From 8ca8eab046b652b481df26dab02cb7fb52d5812c Mon Sep 17 00:00:00 2001 From: Jonathan Fattouh Date: Mon, 18 Jan 2021 16:04:30 +0100 Subject: [PATCH 01/50] Updated Nordic Semi SDK from 14.2.0 to 16.0.0 --- .../ISP4520/s132/config/sdk_config.h | 10864 +++++++++--- .../s132/ses/ble_lora_AT_commands.emProject | 1156 +- .../ISP4520/s132/ses/flash_placement.xml | 20 +- src/apps/ble_lorawan_AT_commands/main.c | 7 +- .../ISP4520/config/sdk_config.h | 8436 ++++++++- .../ISP4520/ses/flash_placement.xml | 12 + .../ISP4520/ses/ping-pong.emProject | 1865 ++ .../ISP4520/ses/ping_pong.emProject | 578 - .../ISP4520/config/sdk_config.h | 8463 ++++++++- .../ISP4520/config/sdk_config.h~RFac87b98.TMP | 2646 --- .../ISP4520/ses/RX_temperature.emProject | 590 - .../ISP4520/ses/flash_placement.xml | 12 + .../lora_tx_cw/ISP4520/config/sdk_config.h | 8466 ++++++++- .../ISP4520/ses/flash_placement.xml | 12 + .../lora_tx_cw/ISP4520/ses/tx-cw.emProject | 1865 ++ .../lora_tx_cw/ISP4520/ses/tx_cw.emProject | 590 - .../ISP4520/config/sdk_config.h | 8463 ++++++++- .../ISP4520/ses/flash_placement.xml | 12 + .../ISP4520/ses/tx-temperature.emProject | 1871 ++ .../ISP4520/ses/tx_temperature.emProject | 590 - .../ISP4520/config/sdk_config.h | 8573 +++++++-- .../ISP4520/ses/class-A.emProject | 1973 +++ .../ISP4520/ses/class_A.emProject | 796 - .../ISP4520/ses/flash_placement.xml | 11 +- .../ISP4520/config/sdk_config.h | 8563 +++++++-- .../ISP4520/ses/class-C.emProject | 1973 +++ .../ISP4520/ses/class_C.emProject | 801 - .../ISP4520/ses/flash_placement.xml | 11 +- src/lora/boards/ISP4520B-AS/spi-board.c | 3 + src/lora/boards/ISP4520B-AS/sx126x-board.c | 10 + src/lora/misc/LoRaMacHelper.h | 2 +- src/lora/system/soft-se/{aes.c => lora_aes.c} | 2 +- src/lora/system/soft-se/{aes.h => lora_aes.h} | 0 .../system/soft-se/{cmac.c => lora_cmac.c} | 4 +- .../system/soft-se/{cmac.h => lora_cmac.h} | 2 +- src/lora/system/soft-se/soft-se.c | 4 +- .../Extract nRF5_SDK_14.2.0_17b948a here.txt | 0 .../ble/ble_advertising/ble_advertising.c | 695 - .../ble/ble_db_discovery/ble_db_discovery.h | 235 - .../ble_ancs_c/ancs_app_attr_get.c | 367 - .../ble_services/ble_ancs_c/ancs_tx_buffer.c | 113 - .../ble_services/ble_ancs_c/ancs_tx_buffer.h | 103 - .../ble/ble_services/ble_gls/ble_gls.h | 323 - .../ble/ble_services/ble_hids/ble_hids.c | 1413 -- .../ble/ble_services/ble_nus/ble_nus.c | 339 - .../experimental_ble_ots/ble_hvx_buffering.h | 104 - .../ots_tx_buffer.c | 113 - .../ots_tx_buffer.h | 103 - .../components/ble/common/ble_conn_state.c | 444 - .../components/ble/peer_manager/pm_mutex.c | 144 - .../components/ble/peer_manager/pm_mutex.h | 125 - .../components/device/nrf51.h | 1202 -- .../components/device/nrf51422_peripherals.h | 164 - .../components/device/nrf51802_peripherals.h | 164 - .../components/device/nrf51822_peripherals.h | 164 - .../components/device/nrf51_bitfields.h | 6140 ------- .../components/device/nrf51_deprecated.h | 451 - .../components/device/nrf51_to_nrf52.h | 963 - .../components/device/nrf51_to_nrf52810.h | 532 - .../components/device/nrf51_to_nrf52840.h | 578 - .../components/device/nrf52.h | 2100 --- .../components/device/nrf52810.h | 1589 -- .../components/device/nrf52810_bitfields.h | 10247 ----------- .../components/device/nrf52810_peripherals.h | 212 - .../components/device/nrf52840.h | 2442 --- .../components/device/nrf52840_bitfields.h | 14790 ---------------- .../components/device/nrf52840_peripherals.h | 298 - .../components/device/nrf52_to_nrf52810.h | 105 - .../components/device/nrf52_to_nrf52840.h | 105 - .../drivers_nrf/ble_flash/ble_flash.c | 313 - .../drivers_nrf/ble_flash/ble_flash.h | 178 - .../drivers_nrf/common/nrf_drv_common.c | 297 - .../drivers_nrf/common/nrf_drv_common.h | 358 - .../drivers_nrf/comp/nrf_drv_comp.c | 239 - .../drivers_nrf/comp/nrf_drv_comp.h | 258 - .../components/drivers_nrf/delay/nrf_delay.h | 269 - .../drivers_nrf/gpiote/nrf_drv_gpiote.h | 385 - .../components/drivers_nrf/hal/nrf_clock.h | 401 - .../components/drivers_nrf/hal/nrf_comp.h | 518 - .../drivers_nrf/hal/nrf_peripherals.h | 73 - .../components/drivers_nrf/hal/nrf_rtc.h | 343 - .../components/drivers_nrf/hal/nrf_saadc.c | 62 - .../components/drivers_nrf/hal/nrf_spim.h | 571 - .../components/drivers_nrf/hal/nrf_twis.h | 706 - .../components/drivers_nrf/i2s/nrf_drv_i2s.c | 446 - .../components/drivers_nrf/i2s/nrf_drv_i2s.h | 255 - .../drivers_nrf/lpcomp/nrf_drv_lpcomp.c | 205 - .../drivers_nrf/lpcomp/nrf_drv_lpcomp.h | 153 - .../components/drivers_nrf/pdm/nrf_drv_pdm.c | 365 - .../components/drivers_nrf/pdm/nrf_drv_pdm.h | 226 - .../drivers_nrf/power/nrf_drv_power.h | 371 - .../components/drivers_nrf/ppi/nrf_drv_ppi.c | 540 - .../components/drivers_nrf/ppi/nrf_drv_ppi.h | 316 - .../components/drivers_nrf/pwm/nrf_drv_pwm.h | 512 - .../drivers_nrf/qdec/nrf_drv_qdec.h | 185 - .../drivers_nrf/qspi/nrf_drv_qspi.c | 308 - .../drivers_nrf/qspi/nrf_drv_qspi.h | 311 - .../components/drivers_nrf/rtc/nrf_drv_rtc.c | 356 - .../components/drivers_nrf/rtc/nrf_drv_rtc.h | 365 - .../drivers_nrf/saadc/nrf_drv_saadc.h | 326 - .../drivers_nrf/spi_master/nrf_drv_spi.c | 774 - .../drivers_nrf/spi_slave/nrf_drv_spis.h | 286 - .../components/drivers_nrf/swi/nrf_drv_swi.c | 508 - .../components/drivers_nrf/swi/nrf_drv_swi.h | 212 - .../drivers_nrf/timer/nrf_drv_timer.c | 339 - .../drivers_nrf/timer/nrf_drv_timer.h | 410 - .../drivers_nrf/twi_master/nrf_drv_twi.c | 1267 -- .../drivers_nrf/twis_slave/nrf_drv_twis.c | 977 - .../drivers_nrf/twis_slave/nrf_drv_twis.h | 409 - .../twis_slave/nrf_drv_twis_inst.def | 20 - .../drivers_nrf/uart/nrf_drv_uart.c | 990 -- .../drivers_nrf/uart/nrf_drv_uart.h | 465 - .../drivers_nrf/usbd/nrf_drv_usbd.h | 947 - .../drivers_nrf/usbd/nrf_drv_usbd_errata.h | 141 - .../components/drivers_nrf/wdt/nrf_drv_wdt.c | 173 - .../bootloader/ble_dfu/nrf_ble_dfu.c | 1252 -- .../libraries/bootloader/dfu/nrf_dfu.c | 238 - .../libraries/bootloader/dfu/nrf_dfu_mbr.h | 131 - .../bootloader/dfu/nrf_dfu_req_handler.h | 192 - .../bootloader/dfu/nrf_dfu_settings.c | 230 - .../libraries/bootloader/dfu/nrf_dfu_svci.c | 123 - .../libraries/bootloader/dfu/nrf_dfu_types.h | 327 - .../libraries/bootloader/dfu/nrf_dfu_utils.c | 678 - .../bootloader/nrf_bootloader_app_start_asm.c | 179 - .../bootloader/nrf_bootloader_info.h | 136 - .../bootloader/serial_dfu/nrf_serial_dfu.c | 432 - .../bootloader/serial_dfu/nrf_serial_dfu.h | 114 - .../bootloader/usb_dfu/nrf_usb_dfu.c | 590 - .../bootloader/usb_dfu/nrf_usb_dfu.h | 113 - .../components/libraries/button/app_button.c | 219 - .../crypto/backend/cc310_lib/cc310_lib_ecdh.c | 234 - .../backend/cc310_lib/cc310_lib_ecdsa.c | 345 - .../crypto/backend/cc310_lib/cc310_lib_hash.c | 333 - .../crypto/backend/cc310_lib/cc310_lib_keys.c | 465 - .../backend/micro_ecc/micro_ecc_lib_ecdh.c | 165 - .../backend/micro_ecc/micro_ecc_lib_ecdsa.c | 214 - .../backend/micro_ecc/micro_ecc_lib_keys.c | 280 - .../nrf_crypto_sw/nrf_crypto_sw_hash.c | 218 - .../libraries/crypto/nrf_crypto_ecdh.c | 153 - .../libraries/crypto/nrf_crypto_ecdh.h | 186 - .../libraries/crypto/nrf_crypto_ecdsa.c | 227 - .../libraries/crypto/nrf_crypto_ecdsa.h | 254 - .../libraries/crypto/nrf_crypto_hash.c | 162 - .../libraries/crypto/nrf_crypto_hash.h | 303 - .../libraries/crypto/nrf_crypto_keys.c | 246 - .../libraries/crypto/nrf_crypto_keys.h | 531 - .../libraries/crypto/nrf_crypto_types.h | 252 - .../eddystone/es_battery_voltage_adc.c | 99 - .../libraries/eddystone/es_security.c | 530 - .../components/libraries/twi/app_twi.h | 169 - .../libraries/usbd/app_usbd_langid.h | 286 - .../libraries/usbd/app_usbd_string_desc.c | 188 - .../usbd/class/audio/app_usbd_audio.c | 559 - .../class/audio/app_usbd_audio_internal.h | 231 - .../usbd/class/cdc/acm/app_usbd_cdc_acm.c | 724 - .../class/cdc/acm/app_usbd_cdc_acm_internal.h | 221 - .../class/hid/generic/app_usbd_hid_generic.c | 343 - .../usbd/class/hid/kbd/app_usbd_hid_kbd.c | 392 - .../libraries/usbd/class/msc/app_usbd_msc.c | 2194 --- .../usbd/config/app_usbd_string_config.h | 131 - .../nfc/t2t_lib/hal_t2t/hal_nfc_t2t.c | 867 - .../nfc/t2t_lib/hal_t2t/hal_nfc_t2t.h | 203 - .../nfc/t4t_lib/hal_t4t/hal_nfc_t4t.c | 1152 -- .../nfc/t4t_lib/hal_t4t/hal_nfc_t4t.h | 203 - .../components/nfc/t4t_lib/nfc_fixes.h | 85 - .../doc/s132_nrf51822_5.0.0_release-notes.pdf | Bin 35595 -> 0 bytes .../s132_nrf52_5.0.0_migration-document.pdf | Bin 99118 -> 0 bytes .../s132_nrf52_5.0.0_softdevice.build_log.htm | 103 - .../s132/hex/s132_nrf52_5.0.0_softdevice.sct | 15 - .../armgcc/armgcc_s132_nrf52832_xxaa.ld | 35 - .../toolchain/arm/arm_startup_nrf51.s | 259 - .../toolchain/arm/arm_startup_nrf52810.s | 349 - .../toolchain/arm/arm_startup_nrf52840.s | 381 - .../components/toolchain/gcc/Makefile.posix | 3 - .../toolchain/gcc/gcc_startup_nrf51.S | 298 - .../toolchain/gcc/gcc_startup_nrf52810.S | 394 - .../toolchain/gcc/gcc_startup_nrf52840.S | 410 - .../components/toolchain/gcc/nrf51_xxaa.ld | 13 - .../components/toolchain/gcc/nrf51_xxab.ld | 13 - .../components/toolchain/gcc/nrf52810_xxaa.ld | 13 - .../components/toolchain/gcc/nrf52840_xxaa.ld | 13 - .../components/toolchain/gcc/nrf5x_common.ld | 168 - .../toolchain/iar/iar_startup_nrf51.s | 311 - .../toolchain/iar/iar_startup_nrf52810.s | 407 - .../toolchain/iar/iar_startup_nrf52840.s | 487 - .../toolchain/ses/ses_nrf51_Vectors.s | 329 - .../toolchain/ses/ses_nrf52810_Vectors.s | 369 - .../toolchain/ses/ses_nrf52840_Vectors.s | 513 - .../toolchain/ses/ses_nrf52_Vectors.s | 458 - .../components/toolchain/system_nrf51.c | 143 - .../components/toolchain/system_nrf51.h | 61 - .../components/toolchain/system_nrf52810.c | 394 - .../components/toolchain/system_nrf52810.h | 61 - .../components/toolchain/system_nrf52840.c | 256 - .../components/toolchain/system_nrf52840.h | 61 - .../external/freertos/license/license.txt | 394 - .../freertos/portable/ARM/nrf51/port.c | 169 - .../freertos/portable/ARM/nrf51/portmacro.h | 75 - .../freertos/portable/ARM/nrf52/port.c | 194 - .../freertos/portable/ARM/nrf52/portmacro.h | 75 - .../freertos/portable/GCC/nrf51/portmacro.h | 77 - .../freertos/portable/GCC/nrf52/portmacro.h | 77 - .../freertos/portable/IAR/nrf51/portmacro.h | 82 - .../freertos/portable/IAR/nrf52/portmacro.h | 82 - .../freertos/source/include/StackMacros.h | 184 - .../freertos/source/include/mpu_wrappers.h | 157 - .../freertos/source/include/projdefs.h | 114 - .../external/freertos/source/include/semphr.h | 844 - .../freertos/source/portable/MemMang/heap_1.c | 174 - .../freertos/source/portable/MemMang/heap_3.c | 135 - .../freertos/source/portable/readme.txt | 19 - .../external/micro-ecc/build_all.bat | 25 - .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 35 - .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 35 - .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 35 - .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 35 - .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 35 - .../common/integration_test_plat_defs.h | 50 - .../common/integration_test_plat_utils.c | 87 - .../common/integration_test_ssi_defs.h | 54 - .../external/nrf_cc310/include/crys_aesccm.h | 265 - .../nrf_cc310/include/crys_aesccm_error.h | 78 - .../nrf_cc310/include/crys_chacha_error.h | 62 - .../nrf_cc310/include/crys_chacha_poly.h | 66 - .../include/crys_chacha_poly_error.h | 58 - .../nrf_cc310/include/crys_common_error.h | 71 - .../nrf_cc310/include/crys_dh_error.h | 102 - .../external/nrf_cc310/include/crys_dh_kg.h | 155 - .../nrf_cc310/include/crys_ec_edw_api.h | 157 - .../nrf_cc310/include/crys_ecpki_build.h | 172 - .../nrf_cc310/include/crys_ecpki_dh.h | 61 - .../nrf_cc310/include/crys_ecpki_domain.h | 51 - .../nrf_cc310/include/crys_ecpki_ecdsa.h | 101 - .../nrf_cc310/include/crys_ecpki_error.h | 213 - .../nrf_cc310/include/crys_ecpki_kg.h | 58 - .../nrf_cc310/include/crys_ecpki_types.h | 429 - .../nrf_cc310/include/crys_hash_defs.h | 36 - .../nrf_cc310/include/crys_hash_error.h | 72 - .../external/nrf_cc310/include/crys_hkdf.h | 89 - .../nrf_cc310/include/crys_hkdf_error.h | 58 - .../nrf_cc310/include/crys_hmac_defs.h | 30 - .../nrf_cc310/include/crys_hmac_error.h | 70 - .../external/nrf_cc310/include/crys_kdf.h | 173 - .../nrf_cc310/include/crys_kdf_error.h | 70 - .../nrf_cc310/include/crys_pka_defs_hw.h | 84 - .../external/nrf_cc310/include/crys_poly.h | 75 - .../external/nrf_cc310/include/crys_rnd.h | 356 - .../nrf_cc310/include/crys_rnd_error.h | 97 - .../external/nrf_cc310/include/crys_rsa_kg.h | 93 - .../nrf_cc310/include/crys_rsa_prim.h | 91 - .../external/nrf_cc310/include/crys_srp.h | 288 - .../nrf_cc310/include/crys_srp_error.h | 55 - .../nrf_cc310/include/dx_reg_base_host.h | 33 - .../external/nrf_cc310/include/sns_silib.h | 82 - .../external/nrf_cc310/include/ssi_aes.h | 285 - .../external/nrf_cc310/include/ssi_aes_defs.h | 53 - .../nrf_cc310/include/ssi_aes_error.h | 77 - .../external/nrf_cc310/include/ssi_bitops.h | 57 - .../nrf_cc310/include/ssi_pal_abort.h | 31 - .../nrf_cc310/include/ssi_pal_abort_plat.h | 23 - .../nrf_cc310/include/ssi_pal_barrier.h | 41 - .../external/nrf_cc310/include/ssi_pal_dma.h | 143 - .../nrf_cc310/include/ssi_pal_dma_defs.h | 47 - .../nrf_cc310/include/ssi_pal_dma_plat.h | 48 - .../nrf_cc310/include/ssi_pal_error.h | 46 - .../nrf_cc310/include/ssi_pal_file_plat.h | 104 - .../external/nrf_cc310/include/ssi_pal_init.h | 55 - .../external/nrf_cc310/include/ssi_pal_log.h | 143 - .../nrf_cc310/include/ssi_pal_log_plat.h | 31 - .../nrf_cc310/include/ssi_pal_malloc_plat.h | 63 - .../external/nrf_cc310/include/ssi_pal_mem.h | 157 - .../nrf_cc310/include/ssi_pal_mem_plat.h | 73 - .../nrf_cc310/include/ssi_pal_memmap.h | 66 - .../nrf_cc310/include/ssi_pal_mutex.h | 89 - .../nrf_cc310/include/ssi_pal_mutex_plat.h | 47 - .../nrf_cc310/include/ssi_pal_perf_plat.h | 31 - .../nrf_cc310/include/ssi_pal_sem_plat.h | 96 - .../nrf_cc310/include/ssi_pal_string_plat.h | 73 - .../nrf_cc310/include/ssi_pal_types.h | 65 - .../nrf_cc310/include/ssi_pal_types_plat.h | 33 - .../nrf_cc310/include/ssi_pka_hw_plat_defs.h | 45 - .../external/nrf_cc310/include/ssi_regs.h | 142 - .../external/nrf_cc310/include/ssi_sram_map.h | 38 - .../external/nrf_cc310/lib/license.txt | 30 - .../external/nrf_cc310/license.txt | 30 - .../external/tiny-AES128/aes.c | 582 - .../external/tiny-AES128/aes.h | 40 - .../external/tiny-AES128/origin.txt | 1 - .../external/tiny-AES128/unlicense.txt | 24 - .../ble/ble_advertising/ble_advertising.c | 813 + .../ble/ble_advertising/ble_advertising.h | 222 +- .../ble/ble_db_discovery/ble_db_discovery.c | 272 +- .../ble/ble_db_discovery/ble_db_discovery.h | 271 + .../components/ble/ble_dtm/ble_dtm.c | 292 +- .../components/ble/ble_dtm/ble_dtm.h | 24 +- .../components/ble/ble_dtm/ble_dtm_hw.h | 22 +- .../components/ble/ble_dtm/ble_dtm_hw_nrf51.c | 20 +- .../components/ble/ble_dtm/ble_dtm_hw_nrf52.c | 54 +- .../ble_link_ctx_manager.c} | 74 +- .../ble_link_ctx_manager.h | 127 + .../components/ble/ble_racp/ble_racp.c | 20 +- .../components/ble/ble_racp/ble_racp.h | 23 +- .../ble_radio_notification.c | 21 +- .../ble_radio_notification.h | 20 +- .../ble_ancs_c/ancs_app_attr_get.c | 390 + .../ble_ancs_c/ancs_app_attr_get.h | 22 +- .../ble_ancs_c/ancs_attr_parser.c | 20 +- .../ble_ancs_c/ancs_attr_parser.h | 20 +- .../ble_services/ble_ancs_c/nrf_ble_ancs_c.c | 253 +- .../ble_services/ble_ancs_c/nrf_ble_ancs_c.h | 228 +- .../ble/ble_services/ble_ans_c/ble_ans_c.c | 263 +- .../ble/ble_services/ble_ans_c/ble_ans_c.h | 218 +- .../ble/ble_services/ble_bas/ble_bas.c | 293 +- .../ble/ble_services/ble_bas/ble_bas.h | 105 +- .../ble/ble_services/ble_bas_c/ble_bas_c.c | 214 +- .../ble/ble_services/ble_bas_c/ble_bas_c.h | 110 +- .../ble/ble_services/ble_bps/ble_bps.c | 237 +- .../ble/ble_services/ble_bps/ble_bps.h | 29 +- .../ble/ble_services/ble_cscs/ble_cscs.c | 241 +- .../ble/ble_services/ble_cscs/ble_cscs.h | 29 +- .../ble/ble_services/ble_cscs/ble_sc_ctrlpt.c | 80 +- .../ble/ble_services/ble_cscs/ble_sc_ctrlpt.h | 23 +- .../ble/ble_services/ble_cts_c/ble_cts_c.c | 120 +- .../ble/ble_services/ble_cts_c/ble_cts_c.h | 127 +- .../ble/ble_services/ble_dfu/ble_dfu.c | 95 +- .../ble/ble_services/ble_dfu/ble_dfu.h | 56 +- .../ble/ble_services/ble_dfu/ble_dfu_bonded.c | 266 +- .../ble_services/ble_dfu/ble_dfu_unbonded.c | 136 +- .../ble/ble_services/ble_dis/ble_dis.c | 84 +- .../ble/ble_services/ble_dis/ble_dis.h | 22 +- .../ble/ble_services/ble_dis_c/ble_dis_c.c | 516 + .../ble/ble_services/ble_dis_c/ble_dis_c.h | 311 + .../ble/ble_services/ble_escs/escs_defs.h | 22 +- .../ble/ble_services/ble_escs/nrf_ble_escs.c | 371 +- .../ble/ble_services/ble_escs/nrf_ble_escs.h | 24 +- .../ble/ble_services/ble_gls/ble_gls.c | 565 +- .../ble/ble_services/ble_gls/ble_gls.h | 330 + .../ble/ble_services/ble_gls/ble_gls_db.c | 20 +- .../ble/ble_services/ble_gls/ble_gls_db.h | 20 +- .../ble/ble_services/ble_hids/ble_hids.c | 1576 ++ .../ble/ble_services/ble_hids/ble_hids.h | 214 +- .../ble/ble_services/ble_hrs/ble_hrs.c | 158 +- .../ble/ble_services/ble_hrs/ble_hrs.h | 24 +- .../ble/ble_services/ble_hrs_c/ble_hrs_c.c | 193 +- .../ble/ble_services/ble_hrs_c/ble_hrs_c.h | 144 +- .../ble/ble_services/ble_hts/ble_hts.c | 238 +- .../ble/ble_services/ble_hts/ble_hts.h | 29 +- .../ble/ble_services/ble_ias/ble_ias.c | 170 +- .../ble/ble_services/ble_ias/ble_ias.h | 82 +- .../ble/ble_services/ble_ias_c/ble_ias_c.c | 95 +- .../ble/ble_services/ble_ias_c/ble_ias_c.h | 95 +- .../ble/ble_services/ble_ipsp/ble_ipsp.c | 70 +- .../ble/ble_services/ble_ipsp/ble_ipsp.h | 20 +- .../ble/ble_services/ble_lbs/ble_lbs.c | 173 +- .../ble/ble_services/ble_lbs/ble_lbs.h | 20 +- .../ble/ble_services/ble_lbs_c/ble_lbs_c.c | 214 +- .../ble/ble_services/ble_lbs_c/ble_lbs_c.h | 114 +- .../ble/ble_services/ble_lls/ble_lls.c | 93 +- .../ble/ble_services/ble_lls/ble_lls.h | 23 +- .../ble/ble_services/ble_nus/ble_nus.c | 354 + .../ble/ble_services/ble_nus/ble_nus.h | 119 +- .../ble/ble_services/ble_nus_c/ble_nus_c.c | 128 +- .../ble/ble_services/ble_nus_c/ble_nus_c.h | 121 +- .../ble/ble_services/ble_rscs/ble_rscs.c | 164 +- .../ble/ble_services/ble_rscs/ble_rscs.h | 30 +- .../ble/ble_services/ble_rscs_c/ble_rscs_c.c | 199 +- .../ble/ble_services/ble_rscs_c/ble_rscs_c.h | 92 +- .../ble/ble_services/ble_tps/ble_tps.c | 90 +- .../ble/ble_services/ble_tps/ble_tps.h | 26 +- .../ble/ble_services}/eddystone/es.h | 20 +- .../ble/ble_services}/eddystone/es_adv.c | 105 +- .../ble/ble_services}/eddystone/es_adv.h | 24 +- .../ble_services}/eddystone/es_adv_frame.c | 48 +- .../ble_services}/eddystone/es_adv_frame.h | 36 +- .../ble_services}/eddystone/es_adv_timing.c | 20 +- .../ble_services}/eddystone/es_adv_timing.h | 20 +- .../eddystone/es_adv_timing_resolver.c | 20 +- .../eddystone/es_adv_timing_resolver.h | 20 +- .../eddystone/es_battery_voltage.h | 20 +- .../eddystone/es_battery_voltage_saadc.c | 20 +- .../ble/ble_services}/eddystone/es_flash.c | 61 +- .../ble/ble_services}/eddystone/es_flash.h | 20 +- .../ble/ble_services}/eddystone/es_gatts.c | 32 +- .../ble/ble_services}/eddystone/es_gatts.h | 20 +- .../ble_services}/eddystone/es_gatts_read.c | 29 +- .../ble_services}/eddystone/es_gatts_read.h | 26 +- .../ble_services}/eddystone/es_gatts_write.c | 20 +- .../ble_services}/eddystone/es_gatts_write.h | 20 +- .../ble/ble_services/eddystone/es_security.c | 606 + .../ble/ble_services}/eddystone/es_security.h | 20 +- .../ble/ble_services}/eddystone/es_slot.c | 29 +- .../ble/ble_services}/eddystone/es_slot.h | 20 +- .../ble/ble_services}/eddystone/es_slot_reg.c | 26 +- .../ble/ble_services}/eddystone/es_slot_reg.h | 20 +- .../ble_services}/eddystone/es_stopwatch.c | 22 +- .../ble_services}/eddystone/es_stopwatch.h | 20 +- .../ble/ble_services}/eddystone/es_tlm.c | 20 +- .../ble/ble_services}/eddystone/es_tlm.h | 20 +- .../ble/ble_services}/eddystone/es_util.h | 20 +- .../ble/ble_services}/eddystone/nrf_ble_es.c | 39 +- .../ble/ble_services}/eddystone/nrf_ble_es.h | 20 +- .../experimental_ble_lns/ble_ln_common.h | 20 +- .../experimental_ble_lns/ble_ln_cp.c | 121 +- .../experimental_ble_lns/ble_ln_cp.h | 39 +- .../experimental_ble_lns/ble_ln_db.c | 20 +- .../experimental_ble_lns/ble_ln_db.h | 20 +- .../experimental_ble_lns/ble_lns.c | 34 +- .../experimental_ble_lns/ble_lns.h | 29 +- .../experimental_ble_ots/ble_ots.c | 54 +- .../experimental_ble_ots/ble_ots.h | 36 +- .../experimental_ble_ots/ble_ots_l2cap.c | 166 +- .../experimental_ble_ots/ble_ots_l2cap.h | 32 +- .../experimental_ble_ots/ble_ots_oacp.c | 165 +- .../experimental_ble_ots/ble_ots_oacp.h | 21 +- .../experimental_ble_ots/ble_ots_object.c | 26 +- .../experimental_ble_ots/ble_ots_object.h | 20 +- .../experimental_gatts_c/nrf_ble_gatts_c.c | 130 +- .../experimental_gatts_c/nrf_ble_gatts_c.h | 112 +- .../experimental_nrf_ble_cgms/cgms_db.c | 23 +- .../experimental_nrf_ble_cgms/cgms_db.h | 20 +- .../experimental_nrf_ble_cgms/cgms_meas.c | 23 +- .../experimental_nrf_ble_cgms/cgms_meas.h | 20 +- .../experimental_nrf_ble_cgms/cgms_racp.c | 396 +- .../experimental_nrf_ble_cgms/cgms_racp.h | 20 +- .../experimental_nrf_ble_cgms/cgms_socp.c | 104 +- .../experimental_nrf_ble_cgms/cgms_socp.h | 28 +- .../experimental_nrf_ble_cgms/cgms_sst.c | 21 +- .../experimental_nrf_ble_cgms/cgms_sst.h | 20 +- .../experimental_nrf_ble_cgms/nrf_ble_cgms.c | 117 +- .../experimental_nrf_ble_cgms/nrf_ble_cgms.h | 55 +- .../nrf_ble_ots_c.c | 170 +- .../nrf_ble_ots_c.h | 209 +- .../nrf_ble_ots_c_l2cap.c | 268 +- .../nrf_ble_ots_c_l2cap.h | 25 +- .../nrf_ble_ots_c_oacp.c | 105 +- .../nrf_ble_ots_c_oacp.h | 46 +- .../ble_services/nrf_ble_bms/nrf_ble_bms.c | 20 +- .../ble_services/nrf_ble_bms/nrf_ble_bms.h | 20 +- .../components/ble/common/ble_advdata.c | 415 +- .../components/ble/common/ble_advdata.h | 185 +- .../components/ble/common/ble_conn_params.c | 44 +- .../components/ble/common/ble_conn_params.h | 20 +- .../components/ble/common/ble_conn_state.c | 489 + .../components/ble/common/ble_conn_state.h | 102 +- .../components/ble/common/ble_date_time.h | 20 +- .../components/ble/common/ble_gatt_db.h | 23 +- .../ble/common/ble_sensor_location.h | 20 +- .../components/ble/common/ble_srv_common.c | 20 +- .../components/ble/common/ble_srv_common.h | 20 +- .../ble/nrf_ble_gatt/nrf_ble_gatt.c | 186 +- .../ble/nrf_ble_gatt/nrf_ble_gatt.h | 36 +- .../components/ble/nrf_ble_gq/nrf_ble_gq.c | 611 + .../components/ble/nrf_ble_gq/nrf_ble_gq.h | 260 + .../components/ble/nrf_ble_qwr/nrf_ble_qwr.c | 99 +- .../components/ble/nrf_ble_qwr/nrf_ble_qwr.h | 147 +- .../ble/nrf_ble_scan/nrf_ble_scan.c | 1328 ++ .../ble/nrf_ble_scan/nrf_ble_scan.h | 500 + .../ble/peer_manager/auth_status_tracker.c | 340 + .../ble/peer_manager/auth_status_tracker.h} | 92 +- .../ble/peer_manager/gatt_cache_manager.c | 422 +- .../ble/peer_manager/gatt_cache_manager.h | 20 +- .../ble/peer_manager/gatts_cache_manager.c | 114 +- .../ble/peer_manager/gatts_cache_manager.h | 22 +- .../components/ble/peer_manager/id_manager.c | 545 +- .../components/ble/peer_manager/id_manager.h | 37 +- .../ble/peer_manager/nrf_ble_lesc.c | 445 + .../ble/peer_manager/nrf_ble_lesc.h | 164 + .../ble/peer_manager/peer_data_storage.c | 187 +- .../ble/peer_manager/peer_data_storage.h | 68 +- .../ble/peer_manager/peer_database.c | 291 +- .../ble/peer_manager/peer_database.h | 182 +- .../components/ble/peer_manager/peer_id.c | 48 +- .../components/ble/peer_manager/peer_id.h | 20 +- .../ble/peer_manager/peer_manager.c | 452 +- .../ble/peer_manager/peer_manager.h | 156 +- .../ble/peer_manager/peer_manager_handler.c | 686 + .../ble/peer_manager/peer_manager_handler.h | 166 + .../ble/peer_manager/peer_manager_internal.h | 26 +- .../ble/peer_manager/peer_manager_types.h | 93 +- .../components/ble/peer_manager/pm_buffer.c | 67 +- .../components/ble/peer_manager/pm_buffer.h | 49 +- .../ble/peer_manager/security_dispatcher.c | 522 +- .../ble/peer_manager/security_dispatcher.h | 26 +- .../ble/peer_manager/security_manager.c | 316 +- .../ble/peer_manager/security_manager.h | 46 +- .../drivers_nrf/nrf_soc_nosd/nrf_error.h | 36 +- .../drivers_nrf/nrf_soc_nosd/nrf_nvic.c | 20 +- .../drivers_nrf/nrf_soc_nosd/nrf_nvic.h | 20 +- .../drivers_nrf/nrf_soc_nosd/nrf_sdm.h} | 44 +- .../drivers_nrf/nrf_soc_nosd/nrf_soc.c | 20 +- .../drivers_nrf/nrf_soc_nosd/nrf_soc.h | 20 +- .../drivers_nrf/radio_config/radio_config.c | 20 +- .../drivers_nrf/radio_config/radio_config.h | 20 +- .../drivers_nrf/sdio/config/sdio_config.h | 20 +- .../components/drivers_nrf/sdio/sdio.c | 20 +- .../components/drivers_nrf/sdio/sdio.h | 20 +- .../drivers_nrf/spi_master/spi_5W_master.c | 20 +- .../drivers_nrf/spi_master/spi_5W_master.h | 20 +- .../deprecated/config/twi_master_config.h | 20 +- .../twi_master/deprecated/twi_hw_master.c | 20 +- .../twi_master/deprecated/twi_master.h | 20 +- .../twi_master/deprecated/twi_sw_master.c | 20 +- .../components/libraries/atomic/nrf_atomic.c} | 326 +- .../components/libraries/atomic/nrf_atomic.h | 274 + .../libraries/atomic/nrf_atomic_internal.h | 129 +- .../atomic/nrf_atomic_sanity_check.h | 20 +- .../libraries/atomic_fifo/nrf_atfifo.c | 53 +- .../libraries/atomic_fifo/nrf_atfifo.h | 55 +- .../atomic_fifo/nrf_atfifo_internal.h | 20 +- .../libraries/atomic_flags/nrf_atflags.c | 160 + .../libraries/atomic_flags/nrf_atflags.h | 184 + .../components/libraries/balloc/nrf_balloc.c | 134 +- .../components/libraries/balloc/nrf_balloc.h | 72 +- .../block_dev/empty/nrf_block_dev_empty.c | 79 +- .../block_dev/empty/nrf_block_dev_empty.h | 62 +- .../libraries/block_dev/nrf_block_dev.h | 20 +- .../block_dev/qspi/nrf_block_dev_qspi.c | 94 +- .../block_dev/qspi/nrf_block_dev_qspi.h | 55 +- .../block_dev/qspi/nrf_serial_flash_params.c | 20 +- .../block_dev/qspi/nrf_serial_flash_params.h | 20 +- .../block_dev/ram/nrf_block_dev_ram.c | 61 +- .../block_dev/ram/nrf_block_dev_ram.h | 46 +- .../block_dev/sdc/nrf_block_dev_sdc.c | 20 +- .../block_dev/sdc/nrf_block_dev_sdc.h | 20 +- .../bootloader/ant_dfu/nrf_dfu_ant.c | 772 + .../bootloader/ble_dfu/nrf_dfu_ble.c | 1261 ++ .../bootloader/ble_dfu/nrf_dfu_ble.h} | 75 +- .../ble_dfu/nrf_dfu_ble_svci_bond_sharing.h} | 84 +- .../libraries/bootloader/dfu/dfu-cc.options | 5 + .../libraries/bootloader/dfu/dfu-cc.pb.c | 123 + .../libraries/bootloader/dfu/dfu-cc.pb.h | 241 + .../libraries/bootloader/dfu/dfu-cc.proto | 82 + .../libraries/bootloader/dfu/nrf_dfu.c} | 94 +- .../libraries/bootloader/dfu/nrf_dfu.h | 85 + .../libraries/bootloader/dfu/nrf_dfu_flash.c | 83 +- .../libraries/bootloader/dfu/nrf_dfu_flash.h | 28 +- .../bootloader/dfu/nrf_dfu_handling_error.c | 22 +- .../bootloader/dfu/nrf_dfu_handling_error.h | 47 +- .../libraries/bootloader/dfu/nrf_dfu_mbr.c | 99 +- .../libraries/bootloader/dfu/nrf_dfu_mbr.h | 90 + .../bootloader/dfu/nrf_dfu_req_handler.c | 865 + .../bootloader/dfu/nrf_dfu_req_handler.h | 345 + .../bootloader/dfu/nrf_dfu_settings.c | 425 + .../bootloader/dfu/nrf_dfu_settings.h | 68 +- .../bootloader/dfu/nrf_dfu_settings_svci.c | 20 +- .../libraries/bootloader/dfu/nrf_dfu_svci.c} | 70 +- .../bootloader/dfu/nrf_dfu_svci_handler.c | 77 +- .../bootloader/dfu/nrf_dfu_transport.c | 42 +- .../bootloader/dfu/nrf_dfu_transport.h | 53 +- .../bootloader/dfu/nrf_dfu_trigger_usb.c | 244 + .../bootloader/dfu/nrf_dfu_trigger_usb.h | 74 + .../libraries/bootloader/dfu/nrf_dfu_types.h | 338 + .../libraries/bootloader/dfu/nrf_dfu_utils.c | 220 + .../libraries/bootloader/dfu/nrf_dfu_utils.h | 154 + .../bootloader/dfu/nrf_dfu_validation.c | 1095 ++ .../bootloader/dfu/nrf_dfu_validation.h | 199 + .../bootloader/dfu/nrf_dfu_ver_validation.c | 312 + .../bootloader/dfu/nrf_dfu_ver_validation.h | 64 + .../libraries/bootloader/nrf_bootloader.c | 524 + .../libraries/bootloader/nrf_bootloader.h | 47 +- .../bootloader/nrf_bootloader_app_start.c | 57 +- .../bootloader/nrf_bootloader_app_start.h | 56 +- .../nrf_bootloader_app_start_final.c | 244 + .../bootloader/nrf_bootloader_dfu_timers.c | 268 + .../bootloader/nrf_bootloader_dfu_timers.h | 111 + .../bootloader/nrf_bootloader_fw_activation.c | 438 + .../nrf_bootloader_fw_activation.h} | 91 +- .../bootloader/nrf_bootloader_info.c | 56 +- .../bootloader/nrf_bootloader_info.h | 210 + .../bootloader/nrf_bootloader_wdt.c} | 131 +- .../libraries/bootloader/nrf_bootloader_wdt.h | 79 + .../bootloader/serial_dfu/nrf_dfu_serial.c | 273 + .../bootloader/serial_dfu/nrf_dfu_serial.h | 111 + .../serial_dfu/nrf_dfu_serial_uart.c | 238 + .../serial_dfu/nrf_dfu_serial_usb.c | 368 + .../components/libraries/bsp/bsp.c | 140 +- .../components/libraries/bsp/bsp.h | 24 +- .../components/libraries/bsp/bsp_btn_ant.c | 20 +- .../components/libraries/bsp/bsp_btn_ant.h | 20 +- .../components/libraries/bsp/bsp_btn_ble.c | 25 +- .../components/libraries/bsp/bsp_btn_ble.h | 20 +- .../components/libraries/bsp/bsp_cli.c} | 82 +- .../components/libraries/bsp/bsp_cli.h | 83 + .../components/libraries/bsp/bsp_config.h | 20 +- .../components/libraries/bsp/bsp_nfc.c | 20 +- .../components/libraries/bsp/bsp_nfc.h | 20 +- .../components/libraries/button/app_button.c | 349 + .../components/libraries/button/app_button.h | 32 +- .../libraries/cli/ble_uart/nrf_cli_ble_uart.c | 88 +- .../libraries/cli/ble_uart/nrf_cli_ble_uart.h | 22 +- .../libraries/cli/cdc_acm/nrf_cli_cdc_acm.c | 120 +- .../libraries/cli/cdc_acm/nrf_cli_cdc_acm.h | 29 +- .../components/libraries/cli/cli_utils_cmds.c | 164 + .../libraries/cli/libuarte/nrf_cli_libuarte.c | 252 + .../libraries/cli/libuarte/nrf_cli_libuarte.h | 112 + .../components/libraries/cli/nrf_cli.c | 1206 +- .../components/libraries/cli/nrf_cli.h | 237 +- .../components/libraries/cli/nrf_cli_types.h | 20 +- .../components/libraries/cli/nrf_cli_vt100.h | 27 +- .../libraries/cli/rtt/nrf_cli_rtt.c | 88 +- .../libraries/cli/rtt/nrf_cli_rtt.h | 22 +- .../libraries/cli/uart/nrf_cli_uart.c | 40 +- .../libraries/cli/uart/nrf_cli_uart.h | 22 +- .../components/libraries/crc16/crc16.c | 20 +- .../components/libraries/crc16/crc16.h | 20 +- .../components/libraries/crc32/crc32.c | 20 +- .../components/libraries/crc32/crc32.h | 20 +- .../crypto/backend/cc310/cc310_backend_aes.c | 887 + .../crypto/backend/cc310/cc310_backend_aes.h | 187 + .../backend/cc310/cc310_backend_aes_aead.c | 366 + .../backend/cc310/cc310_backend_aes_aead.h | 124 + .../cc310/cc310_backend_chacha_poly_aead.c | 214 + .../cc310/cc310_backend_chacha_poly_aead.h | 99 + .../crypto/backend/cc310/cc310_backend_ecc.c | 727 + .../crypto/backend/cc310/cc310_backend_ecc.h | 734 + .../crypto/backend/cc310/cc310_backend_ecdh.c | 191 + .../crypto/backend/cc310/cc310_backend_ecdh.h | 199 + .../backend/cc310/cc310_backend_ecdsa.c | 223 + .../backend/cc310/cc310_backend_ecdsa.h | 245 + .../backend/cc310/cc310_backend_eddsa.c | 142 + .../backend/cc310/cc310_backend_eddsa.h | 72 + .../crypto/backend/cc310/cc310_backend_hash.c | 311 + .../crypto/backend/cc310/cc310_backend_hash.h | 122 + .../crypto/backend/cc310/cc310_backend_hmac.c | 272 + .../crypto/backend/cc310/cc310_backend_hmac.h | 122 + .../backend/cc310/cc310_backend_init.c} | 146 +- .../backend/cc310/cc310_backend_mutex.c} | 35 +- .../backend/cc310/cc310_backend_mutex.h | 111 + .../crypto/backend/cc310/cc310_backend_rng.c | 272 + .../crypto/backend/cc310/cc310_backend_rng.h | 97 + .../backend/cc310/cc310_backend_shared.c | 141 + .../backend/cc310/cc310_backend_shared.h} | 67 +- .../backend/cc310_bl/cc310_bl_backend_ecc.c | 165 + .../backend/cc310_bl/cc310_bl_backend_ecc.h | 155 + .../backend/cc310_bl/cc310_bl_backend_ecdh.h | 75 + .../backend/cc310_bl/cc310_bl_backend_ecdsa.c | 197 + .../backend/cc310_bl/cc310_bl_backend_ecdsa.h | 124 + .../backend/cc310_bl/cc310_bl_backend_hash.c | 276 + .../backend/cc310_bl/cc310_bl_backend_hash.h | 97 + .../backend/cc310_bl/cc310_bl_backend_init.c} | 113 +- .../cc310_bl/cc310_bl_backend_shared.c | 94 + .../cc310_bl/cc310_bl_backend_shared.h} | 60 +- .../backend/cifra/cifra_backend_aes_aead.c | 205 + .../backend/cifra/cifra_backend_aes_aead.h} | 96 +- .../backend/mbedtls/mbedtls_backend_aes.c | 1213 ++ .../backend/mbedtls/mbedtls_backend_aes.h | 227 + .../mbedtls/mbedtls_backend_aes_aead.c | 384 + .../mbedtls/mbedtls_backend_aes_aead.h | 123 + .../backend/mbedtls/mbedtls_backend_ecc.c | 585 + .../backend/mbedtls/mbedtls_backend_ecc.h | 519 + .../backend/mbedtls/mbedtls_backend_ecdh.c | 124 + .../backend/mbedtls/mbedtls_backend_ecdh.h | 169 + .../backend/mbedtls/mbedtls_backend_ecdsa.c | 176 + .../backend/mbedtls/mbedtls_backend_ecdsa.h | 240 + .../backend/mbedtls/mbedtls_backend_hash.c | 196 + .../backend/mbedtls/mbedtls_backend_hash.h | 128 + .../backend/mbedtls/mbedtls_backend_hmac.c | 230 + .../backend/mbedtls/mbedtls_backend_hmac.h | 140 + .../backend/mbedtls/mbedtls_backend_init.c | 106 + .../backend/micro_ecc/micro_ecc_backend_ecc.c | 341 + .../backend/micro_ecc/micro_ecc_backend_ecc.h | 303 + .../micro_ecc/micro_ecc_backend_ecdh.c | 103 + .../micro_ecc/micro_ecc_backend_ecdh.h | 105 + .../micro_ecc/micro_ecc_backend_ecdsa.c | 166 + .../micro_ecc/micro_ecc_backend_ecdsa.h | 124 + .../micro_ecc/micro_ecc_backend_shared.h} | 54 +- .../backend/nrf_hw/nrf_hw_backend_init.c | 95 + .../backend/nrf_hw/nrf_hw_backend_rng.c} | 113 +- .../backend/nrf_hw/nrf_hw_backend_rng.h | 104 + .../nrf_hw/nrf_hw_backend_rng_mbedtls.c | 168 + .../nrf_hw/nrf_hw_backend_rng_mbedtls.h | 108 + .../backend/nrf_sw/nrf_sw_backend_hash.c | 139 + .../backend/nrf_sw/nrf_sw_backend_hash.h} | 86 +- .../oberon/oberon_backend_chacha_poly_aead.c | 153 + .../oberon/oberon_backend_chacha_poly_aead.h | 100 + .../backend/oberon/oberon_backend_ecc.c | 464 + .../backend/oberon/oberon_backend_ecc.h | 314 + .../backend/oberon/oberon_backend_ecdh.c | 116 + .../backend/oberon/oberon_backend_ecdh.h | 108 + .../backend/oberon/oberon_backend_ecdsa.c | 120 + .../backend/oberon/oberon_backend_ecdsa.h} | 118 +- .../backend/oberon/oberon_backend_eddsa.c | 97 + .../backend/oberon/oberon_backend_eddsa.h | 72 + .../backend/oberon/oberon_backend_hash.c | 182 + .../backend/oberon/oberon_backend_hash.h | 123 + .../backend/oberon/oberon_backend_hmac.c | 169 + .../backend/oberon/oberon_backend_hmac.h | 136 + .../backend/optiga/optiga_backend_ecc.c | 305 + .../backend/optiga/optiga_backend_ecc.h | 200 + .../backend/optiga/optiga_backend_ecdh.c | 110 + .../backend/optiga/optiga_backend_ecdh.h | 83 + .../backend/optiga/optiga_backend_ecdsa.c | 155 + .../backend/optiga/optiga_backend_ecdsa.h | 98 + .../backend/optiga/optiga_backend_init.c | 128 + .../backend/optiga/optiga_backend_rng.c | 147 + .../backend/optiga/optiga_backend_rng.h | 100 + .../backend/optiga/optiga_backend_utils.c | 265 + .../backend/optiga/optiga_backend_utils.h | 112 + .../components/libraries/crypto/nrf_crypto.h | 78 + .../libraries/crypto/nrf_crypto_aead.c | 159 + .../libraries/crypto/nrf_crypto_aead.h | 235 + .../crypto/nrf_crypto_aead_backend.h | 100 + .../libraries/crypto/nrf_crypto_aead_shared.h | 147 + .../libraries/crypto/nrf_crypto_aes.c | 319 + .../libraries/crypto/nrf_crypto_aes.h | 481 + .../libraries/crypto/nrf_crypto_aes_backend.h | 112 + .../libraries/crypto/nrf_crypto_aes_shared.c | 121 + .../libraries/crypto/nrf_crypto_aes_shared.h | 218 + .../libraries/crypto/nrf_crypto_ecc.c | 1314 ++ .../libraries/crypto/nrf_crypto_ecc.h | 969 + .../libraries/crypto/nrf_crypto_ecc_backend.h | 356 + .../libraries/crypto/nrf_crypto_ecc_shared.h | 229 + .../libraries/crypto/nrf_crypto_ecdh.c | 277 + .../libraries/crypto/nrf_crypto_ecdh.h | 201 + .../crypto/nrf_crypto_ecdh_backend.h | 185 + .../libraries/crypto/nrf_crypto_ecdh_shared.h | 79 + .../libraries/crypto/nrf_crypto_ecdsa.c | 454 + .../libraries/crypto/nrf_crypto_ecdsa.h | 245 + .../crypto/nrf_crypto_ecdsa_backend.h | 251 + .../crypto/nrf_crypto_ecdsa_shared.h | 103 + .../libraries/crypto/nrf_crypto_eddsa.c | 162 + .../libraries/crypto/nrf_crypto_eddsa.h | 127 + .../crypto/nrf_crypto_eddsa_backend.h | 77 + .../crypto/nrf_crypto_eddsa_shared.h | 111 + .../libraries/crypto/nrf_crypto_error.c | 102 + .../libraries/crypto/nrf_crypto_error.h | 113 + .../libraries/crypto/nrf_crypto_hash.c | 205 + .../libraries/crypto/nrf_crypto_hash.h | 268 + .../crypto/nrf_crypto_hash_backend.h} | 74 +- .../libraries/crypto/nrf_crypto_hash_shared.h | 120 + .../libraries/crypto/nrf_crypto_hkdf.c | 225 + .../libraries/crypto/nrf_crypto_hkdf.h | 141 + .../libraries/crypto/nrf_crypto_hmac.c | 203 + .../libraries/crypto/nrf_crypto_hmac.h | 226 + .../crypto/nrf_crypto_hmac_backend.h | 93 + .../libraries/crypto/nrf_crypto_hmac_shared.h | 150 + .../libraries/crypto/nrf_crypto_init.c | 122 + .../libraries/crypto/nrf_crypto_init.h | 145 + .../libraries/crypto/nrf_crypto_mem.h | 185 + .../libraries/crypto/nrf_crypto_rng.c | 430 + .../libraries/crypto/nrf_crypto_rng.h | 285 + .../libraries/crypto/nrf_crypto_rng_backend.h | 83 + .../libraries/crypto/nrf_crypto_rng_shared.h | 142 + .../libraries/crypto/nrf_crypto_shared.c} | 94 +- .../libraries/crypto/nrf_crypto_shared.h | 189 + .../libraries/crypto/nrf_crypto_svc.c | 23 +- .../libraries/crypto/nrf_crypto_types.h | 113 + .../components/libraries/csense/nrf_csense.c | 47 +- .../components/libraries/csense/nrf_csense.h | 20 +- .../libraries/csense/nrf_csense_macros.h | 20 +- .../libraries/csense_drv/nrf_drv_csense.c | 54 +- .../libraries/csense_drv/nrf_drv_csense.h | 21 +- .../components/libraries/delay/nrf_delay.h} | 63 +- .../components/libraries/ecc/ecc.c | 33 +- .../components/libraries/ecc/ecc.h | 20 +- .../experimental_section_vars/nrf_section.h | 20 +- .../nrf_section_iter.c | 20 +- .../nrf_section_iter.h | 20 +- .../experimental_task_manager/task_manager.c | 36 +- .../experimental_task_manager/task_manager.h | 20 +- .../task_manager_core_armgcc.S | 0 .../task_manager_core_iar.s | 0 .../task_manager_core_keil.s | 0 .../components/libraries/fds/fds.c | 175 +- .../components/libraries/fds/fds.h | 129 +- .../libraries/fds/fds_internal_defs.h | 28 +- .../components/libraries/fifo/app_fifo.c | 20 +- .../components/libraries/fifo/app_fifo.h | 20 +- .../libraries/fstorage/nrf_fstorage.c | 165 +- .../libraries/fstorage/nrf_fstorage.h | 23 +- .../libraries/fstorage/nrf_fstorage_nvmc.c | 26 +- .../libraries/fstorage/nrf_fstorage_nvmc.h | 20 +- .../libraries/fstorage/nrf_fstorage_sd.c | 78 +- .../libraries/fstorage/nrf_fstorage_sd.h | 20 +- .../components/libraries/gfx/nrf_gfx.c | 44 +- .../components/libraries/gfx/nrf_gfx.h | 20 +- .../components/libraries/gfx/nrf_lcd.h | 24 +- .../components/libraries/gpiote/app_gpiote.c | 106 +- .../components/libraries/gpiote/app_gpiote.h | 83 +- .../libraries/hardfault/hardfault.h | 20 +- .../libraries/hardfault/hardfault_genhf.h | 20 +- .../hardfault/hardfault_implementation.c | 52 +- .../nrf51/handler/hardfault_handler_gcc.c | 20 +- .../nrf51/handler/hardfault_handler_iar.c | 20 +- .../nrf51/handler/hardfault_handler_keil.c | 20 +- .../nrf52/handler/hardfault_handler_gcc.c | 37 +- .../nrf52/handler/hardfault_handler_iar.c | 20 +- .../nrf52/handler/hardfault_handler_keil.c | 20 +- .../components/libraries/hci/hci_mem_pool.c | 20 +- .../components/libraries/hci/hci_mem_pool.h | 20 +- .../components/libraries/hci/hci_slip.c | 20 +- .../components/libraries/hci/hci_slip.h | 20 +- .../components/libraries/hci/hci_transport.c | 20 +- .../components/libraries/hci/hci_transport.h | 20 +- .../libraries/led_softblink/led_softblink.c | 44 +- .../libraries/led_softblink/led_softblink.h | 20 +- .../libraries/libuarte/nrf_libuarte_async.c | 658 + .../libraries/libuarte/nrf_libuarte_async.h | 383 + .../libraries/libuarte/nrf_libuarte_drv.c | 835 + .../libraries/libuarte/nrf_libuarte_drv.h | 278 + .../components/libraries/log}/nrf_log.h | 152 +- .../libraries/log/nrf_log_backend_flash.h | 125 + .../log}/nrf_log_backend_interface.h | 125 +- .../libraries/log}/nrf_log_backend_rtt.h | 35 +- .../libraries/log}/nrf_log_backend_uart.h | 35 +- .../components/libraries/log}/nrf_log_ctrl.h | 64 +- .../libraries/log}/nrf_log_default_backends.h | 20 +- .../libraries/log/nrf_log_instance.h | 163 + .../libraries/log}/nrf_log_str_formatter.h | 41 +- .../components/libraries/log/nrf_log_types.h | 93 + .../libraries/log/src/nrf_log_backend_flash.c | 740 + .../libraries/log}/src/nrf_log_backend_rtt.c | 50 +- .../log}/src/nrf_log_backend_serial.c | 26 +- .../log}/src/nrf_log_backend_serial.h | 20 +- .../libraries/log}/src/nrf_log_backend_uart.c | 20 +- .../log}/src/nrf_log_ctrl_internal.h | 37 +- .../log}/src/nrf_log_default_backends.c | 28 +- .../libraries/log}/src/nrf_log_frontend.c | 877 +- .../libraries/log}/src/nrf_log_internal.h | 334 +- .../log}/src/nrf_log_str_formatter.c | 85 +- .../libraries/low_power_pwm/low_power_pwm.c | 36 +- .../libraries/low_power_pwm/low_power_pwm.h | 26 +- .../libraries/mem_manager/mem_manager.c | 22 +- .../libraries/mem_manager/mem_manager.h | 20 +- .../components/libraries/memobj}/nrf_memobj.c | 123 +- .../components/libraries/memobj}/nrf_memobj.h | 125 +- .../components/libraries/mpu/nrf_mpu_lib.c} | 99 +- .../components/libraries/mpu/nrf_mpu_lib.h} | 52 +- .../components/libraries/mutex/nrf_mtx.h | 20 +- .../components/libraries/pwm/app_pwm.c | 43 +- .../components/libraries/pwm/app_pwm.h | 23 +- .../libraries/pwr_mgmt/nrf_pwr_mgmt.c | 47 +- .../libraries/pwr_mgmt/nrf_pwr_mgmt.h | 28 +- .../components/libraries/queue/nrf_queue.c | 146 +- .../components/libraries/queue/nrf_queue.h | 115 +- .../libraries/ringbuf}/nrf_ringbuf.c | 25 +- .../libraries/ringbuf}/nrf_ringbuf.h | 80 +- .../libraries/scheduler/app_scheduler.c | 20 +- .../libraries/scheduler/app_scheduler.h | 20 +- .../scheduler/app_scheduler_serconn.c | 20 +- .../components/libraries/sdcard/app_sdcard.c | 24 +- .../components/libraries/sdcard/app_sdcard.h | 20 +- .../libraries/sensorsim/sensorsim.c | 20 +- .../libraries/sensorsim/sensorsim.h | 20 +- .../components/libraries/serial/nrf_serial.c | 42 +- .../components/libraries/serial/nrf_serial.h | 20 +- .../components/libraries/sha256/sha256.c | 20 +- .../components/libraries/sha256/sha256.h | 20 +- .../libraries/simple_timer/app_simple_timer.c | 20 +- .../libraries/simple_timer/app_simple_timer.h | 20 +- .../components/libraries/slip/slip.c | 20 +- .../components/libraries/slip/slip.h | 20 +- .../libraries/sortlist/nrf_sortlist.c | 20 +- .../libraries/sortlist/nrf_sortlist.h | 20 +- .../libraries/spi_mngr/nrf_spi_mngr.c | 160 +- .../libraries/spi_mngr/nrf_spi_mngr.h | 30 +- .../libraries/stack_guard}/nrf_stack_guard.c | 36 +- .../libraries/stack_guard}/nrf_stack_guard.h | 32 +- .../libraries/stack_info/nrf_stack_info.h | 163 + .../libraries/strerror/nrf_strerror.c | 37 +- .../libraries/strerror/nrf_strerror.h | 20 +- .../libraries/svc/nrf_svc_function.h | 20 +- .../libraries/svc/nrf_svc_handler.c | 22 +- .../components/libraries/svc/nrf_svci.h | 22 +- .../libraries/svc/nrf_svci_async_function.h | 20 +- .../libraries/svc/nrf_svci_async_handler.h | 20 +- .../components/libraries/timer/app_timer.c | 43 +- .../components/libraries/timer/app_timer.h | 83 +- .../components/libraries/timer/app_timer2.c | 637 + .../libraries/timer/app_timer_freertos.c | 40 +- .../libraries/timer/app_timer_rtx.c | 20 +- .../components/libraries/timer/drv_rtc.c | 358 + .../components/libraries/timer/drv_rtc.h | 305 + .../libraries/twi_mngr/nrf_twi_mngr.c | 20 +- .../libraries/twi_mngr/nrf_twi_mngr.h | 20 +- .../libraries/twi_sensor/nrf_twi_sensor.c | 220 + .../libraries/twi_sensor/nrf_twi_sensor.h | 314 + .../components/libraries/uart/app_uart.c | 41 +- .../components/libraries/uart/app_uart.h | 20 +- .../components/libraries/uart/app_uart_fifo.c | 35 +- .../components/libraries/uart/retarget.c | 30 +- .../components/libraries/usbd/app_usbd.c | 768 +- .../components/libraries/usbd/app_usbd.h | 302 +- .../libraries/usbd/app_usbd_class_base.h | 395 +- .../components/libraries/usbd/app_usbd_core.c | 423 +- .../components/libraries/usbd/app_usbd_core.h | 74 +- .../libraries/usbd/app_usbd_descriptor.h | 64 +- .../libraries/usbd/app_usbd_langid.h | 300 + .../libraries/usbd/app_usbd_request.h | 77 +- .../libraries/usbd/app_usbd_serial_num.c | 84 + .../libraries/usbd/app_usbd_serial_num.h} | 60 +- .../libraries/usbd/app_usbd_string_desc.c | 295 + .../libraries/usbd/app_usbd_string_desc.h | 179 + .../libraries/usbd/app_usbd_types.h | 114 +- .../usbd/class/audio/app_usbd_audio.c | 861 + .../usbd/class/audio/app_usbd_audio.h | 168 +- .../usbd/class/audio/app_usbd_audio_desc.h | 126 +- .../class/audio/app_usbd_audio_internal.h | 291 + .../usbd/class/audio/app_usbd_audio_types.h | 76 +- .../usbd/class/cdc/acm/app_usbd_cdc_acm.c | 1199 ++ .../usbd/class/cdc/acm/app_usbd_cdc_acm.h | 117 +- .../class/cdc/acm/app_usbd_cdc_acm_internal.h | 287 + .../usbd/class/cdc/app_usbd_cdc_desc.h | 20 +- .../usbd/class/cdc/app_usbd_cdc_types.h | 40 +- .../usbd/class/dummy/app_usbd_dummy.c | 115 + .../usbd/class/dummy/app_usbd_dummy.h | 138 + .../class/dummy/app_usbd_dummy_internal.h | 115 + .../usbd/class/dummy/app_usbd_dummy_types.h} | 60 +- .../libraries/usbd/class/hid/app_usbd_hid.c | 362 +- .../libraries/usbd/class/hid/app_usbd_hid.h | 241 +- .../usbd/class/hid/app_usbd_hid_types.h | 63 +- .../class/hid/generic/app_usbd_hid_generic.c | 658 + .../class/hid/generic/app_usbd_hid_generic.h | 141 +- .../hid/generic/app_usbd_hid_generic_desc.h | 20 +- .../generic/app_usbd_hid_generic_internal.h | 84 +- .../usbd/class/hid/kbd/app_usbd_hid_kbd.c | 611 + .../usbd/class/hid/kbd/app_usbd_hid_kbd.h | 61 +- .../class/hid/kbd/app_usbd_hid_kbd_desc.h | 20 +- .../class/hid/kbd/app_usbd_hid_kbd_internal.h | 111 +- .../usbd/class/hid/mouse/app_usbd_hid_mouse.c | 314 +- .../usbd/class/hid/mouse/app_usbd_hid_mouse.h | 69 +- .../class/hid/mouse/app_usbd_hid_mouse_desc.h | 20 +- .../hid/mouse/app_usbd_hid_mouse_internal.h | 102 +- .../libraries/usbd/class/msc/app_usbd_msc.c | 2492 +++ .../libraries/usbd/class/msc/app_usbd_msc.h | 64 +- .../usbd/class/msc/app_usbd_msc_desc.h | 32 +- .../usbd/class/msc/app_usbd_msc_internal.h | 237 +- .../usbd/class/msc/app_usbd_msc_scsi.h | 94 +- .../usbd/class/msc/app_usbd_msc_types.h | 67 +- .../app_usbd_nrf_dfu_trigger.c | 374 + .../app_usbd_nrf_dfu_trigger.h | 166 + .../app_usbd_nrf_dfu_trigger_internal.h | 203 + .../app_usbd_nrf_dfu_trigger_types.h | 145 + .../components/libraries/util/app_error.c | 40 +- .../components/libraries/util/app_error.h | 48 +- .../libraries/util/app_error_handler_gcc.c | 101 + .../libraries/util/app_error_handler_iar.c | 101 + .../libraries/util/app_error_handler_keil.c | 89 + .../libraries/util/app_error_weak.c | 31 +- .../libraries/util/app_error_weak.h | 22 +- .../components/libraries/util/app_util.h | 280 +- .../components/libraries/util/app_util_bds.h | 20 +- .../libraries/util/app_util_platform.c | 20 +- .../libraries/util/app_util_platform.h | 57 +- .../components/libraries/util/nordic_common.h | 26 +- .../components/libraries/util/nrf_assert.c | 20 +- .../components/libraries/util/nrf_assert.h | 21 +- .../components/libraries/util/nrf_bitmask.h | 20 +- .../components/libraries/util/sdk_alloca.h | 85 + .../components/libraries/util/sdk_common.h | 20 +- .../components/libraries/util/sdk_errors.h | 50 +- .../components/libraries/util/sdk_macros.h | 107 +- .../libraries/util/sdk_mapped_flags.c | 20 +- .../libraries/util/sdk_mapped_flags.h | 20 +- .../components/libraries/util/sdk_os.h | 20 +- .../components/libraries/util/sdk_resources.h | 28 +- .../ac_rec_parser/nfc_ac_rec_parser.c | 24 +- .../ac_rec_parser/nfc_ac_rec_parser.h | 28 +- .../nfc_ble_oob_advdata_parser.c | 94 +- .../nfc_ble_oob_advdata_parser.h | 53 +- .../le_oob_rec_parser/nfc_le_oob_rec_parser.c | 24 +- .../le_oob_rec_parser/nfc_le_oob_rec_parser.h | 28 +- .../connection_handover/ac_rec/nfc_ac_rec.c | 20 +- .../connection_handover/ac_rec/nfc_ac_rec.h | 20 +- .../ble_oob_advdata/nfc_ble_oob_advdata.c | 26 +- .../ble_oob_advdata/nfc_ble_oob_advdata.h | 94 + .../ble_pair_lib/nfc_ble_pair_lib.c | 198 +- .../ble_pair_lib/nfc_ble_pair_lib.h | 20 +- .../ble_pair_msg/nfc_ble_pair_msg.c | 20 +- .../ble_pair_msg/nfc_ble_pair_msg.h | 20 +- .../common/nfc_ble_pair_common.c | 21 +- .../common/nfc_ble_pair_common.h} | 91 +- .../ep_oob_rec/nfc_ep_oob_rec.c | 40 +- .../ep_oob_rec/nfc_ep_oob_rec.h | 20 +- .../connection_handover/hs_rec/nfc_hs_rec.c | 20 +- .../connection_handover/hs_rec/nfc_hs_rec.h | 20 +- .../le_oob_rec/nfc_le_oob_rec.c | 20 +- .../le_oob_rec/nfc_le_oob_rec.h | 20 +- .../nfc/ndef/generic/message/nfc_ndef_msg.c | 20 +- .../nfc/ndef/generic/message/nfc_ndef_msg.h | 20 +- .../nfc/ndef/generic/record/nfc_ndef_record.c | 20 +- .../nfc/ndef/generic/record/nfc_ndef_record.h | 20 +- .../nfc/ndef/launchapp/nfc_launchapp_msg.c | 20 +- .../nfc/ndef/launchapp/nfc_launchapp_msg.h | 20 +- .../nfc/ndef/launchapp/nfc_launchapp_rec.c | 20 +- .../nfc/ndef/launchapp/nfc_launchapp_rec.h | 20 +- .../ndef/parser/message/nfc_ndef_msg_parser.c | 26 +- .../ndef/parser/message/nfc_ndef_msg_parser.h | 20 +- .../message/nfc_ndef_msg_parser_local.c | 20 +- .../message/nfc_ndef_msg_parser_local.h | 20 +- .../parser/record/nfc_ndef_record_parser.c | 29 +- .../parser/record/nfc_ndef_record_parser.h | 20 +- .../components/nfc/ndef/text/nfc_text_rec.c | 20 +- .../components/nfc/ndef/text/nfc_text_rec.h | 20 +- .../components/nfc/ndef/uri/nfc_uri_msg.c | 20 +- .../components/nfc/ndef/uri/nfc_uri_msg.h | 20 +- .../components/nfc/ndef/uri/nfc_uri_rec.c | 20 +- .../components/nfc/ndef/uri/nfc_uri_rec.h | 20 +- .../components/nfc/platform/nfc_platform.c | 126 + .../components/nfc/platform/nfc_platform.h | 98 + .../components/nfc/t2t_lib/license.txt | 2 +- .../components/nfc/t2t_lib/nfc_t2t_lib.h | 20 +- .../nfc/t2t_parser/nfc_t2t_parser.c | 63 +- .../nfc/t2t_parser/nfc_t2t_parser.h | 20 +- .../components/nfc/t2t_parser/nfc_tlv_block.h | 20 +- .../components/nfc/t4t_lib/license.txt | 2 +- .../components/nfc/t4t_lib/nfc_t4t_lib.h | 20 +- .../nfc/t4t_parser/apdu/nfc_t4t_apdu.c | 26 +- .../nfc/t4t_parser/apdu/nfc_t4t_apdu.h | 20 +- .../nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c | 25 +- .../nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h | 20 +- .../nfc_t4t_hl_detection_procedures.c | 25 +- .../nfc_t4t_hl_detection_procedures.h | 20 +- .../nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c | 25 +- .../nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h | 20 +- .../components/sdk_validation.h | 36 +- .../components/softdevice/common/nrf_sdh.c | 96 +- .../components/softdevice/common/nrf_sdh.h | 21 +- .../softdevice/common/nrf_sdh_ant.c | 44 +- .../softdevice/common/nrf_sdh_ant.h | 20 +- .../softdevice/common/nrf_sdh_ble.c | 70 +- .../softdevice/common/nrf_sdh_ble.h | 25 +- .../softdevice/common/nrf_sdh_freertos.c | 21 +- .../softdevice/common/nrf_sdh_freertos.h | 20 +- .../softdevice/common/nrf_sdh_soc.c | 20 +- .../softdevice/common/nrf_sdh_soc.h | 22 +- .../softdevice/mbr/headers}/nrf_mbr.h | 100 +- .../softdevice/mbr}/headers/nrf_svc.h | 12 +- .../mbr_nrf52_2.4.1_licence-agreement.txt} | 2 +- .../s112_nrf52_7.0.1_licence-agreement.txt} | 2 +- .../s112_nrf52_7.0.1_migration-document.pdf | Bin 0 -> 22006 bytes .../doc/s112_nrf52_7.0.1_release-notes.pdf | Bin 0 -> 50441 bytes .../components/softdevice/s112}/headers/ble.h | 135 +- .../softdevice/s112}/headers/ble_err.h | 6 +- .../softdevice/s112}/headers/ble_gap.h | 1115 +- .../softdevice/s112}/headers/ble_gatt.h | 14 +- .../softdevice/s112}/headers/ble_gattc.h | 21 +- .../softdevice/s112}/headers/ble_gatts.h | 38 +- .../softdevice/s112}/headers/ble_hci.h | 0 .../softdevice/s112/headers/ble_ranges.h | 148 + .../softdevice/s112}/headers/ble_types.h | 0 .../softdevice/s112/headers/nrf52/nrf_mbr.h | 268 + .../softdevice/s112}/headers/nrf_error.h | 0 .../softdevice/s112}/headers/nrf_error_sdm.h | 0 .../softdevice/s112}/headers/nrf_error_soc.h | 0 .../softdevice/s112}/headers/nrf_nvic.h | 28 +- .../softdevice/s112}/headers/nrf_sd_def.h | 20 +- .../softdevice/s112}/headers/nrf_sdm.h | 46 +- .../softdevice/s112}/headers/nrf_soc.h | 201 +- .../softdevice/s112/headers/nrf_svc.h | 100 + .../s112_nrf52_7.0.1_licence-agreement.txt | 35 + .../armgcc/armgcc_s112_nrf52810_xxaa.ld | 34 + .../toolchain/iar/iar_s112_nrf52810_xxaa.icf | 37 + .../s132_nrf52_7.0.1_licence-agreement.txt | 35 + .../s132_nrf52_7.0.1_migration-document.pdf | Bin 0 -> 161059 bytes .../doc/s132_nrf52_7.0.1_release-notes.pdf | Bin 0 -> 85685 bytes .../components/softdevice/s132/headers/ble.h | 662 + .../softdevice/s132/headers/ble_err.h | 93 + .../softdevice/s132/headers/ble_gap.h | 2829 +++ .../softdevice/s132/headers/ble_gatt.h | 229 + .../softdevice/s132/headers/ble_gattc.h | 715 + .../softdevice/s132/headers/ble_gatts.h | 845 + .../softdevice/s132/headers/ble_hci.h | 135 + .../softdevice/s132/headers/ble_l2cap.h | 56 +- .../softdevice/s132/headers/ble_ranges.h | 14 +- .../softdevice/s132/headers/ble_types.h | 215 + .../softdevice/s132/headers/nrf52/nrf_mbr.h | 268 + .../softdevice/s132/headers/nrf_error.h | 90 + .../softdevice/s132/headers/nrf_error_sdm.h | 70 + .../softdevice/s132/headers/nrf_error_soc.h | 85 + .../softdevice/s132/headers/nrf_nvic.h | 491 + .../softdevice/s132/headers/nrf_sd_def.h} | 42 +- .../softdevice/s132/headers/nrf_sdm.h | 371 + .../softdevice/s132/headers/nrf_soc.h | 1000 ++ .../softdevice/s132/headers/nrf_svc.h | 100 + .../s132_nrf52_7.0.1_licence-agreement.txt | 35 + .../armgcc/armgcc_s132_nrf52832_xxaa.ld | 34 + .../toolchain/iar/iar_s132_nrf52832_xxaa.icf | 15 +- .../components/toolchain/arm/uicr_config.h | 20 +- .../toolchain/cmsis/dsp/license.txt | 0 .../cmsis/include/arm_common_tables.h | 0 .../cmsis/include/arm_const_structs.h | 0 .../toolchain/cmsis/include/arm_math.h | 0 .../toolchain/cmsis/include/cmsis_armcc.h | 0 .../toolchain/cmsis/include/cmsis_armcc_V6.h | 0 .../toolchain/cmsis/include/cmsis_gcc.h | 0 .../toolchain/cmsis/include/core_cm0.h | 0 .../toolchain/cmsis/include/core_cm0plus.h | 0 .../toolchain/cmsis/include/core_cm3.h | 0 .../toolchain/cmsis/include/core_cm4.h | 0 .../toolchain/cmsis/include/core_cm7.h | 0 .../toolchain/cmsis/include/core_cmFunc.h | 0 .../toolchain/cmsis/include/core_cmInstr.h | 0 .../toolchain/cmsis/include/core_cmSimd.h | 0 .../toolchain/cmsis/include/core_sc000.h | 0 .../toolchain/cmsis/include/core_sc300.h | 0 .../components/toolchain/gcc/Makefile.common | 0 .../components/toolchain/gcc/Makefile.posix | 3 + .../components/toolchain/gcc/Makefile.windows | 4 +- .../components/toolchain/gcc/dump.mk | 0 .../toolchain/gcc/gcc_nrf51_common.ld | 0 .../toolchain/iar/iar_nrf51_blank_xxaa.icf | 0 .../toolchain/iar/iar_nrf51_blank_xxac.icf | 0 .../nrf52810/armgcc/generic_gcc_nrf52.ld | 130 + .../config/nrf52810}/config/sdk_config.h | 12493 +++++++------ .../config/nrf52810/ses/flash_placement.xml | 53 + .../config/nrf52811/armgcc/Makefile | 234 + .../nrf52811/armgcc/generic_gcc_nrf52.ld | 130 + .../config/nrf52811/config/sdk_config.h | 10335 +++++++++++ .../config/nrf52811/ses/flash_placement.xml | 53 + .../ses/generic_nrf52811_xxaa.emProject | 90 + .../nrf52832/armgcc/generic_gcc_nrf52.ld | 136 + .../config/nrf52832/config/sdk_config.h | 12826 ++++++++++++++ .../config/nrf52832/ses/flash_placement.xml | 54 + .../config/nrf52833/armgcc/Makefile | 264 + .../nrf52833/armgcc/generic_gcc_nrf52.ld | 130 + .../config/nrf52833/config/sdk_config.h | 11576 ++++++++++++ .../config/nrf52833/ses/flash_placement.xml | 53 + .../ses/generic_nrf52833_xxaa.emProject | 94 + .../nrf52840/armgcc/generic_gcc_nrf52.ld | 130 + .../config/nrf52840/config/sdk_config.h | 11698 ++++++++++++ .../config/nrf52840/ses/flash_placement.xml | 53 + .../external/cifra_AES128-EAX/bitops.h | 290 + .../external/cifra_AES128-EAX/blockwise.c | 197 + .../external/cifra_AES128-EAX/blockwise.h | 147 + .../external/cifra_AES128-EAX/cf_config.h | 59 + .../external/cifra_AES128-EAX/cifra_cmac.c | 150 + .../external/cifra_AES128-EAX/cifra_eax_aes.c | 416 + .../external/cifra_AES128-EAX/cifra_eax_aes.h | 152 + .../external/cifra_AES128-EAX/eax.c | 115 + .../external/cifra_AES128-EAX/gf128.c | 113 + .../external/cifra_AES128-EAX/gf128.h | 55 + .../external/cifra_AES128-EAX/handy.h | 88 + .../external/cifra_AES128-EAX/license.txt | 121 + .../external/cifra_AES128-EAX/modes.c | 99 + .../external/cifra_AES128-EAX/modes.h | 560 + .../external/cifra_AES128-EAX/prp.h | 64 + .../external/cifra_AES128-EAX/tassert.h | 32 + .../external/fnmatch/fnmatch.c | 208 + .../external/fnmatch/fnmatch.h | 50 + .../external/fprintf/nrf_fprintf.c | 20 +- .../external/fprintf/nrf_fprintf.h | 20 +- .../external/fprintf/nrf_fprintf_format.c | 306 +- .../external/fprintf/nrf_fprintf_format.h | 0 .../external/freertos/config/FreeRTOSConfig.h | 89 +- .../external/freertos/license/license.txt | 38 + .../freertos/portable/ARM/nrf51/port.c | 128 + .../freertos/portable/ARM/nrf51/portmacro.h | 34 + .../freertos/portable/ARM/nrf52/port.c | 153 + .../freertos/portable/ARM/nrf52/portmacro.h | 34 + .../portable/CMSIS/nrf51/port_cmsis.c | 95 +- .../portable/CMSIS/nrf51/port_cmsis_systick.c | 95 +- .../portable/CMSIS/nrf51/portmacro_cmsis.h | 93 +- .../portable/CMSIS/nrf52/port_cmsis.c | 93 +- .../portable/CMSIS/nrf52/port_cmsis_systick.c | 94 +- .../portable/CMSIS/nrf52/portmacro_cmsis.h | 94 +- .../freertos/portable/GCC/nrf51/port.c | 95 +- .../freertos/portable/GCC/nrf51/portmacro.h | 36 + .../freertos/portable/GCC/nrf52/port.c | 93 +- .../freertos/portable/GCC/nrf52/portmacro.h | 36 + .../freertos/portable/IAR/nrf51/port.c | 95 +- .../freertos/portable/IAR/nrf51/portmacro.h | 40 + .../freertos/portable/IAR/nrf52/port.c | 93 +- .../freertos/portable/IAR/nrf52/portmacro.h | 41 + .../external/freertos/readme.txt | 0 .../external/freertos/source/croutine.c | 127 +- .../external/freertos/source/event_groups.c | 306 +- .../freertos/source/include/FreeRTOS.h | 642 +- .../freertos/source/include/StackMacros.h | 134 + .../freertos/source/include/croutine.h | 141 +- .../source/include/deprecated_definitions.h | 93 +- .../freertos/source/include/event_groups.h | 219 +- .../external/freertos/source/include/list.h | 127 +- .../freertos/source/include/message_buffer.h | 780 + .../freertos/source/include/mpu_prototypes.h | 156 + .../freertos/source/include/mpu_wrappers.h | 182 + .../freertos/source/include/portable.h | 109 +- .../freertos/source/include/projdefs.h | 125 + .../external/freertos/source/include/queue.h | 445 +- .../external/freertos/source/include/semphr.h | 1141 ++ .../freertos/source/include/stack_macros.h | 130 + .../freertos/source/include/stdint.readme | 0 .../freertos/source/include/stream_buffer.h | 849 + .../external/freertos/source/include/task.h | 636 +- .../external/freertos/source/include/timers.h | 338 +- .../external/freertos/source/list.c | 99 +- .../source/portable/Common/mpu_wrappers.c | 1291 ++ .../source/portable/MemMang/ReadMe.url | 5 + .../freertos/source/portable/MemMang/heap_1.c | 148 + .../freertos/source/portable/MemMang/heap_2.c | 130 +- .../freertos/source/portable/MemMang/heap_3.c | 98 + .../freertos/source/portable/MemMang/heap_4.c | 171 +- .../freertos/source/portable/MemMang/heap_5.c | 185 +- .../freertos/source/portable/readme.txt | 20 + .../external/freertos/source/queue.c | 1774 +- .../external/freertos/source/readme.txt | 14 +- .../external/freertos/source/stream_buffer.c | 1196 ++ .../external/freertos/source/tasks.c | 3413 ++-- .../external/freertos/source/timers.c | 484 +- .../external/licenses_external.txt | 0 .../external/mbedtls/.travis.yml | 39 + .../external/mbedtls/CMakeLists.txt | 166 + .../external/mbedtls/ChangeLog | 2152 +++ .../external/mbedtls/DartConfiguration.tcl | 4 + .../external/mbedtls/LICENSE | 2 + .../external/mbedtls/Makefile | 110 + .../external/mbedtls/README.md | 185 + .../external/mbedtls/apache-2.0.txt | 202 + .../external/mbedtls/circle.yml | 44 + .../external/mbedtls/configs/README.txt | 26 + .../mbedtls/configs/config-ccm-psk-tls1_2.h | 85 + .../mbedtls/configs/config-mini-tls1_1.h | 75 + .../mbedtls/configs/config-no-entropy.h | 85 + .../mbedtls/configs/config-picocoin.h | 71 + .../external/mbedtls/configs/config-suite-b.h | 114 + .../external/mbedtls/configs/config-thread.h | 91 + .../mbedtls/doxygen/input/doc_encdec.h | 69 + .../mbedtls/doxygen/input/doc_hashing.h | 41 + .../mbedtls/doxygen/input/doc_mainpage.h | 93 + .../external/mbedtls/doxygen/input/doc_rng.h | 43 + .../mbedtls/doxygen/input/doc_ssltls.h | 48 + .../mbedtls/doxygen/input/doc_tcpip.h | 43 + .../external/mbedtls/doxygen/input/doc_x509.h | 42 + .../external/mbedtls/doxygen/mbedtls.doxyfile | 1911 ++ .../external/mbedtls/include/CMakeLists.txt | 11 + .../external/mbedtls/include/mbedtls/aes.h | 297 + .../external/mbedtls/include/mbedtls/aesni.h | 111 + .../external/mbedtls/include/mbedtls/arc4.h | 113 + .../external/mbedtls/include/mbedtls/asn1.h | 342 + .../mbedtls/include/mbedtls/asn1write.h | 239 + .../external/mbedtls/include/mbedtls/base64.h | 88 + .../external/mbedtls/include/mbedtls/bignum.h | 717 + .../mbedtls/include/mbedtls/blowfish.h | 203 + .../external/mbedtls/include/mbedtls/bn_mul.h | 885 + .../mbedtls/include/mbedtls/camellia.h | 235 + .../external/mbedtls/include/mbedtls/ccm.h | 141 + .../external/mbedtls/include/mbedtls/certs.h | 99 + .../mbedtls/include/mbedtls/check_config.h | 628 + .../external/mbedtls/include/mbedtls/cipher.h | 709 + .../mbedtls/include/mbedtls/cipher_internal.h | 109 + .../external/mbedtls/include/mbedtls/cmac.h | 170 + .../mbedtls/include/mbedtls/compat-1.3.h | 2633 +++ .../external/mbedtls/include/mbedtls/config.h | 2600 +++ .../mbedtls/include/mbedtls/ctr_drbg.h | 290 + .../external/mbedtls/include/mbedtls/debug.h | 228 + .../external/mbedtls/include/mbedtls/des.h | 306 + .../external/mbedtls/include/mbedtls/dhm.h | 305 + .../external/mbedtls/include/mbedtls/ecdh.h | 214 + .../external/mbedtls/include/mbedtls/ecdsa.h | 248 + .../mbedtls/include/mbedtls/ecjpake.h | 238 + .../external/mbedtls/include/mbedtls/ecp.h | 669 + .../mbedtls/include/mbedtls/entropy.h | 287 + .../mbedtls/include/mbedtls/entropy_poll.h | 109 + .../external/mbedtls/include/mbedtls/error.h | 107 + .../external/mbedtls/include/mbedtls/gcm.h | 220 + .../external/mbedtls/include/mbedtls/havege.h | 74 + .../mbedtls/include/mbedtls/hmac_drbg.h | 299 + .../external/mbedtls/include/mbedtls/md.h | 354 + .../external/mbedtls/include/mbedtls/md2.h | 136 + .../external/mbedtls/include/mbedtls/md4.h | 136 + .../external/mbedtls/include/mbedtls/md5.h | 136 + .../mbedtls/include/mbedtls/md_internal.h | 114 + .../include/mbedtls/memory_buffer_alloc.h | 150 + .../external/mbedtls/include/mbedtls/net.h | 31 + .../mbedtls/include/mbedtls/net_sockets.h | 225 + .../external/mbedtls/include/mbedtls/oid.h | 570 + .../mbedtls/include/mbedtls/padlock.h | 107 + .../external/mbedtls/include/mbedtls/pem.h | 129 + .../external/mbedtls/include/mbedtls/pk.h | 616 + .../mbedtls/include/mbedtls/pk_internal.h | 114 + .../external/mbedtls/include/mbedtls/pkcs11.h | 173 + .../external/mbedtls/include/mbedtls/pkcs12.h | 119 + .../external/mbedtls/include/mbedtls/pkcs5.h | 94 + .../mbedtls/include/mbedtls/platform.h | 295 + .../mbedtls/include/mbedtls/platform_time.h | 81 + .../mbedtls/include/mbedtls/ripemd160.h | 138 + .../external/mbedtls/include/mbedtls/rsa.h | 652 + .../external/mbedtls/include/mbedtls/sha1.h | 136 + .../external/mbedtls/include/mbedtls/sha256.h | 141 + .../external/mbedtls/include/mbedtls/sha512.h | 141 + .../external/mbedtls/include/mbedtls/ssl.h | 2559 +++ .../mbedtls/include/mbedtls/ssl_cache.h | 143 + .../include/mbedtls/ssl_ciphersuites.h | 321 + .../mbedtls/include/mbedtls/ssl_cookie.h | 108 + .../mbedtls/include/mbedtls/ssl_internal.h | 500 + .../mbedtls/include/mbedtls/ssl_ticket.h | 135 + .../mbedtls/include/mbedtls/threading.h | 106 + .../external/mbedtls/include/mbedtls/timing.h | 141 + .../mbedtls/include/mbedtls/version.h | 111 + .../external/mbedtls/include/mbedtls/x509.h | 331 + .../mbedtls/include/mbedtls/x509_crl.h | 173 + .../mbedtls/include/mbedtls/x509_crt.h | 654 + .../mbedtls/include/mbedtls/x509_csr.h | 298 + .../external/mbedtls/include/mbedtls/xtea.h | 139 + .../external/mbedtls/library/CMakeLists.txt | 162 + .../external/mbedtls/library/Makefile | 169 + .../external/mbedtls/library/aes.c | 1492 ++ .../external/mbedtls/library/aesni.c | 464 + .../external/mbedtls/library/arc4.c | 205 + .../external/mbedtls/library/asn1parse.c | 393 + .../external/mbedtls/library/asn1write.c | 390 + .../external/mbedtls/library/base64.c | 293 + .../external/mbedtls/library/bignum.c | 2447 +++ .../external/mbedtls/library/blowfish.c | 656 + .../external/mbedtls/library/camellia.c | 1072 ++ .../external/mbedtls/library/ccm.c | 464 + .../external/mbedtls/library/certs.c | 351 + .../external/mbedtls/library/cipher.c | 917 + .../external/mbedtls/library/cipher_wrap.c | 1451 ++ .../external/mbedtls/library/cmac.c | 1074 ++ .../external/mbedtls/library/ctr_drbg.c | 594 + .../external/mbedtls/library/debug.c | 368 + .../external/mbedtls/library/des.c | 1061 ++ .../external/mbedtls/library/dhm.c | 627 + .../external/mbedtls/library/ecdh.c | 264 + .../external/mbedtls/library/ecdsa.c | 448 + .../external/mbedtls/library/ecjpake.c | 1103 ++ .../external/mbedtls/library/ecp.c | 2092 +++ .../external/mbedtls/library/ecp_curves.c | 1325 ++ .../external/mbedtls/library/entropy.c | 655 + .../external/mbedtls/library/entropy_poll.c | 268 + .../external/mbedtls/library/error.c | 707 + .../external/mbedtls/library/gcm.c | 952 + .../external/mbedtls/library/havege.c | 245 + .../external/mbedtls/library/hmac_drbg.c | 529 + .../external/mbedtls/library/md.c | 471 + .../external/mbedtls/library/md2.c | 288 + .../external/mbedtls/library/md4.c | 384 + .../external/mbedtls/library/md5.c | 404 + .../external/mbedtls/library/md_wrap.c | 575 + .../mbedtls/library/memory_buffer_alloc.c | 745 + .../external/mbedtls/library/net_sockets.c | 586 + .../external/mbedtls/library/oid.c | 710 + .../external/mbedtls/library/padlock.c | 170 + .../external/mbedtls/library/pem.c | 449 + .../external/mbedtls/library/pk.c | 383 + .../external/mbedtls/library/pk_wrap.c | 513 + .../external/mbedtls/library/pkcs11.c | 240 + .../external/mbedtls/library/pkcs12.c | 365 + .../external/mbedtls/library/pkcs5.c | 406 + .../external/mbedtls/library/pkparse.c | 1293 ++ .../external/mbedtls/library/pkwrite.c | 439 + .../external/mbedtls/library/platform.c | 307 + .../external/mbedtls/library/ripemd160.c | 467 + .../external/mbedtls/library/rsa.c | 1730 ++ .../external/mbedtls/library/sha1.c | 448 + .../external/mbedtls/library/sha256.c | 458 + .../external/mbedtls/library/sha512.c | 514 + .../external/mbedtls/library/ssl_cache.c | 326 + .../mbedtls/library/ssl_ciphersuites.c | 1857 ++ .../external/mbedtls/library/ssl_cli.c | 3405 ++++ .../external/mbedtls/library/ssl_cookie.c | 260 + .../external/mbedtls/library/ssl_srv.c | 3926 ++++ .../external/mbedtls/library/ssl_ticket.c | 489 + .../external/mbedtls/library/ssl_tls.c | 7687 ++++++++ .../external/mbedtls/library/threading.c | 137 + .../external/mbedtls/library/timing.c | 525 + .../external/mbedtls/library/version.c | 50 + .../mbedtls/library/version_features.c | 647 + .../external/mbedtls/library/x509.c | 1098 ++ .../external/mbedtls/library/x509_create.c | 340 + .../external/mbedtls/library/x509_crl.c | 723 + .../external/mbedtls/library/x509_crt.c | 2403 +++ .../external/mbedtls/library/x509_csr.c | 423 + .../external/mbedtls/library/x509write_crt.c | 459 + .../external/mbedtls/library/x509write_csr.c | 259 + .../external/mbedtls/library/xtea.c | 281 + .../external/mbedtls/programs/CMakeLists.txt | 8 + .../external/mbedtls/programs/Makefile | 288 + .../mbedtls/programs/aes/CMakeLists.txt | 9 + .../external/mbedtls/programs/aes/aescrypt2.c | 452 + .../mbedtls/programs/aes/crypt_and_hash.c | 551 + .../mbedtls/programs/hash/CMakeLists.txt | 9 + .../mbedtls/programs/hash/generic_sum.c | 232 + .../external/mbedtls/programs/hash/hello.c | 68 + .../mbedtls/programs/pkey/CMakeLists.txt | 63 + .../mbedtls/programs/pkey/dh_client.c | 304 + .../mbedtls/programs/pkey/dh_genprime.c | 197 + .../mbedtls/programs/pkey/dh_prime.txt | 2 + .../mbedtls/programs/pkey/dh_server.c | 308 + .../mbedtls/programs/pkey/ecdh_curve25519.c | 237 + .../external/mbedtls/programs/pkey/ecdsa.c | 231 + .../external/mbedtls/programs/pkey/gen_key.c | 425 + .../external/mbedtls/programs/pkey/key_app.c | 281 + .../mbedtls/programs/pkey/key_app_writer.c | 406 + .../external/mbedtls/programs/pkey/mpi_demo.c | 109 + .../mbedtls/programs/pkey/pk_decrypt.c | 168 + .../mbedtls/programs/pkey/pk_encrypt.c | 168 + .../external/mbedtls/programs/pkey/pk_sign.c | 175 + .../mbedtls/programs/pkey/pk_verify.c | 149 + .../mbedtls/programs/pkey/rsa_decrypt.c | 196 + .../mbedtls/programs/pkey/rsa_encrypt.c | 186 + .../mbedtls/programs/pkey/rsa_genkey.c | 172 + .../mbedtls/programs/pkey/rsa_priv.txt | 8 + .../mbedtls/programs/pkey/rsa_pub.txt | 2 + .../external/mbedtls/programs/pkey/rsa_sign.c | 170 + .../mbedtls/programs/pkey/rsa_sign_pss.c | 178 + .../mbedtls/programs/pkey/rsa_verify.c | 163 + .../mbedtls/programs/pkey/rsa_verify_pss.c | 155 + .../mbedtls/programs/random/CMakeLists.txt | 12 + .../mbedtls/programs/random/gen_entropy.c | 96 + .../programs/random/gen_random_ctr_drbg.c | 130 + .../programs/random/gen_random_havege.c | 101 + .../mbedtls/programs/ssl/CMakeLists.txt | 62 + .../mbedtls/programs/ssl/dtls_client.c | 350 + .../mbedtls/programs/ssl/dtls_server.c | 425 + .../mbedtls/programs/ssl/mini_client.c | 302 + .../mbedtls/programs/ssl/ssl_client1.c | 313 + .../mbedtls/programs/ssl/ssl_client2.c | 1673 ++ .../mbedtls/programs/ssl/ssl_fork_server.c | 416 + .../mbedtls/programs/ssl/ssl_mail_client.c | 842 + .../mbedtls/programs/ssl/ssl_pthread_server.c | 529 + .../mbedtls/programs/ssl/ssl_server.c | 401 + .../mbedtls/programs/ssl/ssl_server2.c | 2361 +++ .../mbedtls/programs/util/CMakeLists.txt | 13 + .../external/mbedtls/programs/util/pem2der.c | 286 + .../external/mbedtls/programs/util/strerror.c | 92 + .../external/mbedtls/programs/wince_main.c | 45 + .../mbedtls/programs/x509/CMakeLists.txt | 30 + .../external/mbedtls/programs/x509/cert_app.c | 495 + .../external/mbedtls/programs/x509/cert_req.c | 345 + .../mbedtls/programs/x509/cert_write.c | 668 + .../external/mbedtls/programs/x509/crl_app.c | 145 + .../external/mbedtls/programs/x509/req_app.c | 145 + .../external/mbedtls/scripts/apidoc_full.sh | 25 + .../external/mbedtls/scripts/bump_version.sh | 140 + .../external/mbedtls/scripts/config.pl | 252 + .../mbedtls/scripts/data_files/error.fmt | 123 + .../scripts/data_files/rename-1.3-2.0.txt | 2174 +++ .../scripts/data_files/version_features.fmt | 60 + .../data_files/vs2010-app-template.vcxproj | 173 + .../data_files/vs2010-main-template.vcxproj | 157 + .../data_files/vs2010-sln-template.sln | 28 + .../scripts/data_files/vs6-app-template.dsp | 101 + .../scripts/data_files/vs6-main-template.dsp | 94 + .../data_files/vs6-workspace-template.dsw | 18 + .../external/mbedtls/scripts/ecc-heap.sh | 74 + .../mbedtls/scripts/find-mem-leak.cocci | 20 + .../external/mbedtls/scripts/footprint.sh | 114 + .../mbedtls/scripts/generate_errors.pl | 198 + .../mbedtls/scripts/generate_features.pl | 74 + .../mbedtls/scripts/generate_visualc_files.pl | 195 + .../external/mbedtls/scripts/malloc-init.pl | 70 + .../external/mbedtls/scripts/massif_max.pl | 33 + .../external/mbedtls/scripts/memory.sh | 126 + .../external/mbedtls/scripts/output_env.sh | 114 + .../external/mbedtls/scripts/rename.pl | 122 + .../mbedtls/scripts/rm-malloc-cast.cocci | 7 + .../mbedtls/scripts/tmp_ignore_makefiles.sh | 44 + .../mbedtls/visualc/VS2010/aescrypt2.vcxproj | 173 + .../mbedtls/visualc/VS2010/benchmark.vcxproj | 173 + .../mbedtls/visualc/VS2010/cert_app.vcxproj | 173 + .../mbedtls/visualc/VS2010/cert_req.vcxproj | 173 + .../mbedtls/visualc/VS2010/cert_write.vcxproj | 173 + .../mbedtls/visualc/VS2010/crl_app.vcxproj | 173 + .../visualc/VS2010/crypt_and_hash.vcxproj | 173 + .../mbedtls/visualc/VS2010/dh_client.vcxproj | 173 + .../visualc/VS2010/dh_genprime.vcxproj | 173 + .../mbedtls/visualc/VS2010/dh_server.vcxproj | 173 + .../visualc/VS2010/dtls_client.vcxproj | 173 + .../visualc/VS2010/dtls_server.vcxproj | 173 + .../visualc/VS2010/ecdh_curve25519.vcxproj | 173 + .../mbedtls/visualc/VS2010/ecdsa.vcxproj | 173 + .../visualc/VS2010/gen_entropy.vcxproj | 173 + .../mbedtls/visualc/VS2010/gen_key.vcxproj | 173 + .../VS2010/gen_random_ctr_drbg.vcxproj | 173 + .../visualc/VS2010/gen_random_havege.vcxproj | 173 + .../visualc/VS2010/generic_sum.vcxproj | 173 + .../mbedtls/visualc/VS2010/hello.vcxproj | 173 + .../mbedtls/visualc/VS2010/key_app.vcxproj | 173 + .../visualc/VS2010/key_app_writer.vcxproj | 173 + .../mbedtls/visualc/VS2010/mbedTLS.sln | 637 + .../mbedtls/visualc/VS2010/mbedTLS.vcxproj | 295 + .../mbedtls/visualc/VS2010/md5sum.vcxproj | 169 + .../visualc/VS2010/mini_client.vcxproj | 173 + .../mbedtls/visualc/VS2010/mpi_demo.vcxproj | 173 + .../mbedtls/visualc/VS2010/pem2der.vcxproj | 173 + .../mbedtls/visualc/VS2010/pk_decrypt.vcxproj | 173 + .../mbedtls/visualc/VS2010/pk_encrypt.vcxproj | 173 + .../mbedtls/visualc/VS2010/pk_sign.vcxproj | 173 + .../mbedtls/visualc/VS2010/pk_verify.vcxproj | 173 + .../mbedtls/visualc/VS2010/req_app.vcxproj | 173 + .../visualc/VS2010/rsa_decrypt.vcxproj | 173 + .../visualc/VS2010/rsa_encrypt.vcxproj | 173 + .../mbedtls/visualc/VS2010/rsa_genkey.vcxproj | 173 + .../mbedtls/visualc/VS2010/rsa_sign.vcxproj | 173 + .../visualc/VS2010/rsa_sign_pss.vcxproj | 173 + .../mbedtls/visualc/VS2010/rsa_verify.vcxproj | 173 + .../visualc/VS2010/rsa_verify_pss.vcxproj | 173 + .../mbedtls/visualc/VS2010/selftest.vcxproj | 173 + .../mbedtls/visualc/VS2010/sha1sum.vcxproj | 169 + .../mbedtls/visualc/VS2010/sha2sum.vcxproj | 169 + .../visualc/VS2010/ssl_cert_test.vcxproj | 173 + .../visualc/VS2010/ssl_client1.vcxproj | 173 + .../visualc/VS2010/ssl_client2.vcxproj | 173 + .../visualc/VS2010/ssl_fork_server.vcxproj | 173 + .../visualc/VS2010/ssl_mail_client.vcxproj | 173 + .../mbedtls/visualc/VS2010/ssl_server.vcxproj | 173 + .../visualc/VS2010/ssl_server2.vcxproj | 173 + .../mbedtls/visualc/VS2010/strerror.vcxproj | 173 + .../mbedtls/visualc/VS2010/udp_proxy.vcxproj | 173 + .../external/mbedtls/yotta/create-module.sh | 47 + .../external/mbedtls/yotta/data/README.md | 103 + .../mbedtls/yotta/data/adjust-config.sh | 77 + .../yotta/data/entropy_hardware_poll.c | 88 + .../yotta/data/example-authcrypt/README.md | 68 + .../yotta/data/example-authcrypt/main.cpp | 197 + .../yotta/data/example-benchmark/README.md | 100 + .../yotta/data/example-benchmark/main.cpp | 951 + .../yotta/data/example-hashing/README.md | 67 + .../yotta/data/example-hashing/main.cpp | 177 + .../yotta/data/example-selftest/README.md | 82 + .../yotta/data/example-selftest/main.cpp | 268 + .../mbedtls/yotta/data/target_config.h | 35 + .../external/micro-ecc/build_all.bat | 24 + .../external/micro-ecc/build_all.sh | 9 +- .../external/micro-ecc/license.txt | 0 .../external/micro-ecc/micro-ecc/.gitignore | 0 .../external/micro-ecc/micro-ecc/LICENSE.txt | 0 .../external/micro-ecc/micro-ecc/README.md | 0 .../external/micro-ecc/micro-ecc/asm_arm.inc | 0 .../micro-ecc/asm_arm_mult_square.inc | 0 .../micro-ecc/asm_arm_mult_square_umaal.inc | 0 .../external/micro-ecc/micro-ecc/asm_avr.inc | 0 .../micro-ecc/asm_avr_mult_square.inc | 0 .../micro-ecc/micro-ecc/curve-specific.inc | 0 .../micro-ecc/micro-ecc/emk_project.py | 0 .../external/micro-ecc/micro-ecc/emk_rules.py | 0 .../micro-ecc/examples/ecc_test/ecc_test.ino | 0 .../micro-ecc/micro-ecc/library.properties | 0 .../micro-ecc/micro-ecc/platform-specific.inc | 0 .../micro-ecc/micro-ecc/scripts/mult_arm.py | 0 .../micro-ecc/micro-ecc/scripts/mult_avr.py | 0 .../micro-ecc/scripts/mult_avr_extra.py | 0 .../micro-ecc/micro-ecc/scripts/square_arm.py | 0 .../micro-ecc/micro-ecc/scripts/square_avr.py | 0 .../micro-ecc/micro-ecc/test/emk_rules.py | 0 .../micro-ecc/micro-ecc/test/test_compress.c | 0 .../micro-ecc/micro-ecc/test/test_compute.c | 0 .../micro-ecc/micro-ecc/test/test_ecdh.c | 0 .../micro-ecc/micro-ecc/test/test_ecdsa.c | 0 .../test/test_ecdsa_deterministic.c.example | 0 .../external/micro-ecc/micro-ecc/types.h | 0 .../external/micro-ecc/micro-ecc/uECC.c | 0 .../external/micro-ecc/micro-ecc/uECC.h | 0 .../external/micro-ecc/micro-ecc/uECC_vli.h | 0 .../micro-ecc/nrf51_armgcc/armgcc/Makefile | 25 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 5 +- .../micro-ecc/nrf51_iar/armgcc/Makefile | 25 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 5 +- .../micro-ecc/nrf51_keil/armgcc/Makefile | 21 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 5 +- .../micro-ecc/nrf52hf_armgcc/armgcc/Makefile | 25 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 5 +- .../micro-ecc/nrf52hf_iar/armgcc/Makefile | 25 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 34 + .../micro-ecc/nrf52hf_keil/armgcc/Makefile | 21 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 34 + .../micro-ecc/nrf52nf_armgcc/armgcc/Makefile | 25 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 34 + .../micro-ecc/nrf52nf_iar/armgcc/Makefile | 25 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 34 + .../micro-ecc/nrf52nf_keil/armgcc/Makefile | 21 +- .../armgcc/ext_micro_ecc_gcc_nRF5x.ld | 34 + .../external/nano-pb/LICENSE.txt | 0 .../nano-pb/generator/camel_case_splitter.py | 0 .../nano-pb/generator/nanopb_generator.py | 0 .../external/nano-pb/generator/proto/Makefile | 0 .../nano-pb/generator/proto/__init__.py | 0 .../proto/google/protobuf/descriptor.proto | 0 .../nano-pb/generator/proto/nanopb.proto | 0 .../nano-pb/generator/proto/nanopb_pb2.py | 0 .../nano-pb/generator/proto/plugin.proto | 0 .../nano-pb/generator/proto/plugin_pb2.py | 0 .../nano-pb/generator/protoc-gen-nanopb | 0 .../nano-pb/generator/protoc-gen-nanopb.bat | 0 .../external/nano-pb/pb.h | 2 +- .../external/nano-pb/pb_common.c | 0 .../external/nano-pb/pb_common.h | 0 .../external/nano-pb/pb_decode.c | 0 .../external/nano-pb/pb_decode.h | 0 .../external/nano-pb/pb_encode.c | 0 .../external/nano-pb/pb_encode.h | 0 .../external/nano/mock_pb_decode.c | 2393 +++ .../external/nano/mock_pb_decode.h | 311 + .../nfc_adafruit_library/adafruit_pn532.c | 0 .../nfc_adafruit_library/adafruit_pn532.h | 0 .../external/nrf_cc310/Doxyfile | 11 + .../external/nrf_cc310/Doxyfile.internal | 25 + .../common/integration_test_plat_defs.h | 73 + .../common/integration_test_plat_utils.c | 120 + .../common/integration_test_ssi_data.h | 126 +- .../common/integration_test_ssi_defs.h | 78 + .../include/ccsw_crys_rsa_shared_types.h | 144 + .../external/nrf_cc310/include/crys_aesccm.h | 315 + .../nrf_cc310/include/crys_aesccm_error.h | 134 + .../external/nrf_cc310/include/crys_chacha.h | 103 +- .../nrf_cc310/include/crys_chacha_error.h | 103 + .../nrf_cc310/include/crys_chacha_poly.h | 95 + .../include/crys_chacha_poly_error.h | 95 + .../external/nrf_cc310/include/crys_common.h | 154 +- .../nrf_cc310/include/crys_common_error.h | 95 + .../external/nrf_cc310/include/crys_dh.h | 326 +- .../nrf_cc310/include/crys_dh_error.h | 158 + .../external/nrf_cc310/include/crys_dh_kg.h | 203 + .../nrf_cc310/include/crys_ec_edw_api.h | 201 + .../nrf_cc310/include/crys_ec_mont_api.h | 105 +- .../include/crys_ec_mont_edw_error.h | 114 + .../nrf_cc310/include/crys_ecpki_build.h | 224 + .../nrf_cc310/include/crys_ecpki_dh.h | 90 + .../nrf_cc310/include/crys_ecpki_domain.h | 80 + .../nrf_cc310/include/crys_ecpki_ecdsa.h | 139 + .../nrf_cc310/include/crys_ecpki_error.h | 317 + .../nrf_cc310/include/crys_ecpki_kg.h | 88 + .../nrf_cc310/include/crys_ecpki_types.h | 478 + .../external/nrf_cc310/include/crys_error.h | 153 +- .../external/nrf_cc310/include/crys_hash.h | 149 +- .../nrf_cc310/include/crys_hash_defs.h | 66 + .../nrf_cc310/include/crys_hash_error.h | 108 + .../external/nrf_cc310/include/crys_hkdf.h | 124 + .../nrf_cc310/include/crys_hkdf_error.h | 91 + .../external/nrf_cc310/include/crys_hmac.h | 106 +- .../nrf_cc310/include/crys_hmac_defs.h | 64 + .../nrf_cc310/include/crys_hmac_error.h | 108 + .../external/nrf_cc310/include/crys_kdf.h | 211 + .../nrf_cc310/include/crys_kdf_error.h | 105 + .../nrf_cc310/include/crys_pka_defs_hw.h | 128 + .../external/nrf_cc310/include/crys_poly.h | 107 + .../nrf_cc310/include/crys_poly_error.h | 89 + .../external/nrf_cc310/include/crys_rnd.h | 398 + .../nrf_cc310/include/crys_rnd_error.h | 160 + .../nrf_cc310/include/crys_rsa_build.h | 71 +- .../nrf_cc310/include/crys_rsa_error.h | 165 +- .../external/nrf_cc310/include/crys_rsa_kg.h | 129 + .../nrf_cc310/include/crys_rsa_prim.h | 125 + .../nrf_cc310/include/crys_rsa_schemes.h | 231 +- .../nrf_cc310/include/crys_rsa_types.h | 258 +- .../external/nrf_cc310/include/crys_srp.h | 375 + .../nrf_cc310/include/crys_srp_error.h | 91 + .../nrf_cc310/include/dx_reg_base_host.h | 60 + .../external/nrf_cc310/include/sns_silib.h | 101 + .../external/nrf_cc310/include/ssi_aes.h | 325 + .../external/nrf_cc310/include/ssi_aes_defs.h | 83 + .../nrf_cc310/include/ssi_aes_error.h | 133 + .../external/nrf_cc310/include/ssi_bitops.h | 81 + .../nrf_cc310/include/ssi_pal_abort.h | 80 + .../nrf_cc310/include/ssi_pal_barrier.h | 71 + .../nrf_cc310/include/ssi_pal_compiler.h | 62 +- .../external/nrf_cc310/include/ssi_pal_dma.h | 175 + .../nrf_cc310/include/ssi_pal_dma_defs.h | 77 + .../nrf_cc310/include/ssi_pal_dma_plat.h | 72 + .../nrf_cc310/include/ssi_pal_error.h | 84 + .../external/nrf_cc310/include/ssi_pal_file.h | 225 + .../nrf_cc310/include/ssi_pal_file_plat.h | 128 + .../external/nrf_cc310/include/ssi_pal_fips.h | 119 + .../external/nrf_cc310/include/ssi_pal_init.h | 85 + .../external/nrf_cc310/include/ssi_pal_list.h | 118 + .../external/nrf_cc310/include/ssi_pal_log.h | 216 + .../external/nrf_cc310/include/ssi_pal_mem.h | 162 + .../nrf_cc310/include/ssi_pal_memmap.h | 95 + .../nrf_cc310/include/ssi_pal_mutex.h | 117 + .../nrf_cc310/include/ssi_pal_mutex_plat.h | 71 + .../external/nrf_cc310/include/ssi_pal_perf.h | 143 + .../nrf_cc310/include/ssi_pal_perf_plat.h | 55 + .../external/nrf_cc310/include/ssi_pal_sem.h | 123 + .../nrf_cc310/include/ssi_pal_sem_plat.h | 120 + .../external/nrf_cc310/include/ssi_pal_trng.h | 66 + .../nrf_cc310/include/ssi_pal_types.h | 115 + .../nrf_cc310/include/ssi_pal_types_plat.h | 57 + .../nrf_cc310/include/ssi_pka_hw_plat_defs.h | 77 + .../external/nrf_cc310/include/ssi_regs.h | 166 + .../external/nrf_cc310/include/ssi_sram_map.h | 71 + .../nrf_cc310/include/ssi_util_defs.h | 93 + .../nrf_cc310/include/ssi_util_error.h | 97 + .../include/ssi_util_key_derivation.h | 107 + .../include/ssi_util_key_derivation_defs.h | 81 + .../external/nrf_cc310/lib/license.txt | 28 + .../external/nrf_cc310/license.txt | 28 + .../nrf_cc310_bl/include/crys_aesccm.h | 315 + .../nrf_cc310_bl/include/crys_ecpki_error.h | 317 + .../nrf_cc310_bl/include/crys_error.h | 273 + .../nrf_cc310_bl/include/crys_hash_error.h | 108 + .../external/nrf_cc310_bl/include/crys_rnd.h | 398 + .../nrf_cc310_bl/include/crys_rnd_error.h | 160 + .../nrf_cc310_bl/include/nrf_cc310_bl.h | 52 + .../nrf_cc310_bl_ecdsa_verify_common.h | 61 + .../nrf_cc310_bl_ecdsa_verify_secp224r1.h | 167 + .../nrf_cc310_bl_ecdsa_verify_secp256r1.h | 161 + .../include/nrf_cc310_bl_hash_common.h | 60 + .../include/nrf_cc310_bl_hash_sha256.h | 120 + .../nrf_cc310_bl/include/nrf_cc310_bl_init.h | 62 + .../external/nrf_cc310_bl/include/sns_silib.h | 101 + .../external/nrf_cc310_bl/include/ssi_aes.h | 325 + .../nrf_cc310_bl/include/ssi_aes_defs.h | 83 + .../nrf_cc310_bl/include/ssi_aes_error.h | 133 + .../nrf_cc310_bl/include/ssi_pal_types.h | 115 + .../nrf_cc310_bl/include/ssi_pal_types_plat.h | 57 + .../external/nrf_cc310_bl/lib/license.txt | 28 + .../external/nrf_cc310_bl/license.txt | 28 + .../nrf_oberon/include/ocrypto_aes_ctr.h | 148 + .../nrf_oberon/include/ocrypto_aes_eax.h | 115 + .../nrf_oberon/include/ocrypto_aes_gcm.h | 114 + .../nrf_oberon/include/ocrypto_aes_key.h} | 50 +- .../nrf_oberon/include/ocrypto_chacha20.h | 146 + .../include/ocrypto_chacha20_poly1305.h | 226 + .../include/ocrypto_chacha20_poly1305_inc.h | 245 + .../include/ocrypto_constant_time.h} | 118 +- .../nrf_oberon/include/ocrypto_curve25519.h | 118 + .../nrf_oberon/include/ocrypto_curve_p256.h | 137 + .../nrf_oberon/include/ocrypto_ecdh_p256.h | 86 + .../nrf_oberon/include/ocrypto_ecdsa_p256.h | 142 + .../nrf_oberon/include/ocrypto_ed25519.h | 128 + .../nrf_oberon/include/ocrypto_hkdf_sha256.h} | 106 +- .../nrf_oberon/include/ocrypto_hkdf_sha512.h | 102 + .../nrf_oberon/include/ocrypto_hmac_sha256.h | 176 + .../nrf_oberon/include/ocrypto_hmac_sha512.h | 171 + .../external/nrf_oberon/include/ocrypto_rsa.h | 643 + .../nrf_oberon/include/ocrypto_rsa_key.h | 279 + .../nrf_oberon/include/ocrypto_sha256.h | 155 + .../nrf_oberon/include/ocrypto_sha512.h | 155 + .../external/nrf_oberon/include/ocrypto_srp.h | 311 + .../nrf_oberon/include/ocrypto_srtp.h | 205 + .../external/nrf_oberon/lib/license.txt | 37 + .../external/nrf_oberon/license.txt | 37 + .../mbedtls/dtls/config/nrf_dtls_config.h | 2477 +++ .../config/nrf_crypto_mbedtls_config.h | 2514 +++ .../nrf_tls/mbedtls/replacements/asn1write.c | 392 + .../nrf_tls/mbedtls/replacements/ssl_srv.c | 3926 ++++ .../mbedtls/tls/config/nrf_tls_config.h | 2502 +++ .../external/nrf_tls/mbedtls/tls_interface.c | 1111 ++ .../external/nrf_tls/nrf_tls.h | 307 + .../external/protothreads/nrf_pt.h} | 31 +- .../external/protothreads/pt-1.4/Makefile | 9 + .../external/protothreads/pt-1.4/README | 51 + .../protothreads/pt-1.4/README-VISUAL-C++.txt | 5 + .../external/protothreads/pt-1.4/doc/Doxyfile | 229 + .../external/protothreads/pt-1.4/doc/Makefile | 7 + .../protothreads/pt-1.4/doc/header.tex | 52 + .../protothreads/pt-1.4/doc/html/a00005.html | 40 + .../protothreads/pt-1.4/doc/html/a00006.html | 40 + .../protothreads/pt-1.4/doc/html/a00009.html | 61 + .../protothreads/pt-1.4/doc/html/a00010.html | 56 + .../protothreads/pt-1.4/doc/html/a00011.html | 51 + .../protothreads/pt-1.4/doc/html/a00012.html | 51 + .../protothreads/pt-1.4/doc/html/a00013.html | 100 + .../protothreads/pt-1.4/doc/html/a00014.html | 627 + .../protothreads/pt-1.4/doc/html/a00015.html | 711 + .../protothreads/pt-1.4/doc/html/a00016.html | 246 + .../protothreads/pt-1.4/doc/html/a00017.html | 226 + .../protothreads/pt-1.4/doc/html/a00018.html | 109 + .../protothreads/pt-1.4/doc/html/a00019.html | 100 + .../protothreads/pt-1.4/doc/html/a00020.html | 156 + .../protothreads/pt-1.4/doc/html/a00021.html | 252 + .../protothreads/pt-1.4/doc/html/a00022.html | 347 + .../pt-1.4/doc/html/annotated.html | 29 + .../protothreads/pt-1.4/doc/html/doxygen.css | 310 + .../protothreads/pt-1.4/doc/html/doxygen.png | Bin 0 -> 1281 bytes .../protothreads/pt-1.4/doc/html/files.html | 31 + .../pt-1.4/doc/html/ftv2blank.png | Bin 0 -> 174 bytes .../protothreads/pt-1.4/doc/html/ftv2doc.png | Bin 0 -> 255 bytes .../pt-1.4/doc/html/ftv2folderclosed.png | Bin 0 -> 259 bytes .../pt-1.4/doc/html/ftv2folderopen.png | Bin 0 -> 261 bytes .../pt-1.4/doc/html/ftv2lastnode.png | Bin 0 -> 233 bytes .../protothreads/pt-1.4/doc/html/ftv2link.png | Bin 0 -> 358 bytes .../pt-1.4/doc/html/ftv2mlastnode.png | Bin 0 -> 160 bytes .../pt-1.4/doc/html/ftv2mnode.png | Bin 0 -> 194 bytes .../protothreads/pt-1.4/doc/html/ftv2node.png | Bin 0 -> 235 bytes .../pt-1.4/doc/html/ftv2plastnode.png | Bin 0 -> 165 bytes .../pt-1.4/doc/html/ftv2pnode.png | Bin 0 -> 200 bytes .../pt-1.4/doc/html/ftv2vertline.png | Bin 0 -> 229 bytes .../pt-1.4/doc/html/functions.html | 37 + .../pt-1.4/doc/html/functions_vars.html | 37 + .../protothreads/pt-1.4/doc/html/globals.html | 62 + .../pt-1.4/doc/html/globals_defs.html | 61 + .../pt-1.4/doc/html/globals_type.html | 36 + .../pt-1.4/doc/html/hierarchy.html | 29 + .../protothreads/pt-1.4/doc/html/index.hhc | 43 + .../protothreads/pt-1.4/doc/html/index.hhk | 56 + .../protothreads/pt-1.4/doc/html/index.hhp | 44 + .../protothreads/pt-1.4/doc/html/index.html | 8 + .../protothreads/pt-1.4/doc/html/main.html | 81 + .../protothreads/pt-1.4/doc/html/modules.html | 27 + .../protothreads/pt-1.4/doc/html/tab_b.gif | Bin 0 -> 35 bytes .../protothreads/pt-1.4/doc/html/tab_l.gif | Bin 0 -> 706 bytes .../protothreads/pt-1.4/doc/html/tab_r.gif | Bin 0 -> 2585 bytes .../protothreads/pt-1.4/doc/html/tabs.css | 102 + .../protothreads/pt-1.4/doc/html/tree.html | 108 + .../protothreads/pt-1.4/doc/pt-doc.txt | 58 + .../protothreads/pt-1.4/doc/pt-mainpage.txt | 156 + .../protothreads/pt-1.4/doc/pt-refman.pdf | Bin 0 -> 226750 bytes .../protothreads/pt-1.4/doc/sicslogo.pdf | Bin 0 -> 4547 bytes .../protothreads/pt-1.4/example-buffer.c | 165 + .../protothreads/pt-1.4/example-codelock.c | 414 + .../protothreads/pt-1.4/example-small.c | 97 + .../protothreads/pt-1.4/lc-addrlabels.h | 85 + .../external/protothreads/pt-1.4/lc-switch.h | 76 + .../external/protothreads/pt-1.4/lc.h | 132 + .../external/protothreads/pt-1.4/pt-sem.h | 228 + .../external/protothreads/pt-1.4/pt.h | 323 + .../external/segger_rtt/SEGGER_RTT.c | 0 .../external/segger_rtt/SEGGER_RTT.h | 0 .../external/segger_rtt/SEGGER_RTT_Conf.h | 0 .../segger_rtt/SEGGER_RTT_Syscalls_GCC.c | 0 .../segger_rtt/SEGGER_RTT_Syscalls_IAR.c | 0 .../segger_rtt/SEGGER_RTT_Syscalls_KEIL.c | 0 .../segger_rtt/SEGGER_RTT_Syscalls_SES.c | 0 .../external/segger_rtt/SEGGER_RTT_printf.c | 0 .../external/segger_rtt/license/license.txt | 0 .../thedotfactory_fonts/SIL-License.txt | 89 + .../external/thedotfactory_fonts/nrf_font.h | 62 + .../thedotfactory_fonts/orkney24pts.c | 4736 +++++ .../external/thedotfactory_fonts/orkney8pts.c | 1823 ++ .../external/utf_converter/LICENSE | 9 + .../external/utf_converter/utf.c | 350 + .../external/utf_converter/utf.h | 61 + .../CMSIS_Configuration_Wizard.jar | Bin .../external_tools/cmsisconfig/LICENSE.txt | 0 .../external_tools/cmsisconfig/README.TXT | 0 .../nrfx/legacy/apply_old_config.h | 1391 ++ .../integration/nrfx/legacy}/nrf_drv_clock.c | 176 +- .../integration/nrfx/legacy}/nrf_drv_clock.h | 112 +- .../integration/nrfx/legacy/nrf_drv_common.h} | 48 +- .../integration/nrfx/legacy/nrf_drv_comp.h | 137 + .../integration/nrfx/legacy/nrf_drv_gpiote.h | 139 + .../integration/nrfx/legacy/nrf_drv_i2s.h | 112 + .../integration/nrfx/legacy/nrf_drv_lpcomp.h | 82 + .../integration/nrfx/legacy/nrf_drv_pdm.h | 116 + .../integration/nrfx/legacy}/nrf_drv_power.c | 376 +- .../integration/nrfx/legacy/nrf_drv_power.h | 232 + .../integration/nrfx/legacy/nrf_drv_ppi.c} | 66 +- .../integration/nrfx/legacy/nrf_drv_ppi.h | 130 + .../integration/nrfx/legacy/nrf_drv_pwm.h | 135 + .../integration/nrfx/legacy/nrf_drv_qdec.h | 130 + .../integration/nrfx/legacy/nrf_drv_qspi.h | 122 + .../integration/nrfx/legacy}/nrf_drv_rng.c | 146 +- .../integration/nrfx/legacy}/nrf_drv_rng.h | 62 +- .../integration/nrfx/legacy/nrf_drv_rtc.h | 129 + .../integration/nrfx/legacy/nrf_drv_saadc.h | 143 + .../integration/nrfx/legacy/nrf_drv_spi.c | 135 + .../integration/nrfx/legacy}/nrf_drv_spi.h | 361 +- .../integration/nrfx/legacy/nrf_drv_spis.c | 63 + .../integration/nrfx/legacy/nrf_drv_spis.h | 144 + .../integration/nrfx/legacy/nrf_drv_swi.c} | 60 +- .../integration/nrfx/legacy/nrf_drv_swi.h | 108 + .../integration/nrfx/legacy/nrf_drv_systick.h | 80 + .../integration/nrfx/legacy/nrf_drv_timer.h | 121 + .../integration/nrfx/legacy/nrf_drv_twi.c | 192 + .../integration/nrfx/legacy}/nrf_drv_twi.h | 453 +- .../integration/nrfx/legacy/nrf_drv_twis.h | 134 + .../integration/nrfx/legacy/nrf_drv_uart.c | 141 + .../integration/nrfx/legacy/nrf_drv_uart.h | 660 + .../integration/nrfx/legacy/nrf_drv_usbd.h | 272 + .../nrfx/legacy/nrf_drv_usbd_errata.h | 70 + .../integration/nrfx/legacy/nrf_drv_wdt.h | 111 + .../integration/nrfx/nrfx_config.h | 47 + .../integration/nrfx/nrfx_glue.h | 338 + .../integration/nrfx/nrfx_log.h | 152 + .../license.txt | 0 .../modules/nrfx/CHANGELOG.md | 230 + .../modules/nrfx/LICENSE} | 23 +- .../modules/nrfx/README.md | 44 + .../nrfx/doc/buildfiles/extra_stylesheet.css | 506 + .../modules/nrfx/doc/buildfiles/favicon.ico | Bin 0 -> 26694 bytes .../modules/nrfx/doc/buildfiles/footer.html | 10 + .../modules/nrfx/doc/buildfiles/header.html | 58 + .../modules/nrfx/doc/buildfiles/layout.xml | 187 + .../nrfx/doc/buildfiles/nordic_small.png | Bin 0 -> 4338 bytes .../modules/nrfx/doc/drv_supp_matrix.dox | 55 + .../modules/nrfx/doc/generate_html_doc.bat | 2 + .../modules/nrfx/doc/generate_html_doc.sh | 2 + .../modules/nrfx/doc/main_page.dox | 89 + .../modules/nrfx/doc/nrf51_series.dox | 56 + .../modules/nrfx/doc/nrf52810.dox | 70 + .../modules/nrfx/doc/nrf52832.dox | 78 + .../modules/nrfx/doc/nrf52833.dox | 80 + .../modules/nrfx/doc/nrf52840.dox | 82 + .../modules/nrfx/doc/nrf9160.dox | 54 + .../modules/nrfx/doc/nrfx.doxyfile | 2505 +++ .../modules/nrfx/doc/nrfx_api.dox | 98 + .../nrfx/drivers/include/nrf_bitmask.h | 159 + .../modules/nrfx/drivers/include/nrfx_adc.h | 289 + .../modules/nrfx/drivers/include/nrfx_clock.h | 206 + .../modules/nrfx/drivers/include/nrfx_comp.h | 248 + .../modules/nrfx/drivers/include/nrfx_dppi.h | 185 + .../nrfx/drivers/include/nrfx_gpiote.h | 444 + .../modules/nrfx/drivers/include/nrfx_i2s.h | 253 + .../nrfx/drivers/include/nrfx_lpcomp.h | 153 + .../modules/nrfx/drivers/include/nrfx_nfct.h | 353 + .../modules/nrfx/drivers/include/nrfx_nvmc.h | 295 + .../modules/nrfx/drivers/include/nrfx_pdm.h | 207 + .../modules/nrfx/drivers/include/nrfx_power.h | 380 + .../nrfx/drivers/include/nrfx_power_clock.h} | 91 +- .../modules/nrfx/drivers/include/nrfx_ppi.h | 331 + .../modules/nrfx/drivers/include/nrfx_pwm.h | 476 + .../modules/nrfx/drivers/include/nrfx_qdec.h | 198 + .../modules/nrfx/drivers/include/nrfx_qspi.h | 330 + .../modules/nrfx/drivers/include/nrfx_rng.h} | 123 +- .../modules/nrfx/drivers/include/nrfx_rtc.h | 378 + .../modules/nrfx/drivers/include/nrfx_saadc.h | 316 + .../modules/nrfx/drivers/include/nrfx_spi.h | 255 + .../modules/nrfx/drivers/include/nrfx_spim.h | 385 + .../modules/nrfx/drivers/include/nrfx_spis.h | 256 + .../modules/nrfx/drivers/include/nrfx_swi.h | 245 + .../nrfx/drivers/include/nrfx_systick.h} | 114 +- .../modules/nrfx/drivers/include/nrfx_temp.h | 162 + .../modules/nrfx/drivers/include/nrfx_timer.h | 409 + .../modules/nrfx/drivers/include/nrfx_twi.h | 406 + .../nrfx/drivers/include/nrfx_twi_twim.h} | 32 +- .../modules/nrfx/drivers/include/nrfx_twim.h | 442 + .../modules/nrfx/drivers/include/nrfx_twis.h | 403 + .../modules/nrfx/drivers/include/nrfx_uart.h | 360 + .../modules/nrfx/drivers/include/nrfx_uarte.h | 359 + .../modules/nrfx/drivers/include/nrfx_usbd.h | 872 + .../modules/nrfx/drivers/include/nrfx_wdt.h} | 144 +- .../modules/nrfx/drivers/nrfx_common.h | 342 + .../modules/nrfx/drivers/nrfx_errors.h | 85 + .../modules/nrfx/drivers/src/nrfx_adc.c | 340 + .../modules/nrfx/drivers/src/nrfx_clock.c | 389 + .../modules/nrfx/drivers/src/nrfx_comp.c | 211 + .../modules/nrfx/drivers/src/nrfx_dppi.c | 319 + .../modules/nrfx/drivers/src/nrfx_gpiote.c} | 407 +- .../modules/nrfx/drivers/src/nrfx_i2s.c | 445 + .../modules/nrfx/drivers/src/nrfx_lpcomp.c | 174 + .../modules/nrfx/drivers/src/nrfx_nfct.c | 840 + .../modules/nrfx/drivers/src/nrfx_nvmc.c | 430 + .../modules/nrfx/drivers/src/nrfx_pdm.c | 370 + .../modules/nrfx/drivers/src/nrfx_power.c | 341 + .../modules/nrfx/drivers/src/nrfx_ppi.c | 530 + .../modules/nrfx/drivers/src/nrfx_pwm.c} | 290 +- .../modules/nrfx/drivers/src/nrfx_qdec.c} | 190 +- .../modules/nrfx/drivers/src/nrfx_qspi.c | 417 + .../modules/nrfx/drivers/src/nrfx_rng.c | 122 + .../modules/nrfx/drivers/src/nrfx_rtc.c | 348 + .../modules/nrfx/drivers/src/nrfx_saadc.c} | 364 +- .../modules/nrfx/drivers/src/nrfx_spi.c | 441 + .../modules/nrfx/drivers/src/nrfx_spim.c | 702 + .../modules/nrfx/drivers/src/nrfx_spis.c} | 420 +- .../modules/nrfx/drivers/src/nrfx_swi.c | 439 + .../modules/nrfx/drivers/src/nrfx_systick.c} | 88 +- .../modules/nrfx/drivers/src/nrfx_temp.c | 155 + .../modules/nrfx/drivers/src/nrfx_timer.c | 330 + .../modules/nrfx/drivers/src/nrfx_twi.c | 737 + .../modules/nrfx/drivers/src/nrfx_twi_twim.c} | 105 +- .../modules/nrfx/drivers/src/nrfx_twim.c | 777 + .../modules/nrfx/drivers/src/nrfx_twis.c | 857 + .../modules/nrfx/drivers/src/nrfx_uart.c | 654 + .../modules/nrfx/drivers/src/nrfx_uarte.c | 664 + .../modules/nrfx/drivers/src/nrfx_usbd.c} | 1452 +- .../nrfx/drivers/src/nrfx_usbd_errata.h | 157 + .../modules/nrfx/drivers/src/nrfx_wdt.c | 166 + .../modules/nrfx/drivers/src/prs/nrfx_prs.c | 166 + .../modules/nrfx/drivers/src/prs/nrfx_prs.h | 148 + .../modules/nrfx/hal/nrf_aar.h | 385 + .../modules/nrfx/hal/nrf_acl.h | 155 + .../modules/nrfx/hal/nrf_adc.h | 336 + .../modules/nrfx/hal/nrf_bprot.h | 134 + .../modules/nrfx/hal/nrf_ccm.h | 488 + .../modules/nrfx/hal/nrf_clock.h | 530 + .../modules/nrfx/hal/nrf_comp.h | 451 + .../modules/nrfx/hal/nrf_dppi.h | 341 + .../modules/nrfx}/hal/nrf_ecb.c | 33 +- .../modules/nrfx/hal/nrf_ecb.h | 287 + .../modules/nrfx}/hal/nrf_egu.h | 426 +- .../modules/nrfx/hal/nrf_ficr.h | 159 + .../modules/nrfx}/hal/nrf_gpio.h | 246 +- .../modules/nrfx}/hal/nrf_gpiote.h | 416 +- .../modules/nrfx}/hal/nrf_i2s.h | 430 +- .../modules/nrfx/hal/nrf_kmu.h | 278 + .../modules/nrfx}/hal/nrf_lpcomp.h | 408 +- .../modules/nrfx/hal/nrf_mpu.h | 185 + .../modules/nrfx/hal/nrf_mwu.h | 425 + .../modules/nrfx/hal/nrf_nfct.h | 1073 ++ .../modules/nrfx}/hal/nrf_nvmc.c | 41 +- .../modules/nrfx/hal/nrf_nvmc.h | 460 + .../modules/nrfx}/hal/nrf_pdm.h | 458 +- .../modules/nrfx}/hal/nrf_power.h | 1124 +- .../modules/nrfx}/hal/nrf_ppi.h | 451 +- .../modules/nrfx}/hal/nrf_pwm.h | 350 +- .../modules/nrfx}/hal/nrf_qdec.h | 528 +- .../modules/nrfx}/hal/nrf_qspi.h | 354 +- .../modules/nrfx/hal/nrf_radio.h | 1404 ++ .../modules/nrfx/hal/nrf_regulators.h} | 89 +- .../modules/nrfx}/hal/nrf_rng.h | 176 +- .../modules/nrfx/hal/nrf_rtc.h | 426 + .../modules/nrfx}/hal/nrf_saadc.h | 695 +- .../modules/nrfx}/hal/nrf_spi.h | 214 +- .../modules/nrfx/hal/nrf_spim.h | 801 + .../modules/nrfx}/hal/nrf_spis.h | 407 +- .../modules/nrfx/hal/nrf_spu.h | 450 + .../modules/nrfx}/hal/nrf_systick.h | 69 +- .../modules/nrfx/hal/nrf_temp.h | 274 + .../modules/nrfx}/hal/nrf_timer.h | 376 +- .../modules/nrfx}/hal/nrf_twi.h | 272 +- .../modules/nrfx}/hal/nrf_twim.h | 374 +- .../modules/nrfx/hal/nrf_twis.h | 745 + .../modules/nrfx}/hal/nrf_uart.h | 278 +- .../modules/nrfx}/hal/nrf_uarte.h | 478 +- .../modules/nrfx}/hal/nrf_usbd.h | 777 +- .../modules/nrfx/hal/nrf_vmc.h | 259 + .../modules/nrfx}/hal/nrf_wdt.h | 387 +- .../nrfx/helpers/nrfx_gppi/nrfx_gppi.h | 586 + .../modules/nrfx/mdk}/arm_startup_nrf52.s | 8 +- .../modules/nrfx/mdk}/compiler_abstraction.h | 26 +- .../modules/nrfx/mdk}/gcc_startup_nrf52.S | 12 +- .../modules/nrfx/mdk}/iar_startup_nrf52.s | 3 +- .../modules/nrfx/mdk}/nrf.h | 82 +- .../modules/nrfx/mdk/nrf51_to_nrf52.h | 2364 +++ .../modules/nrfx/mdk/nrf52.h | 2452 +++ .../modules/nrfx/mdk}/nrf52.svd | 106 +- .../modules/nrfx/mdk}/nrf52832_peripherals.h | 16 +- .../modules/nrfx/mdk/nrf52832_xxaa.ld | 13 + .../modules/nrfx/mdk/nrf52832_xxab.ld} | 2 +- .../modules/nrfx/mdk}/nrf52_bitfields.h | 26 +- .../modules/nrfx/mdk}/nrf52_common.ld | 4 +- .../modules/nrfx/mdk}/nrf52_name_change.h | 2 +- .../modules/nrfx/mdk}/nrf52_xxaa.ld | 2 +- .../modules/nrfx/mdk/nrf_common.ld} | 2 +- .../modules/nrfx/mdk/nrf_peripherals.h | 81 + .../modules/nrfx/mdk/ses_startup_nrf52.s | 391 + .../nrfx/mdk/ses_startup_nrf_common.s} | 134 +- .../modules/nrfx/mdk/system_nrf.h} | 8 +- .../modules/nrfx/mdk}/system_nrf52.c | 43 +- .../modules/nrfx/mdk/system_nrf52.h | 55 + .../modules/nrfx/nrfx.h | 49 + .../modules/nrfx/soc/nrfx_atomic.c | 395 + .../modules/nrfx/soc/nrfx_atomic.h | 284 + .../modules/nrfx/soc/nrfx_atomic_internal.h | 335 + .../modules/nrfx/soc/nrfx_coredep.h | 180 + .../modules/nrfx/soc/nrfx_irqs.h | 62 + .../modules/nrfx/soc/nrfx_irqs_nrf51.h | 137 + .../modules/nrfx/soc/nrfx_irqs_nrf52810.h | 149 + .../modules/nrfx/soc/nrfx_irqs_nrf52811.h | 152 + .../modules/nrfx/soc/nrfx_irqs_nrf52832.h | 194 + .../modules/nrfx/soc/nrfx_irqs_nrf52833.h | 205 + .../modules/nrfx/soc/nrfx_irqs_nrf52840.h | 211 + .../modules/nrfx/soc/nrfx_irqs_nrf9160.h | 170 + .../nrfx/templates/nRF51/nrfx_config.h | 1605 ++ .../nrfx/templates/nRF52810/nrfx_config.h | 2415 +++ .../nrfx/templates/nRF52811/nrfx_config.h | 2430 +++ .../nrfx/templates/nRF52832/nrfx_config.h | 2990 ++++ .../nrfx/templates/nRF52833/nrfx_config.h | 3042 ++++ .../nrfx/templates/nRF52840/nrfx_config.h | 3180 ++++ .../nrfx/templates/nRF9160/nrfx_config.h | 2079 +++ .../modules/nrfx/templates/nrfx_glue.h | 267 + .../modules/nrfx/templates/nrfx_log.h | 144 + 2045 files changed, 479723 insertions(+), 150098 deletions(-) create mode 100644 src/apps/lora_ping_pong/ISP4520/ses/ping-pong.emProject delete mode 100644 src/apps/lora_ping_pong/ISP4520/ses/ping_pong.emProject delete mode 100644 src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h~RFac87b98.TMP delete mode 100644 src/apps/lora_rx_temperature/ISP4520/ses/RX_temperature.emProject create mode 100644 src/apps/lora_tx_cw/ISP4520/ses/tx-cw.emProject delete mode 100644 src/apps/lora_tx_cw/ISP4520/ses/tx_cw.emProject create mode 100644 src/apps/lora_tx_temperature/ISP4520/ses/tx-temperature.emProject delete mode 100644 src/apps/lora_tx_temperature/ISP4520/ses/tx_temperature.emProject create mode 100644 src/apps/lorawan_class_A/ISP4520/ses/class-A.emProject delete mode 100644 src/apps/lorawan_class_A/ISP4520/ses/class_A.emProject create mode 100644 src/apps/lorawan_class_C/ISP4520/ses/class-C.emProject delete mode 100644 src/apps/lorawan_class_C/ISP4520/ses/class_C.emProject rename src/lora/system/soft-se/{aes.c => lora_aes.c} (99%) rename src/lora/system/soft-se/{aes.h => lora_aes.h} (100%) rename src/lora/system/soft-se/{cmac.c => lora_cmac.c} (99%) rename src/lora/system/soft-se/{cmac.h => lora_cmac.h} (99%) delete mode 100644 src/nordic_sdk/Extract nRF5_SDK_14.2.0_17b948a here.txt delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51422_peripherals.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51802_peripherals.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51822_peripherals.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_bitfields.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_deprecated.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52810.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52840.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_bitfields.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_peripherals.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_bitfields.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_peripherals.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52810.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52840.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/delay/nrf_delay.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/gpiote/nrf_drv_gpiote.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_clock.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_comp.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_peripherals.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_rtc.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_saadc.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_spim.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_twis.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pwm/nrf_drv_pwm.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qdec/nrf_drv_qdec.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/saadc/nrf_drv_saadc.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_slave/nrf_drv_spis.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis_inst.def delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd_errata.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/wdt/nrf_drv_wdt.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_types.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_asm.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdh.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdh.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_types.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_adc.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_langid.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_string_desc.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_internal.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/config/app_usbd_string_config.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_fixes.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf51822_5.0.0_release-notes.pdf delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_migration-document.pdf delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.build_log.htm delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.sct delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf51.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52810.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52840.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.posix delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf51.S delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52810.S delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52840.S delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxaa.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxab.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52810_xxaa.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52840_xxaa.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf5x_common.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf51.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52810.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52840.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf51_Vectors.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52810_Vectors.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52840_Vectors.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52_Vectors.s delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/license/license.txt delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/port.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/portmacro.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/port.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/portmacro.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/portmacro.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/portmacro.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/portmacro.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/portmacro.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/StackMacros.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/mpu_wrappers.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/projdefs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/semphr.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_1.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_3.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/readme.txt delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.bat delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_utils.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_kg.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_edw_api.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_build.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_dh.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_domain.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_ecdsa.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_kg.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_types.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_pka_defs_hw.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_poly.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_kg.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_prim.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/dx_reg_base_host.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/sns_silib.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_bitops.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_barrier.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_error.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_file_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_init.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_malloc_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_memmap.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_perf_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_sem_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_string_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types_plat.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_regs.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_sram_map.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/lib/license.txt delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/license.txt delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/aes.c delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/aes.h delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/origin.txt delete mode 100644 src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/unlicense.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_advertising/ble_advertising.h (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_db_discovery/ble_db_discovery.c (81%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_dtm/ble_dtm.c (77%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_dtm/ble_dtm.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_dtm/ble_dtm_hw.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_dtm/ble_dtm_hw_nrf51.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_dtm/ble_dtm_hw_nrf52.c (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.c => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c} (65%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_racp/ble_racp.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_racp/ble_racp.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_radio_notification/ble_radio_notification.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_radio_notification/ble_radio_notification.h (97%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ans_c/ble_ans_c.c (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ans_c/ble_ans_c.h (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_bas/ble_bas.c (52%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_bas/ble_bas.h (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_bas_c/ble_bas_c.c (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_bas_c/ble_bas_c.h (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_bps/ble_bps.c (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_bps/ble_bps.h (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_cscs/ble_cscs.c (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_cscs/ble_cscs.h (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_cts_c/ble_cts_c.c (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_cts_c/ble_cts_c.h (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_dfu/ble_dfu.c (87%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_dfu/ble_dfu.h (84%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c (78%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_dis/ble_dis.c (83%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_dis/ble_dis.h (96%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_escs/escs_defs.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_escs/nrf_ble_escs.c (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_escs/nrf_ble_escs.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_gls/ble_gls.c (65%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_gls/ble_gls_db.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_gls/ble_gls_db.h (97%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hids/ble_hids.h (53%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hrs/ble_hrs.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hrs/ble_hrs.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h (57%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hts/ble_hts.c (66%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_hts/ble_hts.h (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ias/ble_ias.c (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ias/ble_ias.h (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ias_c/ble_ias_c.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ias_c/ble_ias_c.h (71%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ipsp/ble_ipsp.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_ipsp/ble_ipsp.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_lbs/ble_lbs.c (50%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_lbs/ble_lbs.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c (57%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_lls/ble_lls.c (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_lls/ble_lls.h (95%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_nus/ble_nus.h (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_nus_c/ble_nus_c.c (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_nus_c/ble_nus_c.h (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_rscs/ble_rscs.c (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_rscs/ble_rscs.h (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c (60%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h (72%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_tps/ble_tps.c (65%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/ble_tps/ble_tps.h (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv.h (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv_frame.c (81%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv_frame.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv_timing.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv_timing.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv_timing_resolver.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_adv_timing_resolver.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_battery_voltage.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_battery_voltage_saadc.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_flash.c (89%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_flash.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_gatts.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_gatts.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_gatts_read.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_gatts_read.h (89%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_gatts_write.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_gatts_write.h (97%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_security.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_slot.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_slot.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_slot_reg.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_slot_reg.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_stopwatch.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_stopwatch.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_tlm.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_tlm.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/es_util.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/nrf_ble_es.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries => nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services}/eddystone/nrf_ble_es.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_lns.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_lns/ble_lns.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h (62%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c (89%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c (85%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c (53%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c (71%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_advdata.c (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_advdata.h (62%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_conn_params.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_conn_params.h (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_conn_state.h (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_date_time.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_gatt_db.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_sensor_location.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_srv_common.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/common/ble_srv_common.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/nrf_ble_gatt/nrf_ble_gatt.c (81%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/nrf_ble_gatt/nrf_ble_gatt.h (96%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/nrf_ble_qwr/nrf_ble_qwr.c (85%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/nrf_ble_qwr/nrf_ble_qwr.h (68%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_ecb.h => nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.h} (60%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/gatt_cache_manager.c (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/gatt_cache_manager.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/gatts_cache_manager.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/gatts_cache_manager.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/id_manager.c (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/id_manager.h (96%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_data_storage.c (84%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_data_storage.h (83%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_database.c (77%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_database.h (53%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_id.c (78%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_id.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_manager.c (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_manager.h (84%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_manager_internal.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/peer_manager_types.h (86%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/pm_buffer.c (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/pm_buffer.h (82%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/security_dispatcher.c (72%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/security_dispatcher.h (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/security_manager.c (71%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/ble/peer_manager/security_manager.h (84%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/nrf_soc_nosd/nrf_error.h (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h => nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_sdm.h} (82%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/radio_config/radio_config.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/radio_config/radio_config.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/sdio/config/sdio_config.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/sdio/sdio.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/sdio/sdio.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/spi_master/spi_5W_master.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/spi_master/spi_5W_master.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/twi_master/deprecated/twi_master.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.c} (60%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/atomic/nrf_atomic_internal.h (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/atomic/nrf_atomic_sanity_check.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/atomic_fifo/nrf_atfifo.c (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/atomic_fifo/nrf_atfifo.h (89%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/atomic_fifo/nrf_atfifo_internal.h (99%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/balloc/nrf_balloc.c (71%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/balloc/nrf_balloc.h (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/empty/nrf_block_dev_empty.c (78%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/empty/nrf_block_dev_empty.h (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/nrf_block_dev.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c (87%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/qspi/nrf_serial_flash_params.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/qspi/nrf_serial_flash_params.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/ram/nrf_block_dev_ram.c (81%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/ram/nrf_block_dev_ram.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ant_dfu/nrf_dfu_ant.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.h} (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble_svci_bond_sharing.h} (61%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.options create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.proto rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu.c} (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_flash.c (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_flash.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h (78%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_mbr.c (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_settings.h (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_nosd.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci.c} (65%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c (76%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_transport.c (82%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/dfu/nrf_dfu_transport.h (73%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_types.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/nrf_bootloader.h (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/nrf_bootloader_app_start.c (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/nrf_bootloader_app_start.h (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start_final.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.h} (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bootloader/nrf_bootloader_info.c (72%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.c} (53%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_uart.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_usb.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp.c (86%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_btn_ant.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_btn_ant.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_btn_ble.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_btn_ble.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.c} (67%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_config.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_nfc.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/bsp/bsp_nfc.h (97%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/button/app_button.h (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c (82%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c (78%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h (94%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cli_utils_cmds.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/nrf_cli.c (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/nrf_cli.h (81%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/nrf_cli_types.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/nrf_cli_vt100.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/rtt/nrf_cli_rtt.c (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/rtt/nrf_cli_rtt.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/uart/nrf_cli_uart.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/cli/uart/nrf_cli_uart.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/crc16/crc16.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/crc16/crc16.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/crc32/crc32.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/crc32/crc32.h (96%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_init.c} (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.c} (87%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.h} (64%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_init.c} (55%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.h} (71%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.h} (57%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_init.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_shared.h} (73%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_init.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.c} (55%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.h} (60%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_nvmc.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.h} (54%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_init.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_backend.h} (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_shared.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_mem.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_backend.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_shared.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_rng.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.c} (60%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/crypto/nrf_crypto_svc.c (96%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_types.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/csense/nrf_csense.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/csense/nrf_csense.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/csense/nrf_csense_macros.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/csense_drv/nrf_drv_csense.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/csense_drv/nrf_drv_csense.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/delay/nrf_delay.h} (76%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/ecc/ecc.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/ecc/ecc.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_section_vars/nrf_section.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_section_vars/nrf_section_iter.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_section_vars/nrf_section_iter.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_task_manager/task_manager.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_task_manager/task_manager.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_task_manager/task_manager_core_armgcc.S (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_task_manager/task_manager_core_iar.s (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/experimental_task_manager/task_manager_core_keil.s (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fds/fds.c (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fds/fds.h (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fds/fds_internal_defs.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fifo/app_fifo.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fifo/app_fifo.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fstorage/nrf_fstorage.c (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fstorage/nrf_fstorage.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fstorage/nrf_fstorage_nvmc.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fstorage/nrf_fstorage_nvmc.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fstorage/nrf_fstorage_sd.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/fstorage/nrf_fstorage_sd.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/gfx/nrf_gfx.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/gfx/nrf_gfx.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/gfx/nrf_lcd.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/gpiote/app_gpiote.c (77%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/gpiote/app_gpiote.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/hardfault.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/hardfault_genhf.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/hardfault_implementation.c (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c (76%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hci/hci_mem_pool.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hci/hci_mem_pool.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hci/hci_slip.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hci/hci_slip.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hci/hci_transport.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/hci/hci_transport.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/led_softblink/led_softblink.c (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/led_softblink/led_softblink.h (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log.h (59%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_flash.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log_backend_interface.h (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log_backend_rtt.h (89%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log_backend_uart.h (89%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log_ctrl.h (83%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log_default_backends.h (96%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_instance.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/nrf_log_str_formatter.h (88%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_types.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_flash.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_backend_rtt.c (71%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_backend_serial.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_backend_serial.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_backend_uart.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_ctrl_internal.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_default_backends.c (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_frontend.c (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_internal.h (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log => nRF5_SDK_16.0.0_98a08e2/components/libraries/log}/src/nrf_log_str_formatter.c (77%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/low_power_pwm/low_power_pwm.c (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/low_power_pwm/low_power_pwm.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/mem_manager/mem_manager.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/mem_manager/mem_manager.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj => nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj}/nrf_memobj.c (66%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj => nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj}/nrf_memobj.h (56%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.c => nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.c} (85%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.h} (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/mutex/nrf_mtx.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/pwm/app_pwm.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/pwm/app_pwm.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/queue/nrf_queue.c (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/queue/nrf_queue.h (82%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf => nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf}/nrf_ringbuf.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf => nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf}/nrf_ringbuf.h (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/scheduler/app_scheduler.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/scheduler/app_scheduler.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/scheduler/app_scheduler_serconn.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sdcard/app_sdcard.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sdcard/app_sdcard.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sensorsim/sensorsim.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sensorsim/sensorsim.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/serial/nrf_serial.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/serial/nrf_serial.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sha256/sha256.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sha256/sha256.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/simple_timer/app_simple_timer.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/simple_timer/app_simple_timer.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/slip/slip.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/slip/slip.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sortlist/nrf_sortlist.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/sortlist/nrf_sortlist.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/spi_mngr/nrf_spi_mngr.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/spi_mngr/nrf_spi_mngr.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard => nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard}/nrf_stack_guard.c (85%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard => nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard}/nrf_stack_guard.h (85%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_info/nrf_stack_info.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/strerror/nrf_strerror.c (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/strerror/nrf_strerror.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/svc/nrf_svc_function.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/svc/nrf_svc_handler.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/svc/nrf_svci.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/svc/nrf_svci_async_function.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/svc/nrf_svci_async_handler.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/timer/app_timer.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/timer/app_timer.h (81%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer2.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/timer/app_timer_freertos.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/timer/app_timer_rtx.c (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/twi_mngr/nrf_twi_mngr.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/twi_mngr/nrf_twi_mngr.h (99%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/uart/app_uart.c (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/uart/app_uart.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/uart/app_uart_fifo.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/uart/retarget.c (94%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd.c (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd.h (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd_class_base.h (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd_core.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd_core.h (83%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd_descriptor.h (93%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_langid.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd_request.h (90%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_shared.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.h} (71%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/app_usbd_types.h (74%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/audio/app_usbd_audio.h (53%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/audio/app_usbd_audio_desc.h (85%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_internal.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/audio/app_usbd_audio_types.h (91%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h (71%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_internal.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.h => nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_types.h} (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/app_usbd_hid.c (56%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/app_usbd_hid.h (60%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/app_usbd_hid_types.h (86%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h (65%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h (69%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h (68%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c (53%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h (72%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h (71%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/msc/app_usbd_msc.h (84%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/msc/app_usbd_msc_desc.h (92%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/msc/app_usbd_msc_internal.h (50%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h (85%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/usbd/class/msc/app_usbd_msc_types.h (73%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_internal.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_types.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_error.c (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_error.h (79%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_gcc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_iar.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_keil.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_error_weak.c (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_error_weak.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_util.h (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_util_bds.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_util_platform.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/app_util_platform.h (85%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/nordic_common.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/nrf_assert.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/nrf_assert.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/nrf_bitmask.h (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_alloca.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_common.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_errors.h (83%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_macros.h (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_mapped_flags.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_mapped_flags.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_os.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/libraries/util/sdk_resources.h (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c (73%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h => nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h} (67%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/generic/message/nfc_ndef_msg.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/generic/message/nfc_ndef_msg.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/generic/record/nfc_ndef_record.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/generic/record/nfc_ndef_record.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/launchapp/nfc_launchapp_msg.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/launchapp/nfc_launchapp_msg.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/launchapp/nfc_launchapp_rec.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/launchapp/nfc_launchapp_rec.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/text/nfc_text_rec.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/text/nfc_text_rec.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/uri/nfc_uri_msg.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/uri/nfc_uri_msg.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/uri/nfc_uri_rec.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/ndef/uri/nfc_uri_rec.h (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t2t_lib/license.txt (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t2t_lib/nfc_t2t_lib.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t2t_parser/nfc_t2t_parser.c (93%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t2t_parser/nfc_t2t_parser.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t2t_parser/nfc_tlv_block.h (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_lib/license.txt (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_lib/nfc_t4t_lib.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/sdk_validation.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh.c (84%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_ant.c (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_ant.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_ble.c (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_ble.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_freertos.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_freertos.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_soc.c (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/common/nrf_sdh_soc.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf52 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers}/nrf_mbr.h (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr}/headers/nrf_svc.h (86%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_licence-agreement.txt => nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/hex/mbr_nrf52_2.4.1_licence-agreement.txt} (97%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_licence-agreement.txt => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_licence-agreement.txt} (97%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_migration-document.pdf create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_release-notes.pdf rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble.h (81%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_err.h (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_gap.h (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_gatt.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_gattc.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_gatts.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_hci.h (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_ranges.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/ble_types.h (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf52/nrf_mbr.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_error.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_error_sdm.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_error_soc.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_nvic.h (95%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_sd_def.h (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_sdm.h (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/softdevice/s132 => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112}/headers/nrf_soc.h (85%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_svc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/hex/s112_nrf52_7.0.1_licence-agreement.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/armgcc/armgcc_s112_nrf52810_xxaa.ld create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/iar/iar_s112_nrf52810_xxaa.icf create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_licence-agreement.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_migration-document.pdf create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_release-notes.pdf create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_err.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gap.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatt.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gattc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatts.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_hci.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/s132/headers/ble_l2cap.h (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/s132/headers/ble_ranges.h (93%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_types.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf52/nrf_mbr.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_sdm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_soc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_nvic.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.h => nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sd_def.h} (77%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sdm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_soc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_svc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/hex/s132_nrf52_7.0.1_licence-agreement.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/arm/uicr_config.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/dsp/license.txt (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/arm_common_tables.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/arm_const_structs.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/arm_math.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/cmsis_armcc.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/cmsis_armcc_V6.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/cmsis_gcc.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cm0.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cm0plus.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cm3.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cm4.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cm7.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cmFunc.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cmInstr.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_cmSimd.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_sc000.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/cmsis/include/core_sc300.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/gcc/Makefile.common (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.posix rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/gcc/Makefile.windows (67%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/gcc/dump.mk (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/gcc/gcc_nrf51_common.ld (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/iar/iar_nrf51_blank_xxaa.icf (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/components/toolchain/iar/iar_nrf51_blank_xxac.icf (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/armgcc/generic_gcc_nrf52.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2/config/nrf52810}/config/sdk_config.h (54%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/ses/flash_placement.xml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/generic_gcc_nrf52.ld create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/config/sdk_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/flash_placement.xml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/generic_nrf52811_xxaa.emProject create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/armgcc/generic_gcc_nrf52.ld create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/config/sdk_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/ses/flash_placement.xml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/generic_gcc_nrf52.ld create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/config/sdk_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/flash_placement.xml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/generic_nrf52833_xxaa.emProject create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/armgcc/generic_gcc_nrf52.ld create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/config/sdk_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/ses/flash_placement.xml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/bitops.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cf_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_cmac.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/eax.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/handy.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/prp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/tassert.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/fprintf/nrf_fprintf.c (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/fprintf/nrf_fprintf.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/fprintf/nrf_fprintf_format.c (66%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/fprintf/nrf_fprintf_format.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/config/FreeRTOSConfig.h (73%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/license/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/port.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/portmacro.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/port.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/portmacro.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/CMSIS/nrf51/port_cmsis.c (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/CMSIS/nrf52/port_cmsis.c (76%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h (62%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/GCC/nrf51/port.c (55%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/portmacro.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/GCC/nrf52/port.c (58%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/portmacro.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/IAR/nrf51/port.c (57%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/portmacro.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/portable/IAR/nrf52/port.c (62%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/portmacro.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/readme.txt (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/croutine.c (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/event_groups.c (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/FreeRTOS.h (55%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/StackMacros.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/croutine.h (83%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/deprecated_definitions.h (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/event_groups.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/list.h (75%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/message_buffer.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_prototypes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_wrappers.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/portable.h (52%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/projdefs.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/queue.h (82%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/semphr.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stack_macros.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/stdint.readme (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stream_buffer.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/task.h (76%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/include/timers.h (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/list.c (61%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/Common/mpu_wrappers.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/ReadMe.url create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_1.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/portable/MemMang/heap_2.c (62%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_3.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/portable/MemMang/heap_4.c (63%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/portable/MemMang/heap_5.c (66%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/readme.txt rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/queue.c (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/readme.txt (88%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/stream_buffer.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/tasks.c (58%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/freertos/source/timers.c (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/licenses_external.txt (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/.travis.yml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/ChangeLog create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/DartConfiguration.tcl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/LICENSE create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/apache-2.0.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/circle.yml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/README.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-ccm-psk-tls1_2.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-mini-tls1_1.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-no-entropy.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-picocoin.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-suite-b.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-thread.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_encdec.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_hashing.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_mainpage.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_rng.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_ssltls.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_tcpip.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_x509.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/mbedtls.doxyfile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aesni.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/arc4.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1write.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/base64.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bignum.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/blowfish.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bn_mul.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/camellia.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ccm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/certs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/check_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher_internal.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cmac.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/compat-1.3.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ctr_drbg.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/debug.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/des.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/dhm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecjpake.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy_poll.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/gcm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/havege.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/hmac_drbg.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md2.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md4.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md5.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md_internal.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/memory_buffer_alloc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net_sockets.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/oid.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/padlock.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pem.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk_internal.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs11.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs12.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs5.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform_time.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ripemd160.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/rsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha1.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha512.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cache.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ciphersuites.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cookie.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_internal.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ticket.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/threading.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/timing.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/version.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crl.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crt.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_csr.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/xtea.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aes.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aesni.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/arc4.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1parse.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1write.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/base64.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/bignum.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/blowfish.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/camellia.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ccm.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/certs.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher_wrap.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cmac.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ctr_drbg.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/debug.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/des.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/dhm.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdh.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecjpake.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp_curves.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy_poll.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/error.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/gcm.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/havege.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/hmac_drbg.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md2.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md4.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md5.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md_wrap.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/memory_buffer_alloc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/net_sockets.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/oid.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/padlock.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pem.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk_wrap.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs11.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs12.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs5.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkparse.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkwrite.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/platform.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ripemd160.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/rsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha1.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha256.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha512.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cache.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ciphersuites.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cli.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cookie.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_srv.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ticket.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_tls.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/threading.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/timing.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version_features.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_create.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crl.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_csr.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_crt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_csr.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/xtea.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/aescrypt2.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/crypt_and_hash.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/generic_sum.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/hello.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_client.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_genprime.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_prime.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_server.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdh_curve25519.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdsa.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/gen_key.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app_writer.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/mpi_demo.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_decrypt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_encrypt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_sign.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_verify.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_decrypt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_encrypt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_genkey.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_priv.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_pub.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign_pss.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify_pss.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_entropy.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_ctr_drbg.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_havege.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_client.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_server.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/mini_client.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client1.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client2.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_fork_server.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_mail_client.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_pthread_server.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server2.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/pem2der.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/strerror.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/wince_main.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/CMakeLists.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_app.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_req.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_write.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/crl_app.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/req_app.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/apidoc_full.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/bump_version.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/config.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/error.fmt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/rename-1.3-2.0.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/version_features.fmt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-app-template.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-main-template.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-sln-template.sln create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-app-template.dsp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-main-template.dsp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-workspace-template.dsw create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/ecc-heap.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/find-mem-leak.cocci create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/footprint.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_errors.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_features.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_visualc_files.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/malloc-init.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/massif_max.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/memory.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/output_env.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rename.pl create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rm-malloc-cast.cocci create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/tmp_ignore_makefiles.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/aescrypt2.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/benchmark.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_app.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_req.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_write.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crl_app.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crypt_and_hash.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_client.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_genprime.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_server.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_client.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_server.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdh_curve25519.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdsa.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_entropy.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_key.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_ctr_drbg.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_havege.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/generic_sum.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/hello.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app_writer.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.sln create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/md5sum.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mini_client.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mpi_demo.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pem2der.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_decrypt.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_encrypt.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_sign.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_verify.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/req_app.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_decrypt.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_encrypt.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_genkey.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign_pss.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify_pss.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/selftest.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha1sum.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha2sum.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client1.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client2.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_fork_server.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_mail_client.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server2.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/strerror.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/udp_proxy.vcxproj create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/create-module.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/adjust-config.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/entropy_hardware_poll.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/main.cpp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/main.cpp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/main.cpp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/main.cpp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/target_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.bat rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/build_all.sh (69%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/license.txt (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/.gitignore (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/LICENSE.txt (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/README.md (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/asm_arm.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/asm_arm_mult_square.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/asm_arm_mult_square_umaal.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/asm_avr.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/asm_avr_mult_square.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/curve-specific.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/emk_project.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/emk_rules.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/examples/ecc_test/ecc_test.ino (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/library.properties (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/platform-specific.inc (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/scripts/mult_arm.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/scripts/mult_avr.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/scripts/mult_avr_extra.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/scripts/square_arm.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/scripts/square_avr.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/test/emk_rules.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/test/test_compress.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/test/test_compute.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/test/test_ecdh.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/test/test_ecdsa.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/test/test_ecdsa_deterministic.c.example (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/types.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/uECC.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/uECC.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/micro-ecc/uECC_vli.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf51_armgcc/armgcc/Makefile (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf51_iar/armgcc/Makefile (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc => nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar}/armgcc/ext_micro_ecc_gcc_nRF5x.ld (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf51_keil/armgcc/Makefile (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar => nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil}/armgcc/ext_micro_ecc_gcc_nRF5x.ld (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile (80%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil => nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc}/armgcc/ext_micro_ecc_gcc_nRF5x.ld (91%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf52hf_iar/armgcc/Makefile (80%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf52hf_keil/armgcc/Makefile (81%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile (80%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf52nf_iar/armgcc/Makefile (79%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/micro-ecc/nrf52nf_keil/armgcc/Makefile (81%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/LICENSE.txt (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/camel_case_splitter.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/nanopb_generator.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/Makefile (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/__init__.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/google/protobuf/descriptor.proto (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/nanopb.proto (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/nanopb_pb2.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/plugin.proto (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/proto/plugin_pb2.py (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/protoc-gen-nanopb (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/generator/protoc-gen-nanopb.bat (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb_common.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb_common.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb_decode.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb_decode.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb_encode.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nano-pb/pb_encode.h (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nfc_adafruit_library/adafruit_pn532.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nfc_adafruit_library/adafruit_pn532.h (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile.internal create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_utils.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/common/integration_test_ssi_data.h (69%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ccsw_crys_rsa_shared_types.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm_error.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_chacha.h (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly_error.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_common.h (65%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common_error.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_dh.h (53%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_kg.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_edw_api.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_ec_mont_api.h (61%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_edw_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_build.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_dh.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_domain.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_ecdsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_kg.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_types.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_error.h (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_hash.h (59%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf_error.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_hmac.h (53%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_pka_defs_hw.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd_error.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_rsa_build.h (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_rsa_error.h (54%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_kg.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_prim.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_rsa_schemes.h (56%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/crys_rsa_types.h (79%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/dx_reg_base_host.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/sns_silib.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_bitops.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_abort.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_barrier.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/nrf_cc310/include/ssi_pal_compiler.h (62%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_fips.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_init.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_list.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_log.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mem.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_memmap.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_trng.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_regs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_sram_map.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/lib/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_aesccm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_ecpki_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_hash_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_common.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp224r1.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp256r1.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_common.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_sha256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_init.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/sns_silib.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_defs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_error.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types_plat.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/lib/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_ctr.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_eax.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_gcm.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.h => nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_key.h} (75%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305_inc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto.h => nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_constant_time.h} (53%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve25519.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve_p256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdh_p256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdsa_p256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ed25519.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.h => nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha256.h} (56%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha512.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha512.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa_key.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha256.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha512.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srtp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/lib/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/license.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/dtls/config/nrf_dtls_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/nrf_crypto/config/nrf_crypto_mbedtls_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/asn1write.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/ssl_srv.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls/config/nrf_tls_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls_interface.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/nrf_tls.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.c => nRF5_SDK_16.0.0_98a08e2/external/protothreads/nrf_pt.h} (84%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README-VISUAL-C++.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Doxyfile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Makefile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/header.tex create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00005.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00006.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00009.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00010.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00011.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00012.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00013.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00014.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00015.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00016.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00017.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00018.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00019.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00020.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00021.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00022.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/annotated.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.css create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/files.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2blank.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2doc.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2folderclosed.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2folderopen.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2lastnode.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2link.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2mlastnode.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2mnode.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2node.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2plastnode.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2pnode.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2vertline.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions_vars.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_defs.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_type.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/hierarchy.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhc create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhk create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhp create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/main.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/modules.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_b.gif create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_l.gif create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_r.gif create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tabs.css create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tree.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-doc.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-mainpage.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-refman.pdf create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/sicslogo.pdf create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-buffer.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-codelock.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-small.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-addrlabels.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-switch.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt-sem.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT_Conf.h (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT_Syscalls_IAR.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT_Syscalls_KEIL.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT_Syscalls_SES.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/SEGGER_RTT_printf.c (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external/segger_rtt/license/license.txt (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/SIL-License.txt create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/nrf_font.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney24pts.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney8pts.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/LICENSE create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external_tools/cmsisconfig/LICENSE.txt (100%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/external_tools/cmsisconfig/README.TXT (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/apply_old_config.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_clock.c (74%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_clock.h (78%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.h => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_common.h} (76%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_comp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_gpiote.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_i2s.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_lpcomp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pdm.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_power.c (54%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.h => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.c} (74%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pwm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qdec.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qspi.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_rng.c (75%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_rng.h (76%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rtc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_saadc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_spi.h (66%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.h => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.c} (75%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_systick.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_timer.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master => nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy}/nrf_drv_twi.h (65%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twis.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd_errata.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_wdt.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_glue.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_log.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a => nRF5_SDK_16.0.0_98a08e2}/license.txt (100%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/CHANGELOG.md rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/LICENSE} (93%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/README.md create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/extra_stylesheet.css create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/favicon.ico create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/footer.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/header.html create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/layout.xml create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/nordic_small.png create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/drv_supp_matrix.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.bat create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.sh create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/main_page.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf51_series.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52810.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52832.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52833.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52840.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf9160.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrfx.doxyfile create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrfx_api.dox create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrf_bitmask.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_adc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_clock.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_comp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_dppi.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_gpiote.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_i2s.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_lpcomp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_nfct.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_nvmc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_pdm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_power.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/nfc_fixes.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_power_clock.h} (58%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_ppi.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_pwm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_qdec.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_qspi.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_string_desc.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_rng.h} (50%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_rtc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_saadc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_spi.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_spim.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_spis.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_swi.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/systick/nrf_drv_systick.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_systick.h} (52%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_temp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_timer.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_twi.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdh.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_twi_twim.h} (89%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_twim.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_twis.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_uart.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_uarte.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_usbd.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/wdt/nrf_drv_wdt.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/include/nrfx_wdt.h} (50%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/nrfx_common.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/nrfx_errors.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_adc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_clock.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_comp.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_dppi.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/gpiote/nrf_drv_gpiote.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_gpiote.c} (61%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_i2s.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_lpcomp.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_nfct.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_nvmc.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_pdm.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_power.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_ppi.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pwm/nrf_drv_pwm.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_pwm.c} (61%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qdec/nrf_drv_qdec.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_qdec.c} (50%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_qspi.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_rng.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_rtc.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/saadc/nrf_drv_saadc.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_saadc.c} (60%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_spi.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_spim.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_slave/nrf_drv_spis.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_spis.c} (50%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_swi.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/systick/nrf_drv_systick.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_systick.c} (68%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_temp.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_timer.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_twi.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_shared.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_twi_twim.c} (58%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_twim.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_twis.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_uart.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_uarte.c rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd.c => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_usbd.c} (51%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_usbd_errata.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/nrfx_wdt.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/prs/nrfx_prs.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/drivers/src/prs/nrfx_prs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_aar.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_acl.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_adc.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_bprot.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_ccm.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_clock.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_comp.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_dppi.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_ecb.c (93%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_ecb.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_egu.h (60%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_ficr.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_gpio.h (79%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_gpiote.h (56%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_i2s.h (56%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_kmu.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_lpcomp.h (67%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_mpu.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_mwu.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_nfct.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_nvmc.c (90%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_nvmc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_pdm.h (51%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_power.h (54%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_ppi.h (62%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_pwm.h (70%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_qdec.h (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_qspi.h (73%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_radio.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_temp.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_regulators.h} (58%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_rng.h (57%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_rtc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_saadc.h (57%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_spi.h (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_spim.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_spis.h (51%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_spu.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_systick.h (82%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_temp.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_timer.h (64%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_twi.h (59%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_twim.h (52%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_twis.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_uart.h (62%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_uarte.h (50%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_usbd.h (61%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/hal/nrf_vmc.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/drivers_nrf => nRF5_SDK_16.0.0_98a08e2/modules/nrfx}/hal/nrf_wdt.h (55%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/helpers/nrfx_gppi/nrfx_gppi.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/arm => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/arm_startup_nrf52.s (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/device => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/compiler_abstraction.h (87%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/gcc_startup_nrf52.S (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/iar => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/iar_startup_nrf52.s (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/device => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf.h (63%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/nrf51_to_nrf52.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/nrf52.h rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/svd => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf52.svd (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/device => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf52832_peripherals.h (94%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/nrf52832_xxaa.ld rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxac.ld => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/nrf52832_xxab.ld} (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/device => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf52_bitfields.h (99%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf52_common.ld (96%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/device => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf52_name_change.h (98%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/nrf52_xxaa.ld (88%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_common.ld => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/nrf_common.ld} (98%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/nrf_peripherals.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/ses_startup_nrf52.s rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nRF_Startup.s => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/ses_startup_nrf_common.s} (52%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52.h => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/system_nrf.h} (90%) rename src/nordic_sdk/{nRF5_SDK_14.2.0_17b948a/components/toolchain => nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk}/system_nrf52.c (93%) create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/mdk/system_nrf52.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/nrfx.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_atomic.c create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_atomic.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_atomic_internal.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_coredep.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf51.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf52810.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf52811.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf52832.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf52833.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf52840.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/soc/nrfx_irqs_nrf9160.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF51/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF52810/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF52811/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF52832/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF52833/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF52840/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nRF9160/nrfx_config.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nrfx_glue.h create mode 100644 src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/templates/nrfx_log.h diff --git a/src/apps/ble_lorawan_AT_commands/ISP4520/s132/config/sdk_config.h b/src/apps/ble_lorawan_AT_commands/ISP4520/s132/config/sdk_config.h index b8e6ee4..2e7fc4d 100644 --- a/src/apps/ble_lorawan_AT_commands/ISP4520/s132/config/sdk_config.h +++ b/src/apps/ble_lorawan_AT_commands/ISP4520/s132/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,19 +46,6 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// Board Support - -//========================================================== -// BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE - - -#ifndef BSP_BTN_BLE_ENABLED -#define BSP_BTN_BLE_ENABLED 1 -#endif - -// -//========================================================== - // nRF_BLE //========================================================== @@ -69,13 +56,6 @@ #define BLE_ADVERTISING_ENABLED 1 #endif -// BLE_DB_DISCOVERY_ENABLED - ble_db_discovery - Database discovery module - - -#ifndef BLE_DB_DISCOVERY_ENABLED -#define BLE_DB_DISCOVERY_ENABLED 1 -#endif - // BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands @@ -118,17 +98,22 @@ #define NRF_BLE_GATT_ENABLED 1 #endif -// NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) - - +// 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 +#define NRF_BLE_QWR_ENABLED 1 #endif +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// // PEER_MANAGER_ENABLED - peer_manager - Peer Manager //========================================================== #ifndef PEER_MANAGER_ENABLED -#define PEER_MANAGER_ENABLED 0 +#define PEER_MANAGER_ENABLED 1 #endif // PM_MAX_REGISTRANTS - Number of event handlers that can be registered. #ifndef PM_MAX_REGISTRANTS @@ -139,7 +124,7 @@ // Decrease this value to lower RAM usage. #ifndef PM_FLASH_BUFFERS -#define PM_FLASH_BUFFERS 2 +#define PM_FLASH_BUFFERS 4 #endif // PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. @@ -151,6 +136,70 @@ #define PM_CENTRAL_ENABLED 0 #endif +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + // // @@ -180,12 +229,63 @@ #define BLE_BAS_C_ENABLED 0 #endif -// BLE_BAS_ENABLED - ble_bas - Battery Service - - +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== #ifndef BLE_BAS_ENABLED #define BLE_BAS_ENABLED 0 #endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// // BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service @@ -250,12 +350,63 @@ #define BLE_IAS_C_ENABLED 0 #endif -// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service - - +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== #ifndef BLE_IAS_ENABLED #define BLE_IAS_ENABLED 0 #endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// // BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client @@ -285,12 +436,63 @@ #define BLE_NUS_C_ENABLED 0 #endif -// BLE_NUS_ENABLED - ble_nus - Nordic UART Service - - +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== #ifndef BLE_NUS_ENABLED #define BLE_NUS_ENABLED 0 #endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// // BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client @@ -316,904 +518,843 @@ // //========================================================== -// nRF_DFU +// nRF_Core //========================================================== -// ble_dfu - Device Firmware Update - +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU //========================================================== -// BLE_DFU_ENABLED - Enable DFU Service. +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. -#ifndef BLE_DFU_ENABLED -#define BLE_DFU_ENABLED 0 +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 #endif -// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS -#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif -// -//========================================================== +// // //========================================================== -// nRF_Drivers +// nRF_Crypto //========================================================== -// APP_USBD_ENABLED - app_usbd - USB Device library +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. //========================================================== -#ifndef APP_USBD_ENABLED -#define APP_USBD_ENABLED 0 +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 #endif -// APP_USBD_VID - Vendor ID <0x0000-0xFFFF> - +// NRF_CRYPTO_ALLOCATOR - Memory allocator + -// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) -#ifndef APP_USBD_VID -#define APP_USBD_VID 0 +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// APP_USBD_PID - Product ID <0x0000-0xFFFF> +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + -// Selected Product ID - -#ifndef APP_USBD_PID -#define APP_USBD_PID 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// APP_USBD_DEVICE_VER_MAJOR - Device version, major part <0-99> +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + -// Device version, will be converted automatically to BCD notation. Use just decimal values. +// CC310_BL backend implementation for hardware-accelerated SHA-256. -#ifndef APP_USBD_DEVICE_VER_MAJOR -#define APP_USBD_DEVICE_VER_MAJOR 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// APP_USBD_DEVICE_VER_MINOR - Device version, minor part <0-99> - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + -// Device version, will be converted automatically to BCD notation. Use just decimal values. +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#ifndef APP_USBD_DEVICE_VER_MINOR -#define APP_USBD_DEVICE_VER_MINOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// APP_USBD_EVENT_QUEUE_ENABLE - Enable event queue +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -// This is the default configuration when all the events are placed into internal queue. -// Disable it when external queue is used like app_scheduler or if you wish to process all events inside interrupts. -// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. -// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable and disable. -//========================================================== -#ifndef APP_USBD_EVENT_QUEUE_ENABLE -#define APP_USBD_EVENT_QUEUE_ENABLE 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// APP_USBD_EVENT_QUEUE_SIZE - The size of event queue <16-64> +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + -// The size of the queue for the events that would be processed in the main loop. +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used -#ifndef APP_USBD_EVENT_QUEUE_SIZE -#define APP_USBD_EVENT_QUEUE_SIZE 32 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif // -// APP_USBD_CONFIG_PROVIDE_SOF_TIMESTAMP - Provide a function that generates timestamps for logs based on the current SOF - - -// The function app_usbd_sof_timestamp_get will be implemented if the logger is enabled. -// Use it when initializing the logger. -// SOF processing will be always enabled when this configuration parameter is active. -// Notice that this option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. -// This means that it will work even if the logging in this very module is disabled. - -#ifndef APP_USBD_CONFIG_PROVIDE_SOF_TIMESTAMP -#define APP_USBD_CONFIG_PROVIDE_SOF_TIMESTAMP 0 -#endif +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. -// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef APP_USBD_CONFIG_LOG_ENABLED -#define APP_USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef APP_USBD_CONFIG_LOG_LEVEL -#define APP_USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef APP_USBD_CONFIG_INFO_COLOR -#define APP_USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 #endif -// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef APP_USBD_CONFIG_DEBUG_COLOR -#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + -// +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + -// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver -//========================================================== -#ifndef COMP_ENABLED -#define COMP_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// COMP_CONFIG_REF - Reference voltage + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -// <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 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// COMP_CONFIG_MAIN_MODE - Main mode +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. -// <0=> Single ended -// <1=> Differential -#ifndef COMP_CONFIG_MAIN_MODE -#define COMP_CONFIG_MAIN_MODE 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// COMP_CONFIG_SPEED_MODE - Speed mode +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -// <0=> Low power -// <1=> Normal -// <2=> High speed -#ifndef COMP_CONFIG_SPEED_MODE -#define COMP_CONFIG_SPEED_MODE 2 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// COMP_CONFIG_HYST - Hystheresis +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. -// <0=> No -// <1=> 50mV -#ifndef COMP_CONFIG_HYST -#define COMP_CONFIG_HYST 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// COMP_CONFIG_ISOURCE - Current Source +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -// <0=> Off -// <1=> 2.5 uA -// <2=> 5 uA -// <3=> 10 uA -#ifndef COMP_CONFIG_ISOURCE -#define COMP_CONFIG_ISOURCE 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// COMP_CONFIG_INPUT - Analog input +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. -// <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 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif -#ifndef COMP_CONFIG_IRQ_PRIORITY -#define COMP_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif -// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. -#ifndef EGU_ENABLED -#define EGU_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// 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 6 + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality -// 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 +// CC310 backend implementation for SHA-512 (in software). -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + -// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver -//========================================================== -#ifndef I2S_ENABLED -#define I2S_ENABLED 0 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// I2S_CONFIG_SCK_PIN - SCK pin <0-31> +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + -#ifndef I2S_CONFIG_SCK_PIN -#define I2S_CONFIG_SCK_PIN 31 +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 #endif -// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif -#ifndef I2S_CONFIG_LRCK_PIN -#define I2S_CONFIG_LRCK_PIN 30 +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 #endif -// I2S_CONFIG_MCK_PIN - MCK pin -#ifndef I2S_CONFIG_MCK_PIN -#define I2S_CONFIG_MCK_PIN 255 +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 #endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + -// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif +// -#ifndef I2S_CONFIG_SDOUT_PIN -#define I2S_CONFIG_SDOUT_PIN 29 +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 #endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + -// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + -#ifndef I2S_CONFIG_SDIN_PIN -#define I2S_CONFIG_SDIN_PIN 28 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// I2S_CONFIG_MASTER - Mode +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. -// <0=> Master -// <1=> Slave -#ifndef I2S_CONFIG_MASTER -#define I2S_CONFIG_MASTER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// I2S_CONFIG_FORMAT - Format +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. -// <0=> I2S -// <1=> Aligned -#ifndef I2S_CONFIG_FORMAT -#define I2S_CONFIG_FORMAT 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 #endif -// I2S_CONFIG_ALIGN - Alignment +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. -// <0=> Left -// <1=> Right -#ifndef I2S_CONFIG_ALIGN -#define I2S_CONFIG_ALIGN 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 #endif -// I2S_CONFIG_SWIDTH - Sample width (bits) +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. -// <0=> 8 -// <1=> 16 -// <2=> 24 -#ifndef I2S_CONFIG_SWIDTH -#define I2S_CONFIG_SWIDTH 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 #endif -// I2S_CONFIG_CHANNELS - Channels +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. -// <0=> Stereo -// <1=> Left -// <2=> Right -#ifndef I2S_CONFIG_CHANNELS -#define I2S_CONFIG_CHANNELS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 #endif -// I2S_CONFIG_MCK_SETUP - MCK behavior +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. -// <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 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 #endif -// I2S_CONFIG_RATIO - MCK/LRCK ratio +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -// <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 +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 #endif -// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -// 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 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS -#ifndef I2S_CONFIG_IRQ_PRIORITY -#define I2S_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + -// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver -//========================================================== -#ifndef LPCOMP_ENABLED -#define LPCOMP_ENABLED 0 +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 #endif -// LPCOMP_CONFIG_REFERENCE - Reference voltage + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve -// <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 +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 #endif -// LPCOMP_CONFIG_DETECTION - Detection +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve -// <0=> Crossing -// <1=> Up -// <2=> Down -#ifndef LPCOMP_CONFIG_DETECTION -#define LPCOMP_CONFIG_DETECTION 2 +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 #endif -// LPCOMP_CONFIG_INPUT - Analog input +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve -// <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 +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 #endif -// LPCOMP_CONFIG_HYST - Hysteresis +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve -#ifndef LPCOMP_CONFIG_HYST -#define LPCOMP_CONFIG_HYST 0 +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 #endif -// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve -// 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 +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS -#ifndef LPCOMP_CONFIG_IRQ_PRIORITY -#define LPCOMP_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 #endif -// - -// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver -//========================================================== -#ifndef PDM_ENABLED -#define PDM_ENABLED 0 -#endif -// PDM_CONFIG_MODE - Mode +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve -// <0=> Stereo -// <1=> Mono -#ifndef PDM_CONFIG_MODE -#define PDM_CONFIG_MODE 1 +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 #endif -// PDM_CONFIG_EDGE - Edge +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve -// <0=> Left falling -// <1=> Left rising -#ifndef PDM_CONFIG_EDGE -#define PDM_CONFIG_EDGE 0 +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 #endif -// PDM_CONFIG_CLOCK_FREQ - Clock frequency +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve -// <134217728=> 1000k -// <138412032=> 1032k (default) -// <142606336=> 1067k -#ifndef PDM_CONFIG_CLOCK_FREQ -#define PDM_CONFIG_CLOCK_FREQ 138412032 +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 #endif -// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve -// 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 +// Enable this setting if you need Curve25519 support using MBEDTLS -#ifndef PDM_CONFIG_IRQ_PRIORITY -#define PDM_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 #endif -// - -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 -#endif +// mbed TLS backend implementation for SHA-256. -// POWER_ENABLED - nrf_drv_power - POWER peripheral driver -//========================================================== -#ifndef POWER_ENABLED -#define POWER_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 #endif -// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. -// 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 +// mbed TLS backend implementation for SHA-512. -#ifndef POWER_CONFIG_IRQ_PRIORITY -#define POWER_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 #endif -// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. -// This settings means only that components for DCDC regulator are installed and it can be enabled. +// mbed TLS backend implementation for HMAC using SHA-256. -#ifndef POWER_CONFIG_DEFAULT_DCDCEN -#define POWER_CONFIG_DEFAULT_DCDCEN 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 #endif -// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. -// This settings means only that components for DCDC regulator are installed and it can be enabled. +// mbed TLS backend implementation for HMAC using SHA-512. -#ifndef POWER_CONFIG_DEFAULT_DCDCENHV -#define POWER_CONFIG_DEFAULT_DCDCENHV 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 #endif // -// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef PPI_ENABLED -#define PPI_ENABLED 0 -#endif +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc -// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver -//========================================================== -#ifndef PWM_ENABLED -#define PWM_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + -#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN -#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc -#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN -#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc -#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN -#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> +// +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. -#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN -#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 #endif - -// PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. -// <0=> 16 MHz -// <1=> 8 MHz -// <2=> 4 MHz -// <3=> 2 MHz -// <4=> 1 MHz -// <5=> 500 kHz -// <6=> 250 kHz -// <7=> 125 kHz -#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK -#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 #endif -// 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 +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 #endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + -// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value -#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE -#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. -// <0=> Common -// <1=> Grouped -// <2=> Individual -// <3=> Waveform -#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE -#define PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_STEP_MODE - Step mode +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve -// <0=> Auto -// <1=> Triggered -#ifndef PWM_DEFAULT_CONFIG_STEP_MODE -#define PWM_DEFAULT_CONFIG_STEP_MODE 0 +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 #endif -// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH -// 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 +// Enable this setting if you need Curve25519 ECDH support using Oberon library -#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY -#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 #endif -// PWM0_ENABLED - Enable PWM0 instance +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme -#ifndef PWM0_ENABLED -#define PWM0_ENABLED 0 +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 #endif -// PWM1_ENABLED - Enable PWM1 instance +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality -#ifndef PWM1_ENABLED -#define PWM1_ENABLED 0 +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 #endif -// PWM2_ENABLED - Enable PWM2 instance +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality -#ifndef PWM2_ENABLED -#define PWM2_ENABLED 0 +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 #endif -// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + -// The workaround uses interrupts to wake up the CPU and ensure -// it is active when PWM is about to start a DMA transfer. For -// initial transfer, done when a playback is started via PPI, -// a specific EGU instance is used to generate the interrupt. -// During the playback, the PWM interrupt triggered on SEQEND -// event of a preceding sequence is used to protect the transfer -// done for the next sequence to be played. -//========================================================== -#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 #endif -// PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 -// <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 +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 #endif // -// +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. -// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver +// Enables the nrf_crypto backend for Optiga Trust X devices. //========================================================== -#ifndef QDEC_ENABLED -#define QDEC_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 #endif -// QDEC_CONFIG_REPORTPER - Report period +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG -// <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 +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 #endif -// QDEC_CONFIG_SAMPLEPER - Sample period +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 -// <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 +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 #endif -// QDEC_CONFIG_PIO_A - A pin <0-31> +// +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + -#ifndef QDEC_CONFIG_PIO_A -#define QDEC_CONFIG_PIO_A 31 +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 #endif -// QDEC_CONFIG_PIO_B - B pin <0-31> +// +// +//========================================================== -#ifndef QDEC_CONFIG_PIO_B -#define QDEC_CONFIG_PIO_B 31 +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 #endif -// QDEC_CONFIG_PIO_LED - LED pin <0-31> +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif +// +//========================================================== -#ifndef QDEC_CONFIG_PIO_LED -#define QDEC_CONFIG_PIO_LED 31 +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 #endif +// COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef -// QDEC_CONFIG_LEDPRE - LED pre -#ifndef QDEC_CONFIG_LEDPRE -#define QDEC_CONFIG_LEDPRE 511 +#ifndef COMP_CONFIG_REF +#define COMP_CONFIG_REF 1 #endif -// QDEC_CONFIG_LEDPOL - LED polarity +// COMP_CONFIG_MAIN_MODE - Main mode -// <0=> Active low -// <1=> Active high +// <0=> Single ended +// <1=> Differential -#ifndef QDEC_CONFIG_LEDPOL -#define QDEC_CONFIG_LEDPOL 1 +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 #endif -// QDEC_CONFIG_DBFEN - Debouncing enable +// COMP_CONFIG_SPEED_MODE - Speed mode +// <0=> Low power +// <1=> Normal +// <2=> High speed -#ifndef QDEC_CONFIG_DBFEN -#define QDEC_CONFIG_DBFEN 0 +#ifndef COMP_CONFIG_SPEED_MODE +#define COMP_CONFIG_SPEED_MODE 2 #endif -// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable +// COMP_CONFIG_HYST - Hystheresis +// <0=> No +// <1=> 50mV -#ifndef QDEC_CONFIG_SAMPLE_INTEN -#define QDEC_CONFIG_SAMPLE_INTEN 0 +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 #endif -// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority +// COMP_CONFIG_ISOURCE - Current Source +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) +#ifndef COMP_CONFIG_ISOURCE +#define COMP_CONFIG_ISOURCE 0 +#endif + +// COMP_CONFIG_INPUT - Analog input + +// <0=> 0 // <1=> 1 // <2=> 2 // <3=> 3 @@ -1222,30 +1363,11 @@ // <6=> 6 // <7=> 7 -#ifndef QDEC_CONFIG_IRQ_PRIORITY -#define QDEC_CONFIG_IRQ_PRIORITY 7 -#endif - -// - -// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver -//========================================================== -#ifndef RNG_ENABLED -#define RNG_ENABLED 0 -#endif -// RNG_CONFIG_ERROR_CORRECTION - Error correction - - -#ifndef RNG_CONFIG_ERROR_CORRECTION -#define RNG_CONFIG_ERROR_CORRECTION 0 -#endif - -// RNG_CONFIG_POOL_SIZE - Pool size -#ifndef RNG_CONFIG_POOL_SIZE -#define RNG_CONFIG_POOL_SIZE 32 +#ifndef COMP_CONFIG_INPUT +#define COMP_CONFIG_INPUT 0 #endif -// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice @@ -1258,32 +1380,30 @@ // <6=> 6 // <7=> 7 -#ifndef RNG_CONFIG_IRQ_PRIORITY -#define RNG_CONFIG_IRQ_PRIORITY 7 +#ifndef COMP_CONFIG_IRQ_PRIORITY +#define COMP_CONFIG_IRQ_PRIORITY 6 #endif // -// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver -//========================================================== -#ifndef RTC_ENABLED -#define RTC_ENABLED 0 -#endif -// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> - +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + -#ifndef RTC_DEFAULT_CONFIG_FREQUENCY -#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 #endif -// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering - - -#ifndef RTC_DEFAULT_CONFIG_RELIABLE -#define RTC_DEFAULT_CONFIG_RELIABLE 0 +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 +#endif +// 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 -// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice @@ -1296,195 +1416,271 @@ // <6=> 6 // <7=> 7 -#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY -#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef GPIOTE_CONFIG_IRQ_PRIORITY +#define GPIOTE_CONFIG_IRQ_PRIORITY 6 #endif -// RTC0_ENABLED - Enable RTC0 instance - +// -#ifndef RTC0_ENABLED -#define RTC0_ENABLED 0 +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 #endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> -// RTC1_ENABLED - Enable RTC1 instance - -#ifndef RTC1_ENABLED -#define RTC1_ENABLED 0 +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 #endif -// RTC2_ENABLED - Enable RTC2 instance - +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> -#ifndef RTC2_ENABLED -#define RTC2_ENABLED 0 + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 #endif -// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt -#ifndef NRF_MAXIMUM_LATENCY_US -#define NRF_MAXIMUM_LATENCY_US 2000 +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 #endif -// +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> -// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver -//========================================================== -#ifndef SAADC_ENABLED -#define SAADC_ENABLED 0 + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 #endif -// SAADC_CONFIG_RESOLUTION - Resolution - -// <0=> 8 bit -// <1=> 10 bit -// <2=> 12 bit -// <3=> 14 bit -#ifndef SAADC_CONFIG_RESOLUTION -#define SAADC_CONFIG_RESOLUTION 1 +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 #endif -// SAADC_CONFIG_OVERSAMPLE - Sample period +// I2S_CONFIG_MASTER - Mode -// <0=> Disabled -// <1=> 2x -// <2=> 4x -// <3=> 8x -// <4=> 16x -// <5=> 32x -// <6=> 64x -// <7=> 128x -// <8=> 256x +// <0=> Master +// <1=> Slave -#ifndef SAADC_CONFIG_OVERSAMPLE -#define SAADC_CONFIG_OVERSAMPLE 0 +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 #endif -// SAADC_CONFIG_LP_MODE - Enabling low power mode +// I2S_CONFIG_FORMAT - Format +// <0=> I2S +// <1=> Aligned -#ifndef SAADC_CONFIG_LP_MODE -#define SAADC_CONFIG_LP_MODE 0 +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 #endif -// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority +// I2S_CONFIG_ALIGN - Alignment +// <0=> Left +// <1=> Right -// 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 +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 #endif -// +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 -// SPIS_ENABLED - nrf_drv_spis - SPI Slave driver -//========================================================== -#ifndef SPIS_ENABLED -#define SPIS_ENABLED 0 +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 #endif -// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// I2S_CONFIG_CHANNELS - Channels +// <0=> Stereo +// <1=> Left +// <2=> Right -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 +#ifndef I2S_CONFIG_IRQ_PRIORITY +#define I2S_CONFIG_IRQ_PRIORITY 6 #endif -// SPIS_DEFAULT_MODE - Mode +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// I2S_CONFIG_LOG_LEVEL - Default Severity level -// <0=> MODE_0 -// <1=> MODE_1 -// <2=> MODE_2 -// <3=> MODE_3 +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef SPIS_DEFAULT_MODE -#define SPIS_DEFAULT_MODE 0 +#ifndef I2S_CONFIG_LOG_LEVEL +#define I2S_CONFIG_LOG_LEVEL 3 #endif -// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order +// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. -// <0=> MSB first -// <1=> LSB first +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef SPIS_DEFAULT_BIT_ORDER -#define SPIS_DEFAULT_BIT_ORDER 0 +#ifndef I2S_CONFIG_INFO_COLOR +#define I2S_CONFIG_INFO_COLOR 0 #endif -// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> - +// 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 SPIS_DEFAULT_DEF -#define SPIS_DEFAULT_DEF 255 +#ifndef I2S_CONFIG_DEBUG_COLOR +#define I2S_CONFIG_DEBUG_COLOR 0 #endif -// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> +// +// -#ifndef SPIS_DEFAULT_ORC -#define SPIS_DEFAULT_ORC 255 +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 #endif - -// SPIS0_ENABLED - Enable SPIS0 instance +// 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 SPIS0_ENABLED -#define SPIS0_ENABLED 0 +#ifndef LPCOMP_CONFIG_REFERENCE +#define LPCOMP_CONFIG_REFERENCE 3 #endif -// SPIS1_ENABLED - Enable SPIS1 instance +// LPCOMP_CONFIG_DETECTION - Detection +// <0=> Crossing +// <1=> Up +// <2=> Down -#ifndef SPIS1_ENABLED -#define SPIS1_ENABLED 0 +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 #endif -// SPIS2_ENABLED - Enable SPIS2 instance +// LPCOMP_CONFIG_INPUT - Analog input +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef SPIS2_ENABLED -#define SPIS2_ENABLED 0 +#ifndef LPCOMP_CONFIG_INPUT +#define LPCOMP_CONFIG_INPUT 0 #endif -// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. +// LPCOMP_CONFIG_HYST - Hysteresis -// The workaround uses a GPIOTE channel to generate interrupts -// on falling edges detected on the CSN line. This will make -// the CPU active for the moment when SPIS starts DMA transfers, -// and this way the transfers will be protected. -// This workaround uses GPIOTE driver, so this driver must be -// enabled as well. - -#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 #endif -// - -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 -#endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice @@ -1497,139 +1693,156 @@ // <6=> 6 // <7=> 7 -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef LPCOMP_CONFIG_IRQ_PRIORITY +#define LPCOMP_CONFIG_IRQ_PRIORITY 6 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY -2147483648 +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 #endif -// SPI0_ENABLED - Enable SPI0 instance +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 #endif -// +// NRFX_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 -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRFX_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 SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 #endif // -// SPI2_ENABLED - Enable SPI2 instance +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver //========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA +// NRFX_COMP_CONFIG_REF - Reference voltage +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 #endif -// - -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode +// <0=> Single ended +// <1=> Differential -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ - -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 #endif -// - -// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver -//========================================================== -#ifndef TIMER_ENABLED -#define TIMER_ENABLED 0 -#endif -// TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode +// NRFX_COMP_CONFIG_SPEED_MODE - Speed 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 +// <0=> Low power +// <1=> Normal +// <2=> High speed -#ifndef TIMER_DEFAULT_CONFIG_FREQUENCY -#define TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 #endif -// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation +// NRFX_COMP_CONFIG_HYST - Hystheresis -// <0=> Timer -// <1=> Counter +// <0=> No +// <1=> 50mV -#ifndef TIMER_DEFAULT_CONFIG_MODE -#define TIMER_DEFAULT_CONFIG_MODE 0 +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 #endif -// TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width +// NRFX_COMP_CONFIG_ISOURCE - Current Source -// <0=> 16 bit -// <1=> 8 bit -// <2=> 24 bit -// <3=> 32 bit +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA -#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH -#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 #endif -// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_COMP_CONFIG_INPUT - Analog input - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) +// <0=> 0 // <1=> 1 // <2=> 2 // <3=> 3 @@ -1638,86 +1851,90 @@ // <6=> 6 // <7=> 7 -#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY -#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 #endif -// TIMER0_ENABLED - Enable TIMER0 instance +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef TIMER0_ENABLED -#define TIMER0_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 #endif -// TIMER1_ENABLED - Enable TIMER1 instance - - -#ifndef TIMER1_ENABLED -#define TIMER1_ENABLED 0 +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 #endif - -// TIMER2_ENABLED - Enable TIMER2 instance +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef TIMER2_ENABLED -#define TIMER2_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 #endif -// TIMER3_ENABLED - Enable TIMER3 instance +// NRFX_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 TIMER3_ENABLED -#define TIMER3_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 #endif -// TIMER4_ENABLED - Enable TIMER4 instance +// NRFX_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 TIMER4_ENABLED -#define TIMER4_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver -//========================================================== -#ifndef TWIS_ENABLED -#define TWIS_ENABLED 0 -#endif -// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 -#ifndef TWIS_DEFAULT_CONFIG_ADDR0 -#define TWIS_DEFAULT_CONFIG_ADDR0 0 -#endif - -// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 -#ifndef TWIS_DEFAULT_CONFIG_ADDR1 -#define TWIS_DEFAULT_CONFIG_ADDR1 0 -#endif - -// 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 +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 #endif - -// 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 +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 #endif -// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -1727,183 +1944,192 @@ // <6=> 6 // <7=> 7 -#ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY -#define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 #endif -// TWIS0_ENABLED - Enable TWIS0 instance +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef TWIS0_ENABLED -#define TWIS0_ENABLED 0 +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 #endif -// TWIS1_ENABLED - Enable TWIS1 instance +// NRFX_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 TWIS1_ENABLED -#define TWIS1_ENABLED 0 +#ifndef NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 #endif -// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once +// NRFX_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 -// 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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif -#ifndef TWIS_ASSUME_INIT_AFTER_RESET_ONLY -#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 #endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> -// TWIS_NO_SYNC_MODE - Remove support for synchronous mode - -// 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 NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif -#ifndef TWIS_NO_SYNC_MODE -#define TWIS_NO_SYNC_MODE 0 +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 #endif -// +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif -// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver -//========================================================== -#ifndef TWI_ENABLED -#define TWI_ENABLED 1 +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 #endif -// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency - -// <26738688=> 100k -// <67108864=> 250k -// <104857600=> 400k -#ifndef TWI_DEFAULT_CONFIG_FREQUENCY -#define TWI_DEFAULT_CONFIG_FREQUENCY 104857600 +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 #endif -// TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init +// NRFX_I2S_CONFIG_MASTER - Mode +// <0=> Master +// <1=> Slave -#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT -#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 #endif -// TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit +// NRFX_I2S_CONFIG_FORMAT - Format +// <0=> I2S +// <1=> Aligned -#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT -#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 #endif -// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_I2S_CONFIG_ALIGN - Alignment +// <0=> Left +// <1=> Right -// 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 +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 #endif -// TWI0_ENABLED - Enable TWI0 instance -//========================================================== -#ifndef TWI0_ENABLED -#define TWI0_ENABLED 0 -#endif -// TWI0_USE_EASY_DMA - Use EasyDMA (if present) +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) +// <0=> 8 +// <1=> 16 +// <2=> 24 -#ifndef TWI0_USE_EASY_DMA -#define TWI0_USE_EASY_DMA 0 +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 #endif -// - -// TWI1_ENABLED - Enable TWI1 instance -//========================================================== -#ifndef TWI1_ENABLED -#define TWI1_ENABLED 0 -#endif -// TWI1_USE_EASY_DMA - Use EasyDMA (if present) - - -#ifndef TWI1_USE_EASY_DMA -#define TWI1_USE_EASY_DMA 0 -#endif - -// - -// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. +// NRFX_I2S_CONFIG_CHANNELS - Channels +// <0=> Stereo +// <1=> Left +// <2=> Right -// The workaround uses interrupts to wake up the CPU by catching -// the start event of zero-frequency transmission, clear the -// peripheral, set desired frequency, start the peripheral, and -// the proper transmission. See more in the Errata document or -// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ - -#ifndef TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 #endif -// - -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver -//========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 -#endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRFX_I2S_CONFIG_MCK_SETUP - MCK behavior // <0=> Disabled -// <1=> Enabled - -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 -#endif - -// UART_DEFAULT_CONFIG_PARITY - Parity - -// <0=> Excluded -// <14=> Included +// <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 UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRFX_I2S_CONFIG_RATIO - MCK/LRCK ratio -// <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=> 1000000 baud +// <0=> 32x +// <1=> 48x +// <2=> 64x +// <3=> 96x +// <4=> 128x +// <5=> 192x +// <6=> 256x +// <7=> 384x +// <8=> 512x -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#ifndef NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -1913,50 +2139,105 @@ // <6=> 6 // <7=> 7 -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRFX_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 UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +#ifndef NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 #endif -// UART0_ENABLED - Enable UART0 instance -//========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 -#endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRFX_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 UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 0 +#ifndef NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 #endif // // -// USBD_ENABLED - nrf_drv_usbd - USB driver +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver //========================================================== -#ifndef USBD_ENABLED -#define USBD_ENABLED 0 +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 #endif -// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_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 -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) +#ifndef NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 // <1=> 1 // <2=> 2 // <3=> 3 @@ -1965,48 +2246,92 @@ // <6=> 6 // <7=> 7 -#ifndef USBD_CONFIG_IRQ_PRIORITY -#define USBD_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 #endif -// NRF_DRV_USBD_DMASCHEDULER_MODE - USBD SMA scheduler working scheme +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis -// <0=> Prioritized access -// <1=> Round Robin -#ifndef NRF_DRV_USBD_DMASCHEDULER_MODE -#define NRF_DRV_USBD_DMASCHEDULER_MODE 0 +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 #endif -// +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif -// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_ENABLED -#define WDT_ENABLED 0 +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level -// <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 +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef WDT_CONFIG_BEHAVIOUR -#define WDT_CONFIG_BEHAVIOUR 1 +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> - +// NRFX_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 WDT_CONFIG_RELOAD_VALUE -#define WDT_CONFIG_RELOAD_VALUE 2000 +#ifndef NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_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 -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_NFCT_ENABLED - nrfx_nfct - NFCT peripheral driver +//========================================================== +#ifndef NRFX_NFCT_ENABLED +#define NRFX_NFCT_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2016,82 +2341,98 @@ // <6=> 6 // <7=> 7 -#ifndef WDT_CONFIG_IRQ_PRIORITY -#define WDT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_NFCT_CONFIG_IRQ_PRIORITY +#define NRFX_NFCT_CONFIG_IRQ_PRIORITY 6 #endif -// - -// -//========================================================== - -// nRF_Libraries - +// NRFX_NFCT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation - - -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +#ifndef NRFX_NFCT_CONFIG_LOG_ENABLED +#define NRFX_NFCT_CONFIG_LOG_ENABLED 0 #endif - -// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher +// NRFX_NFCT_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_GPIOTE_ENABLED -#define APP_GPIOTE_ENABLED 0 +#ifndef NRFX_NFCT_CONFIG_LOG_LEVEL +#define NRFX_NFCT_CONFIG_LOG_LEVEL 3 #endif -// APP_PWM_ENABLED - app_pwm - PWM functionality - - -#ifndef APP_PWM_ENABLED -#define APP_PWM_ENABLED 0 -#endif - -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler -//========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 1 -#endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature +// NRFX_NFCT_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 APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 +#ifndef NRFX_NFCT_CONFIG_INFO_COLOR +#define NRFX_NFCT_CONFIG_INFO_COLOR 0 #endif -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling +// NRFX_NFCT_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 APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 +#ifndef NRFX_NFCT_CONFIG_DEBUG_COLOR +#define NRFX_NFCT_CONFIG_DEBUG_COLOR 0 #endif // -// APP_TIMER_ENABLED - app_timer - Application timer functionality +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver //========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 1 +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 #endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. +// NRFX_PDM_CONFIG_MODE - Mode -// <0=> 32768 Hz -// <1=> 16384 Hz -// <3=> 8192 Hz -// <7=> 4096 Hz -// <15=> 2048 Hz -// <31=> 1024 Hz +// <0=> Stereo +// <1=> Mono -#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY -#define APP_TIMER_CONFIG_RTC_FREQUENCY 31 +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 #endif -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_PDM_CONFIG_EDGE - Edge +// <0=> Left falling +// <1=> Left rising -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2101,500 +2442,751 @@ // <6=> 6 // <7=> 7 -#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY -#define APP_TIMER_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 #endif -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 15 +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 #endif -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler +// NRFX_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 APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 1 +#ifndef NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 #endif -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 0 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 #endif -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator -// If option is enabled RTC is kept running even if there is no active timers. -// This option can be used when app_timer is used for timestamping. +// This settings means only that components for DCDC regulator are installed and it can be enabled. -#ifndef APP_TIMER_KEEPS_RTC_ACTIVE -#define APP_TIMER_KEEPS_RTC_ACTIVE 0 +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 #endif -// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator -// <0=> 0 -// <1=> 1 -#ifndef APP_TIMER_CONFIG_SWI_NUMBER -#define APP_TIMER_CONFIG_SWI_NUMBER 0 +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 #endif // -// APP_TWI_ENABLED - app_twi - TWI transaction manager wrapper. Switch to nrf_twi_mngr usage. +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_TWI_ENABLED -#define APP_TWI_ENABLED 0 +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 #endif -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 #endif -// APP_UART_DRIVER_INSTANCE - UART instance used + +// NRFX_PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. -// <0=> 0 +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +#ifndef NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_CLASS_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. -#ifndef APP_USBD_CLASS_AUDIO_ENABLED -#define APP_USBD_CLASS_AUDIO_ENABLED 0 +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 0 #endif -// APP_USBD_CLASS_CDC_ACM_ENABLED - app_usbd_cdc_acm - USB CDC ACM class +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. -#ifndef APP_USBD_CLASS_CDC_ACM_ENABLED -#define APP_USBD_CLASS_CDC_ACM_ENABLED 0 +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 0 #endif -// APP_USBD_CLASS_HID_ENABLED - app_usbd_hid - USB HID class +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. -#ifndef APP_USBD_CLASS_HID_ENABLED -#define APP_USBD_CLASS_HID_ENABLED 0 +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 0 #endif -// APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. -#ifndef APP_USBD_HID_GENERIC_ENABLED -#define APP_USBD_HID_GENERIC_ENABLED 0 +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 0 #endif -// APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. -#ifndef APP_USBD_HID_KBD_ENABLED -#define APP_USBD_HID_KBD_ENABLED 0 +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 #endif -// APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_USBD_HID_MOUSE_ENABLED -#define APP_USBD_HID_MOUSE_ENABLED 0 +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class +// NRFX_PRS_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 APP_USBD_MSC_ENABLED -#define APP_USBD_MSC_ENABLED 0 +#ifndef NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 #endif -// BUTTON_ENABLED - app_button - buttons handling module +// NRFX_PRS_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 BUTTON_ENABLED -#define BUTTON_ENABLED 1 +#ifndef NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 #endif -// CRC16_ENABLED - crc16 - CRC16 calculation routines +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance -#ifndef CRC16_ENABLED -#define CRC16_ENABLED 1 +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 #endif -// CRC32_ENABLED - crc32 - CRC32 calculation routines +// NRFX_PWM1_ENABLED - Enable PWM1 instance -#ifndef CRC32_ENABLED -#define CRC32_ENABLED 0 +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 0 #endif -// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library +// NRFX_PWM2_ENABLED - Enable PWM2 instance -#ifndef ECC_ENABLED -#define ECC_ENABLED 0 +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 0 #endif -// FDS_ENABLED - fds - Flash data storage module -//========================================================== -#ifndef FDS_ENABLED -#define FDS_ENABLED 1 -#endif -// Pages - Virtual page settings +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> -// Configure the number of virtual pages to use and their size. -//========================================================== -// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. -// One of the virtual pages is reserved by the system for garbage collection. -// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. -// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. -#ifndef FDS_VIRTUAL_PAGES -#define FDS_VIRTUAL_PAGES 6 +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 #endif -// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. - +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> -// Expressed in number of 4-byte words. -// By default, a virtual page is the same size as a physical page. -// 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 +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 #endif -// -//========================================================== +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> -// Backend - Backend configuration -// Configure which nrf_fstorage backend is used by FDS to write to flash. -//========================================================== -// FDS_BACKEND - FDS flash backend. - +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif -// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. -// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. -// <1=> NRF_FSTORAGE_NVMC -// <2=> NRF_FSTORAGE_SD +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> -#ifndef FDS_BACKEND -#define FDS_BACKEND 2 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 #endif -// -//========================================================== +// NRFX_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 kHz -// Queue - Queue settings +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif -//========================================================== -// FDS_OP_QUEUE_SIZE - Size of the internal queue. -// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down -#ifndef FDS_OP_QUEUE_SIZE -#define FDS_OP_QUEUE_SIZE 6 +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 #endif -// -//========================================================== - -// CRC - CRC functionality +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif -//========================================================== -// FDS_CRC_CHECK_ON_READ - Enable CRC checks. +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform -// Save a record's CRC when it is written to flash and check it when the record is opened. -// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. -// Additionally, they will not be garbage collected until they are deleted. -//========================================================== -#ifndef FDS_CRC_CHECK_ON_READ -#define FDS_CRC_CHECK_ON_READ 0 +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 #endif -// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. - -// Perform a CRC check on newly written records. -// This setting can be used to make sure that the record data was not altered while being written to flash. -// <1=> Enabled -// <0=> Disabled +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered -#ifndef FDS_CRC_CHECK_ON_WRITE -#define FDS_CRC_CHECK_ON_WRITE 0 +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 #endif -// - -// -//========================================================== +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -// Users - Number of users +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// FDS_MAX_USERS - Maximum number of callbacks that can be registered. -#ifndef FDS_MAX_USERS -#define FDS_MAX_USERS 4 +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 #endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// -//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif -// +// NRFX_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 -// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release -//========================================================== -#ifndef HARDFAULT_HANDLER_ENABLED -#define HARDFAULT_HANDLER_ENABLED 0 +#ifndef NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 #endif -// HARDFAULT_HANDLER_GDB_PSP_BACKTRACE - Bypass the GDB problem with multiple stack pointers backtrace - -// There is a known bug in GDB which causes it to incorrectly backtrace the code -// when multiple stack pointers are used (main and process stack pointers). -// This option enables the fix for that problem and allows to see the proper backtrace info. -// It makes it possible to trace the code to the exact point where a HardFault appeared. -// This option requires additional commands and may temporarily switch MSP stack to store data on PSP space. -// This is an optional parameter - enable it while debugging. -// Before a HardFault handler exits, the stack will be reverted to its previous value. +// NRFX_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 HARDFAULT_HANDLER_GDB_PSP_BACKTRACE -#define HARDFAULT_HANDLER_GDB_PSP_BACKTRACE 1 +#ifndef NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 #endif // -// HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. //========================================================== -#ifndef HCI_MEM_POOL_ENABLED -#define HCI_MEM_POOL_ENABLED 0 -#endif -// HCI_TX_BUF_SIZE - TX buffer size in bytes. -#ifndef HCI_TX_BUF_SIZE -#define HCI_TX_BUF_SIZE 600 +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 #endif +// NRFX_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 -// HCI_RX_BUF_SIZE - RX buffer size in bytes. -#ifndef HCI_RX_BUF_SIZE -#define HCI_RX_BUF_SIZE 600 +#ifndef NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 #endif -// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. -#ifndef HCI_RX_BUF_QUEUE_SIZE -#define HCI_RX_BUF_QUEUE_SIZE 4 -#endif +// // -// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver //========================================================== -#ifndef HCI_SLIP_ENABLED -#define HCI_SLIP_ENABLED 0 +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 #endif -// HCI_UART_BAUDRATE - Default Baudrate +// NRFX_QDEC_CONFIG_REPORTPER - Report period -// <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=> 1000000 baud +// <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 HCI_UART_BAUDRATE -#define HCI_UART_BAUDRATE 30801920 +#ifndef NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 #endif -// HCI_UART_FLOW_CONTROL - Hardware Flow Control +// NRFX_QDEC_CONFIG_SAMPLEPER - Sample period -// <0=> Disabled -// <1=> Enabled +// <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 HCI_UART_FLOW_CONTROL -#define HCI_UART_FLOW_CONTROL 0 +#ifndef NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 #endif -// HCI_UART_RX_PIN - UART RX pin -#ifndef HCI_UART_RX_PIN -#define HCI_UART_RX_PIN 8 +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 #endif -// HCI_UART_TX_PIN - UART TX pin -#ifndef HCI_UART_TX_PIN -#define HCI_UART_TX_PIN 6 +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 #endif -// HCI_UART_RTS_PIN - UART RTS pin -#ifndef HCI_UART_RTS_PIN -#define HCI_UART_RTS_PIN 5 +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 #endif -// HCI_UART_CTS_PIN - UART CTS pin -#ifndef HCI_UART_CTS_PIN -#define HCI_UART_CTS_PIN 7 +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 #endif -// +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high -// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport -//========================================================== -#ifndef HCI_TRANSPORT_ENABLED -#define HCI_TRANSPORT_ENABLED 0 -#endif -// 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 +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 #endif -// +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + -// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable -#ifndef LED_SOFTBLINK_ENABLED -#define LED_SOFTBLINK_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 #endif -// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef LOW_POWER_PWM_ENABLED -#define LOW_POWER_PWM_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 #endif -// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef MEM_MANAGER_ENABLED -#define MEM_MANAGER_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 #endif -// MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block. <0-255> - +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT -#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1 +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 #endif -// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. -// Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized. +// NRFX_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 MEMORY_MANAGER_SMALL_BLOCK_SIZE -#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32 +#ifndef NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 #endif -// MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> - +// NRFX_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 MEMORY_MANAGER_MEDIUM_BLOCK_COUNT -#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 +#ifndef NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 #endif -// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. -// 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 +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 #endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + -// MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block. <0-255> +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT -#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0 +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 #endif -// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. -// 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 +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 #endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block. <0-255> +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif +// NRFX_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 MEMORY_MANAGER_XLARGE_BLOCK_COUNT -#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0 +#ifndef NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 #endif -// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. -// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. +// NRFX_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 MEMORY_MANAGER_XLARGE_BLOCK_SIZE -#define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 1320 +#ifndef NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 #endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + -// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. -// Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized. +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif -#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE -#define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 3444 +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 #endif -// MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block. <0-255> +// NRFX_RTC2_ENABLED - Enable RTC2 instance + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 0 +#endif -#ifndef MEMORY_MANAGER_XSMALL_BLOCK_COUNT -#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0 +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 #endif -// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. -// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> -#ifndef MEMORY_MANAGER_XSMALL_BLOCK_SIZE -#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64 -#endif -// MEMORY_MANAGER_XXSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra small' block. <0-255> +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + -#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_COUNT -#define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 0 +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 #endif -// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. -// Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized. +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE -#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32 +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED -#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 #endif -// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2602,11 +3194,11 @@ // <3=> Info // <4=> Debug -#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL -#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 #endif -// MEM_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRFX_RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2618,11 +3210,11 @@ // <7=> Cyan // <8=> White -#ifndef MEM_MANAGER_CONFIG_INFO_COLOR -#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 #endif -// MEM_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRFX_RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2634,508 +3226,5508 @@ // <7=> Cyan // <8=> White -#ifndef MEM_MANAGER_CONFIG_DEBUG_COLOR -#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 #endif // -// 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 - // -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver //========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRFX_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 NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#ifndef NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRFX_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 NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 #endif // // -// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver //========================================================== -#ifndef NRF_CSENSE_ENABLED -#define NRF_CSENSE_ENABLED 0 -#endif -// 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 - -// 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 +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 #endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + -// 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 +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 #endif -// 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 +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + -// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. -#ifndef NRF_CSENSE_MAX_VALUE -#define NRF_CSENSE_MAX_VALUE 1000 +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 #endif -// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. -// This is used when capacitive sensor does not use COMP. +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + -#ifndef NRF_CSENSE_OUTPUT_PIN -#define NRF_CSENSE_OUTPUT_PIN 26 +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 #endif -// +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP -// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module -//========================================================== -#ifndef NRF_DRV_CSENSE_ENABLED -#define NRF_DRV_CSENSE_ENABLED 0 +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 #endif -// USE_COMP - Use the comparator to implement the capacitive sensor driver. -// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. -//========================================================== -#ifndef USE_COMP -#define USE_COMP 0 -#endif -// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). -#ifndef TIMER0_FOR_CSENSE -#define TIMER0_FOR_CSENSE 1 +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). -#ifndef TIMER1_FOR_CSENSE -#define TIMER1_FOR_CSENSE 2 +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 #endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// MEASUREMENT_PERIOD - Single measurement period. -// Time of a single measurement can be calculated as -// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). -// I_SOURCE, VUP, and VDOWN are values used to initialize COMP and C is the capacitance of the used pad. +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif -#ifndef MEASUREMENT_PERIOD -#define MEASUREMENT_PERIOD 20 +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 #endif -// +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif // -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 -#endif +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ -// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library -//========================================================== -#ifndef NRF_FSTORAGE_ENABLED -#define NRF_FSTORAGE_ENABLED 1 +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 #endif -// nrf_fstorage_sd - Implementation using the SoftDevice. -// Configuration options for the fstorage implementation using the SoftDevice. -//========================================================== -// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations. -// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. +// -#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE -#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 #endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + -// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy. -// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. -// The SoftDevice might fail to schedule flash access due to high BLE activity. - -#ifndef NRF_FSTORAGE_SD_MAX_RETRIES -#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 #endif -// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation. -// This value must be a multiple of four. -// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. -// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. -// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + -#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE -#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 #endif -// -//========================================================== +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + -// +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 0 +#endif -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module -//========================================================== -#ifndef NRF_PWR_MGMT_ENABLED -#define NRF_PWR_MGMT_ENABLED 1 -#endif -// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> -// Selected pin will be set when CPU is in sleep mode. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED -#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 -#endif -// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number - -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <4294967295=> Not connected -#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN -#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 #endif -// - -// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. - +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> -// Module will trace percentage of CPU usage in one second intervals. -#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED -#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). -// Shutdown procedure will begin no earlier than after this number of seconds. +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 #endif -// - -// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. +// NRFX_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 NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED -#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#ifndef NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 #endif -// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. +// NRFX_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 NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY -#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#ifndef NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 #endif -// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. - +// -#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER -#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 -#endif +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + -// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. -// The number of stages of the shutdown process. +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. -#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT -#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 #endif // -// NRF_QUEUE_ENABLED - nrf_queue - Queue module +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance -#ifndef NRF_QUEUE_ENABLED -#define NRF_QUEUE_ENABLED 0 +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 #endif -// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator +// NRFX_SPI1_ENABLED - Enable SPI1 instance -#ifndef NRF_SECTION_ITER_ENABLED -#define NRF_SECTION_ITER_ENABLED 1 +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// NRFX_SPI2_ENABLED - Enable SPI2 instance -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 #endif -// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_TWI_MNGR_ENABLED -#define NRF_TWI_MNGR_ENABLED 0 +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 #endif -// SLIP_ENABLED - slip - SLIP encoding and decoding +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef SLIP_ENABLED -#define SLIP_ENABLED 0 +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// nrf_cli - Command line interface - +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_CLI_ENABLED - Enable/disable the CLI module. - - -#ifndef NRF_CLI_ENABLED -#define NRF_CLI_ENABLED 0 +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 #endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. -#ifndef NRF_CLI_ARGC_MAX -#define NRF_CLI_ARGC_MAX 12 +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. +// NRFX_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 NRF_CLI_BUILD_IN_CMDS_ENABLED -#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#ifndef NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. -#ifndef NRF_CLI_CMD_BUFF_SIZE -#define NRF_CLI_CMD_BUFF_SIZE 128 +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 #endif -// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support -#ifndef NRF_CLI_ECHO_STATUS -#define NRF_CLI_ECHO_STATUS 1 +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 #endif -// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. -#ifndef NRF_CLI_PRINTF_BUFF_SIZE -#define NRF_CLI_PRINTF_BUFF_SIZE 23 +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 #endif -// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_HISTORY_ENABLED -#define NRF_CLI_HISTORY_ENABLED 1 +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. -#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE -#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. -#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT -#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance -#ifndef NRF_CLI_VT100_COLORS_ENABLED -#define NRF_CLI_VT100_COLORS_ENABLED 1 +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 #endif -// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance -#ifndef NRF_CLI_STATISTICS_ENABLED -#define NRF_CLI_STATISTICS_ENABLED 1 +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 #endif -// NRF_CLI_LOG_BACKEND - Enable logger backend interface. +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance -#ifndef NRF_CLI_LOG_BACKEND -#define NRF_CLI_LOG_BACKEND 1 +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 #endif -// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance -#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED -#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 0 #endif -// -//========================================================== +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + -// -//========================================================== +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 0 +#endif -// nRF_Log +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend -//========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 6 +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance -// <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=> 1000000 baud -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 0 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 0 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 0 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// nrfx_qspi - QSPI peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_usbd - USBD peripheral driver + +//========================================================== +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 1 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> + + +// Major 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 + +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> + + +// Minor 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 + +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// 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 + +// 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 + +// 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 + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 1 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 1 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// - -// nrf_log - Logger - -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 1 -#endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3147,11 +8739,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3163,11 +8774,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3179,13 +8790,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3193,110 +8809,101 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// 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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// 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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// TWI_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// 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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// 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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 -#endif - -// Log message pool - Configuration of log message pool - -//========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. - -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 -#endif - -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. - -#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif -// -//========================================================== - // -// nrf_log module configuration - -//========================================================== -// nrf_log in nRF_Core - -//========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3304,11 +8911,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3320,11 +8927,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3336,18 +8943,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3355,11 +8962,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3371,11 +8978,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3387,18 +8994,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3406,11 +9013,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3422,11 +9029,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3438,8 +9045,8 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif // @@ -3447,15 +9054,15 @@ // //========================================================== -// nrf_log in nRF_Drivers +// nrf_log in nRF_Libraries //========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3463,11 +9070,27 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3479,11 +9102,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3495,30 +9118,46 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. // <0=> Off // <1=> Error // <2=> Warning // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3530,11 +9169,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3546,18 +9185,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3565,11 +9204,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3581,11 +9220,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3597,18 +9236,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3616,11 +9255,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3632,11 +9271,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3648,18 +9287,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3667,11 +9306,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3683,11 +9322,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3699,18 +9338,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3718,11 +9357,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3734,11 +9373,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3750,18 +9389,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3769,11 +9408,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3785,11 +9424,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3801,18 +9440,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3820,11 +9459,23 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3836,11 +9487,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3852,18 +9503,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3871,11 +9522,27 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3887,11 +9554,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3903,18 +9570,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3922,11 +9589,23 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3938,11 +9617,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3954,18 +9633,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -3973,11 +9652,23 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -3989,11 +9680,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4005,25 +9696,18 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 -#endif - -// 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 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4031,11 +9715,23 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4047,11 +9743,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4063,18 +9759,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4082,11 +9778,11 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4098,11 +9794,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4114,18 +9810,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4133,11 +9829,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4149,11 +9845,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4165,18 +9861,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4184,11 +9880,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 2 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4200,11 +9896,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4216,18 +9912,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4235,11 +9931,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4251,11 +9947,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4267,18 +9963,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4286,11 +9982,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 3 +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_MEMOBJ_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4302,11 +9998,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_MEMOBJ_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4318,18 +10014,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4337,11 +10033,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_PWR_MGMT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4353,11 +10049,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_PWR_MGMT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4369,18 +10065,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4388,11 +10084,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4404,11 +10112,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_QUEUE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4420,18 +10128,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4439,11 +10147,11 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4455,11 +10163,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4471,18 +10179,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4490,11 +10198,11 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4506,11 +10214,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4522,18 +10230,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_SDH_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4541,11 +10249,11 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_SDH_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4557,11 +10265,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_SDH_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4573,24 +10281,18 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4598,11 +10300,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4614,11 +10316,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_SDH_SOC_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4630,18 +10332,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4649,11 +10351,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_SORTLIST_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4665,11 +10367,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_SORTLIST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4681,18 +10383,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4700,11 +10402,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_TWI_SENSOR_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4716,11 +10418,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4732,18 +10434,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// PM_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4751,11 +10453,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PM_LOG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4767,11 +10469,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PM_LOG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4783,18 +10485,24 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4802,11 +10510,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SER_HAL_TRANSPORT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4818,11 +10526,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4834,18 +10542,81 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +// //========================================================== -#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED -#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 #endif -// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// +//========================================================== + +// nRF_NFC + +//========================================================== +// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder + + +#ifndef NFC_AC_REC_ENABLED +#define NFC_AC_REC_ENABLED 0 +#endif + +// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser + + +#ifndef NFC_AC_REC_PARSER_ENABLED +#define NFC_AC_REC_PARSER_ENABLED 0 +#endif + +// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder +//========================================================== +#ifndef NFC_BLE_OOB_ADVDATA_ENABLED +#define NFC_BLE_OOB_ADVDATA_ENABLED 0 +#endif +// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) + +// <1=> Enabled +// <0=> Disabled + +#ifndef ADVANCED_ADVDATA_SUPPORT +#define ADVANCED_ADVDATA_SUPPORT 0 +#endif + +// + +// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser + + +#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED +#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 +#endif + +// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_ENABLED +#define NFC_BLE_PAIR_LIB_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED +#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4853,11 +10624,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL -#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL +#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 #endif -// NRF_MEMOBJ_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NFC_BLE_PAIR_LIB_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4869,11 +10640,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MEMOBJ_CONFIG_INFO_COLOR -#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#ifndef NFC_BLE_PAIR_LIB_INFO_COLOR +#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 #endif -// NRF_MEMOBJ_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NFC_BLE_PAIR_LIB_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4885,18 +10656,174 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MEMOBJ_CONFIG_DEBUG_COLOR -#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#ifndef NFC_BLE_PAIR_LIB_DEBUG_COLOR +#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 #endif // -// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. + //========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED -#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. + +// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +//========================================================== +#ifndef BLE_NFC_SEC_PARAM_BOND +#define BLE_NFC_SEC_PARAM_BOND 1 #endif -// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level +// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#endif + +// + +// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#endif + +// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#endif + +// +//========================================================== + +// + +// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder + + +#ifndef NFC_BLE_PAIR_MSG_ENABLED +#define NFC_BLE_PAIR_MSG_ENABLED 0 +#endif + +// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data + + +#ifndef NFC_CH_COMMON_ENABLED +#define NFC_CH_COMMON_ENABLED 0 +#endif + +// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder + + +#ifndef NFC_EP_OOB_REC_ENABLED +#define NFC_EP_OOB_REC_ENABLED 0 +#endif + +// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder + + +#ifndef NFC_HS_REC_ENABLED +#define NFC_HS_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder + + +#ifndef NFC_LE_OOB_REC_ENABLED +#define NFC_LE_OOB_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser + + +#ifndef NFC_LE_OOB_REC_PARSER_ENABLED +#define NFC_LE_OOB_REC_PARSER_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED +#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED +#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 +#endif + +// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module +//========================================================== +#ifndef NFC_NDEF_MSG_ENABLED +#define NFC_NDEF_MSG_ENABLED 0 +#endif +// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type + +// <2=> Type 2 Tag +// <4=> Type 4 Tag + +#ifndef NFC_NDEF_MSG_TAG_TYPE +#define NFC_NDEF_MSG_TAG_TYPE 2 +#endif + +// + +// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_ENABLED +#define NFC_NDEF_MSG_PARSER_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED +#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4904,11 +10831,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL -#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL +#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 #endif -// NRF_PWR_MGMT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NFC_NDEF_MSG_PARSER_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4920,11 +10847,44 @@ // <7=> Cyan // <8=> White -#ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR -#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#ifndef NFC_NDEF_MSG_PARSER_INFO_COLOR +#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 #endif -// NRF_PWR_MGMT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// + +// + +// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module + + +#ifndef NFC_NDEF_RECORD_ENABLED +#define NFC_NDEF_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_ENABLED +#define NFC_NDEF_RECORD_PARSER_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED +#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL +#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_RECORD_PARSER_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4936,18 +10896,46 @@ // <7=> Cyan // <8=> White -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR -#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#ifndef NFC_NDEF_RECORD_PARSER_INFO_COLOR +#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 #endif // -// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +// + +// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag + + +#ifndef NFC_NDEF_TEXT_RECORD_ENABLED +#define NFC_NDEF_TEXT_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_MSG_ENABLED +#define NFC_NDEF_URI_MSG_ENABLED 0 +#endif + +// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_REC_ENABLED +#define NFC_NDEF_URI_REC_ENABLED 0 +#endif + +// NFC_PLATFORM_ENABLED - nfc_platform - NFC platform module for Clock control. //========================================================== -#ifndef NRF_SDH_ANT_LOG_ENABLED -#define NRF_SDH_ANT_LOG_ENABLED 0 +#ifndef NFC_PLATFORM_ENABLED +#define NFC_PLATFORM_ENABLED 0 #endif -// NRF_SDH_ANT_LOG_LEVEL - Default Severity level +// NFC_PLATFORM_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_PLATFORM_LOG_ENABLED +#define NFC_PLATFORM_LOG_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -4955,11 +10943,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_SDH_ANT_LOG_LEVEL -#define NRF_SDH_ANT_LOG_LEVEL 3 +#ifndef NFC_PLATFORM_LOG_LEVEL +#define NFC_PLATFORM_LOG_LEVEL 3 #endif -// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. +// NFC_PLATFORM_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4971,11 +10959,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SDH_ANT_INFO_COLOR -#define NRF_SDH_ANT_INFO_COLOR 0 +#ifndef NFC_PLATFORM_INFO_COLOR +#define NFC_PLATFORM_INFO_COLOR 0 #endif -// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. +// NFC_PLATFORM_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -4987,18 +10975,25 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SDH_ANT_DEBUG_COLOR -#define NRF_SDH_ANT_DEBUG_COLOR 0 +#ifndef NFC_PLATFORM_DEBUG_COLOR +#define NFC_PLATFORM_DEBUG_COLOR 0 #endif // -// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +// + +// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data //========================================================== -#ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#ifndef NFC_T2T_PARSER_ENABLED +#define NFC_T2T_PARSER_ENABLED 0 #endif -// NRF_SDH_BLE_LOG_LEVEL - Default Severity level +// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T2T_PARSER_LOG_ENABLED +#define NFC_T2T_PARSER_LOG_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -5006,11 +11001,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_SDH_BLE_LOG_LEVEL -#define NRF_SDH_BLE_LOG_LEVEL 3 +#ifndef NFC_T2T_PARSER_LOG_LEVEL +#define NFC_T2T_PARSER_LOG_LEVEL 3 #endif -// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. +// NFC_T2T_PARSER_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -5022,11 +11017,37 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SDH_BLE_INFO_COLOR -#define NRF_SDH_BLE_INFO_COLOR 0 +#ifndef NFC_T2T_PARSER_INFO_COLOR +#define NFC_T2T_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_APDU_ENABLED +#define NFC_T4T_APDU_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_APDU_LOG_ENABLED +#define NFC_T4T_APDU_LOG_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_APDU_LOG_LEVEL +#define NFC_T4T_APDU_LOG_LEVEL 3 #endif -// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. +// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -5038,18 +11059,25 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SDH_BLE_DEBUG_COLOR -#define NRF_SDH_BLE_DEBUG_COLOR 0 +#ifndef NFC_T4T_APDU_LOG_COLOR +#define NFC_T4T_APDU_LOG_COLOR 0 #endif // -// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +// + +// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag //========================================================== -#ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED +#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 #endif -// NRF_SDH_LOG_LEVEL - Default Severity level +// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED +#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -5057,11 +11085,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_SDH_LOG_LEVEL -#define NRF_SDH_LOG_LEVEL 3 +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL +#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 #endif -// NRF_SDH_INFO_COLOR - ANSI escape code prefix. +// NFC_T4T_CC_FILE_PARSER_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -5073,34 +11101,25 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SDH_INFO_COLOR -#define NRF_SDH_INFO_COLOR 0 +#ifndef NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 #endif -// NRF_SDH_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 NRF_SDH_DEBUG_COLOR -#define NRF_SDH_DEBUG_COLOR 0 -#endif +// // -// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag //========================================================== -#ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 #endif -// NRF_SDH_SOC_LOG_LEVEL - Default Severity level +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -5108,11 +11127,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_SDH_SOC_LOG_LEVEL -#define NRF_SDH_SOC_LOG_LEVEL 3 +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 #endif -// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. +// NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -5124,34 +11143,35 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SDH_SOC_INFO_COLOR -#define NRF_SDH_SOC_INFO_COLOR 0 +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 #endif -// NRF_SDH_SOC_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 NRF_SDH_SOC_DEBUG_COLOR -#define NRF_SDH_SOC_DEBUG_COLOR 0 +// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage +#ifndef APDU_BUFF_SIZE +#define APDU_BUFF_SIZE 250 +#endif + +// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage +#ifndef CC_STORAGE_BUFF_SIZE +#define CC_STORAGE_BUFF_SIZE 64 #endif // -// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag //========================================================== -#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED -#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 #endif -// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level +// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -5159,27 +11179,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL -#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR -#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 #endif -// NRF_SORTLIST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -5191,20 +11195,13 @@ // <7=> Cyan // <8=> White -#ifndef NRF_SORTLIST_CONFIG_DEBUG_COLOR -#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#ifndef NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 #endif // -// -//========================================================== - -// -//========================================================== - -// -//========================================================== +// // //========================================================== @@ -5220,22 +11217,22 @@ // 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 1024 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 4 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN -#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 32 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -5250,7 +11247,7 @@ // <2=> BLOCK_IF_FIFO_FULL #ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE -#define SEGGER_RTT_CONFIG_DEFAULT_MODE 1 +#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0 #endif // @@ -5269,9 +11266,18 @@ #endif // BLE Stack configuration - Stack configuration parameters -// These values are not used directly by the SoftDevice handler but the application or other libraries might depend on them. -// Keep them up-to-date with the desired configuration. +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. //========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + // NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1 @@ -5282,14 +11288,18 @@ #define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 #endif -// NRF_SDH_BLE_TOTAL_LINK_COUNT - Maximum number of total concurrent connections using the default configuration. +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT #define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 #endif -// NRF_SDH_BLE_GAP_EVENT_LENGTH - The time set aside for this connection on every connection interval in 1.25 ms units. +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + #ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH -#define NRF_SDH_BLE_GAP_EVENT_LENGTH 3 +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 #endif // NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. @@ -5415,6 +11425,13 @@ #define BLE_DFU_BLE_OBSERVER_PRIO 2 #endif +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + // BLE_GLS_BLE_OBSERVER_PRIO // Priority with which BLE events are dispatched to the Glucose Service. @@ -5555,6 +11572,146 @@ #define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 #endif +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + // NRF_BLE_BMS_BLE_OBSERVER_PRIO // Priority with which BLE events are dispatched to the Bond Management Service. @@ -5590,6 +11747,13 @@ #define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 #endif +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 +#endif + // NRF_BLE_QWR_BLE_OBSERVER_PRIO // Priority with which BLE events are dispatched to the Queued writes module. @@ -5597,6 +11761,13 @@ #define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 #endif +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + // PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. #ifndef PM_BLE_OBSERVER_PRIO #define PM_BLE_OBSERVER_PRIO 1 @@ -5663,19 +11834,23 @@ #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 #endif -// NRF_SDH_CLOCK_LF_XTAL_ACCURACY - External crystal clock accuracy used in the LL to compute timing windows. +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. -// <0=> NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM -// <1=> NRF_CLOCK_LF_XTAL_ACCURACY_500_PPM -// <2=> NRF_CLOCK_LF_XTAL_ACCURACY_150_PPM -// <3=> NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM -// <4=> NRF_CLOCK_LF_XTAL_ACCURACY_75_PPM -// <5=> NRF_CLOCK_LF_XTAL_ACCURACY_50_PPM -// <6=> NRF_CLOCK_LF_XTAL_ACCURACY_30_PPM -// <7=> NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM -#ifndef NRF_SDH_CLOCK_LF_XTAL_ACCURACY -#define NRF_SDH_CLOCK_LF_XTAL_ACCURACY 7 +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 #endif // @@ -5794,13 +11969,6 @@ // SoC Observers priorities - Invididual priorities //========================================================== -// BLE_ADV_SOC_OBSERVER_PRIO -// Priority with which SoC events are dispatched to the Advertising module. - -#ifndef BLE_ADV_SOC_OBSERVER_PRIO -#define BLE_ADV_SOC_OBSERVER_PRIO 1 -#endif - // BLE_DFU_SOC_OBSERVER_PRIO // Priority with which BLE events are dispatched to the DFU Service. diff --git a/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/ble_lora_AT_commands.emProject b/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/ble_lora_AT_commands.emProject index d7285c9..423250d 100644 --- a/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/ble_lora_AT_commands.emProject +++ b/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/ble_lora_AT_commands.emProject @@ -1,9 +1,6 @@ - - + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - + - + - - - + + + - - - - - - + + - + - - - - + - - - - - - - - - - - - - + + + - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - + + - - - - - - - + + - + - - - - + - - - - - - - - - - - - - + + + - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + - + + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - + + + - - - - - - + + - + - - - - + + + + - - - - - - - - - - - diff --git a/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/flash_placement.xml b/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/flash_placement.xml index 652702d..8cf5ad1 100644 --- a/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/flash_placement.xml +++ b/src/apps/ble_lorawan_AT_commands/ISP4520/s132/ses/flash_placement.xml @@ -7,17 +7,22 @@ - - - + + + + + + + - - + + + @@ -30,9 +35,10 @@ - - + + + diff --git a/src/apps/ble_lorawan_AT_commands/main.c b/src/apps/ble_lorawan_AT_commands/main.c index d95cd8d..86a2e8a 100644 --- a/src/apps/ble_lorawan_AT_commands/main.c +++ b/src/apps/ble_lorawan_AT_commands/main.c @@ -246,7 +246,7 @@ static void gap_params_init (void) err_code = sd_ble_gap_ppcp_set(&gap_conn_params); APP_ERROR_CHECK(err_code); - err_code = sd_ble_gap_tx_power_set(BLE_TX_POWER_LEVEL); + err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, BLE_TX_POWER_LEVEL); APP_ERROR_CHECK(err_code); err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE); @@ -353,8 +353,7 @@ static void services_init (void) ble_srv_ascii_to_utf8 (&dis_init.fw_rev_str, (char*)FW_REVISION); ble_srv_ascii_to_utf8 (&dis_init.hw_rev_str, (char*)HW_REVISION); - BLE_GAP_CONN_SEC_MODE_SET_OPEN (&dis_init.dis_attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS (&dis_init.dis_attr_md.write_perm); + dis_init.dis_char_rd_sec = SEC_OPEN; err_code = ble_dis_init(&dis_init); APP_ERROR_CHECK(err_code); @@ -404,10 +403,10 @@ int main (void) // Initialize BLE ble_stack_init(); + advertising_init(); gap_params_init(); conn_params_init(); services_init(); - advertising_init(); // Initialize LoRa chip. err_code = lora_hardware_init(); diff --git a/src/apps/lora_ping_pong/ISP4520/config/sdk_config.h b/src/apps/lora_ping_pong/ISP4520/config/sdk_config.h index 95762b5..db9ea43 100644 --- a/src/apps/lora_ping_pong/ISP4520/config/sdk_config.h +++ b/src/apps/lora_ping_pong/ISP4520/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,479 +46,7032 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// nRF_BLE +// nRF_Core //========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 1 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 1 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif +// + // //========================================================== -// nRF_Drivers +// nRF_Crypto //========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 0 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). //========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Disabled -// <1=> Enabled -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <0=> Excluded -// <14=> Included -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. -// <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=> 1000000 baud -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -// 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 +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif -// UART0_ENABLED - Enable UART0 instance +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + -// +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif -//========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// 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 1 + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 -// 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 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + +// CC310 backend implementation for HMAC using SHA-512 (in software). -// -//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif -// nRF_Libraries +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 #endif -// APP_UART_ENABLED - app_uart - UART driver +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. //========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 #endif -// APP_UART_DRIVER_INSTANCE - UART instance used +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif // -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. //========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> - +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// nrf_crypto_rng - RNG Configuration + +//========================================================== +// NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED - Use static memory buffers for context and temporary init buffer. + + +// Always recommended when using the nRF HW RNG as the context and temporary buffers are small. Consider disabling if using the CC310 RNG in a RAM constrained application. In this case, memory must be provided to nrf_crypto_rng_init, or it can be allocated internally provided that NRF_CRYPTO_ALLOCATOR does not allocate memory on the stack. + +#ifndef NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED +#define NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED 1 +#endif + +// NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - Initialize the RNG module automatically when nrf_crypto is initialized. + + +// Automatic initialization is only supported with static or internally allocated context and temporary memory. + +#ifndef NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 +#endif +// 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 6 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 2 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 1 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 1 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 1 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 1 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 1 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 1 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 1 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 1 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 1 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 1 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 1 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 1 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 1 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 1 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 1 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 1 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 1 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 1 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 1 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 1 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SYSTICK_ENABLED - nrfx_systick - ARM(R) SysTick driver + + +#ifndef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED 0 +#endif + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 1 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 1 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 1 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 1 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 1 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 1 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 1 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 1 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 1 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 1 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 1 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 1 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 1 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 1 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 1 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 1 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 1 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 1 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 1 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 1 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SYSTICK_ENABLED - nrf_drv_systick - ARM(R) SysTick driver - legacy layer + + +#ifndef SYSTICK_ENABLED +#define SYSTICK_ENABLED 0 +#endif + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 1 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 1 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 1 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 1 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 1 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 1 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 1 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 1 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 1 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 31 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 1 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 1 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 1 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 #endif // NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 1 +#endif + +// + +// + +// NRF_CLI_UART_ENABLED - nrf_cli_uart - UART command line interface transport + + +#ifndef NRF_CLI_UART_ENABLED +#define NRF_CLI_UART_ENABLED 0 +#endif + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 1 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 0 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 0 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 1 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 1 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 1 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 #endif // +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + // -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// TASK_MANAGER_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 NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +#ifndef TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 #endif -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// TASK_MANAGER_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 NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 +#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 #endif +// + // //========================================================== -// nRF_Log +// nrf_log in nRF_Drivers //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef CLOCK_CONFIG_LOG_LEVEL +#define CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// 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 + +// 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 // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 7 +// 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 -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. -// <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=> 1000000 baud +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#ifndef COMP_CONFIG_INFO_COLOR +#define COMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// 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 NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#ifndef COMP_CONFIG_DEBUG_COLOR +#define COMP_CONFIG_DEBUG_COLOR 0 #endif // -// nrf_log - Logger +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -530,11 +7083,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -546,11 +7118,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -562,13 +7134,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -576,110 +7153,152 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// MAX3421E_HOST_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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// MAX3421E_HOST_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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// NRFX_USBD_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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// NRFX_USBD_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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 #endif -// Log message pool - Configuration of log message pool +// +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// 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 NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== - -// +// 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 -// nrf_log module configuration +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif -//========================================================== -// nrf_log in nRF_Core +// +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// PPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -687,11 +7306,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -703,11 +7322,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -719,18 +7338,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// PWM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -738,11 +7357,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -754,11 +7373,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -770,18 +7389,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// QDEC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -789,11 +7408,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -805,11 +7424,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -821,24 +7440,18 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -846,11 +7459,11 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -862,11 +7475,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -878,18 +7491,25 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// 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 // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -897,11 +7517,11 @@ // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -913,11 +7533,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -929,18 +7549,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// SAADC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -948,11 +7568,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -964,11 +7584,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -980,18 +7600,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -999,11 +7619,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1015,11 +7635,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1031,18 +7651,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// SPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1050,11 +7670,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1066,11 +7686,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1082,18 +7702,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1101,11 +7721,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1117,11 +7737,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1133,18 +7753,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1152,11 +7772,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1168,11 +7788,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1184,18 +7804,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1203,11 +7823,11 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1219,11 +7839,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1235,18 +7855,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1254,11 +7874,11 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1270,11 +7890,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1286,18 +7906,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1305,11 +7925,11 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1321,11 +7941,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1337,18 +7957,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1356,11 +7976,11 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1372,11 +7992,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1388,25 +8008,24 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// +//========================================================== -// +// nrf_log in nRF_Libraries -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1414,11 +8033,27 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1430,11 +8065,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1446,18 +8081,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1465,11 +8100,27 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1481,11 +8132,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1497,18 +8148,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1516,11 +8167,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1532,11 +8183,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1548,18 +8199,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1567,11 +8218,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1583,11 +8234,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1599,18 +8250,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1618,11 +8269,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1634,11 +8285,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1650,18 +8301,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1669,11 +8320,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1685,11 +8336,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1701,18 +8352,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1720,11 +8371,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1736,11 +8387,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1752,18 +8403,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1771,11 +8422,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1787,11 +8450,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1803,18 +8466,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1822,11 +8485,27 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1838,11 +8517,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1854,18 +8533,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1873,11 +8552,23 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1889,11 +8580,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1905,18 +8596,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1924,11 +8615,23 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1940,11 +8643,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1956,24 +8659,30 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled // <0=> Off // <1=> Error @@ -1981,11 +8690,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1997,11 +8706,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2013,18 +8722,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2032,11 +8741,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2048,11 +8757,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2064,18 +8773,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2083,11 +8792,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2099,11 +8808,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2115,18 +8824,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2134,11 +8843,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2150,11 +8859,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2166,18 +8875,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2185,11 +8894,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2201,11 +8910,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2217,8 +8926,8 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // @@ -2325,6 +9034,69 @@ // +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + // NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== #ifndef NRF_SDH_ANT_LOG_ENABLED @@ -2379,7 +9151,7 @@ // NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== #ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#define NRF_SDH_BLE_LOG_ENABLED 0 #endif // NRF_SDH_BLE_LOG_LEVEL - Default Severity level @@ -2430,7 +9202,7 @@ // NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== #ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#define NRF_SDH_LOG_ENABLED 0 #endif // NRF_SDH_LOG_LEVEL - Default Severity level @@ -2481,7 +9253,7 @@ // NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== #ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#define NRF_SDH_SOC_LOG_ENABLED 0 #endif // NRF_SDH_SOC_LOG_LEVEL - Default Severity level @@ -2580,15 +9352,180 @@ // +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== // //========================================================== +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + // //========================================================== @@ -2603,22 +9540,22 @@ // 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 2048 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -2641,6 +9578,7 @@ // //========================================================== + // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/src/apps/lora_ping_pong/ISP4520/ses/flash_placement.xml b/src/apps/lora_ping_pong/ISP4520/ses/flash_placement.xml index 91fbb42..8c8f579 100644 --- a/src/apps/lora_ping_pong/ISP4520/ses/flash_placement.xml +++ b/src/apps/lora_ping_pong/ISP4520/ses/flash_placement.xml @@ -5,9 +5,18 @@ + + + + + + + + + @@ -19,7 +28,10 @@ + + + diff --git a/src/apps/lora_ping_pong/ISP4520/ses/ping-pong.emProject b/src/apps/lora_ping_pong/ISP4520/ses/ping-pong.emProject new file mode 100644 index 0000000..099caa5 --- /dev/null +++ b/src/apps/lora_ping_pong/ISP4520/ses/ping-pong.emProject @@ -0,0 +1,1865 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/apps/lora_ping_pong/ISP4520/ses/ping_pong.emProject b/src/apps/lora_ping_pong/ISP4520/ses/ping_pong.emProject deleted file mode 100644 index 466866b..0000000 --- a/src/apps/lora_ping_pong/ISP4520/ses/ping_pong.emProject +++ /dev/null @@ -1,578 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h b/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h index f00fddd..6e576a1 100644 --- a/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h +++ b/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,580 +46,7032 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// nRF_BLE +// nRF_Core //========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 1 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 1 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif +// + // //========================================================== -// nRF_Drivers +// nRF_Crypto //========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 0 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). //========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Disabled -// <1=> Enabled -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <0=> Excluded -// <14=> Included -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. -// <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=> 1000000 baud -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -// 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 +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif -// UART0_ENABLED - Enable UART0 instance +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + -// +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif -//========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// 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 6 + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 6 +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 -// 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 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + +// CC310 backend implementation for HMAC using SHA-512 (in software). -// -//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif -// nRF_Libraries +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 #endif -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. //========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 #endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. -#ifndef APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. -#ifndef APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + -// APP_TIMER_ENABLED - app_timer - Application timer functionality -//========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. -// <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 31 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. -// 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 NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif -#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY -#define APP_TIMER_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 #endif -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 15 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 #endif -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. -#ifndef APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 #endif -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. -#ifndef APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 #endif -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -// If option is enabled RTC is kept running even if there is no active timers. -// This option can be used when app_timer is used for timestamping. +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS -#ifndef APP_TIMER_KEEPS_RTC_ACTIVE -#define APP_TIMER_KEEPS_RTC_ACTIVE 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 #endif -// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -// <0=> 0 -// <1=> 1 -#ifndef APP_TIMER_CONFIG_SWI_NUMBER -#define APP_TIMER_CONFIG_SWI_NUMBER 0 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 #endif -// APP_UART_DRIVER_INSTANCE - UART instance used + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif // -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 #endif -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. //========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + -// nRF_Log +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend //========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 1 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 #endif // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 6 +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 -// <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=> 1000000 baud -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// -#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 #endif // -// nrf_log - Logger +// nrf_crypto_rng - RNG Configuration + +//========================================================== +// NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED - Use static memory buffers for context and temporary init buffer. + + +// Always recommended when using the nRF HW RNG as the context and temporary buffers are small. Consider disabling if using the CC310 RNG in a RAM constrained application. In this case, memory must be provided to nrf_crypto_rng_init, or it can be allocated internally provided that NRF_CRYPTO_ALLOCATOR does not allocate memory on the stack. + +#ifndef NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED +#define NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED 1 +#endif + +// NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - Initialize the RNG module automatically when nrf_crypto is initialized. + + +// Automatic initialization is only supported with static or internally allocated context and temporary memory. + +#ifndef NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 +#endif +// 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 6 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 2 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 1 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 1 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 1 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 1 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 1 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 1 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 1 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 1 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 1 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 1 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 1 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 1 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 1 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 1 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 1 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 1 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 1 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 1 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 1 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 1 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SYSTICK_ENABLED - nrfx_systick - ARM(R) SysTick driver + + +#ifndef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED 0 +#endif + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 1 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 1 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 1 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 1 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 1 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 1 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 1 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 1 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 1 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 1 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 1 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 1 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 1 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 1 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 1 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 1 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 1 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 1 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 1 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 1 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SYSTICK_ENABLED - nrf_drv_systick - ARM(R) SysTick driver - legacy layer + + +#ifndef SYSTICK_ENABLED +#define SYSTICK_ENABLED 0 +#endif + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 1 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 1 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 1 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 1 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 1 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 1 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 1 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 1 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 1 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 31 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 1 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 1 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 1 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 1 +#endif + +// + +// + +// NRF_CLI_UART_ENABLED - nrf_cli_uart - UART command line interface transport + + +#ifndef NRF_CLI_UART_ENABLED +#define NRF_CLI_UART_ENABLED 0 +#endif + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 1 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 0 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 1 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 1 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 1 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -631,11 +7083,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -647,11 +7118,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -663,13 +7134,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -677,110 +7153,152 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// MAX3421E_HOST_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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// MAX3421E_HOST_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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// NRFX_USBD_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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// NRFX_USBD_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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 #endif -// Log message pool - Configuration of log message pool +// +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// 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 NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== - -// +// 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 -// nrf_log module configuration +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif -//========================================================== -// nrf_log in nRF_Core +// +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// PPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -788,11 +7306,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -804,11 +7322,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -820,18 +7338,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// PWM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -839,11 +7357,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -855,11 +7373,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -871,18 +7389,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// QDEC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -890,11 +7408,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -906,11 +7424,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -922,24 +7440,18 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -947,11 +7459,11 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -963,11 +7475,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -979,18 +7491,25 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// 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 // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -998,11 +7517,11 @@ // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1014,11 +7533,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1030,18 +7549,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// SAADC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1049,11 +7568,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1065,11 +7584,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1081,18 +7600,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1100,11 +7619,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1116,11 +7635,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1132,18 +7651,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// SPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1151,11 +7670,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1167,11 +7686,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1183,18 +7702,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1202,11 +7721,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1218,11 +7737,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1234,18 +7753,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1253,11 +7772,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1269,11 +7788,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1285,18 +7804,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1304,11 +7823,11 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1320,11 +7839,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1336,18 +7855,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1355,11 +7874,11 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1371,11 +7890,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1387,18 +7906,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1406,11 +7925,11 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1422,11 +7941,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1438,18 +7957,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1457,11 +7976,11 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1473,11 +7992,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1489,25 +8008,24 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// +//========================================================== -// +// nrf_log in nRF_Libraries -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1515,11 +8033,27 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1531,11 +8065,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1547,18 +8081,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1566,11 +8100,27 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1582,11 +8132,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1598,18 +8148,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1617,11 +8167,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1633,11 +8183,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1649,18 +8199,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1668,11 +8218,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1684,11 +8234,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1700,18 +8250,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1719,11 +8269,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1735,11 +8285,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1751,18 +8301,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1770,11 +8320,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1786,11 +8336,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1802,18 +8352,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1821,11 +8371,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1837,11 +8387,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1853,18 +8403,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1872,11 +8422,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1888,11 +8450,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1904,18 +8466,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1923,11 +8485,27 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1939,11 +8517,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1955,18 +8533,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1974,11 +8552,23 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1990,11 +8580,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2006,18 +8596,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2025,11 +8615,23 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2041,11 +8643,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2057,24 +8659,30 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled // <0=> Off // <1=> Error @@ -2082,11 +8690,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2098,11 +8706,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2114,18 +8722,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2133,11 +8741,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2149,11 +8757,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2165,18 +8773,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2184,11 +8792,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2200,11 +8808,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2216,18 +8824,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2235,11 +8843,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2251,11 +8859,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2267,18 +8875,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2286,11 +8894,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2302,11 +8910,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2318,8 +8926,8 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // @@ -2426,6 +9034,69 @@ // +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + // NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== #ifndef NRF_SDH_ANT_LOG_ENABLED @@ -2480,7 +9151,7 @@ // NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== #ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#define NRF_SDH_BLE_LOG_ENABLED 0 #endif // NRF_SDH_BLE_LOG_LEVEL - Default Severity level @@ -2531,7 +9202,7 @@ // NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== #ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#define NRF_SDH_LOG_ENABLED 0 #endif // NRF_SDH_LOG_LEVEL - Default Severity level @@ -2582,7 +9253,7 @@ // NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== #ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#define NRF_SDH_SOC_LOG_ENABLED 0 #endif // NRF_SDH_SOC_LOG_LEVEL - Default Severity level @@ -2681,15 +9352,180 @@ // +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== // //========================================================== +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + // //========================================================== @@ -2704,22 +9540,22 @@ // 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 2048 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -2742,6 +9578,7 @@ // //========================================================== + // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h~RFac87b98.TMP b/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h~RFac87b98.TMP deleted file mode 100644 index 71f987d..0000000 --- a/src/apps/lora_rx_temperature/ISP4520/config/sdk_config.h~RFac87b98.TMP +++ /dev/null @@ -1,2646 +0,0 @@ -/** - * Copyright (c) 2017 - 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 SDK_CONFIG_H -#define SDK_CONFIG_H -// <<< Use Configuration Wizard in Context Menu >>>\n -#ifdef USE_APP_CONFIG -#include "app_config.h" -#endif -// nRF_BLE - -//========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands - - -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 -#endif - -// -//========================================================== - -// nRF_Drivers - -//========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module - - -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 -#endif - -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver -//========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 -#endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control - -// <0=> Disabled -// <1=> Enabled - -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 -#endif - -// UART_DEFAULT_CONFIG_PARITY - Parity - -// <0=> Excluded -// <14=> Included - -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 -#endif - -// 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=> 1000000 baud - -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 -#endif - -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// 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 - -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - - -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 -#endif - -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode - - -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 -#endif - -// UART0_ENABLED - Enable UART0 instance -//========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 -#endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA - - -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 -#endif - -// - -// - -//========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 -#endif -// 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 6 -#endif - -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// 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 - -// - -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 -#endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// 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 - -// SPI_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 SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 -#endif - -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. - -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP - -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 -#endif - -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 -#endif -// SPI0_USE_EASY_DMA - Use EasyDMA - - -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 -#endif - -// - -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 -#endif -// SPI1_USE_EASY_DMA - Use EasyDMA - - -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 -#endif - -// - -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 -#endif -// SPI2_USE_EASY_DMA - Use EasyDMA - - -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 -#endif - -// - -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. - - -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ - -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 -#endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency - -// <0=> Default (64 MHz) - -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 -#endif - -// 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 - -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// 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 - -// - - -// -//========================================================== - -// nRF_Libraries - -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation - - -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 -#endif - -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 -#endif -// APP_UART_DRIVER_INSTANCE - UART instance used - -// <0=> 0 - -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 -#endif - -// - -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 -#endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 -#endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> - - -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 -#endif - -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> - - -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 -#endif - -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. - - -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 -#endif - -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. - - -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 -#endif - -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. - - -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 -#endif - -// - -// - -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module - - -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 -#endif - -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. - - -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 -#endif - -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. - - -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 -#endif - -// -//========================================================== - -// nRF_Log - -//========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend -//========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 -#endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. - -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 -#endif - -// - -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend -//========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 -#endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 3 -#endif - -// NRF_LOG_BACKEND_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=> 1000000 baud - -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 -#endif - -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. - -#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 -#endif - -// - -// nrf_log - Logger - -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 -// 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 - -// 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 2 -#endif - -// 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 4 -#endif - -// - -// 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 4 -#endif - -// NRF_LOG_DEFERRED - Enable deffered logger. - - -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 -#endif - -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). - - -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 -#endif - -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. - -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 -#endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping - - -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 -#endif - -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. - - -#ifndef NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 -#endif - -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. - - -#ifndef NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 -#endif - -// Log message pool - Configuration of log message pool - -//========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. - -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 -#endif - -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. - -#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 -#endif - -// -//========================================================== - -// - -// nrf_log module configuration - -//========================================================== -// nrf_log in nRF_Core - -//========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 -#endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_MPU_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 NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 -#endif - -// NRF_MPU_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 NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 -#endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 -#endif - -// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 -#endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 -#endif - -// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 -#endif - -// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// 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 - -// - -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 -#endif -// 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 4 -#endif - -// 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 - -// 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 - -// - -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 -#endif -// 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 4 -#endif - -// 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 - -// 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 - -// - -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module -//========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 -#endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 -#endif - -// USBD_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 USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 -#endif - -// USBD_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 USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 -#endif -// 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 - -// 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 - -// 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 - -// - -// -//========================================================== - -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 -#endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_BALLOC_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 NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 -#endif - -// NRF_BALLOC_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 NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 -#endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 -#endif - -// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 -#endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_CLI_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 NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 -#endif - -// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED -#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 -#endif -// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL -#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_INFO_COLOR -#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 -#endif - -// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_DEBUG_COLOR -#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED -#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 -#endif -// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL -#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_INFO_COLOR -#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 -#endif - -// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_DEBUG_COLOR -#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. -//========================================================== -#ifndef NRF_SDH_ANT_LOG_ENABLED -#define NRF_SDH_ANT_LOG_ENABLED 0 -#endif -// NRF_SDH_ANT_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_ANT_LOG_LEVEL -#define NRF_SDH_ANT_LOG_LEVEL 3 -#endif - -// NRF_SDH_ANT_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 NRF_SDH_ANT_INFO_COLOR -#define NRF_SDH_ANT_INFO_COLOR 0 -#endif - -// NRF_SDH_ANT_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 NRF_SDH_ANT_DEBUG_COLOR -#define NRF_SDH_ANT_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. -//========================================================== -#ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 -#endif -// NRF_SDH_BLE_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_BLE_LOG_LEVEL -#define NRF_SDH_BLE_LOG_LEVEL 3 -#endif - -// NRF_SDH_BLE_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 NRF_SDH_BLE_INFO_COLOR -#define NRF_SDH_BLE_INFO_COLOR 0 -#endif - -// NRF_SDH_BLE_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 NRF_SDH_BLE_DEBUG_COLOR -#define NRF_SDH_BLE_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. -//========================================================== -#ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 -#endif -// NRF_SDH_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_LOG_LEVEL -#define NRF_SDH_LOG_LEVEL 3 -#endif - -// NRF_SDH_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 NRF_SDH_INFO_COLOR -#define NRF_SDH_INFO_COLOR 0 -#endif - -// NRF_SDH_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 NRF_SDH_DEBUG_COLOR -#define NRF_SDH_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. -//========================================================== -#ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 -#endif -// NRF_SDH_SOC_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_SOC_LOG_LEVEL -#define NRF_SDH_SOC_LOG_LEVEL 3 -#endif - -// NRF_SDH_SOC_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 NRF_SDH_SOC_INFO_COLOR -#define NRF_SDH_SOC_INFO_COLOR 0 -#endif - -// NRF_SDH_SOC_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 NRF_SDH_SOC_DEBUG_COLOR -#define NRF_SDH_SOC_DEBUG_COLOR 0 -#endif - -// - -// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED -#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 -#endif -// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL -#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR -#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 -#endif - -// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_DEBUG_COLOR -#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// -//========================================================== - -// -//========================================================== - -// -//========================================================== - -// -//========================================================== - -// nRF_Segger_RTT - -//========================================================== -// segger_rtt - SEGGER RTT - -//========================================================== -// SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer. -// Note that either @ref NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE -// 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 2048 -#endif - -// 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 3 -#endif - -// 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 - -// 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 3 -#endif - -// SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. - - -// The following modes are supported: -// - SKIP - Do not block, output nothing. -// - TRIM - Do not block, output as much as fits. -// - 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 - -// -//========================================================== - -// -//========================================================== -// <<< end of configuration section >>> -#endif //SDK_CONFIG_H - diff --git a/src/apps/lora_rx_temperature/ISP4520/ses/RX_temperature.emProject b/src/apps/lora_rx_temperature/ISP4520/ses/RX_temperature.emProject deleted file mode 100644 index 7bfdedc..0000000 --- a/src/apps/lora_rx_temperature/ISP4520/ses/RX_temperature.emProject +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apps/lora_rx_temperature/ISP4520/ses/flash_placement.xml b/src/apps/lora_rx_temperature/ISP4520/ses/flash_placement.xml index 91fbb42..8c8f579 100644 --- a/src/apps/lora_rx_temperature/ISP4520/ses/flash_placement.xml +++ b/src/apps/lora_rx_temperature/ISP4520/ses/flash_placement.xml @@ -5,9 +5,18 @@ + + + + + + + + + @@ -19,7 +28,10 @@ + + + diff --git a/src/apps/lora_tx_cw/ISP4520/config/sdk_config.h b/src/apps/lora_tx_cw/ISP4520/config/sdk_config.h index 127a42a..db9ea43 100644 --- a/src/apps/lora_tx_cw/ISP4520/config/sdk_config.h +++ b/src/apps/lora_tx_cw/ISP4520/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,479 +46,7032 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// nRF_BLE +// nRF_Core //========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 1 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 #endif -// -//========================================================== - -// nRF_Drivers +// +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard //========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 1 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver +// + +// //========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRF_CRYPTO_ALLOCATOR - Memory allocator -// <0=> Disabled -// <1=> Enabled -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Excluded -// <14=> Included -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <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=> 1000000 baud -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. -// 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 +// CC310_BL backend implementation for hardware-accelerated SHA-256. -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// UART0_ENABLED - Enable UART0 instance -//========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 -#endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif // -// +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// 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 6 +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. -// 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 6 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// 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 +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 #endif -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 -#endif -// SPI0_USE_EASY_DMA - Use EasyDMA +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// - -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ - -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. -// 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 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif -// -//========================================================== +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + -// nRF_Libraries +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 #endif -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 -#endif -// APP_UART_DRIVER_INSTANCE - UART instance used +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 -#endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + +// CC310 backend implementation for SHA-512 (in software). -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif // -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// nrf_crypto_rng - RNG Configuration + +//========================================================== +// NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED - Use static memory buffers for context and temporary init buffer. + + +// Always recommended when using the nRF HW RNG as the context and temporary buffers are small. Consider disabling if using the CC310 RNG in a RAM constrained application. In this case, memory must be provided to nrf_crypto_rng_init, or it can be allocated internally provided that NRF_CRYPTO_ALLOCATOR does not allocate memory on the stack. + +#ifndef NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED +#define NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED 1 +#endif + +// NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - Initialize the RNG module automatically when nrf_crypto is initialized. + + +// Automatic initialization is only supported with static or internally allocated context and temporary memory. + +#ifndef NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 +#endif +// 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 6 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 2 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 1 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 1 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 1 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 1 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 1 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 1 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 1 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 1 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 1 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 1 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 1 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 1 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 1 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 1 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 1 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 1 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 1 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 1 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 1 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 1 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SYSTICK_ENABLED - nrfx_systick - ARM(R) SysTick driver + + +#ifndef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED 0 +#endif + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 1 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 1 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 1 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 1 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 1 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 1 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 1 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 1 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 1 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 1 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 1 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 1 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 1 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 1 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 1 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 1 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 1 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 1 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 1 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 1 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SYSTICK_ENABLED - nrf_drv_systick - ARM(R) SysTick driver - legacy layer + + +#ifndef SYSTICK_ENABLED +#define SYSTICK_ENABLED 0 +#endif + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 1 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 1 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 1 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 1 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 1 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 1 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 1 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 1 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 1 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 31 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 1 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 1 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 1 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 1 +#endif + +// + +// + +// NRF_CLI_UART_ENABLED - nrf_cli_uart - UART command line interface transport + + +#ifndef NRF_CLI_UART_ENABLED +#define NRF_CLI_UART_ENABLED 0 +#endif + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 1 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 0 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 0 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 1 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 1 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 1 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +#ifndef NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 #endif -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 #endif +// + // //========================================================== -// nRF_Log +// nrf_log in nRF_Drivers //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef CLOCK_CONFIG_LOG_LEVEL +#define CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// 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 + +// 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 // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 3 +// 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 -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. -// <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=> 1000000 baud +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#ifndef COMP_CONFIG_INFO_COLOR +#define COMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// 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 NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#ifndef COMP_CONFIG_DEBUG_COLOR +#define COMP_CONFIG_DEBUG_COLOR 0 #endif // -// nrf_log - Logger +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -530,11 +7083,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -546,11 +7118,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -562,13 +7134,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -576,110 +7153,152 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// MAX3421E_HOST_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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// MAX3421E_HOST_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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// NRFX_USBD_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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// NRFX_USBD_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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 #endif -// Log message pool - Configuration of log message pool +// +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// 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 NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== - -// +// 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 -// nrf_log module configuration +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif -//========================================================== -// nrf_log in nRF_Core +// +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// PPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -687,11 +7306,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -703,11 +7322,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -719,18 +7338,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// PWM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -738,11 +7357,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -754,11 +7373,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -770,18 +7389,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// QDEC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -789,11 +7408,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -805,11 +7424,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -821,24 +7440,18 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -846,11 +7459,11 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -862,11 +7475,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -878,18 +7491,25 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// 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 // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -897,11 +7517,11 @@ // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -913,11 +7533,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -929,18 +7549,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// SAADC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -948,11 +7568,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -964,11 +7584,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -980,18 +7600,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -999,11 +7619,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1015,11 +7635,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1031,18 +7651,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// SPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1050,11 +7670,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1066,11 +7686,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1082,18 +7702,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1101,11 +7721,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1117,11 +7737,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1133,18 +7753,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1152,11 +7772,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1168,11 +7788,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1184,18 +7804,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1203,11 +7823,11 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1219,11 +7839,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1235,18 +7855,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1254,11 +7874,11 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1270,11 +7890,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1286,18 +7906,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1305,11 +7925,11 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1321,11 +7941,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1337,18 +7957,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1356,11 +7976,11 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1372,11 +7992,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1388,25 +8008,24 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// +//========================================================== -// +// nrf_log in nRF_Libraries -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1414,11 +8033,27 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1430,11 +8065,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1446,18 +8081,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1465,11 +8100,27 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1481,11 +8132,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1497,18 +8148,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1516,11 +8167,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1532,11 +8183,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1548,18 +8199,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1567,11 +8218,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1583,11 +8234,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1599,18 +8250,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1618,11 +8269,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1634,11 +8285,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1650,18 +8301,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1669,11 +8320,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1685,11 +8336,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1701,18 +8352,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1720,11 +8371,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1736,11 +8387,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1752,18 +8403,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1771,11 +8422,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1787,11 +8450,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1803,18 +8466,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1822,11 +8485,27 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1838,11 +8517,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1854,18 +8533,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1873,11 +8552,23 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1889,11 +8580,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1905,18 +8596,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1924,11 +8615,23 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1940,11 +8643,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1956,24 +8659,30 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled // <0=> Off // <1=> Error @@ -1981,11 +8690,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1997,11 +8706,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2013,18 +8722,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2032,11 +8741,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2048,11 +8757,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2064,18 +8773,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2083,11 +8792,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2099,11 +8808,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2115,18 +8824,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2134,11 +8843,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2150,11 +8859,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2166,18 +8875,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2185,11 +8894,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2201,11 +8910,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2217,8 +8926,8 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // @@ -2325,6 +9034,69 @@ // +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + // NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== #ifndef NRF_SDH_ANT_LOG_ENABLED @@ -2379,7 +9151,7 @@ // NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== #ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#define NRF_SDH_BLE_LOG_ENABLED 0 #endif // NRF_SDH_BLE_LOG_LEVEL - Default Severity level @@ -2430,7 +9202,7 @@ // NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== #ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#define NRF_SDH_LOG_ENABLED 0 #endif // NRF_SDH_LOG_LEVEL - Default Severity level @@ -2481,7 +9253,7 @@ // NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== #ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#define NRF_SDH_SOC_LOG_ENABLED 0 #endif // NRF_SDH_SOC_LOG_LEVEL - Default Severity level @@ -2580,15 +9352,180 @@ // +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== // //========================================================== +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + // //========================================================== @@ -2603,22 +9540,22 @@ // 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 2048 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -2641,6 +9578,7 @@ // //========================================================== + // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/src/apps/lora_tx_cw/ISP4520/ses/flash_placement.xml b/src/apps/lora_tx_cw/ISP4520/ses/flash_placement.xml index 91fbb42..8c8f579 100644 --- a/src/apps/lora_tx_cw/ISP4520/ses/flash_placement.xml +++ b/src/apps/lora_tx_cw/ISP4520/ses/flash_placement.xml @@ -5,9 +5,18 @@ + + + + + + + + + @@ -19,7 +28,10 @@ + + + diff --git a/src/apps/lora_tx_cw/ISP4520/ses/tx-cw.emProject b/src/apps/lora_tx_cw/ISP4520/ses/tx-cw.emProject new file mode 100644 index 0000000..0115754 --- /dev/null +++ b/src/apps/lora_tx_cw/ISP4520/ses/tx-cw.emProject @@ -0,0 +1,1865 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/apps/lora_tx_cw/ISP4520/ses/tx_cw.emProject b/src/apps/lora_tx_cw/ISP4520/ses/tx_cw.emProject deleted file mode 100644 index a62930d..0000000 --- a/src/apps/lora_tx_cw/ISP4520/ses/tx_cw.emProject +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apps/lora_tx_temperature/ISP4520/config/sdk_config.h b/src/apps/lora_tx_temperature/ISP4520/config/sdk_config.h index c02957f..6e576a1 100644 --- a/src/apps/lora_tx_temperature/ISP4520/config/sdk_config.h +++ b/src/apps/lora_tx_temperature/ISP4520/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,580 +46,7032 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// nRF_BLE +// nRF_Core //========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 1 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 1 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif +// + // //========================================================== -// nRF_Drivers +// nRF_Crypto //========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 0 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). //========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Disabled -// <1=> Enabled -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <0=> Excluded -// <14=> Included -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. -// <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=> 1000000 baud -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -// 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 +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif -// UART0_ENABLED - Enable UART0 instance +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + -// +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif -//========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// 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 6 + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 6 +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 -// 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 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + +// CC310 backend implementation for HMAC using SHA-512 (in software). -// -//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif -// nRF_Libraries +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 #endif -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. //========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 #endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. -#ifndef APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. -#ifndef APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + -// APP_TIMER_ENABLED - app_timer - Application timer functionality -//========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. -// <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 31 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. -// 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 NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif -#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY -#define APP_TIMER_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 #endif -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 15 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 #endif -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. -#ifndef APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 #endif -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. -#ifndef APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 #endif -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -// If option is enabled RTC is kept running even if there is no active timers. -// This option can be used when app_timer is used for timestamping. +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS -#ifndef APP_TIMER_KEEPS_RTC_ACTIVE -#define APP_TIMER_KEEPS_RTC_ACTIVE 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 #endif -// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -// <0=> 0 -// <1=> 1 -#ifndef APP_TIMER_CONFIG_SWI_NUMBER -#define APP_TIMER_CONFIG_SWI_NUMBER 0 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 #endif -// APP_UART_DRIVER_INSTANCE - UART instance used + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif // -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 #endif -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. //========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + -// nRF_Log +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend //========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 1 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 #endif // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 3 +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 -// <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=> 1000000 baud -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// -#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 #endif // -// nrf_log - Logger +// nrf_crypto_rng - RNG Configuration + +//========================================================== +// NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED - Use static memory buffers for context and temporary init buffer. + + +// Always recommended when using the nRF HW RNG as the context and temporary buffers are small. Consider disabling if using the CC310 RNG in a RAM constrained application. In this case, memory must be provided to nrf_crypto_rng_init, or it can be allocated internally provided that NRF_CRYPTO_ALLOCATOR does not allocate memory on the stack. + +#ifndef NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED +#define NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED 1 +#endif + +// NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - Initialize the RNG module automatically when nrf_crypto is initialized. + + +// Automatic initialization is only supported with static or internally allocated context and temporary memory. + +#ifndef NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 +#endif +// 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 6 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 2 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 1 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 1 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 1 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 1 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 1 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 1 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 1 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 1 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 1 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 1 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 1 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 1 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 1 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 1 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 1 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 1 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 1 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 1 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 1 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 1 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SYSTICK_ENABLED - nrfx_systick - ARM(R) SysTick driver + + +#ifndef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED 0 +#endif + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 1 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 1 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 1 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 1 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 1 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 1 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 1 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 1 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 1 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 1 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 1 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 1 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 1 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 1 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 1 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 1 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 1 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 1 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 1 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 1 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SYSTICK_ENABLED - nrf_drv_systick - ARM(R) SysTick driver - legacy layer + + +#ifndef SYSTICK_ENABLED +#define SYSTICK_ENABLED 0 +#endif + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 1 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 1 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 1 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 1 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 1 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 1 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 1 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 1 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 1 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 31 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 1 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 1 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 1 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 1 +#endif + +// + +// + +// NRF_CLI_UART_ENABLED - nrf_cli_uart - UART command line interface transport + + +#ifndef NRF_CLI_UART_ENABLED +#define NRF_CLI_UART_ENABLED 0 +#endif + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 1 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 0 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 1 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 1 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 1 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -631,11 +7083,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -647,11 +7118,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -663,13 +7134,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -677,110 +7153,152 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// MAX3421E_HOST_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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// MAX3421E_HOST_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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// NRFX_USBD_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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// NRFX_USBD_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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 #endif -// Log message pool - Configuration of log message pool +// +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// 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 NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== - -// +// 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 -// nrf_log module configuration +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif -//========================================================== -// nrf_log in nRF_Core +// +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// PPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -788,11 +7306,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -804,11 +7322,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -820,18 +7338,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// PWM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -839,11 +7357,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -855,11 +7373,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -871,18 +7389,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// QDEC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -890,11 +7408,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -906,11 +7424,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -922,24 +7440,18 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -947,11 +7459,11 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -963,11 +7475,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -979,18 +7491,25 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// 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 // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -998,11 +7517,11 @@ // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1014,11 +7533,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1030,18 +7549,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// SAADC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1049,11 +7568,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1065,11 +7584,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1081,18 +7600,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1100,11 +7619,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1116,11 +7635,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1132,18 +7651,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// SPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1151,11 +7670,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1167,11 +7686,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1183,18 +7702,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1202,11 +7721,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1218,11 +7737,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1234,18 +7753,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1253,11 +7772,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1269,11 +7788,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1285,18 +7804,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1304,11 +7823,11 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1320,11 +7839,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1336,18 +7855,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1355,11 +7874,11 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1371,11 +7890,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1387,18 +7906,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1406,11 +7925,11 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1422,11 +7941,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1438,18 +7957,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1457,11 +7976,11 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1473,11 +7992,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1489,25 +8008,24 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// +//========================================================== -// +// nrf_log in nRF_Libraries -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1515,11 +8033,27 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1531,11 +8065,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1547,18 +8081,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1566,11 +8100,27 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1582,11 +8132,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1598,18 +8148,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1617,11 +8167,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1633,11 +8183,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1649,18 +8199,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1668,11 +8218,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1684,11 +8234,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1700,18 +8250,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1719,11 +8269,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1735,11 +8285,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1751,18 +8301,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1770,11 +8320,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1786,11 +8336,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1802,18 +8352,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1821,11 +8371,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1837,11 +8387,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1853,18 +8403,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1872,11 +8422,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1888,11 +8450,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1904,18 +8466,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1923,11 +8485,27 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1939,11 +8517,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1955,18 +8533,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1974,11 +8552,23 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1990,11 +8580,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2006,18 +8596,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2025,11 +8615,23 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2041,11 +8643,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2057,24 +8659,30 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled // <0=> Off // <1=> Error @@ -2082,11 +8690,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2098,11 +8706,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2114,18 +8722,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2133,11 +8741,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2149,11 +8757,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2165,18 +8773,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2184,11 +8792,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2200,11 +8808,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2216,18 +8824,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2235,11 +8843,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2251,11 +8859,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2267,18 +8875,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2286,11 +8894,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2302,11 +8910,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2318,8 +8926,8 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // @@ -2426,6 +9034,69 @@ // +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + // NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== #ifndef NRF_SDH_ANT_LOG_ENABLED @@ -2480,7 +9151,7 @@ // NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== #ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#define NRF_SDH_BLE_LOG_ENABLED 0 #endif // NRF_SDH_BLE_LOG_LEVEL - Default Severity level @@ -2531,7 +9202,7 @@ // NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== #ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#define NRF_SDH_LOG_ENABLED 0 #endif // NRF_SDH_LOG_LEVEL - Default Severity level @@ -2582,7 +9253,7 @@ // NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== #ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#define NRF_SDH_SOC_LOG_ENABLED 0 #endif // NRF_SDH_SOC_LOG_LEVEL - Default Severity level @@ -2681,15 +9352,180 @@ // +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== // //========================================================== +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + // //========================================================== @@ -2704,22 +9540,22 @@ // 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 2048 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -2742,6 +9578,7 @@ // //========================================================== + // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/src/apps/lora_tx_temperature/ISP4520/ses/flash_placement.xml b/src/apps/lora_tx_temperature/ISP4520/ses/flash_placement.xml index 91fbb42..8c8f579 100644 --- a/src/apps/lora_tx_temperature/ISP4520/ses/flash_placement.xml +++ b/src/apps/lora_tx_temperature/ISP4520/ses/flash_placement.xml @@ -5,9 +5,18 @@ + + + + + + + + + @@ -19,7 +28,10 @@ + + + diff --git a/src/apps/lora_tx_temperature/ISP4520/ses/tx-temperature.emProject b/src/apps/lora_tx_temperature/ISP4520/ses/tx-temperature.emProject new file mode 100644 index 0000000..7cf3459 --- /dev/null +++ b/src/apps/lora_tx_temperature/ISP4520/ses/tx-temperature.emProject @@ -0,0 +1,1871 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/apps/lora_tx_temperature/ISP4520/ses/tx_temperature.emProject b/src/apps/lora_tx_temperature/ISP4520/ses/tx_temperature.emProject deleted file mode 100644 index b9c8734..0000000 --- a/src/apps/lora_tx_temperature/ISP4520/ses/tx_temperature.emProject +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apps/lorawan_class_A/ISP4520/config/sdk_config.h b/src/apps/lorawan_class_A/ISP4520/config/sdk_config.h index 3fe27e6..9b4fb31 100644 --- a/src/apps/lorawan_class_A/ISP4520/config/sdk_config.h +++ b/src/apps/lorawan_class_A/ISP4520/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,868 +46,7032 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// nRF_BLE +// nRF_Core //========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 1 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 1 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif +// + // //========================================================== -// nRF_Drivers +// nRF_Crypto //========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 0 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). //========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Disabled -// <1=> Enabled -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <0=> Excluded -// <14=> Included -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. -// <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=> 1000000 baud -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -// 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 +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif -// UART0_ENABLED - Enable UART0 instance +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// - -// +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + -//========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 -#endif -// 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 6 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 2 +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. -// 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 +// CC310 backend implementation for hardware-accelerated SHA-256. -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + +// CC310 backend implementation for SHA-512 (in software). -// -//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif -// nRF_Libraries +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 #endif -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler -//========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 #endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. -#ifndef APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 #endif -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. -#ifndef APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif // -// APP_TIMER_ENABLED - app_timer - Application timer functionality +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. //========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 #endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. -// <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 31 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 #endif -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. -// 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 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 15 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. -#ifndef APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 #endif -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. -#ifndef APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 #endif -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. -// If option is enabled RTC is kept running even if there is no active timers. -// 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 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 #endif -// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. -// <0=> 0 -// <1=> 1 -#ifndef APP_TIMER_CONFIG_SWI_NUMBER -#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 #endif -// - -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 -#endif -// APP_UART_DRIVER_INSTANCE - UART instance used +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 #endif -// - -// CRC16_ENABLED - crc16 - CRC16 calculation routines +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef CRC16_ENABLED -#define CRC16_ENABLED 1 -#endif +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS -// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release -//========================================================== -#ifndef HARDFAULT_HANDLER_ENABLED -#define HARDFAULT_HANDLER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 #endif -// HARDFAULT_HANDLER_GDB_PSP_BACKTRACE - Bypass the GDB problem with multiple stack pointers backtrace + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -// There is a known bug in GDB which causes it to incorrectly backtrace the code -// when multiple stack pointers are used (main and process stack pointers). -// This option enables the fix for that problem and allows to see the proper backtrace info. -// It makes it possible to trace the code to the exact point where a HardFault appeared. -// This option requires additional commands and may temporarily switch MSP stack to store data on PSP space. -// This is an optional parameter - enable it while debugging. -// Before a HardFault handler exits, the stack will be reverted to its previous value. +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS -#ifndef HARDFAULT_HANDLER_GDB_PSP_BACKTRACE -#define HARDFAULT_HANDLER_GDB_PSP_BACKTRACE 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 #endif -// - -// FDS_ENABLED - fds - Flash data storage module -//========================================================== -#ifndef FDS_ENABLED -#define FDS_ENABLED 0 -#endif -// Pages - Virtual page settings +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + -// Configure the number of virtual pages to use and their size. -//========================================================== -// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. -// One of the virtual pages is reserved by the system for garbage collection. -// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. -// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS -#ifndef FDS_VIRTUAL_PAGES -#define FDS_VIRTUAL_PAGES 3 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 #endif -// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve -// Expressed in number of 4-byte words. -// By default, a virtual page is the same size as a physical page. -// The size of a virtual page must be a multiple of the size of a physical page. -// <1024=> 1024 -// <2048=> 2048 +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS -#ifndef FDS_VIRTUAL_PAGE_SIZE -#define FDS_VIRTUAL_PAGE_SIZE 2048 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 #endif -// -//========================================================== +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + -// Backend - Backend configuration +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS -// Configure which nrf_fstorage backend is used by FDS to write to flash. -//========================================================== -// FDS_BACKEND - FDS flash backend. +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve -// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. -// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. -// <1=> NRF_FSTORAGE_NVMC -// <2=> NRF_FSTORAGE_SD +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS -#ifndef FDS_BACKEND -#define FDS_BACKEND 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 #endif -// -//========================================================== - -// Queue - Queue settings +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + -//========================================================== -// FDS_OP_QUEUE_SIZE - Size of the internal queue. -// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS -#ifndef FDS_OP_QUEUE_SIZE -#define FDS_OP_QUEUE_SIZE 4 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 #endif -// -//========================================================== - -// CRC - CRC functionality +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + -//========================================================== -// FDS_CRC_CHECK_ON_READ - Enable CRC checks. +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS -// Save a record's CRC when it is written to flash and check it when the record is opened. -// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. -// Additionally, they will not be garbage collected until they are deleted. -//========================================================== -#ifndef FDS_CRC_CHECK_ON_READ -#define FDS_CRC_CHECK_ON_READ 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 #endif -// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve -// Perform a CRC check on newly written records. -// This setting can be used to make sure that the record data was not altered while being written to flash. -// <1=> Enabled -// <0=> Disabled +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS -#ifndef FDS_CRC_CHECK_ON_WRITE -#define FDS_CRC_CHECK_ON_WRITE 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 #endif -// - -// -//========================================================== +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + -// Users - Number of users +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS -//========================================================== -// FDS_MAX_USERS - Maximum number of callbacks that can be registered. -#ifndef FDS_MAX_USERS -#define FDS_MAX_USERS 4 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 #endif -// -//========================================================== +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 -#endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + +// mbed TLS backend implementation for SHA-256. -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 -#endif +// mbed TLS backend implementation for HMAC using SHA-512. -// +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif // -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 #endif -// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module -//========================================================== -#ifndef NRF_PWR_MGMT_ENABLED -#define NRF_PWR_MGMT_ENABLED 1 +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. -// Selected pin will be set when CPU is in sleep mode. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED -#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 #endif -// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <4294967295=> Not connected -#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN -#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 #endif // -// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. -// Module will trace percentage of CPU usage in one second intervals. +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. -#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED -#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). //========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). -// Shutdown procedure will begin no earlier than after this number of seconds. +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 #endif // -// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. -#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED -#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve -#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY -#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH -#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER -#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. -// The number of stages of the shutdown process. +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + -#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT -#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + -// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality -#ifndef NRF_SECTION_ITER_ENABLED -#define NRF_SECTION_ITER_ENABLED 1 +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 #endif -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 #endif -// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. //========================================================== -#ifndef NRF_FSTORAGE_ENABLED -#define NRF_FSTORAGE_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 #endif -// nrf_fstorage_sd - Implementation using the SoftDevice. +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + -// Configuration options for the fstorage implementation using the SoftDevice. -//========================================================== -// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations. -// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. +// The Optiga backend provide external chip RNG. -#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE -#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 #endif -// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy. -// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. -// The SoftDevice might fail to schedule flash access due to high BLE activity. +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + -#ifndef NRF_FSTORAGE_SD_MAX_RETRIES -#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 #endif -// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation. -// This value must be a multiple of four. -// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. -// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. -// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. +// -#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE -#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 #endif -// +// + +// nrf_crypto_rng - RNG Configuration + //========================================================== +// NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED - Use static memory buffers for context and temporary init buffer. + -// +// Always recommended when using the nRF HW RNG as the context and temporary buffers are small. Consider disabling if using the CC310 RNG in a RAM constrained application. In this case, memory must be provided to nrf_crypto_rng_init, or it can be allocated internally provided that NRF_CRYPTO_ALLOCATOR does not allocate memory on the stack. + +#ifndef NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED +#define NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED 1 +#endif + +// NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - Initialize the RNG module automatically when nrf_crypto is initialized. + + +// Automatic initialization is only supported with static or internally allocated context and temporary memory. + +#ifndef NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1 +#endif // //========================================================== -// nRF_Log +// +//========================================================== + +// nRF_Drivers //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer //========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef COMP_CONFIG_REF +#define COMP_CONFIG_REF 1 +#endif + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 #endif // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 3 +// 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 6 #endif -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority -// <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=> 1000000 baud -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +// 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 2 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// -#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 1 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 1 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 1 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 1 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 1 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 1 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 1 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 1 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 1 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 1 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 1 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 1 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 1 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 1 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 1 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 1 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 1 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 1 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 1 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 1 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SYSTICK_ENABLED - nrfx_systick - ARM(R) SysTick driver + + +#ifndef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED 0 +#endif + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 1 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 1 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 1 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 1 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 1 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 1 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 1 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 1 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 1 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 1 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 1 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 1 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 1 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 1 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 1 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 1 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 1 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 1 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 1 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 1 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SYSTICK_ENABLED - nrf_drv_systick - ARM(R) SysTick driver - legacy layer + + +#ifndef SYSTICK_ENABLED +#define SYSTICK_ENABLED 0 +#endif + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 1 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 1 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 1 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 1 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 1 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 1 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 1 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 1 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 1 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 31 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 1 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 1 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 1 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 1 +#endif + +// + +// + +// NRF_CLI_UART_ENABLED - nrf_cli_uart - UART command line interface transport + + +#ifndef NRF_CLI_UART_ENABLED +#define NRF_CLI_UART_ENABLED 0 +#endif + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 1 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 1 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 1 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 1 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 -// - -// nrf_log - Logger +// 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 -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 1 +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -919,11 +7083,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -935,11 +7118,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -951,13 +7134,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -965,110 +7153,152 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// MAX3421E_HOST_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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// MAX3421E_HOST_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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// NRFX_USBD_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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// NRFX_USBD_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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 #endif -// Log message pool - Configuration of log message pool +// +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// 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 NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== - -// +// 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 -// nrf_log module configuration +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif -//========================================================== -// nrf_log in nRF_Core +// +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// PPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1076,11 +7306,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1092,11 +7322,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1108,18 +7338,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// PWM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1127,11 +7357,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1143,11 +7373,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1159,18 +7389,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// QDEC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1178,11 +7408,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1194,11 +7424,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1210,24 +7440,18 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1235,11 +7459,11 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1251,11 +7475,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1267,18 +7491,25 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// 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 // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1286,11 +7517,11 @@ // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1302,11 +7533,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1318,18 +7549,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// SAADC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1337,11 +7568,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1353,11 +7584,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1369,18 +7600,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1388,11 +7619,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1404,11 +7635,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1420,18 +7651,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// SPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1439,11 +7670,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1455,11 +7686,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1471,18 +7702,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1490,11 +7721,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1506,11 +7737,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1522,18 +7753,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1541,11 +7772,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1557,11 +7788,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1573,18 +7804,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1592,11 +7823,11 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1608,11 +7839,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1624,18 +7855,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1643,11 +7874,11 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1659,11 +7890,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1675,18 +7906,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1694,11 +7925,11 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1710,11 +7941,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1726,18 +7957,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1745,11 +7976,11 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1761,11 +7992,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1777,25 +8008,24 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// +//========================================================== -// +// nrf_log in nRF_Libraries -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1803,11 +8033,27 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1819,11 +8065,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1835,18 +8081,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1854,11 +8100,27 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1870,11 +8132,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1886,18 +8148,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1905,11 +8167,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1921,11 +8183,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1937,18 +8199,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1956,11 +8218,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1972,11 +8234,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1988,18 +8250,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2007,11 +8269,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2023,11 +8285,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2039,18 +8301,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2058,11 +8320,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2074,11 +8336,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2090,18 +8352,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2109,11 +8371,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2125,11 +8387,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2141,18 +8403,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2160,11 +8422,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2176,11 +8450,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2192,18 +8466,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2211,11 +8485,27 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2227,11 +8517,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2243,18 +8533,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2262,11 +8552,23 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2278,11 +8580,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2294,18 +8596,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2313,11 +8615,23 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2329,11 +8643,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2345,24 +8659,30 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled // <0=> Off // <1=> Error @@ -2370,11 +8690,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2386,11 +8706,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2402,18 +8722,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2421,11 +8741,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2437,11 +8757,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2453,18 +8773,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2472,11 +8792,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2488,11 +8808,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2504,18 +8824,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2523,11 +8843,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2539,11 +8859,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2555,18 +8875,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2574,11 +8894,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2590,11 +8910,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2606,8 +8926,8 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // @@ -2714,6 +9034,69 @@ // +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + // NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== #ifndef NRF_SDH_ANT_LOG_ENABLED @@ -2768,7 +9151,7 @@ // NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== #ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#define NRF_SDH_BLE_LOG_ENABLED 0 #endif // NRF_SDH_BLE_LOG_LEVEL - Default Severity level @@ -2819,7 +9202,7 @@ // NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== #ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#define NRF_SDH_LOG_ENABLED 0 #endif // NRF_SDH_LOG_LEVEL - Default Severity level @@ -2870,7 +9253,7 @@ // NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== #ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#define NRF_SDH_SOC_LOG_ENABLED 0 #endif // NRF_SDH_SOC_LOG_LEVEL - Default Severity level @@ -2969,15 +9352,180 @@ // +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== // //========================================================== +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + // //========================================================== @@ -2992,22 +9540,22 @@ // 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 2048 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -3030,6 +9578,7 @@ // //========================================================== + // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/src/apps/lorawan_class_A/ISP4520/ses/class-A.emProject b/src/apps/lorawan_class_A/ISP4520/ses/class-A.emProject new file mode 100644 index 0000000..f52932f --- /dev/null +++ b/src/apps/lorawan_class_A/ISP4520/ses/class-A.emProject @@ -0,0 +1,1973 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/apps/lorawan_class_A/ISP4520/ses/class_A.emProject b/src/apps/lorawan_class_A/ISP4520/ses/class_A.emProject deleted file mode 100644 index dece09a..0000000 --- a/src/apps/lorawan_class_A/ISP4520/ses/class_A.emProject +++ /dev/null @@ -1,796 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apps/lorawan_class_A/ISP4520/ses/flash_placement.xml b/src/apps/lorawan_class_A/ISP4520/ses/flash_placement.xml index a74ed6a..8c8f579 100644 --- a/src/apps/lorawan_class_A/ISP4520/ses/flash_placement.xml +++ b/src/apps/lorawan_class_A/ISP4520/ses/flash_placement.xml @@ -5,11 +5,18 @@ - + + + + + + + + @@ -23,6 +30,8 @@ + + diff --git a/src/apps/lorawan_class_C/ISP4520/config/sdk_config.h b/src/apps/lorawan_class_C/ISP4520/config/sdk_config.h index f5083c0..9b4fb31 100644 --- a/src/apps/lorawan_class_C/ISP4520/config/sdk_config.h +++ b/src/apps/lorawan_class_C/ISP4520/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,846 +46,7032 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// nRF_BLE +// nRF_Core //========================================================== -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 1 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 1 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif +// + // //========================================================== -// nRF_Drivers +// nRF_Crypto //========================================================== -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 0 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). //========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Disabled -// <1=> Enabled -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <0=> Excluded -// <14=> Included -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. -// <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=> 1000000 baud -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -// 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 +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif -// UART0_ENABLED - Enable UART0 instance +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + -// +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif -//========================================================== -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// 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 6 + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. -// 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 NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// SPI_DEFAULT_FREQUENCY - SPI frequency +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz -#ifndef SPI_DEFAULT_FREQUENCY -#define SPI_DEFAULT_FREQUENCY 1073741824 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 1 +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. -// <0=> Default (64 MHz) -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality -// <0=> RC -// <1=> XTAL -// <2=> Synth -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 #endif -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 -// 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 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 7 +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + +// CC310 backend implementation for HMAC using SHA-512 (in software). -// -//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif -// nRF_Libraries +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + -//========================================================== -// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. -#ifndef APP_FIFO_ENABLED -#define APP_FIFO_ENABLED 1 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 #endif -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. //========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 #endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. -#ifndef APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. -#ifndef APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + -// APP_TIMER_ENABLED - app_timer - Application timer functionality -//========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. -// <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 31 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. -// 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 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 #endif -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 15 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 #endif -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. -#ifndef APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 #endif -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. -#ifndef APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 #endif -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. -// If option is enabled RTC is kept running even if there is no active timers. -// 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 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 #endif -// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -// <0=> 0 -// <1=> 1 - -#ifndef APP_TIMER_CONFIG_SWI_NUMBER -#define APP_TIMER_CONFIG_SWI_NUMBER 0 -#endif -// +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 #endif -// APP_UART_DRIVER_INSTANCE - UART instance used + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 -#endif +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS -// +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif -// CRC16_ENABLED - crc16 - CRC16 calculation routines +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve -#ifndef CRC16_ENABLED -#define CRC16_ENABLED 1 -#endif +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS -// FDS_ENABLED - fds - Flash data storage module -//========================================================== -#ifndef FDS_ENABLED -#define FDS_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 #endif -// Pages - Virtual page settings -// Configure the number of virtual pages to use and their size. -//========================================================== -// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. -// One of the virtual pages is reserved by the system for garbage collection. -// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. -// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + -#ifndef FDS_VIRTUAL_PAGES -#define FDS_VIRTUAL_PAGES 3 +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 #endif -// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve -// Expressed in number of 4-byte words. -// By default, a virtual page is the same size as a physical page. -// The size of a virtual page must be a multiple of the size of a physical page. -// <1024=> 1024 -// <2048=> 2048 +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS -#ifndef FDS_VIRTUAL_PAGE_SIZE -#define FDS_VIRTUAL_PAGE_SIZE 2048 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 #endif -// -//========================================================== - -// Backend - Backend configuration - -// Configure which nrf_fstorage backend is used by FDS to write to flash. -//========================================================== -// FDS_BACKEND - FDS flash backend. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve -// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. -// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. -// <1=> NRF_FSTORAGE_NVMC -// <2=> NRF_FSTORAGE_SD +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS -#ifndef FDS_BACKEND -#define FDS_BACKEND 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 #endif -// -//========================================================== - -// Queue - Queue settings +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + -//========================================================== -// FDS_OP_QUEUE_SIZE - Size of the internal queue. -// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS -#ifndef FDS_OP_QUEUE_SIZE -#define FDS_OP_QUEUE_SIZE 4 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 #endif -// -//========================================================== - -// CRC - CRC functionality +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + -//========================================================== -// FDS_CRC_CHECK_ON_READ - Enable CRC checks. +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS -// Save a record's CRC when it is written to flash and check it when the record is opened. -// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. -// Additionally, they will not be garbage collected until they are deleted. -//========================================================== -#ifndef FDS_CRC_CHECK_ON_READ -#define FDS_CRC_CHECK_ON_READ 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 #endif -// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve -// Perform a CRC check on newly written records. -// This setting can be used to make sure that the record data was not altered while being written to flash. -// <1=> Enabled -// <0=> Disabled +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS -#ifndef FDS_CRC_CHECK_ON_WRITE -#define FDS_CRC_CHECK_ON_WRITE 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 #endif -// - -// -//========================================================== +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + -// Users - Number of users +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS -//========================================================== -// FDS_MAX_USERS - Maximum number of callbacks that can be registered. -#ifndef FDS_MAX_USERS -#define FDS_MAX_USERS 4 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 #endif -// -//========================================================== +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 -#endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + +// mbed TLS backend implementation for SHA-256. -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 -#endif +// mbed TLS backend implementation for HMAC using SHA-512. -// +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif // -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 #endif -// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module -//========================================================== -#ifndef NRF_PWR_MGMT_ENABLED -#define NRF_PWR_MGMT_ENABLED 1 +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. -// Selected pin will be set when CPU is in sleep mode. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED -#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 #endif -// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <4294967295=> Not connected -#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN -#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 #endif // -// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. -// Module will trace percentage of CPU usage in one second intervals. +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. -#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED -#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). //========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). -// Shutdown procedure will begin no earlier than after this number of seconds. +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 #endif // -// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 1 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. -#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED -#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve -#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY -#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH -#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER -#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 #endif -// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. -// The number of stages of the shutdown process. +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + -#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT -#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + -// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality -#ifndef NRF_SECTION_ITER_ENABLED -#define NRF_SECTION_ITER_ENABLED 1 +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 #endif -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 #endif -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 #endif -// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. //========================================================== -#ifndef NRF_FSTORAGE_ENABLED -#define NRF_FSTORAGE_ENABLED 1 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 #endif -// nrf_fstorage_sd - Implementation using the SoftDevice. +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + -// Configuration options for the fstorage implementation using the SoftDevice. -//========================================================== -// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations. -// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. +// The Optiga backend provide external chip RNG. -#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE -#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 #endif -// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy. -// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. -// The SoftDevice might fail to schedule flash access due to high BLE activity. +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + -#ifndef NRF_FSTORAGE_SD_MAX_RETRIES -#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 #endif -// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation. -// This value must be a multiple of four. -// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. -// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. -// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. +// -#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE -#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 #endif -// +// + +// nrf_crypto_rng - RNG Configuration + //========================================================== +// NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED - Use static memory buffers for context and temporary init buffer. + -// +// Always recommended when using the nRF HW RNG as the context and temporary buffers are small. Consider disabling if using the CC310 RNG in a RAM constrained application. In this case, memory must be provided to nrf_crypto_rng_init, or it can be allocated internally provided that NRF_CRYPTO_ALLOCATOR does not allocate memory on the stack. + +#ifndef NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED +#define NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED 1 +#endif + +// NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - Initialize the RNG module automatically when nrf_crypto is initialized. + + +// Automatic initialization is only supported with static or internally allocated context and temporary memory. + +#ifndef NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1 +#endif // //========================================================== -// nRF_Log +// +//========================================================== + +// nRF_Drivers //========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer //========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#ifndef COMP_CONFIG_REF +#define COMP_CONFIG_REF 1 +#endif + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 #endif // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 3 +// 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 6 #endif -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority -// <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=> 1000000 baud -#ifndef NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +// 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 2 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// -#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 1 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 1 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 1 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 1 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_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 NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 1 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 1 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 1 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 1 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 1 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 1 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 1 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 1 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 1 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 1 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 1 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 1 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 1 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 1 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 1 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 1 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SYSTICK_ENABLED - nrfx_systick - ARM(R) SysTick driver + + +#ifndef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED 0 +#endif + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 1 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 1 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 1 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 1 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 1 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 1 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 1 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 1 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 1 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 1 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 1 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 1 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 1 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 1 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 1 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 1 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 1 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 1 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 1 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 1 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 1 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 1 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 0 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SYSTICK_ENABLED - nrf_drv_systick - ARM(R) SysTick driver - legacy layer + + +#ifndef SYSTICK_ENABLED +#define SYSTICK_ENABLED 0 +#endif + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 1 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 1 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 1 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 1 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 1 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 1 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 1 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 1 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 1 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_FIFO_ENABLED - app_fifo - Software FIFO implementation + + +#ifndef APP_FIFO_ENABLED +#define APP_FIFO_ENABLED 1 +#endif + +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// 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 31 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 1 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_UART_ENABLED - app_uart - UART driver +//========================================================== +#ifndef APP_UART_ENABLED +#define APP_UART_ENABLED 1 +#endif +// APP_UART_DRIVER_INSTANCE - UART instance used + +// <0=> 0 + +#ifndef APP_UART_DRIVER_INSTANCE +#define APP_UART_DRIVER_INSTANCE 0 +#endif + +// + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 1 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 1 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 1 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 1 +#endif + +// + +// + +// NRF_CLI_UART_ENABLED - nrf_cli_uart - UART command line interface transport + + +#ifndef NRF_CLI_UART_ENABLED +#define NRF_CLI_UART_ENABLED 0 +#endif + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 1 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 1 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 1 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 0 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_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=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 1 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 1 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 -// - -// nrf_log - Logger +// 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 -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 -#endif -// 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 1 +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -897,11 +7083,30 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -913,11 +7118,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -929,13 +7134,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -943,110 +7153,152 @@ // <3=> Info // <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 4 +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// MAX3421E_HOST_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 -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). +// MAX3421E_HOST_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 -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 #endif -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +// -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 #endif - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// Function for getting the timestamp is provided by the user - -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// NRFX_USBD_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 NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// NRFX_USBD_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 NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 #endif -// Log message pool - Configuration of log message pool +// +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// 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 NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== - -// +// 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 -// nrf_log module configuration +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif -//========================================================== -// nrf_log in nRF_Core +// +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// PPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1054,11 +7306,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 #endif -// NRF_MPU_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1070,11 +7322,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1086,18 +7338,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level +// PWM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1105,11 +7357,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1121,11 +7373,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1137,18 +7389,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 #endif // -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level +// QDEC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1156,11 +7408,11 @@ // <3=> Info // <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1172,11 +7424,11 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1188,24 +7440,18 @@ // <7=> Cyan // <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 #endif // -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1213,11 +7459,11 @@ // <3=> Info // <4=> Debug -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1229,11 +7475,11 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1245,18 +7491,25 @@ // <7=> Cyan // <8=> White -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// 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 // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// RTC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1264,11 +7517,11 @@ // <3=> Info // <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1280,11 +7533,11 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1296,18 +7549,18 @@ // <7=> Cyan // <8=> White -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 #endif // -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 #endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level +// SAADC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1315,11 +7568,11 @@ // <3=> Info // <4=> Debug -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 #endif -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1331,11 +7584,11 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1347,18 +7600,18 @@ // <7=> Cyan // <8=> White -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1366,11 +7619,11 @@ // <3=> Info // <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1382,11 +7635,11 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1398,18 +7651,18 @@ // <7=> Cyan // <8=> White -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// SPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1417,11 +7670,11 @@ // <3=> Info // <4=> Debug -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1433,11 +7686,11 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1449,18 +7702,18 @@ // <7=> Cyan // <8=> White -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 #endif // -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 #endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1468,11 +7721,11 @@ // <3=> Info // <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1484,11 +7737,11 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1500,18 +7753,18 @@ // <7=> Cyan // <8=> White -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 #endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TWIS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1519,11 +7772,11 @@ // <3=> Info // <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1535,11 +7788,11 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1551,18 +7804,18 @@ // <7=> Cyan // <8=> White -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1570,11 +7823,11 @@ // <3=> Info // <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1586,11 +7839,11 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1602,18 +7855,18 @@ // <7=> Cyan // <8=> White -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 #endif // -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 #endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level +// UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1621,11 +7874,11 @@ // <3=> Info // <4=> Debug -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1637,11 +7890,11 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1653,18 +7906,18 @@ // <7=> Cyan // <8=> White -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1672,11 +7925,11 @@ // <3=> Info // <4=> Debug -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1688,11 +7941,11 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1704,18 +7957,18 @@ // <7=> Cyan // <8=> White -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 #endif // -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1723,11 +7976,11 @@ // <3=> Info // <4=> Debug -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1739,11 +7992,11 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 #endif -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1755,25 +8008,24 @@ // <7=> Cyan // <8=> White -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// +//========================================================== -// +// nrf_log in nRF_Libraries -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1781,11 +8033,27 @@ // <3=> Info // <4=> Debug -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1797,11 +8065,11 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1813,18 +8081,18 @@ // <7=> Cyan // <8=> White -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 #endif // -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1832,11 +8100,27 @@ // <3=> Info // <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1848,11 +8132,11 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1864,18 +8148,18 @@ // <7=> Cyan // <8=> White -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1883,11 +8167,11 @@ // <3=> Info // <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1899,11 +8183,11 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1915,18 +8199,18 @@ // <7=> Cyan // <8=> White -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1934,11 +8218,11 @@ // <3=> Info // <4=> Debug -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 #endif -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1950,11 +8234,11 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -1966,18 +8250,18 @@ // <7=> Cyan // <8=> White -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 #endif -// SWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -1985,11 +8269,11 @@ // <3=> Info // <4=> Debug -#ifndef SWI_CONFIG_LOG_LEVEL -#define SWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 #endif -// SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2001,11 +8285,11 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_INFO_COLOR -#define SWI_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 #endif -// SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2017,18 +8301,18 @@ // <7=> Cyan // <8=> White -#ifndef SWI_CONFIG_DEBUG_COLOR -#define SWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 #endif // -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 #endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2036,11 +8320,11 @@ // <3=> Info // <4=> Debug -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 4 +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 #endif -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2052,11 +8336,11 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 #endif -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2068,18 +8352,18 @@ // <7=> Cyan // <8=> White -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 #endif // -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2087,11 +8371,11 @@ // <3=> Info // <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2103,11 +8387,11 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2119,18 +8403,18 @@ // <7=> Cyan // <8=> White -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2138,11 +8422,23 @@ // <3=> Info // <4=> Debug -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2154,11 +8450,11 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2170,18 +8466,18 @@ // <7=> Cyan // <8=> White -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2189,11 +8485,27 @@ // <3=> Info // <4=> Debug -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2205,11 +8517,11 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 #endif -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2221,18 +8533,18 @@ // <7=> Cyan // <8=> White -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 #endif // -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2240,11 +8552,23 @@ // <3=> Info // <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 #endif -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2256,11 +8580,11 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2272,18 +8596,18 @@ // <7=> Cyan // <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 #endif // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2291,11 +8615,23 @@ // <3=> Info // <4=> Debug -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 #endif -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2307,11 +8643,11 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2323,24 +8659,30 @@ // <7=> Cyan // <8=> White -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 #endif // -// +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// nrf_log in nRF_Libraries - -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled // <0=> Off // <1=> Error @@ -2348,11 +8690,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2364,11 +8706,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2380,18 +8722,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 #endif // -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2399,11 +8741,11 @@ // <3=> Info // <4=> Debug -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2415,11 +8757,11 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2431,18 +8773,18 @@ // <7=> Cyan // <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2450,11 +8792,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2466,11 +8808,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2482,18 +8824,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2501,11 +8843,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2517,11 +8859,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2533,18 +8875,18 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -2552,11 +8894,11 @@ // <3=> Info // <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2568,11 +8910,11 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -2584,8 +8926,8 @@ // <7=> Cyan // <8=> White -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 #endif // @@ -2692,6 +9034,69 @@ // +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + // NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. //========================================================== #ifndef NRF_SDH_ANT_LOG_ENABLED @@ -2746,7 +9151,7 @@ // NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. //========================================================== #ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#define NRF_SDH_BLE_LOG_ENABLED 0 #endif // NRF_SDH_BLE_LOG_LEVEL - Default Severity level @@ -2797,7 +9202,7 @@ // NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. //========================================================== #ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 +#define NRF_SDH_LOG_ENABLED 0 #endif // NRF_SDH_LOG_LEVEL - Default Severity level @@ -2848,7 +9253,7 @@ // NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== #ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 +#define NRF_SDH_SOC_LOG_ENABLED 0 #endif // NRF_SDH_SOC_LOG_LEVEL - Default Severity level @@ -2947,15 +9352,180 @@ // +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + // //========================================================== // //========================================================== +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + // //========================================================== @@ -2970,22 +9540,22 @@ // 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 2048 +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 #endif -// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 #endif -// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS -#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3 +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 #endif // SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. @@ -3008,6 +9578,7 @@ // //========================================================== + // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/src/apps/lorawan_class_C/ISP4520/ses/class-C.emProject b/src/apps/lorawan_class_C/ISP4520/ses/class-C.emProject new file mode 100644 index 0000000..0e6fe68 --- /dev/null +++ b/src/apps/lorawan_class_C/ISP4520/ses/class-C.emProject @@ -0,0 +1,1973 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/apps/lorawan_class_C/ISP4520/ses/class_C.emProject b/src/apps/lorawan_class_C/ISP4520/ses/class_C.emProject deleted file mode 100644 index 2bf82e5..0000000 --- a/src/apps/lorawan_class_C/ISP4520/ses/class_C.emProject +++ /dev/null @@ -1,801 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apps/lorawan_class_C/ISP4520/ses/flash_placement.xml b/src/apps/lorawan_class_C/ISP4520/ses/flash_placement.xml index a74ed6a..8c8f579 100644 --- a/src/apps/lorawan_class_C/ISP4520/ses/flash_placement.xml +++ b/src/apps/lorawan_class_C/ISP4520/ses/flash_placement.xml @@ -5,11 +5,18 @@ - + + + + + + + + @@ -23,6 +30,8 @@ + + diff --git a/src/lora/boards/ISP4520B-AS/spi-board.c b/src/lora/boards/ISP4520B-AS/spi-board.c index 7dc8bc4..62e076b 100644 --- a/src/lora/boards/ISP4520B-AS/spi-board.c +++ b/src/lora/boards/ISP4520B-AS/spi-board.c @@ -1,3 +1,6 @@ + + + /*! * \file spi-board.c * diff --git a/src/lora/boards/ISP4520B-AS/sx126x-board.c b/src/lora/boards/ISP4520B-AS/sx126x-board.c index 9db7718..957cc56 100644 --- a/src/lora/boards/ISP4520B-AS/sx126x-board.c +++ b/src/lora/boards/ISP4520B-AS/sx126x-board.c @@ -1,3 +1,13 @@ + + + + + + + + + + /****************************************************************************** * @file sx126x-board.c * @author Insight SiP diff --git a/src/lora/misc/LoRaMacHelper.h b/src/lora/misc/LoRaMacHelper.h index 1cc93db..32acbda 100644 --- a/src/lora/misc/LoRaMacHelper.h +++ b/src/lora/misc/LoRaMacHelper.h @@ -29,7 +29,7 @@ #define LORAWAN_CONFIRMED_MSG_ON 0 /**< LoRaWAN confirmed messages */ #define LORAWAN_CERTIF_PORT 224 /**< LoRaWAN certification port */ -#define LORAWAN_CERTIF_DELAY 5000 /**< LoRaWAN certification delay */ +#define LORAWAN_CERTIF_DELAY 5000 /**< LoRaWAN certification delay */ #define LORAWAN_APP_DATA_MAX_SIZE 242 /**< LoRaWAN User application data buffer size*/ #define LORAWAN_DEFAULT_DATARATE DR_0 /**< LoRaWAN Default datarate*/ #define LORAWAN_DEFAULT_TX_POWER TX_POWER_0 /**< LoRaWAN Default tx power*/ diff --git a/src/lora/system/soft-se/aes.c b/src/lora/system/soft-se/lora_aes.c similarity index 99% rename from src/lora/system/soft-se/aes.c rename to src/lora/system/soft-se/lora_aes.c index 7f46ea3..378923c 100644 --- a/src/lora/system/soft-se/aes.c +++ b/src/lora/system/soft-se/lora_aes.c @@ -62,7 +62,7 @@ # define VERSION_1 #endif -#include "aes.h" +#include "lora_aes.h" //#if defined( HAVE_UINT_32T ) // typedef unsigned long uint32_t; diff --git a/src/lora/system/soft-se/aes.h b/src/lora/system/soft-se/lora_aes.h similarity index 100% rename from src/lora/system/soft-se/aes.h rename to src/lora/system/soft-se/lora_aes.h diff --git a/src/lora/system/soft-se/cmac.c b/src/lora/system/soft-se/lora_cmac.c similarity index 99% rename from src/lora/system/soft-se/cmac.c rename to src/lora/system/soft-se/lora_cmac.c index 9ea1a42..75f0497 100644 --- a/src/lora/system/soft-se/cmac.c +++ b/src/lora/system/soft-se/lora_cmac.c @@ -35,8 +35,8 @@ DEALINGS WITH THE SOFTWARE //#include //#include #include -#include "aes.h" -#include "cmac.h" +#include "lora_aes.h" +#include "lora_cmac.h" #include "utilities.h" #define LSHIFT(v, r) do { \ diff --git a/src/lora/system/soft-se/cmac.h b/src/lora/system/soft-se/lora_cmac.h similarity index 99% rename from src/lora/system/soft-se/cmac.h rename to src/lora/system/soft-se/lora_cmac.h index 6ebccd8..c16a5b1 100644 --- a/src/lora/system/soft-se/cmac.h +++ b/src/lora/system/soft-se/lora_cmac.h @@ -40,7 +40,7 @@ DEALINGS WITH THE SOFTWARE extern "C" #endif -#include "aes.h" +#include "lora_aes.h" #define AES_CMAC_KEY_LENGTH 16 #define AES_CMAC_DIGEST_LENGTH 16 diff --git a/src/lora/system/soft-se/soft-se.c b/src/lora/system/soft-se/soft-se.c index d170ac0..83866bf 100644 --- a/src/lora/system/soft-se/soft-se.c +++ b/src/lora/system/soft-se/soft-se.c @@ -25,8 +25,8 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ), #include "LoRaMacCrypto.h" #include "utilities.h" -#include "aes.h" -#include "cmac.h" +#include "lora_aes.h" +#include "lora_cmac.h" #include "radio.h" #define NUM_OF_KEYS 24 diff --git a/src/nordic_sdk/Extract nRF5_SDK_14.2.0_17b948a here.txt b/src/nordic_sdk/Extract nRF5_SDK_14.2.0_17b948a here.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.c deleted file mode 100644 index 1cb77cd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.c +++ /dev/null @@ -1,695 +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(BLE_ADVERTISING) -#include "ble_advdata.h" -#include "ble_advertising.h" -#include "nrf_soc.h" -#include "nrf_log.h" -#include "nrf_fstorage.h" -#include "sdk_errors.h" -#include "nrf_sdh_ble.h" -#include "nrf_sdh_soc.h" - -#define BLE_ADV_MODES (5) /**< Total number of possible advertising modes. */ - - -#if (NRF_SD_BLE_API_VERSION <= 2) - - static bool whitelist_has_entries(ble_advertising_t * const p_advertising) - { - return ((p_advertising->whitelist.addr_count != 0) || (p_advertising->whitelist.irk_count != 0)); - } - -#else - - static bool whitelist_has_entries(ble_advertising_t * const p_advertising) - { - return p_advertising->whitelist_in_use; - } - -#endif - - - -/**@brief Function for checking if an address is valid. - */ -static bool addr_is_valid(uint8_t const * const addr) -{ - for (uint32_t i = 0; i < BLE_GAP_ADDR_LEN; i++) - { - if (addr[i] != 0) - { - return true; - } - } - return false; -} - - -static ble_adv_mode_t adv_mode_next_get(ble_adv_mode_t adv_mode) -{ - return (ble_adv_mode_t)((adv_mode + 1) % BLE_ADV_MODES); -} - - -/**@brief Function for handling the Connected event. - * - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_connected(ble_advertising_t * const p_advertising, ble_evt_t const * p_ble_evt) -{ - if (p_ble_evt->evt.gap_evt.params.connected.role == BLE_GAP_ROLE_PERIPH) - { - p_advertising->current_slave_link_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - } -} - - -/**@brief Function for handling the Disconnected event. - * - * @param[in] p_advertising Advertising module instance. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_disconnected(ble_advertising_t * const p_advertising, ble_evt_t const * p_ble_evt) -{ - uint32_t ret; - - p_advertising->whitelist_temporarily_disabled = false; - - if (p_ble_evt->evt.gap_evt.conn_handle == p_advertising->current_slave_link_conn_handle && - p_advertising->adv_modes_config.ble_adv_on_disconnect_disabled == false) - { - ret = ble_advertising_start(p_advertising, BLE_ADV_MODE_DIRECTED); - if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) - { - p_advertising->error_handler(ret); - } - } -} - - -/**@brief Function for handling the Timeout event. - * - * @param[in] p_advertising Advertising module instance. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_timeout(ble_advertising_t * const p_advertising, ble_evt_t const * p_ble_evt) -{ - ret_code_t ret; - - if (p_ble_evt->evt.gap_evt.params.timeout.src != BLE_GAP_TIMEOUT_SRC_ADVERTISING) - { - // Nothing to do. - return; - } - - // Start advertising in the next mode. - ret = ble_advertising_start(p_advertising, adv_mode_next_get(p_advertising->adv_mode_current)); - - if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) - { - p_advertising->error_handler(ret); - } -} - - -/** @brief Function to determine if a flash write operation in in progress. - * - * @return true if a flash operation is in progress, false if not. - */ -static bool flash_access_in_progress() -{ - return nrf_fstorage_is_busy(NULL); -} - - -/**@brief Get the next available advertising mode. - * - * @param[in] p_advertising Advertising module instance. - * @param[in] adv_mode Requested advertising mode. - * - * @returns adv_mode if possible, or the best available mode if not. - */ -static ble_adv_mode_t adv_mode_next_avail_get(ble_advertising_t * const p_advertising, - ble_adv_mode_t adv_mode) -{ - bool peer_addr_is_valid = addr_is_valid(p_advertising->peer_address.addr); - - // If a mode is disabled, continue to the next mode. - - switch (adv_mode) - { - case BLE_ADV_MODE_DIRECTED: - if ((p_advertising->adv_modes_config.ble_adv_directed_enabled) && peer_addr_is_valid) - { - return BLE_ADV_MODE_DIRECTED; - } - // Fallthrough. - - case BLE_ADV_MODE_DIRECTED_SLOW: - if ((p_advertising->adv_modes_config.ble_adv_directed_slow_enabled) && peer_addr_is_valid) - { - return BLE_ADV_MODE_DIRECTED_SLOW; - } - // Fallthrough. - - case BLE_ADV_MODE_FAST: - if (p_advertising->adv_modes_config.ble_adv_fast_enabled) - { - return BLE_ADV_MODE_FAST; - } - // Fallthrough. - - case BLE_ADV_MODE_SLOW: - if (p_advertising->adv_modes_config.ble_adv_slow_enabled) - { - return BLE_ADV_MODE_SLOW; - } - // Fallthrough. - - default: - return BLE_ADV_MODE_IDLE; - } -} - - -/**@brief Function for starting directed advertising. - * - * @param[in] p_advertising Advertising instance. - * @param[out] p_adv_params Advertising parameters. - * - * @return NRF_SUCCESS - */ -static ret_code_t set_adv_mode_directed(ble_advertising_t * const p_advertising, - ble_gap_adv_params_t * p_adv_params) -{ - p_advertising->adv_evt = BLE_ADV_EVT_DIRECTED; - - p_adv_params->p_peer_addr = &(p_advertising->peer_address); - p_adv_params->type = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND; - p_adv_params->timeout = 0; - p_adv_params->interval = 0; - - return NRF_SUCCESS; -} - - -/**@brief Function for starting directed slow advertising. - * - * @param[in] p_advertising Advertising module instance. - * @param[out] p_adv_params Advertising parameters. - * - * @return NRF_SUCCESS - */ -static ret_code_t set_adv_mode_directed_slow(ble_advertising_t * const p_advertising, - ble_gap_adv_params_t * p_adv_params) -{ - p_advertising->adv_evt = BLE_ADV_EVT_DIRECTED_SLOW; - - p_adv_params->p_peer_addr = &p_advertising->peer_address; - p_adv_params->type = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND; - p_adv_params->timeout = p_advertising->adv_modes_config.ble_adv_directed_slow_timeout; - p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_directed_slow_interval; - - return NRF_SUCCESS; -} - - -/**@brief Function for starting fast advertising. - * - * @param[in] p_advertising Advertising module instance. - * @param[out] p_adv_params Advertising parameters. - * - * @return NRF_SUCCESS or an error from @ref ble_advdata_set(). - */ -static ret_code_t set_adv_mode_fast(ble_advertising_t * const p_advertising, - ble_gap_adv_params_t * p_adv_params) -{ - ret_code_t ret; - - p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_fast_interval; - p_adv_params->timeout = p_advertising->adv_modes_config.ble_adv_fast_timeout; - - if ((p_advertising->adv_modes_config.ble_adv_whitelist_enabled) && - (!p_advertising->whitelist_temporarily_disabled) && - (whitelist_has_entries(p_advertising))) - { - #if (NRF_SD_BLE_API_VERSION <= 2) - p_adv_params->p_whitelist = &m_whitelist; - #endif - - p_adv_params->fp = BLE_GAP_ADV_FP_FILTER_CONNREQ; - p_advertising->advdata.flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; - - ret = ble_advdata_set(&(p_advertising->advdata), NULL); - if (ret != NRF_SUCCESS) - { - return ret; - } - - p_advertising->adv_evt = BLE_ADV_EVT_FAST_WHITELIST; - } - else - { - p_advertising->adv_evt = BLE_ADV_EVT_FAST; - } - - return NRF_SUCCESS; -} - - -/**@brief Function for starting slow advertising. - * - * @param[in] p_advertising Advertising module instance. - * @param[out] p_adv_params Advertising parameters. - * - * @return NRF_SUCCESS or an error from @ref ble_advdata_set(). - */ -static ret_code_t set_adv_mode_slow(ble_advertising_t * const p_advertising, - ble_gap_adv_params_t * p_adv_params) -{ - ret_code_t ret; - - p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_slow_interval; - p_adv_params->timeout = p_advertising->adv_modes_config.ble_adv_slow_timeout; - - if ((p_advertising->adv_modes_config.ble_adv_whitelist_enabled) && - (!p_advertising->whitelist_temporarily_disabled) && - (whitelist_has_entries(p_advertising))) - { - #if (NRF_SD_BLE_API_VERSION <= 2) - { - p_adv_params->p_whitelist = &p_advertising->whitelist; - } - #endif - - p_adv_params->fp = BLE_GAP_ADV_FP_FILTER_CONNREQ; - p_advertising->advdata.flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; - - ret = ble_advdata_set(&(p_advertising->advdata), NULL); - if (ret != NRF_SUCCESS) - { - return ret; - } - - p_advertising->adv_evt = BLE_ADV_EVT_SLOW_WHITELIST; - } - else - { - p_advertising->adv_evt = BLE_ADV_EVT_SLOW; - } - - return NRF_SUCCESS; -} - - -void ble_advertising_conn_cfg_tag_set(ble_advertising_t * const p_advertising, - uint8_t ble_cfg_tag) -{ - p_advertising->conn_cfg_tag = ble_cfg_tag; -} - - -uint32_t ble_advertising_init(ble_advertising_t * const p_advertising, - ble_advertising_init_t const * const p_init) -{ - uint32_t ret; - if ((p_init == NULL) || (p_advertising == NULL)) - { - return NRF_ERROR_NULL; - } - - p_advertising->initialized = true; - p_advertising->adv_mode_current = BLE_ADV_MODE_IDLE; - p_advertising->adv_modes_config = p_init->config; - p_advertising->conn_cfg_tag = BLE_CONN_CFG_TAG_DEFAULT; - p_advertising->evt_handler = p_init->evt_handler; - p_advertising->error_handler = p_init->error_handler; - p_advertising->current_slave_link_conn_handle = BLE_CONN_HANDLE_INVALID; - - memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address)); - memset(&p_advertising->advdata, 0, sizeof(p_advertising->advdata)); - - // Copy advertising data. - p_advertising->advdata.name_type = p_init->advdata.name_type; - p_advertising->advdata.include_appearance = p_init->advdata.include_appearance; - p_advertising->advdata.flags = p_init->advdata.flags; - p_advertising->advdata.short_name_len = p_init->advdata.short_name_len; - - p_advertising->advdata.uuids_complete = p_init->advdata.uuids_complete; - p_advertising->advdata.uuids_more_available = p_init->advdata.uuids_more_available; - p_advertising->advdata.uuids_solicited = p_init->advdata.uuids_solicited; - p_advertising->advdata.include_ble_device_addr = p_init->advdata.include_ble_device_addr; - - if (p_init->advdata.p_manuf_specific_data != NULL) - { - p_advertising->advdata.p_manuf_specific_data = &(p_advertising->manuf_specific_data); - p_advertising->manuf_specific_data.data.p_data = p_advertising->manuf_data_array; - p_advertising->advdata.p_manuf_specific_data->company_identifier = - p_init->advdata.p_manuf_specific_data->company_identifier; - p_advertising->advdata.p_manuf_specific_data->data.size = p_init->advdata.p_manuf_specific_data->data.size; - - for (uint32_t i = 0; i < p_advertising->advdata.p_manuf_specific_data->data.size; i++) - { - p_advertising->manuf_data_array[i] = p_init->advdata.p_manuf_specific_data->data.p_data[i]; - } - } - - if (p_init->advdata.p_service_data_array != NULL) - { - p_advertising->service_data.data.p_data = p_advertising->service_data_array; - p_advertising->advdata.p_service_data_array = &(p_advertising->service_data); - p_advertising->advdata.p_service_data_array->data.p_data = p_advertising->service_data_array; - p_advertising->advdata.p_service_data_array->data.size = p_init->advdata.p_service_data_array->data.size; - p_advertising->advdata.p_service_data_array->service_uuid = p_init->advdata.p_service_data_array->service_uuid; - - for (uint32_t i = 0; i < p_advertising->advdata.p_service_data_array->data.size; i++) - { - p_advertising->service_data_array[i] = p_init->advdata.p_service_data_array->data.p_data[i]; - } - - p_advertising->advdata.service_data_count = p_init->advdata.service_data_count; - } - - if (p_init->advdata.p_slave_conn_int != NULL) - { - p_advertising->advdata.p_slave_conn_int = &(p_advertising->slave_conn_int); - p_advertising->advdata.p_slave_conn_int->max_conn_interval = p_init->advdata.p_slave_conn_int->max_conn_interval; - p_advertising->advdata.p_slave_conn_int->min_conn_interval = p_init->advdata.p_slave_conn_int->min_conn_interval; - } - - if (p_init->advdata.p_tx_power_level != NULL) - { - p_advertising->advdata.p_tx_power_level = p_init->advdata.p_tx_power_level; - } - -#if (NRF_SD_BLE_API_VERSION <= 2) - for (int i = 0; i whitelist.pp_addrs[i] = &p_advertising->whitelist_addrs[i]; - } - - for (int i = 0; i whitelist.pp_irks[i] = &p_advertising->whitelist_irks[i]; - } -#endif - ret = ble_advdata_set(&(p_advertising->advdata), &(p_init->srdata)); - return ret; -} - - -uint32_t ble_advertising_start(ble_advertising_t * const p_advertising, - ble_adv_mode_t advertising_mode) -{ - uint32_t ret; - ble_gap_adv_params_t adv_params; - - if (p_advertising->initialized == false) - { - return NRF_ERROR_INVALID_STATE; - } - - p_advertising->adv_mode_current = advertising_mode; - - // Delay starting advertising until the flash operations are complete. - if (flash_access_in_progress()) - { - p_advertising->advertising_start_pending = true; - return NRF_SUCCESS; - } - - memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address)); - - if ( ((p_advertising->adv_modes_config.ble_adv_directed_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED)) - ||((p_advertising->adv_modes_config.ble_adv_directed_slow_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED)) - ||((p_advertising->adv_modes_config.ble_adv_directed_slow_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED_SLOW)) - ) - { - if (p_advertising->evt_handler != NULL) - { - p_advertising->peer_addr_reply_expected = true; - p_advertising->evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST); - } - else - { - p_advertising->peer_addr_reply_expected = false; - } - } - - p_advertising->adv_mode_current = adv_mode_next_avail_get(p_advertising, advertising_mode); - - // Fetch the whitelist. - if ((p_advertising->evt_handler != NULL) && - (p_advertising->adv_mode_current == BLE_ADV_MODE_FAST || p_advertising->adv_mode_current == BLE_ADV_MODE_SLOW) && - (p_advertising->adv_modes_config.ble_adv_whitelist_enabled) && - (!p_advertising->whitelist_temporarily_disabled)) - { - #if (NRF_SD_BLE_API_VERSION >= 3) - p_advertising->whitelist_in_use = false; - #endif - p_advertising->whitelist_reply_expected = true; - p_advertising->evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST); - } - else - { - p_advertising->whitelist_reply_expected = false; - } - - // Initialize advertising parameters with default values. - memset(&adv_params, 0, sizeof(adv_params)); - - adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND; - adv_params.fp = BLE_GAP_ADV_FP_ANY; - - // Set advertising parameters and events according to selected advertising mode. - switch (p_advertising->adv_mode_current) - { - case BLE_ADV_MODE_DIRECTED: - ret = set_adv_mode_directed(p_advertising, &adv_params); - break; - - case BLE_ADV_MODE_DIRECTED_SLOW: - ret = set_adv_mode_directed_slow(p_advertising, &adv_params); - break; - - case BLE_ADV_MODE_FAST: - ret = set_adv_mode_fast(p_advertising, &adv_params); - break; - - case BLE_ADV_MODE_SLOW: - ret = set_adv_mode_slow(p_advertising, &adv_params); - break; - - case BLE_ADV_MODE_IDLE: - p_advertising->adv_evt = BLE_ADV_EVT_IDLE; - break; - - default: - break; - } - - if (p_advertising->adv_mode_current != BLE_ADV_MODE_IDLE) - { - ret = sd_ble_gap_adv_start(&adv_params, p_advertising->conn_cfg_tag); - if (ret != NRF_SUCCESS) - { - return ret; - } - } - - if (p_advertising->evt_handler != NULL) - { - p_advertising->evt_handler(p_advertising->adv_evt); - } - - return NRF_SUCCESS; -} - - -void ble_advertising_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) -{ - ble_advertising_t * p_advertising = (ble_advertising_t *)p_context; - - switch (p_ble_evt->header.evt_id) - { - case BLE_GAP_EVT_CONNECTED: - on_connected(p_advertising, p_ble_evt); - break; - - // Upon disconnection, whitelist will be activated and direct advertising is started. - case BLE_GAP_EVT_DISCONNECTED: - on_disconnected(p_advertising, p_ble_evt); - break; - - // Upon time-out, the next advertising mode is started. - case BLE_GAP_EVT_TIMEOUT: - on_timeout(p_advertising, p_ble_evt); - break; - - default: - break; - } -} - - -void ble_advertising_on_sys_evt(uint32_t evt_id, void * p_context) -{ - ble_advertising_t * p_advertising = (ble_advertising_t *)p_context; - - switch (evt_id) - { - //When a flash operation finishes, re-attempt to start advertising operations. - case NRF_EVT_FLASH_OPERATION_SUCCESS: - case NRF_EVT_FLASH_OPERATION_ERROR: - { - if (p_advertising->advertising_start_pending) - { - p_advertising->advertising_start_pending = false; - ret_code_t ret = ble_advertising_start(p_advertising, - p_advertising->adv_mode_current); - - if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) - { - p_advertising->error_handler(ret); - } - } - } break; - - default: - // No implementation needed. - break; - } -} - - -uint32_t ble_advertising_peer_addr_reply(ble_advertising_t * const p_advertising, - ble_gap_addr_t * p_peer_address) -{ - if (!p_advertising->peer_addr_reply_expected) - { - return NRF_ERROR_INVALID_STATE; - } - - p_advertising->peer_addr_reply_expected = false; - - memcpy(&p_advertising->peer_address, p_peer_address, sizeof(p_advertising->peer_address)); - - return NRF_SUCCESS; -} - - -uint32_t ble_advertising_whitelist_reply(ble_advertising_t * const p_advertising, - ble_gap_addr_t const * p_gap_addrs, - uint32_t addr_cnt, - ble_gap_irk_t const * p_gap_irks, - uint32_t irk_cnt) -{ - if (!p_advertising->whitelist_reply_expected) - { - return NRF_ERROR_INVALID_STATE; - } - - p_advertising->whitelist_reply_expected = false; - - #if (NRF_SD_BLE_API_VERSION <= 2) - - p_advertising->whitelist.addr_count = addr_cnt; - p_advertising->whitelist.irk_count = irk_cnt; - - for (uint32_t i = 0; i < addr_cnt; i++) - { - *p_advertising->whitelist.pp_addrs[i] = p_gap_addrs[i]; - } - - for (uint32_t i = 0; i < irk_cnt; i++) - { - *p_advertising->whitelist.pp_irks[i] = p_gap_irks[i]; - } - - #else - - p_advertising->whitelist_in_use = ((addr_cnt > 0) || (irk_cnt > 0)); - - #endif - - return NRF_SUCCESS; -} - - -uint32_t ble_advertising_restart_without_whitelist(ble_advertising_t * const p_advertising) -{ - uint32_t ret; - - (void) sd_ble_gap_adv_stop(); - - p_advertising->whitelist_temporarily_disabled = true; - - #if (NRF_SD_BLE_API_VERSION >= 3) - p_advertising->whitelist_in_use = false; - #endif - - p_advertising->advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; - - ret = ble_advdata_set(&(p_advertising->advdata), NULL); - if (ret != NRF_SUCCESS) - { - return ret; - } - - ret = ble_advertising_start(p_advertising, p_advertising->adv_mode_current); - if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) - { - p_advertising->error_handler(ret); - } - - return NRF_SUCCESS; -} - - -void ble_advertising_modes_config_set(ble_advertising_t * const p_advertising, - ble_adv_modes_config_t const * const p_adv_modes_config) -{ - p_advertising->adv_modes_config = *p_adv_modes_config; -} - - -#endif // NRF_MODULE_ENABLED(BLE_ADVERTISING) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.h deleted file mode 100644 index 934e5a7..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Copyright (c) 2013 - 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 ble_db_discovery Database Discovery - * @{ - * @ingroup ble_sdk_lib - * @brief Database discovery module. - * - * @details This module contains the APIs and types exposed by the DB Discovery module. These APIs - * and types can be used by the application to perform discovery of a service and its - * characteristics at the peer server. This module can also be used to discover the - * desired services in multiple remote devices. - * - * @warning The maximum number of characteristics per service that can be discovered by this module - * is determined by the number of characteristics in the service structure defined in - * db_disc_config.h. If the peer has more than the supported number of characteristics, then - * the first found will be discovered and any further characteristics will be ignored. Only the - * following descriptors will be searched for at the peer: Client Characteristic Configuration, - * Characteristic Extended Properties, Characteristic User Description, and Report Reference. - * - * @note Presently only one instance of a Primary Service can be discovered by this module. If - * there are multiple instances of the service at the peer, only the first instance - * of it at the peer is fetched and returned to the application. - * - * @note The application must propagate BLE stack events to this module by calling - * ble_db_discovery_on_ble_evt(). - * - */ - -#ifndef BLE_DB_DISCOVERY_H__ -#define BLE_DB_DISCOVERY_H__ - -#include -#include -#include "nrf_error.h" -#include "ble.h" -#include "ble_gattc.h" -#include "ble_gatt_db.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Macro for defining a ble_db_discovery instance. - * - * @param _name Name of the instance. - * @hideinitializer - */ -#define BLE_DB_DISCOVERY_DEF(_name) \ -static ble_db_discovery_t _name = {.discovery_in_progress = 0, \ - .discovery_pending = 0, \ - .conn_handle = BLE_CONN_HANDLE_INVALID}; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - BLE_DB_DISC_BLE_OBSERVER_PRIO, \ - ble_db_discovery_on_ble_evt, &_name) - -/** @brief Macro for defining multiple ble_db_discovery instances. - * - * @param _name Name of the array of instances. - * @param _cnt Number of instances to define. - */ -#define BLE_DB_DISCOVERY_ARRAY_DEF(_name, _cnt) \ -static ble_db_discovery_t _name[_cnt] = {{.discovery_in_progress = 0, \ - .discovery_pending = 0, \ - .conn_handle = BLE_CONN_HANDLE_INVALID}}; \ -NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ - BLE_DB_DISC_BLE_OBSERVER_PRIO, \ - ble_db_discovery_on_ble_evt, &_name, _cnt) - -#define BLE_DB_DISCOVERY_MAX_SRV 6 /**< Maximum number of services supported by this module. This also indicates the maximum number of users allowed to be registered to this module (one user per service). */ - - -/**@brief DB Discovery event type. */ -typedef enum -{ - BLE_DB_DISCOVERY_COMPLETE, /**< Event indicating that the discovery of one service is complete. */ - BLE_DB_DISCOVERY_ERROR, /**< Event indicating that an internal error has occurred in the DB Discovery module. This could typically be because of the SoftDevice API returning an error code during the DB discover.*/ - BLE_DB_DISCOVERY_SRV_NOT_FOUND, /**< Event indicating that the service was not found at the peer.*/ - BLE_DB_DISCOVERY_AVAILABLE /**< Event indicating that the DB discovery instance is available.*/ -} ble_db_discovery_evt_type_t; - -/**@brief Structure for holding the information related to the GATT database at the server. - * - * @details This module identifies a remote database. Use one instance of this structure per - * connection. - * - * @warning This structure must be zero-initialized. - */ -typedef struct -{ - ble_gatt_db_srv_t services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered. This is intended for internal use during service discovery.*/ - uint8_t srv_count; /**< Number of services at the peers GATT database.*/ - uint8_t curr_char_ind; /**< Index of the current characteristic being discovered. This is intended for internal use during service discovery.*/ - uint8_t curr_srv_ind; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/ - bool discovery_in_progress; /**< Variable to indicate if there is a service discovery in progress. */ - bool discovery_pending; /**< Discovery was requested, but could not start because the SoftDevice was busy. */ - uint8_t discoveries_count; /**< Number of service discoveries made, both successful and unsuccessful. */ - uint16_t conn_handle; /**< Connection handle on which the discovery is started*/ -} ble_db_discovery_t; - -/**@brief Structure containing the event from the DB discovery module to the application. */ -typedef struct -{ - ble_db_discovery_evt_type_t evt_type; /**< Type of event. */ - uint16_t conn_handle; /**< Handle of the connection for which this event has occurred. */ - union - { - ble_gatt_db_srv_t discovered_db; /**< Structure containing the information about the GATT Database at the server. This will be filled when the event type is @ref BLE_DB_DISCOVERY_COMPLETE. The UUID field of this will be filled when the event type is @ref BLE_DB_DISCOVERY_SRV_NOT_FOUND. */ - uint32_t err_code; /**< nRF Error code indicating the type of error which occurred in the DB Discovery module. This will be filled when the event type is @ref BLE_DB_DISCOVERY_ERROR. */ - } params; -} ble_db_discovery_evt_t; - -/**@brief DB Discovery event handler type. */ -typedef void (* ble_db_discovery_evt_handler_t)(ble_db_discovery_evt_t * p_evt); - - -/**@brief Function for initializing the DB Discovery module. - * - * @param[in] evt_handler Event handler to be called by the DB discovery module when any event - * related to discovery of the registered service occurs. - * - * @retval NRF_SUCCESS On successful initialization. - * @retval NRF_ERROR_NULL If the handler was NULL. - */ -uint32_t ble_db_discovery_init(ble_db_discovery_evt_handler_t evt_handler); - - -/**@brief Function for closing the DB Discovery module. - * - * @details This function will clear up any internal variables and states maintained by the - * module. To re-use the module after calling this function, the function @ref - * ble_db_discovery_init must be called again. - * - * @retval NRF_SUCCESS Operation success. - */ -uint32_t ble_db_discovery_close(void); - - -/**@brief Function for registering with the DB Discovery module. - * - * @details The application can use this function to inform which service it is interested in - * discovering at the server. - * - * @param[in] p_uuid Pointer to the UUID of the service to be discovered at the server. - * - * @note The total number of services that can be discovered by this module is @ref - * BLE_DB_DISCOVERY_MAX_SRV. This effectively means that the maximum number of - * registrations possible is equal to the @ref BLE_DB_DISCOVERY_MAX_SRV. - * - * @retval NRF_SUCCESS Operation success. - * @retval NRF_ERROR_NULL When a NULL pointer is passed as input. - * @retval NRF_ERROR_INVALID_STATE If this function is called without calling the - * @ref ble_db_discovery_init. - * @retval NRF_ERROR_NO_MEM The maximum number of registrations allowed by this module - * has been reached. - */ -uint32_t ble_db_discovery_evt_register(const ble_uuid_t * const p_uuid); - - -/**@brief Function for starting the discovery of the GATT database at the server. - * - * @param[out] p_db_discovery Pointer to the DB Discovery structure. - * @param[in] conn_handle The handle of the connection for which the discovery should be - * started. - * - * @retval NRF_SUCCESS Operation success. - * @retval NRF_ERROR_NULL When a NULL pointer is passed as input. - * @retval NRF_ERROR_INVALID_STATE If this function is called without calling the - * @ref ble_db_discovery_init, or without calling - * @ref ble_db_discovery_evt_register. - * @retval NRF_ERROR_BUSY If a discovery is already in progress using - * @p p_db_discovery. Use a different @ref ble_db_discovery_t - * structure, or wait for a DB Discovery event before retrying. - * - * @return This API propagates the error code returned by the - * SoftDevice API @ref sd_ble_gattc_primary_services_discover. - */ -uint32_t ble_db_discovery_start(ble_db_discovery_t * p_db_discovery, - uint16_t conn_handle); - - -/**@brief Function for handling the Application's BLE Stack events. - * - * @param[in] p_ble_evt Pointer to the BLE event received. - * @param[in,out] p_context Pointer to the DB Discovery structure. - */ -void ble_db_discovery_on_ble_evt(ble_evt_t const * p_ble_evt, - void * p_context); - - -#ifdef __cplusplus -} -#endif - -#endif // BLE_DB_DISCOVERY_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c deleted file mode 100644 index b64b5d4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c +++ /dev/null @@ -1,367 +0,0 @@ -/** - * Copyright (c) 2016 - 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. - * - */ -/* Disclaimer: This client implementation of the Apple Notification Center Service can and will be changed at any time by Nordic Semiconductor ASA. - * Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working. - */ - -#include "ancs_app_attr_get.h" -#include "nrf_ble_ancs_c.h" -#include "ancs_tx_buffer.h" -#include "sdk_macros.h" -#include "nrf_log.h" -#include "string.h" - -#define GATTC_OPCODE_SIZE 1 /**< Size of the GATTC OPCODE. */ -#define GATTC_ATTR_HANDLE_SIZE 4 /**< Size of the Attribute handle Size. */ - - -#define ANCS_GATTC_WRITE_PAYLOAD_LEN_MAX (BLE_GATT_ATT_MTU_DEFAULT - GATTC_OPCODE_SIZE - GATTC_ATTR_HANDLE_SIZE) /**< Maximum Length of the data we can send in one write. */ - - -/**@brief Enum to keep track of the state based encoding while requesting App attributes. */ -typedef enum -{ - APP_ATTR_COMMAND_ID, /**< Currently encoding the Command ID. */ - APP_ATTR_APP_ID, /**< Currently encoding the App ID. */ - APP_ATTR_ATTR_ID, /**< Currently encoding the Attribute ID. */ - APP_ATTR_DONE /**< Encoding done. */ -}encode_app_attr_t; - - -/**@brief Function for determening if an attribute is desired to get. - * - * @param[in] p_ancs iOS notification structure. This structure must be supplied by - * the application. It identifies the particular client instance to use. - * - * @return True If it is requested - * @return False If it is not be requested. -*/ -static bool app_attr_is_requested(ble_ancs_c_t * p_ancs, uint32_t attr_id) -{ - if (p_ancs->ancs_app_attr_list[attr_id].get == true) - { - return true; - } - return false; -} - -/**@brief Function for counting the number of attributes that will be requested upon a Get App Attribute. - * - * @param[in] p_ancs iOS notification structure. This structure must be supplied by - * the application. It identifies the particular client instance to use. - * - * @return Number of attributes that will be requested upon a Get App Attribute. -*/ -static uint32_t app_attr_nb_to_get(ble_ancs_c_t * p_ancs) -{ - uint32_t attr_nb_to_get = 0; - for (uint32_t i = 0; i < (sizeof(p_ancs->ancs_app_attr_list)/sizeof(ble_ancs_c_attr_list_t)); i++) - { - if (app_attr_is_requested(p_ancs,i)) - { - attr_nb_to_get++; - } - } - return attr_nb_to_get; -} - - -/**@brief Function for encoding the Command ID as part of assembling a "Get App Attributes" command. - * - * @param[in] conn_handle Connection handle for where the prepared write will be executed. - * @param[in] handle_value The handle that will receive the execute command. - * @param[in] p_offset Pointer to the offset for the write. - * @param[in] p_index Pointer to the length encoded so far for the current write. - * @param[in,out] p_msg Pointer to the tx message that has been filled out and will be added to - * tx queue in this function. - */ -static void queued_write_tx_message(uint16_t conn_handle, - uint16_t handle_value, - uint16_t * p_offset, - uint32_t * p_index, - tx_message_t * p_msg) -{ - NRF_LOG_DEBUG("Starting new TX message."); - - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - p_msg->req.write_req.gattc_params.len = *p_index; - p_msg->req.write_req.gattc_params.handle = handle_value; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - - p_msg->req.write_req.gattc_params.offset = *p_offset; - - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_PREP_WRITE_REQ; - - tx_buffer_insert(p_msg); -} - - -/**@brief Function for encoding the Command ID as part of assembling a "Get App Attributes" command. - * - * @param[in] p_ancs iOS notification structure. This structure must be supplied by - * the application. It identifies the particular client instance to use. - * @param[in] p_index Pointer to the length encoded so far for the current write. - * @param[in] p_offset Pointer to the accumulated offset for the next write. - * @param[in,out] p_msg Pointer to the tx message that will be filled out in this function. - */ -static encode_app_attr_t app_attr_encode_cmd_id(ble_ancs_c_t * p_ancs, - uint32_t * index, - tx_message_t * p_msg) -{ - NRF_LOG_DEBUG("Encoding Command ID"); - - // Encode Command ID. - p_msg->req.write_req.gattc_value[(*index)++] = BLE_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES; - return APP_ATTR_APP_ID; -} - -/**@brief Function for encoding the App Identifier as part of assembling a "Get App Attributes" command. - * - * @param[in] p_ancs iOS notification structure. This structure must be supplied by - * the application. It identifies the particular client instance to use. - * @param[in] p_app_id The App ID for the App which we will request App Attributes for. - * @param[in] app_id_len Length of the App ID. - * @param[in] p_index Pointer to the length encoded so far for the current write. - * @param[in] p_offset Pointer to the accumulated offset for the next write. - * @param[in] p_app_id_bytes_encoded_count Variable to keep count of the encoded APP ID bytes. - * As long as it is lower than the length of the App ID, - * parsing will continue. - */ -static encode_app_attr_t app_attr_encode_app_id(ble_ancs_c_t * p_ancs, - uint32_t * p_index, - uint16_t * p_offset, - tx_message_t * p_msg, - const uint8_t * p_app_id, - const uint32_t app_id_len, - uint32_t * p_app_id_bytes_encoded_count) -{ - NRF_LOG_DEBUG("Encoding APP ID"); - if (*p_index >= ANCS_GATTC_WRITE_PAYLOAD_LEN_MAX) - { - queued_write_tx_message(p_ancs->conn_handle, p_ancs->service.control_point_char.handle_value, p_offset, p_index, p_msg); - *(p_offset) += *p_index; - *p_index = 0; - } - - //Encode App Identifier. - if (*p_app_id_bytes_encoded_count == app_id_len) - { - p_msg->req.write_req.gattc_value[(*p_index)++] = '\0'; - (*p_app_id_bytes_encoded_count)++; - } - NRF_LOG_DEBUG("%c", p_app_id[(*p_app_id_bytes_encoded_count)]); - if (*p_app_id_bytes_encoded_count < app_id_len) - { - p_msg->req.write_req.gattc_value[(*p_index)++] = p_app_id[(*p_app_id_bytes_encoded_count)++]; - } - if (*p_app_id_bytes_encoded_count > app_id_len) - { - return APP_ATTR_ATTR_ID; - } - return APP_ATTR_APP_ID; -} - -/**@brief Function for encoding the Attribute ID as part of assembling a "Get App Attributes" command. - * - * @param[in] p_ancs iOS notification structure. This structure must be supplied by - * - * @param[in] p_index Pointer to the length encoded so far for the current write. - * @param[in] p_offset Pointer to the accumulated offset for the next write. - * @param[in,out] p_msg Pointer to the tx message that will be filled out in this function. - * @param[in] p_attr_count Pointer to a variable that iterates the possible App Attributes. - */ -static encode_app_attr_t app_attr_encode_attr_id(ble_ancs_c_t * p_ancs, - uint32_t * p_index, - uint16_t * p_offset, - tx_message_t * p_msg, - uint32_t * p_attr_count, - uint32_t * attr_get_total_nb) -{ - NRF_LOG_DEBUG("Encoding Attribute ID"); - if ((*p_index) >= ANCS_GATTC_WRITE_PAYLOAD_LEN_MAX) - { - queued_write_tx_message(p_ancs->conn_handle, - p_ancs->service.control_point_char.handle_value, - p_offset, p_index, p_msg); - *(p_offset) += *p_index; - *p_index = 0; - } - //Encode Attribute ID. - if (*p_attr_count < BLE_ANCS_NB_OF_APP_ATTR) - { - if (app_attr_is_requested(p_ancs, *p_attr_count)) - { - p_msg->req.write_req.gattc_value[(*p_index)] = *p_attr_count; - p_ancs->number_of_requested_attr++; - (*p_index)++; - NRF_LOG_DEBUG("offset %i", *p_offset); - } - (*p_attr_count)++; - } - if (*p_attr_count == BLE_ANCS_NB_OF_APP_ATTR) - { - return APP_ATTR_DONE; - } - return APP_ATTR_APP_ID; -} - -/**@brief Function for writing the execute write command to a handle for a given connection. - * - * @param[in] conn_handle Connection handle for where the prepared write will be executed. - * @param[in] handle_value The handle that will receive the execute command. - * @param[in] p_msg Pointer to the message that will be filled out in this function and then - * added to the tx queue. - */ -static void app_attr_execute_write(uint16_t conn_handle, uint16_t handle_value, tx_message_t * p_msg) -{ - NRF_LOG_DEBUG("Sending Execute Write."); - memset(p_msg,0,sizeof(tx_message_t)); - - p_msg->req.write_req.gattc_params.handle = handle_value; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_EXEC_WRITE_REQ; - p_msg->req.write_req.gattc_params.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE; - - p_msg->req.write_req.gattc_params.len = 0; - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_insert(p_msg); -} - - -/**@brief Function for sending a get App Attributes request. - * - * @details Since the APP id may not fit in a single write, we use long write - * with a state machine to encode the Get App Attribute request. - * - * @param[in] p_ancs iOS notification structure. This structure must be supplied by - * the application. It identifies the particular client instance to use. - * @param[in] p_app_id The App ID for the App which we will request App Attributes for. - * @param[in] app_id_len Length of the App ID. - * -*/ -static uint32_t app_attr_get(ble_ancs_c_t * p_ancs, - const uint8_t * p_app_id, - uint32_t app_id_len) -{ - uint32_t index = 0; - uint32_t attr_bytes_encoded_count = 0; - uint16_t offset = 0; - uint32_t app_id_bytes_encoded_count = 0; - encode_app_attr_t state = APP_ATTR_COMMAND_ID; - p_ancs->number_of_requested_attr = 0; - - uint32_t attr_get_total_nb = app_attr_nb_to_get(p_ancs); - tx_message_t p_msg; - - memset(&p_msg, 0, sizeof(tx_message_t)); - - while (state != APP_ATTR_DONE) - { - switch (state) - { - case APP_ATTR_COMMAND_ID: - state = app_attr_encode_cmd_id(p_ancs, - &index, - &p_msg); - break; - case APP_ATTR_APP_ID: - state = app_attr_encode_app_id(p_ancs, - &index, - &offset, - &p_msg, - p_app_id, - app_id_len, - &app_id_bytes_encoded_count); - break; - case APP_ATTR_ATTR_ID: - state = app_attr_encode_attr_id(p_ancs, - &index, - &offset, - &p_msg, - &attr_bytes_encoded_count, - &attr_get_total_nb); - break; - case APP_ATTR_DONE: - break; - default: - break; - } - } - queued_write_tx_message(p_ancs->conn_handle, - p_ancs->service.control_point_char.handle_value, - &offset, - &index, - &p_msg); - - app_attr_execute_write(p_ancs->conn_handle, - p_ancs->service.control_point_char.handle_value, - &p_msg); - - p_ancs->parse_info.expected_number_of_attrs = p_ancs->number_of_requested_attr; - - tx_buffer_process(); - return NRF_SUCCESS; -} - - -uint32_t ancs_c_app_attr_request(ble_ancs_c_t * p_ancs, - const uint8_t * p_app_id, - uint32_t len) -{ - uint32_t err_code; - - if (len == 0) - { - return NRF_ERROR_DATA_SIZE; - } - if (p_app_id[len] != '\0') // App id to be requestes must be NULL terminated - { - return NRF_ERROR_INVALID_PARAM; - } - - p_ancs->parse_info.parse_state = COMMAND_ID; - err_code = app_attr_get(p_ancs, p_app_id, len); - VERIFY_SUCCESS(err_code); - return NRF_SUCCESS; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.c deleted file mode 100644 index e1ba16d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.c +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2016 - 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. - * - */ -/* Disclaimer: This client implementation of the Apple Notification Center Service can and will be changed at any time by Nordic Semiconductor ASA. - * Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working. - */ - - #include "nrf_ble_ancs_c.h" - #include "ancs_tx_buffer.h" - #include "sdk_macros.h" - #include "nrf_log.h" - #include "string.h" - - -static tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for messages to be transmitted to the Notification Provider. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where the next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer from where the next message to be transmitted resides. */ - - -void tx_buffer_init(void) -{ - memset(m_tx_buffer, 0, sizeof(m_tx_buffer)); -} - - -void tx_buffer_insert(tx_message_t * p_msg) -{ - - memset(&(m_tx_buffer[m_tx_insert_index]), 0, sizeof(m_tx_buffer)/sizeof(tx_message_t)); - - m_tx_buffer[m_tx_insert_index].conn_handle = p_msg->conn_handle; - m_tx_buffer[m_tx_insert_index].type = p_msg->type; - - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.handle = p_msg->req.write_req.gattc_params.handle; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.len = p_msg->req.write_req.gattc_params.len; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.write_op = p_msg->req.write_req.gattc_params.write_op; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.flags = p_msg->req.write_req.gattc_params.flags; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.p_value = m_tx_buffer[m_tx_insert_index].req.write_req.gattc_value; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.offset = p_msg->req.write_req.gattc_params.offset; - - if (p_msg->type == WRITE_REQ) - { - memcpy(m_tx_buffer[m_tx_insert_index].req.write_req.gattc_value, - p_msg->req.write_req.gattc_value, - WRITE_MESSAGE_LENGTH); - } - - m_tx_insert_index++; - m_tx_insert_index &= TX_BUFFER_MASK; -} - - - -void tx_buffer_process(void) -{ - if (m_tx_index != m_tx_insert_index) - { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - ++m_tx_index; - m_tx_index &= TX_BUFFER_MASK; - } - } -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.h deleted file mode 100644 index 89363d4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2012 - 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 ANCS_TX_BUFFER_H__ -#define ANCS_TX_BUFFER_H__ - -#include "nrf_ble_ancs_c.h" - -/** @file - * - * @addtogroup ble_ancs_c - * @{ - */ - -#define TX_BUFFER_MASK 0x07 //!< TX buffer mask. Must be a mask of contiguous zeroes followed by a contiguous sequence of ones: 000...111. -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) //!< Size of the send buffer, which is 1 bigger than the mask. -#define WRITE_MESSAGE_LENGTH 20 //!< Length of the write message for the CCCD/control point. - -/**@brief ANCS request types. - */ -typedef enum -{ - READ_REQ = 1, /**< Type identifying that this TX message is a read request. */ - WRITE_REQ /**< Type identifying that this TX message is a write request. */ -} tx_request_t; - - -/**@brief Structure for writing a message to the central, thus the Control Point or CCCD. - */ -typedef struct -{ - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; //!< The message to write. - ble_gattc_write_params_t gattc_params; //!< GATTC parameters for this message. -} write_params_t; - - -/**@brief Data to be transmitted to the connected master. - */ -typedef struct -{ - uint16_t conn_handle; //!< Connection handle to be used when transmitting this message. - tx_request_t type; //!< Type of this message (read or write message). - union - { - uint16_t read_handle; //!< Read request message. - write_params_t write_req; //!< Write request message. - } req; -} tx_message_t; - -/**@brief Function for clearing the TX buffer. - * - * @details Always call this function before using the TX buffer. -*/ -void tx_buffer_init(void); - -/**@brief Function for moving the pointer of the ring buffer to the next element. -*/ -void tx_buffer_insert(tx_message_t * p_msg); - -/**@brief Function for passing any pending request from the buffer to the stack. -*/ -void tx_buffer_process(void); - -/** @} */ - -#endif // ANCS_TX_BUFFER_H__ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.h deleted file mode 100644 index 10080d1..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.h +++ /dev/null @@ -1,323 +0,0 @@ -/** - * Copyright (c) 2012 - 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 ble_gls Glucose Service - * @{ - * @ingroup ble_sdk_srv - * @brief Glucose Service module. - * - * @details This module implements the Glucose Service. - * - * @note The application must register this module as BLE event observer using the - * NRF_SDH_BLE_OBSERVER macro. Example: - * @code - * ble_gls_t instance; - * NRF_SDH_BLE_OBSERVER(anything, BLE_GLS_BLE_OBSERVER_PRIO, - * ble_gls_on_ble_evt, &instance); - * @endcode - * - * @note Attention! - * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile - * qualification listings, this section of source code must not be modified. - */ - -#ifndef BLE_GLS_H__ -#define BLE_GLS_H__ - -#include -#include -#include "ble.h" -#include "ble_srv_common.h" -#include "ble_date_time.h" -#include "nrf_sdh_ble.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Macro for defining a ble_gls instance. - * - * @param _name Name of the instance. - * @hideinitializer - */ -#define BLE_GLS_DEF(_name) \ -static ble_gls_t _name; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - BLE_GLS_BLE_OBSERVER_PRIO, \ - ble_gls_on_ble_evt, &_name) - - -/**@brief Glucose feature */ -#define BLE_GLS_FEATURE_LOW_BATT 0x0001 /**< Low Battery Detection During Measurement Supported */ -#define BLE_GLS_FEATURE_MALFUNC 0x0002 /**< Sensor Malfunction Detection Supported */ -#define BLE_GLS_FEATURE_SAMPLE_SIZE 0x0004 /**< Sensor Sample Size Supported */ -#define BLE_GLS_FEATURE_INSERT_ERR 0x0008 /**< Sensor Strip Insertion Error Detection Supported */ -#define BLE_GLS_FEATURE_TYPE_ERR 0x0010 /**< Sensor Strip Type Error Detection Supported */ -#define BLE_GLS_FEATURE_RES_HIGH_LOW 0x0020 /**< Sensor Result High-Low Detection Supported */ -#define BLE_GLS_FEATURE_TEMP_HIGH_LOW 0x0040 /**< Sensor Temperature High-Low Detection Supported */ -#define BLE_GLS_FEATURE_READ_INT 0x0080 /**< Sensor Read Interrupt Detection Supported */ -#define BLE_GLS_FEATURE_GENERAL_FAULT 0x0100 /**< General Device Fault Supported */ -#define BLE_GLS_FEATURE_TIME_FAULT 0x0200 /**< Time Fault Supported */ -#define BLE_GLS_FEATURE_MULTI_BOND 0x0400 /**< Multiple Bond Supported */ - -/**@brief Glucose measurement flags */ -#define BLE_GLS_MEAS_FLAG_TIME_OFFSET 0x01 /**< Time Offset Present */ -#define BLE_GLS_MEAS_FLAG_CONC_TYPE_LOC 0x02 /**< Glucose Concentration, Type, and Sample Location Present */ -#define BLE_GLS_MEAS_FLAG_UNITS_KG_L 0x00 /**< Glucose Concentration Units kg/L */ -#define BLE_GLS_MEAS_FLAG_UNITS_MOL_L 0x04 /**< Glucose Concentration Units mol/L */ -#define BLE_GLS_MEAS_FLAG_SENSOR_STATUS 0x08 /**< Sensor Status Annunciation Present */ -#define BLE_GLS_MEAS_FLAG_CONTEXT_INFO 0x10 /**< Context Information Follows */ - -/**@brief Glucose measurement type */ -#define BLE_GLS_MEAS_TYPE_CAP_BLOOD 1 /**< Capillary whole blood */ -#define BLE_GLS_MEAS_TYPE_CAP_PLASMA 2 /**< Capillary plasma */ -#define BLE_GLS_MEAS_TYPE_VEN_BLOOD 3 /**< Venous whole blood */ -#define BLE_GLS_MEAS_TYPE_VEN_PLASMA 4 /**< Venous plasma */ -#define BLE_GLS_MEAS_TYPE_ART_BLOOD 5 /**< Arterial whole blood */ -#define BLE_GLS_MEAS_TYPE_ART_PLASMA 6 /**< Arterial plasma */ -#define BLE_GLS_MEAS_TYPE_UNDET_BLOOD 7 /**< Undetermined whole blood */ -#define BLE_GLS_MEAS_TYPE_UNDET_PLASMA 8 /**< Undetermined plasma */ -#define BLE_GLS_MEAS_TYPE_FLUID 9 /**< Interstitial fluid (ISF) */ -#define BLE_GLS_MEAS_TYPE_CONTROL 10 /**< Control solution */ - -/**@brief Glucose measurement location */ -#define BLE_GLS_MEAS_LOC_FINGER 1 /**< Finger */ -#define BLE_GLS_MEAS_LOC_AST 2 /**< Alternate Site Test (AST) */ -#define BLE_GLS_MEAS_LOC_EAR 3 /**< Earlobe */ -#define BLE_GLS_MEAS_LOC_CONTROL 4 /**< Control solution */ -#define BLE_GLS_MEAS_LOC_NOT_AVAIL 15 /**< Sample Location value not available */ - -/**@brief Glucose sensor status annunciation */ -#define BLE_GLS_MEAS_STATUS_BATT_LOW 0x0001 /**< Device battery low at time of measurement */ -#define BLE_GLS_MEAS_STATUS_SENSOR_FAULT 0x0002 /**< Sensor malfunction or faulting at time of measurement */ -#define BLE_GLS_MEAS_STATUS_SAMPLE_SIZE 0x0004 /**< Sample size for blood or control solution insufficient at time of measurement */ -#define BLE_GLS_MEAS_STATUS_STRIP_INSERT 0x0008 /**< Strip insertion error */ -#define BLE_GLS_MEAS_STATUS_STRIP_TYPE 0x0010 /**< Strip type incorrect for device */ -#define BLE_GLS_MEAS_STATUS_RESULT_HIGH 0x0020 /**< Sensor result higher than the device can process */ -#define BLE_GLS_MEAS_STATUS_RESULT_LOW 0x0040 /**< Sensor result lower than the device can process */ -#define BLE_GLS_MEAS_STATUS_TEMP_HIGH 0x0080 /**< Sensor temperature too high for valid test/result at time of measurement */ -#define BLE_GLS_MEAS_STATUS_TEMP_LOW 0x0100 /**< Sensor temperature too low for valid test/result at time of measurement */ -#define BLE_GLS_MEAS_STATUS_STRIP_PULL 0x0200 /**< Sensor read interrupted because strip was pulled too soon at time of measurement */ -#define BLE_GLS_MEAS_STATUS_GENERAL_FAULT 0x0400 /**< General device fault has occurred in the sensor */ -#define BLE_GLS_MEAS_STATUS_TIME_FAULT 0x0800 /**< Time fault has occurred in the sensor and time may be inaccurate */ - -/**@brief Glucose measurement context flags */ -#define BLE_GLS_CONTEXT_FLAG_CARB 0x01 /**< Carbohydrate id and carbohydrate present */ -#define BLE_GLS_CONTEXT_FLAG_MEAL 0x02 /**< Meal present */ -#define BLE_GLS_CONTEXT_FLAG_TESTER 0x04 /**< Tester-health present */ -#define BLE_GLS_CONTEXT_FLAG_EXERCISE 0x08 /**< Exercise duration and exercise intensity present */ -#define BLE_GLS_CONTEXT_FLAG_MED 0x10 /**< Medication ID and medication present */ -#define BLE_GLS_CONTEXT_FLAG_MED_KG 0x00 /**< Medication value units, kilograms */ -#define BLE_GLS_CONTEXT_FLAG_MED_L 0x20 /**< Medication value units, liters */ -#define BLE_GLS_CONTEXT_FLAG_HBA1C 0x40 /**< Hba1c present */ -#define BLE_GLS_CONTEXT_FLAG_EXT 0x80 /**< Extended flags present */ - -/**@brief Glucose measurement context carbohydrate ID */ -#define BLE_GLS_CONTEXT_CARB_BREAKFAST 1 /**< Breakfast */ -#define BLE_GLS_CONTEXT_CARB_LUNCH 2 /**< Lunch */ -#define BLE_GLS_CONTEXT_CARB_DINNER 3 /**< Dinner */ -#define BLE_GLS_CONTEXT_CARB_SNACK 4 /**< Snack */ -#define BLE_GLS_CONTEXT_CARB_DRINK 5 /**< Drink */ -#define BLE_GLS_CONTEXT_CARB_SUPPER 6 /**< Supper */ -#define BLE_GLS_CONTEXT_CARB_BRUNCH 7 /**< Brunch */ - -/**@brief Glucose measurement context meal */ -#define BLE_GLS_CONTEXT_MEAL_PREPRANDIAL 1 /**< Preprandial (before meal) */ -#define BLE_GLS_CONTEXT_MEAL_POSTPRANDIAL 2 /**< Postprandial (after meal) */ -#define BLE_GLS_CONTEXT_MEAL_FASTING 3 /**< Fasting */ -#define BLE_GLS_CONTEXT_MEAL_CASUAL 4 /**< Casual (snacks, drinks, etc.) */ -#define BLE_GLS_CONTEXT_MEAL_BEDTIME 5 /**< Bedtime */ - -/**@brief Glucose measurement context tester */ -#define BLE_GLS_CONTEXT_TESTER_SELF 1 /**< Self */ -#define BLE_GLS_CONTEXT_TESTER_PRO 2 /**< Health care professional */ -#define BLE_GLS_CONTEXT_TESTER_LAB 3 /**< Lab test */ -#define BLE_GLS_CONTEXT_TESTER_NOT_AVAIL 15 /**< Tester value not available */ - -/**@brief Glucose measurement context health */ -#define BLE_GLS_CONTEXT_HEALTH_MINOR 1 /**< Minor health issues */ -#define BLE_GLS_CONTEXT_HEALTH_MAJOR 2 /**< Major health issues */ -#define BLE_GLS_CONTEXT_HEALTH_MENSES 3 /**< During menses */ -#define BLE_GLS_CONTEXT_HEALTH_STRESS 4 /**< Under stress */ -#define BLE_GLS_CONTEXT_HEALTH_NONE 5 /**< No health issues */ -#define BLE_GLS_CONTEXT_HEALTH_NOT_AVAIL 15 /**< Health value not available */ - -/**@brief Glucose measurement context medication ID */ -#define BLE_GLS_CONTEXT_MED_RAPID 1 /**< Rapid acting insulin */ -#define BLE_GLS_CONTEXT_MED_SHORT 2 /**< Short acting insulin */ -#define BLE_GLS_CONTEXT_MED_INTERMED 3 /**< Intermediate acting insulin */ -#define BLE_GLS_CONTEXT_MED_LONG 4 /**< Long acting insulin */ -#define BLE_GLS_CONTEXT_MED_PREMIX 5 /**< Pre-mixed insulin */ - - -/**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, meaning 4 bits for exponent (base 10) and 12 bits mantissa) */ -typedef struct -{ - int8_t exponent; /**< Base 10 exponent, should be using only 4 bits */ - int16_t mantissa; /**< Mantissa, should be using only 12 bits */ -} sfloat_t; - -/**@brief Glucose Service event type. */ -typedef enum -{ - BLE_GLS_EVT_NOTIFICATION_ENABLED, /**< Glucose value notification enabled event. */ - BLE_GLS_EVT_NOTIFICATION_DISABLED /**< Glucose value notification disabled event. */ -} ble_gls_evt_type_t; - -/**@brief Glucose Service event. */ -typedef struct -{ - ble_gls_evt_type_t evt_type; /**< Type of event. */ -} ble_gls_evt_t; - -// Forward declaration of the ble_gls_t type. -typedef struct ble_gls_s ble_gls_t; - -/**@brief Glucose Service event handler type. */ -typedef void (*ble_gls_evt_handler_t) (ble_gls_t * p_gls, ble_gls_evt_t * p_evt); - -/**@brief Glucose Measurement structure. This contains glucose measurement value. */ -typedef struct -{ - uint8_t flags; /**< Flags */ - uint16_t sequence_number; /**< Sequence number */ - ble_date_time_t base_time; /**< Time stamp */ - int16_t time_offset; /**< Time offset */ - sfloat_t glucose_concentration; /**< Glucose concentration */ - uint8_t type; /**< Type */ - uint8_t sample_location; /**< Sample location */ - uint16_t sensor_status_annunciation; /**< Sensor status annunciation */ -} ble_gls_meas_t; - -/**@brief Glucose measurement context structure */ -typedef struct -{ - uint8_t flags; /**< Flags */ - uint8_t extended_flags; /**< Extended Flags */ - uint8_t carbohydrate_id; /**< Carbohydrate ID */ - sfloat_t carbohydrate; /**< Carbohydrate */ - uint8_t meal; /**< Meal */ - uint8_t tester_and_health; /**< Tester and health */ - uint16_t exercise_duration; /**< Exercise Duration */ - uint8_t exercise_intensity; /**< Exercise Intensity */ - uint8_t medication_id; /**< Medication ID */ - sfloat_t medication; /**< Medication */ - uint16_t hba1c; /**< HbA1c */ -} ble_gls_meas_context_t; - -/**@brief Glucose measurement record */ -typedef struct -{ - ble_gls_meas_t meas; /**< Glucose measurement */ - ble_gls_meas_context_t context; /**< Glucose measurement context */ -} ble_gls_rec_t; - -/**@brief Glucose Service init structure. This contains all options and data needed for - * initialization of the service. */ -typedef struct -{ - ble_gls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Glucose Service. */ - ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ - uint16_t feature; /**< Glucose Feature value indicating supported features. */ - bool is_context_supported; /**< Determines if optional Glucose Measurement Context is to be supported. */ -} ble_gls_init_t; - -/**@brief Glucose Service structure. This contains various status information for the service. */ -struct ble_gls_s -{ - ble_gls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Glucose Service. */ - ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ - uint16_t service_handle; /**< Handle of Glucose Service (as provided by the BLE stack). */ - ble_gatts_char_handles_t glm_handles; /**< Handles related to the Glucose Measurement characteristic. */ - ble_gatts_char_handles_t glm_context_handles; /**< Handles related to the Glucose Measurement Context characteristic. */ - ble_gatts_char_handles_t glf_handles; /**< Handles related to the Glucose Feature characteristic. */ - ble_gatts_char_handles_t racp_handles; /**< Handles related to the Record Access Control Point characteristic. */ - uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ - uint16_t feature; - bool is_context_supported; -}; - - -/**@brief Function for initializing the Glucose Service. - * - * @details This call allows the application to initialize the Glucose Service. - * - * @param[out] p_gls Glucose Service structure. This structure will have to be supplied by - * the application. It will be initialized by this function, and will later - * be used to identify this particular service instance. - * @param[in] p_gls_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. - */ -uint32_t ble_gls_init(ble_gls_t * p_gls, ble_gls_init_t const * p_gls_init); - - -/**@brief Function for handling the Application's BLE Stack events. - * - * @details Handles all events from the BLE stack of interest to the Glucose Service. - * - * @param[in] p_ble_evt Event received from the BLE stack. - * @param[in] p_context Glucose Service structure. - */ -void ble_gls_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); - - -/**@brief Function for reporting a new glucose measurement to the glucose service module. - * - * @details The application calls this function after having performed a new glucose measurement. - * The new measurement is recorded in the RACP database. - * - * @param[in] p_gls Glucose Service structure. - * @param[in] p_rec Pointer to glucose record (measurement plus context). - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -uint32_t ble_gls_glucose_new_meas(ble_gls_t * p_gls, ble_gls_rec_t * p_rec); - - -#ifdef __cplusplus -} -#endif - -#endif // BLE_GLS_H__ - -/** @} */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.c deleted file mode 100644 index 1e41564..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.c +++ /dev/null @@ -1,1413 +0,0 @@ -/** - * Copyright (c) 2012 - 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. - * - */ -/* Attention! - * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile - * qualification listings, this section of source code must not be modified. - */ -#include "sdk_common.h" -#if NRF_MODULE_ENABLED(BLE_HIDS) -#include "ble_hids.h" -#include -#include "app_error.h" -#include "ble_srv_common.h" - - -// Protocol Mode values -#define PROTOCOL_MODE_BOOT 0x00 /**< Boot Protocol Mode. */ -#define PROTOCOL_MODE_REPORT 0x01 /**< Report Protocol Mode. */ - -// HID Control Point values -#define HIDS_CONTROL_POINT_SUSPEND 0 /**< Suspend command. */ -#define HIDS_CONTROL_POINT_EXIT_SUSPEND 1 /**< Exit Suspend command. */ - -#define DEFAULT_PROTOCOL_MODE PROTOCOL_MODE_REPORT /**< Default value for the Protocol Mode characteristic. */ -#define INITIAL_VALUE_HID_CONTROL_POINT HIDS_CONTROL_POINT_SUSPEND /**< Initial value for the HID Control Point characteristic. */ - -#define ENCODED_HID_INFORMATION_LEN 4 /**< Maximum size of an encoded HID Information characteristic. */ - -#define BOOT_KB_INPUT_REPORT_MAX_SIZE 8 /**< Maximum size of a Boot Keyboard Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ -#define BOOT_KB_OUTPUT_REPORT_MAX_SIZE 1 /**< Maximum size of a Boot Keyboard Output Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ -#define BOOT_MOUSE_INPUT_REPORT_MIN_SIZE 3 /**< Minimum size of a Boot Mouse Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ -#define BOOT_MOUSE_INPUT_REPORT_MAX_SIZE 8 /**< Maximum size of a Boot Mouse Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ - - -/**@brief Function for making a HID Service characteristic id. - * - * @param[in] uuid UUID of characteristic. - * @param[in] rep_type Type of report. - * @param[in] rep_index Index of the characteristic. - * - * @return HID Service characteristic id structure. - */ -static ble_hids_char_id_t make_char_id(uint16_t uuid, uint8_t rep_type, uint8_t rep_index) -{ - ble_hids_char_id_t char_id = {0}; - - char_id.uuid = uuid; - char_id.rep_type = rep_type; - char_id.rep_index = rep_index; - - return char_id; -} - - -/**@brief Function for handling the Connect event. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_connect(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) -{ - uint32_t err_code; - uint8_t default_protocol_mode; - ble_gatts_value_t gatts_value; - - p_hids->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - - if (p_hids->protocol_mode_handles.value_handle) - { - // Set Protocol Mode characteristic value to default value - default_protocol_mode = DEFAULT_PROTOCOL_MODE; - - // Initialize value struct. - memset(&gatts_value, 0, sizeof(gatts_value)); - - gatts_value.len = sizeof(uint8_t); - gatts_value.offset = 0; - gatts_value.p_value = &default_protocol_mode; - - err_code = sd_ble_gatts_value_set(p_hids->conn_handle, - p_hids->protocol_mode_handles.value_handle, - &gatts_value); - if ((err_code != NRF_SUCCESS) && (p_hids->error_handler != NULL)) - { - p_hids->error_handler(err_code); - } - } -} - - -/**@brief Function for handling the Disconnect event. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_disconnect(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) -{ - UNUSED_PARAMETER(p_ble_evt); - p_hids->conn_handle = BLE_CONN_HANDLE_INVALID; -} - - -/**@brief Function for handling write events to the HID Control Point value. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_evt_write Write event received from the BLE stack. - */ -static void on_control_point_write(ble_hids_t * p_hids, ble_gatts_evt_write_t const * p_evt_write) -{ - if ((p_evt_write->len == 1) && (p_hids->evt_handler != NULL)) - { - ble_hids_evt_t evt; - - // HID Control Point written, propagate event to application - switch (p_evt_write->data[0]) - { - case HIDS_CONTROL_POINT_SUSPEND: - evt.evt_type = BLE_HIDS_EVT_HOST_SUSP; - break; - - case HIDS_CONTROL_POINT_EXIT_SUSPEND: - evt.evt_type = BLE_HIDS_EVT_HOST_EXIT_SUSP; - break; - - default: - // Illegal Control Point value, ignore - return; - } - - p_hids->evt_handler(p_hids, &evt); - } -} - - -/**@brief Function for handling write events to the Protocol Mode value. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_evt_write Write event received from the BLE stack. - */ -static void on_protocol_mode_write(ble_hids_t * p_hids, ble_gatts_evt_write_t const * p_evt_write) -{ - if ((p_evt_write->len == 1) && (p_hids->evt_handler != NULL)) - { - ble_hids_evt_t evt; - - // HID Protocol Mode written, propagate event to application - switch (p_evt_write->data[0]) - { - case PROTOCOL_MODE_BOOT: - evt.evt_type = BLE_HIDS_EVT_BOOT_MODE_ENTERED; - break; - - case PROTOCOL_MODE_REPORT: - evt.evt_type = BLE_HIDS_EVT_REPORT_MODE_ENTERED; - break; - - default: - // Illegal Protocol Mode value, ignore - return; - } - - p_hids->evt_handler(p_hids, &evt); - } -} - - -/**@brief Function for handling write events to a report CCCD. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_char_id Id of report characteristic. - * @param[in] p_evt_write Write event received from the BLE stack. - */ -static void on_report_cccd_write(ble_hids_t * p_hids, - ble_hids_char_id_t * p_char_id, - ble_gatts_evt_write_t const * p_evt_write) -{ - if (p_evt_write->len == 2) - { - // CCCD written, update notification state - if (p_hids->evt_handler != NULL) - { - ble_hids_evt_t evt; - - if (ble_srv_is_notification_enabled(p_evt_write->data)) - { - evt.evt_type = BLE_HIDS_EVT_NOTIF_ENABLED; - } - else - { - evt.evt_type = BLE_HIDS_EVT_NOTIF_DISABLED; - } - evt.params.notification.char_id = *p_char_id; - - p_hids->evt_handler(p_hids, &evt); - } - } -} - - -/**@brief Function for handling write events to a report value. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_char_id Id of report characteristic. - */ -static void on_report_value_write(ble_hids_t * p_hids, - ble_evt_t const * p_ble_evt, - ble_hids_char_id_t * p_char_id) -{ - if (p_hids->evt_handler != NULL) - { - ble_hids_evt_t evt; - - evt.evt_type = BLE_HIDS_EVT_REP_CHAR_WRITE; - evt.params.char_write.char_id = *p_char_id; - evt.params.char_write.offset = p_ble_evt->evt.gatts_evt.params.write.offset; - evt.params.char_write.len = p_ble_evt->evt.gatts_evt.params.write.len; - evt.params.char_write.data = (uint8_t*)p_ble_evt->evt.gatts_evt.params.write.data; - - p_hids->evt_handler(p_hids, &evt); - } -} - -/**@brief Handle authorize read events to a report value. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_char_id Id of report characteristic. - */ -static void on_report_value_read_auth(ble_hids_t * p_hids, - ble_hids_char_id_t * p_char_id, - ble_evt_t const * p_ble_evt) -{ - if (p_hids->evt_handler != NULL) - { - ble_hids_evt_t evt; - - evt.evt_type = BLE_HIDS_EVT_REPORT_READ; - evt.params.char_auth_read.char_id = *p_char_id; - evt.p_ble_evt = (ble_evt_t*)p_ble_evt; - - p_hids->evt_handler(p_hids, &evt); - } -} - -/**@brief Function for finding the Characteristic Id of a characteristic corresponding to a CCCD handle. - * - * @param[in] p_hids HID Service structure. - * @param[in] handle Handle to search for. - * @param[out] p_char_id Id of report characteristic. - * - * @return TRUE if CCCD handle was found, FALSE otherwise. - */ -static bool inp_rep_cccd_identify(ble_hids_t * p_hids, - uint16_t handle, - ble_hids_char_id_t * p_char_id) -{ - uint8_t i; - - for (i = 0; i < p_hids->inp_rep_count; i++) - { - if (handle == p_hids->inp_rep_array[i].char_handles.cccd_handle) - { - *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_INPUT, i); - return true; - } - } - - return false; -} - - -/**@brief Function for finding the Characteristic Id of a characteristic corresponding to a value handle. - * - * @param[in] p_hids HID Service structure. - * @param[in] handle Handle to search for. - * @param[out] p_char_id Id of report characteristic. - * - * @return TRUE if value handle was found, FALSE otherwise. - */ -static bool rep_value_identify(ble_hids_t * p_hids, - uint16_t handle, - ble_hids_char_id_t * p_char_id) -{ - uint8_t i; - - for (i = 0; i < p_hids->inp_rep_count; i++) - { - if (handle == p_hids->inp_rep_array[i].char_handles.value_handle) - { - *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_INPUT, i); - return true; - } - } - - for (i = 0; i < p_hids->outp_rep_count; i++) - { - if (handle == p_hids->outp_rep_array[i].char_handles.value_handle) - { - *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_OUTPUT, i); - return true; - } - } - - for (i = 0; i < p_hids->feature_rep_count; i++) - { - if (handle == p_hids->feature_rep_array[i].char_handles.value_handle) - { - *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_FEATURE, i); - return true; - } - } - - return false; -} - - -/**@brief Function for handling the Write event. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_write(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) -{ - ble_hids_char_id_t char_id; - ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; - - if (p_evt_write->handle == p_hids->hid_control_point_handles.value_handle) - { - on_control_point_write(p_hids, p_evt_write); - } - else if (p_evt_write->handle == p_hids->protocol_mode_handles.value_handle) - { - on_protocol_mode_write(p_hids, p_evt_write); - } - else if (p_evt_write->handle == p_hids->boot_kb_inp_rep_handles.cccd_handle) - { - char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, 0, 0); - on_report_cccd_write(p_hids, &char_id, p_evt_write); - } - else if (p_evt_write->handle == p_hids->boot_kb_inp_rep_handles.value_handle) - { - char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, 0, 0); - on_report_value_write(p_hids, p_ble_evt, &char_id); - } - else if (p_evt_write->handle == p_hids->boot_mouse_inp_rep_handles.cccd_handle) - { - char_id = make_char_id(BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, 0, 0); - on_report_cccd_write(p_hids, &char_id, p_evt_write); - } - else if (p_evt_write->handle == p_hids->boot_mouse_inp_rep_handles.value_handle) - { - char_id = make_char_id(BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, 0, 0); - on_report_value_write(p_hids, p_ble_evt, &char_id); - } - else if (inp_rep_cccd_identify(p_hids, p_evt_write->handle, &char_id)) - { - on_report_cccd_write(p_hids, &char_id, p_evt_write); - } - else if (rep_value_identify(p_hids, p_evt_write->handle, &char_id)) - { - on_report_value_write(p_hids, p_ble_evt, &char_id); - } - else - { - // No implementation needed. - } -} - -/**@brief Read/write authorize request event handler. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_rw_authorize_request(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) -{ - ble_gatts_evt_rw_authorize_request_t const * evt_rw_auth = - &p_ble_evt->evt.gatts_evt.params.authorize_request; - - ble_hids_char_id_t char_id; - - if (evt_rw_auth->type != BLE_GATTS_AUTHORIZE_TYPE_READ) - { - // Unexpected operation - return; - } - - if (rep_value_identify(p_hids, evt_rw_auth->request.read.handle, &char_id)) - { - on_report_value_read_auth(p_hids, &char_id, p_ble_evt); - } -} - - -void ble_hids_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) -{ - ble_hids_t * p_hids = (ble_hids_t *)p_context; - - switch (p_ble_evt->header.evt_id) - { - case BLE_GAP_EVT_CONNECTED: - on_connect(p_hids, p_ble_evt); - break; - - case BLE_GAP_EVT_DISCONNECTED: - on_disconnect(p_hids, p_ble_evt); - break; - - case BLE_GATTS_EVT_WRITE: - on_write(p_hids, p_ble_evt); - break; - - case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: - on_rw_authorize_request(p_hids, p_ble_evt); - break; - - default: - // No implementation needed. - break; - } -} - - -/**@brief Function for adding Protocol Mode characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_sec_mode Characteristic security settings. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t protocol_mode_char_add(ble_hids_t * p_hids, - ble_srv_security_mode_t const * p_sec_mode) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t initial_protocol_mode; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.write_wo_resp = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_PROTOCOL_MODE_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_sec_mode->read_perm; - attr_md.write_perm = p_sec_mode->write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - initial_protocol_mode = DEFAULT_PROTOCOL_MODE; - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof(uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof(uint8_t); - attr_char_value.p_value = &initial_protocol_mode; - - return sd_ble_gatts_characteristic_add(p_hids->service_handle, - &char_md, - &attr_char_value, - &p_hids->protocol_mode_handles); -} - - -/**@brief Function for adding report characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_properties Report characteristic properties. - * @param[in] max_len Maximum length of report value. - * @param[in] p_rep_ref Report Reference descriptor. - * @param[in] p_rep_ref_attr_md Characteristic security settings. - * @param[in] is_read_resp Characteristic read authorization. - * @param[out] p_rep_char Handles of new characteristic. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t rep_char_add(ble_hids_t * p_hids, - ble_gatt_char_props_t * p_properties, - uint16_t max_len, - ble_srv_report_ref_t * p_rep_ref, - ble_srv_cccd_security_mode_t * p_rep_ref_attr_md, - bool is_read_resp, - ble_hids_rep_char_t * p_rep_char) -{ - uint32_t err_code; - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t encoded_rep_ref[BLE_SRV_ENCODED_REPORT_REF_LEN]; - - // Add Report characteristic - if (p_properties->notify) - { - memset(&cccd_md, 0, sizeof(cccd_md)); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_rep_ref_attr_md->cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - } - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props = *p_properties; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = (p_properties->notify) ? &cccd_md : NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_REPORT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_rep_ref_attr_md->read_perm; - attr_md.write_perm = p_rep_ref_attr_md->write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = is_read_resp ? 1 : 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = max_len; - attr_char_value.p_value = NULL; - - err_code = sd_ble_gatts_characteristic_add(p_hids->service_handle, - &char_md, - &attr_char_value, - &p_rep_char->char_handles); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add Report Reference descriptor - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_REPORT_REF_DESCR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_rep_ref_attr_md->read_perm; - attr_md.write_perm = p_rep_ref_attr_md->write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = ble_srv_report_ref_encode(encoded_rep_ref, p_rep_ref); - attr_char_value.init_offs = 0; - attr_char_value.max_len = attr_char_value.init_len; - attr_char_value.p_value = encoded_rep_ref; - - return sd_ble_gatts_descriptor_add(p_rep_char->char_handles.value_handle, - &attr_char_value, - &p_rep_char->ref_handle); -} - - -/**@brief Function for adding Report Map characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t rep_map_char_add(ble_hids_t * p_hids, ble_hids_init_t const * p_hids_init) -{ - uint32_t err_code; - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - // Add Report Map characteristic - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_REPORT_MAP_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_hids_init->rep_map.security_mode.read_perm; - attr_md.write_perm = p_hids_init->rep_map.security_mode.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = p_hids_init->rep_map.data_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = p_hids_init->rep_map.data_len; - attr_char_value.p_value = p_hids_init->rep_map.p_data; - - err_code = sd_ble_gatts_characteristic_add(p_hids->service_handle, - &char_md, - &attr_char_value, - &p_hids->rep_map_handles); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - if (p_hids_init->rep_map.ext_rep_ref_num != 0 && p_hids_init->rep_map.p_ext_rep_ref == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - for (int i = 0; i < p_hids_init->rep_map.ext_rep_ref_num; ++i) - { - uint8_t encoded_rep_ref[sizeof(ble_uuid128_t)]; - uint8_t encoded_rep_ref_len; - - // Add External Report Reference descriptor - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_EXTERNAL_REPORT_REF_DESCR); - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - err_code = sd_ble_uuid_encode(&p_hids_init->rep_map.p_ext_rep_ref[i], - &encoded_rep_ref_len, - encoded_rep_ref); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = encoded_rep_ref_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = attr_char_value.init_len; - attr_char_value.p_value = encoded_rep_ref; - - err_code = sd_ble_gatts_descriptor_add(p_hids->rep_map_handles.value_handle, - &attr_char_value, - &p_hids->rep_map_ext_rep_ref_handle); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - - return NRF_SUCCESS; -} - - -/**@brief Function for adding Input Report characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] uuid UUID of report characteristic to be added. - * @param[in] max_data_len Maximum length of report value. - * @param[in] p_sec_mode Characteristic security settings. - * @param[out] p_char_handles Handles of new characteristic. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t boot_inp_rep_char_add(ble_hids_t * p_hids, - uint16_t uuid, - uint16_t max_data_len, - ble_srv_cccd_security_mode_t const * p_sec_mode, - ble_gatts_char_handles_t * p_char_handles) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_sec_mode->cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.write = (p_sec_mode->write_perm.sm) ? 1 : 0; - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, uuid); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_sec_mode->read_perm; - attr_md.write_perm = p_sec_mode->write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = max_data_len; - attr_char_value.p_value = NULL; - - return sd_ble_gatts_characteristic_add(p_hids->service_handle, - &char_md, - &attr_char_value, - p_char_handles); -} - - -/**@brief Function for adding Boot Keyboard Output Report characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t boot_kb_outp_rep_char_add(ble_hids_t * p_hids, ble_hids_init_t const * p_hids_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.write = 1; - char_md.char_props.write_wo_resp = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_hids_init->security_mode_boot_kb_outp_rep.read_perm; - attr_md.write_perm = p_hids_init->security_mode_boot_kb_outp_rep.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = BOOT_KB_OUTPUT_REPORT_MAX_SIZE; - attr_char_value.p_value = NULL; - - return sd_ble_gatts_characteristic_add(p_hids->service_handle, &char_md, &attr_char_value, - &p_hids->boot_kb_outp_rep_handles); -} - - -/**@brief Function for encoding a HID Information characteristic value. - * - * @param[out] p_encoded_buffer Buffer where the encoded data will be written. - * @param[in] p_hid_information Measurement to be encoded. - * - * @return Size of encoded data. - */ -static uint8_t encode_hid_information(uint8_t * p_encoded_buffer, - ble_hids_hid_information_t const * p_hid_information) -{ - uint8_t len = uint16_encode(p_hid_information->bcd_hid, p_encoded_buffer); - - p_encoded_buffer[len++] = p_hid_information->b_country_code; - p_encoded_buffer[len++] = p_hid_information->flags; - - APP_ERROR_CHECK_BOOL(len == ENCODED_HID_INFORMATION_LEN); - - return len; -} - - -/**@brief Function for adding HID Information characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t hid_information_char_add(ble_hids_t * p_hids, ble_hids_init_t const * p_hids_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t encoded_hid_information[ENCODED_HID_INFORMATION_LEN]; - uint8_t hid_info_len; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HID_INFORMATION_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_hids_init->hid_information.security_mode.read_perm; - attr_md.write_perm = p_hids_init->hid_information.security_mode.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - hid_info_len = encode_hid_information(encoded_hid_information, &p_hids_init->hid_information); - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = hid_info_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = attr_char_value.init_len; - attr_char_value.p_value = encoded_hid_information; - - return sd_ble_gatts_characteristic_add(p_hids->service_handle, &char_md, - &attr_char_value, - &p_hids->hid_information_handles); -} - - -/**@brief Function for adding HID Control Point characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_sec_mode Characteristic security settings. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t hid_control_point_char_add(ble_hids_t * p_hids, - ble_srv_security_mode_t const * p_sec_mode) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t initial_hid_control_point; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.write_wo_resp = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HID_CONTROL_POINT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_sec_mode->read_perm; - attr_md.write_perm = p_sec_mode->write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - initial_hid_control_point = INITIAL_VALUE_HID_CONTROL_POINT; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof(uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof(uint8_t); - attr_char_value.p_value = &initial_hid_control_point; - - return sd_ble_gatts_characteristic_add(p_hids->service_handle, &char_md, - &attr_char_value, - &p_hids->hid_control_point_handles); -} - - -/**@brief Function for adding input report characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t inp_rep_characteristics_add(ble_hids_t * p_hids, - ble_hids_init_t const * p_hids_init) -{ - if ((p_hids_init->inp_rep_count != 0) && (p_hids_init->p_inp_rep_array != NULL)) - { - uint8_t i; - - for (i = 0; i < p_hids_init->inp_rep_count; i++) - { - uint32_t err_code; - ble_hids_inp_rep_init_t * p_rep_init = &p_hids_init->p_inp_rep_array[i]; - ble_gatt_char_props_t properties; - - memset(&properties, 0, sizeof(properties)); - - properties.read = true; - properties.write = p_rep_init->security_mode.write_perm.sm ? 1 : 0; - properties.notify = true; - - err_code = rep_char_add(p_hids, - &properties, - p_rep_init->max_len, - &p_rep_init->rep_ref, - &p_rep_init->security_mode, - p_rep_init->read_resp, - &p_hids->inp_rep_array[i]); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - } - - return NRF_SUCCESS; -} - - -/**@brief Function for adding output report characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t outp_rep_characteristics_add(ble_hids_t * p_hids, - ble_hids_init_t const * p_hids_init) -{ - if ((p_hids_init->outp_rep_count != 0) && (p_hids_init->p_outp_rep_array != NULL)) - { - uint8_t i; - - for (i = 0; i < p_hids_init->outp_rep_count; i++) - { - uint32_t err_code; - ble_hids_outp_rep_init_t * p_rep_init = &p_hids_init->p_outp_rep_array[i]; - ble_gatt_char_props_t properties; - - memset(&properties, 0, sizeof(properties)); - - properties.read = true; - properties.write = true; - properties.write_wo_resp = true; - - err_code = rep_char_add(p_hids, - &properties, - p_rep_init->max_len, - &p_rep_init->rep_ref, - &p_rep_init->security_mode, - p_rep_init->read_resp, - &p_hids->outp_rep_array[i]); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - } - - return NRF_SUCCESS; -} - - -/**@brief Function for adding feature report characteristics. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t feature_rep_characteristics_add(ble_hids_t * p_hids, - ble_hids_init_t const * p_hids_init) -{ - if ((p_hids_init->feature_rep_count != 0) && (p_hids_init->p_feature_rep_array != NULL)) - { - uint8_t i; - - for (i = 0; i < p_hids_init->feature_rep_count; i++) - { - uint32_t err_code; - ble_hids_feature_rep_init_t * p_rep_init = &p_hids_init->p_feature_rep_array[i]; - ble_gatt_char_props_t properties; - - memset(&properties, 0, sizeof(properties)); - - properties.read = true; - properties.write = true; - - err_code = rep_char_add(p_hids, - &properties, - p_rep_init->max_len, - &p_rep_init->rep_ref, - &p_rep_init->security_mode, - p_rep_init->read_resp, - &p_hids->feature_rep_array[i]); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - } - - return NRF_SUCCESS; -} - - -/**@brief Function for adding included services. - * - * @param[in] p_hids HID Service structure. - * @param[in] p_hids_init Service initialization structure. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t includes_add(ble_hids_t * p_hids, ble_hids_init_t const * p_hids_init) -{ - uint32_t err_code; - uint8_t i; - uint16_t unused_include_handle; - - for (i = 0; i < p_hids_init->included_services_count; i++) - { - err_code = sd_ble_gatts_include_add(p_hids->service_handle, - p_hids_init->p_included_services_array[i], - &unused_include_handle); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - - return NRF_SUCCESS; -} - - -uint32_t ble_hids_init(ble_hids_t * p_hids, ble_hids_init_t const * p_hids_init) -{ - uint32_t err_code; - ble_uuid_t ble_uuid; - - if ((p_hids_init->inp_rep_count > BLE_HIDS_MAX_INPUT_REP) || - (p_hids_init->outp_rep_count > BLE_HIDS_MAX_OUTPUT_REP) || - (p_hids_init->feature_rep_count > BLE_HIDS_MAX_FEATURE_REP) - ) - { - return NRF_ERROR_INVALID_PARAM; - } - - // Initialize service structure. - p_hids->evt_handler = p_hids_init->evt_handler; - p_hids->error_handler = p_hids_init->error_handler; - p_hids->inp_rep_count = p_hids_init->inp_rep_count; - p_hids->outp_rep_count = p_hids_init->outp_rep_count; - p_hids->feature_rep_count = p_hids_init->feature_rep_count; - p_hids->conn_handle = BLE_CONN_HANDLE_INVALID; - - // Add service. - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE); - - err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, - &ble_uuid, - &p_hids->service_handle); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add includes. - err_code = includes_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - if (p_hids_init->is_kb || p_hids_init->is_mouse) - { - // Add Protocol Mode characteristic. - err_code = protocol_mode_char_add(p_hids, &p_hids_init->security_mode_protocol); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - - // Add Input Report characteristics (if any). - err_code = inp_rep_characteristics_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add Output Report characteristics (if any). - err_code = outp_rep_characteristics_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add Feature Report characteristic (if any). - err_code = feature_rep_characteristics_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add Report Map characteristic. - err_code = rep_map_char_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - if (p_hids_init->is_kb) - { - // Add Boot Keyboard Input Report characteristic. - err_code = boot_inp_rep_char_add(p_hids, - BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, - BOOT_KB_INPUT_REPORT_MAX_SIZE, - &p_hids_init->security_mode_boot_kb_inp_rep, - &p_hids->boot_kb_inp_rep_handles); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add Boot Keyboard Output Report characteristic. - err_code = boot_kb_outp_rep_char_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - - if (p_hids_init->is_mouse) - { - // Add Boot Mouse Input Report characteristic. - err_code = boot_inp_rep_char_add(p_hids, - BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, - BOOT_MOUSE_INPUT_REPORT_MAX_SIZE, - &p_hids_init->security_mode_boot_mouse_inp_rep, - &p_hids->boot_mouse_inp_rep_handles); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - - // Add HID Information characteristic. - err_code = hid_information_char_add(p_hids, p_hids_init); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Add HID Control Point characteristic. - err_code = hid_control_point_char_add(p_hids, &p_hids_init->security_mode_ctrl_point); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - return NRF_SUCCESS; -} - - -uint32_t ble_hids_inp_rep_send(ble_hids_t * p_hids, - uint8_t rep_index, - uint16_t len, - uint8_t * p_data) -{ - uint32_t err_code; - - if (rep_index < p_hids->inp_rep_count) - { - ble_hids_rep_char_t * p_rep_char = &p_hids->inp_rep_array[rep_index]; - - if (p_hids->conn_handle != BLE_CONN_HANDLE_INVALID) - { - ble_gatts_hvx_params_t hvx_params; - uint16_t hvx_len = len; - - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_rep_char->char_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_NOTIFICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = p_data; - - err_code = sd_ble_gatts_hvx(p_hids->conn_handle, &hvx_params); - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } - } - else - { - err_code = NRF_ERROR_INVALID_STATE; - } - } - else - { - err_code = NRF_ERROR_INVALID_PARAM; - } - - return err_code; -} - - -uint32_t ble_hids_boot_kb_inp_rep_send(ble_hids_t * p_hids, uint16_t len, uint8_t * p_data) -{ - uint32_t err_code; - - if (p_hids->conn_handle != BLE_CONN_HANDLE_INVALID) - { - ble_gatts_hvx_params_t hvx_params; - uint16_t hvx_len = len; - - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_hids->boot_kb_inp_rep_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_NOTIFICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = p_data; - - err_code = sd_ble_gatts_hvx(p_hids->conn_handle, &hvx_params); - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } - } - else - { - err_code = NRF_ERROR_INVALID_STATE; - } - - return err_code; -} - - -uint32_t ble_hids_boot_mouse_inp_rep_send(ble_hids_t * p_hids, - uint8_t buttons, - int8_t x_delta, - int8_t y_delta, - uint16_t optional_data_len, - uint8_t * p_optional_data) -{ - uint32_t err_code; - - if (p_hids->conn_handle != BLE_CONN_HANDLE_INVALID) - { - uint16_t hvx_len = BOOT_MOUSE_INPUT_REPORT_MIN_SIZE + optional_data_len; - - if (hvx_len <= BOOT_MOUSE_INPUT_REPORT_MAX_SIZE) - { - uint8_t buffer[BOOT_MOUSE_INPUT_REPORT_MAX_SIZE]; - ble_gatts_hvx_params_t hvx_params; - - APP_ERROR_CHECK_BOOL(BOOT_MOUSE_INPUT_REPORT_MIN_SIZE == 3); - - // Build buffer - buffer[0] = buttons; - buffer[1] = (uint8_t)x_delta; - buffer[2] = (uint8_t)y_delta; - - if (optional_data_len > 0) - { - memcpy(&buffer[3], p_optional_data, optional_data_len); - } - - // Pass buffer to stack - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_hids->boot_mouse_inp_rep_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_NOTIFICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = buffer; - - err_code = sd_ble_gatts_hvx(p_hids->conn_handle, &hvx_params); - if ((err_code == NRF_SUCCESS) && - (hvx_len != BOOT_MOUSE_INPUT_REPORT_MIN_SIZE + optional_data_len) - ) - { - err_code = NRF_ERROR_DATA_SIZE; - } - } - else - { - err_code = NRF_ERROR_DATA_SIZE; - } - } - else - { - err_code = NRF_ERROR_INVALID_STATE; - } - - return err_code; -} - - -uint32_t ble_hids_outp_rep_get(ble_hids_t * p_hids, - uint8_t rep_index, - uint16_t len, - uint8_t offset, - uint8_t * p_outp_rep) -{ - ble_gatts_value_t gatts_value; - - // Initialize value struct. - memset(&gatts_value, 0, sizeof(gatts_value)); - - gatts_value.len = len; - gatts_value.offset = offset; - gatts_value.p_value = p_outp_rep; - - return sd_ble_gatts_value_get(p_hids->conn_handle, - p_hids->outp_rep_array[rep_index].char_handles.value_handle, - &gatts_value); -} - -/** - @} -*/ -#endif // NRF_MODULE_ENABLED(BLE_HIDS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.c deleted file mode 100644 index d8fffc9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.c +++ /dev/null @@ -1,339 +0,0 @@ -/** - * Copyright (c) 2012 - 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(BLE_NUS) -#include "ble.h" -#include "ble_nus.h" -#include "ble_srv_common.h" - - -#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0003 /**< The UUID of the TX Characteristic. */ -#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0002 /**< The UUID of the RX Characteristic. */ - -#define BLE_NUS_MAX_RX_CHAR_LEN BLE_NUS_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */ -#define BLE_NUS_MAX_TX_CHAR_LEN BLE_NUS_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */ - -#define NUS_BASE_UUID {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */ - - -/**@brief Function for handling the @ref BLE_GAP_EVT_CONNECTED event from the SoftDevice. - * - * @param[in] p_nus Nordic UART Service structure. - * @param[in] p_ble_evt Pointer to the event received from BLE stack. - */ -static void on_connect(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) -{ - p_nus->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; -} - - -/**@brief Function for handling the @ref BLE_GAP_EVT_DISCONNECTED event from the SoftDevice. - * - * @param[in] p_nus Nordic UART Service structure. - * @param[in] p_ble_evt Pointer to the event received from BLE stack. - */ -static void on_disconnect(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) -{ - UNUSED_PARAMETER(p_ble_evt); - p_nus->conn_handle = BLE_CONN_HANDLE_INVALID; -} - - -/**@brief Function for handling the @ref BLE_GATTS_EVT_WRITE event from the SoftDevice. - * - * @param[in] p_nus Nordic UART Service structure. - * @param[in] p_ble_evt Pointer to the event received from BLE stack. - */ -static void on_write(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) -{ - ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; - ble_nus_evt_t evt; - evt.p_nus = p_nus; - if ( (p_evt_write->handle == p_nus->tx_handles.cccd_handle) - && (p_evt_write->len == 2)) - { - if (ble_srv_is_notification_enabled(p_evt_write->data)) - { - p_nus->is_notification_enabled = true; - evt.type = BLE_NUS_EVT_COMM_STARTED; - } - else - { - p_nus->is_notification_enabled = false; - evt.type = BLE_NUS_EVT_COMM_STOPPED; - } - p_nus->data_handler(&evt); - } - else if ( (p_evt_write->handle == p_nus->rx_handles.value_handle) - && (p_nus->data_handler != NULL)) - { - evt.params.rx_data.p_data = p_evt_write->data; - evt.params.rx_data.length = p_evt_write->len; - evt.type = BLE_NUS_EVT_RX_DATA; - p_nus->data_handler(&evt); - } - else - { - // Do Nothing. This event is not relevant for this service. - } -} - - -/**@brief Function for adding TX characteristic. - * - * @param[in] p_nus Nordic UART Service structure. - * @param[in] p_nus_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t tx_char_add(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init) -{ - /**@snippet [Adding proprietary characteristic to the SoftDevice] */ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); - - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - ble_uuid.type = p_nus->uuid_type; - ble_uuid.uuid = BLE_UUID_NUS_TX_CHARACTERISTIC; - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof(uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = BLE_NUS_MAX_TX_CHAR_LEN; - - return sd_ble_gatts_characteristic_add(p_nus->service_handle, - &char_md, - &attr_char_value, - &p_nus->tx_handles); - /**@snippet [Adding proprietary characteristic to the SoftDevice] */ -} - - -/**@brief Function for adding RX characteristic. - * - * @param[in] p_nus Nordic UART Service structure. - * @param[in] p_nus_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t rx_char_add(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.write = 1; - char_md.char_props.write_wo_resp = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - ble_uuid.type = p_nus->uuid_type; - ble_uuid.uuid = BLE_UUID_NUS_RX_CHARACTERISTIC; - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 1; - attr_char_value.init_offs = 0; - attr_char_value.max_len = BLE_NUS_MAX_RX_CHAR_LEN; - - return sd_ble_gatts_characteristic_add(p_nus->service_handle, - &char_md, - &attr_char_value, - &p_nus->rx_handles); -} - - -void ble_nus_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) -{ - if ((p_context == NULL) || (p_ble_evt == NULL)) - { - return; - } - - ble_nus_t * p_nus = (ble_nus_t *)p_context; - - switch (p_ble_evt->header.evt_id) - { - case BLE_GAP_EVT_CONNECTED: - on_connect(p_nus, p_ble_evt); - break; - - case BLE_GAP_EVT_DISCONNECTED: - on_disconnect(p_nus, p_ble_evt); - break; - - case BLE_GATTS_EVT_WRITE: - on_write(p_nus, p_ble_evt); - break; - - case BLE_GATTS_EVT_HVN_TX_COMPLETE: - { - //notify with empty data that some tx was completed. - ble_nus_evt_t evt = { - .type = BLE_NUS_EVT_TX_RDY, - .p_nus = p_nus - }; - p_nus->data_handler(&evt); - break; - } - default: - // No implementation needed. - break; - } -} - - -uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init) -{ - uint32_t err_code; - ble_uuid_t ble_uuid; - ble_uuid128_t nus_base_uuid = NUS_BASE_UUID; - - VERIFY_PARAM_NOT_NULL(p_nus); - VERIFY_PARAM_NOT_NULL(p_nus_init); - - // Initialize the service structure. - p_nus->conn_handle = BLE_CONN_HANDLE_INVALID; - p_nus->data_handler = p_nus_init->data_handler; - p_nus->is_notification_enabled = false; - - /**@snippet [Adding proprietary Service to the SoftDevice] */ - // Add a custom base UUID. - err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type); - VERIFY_SUCCESS(err_code); - - ble_uuid.type = p_nus->uuid_type; - ble_uuid.uuid = BLE_UUID_NUS_SERVICE; - - // Add the service. - err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, - &ble_uuid, - &p_nus->service_handle); - /**@snippet [Adding proprietary Service to the SoftDevice] */ - VERIFY_SUCCESS(err_code); - - // Add the RX Characteristic. - err_code = rx_char_add(p_nus, p_nus_init); - VERIFY_SUCCESS(err_code); - - // Add the TX Characteristic. - err_code = tx_char_add(p_nus, p_nus_init); - VERIFY_SUCCESS(err_code); - - return NRF_SUCCESS; -} - - -uint32_t ble_nus_string_send(ble_nus_t * p_nus, uint8_t * p_string, uint16_t * p_length) -{ - ble_gatts_hvx_params_t hvx_params; - - VERIFY_PARAM_NOT_NULL(p_nus); - - if ((p_nus->conn_handle == BLE_CONN_HANDLE_INVALID) || (!p_nus->is_notification_enabled)) - { - return NRF_ERROR_INVALID_STATE; - } - - if (*p_length > BLE_NUS_MAX_DATA_LEN) - { - return NRF_ERROR_INVALID_PARAM; - } - - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_nus->tx_handles.value_handle; - hvx_params.p_data = p_string; - hvx_params.p_len = p_length; - hvx_params.type = BLE_GATT_HVX_NOTIFICATION; - - return sd_ble_gatts_hvx(p_nus->conn_handle, &hvx_params); -} - -#endif // NRF_MODULE_ENABLED(BLE_NUS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.h deleted file mode 100644 index 4d843e3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2017 - 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 ble_sdk_srv_ots_buf Object Transfer Service, HVX buffering - * @{ - * @ingroup ble_ots - * @brief Object Transfer Service module - * - * @details This module is responsible for buffering indications and notifications. - */ - -#ifndef BLE_HVX_BUFFERING_H__ -#define BLE_HVX_BUFFERING_H__ - - -#include -#include "ble_types.h" -#include "ble_gatts.h" - -#define BLE_HVX_BUF_LEN (1 << 3) // 8 -#define BLE_HVX_BUF_MASK (BLE_HVX_BUF_LEN-1) - -/**@brief ble_hvx_t represents one notification/indication. */ -typedef struct { - uint16_t conn_handle; /**< The associated connection handle. */ - uint8_t data[BLE_GATT_ATT_MTU_DEFAULT]; /**< The hvx data. */ - uint16_t data_len; - ble_gatts_hvx_params_t params; /**< Parameters of the hvx. */ -} ble_hvx_t; - -/**@brief ble_hvx_buf_t is the structure holding the state of the hvx buffering module. */ -typedef struct { - ble_hvx_t buf[BLE_HVX_BUF_LEN]; /**< A buffer of nofications/indications. */ - - uint8_t insert_index; - uint8_t read_index; -} ble_hvx_buf_t; - -/**@brief Function for initializing the HVX buffer module. - * - * @param[out] p_ble_hvx_buf HVX buffering structure. - * @return NRF_SUCCESS If the given paramer is valid. - */ -uint32_t ble_hvx_init(ble_hvx_buf_t * p_ble_hvx_buf); - -/**@brief Function for obtaining the pointer to the next hvx. The user can then fill out the hvx structure. - * - * @param[in] p_ble_hvx_buf HVX buffering structure. - * @return ble_hvx_t * If there is a free ble_hvx_t. - * @return NULL If there is no free ble_hvx_t, or an invalid parameter is supplied. - */ -ble_hvx_t * ble_hvx_get_p_to_next_hvx(ble_hvx_buf_t * p_ble_hvx_buf); - -/**@brief Function for sending something from the HVX buffer. - * - * @param[in] p_ble_hvx_buf HVX buffering structure. - * @return NRF_SUCCESS If a indication/notification was successfully sent. - */ -uint32_t ble_hvx_buffer_process(ble_hvx_buf_t * p_ble_hvx_buf); - - -#endif // BLE_HVX_BUFFERING_H__ - -/** @} */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.c deleted file mode 100644 index 29f5ed9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.c +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2016 - 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. - * - */ -/* Disclaimer: This client implementation of the Apple Notification Center Service can and will be changed at any time by Nordic Semiconductor ASA. - * Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working. - */ - - #include "nrf_ble_ots_c.h" - #include "ancs_tx_buffer.h" - #include "sdk_macros.h" - #include "nrf_log.h" - #include "string.h" - - -static tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for messages to be transmitted to the Notification Provider. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where the next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer from where the next message to be transmitted resides. */ - - -void tx_buffer_init(void) -{ - memset(m_tx_buffer, 0, sizeof(m_tx_buffer)); -} - - -void tx_buffer_insert(tx_message_t * p_msg) -{ - - memset(&(m_tx_buffer[m_tx_insert_index]), 0, sizeof(m_tx_buffer)/sizeof(tx_message_t)); - - m_tx_buffer[m_tx_insert_index].conn_handle = p_msg->conn_handle; - m_tx_buffer[m_tx_insert_index].type = p_msg->type; - - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.handle = p_msg->req.write_req.gattc_params.handle; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.len = p_msg->req.write_req.gattc_params.len; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.write_op = p_msg->req.write_req.gattc_params.write_op; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.flags = p_msg->req.write_req.gattc_params.flags; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.p_value = m_tx_buffer[m_tx_insert_index].req.write_req.gattc_value; - m_tx_buffer[m_tx_insert_index].req.write_req.gattc_params.offset = p_msg->req.write_req.gattc_params.offset; - - if(p_msg->type == WRITE_REQ) - { - memcpy(m_tx_buffer[m_tx_insert_index].req.write_req.gattc_value, - p_msg->req.write_req.gattc_value, - WRITE_MESSAGE_LENGTH); - } - - m_tx_insert_index++; - m_tx_insert_index &= TX_BUFFER_MASK; -} - - - -void tx_buffer_process(void) -{ - if (m_tx_index != m_tx_insert_index) - { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - ++m_tx_index; - m_tx_index &= TX_BUFFER_MASK; - } - } -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.h deleted file mode 100644 index 89363d4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/ots_tx_buffer.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2012 - 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 ANCS_TX_BUFFER_H__ -#define ANCS_TX_BUFFER_H__ - -#include "nrf_ble_ancs_c.h" - -/** @file - * - * @addtogroup ble_ancs_c - * @{ - */ - -#define TX_BUFFER_MASK 0x07 //!< TX buffer mask. Must be a mask of contiguous zeroes followed by a contiguous sequence of ones: 000...111. -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) //!< Size of the send buffer, which is 1 bigger than the mask. -#define WRITE_MESSAGE_LENGTH 20 //!< Length of the write message for the CCCD/control point. - -/**@brief ANCS request types. - */ -typedef enum -{ - READ_REQ = 1, /**< Type identifying that this TX message is a read request. */ - WRITE_REQ /**< Type identifying that this TX message is a write request. */ -} tx_request_t; - - -/**@brief Structure for writing a message to the central, thus the Control Point or CCCD. - */ -typedef struct -{ - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; //!< The message to write. - ble_gattc_write_params_t gattc_params; //!< GATTC parameters for this message. -} write_params_t; - - -/**@brief Data to be transmitted to the connected master. - */ -typedef struct -{ - uint16_t conn_handle; //!< Connection handle to be used when transmitting this message. - tx_request_t type; //!< Type of this message (read or write message). - union - { - uint16_t read_handle; //!< Read request message. - write_params_t write_req; //!< Write request message. - } req; -} tx_message_t; - -/**@brief Function for clearing the TX buffer. - * - * @details Always call this function before using the TX buffer. -*/ -void tx_buffer_init(void); - -/**@brief Function for moving the pointer of the ring buffer to the next element. -*/ -void tx_buffer_insert(tx_message_t * p_msg); - -/**@brief Function for passing any pending request from the buffer to the stack. -*/ -void tx_buffer_process(void); - -/** @} */ - -#endif // ANCS_TX_BUFFER_H__ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.c deleted file mode 100644 index 15c86d1..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.c +++ /dev/null @@ -1,444 +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 "ble_conn_state.h" -#include -#include -#include -#include "ble.h" -#include "sdk_mapped_flags.h" -#include "app_error.h" -#include "nrf_sdh_ble.h" - - -#if defined(__CC_ARM) - #pragma push - #pragma anon_unions -#elif defined(__ICCARM__) - #pragma language=extended -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#endif - - -#define BLE_CONN_STATE_N_DEFAULT_FLAGS 5 /**< The number of flags kept for each connection, excluding user flags. */ -#define BLE_CONN_STATE_N_FLAGS (BLE_CONN_STATE_N_DEFAULT_FLAGS + BLE_CONN_STATE_N_USER_FLAGS) /**< The number of flags kept for each connection, including user flags. */ - -/**@brief Structure containing all the flag collections maintained by the Connection State module. - */ -typedef struct -{ - sdk_mapped_flags_t valid_flags; /**< Flags indicating which connection handles are valid. */ - sdk_mapped_flags_t connected_flags; /**< Flags indicating which connections are connected, since disconnected connection handles will not immediately be invalidated. */ - sdk_mapped_flags_t central_flags; /**< Flags indicating in which connections the local device is the central. */ - sdk_mapped_flags_t encrypted_flags; /**< Flags indicating which connections are encrypted. */ - sdk_mapped_flags_t mitm_protected_flags; /**< Flags indicating which connections have encryption with protection from man-in-the-middle attacks. */ - sdk_mapped_flags_t user_flags[BLE_CONN_STATE_N_USER_FLAGS]; /**< Flags that can be reserved by the user. The flags will be cleared when a connection is invalidated, otherwise, the user is wholly responsible for the flag states. */ -} ble_conn_state_flag_collections_t; - - -/**@brief Structure containing the internal state of the Connection State module. - */ -typedef struct -{ - uint32_t acquired_flags; /**< Bitmap for keeping track of which user flags have been acquired. */ - uint16_t valid_conn_handles[SDK_MAPPED_FLAGS_N_KEYS]; /**< List of connection handles used as keys for the sdk_mapped_flags module. */ - union - { - ble_conn_state_flag_collections_t flags; /**< Flag collections kept by the Connection State module. */ - sdk_mapped_flags_t flag_array[BLE_CONN_STATE_N_FLAGS]; /**< Flag collections as array to allow use of @ref sdk_mapped_flags_bulk_update_by_key() when setting all flags. */ - }; -} ble_conn_state_t; - - -#if defined(__CC_ARM) - #pragma pop -#elif defined(__ICCARM__) - /* leave anonymous unions enabled */ -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#endif - - -static ble_conn_state_t m_bcs = {0}; /**< Instantiation of the internal state. */ - - -/**@brief Function for resetting all internal memory to the values it had at initialization. - */ -void bcs_internal_state_reset(void) -{ - memset( &m_bcs, 0, sizeof(ble_conn_state_t) ); -} - - -/**@brief Function for activating a connection record. - * - * @param p_record The record to activate. - * @param conn_handle The connection handle to copy into the record. - * @param role The role of the connection. - * - * @return whether the record was activated successfully. - */ -static bool record_activate(uint16_t conn_handle) -{ - uint16_t available_index = sdk_mapped_flags_first_key_index_get(~m_bcs.flags.valid_flags); - - if (available_index != SDK_MAPPED_FLAGS_INVALID_INDEX) - { - m_bcs.valid_conn_handles[available_index] = conn_handle; - sdk_mapped_flags_update_by_key(m_bcs.valid_conn_handles, - &m_bcs.flags.connected_flags, - conn_handle, - 1); - sdk_mapped_flags_update_by_key(m_bcs.valid_conn_handles, - &m_bcs.flags.valid_flags, - conn_handle, - 1); - - return true; - } - - return false; -} - - -/**@brief Function for marking a connection record as invalid and resetting the values. - * - * @param p_record The record to invalidate. - */ -static void record_invalidate(uint16_t conn_handle) -{ - sdk_mapped_flags_bulk_update_by_key(m_bcs.valid_conn_handles, - m_bcs.flag_array, - BLE_CONN_STATE_N_FLAGS, - conn_handle, - 0); -} - - -/**@brief Function for marking a connection as disconnected. See @ref BLE_CONN_STATUS_DISCONNECTED. - * - * @param p_record The record of the connection to set as disconnected. - */ -static void record_set_disconnected(uint16_t conn_handle) -{ - sdk_mapped_flags_update_by_key(m_bcs.valid_conn_handles, - &m_bcs.flags.connected_flags, - conn_handle, - 0); -} - - -/**@brief Function for invalidating records with a @ref BLE_CONN_STATUS_DISCONNECTED - * connection status - */ -static void record_purge_disconnected() -{ - sdk_mapped_flags_key_list_t disconnected_list; - - disconnected_list = sdk_mapped_flags_key_list_get( - m_bcs.valid_conn_handles, - (~m_bcs.flags.connected_flags) & (m_bcs.flags.valid_flags)); - - for (uint32_t i = 0; i < disconnected_list.len; i++) - { - record_invalidate(disconnected_list.flag_keys[i]); - } -} - - -/**@brief Function for checking if a user flag has been acquired. - * - * @param[in] flag_id Which flag to check. - * - * @return Whether the flag has been acquired. - */ -static bool user_flag_is_acquired(ble_conn_state_user_flag_id_t flag_id) -{ - return ((m_bcs.acquired_flags & (1 << flag_id)) != 0); -} - - -/**@brief Function for marking a user flag as acquired. - * - * @param[in] flag_id Which flag to mark. - */ -static void user_flag_acquire(ble_conn_state_user_flag_id_t flag_id) -{ - m_bcs.acquired_flags |= (1 << flag_id); -} - - -void ble_conn_state_init(void) -{ - bcs_internal_state_reset(); -} - -/** - * @brief Function for handling BLE events. - * - * @param[in] p_ble_evt Event received from the BLE stack. - * @param[in] p_context Context. - */ -static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) -{ - switch (p_ble_evt->header.evt_id) - { - case BLE_GAP_EVT_CONNECTED: - record_purge_disconnected(); - - if ( !record_activate(p_ble_evt->evt.gap_evt.conn_handle) ) - { - // No more records available. Should not happen. - APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); - } -#if !defined (S112) - else - { - bool is_central = - (p_ble_evt->evt.gap_evt.params.connected.role == BLE_GAP_ROLE_CENTRAL); - - sdk_mapped_flags_update_by_key(m_bcs.valid_conn_handles, - &m_bcs.flags.central_flags, - p_ble_evt->evt.gap_evt.conn_handle, - is_central); - } -#endif // !defined (S112) - - break; - - case BLE_GAP_EVT_DISCONNECTED: - record_set_disconnected(p_ble_evt->evt.gap_evt.conn_handle); - break; - - case BLE_GAP_EVT_CONN_SEC_UPDATE: - sdk_mapped_flags_update_by_key( - m_bcs.valid_conn_handles, - &m_bcs.flags.encrypted_flags, - p_ble_evt->evt.gap_evt.conn_handle, - (p_ble_evt->evt.gap_evt.params.conn_sec_update.conn_sec.sec_mode.lv > 1)); - sdk_mapped_flags_update_by_key( - m_bcs.valid_conn_handles, - &m_bcs.flags.mitm_protected_flags, - p_ble_evt->evt.gap_evt.conn_handle, - (p_ble_evt->evt.gap_evt.params.conn_sec_update.conn_sec.sec_mode.lv > 2)); - break; - } -} - -NRF_SDH_BLE_OBSERVER(m_ble_evt_observer, BLE_CONN_STATE_BLE_OBSERVER_PRIO, ble_evt_handler, NULL); - - -bool ble_conn_state_valid(uint16_t conn_handle) -{ - return sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.valid_flags, - conn_handle); -} - - -uint8_t ble_conn_state_role(uint16_t conn_handle) -{ - uint8_t role = BLE_GAP_ROLE_INVALID; - - if ( sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, m_bcs.flags.valid_flags, conn_handle) ) - { - bool central = sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.central_flags, - conn_handle); -#if !defined (S112) - role = central ? BLE_GAP_ROLE_CENTRAL : BLE_GAP_ROLE_PERIPH; -#else - role = BLE_GAP_ROLE_PERIPH; - UNUSED_VARIABLE(central); -#endif // !defined (S112) - } - - return role; -} - - -ble_conn_state_status_t ble_conn_state_status(uint16_t conn_handle) -{ - ble_conn_state_status_t conn_status = BLE_CONN_STATUS_INVALID; - bool valid = sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.valid_flags, - conn_handle); - - if (valid) - { - bool connected = sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.connected_flags, - conn_handle); - - conn_status = connected ? BLE_CONN_STATUS_CONNECTED : BLE_CONN_STATUS_DISCONNECTED; - } - - return conn_status; -} - - -bool ble_conn_state_encrypted(uint16_t conn_handle) -{ - return sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.encrypted_flags, - conn_handle); -} - - -bool ble_conn_state_mitm_protected(uint16_t conn_handle) -{ - return sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.mitm_protected_flags, - conn_handle); -} - - -uint32_t ble_conn_state_n_connections(void) -{ - return sdk_mapped_flags_n_flags_set(m_bcs.flags.connected_flags); -} - - -uint32_t ble_conn_state_n_centrals(void) -{ - return sdk_mapped_flags_n_flags_set((m_bcs.flags.central_flags) & (m_bcs.flags.connected_flags)); -} - - -uint32_t ble_conn_state_n_peripherals(void) -{ - return sdk_mapped_flags_n_flags_set((~m_bcs.flags.central_flags) & (m_bcs.flags.connected_flags)); -} - - -sdk_mapped_flags_key_list_t ble_conn_state_conn_handles(void) -{ - return sdk_mapped_flags_key_list_get(m_bcs.valid_conn_handles, m_bcs.flags.valid_flags); -} - - -sdk_mapped_flags_key_list_t ble_conn_state_central_handles(void) -{ - return sdk_mapped_flags_key_list_get(m_bcs.valid_conn_handles, - (m_bcs.flags.central_flags) & (m_bcs.flags.connected_flags)); -} - - -sdk_mapped_flags_key_list_t ble_conn_state_periph_handles(void) -{ - return sdk_mapped_flags_key_list_get(m_bcs.valid_conn_handles, - (~m_bcs.flags.central_flags) & (m_bcs.flags.connected_flags)); -} - - -uint8_t ble_conn_state_conn_idx(uint16_t conn_handle) -{ - uint8_t index; - if (sdk_mapped_flags_get_by_key_w_idx(m_bcs.valid_conn_handles, - m_bcs.flags.valid_flags, - conn_handle, - &index)) - { - return index; - } - else - { - return BLE_CONN_STATE_MAX_CONNECTIONS; - } -} - - -ble_conn_state_user_flag_id_t ble_conn_state_user_flag_acquire(void) -{ - for (ble_conn_state_user_flag_id_t i = BLE_CONN_STATE_USER_FLAG0; - i < BLE_CONN_STATE_N_USER_FLAGS; - i++) - { - if ( !user_flag_is_acquired(i) ) - { - user_flag_acquire(i); - return i; - } - } - - return BLE_CONN_STATE_USER_FLAG_INVALID; -} - - -bool ble_conn_state_user_flag_get(uint16_t conn_handle, ble_conn_state_user_flag_id_t flag_id) -{ - if (user_flag_is_acquired(flag_id)) - { - return sdk_mapped_flags_get_by_key(m_bcs.valid_conn_handles, - m_bcs.flags.user_flags[flag_id], - conn_handle); - } - else - { - return false; - } -} - - -void ble_conn_state_user_flag_set(uint16_t conn_handle, - ble_conn_state_user_flag_id_t flag_id, - bool value) -{ - if (user_flag_is_acquired(flag_id)) - { - sdk_mapped_flags_update_by_key(m_bcs.valid_conn_handles, - &m_bcs.flags.user_flags[flag_id], - conn_handle, - value); - } -} - - -sdk_mapped_flags_t ble_conn_state_user_flag_collection(ble_conn_state_user_flag_id_t flag_id) -{ - if ( user_flag_is_acquired(flag_id) ) - { - return m_bcs.flags.user_flags[flag_id]; - } - else - { - return 0; - } -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.c deleted file mode 100644 index 10c2607..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.c +++ /dev/null @@ -1,144 +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(PEER_MANAGER) -#include "pm_mutex.h" - -#include -#include -#include "nrf_error.h" -#include "app_util_platform.h" - - - -/**@brief Locks the mutex defined by the mask. - * - * @param p_mutex pointer to the mutex storage. - * @param mutex_mask the mask identifying the mutex position. - * - * @retval true if the mutex could be locked. - * @retval false if the mutex was already locked. - */ -static bool lock_by_mask(uint8_t * p_mutex, uint8_t mutex_mask) -{ - bool success = false; - - if ( (*p_mutex & mutex_mask) == 0 ) - { - CRITICAL_REGION_ENTER(); - if ( (*p_mutex & mutex_mask) == 0 ) - { - *p_mutex |= mutex_mask; - - success = true; - } - CRITICAL_REGION_EXIT(); - } - - return ( success ); -} - - -void pm_mutex_init(uint8_t * p_mutex, uint16_t mutex_size) -{ - if (p_mutex != NULL) - { - memset(&p_mutex[0], 0, MUTEX_STORAGE_SIZE(mutex_size)); - } -} - - -bool pm_mutex_lock(uint8_t * p_mutex, uint16_t mutex_id) -{ - if (p_mutex != NULL) - { - return ( lock_by_mask(&(p_mutex[mutex_id >> 3]), (1 << (mutex_id & 0x07))) ); - } - else - { - return false; - } -} - - -void pm_mutex_unlock(uint8_t * p_mutex, uint16_t mutex_id) -{ - uint8_t mutex_base = mutex_id >> 3; - uint8_t mutex_mask = (1 << (mutex_id & 0x07)); - - if ((p_mutex != NULL) - && (p_mutex[mutex_base] & mutex_mask)) - { - CRITICAL_REGION_ENTER(); - p_mutex[mutex_base] &= ~mutex_mask; - CRITICAL_REGION_EXIT(); - } -} - - -uint16_t pm_mutex_lock_first_available(uint8_t * p_mutex, uint16_t mutex_size) -{ - if (p_mutex != NULL) - { - for ( uint16_t i = 0; i < mutex_size; i++ ) - { - if ( lock_by_mask(&(p_mutex[i >> 3]), 1 << (i & 0x07)) ) - { - return ( i ); - } - } - } - - return ( mutex_size ); -} - - -bool pm_mutex_lock_status_get(uint8_t * p_mutex, uint16_t mutex_id) -{ - if (p_mutex != NULL) - { - return ( (p_mutex[mutex_id >> 3] & (1 << (mutex_id & 0x07))) ); - } - else - { - return true; - } -} -#endif // NRF_MODULE_ENABLED(PEER_MANAGER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.h deleted file mode 100644 index 7031d73..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_mutex.h +++ /dev/null @@ -1,125 +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 MUTEX_H__ -#define MUTEX_H__ - - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @cond NO_DOXYGEN - * @defgroup pm_mutex Mutex - * @ingroup peer_manager - * @{ - * @brief An internal module of @ref peer_manager. This module provides thread-safe mutexes. - */ - - -/**@brief Defines the storage size of a specified mutex group. - * - * @param number_of_mutexes the number of mutexes in the group. - */ -#define MUTEX_STORAGE_SIZE(number_of_mutexes) ((7 + (number_of_mutexes)) >> 3) - - -/**@brief Initializes a mutex group. - * - * @param[in] p_mutex Pointer to the mutex group. See @ref MUTEX_STORAGE_SIZE(). - * @param[in] mutex_size The size of the mutex group in number of mutexes. - */ -void pm_mutex_init(uint8_t * p_mutex, uint16_t mutex_size); - - -/**@brief Locks the mutex specified by the bit id. - * - * @param[inout] p_mutex Pointer to the mutex group. - * @param[in] mutex_bit_id The bit id of the mutex. - * - * @retval true if it was possible to lock the mutex. - * @retval false otherwise. - */ -bool pm_mutex_lock(uint8_t * p_mutex, uint16_t mutex_bit_id); - - -/**@brief Locks the first unlocked mutex within the mutex group. - * - * @param[in, out] p_mutex Pointer to the mutex group. - * @param[in] mutex_size The size of the mutex group. - * - * @return The first unlocked mutex id in the group. - * @retval group-size if there was no unlocked mutex available. - */ -uint16_t pm_mutex_lock_first_available(uint8_t * p_mutex, uint16_t mutex_size); - - -/**@brief Unlocks the mutex specified by the bit id. - * - * @param[in, out] p_mutex Pointer to the mutex group. - * @param[in] mutex_bit_id The bit id of the mutex. - */ -void pm_mutex_unlock(uint8_t * p_mutex, uint16_t mutex_bit_id); - - -/**@brief Gets the locking status of the specified mutex. - * - * @param[in, out] p_mutex Pointer to the mutex group. - * @param[in] mutex_bit_id The bit id of the mutex. - * - * @retval true if the mutex was locked. - * @retval false otherwise. - */ -bool pm_mutex_lock_status_get(uint8_t * p_mutex, uint16_t mutex_bit_id); - - - -#ifdef __cplusplus -} -#endif - -#endif // MUTEX_H__ - -/** @} - * @endcond - */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51.h deleted file mode 100644 index 12facd4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51.h +++ /dev/null @@ -1,1202 +0,0 @@ - -/****************************************************************************************************//** - * @file nrf51.h - * - * @brief CMSIS Cortex-M0 Peripheral Access Layer Header File for - * nrf51 from Nordic Semiconductor. - * - * @version V522 - * @date 3. October 2017 - * - * @note Generated with SVDConv V2.81d - * from CMSIS SVD File 'nrf51.svd' Version 522, - * - * @par Copyright (c) 2010 - 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. - * - * - *******************************************************************************************************/ - - - -/** @addtogroup Nordic Semiconductor - * @{ - */ - -/** @addtogroup nrf51 - * @{ - */ - -#ifndef NRF51_H -#define NRF51_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* ------------------------- Interrupt Number Definition ------------------------ */ - -typedef enum { -/* ------------------- Cortex-M0 Processor Exceptions Numbers ------------------- */ - Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */ - NonMaskableInt_IRQn = -14, /*!< 2 Non maskable Interrupt, cannot be stopped or preempted */ - HardFault_IRQn = -13, /*!< 3 Hard Fault, all classes of Fault */ - SVCall_IRQn = -5, /*!< 11 System Service Call via SVC instruction */ - DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor */ - PendSV_IRQn = -2, /*!< 14 Pendable request for system service */ - SysTick_IRQn = -1, /*!< 15 System Tick Timer */ -/* ---------------------- nrf51 Specific Interrupt Numbers ---------------------- */ - POWER_CLOCK_IRQn = 0, /*!< 0 POWER_CLOCK */ - RADIO_IRQn = 1, /*!< 1 RADIO */ - UART0_IRQn = 2, /*!< 2 UART0 */ - SPI0_TWI0_IRQn = 3, /*!< 3 SPI0_TWI0 */ - SPI1_TWI1_IRQn = 4, /*!< 4 SPI1_TWI1 */ - GPIOTE_IRQn = 6, /*!< 6 GPIOTE */ - ADC_IRQn = 7, /*!< 7 ADC */ - TIMER0_IRQn = 8, /*!< 8 TIMER0 */ - TIMER1_IRQn = 9, /*!< 9 TIMER1 */ - TIMER2_IRQn = 10, /*!< 10 TIMER2 */ - RTC0_IRQn = 11, /*!< 11 RTC0 */ - TEMP_IRQn = 12, /*!< 12 TEMP */ - RNG_IRQn = 13, /*!< 13 RNG */ - ECB_IRQn = 14, /*!< 14 ECB */ - CCM_AAR_IRQn = 15, /*!< 15 CCM_AAR */ - WDT_IRQn = 16, /*!< 16 WDT */ - RTC1_IRQn = 17, /*!< 17 RTC1 */ - QDEC_IRQn = 18, /*!< 18 QDEC */ - LPCOMP_IRQn = 19, /*!< 19 LPCOMP */ - SWI0_IRQn = 20, /*!< 20 SWI0 */ - SWI1_IRQn = 21, /*!< 21 SWI1 */ - SWI2_IRQn = 22, /*!< 22 SWI2 */ - SWI3_IRQn = 23, /*!< 23 SWI3 */ - SWI4_IRQn = 24, /*!< 24 SWI4 */ - SWI5_IRQn = 25 /*!< 25 SWI5 */ -} IRQn_Type; - - -/** @addtogroup Configuration_of_CMSIS - * @{ - */ - - -/* ================================================================================ */ -/* ================ Processor and Core Peripheral Section ================ */ -/* ================================================================================ */ - -/* ----------------Configuration of the Cortex-M0 Processor and Core Peripherals---------------- */ -#define __CM0_REV 0x0301 /*!< Cortex-M0 Core Revision */ -#define __MPU_PRESENT 0 /*!< MPU present or not */ -#define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */ -#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ -/** @} */ /* End of group Configuration_of_CMSIS */ - -#include "core_cm0.h" /*!< Cortex-M0 processor and core peripherals */ -#include "system_nrf51.h" /*!< nrf51 System */ - - -/* ================================================================================ */ -/* ================ Device Specific Peripheral Section ================ */ -/* ================================================================================ */ - - -/** @addtogroup Device_Peripheral_Registers - * @{ - */ - - -/* ------------------- Start of section using anonymous unions ------------------ */ -#if defined(__CC_ARM) - #pragma push - #pragma anon_unions -#elif defined(__ICCARM__) - #pragma language=extended -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) -/* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning 586 -#else - #warning Not supported compiler type -#endif - - -typedef struct { - __O uint32_t EN; /*!< Enable channel group. */ - __O uint32_t DIS; /*!< Disable channel group. */ -} PPI_TASKS_CHG_Type; - -typedef struct { - __IO uint32_t EEP; /*!< Channel event end-point. */ - __IO uint32_t TEP; /*!< Channel task end-point. */ -} PPI_CH_Type; - - -/* ================================================================================ */ -/* ================ POWER ================ */ -/* ================================================================================ */ - - -/** - * @brief Power Control. (POWER) - */ - -typedef struct { /*!< POWER Structure */ - __I uint32_t RESERVED0[30]; - __O uint32_t TASKS_CONSTLAT; /*!< Enable constant latency mode. */ - __O uint32_t TASKS_LOWPWR; /*!< Enable low power mode (variable latency). */ - __I uint32_t RESERVED1[34]; - __IO uint32_t EVENTS_POFWARN; /*!< Power failure warning. */ - __I uint32_t RESERVED2[126]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[61]; - __IO uint32_t RESETREAS; /*!< Reset reason. */ - __I uint32_t RESERVED4[9]; - __I uint32_t RAMSTATUS; /*!< Ram status register. */ - __I uint32_t RESERVED5[53]; - __O uint32_t SYSTEMOFF; /*!< System off register. */ - __I uint32_t RESERVED6[3]; - __IO uint32_t POFCON; /*!< Power failure configuration. */ - __I uint32_t RESERVED7[2]; - __IO uint32_t GPREGRET; /*!< General purpose retention register. This register is a retained - register. */ - __I uint32_t RESERVED8; - __IO uint32_t RAMON; /*!< Ram on/off. */ - __I uint32_t RESERVED9[7]; - __IO uint32_t RESET; /*!< Pin reset functionality configuration register. This register - is a retained register. */ - __I uint32_t RESERVED10[3]; - __IO uint32_t RAMONB; /*!< Ram on/off. */ - __I uint32_t RESERVED11[8]; - __IO uint32_t DCDCEN; /*!< DCDC converter enable configuration register. */ - __I uint32_t RESERVED12[291]; - __IO uint32_t DCDCFORCE; /*!< DCDC power-up force register. */ -} NRF_POWER_Type; - - -/* ================================================================================ */ -/* ================ CLOCK ================ */ -/* ================================================================================ */ - - -/** - * @brief Clock control. (CLOCK) - */ - -typedef struct { /*!< CLOCK Structure */ - __O uint32_t TASKS_HFCLKSTART; /*!< Start HFCLK clock source. */ - __O uint32_t TASKS_HFCLKSTOP; /*!< Stop HFCLK clock source. */ - __O uint32_t TASKS_LFCLKSTART; /*!< Start LFCLK clock source. */ - __O uint32_t TASKS_LFCLKSTOP; /*!< Stop LFCLK clock source. */ - __O uint32_t TASKS_CAL; /*!< Start calibration of LFCLK RC oscillator. */ - __O uint32_t TASKS_CTSTART; /*!< Start calibration timer. */ - __O uint32_t TASKS_CTSTOP; /*!< Stop calibration timer. */ - __I uint32_t RESERVED0[57]; - __IO uint32_t EVENTS_HFCLKSTARTED; /*!< HFCLK oscillator started. */ - __IO uint32_t EVENTS_LFCLKSTARTED; /*!< LFCLK oscillator started. */ - __I uint32_t RESERVED1; - __IO uint32_t EVENTS_DONE; /*!< Calibration of LFCLK RC oscillator completed. */ - __IO uint32_t EVENTS_CTTO; /*!< Calibration timer timeout. */ - __I uint32_t RESERVED2[124]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[63]; - __I uint32_t HFCLKRUN; /*!< Task HFCLKSTART trigger status. */ - __I uint32_t HFCLKSTAT; /*!< High frequency clock status. */ - __I uint32_t RESERVED4; - __I uint32_t LFCLKRUN; /*!< Task LFCLKSTART triggered status. */ - __I uint32_t LFCLKSTAT; /*!< Low frequency clock status. */ - __I uint32_t LFCLKSRCCOPY; /*!< Clock source for the LFCLK clock, set when task LKCLKSTART is - triggered. */ - __I uint32_t RESERVED5[62]; - __IO uint32_t LFCLKSRC; /*!< Clock source for the LFCLK clock. */ - __I uint32_t RESERVED6[7]; - __IO uint32_t CTIV; /*!< Calibration timer interval. */ - __I uint32_t RESERVED7[5]; - __IO uint32_t XTALFREQ; /*!< Crystal frequency. */ -} NRF_CLOCK_Type; - - -/* ================================================================================ */ -/* ================ MPU ================ */ -/* ================================================================================ */ - - -/** - * @brief Memory Protection Unit. (MPU) - */ - -typedef struct { /*!< MPU Structure */ - __I uint32_t RESERVED0[330]; - __IO uint32_t PERR0; /*!< Configuration of peripherals in mpu regions. */ - __IO uint32_t RLENR0; /*!< Length of RAM region 0. */ - __I uint32_t RESERVED1[52]; - __IO uint32_t PROTENSET0; /*!< Erase and write protection bit enable set register. */ - __IO uint32_t PROTENSET1; /*!< Erase and write protection bit enable set register. */ - __IO uint32_t DISABLEINDEBUG; /*!< Disable erase and write protection mechanism in debug mode. */ - __IO uint32_t PROTBLOCKSIZE; /*!< Erase and write protection block size. */ -} NRF_MPU_Type; - - -/* ================================================================================ */ -/* ================ RADIO ================ */ -/* ================================================================================ */ - - -/** - * @brief The radio. (RADIO) - */ - -typedef struct { /*!< RADIO Structure */ - __O uint32_t TASKS_TXEN; /*!< Enable radio in TX mode. */ - __O uint32_t TASKS_RXEN; /*!< Enable radio in RX mode. */ - __O uint32_t TASKS_START; /*!< Start radio. */ - __O uint32_t TASKS_STOP; /*!< Stop radio. */ - __O uint32_t TASKS_DISABLE; /*!< Disable radio. */ - __O uint32_t TASKS_RSSISTART; /*!< Start the RSSI and take one sample of the receive signal strength. */ - __O uint32_t TASKS_RSSISTOP; /*!< Stop the RSSI measurement. */ - __O uint32_t TASKS_BCSTART; /*!< Start the bit counter. */ - __O uint32_t TASKS_BCSTOP; /*!< Stop the bit counter. */ - __I uint32_t RESERVED0[55]; - __IO uint32_t EVENTS_READY; /*!< Ready event. */ - __IO uint32_t EVENTS_ADDRESS; /*!< Address event. */ - __IO uint32_t EVENTS_PAYLOAD; /*!< Payload event. */ - __IO uint32_t EVENTS_END; /*!< End event. */ - __IO uint32_t EVENTS_DISABLED; /*!< Disable event. */ - __IO uint32_t EVENTS_DEVMATCH; /*!< A device address match occurred on the last received packet. */ - __IO uint32_t EVENTS_DEVMISS; /*!< No device address match occurred on the last received packet. */ - __IO uint32_t EVENTS_RSSIEND; /*!< Sampling of the receive signal strength complete. A new RSSI - sample is ready for readout at the RSSISAMPLE register. */ - __I uint32_t RESERVED1[2]; - __IO uint32_t EVENTS_BCMATCH; /*!< Bit counter reached bit count value specified in BCC register. */ - __I uint32_t RESERVED2[53]; - __IO uint32_t SHORTS; /*!< Shortcuts for the radio. */ - __I uint32_t RESERVED3[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED4[61]; - __I uint32_t CRCSTATUS; /*!< CRC status of received packet. */ - __I uint32_t RESERVED5; - __I uint32_t RXMATCH; /*!< Received address. */ - __I uint32_t RXCRC; /*!< Received CRC. */ - __I uint32_t DAI; /*!< Device address match index. */ - __I uint32_t RESERVED6[60]; - __IO uint32_t PACKETPTR; /*!< Packet pointer. Decision point: START task. */ - __IO uint32_t FREQUENCY; /*!< Frequency. */ - __IO uint32_t TXPOWER; /*!< Output power. */ - __IO uint32_t MODE; /*!< Data rate and modulation. */ - __IO uint32_t PCNF0; /*!< Packet configuration 0. */ - __IO uint32_t PCNF1; /*!< Packet configuration 1. */ - __IO uint32_t BASE0; /*!< Radio base address 0. Decision point: START task. */ - __IO uint32_t BASE1; /*!< Radio base address 1. Decision point: START task. */ - __IO uint32_t PREFIX0; /*!< Prefixes bytes for logical addresses 0 to 3. */ - __IO uint32_t PREFIX1; /*!< Prefixes bytes for logical addresses 4 to 7. */ - __IO uint32_t TXADDRESS; /*!< Transmit address select. */ - __IO uint32_t RXADDRESSES; /*!< Receive address select. */ - __IO uint32_t CRCCNF; /*!< CRC configuration. */ - __IO uint32_t CRCPOLY; /*!< CRC polynomial. */ - __IO uint32_t CRCINIT; /*!< CRC initial value. */ - __IO uint32_t TEST; /*!< Test features enable register. */ - __IO uint32_t TIFS; /*!< Inter Frame Spacing in microseconds. */ - __I uint32_t RSSISAMPLE; /*!< RSSI sample. */ - __I uint32_t RESERVED7; - __I uint32_t STATE; /*!< Current radio state. */ - __IO uint32_t DATAWHITEIV; /*!< Data whitening initial value. */ - __I uint32_t RESERVED8[2]; - __IO uint32_t BCC; /*!< Bit counter compare. */ - __I uint32_t RESERVED9[39]; - __IO uint32_t DAB[8]; /*!< Device address base segment. */ - __IO uint32_t DAP[8]; /*!< Device address prefix. */ - __IO uint32_t DACNF; /*!< Device address match configuration. */ - __I uint32_t RESERVED10[56]; - __IO uint32_t OVERRIDE0; /*!< Trim value override register 0. */ - __IO uint32_t OVERRIDE1; /*!< Trim value override register 1. */ - __IO uint32_t OVERRIDE2; /*!< Trim value override register 2. */ - __IO uint32_t OVERRIDE3; /*!< Trim value override register 3. */ - __IO uint32_t OVERRIDE4; /*!< Trim value override register 4. */ - __I uint32_t RESERVED11[561]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_RADIO_Type; - - -/* ================================================================================ */ -/* ================ UART ================ */ -/* ================================================================================ */ - - -/** - * @brief Universal Asynchronous Receiver/Transmitter. (UART) - */ - -typedef struct { /*!< UART Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start UART receiver. */ - __O uint32_t TASKS_STOPRX; /*!< Stop UART receiver. */ - __O uint32_t TASKS_STARTTX; /*!< Start UART transmitter. */ - __O uint32_t TASKS_STOPTX; /*!< Stop UART transmitter. */ - __I uint32_t RESERVED0[3]; - __O uint32_t TASKS_SUSPEND; /*!< Suspend UART. */ - __I uint32_t RESERVED1[56]; - __IO uint32_t EVENTS_CTS; /*!< CTS activated. */ - __IO uint32_t EVENTS_NCTS; /*!< CTS deactivated. */ - __IO uint32_t EVENTS_RXDRDY; /*!< Data received in RXD. */ - __I uint32_t RESERVED2[4]; - __IO uint32_t EVENTS_TXDRDY; /*!< Data sent from TXD. */ - __I uint32_t RESERVED3; - __IO uint32_t EVENTS_ERROR; /*!< Error detected. */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_RXTO; /*!< Receiver timeout. */ - __I uint32_t RESERVED5[46]; - __IO uint32_t SHORTS; /*!< Shortcuts for UART. */ - __I uint32_t RESERVED6[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED7[93]; - __IO uint32_t ERRORSRC; /*!< Error source. Write error field to 1 to clear error. */ - __I uint32_t RESERVED8[31]; - __IO uint32_t ENABLE; /*!< Enable UART and acquire IOs. */ - __I uint32_t RESERVED9; - __IO uint32_t PSELRTS; /*!< Pin select for RTS. */ - __IO uint32_t PSELTXD; /*!< Pin select for TXD. */ - __IO uint32_t PSELCTS; /*!< Pin select for CTS. */ - __IO uint32_t PSELRXD; /*!< Pin select for RXD. */ - __I uint32_t RXD; /*!< RXD register. On read action the buffer pointer is displaced. - Once read the character is consumed. If read when no character - available, the UART will stop working. */ - __O uint32_t TXD; /*!< TXD register. */ - __I uint32_t RESERVED10; - __IO uint32_t BAUDRATE; /*!< UART Baudrate. */ - __I uint32_t RESERVED11[17]; - __IO uint32_t CONFIG; /*!< Configuration of parity and hardware flow control register. */ - __I uint32_t RESERVED12[675]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_UART_Type; - - -/* ================================================================================ */ -/* ================ SPI ================ */ -/* ================================================================================ */ - - -/** - * @brief SPI master 0. (SPI) - */ - -typedef struct { /*!< SPI Structure */ - __I uint32_t RESERVED0[66]; - __IO uint32_t EVENTS_READY; /*!< TXD byte sent and RXD byte received. */ - __I uint32_t RESERVED1[126]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< Enable SPI. */ - __I uint32_t RESERVED3; - __IO uint32_t PSELSCK; /*!< Pin select for SCK. */ - __IO uint32_t PSELMOSI; /*!< Pin select for MOSI. */ - __IO uint32_t PSELMISO; /*!< Pin select for MISO. */ - __I uint32_t RESERVED4; - __I uint32_t RXD; /*!< RX data. */ - __IO uint32_t TXD; /*!< TX data. */ - __I uint32_t RESERVED5; - __IO uint32_t FREQUENCY; /*!< SPI frequency */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CONFIG; /*!< Configuration register. */ - __I uint32_t RESERVED7[681]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_SPI_Type; - - -/* ================================================================================ */ -/* ================ TWI ================ */ -/* ================================================================================ */ - - -/** - * @brief Two-wire interface master 0. (TWI) - */ - -typedef struct { /*!< TWI Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start 2-Wire master receive sequence. */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTTX; /*!< Start 2-Wire master transmit sequence. */ - __I uint32_t RESERVED1[2]; - __O uint32_t TASKS_STOP; /*!< Stop 2-Wire transaction. */ - __I uint32_t RESERVED2; - __O uint32_t TASKS_SUSPEND; /*!< Suspend 2-Wire transaction. */ - __O uint32_t TASKS_RESUME; /*!< Resume 2-Wire transaction. */ - __I uint32_t RESERVED3[56]; - __IO uint32_t EVENTS_STOPPED; /*!< Two-wire stopped. */ - __IO uint32_t EVENTS_RXDREADY; /*!< Two-wire ready to deliver new RXD byte received. */ - __I uint32_t RESERVED4[4]; - __IO uint32_t EVENTS_TXDSENT; /*!< Two-wire finished sending last TXD byte. */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_ERROR; /*!< Two-wire error detected. */ - __I uint32_t RESERVED6[4]; - __IO uint32_t EVENTS_BB; /*!< Two-wire byte boundary. */ - __I uint32_t RESERVED7[3]; - __IO uint32_t EVENTS_SUSPENDED; /*!< Two-wire suspended. */ - __I uint32_t RESERVED8[45]; - __IO uint32_t SHORTS; /*!< Shortcuts for TWI. */ - __I uint32_t RESERVED9[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED10[110]; - __IO uint32_t ERRORSRC; /*!< Two-wire error source. Write error field to 1 to clear error. */ - __I uint32_t RESERVED11[14]; - __IO uint32_t ENABLE; /*!< Enable two-wire master. */ - __I uint32_t RESERVED12; - __IO uint32_t PSELSCL; /*!< Pin select for SCL. */ - __IO uint32_t PSELSDA; /*!< Pin select for SDA. */ - __I uint32_t RESERVED13[2]; - __I uint32_t RXD; /*!< RX data register. */ - __IO uint32_t TXD; /*!< TX data register. */ - __I uint32_t RESERVED14; - __IO uint32_t FREQUENCY; /*!< Two-wire frequency. */ - __I uint32_t RESERVED15[24]; - __IO uint32_t ADDRESS; /*!< Address used in the two-wire transfer. */ - __I uint32_t RESERVED16[668]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_TWI_Type; - - -/* ================================================================================ */ -/* ================ SPIS ================ */ -/* ================================================================================ */ - - -/** - * @brief SPI slave 1. (SPIS) - */ - -typedef struct { /*!< SPIS Structure */ - __I uint32_t RESERVED0[9]; - __O uint32_t TASKS_ACQUIRE; /*!< Acquire SPI semaphore. */ - __O uint32_t TASKS_RELEASE; /*!< Release SPI semaphore. */ - __I uint32_t RESERVED1[54]; - __IO uint32_t EVENTS_END; /*!< Granted transaction completed. */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED3[5]; - __IO uint32_t EVENTS_ACQUIRED; /*!< Semaphore acquired. */ - __I uint32_t RESERVED4[53]; - __IO uint32_t SHORTS; /*!< Shortcuts for SPIS. */ - __I uint32_t RESERVED5[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED6[61]; - __I uint32_t SEMSTAT; /*!< Semaphore status. */ - __I uint32_t RESERVED7[15]; - __IO uint32_t STATUS; /*!< Status from last transaction. */ - __I uint32_t RESERVED8[47]; - __IO uint32_t ENABLE; /*!< Enable SPIS. */ - __I uint32_t RESERVED9; - __IO uint32_t PSELSCK; /*!< Pin select for SCK. */ - __IO uint32_t PSELMISO; /*!< Pin select for MISO. */ - __IO uint32_t PSELMOSI; /*!< Pin select for MOSI. */ - __IO uint32_t PSELCSN; /*!< Pin select for CSN. */ - __I uint32_t RESERVED10[7]; - __IO uint32_t RXDPTR; /*!< RX data pointer. */ - __IO uint32_t MAXRX; /*!< Maximum number of bytes in the receive buffer. */ - __I uint32_t AMOUNTRX; /*!< Number of bytes received in last granted transaction. */ - __I uint32_t RESERVED11; - __IO uint32_t TXDPTR; /*!< TX data pointer. */ - __IO uint32_t MAXTX; /*!< Maximum number of bytes in the transmit buffer. */ - __I uint32_t AMOUNTTX; /*!< Number of bytes transmitted in last granted transaction. */ - __I uint32_t RESERVED12; - __IO uint32_t CONFIG; /*!< Configuration register. */ - __I uint32_t RESERVED13; - __IO uint32_t DEF; /*!< Default character. */ - __I uint32_t RESERVED14[24]; - __IO uint32_t ORC; /*!< Over-read character. */ - __I uint32_t RESERVED15[654]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_SPIS_Type; - - -/* ================================================================================ */ -/* ================ GPIOTE ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO tasks and events. (GPIOTE) - */ - -typedef struct { /*!< GPIOTE Structure */ - __O uint32_t TASKS_OUT[4]; /*!< Tasks asssociated with GPIOTE channels. */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_IN[4]; /*!< Tasks asssociated with GPIOTE channels. */ - __I uint32_t RESERVED1[27]; - __IO uint32_t EVENTS_PORT; /*!< Event generated from multiple pins. */ - __I uint32_t RESERVED2[97]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[129]; - __IO uint32_t CONFIG[4]; /*!< Channel configuration registers. */ - __I uint32_t RESERVED4[695]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_GPIOTE_Type; - - -/* ================================================================================ */ -/* ================ ADC ================ */ -/* ================================================================================ */ - - -/** - * @brief Analog to digital converter. (ADC) - */ - -typedef struct { /*!< ADC Structure */ - __O uint32_t TASKS_START; /*!< Start an ADC conversion. */ - __O uint32_t TASKS_STOP; /*!< Stop ADC. */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_END; /*!< ADC conversion complete. */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED2[61]; - __I uint32_t BUSY; /*!< ADC busy register. */ - __I uint32_t RESERVED3[63]; - __IO uint32_t ENABLE; /*!< ADC enable. */ - __IO uint32_t CONFIG; /*!< ADC configuration register. */ - __I uint32_t RESULT; /*!< Result of ADC conversion. */ - __I uint32_t RESERVED4[700]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_ADC_Type; - - -/* ================================================================================ */ -/* ================ TIMER ================ */ -/* ================================================================================ */ - - -/** - * @brief Timer 0. (TIMER) - */ - -typedef struct { /*!< TIMER Structure */ - __O uint32_t TASKS_START; /*!< Start Timer. */ - __O uint32_t TASKS_STOP; /*!< Stop Timer. */ - __O uint32_t TASKS_COUNT; /*!< Increment Timer (In counter mode). */ - __O uint32_t TASKS_CLEAR; /*!< Clear timer. */ - __O uint32_t TASKS_SHUTDOWN; /*!< Shutdown timer. */ - __I uint32_t RESERVED0[11]; - __O uint32_t TASKS_CAPTURE[4]; /*!< Capture Timer value to CC[n] registers. */ - __I uint32_t RESERVED1[60]; - __IO uint32_t EVENTS_COMPARE[4]; /*!< Compare event on CC[n] match. */ - __I uint32_t RESERVED2[44]; - __IO uint32_t SHORTS; /*!< Shortcuts for Timer. */ - __I uint32_t RESERVED3[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED4[126]; - __IO uint32_t MODE; /*!< Timer Mode selection. */ - __IO uint32_t BITMODE; /*!< Sets timer behaviour. */ - __I uint32_t RESERVED5; - __IO uint32_t PRESCALER; /*!< 4-bit prescaler to source clock frequency (max value 9). Source - clock frequency is divided by 2^SCALE. */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CC[4]; /*!< Capture/compare registers. */ - __I uint32_t RESERVED7[683]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_TIMER_Type; - - -/* ================================================================================ */ -/* ================ RTC ================ */ -/* ================================================================================ */ - - -/** - * @brief Real time counter 0. (RTC) - */ - -typedef struct { /*!< RTC Structure */ - __O uint32_t TASKS_START; /*!< Start RTC Counter. */ - __O uint32_t TASKS_STOP; /*!< Stop RTC Counter. */ - __O uint32_t TASKS_CLEAR; /*!< Clear RTC Counter. */ - __O uint32_t TASKS_TRIGOVRFLW; /*!< Set COUNTER to 0xFFFFFFF0. */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_TICK; /*!< Event on COUNTER increment. */ - __IO uint32_t EVENTS_OVRFLW; /*!< Event on COUNTER overflow. */ - __I uint32_t RESERVED1[14]; - __IO uint32_t EVENTS_COMPARE[4]; /*!< Compare event on CC[n] match. */ - __I uint32_t RESERVED2[109]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[13]; - __IO uint32_t EVTEN; /*!< Configures event enable routing to PPI for each RTC event. */ - __IO uint32_t EVTENSET; /*!< Enable events routing to PPI. The reading of this register gives - the value of EVTEN. */ - __IO uint32_t EVTENCLR; /*!< Disable events routing to PPI. The reading of this register - gives the value of EVTEN. */ - __I uint32_t RESERVED4[110]; - __I uint32_t COUNTER; /*!< Current COUNTER value. */ - __IO uint32_t PRESCALER; /*!< 12-bit prescaler for COUNTER frequency (32768/(PRESCALER+1)). - Must be written when RTC is STOPed. */ - __I uint32_t RESERVED5[13]; - __IO uint32_t CC[4]; /*!< Capture/compare registers. */ - __I uint32_t RESERVED6[683]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_RTC_Type; - - -/* ================================================================================ */ -/* ================ TEMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Temperature Sensor. (TEMP) - */ - -typedef struct { /*!< TEMP Structure */ - __O uint32_t TASKS_START; /*!< Start temperature measurement. */ - __O uint32_t TASKS_STOP; /*!< Stop temperature measurement. */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_DATARDY; /*!< Temperature measurement complete, data ready event. */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED2[127]; - __I int32_t TEMP; /*!< Die temperature in degC, 2's complement format, 0.25 degC pecision. */ - __I uint32_t RESERVED3[700]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_TEMP_Type; - - -/* ================================================================================ */ -/* ================ RNG ================ */ -/* ================================================================================ */ - - -/** - * @brief Random Number Generator. (RNG) - */ - -typedef struct { /*!< RNG Structure */ - __O uint32_t TASKS_START; /*!< Start the random number generator. */ - __O uint32_t TASKS_STOP; /*!< Stop the random number generator. */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_VALRDY; /*!< New random number generated and written to VALUE register. */ - __I uint32_t RESERVED1[63]; - __IO uint32_t SHORTS; /*!< Shortcuts for the RNG. */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register */ - __I uint32_t RESERVED3[126]; - __IO uint32_t CONFIG; /*!< Configuration register. */ - __I uint32_t VALUE; /*!< RNG random number. */ - __I uint32_t RESERVED4[700]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_RNG_Type; - - -/* ================================================================================ */ -/* ================ ECB ================ */ -/* ================================================================================ */ - - -/** - * @brief AES ECB Mode Encryption. (ECB) - */ - -typedef struct { /*!< ECB Structure */ - __O uint32_t TASKS_STARTECB; /*!< Start ECB block encrypt. If a crypto operation is running, this - will not initiate a new encryption and the ERRORECB event will - be triggered. */ - __O uint32_t TASKS_STOPECB; /*!< Stop current ECB encryption. If a crypto operation is running, - this will will trigger the ERRORECB event. */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_ENDECB; /*!< ECB block encrypt complete. */ - __IO uint32_t EVENTS_ERRORECB; /*!< ECB block encrypt aborted due to a STOPECB task or due to an - error. */ - __I uint32_t RESERVED1[127]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED2[126]; - __IO uint32_t ECBDATAPTR; /*!< ECB block encrypt memory pointer. */ - __I uint32_t RESERVED3[701]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_ECB_Type; - - -/* ================================================================================ */ -/* ================ AAR ================ */ -/* ================================================================================ */ - - -/** - * @brief Accelerated Address Resolver. (AAR) - */ - -typedef struct { /*!< AAR Structure */ - __O uint32_t TASKS_START; /*!< Start resolving addresses based on IRKs specified in the IRK - data structure. */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stop resolving addresses. */ - __I uint32_t RESERVED1[61]; - __IO uint32_t EVENTS_END; /*!< Address resolution procedure completed. */ - __IO uint32_t EVENTS_RESOLVED; /*!< Address resolved. */ - __IO uint32_t EVENTS_NOTRESOLVED; /*!< Address not resolved. */ - __I uint32_t RESERVED2[126]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[61]; - __I uint32_t STATUS; /*!< Resolution status. */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable AAR. */ - __IO uint32_t NIRK; /*!< Number of Identity root Keys in the IRK data structure. */ - __IO uint32_t IRKPTR; /*!< Pointer to the IRK data structure. */ - __I uint32_t RESERVED5; - __IO uint32_t ADDRPTR; /*!< Pointer to the resolvable address (6 bytes). */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to a scratch data area used for temporary storage during - resolution. A minimum of 3 bytes must be reserved. */ - __I uint32_t RESERVED6[697]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_AAR_Type; - - -/* ================================================================================ */ -/* ================ CCM ================ */ -/* ================================================================================ */ - - -/** - * @brief AES CCM Mode Encryption. (CCM) - */ - -typedef struct { /*!< CCM Structure */ - __O uint32_t TASKS_KSGEN; /*!< Start generation of key-stream. This operation will stop by - itself when completed. */ - __O uint32_t TASKS_CRYPT; /*!< Start encrypt/decrypt. This operation will stop by itself when - completed. */ - __O uint32_t TASKS_STOP; /*!< Stop encrypt/decrypt. */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_ENDKSGEN; /*!< Keystream generation completed. */ - __IO uint32_t EVENTS_ENDCRYPT; /*!< Encrypt/decrypt completed. */ - __IO uint32_t EVENTS_ERROR; /*!< Error happened. */ - __I uint32_t RESERVED1[61]; - __IO uint32_t SHORTS; /*!< Shortcuts for the CCM. */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[61]; - __I uint32_t MICSTATUS; /*!< CCM RX MIC check result. */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< CCM enable. */ - __IO uint32_t MODE; /*!< Operation mode. */ - __IO uint32_t CNFPTR; /*!< Pointer to a data structure holding AES key and NONCE vector. */ - __IO uint32_t INPTR; /*!< Pointer to the input packet. */ - __IO uint32_t OUTPTR; /*!< Pointer to the output packet. */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to a scratch data area used for temporary storage during - resolution. A minimum of 43 bytes must be reserved. */ - __I uint32_t RESERVED5[697]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_CCM_Type; - - -/* ================================================================================ */ -/* ================ WDT ================ */ -/* ================================================================================ */ - - -/** - * @brief Watchdog Timer. (WDT) - */ - -typedef struct { /*!< WDT Structure */ - __O uint32_t TASKS_START; /*!< Start the watchdog. */ - __I uint32_t RESERVED0[63]; - __IO uint32_t EVENTS_TIMEOUT; /*!< Watchdog timeout. */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED2[61]; - __I uint32_t RUNSTATUS; /*!< Watchdog running status. */ - __I uint32_t REQSTATUS; /*!< Request status. */ - __I uint32_t RESERVED3[63]; - __IO uint32_t CRV; /*!< Counter reload value in number of 32kiHz clock cycles. */ - __IO uint32_t RREN; /*!< Reload request enable. */ - __IO uint32_t CONFIG; /*!< Configuration register. */ - __I uint32_t RESERVED4[60]; - __O uint32_t RR[8]; /*!< Reload requests registers. */ - __I uint32_t RESERVED5[631]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_WDT_Type; - - -/* ================================================================================ */ -/* ================ QDEC ================ */ -/* ================================================================================ */ - - -/** - * @brief Rotary decoder. (QDEC) - */ - -typedef struct { /*!< QDEC Structure */ - __O uint32_t TASKS_START; /*!< Start the quadrature decoder. */ - __O uint32_t TASKS_STOP; /*!< Stop the quadrature decoder. */ - __O uint32_t TASKS_READCLRACC; /*!< Transfers the content from ACC registers to ACCREAD registers, - and clears the ACC registers. */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_SAMPLERDY; /*!< A new sample is written to the sample register. */ - __IO uint32_t EVENTS_REPORTRDY; /*!< REPORTPER number of samples accumulated in ACC register, and - ACC register different than zero. */ - __IO uint32_t EVENTS_ACCOF; /*!< ACC or ACCDBL register overflow. */ - __I uint32_t RESERVED1[61]; - __IO uint32_t SHORTS; /*!< Shortcuts for the QDEC. */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[125]; - __IO uint32_t ENABLE; /*!< Enable the QDEC. */ - __IO uint32_t LEDPOL; /*!< LED output pin polarity. */ - __IO uint32_t SAMPLEPER; /*!< Sample period. */ - __I int32_t SAMPLE; /*!< Motion sample value. */ - __IO uint32_t REPORTPER; /*!< Number of samples to generate an EVENT_REPORTRDY. */ - __I int32_t ACC; /*!< Accumulated valid transitions register. */ - __I int32_t ACCREAD; /*!< Snapshot of ACC register. Value generated by the TASKS_READCLEACC - task. */ - __IO uint32_t PSELLED; /*!< Pin select for LED output. */ - __IO uint32_t PSELA; /*!< Pin select for phase A input. */ - __IO uint32_t PSELB; /*!< Pin select for phase B input. */ - __IO uint32_t DBFEN; /*!< Enable debouncer input filters. */ - __I uint32_t RESERVED4[5]; - __IO uint32_t LEDPRE; /*!< Time LED is switched ON before the sample. */ - __I uint32_t ACCDBL; /*!< Accumulated double (error) transitions register. */ - __I uint32_t ACCDBLREAD; /*!< Snapshot of ACCDBL register. Value generated by the TASKS_READCLEACC - task. */ - __I uint32_t RESERVED5[684]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_QDEC_Type; - - -/* ================================================================================ */ -/* ================ LPCOMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Low power comparator. (LPCOMP) - */ - -typedef struct { /*!< LPCOMP Structure */ - __O uint32_t TASKS_START; /*!< Start the comparator. */ - __O uint32_t TASKS_STOP; /*!< Stop the comparator. */ - __O uint32_t TASKS_SAMPLE; /*!< Sample comparator value. */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_READY; /*!< LPCOMP is ready and output is valid. */ - __IO uint32_t EVENTS_DOWN; /*!< Input voltage crossed the threshold going down. */ - __IO uint32_t EVENTS_UP; /*!< Input voltage crossed the threshold going up. */ - __IO uint32_t EVENTS_CROSS; /*!< Input voltage crossed the threshold in any direction. */ - __I uint32_t RESERVED1[60]; - __IO uint32_t SHORTS; /*!< Shortcuts for the LPCOMP. */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Interrupt enable set register. */ - __IO uint32_t INTENCLR; /*!< Interrupt enable clear register. */ - __I uint32_t RESERVED3[61]; - __I uint32_t RESULT; /*!< Result of last compare. */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable the LPCOMP. */ - __IO uint32_t PSEL; /*!< Input pin select. */ - __IO uint32_t REFSEL; /*!< Reference select. */ - __IO uint32_t EXTREFSEL; /*!< External reference select. */ - __I uint32_t RESERVED5[4]; - __IO uint32_t ANADETECT; /*!< Analog detect configuration. */ - __I uint32_t RESERVED6[694]; - __IO uint32_t POWER; /*!< Peripheral power control. */ -} NRF_LPCOMP_Type; - - -/* ================================================================================ */ -/* ================ SWI ================ */ -/* ================================================================================ */ - - -/** - * @brief SW Interrupts. (SWI) - */ - -typedef struct { /*!< SWI Structure */ - __I uint32_t UNUSED; /*!< Unused. */ -} NRF_SWI_Type; - - -/* ================================================================================ */ -/* ================ NVMC ================ */ -/* ================================================================================ */ - - -/** - * @brief Non Volatile Memory Controller. (NVMC) - */ - -typedef struct { /*!< NVMC Structure */ - __I uint32_t RESERVED0[256]; - __I uint32_t READY; /*!< Ready flag. */ - __I uint32_t RESERVED1[64]; - __IO uint32_t CONFIG; /*!< Configuration register. */ - - union { - __IO uint32_t ERASEPCR1; /*!< Register for erasing a non-protected non-volatile memory page. */ - __IO uint32_t ERASEPAGE; /*!< Register for erasing a non-protected non-volatile memory page. */ - }; - __IO uint32_t ERASEALL; /*!< Register for erasing all non-volatile user memory. */ - __IO uint32_t ERASEPCR0; /*!< Register for erasing a protected non-volatile memory page. */ - __IO uint32_t ERASEUICR; /*!< Register for start erasing User Information Congfiguration Registers. */ -} NRF_NVMC_Type; - - -/* ================================================================================ */ -/* ================ PPI ================ */ -/* ================================================================================ */ - - -/** - * @brief PPI controller. (PPI) - */ - -typedef struct { /*!< PPI Structure */ - PPI_TASKS_CHG_Type TASKS_CHG[4]; /*!< Channel group tasks. */ - __I uint32_t RESERVED0[312]; - __IO uint32_t CHEN; /*!< Channel enable. */ - __IO uint32_t CHENSET; /*!< Channel enable set. */ - __IO uint32_t CHENCLR; /*!< Channel enable clear. */ - __I uint32_t RESERVED1; - PPI_CH_Type CH[16]; /*!< PPI Channel. */ - __I uint32_t RESERVED2[156]; - __IO uint32_t CHG[4]; /*!< Channel group configuration. */ -} NRF_PPI_Type; - - -/* ================================================================================ */ -/* ================ FICR ================ */ -/* ================================================================================ */ - - -/** - * @brief Factory Information Configuration. (FICR) - */ - -typedef struct { /*!< FICR Structure */ - __I uint32_t RESERVED0[4]; - __I uint32_t CODEPAGESIZE; /*!< Code memory page size in bytes. */ - __I uint32_t CODESIZE; /*!< Code memory size in pages. */ - __I uint32_t RESERVED1[4]; - __I uint32_t CLENR0; /*!< Length of code region 0 in bytes. */ - __I uint32_t PPFC; /*!< Pre-programmed factory code present. */ - __I uint32_t RESERVED2; - __I uint32_t NUMRAMBLOCK; /*!< Number of individualy controllable RAM blocks. */ - - union { - __I uint32_t SIZERAMBLOCK[4]; /*!< Deprecated array of size of RAM block in bytes. This name is - kept for backward compatinility purposes. Use SIZERAMBLOCKS - instead. */ - __I uint32_t SIZERAMBLOCKS; /*!< Size of RAM blocks in bytes. */ - }; - __I uint32_t RESERVED3[5]; - __I uint32_t CONFIGID; /*!< Configuration identifier. */ - __I uint32_t DEVICEID[2]; /*!< Device identifier. */ - __I uint32_t RESERVED4[6]; - __I uint32_t ER[4]; /*!< Encryption root. */ - __I uint32_t IR[4]; /*!< Identity root. */ - __I uint32_t DEVICEADDRTYPE; /*!< Device address type. */ - __I uint32_t DEVICEADDR[2]; /*!< Device address. */ - __I uint32_t OVERRIDEEN; /*!< Radio calibration override enable. */ - __I uint32_t NRF_1MBIT[5]; /*!< Override values for the OVERRIDEn registers in RADIO for NRF_1Mbit - mode. */ - __I uint32_t RESERVED5[10]; - __I uint32_t BLE_1MBIT[5]; /*!< Override values for the OVERRIDEn registers in RADIO for BLE_1Mbit - mode. */ -} NRF_FICR_Type; - - -/* ================================================================================ */ -/* ================ UICR ================ */ -/* ================================================================================ */ - - -/** - * @brief User Information Configuration. (UICR) - */ - -typedef struct { /*!< UICR Structure */ - __IO uint32_t CLENR0; /*!< Length of code region 0. */ - __IO uint32_t RBPCONF; /*!< Readback protection configuration. */ - __IO uint32_t XTALFREQ; /*!< Reset value for CLOCK XTALFREQ register. */ - __I uint32_t RESERVED0; - __I uint32_t FWID; /*!< Firmware ID. */ - - union { - __IO uint32_t NRFFW[15]; /*!< Reserved for Nordic firmware design. */ - __IO uint32_t BOOTLOADERADDR; /*!< Bootloader start address. */ - }; - __IO uint32_t NRFHW[12]; /*!< Reserved for Nordic hardware design. */ - __IO uint32_t CUSTOMER[32]; /*!< Reserved for customer. */ -} NRF_UICR_Type; - - -/* ================================================================================ */ -/* ================ GPIO ================ */ -/* ================================================================================ */ - - -/** - * @brief General purpose input and output. (GPIO) - */ - -typedef struct { /*!< GPIO Structure */ - __I uint32_t RESERVED0[321]; - __IO uint32_t OUT; /*!< Write GPIO port. */ - __IO uint32_t OUTSET; /*!< Set individual bits in GPIO port. */ - __IO uint32_t OUTCLR; /*!< Clear individual bits in GPIO port. */ - __I uint32_t IN; /*!< Read GPIO port. */ - __IO uint32_t DIR; /*!< Direction of GPIO pins. */ - __IO uint32_t DIRSET; /*!< DIR set register. */ - __IO uint32_t DIRCLR; /*!< DIR clear register. */ - __I uint32_t RESERVED1[120]; - __IO uint32_t PIN_CNF[32]; /*!< Configuration of GPIO pins. */ -} NRF_GPIO_Type; - - -/* -------------------- End of section using anonymous unions ------------------- */ -#if defined(__CC_ARM) - #pragma pop -#elif defined(__ICCARM__) - /* leave anonymous unions enabled */ -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) - /* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning restore -#else - #warning Not supported compiler type -#endif - - - - -/* ================================================================================ */ -/* ================ Peripheral memory map ================ */ -/* ================================================================================ */ - -#define NRF_POWER_BASE 0x40000000UL -#define NRF_CLOCK_BASE 0x40000000UL -#define NRF_MPU_BASE 0x40000000UL -#define NRF_RADIO_BASE 0x40001000UL -#define NRF_UART0_BASE 0x40002000UL -#define NRF_SPI0_BASE 0x40003000UL -#define NRF_TWI0_BASE 0x40003000UL -#define NRF_SPI1_BASE 0x40004000UL -#define NRF_TWI1_BASE 0x40004000UL -#define NRF_SPIS1_BASE 0x40004000UL -#define NRF_GPIOTE_BASE 0x40006000UL -#define NRF_ADC_BASE 0x40007000UL -#define NRF_TIMER0_BASE 0x40008000UL -#define NRF_TIMER1_BASE 0x40009000UL -#define NRF_TIMER2_BASE 0x4000A000UL -#define NRF_RTC0_BASE 0x4000B000UL -#define NRF_TEMP_BASE 0x4000C000UL -#define NRF_RNG_BASE 0x4000D000UL -#define NRF_ECB_BASE 0x4000E000UL -#define NRF_AAR_BASE 0x4000F000UL -#define NRF_CCM_BASE 0x4000F000UL -#define NRF_WDT_BASE 0x40010000UL -#define NRF_RTC1_BASE 0x40011000UL -#define NRF_QDEC_BASE 0x40012000UL -#define NRF_LPCOMP_BASE 0x40013000UL -#define NRF_SWI_BASE 0x40014000UL -#define NRF_NVMC_BASE 0x4001E000UL -#define NRF_PPI_BASE 0x4001F000UL -#define NRF_FICR_BASE 0x10000000UL -#define NRF_UICR_BASE 0x10001000UL -#define NRF_GPIO_BASE 0x50000000UL - - -/* ================================================================================ */ -/* ================ Peripheral declaration ================ */ -/* ================================================================================ */ - -#define NRF_POWER ((NRF_POWER_Type *) NRF_POWER_BASE) -#define NRF_CLOCK ((NRF_CLOCK_Type *) NRF_CLOCK_BASE) -#define NRF_MPU ((NRF_MPU_Type *) NRF_MPU_BASE) -#define NRF_RADIO ((NRF_RADIO_Type *) NRF_RADIO_BASE) -#define NRF_UART0 ((NRF_UART_Type *) NRF_UART0_BASE) -#define NRF_SPI0 ((NRF_SPI_Type *) NRF_SPI0_BASE) -#define NRF_TWI0 ((NRF_TWI_Type *) NRF_TWI0_BASE) -#define NRF_SPI1 ((NRF_SPI_Type *) NRF_SPI1_BASE) -#define NRF_TWI1 ((NRF_TWI_Type *) NRF_TWI1_BASE) -#define NRF_SPIS1 ((NRF_SPIS_Type *) NRF_SPIS1_BASE) -#define NRF_GPIOTE ((NRF_GPIOTE_Type *) NRF_GPIOTE_BASE) -#define NRF_ADC ((NRF_ADC_Type *) NRF_ADC_BASE) -#define NRF_TIMER0 ((NRF_TIMER_Type *) NRF_TIMER0_BASE) -#define NRF_TIMER1 ((NRF_TIMER_Type *) NRF_TIMER1_BASE) -#define NRF_TIMER2 ((NRF_TIMER_Type *) NRF_TIMER2_BASE) -#define NRF_RTC0 ((NRF_RTC_Type *) NRF_RTC0_BASE) -#define NRF_TEMP ((NRF_TEMP_Type *) NRF_TEMP_BASE) -#define NRF_RNG ((NRF_RNG_Type *) NRF_RNG_BASE) -#define NRF_ECB ((NRF_ECB_Type *) NRF_ECB_BASE) -#define NRF_AAR ((NRF_AAR_Type *) NRF_AAR_BASE) -#define NRF_CCM ((NRF_CCM_Type *) NRF_CCM_BASE) -#define NRF_WDT ((NRF_WDT_Type *) NRF_WDT_BASE) -#define NRF_RTC1 ((NRF_RTC_Type *) NRF_RTC1_BASE) -#define NRF_QDEC ((NRF_QDEC_Type *) NRF_QDEC_BASE) -#define NRF_LPCOMP ((NRF_LPCOMP_Type *) NRF_LPCOMP_BASE) -#define NRF_SWI ((NRF_SWI_Type *) NRF_SWI_BASE) -#define NRF_NVMC ((NRF_NVMC_Type *) NRF_NVMC_BASE) -#define NRF_PPI ((NRF_PPI_Type *) NRF_PPI_BASE) -#define NRF_FICR ((NRF_FICR_Type *) NRF_FICR_BASE) -#define NRF_UICR ((NRF_UICR_Type *) NRF_UICR_BASE) -#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE) - - -/** @} */ /* End of group Device_Peripheral_Registers */ -/** @} */ /* End of group nrf51 */ -/** @} */ /* End of group Nordic Semiconductor */ - -#ifdef __cplusplus -} -#endif - - -#endif /* nrf51_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51422_peripherals.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51422_peripherals.h deleted file mode 100644 index 793bc65..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51422_peripherals.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - -Copyright (c) 2010 - 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 _NRF51422_PERIPHERALS_H -#define _NRF51422_PERIPHERALS_H - - -/* Power Peripheral */ -#define POWER_PRESENT -#define POWER_COUNT 1 - -#define POWER_FEATURE_RAMON_REGISTERS_PRESENT - -/* Software Interrupts */ -#define SWI_PRESENT -#define SWI_COUNT 6 - -/* GPIO */ -#define GPIO_PRESENT -#define GPIO_COUNT 1 - -#define P0_PIN_NUM 32 - -/* MPU and BPROT */ -#define BPROT_PRESENT - -#define BPROT_REGIONS_SIZE 4096 -#define BPROT_REGIONS_NUM 64 - -/* Radio */ -#define RADIO_PRESENT -#define RADIO_COUNT 1 - -/* Accelerated Address Resolver */ -#define AAR_PRESENT -#define AAR_COUNT 1 - -#define AAR_MAX_IRK_NUM 8 - -/* AES Electronic CodeBook mode encryption */ -#define ECB_PRESENT -#define ECB_COUNT 1 - -/* AES CCM mode encryption */ -#define CCM_PRESENT -#define CCM_COUNT 1 - -/* Peripheral to Peripheral Interconnect */ -#define PPI_PRESENT -#define PPI_COUNT 1 - -#define PPI_CH_NUM 16 -#define PPI_FIXED_CH_NUM 12 -#define PPI_GROUP_NUM 4 - -/* Timer/Counter */ -#define TIMER_PRESENT -#define TIMER_COUNT 3 - -#define TIMER0_MAX_SIZE 32 -#define TIMER1_MAX_SIZE 16 -#define TIMER2_MAX_SIZE 16 - -#define TIMER0_CC_NUM 4 -#define TIMER1_CC_NUM 4 -#define TIMER2_CC_NUM 4 - -/* Real Time Counter */ -#define RTC_PRESENT -#define RTC_COUNT 2 - -#define RTC0_CC_NUM 3 -#define RTC1_CC_NUM 4 - -/* RNG */ -#define RNG_PRESENT -#define RNG_COUNT 1 - -/* Watchdog Timer */ -#define WDT_PRESENT -#define WDT_COUNT 1 - -/* Temperature Sensor */ -#define TEMP_PRESENT -#define TEMP_COUNT 1 - -/* Serial Peripheral Interface Master */ -#define SPI_PRESENT -#define SPI_COUNT 2 - -/* Serial Peripheral Interface Slave with DMA */ -#define SPIS_PRESENT -#define SPIS_COUNT 1 - -#define SPIS0_EASYDMA_MAXCNT_SIZE 8 - -/* Two Wire Interface Master */ -#define TWI_PRESENT -#define TWI_COUNT 2 - -/* Universal Asynchronous Receiver-Transmitter */ -#define UART_PRESENT -#define UART_COUNT 1 - -/* Quadrature Decoder */ -#define QDEC_PRESENT -#define QDEC_COUNT 1 - -/* Analog to Digital Converter */ -#define ADC_PRESENT -#define ADC_COUNT 1 - -/* GPIO Tasks and Events */ -#define GPIOTE_PRESENT -#define GPIOTE_COUNT 1 - -#define GPIOTE_CH_NUM 4 - -/* Low Power Comparator */ -#define LPCOMP_PRESENT -#define LPCOMP_COUNT 1 - -#define LPCOMP_REFSEL_RESOLUTION 8 - - -#endif // _NRF51422_PERIPHERALS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51802_peripherals.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51802_peripherals.h deleted file mode 100644 index ca92539..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51802_peripherals.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - -Copyright (c) 2010 - 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 _NRF51802_PERIPHERALS_H -#define _NRF51802_PERIPHERALS_H - - -/* Power Peripheral */ -#define POWER_PRESENT -#define POWER_COUNT 1 - -#define POWER_FEATURE_RAMON_REGISTERS_PRESENT - -/* Software Interrupts */ -#define SWI_PRESENT -#define SWI_COUNT 6 - -/* GPIO */ -#define GPIO_PRESENT -#define GPIO_COUNT 1 - -#define P0_PIN_NUM 32 - -/* MPU and BPROT */ -#define BPROT_PRESENT - -#define BPROT_REGIONS_SIZE 4096 -#define BPROT_REGIONS_NUM 64 - -/* Radio */ -#define RADIO_PRESENT -#define RADIO_COUNT 1 - -/* Accelerated Address Resolver */ -#define AAR_PRESENT -#define AAR_COUNT 1 - -#define AAR_MAX_IRK_NUM 8 - -/* AES Electronic CodeBook mode encryption */ -#define ECB_PRESENT -#define ECB_COUNT 1 - -/* AES CCM mode encryption */ -#define CCM_PRESENT -#define CCM_COUNT 1 - -/* Peripheral to Peripheral Interconnect */ -#define PPI_PRESENT -#define PPI_COUNT 1 - -#define PPI_CH_NUM 16 -#define PPI_FIXED_CH_NUM 12 -#define PPI_GROUP_NUM 4 - -/* Timer/Counter */ -#define TIMER_PRESENT -#define TIMER_COUNT 3 - -#define TIMER0_MAX_SIZE 32 -#define TIMER1_MAX_SIZE 16 -#define TIMER2_MAX_SIZE 16 - -#define TIMER0_CC_NUM 4 -#define TIMER1_CC_NUM 4 -#define TIMER2_CC_NUM 4 - -/* Real Time Counter */ -#define RTC_PRESENT -#define RTC_COUNT 2 - -#define RTC0_CC_NUM 3 -#define RTC1_CC_NUM 4 - -/* RNG */ -#define RNG_PRESENT -#define RNG_COUNT 1 - -/* Watchdog Timer */ -#define WDT_PRESENT -#define WDT_COUNT 1 - -/* Temperature Sensor */ -#define TEMP_PRESENT -#define TEMP_COUNT 1 - -/* Serial Peripheral Interface Master */ -#define SPI_PRESENT -#define SPI_COUNT 2 - -/* Serial Peripheral Interface Slave with DMA */ -#define SPIS_PRESENT -#define SPIS_COUNT 1 - -#define SPIS0_EASYDMA_MAXCNT_SIZE 8 - -/* Two Wire Interface Master */ -#define TWI_PRESENT -#define TWI_COUNT 2 - -/* Universal Asynchronous Receiver-Transmitter */ -#define UART_PRESENT -#define UART_COUNT 1 - -/* Quadrature Decoder */ -#define QDEC_PRESENT -#define QDEC_COUNT 1 - -/* Analog to Digital Converter */ -#define ADC_PRESENT -#define ADC_COUNT 1 - -/* GPIO Tasks and Events */ -#define GPIOTE_PRESENT -#define GPIOTE_COUNT 1 - -#define GPIOTE_CH_NUM 4 - -/* Low Power Comparator */ -#define LPCOMP_PRESENT -#define LPCOMP_COUNT 1 - -#define LPCOMP_REFSEL_RESOLUTION 8 - - -#endif // _NRF51802_PERIPHERALS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51822_peripherals.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51822_peripherals.h deleted file mode 100644 index 8e01f4e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51822_peripherals.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - -Copyright (c) 2010 - 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 _NRF51822_PERIPHERALS_H -#define _NRF51822_PERIPHERALS_H - - -/* Power Peripheral */ -#define POWER_PRESENT -#define POWER_COUNT 1 - -#define POWER_FEATURE_RAMON_REGISTERS_PRESENT - -/* Software Interrupts */ -#define SWI_PRESENT -#define SWI_COUNT 6 - -/* GPIO */ -#define GPIO_PRESENT -#define GPIO_COUNT 1 - -#define P0_PIN_NUM 32 - -/* MPU and BPROT */ -#define BPROT_PRESENT - -#define BPROT_REGIONS_SIZE 4096 -#define BPROT_REGIONS_NUM 64 - -/* Radio */ -#define RADIO_PRESENT -#define RADIO_COUNT 1 - -/* Accelerated Address Resolver */ -#define AAR_PRESENT -#define AAR_COUNT 1 - -#define AAR_MAX_IRK_NUM 8 - -/* AES Electronic CodeBook mode encryption */ -#define ECB_PRESENT -#define ECB_COUNT 1 - -/* AES CCM mode encryption */ -#define CCM_PRESENT -#define CCM_COUNT 1 - -/* Peripheral to Peripheral Interconnect */ -#define PPI_PRESENT -#define PPI_COUNT 1 - -#define PPI_CH_NUM 16 -#define PPI_FIXED_CH_NUM 12 -#define PPI_GROUP_NUM 4 - -/* Timer/Counter */ -#define TIMER_PRESENT -#define TIMER_COUNT 3 - -#define TIMER0_MAX_SIZE 32 -#define TIMER1_MAX_SIZE 16 -#define TIMER2_MAX_SIZE 16 - -#define TIMER0_CC_NUM 4 -#define TIMER1_CC_NUM 4 -#define TIMER2_CC_NUM 4 - -/* Real Time Counter */ -#define RTC_PRESENT -#define RTC_COUNT 2 - -#define RTC0_CC_NUM 3 -#define RTC1_CC_NUM 4 - -/* RNG */ -#define RNG_PRESENT -#define RNG_COUNT 1 - -/* Watchdog Timer */ -#define WDT_PRESENT -#define WDT_COUNT 1 - -/* Temperature Sensor */ -#define TEMP_PRESENT -#define TEMP_COUNT 1 - -/* Serial Peripheral Interface Master */ -#define SPI_PRESENT -#define SPI_COUNT 2 - -/* Serial Peripheral Interface Slave with DMA */ -#define SPIS_PRESENT -#define SPIS_COUNT 1 - -#define SPIS0_EASYDMA_MAXCNT_SIZE 8 - -/* Two Wire Interface Master */ -#define TWI_PRESENT -#define TWI_COUNT 2 - -/* Universal Asynchronous Receiver-Transmitter */ -#define UART_PRESENT -#define UART_COUNT 1 - -/* Quadrature Decoder */ -#define QDEC_PRESENT -#define QDEC_COUNT 1 - -/* Analog to Digital Converter */ -#define ADC_PRESENT -#define ADC_COUNT 1 - -/* GPIO Tasks and Events */ -#define GPIOTE_PRESENT -#define GPIOTE_COUNT 1 - -#define GPIOTE_CH_NUM 4 - -/* Low Power Comparator */ -#define LPCOMP_PRESENT -#define LPCOMP_COUNT 1 - -#define LPCOMP_REFSEL_RESOLUTION 8 - - -#endif // _NRF51822_PERIPHERALS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_bitfields.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_bitfields.h deleted file mode 100644 index ee55d02..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_bitfields.h +++ /dev/null @@ -1,6140 +0,0 @@ -/* - -Copyright (c) 2010 - 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 __NRF51_BITS_H -#define __NRF51_BITS_H - -/*lint ++flb "Enter library region" */ - -/* Peripheral: AAR */ -/* Description: Accelerated Address Resolver. */ - -/* Register: AAR_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 2 : Enable interrupt on NOTRESOLVED event. */ -#define AAR_INTENSET_NOTRESOLVED_Pos (2UL) /*!< Position of NOTRESOLVED field. */ -#define AAR_INTENSET_NOTRESOLVED_Msk (0x1UL << AAR_INTENSET_NOTRESOLVED_Pos) /*!< Bit mask of NOTRESOLVED field. */ -#define AAR_INTENSET_NOTRESOLVED_Disabled (0UL) /*!< Interrupt disabled. */ -#define AAR_INTENSET_NOTRESOLVED_Enabled (1UL) /*!< Interrupt enabled. */ -#define AAR_INTENSET_NOTRESOLVED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on RESOLVED event. */ -#define AAR_INTENSET_RESOLVED_Pos (1UL) /*!< Position of RESOLVED field. */ -#define AAR_INTENSET_RESOLVED_Msk (0x1UL << AAR_INTENSET_RESOLVED_Pos) /*!< Bit mask of RESOLVED field. */ -#define AAR_INTENSET_RESOLVED_Disabled (0UL) /*!< Interrupt disabled. */ -#define AAR_INTENSET_RESOLVED_Enabled (1UL) /*!< Interrupt enabled. */ -#define AAR_INTENSET_RESOLVED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on END event. */ -#define AAR_INTENSET_END_Pos (0UL) /*!< Position of END field. */ -#define AAR_INTENSET_END_Msk (0x1UL << AAR_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define AAR_INTENSET_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define AAR_INTENSET_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define AAR_INTENSET_END_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: AAR_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 2 : Disable interrupt on NOTRESOLVED event. */ -#define AAR_INTENCLR_NOTRESOLVED_Pos (2UL) /*!< Position of NOTRESOLVED field. */ -#define AAR_INTENCLR_NOTRESOLVED_Msk (0x1UL << AAR_INTENCLR_NOTRESOLVED_Pos) /*!< Bit mask of NOTRESOLVED field. */ -#define AAR_INTENCLR_NOTRESOLVED_Disabled (0UL) /*!< Interrupt disabled. */ -#define AAR_INTENCLR_NOTRESOLVED_Enabled (1UL) /*!< Interrupt enabled. */ -#define AAR_INTENCLR_NOTRESOLVED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on RESOLVED event. */ -#define AAR_INTENCLR_RESOLVED_Pos (1UL) /*!< Position of RESOLVED field. */ -#define AAR_INTENCLR_RESOLVED_Msk (0x1UL << AAR_INTENCLR_RESOLVED_Pos) /*!< Bit mask of RESOLVED field. */ -#define AAR_INTENCLR_RESOLVED_Disabled (0UL) /*!< Interrupt disabled. */ -#define AAR_INTENCLR_RESOLVED_Enabled (1UL) /*!< Interrupt enabled. */ -#define AAR_INTENCLR_RESOLVED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on ENDKSGEN event. */ -#define AAR_INTENCLR_END_Pos (0UL) /*!< Position of END field. */ -#define AAR_INTENCLR_END_Msk (0x1UL << AAR_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define AAR_INTENCLR_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define AAR_INTENCLR_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define AAR_INTENCLR_END_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: AAR_STATUS */ -/* Description: Resolution status. */ - -/* Bits 3..0 : The IRK used last time an address was resolved. */ -#define AAR_STATUS_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define AAR_STATUS_STATUS_Msk (0xFUL << AAR_STATUS_STATUS_Pos) /*!< Bit mask of STATUS field. */ - -/* Register: AAR_ENABLE */ -/* Description: Enable AAR. */ - -/* Bits 1..0 : Enable AAR. */ -#define AAR_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define AAR_ENABLE_ENABLE_Msk (0x3UL << AAR_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define AAR_ENABLE_ENABLE_Disabled (0x00UL) /*!< Disabled AAR. */ -#define AAR_ENABLE_ENABLE_Enabled (0x03UL) /*!< Enable AAR. */ - -/* Register: AAR_NIRK */ -/* Description: Number of Identity root Keys in the IRK data structure. */ - -/* Bits 4..0 : Number of Identity root Keys in the IRK data structure. */ -#define AAR_NIRK_NIRK_Pos (0UL) /*!< Position of NIRK field. */ -#define AAR_NIRK_NIRK_Msk (0x1FUL << AAR_NIRK_NIRK_Pos) /*!< Bit mask of NIRK field. */ - -/* Register: AAR_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define AAR_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define AAR_POWER_POWER_Msk (0x1UL << AAR_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define AAR_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define AAR_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: ADC */ -/* Description: Analog to digital converter. */ - -/* Register: ADC_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 0 : Enable interrupt on END event. */ -#define ADC_INTENSET_END_Pos (0UL) /*!< Position of END field. */ -#define ADC_INTENSET_END_Msk (0x1UL << ADC_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define ADC_INTENSET_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define ADC_INTENSET_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define ADC_INTENSET_END_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: ADC_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 0 : Disable interrupt on END event. */ -#define ADC_INTENCLR_END_Pos (0UL) /*!< Position of END field. */ -#define ADC_INTENCLR_END_Msk (0x1UL << ADC_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define ADC_INTENCLR_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define ADC_INTENCLR_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define ADC_INTENCLR_END_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: ADC_BUSY */ -/* Description: ADC busy register. */ - -/* Bit 0 : ADC busy register. */ -#define ADC_BUSY_BUSY_Pos (0UL) /*!< Position of BUSY field. */ -#define ADC_BUSY_BUSY_Msk (0x1UL << ADC_BUSY_BUSY_Pos) /*!< Bit mask of BUSY field. */ -#define ADC_BUSY_BUSY_Ready (0UL) /*!< No ongoing ADC conversion is taking place. ADC is ready. */ -#define ADC_BUSY_BUSY_Busy (1UL) /*!< An ADC conversion is taking place. ADC is busy. */ - -/* Register: ADC_ENABLE */ -/* Description: ADC enable. */ - -/* Bits 1..0 : ADC enable. */ -#define ADC_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define ADC_ENABLE_ENABLE_Msk (0x3UL << ADC_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define ADC_ENABLE_ENABLE_Disabled (0x00UL) /*!< ADC is disabled. */ -#define ADC_ENABLE_ENABLE_Enabled (0x01UL) /*!< ADC is enabled. If an analog input pin is selected as source of the conversion, the selected pin is configured as an analog input. */ - -/* Register: ADC_CONFIG */ -/* Description: ADC configuration register. */ - -/* Bits 17..16 : ADC external reference pin selection. */ -#define ADC_CONFIG_EXTREFSEL_Pos (16UL) /*!< Position of EXTREFSEL field. */ -#define ADC_CONFIG_EXTREFSEL_Msk (0x3UL << ADC_CONFIG_EXTREFSEL_Pos) /*!< Bit mask of EXTREFSEL field. */ -#define ADC_CONFIG_EXTREFSEL_None (0UL) /*!< Analog external reference inputs disabled. */ -#define ADC_CONFIG_EXTREFSEL_AnalogReference0 (1UL) /*!< Use analog reference 0 as reference. */ -#define ADC_CONFIG_EXTREFSEL_AnalogReference1 (2UL) /*!< Use analog reference 1 as reference. */ - -/* Bits 15..8 : ADC analog pin selection. */ -#define ADC_CONFIG_PSEL_Pos (8UL) /*!< Position of PSEL field. */ -#define ADC_CONFIG_PSEL_Msk (0xFFUL << ADC_CONFIG_PSEL_Pos) /*!< Bit mask of PSEL field. */ -#define ADC_CONFIG_PSEL_Disabled (0UL) /*!< Analog input pins disabled. */ -#define ADC_CONFIG_PSEL_AnalogInput0 (1UL) /*!< Use analog input 0 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput1 (2UL) /*!< Use analog input 1 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput2 (4UL) /*!< Use analog input 2 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput3 (8UL) /*!< Use analog input 3 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput4 (16UL) /*!< Use analog input 4 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput5 (32UL) /*!< Use analog input 5 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput6 (64UL) /*!< Use analog input 6 as analog input. */ -#define ADC_CONFIG_PSEL_AnalogInput7 (128UL) /*!< Use analog input 7 as analog input. */ - -/* Bits 6..5 : ADC reference selection. */ -#define ADC_CONFIG_REFSEL_Pos (5UL) /*!< Position of REFSEL field. */ -#define ADC_CONFIG_REFSEL_Msk (0x3UL << ADC_CONFIG_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define ADC_CONFIG_REFSEL_VBG (0x00UL) /*!< Use internal 1.2V bandgap voltage as reference for conversion. */ -#define ADC_CONFIG_REFSEL_External (0x01UL) /*!< Use external source configured by EXTREFSEL as reference for conversion. */ -#define ADC_CONFIG_REFSEL_SupplyOneHalfPrescaling (0x02UL) /*!< Use supply voltage with 1/2 prescaling as reference for conversion. Only usable when supply voltage is between 1.7V and 2.6V. */ -#define ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling (0x03UL) /*!< Use supply voltage with 1/3 prescaling as reference for conversion. Only usable when supply voltage is between 2.5V and 3.6V. */ - -/* Bits 4..2 : ADC input selection. */ -#define ADC_CONFIG_INPSEL_Pos (2UL) /*!< Position of INPSEL field. */ -#define ADC_CONFIG_INPSEL_Msk (0x7UL << ADC_CONFIG_INPSEL_Pos) /*!< Bit mask of INPSEL field. */ -#define ADC_CONFIG_INPSEL_AnalogInputNoPrescaling (0x00UL) /*!< Analog input specified by PSEL with no prescaling used as input for the conversion. */ -#define ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling (0x01UL) /*!< Analog input specified by PSEL with 2/3 prescaling used as input for the conversion. */ -#define ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling (0x02UL) /*!< Analog input specified by PSEL with 1/3 prescaling used as input for the conversion. */ -#define ADC_CONFIG_INPSEL_SupplyTwoThirdsPrescaling (0x05UL) /*!< Supply voltage with 2/3 prescaling used as input for the conversion. */ -#define ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling (0x06UL) /*!< Supply voltage with 1/3 prescaling used as input for the conversion. */ - -/* Bits 1..0 : ADC resolution. */ -#define ADC_CONFIG_RES_Pos (0UL) /*!< Position of RES field. */ -#define ADC_CONFIG_RES_Msk (0x3UL << ADC_CONFIG_RES_Pos) /*!< Bit mask of RES field. */ -#define ADC_CONFIG_RES_8bit (0x00UL) /*!< 8bit ADC resolution. */ -#define ADC_CONFIG_RES_9bit (0x01UL) /*!< 9bit ADC resolution. */ -#define ADC_CONFIG_RES_10bit (0x02UL) /*!< 10bit ADC resolution. */ - -/* Register: ADC_RESULT */ -/* Description: Result of ADC conversion. */ - -/* Bits 9..0 : Result of ADC conversion. */ -#define ADC_RESULT_RESULT_Pos (0UL) /*!< Position of RESULT field. */ -#define ADC_RESULT_RESULT_Msk (0x3FFUL << ADC_RESULT_RESULT_Pos) /*!< Bit mask of RESULT field. */ - -/* Register: ADC_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define ADC_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define ADC_POWER_POWER_Msk (0x1UL << ADC_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define ADC_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define ADC_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: CCM */ -/* Description: AES CCM Mode Encryption. */ - -/* Register: CCM_SHORTS */ -/* Description: Shortcuts for the CCM. */ - -/* Bit 0 : Shortcut between ENDKSGEN event and CRYPT task. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Pos (0UL) /*!< Position of ENDKSGEN_CRYPT field. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Msk (0x1UL << CCM_SHORTS_ENDKSGEN_CRYPT_Pos) /*!< Bit mask of ENDKSGEN_CRYPT field. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Disabled (0UL) /*!< Shortcut disabled. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: CCM_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 2 : Enable interrupt on ERROR event. */ -#define CCM_INTENSET_ERROR_Pos (2UL) /*!< Position of ERROR field. */ -#define CCM_INTENSET_ERROR_Msk (0x1UL << CCM_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define CCM_INTENSET_ERROR_Disabled (0UL) /*!< Interrupt disabled. */ -#define CCM_INTENSET_ERROR_Enabled (1UL) /*!< Interrupt enabled. */ -#define CCM_INTENSET_ERROR_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on ENDCRYPT event. */ -#define CCM_INTENSET_ENDCRYPT_Pos (1UL) /*!< Position of ENDCRYPT field. */ -#define CCM_INTENSET_ENDCRYPT_Msk (0x1UL << CCM_INTENSET_ENDCRYPT_Pos) /*!< Bit mask of ENDCRYPT field. */ -#define CCM_INTENSET_ENDCRYPT_Disabled (0UL) /*!< Interrupt disabled. */ -#define CCM_INTENSET_ENDCRYPT_Enabled (1UL) /*!< Interrupt enabled. */ -#define CCM_INTENSET_ENDCRYPT_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on ENDKSGEN event. */ -#define CCM_INTENSET_ENDKSGEN_Pos (0UL) /*!< Position of ENDKSGEN field. */ -#define CCM_INTENSET_ENDKSGEN_Msk (0x1UL << CCM_INTENSET_ENDKSGEN_Pos) /*!< Bit mask of ENDKSGEN field. */ -#define CCM_INTENSET_ENDKSGEN_Disabled (0UL) /*!< Interrupt disabled. */ -#define CCM_INTENSET_ENDKSGEN_Enabled (1UL) /*!< Interrupt enabled. */ -#define CCM_INTENSET_ENDKSGEN_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: CCM_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 2 : Disable interrupt on ERROR event. */ -#define CCM_INTENCLR_ERROR_Pos (2UL) /*!< Position of ERROR field. */ -#define CCM_INTENCLR_ERROR_Msk (0x1UL << CCM_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define CCM_INTENCLR_ERROR_Disabled (0UL) /*!< Interrupt disabled. */ -#define CCM_INTENCLR_ERROR_Enabled (1UL) /*!< Interrupt enabled. */ -#define CCM_INTENCLR_ERROR_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on ENDCRYPT event. */ -#define CCM_INTENCLR_ENDCRYPT_Pos (1UL) /*!< Position of ENDCRYPT field. */ -#define CCM_INTENCLR_ENDCRYPT_Msk (0x1UL << CCM_INTENCLR_ENDCRYPT_Pos) /*!< Bit mask of ENDCRYPT field. */ -#define CCM_INTENCLR_ENDCRYPT_Disabled (0UL) /*!< Interrupt disabled. */ -#define CCM_INTENCLR_ENDCRYPT_Enabled (1UL) /*!< Interrupt enabled. */ -#define CCM_INTENCLR_ENDCRYPT_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on ENDKSGEN event. */ -#define CCM_INTENCLR_ENDKSGEN_Pos (0UL) /*!< Position of ENDKSGEN field. */ -#define CCM_INTENCLR_ENDKSGEN_Msk (0x1UL << CCM_INTENCLR_ENDKSGEN_Pos) /*!< Bit mask of ENDKSGEN field. */ -#define CCM_INTENCLR_ENDKSGEN_Disabled (0UL) /*!< Interrupt disabled. */ -#define CCM_INTENCLR_ENDKSGEN_Enabled (1UL) /*!< Interrupt enabled. */ -#define CCM_INTENCLR_ENDKSGEN_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: CCM_MICSTATUS */ -/* Description: CCM RX MIC check result. */ - -/* Bit 0 : Result of the MIC check performed during the previous CCM RX STARTCRYPT */ -#define CCM_MICSTATUS_MICSTATUS_Pos (0UL) /*!< Position of MICSTATUS field. */ -#define CCM_MICSTATUS_MICSTATUS_Msk (0x1UL << CCM_MICSTATUS_MICSTATUS_Pos) /*!< Bit mask of MICSTATUS field. */ -#define CCM_MICSTATUS_MICSTATUS_CheckFailed (0UL) /*!< MIC check failed. */ -#define CCM_MICSTATUS_MICSTATUS_CheckPassed (1UL) /*!< MIC check passed. */ - -/* Register: CCM_ENABLE */ -/* Description: CCM enable. */ - -/* Bits 1..0 : CCM enable. */ -#define CCM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define CCM_ENABLE_ENABLE_Msk (0x3UL << CCM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define CCM_ENABLE_ENABLE_Disabled (0x00UL) /*!< CCM is disabled. */ -#define CCM_ENABLE_ENABLE_Enabled (0x02UL) /*!< CCM is enabled. */ - -/* Register: CCM_MODE */ -/* Description: Operation mode. */ - -/* Bit 0 : CCM mode operation. */ -#define CCM_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define CCM_MODE_MODE_Msk (0x1UL << CCM_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define CCM_MODE_MODE_Encryption (0UL) /*!< CCM mode TX */ -#define CCM_MODE_MODE_Decryption (1UL) /*!< CCM mode TX */ - -/* Register: CCM_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define CCM_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define CCM_POWER_POWER_Msk (0x1UL << CCM_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define CCM_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define CCM_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: CLOCK */ -/* Description: Clock control. */ - -/* Register: CLOCK_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 4 : Enable interrupt on CTTO event. */ -#define CLOCK_INTENSET_CTTO_Pos (4UL) /*!< Position of CTTO field. */ -#define CLOCK_INTENSET_CTTO_Msk (0x1UL << CLOCK_INTENSET_CTTO_Pos) /*!< Bit mask of CTTO field. */ -#define CLOCK_INTENSET_CTTO_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENSET_CTTO_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENSET_CTTO_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 3 : Enable interrupt on DONE event. */ -#define CLOCK_INTENSET_DONE_Pos (3UL) /*!< Position of DONE field. */ -#define CLOCK_INTENSET_DONE_Msk (0x1UL << CLOCK_INTENSET_DONE_Pos) /*!< Bit mask of DONE field. */ -#define CLOCK_INTENSET_DONE_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENSET_DONE_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENSET_DONE_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on LFCLKSTARTED event. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Pos (1UL) /*!< Position of LFCLKSTARTED field. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Msk (0x1UL << CLOCK_INTENSET_LFCLKSTARTED_Pos) /*!< Bit mask of LFCLKSTARTED field. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on HFCLKSTARTED event. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Pos (0UL) /*!< Position of HFCLKSTARTED field. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Msk (0x1UL << CLOCK_INTENSET_HFCLKSTARTED_Pos) /*!< Bit mask of HFCLKSTARTED field. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: CLOCK_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 4 : Disable interrupt on CTTO event. */ -#define CLOCK_INTENCLR_CTTO_Pos (4UL) /*!< Position of CTTO field. */ -#define CLOCK_INTENCLR_CTTO_Msk (0x1UL << CLOCK_INTENCLR_CTTO_Pos) /*!< Bit mask of CTTO field. */ -#define CLOCK_INTENCLR_CTTO_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENCLR_CTTO_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENCLR_CTTO_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 3 : Disable interrupt on DONE event. */ -#define CLOCK_INTENCLR_DONE_Pos (3UL) /*!< Position of DONE field. */ -#define CLOCK_INTENCLR_DONE_Msk (0x1UL << CLOCK_INTENCLR_DONE_Pos) /*!< Bit mask of DONE field. */ -#define CLOCK_INTENCLR_DONE_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENCLR_DONE_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENCLR_DONE_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on LFCLKSTARTED event. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Pos (1UL) /*!< Position of LFCLKSTARTED field. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Msk (0x1UL << CLOCK_INTENCLR_LFCLKSTARTED_Pos) /*!< Bit mask of LFCLKSTARTED field. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on HFCLKSTARTED event. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Pos (0UL) /*!< Position of HFCLKSTARTED field. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Msk (0x1UL << CLOCK_INTENCLR_HFCLKSTARTED_Pos) /*!< Bit mask of HFCLKSTARTED field. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Disabled (0UL) /*!< Interrupt disabled. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Enabled (1UL) /*!< Interrupt enabled. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: CLOCK_HFCLKRUN */ -/* Description: Task HFCLKSTART trigger status. */ - -/* Bit 0 : Task HFCLKSTART trigger status. */ -#define CLOCK_HFCLKRUN_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define CLOCK_HFCLKRUN_STATUS_Msk (0x1UL << CLOCK_HFCLKRUN_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_HFCLKRUN_STATUS_NotTriggered (0UL) /*!< Task HFCLKSTART has not been triggered. */ -#define CLOCK_HFCLKRUN_STATUS_Triggered (1UL) /*!< Task HFCLKSTART has been triggered. */ - -/* Register: CLOCK_HFCLKSTAT */ -/* Description: High frequency clock status. */ - -/* Bit 16 : State for the HFCLK. */ -#define CLOCK_HFCLKSTAT_STATE_Pos (16UL) /*!< Position of STATE field. */ -#define CLOCK_HFCLKSTAT_STATE_Msk (0x1UL << CLOCK_HFCLKSTAT_STATE_Pos) /*!< Bit mask of STATE field. */ -#define CLOCK_HFCLKSTAT_STATE_NotRunning (0UL) /*!< HFCLK clock not running. */ -#define CLOCK_HFCLKSTAT_STATE_Running (1UL) /*!< HFCLK clock running. */ - -/* Bit 0 : Active clock source for the HF clock. */ -#define CLOCK_HFCLKSTAT_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_HFCLKSTAT_SRC_Msk (0x1UL << CLOCK_HFCLKSTAT_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_HFCLKSTAT_SRC_RC (0UL) /*!< Internal 16MHz RC oscillator running and generating the HFCLK clock. */ -#define CLOCK_HFCLKSTAT_SRC_Xtal (1UL) /*!< External 16MHz/32MHz crystal oscillator running and generating the HFCLK clock. */ - -/* Register: CLOCK_LFCLKRUN */ -/* Description: Task LFCLKSTART triggered status. */ - -/* Bit 0 : Task LFCLKSTART triggered status. */ -#define CLOCK_LFCLKRUN_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define CLOCK_LFCLKRUN_STATUS_Msk (0x1UL << CLOCK_LFCLKRUN_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_LFCLKRUN_STATUS_NotTriggered (0UL) /*!< Task LFCLKSTART has not been triggered. */ -#define CLOCK_LFCLKRUN_STATUS_Triggered (1UL) /*!< Task LFCLKSTART has been triggered. */ - -/* Register: CLOCK_LFCLKSTAT */ -/* Description: Low frequency clock status. */ - -/* Bit 16 : State for the LF clock. */ -#define CLOCK_LFCLKSTAT_STATE_Pos (16UL) /*!< Position of STATE field. */ -#define CLOCK_LFCLKSTAT_STATE_Msk (0x1UL << CLOCK_LFCLKSTAT_STATE_Pos) /*!< Bit mask of STATE field. */ -#define CLOCK_LFCLKSTAT_STATE_NotRunning (0UL) /*!< LFCLK clock not running. */ -#define CLOCK_LFCLKSTAT_STATE_Running (1UL) /*!< LFCLK clock running. */ - -/* Bits 1..0 : Active clock source for the LF clock. */ -#define CLOCK_LFCLKSTAT_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSTAT_SRC_Msk (0x3UL << CLOCK_LFCLKSTAT_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSTAT_SRC_RC (0UL) /*!< Internal 32KiHz RC oscillator running and generating the LFCLK clock. */ -#define CLOCK_LFCLKSTAT_SRC_Xtal (1UL) /*!< External 32KiHz crystal oscillator running and generating the LFCLK clock. */ -#define CLOCK_LFCLKSTAT_SRC_Synth (2UL) /*!< Internal 32KiHz synthesizer from the HFCLK running and generating the LFCLK clock. */ - -/* Register: CLOCK_LFCLKSRCCOPY */ -/* Description: Clock source for the LFCLK clock, set when task LKCLKSTART is triggered. */ - -/* Bits 1..0 : Clock source for the LFCLK clock, set when task LKCLKSTART is triggered. */ -#define CLOCK_LFCLKSRCCOPY_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSRCCOPY_SRC_Msk (0x3UL << CLOCK_LFCLKSRCCOPY_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSRCCOPY_SRC_RC (0UL) /*!< Internal 32KiHz RC oscillator. */ -#define CLOCK_LFCLKSRCCOPY_SRC_Xtal (1UL) /*!< External 32KiHz crystal. */ -#define CLOCK_LFCLKSRCCOPY_SRC_Synth (2UL) /*!< Internal 32KiHz synthesizer from HFCLK system clock. */ - -/* Register: CLOCK_LFCLKSRC */ -/* Description: Clock source for the LFCLK clock. */ - -/* Bits 1..0 : Clock source. */ -#define CLOCK_LFCLKSRC_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSRC_SRC_Msk (0x3UL << CLOCK_LFCLKSRC_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSRC_SRC_RC (0UL) /*!< Internal 32KiHz RC oscillator. */ -#define CLOCK_LFCLKSRC_SRC_Xtal (1UL) /*!< External 32KiHz crystal. */ -#define CLOCK_LFCLKSRC_SRC_Synth (2UL) /*!< Internal 32KiHz synthesizer from HFCLK system clock. */ - -/* Register: CLOCK_CTIV */ -/* Description: Calibration timer interval. */ - -/* Bits 6..0 : Calibration timer interval in 0.25s resolution. */ -#define CLOCK_CTIV_CTIV_Pos (0UL) /*!< Position of CTIV field. */ -#define CLOCK_CTIV_CTIV_Msk (0x7FUL << CLOCK_CTIV_CTIV_Pos) /*!< Bit mask of CTIV field. */ - -/* Register: CLOCK_XTALFREQ */ -/* Description: Crystal frequency. */ - -/* Bits 7..0 : External Xtal frequency selection. */ -#define CLOCK_XTALFREQ_XTALFREQ_Pos (0UL) /*!< Position of XTALFREQ field. */ -#define CLOCK_XTALFREQ_XTALFREQ_Msk (0xFFUL << CLOCK_XTALFREQ_XTALFREQ_Pos) /*!< Bit mask of XTALFREQ field. */ -#define CLOCK_XTALFREQ_XTALFREQ_32MHz (0x00UL) /*!< 32MHz xtal is used as source for the HFCLK oscillator. */ -#define CLOCK_XTALFREQ_XTALFREQ_16MHz (0xFFUL) /*!< 16MHz xtal is used as source for the HFCLK oscillator. */ - - -/* Peripheral: ECB */ -/* Description: AES ECB Mode Encryption. */ - -/* Register: ECB_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 1 : Enable interrupt on ERRORECB event. */ -#define ECB_INTENSET_ERRORECB_Pos (1UL) /*!< Position of ERRORECB field. */ -#define ECB_INTENSET_ERRORECB_Msk (0x1UL << ECB_INTENSET_ERRORECB_Pos) /*!< Bit mask of ERRORECB field. */ -#define ECB_INTENSET_ERRORECB_Disabled (0UL) /*!< Interrupt disabled. */ -#define ECB_INTENSET_ERRORECB_Enabled (1UL) /*!< Interrupt enabled. */ -#define ECB_INTENSET_ERRORECB_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on ENDECB event. */ -#define ECB_INTENSET_ENDECB_Pos (0UL) /*!< Position of ENDECB field. */ -#define ECB_INTENSET_ENDECB_Msk (0x1UL << ECB_INTENSET_ENDECB_Pos) /*!< Bit mask of ENDECB field. */ -#define ECB_INTENSET_ENDECB_Disabled (0UL) /*!< Interrupt disabled. */ -#define ECB_INTENSET_ENDECB_Enabled (1UL) /*!< Interrupt enabled. */ -#define ECB_INTENSET_ENDECB_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: ECB_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 1 : Disable interrupt on ERRORECB event. */ -#define ECB_INTENCLR_ERRORECB_Pos (1UL) /*!< Position of ERRORECB field. */ -#define ECB_INTENCLR_ERRORECB_Msk (0x1UL << ECB_INTENCLR_ERRORECB_Pos) /*!< Bit mask of ERRORECB field. */ -#define ECB_INTENCLR_ERRORECB_Disabled (0UL) /*!< Interrupt disabled. */ -#define ECB_INTENCLR_ERRORECB_Enabled (1UL) /*!< Interrupt enabled. */ -#define ECB_INTENCLR_ERRORECB_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on ENDECB event. */ -#define ECB_INTENCLR_ENDECB_Pos (0UL) /*!< Position of ENDECB field. */ -#define ECB_INTENCLR_ENDECB_Msk (0x1UL << ECB_INTENCLR_ENDECB_Pos) /*!< Bit mask of ENDECB field. */ -#define ECB_INTENCLR_ENDECB_Disabled (0UL) /*!< Interrupt disabled. */ -#define ECB_INTENCLR_ENDECB_Enabled (1UL) /*!< Interrupt enabled. */ -#define ECB_INTENCLR_ENDECB_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: ECB_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define ECB_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define ECB_POWER_POWER_Msk (0x1UL << ECB_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define ECB_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define ECB_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: FICR */ -/* Description: Factory Information Configuration. */ - -/* Register: FICR_PPFC */ -/* Description: Pre-programmed factory code present. */ - -/* Bits 7..0 : Pre-programmed factory code present. */ -#define FICR_PPFC_PPFC_Pos (0UL) /*!< Position of PPFC field. */ -#define FICR_PPFC_PPFC_Msk (0xFFUL << FICR_PPFC_PPFC_Pos) /*!< Bit mask of PPFC field. */ -#define FICR_PPFC_PPFC_Present (0x00UL) /*!< Present. */ -#define FICR_PPFC_PPFC_NotPresent (0xFFUL) /*!< Not present. */ - -/* Register: FICR_CONFIGID */ -/* Description: Configuration identifier. */ - -/* Bits 31..16 : Firmware Identification Number pre-loaded into the flash. */ -#define FICR_CONFIGID_FWID_Pos (16UL) /*!< Position of FWID field. */ -#define FICR_CONFIGID_FWID_Msk (0xFFFFUL << FICR_CONFIGID_FWID_Pos) /*!< Bit mask of FWID field. */ - -/* Bits 15..0 : Hardware Identification Number. */ -#define FICR_CONFIGID_HWID_Pos (0UL) /*!< Position of HWID field. */ -#define FICR_CONFIGID_HWID_Msk (0xFFFFUL << FICR_CONFIGID_HWID_Pos) /*!< Bit mask of HWID field. */ - -/* Register: FICR_DEVICEADDRTYPE */ -/* Description: Device address type. */ - -/* Bit 0 : Device address type. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Pos (0UL) /*!< Position of DEVICEADDRTYPE field. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Msk (0x1UL << FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Pos) /*!< Bit mask of DEVICEADDRTYPE field. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Public (0UL) /*!< Public address. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Random (1UL) /*!< Random address. */ - -/* Register: FICR_OVERRIDEEN */ -/* Description: Radio calibration override enable. */ - -/* Bit 3 : Override default values for BLE_1Mbit mode. */ -#define FICR_OVERRIDEEN_BLE_1MBIT_Pos (3UL) /*!< Position of BLE_1MBIT field. */ -#define FICR_OVERRIDEEN_BLE_1MBIT_Msk (0x1UL << FICR_OVERRIDEEN_BLE_1MBIT_Pos) /*!< Bit mask of BLE_1MBIT field. */ -#define FICR_OVERRIDEEN_BLE_1MBIT_Override (0UL) /*!< Override the default values for BLE_1Mbit mode. */ -#define FICR_OVERRIDEEN_BLE_1MBIT_NotOverride (1UL) /*!< Do not override the default values for BLE_1Mbit mode. */ - -/* Bit 0 : Override default values for NRF_1Mbit mode. */ -#define FICR_OVERRIDEEN_NRF_1MBIT_Pos (0UL) /*!< Position of NRF_1MBIT field. */ -#define FICR_OVERRIDEEN_NRF_1MBIT_Msk (0x1UL << FICR_OVERRIDEEN_NRF_1MBIT_Pos) /*!< Bit mask of NRF_1MBIT field. */ -#define FICR_OVERRIDEEN_NRF_1MBIT_Override (0UL) /*!< Override the default values for NRF_1Mbit mode. */ -#define FICR_OVERRIDEEN_NRF_1MBIT_NotOverride (1UL) /*!< Do not override the default values for NRF_1Mbit mode. */ - - -/* Peripheral: GPIO */ -/* Description: General purpose input and output. */ - -/* Register: GPIO_OUT */ -/* Description: Write GPIO port. */ - -/* Bit 31 : Pin 31. */ -#define GPIO_OUT_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUT_PIN31_Msk (0x1UL << GPIO_OUT_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUT_PIN31_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN31_High (1UL) /*!< Pin driver is high. */ - -/* Bit 30 : Pin 30. */ -#define GPIO_OUT_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUT_PIN30_Msk (0x1UL << GPIO_OUT_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUT_PIN30_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN30_High (1UL) /*!< Pin driver is high. */ - -/* Bit 29 : Pin 29. */ -#define GPIO_OUT_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUT_PIN29_Msk (0x1UL << GPIO_OUT_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUT_PIN29_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN29_High (1UL) /*!< Pin driver is high. */ - -/* Bit 28 : Pin 28. */ -#define GPIO_OUT_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUT_PIN28_Msk (0x1UL << GPIO_OUT_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUT_PIN28_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN28_High (1UL) /*!< Pin driver is high. */ - -/* Bit 27 : Pin 27. */ -#define GPIO_OUT_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUT_PIN27_Msk (0x1UL << GPIO_OUT_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUT_PIN27_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN27_High (1UL) /*!< Pin driver is high. */ - -/* Bit 26 : Pin 26. */ -#define GPIO_OUT_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUT_PIN26_Msk (0x1UL << GPIO_OUT_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUT_PIN26_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN26_High (1UL) /*!< Pin driver is high. */ - -/* Bit 25 : Pin 25. */ -#define GPIO_OUT_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUT_PIN25_Msk (0x1UL << GPIO_OUT_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUT_PIN25_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN25_High (1UL) /*!< Pin driver is high. */ - -/* Bit 24 : Pin 24. */ -#define GPIO_OUT_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUT_PIN24_Msk (0x1UL << GPIO_OUT_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUT_PIN24_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN24_High (1UL) /*!< Pin driver is high. */ - -/* Bit 23 : Pin 23. */ -#define GPIO_OUT_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUT_PIN23_Msk (0x1UL << GPIO_OUT_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUT_PIN23_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN23_High (1UL) /*!< Pin driver is high. */ - -/* Bit 22 : Pin 22. */ -#define GPIO_OUT_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUT_PIN22_Msk (0x1UL << GPIO_OUT_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUT_PIN22_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN22_High (1UL) /*!< Pin driver is high. */ - -/* Bit 21 : Pin 21. */ -#define GPIO_OUT_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUT_PIN21_Msk (0x1UL << GPIO_OUT_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUT_PIN21_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN21_High (1UL) /*!< Pin driver is high. */ - -/* Bit 20 : Pin 20. */ -#define GPIO_OUT_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUT_PIN20_Msk (0x1UL << GPIO_OUT_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUT_PIN20_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN20_High (1UL) /*!< Pin driver is high. */ - -/* Bit 19 : Pin 19. */ -#define GPIO_OUT_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUT_PIN19_Msk (0x1UL << GPIO_OUT_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUT_PIN19_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN19_High (1UL) /*!< Pin driver is high. */ - -/* Bit 18 : Pin 18. */ -#define GPIO_OUT_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUT_PIN18_Msk (0x1UL << GPIO_OUT_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUT_PIN18_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN18_High (1UL) /*!< Pin driver is high. */ - -/* Bit 17 : Pin 17. */ -#define GPIO_OUT_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUT_PIN17_Msk (0x1UL << GPIO_OUT_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUT_PIN17_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN17_High (1UL) /*!< Pin driver is high. */ - -/* Bit 16 : Pin 16. */ -#define GPIO_OUT_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUT_PIN16_Msk (0x1UL << GPIO_OUT_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUT_PIN16_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN16_High (1UL) /*!< Pin driver is high. */ - -/* Bit 15 : Pin 15. */ -#define GPIO_OUT_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUT_PIN15_Msk (0x1UL << GPIO_OUT_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUT_PIN15_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN15_High (1UL) /*!< Pin driver is high. */ - -/* Bit 14 : Pin 14. */ -#define GPIO_OUT_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUT_PIN14_Msk (0x1UL << GPIO_OUT_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUT_PIN14_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN14_High (1UL) /*!< Pin driver is high. */ - -/* Bit 13 : Pin 13. */ -#define GPIO_OUT_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUT_PIN13_Msk (0x1UL << GPIO_OUT_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUT_PIN13_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN13_High (1UL) /*!< Pin driver is high. */ - -/* Bit 12 : Pin 12. */ -#define GPIO_OUT_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUT_PIN12_Msk (0x1UL << GPIO_OUT_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUT_PIN12_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN12_High (1UL) /*!< Pin driver is high. */ - -/* Bit 11 : Pin 11. */ -#define GPIO_OUT_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUT_PIN11_Msk (0x1UL << GPIO_OUT_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUT_PIN11_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN11_High (1UL) /*!< Pin driver is high. */ - -/* Bit 10 : Pin 10. */ -#define GPIO_OUT_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUT_PIN10_Msk (0x1UL << GPIO_OUT_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUT_PIN10_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN10_High (1UL) /*!< Pin driver is high. */ - -/* Bit 9 : Pin 9. */ -#define GPIO_OUT_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUT_PIN9_Msk (0x1UL << GPIO_OUT_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUT_PIN9_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN9_High (1UL) /*!< Pin driver is high. */ - -/* Bit 8 : Pin 8. */ -#define GPIO_OUT_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUT_PIN8_Msk (0x1UL << GPIO_OUT_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUT_PIN8_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN8_High (1UL) /*!< Pin driver is high. */ - -/* Bit 7 : Pin 7. */ -#define GPIO_OUT_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUT_PIN7_Msk (0x1UL << GPIO_OUT_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUT_PIN7_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN7_High (1UL) /*!< Pin driver is high. */ - -/* Bit 6 : Pin 6. */ -#define GPIO_OUT_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUT_PIN6_Msk (0x1UL << GPIO_OUT_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUT_PIN6_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN6_High (1UL) /*!< Pin driver is high. */ - -/* Bit 5 : Pin 5. */ -#define GPIO_OUT_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUT_PIN5_Msk (0x1UL << GPIO_OUT_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUT_PIN5_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN5_High (1UL) /*!< Pin driver is high. */ - -/* Bit 4 : Pin 4. */ -#define GPIO_OUT_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUT_PIN4_Msk (0x1UL << GPIO_OUT_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUT_PIN4_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN4_High (1UL) /*!< Pin driver is high. */ - -/* Bit 3 : Pin 3. */ -#define GPIO_OUT_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUT_PIN3_Msk (0x1UL << GPIO_OUT_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUT_PIN3_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN3_High (1UL) /*!< Pin driver is high. */ - -/* Bit 2 : Pin 2. */ -#define GPIO_OUT_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUT_PIN2_Msk (0x1UL << GPIO_OUT_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUT_PIN2_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN2_High (1UL) /*!< Pin driver is high. */ - -/* Bit 1 : Pin 1. */ -#define GPIO_OUT_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUT_PIN1_Msk (0x1UL << GPIO_OUT_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUT_PIN1_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN1_High (1UL) /*!< Pin driver is high. */ - -/* Bit 0 : Pin 0. */ -#define GPIO_OUT_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUT_PIN0_Msk (0x1UL << GPIO_OUT_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUT_PIN0_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUT_PIN0_High (1UL) /*!< Pin driver is high. */ - -/* Register: GPIO_OUTSET */ -/* Description: Set individual bits in GPIO port. */ - -/* Bit 31 : Pin 31. */ -#define GPIO_OUTSET_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUTSET_PIN31_Msk (0x1UL << GPIO_OUTSET_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUTSET_PIN31_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN31_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN31_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 30 : Pin 30. */ -#define GPIO_OUTSET_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUTSET_PIN30_Msk (0x1UL << GPIO_OUTSET_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUTSET_PIN30_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN30_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN30_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 29 : Pin 29. */ -#define GPIO_OUTSET_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUTSET_PIN29_Msk (0x1UL << GPIO_OUTSET_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUTSET_PIN29_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN29_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN29_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 28 : Pin 28. */ -#define GPIO_OUTSET_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUTSET_PIN28_Msk (0x1UL << GPIO_OUTSET_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUTSET_PIN28_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN28_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN28_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 27 : Pin 27. */ -#define GPIO_OUTSET_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUTSET_PIN27_Msk (0x1UL << GPIO_OUTSET_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUTSET_PIN27_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN27_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN27_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 26 : Pin 26. */ -#define GPIO_OUTSET_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUTSET_PIN26_Msk (0x1UL << GPIO_OUTSET_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUTSET_PIN26_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN26_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN26_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 25 : Pin 25. */ -#define GPIO_OUTSET_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUTSET_PIN25_Msk (0x1UL << GPIO_OUTSET_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUTSET_PIN25_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN25_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN25_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 24 : Pin 24. */ -#define GPIO_OUTSET_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUTSET_PIN24_Msk (0x1UL << GPIO_OUTSET_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUTSET_PIN24_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN24_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN24_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 23 : Pin 23. */ -#define GPIO_OUTSET_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUTSET_PIN23_Msk (0x1UL << GPIO_OUTSET_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUTSET_PIN23_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN23_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN23_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 22 : Pin 22. */ -#define GPIO_OUTSET_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUTSET_PIN22_Msk (0x1UL << GPIO_OUTSET_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUTSET_PIN22_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN22_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN22_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 21 : Pin 21. */ -#define GPIO_OUTSET_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUTSET_PIN21_Msk (0x1UL << GPIO_OUTSET_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUTSET_PIN21_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN21_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN21_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 20 : Pin 20. */ -#define GPIO_OUTSET_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUTSET_PIN20_Msk (0x1UL << GPIO_OUTSET_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUTSET_PIN20_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN20_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN20_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 19 : Pin 19. */ -#define GPIO_OUTSET_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUTSET_PIN19_Msk (0x1UL << GPIO_OUTSET_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUTSET_PIN19_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN19_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN19_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 18 : Pin 18. */ -#define GPIO_OUTSET_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUTSET_PIN18_Msk (0x1UL << GPIO_OUTSET_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUTSET_PIN18_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN18_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN18_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 17 : Pin 17. */ -#define GPIO_OUTSET_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUTSET_PIN17_Msk (0x1UL << GPIO_OUTSET_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUTSET_PIN17_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN17_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN17_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 16 : Pin 16. */ -#define GPIO_OUTSET_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUTSET_PIN16_Msk (0x1UL << GPIO_OUTSET_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUTSET_PIN16_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN16_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN16_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 15 : Pin 15. */ -#define GPIO_OUTSET_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUTSET_PIN15_Msk (0x1UL << GPIO_OUTSET_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUTSET_PIN15_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN15_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN15_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 14 : Pin 14. */ -#define GPIO_OUTSET_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUTSET_PIN14_Msk (0x1UL << GPIO_OUTSET_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUTSET_PIN14_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN14_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN14_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 13 : Pin 13. */ -#define GPIO_OUTSET_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUTSET_PIN13_Msk (0x1UL << GPIO_OUTSET_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUTSET_PIN13_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN13_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN13_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 12 : Pin 12. */ -#define GPIO_OUTSET_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUTSET_PIN12_Msk (0x1UL << GPIO_OUTSET_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUTSET_PIN12_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN12_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN12_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 11 : Pin 11. */ -#define GPIO_OUTSET_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUTSET_PIN11_Msk (0x1UL << GPIO_OUTSET_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUTSET_PIN11_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN11_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN11_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 10 : Pin 10. */ -#define GPIO_OUTSET_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUTSET_PIN10_Msk (0x1UL << GPIO_OUTSET_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUTSET_PIN10_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN10_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN10_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 9 : Pin 9. */ -#define GPIO_OUTSET_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUTSET_PIN9_Msk (0x1UL << GPIO_OUTSET_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUTSET_PIN9_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN9_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN9_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 8 : Pin 8. */ -#define GPIO_OUTSET_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUTSET_PIN8_Msk (0x1UL << GPIO_OUTSET_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUTSET_PIN8_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN8_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN8_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 7 : Pin 7. */ -#define GPIO_OUTSET_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUTSET_PIN7_Msk (0x1UL << GPIO_OUTSET_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUTSET_PIN7_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN7_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN7_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 6 : Pin 6. */ -#define GPIO_OUTSET_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUTSET_PIN6_Msk (0x1UL << GPIO_OUTSET_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUTSET_PIN6_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN6_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN6_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 5 : Pin 5. */ -#define GPIO_OUTSET_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUTSET_PIN5_Msk (0x1UL << GPIO_OUTSET_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUTSET_PIN5_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN5_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN5_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 4 : Pin 4. */ -#define GPIO_OUTSET_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUTSET_PIN4_Msk (0x1UL << GPIO_OUTSET_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUTSET_PIN4_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN4_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN4_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 3 : Pin 3. */ -#define GPIO_OUTSET_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUTSET_PIN3_Msk (0x1UL << GPIO_OUTSET_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUTSET_PIN3_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN3_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN3_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 2 : Pin 2. */ -#define GPIO_OUTSET_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUTSET_PIN2_Msk (0x1UL << GPIO_OUTSET_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUTSET_PIN2_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN2_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN2_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 1 : Pin 1. */ -#define GPIO_OUTSET_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUTSET_PIN1_Msk (0x1UL << GPIO_OUTSET_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUTSET_PIN1_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN1_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN1_Set (1UL) /*!< Set pin driver high. */ - -/* Bit 0 : Pin 0. */ -#define GPIO_OUTSET_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUTSET_PIN0_Msk (0x1UL << GPIO_OUTSET_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUTSET_PIN0_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTSET_PIN0_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTSET_PIN0_Set (1UL) /*!< Set pin driver high. */ - -/* Register: GPIO_OUTCLR */ -/* Description: Clear individual bits in GPIO port. */ - -/* Bit 31 : Pin 31. */ -#define GPIO_OUTCLR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUTCLR_PIN31_Msk (0x1UL << GPIO_OUTCLR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUTCLR_PIN31_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN31_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN31_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 30 : Pin 30. */ -#define GPIO_OUTCLR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUTCLR_PIN30_Msk (0x1UL << GPIO_OUTCLR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUTCLR_PIN30_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN30_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN30_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 29 : Pin 29. */ -#define GPIO_OUTCLR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUTCLR_PIN29_Msk (0x1UL << GPIO_OUTCLR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUTCLR_PIN29_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN29_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN29_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 28 : Pin 28. */ -#define GPIO_OUTCLR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUTCLR_PIN28_Msk (0x1UL << GPIO_OUTCLR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUTCLR_PIN28_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN28_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN28_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 27 : Pin 27. */ -#define GPIO_OUTCLR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUTCLR_PIN27_Msk (0x1UL << GPIO_OUTCLR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUTCLR_PIN27_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN27_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN27_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 26 : Pin 26. */ -#define GPIO_OUTCLR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUTCLR_PIN26_Msk (0x1UL << GPIO_OUTCLR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUTCLR_PIN26_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN26_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN26_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 25 : Pin 25. */ -#define GPIO_OUTCLR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUTCLR_PIN25_Msk (0x1UL << GPIO_OUTCLR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUTCLR_PIN25_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN25_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN25_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 24 : Pin 24. */ -#define GPIO_OUTCLR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUTCLR_PIN24_Msk (0x1UL << GPIO_OUTCLR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUTCLR_PIN24_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN24_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN24_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 23 : Pin 23. */ -#define GPIO_OUTCLR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUTCLR_PIN23_Msk (0x1UL << GPIO_OUTCLR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUTCLR_PIN23_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN23_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN23_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 22 : Pin 22. */ -#define GPIO_OUTCLR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUTCLR_PIN22_Msk (0x1UL << GPIO_OUTCLR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUTCLR_PIN22_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN22_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN22_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 21 : Pin 21. */ -#define GPIO_OUTCLR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUTCLR_PIN21_Msk (0x1UL << GPIO_OUTCLR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUTCLR_PIN21_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN21_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN21_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 20 : Pin 20. */ -#define GPIO_OUTCLR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUTCLR_PIN20_Msk (0x1UL << GPIO_OUTCLR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUTCLR_PIN20_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN20_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN20_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 19 : Pin 19. */ -#define GPIO_OUTCLR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUTCLR_PIN19_Msk (0x1UL << GPIO_OUTCLR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUTCLR_PIN19_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN19_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN19_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 18 : Pin 18. */ -#define GPIO_OUTCLR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUTCLR_PIN18_Msk (0x1UL << GPIO_OUTCLR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUTCLR_PIN18_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN18_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN18_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 17 : Pin 17. */ -#define GPIO_OUTCLR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUTCLR_PIN17_Msk (0x1UL << GPIO_OUTCLR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUTCLR_PIN17_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN17_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN17_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 16 : Pin 16. */ -#define GPIO_OUTCLR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUTCLR_PIN16_Msk (0x1UL << GPIO_OUTCLR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUTCLR_PIN16_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN16_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN16_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 15 : Pin 15. */ -#define GPIO_OUTCLR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUTCLR_PIN15_Msk (0x1UL << GPIO_OUTCLR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUTCLR_PIN15_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN15_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN15_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 14 : Pin 14. */ -#define GPIO_OUTCLR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUTCLR_PIN14_Msk (0x1UL << GPIO_OUTCLR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUTCLR_PIN14_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN14_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN14_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 13 : Pin 13. */ -#define GPIO_OUTCLR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUTCLR_PIN13_Msk (0x1UL << GPIO_OUTCLR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUTCLR_PIN13_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN13_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN13_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 12 : Pin 12. */ -#define GPIO_OUTCLR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUTCLR_PIN12_Msk (0x1UL << GPIO_OUTCLR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUTCLR_PIN12_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN12_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN12_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 11 : Pin 11. */ -#define GPIO_OUTCLR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUTCLR_PIN11_Msk (0x1UL << GPIO_OUTCLR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUTCLR_PIN11_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN11_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN11_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 10 : Pin 10. */ -#define GPIO_OUTCLR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUTCLR_PIN10_Msk (0x1UL << GPIO_OUTCLR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUTCLR_PIN10_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN10_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN10_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 9 : Pin 9. */ -#define GPIO_OUTCLR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUTCLR_PIN9_Msk (0x1UL << GPIO_OUTCLR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUTCLR_PIN9_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN9_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN9_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 8 : Pin 8. */ -#define GPIO_OUTCLR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUTCLR_PIN8_Msk (0x1UL << GPIO_OUTCLR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUTCLR_PIN8_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN8_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN8_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 7 : Pin 7. */ -#define GPIO_OUTCLR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUTCLR_PIN7_Msk (0x1UL << GPIO_OUTCLR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUTCLR_PIN7_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN7_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN7_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 6 : Pin 6. */ -#define GPIO_OUTCLR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUTCLR_PIN6_Msk (0x1UL << GPIO_OUTCLR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUTCLR_PIN6_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN6_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN6_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 5 : Pin 5. */ -#define GPIO_OUTCLR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUTCLR_PIN5_Msk (0x1UL << GPIO_OUTCLR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUTCLR_PIN5_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN5_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN5_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 4 : Pin 4. */ -#define GPIO_OUTCLR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUTCLR_PIN4_Msk (0x1UL << GPIO_OUTCLR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUTCLR_PIN4_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN4_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN4_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 3 : Pin 3. */ -#define GPIO_OUTCLR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUTCLR_PIN3_Msk (0x1UL << GPIO_OUTCLR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUTCLR_PIN3_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN3_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN3_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 2 : Pin 2. */ -#define GPIO_OUTCLR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUTCLR_PIN2_Msk (0x1UL << GPIO_OUTCLR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUTCLR_PIN2_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN2_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN2_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 1 : Pin 1. */ -#define GPIO_OUTCLR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUTCLR_PIN1_Msk (0x1UL << GPIO_OUTCLR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUTCLR_PIN1_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN1_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN1_Clear (1UL) /*!< Set pin driver low. */ - -/* Bit 0 : Pin 0. */ -#define GPIO_OUTCLR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUTCLR_PIN0_Msk (0x1UL << GPIO_OUTCLR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUTCLR_PIN0_Low (0UL) /*!< Pin driver is low. */ -#define GPIO_OUTCLR_PIN0_High (1UL) /*!< Pin driver is high. */ -#define GPIO_OUTCLR_PIN0_Clear (1UL) /*!< Set pin driver low. */ - -/* Register: GPIO_IN */ -/* Description: Read GPIO port. */ - -/* Bit 31 : Pin 31. */ -#define GPIO_IN_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_IN_PIN31_Msk (0x1UL << GPIO_IN_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_IN_PIN31_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN31_High (1UL) /*!< Pin input is high. */ - -/* Bit 30 : Pin 30. */ -#define GPIO_IN_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_IN_PIN30_Msk (0x1UL << GPIO_IN_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_IN_PIN30_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN30_High (1UL) /*!< Pin input is high. */ - -/* Bit 29 : Pin 29. */ -#define GPIO_IN_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_IN_PIN29_Msk (0x1UL << GPIO_IN_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_IN_PIN29_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN29_High (1UL) /*!< Pin input is high. */ - -/* Bit 28 : Pin 28. */ -#define GPIO_IN_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_IN_PIN28_Msk (0x1UL << GPIO_IN_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_IN_PIN28_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN28_High (1UL) /*!< Pin input is high. */ - -/* Bit 27 : Pin 27. */ -#define GPIO_IN_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_IN_PIN27_Msk (0x1UL << GPIO_IN_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_IN_PIN27_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN27_High (1UL) /*!< Pin input is high. */ - -/* Bit 26 : Pin 26. */ -#define GPIO_IN_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_IN_PIN26_Msk (0x1UL << GPIO_IN_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_IN_PIN26_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN26_High (1UL) /*!< Pin input is high. */ - -/* Bit 25 : Pin 25. */ -#define GPIO_IN_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_IN_PIN25_Msk (0x1UL << GPIO_IN_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_IN_PIN25_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN25_High (1UL) /*!< Pin input is high. */ - -/* Bit 24 : Pin 24. */ -#define GPIO_IN_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_IN_PIN24_Msk (0x1UL << GPIO_IN_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_IN_PIN24_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN24_High (1UL) /*!< Pin input is high. */ - -/* Bit 23 : Pin 23. */ -#define GPIO_IN_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_IN_PIN23_Msk (0x1UL << GPIO_IN_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_IN_PIN23_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN23_High (1UL) /*!< Pin input is high. */ - -/* Bit 22 : Pin 22. */ -#define GPIO_IN_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_IN_PIN22_Msk (0x1UL << GPIO_IN_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_IN_PIN22_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN22_High (1UL) /*!< Pin input is high. */ - -/* Bit 21 : Pin 21. */ -#define GPIO_IN_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_IN_PIN21_Msk (0x1UL << GPIO_IN_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_IN_PIN21_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN21_High (1UL) /*!< Pin input is high. */ - -/* Bit 20 : Pin 20. */ -#define GPIO_IN_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_IN_PIN20_Msk (0x1UL << GPIO_IN_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_IN_PIN20_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN20_High (1UL) /*!< Pin input is high. */ - -/* Bit 19 : Pin 19. */ -#define GPIO_IN_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_IN_PIN19_Msk (0x1UL << GPIO_IN_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_IN_PIN19_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN19_High (1UL) /*!< Pin input is high. */ - -/* Bit 18 : Pin 18. */ -#define GPIO_IN_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_IN_PIN18_Msk (0x1UL << GPIO_IN_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_IN_PIN18_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN18_High (1UL) /*!< Pin input is high. */ - -/* Bit 17 : Pin 17. */ -#define GPIO_IN_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_IN_PIN17_Msk (0x1UL << GPIO_IN_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_IN_PIN17_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN17_High (1UL) /*!< Pin input is high. */ - -/* Bit 16 : Pin 16. */ -#define GPIO_IN_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_IN_PIN16_Msk (0x1UL << GPIO_IN_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_IN_PIN16_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN16_High (1UL) /*!< Pin input is high. */ - -/* Bit 15 : Pin 15. */ -#define GPIO_IN_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_IN_PIN15_Msk (0x1UL << GPIO_IN_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_IN_PIN15_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN15_High (1UL) /*!< Pin input is high. */ - -/* Bit 14 : Pin 14. */ -#define GPIO_IN_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_IN_PIN14_Msk (0x1UL << GPIO_IN_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_IN_PIN14_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN14_High (1UL) /*!< Pin input is high. */ - -/* Bit 13 : Pin 13. */ -#define GPIO_IN_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_IN_PIN13_Msk (0x1UL << GPIO_IN_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_IN_PIN13_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN13_High (1UL) /*!< Pin input is high. */ - -/* Bit 12 : Pin 12. */ -#define GPIO_IN_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_IN_PIN12_Msk (0x1UL << GPIO_IN_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_IN_PIN12_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN12_High (1UL) /*!< Pin input is high. */ - -/* Bit 11 : Pin 11. */ -#define GPIO_IN_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_IN_PIN11_Msk (0x1UL << GPIO_IN_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_IN_PIN11_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN11_High (1UL) /*!< Pin input is high. */ - -/* Bit 10 : Pin 10. */ -#define GPIO_IN_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_IN_PIN10_Msk (0x1UL << GPIO_IN_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_IN_PIN10_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN10_High (1UL) /*!< Pin input is high. */ - -/* Bit 9 : Pin 9. */ -#define GPIO_IN_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_IN_PIN9_Msk (0x1UL << GPIO_IN_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_IN_PIN9_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN9_High (1UL) /*!< Pin input is high. */ - -/* Bit 8 : Pin 8. */ -#define GPIO_IN_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_IN_PIN8_Msk (0x1UL << GPIO_IN_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_IN_PIN8_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN8_High (1UL) /*!< Pin input is high. */ - -/* Bit 7 : Pin 7. */ -#define GPIO_IN_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_IN_PIN7_Msk (0x1UL << GPIO_IN_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_IN_PIN7_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN7_High (1UL) /*!< Pin input is high. */ - -/* Bit 6 : Pin 6. */ -#define GPIO_IN_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_IN_PIN6_Msk (0x1UL << GPIO_IN_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_IN_PIN6_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN6_High (1UL) /*!< Pin input is high. */ - -/* Bit 5 : Pin 5. */ -#define GPIO_IN_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_IN_PIN5_Msk (0x1UL << GPIO_IN_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_IN_PIN5_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN5_High (1UL) /*!< Pin input is high. */ - -/* Bit 4 : Pin 4. */ -#define GPIO_IN_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_IN_PIN4_Msk (0x1UL << GPIO_IN_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_IN_PIN4_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN4_High (1UL) /*!< Pin input is high. */ - -/* Bit 3 : Pin 3. */ -#define GPIO_IN_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_IN_PIN3_Msk (0x1UL << GPIO_IN_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_IN_PIN3_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN3_High (1UL) /*!< Pin input is high. */ - -/* Bit 2 : Pin 2. */ -#define GPIO_IN_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_IN_PIN2_Msk (0x1UL << GPIO_IN_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_IN_PIN2_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN2_High (1UL) /*!< Pin input is high. */ - -/* Bit 1 : Pin 1. */ -#define GPIO_IN_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_IN_PIN1_Msk (0x1UL << GPIO_IN_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_IN_PIN1_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN1_High (1UL) /*!< Pin input is high. */ - -/* Bit 0 : Pin 0. */ -#define GPIO_IN_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_IN_PIN0_Msk (0x1UL << GPIO_IN_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_IN_PIN0_Low (0UL) /*!< Pin input is low. */ -#define GPIO_IN_PIN0_High (1UL) /*!< Pin input is high. */ - -/* Register: GPIO_DIR */ -/* Description: Direction of GPIO pins. */ - -/* Bit 31 : Pin 31. */ -#define GPIO_DIR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIR_PIN31_Msk (0x1UL << GPIO_DIR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIR_PIN31_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN31_Output (1UL) /*!< Pin set as output. */ - -/* Bit 30 : Pin 30. */ -#define GPIO_DIR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIR_PIN30_Msk (0x1UL << GPIO_DIR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIR_PIN30_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN30_Output (1UL) /*!< Pin set as output. */ - -/* Bit 29 : Pin 29. */ -#define GPIO_DIR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIR_PIN29_Msk (0x1UL << GPIO_DIR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIR_PIN29_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN29_Output (1UL) /*!< Pin set as output. */ - -/* Bit 28 : Pin 28. */ -#define GPIO_DIR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIR_PIN28_Msk (0x1UL << GPIO_DIR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIR_PIN28_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN28_Output (1UL) /*!< Pin set as output. */ - -/* Bit 27 : Pin 27. */ -#define GPIO_DIR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIR_PIN27_Msk (0x1UL << GPIO_DIR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIR_PIN27_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN27_Output (1UL) /*!< Pin set as output. */ - -/* Bit 26 : Pin 26. */ -#define GPIO_DIR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIR_PIN26_Msk (0x1UL << GPIO_DIR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIR_PIN26_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN26_Output (1UL) /*!< Pin set as output. */ - -/* Bit 25 : Pin 25. */ -#define GPIO_DIR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIR_PIN25_Msk (0x1UL << GPIO_DIR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIR_PIN25_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN25_Output (1UL) /*!< Pin set as output. */ - -/* Bit 24 : Pin 24. */ -#define GPIO_DIR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIR_PIN24_Msk (0x1UL << GPIO_DIR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIR_PIN24_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN24_Output (1UL) /*!< Pin set as output. */ - -/* Bit 23 : Pin 23. */ -#define GPIO_DIR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIR_PIN23_Msk (0x1UL << GPIO_DIR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIR_PIN23_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN23_Output (1UL) /*!< Pin set as output. */ - -/* Bit 22 : Pin 22. */ -#define GPIO_DIR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIR_PIN22_Msk (0x1UL << GPIO_DIR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIR_PIN22_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN22_Output (1UL) /*!< Pin set as output. */ - -/* Bit 21 : Pin 21. */ -#define GPIO_DIR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIR_PIN21_Msk (0x1UL << GPIO_DIR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIR_PIN21_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN21_Output (1UL) /*!< Pin set as output. */ - -/* Bit 20 : Pin 20. */ -#define GPIO_DIR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIR_PIN20_Msk (0x1UL << GPIO_DIR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIR_PIN20_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN20_Output (1UL) /*!< Pin set as output. */ - -/* Bit 19 : Pin 19. */ -#define GPIO_DIR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIR_PIN19_Msk (0x1UL << GPIO_DIR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIR_PIN19_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN19_Output (1UL) /*!< Pin set as output. */ - -/* Bit 18 : Pin 18. */ -#define GPIO_DIR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIR_PIN18_Msk (0x1UL << GPIO_DIR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIR_PIN18_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN18_Output (1UL) /*!< Pin set as output. */ - -/* Bit 17 : Pin 17. */ -#define GPIO_DIR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIR_PIN17_Msk (0x1UL << GPIO_DIR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIR_PIN17_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN17_Output (1UL) /*!< Pin set as output. */ - -/* Bit 16 : Pin 16. */ -#define GPIO_DIR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIR_PIN16_Msk (0x1UL << GPIO_DIR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIR_PIN16_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN16_Output (1UL) /*!< Pin set as output. */ - -/* Bit 15 : Pin 15. */ -#define GPIO_DIR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIR_PIN15_Msk (0x1UL << GPIO_DIR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIR_PIN15_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN15_Output (1UL) /*!< Pin set as output. */ - -/* Bit 14 : Pin 14. */ -#define GPIO_DIR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIR_PIN14_Msk (0x1UL << GPIO_DIR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIR_PIN14_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN14_Output (1UL) /*!< Pin set as output. */ - -/* Bit 13 : Pin 13. */ -#define GPIO_DIR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIR_PIN13_Msk (0x1UL << GPIO_DIR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIR_PIN13_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN13_Output (1UL) /*!< Pin set as output. */ - -/* Bit 12 : Pin 12. */ -#define GPIO_DIR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIR_PIN12_Msk (0x1UL << GPIO_DIR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIR_PIN12_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN12_Output (1UL) /*!< Pin set as output. */ - -/* Bit 11 : Pin 11. */ -#define GPIO_DIR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIR_PIN11_Msk (0x1UL << GPIO_DIR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIR_PIN11_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN11_Output (1UL) /*!< Pin set as output. */ - -/* Bit 10 : Pin 10. */ -#define GPIO_DIR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIR_PIN10_Msk (0x1UL << GPIO_DIR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIR_PIN10_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN10_Output (1UL) /*!< Pin set as output. */ - -/* Bit 9 : Pin 9. */ -#define GPIO_DIR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIR_PIN9_Msk (0x1UL << GPIO_DIR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIR_PIN9_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN9_Output (1UL) /*!< Pin set as output. */ - -/* Bit 8 : Pin 8. */ -#define GPIO_DIR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIR_PIN8_Msk (0x1UL << GPIO_DIR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIR_PIN8_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN8_Output (1UL) /*!< Pin set as output. */ - -/* Bit 7 : Pin 7. */ -#define GPIO_DIR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIR_PIN7_Msk (0x1UL << GPIO_DIR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIR_PIN7_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN7_Output (1UL) /*!< Pin set as output. */ - -/* Bit 6 : Pin 6. */ -#define GPIO_DIR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIR_PIN6_Msk (0x1UL << GPIO_DIR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIR_PIN6_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN6_Output (1UL) /*!< Pin set as output. */ - -/* Bit 5 : Pin 5. */ -#define GPIO_DIR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIR_PIN5_Msk (0x1UL << GPIO_DIR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIR_PIN5_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN5_Output (1UL) /*!< Pin set as output. */ - -/* Bit 4 : Pin 4. */ -#define GPIO_DIR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIR_PIN4_Msk (0x1UL << GPIO_DIR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIR_PIN4_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN4_Output (1UL) /*!< Pin set as output. */ - -/* Bit 3 : Pin 3. */ -#define GPIO_DIR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIR_PIN3_Msk (0x1UL << GPIO_DIR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIR_PIN3_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN3_Output (1UL) /*!< Pin set as output. */ - -/* Bit 2 : Pin 2. */ -#define GPIO_DIR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIR_PIN2_Msk (0x1UL << GPIO_DIR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIR_PIN2_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN2_Output (1UL) /*!< Pin set as output. */ - -/* Bit 1 : Pin 1. */ -#define GPIO_DIR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIR_PIN1_Msk (0x1UL << GPIO_DIR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIR_PIN1_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN1_Output (1UL) /*!< Pin set as output. */ - -/* Bit 0 : Pin 0. */ -#define GPIO_DIR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIR_PIN0_Msk (0x1UL << GPIO_DIR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIR_PIN0_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIR_PIN0_Output (1UL) /*!< Pin set as output. */ - -/* Register: GPIO_DIRSET */ -/* Description: DIR set register. */ - -/* Bit 31 : Set as output pin 31. */ -#define GPIO_DIRSET_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIRSET_PIN31_Msk (0x1UL << GPIO_DIRSET_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIRSET_PIN31_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN31_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN31_Set (1UL) /*!< Set pin as output. */ - -/* Bit 30 : Set as output pin 30. */ -#define GPIO_DIRSET_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIRSET_PIN30_Msk (0x1UL << GPIO_DIRSET_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIRSET_PIN30_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN30_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN30_Set (1UL) /*!< Set pin as output. */ - -/* Bit 29 : Set as output pin 29. */ -#define GPIO_DIRSET_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIRSET_PIN29_Msk (0x1UL << GPIO_DIRSET_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIRSET_PIN29_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN29_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN29_Set (1UL) /*!< Set pin as output. */ - -/* Bit 28 : Set as output pin 28. */ -#define GPIO_DIRSET_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIRSET_PIN28_Msk (0x1UL << GPIO_DIRSET_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIRSET_PIN28_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN28_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN28_Set (1UL) /*!< Set pin as output. */ - -/* Bit 27 : Set as output pin 27. */ -#define GPIO_DIRSET_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIRSET_PIN27_Msk (0x1UL << GPIO_DIRSET_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIRSET_PIN27_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN27_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN27_Set (1UL) /*!< Set pin as output. */ - -/* Bit 26 : Set as output pin 26. */ -#define GPIO_DIRSET_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIRSET_PIN26_Msk (0x1UL << GPIO_DIRSET_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIRSET_PIN26_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN26_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN26_Set (1UL) /*!< Set pin as output. */ - -/* Bit 25 : Set as output pin 25. */ -#define GPIO_DIRSET_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIRSET_PIN25_Msk (0x1UL << GPIO_DIRSET_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIRSET_PIN25_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN25_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN25_Set (1UL) /*!< Set pin as output. */ - -/* Bit 24 : Set as output pin 24. */ -#define GPIO_DIRSET_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIRSET_PIN24_Msk (0x1UL << GPIO_DIRSET_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIRSET_PIN24_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN24_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN24_Set (1UL) /*!< Set pin as output. */ - -/* Bit 23 : Set as output pin 23. */ -#define GPIO_DIRSET_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIRSET_PIN23_Msk (0x1UL << GPIO_DIRSET_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIRSET_PIN23_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN23_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN23_Set (1UL) /*!< Set pin as output. */ - -/* Bit 22 : Set as output pin 22. */ -#define GPIO_DIRSET_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIRSET_PIN22_Msk (0x1UL << GPIO_DIRSET_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIRSET_PIN22_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN22_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN22_Set (1UL) /*!< Set pin as output. */ - -/* Bit 21 : Set as output pin 21. */ -#define GPIO_DIRSET_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIRSET_PIN21_Msk (0x1UL << GPIO_DIRSET_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIRSET_PIN21_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN21_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN21_Set (1UL) /*!< Set pin as output. */ - -/* Bit 20 : Set as output pin 20. */ -#define GPIO_DIRSET_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIRSET_PIN20_Msk (0x1UL << GPIO_DIRSET_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIRSET_PIN20_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN20_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN20_Set (1UL) /*!< Set pin as output. */ - -/* Bit 19 : Set as output pin 19. */ -#define GPIO_DIRSET_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIRSET_PIN19_Msk (0x1UL << GPIO_DIRSET_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIRSET_PIN19_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN19_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN19_Set (1UL) /*!< Set pin as output. */ - -/* Bit 18 : Set as output pin 18. */ -#define GPIO_DIRSET_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIRSET_PIN18_Msk (0x1UL << GPIO_DIRSET_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIRSET_PIN18_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN18_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN18_Set (1UL) /*!< Set pin as output. */ - -/* Bit 17 : Set as output pin 17. */ -#define GPIO_DIRSET_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIRSET_PIN17_Msk (0x1UL << GPIO_DIRSET_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIRSET_PIN17_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN17_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN17_Set (1UL) /*!< Set pin as output. */ - -/* Bit 16 : Set as output pin 16. */ -#define GPIO_DIRSET_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIRSET_PIN16_Msk (0x1UL << GPIO_DIRSET_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIRSET_PIN16_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN16_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN16_Set (1UL) /*!< Set pin as output. */ - -/* Bit 15 : Set as output pin 15. */ -#define GPIO_DIRSET_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIRSET_PIN15_Msk (0x1UL << GPIO_DIRSET_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIRSET_PIN15_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN15_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN15_Set (1UL) /*!< Set pin as output. */ - -/* Bit 14 : Set as output pin 14. */ -#define GPIO_DIRSET_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIRSET_PIN14_Msk (0x1UL << GPIO_DIRSET_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIRSET_PIN14_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN14_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN14_Set (1UL) /*!< Set pin as output. */ - -/* Bit 13 : Set as output pin 13. */ -#define GPIO_DIRSET_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIRSET_PIN13_Msk (0x1UL << GPIO_DIRSET_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIRSET_PIN13_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN13_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN13_Set (1UL) /*!< Set pin as output. */ - -/* Bit 12 : Set as output pin 12. */ -#define GPIO_DIRSET_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIRSET_PIN12_Msk (0x1UL << GPIO_DIRSET_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIRSET_PIN12_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN12_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN12_Set (1UL) /*!< Set pin as output. */ - -/* Bit 11 : Set as output pin 11. */ -#define GPIO_DIRSET_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIRSET_PIN11_Msk (0x1UL << GPIO_DIRSET_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIRSET_PIN11_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN11_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN11_Set (1UL) /*!< Set pin as output. */ - -/* Bit 10 : Set as output pin 10. */ -#define GPIO_DIRSET_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIRSET_PIN10_Msk (0x1UL << GPIO_DIRSET_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIRSET_PIN10_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN10_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN10_Set (1UL) /*!< Set pin as output. */ - -/* Bit 9 : Set as output pin 9. */ -#define GPIO_DIRSET_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIRSET_PIN9_Msk (0x1UL << GPIO_DIRSET_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIRSET_PIN9_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN9_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN9_Set (1UL) /*!< Set pin as output. */ - -/* Bit 8 : Set as output pin 8. */ -#define GPIO_DIRSET_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIRSET_PIN8_Msk (0x1UL << GPIO_DIRSET_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIRSET_PIN8_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN8_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN8_Set (1UL) /*!< Set pin as output. */ - -/* Bit 7 : Set as output pin 7. */ -#define GPIO_DIRSET_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIRSET_PIN7_Msk (0x1UL << GPIO_DIRSET_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIRSET_PIN7_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN7_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN7_Set (1UL) /*!< Set pin as output. */ - -/* Bit 6 : Set as output pin 6. */ -#define GPIO_DIRSET_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIRSET_PIN6_Msk (0x1UL << GPIO_DIRSET_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIRSET_PIN6_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN6_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN6_Set (1UL) /*!< Set pin as output. */ - -/* Bit 5 : Set as output pin 5. */ -#define GPIO_DIRSET_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIRSET_PIN5_Msk (0x1UL << GPIO_DIRSET_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIRSET_PIN5_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN5_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN5_Set (1UL) /*!< Set pin as output. */ - -/* Bit 4 : Set as output pin 4. */ -#define GPIO_DIRSET_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIRSET_PIN4_Msk (0x1UL << GPIO_DIRSET_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIRSET_PIN4_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN4_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN4_Set (1UL) /*!< Set pin as output. */ - -/* Bit 3 : Set as output pin 3. */ -#define GPIO_DIRSET_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIRSET_PIN3_Msk (0x1UL << GPIO_DIRSET_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIRSET_PIN3_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN3_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN3_Set (1UL) /*!< Set pin as output. */ - -/* Bit 2 : Set as output pin 2. */ -#define GPIO_DIRSET_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIRSET_PIN2_Msk (0x1UL << GPIO_DIRSET_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIRSET_PIN2_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN2_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN2_Set (1UL) /*!< Set pin as output. */ - -/* Bit 1 : Set as output pin 1. */ -#define GPIO_DIRSET_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIRSET_PIN1_Msk (0x1UL << GPIO_DIRSET_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIRSET_PIN1_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN1_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN1_Set (1UL) /*!< Set pin as output. */ - -/* Bit 0 : Set as output pin 0. */ -#define GPIO_DIRSET_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIRSET_PIN0_Msk (0x1UL << GPIO_DIRSET_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIRSET_PIN0_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRSET_PIN0_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRSET_PIN0_Set (1UL) /*!< Set pin as output. */ - -/* Register: GPIO_DIRCLR */ -/* Description: DIR clear register. */ - -/* Bit 31 : Set as input pin 31. */ -#define GPIO_DIRCLR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIRCLR_PIN31_Msk (0x1UL << GPIO_DIRCLR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIRCLR_PIN31_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN31_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN31_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 30 : Set as input pin 30. */ -#define GPIO_DIRCLR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIRCLR_PIN30_Msk (0x1UL << GPIO_DIRCLR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIRCLR_PIN30_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN30_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN30_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 29 : Set as input pin 29. */ -#define GPIO_DIRCLR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIRCLR_PIN29_Msk (0x1UL << GPIO_DIRCLR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIRCLR_PIN29_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN29_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN29_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 28 : Set as input pin 28. */ -#define GPIO_DIRCLR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIRCLR_PIN28_Msk (0x1UL << GPIO_DIRCLR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIRCLR_PIN28_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN28_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN28_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 27 : Set as input pin 27. */ -#define GPIO_DIRCLR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIRCLR_PIN27_Msk (0x1UL << GPIO_DIRCLR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIRCLR_PIN27_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN27_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN27_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 26 : Set as input pin 26. */ -#define GPIO_DIRCLR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIRCLR_PIN26_Msk (0x1UL << GPIO_DIRCLR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIRCLR_PIN26_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN26_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN26_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 25 : Set as input pin 25. */ -#define GPIO_DIRCLR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIRCLR_PIN25_Msk (0x1UL << GPIO_DIRCLR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIRCLR_PIN25_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN25_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN25_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 24 : Set as input pin 24. */ -#define GPIO_DIRCLR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIRCLR_PIN24_Msk (0x1UL << GPIO_DIRCLR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIRCLR_PIN24_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN24_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN24_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 23 : Set as input pin 23. */ -#define GPIO_DIRCLR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIRCLR_PIN23_Msk (0x1UL << GPIO_DIRCLR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIRCLR_PIN23_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN23_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN23_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 22 : Set as input pin 22. */ -#define GPIO_DIRCLR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIRCLR_PIN22_Msk (0x1UL << GPIO_DIRCLR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIRCLR_PIN22_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN22_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN22_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 21 : Set as input pin 21. */ -#define GPIO_DIRCLR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIRCLR_PIN21_Msk (0x1UL << GPIO_DIRCLR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIRCLR_PIN21_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN21_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN21_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 20 : Set as input pin 20. */ -#define GPIO_DIRCLR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIRCLR_PIN20_Msk (0x1UL << GPIO_DIRCLR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIRCLR_PIN20_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN20_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN20_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 19 : Set as input pin 19. */ -#define GPIO_DIRCLR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIRCLR_PIN19_Msk (0x1UL << GPIO_DIRCLR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIRCLR_PIN19_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN19_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN19_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 18 : Set as input pin 18. */ -#define GPIO_DIRCLR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIRCLR_PIN18_Msk (0x1UL << GPIO_DIRCLR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIRCLR_PIN18_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN18_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN18_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 17 : Set as input pin 17. */ -#define GPIO_DIRCLR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIRCLR_PIN17_Msk (0x1UL << GPIO_DIRCLR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIRCLR_PIN17_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN17_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN17_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 16 : Set as input pin 16. */ -#define GPIO_DIRCLR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIRCLR_PIN16_Msk (0x1UL << GPIO_DIRCLR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIRCLR_PIN16_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN16_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN16_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 15 : Set as input pin 15. */ -#define GPIO_DIRCLR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIRCLR_PIN15_Msk (0x1UL << GPIO_DIRCLR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIRCLR_PIN15_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN15_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN15_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 14 : Set as input pin 14. */ -#define GPIO_DIRCLR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIRCLR_PIN14_Msk (0x1UL << GPIO_DIRCLR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIRCLR_PIN14_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN14_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN14_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 13 : Set as input pin 13. */ -#define GPIO_DIRCLR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIRCLR_PIN13_Msk (0x1UL << GPIO_DIRCLR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIRCLR_PIN13_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN13_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN13_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 12 : Set as input pin 12. */ -#define GPIO_DIRCLR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIRCLR_PIN12_Msk (0x1UL << GPIO_DIRCLR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIRCLR_PIN12_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN12_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN12_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 11 : Set as input pin 11. */ -#define GPIO_DIRCLR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIRCLR_PIN11_Msk (0x1UL << GPIO_DIRCLR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIRCLR_PIN11_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN11_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN11_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 10 : Set as input pin 10. */ -#define GPIO_DIRCLR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIRCLR_PIN10_Msk (0x1UL << GPIO_DIRCLR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIRCLR_PIN10_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN10_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN10_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 9 : Set as input pin 9. */ -#define GPIO_DIRCLR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIRCLR_PIN9_Msk (0x1UL << GPIO_DIRCLR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIRCLR_PIN9_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN9_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN9_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 8 : Set as input pin 8. */ -#define GPIO_DIRCLR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIRCLR_PIN8_Msk (0x1UL << GPIO_DIRCLR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIRCLR_PIN8_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN8_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN8_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 7 : Set as input pin 7. */ -#define GPIO_DIRCLR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIRCLR_PIN7_Msk (0x1UL << GPIO_DIRCLR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIRCLR_PIN7_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN7_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN7_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 6 : Set as input pin 6. */ -#define GPIO_DIRCLR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIRCLR_PIN6_Msk (0x1UL << GPIO_DIRCLR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIRCLR_PIN6_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN6_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN6_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 5 : Set as input pin 5. */ -#define GPIO_DIRCLR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIRCLR_PIN5_Msk (0x1UL << GPIO_DIRCLR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIRCLR_PIN5_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN5_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN5_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 4 : Set as input pin 4. */ -#define GPIO_DIRCLR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIRCLR_PIN4_Msk (0x1UL << GPIO_DIRCLR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIRCLR_PIN4_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN4_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN4_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 3 : Set as input pin 3. */ -#define GPIO_DIRCLR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIRCLR_PIN3_Msk (0x1UL << GPIO_DIRCLR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIRCLR_PIN3_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN3_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN3_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 2 : Set as input pin 2. */ -#define GPIO_DIRCLR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIRCLR_PIN2_Msk (0x1UL << GPIO_DIRCLR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIRCLR_PIN2_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN2_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN2_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 1 : Set as input pin 1. */ -#define GPIO_DIRCLR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIRCLR_PIN1_Msk (0x1UL << GPIO_DIRCLR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIRCLR_PIN1_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN1_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN1_Clear (1UL) /*!< Set pin as input. */ - -/* Bit 0 : Set as input pin 0. */ -#define GPIO_DIRCLR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIRCLR_PIN0_Msk (0x1UL << GPIO_DIRCLR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIRCLR_PIN0_Input (0UL) /*!< Pin set as input. */ -#define GPIO_DIRCLR_PIN0_Output (1UL) /*!< Pin set as output. */ -#define GPIO_DIRCLR_PIN0_Clear (1UL) /*!< Set pin as input. */ - -/* Register: GPIO_PIN_CNF */ -/* Description: Configuration of GPIO pins. */ - -/* Bits 17..16 : Pin sensing mechanism. */ -#define GPIO_PIN_CNF_SENSE_Pos (16UL) /*!< Position of SENSE field. */ -#define GPIO_PIN_CNF_SENSE_Msk (0x3UL << GPIO_PIN_CNF_SENSE_Pos) /*!< Bit mask of SENSE field. */ -#define GPIO_PIN_CNF_SENSE_Disabled (0x00UL) /*!< Disabled. */ -#define GPIO_PIN_CNF_SENSE_High (0x02UL) /*!< Wakeup on high level. */ -#define GPIO_PIN_CNF_SENSE_Low (0x03UL) /*!< Wakeup on low level. */ - -/* Bits 10..8 : Drive configuration. */ -#define GPIO_PIN_CNF_DRIVE_Pos (8UL) /*!< Position of DRIVE field. */ -#define GPIO_PIN_CNF_DRIVE_Msk (0x7UL << GPIO_PIN_CNF_DRIVE_Pos) /*!< Bit mask of DRIVE field. */ -#define GPIO_PIN_CNF_DRIVE_S0S1 (0x00UL) /*!< Standard '0', Standard '1'. */ -#define GPIO_PIN_CNF_DRIVE_H0S1 (0x01UL) /*!< High '0', Standard '1'. */ -#define GPIO_PIN_CNF_DRIVE_S0H1 (0x02UL) /*!< Standard '0', High '1'. */ -#define GPIO_PIN_CNF_DRIVE_H0H1 (0x03UL) /*!< High '0', High '1'. */ -#define GPIO_PIN_CNF_DRIVE_D0S1 (0x04UL) /*!< Disconnected '0', Standard '1'. */ -#define GPIO_PIN_CNF_DRIVE_D0H1 (0x05UL) /*!< Disconnected '0', High '1'. */ -#define GPIO_PIN_CNF_DRIVE_S0D1 (0x06UL) /*!< Standard '0', Disconnected '1'. */ -#define GPIO_PIN_CNF_DRIVE_H0D1 (0x07UL) /*!< High '0', Disconnected '1'. */ - -/* Bits 3..2 : Pull-up or -down configuration. */ -#define GPIO_PIN_CNF_PULL_Pos (2UL) /*!< Position of PULL field. */ -#define GPIO_PIN_CNF_PULL_Msk (0x3UL << GPIO_PIN_CNF_PULL_Pos) /*!< Bit mask of PULL field. */ -#define GPIO_PIN_CNF_PULL_Disabled (0x00UL) /*!< No pull. */ -#define GPIO_PIN_CNF_PULL_Pulldown (0x01UL) /*!< Pulldown on pin. */ -#define GPIO_PIN_CNF_PULL_Pullup (0x03UL) /*!< Pullup on pin. */ - -/* Bit 1 : Connect or disconnect input path. */ -#define GPIO_PIN_CNF_INPUT_Pos (1UL) /*!< Position of INPUT field. */ -#define GPIO_PIN_CNF_INPUT_Msk (0x1UL << GPIO_PIN_CNF_INPUT_Pos) /*!< Bit mask of INPUT field. */ -#define GPIO_PIN_CNF_INPUT_Connect (0UL) /*!< Connect input pin. */ -#define GPIO_PIN_CNF_INPUT_Disconnect (1UL) /*!< Disconnect input pin. */ - -/* Bit 0 : Pin direction. */ -#define GPIO_PIN_CNF_DIR_Pos (0UL) /*!< Position of DIR field. */ -#define GPIO_PIN_CNF_DIR_Msk (0x1UL << GPIO_PIN_CNF_DIR_Pos) /*!< Bit mask of DIR field. */ -#define GPIO_PIN_CNF_DIR_Input (0UL) /*!< Configure pin as an input pin. */ -#define GPIO_PIN_CNF_DIR_Output (1UL) /*!< Configure pin as an output pin. */ - - -/* Peripheral: GPIOTE */ -/* Description: GPIO tasks and events. */ - -/* Register: GPIOTE_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 31 : Enable interrupt on PORT event. */ -#define GPIOTE_INTENSET_PORT_Pos (31UL) /*!< Position of PORT field. */ -#define GPIOTE_INTENSET_PORT_Msk (0x1UL << GPIOTE_INTENSET_PORT_Pos) /*!< Bit mask of PORT field. */ -#define GPIOTE_INTENSET_PORT_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENSET_PORT_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENSET_PORT_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 3 : Enable interrupt on IN[3] event. */ -#define GPIOTE_INTENSET_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define GPIOTE_INTENSET_IN3_Msk (0x1UL << GPIOTE_INTENSET_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define GPIOTE_INTENSET_IN3_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENSET_IN3_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENSET_IN3_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 2 : Enable interrupt on IN[2] event. */ -#define GPIOTE_INTENSET_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define GPIOTE_INTENSET_IN2_Msk (0x1UL << GPIOTE_INTENSET_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define GPIOTE_INTENSET_IN2_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENSET_IN2_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENSET_IN2_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on IN[1] event. */ -#define GPIOTE_INTENSET_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define GPIOTE_INTENSET_IN1_Msk (0x1UL << GPIOTE_INTENSET_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define GPIOTE_INTENSET_IN1_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENSET_IN1_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENSET_IN1_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on IN[0] event. */ -#define GPIOTE_INTENSET_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define GPIOTE_INTENSET_IN0_Msk (0x1UL << GPIOTE_INTENSET_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define GPIOTE_INTENSET_IN0_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENSET_IN0_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENSET_IN0_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: GPIOTE_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 31 : Disable interrupt on PORT event. */ -#define GPIOTE_INTENCLR_PORT_Pos (31UL) /*!< Position of PORT field. */ -#define GPIOTE_INTENCLR_PORT_Msk (0x1UL << GPIOTE_INTENCLR_PORT_Pos) /*!< Bit mask of PORT field. */ -#define GPIOTE_INTENCLR_PORT_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENCLR_PORT_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENCLR_PORT_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 3 : Disable interrupt on IN[3] event. */ -#define GPIOTE_INTENCLR_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define GPIOTE_INTENCLR_IN3_Msk (0x1UL << GPIOTE_INTENCLR_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define GPIOTE_INTENCLR_IN3_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENCLR_IN3_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENCLR_IN3_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 2 : Disable interrupt on IN[2] event. */ -#define GPIOTE_INTENCLR_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define GPIOTE_INTENCLR_IN2_Msk (0x1UL << GPIOTE_INTENCLR_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define GPIOTE_INTENCLR_IN2_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENCLR_IN2_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENCLR_IN2_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on IN[1] event. */ -#define GPIOTE_INTENCLR_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define GPIOTE_INTENCLR_IN1_Msk (0x1UL << GPIOTE_INTENCLR_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define GPIOTE_INTENCLR_IN1_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENCLR_IN1_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENCLR_IN1_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on IN[0] event. */ -#define GPIOTE_INTENCLR_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define GPIOTE_INTENCLR_IN0_Msk (0x1UL << GPIOTE_INTENCLR_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define GPIOTE_INTENCLR_IN0_Disabled (0UL) /*!< Interrupt disabled. */ -#define GPIOTE_INTENCLR_IN0_Enabled (1UL) /*!< Interrupt enabled. */ -#define GPIOTE_INTENCLR_IN0_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: GPIOTE_CONFIG */ -/* Description: Channel configuration registers. */ - -/* Bit 20 : Initial value of the output when the GPIOTE channel is configured as a Task. */ -#define GPIOTE_CONFIG_OUTINIT_Pos (20UL) /*!< Position of OUTINIT field. */ -#define GPIOTE_CONFIG_OUTINIT_Msk (0x1UL << GPIOTE_CONFIG_OUTINIT_Pos) /*!< Bit mask of OUTINIT field. */ -#define GPIOTE_CONFIG_OUTINIT_Low (0UL) /*!< Initial low output when in task mode. */ -#define GPIOTE_CONFIG_OUTINIT_High (1UL) /*!< Initial high output when in task mode. */ - -/* Bits 17..16 : Effects on output when in Task mode, or events on input that generates an event. */ -#define GPIOTE_CONFIG_POLARITY_Pos (16UL) /*!< Position of POLARITY field. */ -#define GPIOTE_CONFIG_POLARITY_Msk (0x3UL << GPIOTE_CONFIG_POLARITY_Pos) /*!< Bit mask of POLARITY field. */ -#define GPIOTE_CONFIG_POLARITY_None (0x00UL) /*!< No task or event. */ -#define GPIOTE_CONFIG_POLARITY_LoToHi (0x01UL) /*!< Low to high. */ -#define GPIOTE_CONFIG_POLARITY_HiToLo (0x02UL) /*!< High to low. */ -#define GPIOTE_CONFIG_POLARITY_Toggle (0x03UL) /*!< Toggle. */ - -/* Bits 12..8 : Pin select. */ -#define GPIOTE_CONFIG_PSEL_Pos (8UL) /*!< Position of PSEL field. */ -#define GPIOTE_CONFIG_PSEL_Msk (0x1FUL << GPIOTE_CONFIG_PSEL_Pos) /*!< Bit mask of PSEL field. */ - -/* Bits 1..0 : Mode */ -#define GPIOTE_CONFIG_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define GPIOTE_CONFIG_MODE_Msk (0x3UL << GPIOTE_CONFIG_MODE_Pos) /*!< Bit mask of MODE field. */ -#define GPIOTE_CONFIG_MODE_Disabled (0x00UL) /*!< Disabled. */ -#define GPIOTE_CONFIG_MODE_Event (0x01UL) /*!< Channel configure in event mode. */ -#define GPIOTE_CONFIG_MODE_Task (0x03UL) /*!< Channel configure in task mode. */ - -/* Register: GPIOTE_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define GPIOTE_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define GPIOTE_POWER_POWER_Msk (0x1UL << GPIOTE_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define GPIOTE_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define GPIOTE_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: LPCOMP */ -/* Description: Low power comparator. */ - -/* Register: LPCOMP_SHORTS */ -/* Description: Shortcuts for the LPCOMP. */ - -/* Bit 4 : Shortcut between CROSS event and STOP task. */ -#define LPCOMP_SHORTS_CROSS_STOP_Pos (4UL) /*!< Position of CROSS_STOP field. */ -#define LPCOMP_SHORTS_CROSS_STOP_Msk (0x1UL << LPCOMP_SHORTS_CROSS_STOP_Pos) /*!< Bit mask of CROSS_STOP field. */ -#define LPCOMP_SHORTS_CROSS_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define LPCOMP_SHORTS_CROSS_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 3 : Shortcut between UP event and STOP task. */ -#define LPCOMP_SHORTS_UP_STOP_Pos (3UL) /*!< Position of UP_STOP field. */ -#define LPCOMP_SHORTS_UP_STOP_Msk (0x1UL << LPCOMP_SHORTS_UP_STOP_Pos) /*!< Bit mask of UP_STOP field. */ -#define LPCOMP_SHORTS_UP_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define LPCOMP_SHORTS_UP_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 2 : Shortcut between DOWN event and STOP task. */ -#define LPCOMP_SHORTS_DOWN_STOP_Pos (2UL) /*!< Position of DOWN_STOP field. */ -#define LPCOMP_SHORTS_DOWN_STOP_Msk (0x1UL << LPCOMP_SHORTS_DOWN_STOP_Pos) /*!< Bit mask of DOWN_STOP field. */ -#define LPCOMP_SHORTS_DOWN_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define LPCOMP_SHORTS_DOWN_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 1 : Shortcut between RADY event and STOP task. */ -#define LPCOMP_SHORTS_READY_STOP_Pos (1UL) /*!< Position of READY_STOP field. */ -#define LPCOMP_SHORTS_READY_STOP_Msk (0x1UL << LPCOMP_SHORTS_READY_STOP_Pos) /*!< Bit mask of READY_STOP field. */ -#define LPCOMP_SHORTS_READY_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define LPCOMP_SHORTS_READY_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 0 : Shortcut between READY event and SAMPLE task. */ -#define LPCOMP_SHORTS_READY_SAMPLE_Pos (0UL) /*!< Position of READY_SAMPLE field. */ -#define LPCOMP_SHORTS_READY_SAMPLE_Msk (0x1UL << LPCOMP_SHORTS_READY_SAMPLE_Pos) /*!< Bit mask of READY_SAMPLE field. */ -#define LPCOMP_SHORTS_READY_SAMPLE_Disabled (0UL) /*!< Shortcut disabled. */ -#define LPCOMP_SHORTS_READY_SAMPLE_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: LPCOMP_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 3 : Enable interrupt on CROSS event. */ -#define LPCOMP_INTENSET_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define LPCOMP_INTENSET_CROSS_Msk (0x1UL << LPCOMP_INTENSET_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define LPCOMP_INTENSET_CROSS_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENSET_CROSS_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENSET_CROSS_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 2 : Enable interrupt on UP event. */ -#define LPCOMP_INTENSET_UP_Pos (2UL) /*!< Position of UP field. */ -#define LPCOMP_INTENSET_UP_Msk (0x1UL << LPCOMP_INTENSET_UP_Pos) /*!< Bit mask of UP field. */ -#define LPCOMP_INTENSET_UP_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENSET_UP_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENSET_UP_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on DOWN event. */ -#define LPCOMP_INTENSET_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define LPCOMP_INTENSET_DOWN_Msk (0x1UL << LPCOMP_INTENSET_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define LPCOMP_INTENSET_DOWN_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENSET_DOWN_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENSET_DOWN_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on READY event. */ -#define LPCOMP_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define LPCOMP_INTENSET_READY_Msk (0x1UL << LPCOMP_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define LPCOMP_INTENSET_READY_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENSET_READY_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENSET_READY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: LPCOMP_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 3 : Disable interrupt on CROSS event. */ -#define LPCOMP_INTENCLR_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define LPCOMP_INTENCLR_CROSS_Msk (0x1UL << LPCOMP_INTENCLR_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define LPCOMP_INTENCLR_CROSS_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENCLR_CROSS_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENCLR_CROSS_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 2 : Disable interrupt on UP event. */ -#define LPCOMP_INTENCLR_UP_Pos (2UL) /*!< Position of UP field. */ -#define LPCOMP_INTENCLR_UP_Msk (0x1UL << LPCOMP_INTENCLR_UP_Pos) /*!< Bit mask of UP field. */ -#define LPCOMP_INTENCLR_UP_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENCLR_UP_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENCLR_UP_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on DOWN event. */ -#define LPCOMP_INTENCLR_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define LPCOMP_INTENCLR_DOWN_Msk (0x1UL << LPCOMP_INTENCLR_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define LPCOMP_INTENCLR_DOWN_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENCLR_DOWN_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENCLR_DOWN_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on READY event. */ -#define LPCOMP_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define LPCOMP_INTENCLR_READY_Msk (0x1UL << LPCOMP_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define LPCOMP_INTENCLR_READY_Disabled (0UL) /*!< Interrupt disabled. */ -#define LPCOMP_INTENCLR_READY_Enabled (1UL) /*!< Interrupt enabled. */ -#define LPCOMP_INTENCLR_READY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: LPCOMP_RESULT */ -/* Description: Result of last compare. */ - -/* Bit 0 : Result of last compare. Decision point SAMPLE task. */ -#define LPCOMP_RESULT_RESULT_Pos (0UL) /*!< Position of RESULT field. */ -#define LPCOMP_RESULT_RESULT_Msk (0x1UL << LPCOMP_RESULT_RESULT_Pos) /*!< Bit mask of RESULT field. */ -#define LPCOMP_RESULT_RESULT_Below (0UL) /*!< Input voltage is bellow the reference threshold. */ -#define LPCOMP_RESULT_RESULT_Above (1UL) /*!< Input voltage is above the reference threshold. */ - -/* Register: LPCOMP_ENABLE */ -/* Description: Enable the LPCOMP. */ - -/* Bits 1..0 : Enable or disable LPCOMP. */ -#define LPCOMP_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define LPCOMP_ENABLE_ENABLE_Msk (0x3UL << LPCOMP_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define LPCOMP_ENABLE_ENABLE_Disabled (0x00UL) /*!< Disabled LPCOMP. */ -#define LPCOMP_ENABLE_ENABLE_Enabled (0x01UL) /*!< Enable LPCOMP. */ - -/* Register: LPCOMP_PSEL */ -/* Description: Input pin select. */ - -/* Bits 2..0 : Analog input pin select. */ -#define LPCOMP_PSEL_PSEL_Pos (0UL) /*!< Position of PSEL field. */ -#define LPCOMP_PSEL_PSEL_Msk (0x7UL << LPCOMP_PSEL_PSEL_Pos) /*!< Bit mask of PSEL field. */ -#define LPCOMP_PSEL_PSEL_AnalogInput0 (0UL) /*!< Use analog input 0 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput1 (1UL) /*!< Use analog input 1 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput2 (2UL) /*!< Use analog input 2 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput3 (3UL) /*!< Use analog input 3 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput4 (4UL) /*!< Use analog input 4 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput5 (5UL) /*!< Use analog input 5 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput6 (6UL) /*!< Use analog input 6 as analog input. */ -#define LPCOMP_PSEL_PSEL_AnalogInput7 (7UL) /*!< Use analog input 7 as analog input. */ - -/* Register: LPCOMP_REFSEL */ -/* Description: Reference select. */ - -/* Bits 2..0 : Reference select. */ -#define LPCOMP_REFSEL_REFSEL_Pos (0UL) /*!< Position of REFSEL field. */ -#define LPCOMP_REFSEL_REFSEL_Msk (0x7UL << LPCOMP_REFSEL_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define LPCOMP_REFSEL_REFSEL_SupplyOneEighthPrescaling (0UL) /*!< Use supply with a 1/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_SupplyTwoEighthsPrescaling (1UL) /*!< Use supply with a 2/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_SupplyThreeEighthsPrescaling (2UL) /*!< Use supply with a 3/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_SupplyFourEighthsPrescaling (3UL) /*!< Use supply with a 4/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_SupplyFiveEighthsPrescaling (4UL) /*!< Use supply with a 5/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_SupplySixEighthsPrescaling (5UL) /*!< Use supply with a 6/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling (6UL) /*!< Use supply with a 7/8 prescaler as reference. */ -#define LPCOMP_REFSEL_REFSEL_ARef (7UL) /*!< Use external analog reference as reference. */ - -/* Register: LPCOMP_EXTREFSEL */ -/* Description: External reference select. */ - -/* Bit 0 : External analog reference pin selection. */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_Pos (0UL) /*!< Position of EXTREFSEL field. */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_Msk (0x1UL << LPCOMP_EXTREFSEL_EXTREFSEL_Pos) /*!< Bit mask of EXTREFSEL field. */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference0 (0UL) /*!< Use analog reference 0 as reference. */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference1 (1UL) /*!< Use analog reference 1 as reference. */ - -/* Register: LPCOMP_ANADETECT */ -/* Description: Analog detect configuration. */ - -/* Bits 1..0 : Analog detect configuration. */ -#define LPCOMP_ANADETECT_ANADETECT_Pos (0UL) /*!< Position of ANADETECT field. */ -#define LPCOMP_ANADETECT_ANADETECT_Msk (0x3UL << LPCOMP_ANADETECT_ANADETECT_Pos) /*!< Bit mask of ANADETECT field. */ -#define LPCOMP_ANADETECT_ANADETECT_Cross (0UL) /*!< Generate ANADETEC on crossing, both upwards and downwards crossing. */ -#define LPCOMP_ANADETECT_ANADETECT_Up (1UL) /*!< Generate ANADETEC on upwards crossing only. */ -#define LPCOMP_ANADETECT_ANADETECT_Down (2UL) /*!< Generate ANADETEC on downwards crossing only. */ - -/* Register: LPCOMP_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define LPCOMP_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define LPCOMP_POWER_POWER_Msk (0x1UL << LPCOMP_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define LPCOMP_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define LPCOMP_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: MPU */ -/* Description: Memory Protection Unit. */ - -/* Register: MPU_PERR0 */ -/* Description: Configuration of peripherals in mpu regions. */ - -/* Bit 31 : PPI region configuration. */ -#define MPU_PERR0_PPI_Pos (31UL) /*!< Position of PPI field. */ -#define MPU_PERR0_PPI_Msk (0x1UL << MPU_PERR0_PPI_Pos) /*!< Bit mask of PPI field. */ -#define MPU_PERR0_PPI_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_PPI_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 30 : NVMC region configuration. */ -#define MPU_PERR0_NVMC_Pos (30UL) /*!< Position of NVMC field. */ -#define MPU_PERR0_NVMC_Msk (0x1UL << MPU_PERR0_NVMC_Pos) /*!< Bit mask of NVMC field. */ -#define MPU_PERR0_NVMC_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_NVMC_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 19 : LPCOMP region configuration. */ -#define MPU_PERR0_LPCOMP_Pos (19UL) /*!< Position of LPCOMP field. */ -#define MPU_PERR0_LPCOMP_Msk (0x1UL << MPU_PERR0_LPCOMP_Pos) /*!< Bit mask of LPCOMP field. */ -#define MPU_PERR0_LPCOMP_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_LPCOMP_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 18 : QDEC region configuration. */ -#define MPU_PERR0_QDEC_Pos (18UL) /*!< Position of QDEC field. */ -#define MPU_PERR0_QDEC_Msk (0x1UL << MPU_PERR0_QDEC_Pos) /*!< Bit mask of QDEC field. */ -#define MPU_PERR0_QDEC_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_QDEC_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 17 : RTC1 region configuration. */ -#define MPU_PERR0_RTC1_Pos (17UL) /*!< Position of RTC1 field. */ -#define MPU_PERR0_RTC1_Msk (0x1UL << MPU_PERR0_RTC1_Pos) /*!< Bit mask of RTC1 field. */ -#define MPU_PERR0_RTC1_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_RTC1_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 16 : WDT region configuration. */ -#define MPU_PERR0_WDT_Pos (16UL) /*!< Position of WDT field. */ -#define MPU_PERR0_WDT_Msk (0x1UL << MPU_PERR0_WDT_Pos) /*!< Bit mask of WDT field. */ -#define MPU_PERR0_WDT_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_WDT_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 15 : CCM and AAR region configuration. */ -#define MPU_PERR0_CCM_AAR_Pos (15UL) /*!< Position of CCM_AAR field. */ -#define MPU_PERR0_CCM_AAR_Msk (0x1UL << MPU_PERR0_CCM_AAR_Pos) /*!< Bit mask of CCM_AAR field. */ -#define MPU_PERR0_CCM_AAR_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_CCM_AAR_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 14 : ECB region configuration. */ -#define MPU_PERR0_ECB_Pos (14UL) /*!< Position of ECB field. */ -#define MPU_PERR0_ECB_Msk (0x1UL << MPU_PERR0_ECB_Pos) /*!< Bit mask of ECB field. */ -#define MPU_PERR0_ECB_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_ECB_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 13 : RNG region configuration. */ -#define MPU_PERR0_RNG_Pos (13UL) /*!< Position of RNG field. */ -#define MPU_PERR0_RNG_Msk (0x1UL << MPU_PERR0_RNG_Pos) /*!< Bit mask of RNG field. */ -#define MPU_PERR0_RNG_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_RNG_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 12 : TEMP region configuration. */ -#define MPU_PERR0_TEMP_Pos (12UL) /*!< Position of TEMP field. */ -#define MPU_PERR0_TEMP_Msk (0x1UL << MPU_PERR0_TEMP_Pos) /*!< Bit mask of TEMP field. */ -#define MPU_PERR0_TEMP_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_TEMP_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 11 : RTC0 region configuration. */ -#define MPU_PERR0_RTC0_Pos (11UL) /*!< Position of RTC0 field. */ -#define MPU_PERR0_RTC0_Msk (0x1UL << MPU_PERR0_RTC0_Pos) /*!< Bit mask of RTC0 field. */ -#define MPU_PERR0_RTC0_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_RTC0_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 10 : TIMER2 region configuration. */ -#define MPU_PERR0_TIMER2_Pos (10UL) /*!< Position of TIMER2 field. */ -#define MPU_PERR0_TIMER2_Msk (0x1UL << MPU_PERR0_TIMER2_Pos) /*!< Bit mask of TIMER2 field. */ -#define MPU_PERR0_TIMER2_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_TIMER2_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 9 : TIMER1 region configuration. */ -#define MPU_PERR0_TIMER1_Pos (9UL) /*!< Position of TIMER1 field. */ -#define MPU_PERR0_TIMER1_Msk (0x1UL << MPU_PERR0_TIMER1_Pos) /*!< Bit mask of TIMER1 field. */ -#define MPU_PERR0_TIMER1_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_TIMER1_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 8 : TIMER0 region configuration. */ -#define MPU_PERR0_TIMER0_Pos (8UL) /*!< Position of TIMER0 field. */ -#define MPU_PERR0_TIMER0_Msk (0x1UL << MPU_PERR0_TIMER0_Pos) /*!< Bit mask of TIMER0 field. */ -#define MPU_PERR0_TIMER0_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_TIMER0_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 7 : ADC region configuration. */ -#define MPU_PERR0_ADC_Pos (7UL) /*!< Position of ADC field. */ -#define MPU_PERR0_ADC_Msk (0x1UL << MPU_PERR0_ADC_Pos) /*!< Bit mask of ADC field. */ -#define MPU_PERR0_ADC_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_ADC_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 6 : GPIOTE region configuration. */ -#define MPU_PERR0_GPIOTE_Pos (6UL) /*!< Position of GPIOTE field. */ -#define MPU_PERR0_GPIOTE_Msk (0x1UL << MPU_PERR0_GPIOTE_Pos) /*!< Bit mask of GPIOTE field. */ -#define MPU_PERR0_GPIOTE_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_GPIOTE_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 4 : SPI1 and TWI1 region configuration. */ -#define MPU_PERR0_SPI1_TWI1_Pos (4UL) /*!< Position of SPI1_TWI1 field. */ -#define MPU_PERR0_SPI1_TWI1_Msk (0x1UL << MPU_PERR0_SPI1_TWI1_Pos) /*!< Bit mask of SPI1_TWI1 field. */ -#define MPU_PERR0_SPI1_TWI1_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_SPI1_TWI1_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 3 : SPI0 and TWI0 region configuration. */ -#define MPU_PERR0_SPI0_TWI0_Pos (3UL) /*!< Position of SPI0_TWI0 field. */ -#define MPU_PERR0_SPI0_TWI0_Msk (0x1UL << MPU_PERR0_SPI0_TWI0_Pos) /*!< Bit mask of SPI0_TWI0 field. */ -#define MPU_PERR0_SPI0_TWI0_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_SPI0_TWI0_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 2 : UART0 region configuration. */ -#define MPU_PERR0_UART0_Pos (2UL) /*!< Position of UART0 field. */ -#define MPU_PERR0_UART0_Msk (0x1UL << MPU_PERR0_UART0_Pos) /*!< Bit mask of UART0 field. */ -#define MPU_PERR0_UART0_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_UART0_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 1 : RADIO region configuration. */ -#define MPU_PERR0_RADIO_Pos (1UL) /*!< Position of RADIO field. */ -#define MPU_PERR0_RADIO_Msk (0x1UL << MPU_PERR0_RADIO_Pos) /*!< Bit mask of RADIO field. */ -#define MPU_PERR0_RADIO_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_RADIO_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Bit 0 : POWER_CLOCK region configuration. */ -#define MPU_PERR0_POWER_CLOCK_Pos (0UL) /*!< Position of POWER_CLOCK field. */ -#define MPU_PERR0_POWER_CLOCK_Msk (0x1UL << MPU_PERR0_POWER_CLOCK_Pos) /*!< Bit mask of POWER_CLOCK field. */ -#define MPU_PERR0_POWER_CLOCK_InRegion1 (0UL) /*!< Peripheral configured in region 1. */ -#define MPU_PERR0_POWER_CLOCK_InRegion0 (1UL) /*!< Peripheral configured in region 0. */ - -/* Register: MPU_PROTENSET0 */ -/* Description: Erase and write protection bit enable set register. */ - -/* Bit 31 : Protection enable for region 31. */ -#define MPU_PROTENSET0_PROTREG31_Pos (31UL) /*!< Position of PROTREG31 field. */ -#define MPU_PROTENSET0_PROTREG31_Msk (0x1UL << MPU_PROTENSET0_PROTREG31_Pos) /*!< Bit mask of PROTREG31 field. */ -#define MPU_PROTENSET0_PROTREG31_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG31_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG31_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 30 : Protection enable for region 30. */ -#define MPU_PROTENSET0_PROTREG30_Pos (30UL) /*!< Position of PROTREG30 field. */ -#define MPU_PROTENSET0_PROTREG30_Msk (0x1UL << MPU_PROTENSET0_PROTREG30_Pos) /*!< Bit mask of PROTREG30 field. */ -#define MPU_PROTENSET0_PROTREG30_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG30_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG30_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 29 : Protection enable for region 29. */ -#define MPU_PROTENSET0_PROTREG29_Pos (29UL) /*!< Position of PROTREG29 field. */ -#define MPU_PROTENSET0_PROTREG29_Msk (0x1UL << MPU_PROTENSET0_PROTREG29_Pos) /*!< Bit mask of PROTREG29 field. */ -#define MPU_PROTENSET0_PROTREG29_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG29_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG29_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 28 : Protection enable for region 28. */ -#define MPU_PROTENSET0_PROTREG28_Pos (28UL) /*!< Position of PROTREG28 field. */ -#define MPU_PROTENSET0_PROTREG28_Msk (0x1UL << MPU_PROTENSET0_PROTREG28_Pos) /*!< Bit mask of PROTREG28 field. */ -#define MPU_PROTENSET0_PROTREG28_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG28_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG28_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 27 : Protection enable for region 27. */ -#define MPU_PROTENSET0_PROTREG27_Pos (27UL) /*!< Position of PROTREG27 field. */ -#define MPU_PROTENSET0_PROTREG27_Msk (0x1UL << MPU_PROTENSET0_PROTREG27_Pos) /*!< Bit mask of PROTREG27 field. */ -#define MPU_PROTENSET0_PROTREG27_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG27_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG27_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 26 : Protection enable for region 26. */ -#define MPU_PROTENSET0_PROTREG26_Pos (26UL) /*!< Position of PROTREG26 field. */ -#define MPU_PROTENSET0_PROTREG26_Msk (0x1UL << MPU_PROTENSET0_PROTREG26_Pos) /*!< Bit mask of PROTREG26 field. */ -#define MPU_PROTENSET0_PROTREG26_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG26_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG26_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 25 : Protection enable for region 25. */ -#define MPU_PROTENSET0_PROTREG25_Pos (25UL) /*!< Position of PROTREG25 field. */ -#define MPU_PROTENSET0_PROTREG25_Msk (0x1UL << MPU_PROTENSET0_PROTREG25_Pos) /*!< Bit mask of PROTREG25 field. */ -#define MPU_PROTENSET0_PROTREG25_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG25_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG25_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 24 : Protection enable for region 24. */ -#define MPU_PROTENSET0_PROTREG24_Pos (24UL) /*!< Position of PROTREG24 field. */ -#define MPU_PROTENSET0_PROTREG24_Msk (0x1UL << MPU_PROTENSET0_PROTREG24_Pos) /*!< Bit mask of PROTREG24 field. */ -#define MPU_PROTENSET0_PROTREG24_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG24_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG24_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 23 : Protection enable for region 23. */ -#define MPU_PROTENSET0_PROTREG23_Pos (23UL) /*!< Position of PROTREG23 field. */ -#define MPU_PROTENSET0_PROTREG23_Msk (0x1UL << MPU_PROTENSET0_PROTREG23_Pos) /*!< Bit mask of PROTREG23 field. */ -#define MPU_PROTENSET0_PROTREG23_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG23_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG23_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 22 : Protection enable for region 22. */ -#define MPU_PROTENSET0_PROTREG22_Pos (22UL) /*!< Position of PROTREG22 field. */ -#define MPU_PROTENSET0_PROTREG22_Msk (0x1UL << MPU_PROTENSET0_PROTREG22_Pos) /*!< Bit mask of PROTREG22 field. */ -#define MPU_PROTENSET0_PROTREG22_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG22_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG22_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 21 : Protection enable for region 21. */ -#define MPU_PROTENSET0_PROTREG21_Pos (21UL) /*!< Position of PROTREG21 field. */ -#define MPU_PROTENSET0_PROTREG21_Msk (0x1UL << MPU_PROTENSET0_PROTREG21_Pos) /*!< Bit mask of PROTREG21 field. */ -#define MPU_PROTENSET0_PROTREG21_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG21_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG21_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 20 : Protection enable for region 20. */ -#define MPU_PROTENSET0_PROTREG20_Pos (20UL) /*!< Position of PROTREG20 field. */ -#define MPU_PROTENSET0_PROTREG20_Msk (0x1UL << MPU_PROTENSET0_PROTREG20_Pos) /*!< Bit mask of PROTREG20 field. */ -#define MPU_PROTENSET0_PROTREG20_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG20_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG20_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 19 : Protection enable for region 19. */ -#define MPU_PROTENSET0_PROTREG19_Pos (19UL) /*!< Position of PROTREG19 field. */ -#define MPU_PROTENSET0_PROTREG19_Msk (0x1UL << MPU_PROTENSET0_PROTREG19_Pos) /*!< Bit mask of PROTREG19 field. */ -#define MPU_PROTENSET0_PROTREG19_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG19_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG19_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 18 : Protection enable for region 18. */ -#define MPU_PROTENSET0_PROTREG18_Pos (18UL) /*!< Position of PROTREG18 field. */ -#define MPU_PROTENSET0_PROTREG18_Msk (0x1UL << MPU_PROTENSET0_PROTREG18_Pos) /*!< Bit mask of PROTREG18 field. */ -#define MPU_PROTENSET0_PROTREG18_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG18_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG18_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 17 : Protection enable for region 17. */ -#define MPU_PROTENSET0_PROTREG17_Pos (17UL) /*!< Position of PROTREG17 field. */ -#define MPU_PROTENSET0_PROTREG17_Msk (0x1UL << MPU_PROTENSET0_PROTREG17_Pos) /*!< Bit mask of PROTREG17 field. */ -#define MPU_PROTENSET0_PROTREG17_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG17_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG17_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 16 : Protection enable for region 16. */ -#define MPU_PROTENSET0_PROTREG16_Pos (16UL) /*!< Position of PROTREG16 field. */ -#define MPU_PROTENSET0_PROTREG16_Msk (0x1UL << MPU_PROTENSET0_PROTREG16_Pos) /*!< Bit mask of PROTREG16 field. */ -#define MPU_PROTENSET0_PROTREG16_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG16_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG16_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 15 : Protection enable for region 15. */ -#define MPU_PROTENSET0_PROTREG15_Pos (15UL) /*!< Position of PROTREG15 field. */ -#define MPU_PROTENSET0_PROTREG15_Msk (0x1UL << MPU_PROTENSET0_PROTREG15_Pos) /*!< Bit mask of PROTREG15 field. */ -#define MPU_PROTENSET0_PROTREG15_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG15_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG15_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 14 : Protection enable for region 14. */ -#define MPU_PROTENSET0_PROTREG14_Pos (14UL) /*!< Position of PROTREG14 field. */ -#define MPU_PROTENSET0_PROTREG14_Msk (0x1UL << MPU_PROTENSET0_PROTREG14_Pos) /*!< Bit mask of PROTREG14 field. */ -#define MPU_PROTENSET0_PROTREG14_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG14_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG14_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 13 : Protection enable for region 13. */ -#define MPU_PROTENSET0_PROTREG13_Pos (13UL) /*!< Position of PROTREG13 field. */ -#define MPU_PROTENSET0_PROTREG13_Msk (0x1UL << MPU_PROTENSET0_PROTREG13_Pos) /*!< Bit mask of PROTREG13 field. */ -#define MPU_PROTENSET0_PROTREG13_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG13_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG13_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 12 : Protection enable for region 12. */ -#define MPU_PROTENSET0_PROTREG12_Pos (12UL) /*!< Position of PROTREG12 field. */ -#define MPU_PROTENSET0_PROTREG12_Msk (0x1UL << MPU_PROTENSET0_PROTREG12_Pos) /*!< Bit mask of PROTREG12 field. */ -#define MPU_PROTENSET0_PROTREG12_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG12_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG12_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 11 : Protection enable for region 11. */ -#define MPU_PROTENSET0_PROTREG11_Pos (11UL) /*!< Position of PROTREG11 field. */ -#define MPU_PROTENSET0_PROTREG11_Msk (0x1UL << MPU_PROTENSET0_PROTREG11_Pos) /*!< Bit mask of PROTREG11 field. */ -#define MPU_PROTENSET0_PROTREG11_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG11_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG11_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 10 : Protection enable for region 10. */ -#define MPU_PROTENSET0_PROTREG10_Pos (10UL) /*!< Position of PROTREG10 field. */ -#define MPU_PROTENSET0_PROTREG10_Msk (0x1UL << MPU_PROTENSET0_PROTREG10_Pos) /*!< Bit mask of PROTREG10 field. */ -#define MPU_PROTENSET0_PROTREG10_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG10_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG10_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 9 : Protection enable for region 9. */ -#define MPU_PROTENSET0_PROTREG9_Pos (9UL) /*!< Position of PROTREG9 field. */ -#define MPU_PROTENSET0_PROTREG9_Msk (0x1UL << MPU_PROTENSET0_PROTREG9_Pos) /*!< Bit mask of PROTREG9 field. */ -#define MPU_PROTENSET0_PROTREG9_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG9_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG9_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 8 : Protection enable for region 8. */ -#define MPU_PROTENSET0_PROTREG8_Pos (8UL) /*!< Position of PROTREG8 field. */ -#define MPU_PROTENSET0_PROTREG8_Msk (0x1UL << MPU_PROTENSET0_PROTREG8_Pos) /*!< Bit mask of PROTREG8 field. */ -#define MPU_PROTENSET0_PROTREG8_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG8_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG8_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 7 : Protection enable for region 7. */ -#define MPU_PROTENSET0_PROTREG7_Pos (7UL) /*!< Position of PROTREG7 field. */ -#define MPU_PROTENSET0_PROTREG7_Msk (0x1UL << MPU_PROTENSET0_PROTREG7_Pos) /*!< Bit mask of PROTREG7 field. */ -#define MPU_PROTENSET0_PROTREG7_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG7_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG7_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 6 : Protection enable for region 6. */ -#define MPU_PROTENSET0_PROTREG6_Pos (6UL) /*!< Position of PROTREG6 field. */ -#define MPU_PROTENSET0_PROTREG6_Msk (0x1UL << MPU_PROTENSET0_PROTREG6_Pos) /*!< Bit mask of PROTREG6 field. */ -#define MPU_PROTENSET0_PROTREG6_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG6_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG6_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 5 : Protection enable for region 5. */ -#define MPU_PROTENSET0_PROTREG5_Pos (5UL) /*!< Position of PROTREG5 field. */ -#define MPU_PROTENSET0_PROTREG5_Msk (0x1UL << MPU_PROTENSET0_PROTREG5_Pos) /*!< Bit mask of PROTREG5 field. */ -#define MPU_PROTENSET0_PROTREG5_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG5_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG5_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 4 : Protection enable for region 4. */ -#define MPU_PROTENSET0_PROTREG4_Pos (4UL) /*!< Position of PROTREG4 field. */ -#define MPU_PROTENSET0_PROTREG4_Msk (0x1UL << MPU_PROTENSET0_PROTREG4_Pos) /*!< Bit mask of PROTREG4 field. */ -#define MPU_PROTENSET0_PROTREG4_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG4_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG4_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 3 : Protection enable for region 3. */ -#define MPU_PROTENSET0_PROTREG3_Pos (3UL) /*!< Position of PROTREG3 field. */ -#define MPU_PROTENSET0_PROTREG3_Msk (0x1UL << MPU_PROTENSET0_PROTREG3_Pos) /*!< Bit mask of PROTREG3 field. */ -#define MPU_PROTENSET0_PROTREG3_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG3_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG3_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 2 : Protection enable for region 2. */ -#define MPU_PROTENSET0_PROTREG2_Pos (2UL) /*!< Position of PROTREG2 field. */ -#define MPU_PROTENSET0_PROTREG2_Msk (0x1UL << MPU_PROTENSET0_PROTREG2_Pos) /*!< Bit mask of PROTREG2 field. */ -#define MPU_PROTENSET0_PROTREG2_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG2_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG2_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 1 : Protection enable for region 1. */ -#define MPU_PROTENSET0_PROTREG1_Pos (1UL) /*!< Position of PROTREG1 field. */ -#define MPU_PROTENSET0_PROTREG1_Msk (0x1UL << MPU_PROTENSET0_PROTREG1_Pos) /*!< Bit mask of PROTREG1 field. */ -#define MPU_PROTENSET0_PROTREG1_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG1_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG1_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 0 : Protection enable for region 0. */ -#define MPU_PROTENSET0_PROTREG0_Pos (0UL) /*!< Position of PROTREG0 field. */ -#define MPU_PROTENSET0_PROTREG0_Msk (0x1UL << MPU_PROTENSET0_PROTREG0_Pos) /*!< Bit mask of PROTREG0 field. */ -#define MPU_PROTENSET0_PROTREG0_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET0_PROTREG0_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET0_PROTREG0_Set (1UL) /*!< Enable protection on write. */ - -/* Register: MPU_PROTENSET1 */ -/* Description: Erase and write protection bit enable set register. */ - -/* Bit 31 : Protection enable for region 63. */ -#define MPU_PROTENSET1_PROTREG63_Pos (31UL) /*!< Position of PROTREG63 field. */ -#define MPU_PROTENSET1_PROTREG63_Msk (0x1UL << MPU_PROTENSET1_PROTREG63_Pos) /*!< Bit mask of PROTREG63 field. */ -#define MPU_PROTENSET1_PROTREG63_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG63_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG63_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 30 : Protection enable for region 62. */ -#define MPU_PROTENSET1_PROTREG62_Pos (30UL) /*!< Position of PROTREG62 field. */ -#define MPU_PROTENSET1_PROTREG62_Msk (0x1UL << MPU_PROTENSET1_PROTREG62_Pos) /*!< Bit mask of PROTREG62 field. */ -#define MPU_PROTENSET1_PROTREG62_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG62_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG62_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 29 : Protection enable for region 61. */ -#define MPU_PROTENSET1_PROTREG61_Pos (29UL) /*!< Position of PROTREG61 field. */ -#define MPU_PROTENSET1_PROTREG61_Msk (0x1UL << MPU_PROTENSET1_PROTREG61_Pos) /*!< Bit mask of PROTREG61 field. */ -#define MPU_PROTENSET1_PROTREG61_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG61_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG61_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 28 : Protection enable for region 60. */ -#define MPU_PROTENSET1_PROTREG60_Pos (28UL) /*!< Position of PROTREG60 field. */ -#define MPU_PROTENSET1_PROTREG60_Msk (0x1UL << MPU_PROTENSET1_PROTREG60_Pos) /*!< Bit mask of PROTREG60 field. */ -#define MPU_PROTENSET1_PROTREG60_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG60_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG60_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 27 : Protection enable for region 59. */ -#define MPU_PROTENSET1_PROTREG59_Pos (27UL) /*!< Position of PROTREG59 field. */ -#define MPU_PROTENSET1_PROTREG59_Msk (0x1UL << MPU_PROTENSET1_PROTREG59_Pos) /*!< Bit mask of PROTREG59 field. */ -#define MPU_PROTENSET1_PROTREG59_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG59_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG59_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 26 : Protection enable for region 58. */ -#define MPU_PROTENSET1_PROTREG58_Pos (26UL) /*!< Position of PROTREG58 field. */ -#define MPU_PROTENSET1_PROTREG58_Msk (0x1UL << MPU_PROTENSET1_PROTREG58_Pos) /*!< Bit mask of PROTREG58 field. */ -#define MPU_PROTENSET1_PROTREG58_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG58_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG58_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 25 : Protection enable for region 57. */ -#define MPU_PROTENSET1_PROTREG57_Pos (25UL) /*!< Position of PROTREG57 field. */ -#define MPU_PROTENSET1_PROTREG57_Msk (0x1UL << MPU_PROTENSET1_PROTREG57_Pos) /*!< Bit mask of PROTREG57 field. */ -#define MPU_PROTENSET1_PROTREG57_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG57_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG57_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 24 : Protection enable for region 56. */ -#define MPU_PROTENSET1_PROTREG56_Pos (24UL) /*!< Position of PROTREG56 field. */ -#define MPU_PROTENSET1_PROTREG56_Msk (0x1UL << MPU_PROTENSET1_PROTREG56_Pos) /*!< Bit mask of PROTREG56 field. */ -#define MPU_PROTENSET1_PROTREG56_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG56_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG56_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 23 : Protection enable for region 55. */ -#define MPU_PROTENSET1_PROTREG55_Pos (23UL) /*!< Position of PROTREG55 field. */ -#define MPU_PROTENSET1_PROTREG55_Msk (0x1UL << MPU_PROTENSET1_PROTREG55_Pos) /*!< Bit mask of PROTREG55 field. */ -#define MPU_PROTENSET1_PROTREG55_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG55_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG55_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 22 : Protection enable for region 54. */ -#define MPU_PROTENSET1_PROTREG54_Pos (22UL) /*!< Position of PROTREG54 field. */ -#define MPU_PROTENSET1_PROTREG54_Msk (0x1UL << MPU_PROTENSET1_PROTREG54_Pos) /*!< Bit mask of PROTREG54 field. */ -#define MPU_PROTENSET1_PROTREG54_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG54_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG54_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 21 : Protection enable for region 53. */ -#define MPU_PROTENSET1_PROTREG53_Pos (21UL) /*!< Position of PROTREG53 field. */ -#define MPU_PROTENSET1_PROTREG53_Msk (0x1UL << MPU_PROTENSET1_PROTREG53_Pos) /*!< Bit mask of PROTREG53 field. */ -#define MPU_PROTENSET1_PROTREG53_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG53_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG53_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 20 : Protection enable for region 52. */ -#define MPU_PROTENSET1_PROTREG52_Pos (20UL) /*!< Position of PROTREG52 field. */ -#define MPU_PROTENSET1_PROTREG52_Msk (0x1UL << MPU_PROTENSET1_PROTREG52_Pos) /*!< Bit mask of PROTREG52 field. */ -#define MPU_PROTENSET1_PROTREG52_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG52_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG52_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 19 : Protection enable for region 51. */ -#define MPU_PROTENSET1_PROTREG51_Pos (19UL) /*!< Position of PROTREG51 field. */ -#define MPU_PROTENSET1_PROTREG51_Msk (0x1UL << MPU_PROTENSET1_PROTREG51_Pos) /*!< Bit mask of PROTREG51 field. */ -#define MPU_PROTENSET1_PROTREG51_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG51_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG51_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 18 : Protection enable for region 50. */ -#define MPU_PROTENSET1_PROTREG50_Pos (18UL) /*!< Position of PROTREG50 field. */ -#define MPU_PROTENSET1_PROTREG50_Msk (0x1UL << MPU_PROTENSET1_PROTREG50_Pos) /*!< Bit mask of PROTREG50 field. */ -#define MPU_PROTENSET1_PROTREG50_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG50_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG50_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 17 : Protection enable for region 49. */ -#define MPU_PROTENSET1_PROTREG49_Pos (17UL) /*!< Position of PROTREG49 field. */ -#define MPU_PROTENSET1_PROTREG49_Msk (0x1UL << MPU_PROTENSET1_PROTREG49_Pos) /*!< Bit mask of PROTREG49 field. */ -#define MPU_PROTENSET1_PROTREG49_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG49_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG49_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 16 : Protection enable for region 48. */ -#define MPU_PROTENSET1_PROTREG48_Pos (16UL) /*!< Position of PROTREG48 field. */ -#define MPU_PROTENSET1_PROTREG48_Msk (0x1UL << MPU_PROTENSET1_PROTREG48_Pos) /*!< Bit mask of PROTREG48 field. */ -#define MPU_PROTENSET1_PROTREG48_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG48_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG48_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 15 : Protection enable for region 47. */ -#define MPU_PROTENSET1_PROTREG47_Pos (15UL) /*!< Position of PROTREG47 field. */ -#define MPU_PROTENSET1_PROTREG47_Msk (0x1UL << MPU_PROTENSET1_PROTREG47_Pos) /*!< Bit mask of PROTREG47 field. */ -#define MPU_PROTENSET1_PROTREG47_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG47_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG47_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 14 : Protection enable for region 46. */ -#define MPU_PROTENSET1_PROTREG46_Pos (14UL) /*!< Position of PROTREG46 field. */ -#define MPU_PROTENSET1_PROTREG46_Msk (0x1UL << MPU_PROTENSET1_PROTREG46_Pos) /*!< Bit mask of PROTREG46 field. */ -#define MPU_PROTENSET1_PROTREG46_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG46_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG46_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 13 : Protection enable for region 45. */ -#define MPU_PROTENSET1_PROTREG45_Pos (13UL) /*!< Position of PROTREG45 field. */ -#define MPU_PROTENSET1_PROTREG45_Msk (0x1UL << MPU_PROTENSET1_PROTREG45_Pos) /*!< Bit mask of PROTREG45 field. */ -#define MPU_PROTENSET1_PROTREG45_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG45_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG45_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 12 : Protection enable for region 44. */ -#define MPU_PROTENSET1_PROTREG44_Pos (12UL) /*!< Position of PROTREG44 field. */ -#define MPU_PROTENSET1_PROTREG44_Msk (0x1UL << MPU_PROTENSET1_PROTREG44_Pos) /*!< Bit mask of PROTREG44 field. */ -#define MPU_PROTENSET1_PROTREG44_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG44_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG44_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 11 : Protection enable for region 43. */ -#define MPU_PROTENSET1_PROTREG43_Pos (11UL) /*!< Position of PROTREG43 field. */ -#define MPU_PROTENSET1_PROTREG43_Msk (0x1UL << MPU_PROTENSET1_PROTREG43_Pos) /*!< Bit mask of PROTREG43 field. */ -#define MPU_PROTENSET1_PROTREG43_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG43_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG43_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 10 : Protection enable for region 42. */ -#define MPU_PROTENSET1_PROTREG42_Pos (10UL) /*!< Position of PROTREG42 field. */ -#define MPU_PROTENSET1_PROTREG42_Msk (0x1UL << MPU_PROTENSET1_PROTREG42_Pos) /*!< Bit mask of PROTREG42 field. */ -#define MPU_PROTENSET1_PROTREG42_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG42_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG42_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 9 : Protection enable for region 41. */ -#define MPU_PROTENSET1_PROTREG41_Pos (9UL) /*!< Position of PROTREG41 field. */ -#define MPU_PROTENSET1_PROTREG41_Msk (0x1UL << MPU_PROTENSET1_PROTREG41_Pos) /*!< Bit mask of PROTREG41 field. */ -#define MPU_PROTENSET1_PROTREG41_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG41_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG41_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 8 : Protection enable for region 40. */ -#define MPU_PROTENSET1_PROTREG40_Pos (8UL) /*!< Position of PROTREG40 field. */ -#define MPU_PROTENSET1_PROTREG40_Msk (0x1UL << MPU_PROTENSET1_PROTREG40_Pos) /*!< Bit mask of PROTREG40 field. */ -#define MPU_PROTENSET1_PROTREG40_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG40_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG40_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 7 : Protection enable for region 39. */ -#define MPU_PROTENSET1_PROTREG39_Pos (7UL) /*!< Position of PROTREG39 field. */ -#define MPU_PROTENSET1_PROTREG39_Msk (0x1UL << MPU_PROTENSET1_PROTREG39_Pos) /*!< Bit mask of PROTREG39 field. */ -#define MPU_PROTENSET1_PROTREG39_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG39_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG39_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 6 : Protection enable for region 38. */ -#define MPU_PROTENSET1_PROTREG38_Pos (6UL) /*!< Position of PROTREG38 field. */ -#define MPU_PROTENSET1_PROTREG38_Msk (0x1UL << MPU_PROTENSET1_PROTREG38_Pos) /*!< Bit mask of PROTREG38 field. */ -#define MPU_PROTENSET1_PROTREG38_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG38_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG38_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 5 : Protection enable for region 37. */ -#define MPU_PROTENSET1_PROTREG37_Pos (5UL) /*!< Position of PROTREG37 field. */ -#define MPU_PROTENSET1_PROTREG37_Msk (0x1UL << MPU_PROTENSET1_PROTREG37_Pos) /*!< Bit mask of PROTREG37 field. */ -#define MPU_PROTENSET1_PROTREG37_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG37_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG37_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 4 : Protection enable for region 36. */ -#define MPU_PROTENSET1_PROTREG36_Pos (4UL) /*!< Position of PROTREG36 field. */ -#define MPU_PROTENSET1_PROTREG36_Msk (0x1UL << MPU_PROTENSET1_PROTREG36_Pos) /*!< Bit mask of PROTREG36 field. */ -#define MPU_PROTENSET1_PROTREG36_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG36_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG36_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 3 : Protection enable for region 35. */ -#define MPU_PROTENSET1_PROTREG35_Pos (3UL) /*!< Position of PROTREG35 field. */ -#define MPU_PROTENSET1_PROTREG35_Msk (0x1UL << MPU_PROTENSET1_PROTREG35_Pos) /*!< Bit mask of PROTREG35 field. */ -#define MPU_PROTENSET1_PROTREG35_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG35_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG35_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 2 : Protection enable for region 34. */ -#define MPU_PROTENSET1_PROTREG34_Pos (2UL) /*!< Position of PROTREG34 field. */ -#define MPU_PROTENSET1_PROTREG34_Msk (0x1UL << MPU_PROTENSET1_PROTREG34_Pos) /*!< Bit mask of PROTREG34 field. */ -#define MPU_PROTENSET1_PROTREG34_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG34_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG34_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 1 : Protection enable for region 33. */ -#define MPU_PROTENSET1_PROTREG33_Pos (1UL) /*!< Position of PROTREG33 field. */ -#define MPU_PROTENSET1_PROTREG33_Msk (0x1UL << MPU_PROTENSET1_PROTREG33_Pos) /*!< Bit mask of PROTREG33 field. */ -#define MPU_PROTENSET1_PROTREG33_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG33_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG33_Set (1UL) /*!< Enable protection on write. */ - -/* Bit 0 : Protection enable for region 32. */ -#define MPU_PROTENSET1_PROTREG32_Pos (0UL) /*!< Position of PROTREG32 field. */ -#define MPU_PROTENSET1_PROTREG32_Msk (0x1UL << MPU_PROTENSET1_PROTREG32_Pos) /*!< Bit mask of PROTREG32 field. */ -#define MPU_PROTENSET1_PROTREG32_Disabled (0UL) /*!< Protection disabled. */ -#define MPU_PROTENSET1_PROTREG32_Enabled (1UL) /*!< Protection enabled. */ -#define MPU_PROTENSET1_PROTREG32_Set (1UL) /*!< Enable protection on write. */ - -/* Register: MPU_DISABLEINDEBUG */ -/* Description: Disable erase and write protection mechanism in debug mode. */ - -/* Bit 0 : Disable protection mechanism in debug mode. */ -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos (0UL) /*!< Position of DISABLEINDEBUG field. */ -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Msk (0x1UL << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos) /*!< Bit mask of DISABLEINDEBUG field. */ -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Enabled (0UL) /*!< Protection enabled. */ -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled (1UL) /*!< Protection disabled. */ - -/* Register: MPU_PROTBLOCKSIZE */ -/* Description: Erase and write protection block size. */ - -/* Bits 1..0 : Erase and write protection block size. */ -#define MPU_PROTBLOCKSIZE_PROTBLOCKSIZE_Pos (0UL) /*!< Position of PROTBLOCKSIZE field. */ -#define MPU_PROTBLOCKSIZE_PROTBLOCKSIZE_Msk (0x3UL << MPU_PROTBLOCKSIZE_PROTBLOCKSIZE_Pos) /*!< Bit mask of PROTBLOCKSIZE field. */ -#define MPU_PROTBLOCKSIZE_PROTBLOCKSIZE_4k (0UL) /*!< Erase and write protection block size is 4k. */ - - -/* Peripheral: NVMC */ -/* Description: Non Volatile Memory Controller. */ - -/* Register: NVMC_READY */ -/* Description: Ready flag. */ - -/* Bit 0 : NVMC ready. */ -#define NVMC_READY_READY_Pos (0UL) /*!< Position of READY field. */ -#define NVMC_READY_READY_Msk (0x1UL << NVMC_READY_READY_Pos) /*!< Bit mask of READY field. */ -#define NVMC_READY_READY_Busy (0UL) /*!< NVMC is busy (on-going write or erase operation). */ -#define NVMC_READY_READY_Ready (1UL) /*!< NVMC is ready. */ - -/* Register: NVMC_CONFIG */ -/* Description: Configuration register. */ - -/* Bits 1..0 : Program write enable. */ -#define NVMC_CONFIG_WEN_Pos (0UL) /*!< Position of WEN field. */ -#define NVMC_CONFIG_WEN_Msk (0x3UL << NVMC_CONFIG_WEN_Pos) /*!< Bit mask of WEN field. */ -#define NVMC_CONFIG_WEN_Ren (0x00UL) /*!< Read only access. */ -#define NVMC_CONFIG_WEN_Wen (0x01UL) /*!< Write enabled. */ -#define NVMC_CONFIG_WEN_Een (0x02UL) /*!< Erase enabled. */ - -/* Register: NVMC_ERASEALL */ -/* Description: Register for erasing all non-volatile user memory. */ - -/* Bit 0 : Starts the erasing of all user NVM (code region 0/1 and UICR registers). */ -#define NVMC_ERASEALL_ERASEALL_Pos (0UL) /*!< Position of ERASEALL field. */ -#define NVMC_ERASEALL_ERASEALL_Msk (0x1UL << NVMC_ERASEALL_ERASEALL_Pos) /*!< Bit mask of ERASEALL field. */ -#define NVMC_ERASEALL_ERASEALL_NoOperation (0UL) /*!< No operation. */ -#define NVMC_ERASEALL_ERASEALL_Erase (1UL) /*!< Start chip erase. */ - -/* Register: NVMC_ERASEUICR */ -/* Description: Register for start erasing User Information Congfiguration Registers. */ - -/* Bit 0 : It can only be used when all contents of code region 1 are erased. */ -#define NVMC_ERASEUICR_ERASEUICR_Pos (0UL) /*!< Position of ERASEUICR field. */ -#define NVMC_ERASEUICR_ERASEUICR_Msk (0x1UL << NVMC_ERASEUICR_ERASEUICR_Pos) /*!< Bit mask of ERASEUICR field. */ -#define NVMC_ERASEUICR_ERASEUICR_NoOperation (0UL) /*!< No operation. */ -#define NVMC_ERASEUICR_ERASEUICR_Erase (1UL) /*!< Start UICR erase. */ - - -/* Peripheral: POWER */ -/* Description: Power Control. */ - -/* Register: POWER_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 2 : Enable interrupt on POFWARN event. */ -#define POWER_INTENSET_POFWARN_Pos (2UL) /*!< Position of POFWARN field. */ -#define POWER_INTENSET_POFWARN_Msk (0x1UL << POWER_INTENSET_POFWARN_Pos) /*!< Bit mask of POFWARN field. */ -#define POWER_INTENSET_POFWARN_Disabled (0UL) /*!< Interrupt disabled. */ -#define POWER_INTENSET_POFWARN_Enabled (1UL) /*!< Interrupt enabled. */ -#define POWER_INTENSET_POFWARN_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: POWER_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 2 : Disable interrupt on POFWARN event. */ -#define POWER_INTENCLR_POFWARN_Pos (2UL) /*!< Position of POFWARN field. */ -#define POWER_INTENCLR_POFWARN_Msk (0x1UL << POWER_INTENCLR_POFWARN_Pos) /*!< Bit mask of POFWARN field. */ -#define POWER_INTENCLR_POFWARN_Disabled (0UL) /*!< Interrupt disabled. */ -#define POWER_INTENCLR_POFWARN_Enabled (1UL) /*!< Interrupt enabled. */ -#define POWER_INTENCLR_POFWARN_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: POWER_RESETREAS */ -/* Description: Reset reason. */ - -/* Bit 18 : Reset from wake-up from OFF mode detected by entering into debug interface mode. */ -#define POWER_RESETREAS_DIF_Pos (18UL) /*!< Position of DIF field. */ -#define POWER_RESETREAS_DIF_Msk (0x1UL << POWER_RESETREAS_DIF_Pos) /*!< Bit mask of DIF field. */ -#define POWER_RESETREAS_DIF_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_DIF_Detected (1UL) /*!< Reset detected. */ - -/* Bit 17 : Reset from wake-up from OFF mode detected by the use of ANADETECT signal from LPCOMP. */ -#define POWER_RESETREAS_LPCOMP_Pos (17UL) /*!< Position of LPCOMP field. */ -#define POWER_RESETREAS_LPCOMP_Msk (0x1UL << POWER_RESETREAS_LPCOMP_Pos) /*!< Bit mask of LPCOMP field. */ -#define POWER_RESETREAS_LPCOMP_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_LPCOMP_Detected (1UL) /*!< Reset detected. */ - -/* Bit 16 : Reset from wake-up from OFF mode detected by the use of DETECT signal from GPIO. */ -#define POWER_RESETREAS_OFF_Pos (16UL) /*!< Position of OFF field. */ -#define POWER_RESETREAS_OFF_Msk (0x1UL << POWER_RESETREAS_OFF_Pos) /*!< Bit mask of OFF field. */ -#define POWER_RESETREAS_OFF_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_OFF_Detected (1UL) /*!< Reset detected. */ - -/* Bit 3 : Reset from CPU lock-up detected. */ -#define POWER_RESETREAS_LOCKUP_Pos (3UL) /*!< Position of LOCKUP field. */ -#define POWER_RESETREAS_LOCKUP_Msk (0x1UL << POWER_RESETREAS_LOCKUP_Pos) /*!< Bit mask of LOCKUP field. */ -#define POWER_RESETREAS_LOCKUP_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_LOCKUP_Detected (1UL) /*!< Reset detected. */ - -/* Bit 2 : Reset from AIRCR.SYSRESETREQ detected. */ -#define POWER_RESETREAS_SREQ_Pos (2UL) /*!< Position of SREQ field. */ -#define POWER_RESETREAS_SREQ_Msk (0x1UL << POWER_RESETREAS_SREQ_Pos) /*!< Bit mask of SREQ field. */ -#define POWER_RESETREAS_SREQ_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_SREQ_Detected (1UL) /*!< Reset detected. */ - -/* Bit 1 : Reset from watchdog detected. */ -#define POWER_RESETREAS_DOG_Pos (1UL) /*!< Position of DOG field. */ -#define POWER_RESETREAS_DOG_Msk (0x1UL << POWER_RESETREAS_DOG_Pos) /*!< Bit mask of DOG field. */ -#define POWER_RESETREAS_DOG_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_DOG_Detected (1UL) /*!< Reset detected. */ - -/* Bit 0 : Reset from pin-reset detected. */ -#define POWER_RESETREAS_RESETPIN_Pos (0UL) /*!< Position of RESETPIN field. */ -#define POWER_RESETREAS_RESETPIN_Msk (0x1UL << POWER_RESETREAS_RESETPIN_Pos) /*!< Bit mask of RESETPIN field. */ -#define POWER_RESETREAS_RESETPIN_NotDetected (0UL) /*!< Reset not detected. */ -#define POWER_RESETREAS_RESETPIN_Detected (1UL) /*!< Reset detected. */ - -/* Register: POWER_RAMSTATUS */ -/* Description: Ram status register. */ - -/* Bit 3 : RAM block 3 status. */ -#define POWER_RAMSTATUS_RAMBLOCK3_Pos (3UL) /*!< Position of RAMBLOCK3 field. */ -#define POWER_RAMSTATUS_RAMBLOCK3_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK3_Pos) /*!< Bit mask of RAMBLOCK3 field. */ -#define POWER_RAMSTATUS_RAMBLOCK3_Off (0UL) /*!< RAM block 3 is off or powering up. */ -#define POWER_RAMSTATUS_RAMBLOCK3_On (1UL) /*!< RAM block 3 is on. */ - -/* Bit 2 : RAM block 2 status. */ -#define POWER_RAMSTATUS_RAMBLOCK2_Pos (2UL) /*!< Position of RAMBLOCK2 field. */ -#define POWER_RAMSTATUS_RAMBLOCK2_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK2_Pos) /*!< Bit mask of RAMBLOCK2 field. */ -#define POWER_RAMSTATUS_RAMBLOCK2_Off (0UL) /*!< RAM block 2 is off or powering up. */ -#define POWER_RAMSTATUS_RAMBLOCK2_On (1UL) /*!< RAM block 2 is on. */ - -/* Bit 1 : RAM block 1 status. */ -#define POWER_RAMSTATUS_RAMBLOCK1_Pos (1UL) /*!< Position of RAMBLOCK1 field. */ -#define POWER_RAMSTATUS_RAMBLOCK1_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK1_Pos) /*!< Bit mask of RAMBLOCK1 field. */ -#define POWER_RAMSTATUS_RAMBLOCK1_Off (0UL) /*!< RAM block 1 is off or powering up. */ -#define POWER_RAMSTATUS_RAMBLOCK1_On (1UL) /*!< RAM block 1 is on. */ - -/* Bit 0 : RAM block 0 status. */ -#define POWER_RAMSTATUS_RAMBLOCK0_Pos (0UL) /*!< Position of RAMBLOCK0 field. */ -#define POWER_RAMSTATUS_RAMBLOCK0_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK0_Pos) /*!< Bit mask of RAMBLOCK0 field. */ -#define POWER_RAMSTATUS_RAMBLOCK0_Off (0UL) /*!< RAM block 0 is off or powering up. */ -#define POWER_RAMSTATUS_RAMBLOCK0_On (1UL) /*!< RAM block 0 is on. */ - -/* Register: POWER_SYSTEMOFF */ -/* Description: System off register. */ - -/* Bit 0 : Enter system off mode. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Pos (0UL) /*!< Position of SYSTEMOFF field. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Msk (0x1UL << POWER_SYSTEMOFF_SYSTEMOFF_Pos) /*!< Bit mask of SYSTEMOFF field. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Enter (1UL) /*!< Enter system off mode. */ - -/* Register: POWER_POFCON */ -/* Description: Power failure configuration. */ - -/* Bits 2..1 : Set threshold level. */ -#define POWER_POFCON_THRESHOLD_Pos (1UL) /*!< Position of THRESHOLD field. */ -#define POWER_POFCON_THRESHOLD_Msk (0x3UL << POWER_POFCON_THRESHOLD_Pos) /*!< Bit mask of THRESHOLD field. */ -#define POWER_POFCON_THRESHOLD_V21 (0x00UL) /*!< Set threshold to 2.1Volts. */ -#define POWER_POFCON_THRESHOLD_V23 (0x01UL) /*!< Set threshold to 2.3Volts. */ -#define POWER_POFCON_THRESHOLD_V25 (0x02UL) /*!< Set threshold to 2.5Volts. */ -#define POWER_POFCON_THRESHOLD_V27 (0x03UL) /*!< Set threshold to 2.7Volts. */ - -/* Bit 0 : Power failure comparator enable. */ -#define POWER_POFCON_POF_Pos (0UL) /*!< Position of POF field. */ -#define POWER_POFCON_POF_Msk (0x1UL << POWER_POFCON_POF_Pos) /*!< Bit mask of POF field. */ -#define POWER_POFCON_POF_Disabled (0UL) /*!< Disabled. */ -#define POWER_POFCON_POF_Enabled (1UL) /*!< Enabled. */ - -/* Register: POWER_GPREGRET */ -/* Description: General purpose retention register. This register is a retained register. */ - -/* Bits 7..0 : General purpose retention register. */ -#define POWER_GPREGRET_GPREGRET_Pos (0UL) /*!< Position of GPREGRET field. */ -#define POWER_GPREGRET_GPREGRET_Msk (0xFFUL << POWER_GPREGRET_GPREGRET_Pos) /*!< Bit mask of GPREGRET field. */ - -/* Register: POWER_RAMON */ -/* Description: Ram on/off. */ - -/* Bit 17 : RAM block 1 behaviour in OFF mode. */ -#define POWER_RAMON_OFFRAM1_Pos (17UL) /*!< Position of OFFRAM1 field. */ -#define POWER_RAMON_OFFRAM1_Msk (0x1UL << POWER_RAMON_OFFRAM1_Pos) /*!< Bit mask of OFFRAM1 field. */ -#define POWER_RAMON_OFFRAM1_RAM1Off (0UL) /*!< RAM block 1 OFF in OFF mode. */ -#define POWER_RAMON_OFFRAM1_RAM1On (1UL) /*!< RAM block 1 ON in OFF mode. */ - -/* Bit 16 : RAM block 0 behaviour in OFF mode. */ -#define POWER_RAMON_OFFRAM0_Pos (16UL) /*!< Position of OFFRAM0 field. */ -#define POWER_RAMON_OFFRAM0_Msk (0x1UL << POWER_RAMON_OFFRAM0_Pos) /*!< Bit mask of OFFRAM0 field. */ -#define POWER_RAMON_OFFRAM0_RAM0Off (0UL) /*!< RAM block 0 OFF in OFF mode. */ -#define POWER_RAMON_OFFRAM0_RAM0On (1UL) /*!< RAM block 0 ON in OFF mode. */ - -/* Bit 1 : RAM block 1 behaviour in ON mode. */ -#define POWER_RAMON_ONRAM1_Pos (1UL) /*!< Position of ONRAM1 field. */ -#define POWER_RAMON_ONRAM1_Msk (0x1UL << POWER_RAMON_ONRAM1_Pos) /*!< Bit mask of ONRAM1 field. */ -#define POWER_RAMON_ONRAM1_RAM1Off (0UL) /*!< RAM block 1 OFF in ON mode. */ -#define POWER_RAMON_ONRAM1_RAM1On (1UL) /*!< RAM block 1 ON in ON mode. */ - -/* Bit 0 : RAM block 0 behaviour in ON mode. */ -#define POWER_RAMON_ONRAM0_Pos (0UL) /*!< Position of ONRAM0 field. */ -#define POWER_RAMON_ONRAM0_Msk (0x1UL << POWER_RAMON_ONRAM0_Pos) /*!< Bit mask of ONRAM0 field. */ -#define POWER_RAMON_ONRAM0_RAM0Off (0UL) /*!< RAM block 0 OFF in ON mode. */ -#define POWER_RAMON_ONRAM0_RAM0On (1UL) /*!< RAM block 0 ON in ON mode. */ - -/* Register: POWER_RESET */ -/* Description: Pin reset functionality configuration register. This register is a retained register. */ - -/* Bit 0 : Enable or disable pin reset in debug interface mode. */ -#define POWER_RESET_RESET_Pos (0UL) /*!< Position of RESET field. */ -#define POWER_RESET_RESET_Msk (0x1UL << POWER_RESET_RESET_Pos) /*!< Bit mask of RESET field. */ -#define POWER_RESET_RESET_Disabled (0UL) /*!< Pin reset in debug interface mode disabled. */ -#define POWER_RESET_RESET_Enabled (1UL) /*!< Pin reset in debug interface mode enabled. */ - -/* Register: POWER_RAMONB */ -/* Description: Ram on/off. */ - -/* Bit 17 : RAM block 3 behaviour in OFF mode. */ -#define POWER_RAMONB_OFFRAM3_Pos (17UL) /*!< Position of OFFRAM3 field. */ -#define POWER_RAMONB_OFFRAM3_Msk (0x1UL << POWER_RAMONB_OFFRAM3_Pos) /*!< Bit mask of OFFRAM3 field. */ -#define POWER_RAMONB_OFFRAM3_RAM3Off (0UL) /*!< RAM block 3 OFF in OFF mode. */ -#define POWER_RAMONB_OFFRAM3_RAM3On (1UL) /*!< RAM block 3 ON in OFF mode. */ - -/* Bit 16 : RAM block 2 behaviour in OFF mode. */ -#define POWER_RAMONB_OFFRAM2_Pos (16UL) /*!< Position of OFFRAM2 field. */ -#define POWER_RAMONB_OFFRAM2_Msk (0x1UL << POWER_RAMONB_OFFRAM2_Pos) /*!< Bit mask of OFFRAM2 field. */ -#define POWER_RAMONB_OFFRAM2_RAM2Off (0UL) /*!< RAM block 2 OFF in OFF mode. */ -#define POWER_RAMONB_OFFRAM2_RAM2On (1UL) /*!< RAM block 2 ON in OFF mode. */ - -/* Bit 1 : RAM block 3 behaviour in ON mode. */ -#define POWER_RAMONB_ONRAM3_Pos (1UL) /*!< Position of ONRAM3 field. */ -#define POWER_RAMONB_ONRAM3_Msk (0x1UL << POWER_RAMONB_ONRAM3_Pos) /*!< Bit mask of ONRAM3 field. */ -#define POWER_RAMONB_ONRAM3_RAM3Off (0UL) /*!< RAM block 33 OFF in ON mode. */ -#define POWER_RAMONB_ONRAM3_RAM3On (1UL) /*!< RAM block 3 ON in ON mode. */ - -/* Bit 0 : RAM block 2 behaviour in ON mode. */ -#define POWER_RAMONB_ONRAM2_Pos (0UL) /*!< Position of ONRAM2 field. */ -#define POWER_RAMONB_ONRAM2_Msk (0x1UL << POWER_RAMONB_ONRAM2_Pos) /*!< Bit mask of ONRAM2 field. */ -#define POWER_RAMONB_ONRAM2_RAM2Off (0UL) /*!< RAM block 2 OFF in ON mode. */ -#define POWER_RAMONB_ONRAM2_RAM2On (1UL) /*!< RAM block 2 ON in ON mode. */ - -/* Register: POWER_DCDCEN */ -/* Description: DCDC converter enable configuration register. */ - -/* Bit 0 : Enable DCDC converter. */ -#define POWER_DCDCEN_DCDCEN_Pos (0UL) /*!< Position of DCDCEN field. */ -#define POWER_DCDCEN_DCDCEN_Msk (0x1UL << POWER_DCDCEN_DCDCEN_Pos) /*!< Bit mask of DCDCEN field. */ -#define POWER_DCDCEN_DCDCEN_Disabled (0UL) /*!< DCDC converter disabled. */ -#define POWER_DCDCEN_DCDCEN_Enabled (1UL) /*!< DCDC converter enabled. */ - -/* Register: POWER_DCDCFORCE */ -/* Description: DCDC power-up force register. */ - -/* Bit 1 : DCDC power-up force on. */ -#define POWER_DCDCFORCE_FORCEON_Pos (1UL) /*!< Position of FORCEON field. */ -#define POWER_DCDCFORCE_FORCEON_Msk (0x1UL << POWER_DCDCFORCE_FORCEON_Pos) /*!< Bit mask of FORCEON field. */ -#define POWER_DCDCFORCE_FORCEON_NoForce (0UL) /*!< No force. */ -#define POWER_DCDCFORCE_FORCEON_Force (1UL) /*!< Force. */ - -/* Bit 0 : DCDC power-up force off. */ -#define POWER_DCDCFORCE_FORCEOFF_Pos (0UL) /*!< Position of FORCEOFF field. */ -#define POWER_DCDCFORCE_FORCEOFF_Msk (0x1UL << POWER_DCDCFORCE_FORCEOFF_Pos) /*!< Bit mask of FORCEOFF field. */ -#define POWER_DCDCFORCE_FORCEOFF_NoForce (0UL) /*!< No force. */ -#define POWER_DCDCFORCE_FORCEOFF_Force (1UL) /*!< Force. */ - - -/* Peripheral: PPI */ -/* Description: PPI controller. */ - -/* Register: PPI_CHEN */ -/* Description: Channel enable. */ - -/* Bit 31 : Enable PPI channel 31. */ -#define PPI_CHEN_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHEN_CH31_Msk (0x1UL << PPI_CHEN_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHEN_CH31_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH31_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 30 : Enable PPI channel 30. */ -#define PPI_CHEN_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHEN_CH30_Msk (0x1UL << PPI_CHEN_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHEN_CH30_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH30_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 29 : Enable PPI channel 29. */ -#define PPI_CHEN_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHEN_CH29_Msk (0x1UL << PPI_CHEN_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHEN_CH29_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH29_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 28 : Enable PPI channel 28. */ -#define PPI_CHEN_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHEN_CH28_Msk (0x1UL << PPI_CHEN_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHEN_CH28_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH28_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 27 : Enable PPI channel 27. */ -#define PPI_CHEN_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHEN_CH27_Msk (0x1UL << PPI_CHEN_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHEN_CH27_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH27_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 26 : Enable PPI channel 26. */ -#define PPI_CHEN_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHEN_CH26_Msk (0x1UL << PPI_CHEN_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHEN_CH26_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH26_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 25 : Enable PPI channel 25. */ -#define PPI_CHEN_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHEN_CH25_Msk (0x1UL << PPI_CHEN_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHEN_CH25_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH25_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 24 : Enable PPI channel 24. */ -#define PPI_CHEN_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHEN_CH24_Msk (0x1UL << PPI_CHEN_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHEN_CH24_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH24_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 23 : Enable PPI channel 23. */ -#define PPI_CHEN_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHEN_CH23_Msk (0x1UL << PPI_CHEN_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHEN_CH23_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH23_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 22 : Enable PPI channel 22. */ -#define PPI_CHEN_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHEN_CH22_Msk (0x1UL << PPI_CHEN_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHEN_CH22_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH22_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 21 : Enable PPI channel 21. */ -#define PPI_CHEN_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHEN_CH21_Msk (0x1UL << PPI_CHEN_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHEN_CH21_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH21_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 20 : Enable PPI channel 20. */ -#define PPI_CHEN_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHEN_CH20_Msk (0x1UL << PPI_CHEN_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHEN_CH20_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH20_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 15 : Enable PPI channel 15. */ -#define PPI_CHEN_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHEN_CH15_Msk (0x1UL << PPI_CHEN_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHEN_CH15_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH15_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 14 : Enable PPI channel 14. */ -#define PPI_CHEN_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHEN_CH14_Msk (0x1UL << PPI_CHEN_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHEN_CH14_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH14_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 13 : Enable PPI channel 13. */ -#define PPI_CHEN_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHEN_CH13_Msk (0x1UL << PPI_CHEN_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHEN_CH13_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH13_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 12 : Enable PPI channel 12. */ -#define PPI_CHEN_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHEN_CH12_Msk (0x1UL << PPI_CHEN_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHEN_CH12_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH12_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 11 : Enable PPI channel 11. */ -#define PPI_CHEN_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHEN_CH11_Msk (0x1UL << PPI_CHEN_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHEN_CH11_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH11_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 10 : Enable PPI channel 10. */ -#define PPI_CHEN_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHEN_CH10_Msk (0x1UL << PPI_CHEN_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHEN_CH10_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH10_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 9 : Enable PPI channel 9. */ -#define PPI_CHEN_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHEN_CH9_Msk (0x1UL << PPI_CHEN_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHEN_CH9_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH9_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 8 : Enable PPI channel 8. */ -#define PPI_CHEN_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHEN_CH8_Msk (0x1UL << PPI_CHEN_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHEN_CH8_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH8_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 7 : Enable PPI channel 7. */ -#define PPI_CHEN_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHEN_CH7_Msk (0x1UL << PPI_CHEN_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHEN_CH7_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH7_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 6 : Enable PPI channel 6. */ -#define PPI_CHEN_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHEN_CH6_Msk (0x1UL << PPI_CHEN_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHEN_CH6_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH6_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 5 : Enable PPI channel 5. */ -#define PPI_CHEN_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHEN_CH5_Msk (0x1UL << PPI_CHEN_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHEN_CH5_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH5_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 4 : Enable PPI channel 4. */ -#define PPI_CHEN_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHEN_CH4_Msk (0x1UL << PPI_CHEN_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHEN_CH4_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH4_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 3 : Enable PPI channel 3. */ -#define PPI_CHEN_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHEN_CH3_Msk (0x1UL << PPI_CHEN_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHEN_CH3_Disabled (0UL) /*!< Channel disabled */ -#define PPI_CHEN_CH3_Enabled (1UL) /*!< Channel enabled */ - -/* Bit 2 : Enable PPI channel 2. */ -#define PPI_CHEN_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHEN_CH2_Msk (0x1UL << PPI_CHEN_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHEN_CH2_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH2_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 1 : Enable PPI channel 1. */ -#define PPI_CHEN_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHEN_CH1_Msk (0x1UL << PPI_CHEN_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHEN_CH1_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH1_Enabled (1UL) /*!< Channel enabled. */ - -/* Bit 0 : Enable PPI channel 0. */ -#define PPI_CHEN_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHEN_CH0_Msk (0x1UL << PPI_CHEN_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHEN_CH0_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHEN_CH0_Enabled (1UL) /*!< Channel enabled. */ - -/* Register: PPI_CHENSET */ -/* Description: Channel enable set. */ - -/* Bit 31 : Enable PPI channel 31. */ -#define PPI_CHENSET_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHENSET_CH31_Msk (0x1UL << PPI_CHENSET_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHENSET_CH31_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH31_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH31_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 30 : Enable PPI channel 30. */ -#define PPI_CHENSET_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHENSET_CH30_Msk (0x1UL << PPI_CHENSET_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHENSET_CH30_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH30_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH30_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 29 : Enable PPI channel 29. */ -#define PPI_CHENSET_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHENSET_CH29_Msk (0x1UL << PPI_CHENSET_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHENSET_CH29_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH29_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH29_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 28 : Enable PPI channel 28. */ -#define PPI_CHENSET_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHENSET_CH28_Msk (0x1UL << PPI_CHENSET_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHENSET_CH28_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH28_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH28_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 27 : Enable PPI channel 27. */ -#define PPI_CHENSET_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHENSET_CH27_Msk (0x1UL << PPI_CHENSET_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHENSET_CH27_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH27_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH27_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 26 : Enable PPI channel 26. */ -#define PPI_CHENSET_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHENSET_CH26_Msk (0x1UL << PPI_CHENSET_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHENSET_CH26_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH26_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH26_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 25 : Enable PPI channel 25. */ -#define PPI_CHENSET_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHENSET_CH25_Msk (0x1UL << PPI_CHENSET_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHENSET_CH25_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH25_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH25_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 24 : Enable PPI channel 24. */ -#define PPI_CHENSET_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHENSET_CH24_Msk (0x1UL << PPI_CHENSET_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHENSET_CH24_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH24_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH24_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 23 : Enable PPI channel 23. */ -#define PPI_CHENSET_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHENSET_CH23_Msk (0x1UL << PPI_CHENSET_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHENSET_CH23_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH23_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH23_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 22 : Enable PPI channel 22. */ -#define PPI_CHENSET_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHENSET_CH22_Msk (0x1UL << PPI_CHENSET_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHENSET_CH22_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH22_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH22_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 21 : Enable PPI channel 21. */ -#define PPI_CHENSET_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHENSET_CH21_Msk (0x1UL << PPI_CHENSET_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHENSET_CH21_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH21_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH21_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 20 : Enable PPI channel 20. */ -#define PPI_CHENSET_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHENSET_CH20_Msk (0x1UL << PPI_CHENSET_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHENSET_CH20_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH20_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH20_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 15 : Enable PPI channel 15. */ -#define PPI_CHENSET_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHENSET_CH15_Msk (0x1UL << PPI_CHENSET_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHENSET_CH15_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH15_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH15_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 14 : Enable PPI channel 14. */ -#define PPI_CHENSET_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHENSET_CH14_Msk (0x1UL << PPI_CHENSET_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHENSET_CH14_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH14_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH14_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 13 : Enable PPI channel 13. */ -#define PPI_CHENSET_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHENSET_CH13_Msk (0x1UL << PPI_CHENSET_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHENSET_CH13_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH13_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH13_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 12 : Enable PPI channel 12. */ -#define PPI_CHENSET_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHENSET_CH12_Msk (0x1UL << PPI_CHENSET_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHENSET_CH12_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH12_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH12_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 11 : Enable PPI channel 11. */ -#define PPI_CHENSET_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHENSET_CH11_Msk (0x1UL << PPI_CHENSET_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHENSET_CH11_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH11_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH11_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 10 : Enable PPI channel 10. */ -#define PPI_CHENSET_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHENSET_CH10_Msk (0x1UL << PPI_CHENSET_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHENSET_CH10_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH10_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH10_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 9 : Enable PPI channel 9. */ -#define PPI_CHENSET_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHENSET_CH9_Msk (0x1UL << PPI_CHENSET_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHENSET_CH9_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH9_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH9_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 8 : Enable PPI channel 8. */ -#define PPI_CHENSET_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHENSET_CH8_Msk (0x1UL << PPI_CHENSET_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHENSET_CH8_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH8_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH8_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 7 : Enable PPI channel 7. */ -#define PPI_CHENSET_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHENSET_CH7_Msk (0x1UL << PPI_CHENSET_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHENSET_CH7_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH7_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH7_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 6 : Enable PPI channel 6. */ -#define PPI_CHENSET_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHENSET_CH6_Msk (0x1UL << PPI_CHENSET_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHENSET_CH6_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH6_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH6_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 5 : Enable PPI channel 5. */ -#define PPI_CHENSET_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHENSET_CH5_Msk (0x1UL << PPI_CHENSET_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHENSET_CH5_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH5_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH5_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 4 : Enable PPI channel 4. */ -#define PPI_CHENSET_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHENSET_CH4_Msk (0x1UL << PPI_CHENSET_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHENSET_CH4_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH4_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH4_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 3 : Enable PPI channel 3. */ -#define PPI_CHENSET_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHENSET_CH3_Msk (0x1UL << PPI_CHENSET_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHENSET_CH3_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH3_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH3_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 2 : Enable PPI channel 2. */ -#define PPI_CHENSET_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHENSET_CH2_Msk (0x1UL << PPI_CHENSET_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHENSET_CH2_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH2_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH2_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 1 : Enable PPI channel 1. */ -#define PPI_CHENSET_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHENSET_CH1_Msk (0x1UL << PPI_CHENSET_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHENSET_CH1_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH1_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH1_Set (1UL) /*!< Enable channel on write. */ - -/* Bit 0 : Enable PPI channel 0. */ -#define PPI_CHENSET_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHENSET_CH0_Msk (0x1UL << PPI_CHENSET_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHENSET_CH0_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENSET_CH0_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENSET_CH0_Set (1UL) /*!< Enable channel on write. */ - -/* Register: PPI_CHENCLR */ -/* Description: Channel enable clear. */ - -/* Bit 31 : Disable PPI channel 31. */ -#define PPI_CHENCLR_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHENCLR_CH31_Msk (0x1UL << PPI_CHENCLR_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHENCLR_CH31_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH31_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH31_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 30 : Disable PPI channel 30. */ -#define PPI_CHENCLR_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHENCLR_CH30_Msk (0x1UL << PPI_CHENCLR_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHENCLR_CH30_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH30_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH30_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 29 : Disable PPI channel 29. */ -#define PPI_CHENCLR_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHENCLR_CH29_Msk (0x1UL << PPI_CHENCLR_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHENCLR_CH29_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH29_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH29_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 28 : Disable PPI channel 28. */ -#define PPI_CHENCLR_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHENCLR_CH28_Msk (0x1UL << PPI_CHENCLR_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHENCLR_CH28_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH28_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH28_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 27 : Disable PPI channel 27. */ -#define PPI_CHENCLR_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHENCLR_CH27_Msk (0x1UL << PPI_CHENCLR_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHENCLR_CH27_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH27_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH27_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 26 : Disable PPI channel 26. */ -#define PPI_CHENCLR_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHENCLR_CH26_Msk (0x1UL << PPI_CHENCLR_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHENCLR_CH26_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH26_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH26_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 25 : Disable PPI channel 25. */ -#define PPI_CHENCLR_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHENCLR_CH25_Msk (0x1UL << PPI_CHENCLR_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHENCLR_CH25_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH25_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH25_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 24 : Disable PPI channel 24. */ -#define PPI_CHENCLR_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHENCLR_CH24_Msk (0x1UL << PPI_CHENCLR_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHENCLR_CH24_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH24_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH24_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 23 : Disable PPI channel 23. */ -#define PPI_CHENCLR_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHENCLR_CH23_Msk (0x1UL << PPI_CHENCLR_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHENCLR_CH23_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH23_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH23_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 22 : Disable PPI channel 22. */ -#define PPI_CHENCLR_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHENCLR_CH22_Msk (0x1UL << PPI_CHENCLR_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHENCLR_CH22_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH22_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH22_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 21 : Disable PPI channel 21. */ -#define PPI_CHENCLR_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHENCLR_CH21_Msk (0x1UL << PPI_CHENCLR_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHENCLR_CH21_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH21_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH21_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 20 : Disable PPI channel 20. */ -#define PPI_CHENCLR_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHENCLR_CH20_Msk (0x1UL << PPI_CHENCLR_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHENCLR_CH20_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH20_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH20_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 15 : Disable PPI channel 15. */ -#define PPI_CHENCLR_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHENCLR_CH15_Msk (0x1UL << PPI_CHENCLR_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHENCLR_CH15_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH15_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH15_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 14 : Disable PPI channel 14. */ -#define PPI_CHENCLR_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHENCLR_CH14_Msk (0x1UL << PPI_CHENCLR_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHENCLR_CH14_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH14_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH14_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 13 : Disable PPI channel 13. */ -#define PPI_CHENCLR_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHENCLR_CH13_Msk (0x1UL << PPI_CHENCLR_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHENCLR_CH13_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH13_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH13_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 12 : Disable PPI channel 12. */ -#define PPI_CHENCLR_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHENCLR_CH12_Msk (0x1UL << PPI_CHENCLR_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHENCLR_CH12_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH12_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH12_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 11 : Disable PPI channel 11. */ -#define PPI_CHENCLR_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHENCLR_CH11_Msk (0x1UL << PPI_CHENCLR_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHENCLR_CH11_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH11_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH11_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 10 : Disable PPI channel 10. */ -#define PPI_CHENCLR_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHENCLR_CH10_Msk (0x1UL << PPI_CHENCLR_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHENCLR_CH10_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH10_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH10_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 9 : Disable PPI channel 9. */ -#define PPI_CHENCLR_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHENCLR_CH9_Msk (0x1UL << PPI_CHENCLR_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHENCLR_CH9_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH9_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH9_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 8 : Disable PPI channel 8. */ -#define PPI_CHENCLR_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHENCLR_CH8_Msk (0x1UL << PPI_CHENCLR_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHENCLR_CH8_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH8_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH8_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 7 : Disable PPI channel 7. */ -#define PPI_CHENCLR_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHENCLR_CH7_Msk (0x1UL << PPI_CHENCLR_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHENCLR_CH7_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH7_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH7_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 6 : Disable PPI channel 6. */ -#define PPI_CHENCLR_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHENCLR_CH6_Msk (0x1UL << PPI_CHENCLR_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHENCLR_CH6_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH6_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH6_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 5 : Disable PPI channel 5. */ -#define PPI_CHENCLR_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHENCLR_CH5_Msk (0x1UL << PPI_CHENCLR_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHENCLR_CH5_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH5_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH5_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 4 : Disable PPI channel 4. */ -#define PPI_CHENCLR_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHENCLR_CH4_Msk (0x1UL << PPI_CHENCLR_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHENCLR_CH4_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH4_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH4_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 3 : Disable PPI channel 3. */ -#define PPI_CHENCLR_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHENCLR_CH3_Msk (0x1UL << PPI_CHENCLR_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHENCLR_CH3_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH3_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH3_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 2 : Disable PPI channel 2. */ -#define PPI_CHENCLR_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHENCLR_CH2_Msk (0x1UL << PPI_CHENCLR_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHENCLR_CH2_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH2_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH2_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 1 : Disable PPI channel 1. */ -#define PPI_CHENCLR_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHENCLR_CH1_Msk (0x1UL << PPI_CHENCLR_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHENCLR_CH1_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH1_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH1_Clear (1UL) /*!< Disable channel on write. */ - -/* Bit 0 : Disable PPI channel 0. */ -#define PPI_CHENCLR_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHENCLR_CH0_Msk (0x1UL << PPI_CHENCLR_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHENCLR_CH0_Disabled (0UL) /*!< Channel disabled. */ -#define PPI_CHENCLR_CH0_Enabled (1UL) /*!< Channel enabled. */ -#define PPI_CHENCLR_CH0_Clear (1UL) /*!< Disable channel on write. */ - -/* Register: PPI_CHG */ -/* Description: Channel group configuration. */ - -/* Bit 31 : Include CH31 in channel group. */ -#define PPI_CHG_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHG_CH31_Msk (0x1UL << PPI_CHG_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHG_CH31_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH31_Included (1UL) /*!< Channel included. */ - -/* Bit 30 : Include CH30 in channel group. */ -#define PPI_CHG_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHG_CH30_Msk (0x1UL << PPI_CHG_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHG_CH30_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH30_Included (1UL) /*!< Channel included. */ - -/* Bit 29 : Include CH29 in channel group. */ -#define PPI_CHG_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHG_CH29_Msk (0x1UL << PPI_CHG_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHG_CH29_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH29_Included (1UL) /*!< Channel included. */ - -/* Bit 28 : Include CH28 in channel group. */ -#define PPI_CHG_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHG_CH28_Msk (0x1UL << PPI_CHG_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHG_CH28_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH28_Included (1UL) /*!< Channel included. */ - -/* Bit 27 : Include CH27 in channel group. */ -#define PPI_CHG_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHG_CH27_Msk (0x1UL << PPI_CHG_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHG_CH27_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH27_Included (1UL) /*!< Channel included. */ - -/* Bit 26 : Include CH26 in channel group. */ -#define PPI_CHG_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHG_CH26_Msk (0x1UL << PPI_CHG_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHG_CH26_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH26_Included (1UL) /*!< Channel included. */ - -/* Bit 25 : Include CH25 in channel group. */ -#define PPI_CHG_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHG_CH25_Msk (0x1UL << PPI_CHG_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHG_CH25_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH25_Included (1UL) /*!< Channel included. */ - -/* Bit 24 : Include CH24 in channel group. */ -#define PPI_CHG_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHG_CH24_Msk (0x1UL << PPI_CHG_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHG_CH24_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH24_Included (1UL) /*!< Channel included. */ - -/* Bit 23 : Include CH23 in channel group. */ -#define PPI_CHG_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHG_CH23_Msk (0x1UL << PPI_CHG_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHG_CH23_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH23_Included (1UL) /*!< Channel included. */ - -/* Bit 22 : Include CH22 in channel group. */ -#define PPI_CHG_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHG_CH22_Msk (0x1UL << PPI_CHG_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHG_CH22_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH22_Included (1UL) /*!< Channel included. */ - -/* Bit 21 : Include CH21 in channel group. */ -#define PPI_CHG_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHG_CH21_Msk (0x1UL << PPI_CHG_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHG_CH21_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH21_Included (1UL) /*!< Channel included. */ - -/* Bit 20 : Include CH20 in channel group. */ -#define PPI_CHG_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHG_CH20_Msk (0x1UL << PPI_CHG_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHG_CH20_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH20_Included (1UL) /*!< Channel included. */ - -/* Bit 15 : Include CH15 in channel group. */ -#define PPI_CHG_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHG_CH15_Msk (0x1UL << PPI_CHG_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHG_CH15_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH15_Included (1UL) /*!< Channel included. */ - -/* Bit 14 : Include CH14 in channel group. */ -#define PPI_CHG_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHG_CH14_Msk (0x1UL << PPI_CHG_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHG_CH14_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH14_Included (1UL) /*!< Channel included. */ - -/* Bit 13 : Include CH13 in channel group. */ -#define PPI_CHG_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHG_CH13_Msk (0x1UL << PPI_CHG_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHG_CH13_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH13_Included (1UL) /*!< Channel included. */ - -/* Bit 12 : Include CH12 in channel group. */ -#define PPI_CHG_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHG_CH12_Msk (0x1UL << PPI_CHG_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHG_CH12_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH12_Included (1UL) /*!< Channel included. */ - -/* Bit 11 : Include CH11 in channel group. */ -#define PPI_CHG_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHG_CH11_Msk (0x1UL << PPI_CHG_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHG_CH11_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH11_Included (1UL) /*!< Channel included. */ - -/* Bit 10 : Include CH10 in channel group. */ -#define PPI_CHG_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHG_CH10_Msk (0x1UL << PPI_CHG_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHG_CH10_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH10_Included (1UL) /*!< Channel included. */ - -/* Bit 9 : Include CH9 in channel group. */ -#define PPI_CHG_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHG_CH9_Msk (0x1UL << PPI_CHG_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHG_CH9_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH9_Included (1UL) /*!< Channel included. */ - -/* Bit 8 : Include CH8 in channel group. */ -#define PPI_CHG_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHG_CH8_Msk (0x1UL << PPI_CHG_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHG_CH8_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH8_Included (1UL) /*!< Channel included. */ - -/* Bit 7 : Include CH7 in channel group. */ -#define PPI_CHG_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHG_CH7_Msk (0x1UL << PPI_CHG_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHG_CH7_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH7_Included (1UL) /*!< Channel included. */ - -/* Bit 6 : Include CH6 in channel group. */ -#define PPI_CHG_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHG_CH6_Msk (0x1UL << PPI_CHG_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHG_CH6_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH6_Included (1UL) /*!< Channel included. */ - -/* Bit 5 : Include CH5 in channel group. */ -#define PPI_CHG_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHG_CH5_Msk (0x1UL << PPI_CHG_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHG_CH5_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH5_Included (1UL) /*!< Channel included. */ - -/* Bit 4 : Include CH4 in channel group. */ -#define PPI_CHG_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHG_CH4_Msk (0x1UL << PPI_CHG_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHG_CH4_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH4_Included (1UL) /*!< Channel included. */ - -/* Bit 3 : Include CH3 in channel group. */ -#define PPI_CHG_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHG_CH3_Msk (0x1UL << PPI_CHG_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHG_CH3_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH3_Included (1UL) /*!< Channel included. */ - -/* Bit 2 : Include CH2 in channel group. */ -#define PPI_CHG_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHG_CH2_Msk (0x1UL << PPI_CHG_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHG_CH2_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH2_Included (1UL) /*!< Channel included. */ - -/* Bit 1 : Include CH1 in channel group. */ -#define PPI_CHG_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHG_CH1_Msk (0x1UL << PPI_CHG_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHG_CH1_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH1_Included (1UL) /*!< Channel included. */ - -/* Bit 0 : Include CH0 in channel group. */ -#define PPI_CHG_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHG_CH0_Msk (0x1UL << PPI_CHG_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHG_CH0_Excluded (0UL) /*!< Channel excluded. */ -#define PPI_CHG_CH0_Included (1UL) /*!< Channel included. */ - - -/* Peripheral: QDEC */ -/* Description: Rotary decoder. */ - -/* Register: QDEC_SHORTS */ -/* Description: Shortcuts for the QDEC. */ - -/* Bit 1 : Shortcut between SAMPLERDY event and STOP task. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Pos (1UL) /*!< Position of SAMPLERDY_STOP field. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Msk (0x1UL << QDEC_SHORTS_SAMPLERDY_STOP_Pos) /*!< Bit mask of SAMPLERDY_STOP field. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 0 : Shortcut between REPORTRDY event and READCLRACC task. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Pos (0UL) /*!< Position of REPORTRDY_READCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_READCLRACC_Pos) /*!< Bit mask of REPORTRDY_READCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Disabled (0UL) /*!< Shortcut disabled. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: QDEC_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 2 : Enable interrupt on ACCOF event. */ -#define QDEC_INTENSET_ACCOF_Pos (2UL) /*!< Position of ACCOF field. */ -#define QDEC_INTENSET_ACCOF_Msk (0x1UL << QDEC_INTENSET_ACCOF_Pos) /*!< Bit mask of ACCOF field. */ -#define QDEC_INTENSET_ACCOF_Disabled (0UL) /*!< Interrupt disabled. */ -#define QDEC_INTENSET_ACCOF_Enabled (1UL) /*!< Interrupt enabled. */ -#define QDEC_INTENSET_ACCOF_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on REPORTRDY event. */ -#define QDEC_INTENSET_REPORTRDY_Pos (1UL) /*!< Position of REPORTRDY field. */ -#define QDEC_INTENSET_REPORTRDY_Msk (0x1UL << QDEC_INTENSET_REPORTRDY_Pos) /*!< Bit mask of REPORTRDY field. */ -#define QDEC_INTENSET_REPORTRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define QDEC_INTENSET_REPORTRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define QDEC_INTENSET_REPORTRDY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on SAMPLERDY event. */ -#define QDEC_INTENSET_SAMPLERDY_Pos (0UL) /*!< Position of SAMPLERDY field. */ -#define QDEC_INTENSET_SAMPLERDY_Msk (0x1UL << QDEC_INTENSET_SAMPLERDY_Pos) /*!< Bit mask of SAMPLERDY field. */ -#define QDEC_INTENSET_SAMPLERDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define QDEC_INTENSET_SAMPLERDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define QDEC_INTENSET_SAMPLERDY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: QDEC_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 2 : Disable interrupt on ACCOF event. */ -#define QDEC_INTENCLR_ACCOF_Pos (2UL) /*!< Position of ACCOF field. */ -#define QDEC_INTENCLR_ACCOF_Msk (0x1UL << QDEC_INTENCLR_ACCOF_Pos) /*!< Bit mask of ACCOF field. */ -#define QDEC_INTENCLR_ACCOF_Disabled (0UL) /*!< Interrupt disabled. */ -#define QDEC_INTENCLR_ACCOF_Enabled (1UL) /*!< Interrupt enabled. */ -#define QDEC_INTENCLR_ACCOF_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on REPORTRDY event. */ -#define QDEC_INTENCLR_REPORTRDY_Pos (1UL) /*!< Position of REPORTRDY field. */ -#define QDEC_INTENCLR_REPORTRDY_Msk (0x1UL << QDEC_INTENCLR_REPORTRDY_Pos) /*!< Bit mask of REPORTRDY field. */ -#define QDEC_INTENCLR_REPORTRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define QDEC_INTENCLR_REPORTRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define QDEC_INTENCLR_REPORTRDY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on SAMPLERDY event. */ -#define QDEC_INTENCLR_SAMPLERDY_Pos (0UL) /*!< Position of SAMPLERDY field. */ -#define QDEC_INTENCLR_SAMPLERDY_Msk (0x1UL << QDEC_INTENCLR_SAMPLERDY_Pos) /*!< Bit mask of SAMPLERDY field. */ -#define QDEC_INTENCLR_SAMPLERDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define QDEC_INTENCLR_SAMPLERDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define QDEC_INTENCLR_SAMPLERDY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: QDEC_ENABLE */ -/* Description: Enable the QDEC. */ - -/* Bit 0 : Enable or disable QDEC. */ -#define QDEC_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define QDEC_ENABLE_ENABLE_Msk (0x1UL << QDEC_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define QDEC_ENABLE_ENABLE_Disabled (0UL) /*!< Disabled QDEC. */ -#define QDEC_ENABLE_ENABLE_Enabled (1UL) /*!< Enable QDEC. */ - -/* Register: QDEC_LEDPOL */ -/* Description: LED output pin polarity. */ - -/* Bit 0 : LED output pin polarity. */ -#define QDEC_LEDPOL_LEDPOL_Pos (0UL) /*!< Position of LEDPOL field. */ -#define QDEC_LEDPOL_LEDPOL_Msk (0x1UL << QDEC_LEDPOL_LEDPOL_Pos) /*!< Bit mask of LEDPOL field. */ -#define QDEC_LEDPOL_LEDPOL_ActiveLow (0UL) /*!< LED output is active low. */ -#define QDEC_LEDPOL_LEDPOL_ActiveHigh (1UL) /*!< LED output is active high. */ - -/* Register: QDEC_SAMPLEPER */ -/* Description: Sample period. */ - -/* Bits 2..0 : Sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_Pos (0UL) /*!< Position of SAMPLEPER field. */ -#define QDEC_SAMPLEPER_SAMPLEPER_Msk (0x7UL << QDEC_SAMPLEPER_SAMPLEPER_Pos) /*!< Bit mask of SAMPLEPER field. */ -#define QDEC_SAMPLEPER_SAMPLEPER_128us (0x00UL) /*!< 128us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_256us (0x01UL) /*!< 256us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_512us (0x02UL) /*!< 512us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_1024us (0x03UL) /*!< 1024us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_2048us (0x04UL) /*!< 2048us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_4096us (0x05UL) /*!< 4096us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_8192us (0x06UL) /*!< 8192us sample period. */ -#define QDEC_SAMPLEPER_SAMPLEPER_16384us (0x07UL) /*!< 16384us sample period. */ - -/* Register: QDEC_SAMPLE */ -/* Description: Motion sample value. */ - -/* Bits 31..0 : Last sample taken in compliment to 2. */ -#define QDEC_SAMPLE_SAMPLE_Pos (0UL) /*!< Position of SAMPLE field. */ -#define QDEC_SAMPLE_SAMPLE_Msk (0xFFFFFFFFUL << QDEC_SAMPLE_SAMPLE_Pos) /*!< Bit mask of SAMPLE field. */ - -/* Register: QDEC_REPORTPER */ -/* Description: Number of samples to generate an EVENT_REPORTRDY. */ - -/* Bits 2..0 : Number of samples to generate an EVENT_REPORTRDY. */ -#define QDEC_REPORTPER_REPORTPER_Pos (0UL) /*!< Position of REPORTPER field. */ -#define QDEC_REPORTPER_REPORTPER_Msk (0x7UL << QDEC_REPORTPER_REPORTPER_Pos) /*!< Bit mask of REPORTPER field. */ -#define QDEC_REPORTPER_REPORTPER_10Smpl (0x00UL) /*!< 10 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_40Smpl (0x01UL) /*!< 40 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_80Smpl (0x02UL) /*!< 80 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_120Smpl (0x03UL) /*!< 120 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_160Smpl (0x04UL) /*!< 160 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_200Smpl (0x05UL) /*!< 200 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_240Smpl (0x06UL) /*!< 240 samples per report. */ -#define QDEC_REPORTPER_REPORTPER_280Smpl (0x07UL) /*!< 280 samples per report. */ - -/* Register: QDEC_DBFEN */ -/* Description: Enable debouncer input filters. */ - -/* Bit 0 : Enable debounce input filters. */ -#define QDEC_DBFEN_DBFEN_Pos (0UL) /*!< Position of DBFEN field. */ -#define QDEC_DBFEN_DBFEN_Msk (0x1UL << QDEC_DBFEN_DBFEN_Pos) /*!< Bit mask of DBFEN field. */ -#define QDEC_DBFEN_DBFEN_Disabled (0UL) /*!< Debounce input filters disabled. */ -#define QDEC_DBFEN_DBFEN_Enabled (1UL) /*!< Debounce input filters enabled. */ - -/* Register: QDEC_LEDPRE */ -/* Description: Time LED is switched ON before the sample. */ - -/* Bits 8..0 : Period in us the LED in switched on prior to sampling. */ -#define QDEC_LEDPRE_LEDPRE_Pos (0UL) /*!< Position of LEDPRE field. */ -#define QDEC_LEDPRE_LEDPRE_Msk (0x1FFUL << QDEC_LEDPRE_LEDPRE_Pos) /*!< Bit mask of LEDPRE field. */ - -/* Register: QDEC_ACCDBL */ -/* Description: Accumulated double (error) transitions register. */ - -/* Bits 3..0 : Accumulated double (error) transitions. */ -#define QDEC_ACCDBL_ACCDBL_Pos (0UL) /*!< Position of ACCDBL field. */ -#define QDEC_ACCDBL_ACCDBL_Msk (0xFUL << QDEC_ACCDBL_ACCDBL_Pos) /*!< Bit mask of ACCDBL field. */ - -/* Register: QDEC_ACCDBLREAD */ -/* Description: Snapshot of ACCDBL register. Value generated by the TASKS_READCLEACC task. */ - -/* Bits 3..0 : Snapshot of accumulated double (error) transitions. */ -#define QDEC_ACCDBLREAD_ACCDBLREAD_Pos (0UL) /*!< Position of ACCDBLREAD field. */ -#define QDEC_ACCDBLREAD_ACCDBLREAD_Msk (0xFUL << QDEC_ACCDBLREAD_ACCDBLREAD_Pos) /*!< Bit mask of ACCDBLREAD field. */ - -/* Register: QDEC_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define QDEC_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define QDEC_POWER_POWER_Msk (0x1UL << QDEC_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define QDEC_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define QDEC_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: RADIO */ -/* Description: The radio. */ - -/* Register: RADIO_SHORTS */ -/* Description: Shortcuts for the radio. */ - -/* Bit 8 : Shortcut between DISABLED event and RSSISTOP task. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Pos (8UL) /*!< Position of DISABLED_RSSISTOP field. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Msk (0x1UL << RADIO_SHORTS_DISABLED_RSSISTOP_Pos) /*!< Bit mask of DISABLED_RSSISTOP field. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 6 : Shortcut between ADDRESS event and BCSTART task. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Pos (6UL) /*!< Position of ADDRESS_BCSTART field. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Msk (0x1UL << RADIO_SHORTS_ADDRESS_BCSTART_Pos) /*!< Bit mask of ADDRESS_BCSTART field. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 5 : Shortcut between END event and START task. */ -#define RADIO_SHORTS_END_START_Pos (5UL) /*!< Position of END_START field. */ -#define RADIO_SHORTS_END_START_Msk (0x1UL << RADIO_SHORTS_END_START_Pos) /*!< Bit mask of END_START field. */ -#define RADIO_SHORTS_END_START_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_END_START_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 4 : Shortcut between ADDRESS event and RSSISTART task. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Pos (4UL) /*!< Position of ADDRESS_RSSISTART field. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Msk (0x1UL << RADIO_SHORTS_ADDRESS_RSSISTART_Pos) /*!< Bit mask of ADDRESS_RSSISTART field. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 3 : Shortcut between DISABLED event and RXEN task. */ -#define RADIO_SHORTS_DISABLED_RXEN_Pos (3UL) /*!< Position of DISABLED_RXEN field. */ -#define RADIO_SHORTS_DISABLED_RXEN_Msk (0x1UL << RADIO_SHORTS_DISABLED_RXEN_Pos) /*!< Bit mask of DISABLED_RXEN field. */ -#define RADIO_SHORTS_DISABLED_RXEN_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_DISABLED_RXEN_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 2 : Shortcut between DISABLED event and TXEN task. */ -#define RADIO_SHORTS_DISABLED_TXEN_Pos (2UL) /*!< Position of DISABLED_TXEN field. */ -#define RADIO_SHORTS_DISABLED_TXEN_Msk (0x1UL << RADIO_SHORTS_DISABLED_TXEN_Pos) /*!< Bit mask of DISABLED_TXEN field. */ -#define RADIO_SHORTS_DISABLED_TXEN_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_DISABLED_TXEN_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 1 : Shortcut between END event and DISABLE task. */ -#define RADIO_SHORTS_END_DISABLE_Pos (1UL) /*!< Position of END_DISABLE field. */ -#define RADIO_SHORTS_END_DISABLE_Msk (0x1UL << RADIO_SHORTS_END_DISABLE_Pos) /*!< Bit mask of END_DISABLE field. */ -#define RADIO_SHORTS_END_DISABLE_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_END_DISABLE_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 0 : Shortcut between READY event and START task. */ -#define RADIO_SHORTS_READY_START_Pos (0UL) /*!< Position of READY_START field. */ -#define RADIO_SHORTS_READY_START_Msk (0x1UL << RADIO_SHORTS_READY_START_Pos) /*!< Bit mask of READY_START field. */ -#define RADIO_SHORTS_READY_START_Disabled (0UL) /*!< Shortcut disabled. */ -#define RADIO_SHORTS_READY_START_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: RADIO_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 10 : Enable interrupt on BCMATCH event. */ -#define RADIO_INTENSET_BCMATCH_Pos (10UL) /*!< Position of BCMATCH field. */ -#define RADIO_INTENSET_BCMATCH_Msk (0x1UL << RADIO_INTENSET_BCMATCH_Pos) /*!< Bit mask of BCMATCH field. */ -#define RADIO_INTENSET_BCMATCH_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_BCMATCH_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_BCMATCH_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 7 : Enable interrupt on RSSIEND event. */ -#define RADIO_INTENSET_RSSIEND_Pos (7UL) /*!< Position of RSSIEND field. */ -#define RADIO_INTENSET_RSSIEND_Msk (0x1UL << RADIO_INTENSET_RSSIEND_Pos) /*!< Bit mask of RSSIEND field. */ -#define RADIO_INTENSET_RSSIEND_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_RSSIEND_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_RSSIEND_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 6 : Enable interrupt on DEVMISS event. */ -#define RADIO_INTENSET_DEVMISS_Pos (6UL) /*!< Position of DEVMISS field. */ -#define RADIO_INTENSET_DEVMISS_Msk (0x1UL << RADIO_INTENSET_DEVMISS_Pos) /*!< Bit mask of DEVMISS field. */ -#define RADIO_INTENSET_DEVMISS_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_DEVMISS_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_DEVMISS_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 5 : Enable interrupt on DEVMATCH event. */ -#define RADIO_INTENSET_DEVMATCH_Pos (5UL) /*!< Position of DEVMATCH field. */ -#define RADIO_INTENSET_DEVMATCH_Msk (0x1UL << RADIO_INTENSET_DEVMATCH_Pos) /*!< Bit mask of DEVMATCH field. */ -#define RADIO_INTENSET_DEVMATCH_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_DEVMATCH_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_DEVMATCH_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 4 : Enable interrupt on DISABLED event. */ -#define RADIO_INTENSET_DISABLED_Pos (4UL) /*!< Position of DISABLED field. */ -#define RADIO_INTENSET_DISABLED_Msk (0x1UL << RADIO_INTENSET_DISABLED_Pos) /*!< Bit mask of DISABLED field. */ -#define RADIO_INTENSET_DISABLED_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_DISABLED_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_DISABLED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 3 : Enable interrupt on END event. */ -#define RADIO_INTENSET_END_Pos (3UL) /*!< Position of END field. */ -#define RADIO_INTENSET_END_Msk (0x1UL << RADIO_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define RADIO_INTENSET_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_END_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 2 : Enable interrupt on PAYLOAD event. */ -#define RADIO_INTENSET_PAYLOAD_Pos (2UL) /*!< Position of PAYLOAD field. */ -#define RADIO_INTENSET_PAYLOAD_Msk (0x1UL << RADIO_INTENSET_PAYLOAD_Pos) /*!< Bit mask of PAYLOAD field. */ -#define RADIO_INTENSET_PAYLOAD_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_PAYLOAD_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_PAYLOAD_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on ADDRESS event. */ -#define RADIO_INTENSET_ADDRESS_Pos (1UL) /*!< Position of ADDRESS field. */ -#define RADIO_INTENSET_ADDRESS_Msk (0x1UL << RADIO_INTENSET_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ -#define RADIO_INTENSET_ADDRESS_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_ADDRESS_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_ADDRESS_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on READY event. */ -#define RADIO_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define RADIO_INTENSET_READY_Msk (0x1UL << RADIO_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define RADIO_INTENSET_READY_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENSET_READY_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENSET_READY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: RADIO_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 10 : Disable interrupt on BCMATCH event. */ -#define RADIO_INTENCLR_BCMATCH_Pos (10UL) /*!< Position of BCMATCH field. */ -#define RADIO_INTENCLR_BCMATCH_Msk (0x1UL << RADIO_INTENCLR_BCMATCH_Pos) /*!< Bit mask of BCMATCH field. */ -#define RADIO_INTENCLR_BCMATCH_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_BCMATCH_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_BCMATCH_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 7 : Disable interrupt on RSSIEND event. */ -#define RADIO_INTENCLR_RSSIEND_Pos (7UL) /*!< Position of RSSIEND field. */ -#define RADIO_INTENCLR_RSSIEND_Msk (0x1UL << RADIO_INTENCLR_RSSIEND_Pos) /*!< Bit mask of RSSIEND field. */ -#define RADIO_INTENCLR_RSSIEND_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_RSSIEND_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_RSSIEND_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 6 : Disable interrupt on DEVMISS event. */ -#define RADIO_INTENCLR_DEVMISS_Pos (6UL) /*!< Position of DEVMISS field. */ -#define RADIO_INTENCLR_DEVMISS_Msk (0x1UL << RADIO_INTENCLR_DEVMISS_Pos) /*!< Bit mask of DEVMISS field. */ -#define RADIO_INTENCLR_DEVMISS_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_DEVMISS_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_DEVMISS_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 5 : Disable interrupt on DEVMATCH event. */ -#define RADIO_INTENCLR_DEVMATCH_Pos (5UL) /*!< Position of DEVMATCH field. */ -#define RADIO_INTENCLR_DEVMATCH_Msk (0x1UL << RADIO_INTENCLR_DEVMATCH_Pos) /*!< Bit mask of DEVMATCH field. */ -#define RADIO_INTENCLR_DEVMATCH_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_DEVMATCH_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_DEVMATCH_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 4 : Disable interrupt on DISABLED event. */ -#define RADIO_INTENCLR_DISABLED_Pos (4UL) /*!< Position of DISABLED field. */ -#define RADIO_INTENCLR_DISABLED_Msk (0x1UL << RADIO_INTENCLR_DISABLED_Pos) /*!< Bit mask of DISABLED field. */ -#define RADIO_INTENCLR_DISABLED_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_DISABLED_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_DISABLED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 3 : Disable interrupt on END event. */ -#define RADIO_INTENCLR_END_Pos (3UL) /*!< Position of END field. */ -#define RADIO_INTENCLR_END_Msk (0x1UL << RADIO_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define RADIO_INTENCLR_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_END_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 2 : Disable interrupt on PAYLOAD event. */ -#define RADIO_INTENCLR_PAYLOAD_Pos (2UL) /*!< Position of PAYLOAD field. */ -#define RADIO_INTENCLR_PAYLOAD_Msk (0x1UL << RADIO_INTENCLR_PAYLOAD_Pos) /*!< Bit mask of PAYLOAD field. */ -#define RADIO_INTENCLR_PAYLOAD_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_PAYLOAD_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_PAYLOAD_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on ADDRESS event. */ -#define RADIO_INTENCLR_ADDRESS_Pos (1UL) /*!< Position of ADDRESS field. */ -#define RADIO_INTENCLR_ADDRESS_Msk (0x1UL << RADIO_INTENCLR_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ -#define RADIO_INTENCLR_ADDRESS_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_ADDRESS_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_ADDRESS_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on READY event. */ -#define RADIO_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define RADIO_INTENCLR_READY_Msk (0x1UL << RADIO_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define RADIO_INTENCLR_READY_Disabled (0UL) /*!< Interrupt disabled. */ -#define RADIO_INTENCLR_READY_Enabled (1UL) /*!< Interrupt enabled. */ -#define RADIO_INTENCLR_READY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: RADIO_CRCSTATUS */ -/* Description: CRC status of received packet. */ - -/* Bit 0 : CRC status of received packet. */ -#define RADIO_CRCSTATUS_CRCSTATUS_Pos (0UL) /*!< Position of CRCSTATUS field. */ -#define RADIO_CRCSTATUS_CRCSTATUS_Msk (0x1UL << RADIO_CRCSTATUS_CRCSTATUS_Pos) /*!< Bit mask of CRCSTATUS field. */ -#define RADIO_CRCSTATUS_CRCSTATUS_CRCError (0UL) /*!< Packet received with CRC error. */ -#define RADIO_CRCSTATUS_CRCSTATUS_CRCOk (1UL) /*!< Packet received with CRC ok. */ - -/* Register: RADIO_RXMATCH */ -/* Description: Received address. */ - -/* Bits 2..0 : Logical address in which previous packet was received. */ -#define RADIO_RXMATCH_RXMATCH_Pos (0UL) /*!< Position of RXMATCH field. */ -#define RADIO_RXMATCH_RXMATCH_Msk (0x7UL << RADIO_RXMATCH_RXMATCH_Pos) /*!< Bit mask of RXMATCH field. */ - -/* Register: RADIO_RXCRC */ -/* Description: Received CRC. */ - -/* Bits 23..0 : CRC field of previously received packet. */ -#define RADIO_RXCRC_RXCRC_Pos (0UL) /*!< Position of RXCRC field. */ -#define RADIO_RXCRC_RXCRC_Msk (0xFFFFFFUL << RADIO_RXCRC_RXCRC_Pos) /*!< Bit mask of RXCRC field. */ - -/* Register: RADIO_DAI */ -/* Description: Device address match index. */ - -/* Bits 2..0 : Index (n) of device address (see DAB[n] and DAP[n]) that obtained an address match. */ -#define RADIO_DAI_DAI_Pos (0UL) /*!< Position of DAI field. */ -#define RADIO_DAI_DAI_Msk (0x7UL << RADIO_DAI_DAI_Pos) /*!< Bit mask of DAI field. */ - -/* Register: RADIO_FREQUENCY */ -/* Description: Frequency. */ - -/* Bits 6..0 : Radio channel frequency offset in MHz: RF Frequency = 2400 + FREQUENCY (MHz). Decision point: TXEN or RXEN task. */ -#define RADIO_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define RADIO_FREQUENCY_FREQUENCY_Msk (0x7FUL << RADIO_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ - -/* Register: RADIO_TXPOWER */ -/* Description: Output power. */ - -/* Bits 7..0 : Radio output power. Decision point: TXEN task. */ -#define RADIO_TXPOWER_TXPOWER_Pos (0UL) /*!< Position of TXPOWER field. */ -#define RADIO_TXPOWER_TXPOWER_Msk (0xFFUL << RADIO_TXPOWER_TXPOWER_Pos) /*!< Bit mask of TXPOWER field. */ -#define RADIO_TXPOWER_TXPOWER_0dBm (0x00UL) /*!< 0dBm. */ -#define RADIO_TXPOWER_TXPOWER_Pos4dBm (0x04UL) /*!< +4dBm. */ -#define RADIO_TXPOWER_TXPOWER_Neg30dBm (0xD8UL) /*!< -30dBm. */ -#define RADIO_TXPOWER_TXPOWER_Neg20dBm (0xECUL) /*!< -20dBm. */ -#define RADIO_TXPOWER_TXPOWER_Neg16dBm (0xF0UL) /*!< -16dBm. */ -#define RADIO_TXPOWER_TXPOWER_Neg12dBm (0xF4UL) /*!< -12dBm. */ -#define RADIO_TXPOWER_TXPOWER_Neg8dBm (0xF8UL) /*!< -8dBm. */ -#define RADIO_TXPOWER_TXPOWER_Neg4dBm (0xFCUL) /*!< -4dBm. */ - -/* Register: RADIO_MODE */ -/* Description: Data rate and modulation. */ - -/* Bits 1..0 : Radio data rate and modulation setting. Decision point: TXEN or RXEN task. */ -#define RADIO_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define RADIO_MODE_MODE_Msk (0x3UL << RADIO_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define RADIO_MODE_MODE_Nrf_1Mbit (0x00UL) /*!< 1Mbit/s Nordic propietary radio mode. */ -#define RADIO_MODE_MODE_Nrf_2Mbit (0x01UL) /*!< 2Mbit/s Nordic propietary radio mode. */ -#define RADIO_MODE_MODE_Nrf_250Kbit (0x02UL) /*!< 250kbit/s Nordic propietary radio mode. */ -#define RADIO_MODE_MODE_Ble_1Mbit (0x03UL) /*!< 1Mbit/s Bluetooth Low Energy */ - -/* Register: RADIO_PCNF0 */ -/* Description: Packet configuration 0. */ - -/* Bits 19..16 : Length of S1 field in number of bits. Decision point: START task. */ -#define RADIO_PCNF0_S1LEN_Pos (16UL) /*!< Position of S1LEN field. */ -#define RADIO_PCNF0_S1LEN_Msk (0xFUL << RADIO_PCNF0_S1LEN_Pos) /*!< Bit mask of S1LEN field. */ - -/* Bit 8 : Length of S0 field in number of bytes. Decision point: START task. */ -#define RADIO_PCNF0_S0LEN_Pos (8UL) /*!< Position of S0LEN field. */ -#define RADIO_PCNF0_S0LEN_Msk (0x1UL << RADIO_PCNF0_S0LEN_Pos) /*!< Bit mask of S0LEN field. */ - -/* Bits 3..0 : Length of length field in number of bits. Decision point: START task. */ -#define RADIO_PCNF0_LFLEN_Pos (0UL) /*!< Position of LFLEN field. */ -#define RADIO_PCNF0_LFLEN_Msk (0xFUL << RADIO_PCNF0_LFLEN_Pos) /*!< Bit mask of LFLEN field. */ - -/* Register: RADIO_PCNF1 */ -/* Description: Packet configuration 1. */ - -/* Bit 25 : Packet whitening enable. */ -#define RADIO_PCNF1_WHITEEN_Pos (25UL) /*!< Position of WHITEEN field. */ -#define RADIO_PCNF1_WHITEEN_Msk (0x1UL << RADIO_PCNF1_WHITEEN_Pos) /*!< Bit mask of WHITEEN field. */ -#define RADIO_PCNF1_WHITEEN_Disabled (0UL) /*!< Whitening disabled. */ -#define RADIO_PCNF1_WHITEEN_Enabled (1UL) /*!< Whitening enabled. */ - -/* Bit 24 : On air endianness of packet length field. Decision point: START task. */ -#define RADIO_PCNF1_ENDIAN_Pos (24UL) /*!< Position of ENDIAN field. */ -#define RADIO_PCNF1_ENDIAN_Msk (0x1UL << RADIO_PCNF1_ENDIAN_Pos) /*!< Bit mask of ENDIAN field. */ -#define RADIO_PCNF1_ENDIAN_Little (0UL) /*!< Least significant bit on air first */ -#define RADIO_PCNF1_ENDIAN_Big (1UL) /*!< Most significant bit on air first */ - -/* Bits 18..16 : Base address length in number of bytes. Decision point: START task. */ -#define RADIO_PCNF1_BALEN_Pos (16UL) /*!< Position of BALEN field. */ -#define RADIO_PCNF1_BALEN_Msk (0x7UL << RADIO_PCNF1_BALEN_Pos) /*!< Bit mask of BALEN field. */ - -/* Bits 15..8 : Static length in number of bytes. Decision point: START task. */ -#define RADIO_PCNF1_STATLEN_Pos (8UL) /*!< Position of STATLEN field. */ -#define RADIO_PCNF1_STATLEN_Msk (0xFFUL << RADIO_PCNF1_STATLEN_Pos) /*!< Bit mask of STATLEN field. */ - -/* Bits 7..0 : Maximum length of packet payload in number of bytes. */ -#define RADIO_PCNF1_MAXLEN_Pos (0UL) /*!< Position of MAXLEN field. */ -#define RADIO_PCNF1_MAXLEN_Msk (0xFFUL << RADIO_PCNF1_MAXLEN_Pos) /*!< Bit mask of MAXLEN field. */ - -/* Register: RADIO_PREFIX0 */ -/* Description: Prefixes bytes for logical addresses 0 to 3. */ - -/* Bits 31..24 : Address prefix 3. Decision point: START task. */ -#define RADIO_PREFIX0_AP3_Pos (24UL) /*!< Position of AP3 field. */ -#define RADIO_PREFIX0_AP3_Msk (0xFFUL << RADIO_PREFIX0_AP3_Pos) /*!< Bit mask of AP3 field. */ - -/* Bits 23..16 : Address prefix 2. Decision point: START task. */ -#define RADIO_PREFIX0_AP2_Pos (16UL) /*!< Position of AP2 field. */ -#define RADIO_PREFIX0_AP2_Msk (0xFFUL << RADIO_PREFIX0_AP2_Pos) /*!< Bit mask of AP2 field. */ - -/* Bits 15..8 : Address prefix 1. Decision point: START task. */ -#define RADIO_PREFIX0_AP1_Pos (8UL) /*!< Position of AP1 field. */ -#define RADIO_PREFIX0_AP1_Msk (0xFFUL << RADIO_PREFIX0_AP1_Pos) /*!< Bit mask of AP1 field. */ - -/* Bits 7..0 : Address prefix 0. Decision point: START task. */ -#define RADIO_PREFIX0_AP0_Pos (0UL) /*!< Position of AP0 field. */ -#define RADIO_PREFIX0_AP0_Msk (0xFFUL << RADIO_PREFIX0_AP0_Pos) /*!< Bit mask of AP0 field. */ - -/* Register: RADIO_PREFIX1 */ -/* Description: Prefixes bytes for logical addresses 4 to 7. */ - -/* Bits 31..24 : Address prefix 7. Decision point: START task. */ -#define RADIO_PREFIX1_AP7_Pos (24UL) /*!< Position of AP7 field. */ -#define RADIO_PREFIX1_AP7_Msk (0xFFUL << RADIO_PREFIX1_AP7_Pos) /*!< Bit mask of AP7 field. */ - -/* Bits 23..16 : Address prefix 6. Decision point: START task. */ -#define RADIO_PREFIX1_AP6_Pos (16UL) /*!< Position of AP6 field. */ -#define RADIO_PREFIX1_AP6_Msk (0xFFUL << RADIO_PREFIX1_AP6_Pos) /*!< Bit mask of AP6 field. */ - -/* Bits 15..8 : Address prefix 5. Decision point: START task. */ -#define RADIO_PREFIX1_AP5_Pos (8UL) /*!< Position of AP5 field. */ -#define RADIO_PREFIX1_AP5_Msk (0xFFUL << RADIO_PREFIX1_AP5_Pos) /*!< Bit mask of AP5 field. */ - -/* Bits 7..0 : Address prefix 4. Decision point: START task. */ -#define RADIO_PREFIX1_AP4_Pos (0UL) /*!< Position of AP4 field. */ -#define RADIO_PREFIX1_AP4_Msk (0xFFUL << RADIO_PREFIX1_AP4_Pos) /*!< Bit mask of AP4 field. */ - -/* Register: RADIO_TXADDRESS */ -/* Description: Transmit address select. */ - -/* Bits 2..0 : Logical address to be used when transmitting a packet. Decision point: START task. */ -#define RADIO_TXADDRESS_TXADDRESS_Pos (0UL) /*!< Position of TXADDRESS field. */ -#define RADIO_TXADDRESS_TXADDRESS_Msk (0x7UL << RADIO_TXADDRESS_TXADDRESS_Pos) /*!< Bit mask of TXADDRESS field. */ - -/* Register: RADIO_RXADDRESSES */ -/* Description: Receive address select. */ - -/* Bit 7 : Enable reception on logical address 7. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR7_Pos (7UL) /*!< Position of ADDR7 field. */ -#define RADIO_RXADDRESSES_ADDR7_Msk (0x1UL << RADIO_RXADDRESSES_ADDR7_Pos) /*!< Bit mask of ADDR7 field. */ -#define RADIO_RXADDRESSES_ADDR7_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR7_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 6 : Enable reception on logical address 6. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR6_Pos (6UL) /*!< Position of ADDR6 field. */ -#define RADIO_RXADDRESSES_ADDR6_Msk (0x1UL << RADIO_RXADDRESSES_ADDR6_Pos) /*!< Bit mask of ADDR6 field. */ -#define RADIO_RXADDRESSES_ADDR6_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR6_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 5 : Enable reception on logical address 5. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR5_Pos (5UL) /*!< Position of ADDR5 field. */ -#define RADIO_RXADDRESSES_ADDR5_Msk (0x1UL << RADIO_RXADDRESSES_ADDR5_Pos) /*!< Bit mask of ADDR5 field. */ -#define RADIO_RXADDRESSES_ADDR5_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR5_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 4 : Enable reception on logical address 4. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR4_Pos (4UL) /*!< Position of ADDR4 field. */ -#define RADIO_RXADDRESSES_ADDR4_Msk (0x1UL << RADIO_RXADDRESSES_ADDR4_Pos) /*!< Bit mask of ADDR4 field. */ -#define RADIO_RXADDRESSES_ADDR4_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR4_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 3 : Enable reception on logical address 3. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR3_Pos (3UL) /*!< Position of ADDR3 field. */ -#define RADIO_RXADDRESSES_ADDR3_Msk (0x1UL << RADIO_RXADDRESSES_ADDR3_Pos) /*!< Bit mask of ADDR3 field. */ -#define RADIO_RXADDRESSES_ADDR3_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR3_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 2 : Enable reception on logical address 2. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR2_Pos (2UL) /*!< Position of ADDR2 field. */ -#define RADIO_RXADDRESSES_ADDR2_Msk (0x1UL << RADIO_RXADDRESSES_ADDR2_Pos) /*!< Bit mask of ADDR2 field. */ -#define RADIO_RXADDRESSES_ADDR2_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR2_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 1 : Enable reception on logical address 1. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR1_Pos (1UL) /*!< Position of ADDR1 field. */ -#define RADIO_RXADDRESSES_ADDR1_Msk (0x1UL << RADIO_RXADDRESSES_ADDR1_Pos) /*!< Bit mask of ADDR1 field. */ -#define RADIO_RXADDRESSES_ADDR1_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR1_Enabled (1UL) /*!< Reception enabled. */ - -/* Bit 0 : Enable reception on logical address 0. Decision point: START task. */ -#define RADIO_RXADDRESSES_ADDR0_Pos (0UL) /*!< Position of ADDR0 field. */ -#define RADIO_RXADDRESSES_ADDR0_Msk (0x1UL << RADIO_RXADDRESSES_ADDR0_Pos) /*!< Bit mask of ADDR0 field. */ -#define RADIO_RXADDRESSES_ADDR0_Disabled (0UL) /*!< Reception disabled. */ -#define RADIO_RXADDRESSES_ADDR0_Enabled (1UL) /*!< Reception enabled. */ - -/* Register: RADIO_CRCCNF */ -/* Description: CRC configuration. */ - -/* Bit 8 : Leave packet address field out of the CRC calculation. Decision point: START task. */ -#define RADIO_CRCCNF_SKIPADDR_Pos (8UL) /*!< Position of SKIPADDR field. */ -#define RADIO_CRCCNF_SKIPADDR_Msk (0x1UL << RADIO_CRCCNF_SKIPADDR_Pos) /*!< Bit mask of SKIPADDR field. */ -#define RADIO_CRCCNF_SKIPADDR_Include (0UL) /*!< Include packet address in CRC calculation. */ -#define RADIO_CRCCNF_SKIPADDR_Skip (1UL) /*!< Packet address is skipped in CRC calculation. The CRC calculation will start at the first byte after the address. */ - -/* Bits 1..0 : CRC length. Decision point: START task. */ -#define RADIO_CRCCNF_LEN_Pos (0UL) /*!< Position of LEN field. */ -#define RADIO_CRCCNF_LEN_Msk (0x3UL << RADIO_CRCCNF_LEN_Pos) /*!< Bit mask of LEN field. */ -#define RADIO_CRCCNF_LEN_Disabled (0UL) /*!< CRC calculation disabled. */ -#define RADIO_CRCCNF_LEN_One (1UL) /*!< One byte long CRC. */ -#define RADIO_CRCCNF_LEN_Two (2UL) /*!< Two bytes long CRC. */ -#define RADIO_CRCCNF_LEN_Three (3UL) /*!< Three bytes long CRC. */ - -/* Register: RADIO_CRCPOLY */ -/* Description: CRC polynomial. */ - -/* Bits 23..0 : CRC polynomial. Decision point: START task. */ -#define RADIO_CRCPOLY_CRCPOLY_Pos (0UL) /*!< Position of CRCPOLY field. */ -#define RADIO_CRCPOLY_CRCPOLY_Msk (0xFFFFFFUL << RADIO_CRCPOLY_CRCPOLY_Pos) /*!< Bit mask of CRCPOLY field. */ - -/* Register: RADIO_CRCINIT */ -/* Description: CRC initial value. */ - -/* Bits 23..0 : Initial value for CRC calculation. Decision point: START task. */ -#define RADIO_CRCINIT_CRCINIT_Pos (0UL) /*!< Position of CRCINIT field. */ -#define RADIO_CRCINIT_CRCINIT_Msk (0xFFFFFFUL << RADIO_CRCINIT_CRCINIT_Pos) /*!< Bit mask of CRCINIT field. */ - -/* Register: RADIO_TEST */ -/* Description: Test features enable register. */ - -/* Bit 1 : PLL lock. Decision point: TXEN or RXEN task. */ -#define RADIO_TEST_PLLLOCK_Pos (1UL) /*!< Position of PLLLOCK field. */ -#define RADIO_TEST_PLLLOCK_Msk (0x1UL << RADIO_TEST_PLLLOCK_Pos) /*!< Bit mask of PLLLOCK field. */ -#define RADIO_TEST_PLLLOCK_Disabled (0UL) /*!< PLL lock disabled. */ -#define RADIO_TEST_PLLLOCK_Enabled (1UL) /*!< PLL lock enabled. */ - -/* Bit 0 : Constant carrier. Decision point: TXEN task. */ -#define RADIO_TEST_CONSTCARRIER_Pos (0UL) /*!< Position of CONSTCARRIER field. */ -#define RADIO_TEST_CONSTCARRIER_Msk (0x1UL << RADIO_TEST_CONSTCARRIER_Pos) /*!< Bit mask of CONSTCARRIER field. */ -#define RADIO_TEST_CONSTCARRIER_Disabled (0UL) /*!< Constant carrier disabled. */ -#define RADIO_TEST_CONSTCARRIER_Enabled (1UL) /*!< Constant carrier enabled. */ - -/* Register: RADIO_TIFS */ -/* Description: Inter Frame Spacing in microseconds. */ - -/* Bits 7..0 : Inter frame spacing in microseconds. Decision point: START rask */ -#define RADIO_TIFS_TIFS_Pos (0UL) /*!< Position of TIFS field. */ -#define RADIO_TIFS_TIFS_Msk (0xFFUL << RADIO_TIFS_TIFS_Pos) /*!< Bit mask of TIFS field. */ - -/* Register: RADIO_RSSISAMPLE */ -/* Description: RSSI sample. */ - -/* Bits 6..0 : RSSI sample result. The result is read as a positive value so that ReceivedSignalStrength = -RSSISAMPLE dBm */ -#define RADIO_RSSISAMPLE_RSSISAMPLE_Pos (0UL) /*!< Position of RSSISAMPLE field. */ -#define RADIO_RSSISAMPLE_RSSISAMPLE_Msk (0x7FUL << RADIO_RSSISAMPLE_RSSISAMPLE_Pos) /*!< Bit mask of RSSISAMPLE field. */ - -/* Register: RADIO_STATE */ -/* Description: Current radio state. */ - -/* Bits 3..0 : Current radio state. */ -#define RADIO_STATE_STATE_Pos (0UL) /*!< Position of STATE field. */ -#define RADIO_STATE_STATE_Msk (0xFUL << RADIO_STATE_STATE_Pos) /*!< Bit mask of STATE field. */ -#define RADIO_STATE_STATE_Disabled (0x00UL) /*!< Radio is in the Disabled state. */ -#define RADIO_STATE_STATE_RxRu (0x01UL) /*!< Radio is in the Rx Ramp Up state. */ -#define RADIO_STATE_STATE_RxIdle (0x02UL) /*!< Radio is in the Rx Idle state. */ -#define RADIO_STATE_STATE_Rx (0x03UL) /*!< Radio is in the Rx state. */ -#define RADIO_STATE_STATE_RxDisable (0x04UL) /*!< Radio is in the Rx Disable state. */ -#define RADIO_STATE_STATE_TxRu (0x09UL) /*!< Radio is in the Tx Ramp Up state. */ -#define RADIO_STATE_STATE_TxIdle (0x0AUL) /*!< Radio is in the Tx Idle state. */ -#define RADIO_STATE_STATE_Tx (0x0BUL) /*!< Radio is in the Tx state. */ -#define RADIO_STATE_STATE_TxDisable (0x0CUL) /*!< Radio is in the Tx Disable state. */ - -/* Register: RADIO_DATAWHITEIV */ -/* Description: Data whitening initial value. */ - -/* Bits 6..0 : Data whitening initial value. Bit 0 corresponds to Position 0 of the LSFR, Bit 1 to position 5... Decision point: TXEN or RXEN task. */ -#define RADIO_DATAWHITEIV_DATAWHITEIV_Pos (0UL) /*!< Position of DATAWHITEIV field. */ -#define RADIO_DATAWHITEIV_DATAWHITEIV_Msk (0x7FUL << RADIO_DATAWHITEIV_DATAWHITEIV_Pos) /*!< Bit mask of DATAWHITEIV field. */ - -/* Register: RADIO_DAP */ -/* Description: Device address prefix. */ - -/* Bits 15..0 : Device address prefix. */ -#define RADIO_DAP_DAP_Pos (0UL) /*!< Position of DAP field. */ -#define RADIO_DAP_DAP_Msk (0xFFFFUL << RADIO_DAP_DAP_Pos) /*!< Bit mask of DAP field. */ - -/* Register: RADIO_DACNF */ -/* Description: Device address match configuration. */ - -/* Bit 15 : TxAdd for device address 7. */ -#define RADIO_DACNF_TXADD7_Pos (15UL) /*!< Position of TXADD7 field. */ -#define RADIO_DACNF_TXADD7_Msk (0x1UL << RADIO_DACNF_TXADD7_Pos) /*!< Bit mask of TXADD7 field. */ - -/* Bit 14 : TxAdd for device address 6. */ -#define RADIO_DACNF_TXADD6_Pos (14UL) /*!< Position of TXADD6 field. */ -#define RADIO_DACNF_TXADD6_Msk (0x1UL << RADIO_DACNF_TXADD6_Pos) /*!< Bit mask of TXADD6 field. */ - -/* Bit 13 : TxAdd for device address 5. */ -#define RADIO_DACNF_TXADD5_Pos (13UL) /*!< Position of TXADD5 field. */ -#define RADIO_DACNF_TXADD5_Msk (0x1UL << RADIO_DACNF_TXADD5_Pos) /*!< Bit mask of TXADD5 field. */ - -/* Bit 12 : TxAdd for device address 4. */ -#define RADIO_DACNF_TXADD4_Pos (12UL) /*!< Position of TXADD4 field. */ -#define RADIO_DACNF_TXADD4_Msk (0x1UL << RADIO_DACNF_TXADD4_Pos) /*!< Bit mask of TXADD4 field. */ - -/* Bit 11 : TxAdd for device address 3. */ -#define RADIO_DACNF_TXADD3_Pos (11UL) /*!< Position of TXADD3 field. */ -#define RADIO_DACNF_TXADD3_Msk (0x1UL << RADIO_DACNF_TXADD3_Pos) /*!< Bit mask of TXADD3 field. */ - -/* Bit 10 : TxAdd for device address 2. */ -#define RADIO_DACNF_TXADD2_Pos (10UL) /*!< Position of TXADD2 field. */ -#define RADIO_DACNF_TXADD2_Msk (0x1UL << RADIO_DACNF_TXADD2_Pos) /*!< Bit mask of TXADD2 field. */ - -/* Bit 9 : TxAdd for device address 1. */ -#define RADIO_DACNF_TXADD1_Pos (9UL) /*!< Position of TXADD1 field. */ -#define RADIO_DACNF_TXADD1_Msk (0x1UL << RADIO_DACNF_TXADD1_Pos) /*!< Bit mask of TXADD1 field. */ - -/* Bit 8 : TxAdd for device address 0. */ -#define RADIO_DACNF_TXADD0_Pos (8UL) /*!< Position of TXADD0 field. */ -#define RADIO_DACNF_TXADD0_Msk (0x1UL << RADIO_DACNF_TXADD0_Pos) /*!< Bit mask of TXADD0 field. */ - -/* Bit 7 : Enable or disable device address matching using device address 7. */ -#define RADIO_DACNF_ENA7_Pos (7UL) /*!< Position of ENA7 field. */ -#define RADIO_DACNF_ENA7_Msk (0x1UL << RADIO_DACNF_ENA7_Pos) /*!< Bit mask of ENA7 field. */ -#define RADIO_DACNF_ENA7_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA7_Enabled (1UL) /*!< Enabled. */ - -/* Bit 6 : Enable or disable device address matching using device address 6. */ -#define RADIO_DACNF_ENA6_Pos (6UL) /*!< Position of ENA6 field. */ -#define RADIO_DACNF_ENA6_Msk (0x1UL << RADIO_DACNF_ENA6_Pos) /*!< Bit mask of ENA6 field. */ -#define RADIO_DACNF_ENA6_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA6_Enabled (1UL) /*!< Enabled. */ - -/* Bit 5 : Enable or disable device address matching using device address 5. */ -#define RADIO_DACNF_ENA5_Pos (5UL) /*!< Position of ENA5 field. */ -#define RADIO_DACNF_ENA5_Msk (0x1UL << RADIO_DACNF_ENA5_Pos) /*!< Bit mask of ENA5 field. */ -#define RADIO_DACNF_ENA5_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA5_Enabled (1UL) /*!< Enabled. */ - -/* Bit 4 : Enable or disable device address matching using device address 4. */ -#define RADIO_DACNF_ENA4_Pos (4UL) /*!< Position of ENA4 field. */ -#define RADIO_DACNF_ENA4_Msk (0x1UL << RADIO_DACNF_ENA4_Pos) /*!< Bit mask of ENA4 field. */ -#define RADIO_DACNF_ENA4_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA4_Enabled (1UL) /*!< Enabled. */ - -/* Bit 3 : Enable or disable device address matching using device address 3. */ -#define RADIO_DACNF_ENA3_Pos (3UL) /*!< Position of ENA3 field. */ -#define RADIO_DACNF_ENA3_Msk (0x1UL << RADIO_DACNF_ENA3_Pos) /*!< Bit mask of ENA3 field. */ -#define RADIO_DACNF_ENA3_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA3_Enabled (1UL) /*!< Enabled. */ - -/* Bit 2 : Enable or disable device address matching using device address 2. */ -#define RADIO_DACNF_ENA2_Pos (2UL) /*!< Position of ENA2 field. */ -#define RADIO_DACNF_ENA2_Msk (0x1UL << RADIO_DACNF_ENA2_Pos) /*!< Bit mask of ENA2 field. */ -#define RADIO_DACNF_ENA2_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA2_Enabled (1UL) /*!< Enabled. */ - -/* Bit 1 : Enable or disable device address matching using device address 1. */ -#define RADIO_DACNF_ENA1_Pos (1UL) /*!< Position of ENA1 field. */ -#define RADIO_DACNF_ENA1_Msk (0x1UL << RADIO_DACNF_ENA1_Pos) /*!< Bit mask of ENA1 field. */ -#define RADIO_DACNF_ENA1_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA1_Enabled (1UL) /*!< Enabled. */ - -/* Bit 0 : Enable or disable device address matching using device address 0. */ -#define RADIO_DACNF_ENA0_Pos (0UL) /*!< Position of ENA0 field. */ -#define RADIO_DACNF_ENA0_Msk (0x1UL << RADIO_DACNF_ENA0_Pos) /*!< Bit mask of ENA0 field. */ -#define RADIO_DACNF_ENA0_Disabled (0UL) /*!< Disabled. */ -#define RADIO_DACNF_ENA0_Enabled (1UL) /*!< Enabled. */ - -/* Register: RADIO_OVERRIDE0 */ -/* Description: Trim value override register 0. */ - -/* Bits 31..0 : Trim value override 0. */ -#define RADIO_OVERRIDE0_OVERRIDE0_Pos (0UL) /*!< Position of OVERRIDE0 field. */ -#define RADIO_OVERRIDE0_OVERRIDE0_Msk (0xFFFFFFFFUL << RADIO_OVERRIDE0_OVERRIDE0_Pos) /*!< Bit mask of OVERRIDE0 field. */ - -/* Register: RADIO_OVERRIDE1 */ -/* Description: Trim value override register 1. */ - -/* Bits 31..0 : Trim value override 1. */ -#define RADIO_OVERRIDE1_OVERRIDE1_Pos (0UL) /*!< Position of OVERRIDE1 field. */ -#define RADIO_OVERRIDE1_OVERRIDE1_Msk (0xFFFFFFFFUL << RADIO_OVERRIDE1_OVERRIDE1_Pos) /*!< Bit mask of OVERRIDE1 field. */ - -/* Register: RADIO_OVERRIDE2 */ -/* Description: Trim value override register 2. */ - -/* Bits 31..0 : Trim value override 2. */ -#define RADIO_OVERRIDE2_OVERRIDE2_Pos (0UL) /*!< Position of OVERRIDE2 field. */ -#define RADIO_OVERRIDE2_OVERRIDE2_Msk (0xFFFFFFFFUL << RADIO_OVERRIDE2_OVERRIDE2_Pos) /*!< Bit mask of OVERRIDE2 field. */ - -/* Register: RADIO_OVERRIDE3 */ -/* Description: Trim value override register 3. */ - -/* Bits 31..0 : Trim value override 3. */ -#define RADIO_OVERRIDE3_OVERRIDE3_Pos (0UL) /*!< Position of OVERRIDE3 field. */ -#define RADIO_OVERRIDE3_OVERRIDE3_Msk (0xFFFFFFFFUL << RADIO_OVERRIDE3_OVERRIDE3_Pos) /*!< Bit mask of OVERRIDE3 field. */ - -/* Register: RADIO_OVERRIDE4 */ -/* Description: Trim value override register 4. */ - -/* Bit 31 : Enable or disable override of default trim values. */ -#define RADIO_OVERRIDE4_ENABLE_Pos (31UL) /*!< Position of ENABLE field. */ -#define RADIO_OVERRIDE4_ENABLE_Msk (0x1UL << RADIO_OVERRIDE4_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define RADIO_OVERRIDE4_ENABLE_Disabled (0UL) /*!< Override trim values disabled. */ -#define RADIO_OVERRIDE4_ENABLE_Enabled (1UL) /*!< Override trim values enabled. */ - -/* Bits 27..0 : Trim value override 4. */ -#define RADIO_OVERRIDE4_OVERRIDE4_Pos (0UL) /*!< Position of OVERRIDE4 field. */ -#define RADIO_OVERRIDE4_OVERRIDE4_Msk (0xFFFFFFFUL << RADIO_OVERRIDE4_OVERRIDE4_Pos) /*!< Bit mask of OVERRIDE4 field. */ - -/* Register: RADIO_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define RADIO_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define RADIO_POWER_POWER_Msk (0x1UL << RADIO_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define RADIO_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define RADIO_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: RNG */ -/* Description: Random Number Generator. */ - -/* Register: RNG_SHORTS */ -/* Description: Shortcuts for the RNG. */ - -/* Bit 0 : Shortcut between VALRDY event and STOP task. */ -#define RNG_SHORTS_VALRDY_STOP_Pos (0UL) /*!< Position of VALRDY_STOP field. */ -#define RNG_SHORTS_VALRDY_STOP_Msk (0x1UL << RNG_SHORTS_VALRDY_STOP_Pos) /*!< Bit mask of VALRDY_STOP field. */ -#define RNG_SHORTS_VALRDY_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define RNG_SHORTS_VALRDY_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: RNG_INTENSET */ -/* Description: Interrupt enable set register */ - -/* Bit 0 : Enable interrupt on VALRDY event. */ -#define RNG_INTENSET_VALRDY_Pos (0UL) /*!< Position of VALRDY field. */ -#define RNG_INTENSET_VALRDY_Msk (0x1UL << RNG_INTENSET_VALRDY_Pos) /*!< Bit mask of VALRDY field. */ -#define RNG_INTENSET_VALRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define RNG_INTENSET_VALRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define RNG_INTENSET_VALRDY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: RNG_INTENCLR */ -/* Description: Interrupt enable clear register */ - -/* Bit 0 : Disable interrupt on VALRDY event. */ -#define RNG_INTENCLR_VALRDY_Pos (0UL) /*!< Position of VALRDY field. */ -#define RNG_INTENCLR_VALRDY_Msk (0x1UL << RNG_INTENCLR_VALRDY_Pos) /*!< Bit mask of VALRDY field. */ -#define RNG_INTENCLR_VALRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define RNG_INTENCLR_VALRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define RNG_INTENCLR_VALRDY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: RNG_CONFIG */ -/* Description: Configuration register. */ - -/* Bit 0 : Digital error correction enable. */ -#define RNG_CONFIG_DERCEN_Pos (0UL) /*!< Position of DERCEN field. */ -#define RNG_CONFIG_DERCEN_Msk (0x1UL << RNG_CONFIG_DERCEN_Pos) /*!< Bit mask of DERCEN field. */ -#define RNG_CONFIG_DERCEN_Disabled (0UL) /*!< Digital error correction disabled. */ -#define RNG_CONFIG_DERCEN_Enabled (1UL) /*!< Digital error correction enabled. */ - -/* Register: RNG_VALUE */ -/* Description: RNG random number. */ - -/* Bits 7..0 : Generated random number. */ -#define RNG_VALUE_VALUE_Pos (0UL) /*!< Position of VALUE field. */ -#define RNG_VALUE_VALUE_Msk (0xFFUL << RNG_VALUE_VALUE_Pos) /*!< Bit mask of VALUE field. */ - -/* Register: RNG_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define RNG_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define RNG_POWER_POWER_Msk (0x1UL << RNG_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define RNG_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define RNG_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: RTC */ -/* Description: Real time counter 0. */ - -/* Register: RTC_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 19 : Enable interrupt on COMPARE[3] event. */ -#define RTC_INTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_INTENSET_COMPARE3_Msk (0x1UL << RTC_INTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_INTENSET_COMPARE3_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENSET_COMPARE3_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENSET_COMPARE3_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 18 : Enable interrupt on COMPARE[2] event. */ -#define RTC_INTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_INTENSET_COMPARE2_Msk (0x1UL << RTC_INTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_INTENSET_COMPARE2_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENSET_COMPARE2_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENSET_COMPARE2_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 17 : Enable interrupt on COMPARE[1] event. */ -#define RTC_INTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_INTENSET_COMPARE1_Msk (0x1UL << RTC_INTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_INTENSET_COMPARE1_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENSET_COMPARE1_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENSET_COMPARE1_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 16 : Enable interrupt on COMPARE[0] event. */ -#define RTC_INTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_INTENSET_COMPARE0_Msk (0x1UL << RTC_INTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_INTENSET_COMPARE0_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENSET_COMPARE0_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENSET_COMPARE0_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on OVRFLW event. */ -#define RTC_INTENSET_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_INTENSET_OVRFLW_Msk (0x1UL << RTC_INTENSET_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_INTENSET_OVRFLW_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENSET_OVRFLW_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENSET_OVRFLW_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on TICK event. */ -#define RTC_INTENSET_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_INTENSET_TICK_Msk (0x1UL << RTC_INTENSET_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_INTENSET_TICK_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENSET_TICK_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENSET_TICK_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: RTC_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 19 : Disable interrupt on COMPARE[3] event. */ -#define RTC_INTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_INTENCLR_COMPARE3_Msk (0x1UL << RTC_INTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_INTENCLR_COMPARE3_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENCLR_COMPARE3_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENCLR_COMPARE3_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 18 : Disable interrupt on COMPARE[2] event. */ -#define RTC_INTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_INTENCLR_COMPARE2_Msk (0x1UL << RTC_INTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_INTENCLR_COMPARE2_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENCLR_COMPARE2_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENCLR_COMPARE2_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 17 : Disable interrupt on COMPARE[1] event. */ -#define RTC_INTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_INTENCLR_COMPARE1_Msk (0x1UL << RTC_INTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_INTENCLR_COMPARE1_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENCLR_COMPARE1_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENCLR_COMPARE1_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 16 : Disable interrupt on COMPARE[0] event. */ -#define RTC_INTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_INTENCLR_COMPARE0_Msk (0x1UL << RTC_INTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_INTENCLR_COMPARE0_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENCLR_COMPARE0_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENCLR_COMPARE0_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on OVRFLW event. */ -#define RTC_INTENCLR_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_INTENCLR_OVRFLW_Msk (0x1UL << RTC_INTENCLR_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_INTENCLR_OVRFLW_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENCLR_OVRFLW_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENCLR_OVRFLW_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on TICK event. */ -#define RTC_INTENCLR_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_INTENCLR_TICK_Msk (0x1UL << RTC_INTENCLR_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_INTENCLR_TICK_Disabled (0UL) /*!< Interrupt disabled. */ -#define RTC_INTENCLR_TICK_Enabled (1UL) /*!< Interrupt enabled. */ -#define RTC_INTENCLR_TICK_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: RTC_EVTEN */ -/* Description: Configures event enable routing to PPI for each RTC event. */ - -/* Bit 19 : COMPARE[3] event enable. */ -#define RTC_EVTEN_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTEN_COMPARE3_Msk (0x1UL << RTC_EVTEN_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTEN_COMPARE3_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTEN_COMPARE3_Enabled (1UL) /*!< Event enabled. */ - -/* Bit 18 : COMPARE[2] event enable. */ -#define RTC_EVTEN_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTEN_COMPARE2_Msk (0x1UL << RTC_EVTEN_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTEN_COMPARE2_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTEN_COMPARE2_Enabled (1UL) /*!< Event enabled. */ - -/* Bit 17 : COMPARE[1] event enable. */ -#define RTC_EVTEN_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTEN_COMPARE1_Msk (0x1UL << RTC_EVTEN_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTEN_COMPARE1_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTEN_COMPARE1_Enabled (1UL) /*!< Event enabled. */ - -/* Bit 16 : COMPARE[0] event enable. */ -#define RTC_EVTEN_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTEN_COMPARE0_Msk (0x1UL << RTC_EVTEN_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTEN_COMPARE0_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTEN_COMPARE0_Enabled (1UL) /*!< Event enabled. */ - -/* Bit 1 : OVRFLW event enable. */ -#define RTC_EVTEN_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTEN_OVRFLW_Msk (0x1UL << RTC_EVTEN_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTEN_OVRFLW_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTEN_OVRFLW_Enabled (1UL) /*!< Event enabled. */ - -/* Bit 0 : TICK event enable. */ -#define RTC_EVTEN_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTEN_TICK_Msk (0x1UL << RTC_EVTEN_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTEN_TICK_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTEN_TICK_Enabled (1UL) /*!< Event enabled. */ - -/* Register: RTC_EVTENSET */ -/* Description: Enable events routing to PPI. The reading of this register gives the value of EVTEN. */ - -/* Bit 19 : Enable routing to PPI of COMPARE[3] event. */ -#define RTC_EVTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTENSET_COMPARE3_Msk (0x1UL << RTC_EVTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTENSET_COMPARE3_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENSET_COMPARE3_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENSET_COMPARE3_Set (1UL) /*!< Enable event on write. */ - -/* Bit 18 : Enable routing to PPI of COMPARE[2] event. */ -#define RTC_EVTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTENSET_COMPARE2_Msk (0x1UL << RTC_EVTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTENSET_COMPARE2_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENSET_COMPARE2_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENSET_COMPARE2_Set (1UL) /*!< Enable event on write. */ - -/* Bit 17 : Enable routing to PPI of COMPARE[1] event. */ -#define RTC_EVTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTENSET_COMPARE1_Msk (0x1UL << RTC_EVTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTENSET_COMPARE1_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENSET_COMPARE1_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENSET_COMPARE1_Set (1UL) /*!< Enable event on write. */ - -/* Bit 16 : Enable routing to PPI of COMPARE[0] event. */ -#define RTC_EVTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTENSET_COMPARE0_Msk (0x1UL << RTC_EVTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTENSET_COMPARE0_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENSET_COMPARE0_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENSET_COMPARE0_Set (1UL) /*!< Enable event on write. */ - -/* Bit 1 : Enable routing to PPI of OVRFLW event. */ -#define RTC_EVTENSET_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTENSET_OVRFLW_Msk (0x1UL << RTC_EVTENSET_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTENSET_OVRFLW_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENSET_OVRFLW_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENSET_OVRFLW_Set (1UL) /*!< Enable event on write. */ - -/* Bit 0 : Enable routing to PPI of TICK event. */ -#define RTC_EVTENSET_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTENSET_TICK_Msk (0x1UL << RTC_EVTENSET_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTENSET_TICK_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENSET_TICK_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENSET_TICK_Set (1UL) /*!< Enable event on write. */ - -/* Register: RTC_EVTENCLR */ -/* Description: Disable events routing to PPI. The reading of this register gives the value of EVTEN. */ - -/* Bit 19 : Disable routing to PPI of COMPARE[3] event. */ -#define RTC_EVTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTENCLR_COMPARE3_Msk (0x1UL << RTC_EVTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTENCLR_COMPARE3_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENCLR_COMPARE3_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENCLR_COMPARE3_Clear (1UL) /*!< Disable event on write. */ - -/* Bit 18 : Disable routing to PPI of COMPARE[2] event. */ -#define RTC_EVTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTENCLR_COMPARE2_Msk (0x1UL << RTC_EVTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTENCLR_COMPARE2_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENCLR_COMPARE2_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENCLR_COMPARE2_Clear (1UL) /*!< Disable event on write. */ - -/* Bit 17 : Disable routing to PPI of COMPARE[1] event. */ -#define RTC_EVTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTENCLR_COMPARE1_Msk (0x1UL << RTC_EVTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTENCLR_COMPARE1_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENCLR_COMPARE1_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENCLR_COMPARE1_Clear (1UL) /*!< Disable event on write. */ - -/* Bit 16 : Disable routing to PPI of COMPARE[0] event. */ -#define RTC_EVTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTENCLR_COMPARE0_Msk (0x1UL << RTC_EVTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTENCLR_COMPARE0_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENCLR_COMPARE0_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENCLR_COMPARE0_Clear (1UL) /*!< Disable event on write. */ - -/* Bit 1 : Disable routing to PPI of OVRFLW event. */ -#define RTC_EVTENCLR_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTENCLR_OVRFLW_Msk (0x1UL << RTC_EVTENCLR_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTENCLR_OVRFLW_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENCLR_OVRFLW_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENCLR_OVRFLW_Clear (1UL) /*!< Disable event on write. */ - -/* Bit 0 : Disable routing to PPI of TICK event. */ -#define RTC_EVTENCLR_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTENCLR_TICK_Msk (0x1UL << RTC_EVTENCLR_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTENCLR_TICK_Disabled (0UL) /*!< Event disabled. */ -#define RTC_EVTENCLR_TICK_Enabled (1UL) /*!< Event enabled. */ -#define RTC_EVTENCLR_TICK_Clear (1UL) /*!< Disable event on write. */ - -/* Register: RTC_COUNTER */ -/* Description: Current COUNTER value. */ - -/* Bits 23..0 : Counter value. */ -#define RTC_COUNTER_COUNTER_Pos (0UL) /*!< Position of COUNTER field. */ -#define RTC_COUNTER_COUNTER_Msk (0xFFFFFFUL << RTC_COUNTER_COUNTER_Pos) /*!< Bit mask of COUNTER field. */ - -/* Register: RTC_PRESCALER */ -/* Description: 12-bit prescaler for COUNTER frequency (32768/(PRESCALER+1)). Must be written when RTC is STOPed. */ - -/* Bits 11..0 : RTC PRESCALER value. */ -#define RTC_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define RTC_PRESCALER_PRESCALER_Msk (0xFFFUL << RTC_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ - -/* Register: RTC_CC */ -/* Description: Capture/compare registers. */ - -/* Bits 23..0 : Compare value. */ -#define RTC_CC_COMPARE_Pos (0UL) /*!< Position of COMPARE field. */ -#define RTC_CC_COMPARE_Msk (0xFFFFFFUL << RTC_CC_COMPARE_Pos) /*!< Bit mask of COMPARE field. */ - -/* Register: RTC_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define RTC_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define RTC_POWER_POWER_Msk (0x1UL << RTC_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define RTC_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define RTC_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: SPI */ -/* Description: SPI master 0. */ - -/* Register: SPI_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 2 : Enable interrupt on READY event. */ -#define SPI_INTENSET_READY_Pos (2UL) /*!< Position of READY field. */ -#define SPI_INTENSET_READY_Msk (0x1UL << SPI_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define SPI_INTENSET_READY_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPI_INTENSET_READY_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPI_INTENSET_READY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: SPI_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 2 : Disable interrupt on READY event. */ -#define SPI_INTENCLR_READY_Pos (2UL) /*!< Position of READY field. */ -#define SPI_INTENCLR_READY_Msk (0x1UL << SPI_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define SPI_INTENCLR_READY_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPI_INTENCLR_READY_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPI_INTENCLR_READY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: SPI_ENABLE */ -/* Description: Enable SPI. */ - -/* Bits 2..0 : Enable or disable SPI. */ -#define SPI_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPI_ENABLE_ENABLE_Msk (0x7UL << SPI_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPI_ENABLE_ENABLE_Disabled (0x00UL) /*!< Disabled SPI. */ -#define SPI_ENABLE_ENABLE_Enabled (0x01UL) /*!< Enable SPI. */ - -/* Register: SPI_RXD */ -/* Description: RX data. */ - -/* Bits 7..0 : RX data from last transfer. */ -#define SPI_RXD_RXD_Pos (0UL) /*!< Position of RXD field. */ -#define SPI_RXD_RXD_Msk (0xFFUL << SPI_RXD_RXD_Pos) /*!< Bit mask of RXD field. */ - -/* Register: SPI_TXD */ -/* Description: TX data. */ - -/* Bits 7..0 : TX data for next transfer. */ -#define SPI_TXD_TXD_Pos (0UL) /*!< Position of TXD field. */ -#define SPI_TXD_TXD_Msk (0xFFUL << SPI_TXD_TXD_Pos) /*!< Bit mask of TXD field. */ - -/* Register: SPI_FREQUENCY */ -/* Description: SPI frequency */ - -/* Bits 31..0 : SPI data rate. */ -#define SPI_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define SPI_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << SPI_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define SPI_FREQUENCY_FREQUENCY_K125 (0x02000000UL) /*!< 125kbps. */ -#define SPI_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250kbps. */ -#define SPI_FREQUENCY_FREQUENCY_K500 (0x08000000UL) /*!< 500kbps. */ -#define SPI_FREQUENCY_FREQUENCY_M1 (0x10000000UL) /*!< 1Mbps. */ -#define SPI_FREQUENCY_FREQUENCY_M2 (0x20000000UL) /*!< 2Mbps. */ -#define SPI_FREQUENCY_FREQUENCY_M4 (0x40000000UL) /*!< 4Mbps. */ -#define SPI_FREQUENCY_FREQUENCY_M8 (0x80000000UL) /*!< 8Mbps. */ - -/* Register: SPI_CONFIG */ -/* Description: Configuration register. */ - -/* Bit 2 : Serial clock (SCK) polarity. */ -#define SPI_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPI_CONFIG_CPOL_Msk (0x1UL << SPI_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPI_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high. */ -#define SPI_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low. */ - -/* Bit 1 : Serial clock (SCK) phase. */ -#define SPI_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPI_CONFIG_CPHA_Msk (0x1UL << SPI_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPI_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of the clock. Shift serial data on trailing edge. */ -#define SPI_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of the clock. Shift serial data on leading edge. */ - -/* Bit 0 : Bit order. */ -#define SPI_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPI_CONFIG_ORDER_Msk (0x1UL << SPI_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPI_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit transmitted out first. */ -#define SPI_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit transmitted out first. */ - -/* Register: SPI_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define SPI_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define SPI_POWER_POWER_Msk (0x1UL << SPI_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define SPI_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define SPI_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: SPIS */ -/* Description: SPI slave 1. */ - -/* Register: SPIS_SHORTS */ -/* Description: Shortcuts for SPIS. */ - -/* Bit 2 : Shortcut between END event and the ACQUIRE task. */ -#define SPIS_SHORTS_END_ACQUIRE_Pos (2UL) /*!< Position of END_ACQUIRE field. */ -#define SPIS_SHORTS_END_ACQUIRE_Msk (0x1UL << SPIS_SHORTS_END_ACQUIRE_Pos) /*!< Bit mask of END_ACQUIRE field. */ -#define SPIS_SHORTS_END_ACQUIRE_Disabled (0UL) /*!< Shortcut disabled. */ -#define SPIS_SHORTS_END_ACQUIRE_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: SPIS_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 10 : Enable interrupt on ACQUIRED event. */ -#define SPIS_INTENSET_ACQUIRED_Pos (10UL) /*!< Position of ACQUIRED field. */ -#define SPIS_INTENSET_ACQUIRED_Msk (0x1UL << SPIS_INTENSET_ACQUIRED_Pos) /*!< Bit mask of ACQUIRED field. */ -#define SPIS_INTENSET_ACQUIRED_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPIS_INTENSET_ACQUIRED_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPIS_INTENSET_ACQUIRED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 4 : enable interrupt on ENDRX event. */ -#define SPIS_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIS_INTENSET_ENDRX_Msk (0x1UL << SPIS_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIS_INTENSET_ENDRX_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPIS_INTENSET_ENDRX_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPIS_INTENSET_ENDRX_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on END event. */ -#define SPIS_INTENSET_END_Pos (1UL) /*!< Position of END field. */ -#define SPIS_INTENSET_END_Msk (0x1UL << SPIS_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SPIS_INTENSET_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPIS_INTENSET_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPIS_INTENSET_END_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: SPIS_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 10 : Disable interrupt on ACQUIRED event. */ -#define SPIS_INTENCLR_ACQUIRED_Pos (10UL) /*!< Position of ACQUIRED field. */ -#define SPIS_INTENCLR_ACQUIRED_Msk (0x1UL << SPIS_INTENCLR_ACQUIRED_Pos) /*!< Bit mask of ACQUIRED field. */ -#define SPIS_INTENCLR_ACQUIRED_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPIS_INTENCLR_ACQUIRED_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPIS_INTENCLR_ACQUIRED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 4 : Disable interrupt on ENDRX event. */ -#define SPIS_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIS_INTENCLR_ENDRX_Msk (0x1UL << SPIS_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIS_INTENCLR_ENDRX_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPIS_INTENCLR_ENDRX_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPIS_INTENCLR_ENDRX_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on END event. */ -#define SPIS_INTENCLR_END_Pos (1UL) /*!< Position of END field. */ -#define SPIS_INTENCLR_END_Msk (0x1UL << SPIS_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SPIS_INTENCLR_END_Disabled (0UL) /*!< Interrupt disabled. */ -#define SPIS_INTENCLR_END_Enabled (1UL) /*!< Interrupt enabled. */ -#define SPIS_INTENCLR_END_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: SPIS_SEMSTAT */ -/* Description: Semaphore status. */ - -/* Bits 1..0 : Semaphore status. */ -#define SPIS_SEMSTAT_SEMSTAT_Pos (0UL) /*!< Position of SEMSTAT field. */ -#define SPIS_SEMSTAT_SEMSTAT_Msk (0x3UL << SPIS_SEMSTAT_SEMSTAT_Pos) /*!< Bit mask of SEMSTAT field. */ -#define SPIS_SEMSTAT_SEMSTAT_Free (0x00UL) /*!< Semaphore is free. */ -#define SPIS_SEMSTAT_SEMSTAT_CPU (0x01UL) /*!< Semaphore is assigned to the CPU. */ -#define SPIS_SEMSTAT_SEMSTAT_SPIS (0x02UL) /*!< Semaphore is assigned to the SPIS. */ -#define SPIS_SEMSTAT_SEMSTAT_CPUPending (0x03UL) /*!< Semaphore is assigned to the SPIS, but a handover to the CPU is pending. */ - -/* Register: SPIS_STATUS */ -/* Description: Status from last transaction. */ - -/* Bit 1 : RX buffer overflow detected, and prevented. */ -#define SPIS_STATUS_OVERFLOW_Pos (1UL) /*!< Position of OVERFLOW field. */ -#define SPIS_STATUS_OVERFLOW_Msk (0x1UL << SPIS_STATUS_OVERFLOW_Pos) /*!< Bit mask of OVERFLOW field. */ -#define SPIS_STATUS_OVERFLOW_NotPresent (0UL) /*!< Error not present. */ -#define SPIS_STATUS_OVERFLOW_Present (1UL) /*!< Error present. */ -#define SPIS_STATUS_OVERFLOW_Clear (1UL) /*!< Clear on write. */ - -/* Bit 0 : TX buffer overread detected, and prevented. */ -#define SPIS_STATUS_OVERREAD_Pos (0UL) /*!< Position of OVERREAD field. */ -#define SPIS_STATUS_OVERREAD_Msk (0x1UL << SPIS_STATUS_OVERREAD_Pos) /*!< Bit mask of OVERREAD field. */ -#define SPIS_STATUS_OVERREAD_NotPresent (0UL) /*!< Error not present. */ -#define SPIS_STATUS_OVERREAD_Present (1UL) /*!< Error present. */ -#define SPIS_STATUS_OVERREAD_Clear (1UL) /*!< Clear on write. */ - -/* Register: SPIS_ENABLE */ -/* Description: Enable SPIS. */ - -/* Bits 2..0 : Enable or disable SPIS. */ -#define SPIS_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPIS_ENABLE_ENABLE_Msk (0x7UL << SPIS_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPIS_ENABLE_ENABLE_Disabled (0x00UL) /*!< Disabled SPIS. */ -#define SPIS_ENABLE_ENABLE_Enabled (0x02UL) /*!< Enable SPIS. */ - -/* Register: SPIS_MAXRX */ -/* Description: Maximum number of bytes in the receive buffer. */ - -/* Bits 7..0 : Maximum number of bytes in the receive buffer. */ -#define SPIS_MAXRX_MAXRX_Pos (0UL) /*!< Position of MAXRX field. */ -#define SPIS_MAXRX_MAXRX_Msk (0xFFUL << SPIS_MAXRX_MAXRX_Pos) /*!< Bit mask of MAXRX field. */ - -/* Register: SPIS_AMOUNTRX */ -/* Description: Number of bytes received in last granted transaction. */ - -/* Bits 7..0 : Number of bytes received in last granted transaction. */ -#define SPIS_AMOUNTRX_AMOUNTRX_Pos (0UL) /*!< Position of AMOUNTRX field. */ -#define SPIS_AMOUNTRX_AMOUNTRX_Msk (0xFFUL << SPIS_AMOUNTRX_AMOUNTRX_Pos) /*!< Bit mask of AMOUNTRX field. */ - -/* Register: SPIS_MAXTX */ -/* Description: Maximum number of bytes in the transmit buffer. */ - -/* Bits 7..0 : Maximum number of bytes in the transmit buffer. */ -#define SPIS_MAXTX_MAXTX_Pos (0UL) /*!< Position of MAXTX field. */ -#define SPIS_MAXTX_MAXTX_Msk (0xFFUL << SPIS_MAXTX_MAXTX_Pos) /*!< Bit mask of MAXTX field. */ - -/* Register: SPIS_AMOUNTTX */ -/* Description: Number of bytes transmitted in last granted transaction. */ - -/* Bits 7..0 : Number of bytes transmitted in last granted transaction. */ -#define SPIS_AMOUNTTX_AMOUNTTX_Pos (0UL) /*!< Position of AMOUNTTX field. */ -#define SPIS_AMOUNTTX_AMOUNTTX_Msk (0xFFUL << SPIS_AMOUNTTX_AMOUNTTX_Pos) /*!< Bit mask of AMOUNTTX field. */ - -/* Register: SPIS_CONFIG */ -/* Description: Configuration register. */ - -/* Bit 2 : Serial clock (SCK) polarity. */ -#define SPIS_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPIS_CONFIG_CPOL_Msk (0x1UL << SPIS_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPIS_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high. */ -#define SPIS_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low. */ - -/* Bit 1 : Serial clock (SCK) phase. */ -#define SPIS_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPIS_CONFIG_CPHA_Msk (0x1UL << SPIS_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPIS_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of the clock. Shift serial data on trailing edge. */ -#define SPIS_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of the clock. Shift serial data on leading edge. */ - -/* Bit 0 : Bit order. */ -#define SPIS_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPIS_CONFIG_ORDER_Msk (0x1UL << SPIS_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPIS_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit transmitted out first. */ -#define SPIS_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit transmitted out first. */ - -/* Register: SPIS_DEF */ -/* Description: Default character. */ - -/* Bits 7..0 : Default character. */ -#define SPIS_DEF_DEF_Pos (0UL) /*!< Position of DEF field. */ -#define SPIS_DEF_DEF_Msk (0xFFUL << SPIS_DEF_DEF_Pos) /*!< Bit mask of DEF field. */ - -/* Register: SPIS_ORC */ -/* Description: Over-read character. */ - -/* Bits 7..0 : Over-read character. */ -#define SPIS_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define SPIS_ORC_ORC_Msk (0xFFUL << SPIS_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - -/* Register: SPIS_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define SPIS_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define SPIS_POWER_POWER_Msk (0x1UL << SPIS_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define SPIS_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define SPIS_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: TEMP */ -/* Description: Temperature Sensor. */ - -/* Register: TEMP_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 0 : Enable interrupt on DATARDY event. */ -#define TEMP_INTENSET_DATARDY_Pos (0UL) /*!< Position of DATARDY field. */ -#define TEMP_INTENSET_DATARDY_Msk (0x1UL << TEMP_INTENSET_DATARDY_Pos) /*!< Bit mask of DATARDY field. */ -#define TEMP_INTENSET_DATARDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define TEMP_INTENSET_DATARDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define TEMP_INTENSET_DATARDY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: TEMP_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 0 : Disable interrupt on DATARDY event. */ -#define TEMP_INTENCLR_DATARDY_Pos (0UL) /*!< Position of DATARDY field. */ -#define TEMP_INTENCLR_DATARDY_Msk (0x1UL << TEMP_INTENCLR_DATARDY_Pos) /*!< Bit mask of DATARDY field. */ -#define TEMP_INTENCLR_DATARDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define TEMP_INTENCLR_DATARDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define TEMP_INTENCLR_DATARDY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: TEMP_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define TEMP_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define TEMP_POWER_POWER_Msk (0x1UL << TEMP_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define TEMP_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define TEMP_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: TIMER */ -/* Description: Timer 0. */ - -/* Register: TIMER_SHORTS */ -/* Description: Shortcuts for Timer. */ - -/* Bit 11 : Shortcut between CC[3] event and the STOP task. */ -#define TIMER_SHORTS_COMPARE3_STOP_Pos (11UL) /*!< Position of COMPARE3_STOP field. */ -#define TIMER_SHORTS_COMPARE3_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE3_STOP_Pos) /*!< Bit mask of COMPARE3_STOP field. */ -#define TIMER_SHORTS_COMPARE3_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE3_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 10 : Shortcut between CC[2] event and the STOP task. */ -#define TIMER_SHORTS_COMPARE2_STOP_Pos (10UL) /*!< Position of COMPARE2_STOP field. */ -#define TIMER_SHORTS_COMPARE2_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE2_STOP_Pos) /*!< Bit mask of COMPARE2_STOP field. */ -#define TIMER_SHORTS_COMPARE2_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE2_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 9 : Shortcut between CC[1] event and the STOP task. */ -#define TIMER_SHORTS_COMPARE1_STOP_Pos (9UL) /*!< Position of COMPARE1_STOP field. */ -#define TIMER_SHORTS_COMPARE1_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE1_STOP_Pos) /*!< Bit mask of COMPARE1_STOP field. */ -#define TIMER_SHORTS_COMPARE1_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE1_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 8 : Shortcut between CC[0] event and the STOP task. */ -#define TIMER_SHORTS_COMPARE0_STOP_Pos (8UL) /*!< Position of COMPARE0_STOP field. */ -#define TIMER_SHORTS_COMPARE0_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE0_STOP_Pos) /*!< Bit mask of COMPARE0_STOP field. */ -#define TIMER_SHORTS_COMPARE0_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE0_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 3 : Shortcut between CC[3] event and the CLEAR task. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Pos (3UL) /*!< Position of COMPARE3_CLEAR field. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE3_CLEAR_Pos) /*!< Bit mask of COMPARE3_CLEAR field. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 2 : Shortcut between CC[2] event and the CLEAR task. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Pos (2UL) /*!< Position of COMPARE2_CLEAR field. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE2_CLEAR_Pos) /*!< Bit mask of COMPARE2_CLEAR field. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 1 : Shortcut between CC[1] event and the CLEAR task. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Pos (1UL) /*!< Position of COMPARE1_CLEAR field. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE1_CLEAR_Pos) /*!< Bit mask of COMPARE1_CLEAR field. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 0 : Shortcut between CC[0] event and the CLEAR task. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Pos (0UL) /*!< Position of COMPARE0_CLEAR field. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE0_CLEAR_Pos) /*!< Bit mask of COMPARE0_CLEAR field. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Disabled (0UL) /*!< Shortcut disabled. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: TIMER_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 19 : Enable interrupt on COMPARE[3] */ -#define TIMER_INTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define TIMER_INTENSET_COMPARE3_Msk (0x1UL << TIMER_INTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define TIMER_INTENSET_COMPARE3_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENSET_COMPARE3_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENSET_COMPARE3_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 18 : Enable interrupt on COMPARE[2] */ -#define TIMER_INTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define TIMER_INTENSET_COMPARE2_Msk (0x1UL << TIMER_INTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define TIMER_INTENSET_COMPARE2_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENSET_COMPARE2_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENSET_COMPARE2_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 17 : Enable interrupt on COMPARE[1] */ -#define TIMER_INTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define TIMER_INTENSET_COMPARE1_Msk (0x1UL << TIMER_INTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define TIMER_INTENSET_COMPARE1_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENSET_COMPARE1_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENSET_COMPARE1_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 16 : Enable interrupt on COMPARE[0] */ -#define TIMER_INTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define TIMER_INTENSET_COMPARE0_Msk (0x1UL << TIMER_INTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define TIMER_INTENSET_COMPARE0_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENSET_COMPARE0_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENSET_COMPARE0_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: TIMER_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 19 : Disable interrupt on COMPARE[3] */ -#define TIMER_INTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define TIMER_INTENCLR_COMPARE3_Msk (0x1UL << TIMER_INTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define TIMER_INTENCLR_COMPARE3_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENCLR_COMPARE3_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENCLR_COMPARE3_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 18 : Disable interrupt on COMPARE[2] */ -#define TIMER_INTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define TIMER_INTENCLR_COMPARE2_Msk (0x1UL << TIMER_INTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define TIMER_INTENCLR_COMPARE2_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENCLR_COMPARE2_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENCLR_COMPARE2_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 17 : Disable interrupt on COMPARE[1] */ -#define TIMER_INTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define TIMER_INTENCLR_COMPARE1_Msk (0x1UL << TIMER_INTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define TIMER_INTENCLR_COMPARE1_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENCLR_COMPARE1_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENCLR_COMPARE1_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 16 : Disable interrupt on COMPARE[0] */ -#define TIMER_INTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define TIMER_INTENCLR_COMPARE0_Msk (0x1UL << TIMER_INTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define TIMER_INTENCLR_COMPARE0_Disabled (0UL) /*!< Interrupt disabled. */ -#define TIMER_INTENCLR_COMPARE0_Enabled (1UL) /*!< Interrupt enabled. */ -#define TIMER_INTENCLR_COMPARE0_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: TIMER_MODE */ -/* Description: Timer Mode selection. */ - -/* Bit 0 : Select Normal or Counter mode. */ -#define TIMER_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define TIMER_MODE_MODE_Msk (0x1UL << TIMER_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define TIMER_MODE_MODE_Timer (0UL) /*!< Timer in Normal mode. */ -#define TIMER_MODE_MODE_Counter (1UL) /*!< Timer in Counter mode. */ - -/* Register: TIMER_BITMODE */ -/* Description: Sets timer behaviour. */ - -/* Bits 1..0 : Sets timer behaviour ro be like the implementation of a timer with width as indicated. */ -#define TIMER_BITMODE_BITMODE_Pos (0UL) /*!< Position of BITMODE field. */ -#define TIMER_BITMODE_BITMODE_Msk (0x3UL << TIMER_BITMODE_BITMODE_Pos) /*!< Bit mask of BITMODE field. */ -#define TIMER_BITMODE_BITMODE_16Bit (0x00UL) /*!< 16-bit timer behaviour. */ -#define TIMER_BITMODE_BITMODE_08Bit (0x01UL) /*!< 8-bit timer behaviour. */ -#define TIMER_BITMODE_BITMODE_24Bit (0x02UL) /*!< 24-bit timer behaviour. */ -#define TIMER_BITMODE_BITMODE_32Bit (0x03UL) /*!< 32-bit timer behaviour. */ - -/* Register: TIMER_PRESCALER */ -/* Description: 4-bit prescaler to source clock frequency (max value 9). Source clock frequency is divided by 2^SCALE. */ - -/* Bits 3..0 : Timer PRESCALER value. Max value is 9. */ -#define TIMER_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define TIMER_PRESCALER_PRESCALER_Msk (0xFUL << TIMER_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ - -/* Register: TIMER_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define TIMER_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define TIMER_POWER_POWER_Msk (0x1UL << TIMER_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define TIMER_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define TIMER_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: TWI */ -/* Description: Two-wire interface master 0. */ - -/* Register: TWI_SHORTS */ -/* Description: Shortcuts for TWI. */ - -/* Bit 1 : Shortcut between BB event and the STOP task. */ -#define TWI_SHORTS_BB_STOP_Pos (1UL) /*!< Position of BB_STOP field. */ -#define TWI_SHORTS_BB_STOP_Msk (0x1UL << TWI_SHORTS_BB_STOP_Pos) /*!< Bit mask of BB_STOP field. */ -#define TWI_SHORTS_BB_STOP_Disabled (0UL) /*!< Shortcut disabled. */ -#define TWI_SHORTS_BB_STOP_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 0 : Shortcut between BB event and the SUSPEND task. */ -#define TWI_SHORTS_BB_SUSPEND_Pos (0UL) /*!< Position of BB_SUSPEND field. */ -#define TWI_SHORTS_BB_SUSPEND_Msk (0x1UL << TWI_SHORTS_BB_SUSPEND_Pos) /*!< Bit mask of BB_SUSPEND field. */ -#define TWI_SHORTS_BB_SUSPEND_Disabled (0UL) /*!< Shortcut disabled. */ -#define TWI_SHORTS_BB_SUSPEND_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: TWI_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 18 : Enable interrupt on SUSPENDED event. */ -#define TWI_INTENSET_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWI_INTENSET_SUSPENDED_Msk (0x1UL << TWI_INTENSET_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWI_INTENSET_SUSPENDED_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENSET_SUSPENDED_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENSET_SUSPENDED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 14 : Enable interrupt on BB event. */ -#define TWI_INTENSET_BB_Pos (14UL) /*!< Position of BB field. */ -#define TWI_INTENSET_BB_Msk (0x1UL << TWI_INTENSET_BB_Pos) /*!< Bit mask of BB field. */ -#define TWI_INTENSET_BB_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENSET_BB_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENSET_BB_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 9 : Enable interrupt on ERROR event. */ -#define TWI_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWI_INTENSET_ERROR_Msk (0x1UL << TWI_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWI_INTENSET_ERROR_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENSET_ERROR_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENSET_ERROR_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 7 : Enable interrupt on TXDSENT event. */ -#define TWI_INTENSET_TXDSENT_Pos (7UL) /*!< Position of TXDSENT field. */ -#define TWI_INTENSET_TXDSENT_Msk (0x1UL << TWI_INTENSET_TXDSENT_Pos) /*!< Bit mask of TXDSENT field. */ -#define TWI_INTENSET_TXDSENT_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENSET_TXDSENT_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENSET_TXDSENT_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 2 : Enable interrupt on READY event. */ -#define TWI_INTENSET_RXDREADY_Pos (2UL) /*!< Position of RXDREADY field. */ -#define TWI_INTENSET_RXDREADY_Msk (0x1UL << TWI_INTENSET_RXDREADY_Pos) /*!< Bit mask of RXDREADY field. */ -#define TWI_INTENSET_RXDREADY_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENSET_RXDREADY_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENSET_RXDREADY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on STOPPED event. */ -#define TWI_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWI_INTENSET_STOPPED_Msk (0x1UL << TWI_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWI_INTENSET_STOPPED_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENSET_STOPPED_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENSET_STOPPED_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: TWI_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 18 : Disable interrupt on SUSPENDED event. */ -#define TWI_INTENCLR_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWI_INTENCLR_SUSPENDED_Msk (0x1UL << TWI_INTENCLR_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWI_INTENCLR_SUSPENDED_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENCLR_SUSPENDED_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENCLR_SUSPENDED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 14 : Disable interrupt on BB event. */ -#define TWI_INTENCLR_BB_Pos (14UL) /*!< Position of BB field. */ -#define TWI_INTENCLR_BB_Msk (0x1UL << TWI_INTENCLR_BB_Pos) /*!< Bit mask of BB field. */ -#define TWI_INTENCLR_BB_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENCLR_BB_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENCLR_BB_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 9 : Disable interrupt on ERROR event. */ -#define TWI_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWI_INTENCLR_ERROR_Msk (0x1UL << TWI_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWI_INTENCLR_ERROR_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENCLR_ERROR_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENCLR_ERROR_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 7 : Disable interrupt on TXDSENT event. */ -#define TWI_INTENCLR_TXDSENT_Pos (7UL) /*!< Position of TXDSENT field. */ -#define TWI_INTENCLR_TXDSENT_Msk (0x1UL << TWI_INTENCLR_TXDSENT_Pos) /*!< Bit mask of TXDSENT field. */ -#define TWI_INTENCLR_TXDSENT_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENCLR_TXDSENT_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENCLR_TXDSENT_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 2 : Disable interrupt on RXDREADY event. */ -#define TWI_INTENCLR_RXDREADY_Pos (2UL) /*!< Position of RXDREADY field. */ -#define TWI_INTENCLR_RXDREADY_Msk (0x1UL << TWI_INTENCLR_RXDREADY_Pos) /*!< Bit mask of RXDREADY field. */ -#define TWI_INTENCLR_RXDREADY_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENCLR_RXDREADY_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENCLR_RXDREADY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on STOPPED event. */ -#define TWI_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWI_INTENCLR_STOPPED_Msk (0x1UL << TWI_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWI_INTENCLR_STOPPED_Disabled (0UL) /*!< Interrupt disabled. */ -#define TWI_INTENCLR_STOPPED_Enabled (1UL) /*!< Interrupt enabled. */ -#define TWI_INTENCLR_STOPPED_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: TWI_ERRORSRC */ -/* Description: Two-wire error source. Write error field to 1 to clear error. */ - -/* Bit 2 : NACK received after sending a data byte. */ -#define TWI_ERRORSRC_DNACK_Pos (2UL) /*!< Position of DNACK field. */ -#define TWI_ERRORSRC_DNACK_Msk (0x1UL << TWI_ERRORSRC_DNACK_Pos) /*!< Bit mask of DNACK field. */ -#define TWI_ERRORSRC_DNACK_NotPresent (0UL) /*!< Error not present. */ -#define TWI_ERRORSRC_DNACK_Present (1UL) /*!< Error present. */ -#define TWI_ERRORSRC_DNACK_Clear (1UL) /*!< Clear error on write. */ - -/* Bit 1 : NACK received after sending the address. */ -#define TWI_ERRORSRC_ANACK_Pos (1UL) /*!< Position of ANACK field. */ -#define TWI_ERRORSRC_ANACK_Msk (0x1UL << TWI_ERRORSRC_ANACK_Pos) /*!< Bit mask of ANACK field. */ -#define TWI_ERRORSRC_ANACK_NotPresent (0UL) /*!< Error not present. */ -#define TWI_ERRORSRC_ANACK_Present (1UL) /*!< Error present. */ -#define TWI_ERRORSRC_ANACK_Clear (1UL) /*!< Clear error on write. */ - -/* Bit 0 : Byte received in RXD register before read of the last received byte (data loss). */ -#define TWI_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define TWI_ERRORSRC_OVERRUN_Msk (0x1UL << TWI_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define TWI_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Error not present. */ -#define TWI_ERRORSRC_OVERRUN_Present (1UL) /*!< Error present. */ -#define TWI_ERRORSRC_OVERRUN_Clear (1UL) /*!< Clear error on write. */ - -/* Register: TWI_ENABLE */ -/* Description: Enable two-wire master. */ - -/* Bits 2..0 : Enable or disable W2M */ -#define TWI_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define TWI_ENABLE_ENABLE_Msk (0x7UL << TWI_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define TWI_ENABLE_ENABLE_Disabled (0x00UL) /*!< Disabled. */ -#define TWI_ENABLE_ENABLE_Enabled (0x05UL) /*!< Enabled. */ - -/* Register: TWI_RXD */ -/* Description: RX data register. */ - -/* Bits 7..0 : RX data from last transfer. */ -#define TWI_RXD_RXD_Pos (0UL) /*!< Position of RXD field. */ -#define TWI_RXD_RXD_Msk (0xFFUL << TWI_RXD_RXD_Pos) /*!< Bit mask of RXD field. */ - -/* Register: TWI_TXD */ -/* Description: TX data register. */ - -/* Bits 7..0 : TX data for next transfer. */ -#define TWI_TXD_TXD_Pos (0UL) /*!< Position of TXD field. */ -#define TWI_TXD_TXD_Msk (0xFFUL << TWI_TXD_TXD_Pos) /*!< Bit mask of TXD field. */ - -/* Register: TWI_FREQUENCY */ -/* Description: Two-wire frequency. */ - -/* Bits 31..0 : Two-wire master clock frequency. */ -#define TWI_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define TWI_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << TWI_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define TWI_FREQUENCY_FREQUENCY_K100 (0x01980000UL) /*!< 100 kbps. */ -#define TWI_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps. */ -#define TWI_FREQUENCY_FREQUENCY_K400 (0x06680000UL) /*!< 400 kbps (actual rate 410.256 kbps). */ - -/* Register: TWI_ADDRESS */ -/* Description: Address used in the two-wire transfer. */ - -/* Bits 6..0 : Two-wire address. */ -#define TWI_ADDRESS_ADDRESS_Pos (0UL) /*!< Position of ADDRESS field. */ -#define TWI_ADDRESS_ADDRESS_Msk (0x7FUL << TWI_ADDRESS_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ - -/* Register: TWI_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define TWI_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define TWI_POWER_POWER_Msk (0x1UL << TWI_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define TWI_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define TWI_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: UART */ -/* Description: Universal Asynchronous Receiver/Transmitter. */ - -/* Register: UART_SHORTS */ -/* Description: Shortcuts for UART. */ - -/* Bit 4 : Shortcut between NCTS event and STOPRX task. */ -#define UART_SHORTS_NCTS_STOPRX_Pos (4UL) /*!< Position of NCTS_STOPRX field. */ -#define UART_SHORTS_NCTS_STOPRX_Msk (0x1UL << UART_SHORTS_NCTS_STOPRX_Pos) /*!< Bit mask of NCTS_STOPRX field. */ -#define UART_SHORTS_NCTS_STOPRX_Disabled (0UL) /*!< Shortcut disabled. */ -#define UART_SHORTS_NCTS_STOPRX_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Bit 3 : Shortcut between CTS event and STARTRX task. */ -#define UART_SHORTS_CTS_STARTRX_Pos (3UL) /*!< Position of CTS_STARTRX field. */ -#define UART_SHORTS_CTS_STARTRX_Msk (0x1UL << UART_SHORTS_CTS_STARTRX_Pos) /*!< Bit mask of CTS_STARTRX field. */ -#define UART_SHORTS_CTS_STARTRX_Disabled (0UL) /*!< Shortcut disabled. */ -#define UART_SHORTS_CTS_STARTRX_Enabled (1UL) /*!< Shortcut enabled. */ - -/* Register: UART_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 17 : Enable interrupt on RXTO event. */ -#define UART_INTENSET_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UART_INTENSET_RXTO_Msk (0x1UL << UART_INTENSET_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UART_INTENSET_RXTO_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENSET_RXTO_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENSET_RXTO_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 9 : Enable interrupt on ERROR event. */ -#define UART_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UART_INTENSET_ERROR_Msk (0x1UL << UART_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UART_INTENSET_ERROR_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENSET_ERROR_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENSET_ERROR_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 7 : Enable interrupt on TXRDY event. */ -#define UART_INTENSET_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UART_INTENSET_TXDRDY_Msk (0x1UL << UART_INTENSET_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UART_INTENSET_TXDRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENSET_TXDRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENSET_TXDRDY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 2 : Enable interrupt on RXRDY event. */ -#define UART_INTENSET_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UART_INTENSET_RXDRDY_Msk (0x1UL << UART_INTENSET_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UART_INTENSET_RXDRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENSET_RXDRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENSET_RXDRDY_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 1 : Enable interrupt on NCTS event. */ -#define UART_INTENSET_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UART_INTENSET_NCTS_Msk (0x1UL << UART_INTENSET_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UART_INTENSET_NCTS_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENSET_NCTS_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENSET_NCTS_Set (1UL) /*!< Enable interrupt on write. */ - -/* Bit 0 : Enable interrupt on CTS event. */ -#define UART_INTENSET_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UART_INTENSET_CTS_Msk (0x1UL << UART_INTENSET_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UART_INTENSET_CTS_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENSET_CTS_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENSET_CTS_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: UART_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 17 : Disable interrupt on RXTO event. */ -#define UART_INTENCLR_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UART_INTENCLR_RXTO_Msk (0x1UL << UART_INTENCLR_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UART_INTENCLR_RXTO_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENCLR_RXTO_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENCLR_RXTO_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 9 : Disable interrupt on ERROR event. */ -#define UART_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UART_INTENCLR_ERROR_Msk (0x1UL << UART_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UART_INTENCLR_ERROR_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENCLR_ERROR_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENCLR_ERROR_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 7 : Disable interrupt on TXRDY event. */ -#define UART_INTENCLR_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UART_INTENCLR_TXDRDY_Msk (0x1UL << UART_INTENCLR_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UART_INTENCLR_TXDRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENCLR_TXDRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENCLR_TXDRDY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 2 : Disable interrupt on RXRDY event. */ -#define UART_INTENCLR_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UART_INTENCLR_RXDRDY_Msk (0x1UL << UART_INTENCLR_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UART_INTENCLR_RXDRDY_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENCLR_RXDRDY_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENCLR_RXDRDY_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 1 : Disable interrupt on NCTS event. */ -#define UART_INTENCLR_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UART_INTENCLR_NCTS_Msk (0x1UL << UART_INTENCLR_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UART_INTENCLR_NCTS_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENCLR_NCTS_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENCLR_NCTS_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Bit 0 : Disable interrupt on CTS event. */ -#define UART_INTENCLR_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UART_INTENCLR_CTS_Msk (0x1UL << UART_INTENCLR_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UART_INTENCLR_CTS_Disabled (0UL) /*!< Interrupt disabled. */ -#define UART_INTENCLR_CTS_Enabled (1UL) /*!< Interrupt enabled. */ -#define UART_INTENCLR_CTS_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: UART_ERRORSRC */ -/* Description: Error source. Write error field to 1 to clear error. */ - -/* Bit 3 : The serial data input is '0' for longer than the length of a data frame. */ -#define UART_ERRORSRC_BREAK_Pos (3UL) /*!< Position of BREAK field. */ -#define UART_ERRORSRC_BREAK_Msk (0x1UL << UART_ERRORSRC_BREAK_Pos) /*!< Bit mask of BREAK field. */ -#define UART_ERRORSRC_BREAK_NotPresent (0UL) /*!< Error not present. */ -#define UART_ERRORSRC_BREAK_Present (1UL) /*!< Error present. */ -#define UART_ERRORSRC_BREAK_Clear (1UL) /*!< Clear error on write. */ - -/* Bit 2 : A valid stop bit is not detected on the serial data input after all bits in a character have been received. */ -#define UART_ERRORSRC_FRAMING_Pos (2UL) /*!< Position of FRAMING field. */ -#define UART_ERRORSRC_FRAMING_Msk (0x1UL << UART_ERRORSRC_FRAMING_Pos) /*!< Bit mask of FRAMING field. */ -#define UART_ERRORSRC_FRAMING_NotPresent (0UL) /*!< Error not present. */ -#define UART_ERRORSRC_FRAMING_Present (1UL) /*!< Error present. */ -#define UART_ERRORSRC_FRAMING_Clear (1UL) /*!< Clear error on write. */ - -/* Bit 1 : A character with bad parity is received. Only checked if HW parity control is enabled. */ -#define UART_ERRORSRC_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UART_ERRORSRC_PARITY_Msk (0x1UL << UART_ERRORSRC_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UART_ERRORSRC_PARITY_NotPresent (0UL) /*!< Error not present. */ -#define UART_ERRORSRC_PARITY_Present (1UL) /*!< Error present. */ -#define UART_ERRORSRC_PARITY_Clear (1UL) /*!< Clear error on write. */ - -/* Bit 0 : A start bit is received while the previous data still lies in RXD. (Data loss). */ -#define UART_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define UART_ERRORSRC_OVERRUN_Msk (0x1UL << UART_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define UART_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Error not present. */ -#define UART_ERRORSRC_OVERRUN_Present (1UL) /*!< Error present. */ -#define UART_ERRORSRC_OVERRUN_Clear (1UL) /*!< Clear error on write. */ - -/* Register: UART_ENABLE */ -/* Description: Enable UART and acquire IOs. */ - -/* Bits 2..0 : Enable or disable UART and acquire IOs. */ -#define UART_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define UART_ENABLE_ENABLE_Msk (0x7UL << UART_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define UART_ENABLE_ENABLE_Disabled (0x00UL) /*!< UART disabled. */ -#define UART_ENABLE_ENABLE_Enabled (0x04UL) /*!< UART enabled. */ - -/* Register: UART_RXD */ -/* Description: RXD register. On read action the buffer pointer is displaced. Once read the character is consumed. If read when no character available, the UART will stop working. */ - -/* Bits 7..0 : RX data from previous transfer. Double buffered. */ -#define UART_RXD_RXD_Pos (0UL) /*!< Position of RXD field. */ -#define UART_RXD_RXD_Msk (0xFFUL << UART_RXD_RXD_Pos) /*!< Bit mask of RXD field. */ - -/* Register: UART_TXD */ -/* Description: TXD register. */ - -/* Bits 7..0 : TX data for transfer. */ -#define UART_TXD_TXD_Pos (0UL) /*!< Position of TXD field. */ -#define UART_TXD_TXD_Msk (0xFFUL << UART_TXD_TXD_Pos) /*!< Bit mask of TXD field. */ - -/* Register: UART_BAUDRATE */ -/* Description: UART Baudrate. */ - -/* Bits 31..0 : UART baudrate. */ -#define UART_BAUDRATE_BAUDRATE_Pos (0UL) /*!< Position of BAUDRATE field. */ -#define UART_BAUDRATE_BAUDRATE_Msk (0xFFFFFFFFUL << UART_BAUDRATE_BAUDRATE_Pos) /*!< Bit mask of BAUDRATE field. */ -#define UART_BAUDRATE_BAUDRATE_Baud1200 (0x0004F000UL) /*!< 1200 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud2400 (0x0009D000UL) /*!< 2400 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud4800 (0x0013B000UL) /*!< 4800 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud9600 (0x00275000UL) /*!< 9600 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud14400 (0x003B0000UL) /*!< 14400 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud19200 (0x004EA000UL) /*!< 19200 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud28800 (0x0075F000UL) /*!< 28800 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud31250 (0x00800000UL) /*!< 31250 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud38400 (0x009D5000UL) /*!< 38400 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud56000 (0x00E50000UL) /*!< 56000 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud57600 (0x00EBF000UL) /*!< 57600 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud76800 (0x013A9000UL) /*!< 76800 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud115200 (0x01D7E000UL) /*!< 115200 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud230400 (0x03AFB000UL) /*!< 230400 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud250000 (0x04000000UL) /*!< 250000 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud460800 (0x075F7000UL) /*!< 460800 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud921600 (0x0EBED000UL) /*!< 921600 baud. */ -#define UART_BAUDRATE_BAUDRATE_Baud1M (0x10000000UL) /*!< 1M baud. */ - -/* Register: UART_CONFIG */ -/* Description: Configuration of parity and hardware flow control register. */ - -/* Bits 3..1 : Include parity bit. */ -#define UART_CONFIG_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UART_CONFIG_PARITY_Msk (0x7UL << UART_CONFIG_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UART_CONFIG_PARITY_Excluded (0UL) /*!< Parity bit excluded. */ -#define UART_CONFIG_PARITY_Included (7UL) /*!< Parity bit included. */ - -/* Bit 0 : Hardware flow control. */ -#define UART_CONFIG_HWFC_Pos (0UL) /*!< Position of HWFC field. */ -#define UART_CONFIG_HWFC_Msk (0x1UL << UART_CONFIG_HWFC_Pos) /*!< Bit mask of HWFC field. */ -#define UART_CONFIG_HWFC_Disabled (0UL) /*!< Hardware flow control disabled. */ -#define UART_CONFIG_HWFC_Enabled (1UL) /*!< Hardware flow control enabled. */ - -/* Register: UART_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define UART_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define UART_POWER_POWER_Msk (0x1UL << UART_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define UART_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define UART_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/* Peripheral: UICR */ -/* Description: User Information Configuration. */ - -/* Register: UICR_RBPCONF */ -/* Description: Readback protection configuration. */ - -/* Bits 15..8 : Readback protect all code in the device. */ -#define UICR_RBPCONF_PALL_Pos (8UL) /*!< Position of PALL field. */ -#define UICR_RBPCONF_PALL_Msk (0xFFUL << UICR_RBPCONF_PALL_Pos) /*!< Bit mask of PALL field. */ -#define UICR_RBPCONF_PALL_Enabled (0x00UL) /*!< Enabled. */ -#define UICR_RBPCONF_PALL_Disabled (0xFFUL) /*!< Disabled. */ - -/* Bits 7..0 : Readback protect region 0. Will be ignored if pre-programmed factory code is present on the chip. */ -#define UICR_RBPCONF_PR0_Pos (0UL) /*!< Position of PR0 field. */ -#define UICR_RBPCONF_PR0_Msk (0xFFUL << UICR_RBPCONF_PR0_Pos) /*!< Bit mask of PR0 field. */ -#define UICR_RBPCONF_PR0_Enabled (0x00UL) /*!< Enabled. */ -#define UICR_RBPCONF_PR0_Disabled (0xFFUL) /*!< Disabled. */ - -/* Register: UICR_XTALFREQ */ -/* Description: Reset value for CLOCK XTALFREQ register. */ - -/* Bits 7..0 : Reset value for CLOCK XTALFREQ register. */ -#define UICR_XTALFREQ_XTALFREQ_Pos (0UL) /*!< Position of XTALFREQ field. */ -#define UICR_XTALFREQ_XTALFREQ_Msk (0xFFUL << UICR_XTALFREQ_XTALFREQ_Pos) /*!< Bit mask of XTALFREQ field. */ -#define UICR_XTALFREQ_XTALFREQ_32MHz (0x00UL) /*!< 32MHz Xtal is used. */ -#define UICR_XTALFREQ_XTALFREQ_16MHz (0xFFUL) /*!< 16MHz Xtal is used. */ - -/* Register: UICR_FWID */ -/* Description: Firmware ID. */ - -/* Bits 15..0 : Identification number for the firmware loaded into the chip. */ -#define UICR_FWID_FWID_Pos (0UL) /*!< Position of FWID field. */ -#define UICR_FWID_FWID_Msk (0xFFFFUL << UICR_FWID_FWID_Pos) /*!< Bit mask of FWID field. */ - - -/* Peripheral: WDT */ -/* Description: Watchdog Timer. */ - -/* Register: WDT_INTENSET */ -/* Description: Interrupt enable set register. */ - -/* Bit 0 : Enable interrupt on TIMEOUT event. */ -#define WDT_INTENSET_TIMEOUT_Pos (0UL) /*!< Position of TIMEOUT field. */ -#define WDT_INTENSET_TIMEOUT_Msk (0x1UL << WDT_INTENSET_TIMEOUT_Pos) /*!< Bit mask of TIMEOUT field. */ -#define WDT_INTENSET_TIMEOUT_Disabled (0UL) /*!< Interrupt disabled. */ -#define WDT_INTENSET_TIMEOUT_Enabled (1UL) /*!< Interrupt enabled. */ -#define WDT_INTENSET_TIMEOUT_Set (1UL) /*!< Enable interrupt on write. */ - -/* Register: WDT_INTENCLR */ -/* Description: Interrupt enable clear register. */ - -/* Bit 0 : Disable interrupt on TIMEOUT event. */ -#define WDT_INTENCLR_TIMEOUT_Pos (0UL) /*!< Position of TIMEOUT field. */ -#define WDT_INTENCLR_TIMEOUT_Msk (0x1UL << WDT_INTENCLR_TIMEOUT_Pos) /*!< Bit mask of TIMEOUT field. */ -#define WDT_INTENCLR_TIMEOUT_Disabled (0UL) /*!< Interrupt disabled. */ -#define WDT_INTENCLR_TIMEOUT_Enabled (1UL) /*!< Interrupt enabled. */ -#define WDT_INTENCLR_TIMEOUT_Clear (1UL) /*!< Disable interrupt on write. */ - -/* Register: WDT_RUNSTATUS */ -/* Description: Watchdog running status. */ - -/* Bit 0 : Watchdog running status. */ -#define WDT_RUNSTATUS_RUNSTATUS_Pos (0UL) /*!< Position of RUNSTATUS field. */ -#define WDT_RUNSTATUS_RUNSTATUS_Msk (0x1UL << WDT_RUNSTATUS_RUNSTATUS_Pos) /*!< Bit mask of RUNSTATUS field. */ -#define WDT_RUNSTATUS_RUNSTATUS_NotRunning (0UL) /*!< Watchdog timer is not running. */ -#define WDT_RUNSTATUS_RUNSTATUS_Running (1UL) /*!< Watchdog timer is running. */ - -/* Register: WDT_REQSTATUS */ -/* Description: Request status. */ - -/* Bit 7 : Request status for RR[7]. */ -#define WDT_REQSTATUS_RR7_Pos (7UL) /*!< Position of RR7 field. */ -#define WDT_REQSTATUS_RR7_Msk (0x1UL << WDT_REQSTATUS_RR7_Pos) /*!< Bit mask of RR7 field. */ -#define WDT_REQSTATUS_RR7_DisabledOrRequested (0UL) /*!< RR[7] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR7_EnabledAndUnrequested (1UL) /*!< RR[7] register is enabled and has not jet requested. */ - -/* Bit 6 : Request status for RR[6]. */ -#define WDT_REQSTATUS_RR6_Pos (6UL) /*!< Position of RR6 field. */ -#define WDT_REQSTATUS_RR6_Msk (0x1UL << WDT_REQSTATUS_RR6_Pos) /*!< Bit mask of RR6 field. */ -#define WDT_REQSTATUS_RR6_DisabledOrRequested (0UL) /*!< RR[6] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR6_EnabledAndUnrequested (1UL) /*!< RR[6] register is enabled and has not jet requested. */ - -/* Bit 5 : Request status for RR[5]. */ -#define WDT_REQSTATUS_RR5_Pos (5UL) /*!< Position of RR5 field. */ -#define WDT_REQSTATUS_RR5_Msk (0x1UL << WDT_REQSTATUS_RR5_Pos) /*!< Bit mask of RR5 field. */ -#define WDT_REQSTATUS_RR5_DisabledOrRequested (0UL) /*!< RR[5] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR5_EnabledAndUnrequested (1UL) /*!< RR[5] register is enabled and has not jet requested. */ - -/* Bit 4 : Request status for RR[4]. */ -#define WDT_REQSTATUS_RR4_Pos (4UL) /*!< Position of RR4 field. */ -#define WDT_REQSTATUS_RR4_Msk (0x1UL << WDT_REQSTATUS_RR4_Pos) /*!< Bit mask of RR4 field. */ -#define WDT_REQSTATUS_RR4_DisabledOrRequested (0UL) /*!< RR[4] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR4_EnabledAndUnrequested (1UL) /*!< RR[4] register is enabled and has not jet requested. */ - -/* Bit 3 : Request status for RR[3]. */ -#define WDT_REQSTATUS_RR3_Pos (3UL) /*!< Position of RR3 field. */ -#define WDT_REQSTATUS_RR3_Msk (0x1UL << WDT_REQSTATUS_RR3_Pos) /*!< Bit mask of RR3 field. */ -#define WDT_REQSTATUS_RR3_DisabledOrRequested (0UL) /*!< RR[3] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR3_EnabledAndUnrequested (1UL) /*!< RR[3] register is enabled and has not jet requested. */ - -/* Bit 2 : Request status for RR[2]. */ -#define WDT_REQSTATUS_RR2_Pos (2UL) /*!< Position of RR2 field. */ -#define WDT_REQSTATUS_RR2_Msk (0x1UL << WDT_REQSTATUS_RR2_Pos) /*!< Bit mask of RR2 field. */ -#define WDT_REQSTATUS_RR2_DisabledOrRequested (0UL) /*!< RR[2] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR2_EnabledAndUnrequested (1UL) /*!< RR[2] register is enabled and has not jet requested. */ - -/* Bit 1 : Request status for RR[1]. */ -#define WDT_REQSTATUS_RR1_Pos (1UL) /*!< Position of RR1 field. */ -#define WDT_REQSTATUS_RR1_Msk (0x1UL << WDT_REQSTATUS_RR1_Pos) /*!< Bit mask of RR1 field. */ -#define WDT_REQSTATUS_RR1_DisabledOrRequested (0UL) /*!< RR[1] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR1_EnabledAndUnrequested (1UL) /*!< RR[1] register is enabled and has not jet requested. */ - -/* Bit 0 : Request status for RR[0]. */ -#define WDT_REQSTATUS_RR0_Pos (0UL) /*!< Position of RR0 field. */ -#define WDT_REQSTATUS_RR0_Msk (0x1UL << WDT_REQSTATUS_RR0_Pos) /*!< Bit mask of RR0 field. */ -#define WDT_REQSTATUS_RR0_DisabledOrRequested (0UL) /*!< RR[0] register is not enabled or has already requested reload. */ -#define WDT_REQSTATUS_RR0_EnabledAndUnrequested (1UL) /*!< RR[0] register is enabled and has not jet requested. */ - -/* Register: WDT_RREN */ -/* Description: Reload request enable. */ - -/* Bit 7 : Enable or disable RR[7] register. */ -#define WDT_RREN_RR7_Pos (7UL) /*!< Position of RR7 field. */ -#define WDT_RREN_RR7_Msk (0x1UL << WDT_RREN_RR7_Pos) /*!< Bit mask of RR7 field. */ -#define WDT_RREN_RR7_Disabled (0UL) /*!< RR[7] register is disabled. */ -#define WDT_RREN_RR7_Enabled (1UL) /*!< RR[7] register is enabled. */ - -/* Bit 6 : Enable or disable RR[6] register. */ -#define WDT_RREN_RR6_Pos (6UL) /*!< Position of RR6 field. */ -#define WDT_RREN_RR6_Msk (0x1UL << WDT_RREN_RR6_Pos) /*!< Bit mask of RR6 field. */ -#define WDT_RREN_RR6_Disabled (0UL) /*!< RR[6] register is disabled. */ -#define WDT_RREN_RR6_Enabled (1UL) /*!< RR[6] register is enabled. */ - -/* Bit 5 : Enable or disable RR[5] register. */ -#define WDT_RREN_RR5_Pos (5UL) /*!< Position of RR5 field. */ -#define WDT_RREN_RR5_Msk (0x1UL << WDT_RREN_RR5_Pos) /*!< Bit mask of RR5 field. */ -#define WDT_RREN_RR5_Disabled (0UL) /*!< RR[5] register is disabled. */ -#define WDT_RREN_RR5_Enabled (1UL) /*!< RR[5] register is enabled. */ - -/* Bit 4 : Enable or disable RR[4] register. */ -#define WDT_RREN_RR4_Pos (4UL) /*!< Position of RR4 field. */ -#define WDT_RREN_RR4_Msk (0x1UL << WDT_RREN_RR4_Pos) /*!< Bit mask of RR4 field. */ -#define WDT_RREN_RR4_Disabled (0UL) /*!< RR[4] register is disabled. */ -#define WDT_RREN_RR4_Enabled (1UL) /*!< RR[4] register is enabled. */ - -/* Bit 3 : Enable or disable RR[3] register. */ -#define WDT_RREN_RR3_Pos (3UL) /*!< Position of RR3 field. */ -#define WDT_RREN_RR3_Msk (0x1UL << WDT_RREN_RR3_Pos) /*!< Bit mask of RR3 field. */ -#define WDT_RREN_RR3_Disabled (0UL) /*!< RR[3] register is disabled. */ -#define WDT_RREN_RR3_Enabled (1UL) /*!< RR[3] register is enabled. */ - -/* Bit 2 : Enable or disable RR[2] register. */ -#define WDT_RREN_RR2_Pos (2UL) /*!< Position of RR2 field. */ -#define WDT_RREN_RR2_Msk (0x1UL << WDT_RREN_RR2_Pos) /*!< Bit mask of RR2 field. */ -#define WDT_RREN_RR2_Disabled (0UL) /*!< RR[2] register is disabled. */ -#define WDT_RREN_RR2_Enabled (1UL) /*!< RR[2] register is enabled. */ - -/* Bit 1 : Enable or disable RR[1] register. */ -#define WDT_RREN_RR1_Pos (1UL) /*!< Position of RR1 field. */ -#define WDT_RREN_RR1_Msk (0x1UL << WDT_RREN_RR1_Pos) /*!< Bit mask of RR1 field. */ -#define WDT_RREN_RR1_Disabled (0UL) /*!< RR[1] register is disabled. */ -#define WDT_RREN_RR1_Enabled (1UL) /*!< RR[1] register is enabled. */ - -/* Bit 0 : Enable or disable RR[0] register. */ -#define WDT_RREN_RR0_Pos (0UL) /*!< Position of RR0 field. */ -#define WDT_RREN_RR0_Msk (0x1UL << WDT_RREN_RR0_Pos) /*!< Bit mask of RR0 field. */ -#define WDT_RREN_RR0_Disabled (0UL) /*!< RR[0] register is disabled. */ -#define WDT_RREN_RR0_Enabled (1UL) /*!< RR[0] register is enabled. */ - -/* Register: WDT_CONFIG */ -/* Description: Configuration register. */ - -/* Bit 3 : Configure the watchdog to pause or not while the CPU is halted by the debugger. */ -#define WDT_CONFIG_HALT_Pos (3UL) /*!< Position of HALT field. */ -#define WDT_CONFIG_HALT_Msk (0x1UL << WDT_CONFIG_HALT_Pos) /*!< Bit mask of HALT field. */ -#define WDT_CONFIG_HALT_Pause (0UL) /*!< Pause watchdog while the CPU is halted by the debugger. */ -#define WDT_CONFIG_HALT_Run (1UL) /*!< Do not pause watchdog while the CPU is halted by the debugger. */ - -/* Bit 0 : Configure the watchdog to pause or not while the CPU is sleeping. */ -#define WDT_CONFIG_SLEEP_Pos (0UL) /*!< Position of SLEEP field. */ -#define WDT_CONFIG_SLEEP_Msk (0x1UL << WDT_CONFIG_SLEEP_Pos) /*!< Bit mask of SLEEP field. */ -#define WDT_CONFIG_SLEEP_Pause (0UL) /*!< Pause watchdog while the CPU is asleep. */ -#define WDT_CONFIG_SLEEP_Run (1UL) /*!< Do not pause watchdog while the CPU is asleep. */ - -/* Register: WDT_RR */ -/* Description: Reload requests registers. */ - -/* Bits 31..0 : Reload register. */ -#define WDT_RR_RR_Pos (0UL) /*!< Position of RR field. */ -#define WDT_RR_RR_Msk (0xFFFFFFFFUL << WDT_RR_RR_Pos) /*!< Bit mask of RR field. */ -#define WDT_RR_RR_Reload (0x6E524635UL) /*!< Value to request a reload of the watchdog timer. */ - -/* Register: WDT_POWER */ -/* Description: Peripheral power control. */ - -/* Bit 0 : Peripheral power control. */ -#define WDT_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define WDT_POWER_POWER_Msk (0x1UL << WDT_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define WDT_POWER_POWER_Disabled (0UL) /*!< Module power disabled. */ -#define WDT_POWER_POWER_Enabled (1UL) /*!< Module power enabled. */ - - -/*lint --flb "Leave library region" */ -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_deprecated.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_deprecated.h deleted file mode 100644 index 189d649..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_deprecated.h +++ /dev/null @@ -1,451 +0,0 @@ -/* - -Copyright (c) 2010 - 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 NRF51_DEPRECATED_H -#define NRF51_DEPRECATED_H - -/*lint ++flb "Enter library region */ - -/* This file is given to prevent your SW from not compiling with the updates made to nrf51.h and - * nrf51_bitfields.h. The macros defined in this file were available previously. Do not use these - * macros on purpose. Use the ones defined in nrf51.h and nrf51_bitfields.h instead. - */ - -/* NVMC */ -/* The register ERASEPROTECTEDPAGE is called ERASEPCR0 in the documentation. */ -#define ERASEPROTECTEDPAGE ERASEPCR0 - - -/* LPCOMP */ -/* The interrupt ISR was renamed. Adding old name to the macros. */ -#define LPCOMP_COMP_IRQHandler LPCOMP_IRQHandler -#define LPCOMP_COMP_IRQn LPCOMP_IRQn -/* Corrected typo in RESULT register. */ -#define LPCOMP_RESULT_RESULT_Bellow LPCOMP_RESULT_RESULT_Below - - -/* MPU */ -/* The field MPU.PERR0.LPCOMP_COMP was renamed. Added into deprecated in case somebody was using the macros defined for it. */ -#define MPU_PERR0_LPCOMP_COMP_Pos MPU_PERR0_LPCOMP_Pos -#define MPU_PERR0_LPCOMP_COMP_Msk MPU_PERR0_LPCOMP_Msk -#define MPU_PERR0_LPCOMP_COMP_InRegion1 MPU_PERR0_LPCOMP_InRegion1 -#define MPU_PERR0_LPCOMP_COMP_InRegion0 MPU_PERR0_LPCOMP_InRegion0 - - -/* POWER */ -/* The field POWER.RAMON.OFFRAM3 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */ -#define POWER_RAMON_OFFRAM3_Pos (19UL) -#define POWER_RAMON_OFFRAM3_Msk (0x1UL << POWER_RAMON_OFFRAM3_Pos) -#define POWER_RAMON_OFFRAM3_RAM3Off (0UL) -#define POWER_RAMON_OFFRAM3_RAM3On (1UL) -/* The field POWER.RAMON.OFFRAM2 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */ -#define POWER_RAMON_OFFRAM2_Pos (18UL) -#define POWER_RAMON_OFFRAM2_Msk (0x1UL << POWER_RAMON_OFFRAM2_Pos) -#define POWER_RAMON_OFFRAM2_RAM2Off (0UL) -#define POWER_RAMON_OFFRAM2_RAM2On (1UL) -/* The field POWER.RAMON.ONRAM3 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */ -#define POWER_RAMON_ONRAM3_Pos (3UL) -#define POWER_RAMON_ONRAM3_Msk (0x1UL << POWER_RAMON_ONRAM3_Pos) -#define POWER_RAMON_ONRAM3_RAM3Off (0UL) -#define POWER_RAMON_ONRAM3_RAM3On (1UL) -/* The field POWER.RAMON.ONRAM2 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */ -#define POWER_RAMON_ONRAM2_Pos (2UL) -#define POWER_RAMON_ONRAM2_Msk (0x1UL << POWER_RAMON_ONRAM2_Pos) -#define POWER_RAMON_ONRAM2_RAM2Off (0UL) -#define POWER_RAMON_ONRAM2_RAM2On (1UL) - - -/* RADIO */ -/* The enumerated value RADIO.TXPOWER.TXPOWER.Neg40dBm was renamed. Added into deprecated with the new macro name. */ -#define RADIO_TXPOWER_TXPOWER_Neg40dBm RADIO_TXPOWER_TXPOWER_Neg30dBm -/* The name of the field SKIPADDR was corrected. Old macros added for compatibility. */ -#define RADIO_CRCCNF_SKIP_ADDR_Pos RADIO_CRCCNF_SKIPADDR_Pos -#define RADIO_CRCCNF_SKIP_ADDR_Msk RADIO_CRCCNF_SKIPADDR_Msk -#define RADIO_CRCCNF_SKIP_ADDR_Include RADIO_CRCCNF_SKIPADDR_Include -#define RADIO_CRCCNF_SKIP_ADDR_Skip RADIO_CRCCNF_SKIPADDR_Skip -/* The name of the field PLLLOCK was corrected. Old macros added for compatibility. */ -#define RADIO_TEST_PLL_LOCK_Pos RADIO_TEST_PLLLOCK_Pos -#define RADIO_TEST_PLL_LOCK_Msk RADIO_TEST_PLLLOCK_Msk -#define RADIO_TEST_PLL_LOCK_Disabled RADIO_TEST_PLLLOCK_Disabled -#define RADIO_TEST_PLL_LOCK_Enabled RADIO_TEST_PLLLOCK_Enabled -/* The name of the field CONSTCARRIER was corrected. Old macros added for compatibility. */ -#define RADIO_TEST_CONST_CARRIER_Pos RADIO_TEST_CONSTCARRIER_Pos -#define RADIO_TEST_CONST_CARRIER_Msk RADIO_TEST_CONSTCARRIER_Msk -#define RADIO_TEST_CONST_CARRIER_Disabled RADIO_TEST_CONSTCARRIER_Disabled -#define RADIO_TEST_CONST_CARRIER_Enabled RADIO_TEST_CONSTCARRIER_Enabled - - -/* FICR */ -/* The registers FICR.SIZERAMBLOCK0, FICR.SIZERAMBLOCK1, FICR.SIZERAMBLOCK2 and FICR.SIZERAMBLOCK3 were renamed into an array. */ -#define SIZERAMBLOCK0 SIZERAMBLOCKS -#define SIZERAMBLOCK1 SIZERAMBLOCKS -#define SIZERAMBLOCK2 SIZERAMBLOCK[2] /*!< Note that this macro will disapear when SIZERAMBLOCK array is eliminated. SIZERAMBLOCK is a deprecated array. */ -#define SIZERAMBLOCK3 SIZERAMBLOCK[3] /*!< Note that this macro will disapear when SIZERAMBLOCK array is eliminated. SIZERAMBLOCK is a deprecated array. */ -/* The registers FICR.DEVICEID0 and FICR.DEVICEID1 were renamed into an array. */ -#define DEVICEID0 DEVICEID[0] -#define DEVICEID1 DEVICEID[1] -/* The registers FICR.ER0, FICR.ER1, FICR.ER2 and FICR.ER3 were renamed into an array. */ -#define ER0 ER[0] -#define ER1 ER[1] -#define ER2 ER[2] -#define ER3 ER[3] -/* The registers FICR.IR0, FICR.IR1, FICR.IR2 and FICR.IR3 were renamed into an array. */ -#define IR0 IR[0] -#define IR1 IR[1] -#define IR2 IR[2] -#define IR3 IR[3] -/* The registers FICR.DEVICEADDR0 and FICR.DEVICEADDR1 were renamed into an array. */ -#define DEVICEADDR0 DEVICEADDR[0] -#define DEVICEADDR1 DEVICEADDR[1] - - -/* PPI */ -/* The tasks PPI.TASKS_CHGxEN and PPI.TASKS_CHGxDIS were renamed into an array of structs. */ -#define TASKS_CHG0EN TASKS_CHG[0].EN -#define TASKS_CHG0DIS TASKS_CHG[0].DIS -#define TASKS_CHG1EN TASKS_CHG[1].EN -#define TASKS_CHG1DIS TASKS_CHG[1].DIS -#define TASKS_CHG2EN TASKS_CHG[2].EN -#define TASKS_CHG2DIS TASKS_CHG[2].DIS -#define TASKS_CHG3EN TASKS_CHG[3].EN -#define TASKS_CHG3DIS TASKS_CHG[3].DIS -/* The registers PPI.CHx_EEP and PPI.CHx_TEP were renamed into an array of structs. */ -#define CH0_EEP CH[0].EEP -#define CH0_TEP CH[0].TEP -#define CH1_EEP CH[1].EEP -#define CH1_TEP CH[1].TEP -#define CH2_EEP CH[2].EEP -#define CH2_TEP CH[2].TEP -#define CH3_EEP CH[3].EEP -#define CH3_TEP CH[3].TEP -#define CH4_EEP CH[4].EEP -#define CH4_TEP CH[4].TEP -#define CH5_EEP CH[5].EEP -#define CH5_TEP CH[5].TEP -#define CH6_EEP CH[6].EEP -#define CH6_TEP CH[6].TEP -#define CH7_EEP CH[7].EEP -#define CH7_TEP CH[7].TEP -#define CH8_EEP CH[8].EEP -#define CH8_TEP CH[8].TEP -#define CH9_EEP CH[9].EEP -#define CH9_TEP CH[9].TEP -#define CH10_EEP CH[10].EEP -#define CH10_TEP CH[10].TEP -#define CH11_EEP CH[11].EEP -#define CH11_TEP CH[11].TEP -#define CH12_EEP CH[12].EEP -#define CH12_TEP CH[12].TEP -#define CH13_EEP CH[13].EEP -#define CH13_TEP CH[13].TEP -#define CH14_EEP CH[14].EEP -#define CH14_TEP CH[14].TEP -#define CH15_EEP CH[15].EEP -#define CH15_TEP CH[15].TEP -/* The registers PPI.CHG0, PPI.CHG1, PPI.CHG2 and PPI.CHG3 were renamed into an array. */ -#define CHG0 CHG[0] -#define CHG1 CHG[1] -#define CHG2 CHG[2] -#define CHG3 CHG[3] -/* All bitfield macros for the CHGx registers therefore changed name. */ -#define PPI_CHG0_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG0_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG0_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG0_CH15_Included PPI_CHG_CH15_Included -#define PPI_CHG0_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG0_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG0_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG0_CH14_Included PPI_CHG_CH14_Included -#define PPI_CHG0_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG0_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG0_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG0_CH13_Included PPI_CHG_CH13_Included -#define PPI_CHG0_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG0_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG0_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG0_CH12_Included PPI_CHG_CH12_Included -#define PPI_CHG0_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG0_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG0_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG0_CH11_Included PPI_CHG_CH11_Included -#define PPI_CHG0_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG0_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG0_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG0_CH10_Included PPI_CHG_CH10_Included -#define PPI_CHG0_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG0_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG0_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG0_CH9_Included PPI_CHG_CH9_Included -#define PPI_CHG0_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG0_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG0_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG0_CH8_Included PPI_CHG_CH8_Included -#define PPI_CHG0_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG0_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG0_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG0_CH7_Included PPI_CHG_CH7_Included -#define PPI_CHG0_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG0_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG0_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG0_CH6_Included PPI_CHG_CH6_Included -#define PPI_CHG0_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG0_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG0_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG0_CH5_Included PPI_CHG_CH5_Included -#define PPI_CHG0_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG0_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG0_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG0_CH4_Included PPI_CHG_CH4_Included -#define PPI_CHG0_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG0_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG0_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG0_CH3_Included PPI_CHG_CH3_Included -#define PPI_CHG0_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG0_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG0_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG0_CH2_Included PPI_CHG_CH2_Included -#define PPI_CHG0_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG0_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG0_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG0_CH1_Included PPI_CHG_CH1_Included -#define PPI_CHG0_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG0_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG0_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG0_CH0_Included PPI_CHG_CH0_Included -#define PPI_CHG1_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG1_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG1_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG1_CH15_Included PPI_CHG_CH15_Included -#define PPI_CHG1_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG1_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG1_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG1_CH14_Included PPI_CHG_CH14_Included -#define PPI_CHG1_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG1_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG1_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG1_CH13_Included PPI_CHG_CH13_Included -#define PPI_CHG1_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG1_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG1_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG1_CH12_Included PPI_CHG_CH12_Included -#define PPI_CHG1_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG1_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG1_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG1_CH11_Included PPI_CHG_CH11_Included -#define PPI_CHG1_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG1_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG1_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG1_CH10_Included PPI_CHG_CH10_Included -#define PPI_CHG1_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG1_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG1_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG1_CH9_Included PPI_CHG_CH9_Included -#define PPI_CHG1_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG1_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG1_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG1_CH8_Included PPI_CHG_CH8_Included -#define PPI_CHG1_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG1_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG1_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG1_CH7_Included PPI_CHG_CH7_Included -#define PPI_CHG1_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG1_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG1_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG1_CH6_Included PPI_CHG_CH6_Included -#define PPI_CHG1_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG1_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG1_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG1_CH5_Included PPI_CHG_CH5_Included -#define PPI_CHG1_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG1_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG1_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG1_CH4_Included PPI_CHG_CH4_Included -#define PPI_CHG1_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG1_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG1_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG1_CH3_Included PPI_CHG_CH3_Included -#define PPI_CHG1_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG1_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG1_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG1_CH2_Included PPI_CHG_CH2_Included -#define PPI_CHG1_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG1_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG1_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG1_CH1_Included PPI_CHG_CH1_Included -#define PPI_CHG1_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG1_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG1_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG1_CH0_Included PPI_CHG_CH0_Included -#define PPI_CHG2_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG2_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG2_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG2_CH15_Included PPI_CHG_CH15_Included -#define PPI_CHG2_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG2_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG2_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG2_CH14_Included PPI_CHG_CH14_Included -#define PPI_CHG2_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG2_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG2_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG2_CH13_Included PPI_CHG_CH13_Included -#define PPI_CHG2_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG2_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG2_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG2_CH12_Included PPI_CHG_CH12_Included -#define PPI_CHG2_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG2_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG2_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG2_CH11_Included PPI_CHG_CH11_Included -#define PPI_CHG2_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG2_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG2_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG2_CH10_Included PPI_CHG_CH10_Included -#define PPI_CHG2_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG2_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG2_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG2_CH9_Included PPI_CHG_CH9_Included -#define PPI_CHG2_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG2_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG2_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG2_CH8_Included PPI_CHG_CH8_Included -#define PPI_CHG2_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG2_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG2_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG2_CH7_Included PPI_CHG_CH7_Included -#define PPI_CHG2_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG2_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG2_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG2_CH6_Included PPI_CHG_CH6_Included -#define PPI_CHG2_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG2_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG2_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG2_CH5_Included PPI_CHG_CH5_Included -#define PPI_CHG2_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG2_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG2_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG2_CH4_Included PPI_CHG_CH4_Included -#define PPI_CHG2_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG2_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG2_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG2_CH3_Included PPI_CHG_CH3_Included -#define PPI_CHG2_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG2_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG2_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG2_CH2_Included PPI_CHG_CH2_Included -#define PPI_CHG2_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG2_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG2_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG2_CH1_Included PPI_CHG_CH1_Included -#define PPI_CHG2_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG2_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG2_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG2_CH0_Included PPI_CHG_CH0_Included -#define PPI_CHG3_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG3_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG3_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG3_CH15_Included PPI_CHG_CH15_Included -#define PPI_CHG3_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG3_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG3_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG3_CH14_Included PPI_CHG_CH14_Included -#define PPI_CHG3_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG3_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG3_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG3_CH13_Included PPI_CHG_CH13_Included -#define PPI_CHG3_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG3_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG3_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG3_CH12_Included PPI_CHG_CH12_Included -#define PPI_CHG3_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG3_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG3_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG3_CH11_Included PPI_CHG_CH11_Included -#define PPI_CHG3_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG3_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG3_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG3_CH10_Included PPI_CHG_CH10_Included -#define PPI_CHG3_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG3_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG3_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG3_CH9_Included PPI_CHG_CH9_Included -#define PPI_CHG3_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG3_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG3_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG3_CH8_Included PPI_CHG_CH8_Included -#define PPI_CHG3_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG3_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG3_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG3_CH7_Included PPI_CHG_CH7_Included -#define PPI_CHG3_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG3_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG3_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG3_CH6_Included PPI_CHG_CH6_Included -#define PPI_CHG3_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG3_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG3_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG3_CH5_Included PPI_CHG_CH5_Included -#define PPI_CHG3_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG3_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG3_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG3_CH4_Included PPI_CHG_CH4_Included -#define PPI_CHG3_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG3_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG3_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG3_CH3_Included PPI_CHG_CH3_Included -#define PPI_CHG3_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG3_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG3_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG3_CH2_Included PPI_CHG_CH2_Included -#define PPI_CHG3_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG3_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG3_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG3_CH1_Included PPI_CHG_CH1_Included -#define PPI_CHG3_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG3_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG3_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG3_CH0_Included PPI_CHG_CH0_Included - - - -/*lint --flb "Leave library region" */ - -#endif /* NRF51_DEPRECATED_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52.h deleted file mode 100644 index 66685de..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52.h +++ /dev/null @@ -1,963 +0,0 @@ -/* - -Copyright (c) 2010 - 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 NRF51_TO_NRF52_H -#define NRF51_TO_NRF52_H - -/*lint ++flb "Enter library region */ - -/* This file is given to prevent your SW from not compiling with the name changes between nRF51 and nRF52 devices. - * It redefines the old nRF51 names into the new ones as long as the functionality is still supported. If the - * functionality is gone, there old names are not defined, so compilation will fail. Note that also includes macros - * from the nrf51_deprecated.h file. */ - - -/* IRQ */ -/* Several peripherals have been added to several indexes. Names of IRQ handlers and IRQ numbers have changed. */ -#define UART0_IRQHandler UARTE0_UART0_IRQHandler -#define SPI0_TWI0_IRQHandler SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler -#define SPI1_TWI1_IRQHandler SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler -#define ADC_IRQHandler SAADC_IRQHandler -#define LPCOMP_IRQHandler COMP_LPCOMP_IRQHandler -#define SWI0_IRQHandler SWI0_EGU0_IRQHandler -#define SWI1_IRQHandler SWI1_EGU1_IRQHandler -#define SWI2_IRQHandler SWI2_EGU2_IRQHandler -#define SWI3_IRQHandler SWI3_EGU3_IRQHandler -#define SWI4_IRQHandler SWI4_EGU4_IRQHandler -#define SWI5_IRQHandler SWI5_EGU5_IRQHandler - -#define UART0_IRQn UARTE0_UART0_IRQn -#define SPI0_TWI0_IRQn SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn -#define SPI1_TWI1_IRQn SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn -#define ADC_IRQn SAADC_IRQn -#define LPCOMP_IRQn COMP_LPCOMP_IRQn -#define SWI0_IRQn SWI0_EGU0_IRQn -#define SWI1_IRQn SWI1_EGU1_IRQn -#define SWI2_IRQn SWI2_EGU2_IRQn -#define SWI3_IRQn SWI3_EGU3_IRQn -#define SWI4_IRQn SWI4_EGU4_IRQn -#define SWI5_IRQn SWI5_EGU5_IRQn - - -/* UICR */ -/* Register RBPCONF was renamed to APPROTECT. */ -#define RBPCONF APPROTECT - -#define UICR_RBPCONF_PALL_Pos UICR_APPROTECT_PALL_Pos -#define UICR_RBPCONF_PALL_Msk UICR_APPROTECT_PALL_Msk -#define UICR_RBPCONF_PALL_Enabled UICR_APPROTECT_PALL_Enabled -#define UICR_RBPCONF_PALL_Disabled UICR_APPROTECT_PALL_Disabled - - -/* GPIO */ -/* GPIO port was renamed to P0. */ -#define NRF_GPIO NRF_P0 -#define NRF_GPIO_BASE NRF_P0_BASE - - -/* QDEC */ -/* The registers PSELA, PSELB and PSELLED were restructured into a struct. */ -#define PSELLED PSEL.LED -#define PSELA PSEL.A -#define PSELB PSEL.B - - -/* SPIS */ -/* The registers PSELSCK, PSELMISO, PSELMOSI, PSELCSN were restructured into a struct. */ -#define PSELSCK PSEL.SCK -#define PSELMISO PSEL.MISO -#define PSELMOSI PSEL.MOSI -#define PSELCSN PSEL.CSN - -/* The registers RXDPTR, MAXRX, AMOUNTRX were restructured into a struct */ -#define RXDPTR RXD.PTR -#define MAXRX RXD.MAXCNT -#define AMOUNTRX RXD.AMOUNT - -#define SPIS_MAXRX_MAXRX_Pos SPIS_RXD_MAXCNT_MAXCNT_Pos -#define SPIS_MAXRX_MAXRX_Msk SPIS_RXD_MAXCNT_MAXCNT_Msk - -#define SPIS_AMOUNTRX_AMOUNTRX_Pos SPIS_RXD_AMOUNT_AMOUNT_Pos -#define SPIS_AMOUNTRX_AMOUNTRX_Msk SPIS_RXD_AMOUNT_AMOUNT_Msk - -/* The registers TXDPTR, MAXTX, AMOUNTTX were restructured into a struct */ -#define TXDPTR TXD.PTR -#define MAXTX TXD.MAXCNT -#define AMOUNTTX TXD.AMOUNT - -#define SPIS_MAXTX_MAXTX_Pos SPIS_TXD_MAXCNT_MAXCNT_Pos -#define SPIS_MAXTX_MAXTX_Msk SPIS_TXD_MAXCNT_MAXCNT_Msk - -#define SPIS_AMOUNTTX_AMOUNTTX_Pos SPIS_TXD_AMOUNT_AMOUNT_Pos -#define SPIS_AMOUNTTX_AMOUNTTX_Msk SPIS_TXD_AMOUNT_AMOUNT_Msk - - -/* MPU */ -/* Part of MPU module was renamed BPROT, while the rest was eliminated. */ -#define NRF_MPU NRF_BPROT - -/* Register DISABLEINDEBUG macros were affected. */ -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Pos -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Msk BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Msk -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Enabled BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Enabled -#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Disabled - -/* Registers PROTENSET0 and PROTENSET1 were affected and renamed as CONFIG0 and CONFIG1. */ -#define PROTENSET0 CONFIG0 -#define PROTENSET1 CONFIG1 - -#define MPU_PROTENSET1_PROTREG63_Pos BPROT_CONFIG1_REGION63_Pos -#define MPU_PROTENSET1_PROTREG63_Msk BPROT_CONFIG1_REGION63_Msk -#define MPU_PROTENSET1_PROTREG63_Disabled BPROT_CONFIG1_REGION63_Disabled -#define MPU_PROTENSET1_PROTREG63_Enabled BPROT_CONFIG1_REGION63_Enabled -#define MPU_PROTENSET1_PROTREG63_Set BPROT_CONFIG1_REGION63_Enabled - -#define MPU_PROTENSET1_PROTREG62_Pos BPROT_CONFIG1_REGION62_Pos -#define MPU_PROTENSET1_PROTREG62_Msk BPROT_CONFIG1_REGION62_Msk -#define MPU_PROTENSET1_PROTREG62_Disabled BPROT_CONFIG1_REGION62_Disabled -#define MPU_PROTENSET1_PROTREG62_Enabled BPROT_CONFIG1_REGION62_Enabled -#define MPU_PROTENSET1_PROTREG62_Set BPROT_CONFIG1_REGION62_Enabled - -#define MPU_PROTENSET1_PROTREG61_Pos BPROT_CONFIG1_REGION61_Pos -#define MPU_PROTENSET1_PROTREG61_Msk BPROT_CONFIG1_REGION61_Msk -#define MPU_PROTENSET1_PROTREG61_Disabled BPROT_CONFIG1_REGION61_Disabled -#define MPU_PROTENSET1_PROTREG61_Enabled BPROT_CONFIG1_REGION61_Enabled -#define MPU_PROTENSET1_PROTREG61_Set BPROT_CONFIG1_REGION61_Enabled - -#define MPU_PROTENSET1_PROTREG60_Pos BPROT_CONFIG1_REGION60_Pos -#define MPU_PROTENSET1_PROTREG60_Msk BPROT_CONFIG1_REGION60_Msk -#define MPU_PROTENSET1_PROTREG60_Disabled BPROT_CONFIG1_REGION60_Disabled -#define MPU_PROTENSET1_PROTREG60_Enabled BPROT_CONFIG1_REGION60_Enabled -#define MPU_PROTENSET1_PROTREG60_Set BPROT_CONFIG1_REGION60_Enabled - -#define MPU_PROTENSET1_PROTREG59_Pos BPROT_CONFIG1_REGION59_Pos -#define MPU_PROTENSET1_PROTREG59_Msk BPROT_CONFIG1_REGION59_Msk -#define MPU_PROTENSET1_PROTREG59_Disabled BPROT_CONFIG1_REGION59_Disabled -#define MPU_PROTENSET1_PROTREG59_Enabled BPROT_CONFIG1_REGION59_Enabled -#define MPU_PROTENSET1_PROTREG59_Set BPROT_CONFIG1_REGION59_Enabled - -#define MPU_PROTENSET1_PROTREG58_Pos BPROT_CONFIG1_REGION58_Pos -#define MPU_PROTENSET1_PROTREG58_Msk BPROT_CONFIG1_REGION58_Msk -#define MPU_PROTENSET1_PROTREG58_Disabled BPROT_CONFIG1_REGION58_Disabled -#define MPU_PROTENSET1_PROTREG58_Enabled BPROT_CONFIG1_REGION58_Enabled -#define MPU_PROTENSET1_PROTREG58_Set BPROT_CONFIG1_REGION58_Enabled - -#define MPU_PROTENSET1_PROTREG57_Pos BPROT_CONFIG1_REGION57_Pos -#define MPU_PROTENSET1_PROTREG57_Msk BPROT_CONFIG1_REGION57_Msk -#define MPU_PROTENSET1_PROTREG57_Disabled BPROT_CONFIG1_REGION57_Disabled -#define MPU_PROTENSET1_PROTREG57_Enabled BPROT_CONFIG1_REGION57_Enabled -#define MPU_PROTENSET1_PROTREG57_Set BPROT_CONFIG1_REGION57_Enabled - -#define MPU_PROTENSET1_PROTREG56_Pos BPROT_CONFIG1_REGION56_Pos -#define MPU_PROTENSET1_PROTREG56_Msk BPROT_CONFIG1_REGION56_Msk -#define MPU_PROTENSET1_PROTREG56_Disabled BPROT_CONFIG1_REGION56_Disabled -#define MPU_PROTENSET1_PROTREG56_Enabled BPROT_CONFIG1_REGION56_Enabled -#define MPU_PROTENSET1_PROTREG56_Set BPROT_CONFIG1_REGION56_Enabled - -#define MPU_PROTENSET1_PROTREG55_Pos BPROT_CONFIG1_REGION55_Pos -#define MPU_PROTENSET1_PROTREG55_Msk BPROT_CONFIG1_REGION55_Msk -#define MPU_PROTENSET1_PROTREG55_Disabled BPROT_CONFIG1_REGION55_Disabled -#define MPU_PROTENSET1_PROTREG55_Enabled BPROT_CONFIG1_REGION55_Enabled -#define MPU_PROTENSET1_PROTREG55_Set BPROT_CONFIG1_REGION55_Enabled - -#define MPU_PROTENSET1_PROTREG54_Pos BPROT_CONFIG1_REGION54_Pos -#define MPU_PROTENSET1_PROTREG54_Msk BPROT_CONFIG1_REGION54_Msk -#define MPU_PROTENSET1_PROTREG54_Disabled BPROT_CONFIG1_REGION54_Disabled -#define MPU_PROTENSET1_PROTREG54_Enabled BPROT_CONFIG1_REGION54_Enabled -#define MPU_PROTENSET1_PROTREG54_Set BPROT_CONFIG1_REGION54_Enabled - -#define MPU_PROTENSET1_PROTREG53_Pos BPROT_CONFIG1_REGION53_Pos -#define MPU_PROTENSET1_PROTREG53_Msk BPROT_CONFIG1_REGION53_Msk -#define MPU_PROTENSET1_PROTREG53_Disabled BPROT_CONFIG1_REGION53_Disabled -#define MPU_PROTENSET1_PROTREG53_Enabled BPROT_CONFIG1_REGION53_Enabled -#define MPU_PROTENSET1_PROTREG53_Set BPROT_CONFIG1_REGION53_Enabled - -#define MPU_PROTENSET1_PROTREG52_Pos BPROT_CONFIG1_REGION52_Pos -#define MPU_PROTENSET1_PROTREG52_Msk BPROT_CONFIG1_REGION52_Msk -#define MPU_PROTENSET1_PROTREG52_Disabled BPROT_CONFIG1_REGION52_Disabled -#define MPU_PROTENSET1_PROTREG52_Enabled BPROT_CONFIG1_REGION52_Enabled -#define MPU_PROTENSET1_PROTREG52_Set BPROT_CONFIG1_REGION52_Enabled - -#define MPU_PROTENSET1_PROTREG51_Pos BPROT_CONFIG1_REGION51_Pos -#define MPU_PROTENSET1_PROTREG51_Msk BPROT_CONFIG1_REGION51_Msk -#define MPU_PROTENSET1_PROTREG51_Disabled BPROT_CONFIG1_REGION51_Disabled -#define MPU_PROTENSET1_PROTREG51_Enabled BPROT_CONFIG1_REGION51_Enabled -#define MPU_PROTENSET1_PROTREG51_Set BPROT_CONFIG1_REGION51_Enabled - -#define MPU_PROTENSET1_PROTREG50_Pos BPROT_CONFIG1_REGION50_Pos -#define MPU_PROTENSET1_PROTREG50_Msk BPROT_CONFIG1_REGION50_Msk -#define MPU_PROTENSET1_PROTREG50_Disabled BPROT_CONFIG1_REGION50_Disabled -#define MPU_PROTENSET1_PROTREG50_Enabled BPROT_CONFIG1_REGION50_Enabled -#define MPU_PROTENSET1_PROTREG50_Set BPROT_CONFIG1_REGION50_Enabled - -#define MPU_PROTENSET1_PROTREG49_Pos BPROT_CONFIG1_REGION49_Pos -#define MPU_PROTENSET1_PROTREG49_Msk BPROT_CONFIG1_REGION49_Msk -#define MPU_PROTENSET1_PROTREG49_Disabled BPROT_CONFIG1_REGION49_Disabled -#define MPU_PROTENSET1_PROTREG49_Enabled BPROT_CONFIG1_REGION49_Enabled -#define MPU_PROTENSET1_PROTREG49_Set BPROT_CONFIG1_REGION49_Enabled - -#define MPU_PROTENSET1_PROTREG48_Pos BPROT_CONFIG1_REGION48_Pos -#define MPU_PROTENSET1_PROTREG48_Msk BPROT_CONFIG1_REGION48_Msk -#define MPU_PROTENSET1_PROTREG48_Disabled BPROT_CONFIG1_REGION48_Disabled -#define MPU_PROTENSET1_PROTREG48_Enabled BPROT_CONFIG1_REGION48_Enabled -#define MPU_PROTENSET1_PROTREG48_Set BPROT_CONFIG1_REGION48_Enabled - -#define MPU_PROTENSET1_PROTREG47_Pos BPROT_CONFIG1_REGION47_Pos -#define MPU_PROTENSET1_PROTREG47_Msk BPROT_CONFIG1_REGION47_Msk -#define MPU_PROTENSET1_PROTREG47_Disabled BPROT_CONFIG1_REGION47_Disabled -#define MPU_PROTENSET1_PROTREG47_Enabled BPROT_CONFIG1_REGION47_Enabled -#define MPU_PROTENSET1_PROTREG47_Set BPROT_CONFIG1_REGION47_Enabled - -#define MPU_PROTENSET1_PROTREG46_Pos BPROT_CONFIG1_REGION46_Pos -#define MPU_PROTENSET1_PROTREG46_Msk BPROT_CONFIG1_REGION46_Msk -#define MPU_PROTENSET1_PROTREG46_Disabled BPROT_CONFIG1_REGION46_Disabled -#define MPU_PROTENSET1_PROTREG46_Enabled BPROT_CONFIG1_REGION46_Enabled -#define MPU_PROTENSET1_PROTREG46_Set BPROT_CONFIG1_REGION46_Enabled - -#define MPU_PROTENSET1_PROTREG45_Pos BPROT_CONFIG1_REGION45_Pos -#define MPU_PROTENSET1_PROTREG45_Msk BPROT_CONFIG1_REGION45_Msk -#define MPU_PROTENSET1_PROTREG45_Disabled BPROT_CONFIG1_REGION45_Disabled -#define MPU_PROTENSET1_PROTREG45_Enabled BPROT_CONFIG1_REGION45_Enabled -#define MPU_PROTENSET1_PROTREG45_Set BPROT_CONFIG1_REGION45_Enabled - -#define MPU_PROTENSET1_PROTREG44_Pos BPROT_CONFIG1_REGION44_Pos -#define MPU_PROTENSET1_PROTREG44_Msk BPROT_CONFIG1_REGION44_Msk -#define MPU_PROTENSET1_PROTREG44_Disabled BPROT_CONFIG1_REGION44_Disabled -#define MPU_PROTENSET1_PROTREG44_Enabled BPROT_CONFIG1_REGION44_Enabled -#define MPU_PROTENSET1_PROTREG44_Set BPROT_CONFIG1_REGION44_Enabled - -#define MPU_PROTENSET1_PROTREG43_Pos BPROT_CONFIG1_REGION43_Pos -#define MPU_PROTENSET1_PROTREG43_Msk BPROT_CONFIG1_REGION43_Msk -#define MPU_PROTENSET1_PROTREG43_Disabled BPROT_CONFIG1_REGION43_Disabled -#define MPU_PROTENSET1_PROTREG43_Enabled BPROT_CONFIG1_REGION43_Enabled -#define MPU_PROTENSET1_PROTREG43_Set BPROT_CONFIG1_REGION43_Enabled - -#define MPU_PROTENSET1_PROTREG42_Pos BPROT_CONFIG1_REGION42_Pos -#define MPU_PROTENSET1_PROTREG42_Msk BPROT_CONFIG1_REGION42_Msk -#define MPU_PROTENSET1_PROTREG42_Disabled BPROT_CONFIG1_REGION42_Disabled -#define MPU_PROTENSET1_PROTREG42_Enabled BPROT_CONFIG1_REGION42_Enabled -#define MPU_PROTENSET1_PROTREG42_Set BPROT_CONFIG1_REGION42_Enabled - -#define MPU_PROTENSET1_PROTREG41_Pos BPROT_CONFIG1_REGION41_Pos -#define MPU_PROTENSET1_PROTREG41_Msk BPROT_CONFIG1_REGION41_Msk -#define MPU_PROTENSET1_PROTREG41_Disabled BPROT_CONFIG1_REGION41_Disabled -#define MPU_PROTENSET1_PROTREG41_Enabled BPROT_CONFIG1_REGION41_Enabled -#define MPU_PROTENSET1_PROTREG41_Set BPROT_CONFIG1_REGION41_Enabled - -#define MPU_PROTENSET1_PROTREG40_Pos BPROT_CONFIG1_REGION40_Pos -#define MPU_PROTENSET1_PROTREG40_Msk BPROT_CONFIG1_REGION40_Msk -#define MPU_PROTENSET1_PROTREG40_Disabled BPROT_CONFIG1_REGION40_Disabled -#define MPU_PROTENSET1_PROTREG40_Enabled BPROT_CONFIG1_REGION40_Enabled -#define MPU_PROTENSET1_PROTREG40_Set BPROT_CONFIG1_REGION40_Enabled - -#define MPU_PROTENSET1_PROTREG39_Pos BPROT_CONFIG1_REGION39_Pos -#define MPU_PROTENSET1_PROTREG39_Msk BPROT_CONFIG1_REGION39_Msk -#define MPU_PROTENSET1_PROTREG39_Disabled BPROT_CONFIG1_REGION39_Disabled -#define MPU_PROTENSET1_PROTREG39_Enabled BPROT_CONFIG1_REGION39_Enabled -#define MPU_PROTENSET1_PROTREG39_Set BPROT_CONFIG1_REGION39_Enabled - -#define MPU_PROTENSET1_PROTREG38_Pos BPROT_CONFIG1_REGION38_Pos -#define MPU_PROTENSET1_PROTREG38_Msk BPROT_CONFIG1_REGION38_Msk -#define MPU_PROTENSET1_PROTREG38_Disabled BPROT_CONFIG1_REGION38_Disabled -#define MPU_PROTENSET1_PROTREG38_Enabled BPROT_CONFIG1_REGION38_Enabled -#define MPU_PROTENSET1_PROTREG38_Set BPROT_CONFIG1_REGION38_Enabled - -#define MPU_PROTENSET1_PROTREG37_Pos BPROT_CONFIG1_REGION37_Pos -#define MPU_PROTENSET1_PROTREG37_Msk BPROT_CONFIG1_REGION37_Msk -#define MPU_PROTENSET1_PROTREG37_Disabled BPROT_CONFIG1_REGION37_Disabled -#define MPU_PROTENSET1_PROTREG37_Enabled BPROT_CONFIG1_REGION37_Enabled -#define MPU_PROTENSET1_PROTREG37_Set BPROT_CONFIG1_REGION37_Enabled - -#define MPU_PROTENSET1_PROTREG36_Pos BPROT_CONFIG1_REGION36_Pos -#define MPU_PROTENSET1_PROTREG36_Msk BPROT_CONFIG1_REGION36_Msk -#define MPU_PROTENSET1_PROTREG36_Disabled BPROT_CONFIG1_REGION36_Disabled -#define MPU_PROTENSET1_PROTREG36_Enabled BPROT_CONFIG1_REGION36_Enabled -#define MPU_PROTENSET1_PROTREG36_Set BPROT_CONFIG1_REGION36_Enabled - -#define MPU_PROTENSET1_PROTREG35_Pos BPROT_CONFIG1_REGION35_Pos -#define MPU_PROTENSET1_PROTREG35_Msk BPROT_CONFIG1_REGION35_Msk -#define MPU_PROTENSET1_PROTREG35_Disabled BPROT_CONFIG1_REGION35_Disabled -#define MPU_PROTENSET1_PROTREG35_Enabled BPROT_CONFIG1_REGION35_Enabled -#define MPU_PROTENSET1_PROTREG35_Set BPROT_CONFIG1_REGION35_Enabled - -#define MPU_PROTENSET1_PROTREG34_Pos BPROT_CONFIG1_REGION34_Pos -#define MPU_PROTENSET1_PROTREG34_Msk BPROT_CONFIG1_REGION34_Msk -#define MPU_PROTENSET1_PROTREG34_Disabled BPROT_CONFIG1_REGION34_Disabled -#define MPU_PROTENSET1_PROTREG34_Enabled BPROT_CONFIG1_REGION34_Enabled -#define MPU_PROTENSET1_PROTREG34_Set BPROT_CONFIG1_REGION34_Enabled - -#define MPU_PROTENSET1_PROTREG33_Pos BPROT_CONFIG1_REGION33_Pos -#define MPU_PROTENSET1_PROTREG33_Msk BPROT_CONFIG1_REGION33_Msk -#define MPU_PROTENSET1_PROTREG33_Disabled BPROT_CONFIG1_REGION33_Disabled -#define MPU_PROTENSET1_PROTREG33_Enabled BPROT_CONFIG1_REGION33_Enabled -#define MPU_PROTENSET1_PROTREG33_Set BPROT_CONFIG1_REGION33_Enabled - -#define MPU_PROTENSET1_PROTREG32_Pos BPROT_CONFIG1_REGION32_Pos -#define MPU_PROTENSET1_PROTREG32_Msk BPROT_CONFIG1_REGION32_Msk -#define MPU_PROTENSET1_PROTREG32_Disabled BPROT_CONFIG1_REGION32_Disabled -#define MPU_PROTENSET1_PROTREG32_Enabled BPROT_CONFIG1_REGION32_Enabled -#define MPU_PROTENSET1_PROTREG32_Set BPROT_CONFIG1_REGION32_Enabled - -#define MPU_PROTENSET0_PROTREG31_Pos BPROT_CONFIG0_REGION31_Pos -#define MPU_PROTENSET0_PROTREG31_Msk BPROT_CONFIG0_REGION31_Msk -#define MPU_PROTENSET0_PROTREG31_Disabled BPROT_CONFIG0_REGION31_Disabled -#define MPU_PROTENSET0_PROTREG31_Enabled BPROT_CONFIG0_REGION31_Enabled -#define MPU_PROTENSET0_PROTREG31_Set BPROT_CONFIG0_REGION31_Enabled - -#define MPU_PROTENSET0_PROTREG30_Pos BPROT_CONFIG0_REGION30_Pos -#define MPU_PROTENSET0_PROTREG30_Msk BPROT_CONFIG0_REGION30_Msk -#define MPU_PROTENSET0_PROTREG30_Disabled BPROT_CONFIG0_REGION30_Disabled -#define MPU_PROTENSET0_PROTREG30_Enabled BPROT_CONFIG0_REGION30_Enabled -#define MPU_PROTENSET0_PROTREG30_Set BPROT_CONFIG0_REGION30_Enabled - -#define MPU_PROTENSET0_PROTREG29_Pos BPROT_CONFIG0_REGION29_Pos -#define MPU_PROTENSET0_PROTREG29_Msk BPROT_CONFIG0_REGION29_Msk -#define MPU_PROTENSET0_PROTREG29_Disabled BPROT_CONFIG0_REGION29_Disabled -#define MPU_PROTENSET0_PROTREG29_Enabled BPROT_CONFIG0_REGION29_Enabled -#define MPU_PROTENSET0_PROTREG29_Set BPROT_CONFIG0_REGION29_Enabled - -#define MPU_PROTENSET0_PROTREG28_Pos BPROT_CONFIG0_REGION28_Pos -#define MPU_PROTENSET0_PROTREG28_Msk BPROT_CONFIG0_REGION28_Msk -#define MPU_PROTENSET0_PROTREG28_Disabled BPROT_CONFIG0_REGION28_Disabled -#define MPU_PROTENSET0_PROTREG28_Enabled BPROT_CONFIG0_REGION28_Enabled -#define MPU_PROTENSET0_PROTREG28_Set BPROT_CONFIG0_REGION28_Enabled - -#define MPU_PROTENSET0_PROTREG27_Pos BPROT_CONFIG0_REGION27_Pos -#define MPU_PROTENSET0_PROTREG27_Msk BPROT_CONFIG0_REGION27_Msk -#define MPU_PROTENSET0_PROTREG27_Disabled BPROT_CONFIG0_REGION27_Disabled -#define MPU_PROTENSET0_PROTREG27_Enabled BPROT_CONFIG0_REGION27_Enabled -#define MPU_PROTENSET0_PROTREG27_Set BPROT_CONFIG0_REGION27_Enabled - -#define MPU_PROTENSET0_PROTREG26_Pos BPROT_CONFIG0_REGION26_Pos -#define MPU_PROTENSET0_PROTREG26_Msk BPROT_CONFIG0_REGION26_Msk -#define MPU_PROTENSET0_PROTREG26_Disabled BPROT_CONFIG0_REGION26_Disabled -#define MPU_PROTENSET0_PROTREG26_Enabled BPROT_CONFIG0_REGION26_Enabled -#define MPU_PROTENSET0_PROTREG26_Set BPROT_CONFIG0_REGION26_Enabled - -#define MPU_PROTENSET0_PROTREG25_Pos BPROT_CONFIG0_REGION25_Pos -#define MPU_PROTENSET0_PROTREG25_Msk BPROT_CONFIG0_REGION25_Msk -#define MPU_PROTENSET0_PROTREG25_Disabled BPROT_CONFIG0_REGION25_Disabled -#define MPU_PROTENSET0_PROTREG25_Enabled BPROT_CONFIG0_REGION25_Enabled -#define MPU_PROTENSET0_PROTREG25_Set BPROT_CONFIG0_REGION25_Enabled - -#define MPU_PROTENSET0_PROTREG24_Pos BPROT_CONFIG0_REGION24_Pos -#define MPU_PROTENSET0_PROTREG24_Msk BPROT_CONFIG0_REGION24_Msk -#define MPU_PROTENSET0_PROTREG24_Disabled BPROT_CONFIG0_REGION24_Disabled -#define MPU_PROTENSET0_PROTREG24_Enabled BPROT_CONFIG0_REGION24_Enabled -#define MPU_PROTENSET0_PROTREG24_Set BPROT_CONFIG0_REGION24_Enabled - -#define MPU_PROTENSET0_PROTREG23_Pos BPROT_CONFIG0_REGION23_Pos -#define MPU_PROTENSET0_PROTREG23_Msk BPROT_CONFIG0_REGION23_Msk -#define MPU_PROTENSET0_PROTREG23_Disabled BPROT_CONFIG0_REGION23_Disabled -#define MPU_PROTENSET0_PROTREG23_Enabled BPROT_CONFIG0_REGION23_Enabled -#define MPU_PROTENSET0_PROTREG23_Set BPROT_CONFIG0_REGION23_Enabled - -#define MPU_PROTENSET0_PROTREG22_Pos BPROT_CONFIG0_REGION22_Pos -#define MPU_PROTENSET0_PROTREG22_Msk BPROT_CONFIG0_REGION22_Msk -#define MPU_PROTENSET0_PROTREG22_Disabled BPROT_CONFIG0_REGION22_Disabled -#define MPU_PROTENSET0_PROTREG22_Enabled BPROT_CONFIG0_REGION22_Enabled -#define MPU_PROTENSET0_PROTREG22_Set BPROT_CONFIG0_REGION22_Enabled - -#define MPU_PROTENSET0_PROTREG21_Pos BPROT_CONFIG0_REGION21_Pos -#define MPU_PROTENSET0_PROTREG21_Msk BPROT_CONFIG0_REGION21_Msk -#define MPU_PROTENSET0_PROTREG21_Disabled BPROT_CONFIG0_REGION21_Disabled -#define MPU_PROTENSET0_PROTREG21_Enabled BPROT_CONFIG0_REGION21_Enabled -#define MPU_PROTENSET0_PROTREG21_Set BPROT_CONFIG0_REGION21_Enabled - -#define MPU_PROTENSET0_PROTREG20_Pos BPROT_CONFIG0_REGION20_Pos -#define MPU_PROTENSET0_PROTREG20_Msk BPROT_CONFIG0_REGION20_Msk -#define MPU_PROTENSET0_PROTREG20_Disabled BPROT_CONFIG0_REGION20_Disabled -#define MPU_PROTENSET0_PROTREG20_Enabled BPROT_CONFIG0_REGION20_Enabled -#define MPU_PROTENSET0_PROTREG20_Set BPROT_CONFIG0_REGION20_Enabled - -#define MPU_PROTENSET0_PROTREG19_Pos BPROT_CONFIG0_REGION19_Pos -#define MPU_PROTENSET0_PROTREG19_Msk BPROT_CONFIG0_REGION19_Msk -#define MPU_PROTENSET0_PROTREG19_Disabled BPROT_CONFIG0_REGION19_Disabled -#define MPU_PROTENSET0_PROTREG19_Enabled BPROT_CONFIG0_REGION19_Enabled -#define MPU_PROTENSET0_PROTREG19_Set BPROT_CONFIG0_REGION19_Enabled - -#define MPU_PROTENSET0_PROTREG18_Pos BPROT_CONFIG0_REGION18_Pos -#define MPU_PROTENSET0_PROTREG18_Msk BPROT_CONFIG0_REGION18_Msk -#define MPU_PROTENSET0_PROTREG18_Disabled BPROT_CONFIG0_REGION18_Disabled -#define MPU_PROTENSET0_PROTREG18_Enabled BPROT_CONFIG0_REGION18_Enabled -#define MPU_PROTENSET0_PROTREG18_Set BPROT_CONFIG0_REGION18_Enabled - -#define MPU_PROTENSET0_PROTREG17_Pos BPROT_CONFIG0_REGION17_Pos -#define MPU_PROTENSET0_PROTREG17_Msk BPROT_CONFIG0_REGION17_Msk -#define MPU_PROTENSET0_PROTREG17_Disabled BPROT_CONFIG0_REGION17_Disabled -#define MPU_PROTENSET0_PROTREG17_Enabled BPROT_CONFIG0_REGION17_Enabled -#define MPU_PROTENSET0_PROTREG17_Set BPROT_CONFIG0_REGION17_Enabled - -#define MPU_PROTENSET0_PROTREG16_Pos BPROT_CONFIG0_REGION16_Pos -#define MPU_PROTENSET0_PROTREG16_Msk BPROT_CONFIG0_REGION16_Msk -#define MPU_PROTENSET0_PROTREG16_Disabled BPROT_CONFIG0_REGION16_Disabled -#define MPU_PROTENSET0_PROTREG16_Enabled BPROT_CONFIG0_REGION16_Enabled -#define MPU_PROTENSET0_PROTREG16_Set BPROT_CONFIG0_REGION16_Enabled - -#define MPU_PROTENSET0_PROTREG15_Pos BPROT_CONFIG0_REGION15_Pos -#define MPU_PROTENSET0_PROTREG15_Msk BPROT_CONFIG0_REGION15_Msk -#define MPU_PROTENSET0_PROTREG15_Disabled BPROT_CONFIG0_REGION15_Disabled -#define MPU_PROTENSET0_PROTREG15_Enabled BPROT_CONFIG0_REGION15_Enabled -#define MPU_PROTENSET0_PROTREG15_Set BPROT_CONFIG0_REGION15_Enabled - -#define MPU_PROTENSET0_PROTREG14_Pos BPROT_CONFIG0_REGION14_Pos -#define MPU_PROTENSET0_PROTREG14_Msk BPROT_CONFIG0_REGION14_Msk -#define MPU_PROTENSET0_PROTREG14_Disabled BPROT_CONFIG0_REGION14_Disabled -#define MPU_PROTENSET0_PROTREG14_Enabled BPROT_CONFIG0_REGION14_Enabled -#define MPU_PROTENSET0_PROTREG14_Set BPROT_CONFIG0_REGION14_Enabled - -#define MPU_PROTENSET0_PROTREG13_Pos BPROT_CONFIG0_REGION13_Pos -#define MPU_PROTENSET0_PROTREG13_Msk BPROT_CONFIG0_REGION13_Msk -#define MPU_PROTENSET0_PROTREG13_Disabled BPROT_CONFIG0_REGION13_Disabled -#define MPU_PROTENSET0_PROTREG13_Enabled BPROT_CONFIG0_REGION13_Enabled -#define MPU_PROTENSET0_PROTREG13_Set BPROT_CONFIG0_REGION13_Enabled - -#define MPU_PROTENSET0_PROTREG12_Pos BPROT_CONFIG0_REGION12_Pos -#define MPU_PROTENSET0_PROTREG12_Msk BPROT_CONFIG0_REGION12_Msk -#define MPU_PROTENSET0_PROTREG12_Disabled BPROT_CONFIG0_REGION12_Disabled -#define MPU_PROTENSET0_PROTREG12_Enabled BPROT_CONFIG0_REGION12_Enabled -#define MPU_PROTENSET0_PROTREG12_Set BPROT_CONFIG0_REGION12_Enabled - -#define MPU_PROTENSET0_PROTREG11_Pos BPROT_CONFIG0_REGION11_Pos -#define MPU_PROTENSET0_PROTREG11_Msk BPROT_CONFIG0_REGION11_Msk -#define MPU_PROTENSET0_PROTREG11_Disabled BPROT_CONFIG0_REGION11_Disabled -#define MPU_PROTENSET0_PROTREG11_Enabled BPROT_CONFIG0_REGION11_Enabled -#define MPU_PROTENSET0_PROTREG11_Set BPROT_CONFIG0_REGION11_Enabled - -#define MPU_PROTENSET0_PROTREG10_Pos BPROT_CONFIG0_REGION10_Pos -#define MPU_PROTENSET0_PROTREG10_Msk BPROT_CONFIG0_REGION10_Msk -#define MPU_PROTENSET0_PROTREG10_Disabled BPROT_CONFIG0_REGION10_Disabled -#define MPU_PROTENSET0_PROTREG10_Enabled BPROT_CONFIG0_REGION10_Enabled -#define MPU_PROTENSET0_PROTREG10_Set BPROT_CONFIG0_REGION10_Enabled - -#define MPU_PROTENSET0_PROTREG9_Pos BPROT_CONFIG0_REGION9_Pos -#define MPU_PROTENSET0_PROTREG9_Msk BPROT_CONFIG0_REGION9_Msk -#define MPU_PROTENSET0_PROTREG9_Disabled BPROT_CONFIG0_REGION9_Disabled -#define MPU_PROTENSET0_PROTREG9_Enabled BPROT_CONFIG0_REGION9_Enabled -#define MPU_PROTENSET0_PROTREG9_Set BPROT_CONFIG0_REGION9_Enabled - -#define MPU_PROTENSET0_PROTREG8_Pos BPROT_CONFIG0_REGION8_Pos -#define MPU_PROTENSET0_PROTREG8_Msk BPROT_CONFIG0_REGION8_Msk -#define MPU_PROTENSET0_PROTREG8_Disabled BPROT_CONFIG0_REGION8_Disabled -#define MPU_PROTENSET0_PROTREG8_Enabled BPROT_CONFIG0_REGION8_Enabled -#define MPU_PROTENSET0_PROTREG8_Set BPROT_CONFIG0_REGION8_Enabled - -#define MPU_PROTENSET0_PROTREG7_Pos BPROT_CONFIG0_REGION7_Pos -#define MPU_PROTENSET0_PROTREG7_Msk BPROT_CONFIG0_REGION7_Msk -#define MPU_PROTENSET0_PROTREG7_Disabled BPROT_CONFIG0_REGION7_Disabled -#define MPU_PROTENSET0_PROTREG7_Enabled BPROT_CONFIG0_REGION7_Enabled -#define MPU_PROTENSET0_PROTREG7_Set BPROT_CONFIG0_REGION7_Enabled - -#define MPU_PROTENSET0_PROTREG6_Pos BPROT_CONFIG0_REGION6_Pos -#define MPU_PROTENSET0_PROTREG6_Msk BPROT_CONFIG0_REGION6_Msk -#define MPU_PROTENSET0_PROTREG6_Disabled BPROT_CONFIG0_REGION6_Disabled -#define MPU_PROTENSET0_PROTREG6_Enabled BPROT_CONFIG0_REGION6_Enabled -#define MPU_PROTENSET0_PROTREG6_Set BPROT_CONFIG0_REGION6_Enabled - -#define MPU_PROTENSET0_PROTREG5_Pos BPROT_CONFIG0_REGION5_Pos -#define MPU_PROTENSET0_PROTREG5_Msk BPROT_CONFIG0_REGION5_Msk -#define MPU_PROTENSET0_PROTREG5_Disabled BPROT_CONFIG0_REGION5_Disabled -#define MPU_PROTENSET0_PROTREG5_Enabled BPROT_CONFIG0_REGION5_Enabled -#define MPU_PROTENSET0_PROTREG5_Set BPROT_CONFIG0_REGION5_Enabled - -#define MPU_PROTENSET0_PROTREG4_Pos BPROT_CONFIG0_REGION4_Pos -#define MPU_PROTENSET0_PROTREG4_Msk BPROT_CONFIG0_REGION4_Msk -#define MPU_PROTENSET0_PROTREG4_Disabled BPROT_CONFIG0_REGION4_Disabled -#define MPU_PROTENSET0_PROTREG4_Enabled BPROT_CONFIG0_REGION4_Enabled -#define MPU_PROTENSET0_PROTREG4_Set BPROT_CONFIG0_REGION4_Enabled - -#define MPU_PROTENSET0_PROTREG3_Pos BPROT_CONFIG0_REGION3_Pos -#define MPU_PROTENSET0_PROTREG3_Msk BPROT_CONFIG0_REGION3_Msk -#define MPU_PROTENSET0_PROTREG3_Disabled BPROT_CONFIG0_REGION3_Disabled -#define MPU_PROTENSET0_PROTREG3_Enabled BPROT_CONFIG0_REGION3_Enabled -#define MPU_PROTENSET0_PROTREG3_Set BPROT_CONFIG0_REGION3_Enabled - -#define MPU_PROTENSET0_PROTREG2_Pos BPROT_CONFIG0_REGION2_Pos -#define MPU_PROTENSET0_PROTREG2_Msk BPROT_CONFIG0_REGION2_Msk -#define MPU_PROTENSET0_PROTREG2_Disabled BPROT_CONFIG0_REGION2_Disabled -#define MPU_PROTENSET0_PROTREG2_Enabled BPROT_CONFIG0_REGION2_Enabled -#define MPU_PROTENSET0_PROTREG2_Set BPROT_CONFIG0_REGION2_Enabled - -#define MPU_PROTENSET0_PROTREG1_Pos BPROT_CONFIG0_REGION1_Pos -#define MPU_PROTENSET0_PROTREG1_Msk BPROT_CONFIG0_REGION1_Msk -#define MPU_PROTENSET0_PROTREG1_Disabled BPROT_CONFIG0_REGION1_Disabled -#define MPU_PROTENSET0_PROTREG1_Enabled BPROT_CONFIG0_REGION1_Enabled -#define MPU_PROTENSET0_PROTREG1_Set BPROT_CONFIG0_REGION1_Enabled - -#define MPU_PROTENSET0_PROTREG0_Pos BPROT_CONFIG0_REGION0_Pos -#define MPU_PROTENSET0_PROTREG0_Msk BPROT_CONFIG0_REGION0_Msk -#define MPU_PROTENSET0_PROTREG0_Disabled BPROT_CONFIG0_REGION0_Disabled -#define MPU_PROTENSET0_PROTREG0_Enabled BPROT_CONFIG0_REGION0_Enabled -#define MPU_PROTENSET0_PROTREG0_Set BPROT_CONFIG0_REGION0_Enabled - - -/* From nrf51_deprecated.h */ - -/* NVMC */ -/* The register ERASEPROTECTEDPAGE changed name to ERASEPCR0 in the documentation. */ -#define ERASEPROTECTEDPAGE ERASEPCR0 - - -/* IRQ */ -/* COMP module was eliminated. Adapted to nrf52 headers. */ -#define LPCOMP_COMP_IRQHandler COMP_LPCOMP_IRQHandler -#define LPCOMP_COMP_IRQn COMP_LPCOMP_IRQn - - -/* REFSEL register redefined enumerated values and added some more. */ -#define LPCOMP_REFSEL_REFSEL_SupplyOneEighthPrescaling LPCOMP_REFSEL_REFSEL_Ref1_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyTwoEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref2_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyThreeEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref3_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyFourEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref4_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyFiveEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref5_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplySixEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref6_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref7_8Vdd - - -/* RADIO */ -/* The name of the field SKIPADDR was corrected. Old macros added for compatibility. */ -#define RADIO_CRCCNF_SKIP_ADDR_Pos RADIO_CRCCNF_SKIPADDR_Pos -#define RADIO_CRCCNF_SKIP_ADDR_Msk RADIO_CRCCNF_SKIPADDR_Msk -#define RADIO_CRCCNF_SKIP_ADDR_Include RADIO_CRCCNF_SKIPADDR_Include -#define RADIO_CRCCNF_SKIP_ADDR_Skip RADIO_CRCCNF_SKIPADDR_Skip - - -/* FICR */ -/* The registers FICR.DEVICEID0 and FICR.DEVICEID1 were renamed into an array. */ -#define DEVICEID0 DEVICEID[0] -#define DEVICEID1 DEVICEID[1] - -/* The registers FICR.ER0, FICR.ER1, FICR.ER2 and FICR.ER3 were renamed into an array. */ -#define ER0 ER[0] -#define ER1 ER[1] -#define ER2 ER[2] -#define ER3 ER[3] - -/* The registers FICR.IR0, FICR.IR1, FICR.IR2 and FICR.IR3 were renamed into an array. */ -#define IR0 IR[0] -#define IR1 IR[1] -#define IR2 IR[2] -#define IR3 IR[3] - -/* The registers FICR.DEVICEADDR0 and FICR.DEVICEADDR1 were renamed into an array. */ -#define DEVICEADDR0 DEVICEADDR[0] -#define DEVICEADDR1 DEVICEADDR[1] - - -/* PPI */ -/* The tasks PPI.TASKS_CHGxEN and PPI.TASKS_CHGxDIS were renamed into an array of structs. */ -#define TASKS_CHG0EN TASKS_CHG[0].EN -#define TASKS_CHG0DIS TASKS_CHG[0].DIS -#define TASKS_CHG1EN TASKS_CHG[1].EN -#define TASKS_CHG1DIS TASKS_CHG[1].DIS -#define TASKS_CHG2EN TASKS_CHG[2].EN -#define TASKS_CHG2DIS TASKS_CHG[2].DIS -#define TASKS_CHG3EN TASKS_CHG[3].EN -#define TASKS_CHG3DIS TASKS_CHG[3].DIS - -/* The registers PPI.CHx_EEP and PPI.CHx_TEP were renamed into an array of structs. */ -#define CH0_EEP CH[0].EEP -#define CH0_TEP CH[0].TEP -#define CH1_EEP CH[1].EEP -#define CH1_TEP CH[1].TEP -#define CH2_EEP CH[2].EEP -#define CH2_TEP CH[2].TEP -#define CH3_EEP CH[3].EEP -#define CH3_TEP CH[3].TEP -#define CH4_EEP CH[4].EEP -#define CH4_TEP CH[4].TEP -#define CH5_EEP CH[5].EEP -#define CH5_TEP CH[5].TEP -#define CH6_EEP CH[6].EEP -#define CH6_TEP CH[6].TEP -#define CH7_EEP CH[7].EEP -#define CH7_TEP CH[7].TEP -#define CH8_EEP CH[8].EEP -#define CH8_TEP CH[8].TEP -#define CH9_EEP CH[9].EEP -#define CH9_TEP CH[9].TEP -#define CH10_EEP CH[10].EEP -#define CH10_TEP CH[10].TEP -#define CH11_EEP CH[11].EEP -#define CH11_TEP CH[11].TEP -#define CH12_EEP CH[12].EEP -#define CH12_TEP CH[12].TEP -#define CH13_EEP CH[13].EEP -#define CH13_TEP CH[13].TEP -#define CH14_EEP CH[14].EEP -#define CH14_TEP CH[14].TEP -#define CH15_EEP CH[15].EEP -#define CH15_TEP CH[15].TEP - -/* The registers PPI.CHG0, PPI.CHG1, PPI.CHG2 and PPI.CHG3 were renamed into an array. */ -#define CHG0 CHG[0] -#define CHG1 CHG[1] -#define CHG2 CHG[2] -#define CHG3 CHG[3] - -/* All bitfield macros for the CHGx registers therefore changed name. */ -#define PPI_CHG0_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG0_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG0_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG0_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG0_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG0_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG0_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG0_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG0_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG0_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG0_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG0_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG0_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG0_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG0_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG0_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG0_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG0_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG0_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG0_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG0_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG0_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG0_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG0_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG0_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG0_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG0_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG0_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG0_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG0_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG0_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG0_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG0_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG0_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG0_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG0_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG0_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG0_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG0_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG0_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG0_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG0_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG0_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG0_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG0_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG0_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG0_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG0_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG0_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG0_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG0_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG0_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG0_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG0_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG0_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG0_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG0_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG0_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG0_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG0_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG0_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG0_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG0_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG0_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG1_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG1_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG1_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG1_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG1_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG1_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG1_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG1_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG1_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG1_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG1_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG1_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG1_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG1_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG1_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG1_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG1_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG1_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG1_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG1_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG1_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG1_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG1_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG1_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG1_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG1_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG1_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG1_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG1_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG1_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG1_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG1_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG1_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG1_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG1_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG1_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG1_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG1_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG1_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG1_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG1_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG1_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG1_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG1_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG1_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG1_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG1_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG1_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG1_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG1_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG1_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG1_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG1_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG1_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG1_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG1_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG1_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG1_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG1_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG1_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG1_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG1_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG1_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG1_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG2_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG2_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG2_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG2_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG2_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG2_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG2_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG2_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG2_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG2_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG2_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG2_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG2_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG2_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG2_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG2_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG2_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG2_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG2_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG2_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG2_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG2_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG2_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG2_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG2_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG2_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG2_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG2_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG2_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG2_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG2_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG2_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG2_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG2_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG2_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG2_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG2_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG2_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG2_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG2_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG2_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG2_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG2_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG2_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG2_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG2_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG2_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG2_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG2_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG2_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG2_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG2_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG2_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG2_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG2_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG2_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG2_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG2_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG2_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG2_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG2_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG2_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG2_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG2_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG3_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG3_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG3_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG3_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG3_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG3_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG3_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG3_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG3_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG3_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG3_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG3_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG3_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG3_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG3_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG3_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG3_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG3_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG3_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG3_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG3_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG3_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG3_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG3_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG3_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG3_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG3_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG3_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG3_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG3_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG3_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG3_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG3_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG3_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG3_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG3_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG3_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG3_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG3_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG3_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG3_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG3_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG3_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG3_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG3_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG3_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG3_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG3_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG3_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG3_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG3_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG3_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG3_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG3_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG3_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG3_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG3_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG3_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG3_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG3_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG3_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG3_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG3_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG3_CH0_Included PPI_CHG_CH0_Included - - - - -/*lint --flb "Leave library region" */ - -#endif /* NRF51_TO_NRF52_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52810.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52810.h deleted file mode 100644 index 3f304f4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52810.h +++ /dev/null @@ -1,532 +0,0 @@ -/* - -Copyright (c) 2010 - 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 NRF51_TO_NRF52810_H -#define NRF51_TO_NRF52810_H - -/*lint ++flb "Enter library region */ - -/* This file is given to prevent your SW from not compiling with the name changes between nRF51 and nRF52840 devices. - * It redefines the old nRF51 names into the new ones as long as the functionality is still supported. If the - * functionality is gone, there old names are not defined, so compilation will fail. Note that also includes macros - * from the nrf51_deprecated.h file. */ - - - /* Differences between latest nRF51 headers and nRF52810 headers. */ - -/* IRQ */ -/* Several peripherals have been added to several indexes. Names of IRQ handlers and IRQ numbers have changed. */ -#define SWI0_IRQHandler SWI0_EGU0_IRQHandler -#define SWI1_IRQHandler SWI1_EGU1_IRQHandler - -#define SWI0_IRQn SWI0_EGU0_IRQn -#define SWI1_IRQn SWI1_EGU1_IRQn - - -/* UICR */ -/* Register RBPCONF was renamed to APPROTECT. */ -#define RBPCONF APPROTECT - -#define UICR_RBPCONF_PALL_Pos UICR_APPROTECT_PALL_Pos -#define UICR_RBPCONF_PALL_Msk UICR_APPROTECT_PALL_Msk -#define UICR_RBPCONF_PALL_Enabled UICR_APPROTECT_PALL_Enabled -#define UICR_RBPCONF_PALL_Disabled UICR_APPROTECT_PALL_Disabled - - -/* GPIO */ -/* GPIO port was renamed to P0. */ -#define NRF_GPIO NRF_P0 -#define NRF_GPIO_BASE NRF_P0_BASE - - -/* QDEC */ -/* The registers PSELA, PSELB and PSELLED were restructured into a struct. */ -#define PSELLED PSEL.LED -#define PSELA PSEL.A -#define PSELB PSEL.B - - -/* SPIS */ -/* The registers PSELSCK, PSELMISO, PSELMOSI, PSELCSN were restructured into a struct. */ -#define PSELSCK PSEL.SCK -#define PSELMISO PSEL.MISO -#define PSELMOSI PSEL.MOSI -#define PSELCSN PSEL.CSN - -/* The registers RXDPTR, MAXRX, AMOUNTRX were restructured into a struct */ -#define RXDPTR RXD.PTR -#define MAXRX RXD.MAXCNT -#define AMOUNTRX RXD.AMOUNT - -#define SPIS_MAXRX_MAXRX_Pos SPIS_RXD_MAXCNT_MAXCNT_Pos -#define SPIS_MAXRX_MAXRX_Msk SPIS_RXD_MAXCNT_MAXCNT_Msk - -#define SPIS_AMOUNTRX_AMOUNTRX_Pos SPIS_RXD_AMOUNT_AMOUNT_Pos -#define SPIS_AMOUNTRX_AMOUNTRX_Msk SPIS_RXD_AMOUNT_AMOUNT_Msk - -/* The registers TXDPTR, MAXTX, AMOUNTTX were restructured into a struct */ -#define TXDPTR TXD.PTR -#define MAXTX TXD.MAXCNT -#define AMOUNTTX TXD.AMOUNT - -#define SPIS_MAXTX_MAXTX_Pos SPIS_TXD_MAXCNT_MAXCNT_Pos -#define SPIS_MAXTX_MAXTX_Msk SPIS_TXD_MAXCNT_MAXCNT_Msk - -#define SPIS_AMOUNTTX_AMOUNTTX_Pos SPIS_TXD_AMOUNT_AMOUNT_Pos -#define SPIS_AMOUNTTX_AMOUNTTX_Msk SPIS_TXD_AMOUNT_AMOUNT_Msk - - -/* From nrf51_deprecated.h. Several macros changed in different versions of nRF52 headers. By defining the following, any code written for any version of nRF52 headers will still compile. */ - -/* NVMC */ -/* The register ERASEPROTECTEDPAGE changed name to ERASEPCR0 in the documentation. */ -#define ERASEPROTECTEDPAGE ERASEPCR0 - - -/* RADIO */ -/* The name of the field SKIPADDR was corrected. Old macros added for compatibility. */ -#define RADIO_CRCCNF_SKIP_ADDR_Pos RADIO_CRCCNF_SKIPADDR_Pos -#define RADIO_CRCCNF_SKIP_ADDR_Msk RADIO_CRCCNF_SKIPADDR_Msk -#define RADIO_CRCCNF_SKIP_ADDR_Include RADIO_CRCCNF_SKIPADDR_Include -#define RADIO_CRCCNF_SKIP_ADDR_Skip RADIO_CRCCNF_SKIPADDR_Skip - - -/* FICR */ -/* The registers FICR.DEVICEID0 and FICR.DEVICEID1 were renamed into an array. */ -#define DEVICEID0 DEVICEID[0] -#define DEVICEID1 DEVICEID[1] - -/* The registers FICR.ER0, FICR.ER1, FICR.ER2 and FICR.ER3 were renamed into an array. */ -#define ER0 ER[0] -#define ER1 ER[1] -#define ER2 ER[2] -#define ER3 ER[3] - -/* The registers FICR.IR0, FICR.IR1, FICR.IR2 and FICR.IR3 were renamed into an array. */ -#define IR0 IR[0] -#define IR1 IR[1] -#define IR2 IR[2] -#define IR3 IR[3] - -/* The registers FICR.DEVICEADDR0 and FICR.DEVICEADDR1 were renamed into an array. */ -#define DEVICEADDR0 DEVICEADDR[0] -#define DEVICEADDR1 DEVICEADDR[1] - - -/* PPI */ -/* The tasks PPI.TASKS_CHGxEN and PPI.TASKS_CHGxDIS were renamed into an array of structs. */ -#define TASKS_CHG0EN TASKS_CHG[0].EN -#define TASKS_CHG0DIS TASKS_CHG[0].DIS -#define TASKS_CHG1EN TASKS_CHG[1].EN -#define TASKS_CHG1DIS TASKS_CHG[1].DIS -#define TASKS_CHG2EN TASKS_CHG[2].EN -#define TASKS_CHG2DIS TASKS_CHG[2].DIS -#define TASKS_CHG3EN TASKS_CHG[3].EN -#define TASKS_CHG3DIS TASKS_CHG[3].DIS - -/* The registers PPI.CHx_EEP and PPI.CHx_TEP were renamed into an array of structs. */ -#define CH0_EEP CH[0].EEP -#define CH0_TEP CH[0].TEP -#define CH1_EEP CH[1].EEP -#define CH1_TEP CH[1].TEP -#define CH2_EEP CH[2].EEP -#define CH2_TEP CH[2].TEP -#define CH3_EEP CH[3].EEP -#define CH3_TEP CH[3].TEP -#define CH4_EEP CH[4].EEP -#define CH4_TEP CH[4].TEP -#define CH5_EEP CH[5].EEP -#define CH5_TEP CH[5].TEP -#define CH6_EEP CH[6].EEP -#define CH6_TEP CH[6].TEP -#define CH7_EEP CH[7].EEP -#define CH7_TEP CH[7].TEP -#define CH8_EEP CH[8].EEP -#define CH8_TEP CH[8].TEP -#define CH9_EEP CH[9].EEP -#define CH9_TEP CH[9].TEP -#define CH10_EEP CH[10].EEP -#define CH10_TEP CH[10].TEP -#define CH11_EEP CH[11].EEP -#define CH11_TEP CH[11].TEP -#define CH12_EEP CH[12].EEP -#define CH12_TEP CH[12].TEP -#define CH13_EEP CH[13].EEP -#define CH13_TEP CH[13].TEP -#define CH14_EEP CH[14].EEP -#define CH14_TEP CH[14].TEP -#define CH15_EEP CH[15].EEP -#define CH15_TEP CH[15].TEP - -/* The registers PPI.CHG0, PPI.CHG1, PPI.CHG2 and PPI.CHG3 were renamed into an array. */ -#define CHG0 CHG[0] -#define CHG1 CHG[1] -#define CHG2 CHG[2] -#define CHG3 CHG[3] - -/* All bitfield macros for the CHGx registers therefore changed name. */ -#define PPI_CHG0_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG0_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG0_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG0_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG0_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG0_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG0_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG0_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG0_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG0_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG0_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG0_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG0_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG0_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG0_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG0_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG0_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG0_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG0_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG0_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG0_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG0_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG0_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG0_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG0_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG0_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG0_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG0_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG0_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG0_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG0_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG0_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG0_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG0_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG0_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG0_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG0_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG0_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG0_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG0_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG0_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG0_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG0_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG0_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG0_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG0_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG0_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG0_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG0_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG0_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG0_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG0_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG0_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG0_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG0_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG0_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG0_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG0_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG0_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG0_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG0_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG0_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG0_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG0_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG1_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG1_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG1_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG1_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG1_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG1_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG1_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG1_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG1_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG1_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG1_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG1_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG1_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG1_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG1_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG1_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG1_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG1_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG1_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG1_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG1_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG1_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG1_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG1_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG1_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG1_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG1_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG1_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG1_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG1_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG1_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG1_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG1_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG1_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG1_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG1_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG1_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG1_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG1_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG1_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG1_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG1_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG1_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG1_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG1_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG1_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG1_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG1_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG1_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG1_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG1_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG1_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG1_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG1_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG1_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG1_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG1_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG1_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG1_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG1_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG1_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG1_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG1_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG1_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG2_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG2_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG2_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG2_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG2_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG2_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG2_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG2_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG2_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG2_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG2_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG2_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG2_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG2_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG2_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG2_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG2_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG2_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG2_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG2_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG2_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG2_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG2_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG2_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG2_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG2_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG2_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG2_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG2_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG2_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG2_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG2_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG2_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG2_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG2_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG2_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG2_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG2_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG2_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG2_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG2_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG2_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG2_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG2_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG2_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG2_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG2_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG2_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG2_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG2_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG2_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG2_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG2_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG2_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG2_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG2_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG2_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG2_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG2_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG2_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG2_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG2_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG2_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG2_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG3_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG3_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG3_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG3_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG3_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG3_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG3_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG3_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG3_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG3_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG3_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG3_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG3_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG3_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG3_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG3_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG3_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG3_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG3_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG3_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG3_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG3_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG3_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG3_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG3_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG3_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG3_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG3_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG3_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG3_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG3_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG3_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG3_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG3_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG3_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG3_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG3_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG3_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG3_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG3_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG3_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG3_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG3_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG3_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG3_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG3_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG3_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG3_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG3_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG3_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG3_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG3_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG3_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG3_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG3_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG3_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG3_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG3_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG3_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG3_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG3_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG3_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG3_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG3_CH0_Included PPI_CHG_CH0_Included - - - - -/*lint --flb "Leave library region" */ - -#endif /* NRF51_TO_NRF52810_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52840.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52840.h deleted file mode 100644 index fe89337..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf51_to_nrf52840.h +++ /dev/null @@ -1,578 +0,0 @@ -/* - -Copyright (c) 2010 - 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 NRF51_TO_NRF52840_H -#define NRF51_TO_NRF52840_H - -/*lint ++flb "Enter library region */ - -/* This file is given to prevent your SW from not compiling with the name changes between nRF51 and nRF52840 devices. - * It redefines the old nRF51 names into the new ones as long as the functionality is still supported. If the - * functionality is gone, there old names are not defined, so compilation will fail. Note that also includes macros - * from the nrf51_deprecated.h file. */ - - -/* IRQ */ -/* Several peripherals have been added to several indexes. Names of IRQ handlers and IRQ numbers have changed. */ -#define UART0_IRQHandler UARTE0_UART0_IRQHandler -#define SPI0_TWI0_IRQHandler SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler -#define SPI1_TWI1_IRQHandler SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler -#define ADC_IRQHandler SAADC_IRQHandler -#define LPCOMP_IRQHandler COMP_LPCOMP_IRQHandler -#define SWI0_IRQHandler SWI0_EGU0_IRQHandler -#define SWI1_IRQHandler SWI1_EGU1_IRQHandler -#define SWI2_IRQHandler SWI2_EGU2_IRQHandler -#define SWI3_IRQHandler SWI3_EGU3_IRQHandler -#define SWI4_IRQHandler SWI4_EGU4_IRQHandler -#define SWI5_IRQHandler SWI5_EGU5_IRQHandler - -#define UART0_IRQn UARTE0_UART0_IRQn -#define SPI0_TWI0_IRQn SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn -#define SPI1_TWI1_IRQn SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn -#define ADC_IRQn SAADC_IRQn -#define LPCOMP_IRQn COMP_LPCOMP_IRQn -#define SWI0_IRQn SWI0_EGU0_IRQn -#define SWI1_IRQn SWI1_EGU1_IRQn -#define SWI2_IRQn SWI2_EGU2_IRQn -#define SWI3_IRQn SWI3_EGU3_IRQn -#define SWI4_IRQn SWI4_EGU4_IRQn -#define SWI5_IRQn SWI5_EGU5_IRQn - - -/* UICR */ -/* Register RBPCONF was renamed to APPROTECT. */ -#define RBPCONF APPROTECT - -#define UICR_RBPCONF_PALL_Pos UICR_APPROTECT_PALL_Pos -#define UICR_RBPCONF_PALL_Msk UICR_APPROTECT_PALL_Msk -#define UICR_RBPCONF_PALL_Enabled UICR_APPROTECT_PALL_Enabled -#define UICR_RBPCONF_PALL_Disabled UICR_APPROTECT_PALL_Disabled - - -/* GPIO */ -/* GPIO port was renamed to P0. */ -#define NRF_GPIO NRF_P0 -#define NRF_GPIO_BASE NRF_P0_BASE - - -/* QDEC */ -/* The registers PSELA, PSELB and PSELLED were restructured into a struct. */ -#define PSELLED PSEL.LED -#define PSELA PSEL.A -#define PSELB PSEL.B - - -/* SPIS */ -/* The registers PSELSCK, PSELMISO, PSELMOSI, PSELCSN were restructured into a struct. */ -#define PSELSCK PSEL.SCK -#define PSELMISO PSEL.MISO -#define PSELMOSI PSEL.MOSI -#define PSELCSN PSEL.CSN - -/* The registers RXDPTR, MAXRX, AMOUNTRX were restructured into a struct */ -#define RXDPTR RXD.PTR -#define MAXRX RXD.MAXCNT -#define AMOUNTRX RXD.AMOUNT - -#define SPIS_MAXRX_MAXRX_Pos SPIS_RXD_MAXCNT_MAXCNT_Pos -#define SPIS_MAXRX_MAXRX_Msk SPIS_RXD_MAXCNT_MAXCNT_Msk - -#define SPIS_AMOUNTRX_AMOUNTRX_Pos SPIS_RXD_AMOUNT_AMOUNT_Pos -#define SPIS_AMOUNTRX_AMOUNTRX_Msk SPIS_RXD_AMOUNT_AMOUNT_Msk - -/* The registers TXDPTR, MAXTX, AMOUNTTX were restructured into a struct */ -#define TXDPTR TXD.PTR -#define MAXTX TXD.MAXCNT -#define AMOUNTTX TXD.AMOUNT - -#define SPIS_MAXTX_MAXTX_Pos SPIS_TXD_MAXCNT_MAXCNT_Pos -#define SPIS_MAXTX_MAXTX_Msk SPIS_TXD_MAXCNT_MAXCNT_Msk - -#define SPIS_AMOUNTTX_AMOUNTTX_Pos SPIS_TXD_AMOUNT_AMOUNT_Pos -#define SPIS_AMOUNTTX_AMOUNTTX_Msk SPIS_TXD_AMOUNT_AMOUNT_Msk - - -/* UART */ -/* The registers PSELRTS, PSELTXD, PSELCTS, PSELRXD were restructured into a struct. */ -#define PSELRTS PSEL.RTS -#define PSELTXD PSEL.TXD -#define PSELCTS PSEL.CTS -#define PSELRXD PSEL.RXD - -/* TWI */ -/* The registers PSELSCL, PSELSDA were restructured into a struct. */ -#define PSELSCL PSEL.SCL -#define PSELSDA PSEL.SDA - - - -/* From nrf51_deprecated.h */ - -/* NVMC */ -/* The register ERASEPROTECTEDPAGE changed name to ERASEPCR0 in the documentation. */ -#define ERASEPROTECTEDPAGE ERASEPCR0 - - -/* IRQ */ -/* COMP module was eliminated. Adapted to nrf52840 headers. */ -#define LPCOMP_COMP_IRQHandler COMP_LPCOMP_IRQHandler -#define LPCOMP_COMP_IRQn COMP_LPCOMP_IRQn - - -/* REFSEL register redefined enumerated values and added some more. */ -#define LPCOMP_REFSEL_REFSEL_SupplyOneEighthPrescaling LPCOMP_REFSEL_REFSEL_Ref1_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyTwoEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref2_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyThreeEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref3_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyFourEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref4_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplyFiveEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref5_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplySixEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref6_8Vdd -#define LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling LPCOMP_REFSEL_REFSEL_Ref7_8Vdd - - -/* RADIO */ -/* The name of the field SKIPADDR was corrected. Old macros added for compatibility. */ -#define RADIO_CRCCNF_SKIP_ADDR_Pos RADIO_CRCCNF_SKIPADDR_Pos -#define RADIO_CRCCNF_SKIP_ADDR_Msk RADIO_CRCCNF_SKIPADDR_Msk -#define RADIO_CRCCNF_SKIP_ADDR_Include RADIO_CRCCNF_SKIPADDR_Include -#define RADIO_CRCCNF_SKIP_ADDR_Skip RADIO_CRCCNF_SKIPADDR_Skip - - -/* FICR */ -/* The registers FICR.DEVICEID0 and FICR.DEVICEID1 were renamed into an array. */ -#define DEVICEID0 DEVICEID[0] -#define DEVICEID1 DEVICEID[1] - -/* The registers FICR.ER0, FICR.ER1, FICR.ER2 and FICR.ER3 were renamed into an array. */ -#define ER0 ER[0] -#define ER1 ER[1] -#define ER2 ER[2] -#define ER3 ER[3] - -/* The registers FICR.IR0, FICR.IR1, FICR.IR2 and FICR.IR3 were renamed into an array. */ -#define IR0 IR[0] -#define IR1 IR[1] -#define IR2 IR[2] -#define IR3 IR[3] - -/* The registers FICR.DEVICEADDR0 and FICR.DEVICEADDR1 were renamed into an array. */ -#define DEVICEADDR0 DEVICEADDR[0] -#define DEVICEADDR1 DEVICEADDR[1] - - -/* PPI */ -/* The tasks PPI.TASKS_CHGxEN and PPI.TASKS_CHGxDIS were renamed into an array of structs. */ -#define TASKS_CHG0EN TASKS_CHG[0].EN -#define TASKS_CHG0DIS TASKS_CHG[0].DIS -#define TASKS_CHG1EN TASKS_CHG[1].EN -#define TASKS_CHG1DIS TASKS_CHG[1].DIS -#define TASKS_CHG2EN TASKS_CHG[2].EN -#define TASKS_CHG2DIS TASKS_CHG[2].DIS -#define TASKS_CHG3EN TASKS_CHG[3].EN -#define TASKS_CHG3DIS TASKS_CHG[3].DIS - -/* The registers PPI.CHx_EEP and PPI.CHx_TEP were renamed into an array of structs. */ -#define CH0_EEP CH[0].EEP -#define CH0_TEP CH[0].TEP -#define CH1_EEP CH[1].EEP -#define CH1_TEP CH[1].TEP -#define CH2_EEP CH[2].EEP -#define CH2_TEP CH[2].TEP -#define CH3_EEP CH[3].EEP -#define CH3_TEP CH[3].TEP -#define CH4_EEP CH[4].EEP -#define CH4_TEP CH[4].TEP -#define CH5_EEP CH[5].EEP -#define CH5_TEP CH[5].TEP -#define CH6_EEP CH[6].EEP -#define CH6_TEP CH[6].TEP -#define CH7_EEP CH[7].EEP -#define CH7_TEP CH[7].TEP -#define CH8_EEP CH[8].EEP -#define CH8_TEP CH[8].TEP -#define CH9_EEP CH[9].EEP -#define CH9_TEP CH[9].TEP -#define CH10_EEP CH[10].EEP -#define CH10_TEP CH[10].TEP -#define CH11_EEP CH[11].EEP -#define CH11_TEP CH[11].TEP -#define CH12_EEP CH[12].EEP -#define CH12_TEP CH[12].TEP -#define CH13_EEP CH[13].EEP -#define CH13_TEP CH[13].TEP -#define CH14_EEP CH[14].EEP -#define CH14_TEP CH[14].TEP -#define CH15_EEP CH[15].EEP -#define CH15_TEP CH[15].TEP - -/* The registers PPI.CHG0, PPI.CHG1, PPI.CHG2 and PPI.CHG3 were renamed into an array. */ -#define CHG0 CHG[0] -#define CHG1 CHG[1] -#define CHG2 CHG[2] -#define CHG3 CHG[3] - -/* All bitfield macros for the CHGx registers therefore changed name. */ -#define PPI_CHG0_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG0_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG0_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG0_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG0_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG0_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG0_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG0_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG0_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG0_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG0_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG0_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG0_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG0_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG0_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG0_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG0_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG0_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG0_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG0_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG0_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG0_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG0_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG0_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG0_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG0_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG0_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG0_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG0_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG0_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG0_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG0_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG0_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG0_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG0_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG0_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG0_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG0_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG0_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG0_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG0_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG0_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG0_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG0_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG0_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG0_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG0_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG0_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG0_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG0_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG0_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG0_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG0_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG0_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG0_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG0_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG0_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG0_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG0_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG0_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG0_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG0_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG0_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG0_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG1_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG1_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG1_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG1_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG1_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG1_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG1_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG1_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG1_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG1_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG1_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG1_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG1_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG1_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG1_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG1_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG1_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG1_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG1_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG1_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG1_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG1_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG1_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG1_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG1_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG1_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG1_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG1_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG1_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG1_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG1_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG1_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG1_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG1_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG1_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG1_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG1_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG1_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG1_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG1_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG1_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG1_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG1_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG1_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG1_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG1_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG1_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG1_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG1_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG1_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG1_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG1_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG1_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG1_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG1_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG1_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG1_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG1_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG1_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG1_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG1_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG1_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG1_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG1_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG2_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG2_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG2_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG2_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG2_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG2_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG2_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG2_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG2_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG2_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG2_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG2_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG2_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG2_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG2_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG2_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG2_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG2_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG2_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG2_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG2_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG2_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG2_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG2_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG2_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG2_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG2_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG2_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG2_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG2_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG2_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG2_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG2_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG2_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG2_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG2_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG2_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG2_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG2_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG2_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG2_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG2_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG2_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG2_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG2_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG2_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG2_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG2_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG2_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG2_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG2_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG2_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG2_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG2_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG2_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG2_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG2_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG2_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG2_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG2_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG2_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG2_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG2_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG2_CH0_Included PPI_CHG_CH0_Included - -#define PPI_CHG3_CH15_Pos PPI_CHG_CH15_Pos -#define PPI_CHG3_CH15_Msk PPI_CHG_CH15_Msk -#define PPI_CHG3_CH15_Excluded PPI_CHG_CH15_Excluded -#define PPI_CHG3_CH15_Included PPI_CHG_CH15_Included - -#define PPI_CHG3_CH14_Pos PPI_CHG_CH14_Pos -#define PPI_CHG3_CH14_Msk PPI_CHG_CH14_Msk -#define PPI_CHG3_CH14_Excluded PPI_CHG_CH14_Excluded -#define PPI_CHG3_CH14_Included PPI_CHG_CH14_Included - -#define PPI_CHG3_CH13_Pos PPI_CHG_CH13_Pos -#define PPI_CHG3_CH13_Msk PPI_CHG_CH13_Msk -#define PPI_CHG3_CH13_Excluded PPI_CHG_CH13_Excluded -#define PPI_CHG3_CH13_Included PPI_CHG_CH13_Included - -#define PPI_CHG3_CH12_Pos PPI_CHG_CH12_Pos -#define PPI_CHG3_CH12_Msk PPI_CHG_CH12_Msk -#define PPI_CHG3_CH12_Excluded PPI_CHG_CH12_Excluded -#define PPI_CHG3_CH12_Included PPI_CHG_CH12_Included - -#define PPI_CHG3_CH11_Pos PPI_CHG_CH11_Pos -#define PPI_CHG3_CH11_Msk PPI_CHG_CH11_Msk -#define PPI_CHG3_CH11_Excluded PPI_CHG_CH11_Excluded -#define PPI_CHG3_CH11_Included PPI_CHG_CH11_Included - -#define PPI_CHG3_CH10_Pos PPI_CHG_CH10_Pos -#define PPI_CHG3_CH10_Msk PPI_CHG_CH10_Msk -#define PPI_CHG3_CH10_Excluded PPI_CHG_CH10_Excluded -#define PPI_CHG3_CH10_Included PPI_CHG_CH10_Included - -#define PPI_CHG3_CH9_Pos PPI_CHG_CH9_Pos -#define PPI_CHG3_CH9_Msk PPI_CHG_CH9_Msk -#define PPI_CHG3_CH9_Excluded PPI_CHG_CH9_Excluded -#define PPI_CHG3_CH9_Included PPI_CHG_CH9_Included - -#define PPI_CHG3_CH8_Pos PPI_CHG_CH8_Pos -#define PPI_CHG3_CH8_Msk PPI_CHG_CH8_Msk -#define PPI_CHG3_CH8_Excluded PPI_CHG_CH8_Excluded -#define PPI_CHG3_CH8_Included PPI_CHG_CH8_Included - -#define PPI_CHG3_CH7_Pos PPI_CHG_CH7_Pos -#define PPI_CHG3_CH7_Msk PPI_CHG_CH7_Msk -#define PPI_CHG3_CH7_Excluded PPI_CHG_CH7_Excluded -#define PPI_CHG3_CH7_Included PPI_CHG_CH7_Included - -#define PPI_CHG3_CH6_Pos PPI_CHG_CH6_Pos -#define PPI_CHG3_CH6_Msk PPI_CHG_CH6_Msk -#define PPI_CHG3_CH6_Excluded PPI_CHG_CH6_Excluded -#define PPI_CHG3_CH6_Included PPI_CHG_CH6_Included - -#define PPI_CHG3_CH5_Pos PPI_CHG_CH5_Pos -#define PPI_CHG3_CH5_Msk PPI_CHG_CH5_Msk -#define PPI_CHG3_CH5_Excluded PPI_CHG_CH5_Excluded -#define PPI_CHG3_CH5_Included PPI_CHG_CH5_Included - -#define PPI_CHG3_CH4_Pos PPI_CHG_CH4_Pos -#define PPI_CHG3_CH4_Msk PPI_CHG_CH4_Msk -#define PPI_CHG3_CH4_Excluded PPI_CHG_CH4_Excluded -#define PPI_CHG3_CH4_Included PPI_CHG_CH4_Included - -#define PPI_CHG3_CH3_Pos PPI_CHG_CH3_Pos -#define PPI_CHG3_CH3_Msk PPI_CHG_CH3_Msk -#define PPI_CHG3_CH3_Excluded PPI_CHG_CH3_Excluded -#define PPI_CHG3_CH3_Included PPI_CHG_CH3_Included - -#define PPI_CHG3_CH2_Pos PPI_CHG_CH2_Pos -#define PPI_CHG3_CH2_Msk PPI_CHG_CH2_Msk -#define PPI_CHG3_CH2_Excluded PPI_CHG_CH2_Excluded -#define PPI_CHG3_CH2_Included PPI_CHG_CH2_Included - -#define PPI_CHG3_CH1_Pos PPI_CHG_CH1_Pos -#define PPI_CHG3_CH1_Msk PPI_CHG_CH1_Msk -#define PPI_CHG3_CH1_Excluded PPI_CHG_CH1_Excluded -#define PPI_CHG3_CH1_Included PPI_CHG_CH1_Included - -#define PPI_CHG3_CH0_Pos PPI_CHG_CH0_Pos -#define PPI_CHG3_CH0_Msk PPI_CHG_CH0_Msk -#define PPI_CHG3_CH0_Excluded PPI_CHG_CH0_Excluded -#define PPI_CHG3_CH0_Included PPI_CHG_CH0_Included - - - - -/*lint --flb "Leave library region" */ - -#endif /* NRF51_TO_NRF52840_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52.h deleted file mode 100644 index 9018fe6..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52.h +++ /dev/null @@ -1,2100 +0,0 @@ - -/****************************************************************************************************//** - * @file nrf52.h - * - * @brief CMSIS Cortex-M4 Peripheral Access Layer Header File for - * nrf52 from Nordic Semiconductor. - * - * @version V1 - * @date 3. October 2017 - * - * @note Generated with SVDConv V2.81d - * from CMSIS SVD File 'nrf52.svd' Version 1, - * - * @par Copyright (c) 2010 - 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. - * - * - *******************************************************************************************************/ - - - -/** @addtogroup Nordic Semiconductor - * @{ - */ - -/** @addtogroup nrf52 - * @{ - */ - -#ifndef NRF52_H -#define NRF52_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* ------------------------- Interrupt Number Definition ------------------------ */ - -typedef enum { -/* ------------------- Cortex-M4 Processor Exceptions Numbers ------------------- */ - Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */ - NonMaskableInt_IRQn = -14, /*!< 2 Non maskable Interrupt, cannot be stopped or preempted */ - HardFault_IRQn = -13, /*!< 3 Hard Fault, all classes of Fault */ - MemoryManagement_IRQn = -12, /*!< 4 Memory Management, MPU mismatch, including Access Violation - and No Match */ - BusFault_IRQn = -11, /*!< 5 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory - related Fault */ - UsageFault_IRQn = -10, /*!< 6 Usage Fault, i.e. Undef Instruction, Illegal State Transition */ - SVCall_IRQn = -5, /*!< 11 System Service Call via SVC instruction */ - DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor */ - PendSV_IRQn = -2, /*!< 14 Pendable request for system service */ - SysTick_IRQn = -1, /*!< 15 System Tick Timer */ -/* ---------------------- nrf52 Specific Interrupt Numbers ---------------------- */ - POWER_CLOCK_IRQn = 0, /*!< 0 POWER_CLOCK */ - RADIO_IRQn = 1, /*!< 1 RADIO */ - UARTE0_UART0_IRQn = 2, /*!< 2 UARTE0_UART0 */ - SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn= 3, /*!< 3 SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 */ - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn= 4, /*!< 4 SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 */ - NFCT_IRQn = 5, /*!< 5 NFCT */ - GPIOTE_IRQn = 6, /*!< 6 GPIOTE */ - SAADC_IRQn = 7, /*!< 7 SAADC */ - TIMER0_IRQn = 8, /*!< 8 TIMER0 */ - TIMER1_IRQn = 9, /*!< 9 TIMER1 */ - TIMER2_IRQn = 10, /*!< 10 TIMER2 */ - RTC0_IRQn = 11, /*!< 11 RTC0 */ - TEMP_IRQn = 12, /*!< 12 TEMP */ - RNG_IRQn = 13, /*!< 13 RNG */ - ECB_IRQn = 14, /*!< 14 ECB */ - CCM_AAR_IRQn = 15, /*!< 15 CCM_AAR */ - WDT_IRQn = 16, /*!< 16 WDT */ - RTC1_IRQn = 17, /*!< 17 RTC1 */ - QDEC_IRQn = 18, /*!< 18 QDEC */ - COMP_LPCOMP_IRQn = 19, /*!< 19 COMP_LPCOMP */ - SWI0_EGU0_IRQn = 20, /*!< 20 SWI0_EGU0 */ - SWI1_EGU1_IRQn = 21, /*!< 21 SWI1_EGU1 */ - SWI2_EGU2_IRQn = 22, /*!< 22 SWI2_EGU2 */ - SWI3_EGU3_IRQn = 23, /*!< 23 SWI3_EGU3 */ - SWI4_EGU4_IRQn = 24, /*!< 24 SWI4_EGU4 */ - SWI5_EGU5_IRQn = 25, /*!< 25 SWI5_EGU5 */ - TIMER3_IRQn = 26, /*!< 26 TIMER3 */ - TIMER4_IRQn = 27, /*!< 27 TIMER4 */ - PWM0_IRQn = 28, /*!< 28 PWM0 */ - PDM_IRQn = 29, /*!< 29 PDM */ - MWU_IRQn = 32, /*!< 32 MWU */ - PWM1_IRQn = 33, /*!< 33 PWM1 */ - PWM2_IRQn = 34, /*!< 34 PWM2 */ - SPIM2_SPIS2_SPI2_IRQn = 35, /*!< 35 SPIM2_SPIS2_SPI2 */ - RTC2_IRQn = 36, /*!< 36 RTC2 */ - I2S_IRQn = 37, /*!< 37 I2S */ - FPU_IRQn = 38 /*!< 38 FPU */ -} IRQn_Type; - - -/** @addtogroup Configuration_of_CMSIS - * @{ - */ - - -/* ================================================================================ */ -/* ================ Processor and Core Peripheral Section ================ */ -/* ================================================================================ */ - -/* ----------------Configuration of the Cortex-M4 Processor and Core Peripherals---------------- */ -#define __CM4_REV 0x0001 /*!< Cortex-M4 Core Revision */ -#define __MPU_PRESENT 1 /*!< MPU present or not */ -#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */ -#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ -#define __FPU_PRESENT 1 /*!< FPU present or not */ -/** @} */ /* End of group Configuration_of_CMSIS */ - -#include "core_cm4.h" /*!< Cortex-M4 processor and core peripherals */ -#include "system_nrf52.h" /*!< nrf52 System */ - - -/* ================================================================================ */ -/* ================ Device Specific Peripheral Section ================ */ -/* ================================================================================ */ - - -/** @addtogroup Device_Peripheral_Registers - * @{ - */ - - -/* ------------------- Start of section using anonymous unions ------------------ */ -#if defined(__CC_ARM) - #pragma push - #pragma anon_unions -#elif defined(__ICCARM__) - #pragma language=extended -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) -/* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning 586 -#else - #warning Not supported compiler type -#endif - - -typedef struct { - __I uint32_t PART; /*!< Part code */ - __I uint32_t VARIANT; /*!< Part Variant, Hardware version and Production configuration */ - __I uint32_t PACKAGE; /*!< Package option */ - __I uint32_t RAM; /*!< RAM variant */ - __I uint32_t FLASH; /*!< Flash variant */ - __IO uint32_t UNUSED0[3]; /*!< Description collection[0]: Unspecified */ -} FICR_INFO_Type; - -typedef struct { - __I uint32_t A0; /*!< Slope definition A0. */ - __I uint32_t A1; /*!< Slope definition A1. */ - __I uint32_t A2; /*!< Slope definition A2. */ - __I uint32_t A3; /*!< Slope definition A3. */ - __I uint32_t A4; /*!< Slope definition A4. */ - __I uint32_t A5; /*!< Slope definition A5. */ - __I uint32_t B0; /*!< y-intercept B0. */ - __I uint32_t B1; /*!< y-intercept B1. */ - __I uint32_t B2; /*!< y-intercept B2. */ - __I uint32_t B3; /*!< y-intercept B3. */ - __I uint32_t B4; /*!< y-intercept B4. */ - __I uint32_t B5; /*!< y-intercept B5. */ - __I uint32_t T0; /*!< Segment end T0. */ - __I uint32_t T1; /*!< Segment end T1. */ - __I uint32_t T2; /*!< Segment end T2. */ - __I uint32_t T3; /*!< Segment end T3. */ - __I uint32_t T4; /*!< Segment end T4. */ -} FICR_TEMP_Type; - -typedef struct { - __I uint32_t TAGHEADER0; /*!< Default header for NFC Tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - __I uint32_t TAGHEADER1; /*!< Default header for NFC Tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - __I uint32_t TAGHEADER2; /*!< Default header for NFC Tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - __I uint32_t TAGHEADER3; /*!< Default header for NFC Tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ -} FICR_NFC_Type; - -typedef struct { - __IO uint32_t POWER; /*!< Description cluster[0]: RAM0 power control register */ - __O uint32_t POWERSET; /*!< Description cluster[0]: RAM0 power control set register */ - __O uint32_t POWERCLR; /*!< Description cluster[0]: RAM0 power control clear register */ - __I uint32_t RESERVED0; -} POWER_RAM_Type; - -typedef struct { - __IO uint32_t RTS; /*!< Pin select for RTS signal */ - __IO uint32_t TXD; /*!< Pin select for TXD signal */ - __IO uint32_t CTS; /*!< Pin select for CTS signal */ - __IO uint32_t RXD; /*!< Pin select for RXD signal */ -} UARTE_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} UARTE_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} UARTE_TXD_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ -} SPIM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} SPIM_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} SPIM_TXD_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t CSN; /*!< Pin select for CSN signal */ -} SPIS_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RXD data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes received in last granted transaction */ -} SPIS_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< TXD data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transmitted in last granted transaction */ -} SPIS_TXD_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL signal */ - __IO uint32_t SDA; /*!< Pin select for SDA signal */ -} TWIM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} TWIM_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} TWIM_TXD_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL signal */ - __IO uint32_t SDA; /*!< Pin select for SDA signal */ -} TWIS_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RXD Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in RXD buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last RXD transaction */ -} TWIS_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< TXD Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in TXD buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last TXD transaction */ -} TWIS_TXD_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MOSI; /*!< Pin select for MOSI */ - __IO uint32_t MISO; /*!< Pin select for MISO */ -} SPI_PSEL_Type; - -typedef struct { - __IO uint32_t RX; /*!< Result of last incoming frames */ -} NFCT_FRAMESTATUS_Type; - -typedef struct { - __IO uint32_t FRAMECONFIG; /*!< Configuration of outgoing frames */ - __IO uint32_t AMOUNT; /*!< Size of outgoing frame */ -} NFCT_TXD_Type; - -typedef struct { - __IO uint32_t FRAMECONFIG; /*!< Configuration of incoming frames */ - __I uint32_t AMOUNT; /*!< Size of last incoming frame */ -} NFCT_RXD_Type; - -typedef struct { - __IO uint32_t LIMITH; /*!< Description cluster[0]: Last results is equal or above CH[0].LIMIT.HIGH */ - __IO uint32_t LIMITL; /*!< Description cluster[0]: Last results is equal or below CH[0].LIMIT.LOW */ -} SAADC_EVENTS_CH_Type; - -typedef struct { - __IO uint32_t PSELP; /*!< Description cluster[0]: Input positive pin selection for CH[0] */ - __IO uint32_t PSELN; /*!< Description cluster[0]: Input negative pin selection for CH[0] */ - __IO uint32_t CONFIG; /*!< Description cluster[0]: Input configuration for CH[0] */ - __IO uint32_t LIMIT; /*!< Description cluster[0]: High/low limits for event monitoring - a channel */ -} SAADC_CH_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of buffer words to transfer */ - __I uint32_t AMOUNT; /*!< Number of buffer words transferred since last START */ -} SAADC_RESULT_Type; - -typedef struct { - __IO uint32_t LED; /*!< Pin select for LED signal */ - __IO uint32_t A; /*!< Pin select for A signal */ - __IO uint32_t B; /*!< Pin select for B signal */ -} QDEC_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Description cluster[0]: Beginning address in Data RAM of this - sequence */ - __IO uint32_t CNT; /*!< Description cluster[0]: Amount of values (duty cycles) in this - sequence */ - __IO uint32_t REFRESH; /*!< Description cluster[0]: Amount of additional PWM periods between - samples loaded into compare register */ - __IO uint32_t ENDDELAY; /*!< Description cluster[0]: Time added after the sequence */ - __I uint32_t RESERVED1[4]; -} PWM_SEQ_Type; - -typedef struct { - __IO uint32_t OUT[4]; /*!< Description collection[0]: Output pin select for PWM channel - 0 */ -} PWM_PSEL_Type; - -typedef struct { - __IO uint32_t CLK; /*!< Pin number configuration for PDM CLK signal */ - __IO uint32_t DIN; /*!< Pin number configuration for PDM DIN signal */ -} PDM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RAM address pointer to write samples to with EasyDMA */ - __IO uint32_t MAXCNT; /*!< Number of samples to allocate memory for in EasyDMA mode */ -} PDM_SAMPLE_Type; - -typedef struct { - __O uint32_t EN; /*!< Description cluster[0]: Enable channel group 0 */ - __O uint32_t DIS; /*!< Description cluster[0]: Disable channel group 0 */ -} PPI_TASKS_CHG_Type; - -typedef struct { - __IO uint32_t EEP; /*!< Description cluster[0]: Channel 0 event end-point */ - __IO uint32_t TEP; /*!< Description cluster[0]: Channel 0 task end-point */ -} PPI_CH_Type; - -typedef struct { - __IO uint32_t TEP; /*!< Description cluster[0]: Channel 0 task end-point */ -} PPI_FORK_Type; - -typedef struct { - __IO uint32_t WA; /*!< Description cluster[0]: Write access to region 0 detected */ - __IO uint32_t RA; /*!< Description cluster[0]: Read access to region 0 detected */ -} MWU_EVENTS_REGION_Type; - -typedef struct { - __IO uint32_t WA; /*!< Description cluster[0]: Write access to peripheral region 0 - detected */ - __IO uint32_t RA; /*!< Description cluster[0]: Read access to peripheral region 0 detected */ -} MWU_EVENTS_PREGION_Type; - -typedef struct { - __IO uint32_t SUBSTATWA; /*!< Description cluster[0]: Source of event/interrupt in region - 0, write access detected while corresponding subregion was enabled - for watching */ - __IO uint32_t SUBSTATRA; /*!< Description cluster[0]: Source of event/interrupt in region - 0, read access detected while corresponding subregion was enabled - for watching */ -} MWU_PERREGION_Type; - -typedef struct { - __IO uint32_t START; /*!< Description cluster[0]: Start address for region 0 */ - __IO uint32_t END; /*!< Description cluster[0]: End address of region 0 */ - __I uint32_t RESERVED2[2]; -} MWU_REGION_Type; - -typedef struct { - __I uint32_t START; /*!< Description cluster[0]: Reserved for future use */ - __I uint32_t END; /*!< Description cluster[0]: Reserved for future use */ - __IO uint32_t SUBS; /*!< Description cluster[0]: Subregions of region 0 */ - __I uint32_t RESERVED3; -} MWU_PREGION_Type; - -typedef struct { - __IO uint32_t MODE; /*!< I2S mode. */ - __IO uint32_t RXEN; /*!< Reception (RX) enable. */ - __IO uint32_t TXEN; /*!< Transmission (TX) enable. */ - __IO uint32_t MCKEN; /*!< Master clock generator enable. */ - __IO uint32_t MCKFREQ; /*!< Master clock generator frequency. */ - __IO uint32_t RATIO; /*!< MCK / LRCK ratio. */ - __IO uint32_t SWIDTH; /*!< Sample width. */ - __IO uint32_t ALIGN; /*!< Alignment of sample within a frame. */ - __IO uint32_t FORMAT; /*!< Frame format. */ - __IO uint32_t CHANNELS; /*!< Enable channels. */ -} I2S_CONFIG_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Receive buffer RAM start address. */ -} I2S_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Transmit buffer RAM start address. */ -} I2S_TXD_Type; - -typedef struct { - __IO uint32_t MAXCNT; /*!< Size of RXD and TXD buffers. */ -} I2S_RXTXD_Type; - -typedef struct { - __IO uint32_t MCK; /*!< Pin select for MCK signal. */ - __IO uint32_t SCK; /*!< Pin select for SCK signal. */ - __IO uint32_t LRCK; /*!< Pin select for LRCK signal. */ - __IO uint32_t SDIN; /*!< Pin select for SDIN signal. */ - __IO uint32_t SDOUT; /*!< Pin select for SDOUT signal. */ -} I2S_PSEL_Type; - - -/* ================================================================================ */ -/* ================ FICR ================ */ -/* ================================================================================ */ - - -/** - * @brief Factory Information Configuration Registers (FICR) - */ - -typedef struct { /*!< FICR Structure */ - __I uint32_t RESERVED0[4]; - __I uint32_t CODEPAGESIZE; /*!< Code memory page size */ - __I uint32_t CODESIZE; /*!< Code memory size */ - __I uint32_t RESERVED1[18]; - __I uint32_t DEVICEID[2]; /*!< Description collection[0]: Device identifier */ - __I uint32_t RESERVED2[6]; - __I uint32_t ER[4]; /*!< Description collection[0]: Encryption Root, word 0 */ - __I uint32_t IR[4]; /*!< Description collection[0]: Identity Root, word 0 */ - __I uint32_t DEVICEADDRTYPE; /*!< Device address type */ - __I uint32_t DEVICEADDR[2]; /*!< Description collection[0]: Device address 0 */ - __I uint32_t RESERVED3[21]; - FICR_INFO_Type INFO; /*!< Device info */ - __I uint32_t RESERVED4[185]; - FICR_TEMP_Type TEMP; /*!< Registers storing factory TEMP module linearization coefficients */ - __I uint32_t RESERVED5[2]; - FICR_NFC_Type NFC; /*!< Unspecified */ -} NRF_FICR_Type; - - -/* ================================================================================ */ -/* ================ UICR ================ */ -/* ================================================================================ */ - - -/** - * @brief User Information Configuration Registers (UICR) - */ - -typedef struct { /*!< UICR Structure */ - __IO uint32_t UNUSED0; /*!< Unspecified */ - __IO uint32_t UNUSED1; /*!< Unspecified */ - __IO uint32_t UNUSED2; /*!< Unspecified */ - __I uint32_t RESERVED0; - __IO uint32_t UNUSED3; /*!< Unspecified */ - __IO uint32_t NRFFW[15]; /*!< Description collection[0]: Reserved for Nordic firmware design */ - __IO uint32_t NRFHW[12]; /*!< Description collection[0]: Reserved for Nordic hardware design */ - __IO uint32_t CUSTOMER[32]; /*!< Description collection[0]: Reserved for customer */ - __I uint32_t RESERVED1[64]; - __IO uint32_t PSELRESET[2]; /*!< Description collection[0]: Mapping of the nRESET function (see - POWER chapter for details) */ - __IO uint32_t APPROTECT; /*!< Access Port protection */ - __IO uint32_t NFCPINS; /*!< Setting of pins dedicated to NFC functionality: NFC antenna - or GPIO */ -} NRF_UICR_Type; - - -/* ================================================================================ */ -/* ================ BPROT ================ */ -/* ================================================================================ */ - - -/** - * @brief Block Protect (BPROT) - */ - -typedef struct { /*!< BPROT Structure */ - __I uint32_t RESERVED0[384]; - __IO uint32_t CONFIG0; /*!< Block protect configuration register 0 */ - __IO uint32_t CONFIG1; /*!< Block protect configuration register 1 */ - __IO uint32_t DISABLEINDEBUG; /*!< Disable protection mechanism in debug interface mode */ - __IO uint32_t UNUSED0; /*!< Unspecified */ - __IO uint32_t CONFIG2; /*!< Block protect configuration register 2 */ - __IO uint32_t CONFIG3; /*!< Block protect configuration register 3 */ -} NRF_BPROT_Type; - - -/* ================================================================================ */ -/* ================ POWER ================ */ -/* ================================================================================ */ - - -/** - * @brief Power control (POWER) - */ - -typedef struct { /*!< POWER Structure */ - __I uint32_t RESERVED0[30]; - __O uint32_t TASKS_CONSTLAT; /*!< Enable constant latency mode */ - __O uint32_t TASKS_LOWPWR; /*!< Enable low power mode (variable latency) */ - __I uint32_t RESERVED1[34]; - __IO uint32_t EVENTS_POFWARN; /*!< Power failure warning */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_SLEEPENTER; /*!< CPU entered WFI/WFE sleep */ - __IO uint32_t EVENTS_SLEEPEXIT; /*!< CPU exited WFI/WFE sleep */ - __I uint32_t RESERVED3[122]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[61]; - __IO uint32_t RESETREAS; /*!< Reset reason */ - __I uint32_t RESERVED5[9]; - __I uint32_t RAMSTATUS; /*!< Deprecated register - RAM status register */ - __I uint32_t RESERVED6[53]; - __O uint32_t SYSTEMOFF; /*!< System OFF register */ - __I uint32_t RESERVED7[3]; - __IO uint32_t POFCON; /*!< Power failure comparator configuration */ - __I uint32_t RESERVED8[2]; - __IO uint32_t GPREGRET; /*!< General purpose retention register */ - __IO uint32_t GPREGRET2; /*!< General purpose retention register */ - __IO uint32_t RAMON; /*!< Deprecated register - RAM on/off register (this register is - retained) */ - __I uint32_t RESERVED9[11]; - __IO uint32_t RAMONB; /*!< Deprecated register - RAM on/off register (this register is - retained) */ - __I uint32_t RESERVED10[8]; - __IO uint32_t DCDCEN; /*!< DC/DC enable register */ - __I uint32_t RESERVED11[225]; - POWER_RAM_Type RAM[8]; /*!< Unspecified */ -} NRF_POWER_Type; - - -/* ================================================================================ */ -/* ================ CLOCK ================ */ -/* ================================================================================ */ - - -/** - * @brief Clock control (CLOCK) - */ - -typedef struct { /*!< CLOCK Structure */ - __O uint32_t TASKS_HFCLKSTART; /*!< Start HFCLK crystal oscillator */ - __O uint32_t TASKS_HFCLKSTOP; /*!< Stop HFCLK crystal oscillator */ - __O uint32_t TASKS_LFCLKSTART; /*!< Start LFCLK source */ - __O uint32_t TASKS_LFCLKSTOP; /*!< Stop LFCLK source */ - __O uint32_t TASKS_CAL; /*!< Start calibration of LFRC oscillator */ - __O uint32_t TASKS_CTSTART; /*!< Start calibration timer */ - __O uint32_t TASKS_CTSTOP; /*!< Stop calibration timer */ - __I uint32_t RESERVED0[57]; - __IO uint32_t EVENTS_HFCLKSTARTED; /*!< HFCLK oscillator started */ - __IO uint32_t EVENTS_LFCLKSTARTED; /*!< LFCLK started */ - __I uint32_t RESERVED1; - __IO uint32_t EVENTS_DONE; /*!< Calibration of LFCLK RC oscillator complete event */ - __IO uint32_t EVENTS_CTTO; /*!< Calibration timer timeout */ - __I uint32_t RESERVED2[124]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[63]; - __I uint32_t HFCLKRUN; /*!< Status indicating that HFCLKSTART task has been triggered */ - __I uint32_t HFCLKSTAT; /*!< HFCLK status */ - __I uint32_t RESERVED4; - __I uint32_t LFCLKRUN; /*!< Status indicating that LFCLKSTART task has been triggered */ - __I uint32_t LFCLKSTAT; /*!< LFCLK status */ - __I uint32_t LFCLKSRCCOPY; /*!< Copy of LFCLKSRC register, set when LFCLKSTART task was triggered */ - __I uint32_t RESERVED5[62]; - __IO uint32_t LFCLKSRC; /*!< Clock source for the LFCLK */ - __I uint32_t RESERVED6[7]; - __IO uint32_t CTIV; /*!< Calibration timer interval */ - __I uint32_t RESERVED7[8]; - __IO uint32_t TRACECONFIG; /*!< Clocking options for the Trace Port debug interface */ -} NRF_CLOCK_Type; - - -/* ================================================================================ */ -/* ================ RADIO ================ */ -/* ================================================================================ */ - - -/** - * @brief 2.4 GHz Radio (RADIO) - */ - -typedef struct { /*!< RADIO Structure */ - __O uint32_t TASKS_TXEN; /*!< Enable RADIO in TX mode */ - __O uint32_t TASKS_RXEN; /*!< Enable RADIO in RX mode */ - __O uint32_t TASKS_START; /*!< Start RADIO */ - __O uint32_t TASKS_STOP; /*!< Stop RADIO */ - __O uint32_t TASKS_DISABLE; /*!< Disable RADIO */ - __O uint32_t TASKS_RSSISTART; /*!< Start the RSSI and take one single sample of the receive signal - strength. */ - __O uint32_t TASKS_RSSISTOP; /*!< Stop the RSSI measurement */ - __O uint32_t TASKS_BCSTART; /*!< Start the bit counter */ - __O uint32_t TASKS_BCSTOP; /*!< Stop the bit counter */ - __I uint32_t RESERVED0[55]; - __IO uint32_t EVENTS_READY; /*!< RADIO has ramped up and is ready to be started */ - __IO uint32_t EVENTS_ADDRESS; /*!< Address sent or received */ - __IO uint32_t EVENTS_PAYLOAD; /*!< Packet payload sent or received */ - __IO uint32_t EVENTS_END; /*!< Packet sent or received */ - __IO uint32_t EVENTS_DISABLED; /*!< RADIO has been disabled */ - __IO uint32_t EVENTS_DEVMATCH; /*!< A device address match occurred on the last received packet */ - __IO uint32_t EVENTS_DEVMISS; /*!< No device address match occurred on the last received packet */ - __IO uint32_t EVENTS_RSSIEND; /*!< Sampling of receive signal strength complete. */ - __I uint32_t RESERVED1[2]; - __IO uint32_t EVENTS_BCMATCH; /*!< Bit counter reached bit count value. */ - __I uint32_t RESERVED2; - __IO uint32_t EVENTS_CRCOK; /*!< Packet received with CRC ok */ - __IO uint32_t EVENTS_CRCERROR; /*!< Packet received with CRC error */ - __I uint32_t RESERVED3[50]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED4[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED5[61]; - __I uint32_t CRCSTATUS; /*!< CRC status */ - __I uint32_t RESERVED6; - __I uint32_t RXMATCH; /*!< Received address */ - __I uint32_t RXCRC; /*!< CRC field of previously received packet */ - __I uint32_t DAI; /*!< Device address match index */ - __I uint32_t RESERVED7[60]; - __IO uint32_t PACKETPTR; /*!< Packet pointer */ - __IO uint32_t FREQUENCY; /*!< Frequency */ - __IO uint32_t TXPOWER; /*!< Output power */ - __IO uint32_t MODE; /*!< Data rate and modulation */ - __IO uint32_t PCNF0; /*!< Packet configuration register 0 */ - __IO uint32_t PCNF1; /*!< Packet configuration register 1 */ - __IO uint32_t BASE0; /*!< Base address 0 */ - __IO uint32_t BASE1; /*!< Base address 1 */ - __IO uint32_t PREFIX0; /*!< Prefixes bytes for logical addresses 0-3 */ - __IO uint32_t PREFIX1; /*!< Prefixes bytes for logical addresses 4-7 */ - __IO uint32_t TXADDRESS; /*!< Transmit address select */ - __IO uint32_t RXADDRESSES; /*!< Receive address select */ - __IO uint32_t CRCCNF; /*!< CRC configuration */ - __IO uint32_t CRCPOLY; /*!< CRC polynomial */ - __IO uint32_t CRCINIT; /*!< CRC initial value */ - __IO uint32_t UNUSED0; /*!< Unspecified */ - __IO uint32_t TIFS; /*!< Inter Frame Spacing in us */ - __I uint32_t RSSISAMPLE; /*!< RSSI sample */ - __I uint32_t RESERVED8; - __I uint32_t STATE; /*!< Current radio state */ - __IO uint32_t DATAWHITEIV; /*!< Data whitening initial value */ - __I uint32_t RESERVED9[2]; - __IO uint32_t BCC; /*!< Bit counter compare */ - __I uint32_t RESERVED10[39]; - __IO uint32_t DAB[8]; /*!< Description collection[0]: Device address base segment 0 */ - __IO uint32_t DAP[8]; /*!< Description collection[0]: Device address prefix 0 */ - __IO uint32_t DACNF; /*!< Device address match configuration */ - __I uint32_t RESERVED11[3]; - __IO uint32_t MODECNF0; /*!< Radio mode configuration register 0 */ - __I uint32_t RESERVED12[618]; - __IO uint32_t POWER; /*!< Peripheral power control */ -} NRF_RADIO_Type; - - -/* ================================================================================ */ -/* ================ UARTE ================ */ -/* ================================================================================ */ - - -/** - * @brief UART with EasyDMA (UARTE) - */ - -typedef struct { /*!< UARTE Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start UART receiver */ - __O uint32_t TASKS_STOPRX; /*!< Stop UART receiver */ - __O uint32_t TASKS_STARTTX; /*!< Start UART transmitter */ - __O uint32_t TASKS_STOPTX; /*!< Stop UART transmitter */ - __I uint32_t RESERVED0[7]; - __O uint32_t TASKS_FLUSHRX; /*!< Flush RX FIFO into RX buffer */ - __I uint32_t RESERVED1[52]; - __IO uint32_t EVENTS_CTS; /*!< CTS is activated (set low). Clear To Send. */ - __IO uint32_t EVENTS_NCTS; /*!< CTS is deactivated (set high). Not Clear To Send. */ - __IO uint32_t EVENTS_RXDRDY; /*!< Data received in RXD (but potentially not yet transferred to - Data RAM) */ - __I uint32_t RESERVED2; - __IO uint32_t EVENTS_ENDRX; /*!< Receive buffer is filled up */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_TXDRDY; /*!< Data sent from TXD */ - __IO uint32_t EVENTS_ENDTX; /*!< Last TX byte transmitted */ - __IO uint32_t EVENTS_ERROR; /*!< Error detected */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_RXTO; /*!< Receiver timeout */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_RXSTARTED; /*!< UART receiver has started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< UART transmitter has started */ - __I uint32_t RESERVED6; - __IO uint32_t EVENTS_TXSTOPPED; /*!< Transmitter stopped */ - __I uint32_t RESERVED7[41]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[93]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED10[31]; - __IO uint32_t ENABLE; /*!< Enable UART */ - __I uint32_t RESERVED11; - UARTE_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[3]; - __IO uint32_t BAUDRATE; /*!< Baud rate. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED13[3]; - UARTE_RXD_Type RXD; /*!< RXD EasyDMA channel */ - __I uint32_t RESERVED14; - UARTE_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED15[7]; - __IO uint32_t CONFIG; /*!< Configuration of parity and hardware flow control */ -} NRF_UARTE_Type; - - -/* ================================================================================ */ -/* ================ UART ================ */ -/* ================================================================================ */ - - -/** - * @brief Universal Asynchronous Receiver/Transmitter (UART) - */ - -typedef struct { /*!< UART Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start UART receiver */ - __O uint32_t TASKS_STOPRX; /*!< Stop UART receiver */ - __O uint32_t TASKS_STARTTX; /*!< Start UART transmitter */ - __O uint32_t TASKS_STOPTX; /*!< Stop UART transmitter */ - __I uint32_t RESERVED0[3]; - __O uint32_t TASKS_SUSPEND; /*!< Suspend UART */ - __I uint32_t RESERVED1[56]; - __IO uint32_t EVENTS_CTS; /*!< CTS is activated (set low). Clear To Send. */ - __IO uint32_t EVENTS_NCTS; /*!< CTS is deactivated (set high). Not Clear To Send. */ - __IO uint32_t EVENTS_RXDRDY; /*!< Data received in RXD */ - __I uint32_t RESERVED2[4]; - __IO uint32_t EVENTS_TXDRDY; /*!< Data sent from TXD */ - __I uint32_t RESERVED3; - __IO uint32_t EVENTS_ERROR; /*!< Error detected */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_RXTO; /*!< Receiver timeout */ - __I uint32_t RESERVED5[46]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED6[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED7[93]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED8[31]; - __IO uint32_t ENABLE; /*!< Enable UART */ - __I uint32_t RESERVED9; - __IO uint32_t PSELRTS; /*!< Pin select for RTS */ - __IO uint32_t PSELTXD; /*!< Pin select for TXD */ - __IO uint32_t PSELCTS; /*!< Pin select for CTS */ - __IO uint32_t PSELRXD; /*!< Pin select for RXD */ - __I uint32_t RXD; /*!< RXD register */ - __O uint32_t TXD; /*!< TXD register */ - __I uint32_t RESERVED10; - __IO uint32_t BAUDRATE; /*!< Baud rate */ - __I uint32_t RESERVED11[17]; - __IO uint32_t CONFIG; /*!< Configuration of parity and hardware flow control */ -} NRF_UART_Type; - - -/* ================================================================================ */ -/* ================ SPIM ================ */ -/* ================================================================================ */ - - -/** - * @brief Serial Peripheral Interface Master with EasyDMA 0 (SPIM) - */ - -typedef struct { /*!< SPIM Structure */ - __I uint32_t RESERVED0[4]; - __O uint32_t TASKS_START; /*!< Start SPI transaction */ - __O uint32_t TASKS_STOP; /*!< Stop SPI transaction */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_SUSPEND; /*!< Suspend SPI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume SPI transaction */ - __I uint32_t RESERVED2[56]; - __IO uint32_t EVENTS_STOPPED; /*!< SPI transaction has stopped */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED4; - __IO uint32_t EVENTS_END; /*!< End of RXD buffer and TXD buffer reached */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_ENDTX; /*!< End of TXD buffer reached */ - __I uint32_t RESERVED6[10]; - __IO uint32_t EVENTS_STARTED; /*!< Transaction started */ - __I uint32_t RESERVED7[44]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[125]; - __IO uint32_t ENABLE; /*!< Enable SPIM */ - __I uint32_t RESERVED10; - SPIM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED11[4]; - __IO uint32_t FREQUENCY; /*!< SPI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED12[3]; - SPIM_RXD_Type RXD; /*!< RXD EasyDMA channel */ - SPIM_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED13[26]; - __IO uint32_t ORC; /*!< Over-read character. Character clocked out in case and over-read - of the TXD buffer. */ -} NRF_SPIM_Type; - - -/* ================================================================================ */ -/* ================ SPIS ================ */ -/* ================================================================================ */ - - -/** - * @brief SPI Slave 0 (SPIS) - */ - -typedef struct { /*!< SPIS Structure */ - __I uint32_t RESERVED0[9]; - __O uint32_t TASKS_ACQUIRE; /*!< Acquire SPI semaphore */ - __O uint32_t TASKS_RELEASE; /*!< Release SPI semaphore, enabling the SPI slave to acquire it */ - __I uint32_t RESERVED1[54]; - __IO uint32_t EVENTS_END; /*!< Granted transaction completed */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED3[5]; - __IO uint32_t EVENTS_ACQUIRED; /*!< Semaphore acquired */ - __I uint32_t RESERVED4[53]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED5[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED6[61]; - __I uint32_t SEMSTAT; /*!< Semaphore status register */ - __I uint32_t RESERVED7[15]; - __IO uint32_t STATUS; /*!< Status from last transaction */ - __I uint32_t RESERVED8[47]; - __IO uint32_t ENABLE; /*!< Enable SPI slave */ - __I uint32_t RESERVED9; - SPIS_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED10[7]; - SPIS_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED11; - SPIS_TXD_Type TXD; /*!< Unspecified */ - __I uint32_t RESERVED12; - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED13; - __IO uint32_t DEF; /*!< Default character. Character clocked out in case of an ignored - transaction. */ - __I uint32_t RESERVED14[24]; - __IO uint32_t ORC; /*!< Over-read character */ -} NRF_SPIS_Type; - - -/* ================================================================================ */ -/* ================ TWIM ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Master Interface with EasyDMA 0 (TWIM) - */ - -typedef struct { /*!< TWIM Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start TWI receive sequence */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTTX; /*!< Start TWI transmit sequence */ - __I uint32_t RESERVED1[2]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction. Must be issued while the TWI master is - not suspended. */ - __I uint32_t RESERVED2; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED3[56]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED5[8]; - __IO uint32_t EVENTS_SUSPENDED; /*!< Last byte has been sent out after the SUSPEND task has been - issued, TWI traffic is now suspended. */ - __IO uint32_t EVENTS_RXSTARTED; /*!< Receive sequence started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< Transmit sequence started */ - __I uint32_t RESERVED6[2]; - __IO uint32_t EVENTS_LASTRX; /*!< Byte boundary, starting to receive the last byte */ - __IO uint32_t EVENTS_LASTTX; /*!< Byte boundary, starting to transmit the last byte */ - __I uint32_t RESERVED7[39]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[110]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED10[14]; - __IO uint32_t ENABLE; /*!< Enable TWIM */ - __I uint32_t RESERVED11; - TWIM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[5]; - __IO uint32_t FREQUENCY; /*!< TWI frequency */ - __I uint32_t RESERVED13[3]; - TWIM_RXD_Type RXD; /*!< RXD EasyDMA channel */ - TWIM_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED14[13]; - __IO uint32_t ADDRESS; /*!< Address used in the TWI transfer */ -} NRF_TWIM_Type; - - -/* ================================================================================ */ -/* ================ TWIS ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Slave Interface with EasyDMA 0 (TWIS) - */ - -typedef struct { /*!< TWIS Structure */ - __I uint32_t RESERVED0[5]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED2[3]; - __O uint32_t TASKS_PREPARERX; /*!< Prepare the TWI slave to respond to a write command */ - __O uint32_t TASKS_PREPARETX; /*!< Prepare the TWI slave to respond to a read command */ - __I uint32_t RESERVED3[51]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED5[9]; - __IO uint32_t EVENTS_RXSTARTED; /*!< Receive sequence started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< Transmit sequence started */ - __I uint32_t RESERVED6[4]; - __IO uint32_t EVENTS_WRITE; /*!< Write command received */ - __IO uint32_t EVENTS_READ; /*!< Read command received */ - __I uint32_t RESERVED7[37]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[113]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t MATCH; /*!< Status register indicating which address had a match */ - __I uint32_t RESERVED10[10]; - __IO uint32_t ENABLE; /*!< Enable TWIS */ - __I uint32_t RESERVED11; - TWIS_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[9]; - TWIS_RXD_Type RXD; /*!< RXD EasyDMA channel */ - __I uint32_t RESERVED13; - TWIS_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED14[14]; - __IO uint32_t ADDRESS[2]; /*!< Description collection[0]: TWI slave address 0 */ - __I uint32_t RESERVED15; - __IO uint32_t CONFIG; /*!< Configuration register for the address match mechanism */ - __I uint32_t RESERVED16[10]; - __IO uint32_t ORC; /*!< Over-read character. Character sent out in case of an over-read - of the transmit buffer. */ -} NRF_TWIS_Type; - - -/* ================================================================================ */ -/* ================ SPI ================ */ -/* ================================================================================ */ - - -/** - * @brief Serial Peripheral Interface 0 (SPI) - */ - -typedef struct { /*!< SPI Structure */ - __I uint32_t RESERVED0[66]; - __IO uint32_t EVENTS_READY; /*!< TXD byte sent and RXD byte received */ - __I uint32_t RESERVED1[126]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< Enable SPI */ - __I uint32_t RESERVED3; - SPI_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED4; - __I uint32_t RXD; /*!< RXD register */ - __IO uint32_t TXD; /*!< TXD register */ - __I uint32_t RESERVED5; - __IO uint32_t FREQUENCY; /*!< SPI frequency */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CONFIG; /*!< Configuration register */ -} NRF_SPI_Type; - - -/* ================================================================================ */ -/* ================ TWI ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Interface 0 (TWI) - */ - -typedef struct { /*!< TWI Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start TWI receive sequence */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTTX; /*!< Start TWI transmit sequence */ - __I uint32_t RESERVED1[2]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction */ - __I uint32_t RESERVED2; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED3[56]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __IO uint32_t EVENTS_RXDREADY; /*!< TWI RXD byte received */ - __I uint32_t RESERVED4[4]; - __IO uint32_t EVENTS_TXDSENT; /*!< TWI TXD byte sent */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED6[4]; - __IO uint32_t EVENTS_BB; /*!< TWI byte boundary, generated before each byte that is sent or - received */ - __I uint32_t RESERVED7[3]; - __IO uint32_t EVENTS_SUSPENDED; /*!< TWI entered the suspended state */ - __I uint32_t RESERVED8[45]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED9[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED10[110]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED11[14]; - __IO uint32_t ENABLE; /*!< Enable TWI */ - __I uint32_t RESERVED12; - __IO uint32_t PSELSCL; /*!< Pin select for SCL */ - __IO uint32_t PSELSDA; /*!< Pin select for SDA */ - __I uint32_t RESERVED13[2]; - __I uint32_t RXD; /*!< RXD register */ - __IO uint32_t TXD; /*!< TXD register */ - __I uint32_t RESERVED14; - __IO uint32_t FREQUENCY; /*!< TWI frequency */ - __I uint32_t RESERVED15[24]; - __IO uint32_t ADDRESS; /*!< Address used in the TWI transfer */ -} NRF_TWI_Type; - - -/* ================================================================================ */ -/* ================ NFCT ================ */ -/* ================================================================================ */ - - -/** - * @brief NFC-A compatible radio (NFCT) - */ - -typedef struct { /*!< NFCT Structure */ - __O uint32_t TASKS_ACTIVATE; /*!< Activate NFC peripheral for incoming and outgoing frames, change - state to activated */ - __O uint32_t TASKS_DISABLE; /*!< Disable NFC peripheral */ - __O uint32_t TASKS_SENSE; /*!< Enable NFC sense field mode, change state to sense mode */ - __O uint32_t TASKS_STARTTX; /*!< Start transmission of a outgoing frame, change state to transmit */ - __I uint32_t RESERVED0[3]; - __O uint32_t TASKS_ENABLERXDATA; /*!< Initializes the EasyDMA for receive. */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_GOIDLE; /*!< Force state machine to IDLE state */ - __O uint32_t TASKS_GOSLEEP; /*!< Force state machine to SLEEP_A state */ - __I uint32_t RESERVED2[53]; - __IO uint32_t EVENTS_READY; /*!< The NFC peripheral is ready to receive and send frames */ - __IO uint32_t EVENTS_FIELDDETECTED; /*!< Remote NFC field detected */ - __IO uint32_t EVENTS_FIELDLOST; /*!< Remote NFC field lost */ - __IO uint32_t EVENTS_TXFRAMESTART; /*!< Marks the start of the first symbol of a transmitted frame */ - __IO uint32_t EVENTS_TXFRAMEEND; /*!< Marks the end of the last transmitted on-air symbol of a frame */ - __IO uint32_t EVENTS_RXFRAMESTART; /*!< Marks the end of the first symbol of a received frame */ - __IO uint32_t EVENTS_RXFRAMEEND; /*!< Received data have been checked (CRC, parity) and transferred - to RAM, and EasyDMA has ended accessing the RX buffer */ - __IO uint32_t EVENTS_ERROR; /*!< NFC error reported. The ERRORSTATUS register contains details - on the source of the error. */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_RXERROR; /*!< NFC RX frame error reported. The FRAMESTATUS.RX register contains - details on the source of the error. */ - __IO uint32_t EVENTS_ENDRX; /*!< RX buffer (as defined by PACKETPTR and MAXLEN) in Data RAM full. */ - __IO uint32_t EVENTS_ENDTX; /*!< Transmission of data in RAM has ended, and EasyDMA has ended - accessing the TX buffer */ - __I uint32_t RESERVED4; - __IO uint32_t EVENTS_AUTOCOLRESSTARTED; /*!< Auto collision resolution process has started */ - __I uint32_t RESERVED5[3]; - __IO uint32_t EVENTS_COLLISION; /*!< NFC Auto collision resolution error reported. */ - __IO uint32_t EVENTS_SELECTED; /*!< NFC Auto collision resolution successfully completed */ - __IO uint32_t EVENTS_STARTED; /*!< EasyDMA is ready to receive or send frames. */ - __I uint32_t RESERVED6[43]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED7[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED8[62]; - __IO uint32_t ERRORSTATUS; /*!< NFC Error Status register */ - __I uint32_t RESERVED9; - NFCT_FRAMESTATUS_Type FRAMESTATUS; /*!< Unspecified */ - __I uint32_t RESERVED10[8]; - __I uint32_t CURRENTLOADCTRL; /*!< Current value driven to the NFC Load Control */ - __I uint32_t RESERVED11[2]; - __I uint32_t FIELDPRESENT; /*!< Indicates the presence or not of a valid field */ - __I uint32_t RESERVED12[49]; - __IO uint32_t FRAMEDELAYMIN; /*!< Minimum frame delay */ - __IO uint32_t FRAMEDELAYMAX; /*!< Maximum frame delay */ - __IO uint32_t FRAMEDELAYMODE; /*!< Configuration register for the Frame Delay Timer */ - __IO uint32_t PACKETPTR; /*!< Packet pointer for TXD and RXD data storage in Data RAM */ - __IO uint32_t MAXLEN; /*!< Size of allocated for TXD and RXD data storage buffer in Data - RAM */ - NFCT_TXD_Type TXD; /*!< Unspecified */ - NFCT_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED13[26]; - __IO uint32_t NFCID1_LAST; /*!< Last NFCID1 part (4, 7 or 10 bytes ID) */ - __IO uint32_t NFCID1_2ND_LAST; /*!< Second last NFCID1 part (7 or 10 bytes ID) */ - __IO uint32_t NFCID1_3RD_LAST; /*!< Third last NFCID1 part (10 bytes ID) */ - __I uint32_t RESERVED14; - __IO uint32_t SENSRES; /*!< NFC-A SENS_RES auto-response settings */ - __IO uint32_t SELRES; /*!< NFC-A SEL_RES auto-response settings */ -} NRF_NFCT_Type; - - -/* ================================================================================ */ -/* ================ GPIOTE ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO Tasks and Events (GPIOTE) - */ - -typedef struct { /*!< GPIOTE Structure */ - __O uint32_t TASKS_OUT[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is configured in CONFIG[0].POLARITY. */ - __I uint32_t RESERVED0[4]; - __O uint32_t TASKS_SET[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is to set it high. */ - __I uint32_t RESERVED1[4]; - __O uint32_t TASKS_CLR[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is to set it low. */ - __I uint32_t RESERVED2[32]; - __IO uint32_t EVENTS_IN[8]; /*!< Description collection[0]: Event generated from pin specified - in CONFIG[0].PSEL */ - __I uint32_t RESERVED3[23]; - __IO uint32_t EVENTS_PORT; /*!< Event generated from multiple input GPIO pins with SENSE mechanism - enabled */ - __I uint32_t RESERVED4[97]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED5[129]; - __IO uint32_t CONFIG[8]; /*!< Description collection[0]: Configuration for OUT[n], SET[n] - and CLR[n] tasks and IN[n] event */ -} NRF_GPIOTE_Type; - - -/* ================================================================================ */ -/* ================ SAADC ================ */ -/* ================================================================================ */ - - -/** - * @brief Analog to Digital Converter (SAADC) - */ - -typedef struct { /*!< SAADC Structure */ - __O uint32_t TASKS_START; /*!< Start the ADC and prepare the result buffer in RAM */ - __O uint32_t TASKS_SAMPLE; /*!< Take one ADC sample, if scan is enabled all channels are sampled */ - __O uint32_t TASKS_STOP; /*!< Stop the ADC and terminate any on-going conversion */ - __O uint32_t TASKS_CALIBRATEOFFSET; /*!< Starts offset auto-calibration */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_STARTED; /*!< The ADC has started */ - __IO uint32_t EVENTS_END; /*!< The ADC has filled up the Result buffer */ - __IO uint32_t EVENTS_DONE; /*!< A conversion task has been completed. Depending on the mode, - multiple conversions might be needed for a result to be transferred - to RAM. */ - __IO uint32_t EVENTS_RESULTDONE; /*!< A result is ready to get transferred to RAM. */ - __IO uint32_t EVENTS_CALIBRATEDONE; /*!< Calibration is complete */ - __IO uint32_t EVENTS_STOPPED; /*!< The ADC has stopped */ - SAADC_EVENTS_CH_Type EVENTS_CH[8]; /*!< Unspecified */ - __I uint32_t RESERVED1[106]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[61]; - __I uint32_t STATUS; /*!< Status */ - __I uint32_t RESERVED3[63]; - __IO uint32_t ENABLE; /*!< Enable or disable ADC */ - __I uint32_t RESERVED4[3]; - SAADC_CH_Type CH[8]; /*!< Unspecified */ - __I uint32_t RESERVED5[24]; - __IO uint32_t RESOLUTION; /*!< Resolution configuration */ - __IO uint32_t OVERSAMPLE; /*!< Oversampling configuration. OVERSAMPLE should not be combined - with SCAN. The RESOLUTION is applied before averaging, thus - for high OVERSAMPLE a higher RESOLUTION should be used. */ - __IO uint32_t SAMPLERATE; /*!< Controls normal or continuous sample rate */ - __I uint32_t RESERVED6[12]; - SAADC_RESULT_Type RESULT; /*!< RESULT EasyDMA channel */ -} NRF_SAADC_Type; - - -/* ================================================================================ */ -/* ================ TIMER ================ */ -/* ================================================================================ */ - - -/** - * @brief Timer/Counter 0 (TIMER) - */ - -typedef struct { /*!< TIMER Structure */ - __O uint32_t TASKS_START; /*!< Start Timer */ - __O uint32_t TASKS_STOP; /*!< Stop Timer */ - __O uint32_t TASKS_COUNT; /*!< Increment Timer (Counter mode only) */ - __O uint32_t TASKS_CLEAR; /*!< Clear time */ - __O uint32_t TASKS_SHUTDOWN; /*!< Deprecated register - Shut down timer */ - __I uint32_t RESERVED0[11]; - __O uint32_t TASKS_CAPTURE[6]; /*!< Description collection[0]: Capture Timer value to CC[0] register */ - __I uint32_t RESERVED1[58]; - __IO uint32_t EVENTS_COMPARE[6]; /*!< Description collection[0]: Compare event on CC[0] match */ - __I uint32_t RESERVED2[42]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[126]; - __IO uint32_t MODE; /*!< Timer mode selection */ - __IO uint32_t BITMODE; /*!< Configure the number of bits used by the TIMER */ - __I uint32_t RESERVED5; - __IO uint32_t PRESCALER; /*!< Timer prescaler register */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CC[6]; /*!< Description collection[0]: Capture/Compare register 0 */ -} NRF_TIMER_Type; - - -/* ================================================================================ */ -/* ================ RTC ================ */ -/* ================================================================================ */ - - -/** - * @brief Real time counter 0 (RTC) - */ - -typedef struct { /*!< RTC Structure */ - __O uint32_t TASKS_START; /*!< Start RTC COUNTER */ - __O uint32_t TASKS_STOP; /*!< Stop RTC COUNTER */ - __O uint32_t TASKS_CLEAR; /*!< Clear RTC COUNTER */ - __O uint32_t TASKS_TRIGOVRFLW; /*!< Set COUNTER to 0xFFFFF0 */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_TICK; /*!< Event on COUNTER increment */ - __IO uint32_t EVENTS_OVRFLW; /*!< Event on COUNTER overflow */ - __I uint32_t RESERVED1[14]; - __IO uint32_t EVENTS_COMPARE[4]; /*!< Description collection[0]: Compare event on CC[0] match */ - __I uint32_t RESERVED2[109]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[13]; - __IO uint32_t EVTEN; /*!< Enable or disable event routing */ - __IO uint32_t EVTENSET; /*!< Enable event routing */ - __IO uint32_t EVTENCLR; /*!< Disable event routing */ - __I uint32_t RESERVED4[110]; - __I uint32_t COUNTER; /*!< Current COUNTER value */ - __IO uint32_t PRESCALER; /*!< 12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)).Must - be written when RTC is stopped */ - __I uint32_t RESERVED5[13]; - __IO uint32_t CC[4]; /*!< Description collection[0]: Compare register 0 */ -} NRF_RTC_Type; - - -/* ================================================================================ */ -/* ================ TEMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Temperature Sensor (TEMP) - */ - -typedef struct { /*!< TEMP Structure */ - __O uint32_t TASKS_START; /*!< Start temperature measurement */ - __O uint32_t TASKS_STOP; /*!< Stop temperature measurement */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_DATARDY; /*!< Temperature measurement complete, data ready */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[127]; - __I int32_t TEMP; /*!< Temperature in degC (0.25deg steps) */ - __I uint32_t RESERVED3[5]; - __IO uint32_t A0; /*!< Slope of 1st piece wise linear function */ - __IO uint32_t A1; /*!< Slope of 2nd piece wise linear function */ - __IO uint32_t A2; /*!< Slope of 3rd piece wise linear function */ - __IO uint32_t A3; /*!< Slope of 4th piece wise linear function */ - __IO uint32_t A4; /*!< Slope of 5th piece wise linear function */ - __IO uint32_t A5; /*!< Slope of 6th piece wise linear function */ - __I uint32_t RESERVED4[2]; - __IO uint32_t B0; /*!< y-intercept of 1st piece wise linear function */ - __IO uint32_t B1; /*!< y-intercept of 2nd piece wise linear function */ - __IO uint32_t B2; /*!< y-intercept of 3rd piece wise linear function */ - __IO uint32_t B3; /*!< y-intercept of 4th piece wise linear function */ - __IO uint32_t B4; /*!< y-intercept of 5th piece wise linear function */ - __IO uint32_t B5; /*!< y-intercept of 6th piece wise linear function */ - __I uint32_t RESERVED5[2]; - __IO uint32_t T0; /*!< End point of 1st piece wise linear function */ - __IO uint32_t T1; /*!< End point of 2nd piece wise linear function */ - __IO uint32_t T2; /*!< End point of 3rd piece wise linear function */ - __IO uint32_t T3; /*!< End point of 4th piece wise linear function */ - __IO uint32_t T4; /*!< End point of 5th piece wise linear function */ -} NRF_TEMP_Type; - - -/* ================================================================================ */ -/* ================ RNG ================ */ -/* ================================================================================ */ - - -/** - * @brief Random Number Generator (RNG) - */ - -typedef struct { /*!< RNG Structure */ - __O uint32_t TASKS_START; /*!< Task starting the random number generator */ - __O uint32_t TASKS_STOP; /*!< Task stopping the random number generator */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_VALRDY; /*!< Event being generated for every new random number written to - the VALUE register */ - __I uint32_t RESERVED1[63]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[126]; - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t VALUE; /*!< Output random number */ -} NRF_RNG_Type; - - -/* ================================================================================ */ -/* ================ ECB ================ */ -/* ================================================================================ */ - - -/** - * @brief AES ECB Mode Encryption (ECB) - */ - -typedef struct { /*!< ECB Structure */ - __O uint32_t TASKS_STARTECB; /*!< Start ECB block encrypt */ - __O uint32_t TASKS_STOPECB; /*!< Abort a possible executing ECB operation */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_ENDECB; /*!< ECB block encrypt complete */ - __IO uint32_t EVENTS_ERRORECB; /*!< ECB block encrypt aborted because of a STOPECB task or due to - an error */ - __I uint32_t RESERVED1[127]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[126]; - __IO uint32_t ECBDATAPTR; /*!< ECB block encrypt memory pointers */ -} NRF_ECB_Type; - - -/* ================================================================================ */ -/* ================ CCM ================ */ -/* ================================================================================ */ - - -/** - * @brief AES CCM Mode Encryption (CCM) - */ - -typedef struct { /*!< CCM Structure */ - __O uint32_t TASKS_KSGEN; /*!< Start generation of key-stream. This operation will stop by - itself when completed. */ - __O uint32_t TASKS_CRYPT; /*!< Start encryption/decryption. This operation will stop by itself - when completed. */ - __O uint32_t TASKS_STOP; /*!< Stop encryption/decryption */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_ENDKSGEN; /*!< Key-stream generation complete */ - __IO uint32_t EVENTS_ENDCRYPT; /*!< Encrypt/decrypt complete */ - __IO uint32_t EVENTS_ERROR; /*!< CCM error event */ - __I uint32_t RESERVED1[61]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t MICSTATUS; /*!< MIC check result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable */ - __IO uint32_t MODE; /*!< Operation mode */ - __IO uint32_t CNFPTR; /*!< Pointer to data structure holding AES key and NONCE vector */ - __IO uint32_t INPTR; /*!< Input pointer */ - __IO uint32_t OUTPTR; /*!< Output pointer */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to data area used for temporary storage */ -} NRF_CCM_Type; - - -/* ================================================================================ */ -/* ================ AAR ================ */ -/* ================================================================================ */ - - -/** - * @brief Accelerated Address Resolver (AAR) - */ - -typedef struct { /*!< AAR Structure */ - __O uint32_t TASKS_START; /*!< Start resolving addresses based on IRKs specified in the IRK - data structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stop resolving addresses */ - __I uint32_t RESERVED1[61]; - __IO uint32_t EVENTS_END; /*!< Address resolution procedure complete */ - __IO uint32_t EVENTS_RESOLVED; /*!< Address resolved */ - __IO uint32_t EVENTS_NOTRESOLVED; /*!< Address not resolved */ - __I uint32_t RESERVED2[126]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t STATUS; /*!< Resolution status */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable AAR */ - __IO uint32_t NIRK; /*!< Number of IRKs */ - __IO uint32_t IRKPTR; /*!< Pointer to IRK data structure */ - __I uint32_t RESERVED5; - __IO uint32_t ADDRPTR; /*!< Pointer to the resolvable address */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to data area used for temporary storage */ -} NRF_AAR_Type; - - -/* ================================================================================ */ -/* ================ WDT ================ */ -/* ================================================================================ */ - - -/** - * @brief Watchdog Timer (WDT) - */ - -typedef struct { /*!< WDT Structure */ - __O uint32_t TASKS_START; /*!< Start the watchdog */ - __I uint32_t RESERVED0[63]; - __IO uint32_t EVENTS_TIMEOUT; /*!< Watchdog timeout */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[61]; - __I uint32_t RUNSTATUS; /*!< Run status */ - __I uint32_t REQSTATUS; /*!< Request status */ - __I uint32_t RESERVED3[63]; - __IO uint32_t CRV; /*!< Counter reload value */ - __IO uint32_t RREN; /*!< Enable register for reload request registers */ - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED4[60]; - __O uint32_t RR[8]; /*!< Description collection[0]: Reload request 0 */ -} NRF_WDT_Type; - - -/* ================================================================================ */ -/* ================ QDEC ================ */ -/* ================================================================================ */ - - -/** - * @brief Quadrature Decoder (QDEC) - */ - -typedef struct { /*!< QDEC Structure */ - __O uint32_t TASKS_START; /*!< Task starting the quadrature decoder */ - __O uint32_t TASKS_STOP; /*!< Task stopping the quadrature decoder */ - __O uint32_t TASKS_READCLRACC; /*!< Read and clear ACC and ACCDBL */ - __O uint32_t TASKS_RDCLRACC; /*!< Read and clear ACC */ - __O uint32_t TASKS_RDCLRDBL; /*!< Read and clear ACCDBL */ - __I uint32_t RESERVED0[59]; - __IO uint32_t EVENTS_SAMPLERDY; /*!< Event being generated for every new sample value written to - the SAMPLE register */ - __IO uint32_t EVENTS_REPORTRDY; /*!< Non-null report ready */ - __IO uint32_t EVENTS_ACCOF; /*!< ACC or ACCDBL register overflow */ - __IO uint32_t EVENTS_DBLRDY; /*!< Double displacement(s) detected */ - __IO uint32_t EVENTS_STOPPED; /*!< QDEC has been stopped */ - __I uint32_t RESERVED1[59]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[125]; - __IO uint32_t ENABLE; /*!< Enable the quadrature decoder */ - __IO uint32_t LEDPOL; /*!< LED output pin polarity */ - __IO uint32_t SAMPLEPER; /*!< Sample period */ - __I int32_t SAMPLE; /*!< Motion sample value */ - __IO uint32_t REPORTPER; /*!< Number of samples to be taken before REPORTRDY and DBLRDY events - can be generated */ - __I int32_t ACC; /*!< Register accumulating the valid transitions */ - __I int32_t ACCREAD; /*!< Snapshot of the ACC register, updated by the READCLRACC or RDCLRACC - task */ - QDEC_PSEL_Type PSEL; /*!< Unspecified */ - __IO uint32_t DBFEN; /*!< Enable input debounce filters */ - __I uint32_t RESERVED4[5]; - __IO uint32_t LEDPRE; /*!< Time period the LED is switched ON prior to sampling */ - __I uint32_t ACCDBL; /*!< Register accumulating the number of detected double transitions */ - __I uint32_t ACCDBLREAD; /*!< Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL - task */ -} NRF_QDEC_Type; - - -/* ================================================================================ */ -/* ================ COMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Comparator (COMP) - */ - -typedef struct { /*!< COMP Structure */ - __O uint32_t TASKS_START; /*!< Start comparator */ - __O uint32_t TASKS_STOP; /*!< Stop comparator */ - __O uint32_t TASKS_SAMPLE; /*!< Sample comparator value */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_READY; /*!< COMP is ready and output is valid */ - __IO uint32_t EVENTS_DOWN; /*!< Downward crossing */ - __IO uint32_t EVENTS_UP; /*!< Upward crossing */ - __IO uint32_t EVENTS_CROSS; /*!< Downward or upward crossing */ - __I uint32_t RESERVED1[60]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t RESULT; /*!< Compare result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< COMP enable */ - __IO uint32_t PSEL; /*!< Pin select */ - __IO uint32_t REFSEL; /*!< Reference source select */ - __IO uint32_t EXTREFSEL; /*!< External reference select */ - __I uint32_t RESERVED5[8]; - __IO uint32_t TH; /*!< Threshold configuration for hysteresis unit */ - __IO uint32_t MODE; /*!< Mode configuration */ - __IO uint32_t HYST; /*!< Comparator hysteresis enable */ - __IO uint32_t ISOURCE; /*!< Current source select on analog input */ -} NRF_COMP_Type; - - -/* ================================================================================ */ -/* ================ LPCOMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Low Power Comparator (LPCOMP) - */ - -typedef struct { /*!< LPCOMP Structure */ - __O uint32_t TASKS_START; /*!< Start comparator */ - __O uint32_t TASKS_STOP; /*!< Stop comparator */ - __O uint32_t TASKS_SAMPLE; /*!< Sample comparator value */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_READY; /*!< LPCOMP is ready and output is valid */ - __IO uint32_t EVENTS_DOWN; /*!< Downward crossing */ - __IO uint32_t EVENTS_UP; /*!< Upward crossing */ - __IO uint32_t EVENTS_CROSS; /*!< Downward or upward crossing */ - __I uint32_t RESERVED1[60]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t RESULT; /*!< Compare result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable LPCOMP */ - __IO uint32_t PSEL; /*!< Input pin select */ - __IO uint32_t REFSEL; /*!< Reference select */ - __IO uint32_t EXTREFSEL; /*!< External reference select */ - __I uint32_t RESERVED5[4]; - __IO uint32_t ANADETECT; /*!< Analog detect configuration */ - __I uint32_t RESERVED6[5]; - __IO uint32_t HYST; /*!< Comparator hysteresis enable */ -} NRF_LPCOMP_Type; - - -/* ================================================================================ */ -/* ================ SWI ================ */ -/* ================================================================================ */ - - -/** - * @brief Software interrupt 0 (SWI) - */ - -typedef struct { /*!< SWI Structure */ - __I uint32_t UNUSED; /*!< Unused. */ -} NRF_SWI_Type; - - -/* ================================================================================ */ -/* ================ EGU ================ */ -/* ================================================================================ */ - - -/** - * @brief Event Generator Unit 0 (EGU) - */ - -typedef struct { /*!< EGU Structure */ - __O uint32_t TASKS_TRIGGER[16]; /*!< Description collection[0]: Trigger 0 for triggering the corresponding - TRIGGERED[0] event */ - __I uint32_t RESERVED0[48]; - __IO uint32_t EVENTS_TRIGGERED[16]; /*!< Description collection[0]: Event number 0 generated by triggering - the corresponding TRIGGER[0] task */ - __I uint32_t RESERVED1[112]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ -} NRF_EGU_Type; - - -/* ================================================================================ */ -/* ================ PWM ================ */ -/* ================================================================================ */ - - -/** - * @brief Pulse Width Modulation Unit 0 (PWM) - */ - -typedef struct { /*!< PWM Structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stops PWM pulse generation on all channels at the end of current - PWM period, and stops sequence playback */ - __O uint32_t TASKS_SEQSTART[2]; /*!< Description collection[0]: Loads the first PWM value on all - enabled channels from sequence 0, and starts playing that sequence - at the rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes - PWM generation to start it was not running. */ - __O uint32_t TASKS_NEXTSTEP; /*!< Steps by one value in the current sequence on all enabled channels - if DECODER.MODE=NextStep. Does not cause PWM generation to start - it was not running. */ - __I uint32_t RESERVED1[60]; - __IO uint32_t EVENTS_STOPPED; /*!< Response to STOP task, emitted when PWM pulses are no longer - generated */ - __IO uint32_t EVENTS_SEQSTARTED[2]; /*!< Description collection[0]: First PWM period started on sequence - 0 */ - __IO uint32_t EVENTS_SEQEND[2]; /*!< Description collection[0]: Emitted at end of every sequence - 0, when last value from RAM has been applied to wave counter */ - __IO uint32_t EVENTS_PWMPERIODEND; /*!< Emitted at the end of each PWM period */ - __IO uint32_t EVENTS_LOOPSDONE; /*!< Concatenated sequences have been played the amount of times - defined in LOOP.CNT */ - __I uint32_t RESERVED2[56]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[125]; - __IO uint32_t ENABLE; /*!< PWM module enable register */ - __IO uint32_t MODE; /*!< Selects operating mode of the wave counter */ - __IO uint32_t COUNTERTOP; /*!< Value up to which the pulse generator counter counts */ - __IO uint32_t PRESCALER; /*!< Configuration for PWM_CLK */ - __IO uint32_t DECODER; /*!< Configuration of the decoder */ - __IO uint32_t LOOP; /*!< Amount of playback of a loop */ - __I uint32_t RESERVED5[2]; - PWM_SEQ_Type SEQ[2]; /*!< Unspecified */ - PWM_PSEL_Type PSEL; /*!< Unspecified */ -} NRF_PWM_Type; - - -/* ================================================================================ */ -/* ================ PDM ================ */ -/* ================================================================================ */ - - -/** - * @brief Pulse Density Modulation (Digital Microphone) Interface (PDM) - */ - -typedef struct { /*!< PDM Structure */ - __O uint32_t TASKS_START; /*!< Starts continuous PDM transfer */ - __O uint32_t TASKS_STOP; /*!< Stops PDM transfer */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_STARTED; /*!< PDM transfer has started */ - __IO uint32_t EVENTS_STOPPED; /*!< PDM transfer has finished */ - __IO uint32_t EVENTS_END; /*!< The PDM has written the last sample specified by SAMPLE.MAXCNT - (or the last sample after a STOP task has been received) to - Data RAM */ - __I uint32_t RESERVED1[125]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< PDM module enable register */ - __IO uint32_t PDMCLKCTRL; /*!< PDM clock generator control */ - __IO uint32_t MODE; /*!< Defines the routing of the connected PDM microphones' signals */ - __I uint32_t RESERVED3[3]; - __IO uint32_t GAINL; /*!< Left output gain adjustment */ - __IO uint32_t GAINR; /*!< Right output gain adjustment */ - __I uint32_t RESERVED4[8]; - PDM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED5[6]; - PDM_SAMPLE_Type SAMPLE; /*!< Unspecified */ -} NRF_PDM_Type; - - -/* ================================================================================ */ -/* ================ NVMC ================ */ -/* ================================================================================ */ - - -/** - * @brief Non Volatile Memory Controller (NVMC) - */ - -typedef struct { /*!< NVMC Structure */ - __I uint32_t RESERVED0[256]; - __I uint32_t READY; /*!< Ready flag */ - __I uint32_t RESERVED1[64]; - __IO uint32_t CONFIG; /*!< Configuration register */ - - union { - __IO uint32_t ERASEPCR1; /*!< Deprecated register - Register for erasing a page in Code area. - Equivalent to ERASEPAGE. */ - __IO uint32_t ERASEPAGE; /*!< Register for erasing a page in Code area */ - }; - __IO uint32_t ERASEALL; /*!< Register for erasing all non-volatile user memory */ - __IO uint32_t ERASEPCR0; /*!< Deprecated register - Register for erasing a page in Code area. - Equivalent to ERASEPAGE. */ - __IO uint32_t ERASEUICR; /*!< Register for erasing User Information Configuration Registers */ - __I uint32_t RESERVED2[10]; - __IO uint32_t ICACHECNF; /*!< I-Code cache configuration register. */ - __I uint32_t RESERVED3; - __IO uint32_t IHIT; /*!< I-Code cache hit counter. */ - __IO uint32_t IMISS; /*!< I-Code cache miss counter. */ -} NRF_NVMC_Type; - - -/* ================================================================================ */ -/* ================ PPI ================ */ -/* ================================================================================ */ - - -/** - * @brief Programmable Peripheral Interconnect (PPI) - */ - -typedef struct { /*!< PPI Structure */ - PPI_TASKS_CHG_Type TASKS_CHG[6]; /*!< Channel group tasks */ - __I uint32_t RESERVED0[308]; - __IO uint32_t CHEN; /*!< Channel enable register */ - __IO uint32_t CHENSET; /*!< Channel enable set register */ - __IO uint32_t CHENCLR; /*!< Channel enable clear register */ - __I uint32_t RESERVED1; - PPI_CH_Type CH[20]; /*!< PPI Channel */ - __I uint32_t RESERVED2[148]; - __IO uint32_t CHG[6]; /*!< Description collection[0]: Channel group 0 */ - __I uint32_t RESERVED3[62]; - PPI_FORK_Type FORK[32]; /*!< Fork */ -} NRF_PPI_Type; - - -/* ================================================================================ */ -/* ================ MWU ================ */ -/* ================================================================================ */ - - -/** - * @brief Memory Watch Unit (MWU) - */ - -typedef struct { /*!< MWU Structure */ - __I uint32_t RESERVED0[64]; - MWU_EVENTS_REGION_Type EVENTS_REGION[4]; /*!< Unspecified */ - __I uint32_t RESERVED1[16]; - MWU_EVENTS_PREGION_Type EVENTS_PREGION[2]; /*!< Unspecified */ - __I uint32_t RESERVED2[100]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[5]; - __IO uint32_t NMIEN; /*!< Enable or disable non-maskable interrupt */ - __IO uint32_t NMIENSET; /*!< Enable non-maskable interrupt */ - __IO uint32_t NMIENCLR; /*!< Disable non-maskable interrupt */ - __I uint32_t RESERVED4[53]; - MWU_PERREGION_Type PERREGION[2]; /*!< Unspecified */ - __I uint32_t RESERVED5[64]; - __IO uint32_t REGIONEN; /*!< Enable/disable regions watch */ - __IO uint32_t REGIONENSET; /*!< Enable regions watch */ - __IO uint32_t REGIONENCLR; /*!< Disable regions watch */ - __I uint32_t RESERVED6[57]; - MWU_REGION_Type REGION[4]; /*!< Unspecified */ - __I uint32_t RESERVED7[32]; - MWU_PREGION_Type PREGION[2]; /*!< Unspecified */ -} NRF_MWU_Type; - - -/* ================================================================================ */ -/* ================ I2S ================ */ -/* ================================================================================ */ - - -/** - * @brief Inter-IC Sound (I2S) - */ - -typedef struct { /*!< I2S Structure */ - __O uint32_t TASKS_START; /*!< Starts continuous I2S transfer. Also starts MCK generator when - this is enabled. */ - __O uint32_t TASKS_STOP; /*!< Stops I2S transfer. Also stops MCK generator. Triggering this - task will cause the {event:STOPPED} event to be generated. */ - __I uint32_t RESERVED0[63]; - __IO uint32_t EVENTS_RXPTRUPD; /*!< The RXD.PTR register has been copied to internal double-buffers. - When the I2S module is started and RX is enabled, this event - will be generated for every RXTXD.MAXCNT words that are received - on the SDIN pin. */ - __IO uint32_t EVENTS_STOPPED; /*!< I2S transfer stopped. */ - __I uint32_t RESERVED1[2]; - __IO uint32_t EVENTS_TXPTRUPD; /*!< The TDX.PTR register has been copied to internal double-buffers. - When the I2S module is started and TX is enabled, this event - will be generated for every RXTXD.MAXCNT words that are sent - on the SDOUT pin. */ - __I uint32_t RESERVED2[122]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[125]; - __IO uint32_t ENABLE; /*!< Enable I2S module. */ - I2S_CONFIG_Type CONFIG; /*!< Unspecified */ - __I uint32_t RESERVED4[3]; - I2S_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED5; - I2S_TXD_Type TXD; /*!< Unspecified */ - __I uint32_t RESERVED6[3]; - I2S_RXTXD_Type RXTXD; /*!< Unspecified */ - __I uint32_t RESERVED7[3]; - I2S_PSEL_Type PSEL; /*!< Unspecified */ -} NRF_I2S_Type; - - -/* ================================================================================ */ -/* ================ FPU ================ */ -/* ================================================================================ */ - - -/** - * @brief FPU (FPU) - */ - -typedef struct { /*!< FPU Structure */ - __I uint32_t UNUSED; /*!< Unused. */ -} NRF_FPU_Type; - - -/* ================================================================================ */ -/* ================ GPIO ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO Port 1 (GPIO) - */ - -typedef struct { /*!< GPIO Structure */ - __I uint32_t RESERVED0[321]; - __IO uint32_t OUT; /*!< Write GPIO port */ - __IO uint32_t OUTSET; /*!< Set individual bits in GPIO port */ - __IO uint32_t OUTCLR; /*!< Clear individual bits in GPIO port */ - __I uint32_t IN; /*!< Read GPIO port */ - __IO uint32_t DIR; /*!< Direction of GPIO pins */ - __IO uint32_t DIRSET; /*!< DIR set register */ - __IO uint32_t DIRCLR; /*!< DIR clear register */ - __IO uint32_t LATCH; /*!< Latch register indicating what GPIO pins that have met the criteria - set in the PIN_CNF[n].SENSE registers */ - __IO uint32_t DETECTMODE; /*!< Select between default DETECT signal behaviour and LDETECT mode */ - __I uint32_t RESERVED1[118]; - __IO uint32_t PIN_CNF[32]; /*!< Description collection[0]: Configuration of GPIO pins */ -} NRF_GPIO_Type; - - -/* -------------------- End of section using anonymous unions ------------------- */ -#if defined(__CC_ARM) - #pragma pop -#elif defined(__ICCARM__) - /* leave anonymous unions enabled */ -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) - /* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning restore -#else - #warning Not supported compiler type -#endif - - - - -/* ================================================================================ */ -/* ================ Peripheral memory map ================ */ -/* ================================================================================ */ - -#define NRF_FICR_BASE 0x10000000UL -#define NRF_UICR_BASE 0x10001000UL -#define NRF_BPROT_BASE 0x40000000UL -#define NRF_POWER_BASE 0x40000000UL -#define NRF_CLOCK_BASE 0x40000000UL -#define NRF_RADIO_BASE 0x40001000UL -#define NRF_UARTE0_BASE 0x40002000UL -#define NRF_UART0_BASE 0x40002000UL -#define NRF_SPIM0_BASE 0x40003000UL -#define NRF_SPIS0_BASE 0x40003000UL -#define NRF_TWIM0_BASE 0x40003000UL -#define NRF_TWIS0_BASE 0x40003000UL -#define NRF_SPI0_BASE 0x40003000UL -#define NRF_TWI0_BASE 0x40003000UL -#define NRF_SPIM1_BASE 0x40004000UL -#define NRF_SPIS1_BASE 0x40004000UL -#define NRF_TWIM1_BASE 0x40004000UL -#define NRF_TWIS1_BASE 0x40004000UL -#define NRF_SPI1_BASE 0x40004000UL -#define NRF_TWI1_BASE 0x40004000UL -#define NRF_NFCT_BASE 0x40005000UL -#define NRF_GPIOTE_BASE 0x40006000UL -#define NRF_SAADC_BASE 0x40007000UL -#define NRF_TIMER0_BASE 0x40008000UL -#define NRF_TIMER1_BASE 0x40009000UL -#define NRF_TIMER2_BASE 0x4000A000UL -#define NRF_RTC0_BASE 0x4000B000UL -#define NRF_TEMP_BASE 0x4000C000UL -#define NRF_RNG_BASE 0x4000D000UL -#define NRF_ECB_BASE 0x4000E000UL -#define NRF_CCM_BASE 0x4000F000UL -#define NRF_AAR_BASE 0x4000F000UL -#define NRF_WDT_BASE 0x40010000UL -#define NRF_RTC1_BASE 0x40011000UL -#define NRF_QDEC_BASE 0x40012000UL -#define NRF_COMP_BASE 0x40013000UL -#define NRF_LPCOMP_BASE 0x40013000UL -#define NRF_SWI0_BASE 0x40014000UL -#define NRF_EGU0_BASE 0x40014000UL -#define NRF_SWI1_BASE 0x40015000UL -#define NRF_EGU1_BASE 0x40015000UL -#define NRF_SWI2_BASE 0x40016000UL -#define NRF_EGU2_BASE 0x40016000UL -#define NRF_SWI3_BASE 0x40017000UL -#define NRF_EGU3_BASE 0x40017000UL -#define NRF_SWI4_BASE 0x40018000UL -#define NRF_EGU4_BASE 0x40018000UL -#define NRF_SWI5_BASE 0x40019000UL -#define NRF_EGU5_BASE 0x40019000UL -#define NRF_TIMER3_BASE 0x4001A000UL -#define NRF_TIMER4_BASE 0x4001B000UL -#define NRF_PWM0_BASE 0x4001C000UL -#define NRF_PDM_BASE 0x4001D000UL -#define NRF_NVMC_BASE 0x4001E000UL -#define NRF_PPI_BASE 0x4001F000UL -#define NRF_MWU_BASE 0x40020000UL -#define NRF_PWM1_BASE 0x40021000UL -#define NRF_PWM2_BASE 0x40022000UL -#define NRF_SPIM2_BASE 0x40023000UL -#define NRF_SPIS2_BASE 0x40023000UL -#define NRF_SPI2_BASE 0x40023000UL -#define NRF_RTC2_BASE 0x40024000UL -#define NRF_I2S_BASE 0x40025000UL -#define NRF_FPU_BASE 0x40026000UL -#define NRF_P0_BASE 0x50000000UL - - -/* ================================================================================ */ -/* ================ Peripheral declaration ================ */ -/* ================================================================================ */ - -#define NRF_FICR ((NRF_FICR_Type *) NRF_FICR_BASE) -#define NRF_UICR ((NRF_UICR_Type *) NRF_UICR_BASE) -#define NRF_BPROT ((NRF_BPROT_Type *) NRF_BPROT_BASE) -#define NRF_POWER ((NRF_POWER_Type *) NRF_POWER_BASE) -#define NRF_CLOCK ((NRF_CLOCK_Type *) NRF_CLOCK_BASE) -#define NRF_RADIO ((NRF_RADIO_Type *) NRF_RADIO_BASE) -#define NRF_UARTE0 ((NRF_UARTE_Type *) NRF_UARTE0_BASE) -#define NRF_UART0 ((NRF_UART_Type *) NRF_UART0_BASE) -#define NRF_SPIM0 ((NRF_SPIM_Type *) NRF_SPIM0_BASE) -#define NRF_SPIS0 ((NRF_SPIS_Type *) NRF_SPIS0_BASE) -#define NRF_TWIM0 ((NRF_TWIM_Type *) NRF_TWIM0_BASE) -#define NRF_TWIS0 ((NRF_TWIS_Type *) NRF_TWIS0_BASE) -#define NRF_SPI0 ((NRF_SPI_Type *) NRF_SPI0_BASE) -#define NRF_TWI0 ((NRF_TWI_Type *) NRF_TWI0_BASE) -#define NRF_SPIM1 ((NRF_SPIM_Type *) NRF_SPIM1_BASE) -#define NRF_SPIS1 ((NRF_SPIS_Type *) NRF_SPIS1_BASE) -#define NRF_TWIM1 ((NRF_TWIM_Type *) NRF_TWIM1_BASE) -#define NRF_TWIS1 ((NRF_TWIS_Type *) NRF_TWIS1_BASE) -#define NRF_SPI1 ((NRF_SPI_Type *) NRF_SPI1_BASE) -#define NRF_TWI1 ((NRF_TWI_Type *) NRF_TWI1_BASE) -#define NRF_NFCT ((NRF_NFCT_Type *) NRF_NFCT_BASE) -#define NRF_GPIOTE ((NRF_GPIOTE_Type *) NRF_GPIOTE_BASE) -#define NRF_SAADC ((NRF_SAADC_Type *) NRF_SAADC_BASE) -#define NRF_TIMER0 ((NRF_TIMER_Type *) NRF_TIMER0_BASE) -#define NRF_TIMER1 ((NRF_TIMER_Type *) NRF_TIMER1_BASE) -#define NRF_TIMER2 ((NRF_TIMER_Type *) NRF_TIMER2_BASE) -#define NRF_RTC0 ((NRF_RTC_Type *) NRF_RTC0_BASE) -#define NRF_TEMP ((NRF_TEMP_Type *) NRF_TEMP_BASE) -#define NRF_RNG ((NRF_RNG_Type *) NRF_RNG_BASE) -#define NRF_ECB ((NRF_ECB_Type *) NRF_ECB_BASE) -#define NRF_CCM ((NRF_CCM_Type *) NRF_CCM_BASE) -#define NRF_AAR ((NRF_AAR_Type *) NRF_AAR_BASE) -#define NRF_WDT ((NRF_WDT_Type *) NRF_WDT_BASE) -#define NRF_RTC1 ((NRF_RTC_Type *) NRF_RTC1_BASE) -#define NRF_QDEC ((NRF_QDEC_Type *) NRF_QDEC_BASE) -#define NRF_COMP ((NRF_COMP_Type *) NRF_COMP_BASE) -#define NRF_LPCOMP ((NRF_LPCOMP_Type *) NRF_LPCOMP_BASE) -#define NRF_SWI0 ((NRF_SWI_Type *) NRF_SWI0_BASE) -#define NRF_EGU0 ((NRF_EGU_Type *) NRF_EGU0_BASE) -#define NRF_SWI1 ((NRF_SWI_Type *) NRF_SWI1_BASE) -#define NRF_EGU1 ((NRF_EGU_Type *) NRF_EGU1_BASE) -#define NRF_SWI2 ((NRF_SWI_Type *) NRF_SWI2_BASE) -#define NRF_EGU2 ((NRF_EGU_Type *) NRF_EGU2_BASE) -#define NRF_SWI3 ((NRF_SWI_Type *) NRF_SWI3_BASE) -#define NRF_EGU3 ((NRF_EGU_Type *) NRF_EGU3_BASE) -#define NRF_SWI4 ((NRF_SWI_Type *) NRF_SWI4_BASE) -#define NRF_EGU4 ((NRF_EGU_Type *) NRF_EGU4_BASE) -#define NRF_SWI5 ((NRF_SWI_Type *) NRF_SWI5_BASE) -#define NRF_EGU5 ((NRF_EGU_Type *) NRF_EGU5_BASE) -#define NRF_TIMER3 ((NRF_TIMER_Type *) NRF_TIMER3_BASE) -#define NRF_TIMER4 ((NRF_TIMER_Type *) NRF_TIMER4_BASE) -#define NRF_PWM0 ((NRF_PWM_Type *) NRF_PWM0_BASE) -#define NRF_PDM ((NRF_PDM_Type *) NRF_PDM_BASE) -#define NRF_NVMC ((NRF_NVMC_Type *) NRF_NVMC_BASE) -#define NRF_PPI ((NRF_PPI_Type *) NRF_PPI_BASE) -#define NRF_MWU ((NRF_MWU_Type *) NRF_MWU_BASE) -#define NRF_PWM1 ((NRF_PWM_Type *) NRF_PWM1_BASE) -#define NRF_PWM2 ((NRF_PWM_Type *) NRF_PWM2_BASE) -#define NRF_SPIM2 ((NRF_SPIM_Type *) NRF_SPIM2_BASE) -#define NRF_SPIS2 ((NRF_SPIS_Type *) NRF_SPIS2_BASE) -#define NRF_SPI2 ((NRF_SPI_Type *) NRF_SPI2_BASE) -#define NRF_RTC2 ((NRF_RTC_Type *) NRF_RTC2_BASE) -#define NRF_I2S ((NRF_I2S_Type *) NRF_I2S_BASE) -#define NRF_FPU ((NRF_FPU_Type *) NRF_FPU_BASE) -#define NRF_P0 ((NRF_GPIO_Type *) NRF_P0_BASE) - - -/** @} */ /* End of group Device_Peripheral_Registers */ -/** @} */ /* End of group nrf52 */ -/** @} */ /* End of group Nordic Semiconductor */ - -#ifdef __cplusplus -} -#endif - - -#endif /* nrf52_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810.h deleted file mode 100644 index d3a3264..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810.h +++ /dev/null @@ -1,1589 +0,0 @@ - -/****************************************************************************************************//** - * @file nrf52810.h - * - * @brief CMSIS Cortex-M4 Peripheral Access Layer Header File for - * nrf52810 from Nordic Semiconductor. - * - * @version V1 - * @date 3. October 2017 - * - * @note Generated with SVDConv V2.81d - * from CMSIS SVD File 'nrf52810.svd' Version 1, - * - * @par Copyright (c) 2010 - 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. - * - * - *******************************************************************************************************/ - - - -/** @addtogroup Nordic Semiconductor - * @{ - */ - -/** @addtogroup nrf52810 - * @{ - */ - -#ifndef NRF52810_H -#define NRF52810_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* ------------------------- Interrupt Number Definition ------------------------ */ - -typedef enum { -/* ------------------- Cortex-M4 Processor Exceptions Numbers ------------------- */ - Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */ - NonMaskableInt_IRQn = -14, /*!< 2 Non maskable Interrupt, cannot be stopped or preempted */ - HardFault_IRQn = -13, /*!< 3 Hard Fault, all classes of Fault */ - MemoryManagement_IRQn = -12, /*!< 4 Memory Management, MPU mismatch, including Access Violation - and No Match */ - BusFault_IRQn = -11, /*!< 5 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory - related Fault */ - UsageFault_IRQn = -10, /*!< 6 Usage Fault, i.e. Undef Instruction, Illegal State Transition */ - SVCall_IRQn = -5, /*!< 11 System Service Call via SVC instruction */ - DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor */ - PendSV_IRQn = -2, /*!< 14 Pendable request for system service */ - SysTick_IRQn = -1, /*!< 15 System Tick Timer */ -/* --------------------- nrf52810 Specific Interrupt Numbers -------------------- */ - POWER_CLOCK_IRQn = 0, /*!< 0 POWER_CLOCK */ - RADIO_IRQn = 1, /*!< 1 RADIO */ - UARTE0_IRQn = 2, /*!< 2 UARTE0 */ - TWIM0_TWIS0_IRQn = 3, /*!< 3 TWIM0_TWIS0 */ - SPIM0_SPIS0_IRQn = 4, /*!< 4 SPIM0_SPIS0 */ - GPIOTE_IRQn = 6, /*!< 6 GPIOTE */ - SAADC_IRQn = 7, /*!< 7 SAADC */ - TIMER0_IRQn = 8, /*!< 8 TIMER0 */ - TIMER1_IRQn = 9, /*!< 9 TIMER1 */ - TIMER2_IRQn = 10, /*!< 10 TIMER2 */ - RTC0_IRQn = 11, /*!< 11 RTC0 */ - TEMP_IRQn = 12, /*!< 12 TEMP */ - RNG_IRQn = 13, /*!< 13 RNG */ - ECB_IRQn = 14, /*!< 14 ECB */ - CCM_AAR_IRQn = 15, /*!< 15 CCM_AAR */ - WDT_IRQn = 16, /*!< 16 WDT */ - RTC1_IRQn = 17, /*!< 17 RTC1 */ - QDEC_IRQn = 18, /*!< 18 QDEC */ - COMP_IRQn = 19, /*!< 19 COMP */ - SWI0_EGU0_IRQn = 20, /*!< 20 SWI0_EGU0 */ - SWI1_EGU1_IRQn = 21, /*!< 21 SWI1_EGU1 */ - SWI2_IRQn = 22, /*!< 22 SWI2 */ - SWI3_IRQn = 23, /*!< 23 SWI3 */ - SWI4_IRQn = 24, /*!< 24 SWI4 */ - SWI5_IRQn = 25, /*!< 25 SWI5 */ - PWM0_IRQn = 28, /*!< 28 PWM0 */ - PDM_IRQn = 29 /*!< 29 PDM */ -} IRQn_Type; - - -/** @addtogroup Configuration_of_CMSIS - * @{ - */ - - -/* ================================================================================ */ -/* ================ Processor and Core Peripheral Section ================ */ -/* ================================================================================ */ - -/* ----------------Configuration of the Cortex-M4 Processor and Core Peripherals---------------- */ -#define __CM4_REV 0x0001 /*!< Cortex-M4 Core Revision */ -#define __MPU_PRESENT 1 /*!< MPU present or not */ -#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */ -#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ -#define __FPU_PRESENT 0 /*!< FPU present or not */ -/** @} */ /* End of group Configuration_of_CMSIS */ - -#include "core_cm4.h" /*!< Cortex-M4 processor and core peripherals */ -#include "system_nrf52810.h" /*!< nrf52810 System */ - - -/* ================================================================================ */ -/* ================ Device Specific Peripheral Section ================ */ -/* ================================================================================ */ - - -/** @addtogroup Device_Peripheral_Registers - * @{ - */ - - -/* ------------------- Start of section using anonymous unions ------------------ */ -#if defined(__CC_ARM) - #pragma push - #pragma anon_unions -#elif defined(__ICCARM__) - #pragma language=extended -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) -/* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning 586 -#else - #warning Not supported compiler type -#endif - - -typedef struct { - __I uint32_t PART; /*!< Part code */ - __I uint32_t VARIANT; /*!< Part variant, hardware version and production configuration */ - __I uint32_t PACKAGE; /*!< Package option */ - __I uint32_t RAM; /*!< RAM variant */ - __I uint32_t FLASH; /*!< Flash variant */ - __IO uint32_t UNUSED0[3]; /*!< Description collection[0]: Unspecified */ -} FICR_INFO_Type; - -typedef struct { - __I uint32_t A0; /*!< Slope definition A0 */ - __I uint32_t A1; /*!< Slope definition A1 */ - __I uint32_t A2; /*!< Slope definition A2 */ - __I uint32_t A3; /*!< Slope definition A3 */ - __I uint32_t A4; /*!< Slope definition A4 */ - __I uint32_t A5; /*!< Slope definition A5 */ - __I uint32_t B0; /*!< Y-intercept B0 */ - __I uint32_t B1; /*!< Y-intercept B1 */ - __I uint32_t B2; /*!< Y-intercept B2 */ - __I uint32_t B3; /*!< Y-intercept B3 */ - __I uint32_t B4; /*!< Y-intercept B4 */ - __I uint32_t B5; /*!< Y-intercept B5 */ - __I uint32_t T0; /*!< Segment end T0 */ - __I uint32_t T1; /*!< Segment end T1 */ - __I uint32_t T2; /*!< Segment end T2 */ - __I uint32_t T3; /*!< Segment end T3 */ - __I uint32_t T4; /*!< Segment end T4 */ -} FICR_TEMP_Type; - -typedef struct { - __IO uint32_t POWER; /*!< Description cluster[0]: RAM0 power control register */ - __O uint32_t POWERSET; /*!< Description cluster[0]: RAM0 power control set register */ - __O uint32_t POWERCLR; /*!< Description cluster[0]: RAM0 power control clear register */ - __I uint32_t RESERVED0; -} POWER_RAM_Type; - -typedef struct { - __IO uint32_t RTS; /*!< Pin select for RTS signal */ - __IO uint32_t TXD; /*!< Pin select for TXD signal */ - __IO uint32_t CTS; /*!< Pin select for CTS signal */ - __IO uint32_t RXD; /*!< Pin select for RXD signal */ -} UARTE_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} UARTE_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} UARTE_TXD_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL signal */ - __IO uint32_t SDA; /*!< Pin select for SDA signal */ -} TWIM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} TWIM_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} TWIM_TXD_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL signal */ - __IO uint32_t SDA; /*!< Pin select for SDA signal */ -} TWIS_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RXD Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in RXD buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last RXD transaction */ -} TWIS_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< TXD Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in TXD buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last TXD transaction */ -} TWIS_TXD_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ -} SPIM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} SPIM_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} SPIM_TXD_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t CSN; /*!< Pin select for CSN signal */ -} SPIS_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RXD data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes received in last granted transaction */ -} SPIS_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< TXD data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transmitted in last granted transaction */ -} SPIS_TXD_Type; - -typedef struct { - __IO uint32_t LIMITH; /*!< Description cluster[0]: Last results is equal or above CH[0].LIMIT.HIGH */ - __IO uint32_t LIMITL; /*!< Description cluster[0]: Last results is equal or below CH[0].LIMIT.LOW */ -} SAADC_EVENTS_CH_Type; - -typedef struct { - __IO uint32_t PSELP; /*!< Description cluster[0]: Input positive pin selection for CH[0] */ - __IO uint32_t PSELN; /*!< Description cluster[0]: Input negative pin selection for CH[0] */ - __IO uint32_t CONFIG; /*!< Description cluster[0]: Input configuration for CH[0] */ - __IO uint32_t LIMIT; /*!< Description cluster[0]: High/low limits for event monitoring - a channel */ -} SAADC_CH_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of buffer words to transfer */ - __I uint32_t AMOUNT; /*!< Number of buffer words transferred since last START */ -} SAADC_RESULT_Type; - -typedef struct { - __IO uint32_t LED; /*!< Pin select for LED signal */ - __IO uint32_t A; /*!< Pin select for A signal */ - __IO uint32_t B; /*!< Pin select for B signal */ -} QDEC_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Description cluster[0]: Beginning address in Data RAM of this - sequence */ - __IO uint32_t CNT; /*!< Description cluster[0]: Amount of values (duty cycles) in this - sequence */ - __IO uint32_t REFRESH; /*!< Description cluster[0]: Amount of additional PWM periods between - samples loaded into compare register */ - __IO uint32_t ENDDELAY; /*!< Description cluster[0]: Time added after the sequence */ - __I uint32_t RESERVED1[4]; -} PWM_SEQ_Type; - -typedef struct { - __IO uint32_t OUT[4]; /*!< Description collection[0]: Output pin select for PWM channel - 0 */ -} PWM_PSEL_Type; - -typedef struct { - __IO uint32_t CLK; /*!< Pin number configuration for PDM CLK signal */ - __IO uint32_t DIN; /*!< Pin number configuration for PDM DIN signal */ -} PDM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RAM address pointer to write samples to with EasyDMA */ - __IO uint32_t MAXCNT; /*!< Number of samples to allocate memory for in EasyDMA mode */ -} PDM_SAMPLE_Type; - -typedef struct { - __O uint32_t EN; /*!< Description cluster[0]: Enable channel group 0 */ - __O uint32_t DIS; /*!< Description cluster[0]: Disable channel group 0 */ -} PPI_TASKS_CHG_Type; - -typedef struct { - __IO uint32_t EEP; /*!< Description cluster[0]: Channel 0 event end-point */ - __IO uint32_t TEP; /*!< Description cluster[0]: Channel 0 task end-point */ -} PPI_CH_Type; - -typedef struct { - __IO uint32_t TEP; /*!< Description cluster[0]: Channel 0 task end-point */ -} PPI_FORK_Type; - - -/* ================================================================================ */ -/* ================ FICR ================ */ -/* ================================================================================ */ - - -/** - * @brief Factory information configuration registers (FICR) - */ - -typedef struct { /*!< FICR Structure */ - __I uint32_t RESERVED0[4]; - __I uint32_t CODEPAGESIZE; /*!< Code memory page size */ - __I uint32_t CODESIZE; /*!< Code memory size */ - __I uint32_t RESERVED1[18]; - __I uint32_t DEVICEID[2]; /*!< Description collection[0]: Device identifier */ - __I uint32_t RESERVED2[6]; - __I uint32_t ER[4]; /*!< Description collection[0]: Encryption root, word 0 */ - __I uint32_t IR[4]; /*!< Description collection[0]: Identity root, word 0 */ - __I uint32_t DEVICEADDRTYPE; /*!< Device address type */ - __I uint32_t DEVICEADDR[2]; /*!< Description collection[0]: Device address 0 */ - __I uint32_t RESERVED3[21]; - FICR_INFO_Type INFO; /*!< Device info */ - __I uint32_t RESERVED4[185]; - FICR_TEMP_Type TEMP; /*!< Registers storing factory TEMP module linearization coefficients */ -} NRF_FICR_Type; - - -/* ================================================================================ */ -/* ================ UICR ================ */ -/* ================================================================================ */ - - -/** - * @brief User information configuration registers (UICR) - */ - -typedef struct { /*!< UICR Structure */ - __IO uint32_t UNUSED0; /*!< Unspecified */ - __IO uint32_t UNUSED1; /*!< Unspecified */ - __IO uint32_t UNUSED2; /*!< Unspecified */ - __I uint32_t RESERVED0; - __IO uint32_t UNUSED3; /*!< Unspecified */ - __IO uint32_t NRFFW[15]; /*!< Description collection[0]: Reserved for Nordic firmware design */ - __IO uint32_t NRFHW[12]; /*!< Description collection[0]: Reserved for Nordic hardware design */ - __IO uint32_t CUSTOMER[32]; /*!< Description collection[0]: Reserved for customer */ - __I uint32_t RESERVED1[64]; - __IO uint32_t PSELRESET[2]; /*!< Description collection[0]: Mapping of the nRESET function (see - POWER chapter for details) */ - __IO uint32_t APPROTECT; /*!< Access port protection */ -} NRF_UICR_Type; - - -/* ================================================================================ */ -/* ================ BPROT ================ */ -/* ================================================================================ */ - - -/** - * @brief Block Protect (BPROT) - */ - -typedef struct { /*!< BPROT Structure */ - __I uint32_t RESERVED0[384]; - __IO uint32_t CONFIG0; /*!< Block protect configuration register 0 */ - __IO uint32_t CONFIG1; /*!< Block protect configuration register 1 */ - __IO uint32_t DISABLEINDEBUG; /*!< Disable protection mechanism in debug mode */ - __IO uint32_t UNUSED0; /*!< Unspecified */ -} NRF_BPROT_Type; - - -/* ================================================================================ */ -/* ================ POWER ================ */ -/* ================================================================================ */ - - -/** - * @brief Power control (POWER) - */ - -typedef struct { /*!< POWER Structure */ - __I uint32_t RESERVED0[30]; - __O uint32_t TASKS_CONSTLAT; /*!< Enable constant latency mode */ - __O uint32_t TASKS_LOWPWR; /*!< Enable low power mode (variable latency) */ - __I uint32_t RESERVED1[34]; - __IO uint32_t EVENTS_POFWARN; /*!< Power failure warning */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_SLEEPENTER; /*!< CPU entered WFI/WFE sleep */ - __IO uint32_t EVENTS_SLEEPEXIT; /*!< CPU exited WFI/WFE sleep */ - __I uint32_t RESERVED3[122]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[61]; - __IO uint32_t RESETREAS; /*!< Reset reason */ - __I uint32_t RESERVED5[63]; - __O uint32_t SYSTEMOFF; /*!< System OFF register */ - __I uint32_t RESERVED6[3]; - __IO uint32_t POFCON; /*!< Power failure comparator configuration */ - __I uint32_t RESERVED7[2]; - __IO uint32_t GPREGRET; /*!< General purpose retention register */ - __IO uint32_t GPREGRET2; /*!< General purpose retention register */ - __I uint32_t RESERVED8[21]; - __IO uint32_t DCDCEN; /*!< DC/DC enable register */ - __I uint32_t RESERVED9[225]; - POWER_RAM_Type RAM[8]; /*!< Unspecified */ -} NRF_POWER_Type; - - -/* ================================================================================ */ -/* ================ CLOCK ================ */ -/* ================================================================================ */ - - -/** - * @brief Clock control (CLOCK) - */ - -typedef struct { /*!< CLOCK Structure */ - __O uint32_t TASKS_HFCLKSTART; /*!< Start HFCLK crystal oscillator */ - __O uint32_t TASKS_HFCLKSTOP; /*!< Stop HFCLK crystal oscillator */ - __O uint32_t TASKS_LFCLKSTART; /*!< Start LFCLK source */ - __O uint32_t TASKS_LFCLKSTOP; /*!< Stop LFCLK source */ - __O uint32_t TASKS_CAL; /*!< Start calibration of LFRC oscillator */ - __O uint32_t TASKS_CTSTART; /*!< Start calibration timer */ - __O uint32_t TASKS_CTSTOP; /*!< Stop calibration timer */ - __I uint32_t RESERVED0[57]; - __IO uint32_t EVENTS_HFCLKSTARTED; /*!< HFCLK oscillator started */ - __IO uint32_t EVENTS_LFCLKSTARTED; /*!< LFCLK started */ - __I uint32_t RESERVED1; - __IO uint32_t EVENTS_DONE; /*!< Calibration of LFCLK RC oscillator complete event */ - __IO uint32_t EVENTS_CTTO; /*!< Calibration timer timeout */ - __I uint32_t RESERVED2[124]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[63]; - __I uint32_t HFCLKRUN; /*!< Status indicating that HFCLKSTART task has been triggered */ - __I uint32_t HFCLKSTAT; /*!< HFCLK status */ - __I uint32_t RESERVED4; - __I uint32_t LFCLKRUN; /*!< Status indicating that LFCLKSTART task has been triggered */ - __I uint32_t LFCLKSTAT; /*!< LFCLK status */ - __I uint32_t LFCLKSRCCOPY; /*!< Copy of LFCLKSRC register, set when LFCLKSTART task was triggered */ - __I uint32_t RESERVED5[62]; - __IO uint32_t LFCLKSRC; /*!< Clock source for the LFCLK */ - __I uint32_t RESERVED6[7]; - __IO uint32_t CTIV; /*!< Calibration timer interval */ -} NRF_CLOCK_Type; - - -/* ================================================================================ */ -/* ================ RADIO ================ */ -/* ================================================================================ */ - - -/** - * @brief 2.4 GHz Radio (RADIO) - */ - -typedef struct { /*!< RADIO Structure */ - __O uint32_t TASKS_TXEN; /*!< Enable RADIO in TX mode */ - __O uint32_t TASKS_RXEN; /*!< Enable RADIO in RX mode */ - __O uint32_t TASKS_START; /*!< Start RADIO */ - __O uint32_t TASKS_STOP; /*!< Stop RADIO */ - __O uint32_t TASKS_DISABLE; /*!< Disable RADIO */ - __O uint32_t TASKS_RSSISTART; /*!< Start the RSSI and take one single sample of the receive signal - strength. */ - __O uint32_t TASKS_RSSISTOP; /*!< Stop the RSSI measurement */ - __O uint32_t TASKS_BCSTART; /*!< Start the bit counter */ - __O uint32_t TASKS_BCSTOP; /*!< Stop the bit counter */ - __I uint32_t RESERVED0[55]; - __IO uint32_t EVENTS_READY; /*!< RADIO has ramped up and is ready to be started */ - __IO uint32_t EVENTS_ADDRESS; /*!< Address sent or received */ - __IO uint32_t EVENTS_PAYLOAD; /*!< Packet payload sent or received */ - __IO uint32_t EVENTS_END; /*!< Packet sent or received */ - __IO uint32_t EVENTS_DISABLED; /*!< RADIO has been disabled */ - __IO uint32_t EVENTS_DEVMATCH; /*!< A device address match occurred on the last received packet */ - __IO uint32_t EVENTS_DEVMISS; /*!< No device address match occurred on the last received packet */ - __IO uint32_t EVENTS_RSSIEND; /*!< Sampling of receive signal strength complete. */ - __I uint32_t RESERVED1[2]; - __IO uint32_t EVENTS_BCMATCH; /*!< Bit counter reached bit count value. */ - __I uint32_t RESERVED2; - __IO uint32_t EVENTS_CRCOK; /*!< Packet received with CRC ok */ - __IO uint32_t EVENTS_CRCERROR; /*!< Packet received with CRC error */ - __I uint32_t RESERVED3[50]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED4[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED5[61]; - __I uint32_t CRCSTATUS; /*!< CRC status */ - __I uint32_t RESERVED6; - __I uint32_t RXMATCH; /*!< Received address */ - __I uint32_t RXCRC; /*!< CRC field of previously received packet */ - __I uint32_t DAI; /*!< Device address match index */ - __I uint32_t RESERVED7[60]; - __IO uint32_t PACKETPTR; /*!< Packet pointer */ - __IO uint32_t FREQUENCY; /*!< Frequency */ - __IO uint32_t TXPOWER; /*!< Output power */ - __IO uint32_t MODE; /*!< Data rate and modulation */ - __IO uint32_t PCNF0; /*!< Packet configuration register 0 */ - __IO uint32_t PCNF1; /*!< Packet configuration register 1 */ - __IO uint32_t BASE0; /*!< Base address 0 */ - __IO uint32_t BASE1; /*!< Base address 1 */ - __IO uint32_t PREFIX0; /*!< Prefixes bytes for logical addresses 0-3 */ - __IO uint32_t PREFIX1; /*!< Prefixes bytes for logical addresses 4-7 */ - __IO uint32_t TXADDRESS; /*!< Transmit address select */ - __IO uint32_t RXADDRESSES; /*!< Receive address select */ - __IO uint32_t CRCCNF; /*!< CRC configuration */ - __IO uint32_t CRCPOLY; /*!< CRC polynomial */ - __IO uint32_t CRCINIT; /*!< CRC initial value */ - __IO uint32_t UNUSED0; /*!< Unspecified */ - __IO uint32_t TIFS; /*!< Inter Frame Spacing in us */ - __I uint32_t RSSISAMPLE; /*!< RSSI sample */ - __I uint32_t RESERVED8; - __I uint32_t STATE; /*!< Current radio state */ - __IO uint32_t DATAWHITEIV; /*!< Data whitening initial value */ - __I uint32_t RESERVED9[2]; - __IO uint32_t BCC; /*!< Bit counter compare */ - __I uint32_t RESERVED10[39]; - __IO uint32_t DAB[8]; /*!< Description collection[0]: Device address base segment 0 */ - __IO uint32_t DAP[8]; /*!< Description collection[0]: Device address prefix 0 */ - __IO uint32_t DACNF; /*!< Device address match configuration */ - __I uint32_t RESERVED11[3]; - __IO uint32_t MODECNF0; /*!< Radio mode configuration register 0 */ - __I uint32_t RESERVED12[618]; - __IO uint32_t POWER; /*!< Peripheral power control */ -} NRF_RADIO_Type; - - -/* ================================================================================ */ -/* ================ UARTE ================ */ -/* ================================================================================ */ - - -/** - * @brief UART with EasyDMA (UARTE) - */ - -typedef struct { /*!< UARTE Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start UART receiver */ - __O uint32_t TASKS_STOPRX; /*!< Stop UART receiver */ - __O uint32_t TASKS_STARTTX; /*!< Start UART transmitter */ - __O uint32_t TASKS_STOPTX; /*!< Stop UART transmitter */ - __I uint32_t RESERVED0[7]; - __O uint32_t TASKS_FLUSHRX; /*!< Flush RX FIFO into RX buffer */ - __I uint32_t RESERVED1[52]; - __IO uint32_t EVENTS_CTS; /*!< CTS is activated (set low). Clear To Send. */ - __IO uint32_t EVENTS_NCTS; /*!< CTS is deactivated (set high). Not Clear To Send. */ - __IO uint32_t EVENTS_RXDRDY; /*!< Data received in RXD (but potentially not yet transferred to - Data RAM) */ - __I uint32_t RESERVED2; - __IO uint32_t EVENTS_ENDRX; /*!< Receive buffer is filled up */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_TXDRDY; /*!< Data sent from TXD */ - __IO uint32_t EVENTS_ENDTX; /*!< Last TX byte transmitted */ - __IO uint32_t EVENTS_ERROR; /*!< Error detected */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_RXTO; /*!< Receiver timeout */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_RXSTARTED; /*!< UART receiver has started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< UART transmitter has started */ - __I uint32_t RESERVED6; - __IO uint32_t EVENTS_TXSTOPPED; /*!< Transmitter stopped */ - __I uint32_t RESERVED7[41]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[93]; - __IO uint32_t ERRORSRC; /*!< Error source Note : this register is read / write one to clear. */ - __I uint32_t RESERVED10[31]; - __IO uint32_t ENABLE; /*!< Enable UART */ - __I uint32_t RESERVED11; - UARTE_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[3]; - __IO uint32_t BAUDRATE; /*!< Baud rate. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED13[3]; - UARTE_RXD_Type RXD; /*!< RXD EasyDMA channel */ - __I uint32_t RESERVED14; - UARTE_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED15[7]; - __IO uint32_t CONFIG; /*!< Configuration of parity and hardware flow control */ -} NRF_UARTE_Type; - - -/* ================================================================================ */ -/* ================ TWIM ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Master Interface with EasyDMA (TWIM) - */ - -typedef struct { /*!< TWIM Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start TWI receive sequence */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTTX; /*!< Start TWI transmit sequence */ - __I uint32_t RESERVED1[2]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction. Must be issued while the TWI master is - not suspended. */ - __I uint32_t RESERVED2; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED3[56]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED5[8]; - __IO uint32_t EVENTS_SUSPENDED; /*!< Last byte has been sent out after the SUSPEND task has been - issued, TWI traffic is now suspended. */ - __IO uint32_t EVENTS_RXSTARTED; /*!< Receive sequence started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< Transmit sequence started */ - __I uint32_t RESERVED6[2]; - __IO uint32_t EVENTS_LASTRX; /*!< Byte boundary, starting to receive the last byte */ - __IO uint32_t EVENTS_LASTTX; /*!< Byte boundary, starting to transmit the last byte */ - __I uint32_t RESERVED7[39]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[110]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED10[14]; - __IO uint32_t ENABLE; /*!< Enable TWIM */ - __I uint32_t RESERVED11; - TWIM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[5]; - __IO uint32_t FREQUENCY; /*!< TWI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED13[3]; - TWIM_RXD_Type RXD; /*!< RXD EasyDMA channel */ - TWIM_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED14[13]; - __IO uint32_t ADDRESS; /*!< Address used in the TWI transfer */ -} NRF_TWIM_Type; - - -/* ================================================================================ */ -/* ================ TWIS ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Slave Interface with EasyDMA (TWIS) - */ - -typedef struct { /*!< TWIS Structure */ - __I uint32_t RESERVED0[5]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED2[3]; - __O uint32_t TASKS_PREPARERX; /*!< Prepare the TWI slave to respond to a write command */ - __O uint32_t TASKS_PREPARETX; /*!< Prepare the TWI slave to respond to a read command */ - __I uint32_t RESERVED3[51]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED5[9]; - __IO uint32_t EVENTS_RXSTARTED; /*!< Receive sequence started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< Transmit sequence started */ - __I uint32_t RESERVED6[4]; - __IO uint32_t EVENTS_WRITE; /*!< Write command received */ - __IO uint32_t EVENTS_READ; /*!< Read command received */ - __I uint32_t RESERVED7[37]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[113]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t MATCH; /*!< Status register indicating which address had a match */ - __I uint32_t RESERVED10[10]; - __IO uint32_t ENABLE; /*!< Enable TWIS */ - __I uint32_t RESERVED11; - TWIS_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[9]; - TWIS_RXD_Type RXD; /*!< RXD EasyDMA channel */ - __I uint32_t RESERVED13; - TWIS_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED14[14]; - __IO uint32_t ADDRESS[2]; /*!< Description collection[0]: TWI slave address 0 */ - __I uint32_t RESERVED15; - __IO uint32_t CONFIG; /*!< Configuration register for the address match mechanism */ - __I uint32_t RESERVED16[10]; - __IO uint32_t ORC; /*!< Over-read character. Character sent out in case of an over-read - of the transmit buffer. */ -} NRF_TWIS_Type; - - -/* ================================================================================ */ -/* ================ SPIM ================ */ -/* ================================================================================ */ - - -/** - * @brief Serial Peripheral Interface Master with EasyDMA (SPIM) - */ - -typedef struct { /*!< SPIM Structure */ - __I uint32_t RESERVED0[4]; - __O uint32_t TASKS_START; /*!< Start SPI transaction */ - __O uint32_t TASKS_STOP; /*!< Stop SPI transaction */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_SUSPEND; /*!< Suspend SPI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume SPI transaction */ - __I uint32_t RESERVED2[56]; - __IO uint32_t EVENTS_STOPPED; /*!< SPI transaction has stopped */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED4; - __IO uint32_t EVENTS_END; /*!< End of RXD buffer and TXD buffer reached */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_ENDTX; /*!< End of TXD buffer reached */ - __I uint32_t RESERVED6[10]; - __IO uint32_t EVENTS_STARTED; /*!< Transaction started */ - __I uint32_t RESERVED7[44]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[125]; - __IO uint32_t ENABLE; /*!< Enable SPIM */ - __I uint32_t RESERVED10; - SPIM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED11[4]; - __IO uint32_t FREQUENCY; /*!< SPI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED12[3]; - SPIM_RXD_Type RXD; /*!< RXD EasyDMA channel */ - SPIM_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED13[26]; - __IO uint32_t ORC; /*!< Over-read character. Character clocked out in case and over-read - of the TXD buffer. */ -} NRF_SPIM_Type; - - -/* ================================================================================ */ -/* ================ SPIS ================ */ -/* ================================================================================ */ - - -/** - * @brief SPI Slave (SPIS) - */ - -typedef struct { /*!< SPIS Structure */ - __I uint32_t RESERVED0[9]; - __O uint32_t TASKS_ACQUIRE; /*!< Acquire SPI semaphore */ - __O uint32_t TASKS_RELEASE; /*!< Release SPI semaphore, enabling the SPI slave to acquire it */ - __I uint32_t RESERVED1[54]; - __IO uint32_t EVENTS_END; /*!< Granted transaction completed */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED3[5]; - __IO uint32_t EVENTS_ACQUIRED; /*!< Semaphore acquired */ - __I uint32_t RESERVED4[53]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED5[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED6[61]; - __I uint32_t SEMSTAT; /*!< Semaphore status register */ - __I uint32_t RESERVED7[15]; - __IO uint32_t STATUS; /*!< Status from last transaction */ - __I uint32_t RESERVED8[47]; - __IO uint32_t ENABLE; /*!< Enable SPI slave */ - __I uint32_t RESERVED9; - SPIS_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED10[7]; - SPIS_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED11; - SPIS_TXD_Type TXD; /*!< Unspecified */ - __I uint32_t RESERVED12; - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED13; - __IO uint32_t DEF; /*!< Default character. Character clocked out in case of an ignored - transaction. */ - __I uint32_t RESERVED14[24]; - __IO uint32_t ORC; /*!< Over-read character */ -} NRF_SPIS_Type; - - -/* ================================================================================ */ -/* ================ GPIOTE ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO Tasks and Events (GPIOTE) - */ - -typedef struct { /*!< GPIOTE Structure */ - __O uint32_t TASKS_OUT[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is configured in CONFIG[0].POLARITY. */ - __I uint32_t RESERVED0[4]; - __O uint32_t TASKS_SET[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is to set it high. */ - __I uint32_t RESERVED1[4]; - __O uint32_t TASKS_CLR[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is to set it low. */ - __I uint32_t RESERVED2[32]; - __IO uint32_t EVENTS_IN[8]; /*!< Description collection[0]: Event generated from pin specified - in CONFIG[0].PSEL */ - __I uint32_t RESERVED3[23]; - __IO uint32_t EVENTS_PORT; /*!< Event generated from multiple input GPIO pins with SENSE mechanism - enabled */ - __I uint32_t RESERVED4[97]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED5[129]; - __IO uint32_t CONFIG[8]; /*!< Description collection[0]: Configuration for OUT[n], SET[n] - and CLR[n] tasks and IN[n] event */ -} NRF_GPIOTE_Type; - - -/* ================================================================================ */ -/* ================ SAADC ================ */ -/* ================================================================================ */ - - -/** - * @brief Analog to Digital Converter (SAADC) - */ - -typedef struct { /*!< SAADC Structure */ - __O uint32_t TASKS_START; /*!< Start the ADC and prepare the result buffer in RAM */ - __O uint32_t TASKS_SAMPLE; /*!< Take one ADC sample, if scan is enabled all channels are sampled */ - __O uint32_t TASKS_STOP; /*!< Stop the ADC and terminate any on-going conversion */ - __O uint32_t TASKS_CALIBRATEOFFSET; /*!< Starts offset auto-calibration */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_STARTED; /*!< The ADC has started */ - __IO uint32_t EVENTS_END; /*!< The ADC has filled up the Result buffer */ - __IO uint32_t EVENTS_DONE; /*!< A conversion task has been completed. Depending on the mode, - multiple conversions might be needed for a result to be transferred - to RAM. */ - __IO uint32_t EVENTS_RESULTDONE; /*!< A result is ready to get transferred to RAM. */ - __IO uint32_t EVENTS_CALIBRATEDONE; /*!< Calibration is complete */ - __IO uint32_t EVENTS_STOPPED; /*!< The ADC has stopped */ - SAADC_EVENTS_CH_Type EVENTS_CH[8]; /*!< Unspecified */ - __I uint32_t RESERVED1[106]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[61]; - __I uint32_t STATUS; /*!< Status */ - __I uint32_t RESERVED3[63]; - __IO uint32_t ENABLE; /*!< Enable or disable ADC */ - __I uint32_t RESERVED4[3]; - SAADC_CH_Type CH[8]; /*!< Unspecified */ - __I uint32_t RESERVED5[24]; - __IO uint32_t RESOLUTION; /*!< Resolution configuration */ - __IO uint32_t OVERSAMPLE; /*!< Oversampling configuration. OVERSAMPLE should not be combined - with SCAN. The RESOLUTION is applied before averaging, thus - for high OVERSAMPLE a higher RESOLUTION should be used. */ - __IO uint32_t SAMPLERATE; /*!< Controls normal or continuous sample rate */ - __I uint32_t RESERVED6[12]; - SAADC_RESULT_Type RESULT; /*!< RESULT EasyDMA channel */ -} NRF_SAADC_Type; - - -/* ================================================================================ */ -/* ================ TIMER ================ */ -/* ================================================================================ */ - - -/** - * @brief Timer/Counter 0 (TIMER) - */ - -typedef struct { /*!< TIMER Structure */ - __O uint32_t TASKS_START; /*!< Start Timer */ - __O uint32_t TASKS_STOP; /*!< Stop Timer */ - __O uint32_t TASKS_COUNT; /*!< Increment Timer (Counter mode only) */ - __O uint32_t TASKS_CLEAR; /*!< Clear time */ - __O uint32_t TASKS_SHUTDOWN; /*!< Deprecated register - Shut down timer */ - __I uint32_t RESERVED0[11]; - __O uint32_t TASKS_CAPTURE[6]; /*!< Description collection[0]: Capture Timer value to CC[0] register */ - __I uint32_t RESERVED1[58]; - __IO uint32_t EVENTS_COMPARE[6]; /*!< Description collection[0]: Compare event on CC[0] match */ - __I uint32_t RESERVED2[42]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[126]; - __IO uint32_t MODE; /*!< Timer mode selection */ - __IO uint32_t BITMODE; /*!< Configure the number of bits used by the TIMER */ - __I uint32_t RESERVED5; - __IO uint32_t PRESCALER; /*!< Timer prescaler register */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CC[6]; /*!< Description collection[0]: Capture/Compare register 0 */ -} NRF_TIMER_Type; - - -/* ================================================================================ */ -/* ================ RTC ================ */ -/* ================================================================================ */ - - -/** - * @brief Real time counter 0 (RTC) - */ - -typedef struct { /*!< RTC Structure */ - __O uint32_t TASKS_START; /*!< Start RTC COUNTER */ - __O uint32_t TASKS_STOP; /*!< Stop RTC COUNTER */ - __O uint32_t TASKS_CLEAR; /*!< Clear RTC COUNTER */ - __O uint32_t TASKS_TRIGOVRFLW; /*!< Set COUNTER to 0xFFFFF0 */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_TICK; /*!< Event on COUNTER increment */ - __IO uint32_t EVENTS_OVRFLW; /*!< Event on COUNTER overflow */ - __I uint32_t RESERVED1[14]; - __IO uint32_t EVENTS_COMPARE[4]; /*!< Description collection[0]: Compare event on CC[0] match */ - __I uint32_t RESERVED2[109]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[13]; - __IO uint32_t EVTEN; /*!< Enable or disable event routing */ - __IO uint32_t EVTENSET; /*!< Enable event routing */ - __IO uint32_t EVTENCLR; /*!< Disable event routing */ - __I uint32_t RESERVED4[110]; - __I uint32_t COUNTER; /*!< Current COUNTER value */ - __IO uint32_t PRESCALER; /*!< 12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)).Must - be written when RTC is stopped */ - __I uint32_t RESERVED5[13]; - __IO uint32_t CC[4]; /*!< Description collection[0]: Compare register 0 */ -} NRF_RTC_Type; - - -/* ================================================================================ */ -/* ================ TEMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Temperature Sensor (TEMP) - */ - -typedef struct { /*!< TEMP Structure */ - __O uint32_t TASKS_START; /*!< Start temperature measurement */ - __O uint32_t TASKS_STOP; /*!< Stop temperature measurement */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_DATARDY; /*!< Temperature measurement complete, data ready */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[127]; - __I int32_t TEMP; /*!< Temperature in degC (0.25deg steps) */ - __I uint32_t RESERVED3[5]; - __IO uint32_t A0; /*!< Slope of 1st piece wise linear function */ - __IO uint32_t A1; /*!< Slope of 2nd piece wise linear function */ - __IO uint32_t A2; /*!< Slope of 3rd piece wise linear function */ - __IO uint32_t A3; /*!< Slope of 4th piece wise linear function */ - __IO uint32_t A4; /*!< Slope of 5th piece wise linear function */ - __IO uint32_t A5; /*!< Slope of 6th piece wise linear function */ - __I uint32_t RESERVED4[2]; - __IO uint32_t B0; /*!< y-intercept of 1st piece wise linear function */ - __IO uint32_t B1; /*!< y-intercept of 2nd piece wise linear function */ - __IO uint32_t B2; /*!< y-intercept of 3rd piece wise linear function */ - __IO uint32_t B3; /*!< y-intercept of 4th piece wise linear function */ - __IO uint32_t B4; /*!< y-intercept of 5th piece wise linear function */ - __IO uint32_t B5; /*!< y-intercept of 6th piece wise linear function */ - __I uint32_t RESERVED5[2]; - __IO uint32_t T0; /*!< End point of 1st piece wise linear function */ - __IO uint32_t T1; /*!< End point of 2nd piece wise linear function */ - __IO uint32_t T2; /*!< End point of 3rd piece wise linear function */ - __IO uint32_t T3; /*!< End point of 4th piece wise linear function */ - __IO uint32_t T4; /*!< End point of 5th piece wise linear function */ -} NRF_TEMP_Type; - - -/* ================================================================================ */ -/* ================ RNG ================ */ -/* ================================================================================ */ - - -/** - * @brief Random Number Generator (RNG) - */ - -typedef struct { /*!< RNG Structure */ - __O uint32_t TASKS_START; /*!< Task starting the random number generator */ - __O uint32_t TASKS_STOP; /*!< Task stopping the random number generator */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_VALRDY; /*!< Event being generated for every new random number written to - the VALUE register */ - __I uint32_t RESERVED1[63]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[126]; - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t VALUE; /*!< Output random number */ -} NRF_RNG_Type; - - -/* ================================================================================ */ -/* ================ ECB ================ */ -/* ================================================================================ */ - - -/** - * @brief AES ECB Mode Encryption (ECB) - */ - -typedef struct { /*!< ECB Structure */ - __O uint32_t TASKS_STARTECB; /*!< Start ECB block encrypt */ - __O uint32_t TASKS_STOPECB; /*!< Abort a possible executing ECB operation */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_ENDECB; /*!< ECB block encrypt complete */ - __IO uint32_t EVENTS_ERRORECB; /*!< ECB block encrypt aborted because of a STOPECB task or due to - an error */ - __I uint32_t RESERVED1[127]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[126]; - __IO uint32_t ECBDATAPTR; /*!< ECB block encrypt memory pointers */ -} NRF_ECB_Type; - - -/* ================================================================================ */ -/* ================ CCM ================ */ -/* ================================================================================ */ - - -/** - * @brief AES CCM Mode Encryption (CCM) - */ - -typedef struct { /*!< CCM Structure */ - __O uint32_t TASKS_KSGEN; /*!< Start generation of key-stream. This operation will stop by - itself when completed. */ - __O uint32_t TASKS_CRYPT; /*!< Start encryption/decryption. This operation will stop by itself - when completed. */ - __O uint32_t TASKS_STOP; /*!< Stop encryption/decryption */ - __O uint32_t TASKS_RATEOVERRIDE; /*!< Override DATARATE setting in MODE register with the contents - of the RATEOVERRIDE register for any ongoing encryption/decryption */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_ENDKSGEN; /*!< Key-stream generation complete */ - __IO uint32_t EVENTS_ENDCRYPT; /*!< Encrypt/decrypt complete */ - __IO uint32_t EVENTS_ERROR; /*!< Deprecated register - CCM error event */ - __I uint32_t RESERVED1[61]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t MICSTATUS; /*!< MIC check result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable */ - __IO uint32_t MODE; /*!< Operation mode */ - __IO uint32_t CNFPTR; /*!< Pointer to data structure holding AES key and NONCE vector */ - __IO uint32_t INPTR; /*!< Input pointer */ - __IO uint32_t OUTPTR; /*!< Output pointer */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to data area used for temporary storage */ - __IO uint32_t MAXPACKETSIZE; /*!< Length of key-stream generated when MODE.LENGTH = Extended. */ - __IO uint32_t RATEOVERRIDE; /*!< Data rate override setting. */ -} NRF_CCM_Type; - - -/* ================================================================================ */ -/* ================ AAR ================ */ -/* ================================================================================ */ - - -/** - * @brief Accelerated Address Resolver (AAR) - */ - -typedef struct { /*!< AAR Structure */ - __O uint32_t TASKS_START; /*!< Start resolving addresses based on IRKs specified in the IRK - data structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stop resolving addresses */ - __I uint32_t RESERVED1[61]; - __IO uint32_t EVENTS_END; /*!< Address resolution procedure complete */ - __IO uint32_t EVENTS_RESOLVED; /*!< Address resolved */ - __IO uint32_t EVENTS_NOTRESOLVED; /*!< Address not resolved */ - __I uint32_t RESERVED2[126]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t STATUS; /*!< Resolution status */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable AAR */ - __IO uint32_t NIRK; /*!< Number of IRKs */ - __IO uint32_t IRKPTR; /*!< Pointer to IRK data structure */ - __I uint32_t RESERVED5; - __IO uint32_t ADDRPTR; /*!< Pointer to the resolvable address */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to data area used for temporary storage */ -} NRF_AAR_Type; - - -/* ================================================================================ */ -/* ================ WDT ================ */ -/* ================================================================================ */ - - -/** - * @brief Watchdog Timer (WDT) - */ - -typedef struct { /*!< WDT Structure */ - __O uint32_t TASKS_START; /*!< Start the watchdog */ - __I uint32_t RESERVED0[63]; - __IO uint32_t EVENTS_TIMEOUT; /*!< Watchdog timeout */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[61]; - __I uint32_t RUNSTATUS; /*!< Run status */ - __I uint32_t REQSTATUS; /*!< Request status */ - __I uint32_t RESERVED3[63]; - __IO uint32_t CRV; /*!< Counter reload value */ - __IO uint32_t RREN; /*!< Enable register for reload request registers */ - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED4[60]; - __O uint32_t RR[8]; /*!< Description collection[0]: Reload request 0 */ -} NRF_WDT_Type; - - -/* ================================================================================ */ -/* ================ QDEC ================ */ -/* ================================================================================ */ - - -/** - * @brief Quadrature Decoder (QDEC) - */ - -typedef struct { /*!< QDEC Structure */ - __O uint32_t TASKS_START; /*!< Task starting the quadrature decoder */ - __O uint32_t TASKS_STOP; /*!< Task stopping the quadrature decoder */ - __O uint32_t TASKS_READCLRACC; /*!< Read and clear ACC and ACCDBL */ - __O uint32_t TASKS_RDCLRACC; /*!< Read and clear ACC */ - __O uint32_t TASKS_RDCLRDBL; /*!< Read and clear ACCDBL */ - __I uint32_t RESERVED0[59]; - __IO uint32_t EVENTS_SAMPLERDY; /*!< Event being generated for every new sample value written to - the SAMPLE register */ - __IO uint32_t EVENTS_REPORTRDY; /*!< Non-null report ready */ - __IO uint32_t EVENTS_ACCOF; /*!< ACC or ACCDBL register overflow */ - __IO uint32_t EVENTS_DBLRDY; /*!< Double displacement(s) detected */ - __IO uint32_t EVENTS_STOPPED; /*!< QDEC has been stopped */ - __I uint32_t RESERVED1[59]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[125]; - __IO uint32_t ENABLE; /*!< Enable the quadrature decoder */ - __IO uint32_t LEDPOL; /*!< LED output pin polarity */ - __IO uint32_t SAMPLEPER; /*!< Sample period */ - __I int32_t SAMPLE; /*!< Motion sample value */ - __IO uint32_t REPORTPER; /*!< Number of samples to be taken before REPORTRDY and DBLRDY events - can be generated */ - __I int32_t ACC; /*!< Register accumulating the valid transitions */ - __I int32_t ACCREAD; /*!< Snapshot of the ACC register, updated by the READCLRACC or RDCLRACC - task */ - QDEC_PSEL_Type PSEL; /*!< Unspecified */ - __IO uint32_t DBFEN; /*!< Enable input debounce filters */ - __I uint32_t RESERVED4[5]; - __IO uint32_t LEDPRE; /*!< Time period the LED is switched ON prior to sampling */ - __I uint32_t ACCDBL; /*!< Register accumulating the number of detected double transitions */ - __I uint32_t ACCDBLREAD; /*!< Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL - task */ -} NRF_QDEC_Type; - - -/* ================================================================================ */ -/* ================ COMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Comparator (COMP) - */ - -typedef struct { /*!< COMP Structure */ - __O uint32_t TASKS_START; /*!< Start comparator */ - __O uint32_t TASKS_STOP; /*!< Stop comparator */ - __O uint32_t TASKS_SAMPLE; /*!< Sample comparator value */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_READY; /*!< COMP is ready and output is valid */ - __IO uint32_t EVENTS_DOWN; /*!< Downward crossing */ - __IO uint32_t EVENTS_UP; /*!< Upward crossing */ - __IO uint32_t EVENTS_CROSS; /*!< Downward or upward crossing */ - __I uint32_t RESERVED1[60]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t RESULT; /*!< Compare result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< COMP enable */ - __IO uint32_t PSEL; /*!< Pin select */ - __IO uint32_t REFSEL; /*!< Reference source select for single-ended mode */ - __IO uint32_t EXTREFSEL; /*!< External reference select */ - __I uint32_t RESERVED5[8]; - __IO uint32_t TH; /*!< Threshold configuration for hysteresis unit */ - __IO uint32_t MODE; /*!< Mode configuration */ - __IO uint32_t HYST; /*!< Comparator hysteresis enable */ -} NRF_COMP_Type; - - -/* ================================================================================ */ -/* ================ SWI ================ */ -/* ================================================================================ */ - - -/** - * @brief Software interrupt 0 (SWI) - */ - -typedef struct { /*!< SWI Structure */ - __I uint32_t UNUSED; /*!< Unused. */ -} NRF_SWI_Type; - - -/* ================================================================================ */ -/* ================ EGU ================ */ -/* ================================================================================ */ - - -/** - * @brief Event Generator Unit 0 (EGU) - */ - -typedef struct { /*!< EGU Structure */ - __O uint32_t TASKS_TRIGGER[16]; /*!< Description collection[0]: Trigger 0 for triggering the corresponding - TRIGGERED[0] event */ - __I uint32_t RESERVED0[48]; - __IO uint32_t EVENTS_TRIGGERED[16]; /*!< Description collection[0]: Event number 0 generated by triggering - the corresponding TRIGGER[0] task */ - __I uint32_t RESERVED1[112]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ -} NRF_EGU_Type; - - -/* ================================================================================ */ -/* ================ PWM ================ */ -/* ================================================================================ */ - - -/** - * @brief Pulse Width Modulation Unit (PWM) - */ - -typedef struct { /*!< PWM Structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stops PWM pulse generation on all channels at the end of current - PWM period, and stops sequence playback */ - __O uint32_t TASKS_SEQSTART[2]; /*!< Description collection[0]: Loads the first PWM value on all - enabled channels from sequence 0, and starts playing that sequence - at the rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes - PWM generation to start it was not running. */ - __O uint32_t TASKS_NEXTSTEP; /*!< Steps by one value in the current sequence on all enabled channels - if DECODER.MODE=NextStep. Does not cause PWM generation to start - it was not running. */ - __I uint32_t RESERVED1[60]; - __IO uint32_t EVENTS_STOPPED; /*!< Response to STOP task, emitted when PWM pulses are no longer - generated */ - __IO uint32_t EVENTS_SEQSTARTED[2]; /*!< Description collection[0]: First PWM period started on sequence - 0 */ - __IO uint32_t EVENTS_SEQEND[2]; /*!< Description collection[0]: Emitted at end of every sequence - 0, when last value from RAM has been applied to wave counter */ - __IO uint32_t EVENTS_PWMPERIODEND; /*!< Emitted at the end of each PWM period */ - __IO uint32_t EVENTS_LOOPSDONE; /*!< Concatenated sequences have been played the amount of times - defined in LOOP.CNT */ - __I uint32_t RESERVED2[56]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[125]; - __IO uint32_t ENABLE; /*!< PWM module enable register */ - __IO uint32_t MODE; /*!< Selects operating mode of the wave counter */ - __IO uint32_t COUNTERTOP; /*!< Value up to which the pulse generator counter counts */ - __IO uint32_t PRESCALER; /*!< Configuration for PWM_CLK */ - __IO uint32_t DECODER; /*!< Configuration of the decoder */ - __IO uint32_t LOOP; /*!< Amount of playback of a loop */ - __I uint32_t RESERVED5[2]; - PWM_SEQ_Type SEQ[2]; /*!< Unspecified */ - PWM_PSEL_Type PSEL; /*!< Unspecified */ -} NRF_PWM_Type; - - -/* ================================================================================ */ -/* ================ PDM ================ */ -/* ================================================================================ */ - - -/** - * @brief Pulse Density Modulation (Digital Microphone) Interface (PDM) - */ - -typedef struct { /*!< PDM Structure */ - __O uint32_t TASKS_START; /*!< Starts continuous PDM transfer */ - __O uint32_t TASKS_STOP; /*!< Stops PDM transfer */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_STARTED; /*!< PDM transfer has started */ - __IO uint32_t EVENTS_STOPPED; /*!< PDM transfer has finished */ - __IO uint32_t EVENTS_END; /*!< The PDM has written the last sample specified by SAMPLE.MAXCNT - (or the last sample after a STOP task has been received) to - Data RAM */ - __I uint32_t RESERVED1[125]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< PDM module enable register */ - __IO uint32_t PDMCLKCTRL; /*!< PDM clock generator control */ - __IO uint32_t MODE; /*!< Defines the routing of the connected PDM microphones' signals */ - __I uint32_t RESERVED3[3]; - __IO uint32_t GAINL; /*!< Left output gain adjustment */ - __IO uint32_t GAINR; /*!< Right output gain adjustment */ - __I uint32_t RESERVED4[8]; - PDM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED5[6]; - PDM_SAMPLE_Type SAMPLE; /*!< Unspecified */ -} NRF_PDM_Type; - - -/* ================================================================================ */ -/* ================ NVMC ================ */ -/* ================================================================================ */ - - -/** - * @brief Non-volatile memory controller (NVMC) - */ - -typedef struct { /*!< NVMC Structure */ - __I uint32_t RESERVED0[256]; - __I uint32_t READY; /*!< Ready flag */ - __I uint32_t RESERVED1[64]; - __IO uint32_t CONFIG; /*!< Configuration register */ - - union { - __IO uint32_t ERASEPAGE; /*!< Register for erasing a page in code area */ - __IO uint32_t ERASEPCR1; /*!< Deprecated register - Register for erasing a page in code area. - Equivalent to ERASEPAGE. */ - }; - __IO uint32_t ERASEALL; /*!< Register for erasing all non-volatile user memory */ - __IO uint32_t ERASEPCR0; /*!< Deprecated register - Register for erasing a page in code area. - Equivalent to ERASEPAGE. */ - __IO uint32_t ERASEUICR; /*!< Register for erasing user information configuration registers */ -} NRF_NVMC_Type; - - -/* ================================================================================ */ -/* ================ PPI ================ */ -/* ================================================================================ */ - - -/** - * @brief Programmable Peripheral Interconnect (PPI) - */ - -typedef struct { /*!< PPI Structure */ - PPI_TASKS_CHG_Type TASKS_CHG[6]; /*!< Channel group tasks */ - __I uint32_t RESERVED0[308]; - __IO uint32_t CHEN; /*!< Channel enable register */ - __IO uint32_t CHENSET; /*!< Channel enable set register */ - __IO uint32_t CHENCLR; /*!< Channel enable clear register */ - __I uint32_t RESERVED1; - PPI_CH_Type CH[20]; /*!< PPI Channel */ - __I uint32_t RESERVED2[148]; - __IO uint32_t CHG[6]; /*!< Description collection[0]: Channel group 0 */ - __I uint32_t RESERVED3[62]; - PPI_FORK_Type FORK[32]; /*!< Fork */ -} NRF_PPI_Type; - - -/* ================================================================================ */ -/* ================ GPIO ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO Port (GPIO) - */ - -typedef struct { /*!< GPIO Structure */ - __I uint32_t RESERVED0[321]; - __IO uint32_t OUT; /*!< Write GPIO port */ - __IO uint32_t OUTSET; /*!< Set individual bits in GPIO port */ - __IO uint32_t OUTCLR; /*!< Clear individual bits in GPIO port */ - __I uint32_t IN; /*!< Read GPIO port */ - __IO uint32_t DIR; /*!< Direction of GPIO pins */ - __IO uint32_t DIRSET; /*!< DIR set register */ - __IO uint32_t DIRCLR; /*!< DIR clear register */ - __IO uint32_t LATCH; /*!< Latch register indicating what GPIO pins that have met the criteria - set in the PIN_CNF[n].SENSE registers */ - __IO uint32_t DETECTMODE; /*!< Select between default DETECT signal behaviour and LDETECT mode */ - __I uint32_t RESERVED1[118]; - __IO uint32_t PIN_CNF[32]; /*!< Description collection[0]: Configuration of GPIO pins */ -} NRF_GPIO_Type; - - -/* -------------------- End of section using anonymous unions ------------------- */ -#if defined(__CC_ARM) - #pragma pop -#elif defined(__ICCARM__) - /* leave anonymous unions enabled */ -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) - /* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning restore -#else - #warning Not supported compiler type -#endif - - - - -/* ================================================================================ */ -/* ================ Peripheral memory map ================ */ -/* ================================================================================ */ - -#define NRF_FICR_BASE 0x10000000UL -#define NRF_UICR_BASE 0x10001000UL -#define NRF_BPROT_BASE 0x40000000UL -#define NRF_POWER_BASE 0x40000000UL -#define NRF_CLOCK_BASE 0x40000000UL -#define NRF_RADIO_BASE 0x40001000UL -#define NRF_UARTE0_BASE 0x40002000UL -#define NRF_TWIM0_BASE 0x40003000UL -#define NRF_TWIS0_BASE 0x40003000UL -#define NRF_SPIM0_BASE 0x40004000UL -#define NRF_SPIS0_BASE 0x40004000UL -#define NRF_GPIOTE_BASE 0x40006000UL -#define NRF_SAADC_BASE 0x40007000UL -#define NRF_TIMER0_BASE 0x40008000UL -#define NRF_TIMER1_BASE 0x40009000UL -#define NRF_TIMER2_BASE 0x4000A000UL -#define NRF_RTC0_BASE 0x4000B000UL -#define NRF_TEMP_BASE 0x4000C000UL -#define NRF_RNG_BASE 0x4000D000UL -#define NRF_ECB_BASE 0x4000E000UL -#define NRF_CCM_BASE 0x4000F000UL -#define NRF_AAR_BASE 0x4000F000UL -#define NRF_WDT_BASE 0x40010000UL -#define NRF_RTC1_BASE 0x40011000UL -#define NRF_QDEC_BASE 0x40012000UL -#define NRF_COMP_BASE 0x40013000UL -#define NRF_SWI0_BASE 0x40014000UL -#define NRF_EGU0_BASE 0x40014000UL -#define NRF_SWI1_BASE 0x40015000UL -#define NRF_EGU1_BASE 0x40015000UL -#define NRF_SWI2_BASE 0x40016000UL -#define NRF_SWI3_BASE 0x40017000UL -#define NRF_SWI4_BASE 0x40018000UL -#define NRF_SWI5_BASE 0x40019000UL -#define NRF_PWM0_BASE 0x4001C000UL -#define NRF_PDM_BASE 0x4001D000UL -#define NRF_NVMC_BASE 0x4001E000UL -#define NRF_PPI_BASE 0x4001F000UL -#define NRF_P0_BASE 0x50000000UL - - -/* ================================================================================ */ -/* ================ Peripheral declaration ================ */ -/* ================================================================================ */ - -#define NRF_FICR ((NRF_FICR_Type *) NRF_FICR_BASE) -#define NRF_UICR ((NRF_UICR_Type *) NRF_UICR_BASE) -#define NRF_BPROT ((NRF_BPROT_Type *) NRF_BPROT_BASE) -#define NRF_POWER ((NRF_POWER_Type *) NRF_POWER_BASE) -#define NRF_CLOCK ((NRF_CLOCK_Type *) NRF_CLOCK_BASE) -#define NRF_RADIO ((NRF_RADIO_Type *) NRF_RADIO_BASE) -#define NRF_UARTE0 ((NRF_UARTE_Type *) NRF_UARTE0_BASE) -#define NRF_TWIM0 ((NRF_TWIM_Type *) NRF_TWIM0_BASE) -#define NRF_TWIS0 ((NRF_TWIS_Type *) NRF_TWIS0_BASE) -#define NRF_SPIM0 ((NRF_SPIM_Type *) NRF_SPIM0_BASE) -#define NRF_SPIS0 ((NRF_SPIS_Type *) NRF_SPIS0_BASE) -#define NRF_GPIOTE ((NRF_GPIOTE_Type *) NRF_GPIOTE_BASE) -#define NRF_SAADC ((NRF_SAADC_Type *) NRF_SAADC_BASE) -#define NRF_TIMER0 ((NRF_TIMER_Type *) NRF_TIMER0_BASE) -#define NRF_TIMER1 ((NRF_TIMER_Type *) NRF_TIMER1_BASE) -#define NRF_TIMER2 ((NRF_TIMER_Type *) NRF_TIMER2_BASE) -#define NRF_RTC0 ((NRF_RTC_Type *) NRF_RTC0_BASE) -#define NRF_TEMP ((NRF_TEMP_Type *) NRF_TEMP_BASE) -#define NRF_RNG ((NRF_RNG_Type *) NRF_RNG_BASE) -#define NRF_ECB ((NRF_ECB_Type *) NRF_ECB_BASE) -#define NRF_CCM ((NRF_CCM_Type *) NRF_CCM_BASE) -#define NRF_AAR ((NRF_AAR_Type *) NRF_AAR_BASE) -#define NRF_WDT ((NRF_WDT_Type *) NRF_WDT_BASE) -#define NRF_RTC1 ((NRF_RTC_Type *) NRF_RTC1_BASE) -#define NRF_QDEC ((NRF_QDEC_Type *) NRF_QDEC_BASE) -#define NRF_COMP ((NRF_COMP_Type *) NRF_COMP_BASE) -#define NRF_SWI0 ((NRF_SWI_Type *) NRF_SWI0_BASE) -#define NRF_EGU0 ((NRF_EGU_Type *) NRF_EGU0_BASE) -#define NRF_SWI1 ((NRF_SWI_Type *) NRF_SWI1_BASE) -#define NRF_EGU1 ((NRF_EGU_Type *) NRF_EGU1_BASE) -#define NRF_SWI2 ((NRF_SWI_Type *) NRF_SWI2_BASE) -#define NRF_SWI3 ((NRF_SWI_Type *) NRF_SWI3_BASE) -#define NRF_SWI4 ((NRF_SWI_Type *) NRF_SWI4_BASE) -#define NRF_SWI5 ((NRF_SWI_Type *) NRF_SWI5_BASE) -#define NRF_PWM0 ((NRF_PWM_Type *) NRF_PWM0_BASE) -#define NRF_PDM ((NRF_PDM_Type *) NRF_PDM_BASE) -#define NRF_NVMC ((NRF_NVMC_Type *) NRF_NVMC_BASE) -#define NRF_PPI ((NRF_PPI_Type *) NRF_PPI_BASE) -#define NRF_P0 ((NRF_GPIO_Type *) NRF_P0_BASE) - - -/** @} */ /* End of group Device_Peripheral_Registers */ -/** @} */ /* End of group nrf52810 */ -/** @} */ /* End of group Nordic Semiconductor */ - -#ifdef __cplusplus -} -#endif - - -#endif /* nrf52810_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_bitfields.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_bitfields.h deleted file mode 100644 index fe4ba24..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_bitfields.h +++ /dev/null @@ -1,10247 +0,0 @@ -/* - -Copyright (c) 2010 - 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 __NRF52810_BITS_H -#define __NRF52810_BITS_H - -/*lint ++flb "Enter library region" */ - -/* Peripheral: AAR */ -/* Description: Accelerated Address Resolver */ - -/* Register: AAR_TASKS_START */ -/* Description: Start resolving addresses based on IRKs specified in the IRK data structure */ - -/* Bit 0 : */ -#define AAR_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define AAR_TASKS_START_TASKS_START_Msk (0x1UL << AAR_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: AAR_TASKS_STOP */ -/* Description: Stop resolving addresses */ - -/* Bit 0 : */ -#define AAR_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define AAR_TASKS_STOP_TASKS_STOP_Msk (0x1UL << AAR_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: AAR_EVENTS_END */ -/* Description: Address resolution procedure complete */ - -/* Bit 0 : */ -#define AAR_EVENTS_END_EVENTS_END_Pos (0UL) /*!< Position of EVENTS_END field. */ -#define AAR_EVENTS_END_EVENTS_END_Msk (0x1UL << AAR_EVENTS_END_EVENTS_END_Pos) /*!< Bit mask of EVENTS_END field. */ - -/* Register: AAR_EVENTS_RESOLVED */ -/* Description: Address resolved */ - -/* Bit 0 : */ -#define AAR_EVENTS_RESOLVED_EVENTS_RESOLVED_Pos (0UL) /*!< Position of EVENTS_RESOLVED field. */ -#define AAR_EVENTS_RESOLVED_EVENTS_RESOLVED_Msk (0x1UL << AAR_EVENTS_RESOLVED_EVENTS_RESOLVED_Pos) /*!< Bit mask of EVENTS_RESOLVED field. */ - -/* Register: AAR_EVENTS_NOTRESOLVED */ -/* Description: Address not resolved */ - -/* Bit 0 : */ -#define AAR_EVENTS_NOTRESOLVED_EVENTS_NOTRESOLVED_Pos (0UL) /*!< Position of EVENTS_NOTRESOLVED field. */ -#define AAR_EVENTS_NOTRESOLVED_EVENTS_NOTRESOLVED_Msk (0x1UL << AAR_EVENTS_NOTRESOLVED_EVENTS_NOTRESOLVED_Pos) /*!< Bit mask of EVENTS_NOTRESOLVED field. */ - -/* Register: AAR_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for NOTRESOLVED event */ -#define AAR_INTENSET_NOTRESOLVED_Pos (2UL) /*!< Position of NOTRESOLVED field. */ -#define AAR_INTENSET_NOTRESOLVED_Msk (0x1UL << AAR_INTENSET_NOTRESOLVED_Pos) /*!< Bit mask of NOTRESOLVED field. */ -#define AAR_INTENSET_NOTRESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENSET_NOTRESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENSET_NOTRESOLVED_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for RESOLVED event */ -#define AAR_INTENSET_RESOLVED_Pos (1UL) /*!< Position of RESOLVED field. */ -#define AAR_INTENSET_RESOLVED_Msk (0x1UL << AAR_INTENSET_RESOLVED_Pos) /*!< Bit mask of RESOLVED field. */ -#define AAR_INTENSET_RESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENSET_RESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENSET_RESOLVED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for END event */ -#define AAR_INTENSET_END_Pos (0UL) /*!< Position of END field. */ -#define AAR_INTENSET_END_Msk (0x1UL << AAR_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define AAR_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Register: AAR_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for NOTRESOLVED event */ -#define AAR_INTENCLR_NOTRESOLVED_Pos (2UL) /*!< Position of NOTRESOLVED field. */ -#define AAR_INTENCLR_NOTRESOLVED_Msk (0x1UL << AAR_INTENCLR_NOTRESOLVED_Pos) /*!< Bit mask of NOTRESOLVED field. */ -#define AAR_INTENCLR_NOTRESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENCLR_NOTRESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENCLR_NOTRESOLVED_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for RESOLVED event */ -#define AAR_INTENCLR_RESOLVED_Pos (1UL) /*!< Position of RESOLVED field. */ -#define AAR_INTENCLR_RESOLVED_Msk (0x1UL << AAR_INTENCLR_RESOLVED_Pos) /*!< Bit mask of RESOLVED field. */ -#define AAR_INTENCLR_RESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENCLR_RESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENCLR_RESOLVED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for END event */ -#define AAR_INTENCLR_END_Pos (0UL) /*!< Position of END field. */ -#define AAR_INTENCLR_END_Msk (0x1UL << AAR_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define AAR_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Register: AAR_STATUS */ -/* Description: Resolution status */ - -/* Bits 3..0 : The IRK that was used last time an address was resolved */ -#define AAR_STATUS_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define AAR_STATUS_STATUS_Msk (0xFUL << AAR_STATUS_STATUS_Pos) /*!< Bit mask of STATUS field. */ - -/* Register: AAR_ENABLE */ -/* Description: Enable AAR */ - -/* Bits 1..0 : Enable or disable AAR */ -#define AAR_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define AAR_ENABLE_ENABLE_Msk (0x3UL << AAR_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define AAR_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define AAR_ENABLE_ENABLE_Enabled (3UL) /*!< Enable */ - -/* Register: AAR_NIRK */ -/* Description: Number of IRKs */ - -/* Bits 4..0 : Number of Identity root keys available in the IRK data structure */ -#define AAR_NIRK_NIRK_Pos (0UL) /*!< Position of NIRK field. */ -#define AAR_NIRK_NIRK_Msk (0x1FUL << AAR_NIRK_NIRK_Pos) /*!< Bit mask of NIRK field. */ - -/* Register: AAR_IRKPTR */ -/* Description: Pointer to IRK data structure */ - -/* Bits 31..0 : Pointer to the IRK data structure */ -#define AAR_IRKPTR_IRKPTR_Pos (0UL) /*!< Position of IRKPTR field. */ -#define AAR_IRKPTR_IRKPTR_Msk (0xFFFFFFFFUL << AAR_IRKPTR_IRKPTR_Pos) /*!< Bit mask of IRKPTR field. */ - -/* Register: AAR_ADDRPTR */ -/* Description: Pointer to the resolvable address */ - -/* Bits 31..0 : Pointer to the resolvable address (6-bytes) */ -#define AAR_ADDRPTR_ADDRPTR_Pos (0UL) /*!< Position of ADDRPTR field. */ -#define AAR_ADDRPTR_ADDRPTR_Msk (0xFFFFFFFFUL << AAR_ADDRPTR_ADDRPTR_Pos) /*!< Bit mask of ADDRPTR field. */ - -/* Register: AAR_SCRATCHPTR */ -/* Description: Pointer to data area used for temporary storage */ - -/* Bits 31..0 : Pointer to a scratch data area used for temporary storage during resolution.A space of minimum 3 bytes must be reserved. */ -#define AAR_SCRATCHPTR_SCRATCHPTR_Pos (0UL) /*!< Position of SCRATCHPTR field. */ -#define AAR_SCRATCHPTR_SCRATCHPTR_Msk (0xFFFFFFFFUL << AAR_SCRATCHPTR_SCRATCHPTR_Pos) /*!< Bit mask of SCRATCHPTR field. */ - - -/* Peripheral: BPROT */ -/* Description: Block Protect */ - -/* Register: BPROT_CONFIG0 */ -/* Description: Block protect configuration register 0 */ - -/* Bit 31 : Enable protection for region 31. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION31_Pos (31UL) /*!< Position of REGION31 field. */ -#define BPROT_CONFIG0_REGION31_Msk (0x1UL << BPROT_CONFIG0_REGION31_Pos) /*!< Bit mask of REGION31 field. */ -#define BPROT_CONFIG0_REGION31_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION31_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 30 : Enable protection for region 30. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION30_Pos (30UL) /*!< Position of REGION30 field. */ -#define BPROT_CONFIG0_REGION30_Msk (0x1UL << BPROT_CONFIG0_REGION30_Pos) /*!< Bit mask of REGION30 field. */ -#define BPROT_CONFIG0_REGION30_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION30_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 29 : Enable protection for region 29. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION29_Pos (29UL) /*!< Position of REGION29 field. */ -#define BPROT_CONFIG0_REGION29_Msk (0x1UL << BPROT_CONFIG0_REGION29_Pos) /*!< Bit mask of REGION29 field. */ -#define BPROT_CONFIG0_REGION29_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION29_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 28 : Enable protection for region 28. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION28_Pos (28UL) /*!< Position of REGION28 field. */ -#define BPROT_CONFIG0_REGION28_Msk (0x1UL << BPROT_CONFIG0_REGION28_Pos) /*!< Bit mask of REGION28 field. */ -#define BPROT_CONFIG0_REGION28_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION28_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 27 : Enable protection for region 27. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION27_Pos (27UL) /*!< Position of REGION27 field. */ -#define BPROT_CONFIG0_REGION27_Msk (0x1UL << BPROT_CONFIG0_REGION27_Pos) /*!< Bit mask of REGION27 field. */ -#define BPROT_CONFIG0_REGION27_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION27_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 26 : Enable protection for region 26. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION26_Pos (26UL) /*!< Position of REGION26 field. */ -#define BPROT_CONFIG0_REGION26_Msk (0x1UL << BPROT_CONFIG0_REGION26_Pos) /*!< Bit mask of REGION26 field. */ -#define BPROT_CONFIG0_REGION26_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION26_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 25 : Enable protection for region 25. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION25_Pos (25UL) /*!< Position of REGION25 field. */ -#define BPROT_CONFIG0_REGION25_Msk (0x1UL << BPROT_CONFIG0_REGION25_Pos) /*!< Bit mask of REGION25 field. */ -#define BPROT_CONFIG0_REGION25_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION25_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 24 : Enable protection for region 24. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION24_Pos (24UL) /*!< Position of REGION24 field. */ -#define BPROT_CONFIG0_REGION24_Msk (0x1UL << BPROT_CONFIG0_REGION24_Pos) /*!< Bit mask of REGION24 field. */ -#define BPROT_CONFIG0_REGION24_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION24_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 23 : Enable protection for region 23. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION23_Pos (23UL) /*!< Position of REGION23 field. */ -#define BPROT_CONFIG0_REGION23_Msk (0x1UL << BPROT_CONFIG0_REGION23_Pos) /*!< Bit mask of REGION23 field. */ -#define BPROT_CONFIG0_REGION23_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION23_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 22 : Enable protection for region 22. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION22_Pos (22UL) /*!< Position of REGION22 field. */ -#define BPROT_CONFIG0_REGION22_Msk (0x1UL << BPROT_CONFIG0_REGION22_Pos) /*!< Bit mask of REGION22 field. */ -#define BPROT_CONFIG0_REGION22_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION22_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 21 : Enable protection for region 21. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION21_Pos (21UL) /*!< Position of REGION21 field. */ -#define BPROT_CONFIG0_REGION21_Msk (0x1UL << BPROT_CONFIG0_REGION21_Pos) /*!< Bit mask of REGION21 field. */ -#define BPROT_CONFIG0_REGION21_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION21_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 20 : Enable protection for region 20. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION20_Pos (20UL) /*!< Position of REGION20 field. */ -#define BPROT_CONFIG0_REGION20_Msk (0x1UL << BPROT_CONFIG0_REGION20_Pos) /*!< Bit mask of REGION20 field. */ -#define BPROT_CONFIG0_REGION20_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION20_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 19 : Enable protection for region 19. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION19_Pos (19UL) /*!< Position of REGION19 field. */ -#define BPROT_CONFIG0_REGION19_Msk (0x1UL << BPROT_CONFIG0_REGION19_Pos) /*!< Bit mask of REGION19 field. */ -#define BPROT_CONFIG0_REGION19_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION19_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 18 : Enable protection for region 18. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION18_Pos (18UL) /*!< Position of REGION18 field. */ -#define BPROT_CONFIG0_REGION18_Msk (0x1UL << BPROT_CONFIG0_REGION18_Pos) /*!< Bit mask of REGION18 field. */ -#define BPROT_CONFIG0_REGION18_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION18_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 17 : Enable protection for region 17. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION17_Pos (17UL) /*!< Position of REGION17 field. */ -#define BPROT_CONFIG0_REGION17_Msk (0x1UL << BPROT_CONFIG0_REGION17_Pos) /*!< Bit mask of REGION17 field. */ -#define BPROT_CONFIG0_REGION17_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION17_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 16 : Enable protection for region 16. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION16_Pos (16UL) /*!< Position of REGION16 field. */ -#define BPROT_CONFIG0_REGION16_Msk (0x1UL << BPROT_CONFIG0_REGION16_Pos) /*!< Bit mask of REGION16 field. */ -#define BPROT_CONFIG0_REGION16_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION16_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 15 : Enable protection for region 15. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION15_Pos (15UL) /*!< Position of REGION15 field. */ -#define BPROT_CONFIG0_REGION15_Msk (0x1UL << BPROT_CONFIG0_REGION15_Pos) /*!< Bit mask of REGION15 field. */ -#define BPROT_CONFIG0_REGION15_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION15_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 14 : Enable protection for region 14. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION14_Pos (14UL) /*!< Position of REGION14 field. */ -#define BPROT_CONFIG0_REGION14_Msk (0x1UL << BPROT_CONFIG0_REGION14_Pos) /*!< Bit mask of REGION14 field. */ -#define BPROT_CONFIG0_REGION14_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION14_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 13 : Enable protection for region 13. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION13_Pos (13UL) /*!< Position of REGION13 field. */ -#define BPROT_CONFIG0_REGION13_Msk (0x1UL << BPROT_CONFIG0_REGION13_Pos) /*!< Bit mask of REGION13 field. */ -#define BPROT_CONFIG0_REGION13_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION13_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 12 : Enable protection for region 12. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION12_Pos (12UL) /*!< Position of REGION12 field. */ -#define BPROT_CONFIG0_REGION12_Msk (0x1UL << BPROT_CONFIG0_REGION12_Pos) /*!< Bit mask of REGION12 field. */ -#define BPROT_CONFIG0_REGION12_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION12_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 11 : Enable protection for region 11. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION11_Pos (11UL) /*!< Position of REGION11 field. */ -#define BPROT_CONFIG0_REGION11_Msk (0x1UL << BPROT_CONFIG0_REGION11_Pos) /*!< Bit mask of REGION11 field. */ -#define BPROT_CONFIG0_REGION11_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION11_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 10 : Enable protection for region 10. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION10_Pos (10UL) /*!< Position of REGION10 field. */ -#define BPROT_CONFIG0_REGION10_Msk (0x1UL << BPROT_CONFIG0_REGION10_Pos) /*!< Bit mask of REGION10 field. */ -#define BPROT_CONFIG0_REGION10_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION10_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 9 : Enable protection for region 9. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION9_Pos (9UL) /*!< Position of REGION9 field. */ -#define BPROT_CONFIG0_REGION9_Msk (0x1UL << BPROT_CONFIG0_REGION9_Pos) /*!< Bit mask of REGION9 field. */ -#define BPROT_CONFIG0_REGION9_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION9_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 8 : Enable protection for region 8. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION8_Pos (8UL) /*!< Position of REGION8 field. */ -#define BPROT_CONFIG0_REGION8_Msk (0x1UL << BPROT_CONFIG0_REGION8_Pos) /*!< Bit mask of REGION8 field. */ -#define BPROT_CONFIG0_REGION8_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION8_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 7 : Enable protection for region 7. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION7_Pos (7UL) /*!< Position of REGION7 field. */ -#define BPROT_CONFIG0_REGION7_Msk (0x1UL << BPROT_CONFIG0_REGION7_Pos) /*!< Bit mask of REGION7 field. */ -#define BPROT_CONFIG0_REGION7_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION7_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 6 : Enable protection for region 6. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION6_Pos (6UL) /*!< Position of REGION6 field. */ -#define BPROT_CONFIG0_REGION6_Msk (0x1UL << BPROT_CONFIG0_REGION6_Pos) /*!< Bit mask of REGION6 field. */ -#define BPROT_CONFIG0_REGION6_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION6_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 5 : Enable protection for region 5. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION5_Pos (5UL) /*!< Position of REGION5 field. */ -#define BPROT_CONFIG0_REGION5_Msk (0x1UL << BPROT_CONFIG0_REGION5_Pos) /*!< Bit mask of REGION5 field. */ -#define BPROT_CONFIG0_REGION5_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION5_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 4 : Enable protection for region 4. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION4_Pos (4UL) /*!< Position of REGION4 field. */ -#define BPROT_CONFIG0_REGION4_Msk (0x1UL << BPROT_CONFIG0_REGION4_Pos) /*!< Bit mask of REGION4 field. */ -#define BPROT_CONFIG0_REGION4_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION4_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 3 : Enable protection for region 3. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION3_Pos (3UL) /*!< Position of REGION3 field. */ -#define BPROT_CONFIG0_REGION3_Msk (0x1UL << BPROT_CONFIG0_REGION3_Pos) /*!< Bit mask of REGION3 field. */ -#define BPROT_CONFIG0_REGION3_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION3_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 2 : Enable protection for region 2. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION2_Pos (2UL) /*!< Position of REGION2 field. */ -#define BPROT_CONFIG0_REGION2_Msk (0x1UL << BPROT_CONFIG0_REGION2_Pos) /*!< Bit mask of REGION2 field. */ -#define BPROT_CONFIG0_REGION2_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION2_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 1 : Enable protection for region 1. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION1_Pos (1UL) /*!< Position of REGION1 field. */ -#define BPROT_CONFIG0_REGION1_Msk (0x1UL << BPROT_CONFIG0_REGION1_Pos) /*!< Bit mask of REGION1 field. */ -#define BPROT_CONFIG0_REGION1_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION1_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 0 : Enable protection for region 0. Write '0' has no effect. */ -#define BPROT_CONFIG0_REGION0_Pos (0UL) /*!< Position of REGION0 field. */ -#define BPROT_CONFIG0_REGION0_Msk (0x1UL << BPROT_CONFIG0_REGION0_Pos) /*!< Bit mask of REGION0 field. */ -#define BPROT_CONFIG0_REGION0_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG0_REGION0_Enabled (1UL) /*!< Protection enabled */ - -/* Register: BPROT_CONFIG1 */ -/* Description: Block protect configuration register 1 */ - -/* Bit 15 : Enable protection for region 47. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION47_Pos (15UL) /*!< Position of REGION47 field. */ -#define BPROT_CONFIG1_REGION47_Msk (0x1UL << BPROT_CONFIG1_REGION47_Pos) /*!< Bit mask of REGION47 field. */ -#define BPROT_CONFIG1_REGION47_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION47_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 14 : Enable protection for region 46. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION46_Pos (14UL) /*!< Position of REGION46 field. */ -#define BPROT_CONFIG1_REGION46_Msk (0x1UL << BPROT_CONFIG1_REGION46_Pos) /*!< Bit mask of REGION46 field. */ -#define BPROT_CONFIG1_REGION46_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION46_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 13 : Enable protection for region 45. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION45_Pos (13UL) /*!< Position of REGION45 field. */ -#define BPROT_CONFIG1_REGION45_Msk (0x1UL << BPROT_CONFIG1_REGION45_Pos) /*!< Bit mask of REGION45 field. */ -#define BPROT_CONFIG1_REGION45_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION45_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 12 : Enable protection for region 44. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION44_Pos (12UL) /*!< Position of REGION44 field. */ -#define BPROT_CONFIG1_REGION44_Msk (0x1UL << BPROT_CONFIG1_REGION44_Pos) /*!< Bit mask of REGION44 field. */ -#define BPROT_CONFIG1_REGION44_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION44_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 11 : Enable protection for region 43. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION43_Pos (11UL) /*!< Position of REGION43 field. */ -#define BPROT_CONFIG1_REGION43_Msk (0x1UL << BPROT_CONFIG1_REGION43_Pos) /*!< Bit mask of REGION43 field. */ -#define BPROT_CONFIG1_REGION43_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION43_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 10 : Enable protection for region 42. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION42_Pos (10UL) /*!< Position of REGION42 field. */ -#define BPROT_CONFIG1_REGION42_Msk (0x1UL << BPROT_CONFIG1_REGION42_Pos) /*!< Bit mask of REGION42 field. */ -#define BPROT_CONFIG1_REGION42_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION42_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 9 : Enable protection for region 41. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION41_Pos (9UL) /*!< Position of REGION41 field. */ -#define BPROT_CONFIG1_REGION41_Msk (0x1UL << BPROT_CONFIG1_REGION41_Pos) /*!< Bit mask of REGION41 field. */ -#define BPROT_CONFIG1_REGION41_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION41_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 8 : Enable protection for region 40. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION40_Pos (8UL) /*!< Position of REGION40 field. */ -#define BPROT_CONFIG1_REGION40_Msk (0x1UL << BPROT_CONFIG1_REGION40_Pos) /*!< Bit mask of REGION40 field. */ -#define BPROT_CONFIG1_REGION40_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION40_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 7 : Enable protection for region 39. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION39_Pos (7UL) /*!< Position of REGION39 field. */ -#define BPROT_CONFIG1_REGION39_Msk (0x1UL << BPROT_CONFIG1_REGION39_Pos) /*!< Bit mask of REGION39 field. */ -#define BPROT_CONFIG1_REGION39_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION39_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 6 : Enable protection for region 38. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION38_Pos (6UL) /*!< Position of REGION38 field. */ -#define BPROT_CONFIG1_REGION38_Msk (0x1UL << BPROT_CONFIG1_REGION38_Pos) /*!< Bit mask of REGION38 field. */ -#define BPROT_CONFIG1_REGION38_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION38_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 5 : Enable protection for region 37. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION37_Pos (5UL) /*!< Position of REGION37 field. */ -#define BPROT_CONFIG1_REGION37_Msk (0x1UL << BPROT_CONFIG1_REGION37_Pos) /*!< Bit mask of REGION37 field. */ -#define BPROT_CONFIG1_REGION37_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION37_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 4 : Enable protection for region 36. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION36_Pos (4UL) /*!< Position of REGION36 field. */ -#define BPROT_CONFIG1_REGION36_Msk (0x1UL << BPROT_CONFIG1_REGION36_Pos) /*!< Bit mask of REGION36 field. */ -#define BPROT_CONFIG1_REGION36_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION36_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 3 : Enable protection for region 35. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION35_Pos (3UL) /*!< Position of REGION35 field. */ -#define BPROT_CONFIG1_REGION35_Msk (0x1UL << BPROT_CONFIG1_REGION35_Pos) /*!< Bit mask of REGION35 field. */ -#define BPROT_CONFIG1_REGION35_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION35_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 2 : Enable protection for region 34. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION34_Pos (2UL) /*!< Position of REGION34 field. */ -#define BPROT_CONFIG1_REGION34_Msk (0x1UL << BPROT_CONFIG1_REGION34_Pos) /*!< Bit mask of REGION34 field. */ -#define BPROT_CONFIG1_REGION34_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION34_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 1 : Enable protection for region 33. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION33_Pos (1UL) /*!< Position of REGION33 field. */ -#define BPROT_CONFIG1_REGION33_Msk (0x1UL << BPROT_CONFIG1_REGION33_Pos) /*!< Bit mask of REGION33 field. */ -#define BPROT_CONFIG1_REGION33_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION33_Enabled (1UL) /*!< Protection enabled */ - -/* Bit 0 : Enable protection for region 32. Write '0' has no effect. */ -#define BPROT_CONFIG1_REGION32_Pos (0UL) /*!< Position of REGION32 field. */ -#define BPROT_CONFIG1_REGION32_Msk (0x1UL << BPROT_CONFIG1_REGION32_Pos) /*!< Bit mask of REGION32 field. */ -#define BPROT_CONFIG1_REGION32_Disabled (0UL) /*!< Protection disabled */ -#define BPROT_CONFIG1_REGION32_Enabled (1UL) /*!< Protection enabled */ - -/* Register: BPROT_DISABLEINDEBUG */ -/* Description: Disable protection mechanism in debug mode */ - -/* Bit 0 : Disable the protection mechanism for NVM regions while in debug mode. This register will only disable the protection mechanism if the device is in debug mode. */ -#define BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Pos (0UL) /*!< Position of DISABLEINDEBUG field. */ -#define BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Msk (0x1UL << BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Pos) /*!< Bit mask of DISABLEINDEBUG field. */ -#define BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Enabled (0UL) /*!< Enabled in debug */ -#define BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Disabled (1UL) /*!< Disabled in debug */ - - -/* Peripheral: CCM */ -/* Description: AES CCM Mode Encryption */ - -/* Register: CCM_TASKS_KSGEN */ -/* Description: Start generation of key-stream. This operation will stop by itself when completed. */ - -/* Bit 0 : */ -#define CCM_TASKS_KSGEN_TASKS_KSGEN_Pos (0UL) /*!< Position of TASKS_KSGEN field. */ -#define CCM_TASKS_KSGEN_TASKS_KSGEN_Msk (0x1UL << CCM_TASKS_KSGEN_TASKS_KSGEN_Pos) /*!< Bit mask of TASKS_KSGEN field. */ - -/* Register: CCM_TASKS_CRYPT */ -/* Description: Start encryption/decryption. This operation will stop by itself when completed. */ - -/* Bit 0 : */ -#define CCM_TASKS_CRYPT_TASKS_CRYPT_Pos (0UL) /*!< Position of TASKS_CRYPT field. */ -#define CCM_TASKS_CRYPT_TASKS_CRYPT_Msk (0x1UL << CCM_TASKS_CRYPT_TASKS_CRYPT_Pos) /*!< Bit mask of TASKS_CRYPT field. */ - -/* Register: CCM_TASKS_STOP */ -/* Description: Stop encryption/decryption */ - -/* Bit 0 : */ -#define CCM_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define CCM_TASKS_STOP_TASKS_STOP_Msk (0x1UL << CCM_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: CCM_TASKS_RATEOVERRIDE */ -/* Description: Override DATARATE setting in MODE register with the contents of the RATEOVERRIDE register for any ongoing encryption/decryption */ - -/* Bit 0 : */ -#define CCM_TASKS_RATEOVERRIDE_TASKS_RATEOVERRIDE_Pos (0UL) /*!< Position of TASKS_RATEOVERRIDE field. */ -#define CCM_TASKS_RATEOVERRIDE_TASKS_RATEOVERRIDE_Msk (0x1UL << CCM_TASKS_RATEOVERRIDE_TASKS_RATEOVERRIDE_Pos) /*!< Bit mask of TASKS_RATEOVERRIDE field. */ - -/* Register: CCM_EVENTS_ENDKSGEN */ -/* Description: Key-stream generation complete */ - -/* Bit 0 : */ -#define CCM_EVENTS_ENDKSGEN_EVENTS_ENDKSGEN_Pos (0UL) /*!< Position of EVENTS_ENDKSGEN field. */ -#define CCM_EVENTS_ENDKSGEN_EVENTS_ENDKSGEN_Msk (0x1UL << CCM_EVENTS_ENDKSGEN_EVENTS_ENDKSGEN_Pos) /*!< Bit mask of EVENTS_ENDKSGEN field. */ - -/* Register: CCM_EVENTS_ENDCRYPT */ -/* Description: Encrypt/decrypt complete */ - -/* Bit 0 : */ -#define CCM_EVENTS_ENDCRYPT_EVENTS_ENDCRYPT_Pos (0UL) /*!< Position of EVENTS_ENDCRYPT field. */ -#define CCM_EVENTS_ENDCRYPT_EVENTS_ENDCRYPT_Msk (0x1UL << CCM_EVENTS_ENDCRYPT_EVENTS_ENDCRYPT_Pos) /*!< Bit mask of EVENTS_ENDCRYPT field. */ - -/* Register: CCM_EVENTS_ERROR */ -/* Description: Deprecated register - CCM error event */ - -/* Bit 0 : */ -#define CCM_EVENTS_ERROR_EVENTS_ERROR_Pos (0UL) /*!< Position of EVENTS_ERROR field. */ -#define CCM_EVENTS_ERROR_EVENTS_ERROR_Msk (0x1UL << CCM_EVENTS_ERROR_EVENTS_ERROR_Pos) /*!< Bit mask of EVENTS_ERROR field. */ - -/* Register: CCM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 0 : Shortcut between ENDKSGEN event and CRYPT task */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Pos (0UL) /*!< Position of ENDKSGEN_CRYPT field. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Msk (0x1UL << CCM_SHORTS_ENDKSGEN_CRYPT_Pos) /*!< Bit mask of ENDKSGEN_CRYPT field. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Disabled (0UL) /*!< Disable shortcut */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: CCM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for ERROR event */ -#define CCM_INTENSET_ERROR_Pos (2UL) /*!< Position of ERROR field. */ -#define CCM_INTENSET_ERROR_Msk (0x1UL << CCM_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define CCM_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for ENDCRYPT event */ -#define CCM_INTENSET_ENDCRYPT_Pos (1UL) /*!< Position of ENDCRYPT field. */ -#define CCM_INTENSET_ENDCRYPT_Msk (0x1UL << CCM_INTENSET_ENDCRYPT_Pos) /*!< Bit mask of ENDCRYPT field. */ -#define CCM_INTENSET_ENDCRYPT_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENSET_ENDCRYPT_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENSET_ENDCRYPT_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for ENDKSGEN event */ -#define CCM_INTENSET_ENDKSGEN_Pos (0UL) /*!< Position of ENDKSGEN field. */ -#define CCM_INTENSET_ENDKSGEN_Msk (0x1UL << CCM_INTENSET_ENDKSGEN_Pos) /*!< Bit mask of ENDKSGEN field. */ -#define CCM_INTENSET_ENDKSGEN_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENSET_ENDKSGEN_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENSET_ENDKSGEN_Set (1UL) /*!< Enable */ - -/* Register: CCM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for ERROR event */ -#define CCM_INTENCLR_ERROR_Pos (2UL) /*!< Position of ERROR field. */ -#define CCM_INTENCLR_ERROR_Msk (0x1UL << CCM_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define CCM_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for ENDCRYPT event */ -#define CCM_INTENCLR_ENDCRYPT_Pos (1UL) /*!< Position of ENDCRYPT field. */ -#define CCM_INTENCLR_ENDCRYPT_Msk (0x1UL << CCM_INTENCLR_ENDCRYPT_Pos) /*!< Bit mask of ENDCRYPT field. */ -#define CCM_INTENCLR_ENDCRYPT_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENCLR_ENDCRYPT_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENCLR_ENDCRYPT_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for ENDKSGEN event */ -#define CCM_INTENCLR_ENDKSGEN_Pos (0UL) /*!< Position of ENDKSGEN field. */ -#define CCM_INTENCLR_ENDKSGEN_Msk (0x1UL << CCM_INTENCLR_ENDKSGEN_Pos) /*!< Bit mask of ENDKSGEN field. */ -#define CCM_INTENCLR_ENDKSGEN_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENCLR_ENDKSGEN_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENCLR_ENDKSGEN_Clear (1UL) /*!< Disable */ - -/* Register: CCM_MICSTATUS */ -/* Description: MIC check result */ - -/* Bit 0 : The result of the MIC check performed during the previous decryption operation */ -#define CCM_MICSTATUS_MICSTATUS_Pos (0UL) /*!< Position of MICSTATUS field. */ -#define CCM_MICSTATUS_MICSTATUS_Msk (0x1UL << CCM_MICSTATUS_MICSTATUS_Pos) /*!< Bit mask of MICSTATUS field. */ -#define CCM_MICSTATUS_MICSTATUS_CheckFailed (0UL) /*!< MIC check failed */ -#define CCM_MICSTATUS_MICSTATUS_CheckPassed (1UL) /*!< MIC check passed */ - -/* Register: CCM_ENABLE */ -/* Description: Enable */ - -/* Bits 1..0 : Enable or disable CCM */ -#define CCM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define CCM_ENABLE_ENABLE_Msk (0x3UL << CCM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define CCM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define CCM_ENABLE_ENABLE_Enabled (2UL) /*!< Enable */ - -/* Register: CCM_MODE */ -/* Description: Operation mode */ - -/* Bit 24 : Packet length configuration */ -#define CCM_MODE_LENGTH_Pos (24UL) /*!< Position of LENGTH field. */ -#define CCM_MODE_LENGTH_Msk (0x1UL << CCM_MODE_LENGTH_Pos) /*!< Bit mask of LENGTH field. */ -#define CCM_MODE_LENGTH_Default (0UL) /*!< Default length. Effective length of LENGTH field in encrypted/decrypted packet is 5 bits. A key-stream for packet payloads up to 27 bytes will be generated. */ -#define CCM_MODE_LENGTH_Extended (1UL) /*!< Extended length. Effective length of LENGTH field in encrypted/decrypted packet is 8 bits. A key-stream for packet payloads up to MAXPACKETSIZE bytes will be generated. */ - -/* Bits 17..16 : Radio data rate that the CCM shall run synchronous with */ -#define CCM_MODE_DATARATE_Pos (16UL) /*!< Position of DATARATE field. */ -#define CCM_MODE_DATARATE_Msk (0x3UL << CCM_MODE_DATARATE_Pos) /*!< Bit mask of DATARATE field. */ -#define CCM_MODE_DATARATE_1Mbit (0UL) /*!< 1 Mbps */ -#define CCM_MODE_DATARATE_2Mbit (1UL) /*!< 2 Mbps */ -#define CCM_MODE_DATARATE_125Kbps (2UL) /*!< 125 Kbps */ -#define CCM_MODE_DATARATE_500Kbps (3UL) /*!< 500 Kbps */ - -/* Bit 0 : The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered. */ -#define CCM_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define CCM_MODE_MODE_Msk (0x1UL << CCM_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define CCM_MODE_MODE_Encryption (0UL) /*!< AES CCM packet encryption mode */ -#define CCM_MODE_MODE_Decryption (1UL) /*!< AES CCM packet decryption mode */ - -/* Register: CCM_CNFPTR */ -/* Description: Pointer to data structure holding AES key and NONCE vector */ - -/* Bits 31..0 : Pointer to the data structure holding the AES key and the CCM NONCE vector (see Table 1 CCM data structure overview) */ -#define CCM_CNFPTR_CNFPTR_Pos (0UL) /*!< Position of CNFPTR field. */ -#define CCM_CNFPTR_CNFPTR_Msk (0xFFFFFFFFUL << CCM_CNFPTR_CNFPTR_Pos) /*!< Bit mask of CNFPTR field. */ - -/* Register: CCM_INPTR */ -/* Description: Input pointer */ - -/* Bits 31..0 : Input pointer */ -#define CCM_INPTR_INPTR_Pos (0UL) /*!< Position of INPTR field. */ -#define CCM_INPTR_INPTR_Msk (0xFFFFFFFFUL << CCM_INPTR_INPTR_Pos) /*!< Bit mask of INPTR field. */ - -/* Register: CCM_OUTPTR */ -/* Description: Output pointer */ - -/* Bits 31..0 : Output pointer */ -#define CCM_OUTPTR_OUTPTR_Pos (0UL) /*!< Position of OUTPTR field. */ -#define CCM_OUTPTR_OUTPTR_Msk (0xFFFFFFFFUL << CCM_OUTPTR_OUTPTR_Pos) /*!< Bit mask of OUTPTR field. */ - -/* Register: CCM_SCRATCHPTR */ -/* Description: Pointer to data area used for temporary storage */ - -/* Bits 31..0 : Pointer to a scratch data area used for temporary storage during key-stream generation, MIC generation and encryption/decryption. */ -#define CCM_SCRATCHPTR_SCRATCHPTR_Pos (0UL) /*!< Position of SCRATCHPTR field. */ -#define CCM_SCRATCHPTR_SCRATCHPTR_Msk (0xFFFFFFFFUL << CCM_SCRATCHPTR_SCRATCHPTR_Pos) /*!< Bit mask of SCRATCHPTR field. */ - -/* Register: CCM_MAXPACKETSIZE */ -/* Description: Length of key-stream generated when MODE.LENGTH = Extended. */ - -/* Bits 7..0 : Length of key-stream generated when MODE.LENGTH = Extended. This value must be greater or equal to the subsequent packet payload to be encrypted/decrypted. */ -#define CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos (0UL) /*!< Position of MAXPACKETSIZE field. */ -#define CCM_MAXPACKETSIZE_MAXPACKETSIZE_Msk (0xFFUL << CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos) /*!< Bit mask of MAXPACKETSIZE field. */ - -/* Register: CCM_RATEOVERRIDE */ -/* Description: Data rate override setting. */ - -/* Bits 1..0 : Data rate override setting. */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_Pos (0UL) /*!< Position of RATEOVERRIDE field. */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_Msk (0x3UL << CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) /*!< Bit mask of RATEOVERRIDE field. */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_1Mbit (0UL) /*!< 1 Mbps */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_2Mbit (1UL) /*!< 2 Mbps */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_125Kbps (2UL) /*!< 125 Kbps */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_500Kbps (3UL) /*!< 500 Kbps */ - - -/* Peripheral: CLOCK */ -/* Description: Clock control */ - -/* Register: CLOCK_TASKS_HFCLKSTART */ -/* Description: Start HFCLK crystal oscillator */ - -/* Bit 0 : */ -#define CLOCK_TASKS_HFCLKSTART_TASKS_HFCLKSTART_Pos (0UL) /*!< Position of TASKS_HFCLKSTART field. */ -#define CLOCK_TASKS_HFCLKSTART_TASKS_HFCLKSTART_Msk (0x1UL << CLOCK_TASKS_HFCLKSTART_TASKS_HFCLKSTART_Pos) /*!< Bit mask of TASKS_HFCLKSTART field. */ - -/* Register: CLOCK_TASKS_HFCLKSTOP */ -/* Description: Stop HFCLK crystal oscillator */ - -/* Bit 0 : */ -#define CLOCK_TASKS_HFCLKSTOP_TASKS_HFCLKSTOP_Pos (0UL) /*!< Position of TASKS_HFCLKSTOP field. */ -#define CLOCK_TASKS_HFCLKSTOP_TASKS_HFCLKSTOP_Msk (0x1UL << CLOCK_TASKS_HFCLKSTOP_TASKS_HFCLKSTOP_Pos) /*!< Bit mask of TASKS_HFCLKSTOP field. */ - -/* Register: CLOCK_TASKS_LFCLKSTART */ -/* Description: Start LFCLK source */ - -/* Bit 0 : */ -#define CLOCK_TASKS_LFCLKSTART_TASKS_LFCLKSTART_Pos (0UL) /*!< Position of TASKS_LFCLKSTART field. */ -#define CLOCK_TASKS_LFCLKSTART_TASKS_LFCLKSTART_Msk (0x1UL << CLOCK_TASKS_LFCLKSTART_TASKS_LFCLKSTART_Pos) /*!< Bit mask of TASKS_LFCLKSTART field. */ - -/* Register: CLOCK_TASKS_LFCLKSTOP */ -/* Description: Stop LFCLK source */ - -/* Bit 0 : */ -#define CLOCK_TASKS_LFCLKSTOP_TASKS_LFCLKSTOP_Pos (0UL) /*!< Position of TASKS_LFCLKSTOP field. */ -#define CLOCK_TASKS_LFCLKSTOP_TASKS_LFCLKSTOP_Msk (0x1UL << CLOCK_TASKS_LFCLKSTOP_TASKS_LFCLKSTOP_Pos) /*!< Bit mask of TASKS_LFCLKSTOP field. */ - -/* Register: CLOCK_TASKS_CAL */ -/* Description: Start calibration of LFRC oscillator */ - -/* Bit 0 : */ -#define CLOCK_TASKS_CAL_TASKS_CAL_Pos (0UL) /*!< Position of TASKS_CAL field. */ -#define CLOCK_TASKS_CAL_TASKS_CAL_Msk (0x1UL << CLOCK_TASKS_CAL_TASKS_CAL_Pos) /*!< Bit mask of TASKS_CAL field. */ - -/* Register: CLOCK_TASKS_CTSTART */ -/* Description: Start calibration timer */ - -/* Bit 0 : */ -#define CLOCK_TASKS_CTSTART_TASKS_CTSTART_Pos (0UL) /*!< Position of TASKS_CTSTART field. */ -#define CLOCK_TASKS_CTSTART_TASKS_CTSTART_Msk (0x1UL << CLOCK_TASKS_CTSTART_TASKS_CTSTART_Pos) /*!< Bit mask of TASKS_CTSTART field. */ - -/* Register: CLOCK_TASKS_CTSTOP */ -/* Description: Stop calibration timer */ - -/* Bit 0 : */ -#define CLOCK_TASKS_CTSTOP_TASKS_CTSTOP_Pos (0UL) /*!< Position of TASKS_CTSTOP field. */ -#define CLOCK_TASKS_CTSTOP_TASKS_CTSTOP_Msk (0x1UL << CLOCK_TASKS_CTSTOP_TASKS_CTSTOP_Pos) /*!< Bit mask of TASKS_CTSTOP field. */ - -/* Register: CLOCK_EVENTS_HFCLKSTARTED */ -/* Description: HFCLK oscillator started */ - -/* Bit 0 : */ -#define CLOCK_EVENTS_HFCLKSTARTED_EVENTS_HFCLKSTARTED_Pos (0UL) /*!< Position of EVENTS_HFCLKSTARTED field. */ -#define CLOCK_EVENTS_HFCLKSTARTED_EVENTS_HFCLKSTARTED_Msk (0x1UL << CLOCK_EVENTS_HFCLKSTARTED_EVENTS_HFCLKSTARTED_Pos) /*!< Bit mask of EVENTS_HFCLKSTARTED field. */ - -/* Register: CLOCK_EVENTS_LFCLKSTARTED */ -/* Description: LFCLK started */ - -/* Bit 0 : */ -#define CLOCK_EVENTS_LFCLKSTARTED_EVENTS_LFCLKSTARTED_Pos (0UL) /*!< Position of EVENTS_LFCLKSTARTED field. */ -#define CLOCK_EVENTS_LFCLKSTARTED_EVENTS_LFCLKSTARTED_Msk (0x1UL << CLOCK_EVENTS_LFCLKSTARTED_EVENTS_LFCLKSTARTED_Pos) /*!< Bit mask of EVENTS_LFCLKSTARTED field. */ - -/* Register: CLOCK_EVENTS_DONE */ -/* Description: Calibration of LFCLK RC oscillator complete event */ - -/* Bit 0 : */ -#define CLOCK_EVENTS_DONE_EVENTS_DONE_Pos (0UL) /*!< Position of EVENTS_DONE field. */ -#define CLOCK_EVENTS_DONE_EVENTS_DONE_Msk (0x1UL << CLOCK_EVENTS_DONE_EVENTS_DONE_Pos) /*!< Bit mask of EVENTS_DONE field. */ - -/* Register: CLOCK_EVENTS_CTTO */ -/* Description: Calibration timer timeout */ - -/* Bit 0 : */ -#define CLOCK_EVENTS_CTTO_EVENTS_CTTO_Pos (0UL) /*!< Position of EVENTS_CTTO field. */ -#define CLOCK_EVENTS_CTTO_EVENTS_CTTO_Msk (0x1UL << CLOCK_EVENTS_CTTO_EVENTS_CTTO_Pos) /*!< Bit mask of EVENTS_CTTO field. */ - -/* Register: CLOCK_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 4 : Write '1' to Enable interrupt for CTTO event */ -#define CLOCK_INTENSET_CTTO_Pos (4UL) /*!< Position of CTTO field. */ -#define CLOCK_INTENSET_CTTO_Msk (0x1UL << CLOCK_INTENSET_CTTO_Pos) /*!< Bit mask of CTTO field. */ -#define CLOCK_INTENSET_CTTO_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_CTTO_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_CTTO_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for DONE event */ -#define CLOCK_INTENSET_DONE_Pos (3UL) /*!< Position of DONE field. */ -#define CLOCK_INTENSET_DONE_Msk (0x1UL << CLOCK_INTENSET_DONE_Pos) /*!< Bit mask of DONE field. */ -#define CLOCK_INTENSET_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_DONE_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for LFCLKSTARTED event */ -#define CLOCK_INTENSET_LFCLKSTARTED_Pos (1UL) /*!< Position of LFCLKSTARTED field. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Msk (0x1UL << CLOCK_INTENSET_LFCLKSTARTED_Pos) /*!< Bit mask of LFCLKSTARTED field. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_LFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_LFCLKSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for HFCLKSTARTED event */ -#define CLOCK_INTENSET_HFCLKSTARTED_Pos (0UL) /*!< Position of HFCLKSTARTED field. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Msk (0x1UL << CLOCK_INTENSET_HFCLKSTARTED_Pos) /*!< Bit mask of HFCLKSTARTED field. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_HFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_HFCLKSTARTED_Set (1UL) /*!< Enable */ - -/* Register: CLOCK_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 4 : Write '1' to Disable interrupt for CTTO event */ -#define CLOCK_INTENCLR_CTTO_Pos (4UL) /*!< Position of CTTO field. */ -#define CLOCK_INTENCLR_CTTO_Msk (0x1UL << CLOCK_INTENCLR_CTTO_Pos) /*!< Bit mask of CTTO field. */ -#define CLOCK_INTENCLR_CTTO_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_CTTO_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_CTTO_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for DONE event */ -#define CLOCK_INTENCLR_DONE_Pos (3UL) /*!< Position of DONE field. */ -#define CLOCK_INTENCLR_DONE_Msk (0x1UL << CLOCK_INTENCLR_DONE_Pos) /*!< Bit mask of DONE field. */ -#define CLOCK_INTENCLR_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_DONE_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for LFCLKSTARTED event */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Pos (1UL) /*!< Position of LFCLKSTARTED field. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Msk (0x1UL << CLOCK_INTENCLR_LFCLKSTARTED_Pos) /*!< Bit mask of LFCLKSTARTED field. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for HFCLKSTARTED event */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Pos (0UL) /*!< Position of HFCLKSTARTED field. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Msk (0x1UL << CLOCK_INTENCLR_HFCLKSTARTED_Pos) /*!< Bit mask of HFCLKSTARTED field. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Clear (1UL) /*!< Disable */ - -/* Register: CLOCK_HFCLKRUN */ -/* Description: Status indicating that HFCLKSTART task has been triggered */ - -/* Bit 0 : HFCLKSTART task triggered or not */ -#define CLOCK_HFCLKRUN_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define CLOCK_HFCLKRUN_STATUS_Msk (0x1UL << CLOCK_HFCLKRUN_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_HFCLKRUN_STATUS_NotTriggered (0UL) /*!< Task not triggered */ -#define CLOCK_HFCLKRUN_STATUS_Triggered (1UL) /*!< Task triggered */ - -/* Register: CLOCK_HFCLKSTAT */ -/* Description: HFCLK status */ - -/* Bit 16 : HFCLK state */ -#define CLOCK_HFCLKSTAT_STATE_Pos (16UL) /*!< Position of STATE field. */ -#define CLOCK_HFCLKSTAT_STATE_Msk (0x1UL << CLOCK_HFCLKSTAT_STATE_Pos) /*!< Bit mask of STATE field. */ -#define CLOCK_HFCLKSTAT_STATE_NotRunning (0UL) /*!< HFCLK not running */ -#define CLOCK_HFCLKSTAT_STATE_Running (1UL) /*!< HFCLK running */ - -/* Bit 0 : Source of HFCLK */ -#define CLOCK_HFCLKSTAT_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_HFCLKSTAT_SRC_Msk (0x1UL << CLOCK_HFCLKSTAT_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_HFCLKSTAT_SRC_RC (0UL) /*!< 64 MHz internal oscillator (HFINT) */ -#define CLOCK_HFCLKSTAT_SRC_Xtal (1UL) /*!< 64 MHz crystal oscillator (HFXO) */ - -/* Register: CLOCK_LFCLKRUN */ -/* Description: Status indicating that LFCLKSTART task has been triggered */ - -/* Bit 0 : LFCLKSTART task triggered or not */ -#define CLOCK_LFCLKRUN_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define CLOCK_LFCLKRUN_STATUS_Msk (0x1UL << CLOCK_LFCLKRUN_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_LFCLKRUN_STATUS_NotTriggered (0UL) /*!< Task not triggered */ -#define CLOCK_LFCLKRUN_STATUS_Triggered (1UL) /*!< Task triggered */ - -/* Register: CLOCK_LFCLKSTAT */ -/* Description: LFCLK status */ - -/* Bit 16 : LFCLK state */ -#define CLOCK_LFCLKSTAT_STATE_Pos (16UL) /*!< Position of STATE field. */ -#define CLOCK_LFCLKSTAT_STATE_Msk (0x1UL << CLOCK_LFCLKSTAT_STATE_Pos) /*!< Bit mask of STATE field. */ -#define CLOCK_LFCLKSTAT_STATE_NotRunning (0UL) /*!< LFCLK not running */ -#define CLOCK_LFCLKSTAT_STATE_Running (1UL) /*!< LFCLK running */ - -/* Bits 1..0 : Source of LFCLK */ -#define CLOCK_LFCLKSTAT_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSTAT_SRC_Msk (0x3UL << CLOCK_LFCLKSTAT_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSTAT_SRC_RC (0UL) /*!< 32.768 kHz RC oscillator */ -#define CLOCK_LFCLKSTAT_SRC_Xtal (1UL) /*!< 32.768 kHz crystal oscillator */ -#define CLOCK_LFCLKSTAT_SRC_Synth (2UL) /*!< 32.768 kHz synthesized from HFCLK */ - -/* Register: CLOCK_LFCLKSRCCOPY */ -/* Description: Copy of LFCLKSRC register, set when LFCLKSTART task was triggered */ - -/* Bits 1..0 : Clock source */ -#define CLOCK_LFCLKSRCCOPY_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSRCCOPY_SRC_Msk (0x3UL << CLOCK_LFCLKSRCCOPY_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSRCCOPY_SRC_RC (0UL) /*!< 32.768 kHz RC oscillator */ -#define CLOCK_LFCLKSRCCOPY_SRC_Xtal (1UL) /*!< 32.768 kHz crystal oscillator */ -#define CLOCK_LFCLKSRCCOPY_SRC_Synth (2UL) /*!< 32.768 kHz synthesized from HFCLK */ - -/* Register: CLOCK_LFCLKSRC */ -/* Description: Clock source for the LFCLK */ - -/* Bit 17 : Enable or disable external source for LFCLK */ -#define CLOCK_LFCLKSRC_EXTERNAL_Pos (17UL) /*!< Position of EXTERNAL field. */ -#define CLOCK_LFCLKSRC_EXTERNAL_Msk (0x1UL << CLOCK_LFCLKSRC_EXTERNAL_Pos) /*!< Bit mask of EXTERNAL field. */ -#define CLOCK_LFCLKSRC_EXTERNAL_Disabled (0UL) /*!< Disable external source (use with Xtal) */ -#define CLOCK_LFCLKSRC_EXTERNAL_Enabled (1UL) /*!< Enable use of external source instead of Xtal (SRC needs to be set to Xtal) */ - -/* Bit 16 : Enable or disable bypass of LFCLK crystal oscillator with external clock source */ -#define CLOCK_LFCLKSRC_BYPASS_Pos (16UL) /*!< Position of BYPASS field. */ -#define CLOCK_LFCLKSRC_BYPASS_Msk (0x1UL << CLOCK_LFCLKSRC_BYPASS_Pos) /*!< Bit mask of BYPASS field. */ -#define CLOCK_LFCLKSRC_BYPASS_Disabled (0UL) /*!< Disable (use with Xtal or low-swing external source) */ -#define CLOCK_LFCLKSRC_BYPASS_Enabled (1UL) /*!< Enable (use with rail-to-rail external source) */ - -/* Bits 1..0 : Clock source */ -#define CLOCK_LFCLKSRC_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSRC_SRC_Msk (0x3UL << CLOCK_LFCLKSRC_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSRC_SRC_RC (0UL) /*!< 32.768 kHz RC oscillator */ -#define CLOCK_LFCLKSRC_SRC_Xtal (1UL) /*!< 32.768 kHz crystal oscillator */ -#define CLOCK_LFCLKSRC_SRC_Synth (2UL) /*!< 32.768 kHz synthesized from HFCLK */ - -/* Register: CLOCK_CTIV */ -/* Description: Calibration timer interval */ - -/* Bits 6..0 : Calibration timer interval in multiple of 0.25 seconds. Range: 0.25 seconds to 31.75 seconds. */ -#define CLOCK_CTIV_CTIV_Pos (0UL) /*!< Position of CTIV field. */ -#define CLOCK_CTIV_CTIV_Msk (0x7FUL << CLOCK_CTIV_CTIV_Pos) /*!< Bit mask of CTIV field. */ - - -/* Peripheral: COMP */ -/* Description: Comparator */ - -/* Register: COMP_TASKS_START */ -/* Description: Start comparator */ - -/* Bit 0 : */ -#define COMP_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define COMP_TASKS_START_TASKS_START_Msk (0x1UL << COMP_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: COMP_TASKS_STOP */ -/* Description: Stop comparator */ - -/* Bit 0 : */ -#define COMP_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define COMP_TASKS_STOP_TASKS_STOP_Msk (0x1UL << COMP_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: COMP_TASKS_SAMPLE */ -/* Description: Sample comparator value */ - -/* Bit 0 : */ -#define COMP_TASKS_SAMPLE_TASKS_SAMPLE_Pos (0UL) /*!< Position of TASKS_SAMPLE field. */ -#define COMP_TASKS_SAMPLE_TASKS_SAMPLE_Msk (0x1UL << COMP_TASKS_SAMPLE_TASKS_SAMPLE_Pos) /*!< Bit mask of TASKS_SAMPLE field. */ - -/* Register: COMP_EVENTS_READY */ -/* Description: COMP is ready and output is valid */ - -/* Bit 0 : */ -#define COMP_EVENTS_READY_EVENTS_READY_Pos (0UL) /*!< Position of EVENTS_READY field. */ -#define COMP_EVENTS_READY_EVENTS_READY_Msk (0x1UL << COMP_EVENTS_READY_EVENTS_READY_Pos) /*!< Bit mask of EVENTS_READY field. */ - -/* Register: COMP_EVENTS_DOWN */ -/* Description: Downward crossing */ - -/* Bit 0 : */ -#define COMP_EVENTS_DOWN_EVENTS_DOWN_Pos (0UL) /*!< Position of EVENTS_DOWN field. */ -#define COMP_EVENTS_DOWN_EVENTS_DOWN_Msk (0x1UL << COMP_EVENTS_DOWN_EVENTS_DOWN_Pos) /*!< Bit mask of EVENTS_DOWN field. */ - -/* Register: COMP_EVENTS_UP */ -/* Description: Upward crossing */ - -/* Bit 0 : */ -#define COMP_EVENTS_UP_EVENTS_UP_Pos (0UL) /*!< Position of EVENTS_UP field. */ -#define COMP_EVENTS_UP_EVENTS_UP_Msk (0x1UL << COMP_EVENTS_UP_EVENTS_UP_Pos) /*!< Bit mask of EVENTS_UP field. */ - -/* Register: COMP_EVENTS_CROSS */ -/* Description: Downward or upward crossing */ - -/* Bit 0 : */ -#define COMP_EVENTS_CROSS_EVENTS_CROSS_Pos (0UL) /*!< Position of EVENTS_CROSS field. */ -#define COMP_EVENTS_CROSS_EVENTS_CROSS_Msk (0x1UL << COMP_EVENTS_CROSS_EVENTS_CROSS_Pos) /*!< Bit mask of EVENTS_CROSS field. */ - -/* Register: COMP_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between CROSS event and STOP task */ -#define COMP_SHORTS_CROSS_STOP_Pos (4UL) /*!< Position of CROSS_STOP field. */ -#define COMP_SHORTS_CROSS_STOP_Msk (0x1UL << COMP_SHORTS_CROSS_STOP_Pos) /*!< Bit mask of CROSS_STOP field. */ -#define COMP_SHORTS_CROSS_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_CROSS_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between UP event and STOP task */ -#define COMP_SHORTS_UP_STOP_Pos (3UL) /*!< Position of UP_STOP field. */ -#define COMP_SHORTS_UP_STOP_Msk (0x1UL << COMP_SHORTS_UP_STOP_Pos) /*!< Bit mask of UP_STOP field. */ -#define COMP_SHORTS_UP_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_UP_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between DOWN event and STOP task */ -#define COMP_SHORTS_DOWN_STOP_Pos (2UL) /*!< Position of DOWN_STOP field. */ -#define COMP_SHORTS_DOWN_STOP_Msk (0x1UL << COMP_SHORTS_DOWN_STOP_Pos) /*!< Bit mask of DOWN_STOP field. */ -#define COMP_SHORTS_DOWN_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_DOWN_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between READY event and STOP task */ -#define COMP_SHORTS_READY_STOP_Pos (1UL) /*!< Position of READY_STOP field. */ -#define COMP_SHORTS_READY_STOP_Msk (0x1UL << COMP_SHORTS_READY_STOP_Pos) /*!< Bit mask of READY_STOP field. */ -#define COMP_SHORTS_READY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_READY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between READY event and SAMPLE task */ -#define COMP_SHORTS_READY_SAMPLE_Pos (0UL) /*!< Position of READY_SAMPLE field. */ -#define COMP_SHORTS_READY_SAMPLE_Msk (0x1UL << COMP_SHORTS_READY_SAMPLE_Pos) /*!< Bit mask of READY_SAMPLE field. */ -#define COMP_SHORTS_READY_SAMPLE_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_READY_SAMPLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: COMP_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 3 : Enable or disable interrupt for CROSS event */ -#define COMP_INTEN_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define COMP_INTEN_CROSS_Msk (0x1UL << COMP_INTEN_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define COMP_INTEN_CROSS_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_CROSS_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for UP event */ -#define COMP_INTEN_UP_Pos (2UL) /*!< Position of UP field. */ -#define COMP_INTEN_UP_Msk (0x1UL << COMP_INTEN_UP_Pos) /*!< Bit mask of UP field. */ -#define COMP_INTEN_UP_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_UP_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for DOWN event */ -#define COMP_INTEN_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define COMP_INTEN_DOWN_Msk (0x1UL << COMP_INTEN_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define COMP_INTEN_DOWN_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_DOWN_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for READY event */ -#define COMP_INTEN_READY_Pos (0UL) /*!< Position of READY field. */ -#define COMP_INTEN_READY_Msk (0x1UL << COMP_INTEN_READY_Pos) /*!< Bit mask of READY field. */ -#define COMP_INTEN_READY_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_READY_Enabled (1UL) /*!< Enable */ - -/* Register: COMP_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 3 : Write '1' to Enable interrupt for CROSS event */ -#define COMP_INTENSET_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define COMP_INTENSET_CROSS_Msk (0x1UL << COMP_INTENSET_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define COMP_INTENSET_CROSS_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_CROSS_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_CROSS_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for UP event */ -#define COMP_INTENSET_UP_Pos (2UL) /*!< Position of UP field. */ -#define COMP_INTENSET_UP_Msk (0x1UL << COMP_INTENSET_UP_Pos) /*!< Bit mask of UP field. */ -#define COMP_INTENSET_UP_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_UP_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_UP_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for DOWN event */ -#define COMP_INTENSET_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define COMP_INTENSET_DOWN_Msk (0x1UL << COMP_INTENSET_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define COMP_INTENSET_DOWN_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_DOWN_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_DOWN_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define COMP_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define COMP_INTENSET_READY_Msk (0x1UL << COMP_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define COMP_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: COMP_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 3 : Write '1' to Disable interrupt for CROSS event */ -#define COMP_INTENCLR_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define COMP_INTENCLR_CROSS_Msk (0x1UL << COMP_INTENCLR_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define COMP_INTENCLR_CROSS_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_CROSS_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_CROSS_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for UP event */ -#define COMP_INTENCLR_UP_Pos (2UL) /*!< Position of UP field. */ -#define COMP_INTENCLR_UP_Msk (0x1UL << COMP_INTENCLR_UP_Pos) /*!< Bit mask of UP field. */ -#define COMP_INTENCLR_UP_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_UP_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_UP_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for DOWN event */ -#define COMP_INTENCLR_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define COMP_INTENCLR_DOWN_Msk (0x1UL << COMP_INTENCLR_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define COMP_INTENCLR_DOWN_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_DOWN_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_DOWN_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define COMP_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define COMP_INTENCLR_READY_Msk (0x1UL << COMP_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define COMP_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: COMP_RESULT */ -/* Description: Compare result */ - -/* Bit 0 : Result of last compare. Decision point SAMPLE task. */ -#define COMP_RESULT_RESULT_Pos (0UL) /*!< Position of RESULT field. */ -#define COMP_RESULT_RESULT_Msk (0x1UL << COMP_RESULT_RESULT_Pos) /*!< Bit mask of RESULT field. */ -#define COMP_RESULT_RESULT_Below (0UL) /*!< Input voltage is below the threshold (VIN+ < VIN-) */ -#define COMP_RESULT_RESULT_Above (1UL) /*!< Input voltage is above the threshold (VIN+ > VIN-) */ - -/* Register: COMP_ENABLE */ -/* Description: COMP enable */ - -/* Bits 1..0 : Enable or disable COMP */ -#define COMP_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define COMP_ENABLE_ENABLE_Msk (0x3UL << COMP_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define COMP_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define COMP_ENABLE_ENABLE_Enabled (2UL) /*!< Enable */ - -/* Register: COMP_PSEL */ -/* Description: Pin select */ - -/* Bits 2..0 : Analog pin select */ -#define COMP_PSEL_PSEL_Pos (0UL) /*!< Position of PSEL field. */ -#define COMP_PSEL_PSEL_Msk (0x7UL << COMP_PSEL_PSEL_Pos) /*!< Bit mask of PSEL field. */ -#define COMP_PSEL_PSEL_AnalogInput0 (0UL) /*!< AIN0 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput1 (1UL) /*!< AIN1 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput2 (2UL) /*!< AIN2 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput3 (3UL) /*!< AIN3 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput4 (4UL) /*!< AIN4 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput5 (5UL) /*!< AIN5 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput6 (6UL) /*!< AIN6 selected as analog input */ -#define COMP_PSEL_PSEL_VddDiv2 (7UL) /*!< VDD/2 selected as analog input */ - -/* Register: COMP_REFSEL */ -/* Description: Reference source select for single-ended mode */ - -/* Bits 2..0 : Reference select */ -#define COMP_REFSEL_REFSEL_Pos (0UL) /*!< Position of REFSEL field. */ -#define COMP_REFSEL_REFSEL_Msk (0x7UL << COMP_REFSEL_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define COMP_REFSEL_REFSEL_Int1V2 (0UL) /*!< VREF = internal 1.2 V reference (VDD >= 1.7 V) */ -#define COMP_REFSEL_REFSEL_Int1V8 (1UL) /*!< VREF = internal 1.8 V reference (VDD >= VREF + 0.2 V) */ -#define COMP_REFSEL_REFSEL_Int2V4 (2UL) /*!< VREF = internal 2.4 V reference (VDD >= VREF + 0.2 V) */ -#define COMP_REFSEL_REFSEL_VDD (4UL) /*!< VREF = VDD */ -#define COMP_REFSEL_REFSEL_ARef (5UL) /*!< VREF = AREF (VDD >= VREF >= AREFMIN) */ - -/* Register: COMP_EXTREFSEL */ -/* Description: External reference select */ - -/* Bits 2..0 : External analog reference select */ -#define COMP_EXTREFSEL_EXTREFSEL_Pos (0UL) /*!< Position of EXTREFSEL field. */ -#define COMP_EXTREFSEL_EXTREFSEL_Msk (0x7UL << COMP_EXTREFSEL_EXTREFSEL_Pos) /*!< Bit mask of EXTREFSEL field. */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference0 (0UL) /*!< Use AIN0 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference1 (1UL) /*!< Use AIN1 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference2 (2UL) /*!< Use AIN2 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference3 (3UL) /*!< Use AIN3 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference4 (4UL) /*!< Use AIN4 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference5 (5UL) /*!< Use AIN5 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference6 (6UL) /*!< Use AIN6 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference7 (7UL) /*!< Use AIN7 as external analog reference */ - -/* Register: COMP_TH */ -/* Description: Threshold configuration for hysteresis unit */ - -/* Bits 13..8 : VUP = (THUP+1)/64*VREF */ -#define COMP_TH_THUP_Pos (8UL) /*!< Position of THUP field. */ -#define COMP_TH_THUP_Msk (0x3FUL << COMP_TH_THUP_Pos) /*!< Bit mask of THUP field. */ - -/* Bits 5..0 : VDOWN = (THDOWN+1)/64*VREF */ -#define COMP_TH_THDOWN_Pos (0UL) /*!< Position of THDOWN field. */ -#define COMP_TH_THDOWN_Msk (0x3FUL << COMP_TH_THDOWN_Pos) /*!< Bit mask of THDOWN field. */ - -/* Register: COMP_MODE */ -/* Description: Mode configuration */ - -/* Bit 8 : Main operation modes */ -#define COMP_MODE_MAIN_Pos (8UL) /*!< Position of MAIN field. */ -#define COMP_MODE_MAIN_Msk (0x1UL << COMP_MODE_MAIN_Pos) /*!< Bit mask of MAIN field. */ -#define COMP_MODE_MAIN_SE (0UL) /*!< Single-ended mode */ -#define COMP_MODE_MAIN_Diff (1UL) /*!< Differential mode */ - -/* Bits 1..0 : Speed and power modes */ -#define COMP_MODE_SP_Pos (0UL) /*!< Position of SP field. */ -#define COMP_MODE_SP_Msk (0x3UL << COMP_MODE_SP_Pos) /*!< Bit mask of SP field. */ -#define COMP_MODE_SP_Low (0UL) /*!< Low-power mode */ -#define COMP_MODE_SP_Normal (1UL) /*!< Normal mode */ -#define COMP_MODE_SP_High (2UL) /*!< High-speed mode */ - -/* Register: COMP_HYST */ -/* Description: Comparator hysteresis enable */ - -/* Bit 0 : Comparator hysteresis */ -#define COMP_HYST_HYST_Pos (0UL) /*!< Position of HYST field. */ -#define COMP_HYST_HYST_Msk (0x1UL << COMP_HYST_HYST_Pos) /*!< Bit mask of HYST field. */ -#define COMP_HYST_HYST_NoHyst (0UL) /*!< Comparator hysteresis disabled */ -#define COMP_HYST_HYST_Hyst50mV (1UL) /*!< Comparator hysteresis enabled */ - - -/* Peripheral: ECB */ -/* Description: AES ECB Mode Encryption */ - -/* Register: ECB_TASKS_STARTECB */ -/* Description: Start ECB block encrypt */ - -/* Bit 0 : */ -#define ECB_TASKS_STARTECB_TASKS_STARTECB_Pos (0UL) /*!< Position of TASKS_STARTECB field. */ -#define ECB_TASKS_STARTECB_TASKS_STARTECB_Msk (0x1UL << ECB_TASKS_STARTECB_TASKS_STARTECB_Pos) /*!< Bit mask of TASKS_STARTECB field. */ - -/* Register: ECB_TASKS_STOPECB */ -/* Description: Abort a possible executing ECB operation */ - -/* Bit 0 : */ -#define ECB_TASKS_STOPECB_TASKS_STOPECB_Pos (0UL) /*!< Position of TASKS_STOPECB field. */ -#define ECB_TASKS_STOPECB_TASKS_STOPECB_Msk (0x1UL << ECB_TASKS_STOPECB_TASKS_STOPECB_Pos) /*!< Bit mask of TASKS_STOPECB field. */ - -/* Register: ECB_EVENTS_ENDECB */ -/* Description: ECB block encrypt complete */ - -/* Bit 0 : */ -#define ECB_EVENTS_ENDECB_EVENTS_ENDECB_Pos (0UL) /*!< Position of EVENTS_ENDECB field. */ -#define ECB_EVENTS_ENDECB_EVENTS_ENDECB_Msk (0x1UL << ECB_EVENTS_ENDECB_EVENTS_ENDECB_Pos) /*!< Bit mask of EVENTS_ENDECB field. */ - -/* Register: ECB_EVENTS_ERRORECB */ -/* Description: ECB block encrypt aborted because of a STOPECB task or due to an error */ - -/* Bit 0 : */ -#define ECB_EVENTS_ERRORECB_EVENTS_ERRORECB_Pos (0UL) /*!< Position of EVENTS_ERRORECB field. */ -#define ECB_EVENTS_ERRORECB_EVENTS_ERRORECB_Msk (0x1UL << ECB_EVENTS_ERRORECB_EVENTS_ERRORECB_Pos) /*!< Bit mask of EVENTS_ERRORECB field. */ - -/* Register: ECB_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 1 : Write '1' to Enable interrupt for ERRORECB event */ -#define ECB_INTENSET_ERRORECB_Pos (1UL) /*!< Position of ERRORECB field. */ -#define ECB_INTENSET_ERRORECB_Msk (0x1UL << ECB_INTENSET_ERRORECB_Pos) /*!< Bit mask of ERRORECB field. */ -#define ECB_INTENSET_ERRORECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENSET_ERRORECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENSET_ERRORECB_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for ENDECB event */ -#define ECB_INTENSET_ENDECB_Pos (0UL) /*!< Position of ENDECB field. */ -#define ECB_INTENSET_ENDECB_Msk (0x1UL << ECB_INTENSET_ENDECB_Pos) /*!< Bit mask of ENDECB field. */ -#define ECB_INTENSET_ENDECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENSET_ENDECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENSET_ENDECB_Set (1UL) /*!< Enable */ - -/* Register: ECB_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 1 : Write '1' to Disable interrupt for ERRORECB event */ -#define ECB_INTENCLR_ERRORECB_Pos (1UL) /*!< Position of ERRORECB field. */ -#define ECB_INTENCLR_ERRORECB_Msk (0x1UL << ECB_INTENCLR_ERRORECB_Pos) /*!< Bit mask of ERRORECB field. */ -#define ECB_INTENCLR_ERRORECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENCLR_ERRORECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENCLR_ERRORECB_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for ENDECB event */ -#define ECB_INTENCLR_ENDECB_Pos (0UL) /*!< Position of ENDECB field. */ -#define ECB_INTENCLR_ENDECB_Msk (0x1UL << ECB_INTENCLR_ENDECB_Pos) /*!< Bit mask of ENDECB field. */ -#define ECB_INTENCLR_ENDECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENCLR_ENDECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENCLR_ENDECB_Clear (1UL) /*!< Disable */ - -/* Register: ECB_ECBDATAPTR */ -/* Description: ECB block encrypt memory pointers */ - -/* Bits 31..0 : Pointer to the ECB data structure (see Table 1 ECB data structure overview) */ -#define ECB_ECBDATAPTR_ECBDATAPTR_Pos (0UL) /*!< Position of ECBDATAPTR field. */ -#define ECB_ECBDATAPTR_ECBDATAPTR_Msk (0xFFFFFFFFUL << ECB_ECBDATAPTR_ECBDATAPTR_Pos) /*!< Bit mask of ECBDATAPTR field. */ - - -/* Peripheral: EGU */ -/* Description: Event Generator Unit 0 */ - -/* Register: EGU_TASKS_TRIGGER */ -/* Description: Description collection[0]: Trigger 0 for triggering the corresponding TRIGGERED[0] event */ - -/* Bit 0 : */ -#define EGU_TASKS_TRIGGER_TASKS_TRIGGER_Pos (0UL) /*!< Position of TASKS_TRIGGER field. */ -#define EGU_TASKS_TRIGGER_TASKS_TRIGGER_Msk (0x1UL << EGU_TASKS_TRIGGER_TASKS_TRIGGER_Pos) /*!< Bit mask of TASKS_TRIGGER field. */ - -/* Register: EGU_EVENTS_TRIGGERED */ -/* Description: Description collection[0]: Event number 0 generated by triggering the corresponding TRIGGER[0] task */ - -/* Bit 0 : */ -#define EGU_EVENTS_TRIGGERED_EVENTS_TRIGGERED_Pos (0UL) /*!< Position of EVENTS_TRIGGERED field. */ -#define EGU_EVENTS_TRIGGERED_EVENTS_TRIGGERED_Msk (0x1UL << EGU_EVENTS_TRIGGERED_EVENTS_TRIGGERED_Pos) /*!< Bit mask of EVENTS_TRIGGERED field. */ - -/* Register: EGU_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 15 : Enable or disable interrupt for TRIGGERED[15] event */ -#define EGU_INTEN_TRIGGERED15_Pos (15UL) /*!< Position of TRIGGERED15 field. */ -#define EGU_INTEN_TRIGGERED15_Msk (0x1UL << EGU_INTEN_TRIGGERED15_Pos) /*!< Bit mask of TRIGGERED15 field. */ -#define EGU_INTEN_TRIGGERED15_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED15_Enabled (1UL) /*!< Enable */ - -/* Bit 14 : Enable or disable interrupt for TRIGGERED[14] event */ -#define EGU_INTEN_TRIGGERED14_Pos (14UL) /*!< Position of TRIGGERED14 field. */ -#define EGU_INTEN_TRIGGERED14_Msk (0x1UL << EGU_INTEN_TRIGGERED14_Pos) /*!< Bit mask of TRIGGERED14 field. */ -#define EGU_INTEN_TRIGGERED14_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED14_Enabled (1UL) /*!< Enable */ - -/* Bit 13 : Enable or disable interrupt for TRIGGERED[13] event */ -#define EGU_INTEN_TRIGGERED13_Pos (13UL) /*!< Position of TRIGGERED13 field. */ -#define EGU_INTEN_TRIGGERED13_Msk (0x1UL << EGU_INTEN_TRIGGERED13_Pos) /*!< Bit mask of TRIGGERED13 field. */ -#define EGU_INTEN_TRIGGERED13_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED13_Enabled (1UL) /*!< Enable */ - -/* Bit 12 : Enable or disable interrupt for TRIGGERED[12] event */ -#define EGU_INTEN_TRIGGERED12_Pos (12UL) /*!< Position of TRIGGERED12 field. */ -#define EGU_INTEN_TRIGGERED12_Msk (0x1UL << EGU_INTEN_TRIGGERED12_Pos) /*!< Bit mask of TRIGGERED12 field. */ -#define EGU_INTEN_TRIGGERED12_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED12_Enabled (1UL) /*!< Enable */ - -/* Bit 11 : Enable or disable interrupt for TRIGGERED[11] event */ -#define EGU_INTEN_TRIGGERED11_Pos (11UL) /*!< Position of TRIGGERED11 field. */ -#define EGU_INTEN_TRIGGERED11_Msk (0x1UL << EGU_INTEN_TRIGGERED11_Pos) /*!< Bit mask of TRIGGERED11 field. */ -#define EGU_INTEN_TRIGGERED11_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED11_Enabled (1UL) /*!< Enable */ - -/* Bit 10 : Enable or disable interrupt for TRIGGERED[10] event */ -#define EGU_INTEN_TRIGGERED10_Pos (10UL) /*!< Position of TRIGGERED10 field. */ -#define EGU_INTEN_TRIGGERED10_Msk (0x1UL << EGU_INTEN_TRIGGERED10_Pos) /*!< Bit mask of TRIGGERED10 field. */ -#define EGU_INTEN_TRIGGERED10_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED10_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for TRIGGERED[9] event */ -#define EGU_INTEN_TRIGGERED9_Pos (9UL) /*!< Position of TRIGGERED9 field. */ -#define EGU_INTEN_TRIGGERED9_Msk (0x1UL << EGU_INTEN_TRIGGERED9_Pos) /*!< Bit mask of TRIGGERED9 field. */ -#define EGU_INTEN_TRIGGERED9_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED9_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for TRIGGERED[8] event */ -#define EGU_INTEN_TRIGGERED8_Pos (8UL) /*!< Position of TRIGGERED8 field. */ -#define EGU_INTEN_TRIGGERED8_Msk (0x1UL << EGU_INTEN_TRIGGERED8_Pos) /*!< Bit mask of TRIGGERED8 field. */ -#define EGU_INTEN_TRIGGERED8_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED8_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for TRIGGERED[7] event */ -#define EGU_INTEN_TRIGGERED7_Pos (7UL) /*!< Position of TRIGGERED7 field. */ -#define EGU_INTEN_TRIGGERED7_Msk (0x1UL << EGU_INTEN_TRIGGERED7_Pos) /*!< Bit mask of TRIGGERED7 field. */ -#define EGU_INTEN_TRIGGERED7_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED7_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for TRIGGERED[6] event */ -#define EGU_INTEN_TRIGGERED6_Pos (6UL) /*!< Position of TRIGGERED6 field. */ -#define EGU_INTEN_TRIGGERED6_Msk (0x1UL << EGU_INTEN_TRIGGERED6_Pos) /*!< Bit mask of TRIGGERED6 field. */ -#define EGU_INTEN_TRIGGERED6_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED6_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for TRIGGERED[5] event */ -#define EGU_INTEN_TRIGGERED5_Pos (5UL) /*!< Position of TRIGGERED5 field. */ -#define EGU_INTEN_TRIGGERED5_Msk (0x1UL << EGU_INTEN_TRIGGERED5_Pos) /*!< Bit mask of TRIGGERED5 field. */ -#define EGU_INTEN_TRIGGERED5_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED5_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for TRIGGERED[4] event */ -#define EGU_INTEN_TRIGGERED4_Pos (4UL) /*!< Position of TRIGGERED4 field. */ -#define EGU_INTEN_TRIGGERED4_Msk (0x1UL << EGU_INTEN_TRIGGERED4_Pos) /*!< Bit mask of TRIGGERED4 field. */ -#define EGU_INTEN_TRIGGERED4_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED4_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for TRIGGERED[3] event */ -#define EGU_INTEN_TRIGGERED3_Pos (3UL) /*!< Position of TRIGGERED3 field. */ -#define EGU_INTEN_TRIGGERED3_Msk (0x1UL << EGU_INTEN_TRIGGERED3_Pos) /*!< Bit mask of TRIGGERED3 field. */ -#define EGU_INTEN_TRIGGERED3_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED3_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for TRIGGERED[2] event */ -#define EGU_INTEN_TRIGGERED2_Pos (2UL) /*!< Position of TRIGGERED2 field. */ -#define EGU_INTEN_TRIGGERED2_Msk (0x1UL << EGU_INTEN_TRIGGERED2_Pos) /*!< Bit mask of TRIGGERED2 field. */ -#define EGU_INTEN_TRIGGERED2_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED2_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for TRIGGERED[1] event */ -#define EGU_INTEN_TRIGGERED1_Pos (1UL) /*!< Position of TRIGGERED1 field. */ -#define EGU_INTEN_TRIGGERED1_Msk (0x1UL << EGU_INTEN_TRIGGERED1_Pos) /*!< Bit mask of TRIGGERED1 field. */ -#define EGU_INTEN_TRIGGERED1_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED1_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for TRIGGERED[0] event */ -#define EGU_INTEN_TRIGGERED0_Pos (0UL) /*!< Position of TRIGGERED0 field. */ -#define EGU_INTEN_TRIGGERED0_Msk (0x1UL << EGU_INTEN_TRIGGERED0_Pos) /*!< Bit mask of TRIGGERED0 field. */ -#define EGU_INTEN_TRIGGERED0_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED0_Enabled (1UL) /*!< Enable */ - -/* Register: EGU_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 15 : Write '1' to Enable interrupt for TRIGGERED[15] event */ -#define EGU_INTENSET_TRIGGERED15_Pos (15UL) /*!< Position of TRIGGERED15 field. */ -#define EGU_INTENSET_TRIGGERED15_Msk (0x1UL << EGU_INTENSET_TRIGGERED15_Pos) /*!< Bit mask of TRIGGERED15 field. */ -#define EGU_INTENSET_TRIGGERED15_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED15_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED15_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for TRIGGERED[14] event */ -#define EGU_INTENSET_TRIGGERED14_Pos (14UL) /*!< Position of TRIGGERED14 field. */ -#define EGU_INTENSET_TRIGGERED14_Msk (0x1UL << EGU_INTENSET_TRIGGERED14_Pos) /*!< Bit mask of TRIGGERED14 field. */ -#define EGU_INTENSET_TRIGGERED14_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED14_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED14_Set (1UL) /*!< Enable */ - -/* Bit 13 : Write '1' to Enable interrupt for TRIGGERED[13] event */ -#define EGU_INTENSET_TRIGGERED13_Pos (13UL) /*!< Position of TRIGGERED13 field. */ -#define EGU_INTENSET_TRIGGERED13_Msk (0x1UL << EGU_INTENSET_TRIGGERED13_Pos) /*!< Bit mask of TRIGGERED13 field. */ -#define EGU_INTENSET_TRIGGERED13_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED13_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED13_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for TRIGGERED[12] event */ -#define EGU_INTENSET_TRIGGERED12_Pos (12UL) /*!< Position of TRIGGERED12 field. */ -#define EGU_INTENSET_TRIGGERED12_Msk (0x1UL << EGU_INTENSET_TRIGGERED12_Pos) /*!< Bit mask of TRIGGERED12 field. */ -#define EGU_INTENSET_TRIGGERED12_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED12_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED12_Set (1UL) /*!< Enable */ - -/* Bit 11 : Write '1' to Enable interrupt for TRIGGERED[11] event */ -#define EGU_INTENSET_TRIGGERED11_Pos (11UL) /*!< Position of TRIGGERED11 field. */ -#define EGU_INTENSET_TRIGGERED11_Msk (0x1UL << EGU_INTENSET_TRIGGERED11_Pos) /*!< Bit mask of TRIGGERED11 field. */ -#define EGU_INTENSET_TRIGGERED11_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED11_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED11_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for TRIGGERED[10] event */ -#define EGU_INTENSET_TRIGGERED10_Pos (10UL) /*!< Position of TRIGGERED10 field. */ -#define EGU_INTENSET_TRIGGERED10_Msk (0x1UL << EGU_INTENSET_TRIGGERED10_Pos) /*!< Bit mask of TRIGGERED10 field. */ -#define EGU_INTENSET_TRIGGERED10_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED10_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED10_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for TRIGGERED[9] event */ -#define EGU_INTENSET_TRIGGERED9_Pos (9UL) /*!< Position of TRIGGERED9 field. */ -#define EGU_INTENSET_TRIGGERED9_Msk (0x1UL << EGU_INTENSET_TRIGGERED9_Pos) /*!< Bit mask of TRIGGERED9 field. */ -#define EGU_INTENSET_TRIGGERED9_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED9_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED9_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for TRIGGERED[8] event */ -#define EGU_INTENSET_TRIGGERED8_Pos (8UL) /*!< Position of TRIGGERED8 field. */ -#define EGU_INTENSET_TRIGGERED8_Msk (0x1UL << EGU_INTENSET_TRIGGERED8_Pos) /*!< Bit mask of TRIGGERED8 field. */ -#define EGU_INTENSET_TRIGGERED8_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED8_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED8_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for TRIGGERED[7] event */ -#define EGU_INTENSET_TRIGGERED7_Pos (7UL) /*!< Position of TRIGGERED7 field. */ -#define EGU_INTENSET_TRIGGERED7_Msk (0x1UL << EGU_INTENSET_TRIGGERED7_Pos) /*!< Bit mask of TRIGGERED7 field. */ -#define EGU_INTENSET_TRIGGERED7_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED7_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED7_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for TRIGGERED[6] event */ -#define EGU_INTENSET_TRIGGERED6_Pos (6UL) /*!< Position of TRIGGERED6 field. */ -#define EGU_INTENSET_TRIGGERED6_Msk (0x1UL << EGU_INTENSET_TRIGGERED6_Pos) /*!< Bit mask of TRIGGERED6 field. */ -#define EGU_INTENSET_TRIGGERED6_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED6_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED6_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for TRIGGERED[5] event */ -#define EGU_INTENSET_TRIGGERED5_Pos (5UL) /*!< Position of TRIGGERED5 field. */ -#define EGU_INTENSET_TRIGGERED5_Msk (0x1UL << EGU_INTENSET_TRIGGERED5_Pos) /*!< Bit mask of TRIGGERED5 field. */ -#define EGU_INTENSET_TRIGGERED5_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED5_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED5_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for TRIGGERED[4] event */ -#define EGU_INTENSET_TRIGGERED4_Pos (4UL) /*!< Position of TRIGGERED4 field. */ -#define EGU_INTENSET_TRIGGERED4_Msk (0x1UL << EGU_INTENSET_TRIGGERED4_Pos) /*!< Bit mask of TRIGGERED4 field. */ -#define EGU_INTENSET_TRIGGERED4_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED4_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED4_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for TRIGGERED[3] event */ -#define EGU_INTENSET_TRIGGERED3_Pos (3UL) /*!< Position of TRIGGERED3 field. */ -#define EGU_INTENSET_TRIGGERED3_Msk (0x1UL << EGU_INTENSET_TRIGGERED3_Pos) /*!< Bit mask of TRIGGERED3 field. */ -#define EGU_INTENSET_TRIGGERED3_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED3_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED3_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for TRIGGERED[2] event */ -#define EGU_INTENSET_TRIGGERED2_Pos (2UL) /*!< Position of TRIGGERED2 field. */ -#define EGU_INTENSET_TRIGGERED2_Msk (0x1UL << EGU_INTENSET_TRIGGERED2_Pos) /*!< Bit mask of TRIGGERED2 field. */ -#define EGU_INTENSET_TRIGGERED2_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED2_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED2_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for TRIGGERED[1] event */ -#define EGU_INTENSET_TRIGGERED1_Pos (1UL) /*!< Position of TRIGGERED1 field. */ -#define EGU_INTENSET_TRIGGERED1_Msk (0x1UL << EGU_INTENSET_TRIGGERED1_Pos) /*!< Bit mask of TRIGGERED1 field. */ -#define EGU_INTENSET_TRIGGERED1_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED1_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED1_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for TRIGGERED[0] event */ -#define EGU_INTENSET_TRIGGERED0_Pos (0UL) /*!< Position of TRIGGERED0 field. */ -#define EGU_INTENSET_TRIGGERED0_Msk (0x1UL << EGU_INTENSET_TRIGGERED0_Pos) /*!< Bit mask of TRIGGERED0 field. */ -#define EGU_INTENSET_TRIGGERED0_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED0_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED0_Set (1UL) /*!< Enable */ - -/* Register: EGU_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 15 : Write '1' to Disable interrupt for TRIGGERED[15] event */ -#define EGU_INTENCLR_TRIGGERED15_Pos (15UL) /*!< Position of TRIGGERED15 field. */ -#define EGU_INTENCLR_TRIGGERED15_Msk (0x1UL << EGU_INTENCLR_TRIGGERED15_Pos) /*!< Bit mask of TRIGGERED15 field. */ -#define EGU_INTENCLR_TRIGGERED15_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED15_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED15_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for TRIGGERED[14] event */ -#define EGU_INTENCLR_TRIGGERED14_Pos (14UL) /*!< Position of TRIGGERED14 field. */ -#define EGU_INTENCLR_TRIGGERED14_Msk (0x1UL << EGU_INTENCLR_TRIGGERED14_Pos) /*!< Bit mask of TRIGGERED14 field. */ -#define EGU_INTENCLR_TRIGGERED14_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED14_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED14_Clear (1UL) /*!< Disable */ - -/* Bit 13 : Write '1' to Disable interrupt for TRIGGERED[13] event */ -#define EGU_INTENCLR_TRIGGERED13_Pos (13UL) /*!< Position of TRIGGERED13 field. */ -#define EGU_INTENCLR_TRIGGERED13_Msk (0x1UL << EGU_INTENCLR_TRIGGERED13_Pos) /*!< Bit mask of TRIGGERED13 field. */ -#define EGU_INTENCLR_TRIGGERED13_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED13_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED13_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for TRIGGERED[12] event */ -#define EGU_INTENCLR_TRIGGERED12_Pos (12UL) /*!< Position of TRIGGERED12 field. */ -#define EGU_INTENCLR_TRIGGERED12_Msk (0x1UL << EGU_INTENCLR_TRIGGERED12_Pos) /*!< Bit mask of TRIGGERED12 field. */ -#define EGU_INTENCLR_TRIGGERED12_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED12_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED12_Clear (1UL) /*!< Disable */ - -/* Bit 11 : Write '1' to Disable interrupt for TRIGGERED[11] event */ -#define EGU_INTENCLR_TRIGGERED11_Pos (11UL) /*!< Position of TRIGGERED11 field. */ -#define EGU_INTENCLR_TRIGGERED11_Msk (0x1UL << EGU_INTENCLR_TRIGGERED11_Pos) /*!< Bit mask of TRIGGERED11 field. */ -#define EGU_INTENCLR_TRIGGERED11_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED11_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED11_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for TRIGGERED[10] event */ -#define EGU_INTENCLR_TRIGGERED10_Pos (10UL) /*!< Position of TRIGGERED10 field. */ -#define EGU_INTENCLR_TRIGGERED10_Msk (0x1UL << EGU_INTENCLR_TRIGGERED10_Pos) /*!< Bit mask of TRIGGERED10 field. */ -#define EGU_INTENCLR_TRIGGERED10_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED10_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED10_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for TRIGGERED[9] event */ -#define EGU_INTENCLR_TRIGGERED9_Pos (9UL) /*!< Position of TRIGGERED9 field. */ -#define EGU_INTENCLR_TRIGGERED9_Msk (0x1UL << EGU_INTENCLR_TRIGGERED9_Pos) /*!< Bit mask of TRIGGERED9 field. */ -#define EGU_INTENCLR_TRIGGERED9_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED9_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED9_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for TRIGGERED[8] event */ -#define EGU_INTENCLR_TRIGGERED8_Pos (8UL) /*!< Position of TRIGGERED8 field. */ -#define EGU_INTENCLR_TRIGGERED8_Msk (0x1UL << EGU_INTENCLR_TRIGGERED8_Pos) /*!< Bit mask of TRIGGERED8 field. */ -#define EGU_INTENCLR_TRIGGERED8_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED8_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED8_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for TRIGGERED[7] event */ -#define EGU_INTENCLR_TRIGGERED7_Pos (7UL) /*!< Position of TRIGGERED7 field. */ -#define EGU_INTENCLR_TRIGGERED7_Msk (0x1UL << EGU_INTENCLR_TRIGGERED7_Pos) /*!< Bit mask of TRIGGERED7 field. */ -#define EGU_INTENCLR_TRIGGERED7_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED7_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED7_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for TRIGGERED[6] event */ -#define EGU_INTENCLR_TRIGGERED6_Pos (6UL) /*!< Position of TRIGGERED6 field. */ -#define EGU_INTENCLR_TRIGGERED6_Msk (0x1UL << EGU_INTENCLR_TRIGGERED6_Pos) /*!< Bit mask of TRIGGERED6 field. */ -#define EGU_INTENCLR_TRIGGERED6_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED6_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED6_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for TRIGGERED[5] event */ -#define EGU_INTENCLR_TRIGGERED5_Pos (5UL) /*!< Position of TRIGGERED5 field. */ -#define EGU_INTENCLR_TRIGGERED5_Msk (0x1UL << EGU_INTENCLR_TRIGGERED5_Pos) /*!< Bit mask of TRIGGERED5 field. */ -#define EGU_INTENCLR_TRIGGERED5_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED5_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED5_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for TRIGGERED[4] event */ -#define EGU_INTENCLR_TRIGGERED4_Pos (4UL) /*!< Position of TRIGGERED4 field. */ -#define EGU_INTENCLR_TRIGGERED4_Msk (0x1UL << EGU_INTENCLR_TRIGGERED4_Pos) /*!< Bit mask of TRIGGERED4 field. */ -#define EGU_INTENCLR_TRIGGERED4_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED4_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED4_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for TRIGGERED[3] event */ -#define EGU_INTENCLR_TRIGGERED3_Pos (3UL) /*!< Position of TRIGGERED3 field. */ -#define EGU_INTENCLR_TRIGGERED3_Msk (0x1UL << EGU_INTENCLR_TRIGGERED3_Pos) /*!< Bit mask of TRIGGERED3 field. */ -#define EGU_INTENCLR_TRIGGERED3_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED3_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED3_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for TRIGGERED[2] event */ -#define EGU_INTENCLR_TRIGGERED2_Pos (2UL) /*!< Position of TRIGGERED2 field. */ -#define EGU_INTENCLR_TRIGGERED2_Msk (0x1UL << EGU_INTENCLR_TRIGGERED2_Pos) /*!< Bit mask of TRIGGERED2 field. */ -#define EGU_INTENCLR_TRIGGERED2_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED2_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED2_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for TRIGGERED[1] event */ -#define EGU_INTENCLR_TRIGGERED1_Pos (1UL) /*!< Position of TRIGGERED1 field. */ -#define EGU_INTENCLR_TRIGGERED1_Msk (0x1UL << EGU_INTENCLR_TRIGGERED1_Pos) /*!< Bit mask of TRIGGERED1 field. */ -#define EGU_INTENCLR_TRIGGERED1_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED1_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED1_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for TRIGGERED[0] event */ -#define EGU_INTENCLR_TRIGGERED0_Pos (0UL) /*!< Position of TRIGGERED0 field. */ -#define EGU_INTENCLR_TRIGGERED0_Msk (0x1UL << EGU_INTENCLR_TRIGGERED0_Pos) /*!< Bit mask of TRIGGERED0 field. */ -#define EGU_INTENCLR_TRIGGERED0_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED0_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED0_Clear (1UL) /*!< Disable */ - - -/* Peripheral: FICR */ -/* Description: Factory information configuration registers */ - -/* Register: FICR_CODEPAGESIZE */ -/* Description: Code memory page size */ - -/* Bits 31..0 : Code memory page size */ -#define FICR_CODEPAGESIZE_CODEPAGESIZE_Pos (0UL) /*!< Position of CODEPAGESIZE field. */ -#define FICR_CODEPAGESIZE_CODEPAGESIZE_Msk (0xFFFFFFFFUL << FICR_CODEPAGESIZE_CODEPAGESIZE_Pos) /*!< Bit mask of CODEPAGESIZE field. */ - -/* Register: FICR_CODESIZE */ -/* Description: Code memory size */ - -/* Bits 31..0 : Code memory size in number of pages */ -#define FICR_CODESIZE_CODESIZE_Pos (0UL) /*!< Position of CODESIZE field. */ -#define FICR_CODESIZE_CODESIZE_Msk (0xFFFFFFFFUL << FICR_CODESIZE_CODESIZE_Pos) /*!< Bit mask of CODESIZE field. */ - -/* Register: FICR_DEVICEID */ -/* Description: Description collection[0]: Device identifier */ - -/* Bits 31..0 : 64 bit unique device identifier */ -#define FICR_DEVICEID_DEVICEID_Pos (0UL) /*!< Position of DEVICEID field. */ -#define FICR_DEVICEID_DEVICEID_Msk (0xFFFFFFFFUL << FICR_DEVICEID_DEVICEID_Pos) /*!< Bit mask of DEVICEID field. */ - -/* Register: FICR_ER */ -/* Description: Description collection[0]: Encryption root, word 0 */ - -/* Bits 31..0 : Encryption root, word n */ -#define FICR_ER_ER_Pos (0UL) /*!< Position of ER field. */ -#define FICR_ER_ER_Msk (0xFFFFFFFFUL << FICR_ER_ER_Pos) /*!< Bit mask of ER field. */ - -/* Register: FICR_IR */ -/* Description: Description collection[0]: Identity root, word 0 */ - -/* Bits 31..0 : Identity root, word n */ -#define FICR_IR_IR_Pos (0UL) /*!< Position of IR field. */ -#define FICR_IR_IR_Msk (0xFFFFFFFFUL << FICR_IR_IR_Pos) /*!< Bit mask of IR field. */ - -/* Register: FICR_DEVICEADDRTYPE */ -/* Description: Device address type */ - -/* Bit 0 : Device address type */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Pos (0UL) /*!< Position of DEVICEADDRTYPE field. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Msk (0x1UL << FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Pos) /*!< Bit mask of DEVICEADDRTYPE field. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Public (0UL) /*!< Public address */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Random (1UL) /*!< Random address */ - -/* Register: FICR_DEVICEADDR */ -/* Description: Description collection[0]: Device address 0 */ - -/* Bits 31..0 : 48 bit device address */ -#define FICR_DEVICEADDR_DEVICEADDR_Pos (0UL) /*!< Position of DEVICEADDR field. */ -#define FICR_DEVICEADDR_DEVICEADDR_Msk (0xFFFFFFFFUL << FICR_DEVICEADDR_DEVICEADDR_Pos) /*!< Bit mask of DEVICEADDR field. */ - -/* Register: FICR_INFO_PART */ -/* Description: Part code */ - -/* Bits 31..0 : Part code */ -#define FICR_INFO_PART_PART_Pos (0UL) /*!< Position of PART field. */ -#define FICR_INFO_PART_PART_Msk (0xFFFFFFFFUL << FICR_INFO_PART_PART_Pos) /*!< Bit mask of PART field. */ -#define FICR_INFO_PART_PART_N52810 (0x52810UL) /*!< nRF52810 */ -#define FICR_INFO_PART_PART_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_VARIANT */ -/* Description: Part variant, hardware version and production configuration */ - -/* Bits 31..0 : Part variant, hardware version and production configuration, encoded as ASCII */ -#define FICR_INFO_VARIANT_VARIANT_Pos (0UL) /*!< Position of VARIANT field. */ -#define FICR_INFO_VARIANT_VARIANT_Msk (0xFFFFFFFFUL << FICR_INFO_VARIANT_VARIANT_Pos) /*!< Bit mask of VARIANT field. */ -#define FICR_INFO_VARIANT_VARIANT_AAAA (0x41414141UL) /*!< AAAA */ -#define FICR_INFO_VARIANT_VARIANT_AAAB (0x41414142UL) /*!< AAAB */ -#define FICR_INFO_VARIANT_VARIANT_AABA (0x41414241UL) /*!< AABA */ -#define FICR_INFO_VARIANT_VARIANT_AABB (0x41414242UL) /*!< AABB */ -#define FICR_INFO_VARIANT_VARIANT_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_PACKAGE */ -/* Description: Package option */ - -/* Bits 31..0 : Package option */ -#define FICR_INFO_PACKAGE_PACKAGE_Pos (0UL) /*!< Position of PACKAGE field. */ -#define FICR_INFO_PACKAGE_PACKAGE_Msk (0xFFFFFFFFUL << FICR_INFO_PACKAGE_PACKAGE_Pos) /*!< Bit mask of PACKAGE field. */ -#define FICR_INFO_PACKAGE_PACKAGE_QF (0x2000UL) /*!< QFxx - 48-pin QFN */ -#define FICR_INFO_PACKAGE_PACKAGE_QC (0x2003UL) /*!< QCxx - 32-pin QFN */ -#define FICR_INFO_PACKAGE_PACKAGE_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_RAM */ -/* Description: RAM variant */ - -/* Bits 31..0 : RAM variant */ -#define FICR_INFO_RAM_RAM_Pos (0UL) /*!< Position of RAM field. */ -#define FICR_INFO_RAM_RAM_Msk (0xFFFFFFFFUL << FICR_INFO_RAM_RAM_Pos) /*!< Bit mask of RAM field. */ -#define FICR_INFO_RAM_RAM_K24 (0x18UL) /*!< 24 kByte RAM */ -#define FICR_INFO_RAM_RAM_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_FLASH */ -/* Description: Flash variant */ - -/* Bits 31..0 : Flash variant */ -#define FICR_INFO_FLASH_FLASH_Pos (0UL) /*!< Position of FLASH field. */ -#define FICR_INFO_FLASH_FLASH_Msk (0xFFFFFFFFUL << FICR_INFO_FLASH_FLASH_Pos) /*!< Bit mask of FLASH field. */ -#define FICR_INFO_FLASH_FLASH_K192 (0xC0UL) /*!< 192 kByte flash */ -#define FICR_INFO_FLASH_FLASH_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_TEMP_A0 */ -/* Description: Slope definition A0 */ - -/* Bits 11..0 : A (slope definition) register */ -#define FICR_TEMP_A0_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A0_A_Msk (0xFFFUL << FICR_TEMP_A0_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A1 */ -/* Description: Slope definition A1 */ - -/* Bits 11..0 : A (slope definition) register */ -#define FICR_TEMP_A1_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A1_A_Msk (0xFFFUL << FICR_TEMP_A1_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A2 */ -/* Description: Slope definition A2 */ - -/* Bits 11..0 : A (slope definition) register */ -#define FICR_TEMP_A2_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A2_A_Msk (0xFFFUL << FICR_TEMP_A2_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A3 */ -/* Description: Slope definition A3 */ - -/* Bits 11..0 : A (slope definition) register */ -#define FICR_TEMP_A3_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A3_A_Msk (0xFFFUL << FICR_TEMP_A3_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A4 */ -/* Description: Slope definition A4 */ - -/* Bits 11..0 : A (slope definition) register */ -#define FICR_TEMP_A4_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A4_A_Msk (0xFFFUL << FICR_TEMP_A4_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A5 */ -/* Description: Slope definition A5 */ - -/* Bits 11..0 : A (slope definition) register */ -#define FICR_TEMP_A5_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A5_A_Msk (0xFFFUL << FICR_TEMP_A5_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_B0 */ -/* Description: Y-intercept B0 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B0_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B0_B_Msk (0x3FFFUL << FICR_TEMP_B0_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B1 */ -/* Description: Y-intercept B1 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B1_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B1_B_Msk (0x3FFFUL << FICR_TEMP_B1_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B2 */ -/* Description: Y-intercept B2 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B2_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B2_B_Msk (0x3FFFUL << FICR_TEMP_B2_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B3 */ -/* Description: Y-intercept B3 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B3_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B3_B_Msk (0x3FFFUL << FICR_TEMP_B3_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B4 */ -/* Description: Y-intercept B4 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B4_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B4_B_Msk (0x3FFFUL << FICR_TEMP_B4_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B5 */ -/* Description: Y-intercept B5 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B5_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B5_B_Msk (0x3FFFUL << FICR_TEMP_B5_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_T0 */ -/* Description: Segment end T0 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T0_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T0_T_Msk (0xFFUL << FICR_TEMP_T0_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T1 */ -/* Description: Segment end T1 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T1_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T1_T_Msk (0xFFUL << FICR_TEMP_T1_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T2 */ -/* Description: Segment end T2 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T2_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T2_T_Msk (0xFFUL << FICR_TEMP_T2_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T3 */ -/* Description: Segment end T3 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T3_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T3_T_Msk (0xFFUL << FICR_TEMP_T3_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T4 */ -/* Description: Segment end T4 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T4_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T4_T_Msk (0xFFUL << FICR_TEMP_T4_T_Pos) /*!< Bit mask of T field. */ - - -/* Peripheral: GPIOTE */ -/* Description: GPIO Tasks and Events */ - -/* Register: GPIOTE_TASKS_OUT */ -/* Description: Description collection[0]: Task for writing to pin specified in CONFIG[0].PSEL. Action on pin is configured in CONFIG[0].POLARITY. */ - -/* Bit 0 : */ -#define GPIOTE_TASKS_OUT_TASKS_OUT_Pos (0UL) /*!< Position of TASKS_OUT field. */ -#define GPIOTE_TASKS_OUT_TASKS_OUT_Msk (0x1UL << GPIOTE_TASKS_OUT_TASKS_OUT_Pos) /*!< Bit mask of TASKS_OUT field. */ - -/* Register: GPIOTE_TASKS_SET */ -/* Description: Description collection[0]: Task for writing to pin specified in CONFIG[0].PSEL. Action on pin is to set it high. */ - -/* Bit 0 : */ -#define GPIOTE_TASKS_SET_TASKS_SET_Pos (0UL) /*!< Position of TASKS_SET field. */ -#define GPIOTE_TASKS_SET_TASKS_SET_Msk (0x1UL << GPIOTE_TASKS_SET_TASKS_SET_Pos) /*!< Bit mask of TASKS_SET field. */ - -/* Register: GPIOTE_TASKS_CLR */ -/* Description: Description collection[0]: Task for writing to pin specified in CONFIG[0].PSEL. Action on pin is to set it low. */ - -/* Bit 0 : */ -#define GPIOTE_TASKS_CLR_TASKS_CLR_Pos (0UL) /*!< Position of TASKS_CLR field. */ -#define GPIOTE_TASKS_CLR_TASKS_CLR_Msk (0x1UL << GPIOTE_TASKS_CLR_TASKS_CLR_Pos) /*!< Bit mask of TASKS_CLR field. */ - -/* Register: GPIOTE_EVENTS_IN */ -/* Description: Description collection[0]: Event generated from pin specified in CONFIG[0].PSEL */ - -/* Bit 0 : */ -#define GPIOTE_EVENTS_IN_EVENTS_IN_Pos (0UL) /*!< Position of EVENTS_IN field. */ -#define GPIOTE_EVENTS_IN_EVENTS_IN_Msk (0x1UL << GPIOTE_EVENTS_IN_EVENTS_IN_Pos) /*!< Bit mask of EVENTS_IN field. */ - -/* Register: GPIOTE_EVENTS_PORT */ -/* Description: Event generated from multiple input GPIO pins with SENSE mechanism enabled */ - -/* Bit 0 : */ -#define GPIOTE_EVENTS_PORT_EVENTS_PORT_Pos (0UL) /*!< Position of EVENTS_PORT field. */ -#define GPIOTE_EVENTS_PORT_EVENTS_PORT_Msk (0x1UL << GPIOTE_EVENTS_PORT_EVENTS_PORT_Pos) /*!< Bit mask of EVENTS_PORT field. */ - -/* Register: GPIOTE_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 31 : Write '1' to Enable interrupt for PORT event */ -#define GPIOTE_INTENSET_PORT_Pos (31UL) /*!< Position of PORT field. */ -#define GPIOTE_INTENSET_PORT_Msk (0x1UL << GPIOTE_INTENSET_PORT_Pos) /*!< Bit mask of PORT field. */ -#define GPIOTE_INTENSET_PORT_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_PORT_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_PORT_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for IN[7] event */ -#define GPIOTE_INTENSET_IN7_Pos (7UL) /*!< Position of IN7 field. */ -#define GPIOTE_INTENSET_IN7_Msk (0x1UL << GPIOTE_INTENSET_IN7_Pos) /*!< Bit mask of IN7 field. */ -#define GPIOTE_INTENSET_IN7_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN7_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN7_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for IN[6] event */ -#define GPIOTE_INTENSET_IN6_Pos (6UL) /*!< Position of IN6 field. */ -#define GPIOTE_INTENSET_IN6_Msk (0x1UL << GPIOTE_INTENSET_IN6_Pos) /*!< Bit mask of IN6 field. */ -#define GPIOTE_INTENSET_IN6_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN6_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN6_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for IN[5] event */ -#define GPIOTE_INTENSET_IN5_Pos (5UL) /*!< Position of IN5 field. */ -#define GPIOTE_INTENSET_IN5_Msk (0x1UL << GPIOTE_INTENSET_IN5_Pos) /*!< Bit mask of IN5 field. */ -#define GPIOTE_INTENSET_IN5_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN5_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN5_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for IN[4] event */ -#define GPIOTE_INTENSET_IN4_Pos (4UL) /*!< Position of IN4 field. */ -#define GPIOTE_INTENSET_IN4_Msk (0x1UL << GPIOTE_INTENSET_IN4_Pos) /*!< Bit mask of IN4 field. */ -#define GPIOTE_INTENSET_IN4_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN4_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN4_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for IN[3] event */ -#define GPIOTE_INTENSET_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define GPIOTE_INTENSET_IN3_Msk (0x1UL << GPIOTE_INTENSET_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define GPIOTE_INTENSET_IN3_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN3_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN3_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for IN[2] event */ -#define GPIOTE_INTENSET_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define GPIOTE_INTENSET_IN2_Msk (0x1UL << GPIOTE_INTENSET_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define GPIOTE_INTENSET_IN2_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN2_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN2_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for IN[1] event */ -#define GPIOTE_INTENSET_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define GPIOTE_INTENSET_IN1_Msk (0x1UL << GPIOTE_INTENSET_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define GPIOTE_INTENSET_IN1_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN1_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN1_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for IN[0] event */ -#define GPIOTE_INTENSET_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define GPIOTE_INTENSET_IN0_Msk (0x1UL << GPIOTE_INTENSET_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define GPIOTE_INTENSET_IN0_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN0_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN0_Set (1UL) /*!< Enable */ - -/* Register: GPIOTE_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 31 : Write '1' to Disable interrupt for PORT event */ -#define GPIOTE_INTENCLR_PORT_Pos (31UL) /*!< Position of PORT field. */ -#define GPIOTE_INTENCLR_PORT_Msk (0x1UL << GPIOTE_INTENCLR_PORT_Pos) /*!< Bit mask of PORT field. */ -#define GPIOTE_INTENCLR_PORT_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_PORT_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_PORT_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for IN[7] event */ -#define GPIOTE_INTENCLR_IN7_Pos (7UL) /*!< Position of IN7 field. */ -#define GPIOTE_INTENCLR_IN7_Msk (0x1UL << GPIOTE_INTENCLR_IN7_Pos) /*!< Bit mask of IN7 field. */ -#define GPIOTE_INTENCLR_IN7_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN7_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN7_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for IN[6] event */ -#define GPIOTE_INTENCLR_IN6_Pos (6UL) /*!< Position of IN6 field. */ -#define GPIOTE_INTENCLR_IN6_Msk (0x1UL << GPIOTE_INTENCLR_IN6_Pos) /*!< Bit mask of IN6 field. */ -#define GPIOTE_INTENCLR_IN6_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN6_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN6_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for IN[5] event */ -#define GPIOTE_INTENCLR_IN5_Pos (5UL) /*!< Position of IN5 field. */ -#define GPIOTE_INTENCLR_IN5_Msk (0x1UL << GPIOTE_INTENCLR_IN5_Pos) /*!< Bit mask of IN5 field. */ -#define GPIOTE_INTENCLR_IN5_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN5_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN5_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for IN[4] event */ -#define GPIOTE_INTENCLR_IN4_Pos (4UL) /*!< Position of IN4 field. */ -#define GPIOTE_INTENCLR_IN4_Msk (0x1UL << GPIOTE_INTENCLR_IN4_Pos) /*!< Bit mask of IN4 field. */ -#define GPIOTE_INTENCLR_IN4_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN4_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN4_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for IN[3] event */ -#define GPIOTE_INTENCLR_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define GPIOTE_INTENCLR_IN3_Msk (0x1UL << GPIOTE_INTENCLR_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define GPIOTE_INTENCLR_IN3_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN3_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN3_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for IN[2] event */ -#define GPIOTE_INTENCLR_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define GPIOTE_INTENCLR_IN2_Msk (0x1UL << GPIOTE_INTENCLR_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define GPIOTE_INTENCLR_IN2_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN2_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN2_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for IN[1] event */ -#define GPIOTE_INTENCLR_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define GPIOTE_INTENCLR_IN1_Msk (0x1UL << GPIOTE_INTENCLR_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define GPIOTE_INTENCLR_IN1_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN1_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN1_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for IN[0] event */ -#define GPIOTE_INTENCLR_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define GPIOTE_INTENCLR_IN0_Msk (0x1UL << GPIOTE_INTENCLR_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define GPIOTE_INTENCLR_IN0_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN0_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN0_Clear (1UL) /*!< Disable */ - -/* Register: GPIOTE_CONFIG */ -/* Description: Description collection[0]: Configuration for OUT[n], SET[n] and CLR[n] tasks and IN[n] event */ - -/* Bit 20 : When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect. */ -#define GPIOTE_CONFIG_OUTINIT_Pos (20UL) /*!< Position of OUTINIT field. */ -#define GPIOTE_CONFIG_OUTINIT_Msk (0x1UL << GPIOTE_CONFIG_OUTINIT_Pos) /*!< Bit mask of OUTINIT field. */ -#define GPIOTE_CONFIG_OUTINIT_Low (0UL) /*!< Task mode: Initial value of pin before task triggering is low */ -#define GPIOTE_CONFIG_OUTINIT_High (1UL) /*!< Task mode: Initial value of pin before task triggering is high */ - -/* Bits 17..16 : When In task mode: Operation to be performed on output when OUT[n] task is triggered. When In event mode: Operation on input that shall trigger IN[n] event. */ -#define GPIOTE_CONFIG_POLARITY_Pos (16UL) /*!< Position of POLARITY field. */ -#define GPIOTE_CONFIG_POLARITY_Msk (0x3UL << GPIOTE_CONFIG_POLARITY_Pos) /*!< Bit mask of POLARITY field. */ -#define GPIOTE_CONFIG_POLARITY_None (0UL) /*!< Task mode: No effect on pin from OUT[n] task. Event mode: no IN[n] event generated on pin activity. */ -#define GPIOTE_CONFIG_POLARITY_LoToHi (1UL) /*!< Task mode: Set pin from OUT[n] task. Event mode: Generate IN[n] event when rising edge on pin. */ -#define GPIOTE_CONFIG_POLARITY_HiToLo (2UL) /*!< Task mode: Clear pin from OUT[n] task. Event mode: Generate IN[n] event when falling edge on pin. */ -#define GPIOTE_CONFIG_POLARITY_Toggle (3UL) /*!< Task mode: Toggle pin from OUT[n]. Event mode: Generate IN[n] when any change on pin. */ - -/* Bits 12..8 : GPIO number associated with SET[n], CLR[n] and OUT[n] tasks and IN[n] event */ -#define GPIOTE_CONFIG_PSEL_Pos (8UL) /*!< Position of PSEL field. */ -#define GPIOTE_CONFIG_PSEL_Msk (0x1FUL << GPIOTE_CONFIG_PSEL_Pos) /*!< Bit mask of PSEL field. */ - -/* Bits 1..0 : Mode */ -#define GPIOTE_CONFIG_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define GPIOTE_CONFIG_MODE_Msk (0x3UL << GPIOTE_CONFIG_MODE_Pos) /*!< Bit mask of MODE field. */ -#define GPIOTE_CONFIG_MODE_Disabled (0UL) /*!< Disabled. Pin specified by PSEL will not be acquired by the GPIOTE module. */ -#define GPIOTE_CONFIG_MODE_Event (1UL) /*!< Event mode */ -#define GPIOTE_CONFIG_MODE_Task (3UL) /*!< Task mode */ - - -/* Peripheral: NVMC */ -/* Description: Non-volatile memory controller */ - -/* Register: NVMC_READY */ -/* Description: Ready flag */ - -/* Bit 0 : NVMC is ready or busy */ -#define NVMC_READY_READY_Pos (0UL) /*!< Position of READY field. */ -#define NVMC_READY_READY_Msk (0x1UL << NVMC_READY_READY_Pos) /*!< Bit mask of READY field. */ -#define NVMC_READY_READY_Busy (0UL) /*!< NVMC is busy (ongoing write or erase operation) */ -#define NVMC_READY_READY_Ready (1UL) /*!< NVMC is ready */ - -/* Register: NVMC_CONFIG */ -/* Description: Configuration register */ - -/* Bits 1..0 : Program memory access mode. It is strongly recommended to activate erase and write modes only when they are actively used. */ -#define NVMC_CONFIG_WEN_Pos (0UL) /*!< Position of WEN field. */ -#define NVMC_CONFIG_WEN_Msk (0x3UL << NVMC_CONFIG_WEN_Pos) /*!< Bit mask of WEN field. */ -#define NVMC_CONFIG_WEN_Ren (0UL) /*!< Read only access */ -#define NVMC_CONFIG_WEN_Wen (1UL) /*!< Write enabled */ -#define NVMC_CONFIG_WEN_Een (2UL) /*!< Erase enabled */ - -/* Register: NVMC_ERASEPCR1 */ -/* Description: Deprecated register - Register for erasing a page in code area. Equivalent to ERASEPAGE. */ - -/* Bits 31..0 : Register for erasing a page in code area. Equivalent to ERASEPAGE. */ -#define NVMC_ERASEPCR1_ERASEPCR1_Pos (0UL) /*!< Position of ERASEPCR1 field. */ -#define NVMC_ERASEPCR1_ERASEPCR1_Msk (0xFFFFFFFFUL << NVMC_ERASEPCR1_ERASEPCR1_Pos) /*!< Bit mask of ERASEPCR1 field. */ - -/* Register: NVMC_ERASEPAGE */ -/* Description: Register for erasing a page in code area */ - -/* Bits 31..0 : Register for starting erase of a page in code area. */ -#define NVMC_ERASEPAGE_ERASEPAGE_Pos (0UL) /*!< Position of ERASEPAGE field. */ -#define NVMC_ERASEPAGE_ERASEPAGE_Msk (0xFFFFFFFFUL << NVMC_ERASEPAGE_ERASEPAGE_Pos) /*!< Bit mask of ERASEPAGE field. */ - -/* Register: NVMC_ERASEALL */ -/* Description: Register for erasing all non-volatile user memory */ - -/* Bit 0 : Erase all non-volatile memory including UICR registers. Note that the erase must be enabled using CONFIG.WEN before the non-volatile memory can be erased. */ -#define NVMC_ERASEALL_ERASEALL_Pos (0UL) /*!< Position of ERASEALL field. */ -#define NVMC_ERASEALL_ERASEALL_Msk (0x1UL << NVMC_ERASEALL_ERASEALL_Pos) /*!< Bit mask of ERASEALL field. */ -#define NVMC_ERASEALL_ERASEALL_NoOperation (0UL) /*!< No operation */ -#define NVMC_ERASEALL_ERASEALL_Erase (1UL) /*!< Start erase of chip */ - -/* Register: NVMC_ERASEPCR0 */ -/* Description: Deprecated register - Register for erasing a page in code area. Equivalent to ERASEPAGE. */ - -/* Bits 31..0 : Register for starting erase of a page in code area. Equivalent to ERASEPAGE. */ -#define NVMC_ERASEPCR0_ERASEPCR0_Pos (0UL) /*!< Position of ERASEPCR0 field. */ -#define NVMC_ERASEPCR0_ERASEPCR0_Msk (0xFFFFFFFFUL << NVMC_ERASEPCR0_ERASEPCR0_Pos) /*!< Bit mask of ERASEPCR0 field. */ - -/* Register: NVMC_ERASEUICR */ -/* Description: Register for erasing user information configuration registers */ - -/* Bit 0 : Register starting erase of all user information configuration registers. Note that the erase must be enabled using CONFIG.WEN before the UICR can be erased. */ -#define NVMC_ERASEUICR_ERASEUICR_Pos (0UL) /*!< Position of ERASEUICR field. */ -#define NVMC_ERASEUICR_ERASEUICR_Msk (0x1UL << NVMC_ERASEUICR_ERASEUICR_Pos) /*!< Bit mask of ERASEUICR field. */ -#define NVMC_ERASEUICR_ERASEUICR_NoOperation (0UL) /*!< No operation */ -#define NVMC_ERASEUICR_ERASEUICR_Erase (1UL) /*!< Start erase of UICR */ - - -/* Peripheral: GPIO */ -/* Description: GPIO Port */ - -/* Register: GPIO_OUT */ -/* Description: Write GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_OUT_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUT_PIN31_Msk (0x1UL << GPIO_OUT_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUT_PIN31_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN31_High (1UL) /*!< Pin driver is high */ - -/* Bit 30 : Pin 30 */ -#define GPIO_OUT_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUT_PIN30_Msk (0x1UL << GPIO_OUT_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUT_PIN30_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN30_High (1UL) /*!< Pin driver is high */ - -/* Bit 29 : Pin 29 */ -#define GPIO_OUT_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUT_PIN29_Msk (0x1UL << GPIO_OUT_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUT_PIN29_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN29_High (1UL) /*!< Pin driver is high */ - -/* Bit 28 : Pin 28 */ -#define GPIO_OUT_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUT_PIN28_Msk (0x1UL << GPIO_OUT_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUT_PIN28_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN28_High (1UL) /*!< Pin driver is high */ - -/* Bit 27 : Pin 27 */ -#define GPIO_OUT_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUT_PIN27_Msk (0x1UL << GPIO_OUT_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUT_PIN27_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN27_High (1UL) /*!< Pin driver is high */ - -/* Bit 26 : Pin 26 */ -#define GPIO_OUT_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUT_PIN26_Msk (0x1UL << GPIO_OUT_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUT_PIN26_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN26_High (1UL) /*!< Pin driver is high */ - -/* Bit 25 : Pin 25 */ -#define GPIO_OUT_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUT_PIN25_Msk (0x1UL << GPIO_OUT_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUT_PIN25_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN25_High (1UL) /*!< Pin driver is high */ - -/* Bit 24 : Pin 24 */ -#define GPIO_OUT_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUT_PIN24_Msk (0x1UL << GPIO_OUT_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUT_PIN24_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN24_High (1UL) /*!< Pin driver is high */ - -/* Bit 23 : Pin 23 */ -#define GPIO_OUT_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUT_PIN23_Msk (0x1UL << GPIO_OUT_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUT_PIN23_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN23_High (1UL) /*!< Pin driver is high */ - -/* Bit 22 : Pin 22 */ -#define GPIO_OUT_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUT_PIN22_Msk (0x1UL << GPIO_OUT_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUT_PIN22_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN22_High (1UL) /*!< Pin driver is high */ - -/* Bit 21 : Pin 21 */ -#define GPIO_OUT_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUT_PIN21_Msk (0x1UL << GPIO_OUT_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUT_PIN21_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN21_High (1UL) /*!< Pin driver is high */ - -/* Bit 20 : Pin 20 */ -#define GPIO_OUT_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUT_PIN20_Msk (0x1UL << GPIO_OUT_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUT_PIN20_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN20_High (1UL) /*!< Pin driver is high */ - -/* Bit 19 : Pin 19 */ -#define GPIO_OUT_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUT_PIN19_Msk (0x1UL << GPIO_OUT_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUT_PIN19_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN19_High (1UL) /*!< Pin driver is high */ - -/* Bit 18 : Pin 18 */ -#define GPIO_OUT_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUT_PIN18_Msk (0x1UL << GPIO_OUT_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUT_PIN18_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN18_High (1UL) /*!< Pin driver is high */ - -/* Bit 17 : Pin 17 */ -#define GPIO_OUT_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUT_PIN17_Msk (0x1UL << GPIO_OUT_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUT_PIN17_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN17_High (1UL) /*!< Pin driver is high */ - -/* Bit 16 : Pin 16 */ -#define GPIO_OUT_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUT_PIN16_Msk (0x1UL << GPIO_OUT_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUT_PIN16_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN16_High (1UL) /*!< Pin driver is high */ - -/* Bit 15 : Pin 15 */ -#define GPIO_OUT_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUT_PIN15_Msk (0x1UL << GPIO_OUT_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUT_PIN15_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN15_High (1UL) /*!< Pin driver is high */ - -/* Bit 14 : Pin 14 */ -#define GPIO_OUT_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUT_PIN14_Msk (0x1UL << GPIO_OUT_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUT_PIN14_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN14_High (1UL) /*!< Pin driver is high */ - -/* Bit 13 : Pin 13 */ -#define GPIO_OUT_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUT_PIN13_Msk (0x1UL << GPIO_OUT_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUT_PIN13_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN13_High (1UL) /*!< Pin driver is high */ - -/* Bit 12 : Pin 12 */ -#define GPIO_OUT_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUT_PIN12_Msk (0x1UL << GPIO_OUT_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUT_PIN12_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN12_High (1UL) /*!< Pin driver is high */ - -/* Bit 11 : Pin 11 */ -#define GPIO_OUT_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUT_PIN11_Msk (0x1UL << GPIO_OUT_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUT_PIN11_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN11_High (1UL) /*!< Pin driver is high */ - -/* Bit 10 : Pin 10 */ -#define GPIO_OUT_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUT_PIN10_Msk (0x1UL << GPIO_OUT_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUT_PIN10_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN10_High (1UL) /*!< Pin driver is high */ - -/* Bit 9 : Pin 9 */ -#define GPIO_OUT_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUT_PIN9_Msk (0x1UL << GPIO_OUT_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUT_PIN9_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN9_High (1UL) /*!< Pin driver is high */ - -/* Bit 8 : Pin 8 */ -#define GPIO_OUT_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUT_PIN8_Msk (0x1UL << GPIO_OUT_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUT_PIN8_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN8_High (1UL) /*!< Pin driver is high */ - -/* Bit 7 : Pin 7 */ -#define GPIO_OUT_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUT_PIN7_Msk (0x1UL << GPIO_OUT_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUT_PIN7_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN7_High (1UL) /*!< Pin driver is high */ - -/* Bit 6 : Pin 6 */ -#define GPIO_OUT_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUT_PIN6_Msk (0x1UL << GPIO_OUT_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUT_PIN6_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN6_High (1UL) /*!< Pin driver is high */ - -/* Bit 5 : Pin 5 */ -#define GPIO_OUT_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUT_PIN5_Msk (0x1UL << GPIO_OUT_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUT_PIN5_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN5_High (1UL) /*!< Pin driver is high */ - -/* Bit 4 : Pin 4 */ -#define GPIO_OUT_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUT_PIN4_Msk (0x1UL << GPIO_OUT_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUT_PIN4_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN4_High (1UL) /*!< Pin driver is high */ - -/* Bit 3 : Pin 3 */ -#define GPIO_OUT_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUT_PIN3_Msk (0x1UL << GPIO_OUT_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUT_PIN3_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN3_High (1UL) /*!< Pin driver is high */ - -/* Bit 2 : Pin 2 */ -#define GPIO_OUT_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUT_PIN2_Msk (0x1UL << GPIO_OUT_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUT_PIN2_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN2_High (1UL) /*!< Pin driver is high */ - -/* Bit 1 : Pin 1 */ -#define GPIO_OUT_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUT_PIN1_Msk (0x1UL << GPIO_OUT_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUT_PIN1_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN1_High (1UL) /*!< Pin driver is high */ - -/* Bit 0 : Pin 0 */ -#define GPIO_OUT_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUT_PIN0_Msk (0x1UL << GPIO_OUT_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUT_PIN0_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN0_High (1UL) /*!< Pin driver is high */ - -/* Register: GPIO_OUTSET */ -/* Description: Set individual bits in GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_OUTSET_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUTSET_PIN31_Msk (0x1UL << GPIO_OUTSET_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUTSET_PIN31_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN31_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN31_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 30 : Pin 30 */ -#define GPIO_OUTSET_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUTSET_PIN30_Msk (0x1UL << GPIO_OUTSET_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUTSET_PIN30_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN30_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN30_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 29 : Pin 29 */ -#define GPIO_OUTSET_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUTSET_PIN29_Msk (0x1UL << GPIO_OUTSET_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUTSET_PIN29_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN29_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN29_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 28 : Pin 28 */ -#define GPIO_OUTSET_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUTSET_PIN28_Msk (0x1UL << GPIO_OUTSET_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUTSET_PIN28_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN28_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN28_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 27 : Pin 27 */ -#define GPIO_OUTSET_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUTSET_PIN27_Msk (0x1UL << GPIO_OUTSET_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUTSET_PIN27_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN27_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN27_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 26 : Pin 26 */ -#define GPIO_OUTSET_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUTSET_PIN26_Msk (0x1UL << GPIO_OUTSET_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUTSET_PIN26_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN26_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN26_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 25 : Pin 25 */ -#define GPIO_OUTSET_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUTSET_PIN25_Msk (0x1UL << GPIO_OUTSET_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUTSET_PIN25_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN25_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN25_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 24 : Pin 24 */ -#define GPIO_OUTSET_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUTSET_PIN24_Msk (0x1UL << GPIO_OUTSET_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUTSET_PIN24_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN24_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN24_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 23 : Pin 23 */ -#define GPIO_OUTSET_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUTSET_PIN23_Msk (0x1UL << GPIO_OUTSET_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUTSET_PIN23_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN23_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN23_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 22 : Pin 22 */ -#define GPIO_OUTSET_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUTSET_PIN22_Msk (0x1UL << GPIO_OUTSET_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUTSET_PIN22_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN22_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN22_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 21 : Pin 21 */ -#define GPIO_OUTSET_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUTSET_PIN21_Msk (0x1UL << GPIO_OUTSET_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUTSET_PIN21_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN21_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN21_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 20 : Pin 20 */ -#define GPIO_OUTSET_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUTSET_PIN20_Msk (0x1UL << GPIO_OUTSET_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUTSET_PIN20_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN20_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN20_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 19 : Pin 19 */ -#define GPIO_OUTSET_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUTSET_PIN19_Msk (0x1UL << GPIO_OUTSET_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUTSET_PIN19_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN19_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN19_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 18 : Pin 18 */ -#define GPIO_OUTSET_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUTSET_PIN18_Msk (0x1UL << GPIO_OUTSET_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUTSET_PIN18_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN18_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN18_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 17 : Pin 17 */ -#define GPIO_OUTSET_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUTSET_PIN17_Msk (0x1UL << GPIO_OUTSET_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUTSET_PIN17_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN17_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN17_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 16 : Pin 16 */ -#define GPIO_OUTSET_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUTSET_PIN16_Msk (0x1UL << GPIO_OUTSET_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUTSET_PIN16_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN16_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN16_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 15 : Pin 15 */ -#define GPIO_OUTSET_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUTSET_PIN15_Msk (0x1UL << GPIO_OUTSET_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUTSET_PIN15_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN15_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN15_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 14 : Pin 14 */ -#define GPIO_OUTSET_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUTSET_PIN14_Msk (0x1UL << GPIO_OUTSET_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUTSET_PIN14_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN14_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN14_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 13 : Pin 13 */ -#define GPIO_OUTSET_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUTSET_PIN13_Msk (0x1UL << GPIO_OUTSET_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUTSET_PIN13_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN13_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN13_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 12 : Pin 12 */ -#define GPIO_OUTSET_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUTSET_PIN12_Msk (0x1UL << GPIO_OUTSET_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUTSET_PIN12_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN12_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN12_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 11 : Pin 11 */ -#define GPIO_OUTSET_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUTSET_PIN11_Msk (0x1UL << GPIO_OUTSET_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUTSET_PIN11_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN11_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN11_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 10 : Pin 10 */ -#define GPIO_OUTSET_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUTSET_PIN10_Msk (0x1UL << GPIO_OUTSET_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUTSET_PIN10_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN10_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN10_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 9 : Pin 9 */ -#define GPIO_OUTSET_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUTSET_PIN9_Msk (0x1UL << GPIO_OUTSET_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUTSET_PIN9_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN9_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN9_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 8 : Pin 8 */ -#define GPIO_OUTSET_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUTSET_PIN8_Msk (0x1UL << GPIO_OUTSET_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUTSET_PIN8_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN8_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN8_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 7 : Pin 7 */ -#define GPIO_OUTSET_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUTSET_PIN7_Msk (0x1UL << GPIO_OUTSET_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUTSET_PIN7_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN7_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN7_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 6 : Pin 6 */ -#define GPIO_OUTSET_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUTSET_PIN6_Msk (0x1UL << GPIO_OUTSET_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUTSET_PIN6_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN6_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN6_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 5 : Pin 5 */ -#define GPIO_OUTSET_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUTSET_PIN5_Msk (0x1UL << GPIO_OUTSET_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUTSET_PIN5_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN5_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN5_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 4 : Pin 4 */ -#define GPIO_OUTSET_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUTSET_PIN4_Msk (0x1UL << GPIO_OUTSET_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUTSET_PIN4_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN4_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN4_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 3 : Pin 3 */ -#define GPIO_OUTSET_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUTSET_PIN3_Msk (0x1UL << GPIO_OUTSET_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUTSET_PIN3_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN3_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN3_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 2 : Pin 2 */ -#define GPIO_OUTSET_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUTSET_PIN2_Msk (0x1UL << GPIO_OUTSET_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUTSET_PIN2_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN2_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN2_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 1 : Pin 1 */ -#define GPIO_OUTSET_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUTSET_PIN1_Msk (0x1UL << GPIO_OUTSET_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUTSET_PIN1_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN1_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN1_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 0 : Pin 0 */ -#define GPIO_OUTSET_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUTSET_PIN0_Msk (0x1UL << GPIO_OUTSET_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUTSET_PIN0_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN0_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN0_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Register: GPIO_OUTCLR */ -/* Description: Clear individual bits in GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_OUTCLR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUTCLR_PIN31_Msk (0x1UL << GPIO_OUTCLR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUTCLR_PIN31_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN31_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN31_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 30 : Pin 30 */ -#define GPIO_OUTCLR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUTCLR_PIN30_Msk (0x1UL << GPIO_OUTCLR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUTCLR_PIN30_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN30_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN30_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 29 : Pin 29 */ -#define GPIO_OUTCLR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUTCLR_PIN29_Msk (0x1UL << GPIO_OUTCLR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUTCLR_PIN29_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN29_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN29_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 28 : Pin 28 */ -#define GPIO_OUTCLR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUTCLR_PIN28_Msk (0x1UL << GPIO_OUTCLR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUTCLR_PIN28_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN28_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN28_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 27 : Pin 27 */ -#define GPIO_OUTCLR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUTCLR_PIN27_Msk (0x1UL << GPIO_OUTCLR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUTCLR_PIN27_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN27_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN27_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 26 : Pin 26 */ -#define GPIO_OUTCLR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUTCLR_PIN26_Msk (0x1UL << GPIO_OUTCLR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUTCLR_PIN26_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN26_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN26_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 25 : Pin 25 */ -#define GPIO_OUTCLR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUTCLR_PIN25_Msk (0x1UL << GPIO_OUTCLR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUTCLR_PIN25_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN25_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN25_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 24 : Pin 24 */ -#define GPIO_OUTCLR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUTCLR_PIN24_Msk (0x1UL << GPIO_OUTCLR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUTCLR_PIN24_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN24_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN24_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 23 : Pin 23 */ -#define GPIO_OUTCLR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUTCLR_PIN23_Msk (0x1UL << GPIO_OUTCLR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUTCLR_PIN23_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN23_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN23_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 22 : Pin 22 */ -#define GPIO_OUTCLR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUTCLR_PIN22_Msk (0x1UL << GPIO_OUTCLR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUTCLR_PIN22_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN22_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN22_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 21 : Pin 21 */ -#define GPIO_OUTCLR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUTCLR_PIN21_Msk (0x1UL << GPIO_OUTCLR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUTCLR_PIN21_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN21_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN21_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 20 : Pin 20 */ -#define GPIO_OUTCLR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUTCLR_PIN20_Msk (0x1UL << GPIO_OUTCLR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUTCLR_PIN20_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN20_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN20_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 19 : Pin 19 */ -#define GPIO_OUTCLR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUTCLR_PIN19_Msk (0x1UL << GPIO_OUTCLR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUTCLR_PIN19_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN19_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN19_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 18 : Pin 18 */ -#define GPIO_OUTCLR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUTCLR_PIN18_Msk (0x1UL << GPIO_OUTCLR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUTCLR_PIN18_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN18_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN18_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 17 : Pin 17 */ -#define GPIO_OUTCLR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUTCLR_PIN17_Msk (0x1UL << GPIO_OUTCLR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUTCLR_PIN17_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN17_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN17_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 16 : Pin 16 */ -#define GPIO_OUTCLR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUTCLR_PIN16_Msk (0x1UL << GPIO_OUTCLR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUTCLR_PIN16_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN16_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN16_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 15 : Pin 15 */ -#define GPIO_OUTCLR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUTCLR_PIN15_Msk (0x1UL << GPIO_OUTCLR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUTCLR_PIN15_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN15_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN15_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 14 : Pin 14 */ -#define GPIO_OUTCLR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUTCLR_PIN14_Msk (0x1UL << GPIO_OUTCLR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUTCLR_PIN14_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN14_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN14_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 13 : Pin 13 */ -#define GPIO_OUTCLR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUTCLR_PIN13_Msk (0x1UL << GPIO_OUTCLR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUTCLR_PIN13_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN13_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN13_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 12 : Pin 12 */ -#define GPIO_OUTCLR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUTCLR_PIN12_Msk (0x1UL << GPIO_OUTCLR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUTCLR_PIN12_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN12_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN12_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 11 : Pin 11 */ -#define GPIO_OUTCLR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUTCLR_PIN11_Msk (0x1UL << GPIO_OUTCLR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUTCLR_PIN11_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN11_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN11_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 10 : Pin 10 */ -#define GPIO_OUTCLR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUTCLR_PIN10_Msk (0x1UL << GPIO_OUTCLR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUTCLR_PIN10_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN10_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN10_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 9 : Pin 9 */ -#define GPIO_OUTCLR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUTCLR_PIN9_Msk (0x1UL << GPIO_OUTCLR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUTCLR_PIN9_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN9_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN9_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 8 : Pin 8 */ -#define GPIO_OUTCLR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUTCLR_PIN8_Msk (0x1UL << GPIO_OUTCLR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUTCLR_PIN8_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN8_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN8_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 7 : Pin 7 */ -#define GPIO_OUTCLR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUTCLR_PIN7_Msk (0x1UL << GPIO_OUTCLR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUTCLR_PIN7_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN7_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN7_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 6 : Pin 6 */ -#define GPIO_OUTCLR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUTCLR_PIN6_Msk (0x1UL << GPIO_OUTCLR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUTCLR_PIN6_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN6_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN6_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 5 : Pin 5 */ -#define GPIO_OUTCLR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUTCLR_PIN5_Msk (0x1UL << GPIO_OUTCLR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUTCLR_PIN5_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN5_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN5_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 4 : Pin 4 */ -#define GPIO_OUTCLR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUTCLR_PIN4_Msk (0x1UL << GPIO_OUTCLR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUTCLR_PIN4_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN4_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN4_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 3 : Pin 3 */ -#define GPIO_OUTCLR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUTCLR_PIN3_Msk (0x1UL << GPIO_OUTCLR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUTCLR_PIN3_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN3_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN3_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 2 : Pin 2 */ -#define GPIO_OUTCLR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUTCLR_PIN2_Msk (0x1UL << GPIO_OUTCLR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUTCLR_PIN2_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN2_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN2_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 1 : Pin 1 */ -#define GPIO_OUTCLR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUTCLR_PIN1_Msk (0x1UL << GPIO_OUTCLR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUTCLR_PIN1_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN1_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN1_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 0 : Pin 0 */ -#define GPIO_OUTCLR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUTCLR_PIN0_Msk (0x1UL << GPIO_OUTCLR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUTCLR_PIN0_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN0_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN0_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Register: GPIO_IN */ -/* Description: Read GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_IN_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_IN_PIN31_Msk (0x1UL << GPIO_IN_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_IN_PIN31_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN31_High (1UL) /*!< Pin input is high */ - -/* Bit 30 : Pin 30 */ -#define GPIO_IN_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_IN_PIN30_Msk (0x1UL << GPIO_IN_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_IN_PIN30_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN30_High (1UL) /*!< Pin input is high */ - -/* Bit 29 : Pin 29 */ -#define GPIO_IN_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_IN_PIN29_Msk (0x1UL << GPIO_IN_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_IN_PIN29_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN29_High (1UL) /*!< Pin input is high */ - -/* Bit 28 : Pin 28 */ -#define GPIO_IN_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_IN_PIN28_Msk (0x1UL << GPIO_IN_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_IN_PIN28_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN28_High (1UL) /*!< Pin input is high */ - -/* Bit 27 : Pin 27 */ -#define GPIO_IN_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_IN_PIN27_Msk (0x1UL << GPIO_IN_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_IN_PIN27_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN27_High (1UL) /*!< Pin input is high */ - -/* Bit 26 : Pin 26 */ -#define GPIO_IN_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_IN_PIN26_Msk (0x1UL << GPIO_IN_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_IN_PIN26_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN26_High (1UL) /*!< Pin input is high */ - -/* Bit 25 : Pin 25 */ -#define GPIO_IN_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_IN_PIN25_Msk (0x1UL << GPIO_IN_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_IN_PIN25_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN25_High (1UL) /*!< Pin input is high */ - -/* Bit 24 : Pin 24 */ -#define GPIO_IN_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_IN_PIN24_Msk (0x1UL << GPIO_IN_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_IN_PIN24_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN24_High (1UL) /*!< Pin input is high */ - -/* Bit 23 : Pin 23 */ -#define GPIO_IN_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_IN_PIN23_Msk (0x1UL << GPIO_IN_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_IN_PIN23_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN23_High (1UL) /*!< Pin input is high */ - -/* Bit 22 : Pin 22 */ -#define GPIO_IN_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_IN_PIN22_Msk (0x1UL << GPIO_IN_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_IN_PIN22_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN22_High (1UL) /*!< Pin input is high */ - -/* Bit 21 : Pin 21 */ -#define GPIO_IN_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_IN_PIN21_Msk (0x1UL << GPIO_IN_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_IN_PIN21_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN21_High (1UL) /*!< Pin input is high */ - -/* Bit 20 : Pin 20 */ -#define GPIO_IN_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_IN_PIN20_Msk (0x1UL << GPIO_IN_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_IN_PIN20_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN20_High (1UL) /*!< Pin input is high */ - -/* Bit 19 : Pin 19 */ -#define GPIO_IN_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_IN_PIN19_Msk (0x1UL << GPIO_IN_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_IN_PIN19_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN19_High (1UL) /*!< Pin input is high */ - -/* Bit 18 : Pin 18 */ -#define GPIO_IN_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_IN_PIN18_Msk (0x1UL << GPIO_IN_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_IN_PIN18_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN18_High (1UL) /*!< Pin input is high */ - -/* Bit 17 : Pin 17 */ -#define GPIO_IN_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_IN_PIN17_Msk (0x1UL << GPIO_IN_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_IN_PIN17_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN17_High (1UL) /*!< Pin input is high */ - -/* Bit 16 : Pin 16 */ -#define GPIO_IN_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_IN_PIN16_Msk (0x1UL << GPIO_IN_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_IN_PIN16_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN16_High (1UL) /*!< Pin input is high */ - -/* Bit 15 : Pin 15 */ -#define GPIO_IN_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_IN_PIN15_Msk (0x1UL << GPIO_IN_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_IN_PIN15_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN15_High (1UL) /*!< Pin input is high */ - -/* Bit 14 : Pin 14 */ -#define GPIO_IN_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_IN_PIN14_Msk (0x1UL << GPIO_IN_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_IN_PIN14_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN14_High (1UL) /*!< Pin input is high */ - -/* Bit 13 : Pin 13 */ -#define GPIO_IN_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_IN_PIN13_Msk (0x1UL << GPIO_IN_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_IN_PIN13_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN13_High (1UL) /*!< Pin input is high */ - -/* Bit 12 : Pin 12 */ -#define GPIO_IN_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_IN_PIN12_Msk (0x1UL << GPIO_IN_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_IN_PIN12_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN12_High (1UL) /*!< Pin input is high */ - -/* Bit 11 : Pin 11 */ -#define GPIO_IN_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_IN_PIN11_Msk (0x1UL << GPIO_IN_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_IN_PIN11_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN11_High (1UL) /*!< Pin input is high */ - -/* Bit 10 : Pin 10 */ -#define GPIO_IN_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_IN_PIN10_Msk (0x1UL << GPIO_IN_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_IN_PIN10_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN10_High (1UL) /*!< Pin input is high */ - -/* Bit 9 : Pin 9 */ -#define GPIO_IN_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_IN_PIN9_Msk (0x1UL << GPIO_IN_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_IN_PIN9_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN9_High (1UL) /*!< Pin input is high */ - -/* Bit 8 : Pin 8 */ -#define GPIO_IN_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_IN_PIN8_Msk (0x1UL << GPIO_IN_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_IN_PIN8_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN8_High (1UL) /*!< Pin input is high */ - -/* Bit 7 : Pin 7 */ -#define GPIO_IN_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_IN_PIN7_Msk (0x1UL << GPIO_IN_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_IN_PIN7_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN7_High (1UL) /*!< Pin input is high */ - -/* Bit 6 : Pin 6 */ -#define GPIO_IN_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_IN_PIN6_Msk (0x1UL << GPIO_IN_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_IN_PIN6_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN6_High (1UL) /*!< Pin input is high */ - -/* Bit 5 : Pin 5 */ -#define GPIO_IN_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_IN_PIN5_Msk (0x1UL << GPIO_IN_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_IN_PIN5_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN5_High (1UL) /*!< Pin input is high */ - -/* Bit 4 : Pin 4 */ -#define GPIO_IN_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_IN_PIN4_Msk (0x1UL << GPIO_IN_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_IN_PIN4_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN4_High (1UL) /*!< Pin input is high */ - -/* Bit 3 : Pin 3 */ -#define GPIO_IN_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_IN_PIN3_Msk (0x1UL << GPIO_IN_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_IN_PIN3_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN3_High (1UL) /*!< Pin input is high */ - -/* Bit 2 : Pin 2 */ -#define GPIO_IN_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_IN_PIN2_Msk (0x1UL << GPIO_IN_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_IN_PIN2_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN2_High (1UL) /*!< Pin input is high */ - -/* Bit 1 : Pin 1 */ -#define GPIO_IN_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_IN_PIN1_Msk (0x1UL << GPIO_IN_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_IN_PIN1_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN1_High (1UL) /*!< Pin input is high */ - -/* Bit 0 : Pin 0 */ -#define GPIO_IN_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_IN_PIN0_Msk (0x1UL << GPIO_IN_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_IN_PIN0_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN0_High (1UL) /*!< Pin input is high */ - -/* Register: GPIO_DIR */ -/* Description: Direction of GPIO pins */ - -/* Bit 31 : Pin 31 */ -#define GPIO_DIR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIR_PIN31_Msk (0x1UL << GPIO_DIR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIR_PIN31_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN31_Output (1UL) /*!< Pin set as output */ - -/* Bit 30 : Pin 30 */ -#define GPIO_DIR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIR_PIN30_Msk (0x1UL << GPIO_DIR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIR_PIN30_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN30_Output (1UL) /*!< Pin set as output */ - -/* Bit 29 : Pin 29 */ -#define GPIO_DIR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIR_PIN29_Msk (0x1UL << GPIO_DIR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIR_PIN29_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN29_Output (1UL) /*!< Pin set as output */ - -/* Bit 28 : Pin 28 */ -#define GPIO_DIR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIR_PIN28_Msk (0x1UL << GPIO_DIR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIR_PIN28_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN28_Output (1UL) /*!< Pin set as output */ - -/* Bit 27 : Pin 27 */ -#define GPIO_DIR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIR_PIN27_Msk (0x1UL << GPIO_DIR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIR_PIN27_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN27_Output (1UL) /*!< Pin set as output */ - -/* Bit 26 : Pin 26 */ -#define GPIO_DIR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIR_PIN26_Msk (0x1UL << GPIO_DIR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIR_PIN26_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN26_Output (1UL) /*!< Pin set as output */ - -/* Bit 25 : Pin 25 */ -#define GPIO_DIR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIR_PIN25_Msk (0x1UL << GPIO_DIR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIR_PIN25_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN25_Output (1UL) /*!< Pin set as output */ - -/* Bit 24 : Pin 24 */ -#define GPIO_DIR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIR_PIN24_Msk (0x1UL << GPIO_DIR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIR_PIN24_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN24_Output (1UL) /*!< Pin set as output */ - -/* Bit 23 : Pin 23 */ -#define GPIO_DIR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIR_PIN23_Msk (0x1UL << GPIO_DIR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIR_PIN23_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN23_Output (1UL) /*!< Pin set as output */ - -/* Bit 22 : Pin 22 */ -#define GPIO_DIR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIR_PIN22_Msk (0x1UL << GPIO_DIR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIR_PIN22_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN22_Output (1UL) /*!< Pin set as output */ - -/* Bit 21 : Pin 21 */ -#define GPIO_DIR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIR_PIN21_Msk (0x1UL << GPIO_DIR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIR_PIN21_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN21_Output (1UL) /*!< Pin set as output */ - -/* Bit 20 : Pin 20 */ -#define GPIO_DIR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIR_PIN20_Msk (0x1UL << GPIO_DIR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIR_PIN20_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN20_Output (1UL) /*!< Pin set as output */ - -/* Bit 19 : Pin 19 */ -#define GPIO_DIR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIR_PIN19_Msk (0x1UL << GPIO_DIR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIR_PIN19_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN19_Output (1UL) /*!< Pin set as output */ - -/* Bit 18 : Pin 18 */ -#define GPIO_DIR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIR_PIN18_Msk (0x1UL << GPIO_DIR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIR_PIN18_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN18_Output (1UL) /*!< Pin set as output */ - -/* Bit 17 : Pin 17 */ -#define GPIO_DIR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIR_PIN17_Msk (0x1UL << GPIO_DIR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIR_PIN17_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN17_Output (1UL) /*!< Pin set as output */ - -/* Bit 16 : Pin 16 */ -#define GPIO_DIR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIR_PIN16_Msk (0x1UL << GPIO_DIR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIR_PIN16_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN16_Output (1UL) /*!< Pin set as output */ - -/* Bit 15 : Pin 15 */ -#define GPIO_DIR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIR_PIN15_Msk (0x1UL << GPIO_DIR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIR_PIN15_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN15_Output (1UL) /*!< Pin set as output */ - -/* Bit 14 : Pin 14 */ -#define GPIO_DIR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIR_PIN14_Msk (0x1UL << GPIO_DIR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIR_PIN14_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN14_Output (1UL) /*!< Pin set as output */ - -/* Bit 13 : Pin 13 */ -#define GPIO_DIR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIR_PIN13_Msk (0x1UL << GPIO_DIR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIR_PIN13_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN13_Output (1UL) /*!< Pin set as output */ - -/* Bit 12 : Pin 12 */ -#define GPIO_DIR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIR_PIN12_Msk (0x1UL << GPIO_DIR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIR_PIN12_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN12_Output (1UL) /*!< Pin set as output */ - -/* Bit 11 : Pin 11 */ -#define GPIO_DIR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIR_PIN11_Msk (0x1UL << GPIO_DIR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIR_PIN11_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN11_Output (1UL) /*!< Pin set as output */ - -/* Bit 10 : Pin 10 */ -#define GPIO_DIR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIR_PIN10_Msk (0x1UL << GPIO_DIR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIR_PIN10_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN10_Output (1UL) /*!< Pin set as output */ - -/* Bit 9 : Pin 9 */ -#define GPIO_DIR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIR_PIN9_Msk (0x1UL << GPIO_DIR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIR_PIN9_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN9_Output (1UL) /*!< Pin set as output */ - -/* Bit 8 : Pin 8 */ -#define GPIO_DIR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIR_PIN8_Msk (0x1UL << GPIO_DIR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIR_PIN8_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN8_Output (1UL) /*!< Pin set as output */ - -/* Bit 7 : Pin 7 */ -#define GPIO_DIR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIR_PIN7_Msk (0x1UL << GPIO_DIR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIR_PIN7_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN7_Output (1UL) /*!< Pin set as output */ - -/* Bit 6 : Pin 6 */ -#define GPIO_DIR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIR_PIN6_Msk (0x1UL << GPIO_DIR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIR_PIN6_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN6_Output (1UL) /*!< Pin set as output */ - -/* Bit 5 : Pin 5 */ -#define GPIO_DIR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIR_PIN5_Msk (0x1UL << GPIO_DIR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIR_PIN5_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN5_Output (1UL) /*!< Pin set as output */ - -/* Bit 4 : Pin 4 */ -#define GPIO_DIR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIR_PIN4_Msk (0x1UL << GPIO_DIR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIR_PIN4_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN4_Output (1UL) /*!< Pin set as output */ - -/* Bit 3 : Pin 3 */ -#define GPIO_DIR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIR_PIN3_Msk (0x1UL << GPIO_DIR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIR_PIN3_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN3_Output (1UL) /*!< Pin set as output */ - -/* Bit 2 : Pin 2 */ -#define GPIO_DIR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIR_PIN2_Msk (0x1UL << GPIO_DIR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIR_PIN2_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN2_Output (1UL) /*!< Pin set as output */ - -/* Bit 1 : Pin 1 */ -#define GPIO_DIR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIR_PIN1_Msk (0x1UL << GPIO_DIR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIR_PIN1_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN1_Output (1UL) /*!< Pin set as output */ - -/* Bit 0 : Pin 0 */ -#define GPIO_DIR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIR_PIN0_Msk (0x1UL << GPIO_DIR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIR_PIN0_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN0_Output (1UL) /*!< Pin set as output */ - -/* Register: GPIO_DIRSET */ -/* Description: DIR set register */ - -/* Bit 31 : Set as output pin 31 */ -#define GPIO_DIRSET_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIRSET_PIN31_Msk (0x1UL << GPIO_DIRSET_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIRSET_PIN31_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN31_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN31_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 30 : Set as output pin 30 */ -#define GPIO_DIRSET_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIRSET_PIN30_Msk (0x1UL << GPIO_DIRSET_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIRSET_PIN30_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN30_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN30_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 29 : Set as output pin 29 */ -#define GPIO_DIRSET_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIRSET_PIN29_Msk (0x1UL << GPIO_DIRSET_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIRSET_PIN29_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN29_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN29_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 28 : Set as output pin 28 */ -#define GPIO_DIRSET_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIRSET_PIN28_Msk (0x1UL << GPIO_DIRSET_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIRSET_PIN28_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN28_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN28_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 27 : Set as output pin 27 */ -#define GPIO_DIRSET_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIRSET_PIN27_Msk (0x1UL << GPIO_DIRSET_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIRSET_PIN27_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN27_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN27_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 26 : Set as output pin 26 */ -#define GPIO_DIRSET_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIRSET_PIN26_Msk (0x1UL << GPIO_DIRSET_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIRSET_PIN26_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN26_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN26_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 25 : Set as output pin 25 */ -#define GPIO_DIRSET_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIRSET_PIN25_Msk (0x1UL << GPIO_DIRSET_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIRSET_PIN25_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN25_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN25_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 24 : Set as output pin 24 */ -#define GPIO_DIRSET_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIRSET_PIN24_Msk (0x1UL << GPIO_DIRSET_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIRSET_PIN24_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN24_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN24_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 23 : Set as output pin 23 */ -#define GPIO_DIRSET_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIRSET_PIN23_Msk (0x1UL << GPIO_DIRSET_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIRSET_PIN23_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN23_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN23_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 22 : Set as output pin 22 */ -#define GPIO_DIRSET_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIRSET_PIN22_Msk (0x1UL << GPIO_DIRSET_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIRSET_PIN22_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN22_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN22_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 21 : Set as output pin 21 */ -#define GPIO_DIRSET_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIRSET_PIN21_Msk (0x1UL << GPIO_DIRSET_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIRSET_PIN21_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN21_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN21_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 20 : Set as output pin 20 */ -#define GPIO_DIRSET_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIRSET_PIN20_Msk (0x1UL << GPIO_DIRSET_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIRSET_PIN20_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN20_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN20_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 19 : Set as output pin 19 */ -#define GPIO_DIRSET_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIRSET_PIN19_Msk (0x1UL << GPIO_DIRSET_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIRSET_PIN19_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN19_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN19_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 18 : Set as output pin 18 */ -#define GPIO_DIRSET_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIRSET_PIN18_Msk (0x1UL << GPIO_DIRSET_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIRSET_PIN18_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN18_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN18_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 17 : Set as output pin 17 */ -#define GPIO_DIRSET_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIRSET_PIN17_Msk (0x1UL << GPIO_DIRSET_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIRSET_PIN17_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN17_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN17_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 16 : Set as output pin 16 */ -#define GPIO_DIRSET_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIRSET_PIN16_Msk (0x1UL << GPIO_DIRSET_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIRSET_PIN16_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN16_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN16_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 15 : Set as output pin 15 */ -#define GPIO_DIRSET_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIRSET_PIN15_Msk (0x1UL << GPIO_DIRSET_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIRSET_PIN15_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN15_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN15_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 14 : Set as output pin 14 */ -#define GPIO_DIRSET_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIRSET_PIN14_Msk (0x1UL << GPIO_DIRSET_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIRSET_PIN14_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN14_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN14_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 13 : Set as output pin 13 */ -#define GPIO_DIRSET_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIRSET_PIN13_Msk (0x1UL << GPIO_DIRSET_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIRSET_PIN13_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN13_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN13_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 12 : Set as output pin 12 */ -#define GPIO_DIRSET_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIRSET_PIN12_Msk (0x1UL << GPIO_DIRSET_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIRSET_PIN12_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN12_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN12_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 11 : Set as output pin 11 */ -#define GPIO_DIRSET_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIRSET_PIN11_Msk (0x1UL << GPIO_DIRSET_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIRSET_PIN11_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN11_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN11_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 10 : Set as output pin 10 */ -#define GPIO_DIRSET_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIRSET_PIN10_Msk (0x1UL << GPIO_DIRSET_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIRSET_PIN10_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN10_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN10_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 9 : Set as output pin 9 */ -#define GPIO_DIRSET_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIRSET_PIN9_Msk (0x1UL << GPIO_DIRSET_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIRSET_PIN9_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN9_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN9_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 8 : Set as output pin 8 */ -#define GPIO_DIRSET_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIRSET_PIN8_Msk (0x1UL << GPIO_DIRSET_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIRSET_PIN8_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN8_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN8_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 7 : Set as output pin 7 */ -#define GPIO_DIRSET_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIRSET_PIN7_Msk (0x1UL << GPIO_DIRSET_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIRSET_PIN7_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN7_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN7_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 6 : Set as output pin 6 */ -#define GPIO_DIRSET_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIRSET_PIN6_Msk (0x1UL << GPIO_DIRSET_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIRSET_PIN6_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN6_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN6_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 5 : Set as output pin 5 */ -#define GPIO_DIRSET_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIRSET_PIN5_Msk (0x1UL << GPIO_DIRSET_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIRSET_PIN5_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN5_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN5_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 4 : Set as output pin 4 */ -#define GPIO_DIRSET_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIRSET_PIN4_Msk (0x1UL << GPIO_DIRSET_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIRSET_PIN4_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN4_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN4_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 3 : Set as output pin 3 */ -#define GPIO_DIRSET_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIRSET_PIN3_Msk (0x1UL << GPIO_DIRSET_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIRSET_PIN3_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN3_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN3_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 2 : Set as output pin 2 */ -#define GPIO_DIRSET_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIRSET_PIN2_Msk (0x1UL << GPIO_DIRSET_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIRSET_PIN2_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN2_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN2_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 1 : Set as output pin 1 */ -#define GPIO_DIRSET_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIRSET_PIN1_Msk (0x1UL << GPIO_DIRSET_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIRSET_PIN1_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN1_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN1_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 0 : Set as output pin 0 */ -#define GPIO_DIRSET_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIRSET_PIN0_Msk (0x1UL << GPIO_DIRSET_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIRSET_PIN0_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN0_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN0_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Register: GPIO_DIRCLR */ -/* Description: DIR clear register */ - -/* Bit 31 : Set as input pin 31 */ -#define GPIO_DIRCLR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIRCLR_PIN31_Msk (0x1UL << GPIO_DIRCLR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIRCLR_PIN31_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN31_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN31_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 30 : Set as input pin 30 */ -#define GPIO_DIRCLR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIRCLR_PIN30_Msk (0x1UL << GPIO_DIRCLR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIRCLR_PIN30_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN30_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN30_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 29 : Set as input pin 29 */ -#define GPIO_DIRCLR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIRCLR_PIN29_Msk (0x1UL << GPIO_DIRCLR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIRCLR_PIN29_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN29_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN29_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 28 : Set as input pin 28 */ -#define GPIO_DIRCLR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIRCLR_PIN28_Msk (0x1UL << GPIO_DIRCLR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIRCLR_PIN28_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN28_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN28_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 27 : Set as input pin 27 */ -#define GPIO_DIRCLR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIRCLR_PIN27_Msk (0x1UL << GPIO_DIRCLR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIRCLR_PIN27_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN27_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN27_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 26 : Set as input pin 26 */ -#define GPIO_DIRCLR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIRCLR_PIN26_Msk (0x1UL << GPIO_DIRCLR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIRCLR_PIN26_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN26_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN26_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 25 : Set as input pin 25 */ -#define GPIO_DIRCLR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIRCLR_PIN25_Msk (0x1UL << GPIO_DIRCLR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIRCLR_PIN25_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN25_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN25_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 24 : Set as input pin 24 */ -#define GPIO_DIRCLR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIRCLR_PIN24_Msk (0x1UL << GPIO_DIRCLR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIRCLR_PIN24_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN24_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN24_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 23 : Set as input pin 23 */ -#define GPIO_DIRCLR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIRCLR_PIN23_Msk (0x1UL << GPIO_DIRCLR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIRCLR_PIN23_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN23_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN23_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 22 : Set as input pin 22 */ -#define GPIO_DIRCLR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIRCLR_PIN22_Msk (0x1UL << GPIO_DIRCLR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIRCLR_PIN22_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN22_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN22_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 21 : Set as input pin 21 */ -#define GPIO_DIRCLR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIRCLR_PIN21_Msk (0x1UL << GPIO_DIRCLR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIRCLR_PIN21_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN21_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN21_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 20 : Set as input pin 20 */ -#define GPIO_DIRCLR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIRCLR_PIN20_Msk (0x1UL << GPIO_DIRCLR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIRCLR_PIN20_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN20_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN20_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 19 : Set as input pin 19 */ -#define GPIO_DIRCLR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIRCLR_PIN19_Msk (0x1UL << GPIO_DIRCLR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIRCLR_PIN19_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN19_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN19_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 18 : Set as input pin 18 */ -#define GPIO_DIRCLR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIRCLR_PIN18_Msk (0x1UL << GPIO_DIRCLR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIRCLR_PIN18_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN18_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN18_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 17 : Set as input pin 17 */ -#define GPIO_DIRCLR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIRCLR_PIN17_Msk (0x1UL << GPIO_DIRCLR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIRCLR_PIN17_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN17_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN17_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 16 : Set as input pin 16 */ -#define GPIO_DIRCLR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIRCLR_PIN16_Msk (0x1UL << GPIO_DIRCLR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIRCLR_PIN16_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN16_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN16_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 15 : Set as input pin 15 */ -#define GPIO_DIRCLR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIRCLR_PIN15_Msk (0x1UL << GPIO_DIRCLR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIRCLR_PIN15_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN15_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN15_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 14 : Set as input pin 14 */ -#define GPIO_DIRCLR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIRCLR_PIN14_Msk (0x1UL << GPIO_DIRCLR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIRCLR_PIN14_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN14_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN14_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 13 : Set as input pin 13 */ -#define GPIO_DIRCLR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIRCLR_PIN13_Msk (0x1UL << GPIO_DIRCLR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIRCLR_PIN13_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN13_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN13_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 12 : Set as input pin 12 */ -#define GPIO_DIRCLR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIRCLR_PIN12_Msk (0x1UL << GPIO_DIRCLR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIRCLR_PIN12_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN12_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN12_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 11 : Set as input pin 11 */ -#define GPIO_DIRCLR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIRCLR_PIN11_Msk (0x1UL << GPIO_DIRCLR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIRCLR_PIN11_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN11_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN11_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 10 : Set as input pin 10 */ -#define GPIO_DIRCLR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIRCLR_PIN10_Msk (0x1UL << GPIO_DIRCLR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIRCLR_PIN10_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN10_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN10_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 9 : Set as input pin 9 */ -#define GPIO_DIRCLR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIRCLR_PIN9_Msk (0x1UL << GPIO_DIRCLR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIRCLR_PIN9_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN9_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN9_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 8 : Set as input pin 8 */ -#define GPIO_DIRCLR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIRCLR_PIN8_Msk (0x1UL << GPIO_DIRCLR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIRCLR_PIN8_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN8_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN8_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 7 : Set as input pin 7 */ -#define GPIO_DIRCLR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIRCLR_PIN7_Msk (0x1UL << GPIO_DIRCLR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIRCLR_PIN7_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN7_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN7_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 6 : Set as input pin 6 */ -#define GPIO_DIRCLR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIRCLR_PIN6_Msk (0x1UL << GPIO_DIRCLR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIRCLR_PIN6_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN6_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN6_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 5 : Set as input pin 5 */ -#define GPIO_DIRCLR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIRCLR_PIN5_Msk (0x1UL << GPIO_DIRCLR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIRCLR_PIN5_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN5_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN5_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 4 : Set as input pin 4 */ -#define GPIO_DIRCLR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIRCLR_PIN4_Msk (0x1UL << GPIO_DIRCLR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIRCLR_PIN4_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN4_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN4_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 3 : Set as input pin 3 */ -#define GPIO_DIRCLR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIRCLR_PIN3_Msk (0x1UL << GPIO_DIRCLR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIRCLR_PIN3_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN3_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN3_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 2 : Set as input pin 2 */ -#define GPIO_DIRCLR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIRCLR_PIN2_Msk (0x1UL << GPIO_DIRCLR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIRCLR_PIN2_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN2_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN2_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 1 : Set as input pin 1 */ -#define GPIO_DIRCLR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIRCLR_PIN1_Msk (0x1UL << GPIO_DIRCLR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIRCLR_PIN1_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN1_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN1_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 0 : Set as input pin 0 */ -#define GPIO_DIRCLR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIRCLR_PIN0_Msk (0x1UL << GPIO_DIRCLR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIRCLR_PIN0_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN0_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN0_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Register: GPIO_LATCH */ -/* Description: Latch register indicating what GPIO pins that have met the criteria set in the PIN_CNF[n].SENSE registers */ - -/* Bit 31 : Status on whether PIN31 has met criteria set in PIN_CNF31.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_LATCH_PIN31_Msk (0x1UL << GPIO_LATCH_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_LATCH_PIN31_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN31_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 30 : Status on whether PIN30 has met criteria set in PIN_CNF30.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_LATCH_PIN30_Msk (0x1UL << GPIO_LATCH_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_LATCH_PIN30_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN30_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 29 : Status on whether PIN29 has met criteria set in PIN_CNF29.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_LATCH_PIN29_Msk (0x1UL << GPIO_LATCH_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_LATCH_PIN29_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN29_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 28 : Status on whether PIN28 has met criteria set in PIN_CNF28.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_LATCH_PIN28_Msk (0x1UL << GPIO_LATCH_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_LATCH_PIN28_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN28_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 27 : Status on whether PIN27 has met criteria set in PIN_CNF27.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_LATCH_PIN27_Msk (0x1UL << GPIO_LATCH_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_LATCH_PIN27_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN27_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 26 : Status on whether PIN26 has met criteria set in PIN_CNF26.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_LATCH_PIN26_Msk (0x1UL << GPIO_LATCH_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_LATCH_PIN26_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN26_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 25 : Status on whether PIN25 has met criteria set in PIN_CNF25.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_LATCH_PIN25_Msk (0x1UL << GPIO_LATCH_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_LATCH_PIN25_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN25_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 24 : Status on whether PIN24 has met criteria set in PIN_CNF24.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_LATCH_PIN24_Msk (0x1UL << GPIO_LATCH_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_LATCH_PIN24_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN24_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 23 : Status on whether PIN23 has met criteria set in PIN_CNF23.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_LATCH_PIN23_Msk (0x1UL << GPIO_LATCH_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_LATCH_PIN23_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN23_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 22 : Status on whether PIN22 has met criteria set in PIN_CNF22.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_LATCH_PIN22_Msk (0x1UL << GPIO_LATCH_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_LATCH_PIN22_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN22_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 21 : Status on whether PIN21 has met criteria set in PIN_CNF21.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_LATCH_PIN21_Msk (0x1UL << GPIO_LATCH_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_LATCH_PIN21_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN21_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 20 : Status on whether PIN20 has met criteria set in PIN_CNF20.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_LATCH_PIN20_Msk (0x1UL << GPIO_LATCH_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_LATCH_PIN20_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN20_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 19 : Status on whether PIN19 has met criteria set in PIN_CNF19.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_LATCH_PIN19_Msk (0x1UL << GPIO_LATCH_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_LATCH_PIN19_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN19_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 18 : Status on whether PIN18 has met criteria set in PIN_CNF18.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_LATCH_PIN18_Msk (0x1UL << GPIO_LATCH_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_LATCH_PIN18_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN18_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 17 : Status on whether PIN17 has met criteria set in PIN_CNF17.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_LATCH_PIN17_Msk (0x1UL << GPIO_LATCH_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_LATCH_PIN17_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN17_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 16 : Status on whether PIN16 has met criteria set in PIN_CNF16.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_LATCH_PIN16_Msk (0x1UL << GPIO_LATCH_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_LATCH_PIN16_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN16_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 15 : Status on whether PIN15 has met criteria set in PIN_CNF15.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_LATCH_PIN15_Msk (0x1UL << GPIO_LATCH_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_LATCH_PIN15_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN15_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 14 : Status on whether PIN14 has met criteria set in PIN_CNF14.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_LATCH_PIN14_Msk (0x1UL << GPIO_LATCH_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_LATCH_PIN14_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN14_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 13 : Status on whether PIN13 has met criteria set in PIN_CNF13.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_LATCH_PIN13_Msk (0x1UL << GPIO_LATCH_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_LATCH_PIN13_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN13_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 12 : Status on whether PIN12 has met criteria set in PIN_CNF12.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_LATCH_PIN12_Msk (0x1UL << GPIO_LATCH_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_LATCH_PIN12_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN12_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 11 : Status on whether PIN11 has met criteria set in PIN_CNF11.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_LATCH_PIN11_Msk (0x1UL << GPIO_LATCH_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_LATCH_PIN11_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN11_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 10 : Status on whether PIN10 has met criteria set in PIN_CNF10.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_LATCH_PIN10_Msk (0x1UL << GPIO_LATCH_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_LATCH_PIN10_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN10_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 9 : Status on whether PIN9 has met criteria set in PIN_CNF9.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_LATCH_PIN9_Msk (0x1UL << GPIO_LATCH_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_LATCH_PIN9_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN9_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 8 : Status on whether PIN8 has met criteria set in PIN_CNF8.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_LATCH_PIN8_Msk (0x1UL << GPIO_LATCH_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_LATCH_PIN8_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN8_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 7 : Status on whether PIN7 has met criteria set in PIN_CNF7.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_LATCH_PIN7_Msk (0x1UL << GPIO_LATCH_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_LATCH_PIN7_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN7_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 6 : Status on whether PIN6 has met criteria set in PIN_CNF6.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_LATCH_PIN6_Msk (0x1UL << GPIO_LATCH_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_LATCH_PIN6_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN6_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 5 : Status on whether PIN5 has met criteria set in PIN_CNF5.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_LATCH_PIN5_Msk (0x1UL << GPIO_LATCH_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_LATCH_PIN5_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN5_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 4 : Status on whether PIN4 has met criteria set in PIN_CNF4.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_LATCH_PIN4_Msk (0x1UL << GPIO_LATCH_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_LATCH_PIN4_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN4_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 3 : Status on whether PIN3 has met criteria set in PIN_CNF3.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_LATCH_PIN3_Msk (0x1UL << GPIO_LATCH_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_LATCH_PIN3_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN3_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 2 : Status on whether PIN2 has met criteria set in PIN_CNF2.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_LATCH_PIN2_Msk (0x1UL << GPIO_LATCH_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_LATCH_PIN2_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN2_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 1 : Status on whether PIN1 has met criteria set in PIN_CNF1.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_LATCH_PIN1_Msk (0x1UL << GPIO_LATCH_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_LATCH_PIN1_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN1_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 0 : Status on whether PIN0 has met criteria set in PIN_CNF0.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_LATCH_PIN0_Msk (0x1UL << GPIO_LATCH_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_LATCH_PIN0_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN0_Latched (1UL) /*!< Criteria has been met */ - -/* Register: GPIO_DETECTMODE */ -/* Description: Select between default DETECT signal behaviour and LDETECT mode */ - -/* Bit 0 : Select between default DETECT signal behaviour and LDETECT mode */ -#define GPIO_DETECTMODE_DETECTMODE_Pos (0UL) /*!< Position of DETECTMODE field. */ -#define GPIO_DETECTMODE_DETECTMODE_Msk (0x1UL << GPIO_DETECTMODE_DETECTMODE_Pos) /*!< Bit mask of DETECTMODE field. */ -#define GPIO_DETECTMODE_DETECTMODE_Default (0UL) /*!< DETECT directly connected to PIN DETECT signals */ -#define GPIO_DETECTMODE_DETECTMODE_LDETECT (1UL) /*!< Use the latched LDETECT behaviour */ - -/* Register: GPIO_PIN_CNF */ -/* Description: Description collection[0]: Configuration of GPIO pins */ - -/* Bits 17..16 : Pin sensing mechanism */ -#define GPIO_PIN_CNF_SENSE_Pos (16UL) /*!< Position of SENSE field. */ -#define GPIO_PIN_CNF_SENSE_Msk (0x3UL << GPIO_PIN_CNF_SENSE_Pos) /*!< Bit mask of SENSE field. */ -#define GPIO_PIN_CNF_SENSE_Disabled (0UL) /*!< Disabled */ -#define GPIO_PIN_CNF_SENSE_High (2UL) /*!< Sense for high level */ -#define GPIO_PIN_CNF_SENSE_Low (3UL) /*!< Sense for low level */ - -/* Bits 10..8 : Drive configuration */ -#define GPIO_PIN_CNF_DRIVE_Pos (8UL) /*!< Position of DRIVE field. */ -#define GPIO_PIN_CNF_DRIVE_Msk (0x7UL << GPIO_PIN_CNF_DRIVE_Pos) /*!< Bit mask of DRIVE field. */ -#define GPIO_PIN_CNF_DRIVE_S0S1 (0UL) /*!< Standard '0', standard '1' */ -#define GPIO_PIN_CNF_DRIVE_H0S1 (1UL) /*!< High drive '0', standard '1' */ -#define GPIO_PIN_CNF_DRIVE_S0H1 (2UL) /*!< Standard '0', high drive '1' */ -#define GPIO_PIN_CNF_DRIVE_H0H1 (3UL) /*!< High drive '0', high 'drive '1'' */ -#define GPIO_PIN_CNF_DRIVE_D0S1 (4UL) /*!< Disconnect '0' standard '1' (normally used for wired-or connections) */ -#define GPIO_PIN_CNF_DRIVE_D0H1 (5UL) /*!< Disconnect '0', high drive '1' (normally used for wired-or connections) */ -#define GPIO_PIN_CNF_DRIVE_S0D1 (6UL) /*!< Standard '0'. disconnect '1' (normally used for wired-and connections) */ -#define GPIO_PIN_CNF_DRIVE_H0D1 (7UL) /*!< High drive '0', disconnect '1' (normally used for wired-and connections) */ - -/* Bits 3..2 : Pull configuration */ -#define GPIO_PIN_CNF_PULL_Pos (2UL) /*!< Position of PULL field. */ -#define GPIO_PIN_CNF_PULL_Msk (0x3UL << GPIO_PIN_CNF_PULL_Pos) /*!< Bit mask of PULL field. */ -#define GPIO_PIN_CNF_PULL_Disabled (0UL) /*!< No pull */ -#define GPIO_PIN_CNF_PULL_Pulldown (1UL) /*!< Pull down on pin */ -#define GPIO_PIN_CNF_PULL_Pullup (3UL) /*!< Pull up on pin */ - -/* Bit 1 : Connect or disconnect input buffer */ -#define GPIO_PIN_CNF_INPUT_Pos (1UL) /*!< Position of INPUT field. */ -#define GPIO_PIN_CNF_INPUT_Msk (0x1UL << GPIO_PIN_CNF_INPUT_Pos) /*!< Bit mask of INPUT field. */ -#define GPIO_PIN_CNF_INPUT_Connect (0UL) /*!< Connect input buffer */ -#define GPIO_PIN_CNF_INPUT_Disconnect (1UL) /*!< Disconnect input buffer */ - -/* Bit 0 : Pin direction. Same physical register as DIR register */ -#define GPIO_PIN_CNF_DIR_Pos (0UL) /*!< Position of DIR field. */ -#define GPIO_PIN_CNF_DIR_Msk (0x1UL << GPIO_PIN_CNF_DIR_Pos) /*!< Bit mask of DIR field. */ -#define GPIO_PIN_CNF_DIR_Input (0UL) /*!< Configure pin as an input pin */ -#define GPIO_PIN_CNF_DIR_Output (1UL) /*!< Configure pin as an output pin */ - - -/* Peripheral: PDM */ -/* Description: Pulse Density Modulation (Digital Microphone) Interface */ - -/* Register: PDM_TASKS_START */ -/* Description: Starts continuous PDM transfer */ - -/* Bit 0 : */ -#define PDM_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define PDM_TASKS_START_TASKS_START_Msk (0x1UL << PDM_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: PDM_TASKS_STOP */ -/* Description: Stops PDM transfer */ - -/* Bit 0 : */ -#define PDM_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define PDM_TASKS_STOP_TASKS_STOP_Msk (0x1UL << PDM_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: PDM_EVENTS_STARTED */ -/* Description: PDM transfer has started */ - -/* Bit 0 : */ -#define PDM_EVENTS_STARTED_EVENTS_STARTED_Pos (0UL) /*!< Position of EVENTS_STARTED field. */ -#define PDM_EVENTS_STARTED_EVENTS_STARTED_Msk (0x1UL << PDM_EVENTS_STARTED_EVENTS_STARTED_Pos) /*!< Bit mask of EVENTS_STARTED field. */ - -/* Register: PDM_EVENTS_STOPPED */ -/* Description: PDM transfer has finished */ - -/* Bit 0 : */ -#define PDM_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define PDM_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << PDM_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: PDM_EVENTS_END */ -/* Description: The PDM has written the last sample specified by SAMPLE.MAXCNT (or the last sample after a STOP task has been received) to Data RAM */ - -/* Bit 0 : */ -#define PDM_EVENTS_END_EVENTS_END_Pos (0UL) /*!< Position of EVENTS_END field. */ -#define PDM_EVENTS_END_EVENTS_END_Msk (0x1UL << PDM_EVENTS_END_EVENTS_END_Pos) /*!< Bit mask of EVENTS_END field. */ - -/* Register: PDM_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 2 : Enable or disable interrupt for END event */ -#define PDM_INTEN_END_Pos (2UL) /*!< Position of END field. */ -#define PDM_INTEN_END_Msk (0x1UL << PDM_INTEN_END_Pos) /*!< Bit mask of END field. */ -#define PDM_INTEN_END_Disabled (0UL) /*!< Disable */ -#define PDM_INTEN_END_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define PDM_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PDM_INTEN_STOPPED_Msk (0x1UL << PDM_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PDM_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define PDM_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for STARTED event */ -#define PDM_INTEN_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define PDM_INTEN_STARTED_Msk (0x1UL << PDM_INTEN_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define PDM_INTEN_STARTED_Disabled (0UL) /*!< Disable */ -#define PDM_INTEN_STARTED_Enabled (1UL) /*!< Enable */ - -/* Register: PDM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for END event */ -#define PDM_INTENSET_END_Pos (2UL) /*!< Position of END field. */ -#define PDM_INTENSET_END_Msk (0x1UL << PDM_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define PDM_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define PDM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PDM_INTENSET_STOPPED_Msk (0x1UL << PDM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PDM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for STARTED event */ -#define PDM_INTENSET_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define PDM_INTENSET_STARTED_Msk (0x1UL << PDM_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define PDM_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Register: PDM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for END event */ -#define PDM_INTENCLR_END_Pos (2UL) /*!< Position of END field. */ -#define PDM_INTENCLR_END_Msk (0x1UL << PDM_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define PDM_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define PDM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PDM_INTENCLR_STOPPED_Msk (0x1UL << PDM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PDM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for STARTED event */ -#define PDM_INTENCLR_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define PDM_INTENCLR_STARTED_Msk (0x1UL << PDM_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define PDM_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Register: PDM_ENABLE */ -/* Description: PDM module enable register */ - -/* Bit 0 : Enable or disable PDM module */ -#define PDM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define PDM_ENABLE_ENABLE_Msk (0x1UL << PDM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define PDM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define PDM_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: PDM_PDMCLKCTRL */ -/* Description: PDM clock generator control */ - -/* Bits 31..0 : PDM_CLK frequency */ -#define PDM_PDMCLKCTRL_FREQ_Pos (0UL) /*!< Position of FREQ field. */ -#define PDM_PDMCLKCTRL_FREQ_Msk (0xFFFFFFFFUL << PDM_PDMCLKCTRL_FREQ_Pos) /*!< Bit mask of FREQ field. */ -#define PDM_PDMCLKCTRL_FREQ_1000K (0x08000000UL) /*!< PDM_CLK = 32 MHz / 32 = 1.000 MHz */ -#define PDM_PDMCLKCTRL_FREQ_Default (0x08400000UL) /*!< PDM_CLK = 32 MHz / 31 = 1.032 MHz */ -#define PDM_PDMCLKCTRL_FREQ_1067K (0x08800000UL) /*!< PDM_CLK = 32 MHz / 30 = 1.067 MHz */ - -/* Register: PDM_MODE */ -/* Description: Defines the routing of the connected PDM microphones' signals */ - -/* Bit 1 : Defines on which PDM_CLK edge Left (or mono) is sampled */ -#define PDM_MODE_EDGE_Pos (1UL) /*!< Position of EDGE field. */ -#define PDM_MODE_EDGE_Msk (0x1UL << PDM_MODE_EDGE_Pos) /*!< Bit mask of EDGE field. */ -#define PDM_MODE_EDGE_LeftFalling (0UL) /*!< Left (or mono) is sampled on falling edge of PDM_CLK */ -#define PDM_MODE_EDGE_LeftRising (1UL) /*!< Left (or mono) is sampled on rising edge of PDM_CLK */ - -/* Bit 0 : Mono or stereo operation */ -#define PDM_MODE_OPERATION_Pos (0UL) /*!< Position of OPERATION field. */ -#define PDM_MODE_OPERATION_Msk (0x1UL << PDM_MODE_OPERATION_Pos) /*!< Bit mask of OPERATION field. */ -#define PDM_MODE_OPERATION_Stereo (0UL) /*!< Sample and store one pair (Left + Right) of 16bit samples per RAM word R=[31:16]; L=[15:0] */ -#define PDM_MODE_OPERATION_Mono (1UL) /*!< Sample and store two successive Left samples (16 bit each) per RAM word L1=[31:16]; L0=[15:0] */ - -/* Register: PDM_GAINL */ -/* Description: Left output gain adjustment */ - -/* Bits 6..0 : Left output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -19.5 dB gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain adjust 0x29 +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 +20 dB gain adjust */ -#define PDM_GAINL_GAINL_Pos (0UL) /*!< Position of GAINL field. */ -#define PDM_GAINL_GAINL_Msk (0x7FUL << PDM_GAINL_GAINL_Pos) /*!< Bit mask of GAINL field. */ -#define PDM_GAINL_GAINL_MinGain (0x00UL) /*!< -20dB gain adjustment (minimum) */ -#define PDM_GAINL_GAINL_DefaultGain (0x28UL) /*!< 0dB gain adjustment ('2500 RMS' requirement) */ -#define PDM_GAINL_GAINL_MaxGain (0x50UL) /*!< +20dB gain adjustment (maximum) */ - -/* Register: PDM_GAINR */ -/* Description: Right output gain adjustment */ - -/* Bits 7..0 : Right output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters) */ -#define PDM_GAINR_GAINR_Pos (0UL) /*!< Position of GAINR field. */ -#define PDM_GAINR_GAINR_Msk (0xFFUL << PDM_GAINR_GAINR_Pos) /*!< Bit mask of GAINR field. */ -#define PDM_GAINR_GAINR_MinGain (0x00UL) /*!< -20dB gain adjustment (minimum) */ -#define PDM_GAINR_GAINR_DefaultGain (0x28UL) /*!< 0dB gain adjustment ('2500 RMS' requirement) */ -#define PDM_GAINR_GAINR_MaxGain (0x50UL) /*!< +20dB gain adjustment (maximum) */ - -/* Register: PDM_PSEL_CLK */ -/* Description: Pin number configuration for PDM CLK signal */ - -/* Bit 31 : Connection */ -#define PDM_PSEL_CLK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define PDM_PSEL_CLK_CONNECT_Msk (0x1UL << PDM_PSEL_CLK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define PDM_PSEL_CLK_CONNECT_Connected (0UL) /*!< Connect */ -#define PDM_PSEL_CLK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define PDM_PSEL_CLK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define PDM_PSEL_CLK_PIN_Msk (0x1FUL << PDM_PSEL_CLK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: PDM_PSEL_DIN */ -/* Description: Pin number configuration for PDM DIN signal */ - -/* Bit 31 : Connection */ -#define PDM_PSEL_DIN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define PDM_PSEL_DIN_CONNECT_Msk (0x1UL << PDM_PSEL_DIN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define PDM_PSEL_DIN_CONNECT_Connected (0UL) /*!< Connect */ -#define PDM_PSEL_DIN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define PDM_PSEL_DIN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define PDM_PSEL_DIN_PIN_Msk (0x1FUL << PDM_PSEL_DIN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: PDM_SAMPLE_PTR */ -/* Description: RAM address pointer to write samples to with EasyDMA */ - -/* Bits 31..0 : Address to write PDM samples to over DMA */ -#define PDM_SAMPLE_PTR_SAMPLEPTR_Pos (0UL) /*!< Position of SAMPLEPTR field. */ -#define PDM_SAMPLE_PTR_SAMPLEPTR_Msk (0xFFFFFFFFUL << PDM_SAMPLE_PTR_SAMPLEPTR_Pos) /*!< Bit mask of SAMPLEPTR field. */ - -/* Register: PDM_SAMPLE_MAXCNT */ -/* Description: Number of samples to allocate memory for in EasyDMA mode */ - -/* Bits 14..0 : Length of DMA RAM allocation in number of samples */ -#define PDM_SAMPLE_MAXCNT_BUFFSIZE_Pos (0UL) /*!< Position of BUFFSIZE field. */ -#define PDM_SAMPLE_MAXCNT_BUFFSIZE_Msk (0x7FFFUL << PDM_SAMPLE_MAXCNT_BUFFSIZE_Pos) /*!< Bit mask of BUFFSIZE field. */ - - -/* Peripheral: POWER */ -/* Description: Power control */ - -/* Register: POWER_TASKS_CONSTLAT */ -/* Description: Enable constant latency mode */ - -/* Bit 0 : */ -#define POWER_TASKS_CONSTLAT_TASKS_CONSTLAT_Pos (0UL) /*!< Position of TASKS_CONSTLAT field. */ -#define POWER_TASKS_CONSTLAT_TASKS_CONSTLAT_Msk (0x1UL << POWER_TASKS_CONSTLAT_TASKS_CONSTLAT_Pos) /*!< Bit mask of TASKS_CONSTLAT field. */ - -/* Register: POWER_TASKS_LOWPWR */ -/* Description: Enable low power mode (variable latency) */ - -/* Bit 0 : */ -#define POWER_TASKS_LOWPWR_TASKS_LOWPWR_Pos (0UL) /*!< Position of TASKS_LOWPWR field. */ -#define POWER_TASKS_LOWPWR_TASKS_LOWPWR_Msk (0x1UL << POWER_TASKS_LOWPWR_TASKS_LOWPWR_Pos) /*!< Bit mask of TASKS_LOWPWR field. */ - -/* Register: POWER_EVENTS_POFWARN */ -/* Description: Power failure warning */ - -/* Bit 0 : */ -#define POWER_EVENTS_POFWARN_EVENTS_POFWARN_Pos (0UL) /*!< Position of EVENTS_POFWARN field. */ -#define POWER_EVENTS_POFWARN_EVENTS_POFWARN_Msk (0x1UL << POWER_EVENTS_POFWARN_EVENTS_POFWARN_Pos) /*!< Bit mask of EVENTS_POFWARN field. */ - -/* Register: POWER_EVENTS_SLEEPENTER */ -/* Description: CPU entered WFI/WFE sleep */ - -/* Bit 0 : */ -#define POWER_EVENTS_SLEEPENTER_EVENTS_SLEEPENTER_Pos (0UL) /*!< Position of EVENTS_SLEEPENTER field. */ -#define POWER_EVENTS_SLEEPENTER_EVENTS_SLEEPENTER_Msk (0x1UL << POWER_EVENTS_SLEEPENTER_EVENTS_SLEEPENTER_Pos) /*!< Bit mask of EVENTS_SLEEPENTER field. */ - -/* Register: POWER_EVENTS_SLEEPEXIT */ -/* Description: CPU exited WFI/WFE sleep */ - -/* Bit 0 : */ -#define POWER_EVENTS_SLEEPEXIT_EVENTS_SLEEPEXIT_Pos (0UL) /*!< Position of EVENTS_SLEEPEXIT field. */ -#define POWER_EVENTS_SLEEPEXIT_EVENTS_SLEEPEXIT_Msk (0x1UL << POWER_EVENTS_SLEEPEXIT_EVENTS_SLEEPEXIT_Pos) /*!< Bit mask of EVENTS_SLEEPEXIT field. */ - -/* Register: POWER_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 6 : Write '1' to Enable interrupt for SLEEPEXIT event */ -#define POWER_INTENSET_SLEEPEXIT_Pos (6UL) /*!< Position of SLEEPEXIT field. */ -#define POWER_INTENSET_SLEEPEXIT_Msk (0x1UL << POWER_INTENSET_SLEEPEXIT_Pos) /*!< Bit mask of SLEEPEXIT field. */ -#define POWER_INTENSET_SLEEPEXIT_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_SLEEPEXIT_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_SLEEPEXIT_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for SLEEPENTER event */ -#define POWER_INTENSET_SLEEPENTER_Pos (5UL) /*!< Position of SLEEPENTER field. */ -#define POWER_INTENSET_SLEEPENTER_Msk (0x1UL << POWER_INTENSET_SLEEPENTER_Pos) /*!< Bit mask of SLEEPENTER field. */ -#define POWER_INTENSET_SLEEPENTER_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_SLEEPENTER_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_SLEEPENTER_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for POFWARN event */ -#define POWER_INTENSET_POFWARN_Pos (2UL) /*!< Position of POFWARN field. */ -#define POWER_INTENSET_POFWARN_Msk (0x1UL << POWER_INTENSET_POFWARN_Pos) /*!< Bit mask of POFWARN field. */ -#define POWER_INTENSET_POFWARN_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_POFWARN_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_POFWARN_Set (1UL) /*!< Enable */ - -/* Register: POWER_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 6 : Write '1' to Disable interrupt for SLEEPEXIT event */ -#define POWER_INTENCLR_SLEEPEXIT_Pos (6UL) /*!< Position of SLEEPEXIT field. */ -#define POWER_INTENCLR_SLEEPEXIT_Msk (0x1UL << POWER_INTENCLR_SLEEPEXIT_Pos) /*!< Bit mask of SLEEPEXIT field. */ -#define POWER_INTENCLR_SLEEPEXIT_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_SLEEPEXIT_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_SLEEPEXIT_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for SLEEPENTER event */ -#define POWER_INTENCLR_SLEEPENTER_Pos (5UL) /*!< Position of SLEEPENTER field. */ -#define POWER_INTENCLR_SLEEPENTER_Msk (0x1UL << POWER_INTENCLR_SLEEPENTER_Pos) /*!< Bit mask of SLEEPENTER field. */ -#define POWER_INTENCLR_SLEEPENTER_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_SLEEPENTER_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_SLEEPENTER_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for POFWARN event */ -#define POWER_INTENCLR_POFWARN_Pos (2UL) /*!< Position of POFWARN field. */ -#define POWER_INTENCLR_POFWARN_Msk (0x1UL << POWER_INTENCLR_POFWARN_Pos) /*!< Bit mask of POFWARN field. */ -#define POWER_INTENCLR_POFWARN_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_POFWARN_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_POFWARN_Clear (1UL) /*!< Disable */ - -/* Register: POWER_RESETREAS */ -/* Description: Reset reason */ - -/* Bit 18 : Reset due to wake up from System OFF mode when wakeup is triggered from entering into debug interface mode */ -#define POWER_RESETREAS_DIF_Pos (18UL) /*!< Position of DIF field. */ -#define POWER_RESETREAS_DIF_Msk (0x1UL << POWER_RESETREAS_DIF_Pos) /*!< Bit mask of DIF field. */ -#define POWER_RESETREAS_DIF_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_DIF_Detected (1UL) /*!< Detected */ - -/* Bit 16 : Reset due to wake up from System OFF mode when wakeup is triggered from DETECT signal from GPIO */ -#define POWER_RESETREAS_OFF_Pos (16UL) /*!< Position of OFF field. */ -#define POWER_RESETREAS_OFF_Msk (0x1UL << POWER_RESETREAS_OFF_Pos) /*!< Bit mask of OFF field. */ -#define POWER_RESETREAS_OFF_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_OFF_Detected (1UL) /*!< Detected */ - -/* Bit 3 : Reset from CPU lock-up detected */ -#define POWER_RESETREAS_LOCKUP_Pos (3UL) /*!< Position of LOCKUP field. */ -#define POWER_RESETREAS_LOCKUP_Msk (0x1UL << POWER_RESETREAS_LOCKUP_Pos) /*!< Bit mask of LOCKUP field. */ -#define POWER_RESETREAS_LOCKUP_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_LOCKUP_Detected (1UL) /*!< Detected */ - -/* Bit 2 : Reset from soft reset detected */ -#define POWER_RESETREAS_SREQ_Pos (2UL) /*!< Position of SREQ field. */ -#define POWER_RESETREAS_SREQ_Msk (0x1UL << POWER_RESETREAS_SREQ_Pos) /*!< Bit mask of SREQ field. */ -#define POWER_RESETREAS_SREQ_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_SREQ_Detected (1UL) /*!< Detected */ - -/* Bit 1 : Reset from watchdog detected */ -#define POWER_RESETREAS_DOG_Pos (1UL) /*!< Position of DOG field. */ -#define POWER_RESETREAS_DOG_Msk (0x1UL << POWER_RESETREAS_DOG_Pos) /*!< Bit mask of DOG field. */ -#define POWER_RESETREAS_DOG_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_DOG_Detected (1UL) /*!< Detected */ - -/* Bit 0 : Reset from pin-reset detected */ -#define POWER_RESETREAS_RESETPIN_Pos (0UL) /*!< Position of RESETPIN field. */ -#define POWER_RESETREAS_RESETPIN_Msk (0x1UL << POWER_RESETREAS_RESETPIN_Pos) /*!< Bit mask of RESETPIN field. */ -#define POWER_RESETREAS_RESETPIN_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_RESETPIN_Detected (1UL) /*!< Detected */ - -/* Register: POWER_SYSTEMOFF */ -/* Description: System OFF register */ - -/* Bit 0 : Enable System OFF mode */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Pos (0UL) /*!< Position of SYSTEMOFF field. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Msk (0x1UL << POWER_SYSTEMOFF_SYSTEMOFF_Pos) /*!< Bit mask of SYSTEMOFF field. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Enter (1UL) /*!< Enable System OFF mode */ - -/* Register: POWER_POFCON */ -/* Description: Power failure comparator configuration */ - -/* Bits 4..1 : Power failure comparator threshold setting */ -#define POWER_POFCON_THRESHOLD_Pos (1UL) /*!< Position of THRESHOLD field. */ -#define POWER_POFCON_THRESHOLD_Msk (0xFUL << POWER_POFCON_THRESHOLD_Pos) /*!< Bit mask of THRESHOLD field. */ -#define POWER_POFCON_THRESHOLD_V17 (4UL) /*!< Set threshold to 1.7 V */ -#define POWER_POFCON_THRESHOLD_V18 (5UL) /*!< Set threshold to 1.8 V */ -#define POWER_POFCON_THRESHOLD_V19 (6UL) /*!< Set threshold to 1.9 V */ -#define POWER_POFCON_THRESHOLD_V20 (7UL) /*!< Set threshold to 2.0 V */ -#define POWER_POFCON_THRESHOLD_V21 (8UL) /*!< Set threshold to 2.1 V */ -#define POWER_POFCON_THRESHOLD_V22 (9UL) /*!< Set threshold to 2.2 V */ -#define POWER_POFCON_THRESHOLD_V23 (10UL) /*!< Set threshold to 2.3 V */ -#define POWER_POFCON_THRESHOLD_V24 (11UL) /*!< Set threshold to 2.4 V */ -#define POWER_POFCON_THRESHOLD_V25 (12UL) /*!< Set threshold to 2.5 V */ -#define POWER_POFCON_THRESHOLD_V26 (13UL) /*!< Set threshold to 2.6 V */ -#define POWER_POFCON_THRESHOLD_V27 (14UL) /*!< Set threshold to 2.7 V */ -#define POWER_POFCON_THRESHOLD_V28 (15UL) /*!< Set threshold to 2.8 V */ - -/* Bit 0 : Enable or disable power failure comparator */ -#define POWER_POFCON_POF_Pos (0UL) /*!< Position of POF field. */ -#define POWER_POFCON_POF_Msk (0x1UL << POWER_POFCON_POF_Pos) /*!< Bit mask of POF field. */ -#define POWER_POFCON_POF_Disabled (0UL) /*!< Disable */ -#define POWER_POFCON_POF_Enabled (1UL) /*!< Enable */ - -/* Register: POWER_GPREGRET */ -/* Description: General purpose retention register */ - -/* Bits 7..0 : General purpose retention register */ -#define POWER_GPREGRET_GPREGRET_Pos (0UL) /*!< Position of GPREGRET field. */ -#define POWER_GPREGRET_GPREGRET_Msk (0xFFUL << POWER_GPREGRET_GPREGRET_Pos) /*!< Bit mask of GPREGRET field. */ - -/* Register: POWER_GPREGRET2 */ -/* Description: General purpose retention register */ - -/* Bits 7..0 : General purpose retention register */ -#define POWER_GPREGRET2_GPREGRET_Pos (0UL) /*!< Position of GPREGRET field. */ -#define POWER_GPREGRET2_GPREGRET_Msk (0xFFUL << POWER_GPREGRET2_GPREGRET_Pos) /*!< Bit mask of GPREGRET field. */ - -/* Register: POWER_DCDCEN */ -/* Description: DC/DC enable register */ - -/* Bit 0 : Enable or disable DC/DC converter */ -#define POWER_DCDCEN_DCDCEN_Pos (0UL) /*!< Position of DCDCEN field. */ -#define POWER_DCDCEN_DCDCEN_Msk (0x1UL << POWER_DCDCEN_DCDCEN_Pos) /*!< Bit mask of DCDCEN field. */ -#define POWER_DCDCEN_DCDCEN_Disabled (0UL) /*!< Disable */ -#define POWER_DCDCEN_DCDCEN_Enabled (1UL) /*!< Enable */ - -/* Register: POWER_RAM_POWER */ -/* Description: Description cluster[0]: RAM0 power control register */ - -/* Bit 17 : Keep retention on RAM section S1 when RAM section is in OFF */ -#define POWER_RAM_POWER_S1RETENTION_Pos (17UL) /*!< Position of S1RETENTION field. */ -#define POWER_RAM_POWER_S1RETENTION_Msk (0x1UL << POWER_RAM_POWER_S1RETENTION_Pos) /*!< Bit mask of S1RETENTION field. */ -#define POWER_RAM_POWER_S1RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S1RETENTION_On (1UL) /*!< On */ - -/* Bit 16 : Keep retention on RAM section S0 when RAM section is in OFF */ -#define POWER_RAM_POWER_S0RETENTION_Pos (16UL) /*!< Position of S0RETENTION field. */ -#define POWER_RAM_POWER_S0RETENTION_Msk (0x1UL << POWER_RAM_POWER_S0RETENTION_Pos) /*!< Bit mask of S0RETENTION field. */ -#define POWER_RAM_POWER_S0RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S0RETENTION_On (1UL) /*!< On */ - -/* Bit 1 : Keep RAM section S1 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S1POWER_Pos (1UL) /*!< Position of S1POWER field. */ -#define POWER_RAM_POWER_S1POWER_Msk (0x1UL << POWER_RAM_POWER_S1POWER_Pos) /*!< Bit mask of S1POWER field. */ -#define POWER_RAM_POWER_S1POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S1POWER_On (1UL) /*!< On */ - -/* Bit 0 : Keep RAM section S0 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S0POWER_Pos (0UL) /*!< Position of S0POWER field. */ -#define POWER_RAM_POWER_S0POWER_Msk (0x1UL << POWER_RAM_POWER_S0POWER_Pos) /*!< Bit mask of S0POWER field. */ -#define POWER_RAM_POWER_S0POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S0POWER_On (1UL) /*!< On */ - -/* Register: POWER_RAM_POWERSET */ -/* Description: Description cluster[0]: RAM0 power control set register */ - -/* Bit 17 : Keep retention on RAM section S1 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S1RETENTION_Pos (17UL) /*!< Position of S1RETENTION field. */ -#define POWER_RAM_POWERSET_S1RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S1RETENTION_Pos) /*!< Bit mask of S1RETENTION field. */ -#define POWER_RAM_POWERSET_S1RETENTION_On (1UL) /*!< On */ - -/* Bit 16 : Keep retention on RAM section S0 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S0RETENTION_Pos (16UL) /*!< Position of S0RETENTION field. */ -#define POWER_RAM_POWERSET_S0RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S0RETENTION_Pos) /*!< Bit mask of S0RETENTION field. */ -#define POWER_RAM_POWERSET_S0RETENTION_On (1UL) /*!< On */ - -/* Bit 1 : Keep RAM section S1 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S1POWER_Pos (1UL) /*!< Position of S1POWER field. */ -#define POWER_RAM_POWERSET_S1POWER_Msk (0x1UL << POWER_RAM_POWERSET_S1POWER_Pos) /*!< Bit mask of S1POWER field. */ -#define POWER_RAM_POWERSET_S1POWER_On (1UL) /*!< On */ - -/* Bit 0 : Keep RAM section S0 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S0POWER_Pos (0UL) /*!< Position of S0POWER field. */ -#define POWER_RAM_POWERSET_S0POWER_Msk (0x1UL << POWER_RAM_POWERSET_S0POWER_Pos) /*!< Bit mask of S0POWER field. */ -#define POWER_RAM_POWERSET_S0POWER_On (1UL) /*!< On */ - -/* Register: POWER_RAM_POWERCLR */ -/* Description: Description cluster[0]: RAM0 power control clear register */ - -/* Bit 17 : Keep retention on RAM section S1 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S1RETENTION_Pos (17UL) /*!< Position of S1RETENTION field. */ -#define POWER_RAM_POWERCLR_S1RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S1RETENTION_Pos) /*!< Bit mask of S1RETENTION field. */ -#define POWER_RAM_POWERCLR_S1RETENTION_Off (1UL) /*!< Off */ - -/* Bit 16 : Keep retention on RAM section S0 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S0RETENTION_Pos (16UL) /*!< Position of S0RETENTION field. */ -#define POWER_RAM_POWERCLR_S0RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S0RETENTION_Pos) /*!< Bit mask of S0RETENTION field. */ -#define POWER_RAM_POWERCLR_S0RETENTION_Off (1UL) /*!< Off */ - -/* Bit 1 : Keep RAM section S1 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S1POWER_Pos (1UL) /*!< Position of S1POWER field. */ -#define POWER_RAM_POWERCLR_S1POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S1POWER_Pos) /*!< Bit mask of S1POWER field. */ -#define POWER_RAM_POWERCLR_S1POWER_Off (1UL) /*!< Off */ - -/* Bit 0 : Keep RAM section S0 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S0POWER_Pos (0UL) /*!< Position of S0POWER field. */ -#define POWER_RAM_POWERCLR_S0POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S0POWER_Pos) /*!< Bit mask of S0POWER field. */ -#define POWER_RAM_POWERCLR_S0POWER_Off (1UL) /*!< Off */ - - -/* Peripheral: PPI */ -/* Description: Programmable Peripheral Interconnect */ - -/* Register: PPI_TASKS_CHG_EN */ -/* Description: Description cluster[0]: Enable channel group 0 */ - -/* Bit 0 : */ -#define PPI_TASKS_CHG_EN_EN_Pos (0UL) /*!< Position of EN field. */ -#define PPI_TASKS_CHG_EN_EN_Msk (0x1UL << PPI_TASKS_CHG_EN_EN_Pos) /*!< Bit mask of EN field. */ - -/* Register: PPI_TASKS_CHG_DIS */ -/* Description: Description cluster[0]: Disable channel group 0 */ - -/* Bit 0 : */ -#define PPI_TASKS_CHG_DIS_DIS_Pos (0UL) /*!< Position of DIS field. */ -#define PPI_TASKS_CHG_DIS_DIS_Msk (0x1UL << PPI_TASKS_CHG_DIS_DIS_Pos) /*!< Bit mask of DIS field. */ - -/* Register: PPI_CHEN */ -/* Description: Channel enable register */ - -/* Bit 31 : Enable or disable channel 31 */ -#define PPI_CHEN_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHEN_CH31_Msk (0x1UL << PPI_CHEN_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHEN_CH31_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH31_Enabled (1UL) /*!< Enable channel */ - -/* Bit 30 : Enable or disable channel 30 */ -#define PPI_CHEN_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHEN_CH30_Msk (0x1UL << PPI_CHEN_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHEN_CH30_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH30_Enabled (1UL) /*!< Enable channel */ - -/* Bit 29 : Enable or disable channel 29 */ -#define PPI_CHEN_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHEN_CH29_Msk (0x1UL << PPI_CHEN_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHEN_CH29_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH29_Enabled (1UL) /*!< Enable channel */ - -/* Bit 28 : Enable or disable channel 28 */ -#define PPI_CHEN_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHEN_CH28_Msk (0x1UL << PPI_CHEN_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHEN_CH28_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH28_Enabled (1UL) /*!< Enable channel */ - -/* Bit 27 : Enable or disable channel 27 */ -#define PPI_CHEN_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHEN_CH27_Msk (0x1UL << PPI_CHEN_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHEN_CH27_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH27_Enabled (1UL) /*!< Enable channel */ - -/* Bit 26 : Enable or disable channel 26 */ -#define PPI_CHEN_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHEN_CH26_Msk (0x1UL << PPI_CHEN_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHEN_CH26_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH26_Enabled (1UL) /*!< Enable channel */ - -/* Bit 25 : Enable or disable channel 25 */ -#define PPI_CHEN_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHEN_CH25_Msk (0x1UL << PPI_CHEN_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHEN_CH25_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH25_Enabled (1UL) /*!< Enable channel */ - -/* Bit 24 : Enable or disable channel 24 */ -#define PPI_CHEN_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHEN_CH24_Msk (0x1UL << PPI_CHEN_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHEN_CH24_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH24_Enabled (1UL) /*!< Enable channel */ - -/* Bit 23 : Enable or disable channel 23 */ -#define PPI_CHEN_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHEN_CH23_Msk (0x1UL << PPI_CHEN_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHEN_CH23_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH23_Enabled (1UL) /*!< Enable channel */ - -/* Bit 22 : Enable or disable channel 22 */ -#define PPI_CHEN_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHEN_CH22_Msk (0x1UL << PPI_CHEN_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHEN_CH22_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH22_Enabled (1UL) /*!< Enable channel */ - -/* Bit 21 : Enable or disable channel 21 */ -#define PPI_CHEN_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHEN_CH21_Msk (0x1UL << PPI_CHEN_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHEN_CH21_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH21_Enabled (1UL) /*!< Enable channel */ - -/* Bit 20 : Enable or disable channel 20 */ -#define PPI_CHEN_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHEN_CH20_Msk (0x1UL << PPI_CHEN_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHEN_CH20_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH20_Enabled (1UL) /*!< Enable channel */ - -/* Bit 19 : Enable or disable channel 19 */ -#define PPI_CHEN_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHEN_CH19_Msk (0x1UL << PPI_CHEN_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHEN_CH19_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH19_Enabled (1UL) /*!< Enable channel */ - -/* Bit 18 : Enable or disable channel 18 */ -#define PPI_CHEN_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHEN_CH18_Msk (0x1UL << PPI_CHEN_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHEN_CH18_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH18_Enabled (1UL) /*!< Enable channel */ - -/* Bit 17 : Enable or disable channel 17 */ -#define PPI_CHEN_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHEN_CH17_Msk (0x1UL << PPI_CHEN_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHEN_CH17_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH17_Enabled (1UL) /*!< Enable channel */ - -/* Bit 16 : Enable or disable channel 16 */ -#define PPI_CHEN_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHEN_CH16_Msk (0x1UL << PPI_CHEN_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHEN_CH16_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH16_Enabled (1UL) /*!< Enable channel */ - -/* Bit 15 : Enable or disable channel 15 */ -#define PPI_CHEN_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHEN_CH15_Msk (0x1UL << PPI_CHEN_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHEN_CH15_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH15_Enabled (1UL) /*!< Enable channel */ - -/* Bit 14 : Enable or disable channel 14 */ -#define PPI_CHEN_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHEN_CH14_Msk (0x1UL << PPI_CHEN_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHEN_CH14_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH14_Enabled (1UL) /*!< Enable channel */ - -/* Bit 13 : Enable or disable channel 13 */ -#define PPI_CHEN_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHEN_CH13_Msk (0x1UL << PPI_CHEN_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHEN_CH13_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH13_Enabled (1UL) /*!< Enable channel */ - -/* Bit 12 : Enable or disable channel 12 */ -#define PPI_CHEN_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHEN_CH12_Msk (0x1UL << PPI_CHEN_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHEN_CH12_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH12_Enabled (1UL) /*!< Enable channel */ - -/* Bit 11 : Enable or disable channel 11 */ -#define PPI_CHEN_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHEN_CH11_Msk (0x1UL << PPI_CHEN_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHEN_CH11_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH11_Enabled (1UL) /*!< Enable channel */ - -/* Bit 10 : Enable or disable channel 10 */ -#define PPI_CHEN_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHEN_CH10_Msk (0x1UL << PPI_CHEN_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHEN_CH10_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH10_Enabled (1UL) /*!< Enable channel */ - -/* Bit 9 : Enable or disable channel 9 */ -#define PPI_CHEN_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHEN_CH9_Msk (0x1UL << PPI_CHEN_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHEN_CH9_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH9_Enabled (1UL) /*!< Enable channel */ - -/* Bit 8 : Enable or disable channel 8 */ -#define PPI_CHEN_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHEN_CH8_Msk (0x1UL << PPI_CHEN_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHEN_CH8_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH8_Enabled (1UL) /*!< Enable channel */ - -/* Bit 7 : Enable or disable channel 7 */ -#define PPI_CHEN_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHEN_CH7_Msk (0x1UL << PPI_CHEN_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHEN_CH7_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH7_Enabled (1UL) /*!< Enable channel */ - -/* Bit 6 : Enable or disable channel 6 */ -#define PPI_CHEN_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHEN_CH6_Msk (0x1UL << PPI_CHEN_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHEN_CH6_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH6_Enabled (1UL) /*!< Enable channel */ - -/* Bit 5 : Enable or disable channel 5 */ -#define PPI_CHEN_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHEN_CH5_Msk (0x1UL << PPI_CHEN_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHEN_CH5_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH5_Enabled (1UL) /*!< Enable channel */ - -/* Bit 4 : Enable or disable channel 4 */ -#define PPI_CHEN_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHEN_CH4_Msk (0x1UL << PPI_CHEN_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHEN_CH4_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH4_Enabled (1UL) /*!< Enable channel */ - -/* Bit 3 : Enable or disable channel 3 */ -#define PPI_CHEN_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHEN_CH3_Msk (0x1UL << PPI_CHEN_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHEN_CH3_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH3_Enabled (1UL) /*!< Enable channel */ - -/* Bit 2 : Enable or disable channel 2 */ -#define PPI_CHEN_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHEN_CH2_Msk (0x1UL << PPI_CHEN_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHEN_CH2_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH2_Enabled (1UL) /*!< Enable channel */ - -/* Bit 1 : Enable or disable channel 1 */ -#define PPI_CHEN_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHEN_CH1_Msk (0x1UL << PPI_CHEN_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHEN_CH1_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH1_Enabled (1UL) /*!< Enable channel */ - -/* Bit 0 : Enable or disable channel 0 */ -#define PPI_CHEN_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHEN_CH0_Msk (0x1UL << PPI_CHEN_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHEN_CH0_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH0_Enabled (1UL) /*!< Enable channel */ - -/* Register: PPI_CHENSET */ -/* Description: Channel enable set register */ - -/* Bit 31 : Channel 31 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHENSET_CH31_Msk (0x1UL << PPI_CHENSET_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHENSET_CH31_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH31_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH31_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 30 : Channel 30 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHENSET_CH30_Msk (0x1UL << PPI_CHENSET_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHENSET_CH30_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH30_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH30_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 29 : Channel 29 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHENSET_CH29_Msk (0x1UL << PPI_CHENSET_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHENSET_CH29_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH29_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH29_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 28 : Channel 28 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHENSET_CH28_Msk (0x1UL << PPI_CHENSET_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHENSET_CH28_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH28_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH28_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 27 : Channel 27 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHENSET_CH27_Msk (0x1UL << PPI_CHENSET_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHENSET_CH27_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH27_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH27_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 26 : Channel 26 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHENSET_CH26_Msk (0x1UL << PPI_CHENSET_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHENSET_CH26_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH26_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH26_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 25 : Channel 25 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHENSET_CH25_Msk (0x1UL << PPI_CHENSET_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHENSET_CH25_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH25_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH25_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 24 : Channel 24 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHENSET_CH24_Msk (0x1UL << PPI_CHENSET_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHENSET_CH24_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH24_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH24_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 23 : Channel 23 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHENSET_CH23_Msk (0x1UL << PPI_CHENSET_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHENSET_CH23_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH23_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH23_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 22 : Channel 22 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHENSET_CH22_Msk (0x1UL << PPI_CHENSET_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHENSET_CH22_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH22_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH22_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 21 : Channel 21 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHENSET_CH21_Msk (0x1UL << PPI_CHENSET_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHENSET_CH21_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH21_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH21_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 20 : Channel 20 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHENSET_CH20_Msk (0x1UL << PPI_CHENSET_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHENSET_CH20_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH20_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH20_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 19 : Channel 19 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHENSET_CH19_Msk (0x1UL << PPI_CHENSET_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHENSET_CH19_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH19_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH19_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 18 : Channel 18 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHENSET_CH18_Msk (0x1UL << PPI_CHENSET_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHENSET_CH18_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH18_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH18_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 17 : Channel 17 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHENSET_CH17_Msk (0x1UL << PPI_CHENSET_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHENSET_CH17_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH17_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH17_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 16 : Channel 16 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHENSET_CH16_Msk (0x1UL << PPI_CHENSET_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHENSET_CH16_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH16_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH16_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 15 : Channel 15 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHENSET_CH15_Msk (0x1UL << PPI_CHENSET_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHENSET_CH15_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH15_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH15_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 14 : Channel 14 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHENSET_CH14_Msk (0x1UL << PPI_CHENSET_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHENSET_CH14_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH14_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH14_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 13 : Channel 13 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHENSET_CH13_Msk (0x1UL << PPI_CHENSET_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHENSET_CH13_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH13_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH13_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 12 : Channel 12 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHENSET_CH12_Msk (0x1UL << PPI_CHENSET_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHENSET_CH12_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH12_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH12_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 11 : Channel 11 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHENSET_CH11_Msk (0x1UL << PPI_CHENSET_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHENSET_CH11_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH11_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH11_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 10 : Channel 10 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHENSET_CH10_Msk (0x1UL << PPI_CHENSET_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHENSET_CH10_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH10_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH10_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 9 : Channel 9 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHENSET_CH9_Msk (0x1UL << PPI_CHENSET_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHENSET_CH9_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH9_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH9_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 8 : Channel 8 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHENSET_CH8_Msk (0x1UL << PPI_CHENSET_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHENSET_CH8_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH8_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH8_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 7 : Channel 7 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHENSET_CH7_Msk (0x1UL << PPI_CHENSET_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHENSET_CH7_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH7_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH7_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 6 : Channel 6 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHENSET_CH6_Msk (0x1UL << PPI_CHENSET_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHENSET_CH6_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH6_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH6_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 5 : Channel 5 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHENSET_CH5_Msk (0x1UL << PPI_CHENSET_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHENSET_CH5_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH5_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH5_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 4 : Channel 4 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHENSET_CH4_Msk (0x1UL << PPI_CHENSET_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHENSET_CH4_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH4_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH4_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 3 : Channel 3 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHENSET_CH3_Msk (0x1UL << PPI_CHENSET_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHENSET_CH3_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH3_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH3_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 2 : Channel 2 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHENSET_CH2_Msk (0x1UL << PPI_CHENSET_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHENSET_CH2_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH2_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH2_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 1 : Channel 1 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHENSET_CH1_Msk (0x1UL << PPI_CHENSET_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHENSET_CH1_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH1_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH1_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 0 : Channel 0 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHENSET_CH0_Msk (0x1UL << PPI_CHENSET_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHENSET_CH0_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH0_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH0_Set (1UL) /*!< Write: Enable channel */ - -/* Register: PPI_CHENCLR */ -/* Description: Channel enable clear register */ - -/* Bit 31 : Channel 31 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHENCLR_CH31_Msk (0x1UL << PPI_CHENCLR_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHENCLR_CH31_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH31_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH31_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 30 : Channel 30 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHENCLR_CH30_Msk (0x1UL << PPI_CHENCLR_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHENCLR_CH30_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH30_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH30_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 29 : Channel 29 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHENCLR_CH29_Msk (0x1UL << PPI_CHENCLR_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHENCLR_CH29_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH29_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH29_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 28 : Channel 28 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHENCLR_CH28_Msk (0x1UL << PPI_CHENCLR_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHENCLR_CH28_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH28_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH28_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 27 : Channel 27 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHENCLR_CH27_Msk (0x1UL << PPI_CHENCLR_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHENCLR_CH27_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH27_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH27_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 26 : Channel 26 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHENCLR_CH26_Msk (0x1UL << PPI_CHENCLR_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHENCLR_CH26_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH26_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH26_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 25 : Channel 25 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHENCLR_CH25_Msk (0x1UL << PPI_CHENCLR_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHENCLR_CH25_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH25_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH25_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 24 : Channel 24 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHENCLR_CH24_Msk (0x1UL << PPI_CHENCLR_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHENCLR_CH24_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH24_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH24_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 23 : Channel 23 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHENCLR_CH23_Msk (0x1UL << PPI_CHENCLR_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHENCLR_CH23_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH23_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH23_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 22 : Channel 22 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHENCLR_CH22_Msk (0x1UL << PPI_CHENCLR_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHENCLR_CH22_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH22_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH22_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 21 : Channel 21 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHENCLR_CH21_Msk (0x1UL << PPI_CHENCLR_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHENCLR_CH21_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH21_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH21_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 20 : Channel 20 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHENCLR_CH20_Msk (0x1UL << PPI_CHENCLR_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHENCLR_CH20_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH20_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH20_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 19 : Channel 19 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHENCLR_CH19_Msk (0x1UL << PPI_CHENCLR_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHENCLR_CH19_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH19_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH19_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 18 : Channel 18 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHENCLR_CH18_Msk (0x1UL << PPI_CHENCLR_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHENCLR_CH18_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH18_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH18_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 17 : Channel 17 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHENCLR_CH17_Msk (0x1UL << PPI_CHENCLR_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHENCLR_CH17_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH17_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH17_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 16 : Channel 16 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHENCLR_CH16_Msk (0x1UL << PPI_CHENCLR_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHENCLR_CH16_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH16_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH16_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 15 : Channel 15 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHENCLR_CH15_Msk (0x1UL << PPI_CHENCLR_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHENCLR_CH15_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH15_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH15_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 14 : Channel 14 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHENCLR_CH14_Msk (0x1UL << PPI_CHENCLR_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHENCLR_CH14_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH14_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH14_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 13 : Channel 13 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHENCLR_CH13_Msk (0x1UL << PPI_CHENCLR_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHENCLR_CH13_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH13_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH13_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 12 : Channel 12 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHENCLR_CH12_Msk (0x1UL << PPI_CHENCLR_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHENCLR_CH12_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH12_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH12_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 11 : Channel 11 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHENCLR_CH11_Msk (0x1UL << PPI_CHENCLR_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHENCLR_CH11_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH11_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH11_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 10 : Channel 10 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHENCLR_CH10_Msk (0x1UL << PPI_CHENCLR_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHENCLR_CH10_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH10_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH10_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 9 : Channel 9 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHENCLR_CH9_Msk (0x1UL << PPI_CHENCLR_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHENCLR_CH9_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH9_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH9_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 8 : Channel 8 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHENCLR_CH8_Msk (0x1UL << PPI_CHENCLR_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHENCLR_CH8_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH8_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH8_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 7 : Channel 7 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHENCLR_CH7_Msk (0x1UL << PPI_CHENCLR_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHENCLR_CH7_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH7_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH7_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 6 : Channel 6 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHENCLR_CH6_Msk (0x1UL << PPI_CHENCLR_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHENCLR_CH6_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH6_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH6_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 5 : Channel 5 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHENCLR_CH5_Msk (0x1UL << PPI_CHENCLR_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHENCLR_CH5_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH5_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH5_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 4 : Channel 4 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHENCLR_CH4_Msk (0x1UL << PPI_CHENCLR_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHENCLR_CH4_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH4_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH4_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 3 : Channel 3 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHENCLR_CH3_Msk (0x1UL << PPI_CHENCLR_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHENCLR_CH3_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH3_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH3_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 2 : Channel 2 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHENCLR_CH2_Msk (0x1UL << PPI_CHENCLR_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHENCLR_CH2_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH2_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH2_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 1 : Channel 1 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHENCLR_CH1_Msk (0x1UL << PPI_CHENCLR_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHENCLR_CH1_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH1_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH1_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 0 : Channel 0 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHENCLR_CH0_Msk (0x1UL << PPI_CHENCLR_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHENCLR_CH0_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH0_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH0_Clear (1UL) /*!< Write: disable channel */ - -/* Register: PPI_CH_EEP */ -/* Description: Description cluster[0]: Channel 0 event end-point */ - -/* Bits 31..0 : Pointer to event register. Accepts only addresses to registers from the Event group. */ -#define PPI_CH_EEP_EEP_Pos (0UL) /*!< Position of EEP field. */ -#define PPI_CH_EEP_EEP_Msk (0xFFFFFFFFUL << PPI_CH_EEP_EEP_Pos) /*!< Bit mask of EEP field. */ - -/* Register: PPI_CH_TEP */ -/* Description: Description cluster[0]: Channel 0 task end-point */ - -/* Bits 31..0 : Pointer to task register. Accepts only addresses to registers from the Task group. */ -#define PPI_CH_TEP_TEP_Pos (0UL) /*!< Position of TEP field. */ -#define PPI_CH_TEP_TEP_Msk (0xFFFFFFFFUL << PPI_CH_TEP_TEP_Pos) /*!< Bit mask of TEP field. */ - -/* Register: PPI_CHG */ -/* Description: Description collection[0]: Channel group 0 */ - -/* Bit 31 : Include or exclude channel 31 */ -#define PPI_CHG_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHG_CH31_Msk (0x1UL << PPI_CHG_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHG_CH31_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH31_Included (1UL) /*!< Include */ - -/* Bit 30 : Include or exclude channel 30 */ -#define PPI_CHG_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHG_CH30_Msk (0x1UL << PPI_CHG_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHG_CH30_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH30_Included (1UL) /*!< Include */ - -/* Bit 29 : Include or exclude channel 29 */ -#define PPI_CHG_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHG_CH29_Msk (0x1UL << PPI_CHG_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHG_CH29_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH29_Included (1UL) /*!< Include */ - -/* Bit 28 : Include or exclude channel 28 */ -#define PPI_CHG_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHG_CH28_Msk (0x1UL << PPI_CHG_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHG_CH28_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH28_Included (1UL) /*!< Include */ - -/* Bit 27 : Include or exclude channel 27 */ -#define PPI_CHG_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHG_CH27_Msk (0x1UL << PPI_CHG_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHG_CH27_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH27_Included (1UL) /*!< Include */ - -/* Bit 26 : Include or exclude channel 26 */ -#define PPI_CHG_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHG_CH26_Msk (0x1UL << PPI_CHG_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHG_CH26_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH26_Included (1UL) /*!< Include */ - -/* Bit 25 : Include or exclude channel 25 */ -#define PPI_CHG_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHG_CH25_Msk (0x1UL << PPI_CHG_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHG_CH25_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH25_Included (1UL) /*!< Include */ - -/* Bit 24 : Include or exclude channel 24 */ -#define PPI_CHG_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHG_CH24_Msk (0x1UL << PPI_CHG_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHG_CH24_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH24_Included (1UL) /*!< Include */ - -/* Bit 23 : Include or exclude channel 23 */ -#define PPI_CHG_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHG_CH23_Msk (0x1UL << PPI_CHG_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHG_CH23_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH23_Included (1UL) /*!< Include */ - -/* Bit 22 : Include or exclude channel 22 */ -#define PPI_CHG_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHG_CH22_Msk (0x1UL << PPI_CHG_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHG_CH22_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH22_Included (1UL) /*!< Include */ - -/* Bit 21 : Include or exclude channel 21 */ -#define PPI_CHG_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHG_CH21_Msk (0x1UL << PPI_CHG_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHG_CH21_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH21_Included (1UL) /*!< Include */ - -/* Bit 20 : Include or exclude channel 20 */ -#define PPI_CHG_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHG_CH20_Msk (0x1UL << PPI_CHG_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHG_CH20_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH20_Included (1UL) /*!< Include */ - -/* Bit 19 : Include or exclude channel 19 */ -#define PPI_CHG_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHG_CH19_Msk (0x1UL << PPI_CHG_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHG_CH19_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH19_Included (1UL) /*!< Include */ - -/* Bit 18 : Include or exclude channel 18 */ -#define PPI_CHG_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHG_CH18_Msk (0x1UL << PPI_CHG_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHG_CH18_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH18_Included (1UL) /*!< Include */ - -/* Bit 17 : Include or exclude channel 17 */ -#define PPI_CHG_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHG_CH17_Msk (0x1UL << PPI_CHG_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHG_CH17_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH17_Included (1UL) /*!< Include */ - -/* Bit 16 : Include or exclude channel 16 */ -#define PPI_CHG_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHG_CH16_Msk (0x1UL << PPI_CHG_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHG_CH16_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH16_Included (1UL) /*!< Include */ - -/* Bit 15 : Include or exclude channel 15 */ -#define PPI_CHG_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHG_CH15_Msk (0x1UL << PPI_CHG_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHG_CH15_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH15_Included (1UL) /*!< Include */ - -/* Bit 14 : Include or exclude channel 14 */ -#define PPI_CHG_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHG_CH14_Msk (0x1UL << PPI_CHG_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHG_CH14_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH14_Included (1UL) /*!< Include */ - -/* Bit 13 : Include or exclude channel 13 */ -#define PPI_CHG_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHG_CH13_Msk (0x1UL << PPI_CHG_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHG_CH13_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH13_Included (1UL) /*!< Include */ - -/* Bit 12 : Include or exclude channel 12 */ -#define PPI_CHG_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHG_CH12_Msk (0x1UL << PPI_CHG_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHG_CH12_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH12_Included (1UL) /*!< Include */ - -/* Bit 11 : Include or exclude channel 11 */ -#define PPI_CHG_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHG_CH11_Msk (0x1UL << PPI_CHG_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHG_CH11_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH11_Included (1UL) /*!< Include */ - -/* Bit 10 : Include or exclude channel 10 */ -#define PPI_CHG_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHG_CH10_Msk (0x1UL << PPI_CHG_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHG_CH10_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH10_Included (1UL) /*!< Include */ - -/* Bit 9 : Include or exclude channel 9 */ -#define PPI_CHG_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHG_CH9_Msk (0x1UL << PPI_CHG_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHG_CH9_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH9_Included (1UL) /*!< Include */ - -/* Bit 8 : Include or exclude channel 8 */ -#define PPI_CHG_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHG_CH8_Msk (0x1UL << PPI_CHG_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHG_CH8_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH8_Included (1UL) /*!< Include */ - -/* Bit 7 : Include or exclude channel 7 */ -#define PPI_CHG_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHG_CH7_Msk (0x1UL << PPI_CHG_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHG_CH7_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH7_Included (1UL) /*!< Include */ - -/* Bit 6 : Include or exclude channel 6 */ -#define PPI_CHG_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHG_CH6_Msk (0x1UL << PPI_CHG_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHG_CH6_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH6_Included (1UL) /*!< Include */ - -/* Bit 5 : Include or exclude channel 5 */ -#define PPI_CHG_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHG_CH5_Msk (0x1UL << PPI_CHG_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHG_CH5_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH5_Included (1UL) /*!< Include */ - -/* Bit 4 : Include or exclude channel 4 */ -#define PPI_CHG_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHG_CH4_Msk (0x1UL << PPI_CHG_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHG_CH4_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH4_Included (1UL) /*!< Include */ - -/* Bit 3 : Include or exclude channel 3 */ -#define PPI_CHG_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHG_CH3_Msk (0x1UL << PPI_CHG_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHG_CH3_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH3_Included (1UL) /*!< Include */ - -/* Bit 2 : Include or exclude channel 2 */ -#define PPI_CHG_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHG_CH2_Msk (0x1UL << PPI_CHG_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHG_CH2_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH2_Included (1UL) /*!< Include */ - -/* Bit 1 : Include or exclude channel 1 */ -#define PPI_CHG_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHG_CH1_Msk (0x1UL << PPI_CHG_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHG_CH1_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH1_Included (1UL) /*!< Include */ - -/* Bit 0 : Include or exclude channel 0 */ -#define PPI_CHG_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHG_CH0_Msk (0x1UL << PPI_CHG_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHG_CH0_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH0_Included (1UL) /*!< Include */ - -/* Register: PPI_FORK_TEP */ -/* Description: Description cluster[0]: Channel 0 task end-point */ - -/* Bits 31..0 : Pointer to task register */ -#define PPI_FORK_TEP_TEP_Pos (0UL) /*!< Position of TEP field. */ -#define PPI_FORK_TEP_TEP_Msk (0xFFFFFFFFUL << PPI_FORK_TEP_TEP_Pos) /*!< Bit mask of TEP field. */ - - -/* Peripheral: PWM */ -/* Description: Pulse Width Modulation Unit */ - -/* Register: PWM_TASKS_STOP */ -/* Description: Stops PWM pulse generation on all channels at the end of current PWM period, and stops sequence playback */ - -/* Bit 0 : */ -#define PWM_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define PWM_TASKS_STOP_TASKS_STOP_Msk (0x1UL << PWM_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: PWM_TASKS_SEQSTART */ -/* Description: Description collection[0]: Loads the first PWM value on all enabled channels from sequence 0, and starts playing that sequence at the rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes PWM generation to start it was not running. */ - -/* Bit 0 : */ -#define PWM_TASKS_SEQSTART_TASKS_SEQSTART_Pos (0UL) /*!< Position of TASKS_SEQSTART field. */ -#define PWM_TASKS_SEQSTART_TASKS_SEQSTART_Msk (0x1UL << PWM_TASKS_SEQSTART_TASKS_SEQSTART_Pos) /*!< Bit mask of TASKS_SEQSTART field. */ - -/* Register: PWM_TASKS_NEXTSTEP */ -/* Description: Steps by one value in the current sequence on all enabled channels if DECODER.MODE=NextStep. Does not cause PWM generation to start it was not running. */ - -/* Bit 0 : */ -#define PWM_TASKS_NEXTSTEP_TASKS_NEXTSTEP_Pos (0UL) /*!< Position of TASKS_NEXTSTEP field. */ -#define PWM_TASKS_NEXTSTEP_TASKS_NEXTSTEP_Msk (0x1UL << PWM_TASKS_NEXTSTEP_TASKS_NEXTSTEP_Pos) /*!< Bit mask of TASKS_NEXTSTEP field. */ - -/* Register: PWM_EVENTS_STOPPED */ -/* Description: Response to STOP task, emitted when PWM pulses are no longer generated */ - -/* Bit 0 : */ -#define PWM_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define PWM_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << PWM_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: PWM_EVENTS_SEQSTARTED */ -/* Description: Description collection[0]: First PWM period started on sequence 0 */ - -/* Bit 0 : */ -#define PWM_EVENTS_SEQSTARTED_EVENTS_SEQSTARTED_Pos (0UL) /*!< Position of EVENTS_SEQSTARTED field. */ -#define PWM_EVENTS_SEQSTARTED_EVENTS_SEQSTARTED_Msk (0x1UL << PWM_EVENTS_SEQSTARTED_EVENTS_SEQSTARTED_Pos) /*!< Bit mask of EVENTS_SEQSTARTED field. */ - -/* Register: PWM_EVENTS_SEQEND */ -/* Description: Description collection[0]: Emitted at end of every sequence 0, when last value from RAM has been applied to wave counter */ - -/* Bit 0 : */ -#define PWM_EVENTS_SEQEND_EVENTS_SEQEND_Pos (0UL) /*!< Position of EVENTS_SEQEND field. */ -#define PWM_EVENTS_SEQEND_EVENTS_SEQEND_Msk (0x1UL << PWM_EVENTS_SEQEND_EVENTS_SEQEND_Pos) /*!< Bit mask of EVENTS_SEQEND field. */ - -/* Register: PWM_EVENTS_PWMPERIODEND */ -/* Description: Emitted at the end of each PWM period */ - -/* Bit 0 : */ -#define PWM_EVENTS_PWMPERIODEND_EVENTS_PWMPERIODEND_Pos (0UL) /*!< Position of EVENTS_PWMPERIODEND field. */ -#define PWM_EVENTS_PWMPERIODEND_EVENTS_PWMPERIODEND_Msk (0x1UL << PWM_EVENTS_PWMPERIODEND_EVENTS_PWMPERIODEND_Pos) /*!< Bit mask of EVENTS_PWMPERIODEND field. */ - -/* Register: PWM_EVENTS_LOOPSDONE */ -/* Description: Concatenated sequences have been played the amount of times defined in LOOP.CNT */ - -/* Bit 0 : */ -#define PWM_EVENTS_LOOPSDONE_EVENTS_LOOPSDONE_Pos (0UL) /*!< Position of EVENTS_LOOPSDONE field. */ -#define PWM_EVENTS_LOOPSDONE_EVENTS_LOOPSDONE_Msk (0x1UL << PWM_EVENTS_LOOPSDONE_EVENTS_LOOPSDONE_Pos) /*!< Bit mask of EVENTS_LOOPSDONE field. */ - -/* Register: PWM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between LOOPSDONE event and STOP task */ -#define PWM_SHORTS_LOOPSDONE_STOP_Pos (4UL) /*!< Position of LOOPSDONE_STOP field. */ -#define PWM_SHORTS_LOOPSDONE_STOP_Msk (0x1UL << PWM_SHORTS_LOOPSDONE_STOP_Pos) /*!< Bit mask of LOOPSDONE_STOP field. */ -#define PWM_SHORTS_LOOPSDONE_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_LOOPSDONE_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between LOOPSDONE event and SEQSTART[1] task */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Pos (3UL) /*!< Position of LOOPSDONE_SEQSTART1 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Msk (0x1UL << PWM_SHORTS_LOOPSDONE_SEQSTART1_Pos) /*!< Bit mask of LOOPSDONE_SEQSTART1 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between LOOPSDONE event and SEQSTART[0] task */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Pos (2UL) /*!< Position of LOOPSDONE_SEQSTART0 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Msk (0x1UL << PWM_SHORTS_LOOPSDONE_SEQSTART0_Pos) /*!< Bit mask of LOOPSDONE_SEQSTART0 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between SEQEND[1] event and STOP task */ -#define PWM_SHORTS_SEQEND1_STOP_Pos (1UL) /*!< Position of SEQEND1_STOP field. */ -#define PWM_SHORTS_SEQEND1_STOP_Msk (0x1UL << PWM_SHORTS_SEQEND1_STOP_Pos) /*!< Bit mask of SEQEND1_STOP field. */ -#define PWM_SHORTS_SEQEND1_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_SEQEND1_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between SEQEND[0] event and STOP task */ -#define PWM_SHORTS_SEQEND0_STOP_Pos (0UL) /*!< Position of SEQEND0_STOP field. */ -#define PWM_SHORTS_SEQEND0_STOP_Msk (0x1UL << PWM_SHORTS_SEQEND0_STOP_Pos) /*!< Bit mask of SEQEND0_STOP field. */ -#define PWM_SHORTS_SEQEND0_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_SEQEND0_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: PWM_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 7 : Enable or disable interrupt for LOOPSDONE event */ -#define PWM_INTEN_LOOPSDONE_Pos (7UL) /*!< Position of LOOPSDONE field. */ -#define PWM_INTEN_LOOPSDONE_Msk (0x1UL << PWM_INTEN_LOOPSDONE_Pos) /*!< Bit mask of LOOPSDONE field. */ -#define PWM_INTEN_LOOPSDONE_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_LOOPSDONE_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for PWMPERIODEND event */ -#define PWM_INTEN_PWMPERIODEND_Pos (6UL) /*!< Position of PWMPERIODEND field. */ -#define PWM_INTEN_PWMPERIODEND_Msk (0x1UL << PWM_INTEN_PWMPERIODEND_Pos) /*!< Bit mask of PWMPERIODEND field. */ -#define PWM_INTEN_PWMPERIODEND_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_PWMPERIODEND_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for SEQEND[1] event */ -#define PWM_INTEN_SEQEND1_Pos (5UL) /*!< Position of SEQEND1 field. */ -#define PWM_INTEN_SEQEND1_Msk (0x1UL << PWM_INTEN_SEQEND1_Pos) /*!< Bit mask of SEQEND1 field. */ -#define PWM_INTEN_SEQEND1_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQEND1_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for SEQEND[0] event */ -#define PWM_INTEN_SEQEND0_Pos (4UL) /*!< Position of SEQEND0 field. */ -#define PWM_INTEN_SEQEND0_Msk (0x1UL << PWM_INTEN_SEQEND0_Pos) /*!< Bit mask of SEQEND0 field. */ -#define PWM_INTEN_SEQEND0_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQEND0_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for SEQSTARTED[1] event */ -#define PWM_INTEN_SEQSTARTED1_Pos (3UL) /*!< Position of SEQSTARTED1 field. */ -#define PWM_INTEN_SEQSTARTED1_Msk (0x1UL << PWM_INTEN_SEQSTARTED1_Pos) /*!< Bit mask of SEQSTARTED1 field. */ -#define PWM_INTEN_SEQSTARTED1_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQSTARTED1_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for SEQSTARTED[0] event */ -#define PWM_INTEN_SEQSTARTED0_Pos (2UL) /*!< Position of SEQSTARTED0 field. */ -#define PWM_INTEN_SEQSTARTED0_Msk (0x1UL << PWM_INTEN_SEQSTARTED0_Pos) /*!< Bit mask of SEQSTARTED0 field. */ -#define PWM_INTEN_SEQSTARTED0_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQSTARTED0_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define PWM_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PWM_INTEN_STOPPED_Msk (0x1UL << PWM_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PWM_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Register: PWM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 7 : Write '1' to Enable interrupt for LOOPSDONE event */ -#define PWM_INTENSET_LOOPSDONE_Pos (7UL) /*!< Position of LOOPSDONE field. */ -#define PWM_INTENSET_LOOPSDONE_Msk (0x1UL << PWM_INTENSET_LOOPSDONE_Pos) /*!< Bit mask of LOOPSDONE field. */ -#define PWM_INTENSET_LOOPSDONE_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_LOOPSDONE_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_LOOPSDONE_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for PWMPERIODEND event */ -#define PWM_INTENSET_PWMPERIODEND_Pos (6UL) /*!< Position of PWMPERIODEND field. */ -#define PWM_INTENSET_PWMPERIODEND_Msk (0x1UL << PWM_INTENSET_PWMPERIODEND_Pos) /*!< Bit mask of PWMPERIODEND field. */ -#define PWM_INTENSET_PWMPERIODEND_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_PWMPERIODEND_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_PWMPERIODEND_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for SEQEND[1] event */ -#define PWM_INTENSET_SEQEND1_Pos (5UL) /*!< Position of SEQEND1 field. */ -#define PWM_INTENSET_SEQEND1_Msk (0x1UL << PWM_INTENSET_SEQEND1_Pos) /*!< Bit mask of SEQEND1 field. */ -#define PWM_INTENSET_SEQEND1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQEND1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQEND1_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for SEQEND[0] event */ -#define PWM_INTENSET_SEQEND0_Pos (4UL) /*!< Position of SEQEND0 field. */ -#define PWM_INTENSET_SEQEND0_Msk (0x1UL << PWM_INTENSET_SEQEND0_Pos) /*!< Bit mask of SEQEND0 field. */ -#define PWM_INTENSET_SEQEND0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQEND0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQEND0_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for SEQSTARTED[1] event */ -#define PWM_INTENSET_SEQSTARTED1_Pos (3UL) /*!< Position of SEQSTARTED1 field. */ -#define PWM_INTENSET_SEQSTARTED1_Msk (0x1UL << PWM_INTENSET_SEQSTARTED1_Pos) /*!< Bit mask of SEQSTARTED1 field. */ -#define PWM_INTENSET_SEQSTARTED1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQSTARTED1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQSTARTED1_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for SEQSTARTED[0] event */ -#define PWM_INTENSET_SEQSTARTED0_Pos (2UL) /*!< Position of SEQSTARTED0 field. */ -#define PWM_INTENSET_SEQSTARTED0_Msk (0x1UL << PWM_INTENSET_SEQSTARTED0_Pos) /*!< Bit mask of SEQSTARTED0 field. */ -#define PWM_INTENSET_SEQSTARTED0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQSTARTED0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQSTARTED0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define PWM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PWM_INTENSET_STOPPED_Msk (0x1UL << PWM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PWM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: PWM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 7 : Write '1' to Disable interrupt for LOOPSDONE event */ -#define PWM_INTENCLR_LOOPSDONE_Pos (7UL) /*!< Position of LOOPSDONE field. */ -#define PWM_INTENCLR_LOOPSDONE_Msk (0x1UL << PWM_INTENCLR_LOOPSDONE_Pos) /*!< Bit mask of LOOPSDONE field. */ -#define PWM_INTENCLR_LOOPSDONE_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_LOOPSDONE_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_LOOPSDONE_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for PWMPERIODEND event */ -#define PWM_INTENCLR_PWMPERIODEND_Pos (6UL) /*!< Position of PWMPERIODEND field. */ -#define PWM_INTENCLR_PWMPERIODEND_Msk (0x1UL << PWM_INTENCLR_PWMPERIODEND_Pos) /*!< Bit mask of PWMPERIODEND field. */ -#define PWM_INTENCLR_PWMPERIODEND_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_PWMPERIODEND_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_PWMPERIODEND_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for SEQEND[1] event */ -#define PWM_INTENCLR_SEQEND1_Pos (5UL) /*!< Position of SEQEND1 field. */ -#define PWM_INTENCLR_SEQEND1_Msk (0x1UL << PWM_INTENCLR_SEQEND1_Pos) /*!< Bit mask of SEQEND1 field. */ -#define PWM_INTENCLR_SEQEND1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQEND1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQEND1_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for SEQEND[0] event */ -#define PWM_INTENCLR_SEQEND0_Pos (4UL) /*!< Position of SEQEND0 field. */ -#define PWM_INTENCLR_SEQEND0_Msk (0x1UL << PWM_INTENCLR_SEQEND0_Pos) /*!< Bit mask of SEQEND0 field. */ -#define PWM_INTENCLR_SEQEND0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQEND0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQEND0_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for SEQSTARTED[1] event */ -#define PWM_INTENCLR_SEQSTARTED1_Pos (3UL) /*!< Position of SEQSTARTED1 field. */ -#define PWM_INTENCLR_SEQSTARTED1_Msk (0x1UL << PWM_INTENCLR_SEQSTARTED1_Pos) /*!< Bit mask of SEQSTARTED1 field. */ -#define PWM_INTENCLR_SEQSTARTED1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQSTARTED1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQSTARTED1_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for SEQSTARTED[0] event */ -#define PWM_INTENCLR_SEQSTARTED0_Pos (2UL) /*!< Position of SEQSTARTED0 field. */ -#define PWM_INTENCLR_SEQSTARTED0_Msk (0x1UL << PWM_INTENCLR_SEQSTARTED0_Pos) /*!< Bit mask of SEQSTARTED0 field. */ -#define PWM_INTENCLR_SEQSTARTED0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQSTARTED0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQSTARTED0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define PWM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PWM_INTENCLR_STOPPED_Msk (0x1UL << PWM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PWM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: PWM_ENABLE */ -/* Description: PWM module enable register */ - -/* Bit 0 : Enable or disable PWM module */ -#define PWM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define PWM_ENABLE_ENABLE_Msk (0x1UL << PWM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define PWM_ENABLE_ENABLE_Disabled (0UL) /*!< Disabled */ -#define PWM_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: PWM_MODE */ -/* Description: Selects operating mode of the wave counter */ - -/* Bit 0 : Selects up or up and down as wave counter mode */ -#define PWM_MODE_UPDOWN_Pos (0UL) /*!< Position of UPDOWN field. */ -#define PWM_MODE_UPDOWN_Msk (0x1UL << PWM_MODE_UPDOWN_Pos) /*!< Bit mask of UPDOWN field. */ -#define PWM_MODE_UPDOWN_Up (0UL) /*!< Up counter - edge aligned PWM duty-cycle */ -#define PWM_MODE_UPDOWN_UpAndDown (1UL) /*!< Up and down counter - center aligned PWM duty cycle */ - -/* Register: PWM_COUNTERTOP */ -/* Description: Value up to which the pulse generator counter counts */ - -/* Bits 14..0 : Value up to which the pulse generator counter counts. This register is ignored when DECODER.MODE=WaveForm and only values from RAM will be used. */ -#define PWM_COUNTERTOP_COUNTERTOP_Pos (0UL) /*!< Position of COUNTERTOP field. */ -#define PWM_COUNTERTOP_COUNTERTOP_Msk (0x7FFFUL << PWM_COUNTERTOP_COUNTERTOP_Pos) /*!< Bit mask of COUNTERTOP field. */ - -/* Register: PWM_PRESCALER */ -/* Description: Configuration for PWM_CLK */ - -/* Bits 2..0 : Pre-scaler of PWM_CLK */ -#define PWM_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define PWM_PRESCALER_PRESCALER_Msk (0x7UL << PWM_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ -#define PWM_PRESCALER_PRESCALER_DIV_1 (0UL) /*!< Divide by 1 (16MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_2 (1UL) /*!< Divide by 2 ( 8MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_4 (2UL) /*!< Divide by 4 ( 4MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_8 (3UL) /*!< Divide by 8 ( 2MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_16 (4UL) /*!< Divide by 16 ( 1MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_32 (5UL) /*!< Divide by 32 ( 500kHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_64 (6UL) /*!< Divide by 64 ( 250kHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_128 (7UL) /*!< Divide by 128 ( 125kHz) */ - -/* Register: PWM_DECODER */ -/* Description: Configuration of the decoder */ - -/* Bit 8 : Selects source for advancing the active sequence */ -#define PWM_DECODER_MODE_Pos (8UL) /*!< Position of MODE field. */ -#define PWM_DECODER_MODE_Msk (0x1UL << PWM_DECODER_MODE_Pos) /*!< Bit mask of MODE field. */ -#define PWM_DECODER_MODE_RefreshCount (0UL) /*!< SEQ[n].REFRESH is used to determine loading internal compare registers */ -#define PWM_DECODER_MODE_NextStep (1UL) /*!< NEXTSTEP task causes a new value to be loaded to internal compare registers */ - -/* Bits 1..0 : How a sequence is read from RAM and spread to the compare register */ -#define PWM_DECODER_LOAD_Pos (0UL) /*!< Position of LOAD field. */ -#define PWM_DECODER_LOAD_Msk (0x3UL << PWM_DECODER_LOAD_Pos) /*!< Bit mask of LOAD field. */ -#define PWM_DECODER_LOAD_Common (0UL) /*!< 1st half word (16-bit) used in all PWM channels 0..3 */ -#define PWM_DECODER_LOAD_Grouped (1UL) /*!< 1st half word (16-bit) used in channel 0..1; 2nd word in channel 2..3 */ -#define PWM_DECODER_LOAD_Individual (2UL) /*!< 1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in ch.3 */ -#define PWM_DECODER_LOAD_WaveForm (3UL) /*!< 1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in COUNTERTOP */ - -/* Register: PWM_LOOP */ -/* Description: Amount of playback of a loop */ - -/* Bits 15..0 : Amount of playback of pattern cycles */ -#define PWM_LOOP_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_LOOP_CNT_Msk (0xFFFFUL << PWM_LOOP_CNT_Pos) /*!< Bit mask of CNT field. */ -#define PWM_LOOP_CNT_Disabled (0UL) /*!< Looping disabled (stop at the end of the sequence) */ - -/* Register: PWM_SEQ_PTR */ -/* Description: Description cluster[0]: Beginning address in Data RAM of this sequence */ - -/* Bits 31..0 : Beginning address in Data RAM of this sequence */ -#define PWM_SEQ_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define PWM_SEQ_PTR_PTR_Msk (0xFFFFFFFFUL << PWM_SEQ_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: PWM_SEQ_CNT */ -/* Description: Description cluster[0]: Amount of values (duty cycles) in this sequence */ - -/* Bits 14..0 : Amount of values (duty cycles) in this sequence */ -#define PWM_SEQ_CNT_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_SEQ_CNT_CNT_Msk (0x7FFFUL << PWM_SEQ_CNT_CNT_Pos) /*!< Bit mask of CNT field. */ -#define PWM_SEQ_CNT_CNT_Disabled (0UL) /*!< Sequence is disabled, and shall not be started as it is empty */ - -/* Register: PWM_SEQ_REFRESH */ -/* Description: Description cluster[0]: Amount of additional PWM periods between samples loaded into compare register */ - -/* Bits 23..0 : Amount of additional PWM periods between samples loaded into compare register (load every REFRESH.CNT+1 PWM periods) */ -#define PWM_SEQ_REFRESH_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_SEQ_REFRESH_CNT_Msk (0xFFFFFFUL << PWM_SEQ_REFRESH_CNT_Pos) /*!< Bit mask of CNT field. */ -#define PWM_SEQ_REFRESH_CNT_Continuous (0UL) /*!< Update every PWM period */ - -/* Register: PWM_SEQ_ENDDELAY */ -/* Description: Description cluster[0]: Time added after the sequence */ - -/* Bits 23..0 : Time added after the sequence in PWM periods */ -#define PWM_SEQ_ENDDELAY_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_SEQ_ENDDELAY_CNT_Msk (0xFFFFFFUL << PWM_SEQ_ENDDELAY_CNT_Pos) /*!< Bit mask of CNT field. */ - -/* Register: PWM_PSEL_OUT */ -/* Description: Description collection[0]: Output pin select for PWM channel 0 */ - -/* Bit 31 : Connection */ -#define PWM_PSEL_OUT_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define PWM_PSEL_OUT_CONNECT_Msk (0x1UL << PWM_PSEL_OUT_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define PWM_PSEL_OUT_CONNECT_Connected (0UL) /*!< Connect */ -#define PWM_PSEL_OUT_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define PWM_PSEL_OUT_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define PWM_PSEL_OUT_PIN_Msk (0x1FUL << PWM_PSEL_OUT_PIN_Pos) /*!< Bit mask of PIN field. */ - - -/* Peripheral: QDEC */ -/* Description: Quadrature Decoder */ - -/* Register: QDEC_TASKS_START */ -/* Description: Task starting the quadrature decoder */ - -/* Bit 0 : */ -#define QDEC_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define QDEC_TASKS_START_TASKS_START_Msk (0x1UL << QDEC_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: QDEC_TASKS_STOP */ -/* Description: Task stopping the quadrature decoder */ - -/* Bit 0 : */ -#define QDEC_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define QDEC_TASKS_STOP_TASKS_STOP_Msk (0x1UL << QDEC_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: QDEC_TASKS_READCLRACC */ -/* Description: Read and clear ACC and ACCDBL */ - -/* Bit 0 : */ -#define QDEC_TASKS_READCLRACC_TASKS_READCLRACC_Pos (0UL) /*!< Position of TASKS_READCLRACC field. */ -#define QDEC_TASKS_READCLRACC_TASKS_READCLRACC_Msk (0x1UL << QDEC_TASKS_READCLRACC_TASKS_READCLRACC_Pos) /*!< Bit mask of TASKS_READCLRACC field. */ - -/* Register: QDEC_TASKS_RDCLRACC */ -/* Description: Read and clear ACC */ - -/* Bit 0 : */ -#define QDEC_TASKS_RDCLRACC_TASKS_RDCLRACC_Pos (0UL) /*!< Position of TASKS_RDCLRACC field. */ -#define QDEC_TASKS_RDCLRACC_TASKS_RDCLRACC_Msk (0x1UL << QDEC_TASKS_RDCLRACC_TASKS_RDCLRACC_Pos) /*!< Bit mask of TASKS_RDCLRACC field. */ - -/* Register: QDEC_TASKS_RDCLRDBL */ -/* Description: Read and clear ACCDBL */ - -/* Bit 0 : */ -#define QDEC_TASKS_RDCLRDBL_TASKS_RDCLRDBL_Pos (0UL) /*!< Position of TASKS_RDCLRDBL field. */ -#define QDEC_TASKS_RDCLRDBL_TASKS_RDCLRDBL_Msk (0x1UL << QDEC_TASKS_RDCLRDBL_TASKS_RDCLRDBL_Pos) /*!< Bit mask of TASKS_RDCLRDBL field. */ - -/* Register: QDEC_EVENTS_SAMPLERDY */ -/* Description: Event being generated for every new sample value written to the SAMPLE register */ - -/* Bit 0 : */ -#define QDEC_EVENTS_SAMPLERDY_EVENTS_SAMPLERDY_Pos (0UL) /*!< Position of EVENTS_SAMPLERDY field. */ -#define QDEC_EVENTS_SAMPLERDY_EVENTS_SAMPLERDY_Msk (0x1UL << QDEC_EVENTS_SAMPLERDY_EVENTS_SAMPLERDY_Pos) /*!< Bit mask of EVENTS_SAMPLERDY field. */ - -/* Register: QDEC_EVENTS_REPORTRDY */ -/* Description: Non-null report ready */ - -/* Bit 0 : */ -#define QDEC_EVENTS_REPORTRDY_EVENTS_REPORTRDY_Pos (0UL) /*!< Position of EVENTS_REPORTRDY field. */ -#define QDEC_EVENTS_REPORTRDY_EVENTS_REPORTRDY_Msk (0x1UL << QDEC_EVENTS_REPORTRDY_EVENTS_REPORTRDY_Pos) /*!< Bit mask of EVENTS_REPORTRDY field. */ - -/* Register: QDEC_EVENTS_ACCOF */ -/* Description: ACC or ACCDBL register overflow */ - -/* Bit 0 : */ -#define QDEC_EVENTS_ACCOF_EVENTS_ACCOF_Pos (0UL) /*!< Position of EVENTS_ACCOF field. */ -#define QDEC_EVENTS_ACCOF_EVENTS_ACCOF_Msk (0x1UL << QDEC_EVENTS_ACCOF_EVENTS_ACCOF_Pos) /*!< Bit mask of EVENTS_ACCOF field. */ - -/* Register: QDEC_EVENTS_DBLRDY */ -/* Description: Double displacement(s) detected */ - -/* Bit 0 : */ -#define QDEC_EVENTS_DBLRDY_EVENTS_DBLRDY_Pos (0UL) /*!< Position of EVENTS_DBLRDY field. */ -#define QDEC_EVENTS_DBLRDY_EVENTS_DBLRDY_Msk (0x1UL << QDEC_EVENTS_DBLRDY_EVENTS_DBLRDY_Pos) /*!< Bit mask of EVENTS_DBLRDY field. */ - -/* Register: QDEC_EVENTS_STOPPED */ -/* Description: QDEC has been stopped */ - -/* Bit 0 : */ -#define QDEC_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define QDEC_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << QDEC_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: QDEC_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 6 : Shortcut between SAMPLERDY event and READCLRACC task */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Pos (6UL) /*!< Position of SAMPLERDY_READCLRACC field. */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Msk (0x1UL << QDEC_SHORTS_SAMPLERDY_READCLRACC_Pos) /*!< Bit mask of SAMPLERDY_READCLRACC field. */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between DBLRDY event and STOP task */ -#define QDEC_SHORTS_DBLRDY_STOP_Pos (5UL) /*!< Position of DBLRDY_STOP field. */ -#define QDEC_SHORTS_DBLRDY_STOP_Msk (0x1UL << QDEC_SHORTS_DBLRDY_STOP_Pos) /*!< Bit mask of DBLRDY_STOP field. */ -#define QDEC_SHORTS_DBLRDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_DBLRDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 4 : Shortcut between DBLRDY event and RDCLRDBL task */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Pos (4UL) /*!< Position of DBLRDY_RDCLRDBL field. */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Msk (0x1UL << QDEC_SHORTS_DBLRDY_RDCLRDBL_Pos) /*!< Bit mask of DBLRDY_RDCLRDBL field. */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between REPORTRDY event and STOP task */ -#define QDEC_SHORTS_REPORTRDY_STOP_Pos (3UL) /*!< Position of REPORTRDY_STOP field. */ -#define QDEC_SHORTS_REPORTRDY_STOP_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_STOP_Pos) /*!< Bit mask of REPORTRDY_STOP field. */ -#define QDEC_SHORTS_REPORTRDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_REPORTRDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between REPORTRDY event and RDCLRACC task */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Pos (2UL) /*!< Position of REPORTRDY_RDCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_RDCLRACC_Pos) /*!< Bit mask of REPORTRDY_RDCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between SAMPLERDY event and STOP task */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Pos (1UL) /*!< Position of SAMPLERDY_STOP field. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Msk (0x1UL << QDEC_SHORTS_SAMPLERDY_STOP_Pos) /*!< Bit mask of SAMPLERDY_STOP field. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between REPORTRDY event and READCLRACC task */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Pos (0UL) /*!< Position of REPORTRDY_READCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_READCLRACC_Pos) /*!< Bit mask of REPORTRDY_READCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: QDEC_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 4 : Write '1' to Enable interrupt for STOPPED event */ -#define QDEC_INTENSET_STOPPED_Pos (4UL) /*!< Position of STOPPED field. */ -#define QDEC_INTENSET_STOPPED_Msk (0x1UL << QDEC_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define QDEC_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for DBLRDY event */ -#define QDEC_INTENSET_DBLRDY_Pos (3UL) /*!< Position of DBLRDY field. */ -#define QDEC_INTENSET_DBLRDY_Msk (0x1UL << QDEC_INTENSET_DBLRDY_Pos) /*!< Bit mask of DBLRDY field. */ -#define QDEC_INTENSET_DBLRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_DBLRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_DBLRDY_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for ACCOF event */ -#define QDEC_INTENSET_ACCOF_Pos (2UL) /*!< Position of ACCOF field. */ -#define QDEC_INTENSET_ACCOF_Msk (0x1UL << QDEC_INTENSET_ACCOF_Pos) /*!< Bit mask of ACCOF field. */ -#define QDEC_INTENSET_ACCOF_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_ACCOF_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_ACCOF_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for REPORTRDY event */ -#define QDEC_INTENSET_REPORTRDY_Pos (1UL) /*!< Position of REPORTRDY field. */ -#define QDEC_INTENSET_REPORTRDY_Msk (0x1UL << QDEC_INTENSET_REPORTRDY_Pos) /*!< Bit mask of REPORTRDY field. */ -#define QDEC_INTENSET_REPORTRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_REPORTRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_REPORTRDY_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for SAMPLERDY event */ -#define QDEC_INTENSET_SAMPLERDY_Pos (0UL) /*!< Position of SAMPLERDY field. */ -#define QDEC_INTENSET_SAMPLERDY_Msk (0x1UL << QDEC_INTENSET_SAMPLERDY_Pos) /*!< Bit mask of SAMPLERDY field. */ -#define QDEC_INTENSET_SAMPLERDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_SAMPLERDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_SAMPLERDY_Set (1UL) /*!< Enable */ - -/* Register: QDEC_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 4 : Write '1' to Disable interrupt for STOPPED event */ -#define QDEC_INTENCLR_STOPPED_Pos (4UL) /*!< Position of STOPPED field. */ -#define QDEC_INTENCLR_STOPPED_Msk (0x1UL << QDEC_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define QDEC_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for DBLRDY event */ -#define QDEC_INTENCLR_DBLRDY_Pos (3UL) /*!< Position of DBLRDY field. */ -#define QDEC_INTENCLR_DBLRDY_Msk (0x1UL << QDEC_INTENCLR_DBLRDY_Pos) /*!< Bit mask of DBLRDY field. */ -#define QDEC_INTENCLR_DBLRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_DBLRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_DBLRDY_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for ACCOF event */ -#define QDEC_INTENCLR_ACCOF_Pos (2UL) /*!< Position of ACCOF field. */ -#define QDEC_INTENCLR_ACCOF_Msk (0x1UL << QDEC_INTENCLR_ACCOF_Pos) /*!< Bit mask of ACCOF field. */ -#define QDEC_INTENCLR_ACCOF_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_ACCOF_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_ACCOF_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for REPORTRDY event */ -#define QDEC_INTENCLR_REPORTRDY_Pos (1UL) /*!< Position of REPORTRDY field. */ -#define QDEC_INTENCLR_REPORTRDY_Msk (0x1UL << QDEC_INTENCLR_REPORTRDY_Pos) /*!< Bit mask of REPORTRDY field. */ -#define QDEC_INTENCLR_REPORTRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_REPORTRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_REPORTRDY_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for SAMPLERDY event */ -#define QDEC_INTENCLR_SAMPLERDY_Pos (0UL) /*!< Position of SAMPLERDY field. */ -#define QDEC_INTENCLR_SAMPLERDY_Msk (0x1UL << QDEC_INTENCLR_SAMPLERDY_Pos) /*!< Bit mask of SAMPLERDY field. */ -#define QDEC_INTENCLR_SAMPLERDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_SAMPLERDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_SAMPLERDY_Clear (1UL) /*!< Disable */ - -/* Register: QDEC_ENABLE */ -/* Description: Enable the quadrature decoder */ - -/* Bit 0 : Enable or disable the quadrature decoder */ -#define QDEC_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define QDEC_ENABLE_ENABLE_Msk (0x1UL << QDEC_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define QDEC_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define QDEC_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: QDEC_LEDPOL */ -/* Description: LED output pin polarity */ - -/* Bit 0 : LED output pin polarity */ -#define QDEC_LEDPOL_LEDPOL_Pos (0UL) /*!< Position of LEDPOL field. */ -#define QDEC_LEDPOL_LEDPOL_Msk (0x1UL << QDEC_LEDPOL_LEDPOL_Pos) /*!< Bit mask of LEDPOL field. */ -#define QDEC_LEDPOL_LEDPOL_ActiveLow (0UL) /*!< Led active on output pin low */ -#define QDEC_LEDPOL_LEDPOL_ActiveHigh (1UL) /*!< Led active on output pin high */ - -/* Register: QDEC_SAMPLEPER */ -/* Description: Sample period */ - -/* Bits 3..0 : Sample period. The SAMPLE register will be updated for every new sample */ -#define QDEC_SAMPLEPER_SAMPLEPER_Pos (0UL) /*!< Position of SAMPLEPER field. */ -#define QDEC_SAMPLEPER_SAMPLEPER_Msk (0xFUL << QDEC_SAMPLEPER_SAMPLEPER_Pos) /*!< Bit mask of SAMPLEPER field. */ -#define QDEC_SAMPLEPER_SAMPLEPER_128us (0UL) /*!< 128 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_256us (1UL) /*!< 256 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_512us (2UL) /*!< 512 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_1024us (3UL) /*!< 1024 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_2048us (4UL) /*!< 2048 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_4096us (5UL) /*!< 4096 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_8192us (6UL) /*!< 8192 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_16384us (7UL) /*!< 16384 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_32ms (8UL) /*!< 32768 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_65ms (9UL) /*!< 65536 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_131ms (10UL) /*!< 131072 us */ - -/* Register: QDEC_SAMPLE */ -/* Description: Motion sample value */ - -/* Bits 31..0 : Last motion sample */ -#define QDEC_SAMPLE_SAMPLE_Pos (0UL) /*!< Position of SAMPLE field. */ -#define QDEC_SAMPLE_SAMPLE_Msk (0xFFFFFFFFUL << QDEC_SAMPLE_SAMPLE_Pos) /*!< Bit mask of SAMPLE field. */ - -/* Register: QDEC_REPORTPER */ -/* Description: Number of samples to be taken before REPORTRDY and DBLRDY events can be generated */ - -/* Bits 3..0 : Specifies the number of samples to be accumulated in the ACC register before the REPORTRDY and DBLRDY events can be generated */ -#define QDEC_REPORTPER_REPORTPER_Pos (0UL) /*!< Position of REPORTPER field. */ -#define QDEC_REPORTPER_REPORTPER_Msk (0xFUL << QDEC_REPORTPER_REPORTPER_Pos) /*!< Bit mask of REPORTPER field. */ -#define QDEC_REPORTPER_REPORTPER_10Smpl (0UL) /*!< 10 samples / report */ -#define QDEC_REPORTPER_REPORTPER_40Smpl (1UL) /*!< 40 samples / report */ -#define QDEC_REPORTPER_REPORTPER_80Smpl (2UL) /*!< 80 samples / report */ -#define QDEC_REPORTPER_REPORTPER_120Smpl (3UL) /*!< 120 samples / report */ -#define QDEC_REPORTPER_REPORTPER_160Smpl (4UL) /*!< 160 samples / report */ -#define QDEC_REPORTPER_REPORTPER_200Smpl (5UL) /*!< 200 samples / report */ -#define QDEC_REPORTPER_REPORTPER_240Smpl (6UL) /*!< 240 samples / report */ -#define QDEC_REPORTPER_REPORTPER_280Smpl (7UL) /*!< 280 samples / report */ -#define QDEC_REPORTPER_REPORTPER_1Smpl (8UL) /*!< 1 sample / report */ - -/* Register: QDEC_ACC */ -/* Description: Register accumulating the valid transitions */ - -/* Bits 31..0 : Register accumulating all valid samples (not double transition) read from the SAMPLE register */ -#define QDEC_ACC_ACC_Pos (0UL) /*!< Position of ACC field. */ -#define QDEC_ACC_ACC_Msk (0xFFFFFFFFUL << QDEC_ACC_ACC_Pos) /*!< Bit mask of ACC field. */ - -/* Register: QDEC_ACCREAD */ -/* Description: Snapshot of the ACC register, updated by the READCLRACC or RDCLRACC task */ - -/* Bits 31..0 : Snapshot of the ACC register. */ -#define QDEC_ACCREAD_ACCREAD_Pos (0UL) /*!< Position of ACCREAD field. */ -#define QDEC_ACCREAD_ACCREAD_Msk (0xFFFFFFFFUL << QDEC_ACCREAD_ACCREAD_Pos) /*!< Bit mask of ACCREAD field. */ - -/* Register: QDEC_PSEL_LED */ -/* Description: Pin select for LED signal */ - -/* Bit 31 : Connection */ -#define QDEC_PSEL_LED_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QDEC_PSEL_LED_CONNECT_Msk (0x1UL << QDEC_PSEL_LED_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QDEC_PSEL_LED_CONNECT_Connected (0UL) /*!< Connect */ -#define QDEC_PSEL_LED_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define QDEC_PSEL_LED_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QDEC_PSEL_LED_PIN_Msk (0x1FUL << QDEC_PSEL_LED_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QDEC_PSEL_A */ -/* Description: Pin select for A signal */ - -/* Bit 31 : Connection */ -#define QDEC_PSEL_A_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QDEC_PSEL_A_CONNECT_Msk (0x1UL << QDEC_PSEL_A_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QDEC_PSEL_A_CONNECT_Connected (0UL) /*!< Connect */ -#define QDEC_PSEL_A_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define QDEC_PSEL_A_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QDEC_PSEL_A_PIN_Msk (0x1FUL << QDEC_PSEL_A_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QDEC_PSEL_B */ -/* Description: Pin select for B signal */ - -/* Bit 31 : Connection */ -#define QDEC_PSEL_B_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QDEC_PSEL_B_CONNECT_Msk (0x1UL << QDEC_PSEL_B_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QDEC_PSEL_B_CONNECT_Connected (0UL) /*!< Connect */ -#define QDEC_PSEL_B_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define QDEC_PSEL_B_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QDEC_PSEL_B_PIN_Msk (0x1FUL << QDEC_PSEL_B_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QDEC_DBFEN */ -/* Description: Enable input debounce filters */ - -/* Bit 0 : Enable input debounce filters */ -#define QDEC_DBFEN_DBFEN_Pos (0UL) /*!< Position of DBFEN field. */ -#define QDEC_DBFEN_DBFEN_Msk (0x1UL << QDEC_DBFEN_DBFEN_Pos) /*!< Bit mask of DBFEN field. */ -#define QDEC_DBFEN_DBFEN_Disabled (0UL) /*!< Debounce input filters disabled */ -#define QDEC_DBFEN_DBFEN_Enabled (1UL) /*!< Debounce input filters enabled */ - -/* Register: QDEC_LEDPRE */ -/* Description: Time period the LED is switched ON prior to sampling */ - -/* Bits 8..0 : Period in us the LED is switched on prior to sampling */ -#define QDEC_LEDPRE_LEDPRE_Pos (0UL) /*!< Position of LEDPRE field. */ -#define QDEC_LEDPRE_LEDPRE_Msk (0x1FFUL << QDEC_LEDPRE_LEDPRE_Pos) /*!< Bit mask of LEDPRE field. */ - -/* Register: QDEC_ACCDBL */ -/* Description: Register accumulating the number of detected double transitions */ - -/* Bits 3..0 : Register accumulating the number of detected double or illegal transitions. ( SAMPLE = 2 ). */ -#define QDEC_ACCDBL_ACCDBL_Pos (0UL) /*!< Position of ACCDBL field. */ -#define QDEC_ACCDBL_ACCDBL_Msk (0xFUL << QDEC_ACCDBL_ACCDBL_Pos) /*!< Bit mask of ACCDBL field. */ - -/* Register: QDEC_ACCDBLREAD */ -/* Description: Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL task */ - -/* Bits 3..0 : Snapshot of the ACCDBL register. This field is updated when the READCLRACC or RDCLRDBL task is triggered. */ -#define QDEC_ACCDBLREAD_ACCDBLREAD_Pos (0UL) /*!< Position of ACCDBLREAD field. */ -#define QDEC_ACCDBLREAD_ACCDBLREAD_Msk (0xFUL << QDEC_ACCDBLREAD_ACCDBLREAD_Pos) /*!< Bit mask of ACCDBLREAD field. */ - - -/* Peripheral: RADIO */ -/* Description: 2.4 GHz Radio */ - -/* Register: RADIO_TASKS_TXEN */ -/* Description: Enable RADIO in TX mode */ - -/* Bit 0 : */ -#define RADIO_TASKS_TXEN_TASKS_TXEN_Pos (0UL) /*!< Position of TASKS_TXEN field. */ -#define RADIO_TASKS_TXEN_TASKS_TXEN_Msk (0x1UL << RADIO_TASKS_TXEN_TASKS_TXEN_Pos) /*!< Bit mask of TASKS_TXEN field. */ - -/* Register: RADIO_TASKS_RXEN */ -/* Description: Enable RADIO in RX mode */ - -/* Bit 0 : */ -#define RADIO_TASKS_RXEN_TASKS_RXEN_Pos (0UL) /*!< Position of TASKS_RXEN field. */ -#define RADIO_TASKS_RXEN_TASKS_RXEN_Msk (0x1UL << RADIO_TASKS_RXEN_TASKS_RXEN_Pos) /*!< Bit mask of TASKS_RXEN field. */ - -/* Register: RADIO_TASKS_START */ -/* Description: Start RADIO */ - -/* Bit 0 : */ -#define RADIO_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define RADIO_TASKS_START_TASKS_START_Msk (0x1UL << RADIO_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: RADIO_TASKS_STOP */ -/* Description: Stop RADIO */ - -/* Bit 0 : */ -#define RADIO_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define RADIO_TASKS_STOP_TASKS_STOP_Msk (0x1UL << RADIO_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: RADIO_TASKS_DISABLE */ -/* Description: Disable RADIO */ - -/* Bit 0 : */ -#define RADIO_TASKS_DISABLE_TASKS_DISABLE_Pos (0UL) /*!< Position of TASKS_DISABLE field. */ -#define RADIO_TASKS_DISABLE_TASKS_DISABLE_Msk (0x1UL << RADIO_TASKS_DISABLE_TASKS_DISABLE_Pos) /*!< Bit mask of TASKS_DISABLE field. */ - -/* Register: RADIO_TASKS_RSSISTART */ -/* Description: Start the RSSI and take one single sample of the receive signal strength. */ - -/* Bit 0 : */ -#define RADIO_TASKS_RSSISTART_TASKS_RSSISTART_Pos (0UL) /*!< Position of TASKS_RSSISTART field. */ -#define RADIO_TASKS_RSSISTART_TASKS_RSSISTART_Msk (0x1UL << RADIO_TASKS_RSSISTART_TASKS_RSSISTART_Pos) /*!< Bit mask of TASKS_RSSISTART field. */ - -/* Register: RADIO_TASKS_RSSISTOP */ -/* Description: Stop the RSSI measurement */ - -/* Bit 0 : */ -#define RADIO_TASKS_RSSISTOP_TASKS_RSSISTOP_Pos (0UL) /*!< Position of TASKS_RSSISTOP field. */ -#define RADIO_TASKS_RSSISTOP_TASKS_RSSISTOP_Msk (0x1UL << RADIO_TASKS_RSSISTOP_TASKS_RSSISTOP_Pos) /*!< Bit mask of TASKS_RSSISTOP field. */ - -/* Register: RADIO_TASKS_BCSTART */ -/* Description: Start the bit counter */ - -/* Bit 0 : */ -#define RADIO_TASKS_BCSTART_TASKS_BCSTART_Pos (0UL) /*!< Position of TASKS_BCSTART field. */ -#define RADIO_TASKS_BCSTART_TASKS_BCSTART_Msk (0x1UL << RADIO_TASKS_BCSTART_TASKS_BCSTART_Pos) /*!< Bit mask of TASKS_BCSTART field. */ - -/* Register: RADIO_TASKS_BCSTOP */ -/* Description: Stop the bit counter */ - -/* Bit 0 : */ -#define RADIO_TASKS_BCSTOP_TASKS_BCSTOP_Pos (0UL) /*!< Position of TASKS_BCSTOP field. */ -#define RADIO_TASKS_BCSTOP_TASKS_BCSTOP_Msk (0x1UL << RADIO_TASKS_BCSTOP_TASKS_BCSTOP_Pos) /*!< Bit mask of TASKS_BCSTOP field. */ - -/* Register: RADIO_EVENTS_READY */ -/* Description: RADIO has ramped up and is ready to be started */ - -/* Bit 0 : */ -#define RADIO_EVENTS_READY_EVENTS_READY_Pos (0UL) /*!< Position of EVENTS_READY field. */ -#define RADIO_EVENTS_READY_EVENTS_READY_Msk (0x1UL << RADIO_EVENTS_READY_EVENTS_READY_Pos) /*!< Bit mask of EVENTS_READY field. */ - -/* Register: RADIO_EVENTS_ADDRESS */ -/* Description: Address sent or received */ - -/* Bit 0 : */ -#define RADIO_EVENTS_ADDRESS_EVENTS_ADDRESS_Pos (0UL) /*!< Position of EVENTS_ADDRESS field. */ -#define RADIO_EVENTS_ADDRESS_EVENTS_ADDRESS_Msk (0x1UL << RADIO_EVENTS_ADDRESS_EVENTS_ADDRESS_Pos) /*!< Bit mask of EVENTS_ADDRESS field. */ - -/* Register: RADIO_EVENTS_PAYLOAD */ -/* Description: Packet payload sent or received */ - -/* Bit 0 : */ -#define RADIO_EVENTS_PAYLOAD_EVENTS_PAYLOAD_Pos (0UL) /*!< Position of EVENTS_PAYLOAD field. */ -#define RADIO_EVENTS_PAYLOAD_EVENTS_PAYLOAD_Msk (0x1UL << RADIO_EVENTS_PAYLOAD_EVENTS_PAYLOAD_Pos) /*!< Bit mask of EVENTS_PAYLOAD field. */ - -/* Register: RADIO_EVENTS_END */ -/* Description: Packet sent or received */ - -/* Bit 0 : */ -#define RADIO_EVENTS_END_EVENTS_END_Pos (0UL) /*!< Position of EVENTS_END field. */ -#define RADIO_EVENTS_END_EVENTS_END_Msk (0x1UL << RADIO_EVENTS_END_EVENTS_END_Pos) /*!< Bit mask of EVENTS_END field. */ - -/* Register: RADIO_EVENTS_DISABLED */ -/* Description: RADIO has been disabled */ - -/* Bit 0 : */ -#define RADIO_EVENTS_DISABLED_EVENTS_DISABLED_Pos (0UL) /*!< Position of EVENTS_DISABLED field. */ -#define RADIO_EVENTS_DISABLED_EVENTS_DISABLED_Msk (0x1UL << RADIO_EVENTS_DISABLED_EVENTS_DISABLED_Pos) /*!< Bit mask of EVENTS_DISABLED field. */ - -/* Register: RADIO_EVENTS_DEVMATCH */ -/* Description: A device address match occurred on the last received packet */ - -/* Bit 0 : */ -#define RADIO_EVENTS_DEVMATCH_EVENTS_DEVMATCH_Pos (0UL) /*!< Position of EVENTS_DEVMATCH field. */ -#define RADIO_EVENTS_DEVMATCH_EVENTS_DEVMATCH_Msk (0x1UL << RADIO_EVENTS_DEVMATCH_EVENTS_DEVMATCH_Pos) /*!< Bit mask of EVENTS_DEVMATCH field. */ - -/* Register: RADIO_EVENTS_DEVMISS */ -/* Description: No device address match occurred on the last received packet */ - -/* Bit 0 : */ -#define RADIO_EVENTS_DEVMISS_EVENTS_DEVMISS_Pos (0UL) /*!< Position of EVENTS_DEVMISS field. */ -#define RADIO_EVENTS_DEVMISS_EVENTS_DEVMISS_Msk (0x1UL << RADIO_EVENTS_DEVMISS_EVENTS_DEVMISS_Pos) /*!< Bit mask of EVENTS_DEVMISS field. */ - -/* Register: RADIO_EVENTS_RSSIEND */ -/* Description: Sampling of receive signal strength complete. */ - -/* Bit 0 : */ -#define RADIO_EVENTS_RSSIEND_EVENTS_RSSIEND_Pos (0UL) /*!< Position of EVENTS_RSSIEND field. */ -#define RADIO_EVENTS_RSSIEND_EVENTS_RSSIEND_Msk (0x1UL << RADIO_EVENTS_RSSIEND_EVENTS_RSSIEND_Pos) /*!< Bit mask of EVENTS_RSSIEND field. */ - -/* Register: RADIO_EVENTS_BCMATCH */ -/* Description: Bit counter reached bit count value. */ - -/* Bit 0 : */ -#define RADIO_EVENTS_BCMATCH_EVENTS_BCMATCH_Pos (0UL) /*!< Position of EVENTS_BCMATCH field. */ -#define RADIO_EVENTS_BCMATCH_EVENTS_BCMATCH_Msk (0x1UL << RADIO_EVENTS_BCMATCH_EVENTS_BCMATCH_Pos) /*!< Bit mask of EVENTS_BCMATCH field. */ - -/* Register: RADIO_EVENTS_CRCOK */ -/* Description: Packet received with CRC ok */ - -/* Bit 0 : */ -#define RADIO_EVENTS_CRCOK_EVENTS_CRCOK_Pos (0UL) /*!< Position of EVENTS_CRCOK field. */ -#define RADIO_EVENTS_CRCOK_EVENTS_CRCOK_Msk (0x1UL << RADIO_EVENTS_CRCOK_EVENTS_CRCOK_Pos) /*!< Bit mask of EVENTS_CRCOK field. */ - -/* Register: RADIO_EVENTS_CRCERROR */ -/* Description: Packet received with CRC error */ - -/* Bit 0 : */ -#define RADIO_EVENTS_CRCERROR_EVENTS_CRCERROR_Pos (0UL) /*!< Position of EVENTS_CRCERROR field. */ -#define RADIO_EVENTS_CRCERROR_EVENTS_CRCERROR_Msk (0x1UL << RADIO_EVENTS_CRCERROR_EVENTS_CRCERROR_Pos) /*!< Bit mask of EVENTS_CRCERROR field. */ - -/* Register: RADIO_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 8 : Shortcut between DISABLED event and RSSISTOP task */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Pos (8UL) /*!< Position of DISABLED_RSSISTOP field. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Msk (0x1UL << RADIO_SHORTS_DISABLED_RSSISTOP_Pos) /*!< Bit mask of DISABLED_RSSISTOP field. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 6 : Shortcut between ADDRESS event and BCSTART task */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Pos (6UL) /*!< Position of ADDRESS_BCSTART field. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Msk (0x1UL << RADIO_SHORTS_ADDRESS_BCSTART_Pos) /*!< Bit mask of ADDRESS_BCSTART field. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between END event and START task */ -#define RADIO_SHORTS_END_START_Pos (5UL) /*!< Position of END_START field. */ -#define RADIO_SHORTS_END_START_Msk (0x1UL << RADIO_SHORTS_END_START_Pos) /*!< Bit mask of END_START field. */ -#define RADIO_SHORTS_END_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_END_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 4 : Shortcut between ADDRESS event and RSSISTART task */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Pos (4UL) /*!< Position of ADDRESS_RSSISTART field. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Msk (0x1UL << RADIO_SHORTS_ADDRESS_RSSISTART_Pos) /*!< Bit mask of ADDRESS_RSSISTART field. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between DISABLED event and RXEN task */ -#define RADIO_SHORTS_DISABLED_RXEN_Pos (3UL) /*!< Position of DISABLED_RXEN field. */ -#define RADIO_SHORTS_DISABLED_RXEN_Msk (0x1UL << RADIO_SHORTS_DISABLED_RXEN_Pos) /*!< Bit mask of DISABLED_RXEN field. */ -#define RADIO_SHORTS_DISABLED_RXEN_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_DISABLED_RXEN_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between DISABLED event and TXEN task */ -#define RADIO_SHORTS_DISABLED_TXEN_Pos (2UL) /*!< Position of DISABLED_TXEN field. */ -#define RADIO_SHORTS_DISABLED_TXEN_Msk (0x1UL << RADIO_SHORTS_DISABLED_TXEN_Pos) /*!< Bit mask of DISABLED_TXEN field. */ -#define RADIO_SHORTS_DISABLED_TXEN_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_DISABLED_TXEN_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between END event and DISABLE task */ -#define RADIO_SHORTS_END_DISABLE_Pos (1UL) /*!< Position of END_DISABLE field. */ -#define RADIO_SHORTS_END_DISABLE_Msk (0x1UL << RADIO_SHORTS_END_DISABLE_Pos) /*!< Bit mask of END_DISABLE field. */ -#define RADIO_SHORTS_END_DISABLE_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_END_DISABLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between READY event and START task */ -#define RADIO_SHORTS_READY_START_Pos (0UL) /*!< Position of READY_START field. */ -#define RADIO_SHORTS_READY_START_Msk (0x1UL << RADIO_SHORTS_READY_START_Pos) /*!< Bit mask of READY_START field. */ -#define RADIO_SHORTS_READY_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_READY_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: RADIO_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 13 : Write '1' to Enable interrupt for CRCERROR event */ -#define RADIO_INTENSET_CRCERROR_Pos (13UL) /*!< Position of CRCERROR field. */ -#define RADIO_INTENSET_CRCERROR_Msk (0x1UL << RADIO_INTENSET_CRCERROR_Pos) /*!< Bit mask of CRCERROR field. */ -#define RADIO_INTENSET_CRCERROR_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CRCERROR_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CRCERROR_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for CRCOK event */ -#define RADIO_INTENSET_CRCOK_Pos (12UL) /*!< Position of CRCOK field. */ -#define RADIO_INTENSET_CRCOK_Msk (0x1UL << RADIO_INTENSET_CRCOK_Pos) /*!< Bit mask of CRCOK field. */ -#define RADIO_INTENSET_CRCOK_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CRCOK_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CRCOK_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for BCMATCH event */ -#define RADIO_INTENSET_BCMATCH_Pos (10UL) /*!< Position of BCMATCH field. */ -#define RADIO_INTENSET_BCMATCH_Msk (0x1UL << RADIO_INTENSET_BCMATCH_Pos) /*!< Bit mask of BCMATCH field. */ -#define RADIO_INTENSET_BCMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_BCMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_BCMATCH_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for RSSIEND event */ -#define RADIO_INTENSET_RSSIEND_Pos (7UL) /*!< Position of RSSIEND field. */ -#define RADIO_INTENSET_RSSIEND_Msk (0x1UL << RADIO_INTENSET_RSSIEND_Pos) /*!< Bit mask of RSSIEND field. */ -#define RADIO_INTENSET_RSSIEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_RSSIEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_RSSIEND_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for DEVMISS event */ -#define RADIO_INTENSET_DEVMISS_Pos (6UL) /*!< Position of DEVMISS field. */ -#define RADIO_INTENSET_DEVMISS_Msk (0x1UL << RADIO_INTENSET_DEVMISS_Pos) /*!< Bit mask of DEVMISS field. */ -#define RADIO_INTENSET_DEVMISS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_DEVMISS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_DEVMISS_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for DEVMATCH event */ -#define RADIO_INTENSET_DEVMATCH_Pos (5UL) /*!< Position of DEVMATCH field. */ -#define RADIO_INTENSET_DEVMATCH_Msk (0x1UL << RADIO_INTENSET_DEVMATCH_Pos) /*!< Bit mask of DEVMATCH field. */ -#define RADIO_INTENSET_DEVMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_DEVMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_DEVMATCH_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for DISABLED event */ -#define RADIO_INTENSET_DISABLED_Pos (4UL) /*!< Position of DISABLED field. */ -#define RADIO_INTENSET_DISABLED_Msk (0x1UL << RADIO_INTENSET_DISABLED_Pos) /*!< Bit mask of DISABLED field. */ -#define RADIO_INTENSET_DISABLED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_DISABLED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_DISABLED_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for END event */ -#define RADIO_INTENSET_END_Pos (3UL) /*!< Position of END field. */ -#define RADIO_INTENSET_END_Msk (0x1UL << RADIO_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define RADIO_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for PAYLOAD event */ -#define RADIO_INTENSET_PAYLOAD_Pos (2UL) /*!< Position of PAYLOAD field. */ -#define RADIO_INTENSET_PAYLOAD_Msk (0x1UL << RADIO_INTENSET_PAYLOAD_Pos) /*!< Bit mask of PAYLOAD field. */ -#define RADIO_INTENSET_PAYLOAD_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_PAYLOAD_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_PAYLOAD_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for ADDRESS event */ -#define RADIO_INTENSET_ADDRESS_Pos (1UL) /*!< Position of ADDRESS field. */ -#define RADIO_INTENSET_ADDRESS_Msk (0x1UL << RADIO_INTENSET_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ -#define RADIO_INTENSET_ADDRESS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_ADDRESS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_ADDRESS_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define RADIO_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define RADIO_INTENSET_READY_Msk (0x1UL << RADIO_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define RADIO_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: RADIO_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 13 : Write '1' to Disable interrupt for CRCERROR event */ -#define RADIO_INTENCLR_CRCERROR_Pos (13UL) /*!< Position of CRCERROR field. */ -#define RADIO_INTENCLR_CRCERROR_Msk (0x1UL << RADIO_INTENCLR_CRCERROR_Pos) /*!< Bit mask of CRCERROR field. */ -#define RADIO_INTENCLR_CRCERROR_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CRCERROR_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CRCERROR_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for CRCOK event */ -#define RADIO_INTENCLR_CRCOK_Pos (12UL) /*!< Position of CRCOK field. */ -#define RADIO_INTENCLR_CRCOK_Msk (0x1UL << RADIO_INTENCLR_CRCOK_Pos) /*!< Bit mask of CRCOK field. */ -#define RADIO_INTENCLR_CRCOK_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CRCOK_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CRCOK_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for BCMATCH event */ -#define RADIO_INTENCLR_BCMATCH_Pos (10UL) /*!< Position of BCMATCH field. */ -#define RADIO_INTENCLR_BCMATCH_Msk (0x1UL << RADIO_INTENCLR_BCMATCH_Pos) /*!< Bit mask of BCMATCH field. */ -#define RADIO_INTENCLR_BCMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_BCMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_BCMATCH_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for RSSIEND event */ -#define RADIO_INTENCLR_RSSIEND_Pos (7UL) /*!< Position of RSSIEND field. */ -#define RADIO_INTENCLR_RSSIEND_Msk (0x1UL << RADIO_INTENCLR_RSSIEND_Pos) /*!< Bit mask of RSSIEND field. */ -#define RADIO_INTENCLR_RSSIEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_RSSIEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_RSSIEND_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for DEVMISS event */ -#define RADIO_INTENCLR_DEVMISS_Pos (6UL) /*!< Position of DEVMISS field. */ -#define RADIO_INTENCLR_DEVMISS_Msk (0x1UL << RADIO_INTENCLR_DEVMISS_Pos) /*!< Bit mask of DEVMISS field. */ -#define RADIO_INTENCLR_DEVMISS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_DEVMISS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_DEVMISS_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for DEVMATCH event */ -#define RADIO_INTENCLR_DEVMATCH_Pos (5UL) /*!< Position of DEVMATCH field. */ -#define RADIO_INTENCLR_DEVMATCH_Msk (0x1UL << RADIO_INTENCLR_DEVMATCH_Pos) /*!< Bit mask of DEVMATCH field. */ -#define RADIO_INTENCLR_DEVMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_DEVMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_DEVMATCH_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for DISABLED event */ -#define RADIO_INTENCLR_DISABLED_Pos (4UL) /*!< Position of DISABLED field. */ -#define RADIO_INTENCLR_DISABLED_Msk (0x1UL << RADIO_INTENCLR_DISABLED_Pos) /*!< Bit mask of DISABLED field. */ -#define RADIO_INTENCLR_DISABLED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_DISABLED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_DISABLED_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for END event */ -#define RADIO_INTENCLR_END_Pos (3UL) /*!< Position of END field. */ -#define RADIO_INTENCLR_END_Msk (0x1UL << RADIO_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define RADIO_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for PAYLOAD event */ -#define RADIO_INTENCLR_PAYLOAD_Pos (2UL) /*!< Position of PAYLOAD field. */ -#define RADIO_INTENCLR_PAYLOAD_Msk (0x1UL << RADIO_INTENCLR_PAYLOAD_Pos) /*!< Bit mask of PAYLOAD field. */ -#define RADIO_INTENCLR_PAYLOAD_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_PAYLOAD_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_PAYLOAD_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for ADDRESS event */ -#define RADIO_INTENCLR_ADDRESS_Pos (1UL) /*!< Position of ADDRESS field. */ -#define RADIO_INTENCLR_ADDRESS_Msk (0x1UL << RADIO_INTENCLR_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ -#define RADIO_INTENCLR_ADDRESS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_ADDRESS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_ADDRESS_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define RADIO_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define RADIO_INTENCLR_READY_Msk (0x1UL << RADIO_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define RADIO_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: RADIO_CRCSTATUS */ -/* Description: CRC status */ - -/* Bit 0 : CRC status of packet received */ -#define RADIO_CRCSTATUS_CRCSTATUS_Pos (0UL) /*!< Position of CRCSTATUS field. */ -#define RADIO_CRCSTATUS_CRCSTATUS_Msk (0x1UL << RADIO_CRCSTATUS_CRCSTATUS_Pos) /*!< Bit mask of CRCSTATUS field. */ -#define RADIO_CRCSTATUS_CRCSTATUS_CRCError (0UL) /*!< Packet received with CRC error */ -#define RADIO_CRCSTATUS_CRCSTATUS_CRCOk (1UL) /*!< Packet received with CRC ok */ - -/* Register: RADIO_RXMATCH */ -/* Description: Received address */ - -/* Bits 2..0 : Received address */ -#define RADIO_RXMATCH_RXMATCH_Pos (0UL) /*!< Position of RXMATCH field. */ -#define RADIO_RXMATCH_RXMATCH_Msk (0x7UL << RADIO_RXMATCH_RXMATCH_Pos) /*!< Bit mask of RXMATCH field. */ - -/* Register: RADIO_RXCRC */ -/* Description: CRC field of previously received packet */ - -/* Bits 23..0 : CRC field of previously received packet */ -#define RADIO_RXCRC_RXCRC_Pos (0UL) /*!< Position of RXCRC field. */ -#define RADIO_RXCRC_RXCRC_Msk (0xFFFFFFUL << RADIO_RXCRC_RXCRC_Pos) /*!< Bit mask of RXCRC field. */ - -/* Register: RADIO_DAI */ -/* Description: Device address match index */ - -/* Bits 2..0 : Device address match index */ -#define RADIO_DAI_DAI_Pos (0UL) /*!< Position of DAI field. */ -#define RADIO_DAI_DAI_Msk (0x7UL << RADIO_DAI_DAI_Pos) /*!< Bit mask of DAI field. */ - -/* Register: RADIO_PACKETPTR */ -/* Description: Packet pointer */ - -/* Bits 31..0 : Packet pointer */ -#define RADIO_PACKETPTR_PACKETPTR_Pos (0UL) /*!< Position of PACKETPTR field. */ -#define RADIO_PACKETPTR_PACKETPTR_Msk (0xFFFFFFFFUL << RADIO_PACKETPTR_PACKETPTR_Pos) /*!< Bit mask of PACKETPTR field. */ - -/* Register: RADIO_FREQUENCY */ -/* Description: Frequency */ - -/* Bit 8 : Channel map selection. */ -#define RADIO_FREQUENCY_MAP_Pos (8UL) /*!< Position of MAP field. */ -#define RADIO_FREQUENCY_MAP_Msk (0x1UL << RADIO_FREQUENCY_MAP_Pos) /*!< Bit mask of MAP field. */ -#define RADIO_FREQUENCY_MAP_Default (0UL) /*!< Channel map between 2400 MHZ .. 2500 MHz */ -#define RADIO_FREQUENCY_MAP_Low (1UL) /*!< Channel map between 2360 MHZ .. 2460 MHz */ - -/* Bits 6..0 : Radio channel frequency */ -#define RADIO_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define RADIO_FREQUENCY_FREQUENCY_Msk (0x7FUL << RADIO_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ - -/* Register: RADIO_TXPOWER */ -/* Description: Output power */ - -/* Bits 7..0 : RADIO output power. */ -#define RADIO_TXPOWER_TXPOWER_Pos (0UL) /*!< Position of TXPOWER field. */ -#define RADIO_TXPOWER_TXPOWER_Msk (0xFFUL << RADIO_TXPOWER_TXPOWER_Pos) /*!< Bit mask of TXPOWER field. */ -#define RADIO_TXPOWER_TXPOWER_0dBm (0x00UL) /*!< 0 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos3dBm (0x03UL) /*!< +3 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos4dBm (0x04UL) /*!< +4 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg30dBm (0xD8UL) /*!< Deprecated enumerator - -40 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg40dBm (0xD8UL) /*!< -40 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg20dBm (0xECUL) /*!< -20 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg16dBm (0xF0UL) /*!< -16 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg12dBm (0xF4UL) /*!< -12 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg8dBm (0xF8UL) /*!< -8 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg4dBm (0xFCUL) /*!< -4 dBm */ - -/* Register: RADIO_MODE */ -/* Description: Data rate and modulation */ - -/* Bits 3..0 : Radio data rate and modulation setting. The radio supports Frequency-shift Keying (FSK) modulation. */ -#define RADIO_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define RADIO_MODE_MODE_Msk (0xFUL << RADIO_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define RADIO_MODE_MODE_Nrf_1Mbit (0UL) /*!< 1 Mbit/s Nordic proprietary radio mode */ -#define RADIO_MODE_MODE_Nrf_2Mbit (1UL) /*!< 2 Mbit/s Nordic proprietary radio mode */ -#define RADIO_MODE_MODE_Ble_1Mbit (3UL) /*!< 1 Mbit/s Bluetooth Low Energy */ -#define RADIO_MODE_MODE_Ble_2Mbit (4UL) /*!< 2 Mbit/s Bluetooth Low Energy */ - -/* Register: RADIO_PCNF0 */ -/* Description: Packet configuration register 0 */ - -/* Bit 24 : Length of preamble on air. Decision point: TASKS_START task */ -#define RADIO_PCNF0_PLEN_Pos (24UL) /*!< Position of PLEN field. */ -#define RADIO_PCNF0_PLEN_Msk (0x1UL << RADIO_PCNF0_PLEN_Pos) /*!< Bit mask of PLEN field. */ -#define RADIO_PCNF0_PLEN_8bit (0UL) /*!< 8-bit preamble */ -#define RADIO_PCNF0_PLEN_16bit (1UL) /*!< 16-bit preamble */ - -/* Bit 20 : Include or exclude S1 field in RAM */ -#define RADIO_PCNF0_S1INCL_Pos (20UL) /*!< Position of S1INCL field. */ -#define RADIO_PCNF0_S1INCL_Msk (0x1UL << RADIO_PCNF0_S1INCL_Pos) /*!< Bit mask of S1INCL field. */ -#define RADIO_PCNF0_S1INCL_Automatic (0UL) /*!< Include S1 field in RAM only if S1LEN > 0 */ -#define RADIO_PCNF0_S1INCL_Include (1UL) /*!< Always include S1 field in RAM independent of S1LEN */ - -/* Bits 19..16 : Length on air of S1 field in number of bits. */ -#define RADIO_PCNF0_S1LEN_Pos (16UL) /*!< Position of S1LEN field. */ -#define RADIO_PCNF0_S1LEN_Msk (0xFUL << RADIO_PCNF0_S1LEN_Pos) /*!< Bit mask of S1LEN field. */ - -/* Bit 8 : Length on air of S0 field in number of bytes. */ -#define RADIO_PCNF0_S0LEN_Pos (8UL) /*!< Position of S0LEN field. */ -#define RADIO_PCNF0_S0LEN_Msk (0x1UL << RADIO_PCNF0_S0LEN_Pos) /*!< Bit mask of S0LEN field. */ - -/* Bits 3..0 : Length on air of LENGTH field in number of bits. */ -#define RADIO_PCNF0_LFLEN_Pos (0UL) /*!< Position of LFLEN field. */ -#define RADIO_PCNF0_LFLEN_Msk (0xFUL << RADIO_PCNF0_LFLEN_Pos) /*!< Bit mask of LFLEN field. */ - -/* Register: RADIO_PCNF1 */ -/* Description: Packet configuration register 1 */ - -/* Bit 25 : Enable or disable packet whitening */ -#define RADIO_PCNF1_WHITEEN_Pos (25UL) /*!< Position of WHITEEN field. */ -#define RADIO_PCNF1_WHITEEN_Msk (0x1UL << RADIO_PCNF1_WHITEEN_Pos) /*!< Bit mask of WHITEEN field. */ -#define RADIO_PCNF1_WHITEEN_Disabled (0UL) /*!< Disable */ -#define RADIO_PCNF1_WHITEEN_Enabled (1UL) /*!< Enable */ - -/* Bit 24 : On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields. */ -#define RADIO_PCNF1_ENDIAN_Pos (24UL) /*!< Position of ENDIAN field. */ -#define RADIO_PCNF1_ENDIAN_Msk (0x1UL << RADIO_PCNF1_ENDIAN_Pos) /*!< Bit mask of ENDIAN field. */ -#define RADIO_PCNF1_ENDIAN_Little (0UL) /*!< Least Significant bit on air first */ -#define RADIO_PCNF1_ENDIAN_Big (1UL) /*!< Most significant bit on air first */ - -/* Bits 18..16 : Base address length in number of bytes */ -#define RADIO_PCNF1_BALEN_Pos (16UL) /*!< Position of BALEN field. */ -#define RADIO_PCNF1_BALEN_Msk (0x7UL << RADIO_PCNF1_BALEN_Pos) /*!< Bit mask of BALEN field. */ - -/* Bits 15..8 : Static length in number of bytes */ -#define RADIO_PCNF1_STATLEN_Pos (8UL) /*!< Position of STATLEN field. */ -#define RADIO_PCNF1_STATLEN_Msk (0xFFUL << RADIO_PCNF1_STATLEN_Pos) /*!< Bit mask of STATLEN field. */ - -/* Bits 7..0 : Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN. */ -#define RADIO_PCNF1_MAXLEN_Pos (0UL) /*!< Position of MAXLEN field. */ -#define RADIO_PCNF1_MAXLEN_Msk (0xFFUL << RADIO_PCNF1_MAXLEN_Pos) /*!< Bit mask of MAXLEN field. */ - -/* Register: RADIO_BASE0 */ -/* Description: Base address 0 */ - -/* Bits 31..0 : Base address 0 */ -#define RADIO_BASE0_BASE0_Pos (0UL) /*!< Position of BASE0 field. */ -#define RADIO_BASE0_BASE0_Msk (0xFFFFFFFFUL << RADIO_BASE0_BASE0_Pos) /*!< Bit mask of BASE0 field. */ - -/* Register: RADIO_BASE1 */ -/* Description: Base address 1 */ - -/* Bits 31..0 : Base address 1 */ -#define RADIO_BASE1_BASE1_Pos (0UL) /*!< Position of BASE1 field. */ -#define RADIO_BASE1_BASE1_Msk (0xFFFFFFFFUL << RADIO_BASE1_BASE1_Pos) /*!< Bit mask of BASE1 field. */ - -/* Register: RADIO_PREFIX0 */ -/* Description: Prefixes bytes for logical addresses 0-3 */ - -/* Bits 31..24 : Address prefix 3. */ -#define RADIO_PREFIX0_AP3_Pos (24UL) /*!< Position of AP3 field. */ -#define RADIO_PREFIX0_AP3_Msk (0xFFUL << RADIO_PREFIX0_AP3_Pos) /*!< Bit mask of AP3 field. */ - -/* Bits 23..16 : Address prefix 2. */ -#define RADIO_PREFIX0_AP2_Pos (16UL) /*!< Position of AP2 field. */ -#define RADIO_PREFIX0_AP2_Msk (0xFFUL << RADIO_PREFIX0_AP2_Pos) /*!< Bit mask of AP2 field. */ - -/* Bits 15..8 : Address prefix 1. */ -#define RADIO_PREFIX0_AP1_Pos (8UL) /*!< Position of AP1 field. */ -#define RADIO_PREFIX0_AP1_Msk (0xFFUL << RADIO_PREFIX0_AP1_Pos) /*!< Bit mask of AP1 field. */ - -/* Bits 7..0 : Address prefix 0. */ -#define RADIO_PREFIX0_AP0_Pos (0UL) /*!< Position of AP0 field. */ -#define RADIO_PREFIX0_AP0_Msk (0xFFUL << RADIO_PREFIX0_AP0_Pos) /*!< Bit mask of AP0 field. */ - -/* Register: RADIO_PREFIX1 */ -/* Description: Prefixes bytes for logical addresses 4-7 */ - -/* Bits 31..24 : Address prefix 7. */ -#define RADIO_PREFIX1_AP7_Pos (24UL) /*!< Position of AP7 field. */ -#define RADIO_PREFIX1_AP7_Msk (0xFFUL << RADIO_PREFIX1_AP7_Pos) /*!< Bit mask of AP7 field. */ - -/* Bits 23..16 : Address prefix 6. */ -#define RADIO_PREFIX1_AP6_Pos (16UL) /*!< Position of AP6 field. */ -#define RADIO_PREFIX1_AP6_Msk (0xFFUL << RADIO_PREFIX1_AP6_Pos) /*!< Bit mask of AP6 field. */ - -/* Bits 15..8 : Address prefix 5. */ -#define RADIO_PREFIX1_AP5_Pos (8UL) /*!< Position of AP5 field. */ -#define RADIO_PREFIX1_AP5_Msk (0xFFUL << RADIO_PREFIX1_AP5_Pos) /*!< Bit mask of AP5 field. */ - -/* Bits 7..0 : Address prefix 4. */ -#define RADIO_PREFIX1_AP4_Pos (0UL) /*!< Position of AP4 field. */ -#define RADIO_PREFIX1_AP4_Msk (0xFFUL << RADIO_PREFIX1_AP4_Pos) /*!< Bit mask of AP4 field. */ - -/* Register: RADIO_TXADDRESS */ -/* Description: Transmit address select */ - -/* Bits 2..0 : Transmit address select */ -#define RADIO_TXADDRESS_TXADDRESS_Pos (0UL) /*!< Position of TXADDRESS field. */ -#define RADIO_TXADDRESS_TXADDRESS_Msk (0x7UL << RADIO_TXADDRESS_TXADDRESS_Pos) /*!< Bit mask of TXADDRESS field. */ - -/* Register: RADIO_RXADDRESSES */ -/* Description: Receive address select */ - -/* Bit 7 : Enable or disable reception on logical address 7. */ -#define RADIO_RXADDRESSES_ADDR7_Pos (7UL) /*!< Position of ADDR7 field. */ -#define RADIO_RXADDRESSES_ADDR7_Msk (0x1UL << RADIO_RXADDRESSES_ADDR7_Pos) /*!< Bit mask of ADDR7 field. */ -#define RADIO_RXADDRESSES_ADDR7_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR7_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable reception on logical address 6. */ -#define RADIO_RXADDRESSES_ADDR6_Pos (6UL) /*!< Position of ADDR6 field. */ -#define RADIO_RXADDRESSES_ADDR6_Msk (0x1UL << RADIO_RXADDRESSES_ADDR6_Pos) /*!< Bit mask of ADDR6 field. */ -#define RADIO_RXADDRESSES_ADDR6_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR6_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable reception on logical address 5. */ -#define RADIO_RXADDRESSES_ADDR5_Pos (5UL) /*!< Position of ADDR5 field. */ -#define RADIO_RXADDRESSES_ADDR5_Msk (0x1UL << RADIO_RXADDRESSES_ADDR5_Pos) /*!< Bit mask of ADDR5 field. */ -#define RADIO_RXADDRESSES_ADDR5_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR5_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable reception on logical address 4. */ -#define RADIO_RXADDRESSES_ADDR4_Pos (4UL) /*!< Position of ADDR4 field. */ -#define RADIO_RXADDRESSES_ADDR4_Msk (0x1UL << RADIO_RXADDRESSES_ADDR4_Pos) /*!< Bit mask of ADDR4 field. */ -#define RADIO_RXADDRESSES_ADDR4_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR4_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable reception on logical address 3. */ -#define RADIO_RXADDRESSES_ADDR3_Pos (3UL) /*!< Position of ADDR3 field. */ -#define RADIO_RXADDRESSES_ADDR3_Msk (0x1UL << RADIO_RXADDRESSES_ADDR3_Pos) /*!< Bit mask of ADDR3 field. */ -#define RADIO_RXADDRESSES_ADDR3_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR3_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable reception on logical address 2. */ -#define RADIO_RXADDRESSES_ADDR2_Pos (2UL) /*!< Position of ADDR2 field. */ -#define RADIO_RXADDRESSES_ADDR2_Msk (0x1UL << RADIO_RXADDRESSES_ADDR2_Pos) /*!< Bit mask of ADDR2 field. */ -#define RADIO_RXADDRESSES_ADDR2_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR2_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable reception on logical address 1. */ -#define RADIO_RXADDRESSES_ADDR1_Pos (1UL) /*!< Position of ADDR1 field. */ -#define RADIO_RXADDRESSES_ADDR1_Msk (0x1UL << RADIO_RXADDRESSES_ADDR1_Pos) /*!< Bit mask of ADDR1 field. */ -#define RADIO_RXADDRESSES_ADDR1_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR1_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable reception on logical address 0. */ -#define RADIO_RXADDRESSES_ADDR0_Pos (0UL) /*!< Position of ADDR0 field. */ -#define RADIO_RXADDRESSES_ADDR0_Msk (0x1UL << RADIO_RXADDRESSES_ADDR0_Pos) /*!< Bit mask of ADDR0 field. */ -#define RADIO_RXADDRESSES_ADDR0_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR0_Enabled (1UL) /*!< Enable */ - -/* Register: RADIO_CRCCNF */ -/* Description: CRC configuration */ - -/* Bit 8 : Include or exclude packet address field out of CRC calculation. */ -#define RADIO_CRCCNF_SKIPADDR_Pos (8UL) /*!< Position of SKIPADDR field. */ -#define RADIO_CRCCNF_SKIPADDR_Msk (0x1UL << RADIO_CRCCNF_SKIPADDR_Pos) /*!< Bit mask of SKIPADDR field. */ -#define RADIO_CRCCNF_SKIPADDR_Include (0UL) /*!< CRC calculation includes address field */ -#define RADIO_CRCCNF_SKIPADDR_Skip (1UL) /*!< CRC calculation does not include address field. The CRC calculation will start at the first byte after the address. */ - -/* Bits 1..0 : CRC length in number of bytes. */ -#define RADIO_CRCCNF_LEN_Pos (0UL) /*!< Position of LEN field. */ -#define RADIO_CRCCNF_LEN_Msk (0x3UL << RADIO_CRCCNF_LEN_Pos) /*!< Bit mask of LEN field. */ -#define RADIO_CRCCNF_LEN_Disabled (0UL) /*!< CRC length is zero and CRC calculation is disabled */ -#define RADIO_CRCCNF_LEN_One (1UL) /*!< CRC length is one byte and CRC calculation is enabled */ -#define RADIO_CRCCNF_LEN_Two (2UL) /*!< CRC length is two bytes and CRC calculation is enabled */ -#define RADIO_CRCCNF_LEN_Three (3UL) /*!< CRC length is three bytes and CRC calculation is enabled */ - -/* Register: RADIO_CRCPOLY */ -/* Description: CRC polynomial */ - -/* Bits 23..0 : CRC polynomial */ -#define RADIO_CRCPOLY_CRCPOLY_Pos (0UL) /*!< Position of CRCPOLY field. */ -#define RADIO_CRCPOLY_CRCPOLY_Msk (0xFFFFFFUL << RADIO_CRCPOLY_CRCPOLY_Pos) /*!< Bit mask of CRCPOLY field. */ - -/* Register: RADIO_CRCINIT */ -/* Description: CRC initial value */ - -/* Bits 23..0 : CRC initial value */ -#define RADIO_CRCINIT_CRCINIT_Pos (0UL) /*!< Position of CRCINIT field. */ -#define RADIO_CRCINIT_CRCINIT_Msk (0xFFFFFFUL << RADIO_CRCINIT_CRCINIT_Pos) /*!< Bit mask of CRCINIT field. */ - -/* Register: RADIO_TIFS */ -/* Description: Inter Frame Spacing in us */ - -/* Bits 7..0 : Inter Frame Spacing in us */ -#define RADIO_TIFS_TIFS_Pos (0UL) /*!< Position of TIFS field. */ -#define RADIO_TIFS_TIFS_Msk (0xFFUL << RADIO_TIFS_TIFS_Pos) /*!< Bit mask of TIFS field. */ - -/* Register: RADIO_RSSISAMPLE */ -/* Description: RSSI sample */ - -/* Bits 6..0 : RSSI sample */ -#define RADIO_RSSISAMPLE_RSSISAMPLE_Pos (0UL) /*!< Position of RSSISAMPLE field. */ -#define RADIO_RSSISAMPLE_RSSISAMPLE_Msk (0x7FUL << RADIO_RSSISAMPLE_RSSISAMPLE_Pos) /*!< Bit mask of RSSISAMPLE field. */ - -/* Register: RADIO_STATE */ -/* Description: Current radio state */ - -/* Bits 3..0 : Current radio state */ -#define RADIO_STATE_STATE_Pos (0UL) /*!< Position of STATE field. */ -#define RADIO_STATE_STATE_Msk (0xFUL << RADIO_STATE_STATE_Pos) /*!< Bit mask of STATE field. */ -#define RADIO_STATE_STATE_Disabled (0UL) /*!< RADIO is in the Disabled state */ -#define RADIO_STATE_STATE_RxRu (1UL) /*!< RADIO is in the RXRU state */ -#define RADIO_STATE_STATE_RxIdle (2UL) /*!< RADIO is in the RXIDLE state */ -#define RADIO_STATE_STATE_Rx (3UL) /*!< RADIO is in the RX state */ -#define RADIO_STATE_STATE_RxDisable (4UL) /*!< RADIO is in the RXDISABLED state */ -#define RADIO_STATE_STATE_TxRu (9UL) /*!< RADIO is in the TXRU state */ -#define RADIO_STATE_STATE_TxIdle (10UL) /*!< RADIO is in the TXIDLE state */ -#define RADIO_STATE_STATE_Tx (11UL) /*!< RADIO is in the TX state */ -#define RADIO_STATE_STATE_TxDisable (12UL) /*!< RADIO is in the TXDISABLED state */ - -/* Register: RADIO_DATAWHITEIV */ -/* Description: Data whitening initial value */ - -/* Bits 6..0 : Data whitening initial value. Bit 6 is hard-wired to '1', writing '0' to it has no effect, and it will always be read back and used by the device as '1'. */ -#define RADIO_DATAWHITEIV_DATAWHITEIV_Pos (0UL) /*!< Position of DATAWHITEIV field. */ -#define RADIO_DATAWHITEIV_DATAWHITEIV_Msk (0x7FUL << RADIO_DATAWHITEIV_DATAWHITEIV_Pos) /*!< Bit mask of DATAWHITEIV field. */ - -/* Register: RADIO_BCC */ -/* Description: Bit counter compare */ - -/* Bits 31..0 : Bit counter compare */ -#define RADIO_BCC_BCC_Pos (0UL) /*!< Position of BCC field. */ -#define RADIO_BCC_BCC_Msk (0xFFFFFFFFUL << RADIO_BCC_BCC_Pos) /*!< Bit mask of BCC field. */ - -/* Register: RADIO_DAB */ -/* Description: Description collection[0]: Device address base segment 0 */ - -/* Bits 31..0 : Device address base segment 0 */ -#define RADIO_DAB_DAB_Pos (0UL) /*!< Position of DAB field. */ -#define RADIO_DAB_DAB_Msk (0xFFFFFFFFUL << RADIO_DAB_DAB_Pos) /*!< Bit mask of DAB field. */ - -/* Register: RADIO_DAP */ -/* Description: Description collection[0]: Device address prefix 0 */ - -/* Bits 15..0 : Device address prefix 0 */ -#define RADIO_DAP_DAP_Pos (0UL) /*!< Position of DAP field. */ -#define RADIO_DAP_DAP_Msk (0xFFFFUL << RADIO_DAP_DAP_Pos) /*!< Bit mask of DAP field. */ - -/* Register: RADIO_DACNF */ -/* Description: Device address match configuration */ - -/* Bit 15 : TxAdd for device address 7 */ -#define RADIO_DACNF_TXADD7_Pos (15UL) /*!< Position of TXADD7 field. */ -#define RADIO_DACNF_TXADD7_Msk (0x1UL << RADIO_DACNF_TXADD7_Pos) /*!< Bit mask of TXADD7 field. */ - -/* Bit 14 : TxAdd for device address 6 */ -#define RADIO_DACNF_TXADD6_Pos (14UL) /*!< Position of TXADD6 field. */ -#define RADIO_DACNF_TXADD6_Msk (0x1UL << RADIO_DACNF_TXADD6_Pos) /*!< Bit mask of TXADD6 field. */ - -/* Bit 13 : TxAdd for device address 5 */ -#define RADIO_DACNF_TXADD5_Pos (13UL) /*!< Position of TXADD5 field. */ -#define RADIO_DACNF_TXADD5_Msk (0x1UL << RADIO_DACNF_TXADD5_Pos) /*!< Bit mask of TXADD5 field. */ - -/* Bit 12 : TxAdd for device address 4 */ -#define RADIO_DACNF_TXADD4_Pos (12UL) /*!< Position of TXADD4 field. */ -#define RADIO_DACNF_TXADD4_Msk (0x1UL << RADIO_DACNF_TXADD4_Pos) /*!< Bit mask of TXADD4 field. */ - -/* Bit 11 : TxAdd for device address 3 */ -#define RADIO_DACNF_TXADD3_Pos (11UL) /*!< Position of TXADD3 field. */ -#define RADIO_DACNF_TXADD3_Msk (0x1UL << RADIO_DACNF_TXADD3_Pos) /*!< Bit mask of TXADD3 field. */ - -/* Bit 10 : TxAdd for device address 2 */ -#define RADIO_DACNF_TXADD2_Pos (10UL) /*!< Position of TXADD2 field. */ -#define RADIO_DACNF_TXADD2_Msk (0x1UL << RADIO_DACNF_TXADD2_Pos) /*!< Bit mask of TXADD2 field. */ - -/* Bit 9 : TxAdd for device address 1 */ -#define RADIO_DACNF_TXADD1_Pos (9UL) /*!< Position of TXADD1 field. */ -#define RADIO_DACNF_TXADD1_Msk (0x1UL << RADIO_DACNF_TXADD1_Pos) /*!< Bit mask of TXADD1 field. */ - -/* Bit 8 : TxAdd for device address 0 */ -#define RADIO_DACNF_TXADD0_Pos (8UL) /*!< Position of TXADD0 field. */ -#define RADIO_DACNF_TXADD0_Msk (0x1UL << RADIO_DACNF_TXADD0_Pos) /*!< Bit mask of TXADD0 field. */ - -/* Bit 7 : Enable or disable device address matching using device address 7 */ -#define RADIO_DACNF_ENA7_Pos (7UL) /*!< Position of ENA7 field. */ -#define RADIO_DACNF_ENA7_Msk (0x1UL << RADIO_DACNF_ENA7_Pos) /*!< Bit mask of ENA7 field. */ -#define RADIO_DACNF_ENA7_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA7_Enabled (1UL) /*!< Enabled */ - -/* Bit 6 : Enable or disable device address matching using device address 6 */ -#define RADIO_DACNF_ENA6_Pos (6UL) /*!< Position of ENA6 field. */ -#define RADIO_DACNF_ENA6_Msk (0x1UL << RADIO_DACNF_ENA6_Pos) /*!< Bit mask of ENA6 field. */ -#define RADIO_DACNF_ENA6_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA6_Enabled (1UL) /*!< Enabled */ - -/* Bit 5 : Enable or disable device address matching using device address 5 */ -#define RADIO_DACNF_ENA5_Pos (5UL) /*!< Position of ENA5 field. */ -#define RADIO_DACNF_ENA5_Msk (0x1UL << RADIO_DACNF_ENA5_Pos) /*!< Bit mask of ENA5 field. */ -#define RADIO_DACNF_ENA5_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA5_Enabled (1UL) /*!< Enabled */ - -/* Bit 4 : Enable or disable device address matching using device address 4 */ -#define RADIO_DACNF_ENA4_Pos (4UL) /*!< Position of ENA4 field. */ -#define RADIO_DACNF_ENA4_Msk (0x1UL << RADIO_DACNF_ENA4_Pos) /*!< Bit mask of ENA4 field. */ -#define RADIO_DACNF_ENA4_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA4_Enabled (1UL) /*!< Enabled */ - -/* Bit 3 : Enable or disable device address matching using device address 3 */ -#define RADIO_DACNF_ENA3_Pos (3UL) /*!< Position of ENA3 field. */ -#define RADIO_DACNF_ENA3_Msk (0x1UL << RADIO_DACNF_ENA3_Pos) /*!< Bit mask of ENA3 field. */ -#define RADIO_DACNF_ENA3_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA3_Enabled (1UL) /*!< Enabled */ - -/* Bit 2 : Enable or disable device address matching using device address 2 */ -#define RADIO_DACNF_ENA2_Pos (2UL) /*!< Position of ENA2 field. */ -#define RADIO_DACNF_ENA2_Msk (0x1UL << RADIO_DACNF_ENA2_Pos) /*!< Bit mask of ENA2 field. */ -#define RADIO_DACNF_ENA2_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA2_Enabled (1UL) /*!< Enabled */ - -/* Bit 1 : Enable or disable device address matching using device address 1 */ -#define RADIO_DACNF_ENA1_Pos (1UL) /*!< Position of ENA1 field. */ -#define RADIO_DACNF_ENA1_Msk (0x1UL << RADIO_DACNF_ENA1_Pos) /*!< Bit mask of ENA1 field. */ -#define RADIO_DACNF_ENA1_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA1_Enabled (1UL) /*!< Enabled */ - -/* Bit 0 : Enable or disable device address matching using device address 0 */ -#define RADIO_DACNF_ENA0_Pos (0UL) /*!< Position of ENA0 field. */ -#define RADIO_DACNF_ENA0_Msk (0x1UL << RADIO_DACNF_ENA0_Pos) /*!< Bit mask of ENA0 field. */ -#define RADIO_DACNF_ENA0_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA0_Enabled (1UL) /*!< Enabled */ - -/* Register: RADIO_MODECNF0 */ -/* Description: Radio mode configuration register 0 */ - -/* Bits 9..8 : Default TX value */ -#define RADIO_MODECNF0_DTX_Pos (8UL) /*!< Position of DTX field. */ -#define RADIO_MODECNF0_DTX_Msk (0x3UL << RADIO_MODECNF0_DTX_Pos) /*!< Bit mask of DTX field. */ -#define RADIO_MODECNF0_DTX_B1 (0UL) /*!< Transmit '1' */ -#define RADIO_MODECNF0_DTX_B0 (1UL) /*!< Transmit '0' */ -#define RADIO_MODECNF0_DTX_Center (2UL) /*!< Transmit center frequency */ - -/* Bit 0 : Radio ramp-up time */ -#define RADIO_MODECNF0_RU_Pos (0UL) /*!< Position of RU field. */ -#define RADIO_MODECNF0_RU_Msk (0x1UL << RADIO_MODECNF0_RU_Pos) /*!< Bit mask of RU field. */ -#define RADIO_MODECNF0_RU_Default (0UL) /*!< Default ramp-up time (tRXEN), compatible with firmware written for nRF51 */ -#define RADIO_MODECNF0_RU_Fast (1UL) /*!< Fast ramp-up (tRXEN,FAST), see electrical specification for more information */ - -/* Register: RADIO_POWER */ -/* Description: Peripheral power control */ - -/* Bit 0 : Peripheral power control. The peripheral and its registers will be reset to its initial state by switching the peripheral off and then back on again. */ -#define RADIO_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define RADIO_POWER_POWER_Msk (0x1UL << RADIO_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define RADIO_POWER_POWER_Disabled (0UL) /*!< Peripheral is powered off */ -#define RADIO_POWER_POWER_Enabled (1UL) /*!< Peripheral is powered on */ - - -/* Peripheral: RNG */ -/* Description: Random Number Generator */ - -/* Register: RNG_TASKS_START */ -/* Description: Task starting the random number generator */ - -/* Bit 0 : */ -#define RNG_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define RNG_TASKS_START_TASKS_START_Msk (0x1UL << RNG_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: RNG_TASKS_STOP */ -/* Description: Task stopping the random number generator */ - -/* Bit 0 : */ -#define RNG_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define RNG_TASKS_STOP_TASKS_STOP_Msk (0x1UL << RNG_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: RNG_EVENTS_VALRDY */ -/* Description: Event being generated for every new random number written to the VALUE register */ - -/* Bit 0 : */ -#define RNG_EVENTS_VALRDY_EVENTS_VALRDY_Pos (0UL) /*!< Position of EVENTS_VALRDY field. */ -#define RNG_EVENTS_VALRDY_EVENTS_VALRDY_Msk (0x1UL << RNG_EVENTS_VALRDY_EVENTS_VALRDY_Pos) /*!< Bit mask of EVENTS_VALRDY field. */ - -/* Register: RNG_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 0 : Shortcut between VALRDY event and STOP task */ -#define RNG_SHORTS_VALRDY_STOP_Pos (0UL) /*!< Position of VALRDY_STOP field. */ -#define RNG_SHORTS_VALRDY_STOP_Msk (0x1UL << RNG_SHORTS_VALRDY_STOP_Pos) /*!< Bit mask of VALRDY_STOP field. */ -#define RNG_SHORTS_VALRDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define RNG_SHORTS_VALRDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: RNG_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for VALRDY event */ -#define RNG_INTENSET_VALRDY_Pos (0UL) /*!< Position of VALRDY field. */ -#define RNG_INTENSET_VALRDY_Msk (0x1UL << RNG_INTENSET_VALRDY_Pos) /*!< Bit mask of VALRDY field. */ -#define RNG_INTENSET_VALRDY_Disabled (0UL) /*!< Read: Disabled */ -#define RNG_INTENSET_VALRDY_Enabled (1UL) /*!< Read: Enabled */ -#define RNG_INTENSET_VALRDY_Set (1UL) /*!< Enable */ - -/* Register: RNG_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for VALRDY event */ -#define RNG_INTENCLR_VALRDY_Pos (0UL) /*!< Position of VALRDY field. */ -#define RNG_INTENCLR_VALRDY_Msk (0x1UL << RNG_INTENCLR_VALRDY_Pos) /*!< Bit mask of VALRDY field. */ -#define RNG_INTENCLR_VALRDY_Disabled (0UL) /*!< Read: Disabled */ -#define RNG_INTENCLR_VALRDY_Enabled (1UL) /*!< Read: Enabled */ -#define RNG_INTENCLR_VALRDY_Clear (1UL) /*!< Disable */ - -/* Register: RNG_CONFIG */ -/* Description: Configuration register */ - -/* Bit 0 : Bias correction */ -#define RNG_CONFIG_DERCEN_Pos (0UL) /*!< Position of DERCEN field. */ -#define RNG_CONFIG_DERCEN_Msk (0x1UL << RNG_CONFIG_DERCEN_Pos) /*!< Bit mask of DERCEN field. */ -#define RNG_CONFIG_DERCEN_Disabled (0UL) /*!< Disabled */ -#define RNG_CONFIG_DERCEN_Enabled (1UL) /*!< Enabled */ - -/* Register: RNG_VALUE */ -/* Description: Output random number */ - -/* Bits 7..0 : Generated random number */ -#define RNG_VALUE_VALUE_Pos (0UL) /*!< Position of VALUE field. */ -#define RNG_VALUE_VALUE_Msk (0xFFUL << RNG_VALUE_VALUE_Pos) /*!< Bit mask of VALUE field. */ - - -/* Peripheral: RTC */ -/* Description: Real time counter 0 */ - -/* Register: RTC_TASKS_START */ -/* Description: Start RTC COUNTER */ - -/* Bit 0 : */ -#define RTC_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define RTC_TASKS_START_TASKS_START_Msk (0x1UL << RTC_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: RTC_TASKS_STOP */ -/* Description: Stop RTC COUNTER */ - -/* Bit 0 : */ -#define RTC_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define RTC_TASKS_STOP_TASKS_STOP_Msk (0x1UL << RTC_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: RTC_TASKS_CLEAR */ -/* Description: Clear RTC COUNTER */ - -/* Bit 0 : */ -#define RTC_TASKS_CLEAR_TASKS_CLEAR_Pos (0UL) /*!< Position of TASKS_CLEAR field. */ -#define RTC_TASKS_CLEAR_TASKS_CLEAR_Msk (0x1UL << RTC_TASKS_CLEAR_TASKS_CLEAR_Pos) /*!< Bit mask of TASKS_CLEAR field. */ - -/* Register: RTC_TASKS_TRIGOVRFLW */ -/* Description: Set COUNTER to 0xFFFFF0 */ - -/* Bit 0 : */ -#define RTC_TASKS_TRIGOVRFLW_TASKS_TRIGOVRFLW_Pos (0UL) /*!< Position of TASKS_TRIGOVRFLW field. */ -#define RTC_TASKS_TRIGOVRFLW_TASKS_TRIGOVRFLW_Msk (0x1UL << RTC_TASKS_TRIGOVRFLW_TASKS_TRIGOVRFLW_Pos) /*!< Bit mask of TASKS_TRIGOVRFLW field. */ - -/* Register: RTC_EVENTS_TICK */ -/* Description: Event on COUNTER increment */ - -/* Bit 0 : */ -#define RTC_EVENTS_TICK_EVENTS_TICK_Pos (0UL) /*!< Position of EVENTS_TICK field. */ -#define RTC_EVENTS_TICK_EVENTS_TICK_Msk (0x1UL << RTC_EVENTS_TICK_EVENTS_TICK_Pos) /*!< Bit mask of EVENTS_TICK field. */ - -/* Register: RTC_EVENTS_OVRFLW */ -/* Description: Event on COUNTER overflow */ - -/* Bit 0 : */ -#define RTC_EVENTS_OVRFLW_EVENTS_OVRFLW_Pos (0UL) /*!< Position of EVENTS_OVRFLW field. */ -#define RTC_EVENTS_OVRFLW_EVENTS_OVRFLW_Msk (0x1UL << RTC_EVENTS_OVRFLW_EVENTS_OVRFLW_Pos) /*!< Bit mask of EVENTS_OVRFLW field. */ - -/* Register: RTC_EVENTS_COMPARE */ -/* Description: Description collection[0]: Compare event on CC[0] match */ - -/* Bit 0 : */ -#define RTC_EVENTS_COMPARE_EVENTS_COMPARE_Pos (0UL) /*!< Position of EVENTS_COMPARE field. */ -#define RTC_EVENTS_COMPARE_EVENTS_COMPARE_Msk (0x1UL << RTC_EVENTS_COMPARE_EVENTS_COMPARE_Pos) /*!< Bit mask of EVENTS_COMPARE field. */ - -/* Register: RTC_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 19 : Write '1' to Enable interrupt for COMPARE[3] event */ -#define RTC_INTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_INTENSET_COMPARE3_Msk (0x1UL << RTC_INTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_INTENSET_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE3_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for COMPARE[2] event */ -#define RTC_INTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_INTENSET_COMPARE2_Msk (0x1UL << RTC_INTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_INTENSET_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE2_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for COMPARE[1] event */ -#define RTC_INTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_INTENSET_COMPARE1_Msk (0x1UL << RTC_INTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_INTENSET_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE1_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for COMPARE[0] event */ -#define RTC_INTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_INTENSET_COMPARE0_Msk (0x1UL << RTC_INTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_INTENSET_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for OVRFLW event */ -#define RTC_INTENSET_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_INTENSET_OVRFLW_Msk (0x1UL << RTC_INTENSET_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_INTENSET_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_OVRFLW_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for TICK event */ -#define RTC_INTENSET_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_INTENSET_TICK_Msk (0x1UL << RTC_INTENSET_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_INTENSET_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_TICK_Set (1UL) /*!< Enable */ - -/* Register: RTC_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 19 : Write '1' to Disable interrupt for COMPARE[3] event */ -#define RTC_INTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_INTENCLR_COMPARE3_Msk (0x1UL << RTC_INTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_INTENCLR_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE3_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for COMPARE[2] event */ -#define RTC_INTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_INTENCLR_COMPARE2_Msk (0x1UL << RTC_INTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_INTENCLR_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE2_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for COMPARE[1] event */ -#define RTC_INTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_INTENCLR_COMPARE1_Msk (0x1UL << RTC_INTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_INTENCLR_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE1_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for COMPARE[0] event */ -#define RTC_INTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_INTENCLR_COMPARE0_Msk (0x1UL << RTC_INTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_INTENCLR_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for OVRFLW event */ -#define RTC_INTENCLR_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_INTENCLR_OVRFLW_Msk (0x1UL << RTC_INTENCLR_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_INTENCLR_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_OVRFLW_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for TICK event */ -#define RTC_INTENCLR_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_INTENCLR_TICK_Msk (0x1UL << RTC_INTENCLR_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_INTENCLR_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_TICK_Clear (1UL) /*!< Disable */ - -/* Register: RTC_EVTEN */ -/* Description: Enable or disable event routing */ - -/* Bit 19 : Enable or disable event routing for COMPARE[3] event */ -#define RTC_EVTEN_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTEN_COMPARE3_Msk (0x1UL << RTC_EVTEN_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTEN_COMPARE3_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE3_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable event routing for COMPARE[2] event */ -#define RTC_EVTEN_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTEN_COMPARE2_Msk (0x1UL << RTC_EVTEN_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTEN_COMPARE2_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE2_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable event routing for COMPARE[1] event */ -#define RTC_EVTEN_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTEN_COMPARE1_Msk (0x1UL << RTC_EVTEN_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTEN_COMPARE1_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE1_Enabled (1UL) /*!< Enable */ - -/* Bit 16 : Enable or disable event routing for COMPARE[0] event */ -#define RTC_EVTEN_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTEN_COMPARE0_Msk (0x1UL << RTC_EVTEN_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTEN_COMPARE0_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE0_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable event routing for OVRFLW event */ -#define RTC_EVTEN_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTEN_OVRFLW_Msk (0x1UL << RTC_EVTEN_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTEN_OVRFLW_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_OVRFLW_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable event routing for TICK event */ -#define RTC_EVTEN_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTEN_TICK_Msk (0x1UL << RTC_EVTEN_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTEN_TICK_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_TICK_Enabled (1UL) /*!< Enable */ - -/* Register: RTC_EVTENSET */ -/* Description: Enable event routing */ - -/* Bit 19 : Write '1' to Enable event routing for COMPARE[3] event */ -#define RTC_EVTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTENSET_COMPARE3_Msk (0x1UL << RTC_EVTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTENSET_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE3_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable event routing for COMPARE[2] event */ -#define RTC_EVTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTENSET_COMPARE2_Msk (0x1UL << RTC_EVTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTENSET_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE2_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable event routing for COMPARE[1] event */ -#define RTC_EVTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTENSET_COMPARE1_Msk (0x1UL << RTC_EVTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTENSET_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE1_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable event routing for COMPARE[0] event */ -#define RTC_EVTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTENSET_COMPARE0_Msk (0x1UL << RTC_EVTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTENSET_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable event routing for OVRFLW event */ -#define RTC_EVTENSET_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTENSET_OVRFLW_Msk (0x1UL << RTC_EVTENSET_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTENSET_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_OVRFLW_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable event routing for TICK event */ -#define RTC_EVTENSET_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTENSET_TICK_Msk (0x1UL << RTC_EVTENSET_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTENSET_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_TICK_Set (1UL) /*!< Enable */ - -/* Register: RTC_EVTENCLR */ -/* Description: Disable event routing */ - -/* Bit 19 : Write '1' to Disable event routing for COMPARE[3] event */ -#define RTC_EVTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTENCLR_COMPARE3_Msk (0x1UL << RTC_EVTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTENCLR_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE3_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable event routing for COMPARE[2] event */ -#define RTC_EVTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTENCLR_COMPARE2_Msk (0x1UL << RTC_EVTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTENCLR_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE2_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable event routing for COMPARE[1] event */ -#define RTC_EVTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTENCLR_COMPARE1_Msk (0x1UL << RTC_EVTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTENCLR_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE1_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable event routing for COMPARE[0] event */ -#define RTC_EVTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTENCLR_COMPARE0_Msk (0x1UL << RTC_EVTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTENCLR_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable event routing for OVRFLW event */ -#define RTC_EVTENCLR_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTENCLR_OVRFLW_Msk (0x1UL << RTC_EVTENCLR_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTENCLR_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_OVRFLW_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable event routing for TICK event */ -#define RTC_EVTENCLR_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTENCLR_TICK_Msk (0x1UL << RTC_EVTENCLR_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTENCLR_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_TICK_Clear (1UL) /*!< Disable */ - -/* Register: RTC_COUNTER */ -/* Description: Current COUNTER value */ - -/* Bits 23..0 : Counter value */ -#define RTC_COUNTER_COUNTER_Pos (0UL) /*!< Position of COUNTER field. */ -#define RTC_COUNTER_COUNTER_Msk (0xFFFFFFUL << RTC_COUNTER_COUNTER_Pos) /*!< Bit mask of COUNTER field. */ - -/* Register: RTC_PRESCALER */ -/* Description: 12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)).Must be written when RTC is stopped */ - -/* Bits 11..0 : Prescaler value */ -#define RTC_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define RTC_PRESCALER_PRESCALER_Msk (0xFFFUL << RTC_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ - -/* Register: RTC_CC */ -/* Description: Description collection[0]: Compare register 0 */ - -/* Bits 23..0 : Compare value */ -#define RTC_CC_COMPARE_Pos (0UL) /*!< Position of COMPARE field. */ -#define RTC_CC_COMPARE_Msk (0xFFFFFFUL << RTC_CC_COMPARE_Pos) /*!< Bit mask of COMPARE field. */ - - -/* Peripheral: SAADC */ -/* Description: Analog to Digital Converter */ - -/* Register: SAADC_TASKS_START */ -/* Description: Start the ADC and prepare the result buffer in RAM */ - -/* Bit 0 : */ -#define SAADC_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define SAADC_TASKS_START_TASKS_START_Msk (0x1UL << SAADC_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: SAADC_TASKS_SAMPLE */ -/* Description: Take one ADC sample, if scan is enabled all channels are sampled */ - -/* Bit 0 : */ -#define SAADC_TASKS_SAMPLE_TASKS_SAMPLE_Pos (0UL) /*!< Position of TASKS_SAMPLE field. */ -#define SAADC_TASKS_SAMPLE_TASKS_SAMPLE_Msk (0x1UL << SAADC_TASKS_SAMPLE_TASKS_SAMPLE_Pos) /*!< Bit mask of TASKS_SAMPLE field. */ - -/* Register: SAADC_TASKS_STOP */ -/* Description: Stop the ADC and terminate any on-going conversion */ - -/* Bit 0 : */ -#define SAADC_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define SAADC_TASKS_STOP_TASKS_STOP_Msk (0x1UL << SAADC_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: SAADC_TASKS_CALIBRATEOFFSET */ -/* Description: Starts offset auto-calibration */ - -/* Bit 0 : */ -#define SAADC_TASKS_CALIBRATEOFFSET_TASKS_CALIBRATEOFFSET_Pos (0UL) /*!< Position of TASKS_CALIBRATEOFFSET field. */ -#define SAADC_TASKS_CALIBRATEOFFSET_TASKS_CALIBRATEOFFSET_Msk (0x1UL << SAADC_TASKS_CALIBRATEOFFSET_TASKS_CALIBRATEOFFSET_Pos) /*!< Bit mask of TASKS_CALIBRATEOFFSET field. */ - -/* Register: SAADC_EVENTS_STARTED */ -/* Description: The ADC has started */ - -/* Bit 0 : */ -#define SAADC_EVENTS_STARTED_EVENTS_STARTED_Pos (0UL) /*!< Position of EVENTS_STARTED field. */ -#define SAADC_EVENTS_STARTED_EVENTS_STARTED_Msk (0x1UL << SAADC_EVENTS_STARTED_EVENTS_STARTED_Pos) /*!< Bit mask of EVENTS_STARTED field. */ - -/* Register: SAADC_EVENTS_END */ -/* Description: The ADC has filled up the Result buffer */ - -/* Bit 0 : */ -#define SAADC_EVENTS_END_EVENTS_END_Pos (0UL) /*!< Position of EVENTS_END field. */ -#define SAADC_EVENTS_END_EVENTS_END_Msk (0x1UL << SAADC_EVENTS_END_EVENTS_END_Pos) /*!< Bit mask of EVENTS_END field. */ - -/* Register: SAADC_EVENTS_DONE */ -/* Description: A conversion task has been completed. Depending on the mode, multiple conversions might be needed for a result to be transferred to RAM. */ - -/* Bit 0 : */ -#define SAADC_EVENTS_DONE_EVENTS_DONE_Pos (0UL) /*!< Position of EVENTS_DONE field. */ -#define SAADC_EVENTS_DONE_EVENTS_DONE_Msk (0x1UL << SAADC_EVENTS_DONE_EVENTS_DONE_Pos) /*!< Bit mask of EVENTS_DONE field. */ - -/* Register: SAADC_EVENTS_RESULTDONE */ -/* Description: A result is ready to get transferred to RAM. */ - -/* Bit 0 : */ -#define SAADC_EVENTS_RESULTDONE_EVENTS_RESULTDONE_Pos (0UL) /*!< Position of EVENTS_RESULTDONE field. */ -#define SAADC_EVENTS_RESULTDONE_EVENTS_RESULTDONE_Msk (0x1UL << SAADC_EVENTS_RESULTDONE_EVENTS_RESULTDONE_Pos) /*!< Bit mask of EVENTS_RESULTDONE field. */ - -/* Register: SAADC_EVENTS_CALIBRATEDONE */ -/* Description: Calibration is complete */ - -/* Bit 0 : */ -#define SAADC_EVENTS_CALIBRATEDONE_EVENTS_CALIBRATEDONE_Pos (0UL) /*!< Position of EVENTS_CALIBRATEDONE field. */ -#define SAADC_EVENTS_CALIBRATEDONE_EVENTS_CALIBRATEDONE_Msk (0x1UL << SAADC_EVENTS_CALIBRATEDONE_EVENTS_CALIBRATEDONE_Pos) /*!< Bit mask of EVENTS_CALIBRATEDONE field. */ - -/* Register: SAADC_EVENTS_STOPPED */ -/* Description: The ADC has stopped */ - -/* Bit 0 : */ -#define SAADC_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define SAADC_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << SAADC_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: SAADC_EVENTS_CH_LIMITH */ -/* Description: Description cluster[0]: Last results is equal or above CH[0].LIMIT.HIGH */ - -/* Bit 0 : */ -#define SAADC_EVENTS_CH_LIMITH_LIMITH_Pos (0UL) /*!< Position of LIMITH field. */ -#define SAADC_EVENTS_CH_LIMITH_LIMITH_Msk (0x1UL << SAADC_EVENTS_CH_LIMITH_LIMITH_Pos) /*!< Bit mask of LIMITH field. */ - -/* Register: SAADC_EVENTS_CH_LIMITL */ -/* Description: Description cluster[0]: Last results is equal or below CH[0].LIMIT.LOW */ - -/* Bit 0 : */ -#define SAADC_EVENTS_CH_LIMITL_LIMITL_Pos (0UL) /*!< Position of LIMITL field. */ -#define SAADC_EVENTS_CH_LIMITL_LIMITL_Msk (0x1UL << SAADC_EVENTS_CH_LIMITL_LIMITL_Pos) /*!< Bit mask of LIMITL field. */ - -/* Register: SAADC_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 21 : Enable or disable interrupt for CH[7].LIMITL event */ -#define SAADC_INTEN_CH7LIMITL_Pos (21UL) /*!< Position of CH7LIMITL field. */ -#define SAADC_INTEN_CH7LIMITL_Msk (0x1UL << SAADC_INTEN_CH7LIMITL_Pos) /*!< Bit mask of CH7LIMITL field. */ -#define SAADC_INTEN_CH7LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH7LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for CH[7].LIMITH event */ -#define SAADC_INTEN_CH7LIMITH_Pos (20UL) /*!< Position of CH7LIMITH field. */ -#define SAADC_INTEN_CH7LIMITH_Msk (0x1UL << SAADC_INTEN_CH7LIMITH_Pos) /*!< Bit mask of CH7LIMITH field. */ -#define SAADC_INTEN_CH7LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH7LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for CH[6].LIMITL event */ -#define SAADC_INTEN_CH6LIMITL_Pos (19UL) /*!< Position of CH6LIMITL field. */ -#define SAADC_INTEN_CH6LIMITL_Msk (0x1UL << SAADC_INTEN_CH6LIMITL_Pos) /*!< Bit mask of CH6LIMITL field. */ -#define SAADC_INTEN_CH6LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH6LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable interrupt for CH[6].LIMITH event */ -#define SAADC_INTEN_CH6LIMITH_Pos (18UL) /*!< Position of CH6LIMITH field. */ -#define SAADC_INTEN_CH6LIMITH_Msk (0x1UL << SAADC_INTEN_CH6LIMITH_Pos) /*!< Bit mask of CH6LIMITH field. */ -#define SAADC_INTEN_CH6LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH6LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable interrupt for CH[5].LIMITL event */ -#define SAADC_INTEN_CH5LIMITL_Pos (17UL) /*!< Position of CH5LIMITL field. */ -#define SAADC_INTEN_CH5LIMITL_Msk (0x1UL << SAADC_INTEN_CH5LIMITL_Pos) /*!< Bit mask of CH5LIMITL field. */ -#define SAADC_INTEN_CH5LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH5LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 16 : Enable or disable interrupt for CH[5].LIMITH event */ -#define SAADC_INTEN_CH5LIMITH_Pos (16UL) /*!< Position of CH5LIMITH field. */ -#define SAADC_INTEN_CH5LIMITH_Msk (0x1UL << SAADC_INTEN_CH5LIMITH_Pos) /*!< Bit mask of CH5LIMITH field. */ -#define SAADC_INTEN_CH5LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH5LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 15 : Enable or disable interrupt for CH[4].LIMITL event */ -#define SAADC_INTEN_CH4LIMITL_Pos (15UL) /*!< Position of CH4LIMITL field. */ -#define SAADC_INTEN_CH4LIMITL_Msk (0x1UL << SAADC_INTEN_CH4LIMITL_Pos) /*!< Bit mask of CH4LIMITL field. */ -#define SAADC_INTEN_CH4LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH4LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 14 : Enable or disable interrupt for CH[4].LIMITH event */ -#define SAADC_INTEN_CH4LIMITH_Pos (14UL) /*!< Position of CH4LIMITH field. */ -#define SAADC_INTEN_CH4LIMITH_Msk (0x1UL << SAADC_INTEN_CH4LIMITH_Pos) /*!< Bit mask of CH4LIMITH field. */ -#define SAADC_INTEN_CH4LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH4LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 13 : Enable or disable interrupt for CH[3].LIMITL event */ -#define SAADC_INTEN_CH3LIMITL_Pos (13UL) /*!< Position of CH3LIMITL field. */ -#define SAADC_INTEN_CH3LIMITL_Msk (0x1UL << SAADC_INTEN_CH3LIMITL_Pos) /*!< Bit mask of CH3LIMITL field. */ -#define SAADC_INTEN_CH3LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH3LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 12 : Enable or disable interrupt for CH[3].LIMITH event */ -#define SAADC_INTEN_CH3LIMITH_Pos (12UL) /*!< Position of CH3LIMITH field. */ -#define SAADC_INTEN_CH3LIMITH_Msk (0x1UL << SAADC_INTEN_CH3LIMITH_Pos) /*!< Bit mask of CH3LIMITH field. */ -#define SAADC_INTEN_CH3LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH3LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 11 : Enable or disable interrupt for CH[2].LIMITL event */ -#define SAADC_INTEN_CH2LIMITL_Pos (11UL) /*!< Position of CH2LIMITL field. */ -#define SAADC_INTEN_CH2LIMITL_Msk (0x1UL << SAADC_INTEN_CH2LIMITL_Pos) /*!< Bit mask of CH2LIMITL field. */ -#define SAADC_INTEN_CH2LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH2LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 10 : Enable or disable interrupt for CH[2].LIMITH event */ -#define SAADC_INTEN_CH2LIMITH_Pos (10UL) /*!< Position of CH2LIMITH field. */ -#define SAADC_INTEN_CH2LIMITH_Msk (0x1UL << SAADC_INTEN_CH2LIMITH_Pos) /*!< Bit mask of CH2LIMITH field. */ -#define SAADC_INTEN_CH2LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH2LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for CH[1].LIMITL event */ -#define SAADC_INTEN_CH1LIMITL_Pos (9UL) /*!< Position of CH1LIMITL field. */ -#define SAADC_INTEN_CH1LIMITL_Msk (0x1UL << SAADC_INTEN_CH1LIMITL_Pos) /*!< Bit mask of CH1LIMITL field. */ -#define SAADC_INTEN_CH1LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH1LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for CH[1].LIMITH event */ -#define SAADC_INTEN_CH1LIMITH_Pos (8UL) /*!< Position of CH1LIMITH field. */ -#define SAADC_INTEN_CH1LIMITH_Msk (0x1UL << SAADC_INTEN_CH1LIMITH_Pos) /*!< Bit mask of CH1LIMITH field. */ -#define SAADC_INTEN_CH1LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH1LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for CH[0].LIMITL event */ -#define SAADC_INTEN_CH0LIMITL_Pos (7UL) /*!< Position of CH0LIMITL field. */ -#define SAADC_INTEN_CH0LIMITL_Msk (0x1UL << SAADC_INTEN_CH0LIMITL_Pos) /*!< Bit mask of CH0LIMITL field. */ -#define SAADC_INTEN_CH0LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH0LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for CH[0].LIMITH event */ -#define SAADC_INTEN_CH0LIMITH_Pos (6UL) /*!< Position of CH0LIMITH field. */ -#define SAADC_INTEN_CH0LIMITH_Msk (0x1UL << SAADC_INTEN_CH0LIMITH_Pos) /*!< Bit mask of CH0LIMITH field. */ -#define SAADC_INTEN_CH0LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH0LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for STOPPED event */ -#define SAADC_INTEN_STOPPED_Pos (5UL) /*!< Position of STOPPED field. */ -#define SAADC_INTEN_STOPPED_Msk (0x1UL << SAADC_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SAADC_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for CALIBRATEDONE event */ -#define SAADC_INTEN_CALIBRATEDONE_Pos (4UL) /*!< Position of CALIBRATEDONE field. */ -#define SAADC_INTEN_CALIBRATEDONE_Msk (0x1UL << SAADC_INTEN_CALIBRATEDONE_Pos) /*!< Bit mask of CALIBRATEDONE field. */ -#define SAADC_INTEN_CALIBRATEDONE_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CALIBRATEDONE_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for RESULTDONE event */ -#define SAADC_INTEN_RESULTDONE_Pos (3UL) /*!< Position of RESULTDONE field. */ -#define SAADC_INTEN_RESULTDONE_Msk (0x1UL << SAADC_INTEN_RESULTDONE_Pos) /*!< Bit mask of RESULTDONE field. */ -#define SAADC_INTEN_RESULTDONE_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_RESULTDONE_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for DONE event */ -#define SAADC_INTEN_DONE_Pos (2UL) /*!< Position of DONE field. */ -#define SAADC_INTEN_DONE_Msk (0x1UL << SAADC_INTEN_DONE_Pos) /*!< Bit mask of DONE field. */ -#define SAADC_INTEN_DONE_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_DONE_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for END event */ -#define SAADC_INTEN_END_Pos (1UL) /*!< Position of END field. */ -#define SAADC_INTEN_END_Msk (0x1UL << SAADC_INTEN_END_Pos) /*!< Bit mask of END field. */ -#define SAADC_INTEN_END_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_END_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for STARTED event */ -#define SAADC_INTEN_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define SAADC_INTEN_STARTED_Msk (0x1UL << SAADC_INTEN_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SAADC_INTEN_STARTED_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_STARTED_Enabled (1UL) /*!< Enable */ - -/* Register: SAADC_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 21 : Write '1' to Enable interrupt for CH[7].LIMITL event */ -#define SAADC_INTENSET_CH7LIMITL_Pos (21UL) /*!< Position of CH7LIMITL field. */ -#define SAADC_INTENSET_CH7LIMITL_Msk (0x1UL << SAADC_INTENSET_CH7LIMITL_Pos) /*!< Bit mask of CH7LIMITL field. */ -#define SAADC_INTENSET_CH7LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH7LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH7LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for CH[7].LIMITH event */ -#define SAADC_INTENSET_CH7LIMITH_Pos (20UL) /*!< Position of CH7LIMITH field. */ -#define SAADC_INTENSET_CH7LIMITH_Msk (0x1UL << SAADC_INTENSET_CH7LIMITH_Pos) /*!< Bit mask of CH7LIMITH field. */ -#define SAADC_INTENSET_CH7LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH7LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH7LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for CH[6].LIMITL event */ -#define SAADC_INTENSET_CH6LIMITL_Pos (19UL) /*!< Position of CH6LIMITL field. */ -#define SAADC_INTENSET_CH6LIMITL_Msk (0x1UL << SAADC_INTENSET_CH6LIMITL_Pos) /*!< Bit mask of CH6LIMITL field. */ -#define SAADC_INTENSET_CH6LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH6LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH6LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for CH[6].LIMITH event */ -#define SAADC_INTENSET_CH6LIMITH_Pos (18UL) /*!< Position of CH6LIMITH field. */ -#define SAADC_INTENSET_CH6LIMITH_Msk (0x1UL << SAADC_INTENSET_CH6LIMITH_Pos) /*!< Bit mask of CH6LIMITH field. */ -#define SAADC_INTENSET_CH6LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH6LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH6LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for CH[5].LIMITL event */ -#define SAADC_INTENSET_CH5LIMITL_Pos (17UL) /*!< Position of CH5LIMITL field. */ -#define SAADC_INTENSET_CH5LIMITL_Msk (0x1UL << SAADC_INTENSET_CH5LIMITL_Pos) /*!< Bit mask of CH5LIMITL field. */ -#define SAADC_INTENSET_CH5LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH5LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH5LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for CH[5].LIMITH event */ -#define SAADC_INTENSET_CH5LIMITH_Pos (16UL) /*!< Position of CH5LIMITH field. */ -#define SAADC_INTENSET_CH5LIMITH_Msk (0x1UL << SAADC_INTENSET_CH5LIMITH_Pos) /*!< Bit mask of CH5LIMITH field. */ -#define SAADC_INTENSET_CH5LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH5LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH5LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 15 : Write '1' to Enable interrupt for CH[4].LIMITL event */ -#define SAADC_INTENSET_CH4LIMITL_Pos (15UL) /*!< Position of CH4LIMITL field. */ -#define SAADC_INTENSET_CH4LIMITL_Msk (0x1UL << SAADC_INTENSET_CH4LIMITL_Pos) /*!< Bit mask of CH4LIMITL field. */ -#define SAADC_INTENSET_CH4LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH4LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH4LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for CH[4].LIMITH event */ -#define SAADC_INTENSET_CH4LIMITH_Pos (14UL) /*!< Position of CH4LIMITH field. */ -#define SAADC_INTENSET_CH4LIMITH_Msk (0x1UL << SAADC_INTENSET_CH4LIMITH_Pos) /*!< Bit mask of CH4LIMITH field. */ -#define SAADC_INTENSET_CH4LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH4LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH4LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 13 : Write '1' to Enable interrupt for CH[3].LIMITL event */ -#define SAADC_INTENSET_CH3LIMITL_Pos (13UL) /*!< Position of CH3LIMITL field. */ -#define SAADC_INTENSET_CH3LIMITL_Msk (0x1UL << SAADC_INTENSET_CH3LIMITL_Pos) /*!< Bit mask of CH3LIMITL field. */ -#define SAADC_INTENSET_CH3LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH3LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH3LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for CH[3].LIMITH event */ -#define SAADC_INTENSET_CH3LIMITH_Pos (12UL) /*!< Position of CH3LIMITH field. */ -#define SAADC_INTENSET_CH3LIMITH_Msk (0x1UL << SAADC_INTENSET_CH3LIMITH_Pos) /*!< Bit mask of CH3LIMITH field. */ -#define SAADC_INTENSET_CH3LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH3LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH3LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 11 : Write '1' to Enable interrupt for CH[2].LIMITL event */ -#define SAADC_INTENSET_CH2LIMITL_Pos (11UL) /*!< Position of CH2LIMITL field. */ -#define SAADC_INTENSET_CH2LIMITL_Msk (0x1UL << SAADC_INTENSET_CH2LIMITL_Pos) /*!< Bit mask of CH2LIMITL field. */ -#define SAADC_INTENSET_CH2LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH2LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH2LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for CH[2].LIMITH event */ -#define SAADC_INTENSET_CH2LIMITH_Pos (10UL) /*!< Position of CH2LIMITH field. */ -#define SAADC_INTENSET_CH2LIMITH_Msk (0x1UL << SAADC_INTENSET_CH2LIMITH_Pos) /*!< Bit mask of CH2LIMITH field. */ -#define SAADC_INTENSET_CH2LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH2LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH2LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for CH[1].LIMITL event */ -#define SAADC_INTENSET_CH1LIMITL_Pos (9UL) /*!< Position of CH1LIMITL field. */ -#define SAADC_INTENSET_CH1LIMITL_Msk (0x1UL << SAADC_INTENSET_CH1LIMITL_Pos) /*!< Bit mask of CH1LIMITL field. */ -#define SAADC_INTENSET_CH1LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH1LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH1LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for CH[1].LIMITH event */ -#define SAADC_INTENSET_CH1LIMITH_Pos (8UL) /*!< Position of CH1LIMITH field. */ -#define SAADC_INTENSET_CH1LIMITH_Msk (0x1UL << SAADC_INTENSET_CH1LIMITH_Pos) /*!< Bit mask of CH1LIMITH field. */ -#define SAADC_INTENSET_CH1LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH1LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH1LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for CH[0].LIMITL event */ -#define SAADC_INTENSET_CH0LIMITL_Pos (7UL) /*!< Position of CH0LIMITL field. */ -#define SAADC_INTENSET_CH0LIMITL_Msk (0x1UL << SAADC_INTENSET_CH0LIMITL_Pos) /*!< Bit mask of CH0LIMITL field. */ -#define SAADC_INTENSET_CH0LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH0LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH0LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for CH[0].LIMITH event */ -#define SAADC_INTENSET_CH0LIMITH_Pos (6UL) /*!< Position of CH0LIMITH field. */ -#define SAADC_INTENSET_CH0LIMITH_Msk (0x1UL << SAADC_INTENSET_CH0LIMITH_Pos) /*!< Bit mask of CH0LIMITH field. */ -#define SAADC_INTENSET_CH0LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH0LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH0LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for STOPPED event */ -#define SAADC_INTENSET_STOPPED_Pos (5UL) /*!< Position of STOPPED field. */ -#define SAADC_INTENSET_STOPPED_Msk (0x1UL << SAADC_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SAADC_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for CALIBRATEDONE event */ -#define SAADC_INTENSET_CALIBRATEDONE_Pos (4UL) /*!< Position of CALIBRATEDONE field. */ -#define SAADC_INTENSET_CALIBRATEDONE_Msk (0x1UL << SAADC_INTENSET_CALIBRATEDONE_Pos) /*!< Bit mask of CALIBRATEDONE field. */ -#define SAADC_INTENSET_CALIBRATEDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CALIBRATEDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CALIBRATEDONE_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for RESULTDONE event */ -#define SAADC_INTENSET_RESULTDONE_Pos (3UL) /*!< Position of RESULTDONE field. */ -#define SAADC_INTENSET_RESULTDONE_Msk (0x1UL << SAADC_INTENSET_RESULTDONE_Pos) /*!< Bit mask of RESULTDONE field. */ -#define SAADC_INTENSET_RESULTDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_RESULTDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_RESULTDONE_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for DONE event */ -#define SAADC_INTENSET_DONE_Pos (2UL) /*!< Position of DONE field. */ -#define SAADC_INTENSET_DONE_Msk (0x1UL << SAADC_INTENSET_DONE_Pos) /*!< Bit mask of DONE field. */ -#define SAADC_INTENSET_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_DONE_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for END event */ -#define SAADC_INTENSET_END_Pos (1UL) /*!< Position of END field. */ -#define SAADC_INTENSET_END_Msk (0x1UL << SAADC_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SAADC_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for STARTED event */ -#define SAADC_INTENSET_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define SAADC_INTENSET_STARTED_Msk (0x1UL << SAADC_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SAADC_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Register: SAADC_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 21 : Write '1' to Disable interrupt for CH[7].LIMITL event */ -#define SAADC_INTENCLR_CH7LIMITL_Pos (21UL) /*!< Position of CH7LIMITL field. */ -#define SAADC_INTENCLR_CH7LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH7LIMITL_Pos) /*!< Bit mask of CH7LIMITL field. */ -#define SAADC_INTENCLR_CH7LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH7LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH7LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for CH[7].LIMITH event */ -#define SAADC_INTENCLR_CH7LIMITH_Pos (20UL) /*!< Position of CH7LIMITH field. */ -#define SAADC_INTENCLR_CH7LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH7LIMITH_Pos) /*!< Bit mask of CH7LIMITH field. */ -#define SAADC_INTENCLR_CH7LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH7LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH7LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for CH[6].LIMITL event */ -#define SAADC_INTENCLR_CH6LIMITL_Pos (19UL) /*!< Position of CH6LIMITL field. */ -#define SAADC_INTENCLR_CH6LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH6LIMITL_Pos) /*!< Bit mask of CH6LIMITL field. */ -#define SAADC_INTENCLR_CH6LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH6LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH6LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for CH[6].LIMITH event */ -#define SAADC_INTENCLR_CH6LIMITH_Pos (18UL) /*!< Position of CH6LIMITH field. */ -#define SAADC_INTENCLR_CH6LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH6LIMITH_Pos) /*!< Bit mask of CH6LIMITH field. */ -#define SAADC_INTENCLR_CH6LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH6LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH6LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for CH[5].LIMITL event */ -#define SAADC_INTENCLR_CH5LIMITL_Pos (17UL) /*!< Position of CH5LIMITL field. */ -#define SAADC_INTENCLR_CH5LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH5LIMITL_Pos) /*!< Bit mask of CH5LIMITL field. */ -#define SAADC_INTENCLR_CH5LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH5LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH5LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for CH[5].LIMITH event */ -#define SAADC_INTENCLR_CH5LIMITH_Pos (16UL) /*!< Position of CH5LIMITH field. */ -#define SAADC_INTENCLR_CH5LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH5LIMITH_Pos) /*!< Bit mask of CH5LIMITH field. */ -#define SAADC_INTENCLR_CH5LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH5LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH5LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 15 : Write '1' to Disable interrupt for CH[4].LIMITL event */ -#define SAADC_INTENCLR_CH4LIMITL_Pos (15UL) /*!< Position of CH4LIMITL field. */ -#define SAADC_INTENCLR_CH4LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH4LIMITL_Pos) /*!< Bit mask of CH4LIMITL field. */ -#define SAADC_INTENCLR_CH4LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH4LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH4LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for CH[4].LIMITH event */ -#define SAADC_INTENCLR_CH4LIMITH_Pos (14UL) /*!< Position of CH4LIMITH field. */ -#define SAADC_INTENCLR_CH4LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH4LIMITH_Pos) /*!< Bit mask of CH4LIMITH field. */ -#define SAADC_INTENCLR_CH4LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH4LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH4LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 13 : Write '1' to Disable interrupt for CH[3].LIMITL event */ -#define SAADC_INTENCLR_CH3LIMITL_Pos (13UL) /*!< Position of CH3LIMITL field. */ -#define SAADC_INTENCLR_CH3LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH3LIMITL_Pos) /*!< Bit mask of CH3LIMITL field. */ -#define SAADC_INTENCLR_CH3LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH3LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH3LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for CH[3].LIMITH event */ -#define SAADC_INTENCLR_CH3LIMITH_Pos (12UL) /*!< Position of CH3LIMITH field. */ -#define SAADC_INTENCLR_CH3LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH3LIMITH_Pos) /*!< Bit mask of CH3LIMITH field. */ -#define SAADC_INTENCLR_CH3LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH3LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH3LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 11 : Write '1' to Disable interrupt for CH[2].LIMITL event */ -#define SAADC_INTENCLR_CH2LIMITL_Pos (11UL) /*!< Position of CH2LIMITL field. */ -#define SAADC_INTENCLR_CH2LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH2LIMITL_Pos) /*!< Bit mask of CH2LIMITL field. */ -#define SAADC_INTENCLR_CH2LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH2LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH2LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for CH[2].LIMITH event */ -#define SAADC_INTENCLR_CH2LIMITH_Pos (10UL) /*!< Position of CH2LIMITH field. */ -#define SAADC_INTENCLR_CH2LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH2LIMITH_Pos) /*!< Bit mask of CH2LIMITH field. */ -#define SAADC_INTENCLR_CH2LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH2LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH2LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for CH[1].LIMITL event */ -#define SAADC_INTENCLR_CH1LIMITL_Pos (9UL) /*!< Position of CH1LIMITL field. */ -#define SAADC_INTENCLR_CH1LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH1LIMITL_Pos) /*!< Bit mask of CH1LIMITL field. */ -#define SAADC_INTENCLR_CH1LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH1LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH1LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for CH[1].LIMITH event */ -#define SAADC_INTENCLR_CH1LIMITH_Pos (8UL) /*!< Position of CH1LIMITH field. */ -#define SAADC_INTENCLR_CH1LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH1LIMITH_Pos) /*!< Bit mask of CH1LIMITH field. */ -#define SAADC_INTENCLR_CH1LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH1LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH1LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for CH[0].LIMITL event */ -#define SAADC_INTENCLR_CH0LIMITL_Pos (7UL) /*!< Position of CH0LIMITL field. */ -#define SAADC_INTENCLR_CH0LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH0LIMITL_Pos) /*!< Bit mask of CH0LIMITL field. */ -#define SAADC_INTENCLR_CH0LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH0LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH0LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for CH[0].LIMITH event */ -#define SAADC_INTENCLR_CH0LIMITH_Pos (6UL) /*!< Position of CH0LIMITH field. */ -#define SAADC_INTENCLR_CH0LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH0LIMITH_Pos) /*!< Bit mask of CH0LIMITH field. */ -#define SAADC_INTENCLR_CH0LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH0LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH0LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for STOPPED event */ -#define SAADC_INTENCLR_STOPPED_Pos (5UL) /*!< Position of STOPPED field. */ -#define SAADC_INTENCLR_STOPPED_Msk (0x1UL << SAADC_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SAADC_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for CALIBRATEDONE event */ -#define SAADC_INTENCLR_CALIBRATEDONE_Pos (4UL) /*!< Position of CALIBRATEDONE field. */ -#define SAADC_INTENCLR_CALIBRATEDONE_Msk (0x1UL << SAADC_INTENCLR_CALIBRATEDONE_Pos) /*!< Bit mask of CALIBRATEDONE field. */ -#define SAADC_INTENCLR_CALIBRATEDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CALIBRATEDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CALIBRATEDONE_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for RESULTDONE event */ -#define SAADC_INTENCLR_RESULTDONE_Pos (3UL) /*!< Position of RESULTDONE field. */ -#define SAADC_INTENCLR_RESULTDONE_Msk (0x1UL << SAADC_INTENCLR_RESULTDONE_Pos) /*!< Bit mask of RESULTDONE field. */ -#define SAADC_INTENCLR_RESULTDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_RESULTDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_RESULTDONE_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for DONE event */ -#define SAADC_INTENCLR_DONE_Pos (2UL) /*!< Position of DONE field. */ -#define SAADC_INTENCLR_DONE_Msk (0x1UL << SAADC_INTENCLR_DONE_Pos) /*!< Bit mask of DONE field. */ -#define SAADC_INTENCLR_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_DONE_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for END event */ -#define SAADC_INTENCLR_END_Pos (1UL) /*!< Position of END field. */ -#define SAADC_INTENCLR_END_Msk (0x1UL << SAADC_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SAADC_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for STARTED event */ -#define SAADC_INTENCLR_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define SAADC_INTENCLR_STARTED_Msk (0x1UL << SAADC_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SAADC_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Register: SAADC_STATUS */ -/* Description: Status */ - -/* Bit 0 : Status */ -#define SAADC_STATUS_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define SAADC_STATUS_STATUS_Msk (0x1UL << SAADC_STATUS_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define SAADC_STATUS_STATUS_Ready (0UL) /*!< ADC is ready. No on-going conversion. */ -#define SAADC_STATUS_STATUS_Busy (1UL) /*!< ADC is busy. Conversion in progress. */ - -/* Register: SAADC_ENABLE */ -/* Description: Enable or disable ADC */ - -/* Bit 0 : Enable or disable ADC */ -#define SAADC_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SAADC_ENABLE_ENABLE_Msk (0x1UL << SAADC_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SAADC_ENABLE_ENABLE_Disabled (0UL) /*!< Disable ADC */ -#define SAADC_ENABLE_ENABLE_Enabled (1UL) /*!< Enable ADC */ - -/* Register: SAADC_CH_PSELP */ -/* Description: Description cluster[0]: Input positive pin selection for CH[0] */ - -/* Bits 4..0 : Analog positive input channel */ -#define SAADC_CH_PSELP_PSELP_Pos (0UL) /*!< Position of PSELP field. */ -#define SAADC_CH_PSELP_PSELP_Msk (0x1FUL << SAADC_CH_PSELP_PSELP_Pos) /*!< Bit mask of PSELP field. */ -#define SAADC_CH_PSELP_PSELP_NC (0UL) /*!< Not connected */ -#define SAADC_CH_PSELP_PSELP_AnalogInput0 (1UL) /*!< AIN0 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput1 (2UL) /*!< AIN1 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput2 (3UL) /*!< AIN2 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput3 (4UL) /*!< AIN3 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput4 (5UL) /*!< AIN4 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput5 (6UL) /*!< AIN5 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput6 (7UL) /*!< AIN6 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput7 (8UL) /*!< AIN7 */ -#define SAADC_CH_PSELP_PSELP_VDD (9UL) /*!< VDD */ - -/* Register: SAADC_CH_PSELN */ -/* Description: Description cluster[0]: Input negative pin selection for CH[0] */ - -/* Bits 4..0 : Analog negative input, enables differential channel */ -#define SAADC_CH_PSELN_PSELN_Pos (0UL) /*!< Position of PSELN field. */ -#define SAADC_CH_PSELN_PSELN_Msk (0x1FUL << SAADC_CH_PSELN_PSELN_Pos) /*!< Bit mask of PSELN field. */ -#define SAADC_CH_PSELN_PSELN_NC (0UL) /*!< Not connected */ -#define SAADC_CH_PSELN_PSELN_AnalogInput0 (1UL) /*!< AIN0 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput1 (2UL) /*!< AIN1 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput2 (3UL) /*!< AIN2 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput3 (4UL) /*!< AIN3 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput4 (5UL) /*!< AIN4 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput5 (6UL) /*!< AIN5 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput6 (7UL) /*!< AIN6 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput7 (8UL) /*!< AIN7 */ -#define SAADC_CH_PSELN_PSELN_VDD (9UL) /*!< VDD */ - -/* Register: SAADC_CH_CONFIG */ -/* Description: Description cluster[0]: Input configuration for CH[0] */ - -/* Bit 24 : Enable burst mode */ -#define SAADC_CH_CONFIG_BURST_Pos (24UL) /*!< Position of BURST field. */ -#define SAADC_CH_CONFIG_BURST_Msk (0x1UL << SAADC_CH_CONFIG_BURST_Pos) /*!< Bit mask of BURST field. */ -#define SAADC_CH_CONFIG_BURST_Disabled (0UL) /*!< Burst mode is disabled (normal operation) */ -#define SAADC_CH_CONFIG_BURST_Enabled (1UL) /*!< Burst mode is enabled. SAADC takes 2^OVERSAMPLE number of samples as fast as it can, and sends the average to Data RAM. */ - -/* Bit 20 : Enable differential mode */ -#define SAADC_CH_CONFIG_MODE_Pos (20UL) /*!< Position of MODE field. */ -#define SAADC_CH_CONFIG_MODE_Msk (0x1UL << SAADC_CH_CONFIG_MODE_Pos) /*!< Bit mask of MODE field. */ -#define SAADC_CH_CONFIG_MODE_SE (0UL) /*!< Single ended, PSELN will be ignored, negative input to ADC shorted to GND */ -#define SAADC_CH_CONFIG_MODE_Diff (1UL) /*!< Differential */ - -/* Bits 18..16 : Acquisition time, the time the ADC uses to sample the input voltage */ -#define SAADC_CH_CONFIG_TACQ_Pos (16UL) /*!< Position of TACQ field. */ -#define SAADC_CH_CONFIG_TACQ_Msk (0x7UL << SAADC_CH_CONFIG_TACQ_Pos) /*!< Bit mask of TACQ field. */ -#define SAADC_CH_CONFIG_TACQ_3us (0UL) /*!< 3 us */ -#define SAADC_CH_CONFIG_TACQ_5us (1UL) /*!< 5 us */ -#define SAADC_CH_CONFIG_TACQ_10us (2UL) /*!< 10 us */ -#define SAADC_CH_CONFIG_TACQ_15us (3UL) /*!< 15 us */ -#define SAADC_CH_CONFIG_TACQ_20us (4UL) /*!< 20 us */ -#define SAADC_CH_CONFIG_TACQ_40us (5UL) /*!< 40 us */ - -/* Bit 12 : Reference control */ -#define SAADC_CH_CONFIG_REFSEL_Pos (12UL) /*!< Position of REFSEL field. */ -#define SAADC_CH_CONFIG_REFSEL_Msk (0x1UL << SAADC_CH_CONFIG_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define SAADC_CH_CONFIG_REFSEL_Internal (0UL) /*!< Internal reference (0.6 V) */ -#define SAADC_CH_CONFIG_REFSEL_VDD1_4 (1UL) /*!< VDD/4 as reference */ - -/* Bits 10..8 : Gain control */ -#define SAADC_CH_CONFIG_GAIN_Pos (8UL) /*!< Position of GAIN field. */ -#define SAADC_CH_CONFIG_GAIN_Msk (0x7UL << SAADC_CH_CONFIG_GAIN_Pos) /*!< Bit mask of GAIN field. */ -#define SAADC_CH_CONFIG_GAIN_Gain1_6 (0UL) /*!< 1/6 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_5 (1UL) /*!< 1/5 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_4 (2UL) /*!< 1/4 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_3 (3UL) /*!< 1/3 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_2 (4UL) /*!< 1/2 */ -#define SAADC_CH_CONFIG_GAIN_Gain1 (5UL) /*!< 1 */ -#define SAADC_CH_CONFIG_GAIN_Gain2 (6UL) /*!< 2 */ -#define SAADC_CH_CONFIG_GAIN_Gain4 (7UL) /*!< 4 */ - -/* Bits 5..4 : Negative channel resistor control */ -#define SAADC_CH_CONFIG_RESN_Pos (4UL) /*!< Position of RESN field. */ -#define SAADC_CH_CONFIG_RESN_Msk (0x3UL << SAADC_CH_CONFIG_RESN_Pos) /*!< Bit mask of RESN field. */ -#define SAADC_CH_CONFIG_RESN_Bypass (0UL) /*!< Bypass resistor ladder */ -#define SAADC_CH_CONFIG_RESN_Pulldown (1UL) /*!< Pull-down to GND */ -#define SAADC_CH_CONFIG_RESN_Pullup (2UL) /*!< Pull-up to VDD */ -#define SAADC_CH_CONFIG_RESN_VDD1_2 (3UL) /*!< Set input at VDD/2 */ - -/* Bits 1..0 : Positive channel resistor control */ -#define SAADC_CH_CONFIG_RESP_Pos (0UL) /*!< Position of RESP field. */ -#define SAADC_CH_CONFIG_RESP_Msk (0x3UL << SAADC_CH_CONFIG_RESP_Pos) /*!< Bit mask of RESP field. */ -#define SAADC_CH_CONFIG_RESP_Bypass (0UL) /*!< Bypass resistor ladder */ -#define SAADC_CH_CONFIG_RESP_Pulldown (1UL) /*!< Pull-down to GND */ -#define SAADC_CH_CONFIG_RESP_Pullup (2UL) /*!< Pull-up to VDD */ -#define SAADC_CH_CONFIG_RESP_VDD1_2 (3UL) /*!< Set input at VDD/2 */ - -/* Register: SAADC_CH_LIMIT */ -/* Description: Description cluster[0]: High/low limits for event monitoring a channel */ - -/* Bits 31..16 : High level limit */ -#define SAADC_CH_LIMIT_HIGH_Pos (16UL) /*!< Position of HIGH field. */ -#define SAADC_CH_LIMIT_HIGH_Msk (0xFFFFUL << SAADC_CH_LIMIT_HIGH_Pos) /*!< Bit mask of HIGH field. */ - -/* Bits 15..0 : Low level limit */ -#define SAADC_CH_LIMIT_LOW_Pos (0UL) /*!< Position of LOW field. */ -#define SAADC_CH_LIMIT_LOW_Msk (0xFFFFUL << SAADC_CH_LIMIT_LOW_Pos) /*!< Bit mask of LOW field. */ - -/* Register: SAADC_RESOLUTION */ -/* Description: Resolution configuration */ - -/* Bits 2..0 : Set the resolution */ -#define SAADC_RESOLUTION_VAL_Pos (0UL) /*!< Position of VAL field. */ -#define SAADC_RESOLUTION_VAL_Msk (0x7UL << SAADC_RESOLUTION_VAL_Pos) /*!< Bit mask of VAL field. */ -#define SAADC_RESOLUTION_VAL_8bit (0UL) /*!< 8 bit */ -#define SAADC_RESOLUTION_VAL_10bit (1UL) /*!< 10 bit */ -#define SAADC_RESOLUTION_VAL_12bit (2UL) /*!< 12 bit */ -#define SAADC_RESOLUTION_VAL_14bit (3UL) /*!< 14 bit */ - -/* Register: SAADC_OVERSAMPLE */ -/* Description: Oversampling configuration. OVERSAMPLE should not be combined with SCAN. The RESOLUTION is applied before averaging, thus for high OVERSAMPLE a higher RESOLUTION should be used. */ - -/* Bits 3..0 : Oversample control */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Pos (0UL) /*!< Position of OVERSAMPLE field. */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Msk (0xFUL << SAADC_OVERSAMPLE_OVERSAMPLE_Pos) /*!< Bit mask of OVERSAMPLE field. */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Bypass (0UL) /*!< Bypass oversampling */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over2x (1UL) /*!< Oversample 2x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over4x (2UL) /*!< Oversample 4x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over8x (3UL) /*!< Oversample 8x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over16x (4UL) /*!< Oversample 16x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over32x (5UL) /*!< Oversample 32x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over64x (6UL) /*!< Oversample 64x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over128x (7UL) /*!< Oversample 128x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over256x (8UL) /*!< Oversample 256x */ - -/* Register: SAADC_SAMPLERATE */ -/* Description: Controls normal or continuous sample rate */ - -/* Bit 12 : Select mode for sample rate control */ -#define SAADC_SAMPLERATE_MODE_Pos (12UL) /*!< Position of MODE field. */ -#define SAADC_SAMPLERATE_MODE_Msk (0x1UL << SAADC_SAMPLERATE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define SAADC_SAMPLERATE_MODE_Task (0UL) /*!< Rate is controlled from SAMPLE task */ -#define SAADC_SAMPLERATE_MODE_Timers (1UL) /*!< Rate is controlled from local timer (use CC to control the rate) */ - -/* Bits 10..0 : Capture and compare value. Sample rate is 16 MHz/CC */ -#define SAADC_SAMPLERATE_CC_Pos (0UL) /*!< Position of CC field. */ -#define SAADC_SAMPLERATE_CC_Msk (0x7FFUL << SAADC_SAMPLERATE_CC_Pos) /*!< Bit mask of CC field. */ - -/* Register: SAADC_RESULT_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define SAADC_RESULT_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SAADC_RESULT_PTR_PTR_Msk (0xFFFFFFFFUL << SAADC_RESULT_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SAADC_RESULT_MAXCNT */ -/* Description: Maximum number of buffer words to transfer */ - -/* Bits 14..0 : Maximum number of buffer words to transfer */ -#define SAADC_RESULT_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SAADC_RESULT_MAXCNT_MAXCNT_Msk (0x7FFFUL << SAADC_RESULT_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SAADC_RESULT_AMOUNT */ -/* Description: Number of buffer words transferred since last START */ - -/* Bits 14..0 : Number of buffer words transferred since last START. This register can be read after an END or STOPPED event. */ -#define SAADC_RESULT_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SAADC_RESULT_AMOUNT_AMOUNT_Msk (0x7FFFUL << SAADC_RESULT_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - - -/* Peripheral: SPIM */ -/* Description: Serial Peripheral Interface Master with EasyDMA */ - -/* Register: SPIM_TASKS_START */ -/* Description: Start SPI transaction */ - -/* Bit 0 : */ -#define SPIM_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define SPIM_TASKS_START_TASKS_START_Msk (0x1UL << SPIM_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: SPIM_TASKS_STOP */ -/* Description: Stop SPI transaction */ - -/* Bit 0 : */ -#define SPIM_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define SPIM_TASKS_STOP_TASKS_STOP_Msk (0x1UL << SPIM_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: SPIM_TASKS_SUSPEND */ -/* Description: Suspend SPI transaction */ - -/* Bit 0 : */ -#define SPIM_TASKS_SUSPEND_TASKS_SUSPEND_Pos (0UL) /*!< Position of TASKS_SUSPEND field. */ -#define SPIM_TASKS_SUSPEND_TASKS_SUSPEND_Msk (0x1UL << SPIM_TASKS_SUSPEND_TASKS_SUSPEND_Pos) /*!< Bit mask of TASKS_SUSPEND field. */ - -/* Register: SPIM_TASKS_RESUME */ -/* Description: Resume SPI transaction */ - -/* Bit 0 : */ -#define SPIM_TASKS_RESUME_TASKS_RESUME_Pos (0UL) /*!< Position of TASKS_RESUME field. */ -#define SPIM_TASKS_RESUME_TASKS_RESUME_Msk (0x1UL << SPIM_TASKS_RESUME_TASKS_RESUME_Pos) /*!< Bit mask of TASKS_RESUME field. */ - -/* Register: SPIM_EVENTS_STOPPED */ -/* Description: SPI transaction has stopped */ - -/* Bit 0 : */ -#define SPIM_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define SPIM_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << SPIM_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: SPIM_EVENTS_ENDRX */ -/* Description: End of RXD buffer reached */ - -/* Bit 0 : */ -#define SPIM_EVENTS_ENDRX_EVENTS_ENDRX_Pos (0UL) /*!< Position of EVENTS_ENDRX field. */ -#define SPIM_EVENTS_ENDRX_EVENTS_ENDRX_Msk (0x1UL << SPIM_EVENTS_ENDRX_EVENTS_ENDRX_Pos) /*!< Bit mask of EVENTS_ENDRX field. */ - -/* Register: SPIM_EVENTS_END */ -/* Description: End of RXD buffer and TXD buffer reached */ - -/* Bit 0 : */ -#define SPIM_EVENTS_END_EVENTS_END_Pos (0UL) /*!< Position of EVENTS_END field. */ -#define SPIM_EVENTS_END_EVENTS_END_Msk (0x1UL << SPIM_EVENTS_END_EVENTS_END_Pos) /*!< Bit mask of EVENTS_END field. */ - -/* Register: SPIM_EVENTS_ENDTX */ -/* Description: End of TXD buffer reached */ - -/* Bit 0 : */ -#define SPIM_EVENTS_ENDTX_EVENTS_ENDTX_Pos (0UL) /*!< Position of EVENTS_ENDTX field. */ -#define SPIM_EVENTS_ENDTX_EVENTS_ENDTX_Msk (0x1UL << SPIM_EVENTS_ENDTX_EVENTS_ENDTX_Pos) /*!< Bit mask of EVENTS_ENDTX field. */ - -/* Register: SPIM_EVENTS_STARTED */ -/* Description: Transaction started */ - -/* Bit 0 : */ -#define SPIM_EVENTS_STARTED_EVENTS_STARTED_Pos (0UL) /*!< Position of EVENTS_STARTED field. */ -#define SPIM_EVENTS_STARTED_EVENTS_STARTED_Msk (0x1UL << SPIM_EVENTS_STARTED_EVENTS_STARTED_Pos) /*!< Bit mask of EVENTS_STARTED field. */ - -/* Register: SPIM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 17 : Shortcut between END event and START task */ -#define SPIM_SHORTS_END_START_Pos (17UL) /*!< Position of END_START field. */ -#define SPIM_SHORTS_END_START_Msk (0x1UL << SPIM_SHORTS_END_START_Pos) /*!< Bit mask of END_START field. */ -#define SPIM_SHORTS_END_START_Disabled (0UL) /*!< Disable shortcut */ -#define SPIM_SHORTS_END_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: SPIM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 19 : Write '1' to Enable interrupt for STARTED event */ -#define SPIM_INTENSET_STARTED_Pos (19UL) /*!< Position of STARTED field. */ -#define SPIM_INTENSET_STARTED_Msk (0x1UL << SPIM_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SPIM_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for ENDTX event */ -#define SPIM_INTENSET_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define SPIM_INTENSET_ENDTX_Msk (0x1UL << SPIM_INTENSET_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define SPIM_INTENSET_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_ENDTX_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for END event */ -#define SPIM_INTENSET_END_Pos (6UL) /*!< Position of END field. */ -#define SPIM_INTENSET_END_Msk (0x1UL << SPIM_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SPIM_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDRX event */ -#define SPIM_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIM_INTENSET_ENDRX_Msk (0x1UL << SPIM_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIM_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define SPIM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define SPIM_INTENSET_STOPPED_Msk (0x1UL << SPIM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SPIM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: SPIM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 19 : Write '1' to Disable interrupt for STARTED event */ -#define SPIM_INTENCLR_STARTED_Pos (19UL) /*!< Position of STARTED field. */ -#define SPIM_INTENCLR_STARTED_Msk (0x1UL << SPIM_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SPIM_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for ENDTX event */ -#define SPIM_INTENCLR_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define SPIM_INTENCLR_ENDTX_Msk (0x1UL << SPIM_INTENCLR_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define SPIM_INTENCLR_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_ENDTX_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for END event */ -#define SPIM_INTENCLR_END_Pos (6UL) /*!< Position of END field. */ -#define SPIM_INTENCLR_END_Msk (0x1UL << SPIM_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SPIM_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDRX event */ -#define SPIM_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIM_INTENCLR_ENDRX_Msk (0x1UL << SPIM_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIM_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define SPIM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define SPIM_INTENCLR_STOPPED_Msk (0x1UL << SPIM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SPIM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: SPIM_ENABLE */ -/* Description: Enable SPIM */ - -/* Bits 3..0 : Enable or disable SPIM */ -#define SPIM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPIM_ENABLE_ENABLE_Msk (0xFUL << SPIM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPIM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable SPIM */ -#define SPIM_ENABLE_ENABLE_Enabled (7UL) /*!< Enable SPIM */ - -/* Register: SPIM_PSEL_SCK */ -/* Description: Pin select for SCK */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_SCK_CONNECT_Msk (0x1UL << SPIM_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_SCK_PIN_Msk (0x1FUL << SPIM_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_PSEL_MOSI */ -/* Description: Pin select for MOSI signal */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_MOSI_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_MOSI_CONNECT_Msk (0x1UL << SPIM_PSEL_MOSI_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_MOSI_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_MOSI_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_MOSI_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_MOSI_PIN_Msk (0x1FUL << SPIM_PSEL_MOSI_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_PSEL_MISO */ -/* Description: Pin select for MISO signal */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_MISO_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_MISO_CONNECT_Msk (0x1UL << SPIM_PSEL_MISO_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_MISO_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_MISO_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_MISO_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_MISO_PIN_Msk (0x1FUL << SPIM_PSEL_MISO_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_FREQUENCY */ -/* Description: SPI frequency. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : SPI master data rate */ -#define SPIM_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define SPIM_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << SPIM_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define SPIM_FREQUENCY_FREQUENCY_K125 (0x02000000UL) /*!< 125 kbps */ -#define SPIM_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */ -#define SPIM_FREQUENCY_FREQUENCY_K500 (0x08000000UL) /*!< 500 kbps */ -#define SPIM_FREQUENCY_FREQUENCY_M1 (0x10000000UL) /*!< 1 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M2 (0x20000000UL) /*!< 2 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M4 (0x40000000UL) /*!< 4 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M8 (0x80000000UL) /*!< 8 Mbps */ - -/* Register: SPIM_RXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define SPIM_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIM_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIM_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIM_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 7..0 : Maximum number of bytes in receive buffer */ -#define SPIM_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIM_RXD_MAXCNT_MAXCNT_Msk (0xFFUL << SPIM_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIM_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 7..0 : Number of bytes transferred in the last transaction */ -#define SPIM_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIM_RXD_AMOUNT_AMOUNT_Msk (0xFFUL << SPIM_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIM_RXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 2..0 : List type */ -#define SPIM_RXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define SPIM_RXD_LIST_LIST_Msk (0x7UL << SPIM_RXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define SPIM_RXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define SPIM_RXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: SPIM_TXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define SPIM_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIM_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIM_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIM_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 7..0 : Maximum number of bytes in transmit buffer */ -#define SPIM_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIM_TXD_MAXCNT_MAXCNT_Msk (0xFFUL << SPIM_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIM_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 7..0 : Number of bytes transferred in the last transaction */ -#define SPIM_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIM_TXD_AMOUNT_AMOUNT_Msk (0xFFUL << SPIM_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIM_TXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 2..0 : List type */ -#define SPIM_TXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define SPIM_TXD_LIST_LIST_Msk (0x7UL << SPIM_TXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define SPIM_TXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define SPIM_TXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: SPIM_CONFIG */ -/* Description: Configuration register */ - -/* Bit 2 : Serial clock (SCK) polarity */ -#define SPIM_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPIM_CONFIG_CPOL_Msk (0x1UL << SPIM_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPIM_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high */ -#define SPIM_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low */ - -/* Bit 1 : Serial clock (SCK) phase */ -#define SPIM_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPIM_CONFIG_CPHA_Msk (0x1UL << SPIM_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPIM_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of clock, shift serial data on trailing edge */ -#define SPIM_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of clock, shift serial data on leading edge */ - -/* Bit 0 : Bit order */ -#define SPIM_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPIM_CONFIG_ORDER_Msk (0x1UL << SPIM_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPIM_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit shifted out first */ -#define SPIM_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit shifted out first */ - -/* Register: SPIM_ORC */ -/* Description: Over-read character. Character clocked out in case and over-read of the TXD buffer. */ - -/* Bits 7..0 : Over-read character. Character clocked out in case and over-read of the TXD buffer. */ -#define SPIM_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define SPIM_ORC_ORC_Msk (0xFFUL << SPIM_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - - -/* Peripheral: SPIS */ -/* Description: SPI Slave */ - -/* Register: SPIS_TASKS_ACQUIRE */ -/* Description: Acquire SPI semaphore */ - -/* Bit 0 : */ -#define SPIS_TASKS_ACQUIRE_TASKS_ACQUIRE_Pos (0UL) /*!< Position of TASKS_ACQUIRE field. */ -#define SPIS_TASKS_ACQUIRE_TASKS_ACQUIRE_Msk (0x1UL << SPIS_TASKS_ACQUIRE_TASKS_ACQUIRE_Pos) /*!< Bit mask of TASKS_ACQUIRE field. */ - -/* Register: SPIS_TASKS_RELEASE */ -/* Description: Release SPI semaphore, enabling the SPI slave to acquire it */ - -/* Bit 0 : */ -#define SPIS_TASKS_RELEASE_TASKS_RELEASE_Pos (0UL) /*!< Position of TASKS_RELEASE field. */ -#define SPIS_TASKS_RELEASE_TASKS_RELEASE_Msk (0x1UL << SPIS_TASKS_RELEASE_TASKS_RELEASE_Pos) /*!< Bit mask of TASKS_RELEASE field. */ - -/* Register: SPIS_EVENTS_END */ -/* Description: Granted transaction completed */ - -/* Bit 0 : */ -#define SPIS_EVENTS_END_EVENTS_END_Pos (0UL) /*!< Position of EVENTS_END field. */ -#define SPIS_EVENTS_END_EVENTS_END_Msk (0x1UL << SPIS_EVENTS_END_EVENTS_END_Pos) /*!< Bit mask of EVENTS_END field. */ - -/* Register: SPIS_EVENTS_ENDRX */ -/* Description: End of RXD buffer reached */ - -/* Bit 0 : */ -#define SPIS_EVENTS_ENDRX_EVENTS_ENDRX_Pos (0UL) /*!< Position of EVENTS_ENDRX field. */ -#define SPIS_EVENTS_ENDRX_EVENTS_ENDRX_Msk (0x1UL << SPIS_EVENTS_ENDRX_EVENTS_ENDRX_Pos) /*!< Bit mask of EVENTS_ENDRX field. */ - -/* Register: SPIS_EVENTS_ACQUIRED */ -/* Description: Semaphore acquired */ - -/* Bit 0 : */ -#define SPIS_EVENTS_ACQUIRED_EVENTS_ACQUIRED_Pos (0UL) /*!< Position of EVENTS_ACQUIRED field. */ -#define SPIS_EVENTS_ACQUIRED_EVENTS_ACQUIRED_Msk (0x1UL << SPIS_EVENTS_ACQUIRED_EVENTS_ACQUIRED_Pos) /*!< Bit mask of EVENTS_ACQUIRED field. */ - -/* Register: SPIS_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 2 : Shortcut between END event and ACQUIRE task */ -#define SPIS_SHORTS_END_ACQUIRE_Pos (2UL) /*!< Position of END_ACQUIRE field. */ -#define SPIS_SHORTS_END_ACQUIRE_Msk (0x1UL << SPIS_SHORTS_END_ACQUIRE_Pos) /*!< Bit mask of END_ACQUIRE field. */ -#define SPIS_SHORTS_END_ACQUIRE_Disabled (0UL) /*!< Disable shortcut */ -#define SPIS_SHORTS_END_ACQUIRE_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: SPIS_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 10 : Write '1' to Enable interrupt for ACQUIRED event */ -#define SPIS_INTENSET_ACQUIRED_Pos (10UL) /*!< Position of ACQUIRED field. */ -#define SPIS_INTENSET_ACQUIRED_Msk (0x1UL << SPIS_INTENSET_ACQUIRED_Pos) /*!< Bit mask of ACQUIRED field. */ -#define SPIS_INTENSET_ACQUIRED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENSET_ACQUIRED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENSET_ACQUIRED_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDRX event */ -#define SPIS_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIS_INTENSET_ENDRX_Msk (0x1UL << SPIS_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIS_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for END event */ -#define SPIS_INTENSET_END_Pos (1UL) /*!< Position of END field. */ -#define SPIS_INTENSET_END_Msk (0x1UL << SPIS_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SPIS_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Register: SPIS_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 10 : Write '1' to Disable interrupt for ACQUIRED event */ -#define SPIS_INTENCLR_ACQUIRED_Pos (10UL) /*!< Position of ACQUIRED field. */ -#define SPIS_INTENCLR_ACQUIRED_Msk (0x1UL << SPIS_INTENCLR_ACQUIRED_Pos) /*!< Bit mask of ACQUIRED field. */ -#define SPIS_INTENCLR_ACQUIRED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENCLR_ACQUIRED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENCLR_ACQUIRED_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDRX event */ -#define SPIS_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIS_INTENCLR_ENDRX_Msk (0x1UL << SPIS_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIS_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for END event */ -#define SPIS_INTENCLR_END_Pos (1UL) /*!< Position of END field. */ -#define SPIS_INTENCLR_END_Msk (0x1UL << SPIS_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SPIS_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Register: SPIS_SEMSTAT */ -/* Description: Semaphore status register */ - -/* Bits 1..0 : Semaphore status */ -#define SPIS_SEMSTAT_SEMSTAT_Pos (0UL) /*!< Position of SEMSTAT field. */ -#define SPIS_SEMSTAT_SEMSTAT_Msk (0x3UL << SPIS_SEMSTAT_SEMSTAT_Pos) /*!< Bit mask of SEMSTAT field. */ -#define SPIS_SEMSTAT_SEMSTAT_Free (0UL) /*!< Semaphore is free */ -#define SPIS_SEMSTAT_SEMSTAT_CPU (1UL) /*!< Semaphore is assigned to CPU */ -#define SPIS_SEMSTAT_SEMSTAT_SPIS (2UL) /*!< Semaphore is assigned to SPI slave */ -#define SPIS_SEMSTAT_SEMSTAT_CPUPending (3UL) /*!< Semaphore is assigned to SPI but a handover to the CPU is pending */ - -/* Register: SPIS_STATUS */ -/* Description: Status from last transaction */ - -/* Bit 1 : RX buffer overflow detected, and prevented */ -#define SPIS_STATUS_OVERFLOW_Pos (1UL) /*!< Position of OVERFLOW field. */ -#define SPIS_STATUS_OVERFLOW_Msk (0x1UL << SPIS_STATUS_OVERFLOW_Pos) /*!< Bit mask of OVERFLOW field. */ -#define SPIS_STATUS_OVERFLOW_NotPresent (0UL) /*!< Read: error not present */ -#define SPIS_STATUS_OVERFLOW_Present (1UL) /*!< Read: error present */ -#define SPIS_STATUS_OVERFLOW_Clear (1UL) /*!< Write: clear error on writing '1' */ - -/* Bit 0 : TX buffer over-read detected, and prevented */ -#define SPIS_STATUS_OVERREAD_Pos (0UL) /*!< Position of OVERREAD field. */ -#define SPIS_STATUS_OVERREAD_Msk (0x1UL << SPIS_STATUS_OVERREAD_Pos) /*!< Bit mask of OVERREAD field. */ -#define SPIS_STATUS_OVERREAD_NotPresent (0UL) /*!< Read: error not present */ -#define SPIS_STATUS_OVERREAD_Present (1UL) /*!< Read: error present */ -#define SPIS_STATUS_OVERREAD_Clear (1UL) /*!< Write: clear error on writing '1' */ - -/* Register: SPIS_ENABLE */ -/* Description: Enable SPI slave */ - -/* Bits 3..0 : Enable or disable SPI slave */ -#define SPIS_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPIS_ENABLE_ENABLE_Msk (0xFUL << SPIS_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPIS_ENABLE_ENABLE_Disabled (0UL) /*!< Disable SPI slave */ -#define SPIS_ENABLE_ENABLE_Enabled (2UL) /*!< Enable SPI slave */ - -/* Register: SPIS_PSEL_SCK */ -/* Description: Pin select for SCK */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_SCK_CONNECT_Msk (0x1UL << SPIS_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_SCK_PIN_Msk (0x1FUL << SPIS_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_PSEL_MISO */ -/* Description: Pin select for MISO signal */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_MISO_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_MISO_CONNECT_Msk (0x1UL << SPIS_PSEL_MISO_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_MISO_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_MISO_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_MISO_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_MISO_PIN_Msk (0x1FUL << SPIS_PSEL_MISO_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_PSEL_MOSI */ -/* Description: Pin select for MOSI signal */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_MOSI_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_MOSI_CONNECT_Msk (0x1UL << SPIS_PSEL_MOSI_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_MOSI_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_MOSI_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_MOSI_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_MOSI_PIN_Msk (0x1FUL << SPIS_PSEL_MOSI_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_PSEL_CSN */ -/* Description: Pin select for CSN signal */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_CSN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_CSN_CONNECT_Msk (0x1UL << SPIS_PSEL_CSN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_CSN_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_CSN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_CSN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_CSN_PIN_Msk (0x1FUL << SPIS_PSEL_CSN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_RXD_PTR */ -/* Description: RXD data pointer */ - -/* Bits 31..0 : RXD data pointer */ -#define SPIS_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIS_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIS_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIS_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 9..0 : Maximum number of bytes in receive buffer */ -#define SPIS_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIS_RXD_MAXCNT_MAXCNT_Msk (0x3FFUL << SPIS_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIS_RXD_AMOUNT */ -/* Description: Number of bytes received in last granted transaction */ - -/* Bits 9..0 : Number of bytes received in the last granted transaction */ -#define SPIS_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIS_RXD_AMOUNT_AMOUNT_Msk (0x3FFUL << SPIS_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIS_TXD_PTR */ -/* Description: TXD data pointer */ - -/* Bits 31..0 : TXD data pointer */ -#define SPIS_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIS_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIS_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIS_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 9..0 : Maximum number of bytes in transmit buffer */ -#define SPIS_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIS_TXD_MAXCNT_MAXCNT_Msk (0x3FFUL << SPIS_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIS_TXD_AMOUNT */ -/* Description: Number of bytes transmitted in last granted transaction */ - -/* Bits 9..0 : Number of bytes transmitted in last granted transaction */ -#define SPIS_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIS_TXD_AMOUNT_AMOUNT_Msk (0x3FFUL << SPIS_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIS_CONFIG */ -/* Description: Configuration register */ - -/* Bit 2 : Serial clock (SCK) polarity */ -#define SPIS_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPIS_CONFIG_CPOL_Msk (0x1UL << SPIS_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPIS_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high */ -#define SPIS_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low */ - -/* Bit 1 : Serial clock (SCK) phase */ -#define SPIS_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPIS_CONFIG_CPHA_Msk (0x1UL << SPIS_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPIS_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of clock, shift serial data on trailing edge */ -#define SPIS_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of clock, shift serial data on leading edge */ - -/* Bit 0 : Bit order */ -#define SPIS_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPIS_CONFIG_ORDER_Msk (0x1UL << SPIS_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPIS_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit shifted out first */ -#define SPIS_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit shifted out first */ - -/* Register: SPIS_DEF */ -/* Description: Default character. Character clocked out in case of an ignored transaction. */ - -/* Bits 7..0 : Default character. Character clocked out in case of an ignored transaction. */ -#define SPIS_DEF_DEF_Pos (0UL) /*!< Position of DEF field. */ -#define SPIS_DEF_DEF_Msk (0xFFUL << SPIS_DEF_DEF_Pos) /*!< Bit mask of DEF field. */ - -/* Register: SPIS_ORC */ -/* Description: Over-read character */ - -/* Bits 7..0 : Over-read character. Character clocked out after an over-read of the transmit buffer. */ -#define SPIS_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define SPIS_ORC_ORC_Msk (0xFFUL << SPIS_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - - -/* Peripheral: TEMP */ -/* Description: Temperature Sensor */ - -/* Register: TEMP_TASKS_START */ -/* Description: Start temperature measurement */ - -/* Bit 0 : */ -#define TEMP_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define TEMP_TASKS_START_TASKS_START_Msk (0x1UL << TEMP_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: TEMP_TASKS_STOP */ -/* Description: Stop temperature measurement */ - -/* Bit 0 : */ -#define TEMP_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define TEMP_TASKS_STOP_TASKS_STOP_Msk (0x1UL << TEMP_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: TEMP_EVENTS_DATARDY */ -/* Description: Temperature measurement complete, data ready */ - -/* Bit 0 : */ -#define TEMP_EVENTS_DATARDY_EVENTS_DATARDY_Pos (0UL) /*!< Position of EVENTS_DATARDY field. */ -#define TEMP_EVENTS_DATARDY_EVENTS_DATARDY_Msk (0x1UL << TEMP_EVENTS_DATARDY_EVENTS_DATARDY_Pos) /*!< Bit mask of EVENTS_DATARDY field. */ - -/* Register: TEMP_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for DATARDY event */ -#define TEMP_INTENSET_DATARDY_Pos (0UL) /*!< Position of DATARDY field. */ -#define TEMP_INTENSET_DATARDY_Msk (0x1UL << TEMP_INTENSET_DATARDY_Pos) /*!< Bit mask of DATARDY field. */ -#define TEMP_INTENSET_DATARDY_Disabled (0UL) /*!< Read: Disabled */ -#define TEMP_INTENSET_DATARDY_Enabled (1UL) /*!< Read: Enabled */ -#define TEMP_INTENSET_DATARDY_Set (1UL) /*!< Enable */ - -/* Register: TEMP_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for DATARDY event */ -#define TEMP_INTENCLR_DATARDY_Pos (0UL) /*!< Position of DATARDY field. */ -#define TEMP_INTENCLR_DATARDY_Msk (0x1UL << TEMP_INTENCLR_DATARDY_Pos) /*!< Bit mask of DATARDY field. */ -#define TEMP_INTENCLR_DATARDY_Disabled (0UL) /*!< Read: Disabled */ -#define TEMP_INTENCLR_DATARDY_Enabled (1UL) /*!< Read: Enabled */ -#define TEMP_INTENCLR_DATARDY_Clear (1UL) /*!< Disable */ - -/* Register: TEMP_TEMP */ -/* Description: Temperature in degC (0.25deg steps) */ - -/* Bits 31..0 : Temperature in degC (0.25deg steps) */ -#define TEMP_TEMP_TEMP_Pos (0UL) /*!< Position of TEMP field. */ -#define TEMP_TEMP_TEMP_Msk (0xFFFFFFFFUL << TEMP_TEMP_TEMP_Pos) /*!< Bit mask of TEMP field. */ - -/* Register: TEMP_A0 */ -/* Description: Slope of 1st piece wise linear function */ - -/* Bits 11..0 : Slope of 1st piece wise linear function */ -#define TEMP_A0_A0_Pos (0UL) /*!< Position of A0 field. */ -#define TEMP_A0_A0_Msk (0xFFFUL << TEMP_A0_A0_Pos) /*!< Bit mask of A0 field. */ - -/* Register: TEMP_A1 */ -/* Description: Slope of 2nd piece wise linear function */ - -/* Bits 11..0 : Slope of 2nd piece wise linear function */ -#define TEMP_A1_A1_Pos (0UL) /*!< Position of A1 field. */ -#define TEMP_A1_A1_Msk (0xFFFUL << TEMP_A1_A1_Pos) /*!< Bit mask of A1 field. */ - -/* Register: TEMP_A2 */ -/* Description: Slope of 3rd piece wise linear function */ - -/* Bits 11..0 : Slope of 3rd piece wise linear function */ -#define TEMP_A2_A2_Pos (0UL) /*!< Position of A2 field. */ -#define TEMP_A2_A2_Msk (0xFFFUL << TEMP_A2_A2_Pos) /*!< Bit mask of A2 field. */ - -/* Register: TEMP_A3 */ -/* Description: Slope of 4th piece wise linear function */ - -/* Bits 11..0 : Slope of 4th piece wise linear function */ -#define TEMP_A3_A3_Pos (0UL) /*!< Position of A3 field. */ -#define TEMP_A3_A3_Msk (0xFFFUL << TEMP_A3_A3_Pos) /*!< Bit mask of A3 field. */ - -/* Register: TEMP_A4 */ -/* Description: Slope of 5th piece wise linear function */ - -/* Bits 11..0 : Slope of 5th piece wise linear function */ -#define TEMP_A4_A4_Pos (0UL) /*!< Position of A4 field. */ -#define TEMP_A4_A4_Msk (0xFFFUL << TEMP_A4_A4_Pos) /*!< Bit mask of A4 field. */ - -/* Register: TEMP_A5 */ -/* Description: Slope of 6th piece wise linear function */ - -/* Bits 11..0 : Slope of 6th piece wise linear function */ -#define TEMP_A5_A5_Pos (0UL) /*!< Position of A5 field. */ -#define TEMP_A5_A5_Msk (0xFFFUL << TEMP_A5_A5_Pos) /*!< Bit mask of A5 field. */ - -/* Register: TEMP_B0 */ -/* Description: y-intercept of 1st piece wise linear function */ - -/* Bits 13..0 : y-intercept of 1st piece wise linear function */ -#define TEMP_B0_B0_Pos (0UL) /*!< Position of B0 field. */ -#define TEMP_B0_B0_Msk (0x3FFFUL << TEMP_B0_B0_Pos) /*!< Bit mask of B0 field. */ - -/* Register: TEMP_B1 */ -/* Description: y-intercept of 2nd piece wise linear function */ - -/* Bits 13..0 : y-intercept of 2nd piece wise linear function */ -#define TEMP_B1_B1_Pos (0UL) /*!< Position of B1 field. */ -#define TEMP_B1_B1_Msk (0x3FFFUL << TEMP_B1_B1_Pos) /*!< Bit mask of B1 field. */ - -/* Register: TEMP_B2 */ -/* Description: y-intercept of 3rd piece wise linear function */ - -/* Bits 13..0 : y-intercept of 3rd piece wise linear function */ -#define TEMP_B2_B2_Pos (0UL) /*!< Position of B2 field. */ -#define TEMP_B2_B2_Msk (0x3FFFUL << TEMP_B2_B2_Pos) /*!< Bit mask of B2 field. */ - -/* Register: TEMP_B3 */ -/* Description: y-intercept of 4th piece wise linear function */ - -/* Bits 13..0 : y-intercept of 4th piece wise linear function */ -#define TEMP_B3_B3_Pos (0UL) /*!< Position of B3 field. */ -#define TEMP_B3_B3_Msk (0x3FFFUL << TEMP_B3_B3_Pos) /*!< Bit mask of B3 field. */ - -/* Register: TEMP_B4 */ -/* Description: y-intercept of 5th piece wise linear function */ - -/* Bits 13..0 : y-intercept of 5th piece wise linear function */ -#define TEMP_B4_B4_Pos (0UL) /*!< Position of B4 field. */ -#define TEMP_B4_B4_Msk (0x3FFFUL << TEMP_B4_B4_Pos) /*!< Bit mask of B4 field. */ - -/* Register: TEMP_B5 */ -/* Description: y-intercept of 6th piece wise linear function */ - -/* Bits 13..0 : y-intercept of 6th piece wise linear function */ -#define TEMP_B5_B5_Pos (0UL) /*!< Position of B5 field. */ -#define TEMP_B5_B5_Msk (0x3FFFUL << TEMP_B5_B5_Pos) /*!< Bit mask of B5 field. */ - -/* Register: TEMP_T0 */ -/* Description: End point of 1st piece wise linear function */ - -/* Bits 7..0 : End point of 1st piece wise linear function */ -#define TEMP_T0_T0_Pos (0UL) /*!< Position of T0 field. */ -#define TEMP_T0_T0_Msk (0xFFUL << TEMP_T0_T0_Pos) /*!< Bit mask of T0 field. */ - -/* Register: TEMP_T1 */ -/* Description: End point of 2nd piece wise linear function */ - -/* Bits 7..0 : End point of 2nd piece wise linear function */ -#define TEMP_T1_T1_Pos (0UL) /*!< Position of T1 field. */ -#define TEMP_T1_T1_Msk (0xFFUL << TEMP_T1_T1_Pos) /*!< Bit mask of T1 field. */ - -/* Register: TEMP_T2 */ -/* Description: End point of 3rd piece wise linear function */ - -/* Bits 7..0 : End point of 3rd piece wise linear function */ -#define TEMP_T2_T2_Pos (0UL) /*!< Position of T2 field. */ -#define TEMP_T2_T2_Msk (0xFFUL << TEMP_T2_T2_Pos) /*!< Bit mask of T2 field. */ - -/* Register: TEMP_T3 */ -/* Description: End point of 4th piece wise linear function */ - -/* Bits 7..0 : End point of 4th piece wise linear function */ -#define TEMP_T3_T3_Pos (0UL) /*!< Position of T3 field. */ -#define TEMP_T3_T3_Msk (0xFFUL << TEMP_T3_T3_Pos) /*!< Bit mask of T3 field. */ - -/* Register: TEMP_T4 */ -/* Description: End point of 5th piece wise linear function */ - -/* Bits 7..0 : End point of 5th piece wise linear function */ -#define TEMP_T4_T4_Pos (0UL) /*!< Position of T4 field. */ -#define TEMP_T4_T4_Msk (0xFFUL << TEMP_T4_T4_Pos) /*!< Bit mask of T4 field. */ - - -/* Peripheral: TIMER */ -/* Description: Timer/Counter 0 */ - -/* Register: TIMER_TASKS_START */ -/* Description: Start Timer */ - -/* Bit 0 : */ -#define TIMER_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define TIMER_TASKS_START_TASKS_START_Msk (0x1UL << TIMER_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: TIMER_TASKS_STOP */ -/* Description: Stop Timer */ - -/* Bit 0 : */ -#define TIMER_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define TIMER_TASKS_STOP_TASKS_STOP_Msk (0x1UL << TIMER_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: TIMER_TASKS_COUNT */ -/* Description: Increment Timer (Counter mode only) */ - -/* Bit 0 : */ -#define TIMER_TASKS_COUNT_TASKS_COUNT_Pos (0UL) /*!< Position of TASKS_COUNT field. */ -#define TIMER_TASKS_COUNT_TASKS_COUNT_Msk (0x1UL << TIMER_TASKS_COUNT_TASKS_COUNT_Pos) /*!< Bit mask of TASKS_COUNT field. */ - -/* Register: TIMER_TASKS_CLEAR */ -/* Description: Clear time */ - -/* Bit 0 : */ -#define TIMER_TASKS_CLEAR_TASKS_CLEAR_Pos (0UL) /*!< Position of TASKS_CLEAR field. */ -#define TIMER_TASKS_CLEAR_TASKS_CLEAR_Msk (0x1UL << TIMER_TASKS_CLEAR_TASKS_CLEAR_Pos) /*!< Bit mask of TASKS_CLEAR field. */ - -/* Register: TIMER_TASKS_SHUTDOWN */ -/* Description: Deprecated register - Shut down timer */ - -/* Bit 0 : */ -#define TIMER_TASKS_SHUTDOWN_TASKS_SHUTDOWN_Pos (0UL) /*!< Position of TASKS_SHUTDOWN field. */ -#define TIMER_TASKS_SHUTDOWN_TASKS_SHUTDOWN_Msk (0x1UL << TIMER_TASKS_SHUTDOWN_TASKS_SHUTDOWN_Pos) /*!< Bit mask of TASKS_SHUTDOWN field. */ - -/* Register: TIMER_TASKS_CAPTURE */ -/* Description: Description collection[0]: Capture Timer value to CC[0] register */ - -/* Bit 0 : */ -#define TIMER_TASKS_CAPTURE_TASKS_CAPTURE_Pos (0UL) /*!< Position of TASKS_CAPTURE field. */ -#define TIMER_TASKS_CAPTURE_TASKS_CAPTURE_Msk (0x1UL << TIMER_TASKS_CAPTURE_TASKS_CAPTURE_Pos) /*!< Bit mask of TASKS_CAPTURE field. */ - -/* Register: TIMER_EVENTS_COMPARE */ -/* Description: Description collection[0]: Compare event on CC[0] match */ - -/* Bit 0 : */ -#define TIMER_EVENTS_COMPARE_EVENTS_COMPARE_Pos (0UL) /*!< Position of EVENTS_COMPARE field. */ -#define TIMER_EVENTS_COMPARE_EVENTS_COMPARE_Msk (0x1UL << TIMER_EVENTS_COMPARE_EVENTS_COMPARE_Pos) /*!< Bit mask of EVENTS_COMPARE field. */ - -/* Register: TIMER_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 13 : Shortcut between COMPARE[5] event and STOP task */ -#define TIMER_SHORTS_COMPARE5_STOP_Pos (13UL) /*!< Position of COMPARE5_STOP field. */ -#define TIMER_SHORTS_COMPARE5_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE5_STOP_Pos) /*!< Bit mask of COMPARE5_STOP field. */ -#define TIMER_SHORTS_COMPARE5_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE5_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 12 : Shortcut between COMPARE[4] event and STOP task */ -#define TIMER_SHORTS_COMPARE4_STOP_Pos (12UL) /*!< Position of COMPARE4_STOP field. */ -#define TIMER_SHORTS_COMPARE4_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE4_STOP_Pos) /*!< Bit mask of COMPARE4_STOP field. */ -#define TIMER_SHORTS_COMPARE4_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE4_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 11 : Shortcut between COMPARE[3] event and STOP task */ -#define TIMER_SHORTS_COMPARE3_STOP_Pos (11UL) /*!< Position of COMPARE3_STOP field. */ -#define TIMER_SHORTS_COMPARE3_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE3_STOP_Pos) /*!< Bit mask of COMPARE3_STOP field. */ -#define TIMER_SHORTS_COMPARE3_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE3_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 10 : Shortcut between COMPARE[2] event and STOP task */ -#define TIMER_SHORTS_COMPARE2_STOP_Pos (10UL) /*!< Position of COMPARE2_STOP field. */ -#define TIMER_SHORTS_COMPARE2_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE2_STOP_Pos) /*!< Bit mask of COMPARE2_STOP field. */ -#define TIMER_SHORTS_COMPARE2_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE2_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 9 : Shortcut between COMPARE[1] event and STOP task */ -#define TIMER_SHORTS_COMPARE1_STOP_Pos (9UL) /*!< Position of COMPARE1_STOP field. */ -#define TIMER_SHORTS_COMPARE1_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE1_STOP_Pos) /*!< Bit mask of COMPARE1_STOP field. */ -#define TIMER_SHORTS_COMPARE1_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE1_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 8 : Shortcut between COMPARE[0] event and STOP task */ -#define TIMER_SHORTS_COMPARE0_STOP_Pos (8UL) /*!< Position of COMPARE0_STOP field. */ -#define TIMER_SHORTS_COMPARE0_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE0_STOP_Pos) /*!< Bit mask of COMPARE0_STOP field. */ -#define TIMER_SHORTS_COMPARE0_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE0_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between COMPARE[5] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Pos (5UL) /*!< Position of COMPARE5_CLEAR field. */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE5_CLEAR_Pos) /*!< Bit mask of COMPARE5_CLEAR field. */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 4 : Shortcut between COMPARE[4] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Pos (4UL) /*!< Position of COMPARE4_CLEAR field. */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE4_CLEAR_Pos) /*!< Bit mask of COMPARE4_CLEAR field. */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between COMPARE[3] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Pos (3UL) /*!< Position of COMPARE3_CLEAR field. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE3_CLEAR_Pos) /*!< Bit mask of COMPARE3_CLEAR field. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between COMPARE[2] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Pos (2UL) /*!< Position of COMPARE2_CLEAR field. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE2_CLEAR_Pos) /*!< Bit mask of COMPARE2_CLEAR field. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between COMPARE[1] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Pos (1UL) /*!< Position of COMPARE1_CLEAR field. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE1_CLEAR_Pos) /*!< Bit mask of COMPARE1_CLEAR field. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between COMPARE[0] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Pos (0UL) /*!< Position of COMPARE0_CLEAR field. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE0_CLEAR_Pos) /*!< Bit mask of COMPARE0_CLEAR field. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TIMER_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 21 : Write '1' to Enable interrupt for COMPARE[5] event */ -#define TIMER_INTENSET_COMPARE5_Pos (21UL) /*!< Position of COMPARE5 field. */ -#define TIMER_INTENSET_COMPARE5_Msk (0x1UL << TIMER_INTENSET_COMPARE5_Pos) /*!< Bit mask of COMPARE5 field. */ -#define TIMER_INTENSET_COMPARE5_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE5_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE5_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for COMPARE[4] event */ -#define TIMER_INTENSET_COMPARE4_Pos (20UL) /*!< Position of COMPARE4 field. */ -#define TIMER_INTENSET_COMPARE4_Msk (0x1UL << TIMER_INTENSET_COMPARE4_Pos) /*!< Bit mask of COMPARE4 field. */ -#define TIMER_INTENSET_COMPARE4_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE4_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE4_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for COMPARE[3] event */ -#define TIMER_INTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define TIMER_INTENSET_COMPARE3_Msk (0x1UL << TIMER_INTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define TIMER_INTENSET_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE3_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for COMPARE[2] event */ -#define TIMER_INTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define TIMER_INTENSET_COMPARE2_Msk (0x1UL << TIMER_INTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define TIMER_INTENSET_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE2_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for COMPARE[1] event */ -#define TIMER_INTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define TIMER_INTENSET_COMPARE1_Msk (0x1UL << TIMER_INTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define TIMER_INTENSET_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE1_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for COMPARE[0] event */ -#define TIMER_INTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define TIMER_INTENSET_COMPARE0_Msk (0x1UL << TIMER_INTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define TIMER_INTENSET_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE0_Set (1UL) /*!< Enable */ - -/* Register: TIMER_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 21 : Write '1' to Disable interrupt for COMPARE[5] event */ -#define TIMER_INTENCLR_COMPARE5_Pos (21UL) /*!< Position of COMPARE5 field. */ -#define TIMER_INTENCLR_COMPARE5_Msk (0x1UL << TIMER_INTENCLR_COMPARE5_Pos) /*!< Bit mask of COMPARE5 field. */ -#define TIMER_INTENCLR_COMPARE5_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE5_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE5_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for COMPARE[4] event */ -#define TIMER_INTENCLR_COMPARE4_Pos (20UL) /*!< Position of COMPARE4 field. */ -#define TIMER_INTENCLR_COMPARE4_Msk (0x1UL << TIMER_INTENCLR_COMPARE4_Pos) /*!< Bit mask of COMPARE4 field. */ -#define TIMER_INTENCLR_COMPARE4_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE4_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE4_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for COMPARE[3] event */ -#define TIMER_INTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define TIMER_INTENCLR_COMPARE3_Msk (0x1UL << TIMER_INTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define TIMER_INTENCLR_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE3_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for COMPARE[2] event */ -#define TIMER_INTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define TIMER_INTENCLR_COMPARE2_Msk (0x1UL << TIMER_INTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define TIMER_INTENCLR_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE2_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for COMPARE[1] event */ -#define TIMER_INTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define TIMER_INTENCLR_COMPARE1_Msk (0x1UL << TIMER_INTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define TIMER_INTENCLR_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE1_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for COMPARE[0] event */ -#define TIMER_INTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define TIMER_INTENCLR_COMPARE0_Msk (0x1UL << TIMER_INTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define TIMER_INTENCLR_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE0_Clear (1UL) /*!< Disable */ - -/* Register: TIMER_MODE */ -/* Description: Timer mode selection */ - -/* Bits 1..0 : Timer mode */ -#define TIMER_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define TIMER_MODE_MODE_Msk (0x3UL << TIMER_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define TIMER_MODE_MODE_Timer (0UL) /*!< Select Timer mode */ -#define TIMER_MODE_MODE_Counter (1UL) /*!< Deprecated enumerator - Select Counter mode */ -#define TIMER_MODE_MODE_LowPowerCounter (2UL) /*!< Select Low Power Counter mode */ - -/* Register: TIMER_BITMODE */ -/* Description: Configure the number of bits used by the TIMER */ - -/* Bits 1..0 : Timer bit width */ -#define TIMER_BITMODE_BITMODE_Pos (0UL) /*!< Position of BITMODE field. */ -#define TIMER_BITMODE_BITMODE_Msk (0x3UL << TIMER_BITMODE_BITMODE_Pos) /*!< Bit mask of BITMODE field. */ -#define TIMER_BITMODE_BITMODE_16Bit (0UL) /*!< 16 bit timer bit width */ -#define TIMER_BITMODE_BITMODE_08Bit (1UL) /*!< 8 bit timer bit width */ -#define TIMER_BITMODE_BITMODE_24Bit (2UL) /*!< 24 bit timer bit width */ -#define TIMER_BITMODE_BITMODE_32Bit (3UL) /*!< 32 bit timer bit width */ - -/* Register: TIMER_PRESCALER */ -/* Description: Timer prescaler register */ - -/* Bits 3..0 : Prescaler value */ -#define TIMER_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define TIMER_PRESCALER_PRESCALER_Msk (0xFUL << TIMER_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ - -/* Register: TIMER_CC */ -/* Description: Description collection[0]: Capture/Compare register 0 */ - -/* Bits 31..0 : Capture/Compare value */ -#define TIMER_CC_CC_Pos (0UL) /*!< Position of CC field. */ -#define TIMER_CC_CC_Msk (0xFFFFFFFFUL << TIMER_CC_CC_Pos) /*!< Bit mask of CC field. */ - - -/* Peripheral: TWIM */ -/* Description: I2C compatible Two-Wire Master Interface with EasyDMA */ - -/* Register: TWIM_TASKS_STARTRX */ -/* Description: Start TWI receive sequence */ - -/* Bit 0 : */ -#define TWIM_TASKS_STARTRX_TASKS_STARTRX_Pos (0UL) /*!< Position of TASKS_STARTRX field. */ -#define TWIM_TASKS_STARTRX_TASKS_STARTRX_Msk (0x1UL << TWIM_TASKS_STARTRX_TASKS_STARTRX_Pos) /*!< Bit mask of TASKS_STARTRX field. */ - -/* Register: TWIM_TASKS_STARTTX */ -/* Description: Start TWI transmit sequence */ - -/* Bit 0 : */ -#define TWIM_TASKS_STARTTX_TASKS_STARTTX_Pos (0UL) /*!< Position of TASKS_STARTTX field. */ -#define TWIM_TASKS_STARTTX_TASKS_STARTTX_Msk (0x1UL << TWIM_TASKS_STARTTX_TASKS_STARTTX_Pos) /*!< Bit mask of TASKS_STARTTX field. */ - -/* Register: TWIM_TASKS_STOP */ -/* Description: Stop TWI transaction. Must be issued while the TWI master is not suspended. */ - -/* Bit 0 : */ -#define TWIM_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define TWIM_TASKS_STOP_TASKS_STOP_Msk (0x1UL << TWIM_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: TWIM_TASKS_SUSPEND */ -/* Description: Suspend TWI transaction */ - -/* Bit 0 : */ -#define TWIM_TASKS_SUSPEND_TASKS_SUSPEND_Pos (0UL) /*!< Position of TASKS_SUSPEND field. */ -#define TWIM_TASKS_SUSPEND_TASKS_SUSPEND_Msk (0x1UL << TWIM_TASKS_SUSPEND_TASKS_SUSPEND_Pos) /*!< Bit mask of TASKS_SUSPEND field. */ - -/* Register: TWIM_TASKS_RESUME */ -/* Description: Resume TWI transaction */ - -/* Bit 0 : */ -#define TWIM_TASKS_RESUME_TASKS_RESUME_Pos (0UL) /*!< Position of TASKS_RESUME field. */ -#define TWIM_TASKS_RESUME_TASKS_RESUME_Msk (0x1UL << TWIM_TASKS_RESUME_TASKS_RESUME_Pos) /*!< Bit mask of TASKS_RESUME field. */ - -/* Register: TWIM_EVENTS_STOPPED */ -/* Description: TWI stopped */ - -/* Bit 0 : */ -#define TWIM_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define TWIM_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << TWIM_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: TWIM_EVENTS_ERROR */ -/* Description: TWI error */ - -/* Bit 0 : */ -#define TWIM_EVENTS_ERROR_EVENTS_ERROR_Pos (0UL) /*!< Position of EVENTS_ERROR field. */ -#define TWIM_EVENTS_ERROR_EVENTS_ERROR_Msk (0x1UL << TWIM_EVENTS_ERROR_EVENTS_ERROR_Pos) /*!< Bit mask of EVENTS_ERROR field. */ - -/* Register: TWIM_EVENTS_SUSPENDED */ -/* Description: Last byte has been sent out after the SUSPEND task has been issued, TWI traffic is now suspended. */ - -/* Bit 0 : */ -#define TWIM_EVENTS_SUSPENDED_EVENTS_SUSPENDED_Pos (0UL) /*!< Position of EVENTS_SUSPENDED field. */ -#define TWIM_EVENTS_SUSPENDED_EVENTS_SUSPENDED_Msk (0x1UL << TWIM_EVENTS_SUSPENDED_EVENTS_SUSPENDED_Pos) /*!< Bit mask of EVENTS_SUSPENDED field. */ - -/* Register: TWIM_EVENTS_RXSTARTED */ -/* Description: Receive sequence started */ - -/* Bit 0 : */ -#define TWIM_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Pos (0UL) /*!< Position of EVENTS_RXSTARTED field. */ -#define TWIM_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Msk (0x1UL << TWIM_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Pos) /*!< Bit mask of EVENTS_RXSTARTED field. */ - -/* Register: TWIM_EVENTS_TXSTARTED */ -/* Description: Transmit sequence started */ - -/* Bit 0 : */ -#define TWIM_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Pos (0UL) /*!< Position of EVENTS_TXSTARTED field. */ -#define TWIM_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Msk (0x1UL << TWIM_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Pos) /*!< Bit mask of EVENTS_TXSTARTED field. */ - -/* Register: TWIM_EVENTS_LASTRX */ -/* Description: Byte boundary, starting to receive the last byte */ - -/* Bit 0 : */ -#define TWIM_EVENTS_LASTRX_EVENTS_LASTRX_Pos (0UL) /*!< Position of EVENTS_LASTRX field. */ -#define TWIM_EVENTS_LASTRX_EVENTS_LASTRX_Msk (0x1UL << TWIM_EVENTS_LASTRX_EVENTS_LASTRX_Pos) /*!< Bit mask of EVENTS_LASTRX field. */ - -/* Register: TWIM_EVENTS_LASTTX */ -/* Description: Byte boundary, starting to transmit the last byte */ - -/* Bit 0 : */ -#define TWIM_EVENTS_LASTTX_EVENTS_LASTTX_Pos (0UL) /*!< Position of EVENTS_LASTTX field. */ -#define TWIM_EVENTS_LASTTX_EVENTS_LASTTX_Msk (0x1UL << TWIM_EVENTS_LASTTX_EVENTS_LASTTX_Pos) /*!< Bit mask of EVENTS_LASTTX field. */ - -/* Register: TWIM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 12 : Shortcut between LASTRX event and STOP task */ -#define TWIM_SHORTS_LASTRX_STOP_Pos (12UL) /*!< Position of LASTRX_STOP field. */ -#define TWIM_SHORTS_LASTRX_STOP_Msk (0x1UL << TWIM_SHORTS_LASTRX_STOP_Pos) /*!< Bit mask of LASTRX_STOP field. */ -#define TWIM_SHORTS_LASTRX_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTRX_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 10 : Shortcut between LASTRX event and STARTTX task */ -#define TWIM_SHORTS_LASTRX_STARTTX_Pos (10UL) /*!< Position of LASTRX_STARTTX field. */ -#define TWIM_SHORTS_LASTRX_STARTTX_Msk (0x1UL << TWIM_SHORTS_LASTRX_STARTTX_Pos) /*!< Bit mask of LASTRX_STARTTX field. */ -#define TWIM_SHORTS_LASTRX_STARTTX_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTRX_STARTTX_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 9 : Shortcut between LASTTX event and STOP task */ -#define TWIM_SHORTS_LASTTX_STOP_Pos (9UL) /*!< Position of LASTTX_STOP field. */ -#define TWIM_SHORTS_LASTTX_STOP_Msk (0x1UL << TWIM_SHORTS_LASTTX_STOP_Pos) /*!< Bit mask of LASTTX_STOP field. */ -#define TWIM_SHORTS_LASTTX_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTTX_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 8 : Shortcut between LASTTX event and SUSPEND task */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Pos (8UL) /*!< Position of LASTTX_SUSPEND field. */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Msk (0x1UL << TWIM_SHORTS_LASTTX_SUSPEND_Pos) /*!< Bit mask of LASTTX_SUSPEND field. */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 7 : Shortcut between LASTTX event and STARTRX task */ -#define TWIM_SHORTS_LASTTX_STARTRX_Pos (7UL) /*!< Position of LASTTX_STARTRX field. */ -#define TWIM_SHORTS_LASTTX_STARTRX_Msk (0x1UL << TWIM_SHORTS_LASTTX_STARTRX_Pos) /*!< Bit mask of LASTTX_STARTRX field. */ -#define TWIM_SHORTS_LASTTX_STARTRX_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTTX_STARTRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TWIM_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 24 : Enable or disable interrupt for LASTTX event */ -#define TWIM_INTEN_LASTTX_Pos (24UL) /*!< Position of LASTTX field. */ -#define TWIM_INTEN_LASTTX_Msk (0x1UL << TWIM_INTEN_LASTTX_Pos) /*!< Bit mask of LASTTX field. */ -#define TWIM_INTEN_LASTTX_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_LASTTX_Enabled (1UL) /*!< Enable */ - -/* Bit 23 : Enable or disable interrupt for LASTRX event */ -#define TWIM_INTEN_LASTRX_Pos (23UL) /*!< Position of LASTRX field. */ -#define TWIM_INTEN_LASTRX_Msk (0x1UL << TWIM_INTEN_LASTRX_Pos) /*!< Bit mask of LASTRX field. */ -#define TWIM_INTEN_LASTRX_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_LASTRX_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for TXSTARTED event */ -#define TWIM_INTEN_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIM_INTEN_TXSTARTED_Msk (0x1UL << TWIM_INTEN_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIM_INTEN_TXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_TXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for RXSTARTED event */ -#define TWIM_INTEN_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIM_INTEN_RXSTARTED_Msk (0x1UL << TWIM_INTEN_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIM_INTEN_RXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_RXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable interrupt for SUSPENDED event */ -#define TWIM_INTEN_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWIM_INTEN_SUSPENDED_Msk (0x1UL << TWIM_INTEN_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWIM_INTEN_SUSPENDED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_SUSPENDED_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ERROR event */ -#define TWIM_INTEN_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIM_INTEN_ERROR_Msk (0x1UL << TWIM_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIM_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define TWIM_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIM_INTEN_STOPPED_Msk (0x1UL << TWIM_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIM_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Register: TWIM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 24 : Write '1' to Enable interrupt for LASTTX event */ -#define TWIM_INTENSET_LASTTX_Pos (24UL) /*!< Position of LASTTX field. */ -#define TWIM_INTENSET_LASTTX_Msk (0x1UL << TWIM_INTENSET_LASTTX_Pos) /*!< Bit mask of LASTTX field. */ -#define TWIM_INTENSET_LASTTX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_LASTTX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_LASTTX_Set (1UL) /*!< Enable */ - -/* Bit 23 : Write '1' to Enable interrupt for LASTRX event */ -#define TWIM_INTENSET_LASTRX_Pos (23UL) /*!< Position of LASTRX field. */ -#define TWIM_INTENSET_LASTRX_Msk (0x1UL << TWIM_INTENSET_LASTRX_Pos) /*!< Bit mask of LASTRX field. */ -#define TWIM_INTENSET_LASTRX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_LASTRX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_LASTRX_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for TXSTARTED event */ -#define TWIM_INTENSET_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIM_INTENSET_TXSTARTED_Msk (0x1UL << TWIM_INTENSET_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIM_INTENSET_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_TXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for RXSTARTED event */ -#define TWIM_INTENSET_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIM_INTENSET_RXSTARTED_Msk (0x1UL << TWIM_INTENSET_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIM_INTENSET_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_RXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for SUSPENDED event */ -#define TWIM_INTENSET_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWIM_INTENSET_SUSPENDED_Msk (0x1UL << TWIM_INTENSET_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWIM_INTENSET_SUSPENDED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_SUSPENDED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_SUSPENDED_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define TWIM_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIM_INTENSET_ERROR_Msk (0x1UL << TWIM_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIM_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define TWIM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIM_INTENSET_STOPPED_Msk (0x1UL << TWIM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: TWIM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 24 : Write '1' to Disable interrupt for LASTTX event */ -#define TWIM_INTENCLR_LASTTX_Pos (24UL) /*!< Position of LASTTX field. */ -#define TWIM_INTENCLR_LASTTX_Msk (0x1UL << TWIM_INTENCLR_LASTTX_Pos) /*!< Bit mask of LASTTX field. */ -#define TWIM_INTENCLR_LASTTX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_LASTTX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_LASTTX_Clear (1UL) /*!< Disable */ - -/* Bit 23 : Write '1' to Disable interrupt for LASTRX event */ -#define TWIM_INTENCLR_LASTRX_Pos (23UL) /*!< Position of LASTRX field. */ -#define TWIM_INTENCLR_LASTRX_Msk (0x1UL << TWIM_INTENCLR_LASTRX_Pos) /*!< Bit mask of LASTRX field. */ -#define TWIM_INTENCLR_LASTRX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_LASTRX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_LASTRX_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for TXSTARTED event */ -#define TWIM_INTENCLR_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIM_INTENCLR_TXSTARTED_Msk (0x1UL << TWIM_INTENCLR_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIM_INTENCLR_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_TXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for RXSTARTED event */ -#define TWIM_INTENCLR_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIM_INTENCLR_RXSTARTED_Msk (0x1UL << TWIM_INTENCLR_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIM_INTENCLR_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_RXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for SUSPENDED event */ -#define TWIM_INTENCLR_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWIM_INTENCLR_SUSPENDED_Msk (0x1UL << TWIM_INTENCLR_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWIM_INTENCLR_SUSPENDED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_SUSPENDED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_SUSPENDED_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define TWIM_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIM_INTENCLR_ERROR_Msk (0x1UL << TWIM_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIM_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define TWIM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIM_INTENCLR_STOPPED_Msk (0x1UL << TWIM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: TWIM_ERRORSRC */ -/* Description: Error source */ - -/* Bit 2 : NACK received after sending a data byte (write '1' to clear) */ -#define TWIM_ERRORSRC_DNACK_Pos (2UL) /*!< Position of DNACK field. */ -#define TWIM_ERRORSRC_DNACK_Msk (0x1UL << TWIM_ERRORSRC_DNACK_Pos) /*!< Bit mask of DNACK field. */ -#define TWIM_ERRORSRC_DNACK_NotReceived (0UL) /*!< Error did not occur */ -#define TWIM_ERRORSRC_DNACK_Received (1UL) /*!< Error occurred */ - -/* Bit 1 : NACK received after sending the address (write '1' to clear) */ -#define TWIM_ERRORSRC_ANACK_Pos (1UL) /*!< Position of ANACK field. */ -#define TWIM_ERRORSRC_ANACK_Msk (0x1UL << TWIM_ERRORSRC_ANACK_Pos) /*!< Bit mask of ANACK field. */ -#define TWIM_ERRORSRC_ANACK_NotReceived (0UL) /*!< Error did not occur */ -#define TWIM_ERRORSRC_ANACK_Received (1UL) /*!< Error occurred */ - -/* Bit 0 : Overrun error */ -#define TWIM_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define TWIM_ERRORSRC_OVERRUN_Msk (0x1UL << TWIM_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define TWIM_ERRORSRC_OVERRUN_NotReceived (0UL) /*!< Error did not occur */ -#define TWIM_ERRORSRC_OVERRUN_Received (1UL) /*!< Error occurred */ - -/* Register: TWIM_ENABLE */ -/* Description: Enable TWIM */ - -/* Bits 3..0 : Enable or disable TWIM */ -#define TWIM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define TWIM_ENABLE_ENABLE_Msk (0xFUL << TWIM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define TWIM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable TWIM */ -#define TWIM_ENABLE_ENABLE_Enabled (6UL) /*!< Enable TWIM */ - -/* Register: TWIM_PSEL_SCL */ -/* Description: Pin select for SCL signal */ - -/* Bit 31 : Connection */ -#define TWIM_PSEL_SCL_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIM_PSEL_SCL_CONNECT_Msk (0x1UL << TWIM_PSEL_SCL_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIM_PSEL_SCL_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIM_PSEL_SCL_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define TWIM_PSEL_SCL_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIM_PSEL_SCL_PIN_Msk (0x1FUL << TWIM_PSEL_SCL_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIM_PSEL_SDA */ -/* Description: Pin select for SDA signal */ - -/* Bit 31 : Connection */ -#define TWIM_PSEL_SDA_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIM_PSEL_SDA_CONNECT_Msk (0x1UL << TWIM_PSEL_SDA_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIM_PSEL_SDA_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIM_PSEL_SDA_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define TWIM_PSEL_SDA_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIM_PSEL_SDA_PIN_Msk (0x1FUL << TWIM_PSEL_SDA_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIM_FREQUENCY */ -/* Description: TWI frequency. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : TWI master clock frequency */ -#define TWIM_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define TWIM_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << TWIM_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define TWIM_FREQUENCY_FREQUENCY_K100 (0x01980000UL) /*!< 100 kbps */ -#define TWIM_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */ -#define TWIM_FREQUENCY_FREQUENCY_K400 (0x06400000UL) /*!< 400 kbps */ - -/* Register: TWIM_RXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define TWIM_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIM_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIM_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIM_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 9..0 : Maximum number of bytes in receive buffer */ -#define TWIM_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIM_RXD_MAXCNT_MAXCNT_Msk (0x3FFUL << TWIM_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIM_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte. */ -#define TWIM_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIM_RXD_AMOUNT_AMOUNT_Msk (0x3FFUL << TWIM_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIM_RXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 2..0 : List type */ -#define TWIM_RXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define TWIM_RXD_LIST_LIST_Msk (0x7UL << TWIM_RXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define TWIM_RXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define TWIM_RXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: TWIM_TXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define TWIM_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIM_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIM_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIM_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 9..0 : Maximum number of bytes in transmit buffer */ -#define TWIM_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIM_TXD_MAXCNT_MAXCNT_Msk (0x3FFUL << TWIM_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIM_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte. */ -#define TWIM_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIM_TXD_AMOUNT_AMOUNT_Msk (0x3FFUL << TWIM_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIM_TXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 2..0 : List type */ -#define TWIM_TXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define TWIM_TXD_LIST_LIST_Msk (0x7UL << TWIM_TXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define TWIM_TXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define TWIM_TXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: TWIM_ADDRESS */ -/* Description: Address used in the TWI transfer */ - -/* Bits 6..0 : Address used in the TWI transfer */ -#define TWIM_ADDRESS_ADDRESS_Pos (0UL) /*!< Position of ADDRESS field. */ -#define TWIM_ADDRESS_ADDRESS_Msk (0x7FUL << TWIM_ADDRESS_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ - - -/* Peripheral: TWIS */ -/* Description: I2C compatible Two-Wire Slave Interface with EasyDMA */ - -/* Register: TWIS_TASKS_STOP */ -/* Description: Stop TWI transaction */ - -/* Bit 0 : */ -#define TWIS_TASKS_STOP_TASKS_STOP_Pos (0UL) /*!< Position of TASKS_STOP field. */ -#define TWIS_TASKS_STOP_TASKS_STOP_Msk (0x1UL << TWIS_TASKS_STOP_TASKS_STOP_Pos) /*!< Bit mask of TASKS_STOP field. */ - -/* Register: TWIS_TASKS_SUSPEND */ -/* Description: Suspend TWI transaction */ - -/* Bit 0 : */ -#define TWIS_TASKS_SUSPEND_TASKS_SUSPEND_Pos (0UL) /*!< Position of TASKS_SUSPEND field. */ -#define TWIS_TASKS_SUSPEND_TASKS_SUSPEND_Msk (0x1UL << TWIS_TASKS_SUSPEND_TASKS_SUSPEND_Pos) /*!< Bit mask of TASKS_SUSPEND field. */ - -/* Register: TWIS_TASKS_RESUME */ -/* Description: Resume TWI transaction */ - -/* Bit 0 : */ -#define TWIS_TASKS_RESUME_TASKS_RESUME_Pos (0UL) /*!< Position of TASKS_RESUME field. */ -#define TWIS_TASKS_RESUME_TASKS_RESUME_Msk (0x1UL << TWIS_TASKS_RESUME_TASKS_RESUME_Pos) /*!< Bit mask of TASKS_RESUME field. */ - -/* Register: TWIS_TASKS_PREPARERX */ -/* Description: Prepare the TWI slave to respond to a write command */ - -/* Bit 0 : */ -#define TWIS_TASKS_PREPARERX_TASKS_PREPARERX_Pos (0UL) /*!< Position of TASKS_PREPARERX field. */ -#define TWIS_TASKS_PREPARERX_TASKS_PREPARERX_Msk (0x1UL << TWIS_TASKS_PREPARERX_TASKS_PREPARERX_Pos) /*!< Bit mask of TASKS_PREPARERX field. */ - -/* Register: TWIS_TASKS_PREPARETX */ -/* Description: Prepare the TWI slave to respond to a read command */ - -/* Bit 0 : */ -#define TWIS_TASKS_PREPARETX_TASKS_PREPARETX_Pos (0UL) /*!< Position of TASKS_PREPARETX field. */ -#define TWIS_TASKS_PREPARETX_TASKS_PREPARETX_Msk (0x1UL << TWIS_TASKS_PREPARETX_TASKS_PREPARETX_Pos) /*!< Bit mask of TASKS_PREPARETX field. */ - -/* Register: TWIS_EVENTS_STOPPED */ -/* Description: TWI stopped */ - -/* Bit 0 : */ -#define TWIS_EVENTS_STOPPED_EVENTS_STOPPED_Pos (0UL) /*!< Position of EVENTS_STOPPED field. */ -#define TWIS_EVENTS_STOPPED_EVENTS_STOPPED_Msk (0x1UL << TWIS_EVENTS_STOPPED_EVENTS_STOPPED_Pos) /*!< Bit mask of EVENTS_STOPPED field. */ - -/* Register: TWIS_EVENTS_ERROR */ -/* Description: TWI error */ - -/* Bit 0 : */ -#define TWIS_EVENTS_ERROR_EVENTS_ERROR_Pos (0UL) /*!< Position of EVENTS_ERROR field. */ -#define TWIS_EVENTS_ERROR_EVENTS_ERROR_Msk (0x1UL << TWIS_EVENTS_ERROR_EVENTS_ERROR_Pos) /*!< Bit mask of EVENTS_ERROR field. */ - -/* Register: TWIS_EVENTS_RXSTARTED */ -/* Description: Receive sequence started */ - -/* Bit 0 : */ -#define TWIS_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Pos (0UL) /*!< Position of EVENTS_RXSTARTED field. */ -#define TWIS_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Msk (0x1UL << TWIS_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Pos) /*!< Bit mask of EVENTS_RXSTARTED field. */ - -/* Register: TWIS_EVENTS_TXSTARTED */ -/* Description: Transmit sequence started */ - -/* Bit 0 : */ -#define TWIS_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Pos (0UL) /*!< Position of EVENTS_TXSTARTED field. */ -#define TWIS_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Msk (0x1UL << TWIS_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Pos) /*!< Bit mask of EVENTS_TXSTARTED field. */ - -/* Register: TWIS_EVENTS_WRITE */ -/* Description: Write command received */ - -/* Bit 0 : */ -#define TWIS_EVENTS_WRITE_EVENTS_WRITE_Pos (0UL) /*!< Position of EVENTS_WRITE field. */ -#define TWIS_EVENTS_WRITE_EVENTS_WRITE_Msk (0x1UL << TWIS_EVENTS_WRITE_EVENTS_WRITE_Pos) /*!< Bit mask of EVENTS_WRITE field. */ - -/* Register: TWIS_EVENTS_READ */ -/* Description: Read command received */ - -/* Bit 0 : */ -#define TWIS_EVENTS_READ_EVENTS_READ_Pos (0UL) /*!< Position of EVENTS_READ field. */ -#define TWIS_EVENTS_READ_EVENTS_READ_Msk (0x1UL << TWIS_EVENTS_READ_EVENTS_READ_Pos) /*!< Bit mask of EVENTS_READ field. */ - -/* Register: TWIS_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 14 : Shortcut between READ event and SUSPEND task */ -#define TWIS_SHORTS_READ_SUSPEND_Pos (14UL) /*!< Position of READ_SUSPEND field. */ -#define TWIS_SHORTS_READ_SUSPEND_Msk (0x1UL << TWIS_SHORTS_READ_SUSPEND_Pos) /*!< Bit mask of READ_SUSPEND field. */ -#define TWIS_SHORTS_READ_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWIS_SHORTS_READ_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 13 : Shortcut between WRITE event and SUSPEND task */ -#define TWIS_SHORTS_WRITE_SUSPEND_Pos (13UL) /*!< Position of WRITE_SUSPEND field. */ -#define TWIS_SHORTS_WRITE_SUSPEND_Msk (0x1UL << TWIS_SHORTS_WRITE_SUSPEND_Pos) /*!< Bit mask of WRITE_SUSPEND field. */ -#define TWIS_SHORTS_WRITE_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWIS_SHORTS_WRITE_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TWIS_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 26 : Enable or disable interrupt for READ event */ -#define TWIS_INTEN_READ_Pos (26UL) /*!< Position of READ field. */ -#define TWIS_INTEN_READ_Msk (0x1UL << TWIS_INTEN_READ_Pos) /*!< Bit mask of READ field. */ -#define TWIS_INTEN_READ_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_READ_Enabled (1UL) /*!< Enable */ - -/* Bit 25 : Enable or disable interrupt for WRITE event */ -#define TWIS_INTEN_WRITE_Pos (25UL) /*!< Position of WRITE field. */ -#define TWIS_INTEN_WRITE_Msk (0x1UL << TWIS_INTEN_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define TWIS_INTEN_WRITE_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_WRITE_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for TXSTARTED event */ -#define TWIS_INTEN_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIS_INTEN_TXSTARTED_Msk (0x1UL << TWIS_INTEN_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIS_INTEN_TXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_TXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for RXSTARTED event */ -#define TWIS_INTEN_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIS_INTEN_RXSTARTED_Msk (0x1UL << TWIS_INTEN_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIS_INTEN_RXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_RXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ERROR event */ -#define TWIS_INTEN_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIS_INTEN_ERROR_Msk (0x1UL << TWIS_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIS_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define TWIS_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIS_INTEN_STOPPED_Msk (0x1UL << TWIS_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIS_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Register: TWIS_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 26 : Write '1' to Enable interrupt for READ event */ -#define TWIS_INTENSET_READ_Pos (26UL) /*!< Position of READ field. */ -#define TWIS_INTENSET_READ_Msk (0x1UL << TWIS_INTENSET_READ_Pos) /*!< Bit mask of READ field. */ -#define TWIS_INTENSET_READ_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_READ_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_READ_Set (1UL) /*!< Enable */ - -/* Bit 25 : Write '1' to Enable interrupt for WRITE event */ -#define TWIS_INTENSET_WRITE_Pos (25UL) /*!< Position of WRITE field. */ -#define TWIS_INTENSET_WRITE_Msk (0x1UL << TWIS_INTENSET_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define TWIS_INTENSET_WRITE_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_WRITE_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_WRITE_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for TXSTARTED event */ -#define TWIS_INTENSET_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIS_INTENSET_TXSTARTED_Msk (0x1UL << TWIS_INTENSET_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIS_INTENSET_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_TXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for RXSTARTED event */ -#define TWIS_INTENSET_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIS_INTENSET_RXSTARTED_Msk (0x1UL << TWIS_INTENSET_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIS_INTENSET_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_RXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define TWIS_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIS_INTENSET_ERROR_Msk (0x1UL << TWIS_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIS_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define TWIS_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIS_INTENSET_STOPPED_Msk (0x1UL << TWIS_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIS_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: TWIS_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 26 : Write '1' to Disable interrupt for READ event */ -#define TWIS_INTENCLR_READ_Pos (26UL) /*!< Position of READ field. */ -#define TWIS_INTENCLR_READ_Msk (0x1UL << TWIS_INTENCLR_READ_Pos) /*!< Bit mask of READ field. */ -#define TWIS_INTENCLR_READ_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_READ_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_READ_Clear (1UL) /*!< Disable */ - -/* Bit 25 : Write '1' to Disable interrupt for WRITE event */ -#define TWIS_INTENCLR_WRITE_Pos (25UL) /*!< Position of WRITE field. */ -#define TWIS_INTENCLR_WRITE_Msk (0x1UL << TWIS_INTENCLR_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define TWIS_INTENCLR_WRITE_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_WRITE_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_WRITE_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for TXSTARTED event */ -#define TWIS_INTENCLR_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIS_INTENCLR_TXSTARTED_Msk (0x1UL << TWIS_INTENCLR_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIS_INTENCLR_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_TXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for RXSTARTED event */ -#define TWIS_INTENCLR_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIS_INTENCLR_RXSTARTED_Msk (0x1UL << TWIS_INTENCLR_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIS_INTENCLR_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_RXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define TWIS_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIS_INTENCLR_ERROR_Msk (0x1UL << TWIS_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIS_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define TWIS_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIS_INTENCLR_STOPPED_Msk (0x1UL << TWIS_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIS_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: TWIS_ERRORSRC */ -/* Description: Error source */ - -/* Bit 3 : TX buffer over-read detected, and prevented */ -#define TWIS_ERRORSRC_OVERREAD_Pos (3UL) /*!< Position of OVERREAD field. */ -#define TWIS_ERRORSRC_OVERREAD_Msk (0x1UL << TWIS_ERRORSRC_OVERREAD_Pos) /*!< Bit mask of OVERREAD field. */ -#define TWIS_ERRORSRC_OVERREAD_NotDetected (0UL) /*!< Error did not occur */ -#define TWIS_ERRORSRC_OVERREAD_Detected (1UL) /*!< Error occurred */ - -/* Bit 2 : NACK sent after receiving a data byte */ -#define TWIS_ERRORSRC_DNACK_Pos (2UL) /*!< Position of DNACK field. */ -#define TWIS_ERRORSRC_DNACK_Msk (0x1UL << TWIS_ERRORSRC_DNACK_Pos) /*!< Bit mask of DNACK field. */ -#define TWIS_ERRORSRC_DNACK_NotReceived (0UL) /*!< Error did not occur */ -#define TWIS_ERRORSRC_DNACK_Received (1UL) /*!< Error occurred */ - -/* Bit 0 : RX buffer overflow detected, and prevented */ -#define TWIS_ERRORSRC_OVERFLOW_Pos (0UL) /*!< Position of OVERFLOW field. */ -#define TWIS_ERRORSRC_OVERFLOW_Msk (0x1UL << TWIS_ERRORSRC_OVERFLOW_Pos) /*!< Bit mask of OVERFLOW field. */ -#define TWIS_ERRORSRC_OVERFLOW_NotDetected (0UL) /*!< Error did not occur */ -#define TWIS_ERRORSRC_OVERFLOW_Detected (1UL) /*!< Error occurred */ - -/* Register: TWIS_MATCH */ -/* Description: Status register indicating which address had a match */ - -/* Bit 0 : Which of the addresses in {ADDRESS} matched the incoming address */ -#define TWIS_MATCH_MATCH_Pos (0UL) /*!< Position of MATCH field. */ -#define TWIS_MATCH_MATCH_Msk (0x1UL << TWIS_MATCH_MATCH_Pos) /*!< Bit mask of MATCH field. */ - -/* Register: TWIS_ENABLE */ -/* Description: Enable TWIS */ - -/* Bits 3..0 : Enable or disable TWIS */ -#define TWIS_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define TWIS_ENABLE_ENABLE_Msk (0xFUL << TWIS_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define TWIS_ENABLE_ENABLE_Disabled (0UL) /*!< Disable TWIS */ -#define TWIS_ENABLE_ENABLE_Enabled (9UL) /*!< Enable TWIS */ - -/* Register: TWIS_PSEL_SCL */ -/* Description: Pin select for SCL signal */ - -/* Bit 31 : Connection */ -#define TWIS_PSEL_SCL_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIS_PSEL_SCL_CONNECT_Msk (0x1UL << TWIS_PSEL_SCL_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIS_PSEL_SCL_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIS_PSEL_SCL_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define TWIS_PSEL_SCL_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIS_PSEL_SCL_PIN_Msk (0x1FUL << TWIS_PSEL_SCL_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIS_PSEL_SDA */ -/* Description: Pin select for SDA signal */ - -/* Bit 31 : Connection */ -#define TWIS_PSEL_SDA_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIS_PSEL_SDA_CONNECT_Msk (0x1UL << TWIS_PSEL_SDA_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIS_PSEL_SDA_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIS_PSEL_SDA_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define TWIS_PSEL_SDA_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIS_PSEL_SDA_PIN_Msk (0x1FUL << TWIS_PSEL_SDA_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIS_RXD_PTR */ -/* Description: RXD Data pointer */ - -/* Bits 31..0 : RXD Data pointer */ -#define TWIS_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIS_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIS_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIS_RXD_MAXCNT */ -/* Description: Maximum number of bytes in RXD buffer */ - -/* Bits 9..0 : Maximum number of bytes in RXD buffer */ -#define TWIS_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIS_RXD_MAXCNT_MAXCNT_Msk (0x3FFUL << TWIS_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIS_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last RXD transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last RXD transaction */ -#define TWIS_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIS_RXD_AMOUNT_AMOUNT_Msk (0x3FFUL << TWIS_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIS_TXD_PTR */ -/* Description: TXD Data pointer */ - -/* Bits 31..0 : TXD Data pointer */ -#define TWIS_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIS_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIS_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIS_TXD_MAXCNT */ -/* Description: Maximum number of bytes in TXD buffer */ - -/* Bits 9..0 : Maximum number of bytes in TXD buffer */ -#define TWIS_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIS_TXD_MAXCNT_MAXCNT_Msk (0x3FFUL << TWIS_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIS_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last TXD transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last TXD transaction */ -#define TWIS_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIS_TXD_AMOUNT_AMOUNT_Msk (0x3FFUL << TWIS_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIS_ADDRESS */ -/* Description: Description collection[0]: TWI slave address 0 */ - -/* Bits 6..0 : TWI slave address */ -#define TWIS_ADDRESS_ADDRESS_Pos (0UL) /*!< Position of ADDRESS field. */ -#define TWIS_ADDRESS_ADDRESS_Msk (0x7FUL << TWIS_ADDRESS_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ - -/* Register: TWIS_CONFIG */ -/* Description: Configuration register for the address match mechanism */ - -/* Bit 1 : Enable or disable address matching on ADDRESS[1] */ -#define TWIS_CONFIG_ADDRESS1_Pos (1UL) /*!< Position of ADDRESS1 field. */ -#define TWIS_CONFIG_ADDRESS1_Msk (0x1UL << TWIS_CONFIG_ADDRESS1_Pos) /*!< Bit mask of ADDRESS1 field. */ -#define TWIS_CONFIG_ADDRESS1_Disabled (0UL) /*!< Disabled */ -#define TWIS_CONFIG_ADDRESS1_Enabled (1UL) /*!< Enabled */ - -/* Bit 0 : Enable or disable address matching on ADDRESS[0] */ -#define TWIS_CONFIG_ADDRESS0_Pos (0UL) /*!< Position of ADDRESS0 field. */ -#define TWIS_CONFIG_ADDRESS0_Msk (0x1UL << TWIS_CONFIG_ADDRESS0_Pos) /*!< Bit mask of ADDRESS0 field. */ -#define TWIS_CONFIG_ADDRESS0_Disabled (0UL) /*!< Disabled */ -#define TWIS_CONFIG_ADDRESS0_Enabled (1UL) /*!< Enabled */ - -/* Register: TWIS_ORC */ -/* Description: Over-read character. Character sent out in case of an over-read of the transmit buffer. */ - -/* Bits 7..0 : Over-read character. Character sent out in case of an over-read of the transmit buffer. */ -#define TWIS_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define TWIS_ORC_ORC_Msk (0xFFUL << TWIS_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - - -/* Peripheral: UARTE */ -/* Description: UART with EasyDMA */ - -/* Register: UARTE_TASKS_STARTRX */ -/* Description: Start UART receiver */ - -/* Bit 0 : */ -#define UARTE_TASKS_STARTRX_TASKS_STARTRX_Pos (0UL) /*!< Position of TASKS_STARTRX field. */ -#define UARTE_TASKS_STARTRX_TASKS_STARTRX_Msk (0x1UL << UARTE_TASKS_STARTRX_TASKS_STARTRX_Pos) /*!< Bit mask of TASKS_STARTRX field. */ - -/* Register: UARTE_TASKS_STOPRX */ -/* Description: Stop UART receiver */ - -/* Bit 0 : */ -#define UARTE_TASKS_STOPRX_TASKS_STOPRX_Pos (0UL) /*!< Position of TASKS_STOPRX field. */ -#define UARTE_TASKS_STOPRX_TASKS_STOPRX_Msk (0x1UL << UARTE_TASKS_STOPRX_TASKS_STOPRX_Pos) /*!< Bit mask of TASKS_STOPRX field. */ - -/* Register: UARTE_TASKS_STARTTX */ -/* Description: Start UART transmitter */ - -/* Bit 0 : */ -#define UARTE_TASKS_STARTTX_TASKS_STARTTX_Pos (0UL) /*!< Position of TASKS_STARTTX field. */ -#define UARTE_TASKS_STARTTX_TASKS_STARTTX_Msk (0x1UL << UARTE_TASKS_STARTTX_TASKS_STARTTX_Pos) /*!< Bit mask of TASKS_STARTTX field. */ - -/* Register: UARTE_TASKS_STOPTX */ -/* Description: Stop UART transmitter */ - -/* Bit 0 : */ -#define UARTE_TASKS_STOPTX_TASKS_STOPTX_Pos (0UL) /*!< Position of TASKS_STOPTX field. */ -#define UARTE_TASKS_STOPTX_TASKS_STOPTX_Msk (0x1UL << UARTE_TASKS_STOPTX_TASKS_STOPTX_Pos) /*!< Bit mask of TASKS_STOPTX field. */ - -/* Register: UARTE_TASKS_FLUSHRX */ -/* Description: Flush RX FIFO into RX buffer */ - -/* Bit 0 : */ -#define UARTE_TASKS_FLUSHRX_TASKS_FLUSHRX_Pos (0UL) /*!< Position of TASKS_FLUSHRX field. */ -#define UARTE_TASKS_FLUSHRX_TASKS_FLUSHRX_Msk (0x1UL << UARTE_TASKS_FLUSHRX_TASKS_FLUSHRX_Pos) /*!< Bit mask of TASKS_FLUSHRX field. */ - -/* Register: UARTE_EVENTS_CTS */ -/* Description: CTS is activated (set low). Clear To Send. */ - -/* Bit 0 : */ -#define UARTE_EVENTS_CTS_EVENTS_CTS_Pos (0UL) /*!< Position of EVENTS_CTS field. */ -#define UARTE_EVENTS_CTS_EVENTS_CTS_Msk (0x1UL << UARTE_EVENTS_CTS_EVENTS_CTS_Pos) /*!< Bit mask of EVENTS_CTS field. */ - -/* Register: UARTE_EVENTS_NCTS */ -/* Description: CTS is deactivated (set high). Not Clear To Send. */ - -/* Bit 0 : */ -#define UARTE_EVENTS_NCTS_EVENTS_NCTS_Pos (0UL) /*!< Position of EVENTS_NCTS field. */ -#define UARTE_EVENTS_NCTS_EVENTS_NCTS_Msk (0x1UL << UARTE_EVENTS_NCTS_EVENTS_NCTS_Pos) /*!< Bit mask of EVENTS_NCTS field. */ - -/* Register: UARTE_EVENTS_RXDRDY */ -/* Description: Data received in RXD (but potentially not yet transferred to Data RAM) */ - -/* Bit 0 : */ -#define UARTE_EVENTS_RXDRDY_EVENTS_RXDRDY_Pos (0UL) /*!< Position of EVENTS_RXDRDY field. */ -#define UARTE_EVENTS_RXDRDY_EVENTS_RXDRDY_Msk (0x1UL << UARTE_EVENTS_RXDRDY_EVENTS_RXDRDY_Pos) /*!< Bit mask of EVENTS_RXDRDY field. */ - -/* Register: UARTE_EVENTS_ENDRX */ -/* Description: Receive buffer is filled up */ - -/* Bit 0 : */ -#define UARTE_EVENTS_ENDRX_EVENTS_ENDRX_Pos (0UL) /*!< Position of EVENTS_ENDRX field. */ -#define UARTE_EVENTS_ENDRX_EVENTS_ENDRX_Msk (0x1UL << UARTE_EVENTS_ENDRX_EVENTS_ENDRX_Pos) /*!< Bit mask of EVENTS_ENDRX field. */ - -/* Register: UARTE_EVENTS_TXDRDY */ -/* Description: Data sent from TXD */ - -/* Bit 0 : */ -#define UARTE_EVENTS_TXDRDY_EVENTS_TXDRDY_Pos (0UL) /*!< Position of EVENTS_TXDRDY field. */ -#define UARTE_EVENTS_TXDRDY_EVENTS_TXDRDY_Msk (0x1UL << UARTE_EVENTS_TXDRDY_EVENTS_TXDRDY_Pos) /*!< Bit mask of EVENTS_TXDRDY field. */ - -/* Register: UARTE_EVENTS_ENDTX */ -/* Description: Last TX byte transmitted */ - -/* Bit 0 : */ -#define UARTE_EVENTS_ENDTX_EVENTS_ENDTX_Pos (0UL) /*!< Position of EVENTS_ENDTX field. */ -#define UARTE_EVENTS_ENDTX_EVENTS_ENDTX_Msk (0x1UL << UARTE_EVENTS_ENDTX_EVENTS_ENDTX_Pos) /*!< Bit mask of EVENTS_ENDTX field. */ - -/* Register: UARTE_EVENTS_ERROR */ -/* Description: Error detected */ - -/* Bit 0 : */ -#define UARTE_EVENTS_ERROR_EVENTS_ERROR_Pos (0UL) /*!< Position of EVENTS_ERROR field. */ -#define UARTE_EVENTS_ERROR_EVENTS_ERROR_Msk (0x1UL << UARTE_EVENTS_ERROR_EVENTS_ERROR_Pos) /*!< Bit mask of EVENTS_ERROR field. */ - -/* Register: UARTE_EVENTS_RXTO */ -/* Description: Receiver timeout */ - -/* Bit 0 : */ -#define UARTE_EVENTS_RXTO_EVENTS_RXTO_Pos (0UL) /*!< Position of EVENTS_RXTO field. */ -#define UARTE_EVENTS_RXTO_EVENTS_RXTO_Msk (0x1UL << UARTE_EVENTS_RXTO_EVENTS_RXTO_Pos) /*!< Bit mask of EVENTS_RXTO field. */ - -/* Register: UARTE_EVENTS_RXSTARTED */ -/* Description: UART receiver has started */ - -/* Bit 0 : */ -#define UARTE_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Pos (0UL) /*!< Position of EVENTS_RXSTARTED field. */ -#define UARTE_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Msk (0x1UL << UARTE_EVENTS_RXSTARTED_EVENTS_RXSTARTED_Pos) /*!< Bit mask of EVENTS_RXSTARTED field. */ - -/* Register: UARTE_EVENTS_TXSTARTED */ -/* Description: UART transmitter has started */ - -/* Bit 0 : */ -#define UARTE_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Pos (0UL) /*!< Position of EVENTS_TXSTARTED field. */ -#define UARTE_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Msk (0x1UL << UARTE_EVENTS_TXSTARTED_EVENTS_TXSTARTED_Pos) /*!< Bit mask of EVENTS_TXSTARTED field. */ - -/* Register: UARTE_EVENTS_TXSTOPPED */ -/* Description: Transmitter stopped */ - -/* Bit 0 : */ -#define UARTE_EVENTS_TXSTOPPED_EVENTS_TXSTOPPED_Pos (0UL) /*!< Position of EVENTS_TXSTOPPED field. */ -#define UARTE_EVENTS_TXSTOPPED_EVENTS_TXSTOPPED_Msk (0x1UL << UARTE_EVENTS_TXSTOPPED_EVENTS_TXSTOPPED_Pos) /*!< Bit mask of EVENTS_TXSTOPPED field. */ - -/* Register: UARTE_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 6 : Shortcut between ENDRX event and STOPRX task */ -#define UARTE_SHORTS_ENDRX_STOPRX_Pos (6UL) /*!< Position of ENDRX_STOPRX field. */ -#define UARTE_SHORTS_ENDRX_STOPRX_Msk (0x1UL << UARTE_SHORTS_ENDRX_STOPRX_Pos) /*!< Bit mask of ENDRX_STOPRX field. */ -#define UARTE_SHORTS_ENDRX_STOPRX_Disabled (0UL) /*!< Disable shortcut */ -#define UARTE_SHORTS_ENDRX_STOPRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between ENDRX event and STARTRX task */ -#define UARTE_SHORTS_ENDRX_STARTRX_Pos (5UL) /*!< Position of ENDRX_STARTRX field. */ -#define UARTE_SHORTS_ENDRX_STARTRX_Msk (0x1UL << UARTE_SHORTS_ENDRX_STARTRX_Pos) /*!< Bit mask of ENDRX_STARTRX field. */ -#define UARTE_SHORTS_ENDRX_STARTRX_Disabled (0UL) /*!< Disable shortcut */ -#define UARTE_SHORTS_ENDRX_STARTRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: UARTE_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 22 : Enable or disable interrupt for TXSTOPPED event */ -#define UARTE_INTEN_TXSTOPPED_Pos (22UL) /*!< Position of TXSTOPPED field. */ -#define UARTE_INTEN_TXSTOPPED_Msk (0x1UL << UARTE_INTEN_TXSTOPPED_Pos) /*!< Bit mask of TXSTOPPED field. */ -#define UARTE_INTEN_TXSTOPPED_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_TXSTOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for TXSTARTED event */ -#define UARTE_INTEN_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define UARTE_INTEN_TXSTARTED_Msk (0x1UL << UARTE_INTEN_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define UARTE_INTEN_TXSTARTED_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_TXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for RXSTARTED event */ -#define UARTE_INTEN_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define UARTE_INTEN_RXSTARTED_Msk (0x1UL << UARTE_INTEN_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define UARTE_INTEN_RXSTARTED_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_RXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable interrupt for RXTO event */ -#define UARTE_INTEN_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UARTE_INTEN_RXTO_Msk (0x1UL << UARTE_INTEN_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UARTE_INTEN_RXTO_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_RXTO_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ERROR event */ -#define UARTE_INTEN_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UARTE_INTEN_ERROR_Msk (0x1UL << UARTE_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UARTE_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for ENDTX event */ -#define UARTE_INTEN_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define UARTE_INTEN_ENDTX_Msk (0x1UL << UARTE_INTEN_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define UARTE_INTEN_ENDTX_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_ENDTX_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for TXDRDY event */ -#define UARTE_INTEN_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UARTE_INTEN_TXDRDY_Msk (0x1UL << UARTE_INTEN_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UARTE_INTEN_TXDRDY_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_TXDRDY_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for ENDRX event */ -#define UARTE_INTEN_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define UARTE_INTEN_ENDRX_Msk (0x1UL << UARTE_INTEN_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define UARTE_INTEN_ENDRX_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_ENDRX_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for RXDRDY event */ -#define UARTE_INTEN_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UARTE_INTEN_RXDRDY_Msk (0x1UL << UARTE_INTEN_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UARTE_INTEN_RXDRDY_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_RXDRDY_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for NCTS event */ -#define UARTE_INTEN_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UARTE_INTEN_NCTS_Msk (0x1UL << UARTE_INTEN_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UARTE_INTEN_NCTS_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_NCTS_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for CTS event */ -#define UARTE_INTEN_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UARTE_INTEN_CTS_Msk (0x1UL << UARTE_INTEN_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UARTE_INTEN_CTS_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_CTS_Enabled (1UL) /*!< Enable */ - -/* Register: UARTE_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 22 : Write '1' to Enable interrupt for TXSTOPPED event */ -#define UARTE_INTENSET_TXSTOPPED_Pos (22UL) /*!< Position of TXSTOPPED field. */ -#define UARTE_INTENSET_TXSTOPPED_Msk (0x1UL << UARTE_INTENSET_TXSTOPPED_Pos) /*!< Bit mask of TXSTOPPED field. */ -#define UARTE_INTENSET_TXSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_TXSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_TXSTOPPED_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for TXSTARTED event */ -#define UARTE_INTENSET_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define UARTE_INTENSET_TXSTARTED_Msk (0x1UL << UARTE_INTENSET_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define UARTE_INTENSET_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_TXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for RXSTARTED event */ -#define UARTE_INTENSET_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define UARTE_INTENSET_RXSTARTED_Msk (0x1UL << UARTE_INTENSET_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define UARTE_INTENSET_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_RXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for RXTO event */ -#define UARTE_INTENSET_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UARTE_INTENSET_RXTO_Msk (0x1UL << UARTE_INTENSET_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UARTE_INTENSET_RXTO_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_RXTO_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_RXTO_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define UARTE_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UARTE_INTENSET_ERROR_Msk (0x1UL << UARTE_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UARTE_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for ENDTX event */ -#define UARTE_INTENSET_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define UARTE_INTENSET_ENDTX_Msk (0x1UL << UARTE_INTENSET_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define UARTE_INTENSET_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_ENDTX_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for TXDRDY event */ -#define UARTE_INTENSET_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UARTE_INTENSET_TXDRDY_Msk (0x1UL << UARTE_INTENSET_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UARTE_INTENSET_TXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_TXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_TXDRDY_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDRX event */ -#define UARTE_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define UARTE_INTENSET_ENDRX_Msk (0x1UL << UARTE_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define UARTE_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for RXDRDY event */ -#define UARTE_INTENSET_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UARTE_INTENSET_RXDRDY_Msk (0x1UL << UARTE_INTENSET_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UARTE_INTENSET_RXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_RXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_RXDRDY_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for NCTS event */ -#define UARTE_INTENSET_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UARTE_INTENSET_NCTS_Msk (0x1UL << UARTE_INTENSET_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UARTE_INTENSET_NCTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_NCTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_NCTS_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for CTS event */ -#define UARTE_INTENSET_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UARTE_INTENSET_CTS_Msk (0x1UL << UARTE_INTENSET_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UARTE_INTENSET_CTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_CTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_CTS_Set (1UL) /*!< Enable */ - -/* Register: UARTE_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 22 : Write '1' to Disable interrupt for TXSTOPPED event */ -#define UARTE_INTENCLR_TXSTOPPED_Pos (22UL) /*!< Position of TXSTOPPED field. */ -#define UARTE_INTENCLR_TXSTOPPED_Msk (0x1UL << UARTE_INTENCLR_TXSTOPPED_Pos) /*!< Bit mask of TXSTOPPED field. */ -#define UARTE_INTENCLR_TXSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_TXSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_TXSTOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for TXSTARTED event */ -#define UARTE_INTENCLR_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define UARTE_INTENCLR_TXSTARTED_Msk (0x1UL << UARTE_INTENCLR_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define UARTE_INTENCLR_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_TXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for RXSTARTED event */ -#define UARTE_INTENCLR_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define UARTE_INTENCLR_RXSTARTED_Msk (0x1UL << UARTE_INTENCLR_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define UARTE_INTENCLR_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_RXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for RXTO event */ -#define UARTE_INTENCLR_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UARTE_INTENCLR_RXTO_Msk (0x1UL << UARTE_INTENCLR_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UARTE_INTENCLR_RXTO_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_RXTO_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_RXTO_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define UARTE_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UARTE_INTENCLR_ERROR_Msk (0x1UL << UARTE_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UARTE_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for ENDTX event */ -#define UARTE_INTENCLR_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define UARTE_INTENCLR_ENDTX_Msk (0x1UL << UARTE_INTENCLR_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define UARTE_INTENCLR_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_ENDTX_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for TXDRDY event */ -#define UARTE_INTENCLR_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UARTE_INTENCLR_TXDRDY_Msk (0x1UL << UARTE_INTENCLR_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UARTE_INTENCLR_TXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_TXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_TXDRDY_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDRX event */ -#define UARTE_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define UARTE_INTENCLR_ENDRX_Msk (0x1UL << UARTE_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define UARTE_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for RXDRDY event */ -#define UARTE_INTENCLR_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UARTE_INTENCLR_RXDRDY_Msk (0x1UL << UARTE_INTENCLR_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UARTE_INTENCLR_RXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_RXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_RXDRDY_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for NCTS event */ -#define UARTE_INTENCLR_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UARTE_INTENCLR_NCTS_Msk (0x1UL << UARTE_INTENCLR_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UARTE_INTENCLR_NCTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_NCTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_NCTS_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for CTS event */ -#define UARTE_INTENCLR_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UARTE_INTENCLR_CTS_Msk (0x1UL << UARTE_INTENCLR_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UARTE_INTENCLR_CTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_CTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_CTS_Clear (1UL) /*!< Disable */ - -/* Register: UARTE_ERRORSRC */ -/* Description: Error source Note : this register is read / write one to clear. */ - -/* Bit 3 : Break condition */ -#define UARTE_ERRORSRC_BREAK_Pos (3UL) /*!< Position of BREAK field. */ -#define UARTE_ERRORSRC_BREAK_Msk (0x1UL << UARTE_ERRORSRC_BREAK_Pos) /*!< Bit mask of BREAK field. */ -#define UARTE_ERRORSRC_BREAK_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_BREAK_Present (1UL) /*!< Read: error present */ - -/* Bit 2 : Framing error occurred */ -#define UARTE_ERRORSRC_FRAMING_Pos (2UL) /*!< Position of FRAMING field. */ -#define UARTE_ERRORSRC_FRAMING_Msk (0x1UL << UARTE_ERRORSRC_FRAMING_Pos) /*!< Bit mask of FRAMING field. */ -#define UARTE_ERRORSRC_FRAMING_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_FRAMING_Present (1UL) /*!< Read: error present */ - -/* Bit 1 : Parity error */ -#define UARTE_ERRORSRC_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UARTE_ERRORSRC_PARITY_Msk (0x1UL << UARTE_ERRORSRC_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UARTE_ERRORSRC_PARITY_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_PARITY_Present (1UL) /*!< Read: error present */ - -/* Bit 0 : Overrun error */ -#define UARTE_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define UARTE_ERRORSRC_OVERRUN_Msk (0x1UL << UARTE_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define UARTE_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_OVERRUN_Present (1UL) /*!< Read: error present */ - -/* Register: UARTE_ENABLE */ -/* Description: Enable UART */ - -/* Bits 3..0 : Enable or disable UARTE */ -#define UARTE_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define UARTE_ENABLE_ENABLE_Msk (0xFUL << UARTE_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define UARTE_ENABLE_ENABLE_Disabled (0UL) /*!< Disable UARTE */ -#define UARTE_ENABLE_ENABLE_Enabled (8UL) /*!< Enable UARTE */ - -/* Register: UARTE_PSEL_RTS */ -/* Description: Pin select for RTS signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_RTS_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_RTS_CONNECT_Msk (0x1UL << UARTE_PSEL_RTS_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_RTS_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_RTS_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_RTS_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_RTS_PIN_Msk (0x1FUL << UARTE_PSEL_RTS_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_PSEL_TXD */ -/* Description: Pin select for TXD signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_TXD_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_TXD_CONNECT_Msk (0x1UL << UARTE_PSEL_TXD_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_TXD_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_TXD_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_TXD_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_TXD_PIN_Msk (0x1FUL << UARTE_PSEL_TXD_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_PSEL_CTS */ -/* Description: Pin select for CTS signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_CTS_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_CTS_CONNECT_Msk (0x1UL << UARTE_PSEL_CTS_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_CTS_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_CTS_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_CTS_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_CTS_PIN_Msk (0x1FUL << UARTE_PSEL_CTS_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_PSEL_RXD */ -/* Description: Pin select for RXD signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_RXD_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_RXD_CONNECT_Msk (0x1UL << UARTE_PSEL_RXD_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_RXD_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_RXD_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_RXD_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_RXD_PIN_Msk (0x1FUL << UARTE_PSEL_RXD_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_BAUDRATE */ -/* Description: Baud rate. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : Baud rate */ -#define UARTE_BAUDRATE_BAUDRATE_Pos (0UL) /*!< Position of BAUDRATE field. */ -#define UARTE_BAUDRATE_BAUDRATE_Msk (0xFFFFFFFFUL << UARTE_BAUDRATE_BAUDRATE_Pos) /*!< Bit mask of BAUDRATE field. */ -#define UARTE_BAUDRATE_BAUDRATE_Baud1200 (0x0004F000UL) /*!< 1200 baud (actual rate: 1205) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud2400 (0x0009D000UL) /*!< 2400 baud (actual rate: 2396) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud4800 (0x0013B000UL) /*!< 4800 baud (actual rate: 4808) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud9600 (0x00275000UL) /*!< 9600 baud (actual rate: 9598) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud14400 (0x003AF000UL) /*!< 14400 baud (actual rate: 14401) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud19200 (0x004EA000UL) /*!< 19200 baud (actual rate: 19208) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud28800 (0x0075C000UL) /*!< 28800 baud (actual rate: 28777) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud31250 (0x00800000UL) /*!< 31250 baud */ -#define UARTE_BAUDRATE_BAUDRATE_Baud38400 (0x009D0000UL) /*!< 38400 baud (actual rate: 38369) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud56000 (0x00E50000UL) /*!< 56000 baud (actual rate: 55944) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud57600 (0x00EB0000UL) /*!< 57600 baud (actual rate: 57554) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud76800 (0x013A9000UL) /*!< 76800 baud (actual rate: 76923) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud115200 (0x01D60000UL) /*!< 115200 baud (actual rate: 115108) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud230400 (0x03B00000UL) /*!< 230400 baud (actual rate: 231884) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud250000 (0x04000000UL) /*!< 250000 baud */ -#define UARTE_BAUDRATE_BAUDRATE_Baud460800 (0x07400000UL) /*!< 460800 baud (actual rate: 457143) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud921600 (0x0F000000UL) /*!< 921600 baud (actual rate: 941176) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud1M (0x10000000UL) /*!< 1Mega baud */ - -/* Register: UARTE_RXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define UARTE_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define UARTE_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << UARTE_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: UARTE_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 9..0 : Maximum number of bytes in receive buffer */ -#define UARTE_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define UARTE_RXD_MAXCNT_MAXCNT_Msk (0x3FFUL << UARTE_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: UARTE_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last transaction */ -#define UARTE_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define UARTE_RXD_AMOUNT_AMOUNT_Msk (0x3FFUL << UARTE_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: UARTE_TXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define UARTE_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define UARTE_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << UARTE_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: UARTE_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 9..0 : Maximum number of bytes in transmit buffer */ -#define UARTE_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define UARTE_TXD_MAXCNT_MAXCNT_Msk (0x3FFUL << UARTE_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: UARTE_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last transaction */ -#define UARTE_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define UARTE_TXD_AMOUNT_AMOUNT_Msk (0x3FFUL << UARTE_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: UARTE_CONFIG */ -/* Description: Configuration of parity and hardware flow control */ - -/* Bit 4 : Stop bits */ -#define UARTE_CONFIG_STOP_Pos (4UL) /*!< Position of STOP field. */ -#define UARTE_CONFIG_STOP_Msk (0x1UL << UARTE_CONFIG_STOP_Pos) /*!< Bit mask of STOP field. */ -#define UARTE_CONFIG_STOP_One (0UL) /*!< One stop bit */ -#define UARTE_CONFIG_STOP_Two (1UL) /*!< Two stop bits */ - -/* Bits 3..1 : Parity */ -#define UARTE_CONFIG_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UARTE_CONFIG_PARITY_Msk (0x7UL << UARTE_CONFIG_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UARTE_CONFIG_PARITY_Excluded (0x0UL) /*!< Exclude parity bit */ -#define UARTE_CONFIG_PARITY_Included (0x7UL) /*!< Include even parity bit */ - -/* Bit 0 : Hardware flow control */ -#define UARTE_CONFIG_HWFC_Pos (0UL) /*!< Position of HWFC field. */ -#define UARTE_CONFIG_HWFC_Msk (0x1UL << UARTE_CONFIG_HWFC_Pos) /*!< Bit mask of HWFC field. */ -#define UARTE_CONFIG_HWFC_Disabled (0UL) /*!< Disabled */ -#define UARTE_CONFIG_HWFC_Enabled (1UL) /*!< Enabled */ - - -/* Peripheral: UICR */ -/* Description: User information configuration registers */ - -/* Register: UICR_NRFFW */ -/* Description: Description collection[0]: Reserved for Nordic firmware design */ - -/* Bits 31..0 : Reserved for Nordic firmware design */ -#define UICR_NRFFW_NRFFW_Pos (0UL) /*!< Position of NRFFW field. */ -#define UICR_NRFFW_NRFFW_Msk (0xFFFFFFFFUL << UICR_NRFFW_NRFFW_Pos) /*!< Bit mask of NRFFW field. */ - -/* Register: UICR_NRFHW */ -/* Description: Description collection[0]: Reserved for Nordic hardware design */ - -/* Bits 31..0 : Reserved for Nordic hardware design */ -#define UICR_NRFHW_NRFHW_Pos (0UL) /*!< Position of NRFHW field. */ -#define UICR_NRFHW_NRFHW_Msk (0xFFFFFFFFUL << UICR_NRFHW_NRFHW_Pos) /*!< Bit mask of NRFHW field. */ - -/* Register: UICR_CUSTOMER */ -/* Description: Description collection[0]: Reserved for customer */ - -/* Bits 31..0 : Reserved for customer */ -#define UICR_CUSTOMER_CUSTOMER_Pos (0UL) /*!< Position of CUSTOMER field. */ -#define UICR_CUSTOMER_CUSTOMER_Msk (0xFFFFFFFFUL << UICR_CUSTOMER_CUSTOMER_Pos) /*!< Bit mask of CUSTOMER field. */ - -/* Register: UICR_PSELRESET */ -/* Description: Description collection[0]: Mapping of the nRESET function (see POWER chapter for details) */ - -/* Bit 31 : Connection */ -#define UICR_PSELRESET_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UICR_PSELRESET_CONNECT_Msk (0x1UL << UICR_PSELRESET_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UICR_PSELRESET_CONNECT_Connected (0UL) /*!< Connect */ -#define UICR_PSELRESET_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bits 5..0 : GPIO number P0.n onto which reset is exposed */ -#define UICR_PSELRESET_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UICR_PSELRESET_PIN_Msk (0x3FUL << UICR_PSELRESET_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UICR_APPROTECT */ -/* Description: Access port protection */ - -/* Bits 7..0 : Enable or disable access port protection. */ -#define UICR_APPROTECT_PALL_Pos (0UL) /*!< Position of PALL field. */ -#define UICR_APPROTECT_PALL_Msk (0xFFUL << UICR_APPROTECT_PALL_Pos) /*!< Bit mask of PALL field. */ -#define UICR_APPROTECT_PALL_Enabled (0x00UL) /*!< Enable */ -#define UICR_APPROTECT_PALL_Disabled (0xFFUL) /*!< Disable */ - - -/* Peripheral: WDT */ -/* Description: Watchdog Timer */ - -/* Register: WDT_TASKS_START */ -/* Description: Start the watchdog */ - -/* Bit 0 : */ -#define WDT_TASKS_START_TASKS_START_Pos (0UL) /*!< Position of TASKS_START field. */ -#define WDT_TASKS_START_TASKS_START_Msk (0x1UL << WDT_TASKS_START_TASKS_START_Pos) /*!< Bit mask of TASKS_START field. */ - -/* Register: WDT_EVENTS_TIMEOUT */ -/* Description: Watchdog timeout */ - -/* Bit 0 : */ -#define WDT_EVENTS_TIMEOUT_EVENTS_TIMEOUT_Pos (0UL) /*!< Position of EVENTS_TIMEOUT field. */ -#define WDT_EVENTS_TIMEOUT_EVENTS_TIMEOUT_Msk (0x1UL << WDT_EVENTS_TIMEOUT_EVENTS_TIMEOUT_Pos) /*!< Bit mask of EVENTS_TIMEOUT field. */ - -/* Register: WDT_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for TIMEOUT event */ -#define WDT_INTENSET_TIMEOUT_Pos (0UL) /*!< Position of TIMEOUT field. */ -#define WDT_INTENSET_TIMEOUT_Msk (0x1UL << WDT_INTENSET_TIMEOUT_Pos) /*!< Bit mask of TIMEOUT field. */ -#define WDT_INTENSET_TIMEOUT_Disabled (0UL) /*!< Read: Disabled */ -#define WDT_INTENSET_TIMEOUT_Enabled (1UL) /*!< Read: Enabled */ -#define WDT_INTENSET_TIMEOUT_Set (1UL) /*!< Enable */ - -/* Register: WDT_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for TIMEOUT event */ -#define WDT_INTENCLR_TIMEOUT_Pos (0UL) /*!< Position of TIMEOUT field. */ -#define WDT_INTENCLR_TIMEOUT_Msk (0x1UL << WDT_INTENCLR_TIMEOUT_Pos) /*!< Bit mask of TIMEOUT field. */ -#define WDT_INTENCLR_TIMEOUT_Disabled (0UL) /*!< Read: Disabled */ -#define WDT_INTENCLR_TIMEOUT_Enabled (1UL) /*!< Read: Enabled */ -#define WDT_INTENCLR_TIMEOUT_Clear (1UL) /*!< Disable */ - -/* Register: WDT_RUNSTATUS */ -/* Description: Run status */ - -/* Bit 0 : Indicates whether or not the watchdog is running */ -#define WDT_RUNSTATUS_RUNSTATUS_Pos (0UL) /*!< Position of RUNSTATUS field. */ -#define WDT_RUNSTATUS_RUNSTATUS_Msk (0x1UL << WDT_RUNSTATUS_RUNSTATUS_Pos) /*!< Bit mask of RUNSTATUS field. */ -#define WDT_RUNSTATUS_RUNSTATUS_NotRunning (0UL) /*!< Watchdog not running */ -#define WDT_RUNSTATUS_RUNSTATUS_Running (1UL) /*!< Watchdog is running */ - -/* Register: WDT_REQSTATUS */ -/* Description: Request status */ - -/* Bit 7 : Request status for RR[7] register */ -#define WDT_REQSTATUS_RR7_Pos (7UL) /*!< Position of RR7 field. */ -#define WDT_REQSTATUS_RR7_Msk (0x1UL << WDT_REQSTATUS_RR7_Pos) /*!< Bit mask of RR7 field. */ -#define WDT_REQSTATUS_RR7_DisabledOrRequested (0UL) /*!< RR[7] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR7_EnabledAndUnrequested (1UL) /*!< RR[7] register is enabled, and are not yet requesting reload */ - -/* Bit 6 : Request status for RR[6] register */ -#define WDT_REQSTATUS_RR6_Pos (6UL) /*!< Position of RR6 field. */ -#define WDT_REQSTATUS_RR6_Msk (0x1UL << WDT_REQSTATUS_RR6_Pos) /*!< Bit mask of RR6 field. */ -#define WDT_REQSTATUS_RR6_DisabledOrRequested (0UL) /*!< RR[6] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR6_EnabledAndUnrequested (1UL) /*!< RR[6] register is enabled, and are not yet requesting reload */ - -/* Bit 5 : Request status for RR[5] register */ -#define WDT_REQSTATUS_RR5_Pos (5UL) /*!< Position of RR5 field. */ -#define WDT_REQSTATUS_RR5_Msk (0x1UL << WDT_REQSTATUS_RR5_Pos) /*!< Bit mask of RR5 field. */ -#define WDT_REQSTATUS_RR5_DisabledOrRequested (0UL) /*!< RR[5] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR5_EnabledAndUnrequested (1UL) /*!< RR[5] register is enabled, and are not yet requesting reload */ - -/* Bit 4 : Request status for RR[4] register */ -#define WDT_REQSTATUS_RR4_Pos (4UL) /*!< Position of RR4 field. */ -#define WDT_REQSTATUS_RR4_Msk (0x1UL << WDT_REQSTATUS_RR4_Pos) /*!< Bit mask of RR4 field. */ -#define WDT_REQSTATUS_RR4_DisabledOrRequested (0UL) /*!< RR[4] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR4_EnabledAndUnrequested (1UL) /*!< RR[4] register is enabled, and are not yet requesting reload */ - -/* Bit 3 : Request status for RR[3] register */ -#define WDT_REQSTATUS_RR3_Pos (3UL) /*!< Position of RR3 field. */ -#define WDT_REQSTATUS_RR3_Msk (0x1UL << WDT_REQSTATUS_RR3_Pos) /*!< Bit mask of RR3 field. */ -#define WDT_REQSTATUS_RR3_DisabledOrRequested (0UL) /*!< RR[3] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR3_EnabledAndUnrequested (1UL) /*!< RR[3] register is enabled, and are not yet requesting reload */ - -/* Bit 2 : Request status for RR[2] register */ -#define WDT_REQSTATUS_RR2_Pos (2UL) /*!< Position of RR2 field. */ -#define WDT_REQSTATUS_RR2_Msk (0x1UL << WDT_REQSTATUS_RR2_Pos) /*!< Bit mask of RR2 field. */ -#define WDT_REQSTATUS_RR2_DisabledOrRequested (0UL) /*!< RR[2] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR2_EnabledAndUnrequested (1UL) /*!< RR[2] register is enabled, and are not yet requesting reload */ - -/* Bit 1 : Request status for RR[1] register */ -#define WDT_REQSTATUS_RR1_Pos (1UL) /*!< Position of RR1 field. */ -#define WDT_REQSTATUS_RR1_Msk (0x1UL << WDT_REQSTATUS_RR1_Pos) /*!< Bit mask of RR1 field. */ -#define WDT_REQSTATUS_RR1_DisabledOrRequested (0UL) /*!< RR[1] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR1_EnabledAndUnrequested (1UL) /*!< RR[1] register is enabled, and are not yet requesting reload */ - -/* Bit 0 : Request status for RR[0] register */ -#define WDT_REQSTATUS_RR0_Pos (0UL) /*!< Position of RR0 field. */ -#define WDT_REQSTATUS_RR0_Msk (0x1UL << WDT_REQSTATUS_RR0_Pos) /*!< Bit mask of RR0 field. */ -#define WDT_REQSTATUS_RR0_DisabledOrRequested (0UL) /*!< RR[0] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR0_EnabledAndUnrequested (1UL) /*!< RR[0] register is enabled, and are not yet requesting reload */ - -/* Register: WDT_CRV */ -/* Description: Counter reload value */ - -/* Bits 31..0 : Counter reload value in number of cycles of the 32.768 kHz clock */ -#define WDT_CRV_CRV_Pos (0UL) /*!< Position of CRV field. */ -#define WDT_CRV_CRV_Msk (0xFFFFFFFFUL << WDT_CRV_CRV_Pos) /*!< Bit mask of CRV field. */ - -/* Register: WDT_RREN */ -/* Description: Enable register for reload request registers */ - -/* Bit 7 : Enable or disable RR[7] register */ -#define WDT_RREN_RR7_Pos (7UL) /*!< Position of RR7 field. */ -#define WDT_RREN_RR7_Msk (0x1UL << WDT_RREN_RR7_Pos) /*!< Bit mask of RR7 field. */ -#define WDT_RREN_RR7_Disabled (0UL) /*!< Disable RR[7] register */ -#define WDT_RREN_RR7_Enabled (1UL) /*!< Enable RR[7] register */ - -/* Bit 6 : Enable or disable RR[6] register */ -#define WDT_RREN_RR6_Pos (6UL) /*!< Position of RR6 field. */ -#define WDT_RREN_RR6_Msk (0x1UL << WDT_RREN_RR6_Pos) /*!< Bit mask of RR6 field. */ -#define WDT_RREN_RR6_Disabled (0UL) /*!< Disable RR[6] register */ -#define WDT_RREN_RR6_Enabled (1UL) /*!< Enable RR[6] register */ - -/* Bit 5 : Enable or disable RR[5] register */ -#define WDT_RREN_RR5_Pos (5UL) /*!< Position of RR5 field. */ -#define WDT_RREN_RR5_Msk (0x1UL << WDT_RREN_RR5_Pos) /*!< Bit mask of RR5 field. */ -#define WDT_RREN_RR5_Disabled (0UL) /*!< Disable RR[5] register */ -#define WDT_RREN_RR5_Enabled (1UL) /*!< Enable RR[5] register */ - -/* Bit 4 : Enable or disable RR[4] register */ -#define WDT_RREN_RR4_Pos (4UL) /*!< Position of RR4 field. */ -#define WDT_RREN_RR4_Msk (0x1UL << WDT_RREN_RR4_Pos) /*!< Bit mask of RR4 field. */ -#define WDT_RREN_RR4_Disabled (0UL) /*!< Disable RR[4] register */ -#define WDT_RREN_RR4_Enabled (1UL) /*!< Enable RR[4] register */ - -/* Bit 3 : Enable or disable RR[3] register */ -#define WDT_RREN_RR3_Pos (3UL) /*!< Position of RR3 field. */ -#define WDT_RREN_RR3_Msk (0x1UL << WDT_RREN_RR3_Pos) /*!< Bit mask of RR3 field. */ -#define WDT_RREN_RR3_Disabled (0UL) /*!< Disable RR[3] register */ -#define WDT_RREN_RR3_Enabled (1UL) /*!< Enable RR[3] register */ - -/* Bit 2 : Enable or disable RR[2] register */ -#define WDT_RREN_RR2_Pos (2UL) /*!< Position of RR2 field. */ -#define WDT_RREN_RR2_Msk (0x1UL << WDT_RREN_RR2_Pos) /*!< Bit mask of RR2 field. */ -#define WDT_RREN_RR2_Disabled (0UL) /*!< Disable RR[2] register */ -#define WDT_RREN_RR2_Enabled (1UL) /*!< Enable RR[2] register */ - -/* Bit 1 : Enable or disable RR[1] register */ -#define WDT_RREN_RR1_Pos (1UL) /*!< Position of RR1 field. */ -#define WDT_RREN_RR1_Msk (0x1UL << WDT_RREN_RR1_Pos) /*!< Bit mask of RR1 field. */ -#define WDT_RREN_RR1_Disabled (0UL) /*!< Disable RR[1] register */ -#define WDT_RREN_RR1_Enabled (1UL) /*!< Enable RR[1] register */ - -/* Bit 0 : Enable or disable RR[0] register */ -#define WDT_RREN_RR0_Pos (0UL) /*!< Position of RR0 field. */ -#define WDT_RREN_RR0_Msk (0x1UL << WDT_RREN_RR0_Pos) /*!< Bit mask of RR0 field. */ -#define WDT_RREN_RR0_Disabled (0UL) /*!< Disable RR[0] register */ -#define WDT_RREN_RR0_Enabled (1UL) /*!< Enable RR[0] register */ - -/* Register: WDT_CONFIG */ -/* Description: Configuration register */ - -/* Bit 3 : Configure the watchdog to either be paused, or kept running, while the CPU is halted by the debugger */ -#define WDT_CONFIG_HALT_Pos (3UL) /*!< Position of HALT field. */ -#define WDT_CONFIG_HALT_Msk (0x1UL << WDT_CONFIG_HALT_Pos) /*!< Bit mask of HALT field. */ -#define WDT_CONFIG_HALT_Pause (0UL) /*!< Pause watchdog while the CPU is halted by the debugger */ -#define WDT_CONFIG_HALT_Run (1UL) /*!< Keep the watchdog running while the CPU is halted by the debugger */ - -/* Bit 0 : Configure the watchdog to either be paused, or kept running, while the CPU is sleeping */ -#define WDT_CONFIG_SLEEP_Pos (0UL) /*!< Position of SLEEP field. */ -#define WDT_CONFIG_SLEEP_Msk (0x1UL << WDT_CONFIG_SLEEP_Pos) /*!< Bit mask of SLEEP field. */ -#define WDT_CONFIG_SLEEP_Pause (0UL) /*!< Pause watchdog while the CPU is sleeping */ -#define WDT_CONFIG_SLEEP_Run (1UL) /*!< Keep the watchdog running while the CPU is sleeping */ - -/* Register: WDT_RR */ -/* Description: Description collection[0]: Reload request 0 */ - -/* Bits 31..0 : Reload request register */ -#define WDT_RR_RR_Pos (0UL) /*!< Position of RR field. */ -#define WDT_RR_RR_Msk (0xFFFFFFFFUL << WDT_RR_RR_Pos) /*!< Bit mask of RR field. */ -#define WDT_RR_RR_Reload (0x6E524635UL) /*!< Value to request a reload of the watchdog timer */ - - -/*lint --flb "Leave library region" */ -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_peripherals.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_peripherals.h deleted file mode 100644 index ea6d7be..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52810_peripherals.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - -Copyright (c) 2010 - 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 _NRF52810_PERIPHERALS_H -#define _NRF52810_PERIPHERALS_H - - -/* Power Peripheral */ -#define POWER_PRESENT -#define POWER_COUNT 1 - -#define POWER_FEATURE_RAM_REGISTERS_PRESENT -#define POWER_FEATURE_RAM_REGISTERS_COUNT 3 - -/* Systick timer */ -#define SYSTICK_PRESENT -#define SYSTICK_COUNT 1 - -/* Software Interrupts */ -#define SWI_PRESENT -#define SWI_COUNT 6 - -/* GPIO */ -#define GPIO_PRESENT -#define GPIO_COUNT 1 - -#define P0_PIN_NUM 32 - -/* MPU and BPROT */ -#define BPROT_PRESENT - -#define BPROT_REGIONS_SIZE 4096 -#define BPROT_REGIONS_NUM 48 - -/* Radio */ -#define RADIO_PRESENT -#define RADIO_COUNT 1 - -#define RADIO_EASYDMA_MAXCNT_SIZE 8 - -/* Accelerated Address Resolver */ -#define AAR_PRESENT -#define AAR_COUNT 1 - -#define AAR_MAX_IRK_NUM 16 - -/* AES Electronic CodeBook mode encryption */ -#define ECB_PRESENT -#define ECB_COUNT 1 - -/* AES CCM mode encryption */ -#define CCM_PRESENT -#define CCM_COUNT 1 - -/* Peripheral to Peripheral Interconnect */ -#define PPI_PRESENT -#define PPI_COUNT 1 - -#define PPI_CH_NUM 20 -#define PPI_FIXED_CH_NUM 12 -#define PPI_GROUP_NUM 6 -#define PPI_FEATURE_FORKS_PRESENT - -/* Event Generator Unit */ -#define EGU_PRESENT -#define EGU_COUNT 2 - -#define EGU0_CH_NUM 16 -#define EGU1_CH_NUM 16 - -/* Timer/Counter */ -#define TIMER_PRESENT -#define TIMER_COUNT 3 - -#define TIMER0_MAX_SIZE 32 -#define TIMER1_MAX_SIZE 32 -#define TIMER2_MAX_SIZE 32 - -#define TIMER0_CC_NUM 4 -#define TIMER1_CC_NUM 4 -#define TIMER2_CC_NUM 4 - -/* Real Time Counter */ -#define RTC_PRESENT -#define RTC_COUNT 2 - -#define RTC0_CC_NUM 3 -#define RTC1_CC_NUM 4 - -/* RNG */ -#define RNG_PRESENT -#define RNG_COUNT 1 - -/* Watchdog Timer */ -#define WDT_PRESENT -#define WDT_COUNT 1 - -/* Temperature Sensor */ -#define TEMP_PRESENT -#define TEMP_COUNT 1 - -/* Serial Peripheral Interface Master with DMA */ -#define SPIM_PRESENT -#define SPIM_COUNT 1 - -#define SPIM0_MAX_DATARATE 8 - -#define SPIM0_FEATURE_HARDWARE_CSN_PRESENT 0 - -#define SPIM0_EASYDMA_MAXCNT_SIZE 10 - -/* Serial Peripheral Interface Slave with DMA*/ -#define SPIS_PRESENT -#define SPIS_COUNT 1 - -#define SPIS0_EASYDMA_MAXCNT_SIZE 10 - -/* Two Wire Interface Master with DMA */ -#define TWIM_PRESENT -#define TWIM_COUNT 1 - -#define TWIM0_EASYDMA_MAXCNT_SIZE 10 - -/* Two Wire Interface Slave with DMA */ -#define TWIS_PRESENT -#define TWIS_COUNT 1 - -#define TWIS0_EASYDMA_MAXCNT_SIZE 10 - -/* Universal Asynchronous Receiver-Transmitter with DMA */ -#define UARTE_PRESENT -#define UARTE_COUNT 1 - -#define UARTE0_EASYDMA_MAXCNT_SIZE 10 - -/* Quadrature Decoder */ -#define QDEC_PRESENT -#define QDEC_COUNT 1 - -/* Successive Approximation Analog to Digital Converter */ -#define SAADC_PRESENT -#define SAADC_COUNT 1 - -#define SAADC_EASYDMA_MAXCNT_SIZE 15 - -/* GPIO Tasks and Events */ -#define GPIOTE_PRESENT -#define GPIOTE_COUNT 1 - -#define GPIOTE_CH_NUM 8 - -#define GPIOTE_FEATURE_SET_PRESENT -#define GPIOTE_FEATURE_CLR_PRESENT - -/* Comparator */ -#define COMP_PRESENT -#define COMP_COUNT 1 - -/* Pulse Width Modulator */ -#define PWM_PRESENT -#define PWM_COUNT 1 - -#define PWM0_CH_NUM 4 - -#define PWM0_EASYDMA_MAXCNT_SIZE 15 - -/* Pulse Density Modulator */ -#define PDM_PRESENT -#define PDM_COUNT 1 - -#define PDM_EASYDMA_MAXCNT_SIZE 15 - - -#endif // _NRF52810_PERIPHERALS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840.h deleted file mode 100644 index bff4c48..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840.h +++ /dev/null @@ -1,2442 +0,0 @@ - -/****************************************************************************************************//** - * @file nrf52840.h - * - * @brief CMSIS Cortex-M4 Peripheral Access Layer Header File for - * nrf52840 from Nordic Semiconductor. - * - * @version V1 - * @date 3. October 2017 - * - * @note Generated with SVDConv V2.81d - * from CMSIS SVD File 'nrf52840.svd' Version 1, - * - * @par Copyright (c) 2010 - 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. - * - * - *******************************************************************************************************/ - - - -/** @addtogroup Nordic Semiconductor - * @{ - */ - -/** @addtogroup nrf52840 - * @{ - */ - -#ifndef NRF52840_H -#define NRF52840_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* ------------------------- Interrupt Number Definition ------------------------ */ - -typedef enum { -/* ------------------- Cortex-M4 Processor Exceptions Numbers ------------------- */ - Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */ - NonMaskableInt_IRQn = -14, /*!< 2 Non maskable Interrupt, cannot be stopped or preempted */ - HardFault_IRQn = -13, /*!< 3 Hard Fault, all classes of Fault */ - MemoryManagement_IRQn = -12, /*!< 4 Memory Management, MPU mismatch, including Access Violation - and No Match */ - BusFault_IRQn = -11, /*!< 5 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory - related Fault */ - UsageFault_IRQn = -10, /*!< 6 Usage Fault, i.e. Undef Instruction, Illegal State Transition */ - SVCall_IRQn = -5, /*!< 11 System Service Call via SVC instruction */ - DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor */ - PendSV_IRQn = -2, /*!< 14 Pendable request for system service */ - SysTick_IRQn = -1, /*!< 15 System Tick Timer */ -/* --------------------- nrf52840 Specific Interrupt Numbers -------------------- */ - POWER_CLOCK_IRQn = 0, /*!< 0 POWER_CLOCK */ - RADIO_IRQn = 1, /*!< 1 RADIO */ - UARTE0_UART0_IRQn = 2, /*!< 2 UARTE0_UART0 */ - SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn= 3, /*!< 3 SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 */ - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn= 4, /*!< 4 SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 */ - NFCT_IRQn = 5, /*!< 5 NFCT */ - GPIOTE_IRQn = 6, /*!< 6 GPIOTE */ - SAADC_IRQn = 7, /*!< 7 SAADC */ - TIMER0_IRQn = 8, /*!< 8 TIMER0 */ - TIMER1_IRQn = 9, /*!< 9 TIMER1 */ - TIMER2_IRQn = 10, /*!< 10 TIMER2 */ - RTC0_IRQn = 11, /*!< 11 RTC0 */ - TEMP_IRQn = 12, /*!< 12 TEMP */ - RNG_IRQn = 13, /*!< 13 RNG */ - ECB_IRQn = 14, /*!< 14 ECB */ - CCM_AAR_IRQn = 15, /*!< 15 CCM_AAR */ - WDT_IRQn = 16, /*!< 16 WDT */ - RTC1_IRQn = 17, /*!< 17 RTC1 */ - QDEC_IRQn = 18, /*!< 18 QDEC */ - COMP_LPCOMP_IRQn = 19, /*!< 19 COMP_LPCOMP */ - SWI0_EGU0_IRQn = 20, /*!< 20 SWI0_EGU0 */ - SWI1_EGU1_IRQn = 21, /*!< 21 SWI1_EGU1 */ - SWI2_EGU2_IRQn = 22, /*!< 22 SWI2_EGU2 */ - SWI3_EGU3_IRQn = 23, /*!< 23 SWI3_EGU3 */ - SWI4_EGU4_IRQn = 24, /*!< 24 SWI4_EGU4 */ - SWI5_EGU5_IRQn = 25, /*!< 25 SWI5_EGU5 */ - TIMER3_IRQn = 26, /*!< 26 TIMER3 */ - TIMER4_IRQn = 27, /*!< 27 TIMER4 */ - PWM0_IRQn = 28, /*!< 28 PWM0 */ - PDM_IRQn = 29, /*!< 29 PDM */ - MWU_IRQn = 32, /*!< 32 MWU */ - PWM1_IRQn = 33, /*!< 33 PWM1 */ - PWM2_IRQn = 34, /*!< 34 PWM2 */ - SPIM2_SPIS2_SPI2_IRQn = 35, /*!< 35 SPIM2_SPIS2_SPI2 */ - RTC2_IRQn = 36, /*!< 36 RTC2 */ - I2S_IRQn = 37, /*!< 37 I2S */ - FPU_IRQn = 38, /*!< 38 FPU */ - USBD_IRQn = 39, /*!< 39 USBD */ - UARTE1_IRQn = 40, /*!< 40 UARTE1 */ - QSPI_IRQn = 41, /*!< 41 QSPI */ - CRYPTOCELL_IRQn = 42, /*!< 42 CRYPTOCELL */ - PWM3_IRQn = 45, /*!< 45 PWM3 */ - SPIM3_IRQn = 47 /*!< 47 SPIM3 */ -} IRQn_Type; - - -/** @addtogroup Configuration_of_CMSIS - * @{ - */ - - -/* ================================================================================ */ -/* ================ Processor and Core Peripheral Section ================ */ -/* ================================================================================ */ - -/* ----------------Configuration of the Cortex-M4 Processor and Core Peripherals---------------- */ -#define __CM4_REV 0x0001 /*!< Cortex-M4 Core Revision */ -#define __MPU_PRESENT 1 /*!< MPU present or not */ -#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */ -#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ -#define __FPU_PRESENT 1 /*!< FPU present or not */ -/** @} */ /* End of group Configuration_of_CMSIS */ - -#include "core_cm4.h" /*!< Cortex-M4 processor and core peripherals */ -#include "system_nrf52840.h" /*!< nrf52840 System */ - - -/* ================================================================================ */ -/* ================ Device Specific Peripheral Section ================ */ -/* ================================================================================ */ - - -/** @addtogroup Device_Peripheral_Registers - * @{ - */ - - -/* ------------------- Start of section using anonymous unions ------------------ */ -#if defined(__CC_ARM) - #pragma push - #pragma anon_unions -#elif defined(__ICCARM__) - #pragma language=extended -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) -/* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning 586 -#else - #warning Not supported compiler type -#endif - - -typedef struct { - __I uint32_t PART; /*!< Part code */ - __I uint32_t VARIANT; /*!< Part variant (hardware version and production configuration) */ - __I uint32_t PACKAGE; /*!< Package option */ - __I uint32_t RAM; /*!< RAM variant */ - __I uint32_t FLASH; /*!< Flash variant */ - __IO uint32_t UNUSED0[3]; /*!< Description collection[0]: Unspecified */ -} FICR_INFO_Type; - -typedef struct { - __I uint32_t A0; /*!< Slope definition A0 */ - __I uint32_t A1; /*!< Slope definition A1 */ - __I uint32_t A2; /*!< Slope definition A2 */ - __I uint32_t A3; /*!< Slope definition A3 */ - __I uint32_t A4; /*!< Slope definition A4 */ - __I uint32_t A5; /*!< Slope definition A5 */ - __I uint32_t B0; /*!< Y-intercept B0 */ - __I uint32_t B1; /*!< Y-intercept B1 */ - __I uint32_t B2; /*!< Y-intercept B2 */ - __I uint32_t B3; /*!< Y-intercept B3 */ - __I uint32_t B4; /*!< Y-intercept B4 */ - __I uint32_t B5; /*!< Y-intercept B5 */ - __I uint32_t T0; /*!< Segment end T0 */ - __I uint32_t T1; /*!< Segment end T1 */ - __I uint32_t T2; /*!< Segment end T2 */ - __I uint32_t T3; /*!< Segment end T3 */ - __I uint32_t T4; /*!< Segment end T4 */ -} FICR_TEMP_Type; - -typedef struct { - __I uint32_t TAGHEADER0; /*!< Default header for NFC tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - __I uint32_t TAGHEADER1; /*!< Default header for NFC tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - __I uint32_t TAGHEADER2; /*!< Default header for NFC tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - __I uint32_t TAGHEADER3; /*!< Default header for NFC tag. Software can read these values to - populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ -} FICR_NFC_Type; - -typedef struct { - __IO uint32_t POWER; /*!< Description cluster[0]: RAM0 power control register */ - __O uint32_t POWERSET; /*!< Description cluster[0]: RAM0 power control set register */ - __O uint32_t POWERCLR; /*!< Description cluster[0]: RAM0 power control clear register */ - __I uint32_t RESERVED0; -} POWER_RAM_Type; - -typedef struct { - __IO uint32_t RTS; /*!< Pin select for RTS signal */ - __IO uint32_t TXD; /*!< Pin select for TXD signal */ - __IO uint32_t CTS; /*!< Pin select for CTS signal */ - __IO uint32_t RXD; /*!< Pin select for RXD signal */ -} UARTE_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} UARTE_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} UARTE_TXD_Type; - -typedef struct { - __IO uint32_t RTS; /*!< Pin select for RTS */ - __IO uint32_t TXD; /*!< Pin select for TXD */ - __IO uint32_t CTS; /*!< Pin select for CTS */ - __IO uint32_t RXD; /*!< Pin select for RXD */ -} UART_PSEL_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ - __IO uint32_t CSN; /*!< Pin select for CSN */ -} SPIM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} SPIM_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} SPIM_TXD_Type; - -typedef struct { - __IO uint32_t RXDELAY; /*!< Sample delay for input serial data on MISO */ - __IO uint32_t CSNDUR; /*!< Minimum duration between edge of CSN and edge of SCK and minimum - duration CSN must stay high between transactions */ -} SPIM_IFTIMING_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t CSN; /*!< Pin select for CSN signal */ -} SPIS_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RXD data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes received in last granted transaction */ -} SPIS_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< TXD data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transmitted in last granted transaction */ -} SPIS_TXD_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL signal */ - __IO uint32_t SDA; /*!< Pin select for SDA signal */ -} TWIM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in receive buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} TWIM_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in transmit buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ - __IO uint32_t LIST; /*!< EasyDMA list type */ -} TWIM_TXD_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL signal */ - __IO uint32_t SDA; /*!< Pin select for SDA signal */ -} TWIS_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RXD Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in RXD buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last RXD transaction */ -} TWIS_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< TXD Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes in TXD buffer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last TXD transaction */ -} TWIS_TXD_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for SCK */ - __IO uint32_t MOSI; /*!< Pin select for MOSI signal */ - __IO uint32_t MISO; /*!< Pin select for MISO signal */ -} SPI_PSEL_Type; - -typedef struct { - __IO uint32_t SCL; /*!< Pin select for SCL */ - __IO uint32_t SDA; /*!< Pin select for SDA */ -} TWI_PSEL_Type; - -typedef struct { - __IO uint32_t RX; /*!< Result of last incoming frame */ -} NFCT_FRAMESTATUS_Type; - -typedef struct { - __IO uint32_t FRAMECONFIG; /*!< Configuration of outgoing frames */ - __IO uint32_t AMOUNT; /*!< Size of outgoing frame */ -} NFCT_TXD_Type; - -typedef struct { - __IO uint32_t FRAMECONFIG; /*!< Configuration of incoming frames */ - __I uint32_t AMOUNT; /*!< Size of last incoming frame */ -} NFCT_RXD_Type; - -typedef struct { - __IO uint32_t LIMITH; /*!< Description cluster[0]: Last results is equal or above CH[0].LIMIT.HIGH */ - __IO uint32_t LIMITL; /*!< Description cluster[0]: Last results is equal or below CH[0].LIMIT.LOW */ -} SAADC_EVENTS_CH_Type; - -typedef struct { - __IO uint32_t PSELP; /*!< Description cluster[0]: Input positive pin selection for CH[0] */ - __IO uint32_t PSELN; /*!< Description cluster[0]: Input negative pin selection for CH[0] */ - __IO uint32_t CONFIG; /*!< Description cluster[0]: Input configuration for CH[0] */ - __IO uint32_t LIMIT; /*!< Description cluster[0]: High/low limits for event monitoring - a channel */ -} SAADC_CH_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of buffer words to transfer */ - __I uint32_t AMOUNT; /*!< Number of buffer words transferred since last START */ -} SAADC_RESULT_Type; - -typedef struct { - __IO uint32_t LED; /*!< Pin select for LED signal */ - __IO uint32_t A; /*!< Pin select for A signal */ - __IO uint32_t B; /*!< Pin select for B signal */ -} QDEC_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Description cluster[0]: Beginning address in Data RAM of this - sequence */ - __IO uint32_t CNT; /*!< Description cluster[0]: Amount of values (duty cycles) in this - sequence */ - __IO uint32_t REFRESH; /*!< Description cluster[0]: Amount of additional PWM periods between - samples loaded into compare register */ - __IO uint32_t ENDDELAY; /*!< Description cluster[0]: Time added after the sequence */ - __I uint32_t RESERVED1[4]; -} PWM_SEQ_Type; - -typedef struct { - __IO uint32_t OUT[4]; /*!< Description collection[0]: Output pin select for PWM channel - 0 */ -} PWM_PSEL_Type; - -typedef struct { - __IO uint32_t CLK; /*!< Pin number configuration for PDM CLK signal */ - __IO uint32_t DIN; /*!< Pin number configuration for PDM DIN signal */ -} PDM_PSEL_Type; - -typedef struct { - __IO uint32_t PTR; /*!< RAM address pointer to write samples to with EasyDMA */ - __IO uint32_t MAXCNT; /*!< Number of samples to allocate memory for in EasyDMA mode */ -} PDM_SAMPLE_Type; - -typedef struct { - __IO uint32_t ADDR; /*!< Description cluster[0]: Configure the word-aligned start address - of region 0 to protect */ - __IO uint32_t SIZE; /*!< Description cluster[0]: Size of region to protect counting from - address ACL[0].ADDR. Write '0' as no effect. */ - __IO uint32_t PERM; /*!< Description cluster[0]: Access permissions for region 0 as defined - by start address ACL[0].ADDR and size ACL[0].SIZE */ - __IO uint32_t UNUSED0; /*!< Unspecified */ -} ACL_ACL_Type; - -typedef struct { - __O uint32_t EN; /*!< Description cluster[0]: Enable channel group 0 */ - __O uint32_t DIS; /*!< Description cluster[0]: Disable channel group 0 */ -} PPI_TASKS_CHG_Type; - -typedef struct { - __IO uint32_t EEP; /*!< Description cluster[0]: Channel 0 event end-point */ - __IO uint32_t TEP; /*!< Description cluster[0]: Channel 0 task end-point */ -} PPI_CH_Type; - -typedef struct { - __IO uint32_t TEP; /*!< Description cluster[0]: Channel 0 task end-point */ -} PPI_FORK_Type; - -typedef struct { - __IO uint32_t WA; /*!< Description cluster[0]: Write access to region 0 detected */ - __IO uint32_t RA; /*!< Description cluster[0]: Read access to region 0 detected */ -} MWU_EVENTS_REGION_Type; - -typedef struct { - __IO uint32_t WA; /*!< Description cluster[0]: Write access to peripheral region 0 - detected */ - __IO uint32_t RA; /*!< Description cluster[0]: Read access to peripheral region 0 detected */ -} MWU_EVENTS_PREGION_Type; - -typedef struct { - __IO uint32_t SUBSTATWA; /*!< Description cluster[0]: Source of event/interrupt in region - 0, write access detected while corresponding subregion was enabled - for watching */ - __IO uint32_t SUBSTATRA; /*!< Description cluster[0]: Source of event/interrupt in region - 0, read access detected while corresponding subregion was enabled - for watching */ -} MWU_PERREGION_Type; - -typedef struct { - __IO uint32_t START; /*!< Description cluster[0]: Start address for region 0 */ - __IO uint32_t END; /*!< Description cluster[0]: End address of region 0 */ - __I uint32_t RESERVED2[2]; -} MWU_REGION_Type; - -typedef struct { - __I uint32_t START; /*!< Description cluster[0]: Reserved for future use */ - __I uint32_t END; /*!< Description cluster[0]: Reserved for future use */ - __IO uint32_t SUBS; /*!< Description cluster[0]: Subregions of region 0 */ - __I uint32_t RESERVED3; -} MWU_PREGION_Type; - -typedef struct { - __IO uint32_t MODE; /*!< I2S mode. */ - __IO uint32_t RXEN; /*!< Reception (RX) enable. */ - __IO uint32_t TXEN; /*!< Transmission (TX) enable. */ - __IO uint32_t MCKEN; /*!< Master clock generator enable. */ - __IO uint32_t MCKFREQ; /*!< Master clock generator frequency. */ - __IO uint32_t RATIO; /*!< MCK / LRCK ratio. */ - __IO uint32_t SWIDTH; /*!< Sample width. */ - __IO uint32_t ALIGN; /*!< Alignment of sample within a frame. */ - __IO uint32_t FORMAT; /*!< Frame format. */ - __IO uint32_t CHANNELS; /*!< Enable channels. */ -} I2S_CONFIG_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Receive buffer RAM start address. */ -} I2S_RXD_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Transmit buffer RAM start address. */ -} I2S_TXD_Type; - -typedef struct { - __IO uint32_t MAXCNT; /*!< Size of RXD and TXD buffers. */ -} I2S_RXTXD_Type; - -typedef struct { - __IO uint32_t MCK; /*!< Pin select for MCK signal. */ - __IO uint32_t SCK; /*!< Pin select for SCK signal. */ - __IO uint32_t LRCK; /*!< Pin select for LRCK signal. */ - __IO uint32_t SDIN; /*!< Pin select for SDIN signal. */ - __IO uint32_t SDOUT; /*!< Pin select for SDOUT signal. */ -} I2S_PSEL_Type; - -typedef struct { - __I uint32_t EPIN[8]; /*!< Description collection[0]: IN endpoint halted status. Can be - used as is as response to a GetStatus() request to endpoint. */ - __I uint32_t RESERVED4; - __I uint32_t EPOUT[8]; /*!< Description collection[0]: OUT endpoint halted status. Can be - used as is as response to a GetStatus() request to endpoint. */ -} USBD_HALTED_Type; - -typedef struct { - __IO uint32_t EPOUT[8]; /*!< Description collection[0]: Amount of bytes received last in - the data stage of this OUT endpoint */ - __I uint32_t ISOOUT; /*!< Amount of bytes received last on this iso OUT data endpoint */ -} USBD_SIZE_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Description cluster[0]: Data pointer */ - __IO uint32_t MAXCNT; /*!< Description cluster[0]: Maximum number of bytes to transfer */ - __I uint32_t AMOUNT; /*!< Description cluster[0]: Number of bytes transferred in the last - transaction */ - __I uint32_t RESERVED5[2]; -} USBD_EPIN_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes to transfer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} USBD_ISOIN_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Description cluster[0]: Data pointer */ - __IO uint32_t MAXCNT; /*!< Description cluster[0]: Maximum number of bytes to transfer */ - __I uint32_t AMOUNT; /*!< Description cluster[0]: Number of bytes transferred in the last - transaction */ - __I uint32_t RESERVED6[2]; -} USBD_EPOUT_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Data pointer */ - __IO uint32_t MAXCNT; /*!< Maximum number of bytes to transfer */ - __I uint32_t AMOUNT; /*!< Number of bytes transferred in the last transaction */ -} USBD_ISOOUT_Type; - -typedef struct { - __IO uint32_t SRC; /*!< Flash memory source address */ - __IO uint32_t DST; /*!< RAM destination address */ - __IO uint32_t CNT; /*!< Read transfer length */ -} QSPI_READ_Type; - -typedef struct { - __IO uint32_t DST; /*!< Flash destination address */ - __IO uint32_t SRC; /*!< RAM source address */ - __IO uint32_t CNT; /*!< Write transfer length */ -} QSPI_WRITE_Type; - -typedef struct { - __IO uint32_t PTR; /*!< Start address of flash block to be erased */ - __IO uint32_t LEN; /*!< Size of block to be erased. */ -} QSPI_ERASE_Type; - -typedef struct { - __IO uint32_t SCK; /*!< Pin select for serial clock SCK */ - __IO uint32_t CSN; /*!< Pin select for chip select signal CSN. */ - __I uint32_t RESERVED7; - __IO uint32_t IO0; /*!< Pin select for serial data MOSI/IO0. */ - __IO uint32_t IO1; /*!< Pin select for serial data MISO/IO1. */ - __IO uint32_t IO2; /*!< Pin select for serial data IO2. */ - __IO uint32_t IO3; /*!< Pin select for serial data IO3. */ -} QSPI_PSEL_Type; - - -/* ================================================================================ */ -/* ================ FICR ================ */ -/* ================================================================================ */ - - -/** - * @brief Factory information configuration registers (FICR) - */ - -typedef struct { /*!< FICR Structure */ - __I uint32_t RESERVED0[4]; - __I uint32_t CODEPAGESIZE; /*!< Code memory page size */ - __I uint32_t CODESIZE; /*!< Code memory size */ - __I uint32_t RESERVED1[18]; - __I uint32_t DEVICEID[2]; /*!< Description collection[0]: Device identifier */ - __I uint32_t RESERVED2[6]; - __I uint32_t ER[4]; /*!< Description collection[0]: Encryption root, word 0 */ - __I uint32_t IR[4]; /*!< Description collection[0]: Identity Root, word 0 */ - __I uint32_t DEVICEADDRTYPE; /*!< Device address type */ - __I uint32_t DEVICEADDR[2]; /*!< Description collection[0]: Device address 0 */ - __I uint32_t RESERVED3[21]; - FICR_INFO_Type INFO; /*!< Device info */ - __I uint32_t RESERVED4[185]; - FICR_TEMP_Type TEMP; /*!< Registers storing factory TEMP module linearization coefficients */ - __I uint32_t RESERVED5[2]; - FICR_NFC_Type NFC; /*!< Unspecified */ -} NRF_FICR_Type; - - -/* ================================================================================ */ -/* ================ UICR ================ */ -/* ================================================================================ */ - - -/** - * @brief User information configuration registers (UICR) - */ - -typedef struct { /*!< UICR Structure */ - __IO uint32_t UNUSED0; /*!< Unspecified */ - __IO uint32_t UNUSED1; /*!< Unspecified */ - __IO uint32_t UNUSED2; /*!< Unspecified */ - __I uint32_t RESERVED0; - __IO uint32_t UNUSED3; /*!< Unspecified */ - __IO uint32_t NRFFW[15]; /*!< Description collection[0]: Reserved for Nordic firmware design */ - __IO uint32_t NRFHW[12]; /*!< Description collection[0]: Reserved for Nordic hardware design */ - __IO uint32_t CUSTOMER[32]; /*!< Description collection[0]: Reserved for customer */ - __I uint32_t RESERVED1[64]; - __IO uint32_t PSELRESET[2]; /*!< Description collection[0]: Mapping of the nRESET function */ - __IO uint32_t APPROTECT; /*!< Access port protection */ - __IO uint32_t NFCPINS; /*!< Setting of pins dedicated to NFC functionality: NFC antenna - or GPIO */ - __IO uint32_t DEBUGCTRL; /*!< Processor debug control */ - __I uint32_t RESERVED2[59]; - __IO uint32_t DCDCDRIVE0; /*!< Set drive level for REG0 DCDC mode. Using high drive will slightly - reduce DCDC efficiency. */ - __IO uint32_t REGOUT0; /*!< GPIO reference voltage / external output supply voltage in high - voltage mode */ -} NRF_UICR_Type; - - -/* ================================================================================ */ -/* ================ POWER ================ */ -/* ================================================================================ */ - - -/** - * @brief Power control (POWER) - */ - -typedef struct { /*!< POWER Structure */ - __I uint32_t RESERVED0[30]; - __O uint32_t TASKS_CONSTLAT; /*!< Enable constant latency mode */ - __O uint32_t TASKS_LOWPWR; /*!< Enable low power mode (variable latency) */ - __I uint32_t RESERVED1[34]; - __IO uint32_t EVENTS_POFWARN; /*!< Power failure warning */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_SLEEPENTER; /*!< CPU entered WFI/WFE sleep */ - __IO uint32_t EVENTS_SLEEPEXIT; /*!< CPU exited WFI/WFE sleep */ - __IO uint32_t EVENTS_USBDETECTED; /*!< Voltage supply detected on VBUS */ - __IO uint32_t EVENTS_USBREMOVED; /*!< Voltage supply removed from VBUS */ - __IO uint32_t EVENTS_USBPWRRDY; /*!< USB 3.3 V supply ready */ - __I uint32_t RESERVED3[119]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[61]; - __IO uint32_t RESETREAS; /*!< Reset reason */ - __I uint32_t RESERVED5[9]; - __I uint32_t RAMSTATUS; /*!< Deprecated register - RAM status register */ - __I uint32_t RESERVED6[3]; - __I uint32_t USBREGSTATUS; /*!< USB supply status */ - __I uint32_t RESERVED7[49]; - __O uint32_t SYSTEMOFF; /*!< System OFF register */ - __I uint32_t RESERVED8[3]; - __IO uint32_t POFCON; /*!< Power failure comparator configuration */ - __I uint32_t RESERVED9[2]; - __IO uint32_t GPREGRET; /*!< General purpose retention register */ - __IO uint32_t GPREGRET2; /*!< General purpose retention register */ - __I uint32_t RESERVED10[21]; - __IO uint32_t DCDCEN; /*!< Enable DC/DC converter for REG1 stage. */ - __I uint32_t RESERVED11; - __IO uint32_t DCDCEN0; /*!< Enable DC/DC converter for REG0 stage. */ - __I uint32_t RESERVED12[47]; - __I uint32_t MAINREGSTATUS; /*!< Main supply status */ - __I uint32_t RESERVED13[175]; - POWER_RAM_Type RAM[9]; /*!< Unspecified */ -} NRF_POWER_Type; - - -/* ================================================================================ */ -/* ================ CLOCK ================ */ -/* ================================================================================ */ - - -/** - * @brief Clock control (CLOCK) - */ - -typedef struct { /*!< CLOCK Structure */ - __O uint32_t TASKS_HFCLKSTART; /*!< Start HFCLK crystal oscillator */ - __O uint32_t TASKS_HFCLKSTOP; /*!< Stop HFCLK crystal oscillator */ - __O uint32_t TASKS_LFCLKSTART; /*!< Start LFCLK source */ - __O uint32_t TASKS_LFCLKSTOP; /*!< Stop LFCLK source */ - __O uint32_t TASKS_CAL; /*!< Start calibration of LFRC or LFULP oscillator */ - __O uint32_t TASKS_CTSTART; /*!< Start calibration timer */ - __O uint32_t TASKS_CTSTOP; /*!< Stop calibration timer */ - __I uint32_t RESERVED0[57]; - __IO uint32_t EVENTS_HFCLKSTARTED; /*!< HFCLK oscillator started */ - __IO uint32_t EVENTS_LFCLKSTARTED; /*!< LFCLK started */ - __I uint32_t RESERVED1; - __IO uint32_t EVENTS_DONE; /*!< Calibration of LFCLK RC oscillator complete event */ - __IO uint32_t EVENTS_CTTO; /*!< Calibration timer timeout */ - __I uint32_t RESERVED2[5]; - __IO uint32_t EVENTS_CTSTARTED; /*!< Calibration timer has been started and is ready to process new - tasks */ - __IO uint32_t EVENTS_CTSTOPPED; /*!< Calibration timer has been stopped and is ready to process new - tasks */ - __I uint32_t RESERVED3[117]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[63]; - __I uint32_t HFCLKRUN; /*!< Status indicating that HFCLKSTART task has been triggered */ - __I uint32_t HFCLKSTAT; /*!< HFCLK status */ - __I uint32_t RESERVED5; - __I uint32_t LFCLKRUN; /*!< Status indicating that LFCLKSTART task has been triggered */ - __I uint32_t LFCLKSTAT; /*!< LFCLK status */ - __I uint32_t LFCLKSRCCOPY; /*!< Copy of LFCLKSRC register, set when LFCLKSTART task was triggered */ - __I uint32_t RESERVED6[62]; - __IO uint32_t LFCLKSRC; /*!< Clock source for the LFCLK */ - __I uint32_t RESERVED7[3]; - __IO uint32_t HFXODEBOUNCE; /*!< HFXO debounce time. The HFXO is started by triggering the TASKS_HFCLKSTART - task. */ - __I uint32_t RESERVED8[3]; - __IO uint32_t CTIV; /*!< Calibration timer interval */ - __I uint32_t RESERVED9[8]; - __IO uint32_t TRACECONFIG; /*!< Clocking options for the Trace Port debug interface */ - __I uint32_t RESERVED10[21]; - __IO uint32_t LFRCMODE; /*!< LFRC mode configuration */ -} NRF_CLOCK_Type; - - -/* ================================================================================ */ -/* ================ RADIO ================ */ -/* ================================================================================ */ - - -/** - * @brief 2.4 GHz Radio (RADIO) - */ - -typedef struct { /*!< RADIO Structure */ - __O uint32_t TASKS_TXEN; /*!< Enable RADIO in TX mode */ - __O uint32_t TASKS_RXEN; /*!< Enable RADIO in RX mode */ - __O uint32_t TASKS_START; /*!< Start RADIO */ - __O uint32_t TASKS_STOP; /*!< Stop RADIO */ - __O uint32_t TASKS_DISABLE; /*!< Disable RADIO */ - __O uint32_t TASKS_RSSISTART; /*!< Start the RSSI and take one single sample of the receive signal - strength. */ - __O uint32_t TASKS_RSSISTOP; /*!< Stop the RSSI measurement */ - __O uint32_t TASKS_BCSTART; /*!< Start the bit counter */ - __O uint32_t TASKS_BCSTOP; /*!< Stop the bit counter */ - __O uint32_t TASKS_EDSTART; /*!< Start the Energy Detect measurement used in IEEE 802.15.4 mode */ - __O uint32_t TASKS_EDSTOP; /*!< Stop the Energy Detect measurement */ - __O uint32_t TASKS_CCASTART; /*!< Start the Clear Channel Assessment used in IEEE 802.15.4 mode */ - __O uint32_t TASKS_CCASTOP; /*!< Stop the Clear Channel Assessment */ - __I uint32_t RESERVED0[51]; - __IO uint32_t EVENTS_READY; /*!< RADIO has ramped up and is ready to be started */ - __IO uint32_t EVENTS_ADDRESS; /*!< Address sent or received */ - __IO uint32_t EVENTS_PAYLOAD; /*!< Packet payload sent or received */ - __IO uint32_t EVENTS_END; /*!< Packet sent or received */ - __IO uint32_t EVENTS_DISABLED; /*!< RADIO has been disabled */ - __IO uint32_t EVENTS_DEVMATCH; /*!< A device address match occurred on the last received packet */ - __IO uint32_t EVENTS_DEVMISS; /*!< No device address match occurred on the last received packet */ - __IO uint32_t EVENTS_RSSIEND; /*!< Sampling of receive signal strength complete. */ - __I uint32_t RESERVED1[2]; - __IO uint32_t EVENTS_BCMATCH; /*!< Bit counter reached bit count value. */ - __I uint32_t RESERVED2; - __IO uint32_t EVENTS_CRCOK; /*!< Packet received with CRC ok */ - __IO uint32_t EVENTS_CRCERROR; /*!< Packet received with CRC error */ - __IO uint32_t EVENTS_FRAMESTART; /*!< IEEE 802.15.4 length field received */ - __IO uint32_t EVENTS_EDEND; /*!< Sampling of Energy Detection complete. A new ED sample is ready - for readout from the RADIO.EDSAMPLE register */ - __IO uint32_t EVENTS_EDSTOPPED; /*!< The sampling of Energy Detection has stopped */ - __IO uint32_t EVENTS_CCAIDLE; /*!< Wireless medium in idle - clear to send */ - __IO uint32_t EVENTS_CCABUSY; /*!< Wireless medium busy - do not send */ - __IO uint32_t EVENTS_CCASTOPPED; /*!< The CCA has stopped */ - __IO uint32_t EVENTS_RATEBOOST; /*!< Ble_LR CI field received, receive mode is changed from Ble_LR125Kbit - to Ble_LR500Kbit. */ - __IO uint32_t EVENTS_TXREADY; /*!< RADIO has ramped up and is ready to be started TX path */ - __IO uint32_t EVENTS_RXREADY; /*!< RADIO has ramped up and is ready to be started RX path */ - __IO uint32_t EVENTS_MHRMATCH; /*!< MAC Header match found. */ - __I uint32_t RESERVED3[3]; - __IO uint32_t EVENTS_PHYEND; /*!< Generated in Ble_LR125Kbit, Ble_LR500Kbit and BleIeee802154_250Kbit - modes when last bit is sent on air. */ - __I uint32_t RESERVED4[36]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED5[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED6[61]; - __I uint32_t CRCSTATUS; /*!< CRC status */ - __I uint32_t RESERVED7; - __I uint32_t RXMATCH; /*!< Received address */ - __I uint32_t RXCRC; /*!< CRC field of previously received packet */ - __I uint32_t DAI; /*!< Device address match index */ - __I uint32_t PDUSTAT; /*!< Payload status */ - __I uint32_t RESERVED8[59]; - __IO uint32_t PACKETPTR; /*!< Packet pointer */ - __IO uint32_t FREQUENCY; /*!< Frequency */ - __IO uint32_t TXPOWER; /*!< Output power */ - __IO uint32_t MODE; /*!< Data rate and modulation */ - __IO uint32_t PCNF0; /*!< Packet configuration register 0 */ - __IO uint32_t PCNF1; /*!< Packet configuration register 1 */ - __IO uint32_t BASE0; /*!< Base address 0 */ - __IO uint32_t BASE1; /*!< Base address 1 */ - __IO uint32_t PREFIX0; /*!< Prefixes bytes for logical addresses 0-3 */ - __IO uint32_t PREFIX1; /*!< Prefixes bytes for logical addresses 4-7 */ - __IO uint32_t TXADDRESS; /*!< Transmit address select */ - __IO uint32_t RXADDRESSES; /*!< Receive address select */ - __IO uint32_t CRCCNF; /*!< CRC configuration */ - __IO uint32_t CRCPOLY; /*!< CRC polynomial */ - __IO uint32_t CRCINIT; /*!< CRC initial value */ - __I uint32_t RESERVED9; - __IO uint32_t TIFS; /*!< Inter Frame Spacing in us */ - __I uint32_t RSSISAMPLE; /*!< RSSI sample */ - __I uint32_t RESERVED10; - __I uint32_t STATE; /*!< Current radio state */ - __IO uint32_t DATAWHITEIV; /*!< Data whitening initial value */ - __I uint32_t RESERVED11[2]; - __IO uint32_t BCC; /*!< Bit counter compare */ - __I uint32_t RESERVED12[39]; - __IO uint32_t DAB[8]; /*!< Description collection[0]: Device address base segment 0 */ - __IO uint32_t DAP[8]; /*!< Description collection[0]: Device address prefix 0 */ - __IO uint32_t DACNF; /*!< Device address match configuration */ - __IO uint32_t MHRMATCHCONF; /*!< Search Pattern Configuration */ - __IO uint32_t MHRMATCHMAS; /*!< Pattern mask */ - __I uint32_t RESERVED13; - __IO uint32_t MODECNF0; /*!< Radio mode configuration register 0 */ - __I uint32_t RESERVED14[3]; - __IO uint32_t SFD; /*!< IEEE 802.15.4 Start of Frame Delimiter */ - __IO uint32_t EDCNT; /*!< IEEE 802.15.4 Energy Detect Loop Count */ - __IO uint32_t EDSAMPLE; /*!< IEEE 802.15.4 Energy Detect Level */ - __IO uint32_t CCACTRL; /*!< IEEE 802.15.4 Clear Channel Assessment Control */ - __I uint32_t RESERVED15[611]; - __IO uint32_t POWER; /*!< Peripheral power control */ -} NRF_RADIO_Type; - - -/* ================================================================================ */ -/* ================ UARTE ================ */ -/* ================================================================================ */ - - -/** - * @brief UART with EasyDMA 0 (UARTE) - */ - -typedef struct { /*!< UARTE Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start UART receiver */ - __O uint32_t TASKS_STOPRX; /*!< Stop UART receiver */ - __O uint32_t TASKS_STARTTX; /*!< Start UART transmitter */ - __O uint32_t TASKS_STOPTX; /*!< Stop UART transmitter */ - __I uint32_t RESERVED0[7]; - __O uint32_t TASKS_FLUSHRX; /*!< Flush RX FIFO into RX buffer */ - __I uint32_t RESERVED1[52]; - __IO uint32_t EVENTS_CTS; /*!< CTS is activated (set low). Clear To Send. */ - __IO uint32_t EVENTS_NCTS; /*!< CTS is deactivated (set high). Not Clear To Send. */ - __IO uint32_t EVENTS_RXDRDY; /*!< Data received in RXD (but potentially not yet transferred to - Data RAM) */ - __I uint32_t RESERVED2; - __IO uint32_t EVENTS_ENDRX; /*!< Receive buffer is filled up */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_TXDRDY; /*!< Data sent from TXD */ - __IO uint32_t EVENTS_ENDTX; /*!< Last TX byte transmitted */ - __IO uint32_t EVENTS_ERROR; /*!< Error detected */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_RXTO; /*!< Receiver timeout */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_RXSTARTED; /*!< UART receiver has started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< UART transmitter has started */ - __I uint32_t RESERVED6; - __IO uint32_t EVENTS_TXSTOPPED; /*!< Transmitter stopped */ - __I uint32_t RESERVED7[41]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[93]; - __IO uint32_t ERRORSRC; /*!< Error source Note : this register is read / write one to clear. */ - __I uint32_t RESERVED10[31]; - __IO uint32_t ENABLE; /*!< Enable UART */ - __I uint32_t RESERVED11; - UARTE_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[3]; - __IO uint32_t BAUDRATE; /*!< Baud rate. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED13[3]; - UARTE_RXD_Type RXD; /*!< RXD EasyDMA channel */ - __I uint32_t RESERVED14; - UARTE_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED15[7]; - __IO uint32_t CONFIG; /*!< Configuration of parity and hardware flow control */ -} NRF_UARTE_Type; - - -/* ================================================================================ */ -/* ================ UART ================ */ -/* ================================================================================ */ - - -/** - * @brief Universal Asynchronous Receiver/Transmitter (UART) - */ - -typedef struct { /*!< UART Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start UART receiver */ - __O uint32_t TASKS_STOPRX; /*!< Stop UART receiver */ - __O uint32_t TASKS_STARTTX; /*!< Start UART transmitter */ - __O uint32_t TASKS_STOPTX; /*!< Stop UART transmitter */ - __I uint32_t RESERVED0[3]; - __O uint32_t TASKS_SUSPEND; /*!< Suspend UART */ - __I uint32_t RESERVED1[56]; - __IO uint32_t EVENTS_CTS; /*!< CTS is activated (set low). Clear To Send. */ - __IO uint32_t EVENTS_NCTS; /*!< CTS is deactivated (set high). Not Clear To Send. */ - __IO uint32_t EVENTS_RXDRDY; /*!< Data received in RXD */ - __I uint32_t RESERVED2[4]; - __IO uint32_t EVENTS_TXDRDY; /*!< Data sent from TXD */ - __I uint32_t RESERVED3; - __IO uint32_t EVENTS_ERROR; /*!< Error detected */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_RXTO; /*!< Receiver timeout */ - __I uint32_t RESERVED5[46]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED6[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED7[93]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED8[31]; - __IO uint32_t ENABLE; /*!< Enable UART */ - __I uint32_t RESERVED9; - UART_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RXD; /*!< RXD register */ - __O uint32_t TXD; /*!< TXD register */ - __I uint32_t RESERVED10; - __IO uint32_t BAUDRATE; /*!< Baud rate. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED11[17]; - __IO uint32_t CONFIG; /*!< Configuration of parity and hardware flow control */ -} NRF_UART_Type; - - -/* ================================================================================ */ -/* ================ SPIM ================ */ -/* ================================================================================ */ - - -/** - * @brief Serial Peripheral Interface Master with EasyDMA 0 (SPIM) - */ - -typedef struct { /*!< SPIM Structure */ - __I uint32_t RESERVED0[4]; - __O uint32_t TASKS_START; /*!< Start SPI transaction */ - __O uint32_t TASKS_STOP; /*!< Stop SPI transaction */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_SUSPEND; /*!< Suspend SPI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume SPI transaction */ - __I uint32_t RESERVED2[56]; - __IO uint32_t EVENTS_STOPPED; /*!< SPI transaction has stopped */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED4; - __IO uint32_t EVENTS_END; /*!< End of RXD buffer and TXD buffer reached */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_ENDTX; /*!< End of TXD buffer reached */ - __I uint32_t RESERVED6[10]; - __IO uint32_t EVENTS_STARTED; /*!< Transaction started */ - __I uint32_t RESERVED7[44]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[61]; - __IO uint32_t STALLSTAT; /*!< Stall status for EasyDMA RAM accesses. The fields in this register - is set to STALL by hardware whenever a stall occurres and can - be cleared (set to NOSTALL) by the CPU. */ - __I uint32_t RESERVED10[63]; - __IO uint32_t ENABLE; /*!< Enable SPIM */ - __I uint32_t RESERVED11; - SPIM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[3]; - __IO uint32_t FREQUENCY; /*!< SPI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED13[3]; - SPIM_RXD_Type RXD; /*!< RXD EasyDMA channel */ - SPIM_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED14[2]; - SPIM_IFTIMING_Type IFTIMING; /*!< Unspecified */ - __IO uint32_t CSNPOL; /*!< Polarity of CSN output */ - __IO uint32_t PSELDCX; /*!< Pin select for DCX signal */ - __IO uint32_t DCXCNT; /*!< DCX configuration */ - __I uint32_t RESERVED15[19]; - __IO uint32_t ORC; /*!< Byte transmitted after TXD.MAXCNT bytes have been transmitted - in the case when RXD.MAXCNT is greater than TXD.MAXCNT */ -} NRF_SPIM_Type; - - -/* ================================================================================ */ -/* ================ SPIS ================ */ -/* ================================================================================ */ - - -/** - * @brief SPI Slave 0 (SPIS) - */ - -typedef struct { /*!< SPIS Structure */ - __I uint32_t RESERVED0[9]; - __O uint32_t TASKS_ACQUIRE; /*!< Acquire SPI semaphore */ - __O uint32_t TASKS_RELEASE; /*!< Release SPI semaphore, enabling the SPI slave to acquire it */ - __I uint32_t RESERVED1[54]; - __IO uint32_t EVENTS_END; /*!< Granted transaction completed */ - __I uint32_t RESERVED2[2]; - __IO uint32_t EVENTS_ENDRX; /*!< End of RXD buffer reached */ - __I uint32_t RESERVED3[5]; - __IO uint32_t EVENTS_ACQUIRED; /*!< Semaphore acquired */ - __I uint32_t RESERVED4[53]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED5[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED6[61]; - __I uint32_t SEMSTAT; /*!< Semaphore status register */ - __I uint32_t RESERVED7[15]; - __IO uint32_t STATUS; /*!< Status from last transaction */ - __I uint32_t RESERVED8[47]; - __IO uint32_t ENABLE; /*!< Enable SPI slave */ - __I uint32_t RESERVED9; - SPIS_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED10[7]; - SPIS_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED11; - SPIS_TXD_Type TXD; /*!< Unspecified */ - __I uint32_t RESERVED12; - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED13; - __IO uint32_t DEF; /*!< Default character. Character clocked out in case of an ignored - transaction. */ - __I uint32_t RESERVED14[24]; - __IO uint32_t ORC; /*!< Over-read character */ -} NRF_SPIS_Type; - - -/* ================================================================================ */ -/* ================ TWIM ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Master Interface with EasyDMA 0 (TWIM) - */ - -typedef struct { /*!< TWIM Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start TWI receive sequence */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTTX; /*!< Start TWI transmit sequence */ - __I uint32_t RESERVED1[2]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction. Must be issued while the TWI master is - not suspended. */ - __I uint32_t RESERVED2; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED3[56]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED5[8]; - __IO uint32_t EVENTS_SUSPENDED; /*!< Last byte has been sent out after the SUSPEND task has been - issued, TWI traffic is now suspended. */ - __IO uint32_t EVENTS_RXSTARTED; /*!< Receive sequence started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< Transmit sequence started */ - __I uint32_t RESERVED6[2]; - __IO uint32_t EVENTS_LASTRX; /*!< Byte boundary, starting to receive the last byte */ - __IO uint32_t EVENTS_LASTTX; /*!< Byte boundary, starting to transmit the last byte */ - __I uint32_t RESERVED7[39]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[110]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED10[14]; - __IO uint32_t ENABLE; /*!< Enable TWIM */ - __I uint32_t RESERVED11; - TWIM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[5]; - __IO uint32_t FREQUENCY; /*!< TWI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED13[3]; - TWIM_RXD_Type RXD; /*!< RXD EasyDMA channel */ - TWIM_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED14[13]; - __IO uint32_t ADDRESS; /*!< Address used in the TWI transfer */ -} NRF_TWIM_Type; - - -/* ================================================================================ */ -/* ================ TWIS ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Slave Interface with EasyDMA 0 (TWIS) - */ - -typedef struct { /*!< TWIS Structure */ - __I uint32_t RESERVED0[5]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED2[3]; - __O uint32_t TASKS_PREPARERX; /*!< Prepare the TWI slave to respond to a write command */ - __O uint32_t TASKS_PREPARETX; /*!< Prepare the TWI slave to respond to a read command */ - __I uint32_t RESERVED3[51]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __I uint32_t RESERVED4[7]; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED5[9]; - __IO uint32_t EVENTS_RXSTARTED; /*!< Receive sequence started */ - __IO uint32_t EVENTS_TXSTARTED; /*!< Transmit sequence started */ - __I uint32_t RESERVED6[4]; - __IO uint32_t EVENTS_WRITE; /*!< Write command received */ - __IO uint32_t EVENTS_READ; /*!< Read command received */ - __I uint32_t RESERVED7[37]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED8[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED9[113]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t MATCH; /*!< Status register indicating which address had a match */ - __I uint32_t RESERVED10[10]; - __IO uint32_t ENABLE; /*!< Enable TWIS */ - __I uint32_t RESERVED11; - TWIS_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED12[9]; - TWIS_RXD_Type RXD; /*!< RXD EasyDMA channel */ - __I uint32_t RESERVED13; - TWIS_TXD_Type TXD; /*!< TXD EasyDMA channel */ - __I uint32_t RESERVED14[14]; - __IO uint32_t ADDRESS[2]; /*!< Description collection[0]: TWI slave address 0 */ - __I uint32_t RESERVED15; - __IO uint32_t CONFIG; /*!< Configuration register for the address match mechanism */ - __I uint32_t RESERVED16[10]; - __IO uint32_t ORC; /*!< Over-read character. Character sent out in case of an over-read - of the transmit buffer. */ -} NRF_TWIS_Type; - - -/* ================================================================================ */ -/* ================ SPI ================ */ -/* ================================================================================ */ - - -/** - * @brief Serial Peripheral Interface 0 (SPI) - */ - -typedef struct { /*!< SPI Structure */ - __I uint32_t RESERVED0[66]; - __IO uint32_t EVENTS_READY; /*!< TXD byte sent and RXD byte received */ - __I uint32_t RESERVED1[126]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< Enable SPI */ - __I uint32_t RESERVED3; - SPI_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED4; - __I uint32_t RXD; /*!< RXD register */ - __IO uint32_t TXD; /*!< TXD register */ - __I uint32_t RESERVED5; - __IO uint32_t FREQUENCY; /*!< SPI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CONFIG; /*!< Configuration register */ -} NRF_SPI_Type; - - -/* ================================================================================ */ -/* ================ TWI ================ */ -/* ================================================================================ */ - - -/** - * @brief I2C compatible Two-Wire Interface 0 (TWI) - */ - -typedef struct { /*!< TWI Structure */ - __O uint32_t TASKS_STARTRX; /*!< Start TWI receive sequence */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTTX; /*!< Start TWI transmit sequence */ - __I uint32_t RESERVED1[2]; - __O uint32_t TASKS_STOP; /*!< Stop TWI transaction */ - __I uint32_t RESERVED2; - __O uint32_t TASKS_SUSPEND; /*!< Suspend TWI transaction */ - __O uint32_t TASKS_RESUME; /*!< Resume TWI transaction */ - __I uint32_t RESERVED3[56]; - __IO uint32_t EVENTS_STOPPED; /*!< TWI stopped */ - __IO uint32_t EVENTS_RXDREADY; /*!< TWI RXD byte received */ - __I uint32_t RESERVED4[4]; - __IO uint32_t EVENTS_TXDSENT; /*!< TWI TXD byte sent */ - __I uint32_t RESERVED5; - __IO uint32_t EVENTS_ERROR; /*!< TWI error */ - __I uint32_t RESERVED6[4]; - __IO uint32_t EVENTS_BB; /*!< TWI byte boundary, generated before each byte that is sent or - received */ - __I uint32_t RESERVED7[3]; - __IO uint32_t EVENTS_SUSPENDED; /*!< TWI entered the suspended state */ - __I uint32_t RESERVED8[45]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED9[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED10[110]; - __IO uint32_t ERRORSRC; /*!< Error source */ - __I uint32_t RESERVED11[14]; - __IO uint32_t ENABLE; /*!< Enable TWI */ - __I uint32_t RESERVED12; - TWI_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED13[2]; - __I uint32_t RXD; /*!< RXD register */ - __IO uint32_t TXD; /*!< TXD register */ - __I uint32_t RESERVED14; - __IO uint32_t FREQUENCY; /*!< TWI frequency. Accuracy depends on the HFCLK source selected. */ - __I uint32_t RESERVED15[24]; - __IO uint32_t ADDRESS; /*!< Address used in the TWI transfer */ -} NRF_TWI_Type; - - -/* ================================================================================ */ -/* ================ NFCT ================ */ -/* ================================================================================ */ - - -/** - * @brief NFC-A compatible radio (NFCT) - */ - -typedef struct { /*!< NFCT Structure */ - __O uint32_t TASKS_ACTIVATE; /*!< Activate NFCT peripheral for incoming and outgoing frames, change - state to activated */ - __O uint32_t TASKS_DISABLE; /*!< Disable NFCT peripheral */ - __O uint32_t TASKS_SENSE; /*!< Enable NFC sense field mode, change state to sense mode */ - __O uint32_t TASKS_STARTTX; /*!< Start transmission of an outgoing frame, change state to transmit */ - __I uint32_t RESERVED0[3]; - __O uint32_t TASKS_ENABLERXDATA; /*!< Initializes the EasyDMA for receive. */ - __I uint32_t RESERVED1; - __O uint32_t TASKS_GOIDLE; /*!< Force state machine to IDLE state */ - __O uint32_t TASKS_GOSLEEP; /*!< Force state machine to SLEEP_A state */ - __I uint32_t RESERVED2[53]; - __IO uint32_t EVENTS_READY; /*!< The NFCT peripheral is ready to receive and send frames */ - __IO uint32_t EVENTS_FIELDDETECTED; /*!< Remote NFC field detected */ - __IO uint32_t EVENTS_FIELDLOST; /*!< Remote NFC field lost */ - __IO uint32_t EVENTS_TXFRAMESTART; /*!< Marks the start of the first symbol of a transmitted frame */ - __IO uint32_t EVENTS_TXFRAMEEND; /*!< Marks the end of the last transmitted on-air symbol of a frame */ - __IO uint32_t EVENTS_RXFRAMESTART; /*!< Marks the end of the first symbol of a received frame */ - __IO uint32_t EVENTS_RXFRAMEEND; /*!< Received data has been checked (CRC, parity) and transferred - to RAM, and EasyDMA has ended accessing the RX buffer */ - __IO uint32_t EVENTS_ERROR; /*!< NFC error reported. The ERRORSTATUS register contains details - on the source of the error. */ - __I uint32_t RESERVED3[2]; - __IO uint32_t EVENTS_RXERROR; /*!< NFC RX frame error reported. The FRAMESTATUS.RX register contains - details on the source of the error. */ - __IO uint32_t EVENTS_ENDRX; /*!< RX buffer (as defined by PACKETPTR and MAXLEN) in Data RAM full. */ - __IO uint32_t EVENTS_ENDTX; /*!< Transmission of data in RAM has ended, and EasyDMA has ended - accessing the TX buffer */ - __I uint32_t RESERVED4; - __IO uint32_t EVENTS_AUTOCOLRESSTARTED; /*!< Auto collision resolution process has started */ - __I uint32_t RESERVED5[3]; - __IO uint32_t EVENTS_COLLISION; /*!< NFC auto collision resolution error reported. */ - __IO uint32_t EVENTS_SELECTED; /*!< NFC auto collision resolution successfully completed */ - __IO uint32_t EVENTS_STARTED; /*!< EasyDMA is ready to receive or send frames. */ - __I uint32_t RESERVED6[43]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED7[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED8[62]; - __IO uint32_t ERRORSTATUS; /*!< NFC Error Status register */ - __I uint32_t RESERVED9; - NFCT_FRAMESTATUS_Type FRAMESTATUS; /*!< Unspecified */ - __I uint32_t NFCTAGSTATE; /*!< NfcTag state register */ - __I uint32_t RESERVED10[10]; - __I uint32_t FIELDPRESENT; /*!< Indicates the presence or not of a valid field */ - __I uint32_t RESERVED11[49]; - __IO uint32_t FRAMEDELAYMIN; /*!< Minimum frame delay */ - __IO uint32_t FRAMEDELAYMAX; /*!< Maximum frame delay */ - __IO uint32_t FRAMEDELAYMODE; /*!< Configuration register for the Frame Delay Timer */ - __IO uint32_t PACKETPTR; /*!< Packet pointer for TXD and RXD data storage in Data RAM */ - __IO uint32_t MAXLEN; /*!< Size of the RAM buffer allocated to TXD and RXD data storage - each */ - NFCT_TXD_Type TXD; /*!< Unspecified */ - NFCT_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED12[26]; - __IO uint32_t NFCID1_LAST; /*!< Last NFCID1 part (4, 7 or 10 bytes ID) */ - __IO uint32_t NFCID1_2ND_LAST; /*!< Second last NFCID1 part (7 or 10 bytes ID) */ - __IO uint32_t NFCID1_3RD_LAST; /*!< Third last NFCID1 part (10 bytes ID) */ - __IO uint32_t AUTOCOLRESCONFIG; /*!< Controls the auto collision resolution function. This setting - must be done before the NFCT peripheral is enabled. */ - __IO uint32_t SENSRES; /*!< NFC-A SENS_RES auto-response settings */ - __IO uint32_t SELRES; /*!< NFC-A SEL_RES auto-response settings */ -} NRF_NFCT_Type; - - -/* ================================================================================ */ -/* ================ GPIOTE ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO Tasks and Events (GPIOTE) - */ - -typedef struct { /*!< GPIOTE Structure */ - __O uint32_t TASKS_OUT[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is configured in CONFIG[0].POLARITY. */ - __I uint32_t RESERVED0[4]; - __O uint32_t TASKS_SET[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is to set it high. */ - __I uint32_t RESERVED1[4]; - __O uint32_t TASKS_CLR[8]; /*!< Description collection[0]: Task for writing to pin specified - in CONFIG[0].PSEL. Action on pin is to set it low. */ - __I uint32_t RESERVED2[32]; - __IO uint32_t EVENTS_IN[8]; /*!< Description collection[0]: Event generated from pin specified - in CONFIG[0].PSEL */ - __I uint32_t RESERVED3[23]; - __IO uint32_t EVENTS_PORT; /*!< Event generated from multiple input GPIO pins with SENSE mechanism - enabled */ - __I uint32_t RESERVED4[97]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED5[129]; - __IO uint32_t CONFIG[8]; /*!< Description collection[0]: Configuration for OUT[n], SET[n] - and CLR[n] tasks and IN[n] event */ -} NRF_GPIOTE_Type; - - -/* ================================================================================ */ -/* ================ SAADC ================ */ -/* ================================================================================ */ - - -/** - * @brief Analog to Digital Converter (SAADC) - */ - -typedef struct { /*!< SAADC Structure */ - __O uint32_t TASKS_START; /*!< Start the ADC and prepare the result buffer in RAM */ - __O uint32_t TASKS_SAMPLE; /*!< Take one ADC sample, if scan is enabled all channels are sampled */ - __O uint32_t TASKS_STOP; /*!< Stop the ADC and terminate any on-going conversion */ - __O uint32_t TASKS_CALIBRATEOFFSET; /*!< Starts offset auto-calibration */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_STARTED; /*!< The ADC has started */ - __IO uint32_t EVENTS_END; /*!< The ADC has filled up the Result buffer */ - __IO uint32_t EVENTS_DONE; /*!< A conversion task has been completed. Depending on the mode, - multiple conversions might be needed for a result to be transferred - to RAM. */ - __IO uint32_t EVENTS_RESULTDONE; /*!< A result is ready to get transferred to RAM. */ - __IO uint32_t EVENTS_CALIBRATEDONE; /*!< Calibration is complete */ - __IO uint32_t EVENTS_STOPPED; /*!< The ADC has stopped */ - SAADC_EVENTS_CH_Type EVENTS_CH[8]; /*!< Unspecified */ - __I uint32_t RESERVED1[106]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[61]; - __I uint32_t STATUS; /*!< Status */ - __I uint32_t RESERVED3[63]; - __IO uint32_t ENABLE; /*!< Enable or disable ADC */ - __I uint32_t RESERVED4[3]; - SAADC_CH_Type CH[8]; /*!< Unspecified */ - __I uint32_t RESERVED5[24]; - __IO uint32_t RESOLUTION; /*!< Resolution configuration */ - __IO uint32_t OVERSAMPLE; /*!< Oversampling configuration. OVERSAMPLE should not be combined - with SCAN. The RESOLUTION is applied before averaging, thus - for high OVERSAMPLE a higher RESOLUTION should be used. */ - __IO uint32_t SAMPLERATE; /*!< Controls normal or continuous sample rate */ - __I uint32_t RESERVED6[12]; - SAADC_RESULT_Type RESULT; /*!< RESULT EasyDMA channel */ -} NRF_SAADC_Type; - - -/* ================================================================================ */ -/* ================ TIMER ================ */ -/* ================================================================================ */ - - -/** - * @brief Timer/Counter 0 (TIMER) - */ - -typedef struct { /*!< TIMER Structure */ - __O uint32_t TASKS_START; /*!< Start Timer */ - __O uint32_t TASKS_STOP; /*!< Stop Timer */ - __O uint32_t TASKS_COUNT; /*!< Increment Timer (Counter mode only) */ - __O uint32_t TASKS_CLEAR; /*!< Clear time */ - __O uint32_t TASKS_SHUTDOWN; /*!< Deprecated register - Shut down timer */ - __I uint32_t RESERVED0[11]; - __O uint32_t TASKS_CAPTURE[6]; /*!< Description collection[0]: Capture Timer value to CC[0] register */ - __I uint32_t RESERVED1[58]; - __IO uint32_t EVENTS_COMPARE[6]; /*!< Description collection[0]: Compare event on CC[0] match */ - __I uint32_t RESERVED2[42]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[126]; - __IO uint32_t MODE; /*!< Timer mode selection */ - __IO uint32_t BITMODE; /*!< Configure the number of bits used by the TIMER */ - __I uint32_t RESERVED5; - __IO uint32_t PRESCALER; /*!< Timer prescaler register */ - __I uint32_t RESERVED6[11]; - __IO uint32_t CC[6]; /*!< Description collection[0]: Capture/Compare register 0 */ -} NRF_TIMER_Type; - - -/* ================================================================================ */ -/* ================ RTC ================ */ -/* ================================================================================ */ - - -/** - * @brief Real time counter 0 (RTC) - */ - -typedef struct { /*!< RTC Structure */ - __O uint32_t TASKS_START; /*!< Start RTC COUNTER */ - __O uint32_t TASKS_STOP; /*!< Stop RTC COUNTER */ - __O uint32_t TASKS_CLEAR; /*!< Clear RTC COUNTER */ - __O uint32_t TASKS_TRIGOVRFLW; /*!< Set COUNTER to 0xFFFFF0 */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_TICK; /*!< Event on COUNTER increment */ - __IO uint32_t EVENTS_OVRFLW; /*!< Event on COUNTER overflow */ - __I uint32_t RESERVED1[14]; - __IO uint32_t EVENTS_COMPARE[4]; /*!< Description collection[0]: Compare event on CC[0] match */ - __I uint32_t RESERVED2[109]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[13]; - __IO uint32_t EVTEN; /*!< Enable or disable event routing */ - __IO uint32_t EVTENSET; /*!< Enable event routing */ - __IO uint32_t EVTENCLR; /*!< Disable event routing */ - __I uint32_t RESERVED4[110]; - __I uint32_t COUNTER; /*!< Current COUNTER value */ - __IO uint32_t PRESCALER; /*!< 12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)).Must - be written when RTC is stopped */ - __I uint32_t RESERVED5[13]; - __IO uint32_t CC[4]; /*!< Description collection[0]: Compare register 0 */ -} NRF_RTC_Type; - - -/* ================================================================================ */ -/* ================ TEMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Temperature Sensor (TEMP) - */ - -typedef struct { /*!< TEMP Structure */ - __O uint32_t TASKS_START; /*!< Start temperature measurement */ - __O uint32_t TASKS_STOP; /*!< Stop temperature measurement */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_DATARDY; /*!< Temperature measurement complete, data ready */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[127]; - __I int32_t TEMP; /*!< Temperature in degC (0.25deg steps) */ - __I uint32_t RESERVED3[5]; - __IO uint32_t A0; /*!< Slope of 1st piece wise linear function */ - __IO uint32_t A1; /*!< Slope of 2nd piece wise linear function */ - __IO uint32_t A2; /*!< Slope of 3rd piece wise linear function */ - __IO uint32_t A3; /*!< Slope of 4th piece wise linear function */ - __IO uint32_t A4; /*!< Slope of 5th piece wise linear function */ - __IO uint32_t A5; /*!< Slope of 6th piece wise linear function */ - __I uint32_t RESERVED4[2]; - __IO uint32_t B0; /*!< y-intercept of 1st piece wise linear function */ - __IO uint32_t B1; /*!< y-intercept of 2nd piece wise linear function */ - __IO uint32_t B2; /*!< y-intercept of 3rd piece wise linear function */ - __IO uint32_t B3; /*!< y-intercept of 4th piece wise linear function */ - __IO uint32_t B4; /*!< y-intercept of 5th piece wise linear function */ - __IO uint32_t B5; /*!< y-intercept of 6th piece wise linear function */ - __I uint32_t RESERVED5[2]; - __IO uint32_t T0; /*!< End point of 1st piece wise linear function */ - __IO uint32_t T1; /*!< End point of 2nd piece wise linear function */ - __IO uint32_t T2; /*!< End point of 3rd piece wise linear function */ - __IO uint32_t T3; /*!< End point of 4th piece wise linear function */ - __IO uint32_t T4; /*!< End point of 5th piece wise linear function */ -} NRF_TEMP_Type; - - -/* ================================================================================ */ -/* ================ RNG ================ */ -/* ================================================================================ */ - - -/** - * @brief Random Number Generator (RNG) - */ - -typedef struct { /*!< RNG Structure */ - __O uint32_t TASKS_START; /*!< Task starting the random number generator */ - __O uint32_t TASKS_STOP; /*!< Task stopping the random number generator */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_VALRDY; /*!< Event being generated for every new random number written to - the VALUE register */ - __I uint32_t RESERVED1[63]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[126]; - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t VALUE; /*!< Output random number */ -} NRF_RNG_Type; - - -/* ================================================================================ */ -/* ================ ECB ================ */ -/* ================================================================================ */ - - -/** - * @brief AES ECB Mode Encryption (ECB) - */ - -typedef struct { /*!< ECB Structure */ - __O uint32_t TASKS_STARTECB; /*!< Start ECB block encrypt */ - __O uint32_t TASKS_STOPECB; /*!< Abort a possible executing ECB operation */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_ENDECB; /*!< ECB block encrypt complete */ - __IO uint32_t EVENTS_ERRORECB; /*!< ECB block encrypt aborted because of a STOPECB task or due to - an error */ - __I uint32_t RESERVED1[127]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[126]; - __IO uint32_t ECBDATAPTR; /*!< ECB block encrypt memory pointers */ -} NRF_ECB_Type; - - -/* ================================================================================ */ -/* ================ CCM ================ */ -/* ================================================================================ */ - - -/** - * @brief AES CCM Mode Encryption (CCM) - */ - -typedef struct { /*!< CCM Structure */ - __O uint32_t TASKS_KSGEN; /*!< Start generation of key-stream. This operation will stop by - itself when completed. */ - __O uint32_t TASKS_CRYPT; /*!< Start encryption/decryption. This operation will stop by itself - when completed. */ - __O uint32_t TASKS_STOP; /*!< Stop encryption/decryption */ - __O uint32_t TASKS_RATEOVERRIDE; /*!< Override DATARATE setting in MODE register with the contents - of the RATEOVERRIDE register for any ongoing encryption/decryption */ - __I uint32_t RESERVED0[60]; - __IO uint32_t EVENTS_ENDKSGEN; /*!< Key-stream generation complete */ - __IO uint32_t EVENTS_ENDCRYPT; /*!< Encrypt/decrypt complete */ - __IO uint32_t EVENTS_ERROR; /*!< Deprecated register - CCM error event */ - __I uint32_t RESERVED1[61]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t MICSTATUS; /*!< MIC check result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable */ - __IO uint32_t MODE; /*!< Operation mode */ - __IO uint32_t CNFPTR; /*!< Pointer to data structure holding AES key and NONCE vector */ - __IO uint32_t INPTR; /*!< Input pointer */ - __IO uint32_t OUTPTR; /*!< Output pointer */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to data area used for temporary storage */ - __IO uint32_t MAXPACKETSIZE; /*!< Length of key-stream generated when MODE.LENGTH = Extended. */ - __IO uint32_t RATEOVERRIDE; /*!< Data rate override setting. */ -} NRF_CCM_Type; - - -/* ================================================================================ */ -/* ================ AAR ================ */ -/* ================================================================================ */ - - -/** - * @brief Accelerated Address Resolver (AAR) - */ - -typedef struct { /*!< AAR Structure */ - __O uint32_t TASKS_START; /*!< Start resolving addresses based on IRKs specified in the IRK - data structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stop resolving addresses */ - __I uint32_t RESERVED1[61]; - __IO uint32_t EVENTS_END; /*!< Address resolution procedure complete */ - __IO uint32_t EVENTS_RESOLVED; /*!< Address resolved */ - __IO uint32_t EVENTS_NOTRESOLVED; /*!< Address not resolved */ - __I uint32_t RESERVED2[126]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t STATUS; /*!< Resolution status */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable AAR */ - __IO uint32_t NIRK; /*!< Number of IRKs */ - __IO uint32_t IRKPTR; /*!< Pointer to IRK data structure */ - __I uint32_t RESERVED5; - __IO uint32_t ADDRPTR; /*!< Pointer to the resolvable address */ - __IO uint32_t SCRATCHPTR; /*!< Pointer to data area used for temporary storage */ -} NRF_AAR_Type; - - -/* ================================================================================ */ -/* ================ WDT ================ */ -/* ================================================================================ */ - - -/** - * @brief Watchdog Timer (WDT) - */ - -typedef struct { /*!< WDT Structure */ - __O uint32_t TASKS_START; /*!< Start the watchdog */ - __I uint32_t RESERVED0[63]; - __IO uint32_t EVENTS_TIMEOUT; /*!< Watchdog timeout */ - __I uint32_t RESERVED1[128]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[61]; - __I uint32_t RUNSTATUS; /*!< Run status */ - __I uint32_t REQSTATUS; /*!< Request status */ - __I uint32_t RESERVED3[63]; - __IO uint32_t CRV; /*!< Counter reload value */ - __IO uint32_t RREN; /*!< Enable register for reload request registers */ - __IO uint32_t CONFIG; /*!< Configuration register */ - __I uint32_t RESERVED4[60]; - __O uint32_t RR[8]; /*!< Description collection[0]: Reload request 0 */ -} NRF_WDT_Type; - - -/* ================================================================================ */ -/* ================ QDEC ================ */ -/* ================================================================================ */ - - -/** - * @brief Quadrature Decoder (QDEC) - */ - -typedef struct { /*!< QDEC Structure */ - __O uint32_t TASKS_START; /*!< Task starting the quadrature decoder */ - __O uint32_t TASKS_STOP; /*!< Task stopping the quadrature decoder */ - __O uint32_t TASKS_READCLRACC; /*!< Read and clear ACC and ACCDBL */ - __O uint32_t TASKS_RDCLRACC; /*!< Read and clear ACC */ - __O uint32_t TASKS_RDCLRDBL; /*!< Read and clear ACCDBL */ - __I uint32_t RESERVED0[59]; - __IO uint32_t EVENTS_SAMPLERDY; /*!< Event being generated for every new sample value written to - the SAMPLE register */ - __IO uint32_t EVENTS_REPORTRDY; /*!< Non-null report ready */ - __IO uint32_t EVENTS_ACCOF; /*!< ACC or ACCDBL register overflow */ - __IO uint32_t EVENTS_DBLRDY; /*!< Double displacement(s) detected */ - __IO uint32_t EVENTS_STOPPED; /*!< QDEC has been stopped */ - __I uint32_t RESERVED1[59]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[125]; - __IO uint32_t ENABLE; /*!< Enable the quadrature decoder */ - __IO uint32_t LEDPOL; /*!< LED output pin polarity */ - __IO uint32_t SAMPLEPER; /*!< Sample period */ - __I int32_t SAMPLE; /*!< Motion sample value */ - __IO uint32_t REPORTPER; /*!< Number of samples to be taken before REPORTRDY and DBLRDY events - can be generated */ - __I int32_t ACC; /*!< Register accumulating the valid transitions */ - __I int32_t ACCREAD; /*!< Snapshot of the ACC register, updated by the READCLRACC or RDCLRACC - task */ - QDEC_PSEL_Type PSEL; /*!< Unspecified */ - __IO uint32_t DBFEN; /*!< Enable input debounce filters */ - __I uint32_t RESERVED4[5]; - __IO uint32_t LEDPRE; /*!< Time period the LED is switched ON prior to sampling */ - __I uint32_t ACCDBL; /*!< Register accumulating the number of detected double transitions */ - __I uint32_t ACCDBLREAD; /*!< Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL - task */ -} NRF_QDEC_Type; - - -/* ================================================================================ */ -/* ================ COMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Comparator (COMP) - */ - -typedef struct { /*!< COMP Structure */ - __O uint32_t TASKS_START; /*!< Start comparator */ - __O uint32_t TASKS_STOP; /*!< Stop comparator */ - __O uint32_t TASKS_SAMPLE; /*!< Sample comparator value */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_READY; /*!< COMP is ready and output is valid */ - __IO uint32_t EVENTS_DOWN; /*!< Downward crossing */ - __IO uint32_t EVENTS_UP; /*!< Upward crossing */ - __IO uint32_t EVENTS_CROSS; /*!< Downward or upward crossing */ - __I uint32_t RESERVED1[60]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t RESULT; /*!< Compare result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< COMP enable */ - __IO uint32_t PSEL; /*!< Pin select */ - __IO uint32_t REFSEL; /*!< Reference source select for single-ended mode */ - __IO uint32_t EXTREFSEL; /*!< External reference select */ - __I uint32_t RESERVED5[8]; - __IO uint32_t TH; /*!< Threshold configuration for hysteresis unit */ - __IO uint32_t MODE; /*!< Mode configuration */ - __IO uint32_t HYST; /*!< Comparator hysteresis enable */ -} NRF_COMP_Type; - - -/* ================================================================================ */ -/* ================ LPCOMP ================ */ -/* ================================================================================ */ - - -/** - * @brief Low Power Comparator (LPCOMP) - */ - -typedef struct { /*!< LPCOMP Structure */ - __O uint32_t TASKS_START; /*!< Start comparator */ - __O uint32_t TASKS_STOP; /*!< Stop comparator */ - __O uint32_t TASKS_SAMPLE; /*!< Sample comparator value */ - __I uint32_t RESERVED0[61]; - __IO uint32_t EVENTS_READY; /*!< LPCOMP is ready and output is valid */ - __IO uint32_t EVENTS_DOWN; /*!< Downward crossing */ - __IO uint32_t EVENTS_UP; /*!< Upward crossing */ - __IO uint32_t EVENTS_CROSS; /*!< Downward or upward crossing */ - __I uint32_t RESERVED1[60]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED2[64]; - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[61]; - __I uint32_t RESULT; /*!< Compare result */ - __I uint32_t RESERVED4[63]; - __IO uint32_t ENABLE; /*!< Enable LPCOMP */ - __IO uint32_t PSEL; /*!< Input pin select */ - __IO uint32_t REFSEL; /*!< Reference select */ - __IO uint32_t EXTREFSEL; /*!< External reference select */ - __I uint32_t RESERVED5[4]; - __IO uint32_t ANADETECT; /*!< Analog detect configuration */ - __I uint32_t RESERVED6[5]; - __IO uint32_t HYST; /*!< Comparator hysteresis enable */ -} NRF_LPCOMP_Type; - - -/* ================================================================================ */ -/* ================ SWI ================ */ -/* ================================================================================ */ - - -/** - * @brief Software interrupt 0 (SWI) - */ - -typedef struct { /*!< SWI Structure */ - __I uint32_t UNUSED; /*!< Unused. */ -} NRF_SWI_Type; - - -/* ================================================================================ */ -/* ================ EGU ================ */ -/* ================================================================================ */ - - -/** - * @brief Event Generator Unit 0 (EGU) - */ - -typedef struct { /*!< EGU Structure */ - __O uint32_t TASKS_TRIGGER[16]; /*!< Description collection[0]: Trigger 0 for triggering the corresponding - TRIGGERED[0] event */ - __I uint32_t RESERVED0[48]; - __IO uint32_t EVENTS_TRIGGERED[16]; /*!< Description collection[0]: Event number 0 generated by triggering - the corresponding TRIGGER[0] task */ - __I uint32_t RESERVED1[112]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ -} NRF_EGU_Type; - - -/* ================================================================================ */ -/* ================ PWM ================ */ -/* ================================================================================ */ - - -/** - * @brief Pulse Width Modulation Unit 0 (PWM) - */ - -typedef struct { /*!< PWM Structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STOP; /*!< Stops PWM pulse generation on all channels at the end of current - PWM period, and stops sequence playback */ - __O uint32_t TASKS_SEQSTART[2]; /*!< Description collection[0]: Loads the first PWM value on all - enabled channels from sequence 0, and starts playing that sequence - at the rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes - PWM generation to start it was not running. */ - __O uint32_t TASKS_NEXTSTEP; /*!< Steps by one value in the current sequence on all enabled channels - if DECODER.MODE=NextStep. Does not cause PWM generation to start - it was not running. */ - __I uint32_t RESERVED1[60]; - __IO uint32_t EVENTS_STOPPED; /*!< Response to STOP task, emitted when PWM pulses are no longer - generated */ - __IO uint32_t EVENTS_SEQSTARTED[2]; /*!< Description collection[0]: First PWM period started on sequence - 0 */ - __IO uint32_t EVENTS_SEQEND[2]; /*!< Description collection[0]: Emitted at end of every sequence - 0, when last value from RAM has been applied to wave counter */ - __IO uint32_t EVENTS_PWMPERIODEND; /*!< Emitted at the end of each PWM period */ - __IO uint32_t EVENTS_LOOPSDONE; /*!< Concatenated sequences have been played the amount of times - defined in LOOP.CNT */ - __I uint32_t RESERVED2[56]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[125]; - __IO uint32_t ENABLE; /*!< PWM module enable register */ - __IO uint32_t MODE; /*!< Selects operating mode of the wave counter */ - __IO uint32_t COUNTERTOP; /*!< Value up to which the pulse generator counter counts */ - __IO uint32_t PRESCALER; /*!< Configuration for PWM_CLK */ - __IO uint32_t DECODER; /*!< Configuration of the decoder */ - __IO uint32_t LOOP; /*!< Amount of playback of a loop */ - __I uint32_t RESERVED5[2]; - PWM_SEQ_Type SEQ[2]; /*!< Unspecified */ - PWM_PSEL_Type PSEL; /*!< Unspecified */ -} NRF_PWM_Type; - - -/* ================================================================================ */ -/* ================ PDM ================ */ -/* ================================================================================ */ - - -/** - * @brief Pulse Density Modulation (Digital Microphone) Interface (PDM) - */ - -typedef struct { /*!< PDM Structure */ - __O uint32_t TASKS_START; /*!< Starts continuous PDM transfer */ - __O uint32_t TASKS_STOP; /*!< Stops PDM transfer */ - __I uint32_t RESERVED0[62]; - __IO uint32_t EVENTS_STARTED; /*!< PDM transfer has started */ - __IO uint32_t EVENTS_STOPPED; /*!< PDM transfer has finished */ - __IO uint32_t EVENTS_END; /*!< The PDM has written the last sample specified by SAMPLE.MAXCNT - (or the last sample after a STOP task has been received) to - Data RAM */ - __I uint32_t RESERVED1[125]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< PDM module enable register */ - __IO uint32_t PDMCLKCTRL; /*!< PDM clock generator control */ - __IO uint32_t MODE; /*!< Defines the routing of the connected PDM microphones' signals */ - __I uint32_t RESERVED3[3]; - __IO uint32_t GAINL; /*!< Left output gain adjustment */ - __IO uint32_t GAINR; /*!< Right output gain adjustment */ - __IO uint32_t RATIO; /*!< Selects the ratio between PDM_CLK and output sample rate. Change - PDMCLKCTRL accordingly. */ - __I uint32_t RESERVED4[7]; - PDM_PSEL_Type PSEL; /*!< Unspecified */ - __I uint32_t RESERVED5[6]; - PDM_SAMPLE_Type SAMPLE; /*!< Unspecified */ -} NRF_PDM_Type; - - -/* ================================================================================ */ -/* ================ NVMC ================ */ -/* ================================================================================ */ - - -/** - * @brief Non Volatile Memory Controller (NVMC) - */ - -typedef struct { /*!< NVMC Structure */ - __I uint32_t RESERVED0[256]; - __I uint32_t READY; /*!< Ready flag */ - __I uint32_t RESERVED1; - __I uint32_t READYNEXT; /*!< Ready flag */ - __I uint32_t RESERVED2[62]; - __IO uint32_t CONFIG; /*!< Configuration register */ - - union { - __IO uint32_t ERASEPAGE; /*!< Register for erasing a page in code area */ - __IO uint32_t ERASEPCR1; /*!< Deprecated register - Register for erasing a page in code area. - Equivalent to ERASEPAGE. */ - }; - __IO uint32_t ERASEALL; /*!< Register for erasing all non-volatile user memory */ - __IO uint32_t ERASEPCR0; /*!< Deprecated register - Register for erasing a page in code area. - Equivalent to ERASEPAGE. */ - __IO uint32_t ERASEUICR; /*!< Register for erasing user information configuration registers */ - __I uint32_t RESERVED3[10]; - __IO uint32_t ICACHECNF; /*!< I-code cache configuration register. */ - __I uint32_t RESERVED4; - __IO uint32_t IHIT; /*!< I-code cache hit counter. */ - __IO uint32_t IMISS; /*!< I-code cache miss counter. */ -} NRF_NVMC_Type; - - -/* ================================================================================ */ -/* ================ ACL ================ */ -/* ================================================================================ */ - - -/** - * @brief Access control lists (ACL) - */ - -typedef struct { /*!< ACL Structure */ - __I uint32_t RESERVED0[512]; - ACL_ACL_Type ACL[8]; /*!< Unspecified */ -} NRF_ACL_Type; - - -/* ================================================================================ */ -/* ================ PPI ================ */ -/* ================================================================================ */ - - -/** - * @brief Programmable Peripheral Interconnect (PPI) - */ - -typedef struct { /*!< PPI Structure */ - PPI_TASKS_CHG_Type TASKS_CHG[6]; /*!< Channel group tasks */ - __I uint32_t RESERVED0[308]; - __IO uint32_t CHEN; /*!< Channel enable register */ - __IO uint32_t CHENSET; /*!< Channel enable set register */ - __IO uint32_t CHENCLR; /*!< Channel enable clear register */ - __I uint32_t RESERVED1; - PPI_CH_Type CH[20]; /*!< PPI Channel */ - __I uint32_t RESERVED2[148]; - __IO uint32_t CHG[6]; /*!< Description collection[0]: Channel group 0 */ - __I uint32_t RESERVED3[62]; - PPI_FORK_Type FORK[32]; /*!< Fork */ -} NRF_PPI_Type; - - -/* ================================================================================ */ -/* ================ MWU ================ */ -/* ================================================================================ */ - - -/** - * @brief Memory Watch Unit (MWU) - */ - -typedef struct { /*!< MWU Structure */ - __I uint32_t RESERVED0[64]; - MWU_EVENTS_REGION_Type EVENTS_REGION[4]; /*!< Unspecified */ - __I uint32_t RESERVED1[16]; - MWU_EVENTS_PREGION_Type EVENTS_PREGION[2]; /*!< Unspecified */ - __I uint32_t RESERVED2[100]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[5]; - __IO uint32_t NMIEN; /*!< Enable or disable non-maskable interrupt */ - __IO uint32_t NMIENSET; /*!< Enable non-maskable interrupt */ - __IO uint32_t NMIENCLR; /*!< Disable non-maskable interrupt */ - __I uint32_t RESERVED4[53]; - MWU_PERREGION_Type PERREGION[2]; /*!< Unspecified */ - __I uint32_t RESERVED5[64]; - __IO uint32_t REGIONEN; /*!< Enable/disable regions watch */ - __IO uint32_t REGIONENSET; /*!< Enable regions watch */ - __IO uint32_t REGIONENCLR; /*!< Disable regions watch */ - __I uint32_t RESERVED6[57]; - MWU_REGION_Type REGION[4]; /*!< Unspecified */ - __I uint32_t RESERVED7[32]; - MWU_PREGION_Type PREGION[2]; /*!< Unspecified */ -} NRF_MWU_Type; - - -/* ================================================================================ */ -/* ================ I2S ================ */ -/* ================================================================================ */ - - -/** - * @brief Inter-IC Sound (I2S) - */ - -typedef struct { /*!< I2S Structure */ - __O uint32_t TASKS_START; /*!< Starts continuous I2S transfer. Also starts MCK generator when - this is enabled. */ - __O uint32_t TASKS_STOP; /*!< Stops I2S transfer. Also stops MCK generator. Triggering this - task will cause the {event:STOPPED} event to be generated. */ - __I uint32_t RESERVED0[63]; - __IO uint32_t EVENTS_RXPTRUPD; /*!< The RXD.PTR register has been copied to internal double-buffers. - When the I2S module is started and RX is enabled, this event - will be generated for every RXTXD.MAXCNT words that are received - on the SDIN pin. */ - __IO uint32_t EVENTS_STOPPED; /*!< I2S transfer stopped. */ - __I uint32_t RESERVED1[2]; - __IO uint32_t EVENTS_TXPTRUPD; /*!< The TDX.PTR register has been copied to internal double-buffers. - When the I2S module is started and TX is enabled, this event - will be generated for every RXTXD.MAXCNT words that are sent - on the SDOUT pin. */ - __I uint32_t RESERVED2[122]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED3[125]; - __IO uint32_t ENABLE; /*!< Enable I2S module. */ - I2S_CONFIG_Type CONFIG; /*!< Unspecified */ - __I uint32_t RESERVED4[3]; - I2S_RXD_Type RXD; /*!< Unspecified */ - __I uint32_t RESERVED5; - I2S_TXD_Type TXD; /*!< Unspecified */ - __I uint32_t RESERVED6[3]; - I2S_RXTXD_Type RXTXD; /*!< Unspecified */ - __I uint32_t RESERVED7[3]; - I2S_PSEL_Type PSEL; /*!< Unspecified */ -} NRF_I2S_Type; - - -/* ================================================================================ */ -/* ================ FPU ================ */ -/* ================================================================================ */ - - -/** - * @brief FPU (FPU) - */ - -typedef struct { /*!< FPU Structure */ - __I uint32_t UNUSED; /*!< Unused. */ -} NRF_FPU_Type; - - -/* ================================================================================ */ -/* ================ USBD ================ */ -/* ================================================================================ */ - - -/** - * @brief Universal Serial Bus device (USBD) - */ - -typedef struct { /*!< USBD Structure */ - __I uint32_t RESERVED0; - __O uint32_t TASKS_STARTEPIN[8]; /*!< Description collection[0]: Captures the EPIN[0].PTR, EPIN[0].MAXCNT - and EPIN[0].CONFIG registers values, and enables endpoint IN - 0 to respond to traffic from host */ - __O uint32_t TASKS_STARTISOIN; /*!< Captures the ISOIN.PTR, ISOIN.MAXCNT and ISOIN.CONFIG registers - values, and enables sending data on iso endpoint */ - __O uint32_t TASKS_STARTEPOUT[8]; /*!< Description collection[0]: Captures the EPOUT[0].PTR, EPOUT[0].MAXCNT - and EPOUT[0].CONFIG registers values, and enables endpoint 0 - to respond to traffic from host */ - __O uint32_t TASKS_STARTISOOUT; /*!< Captures the ISOOUT.PTR, ISOOUT.MAXCNT and ISOOUT.CONFIG registers - values, and enables receiving of data on iso endpoint */ - __O uint32_t TASKS_EP0RCVOUT; /*!< Allows OUT data stage on control endpoint 0 */ - __O uint32_t TASKS_EP0STATUS; /*!< Allows status stage on control endpoint 0 */ - __O uint32_t TASKS_EP0STALL; /*!< STALLs data and status stage on control endpoint 0 */ - __O uint32_t TASKS_DPDMDRIVE; /*!< Forces D+ and D-lines to the state defined in the DPDMVALUE - register */ - __O uint32_t TASKS_DPDMNODRIVE; /*!< Stops forcing D+ and D- lines to any state (USB engine takes - control) */ - __I uint32_t RESERVED1[40]; - __IO uint32_t EVENTS_USBRESET; /*!< Signals that a USB reset condition has been detected on the - USB lines */ - __IO uint32_t EVENTS_STARTED; /*!< Confirms that the EPIN[n].PTR, EPIN[n].MAXCNT, EPIN[n].CONFIG, - or EPOUT[n].PTR, EPOUT[n].MAXCNT and EPOUT[n].CONFIG registers - have been captured on all endpoints reported in the EPSTATUS - register */ - __IO uint32_t EVENTS_ENDEPIN[8]; /*!< Description collection[0]: The whole EPIN[0] buffer has been - consumed. The RAM buffer can be accessed safely by software. */ - __IO uint32_t EVENTS_EP0DATADONE; /*!< An acknowledged data transfer has taken place on the control - endpoint */ - __IO uint32_t EVENTS_ENDISOIN; /*!< The whole ISOIN buffer has been consumed. The RAM buffer can - be accessed safely by software. */ - __IO uint32_t EVENTS_ENDEPOUT[8]; /*!< Description collection[0]: The whole EPOUT[0] buffer has been - consumed. The RAM buffer can be accessed safely by software. */ - __IO uint32_t EVENTS_ENDISOOUT; /*!< The whole ISOOUT buffer has been consumed. The RAM buffer can - be accessed safely by software. */ - __IO uint32_t EVENTS_SOF; /*!< Signals that a SOF (start of frame) condition has been detected - on the USB lines */ - __IO uint32_t EVENTS_USBEVENT; /*!< An event or an error not covered by specific events has occurred, - check EVENTCAUSE register to find the cause */ - __IO uint32_t EVENTS_EP0SETUP; /*!< A valid SETUP token has been received (and acknowledged) on - the control endpoint */ - __IO uint32_t EVENTS_EPDATA; /*!< A data transfer has occurred on a data endpoint, indicated by - the EPDATASTATUS register */ - __IO uint32_t EVENTS_ACCESSFAULT; /*!< Access to an unavailable USB register has been attempted (software - or EasyDMA). This event can get fired even when USBD is not - ENABLEd. */ - __I uint32_t RESERVED2[38]; - __IO uint32_t SHORTS; /*!< Shortcut register */ - __I uint32_t RESERVED3[63]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED4[61]; - __IO uint32_t EVENTCAUSE; /*!< Details on event that caused the USBEVENT event */ - __I uint32_t BUSSTATE; /*!< Provides the logic state of the D+ and D- lines */ - __I uint32_t RESERVED5[6]; - USBD_HALTED_Type HALTED; /*!< Unspecified */ - __I uint32_t RESERVED6; - __IO uint32_t EPSTATUS; /*!< Provides information on which endpoint's EasyDMA registers have - been captured */ - __IO uint32_t EPDATASTATUS; /*!< Provides information on which endpoint(s) an acknowledged data - transfer has occurred (EPDATA event) */ - __I uint32_t USBADDR; /*!< Device USB address */ - __I uint32_t RESERVED7[3]; - __I uint32_t BMREQUESTTYPE; /*!< SETUP data, byte 0, bmRequestType */ - __I uint32_t BREQUEST; /*!< SETUP data, byte 1, bRequest */ - __I uint32_t WVALUEL; /*!< SETUP data, byte 2, LSB of wValue */ - __I uint32_t WVALUEH; /*!< SETUP data, byte 3, MSB of wValue */ - __I uint32_t WINDEXL; /*!< SETUP data, byte 4, LSB of wIndex */ - __I uint32_t WINDEXH; /*!< SETUP data, byte 5, MSB of wIndex */ - __I uint32_t WLENGTHL; /*!< SETUP data, byte 6, LSB of wLength */ - __I uint32_t WLENGTHH; /*!< SETUP data, byte 7, MSB of wLength */ - USBD_SIZE_Type SIZE; /*!< Unspecified */ - __I uint32_t RESERVED8[15]; - __IO uint32_t ENABLE; /*!< Enable USB */ - __IO uint32_t USBPULLUP; /*!< Control of the USB pull-up */ - __IO uint32_t DPDMVALUE; /*!< State at which the DPDMDRIVE task will force D+ and D-. The - DPDMNODRIVE task reverts the control of the lines to MAC IP - (no forcing). */ - __IO uint32_t DTOGGLE; /*!< Data toggle control and status. */ - __IO uint32_t EPINEN; /*!< Endpoint IN enable */ - __IO uint32_t EPOUTEN; /*!< Endpoint OUT enable */ - __O uint32_t EPSTALL; /*!< STALL endpoints */ - __IO uint32_t ISOSPLIT; /*!< Controls the split of ISO buffers */ - __I uint32_t FRAMECNTR; /*!< Returns the current value of the start of frame counter */ - __I uint32_t RESERVED9[2]; - __IO uint32_t LOWPOWER; /*!< Controls USBD peripheral low-power mode during USB suspend */ - __IO uint32_t ISOINCONFIG; /*!< Controls the response of the ISO IN endpoint to an IN token - when no data is ready to be sent */ - __I uint32_t RESERVED10[51]; - USBD_EPIN_Type EPIN[8]; /*!< Unspecified */ - USBD_ISOIN_Type ISOIN; /*!< Unspecified */ - __I uint32_t RESERVED11[21]; - USBD_EPOUT_Type EPOUT[8]; /*!< Unspecified */ - USBD_ISOOUT_Type ISOOUT; /*!< Unspecified */ -} NRF_USBD_Type; - - -/* ================================================================================ */ -/* ================ QSPI ================ */ -/* ================================================================================ */ - - -/** - * @brief External flash interface (QSPI) - */ - -typedef struct { /*!< QSPI Structure */ - __O uint32_t TASKS_ACTIVATE; /*!< Activate QSPI interface */ - __O uint32_t TASKS_READSTART; /*!< Start transfer from external flash memory to internal RAM */ - __O uint32_t TASKS_WRITESTART; /*!< Start transfer from internal RAM to external flash memory */ - __O uint32_t TASKS_ERASESTART; /*!< Start external flash memory erase operation */ - __O uint32_t TASKS_DEACTIVATE; /*!< Deactivate QSPI interface */ - __I uint32_t RESERVED0[59]; - __IO uint32_t EVENTS_READY; /*!< QSPI peripheral is ready. This event will be generated as a - response to any QSPI task. */ - __I uint32_t RESERVED1[127]; - __IO uint32_t INTEN; /*!< Enable or disable interrupt */ - __IO uint32_t INTENSET; /*!< Enable interrupt */ - __IO uint32_t INTENCLR; /*!< Disable interrupt */ - __I uint32_t RESERVED2[125]; - __IO uint32_t ENABLE; /*!< Enable QSPI peripheral and acquire the pins selected in PSELn - registers */ - QSPI_READ_Type READ; /*!< Unspecified */ - QSPI_WRITE_Type WRITE; /*!< Unspecified */ - QSPI_ERASE_Type ERASE; /*!< Unspecified */ - QSPI_PSEL_Type PSEL; /*!< Unspecified */ - __IO uint32_t XIPOFFSET; /*!< Address offset into the external memory for Execute in Place - operation. */ - __IO uint32_t IFCONFIG0; /*!< Interface configuration. */ - __I uint32_t RESERVED3[46]; - __IO uint32_t IFCONFIG1; /*!< Interface configuration. */ - __I uint32_t STATUS; /*!< Status register. */ - __I uint32_t RESERVED4[3]; - __IO uint32_t DPMDUR; /*!< Set the duration required to enter/exit deep power-down mode - (DPM). */ - __I uint32_t RESERVED5[3]; - __IO uint32_t ADDRCONF; /*!< Extended address configuration. */ - __I uint32_t RESERVED6[3]; - __IO uint32_t CINSTRCONF; /*!< Custom instruction configuration register. */ - __IO uint32_t CINSTRDAT0; /*!< Custom instruction data register 0. */ - __IO uint32_t CINSTRDAT1; /*!< Custom instruction data register 1. */ - __IO uint32_t IFTIMING; /*!< SPI interface timing. */ -} NRF_QSPI_Type; - - -/* ================================================================================ */ -/* ================ GPIO ================ */ -/* ================================================================================ */ - - -/** - * @brief GPIO Port 1 (GPIO) - */ - -typedef struct { /*!< GPIO Structure */ - __I uint32_t RESERVED0[321]; - __IO uint32_t OUT; /*!< Write GPIO port */ - __IO uint32_t OUTSET; /*!< Set individual bits in GPIO port */ - __IO uint32_t OUTCLR; /*!< Clear individual bits in GPIO port */ - __I uint32_t IN; /*!< Read GPIO port */ - __IO uint32_t DIR; /*!< Direction of GPIO pins */ - __IO uint32_t DIRSET; /*!< DIR set register */ - __IO uint32_t DIRCLR; /*!< DIR clear register */ - __IO uint32_t LATCH; /*!< Latch register indicating what GPIO pins that have met the criteria - set in the PIN_CNF[n].SENSE registers */ - __IO uint32_t DETECTMODE; /*!< Select between default DETECT signal behaviour and LDETECT mode */ - __I uint32_t RESERVED1[118]; - __IO uint32_t PIN_CNF[32]; /*!< Description collection[0]: Configuration of GPIO pins */ -} NRF_GPIO_Type; - - -/* ================================================================================ */ -/* ================ CRYPTOCELL ================ */ -/* ================================================================================ */ - - -/** - * @brief ARM TrustZone CryptoCell register interface (CRYPTOCELL) - */ - -typedef struct { /*!< CRYPTOCELL Structure */ - __I uint32_t RESERVED0[320]; - __IO uint32_t ENABLE; /*!< Control power and clock for CRYPTOCELL subsystem */ -} NRF_CRYPTOCELL_Type; - - -/* -------------------- End of section using anonymous unions ------------------- */ -#if defined(__CC_ARM) - #pragma pop -#elif defined(__ICCARM__) - /* leave anonymous unions enabled */ -#elif defined(__GNUC__) - /* anonymous unions are enabled by default */ -#elif defined(__TMS470__) - /* anonymous unions are enabled by default */ -#elif defined(__TASKING__) - #pragma warning restore -#else - #warning Not supported compiler type -#endif - - - - -/* ================================================================================ */ -/* ================ Peripheral memory map ================ */ -/* ================================================================================ */ - -#define NRF_FICR_BASE 0x10000000UL -#define NRF_UICR_BASE 0x10001000UL -#define NRF_POWER_BASE 0x40000000UL -#define NRF_CLOCK_BASE 0x40000000UL -#define NRF_RADIO_BASE 0x40001000UL -#define NRF_UARTE0_BASE 0x40002000UL -#define NRF_UART0_BASE 0x40002000UL -#define NRF_SPIM0_BASE 0x40003000UL -#define NRF_SPIS0_BASE 0x40003000UL -#define NRF_TWIM0_BASE 0x40003000UL -#define NRF_TWIS0_BASE 0x40003000UL -#define NRF_SPI0_BASE 0x40003000UL -#define NRF_TWI0_BASE 0x40003000UL -#define NRF_SPIM1_BASE 0x40004000UL -#define NRF_SPIS1_BASE 0x40004000UL -#define NRF_TWIM1_BASE 0x40004000UL -#define NRF_TWIS1_BASE 0x40004000UL -#define NRF_SPI1_BASE 0x40004000UL -#define NRF_TWI1_BASE 0x40004000UL -#define NRF_NFCT_BASE 0x40005000UL -#define NRF_GPIOTE_BASE 0x40006000UL -#define NRF_SAADC_BASE 0x40007000UL -#define NRF_TIMER0_BASE 0x40008000UL -#define NRF_TIMER1_BASE 0x40009000UL -#define NRF_TIMER2_BASE 0x4000A000UL -#define NRF_RTC0_BASE 0x4000B000UL -#define NRF_TEMP_BASE 0x4000C000UL -#define NRF_RNG_BASE 0x4000D000UL -#define NRF_ECB_BASE 0x4000E000UL -#define NRF_CCM_BASE 0x4000F000UL -#define NRF_AAR_BASE 0x4000F000UL -#define NRF_WDT_BASE 0x40010000UL -#define NRF_RTC1_BASE 0x40011000UL -#define NRF_QDEC_BASE 0x40012000UL -#define NRF_COMP_BASE 0x40013000UL -#define NRF_LPCOMP_BASE 0x40013000UL -#define NRF_SWI0_BASE 0x40014000UL -#define NRF_EGU0_BASE 0x40014000UL -#define NRF_SWI1_BASE 0x40015000UL -#define NRF_EGU1_BASE 0x40015000UL -#define NRF_SWI2_BASE 0x40016000UL -#define NRF_EGU2_BASE 0x40016000UL -#define NRF_SWI3_BASE 0x40017000UL -#define NRF_EGU3_BASE 0x40017000UL -#define NRF_SWI4_BASE 0x40018000UL -#define NRF_EGU4_BASE 0x40018000UL -#define NRF_SWI5_BASE 0x40019000UL -#define NRF_EGU5_BASE 0x40019000UL -#define NRF_TIMER3_BASE 0x4001A000UL -#define NRF_TIMER4_BASE 0x4001B000UL -#define NRF_PWM0_BASE 0x4001C000UL -#define NRF_PDM_BASE 0x4001D000UL -#define NRF_NVMC_BASE 0x4001E000UL -#define NRF_ACL_BASE 0x4001E000UL -#define NRF_PPI_BASE 0x4001F000UL -#define NRF_MWU_BASE 0x40020000UL -#define NRF_PWM1_BASE 0x40021000UL -#define NRF_PWM2_BASE 0x40022000UL -#define NRF_SPIM2_BASE 0x40023000UL -#define NRF_SPIS2_BASE 0x40023000UL -#define NRF_SPI2_BASE 0x40023000UL -#define NRF_RTC2_BASE 0x40024000UL -#define NRF_I2S_BASE 0x40025000UL -#define NRF_FPU_BASE 0x40026000UL -#define NRF_USBD_BASE 0x40027000UL -#define NRF_UARTE1_BASE 0x40028000UL -#define NRF_QSPI_BASE 0x40029000UL -#define NRF_PWM3_BASE 0x4002D000UL -#define NRF_SPIM3_BASE 0x4002F000UL -#define NRF_P0_BASE 0x50000000UL -#define NRF_P1_BASE 0x50000300UL -#define NRF_CRYPTOCELL_BASE 0x5002A000UL - - -/* ================================================================================ */ -/* ================ Peripheral declaration ================ */ -/* ================================================================================ */ - -#define NRF_FICR ((NRF_FICR_Type *) NRF_FICR_BASE) -#define NRF_UICR ((NRF_UICR_Type *) NRF_UICR_BASE) -#define NRF_POWER ((NRF_POWER_Type *) NRF_POWER_BASE) -#define NRF_CLOCK ((NRF_CLOCK_Type *) NRF_CLOCK_BASE) -#define NRF_RADIO ((NRF_RADIO_Type *) NRF_RADIO_BASE) -#define NRF_UARTE0 ((NRF_UARTE_Type *) NRF_UARTE0_BASE) -#define NRF_UART0 ((NRF_UART_Type *) NRF_UART0_BASE) -#define NRF_SPIM0 ((NRF_SPIM_Type *) NRF_SPIM0_BASE) -#define NRF_SPIS0 ((NRF_SPIS_Type *) NRF_SPIS0_BASE) -#define NRF_TWIM0 ((NRF_TWIM_Type *) NRF_TWIM0_BASE) -#define NRF_TWIS0 ((NRF_TWIS_Type *) NRF_TWIS0_BASE) -#define NRF_SPI0 ((NRF_SPI_Type *) NRF_SPI0_BASE) -#define NRF_TWI0 ((NRF_TWI_Type *) NRF_TWI0_BASE) -#define NRF_SPIM1 ((NRF_SPIM_Type *) NRF_SPIM1_BASE) -#define NRF_SPIS1 ((NRF_SPIS_Type *) NRF_SPIS1_BASE) -#define NRF_TWIM1 ((NRF_TWIM_Type *) NRF_TWIM1_BASE) -#define NRF_TWIS1 ((NRF_TWIS_Type *) NRF_TWIS1_BASE) -#define NRF_SPI1 ((NRF_SPI_Type *) NRF_SPI1_BASE) -#define NRF_TWI1 ((NRF_TWI_Type *) NRF_TWI1_BASE) -#define NRF_NFCT ((NRF_NFCT_Type *) NRF_NFCT_BASE) -#define NRF_GPIOTE ((NRF_GPIOTE_Type *) NRF_GPIOTE_BASE) -#define NRF_SAADC ((NRF_SAADC_Type *) NRF_SAADC_BASE) -#define NRF_TIMER0 ((NRF_TIMER_Type *) NRF_TIMER0_BASE) -#define NRF_TIMER1 ((NRF_TIMER_Type *) NRF_TIMER1_BASE) -#define NRF_TIMER2 ((NRF_TIMER_Type *) NRF_TIMER2_BASE) -#define NRF_RTC0 ((NRF_RTC_Type *) NRF_RTC0_BASE) -#define NRF_TEMP ((NRF_TEMP_Type *) NRF_TEMP_BASE) -#define NRF_RNG ((NRF_RNG_Type *) NRF_RNG_BASE) -#define NRF_ECB ((NRF_ECB_Type *) NRF_ECB_BASE) -#define NRF_CCM ((NRF_CCM_Type *) NRF_CCM_BASE) -#define NRF_AAR ((NRF_AAR_Type *) NRF_AAR_BASE) -#define NRF_WDT ((NRF_WDT_Type *) NRF_WDT_BASE) -#define NRF_RTC1 ((NRF_RTC_Type *) NRF_RTC1_BASE) -#define NRF_QDEC ((NRF_QDEC_Type *) NRF_QDEC_BASE) -#define NRF_COMP ((NRF_COMP_Type *) NRF_COMP_BASE) -#define NRF_LPCOMP ((NRF_LPCOMP_Type *) NRF_LPCOMP_BASE) -#define NRF_SWI0 ((NRF_SWI_Type *) NRF_SWI0_BASE) -#define NRF_EGU0 ((NRF_EGU_Type *) NRF_EGU0_BASE) -#define NRF_SWI1 ((NRF_SWI_Type *) NRF_SWI1_BASE) -#define NRF_EGU1 ((NRF_EGU_Type *) NRF_EGU1_BASE) -#define NRF_SWI2 ((NRF_SWI_Type *) NRF_SWI2_BASE) -#define NRF_EGU2 ((NRF_EGU_Type *) NRF_EGU2_BASE) -#define NRF_SWI3 ((NRF_SWI_Type *) NRF_SWI3_BASE) -#define NRF_EGU3 ((NRF_EGU_Type *) NRF_EGU3_BASE) -#define NRF_SWI4 ((NRF_SWI_Type *) NRF_SWI4_BASE) -#define NRF_EGU4 ((NRF_EGU_Type *) NRF_EGU4_BASE) -#define NRF_SWI5 ((NRF_SWI_Type *) NRF_SWI5_BASE) -#define NRF_EGU5 ((NRF_EGU_Type *) NRF_EGU5_BASE) -#define NRF_TIMER3 ((NRF_TIMER_Type *) NRF_TIMER3_BASE) -#define NRF_TIMER4 ((NRF_TIMER_Type *) NRF_TIMER4_BASE) -#define NRF_PWM0 ((NRF_PWM_Type *) NRF_PWM0_BASE) -#define NRF_PDM ((NRF_PDM_Type *) NRF_PDM_BASE) -#define NRF_NVMC ((NRF_NVMC_Type *) NRF_NVMC_BASE) -#define NRF_ACL ((NRF_ACL_Type *) NRF_ACL_BASE) -#define NRF_PPI ((NRF_PPI_Type *) NRF_PPI_BASE) -#define NRF_MWU ((NRF_MWU_Type *) NRF_MWU_BASE) -#define NRF_PWM1 ((NRF_PWM_Type *) NRF_PWM1_BASE) -#define NRF_PWM2 ((NRF_PWM_Type *) NRF_PWM2_BASE) -#define NRF_SPIM2 ((NRF_SPIM_Type *) NRF_SPIM2_BASE) -#define NRF_SPIS2 ((NRF_SPIS_Type *) NRF_SPIS2_BASE) -#define NRF_SPI2 ((NRF_SPI_Type *) NRF_SPI2_BASE) -#define NRF_RTC2 ((NRF_RTC_Type *) NRF_RTC2_BASE) -#define NRF_I2S ((NRF_I2S_Type *) NRF_I2S_BASE) -#define NRF_FPU ((NRF_FPU_Type *) NRF_FPU_BASE) -#define NRF_USBD ((NRF_USBD_Type *) NRF_USBD_BASE) -#define NRF_UARTE1 ((NRF_UARTE_Type *) NRF_UARTE1_BASE) -#define NRF_QSPI ((NRF_QSPI_Type *) NRF_QSPI_BASE) -#define NRF_PWM3 ((NRF_PWM_Type *) NRF_PWM3_BASE) -#define NRF_SPIM3 ((NRF_SPIM_Type *) NRF_SPIM3_BASE) -#define NRF_P0 ((NRF_GPIO_Type *) NRF_P0_BASE) -#define NRF_P1 ((NRF_GPIO_Type *) NRF_P1_BASE) -#define NRF_CRYPTOCELL ((NRF_CRYPTOCELL_Type *) NRF_CRYPTOCELL_BASE) - - -/** @} */ /* End of group Device_Peripheral_Registers */ -/** @} */ /* End of group nrf52840 */ -/** @} */ /* End of group Nordic Semiconductor */ - -#ifdef __cplusplus -} -#endif - - -#endif /* nrf52840_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_bitfields.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_bitfields.h deleted file mode 100644 index c259ad0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_bitfields.h +++ /dev/null @@ -1,14790 +0,0 @@ -/* - -Copyright (c) 2010 - 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 __NRF52840_BITS_H -#define __NRF52840_BITS_H - -/*lint ++flb "Enter library region" */ - -/* Peripheral: AAR */ -/* Description: Accelerated Address Resolver */ - -/* Register: AAR_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for NOTRESOLVED event */ -#define AAR_INTENSET_NOTRESOLVED_Pos (2UL) /*!< Position of NOTRESOLVED field. */ -#define AAR_INTENSET_NOTRESOLVED_Msk (0x1UL << AAR_INTENSET_NOTRESOLVED_Pos) /*!< Bit mask of NOTRESOLVED field. */ -#define AAR_INTENSET_NOTRESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENSET_NOTRESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENSET_NOTRESOLVED_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for RESOLVED event */ -#define AAR_INTENSET_RESOLVED_Pos (1UL) /*!< Position of RESOLVED field. */ -#define AAR_INTENSET_RESOLVED_Msk (0x1UL << AAR_INTENSET_RESOLVED_Pos) /*!< Bit mask of RESOLVED field. */ -#define AAR_INTENSET_RESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENSET_RESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENSET_RESOLVED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for END event */ -#define AAR_INTENSET_END_Pos (0UL) /*!< Position of END field. */ -#define AAR_INTENSET_END_Msk (0x1UL << AAR_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define AAR_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Register: AAR_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for NOTRESOLVED event */ -#define AAR_INTENCLR_NOTRESOLVED_Pos (2UL) /*!< Position of NOTRESOLVED field. */ -#define AAR_INTENCLR_NOTRESOLVED_Msk (0x1UL << AAR_INTENCLR_NOTRESOLVED_Pos) /*!< Bit mask of NOTRESOLVED field. */ -#define AAR_INTENCLR_NOTRESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENCLR_NOTRESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENCLR_NOTRESOLVED_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for RESOLVED event */ -#define AAR_INTENCLR_RESOLVED_Pos (1UL) /*!< Position of RESOLVED field. */ -#define AAR_INTENCLR_RESOLVED_Msk (0x1UL << AAR_INTENCLR_RESOLVED_Pos) /*!< Bit mask of RESOLVED field. */ -#define AAR_INTENCLR_RESOLVED_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENCLR_RESOLVED_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENCLR_RESOLVED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for END event */ -#define AAR_INTENCLR_END_Pos (0UL) /*!< Position of END field. */ -#define AAR_INTENCLR_END_Msk (0x1UL << AAR_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define AAR_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define AAR_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define AAR_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Register: AAR_STATUS */ -/* Description: Resolution status */ - -/* Bits 3..0 : The IRK that was used last time an address was resolved */ -#define AAR_STATUS_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define AAR_STATUS_STATUS_Msk (0xFUL << AAR_STATUS_STATUS_Pos) /*!< Bit mask of STATUS field. */ - -/* Register: AAR_ENABLE */ -/* Description: Enable AAR */ - -/* Bits 1..0 : Enable or disable AAR */ -#define AAR_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define AAR_ENABLE_ENABLE_Msk (0x3UL << AAR_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define AAR_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define AAR_ENABLE_ENABLE_Enabled (3UL) /*!< Enable */ - -/* Register: AAR_NIRK */ -/* Description: Number of IRKs */ - -/* Bits 4..0 : Number of Identity root keys available in the IRK data structure */ -#define AAR_NIRK_NIRK_Pos (0UL) /*!< Position of NIRK field. */ -#define AAR_NIRK_NIRK_Msk (0x1FUL << AAR_NIRK_NIRK_Pos) /*!< Bit mask of NIRK field. */ - -/* Register: AAR_IRKPTR */ -/* Description: Pointer to IRK data structure */ - -/* Bits 31..0 : Pointer to the IRK data structure */ -#define AAR_IRKPTR_IRKPTR_Pos (0UL) /*!< Position of IRKPTR field. */ -#define AAR_IRKPTR_IRKPTR_Msk (0xFFFFFFFFUL << AAR_IRKPTR_IRKPTR_Pos) /*!< Bit mask of IRKPTR field. */ - -/* Register: AAR_ADDRPTR */ -/* Description: Pointer to the resolvable address */ - -/* Bits 31..0 : Pointer to the resolvable address (6-bytes) */ -#define AAR_ADDRPTR_ADDRPTR_Pos (0UL) /*!< Position of ADDRPTR field. */ -#define AAR_ADDRPTR_ADDRPTR_Msk (0xFFFFFFFFUL << AAR_ADDRPTR_ADDRPTR_Pos) /*!< Bit mask of ADDRPTR field. */ - -/* Register: AAR_SCRATCHPTR */ -/* Description: Pointer to data area used for temporary storage */ - -/* Bits 31..0 : Pointer to a scratch data area used for temporary storage during resolution.A space of minimum 3 bytes must be reserved. */ -#define AAR_SCRATCHPTR_SCRATCHPTR_Pos (0UL) /*!< Position of SCRATCHPTR field. */ -#define AAR_SCRATCHPTR_SCRATCHPTR_Msk (0xFFFFFFFFUL << AAR_SCRATCHPTR_SCRATCHPTR_Pos) /*!< Bit mask of SCRATCHPTR field. */ - - -/* Peripheral: ACL */ -/* Description: Access control lists */ - -/* Register: ACL_ACL_ADDR */ -/* Description: Description cluster[0]: Configure the word-aligned start address of region 0 to protect */ - -/* Bits 31..0 : Valid word-aligned start address of region 0 to protect. Address must point to a flash page boundary. */ -#define ACL_ACL_ADDR_ADDR_Pos (0UL) /*!< Position of ADDR field. */ -#define ACL_ACL_ADDR_ADDR_Msk (0xFFFFFFFFUL << ACL_ACL_ADDR_ADDR_Pos) /*!< Bit mask of ADDR field. */ - -/* Register: ACL_ACL_SIZE */ -/* Description: Description cluster[0]: Size of region to protect counting from address ACL[0].ADDR. Write '0' as no effect. */ - -/* Bits 31..0 : Size of flash region 0 in bytes. Must be a multiple of the flash page size. */ -#define ACL_ACL_SIZE_SIZE_Pos (0UL) /*!< Position of SIZE field. */ -#define ACL_ACL_SIZE_SIZE_Msk (0xFFFFFFFFUL << ACL_ACL_SIZE_SIZE_Pos) /*!< Bit mask of SIZE field. */ - -/* Register: ACL_ACL_PERM */ -/* Description: Description cluster[0]: Access permissions for region 0 as defined by start address ACL[0].ADDR and size ACL[0].SIZE */ - -/* Bit 2 : Configure read permissions for region 0. Write '0' has no effect. */ -#define ACL_ACL_PERM_READ_Pos (2UL) /*!< Position of READ field. */ -#define ACL_ACL_PERM_READ_Msk (0x1UL << ACL_ACL_PERM_READ_Pos) /*!< Bit mask of READ field. */ -#define ACL_ACL_PERM_READ_Enable (0UL) /*!< Allow read instructions to region 0 */ -#define ACL_ACL_PERM_READ_Disable (1UL) /*!< Block read instructions to region 0 */ - -/* Bit 1 : Configure write and erase permissions for region 0. Write '0' has no effect. */ -#define ACL_ACL_PERM_WRITE_Pos (1UL) /*!< Position of WRITE field. */ -#define ACL_ACL_PERM_WRITE_Msk (0x1UL << ACL_ACL_PERM_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define ACL_ACL_PERM_WRITE_Enable (0UL) /*!< Allow write and erase instructions to region 0 */ -#define ACL_ACL_PERM_WRITE_Disable (1UL) /*!< Block write and erase instructions to region 0 */ - - -/* Peripheral: CCM */ -/* Description: AES CCM Mode Encryption */ - -/* Register: CCM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 0 : Shortcut between ENDKSGEN event and CRYPT task */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Pos (0UL) /*!< Position of ENDKSGEN_CRYPT field. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Msk (0x1UL << CCM_SHORTS_ENDKSGEN_CRYPT_Pos) /*!< Bit mask of ENDKSGEN_CRYPT field. */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Disabled (0UL) /*!< Disable shortcut */ -#define CCM_SHORTS_ENDKSGEN_CRYPT_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: CCM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for ERROR event */ -#define CCM_INTENSET_ERROR_Pos (2UL) /*!< Position of ERROR field. */ -#define CCM_INTENSET_ERROR_Msk (0x1UL << CCM_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define CCM_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for ENDCRYPT event */ -#define CCM_INTENSET_ENDCRYPT_Pos (1UL) /*!< Position of ENDCRYPT field. */ -#define CCM_INTENSET_ENDCRYPT_Msk (0x1UL << CCM_INTENSET_ENDCRYPT_Pos) /*!< Bit mask of ENDCRYPT field. */ -#define CCM_INTENSET_ENDCRYPT_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENSET_ENDCRYPT_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENSET_ENDCRYPT_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for ENDKSGEN event */ -#define CCM_INTENSET_ENDKSGEN_Pos (0UL) /*!< Position of ENDKSGEN field. */ -#define CCM_INTENSET_ENDKSGEN_Msk (0x1UL << CCM_INTENSET_ENDKSGEN_Pos) /*!< Bit mask of ENDKSGEN field. */ -#define CCM_INTENSET_ENDKSGEN_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENSET_ENDKSGEN_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENSET_ENDKSGEN_Set (1UL) /*!< Enable */ - -/* Register: CCM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for ERROR event */ -#define CCM_INTENCLR_ERROR_Pos (2UL) /*!< Position of ERROR field. */ -#define CCM_INTENCLR_ERROR_Msk (0x1UL << CCM_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define CCM_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for ENDCRYPT event */ -#define CCM_INTENCLR_ENDCRYPT_Pos (1UL) /*!< Position of ENDCRYPT field. */ -#define CCM_INTENCLR_ENDCRYPT_Msk (0x1UL << CCM_INTENCLR_ENDCRYPT_Pos) /*!< Bit mask of ENDCRYPT field. */ -#define CCM_INTENCLR_ENDCRYPT_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENCLR_ENDCRYPT_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENCLR_ENDCRYPT_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for ENDKSGEN event */ -#define CCM_INTENCLR_ENDKSGEN_Pos (0UL) /*!< Position of ENDKSGEN field. */ -#define CCM_INTENCLR_ENDKSGEN_Msk (0x1UL << CCM_INTENCLR_ENDKSGEN_Pos) /*!< Bit mask of ENDKSGEN field. */ -#define CCM_INTENCLR_ENDKSGEN_Disabled (0UL) /*!< Read: Disabled */ -#define CCM_INTENCLR_ENDKSGEN_Enabled (1UL) /*!< Read: Enabled */ -#define CCM_INTENCLR_ENDKSGEN_Clear (1UL) /*!< Disable */ - -/* Register: CCM_MICSTATUS */ -/* Description: MIC check result */ - -/* Bit 0 : The result of the MIC check performed during the previous decryption operation */ -#define CCM_MICSTATUS_MICSTATUS_Pos (0UL) /*!< Position of MICSTATUS field. */ -#define CCM_MICSTATUS_MICSTATUS_Msk (0x1UL << CCM_MICSTATUS_MICSTATUS_Pos) /*!< Bit mask of MICSTATUS field. */ -#define CCM_MICSTATUS_MICSTATUS_CheckFailed (0UL) /*!< MIC check failed */ -#define CCM_MICSTATUS_MICSTATUS_CheckPassed (1UL) /*!< MIC check passed */ - -/* Register: CCM_ENABLE */ -/* Description: Enable */ - -/* Bits 1..0 : Enable or disable CCM */ -#define CCM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define CCM_ENABLE_ENABLE_Msk (0x3UL << CCM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define CCM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define CCM_ENABLE_ENABLE_Enabled (2UL) /*!< Enable */ - -/* Register: CCM_MODE */ -/* Description: Operation mode */ - -/* Bit 24 : Packet length configuration */ -#define CCM_MODE_LENGTH_Pos (24UL) /*!< Position of LENGTH field. */ -#define CCM_MODE_LENGTH_Msk (0x1UL << CCM_MODE_LENGTH_Pos) /*!< Bit mask of LENGTH field. */ -#define CCM_MODE_LENGTH_Default (0UL) /*!< Default length. Effective length of LENGTH field in encrypted/decrypted packet is 5 bits. A key-stream for packet payloads up to 27 bytes will be generated. */ -#define CCM_MODE_LENGTH_Extended (1UL) /*!< Extended length. Effective length of LENGTH field in encrypted/decrypted packet is 8 bits. A key-stream for packet payloads up to MAXPACKETSIZE bytes will be generated. */ - -/* Bits 17..16 : Radio data rate that the CCM shall run synchronous with */ -#define CCM_MODE_DATARATE_Pos (16UL) /*!< Position of DATARATE field. */ -#define CCM_MODE_DATARATE_Msk (0x3UL << CCM_MODE_DATARATE_Pos) /*!< Bit mask of DATARATE field. */ -#define CCM_MODE_DATARATE_1Mbit (0UL) /*!< 1 Mbps */ -#define CCM_MODE_DATARATE_2Mbit (1UL) /*!< 2 Mbps */ -#define CCM_MODE_DATARATE_125Kbps (2UL) /*!< 125 Kbps */ -#define CCM_MODE_DATARATE_500Kbps (3UL) /*!< 500 Kbps */ - -/* Bit 0 : The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered. */ -#define CCM_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define CCM_MODE_MODE_Msk (0x1UL << CCM_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define CCM_MODE_MODE_Encryption (0UL) /*!< AES CCM packet encryption mode */ -#define CCM_MODE_MODE_Decryption (1UL) /*!< AES CCM packet decryption mode */ - -/* Register: CCM_CNFPTR */ -/* Description: Pointer to data structure holding AES key and NONCE vector */ - -/* Bits 31..0 : Pointer to the data structure holding the AES key and the CCM NONCE vector (see Table 1 CCM data structure overview) */ -#define CCM_CNFPTR_CNFPTR_Pos (0UL) /*!< Position of CNFPTR field. */ -#define CCM_CNFPTR_CNFPTR_Msk (0xFFFFFFFFUL << CCM_CNFPTR_CNFPTR_Pos) /*!< Bit mask of CNFPTR field. */ - -/* Register: CCM_INPTR */ -/* Description: Input pointer */ - -/* Bits 31..0 : Input pointer */ -#define CCM_INPTR_INPTR_Pos (0UL) /*!< Position of INPTR field. */ -#define CCM_INPTR_INPTR_Msk (0xFFFFFFFFUL << CCM_INPTR_INPTR_Pos) /*!< Bit mask of INPTR field. */ - -/* Register: CCM_OUTPTR */ -/* Description: Output pointer */ - -/* Bits 31..0 : Output pointer */ -#define CCM_OUTPTR_OUTPTR_Pos (0UL) /*!< Position of OUTPTR field. */ -#define CCM_OUTPTR_OUTPTR_Msk (0xFFFFFFFFUL << CCM_OUTPTR_OUTPTR_Pos) /*!< Bit mask of OUTPTR field. */ - -/* Register: CCM_SCRATCHPTR */ -/* Description: Pointer to data area used for temporary storage */ - -/* Bits 31..0 : Pointer to a scratch data area used for temporary storage during key-stream generation, MIC generation and encryption/decryption. */ -#define CCM_SCRATCHPTR_SCRATCHPTR_Pos (0UL) /*!< Position of SCRATCHPTR field. */ -#define CCM_SCRATCHPTR_SCRATCHPTR_Msk (0xFFFFFFFFUL << CCM_SCRATCHPTR_SCRATCHPTR_Pos) /*!< Bit mask of SCRATCHPTR field. */ - -/* Register: CCM_MAXPACKETSIZE */ -/* Description: Length of key-stream generated when MODE.LENGTH = Extended. */ - -/* Bits 7..0 : Length of key-stream generated when MODE.LENGTH = Extended. This value must be greater or equal to the subsequent packet payload to be encrypted/decrypted. */ -#define CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos (0UL) /*!< Position of MAXPACKETSIZE field. */ -#define CCM_MAXPACKETSIZE_MAXPACKETSIZE_Msk (0xFFUL << CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos) /*!< Bit mask of MAXPACKETSIZE field. */ - -/* Register: CCM_RATEOVERRIDE */ -/* Description: Data rate override setting. */ - -/* Bits 1..0 : Data rate override setting. */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_Pos (0UL) /*!< Position of RATEOVERRIDE field. */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_Msk (0x3UL << CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) /*!< Bit mask of RATEOVERRIDE field. */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_1Mbit (0UL) /*!< 1 Mbps */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_2Mbit (1UL) /*!< 2 Mbps */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_125Kbps (2UL) /*!< 125 Kbps */ -#define CCM_RATEOVERRIDE_RATEOVERRIDE_500Kbps (3UL) /*!< 500 Kbps */ - - -/* Peripheral: CLOCK */ -/* Description: Clock control */ - -/* Register: CLOCK_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 11 : Write '1' to Enable interrupt for CTSTOPPED event */ -#define CLOCK_INTENSET_CTSTOPPED_Pos (11UL) /*!< Position of CTSTOPPED field. */ -#define CLOCK_INTENSET_CTSTOPPED_Msk (0x1UL << CLOCK_INTENSET_CTSTOPPED_Pos) /*!< Bit mask of CTSTOPPED field. */ -#define CLOCK_INTENSET_CTSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_CTSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_CTSTOPPED_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for CTSTARTED event */ -#define CLOCK_INTENSET_CTSTARTED_Pos (10UL) /*!< Position of CTSTARTED field. */ -#define CLOCK_INTENSET_CTSTARTED_Msk (0x1UL << CLOCK_INTENSET_CTSTARTED_Pos) /*!< Bit mask of CTSTARTED field. */ -#define CLOCK_INTENSET_CTSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_CTSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_CTSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for CTTO event */ -#define CLOCK_INTENSET_CTTO_Pos (4UL) /*!< Position of CTTO field. */ -#define CLOCK_INTENSET_CTTO_Msk (0x1UL << CLOCK_INTENSET_CTTO_Pos) /*!< Bit mask of CTTO field. */ -#define CLOCK_INTENSET_CTTO_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_CTTO_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_CTTO_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for DONE event */ -#define CLOCK_INTENSET_DONE_Pos (3UL) /*!< Position of DONE field. */ -#define CLOCK_INTENSET_DONE_Msk (0x1UL << CLOCK_INTENSET_DONE_Pos) /*!< Bit mask of DONE field. */ -#define CLOCK_INTENSET_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_DONE_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for LFCLKSTARTED event */ -#define CLOCK_INTENSET_LFCLKSTARTED_Pos (1UL) /*!< Position of LFCLKSTARTED field. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Msk (0x1UL << CLOCK_INTENSET_LFCLKSTARTED_Pos) /*!< Bit mask of LFCLKSTARTED field. */ -#define CLOCK_INTENSET_LFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_LFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_LFCLKSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for HFCLKSTARTED event */ -#define CLOCK_INTENSET_HFCLKSTARTED_Pos (0UL) /*!< Position of HFCLKSTARTED field. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Msk (0x1UL << CLOCK_INTENSET_HFCLKSTARTED_Pos) /*!< Bit mask of HFCLKSTARTED field. */ -#define CLOCK_INTENSET_HFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENSET_HFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENSET_HFCLKSTARTED_Set (1UL) /*!< Enable */ - -/* Register: CLOCK_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 11 : Write '1' to Disable interrupt for CTSTOPPED event */ -#define CLOCK_INTENCLR_CTSTOPPED_Pos (11UL) /*!< Position of CTSTOPPED field. */ -#define CLOCK_INTENCLR_CTSTOPPED_Msk (0x1UL << CLOCK_INTENCLR_CTSTOPPED_Pos) /*!< Bit mask of CTSTOPPED field. */ -#define CLOCK_INTENCLR_CTSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_CTSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_CTSTOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for CTSTARTED event */ -#define CLOCK_INTENCLR_CTSTARTED_Pos (10UL) /*!< Position of CTSTARTED field. */ -#define CLOCK_INTENCLR_CTSTARTED_Msk (0x1UL << CLOCK_INTENCLR_CTSTARTED_Pos) /*!< Bit mask of CTSTARTED field. */ -#define CLOCK_INTENCLR_CTSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_CTSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_CTSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for CTTO event */ -#define CLOCK_INTENCLR_CTTO_Pos (4UL) /*!< Position of CTTO field. */ -#define CLOCK_INTENCLR_CTTO_Msk (0x1UL << CLOCK_INTENCLR_CTTO_Pos) /*!< Bit mask of CTTO field. */ -#define CLOCK_INTENCLR_CTTO_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_CTTO_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_CTTO_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for DONE event */ -#define CLOCK_INTENCLR_DONE_Pos (3UL) /*!< Position of DONE field. */ -#define CLOCK_INTENCLR_DONE_Msk (0x1UL << CLOCK_INTENCLR_DONE_Pos) /*!< Bit mask of DONE field. */ -#define CLOCK_INTENCLR_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_DONE_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for LFCLKSTARTED event */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Pos (1UL) /*!< Position of LFCLKSTARTED field. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Msk (0x1UL << CLOCK_INTENCLR_LFCLKSTARTED_Pos) /*!< Bit mask of LFCLKSTARTED field. */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_LFCLKSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for HFCLKSTARTED event */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Pos (0UL) /*!< Position of HFCLKSTARTED field. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Msk (0x1UL << CLOCK_INTENCLR_HFCLKSTARTED_Pos) /*!< Bit mask of HFCLKSTARTED field. */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define CLOCK_INTENCLR_HFCLKSTARTED_Clear (1UL) /*!< Disable */ - -/* Register: CLOCK_HFCLKRUN */ -/* Description: Status indicating that HFCLKSTART task has been triggered */ - -/* Bit 0 : HFCLKSTART task triggered or not */ -#define CLOCK_HFCLKRUN_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define CLOCK_HFCLKRUN_STATUS_Msk (0x1UL << CLOCK_HFCLKRUN_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_HFCLKRUN_STATUS_NotTriggered (0UL) /*!< Task not triggered */ -#define CLOCK_HFCLKRUN_STATUS_Triggered (1UL) /*!< Task triggered */ - -/* Register: CLOCK_HFCLKSTAT */ -/* Description: HFCLK status */ - -/* Bit 16 : HFCLK state */ -#define CLOCK_HFCLKSTAT_STATE_Pos (16UL) /*!< Position of STATE field. */ -#define CLOCK_HFCLKSTAT_STATE_Msk (0x1UL << CLOCK_HFCLKSTAT_STATE_Pos) /*!< Bit mask of STATE field. */ -#define CLOCK_HFCLKSTAT_STATE_NotRunning (0UL) /*!< HFCLK not running */ -#define CLOCK_HFCLKSTAT_STATE_Running (1UL) /*!< HFCLK running */ - -/* Bit 0 : Source of HFCLK */ -#define CLOCK_HFCLKSTAT_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_HFCLKSTAT_SRC_Msk (0x1UL << CLOCK_HFCLKSTAT_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_HFCLKSTAT_SRC_RC (0UL) /*!< 64 MHz internal oscillator (HFINT) */ -#define CLOCK_HFCLKSTAT_SRC_Xtal (1UL) /*!< 64 MHz crystal oscillator (HFXO) */ - -/* Register: CLOCK_LFCLKRUN */ -/* Description: Status indicating that LFCLKSTART task has been triggered */ - -/* Bit 0 : LFCLKSTART task triggered or not */ -#define CLOCK_LFCLKRUN_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define CLOCK_LFCLKRUN_STATUS_Msk (0x1UL << CLOCK_LFCLKRUN_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_LFCLKRUN_STATUS_NotTriggered (0UL) /*!< Task not triggered */ -#define CLOCK_LFCLKRUN_STATUS_Triggered (1UL) /*!< Task triggered */ - -/* Register: CLOCK_LFCLKSTAT */ -/* Description: LFCLK status */ - -/* Bit 16 : LFCLK state */ -#define CLOCK_LFCLKSTAT_STATE_Pos (16UL) /*!< Position of STATE field. */ -#define CLOCK_LFCLKSTAT_STATE_Msk (0x1UL << CLOCK_LFCLKSTAT_STATE_Pos) /*!< Bit mask of STATE field. */ -#define CLOCK_LFCLKSTAT_STATE_NotRunning (0UL) /*!< LFCLK not running */ -#define CLOCK_LFCLKSTAT_STATE_Running (1UL) /*!< LFCLK running */ - -/* Bits 1..0 : Source of LFCLK */ -#define CLOCK_LFCLKSTAT_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSTAT_SRC_Msk (0x3UL << CLOCK_LFCLKSTAT_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSTAT_SRC_RC (0UL) /*!< 32.768 kHz RC oscillator */ -#define CLOCK_LFCLKSTAT_SRC_Xtal (1UL) /*!< 32.768 kHz crystal oscillator */ -#define CLOCK_LFCLKSTAT_SRC_Synth (2UL) /*!< 32.768 kHz synthesized from HFCLK */ - -/* Register: CLOCK_LFCLKSRCCOPY */ -/* Description: Copy of LFCLKSRC register, set when LFCLKSTART task was triggered */ - -/* Bits 1..0 : Clock source */ -#define CLOCK_LFCLKSRCCOPY_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSRCCOPY_SRC_Msk (0x3UL << CLOCK_LFCLKSRCCOPY_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSRCCOPY_SRC_RC (0UL) /*!< 32.768 kHz RC oscillator */ -#define CLOCK_LFCLKSRCCOPY_SRC_Xtal (1UL) /*!< 32.768 kHz crystal oscillator */ -#define CLOCK_LFCLKSRCCOPY_SRC_Synth (2UL) /*!< 32.768 kHz synthesized from HFCLK */ - -/* Register: CLOCK_LFCLKSRC */ -/* Description: Clock source for the LFCLK */ - -/* Bit 17 : Enable or disable external source for LFCLK */ -#define CLOCK_LFCLKSRC_EXTERNAL_Pos (17UL) /*!< Position of EXTERNAL field. */ -#define CLOCK_LFCLKSRC_EXTERNAL_Msk (0x1UL << CLOCK_LFCLKSRC_EXTERNAL_Pos) /*!< Bit mask of EXTERNAL field. */ -#define CLOCK_LFCLKSRC_EXTERNAL_Disabled (0UL) /*!< Disable external source (use with Xtal) */ -#define CLOCK_LFCLKSRC_EXTERNAL_Enabled (1UL) /*!< Enable use of external source instead of Xtal (SRC needs to be set to Xtal) */ - -/* Bit 16 : Enable or disable bypass of LFCLK crystal oscillator with external clock source */ -#define CLOCK_LFCLKSRC_BYPASS_Pos (16UL) /*!< Position of BYPASS field. */ -#define CLOCK_LFCLKSRC_BYPASS_Msk (0x1UL << CLOCK_LFCLKSRC_BYPASS_Pos) /*!< Bit mask of BYPASS field. */ -#define CLOCK_LFCLKSRC_BYPASS_Disabled (0UL) /*!< Disable (use with Xtal or low-swing external source) */ -#define CLOCK_LFCLKSRC_BYPASS_Enabled (1UL) /*!< Enable (use with rail-to-rail external source) */ - -/* Bits 1..0 : Clock source */ -#define CLOCK_LFCLKSRC_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define CLOCK_LFCLKSRC_SRC_Msk (0x3UL << CLOCK_LFCLKSRC_SRC_Pos) /*!< Bit mask of SRC field. */ -#define CLOCK_LFCLKSRC_SRC_RC (0UL) /*!< 32.768 kHz RC oscillator */ -#define CLOCK_LFCLKSRC_SRC_Xtal (1UL) /*!< 32.768 kHz crystal oscillator */ -#define CLOCK_LFCLKSRC_SRC_Synth (2UL) /*!< 32.768 kHz synthesized from HFCLK */ - -/* Register: CLOCK_HFXODEBOUNCE */ -/* Description: HFXO debounce time. The HFXO is started by triggering the TASKS_HFCLKSTART task. */ - -/* Bits 7..0 : HFXO debounce time. Debounce time = HFXODEBOUNCE * 16 us. */ -#define CLOCK_HFXODEBOUNCE_HFXODEBOUNCE_Pos (0UL) /*!< Position of HFXODEBOUNCE field. */ -#define CLOCK_HFXODEBOUNCE_HFXODEBOUNCE_Msk (0xFFUL << CLOCK_HFXODEBOUNCE_HFXODEBOUNCE_Pos) /*!< Bit mask of HFXODEBOUNCE field. */ - -/* Register: CLOCK_CTIV */ -/* Description: Calibration timer interval */ - -/* Bits 6..0 : Calibration timer interval in multiple of 0.25 seconds. Range: 0.25 seconds to 31.75 seconds. */ -#define CLOCK_CTIV_CTIV_Pos (0UL) /*!< Position of CTIV field. */ -#define CLOCK_CTIV_CTIV_Msk (0x7FUL << CLOCK_CTIV_CTIV_Pos) /*!< Bit mask of CTIV field. */ - -/* Register: CLOCK_TRACECONFIG */ -/* Description: Clocking options for the Trace Port debug interface */ - -/* Bits 17..16 : Pin multiplexing of trace signals. See pin assignment chapter for more details. */ -#define CLOCK_TRACECONFIG_TRACEMUX_Pos (16UL) /*!< Position of TRACEMUX field. */ -#define CLOCK_TRACECONFIG_TRACEMUX_Msk (0x3UL << CLOCK_TRACECONFIG_TRACEMUX_Pos) /*!< Bit mask of TRACEMUX field. */ -#define CLOCK_TRACECONFIG_TRACEMUX_GPIO (0UL) /*!< No trace signals routed to pins. All pins can be used as regular GPIOs. */ -#define CLOCK_TRACECONFIG_TRACEMUX_Serial (1UL) /*!< SWO trace signal routed to pin. Remaining pins can be used as regular GPIOs. */ -#define CLOCK_TRACECONFIG_TRACEMUX_Parallel (2UL) /*!< All trace signals (TRACECLK and TRACEDATA[n]) routed to pins. */ - -/* Bits 1..0 : Speed of Trace Port clock. Note that the TRACECLK pin will output this clock divided by two. */ -#define CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos (0UL) /*!< Position of TRACEPORTSPEED field. */ -#define CLOCK_TRACECONFIG_TRACEPORTSPEED_Msk (0x3UL << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos) /*!< Bit mask of TRACEPORTSPEED field. */ -#define CLOCK_TRACECONFIG_TRACEPORTSPEED_32MHz (0UL) /*!< 32 MHz Trace Port clock (TRACECLK = 16 MHz) */ -#define CLOCK_TRACECONFIG_TRACEPORTSPEED_16MHz (1UL) /*!< 16 MHz Trace Port clock (TRACECLK = 8 MHz) */ -#define CLOCK_TRACECONFIG_TRACEPORTSPEED_8MHz (2UL) /*!< 8 MHz Trace Port clock (TRACECLK = 4 MHz) */ -#define CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz (3UL) /*!< 4 MHz Trace Port clock (TRACECLK = 2 MHz) */ - -/* Register: CLOCK_LFRCMODE */ -/* Description: LFRC mode configuration */ - -/* Bit 16 : Active LFRC mode. This field is read only. */ -#define CLOCK_LFRCMODE_STATUS_Pos (16UL) /*!< Position of STATUS field. */ -#define CLOCK_LFRCMODE_STATUS_Msk (0x1UL << CLOCK_LFRCMODE_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define CLOCK_LFRCMODE_STATUS_Normal (0UL) /*!< Normal mode */ -#define CLOCK_LFRCMODE_STATUS_ULP (1UL) /*!< Ultra-low power mode (ULP) */ - -/* Bit 0 : Set LFRC mode */ -#define CLOCK_LFRCMODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define CLOCK_LFRCMODE_MODE_Msk (0x1UL << CLOCK_LFRCMODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define CLOCK_LFRCMODE_MODE_Normal (0UL) /*!< Normal mode */ -#define CLOCK_LFRCMODE_MODE_ULP (1UL) /*!< Ultra-low power mode (ULP) */ - - -/* Peripheral: COMP */ -/* Description: Comparator */ - -/* Register: COMP_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between CROSS event and STOP task */ -#define COMP_SHORTS_CROSS_STOP_Pos (4UL) /*!< Position of CROSS_STOP field. */ -#define COMP_SHORTS_CROSS_STOP_Msk (0x1UL << COMP_SHORTS_CROSS_STOP_Pos) /*!< Bit mask of CROSS_STOP field. */ -#define COMP_SHORTS_CROSS_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_CROSS_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between UP event and STOP task */ -#define COMP_SHORTS_UP_STOP_Pos (3UL) /*!< Position of UP_STOP field. */ -#define COMP_SHORTS_UP_STOP_Msk (0x1UL << COMP_SHORTS_UP_STOP_Pos) /*!< Bit mask of UP_STOP field. */ -#define COMP_SHORTS_UP_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_UP_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between DOWN event and STOP task */ -#define COMP_SHORTS_DOWN_STOP_Pos (2UL) /*!< Position of DOWN_STOP field. */ -#define COMP_SHORTS_DOWN_STOP_Msk (0x1UL << COMP_SHORTS_DOWN_STOP_Pos) /*!< Bit mask of DOWN_STOP field. */ -#define COMP_SHORTS_DOWN_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_DOWN_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between READY event and STOP task */ -#define COMP_SHORTS_READY_STOP_Pos (1UL) /*!< Position of READY_STOP field. */ -#define COMP_SHORTS_READY_STOP_Msk (0x1UL << COMP_SHORTS_READY_STOP_Pos) /*!< Bit mask of READY_STOP field. */ -#define COMP_SHORTS_READY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_READY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between READY event and SAMPLE task */ -#define COMP_SHORTS_READY_SAMPLE_Pos (0UL) /*!< Position of READY_SAMPLE field. */ -#define COMP_SHORTS_READY_SAMPLE_Msk (0x1UL << COMP_SHORTS_READY_SAMPLE_Pos) /*!< Bit mask of READY_SAMPLE field. */ -#define COMP_SHORTS_READY_SAMPLE_Disabled (0UL) /*!< Disable shortcut */ -#define COMP_SHORTS_READY_SAMPLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: COMP_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 3 : Enable or disable interrupt for CROSS event */ -#define COMP_INTEN_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define COMP_INTEN_CROSS_Msk (0x1UL << COMP_INTEN_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define COMP_INTEN_CROSS_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_CROSS_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for UP event */ -#define COMP_INTEN_UP_Pos (2UL) /*!< Position of UP field. */ -#define COMP_INTEN_UP_Msk (0x1UL << COMP_INTEN_UP_Pos) /*!< Bit mask of UP field. */ -#define COMP_INTEN_UP_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_UP_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for DOWN event */ -#define COMP_INTEN_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define COMP_INTEN_DOWN_Msk (0x1UL << COMP_INTEN_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define COMP_INTEN_DOWN_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_DOWN_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for READY event */ -#define COMP_INTEN_READY_Pos (0UL) /*!< Position of READY field. */ -#define COMP_INTEN_READY_Msk (0x1UL << COMP_INTEN_READY_Pos) /*!< Bit mask of READY field. */ -#define COMP_INTEN_READY_Disabled (0UL) /*!< Disable */ -#define COMP_INTEN_READY_Enabled (1UL) /*!< Enable */ - -/* Register: COMP_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 3 : Write '1' to Enable interrupt for CROSS event */ -#define COMP_INTENSET_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define COMP_INTENSET_CROSS_Msk (0x1UL << COMP_INTENSET_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define COMP_INTENSET_CROSS_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_CROSS_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_CROSS_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for UP event */ -#define COMP_INTENSET_UP_Pos (2UL) /*!< Position of UP field. */ -#define COMP_INTENSET_UP_Msk (0x1UL << COMP_INTENSET_UP_Pos) /*!< Bit mask of UP field. */ -#define COMP_INTENSET_UP_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_UP_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_UP_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for DOWN event */ -#define COMP_INTENSET_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define COMP_INTENSET_DOWN_Msk (0x1UL << COMP_INTENSET_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define COMP_INTENSET_DOWN_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_DOWN_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_DOWN_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define COMP_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define COMP_INTENSET_READY_Msk (0x1UL << COMP_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define COMP_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: COMP_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 3 : Write '1' to Disable interrupt for CROSS event */ -#define COMP_INTENCLR_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define COMP_INTENCLR_CROSS_Msk (0x1UL << COMP_INTENCLR_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define COMP_INTENCLR_CROSS_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_CROSS_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_CROSS_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for UP event */ -#define COMP_INTENCLR_UP_Pos (2UL) /*!< Position of UP field. */ -#define COMP_INTENCLR_UP_Msk (0x1UL << COMP_INTENCLR_UP_Pos) /*!< Bit mask of UP field. */ -#define COMP_INTENCLR_UP_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_UP_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_UP_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for DOWN event */ -#define COMP_INTENCLR_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define COMP_INTENCLR_DOWN_Msk (0x1UL << COMP_INTENCLR_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define COMP_INTENCLR_DOWN_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_DOWN_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_DOWN_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define COMP_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define COMP_INTENCLR_READY_Msk (0x1UL << COMP_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define COMP_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define COMP_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define COMP_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: COMP_RESULT */ -/* Description: Compare result */ - -/* Bit 0 : Result of last compare. Decision point SAMPLE task. */ -#define COMP_RESULT_RESULT_Pos (0UL) /*!< Position of RESULT field. */ -#define COMP_RESULT_RESULT_Msk (0x1UL << COMP_RESULT_RESULT_Pos) /*!< Bit mask of RESULT field. */ -#define COMP_RESULT_RESULT_Below (0UL) /*!< Input voltage is below the threshold (VIN+ < VIN-) */ -#define COMP_RESULT_RESULT_Above (1UL) /*!< Input voltage is above the threshold (VIN+ > VIN-) */ - -/* Register: COMP_ENABLE */ -/* Description: COMP enable */ - -/* Bits 1..0 : Enable or disable COMP */ -#define COMP_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define COMP_ENABLE_ENABLE_Msk (0x3UL << COMP_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define COMP_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define COMP_ENABLE_ENABLE_Enabled (2UL) /*!< Enable */ - -/* Register: COMP_PSEL */ -/* Description: Pin select */ - -/* Bits 2..0 : Analog pin select */ -#define COMP_PSEL_PSEL_Pos (0UL) /*!< Position of PSEL field. */ -#define COMP_PSEL_PSEL_Msk (0x7UL << COMP_PSEL_PSEL_Pos) /*!< Bit mask of PSEL field. */ -#define COMP_PSEL_PSEL_AnalogInput0 (0UL) /*!< AIN0 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput1 (1UL) /*!< AIN1 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput2 (2UL) /*!< AIN2 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput3 (3UL) /*!< AIN3 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput4 (4UL) /*!< AIN4 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput5 (5UL) /*!< AIN5 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput6 (6UL) /*!< AIN6 selected as analog input */ -#define COMP_PSEL_PSEL_AnalogInput7 (7UL) /*!< AIN7 selected as analog input */ - -/* Register: COMP_REFSEL */ -/* Description: Reference source select for single-ended mode */ - -/* Bits 2..0 : Reference select */ -#define COMP_REFSEL_REFSEL_Pos (0UL) /*!< Position of REFSEL field. */ -#define COMP_REFSEL_REFSEL_Msk (0x7UL << COMP_REFSEL_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define COMP_REFSEL_REFSEL_Int1V2 (0UL) /*!< VREF = internal 1.2 V reference (VDD >= 1.7 V) */ -#define COMP_REFSEL_REFSEL_Int1V8 (1UL) /*!< VREF = internal 1.8 V reference (VDD >= VREF + 0.2 V) */ -#define COMP_REFSEL_REFSEL_Int2V4 (2UL) /*!< VREF = internal 2.4 V reference (VDD >= VREF + 0.2 V) */ -#define COMP_REFSEL_REFSEL_VDD (4UL) /*!< VREF = VDD */ -#define COMP_REFSEL_REFSEL_ARef (5UL) /*!< VREF = AREF (VDD >= VREF >= AREFMIN) */ - -/* Register: COMP_EXTREFSEL */ -/* Description: External reference select */ - -/* Bits 2..0 : External analog reference select */ -#define COMP_EXTREFSEL_EXTREFSEL_Pos (0UL) /*!< Position of EXTREFSEL field. */ -#define COMP_EXTREFSEL_EXTREFSEL_Msk (0x7UL << COMP_EXTREFSEL_EXTREFSEL_Pos) /*!< Bit mask of EXTREFSEL field. */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference0 (0UL) /*!< Use AIN0 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference1 (1UL) /*!< Use AIN1 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference2 (2UL) /*!< Use AIN2 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference3 (3UL) /*!< Use AIN3 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference4 (4UL) /*!< Use AIN4 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference5 (5UL) /*!< Use AIN5 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference6 (6UL) /*!< Use AIN6 as external analog reference */ -#define COMP_EXTREFSEL_EXTREFSEL_AnalogReference7 (7UL) /*!< Use AIN7 as external analog reference */ - -/* Register: COMP_TH */ -/* Description: Threshold configuration for hysteresis unit */ - -/* Bits 13..8 : VUP = (THUP+1)/64*VREF */ -#define COMP_TH_THUP_Pos (8UL) /*!< Position of THUP field. */ -#define COMP_TH_THUP_Msk (0x3FUL << COMP_TH_THUP_Pos) /*!< Bit mask of THUP field. */ - -/* Bits 5..0 : VDOWN = (THDOWN+1)/64*VREF */ -#define COMP_TH_THDOWN_Pos (0UL) /*!< Position of THDOWN field. */ -#define COMP_TH_THDOWN_Msk (0x3FUL << COMP_TH_THDOWN_Pos) /*!< Bit mask of THDOWN field. */ - -/* Register: COMP_MODE */ -/* Description: Mode configuration */ - -/* Bit 8 : Main operation modes */ -#define COMP_MODE_MAIN_Pos (8UL) /*!< Position of MAIN field. */ -#define COMP_MODE_MAIN_Msk (0x1UL << COMP_MODE_MAIN_Pos) /*!< Bit mask of MAIN field. */ -#define COMP_MODE_MAIN_SE (0UL) /*!< Single-ended mode */ -#define COMP_MODE_MAIN_Diff (1UL) /*!< Differential mode */ - -/* Bits 1..0 : Speed and power modes */ -#define COMP_MODE_SP_Pos (0UL) /*!< Position of SP field. */ -#define COMP_MODE_SP_Msk (0x3UL << COMP_MODE_SP_Pos) /*!< Bit mask of SP field. */ -#define COMP_MODE_SP_Low (0UL) /*!< Low-power mode */ -#define COMP_MODE_SP_Normal (1UL) /*!< Normal mode */ -#define COMP_MODE_SP_High (2UL) /*!< High-speed mode */ - -/* Register: COMP_HYST */ -/* Description: Comparator hysteresis enable */ - -/* Bit 0 : Comparator hysteresis */ -#define COMP_HYST_HYST_Pos (0UL) /*!< Position of HYST field. */ -#define COMP_HYST_HYST_Msk (0x1UL << COMP_HYST_HYST_Pos) /*!< Bit mask of HYST field. */ -#define COMP_HYST_HYST_NoHyst (0UL) /*!< Comparator hysteresis disabled */ -#define COMP_HYST_HYST_Hyst50mV (1UL) /*!< Comparator hysteresis enabled */ - - -/* Peripheral: CRYPTOCELL */ -/* Description: ARM TrustZone CryptoCell register interface */ - -/* Register: CRYPTOCELL_ENABLE */ -/* Description: Control power and clock for CRYPTOCELL subsystem */ - -/* Bit 0 : Enable or disable the CRYPTOCELL subsystem */ -#define CRYPTOCELL_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define CRYPTOCELL_ENABLE_ENABLE_Msk (0x1UL << CRYPTOCELL_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define CRYPTOCELL_ENABLE_ENABLE_Disabled (0UL) /*!< CRYPTOCELL subsystem disabled */ -#define CRYPTOCELL_ENABLE_ENABLE_Enabled (1UL) /*!< CRYPTOCELL subsystem enabled */ - - -/* Peripheral: ECB */ -/* Description: AES ECB Mode Encryption */ - -/* Register: ECB_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 1 : Write '1' to Enable interrupt for ERRORECB event */ -#define ECB_INTENSET_ERRORECB_Pos (1UL) /*!< Position of ERRORECB field. */ -#define ECB_INTENSET_ERRORECB_Msk (0x1UL << ECB_INTENSET_ERRORECB_Pos) /*!< Bit mask of ERRORECB field. */ -#define ECB_INTENSET_ERRORECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENSET_ERRORECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENSET_ERRORECB_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for ENDECB event */ -#define ECB_INTENSET_ENDECB_Pos (0UL) /*!< Position of ENDECB field. */ -#define ECB_INTENSET_ENDECB_Msk (0x1UL << ECB_INTENSET_ENDECB_Pos) /*!< Bit mask of ENDECB field. */ -#define ECB_INTENSET_ENDECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENSET_ENDECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENSET_ENDECB_Set (1UL) /*!< Enable */ - -/* Register: ECB_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 1 : Write '1' to Disable interrupt for ERRORECB event */ -#define ECB_INTENCLR_ERRORECB_Pos (1UL) /*!< Position of ERRORECB field. */ -#define ECB_INTENCLR_ERRORECB_Msk (0x1UL << ECB_INTENCLR_ERRORECB_Pos) /*!< Bit mask of ERRORECB field. */ -#define ECB_INTENCLR_ERRORECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENCLR_ERRORECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENCLR_ERRORECB_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for ENDECB event */ -#define ECB_INTENCLR_ENDECB_Pos (0UL) /*!< Position of ENDECB field. */ -#define ECB_INTENCLR_ENDECB_Msk (0x1UL << ECB_INTENCLR_ENDECB_Pos) /*!< Bit mask of ENDECB field. */ -#define ECB_INTENCLR_ENDECB_Disabled (0UL) /*!< Read: Disabled */ -#define ECB_INTENCLR_ENDECB_Enabled (1UL) /*!< Read: Enabled */ -#define ECB_INTENCLR_ENDECB_Clear (1UL) /*!< Disable */ - -/* Register: ECB_ECBDATAPTR */ -/* Description: ECB block encrypt memory pointers */ - -/* Bits 31..0 : Pointer to the ECB data structure (see Table 1 ECB data structure overview) */ -#define ECB_ECBDATAPTR_ECBDATAPTR_Pos (0UL) /*!< Position of ECBDATAPTR field. */ -#define ECB_ECBDATAPTR_ECBDATAPTR_Msk (0xFFFFFFFFUL << ECB_ECBDATAPTR_ECBDATAPTR_Pos) /*!< Bit mask of ECBDATAPTR field. */ - - -/* Peripheral: EGU */ -/* Description: Event Generator Unit 0 */ - -/* Register: EGU_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 15 : Enable or disable interrupt for TRIGGERED[15] event */ -#define EGU_INTEN_TRIGGERED15_Pos (15UL) /*!< Position of TRIGGERED15 field. */ -#define EGU_INTEN_TRIGGERED15_Msk (0x1UL << EGU_INTEN_TRIGGERED15_Pos) /*!< Bit mask of TRIGGERED15 field. */ -#define EGU_INTEN_TRIGGERED15_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED15_Enabled (1UL) /*!< Enable */ - -/* Bit 14 : Enable or disable interrupt for TRIGGERED[14] event */ -#define EGU_INTEN_TRIGGERED14_Pos (14UL) /*!< Position of TRIGGERED14 field. */ -#define EGU_INTEN_TRIGGERED14_Msk (0x1UL << EGU_INTEN_TRIGGERED14_Pos) /*!< Bit mask of TRIGGERED14 field. */ -#define EGU_INTEN_TRIGGERED14_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED14_Enabled (1UL) /*!< Enable */ - -/* Bit 13 : Enable or disable interrupt for TRIGGERED[13] event */ -#define EGU_INTEN_TRIGGERED13_Pos (13UL) /*!< Position of TRIGGERED13 field. */ -#define EGU_INTEN_TRIGGERED13_Msk (0x1UL << EGU_INTEN_TRIGGERED13_Pos) /*!< Bit mask of TRIGGERED13 field. */ -#define EGU_INTEN_TRIGGERED13_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED13_Enabled (1UL) /*!< Enable */ - -/* Bit 12 : Enable or disable interrupt for TRIGGERED[12] event */ -#define EGU_INTEN_TRIGGERED12_Pos (12UL) /*!< Position of TRIGGERED12 field. */ -#define EGU_INTEN_TRIGGERED12_Msk (0x1UL << EGU_INTEN_TRIGGERED12_Pos) /*!< Bit mask of TRIGGERED12 field. */ -#define EGU_INTEN_TRIGGERED12_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED12_Enabled (1UL) /*!< Enable */ - -/* Bit 11 : Enable or disable interrupt for TRIGGERED[11] event */ -#define EGU_INTEN_TRIGGERED11_Pos (11UL) /*!< Position of TRIGGERED11 field. */ -#define EGU_INTEN_TRIGGERED11_Msk (0x1UL << EGU_INTEN_TRIGGERED11_Pos) /*!< Bit mask of TRIGGERED11 field. */ -#define EGU_INTEN_TRIGGERED11_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED11_Enabled (1UL) /*!< Enable */ - -/* Bit 10 : Enable or disable interrupt for TRIGGERED[10] event */ -#define EGU_INTEN_TRIGGERED10_Pos (10UL) /*!< Position of TRIGGERED10 field. */ -#define EGU_INTEN_TRIGGERED10_Msk (0x1UL << EGU_INTEN_TRIGGERED10_Pos) /*!< Bit mask of TRIGGERED10 field. */ -#define EGU_INTEN_TRIGGERED10_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED10_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for TRIGGERED[9] event */ -#define EGU_INTEN_TRIGGERED9_Pos (9UL) /*!< Position of TRIGGERED9 field. */ -#define EGU_INTEN_TRIGGERED9_Msk (0x1UL << EGU_INTEN_TRIGGERED9_Pos) /*!< Bit mask of TRIGGERED9 field. */ -#define EGU_INTEN_TRIGGERED9_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED9_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for TRIGGERED[8] event */ -#define EGU_INTEN_TRIGGERED8_Pos (8UL) /*!< Position of TRIGGERED8 field. */ -#define EGU_INTEN_TRIGGERED8_Msk (0x1UL << EGU_INTEN_TRIGGERED8_Pos) /*!< Bit mask of TRIGGERED8 field. */ -#define EGU_INTEN_TRIGGERED8_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED8_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for TRIGGERED[7] event */ -#define EGU_INTEN_TRIGGERED7_Pos (7UL) /*!< Position of TRIGGERED7 field. */ -#define EGU_INTEN_TRIGGERED7_Msk (0x1UL << EGU_INTEN_TRIGGERED7_Pos) /*!< Bit mask of TRIGGERED7 field. */ -#define EGU_INTEN_TRIGGERED7_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED7_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for TRIGGERED[6] event */ -#define EGU_INTEN_TRIGGERED6_Pos (6UL) /*!< Position of TRIGGERED6 field. */ -#define EGU_INTEN_TRIGGERED6_Msk (0x1UL << EGU_INTEN_TRIGGERED6_Pos) /*!< Bit mask of TRIGGERED6 field. */ -#define EGU_INTEN_TRIGGERED6_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED6_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for TRIGGERED[5] event */ -#define EGU_INTEN_TRIGGERED5_Pos (5UL) /*!< Position of TRIGGERED5 field. */ -#define EGU_INTEN_TRIGGERED5_Msk (0x1UL << EGU_INTEN_TRIGGERED5_Pos) /*!< Bit mask of TRIGGERED5 field. */ -#define EGU_INTEN_TRIGGERED5_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED5_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for TRIGGERED[4] event */ -#define EGU_INTEN_TRIGGERED4_Pos (4UL) /*!< Position of TRIGGERED4 field. */ -#define EGU_INTEN_TRIGGERED4_Msk (0x1UL << EGU_INTEN_TRIGGERED4_Pos) /*!< Bit mask of TRIGGERED4 field. */ -#define EGU_INTEN_TRIGGERED4_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED4_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for TRIGGERED[3] event */ -#define EGU_INTEN_TRIGGERED3_Pos (3UL) /*!< Position of TRIGGERED3 field. */ -#define EGU_INTEN_TRIGGERED3_Msk (0x1UL << EGU_INTEN_TRIGGERED3_Pos) /*!< Bit mask of TRIGGERED3 field. */ -#define EGU_INTEN_TRIGGERED3_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED3_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for TRIGGERED[2] event */ -#define EGU_INTEN_TRIGGERED2_Pos (2UL) /*!< Position of TRIGGERED2 field. */ -#define EGU_INTEN_TRIGGERED2_Msk (0x1UL << EGU_INTEN_TRIGGERED2_Pos) /*!< Bit mask of TRIGGERED2 field. */ -#define EGU_INTEN_TRIGGERED2_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED2_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for TRIGGERED[1] event */ -#define EGU_INTEN_TRIGGERED1_Pos (1UL) /*!< Position of TRIGGERED1 field. */ -#define EGU_INTEN_TRIGGERED1_Msk (0x1UL << EGU_INTEN_TRIGGERED1_Pos) /*!< Bit mask of TRIGGERED1 field. */ -#define EGU_INTEN_TRIGGERED1_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED1_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for TRIGGERED[0] event */ -#define EGU_INTEN_TRIGGERED0_Pos (0UL) /*!< Position of TRIGGERED0 field. */ -#define EGU_INTEN_TRIGGERED0_Msk (0x1UL << EGU_INTEN_TRIGGERED0_Pos) /*!< Bit mask of TRIGGERED0 field. */ -#define EGU_INTEN_TRIGGERED0_Disabled (0UL) /*!< Disable */ -#define EGU_INTEN_TRIGGERED0_Enabled (1UL) /*!< Enable */ - -/* Register: EGU_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 15 : Write '1' to Enable interrupt for TRIGGERED[15] event */ -#define EGU_INTENSET_TRIGGERED15_Pos (15UL) /*!< Position of TRIGGERED15 field. */ -#define EGU_INTENSET_TRIGGERED15_Msk (0x1UL << EGU_INTENSET_TRIGGERED15_Pos) /*!< Bit mask of TRIGGERED15 field. */ -#define EGU_INTENSET_TRIGGERED15_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED15_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED15_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for TRIGGERED[14] event */ -#define EGU_INTENSET_TRIGGERED14_Pos (14UL) /*!< Position of TRIGGERED14 field. */ -#define EGU_INTENSET_TRIGGERED14_Msk (0x1UL << EGU_INTENSET_TRIGGERED14_Pos) /*!< Bit mask of TRIGGERED14 field. */ -#define EGU_INTENSET_TRIGGERED14_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED14_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED14_Set (1UL) /*!< Enable */ - -/* Bit 13 : Write '1' to Enable interrupt for TRIGGERED[13] event */ -#define EGU_INTENSET_TRIGGERED13_Pos (13UL) /*!< Position of TRIGGERED13 field. */ -#define EGU_INTENSET_TRIGGERED13_Msk (0x1UL << EGU_INTENSET_TRIGGERED13_Pos) /*!< Bit mask of TRIGGERED13 field. */ -#define EGU_INTENSET_TRIGGERED13_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED13_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED13_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for TRIGGERED[12] event */ -#define EGU_INTENSET_TRIGGERED12_Pos (12UL) /*!< Position of TRIGGERED12 field. */ -#define EGU_INTENSET_TRIGGERED12_Msk (0x1UL << EGU_INTENSET_TRIGGERED12_Pos) /*!< Bit mask of TRIGGERED12 field. */ -#define EGU_INTENSET_TRIGGERED12_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED12_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED12_Set (1UL) /*!< Enable */ - -/* Bit 11 : Write '1' to Enable interrupt for TRIGGERED[11] event */ -#define EGU_INTENSET_TRIGGERED11_Pos (11UL) /*!< Position of TRIGGERED11 field. */ -#define EGU_INTENSET_TRIGGERED11_Msk (0x1UL << EGU_INTENSET_TRIGGERED11_Pos) /*!< Bit mask of TRIGGERED11 field. */ -#define EGU_INTENSET_TRIGGERED11_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED11_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED11_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for TRIGGERED[10] event */ -#define EGU_INTENSET_TRIGGERED10_Pos (10UL) /*!< Position of TRIGGERED10 field. */ -#define EGU_INTENSET_TRIGGERED10_Msk (0x1UL << EGU_INTENSET_TRIGGERED10_Pos) /*!< Bit mask of TRIGGERED10 field. */ -#define EGU_INTENSET_TRIGGERED10_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED10_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED10_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for TRIGGERED[9] event */ -#define EGU_INTENSET_TRIGGERED9_Pos (9UL) /*!< Position of TRIGGERED9 field. */ -#define EGU_INTENSET_TRIGGERED9_Msk (0x1UL << EGU_INTENSET_TRIGGERED9_Pos) /*!< Bit mask of TRIGGERED9 field. */ -#define EGU_INTENSET_TRIGGERED9_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED9_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED9_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for TRIGGERED[8] event */ -#define EGU_INTENSET_TRIGGERED8_Pos (8UL) /*!< Position of TRIGGERED8 field. */ -#define EGU_INTENSET_TRIGGERED8_Msk (0x1UL << EGU_INTENSET_TRIGGERED8_Pos) /*!< Bit mask of TRIGGERED8 field. */ -#define EGU_INTENSET_TRIGGERED8_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED8_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED8_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for TRIGGERED[7] event */ -#define EGU_INTENSET_TRIGGERED7_Pos (7UL) /*!< Position of TRIGGERED7 field. */ -#define EGU_INTENSET_TRIGGERED7_Msk (0x1UL << EGU_INTENSET_TRIGGERED7_Pos) /*!< Bit mask of TRIGGERED7 field. */ -#define EGU_INTENSET_TRIGGERED7_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED7_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED7_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for TRIGGERED[6] event */ -#define EGU_INTENSET_TRIGGERED6_Pos (6UL) /*!< Position of TRIGGERED6 field. */ -#define EGU_INTENSET_TRIGGERED6_Msk (0x1UL << EGU_INTENSET_TRIGGERED6_Pos) /*!< Bit mask of TRIGGERED6 field. */ -#define EGU_INTENSET_TRIGGERED6_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED6_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED6_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for TRIGGERED[5] event */ -#define EGU_INTENSET_TRIGGERED5_Pos (5UL) /*!< Position of TRIGGERED5 field. */ -#define EGU_INTENSET_TRIGGERED5_Msk (0x1UL << EGU_INTENSET_TRIGGERED5_Pos) /*!< Bit mask of TRIGGERED5 field. */ -#define EGU_INTENSET_TRIGGERED5_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED5_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED5_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for TRIGGERED[4] event */ -#define EGU_INTENSET_TRIGGERED4_Pos (4UL) /*!< Position of TRIGGERED4 field. */ -#define EGU_INTENSET_TRIGGERED4_Msk (0x1UL << EGU_INTENSET_TRIGGERED4_Pos) /*!< Bit mask of TRIGGERED4 field. */ -#define EGU_INTENSET_TRIGGERED4_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED4_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED4_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for TRIGGERED[3] event */ -#define EGU_INTENSET_TRIGGERED3_Pos (3UL) /*!< Position of TRIGGERED3 field. */ -#define EGU_INTENSET_TRIGGERED3_Msk (0x1UL << EGU_INTENSET_TRIGGERED3_Pos) /*!< Bit mask of TRIGGERED3 field. */ -#define EGU_INTENSET_TRIGGERED3_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED3_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED3_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for TRIGGERED[2] event */ -#define EGU_INTENSET_TRIGGERED2_Pos (2UL) /*!< Position of TRIGGERED2 field. */ -#define EGU_INTENSET_TRIGGERED2_Msk (0x1UL << EGU_INTENSET_TRIGGERED2_Pos) /*!< Bit mask of TRIGGERED2 field. */ -#define EGU_INTENSET_TRIGGERED2_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED2_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED2_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for TRIGGERED[1] event */ -#define EGU_INTENSET_TRIGGERED1_Pos (1UL) /*!< Position of TRIGGERED1 field. */ -#define EGU_INTENSET_TRIGGERED1_Msk (0x1UL << EGU_INTENSET_TRIGGERED1_Pos) /*!< Bit mask of TRIGGERED1 field. */ -#define EGU_INTENSET_TRIGGERED1_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED1_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED1_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for TRIGGERED[0] event */ -#define EGU_INTENSET_TRIGGERED0_Pos (0UL) /*!< Position of TRIGGERED0 field. */ -#define EGU_INTENSET_TRIGGERED0_Msk (0x1UL << EGU_INTENSET_TRIGGERED0_Pos) /*!< Bit mask of TRIGGERED0 field. */ -#define EGU_INTENSET_TRIGGERED0_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENSET_TRIGGERED0_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENSET_TRIGGERED0_Set (1UL) /*!< Enable */ - -/* Register: EGU_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 15 : Write '1' to Disable interrupt for TRIGGERED[15] event */ -#define EGU_INTENCLR_TRIGGERED15_Pos (15UL) /*!< Position of TRIGGERED15 field. */ -#define EGU_INTENCLR_TRIGGERED15_Msk (0x1UL << EGU_INTENCLR_TRIGGERED15_Pos) /*!< Bit mask of TRIGGERED15 field. */ -#define EGU_INTENCLR_TRIGGERED15_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED15_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED15_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for TRIGGERED[14] event */ -#define EGU_INTENCLR_TRIGGERED14_Pos (14UL) /*!< Position of TRIGGERED14 field. */ -#define EGU_INTENCLR_TRIGGERED14_Msk (0x1UL << EGU_INTENCLR_TRIGGERED14_Pos) /*!< Bit mask of TRIGGERED14 field. */ -#define EGU_INTENCLR_TRIGGERED14_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED14_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED14_Clear (1UL) /*!< Disable */ - -/* Bit 13 : Write '1' to Disable interrupt for TRIGGERED[13] event */ -#define EGU_INTENCLR_TRIGGERED13_Pos (13UL) /*!< Position of TRIGGERED13 field. */ -#define EGU_INTENCLR_TRIGGERED13_Msk (0x1UL << EGU_INTENCLR_TRIGGERED13_Pos) /*!< Bit mask of TRIGGERED13 field. */ -#define EGU_INTENCLR_TRIGGERED13_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED13_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED13_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for TRIGGERED[12] event */ -#define EGU_INTENCLR_TRIGGERED12_Pos (12UL) /*!< Position of TRIGGERED12 field. */ -#define EGU_INTENCLR_TRIGGERED12_Msk (0x1UL << EGU_INTENCLR_TRIGGERED12_Pos) /*!< Bit mask of TRIGGERED12 field. */ -#define EGU_INTENCLR_TRIGGERED12_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED12_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED12_Clear (1UL) /*!< Disable */ - -/* Bit 11 : Write '1' to Disable interrupt for TRIGGERED[11] event */ -#define EGU_INTENCLR_TRIGGERED11_Pos (11UL) /*!< Position of TRIGGERED11 field. */ -#define EGU_INTENCLR_TRIGGERED11_Msk (0x1UL << EGU_INTENCLR_TRIGGERED11_Pos) /*!< Bit mask of TRIGGERED11 field. */ -#define EGU_INTENCLR_TRIGGERED11_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED11_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED11_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for TRIGGERED[10] event */ -#define EGU_INTENCLR_TRIGGERED10_Pos (10UL) /*!< Position of TRIGGERED10 field. */ -#define EGU_INTENCLR_TRIGGERED10_Msk (0x1UL << EGU_INTENCLR_TRIGGERED10_Pos) /*!< Bit mask of TRIGGERED10 field. */ -#define EGU_INTENCLR_TRIGGERED10_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED10_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED10_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for TRIGGERED[9] event */ -#define EGU_INTENCLR_TRIGGERED9_Pos (9UL) /*!< Position of TRIGGERED9 field. */ -#define EGU_INTENCLR_TRIGGERED9_Msk (0x1UL << EGU_INTENCLR_TRIGGERED9_Pos) /*!< Bit mask of TRIGGERED9 field. */ -#define EGU_INTENCLR_TRIGGERED9_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED9_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED9_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for TRIGGERED[8] event */ -#define EGU_INTENCLR_TRIGGERED8_Pos (8UL) /*!< Position of TRIGGERED8 field. */ -#define EGU_INTENCLR_TRIGGERED8_Msk (0x1UL << EGU_INTENCLR_TRIGGERED8_Pos) /*!< Bit mask of TRIGGERED8 field. */ -#define EGU_INTENCLR_TRIGGERED8_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED8_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED8_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for TRIGGERED[7] event */ -#define EGU_INTENCLR_TRIGGERED7_Pos (7UL) /*!< Position of TRIGGERED7 field. */ -#define EGU_INTENCLR_TRIGGERED7_Msk (0x1UL << EGU_INTENCLR_TRIGGERED7_Pos) /*!< Bit mask of TRIGGERED7 field. */ -#define EGU_INTENCLR_TRIGGERED7_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED7_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED7_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for TRIGGERED[6] event */ -#define EGU_INTENCLR_TRIGGERED6_Pos (6UL) /*!< Position of TRIGGERED6 field. */ -#define EGU_INTENCLR_TRIGGERED6_Msk (0x1UL << EGU_INTENCLR_TRIGGERED6_Pos) /*!< Bit mask of TRIGGERED6 field. */ -#define EGU_INTENCLR_TRIGGERED6_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED6_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED6_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for TRIGGERED[5] event */ -#define EGU_INTENCLR_TRIGGERED5_Pos (5UL) /*!< Position of TRIGGERED5 field. */ -#define EGU_INTENCLR_TRIGGERED5_Msk (0x1UL << EGU_INTENCLR_TRIGGERED5_Pos) /*!< Bit mask of TRIGGERED5 field. */ -#define EGU_INTENCLR_TRIGGERED5_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED5_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED5_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for TRIGGERED[4] event */ -#define EGU_INTENCLR_TRIGGERED4_Pos (4UL) /*!< Position of TRIGGERED4 field. */ -#define EGU_INTENCLR_TRIGGERED4_Msk (0x1UL << EGU_INTENCLR_TRIGGERED4_Pos) /*!< Bit mask of TRIGGERED4 field. */ -#define EGU_INTENCLR_TRIGGERED4_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED4_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED4_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for TRIGGERED[3] event */ -#define EGU_INTENCLR_TRIGGERED3_Pos (3UL) /*!< Position of TRIGGERED3 field. */ -#define EGU_INTENCLR_TRIGGERED3_Msk (0x1UL << EGU_INTENCLR_TRIGGERED3_Pos) /*!< Bit mask of TRIGGERED3 field. */ -#define EGU_INTENCLR_TRIGGERED3_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED3_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED3_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for TRIGGERED[2] event */ -#define EGU_INTENCLR_TRIGGERED2_Pos (2UL) /*!< Position of TRIGGERED2 field. */ -#define EGU_INTENCLR_TRIGGERED2_Msk (0x1UL << EGU_INTENCLR_TRIGGERED2_Pos) /*!< Bit mask of TRIGGERED2 field. */ -#define EGU_INTENCLR_TRIGGERED2_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED2_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED2_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for TRIGGERED[1] event */ -#define EGU_INTENCLR_TRIGGERED1_Pos (1UL) /*!< Position of TRIGGERED1 field. */ -#define EGU_INTENCLR_TRIGGERED1_Msk (0x1UL << EGU_INTENCLR_TRIGGERED1_Pos) /*!< Bit mask of TRIGGERED1 field. */ -#define EGU_INTENCLR_TRIGGERED1_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED1_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED1_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for TRIGGERED[0] event */ -#define EGU_INTENCLR_TRIGGERED0_Pos (0UL) /*!< Position of TRIGGERED0 field. */ -#define EGU_INTENCLR_TRIGGERED0_Msk (0x1UL << EGU_INTENCLR_TRIGGERED0_Pos) /*!< Bit mask of TRIGGERED0 field. */ -#define EGU_INTENCLR_TRIGGERED0_Disabled (0UL) /*!< Read: Disabled */ -#define EGU_INTENCLR_TRIGGERED0_Enabled (1UL) /*!< Read: Enabled */ -#define EGU_INTENCLR_TRIGGERED0_Clear (1UL) /*!< Disable */ - - -/* Peripheral: FICR */ -/* Description: Factory information configuration registers */ - -/* Register: FICR_CODEPAGESIZE */ -/* Description: Code memory page size */ - -/* Bits 31..0 : Code memory page size */ -#define FICR_CODEPAGESIZE_CODEPAGESIZE_Pos (0UL) /*!< Position of CODEPAGESIZE field. */ -#define FICR_CODEPAGESIZE_CODEPAGESIZE_Msk (0xFFFFFFFFUL << FICR_CODEPAGESIZE_CODEPAGESIZE_Pos) /*!< Bit mask of CODEPAGESIZE field. */ - -/* Register: FICR_CODESIZE */ -/* Description: Code memory size */ - -/* Bits 31..0 : Code memory size in number of pages */ -#define FICR_CODESIZE_CODESIZE_Pos (0UL) /*!< Position of CODESIZE field. */ -#define FICR_CODESIZE_CODESIZE_Msk (0xFFFFFFFFUL << FICR_CODESIZE_CODESIZE_Pos) /*!< Bit mask of CODESIZE field. */ - -/* Register: FICR_DEVICEID */ -/* Description: Description collection[0]: Device identifier */ - -/* Bits 31..0 : 64 bit unique device identifier */ -#define FICR_DEVICEID_DEVICEID_Pos (0UL) /*!< Position of DEVICEID field. */ -#define FICR_DEVICEID_DEVICEID_Msk (0xFFFFFFFFUL << FICR_DEVICEID_DEVICEID_Pos) /*!< Bit mask of DEVICEID field. */ - -/* Register: FICR_ER */ -/* Description: Description collection[0]: Encryption root, word 0 */ - -/* Bits 31..0 : Encryption root, word 0 */ -#define FICR_ER_ER_Pos (0UL) /*!< Position of ER field. */ -#define FICR_ER_ER_Msk (0xFFFFFFFFUL << FICR_ER_ER_Pos) /*!< Bit mask of ER field. */ - -/* Register: FICR_IR */ -/* Description: Description collection[0]: Identity Root, word 0 */ - -/* Bits 31..0 : Identity Root, word 0 */ -#define FICR_IR_IR_Pos (0UL) /*!< Position of IR field. */ -#define FICR_IR_IR_Msk (0xFFFFFFFFUL << FICR_IR_IR_Pos) /*!< Bit mask of IR field. */ - -/* Register: FICR_DEVICEADDRTYPE */ -/* Description: Device address type */ - -/* Bit 0 : Device address type */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Pos (0UL) /*!< Position of DEVICEADDRTYPE field. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Msk (0x1UL << FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Pos) /*!< Bit mask of DEVICEADDRTYPE field. */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Public (0UL) /*!< Public address */ -#define FICR_DEVICEADDRTYPE_DEVICEADDRTYPE_Random (1UL) /*!< Random address */ - -/* Register: FICR_DEVICEADDR */ -/* Description: Description collection[0]: Device address 0 */ - -/* Bits 31..0 : 48 bit device address */ -#define FICR_DEVICEADDR_DEVICEADDR_Pos (0UL) /*!< Position of DEVICEADDR field. */ -#define FICR_DEVICEADDR_DEVICEADDR_Msk (0xFFFFFFFFUL << FICR_DEVICEADDR_DEVICEADDR_Pos) /*!< Bit mask of DEVICEADDR field. */ - -/* Register: FICR_INFO_PART */ -/* Description: Part code */ - -/* Bits 31..0 : Part code */ -#define FICR_INFO_PART_PART_Pos (0UL) /*!< Position of PART field. */ -#define FICR_INFO_PART_PART_Msk (0xFFFFFFFFUL << FICR_INFO_PART_PART_Pos) /*!< Bit mask of PART field. */ -#define FICR_INFO_PART_PART_N52840 (0x52840UL) /*!< nRF52840 */ -#define FICR_INFO_PART_PART_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_VARIANT */ -/* Description: Part variant (hardware version and production configuration) */ - -/* Bits 31..0 : Part variant (hardware version and production configuration). Encoded as ASCII. */ -#define FICR_INFO_VARIANT_VARIANT_Pos (0UL) /*!< Position of VARIANT field. */ -#define FICR_INFO_VARIANT_VARIANT_Msk (0xFFFFFFFFUL << FICR_INFO_VARIANT_VARIANT_Pos) /*!< Bit mask of VARIANT field. */ -#define FICR_INFO_VARIANT_VARIANT_AAAA (0x41414141UL) /*!< AAAA */ -#define FICR_INFO_VARIANT_VARIANT_AAAB (0x41414142UL) /*!< AAAB */ -#define FICR_INFO_VARIANT_VARIANT_AAB0 (0x41414230UL) /*!< AAB0 */ -#define FICR_INFO_VARIANT_VARIANT_AABA (0x41414241UL) /*!< AABA */ -#define FICR_INFO_VARIANT_VARIANT_AABB (0x41414242UL) /*!< AABB */ -#define FICR_INFO_VARIANT_VARIANT_ABBA (0x41424241UL) /*!< ABBA */ -#define FICR_INFO_VARIANT_VARIANT_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_PACKAGE */ -/* Description: Package option */ - -/* Bits 31..0 : Package option */ -#define FICR_INFO_PACKAGE_PACKAGE_Pos (0UL) /*!< Position of PACKAGE field. */ -#define FICR_INFO_PACKAGE_PACKAGE_Msk (0xFFFFFFFFUL << FICR_INFO_PACKAGE_PACKAGE_Pos) /*!< Bit mask of PACKAGE field. */ -#define FICR_INFO_PACKAGE_PACKAGE_QI (0x2004UL) /*!< QIxx - 73-pin aQFN */ -#define FICR_INFO_PACKAGE_PACKAGE_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_RAM */ -/* Description: RAM variant */ - -/* Bits 31..0 : RAM variant */ -#define FICR_INFO_RAM_RAM_Pos (0UL) /*!< Position of RAM field. */ -#define FICR_INFO_RAM_RAM_Msk (0xFFFFFFFFUL << FICR_INFO_RAM_RAM_Pos) /*!< Bit mask of RAM field. */ -#define FICR_INFO_RAM_RAM_K16 (0x10UL) /*!< 16 kByte RAM */ -#define FICR_INFO_RAM_RAM_K32 (0x20UL) /*!< 32 kByte RAM */ -#define FICR_INFO_RAM_RAM_K64 (0x40UL) /*!< 64 kByte RAM */ -#define FICR_INFO_RAM_RAM_K128 (0x80UL) /*!< 128 kByte RAM */ -#define FICR_INFO_RAM_RAM_K256 (0x100UL) /*!< 256 kByte RAM */ -#define FICR_INFO_RAM_RAM_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_INFO_FLASH */ -/* Description: Flash variant */ - -/* Bits 31..0 : Flash variant */ -#define FICR_INFO_FLASH_FLASH_Pos (0UL) /*!< Position of FLASH field. */ -#define FICR_INFO_FLASH_FLASH_Msk (0xFFFFFFFFUL << FICR_INFO_FLASH_FLASH_Pos) /*!< Bit mask of FLASH field. */ -#define FICR_INFO_FLASH_FLASH_K128 (0x80UL) /*!< 128 kByte FLASH */ -#define FICR_INFO_FLASH_FLASH_K256 (0x100UL) /*!< 256 kByte FLASH */ -#define FICR_INFO_FLASH_FLASH_K512 (0x200UL) /*!< 512 kByte FLASH */ -#define FICR_INFO_FLASH_FLASH_K1024 (0x400UL) /*!< 1 MByte FLASH */ -#define FICR_INFO_FLASH_FLASH_K2048 (0x800UL) /*!< 2 MByte FLASH */ -#define FICR_INFO_FLASH_FLASH_Unspecified (0xFFFFFFFFUL) /*!< Unspecified */ - -/* Register: FICR_TEMP_A0 */ -/* Description: Slope definition A0 */ - -/* Bits 11..0 : A (slope definition) register. */ -#define FICR_TEMP_A0_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A0_A_Msk (0xFFFUL << FICR_TEMP_A0_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A1 */ -/* Description: Slope definition A1 */ - -/* Bits 11..0 : A (slope definition) register. */ -#define FICR_TEMP_A1_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A1_A_Msk (0xFFFUL << FICR_TEMP_A1_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A2 */ -/* Description: Slope definition A2 */ - -/* Bits 11..0 : A (slope definition) register. */ -#define FICR_TEMP_A2_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A2_A_Msk (0xFFFUL << FICR_TEMP_A2_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A3 */ -/* Description: Slope definition A3 */ - -/* Bits 11..0 : A (slope definition) register. */ -#define FICR_TEMP_A3_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A3_A_Msk (0xFFFUL << FICR_TEMP_A3_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A4 */ -/* Description: Slope definition A4 */ - -/* Bits 11..0 : A (slope definition) register. */ -#define FICR_TEMP_A4_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A4_A_Msk (0xFFFUL << FICR_TEMP_A4_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_A5 */ -/* Description: Slope definition A5 */ - -/* Bits 11..0 : A (slope definition) register. */ -#define FICR_TEMP_A5_A_Pos (0UL) /*!< Position of A field. */ -#define FICR_TEMP_A5_A_Msk (0xFFFUL << FICR_TEMP_A5_A_Pos) /*!< Bit mask of A field. */ - -/* Register: FICR_TEMP_B0 */ -/* Description: Y-intercept B0 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B0_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B0_B_Msk (0x3FFFUL << FICR_TEMP_B0_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B1 */ -/* Description: Y-intercept B1 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B1_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B1_B_Msk (0x3FFFUL << FICR_TEMP_B1_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B2 */ -/* Description: Y-intercept B2 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B2_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B2_B_Msk (0x3FFFUL << FICR_TEMP_B2_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B3 */ -/* Description: Y-intercept B3 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B3_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B3_B_Msk (0x3FFFUL << FICR_TEMP_B3_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B4 */ -/* Description: Y-intercept B4 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B4_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B4_B_Msk (0x3FFFUL << FICR_TEMP_B4_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_B5 */ -/* Description: Y-intercept B5 */ - -/* Bits 13..0 : B (y-intercept) */ -#define FICR_TEMP_B5_B_Pos (0UL) /*!< Position of B field. */ -#define FICR_TEMP_B5_B_Msk (0x3FFFUL << FICR_TEMP_B5_B_Pos) /*!< Bit mask of B field. */ - -/* Register: FICR_TEMP_T0 */ -/* Description: Segment end T0 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T0_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T0_T_Msk (0xFFUL << FICR_TEMP_T0_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T1 */ -/* Description: Segment end T1 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T1_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T1_T_Msk (0xFFUL << FICR_TEMP_T1_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T2 */ -/* Description: Segment end T2 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T2_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T2_T_Msk (0xFFUL << FICR_TEMP_T2_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T3 */ -/* Description: Segment end T3 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T3_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T3_T_Msk (0xFFUL << FICR_TEMP_T3_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_TEMP_T4 */ -/* Description: Segment end T4 */ - -/* Bits 7..0 : T (segment end) register */ -#define FICR_TEMP_T4_T_Pos (0UL) /*!< Position of T field. */ -#define FICR_TEMP_T4_T_Msk (0xFFUL << FICR_TEMP_T4_T_Pos) /*!< Bit mask of T field. */ - -/* Register: FICR_NFC_TAGHEADER0 */ -/* Description: Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - -/* Bits 31..24 : Unique identifier byte 3 */ -#define FICR_NFC_TAGHEADER0_UD3_Pos (24UL) /*!< Position of UD3 field. */ -#define FICR_NFC_TAGHEADER0_UD3_Msk (0xFFUL << FICR_NFC_TAGHEADER0_UD3_Pos) /*!< Bit mask of UD3 field. */ - -/* Bits 23..16 : Unique identifier byte 2 */ -#define FICR_NFC_TAGHEADER0_UD2_Pos (16UL) /*!< Position of UD2 field. */ -#define FICR_NFC_TAGHEADER0_UD2_Msk (0xFFUL << FICR_NFC_TAGHEADER0_UD2_Pos) /*!< Bit mask of UD2 field. */ - -/* Bits 15..8 : Unique identifier byte 1 */ -#define FICR_NFC_TAGHEADER0_UD1_Pos (8UL) /*!< Position of UD1 field. */ -#define FICR_NFC_TAGHEADER0_UD1_Msk (0xFFUL << FICR_NFC_TAGHEADER0_UD1_Pos) /*!< Bit mask of UD1 field. */ - -/* Bits 7..0 : Default Manufacturer ID: Nordic Semiconductor ASA has ICM 0x5F */ -#define FICR_NFC_TAGHEADER0_MFGID_Pos (0UL) /*!< Position of MFGID field. */ -#define FICR_NFC_TAGHEADER0_MFGID_Msk (0xFFUL << FICR_NFC_TAGHEADER0_MFGID_Pos) /*!< Bit mask of MFGID field. */ - -/* Register: FICR_NFC_TAGHEADER1 */ -/* Description: Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - -/* Bits 31..24 : Unique identifier byte 7 */ -#define FICR_NFC_TAGHEADER1_UD7_Pos (24UL) /*!< Position of UD7 field. */ -#define FICR_NFC_TAGHEADER1_UD7_Msk (0xFFUL << FICR_NFC_TAGHEADER1_UD7_Pos) /*!< Bit mask of UD7 field. */ - -/* Bits 23..16 : Unique identifier byte 6 */ -#define FICR_NFC_TAGHEADER1_UD6_Pos (16UL) /*!< Position of UD6 field. */ -#define FICR_NFC_TAGHEADER1_UD6_Msk (0xFFUL << FICR_NFC_TAGHEADER1_UD6_Pos) /*!< Bit mask of UD6 field. */ - -/* Bits 15..8 : Unique identifier byte 5 */ -#define FICR_NFC_TAGHEADER1_UD5_Pos (8UL) /*!< Position of UD5 field. */ -#define FICR_NFC_TAGHEADER1_UD5_Msk (0xFFUL << FICR_NFC_TAGHEADER1_UD5_Pos) /*!< Bit mask of UD5 field. */ - -/* Bits 7..0 : Unique identifier byte 4 */ -#define FICR_NFC_TAGHEADER1_UD4_Pos (0UL) /*!< Position of UD4 field. */ -#define FICR_NFC_TAGHEADER1_UD4_Msk (0xFFUL << FICR_NFC_TAGHEADER1_UD4_Pos) /*!< Bit mask of UD4 field. */ - -/* Register: FICR_NFC_TAGHEADER2 */ -/* Description: Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - -/* Bits 31..24 : Unique identifier byte 11 */ -#define FICR_NFC_TAGHEADER2_UD11_Pos (24UL) /*!< Position of UD11 field. */ -#define FICR_NFC_TAGHEADER2_UD11_Msk (0xFFUL << FICR_NFC_TAGHEADER2_UD11_Pos) /*!< Bit mask of UD11 field. */ - -/* Bits 23..16 : Unique identifier byte 10 */ -#define FICR_NFC_TAGHEADER2_UD10_Pos (16UL) /*!< Position of UD10 field. */ -#define FICR_NFC_TAGHEADER2_UD10_Msk (0xFFUL << FICR_NFC_TAGHEADER2_UD10_Pos) /*!< Bit mask of UD10 field. */ - -/* Bits 15..8 : Unique identifier byte 9 */ -#define FICR_NFC_TAGHEADER2_UD9_Pos (8UL) /*!< Position of UD9 field. */ -#define FICR_NFC_TAGHEADER2_UD9_Msk (0xFFUL << FICR_NFC_TAGHEADER2_UD9_Pos) /*!< Bit mask of UD9 field. */ - -/* Bits 7..0 : Unique identifier byte 8 */ -#define FICR_NFC_TAGHEADER2_UD8_Pos (0UL) /*!< Position of UD8 field. */ -#define FICR_NFC_TAGHEADER2_UD8_Msk (0xFFUL << FICR_NFC_TAGHEADER2_UD8_Pos) /*!< Bit mask of UD8 field. */ - -/* Register: FICR_NFC_TAGHEADER3 */ -/* Description: Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST and NFCID1_LAST. */ - -/* Bits 31..24 : Unique identifier byte 15 */ -#define FICR_NFC_TAGHEADER3_UD15_Pos (24UL) /*!< Position of UD15 field. */ -#define FICR_NFC_TAGHEADER3_UD15_Msk (0xFFUL << FICR_NFC_TAGHEADER3_UD15_Pos) /*!< Bit mask of UD15 field. */ - -/* Bits 23..16 : Unique identifier byte 14 */ -#define FICR_NFC_TAGHEADER3_UD14_Pos (16UL) /*!< Position of UD14 field. */ -#define FICR_NFC_TAGHEADER3_UD14_Msk (0xFFUL << FICR_NFC_TAGHEADER3_UD14_Pos) /*!< Bit mask of UD14 field. */ - -/* Bits 15..8 : Unique identifier byte 13 */ -#define FICR_NFC_TAGHEADER3_UD13_Pos (8UL) /*!< Position of UD13 field. */ -#define FICR_NFC_TAGHEADER3_UD13_Msk (0xFFUL << FICR_NFC_TAGHEADER3_UD13_Pos) /*!< Bit mask of UD13 field. */ - -/* Bits 7..0 : Unique identifier byte 12 */ -#define FICR_NFC_TAGHEADER3_UD12_Pos (0UL) /*!< Position of UD12 field. */ -#define FICR_NFC_TAGHEADER3_UD12_Msk (0xFFUL << FICR_NFC_TAGHEADER3_UD12_Pos) /*!< Bit mask of UD12 field. */ - - -/* Peripheral: GPIOTE */ -/* Description: GPIO Tasks and Events */ - -/* Register: GPIOTE_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 31 : Write '1' to Enable interrupt for PORT event */ -#define GPIOTE_INTENSET_PORT_Pos (31UL) /*!< Position of PORT field. */ -#define GPIOTE_INTENSET_PORT_Msk (0x1UL << GPIOTE_INTENSET_PORT_Pos) /*!< Bit mask of PORT field. */ -#define GPIOTE_INTENSET_PORT_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_PORT_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_PORT_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for IN[7] event */ -#define GPIOTE_INTENSET_IN7_Pos (7UL) /*!< Position of IN7 field. */ -#define GPIOTE_INTENSET_IN7_Msk (0x1UL << GPIOTE_INTENSET_IN7_Pos) /*!< Bit mask of IN7 field. */ -#define GPIOTE_INTENSET_IN7_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN7_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN7_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for IN[6] event */ -#define GPIOTE_INTENSET_IN6_Pos (6UL) /*!< Position of IN6 field. */ -#define GPIOTE_INTENSET_IN6_Msk (0x1UL << GPIOTE_INTENSET_IN6_Pos) /*!< Bit mask of IN6 field. */ -#define GPIOTE_INTENSET_IN6_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN6_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN6_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for IN[5] event */ -#define GPIOTE_INTENSET_IN5_Pos (5UL) /*!< Position of IN5 field. */ -#define GPIOTE_INTENSET_IN5_Msk (0x1UL << GPIOTE_INTENSET_IN5_Pos) /*!< Bit mask of IN5 field. */ -#define GPIOTE_INTENSET_IN5_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN5_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN5_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for IN[4] event */ -#define GPIOTE_INTENSET_IN4_Pos (4UL) /*!< Position of IN4 field. */ -#define GPIOTE_INTENSET_IN4_Msk (0x1UL << GPIOTE_INTENSET_IN4_Pos) /*!< Bit mask of IN4 field. */ -#define GPIOTE_INTENSET_IN4_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN4_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN4_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for IN[3] event */ -#define GPIOTE_INTENSET_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define GPIOTE_INTENSET_IN3_Msk (0x1UL << GPIOTE_INTENSET_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define GPIOTE_INTENSET_IN3_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN3_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN3_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for IN[2] event */ -#define GPIOTE_INTENSET_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define GPIOTE_INTENSET_IN2_Msk (0x1UL << GPIOTE_INTENSET_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define GPIOTE_INTENSET_IN2_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN2_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN2_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for IN[1] event */ -#define GPIOTE_INTENSET_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define GPIOTE_INTENSET_IN1_Msk (0x1UL << GPIOTE_INTENSET_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define GPIOTE_INTENSET_IN1_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN1_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN1_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for IN[0] event */ -#define GPIOTE_INTENSET_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define GPIOTE_INTENSET_IN0_Msk (0x1UL << GPIOTE_INTENSET_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define GPIOTE_INTENSET_IN0_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENSET_IN0_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENSET_IN0_Set (1UL) /*!< Enable */ - -/* Register: GPIOTE_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 31 : Write '1' to Disable interrupt for PORT event */ -#define GPIOTE_INTENCLR_PORT_Pos (31UL) /*!< Position of PORT field. */ -#define GPIOTE_INTENCLR_PORT_Msk (0x1UL << GPIOTE_INTENCLR_PORT_Pos) /*!< Bit mask of PORT field. */ -#define GPIOTE_INTENCLR_PORT_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_PORT_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_PORT_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for IN[7] event */ -#define GPIOTE_INTENCLR_IN7_Pos (7UL) /*!< Position of IN7 field. */ -#define GPIOTE_INTENCLR_IN7_Msk (0x1UL << GPIOTE_INTENCLR_IN7_Pos) /*!< Bit mask of IN7 field. */ -#define GPIOTE_INTENCLR_IN7_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN7_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN7_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for IN[6] event */ -#define GPIOTE_INTENCLR_IN6_Pos (6UL) /*!< Position of IN6 field. */ -#define GPIOTE_INTENCLR_IN6_Msk (0x1UL << GPIOTE_INTENCLR_IN6_Pos) /*!< Bit mask of IN6 field. */ -#define GPIOTE_INTENCLR_IN6_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN6_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN6_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for IN[5] event */ -#define GPIOTE_INTENCLR_IN5_Pos (5UL) /*!< Position of IN5 field. */ -#define GPIOTE_INTENCLR_IN5_Msk (0x1UL << GPIOTE_INTENCLR_IN5_Pos) /*!< Bit mask of IN5 field. */ -#define GPIOTE_INTENCLR_IN5_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN5_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN5_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for IN[4] event */ -#define GPIOTE_INTENCLR_IN4_Pos (4UL) /*!< Position of IN4 field. */ -#define GPIOTE_INTENCLR_IN4_Msk (0x1UL << GPIOTE_INTENCLR_IN4_Pos) /*!< Bit mask of IN4 field. */ -#define GPIOTE_INTENCLR_IN4_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN4_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN4_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for IN[3] event */ -#define GPIOTE_INTENCLR_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define GPIOTE_INTENCLR_IN3_Msk (0x1UL << GPIOTE_INTENCLR_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define GPIOTE_INTENCLR_IN3_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN3_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN3_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for IN[2] event */ -#define GPIOTE_INTENCLR_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define GPIOTE_INTENCLR_IN2_Msk (0x1UL << GPIOTE_INTENCLR_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define GPIOTE_INTENCLR_IN2_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN2_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN2_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for IN[1] event */ -#define GPIOTE_INTENCLR_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define GPIOTE_INTENCLR_IN1_Msk (0x1UL << GPIOTE_INTENCLR_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define GPIOTE_INTENCLR_IN1_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN1_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN1_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for IN[0] event */ -#define GPIOTE_INTENCLR_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define GPIOTE_INTENCLR_IN0_Msk (0x1UL << GPIOTE_INTENCLR_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define GPIOTE_INTENCLR_IN0_Disabled (0UL) /*!< Read: Disabled */ -#define GPIOTE_INTENCLR_IN0_Enabled (1UL) /*!< Read: Enabled */ -#define GPIOTE_INTENCLR_IN0_Clear (1UL) /*!< Disable */ - -/* Register: GPIOTE_CONFIG */ -/* Description: Description collection[0]: Configuration for OUT[n], SET[n] and CLR[n] tasks and IN[n] event */ - -/* Bit 20 : When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect. */ -#define GPIOTE_CONFIG_OUTINIT_Pos (20UL) /*!< Position of OUTINIT field. */ -#define GPIOTE_CONFIG_OUTINIT_Msk (0x1UL << GPIOTE_CONFIG_OUTINIT_Pos) /*!< Bit mask of OUTINIT field. */ -#define GPIOTE_CONFIG_OUTINIT_Low (0UL) /*!< Task mode: Initial value of pin before task triggering is low */ -#define GPIOTE_CONFIG_OUTINIT_High (1UL) /*!< Task mode: Initial value of pin before task triggering is high */ - -/* Bits 17..16 : When In task mode: Operation to be performed on output when OUT[n] task is triggered. When In event mode: Operation on input that shall trigger IN[n] event. */ -#define GPIOTE_CONFIG_POLARITY_Pos (16UL) /*!< Position of POLARITY field. */ -#define GPIOTE_CONFIG_POLARITY_Msk (0x3UL << GPIOTE_CONFIG_POLARITY_Pos) /*!< Bit mask of POLARITY field. */ -#define GPIOTE_CONFIG_POLARITY_None (0UL) /*!< Task mode: No effect on pin from OUT[n] task. Event mode: no IN[n] event generated on pin activity. */ -#define GPIOTE_CONFIG_POLARITY_LoToHi (1UL) /*!< Task mode: Set pin from OUT[n] task. Event mode: Generate IN[n] event when rising edge on pin. */ -#define GPIOTE_CONFIG_POLARITY_HiToLo (2UL) /*!< Task mode: Clear pin from OUT[n] task. Event mode: Generate IN[n] event when falling edge on pin. */ -#define GPIOTE_CONFIG_POLARITY_Toggle (3UL) /*!< Task mode: Toggle pin from OUT[n]. Event mode: Generate IN[n] when any change on pin. */ - -/* Bit 13 : Port number */ -#define GPIOTE_CONFIG_PORT_Pos (13UL) /*!< Position of PORT field. */ -#define GPIOTE_CONFIG_PORT_Msk (0x1UL << GPIOTE_CONFIG_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 12..8 : GPIO number associated with SET[n], CLR[n] and OUT[n] tasks and IN[n] event */ -#define GPIOTE_CONFIG_PSEL_Pos (8UL) /*!< Position of PSEL field. */ -#define GPIOTE_CONFIG_PSEL_Msk (0x1FUL << GPIOTE_CONFIG_PSEL_Pos) /*!< Bit mask of PSEL field. */ - -/* Bits 1..0 : Mode */ -#define GPIOTE_CONFIG_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define GPIOTE_CONFIG_MODE_Msk (0x3UL << GPIOTE_CONFIG_MODE_Pos) /*!< Bit mask of MODE field. */ -#define GPIOTE_CONFIG_MODE_Disabled (0UL) /*!< Disabled. Pin specified by PSEL will not be acquired by the GPIOTE module. */ -#define GPIOTE_CONFIG_MODE_Event (1UL) /*!< Event mode */ -#define GPIOTE_CONFIG_MODE_Task (3UL) /*!< Task mode */ - - -/* Peripheral: I2S */ -/* Description: Inter-IC Sound */ - -/* Register: I2S_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 5 : Enable or disable interrupt for TXPTRUPD event */ -#define I2S_INTEN_TXPTRUPD_Pos (5UL) /*!< Position of TXPTRUPD field. */ -#define I2S_INTEN_TXPTRUPD_Msk (0x1UL << I2S_INTEN_TXPTRUPD_Pos) /*!< Bit mask of TXPTRUPD field. */ -#define I2S_INTEN_TXPTRUPD_Disabled (0UL) /*!< Disable */ -#define I2S_INTEN_TXPTRUPD_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for STOPPED event */ -#define I2S_INTEN_STOPPED_Pos (2UL) /*!< Position of STOPPED field. */ -#define I2S_INTEN_STOPPED_Msk (0x1UL << I2S_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define I2S_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define I2S_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for RXPTRUPD event */ -#define I2S_INTEN_RXPTRUPD_Pos (1UL) /*!< Position of RXPTRUPD field. */ -#define I2S_INTEN_RXPTRUPD_Msk (0x1UL << I2S_INTEN_RXPTRUPD_Pos) /*!< Bit mask of RXPTRUPD field. */ -#define I2S_INTEN_RXPTRUPD_Disabled (0UL) /*!< Disable */ -#define I2S_INTEN_RXPTRUPD_Enabled (1UL) /*!< Enable */ - -/* Register: I2S_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 5 : Write '1' to Enable interrupt for TXPTRUPD event */ -#define I2S_INTENSET_TXPTRUPD_Pos (5UL) /*!< Position of TXPTRUPD field. */ -#define I2S_INTENSET_TXPTRUPD_Msk (0x1UL << I2S_INTENSET_TXPTRUPD_Pos) /*!< Bit mask of TXPTRUPD field. */ -#define I2S_INTENSET_TXPTRUPD_Disabled (0UL) /*!< Read: Disabled */ -#define I2S_INTENSET_TXPTRUPD_Enabled (1UL) /*!< Read: Enabled */ -#define I2S_INTENSET_TXPTRUPD_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for STOPPED event */ -#define I2S_INTENSET_STOPPED_Pos (2UL) /*!< Position of STOPPED field. */ -#define I2S_INTENSET_STOPPED_Msk (0x1UL << I2S_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define I2S_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define I2S_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define I2S_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for RXPTRUPD event */ -#define I2S_INTENSET_RXPTRUPD_Pos (1UL) /*!< Position of RXPTRUPD field. */ -#define I2S_INTENSET_RXPTRUPD_Msk (0x1UL << I2S_INTENSET_RXPTRUPD_Pos) /*!< Bit mask of RXPTRUPD field. */ -#define I2S_INTENSET_RXPTRUPD_Disabled (0UL) /*!< Read: Disabled */ -#define I2S_INTENSET_RXPTRUPD_Enabled (1UL) /*!< Read: Enabled */ -#define I2S_INTENSET_RXPTRUPD_Set (1UL) /*!< Enable */ - -/* Register: I2S_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 5 : Write '1' to Disable interrupt for TXPTRUPD event */ -#define I2S_INTENCLR_TXPTRUPD_Pos (5UL) /*!< Position of TXPTRUPD field. */ -#define I2S_INTENCLR_TXPTRUPD_Msk (0x1UL << I2S_INTENCLR_TXPTRUPD_Pos) /*!< Bit mask of TXPTRUPD field. */ -#define I2S_INTENCLR_TXPTRUPD_Disabled (0UL) /*!< Read: Disabled */ -#define I2S_INTENCLR_TXPTRUPD_Enabled (1UL) /*!< Read: Enabled */ -#define I2S_INTENCLR_TXPTRUPD_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for STOPPED event */ -#define I2S_INTENCLR_STOPPED_Pos (2UL) /*!< Position of STOPPED field. */ -#define I2S_INTENCLR_STOPPED_Msk (0x1UL << I2S_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define I2S_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define I2S_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define I2S_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for RXPTRUPD event */ -#define I2S_INTENCLR_RXPTRUPD_Pos (1UL) /*!< Position of RXPTRUPD field. */ -#define I2S_INTENCLR_RXPTRUPD_Msk (0x1UL << I2S_INTENCLR_RXPTRUPD_Pos) /*!< Bit mask of RXPTRUPD field. */ -#define I2S_INTENCLR_RXPTRUPD_Disabled (0UL) /*!< Read: Disabled */ -#define I2S_INTENCLR_RXPTRUPD_Enabled (1UL) /*!< Read: Enabled */ -#define I2S_INTENCLR_RXPTRUPD_Clear (1UL) /*!< Disable */ - -/* Register: I2S_ENABLE */ -/* Description: Enable I2S module. */ - -/* Bit 0 : Enable I2S module. */ -#define I2S_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define I2S_ENABLE_ENABLE_Msk (0x1UL << I2S_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define I2S_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define I2S_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: I2S_CONFIG_MODE */ -/* Description: I2S mode. */ - -/* Bit 0 : I2S mode. */ -#define I2S_CONFIG_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define I2S_CONFIG_MODE_MODE_Msk (0x1UL << I2S_CONFIG_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define I2S_CONFIG_MODE_MODE_Master (0UL) /*!< Master mode. SCK and LRCK generated from internal master clcok (MCK) and output on pins defined by PSEL.xxx. */ -#define I2S_CONFIG_MODE_MODE_Slave (1UL) /*!< Slave mode. SCK and LRCK generated by external master and received on pins defined by PSEL.xxx */ - -/* Register: I2S_CONFIG_RXEN */ -/* Description: Reception (RX) enable. */ - -/* Bit 0 : Reception (RX) enable. */ -#define I2S_CONFIG_RXEN_RXEN_Pos (0UL) /*!< Position of RXEN field. */ -#define I2S_CONFIG_RXEN_RXEN_Msk (0x1UL << I2S_CONFIG_RXEN_RXEN_Pos) /*!< Bit mask of RXEN field. */ -#define I2S_CONFIG_RXEN_RXEN_Disabled (0UL) /*!< Reception disabled and now data will be written to the RXD.PTR address. */ -#define I2S_CONFIG_RXEN_RXEN_Enabled (1UL) /*!< Reception enabled. */ - -/* Register: I2S_CONFIG_TXEN */ -/* Description: Transmission (TX) enable. */ - -/* Bit 0 : Transmission (TX) enable. */ -#define I2S_CONFIG_TXEN_TXEN_Pos (0UL) /*!< Position of TXEN field. */ -#define I2S_CONFIG_TXEN_TXEN_Msk (0x1UL << I2S_CONFIG_TXEN_TXEN_Pos) /*!< Bit mask of TXEN field. */ -#define I2S_CONFIG_TXEN_TXEN_Disabled (0UL) /*!< Transmission disabled and now data will be read from the RXD.TXD address. */ -#define I2S_CONFIG_TXEN_TXEN_Enabled (1UL) /*!< Transmission enabled. */ - -/* Register: I2S_CONFIG_MCKEN */ -/* Description: Master clock generator enable. */ - -/* Bit 0 : Master clock generator enable. */ -#define I2S_CONFIG_MCKEN_MCKEN_Pos (0UL) /*!< Position of MCKEN field. */ -#define I2S_CONFIG_MCKEN_MCKEN_Msk (0x1UL << I2S_CONFIG_MCKEN_MCKEN_Pos) /*!< Bit mask of MCKEN field. */ -#define I2S_CONFIG_MCKEN_MCKEN_Disabled (0UL) /*!< Master clock generator disabled and PSEL.MCK not connected(available as GPIO). */ -#define I2S_CONFIG_MCKEN_MCKEN_Enabled (1UL) /*!< Master clock generator running and MCK output on PSEL.MCK. */ - -/* Register: I2S_CONFIG_MCKFREQ */ -/* Description: Master clock generator frequency. */ - -/* Bits 31..0 : Master clock generator frequency. */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_Pos (0UL) /*!< Position of MCKFREQ field. */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_Msk (0xFFFFFFFFUL << I2S_CONFIG_MCKFREQ_MCKFREQ_Pos) /*!< Bit mask of MCKFREQ field. */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV125 (0x020C0000UL) /*!< 32 MHz / 125 = 0.256 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV63 (0x04100000UL) /*!< 32 MHz / 63 = 0.5079365 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV42 (0x06000000UL) /*!< 32 MHz / 42 = 0.7619048 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV32 (0x08000000UL) /*!< 32 MHz / 32 = 1.0 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV31 (0x08400000UL) /*!< 32 MHz / 31 = 1.0322581 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV30 (0x08800000UL) /*!< 32 MHz / 30 = 1.0666667 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV23 (0x0B000000UL) /*!< 32 MHz / 23 = 1.3913043 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV21 (0x0C000000UL) /*!< 32 MHz / 21 = 1.5238095 */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV16 (0x10000000UL) /*!< 32 MHz / 16 = 2.0 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV15 (0x11000000UL) /*!< 32 MHz / 15 = 2.1333333 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV11 (0x16000000UL) /*!< 32 MHz / 11 = 2.9090909 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV10 (0x18000000UL) /*!< 32 MHz / 10 = 3.2 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV8 (0x20000000UL) /*!< 32 MHz / 8 = 4.0 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV6 (0x28000000UL) /*!< 32 MHz / 6 = 5.3333333 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV5 (0x30000000UL) /*!< 32 MHz / 5 = 6.4 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV4 (0x40000000UL) /*!< 32 MHz / 4 = 8.0 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV3 (0x50000000UL) /*!< 32 MHz / 3 = 10.6666667 MHz */ -#define I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV2 (0x80000000UL) /*!< 32 MHz / 2 = 16.0 MHz */ - -/* Register: I2S_CONFIG_RATIO */ -/* Description: MCK / LRCK ratio. */ - -/* Bits 3..0 : MCK / LRCK ratio. */ -#define I2S_CONFIG_RATIO_RATIO_Pos (0UL) /*!< Position of RATIO field. */ -#define I2S_CONFIG_RATIO_RATIO_Msk (0xFUL << I2S_CONFIG_RATIO_RATIO_Pos) /*!< Bit mask of RATIO field. */ -#define I2S_CONFIG_RATIO_RATIO_32X (0UL) /*!< LRCK = MCK / 32 */ -#define I2S_CONFIG_RATIO_RATIO_48X (1UL) /*!< LRCK = MCK / 48 */ -#define I2S_CONFIG_RATIO_RATIO_64X (2UL) /*!< LRCK = MCK / 64 */ -#define I2S_CONFIG_RATIO_RATIO_96X (3UL) /*!< LRCK = MCK / 96 */ -#define I2S_CONFIG_RATIO_RATIO_128X (4UL) /*!< LRCK = MCK / 128 */ -#define I2S_CONFIG_RATIO_RATIO_192X (5UL) /*!< LRCK = MCK / 192 */ -#define I2S_CONFIG_RATIO_RATIO_256X (6UL) /*!< LRCK = MCK / 256 */ -#define I2S_CONFIG_RATIO_RATIO_384X (7UL) /*!< LRCK = MCK / 384 */ -#define I2S_CONFIG_RATIO_RATIO_512X (8UL) /*!< LRCK = MCK / 512 */ - -/* Register: I2S_CONFIG_SWIDTH */ -/* Description: Sample width. */ - -/* Bits 1..0 : Sample width. */ -#define I2S_CONFIG_SWIDTH_SWIDTH_Pos (0UL) /*!< Position of SWIDTH field. */ -#define I2S_CONFIG_SWIDTH_SWIDTH_Msk (0x3UL << I2S_CONFIG_SWIDTH_SWIDTH_Pos) /*!< Bit mask of SWIDTH field. */ -#define I2S_CONFIG_SWIDTH_SWIDTH_8Bit (0UL) /*!< 8 bit. */ -#define I2S_CONFIG_SWIDTH_SWIDTH_16Bit (1UL) /*!< 16 bit. */ -#define I2S_CONFIG_SWIDTH_SWIDTH_24Bit (2UL) /*!< 24 bit. */ - -/* Register: I2S_CONFIG_ALIGN */ -/* Description: Alignment of sample within a frame. */ - -/* Bit 0 : Alignment of sample within a frame. */ -#define I2S_CONFIG_ALIGN_ALIGN_Pos (0UL) /*!< Position of ALIGN field. */ -#define I2S_CONFIG_ALIGN_ALIGN_Msk (0x1UL << I2S_CONFIG_ALIGN_ALIGN_Pos) /*!< Bit mask of ALIGN field. */ -#define I2S_CONFIG_ALIGN_ALIGN_Left (0UL) /*!< Left-aligned. */ -#define I2S_CONFIG_ALIGN_ALIGN_Right (1UL) /*!< Right-aligned. */ - -/* Register: I2S_CONFIG_FORMAT */ -/* Description: Frame format. */ - -/* Bit 0 : Frame format. */ -#define I2S_CONFIG_FORMAT_FORMAT_Pos (0UL) /*!< Position of FORMAT field. */ -#define I2S_CONFIG_FORMAT_FORMAT_Msk (0x1UL << I2S_CONFIG_FORMAT_FORMAT_Pos) /*!< Bit mask of FORMAT field. */ -#define I2S_CONFIG_FORMAT_FORMAT_I2S (0UL) /*!< Original I2S format. */ -#define I2S_CONFIG_FORMAT_FORMAT_Aligned (1UL) /*!< Alternate (left- or right-aligned) format. */ - -/* Register: I2S_CONFIG_CHANNELS */ -/* Description: Enable channels. */ - -/* Bits 1..0 : Enable channels. */ -#define I2S_CONFIG_CHANNELS_CHANNELS_Pos (0UL) /*!< Position of CHANNELS field. */ -#define I2S_CONFIG_CHANNELS_CHANNELS_Msk (0x3UL << I2S_CONFIG_CHANNELS_CHANNELS_Pos) /*!< Bit mask of CHANNELS field. */ -#define I2S_CONFIG_CHANNELS_CHANNELS_Stereo (0UL) /*!< Stereo. */ -#define I2S_CONFIG_CHANNELS_CHANNELS_Left (1UL) /*!< Left only. */ -#define I2S_CONFIG_CHANNELS_CHANNELS_Right (2UL) /*!< Right only. */ - -/* Register: I2S_RXD_PTR */ -/* Description: Receive buffer RAM start address. */ - -/* Bits 31..0 : Receive buffer Data RAM start address. When receiving, words containing samples will be written to this address. This address is a word aligned Data RAM address. */ -#define I2S_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define I2S_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << I2S_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: I2S_TXD_PTR */ -/* Description: Transmit buffer RAM start address. */ - -/* Bits 31..0 : Transmit buffer Data RAM start address. When transmitting, words containing samples will be fetched from this address. This address is a word aligned Data RAM address. */ -#define I2S_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define I2S_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << I2S_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: I2S_RXTXD_MAXCNT */ -/* Description: Size of RXD and TXD buffers. */ - -/* Bits 13..0 : Size of RXD and TXD buffers in number of 32 bit words. */ -#define I2S_RXTXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define I2S_RXTXD_MAXCNT_MAXCNT_Msk (0x3FFFUL << I2S_RXTXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: I2S_PSEL_MCK */ -/* Description: Pin select for MCK signal. */ - -/* Bit 31 : Connection */ -#define I2S_PSEL_MCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define I2S_PSEL_MCK_CONNECT_Msk (0x1UL << I2S_PSEL_MCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define I2S_PSEL_MCK_CONNECT_Connected (0UL) /*!< Connect */ -#define I2S_PSEL_MCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 8 : Port number */ -#define I2S_PSEL_MCK_PORT_Pos (8UL) /*!< Position of PORT field. */ -#define I2S_PSEL_MCK_PORT_Msk (0x1UL << I2S_PSEL_MCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define I2S_PSEL_MCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define I2S_PSEL_MCK_PIN_Msk (0x1FUL << I2S_PSEL_MCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: I2S_PSEL_SCK */ -/* Description: Pin select for SCK signal. */ - -/* Bit 31 : Connection */ -#define I2S_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define I2S_PSEL_SCK_CONNECT_Msk (0x1UL << I2S_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define I2S_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define I2S_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 8 : Port number */ -#define I2S_PSEL_SCK_PORT_Pos (8UL) /*!< Position of PORT field. */ -#define I2S_PSEL_SCK_PORT_Msk (0x1UL << I2S_PSEL_SCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define I2S_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define I2S_PSEL_SCK_PIN_Msk (0x1FUL << I2S_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: I2S_PSEL_LRCK */ -/* Description: Pin select for LRCK signal. */ - -/* Bit 31 : Connection */ -#define I2S_PSEL_LRCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define I2S_PSEL_LRCK_CONNECT_Msk (0x1UL << I2S_PSEL_LRCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define I2S_PSEL_LRCK_CONNECT_Connected (0UL) /*!< Connect */ -#define I2S_PSEL_LRCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 8 : Port number */ -#define I2S_PSEL_LRCK_PORT_Pos (8UL) /*!< Position of PORT field. */ -#define I2S_PSEL_LRCK_PORT_Msk (0x1UL << I2S_PSEL_LRCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define I2S_PSEL_LRCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define I2S_PSEL_LRCK_PIN_Msk (0x1FUL << I2S_PSEL_LRCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: I2S_PSEL_SDIN */ -/* Description: Pin select for SDIN signal. */ - -/* Bit 31 : Connection */ -#define I2S_PSEL_SDIN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define I2S_PSEL_SDIN_CONNECT_Msk (0x1UL << I2S_PSEL_SDIN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define I2S_PSEL_SDIN_CONNECT_Connected (0UL) /*!< Connect */ -#define I2S_PSEL_SDIN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 8 : Port number */ -#define I2S_PSEL_SDIN_PORT_Pos (8UL) /*!< Position of PORT field. */ -#define I2S_PSEL_SDIN_PORT_Msk (0x1UL << I2S_PSEL_SDIN_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define I2S_PSEL_SDIN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define I2S_PSEL_SDIN_PIN_Msk (0x1FUL << I2S_PSEL_SDIN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: I2S_PSEL_SDOUT */ -/* Description: Pin select for SDOUT signal. */ - -/* Bit 31 : Connection */ -#define I2S_PSEL_SDOUT_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define I2S_PSEL_SDOUT_CONNECT_Msk (0x1UL << I2S_PSEL_SDOUT_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define I2S_PSEL_SDOUT_CONNECT_Connected (0UL) /*!< Connect */ -#define I2S_PSEL_SDOUT_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 8 : Port number */ -#define I2S_PSEL_SDOUT_PORT_Pos (8UL) /*!< Position of PORT field. */ -#define I2S_PSEL_SDOUT_PORT_Msk (0x1UL << I2S_PSEL_SDOUT_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define I2S_PSEL_SDOUT_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define I2S_PSEL_SDOUT_PIN_Msk (0x1FUL << I2S_PSEL_SDOUT_PIN_Pos) /*!< Bit mask of PIN field. */ - - -/* Peripheral: LPCOMP */ -/* Description: Low Power Comparator */ - -/* Register: LPCOMP_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between CROSS event and STOP task */ -#define LPCOMP_SHORTS_CROSS_STOP_Pos (4UL) /*!< Position of CROSS_STOP field. */ -#define LPCOMP_SHORTS_CROSS_STOP_Msk (0x1UL << LPCOMP_SHORTS_CROSS_STOP_Pos) /*!< Bit mask of CROSS_STOP field. */ -#define LPCOMP_SHORTS_CROSS_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define LPCOMP_SHORTS_CROSS_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between UP event and STOP task */ -#define LPCOMP_SHORTS_UP_STOP_Pos (3UL) /*!< Position of UP_STOP field. */ -#define LPCOMP_SHORTS_UP_STOP_Msk (0x1UL << LPCOMP_SHORTS_UP_STOP_Pos) /*!< Bit mask of UP_STOP field. */ -#define LPCOMP_SHORTS_UP_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define LPCOMP_SHORTS_UP_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between DOWN event and STOP task */ -#define LPCOMP_SHORTS_DOWN_STOP_Pos (2UL) /*!< Position of DOWN_STOP field. */ -#define LPCOMP_SHORTS_DOWN_STOP_Msk (0x1UL << LPCOMP_SHORTS_DOWN_STOP_Pos) /*!< Bit mask of DOWN_STOP field. */ -#define LPCOMP_SHORTS_DOWN_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define LPCOMP_SHORTS_DOWN_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between READY event and STOP task */ -#define LPCOMP_SHORTS_READY_STOP_Pos (1UL) /*!< Position of READY_STOP field. */ -#define LPCOMP_SHORTS_READY_STOP_Msk (0x1UL << LPCOMP_SHORTS_READY_STOP_Pos) /*!< Bit mask of READY_STOP field. */ -#define LPCOMP_SHORTS_READY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define LPCOMP_SHORTS_READY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between READY event and SAMPLE task */ -#define LPCOMP_SHORTS_READY_SAMPLE_Pos (0UL) /*!< Position of READY_SAMPLE field. */ -#define LPCOMP_SHORTS_READY_SAMPLE_Msk (0x1UL << LPCOMP_SHORTS_READY_SAMPLE_Pos) /*!< Bit mask of READY_SAMPLE field. */ -#define LPCOMP_SHORTS_READY_SAMPLE_Disabled (0UL) /*!< Disable shortcut */ -#define LPCOMP_SHORTS_READY_SAMPLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: LPCOMP_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 3 : Write '1' to Enable interrupt for CROSS event */ -#define LPCOMP_INTENSET_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define LPCOMP_INTENSET_CROSS_Msk (0x1UL << LPCOMP_INTENSET_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define LPCOMP_INTENSET_CROSS_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENSET_CROSS_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENSET_CROSS_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for UP event */ -#define LPCOMP_INTENSET_UP_Pos (2UL) /*!< Position of UP field. */ -#define LPCOMP_INTENSET_UP_Msk (0x1UL << LPCOMP_INTENSET_UP_Pos) /*!< Bit mask of UP field. */ -#define LPCOMP_INTENSET_UP_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENSET_UP_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENSET_UP_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for DOWN event */ -#define LPCOMP_INTENSET_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define LPCOMP_INTENSET_DOWN_Msk (0x1UL << LPCOMP_INTENSET_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define LPCOMP_INTENSET_DOWN_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENSET_DOWN_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENSET_DOWN_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define LPCOMP_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define LPCOMP_INTENSET_READY_Msk (0x1UL << LPCOMP_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define LPCOMP_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: LPCOMP_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 3 : Write '1' to Disable interrupt for CROSS event */ -#define LPCOMP_INTENCLR_CROSS_Pos (3UL) /*!< Position of CROSS field. */ -#define LPCOMP_INTENCLR_CROSS_Msk (0x1UL << LPCOMP_INTENCLR_CROSS_Pos) /*!< Bit mask of CROSS field. */ -#define LPCOMP_INTENCLR_CROSS_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENCLR_CROSS_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENCLR_CROSS_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for UP event */ -#define LPCOMP_INTENCLR_UP_Pos (2UL) /*!< Position of UP field. */ -#define LPCOMP_INTENCLR_UP_Msk (0x1UL << LPCOMP_INTENCLR_UP_Pos) /*!< Bit mask of UP field. */ -#define LPCOMP_INTENCLR_UP_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENCLR_UP_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENCLR_UP_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for DOWN event */ -#define LPCOMP_INTENCLR_DOWN_Pos (1UL) /*!< Position of DOWN field. */ -#define LPCOMP_INTENCLR_DOWN_Msk (0x1UL << LPCOMP_INTENCLR_DOWN_Pos) /*!< Bit mask of DOWN field. */ -#define LPCOMP_INTENCLR_DOWN_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENCLR_DOWN_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENCLR_DOWN_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define LPCOMP_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define LPCOMP_INTENCLR_READY_Msk (0x1UL << LPCOMP_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define LPCOMP_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define LPCOMP_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define LPCOMP_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: LPCOMP_RESULT */ -/* Description: Compare result */ - -/* Bit 0 : Result of last compare. Decision point SAMPLE task. */ -#define LPCOMP_RESULT_RESULT_Pos (0UL) /*!< Position of RESULT field. */ -#define LPCOMP_RESULT_RESULT_Msk (0x1UL << LPCOMP_RESULT_RESULT_Pos) /*!< Bit mask of RESULT field. */ -#define LPCOMP_RESULT_RESULT_Below (0UL) /*!< Input voltage is below the reference threshold (VIN+ < VIN-). */ -#define LPCOMP_RESULT_RESULT_Above (1UL) /*!< Input voltage is above the reference threshold (VIN+ > VIN-). */ - -/* Register: LPCOMP_ENABLE */ -/* Description: Enable LPCOMP */ - -/* Bits 1..0 : Enable or disable LPCOMP */ -#define LPCOMP_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define LPCOMP_ENABLE_ENABLE_Msk (0x3UL << LPCOMP_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define LPCOMP_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define LPCOMP_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: LPCOMP_PSEL */ -/* Description: Input pin select */ - -/* Bits 2..0 : Analog pin select */ -#define LPCOMP_PSEL_PSEL_Pos (0UL) /*!< Position of PSEL field. */ -#define LPCOMP_PSEL_PSEL_Msk (0x7UL << LPCOMP_PSEL_PSEL_Pos) /*!< Bit mask of PSEL field. */ -#define LPCOMP_PSEL_PSEL_AnalogInput0 (0UL) /*!< AIN0 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput1 (1UL) /*!< AIN1 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput2 (2UL) /*!< AIN2 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput3 (3UL) /*!< AIN3 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput4 (4UL) /*!< AIN4 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput5 (5UL) /*!< AIN5 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput6 (6UL) /*!< AIN6 selected as analog input */ -#define LPCOMP_PSEL_PSEL_AnalogInput7 (7UL) /*!< AIN7 selected as analog input */ - -/* Register: LPCOMP_REFSEL */ -/* Description: Reference select */ - -/* Bits 3..0 : Reference select */ -#define LPCOMP_REFSEL_REFSEL_Pos (0UL) /*!< Position of REFSEL field. */ -#define LPCOMP_REFSEL_REFSEL_Msk (0xFUL << LPCOMP_REFSEL_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define LPCOMP_REFSEL_REFSEL_Ref1_8Vdd (0UL) /*!< VDD * 1/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref2_8Vdd (1UL) /*!< VDD * 2/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref3_8Vdd (2UL) /*!< VDD * 3/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref4_8Vdd (3UL) /*!< VDD * 4/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref5_8Vdd (4UL) /*!< VDD * 5/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref6_8Vdd (5UL) /*!< VDD * 6/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref7_8Vdd (6UL) /*!< VDD * 7/8 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_ARef (7UL) /*!< External analog reference selected */ -#define LPCOMP_REFSEL_REFSEL_Ref1_16Vdd (8UL) /*!< VDD * 1/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref3_16Vdd (9UL) /*!< VDD * 3/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref5_16Vdd (10UL) /*!< VDD * 5/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref7_16Vdd (11UL) /*!< VDD * 7/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref9_16Vdd (12UL) /*!< VDD * 9/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref11_16Vdd (13UL) /*!< VDD * 11/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref13_16Vdd (14UL) /*!< VDD * 13/16 selected as reference */ -#define LPCOMP_REFSEL_REFSEL_Ref15_16Vdd (15UL) /*!< VDD * 15/16 selected as reference */ - -/* Register: LPCOMP_EXTREFSEL */ -/* Description: External reference select */ - -/* Bit 0 : External analog reference select */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_Pos (0UL) /*!< Position of EXTREFSEL field. */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_Msk (0x1UL << LPCOMP_EXTREFSEL_EXTREFSEL_Pos) /*!< Bit mask of EXTREFSEL field. */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference0 (0UL) /*!< Use AIN0 as external analog reference */ -#define LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference1 (1UL) /*!< Use AIN1 as external analog reference */ - -/* Register: LPCOMP_ANADETECT */ -/* Description: Analog detect configuration */ - -/* Bits 1..0 : Analog detect configuration */ -#define LPCOMP_ANADETECT_ANADETECT_Pos (0UL) /*!< Position of ANADETECT field. */ -#define LPCOMP_ANADETECT_ANADETECT_Msk (0x3UL << LPCOMP_ANADETECT_ANADETECT_Pos) /*!< Bit mask of ANADETECT field. */ -#define LPCOMP_ANADETECT_ANADETECT_Cross (0UL) /*!< Generate ANADETECT on crossing, both upward crossing and downward crossing */ -#define LPCOMP_ANADETECT_ANADETECT_Up (1UL) /*!< Generate ANADETECT on upward crossing only */ -#define LPCOMP_ANADETECT_ANADETECT_Down (2UL) /*!< Generate ANADETECT on downward crossing only */ - -/* Register: LPCOMP_HYST */ -/* Description: Comparator hysteresis enable */ - -/* Bit 0 : Comparator hysteresis enable */ -#define LPCOMP_HYST_HYST_Pos (0UL) /*!< Position of HYST field. */ -#define LPCOMP_HYST_HYST_Msk (0x1UL << LPCOMP_HYST_HYST_Pos) /*!< Bit mask of HYST field. */ -#define LPCOMP_HYST_HYST_Disabled (0UL) /*!< Comparator hysteresis disabled */ -#define LPCOMP_HYST_HYST_Enabled (1UL) /*!< Comparator hysteresis enabled */ - - -/* Peripheral: MWU */ -/* Description: Memory Watch Unit */ - -/* Register: MWU_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 27 : Enable or disable interrupt for PREGION[1].RA event */ -#define MWU_INTEN_PREGION1RA_Pos (27UL) /*!< Position of PREGION1RA field. */ -#define MWU_INTEN_PREGION1RA_Msk (0x1UL << MWU_INTEN_PREGION1RA_Pos) /*!< Bit mask of PREGION1RA field. */ -#define MWU_INTEN_PREGION1RA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_PREGION1RA_Enabled (1UL) /*!< Enable */ - -/* Bit 26 : Enable or disable interrupt for PREGION[1].WA event */ -#define MWU_INTEN_PREGION1WA_Pos (26UL) /*!< Position of PREGION1WA field. */ -#define MWU_INTEN_PREGION1WA_Msk (0x1UL << MWU_INTEN_PREGION1WA_Pos) /*!< Bit mask of PREGION1WA field. */ -#define MWU_INTEN_PREGION1WA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_PREGION1WA_Enabled (1UL) /*!< Enable */ - -/* Bit 25 : Enable or disable interrupt for PREGION[0].RA event */ -#define MWU_INTEN_PREGION0RA_Pos (25UL) /*!< Position of PREGION0RA field. */ -#define MWU_INTEN_PREGION0RA_Msk (0x1UL << MWU_INTEN_PREGION0RA_Pos) /*!< Bit mask of PREGION0RA field. */ -#define MWU_INTEN_PREGION0RA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_PREGION0RA_Enabled (1UL) /*!< Enable */ - -/* Bit 24 : Enable or disable interrupt for PREGION[0].WA event */ -#define MWU_INTEN_PREGION0WA_Pos (24UL) /*!< Position of PREGION0WA field. */ -#define MWU_INTEN_PREGION0WA_Msk (0x1UL << MWU_INTEN_PREGION0WA_Pos) /*!< Bit mask of PREGION0WA field. */ -#define MWU_INTEN_PREGION0WA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_PREGION0WA_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for REGION[3].RA event */ -#define MWU_INTEN_REGION3RA_Pos (7UL) /*!< Position of REGION3RA field. */ -#define MWU_INTEN_REGION3RA_Msk (0x1UL << MWU_INTEN_REGION3RA_Pos) /*!< Bit mask of REGION3RA field. */ -#define MWU_INTEN_REGION3RA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION3RA_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for REGION[3].WA event */ -#define MWU_INTEN_REGION3WA_Pos (6UL) /*!< Position of REGION3WA field. */ -#define MWU_INTEN_REGION3WA_Msk (0x1UL << MWU_INTEN_REGION3WA_Pos) /*!< Bit mask of REGION3WA field. */ -#define MWU_INTEN_REGION3WA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION3WA_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for REGION[2].RA event */ -#define MWU_INTEN_REGION2RA_Pos (5UL) /*!< Position of REGION2RA field. */ -#define MWU_INTEN_REGION2RA_Msk (0x1UL << MWU_INTEN_REGION2RA_Pos) /*!< Bit mask of REGION2RA field. */ -#define MWU_INTEN_REGION2RA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION2RA_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for REGION[2].WA event */ -#define MWU_INTEN_REGION2WA_Pos (4UL) /*!< Position of REGION2WA field. */ -#define MWU_INTEN_REGION2WA_Msk (0x1UL << MWU_INTEN_REGION2WA_Pos) /*!< Bit mask of REGION2WA field. */ -#define MWU_INTEN_REGION2WA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION2WA_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for REGION[1].RA event */ -#define MWU_INTEN_REGION1RA_Pos (3UL) /*!< Position of REGION1RA field. */ -#define MWU_INTEN_REGION1RA_Msk (0x1UL << MWU_INTEN_REGION1RA_Pos) /*!< Bit mask of REGION1RA field. */ -#define MWU_INTEN_REGION1RA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION1RA_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for REGION[1].WA event */ -#define MWU_INTEN_REGION1WA_Pos (2UL) /*!< Position of REGION1WA field. */ -#define MWU_INTEN_REGION1WA_Msk (0x1UL << MWU_INTEN_REGION1WA_Pos) /*!< Bit mask of REGION1WA field. */ -#define MWU_INTEN_REGION1WA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION1WA_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for REGION[0].RA event */ -#define MWU_INTEN_REGION0RA_Pos (1UL) /*!< Position of REGION0RA field. */ -#define MWU_INTEN_REGION0RA_Msk (0x1UL << MWU_INTEN_REGION0RA_Pos) /*!< Bit mask of REGION0RA field. */ -#define MWU_INTEN_REGION0RA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION0RA_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for REGION[0].WA event */ -#define MWU_INTEN_REGION0WA_Pos (0UL) /*!< Position of REGION0WA field. */ -#define MWU_INTEN_REGION0WA_Msk (0x1UL << MWU_INTEN_REGION0WA_Pos) /*!< Bit mask of REGION0WA field. */ -#define MWU_INTEN_REGION0WA_Disabled (0UL) /*!< Disable */ -#define MWU_INTEN_REGION0WA_Enabled (1UL) /*!< Enable */ - -/* Register: MWU_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 27 : Write '1' to Enable interrupt for PREGION[1].RA event */ -#define MWU_INTENSET_PREGION1RA_Pos (27UL) /*!< Position of PREGION1RA field. */ -#define MWU_INTENSET_PREGION1RA_Msk (0x1UL << MWU_INTENSET_PREGION1RA_Pos) /*!< Bit mask of PREGION1RA field. */ -#define MWU_INTENSET_PREGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_PREGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_PREGION1RA_Set (1UL) /*!< Enable */ - -/* Bit 26 : Write '1' to Enable interrupt for PREGION[1].WA event */ -#define MWU_INTENSET_PREGION1WA_Pos (26UL) /*!< Position of PREGION1WA field. */ -#define MWU_INTENSET_PREGION1WA_Msk (0x1UL << MWU_INTENSET_PREGION1WA_Pos) /*!< Bit mask of PREGION1WA field. */ -#define MWU_INTENSET_PREGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_PREGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_PREGION1WA_Set (1UL) /*!< Enable */ - -/* Bit 25 : Write '1' to Enable interrupt for PREGION[0].RA event */ -#define MWU_INTENSET_PREGION0RA_Pos (25UL) /*!< Position of PREGION0RA field. */ -#define MWU_INTENSET_PREGION0RA_Msk (0x1UL << MWU_INTENSET_PREGION0RA_Pos) /*!< Bit mask of PREGION0RA field. */ -#define MWU_INTENSET_PREGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_PREGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_PREGION0RA_Set (1UL) /*!< Enable */ - -/* Bit 24 : Write '1' to Enable interrupt for PREGION[0].WA event */ -#define MWU_INTENSET_PREGION0WA_Pos (24UL) /*!< Position of PREGION0WA field. */ -#define MWU_INTENSET_PREGION0WA_Msk (0x1UL << MWU_INTENSET_PREGION0WA_Pos) /*!< Bit mask of PREGION0WA field. */ -#define MWU_INTENSET_PREGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_PREGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_PREGION0WA_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for REGION[3].RA event */ -#define MWU_INTENSET_REGION3RA_Pos (7UL) /*!< Position of REGION3RA field. */ -#define MWU_INTENSET_REGION3RA_Msk (0x1UL << MWU_INTENSET_REGION3RA_Pos) /*!< Bit mask of REGION3RA field. */ -#define MWU_INTENSET_REGION3RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION3RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION3RA_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for REGION[3].WA event */ -#define MWU_INTENSET_REGION3WA_Pos (6UL) /*!< Position of REGION3WA field. */ -#define MWU_INTENSET_REGION3WA_Msk (0x1UL << MWU_INTENSET_REGION3WA_Pos) /*!< Bit mask of REGION3WA field. */ -#define MWU_INTENSET_REGION3WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION3WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION3WA_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for REGION[2].RA event */ -#define MWU_INTENSET_REGION2RA_Pos (5UL) /*!< Position of REGION2RA field. */ -#define MWU_INTENSET_REGION2RA_Msk (0x1UL << MWU_INTENSET_REGION2RA_Pos) /*!< Bit mask of REGION2RA field. */ -#define MWU_INTENSET_REGION2RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION2RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION2RA_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for REGION[2].WA event */ -#define MWU_INTENSET_REGION2WA_Pos (4UL) /*!< Position of REGION2WA field. */ -#define MWU_INTENSET_REGION2WA_Msk (0x1UL << MWU_INTENSET_REGION2WA_Pos) /*!< Bit mask of REGION2WA field. */ -#define MWU_INTENSET_REGION2WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION2WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION2WA_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for REGION[1].RA event */ -#define MWU_INTENSET_REGION1RA_Pos (3UL) /*!< Position of REGION1RA field. */ -#define MWU_INTENSET_REGION1RA_Msk (0x1UL << MWU_INTENSET_REGION1RA_Pos) /*!< Bit mask of REGION1RA field. */ -#define MWU_INTENSET_REGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION1RA_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for REGION[1].WA event */ -#define MWU_INTENSET_REGION1WA_Pos (2UL) /*!< Position of REGION1WA field. */ -#define MWU_INTENSET_REGION1WA_Msk (0x1UL << MWU_INTENSET_REGION1WA_Pos) /*!< Bit mask of REGION1WA field. */ -#define MWU_INTENSET_REGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION1WA_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for REGION[0].RA event */ -#define MWU_INTENSET_REGION0RA_Pos (1UL) /*!< Position of REGION0RA field. */ -#define MWU_INTENSET_REGION0RA_Msk (0x1UL << MWU_INTENSET_REGION0RA_Pos) /*!< Bit mask of REGION0RA field. */ -#define MWU_INTENSET_REGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION0RA_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for REGION[0].WA event */ -#define MWU_INTENSET_REGION0WA_Pos (0UL) /*!< Position of REGION0WA field. */ -#define MWU_INTENSET_REGION0WA_Msk (0x1UL << MWU_INTENSET_REGION0WA_Pos) /*!< Bit mask of REGION0WA field. */ -#define MWU_INTENSET_REGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENSET_REGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENSET_REGION0WA_Set (1UL) /*!< Enable */ - -/* Register: MWU_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 27 : Write '1' to Disable interrupt for PREGION[1].RA event */ -#define MWU_INTENCLR_PREGION1RA_Pos (27UL) /*!< Position of PREGION1RA field. */ -#define MWU_INTENCLR_PREGION1RA_Msk (0x1UL << MWU_INTENCLR_PREGION1RA_Pos) /*!< Bit mask of PREGION1RA field. */ -#define MWU_INTENCLR_PREGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_PREGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_PREGION1RA_Clear (1UL) /*!< Disable */ - -/* Bit 26 : Write '1' to Disable interrupt for PREGION[1].WA event */ -#define MWU_INTENCLR_PREGION1WA_Pos (26UL) /*!< Position of PREGION1WA field. */ -#define MWU_INTENCLR_PREGION1WA_Msk (0x1UL << MWU_INTENCLR_PREGION1WA_Pos) /*!< Bit mask of PREGION1WA field. */ -#define MWU_INTENCLR_PREGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_PREGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_PREGION1WA_Clear (1UL) /*!< Disable */ - -/* Bit 25 : Write '1' to Disable interrupt for PREGION[0].RA event */ -#define MWU_INTENCLR_PREGION0RA_Pos (25UL) /*!< Position of PREGION0RA field. */ -#define MWU_INTENCLR_PREGION0RA_Msk (0x1UL << MWU_INTENCLR_PREGION0RA_Pos) /*!< Bit mask of PREGION0RA field. */ -#define MWU_INTENCLR_PREGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_PREGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_PREGION0RA_Clear (1UL) /*!< Disable */ - -/* Bit 24 : Write '1' to Disable interrupt for PREGION[0].WA event */ -#define MWU_INTENCLR_PREGION0WA_Pos (24UL) /*!< Position of PREGION0WA field. */ -#define MWU_INTENCLR_PREGION0WA_Msk (0x1UL << MWU_INTENCLR_PREGION0WA_Pos) /*!< Bit mask of PREGION0WA field. */ -#define MWU_INTENCLR_PREGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_PREGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_PREGION0WA_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for REGION[3].RA event */ -#define MWU_INTENCLR_REGION3RA_Pos (7UL) /*!< Position of REGION3RA field. */ -#define MWU_INTENCLR_REGION3RA_Msk (0x1UL << MWU_INTENCLR_REGION3RA_Pos) /*!< Bit mask of REGION3RA field. */ -#define MWU_INTENCLR_REGION3RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION3RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION3RA_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for REGION[3].WA event */ -#define MWU_INTENCLR_REGION3WA_Pos (6UL) /*!< Position of REGION3WA field. */ -#define MWU_INTENCLR_REGION3WA_Msk (0x1UL << MWU_INTENCLR_REGION3WA_Pos) /*!< Bit mask of REGION3WA field. */ -#define MWU_INTENCLR_REGION3WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION3WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION3WA_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for REGION[2].RA event */ -#define MWU_INTENCLR_REGION2RA_Pos (5UL) /*!< Position of REGION2RA field. */ -#define MWU_INTENCLR_REGION2RA_Msk (0x1UL << MWU_INTENCLR_REGION2RA_Pos) /*!< Bit mask of REGION2RA field. */ -#define MWU_INTENCLR_REGION2RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION2RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION2RA_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for REGION[2].WA event */ -#define MWU_INTENCLR_REGION2WA_Pos (4UL) /*!< Position of REGION2WA field. */ -#define MWU_INTENCLR_REGION2WA_Msk (0x1UL << MWU_INTENCLR_REGION2WA_Pos) /*!< Bit mask of REGION2WA field. */ -#define MWU_INTENCLR_REGION2WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION2WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION2WA_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for REGION[1].RA event */ -#define MWU_INTENCLR_REGION1RA_Pos (3UL) /*!< Position of REGION1RA field. */ -#define MWU_INTENCLR_REGION1RA_Msk (0x1UL << MWU_INTENCLR_REGION1RA_Pos) /*!< Bit mask of REGION1RA field. */ -#define MWU_INTENCLR_REGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION1RA_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for REGION[1].WA event */ -#define MWU_INTENCLR_REGION1WA_Pos (2UL) /*!< Position of REGION1WA field. */ -#define MWU_INTENCLR_REGION1WA_Msk (0x1UL << MWU_INTENCLR_REGION1WA_Pos) /*!< Bit mask of REGION1WA field. */ -#define MWU_INTENCLR_REGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION1WA_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for REGION[0].RA event */ -#define MWU_INTENCLR_REGION0RA_Pos (1UL) /*!< Position of REGION0RA field. */ -#define MWU_INTENCLR_REGION0RA_Msk (0x1UL << MWU_INTENCLR_REGION0RA_Pos) /*!< Bit mask of REGION0RA field. */ -#define MWU_INTENCLR_REGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION0RA_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for REGION[0].WA event */ -#define MWU_INTENCLR_REGION0WA_Pos (0UL) /*!< Position of REGION0WA field. */ -#define MWU_INTENCLR_REGION0WA_Msk (0x1UL << MWU_INTENCLR_REGION0WA_Pos) /*!< Bit mask of REGION0WA field. */ -#define MWU_INTENCLR_REGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_INTENCLR_REGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_INTENCLR_REGION0WA_Clear (1UL) /*!< Disable */ - -/* Register: MWU_NMIEN */ -/* Description: Enable or disable non-maskable interrupt */ - -/* Bit 27 : Enable or disable non-maskable interrupt for PREGION[1].RA event */ -#define MWU_NMIEN_PREGION1RA_Pos (27UL) /*!< Position of PREGION1RA field. */ -#define MWU_NMIEN_PREGION1RA_Msk (0x1UL << MWU_NMIEN_PREGION1RA_Pos) /*!< Bit mask of PREGION1RA field. */ -#define MWU_NMIEN_PREGION1RA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_PREGION1RA_Enabled (1UL) /*!< Enable */ - -/* Bit 26 : Enable or disable non-maskable interrupt for PREGION[1].WA event */ -#define MWU_NMIEN_PREGION1WA_Pos (26UL) /*!< Position of PREGION1WA field. */ -#define MWU_NMIEN_PREGION1WA_Msk (0x1UL << MWU_NMIEN_PREGION1WA_Pos) /*!< Bit mask of PREGION1WA field. */ -#define MWU_NMIEN_PREGION1WA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_PREGION1WA_Enabled (1UL) /*!< Enable */ - -/* Bit 25 : Enable or disable non-maskable interrupt for PREGION[0].RA event */ -#define MWU_NMIEN_PREGION0RA_Pos (25UL) /*!< Position of PREGION0RA field. */ -#define MWU_NMIEN_PREGION0RA_Msk (0x1UL << MWU_NMIEN_PREGION0RA_Pos) /*!< Bit mask of PREGION0RA field. */ -#define MWU_NMIEN_PREGION0RA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_PREGION0RA_Enabled (1UL) /*!< Enable */ - -/* Bit 24 : Enable or disable non-maskable interrupt for PREGION[0].WA event */ -#define MWU_NMIEN_PREGION0WA_Pos (24UL) /*!< Position of PREGION0WA field. */ -#define MWU_NMIEN_PREGION0WA_Msk (0x1UL << MWU_NMIEN_PREGION0WA_Pos) /*!< Bit mask of PREGION0WA field. */ -#define MWU_NMIEN_PREGION0WA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_PREGION0WA_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable non-maskable interrupt for REGION[3].RA event */ -#define MWU_NMIEN_REGION3RA_Pos (7UL) /*!< Position of REGION3RA field. */ -#define MWU_NMIEN_REGION3RA_Msk (0x1UL << MWU_NMIEN_REGION3RA_Pos) /*!< Bit mask of REGION3RA field. */ -#define MWU_NMIEN_REGION3RA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION3RA_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable non-maskable interrupt for REGION[3].WA event */ -#define MWU_NMIEN_REGION3WA_Pos (6UL) /*!< Position of REGION3WA field. */ -#define MWU_NMIEN_REGION3WA_Msk (0x1UL << MWU_NMIEN_REGION3WA_Pos) /*!< Bit mask of REGION3WA field. */ -#define MWU_NMIEN_REGION3WA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION3WA_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable non-maskable interrupt for REGION[2].RA event */ -#define MWU_NMIEN_REGION2RA_Pos (5UL) /*!< Position of REGION2RA field. */ -#define MWU_NMIEN_REGION2RA_Msk (0x1UL << MWU_NMIEN_REGION2RA_Pos) /*!< Bit mask of REGION2RA field. */ -#define MWU_NMIEN_REGION2RA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION2RA_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable non-maskable interrupt for REGION[2].WA event */ -#define MWU_NMIEN_REGION2WA_Pos (4UL) /*!< Position of REGION2WA field. */ -#define MWU_NMIEN_REGION2WA_Msk (0x1UL << MWU_NMIEN_REGION2WA_Pos) /*!< Bit mask of REGION2WA field. */ -#define MWU_NMIEN_REGION2WA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION2WA_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable non-maskable interrupt for REGION[1].RA event */ -#define MWU_NMIEN_REGION1RA_Pos (3UL) /*!< Position of REGION1RA field. */ -#define MWU_NMIEN_REGION1RA_Msk (0x1UL << MWU_NMIEN_REGION1RA_Pos) /*!< Bit mask of REGION1RA field. */ -#define MWU_NMIEN_REGION1RA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION1RA_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable non-maskable interrupt for REGION[1].WA event */ -#define MWU_NMIEN_REGION1WA_Pos (2UL) /*!< Position of REGION1WA field. */ -#define MWU_NMIEN_REGION1WA_Msk (0x1UL << MWU_NMIEN_REGION1WA_Pos) /*!< Bit mask of REGION1WA field. */ -#define MWU_NMIEN_REGION1WA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION1WA_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable non-maskable interrupt for REGION[0].RA event */ -#define MWU_NMIEN_REGION0RA_Pos (1UL) /*!< Position of REGION0RA field. */ -#define MWU_NMIEN_REGION0RA_Msk (0x1UL << MWU_NMIEN_REGION0RA_Pos) /*!< Bit mask of REGION0RA field. */ -#define MWU_NMIEN_REGION0RA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION0RA_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable non-maskable interrupt for REGION[0].WA event */ -#define MWU_NMIEN_REGION0WA_Pos (0UL) /*!< Position of REGION0WA field. */ -#define MWU_NMIEN_REGION0WA_Msk (0x1UL << MWU_NMIEN_REGION0WA_Pos) /*!< Bit mask of REGION0WA field. */ -#define MWU_NMIEN_REGION0WA_Disabled (0UL) /*!< Disable */ -#define MWU_NMIEN_REGION0WA_Enabled (1UL) /*!< Enable */ - -/* Register: MWU_NMIENSET */ -/* Description: Enable non-maskable interrupt */ - -/* Bit 27 : Write '1' to Enable non-maskable interrupt for PREGION[1].RA event */ -#define MWU_NMIENSET_PREGION1RA_Pos (27UL) /*!< Position of PREGION1RA field. */ -#define MWU_NMIENSET_PREGION1RA_Msk (0x1UL << MWU_NMIENSET_PREGION1RA_Pos) /*!< Bit mask of PREGION1RA field. */ -#define MWU_NMIENSET_PREGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_PREGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_PREGION1RA_Set (1UL) /*!< Enable */ - -/* Bit 26 : Write '1' to Enable non-maskable interrupt for PREGION[1].WA event */ -#define MWU_NMIENSET_PREGION1WA_Pos (26UL) /*!< Position of PREGION1WA field. */ -#define MWU_NMIENSET_PREGION1WA_Msk (0x1UL << MWU_NMIENSET_PREGION1WA_Pos) /*!< Bit mask of PREGION1WA field. */ -#define MWU_NMIENSET_PREGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_PREGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_PREGION1WA_Set (1UL) /*!< Enable */ - -/* Bit 25 : Write '1' to Enable non-maskable interrupt for PREGION[0].RA event */ -#define MWU_NMIENSET_PREGION0RA_Pos (25UL) /*!< Position of PREGION0RA field. */ -#define MWU_NMIENSET_PREGION0RA_Msk (0x1UL << MWU_NMIENSET_PREGION0RA_Pos) /*!< Bit mask of PREGION0RA field. */ -#define MWU_NMIENSET_PREGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_PREGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_PREGION0RA_Set (1UL) /*!< Enable */ - -/* Bit 24 : Write '1' to Enable non-maskable interrupt for PREGION[0].WA event */ -#define MWU_NMIENSET_PREGION0WA_Pos (24UL) /*!< Position of PREGION0WA field. */ -#define MWU_NMIENSET_PREGION0WA_Msk (0x1UL << MWU_NMIENSET_PREGION0WA_Pos) /*!< Bit mask of PREGION0WA field. */ -#define MWU_NMIENSET_PREGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_PREGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_PREGION0WA_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable non-maskable interrupt for REGION[3].RA event */ -#define MWU_NMIENSET_REGION3RA_Pos (7UL) /*!< Position of REGION3RA field. */ -#define MWU_NMIENSET_REGION3RA_Msk (0x1UL << MWU_NMIENSET_REGION3RA_Pos) /*!< Bit mask of REGION3RA field. */ -#define MWU_NMIENSET_REGION3RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION3RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION3RA_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable non-maskable interrupt for REGION[3].WA event */ -#define MWU_NMIENSET_REGION3WA_Pos (6UL) /*!< Position of REGION3WA field. */ -#define MWU_NMIENSET_REGION3WA_Msk (0x1UL << MWU_NMIENSET_REGION3WA_Pos) /*!< Bit mask of REGION3WA field. */ -#define MWU_NMIENSET_REGION3WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION3WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION3WA_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable non-maskable interrupt for REGION[2].RA event */ -#define MWU_NMIENSET_REGION2RA_Pos (5UL) /*!< Position of REGION2RA field. */ -#define MWU_NMIENSET_REGION2RA_Msk (0x1UL << MWU_NMIENSET_REGION2RA_Pos) /*!< Bit mask of REGION2RA field. */ -#define MWU_NMIENSET_REGION2RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION2RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION2RA_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable non-maskable interrupt for REGION[2].WA event */ -#define MWU_NMIENSET_REGION2WA_Pos (4UL) /*!< Position of REGION2WA field. */ -#define MWU_NMIENSET_REGION2WA_Msk (0x1UL << MWU_NMIENSET_REGION2WA_Pos) /*!< Bit mask of REGION2WA field. */ -#define MWU_NMIENSET_REGION2WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION2WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION2WA_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable non-maskable interrupt for REGION[1].RA event */ -#define MWU_NMIENSET_REGION1RA_Pos (3UL) /*!< Position of REGION1RA field. */ -#define MWU_NMIENSET_REGION1RA_Msk (0x1UL << MWU_NMIENSET_REGION1RA_Pos) /*!< Bit mask of REGION1RA field. */ -#define MWU_NMIENSET_REGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION1RA_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable non-maskable interrupt for REGION[1].WA event */ -#define MWU_NMIENSET_REGION1WA_Pos (2UL) /*!< Position of REGION1WA field. */ -#define MWU_NMIENSET_REGION1WA_Msk (0x1UL << MWU_NMIENSET_REGION1WA_Pos) /*!< Bit mask of REGION1WA field. */ -#define MWU_NMIENSET_REGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION1WA_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable non-maskable interrupt for REGION[0].RA event */ -#define MWU_NMIENSET_REGION0RA_Pos (1UL) /*!< Position of REGION0RA field. */ -#define MWU_NMIENSET_REGION0RA_Msk (0x1UL << MWU_NMIENSET_REGION0RA_Pos) /*!< Bit mask of REGION0RA field. */ -#define MWU_NMIENSET_REGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION0RA_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable non-maskable interrupt for REGION[0].WA event */ -#define MWU_NMIENSET_REGION0WA_Pos (0UL) /*!< Position of REGION0WA field. */ -#define MWU_NMIENSET_REGION0WA_Msk (0x1UL << MWU_NMIENSET_REGION0WA_Pos) /*!< Bit mask of REGION0WA field. */ -#define MWU_NMIENSET_REGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENSET_REGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENSET_REGION0WA_Set (1UL) /*!< Enable */ - -/* Register: MWU_NMIENCLR */ -/* Description: Disable non-maskable interrupt */ - -/* Bit 27 : Write '1' to Disable non-maskable interrupt for PREGION[1].RA event */ -#define MWU_NMIENCLR_PREGION1RA_Pos (27UL) /*!< Position of PREGION1RA field. */ -#define MWU_NMIENCLR_PREGION1RA_Msk (0x1UL << MWU_NMIENCLR_PREGION1RA_Pos) /*!< Bit mask of PREGION1RA field. */ -#define MWU_NMIENCLR_PREGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_PREGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_PREGION1RA_Clear (1UL) /*!< Disable */ - -/* Bit 26 : Write '1' to Disable non-maskable interrupt for PREGION[1].WA event */ -#define MWU_NMIENCLR_PREGION1WA_Pos (26UL) /*!< Position of PREGION1WA field. */ -#define MWU_NMIENCLR_PREGION1WA_Msk (0x1UL << MWU_NMIENCLR_PREGION1WA_Pos) /*!< Bit mask of PREGION1WA field. */ -#define MWU_NMIENCLR_PREGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_PREGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_PREGION1WA_Clear (1UL) /*!< Disable */ - -/* Bit 25 : Write '1' to Disable non-maskable interrupt for PREGION[0].RA event */ -#define MWU_NMIENCLR_PREGION0RA_Pos (25UL) /*!< Position of PREGION0RA field. */ -#define MWU_NMIENCLR_PREGION0RA_Msk (0x1UL << MWU_NMIENCLR_PREGION0RA_Pos) /*!< Bit mask of PREGION0RA field. */ -#define MWU_NMIENCLR_PREGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_PREGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_PREGION0RA_Clear (1UL) /*!< Disable */ - -/* Bit 24 : Write '1' to Disable non-maskable interrupt for PREGION[0].WA event */ -#define MWU_NMIENCLR_PREGION0WA_Pos (24UL) /*!< Position of PREGION0WA field. */ -#define MWU_NMIENCLR_PREGION0WA_Msk (0x1UL << MWU_NMIENCLR_PREGION0WA_Pos) /*!< Bit mask of PREGION0WA field. */ -#define MWU_NMIENCLR_PREGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_PREGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_PREGION0WA_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable non-maskable interrupt for REGION[3].RA event */ -#define MWU_NMIENCLR_REGION3RA_Pos (7UL) /*!< Position of REGION3RA field. */ -#define MWU_NMIENCLR_REGION3RA_Msk (0x1UL << MWU_NMIENCLR_REGION3RA_Pos) /*!< Bit mask of REGION3RA field. */ -#define MWU_NMIENCLR_REGION3RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION3RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION3RA_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable non-maskable interrupt for REGION[3].WA event */ -#define MWU_NMIENCLR_REGION3WA_Pos (6UL) /*!< Position of REGION3WA field. */ -#define MWU_NMIENCLR_REGION3WA_Msk (0x1UL << MWU_NMIENCLR_REGION3WA_Pos) /*!< Bit mask of REGION3WA field. */ -#define MWU_NMIENCLR_REGION3WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION3WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION3WA_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable non-maskable interrupt for REGION[2].RA event */ -#define MWU_NMIENCLR_REGION2RA_Pos (5UL) /*!< Position of REGION2RA field. */ -#define MWU_NMIENCLR_REGION2RA_Msk (0x1UL << MWU_NMIENCLR_REGION2RA_Pos) /*!< Bit mask of REGION2RA field. */ -#define MWU_NMIENCLR_REGION2RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION2RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION2RA_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable non-maskable interrupt for REGION[2].WA event */ -#define MWU_NMIENCLR_REGION2WA_Pos (4UL) /*!< Position of REGION2WA field. */ -#define MWU_NMIENCLR_REGION2WA_Msk (0x1UL << MWU_NMIENCLR_REGION2WA_Pos) /*!< Bit mask of REGION2WA field. */ -#define MWU_NMIENCLR_REGION2WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION2WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION2WA_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable non-maskable interrupt for REGION[1].RA event */ -#define MWU_NMIENCLR_REGION1RA_Pos (3UL) /*!< Position of REGION1RA field. */ -#define MWU_NMIENCLR_REGION1RA_Msk (0x1UL << MWU_NMIENCLR_REGION1RA_Pos) /*!< Bit mask of REGION1RA field. */ -#define MWU_NMIENCLR_REGION1RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION1RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION1RA_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable non-maskable interrupt for REGION[1].WA event */ -#define MWU_NMIENCLR_REGION1WA_Pos (2UL) /*!< Position of REGION1WA field. */ -#define MWU_NMIENCLR_REGION1WA_Msk (0x1UL << MWU_NMIENCLR_REGION1WA_Pos) /*!< Bit mask of REGION1WA field. */ -#define MWU_NMIENCLR_REGION1WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION1WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION1WA_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable non-maskable interrupt for REGION[0].RA event */ -#define MWU_NMIENCLR_REGION0RA_Pos (1UL) /*!< Position of REGION0RA field. */ -#define MWU_NMIENCLR_REGION0RA_Msk (0x1UL << MWU_NMIENCLR_REGION0RA_Pos) /*!< Bit mask of REGION0RA field. */ -#define MWU_NMIENCLR_REGION0RA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION0RA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION0RA_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable non-maskable interrupt for REGION[0].WA event */ -#define MWU_NMIENCLR_REGION0WA_Pos (0UL) /*!< Position of REGION0WA field. */ -#define MWU_NMIENCLR_REGION0WA_Msk (0x1UL << MWU_NMIENCLR_REGION0WA_Pos) /*!< Bit mask of REGION0WA field. */ -#define MWU_NMIENCLR_REGION0WA_Disabled (0UL) /*!< Read: Disabled */ -#define MWU_NMIENCLR_REGION0WA_Enabled (1UL) /*!< Read: Enabled */ -#define MWU_NMIENCLR_REGION0WA_Clear (1UL) /*!< Disable */ - -/* Register: MWU_PERREGION_SUBSTATWA */ -/* Description: Description cluster[0]: Source of event/interrupt in region 0, write access detected while corresponding subregion was enabled for watching */ - -/* Bit 31 : Subregion 31 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR31_Pos (31UL) /*!< Position of SR31 field. */ -#define MWU_PERREGION_SUBSTATWA_SR31_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR31_Pos) /*!< Bit mask of SR31 field. */ -#define MWU_PERREGION_SUBSTATWA_SR31_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR31_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 30 : Subregion 30 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR30_Pos (30UL) /*!< Position of SR30 field. */ -#define MWU_PERREGION_SUBSTATWA_SR30_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR30_Pos) /*!< Bit mask of SR30 field. */ -#define MWU_PERREGION_SUBSTATWA_SR30_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR30_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 29 : Subregion 29 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR29_Pos (29UL) /*!< Position of SR29 field. */ -#define MWU_PERREGION_SUBSTATWA_SR29_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR29_Pos) /*!< Bit mask of SR29 field. */ -#define MWU_PERREGION_SUBSTATWA_SR29_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR29_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 28 : Subregion 28 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR28_Pos (28UL) /*!< Position of SR28 field. */ -#define MWU_PERREGION_SUBSTATWA_SR28_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR28_Pos) /*!< Bit mask of SR28 field. */ -#define MWU_PERREGION_SUBSTATWA_SR28_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR28_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 27 : Subregion 27 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR27_Pos (27UL) /*!< Position of SR27 field. */ -#define MWU_PERREGION_SUBSTATWA_SR27_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR27_Pos) /*!< Bit mask of SR27 field. */ -#define MWU_PERREGION_SUBSTATWA_SR27_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR27_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 26 : Subregion 26 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR26_Pos (26UL) /*!< Position of SR26 field. */ -#define MWU_PERREGION_SUBSTATWA_SR26_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR26_Pos) /*!< Bit mask of SR26 field. */ -#define MWU_PERREGION_SUBSTATWA_SR26_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR26_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 25 : Subregion 25 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR25_Pos (25UL) /*!< Position of SR25 field. */ -#define MWU_PERREGION_SUBSTATWA_SR25_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR25_Pos) /*!< Bit mask of SR25 field. */ -#define MWU_PERREGION_SUBSTATWA_SR25_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR25_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 24 : Subregion 24 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR24_Pos (24UL) /*!< Position of SR24 field. */ -#define MWU_PERREGION_SUBSTATWA_SR24_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR24_Pos) /*!< Bit mask of SR24 field. */ -#define MWU_PERREGION_SUBSTATWA_SR24_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR24_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 23 : Subregion 23 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR23_Pos (23UL) /*!< Position of SR23 field. */ -#define MWU_PERREGION_SUBSTATWA_SR23_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR23_Pos) /*!< Bit mask of SR23 field. */ -#define MWU_PERREGION_SUBSTATWA_SR23_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR23_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 22 : Subregion 22 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR22_Pos (22UL) /*!< Position of SR22 field. */ -#define MWU_PERREGION_SUBSTATWA_SR22_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR22_Pos) /*!< Bit mask of SR22 field. */ -#define MWU_PERREGION_SUBSTATWA_SR22_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR22_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 21 : Subregion 21 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR21_Pos (21UL) /*!< Position of SR21 field. */ -#define MWU_PERREGION_SUBSTATWA_SR21_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR21_Pos) /*!< Bit mask of SR21 field. */ -#define MWU_PERREGION_SUBSTATWA_SR21_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR21_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 20 : Subregion 20 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR20_Pos (20UL) /*!< Position of SR20 field. */ -#define MWU_PERREGION_SUBSTATWA_SR20_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR20_Pos) /*!< Bit mask of SR20 field. */ -#define MWU_PERREGION_SUBSTATWA_SR20_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR20_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 19 : Subregion 19 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR19_Pos (19UL) /*!< Position of SR19 field. */ -#define MWU_PERREGION_SUBSTATWA_SR19_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR19_Pos) /*!< Bit mask of SR19 field. */ -#define MWU_PERREGION_SUBSTATWA_SR19_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR19_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 18 : Subregion 18 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR18_Pos (18UL) /*!< Position of SR18 field. */ -#define MWU_PERREGION_SUBSTATWA_SR18_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR18_Pos) /*!< Bit mask of SR18 field. */ -#define MWU_PERREGION_SUBSTATWA_SR18_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR18_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 17 : Subregion 17 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR17_Pos (17UL) /*!< Position of SR17 field. */ -#define MWU_PERREGION_SUBSTATWA_SR17_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR17_Pos) /*!< Bit mask of SR17 field. */ -#define MWU_PERREGION_SUBSTATWA_SR17_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR17_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 16 : Subregion 16 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR16_Pos (16UL) /*!< Position of SR16 field. */ -#define MWU_PERREGION_SUBSTATWA_SR16_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR16_Pos) /*!< Bit mask of SR16 field. */ -#define MWU_PERREGION_SUBSTATWA_SR16_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR16_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 15 : Subregion 15 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR15_Pos (15UL) /*!< Position of SR15 field. */ -#define MWU_PERREGION_SUBSTATWA_SR15_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR15_Pos) /*!< Bit mask of SR15 field. */ -#define MWU_PERREGION_SUBSTATWA_SR15_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR15_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 14 : Subregion 14 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR14_Pos (14UL) /*!< Position of SR14 field. */ -#define MWU_PERREGION_SUBSTATWA_SR14_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR14_Pos) /*!< Bit mask of SR14 field. */ -#define MWU_PERREGION_SUBSTATWA_SR14_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR14_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 13 : Subregion 13 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR13_Pos (13UL) /*!< Position of SR13 field. */ -#define MWU_PERREGION_SUBSTATWA_SR13_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR13_Pos) /*!< Bit mask of SR13 field. */ -#define MWU_PERREGION_SUBSTATWA_SR13_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR13_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 12 : Subregion 12 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR12_Pos (12UL) /*!< Position of SR12 field. */ -#define MWU_PERREGION_SUBSTATWA_SR12_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR12_Pos) /*!< Bit mask of SR12 field. */ -#define MWU_PERREGION_SUBSTATWA_SR12_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR12_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 11 : Subregion 11 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR11_Pos (11UL) /*!< Position of SR11 field. */ -#define MWU_PERREGION_SUBSTATWA_SR11_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR11_Pos) /*!< Bit mask of SR11 field. */ -#define MWU_PERREGION_SUBSTATWA_SR11_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR11_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 10 : Subregion 10 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR10_Pos (10UL) /*!< Position of SR10 field. */ -#define MWU_PERREGION_SUBSTATWA_SR10_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR10_Pos) /*!< Bit mask of SR10 field. */ -#define MWU_PERREGION_SUBSTATWA_SR10_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR10_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 9 : Subregion 9 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR9_Pos (9UL) /*!< Position of SR9 field. */ -#define MWU_PERREGION_SUBSTATWA_SR9_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR9_Pos) /*!< Bit mask of SR9 field. */ -#define MWU_PERREGION_SUBSTATWA_SR9_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR9_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 8 : Subregion 8 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR8_Pos (8UL) /*!< Position of SR8 field. */ -#define MWU_PERREGION_SUBSTATWA_SR8_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR8_Pos) /*!< Bit mask of SR8 field. */ -#define MWU_PERREGION_SUBSTATWA_SR8_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR8_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 7 : Subregion 7 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR7_Pos (7UL) /*!< Position of SR7 field. */ -#define MWU_PERREGION_SUBSTATWA_SR7_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR7_Pos) /*!< Bit mask of SR7 field. */ -#define MWU_PERREGION_SUBSTATWA_SR7_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR7_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 6 : Subregion 6 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR6_Pos (6UL) /*!< Position of SR6 field. */ -#define MWU_PERREGION_SUBSTATWA_SR6_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR6_Pos) /*!< Bit mask of SR6 field. */ -#define MWU_PERREGION_SUBSTATWA_SR6_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR6_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 5 : Subregion 5 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR5_Pos (5UL) /*!< Position of SR5 field. */ -#define MWU_PERREGION_SUBSTATWA_SR5_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR5_Pos) /*!< Bit mask of SR5 field. */ -#define MWU_PERREGION_SUBSTATWA_SR5_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR5_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 4 : Subregion 4 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR4_Pos (4UL) /*!< Position of SR4 field. */ -#define MWU_PERREGION_SUBSTATWA_SR4_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR4_Pos) /*!< Bit mask of SR4 field. */ -#define MWU_PERREGION_SUBSTATWA_SR4_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR4_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 3 : Subregion 3 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR3_Pos (3UL) /*!< Position of SR3 field. */ -#define MWU_PERREGION_SUBSTATWA_SR3_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR3_Pos) /*!< Bit mask of SR3 field. */ -#define MWU_PERREGION_SUBSTATWA_SR3_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR3_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 2 : Subregion 2 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR2_Pos (2UL) /*!< Position of SR2 field. */ -#define MWU_PERREGION_SUBSTATWA_SR2_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR2_Pos) /*!< Bit mask of SR2 field. */ -#define MWU_PERREGION_SUBSTATWA_SR2_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR2_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 1 : Subregion 1 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR1_Pos (1UL) /*!< Position of SR1 field. */ -#define MWU_PERREGION_SUBSTATWA_SR1_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR1_Pos) /*!< Bit mask of SR1 field. */ -#define MWU_PERREGION_SUBSTATWA_SR1_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR1_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Bit 0 : Subregion 0 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATWA_SR0_Pos (0UL) /*!< Position of SR0 field. */ -#define MWU_PERREGION_SUBSTATWA_SR0_Msk (0x1UL << MWU_PERREGION_SUBSTATWA_SR0_Pos) /*!< Bit mask of SR0 field. */ -#define MWU_PERREGION_SUBSTATWA_SR0_NoAccess (0UL) /*!< No write access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATWA_SR0_Access (1UL) /*!< Write access(es) occurred in this subregion */ - -/* Register: MWU_PERREGION_SUBSTATRA */ -/* Description: Description cluster[0]: Source of event/interrupt in region 0, read access detected while corresponding subregion was enabled for watching */ - -/* Bit 31 : Subregion 31 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR31_Pos (31UL) /*!< Position of SR31 field. */ -#define MWU_PERREGION_SUBSTATRA_SR31_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR31_Pos) /*!< Bit mask of SR31 field. */ -#define MWU_PERREGION_SUBSTATRA_SR31_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR31_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 30 : Subregion 30 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR30_Pos (30UL) /*!< Position of SR30 field. */ -#define MWU_PERREGION_SUBSTATRA_SR30_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR30_Pos) /*!< Bit mask of SR30 field. */ -#define MWU_PERREGION_SUBSTATRA_SR30_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR30_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 29 : Subregion 29 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR29_Pos (29UL) /*!< Position of SR29 field. */ -#define MWU_PERREGION_SUBSTATRA_SR29_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR29_Pos) /*!< Bit mask of SR29 field. */ -#define MWU_PERREGION_SUBSTATRA_SR29_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR29_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 28 : Subregion 28 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR28_Pos (28UL) /*!< Position of SR28 field. */ -#define MWU_PERREGION_SUBSTATRA_SR28_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR28_Pos) /*!< Bit mask of SR28 field. */ -#define MWU_PERREGION_SUBSTATRA_SR28_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR28_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 27 : Subregion 27 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR27_Pos (27UL) /*!< Position of SR27 field. */ -#define MWU_PERREGION_SUBSTATRA_SR27_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR27_Pos) /*!< Bit mask of SR27 field. */ -#define MWU_PERREGION_SUBSTATRA_SR27_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR27_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 26 : Subregion 26 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR26_Pos (26UL) /*!< Position of SR26 field. */ -#define MWU_PERREGION_SUBSTATRA_SR26_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR26_Pos) /*!< Bit mask of SR26 field. */ -#define MWU_PERREGION_SUBSTATRA_SR26_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR26_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 25 : Subregion 25 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR25_Pos (25UL) /*!< Position of SR25 field. */ -#define MWU_PERREGION_SUBSTATRA_SR25_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR25_Pos) /*!< Bit mask of SR25 field. */ -#define MWU_PERREGION_SUBSTATRA_SR25_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR25_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 24 : Subregion 24 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR24_Pos (24UL) /*!< Position of SR24 field. */ -#define MWU_PERREGION_SUBSTATRA_SR24_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR24_Pos) /*!< Bit mask of SR24 field. */ -#define MWU_PERREGION_SUBSTATRA_SR24_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR24_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 23 : Subregion 23 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR23_Pos (23UL) /*!< Position of SR23 field. */ -#define MWU_PERREGION_SUBSTATRA_SR23_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR23_Pos) /*!< Bit mask of SR23 field. */ -#define MWU_PERREGION_SUBSTATRA_SR23_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR23_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 22 : Subregion 22 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR22_Pos (22UL) /*!< Position of SR22 field. */ -#define MWU_PERREGION_SUBSTATRA_SR22_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR22_Pos) /*!< Bit mask of SR22 field. */ -#define MWU_PERREGION_SUBSTATRA_SR22_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR22_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 21 : Subregion 21 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR21_Pos (21UL) /*!< Position of SR21 field. */ -#define MWU_PERREGION_SUBSTATRA_SR21_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR21_Pos) /*!< Bit mask of SR21 field. */ -#define MWU_PERREGION_SUBSTATRA_SR21_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR21_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 20 : Subregion 20 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR20_Pos (20UL) /*!< Position of SR20 field. */ -#define MWU_PERREGION_SUBSTATRA_SR20_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR20_Pos) /*!< Bit mask of SR20 field. */ -#define MWU_PERREGION_SUBSTATRA_SR20_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR20_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 19 : Subregion 19 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR19_Pos (19UL) /*!< Position of SR19 field. */ -#define MWU_PERREGION_SUBSTATRA_SR19_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR19_Pos) /*!< Bit mask of SR19 field. */ -#define MWU_PERREGION_SUBSTATRA_SR19_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR19_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 18 : Subregion 18 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR18_Pos (18UL) /*!< Position of SR18 field. */ -#define MWU_PERREGION_SUBSTATRA_SR18_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR18_Pos) /*!< Bit mask of SR18 field. */ -#define MWU_PERREGION_SUBSTATRA_SR18_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR18_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 17 : Subregion 17 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR17_Pos (17UL) /*!< Position of SR17 field. */ -#define MWU_PERREGION_SUBSTATRA_SR17_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR17_Pos) /*!< Bit mask of SR17 field. */ -#define MWU_PERREGION_SUBSTATRA_SR17_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR17_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 16 : Subregion 16 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR16_Pos (16UL) /*!< Position of SR16 field. */ -#define MWU_PERREGION_SUBSTATRA_SR16_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR16_Pos) /*!< Bit mask of SR16 field. */ -#define MWU_PERREGION_SUBSTATRA_SR16_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR16_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 15 : Subregion 15 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR15_Pos (15UL) /*!< Position of SR15 field. */ -#define MWU_PERREGION_SUBSTATRA_SR15_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR15_Pos) /*!< Bit mask of SR15 field. */ -#define MWU_PERREGION_SUBSTATRA_SR15_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR15_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 14 : Subregion 14 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR14_Pos (14UL) /*!< Position of SR14 field. */ -#define MWU_PERREGION_SUBSTATRA_SR14_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR14_Pos) /*!< Bit mask of SR14 field. */ -#define MWU_PERREGION_SUBSTATRA_SR14_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR14_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 13 : Subregion 13 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR13_Pos (13UL) /*!< Position of SR13 field. */ -#define MWU_PERREGION_SUBSTATRA_SR13_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR13_Pos) /*!< Bit mask of SR13 field. */ -#define MWU_PERREGION_SUBSTATRA_SR13_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR13_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 12 : Subregion 12 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR12_Pos (12UL) /*!< Position of SR12 field. */ -#define MWU_PERREGION_SUBSTATRA_SR12_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR12_Pos) /*!< Bit mask of SR12 field. */ -#define MWU_PERREGION_SUBSTATRA_SR12_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR12_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 11 : Subregion 11 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR11_Pos (11UL) /*!< Position of SR11 field. */ -#define MWU_PERREGION_SUBSTATRA_SR11_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR11_Pos) /*!< Bit mask of SR11 field. */ -#define MWU_PERREGION_SUBSTATRA_SR11_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR11_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 10 : Subregion 10 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR10_Pos (10UL) /*!< Position of SR10 field. */ -#define MWU_PERREGION_SUBSTATRA_SR10_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR10_Pos) /*!< Bit mask of SR10 field. */ -#define MWU_PERREGION_SUBSTATRA_SR10_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR10_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 9 : Subregion 9 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR9_Pos (9UL) /*!< Position of SR9 field. */ -#define MWU_PERREGION_SUBSTATRA_SR9_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR9_Pos) /*!< Bit mask of SR9 field. */ -#define MWU_PERREGION_SUBSTATRA_SR9_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR9_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 8 : Subregion 8 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR8_Pos (8UL) /*!< Position of SR8 field. */ -#define MWU_PERREGION_SUBSTATRA_SR8_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR8_Pos) /*!< Bit mask of SR8 field. */ -#define MWU_PERREGION_SUBSTATRA_SR8_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR8_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 7 : Subregion 7 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR7_Pos (7UL) /*!< Position of SR7 field. */ -#define MWU_PERREGION_SUBSTATRA_SR7_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR7_Pos) /*!< Bit mask of SR7 field. */ -#define MWU_PERREGION_SUBSTATRA_SR7_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR7_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 6 : Subregion 6 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR6_Pos (6UL) /*!< Position of SR6 field. */ -#define MWU_PERREGION_SUBSTATRA_SR6_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR6_Pos) /*!< Bit mask of SR6 field. */ -#define MWU_PERREGION_SUBSTATRA_SR6_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR6_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 5 : Subregion 5 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR5_Pos (5UL) /*!< Position of SR5 field. */ -#define MWU_PERREGION_SUBSTATRA_SR5_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR5_Pos) /*!< Bit mask of SR5 field. */ -#define MWU_PERREGION_SUBSTATRA_SR5_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR5_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 4 : Subregion 4 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR4_Pos (4UL) /*!< Position of SR4 field. */ -#define MWU_PERREGION_SUBSTATRA_SR4_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR4_Pos) /*!< Bit mask of SR4 field. */ -#define MWU_PERREGION_SUBSTATRA_SR4_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR4_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 3 : Subregion 3 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR3_Pos (3UL) /*!< Position of SR3 field. */ -#define MWU_PERREGION_SUBSTATRA_SR3_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR3_Pos) /*!< Bit mask of SR3 field. */ -#define MWU_PERREGION_SUBSTATRA_SR3_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR3_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 2 : Subregion 2 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR2_Pos (2UL) /*!< Position of SR2 field. */ -#define MWU_PERREGION_SUBSTATRA_SR2_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR2_Pos) /*!< Bit mask of SR2 field. */ -#define MWU_PERREGION_SUBSTATRA_SR2_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR2_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 1 : Subregion 1 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR1_Pos (1UL) /*!< Position of SR1 field. */ -#define MWU_PERREGION_SUBSTATRA_SR1_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR1_Pos) /*!< Bit mask of SR1 field. */ -#define MWU_PERREGION_SUBSTATRA_SR1_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR1_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Bit 0 : Subregion 0 in region 0 (write '1' to clear) */ -#define MWU_PERREGION_SUBSTATRA_SR0_Pos (0UL) /*!< Position of SR0 field. */ -#define MWU_PERREGION_SUBSTATRA_SR0_Msk (0x1UL << MWU_PERREGION_SUBSTATRA_SR0_Pos) /*!< Bit mask of SR0 field. */ -#define MWU_PERREGION_SUBSTATRA_SR0_NoAccess (0UL) /*!< No read access occurred in this subregion */ -#define MWU_PERREGION_SUBSTATRA_SR0_Access (1UL) /*!< Read access(es) occurred in this subregion */ - -/* Register: MWU_REGIONEN */ -/* Description: Enable/disable regions watch */ - -/* Bit 27 : Enable/disable read access watch in PREGION[1] */ -#define MWU_REGIONEN_PRGN1RA_Pos (27UL) /*!< Position of PRGN1RA field. */ -#define MWU_REGIONEN_PRGN1RA_Msk (0x1UL << MWU_REGIONEN_PRGN1RA_Pos) /*!< Bit mask of PRGN1RA field. */ -#define MWU_REGIONEN_PRGN1RA_Disable (0UL) /*!< Disable read access watch in this PREGION */ -#define MWU_REGIONEN_PRGN1RA_Enable (1UL) /*!< Enable read access watch in this PREGION */ - -/* Bit 26 : Enable/disable write access watch in PREGION[1] */ -#define MWU_REGIONEN_PRGN1WA_Pos (26UL) /*!< Position of PRGN1WA field. */ -#define MWU_REGIONEN_PRGN1WA_Msk (0x1UL << MWU_REGIONEN_PRGN1WA_Pos) /*!< Bit mask of PRGN1WA field. */ -#define MWU_REGIONEN_PRGN1WA_Disable (0UL) /*!< Disable write access watch in this PREGION */ -#define MWU_REGIONEN_PRGN1WA_Enable (1UL) /*!< Enable write access watch in this PREGION */ - -/* Bit 25 : Enable/disable read access watch in PREGION[0] */ -#define MWU_REGIONEN_PRGN0RA_Pos (25UL) /*!< Position of PRGN0RA field. */ -#define MWU_REGIONEN_PRGN0RA_Msk (0x1UL << MWU_REGIONEN_PRGN0RA_Pos) /*!< Bit mask of PRGN0RA field. */ -#define MWU_REGIONEN_PRGN0RA_Disable (0UL) /*!< Disable read access watch in this PREGION */ -#define MWU_REGIONEN_PRGN0RA_Enable (1UL) /*!< Enable read access watch in this PREGION */ - -/* Bit 24 : Enable/disable write access watch in PREGION[0] */ -#define MWU_REGIONEN_PRGN0WA_Pos (24UL) /*!< Position of PRGN0WA field. */ -#define MWU_REGIONEN_PRGN0WA_Msk (0x1UL << MWU_REGIONEN_PRGN0WA_Pos) /*!< Bit mask of PRGN0WA field. */ -#define MWU_REGIONEN_PRGN0WA_Disable (0UL) /*!< Disable write access watch in this PREGION */ -#define MWU_REGIONEN_PRGN0WA_Enable (1UL) /*!< Enable write access watch in this PREGION */ - -/* Bit 7 : Enable/disable read access watch in region[3] */ -#define MWU_REGIONEN_RGN3RA_Pos (7UL) /*!< Position of RGN3RA field. */ -#define MWU_REGIONEN_RGN3RA_Msk (0x1UL << MWU_REGIONEN_RGN3RA_Pos) /*!< Bit mask of RGN3RA field. */ -#define MWU_REGIONEN_RGN3RA_Disable (0UL) /*!< Disable read access watch in this region */ -#define MWU_REGIONEN_RGN3RA_Enable (1UL) /*!< Enable read access watch in this region */ - -/* Bit 6 : Enable/disable write access watch in region[3] */ -#define MWU_REGIONEN_RGN3WA_Pos (6UL) /*!< Position of RGN3WA field. */ -#define MWU_REGIONEN_RGN3WA_Msk (0x1UL << MWU_REGIONEN_RGN3WA_Pos) /*!< Bit mask of RGN3WA field. */ -#define MWU_REGIONEN_RGN3WA_Disable (0UL) /*!< Disable write access watch in this region */ -#define MWU_REGIONEN_RGN3WA_Enable (1UL) /*!< Enable write access watch in this region */ - -/* Bit 5 : Enable/disable read access watch in region[2] */ -#define MWU_REGIONEN_RGN2RA_Pos (5UL) /*!< Position of RGN2RA field. */ -#define MWU_REGIONEN_RGN2RA_Msk (0x1UL << MWU_REGIONEN_RGN2RA_Pos) /*!< Bit mask of RGN2RA field. */ -#define MWU_REGIONEN_RGN2RA_Disable (0UL) /*!< Disable read access watch in this region */ -#define MWU_REGIONEN_RGN2RA_Enable (1UL) /*!< Enable read access watch in this region */ - -/* Bit 4 : Enable/disable write access watch in region[2] */ -#define MWU_REGIONEN_RGN2WA_Pos (4UL) /*!< Position of RGN2WA field. */ -#define MWU_REGIONEN_RGN2WA_Msk (0x1UL << MWU_REGIONEN_RGN2WA_Pos) /*!< Bit mask of RGN2WA field. */ -#define MWU_REGIONEN_RGN2WA_Disable (0UL) /*!< Disable write access watch in this region */ -#define MWU_REGIONEN_RGN2WA_Enable (1UL) /*!< Enable write access watch in this region */ - -/* Bit 3 : Enable/disable read access watch in region[1] */ -#define MWU_REGIONEN_RGN1RA_Pos (3UL) /*!< Position of RGN1RA field. */ -#define MWU_REGIONEN_RGN1RA_Msk (0x1UL << MWU_REGIONEN_RGN1RA_Pos) /*!< Bit mask of RGN1RA field. */ -#define MWU_REGIONEN_RGN1RA_Disable (0UL) /*!< Disable read access watch in this region */ -#define MWU_REGIONEN_RGN1RA_Enable (1UL) /*!< Enable read access watch in this region */ - -/* Bit 2 : Enable/disable write access watch in region[1] */ -#define MWU_REGIONEN_RGN1WA_Pos (2UL) /*!< Position of RGN1WA field. */ -#define MWU_REGIONEN_RGN1WA_Msk (0x1UL << MWU_REGIONEN_RGN1WA_Pos) /*!< Bit mask of RGN1WA field. */ -#define MWU_REGIONEN_RGN1WA_Disable (0UL) /*!< Disable write access watch in this region */ -#define MWU_REGIONEN_RGN1WA_Enable (1UL) /*!< Enable write access watch in this region */ - -/* Bit 1 : Enable/disable read access watch in region[0] */ -#define MWU_REGIONEN_RGN0RA_Pos (1UL) /*!< Position of RGN0RA field. */ -#define MWU_REGIONEN_RGN0RA_Msk (0x1UL << MWU_REGIONEN_RGN0RA_Pos) /*!< Bit mask of RGN0RA field. */ -#define MWU_REGIONEN_RGN0RA_Disable (0UL) /*!< Disable read access watch in this region */ -#define MWU_REGIONEN_RGN0RA_Enable (1UL) /*!< Enable read access watch in this region */ - -/* Bit 0 : Enable/disable write access watch in region[0] */ -#define MWU_REGIONEN_RGN0WA_Pos (0UL) /*!< Position of RGN0WA field. */ -#define MWU_REGIONEN_RGN0WA_Msk (0x1UL << MWU_REGIONEN_RGN0WA_Pos) /*!< Bit mask of RGN0WA field. */ -#define MWU_REGIONEN_RGN0WA_Disable (0UL) /*!< Disable write access watch in this region */ -#define MWU_REGIONEN_RGN0WA_Enable (1UL) /*!< Enable write access watch in this region */ - -/* Register: MWU_REGIONENSET */ -/* Description: Enable regions watch */ - -/* Bit 27 : Enable read access watch in PREGION[1] */ -#define MWU_REGIONENSET_PRGN1RA_Pos (27UL) /*!< Position of PRGN1RA field. */ -#define MWU_REGIONENSET_PRGN1RA_Msk (0x1UL << MWU_REGIONENSET_PRGN1RA_Pos) /*!< Bit mask of PRGN1RA field. */ -#define MWU_REGIONENSET_PRGN1RA_Disabled (0UL) /*!< Read access watch in this PREGION is disabled */ -#define MWU_REGIONENSET_PRGN1RA_Enabled (1UL) /*!< Read access watch in this PREGION is enabled */ -#define MWU_REGIONENSET_PRGN1RA_Set (1UL) /*!< Enable read access watch in this PREGION */ - -/* Bit 26 : Enable write access watch in PREGION[1] */ -#define MWU_REGIONENSET_PRGN1WA_Pos (26UL) /*!< Position of PRGN1WA field. */ -#define MWU_REGIONENSET_PRGN1WA_Msk (0x1UL << MWU_REGIONENSET_PRGN1WA_Pos) /*!< Bit mask of PRGN1WA field. */ -#define MWU_REGIONENSET_PRGN1WA_Disabled (0UL) /*!< Write access watch in this PREGION is disabled */ -#define MWU_REGIONENSET_PRGN1WA_Enabled (1UL) /*!< Write access watch in this PREGION is enabled */ -#define MWU_REGIONENSET_PRGN1WA_Set (1UL) /*!< Enable write access watch in this PREGION */ - -/* Bit 25 : Enable read access watch in PREGION[0] */ -#define MWU_REGIONENSET_PRGN0RA_Pos (25UL) /*!< Position of PRGN0RA field. */ -#define MWU_REGIONENSET_PRGN0RA_Msk (0x1UL << MWU_REGIONENSET_PRGN0RA_Pos) /*!< Bit mask of PRGN0RA field. */ -#define MWU_REGIONENSET_PRGN0RA_Disabled (0UL) /*!< Read access watch in this PREGION is disabled */ -#define MWU_REGIONENSET_PRGN0RA_Enabled (1UL) /*!< Read access watch in this PREGION is enabled */ -#define MWU_REGIONENSET_PRGN0RA_Set (1UL) /*!< Enable read access watch in this PREGION */ - -/* Bit 24 : Enable write access watch in PREGION[0] */ -#define MWU_REGIONENSET_PRGN0WA_Pos (24UL) /*!< Position of PRGN0WA field. */ -#define MWU_REGIONENSET_PRGN0WA_Msk (0x1UL << MWU_REGIONENSET_PRGN0WA_Pos) /*!< Bit mask of PRGN0WA field. */ -#define MWU_REGIONENSET_PRGN0WA_Disabled (0UL) /*!< Write access watch in this PREGION is disabled */ -#define MWU_REGIONENSET_PRGN0WA_Enabled (1UL) /*!< Write access watch in this PREGION is enabled */ -#define MWU_REGIONENSET_PRGN0WA_Set (1UL) /*!< Enable write access watch in this PREGION */ - -/* Bit 7 : Enable read access watch in region[3] */ -#define MWU_REGIONENSET_RGN3RA_Pos (7UL) /*!< Position of RGN3RA field. */ -#define MWU_REGIONENSET_RGN3RA_Msk (0x1UL << MWU_REGIONENSET_RGN3RA_Pos) /*!< Bit mask of RGN3RA field. */ -#define MWU_REGIONENSET_RGN3RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN3RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN3RA_Set (1UL) /*!< Enable read access watch in this region */ - -/* Bit 6 : Enable write access watch in region[3] */ -#define MWU_REGIONENSET_RGN3WA_Pos (6UL) /*!< Position of RGN3WA field. */ -#define MWU_REGIONENSET_RGN3WA_Msk (0x1UL << MWU_REGIONENSET_RGN3WA_Pos) /*!< Bit mask of RGN3WA field. */ -#define MWU_REGIONENSET_RGN3WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN3WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN3WA_Set (1UL) /*!< Enable write access watch in this region */ - -/* Bit 5 : Enable read access watch in region[2] */ -#define MWU_REGIONENSET_RGN2RA_Pos (5UL) /*!< Position of RGN2RA field. */ -#define MWU_REGIONENSET_RGN2RA_Msk (0x1UL << MWU_REGIONENSET_RGN2RA_Pos) /*!< Bit mask of RGN2RA field. */ -#define MWU_REGIONENSET_RGN2RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN2RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN2RA_Set (1UL) /*!< Enable read access watch in this region */ - -/* Bit 4 : Enable write access watch in region[2] */ -#define MWU_REGIONENSET_RGN2WA_Pos (4UL) /*!< Position of RGN2WA field. */ -#define MWU_REGIONENSET_RGN2WA_Msk (0x1UL << MWU_REGIONENSET_RGN2WA_Pos) /*!< Bit mask of RGN2WA field. */ -#define MWU_REGIONENSET_RGN2WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN2WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN2WA_Set (1UL) /*!< Enable write access watch in this region */ - -/* Bit 3 : Enable read access watch in region[1] */ -#define MWU_REGIONENSET_RGN1RA_Pos (3UL) /*!< Position of RGN1RA field. */ -#define MWU_REGIONENSET_RGN1RA_Msk (0x1UL << MWU_REGIONENSET_RGN1RA_Pos) /*!< Bit mask of RGN1RA field. */ -#define MWU_REGIONENSET_RGN1RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN1RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN1RA_Set (1UL) /*!< Enable read access watch in this region */ - -/* Bit 2 : Enable write access watch in region[1] */ -#define MWU_REGIONENSET_RGN1WA_Pos (2UL) /*!< Position of RGN1WA field. */ -#define MWU_REGIONENSET_RGN1WA_Msk (0x1UL << MWU_REGIONENSET_RGN1WA_Pos) /*!< Bit mask of RGN1WA field. */ -#define MWU_REGIONENSET_RGN1WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN1WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN1WA_Set (1UL) /*!< Enable write access watch in this region */ - -/* Bit 1 : Enable read access watch in region[0] */ -#define MWU_REGIONENSET_RGN0RA_Pos (1UL) /*!< Position of RGN0RA field. */ -#define MWU_REGIONENSET_RGN0RA_Msk (0x1UL << MWU_REGIONENSET_RGN0RA_Pos) /*!< Bit mask of RGN0RA field. */ -#define MWU_REGIONENSET_RGN0RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN0RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN0RA_Set (1UL) /*!< Enable read access watch in this region */ - -/* Bit 0 : Enable write access watch in region[0] */ -#define MWU_REGIONENSET_RGN0WA_Pos (0UL) /*!< Position of RGN0WA field. */ -#define MWU_REGIONENSET_RGN0WA_Msk (0x1UL << MWU_REGIONENSET_RGN0WA_Pos) /*!< Bit mask of RGN0WA field. */ -#define MWU_REGIONENSET_RGN0WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENSET_RGN0WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENSET_RGN0WA_Set (1UL) /*!< Enable write access watch in this region */ - -/* Register: MWU_REGIONENCLR */ -/* Description: Disable regions watch */ - -/* Bit 27 : Disable read access watch in PREGION[1] */ -#define MWU_REGIONENCLR_PRGN1RA_Pos (27UL) /*!< Position of PRGN1RA field. */ -#define MWU_REGIONENCLR_PRGN1RA_Msk (0x1UL << MWU_REGIONENCLR_PRGN1RA_Pos) /*!< Bit mask of PRGN1RA field. */ -#define MWU_REGIONENCLR_PRGN1RA_Disabled (0UL) /*!< Read access watch in this PREGION is disabled */ -#define MWU_REGIONENCLR_PRGN1RA_Enabled (1UL) /*!< Read access watch in this PREGION is enabled */ -#define MWU_REGIONENCLR_PRGN1RA_Clear (1UL) /*!< Disable read access watch in this PREGION */ - -/* Bit 26 : Disable write access watch in PREGION[1] */ -#define MWU_REGIONENCLR_PRGN1WA_Pos (26UL) /*!< Position of PRGN1WA field. */ -#define MWU_REGIONENCLR_PRGN1WA_Msk (0x1UL << MWU_REGIONENCLR_PRGN1WA_Pos) /*!< Bit mask of PRGN1WA field. */ -#define MWU_REGIONENCLR_PRGN1WA_Disabled (0UL) /*!< Write access watch in this PREGION is disabled */ -#define MWU_REGIONENCLR_PRGN1WA_Enabled (1UL) /*!< Write access watch in this PREGION is enabled */ -#define MWU_REGIONENCLR_PRGN1WA_Clear (1UL) /*!< Disable write access watch in this PREGION */ - -/* Bit 25 : Disable read access watch in PREGION[0] */ -#define MWU_REGIONENCLR_PRGN0RA_Pos (25UL) /*!< Position of PRGN0RA field. */ -#define MWU_REGIONENCLR_PRGN0RA_Msk (0x1UL << MWU_REGIONENCLR_PRGN0RA_Pos) /*!< Bit mask of PRGN0RA field. */ -#define MWU_REGIONENCLR_PRGN0RA_Disabled (0UL) /*!< Read access watch in this PREGION is disabled */ -#define MWU_REGIONENCLR_PRGN0RA_Enabled (1UL) /*!< Read access watch in this PREGION is enabled */ -#define MWU_REGIONENCLR_PRGN0RA_Clear (1UL) /*!< Disable read access watch in this PREGION */ - -/* Bit 24 : Disable write access watch in PREGION[0] */ -#define MWU_REGIONENCLR_PRGN0WA_Pos (24UL) /*!< Position of PRGN0WA field. */ -#define MWU_REGIONENCLR_PRGN0WA_Msk (0x1UL << MWU_REGIONENCLR_PRGN0WA_Pos) /*!< Bit mask of PRGN0WA field. */ -#define MWU_REGIONENCLR_PRGN0WA_Disabled (0UL) /*!< Write access watch in this PREGION is disabled */ -#define MWU_REGIONENCLR_PRGN0WA_Enabled (1UL) /*!< Write access watch in this PREGION is enabled */ -#define MWU_REGIONENCLR_PRGN0WA_Clear (1UL) /*!< Disable write access watch in this PREGION */ - -/* Bit 7 : Disable read access watch in region[3] */ -#define MWU_REGIONENCLR_RGN3RA_Pos (7UL) /*!< Position of RGN3RA field. */ -#define MWU_REGIONENCLR_RGN3RA_Msk (0x1UL << MWU_REGIONENCLR_RGN3RA_Pos) /*!< Bit mask of RGN3RA field. */ -#define MWU_REGIONENCLR_RGN3RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN3RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN3RA_Clear (1UL) /*!< Disable read access watch in this region */ - -/* Bit 6 : Disable write access watch in region[3] */ -#define MWU_REGIONENCLR_RGN3WA_Pos (6UL) /*!< Position of RGN3WA field. */ -#define MWU_REGIONENCLR_RGN3WA_Msk (0x1UL << MWU_REGIONENCLR_RGN3WA_Pos) /*!< Bit mask of RGN3WA field. */ -#define MWU_REGIONENCLR_RGN3WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN3WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN3WA_Clear (1UL) /*!< Disable write access watch in this region */ - -/* Bit 5 : Disable read access watch in region[2] */ -#define MWU_REGIONENCLR_RGN2RA_Pos (5UL) /*!< Position of RGN2RA field. */ -#define MWU_REGIONENCLR_RGN2RA_Msk (0x1UL << MWU_REGIONENCLR_RGN2RA_Pos) /*!< Bit mask of RGN2RA field. */ -#define MWU_REGIONENCLR_RGN2RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN2RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN2RA_Clear (1UL) /*!< Disable read access watch in this region */ - -/* Bit 4 : Disable write access watch in region[2] */ -#define MWU_REGIONENCLR_RGN2WA_Pos (4UL) /*!< Position of RGN2WA field. */ -#define MWU_REGIONENCLR_RGN2WA_Msk (0x1UL << MWU_REGIONENCLR_RGN2WA_Pos) /*!< Bit mask of RGN2WA field. */ -#define MWU_REGIONENCLR_RGN2WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN2WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN2WA_Clear (1UL) /*!< Disable write access watch in this region */ - -/* Bit 3 : Disable read access watch in region[1] */ -#define MWU_REGIONENCLR_RGN1RA_Pos (3UL) /*!< Position of RGN1RA field. */ -#define MWU_REGIONENCLR_RGN1RA_Msk (0x1UL << MWU_REGIONENCLR_RGN1RA_Pos) /*!< Bit mask of RGN1RA field. */ -#define MWU_REGIONENCLR_RGN1RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN1RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN1RA_Clear (1UL) /*!< Disable read access watch in this region */ - -/* Bit 2 : Disable write access watch in region[1] */ -#define MWU_REGIONENCLR_RGN1WA_Pos (2UL) /*!< Position of RGN1WA field. */ -#define MWU_REGIONENCLR_RGN1WA_Msk (0x1UL << MWU_REGIONENCLR_RGN1WA_Pos) /*!< Bit mask of RGN1WA field. */ -#define MWU_REGIONENCLR_RGN1WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN1WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN1WA_Clear (1UL) /*!< Disable write access watch in this region */ - -/* Bit 1 : Disable read access watch in region[0] */ -#define MWU_REGIONENCLR_RGN0RA_Pos (1UL) /*!< Position of RGN0RA field. */ -#define MWU_REGIONENCLR_RGN0RA_Msk (0x1UL << MWU_REGIONENCLR_RGN0RA_Pos) /*!< Bit mask of RGN0RA field. */ -#define MWU_REGIONENCLR_RGN0RA_Disabled (0UL) /*!< Read access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN0RA_Enabled (1UL) /*!< Read access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN0RA_Clear (1UL) /*!< Disable read access watch in this region */ - -/* Bit 0 : Disable write access watch in region[0] */ -#define MWU_REGIONENCLR_RGN0WA_Pos (0UL) /*!< Position of RGN0WA field. */ -#define MWU_REGIONENCLR_RGN0WA_Msk (0x1UL << MWU_REGIONENCLR_RGN0WA_Pos) /*!< Bit mask of RGN0WA field. */ -#define MWU_REGIONENCLR_RGN0WA_Disabled (0UL) /*!< Write access watch in this region is disabled */ -#define MWU_REGIONENCLR_RGN0WA_Enabled (1UL) /*!< Write access watch in this region is enabled */ -#define MWU_REGIONENCLR_RGN0WA_Clear (1UL) /*!< Disable write access watch in this region */ - -/* Register: MWU_REGION_START */ -/* Description: Description cluster[0]: Start address for region 0 */ - -/* Bits 31..0 : Start address for region */ -#define MWU_REGION_START_START_Pos (0UL) /*!< Position of START field. */ -#define MWU_REGION_START_START_Msk (0xFFFFFFFFUL << MWU_REGION_START_START_Pos) /*!< Bit mask of START field. */ - -/* Register: MWU_REGION_END */ -/* Description: Description cluster[0]: End address of region 0 */ - -/* Bits 31..0 : End address of region. */ -#define MWU_REGION_END_END_Pos (0UL) /*!< Position of END field. */ -#define MWU_REGION_END_END_Msk (0xFFFFFFFFUL << MWU_REGION_END_END_Pos) /*!< Bit mask of END field. */ - -/* Register: MWU_PREGION_START */ -/* Description: Description cluster[0]: Reserved for future use */ - -/* Bits 31..0 : Reserved for future use */ -#define MWU_PREGION_START_START_Pos (0UL) /*!< Position of START field. */ -#define MWU_PREGION_START_START_Msk (0xFFFFFFFFUL << MWU_PREGION_START_START_Pos) /*!< Bit mask of START field. */ - -/* Register: MWU_PREGION_END */ -/* Description: Description cluster[0]: Reserved for future use */ - -/* Bits 31..0 : Reserved for future use */ -#define MWU_PREGION_END_END_Pos (0UL) /*!< Position of END field. */ -#define MWU_PREGION_END_END_Msk (0xFFFFFFFFUL << MWU_PREGION_END_END_Pos) /*!< Bit mask of END field. */ - -/* Register: MWU_PREGION_SUBS */ -/* Description: Description cluster[0]: Subregions of region 0 */ - -/* Bit 31 : Include or exclude subregion 31 in region */ -#define MWU_PREGION_SUBS_SR31_Pos (31UL) /*!< Position of SR31 field. */ -#define MWU_PREGION_SUBS_SR31_Msk (0x1UL << MWU_PREGION_SUBS_SR31_Pos) /*!< Bit mask of SR31 field. */ -#define MWU_PREGION_SUBS_SR31_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR31_Include (1UL) /*!< Include */ - -/* Bit 30 : Include or exclude subregion 30 in region */ -#define MWU_PREGION_SUBS_SR30_Pos (30UL) /*!< Position of SR30 field. */ -#define MWU_PREGION_SUBS_SR30_Msk (0x1UL << MWU_PREGION_SUBS_SR30_Pos) /*!< Bit mask of SR30 field. */ -#define MWU_PREGION_SUBS_SR30_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR30_Include (1UL) /*!< Include */ - -/* Bit 29 : Include or exclude subregion 29 in region */ -#define MWU_PREGION_SUBS_SR29_Pos (29UL) /*!< Position of SR29 field. */ -#define MWU_PREGION_SUBS_SR29_Msk (0x1UL << MWU_PREGION_SUBS_SR29_Pos) /*!< Bit mask of SR29 field. */ -#define MWU_PREGION_SUBS_SR29_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR29_Include (1UL) /*!< Include */ - -/* Bit 28 : Include or exclude subregion 28 in region */ -#define MWU_PREGION_SUBS_SR28_Pos (28UL) /*!< Position of SR28 field. */ -#define MWU_PREGION_SUBS_SR28_Msk (0x1UL << MWU_PREGION_SUBS_SR28_Pos) /*!< Bit mask of SR28 field. */ -#define MWU_PREGION_SUBS_SR28_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR28_Include (1UL) /*!< Include */ - -/* Bit 27 : Include or exclude subregion 27 in region */ -#define MWU_PREGION_SUBS_SR27_Pos (27UL) /*!< Position of SR27 field. */ -#define MWU_PREGION_SUBS_SR27_Msk (0x1UL << MWU_PREGION_SUBS_SR27_Pos) /*!< Bit mask of SR27 field. */ -#define MWU_PREGION_SUBS_SR27_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR27_Include (1UL) /*!< Include */ - -/* Bit 26 : Include or exclude subregion 26 in region */ -#define MWU_PREGION_SUBS_SR26_Pos (26UL) /*!< Position of SR26 field. */ -#define MWU_PREGION_SUBS_SR26_Msk (0x1UL << MWU_PREGION_SUBS_SR26_Pos) /*!< Bit mask of SR26 field. */ -#define MWU_PREGION_SUBS_SR26_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR26_Include (1UL) /*!< Include */ - -/* Bit 25 : Include or exclude subregion 25 in region */ -#define MWU_PREGION_SUBS_SR25_Pos (25UL) /*!< Position of SR25 field. */ -#define MWU_PREGION_SUBS_SR25_Msk (0x1UL << MWU_PREGION_SUBS_SR25_Pos) /*!< Bit mask of SR25 field. */ -#define MWU_PREGION_SUBS_SR25_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR25_Include (1UL) /*!< Include */ - -/* Bit 24 : Include or exclude subregion 24 in region */ -#define MWU_PREGION_SUBS_SR24_Pos (24UL) /*!< Position of SR24 field. */ -#define MWU_PREGION_SUBS_SR24_Msk (0x1UL << MWU_PREGION_SUBS_SR24_Pos) /*!< Bit mask of SR24 field. */ -#define MWU_PREGION_SUBS_SR24_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR24_Include (1UL) /*!< Include */ - -/* Bit 23 : Include or exclude subregion 23 in region */ -#define MWU_PREGION_SUBS_SR23_Pos (23UL) /*!< Position of SR23 field. */ -#define MWU_PREGION_SUBS_SR23_Msk (0x1UL << MWU_PREGION_SUBS_SR23_Pos) /*!< Bit mask of SR23 field. */ -#define MWU_PREGION_SUBS_SR23_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR23_Include (1UL) /*!< Include */ - -/* Bit 22 : Include or exclude subregion 22 in region */ -#define MWU_PREGION_SUBS_SR22_Pos (22UL) /*!< Position of SR22 field. */ -#define MWU_PREGION_SUBS_SR22_Msk (0x1UL << MWU_PREGION_SUBS_SR22_Pos) /*!< Bit mask of SR22 field. */ -#define MWU_PREGION_SUBS_SR22_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR22_Include (1UL) /*!< Include */ - -/* Bit 21 : Include or exclude subregion 21 in region */ -#define MWU_PREGION_SUBS_SR21_Pos (21UL) /*!< Position of SR21 field. */ -#define MWU_PREGION_SUBS_SR21_Msk (0x1UL << MWU_PREGION_SUBS_SR21_Pos) /*!< Bit mask of SR21 field. */ -#define MWU_PREGION_SUBS_SR21_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR21_Include (1UL) /*!< Include */ - -/* Bit 20 : Include or exclude subregion 20 in region */ -#define MWU_PREGION_SUBS_SR20_Pos (20UL) /*!< Position of SR20 field. */ -#define MWU_PREGION_SUBS_SR20_Msk (0x1UL << MWU_PREGION_SUBS_SR20_Pos) /*!< Bit mask of SR20 field. */ -#define MWU_PREGION_SUBS_SR20_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR20_Include (1UL) /*!< Include */ - -/* Bit 19 : Include or exclude subregion 19 in region */ -#define MWU_PREGION_SUBS_SR19_Pos (19UL) /*!< Position of SR19 field. */ -#define MWU_PREGION_SUBS_SR19_Msk (0x1UL << MWU_PREGION_SUBS_SR19_Pos) /*!< Bit mask of SR19 field. */ -#define MWU_PREGION_SUBS_SR19_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR19_Include (1UL) /*!< Include */ - -/* Bit 18 : Include or exclude subregion 18 in region */ -#define MWU_PREGION_SUBS_SR18_Pos (18UL) /*!< Position of SR18 field. */ -#define MWU_PREGION_SUBS_SR18_Msk (0x1UL << MWU_PREGION_SUBS_SR18_Pos) /*!< Bit mask of SR18 field. */ -#define MWU_PREGION_SUBS_SR18_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR18_Include (1UL) /*!< Include */ - -/* Bit 17 : Include or exclude subregion 17 in region */ -#define MWU_PREGION_SUBS_SR17_Pos (17UL) /*!< Position of SR17 field. */ -#define MWU_PREGION_SUBS_SR17_Msk (0x1UL << MWU_PREGION_SUBS_SR17_Pos) /*!< Bit mask of SR17 field. */ -#define MWU_PREGION_SUBS_SR17_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR17_Include (1UL) /*!< Include */ - -/* Bit 16 : Include or exclude subregion 16 in region */ -#define MWU_PREGION_SUBS_SR16_Pos (16UL) /*!< Position of SR16 field. */ -#define MWU_PREGION_SUBS_SR16_Msk (0x1UL << MWU_PREGION_SUBS_SR16_Pos) /*!< Bit mask of SR16 field. */ -#define MWU_PREGION_SUBS_SR16_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR16_Include (1UL) /*!< Include */ - -/* Bit 15 : Include or exclude subregion 15 in region */ -#define MWU_PREGION_SUBS_SR15_Pos (15UL) /*!< Position of SR15 field. */ -#define MWU_PREGION_SUBS_SR15_Msk (0x1UL << MWU_PREGION_SUBS_SR15_Pos) /*!< Bit mask of SR15 field. */ -#define MWU_PREGION_SUBS_SR15_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR15_Include (1UL) /*!< Include */ - -/* Bit 14 : Include or exclude subregion 14 in region */ -#define MWU_PREGION_SUBS_SR14_Pos (14UL) /*!< Position of SR14 field. */ -#define MWU_PREGION_SUBS_SR14_Msk (0x1UL << MWU_PREGION_SUBS_SR14_Pos) /*!< Bit mask of SR14 field. */ -#define MWU_PREGION_SUBS_SR14_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR14_Include (1UL) /*!< Include */ - -/* Bit 13 : Include or exclude subregion 13 in region */ -#define MWU_PREGION_SUBS_SR13_Pos (13UL) /*!< Position of SR13 field. */ -#define MWU_PREGION_SUBS_SR13_Msk (0x1UL << MWU_PREGION_SUBS_SR13_Pos) /*!< Bit mask of SR13 field. */ -#define MWU_PREGION_SUBS_SR13_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR13_Include (1UL) /*!< Include */ - -/* Bit 12 : Include or exclude subregion 12 in region */ -#define MWU_PREGION_SUBS_SR12_Pos (12UL) /*!< Position of SR12 field. */ -#define MWU_PREGION_SUBS_SR12_Msk (0x1UL << MWU_PREGION_SUBS_SR12_Pos) /*!< Bit mask of SR12 field. */ -#define MWU_PREGION_SUBS_SR12_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR12_Include (1UL) /*!< Include */ - -/* Bit 11 : Include or exclude subregion 11 in region */ -#define MWU_PREGION_SUBS_SR11_Pos (11UL) /*!< Position of SR11 field. */ -#define MWU_PREGION_SUBS_SR11_Msk (0x1UL << MWU_PREGION_SUBS_SR11_Pos) /*!< Bit mask of SR11 field. */ -#define MWU_PREGION_SUBS_SR11_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR11_Include (1UL) /*!< Include */ - -/* Bit 10 : Include or exclude subregion 10 in region */ -#define MWU_PREGION_SUBS_SR10_Pos (10UL) /*!< Position of SR10 field. */ -#define MWU_PREGION_SUBS_SR10_Msk (0x1UL << MWU_PREGION_SUBS_SR10_Pos) /*!< Bit mask of SR10 field. */ -#define MWU_PREGION_SUBS_SR10_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR10_Include (1UL) /*!< Include */ - -/* Bit 9 : Include or exclude subregion 9 in region */ -#define MWU_PREGION_SUBS_SR9_Pos (9UL) /*!< Position of SR9 field. */ -#define MWU_PREGION_SUBS_SR9_Msk (0x1UL << MWU_PREGION_SUBS_SR9_Pos) /*!< Bit mask of SR9 field. */ -#define MWU_PREGION_SUBS_SR9_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR9_Include (1UL) /*!< Include */ - -/* Bit 8 : Include or exclude subregion 8 in region */ -#define MWU_PREGION_SUBS_SR8_Pos (8UL) /*!< Position of SR8 field. */ -#define MWU_PREGION_SUBS_SR8_Msk (0x1UL << MWU_PREGION_SUBS_SR8_Pos) /*!< Bit mask of SR8 field. */ -#define MWU_PREGION_SUBS_SR8_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR8_Include (1UL) /*!< Include */ - -/* Bit 7 : Include or exclude subregion 7 in region */ -#define MWU_PREGION_SUBS_SR7_Pos (7UL) /*!< Position of SR7 field. */ -#define MWU_PREGION_SUBS_SR7_Msk (0x1UL << MWU_PREGION_SUBS_SR7_Pos) /*!< Bit mask of SR7 field. */ -#define MWU_PREGION_SUBS_SR7_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR7_Include (1UL) /*!< Include */ - -/* Bit 6 : Include or exclude subregion 6 in region */ -#define MWU_PREGION_SUBS_SR6_Pos (6UL) /*!< Position of SR6 field. */ -#define MWU_PREGION_SUBS_SR6_Msk (0x1UL << MWU_PREGION_SUBS_SR6_Pos) /*!< Bit mask of SR6 field. */ -#define MWU_PREGION_SUBS_SR6_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR6_Include (1UL) /*!< Include */ - -/* Bit 5 : Include or exclude subregion 5 in region */ -#define MWU_PREGION_SUBS_SR5_Pos (5UL) /*!< Position of SR5 field. */ -#define MWU_PREGION_SUBS_SR5_Msk (0x1UL << MWU_PREGION_SUBS_SR5_Pos) /*!< Bit mask of SR5 field. */ -#define MWU_PREGION_SUBS_SR5_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR5_Include (1UL) /*!< Include */ - -/* Bit 4 : Include or exclude subregion 4 in region */ -#define MWU_PREGION_SUBS_SR4_Pos (4UL) /*!< Position of SR4 field. */ -#define MWU_PREGION_SUBS_SR4_Msk (0x1UL << MWU_PREGION_SUBS_SR4_Pos) /*!< Bit mask of SR4 field. */ -#define MWU_PREGION_SUBS_SR4_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR4_Include (1UL) /*!< Include */ - -/* Bit 3 : Include or exclude subregion 3 in region */ -#define MWU_PREGION_SUBS_SR3_Pos (3UL) /*!< Position of SR3 field. */ -#define MWU_PREGION_SUBS_SR3_Msk (0x1UL << MWU_PREGION_SUBS_SR3_Pos) /*!< Bit mask of SR3 field. */ -#define MWU_PREGION_SUBS_SR3_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR3_Include (1UL) /*!< Include */ - -/* Bit 2 : Include or exclude subregion 2 in region */ -#define MWU_PREGION_SUBS_SR2_Pos (2UL) /*!< Position of SR2 field. */ -#define MWU_PREGION_SUBS_SR2_Msk (0x1UL << MWU_PREGION_SUBS_SR2_Pos) /*!< Bit mask of SR2 field. */ -#define MWU_PREGION_SUBS_SR2_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR2_Include (1UL) /*!< Include */ - -/* Bit 1 : Include or exclude subregion 1 in region */ -#define MWU_PREGION_SUBS_SR1_Pos (1UL) /*!< Position of SR1 field. */ -#define MWU_PREGION_SUBS_SR1_Msk (0x1UL << MWU_PREGION_SUBS_SR1_Pos) /*!< Bit mask of SR1 field. */ -#define MWU_PREGION_SUBS_SR1_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR1_Include (1UL) /*!< Include */ - -/* Bit 0 : Include or exclude subregion 0 in region */ -#define MWU_PREGION_SUBS_SR0_Pos (0UL) /*!< Position of SR0 field. */ -#define MWU_PREGION_SUBS_SR0_Msk (0x1UL << MWU_PREGION_SUBS_SR0_Pos) /*!< Bit mask of SR0 field. */ -#define MWU_PREGION_SUBS_SR0_Exclude (0UL) /*!< Exclude */ -#define MWU_PREGION_SUBS_SR0_Include (1UL) /*!< Include */ - - -/* Peripheral: NFCT */ -/* Description: NFC-A compatible radio */ - -/* Register: NFCT_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 5 : Shortcut between TXFRAMEEND event and ENABLERXDATA task */ -#define NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Pos (5UL) /*!< Position of TXFRAMEEND_ENABLERXDATA field. */ -#define NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Msk (0x1UL << NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Pos) /*!< Bit mask of TXFRAMEEND_ENABLERXDATA field. */ -#define NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Disabled (0UL) /*!< Disable shortcut */ -#define NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between FIELDLOST event and SENSE task */ -#define NFCT_SHORTS_FIELDLOST_SENSE_Pos (1UL) /*!< Position of FIELDLOST_SENSE field. */ -#define NFCT_SHORTS_FIELDLOST_SENSE_Msk (0x1UL << NFCT_SHORTS_FIELDLOST_SENSE_Pos) /*!< Bit mask of FIELDLOST_SENSE field. */ -#define NFCT_SHORTS_FIELDLOST_SENSE_Disabled (0UL) /*!< Disable shortcut */ -#define NFCT_SHORTS_FIELDLOST_SENSE_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between FIELDDETECTED event and ACTIVATE task */ -#define NFCT_SHORTS_FIELDDETECTED_ACTIVATE_Pos (0UL) /*!< Position of FIELDDETECTED_ACTIVATE field. */ -#define NFCT_SHORTS_FIELDDETECTED_ACTIVATE_Msk (0x1UL << NFCT_SHORTS_FIELDDETECTED_ACTIVATE_Pos) /*!< Bit mask of FIELDDETECTED_ACTIVATE field. */ -#define NFCT_SHORTS_FIELDDETECTED_ACTIVATE_Disabled (0UL) /*!< Disable shortcut */ -#define NFCT_SHORTS_FIELDDETECTED_ACTIVATE_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: NFCT_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 20 : Enable or disable interrupt for STARTED event */ -#define NFCT_INTEN_STARTED_Pos (20UL) /*!< Position of STARTED field. */ -#define NFCT_INTEN_STARTED_Msk (0x1UL << NFCT_INTEN_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define NFCT_INTEN_STARTED_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_STARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for SELECTED event */ -#define NFCT_INTEN_SELECTED_Pos (19UL) /*!< Position of SELECTED field. */ -#define NFCT_INTEN_SELECTED_Msk (0x1UL << NFCT_INTEN_SELECTED_Pos) /*!< Bit mask of SELECTED field. */ -#define NFCT_INTEN_SELECTED_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_SELECTED_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable interrupt for COLLISION event */ -#define NFCT_INTEN_COLLISION_Pos (18UL) /*!< Position of COLLISION field. */ -#define NFCT_INTEN_COLLISION_Msk (0x1UL << NFCT_INTEN_COLLISION_Pos) /*!< Bit mask of COLLISION field. */ -#define NFCT_INTEN_COLLISION_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_COLLISION_Enabled (1UL) /*!< Enable */ - -/* Bit 14 : Enable or disable interrupt for AUTOCOLRESSTARTED event */ -#define NFCT_INTEN_AUTOCOLRESSTARTED_Pos (14UL) /*!< Position of AUTOCOLRESSTARTED field. */ -#define NFCT_INTEN_AUTOCOLRESSTARTED_Msk (0x1UL << NFCT_INTEN_AUTOCOLRESSTARTED_Pos) /*!< Bit mask of AUTOCOLRESSTARTED field. */ -#define NFCT_INTEN_AUTOCOLRESSTARTED_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_AUTOCOLRESSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 12 : Enable or disable interrupt for ENDTX event */ -#define NFCT_INTEN_ENDTX_Pos (12UL) /*!< Position of ENDTX field. */ -#define NFCT_INTEN_ENDTX_Msk (0x1UL << NFCT_INTEN_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define NFCT_INTEN_ENDTX_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_ENDTX_Enabled (1UL) /*!< Enable */ - -/* Bit 11 : Enable or disable interrupt for ENDRX event */ -#define NFCT_INTEN_ENDRX_Pos (11UL) /*!< Position of ENDRX field. */ -#define NFCT_INTEN_ENDRX_Msk (0x1UL << NFCT_INTEN_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define NFCT_INTEN_ENDRX_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_ENDRX_Enabled (1UL) /*!< Enable */ - -/* Bit 10 : Enable or disable interrupt for RXERROR event */ -#define NFCT_INTEN_RXERROR_Pos (10UL) /*!< Position of RXERROR field. */ -#define NFCT_INTEN_RXERROR_Msk (0x1UL << NFCT_INTEN_RXERROR_Pos) /*!< Bit mask of RXERROR field. */ -#define NFCT_INTEN_RXERROR_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_RXERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for ERROR event */ -#define NFCT_INTEN_ERROR_Pos (7UL) /*!< Position of ERROR field. */ -#define NFCT_INTEN_ERROR_Msk (0x1UL << NFCT_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define NFCT_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for RXFRAMEEND event */ -#define NFCT_INTEN_RXFRAMEEND_Pos (6UL) /*!< Position of RXFRAMEEND field. */ -#define NFCT_INTEN_RXFRAMEEND_Msk (0x1UL << NFCT_INTEN_RXFRAMEEND_Pos) /*!< Bit mask of RXFRAMEEND field. */ -#define NFCT_INTEN_RXFRAMEEND_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_RXFRAMEEND_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for RXFRAMESTART event */ -#define NFCT_INTEN_RXFRAMESTART_Pos (5UL) /*!< Position of RXFRAMESTART field. */ -#define NFCT_INTEN_RXFRAMESTART_Msk (0x1UL << NFCT_INTEN_RXFRAMESTART_Pos) /*!< Bit mask of RXFRAMESTART field. */ -#define NFCT_INTEN_RXFRAMESTART_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_RXFRAMESTART_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for TXFRAMEEND event */ -#define NFCT_INTEN_TXFRAMEEND_Pos (4UL) /*!< Position of TXFRAMEEND field. */ -#define NFCT_INTEN_TXFRAMEEND_Msk (0x1UL << NFCT_INTEN_TXFRAMEEND_Pos) /*!< Bit mask of TXFRAMEEND field. */ -#define NFCT_INTEN_TXFRAMEEND_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_TXFRAMEEND_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for TXFRAMESTART event */ -#define NFCT_INTEN_TXFRAMESTART_Pos (3UL) /*!< Position of TXFRAMESTART field. */ -#define NFCT_INTEN_TXFRAMESTART_Msk (0x1UL << NFCT_INTEN_TXFRAMESTART_Pos) /*!< Bit mask of TXFRAMESTART field. */ -#define NFCT_INTEN_TXFRAMESTART_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_TXFRAMESTART_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for FIELDLOST event */ -#define NFCT_INTEN_FIELDLOST_Pos (2UL) /*!< Position of FIELDLOST field. */ -#define NFCT_INTEN_FIELDLOST_Msk (0x1UL << NFCT_INTEN_FIELDLOST_Pos) /*!< Bit mask of FIELDLOST field. */ -#define NFCT_INTEN_FIELDLOST_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_FIELDLOST_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for FIELDDETECTED event */ -#define NFCT_INTEN_FIELDDETECTED_Pos (1UL) /*!< Position of FIELDDETECTED field. */ -#define NFCT_INTEN_FIELDDETECTED_Msk (0x1UL << NFCT_INTEN_FIELDDETECTED_Pos) /*!< Bit mask of FIELDDETECTED field. */ -#define NFCT_INTEN_FIELDDETECTED_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_FIELDDETECTED_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for READY event */ -#define NFCT_INTEN_READY_Pos (0UL) /*!< Position of READY field. */ -#define NFCT_INTEN_READY_Msk (0x1UL << NFCT_INTEN_READY_Pos) /*!< Bit mask of READY field. */ -#define NFCT_INTEN_READY_Disabled (0UL) /*!< Disable */ -#define NFCT_INTEN_READY_Enabled (1UL) /*!< Enable */ - -/* Register: NFCT_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 20 : Write '1' to Enable interrupt for STARTED event */ -#define NFCT_INTENSET_STARTED_Pos (20UL) /*!< Position of STARTED field. */ -#define NFCT_INTENSET_STARTED_Msk (0x1UL << NFCT_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define NFCT_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for SELECTED event */ -#define NFCT_INTENSET_SELECTED_Pos (19UL) /*!< Position of SELECTED field. */ -#define NFCT_INTENSET_SELECTED_Msk (0x1UL << NFCT_INTENSET_SELECTED_Pos) /*!< Bit mask of SELECTED field. */ -#define NFCT_INTENSET_SELECTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_SELECTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_SELECTED_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for COLLISION event */ -#define NFCT_INTENSET_COLLISION_Pos (18UL) /*!< Position of COLLISION field. */ -#define NFCT_INTENSET_COLLISION_Msk (0x1UL << NFCT_INTENSET_COLLISION_Pos) /*!< Bit mask of COLLISION field. */ -#define NFCT_INTENSET_COLLISION_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_COLLISION_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_COLLISION_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for AUTOCOLRESSTARTED event */ -#define NFCT_INTENSET_AUTOCOLRESSTARTED_Pos (14UL) /*!< Position of AUTOCOLRESSTARTED field. */ -#define NFCT_INTENSET_AUTOCOLRESSTARTED_Msk (0x1UL << NFCT_INTENSET_AUTOCOLRESSTARTED_Pos) /*!< Bit mask of AUTOCOLRESSTARTED field. */ -#define NFCT_INTENSET_AUTOCOLRESSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_AUTOCOLRESSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_AUTOCOLRESSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for ENDTX event */ -#define NFCT_INTENSET_ENDTX_Pos (12UL) /*!< Position of ENDTX field. */ -#define NFCT_INTENSET_ENDTX_Msk (0x1UL << NFCT_INTENSET_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define NFCT_INTENSET_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_ENDTX_Set (1UL) /*!< Enable */ - -/* Bit 11 : Write '1' to Enable interrupt for ENDRX event */ -#define NFCT_INTENSET_ENDRX_Pos (11UL) /*!< Position of ENDRX field. */ -#define NFCT_INTENSET_ENDRX_Msk (0x1UL << NFCT_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define NFCT_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for RXERROR event */ -#define NFCT_INTENSET_RXERROR_Pos (10UL) /*!< Position of RXERROR field. */ -#define NFCT_INTENSET_RXERROR_Msk (0x1UL << NFCT_INTENSET_RXERROR_Pos) /*!< Bit mask of RXERROR field. */ -#define NFCT_INTENSET_RXERROR_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_RXERROR_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_RXERROR_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for ERROR event */ -#define NFCT_INTENSET_ERROR_Pos (7UL) /*!< Position of ERROR field. */ -#define NFCT_INTENSET_ERROR_Msk (0x1UL << NFCT_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define NFCT_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for RXFRAMEEND event */ -#define NFCT_INTENSET_RXFRAMEEND_Pos (6UL) /*!< Position of RXFRAMEEND field. */ -#define NFCT_INTENSET_RXFRAMEEND_Msk (0x1UL << NFCT_INTENSET_RXFRAMEEND_Pos) /*!< Bit mask of RXFRAMEEND field. */ -#define NFCT_INTENSET_RXFRAMEEND_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_RXFRAMEEND_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_RXFRAMEEND_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for RXFRAMESTART event */ -#define NFCT_INTENSET_RXFRAMESTART_Pos (5UL) /*!< Position of RXFRAMESTART field. */ -#define NFCT_INTENSET_RXFRAMESTART_Msk (0x1UL << NFCT_INTENSET_RXFRAMESTART_Pos) /*!< Bit mask of RXFRAMESTART field. */ -#define NFCT_INTENSET_RXFRAMESTART_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_RXFRAMESTART_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_RXFRAMESTART_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for TXFRAMEEND event */ -#define NFCT_INTENSET_TXFRAMEEND_Pos (4UL) /*!< Position of TXFRAMEEND field. */ -#define NFCT_INTENSET_TXFRAMEEND_Msk (0x1UL << NFCT_INTENSET_TXFRAMEEND_Pos) /*!< Bit mask of TXFRAMEEND field. */ -#define NFCT_INTENSET_TXFRAMEEND_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_TXFRAMEEND_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_TXFRAMEEND_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for TXFRAMESTART event */ -#define NFCT_INTENSET_TXFRAMESTART_Pos (3UL) /*!< Position of TXFRAMESTART field. */ -#define NFCT_INTENSET_TXFRAMESTART_Msk (0x1UL << NFCT_INTENSET_TXFRAMESTART_Pos) /*!< Bit mask of TXFRAMESTART field. */ -#define NFCT_INTENSET_TXFRAMESTART_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_TXFRAMESTART_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_TXFRAMESTART_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for FIELDLOST event */ -#define NFCT_INTENSET_FIELDLOST_Pos (2UL) /*!< Position of FIELDLOST field. */ -#define NFCT_INTENSET_FIELDLOST_Msk (0x1UL << NFCT_INTENSET_FIELDLOST_Pos) /*!< Bit mask of FIELDLOST field. */ -#define NFCT_INTENSET_FIELDLOST_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_FIELDLOST_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_FIELDLOST_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for FIELDDETECTED event */ -#define NFCT_INTENSET_FIELDDETECTED_Pos (1UL) /*!< Position of FIELDDETECTED field. */ -#define NFCT_INTENSET_FIELDDETECTED_Msk (0x1UL << NFCT_INTENSET_FIELDDETECTED_Pos) /*!< Bit mask of FIELDDETECTED field. */ -#define NFCT_INTENSET_FIELDDETECTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_FIELDDETECTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_FIELDDETECTED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define NFCT_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define NFCT_INTENSET_READY_Msk (0x1UL << NFCT_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define NFCT_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: NFCT_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 20 : Write '1' to Disable interrupt for STARTED event */ -#define NFCT_INTENCLR_STARTED_Pos (20UL) /*!< Position of STARTED field. */ -#define NFCT_INTENCLR_STARTED_Msk (0x1UL << NFCT_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define NFCT_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for SELECTED event */ -#define NFCT_INTENCLR_SELECTED_Pos (19UL) /*!< Position of SELECTED field. */ -#define NFCT_INTENCLR_SELECTED_Msk (0x1UL << NFCT_INTENCLR_SELECTED_Pos) /*!< Bit mask of SELECTED field. */ -#define NFCT_INTENCLR_SELECTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_SELECTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_SELECTED_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for COLLISION event */ -#define NFCT_INTENCLR_COLLISION_Pos (18UL) /*!< Position of COLLISION field. */ -#define NFCT_INTENCLR_COLLISION_Msk (0x1UL << NFCT_INTENCLR_COLLISION_Pos) /*!< Bit mask of COLLISION field. */ -#define NFCT_INTENCLR_COLLISION_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_COLLISION_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_COLLISION_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for AUTOCOLRESSTARTED event */ -#define NFCT_INTENCLR_AUTOCOLRESSTARTED_Pos (14UL) /*!< Position of AUTOCOLRESSTARTED field. */ -#define NFCT_INTENCLR_AUTOCOLRESSTARTED_Msk (0x1UL << NFCT_INTENCLR_AUTOCOLRESSTARTED_Pos) /*!< Bit mask of AUTOCOLRESSTARTED field. */ -#define NFCT_INTENCLR_AUTOCOLRESSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_AUTOCOLRESSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_AUTOCOLRESSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for ENDTX event */ -#define NFCT_INTENCLR_ENDTX_Pos (12UL) /*!< Position of ENDTX field. */ -#define NFCT_INTENCLR_ENDTX_Msk (0x1UL << NFCT_INTENCLR_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define NFCT_INTENCLR_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_ENDTX_Clear (1UL) /*!< Disable */ - -/* Bit 11 : Write '1' to Disable interrupt for ENDRX event */ -#define NFCT_INTENCLR_ENDRX_Pos (11UL) /*!< Position of ENDRX field. */ -#define NFCT_INTENCLR_ENDRX_Msk (0x1UL << NFCT_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define NFCT_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for RXERROR event */ -#define NFCT_INTENCLR_RXERROR_Pos (10UL) /*!< Position of RXERROR field. */ -#define NFCT_INTENCLR_RXERROR_Msk (0x1UL << NFCT_INTENCLR_RXERROR_Pos) /*!< Bit mask of RXERROR field. */ -#define NFCT_INTENCLR_RXERROR_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_RXERROR_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_RXERROR_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for ERROR event */ -#define NFCT_INTENCLR_ERROR_Pos (7UL) /*!< Position of ERROR field. */ -#define NFCT_INTENCLR_ERROR_Msk (0x1UL << NFCT_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define NFCT_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for RXFRAMEEND event */ -#define NFCT_INTENCLR_RXFRAMEEND_Pos (6UL) /*!< Position of RXFRAMEEND field. */ -#define NFCT_INTENCLR_RXFRAMEEND_Msk (0x1UL << NFCT_INTENCLR_RXFRAMEEND_Pos) /*!< Bit mask of RXFRAMEEND field. */ -#define NFCT_INTENCLR_RXFRAMEEND_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_RXFRAMEEND_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_RXFRAMEEND_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for RXFRAMESTART event */ -#define NFCT_INTENCLR_RXFRAMESTART_Pos (5UL) /*!< Position of RXFRAMESTART field. */ -#define NFCT_INTENCLR_RXFRAMESTART_Msk (0x1UL << NFCT_INTENCLR_RXFRAMESTART_Pos) /*!< Bit mask of RXFRAMESTART field. */ -#define NFCT_INTENCLR_RXFRAMESTART_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_RXFRAMESTART_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_RXFRAMESTART_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for TXFRAMEEND event */ -#define NFCT_INTENCLR_TXFRAMEEND_Pos (4UL) /*!< Position of TXFRAMEEND field. */ -#define NFCT_INTENCLR_TXFRAMEEND_Msk (0x1UL << NFCT_INTENCLR_TXFRAMEEND_Pos) /*!< Bit mask of TXFRAMEEND field. */ -#define NFCT_INTENCLR_TXFRAMEEND_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_TXFRAMEEND_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_TXFRAMEEND_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for TXFRAMESTART event */ -#define NFCT_INTENCLR_TXFRAMESTART_Pos (3UL) /*!< Position of TXFRAMESTART field. */ -#define NFCT_INTENCLR_TXFRAMESTART_Msk (0x1UL << NFCT_INTENCLR_TXFRAMESTART_Pos) /*!< Bit mask of TXFRAMESTART field. */ -#define NFCT_INTENCLR_TXFRAMESTART_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_TXFRAMESTART_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_TXFRAMESTART_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for FIELDLOST event */ -#define NFCT_INTENCLR_FIELDLOST_Pos (2UL) /*!< Position of FIELDLOST field. */ -#define NFCT_INTENCLR_FIELDLOST_Msk (0x1UL << NFCT_INTENCLR_FIELDLOST_Pos) /*!< Bit mask of FIELDLOST field. */ -#define NFCT_INTENCLR_FIELDLOST_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_FIELDLOST_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_FIELDLOST_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for FIELDDETECTED event */ -#define NFCT_INTENCLR_FIELDDETECTED_Pos (1UL) /*!< Position of FIELDDETECTED field. */ -#define NFCT_INTENCLR_FIELDDETECTED_Msk (0x1UL << NFCT_INTENCLR_FIELDDETECTED_Pos) /*!< Bit mask of FIELDDETECTED field. */ -#define NFCT_INTENCLR_FIELDDETECTED_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_FIELDDETECTED_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_FIELDDETECTED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define NFCT_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define NFCT_INTENCLR_READY_Msk (0x1UL << NFCT_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define NFCT_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define NFCT_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define NFCT_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: NFCT_ERRORSTATUS */ -/* Description: NFC Error Status register */ - -/* Bit 0 : No STARTTX task triggered before expiration of the time set in FRAMEDELAYMAX */ -#define NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Pos (0UL) /*!< Position of FRAMEDELAYTIMEOUT field. */ -#define NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk (0x1UL << NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Pos) /*!< Bit mask of FRAMEDELAYTIMEOUT field. */ - -/* Register: NFCT_FRAMESTATUS_RX */ -/* Description: Result of last incoming frame */ - -/* Bit 3 : Overrun detected */ -#define NFCT_FRAMESTATUS_RX_OVERRUN_Pos (3UL) /*!< Position of OVERRUN field. */ -#define NFCT_FRAMESTATUS_RX_OVERRUN_Msk (0x1UL << NFCT_FRAMESTATUS_RX_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define NFCT_FRAMESTATUS_RX_OVERRUN_NoOverrun (0UL) /*!< No overrun detected */ -#define NFCT_FRAMESTATUS_RX_OVERRUN_Overrun (1UL) /*!< Overrun error */ - -/* Bit 2 : Parity status of received frame */ -#define NFCT_FRAMESTATUS_RX_PARITYSTATUS_Pos (2UL) /*!< Position of PARITYSTATUS field. */ -#define NFCT_FRAMESTATUS_RX_PARITYSTATUS_Msk (0x1UL << NFCT_FRAMESTATUS_RX_PARITYSTATUS_Pos) /*!< Bit mask of PARITYSTATUS field. */ -#define NFCT_FRAMESTATUS_RX_PARITYSTATUS_ParityOK (0UL) /*!< Frame received with parity OK */ -#define NFCT_FRAMESTATUS_RX_PARITYSTATUS_ParityError (1UL) /*!< Frame received with parity error */ - -/* Bit 0 : No valid end of frame (EoF) detected */ -#define NFCT_FRAMESTATUS_RX_CRCERROR_Pos (0UL) /*!< Position of CRCERROR field. */ -#define NFCT_FRAMESTATUS_RX_CRCERROR_Msk (0x1UL << NFCT_FRAMESTATUS_RX_CRCERROR_Pos) /*!< Bit mask of CRCERROR field. */ -#define NFCT_FRAMESTATUS_RX_CRCERROR_CRCCorrect (0UL) /*!< Valid CRC detected */ -#define NFCT_FRAMESTATUS_RX_CRCERROR_CRCError (1UL) /*!< CRC received does not match local check */ - -/* Register: NFCT_NFCTAGSTATE */ -/* Description: NfcTag state register */ - -/* Bits 2..0 : NfcTag state */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_Pos (0UL) /*!< Position of NFCTAGSTATE field. */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk (0x7UL << NFCT_NFCTAGSTATE_NFCTAGSTATE_Pos) /*!< Bit mask of NFCTAGSTATE field. */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_Disabled (0UL) /*!< Disabled or sense */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_RampUp (2UL) /*!< RampUp */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_Idle (3UL) /*!< Idle */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_Receive (4UL) /*!< Receive */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_FrameDelay (5UL) /*!< FrameDelay */ -#define NFCT_NFCTAGSTATE_NFCTAGSTATE_Transmit (6UL) /*!< Transmit */ - -/* Register: NFCT_FIELDPRESENT */ -/* Description: Indicates the presence or not of a valid field */ - -/* Bit 1 : Indicates if the low level has locked to the field */ -#define NFCT_FIELDPRESENT_LOCKDETECT_Pos (1UL) /*!< Position of LOCKDETECT field. */ -#define NFCT_FIELDPRESENT_LOCKDETECT_Msk (0x1UL << NFCT_FIELDPRESENT_LOCKDETECT_Pos) /*!< Bit mask of LOCKDETECT field. */ -#define NFCT_FIELDPRESENT_LOCKDETECT_NotLocked (0UL) /*!< Not locked to field */ -#define NFCT_FIELDPRESENT_LOCKDETECT_Locked (1UL) /*!< Locked to field */ - -/* Bit 0 : Indicates if a valid field is present. Available only in the activated state. */ -#define NFCT_FIELDPRESENT_FIELDPRESENT_Pos (0UL) /*!< Position of FIELDPRESENT field. */ -#define NFCT_FIELDPRESENT_FIELDPRESENT_Msk (0x1UL << NFCT_FIELDPRESENT_FIELDPRESENT_Pos) /*!< Bit mask of FIELDPRESENT field. */ -#define NFCT_FIELDPRESENT_FIELDPRESENT_NoField (0UL) /*!< No valid field detected */ -#define NFCT_FIELDPRESENT_FIELDPRESENT_FieldPresent (1UL) /*!< Valid field detected */ - -/* Register: NFCT_FRAMEDELAYMIN */ -/* Description: Minimum frame delay */ - -/* Bits 15..0 : Minimum frame delay in number of 13.56 MHz clocks */ -#define NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Pos (0UL) /*!< Position of FRAMEDELAYMIN field. */ -#define NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Msk (0xFFFFUL << NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Pos) /*!< Bit mask of FRAMEDELAYMIN field. */ - -/* Register: NFCT_FRAMEDELAYMAX */ -/* Description: Maximum frame delay */ - -/* Bits 19..0 : Maximum frame delay in number of 13.56 MHz clocks */ -#define NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Pos (0UL) /*!< Position of FRAMEDELAYMAX field. */ -#define NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Msk (0xFFFFFUL << NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Pos) /*!< Bit mask of FRAMEDELAYMAX field. */ - -/* Register: NFCT_FRAMEDELAYMODE */ -/* Description: Configuration register for the Frame Delay Timer */ - -/* Bits 1..0 : Configuration register for the Frame Delay Timer */ -#define NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Pos (0UL) /*!< Position of FRAMEDELAYMODE field. */ -#define NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Msk (0x3UL << NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Pos) /*!< Bit mask of FRAMEDELAYMODE field. */ -#define NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_FreeRun (0UL) /*!< Transmission is independent of frame timer and will start when the STARTTX task is triggered. No timeout. */ -#define NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Window (1UL) /*!< Frame is transmitted between FRAMEDELAYMIN and FRAMEDELAYMAX */ -#define NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_ExactVal (2UL) /*!< Frame is transmitted exactly at FRAMEDELAYMAX */ -#define NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_WindowGrid (3UL) /*!< Frame is transmitted on a bit grid between FRAMEDELAYMIN and FRAMEDELAYMAX */ - -/* Register: NFCT_PACKETPTR */ -/* Description: Packet pointer for TXD and RXD data storage in Data RAM */ - -/* Bits 31..0 : Packet pointer for TXD and RXD data storage in Data RAM. This address is a byte-aligned RAM address. */ -#define NFCT_PACKETPTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define NFCT_PACKETPTR_PTR_Msk (0xFFFFFFFFUL << NFCT_PACKETPTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: NFCT_MAXLEN */ -/* Description: Size of the RAM buffer allocated to TXD and RXD data storage each */ - -/* Bits 8..0 : Size of the RAM buffer allocated to TXD and RXD data storage each */ -#define NFCT_MAXLEN_MAXLEN_Pos (0UL) /*!< Position of MAXLEN field. */ -#define NFCT_MAXLEN_MAXLEN_Msk (0x1FFUL << NFCT_MAXLEN_MAXLEN_Pos) /*!< Bit mask of MAXLEN field. */ - -/* Register: NFCT_TXD_FRAMECONFIG */ -/* Description: Configuration of outgoing frames */ - -/* Bit 4 : CRC mode for outgoing frames */ -#define NFCT_TXD_FRAMECONFIG_CRCMODETX_Pos (4UL) /*!< Position of CRCMODETX field. */ -#define NFCT_TXD_FRAMECONFIG_CRCMODETX_Msk (0x1UL << NFCT_TXD_FRAMECONFIG_CRCMODETX_Pos) /*!< Bit mask of CRCMODETX field. */ -#define NFCT_TXD_FRAMECONFIG_CRCMODETX_NoCRCTX (0UL) /*!< CRC is not added to the frame */ -#define NFCT_TXD_FRAMECONFIG_CRCMODETX_CRC16TX (1UL) /*!< 16 bit CRC added to the frame based on all the data read from RAM that is used in the frame */ - -/* Bit 2 : Adding SoF or not in TX frames */ -#define NFCT_TXD_FRAMECONFIG_SOF_Pos (2UL) /*!< Position of SOF field. */ -#define NFCT_TXD_FRAMECONFIG_SOF_Msk (0x1UL << NFCT_TXD_FRAMECONFIG_SOF_Pos) /*!< Bit mask of SOF field. */ -#define NFCT_TXD_FRAMECONFIG_SOF_NoSoF (0UL) /*!< SoF symbol not added */ -#define NFCT_TXD_FRAMECONFIG_SOF_SoF (1UL) /*!< SoF symbol added */ - -/* Bit 1 : Discarding unused bits at start or end of a frame */ -#define NFCT_TXD_FRAMECONFIG_DISCARDMODE_Pos (1UL) /*!< Position of DISCARDMODE field. */ -#define NFCT_TXD_FRAMECONFIG_DISCARDMODE_Msk (0x1UL << NFCT_TXD_FRAMECONFIG_DISCARDMODE_Pos) /*!< Bit mask of DISCARDMODE field. */ -#define NFCT_TXD_FRAMECONFIG_DISCARDMODE_DiscardEnd (0UL) /*!< Unused bits are discarded at end of frame (EoF) */ -#define NFCT_TXD_FRAMECONFIG_DISCARDMODE_DiscardStart (1UL) /*!< Unused bits are discarded at start of frame (SoF) */ - -/* Bit 0 : Indicates if parity is added to the frame */ -#define NFCT_TXD_FRAMECONFIG_PARITY_Pos (0UL) /*!< Position of PARITY field. */ -#define NFCT_TXD_FRAMECONFIG_PARITY_Msk (0x1UL << NFCT_TXD_FRAMECONFIG_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define NFCT_TXD_FRAMECONFIG_PARITY_NoParity (0UL) /*!< Parity is not added to TX frames */ -#define NFCT_TXD_FRAMECONFIG_PARITY_Parity (1UL) /*!< Parity is added to TX frames */ - -/* Register: NFCT_TXD_AMOUNT */ -/* Description: Size of outgoing frame */ - -/* Bits 11..3 : Number of complete bytes that shall be included in the frame, excluding CRC, parity and framing */ -#define NFCT_TXD_AMOUNT_TXDATABYTES_Pos (3UL) /*!< Position of TXDATABYTES field. */ -#define NFCT_TXD_AMOUNT_TXDATABYTES_Msk (0x1FFUL << NFCT_TXD_AMOUNT_TXDATABYTES_Pos) /*!< Bit mask of TXDATABYTES field. */ - -/* Bits 2..0 : Number of bits in the last or first byte read from RAM that shall be included in the frame (excluding parity bit). */ -#define NFCT_TXD_AMOUNT_TXDATABITS_Pos (0UL) /*!< Position of TXDATABITS field. */ -#define NFCT_TXD_AMOUNT_TXDATABITS_Msk (0x7UL << NFCT_TXD_AMOUNT_TXDATABITS_Pos) /*!< Bit mask of TXDATABITS field. */ - -/* Register: NFCT_RXD_FRAMECONFIG */ -/* Description: Configuration of incoming frames */ - -/* Bit 4 : CRC mode for incoming frames */ -#define NFCT_RXD_FRAMECONFIG_CRCMODERX_Pos (4UL) /*!< Position of CRCMODERX field. */ -#define NFCT_RXD_FRAMECONFIG_CRCMODERX_Msk (0x1UL << NFCT_RXD_FRAMECONFIG_CRCMODERX_Pos) /*!< Bit mask of CRCMODERX field. */ -#define NFCT_RXD_FRAMECONFIG_CRCMODERX_NoCRCRX (0UL) /*!< CRC is not expected in RX frames */ -#define NFCT_RXD_FRAMECONFIG_CRCMODERX_CRC16RX (1UL) /*!< Last 16 bits in RX frame is CRC, CRC is checked and CRCSTATUS updated */ - -/* Bit 2 : SoF expected or not in RX frames */ -#define NFCT_RXD_FRAMECONFIG_SOF_Pos (2UL) /*!< Position of SOF field. */ -#define NFCT_RXD_FRAMECONFIG_SOF_Msk (0x1UL << NFCT_RXD_FRAMECONFIG_SOF_Pos) /*!< Bit mask of SOF field. */ -#define NFCT_RXD_FRAMECONFIG_SOF_NoSoF (0UL) /*!< SoF symbol is not expected in RX frames */ -#define NFCT_RXD_FRAMECONFIG_SOF_SoF (1UL) /*!< SoF symbol is expected in RX frames */ - -/* Bit 0 : Indicates if parity expected in RX frame */ -#define NFCT_RXD_FRAMECONFIG_PARITY_Pos (0UL) /*!< Position of PARITY field. */ -#define NFCT_RXD_FRAMECONFIG_PARITY_Msk (0x1UL << NFCT_RXD_FRAMECONFIG_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define NFCT_RXD_FRAMECONFIG_PARITY_NoParity (0UL) /*!< Parity is not expected in RX frames */ -#define NFCT_RXD_FRAMECONFIG_PARITY_Parity (1UL) /*!< Parity is expected in RX frames */ - -/* Register: NFCT_RXD_AMOUNT */ -/* Description: Size of last incoming frame */ - -/* Bits 11..3 : Number of complete bytes received in the frame (including CRC, but excluding parity and SoF/EoF framing) */ -#define NFCT_RXD_AMOUNT_RXDATABYTES_Pos (3UL) /*!< Position of RXDATABYTES field. */ -#define NFCT_RXD_AMOUNT_RXDATABYTES_Msk (0x1FFUL << NFCT_RXD_AMOUNT_RXDATABYTES_Pos) /*!< Bit mask of RXDATABYTES field. */ - -/* Bits 2..0 : Number of bits in the last byte in the frame, if less than 8 (including CRC, but excluding parity and SoF/EoF framing). */ -#define NFCT_RXD_AMOUNT_RXDATABITS_Pos (0UL) /*!< Position of RXDATABITS field. */ -#define NFCT_RXD_AMOUNT_RXDATABITS_Msk (0x7UL << NFCT_RXD_AMOUNT_RXDATABITS_Pos) /*!< Bit mask of RXDATABITS field. */ - -/* Register: NFCT_NFCID1_LAST */ -/* Description: Last NFCID1 part (4, 7 or 10 bytes ID) */ - -/* Bits 31..24 : NFCID1 byte W */ -#define NFCT_NFCID1_LAST_NFCID1_W_Pos (24UL) /*!< Position of NFCID1_W field. */ -#define NFCT_NFCID1_LAST_NFCID1_W_Msk (0xFFUL << NFCT_NFCID1_LAST_NFCID1_W_Pos) /*!< Bit mask of NFCID1_W field. */ - -/* Bits 23..16 : NFCID1 byte X */ -#define NFCT_NFCID1_LAST_NFCID1_X_Pos (16UL) /*!< Position of NFCID1_X field. */ -#define NFCT_NFCID1_LAST_NFCID1_X_Msk (0xFFUL << NFCT_NFCID1_LAST_NFCID1_X_Pos) /*!< Bit mask of NFCID1_X field. */ - -/* Bits 15..8 : NFCID1 byte Y */ -#define NFCT_NFCID1_LAST_NFCID1_Y_Pos (8UL) /*!< Position of NFCID1_Y field. */ -#define NFCT_NFCID1_LAST_NFCID1_Y_Msk (0xFFUL << NFCT_NFCID1_LAST_NFCID1_Y_Pos) /*!< Bit mask of NFCID1_Y field. */ - -/* Bits 7..0 : NFCID1 byte Z (very last byte sent) */ -#define NFCT_NFCID1_LAST_NFCID1_Z_Pos (0UL) /*!< Position of NFCID1_Z field. */ -#define NFCT_NFCID1_LAST_NFCID1_Z_Msk (0xFFUL << NFCT_NFCID1_LAST_NFCID1_Z_Pos) /*!< Bit mask of NFCID1_Z field. */ - -/* Register: NFCT_NFCID1_2ND_LAST */ -/* Description: Second last NFCID1 part (7 or 10 bytes ID) */ - -/* Bits 23..16 : NFCID1 byte T */ -#define NFCT_NFCID1_2ND_LAST_NFCID1_T_Pos (16UL) /*!< Position of NFCID1_T field. */ -#define NFCT_NFCID1_2ND_LAST_NFCID1_T_Msk (0xFFUL << NFCT_NFCID1_2ND_LAST_NFCID1_T_Pos) /*!< Bit mask of NFCID1_T field. */ - -/* Bits 15..8 : NFCID1 byte U */ -#define NFCT_NFCID1_2ND_LAST_NFCID1_U_Pos (8UL) /*!< Position of NFCID1_U field. */ -#define NFCT_NFCID1_2ND_LAST_NFCID1_U_Msk (0xFFUL << NFCT_NFCID1_2ND_LAST_NFCID1_U_Pos) /*!< Bit mask of NFCID1_U field. */ - -/* Bits 7..0 : NFCID1 byte V */ -#define NFCT_NFCID1_2ND_LAST_NFCID1_V_Pos (0UL) /*!< Position of NFCID1_V field. */ -#define NFCT_NFCID1_2ND_LAST_NFCID1_V_Msk (0xFFUL << NFCT_NFCID1_2ND_LAST_NFCID1_V_Pos) /*!< Bit mask of NFCID1_V field. */ - -/* Register: NFCT_NFCID1_3RD_LAST */ -/* Description: Third last NFCID1 part (10 bytes ID) */ - -/* Bits 23..16 : NFCID1 byte Q */ -#define NFCT_NFCID1_3RD_LAST_NFCID1_Q_Pos (16UL) /*!< Position of NFCID1_Q field. */ -#define NFCT_NFCID1_3RD_LAST_NFCID1_Q_Msk (0xFFUL << NFCT_NFCID1_3RD_LAST_NFCID1_Q_Pos) /*!< Bit mask of NFCID1_Q field. */ - -/* Bits 15..8 : NFCID1 byte R */ -#define NFCT_NFCID1_3RD_LAST_NFCID1_R_Pos (8UL) /*!< Position of NFCID1_R field. */ -#define NFCT_NFCID1_3RD_LAST_NFCID1_R_Msk (0xFFUL << NFCT_NFCID1_3RD_LAST_NFCID1_R_Pos) /*!< Bit mask of NFCID1_R field. */ - -/* Bits 7..0 : NFCID1 byte S */ -#define NFCT_NFCID1_3RD_LAST_NFCID1_S_Pos (0UL) /*!< Position of NFCID1_S field. */ -#define NFCT_NFCID1_3RD_LAST_NFCID1_S_Msk (0xFFUL << NFCT_NFCID1_3RD_LAST_NFCID1_S_Pos) /*!< Bit mask of NFCID1_S field. */ - -/* Register: NFCT_AUTOCOLRESCONFIG */ -/* Description: Controls the auto collision resolution function. This setting must be done before the NFCT peripheral is enabled. */ - -/* Bit 0 : Enables/disables auto collision resolution */ -#define NFCT_AUTOCOLRESCONFIG_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define NFCT_AUTOCOLRESCONFIG_MODE_Msk (0x1UL << NFCT_AUTOCOLRESCONFIG_MODE_Pos) /*!< Bit mask of MODE field. */ -#define NFCT_AUTOCOLRESCONFIG_MODE_Enabled (0UL) /*!< Auto collision resolution enabled */ -#define NFCT_AUTOCOLRESCONFIG_MODE_Disabled (1UL) /*!< Auto collision resolution disabled */ - -/* Register: NFCT_SENSRES */ -/* Description: NFC-A SENS_RES auto-response settings */ - -/* Bits 15..12 : Reserved for future use. Shall be 0. */ -#define NFCT_SENSRES_RFU74_Pos (12UL) /*!< Position of RFU74 field. */ -#define NFCT_SENSRES_RFU74_Msk (0xFUL << NFCT_SENSRES_RFU74_Pos) /*!< Bit mask of RFU74 field. */ - -/* Bits 11..8 : Tag platform configuration as defined by the b4:b1 of byte 2 in SENS_RES response in the NFC Forum, NFC Digital Protocol Technical Specification */ -#define NFCT_SENSRES_PLATFCONFIG_Pos (8UL) /*!< Position of PLATFCONFIG field. */ -#define NFCT_SENSRES_PLATFCONFIG_Msk (0xFUL << NFCT_SENSRES_PLATFCONFIG_Pos) /*!< Bit mask of PLATFCONFIG field. */ - -/* Bits 7..6 : NFCID1 size. This value is used by the auto collision resolution engine. */ -#define NFCT_SENSRES_NFCIDSIZE_Pos (6UL) /*!< Position of NFCIDSIZE field. */ -#define NFCT_SENSRES_NFCIDSIZE_Msk (0x3UL << NFCT_SENSRES_NFCIDSIZE_Pos) /*!< Bit mask of NFCIDSIZE field. */ -#define NFCT_SENSRES_NFCIDSIZE_NFCID1Single (0UL) /*!< NFCID1 size: single (4 bytes) */ -#define NFCT_SENSRES_NFCIDSIZE_NFCID1Double (1UL) /*!< NFCID1 size: double (7 bytes) */ -#define NFCT_SENSRES_NFCIDSIZE_NFCID1Triple (2UL) /*!< NFCID1 size: triple (10 bytes) */ - -/* Bit 5 : Reserved for future use. Shall be 0. */ -#define NFCT_SENSRES_RFU5_Pos (5UL) /*!< Position of RFU5 field. */ -#define NFCT_SENSRES_RFU5_Msk (0x1UL << NFCT_SENSRES_RFU5_Pos) /*!< Bit mask of RFU5 field. */ - -/* Bits 4..0 : Bit frame SDD as defined by the b5:b1 of byte 1 in SENS_RES response in the NFC Forum, NFC Digital Protocol Technical Specification */ -#define NFCT_SENSRES_BITFRAMESDD_Pos (0UL) /*!< Position of BITFRAMESDD field. */ -#define NFCT_SENSRES_BITFRAMESDD_Msk (0x1FUL << NFCT_SENSRES_BITFRAMESDD_Pos) /*!< Bit mask of BITFRAMESDD field. */ -#define NFCT_SENSRES_BITFRAMESDD_SDD00000 (0UL) /*!< SDD pattern 00000 */ -#define NFCT_SENSRES_BITFRAMESDD_SDD00001 (1UL) /*!< SDD pattern 00001 */ -#define NFCT_SENSRES_BITFRAMESDD_SDD00010 (2UL) /*!< SDD pattern 00010 */ -#define NFCT_SENSRES_BITFRAMESDD_SDD00100 (4UL) /*!< SDD pattern 00100 */ -#define NFCT_SENSRES_BITFRAMESDD_SDD01000 (8UL) /*!< SDD pattern 01000 */ -#define NFCT_SENSRES_BITFRAMESDD_SDD10000 (16UL) /*!< SDD pattern 10000 */ - -/* Register: NFCT_SELRES */ -/* Description: NFC-A SEL_RES auto-response settings */ - -/* Bit 7 : Reserved for future use. Shall be 0. */ -#define NFCT_SELRES_RFU7_Pos (7UL) /*!< Position of RFU7 field. */ -#define NFCT_SELRES_RFU7_Msk (0x1UL << NFCT_SELRES_RFU7_Pos) /*!< Bit mask of RFU7 field. */ - -/* Bits 6..5 : Protocol as defined by the b7:b6 of SEL_RES response in the NFC Forum, NFC Digital Protocol Technical Specification */ -#define NFCT_SELRES_PROTOCOL_Pos (5UL) /*!< Position of PROTOCOL field. */ -#define NFCT_SELRES_PROTOCOL_Msk (0x3UL << NFCT_SELRES_PROTOCOL_Pos) /*!< Bit mask of PROTOCOL field. */ - -/* Bits 4..3 : Reserved for future use. Shall be 0. */ -#define NFCT_SELRES_RFU43_Pos (3UL) /*!< Position of RFU43 field. */ -#define NFCT_SELRES_RFU43_Msk (0x3UL << NFCT_SELRES_RFU43_Pos) /*!< Bit mask of RFU43 field. */ - -/* Bit 2 : Cascade as defined by the b3 of SEL_RES response in the NFC Forum, NFC Digital Protocol Technical Specification (controlled by hardware, shall be 0) */ -#define NFCT_SELRES_CASCADE_Pos (2UL) /*!< Position of CASCADE field. */ -#define NFCT_SELRES_CASCADE_Msk (0x1UL << NFCT_SELRES_CASCADE_Pos) /*!< Bit mask of CASCADE field. */ - -/* Bits 1..0 : Reserved for future use. Shall be 0. */ -#define NFCT_SELRES_RFU10_Pos (0UL) /*!< Position of RFU10 field. */ -#define NFCT_SELRES_RFU10_Msk (0x3UL << NFCT_SELRES_RFU10_Pos) /*!< Bit mask of RFU10 field. */ - - -/* Peripheral: NVMC */ -/* Description: Non Volatile Memory Controller */ - -/* Register: NVMC_READY */ -/* Description: Ready flag */ - -/* Bit 0 : NVMC is ready or busy */ -#define NVMC_READY_READY_Pos (0UL) /*!< Position of READY field. */ -#define NVMC_READY_READY_Msk (0x1UL << NVMC_READY_READY_Pos) /*!< Bit mask of READY field. */ -#define NVMC_READY_READY_Busy (0UL) /*!< NVMC is busy (on-going write or erase operation) */ -#define NVMC_READY_READY_Ready (1UL) /*!< NVMC is ready */ - -/* Register: NVMC_READYNEXT */ -/* Description: Ready flag */ - -/* Bit 0 : NVMC can accept a new write operation */ -#define NVMC_READYNEXT_READYNEXT_Pos (0UL) /*!< Position of READYNEXT field. */ -#define NVMC_READYNEXT_READYNEXT_Msk (0x1UL << NVMC_READYNEXT_READYNEXT_Pos) /*!< Bit mask of READYNEXT field. */ -#define NVMC_READYNEXT_READYNEXT_Busy (0UL) /*!< NVMC cannot accept any write operation */ -#define NVMC_READYNEXT_READYNEXT_Ready (1UL) /*!< NVMC is ready */ - -/* Register: NVMC_CONFIG */ -/* Description: Configuration register */ - -/* Bits 1..0 : Program memory access mode. It is strongly recommended to only activate erase and write modes when they are actively used. Enabling write or erase will invalidate the cache and keep it invalidated. */ -#define NVMC_CONFIG_WEN_Pos (0UL) /*!< Position of WEN field. */ -#define NVMC_CONFIG_WEN_Msk (0x3UL << NVMC_CONFIG_WEN_Pos) /*!< Bit mask of WEN field. */ -#define NVMC_CONFIG_WEN_Ren (0UL) /*!< Read only access */ -#define NVMC_CONFIG_WEN_Wen (1UL) /*!< Write enabled */ -#define NVMC_CONFIG_WEN_Een (2UL) /*!< Erase enabled */ - -/* Register: NVMC_ERASEPCR1 */ -/* Description: Deprecated register - Register for erasing a page in code area. Equivalent to ERASEPAGE. */ - -/* Bits 31..0 : Register for erasing a page in code area. Equivalent to ERASEPAGE. */ -#define NVMC_ERASEPCR1_ERASEPCR1_Pos (0UL) /*!< Position of ERASEPCR1 field. */ -#define NVMC_ERASEPCR1_ERASEPCR1_Msk (0xFFFFFFFFUL << NVMC_ERASEPCR1_ERASEPCR1_Pos) /*!< Bit mask of ERASEPCR1 field. */ - -/* Register: NVMC_ERASEPAGE */ -/* Description: Register for erasing a page in code area */ - -/* Bits 31..0 : Register for starting erase of a page in code area */ -#define NVMC_ERASEPAGE_ERASEPAGE_Pos (0UL) /*!< Position of ERASEPAGE field. */ -#define NVMC_ERASEPAGE_ERASEPAGE_Msk (0xFFFFFFFFUL << NVMC_ERASEPAGE_ERASEPAGE_Pos) /*!< Bit mask of ERASEPAGE field. */ - -/* Register: NVMC_ERASEALL */ -/* Description: Register for erasing all non-volatile user memory */ - -/* Bit 0 : Erase all non-volatile memory including UICR registers. Note that the erase must be enabled using CONFIG.WEN before the non-volatile memory can be erased. */ -#define NVMC_ERASEALL_ERASEALL_Pos (0UL) /*!< Position of ERASEALL field. */ -#define NVMC_ERASEALL_ERASEALL_Msk (0x1UL << NVMC_ERASEALL_ERASEALL_Pos) /*!< Bit mask of ERASEALL field. */ -#define NVMC_ERASEALL_ERASEALL_NoOperation (0UL) /*!< No operation */ -#define NVMC_ERASEALL_ERASEALL_Erase (1UL) /*!< Start chip erase */ - -/* Register: NVMC_ERASEPCR0 */ -/* Description: Deprecated register - Register for erasing a page in code area. Equivalent to ERASEPAGE. */ - -/* Bits 31..0 : Register for starting erase of a page in code area. Equivalent to ERASEPAGE. */ -#define NVMC_ERASEPCR0_ERASEPCR0_Pos (0UL) /*!< Position of ERASEPCR0 field. */ -#define NVMC_ERASEPCR0_ERASEPCR0_Msk (0xFFFFFFFFUL << NVMC_ERASEPCR0_ERASEPCR0_Pos) /*!< Bit mask of ERASEPCR0 field. */ - -/* Register: NVMC_ERASEUICR */ -/* Description: Register for erasing user information configuration registers */ - -/* Bit 0 : Register starting erase of all user information configuration registers. Note that the erase must be enabled using CONFIG.WEN before the UICR can be erased. */ -#define NVMC_ERASEUICR_ERASEUICR_Pos (0UL) /*!< Position of ERASEUICR field. */ -#define NVMC_ERASEUICR_ERASEUICR_Msk (0x1UL << NVMC_ERASEUICR_ERASEUICR_Pos) /*!< Bit mask of ERASEUICR field. */ -#define NVMC_ERASEUICR_ERASEUICR_NoOperation (0UL) /*!< No operation */ -#define NVMC_ERASEUICR_ERASEUICR_Erase (1UL) /*!< Start erase of UICR */ - -/* Register: NVMC_ICACHECNF */ -/* Description: I-code cache configuration register. */ - -/* Bit 8 : Cache profiling enable */ -#define NVMC_ICACHECNF_CACHEPROFEN_Pos (8UL) /*!< Position of CACHEPROFEN field. */ -#define NVMC_ICACHECNF_CACHEPROFEN_Msk (0x1UL << NVMC_ICACHECNF_CACHEPROFEN_Pos) /*!< Bit mask of CACHEPROFEN field. */ -#define NVMC_ICACHECNF_CACHEPROFEN_Disabled (0UL) /*!< Disable cache profiling */ -#define NVMC_ICACHECNF_CACHEPROFEN_Enabled (1UL) /*!< Enable cache profiling */ - -/* Bit 0 : Cache enable */ -#define NVMC_ICACHECNF_CACHEEN_Pos (0UL) /*!< Position of CACHEEN field. */ -#define NVMC_ICACHECNF_CACHEEN_Msk (0x1UL << NVMC_ICACHECNF_CACHEEN_Pos) /*!< Bit mask of CACHEEN field. */ -#define NVMC_ICACHECNF_CACHEEN_Disabled (0UL) /*!< Disable cache. Invalidates all cache entries. */ -#define NVMC_ICACHECNF_CACHEEN_Enabled (1UL) /*!< Enable cache */ - -/* Register: NVMC_IHIT */ -/* Description: I-code cache hit counter. */ - -/* Bits 31..0 : Number of cache hits */ -#define NVMC_IHIT_HITS_Pos (0UL) /*!< Position of HITS field. */ -#define NVMC_IHIT_HITS_Msk (0xFFFFFFFFUL << NVMC_IHIT_HITS_Pos) /*!< Bit mask of HITS field. */ - -/* Register: NVMC_IMISS */ -/* Description: I-code cache miss counter. */ - -/* Bits 31..0 : Number of cache misses */ -#define NVMC_IMISS_MISSES_Pos (0UL) /*!< Position of MISSES field. */ -#define NVMC_IMISS_MISSES_Msk (0xFFFFFFFFUL << NVMC_IMISS_MISSES_Pos) /*!< Bit mask of MISSES field. */ - - -/* Peripheral: GPIO */ -/* Description: GPIO Port 1 */ - -/* Register: GPIO_OUT */ -/* Description: Write GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_OUT_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUT_PIN31_Msk (0x1UL << GPIO_OUT_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUT_PIN31_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN31_High (1UL) /*!< Pin driver is high */ - -/* Bit 30 : Pin 30 */ -#define GPIO_OUT_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUT_PIN30_Msk (0x1UL << GPIO_OUT_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUT_PIN30_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN30_High (1UL) /*!< Pin driver is high */ - -/* Bit 29 : Pin 29 */ -#define GPIO_OUT_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUT_PIN29_Msk (0x1UL << GPIO_OUT_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUT_PIN29_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN29_High (1UL) /*!< Pin driver is high */ - -/* Bit 28 : Pin 28 */ -#define GPIO_OUT_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUT_PIN28_Msk (0x1UL << GPIO_OUT_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUT_PIN28_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN28_High (1UL) /*!< Pin driver is high */ - -/* Bit 27 : Pin 27 */ -#define GPIO_OUT_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUT_PIN27_Msk (0x1UL << GPIO_OUT_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUT_PIN27_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN27_High (1UL) /*!< Pin driver is high */ - -/* Bit 26 : Pin 26 */ -#define GPIO_OUT_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUT_PIN26_Msk (0x1UL << GPIO_OUT_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUT_PIN26_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN26_High (1UL) /*!< Pin driver is high */ - -/* Bit 25 : Pin 25 */ -#define GPIO_OUT_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUT_PIN25_Msk (0x1UL << GPIO_OUT_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUT_PIN25_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN25_High (1UL) /*!< Pin driver is high */ - -/* Bit 24 : Pin 24 */ -#define GPIO_OUT_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUT_PIN24_Msk (0x1UL << GPIO_OUT_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUT_PIN24_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN24_High (1UL) /*!< Pin driver is high */ - -/* Bit 23 : Pin 23 */ -#define GPIO_OUT_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUT_PIN23_Msk (0x1UL << GPIO_OUT_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUT_PIN23_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN23_High (1UL) /*!< Pin driver is high */ - -/* Bit 22 : Pin 22 */ -#define GPIO_OUT_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUT_PIN22_Msk (0x1UL << GPIO_OUT_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUT_PIN22_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN22_High (1UL) /*!< Pin driver is high */ - -/* Bit 21 : Pin 21 */ -#define GPIO_OUT_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUT_PIN21_Msk (0x1UL << GPIO_OUT_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUT_PIN21_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN21_High (1UL) /*!< Pin driver is high */ - -/* Bit 20 : Pin 20 */ -#define GPIO_OUT_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUT_PIN20_Msk (0x1UL << GPIO_OUT_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUT_PIN20_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN20_High (1UL) /*!< Pin driver is high */ - -/* Bit 19 : Pin 19 */ -#define GPIO_OUT_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUT_PIN19_Msk (0x1UL << GPIO_OUT_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUT_PIN19_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN19_High (1UL) /*!< Pin driver is high */ - -/* Bit 18 : Pin 18 */ -#define GPIO_OUT_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUT_PIN18_Msk (0x1UL << GPIO_OUT_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUT_PIN18_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN18_High (1UL) /*!< Pin driver is high */ - -/* Bit 17 : Pin 17 */ -#define GPIO_OUT_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUT_PIN17_Msk (0x1UL << GPIO_OUT_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUT_PIN17_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN17_High (1UL) /*!< Pin driver is high */ - -/* Bit 16 : Pin 16 */ -#define GPIO_OUT_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUT_PIN16_Msk (0x1UL << GPIO_OUT_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUT_PIN16_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN16_High (1UL) /*!< Pin driver is high */ - -/* Bit 15 : Pin 15 */ -#define GPIO_OUT_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUT_PIN15_Msk (0x1UL << GPIO_OUT_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUT_PIN15_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN15_High (1UL) /*!< Pin driver is high */ - -/* Bit 14 : Pin 14 */ -#define GPIO_OUT_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUT_PIN14_Msk (0x1UL << GPIO_OUT_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUT_PIN14_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN14_High (1UL) /*!< Pin driver is high */ - -/* Bit 13 : Pin 13 */ -#define GPIO_OUT_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUT_PIN13_Msk (0x1UL << GPIO_OUT_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUT_PIN13_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN13_High (1UL) /*!< Pin driver is high */ - -/* Bit 12 : Pin 12 */ -#define GPIO_OUT_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUT_PIN12_Msk (0x1UL << GPIO_OUT_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUT_PIN12_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN12_High (1UL) /*!< Pin driver is high */ - -/* Bit 11 : Pin 11 */ -#define GPIO_OUT_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUT_PIN11_Msk (0x1UL << GPIO_OUT_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUT_PIN11_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN11_High (1UL) /*!< Pin driver is high */ - -/* Bit 10 : Pin 10 */ -#define GPIO_OUT_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUT_PIN10_Msk (0x1UL << GPIO_OUT_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUT_PIN10_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN10_High (1UL) /*!< Pin driver is high */ - -/* Bit 9 : Pin 9 */ -#define GPIO_OUT_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUT_PIN9_Msk (0x1UL << GPIO_OUT_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUT_PIN9_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN9_High (1UL) /*!< Pin driver is high */ - -/* Bit 8 : Pin 8 */ -#define GPIO_OUT_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUT_PIN8_Msk (0x1UL << GPIO_OUT_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUT_PIN8_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN8_High (1UL) /*!< Pin driver is high */ - -/* Bit 7 : Pin 7 */ -#define GPIO_OUT_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUT_PIN7_Msk (0x1UL << GPIO_OUT_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUT_PIN7_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN7_High (1UL) /*!< Pin driver is high */ - -/* Bit 6 : Pin 6 */ -#define GPIO_OUT_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUT_PIN6_Msk (0x1UL << GPIO_OUT_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUT_PIN6_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN6_High (1UL) /*!< Pin driver is high */ - -/* Bit 5 : Pin 5 */ -#define GPIO_OUT_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUT_PIN5_Msk (0x1UL << GPIO_OUT_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUT_PIN5_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN5_High (1UL) /*!< Pin driver is high */ - -/* Bit 4 : Pin 4 */ -#define GPIO_OUT_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUT_PIN4_Msk (0x1UL << GPIO_OUT_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUT_PIN4_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN4_High (1UL) /*!< Pin driver is high */ - -/* Bit 3 : Pin 3 */ -#define GPIO_OUT_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUT_PIN3_Msk (0x1UL << GPIO_OUT_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUT_PIN3_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN3_High (1UL) /*!< Pin driver is high */ - -/* Bit 2 : Pin 2 */ -#define GPIO_OUT_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUT_PIN2_Msk (0x1UL << GPIO_OUT_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUT_PIN2_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN2_High (1UL) /*!< Pin driver is high */ - -/* Bit 1 : Pin 1 */ -#define GPIO_OUT_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUT_PIN1_Msk (0x1UL << GPIO_OUT_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUT_PIN1_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN1_High (1UL) /*!< Pin driver is high */ - -/* Bit 0 : Pin 0 */ -#define GPIO_OUT_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUT_PIN0_Msk (0x1UL << GPIO_OUT_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUT_PIN0_Low (0UL) /*!< Pin driver is low */ -#define GPIO_OUT_PIN0_High (1UL) /*!< Pin driver is high */ - -/* Register: GPIO_OUTSET */ -/* Description: Set individual bits in GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_OUTSET_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUTSET_PIN31_Msk (0x1UL << GPIO_OUTSET_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUTSET_PIN31_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN31_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN31_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 30 : Pin 30 */ -#define GPIO_OUTSET_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUTSET_PIN30_Msk (0x1UL << GPIO_OUTSET_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUTSET_PIN30_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN30_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN30_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 29 : Pin 29 */ -#define GPIO_OUTSET_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUTSET_PIN29_Msk (0x1UL << GPIO_OUTSET_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUTSET_PIN29_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN29_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN29_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 28 : Pin 28 */ -#define GPIO_OUTSET_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUTSET_PIN28_Msk (0x1UL << GPIO_OUTSET_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUTSET_PIN28_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN28_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN28_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 27 : Pin 27 */ -#define GPIO_OUTSET_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUTSET_PIN27_Msk (0x1UL << GPIO_OUTSET_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUTSET_PIN27_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN27_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN27_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 26 : Pin 26 */ -#define GPIO_OUTSET_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUTSET_PIN26_Msk (0x1UL << GPIO_OUTSET_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUTSET_PIN26_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN26_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN26_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 25 : Pin 25 */ -#define GPIO_OUTSET_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUTSET_PIN25_Msk (0x1UL << GPIO_OUTSET_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUTSET_PIN25_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN25_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN25_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 24 : Pin 24 */ -#define GPIO_OUTSET_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUTSET_PIN24_Msk (0x1UL << GPIO_OUTSET_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUTSET_PIN24_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN24_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN24_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 23 : Pin 23 */ -#define GPIO_OUTSET_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUTSET_PIN23_Msk (0x1UL << GPIO_OUTSET_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUTSET_PIN23_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN23_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN23_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 22 : Pin 22 */ -#define GPIO_OUTSET_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUTSET_PIN22_Msk (0x1UL << GPIO_OUTSET_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUTSET_PIN22_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN22_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN22_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 21 : Pin 21 */ -#define GPIO_OUTSET_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUTSET_PIN21_Msk (0x1UL << GPIO_OUTSET_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUTSET_PIN21_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN21_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN21_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 20 : Pin 20 */ -#define GPIO_OUTSET_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUTSET_PIN20_Msk (0x1UL << GPIO_OUTSET_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUTSET_PIN20_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN20_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN20_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 19 : Pin 19 */ -#define GPIO_OUTSET_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUTSET_PIN19_Msk (0x1UL << GPIO_OUTSET_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUTSET_PIN19_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN19_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN19_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 18 : Pin 18 */ -#define GPIO_OUTSET_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUTSET_PIN18_Msk (0x1UL << GPIO_OUTSET_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUTSET_PIN18_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN18_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN18_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 17 : Pin 17 */ -#define GPIO_OUTSET_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUTSET_PIN17_Msk (0x1UL << GPIO_OUTSET_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUTSET_PIN17_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN17_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN17_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 16 : Pin 16 */ -#define GPIO_OUTSET_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUTSET_PIN16_Msk (0x1UL << GPIO_OUTSET_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUTSET_PIN16_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN16_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN16_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 15 : Pin 15 */ -#define GPIO_OUTSET_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUTSET_PIN15_Msk (0x1UL << GPIO_OUTSET_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUTSET_PIN15_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN15_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN15_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 14 : Pin 14 */ -#define GPIO_OUTSET_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUTSET_PIN14_Msk (0x1UL << GPIO_OUTSET_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUTSET_PIN14_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN14_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN14_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 13 : Pin 13 */ -#define GPIO_OUTSET_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUTSET_PIN13_Msk (0x1UL << GPIO_OUTSET_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUTSET_PIN13_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN13_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN13_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 12 : Pin 12 */ -#define GPIO_OUTSET_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUTSET_PIN12_Msk (0x1UL << GPIO_OUTSET_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUTSET_PIN12_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN12_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN12_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 11 : Pin 11 */ -#define GPIO_OUTSET_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUTSET_PIN11_Msk (0x1UL << GPIO_OUTSET_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUTSET_PIN11_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN11_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN11_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 10 : Pin 10 */ -#define GPIO_OUTSET_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUTSET_PIN10_Msk (0x1UL << GPIO_OUTSET_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUTSET_PIN10_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN10_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN10_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 9 : Pin 9 */ -#define GPIO_OUTSET_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUTSET_PIN9_Msk (0x1UL << GPIO_OUTSET_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUTSET_PIN9_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN9_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN9_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 8 : Pin 8 */ -#define GPIO_OUTSET_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUTSET_PIN8_Msk (0x1UL << GPIO_OUTSET_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUTSET_PIN8_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN8_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN8_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 7 : Pin 7 */ -#define GPIO_OUTSET_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUTSET_PIN7_Msk (0x1UL << GPIO_OUTSET_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUTSET_PIN7_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN7_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN7_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 6 : Pin 6 */ -#define GPIO_OUTSET_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUTSET_PIN6_Msk (0x1UL << GPIO_OUTSET_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUTSET_PIN6_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN6_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN6_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 5 : Pin 5 */ -#define GPIO_OUTSET_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUTSET_PIN5_Msk (0x1UL << GPIO_OUTSET_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUTSET_PIN5_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN5_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN5_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 4 : Pin 4 */ -#define GPIO_OUTSET_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUTSET_PIN4_Msk (0x1UL << GPIO_OUTSET_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUTSET_PIN4_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN4_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN4_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 3 : Pin 3 */ -#define GPIO_OUTSET_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUTSET_PIN3_Msk (0x1UL << GPIO_OUTSET_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUTSET_PIN3_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN3_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN3_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 2 : Pin 2 */ -#define GPIO_OUTSET_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUTSET_PIN2_Msk (0x1UL << GPIO_OUTSET_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUTSET_PIN2_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN2_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN2_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 1 : Pin 1 */ -#define GPIO_OUTSET_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUTSET_PIN1_Msk (0x1UL << GPIO_OUTSET_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUTSET_PIN1_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN1_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN1_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Bit 0 : Pin 0 */ -#define GPIO_OUTSET_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUTSET_PIN0_Msk (0x1UL << GPIO_OUTSET_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUTSET_PIN0_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTSET_PIN0_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTSET_PIN0_Set (1UL) /*!< Write: writing a '1' sets the pin high; writing a '0' has no effect */ - -/* Register: GPIO_OUTCLR */ -/* Description: Clear individual bits in GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_OUTCLR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_OUTCLR_PIN31_Msk (0x1UL << GPIO_OUTCLR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_OUTCLR_PIN31_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN31_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN31_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 30 : Pin 30 */ -#define GPIO_OUTCLR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_OUTCLR_PIN30_Msk (0x1UL << GPIO_OUTCLR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_OUTCLR_PIN30_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN30_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN30_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 29 : Pin 29 */ -#define GPIO_OUTCLR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_OUTCLR_PIN29_Msk (0x1UL << GPIO_OUTCLR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_OUTCLR_PIN29_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN29_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN29_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 28 : Pin 28 */ -#define GPIO_OUTCLR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_OUTCLR_PIN28_Msk (0x1UL << GPIO_OUTCLR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_OUTCLR_PIN28_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN28_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN28_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 27 : Pin 27 */ -#define GPIO_OUTCLR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_OUTCLR_PIN27_Msk (0x1UL << GPIO_OUTCLR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_OUTCLR_PIN27_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN27_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN27_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 26 : Pin 26 */ -#define GPIO_OUTCLR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_OUTCLR_PIN26_Msk (0x1UL << GPIO_OUTCLR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_OUTCLR_PIN26_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN26_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN26_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 25 : Pin 25 */ -#define GPIO_OUTCLR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_OUTCLR_PIN25_Msk (0x1UL << GPIO_OUTCLR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_OUTCLR_PIN25_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN25_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN25_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 24 : Pin 24 */ -#define GPIO_OUTCLR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_OUTCLR_PIN24_Msk (0x1UL << GPIO_OUTCLR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_OUTCLR_PIN24_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN24_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN24_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 23 : Pin 23 */ -#define GPIO_OUTCLR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_OUTCLR_PIN23_Msk (0x1UL << GPIO_OUTCLR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_OUTCLR_PIN23_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN23_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN23_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 22 : Pin 22 */ -#define GPIO_OUTCLR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_OUTCLR_PIN22_Msk (0x1UL << GPIO_OUTCLR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_OUTCLR_PIN22_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN22_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN22_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 21 : Pin 21 */ -#define GPIO_OUTCLR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_OUTCLR_PIN21_Msk (0x1UL << GPIO_OUTCLR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_OUTCLR_PIN21_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN21_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN21_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 20 : Pin 20 */ -#define GPIO_OUTCLR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_OUTCLR_PIN20_Msk (0x1UL << GPIO_OUTCLR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_OUTCLR_PIN20_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN20_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN20_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 19 : Pin 19 */ -#define GPIO_OUTCLR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_OUTCLR_PIN19_Msk (0x1UL << GPIO_OUTCLR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_OUTCLR_PIN19_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN19_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN19_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 18 : Pin 18 */ -#define GPIO_OUTCLR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_OUTCLR_PIN18_Msk (0x1UL << GPIO_OUTCLR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_OUTCLR_PIN18_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN18_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN18_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 17 : Pin 17 */ -#define GPIO_OUTCLR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_OUTCLR_PIN17_Msk (0x1UL << GPIO_OUTCLR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_OUTCLR_PIN17_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN17_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN17_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 16 : Pin 16 */ -#define GPIO_OUTCLR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_OUTCLR_PIN16_Msk (0x1UL << GPIO_OUTCLR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_OUTCLR_PIN16_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN16_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN16_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 15 : Pin 15 */ -#define GPIO_OUTCLR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_OUTCLR_PIN15_Msk (0x1UL << GPIO_OUTCLR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_OUTCLR_PIN15_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN15_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN15_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 14 : Pin 14 */ -#define GPIO_OUTCLR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_OUTCLR_PIN14_Msk (0x1UL << GPIO_OUTCLR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_OUTCLR_PIN14_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN14_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN14_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 13 : Pin 13 */ -#define GPIO_OUTCLR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_OUTCLR_PIN13_Msk (0x1UL << GPIO_OUTCLR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_OUTCLR_PIN13_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN13_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN13_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 12 : Pin 12 */ -#define GPIO_OUTCLR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_OUTCLR_PIN12_Msk (0x1UL << GPIO_OUTCLR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_OUTCLR_PIN12_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN12_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN12_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 11 : Pin 11 */ -#define GPIO_OUTCLR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_OUTCLR_PIN11_Msk (0x1UL << GPIO_OUTCLR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_OUTCLR_PIN11_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN11_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN11_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 10 : Pin 10 */ -#define GPIO_OUTCLR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_OUTCLR_PIN10_Msk (0x1UL << GPIO_OUTCLR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_OUTCLR_PIN10_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN10_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN10_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 9 : Pin 9 */ -#define GPIO_OUTCLR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_OUTCLR_PIN9_Msk (0x1UL << GPIO_OUTCLR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_OUTCLR_PIN9_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN9_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN9_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 8 : Pin 8 */ -#define GPIO_OUTCLR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_OUTCLR_PIN8_Msk (0x1UL << GPIO_OUTCLR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_OUTCLR_PIN8_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN8_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN8_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 7 : Pin 7 */ -#define GPIO_OUTCLR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_OUTCLR_PIN7_Msk (0x1UL << GPIO_OUTCLR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_OUTCLR_PIN7_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN7_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN7_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 6 : Pin 6 */ -#define GPIO_OUTCLR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_OUTCLR_PIN6_Msk (0x1UL << GPIO_OUTCLR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_OUTCLR_PIN6_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN6_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN6_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 5 : Pin 5 */ -#define GPIO_OUTCLR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_OUTCLR_PIN5_Msk (0x1UL << GPIO_OUTCLR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_OUTCLR_PIN5_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN5_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN5_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 4 : Pin 4 */ -#define GPIO_OUTCLR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_OUTCLR_PIN4_Msk (0x1UL << GPIO_OUTCLR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_OUTCLR_PIN4_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN4_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN4_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 3 : Pin 3 */ -#define GPIO_OUTCLR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_OUTCLR_PIN3_Msk (0x1UL << GPIO_OUTCLR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_OUTCLR_PIN3_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN3_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN3_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 2 : Pin 2 */ -#define GPIO_OUTCLR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_OUTCLR_PIN2_Msk (0x1UL << GPIO_OUTCLR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_OUTCLR_PIN2_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN2_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN2_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 1 : Pin 1 */ -#define GPIO_OUTCLR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_OUTCLR_PIN1_Msk (0x1UL << GPIO_OUTCLR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_OUTCLR_PIN1_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN1_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN1_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Bit 0 : Pin 0 */ -#define GPIO_OUTCLR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_OUTCLR_PIN0_Msk (0x1UL << GPIO_OUTCLR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_OUTCLR_PIN0_Low (0UL) /*!< Read: pin driver is low */ -#define GPIO_OUTCLR_PIN0_High (1UL) /*!< Read: pin driver is high */ -#define GPIO_OUTCLR_PIN0_Clear (1UL) /*!< Write: writing a '1' sets the pin low; writing a '0' has no effect */ - -/* Register: GPIO_IN */ -/* Description: Read GPIO port */ - -/* Bit 31 : Pin 31 */ -#define GPIO_IN_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_IN_PIN31_Msk (0x1UL << GPIO_IN_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_IN_PIN31_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN31_High (1UL) /*!< Pin input is high */ - -/* Bit 30 : Pin 30 */ -#define GPIO_IN_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_IN_PIN30_Msk (0x1UL << GPIO_IN_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_IN_PIN30_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN30_High (1UL) /*!< Pin input is high */ - -/* Bit 29 : Pin 29 */ -#define GPIO_IN_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_IN_PIN29_Msk (0x1UL << GPIO_IN_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_IN_PIN29_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN29_High (1UL) /*!< Pin input is high */ - -/* Bit 28 : Pin 28 */ -#define GPIO_IN_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_IN_PIN28_Msk (0x1UL << GPIO_IN_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_IN_PIN28_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN28_High (1UL) /*!< Pin input is high */ - -/* Bit 27 : Pin 27 */ -#define GPIO_IN_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_IN_PIN27_Msk (0x1UL << GPIO_IN_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_IN_PIN27_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN27_High (1UL) /*!< Pin input is high */ - -/* Bit 26 : Pin 26 */ -#define GPIO_IN_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_IN_PIN26_Msk (0x1UL << GPIO_IN_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_IN_PIN26_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN26_High (1UL) /*!< Pin input is high */ - -/* Bit 25 : Pin 25 */ -#define GPIO_IN_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_IN_PIN25_Msk (0x1UL << GPIO_IN_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_IN_PIN25_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN25_High (1UL) /*!< Pin input is high */ - -/* Bit 24 : Pin 24 */ -#define GPIO_IN_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_IN_PIN24_Msk (0x1UL << GPIO_IN_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_IN_PIN24_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN24_High (1UL) /*!< Pin input is high */ - -/* Bit 23 : Pin 23 */ -#define GPIO_IN_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_IN_PIN23_Msk (0x1UL << GPIO_IN_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_IN_PIN23_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN23_High (1UL) /*!< Pin input is high */ - -/* Bit 22 : Pin 22 */ -#define GPIO_IN_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_IN_PIN22_Msk (0x1UL << GPIO_IN_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_IN_PIN22_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN22_High (1UL) /*!< Pin input is high */ - -/* Bit 21 : Pin 21 */ -#define GPIO_IN_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_IN_PIN21_Msk (0x1UL << GPIO_IN_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_IN_PIN21_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN21_High (1UL) /*!< Pin input is high */ - -/* Bit 20 : Pin 20 */ -#define GPIO_IN_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_IN_PIN20_Msk (0x1UL << GPIO_IN_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_IN_PIN20_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN20_High (1UL) /*!< Pin input is high */ - -/* Bit 19 : Pin 19 */ -#define GPIO_IN_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_IN_PIN19_Msk (0x1UL << GPIO_IN_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_IN_PIN19_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN19_High (1UL) /*!< Pin input is high */ - -/* Bit 18 : Pin 18 */ -#define GPIO_IN_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_IN_PIN18_Msk (0x1UL << GPIO_IN_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_IN_PIN18_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN18_High (1UL) /*!< Pin input is high */ - -/* Bit 17 : Pin 17 */ -#define GPIO_IN_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_IN_PIN17_Msk (0x1UL << GPIO_IN_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_IN_PIN17_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN17_High (1UL) /*!< Pin input is high */ - -/* Bit 16 : Pin 16 */ -#define GPIO_IN_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_IN_PIN16_Msk (0x1UL << GPIO_IN_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_IN_PIN16_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN16_High (1UL) /*!< Pin input is high */ - -/* Bit 15 : Pin 15 */ -#define GPIO_IN_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_IN_PIN15_Msk (0x1UL << GPIO_IN_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_IN_PIN15_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN15_High (1UL) /*!< Pin input is high */ - -/* Bit 14 : Pin 14 */ -#define GPIO_IN_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_IN_PIN14_Msk (0x1UL << GPIO_IN_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_IN_PIN14_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN14_High (1UL) /*!< Pin input is high */ - -/* Bit 13 : Pin 13 */ -#define GPIO_IN_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_IN_PIN13_Msk (0x1UL << GPIO_IN_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_IN_PIN13_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN13_High (1UL) /*!< Pin input is high */ - -/* Bit 12 : Pin 12 */ -#define GPIO_IN_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_IN_PIN12_Msk (0x1UL << GPIO_IN_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_IN_PIN12_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN12_High (1UL) /*!< Pin input is high */ - -/* Bit 11 : Pin 11 */ -#define GPIO_IN_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_IN_PIN11_Msk (0x1UL << GPIO_IN_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_IN_PIN11_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN11_High (1UL) /*!< Pin input is high */ - -/* Bit 10 : Pin 10 */ -#define GPIO_IN_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_IN_PIN10_Msk (0x1UL << GPIO_IN_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_IN_PIN10_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN10_High (1UL) /*!< Pin input is high */ - -/* Bit 9 : Pin 9 */ -#define GPIO_IN_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_IN_PIN9_Msk (0x1UL << GPIO_IN_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_IN_PIN9_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN9_High (1UL) /*!< Pin input is high */ - -/* Bit 8 : Pin 8 */ -#define GPIO_IN_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_IN_PIN8_Msk (0x1UL << GPIO_IN_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_IN_PIN8_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN8_High (1UL) /*!< Pin input is high */ - -/* Bit 7 : Pin 7 */ -#define GPIO_IN_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_IN_PIN7_Msk (0x1UL << GPIO_IN_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_IN_PIN7_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN7_High (1UL) /*!< Pin input is high */ - -/* Bit 6 : Pin 6 */ -#define GPIO_IN_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_IN_PIN6_Msk (0x1UL << GPIO_IN_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_IN_PIN6_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN6_High (1UL) /*!< Pin input is high */ - -/* Bit 5 : Pin 5 */ -#define GPIO_IN_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_IN_PIN5_Msk (0x1UL << GPIO_IN_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_IN_PIN5_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN5_High (1UL) /*!< Pin input is high */ - -/* Bit 4 : Pin 4 */ -#define GPIO_IN_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_IN_PIN4_Msk (0x1UL << GPIO_IN_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_IN_PIN4_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN4_High (1UL) /*!< Pin input is high */ - -/* Bit 3 : Pin 3 */ -#define GPIO_IN_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_IN_PIN3_Msk (0x1UL << GPIO_IN_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_IN_PIN3_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN3_High (1UL) /*!< Pin input is high */ - -/* Bit 2 : Pin 2 */ -#define GPIO_IN_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_IN_PIN2_Msk (0x1UL << GPIO_IN_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_IN_PIN2_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN2_High (1UL) /*!< Pin input is high */ - -/* Bit 1 : Pin 1 */ -#define GPIO_IN_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_IN_PIN1_Msk (0x1UL << GPIO_IN_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_IN_PIN1_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN1_High (1UL) /*!< Pin input is high */ - -/* Bit 0 : Pin 0 */ -#define GPIO_IN_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_IN_PIN0_Msk (0x1UL << GPIO_IN_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_IN_PIN0_Low (0UL) /*!< Pin input is low */ -#define GPIO_IN_PIN0_High (1UL) /*!< Pin input is high */ - -/* Register: GPIO_DIR */ -/* Description: Direction of GPIO pins */ - -/* Bit 31 : Pin 31 */ -#define GPIO_DIR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIR_PIN31_Msk (0x1UL << GPIO_DIR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIR_PIN31_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN31_Output (1UL) /*!< Pin set as output */ - -/* Bit 30 : Pin 30 */ -#define GPIO_DIR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIR_PIN30_Msk (0x1UL << GPIO_DIR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIR_PIN30_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN30_Output (1UL) /*!< Pin set as output */ - -/* Bit 29 : Pin 29 */ -#define GPIO_DIR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIR_PIN29_Msk (0x1UL << GPIO_DIR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIR_PIN29_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN29_Output (1UL) /*!< Pin set as output */ - -/* Bit 28 : Pin 28 */ -#define GPIO_DIR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIR_PIN28_Msk (0x1UL << GPIO_DIR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIR_PIN28_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN28_Output (1UL) /*!< Pin set as output */ - -/* Bit 27 : Pin 27 */ -#define GPIO_DIR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIR_PIN27_Msk (0x1UL << GPIO_DIR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIR_PIN27_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN27_Output (1UL) /*!< Pin set as output */ - -/* Bit 26 : Pin 26 */ -#define GPIO_DIR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIR_PIN26_Msk (0x1UL << GPIO_DIR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIR_PIN26_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN26_Output (1UL) /*!< Pin set as output */ - -/* Bit 25 : Pin 25 */ -#define GPIO_DIR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIR_PIN25_Msk (0x1UL << GPIO_DIR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIR_PIN25_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN25_Output (1UL) /*!< Pin set as output */ - -/* Bit 24 : Pin 24 */ -#define GPIO_DIR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIR_PIN24_Msk (0x1UL << GPIO_DIR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIR_PIN24_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN24_Output (1UL) /*!< Pin set as output */ - -/* Bit 23 : Pin 23 */ -#define GPIO_DIR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIR_PIN23_Msk (0x1UL << GPIO_DIR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIR_PIN23_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN23_Output (1UL) /*!< Pin set as output */ - -/* Bit 22 : Pin 22 */ -#define GPIO_DIR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIR_PIN22_Msk (0x1UL << GPIO_DIR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIR_PIN22_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN22_Output (1UL) /*!< Pin set as output */ - -/* Bit 21 : Pin 21 */ -#define GPIO_DIR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIR_PIN21_Msk (0x1UL << GPIO_DIR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIR_PIN21_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN21_Output (1UL) /*!< Pin set as output */ - -/* Bit 20 : Pin 20 */ -#define GPIO_DIR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIR_PIN20_Msk (0x1UL << GPIO_DIR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIR_PIN20_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN20_Output (1UL) /*!< Pin set as output */ - -/* Bit 19 : Pin 19 */ -#define GPIO_DIR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIR_PIN19_Msk (0x1UL << GPIO_DIR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIR_PIN19_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN19_Output (1UL) /*!< Pin set as output */ - -/* Bit 18 : Pin 18 */ -#define GPIO_DIR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIR_PIN18_Msk (0x1UL << GPIO_DIR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIR_PIN18_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN18_Output (1UL) /*!< Pin set as output */ - -/* Bit 17 : Pin 17 */ -#define GPIO_DIR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIR_PIN17_Msk (0x1UL << GPIO_DIR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIR_PIN17_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN17_Output (1UL) /*!< Pin set as output */ - -/* Bit 16 : Pin 16 */ -#define GPIO_DIR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIR_PIN16_Msk (0x1UL << GPIO_DIR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIR_PIN16_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN16_Output (1UL) /*!< Pin set as output */ - -/* Bit 15 : Pin 15 */ -#define GPIO_DIR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIR_PIN15_Msk (0x1UL << GPIO_DIR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIR_PIN15_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN15_Output (1UL) /*!< Pin set as output */ - -/* Bit 14 : Pin 14 */ -#define GPIO_DIR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIR_PIN14_Msk (0x1UL << GPIO_DIR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIR_PIN14_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN14_Output (1UL) /*!< Pin set as output */ - -/* Bit 13 : Pin 13 */ -#define GPIO_DIR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIR_PIN13_Msk (0x1UL << GPIO_DIR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIR_PIN13_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN13_Output (1UL) /*!< Pin set as output */ - -/* Bit 12 : Pin 12 */ -#define GPIO_DIR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIR_PIN12_Msk (0x1UL << GPIO_DIR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIR_PIN12_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN12_Output (1UL) /*!< Pin set as output */ - -/* Bit 11 : Pin 11 */ -#define GPIO_DIR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIR_PIN11_Msk (0x1UL << GPIO_DIR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIR_PIN11_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN11_Output (1UL) /*!< Pin set as output */ - -/* Bit 10 : Pin 10 */ -#define GPIO_DIR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIR_PIN10_Msk (0x1UL << GPIO_DIR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIR_PIN10_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN10_Output (1UL) /*!< Pin set as output */ - -/* Bit 9 : Pin 9 */ -#define GPIO_DIR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIR_PIN9_Msk (0x1UL << GPIO_DIR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIR_PIN9_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN9_Output (1UL) /*!< Pin set as output */ - -/* Bit 8 : Pin 8 */ -#define GPIO_DIR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIR_PIN8_Msk (0x1UL << GPIO_DIR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIR_PIN8_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN8_Output (1UL) /*!< Pin set as output */ - -/* Bit 7 : Pin 7 */ -#define GPIO_DIR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIR_PIN7_Msk (0x1UL << GPIO_DIR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIR_PIN7_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN7_Output (1UL) /*!< Pin set as output */ - -/* Bit 6 : Pin 6 */ -#define GPIO_DIR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIR_PIN6_Msk (0x1UL << GPIO_DIR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIR_PIN6_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN6_Output (1UL) /*!< Pin set as output */ - -/* Bit 5 : Pin 5 */ -#define GPIO_DIR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIR_PIN5_Msk (0x1UL << GPIO_DIR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIR_PIN5_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN5_Output (1UL) /*!< Pin set as output */ - -/* Bit 4 : Pin 4 */ -#define GPIO_DIR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIR_PIN4_Msk (0x1UL << GPIO_DIR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIR_PIN4_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN4_Output (1UL) /*!< Pin set as output */ - -/* Bit 3 : Pin 3 */ -#define GPIO_DIR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIR_PIN3_Msk (0x1UL << GPIO_DIR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIR_PIN3_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN3_Output (1UL) /*!< Pin set as output */ - -/* Bit 2 : Pin 2 */ -#define GPIO_DIR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIR_PIN2_Msk (0x1UL << GPIO_DIR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIR_PIN2_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN2_Output (1UL) /*!< Pin set as output */ - -/* Bit 1 : Pin 1 */ -#define GPIO_DIR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIR_PIN1_Msk (0x1UL << GPIO_DIR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIR_PIN1_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN1_Output (1UL) /*!< Pin set as output */ - -/* Bit 0 : Pin 0 */ -#define GPIO_DIR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIR_PIN0_Msk (0x1UL << GPIO_DIR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIR_PIN0_Input (0UL) /*!< Pin set as input */ -#define GPIO_DIR_PIN0_Output (1UL) /*!< Pin set as output */ - -/* Register: GPIO_DIRSET */ -/* Description: DIR set register */ - -/* Bit 31 : Set as output pin 31 */ -#define GPIO_DIRSET_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIRSET_PIN31_Msk (0x1UL << GPIO_DIRSET_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIRSET_PIN31_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN31_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN31_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 30 : Set as output pin 30 */ -#define GPIO_DIRSET_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIRSET_PIN30_Msk (0x1UL << GPIO_DIRSET_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIRSET_PIN30_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN30_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN30_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 29 : Set as output pin 29 */ -#define GPIO_DIRSET_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIRSET_PIN29_Msk (0x1UL << GPIO_DIRSET_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIRSET_PIN29_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN29_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN29_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 28 : Set as output pin 28 */ -#define GPIO_DIRSET_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIRSET_PIN28_Msk (0x1UL << GPIO_DIRSET_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIRSET_PIN28_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN28_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN28_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 27 : Set as output pin 27 */ -#define GPIO_DIRSET_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIRSET_PIN27_Msk (0x1UL << GPIO_DIRSET_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIRSET_PIN27_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN27_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN27_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 26 : Set as output pin 26 */ -#define GPIO_DIRSET_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIRSET_PIN26_Msk (0x1UL << GPIO_DIRSET_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIRSET_PIN26_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN26_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN26_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 25 : Set as output pin 25 */ -#define GPIO_DIRSET_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIRSET_PIN25_Msk (0x1UL << GPIO_DIRSET_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIRSET_PIN25_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN25_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN25_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 24 : Set as output pin 24 */ -#define GPIO_DIRSET_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIRSET_PIN24_Msk (0x1UL << GPIO_DIRSET_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIRSET_PIN24_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN24_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN24_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 23 : Set as output pin 23 */ -#define GPIO_DIRSET_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIRSET_PIN23_Msk (0x1UL << GPIO_DIRSET_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIRSET_PIN23_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN23_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN23_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 22 : Set as output pin 22 */ -#define GPIO_DIRSET_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIRSET_PIN22_Msk (0x1UL << GPIO_DIRSET_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIRSET_PIN22_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN22_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN22_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 21 : Set as output pin 21 */ -#define GPIO_DIRSET_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIRSET_PIN21_Msk (0x1UL << GPIO_DIRSET_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIRSET_PIN21_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN21_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN21_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 20 : Set as output pin 20 */ -#define GPIO_DIRSET_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIRSET_PIN20_Msk (0x1UL << GPIO_DIRSET_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIRSET_PIN20_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN20_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN20_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 19 : Set as output pin 19 */ -#define GPIO_DIRSET_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIRSET_PIN19_Msk (0x1UL << GPIO_DIRSET_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIRSET_PIN19_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN19_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN19_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 18 : Set as output pin 18 */ -#define GPIO_DIRSET_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIRSET_PIN18_Msk (0x1UL << GPIO_DIRSET_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIRSET_PIN18_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN18_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN18_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 17 : Set as output pin 17 */ -#define GPIO_DIRSET_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIRSET_PIN17_Msk (0x1UL << GPIO_DIRSET_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIRSET_PIN17_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN17_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN17_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 16 : Set as output pin 16 */ -#define GPIO_DIRSET_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIRSET_PIN16_Msk (0x1UL << GPIO_DIRSET_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIRSET_PIN16_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN16_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN16_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 15 : Set as output pin 15 */ -#define GPIO_DIRSET_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIRSET_PIN15_Msk (0x1UL << GPIO_DIRSET_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIRSET_PIN15_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN15_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN15_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 14 : Set as output pin 14 */ -#define GPIO_DIRSET_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIRSET_PIN14_Msk (0x1UL << GPIO_DIRSET_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIRSET_PIN14_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN14_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN14_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 13 : Set as output pin 13 */ -#define GPIO_DIRSET_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIRSET_PIN13_Msk (0x1UL << GPIO_DIRSET_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIRSET_PIN13_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN13_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN13_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 12 : Set as output pin 12 */ -#define GPIO_DIRSET_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIRSET_PIN12_Msk (0x1UL << GPIO_DIRSET_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIRSET_PIN12_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN12_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN12_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 11 : Set as output pin 11 */ -#define GPIO_DIRSET_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIRSET_PIN11_Msk (0x1UL << GPIO_DIRSET_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIRSET_PIN11_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN11_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN11_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 10 : Set as output pin 10 */ -#define GPIO_DIRSET_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIRSET_PIN10_Msk (0x1UL << GPIO_DIRSET_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIRSET_PIN10_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN10_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN10_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 9 : Set as output pin 9 */ -#define GPIO_DIRSET_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIRSET_PIN9_Msk (0x1UL << GPIO_DIRSET_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIRSET_PIN9_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN9_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN9_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 8 : Set as output pin 8 */ -#define GPIO_DIRSET_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIRSET_PIN8_Msk (0x1UL << GPIO_DIRSET_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIRSET_PIN8_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN8_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN8_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 7 : Set as output pin 7 */ -#define GPIO_DIRSET_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIRSET_PIN7_Msk (0x1UL << GPIO_DIRSET_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIRSET_PIN7_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN7_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN7_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 6 : Set as output pin 6 */ -#define GPIO_DIRSET_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIRSET_PIN6_Msk (0x1UL << GPIO_DIRSET_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIRSET_PIN6_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN6_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN6_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 5 : Set as output pin 5 */ -#define GPIO_DIRSET_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIRSET_PIN5_Msk (0x1UL << GPIO_DIRSET_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIRSET_PIN5_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN5_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN5_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 4 : Set as output pin 4 */ -#define GPIO_DIRSET_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIRSET_PIN4_Msk (0x1UL << GPIO_DIRSET_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIRSET_PIN4_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN4_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN4_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 3 : Set as output pin 3 */ -#define GPIO_DIRSET_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIRSET_PIN3_Msk (0x1UL << GPIO_DIRSET_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIRSET_PIN3_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN3_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN3_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 2 : Set as output pin 2 */ -#define GPIO_DIRSET_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIRSET_PIN2_Msk (0x1UL << GPIO_DIRSET_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIRSET_PIN2_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN2_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN2_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 1 : Set as output pin 1 */ -#define GPIO_DIRSET_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIRSET_PIN1_Msk (0x1UL << GPIO_DIRSET_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIRSET_PIN1_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN1_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN1_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Bit 0 : Set as output pin 0 */ -#define GPIO_DIRSET_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIRSET_PIN0_Msk (0x1UL << GPIO_DIRSET_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIRSET_PIN0_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRSET_PIN0_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRSET_PIN0_Set (1UL) /*!< Write: writing a '1' sets pin to output; writing a '0' has no effect */ - -/* Register: GPIO_DIRCLR */ -/* Description: DIR clear register */ - -/* Bit 31 : Set as input pin 31 */ -#define GPIO_DIRCLR_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_DIRCLR_PIN31_Msk (0x1UL << GPIO_DIRCLR_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_DIRCLR_PIN31_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN31_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN31_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 30 : Set as input pin 30 */ -#define GPIO_DIRCLR_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_DIRCLR_PIN30_Msk (0x1UL << GPIO_DIRCLR_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_DIRCLR_PIN30_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN30_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN30_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 29 : Set as input pin 29 */ -#define GPIO_DIRCLR_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_DIRCLR_PIN29_Msk (0x1UL << GPIO_DIRCLR_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_DIRCLR_PIN29_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN29_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN29_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 28 : Set as input pin 28 */ -#define GPIO_DIRCLR_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_DIRCLR_PIN28_Msk (0x1UL << GPIO_DIRCLR_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_DIRCLR_PIN28_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN28_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN28_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 27 : Set as input pin 27 */ -#define GPIO_DIRCLR_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_DIRCLR_PIN27_Msk (0x1UL << GPIO_DIRCLR_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_DIRCLR_PIN27_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN27_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN27_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 26 : Set as input pin 26 */ -#define GPIO_DIRCLR_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_DIRCLR_PIN26_Msk (0x1UL << GPIO_DIRCLR_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_DIRCLR_PIN26_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN26_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN26_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 25 : Set as input pin 25 */ -#define GPIO_DIRCLR_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_DIRCLR_PIN25_Msk (0x1UL << GPIO_DIRCLR_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_DIRCLR_PIN25_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN25_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN25_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 24 : Set as input pin 24 */ -#define GPIO_DIRCLR_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_DIRCLR_PIN24_Msk (0x1UL << GPIO_DIRCLR_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_DIRCLR_PIN24_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN24_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN24_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 23 : Set as input pin 23 */ -#define GPIO_DIRCLR_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_DIRCLR_PIN23_Msk (0x1UL << GPIO_DIRCLR_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_DIRCLR_PIN23_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN23_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN23_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 22 : Set as input pin 22 */ -#define GPIO_DIRCLR_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_DIRCLR_PIN22_Msk (0x1UL << GPIO_DIRCLR_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_DIRCLR_PIN22_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN22_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN22_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 21 : Set as input pin 21 */ -#define GPIO_DIRCLR_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_DIRCLR_PIN21_Msk (0x1UL << GPIO_DIRCLR_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_DIRCLR_PIN21_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN21_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN21_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 20 : Set as input pin 20 */ -#define GPIO_DIRCLR_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_DIRCLR_PIN20_Msk (0x1UL << GPIO_DIRCLR_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_DIRCLR_PIN20_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN20_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN20_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 19 : Set as input pin 19 */ -#define GPIO_DIRCLR_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_DIRCLR_PIN19_Msk (0x1UL << GPIO_DIRCLR_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_DIRCLR_PIN19_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN19_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN19_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 18 : Set as input pin 18 */ -#define GPIO_DIRCLR_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_DIRCLR_PIN18_Msk (0x1UL << GPIO_DIRCLR_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_DIRCLR_PIN18_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN18_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN18_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 17 : Set as input pin 17 */ -#define GPIO_DIRCLR_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_DIRCLR_PIN17_Msk (0x1UL << GPIO_DIRCLR_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_DIRCLR_PIN17_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN17_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN17_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 16 : Set as input pin 16 */ -#define GPIO_DIRCLR_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_DIRCLR_PIN16_Msk (0x1UL << GPIO_DIRCLR_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_DIRCLR_PIN16_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN16_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN16_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 15 : Set as input pin 15 */ -#define GPIO_DIRCLR_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_DIRCLR_PIN15_Msk (0x1UL << GPIO_DIRCLR_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_DIRCLR_PIN15_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN15_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN15_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 14 : Set as input pin 14 */ -#define GPIO_DIRCLR_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_DIRCLR_PIN14_Msk (0x1UL << GPIO_DIRCLR_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_DIRCLR_PIN14_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN14_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN14_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 13 : Set as input pin 13 */ -#define GPIO_DIRCLR_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_DIRCLR_PIN13_Msk (0x1UL << GPIO_DIRCLR_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_DIRCLR_PIN13_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN13_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN13_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 12 : Set as input pin 12 */ -#define GPIO_DIRCLR_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_DIRCLR_PIN12_Msk (0x1UL << GPIO_DIRCLR_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_DIRCLR_PIN12_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN12_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN12_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 11 : Set as input pin 11 */ -#define GPIO_DIRCLR_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_DIRCLR_PIN11_Msk (0x1UL << GPIO_DIRCLR_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_DIRCLR_PIN11_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN11_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN11_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 10 : Set as input pin 10 */ -#define GPIO_DIRCLR_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_DIRCLR_PIN10_Msk (0x1UL << GPIO_DIRCLR_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_DIRCLR_PIN10_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN10_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN10_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 9 : Set as input pin 9 */ -#define GPIO_DIRCLR_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_DIRCLR_PIN9_Msk (0x1UL << GPIO_DIRCLR_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_DIRCLR_PIN9_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN9_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN9_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 8 : Set as input pin 8 */ -#define GPIO_DIRCLR_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_DIRCLR_PIN8_Msk (0x1UL << GPIO_DIRCLR_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_DIRCLR_PIN8_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN8_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN8_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 7 : Set as input pin 7 */ -#define GPIO_DIRCLR_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_DIRCLR_PIN7_Msk (0x1UL << GPIO_DIRCLR_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_DIRCLR_PIN7_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN7_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN7_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 6 : Set as input pin 6 */ -#define GPIO_DIRCLR_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_DIRCLR_PIN6_Msk (0x1UL << GPIO_DIRCLR_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_DIRCLR_PIN6_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN6_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN6_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 5 : Set as input pin 5 */ -#define GPIO_DIRCLR_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_DIRCLR_PIN5_Msk (0x1UL << GPIO_DIRCLR_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_DIRCLR_PIN5_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN5_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN5_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 4 : Set as input pin 4 */ -#define GPIO_DIRCLR_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_DIRCLR_PIN4_Msk (0x1UL << GPIO_DIRCLR_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_DIRCLR_PIN4_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN4_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN4_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 3 : Set as input pin 3 */ -#define GPIO_DIRCLR_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_DIRCLR_PIN3_Msk (0x1UL << GPIO_DIRCLR_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_DIRCLR_PIN3_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN3_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN3_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 2 : Set as input pin 2 */ -#define GPIO_DIRCLR_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_DIRCLR_PIN2_Msk (0x1UL << GPIO_DIRCLR_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_DIRCLR_PIN2_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN2_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN2_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 1 : Set as input pin 1 */ -#define GPIO_DIRCLR_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_DIRCLR_PIN1_Msk (0x1UL << GPIO_DIRCLR_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_DIRCLR_PIN1_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN1_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN1_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Bit 0 : Set as input pin 0 */ -#define GPIO_DIRCLR_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_DIRCLR_PIN0_Msk (0x1UL << GPIO_DIRCLR_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_DIRCLR_PIN0_Input (0UL) /*!< Read: pin set as input */ -#define GPIO_DIRCLR_PIN0_Output (1UL) /*!< Read: pin set as output */ -#define GPIO_DIRCLR_PIN0_Clear (1UL) /*!< Write: writing a '1' sets pin to input; writing a '0' has no effect */ - -/* Register: GPIO_LATCH */ -/* Description: Latch register indicating what GPIO pins that have met the criteria set in the PIN_CNF[n].SENSE registers */ - -/* Bit 31 : Status on whether PIN31 has met criteria set in PIN_CNF31.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN31_Pos (31UL) /*!< Position of PIN31 field. */ -#define GPIO_LATCH_PIN31_Msk (0x1UL << GPIO_LATCH_PIN31_Pos) /*!< Bit mask of PIN31 field. */ -#define GPIO_LATCH_PIN31_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN31_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 30 : Status on whether PIN30 has met criteria set in PIN_CNF30.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN30_Pos (30UL) /*!< Position of PIN30 field. */ -#define GPIO_LATCH_PIN30_Msk (0x1UL << GPIO_LATCH_PIN30_Pos) /*!< Bit mask of PIN30 field. */ -#define GPIO_LATCH_PIN30_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN30_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 29 : Status on whether PIN29 has met criteria set in PIN_CNF29.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN29_Pos (29UL) /*!< Position of PIN29 field. */ -#define GPIO_LATCH_PIN29_Msk (0x1UL << GPIO_LATCH_PIN29_Pos) /*!< Bit mask of PIN29 field. */ -#define GPIO_LATCH_PIN29_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN29_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 28 : Status on whether PIN28 has met criteria set in PIN_CNF28.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN28_Pos (28UL) /*!< Position of PIN28 field. */ -#define GPIO_LATCH_PIN28_Msk (0x1UL << GPIO_LATCH_PIN28_Pos) /*!< Bit mask of PIN28 field. */ -#define GPIO_LATCH_PIN28_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN28_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 27 : Status on whether PIN27 has met criteria set in PIN_CNF27.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN27_Pos (27UL) /*!< Position of PIN27 field. */ -#define GPIO_LATCH_PIN27_Msk (0x1UL << GPIO_LATCH_PIN27_Pos) /*!< Bit mask of PIN27 field. */ -#define GPIO_LATCH_PIN27_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN27_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 26 : Status on whether PIN26 has met criteria set in PIN_CNF26.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN26_Pos (26UL) /*!< Position of PIN26 field. */ -#define GPIO_LATCH_PIN26_Msk (0x1UL << GPIO_LATCH_PIN26_Pos) /*!< Bit mask of PIN26 field. */ -#define GPIO_LATCH_PIN26_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN26_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 25 : Status on whether PIN25 has met criteria set in PIN_CNF25.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN25_Pos (25UL) /*!< Position of PIN25 field. */ -#define GPIO_LATCH_PIN25_Msk (0x1UL << GPIO_LATCH_PIN25_Pos) /*!< Bit mask of PIN25 field. */ -#define GPIO_LATCH_PIN25_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN25_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 24 : Status on whether PIN24 has met criteria set in PIN_CNF24.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN24_Pos (24UL) /*!< Position of PIN24 field. */ -#define GPIO_LATCH_PIN24_Msk (0x1UL << GPIO_LATCH_PIN24_Pos) /*!< Bit mask of PIN24 field. */ -#define GPIO_LATCH_PIN24_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN24_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 23 : Status on whether PIN23 has met criteria set in PIN_CNF23.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN23_Pos (23UL) /*!< Position of PIN23 field. */ -#define GPIO_LATCH_PIN23_Msk (0x1UL << GPIO_LATCH_PIN23_Pos) /*!< Bit mask of PIN23 field. */ -#define GPIO_LATCH_PIN23_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN23_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 22 : Status on whether PIN22 has met criteria set in PIN_CNF22.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN22_Pos (22UL) /*!< Position of PIN22 field. */ -#define GPIO_LATCH_PIN22_Msk (0x1UL << GPIO_LATCH_PIN22_Pos) /*!< Bit mask of PIN22 field. */ -#define GPIO_LATCH_PIN22_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN22_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 21 : Status on whether PIN21 has met criteria set in PIN_CNF21.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN21_Pos (21UL) /*!< Position of PIN21 field. */ -#define GPIO_LATCH_PIN21_Msk (0x1UL << GPIO_LATCH_PIN21_Pos) /*!< Bit mask of PIN21 field. */ -#define GPIO_LATCH_PIN21_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN21_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 20 : Status on whether PIN20 has met criteria set in PIN_CNF20.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN20_Pos (20UL) /*!< Position of PIN20 field. */ -#define GPIO_LATCH_PIN20_Msk (0x1UL << GPIO_LATCH_PIN20_Pos) /*!< Bit mask of PIN20 field. */ -#define GPIO_LATCH_PIN20_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN20_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 19 : Status on whether PIN19 has met criteria set in PIN_CNF19.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN19_Pos (19UL) /*!< Position of PIN19 field. */ -#define GPIO_LATCH_PIN19_Msk (0x1UL << GPIO_LATCH_PIN19_Pos) /*!< Bit mask of PIN19 field. */ -#define GPIO_LATCH_PIN19_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN19_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 18 : Status on whether PIN18 has met criteria set in PIN_CNF18.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN18_Pos (18UL) /*!< Position of PIN18 field. */ -#define GPIO_LATCH_PIN18_Msk (0x1UL << GPIO_LATCH_PIN18_Pos) /*!< Bit mask of PIN18 field. */ -#define GPIO_LATCH_PIN18_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN18_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 17 : Status on whether PIN17 has met criteria set in PIN_CNF17.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN17_Pos (17UL) /*!< Position of PIN17 field. */ -#define GPIO_LATCH_PIN17_Msk (0x1UL << GPIO_LATCH_PIN17_Pos) /*!< Bit mask of PIN17 field. */ -#define GPIO_LATCH_PIN17_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN17_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 16 : Status on whether PIN16 has met criteria set in PIN_CNF16.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN16_Pos (16UL) /*!< Position of PIN16 field. */ -#define GPIO_LATCH_PIN16_Msk (0x1UL << GPIO_LATCH_PIN16_Pos) /*!< Bit mask of PIN16 field. */ -#define GPIO_LATCH_PIN16_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN16_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 15 : Status on whether PIN15 has met criteria set in PIN_CNF15.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN15_Pos (15UL) /*!< Position of PIN15 field. */ -#define GPIO_LATCH_PIN15_Msk (0x1UL << GPIO_LATCH_PIN15_Pos) /*!< Bit mask of PIN15 field. */ -#define GPIO_LATCH_PIN15_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN15_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 14 : Status on whether PIN14 has met criteria set in PIN_CNF14.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN14_Pos (14UL) /*!< Position of PIN14 field. */ -#define GPIO_LATCH_PIN14_Msk (0x1UL << GPIO_LATCH_PIN14_Pos) /*!< Bit mask of PIN14 field. */ -#define GPIO_LATCH_PIN14_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN14_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 13 : Status on whether PIN13 has met criteria set in PIN_CNF13.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN13_Pos (13UL) /*!< Position of PIN13 field. */ -#define GPIO_LATCH_PIN13_Msk (0x1UL << GPIO_LATCH_PIN13_Pos) /*!< Bit mask of PIN13 field. */ -#define GPIO_LATCH_PIN13_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN13_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 12 : Status on whether PIN12 has met criteria set in PIN_CNF12.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN12_Pos (12UL) /*!< Position of PIN12 field. */ -#define GPIO_LATCH_PIN12_Msk (0x1UL << GPIO_LATCH_PIN12_Pos) /*!< Bit mask of PIN12 field. */ -#define GPIO_LATCH_PIN12_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN12_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 11 : Status on whether PIN11 has met criteria set in PIN_CNF11.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN11_Pos (11UL) /*!< Position of PIN11 field. */ -#define GPIO_LATCH_PIN11_Msk (0x1UL << GPIO_LATCH_PIN11_Pos) /*!< Bit mask of PIN11 field. */ -#define GPIO_LATCH_PIN11_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN11_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 10 : Status on whether PIN10 has met criteria set in PIN_CNF10.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN10_Pos (10UL) /*!< Position of PIN10 field. */ -#define GPIO_LATCH_PIN10_Msk (0x1UL << GPIO_LATCH_PIN10_Pos) /*!< Bit mask of PIN10 field. */ -#define GPIO_LATCH_PIN10_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN10_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 9 : Status on whether PIN9 has met criteria set in PIN_CNF9.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN9_Pos (9UL) /*!< Position of PIN9 field. */ -#define GPIO_LATCH_PIN9_Msk (0x1UL << GPIO_LATCH_PIN9_Pos) /*!< Bit mask of PIN9 field. */ -#define GPIO_LATCH_PIN9_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN9_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 8 : Status on whether PIN8 has met criteria set in PIN_CNF8.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN8_Pos (8UL) /*!< Position of PIN8 field. */ -#define GPIO_LATCH_PIN8_Msk (0x1UL << GPIO_LATCH_PIN8_Pos) /*!< Bit mask of PIN8 field. */ -#define GPIO_LATCH_PIN8_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN8_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 7 : Status on whether PIN7 has met criteria set in PIN_CNF7.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN7_Pos (7UL) /*!< Position of PIN7 field. */ -#define GPIO_LATCH_PIN7_Msk (0x1UL << GPIO_LATCH_PIN7_Pos) /*!< Bit mask of PIN7 field. */ -#define GPIO_LATCH_PIN7_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN7_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 6 : Status on whether PIN6 has met criteria set in PIN_CNF6.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN6_Pos (6UL) /*!< Position of PIN6 field. */ -#define GPIO_LATCH_PIN6_Msk (0x1UL << GPIO_LATCH_PIN6_Pos) /*!< Bit mask of PIN6 field. */ -#define GPIO_LATCH_PIN6_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN6_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 5 : Status on whether PIN5 has met criteria set in PIN_CNF5.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN5_Pos (5UL) /*!< Position of PIN5 field. */ -#define GPIO_LATCH_PIN5_Msk (0x1UL << GPIO_LATCH_PIN5_Pos) /*!< Bit mask of PIN5 field. */ -#define GPIO_LATCH_PIN5_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN5_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 4 : Status on whether PIN4 has met criteria set in PIN_CNF4.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN4_Pos (4UL) /*!< Position of PIN4 field. */ -#define GPIO_LATCH_PIN4_Msk (0x1UL << GPIO_LATCH_PIN4_Pos) /*!< Bit mask of PIN4 field. */ -#define GPIO_LATCH_PIN4_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN4_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 3 : Status on whether PIN3 has met criteria set in PIN_CNF3.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN3_Pos (3UL) /*!< Position of PIN3 field. */ -#define GPIO_LATCH_PIN3_Msk (0x1UL << GPIO_LATCH_PIN3_Pos) /*!< Bit mask of PIN3 field. */ -#define GPIO_LATCH_PIN3_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN3_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 2 : Status on whether PIN2 has met criteria set in PIN_CNF2.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN2_Pos (2UL) /*!< Position of PIN2 field. */ -#define GPIO_LATCH_PIN2_Msk (0x1UL << GPIO_LATCH_PIN2_Pos) /*!< Bit mask of PIN2 field. */ -#define GPIO_LATCH_PIN2_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN2_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 1 : Status on whether PIN1 has met criteria set in PIN_CNF1.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN1_Pos (1UL) /*!< Position of PIN1 field. */ -#define GPIO_LATCH_PIN1_Msk (0x1UL << GPIO_LATCH_PIN1_Pos) /*!< Bit mask of PIN1 field. */ -#define GPIO_LATCH_PIN1_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN1_Latched (1UL) /*!< Criteria has been met */ - -/* Bit 0 : Status on whether PIN0 has met criteria set in PIN_CNF0.SENSE register. Write '1' to clear. */ -#define GPIO_LATCH_PIN0_Pos (0UL) /*!< Position of PIN0 field. */ -#define GPIO_LATCH_PIN0_Msk (0x1UL << GPIO_LATCH_PIN0_Pos) /*!< Bit mask of PIN0 field. */ -#define GPIO_LATCH_PIN0_NotLatched (0UL) /*!< Criteria has not been met */ -#define GPIO_LATCH_PIN0_Latched (1UL) /*!< Criteria has been met */ - -/* Register: GPIO_DETECTMODE */ -/* Description: Select between default DETECT signal behaviour and LDETECT mode */ - -/* Bit 0 : Select between default DETECT signal behaviour and LDETECT mode */ -#define GPIO_DETECTMODE_DETECTMODE_Pos (0UL) /*!< Position of DETECTMODE field. */ -#define GPIO_DETECTMODE_DETECTMODE_Msk (0x1UL << GPIO_DETECTMODE_DETECTMODE_Pos) /*!< Bit mask of DETECTMODE field. */ -#define GPIO_DETECTMODE_DETECTMODE_Default (0UL) /*!< DETECT directly connected to PIN DETECT signals */ -#define GPIO_DETECTMODE_DETECTMODE_LDETECT (1UL) /*!< Use the latched LDETECT behaviour */ - -/* Register: GPIO_PIN_CNF */ -/* Description: Description collection[0]: Configuration of GPIO pins */ - -/* Bits 17..16 : Pin sensing mechanism */ -#define GPIO_PIN_CNF_SENSE_Pos (16UL) /*!< Position of SENSE field. */ -#define GPIO_PIN_CNF_SENSE_Msk (0x3UL << GPIO_PIN_CNF_SENSE_Pos) /*!< Bit mask of SENSE field. */ -#define GPIO_PIN_CNF_SENSE_Disabled (0UL) /*!< Disabled */ -#define GPIO_PIN_CNF_SENSE_High (2UL) /*!< Sense for high level */ -#define GPIO_PIN_CNF_SENSE_Low (3UL) /*!< Sense for low level */ - -/* Bits 10..8 : Drive configuration */ -#define GPIO_PIN_CNF_DRIVE_Pos (8UL) /*!< Position of DRIVE field. */ -#define GPIO_PIN_CNF_DRIVE_Msk (0x7UL << GPIO_PIN_CNF_DRIVE_Pos) /*!< Bit mask of DRIVE field. */ -#define GPIO_PIN_CNF_DRIVE_S0S1 (0UL) /*!< Standard '0', standard '1' */ -#define GPIO_PIN_CNF_DRIVE_H0S1 (1UL) /*!< High drive '0', standard '1' */ -#define GPIO_PIN_CNF_DRIVE_S0H1 (2UL) /*!< Standard '0', high drive '1' */ -#define GPIO_PIN_CNF_DRIVE_H0H1 (3UL) /*!< High drive '0', high 'drive '1'' */ -#define GPIO_PIN_CNF_DRIVE_D0S1 (4UL) /*!< Disconnect '0' standard '1' (normally used for wired-or connections) */ -#define GPIO_PIN_CNF_DRIVE_D0H1 (5UL) /*!< Disconnect '0', high drive '1' (normally used for wired-or connections) */ -#define GPIO_PIN_CNF_DRIVE_S0D1 (6UL) /*!< Standard '0'. disconnect '1' (normally used for wired-and connections) */ -#define GPIO_PIN_CNF_DRIVE_H0D1 (7UL) /*!< High drive '0', disconnect '1' (normally used for wired-and connections) */ - -/* Bits 3..2 : Pull configuration */ -#define GPIO_PIN_CNF_PULL_Pos (2UL) /*!< Position of PULL field. */ -#define GPIO_PIN_CNF_PULL_Msk (0x3UL << GPIO_PIN_CNF_PULL_Pos) /*!< Bit mask of PULL field. */ -#define GPIO_PIN_CNF_PULL_Disabled (0UL) /*!< No pull */ -#define GPIO_PIN_CNF_PULL_Pulldown (1UL) /*!< Pull down on pin */ -#define GPIO_PIN_CNF_PULL_Pullup (3UL) /*!< Pull up on pin */ - -/* Bit 1 : Connect or disconnect input buffer */ -#define GPIO_PIN_CNF_INPUT_Pos (1UL) /*!< Position of INPUT field. */ -#define GPIO_PIN_CNF_INPUT_Msk (0x1UL << GPIO_PIN_CNF_INPUT_Pos) /*!< Bit mask of INPUT field. */ -#define GPIO_PIN_CNF_INPUT_Connect (0UL) /*!< Connect input buffer */ -#define GPIO_PIN_CNF_INPUT_Disconnect (1UL) /*!< Disconnect input buffer */ - -/* Bit 0 : Pin direction. Same physical register as DIR register */ -#define GPIO_PIN_CNF_DIR_Pos (0UL) /*!< Position of DIR field. */ -#define GPIO_PIN_CNF_DIR_Msk (0x1UL << GPIO_PIN_CNF_DIR_Pos) /*!< Bit mask of DIR field. */ -#define GPIO_PIN_CNF_DIR_Input (0UL) /*!< Configure pin as an input pin */ -#define GPIO_PIN_CNF_DIR_Output (1UL) /*!< Configure pin as an output pin */ - - -/* Peripheral: PDM */ -/* Description: Pulse Density Modulation (Digital Microphone) Interface */ - -/* Register: PDM_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 2 : Enable or disable interrupt for END event */ -#define PDM_INTEN_END_Pos (2UL) /*!< Position of END field. */ -#define PDM_INTEN_END_Msk (0x1UL << PDM_INTEN_END_Pos) /*!< Bit mask of END field. */ -#define PDM_INTEN_END_Disabled (0UL) /*!< Disable */ -#define PDM_INTEN_END_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define PDM_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PDM_INTEN_STOPPED_Msk (0x1UL << PDM_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PDM_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define PDM_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for STARTED event */ -#define PDM_INTEN_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define PDM_INTEN_STARTED_Msk (0x1UL << PDM_INTEN_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define PDM_INTEN_STARTED_Disabled (0UL) /*!< Disable */ -#define PDM_INTEN_STARTED_Enabled (1UL) /*!< Enable */ - -/* Register: PDM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for END event */ -#define PDM_INTENSET_END_Pos (2UL) /*!< Position of END field. */ -#define PDM_INTENSET_END_Msk (0x1UL << PDM_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define PDM_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define PDM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PDM_INTENSET_STOPPED_Msk (0x1UL << PDM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PDM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for STARTED event */ -#define PDM_INTENSET_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define PDM_INTENSET_STARTED_Msk (0x1UL << PDM_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define PDM_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Register: PDM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for END event */ -#define PDM_INTENCLR_END_Pos (2UL) /*!< Position of END field. */ -#define PDM_INTENCLR_END_Msk (0x1UL << PDM_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define PDM_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define PDM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PDM_INTENCLR_STOPPED_Msk (0x1UL << PDM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PDM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for STARTED event */ -#define PDM_INTENCLR_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define PDM_INTENCLR_STARTED_Msk (0x1UL << PDM_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define PDM_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define PDM_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define PDM_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Register: PDM_ENABLE */ -/* Description: PDM module enable register */ - -/* Bit 0 : Enable or disable PDM module */ -#define PDM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define PDM_ENABLE_ENABLE_Msk (0x1UL << PDM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define PDM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define PDM_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: PDM_PDMCLKCTRL */ -/* Description: PDM clock generator control */ - -/* Bits 31..0 : PDM_CLK frequency */ -#define PDM_PDMCLKCTRL_FREQ_Pos (0UL) /*!< Position of FREQ field. */ -#define PDM_PDMCLKCTRL_FREQ_Msk (0xFFFFFFFFUL << PDM_PDMCLKCTRL_FREQ_Pos) /*!< Bit mask of FREQ field. */ -#define PDM_PDMCLKCTRL_FREQ_1000K (0x08000000UL) /*!< PDM_CLK = 32 MHz / 32 = 1.000 MHz */ -#define PDM_PDMCLKCTRL_FREQ_Default (0x08400000UL) /*!< PDM_CLK = 32 MHz / 31 = 1.032 MHz. Nominal clock for RATIO=Ratio64. */ -#define PDM_PDMCLKCTRL_FREQ_1067K (0x08800000UL) /*!< PDM_CLK = 32 MHz / 30 = 1.067 MHz */ -#define PDM_PDMCLKCTRL_FREQ_1231K (0x09800000UL) /*!< PDM_CLK = 32 MHz / 26 = 1.231 MHz */ -#define PDM_PDMCLKCTRL_FREQ_1280K (0x0A000000UL) /*!< PDM_CLK = 32 MHz / 25 = 1.280 MHz. Nominal clock for RATIO=Ratio80. */ -#define PDM_PDMCLKCTRL_FREQ_1333K (0x0A800000UL) /*!< PDM_CLK = 32 MHz / 24 = 1.333 MHz */ - -/* Register: PDM_MODE */ -/* Description: Defines the routing of the connected PDM microphones' signals */ - -/* Bit 1 : Defines on which PDM_CLK edge Left (or mono) is sampled */ -#define PDM_MODE_EDGE_Pos (1UL) /*!< Position of EDGE field. */ -#define PDM_MODE_EDGE_Msk (0x1UL << PDM_MODE_EDGE_Pos) /*!< Bit mask of EDGE field. */ -#define PDM_MODE_EDGE_LeftFalling (0UL) /*!< Left (or mono) is sampled on falling edge of PDM_CLK */ -#define PDM_MODE_EDGE_LeftRising (1UL) /*!< Left (or mono) is sampled on rising edge of PDM_CLK */ - -/* Bit 0 : Mono or stereo operation */ -#define PDM_MODE_OPERATION_Pos (0UL) /*!< Position of OPERATION field. */ -#define PDM_MODE_OPERATION_Msk (0x1UL << PDM_MODE_OPERATION_Pos) /*!< Bit mask of OPERATION field. */ -#define PDM_MODE_OPERATION_Stereo (0UL) /*!< Sample and store one pair (Left + Right) of 16bit samples per RAM word R=[31:16]; L=[15:0] */ -#define PDM_MODE_OPERATION_Mono (1UL) /*!< Sample and store two successive Left samples (16 bit each) per RAM word L1=[31:16]; L0=[15:0] */ - -/* Register: PDM_GAINL */ -/* Description: Left output gain adjustment */ - -/* Bits 6..0 : Left output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -19.5 dB gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain adjust 0x29 +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 +20 dB gain adjust */ -#define PDM_GAINL_GAINL_Pos (0UL) /*!< Position of GAINL field. */ -#define PDM_GAINL_GAINL_Msk (0x7FUL << PDM_GAINL_GAINL_Pos) /*!< Bit mask of GAINL field. */ -#define PDM_GAINL_GAINL_MinGain (0x00UL) /*!< -20dB gain adjustment (minimum) */ -#define PDM_GAINL_GAINL_DefaultGain (0x28UL) /*!< 0dB gain adjustment ('2500 RMS' requirement) */ -#define PDM_GAINL_GAINL_MaxGain (0x50UL) /*!< +20dB gain adjustment (maximum) */ - -/* Register: PDM_GAINR */ -/* Description: Right output gain adjustment */ - -/* Bits 7..0 : Right output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters) */ -#define PDM_GAINR_GAINR_Pos (0UL) /*!< Position of GAINR field. */ -#define PDM_GAINR_GAINR_Msk (0xFFUL << PDM_GAINR_GAINR_Pos) /*!< Bit mask of GAINR field. */ -#define PDM_GAINR_GAINR_MinGain (0x00UL) /*!< -20dB gain adjustment (minimum) */ -#define PDM_GAINR_GAINR_DefaultGain (0x28UL) /*!< 0dB gain adjustment ('2500 RMS' requirement) */ -#define PDM_GAINR_GAINR_MaxGain (0x50UL) /*!< +20dB gain adjustment (maximum) */ - -/* Register: PDM_RATIO */ -/* Description: Selects the ratio between PDM_CLK and output sample rate. Change PDMCLKCTRL accordingly. */ - -/* Bit 0 : Selects the ratio between PDM_CLK and output sample rate */ -#define PDM_RATIO_RATIO_Pos (0UL) /*!< Position of RATIO field. */ -#define PDM_RATIO_RATIO_Msk (0x1UL << PDM_RATIO_RATIO_Pos) /*!< Bit mask of RATIO field. */ -#define PDM_RATIO_RATIO_Ratio64 (0UL) /*!< Ratio of 64 */ -#define PDM_RATIO_RATIO_Ratio80 (1UL) /*!< Ratio of 80 */ - -/* Register: PDM_PSEL_CLK */ -/* Description: Pin number configuration for PDM CLK signal */ - -/* Bit 31 : Connection */ -#define PDM_PSEL_CLK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define PDM_PSEL_CLK_CONNECT_Msk (0x1UL << PDM_PSEL_CLK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define PDM_PSEL_CLK_CONNECT_Connected (0UL) /*!< Connect */ -#define PDM_PSEL_CLK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define PDM_PSEL_CLK_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define PDM_PSEL_CLK_PORT_Msk (0x1UL << PDM_PSEL_CLK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define PDM_PSEL_CLK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define PDM_PSEL_CLK_PIN_Msk (0x1FUL << PDM_PSEL_CLK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: PDM_PSEL_DIN */ -/* Description: Pin number configuration for PDM DIN signal */ - -/* Bit 31 : Connection */ -#define PDM_PSEL_DIN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define PDM_PSEL_DIN_CONNECT_Msk (0x1UL << PDM_PSEL_DIN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define PDM_PSEL_DIN_CONNECT_Connected (0UL) /*!< Connect */ -#define PDM_PSEL_DIN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define PDM_PSEL_DIN_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define PDM_PSEL_DIN_PORT_Msk (0x1UL << PDM_PSEL_DIN_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define PDM_PSEL_DIN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define PDM_PSEL_DIN_PIN_Msk (0x1FUL << PDM_PSEL_DIN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: PDM_SAMPLE_PTR */ -/* Description: RAM address pointer to write samples to with EasyDMA */ - -/* Bits 31..0 : Address to write PDM samples to over DMA */ -#define PDM_SAMPLE_PTR_SAMPLEPTR_Pos (0UL) /*!< Position of SAMPLEPTR field. */ -#define PDM_SAMPLE_PTR_SAMPLEPTR_Msk (0xFFFFFFFFUL << PDM_SAMPLE_PTR_SAMPLEPTR_Pos) /*!< Bit mask of SAMPLEPTR field. */ - -/* Register: PDM_SAMPLE_MAXCNT */ -/* Description: Number of samples to allocate memory for in EasyDMA mode */ - -/* Bits 14..0 : Length of DMA RAM allocation in number of samples */ -#define PDM_SAMPLE_MAXCNT_BUFFSIZE_Pos (0UL) /*!< Position of BUFFSIZE field. */ -#define PDM_SAMPLE_MAXCNT_BUFFSIZE_Msk (0x7FFFUL << PDM_SAMPLE_MAXCNT_BUFFSIZE_Pos) /*!< Bit mask of BUFFSIZE field. */ - - -/* Peripheral: POWER */ -/* Description: Power control */ - -/* Register: POWER_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 9 : Write '1' to Enable interrupt for USBPWRRDY event */ -#define POWER_INTENSET_USBPWRRDY_Pos (9UL) /*!< Position of USBPWRRDY field. */ -#define POWER_INTENSET_USBPWRRDY_Msk (0x1UL << POWER_INTENSET_USBPWRRDY_Pos) /*!< Bit mask of USBPWRRDY field. */ -#define POWER_INTENSET_USBPWRRDY_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_USBPWRRDY_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_USBPWRRDY_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for USBREMOVED event */ -#define POWER_INTENSET_USBREMOVED_Pos (8UL) /*!< Position of USBREMOVED field. */ -#define POWER_INTENSET_USBREMOVED_Msk (0x1UL << POWER_INTENSET_USBREMOVED_Pos) /*!< Bit mask of USBREMOVED field. */ -#define POWER_INTENSET_USBREMOVED_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_USBREMOVED_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_USBREMOVED_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for USBDETECTED event */ -#define POWER_INTENSET_USBDETECTED_Pos (7UL) /*!< Position of USBDETECTED field. */ -#define POWER_INTENSET_USBDETECTED_Msk (0x1UL << POWER_INTENSET_USBDETECTED_Pos) /*!< Bit mask of USBDETECTED field. */ -#define POWER_INTENSET_USBDETECTED_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_USBDETECTED_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_USBDETECTED_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for SLEEPEXIT event */ -#define POWER_INTENSET_SLEEPEXIT_Pos (6UL) /*!< Position of SLEEPEXIT field. */ -#define POWER_INTENSET_SLEEPEXIT_Msk (0x1UL << POWER_INTENSET_SLEEPEXIT_Pos) /*!< Bit mask of SLEEPEXIT field. */ -#define POWER_INTENSET_SLEEPEXIT_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_SLEEPEXIT_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_SLEEPEXIT_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for SLEEPENTER event */ -#define POWER_INTENSET_SLEEPENTER_Pos (5UL) /*!< Position of SLEEPENTER field. */ -#define POWER_INTENSET_SLEEPENTER_Msk (0x1UL << POWER_INTENSET_SLEEPENTER_Pos) /*!< Bit mask of SLEEPENTER field. */ -#define POWER_INTENSET_SLEEPENTER_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_SLEEPENTER_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_SLEEPENTER_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for POFWARN event */ -#define POWER_INTENSET_POFWARN_Pos (2UL) /*!< Position of POFWARN field. */ -#define POWER_INTENSET_POFWARN_Msk (0x1UL << POWER_INTENSET_POFWARN_Pos) /*!< Bit mask of POFWARN field. */ -#define POWER_INTENSET_POFWARN_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENSET_POFWARN_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENSET_POFWARN_Set (1UL) /*!< Enable */ - -/* Register: POWER_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 9 : Write '1' to Disable interrupt for USBPWRRDY event */ -#define POWER_INTENCLR_USBPWRRDY_Pos (9UL) /*!< Position of USBPWRRDY field. */ -#define POWER_INTENCLR_USBPWRRDY_Msk (0x1UL << POWER_INTENCLR_USBPWRRDY_Pos) /*!< Bit mask of USBPWRRDY field. */ -#define POWER_INTENCLR_USBPWRRDY_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_USBPWRRDY_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_USBPWRRDY_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for USBREMOVED event */ -#define POWER_INTENCLR_USBREMOVED_Pos (8UL) /*!< Position of USBREMOVED field. */ -#define POWER_INTENCLR_USBREMOVED_Msk (0x1UL << POWER_INTENCLR_USBREMOVED_Pos) /*!< Bit mask of USBREMOVED field. */ -#define POWER_INTENCLR_USBREMOVED_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_USBREMOVED_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_USBREMOVED_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for USBDETECTED event */ -#define POWER_INTENCLR_USBDETECTED_Pos (7UL) /*!< Position of USBDETECTED field. */ -#define POWER_INTENCLR_USBDETECTED_Msk (0x1UL << POWER_INTENCLR_USBDETECTED_Pos) /*!< Bit mask of USBDETECTED field. */ -#define POWER_INTENCLR_USBDETECTED_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_USBDETECTED_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_USBDETECTED_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for SLEEPEXIT event */ -#define POWER_INTENCLR_SLEEPEXIT_Pos (6UL) /*!< Position of SLEEPEXIT field. */ -#define POWER_INTENCLR_SLEEPEXIT_Msk (0x1UL << POWER_INTENCLR_SLEEPEXIT_Pos) /*!< Bit mask of SLEEPEXIT field. */ -#define POWER_INTENCLR_SLEEPEXIT_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_SLEEPEXIT_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_SLEEPEXIT_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for SLEEPENTER event */ -#define POWER_INTENCLR_SLEEPENTER_Pos (5UL) /*!< Position of SLEEPENTER field. */ -#define POWER_INTENCLR_SLEEPENTER_Msk (0x1UL << POWER_INTENCLR_SLEEPENTER_Pos) /*!< Bit mask of SLEEPENTER field. */ -#define POWER_INTENCLR_SLEEPENTER_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_SLEEPENTER_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_SLEEPENTER_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for POFWARN event */ -#define POWER_INTENCLR_POFWARN_Pos (2UL) /*!< Position of POFWARN field. */ -#define POWER_INTENCLR_POFWARN_Msk (0x1UL << POWER_INTENCLR_POFWARN_Pos) /*!< Bit mask of POFWARN field. */ -#define POWER_INTENCLR_POFWARN_Disabled (0UL) /*!< Read: Disabled */ -#define POWER_INTENCLR_POFWARN_Enabled (1UL) /*!< Read: Enabled */ -#define POWER_INTENCLR_POFWARN_Clear (1UL) /*!< Disable */ - -/* Register: POWER_RESETREAS */ -/* Description: Reset reason */ - -/* Bit 20 : Reset due to wake up from System OFF mode by Vbus rising into valid range */ -#define POWER_RESETREAS_VBUS_Pos (20UL) /*!< Position of VBUS field. */ -#define POWER_RESETREAS_VBUS_Msk (0x1UL << POWER_RESETREAS_VBUS_Pos) /*!< Bit mask of VBUS field. */ -#define POWER_RESETREAS_VBUS_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_VBUS_Detected (1UL) /*!< Detected */ - -/* Bit 19 : Reset due to wake up from System OFF mode by NFC field detect */ -#define POWER_RESETREAS_NFC_Pos (19UL) /*!< Position of NFC field. */ -#define POWER_RESETREAS_NFC_Msk (0x1UL << POWER_RESETREAS_NFC_Pos) /*!< Bit mask of NFC field. */ -#define POWER_RESETREAS_NFC_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_NFC_Detected (1UL) /*!< Detected */ - -/* Bit 18 : Reset due to wake up from System OFF mode when wakeup is triggered from entering into debug interface mode */ -#define POWER_RESETREAS_DIF_Pos (18UL) /*!< Position of DIF field. */ -#define POWER_RESETREAS_DIF_Msk (0x1UL << POWER_RESETREAS_DIF_Pos) /*!< Bit mask of DIF field. */ -#define POWER_RESETREAS_DIF_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_DIF_Detected (1UL) /*!< Detected */ - -/* Bit 17 : Reset due to wake up from System OFF mode when wakeup is triggered from ANADETECT signal from LPCOMP */ -#define POWER_RESETREAS_LPCOMP_Pos (17UL) /*!< Position of LPCOMP field. */ -#define POWER_RESETREAS_LPCOMP_Msk (0x1UL << POWER_RESETREAS_LPCOMP_Pos) /*!< Bit mask of LPCOMP field. */ -#define POWER_RESETREAS_LPCOMP_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_LPCOMP_Detected (1UL) /*!< Detected */ - -/* Bit 16 : Reset due to wake up from System OFF mode when wakeup is triggered from DETECT signal from GPIO */ -#define POWER_RESETREAS_OFF_Pos (16UL) /*!< Position of OFF field. */ -#define POWER_RESETREAS_OFF_Msk (0x1UL << POWER_RESETREAS_OFF_Pos) /*!< Bit mask of OFF field. */ -#define POWER_RESETREAS_OFF_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_OFF_Detected (1UL) /*!< Detected */ - -/* Bit 3 : Reset from CPU lock-up detected */ -#define POWER_RESETREAS_LOCKUP_Pos (3UL) /*!< Position of LOCKUP field. */ -#define POWER_RESETREAS_LOCKUP_Msk (0x1UL << POWER_RESETREAS_LOCKUP_Pos) /*!< Bit mask of LOCKUP field. */ -#define POWER_RESETREAS_LOCKUP_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_LOCKUP_Detected (1UL) /*!< Detected */ - -/* Bit 2 : Reset from soft reset detected */ -#define POWER_RESETREAS_SREQ_Pos (2UL) /*!< Position of SREQ field. */ -#define POWER_RESETREAS_SREQ_Msk (0x1UL << POWER_RESETREAS_SREQ_Pos) /*!< Bit mask of SREQ field. */ -#define POWER_RESETREAS_SREQ_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_SREQ_Detected (1UL) /*!< Detected */ - -/* Bit 1 : Reset from watchdog detected */ -#define POWER_RESETREAS_DOG_Pos (1UL) /*!< Position of DOG field. */ -#define POWER_RESETREAS_DOG_Msk (0x1UL << POWER_RESETREAS_DOG_Pos) /*!< Bit mask of DOG field. */ -#define POWER_RESETREAS_DOG_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_DOG_Detected (1UL) /*!< Detected */ - -/* Bit 0 : Reset from pin-reset detected */ -#define POWER_RESETREAS_RESETPIN_Pos (0UL) /*!< Position of RESETPIN field. */ -#define POWER_RESETREAS_RESETPIN_Msk (0x1UL << POWER_RESETREAS_RESETPIN_Pos) /*!< Bit mask of RESETPIN field. */ -#define POWER_RESETREAS_RESETPIN_NotDetected (0UL) /*!< Not detected */ -#define POWER_RESETREAS_RESETPIN_Detected (1UL) /*!< Detected */ - -/* Register: POWER_RAMSTATUS */ -/* Description: Deprecated register - RAM status register */ - -/* Bit 3 : RAM block 3 is on or off/powering up */ -#define POWER_RAMSTATUS_RAMBLOCK3_Pos (3UL) /*!< Position of RAMBLOCK3 field. */ -#define POWER_RAMSTATUS_RAMBLOCK3_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK3_Pos) /*!< Bit mask of RAMBLOCK3 field. */ -#define POWER_RAMSTATUS_RAMBLOCK3_Off (0UL) /*!< Off */ -#define POWER_RAMSTATUS_RAMBLOCK3_On (1UL) /*!< On */ - -/* Bit 2 : RAM block 2 is on or off/powering up */ -#define POWER_RAMSTATUS_RAMBLOCK2_Pos (2UL) /*!< Position of RAMBLOCK2 field. */ -#define POWER_RAMSTATUS_RAMBLOCK2_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK2_Pos) /*!< Bit mask of RAMBLOCK2 field. */ -#define POWER_RAMSTATUS_RAMBLOCK2_Off (0UL) /*!< Off */ -#define POWER_RAMSTATUS_RAMBLOCK2_On (1UL) /*!< On */ - -/* Bit 1 : RAM block 1 is on or off/powering up */ -#define POWER_RAMSTATUS_RAMBLOCK1_Pos (1UL) /*!< Position of RAMBLOCK1 field. */ -#define POWER_RAMSTATUS_RAMBLOCK1_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK1_Pos) /*!< Bit mask of RAMBLOCK1 field. */ -#define POWER_RAMSTATUS_RAMBLOCK1_Off (0UL) /*!< Off */ -#define POWER_RAMSTATUS_RAMBLOCK1_On (1UL) /*!< On */ - -/* Bit 0 : RAM block 0 is on or off/powering up */ -#define POWER_RAMSTATUS_RAMBLOCK0_Pos (0UL) /*!< Position of RAMBLOCK0 field. */ -#define POWER_RAMSTATUS_RAMBLOCK0_Msk (0x1UL << POWER_RAMSTATUS_RAMBLOCK0_Pos) /*!< Bit mask of RAMBLOCK0 field. */ -#define POWER_RAMSTATUS_RAMBLOCK0_Off (0UL) /*!< Off */ -#define POWER_RAMSTATUS_RAMBLOCK0_On (1UL) /*!< On */ - -/* Register: POWER_USBREGSTATUS */ -/* Description: USB supply status */ - -/* Bit 1 : USB supply output settling time elapsed */ -#define POWER_USBREGSTATUS_OUTPUTRDY_Pos (1UL) /*!< Position of OUTPUTRDY field. */ -#define POWER_USBREGSTATUS_OUTPUTRDY_Msk (0x1UL << POWER_USBREGSTATUS_OUTPUTRDY_Pos) /*!< Bit mask of OUTPUTRDY field. */ -#define POWER_USBREGSTATUS_OUTPUTRDY_NotReady (0UL) /*!< USBREG output settling time not elapsed */ -#define POWER_USBREGSTATUS_OUTPUTRDY_Ready (1UL) /*!< USBREG output settling time elapsed (same information as USBPWRRDY event) */ - -/* Bit 0 : VBUS input detection status (USBDETECTED and USBREMOVED events are derived from this information) */ -#define POWER_USBREGSTATUS_VBUSDETECT_Pos (0UL) /*!< Position of VBUSDETECT field. */ -#define POWER_USBREGSTATUS_VBUSDETECT_Msk (0x1UL << POWER_USBREGSTATUS_VBUSDETECT_Pos) /*!< Bit mask of VBUSDETECT field. */ -#define POWER_USBREGSTATUS_VBUSDETECT_NoVbus (0UL) /*!< VBUS voltage below valid threshold */ -#define POWER_USBREGSTATUS_VBUSDETECT_VbusPresent (1UL) /*!< VBUS voltage above valid threshold */ - -/* Register: POWER_SYSTEMOFF */ -/* Description: System OFF register */ - -/* Bit 0 : Enable System OFF mode */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Pos (0UL) /*!< Position of SYSTEMOFF field. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Msk (0x1UL << POWER_SYSTEMOFF_SYSTEMOFF_Pos) /*!< Bit mask of SYSTEMOFF field. */ -#define POWER_SYSTEMOFF_SYSTEMOFF_Enter (1UL) /*!< Enable System OFF mode */ - -/* Register: POWER_POFCON */ -/* Description: Power failure comparator configuration */ - -/* Bits 11..8 : Power failure comparator threshold setting for high voltage mode (supply connected to VDDH only). This setting does not apply for normal voltage mode (supply connected to both VDD and VDDH). */ -#define POWER_POFCON_THRESHOLDVDDH_Pos (8UL) /*!< Position of THRESHOLDVDDH field. */ -#define POWER_POFCON_THRESHOLDVDDH_Msk (0xFUL << POWER_POFCON_THRESHOLDVDDH_Pos) /*!< Bit mask of THRESHOLDVDDH field. */ -#define POWER_POFCON_THRESHOLDVDDH_V27 (0UL) /*!< Set threshold to 2.7 V */ -#define POWER_POFCON_THRESHOLDVDDH_V28 (1UL) /*!< Set threshold to 2.8 V */ -#define POWER_POFCON_THRESHOLDVDDH_V29 (2UL) /*!< Set threshold to 2.9 V */ -#define POWER_POFCON_THRESHOLDVDDH_V30 (3UL) /*!< Set threshold to 3.0 V */ -#define POWER_POFCON_THRESHOLDVDDH_V31 (4UL) /*!< Set threshold to 3.1 V */ -#define POWER_POFCON_THRESHOLDVDDH_V32 (5UL) /*!< Set threshold to 3.2 V */ -#define POWER_POFCON_THRESHOLDVDDH_V33 (6UL) /*!< Set threshold to 3.3 V */ -#define POWER_POFCON_THRESHOLDVDDH_V34 (7UL) /*!< Set threshold to 3.4 V */ -#define POWER_POFCON_THRESHOLDVDDH_V35 (8UL) /*!< Set threshold to 3.5 V */ -#define POWER_POFCON_THRESHOLDVDDH_V36 (9UL) /*!< Set threshold to 3.6 V */ -#define POWER_POFCON_THRESHOLDVDDH_V37 (10UL) /*!< Set threshold to 3.7 V */ -#define POWER_POFCON_THRESHOLDVDDH_V38 (11UL) /*!< Set threshold to 3.8 V */ -#define POWER_POFCON_THRESHOLDVDDH_V39 (12UL) /*!< Set threshold to 3.9 V */ -#define POWER_POFCON_THRESHOLDVDDH_V40 (13UL) /*!< Set threshold to 4.0 V */ -#define POWER_POFCON_THRESHOLDVDDH_V41 (14UL) /*!< Set threshold to 4.1 V */ -#define POWER_POFCON_THRESHOLDVDDH_V42 (15UL) /*!< Set threshold to 4.2 V */ - -/* Bits 4..1 : Power failure comparator threshold setting. This setting applies both for normal voltage mode (supply connected to both VDD and VDDH) and high voltage mode (supply connected to VDDH only). */ -#define POWER_POFCON_THRESHOLD_Pos (1UL) /*!< Position of THRESHOLD field. */ -#define POWER_POFCON_THRESHOLD_Msk (0xFUL << POWER_POFCON_THRESHOLD_Pos) /*!< Bit mask of THRESHOLD field. */ -#define POWER_POFCON_THRESHOLD_V17 (4UL) /*!< Set threshold to 1.7 V */ -#define POWER_POFCON_THRESHOLD_V18 (5UL) /*!< Set threshold to 1.8 V */ -#define POWER_POFCON_THRESHOLD_V19 (6UL) /*!< Set threshold to 1.9 V */ -#define POWER_POFCON_THRESHOLD_V20 (7UL) /*!< Set threshold to 2.0 V */ -#define POWER_POFCON_THRESHOLD_V21 (8UL) /*!< Set threshold to 2.1 V */ -#define POWER_POFCON_THRESHOLD_V22 (9UL) /*!< Set threshold to 2.2 V */ -#define POWER_POFCON_THRESHOLD_V23 (10UL) /*!< Set threshold to 2.3 V */ -#define POWER_POFCON_THRESHOLD_V24 (11UL) /*!< Set threshold to 2.4 V */ -#define POWER_POFCON_THRESHOLD_V25 (12UL) /*!< Set threshold to 2.5 V */ -#define POWER_POFCON_THRESHOLD_V26 (13UL) /*!< Set threshold to 2.6 V */ -#define POWER_POFCON_THRESHOLD_V27 (14UL) /*!< Set threshold to 2.7 V */ -#define POWER_POFCON_THRESHOLD_V28 (15UL) /*!< Set threshold to 2.8 V */ - -/* Bit 0 : Enable or disable power failure comparator */ -#define POWER_POFCON_POF_Pos (0UL) /*!< Position of POF field. */ -#define POWER_POFCON_POF_Msk (0x1UL << POWER_POFCON_POF_Pos) /*!< Bit mask of POF field. */ -#define POWER_POFCON_POF_Disabled (0UL) /*!< Disable */ -#define POWER_POFCON_POF_Enabled (1UL) /*!< Enable */ - -/* Register: POWER_GPREGRET */ -/* Description: General purpose retention register */ - -/* Bits 7..0 : General purpose retention register */ -#define POWER_GPREGRET_GPREGRET_Pos (0UL) /*!< Position of GPREGRET field. */ -#define POWER_GPREGRET_GPREGRET_Msk (0xFFUL << POWER_GPREGRET_GPREGRET_Pos) /*!< Bit mask of GPREGRET field. */ - -/* Register: POWER_GPREGRET2 */ -/* Description: General purpose retention register */ - -/* Bits 7..0 : General purpose retention register */ -#define POWER_GPREGRET2_GPREGRET_Pos (0UL) /*!< Position of GPREGRET field. */ -#define POWER_GPREGRET2_GPREGRET_Msk (0xFFUL << POWER_GPREGRET2_GPREGRET_Pos) /*!< Bit mask of GPREGRET field. */ - -/* Register: POWER_DCDCEN */ -/* Description: Enable DC/DC converter for REG1 stage. */ - -/* Bit 0 : Enable DC/DC converter for REG1 stage. */ -#define POWER_DCDCEN_DCDCEN_Pos (0UL) /*!< Position of DCDCEN field. */ -#define POWER_DCDCEN_DCDCEN_Msk (0x1UL << POWER_DCDCEN_DCDCEN_Pos) /*!< Bit mask of DCDCEN field. */ -#define POWER_DCDCEN_DCDCEN_Disabled (0UL) /*!< Disable */ -#define POWER_DCDCEN_DCDCEN_Enabled (1UL) /*!< Enable */ - -/* Register: POWER_DCDCEN0 */ -/* Description: Enable DC/DC converter for REG0 stage. */ - -/* Bit 0 : Enable DC/DC converter for REG0 stage. */ -#define POWER_DCDCEN0_DCDCEN_Pos (0UL) /*!< Position of DCDCEN field. */ -#define POWER_DCDCEN0_DCDCEN_Msk (0x1UL << POWER_DCDCEN0_DCDCEN_Pos) /*!< Bit mask of DCDCEN field. */ -#define POWER_DCDCEN0_DCDCEN_Disabled (0UL) /*!< Disable */ -#define POWER_DCDCEN0_DCDCEN_Enabled (1UL) /*!< Enable */ - -/* Register: POWER_MAINREGSTATUS */ -/* Description: Main supply status */ - -/* Bit 0 : Main supply status */ -#define POWER_MAINREGSTATUS_MAINREGSTATUS_Pos (0UL) /*!< Position of MAINREGSTATUS field. */ -#define POWER_MAINREGSTATUS_MAINREGSTATUS_Msk (0x1UL << POWER_MAINREGSTATUS_MAINREGSTATUS_Pos) /*!< Bit mask of MAINREGSTATUS field. */ -#define POWER_MAINREGSTATUS_MAINREGSTATUS_Normal (0UL) /*!< Normal voltage mode. Voltage supplied on VDD. */ -#define POWER_MAINREGSTATUS_MAINREGSTATUS_High (1UL) /*!< High voltage mode. Voltage supplied on VDDH. */ - -/* Register: POWER_RAM_POWER */ -/* Description: Description cluster[0]: RAM0 power control register */ - -/* Bit 31 : Keep retention on RAM section S15 when RAM section is in OFF */ -#define POWER_RAM_POWER_S15RETENTION_Pos (31UL) /*!< Position of S15RETENTION field. */ -#define POWER_RAM_POWER_S15RETENTION_Msk (0x1UL << POWER_RAM_POWER_S15RETENTION_Pos) /*!< Bit mask of S15RETENTION field. */ -#define POWER_RAM_POWER_S15RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S15RETENTION_On (1UL) /*!< On */ - -/* Bit 30 : Keep retention on RAM section S14 when RAM section is in OFF */ -#define POWER_RAM_POWER_S14RETENTION_Pos (30UL) /*!< Position of S14RETENTION field. */ -#define POWER_RAM_POWER_S14RETENTION_Msk (0x1UL << POWER_RAM_POWER_S14RETENTION_Pos) /*!< Bit mask of S14RETENTION field. */ -#define POWER_RAM_POWER_S14RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S14RETENTION_On (1UL) /*!< On */ - -/* Bit 29 : Keep retention on RAM section S13 when RAM section is in OFF */ -#define POWER_RAM_POWER_S13RETENTION_Pos (29UL) /*!< Position of S13RETENTION field. */ -#define POWER_RAM_POWER_S13RETENTION_Msk (0x1UL << POWER_RAM_POWER_S13RETENTION_Pos) /*!< Bit mask of S13RETENTION field. */ -#define POWER_RAM_POWER_S13RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S13RETENTION_On (1UL) /*!< On */ - -/* Bit 28 : Keep retention on RAM section S12 when RAM section is in OFF */ -#define POWER_RAM_POWER_S12RETENTION_Pos (28UL) /*!< Position of S12RETENTION field. */ -#define POWER_RAM_POWER_S12RETENTION_Msk (0x1UL << POWER_RAM_POWER_S12RETENTION_Pos) /*!< Bit mask of S12RETENTION field. */ -#define POWER_RAM_POWER_S12RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S12RETENTION_On (1UL) /*!< On */ - -/* Bit 27 : Keep retention on RAM section S11 when RAM section is in OFF */ -#define POWER_RAM_POWER_S11RETENTION_Pos (27UL) /*!< Position of S11RETENTION field. */ -#define POWER_RAM_POWER_S11RETENTION_Msk (0x1UL << POWER_RAM_POWER_S11RETENTION_Pos) /*!< Bit mask of S11RETENTION field. */ -#define POWER_RAM_POWER_S11RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S11RETENTION_On (1UL) /*!< On */ - -/* Bit 26 : Keep retention on RAM section S10 when RAM section is in OFF */ -#define POWER_RAM_POWER_S10RETENTION_Pos (26UL) /*!< Position of S10RETENTION field. */ -#define POWER_RAM_POWER_S10RETENTION_Msk (0x1UL << POWER_RAM_POWER_S10RETENTION_Pos) /*!< Bit mask of S10RETENTION field. */ -#define POWER_RAM_POWER_S10RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S10RETENTION_On (1UL) /*!< On */ - -/* Bit 25 : Keep retention on RAM section S9 when RAM section is in OFF */ -#define POWER_RAM_POWER_S9RETENTION_Pos (25UL) /*!< Position of S9RETENTION field. */ -#define POWER_RAM_POWER_S9RETENTION_Msk (0x1UL << POWER_RAM_POWER_S9RETENTION_Pos) /*!< Bit mask of S9RETENTION field. */ -#define POWER_RAM_POWER_S9RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S9RETENTION_On (1UL) /*!< On */ - -/* Bit 24 : Keep retention on RAM section S8 when RAM section is in OFF */ -#define POWER_RAM_POWER_S8RETENTION_Pos (24UL) /*!< Position of S8RETENTION field. */ -#define POWER_RAM_POWER_S8RETENTION_Msk (0x1UL << POWER_RAM_POWER_S8RETENTION_Pos) /*!< Bit mask of S8RETENTION field. */ -#define POWER_RAM_POWER_S8RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S8RETENTION_On (1UL) /*!< On */ - -/* Bit 23 : Keep retention on RAM section S7 when RAM section is in OFF */ -#define POWER_RAM_POWER_S7RETENTION_Pos (23UL) /*!< Position of S7RETENTION field. */ -#define POWER_RAM_POWER_S7RETENTION_Msk (0x1UL << POWER_RAM_POWER_S7RETENTION_Pos) /*!< Bit mask of S7RETENTION field. */ -#define POWER_RAM_POWER_S7RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S7RETENTION_On (1UL) /*!< On */ - -/* Bit 22 : Keep retention on RAM section S6 when RAM section is in OFF */ -#define POWER_RAM_POWER_S6RETENTION_Pos (22UL) /*!< Position of S6RETENTION field. */ -#define POWER_RAM_POWER_S6RETENTION_Msk (0x1UL << POWER_RAM_POWER_S6RETENTION_Pos) /*!< Bit mask of S6RETENTION field. */ -#define POWER_RAM_POWER_S6RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S6RETENTION_On (1UL) /*!< On */ - -/* Bit 21 : Keep retention on RAM section S5 when RAM section is in OFF */ -#define POWER_RAM_POWER_S5RETENTION_Pos (21UL) /*!< Position of S5RETENTION field. */ -#define POWER_RAM_POWER_S5RETENTION_Msk (0x1UL << POWER_RAM_POWER_S5RETENTION_Pos) /*!< Bit mask of S5RETENTION field. */ -#define POWER_RAM_POWER_S5RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S5RETENTION_On (1UL) /*!< On */ - -/* Bit 20 : Keep retention on RAM section S4 when RAM section is in OFF */ -#define POWER_RAM_POWER_S4RETENTION_Pos (20UL) /*!< Position of S4RETENTION field. */ -#define POWER_RAM_POWER_S4RETENTION_Msk (0x1UL << POWER_RAM_POWER_S4RETENTION_Pos) /*!< Bit mask of S4RETENTION field. */ -#define POWER_RAM_POWER_S4RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S4RETENTION_On (1UL) /*!< On */ - -/* Bit 19 : Keep retention on RAM section S3 when RAM section is in OFF */ -#define POWER_RAM_POWER_S3RETENTION_Pos (19UL) /*!< Position of S3RETENTION field. */ -#define POWER_RAM_POWER_S3RETENTION_Msk (0x1UL << POWER_RAM_POWER_S3RETENTION_Pos) /*!< Bit mask of S3RETENTION field. */ -#define POWER_RAM_POWER_S3RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S3RETENTION_On (1UL) /*!< On */ - -/* Bit 18 : Keep retention on RAM section S2 when RAM section is in OFF */ -#define POWER_RAM_POWER_S2RETENTION_Pos (18UL) /*!< Position of S2RETENTION field. */ -#define POWER_RAM_POWER_S2RETENTION_Msk (0x1UL << POWER_RAM_POWER_S2RETENTION_Pos) /*!< Bit mask of S2RETENTION field. */ -#define POWER_RAM_POWER_S2RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S2RETENTION_On (1UL) /*!< On */ - -/* Bit 17 : Keep retention on RAM section S1 when RAM section is in OFF */ -#define POWER_RAM_POWER_S1RETENTION_Pos (17UL) /*!< Position of S1RETENTION field. */ -#define POWER_RAM_POWER_S1RETENTION_Msk (0x1UL << POWER_RAM_POWER_S1RETENTION_Pos) /*!< Bit mask of S1RETENTION field. */ -#define POWER_RAM_POWER_S1RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S1RETENTION_On (1UL) /*!< On */ - -/* Bit 16 : Keep retention on RAM section S0 when RAM section is in OFF */ -#define POWER_RAM_POWER_S0RETENTION_Pos (16UL) /*!< Position of S0RETENTION field. */ -#define POWER_RAM_POWER_S0RETENTION_Msk (0x1UL << POWER_RAM_POWER_S0RETENTION_Pos) /*!< Bit mask of S0RETENTION field. */ -#define POWER_RAM_POWER_S0RETENTION_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S0RETENTION_On (1UL) /*!< On */ - -/* Bit 15 : Keep RAM section S15 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S15POWER_Pos (15UL) /*!< Position of S15POWER field. */ -#define POWER_RAM_POWER_S15POWER_Msk (0x1UL << POWER_RAM_POWER_S15POWER_Pos) /*!< Bit mask of S15POWER field. */ -#define POWER_RAM_POWER_S15POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S15POWER_On (1UL) /*!< On */ - -/* Bit 14 : Keep RAM section S14 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S14POWER_Pos (14UL) /*!< Position of S14POWER field. */ -#define POWER_RAM_POWER_S14POWER_Msk (0x1UL << POWER_RAM_POWER_S14POWER_Pos) /*!< Bit mask of S14POWER field. */ -#define POWER_RAM_POWER_S14POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S14POWER_On (1UL) /*!< On */ - -/* Bit 13 : Keep RAM section S13 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S13POWER_Pos (13UL) /*!< Position of S13POWER field. */ -#define POWER_RAM_POWER_S13POWER_Msk (0x1UL << POWER_RAM_POWER_S13POWER_Pos) /*!< Bit mask of S13POWER field. */ -#define POWER_RAM_POWER_S13POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S13POWER_On (1UL) /*!< On */ - -/* Bit 12 : Keep RAM section S12 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S12POWER_Pos (12UL) /*!< Position of S12POWER field. */ -#define POWER_RAM_POWER_S12POWER_Msk (0x1UL << POWER_RAM_POWER_S12POWER_Pos) /*!< Bit mask of S12POWER field. */ -#define POWER_RAM_POWER_S12POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S12POWER_On (1UL) /*!< On */ - -/* Bit 11 : Keep RAM section S11 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S11POWER_Pos (11UL) /*!< Position of S11POWER field. */ -#define POWER_RAM_POWER_S11POWER_Msk (0x1UL << POWER_RAM_POWER_S11POWER_Pos) /*!< Bit mask of S11POWER field. */ -#define POWER_RAM_POWER_S11POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S11POWER_On (1UL) /*!< On */ - -/* Bit 10 : Keep RAM section S10 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S10POWER_Pos (10UL) /*!< Position of S10POWER field. */ -#define POWER_RAM_POWER_S10POWER_Msk (0x1UL << POWER_RAM_POWER_S10POWER_Pos) /*!< Bit mask of S10POWER field. */ -#define POWER_RAM_POWER_S10POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S10POWER_On (1UL) /*!< On */ - -/* Bit 9 : Keep RAM section S9 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S9POWER_Pos (9UL) /*!< Position of S9POWER field. */ -#define POWER_RAM_POWER_S9POWER_Msk (0x1UL << POWER_RAM_POWER_S9POWER_Pos) /*!< Bit mask of S9POWER field. */ -#define POWER_RAM_POWER_S9POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S9POWER_On (1UL) /*!< On */ - -/* Bit 8 : Keep RAM section S8 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S8POWER_Pos (8UL) /*!< Position of S8POWER field. */ -#define POWER_RAM_POWER_S8POWER_Msk (0x1UL << POWER_RAM_POWER_S8POWER_Pos) /*!< Bit mask of S8POWER field. */ -#define POWER_RAM_POWER_S8POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S8POWER_On (1UL) /*!< On */ - -/* Bit 7 : Keep RAM section S7 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S7POWER_Pos (7UL) /*!< Position of S7POWER field. */ -#define POWER_RAM_POWER_S7POWER_Msk (0x1UL << POWER_RAM_POWER_S7POWER_Pos) /*!< Bit mask of S7POWER field. */ -#define POWER_RAM_POWER_S7POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S7POWER_On (1UL) /*!< On */ - -/* Bit 6 : Keep RAM section S6 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S6POWER_Pos (6UL) /*!< Position of S6POWER field. */ -#define POWER_RAM_POWER_S6POWER_Msk (0x1UL << POWER_RAM_POWER_S6POWER_Pos) /*!< Bit mask of S6POWER field. */ -#define POWER_RAM_POWER_S6POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S6POWER_On (1UL) /*!< On */ - -/* Bit 5 : Keep RAM section S5 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S5POWER_Pos (5UL) /*!< Position of S5POWER field. */ -#define POWER_RAM_POWER_S5POWER_Msk (0x1UL << POWER_RAM_POWER_S5POWER_Pos) /*!< Bit mask of S5POWER field. */ -#define POWER_RAM_POWER_S5POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S5POWER_On (1UL) /*!< On */ - -/* Bit 4 : Keep RAM section S4 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S4POWER_Pos (4UL) /*!< Position of S4POWER field. */ -#define POWER_RAM_POWER_S4POWER_Msk (0x1UL << POWER_RAM_POWER_S4POWER_Pos) /*!< Bit mask of S4POWER field. */ -#define POWER_RAM_POWER_S4POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S4POWER_On (1UL) /*!< On */ - -/* Bit 3 : Keep RAM section S3 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S3POWER_Pos (3UL) /*!< Position of S3POWER field. */ -#define POWER_RAM_POWER_S3POWER_Msk (0x1UL << POWER_RAM_POWER_S3POWER_Pos) /*!< Bit mask of S3POWER field. */ -#define POWER_RAM_POWER_S3POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S3POWER_On (1UL) /*!< On */ - -/* Bit 2 : Keep RAM section S2 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S2POWER_Pos (2UL) /*!< Position of S2POWER field. */ -#define POWER_RAM_POWER_S2POWER_Msk (0x1UL << POWER_RAM_POWER_S2POWER_Pos) /*!< Bit mask of S2POWER field. */ -#define POWER_RAM_POWER_S2POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S2POWER_On (1UL) /*!< On */ - -/* Bit 1 : Keep RAM section S1 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S1POWER_Pos (1UL) /*!< Position of S1POWER field. */ -#define POWER_RAM_POWER_S1POWER_Msk (0x1UL << POWER_RAM_POWER_S1POWER_Pos) /*!< Bit mask of S1POWER field. */ -#define POWER_RAM_POWER_S1POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S1POWER_On (1UL) /*!< On */ - -/* Bit 0 : Keep RAM section S0 ON or OFF in System ON mode. */ -#define POWER_RAM_POWER_S0POWER_Pos (0UL) /*!< Position of S0POWER field. */ -#define POWER_RAM_POWER_S0POWER_Msk (0x1UL << POWER_RAM_POWER_S0POWER_Pos) /*!< Bit mask of S0POWER field. */ -#define POWER_RAM_POWER_S0POWER_Off (0UL) /*!< Off */ -#define POWER_RAM_POWER_S0POWER_On (1UL) /*!< On */ - -/* Register: POWER_RAM_POWERSET */ -/* Description: Description cluster[0]: RAM0 power control set register */ - -/* Bit 31 : Keep retention on RAM section S15 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S15RETENTION_Pos (31UL) /*!< Position of S15RETENTION field. */ -#define POWER_RAM_POWERSET_S15RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S15RETENTION_Pos) /*!< Bit mask of S15RETENTION field. */ -#define POWER_RAM_POWERSET_S15RETENTION_On (1UL) /*!< On */ - -/* Bit 30 : Keep retention on RAM section S14 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S14RETENTION_Pos (30UL) /*!< Position of S14RETENTION field. */ -#define POWER_RAM_POWERSET_S14RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S14RETENTION_Pos) /*!< Bit mask of S14RETENTION field. */ -#define POWER_RAM_POWERSET_S14RETENTION_On (1UL) /*!< On */ - -/* Bit 29 : Keep retention on RAM section S13 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S13RETENTION_Pos (29UL) /*!< Position of S13RETENTION field. */ -#define POWER_RAM_POWERSET_S13RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S13RETENTION_Pos) /*!< Bit mask of S13RETENTION field. */ -#define POWER_RAM_POWERSET_S13RETENTION_On (1UL) /*!< On */ - -/* Bit 28 : Keep retention on RAM section S12 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S12RETENTION_Pos (28UL) /*!< Position of S12RETENTION field. */ -#define POWER_RAM_POWERSET_S12RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S12RETENTION_Pos) /*!< Bit mask of S12RETENTION field. */ -#define POWER_RAM_POWERSET_S12RETENTION_On (1UL) /*!< On */ - -/* Bit 27 : Keep retention on RAM section S11 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S11RETENTION_Pos (27UL) /*!< Position of S11RETENTION field. */ -#define POWER_RAM_POWERSET_S11RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S11RETENTION_Pos) /*!< Bit mask of S11RETENTION field. */ -#define POWER_RAM_POWERSET_S11RETENTION_On (1UL) /*!< On */ - -/* Bit 26 : Keep retention on RAM section S10 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S10RETENTION_Pos (26UL) /*!< Position of S10RETENTION field. */ -#define POWER_RAM_POWERSET_S10RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S10RETENTION_Pos) /*!< Bit mask of S10RETENTION field. */ -#define POWER_RAM_POWERSET_S10RETENTION_On (1UL) /*!< On */ - -/* Bit 25 : Keep retention on RAM section S9 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S9RETENTION_Pos (25UL) /*!< Position of S9RETENTION field. */ -#define POWER_RAM_POWERSET_S9RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S9RETENTION_Pos) /*!< Bit mask of S9RETENTION field. */ -#define POWER_RAM_POWERSET_S9RETENTION_On (1UL) /*!< On */ - -/* Bit 24 : Keep retention on RAM section S8 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S8RETENTION_Pos (24UL) /*!< Position of S8RETENTION field. */ -#define POWER_RAM_POWERSET_S8RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S8RETENTION_Pos) /*!< Bit mask of S8RETENTION field. */ -#define POWER_RAM_POWERSET_S8RETENTION_On (1UL) /*!< On */ - -/* Bit 23 : Keep retention on RAM section S7 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S7RETENTION_Pos (23UL) /*!< Position of S7RETENTION field. */ -#define POWER_RAM_POWERSET_S7RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S7RETENTION_Pos) /*!< Bit mask of S7RETENTION field. */ -#define POWER_RAM_POWERSET_S7RETENTION_On (1UL) /*!< On */ - -/* Bit 22 : Keep retention on RAM section S6 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S6RETENTION_Pos (22UL) /*!< Position of S6RETENTION field. */ -#define POWER_RAM_POWERSET_S6RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S6RETENTION_Pos) /*!< Bit mask of S6RETENTION field. */ -#define POWER_RAM_POWERSET_S6RETENTION_On (1UL) /*!< On */ - -/* Bit 21 : Keep retention on RAM section S5 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S5RETENTION_Pos (21UL) /*!< Position of S5RETENTION field. */ -#define POWER_RAM_POWERSET_S5RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S5RETENTION_Pos) /*!< Bit mask of S5RETENTION field. */ -#define POWER_RAM_POWERSET_S5RETENTION_On (1UL) /*!< On */ - -/* Bit 20 : Keep retention on RAM section S4 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S4RETENTION_Pos (20UL) /*!< Position of S4RETENTION field. */ -#define POWER_RAM_POWERSET_S4RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S4RETENTION_Pos) /*!< Bit mask of S4RETENTION field. */ -#define POWER_RAM_POWERSET_S4RETENTION_On (1UL) /*!< On */ - -/* Bit 19 : Keep retention on RAM section S3 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S3RETENTION_Pos (19UL) /*!< Position of S3RETENTION field. */ -#define POWER_RAM_POWERSET_S3RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S3RETENTION_Pos) /*!< Bit mask of S3RETENTION field. */ -#define POWER_RAM_POWERSET_S3RETENTION_On (1UL) /*!< On */ - -/* Bit 18 : Keep retention on RAM section S2 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S2RETENTION_Pos (18UL) /*!< Position of S2RETENTION field. */ -#define POWER_RAM_POWERSET_S2RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S2RETENTION_Pos) /*!< Bit mask of S2RETENTION field. */ -#define POWER_RAM_POWERSET_S2RETENTION_On (1UL) /*!< On */ - -/* Bit 17 : Keep retention on RAM section S1 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S1RETENTION_Pos (17UL) /*!< Position of S1RETENTION field. */ -#define POWER_RAM_POWERSET_S1RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S1RETENTION_Pos) /*!< Bit mask of S1RETENTION field. */ -#define POWER_RAM_POWERSET_S1RETENTION_On (1UL) /*!< On */ - -/* Bit 16 : Keep retention on RAM section S0 when RAM section is switched off */ -#define POWER_RAM_POWERSET_S0RETENTION_Pos (16UL) /*!< Position of S0RETENTION field. */ -#define POWER_RAM_POWERSET_S0RETENTION_Msk (0x1UL << POWER_RAM_POWERSET_S0RETENTION_Pos) /*!< Bit mask of S0RETENTION field. */ -#define POWER_RAM_POWERSET_S0RETENTION_On (1UL) /*!< On */ - -/* Bit 15 : Keep RAM section S15 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S15POWER_Pos (15UL) /*!< Position of S15POWER field. */ -#define POWER_RAM_POWERSET_S15POWER_Msk (0x1UL << POWER_RAM_POWERSET_S15POWER_Pos) /*!< Bit mask of S15POWER field. */ -#define POWER_RAM_POWERSET_S15POWER_On (1UL) /*!< On */ - -/* Bit 14 : Keep RAM section S14 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S14POWER_Pos (14UL) /*!< Position of S14POWER field. */ -#define POWER_RAM_POWERSET_S14POWER_Msk (0x1UL << POWER_RAM_POWERSET_S14POWER_Pos) /*!< Bit mask of S14POWER field. */ -#define POWER_RAM_POWERSET_S14POWER_On (1UL) /*!< On */ - -/* Bit 13 : Keep RAM section S13 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S13POWER_Pos (13UL) /*!< Position of S13POWER field. */ -#define POWER_RAM_POWERSET_S13POWER_Msk (0x1UL << POWER_RAM_POWERSET_S13POWER_Pos) /*!< Bit mask of S13POWER field. */ -#define POWER_RAM_POWERSET_S13POWER_On (1UL) /*!< On */ - -/* Bit 12 : Keep RAM section S12 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S12POWER_Pos (12UL) /*!< Position of S12POWER field. */ -#define POWER_RAM_POWERSET_S12POWER_Msk (0x1UL << POWER_RAM_POWERSET_S12POWER_Pos) /*!< Bit mask of S12POWER field. */ -#define POWER_RAM_POWERSET_S12POWER_On (1UL) /*!< On */ - -/* Bit 11 : Keep RAM section S11 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S11POWER_Pos (11UL) /*!< Position of S11POWER field. */ -#define POWER_RAM_POWERSET_S11POWER_Msk (0x1UL << POWER_RAM_POWERSET_S11POWER_Pos) /*!< Bit mask of S11POWER field. */ -#define POWER_RAM_POWERSET_S11POWER_On (1UL) /*!< On */ - -/* Bit 10 : Keep RAM section S10 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S10POWER_Pos (10UL) /*!< Position of S10POWER field. */ -#define POWER_RAM_POWERSET_S10POWER_Msk (0x1UL << POWER_RAM_POWERSET_S10POWER_Pos) /*!< Bit mask of S10POWER field. */ -#define POWER_RAM_POWERSET_S10POWER_On (1UL) /*!< On */ - -/* Bit 9 : Keep RAM section S9 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S9POWER_Pos (9UL) /*!< Position of S9POWER field. */ -#define POWER_RAM_POWERSET_S9POWER_Msk (0x1UL << POWER_RAM_POWERSET_S9POWER_Pos) /*!< Bit mask of S9POWER field. */ -#define POWER_RAM_POWERSET_S9POWER_On (1UL) /*!< On */ - -/* Bit 8 : Keep RAM section S8 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S8POWER_Pos (8UL) /*!< Position of S8POWER field. */ -#define POWER_RAM_POWERSET_S8POWER_Msk (0x1UL << POWER_RAM_POWERSET_S8POWER_Pos) /*!< Bit mask of S8POWER field. */ -#define POWER_RAM_POWERSET_S8POWER_On (1UL) /*!< On */ - -/* Bit 7 : Keep RAM section S7 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S7POWER_Pos (7UL) /*!< Position of S7POWER field. */ -#define POWER_RAM_POWERSET_S7POWER_Msk (0x1UL << POWER_RAM_POWERSET_S7POWER_Pos) /*!< Bit mask of S7POWER field. */ -#define POWER_RAM_POWERSET_S7POWER_On (1UL) /*!< On */ - -/* Bit 6 : Keep RAM section S6 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S6POWER_Pos (6UL) /*!< Position of S6POWER field. */ -#define POWER_RAM_POWERSET_S6POWER_Msk (0x1UL << POWER_RAM_POWERSET_S6POWER_Pos) /*!< Bit mask of S6POWER field. */ -#define POWER_RAM_POWERSET_S6POWER_On (1UL) /*!< On */ - -/* Bit 5 : Keep RAM section S5 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S5POWER_Pos (5UL) /*!< Position of S5POWER field. */ -#define POWER_RAM_POWERSET_S5POWER_Msk (0x1UL << POWER_RAM_POWERSET_S5POWER_Pos) /*!< Bit mask of S5POWER field. */ -#define POWER_RAM_POWERSET_S5POWER_On (1UL) /*!< On */ - -/* Bit 4 : Keep RAM section S4 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S4POWER_Pos (4UL) /*!< Position of S4POWER field. */ -#define POWER_RAM_POWERSET_S4POWER_Msk (0x1UL << POWER_RAM_POWERSET_S4POWER_Pos) /*!< Bit mask of S4POWER field. */ -#define POWER_RAM_POWERSET_S4POWER_On (1UL) /*!< On */ - -/* Bit 3 : Keep RAM section S3 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S3POWER_Pos (3UL) /*!< Position of S3POWER field. */ -#define POWER_RAM_POWERSET_S3POWER_Msk (0x1UL << POWER_RAM_POWERSET_S3POWER_Pos) /*!< Bit mask of S3POWER field. */ -#define POWER_RAM_POWERSET_S3POWER_On (1UL) /*!< On */ - -/* Bit 2 : Keep RAM section S2 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S2POWER_Pos (2UL) /*!< Position of S2POWER field. */ -#define POWER_RAM_POWERSET_S2POWER_Msk (0x1UL << POWER_RAM_POWERSET_S2POWER_Pos) /*!< Bit mask of S2POWER field. */ -#define POWER_RAM_POWERSET_S2POWER_On (1UL) /*!< On */ - -/* Bit 1 : Keep RAM section S1 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S1POWER_Pos (1UL) /*!< Position of S1POWER field. */ -#define POWER_RAM_POWERSET_S1POWER_Msk (0x1UL << POWER_RAM_POWERSET_S1POWER_Pos) /*!< Bit mask of S1POWER field. */ -#define POWER_RAM_POWERSET_S1POWER_On (1UL) /*!< On */ - -/* Bit 0 : Keep RAM section S0 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERSET_S0POWER_Pos (0UL) /*!< Position of S0POWER field. */ -#define POWER_RAM_POWERSET_S0POWER_Msk (0x1UL << POWER_RAM_POWERSET_S0POWER_Pos) /*!< Bit mask of S0POWER field. */ -#define POWER_RAM_POWERSET_S0POWER_On (1UL) /*!< On */ - -/* Register: POWER_RAM_POWERCLR */ -/* Description: Description cluster[0]: RAM0 power control clear register */ - -/* Bit 31 : Keep retention on RAM section S15 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S15RETENTION_Pos (31UL) /*!< Position of S15RETENTION field. */ -#define POWER_RAM_POWERCLR_S15RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S15RETENTION_Pos) /*!< Bit mask of S15RETENTION field. */ -#define POWER_RAM_POWERCLR_S15RETENTION_Off (1UL) /*!< Off */ - -/* Bit 30 : Keep retention on RAM section S14 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S14RETENTION_Pos (30UL) /*!< Position of S14RETENTION field. */ -#define POWER_RAM_POWERCLR_S14RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S14RETENTION_Pos) /*!< Bit mask of S14RETENTION field. */ -#define POWER_RAM_POWERCLR_S14RETENTION_Off (1UL) /*!< Off */ - -/* Bit 29 : Keep retention on RAM section S13 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S13RETENTION_Pos (29UL) /*!< Position of S13RETENTION field. */ -#define POWER_RAM_POWERCLR_S13RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S13RETENTION_Pos) /*!< Bit mask of S13RETENTION field. */ -#define POWER_RAM_POWERCLR_S13RETENTION_Off (1UL) /*!< Off */ - -/* Bit 28 : Keep retention on RAM section S12 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S12RETENTION_Pos (28UL) /*!< Position of S12RETENTION field. */ -#define POWER_RAM_POWERCLR_S12RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S12RETENTION_Pos) /*!< Bit mask of S12RETENTION field. */ -#define POWER_RAM_POWERCLR_S12RETENTION_Off (1UL) /*!< Off */ - -/* Bit 27 : Keep retention on RAM section S11 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S11RETENTION_Pos (27UL) /*!< Position of S11RETENTION field. */ -#define POWER_RAM_POWERCLR_S11RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S11RETENTION_Pos) /*!< Bit mask of S11RETENTION field. */ -#define POWER_RAM_POWERCLR_S11RETENTION_Off (1UL) /*!< Off */ - -/* Bit 26 : Keep retention on RAM section S10 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S10RETENTION_Pos (26UL) /*!< Position of S10RETENTION field. */ -#define POWER_RAM_POWERCLR_S10RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S10RETENTION_Pos) /*!< Bit mask of S10RETENTION field. */ -#define POWER_RAM_POWERCLR_S10RETENTION_Off (1UL) /*!< Off */ - -/* Bit 25 : Keep retention on RAM section S9 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S9RETENTION_Pos (25UL) /*!< Position of S9RETENTION field. */ -#define POWER_RAM_POWERCLR_S9RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S9RETENTION_Pos) /*!< Bit mask of S9RETENTION field. */ -#define POWER_RAM_POWERCLR_S9RETENTION_Off (1UL) /*!< Off */ - -/* Bit 24 : Keep retention on RAM section S8 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S8RETENTION_Pos (24UL) /*!< Position of S8RETENTION field. */ -#define POWER_RAM_POWERCLR_S8RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S8RETENTION_Pos) /*!< Bit mask of S8RETENTION field. */ -#define POWER_RAM_POWERCLR_S8RETENTION_Off (1UL) /*!< Off */ - -/* Bit 23 : Keep retention on RAM section S7 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S7RETENTION_Pos (23UL) /*!< Position of S7RETENTION field. */ -#define POWER_RAM_POWERCLR_S7RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S7RETENTION_Pos) /*!< Bit mask of S7RETENTION field. */ -#define POWER_RAM_POWERCLR_S7RETENTION_Off (1UL) /*!< Off */ - -/* Bit 22 : Keep retention on RAM section S6 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S6RETENTION_Pos (22UL) /*!< Position of S6RETENTION field. */ -#define POWER_RAM_POWERCLR_S6RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S6RETENTION_Pos) /*!< Bit mask of S6RETENTION field. */ -#define POWER_RAM_POWERCLR_S6RETENTION_Off (1UL) /*!< Off */ - -/* Bit 21 : Keep retention on RAM section S5 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S5RETENTION_Pos (21UL) /*!< Position of S5RETENTION field. */ -#define POWER_RAM_POWERCLR_S5RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S5RETENTION_Pos) /*!< Bit mask of S5RETENTION field. */ -#define POWER_RAM_POWERCLR_S5RETENTION_Off (1UL) /*!< Off */ - -/* Bit 20 : Keep retention on RAM section S4 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S4RETENTION_Pos (20UL) /*!< Position of S4RETENTION field. */ -#define POWER_RAM_POWERCLR_S4RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S4RETENTION_Pos) /*!< Bit mask of S4RETENTION field. */ -#define POWER_RAM_POWERCLR_S4RETENTION_Off (1UL) /*!< Off */ - -/* Bit 19 : Keep retention on RAM section S3 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S3RETENTION_Pos (19UL) /*!< Position of S3RETENTION field. */ -#define POWER_RAM_POWERCLR_S3RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S3RETENTION_Pos) /*!< Bit mask of S3RETENTION field. */ -#define POWER_RAM_POWERCLR_S3RETENTION_Off (1UL) /*!< Off */ - -/* Bit 18 : Keep retention on RAM section S2 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S2RETENTION_Pos (18UL) /*!< Position of S2RETENTION field. */ -#define POWER_RAM_POWERCLR_S2RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S2RETENTION_Pos) /*!< Bit mask of S2RETENTION field. */ -#define POWER_RAM_POWERCLR_S2RETENTION_Off (1UL) /*!< Off */ - -/* Bit 17 : Keep retention on RAM section S1 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S1RETENTION_Pos (17UL) /*!< Position of S1RETENTION field. */ -#define POWER_RAM_POWERCLR_S1RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S1RETENTION_Pos) /*!< Bit mask of S1RETENTION field. */ -#define POWER_RAM_POWERCLR_S1RETENTION_Off (1UL) /*!< Off */ - -/* Bit 16 : Keep retention on RAM section S0 when RAM section is switched off */ -#define POWER_RAM_POWERCLR_S0RETENTION_Pos (16UL) /*!< Position of S0RETENTION field. */ -#define POWER_RAM_POWERCLR_S0RETENTION_Msk (0x1UL << POWER_RAM_POWERCLR_S0RETENTION_Pos) /*!< Bit mask of S0RETENTION field. */ -#define POWER_RAM_POWERCLR_S0RETENTION_Off (1UL) /*!< Off */ - -/* Bit 15 : Keep RAM section S15 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S15POWER_Pos (15UL) /*!< Position of S15POWER field. */ -#define POWER_RAM_POWERCLR_S15POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S15POWER_Pos) /*!< Bit mask of S15POWER field. */ -#define POWER_RAM_POWERCLR_S15POWER_Off (1UL) /*!< Off */ - -/* Bit 14 : Keep RAM section S14 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S14POWER_Pos (14UL) /*!< Position of S14POWER field. */ -#define POWER_RAM_POWERCLR_S14POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S14POWER_Pos) /*!< Bit mask of S14POWER field. */ -#define POWER_RAM_POWERCLR_S14POWER_Off (1UL) /*!< Off */ - -/* Bit 13 : Keep RAM section S13 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S13POWER_Pos (13UL) /*!< Position of S13POWER field. */ -#define POWER_RAM_POWERCLR_S13POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S13POWER_Pos) /*!< Bit mask of S13POWER field. */ -#define POWER_RAM_POWERCLR_S13POWER_Off (1UL) /*!< Off */ - -/* Bit 12 : Keep RAM section S12 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S12POWER_Pos (12UL) /*!< Position of S12POWER field. */ -#define POWER_RAM_POWERCLR_S12POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S12POWER_Pos) /*!< Bit mask of S12POWER field. */ -#define POWER_RAM_POWERCLR_S12POWER_Off (1UL) /*!< Off */ - -/* Bit 11 : Keep RAM section S11 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S11POWER_Pos (11UL) /*!< Position of S11POWER field. */ -#define POWER_RAM_POWERCLR_S11POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S11POWER_Pos) /*!< Bit mask of S11POWER field. */ -#define POWER_RAM_POWERCLR_S11POWER_Off (1UL) /*!< Off */ - -/* Bit 10 : Keep RAM section S10 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S10POWER_Pos (10UL) /*!< Position of S10POWER field. */ -#define POWER_RAM_POWERCLR_S10POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S10POWER_Pos) /*!< Bit mask of S10POWER field. */ -#define POWER_RAM_POWERCLR_S10POWER_Off (1UL) /*!< Off */ - -/* Bit 9 : Keep RAM section S9 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S9POWER_Pos (9UL) /*!< Position of S9POWER field. */ -#define POWER_RAM_POWERCLR_S9POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S9POWER_Pos) /*!< Bit mask of S9POWER field. */ -#define POWER_RAM_POWERCLR_S9POWER_Off (1UL) /*!< Off */ - -/* Bit 8 : Keep RAM section S8 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S8POWER_Pos (8UL) /*!< Position of S8POWER field. */ -#define POWER_RAM_POWERCLR_S8POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S8POWER_Pos) /*!< Bit mask of S8POWER field. */ -#define POWER_RAM_POWERCLR_S8POWER_Off (1UL) /*!< Off */ - -/* Bit 7 : Keep RAM section S7 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S7POWER_Pos (7UL) /*!< Position of S7POWER field. */ -#define POWER_RAM_POWERCLR_S7POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S7POWER_Pos) /*!< Bit mask of S7POWER field. */ -#define POWER_RAM_POWERCLR_S7POWER_Off (1UL) /*!< Off */ - -/* Bit 6 : Keep RAM section S6 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S6POWER_Pos (6UL) /*!< Position of S6POWER field. */ -#define POWER_RAM_POWERCLR_S6POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S6POWER_Pos) /*!< Bit mask of S6POWER field. */ -#define POWER_RAM_POWERCLR_S6POWER_Off (1UL) /*!< Off */ - -/* Bit 5 : Keep RAM section S5 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S5POWER_Pos (5UL) /*!< Position of S5POWER field. */ -#define POWER_RAM_POWERCLR_S5POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S5POWER_Pos) /*!< Bit mask of S5POWER field. */ -#define POWER_RAM_POWERCLR_S5POWER_Off (1UL) /*!< Off */ - -/* Bit 4 : Keep RAM section S4 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S4POWER_Pos (4UL) /*!< Position of S4POWER field. */ -#define POWER_RAM_POWERCLR_S4POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S4POWER_Pos) /*!< Bit mask of S4POWER field. */ -#define POWER_RAM_POWERCLR_S4POWER_Off (1UL) /*!< Off */ - -/* Bit 3 : Keep RAM section S3 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S3POWER_Pos (3UL) /*!< Position of S3POWER field. */ -#define POWER_RAM_POWERCLR_S3POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S3POWER_Pos) /*!< Bit mask of S3POWER field. */ -#define POWER_RAM_POWERCLR_S3POWER_Off (1UL) /*!< Off */ - -/* Bit 2 : Keep RAM section S2 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S2POWER_Pos (2UL) /*!< Position of S2POWER field. */ -#define POWER_RAM_POWERCLR_S2POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S2POWER_Pos) /*!< Bit mask of S2POWER field. */ -#define POWER_RAM_POWERCLR_S2POWER_Off (1UL) /*!< Off */ - -/* Bit 1 : Keep RAM section S1 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S1POWER_Pos (1UL) /*!< Position of S1POWER field. */ -#define POWER_RAM_POWERCLR_S1POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S1POWER_Pos) /*!< Bit mask of S1POWER field. */ -#define POWER_RAM_POWERCLR_S1POWER_Off (1UL) /*!< Off */ - -/* Bit 0 : Keep RAM section S0 of RAM0 on or off in System ON mode */ -#define POWER_RAM_POWERCLR_S0POWER_Pos (0UL) /*!< Position of S0POWER field. */ -#define POWER_RAM_POWERCLR_S0POWER_Msk (0x1UL << POWER_RAM_POWERCLR_S0POWER_Pos) /*!< Bit mask of S0POWER field. */ -#define POWER_RAM_POWERCLR_S0POWER_Off (1UL) /*!< Off */ - - -/* Peripheral: PPI */ -/* Description: Programmable Peripheral Interconnect */ - -/* Register: PPI_CHEN */ -/* Description: Channel enable register */ - -/* Bit 31 : Enable or disable channel 31 */ -#define PPI_CHEN_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHEN_CH31_Msk (0x1UL << PPI_CHEN_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHEN_CH31_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH31_Enabled (1UL) /*!< Enable channel */ - -/* Bit 30 : Enable or disable channel 30 */ -#define PPI_CHEN_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHEN_CH30_Msk (0x1UL << PPI_CHEN_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHEN_CH30_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH30_Enabled (1UL) /*!< Enable channel */ - -/* Bit 29 : Enable or disable channel 29 */ -#define PPI_CHEN_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHEN_CH29_Msk (0x1UL << PPI_CHEN_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHEN_CH29_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH29_Enabled (1UL) /*!< Enable channel */ - -/* Bit 28 : Enable or disable channel 28 */ -#define PPI_CHEN_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHEN_CH28_Msk (0x1UL << PPI_CHEN_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHEN_CH28_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH28_Enabled (1UL) /*!< Enable channel */ - -/* Bit 27 : Enable or disable channel 27 */ -#define PPI_CHEN_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHEN_CH27_Msk (0x1UL << PPI_CHEN_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHEN_CH27_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH27_Enabled (1UL) /*!< Enable channel */ - -/* Bit 26 : Enable or disable channel 26 */ -#define PPI_CHEN_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHEN_CH26_Msk (0x1UL << PPI_CHEN_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHEN_CH26_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH26_Enabled (1UL) /*!< Enable channel */ - -/* Bit 25 : Enable or disable channel 25 */ -#define PPI_CHEN_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHEN_CH25_Msk (0x1UL << PPI_CHEN_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHEN_CH25_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH25_Enabled (1UL) /*!< Enable channel */ - -/* Bit 24 : Enable or disable channel 24 */ -#define PPI_CHEN_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHEN_CH24_Msk (0x1UL << PPI_CHEN_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHEN_CH24_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH24_Enabled (1UL) /*!< Enable channel */ - -/* Bit 23 : Enable or disable channel 23 */ -#define PPI_CHEN_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHEN_CH23_Msk (0x1UL << PPI_CHEN_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHEN_CH23_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH23_Enabled (1UL) /*!< Enable channel */ - -/* Bit 22 : Enable or disable channel 22 */ -#define PPI_CHEN_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHEN_CH22_Msk (0x1UL << PPI_CHEN_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHEN_CH22_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH22_Enabled (1UL) /*!< Enable channel */ - -/* Bit 21 : Enable or disable channel 21 */ -#define PPI_CHEN_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHEN_CH21_Msk (0x1UL << PPI_CHEN_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHEN_CH21_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH21_Enabled (1UL) /*!< Enable channel */ - -/* Bit 20 : Enable or disable channel 20 */ -#define PPI_CHEN_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHEN_CH20_Msk (0x1UL << PPI_CHEN_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHEN_CH20_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH20_Enabled (1UL) /*!< Enable channel */ - -/* Bit 19 : Enable or disable channel 19 */ -#define PPI_CHEN_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHEN_CH19_Msk (0x1UL << PPI_CHEN_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHEN_CH19_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH19_Enabled (1UL) /*!< Enable channel */ - -/* Bit 18 : Enable or disable channel 18 */ -#define PPI_CHEN_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHEN_CH18_Msk (0x1UL << PPI_CHEN_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHEN_CH18_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH18_Enabled (1UL) /*!< Enable channel */ - -/* Bit 17 : Enable or disable channel 17 */ -#define PPI_CHEN_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHEN_CH17_Msk (0x1UL << PPI_CHEN_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHEN_CH17_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH17_Enabled (1UL) /*!< Enable channel */ - -/* Bit 16 : Enable or disable channel 16 */ -#define PPI_CHEN_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHEN_CH16_Msk (0x1UL << PPI_CHEN_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHEN_CH16_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH16_Enabled (1UL) /*!< Enable channel */ - -/* Bit 15 : Enable or disable channel 15 */ -#define PPI_CHEN_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHEN_CH15_Msk (0x1UL << PPI_CHEN_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHEN_CH15_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH15_Enabled (1UL) /*!< Enable channel */ - -/* Bit 14 : Enable or disable channel 14 */ -#define PPI_CHEN_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHEN_CH14_Msk (0x1UL << PPI_CHEN_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHEN_CH14_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH14_Enabled (1UL) /*!< Enable channel */ - -/* Bit 13 : Enable or disable channel 13 */ -#define PPI_CHEN_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHEN_CH13_Msk (0x1UL << PPI_CHEN_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHEN_CH13_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH13_Enabled (1UL) /*!< Enable channel */ - -/* Bit 12 : Enable or disable channel 12 */ -#define PPI_CHEN_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHEN_CH12_Msk (0x1UL << PPI_CHEN_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHEN_CH12_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH12_Enabled (1UL) /*!< Enable channel */ - -/* Bit 11 : Enable or disable channel 11 */ -#define PPI_CHEN_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHEN_CH11_Msk (0x1UL << PPI_CHEN_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHEN_CH11_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH11_Enabled (1UL) /*!< Enable channel */ - -/* Bit 10 : Enable or disable channel 10 */ -#define PPI_CHEN_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHEN_CH10_Msk (0x1UL << PPI_CHEN_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHEN_CH10_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH10_Enabled (1UL) /*!< Enable channel */ - -/* Bit 9 : Enable or disable channel 9 */ -#define PPI_CHEN_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHEN_CH9_Msk (0x1UL << PPI_CHEN_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHEN_CH9_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH9_Enabled (1UL) /*!< Enable channel */ - -/* Bit 8 : Enable or disable channel 8 */ -#define PPI_CHEN_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHEN_CH8_Msk (0x1UL << PPI_CHEN_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHEN_CH8_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH8_Enabled (1UL) /*!< Enable channel */ - -/* Bit 7 : Enable or disable channel 7 */ -#define PPI_CHEN_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHEN_CH7_Msk (0x1UL << PPI_CHEN_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHEN_CH7_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH7_Enabled (1UL) /*!< Enable channel */ - -/* Bit 6 : Enable or disable channel 6 */ -#define PPI_CHEN_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHEN_CH6_Msk (0x1UL << PPI_CHEN_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHEN_CH6_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH6_Enabled (1UL) /*!< Enable channel */ - -/* Bit 5 : Enable or disable channel 5 */ -#define PPI_CHEN_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHEN_CH5_Msk (0x1UL << PPI_CHEN_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHEN_CH5_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH5_Enabled (1UL) /*!< Enable channel */ - -/* Bit 4 : Enable or disable channel 4 */ -#define PPI_CHEN_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHEN_CH4_Msk (0x1UL << PPI_CHEN_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHEN_CH4_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH4_Enabled (1UL) /*!< Enable channel */ - -/* Bit 3 : Enable or disable channel 3 */ -#define PPI_CHEN_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHEN_CH3_Msk (0x1UL << PPI_CHEN_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHEN_CH3_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH3_Enabled (1UL) /*!< Enable channel */ - -/* Bit 2 : Enable or disable channel 2 */ -#define PPI_CHEN_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHEN_CH2_Msk (0x1UL << PPI_CHEN_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHEN_CH2_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH2_Enabled (1UL) /*!< Enable channel */ - -/* Bit 1 : Enable or disable channel 1 */ -#define PPI_CHEN_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHEN_CH1_Msk (0x1UL << PPI_CHEN_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHEN_CH1_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH1_Enabled (1UL) /*!< Enable channel */ - -/* Bit 0 : Enable or disable channel 0 */ -#define PPI_CHEN_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHEN_CH0_Msk (0x1UL << PPI_CHEN_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHEN_CH0_Disabled (0UL) /*!< Disable channel */ -#define PPI_CHEN_CH0_Enabled (1UL) /*!< Enable channel */ - -/* Register: PPI_CHENSET */ -/* Description: Channel enable set register */ - -/* Bit 31 : Channel 31 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHENSET_CH31_Msk (0x1UL << PPI_CHENSET_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHENSET_CH31_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH31_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH31_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 30 : Channel 30 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHENSET_CH30_Msk (0x1UL << PPI_CHENSET_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHENSET_CH30_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH30_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH30_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 29 : Channel 29 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHENSET_CH29_Msk (0x1UL << PPI_CHENSET_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHENSET_CH29_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH29_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH29_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 28 : Channel 28 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHENSET_CH28_Msk (0x1UL << PPI_CHENSET_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHENSET_CH28_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH28_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH28_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 27 : Channel 27 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHENSET_CH27_Msk (0x1UL << PPI_CHENSET_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHENSET_CH27_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH27_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH27_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 26 : Channel 26 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHENSET_CH26_Msk (0x1UL << PPI_CHENSET_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHENSET_CH26_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH26_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH26_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 25 : Channel 25 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHENSET_CH25_Msk (0x1UL << PPI_CHENSET_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHENSET_CH25_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH25_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH25_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 24 : Channel 24 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHENSET_CH24_Msk (0x1UL << PPI_CHENSET_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHENSET_CH24_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH24_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH24_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 23 : Channel 23 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHENSET_CH23_Msk (0x1UL << PPI_CHENSET_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHENSET_CH23_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH23_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH23_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 22 : Channel 22 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHENSET_CH22_Msk (0x1UL << PPI_CHENSET_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHENSET_CH22_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH22_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH22_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 21 : Channel 21 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHENSET_CH21_Msk (0x1UL << PPI_CHENSET_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHENSET_CH21_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH21_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH21_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 20 : Channel 20 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHENSET_CH20_Msk (0x1UL << PPI_CHENSET_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHENSET_CH20_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH20_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH20_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 19 : Channel 19 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHENSET_CH19_Msk (0x1UL << PPI_CHENSET_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHENSET_CH19_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH19_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH19_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 18 : Channel 18 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHENSET_CH18_Msk (0x1UL << PPI_CHENSET_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHENSET_CH18_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH18_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH18_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 17 : Channel 17 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHENSET_CH17_Msk (0x1UL << PPI_CHENSET_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHENSET_CH17_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH17_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH17_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 16 : Channel 16 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHENSET_CH16_Msk (0x1UL << PPI_CHENSET_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHENSET_CH16_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH16_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH16_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 15 : Channel 15 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHENSET_CH15_Msk (0x1UL << PPI_CHENSET_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHENSET_CH15_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH15_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH15_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 14 : Channel 14 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHENSET_CH14_Msk (0x1UL << PPI_CHENSET_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHENSET_CH14_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH14_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH14_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 13 : Channel 13 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHENSET_CH13_Msk (0x1UL << PPI_CHENSET_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHENSET_CH13_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH13_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH13_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 12 : Channel 12 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHENSET_CH12_Msk (0x1UL << PPI_CHENSET_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHENSET_CH12_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH12_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH12_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 11 : Channel 11 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHENSET_CH11_Msk (0x1UL << PPI_CHENSET_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHENSET_CH11_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH11_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH11_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 10 : Channel 10 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHENSET_CH10_Msk (0x1UL << PPI_CHENSET_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHENSET_CH10_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH10_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH10_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 9 : Channel 9 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHENSET_CH9_Msk (0x1UL << PPI_CHENSET_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHENSET_CH9_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH9_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH9_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 8 : Channel 8 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHENSET_CH8_Msk (0x1UL << PPI_CHENSET_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHENSET_CH8_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH8_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH8_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 7 : Channel 7 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHENSET_CH7_Msk (0x1UL << PPI_CHENSET_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHENSET_CH7_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH7_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH7_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 6 : Channel 6 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHENSET_CH6_Msk (0x1UL << PPI_CHENSET_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHENSET_CH6_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH6_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH6_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 5 : Channel 5 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHENSET_CH5_Msk (0x1UL << PPI_CHENSET_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHENSET_CH5_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH5_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH5_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 4 : Channel 4 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHENSET_CH4_Msk (0x1UL << PPI_CHENSET_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHENSET_CH4_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH4_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH4_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 3 : Channel 3 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHENSET_CH3_Msk (0x1UL << PPI_CHENSET_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHENSET_CH3_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH3_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH3_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 2 : Channel 2 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHENSET_CH2_Msk (0x1UL << PPI_CHENSET_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHENSET_CH2_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH2_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH2_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 1 : Channel 1 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHENSET_CH1_Msk (0x1UL << PPI_CHENSET_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHENSET_CH1_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH1_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH1_Set (1UL) /*!< Write: Enable channel */ - -/* Bit 0 : Channel 0 enable set register. Writing '0' has no effect */ -#define PPI_CHENSET_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHENSET_CH0_Msk (0x1UL << PPI_CHENSET_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHENSET_CH0_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENSET_CH0_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENSET_CH0_Set (1UL) /*!< Write: Enable channel */ - -/* Register: PPI_CHENCLR */ -/* Description: Channel enable clear register */ - -/* Bit 31 : Channel 31 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHENCLR_CH31_Msk (0x1UL << PPI_CHENCLR_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHENCLR_CH31_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH31_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH31_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 30 : Channel 30 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHENCLR_CH30_Msk (0x1UL << PPI_CHENCLR_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHENCLR_CH30_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH30_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH30_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 29 : Channel 29 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHENCLR_CH29_Msk (0x1UL << PPI_CHENCLR_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHENCLR_CH29_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH29_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH29_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 28 : Channel 28 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHENCLR_CH28_Msk (0x1UL << PPI_CHENCLR_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHENCLR_CH28_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH28_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH28_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 27 : Channel 27 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHENCLR_CH27_Msk (0x1UL << PPI_CHENCLR_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHENCLR_CH27_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH27_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH27_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 26 : Channel 26 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHENCLR_CH26_Msk (0x1UL << PPI_CHENCLR_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHENCLR_CH26_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH26_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH26_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 25 : Channel 25 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHENCLR_CH25_Msk (0x1UL << PPI_CHENCLR_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHENCLR_CH25_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH25_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH25_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 24 : Channel 24 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHENCLR_CH24_Msk (0x1UL << PPI_CHENCLR_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHENCLR_CH24_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH24_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH24_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 23 : Channel 23 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHENCLR_CH23_Msk (0x1UL << PPI_CHENCLR_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHENCLR_CH23_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH23_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH23_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 22 : Channel 22 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHENCLR_CH22_Msk (0x1UL << PPI_CHENCLR_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHENCLR_CH22_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH22_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH22_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 21 : Channel 21 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHENCLR_CH21_Msk (0x1UL << PPI_CHENCLR_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHENCLR_CH21_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH21_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH21_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 20 : Channel 20 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHENCLR_CH20_Msk (0x1UL << PPI_CHENCLR_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHENCLR_CH20_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH20_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH20_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 19 : Channel 19 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHENCLR_CH19_Msk (0x1UL << PPI_CHENCLR_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHENCLR_CH19_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH19_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH19_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 18 : Channel 18 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHENCLR_CH18_Msk (0x1UL << PPI_CHENCLR_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHENCLR_CH18_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH18_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH18_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 17 : Channel 17 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHENCLR_CH17_Msk (0x1UL << PPI_CHENCLR_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHENCLR_CH17_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH17_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH17_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 16 : Channel 16 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHENCLR_CH16_Msk (0x1UL << PPI_CHENCLR_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHENCLR_CH16_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH16_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH16_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 15 : Channel 15 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHENCLR_CH15_Msk (0x1UL << PPI_CHENCLR_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHENCLR_CH15_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH15_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH15_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 14 : Channel 14 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHENCLR_CH14_Msk (0x1UL << PPI_CHENCLR_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHENCLR_CH14_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH14_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH14_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 13 : Channel 13 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHENCLR_CH13_Msk (0x1UL << PPI_CHENCLR_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHENCLR_CH13_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH13_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH13_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 12 : Channel 12 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHENCLR_CH12_Msk (0x1UL << PPI_CHENCLR_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHENCLR_CH12_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH12_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH12_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 11 : Channel 11 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHENCLR_CH11_Msk (0x1UL << PPI_CHENCLR_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHENCLR_CH11_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH11_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH11_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 10 : Channel 10 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHENCLR_CH10_Msk (0x1UL << PPI_CHENCLR_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHENCLR_CH10_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH10_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH10_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 9 : Channel 9 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHENCLR_CH9_Msk (0x1UL << PPI_CHENCLR_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHENCLR_CH9_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH9_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH9_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 8 : Channel 8 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHENCLR_CH8_Msk (0x1UL << PPI_CHENCLR_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHENCLR_CH8_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH8_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH8_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 7 : Channel 7 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHENCLR_CH7_Msk (0x1UL << PPI_CHENCLR_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHENCLR_CH7_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH7_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH7_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 6 : Channel 6 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHENCLR_CH6_Msk (0x1UL << PPI_CHENCLR_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHENCLR_CH6_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH6_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH6_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 5 : Channel 5 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHENCLR_CH5_Msk (0x1UL << PPI_CHENCLR_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHENCLR_CH5_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH5_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH5_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 4 : Channel 4 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHENCLR_CH4_Msk (0x1UL << PPI_CHENCLR_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHENCLR_CH4_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH4_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH4_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 3 : Channel 3 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHENCLR_CH3_Msk (0x1UL << PPI_CHENCLR_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHENCLR_CH3_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH3_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH3_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 2 : Channel 2 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHENCLR_CH2_Msk (0x1UL << PPI_CHENCLR_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHENCLR_CH2_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH2_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH2_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 1 : Channel 1 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHENCLR_CH1_Msk (0x1UL << PPI_CHENCLR_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHENCLR_CH1_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH1_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH1_Clear (1UL) /*!< Write: disable channel */ - -/* Bit 0 : Channel 0 enable clear register. Writing '0' has no effect */ -#define PPI_CHENCLR_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHENCLR_CH0_Msk (0x1UL << PPI_CHENCLR_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHENCLR_CH0_Disabled (0UL) /*!< Read: channel disabled */ -#define PPI_CHENCLR_CH0_Enabled (1UL) /*!< Read: channel enabled */ -#define PPI_CHENCLR_CH0_Clear (1UL) /*!< Write: disable channel */ - -/* Register: PPI_CH_EEP */ -/* Description: Description cluster[0]: Channel 0 event end-point */ - -/* Bits 31..0 : Pointer to event register. Accepts only addresses to registers from the Event group. */ -#define PPI_CH_EEP_EEP_Pos (0UL) /*!< Position of EEP field. */ -#define PPI_CH_EEP_EEP_Msk (0xFFFFFFFFUL << PPI_CH_EEP_EEP_Pos) /*!< Bit mask of EEP field. */ - -/* Register: PPI_CH_TEP */ -/* Description: Description cluster[0]: Channel 0 task end-point */ - -/* Bits 31..0 : Pointer to task register. Accepts only addresses to registers from the Task group. */ -#define PPI_CH_TEP_TEP_Pos (0UL) /*!< Position of TEP field. */ -#define PPI_CH_TEP_TEP_Msk (0xFFFFFFFFUL << PPI_CH_TEP_TEP_Pos) /*!< Bit mask of TEP field. */ - -/* Register: PPI_CHG */ -/* Description: Description collection[0]: Channel group 0 */ - -/* Bit 31 : Include or exclude channel 31 */ -#define PPI_CHG_CH31_Pos (31UL) /*!< Position of CH31 field. */ -#define PPI_CHG_CH31_Msk (0x1UL << PPI_CHG_CH31_Pos) /*!< Bit mask of CH31 field. */ -#define PPI_CHG_CH31_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH31_Included (1UL) /*!< Include */ - -/* Bit 30 : Include or exclude channel 30 */ -#define PPI_CHG_CH30_Pos (30UL) /*!< Position of CH30 field. */ -#define PPI_CHG_CH30_Msk (0x1UL << PPI_CHG_CH30_Pos) /*!< Bit mask of CH30 field. */ -#define PPI_CHG_CH30_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH30_Included (1UL) /*!< Include */ - -/* Bit 29 : Include or exclude channel 29 */ -#define PPI_CHG_CH29_Pos (29UL) /*!< Position of CH29 field. */ -#define PPI_CHG_CH29_Msk (0x1UL << PPI_CHG_CH29_Pos) /*!< Bit mask of CH29 field. */ -#define PPI_CHG_CH29_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH29_Included (1UL) /*!< Include */ - -/* Bit 28 : Include or exclude channel 28 */ -#define PPI_CHG_CH28_Pos (28UL) /*!< Position of CH28 field. */ -#define PPI_CHG_CH28_Msk (0x1UL << PPI_CHG_CH28_Pos) /*!< Bit mask of CH28 field. */ -#define PPI_CHG_CH28_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH28_Included (1UL) /*!< Include */ - -/* Bit 27 : Include or exclude channel 27 */ -#define PPI_CHG_CH27_Pos (27UL) /*!< Position of CH27 field. */ -#define PPI_CHG_CH27_Msk (0x1UL << PPI_CHG_CH27_Pos) /*!< Bit mask of CH27 field. */ -#define PPI_CHG_CH27_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH27_Included (1UL) /*!< Include */ - -/* Bit 26 : Include or exclude channel 26 */ -#define PPI_CHG_CH26_Pos (26UL) /*!< Position of CH26 field. */ -#define PPI_CHG_CH26_Msk (0x1UL << PPI_CHG_CH26_Pos) /*!< Bit mask of CH26 field. */ -#define PPI_CHG_CH26_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH26_Included (1UL) /*!< Include */ - -/* Bit 25 : Include or exclude channel 25 */ -#define PPI_CHG_CH25_Pos (25UL) /*!< Position of CH25 field. */ -#define PPI_CHG_CH25_Msk (0x1UL << PPI_CHG_CH25_Pos) /*!< Bit mask of CH25 field. */ -#define PPI_CHG_CH25_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH25_Included (1UL) /*!< Include */ - -/* Bit 24 : Include or exclude channel 24 */ -#define PPI_CHG_CH24_Pos (24UL) /*!< Position of CH24 field. */ -#define PPI_CHG_CH24_Msk (0x1UL << PPI_CHG_CH24_Pos) /*!< Bit mask of CH24 field. */ -#define PPI_CHG_CH24_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH24_Included (1UL) /*!< Include */ - -/* Bit 23 : Include or exclude channel 23 */ -#define PPI_CHG_CH23_Pos (23UL) /*!< Position of CH23 field. */ -#define PPI_CHG_CH23_Msk (0x1UL << PPI_CHG_CH23_Pos) /*!< Bit mask of CH23 field. */ -#define PPI_CHG_CH23_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH23_Included (1UL) /*!< Include */ - -/* Bit 22 : Include or exclude channel 22 */ -#define PPI_CHG_CH22_Pos (22UL) /*!< Position of CH22 field. */ -#define PPI_CHG_CH22_Msk (0x1UL << PPI_CHG_CH22_Pos) /*!< Bit mask of CH22 field. */ -#define PPI_CHG_CH22_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH22_Included (1UL) /*!< Include */ - -/* Bit 21 : Include or exclude channel 21 */ -#define PPI_CHG_CH21_Pos (21UL) /*!< Position of CH21 field. */ -#define PPI_CHG_CH21_Msk (0x1UL << PPI_CHG_CH21_Pos) /*!< Bit mask of CH21 field. */ -#define PPI_CHG_CH21_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH21_Included (1UL) /*!< Include */ - -/* Bit 20 : Include or exclude channel 20 */ -#define PPI_CHG_CH20_Pos (20UL) /*!< Position of CH20 field. */ -#define PPI_CHG_CH20_Msk (0x1UL << PPI_CHG_CH20_Pos) /*!< Bit mask of CH20 field. */ -#define PPI_CHG_CH20_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH20_Included (1UL) /*!< Include */ - -/* Bit 19 : Include or exclude channel 19 */ -#define PPI_CHG_CH19_Pos (19UL) /*!< Position of CH19 field. */ -#define PPI_CHG_CH19_Msk (0x1UL << PPI_CHG_CH19_Pos) /*!< Bit mask of CH19 field. */ -#define PPI_CHG_CH19_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH19_Included (1UL) /*!< Include */ - -/* Bit 18 : Include or exclude channel 18 */ -#define PPI_CHG_CH18_Pos (18UL) /*!< Position of CH18 field. */ -#define PPI_CHG_CH18_Msk (0x1UL << PPI_CHG_CH18_Pos) /*!< Bit mask of CH18 field. */ -#define PPI_CHG_CH18_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH18_Included (1UL) /*!< Include */ - -/* Bit 17 : Include or exclude channel 17 */ -#define PPI_CHG_CH17_Pos (17UL) /*!< Position of CH17 field. */ -#define PPI_CHG_CH17_Msk (0x1UL << PPI_CHG_CH17_Pos) /*!< Bit mask of CH17 field. */ -#define PPI_CHG_CH17_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH17_Included (1UL) /*!< Include */ - -/* Bit 16 : Include or exclude channel 16 */ -#define PPI_CHG_CH16_Pos (16UL) /*!< Position of CH16 field. */ -#define PPI_CHG_CH16_Msk (0x1UL << PPI_CHG_CH16_Pos) /*!< Bit mask of CH16 field. */ -#define PPI_CHG_CH16_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH16_Included (1UL) /*!< Include */ - -/* Bit 15 : Include or exclude channel 15 */ -#define PPI_CHG_CH15_Pos (15UL) /*!< Position of CH15 field. */ -#define PPI_CHG_CH15_Msk (0x1UL << PPI_CHG_CH15_Pos) /*!< Bit mask of CH15 field. */ -#define PPI_CHG_CH15_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH15_Included (1UL) /*!< Include */ - -/* Bit 14 : Include or exclude channel 14 */ -#define PPI_CHG_CH14_Pos (14UL) /*!< Position of CH14 field. */ -#define PPI_CHG_CH14_Msk (0x1UL << PPI_CHG_CH14_Pos) /*!< Bit mask of CH14 field. */ -#define PPI_CHG_CH14_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH14_Included (1UL) /*!< Include */ - -/* Bit 13 : Include or exclude channel 13 */ -#define PPI_CHG_CH13_Pos (13UL) /*!< Position of CH13 field. */ -#define PPI_CHG_CH13_Msk (0x1UL << PPI_CHG_CH13_Pos) /*!< Bit mask of CH13 field. */ -#define PPI_CHG_CH13_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH13_Included (1UL) /*!< Include */ - -/* Bit 12 : Include or exclude channel 12 */ -#define PPI_CHG_CH12_Pos (12UL) /*!< Position of CH12 field. */ -#define PPI_CHG_CH12_Msk (0x1UL << PPI_CHG_CH12_Pos) /*!< Bit mask of CH12 field. */ -#define PPI_CHG_CH12_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH12_Included (1UL) /*!< Include */ - -/* Bit 11 : Include or exclude channel 11 */ -#define PPI_CHG_CH11_Pos (11UL) /*!< Position of CH11 field. */ -#define PPI_CHG_CH11_Msk (0x1UL << PPI_CHG_CH11_Pos) /*!< Bit mask of CH11 field. */ -#define PPI_CHG_CH11_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH11_Included (1UL) /*!< Include */ - -/* Bit 10 : Include or exclude channel 10 */ -#define PPI_CHG_CH10_Pos (10UL) /*!< Position of CH10 field. */ -#define PPI_CHG_CH10_Msk (0x1UL << PPI_CHG_CH10_Pos) /*!< Bit mask of CH10 field. */ -#define PPI_CHG_CH10_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH10_Included (1UL) /*!< Include */ - -/* Bit 9 : Include or exclude channel 9 */ -#define PPI_CHG_CH9_Pos (9UL) /*!< Position of CH9 field. */ -#define PPI_CHG_CH9_Msk (0x1UL << PPI_CHG_CH9_Pos) /*!< Bit mask of CH9 field. */ -#define PPI_CHG_CH9_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH9_Included (1UL) /*!< Include */ - -/* Bit 8 : Include or exclude channel 8 */ -#define PPI_CHG_CH8_Pos (8UL) /*!< Position of CH8 field. */ -#define PPI_CHG_CH8_Msk (0x1UL << PPI_CHG_CH8_Pos) /*!< Bit mask of CH8 field. */ -#define PPI_CHG_CH8_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH8_Included (1UL) /*!< Include */ - -/* Bit 7 : Include or exclude channel 7 */ -#define PPI_CHG_CH7_Pos (7UL) /*!< Position of CH7 field. */ -#define PPI_CHG_CH7_Msk (0x1UL << PPI_CHG_CH7_Pos) /*!< Bit mask of CH7 field. */ -#define PPI_CHG_CH7_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH7_Included (1UL) /*!< Include */ - -/* Bit 6 : Include or exclude channel 6 */ -#define PPI_CHG_CH6_Pos (6UL) /*!< Position of CH6 field. */ -#define PPI_CHG_CH6_Msk (0x1UL << PPI_CHG_CH6_Pos) /*!< Bit mask of CH6 field. */ -#define PPI_CHG_CH6_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH6_Included (1UL) /*!< Include */ - -/* Bit 5 : Include or exclude channel 5 */ -#define PPI_CHG_CH5_Pos (5UL) /*!< Position of CH5 field. */ -#define PPI_CHG_CH5_Msk (0x1UL << PPI_CHG_CH5_Pos) /*!< Bit mask of CH5 field. */ -#define PPI_CHG_CH5_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH5_Included (1UL) /*!< Include */ - -/* Bit 4 : Include or exclude channel 4 */ -#define PPI_CHG_CH4_Pos (4UL) /*!< Position of CH4 field. */ -#define PPI_CHG_CH4_Msk (0x1UL << PPI_CHG_CH4_Pos) /*!< Bit mask of CH4 field. */ -#define PPI_CHG_CH4_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH4_Included (1UL) /*!< Include */ - -/* Bit 3 : Include or exclude channel 3 */ -#define PPI_CHG_CH3_Pos (3UL) /*!< Position of CH3 field. */ -#define PPI_CHG_CH3_Msk (0x1UL << PPI_CHG_CH3_Pos) /*!< Bit mask of CH3 field. */ -#define PPI_CHG_CH3_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH3_Included (1UL) /*!< Include */ - -/* Bit 2 : Include or exclude channel 2 */ -#define PPI_CHG_CH2_Pos (2UL) /*!< Position of CH2 field. */ -#define PPI_CHG_CH2_Msk (0x1UL << PPI_CHG_CH2_Pos) /*!< Bit mask of CH2 field. */ -#define PPI_CHG_CH2_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH2_Included (1UL) /*!< Include */ - -/* Bit 1 : Include or exclude channel 1 */ -#define PPI_CHG_CH1_Pos (1UL) /*!< Position of CH1 field. */ -#define PPI_CHG_CH1_Msk (0x1UL << PPI_CHG_CH1_Pos) /*!< Bit mask of CH1 field. */ -#define PPI_CHG_CH1_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH1_Included (1UL) /*!< Include */ - -/* Bit 0 : Include or exclude channel 0 */ -#define PPI_CHG_CH0_Pos (0UL) /*!< Position of CH0 field. */ -#define PPI_CHG_CH0_Msk (0x1UL << PPI_CHG_CH0_Pos) /*!< Bit mask of CH0 field. */ -#define PPI_CHG_CH0_Excluded (0UL) /*!< Exclude */ -#define PPI_CHG_CH0_Included (1UL) /*!< Include */ - -/* Register: PPI_FORK_TEP */ -/* Description: Description cluster[0]: Channel 0 task end-point */ - -/* Bits 31..0 : Pointer to task register */ -#define PPI_FORK_TEP_TEP_Pos (0UL) /*!< Position of TEP field. */ -#define PPI_FORK_TEP_TEP_Msk (0xFFFFFFFFUL << PPI_FORK_TEP_TEP_Pos) /*!< Bit mask of TEP field. */ - - -/* Peripheral: PWM */ -/* Description: Pulse Width Modulation Unit 0 */ - -/* Register: PWM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between LOOPSDONE event and STOP task */ -#define PWM_SHORTS_LOOPSDONE_STOP_Pos (4UL) /*!< Position of LOOPSDONE_STOP field. */ -#define PWM_SHORTS_LOOPSDONE_STOP_Msk (0x1UL << PWM_SHORTS_LOOPSDONE_STOP_Pos) /*!< Bit mask of LOOPSDONE_STOP field. */ -#define PWM_SHORTS_LOOPSDONE_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_LOOPSDONE_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between LOOPSDONE event and SEQSTART[1] task */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Pos (3UL) /*!< Position of LOOPSDONE_SEQSTART1 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Msk (0x1UL << PWM_SHORTS_LOOPSDONE_SEQSTART1_Pos) /*!< Bit mask of LOOPSDONE_SEQSTART1 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART1_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between LOOPSDONE event and SEQSTART[0] task */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Pos (2UL) /*!< Position of LOOPSDONE_SEQSTART0 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Msk (0x1UL << PWM_SHORTS_LOOPSDONE_SEQSTART0_Pos) /*!< Bit mask of LOOPSDONE_SEQSTART0 field. */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_LOOPSDONE_SEQSTART0_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between SEQEND[1] event and STOP task */ -#define PWM_SHORTS_SEQEND1_STOP_Pos (1UL) /*!< Position of SEQEND1_STOP field. */ -#define PWM_SHORTS_SEQEND1_STOP_Msk (0x1UL << PWM_SHORTS_SEQEND1_STOP_Pos) /*!< Bit mask of SEQEND1_STOP field. */ -#define PWM_SHORTS_SEQEND1_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_SEQEND1_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between SEQEND[0] event and STOP task */ -#define PWM_SHORTS_SEQEND0_STOP_Pos (0UL) /*!< Position of SEQEND0_STOP field. */ -#define PWM_SHORTS_SEQEND0_STOP_Msk (0x1UL << PWM_SHORTS_SEQEND0_STOP_Pos) /*!< Bit mask of SEQEND0_STOP field. */ -#define PWM_SHORTS_SEQEND0_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define PWM_SHORTS_SEQEND0_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: PWM_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 7 : Enable or disable interrupt for LOOPSDONE event */ -#define PWM_INTEN_LOOPSDONE_Pos (7UL) /*!< Position of LOOPSDONE field. */ -#define PWM_INTEN_LOOPSDONE_Msk (0x1UL << PWM_INTEN_LOOPSDONE_Pos) /*!< Bit mask of LOOPSDONE field. */ -#define PWM_INTEN_LOOPSDONE_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_LOOPSDONE_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for PWMPERIODEND event */ -#define PWM_INTEN_PWMPERIODEND_Pos (6UL) /*!< Position of PWMPERIODEND field. */ -#define PWM_INTEN_PWMPERIODEND_Msk (0x1UL << PWM_INTEN_PWMPERIODEND_Pos) /*!< Bit mask of PWMPERIODEND field. */ -#define PWM_INTEN_PWMPERIODEND_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_PWMPERIODEND_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for SEQEND[1] event */ -#define PWM_INTEN_SEQEND1_Pos (5UL) /*!< Position of SEQEND1 field. */ -#define PWM_INTEN_SEQEND1_Msk (0x1UL << PWM_INTEN_SEQEND1_Pos) /*!< Bit mask of SEQEND1 field. */ -#define PWM_INTEN_SEQEND1_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQEND1_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for SEQEND[0] event */ -#define PWM_INTEN_SEQEND0_Pos (4UL) /*!< Position of SEQEND0 field. */ -#define PWM_INTEN_SEQEND0_Msk (0x1UL << PWM_INTEN_SEQEND0_Pos) /*!< Bit mask of SEQEND0 field. */ -#define PWM_INTEN_SEQEND0_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQEND0_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for SEQSTARTED[1] event */ -#define PWM_INTEN_SEQSTARTED1_Pos (3UL) /*!< Position of SEQSTARTED1 field. */ -#define PWM_INTEN_SEQSTARTED1_Msk (0x1UL << PWM_INTEN_SEQSTARTED1_Pos) /*!< Bit mask of SEQSTARTED1 field. */ -#define PWM_INTEN_SEQSTARTED1_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQSTARTED1_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for SEQSTARTED[0] event */ -#define PWM_INTEN_SEQSTARTED0_Pos (2UL) /*!< Position of SEQSTARTED0 field. */ -#define PWM_INTEN_SEQSTARTED0_Msk (0x1UL << PWM_INTEN_SEQSTARTED0_Pos) /*!< Bit mask of SEQSTARTED0 field. */ -#define PWM_INTEN_SEQSTARTED0_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_SEQSTARTED0_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define PWM_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PWM_INTEN_STOPPED_Msk (0x1UL << PWM_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PWM_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define PWM_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Register: PWM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 7 : Write '1' to Enable interrupt for LOOPSDONE event */ -#define PWM_INTENSET_LOOPSDONE_Pos (7UL) /*!< Position of LOOPSDONE field. */ -#define PWM_INTENSET_LOOPSDONE_Msk (0x1UL << PWM_INTENSET_LOOPSDONE_Pos) /*!< Bit mask of LOOPSDONE field. */ -#define PWM_INTENSET_LOOPSDONE_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_LOOPSDONE_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_LOOPSDONE_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for PWMPERIODEND event */ -#define PWM_INTENSET_PWMPERIODEND_Pos (6UL) /*!< Position of PWMPERIODEND field. */ -#define PWM_INTENSET_PWMPERIODEND_Msk (0x1UL << PWM_INTENSET_PWMPERIODEND_Pos) /*!< Bit mask of PWMPERIODEND field. */ -#define PWM_INTENSET_PWMPERIODEND_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_PWMPERIODEND_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_PWMPERIODEND_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for SEQEND[1] event */ -#define PWM_INTENSET_SEQEND1_Pos (5UL) /*!< Position of SEQEND1 field. */ -#define PWM_INTENSET_SEQEND1_Msk (0x1UL << PWM_INTENSET_SEQEND1_Pos) /*!< Bit mask of SEQEND1 field. */ -#define PWM_INTENSET_SEQEND1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQEND1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQEND1_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for SEQEND[0] event */ -#define PWM_INTENSET_SEQEND0_Pos (4UL) /*!< Position of SEQEND0 field. */ -#define PWM_INTENSET_SEQEND0_Msk (0x1UL << PWM_INTENSET_SEQEND0_Pos) /*!< Bit mask of SEQEND0 field. */ -#define PWM_INTENSET_SEQEND0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQEND0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQEND0_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for SEQSTARTED[1] event */ -#define PWM_INTENSET_SEQSTARTED1_Pos (3UL) /*!< Position of SEQSTARTED1 field. */ -#define PWM_INTENSET_SEQSTARTED1_Msk (0x1UL << PWM_INTENSET_SEQSTARTED1_Pos) /*!< Bit mask of SEQSTARTED1 field. */ -#define PWM_INTENSET_SEQSTARTED1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQSTARTED1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQSTARTED1_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for SEQSTARTED[0] event */ -#define PWM_INTENSET_SEQSTARTED0_Pos (2UL) /*!< Position of SEQSTARTED0 field. */ -#define PWM_INTENSET_SEQSTARTED0_Msk (0x1UL << PWM_INTENSET_SEQSTARTED0_Pos) /*!< Bit mask of SEQSTARTED0 field. */ -#define PWM_INTENSET_SEQSTARTED0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_SEQSTARTED0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_SEQSTARTED0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define PWM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PWM_INTENSET_STOPPED_Msk (0x1UL << PWM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PWM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: PWM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 7 : Write '1' to Disable interrupt for LOOPSDONE event */ -#define PWM_INTENCLR_LOOPSDONE_Pos (7UL) /*!< Position of LOOPSDONE field. */ -#define PWM_INTENCLR_LOOPSDONE_Msk (0x1UL << PWM_INTENCLR_LOOPSDONE_Pos) /*!< Bit mask of LOOPSDONE field. */ -#define PWM_INTENCLR_LOOPSDONE_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_LOOPSDONE_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_LOOPSDONE_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for PWMPERIODEND event */ -#define PWM_INTENCLR_PWMPERIODEND_Pos (6UL) /*!< Position of PWMPERIODEND field. */ -#define PWM_INTENCLR_PWMPERIODEND_Msk (0x1UL << PWM_INTENCLR_PWMPERIODEND_Pos) /*!< Bit mask of PWMPERIODEND field. */ -#define PWM_INTENCLR_PWMPERIODEND_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_PWMPERIODEND_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_PWMPERIODEND_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for SEQEND[1] event */ -#define PWM_INTENCLR_SEQEND1_Pos (5UL) /*!< Position of SEQEND1 field. */ -#define PWM_INTENCLR_SEQEND1_Msk (0x1UL << PWM_INTENCLR_SEQEND1_Pos) /*!< Bit mask of SEQEND1 field. */ -#define PWM_INTENCLR_SEQEND1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQEND1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQEND1_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for SEQEND[0] event */ -#define PWM_INTENCLR_SEQEND0_Pos (4UL) /*!< Position of SEQEND0 field. */ -#define PWM_INTENCLR_SEQEND0_Msk (0x1UL << PWM_INTENCLR_SEQEND0_Pos) /*!< Bit mask of SEQEND0 field. */ -#define PWM_INTENCLR_SEQEND0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQEND0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQEND0_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for SEQSTARTED[1] event */ -#define PWM_INTENCLR_SEQSTARTED1_Pos (3UL) /*!< Position of SEQSTARTED1 field. */ -#define PWM_INTENCLR_SEQSTARTED1_Msk (0x1UL << PWM_INTENCLR_SEQSTARTED1_Pos) /*!< Bit mask of SEQSTARTED1 field. */ -#define PWM_INTENCLR_SEQSTARTED1_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQSTARTED1_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQSTARTED1_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for SEQSTARTED[0] event */ -#define PWM_INTENCLR_SEQSTARTED0_Pos (2UL) /*!< Position of SEQSTARTED0 field. */ -#define PWM_INTENCLR_SEQSTARTED0_Msk (0x1UL << PWM_INTENCLR_SEQSTARTED0_Pos) /*!< Bit mask of SEQSTARTED0 field. */ -#define PWM_INTENCLR_SEQSTARTED0_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_SEQSTARTED0_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_SEQSTARTED0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define PWM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define PWM_INTENCLR_STOPPED_Msk (0x1UL << PWM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define PWM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define PWM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define PWM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: PWM_ENABLE */ -/* Description: PWM module enable register */ - -/* Bit 0 : Enable or disable PWM module */ -#define PWM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define PWM_ENABLE_ENABLE_Msk (0x1UL << PWM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define PWM_ENABLE_ENABLE_Disabled (0UL) /*!< Disabled */ -#define PWM_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: PWM_MODE */ -/* Description: Selects operating mode of the wave counter */ - -/* Bit 0 : Selects up or up and down as wave counter mode */ -#define PWM_MODE_UPDOWN_Pos (0UL) /*!< Position of UPDOWN field. */ -#define PWM_MODE_UPDOWN_Msk (0x1UL << PWM_MODE_UPDOWN_Pos) /*!< Bit mask of UPDOWN field. */ -#define PWM_MODE_UPDOWN_Up (0UL) /*!< Up counter - edge aligned PWM duty-cycle */ -#define PWM_MODE_UPDOWN_UpAndDown (1UL) /*!< Up and down counter - center aligned PWM duty cycle */ - -/* Register: PWM_COUNTERTOP */ -/* Description: Value up to which the pulse generator counter counts */ - -/* Bits 14..0 : Value up to which the pulse generator counter counts. This register is ignored when DECODER.MODE=WaveForm and only values from RAM will be used. */ -#define PWM_COUNTERTOP_COUNTERTOP_Pos (0UL) /*!< Position of COUNTERTOP field. */ -#define PWM_COUNTERTOP_COUNTERTOP_Msk (0x7FFFUL << PWM_COUNTERTOP_COUNTERTOP_Pos) /*!< Bit mask of COUNTERTOP field. */ - -/* Register: PWM_PRESCALER */ -/* Description: Configuration for PWM_CLK */ - -/* Bits 2..0 : Pre-scaler of PWM_CLK */ -#define PWM_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define PWM_PRESCALER_PRESCALER_Msk (0x7UL << PWM_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ -#define PWM_PRESCALER_PRESCALER_DIV_1 (0UL) /*!< Divide by 1 (16MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_2 (1UL) /*!< Divide by 2 ( 8MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_4 (2UL) /*!< Divide by 4 ( 4MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_8 (3UL) /*!< Divide by 8 ( 2MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_16 (4UL) /*!< Divide by 16 ( 1MHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_32 (5UL) /*!< Divide by 32 ( 500kHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_64 (6UL) /*!< Divide by 64 ( 250kHz) */ -#define PWM_PRESCALER_PRESCALER_DIV_128 (7UL) /*!< Divide by 128 ( 125kHz) */ - -/* Register: PWM_DECODER */ -/* Description: Configuration of the decoder */ - -/* Bit 8 : Selects source for advancing the active sequence */ -#define PWM_DECODER_MODE_Pos (8UL) /*!< Position of MODE field. */ -#define PWM_DECODER_MODE_Msk (0x1UL << PWM_DECODER_MODE_Pos) /*!< Bit mask of MODE field. */ -#define PWM_DECODER_MODE_RefreshCount (0UL) /*!< SEQ[n].REFRESH is used to determine loading internal compare registers */ -#define PWM_DECODER_MODE_NextStep (1UL) /*!< NEXTSTEP task causes a new value to be loaded to internal compare registers */ - -/* Bits 1..0 : How a sequence is read from RAM and spread to the compare register */ -#define PWM_DECODER_LOAD_Pos (0UL) /*!< Position of LOAD field. */ -#define PWM_DECODER_LOAD_Msk (0x3UL << PWM_DECODER_LOAD_Pos) /*!< Bit mask of LOAD field. */ -#define PWM_DECODER_LOAD_Common (0UL) /*!< 1st half word (16-bit) used in all PWM channels 0..3 */ -#define PWM_DECODER_LOAD_Grouped (1UL) /*!< 1st half word (16-bit) used in channel 0..1; 2nd word in channel 2..3 */ -#define PWM_DECODER_LOAD_Individual (2UL) /*!< 1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in ch.3 */ -#define PWM_DECODER_LOAD_WaveForm (3UL) /*!< 1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in COUNTERTOP */ - -/* Register: PWM_LOOP */ -/* Description: Amount of playback of a loop */ - -/* Bits 15..0 : Amount of playback of pattern cycles */ -#define PWM_LOOP_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_LOOP_CNT_Msk (0xFFFFUL << PWM_LOOP_CNT_Pos) /*!< Bit mask of CNT field. */ -#define PWM_LOOP_CNT_Disabled (0UL) /*!< Looping disabled (stop at the end of the sequence) */ - -/* Register: PWM_SEQ_PTR */ -/* Description: Description cluster[0]: Beginning address in Data RAM of this sequence */ - -/* Bits 31..0 : Beginning address in Data RAM of this sequence */ -#define PWM_SEQ_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define PWM_SEQ_PTR_PTR_Msk (0xFFFFFFFFUL << PWM_SEQ_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: PWM_SEQ_CNT */ -/* Description: Description cluster[0]: Amount of values (duty cycles) in this sequence */ - -/* Bits 14..0 : Amount of values (duty cycles) in this sequence */ -#define PWM_SEQ_CNT_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_SEQ_CNT_CNT_Msk (0x7FFFUL << PWM_SEQ_CNT_CNT_Pos) /*!< Bit mask of CNT field. */ -#define PWM_SEQ_CNT_CNT_Disabled (0UL) /*!< Sequence is disabled, and shall not be started as it is empty */ - -/* Register: PWM_SEQ_REFRESH */ -/* Description: Description cluster[0]: Amount of additional PWM periods between samples loaded into compare register */ - -/* Bits 23..0 : Amount of additional PWM periods between samples loaded into compare register (load every REFRESH.CNT+1 PWM periods) */ -#define PWM_SEQ_REFRESH_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_SEQ_REFRESH_CNT_Msk (0xFFFFFFUL << PWM_SEQ_REFRESH_CNT_Pos) /*!< Bit mask of CNT field. */ -#define PWM_SEQ_REFRESH_CNT_Continuous (0UL) /*!< Update every PWM period */ - -/* Register: PWM_SEQ_ENDDELAY */ -/* Description: Description cluster[0]: Time added after the sequence */ - -/* Bits 23..0 : Time added after the sequence in PWM periods */ -#define PWM_SEQ_ENDDELAY_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define PWM_SEQ_ENDDELAY_CNT_Msk (0xFFFFFFUL << PWM_SEQ_ENDDELAY_CNT_Pos) /*!< Bit mask of CNT field. */ - -/* Register: PWM_PSEL_OUT */ -/* Description: Description collection[0]: Output pin select for PWM channel 0 */ - -/* Bit 31 : Connection */ -#define PWM_PSEL_OUT_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define PWM_PSEL_OUT_CONNECT_Msk (0x1UL << PWM_PSEL_OUT_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define PWM_PSEL_OUT_CONNECT_Connected (0UL) /*!< Connect */ -#define PWM_PSEL_OUT_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define PWM_PSEL_OUT_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define PWM_PSEL_OUT_PORT_Msk (0x1UL << PWM_PSEL_OUT_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define PWM_PSEL_OUT_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define PWM_PSEL_OUT_PIN_Msk (0x1FUL << PWM_PSEL_OUT_PIN_Pos) /*!< Bit mask of PIN field. */ - - -/* Peripheral: QDEC */ -/* Description: Quadrature Decoder */ - -/* Register: QDEC_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 6 : Shortcut between SAMPLERDY event and READCLRACC task */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Pos (6UL) /*!< Position of SAMPLERDY_READCLRACC field. */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Msk (0x1UL << QDEC_SHORTS_SAMPLERDY_READCLRACC_Pos) /*!< Bit mask of SAMPLERDY_READCLRACC field. */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_SAMPLERDY_READCLRACC_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between DBLRDY event and STOP task */ -#define QDEC_SHORTS_DBLRDY_STOP_Pos (5UL) /*!< Position of DBLRDY_STOP field. */ -#define QDEC_SHORTS_DBLRDY_STOP_Msk (0x1UL << QDEC_SHORTS_DBLRDY_STOP_Pos) /*!< Bit mask of DBLRDY_STOP field. */ -#define QDEC_SHORTS_DBLRDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_DBLRDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 4 : Shortcut between DBLRDY event and RDCLRDBL task */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Pos (4UL) /*!< Position of DBLRDY_RDCLRDBL field. */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Msk (0x1UL << QDEC_SHORTS_DBLRDY_RDCLRDBL_Pos) /*!< Bit mask of DBLRDY_RDCLRDBL field. */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_DBLRDY_RDCLRDBL_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between REPORTRDY event and STOP task */ -#define QDEC_SHORTS_REPORTRDY_STOP_Pos (3UL) /*!< Position of REPORTRDY_STOP field. */ -#define QDEC_SHORTS_REPORTRDY_STOP_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_STOP_Pos) /*!< Bit mask of REPORTRDY_STOP field. */ -#define QDEC_SHORTS_REPORTRDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_REPORTRDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between REPORTRDY event and RDCLRACC task */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Pos (2UL) /*!< Position of REPORTRDY_RDCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_RDCLRACC_Pos) /*!< Bit mask of REPORTRDY_RDCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_REPORTRDY_RDCLRACC_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between SAMPLERDY event and STOP task */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Pos (1UL) /*!< Position of SAMPLERDY_STOP field. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Msk (0x1UL << QDEC_SHORTS_SAMPLERDY_STOP_Pos) /*!< Bit mask of SAMPLERDY_STOP field. */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_SAMPLERDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between REPORTRDY event and READCLRACC task */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Pos (0UL) /*!< Position of REPORTRDY_READCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Msk (0x1UL << QDEC_SHORTS_REPORTRDY_READCLRACC_Pos) /*!< Bit mask of REPORTRDY_READCLRACC field. */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Disabled (0UL) /*!< Disable shortcut */ -#define QDEC_SHORTS_REPORTRDY_READCLRACC_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: QDEC_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 4 : Write '1' to Enable interrupt for STOPPED event */ -#define QDEC_INTENSET_STOPPED_Pos (4UL) /*!< Position of STOPPED field. */ -#define QDEC_INTENSET_STOPPED_Msk (0x1UL << QDEC_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define QDEC_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for DBLRDY event */ -#define QDEC_INTENSET_DBLRDY_Pos (3UL) /*!< Position of DBLRDY field. */ -#define QDEC_INTENSET_DBLRDY_Msk (0x1UL << QDEC_INTENSET_DBLRDY_Pos) /*!< Bit mask of DBLRDY field. */ -#define QDEC_INTENSET_DBLRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_DBLRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_DBLRDY_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for ACCOF event */ -#define QDEC_INTENSET_ACCOF_Pos (2UL) /*!< Position of ACCOF field. */ -#define QDEC_INTENSET_ACCOF_Msk (0x1UL << QDEC_INTENSET_ACCOF_Pos) /*!< Bit mask of ACCOF field. */ -#define QDEC_INTENSET_ACCOF_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_ACCOF_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_ACCOF_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for REPORTRDY event */ -#define QDEC_INTENSET_REPORTRDY_Pos (1UL) /*!< Position of REPORTRDY field. */ -#define QDEC_INTENSET_REPORTRDY_Msk (0x1UL << QDEC_INTENSET_REPORTRDY_Pos) /*!< Bit mask of REPORTRDY field. */ -#define QDEC_INTENSET_REPORTRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_REPORTRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_REPORTRDY_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for SAMPLERDY event */ -#define QDEC_INTENSET_SAMPLERDY_Pos (0UL) /*!< Position of SAMPLERDY field. */ -#define QDEC_INTENSET_SAMPLERDY_Msk (0x1UL << QDEC_INTENSET_SAMPLERDY_Pos) /*!< Bit mask of SAMPLERDY field. */ -#define QDEC_INTENSET_SAMPLERDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENSET_SAMPLERDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENSET_SAMPLERDY_Set (1UL) /*!< Enable */ - -/* Register: QDEC_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 4 : Write '1' to Disable interrupt for STOPPED event */ -#define QDEC_INTENCLR_STOPPED_Pos (4UL) /*!< Position of STOPPED field. */ -#define QDEC_INTENCLR_STOPPED_Msk (0x1UL << QDEC_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define QDEC_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for DBLRDY event */ -#define QDEC_INTENCLR_DBLRDY_Pos (3UL) /*!< Position of DBLRDY field. */ -#define QDEC_INTENCLR_DBLRDY_Msk (0x1UL << QDEC_INTENCLR_DBLRDY_Pos) /*!< Bit mask of DBLRDY field. */ -#define QDEC_INTENCLR_DBLRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_DBLRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_DBLRDY_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for ACCOF event */ -#define QDEC_INTENCLR_ACCOF_Pos (2UL) /*!< Position of ACCOF field. */ -#define QDEC_INTENCLR_ACCOF_Msk (0x1UL << QDEC_INTENCLR_ACCOF_Pos) /*!< Bit mask of ACCOF field. */ -#define QDEC_INTENCLR_ACCOF_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_ACCOF_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_ACCOF_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for REPORTRDY event */ -#define QDEC_INTENCLR_REPORTRDY_Pos (1UL) /*!< Position of REPORTRDY field. */ -#define QDEC_INTENCLR_REPORTRDY_Msk (0x1UL << QDEC_INTENCLR_REPORTRDY_Pos) /*!< Bit mask of REPORTRDY field. */ -#define QDEC_INTENCLR_REPORTRDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_REPORTRDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_REPORTRDY_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for SAMPLERDY event */ -#define QDEC_INTENCLR_SAMPLERDY_Pos (0UL) /*!< Position of SAMPLERDY field. */ -#define QDEC_INTENCLR_SAMPLERDY_Msk (0x1UL << QDEC_INTENCLR_SAMPLERDY_Pos) /*!< Bit mask of SAMPLERDY field. */ -#define QDEC_INTENCLR_SAMPLERDY_Disabled (0UL) /*!< Read: Disabled */ -#define QDEC_INTENCLR_SAMPLERDY_Enabled (1UL) /*!< Read: Enabled */ -#define QDEC_INTENCLR_SAMPLERDY_Clear (1UL) /*!< Disable */ - -/* Register: QDEC_ENABLE */ -/* Description: Enable the quadrature decoder */ - -/* Bit 0 : Enable or disable the quadrature decoder */ -#define QDEC_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define QDEC_ENABLE_ENABLE_Msk (0x1UL << QDEC_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define QDEC_ENABLE_ENABLE_Disabled (0UL) /*!< Disable */ -#define QDEC_ENABLE_ENABLE_Enabled (1UL) /*!< Enable */ - -/* Register: QDEC_LEDPOL */ -/* Description: LED output pin polarity */ - -/* Bit 0 : LED output pin polarity */ -#define QDEC_LEDPOL_LEDPOL_Pos (0UL) /*!< Position of LEDPOL field. */ -#define QDEC_LEDPOL_LEDPOL_Msk (0x1UL << QDEC_LEDPOL_LEDPOL_Pos) /*!< Bit mask of LEDPOL field. */ -#define QDEC_LEDPOL_LEDPOL_ActiveLow (0UL) /*!< Led active on output pin low */ -#define QDEC_LEDPOL_LEDPOL_ActiveHigh (1UL) /*!< Led active on output pin high */ - -/* Register: QDEC_SAMPLEPER */ -/* Description: Sample period */ - -/* Bits 3..0 : Sample period. The SAMPLE register will be updated for every new sample */ -#define QDEC_SAMPLEPER_SAMPLEPER_Pos (0UL) /*!< Position of SAMPLEPER field. */ -#define QDEC_SAMPLEPER_SAMPLEPER_Msk (0xFUL << QDEC_SAMPLEPER_SAMPLEPER_Pos) /*!< Bit mask of SAMPLEPER field. */ -#define QDEC_SAMPLEPER_SAMPLEPER_128us (0UL) /*!< 128 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_256us (1UL) /*!< 256 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_512us (2UL) /*!< 512 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_1024us (3UL) /*!< 1024 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_2048us (4UL) /*!< 2048 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_4096us (5UL) /*!< 4096 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_8192us (6UL) /*!< 8192 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_16384us (7UL) /*!< 16384 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_32ms (8UL) /*!< 32768 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_65ms (9UL) /*!< 65536 us */ -#define QDEC_SAMPLEPER_SAMPLEPER_131ms (10UL) /*!< 131072 us */ - -/* Register: QDEC_SAMPLE */ -/* Description: Motion sample value */ - -/* Bits 31..0 : Last motion sample */ -#define QDEC_SAMPLE_SAMPLE_Pos (0UL) /*!< Position of SAMPLE field. */ -#define QDEC_SAMPLE_SAMPLE_Msk (0xFFFFFFFFUL << QDEC_SAMPLE_SAMPLE_Pos) /*!< Bit mask of SAMPLE field. */ - -/* Register: QDEC_REPORTPER */ -/* Description: Number of samples to be taken before REPORTRDY and DBLRDY events can be generated */ - -/* Bits 3..0 : Specifies the number of samples to be accumulated in the ACC register before the REPORTRDY and DBLRDY events can be generated */ -#define QDEC_REPORTPER_REPORTPER_Pos (0UL) /*!< Position of REPORTPER field. */ -#define QDEC_REPORTPER_REPORTPER_Msk (0xFUL << QDEC_REPORTPER_REPORTPER_Pos) /*!< Bit mask of REPORTPER field. */ -#define QDEC_REPORTPER_REPORTPER_10Smpl (0UL) /*!< 10 samples / report */ -#define QDEC_REPORTPER_REPORTPER_40Smpl (1UL) /*!< 40 samples / report */ -#define QDEC_REPORTPER_REPORTPER_80Smpl (2UL) /*!< 80 samples / report */ -#define QDEC_REPORTPER_REPORTPER_120Smpl (3UL) /*!< 120 samples / report */ -#define QDEC_REPORTPER_REPORTPER_160Smpl (4UL) /*!< 160 samples / report */ -#define QDEC_REPORTPER_REPORTPER_200Smpl (5UL) /*!< 200 samples / report */ -#define QDEC_REPORTPER_REPORTPER_240Smpl (6UL) /*!< 240 samples / report */ -#define QDEC_REPORTPER_REPORTPER_280Smpl (7UL) /*!< 280 samples / report */ -#define QDEC_REPORTPER_REPORTPER_1Smpl (8UL) /*!< 1 sample / report */ - -/* Register: QDEC_ACC */ -/* Description: Register accumulating the valid transitions */ - -/* Bits 31..0 : Register accumulating all valid samples (not double transition) read from the SAMPLE register */ -#define QDEC_ACC_ACC_Pos (0UL) /*!< Position of ACC field. */ -#define QDEC_ACC_ACC_Msk (0xFFFFFFFFUL << QDEC_ACC_ACC_Pos) /*!< Bit mask of ACC field. */ - -/* Register: QDEC_ACCREAD */ -/* Description: Snapshot of the ACC register, updated by the READCLRACC or RDCLRACC task */ - -/* Bits 31..0 : Snapshot of the ACC register. */ -#define QDEC_ACCREAD_ACCREAD_Pos (0UL) /*!< Position of ACCREAD field. */ -#define QDEC_ACCREAD_ACCREAD_Msk (0xFFFFFFFFUL << QDEC_ACCREAD_ACCREAD_Pos) /*!< Bit mask of ACCREAD field. */ - -/* Register: QDEC_PSEL_LED */ -/* Description: Pin select for LED signal */ - -/* Bit 31 : Connection */ -#define QDEC_PSEL_LED_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QDEC_PSEL_LED_CONNECT_Msk (0x1UL << QDEC_PSEL_LED_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QDEC_PSEL_LED_CONNECT_Connected (0UL) /*!< Connect */ -#define QDEC_PSEL_LED_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QDEC_PSEL_LED_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QDEC_PSEL_LED_PORT_Msk (0x1UL << QDEC_PSEL_LED_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QDEC_PSEL_LED_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QDEC_PSEL_LED_PIN_Msk (0x1FUL << QDEC_PSEL_LED_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QDEC_PSEL_A */ -/* Description: Pin select for A signal */ - -/* Bit 31 : Connection */ -#define QDEC_PSEL_A_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QDEC_PSEL_A_CONNECT_Msk (0x1UL << QDEC_PSEL_A_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QDEC_PSEL_A_CONNECT_Connected (0UL) /*!< Connect */ -#define QDEC_PSEL_A_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QDEC_PSEL_A_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QDEC_PSEL_A_PORT_Msk (0x1UL << QDEC_PSEL_A_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QDEC_PSEL_A_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QDEC_PSEL_A_PIN_Msk (0x1FUL << QDEC_PSEL_A_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QDEC_PSEL_B */ -/* Description: Pin select for B signal */ - -/* Bit 31 : Connection */ -#define QDEC_PSEL_B_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QDEC_PSEL_B_CONNECT_Msk (0x1UL << QDEC_PSEL_B_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QDEC_PSEL_B_CONNECT_Connected (0UL) /*!< Connect */ -#define QDEC_PSEL_B_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QDEC_PSEL_B_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QDEC_PSEL_B_PORT_Msk (0x1UL << QDEC_PSEL_B_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QDEC_PSEL_B_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QDEC_PSEL_B_PIN_Msk (0x1FUL << QDEC_PSEL_B_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QDEC_DBFEN */ -/* Description: Enable input debounce filters */ - -/* Bit 0 : Enable input debounce filters */ -#define QDEC_DBFEN_DBFEN_Pos (0UL) /*!< Position of DBFEN field. */ -#define QDEC_DBFEN_DBFEN_Msk (0x1UL << QDEC_DBFEN_DBFEN_Pos) /*!< Bit mask of DBFEN field. */ -#define QDEC_DBFEN_DBFEN_Disabled (0UL) /*!< Debounce input filters disabled */ -#define QDEC_DBFEN_DBFEN_Enabled (1UL) /*!< Debounce input filters enabled */ - -/* Register: QDEC_LEDPRE */ -/* Description: Time period the LED is switched ON prior to sampling */ - -/* Bits 8..0 : Period in us the LED is switched on prior to sampling */ -#define QDEC_LEDPRE_LEDPRE_Pos (0UL) /*!< Position of LEDPRE field. */ -#define QDEC_LEDPRE_LEDPRE_Msk (0x1FFUL << QDEC_LEDPRE_LEDPRE_Pos) /*!< Bit mask of LEDPRE field. */ - -/* Register: QDEC_ACCDBL */ -/* Description: Register accumulating the number of detected double transitions */ - -/* Bits 3..0 : Register accumulating the number of detected double or illegal transitions. ( SAMPLE = 2 ). */ -#define QDEC_ACCDBL_ACCDBL_Pos (0UL) /*!< Position of ACCDBL field. */ -#define QDEC_ACCDBL_ACCDBL_Msk (0xFUL << QDEC_ACCDBL_ACCDBL_Pos) /*!< Bit mask of ACCDBL field. */ - -/* Register: QDEC_ACCDBLREAD */ -/* Description: Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL task */ - -/* Bits 3..0 : Snapshot of the ACCDBL register. This field is updated when the READCLRACC or RDCLRDBL task is triggered. */ -#define QDEC_ACCDBLREAD_ACCDBLREAD_Pos (0UL) /*!< Position of ACCDBLREAD field. */ -#define QDEC_ACCDBLREAD_ACCDBLREAD_Msk (0xFUL << QDEC_ACCDBLREAD_ACCDBLREAD_Pos) /*!< Bit mask of ACCDBLREAD field. */ - - -/* Peripheral: QSPI */ -/* Description: External flash interface */ - -/* Register: QSPI_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 0 : Enable or disable interrupt for READY event */ -#define QSPI_INTEN_READY_Pos (0UL) /*!< Position of READY field. */ -#define QSPI_INTEN_READY_Msk (0x1UL << QSPI_INTEN_READY_Pos) /*!< Bit mask of READY field. */ -#define QSPI_INTEN_READY_Disabled (0UL) /*!< Disable */ -#define QSPI_INTEN_READY_Enabled (1UL) /*!< Enable */ - -/* Register: QSPI_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define QSPI_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define QSPI_INTENSET_READY_Msk (0x1UL << QSPI_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define QSPI_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define QSPI_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define QSPI_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: QSPI_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define QSPI_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define QSPI_INTENCLR_READY_Msk (0x1UL << QSPI_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define QSPI_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define QSPI_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define QSPI_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: QSPI_ENABLE */ -/* Description: Enable QSPI peripheral and acquire the pins selected in PSELn registers */ - -/* Bit 0 : Enable or disable QSPI */ -#define QSPI_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define QSPI_ENABLE_ENABLE_Msk (0x1UL << QSPI_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define QSPI_ENABLE_ENABLE_Disabled (0UL) /*!< Disable QSPI */ -#define QSPI_ENABLE_ENABLE_Enabled (1UL) /*!< Enable QSPI */ - -/* Register: QSPI_READ_SRC */ -/* Description: Flash memory source address */ - -/* Bits 31..0 : Word-aligned flash memory source address. */ -#define QSPI_READ_SRC_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define QSPI_READ_SRC_SRC_Msk (0xFFFFFFFFUL << QSPI_READ_SRC_SRC_Pos) /*!< Bit mask of SRC field. */ - -/* Register: QSPI_READ_DST */ -/* Description: RAM destination address */ - -/* Bits 31..0 : Word-aligned RAM destination address. */ -#define QSPI_READ_DST_DST_Pos (0UL) /*!< Position of DST field. */ -#define QSPI_READ_DST_DST_Msk (0xFFFFFFFFUL << QSPI_READ_DST_DST_Pos) /*!< Bit mask of DST field. */ - -/* Register: QSPI_READ_CNT */ -/* Description: Read transfer length */ - -/* Bits 20..0 : Read transfer length in number of bytes. The length must be a multiple of 4 bytes. */ -#define QSPI_READ_CNT_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define QSPI_READ_CNT_CNT_Msk (0x1FFFFFUL << QSPI_READ_CNT_CNT_Pos) /*!< Bit mask of CNT field. */ - -/* Register: QSPI_WRITE_DST */ -/* Description: Flash destination address */ - -/* Bits 31..0 : Word-aligned flash destination address. */ -#define QSPI_WRITE_DST_DST_Pos (0UL) /*!< Position of DST field. */ -#define QSPI_WRITE_DST_DST_Msk (0xFFFFFFFFUL << QSPI_WRITE_DST_DST_Pos) /*!< Bit mask of DST field. */ - -/* Register: QSPI_WRITE_SRC */ -/* Description: RAM source address */ - -/* Bits 31..0 : Word-aligned RAM source address. */ -#define QSPI_WRITE_SRC_SRC_Pos (0UL) /*!< Position of SRC field. */ -#define QSPI_WRITE_SRC_SRC_Msk (0xFFFFFFFFUL << QSPI_WRITE_SRC_SRC_Pos) /*!< Bit mask of SRC field. */ - -/* Register: QSPI_WRITE_CNT */ -/* Description: Write transfer length */ - -/* Bits 20..0 : Write transfer length in number of bytes. The length must be a multiple of 4 bytes. */ -#define QSPI_WRITE_CNT_CNT_Pos (0UL) /*!< Position of CNT field. */ -#define QSPI_WRITE_CNT_CNT_Msk (0x1FFFFFUL << QSPI_WRITE_CNT_CNT_Pos) /*!< Bit mask of CNT field. */ - -/* Register: QSPI_ERASE_PTR */ -/* Description: Start address of flash block to be erased */ - -/* Bits 31..0 : Word-aligned start address of block to be erased. */ -#define QSPI_ERASE_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define QSPI_ERASE_PTR_PTR_Msk (0xFFFFFFFFUL << QSPI_ERASE_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: QSPI_ERASE_LEN */ -/* Description: Size of block to be erased. */ - -/* Bits 1..0 : LEN */ -#define QSPI_ERASE_LEN_LEN_Pos (0UL) /*!< Position of LEN field. */ -#define QSPI_ERASE_LEN_LEN_Msk (0x3UL << QSPI_ERASE_LEN_LEN_Pos) /*!< Bit mask of LEN field. */ -#define QSPI_ERASE_LEN_LEN_4KB (0UL) /*!< Erase 4 kB block (flash command 0x20) */ -#define QSPI_ERASE_LEN_LEN_64KB (1UL) /*!< Erase 64 kB block (flash command 0xD8) */ -#define QSPI_ERASE_LEN_LEN_All (2UL) /*!< Erase all (flash command 0xC7) */ - -/* Register: QSPI_PSEL_SCK */ -/* Description: Pin select for serial clock SCK */ - -/* Bit 31 : Connection */ -#define QSPI_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QSPI_PSEL_SCK_CONNECT_Msk (0x1UL << QSPI_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QSPI_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define QSPI_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QSPI_PSEL_SCK_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QSPI_PSEL_SCK_PORT_Msk (0x1UL << QSPI_PSEL_SCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QSPI_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QSPI_PSEL_SCK_PIN_Msk (0x1FUL << QSPI_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QSPI_PSEL_CSN */ -/* Description: Pin select for chip select signal CSN. */ - -/* Bit 31 : Connection */ -#define QSPI_PSEL_CSN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QSPI_PSEL_CSN_CONNECT_Msk (0x1UL << QSPI_PSEL_CSN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QSPI_PSEL_CSN_CONNECT_Connected (0UL) /*!< Connect */ -#define QSPI_PSEL_CSN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QSPI_PSEL_CSN_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QSPI_PSEL_CSN_PORT_Msk (0x1UL << QSPI_PSEL_CSN_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QSPI_PSEL_CSN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QSPI_PSEL_CSN_PIN_Msk (0x1FUL << QSPI_PSEL_CSN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QSPI_PSEL_IO0 */ -/* Description: Pin select for serial data MOSI/IO0. */ - -/* Bit 31 : Connection */ -#define QSPI_PSEL_IO0_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QSPI_PSEL_IO0_CONNECT_Msk (0x1UL << QSPI_PSEL_IO0_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QSPI_PSEL_IO0_CONNECT_Connected (0UL) /*!< Connect */ -#define QSPI_PSEL_IO0_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QSPI_PSEL_IO0_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QSPI_PSEL_IO0_PORT_Msk (0x1UL << QSPI_PSEL_IO0_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QSPI_PSEL_IO0_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QSPI_PSEL_IO0_PIN_Msk (0x1FUL << QSPI_PSEL_IO0_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QSPI_PSEL_IO1 */ -/* Description: Pin select for serial data MISO/IO1. */ - -/* Bit 31 : Connection */ -#define QSPI_PSEL_IO1_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QSPI_PSEL_IO1_CONNECT_Msk (0x1UL << QSPI_PSEL_IO1_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QSPI_PSEL_IO1_CONNECT_Connected (0UL) /*!< Connect */ -#define QSPI_PSEL_IO1_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QSPI_PSEL_IO1_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QSPI_PSEL_IO1_PORT_Msk (0x1UL << QSPI_PSEL_IO1_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QSPI_PSEL_IO1_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QSPI_PSEL_IO1_PIN_Msk (0x1FUL << QSPI_PSEL_IO1_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QSPI_PSEL_IO2 */ -/* Description: Pin select for serial data IO2. */ - -/* Bit 31 : Connection */ -#define QSPI_PSEL_IO2_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QSPI_PSEL_IO2_CONNECT_Msk (0x1UL << QSPI_PSEL_IO2_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QSPI_PSEL_IO2_CONNECT_Connected (0UL) /*!< Connect */ -#define QSPI_PSEL_IO2_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QSPI_PSEL_IO2_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QSPI_PSEL_IO2_PORT_Msk (0x1UL << QSPI_PSEL_IO2_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QSPI_PSEL_IO2_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QSPI_PSEL_IO2_PIN_Msk (0x1FUL << QSPI_PSEL_IO2_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QSPI_PSEL_IO3 */ -/* Description: Pin select for serial data IO3. */ - -/* Bit 31 : Connection */ -#define QSPI_PSEL_IO3_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define QSPI_PSEL_IO3_CONNECT_Msk (0x1UL << QSPI_PSEL_IO3_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define QSPI_PSEL_IO3_CONNECT_Connected (0UL) /*!< Connect */ -#define QSPI_PSEL_IO3_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define QSPI_PSEL_IO3_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define QSPI_PSEL_IO3_PORT_Msk (0x1UL << QSPI_PSEL_IO3_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define QSPI_PSEL_IO3_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define QSPI_PSEL_IO3_PIN_Msk (0x1FUL << QSPI_PSEL_IO3_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: QSPI_XIPOFFSET */ -/* Description: Address offset into the external memory for Execute in Place operation. */ - -/* Bits 31..0 : Address offset into the external memory for Execute in Place operation. Value must be a multiple of 4. */ -#define QSPI_XIPOFFSET_XIPOFFSET_Pos (0UL) /*!< Position of XIPOFFSET field. */ -#define QSPI_XIPOFFSET_XIPOFFSET_Msk (0xFFFFFFFFUL << QSPI_XIPOFFSET_XIPOFFSET_Pos) /*!< Bit mask of XIPOFFSET field. */ - -/* Register: QSPI_IFCONFIG0 */ -/* Description: Interface configuration. */ - -/* Bit 12 : Page size for commands PP, PP2O, PP4O and PP4IO. */ -#define QSPI_IFCONFIG0_PPSIZE_Pos (12UL) /*!< Position of PPSIZE field. */ -#define QSPI_IFCONFIG0_PPSIZE_Msk (0x1UL << QSPI_IFCONFIG0_PPSIZE_Pos) /*!< Bit mask of PPSIZE field. */ -#define QSPI_IFCONFIG0_PPSIZE_256Bytes (0UL) /*!< 256 bytes. */ -#define QSPI_IFCONFIG0_PPSIZE_512Bytes (1UL) /*!< 512 bytes. */ - -/* Bit 7 : Enable deep power-down mode (DPM) feature. */ -#define QSPI_IFCONFIG0_DPMENABLE_Pos (7UL) /*!< Position of DPMENABLE field. */ -#define QSPI_IFCONFIG0_DPMENABLE_Msk (0x1UL << QSPI_IFCONFIG0_DPMENABLE_Pos) /*!< Bit mask of DPMENABLE field. */ -#define QSPI_IFCONFIG0_DPMENABLE_Disable (0UL) /*!< Disable DPM feature. */ -#define QSPI_IFCONFIG0_DPMENABLE_Enable (1UL) /*!< Enable DPM feature. */ - -/* Bit 6 : Addressing mode. */ -#define QSPI_IFCONFIG0_ADDRMODE_Pos (6UL) /*!< Position of ADDRMODE field. */ -#define QSPI_IFCONFIG0_ADDRMODE_Msk (0x1UL << QSPI_IFCONFIG0_ADDRMODE_Pos) /*!< Bit mask of ADDRMODE field. */ -#define QSPI_IFCONFIG0_ADDRMODE_24BIT (0UL) /*!< 24-bit addressing. */ -#define QSPI_IFCONFIG0_ADDRMODE_32BIT (1UL) /*!< 32-bit addressing. */ - -/* Bits 5..3 : Configure number of data lines and opcode used for writing. */ -#define QSPI_IFCONFIG0_WRITEOC_Pos (3UL) /*!< Position of WRITEOC field. */ -#define QSPI_IFCONFIG0_WRITEOC_Msk (0x7UL << QSPI_IFCONFIG0_WRITEOC_Pos) /*!< Bit mask of WRITEOC field. */ -#define QSPI_IFCONFIG0_WRITEOC_PP (0UL) /*!< Single data line SPI. PP (opcode 0x02). */ -#define QSPI_IFCONFIG0_WRITEOC_PP2O (1UL) /*!< Dual data line SPI. PP2O (opcode 0xA2). */ -#define QSPI_IFCONFIG0_WRITEOC_PP4O (2UL) /*!< Quad data line SPI. PP4O (opcode 0x32). */ -#define QSPI_IFCONFIG0_WRITEOC_PP4IO (3UL) /*!< Quad data line SPI. PP4IO (opcode 0x38). */ - -/* Bits 2..0 : Configure number of data lines and opcode used for reading. */ -#define QSPI_IFCONFIG0_READOC_Pos (0UL) /*!< Position of READOC field. */ -#define QSPI_IFCONFIG0_READOC_Msk (0x7UL << QSPI_IFCONFIG0_READOC_Pos) /*!< Bit mask of READOC field. */ -#define QSPI_IFCONFIG0_READOC_FASTREAD (0UL) /*!< Single data line SPI. FAST_READ (opcode 0x0B). */ -#define QSPI_IFCONFIG0_READOC_READ2O (1UL) /*!< Dual data line SPI. READ2O (opcode 0x3B). */ -#define QSPI_IFCONFIG0_READOC_READ2IO (2UL) /*!< Dual data line SPI. READ2IO (opcode 0xBB). */ -#define QSPI_IFCONFIG0_READOC_READ4O (3UL) /*!< Quad data line SPI. READ4O (opcode 0x6B). */ -#define QSPI_IFCONFIG0_READOC_READ4IO (4UL) /*!< Quad data line SPI. READ4IO (opcode 0xEB). */ - -/* Register: QSPI_IFCONFIG1 */ -/* Description: Interface configuration. */ - -/* Bits 31..28 : SCK frequency is given as 32 MHz / (SCKFREQ + 1). */ -#define QSPI_IFCONFIG1_SCKFREQ_Pos (28UL) /*!< Position of SCKFREQ field. */ -#define QSPI_IFCONFIG1_SCKFREQ_Msk (0xFUL << QSPI_IFCONFIG1_SCKFREQ_Pos) /*!< Bit mask of SCKFREQ field. */ - -/* Bit 25 : Select SPI mode. */ -#define QSPI_IFCONFIG1_SPIMODE_Pos (25UL) /*!< Position of SPIMODE field. */ -#define QSPI_IFCONFIG1_SPIMODE_Msk (0x1UL << QSPI_IFCONFIG1_SPIMODE_Pos) /*!< Bit mask of SPIMODE field. */ -#define QSPI_IFCONFIG1_SPIMODE_MODE0 (0UL) /*!< Mode 0: Data are captured on the clock rising edge and data is output on a falling edge. Base level of clock is 0 (CPOL=0, CPHA=0). */ -#define QSPI_IFCONFIG1_SPIMODE_MODE3 (1UL) /*!< Mode 3: Data are captured on the clock falling edge and data is output on a rising edge. Base level of clock is 1 (CPOL=1, CPHA=1). */ - -/* Bit 24 : Enter/exit deep power-down mode (DPM) for external flash memory. */ -#define QSPI_IFCONFIG1_DPMEN_Pos (24UL) /*!< Position of DPMEN field. */ -#define QSPI_IFCONFIG1_DPMEN_Msk (0x1UL << QSPI_IFCONFIG1_DPMEN_Pos) /*!< Bit mask of DPMEN field. */ -#define QSPI_IFCONFIG1_DPMEN_Exit (0UL) /*!< Exit DPM. */ -#define QSPI_IFCONFIG1_DPMEN_Enter (1UL) /*!< Enter DPM. */ - -/* Bits 7..0 : Minimum amount of time that the CSN pin must stay high before it can go low again. Value is specified in number of 16 MHz periods (62.5 ns). */ -#define QSPI_IFCONFIG1_SCKDELAY_Pos (0UL) /*!< Position of SCKDELAY field. */ -#define QSPI_IFCONFIG1_SCKDELAY_Msk (0xFFUL << QSPI_IFCONFIG1_SCKDELAY_Pos) /*!< Bit mask of SCKDELAY field. */ - -/* Register: QSPI_STATUS */ -/* Description: Status register. */ - -/* Bits 31..24 : Value of external flash device Status Register. When the external flash has two bytes status register this field includes the value of the low byte. */ -#define QSPI_STATUS_SREG_Pos (24UL) /*!< Position of SREG field. */ -#define QSPI_STATUS_SREG_Msk (0xFFUL << QSPI_STATUS_SREG_Pos) /*!< Bit mask of SREG field. */ - -/* Bit 3 : Ready status. */ -#define QSPI_STATUS_READY_Pos (3UL) /*!< Position of READY field. */ -#define QSPI_STATUS_READY_Msk (0x1UL << QSPI_STATUS_READY_Pos) /*!< Bit mask of READY field. */ -#define QSPI_STATUS_READY_BUSY (0UL) /*!< QSPI peripheral is busy. It is not allowed to trigger any new tasks, writing custom instructions or enter/exit DPM. */ -#define QSPI_STATUS_READY_READY (1UL) /*!< QSPI peripheral is ready. It is allowed to trigger new tasks, writing custom instructions or enter/exit DPM. */ - -/* Bit 2 : Deep power-down mode (DPM) status of external flash. */ -#define QSPI_STATUS_DPM_Pos (2UL) /*!< Position of DPM field. */ -#define QSPI_STATUS_DPM_Msk (0x1UL << QSPI_STATUS_DPM_Pos) /*!< Bit mask of DPM field. */ -#define QSPI_STATUS_DPM_Disabled (0UL) /*!< External flash is not in DPM. */ -#define QSPI_STATUS_DPM_Enabled (1UL) /*!< External flash is in DPM. */ - -/* Register: QSPI_DPMDUR */ -/* Description: Set the duration required to enter/exit deep power-down mode (DPM). */ - -/* Bits 31..16 : Duration needed by external flash to exit DPM. Duration is given as EXIT * 256 * 62.5 ns. */ -#define QSPI_DPMDUR_EXIT_Pos (16UL) /*!< Position of EXIT field. */ -#define QSPI_DPMDUR_EXIT_Msk (0xFFFFUL << QSPI_DPMDUR_EXIT_Pos) /*!< Bit mask of EXIT field. */ - -/* Bits 15..0 : Duration needed by external flash to enter DPM. Duration is given as ENTER * 256 * 62.5 ns. */ -#define QSPI_DPMDUR_ENTER_Pos (0UL) /*!< Position of ENTER field. */ -#define QSPI_DPMDUR_ENTER_Msk (0xFFFFUL << QSPI_DPMDUR_ENTER_Pos) /*!< Bit mask of ENTER field. */ - -/* Register: QSPI_ADDRCONF */ -/* Description: Extended address configuration. */ - -/* Bit 27 : Send WREN (write enable opcode 0x06) before instruction. */ -#define QSPI_ADDRCONF_WREN_Pos (27UL) /*!< Position of WREN field. */ -#define QSPI_ADDRCONF_WREN_Msk (0x1UL << QSPI_ADDRCONF_WREN_Pos) /*!< Bit mask of WREN field. */ -#define QSPI_ADDRCONF_WREN_Disable (0UL) /*!< Do not send WREN. */ -#define QSPI_ADDRCONF_WREN_Enable (1UL) /*!< Send WREN. */ - -/* Bit 26 : Wait for write complete before sending command. */ -#define QSPI_ADDRCONF_WIPWAIT_Pos (26UL) /*!< Position of WIPWAIT field. */ -#define QSPI_ADDRCONF_WIPWAIT_Msk (0x1UL << QSPI_ADDRCONF_WIPWAIT_Pos) /*!< Bit mask of WIPWAIT field. */ -#define QSPI_ADDRCONF_WIPWAIT_Disable (0UL) /*!< No wait. */ -#define QSPI_ADDRCONF_WIPWAIT_Enable (1UL) /*!< Wait. */ - -/* Bits 25..24 : Extended addressing mode. */ -#define QSPI_ADDRCONF_MODE_Pos (24UL) /*!< Position of MODE field. */ -#define QSPI_ADDRCONF_MODE_Msk (0x3UL << QSPI_ADDRCONF_MODE_Pos) /*!< Bit mask of MODE field. */ -#define QSPI_ADDRCONF_MODE_NoInstr (0UL) /*!< Do not send any instruction. */ -#define QSPI_ADDRCONF_MODE_Opcode (1UL) /*!< Send opcode. */ -#define QSPI_ADDRCONF_MODE_OpByte0 (2UL) /*!< Send opcode, byte0. */ -#define QSPI_ADDRCONF_MODE_All (3UL) /*!< Send opcode, byte0, byte1. */ - -/* Bits 23..16 : Byte 1 following byte 0. */ -#define QSPI_ADDRCONF_BYTE1_Pos (16UL) /*!< Position of BYTE1 field. */ -#define QSPI_ADDRCONF_BYTE1_Msk (0xFFUL << QSPI_ADDRCONF_BYTE1_Pos) /*!< Bit mask of BYTE1 field. */ - -/* Bits 15..8 : Byte 0 following opcode. */ -#define QSPI_ADDRCONF_BYTE0_Pos (8UL) /*!< Position of BYTE0 field. */ -#define QSPI_ADDRCONF_BYTE0_Msk (0xFFUL << QSPI_ADDRCONF_BYTE0_Pos) /*!< Bit mask of BYTE0 field. */ - -/* Bits 7..0 : Opcode that enters the 32-bit addressing mode. */ -#define QSPI_ADDRCONF_OPCODE_Pos (0UL) /*!< Position of OPCODE field. */ -#define QSPI_ADDRCONF_OPCODE_Msk (0xFFUL << QSPI_ADDRCONF_OPCODE_Pos) /*!< Bit mask of OPCODE field. */ - -/* Register: QSPI_CINSTRCONF */ -/* Description: Custom instruction configuration register. */ - -/* Bit 17 : Stop (finalize) long frame transaction */ -#define QSPI_CINSTRCONF_LFSTOP_Pos (17UL) /*!< Position of LFSTOP field. */ -#define QSPI_CINSTRCONF_LFSTOP_Msk (0x1UL << QSPI_CINSTRCONF_LFSTOP_Pos) /*!< Bit mask of LFSTOP field. */ -#define QSPI_CINSTRCONF_LFSTOP_Stop (1UL) /*!< Stop */ - -/* Bit 16 : Enable long frame mode. When enabled, a custom instruction transaction has to be ended by writing the LFSTOP field. */ -#define QSPI_CINSTRCONF_LFEN_Pos (16UL) /*!< Position of LFEN field. */ -#define QSPI_CINSTRCONF_LFEN_Msk (0x1UL << QSPI_CINSTRCONF_LFEN_Pos) /*!< Bit mask of LFEN field. */ -#define QSPI_CINSTRCONF_LFEN_Disable (0UL) /*!< Long frame mode disabled */ -#define QSPI_CINSTRCONF_LFEN_Enable (1UL) /*!< Long frame mode enabled */ - -/* Bit 15 : Send WREN (write enable opcode 0x06) before instruction. */ -#define QSPI_CINSTRCONF_WREN_Pos (15UL) /*!< Position of WREN field. */ -#define QSPI_CINSTRCONF_WREN_Msk (0x1UL << QSPI_CINSTRCONF_WREN_Pos) /*!< Bit mask of WREN field. */ -#define QSPI_CINSTRCONF_WREN_Disable (0UL) /*!< Do not send WREN. */ -#define QSPI_CINSTRCONF_WREN_Enable (1UL) /*!< Send WREN. */ - -/* Bit 14 : Wait for write complete before sending command. */ -#define QSPI_CINSTRCONF_WIPWAIT_Pos (14UL) /*!< Position of WIPWAIT field. */ -#define QSPI_CINSTRCONF_WIPWAIT_Msk (0x1UL << QSPI_CINSTRCONF_WIPWAIT_Pos) /*!< Bit mask of WIPWAIT field. */ -#define QSPI_CINSTRCONF_WIPWAIT_Disable (0UL) /*!< No wait. */ -#define QSPI_CINSTRCONF_WIPWAIT_Enable (1UL) /*!< Wait. */ - -/* Bit 13 : Level of the IO3 pin (if connected) during transmission of custom instruction. */ -#define QSPI_CINSTRCONF_LIO3_Pos (13UL) /*!< Position of LIO3 field. */ -#define QSPI_CINSTRCONF_LIO3_Msk (0x1UL << QSPI_CINSTRCONF_LIO3_Pos) /*!< Bit mask of LIO3 field. */ - -/* Bit 12 : Level of the IO2 pin (if connected) during transmission of custom instruction. */ -#define QSPI_CINSTRCONF_LIO2_Pos (12UL) /*!< Position of LIO2 field. */ -#define QSPI_CINSTRCONF_LIO2_Msk (0x1UL << QSPI_CINSTRCONF_LIO2_Pos) /*!< Bit mask of LIO2 field. */ - -/* Bits 11..8 : Length of custom instruction in number of bytes. */ -#define QSPI_CINSTRCONF_LENGTH_Pos (8UL) /*!< Position of LENGTH field. */ -#define QSPI_CINSTRCONF_LENGTH_Msk (0xFUL << QSPI_CINSTRCONF_LENGTH_Pos) /*!< Bit mask of LENGTH field. */ -#define QSPI_CINSTRCONF_LENGTH_1B (1UL) /*!< Send opcode only. */ -#define QSPI_CINSTRCONF_LENGTH_2B (2UL) /*!< Send opcode, CINSTRDAT0.BYTE0. */ -#define QSPI_CINSTRCONF_LENGTH_3B (3UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT0.BYTE1. */ -#define QSPI_CINSTRCONF_LENGTH_4B (4UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT0.BYTE2. */ -#define QSPI_CINSTRCONF_LENGTH_5B (5UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT0.BYTE3. */ -#define QSPI_CINSTRCONF_LENGTH_6B (6UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE4. */ -#define QSPI_CINSTRCONF_LENGTH_7B (7UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE5. */ -#define QSPI_CINSTRCONF_LENGTH_8B (8UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE6. */ -#define QSPI_CINSTRCONF_LENGTH_9B (9UL) /*!< Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE7. */ - -/* Bits 7..0 : Opcode of Custom instruction. */ -#define QSPI_CINSTRCONF_OPCODE_Pos (0UL) /*!< Position of OPCODE field. */ -#define QSPI_CINSTRCONF_OPCODE_Msk (0xFFUL << QSPI_CINSTRCONF_OPCODE_Pos) /*!< Bit mask of OPCODE field. */ - -/* Register: QSPI_CINSTRDAT0 */ -/* Description: Custom instruction data register 0. */ - -/* Bits 31..24 : Data byte 3 */ -#define QSPI_CINSTRDAT0_BYTE3_Pos (24UL) /*!< Position of BYTE3 field. */ -#define QSPI_CINSTRDAT0_BYTE3_Msk (0xFFUL << QSPI_CINSTRDAT0_BYTE3_Pos) /*!< Bit mask of BYTE3 field. */ - -/* Bits 23..16 : Data byte 2 */ -#define QSPI_CINSTRDAT0_BYTE2_Pos (16UL) /*!< Position of BYTE2 field. */ -#define QSPI_CINSTRDAT0_BYTE2_Msk (0xFFUL << QSPI_CINSTRDAT0_BYTE2_Pos) /*!< Bit mask of BYTE2 field. */ - -/* Bits 15..8 : Data byte 1 */ -#define QSPI_CINSTRDAT0_BYTE1_Pos (8UL) /*!< Position of BYTE1 field. */ -#define QSPI_CINSTRDAT0_BYTE1_Msk (0xFFUL << QSPI_CINSTRDAT0_BYTE1_Pos) /*!< Bit mask of BYTE1 field. */ - -/* Bits 7..0 : Data byte 0 */ -#define QSPI_CINSTRDAT0_BYTE0_Pos (0UL) /*!< Position of BYTE0 field. */ -#define QSPI_CINSTRDAT0_BYTE0_Msk (0xFFUL << QSPI_CINSTRDAT0_BYTE0_Pos) /*!< Bit mask of BYTE0 field. */ - -/* Register: QSPI_CINSTRDAT1 */ -/* Description: Custom instruction data register 1. */ - -/* Bits 31..24 : Data byte 7 */ -#define QSPI_CINSTRDAT1_BYTE7_Pos (24UL) /*!< Position of BYTE7 field. */ -#define QSPI_CINSTRDAT1_BYTE7_Msk (0xFFUL << QSPI_CINSTRDAT1_BYTE7_Pos) /*!< Bit mask of BYTE7 field. */ - -/* Bits 23..16 : Data byte 6 */ -#define QSPI_CINSTRDAT1_BYTE6_Pos (16UL) /*!< Position of BYTE6 field. */ -#define QSPI_CINSTRDAT1_BYTE6_Msk (0xFFUL << QSPI_CINSTRDAT1_BYTE6_Pos) /*!< Bit mask of BYTE6 field. */ - -/* Bits 15..8 : Data byte 5 */ -#define QSPI_CINSTRDAT1_BYTE5_Pos (8UL) /*!< Position of BYTE5 field. */ -#define QSPI_CINSTRDAT1_BYTE5_Msk (0xFFUL << QSPI_CINSTRDAT1_BYTE5_Pos) /*!< Bit mask of BYTE5 field. */ - -/* Bits 7..0 : Data byte 4 */ -#define QSPI_CINSTRDAT1_BYTE4_Pos (0UL) /*!< Position of BYTE4 field. */ -#define QSPI_CINSTRDAT1_BYTE4_Msk (0xFFUL << QSPI_CINSTRDAT1_BYTE4_Pos) /*!< Bit mask of BYTE4 field. */ - -/* Register: QSPI_IFTIMING */ -/* Description: SPI interface timing. */ - -/* Bits 10..8 : Timing related to sampling of the input serial data. The value of RXDELAY specifies the number of 64 MHz cycles (15.625 ns) delay from the the rising edge of the SPI Clock (SCK) until the input serial data is sampled. As en example, if set to 0 the input serial data is sampled on the rising edge of SCK. */ -#define QSPI_IFTIMING_RXDELAY_Pos (8UL) /*!< Position of RXDELAY field. */ -#define QSPI_IFTIMING_RXDELAY_Msk (0x7UL << QSPI_IFTIMING_RXDELAY_Pos) /*!< Bit mask of RXDELAY field. */ - - -/* Peripheral: RADIO */ -/* Description: 2.4 GHz Radio */ - -/* Register: RADIO_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 21 : Shortcut between PHYEND event and START task */ -#define RADIO_SHORTS_PHYEND_START_Pos (21UL) /*!< Position of PHYEND_START field. */ -#define RADIO_SHORTS_PHYEND_START_Msk (0x1UL << RADIO_SHORTS_PHYEND_START_Pos) /*!< Bit mask of PHYEND_START field. */ -#define RADIO_SHORTS_PHYEND_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_PHYEND_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 20 : Shortcut between PHYEND event and DISABLE task */ -#define RADIO_SHORTS_PHYEND_DISABLE_Pos (20UL) /*!< Position of PHYEND_DISABLE field. */ -#define RADIO_SHORTS_PHYEND_DISABLE_Msk (0x1UL << RADIO_SHORTS_PHYEND_DISABLE_Pos) /*!< Bit mask of PHYEND_DISABLE field. */ -#define RADIO_SHORTS_PHYEND_DISABLE_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_PHYEND_DISABLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 19 : Shortcut between RXREADY event and START task */ -#define RADIO_SHORTS_RXREADY_START_Pos (19UL) /*!< Position of RXREADY_START field. */ -#define RADIO_SHORTS_RXREADY_START_Msk (0x1UL << RADIO_SHORTS_RXREADY_START_Pos) /*!< Bit mask of RXREADY_START field. */ -#define RADIO_SHORTS_RXREADY_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_RXREADY_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 18 : Shortcut between TXREADY event and START task */ -#define RADIO_SHORTS_TXREADY_START_Pos (18UL) /*!< Position of TXREADY_START field. */ -#define RADIO_SHORTS_TXREADY_START_Msk (0x1UL << RADIO_SHORTS_TXREADY_START_Pos) /*!< Bit mask of TXREADY_START field. */ -#define RADIO_SHORTS_TXREADY_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_TXREADY_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 17 : Shortcut between CCAIDLE event and STOP task */ -#define RADIO_SHORTS_CCAIDLE_STOP_Pos (17UL) /*!< Position of CCAIDLE_STOP field. */ -#define RADIO_SHORTS_CCAIDLE_STOP_Msk (0x1UL << RADIO_SHORTS_CCAIDLE_STOP_Pos) /*!< Bit mask of CCAIDLE_STOP field. */ -#define RADIO_SHORTS_CCAIDLE_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_CCAIDLE_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 16 : Shortcut between EDEND event and DISABLE task */ -#define RADIO_SHORTS_EDEND_DISABLE_Pos (16UL) /*!< Position of EDEND_DISABLE field. */ -#define RADIO_SHORTS_EDEND_DISABLE_Msk (0x1UL << RADIO_SHORTS_EDEND_DISABLE_Pos) /*!< Bit mask of EDEND_DISABLE field. */ -#define RADIO_SHORTS_EDEND_DISABLE_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_EDEND_DISABLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 15 : Shortcut between READY event and EDSTART task */ -#define RADIO_SHORTS_READY_EDSTART_Pos (15UL) /*!< Position of READY_EDSTART field. */ -#define RADIO_SHORTS_READY_EDSTART_Msk (0x1UL << RADIO_SHORTS_READY_EDSTART_Pos) /*!< Bit mask of READY_EDSTART field. */ -#define RADIO_SHORTS_READY_EDSTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_READY_EDSTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 14 : Shortcut between FRAMESTART event and BCSTART task */ -#define RADIO_SHORTS_FRAMESTART_BCSTART_Pos (14UL) /*!< Position of FRAMESTART_BCSTART field. */ -#define RADIO_SHORTS_FRAMESTART_BCSTART_Msk (0x1UL << RADIO_SHORTS_FRAMESTART_BCSTART_Pos) /*!< Bit mask of FRAMESTART_BCSTART field. */ -#define RADIO_SHORTS_FRAMESTART_BCSTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_FRAMESTART_BCSTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 13 : Shortcut between CCABUSY event and DISABLE task */ -#define RADIO_SHORTS_CCABUSY_DISABLE_Pos (13UL) /*!< Position of CCABUSY_DISABLE field. */ -#define RADIO_SHORTS_CCABUSY_DISABLE_Msk (0x1UL << RADIO_SHORTS_CCABUSY_DISABLE_Pos) /*!< Bit mask of CCABUSY_DISABLE field. */ -#define RADIO_SHORTS_CCABUSY_DISABLE_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_CCABUSY_DISABLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 12 : Shortcut between CCAIDLE event and TXEN task */ -#define RADIO_SHORTS_CCAIDLE_TXEN_Pos (12UL) /*!< Position of CCAIDLE_TXEN field. */ -#define RADIO_SHORTS_CCAIDLE_TXEN_Msk (0x1UL << RADIO_SHORTS_CCAIDLE_TXEN_Pos) /*!< Bit mask of CCAIDLE_TXEN field. */ -#define RADIO_SHORTS_CCAIDLE_TXEN_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_CCAIDLE_TXEN_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 11 : Shortcut between RXREADY event and CCASTART task */ -#define RADIO_SHORTS_RXREADY_CCASTART_Pos (11UL) /*!< Position of RXREADY_CCASTART field. */ -#define RADIO_SHORTS_RXREADY_CCASTART_Msk (0x1UL << RADIO_SHORTS_RXREADY_CCASTART_Pos) /*!< Bit mask of RXREADY_CCASTART field. */ -#define RADIO_SHORTS_RXREADY_CCASTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_RXREADY_CCASTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 8 : Shortcut between DISABLED event and RSSISTOP task */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Pos (8UL) /*!< Position of DISABLED_RSSISTOP field. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Msk (0x1UL << RADIO_SHORTS_DISABLED_RSSISTOP_Pos) /*!< Bit mask of DISABLED_RSSISTOP field. */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_DISABLED_RSSISTOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 6 : Shortcut between ADDRESS event and BCSTART task */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Pos (6UL) /*!< Position of ADDRESS_BCSTART field. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Msk (0x1UL << RADIO_SHORTS_ADDRESS_BCSTART_Pos) /*!< Bit mask of ADDRESS_BCSTART field. */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_ADDRESS_BCSTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between END event and START task */ -#define RADIO_SHORTS_END_START_Pos (5UL) /*!< Position of END_START field. */ -#define RADIO_SHORTS_END_START_Msk (0x1UL << RADIO_SHORTS_END_START_Pos) /*!< Bit mask of END_START field. */ -#define RADIO_SHORTS_END_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_END_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 4 : Shortcut between ADDRESS event and RSSISTART task */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Pos (4UL) /*!< Position of ADDRESS_RSSISTART field. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Msk (0x1UL << RADIO_SHORTS_ADDRESS_RSSISTART_Pos) /*!< Bit mask of ADDRESS_RSSISTART field. */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_ADDRESS_RSSISTART_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between DISABLED event and RXEN task */ -#define RADIO_SHORTS_DISABLED_RXEN_Pos (3UL) /*!< Position of DISABLED_RXEN field. */ -#define RADIO_SHORTS_DISABLED_RXEN_Msk (0x1UL << RADIO_SHORTS_DISABLED_RXEN_Pos) /*!< Bit mask of DISABLED_RXEN field. */ -#define RADIO_SHORTS_DISABLED_RXEN_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_DISABLED_RXEN_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between DISABLED event and TXEN task */ -#define RADIO_SHORTS_DISABLED_TXEN_Pos (2UL) /*!< Position of DISABLED_TXEN field. */ -#define RADIO_SHORTS_DISABLED_TXEN_Msk (0x1UL << RADIO_SHORTS_DISABLED_TXEN_Pos) /*!< Bit mask of DISABLED_TXEN field. */ -#define RADIO_SHORTS_DISABLED_TXEN_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_DISABLED_TXEN_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between END event and DISABLE task */ -#define RADIO_SHORTS_END_DISABLE_Pos (1UL) /*!< Position of END_DISABLE field. */ -#define RADIO_SHORTS_END_DISABLE_Msk (0x1UL << RADIO_SHORTS_END_DISABLE_Pos) /*!< Bit mask of END_DISABLE field. */ -#define RADIO_SHORTS_END_DISABLE_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_END_DISABLE_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between READY event and START task */ -#define RADIO_SHORTS_READY_START_Pos (0UL) /*!< Position of READY_START field. */ -#define RADIO_SHORTS_READY_START_Msk (0x1UL << RADIO_SHORTS_READY_START_Pos) /*!< Bit mask of READY_START field. */ -#define RADIO_SHORTS_READY_START_Disabled (0UL) /*!< Disable shortcut */ -#define RADIO_SHORTS_READY_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: RADIO_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 27 : Write '1' to Enable interrupt for PHYEND event */ -#define RADIO_INTENSET_PHYEND_Pos (27UL) /*!< Position of PHYEND field. */ -#define RADIO_INTENSET_PHYEND_Msk (0x1UL << RADIO_INTENSET_PHYEND_Pos) /*!< Bit mask of PHYEND field. */ -#define RADIO_INTENSET_PHYEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_PHYEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_PHYEND_Set (1UL) /*!< Enable */ - -/* Bit 23 : Write '1' to Enable interrupt for MHRMATCH event */ -#define RADIO_INTENSET_MHRMATCH_Pos (23UL) /*!< Position of MHRMATCH field. */ -#define RADIO_INTENSET_MHRMATCH_Msk (0x1UL << RADIO_INTENSET_MHRMATCH_Pos) /*!< Bit mask of MHRMATCH field. */ -#define RADIO_INTENSET_MHRMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_MHRMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_MHRMATCH_Set (1UL) /*!< Enable */ - -/* Bit 22 : Write '1' to Enable interrupt for RXREADY event */ -#define RADIO_INTENSET_RXREADY_Pos (22UL) /*!< Position of RXREADY field. */ -#define RADIO_INTENSET_RXREADY_Msk (0x1UL << RADIO_INTENSET_RXREADY_Pos) /*!< Bit mask of RXREADY field. */ -#define RADIO_INTENSET_RXREADY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_RXREADY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_RXREADY_Set (1UL) /*!< Enable */ - -/* Bit 21 : Write '1' to Enable interrupt for TXREADY event */ -#define RADIO_INTENSET_TXREADY_Pos (21UL) /*!< Position of TXREADY field. */ -#define RADIO_INTENSET_TXREADY_Msk (0x1UL << RADIO_INTENSET_TXREADY_Pos) /*!< Bit mask of TXREADY field. */ -#define RADIO_INTENSET_TXREADY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_TXREADY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_TXREADY_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for RATEBOOST event */ -#define RADIO_INTENSET_RATEBOOST_Pos (20UL) /*!< Position of RATEBOOST field. */ -#define RADIO_INTENSET_RATEBOOST_Msk (0x1UL << RADIO_INTENSET_RATEBOOST_Pos) /*!< Bit mask of RATEBOOST field. */ -#define RADIO_INTENSET_RATEBOOST_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_RATEBOOST_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_RATEBOOST_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for CCASTOPPED event */ -#define RADIO_INTENSET_CCASTOPPED_Pos (19UL) /*!< Position of CCASTOPPED field. */ -#define RADIO_INTENSET_CCASTOPPED_Msk (0x1UL << RADIO_INTENSET_CCASTOPPED_Pos) /*!< Bit mask of CCASTOPPED field. */ -#define RADIO_INTENSET_CCASTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CCASTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CCASTOPPED_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for CCABUSY event */ -#define RADIO_INTENSET_CCABUSY_Pos (18UL) /*!< Position of CCABUSY field. */ -#define RADIO_INTENSET_CCABUSY_Msk (0x1UL << RADIO_INTENSET_CCABUSY_Pos) /*!< Bit mask of CCABUSY field. */ -#define RADIO_INTENSET_CCABUSY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CCABUSY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CCABUSY_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for CCAIDLE event */ -#define RADIO_INTENSET_CCAIDLE_Pos (17UL) /*!< Position of CCAIDLE field. */ -#define RADIO_INTENSET_CCAIDLE_Msk (0x1UL << RADIO_INTENSET_CCAIDLE_Pos) /*!< Bit mask of CCAIDLE field. */ -#define RADIO_INTENSET_CCAIDLE_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CCAIDLE_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CCAIDLE_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for EDSTOPPED event */ -#define RADIO_INTENSET_EDSTOPPED_Pos (16UL) /*!< Position of EDSTOPPED field. */ -#define RADIO_INTENSET_EDSTOPPED_Msk (0x1UL << RADIO_INTENSET_EDSTOPPED_Pos) /*!< Bit mask of EDSTOPPED field. */ -#define RADIO_INTENSET_EDSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_EDSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_EDSTOPPED_Set (1UL) /*!< Enable */ - -/* Bit 15 : Write '1' to Enable interrupt for EDEND event */ -#define RADIO_INTENSET_EDEND_Pos (15UL) /*!< Position of EDEND field. */ -#define RADIO_INTENSET_EDEND_Msk (0x1UL << RADIO_INTENSET_EDEND_Pos) /*!< Bit mask of EDEND field. */ -#define RADIO_INTENSET_EDEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_EDEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_EDEND_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for FRAMESTART event */ -#define RADIO_INTENSET_FRAMESTART_Pos (14UL) /*!< Position of FRAMESTART field. */ -#define RADIO_INTENSET_FRAMESTART_Msk (0x1UL << RADIO_INTENSET_FRAMESTART_Pos) /*!< Bit mask of FRAMESTART field. */ -#define RADIO_INTENSET_FRAMESTART_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_FRAMESTART_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_FRAMESTART_Set (1UL) /*!< Enable */ - -/* Bit 13 : Write '1' to Enable interrupt for CRCERROR event */ -#define RADIO_INTENSET_CRCERROR_Pos (13UL) /*!< Position of CRCERROR field. */ -#define RADIO_INTENSET_CRCERROR_Msk (0x1UL << RADIO_INTENSET_CRCERROR_Pos) /*!< Bit mask of CRCERROR field. */ -#define RADIO_INTENSET_CRCERROR_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CRCERROR_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CRCERROR_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for CRCOK event */ -#define RADIO_INTENSET_CRCOK_Pos (12UL) /*!< Position of CRCOK field. */ -#define RADIO_INTENSET_CRCOK_Msk (0x1UL << RADIO_INTENSET_CRCOK_Pos) /*!< Bit mask of CRCOK field. */ -#define RADIO_INTENSET_CRCOK_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_CRCOK_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_CRCOK_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for BCMATCH event */ -#define RADIO_INTENSET_BCMATCH_Pos (10UL) /*!< Position of BCMATCH field. */ -#define RADIO_INTENSET_BCMATCH_Msk (0x1UL << RADIO_INTENSET_BCMATCH_Pos) /*!< Bit mask of BCMATCH field. */ -#define RADIO_INTENSET_BCMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_BCMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_BCMATCH_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for RSSIEND event */ -#define RADIO_INTENSET_RSSIEND_Pos (7UL) /*!< Position of RSSIEND field. */ -#define RADIO_INTENSET_RSSIEND_Msk (0x1UL << RADIO_INTENSET_RSSIEND_Pos) /*!< Bit mask of RSSIEND field. */ -#define RADIO_INTENSET_RSSIEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_RSSIEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_RSSIEND_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for DEVMISS event */ -#define RADIO_INTENSET_DEVMISS_Pos (6UL) /*!< Position of DEVMISS field. */ -#define RADIO_INTENSET_DEVMISS_Msk (0x1UL << RADIO_INTENSET_DEVMISS_Pos) /*!< Bit mask of DEVMISS field. */ -#define RADIO_INTENSET_DEVMISS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_DEVMISS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_DEVMISS_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for DEVMATCH event */ -#define RADIO_INTENSET_DEVMATCH_Pos (5UL) /*!< Position of DEVMATCH field. */ -#define RADIO_INTENSET_DEVMATCH_Msk (0x1UL << RADIO_INTENSET_DEVMATCH_Pos) /*!< Bit mask of DEVMATCH field. */ -#define RADIO_INTENSET_DEVMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_DEVMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_DEVMATCH_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for DISABLED event */ -#define RADIO_INTENSET_DISABLED_Pos (4UL) /*!< Position of DISABLED field. */ -#define RADIO_INTENSET_DISABLED_Msk (0x1UL << RADIO_INTENSET_DISABLED_Pos) /*!< Bit mask of DISABLED field. */ -#define RADIO_INTENSET_DISABLED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_DISABLED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_DISABLED_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for END event */ -#define RADIO_INTENSET_END_Pos (3UL) /*!< Position of END field. */ -#define RADIO_INTENSET_END_Msk (0x1UL << RADIO_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define RADIO_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for PAYLOAD event */ -#define RADIO_INTENSET_PAYLOAD_Pos (2UL) /*!< Position of PAYLOAD field. */ -#define RADIO_INTENSET_PAYLOAD_Msk (0x1UL << RADIO_INTENSET_PAYLOAD_Pos) /*!< Bit mask of PAYLOAD field. */ -#define RADIO_INTENSET_PAYLOAD_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_PAYLOAD_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_PAYLOAD_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for ADDRESS event */ -#define RADIO_INTENSET_ADDRESS_Pos (1UL) /*!< Position of ADDRESS field. */ -#define RADIO_INTENSET_ADDRESS_Msk (0x1UL << RADIO_INTENSET_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ -#define RADIO_INTENSET_ADDRESS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_ADDRESS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_ADDRESS_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for READY event */ -#define RADIO_INTENSET_READY_Pos (0UL) /*!< Position of READY field. */ -#define RADIO_INTENSET_READY_Msk (0x1UL << RADIO_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define RADIO_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: RADIO_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 27 : Write '1' to Disable interrupt for PHYEND event */ -#define RADIO_INTENCLR_PHYEND_Pos (27UL) /*!< Position of PHYEND field. */ -#define RADIO_INTENCLR_PHYEND_Msk (0x1UL << RADIO_INTENCLR_PHYEND_Pos) /*!< Bit mask of PHYEND field. */ -#define RADIO_INTENCLR_PHYEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_PHYEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_PHYEND_Clear (1UL) /*!< Disable */ - -/* Bit 23 : Write '1' to Disable interrupt for MHRMATCH event */ -#define RADIO_INTENCLR_MHRMATCH_Pos (23UL) /*!< Position of MHRMATCH field. */ -#define RADIO_INTENCLR_MHRMATCH_Msk (0x1UL << RADIO_INTENCLR_MHRMATCH_Pos) /*!< Bit mask of MHRMATCH field. */ -#define RADIO_INTENCLR_MHRMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_MHRMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_MHRMATCH_Clear (1UL) /*!< Disable */ - -/* Bit 22 : Write '1' to Disable interrupt for RXREADY event */ -#define RADIO_INTENCLR_RXREADY_Pos (22UL) /*!< Position of RXREADY field. */ -#define RADIO_INTENCLR_RXREADY_Msk (0x1UL << RADIO_INTENCLR_RXREADY_Pos) /*!< Bit mask of RXREADY field. */ -#define RADIO_INTENCLR_RXREADY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_RXREADY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_RXREADY_Clear (1UL) /*!< Disable */ - -/* Bit 21 : Write '1' to Disable interrupt for TXREADY event */ -#define RADIO_INTENCLR_TXREADY_Pos (21UL) /*!< Position of TXREADY field. */ -#define RADIO_INTENCLR_TXREADY_Msk (0x1UL << RADIO_INTENCLR_TXREADY_Pos) /*!< Bit mask of TXREADY field. */ -#define RADIO_INTENCLR_TXREADY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_TXREADY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_TXREADY_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for RATEBOOST event */ -#define RADIO_INTENCLR_RATEBOOST_Pos (20UL) /*!< Position of RATEBOOST field. */ -#define RADIO_INTENCLR_RATEBOOST_Msk (0x1UL << RADIO_INTENCLR_RATEBOOST_Pos) /*!< Bit mask of RATEBOOST field. */ -#define RADIO_INTENCLR_RATEBOOST_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_RATEBOOST_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_RATEBOOST_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for CCASTOPPED event */ -#define RADIO_INTENCLR_CCASTOPPED_Pos (19UL) /*!< Position of CCASTOPPED field. */ -#define RADIO_INTENCLR_CCASTOPPED_Msk (0x1UL << RADIO_INTENCLR_CCASTOPPED_Pos) /*!< Bit mask of CCASTOPPED field. */ -#define RADIO_INTENCLR_CCASTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CCASTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CCASTOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for CCABUSY event */ -#define RADIO_INTENCLR_CCABUSY_Pos (18UL) /*!< Position of CCABUSY field. */ -#define RADIO_INTENCLR_CCABUSY_Msk (0x1UL << RADIO_INTENCLR_CCABUSY_Pos) /*!< Bit mask of CCABUSY field. */ -#define RADIO_INTENCLR_CCABUSY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CCABUSY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CCABUSY_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for CCAIDLE event */ -#define RADIO_INTENCLR_CCAIDLE_Pos (17UL) /*!< Position of CCAIDLE field. */ -#define RADIO_INTENCLR_CCAIDLE_Msk (0x1UL << RADIO_INTENCLR_CCAIDLE_Pos) /*!< Bit mask of CCAIDLE field. */ -#define RADIO_INTENCLR_CCAIDLE_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CCAIDLE_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CCAIDLE_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for EDSTOPPED event */ -#define RADIO_INTENCLR_EDSTOPPED_Pos (16UL) /*!< Position of EDSTOPPED field. */ -#define RADIO_INTENCLR_EDSTOPPED_Msk (0x1UL << RADIO_INTENCLR_EDSTOPPED_Pos) /*!< Bit mask of EDSTOPPED field. */ -#define RADIO_INTENCLR_EDSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_EDSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_EDSTOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 15 : Write '1' to Disable interrupt for EDEND event */ -#define RADIO_INTENCLR_EDEND_Pos (15UL) /*!< Position of EDEND field. */ -#define RADIO_INTENCLR_EDEND_Msk (0x1UL << RADIO_INTENCLR_EDEND_Pos) /*!< Bit mask of EDEND field. */ -#define RADIO_INTENCLR_EDEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_EDEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_EDEND_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for FRAMESTART event */ -#define RADIO_INTENCLR_FRAMESTART_Pos (14UL) /*!< Position of FRAMESTART field. */ -#define RADIO_INTENCLR_FRAMESTART_Msk (0x1UL << RADIO_INTENCLR_FRAMESTART_Pos) /*!< Bit mask of FRAMESTART field. */ -#define RADIO_INTENCLR_FRAMESTART_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_FRAMESTART_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_FRAMESTART_Clear (1UL) /*!< Disable */ - -/* Bit 13 : Write '1' to Disable interrupt for CRCERROR event */ -#define RADIO_INTENCLR_CRCERROR_Pos (13UL) /*!< Position of CRCERROR field. */ -#define RADIO_INTENCLR_CRCERROR_Msk (0x1UL << RADIO_INTENCLR_CRCERROR_Pos) /*!< Bit mask of CRCERROR field. */ -#define RADIO_INTENCLR_CRCERROR_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CRCERROR_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CRCERROR_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for CRCOK event */ -#define RADIO_INTENCLR_CRCOK_Pos (12UL) /*!< Position of CRCOK field. */ -#define RADIO_INTENCLR_CRCOK_Msk (0x1UL << RADIO_INTENCLR_CRCOK_Pos) /*!< Bit mask of CRCOK field. */ -#define RADIO_INTENCLR_CRCOK_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_CRCOK_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_CRCOK_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for BCMATCH event */ -#define RADIO_INTENCLR_BCMATCH_Pos (10UL) /*!< Position of BCMATCH field. */ -#define RADIO_INTENCLR_BCMATCH_Msk (0x1UL << RADIO_INTENCLR_BCMATCH_Pos) /*!< Bit mask of BCMATCH field. */ -#define RADIO_INTENCLR_BCMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_BCMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_BCMATCH_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for RSSIEND event */ -#define RADIO_INTENCLR_RSSIEND_Pos (7UL) /*!< Position of RSSIEND field. */ -#define RADIO_INTENCLR_RSSIEND_Msk (0x1UL << RADIO_INTENCLR_RSSIEND_Pos) /*!< Bit mask of RSSIEND field. */ -#define RADIO_INTENCLR_RSSIEND_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_RSSIEND_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_RSSIEND_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for DEVMISS event */ -#define RADIO_INTENCLR_DEVMISS_Pos (6UL) /*!< Position of DEVMISS field. */ -#define RADIO_INTENCLR_DEVMISS_Msk (0x1UL << RADIO_INTENCLR_DEVMISS_Pos) /*!< Bit mask of DEVMISS field. */ -#define RADIO_INTENCLR_DEVMISS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_DEVMISS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_DEVMISS_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for DEVMATCH event */ -#define RADIO_INTENCLR_DEVMATCH_Pos (5UL) /*!< Position of DEVMATCH field. */ -#define RADIO_INTENCLR_DEVMATCH_Msk (0x1UL << RADIO_INTENCLR_DEVMATCH_Pos) /*!< Bit mask of DEVMATCH field. */ -#define RADIO_INTENCLR_DEVMATCH_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_DEVMATCH_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_DEVMATCH_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for DISABLED event */ -#define RADIO_INTENCLR_DISABLED_Pos (4UL) /*!< Position of DISABLED field. */ -#define RADIO_INTENCLR_DISABLED_Msk (0x1UL << RADIO_INTENCLR_DISABLED_Pos) /*!< Bit mask of DISABLED field. */ -#define RADIO_INTENCLR_DISABLED_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_DISABLED_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_DISABLED_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for END event */ -#define RADIO_INTENCLR_END_Pos (3UL) /*!< Position of END field. */ -#define RADIO_INTENCLR_END_Msk (0x1UL << RADIO_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define RADIO_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for PAYLOAD event */ -#define RADIO_INTENCLR_PAYLOAD_Pos (2UL) /*!< Position of PAYLOAD field. */ -#define RADIO_INTENCLR_PAYLOAD_Msk (0x1UL << RADIO_INTENCLR_PAYLOAD_Pos) /*!< Bit mask of PAYLOAD field. */ -#define RADIO_INTENCLR_PAYLOAD_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_PAYLOAD_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_PAYLOAD_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for ADDRESS event */ -#define RADIO_INTENCLR_ADDRESS_Pos (1UL) /*!< Position of ADDRESS field. */ -#define RADIO_INTENCLR_ADDRESS_Msk (0x1UL << RADIO_INTENCLR_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ -#define RADIO_INTENCLR_ADDRESS_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_ADDRESS_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_ADDRESS_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for READY event */ -#define RADIO_INTENCLR_READY_Pos (0UL) /*!< Position of READY field. */ -#define RADIO_INTENCLR_READY_Msk (0x1UL << RADIO_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define RADIO_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define RADIO_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define RADIO_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: RADIO_CRCSTATUS */ -/* Description: CRC status */ - -/* Bit 0 : CRC status of packet received */ -#define RADIO_CRCSTATUS_CRCSTATUS_Pos (0UL) /*!< Position of CRCSTATUS field. */ -#define RADIO_CRCSTATUS_CRCSTATUS_Msk (0x1UL << RADIO_CRCSTATUS_CRCSTATUS_Pos) /*!< Bit mask of CRCSTATUS field. */ -#define RADIO_CRCSTATUS_CRCSTATUS_CRCError (0UL) /*!< Packet received with CRC error */ -#define RADIO_CRCSTATUS_CRCSTATUS_CRCOk (1UL) /*!< Packet received with CRC ok */ - -/* Register: RADIO_RXMATCH */ -/* Description: Received address */ - -/* Bits 2..0 : Received address */ -#define RADIO_RXMATCH_RXMATCH_Pos (0UL) /*!< Position of RXMATCH field. */ -#define RADIO_RXMATCH_RXMATCH_Msk (0x7UL << RADIO_RXMATCH_RXMATCH_Pos) /*!< Bit mask of RXMATCH field. */ - -/* Register: RADIO_RXCRC */ -/* Description: CRC field of previously received packet */ - -/* Bits 23..0 : CRC field of previously received packet */ -#define RADIO_RXCRC_RXCRC_Pos (0UL) /*!< Position of RXCRC field. */ -#define RADIO_RXCRC_RXCRC_Msk (0xFFFFFFUL << RADIO_RXCRC_RXCRC_Pos) /*!< Bit mask of RXCRC field. */ - -/* Register: RADIO_DAI */ -/* Description: Device address match index */ - -/* Bits 2..0 : Device address match index */ -#define RADIO_DAI_DAI_Pos (0UL) /*!< Position of DAI field. */ -#define RADIO_DAI_DAI_Msk (0x7UL << RADIO_DAI_DAI_Pos) /*!< Bit mask of DAI field. */ - -/* Register: RADIO_PDUSTAT */ -/* Description: Payload status */ - -/* Bits 2..1 : Status on what rate packet is received with in Long Range */ -#define RADIO_PDUSTAT_CISTAT_Pos (1UL) /*!< Position of CISTAT field. */ -#define RADIO_PDUSTAT_CISTAT_Msk (0x3UL << RADIO_PDUSTAT_CISTAT_Pos) /*!< Bit mask of CISTAT field. */ -#define RADIO_PDUSTAT_CISTAT_LR125kbit (0UL) /*!< Frame is received at 125kbps */ -#define RADIO_PDUSTAT_CISTAT_LR500kbit (1UL) /*!< Frame is received at 500kbps */ - -/* Bit 0 : Status on payload length vs. PCNF1.MAXLEN */ -#define RADIO_PDUSTAT_PDUSTAT_Pos (0UL) /*!< Position of PDUSTAT field. */ -#define RADIO_PDUSTAT_PDUSTAT_Msk (0x1UL << RADIO_PDUSTAT_PDUSTAT_Pos) /*!< Bit mask of PDUSTAT field. */ -#define RADIO_PDUSTAT_PDUSTAT_LessThan (0UL) /*!< Payload less than PCNF1.MAXLEN */ -#define RADIO_PDUSTAT_PDUSTAT_GreaterThan (1UL) /*!< Payload greater than PCNF1.MAXLEN */ - -/* Register: RADIO_PACKETPTR */ -/* Description: Packet pointer */ - -/* Bits 31..0 : Packet pointer */ -#define RADIO_PACKETPTR_PACKETPTR_Pos (0UL) /*!< Position of PACKETPTR field. */ -#define RADIO_PACKETPTR_PACKETPTR_Msk (0xFFFFFFFFUL << RADIO_PACKETPTR_PACKETPTR_Pos) /*!< Bit mask of PACKETPTR field. */ - -/* Register: RADIO_FREQUENCY */ -/* Description: Frequency */ - -/* Bit 8 : Channel map selection. */ -#define RADIO_FREQUENCY_MAP_Pos (8UL) /*!< Position of MAP field. */ -#define RADIO_FREQUENCY_MAP_Msk (0x1UL << RADIO_FREQUENCY_MAP_Pos) /*!< Bit mask of MAP field. */ -#define RADIO_FREQUENCY_MAP_Default (0UL) /*!< Channel map between 2400 MHZ .. 2500 MHz */ -#define RADIO_FREQUENCY_MAP_Low (1UL) /*!< Channel map between 2360 MHZ .. 2460 MHz */ - -/* Bits 6..0 : Radio channel frequency */ -#define RADIO_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define RADIO_FREQUENCY_FREQUENCY_Msk (0x7FUL << RADIO_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ - -/* Register: RADIO_TXPOWER */ -/* Description: Output power */ - -/* Bits 7..0 : RADIO output power. */ -#define RADIO_TXPOWER_TXPOWER_Pos (0UL) /*!< Position of TXPOWER field. */ -#define RADIO_TXPOWER_TXPOWER_Msk (0xFFUL << RADIO_TXPOWER_TXPOWER_Pos) /*!< Bit mask of TXPOWER field. */ -#define RADIO_TXPOWER_TXPOWER_0dBm (0x0UL) /*!< 0 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos2dBm (0x2UL) /*!< +2 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos3dBm (0x3UL) /*!< +3 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos4dBm (0x4UL) /*!< +4 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos5dBm (0x5UL) /*!< +5 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos6dBm (0x6UL) /*!< +6 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos7dBm (0x7UL) /*!< +7 dBm */ -#define RADIO_TXPOWER_TXPOWER_Pos8dBm (0x8UL) /*!< +8 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg30dBm (0xD8UL) /*!< Deprecated enumerator - -40 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg40dBm (0xD8UL) /*!< -40 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg20dBm (0xECUL) /*!< -20 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg16dBm (0xF0UL) /*!< -16 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg12dBm (0xF4UL) /*!< -12 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg8dBm (0xF8UL) /*!< -8 dBm */ -#define RADIO_TXPOWER_TXPOWER_Neg4dBm (0xFCUL) /*!< -4 dBm */ - -/* Register: RADIO_MODE */ -/* Description: Data rate and modulation */ - -/* Bits 3..0 : Radio data rate and modulation setting. The radio supports Frequency-shift Keying (FSK) modulation. */ -#define RADIO_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define RADIO_MODE_MODE_Msk (0xFUL << RADIO_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define RADIO_MODE_MODE_Nrf_1Mbit (0UL) /*!< 1 Mbit/s Nordic proprietary radio mode */ -#define RADIO_MODE_MODE_Nrf_2Mbit (1UL) /*!< 2 Mbit/s Nordic proprietary radio mode */ -#define RADIO_MODE_MODE_Ble_1Mbit (3UL) /*!< 1 Mbit/s Bluetooth Low Energy */ -#define RADIO_MODE_MODE_Ble_2Mbit (4UL) /*!< 2 Mbit/s Bluetooth Low Energy */ -#define RADIO_MODE_MODE_Ble_LR125Kbit (5UL) /*!< Long range 125 kbit/s (TX Only - RX supports both) */ -#define RADIO_MODE_MODE_Ble_LR500Kbit (6UL) /*!< Long range 500 kbit/s (TX Only - RX supports both) */ -#define RADIO_MODE_MODE_Ieee802154_250Kbit (15UL) /*!< IEEE 802.15.4-2006 250 kbit/s */ - -/* Register: RADIO_PCNF0 */ -/* Description: Packet configuration register 0 */ - -/* Bits 30..29 : Length of TERM field in Long Range operation */ -#define RADIO_PCNF0_TERMLEN_Pos (29UL) /*!< Position of TERMLEN field. */ -#define RADIO_PCNF0_TERMLEN_Msk (0x3UL << RADIO_PCNF0_TERMLEN_Pos) /*!< Bit mask of TERMLEN field. */ - -/* Bit 26 : Indicates if LENGTH field contains CRC or not */ -#define RADIO_PCNF0_CRCINC_Pos (26UL) /*!< Position of CRCINC field. */ -#define RADIO_PCNF0_CRCINC_Msk (0x1UL << RADIO_PCNF0_CRCINC_Pos) /*!< Bit mask of CRCINC field. */ -#define RADIO_PCNF0_CRCINC_Exclude (0UL) /*!< LENGTH does not contain CRC */ -#define RADIO_PCNF0_CRCINC_Include (1UL) /*!< LENGTH includes CRC */ - -/* Bits 25..24 : Length of preamble on air. Decision point: TASKS_START task */ -#define RADIO_PCNF0_PLEN_Pos (24UL) /*!< Position of PLEN field. */ -#define RADIO_PCNF0_PLEN_Msk (0x3UL << RADIO_PCNF0_PLEN_Pos) /*!< Bit mask of PLEN field. */ -#define RADIO_PCNF0_PLEN_8bit (0UL) /*!< 8-bit preamble */ -#define RADIO_PCNF0_PLEN_16bit (1UL) /*!< 16-bit preamble */ -#define RADIO_PCNF0_PLEN_32bitZero (2UL) /*!< 32-bit zero preamble - used for IEEE 802.15.4 */ -#define RADIO_PCNF0_PLEN_LongRange (3UL) /*!< Preamble - used for BTLE Long Range */ - -/* Bits 23..22 : Length of Code Indicator - Long Range */ -#define RADIO_PCNF0_CILEN_Pos (22UL) /*!< Position of CILEN field. */ -#define RADIO_PCNF0_CILEN_Msk (0x3UL << RADIO_PCNF0_CILEN_Pos) /*!< Bit mask of CILEN field. */ - -/* Bit 20 : Include or exclude S1 field in RAM */ -#define RADIO_PCNF0_S1INCL_Pos (20UL) /*!< Position of S1INCL field. */ -#define RADIO_PCNF0_S1INCL_Msk (0x1UL << RADIO_PCNF0_S1INCL_Pos) /*!< Bit mask of S1INCL field. */ -#define RADIO_PCNF0_S1INCL_Automatic (0UL) /*!< Include S1 field in RAM only if S1LEN > 0 */ -#define RADIO_PCNF0_S1INCL_Include (1UL) /*!< Always include S1 field in RAM independent of S1LEN */ - -/* Bits 19..16 : Length on air of S1 field in number of bits. */ -#define RADIO_PCNF0_S1LEN_Pos (16UL) /*!< Position of S1LEN field. */ -#define RADIO_PCNF0_S1LEN_Msk (0xFUL << RADIO_PCNF0_S1LEN_Pos) /*!< Bit mask of S1LEN field. */ - -/* Bit 8 : Length on air of S0 field in number of bytes. */ -#define RADIO_PCNF0_S0LEN_Pos (8UL) /*!< Position of S0LEN field. */ -#define RADIO_PCNF0_S0LEN_Msk (0x1UL << RADIO_PCNF0_S0LEN_Pos) /*!< Bit mask of S0LEN field. */ - -/* Bits 3..0 : Length on air of LENGTH field in number of bits. */ -#define RADIO_PCNF0_LFLEN_Pos (0UL) /*!< Position of LFLEN field. */ -#define RADIO_PCNF0_LFLEN_Msk (0xFUL << RADIO_PCNF0_LFLEN_Pos) /*!< Bit mask of LFLEN field. */ - -/* Register: RADIO_PCNF1 */ -/* Description: Packet configuration register 1 */ - -/* Bit 25 : Enable or disable packet whitening */ -#define RADIO_PCNF1_WHITEEN_Pos (25UL) /*!< Position of WHITEEN field. */ -#define RADIO_PCNF1_WHITEEN_Msk (0x1UL << RADIO_PCNF1_WHITEEN_Pos) /*!< Bit mask of WHITEEN field. */ -#define RADIO_PCNF1_WHITEEN_Disabled (0UL) /*!< Disable */ -#define RADIO_PCNF1_WHITEEN_Enabled (1UL) /*!< Enable */ - -/* Bit 24 : On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields. */ -#define RADIO_PCNF1_ENDIAN_Pos (24UL) /*!< Position of ENDIAN field. */ -#define RADIO_PCNF1_ENDIAN_Msk (0x1UL << RADIO_PCNF1_ENDIAN_Pos) /*!< Bit mask of ENDIAN field. */ -#define RADIO_PCNF1_ENDIAN_Little (0UL) /*!< Least Significant bit on air first */ -#define RADIO_PCNF1_ENDIAN_Big (1UL) /*!< Most significant bit on air first */ - -/* Bits 18..16 : Base address length in number of bytes */ -#define RADIO_PCNF1_BALEN_Pos (16UL) /*!< Position of BALEN field. */ -#define RADIO_PCNF1_BALEN_Msk (0x7UL << RADIO_PCNF1_BALEN_Pos) /*!< Bit mask of BALEN field. */ - -/* Bits 15..8 : Static length in number of bytes */ -#define RADIO_PCNF1_STATLEN_Pos (8UL) /*!< Position of STATLEN field. */ -#define RADIO_PCNF1_STATLEN_Msk (0xFFUL << RADIO_PCNF1_STATLEN_Pos) /*!< Bit mask of STATLEN field. */ - -/* Bits 7..0 : Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN. */ -#define RADIO_PCNF1_MAXLEN_Pos (0UL) /*!< Position of MAXLEN field. */ -#define RADIO_PCNF1_MAXLEN_Msk (0xFFUL << RADIO_PCNF1_MAXLEN_Pos) /*!< Bit mask of MAXLEN field. */ - -/* Register: RADIO_BASE0 */ -/* Description: Base address 0 */ - -/* Bits 31..0 : Base address 0 */ -#define RADIO_BASE0_BASE0_Pos (0UL) /*!< Position of BASE0 field. */ -#define RADIO_BASE0_BASE0_Msk (0xFFFFFFFFUL << RADIO_BASE0_BASE0_Pos) /*!< Bit mask of BASE0 field. */ - -/* Register: RADIO_BASE1 */ -/* Description: Base address 1 */ - -/* Bits 31..0 : Base address 1 */ -#define RADIO_BASE1_BASE1_Pos (0UL) /*!< Position of BASE1 field. */ -#define RADIO_BASE1_BASE1_Msk (0xFFFFFFFFUL << RADIO_BASE1_BASE1_Pos) /*!< Bit mask of BASE1 field. */ - -/* Register: RADIO_PREFIX0 */ -/* Description: Prefixes bytes for logical addresses 0-3 */ - -/* Bits 31..24 : Address prefix 3. */ -#define RADIO_PREFIX0_AP3_Pos (24UL) /*!< Position of AP3 field. */ -#define RADIO_PREFIX0_AP3_Msk (0xFFUL << RADIO_PREFIX0_AP3_Pos) /*!< Bit mask of AP3 field. */ - -/* Bits 23..16 : Address prefix 2. */ -#define RADIO_PREFIX0_AP2_Pos (16UL) /*!< Position of AP2 field. */ -#define RADIO_PREFIX0_AP2_Msk (0xFFUL << RADIO_PREFIX0_AP2_Pos) /*!< Bit mask of AP2 field. */ - -/* Bits 15..8 : Address prefix 1. */ -#define RADIO_PREFIX0_AP1_Pos (8UL) /*!< Position of AP1 field. */ -#define RADIO_PREFIX0_AP1_Msk (0xFFUL << RADIO_PREFIX0_AP1_Pos) /*!< Bit mask of AP1 field. */ - -/* Bits 7..0 : Address prefix 0. */ -#define RADIO_PREFIX0_AP0_Pos (0UL) /*!< Position of AP0 field. */ -#define RADIO_PREFIX0_AP0_Msk (0xFFUL << RADIO_PREFIX0_AP0_Pos) /*!< Bit mask of AP0 field. */ - -/* Register: RADIO_PREFIX1 */ -/* Description: Prefixes bytes for logical addresses 4-7 */ - -/* Bits 31..24 : Address prefix 7. */ -#define RADIO_PREFIX1_AP7_Pos (24UL) /*!< Position of AP7 field. */ -#define RADIO_PREFIX1_AP7_Msk (0xFFUL << RADIO_PREFIX1_AP7_Pos) /*!< Bit mask of AP7 field. */ - -/* Bits 23..16 : Address prefix 6. */ -#define RADIO_PREFIX1_AP6_Pos (16UL) /*!< Position of AP6 field. */ -#define RADIO_PREFIX1_AP6_Msk (0xFFUL << RADIO_PREFIX1_AP6_Pos) /*!< Bit mask of AP6 field. */ - -/* Bits 15..8 : Address prefix 5. */ -#define RADIO_PREFIX1_AP5_Pos (8UL) /*!< Position of AP5 field. */ -#define RADIO_PREFIX1_AP5_Msk (0xFFUL << RADIO_PREFIX1_AP5_Pos) /*!< Bit mask of AP5 field. */ - -/* Bits 7..0 : Address prefix 4. */ -#define RADIO_PREFIX1_AP4_Pos (0UL) /*!< Position of AP4 field. */ -#define RADIO_PREFIX1_AP4_Msk (0xFFUL << RADIO_PREFIX1_AP4_Pos) /*!< Bit mask of AP4 field. */ - -/* Register: RADIO_TXADDRESS */ -/* Description: Transmit address select */ - -/* Bits 2..0 : Transmit address select */ -#define RADIO_TXADDRESS_TXADDRESS_Pos (0UL) /*!< Position of TXADDRESS field. */ -#define RADIO_TXADDRESS_TXADDRESS_Msk (0x7UL << RADIO_TXADDRESS_TXADDRESS_Pos) /*!< Bit mask of TXADDRESS field. */ - -/* Register: RADIO_RXADDRESSES */ -/* Description: Receive address select */ - -/* Bit 7 : Enable or disable reception on logical address 7. */ -#define RADIO_RXADDRESSES_ADDR7_Pos (7UL) /*!< Position of ADDR7 field. */ -#define RADIO_RXADDRESSES_ADDR7_Msk (0x1UL << RADIO_RXADDRESSES_ADDR7_Pos) /*!< Bit mask of ADDR7 field. */ -#define RADIO_RXADDRESSES_ADDR7_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR7_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable reception on logical address 6. */ -#define RADIO_RXADDRESSES_ADDR6_Pos (6UL) /*!< Position of ADDR6 field. */ -#define RADIO_RXADDRESSES_ADDR6_Msk (0x1UL << RADIO_RXADDRESSES_ADDR6_Pos) /*!< Bit mask of ADDR6 field. */ -#define RADIO_RXADDRESSES_ADDR6_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR6_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable reception on logical address 5. */ -#define RADIO_RXADDRESSES_ADDR5_Pos (5UL) /*!< Position of ADDR5 field. */ -#define RADIO_RXADDRESSES_ADDR5_Msk (0x1UL << RADIO_RXADDRESSES_ADDR5_Pos) /*!< Bit mask of ADDR5 field. */ -#define RADIO_RXADDRESSES_ADDR5_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR5_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable reception on logical address 4. */ -#define RADIO_RXADDRESSES_ADDR4_Pos (4UL) /*!< Position of ADDR4 field. */ -#define RADIO_RXADDRESSES_ADDR4_Msk (0x1UL << RADIO_RXADDRESSES_ADDR4_Pos) /*!< Bit mask of ADDR4 field. */ -#define RADIO_RXADDRESSES_ADDR4_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR4_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable reception on logical address 3. */ -#define RADIO_RXADDRESSES_ADDR3_Pos (3UL) /*!< Position of ADDR3 field. */ -#define RADIO_RXADDRESSES_ADDR3_Msk (0x1UL << RADIO_RXADDRESSES_ADDR3_Pos) /*!< Bit mask of ADDR3 field. */ -#define RADIO_RXADDRESSES_ADDR3_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR3_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable reception on logical address 2. */ -#define RADIO_RXADDRESSES_ADDR2_Pos (2UL) /*!< Position of ADDR2 field. */ -#define RADIO_RXADDRESSES_ADDR2_Msk (0x1UL << RADIO_RXADDRESSES_ADDR2_Pos) /*!< Bit mask of ADDR2 field. */ -#define RADIO_RXADDRESSES_ADDR2_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR2_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable reception on logical address 1. */ -#define RADIO_RXADDRESSES_ADDR1_Pos (1UL) /*!< Position of ADDR1 field. */ -#define RADIO_RXADDRESSES_ADDR1_Msk (0x1UL << RADIO_RXADDRESSES_ADDR1_Pos) /*!< Bit mask of ADDR1 field. */ -#define RADIO_RXADDRESSES_ADDR1_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR1_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable reception on logical address 0. */ -#define RADIO_RXADDRESSES_ADDR0_Pos (0UL) /*!< Position of ADDR0 field. */ -#define RADIO_RXADDRESSES_ADDR0_Msk (0x1UL << RADIO_RXADDRESSES_ADDR0_Pos) /*!< Bit mask of ADDR0 field. */ -#define RADIO_RXADDRESSES_ADDR0_Disabled (0UL) /*!< Disable */ -#define RADIO_RXADDRESSES_ADDR0_Enabled (1UL) /*!< Enable */ - -/* Register: RADIO_CRCCNF */ -/* Description: CRC configuration */ - -/* Bits 9..8 : Include or exclude packet address field out of CRC calculation. */ -#define RADIO_CRCCNF_SKIPADDR_Pos (8UL) /*!< Position of SKIPADDR field. */ -#define RADIO_CRCCNF_SKIPADDR_Msk (0x3UL << RADIO_CRCCNF_SKIPADDR_Pos) /*!< Bit mask of SKIPADDR field. */ -#define RADIO_CRCCNF_SKIPADDR_Include (0UL) /*!< CRC calculation includes address field */ -#define RADIO_CRCCNF_SKIPADDR_Skip (1UL) /*!< CRC calculation does not include address field. The CRC calculation will start at the first byte after the address. */ -#define RADIO_CRCCNF_SKIPADDR_Ieee802154 (2UL) /*!< CRC calculation as per 802.15.4 standard. Starting at first byte after length field. */ - -/* Bits 1..0 : CRC length in number of bytes. */ -#define RADIO_CRCCNF_LEN_Pos (0UL) /*!< Position of LEN field. */ -#define RADIO_CRCCNF_LEN_Msk (0x3UL << RADIO_CRCCNF_LEN_Pos) /*!< Bit mask of LEN field. */ -#define RADIO_CRCCNF_LEN_Disabled (0UL) /*!< CRC length is zero and CRC calculation is disabled */ -#define RADIO_CRCCNF_LEN_One (1UL) /*!< CRC length is one byte and CRC calculation is enabled */ -#define RADIO_CRCCNF_LEN_Two (2UL) /*!< CRC length is two bytes and CRC calculation is enabled */ -#define RADIO_CRCCNF_LEN_Three (3UL) /*!< CRC length is three bytes and CRC calculation is enabled */ - -/* Register: RADIO_CRCPOLY */ -/* Description: CRC polynomial */ - -/* Bits 23..0 : CRC polynomial */ -#define RADIO_CRCPOLY_CRCPOLY_Pos (0UL) /*!< Position of CRCPOLY field. */ -#define RADIO_CRCPOLY_CRCPOLY_Msk (0xFFFFFFUL << RADIO_CRCPOLY_CRCPOLY_Pos) /*!< Bit mask of CRCPOLY field. */ - -/* Register: RADIO_CRCINIT */ -/* Description: CRC initial value */ - -/* Bits 23..0 : CRC initial value */ -#define RADIO_CRCINIT_CRCINIT_Pos (0UL) /*!< Position of CRCINIT field. */ -#define RADIO_CRCINIT_CRCINIT_Msk (0xFFFFFFUL << RADIO_CRCINIT_CRCINIT_Pos) /*!< Bit mask of CRCINIT field. */ - -/* Register: RADIO_TIFS */ -/* Description: Inter Frame Spacing in us */ - -/* Bits 9..0 : Inter Frame Spacing in us */ -#define RADIO_TIFS_TIFS_Pos (0UL) /*!< Position of TIFS field. */ -#define RADIO_TIFS_TIFS_Msk (0x3FFUL << RADIO_TIFS_TIFS_Pos) /*!< Bit mask of TIFS field. */ - -/* Register: RADIO_RSSISAMPLE */ -/* Description: RSSI sample */ - -/* Bits 6..0 : RSSI sample */ -#define RADIO_RSSISAMPLE_RSSISAMPLE_Pos (0UL) /*!< Position of RSSISAMPLE field. */ -#define RADIO_RSSISAMPLE_RSSISAMPLE_Msk (0x7FUL << RADIO_RSSISAMPLE_RSSISAMPLE_Pos) /*!< Bit mask of RSSISAMPLE field. */ - -/* Register: RADIO_STATE */ -/* Description: Current radio state */ - -/* Bits 3..0 : Current radio state */ -#define RADIO_STATE_STATE_Pos (0UL) /*!< Position of STATE field. */ -#define RADIO_STATE_STATE_Msk (0xFUL << RADIO_STATE_STATE_Pos) /*!< Bit mask of STATE field. */ -#define RADIO_STATE_STATE_Disabled (0UL) /*!< RADIO is in the Disabled state */ -#define RADIO_STATE_STATE_RxRu (1UL) /*!< RADIO is in the RXRU state */ -#define RADIO_STATE_STATE_RxIdle (2UL) /*!< RADIO is in the RXIDLE state */ -#define RADIO_STATE_STATE_Rx (3UL) /*!< RADIO is in the RX state */ -#define RADIO_STATE_STATE_RxDisable (4UL) /*!< RADIO is in the RXDISABLED state */ -#define RADIO_STATE_STATE_TxRu (9UL) /*!< RADIO is in the TXRU state */ -#define RADIO_STATE_STATE_TxIdle (10UL) /*!< RADIO is in the TXIDLE state */ -#define RADIO_STATE_STATE_Tx (11UL) /*!< RADIO is in the TX state */ -#define RADIO_STATE_STATE_TxDisable (12UL) /*!< RADIO is in the TXDISABLED state */ - -/* Register: RADIO_DATAWHITEIV */ -/* Description: Data whitening initial value */ - -/* Bits 6..0 : Data whitening initial value. Bit 6 is hard-wired to '1', writing '0' to it has no effect, and it will always be read back and used by the device as '1'. */ -#define RADIO_DATAWHITEIV_DATAWHITEIV_Pos (0UL) /*!< Position of DATAWHITEIV field. */ -#define RADIO_DATAWHITEIV_DATAWHITEIV_Msk (0x7FUL << RADIO_DATAWHITEIV_DATAWHITEIV_Pos) /*!< Bit mask of DATAWHITEIV field. */ - -/* Register: RADIO_BCC */ -/* Description: Bit counter compare */ - -/* Bits 31..0 : Bit counter compare */ -#define RADIO_BCC_BCC_Pos (0UL) /*!< Position of BCC field. */ -#define RADIO_BCC_BCC_Msk (0xFFFFFFFFUL << RADIO_BCC_BCC_Pos) /*!< Bit mask of BCC field. */ - -/* Register: RADIO_DAB */ -/* Description: Description collection[0]: Device address base segment 0 */ - -/* Bits 31..0 : Device address base segment 0 */ -#define RADIO_DAB_DAB_Pos (0UL) /*!< Position of DAB field. */ -#define RADIO_DAB_DAB_Msk (0xFFFFFFFFUL << RADIO_DAB_DAB_Pos) /*!< Bit mask of DAB field. */ - -/* Register: RADIO_DAP */ -/* Description: Description collection[0]: Device address prefix 0 */ - -/* Bits 15..0 : Device address prefix 0 */ -#define RADIO_DAP_DAP_Pos (0UL) /*!< Position of DAP field. */ -#define RADIO_DAP_DAP_Msk (0xFFFFUL << RADIO_DAP_DAP_Pos) /*!< Bit mask of DAP field. */ - -/* Register: RADIO_DACNF */ -/* Description: Device address match configuration */ - -/* Bit 15 : TxAdd for device address 7 */ -#define RADIO_DACNF_TXADD7_Pos (15UL) /*!< Position of TXADD7 field. */ -#define RADIO_DACNF_TXADD7_Msk (0x1UL << RADIO_DACNF_TXADD7_Pos) /*!< Bit mask of TXADD7 field. */ - -/* Bit 14 : TxAdd for device address 6 */ -#define RADIO_DACNF_TXADD6_Pos (14UL) /*!< Position of TXADD6 field. */ -#define RADIO_DACNF_TXADD6_Msk (0x1UL << RADIO_DACNF_TXADD6_Pos) /*!< Bit mask of TXADD6 field. */ - -/* Bit 13 : TxAdd for device address 5 */ -#define RADIO_DACNF_TXADD5_Pos (13UL) /*!< Position of TXADD5 field. */ -#define RADIO_DACNF_TXADD5_Msk (0x1UL << RADIO_DACNF_TXADD5_Pos) /*!< Bit mask of TXADD5 field. */ - -/* Bit 12 : TxAdd for device address 4 */ -#define RADIO_DACNF_TXADD4_Pos (12UL) /*!< Position of TXADD4 field. */ -#define RADIO_DACNF_TXADD4_Msk (0x1UL << RADIO_DACNF_TXADD4_Pos) /*!< Bit mask of TXADD4 field. */ - -/* Bit 11 : TxAdd for device address 3 */ -#define RADIO_DACNF_TXADD3_Pos (11UL) /*!< Position of TXADD3 field. */ -#define RADIO_DACNF_TXADD3_Msk (0x1UL << RADIO_DACNF_TXADD3_Pos) /*!< Bit mask of TXADD3 field. */ - -/* Bit 10 : TxAdd for device address 2 */ -#define RADIO_DACNF_TXADD2_Pos (10UL) /*!< Position of TXADD2 field. */ -#define RADIO_DACNF_TXADD2_Msk (0x1UL << RADIO_DACNF_TXADD2_Pos) /*!< Bit mask of TXADD2 field. */ - -/* Bit 9 : TxAdd for device address 1 */ -#define RADIO_DACNF_TXADD1_Pos (9UL) /*!< Position of TXADD1 field. */ -#define RADIO_DACNF_TXADD1_Msk (0x1UL << RADIO_DACNF_TXADD1_Pos) /*!< Bit mask of TXADD1 field. */ - -/* Bit 8 : TxAdd for device address 0 */ -#define RADIO_DACNF_TXADD0_Pos (8UL) /*!< Position of TXADD0 field. */ -#define RADIO_DACNF_TXADD0_Msk (0x1UL << RADIO_DACNF_TXADD0_Pos) /*!< Bit mask of TXADD0 field. */ - -/* Bit 7 : Enable or disable device address matching using device address 7 */ -#define RADIO_DACNF_ENA7_Pos (7UL) /*!< Position of ENA7 field. */ -#define RADIO_DACNF_ENA7_Msk (0x1UL << RADIO_DACNF_ENA7_Pos) /*!< Bit mask of ENA7 field. */ -#define RADIO_DACNF_ENA7_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA7_Enabled (1UL) /*!< Enabled */ - -/* Bit 6 : Enable or disable device address matching using device address 6 */ -#define RADIO_DACNF_ENA6_Pos (6UL) /*!< Position of ENA6 field. */ -#define RADIO_DACNF_ENA6_Msk (0x1UL << RADIO_DACNF_ENA6_Pos) /*!< Bit mask of ENA6 field. */ -#define RADIO_DACNF_ENA6_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA6_Enabled (1UL) /*!< Enabled */ - -/* Bit 5 : Enable or disable device address matching using device address 5 */ -#define RADIO_DACNF_ENA5_Pos (5UL) /*!< Position of ENA5 field. */ -#define RADIO_DACNF_ENA5_Msk (0x1UL << RADIO_DACNF_ENA5_Pos) /*!< Bit mask of ENA5 field. */ -#define RADIO_DACNF_ENA5_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA5_Enabled (1UL) /*!< Enabled */ - -/* Bit 4 : Enable or disable device address matching using device address 4 */ -#define RADIO_DACNF_ENA4_Pos (4UL) /*!< Position of ENA4 field. */ -#define RADIO_DACNF_ENA4_Msk (0x1UL << RADIO_DACNF_ENA4_Pos) /*!< Bit mask of ENA4 field. */ -#define RADIO_DACNF_ENA4_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA4_Enabled (1UL) /*!< Enabled */ - -/* Bit 3 : Enable or disable device address matching using device address 3 */ -#define RADIO_DACNF_ENA3_Pos (3UL) /*!< Position of ENA3 field. */ -#define RADIO_DACNF_ENA3_Msk (0x1UL << RADIO_DACNF_ENA3_Pos) /*!< Bit mask of ENA3 field. */ -#define RADIO_DACNF_ENA3_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA3_Enabled (1UL) /*!< Enabled */ - -/* Bit 2 : Enable or disable device address matching using device address 2 */ -#define RADIO_DACNF_ENA2_Pos (2UL) /*!< Position of ENA2 field. */ -#define RADIO_DACNF_ENA2_Msk (0x1UL << RADIO_DACNF_ENA2_Pos) /*!< Bit mask of ENA2 field. */ -#define RADIO_DACNF_ENA2_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA2_Enabled (1UL) /*!< Enabled */ - -/* Bit 1 : Enable or disable device address matching using device address 1 */ -#define RADIO_DACNF_ENA1_Pos (1UL) /*!< Position of ENA1 field. */ -#define RADIO_DACNF_ENA1_Msk (0x1UL << RADIO_DACNF_ENA1_Pos) /*!< Bit mask of ENA1 field. */ -#define RADIO_DACNF_ENA1_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA1_Enabled (1UL) /*!< Enabled */ - -/* Bit 0 : Enable or disable device address matching using device address 0 */ -#define RADIO_DACNF_ENA0_Pos (0UL) /*!< Position of ENA0 field. */ -#define RADIO_DACNF_ENA0_Msk (0x1UL << RADIO_DACNF_ENA0_Pos) /*!< Bit mask of ENA0 field. */ -#define RADIO_DACNF_ENA0_Disabled (0UL) /*!< Disabled */ -#define RADIO_DACNF_ENA0_Enabled (1UL) /*!< Enabled */ - -/* Register: RADIO_MODECNF0 */ -/* Description: Radio mode configuration register 0 */ - -/* Bits 9..8 : Default TX value */ -#define RADIO_MODECNF0_DTX_Pos (8UL) /*!< Position of DTX field. */ -#define RADIO_MODECNF0_DTX_Msk (0x3UL << RADIO_MODECNF0_DTX_Pos) /*!< Bit mask of DTX field. */ -#define RADIO_MODECNF0_DTX_B1 (0UL) /*!< Transmit '1' */ -#define RADIO_MODECNF0_DTX_B0 (1UL) /*!< Transmit '0' */ -#define RADIO_MODECNF0_DTX_Center (2UL) /*!< Transmit center frequency */ - -/* Bit 0 : Radio ramp-up time */ -#define RADIO_MODECNF0_RU_Pos (0UL) /*!< Position of RU field. */ -#define RADIO_MODECNF0_RU_Msk (0x1UL << RADIO_MODECNF0_RU_Pos) /*!< Bit mask of RU field. */ -#define RADIO_MODECNF0_RU_Default (0UL) /*!< Default ramp-up time (tRXEN), compatible with firmware written for nRF51 */ -#define RADIO_MODECNF0_RU_Fast (1UL) /*!< Fast ramp-up (tRXEN,FAST), see electrical specification for more information */ - -/* Register: RADIO_SFD */ -/* Description: IEEE 802.15.4 Start of Frame Delimiter */ - -/* Bits 7..0 : IEEE 802.15.4 Start of Frame Delimiter. Note, the least significant 4-bits of the SFD cannot all be zeros. */ -#define RADIO_SFD_SFD_Pos (0UL) /*!< Position of SFD field. */ -#define RADIO_SFD_SFD_Msk (0xFFUL << RADIO_SFD_SFD_Pos) /*!< Bit mask of SFD field. */ - -/* Register: RADIO_EDCNT */ -/* Description: IEEE 802.15.4 Energy Detect Loop Count */ - -/* Bits 20..0 : IEEE 802.15.4 Energy Detect Loop Count */ -#define RADIO_EDCNT_EDCNT_Pos (0UL) /*!< Position of EDCNT field. */ -#define RADIO_EDCNT_EDCNT_Msk (0x1FFFFFUL << RADIO_EDCNT_EDCNT_Pos) /*!< Bit mask of EDCNT field. */ - -/* Register: RADIO_EDSAMPLE */ -/* Description: IEEE 802.15.4 Energy Detect Level */ - -/* Bits 7..0 : IEEE 802.15.4 Energy Detect Level */ -#define RADIO_EDSAMPLE_EDLVL_Pos (0UL) /*!< Position of EDLVL field. */ -#define RADIO_EDSAMPLE_EDLVL_Msk (0xFFUL << RADIO_EDSAMPLE_EDLVL_Pos) /*!< Bit mask of EDLVL field. */ - -/* Register: RADIO_CCACTRL */ -/* Description: IEEE 802.15.4 Clear Channel Assessment Control */ - -/* Bits 31..24 : Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled. */ -#define RADIO_CCACTRL_CCACORRCNT_Pos (24UL) /*!< Position of CCACORRCNT field. */ -#define RADIO_CCACTRL_CCACORRCNT_Msk (0xFFUL << RADIO_CCACTRL_CCACORRCNT_Pos) /*!< Bit mask of CCACORRCNT field. */ - -/* Bits 23..16 : CCA Correlator Busy Threshold. Only relevant to CarrierMode, CarrierAndEdMode and CarrierOrEdMode. */ -#define RADIO_CCACTRL_CCACORRTHRES_Pos (16UL) /*!< Position of CCACORRTHRES field. */ -#define RADIO_CCACTRL_CCACORRTHRES_Msk (0xFFUL << RADIO_CCACTRL_CCACORRTHRES_Pos) /*!< Bit mask of CCACORRTHRES field. */ - -/* Bits 15..8 : CCA Energy Busy Threshold. Used in all the CCA modes except CarrierMode. */ -#define RADIO_CCACTRL_CCAEDTHRES_Pos (8UL) /*!< Position of CCAEDTHRES field. */ -#define RADIO_CCACTRL_CCAEDTHRES_Msk (0xFFUL << RADIO_CCACTRL_CCAEDTHRES_Pos) /*!< Bit mask of CCAEDTHRES field. */ - -/* Bits 2..0 : CCA Mode Of Operation */ -#define RADIO_CCACTRL_CCAMODE_Pos (0UL) /*!< Position of CCAMODE field. */ -#define RADIO_CCACTRL_CCAMODE_Msk (0x7UL << RADIO_CCACTRL_CCAMODE_Pos) /*!< Bit mask of CCAMODE field. */ -#define RADIO_CCACTRL_CCAMODE_EdMode (0UL) /*!< Energy Above Threshold */ -#define RADIO_CCACTRL_CCAMODE_CarrierMode (1UL) /*!< Carrier Seen */ -#define RADIO_CCACTRL_CCAMODE_CarrierAndEdMode (2UL) /*!< Energy Above Threshold AND Carrier Seen */ -#define RADIO_CCACTRL_CCAMODE_CarrierOrEdMode (3UL) /*!< Energy Above Threshold OR Carrier Seen */ -#define RADIO_CCACTRL_CCAMODE_EdModeTest1 (4UL) /*!< Energy Above Threshold test mode that will abort when first ED measurement over threshold is seen. No averaging. */ - -/* Register: RADIO_POWER */ -/* Description: Peripheral power control */ - -/* Bit 0 : Peripheral power control. The peripheral and its registers will be reset to its initial state by switching the peripheral off and then back on again. */ -#define RADIO_POWER_POWER_Pos (0UL) /*!< Position of POWER field. */ -#define RADIO_POWER_POWER_Msk (0x1UL << RADIO_POWER_POWER_Pos) /*!< Bit mask of POWER field. */ -#define RADIO_POWER_POWER_Disabled (0UL) /*!< Peripheral is powered off */ -#define RADIO_POWER_POWER_Enabled (1UL) /*!< Peripheral is powered on */ - - -/* Peripheral: RNG */ -/* Description: Random Number Generator */ - -/* Register: RNG_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 0 : Shortcut between VALRDY event and STOP task */ -#define RNG_SHORTS_VALRDY_STOP_Pos (0UL) /*!< Position of VALRDY_STOP field. */ -#define RNG_SHORTS_VALRDY_STOP_Msk (0x1UL << RNG_SHORTS_VALRDY_STOP_Pos) /*!< Bit mask of VALRDY_STOP field. */ -#define RNG_SHORTS_VALRDY_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define RNG_SHORTS_VALRDY_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: RNG_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for VALRDY event */ -#define RNG_INTENSET_VALRDY_Pos (0UL) /*!< Position of VALRDY field. */ -#define RNG_INTENSET_VALRDY_Msk (0x1UL << RNG_INTENSET_VALRDY_Pos) /*!< Bit mask of VALRDY field. */ -#define RNG_INTENSET_VALRDY_Disabled (0UL) /*!< Read: Disabled */ -#define RNG_INTENSET_VALRDY_Enabled (1UL) /*!< Read: Enabled */ -#define RNG_INTENSET_VALRDY_Set (1UL) /*!< Enable */ - -/* Register: RNG_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for VALRDY event */ -#define RNG_INTENCLR_VALRDY_Pos (0UL) /*!< Position of VALRDY field. */ -#define RNG_INTENCLR_VALRDY_Msk (0x1UL << RNG_INTENCLR_VALRDY_Pos) /*!< Bit mask of VALRDY field. */ -#define RNG_INTENCLR_VALRDY_Disabled (0UL) /*!< Read: Disabled */ -#define RNG_INTENCLR_VALRDY_Enabled (1UL) /*!< Read: Enabled */ -#define RNG_INTENCLR_VALRDY_Clear (1UL) /*!< Disable */ - -/* Register: RNG_CONFIG */ -/* Description: Configuration register */ - -/* Bit 0 : Bias correction */ -#define RNG_CONFIG_DERCEN_Pos (0UL) /*!< Position of DERCEN field. */ -#define RNG_CONFIG_DERCEN_Msk (0x1UL << RNG_CONFIG_DERCEN_Pos) /*!< Bit mask of DERCEN field. */ -#define RNG_CONFIG_DERCEN_Disabled (0UL) /*!< Disabled */ -#define RNG_CONFIG_DERCEN_Enabled (1UL) /*!< Enabled */ - -/* Register: RNG_VALUE */ -/* Description: Output random number */ - -/* Bits 7..0 : Generated random number */ -#define RNG_VALUE_VALUE_Pos (0UL) /*!< Position of VALUE field. */ -#define RNG_VALUE_VALUE_Msk (0xFFUL << RNG_VALUE_VALUE_Pos) /*!< Bit mask of VALUE field. */ - - -/* Peripheral: RTC */ -/* Description: Real time counter 0 */ - -/* Register: RTC_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 19 : Write '1' to Enable interrupt for COMPARE[3] event */ -#define RTC_INTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_INTENSET_COMPARE3_Msk (0x1UL << RTC_INTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_INTENSET_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE3_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for COMPARE[2] event */ -#define RTC_INTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_INTENSET_COMPARE2_Msk (0x1UL << RTC_INTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_INTENSET_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE2_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for COMPARE[1] event */ -#define RTC_INTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_INTENSET_COMPARE1_Msk (0x1UL << RTC_INTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_INTENSET_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE1_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for COMPARE[0] event */ -#define RTC_INTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_INTENSET_COMPARE0_Msk (0x1UL << RTC_INTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_INTENSET_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_COMPARE0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for OVRFLW event */ -#define RTC_INTENSET_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_INTENSET_OVRFLW_Msk (0x1UL << RTC_INTENSET_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_INTENSET_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_OVRFLW_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for TICK event */ -#define RTC_INTENSET_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_INTENSET_TICK_Msk (0x1UL << RTC_INTENSET_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_INTENSET_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENSET_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENSET_TICK_Set (1UL) /*!< Enable */ - -/* Register: RTC_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 19 : Write '1' to Disable interrupt for COMPARE[3] event */ -#define RTC_INTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_INTENCLR_COMPARE3_Msk (0x1UL << RTC_INTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_INTENCLR_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE3_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for COMPARE[2] event */ -#define RTC_INTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_INTENCLR_COMPARE2_Msk (0x1UL << RTC_INTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_INTENCLR_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE2_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for COMPARE[1] event */ -#define RTC_INTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_INTENCLR_COMPARE1_Msk (0x1UL << RTC_INTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_INTENCLR_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE1_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for COMPARE[0] event */ -#define RTC_INTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_INTENCLR_COMPARE0_Msk (0x1UL << RTC_INTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_INTENCLR_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_COMPARE0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for OVRFLW event */ -#define RTC_INTENCLR_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_INTENCLR_OVRFLW_Msk (0x1UL << RTC_INTENCLR_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_INTENCLR_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_OVRFLW_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for TICK event */ -#define RTC_INTENCLR_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_INTENCLR_TICK_Msk (0x1UL << RTC_INTENCLR_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_INTENCLR_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_INTENCLR_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_INTENCLR_TICK_Clear (1UL) /*!< Disable */ - -/* Register: RTC_EVTEN */ -/* Description: Enable or disable event routing */ - -/* Bit 19 : Enable or disable event routing for COMPARE[3] event */ -#define RTC_EVTEN_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTEN_COMPARE3_Msk (0x1UL << RTC_EVTEN_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTEN_COMPARE3_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE3_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable event routing for COMPARE[2] event */ -#define RTC_EVTEN_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTEN_COMPARE2_Msk (0x1UL << RTC_EVTEN_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTEN_COMPARE2_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE2_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable event routing for COMPARE[1] event */ -#define RTC_EVTEN_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTEN_COMPARE1_Msk (0x1UL << RTC_EVTEN_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTEN_COMPARE1_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE1_Enabled (1UL) /*!< Enable */ - -/* Bit 16 : Enable or disable event routing for COMPARE[0] event */ -#define RTC_EVTEN_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTEN_COMPARE0_Msk (0x1UL << RTC_EVTEN_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTEN_COMPARE0_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_COMPARE0_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable event routing for OVRFLW event */ -#define RTC_EVTEN_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTEN_OVRFLW_Msk (0x1UL << RTC_EVTEN_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTEN_OVRFLW_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_OVRFLW_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable event routing for TICK event */ -#define RTC_EVTEN_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTEN_TICK_Msk (0x1UL << RTC_EVTEN_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTEN_TICK_Disabled (0UL) /*!< Disable */ -#define RTC_EVTEN_TICK_Enabled (1UL) /*!< Enable */ - -/* Register: RTC_EVTENSET */ -/* Description: Enable event routing */ - -/* Bit 19 : Write '1' to Enable event routing for COMPARE[3] event */ -#define RTC_EVTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTENSET_COMPARE3_Msk (0x1UL << RTC_EVTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTENSET_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE3_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable event routing for COMPARE[2] event */ -#define RTC_EVTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTENSET_COMPARE2_Msk (0x1UL << RTC_EVTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTENSET_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE2_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable event routing for COMPARE[1] event */ -#define RTC_EVTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTENSET_COMPARE1_Msk (0x1UL << RTC_EVTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTENSET_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE1_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable event routing for COMPARE[0] event */ -#define RTC_EVTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTENSET_COMPARE0_Msk (0x1UL << RTC_EVTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTENSET_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_COMPARE0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable event routing for OVRFLW event */ -#define RTC_EVTENSET_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTENSET_OVRFLW_Msk (0x1UL << RTC_EVTENSET_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTENSET_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_OVRFLW_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable event routing for TICK event */ -#define RTC_EVTENSET_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTENSET_TICK_Msk (0x1UL << RTC_EVTENSET_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTENSET_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENSET_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENSET_TICK_Set (1UL) /*!< Enable */ - -/* Register: RTC_EVTENCLR */ -/* Description: Disable event routing */ - -/* Bit 19 : Write '1' to Disable event routing for COMPARE[3] event */ -#define RTC_EVTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define RTC_EVTENCLR_COMPARE3_Msk (0x1UL << RTC_EVTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define RTC_EVTENCLR_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE3_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable event routing for COMPARE[2] event */ -#define RTC_EVTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define RTC_EVTENCLR_COMPARE2_Msk (0x1UL << RTC_EVTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define RTC_EVTENCLR_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE2_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable event routing for COMPARE[1] event */ -#define RTC_EVTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define RTC_EVTENCLR_COMPARE1_Msk (0x1UL << RTC_EVTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define RTC_EVTENCLR_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE1_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable event routing for COMPARE[0] event */ -#define RTC_EVTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define RTC_EVTENCLR_COMPARE0_Msk (0x1UL << RTC_EVTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define RTC_EVTENCLR_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_COMPARE0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable event routing for OVRFLW event */ -#define RTC_EVTENCLR_OVRFLW_Pos (1UL) /*!< Position of OVRFLW field. */ -#define RTC_EVTENCLR_OVRFLW_Msk (0x1UL << RTC_EVTENCLR_OVRFLW_Pos) /*!< Bit mask of OVRFLW field. */ -#define RTC_EVTENCLR_OVRFLW_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_OVRFLW_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_OVRFLW_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable event routing for TICK event */ -#define RTC_EVTENCLR_TICK_Pos (0UL) /*!< Position of TICK field. */ -#define RTC_EVTENCLR_TICK_Msk (0x1UL << RTC_EVTENCLR_TICK_Pos) /*!< Bit mask of TICK field. */ -#define RTC_EVTENCLR_TICK_Disabled (0UL) /*!< Read: Disabled */ -#define RTC_EVTENCLR_TICK_Enabled (1UL) /*!< Read: Enabled */ -#define RTC_EVTENCLR_TICK_Clear (1UL) /*!< Disable */ - -/* Register: RTC_COUNTER */ -/* Description: Current COUNTER value */ - -/* Bits 23..0 : Counter value */ -#define RTC_COUNTER_COUNTER_Pos (0UL) /*!< Position of COUNTER field. */ -#define RTC_COUNTER_COUNTER_Msk (0xFFFFFFUL << RTC_COUNTER_COUNTER_Pos) /*!< Bit mask of COUNTER field. */ - -/* Register: RTC_PRESCALER */ -/* Description: 12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)).Must be written when RTC is stopped */ - -/* Bits 11..0 : Prescaler value */ -#define RTC_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define RTC_PRESCALER_PRESCALER_Msk (0xFFFUL << RTC_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ - -/* Register: RTC_CC */ -/* Description: Description collection[0]: Compare register 0 */ - -/* Bits 23..0 : Compare value */ -#define RTC_CC_COMPARE_Pos (0UL) /*!< Position of COMPARE field. */ -#define RTC_CC_COMPARE_Msk (0xFFFFFFUL << RTC_CC_COMPARE_Pos) /*!< Bit mask of COMPARE field. */ - - -/* Peripheral: SAADC */ -/* Description: Analog to Digital Converter */ - -/* Register: SAADC_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 21 : Enable or disable interrupt for CH[7].LIMITL event */ -#define SAADC_INTEN_CH7LIMITL_Pos (21UL) /*!< Position of CH7LIMITL field. */ -#define SAADC_INTEN_CH7LIMITL_Msk (0x1UL << SAADC_INTEN_CH7LIMITL_Pos) /*!< Bit mask of CH7LIMITL field. */ -#define SAADC_INTEN_CH7LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH7LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for CH[7].LIMITH event */ -#define SAADC_INTEN_CH7LIMITH_Pos (20UL) /*!< Position of CH7LIMITH field. */ -#define SAADC_INTEN_CH7LIMITH_Msk (0x1UL << SAADC_INTEN_CH7LIMITH_Pos) /*!< Bit mask of CH7LIMITH field. */ -#define SAADC_INTEN_CH7LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH7LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for CH[6].LIMITL event */ -#define SAADC_INTEN_CH6LIMITL_Pos (19UL) /*!< Position of CH6LIMITL field. */ -#define SAADC_INTEN_CH6LIMITL_Msk (0x1UL << SAADC_INTEN_CH6LIMITL_Pos) /*!< Bit mask of CH6LIMITL field. */ -#define SAADC_INTEN_CH6LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH6LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable interrupt for CH[6].LIMITH event */ -#define SAADC_INTEN_CH6LIMITH_Pos (18UL) /*!< Position of CH6LIMITH field. */ -#define SAADC_INTEN_CH6LIMITH_Msk (0x1UL << SAADC_INTEN_CH6LIMITH_Pos) /*!< Bit mask of CH6LIMITH field. */ -#define SAADC_INTEN_CH6LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH6LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable interrupt for CH[5].LIMITL event */ -#define SAADC_INTEN_CH5LIMITL_Pos (17UL) /*!< Position of CH5LIMITL field. */ -#define SAADC_INTEN_CH5LIMITL_Msk (0x1UL << SAADC_INTEN_CH5LIMITL_Pos) /*!< Bit mask of CH5LIMITL field. */ -#define SAADC_INTEN_CH5LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH5LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 16 : Enable or disable interrupt for CH[5].LIMITH event */ -#define SAADC_INTEN_CH5LIMITH_Pos (16UL) /*!< Position of CH5LIMITH field. */ -#define SAADC_INTEN_CH5LIMITH_Msk (0x1UL << SAADC_INTEN_CH5LIMITH_Pos) /*!< Bit mask of CH5LIMITH field. */ -#define SAADC_INTEN_CH5LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH5LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 15 : Enable or disable interrupt for CH[4].LIMITL event */ -#define SAADC_INTEN_CH4LIMITL_Pos (15UL) /*!< Position of CH4LIMITL field. */ -#define SAADC_INTEN_CH4LIMITL_Msk (0x1UL << SAADC_INTEN_CH4LIMITL_Pos) /*!< Bit mask of CH4LIMITL field. */ -#define SAADC_INTEN_CH4LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH4LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 14 : Enable or disable interrupt for CH[4].LIMITH event */ -#define SAADC_INTEN_CH4LIMITH_Pos (14UL) /*!< Position of CH4LIMITH field. */ -#define SAADC_INTEN_CH4LIMITH_Msk (0x1UL << SAADC_INTEN_CH4LIMITH_Pos) /*!< Bit mask of CH4LIMITH field. */ -#define SAADC_INTEN_CH4LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH4LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 13 : Enable or disable interrupt for CH[3].LIMITL event */ -#define SAADC_INTEN_CH3LIMITL_Pos (13UL) /*!< Position of CH3LIMITL field. */ -#define SAADC_INTEN_CH3LIMITL_Msk (0x1UL << SAADC_INTEN_CH3LIMITL_Pos) /*!< Bit mask of CH3LIMITL field. */ -#define SAADC_INTEN_CH3LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH3LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 12 : Enable or disable interrupt for CH[3].LIMITH event */ -#define SAADC_INTEN_CH3LIMITH_Pos (12UL) /*!< Position of CH3LIMITH field. */ -#define SAADC_INTEN_CH3LIMITH_Msk (0x1UL << SAADC_INTEN_CH3LIMITH_Pos) /*!< Bit mask of CH3LIMITH field. */ -#define SAADC_INTEN_CH3LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH3LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 11 : Enable or disable interrupt for CH[2].LIMITL event */ -#define SAADC_INTEN_CH2LIMITL_Pos (11UL) /*!< Position of CH2LIMITL field. */ -#define SAADC_INTEN_CH2LIMITL_Msk (0x1UL << SAADC_INTEN_CH2LIMITL_Pos) /*!< Bit mask of CH2LIMITL field. */ -#define SAADC_INTEN_CH2LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH2LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 10 : Enable or disable interrupt for CH[2].LIMITH event */ -#define SAADC_INTEN_CH2LIMITH_Pos (10UL) /*!< Position of CH2LIMITH field. */ -#define SAADC_INTEN_CH2LIMITH_Msk (0x1UL << SAADC_INTEN_CH2LIMITH_Pos) /*!< Bit mask of CH2LIMITH field. */ -#define SAADC_INTEN_CH2LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH2LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for CH[1].LIMITL event */ -#define SAADC_INTEN_CH1LIMITL_Pos (9UL) /*!< Position of CH1LIMITL field. */ -#define SAADC_INTEN_CH1LIMITL_Msk (0x1UL << SAADC_INTEN_CH1LIMITL_Pos) /*!< Bit mask of CH1LIMITL field. */ -#define SAADC_INTEN_CH1LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH1LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for CH[1].LIMITH event */ -#define SAADC_INTEN_CH1LIMITH_Pos (8UL) /*!< Position of CH1LIMITH field. */ -#define SAADC_INTEN_CH1LIMITH_Msk (0x1UL << SAADC_INTEN_CH1LIMITH_Pos) /*!< Bit mask of CH1LIMITH field. */ -#define SAADC_INTEN_CH1LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH1LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for CH[0].LIMITL event */ -#define SAADC_INTEN_CH0LIMITL_Pos (7UL) /*!< Position of CH0LIMITL field. */ -#define SAADC_INTEN_CH0LIMITL_Msk (0x1UL << SAADC_INTEN_CH0LIMITL_Pos) /*!< Bit mask of CH0LIMITL field. */ -#define SAADC_INTEN_CH0LIMITL_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH0LIMITL_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for CH[0].LIMITH event */ -#define SAADC_INTEN_CH0LIMITH_Pos (6UL) /*!< Position of CH0LIMITH field. */ -#define SAADC_INTEN_CH0LIMITH_Msk (0x1UL << SAADC_INTEN_CH0LIMITH_Pos) /*!< Bit mask of CH0LIMITH field. */ -#define SAADC_INTEN_CH0LIMITH_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CH0LIMITH_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for STOPPED event */ -#define SAADC_INTEN_STOPPED_Pos (5UL) /*!< Position of STOPPED field. */ -#define SAADC_INTEN_STOPPED_Msk (0x1UL << SAADC_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SAADC_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for CALIBRATEDONE event */ -#define SAADC_INTEN_CALIBRATEDONE_Pos (4UL) /*!< Position of CALIBRATEDONE field. */ -#define SAADC_INTEN_CALIBRATEDONE_Msk (0x1UL << SAADC_INTEN_CALIBRATEDONE_Pos) /*!< Bit mask of CALIBRATEDONE field. */ -#define SAADC_INTEN_CALIBRATEDONE_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_CALIBRATEDONE_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for RESULTDONE event */ -#define SAADC_INTEN_RESULTDONE_Pos (3UL) /*!< Position of RESULTDONE field. */ -#define SAADC_INTEN_RESULTDONE_Msk (0x1UL << SAADC_INTEN_RESULTDONE_Pos) /*!< Bit mask of RESULTDONE field. */ -#define SAADC_INTEN_RESULTDONE_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_RESULTDONE_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for DONE event */ -#define SAADC_INTEN_DONE_Pos (2UL) /*!< Position of DONE field. */ -#define SAADC_INTEN_DONE_Msk (0x1UL << SAADC_INTEN_DONE_Pos) /*!< Bit mask of DONE field. */ -#define SAADC_INTEN_DONE_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_DONE_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for END event */ -#define SAADC_INTEN_END_Pos (1UL) /*!< Position of END field. */ -#define SAADC_INTEN_END_Msk (0x1UL << SAADC_INTEN_END_Pos) /*!< Bit mask of END field. */ -#define SAADC_INTEN_END_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_END_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for STARTED event */ -#define SAADC_INTEN_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define SAADC_INTEN_STARTED_Msk (0x1UL << SAADC_INTEN_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SAADC_INTEN_STARTED_Disabled (0UL) /*!< Disable */ -#define SAADC_INTEN_STARTED_Enabled (1UL) /*!< Enable */ - -/* Register: SAADC_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 21 : Write '1' to Enable interrupt for CH[7].LIMITL event */ -#define SAADC_INTENSET_CH7LIMITL_Pos (21UL) /*!< Position of CH7LIMITL field. */ -#define SAADC_INTENSET_CH7LIMITL_Msk (0x1UL << SAADC_INTENSET_CH7LIMITL_Pos) /*!< Bit mask of CH7LIMITL field. */ -#define SAADC_INTENSET_CH7LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH7LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH7LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for CH[7].LIMITH event */ -#define SAADC_INTENSET_CH7LIMITH_Pos (20UL) /*!< Position of CH7LIMITH field. */ -#define SAADC_INTENSET_CH7LIMITH_Msk (0x1UL << SAADC_INTENSET_CH7LIMITH_Pos) /*!< Bit mask of CH7LIMITH field. */ -#define SAADC_INTENSET_CH7LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH7LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH7LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for CH[6].LIMITL event */ -#define SAADC_INTENSET_CH6LIMITL_Pos (19UL) /*!< Position of CH6LIMITL field. */ -#define SAADC_INTENSET_CH6LIMITL_Msk (0x1UL << SAADC_INTENSET_CH6LIMITL_Pos) /*!< Bit mask of CH6LIMITL field. */ -#define SAADC_INTENSET_CH6LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH6LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH6LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for CH[6].LIMITH event */ -#define SAADC_INTENSET_CH6LIMITH_Pos (18UL) /*!< Position of CH6LIMITH field. */ -#define SAADC_INTENSET_CH6LIMITH_Msk (0x1UL << SAADC_INTENSET_CH6LIMITH_Pos) /*!< Bit mask of CH6LIMITH field. */ -#define SAADC_INTENSET_CH6LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH6LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH6LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for CH[5].LIMITL event */ -#define SAADC_INTENSET_CH5LIMITL_Pos (17UL) /*!< Position of CH5LIMITL field. */ -#define SAADC_INTENSET_CH5LIMITL_Msk (0x1UL << SAADC_INTENSET_CH5LIMITL_Pos) /*!< Bit mask of CH5LIMITL field. */ -#define SAADC_INTENSET_CH5LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH5LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH5LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for CH[5].LIMITH event */ -#define SAADC_INTENSET_CH5LIMITH_Pos (16UL) /*!< Position of CH5LIMITH field. */ -#define SAADC_INTENSET_CH5LIMITH_Msk (0x1UL << SAADC_INTENSET_CH5LIMITH_Pos) /*!< Bit mask of CH5LIMITH field. */ -#define SAADC_INTENSET_CH5LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH5LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH5LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 15 : Write '1' to Enable interrupt for CH[4].LIMITL event */ -#define SAADC_INTENSET_CH4LIMITL_Pos (15UL) /*!< Position of CH4LIMITL field. */ -#define SAADC_INTENSET_CH4LIMITL_Msk (0x1UL << SAADC_INTENSET_CH4LIMITL_Pos) /*!< Bit mask of CH4LIMITL field. */ -#define SAADC_INTENSET_CH4LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH4LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH4LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for CH[4].LIMITH event */ -#define SAADC_INTENSET_CH4LIMITH_Pos (14UL) /*!< Position of CH4LIMITH field. */ -#define SAADC_INTENSET_CH4LIMITH_Msk (0x1UL << SAADC_INTENSET_CH4LIMITH_Pos) /*!< Bit mask of CH4LIMITH field. */ -#define SAADC_INTENSET_CH4LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH4LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH4LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 13 : Write '1' to Enable interrupt for CH[3].LIMITL event */ -#define SAADC_INTENSET_CH3LIMITL_Pos (13UL) /*!< Position of CH3LIMITL field. */ -#define SAADC_INTENSET_CH3LIMITL_Msk (0x1UL << SAADC_INTENSET_CH3LIMITL_Pos) /*!< Bit mask of CH3LIMITL field. */ -#define SAADC_INTENSET_CH3LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH3LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH3LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for CH[3].LIMITH event */ -#define SAADC_INTENSET_CH3LIMITH_Pos (12UL) /*!< Position of CH3LIMITH field. */ -#define SAADC_INTENSET_CH3LIMITH_Msk (0x1UL << SAADC_INTENSET_CH3LIMITH_Pos) /*!< Bit mask of CH3LIMITH field. */ -#define SAADC_INTENSET_CH3LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH3LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH3LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 11 : Write '1' to Enable interrupt for CH[2].LIMITL event */ -#define SAADC_INTENSET_CH2LIMITL_Pos (11UL) /*!< Position of CH2LIMITL field. */ -#define SAADC_INTENSET_CH2LIMITL_Msk (0x1UL << SAADC_INTENSET_CH2LIMITL_Pos) /*!< Bit mask of CH2LIMITL field. */ -#define SAADC_INTENSET_CH2LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH2LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH2LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for CH[2].LIMITH event */ -#define SAADC_INTENSET_CH2LIMITH_Pos (10UL) /*!< Position of CH2LIMITH field. */ -#define SAADC_INTENSET_CH2LIMITH_Msk (0x1UL << SAADC_INTENSET_CH2LIMITH_Pos) /*!< Bit mask of CH2LIMITH field. */ -#define SAADC_INTENSET_CH2LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH2LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH2LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for CH[1].LIMITL event */ -#define SAADC_INTENSET_CH1LIMITL_Pos (9UL) /*!< Position of CH1LIMITL field. */ -#define SAADC_INTENSET_CH1LIMITL_Msk (0x1UL << SAADC_INTENSET_CH1LIMITL_Pos) /*!< Bit mask of CH1LIMITL field. */ -#define SAADC_INTENSET_CH1LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH1LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH1LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for CH[1].LIMITH event */ -#define SAADC_INTENSET_CH1LIMITH_Pos (8UL) /*!< Position of CH1LIMITH field. */ -#define SAADC_INTENSET_CH1LIMITH_Msk (0x1UL << SAADC_INTENSET_CH1LIMITH_Pos) /*!< Bit mask of CH1LIMITH field. */ -#define SAADC_INTENSET_CH1LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH1LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH1LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for CH[0].LIMITL event */ -#define SAADC_INTENSET_CH0LIMITL_Pos (7UL) /*!< Position of CH0LIMITL field. */ -#define SAADC_INTENSET_CH0LIMITL_Msk (0x1UL << SAADC_INTENSET_CH0LIMITL_Pos) /*!< Bit mask of CH0LIMITL field. */ -#define SAADC_INTENSET_CH0LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH0LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH0LIMITL_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for CH[0].LIMITH event */ -#define SAADC_INTENSET_CH0LIMITH_Pos (6UL) /*!< Position of CH0LIMITH field. */ -#define SAADC_INTENSET_CH0LIMITH_Msk (0x1UL << SAADC_INTENSET_CH0LIMITH_Pos) /*!< Bit mask of CH0LIMITH field. */ -#define SAADC_INTENSET_CH0LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CH0LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CH0LIMITH_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for STOPPED event */ -#define SAADC_INTENSET_STOPPED_Pos (5UL) /*!< Position of STOPPED field. */ -#define SAADC_INTENSET_STOPPED_Msk (0x1UL << SAADC_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SAADC_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for CALIBRATEDONE event */ -#define SAADC_INTENSET_CALIBRATEDONE_Pos (4UL) /*!< Position of CALIBRATEDONE field. */ -#define SAADC_INTENSET_CALIBRATEDONE_Msk (0x1UL << SAADC_INTENSET_CALIBRATEDONE_Pos) /*!< Bit mask of CALIBRATEDONE field. */ -#define SAADC_INTENSET_CALIBRATEDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_CALIBRATEDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_CALIBRATEDONE_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for RESULTDONE event */ -#define SAADC_INTENSET_RESULTDONE_Pos (3UL) /*!< Position of RESULTDONE field. */ -#define SAADC_INTENSET_RESULTDONE_Msk (0x1UL << SAADC_INTENSET_RESULTDONE_Pos) /*!< Bit mask of RESULTDONE field. */ -#define SAADC_INTENSET_RESULTDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_RESULTDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_RESULTDONE_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for DONE event */ -#define SAADC_INTENSET_DONE_Pos (2UL) /*!< Position of DONE field. */ -#define SAADC_INTENSET_DONE_Msk (0x1UL << SAADC_INTENSET_DONE_Pos) /*!< Bit mask of DONE field. */ -#define SAADC_INTENSET_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_DONE_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for END event */ -#define SAADC_INTENSET_END_Pos (1UL) /*!< Position of END field. */ -#define SAADC_INTENSET_END_Msk (0x1UL << SAADC_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SAADC_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for STARTED event */ -#define SAADC_INTENSET_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define SAADC_INTENSET_STARTED_Msk (0x1UL << SAADC_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SAADC_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Register: SAADC_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 21 : Write '1' to Disable interrupt for CH[7].LIMITL event */ -#define SAADC_INTENCLR_CH7LIMITL_Pos (21UL) /*!< Position of CH7LIMITL field. */ -#define SAADC_INTENCLR_CH7LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH7LIMITL_Pos) /*!< Bit mask of CH7LIMITL field. */ -#define SAADC_INTENCLR_CH7LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH7LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH7LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for CH[7].LIMITH event */ -#define SAADC_INTENCLR_CH7LIMITH_Pos (20UL) /*!< Position of CH7LIMITH field. */ -#define SAADC_INTENCLR_CH7LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH7LIMITH_Pos) /*!< Bit mask of CH7LIMITH field. */ -#define SAADC_INTENCLR_CH7LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH7LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH7LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for CH[6].LIMITL event */ -#define SAADC_INTENCLR_CH6LIMITL_Pos (19UL) /*!< Position of CH6LIMITL field. */ -#define SAADC_INTENCLR_CH6LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH6LIMITL_Pos) /*!< Bit mask of CH6LIMITL field. */ -#define SAADC_INTENCLR_CH6LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH6LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH6LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for CH[6].LIMITH event */ -#define SAADC_INTENCLR_CH6LIMITH_Pos (18UL) /*!< Position of CH6LIMITH field. */ -#define SAADC_INTENCLR_CH6LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH6LIMITH_Pos) /*!< Bit mask of CH6LIMITH field. */ -#define SAADC_INTENCLR_CH6LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH6LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH6LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for CH[5].LIMITL event */ -#define SAADC_INTENCLR_CH5LIMITL_Pos (17UL) /*!< Position of CH5LIMITL field. */ -#define SAADC_INTENCLR_CH5LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH5LIMITL_Pos) /*!< Bit mask of CH5LIMITL field. */ -#define SAADC_INTENCLR_CH5LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH5LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH5LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for CH[5].LIMITH event */ -#define SAADC_INTENCLR_CH5LIMITH_Pos (16UL) /*!< Position of CH5LIMITH field. */ -#define SAADC_INTENCLR_CH5LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH5LIMITH_Pos) /*!< Bit mask of CH5LIMITH field. */ -#define SAADC_INTENCLR_CH5LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH5LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH5LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 15 : Write '1' to Disable interrupt for CH[4].LIMITL event */ -#define SAADC_INTENCLR_CH4LIMITL_Pos (15UL) /*!< Position of CH4LIMITL field. */ -#define SAADC_INTENCLR_CH4LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH4LIMITL_Pos) /*!< Bit mask of CH4LIMITL field. */ -#define SAADC_INTENCLR_CH4LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH4LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH4LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for CH[4].LIMITH event */ -#define SAADC_INTENCLR_CH4LIMITH_Pos (14UL) /*!< Position of CH4LIMITH field. */ -#define SAADC_INTENCLR_CH4LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH4LIMITH_Pos) /*!< Bit mask of CH4LIMITH field. */ -#define SAADC_INTENCLR_CH4LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH4LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH4LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 13 : Write '1' to Disable interrupt for CH[3].LIMITL event */ -#define SAADC_INTENCLR_CH3LIMITL_Pos (13UL) /*!< Position of CH3LIMITL field. */ -#define SAADC_INTENCLR_CH3LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH3LIMITL_Pos) /*!< Bit mask of CH3LIMITL field. */ -#define SAADC_INTENCLR_CH3LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH3LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH3LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for CH[3].LIMITH event */ -#define SAADC_INTENCLR_CH3LIMITH_Pos (12UL) /*!< Position of CH3LIMITH field. */ -#define SAADC_INTENCLR_CH3LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH3LIMITH_Pos) /*!< Bit mask of CH3LIMITH field. */ -#define SAADC_INTENCLR_CH3LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH3LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH3LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 11 : Write '1' to Disable interrupt for CH[2].LIMITL event */ -#define SAADC_INTENCLR_CH2LIMITL_Pos (11UL) /*!< Position of CH2LIMITL field. */ -#define SAADC_INTENCLR_CH2LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH2LIMITL_Pos) /*!< Bit mask of CH2LIMITL field. */ -#define SAADC_INTENCLR_CH2LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH2LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH2LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for CH[2].LIMITH event */ -#define SAADC_INTENCLR_CH2LIMITH_Pos (10UL) /*!< Position of CH2LIMITH field. */ -#define SAADC_INTENCLR_CH2LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH2LIMITH_Pos) /*!< Bit mask of CH2LIMITH field. */ -#define SAADC_INTENCLR_CH2LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH2LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH2LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for CH[1].LIMITL event */ -#define SAADC_INTENCLR_CH1LIMITL_Pos (9UL) /*!< Position of CH1LIMITL field. */ -#define SAADC_INTENCLR_CH1LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH1LIMITL_Pos) /*!< Bit mask of CH1LIMITL field. */ -#define SAADC_INTENCLR_CH1LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH1LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH1LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for CH[1].LIMITH event */ -#define SAADC_INTENCLR_CH1LIMITH_Pos (8UL) /*!< Position of CH1LIMITH field. */ -#define SAADC_INTENCLR_CH1LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH1LIMITH_Pos) /*!< Bit mask of CH1LIMITH field. */ -#define SAADC_INTENCLR_CH1LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH1LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH1LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for CH[0].LIMITL event */ -#define SAADC_INTENCLR_CH0LIMITL_Pos (7UL) /*!< Position of CH0LIMITL field. */ -#define SAADC_INTENCLR_CH0LIMITL_Msk (0x1UL << SAADC_INTENCLR_CH0LIMITL_Pos) /*!< Bit mask of CH0LIMITL field. */ -#define SAADC_INTENCLR_CH0LIMITL_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH0LIMITL_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH0LIMITL_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for CH[0].LIMITH event */ -#define SAADC_INTENCLR_CH0LIMITH_Pos (6UL) /*!< Position of CH0LIMITH field. */ -#define SAADC_INTENCLR_CH0LIMITH_Msk (0x1UL << SAADC_INTENCLR_CH0LIMITH_Pos) /*!< Bit mask of CH0LIMITH field. */ -#define SAADC_INTENCLR_CH0LIMITH_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CH0LIMITH_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CH0LIMITH_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for STOPPED event */ -#define SAADC_INTENCLR_STOPPED_Pos (5UL) /*!< Position of STOPPED field. */ -#define SAADC_INTENCLR_STOPPED_Msk (0x1UL << SAADC_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SAADC_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for CALIBRATEDONE event */ -#define SAADC_INTENCLR_CALIBRATEDONE_Pos (4UL) /*!< Position of CALIBRATEDONE field. */ -#define SAADC_INTENCLR_CALIBRATEDONE_Msk (0x1UL << SAADC_INTENCLR_CALIBRATEDONE_Pos) /*!< Bit mask of CALIBRATEDONE field. */ -#define SAADC_INTENCLR_CALIBRATEDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_CALIBRATEDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_CALIBRATEDONE_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for RESULTDONE event */ -#define SAADC_INTENCLR_RESULTDONE_Pos (3UL) /*!< Position of RESULTDONE field. */ -#define SAADC_INTENCLR_RESULTDONE_Msk (0x1UL << SAADC_INTENCLR_RESULTDONE_Pos) /*!< Bit mask of RESULTDONE field. */ -#define SAADC_INTENCLR_RESULTDONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_RESULTDONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_RESULTDONE_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for DONE event */ -#define SAADC_INTENCLR_DONE_Pos (2UL) /*!< Position of DONE field. */ -#define SAADC_INTENCLR_DONE_Msk (0x1UL << SAADC_INTENCLR_DONE_Pos) /*!< Bit mask of DONE field. */ -#define SAADC_INTENCLR_DONE_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_DONE_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_DONE_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for END event */ -#define SAADC_INTENCLR_END_Pos (1UL) /*!< Position of END field. */ -#define SAADC_INTENCLR_END_Msk (0x1UL << SAADC_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SAADC_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for STARTED event */ -#define SAADC_INTENCLR_STARTED_Pos (0UL) /*!< Position of STARTED field. */ -#define SAADC_INTENCLR_STARTED_Msk (0x1UL << SAADC_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SAADC_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SAADC_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SAADC_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Register: SAADC_STATUS */ -/* Description: Status */ - -/* Bit 0 : Status */ -#define SAADC_STATUS_STATUS_Pos (0UL) /*!< Position of STATUS field. */ -#define SAADC_STATUS_STATUS_Msk (0x1UL << SAADC_STATUS_STATUS_Pos) /*!< Bit mask of STATUS field. */ -#define SAADC_STATUS_STATUS_Ready (0UL) /*!< ADC is ready. No on-going conversion. */ -#define SAADC_STATUS_STATUS_Busy (1UL) /*!< ADC is busy. Conversion in progress. */ - -/* Register: SAADC_ENABLE */ -/* Description: Enable or disable ADC */ - -/* Bit 0 : Enable or disable ADC */ -#define SAADC_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SAADC_ENABLE_ENABLE_Msk (0x1UL << SAADC_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SAADC_ENABLE_ENABLE_Disabled (0UL) /*!< Disable ADC */ -#define SAADC_ENABLE_ENABLE_Enabled (1UL) /*!< Enable ADC */ - -/* Register: SAADC_CH_PSELP */ -/* Description: Description cluster[0]: Input positive pin selection for CH[0] */ - -/* Bits 4..0 : Analog positive input channel */ -#define SAADC_CH_PSELP_PSELP_Pos (0UL) /*!< Position of PSELP field. */ -#define SAADC_CH_PSELP_PSELP_Msk (0x1FUL << SAADC_CH_PSELP_PSELP_Pos) /*!< Bit mask of PSELP field. */ -#define SAADC_CH_PSELP_PSELP_NC (0UL) /*!< Not connected */ -#define SAADC_CH_PSELP_PSELP_AnalogInput0 (1UL) /*!< AIN0 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput1 (2UL) /*!< AIN1 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput2 (3UL) /*!< AIN2 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput3 (4UL) /*!< AIN3 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput4 (5UL) /*!< AIN4 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput5 (6UL) /*!< AIN5 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput6 (7UL) /*!< AIN6 */ -#define SAADC_CH_PSELP_PSELP_AnalogInput7 (8UL) /*!< AIN7 */ -#define SAADC_CH_PSELP_PSELP_VDD (9UL) /*!< VDD */ -#define SAADC_CH_PSELP_PSELP_VDDHDIV5 (0x0DUL) /*!< VDDH/5 */ - -/* Register: SAADC_CH_PSELN */ -/* Description: Description cluster[0]: Input negative pin selection for CH[0] */ - -/* Bits 4..0 : Analog negative input, enables differential channel */ -#define SAADC_CH_PSELN_PSELN_Pos (0UL) /*!< Position of PSELN field. */ -#define SAADC_CH_PSELN_PSELN_Msk (0x1FUL << SAADC_CH_PSELN_PSELN_Pos) /*!< Bit mask of PSELN field. */ -#define SAADC_CH_PSELN_PSELN_NC (0UL) /*!< Not connected */ -#define SAADC_CH_PSELN_PSELN_AnalogInput0 (1UL) /*!< AIN0 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput1 (2UL) /*!< AIN1 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput2 (3UL) /*!< AIN2 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput3 (4UL) /*!< AIN3 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput4 (5UL) /*!< AIN4 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput5 (6UL) /*!< AIN5 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput6 (7UL) /*!< AIN6 */ -#define SAADC_CH_PSELN_PSELN_AnalogInput7 (8UL) /*!< AIN7 */ -#define SAADC_CH_PSELN_PSELN_VDD (9UL) /*!< VDD */ -#define SAADC_CH_PSELN_PSELN_VDDHDIV5 (0x0DUL) /*!< VDDH/5 */ - -/* Register: SAADC_CH_CONFIG */ -/* Description: Description cluster[0]: Input configuration for CH[0] */ - -/* Bit 24 : Enable burst mode */ -#define SAADC_CH_CONFIG_BURST_Pos (24UL) /*!< Position of BURST field. */ -#define SAADC_CH_CONFIG_BURST_Msk (0x1UL << SAADC_CH_CONFIG_BURST_Pos) /*!< Bit mask of BURST field. */ -#define SAADC_CH_CONFIG_BURST_Disabled (0UL) /*!< Burst mode is disabled (normal operation) */ -#define SAADC_CH_CONFIG_BURST_Enabled (1UL) /*!< Burst mode is enabled. SAADC takes 2^OVERSAMPLE number of samples as fast as it can, and sends the average to Data RAM. */ - -/* Bit 20 : Enable differential mode */ -#define SAADC_CH_CONFIG_MODE_Pos (20UL) /*!< Position of MODE field. */ -#define SAADC_CH_CONFIG_MODE_Msk (0x1UL << SAADC_CH_CONFIG_MODE_Pos) /*!< Bit mask of MODE field. */ -#define SAADC_CH_CONFIG_MODE_SE (0UL) /*!< Single ended, PSELN will be ignored, negative input to ADC shorted to GND */ -#define SAADC_CH_CONFIG_MODE_Diff (1UL) /*!< Differential */ - -/* Bits 18..16 : Acquisition time, the time the ADC uses to sample the input voltage */ -#define SAADC_CH_CONFIG_TACQ_Pos (16UL) /*!< Position of TACQ field. */ -#define SAADC_CH_CONFIG_TACQ_Msk (0x7UL << SAADC_CH_CONFIG_TACQ_Pos) /*!< Bit mask of TACQ field. */ -#define SAADC_CH_CONFIG_TACQ_3us (0UL) /*!< 3 us */ -#define SAADC_CH_CONFIG_TACQ_5us (1UL) /*!< 5 us */ -#define SAADC_CH_CONFIG_TACQ_10us (2UL) /*!< 10 us */ -#define SAADC_CH_CONFIG_TACQ_15us (3UL) /*!< 15 us */ -#define SAADC_CH_CONFIG_TACQ_20us (4UL) /*!< 20 us */ -#define SAADC_CH_CONFIG_TACQ_40us (5UL) /*!< 40 us */ - -/* Bit 12 : Reference control */ -#define SAADC_CH_CONFIG_REFSEL_Pos (12UL) /*!< Position of REFSEL field. */ -#define SAADC_CH_CONFIG_REFSEL_Msk (0x1UL << SAADC_CH_CONFIG_REFSEL_Pos) /*!< Bit mask of REFSEL field. */ -#define SAADC_CH_CONFIG_REFSEL_Internal (0UL) /*!< Internal reference (0.6 V) */ -#define SAADC_CH_CONFIG_REFSEL_VDD1_4 (1UL) /*!< VDD/4 as reference */ - -/* Bits 10..8 : Gain control */ -#define SAADC_CH_CONFIG_GAIN_Pos (8UL) /*!< Position of GAIN field. */ -#define SAADC_CH_CONFIG_GAIN_Msk (0x7UL << SAADC_CH_CONFIG_GAIN_Pos) /*!< Bit mask of GAIN field. */ -#define SAADC_CH_CONFIG_GAIN_Gain1_6 (0UL) /*!< 1/6 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_5 (1UL) /*!< 1/5 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_4 (2UL) /*!< 1/4 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_3 (3UL) /*!< 1/3 */ -#define SAADC_CH_CONFIG_GAIN_Gain1_2 (4UL) /*!< 1/2 */ -#define SAADC_CH_CONFIG_GAIN_Gain1 (5UL) /*!< 1 */ -#define SAADC_CH_CONFIG_GAIN_Gain2 (6UL) /*!< 2 */ -#define SAADC_CH_CONFIG_GAIN_Gain4 (7UL) /*!< 4 */ - -/* Bits 5..4 : Negative channel resistor control */ -#define SAADC_CH_CONFIG_RESN_Pos (4UL) /*!< Position of RESN field. */ -#define SAADC_CH_CONFIG_RESN_Msk (0x3UL << SAADC_CH_CONFIG_RESN_Pos) /*!< Bit mask of RESN field. */ -#define SAADC_CH_CONFIG_RESN_Bypass (0UL) /*!< Bypass resistor ladder */ -#define SAADC_CH_CONFIG_RESN_Pulldown (1UL) /*!< Pull-down to GND */ -#define SAADC_CH_CONFIG_RESN_Pullup (2UL) /*!< Pull-up to VDD */ -#define SAADC_CH_CONFIG_RESN_VDD1_2 (3UL) /*!< Set input at VDD/2 */ - -/* Bits 1..0 : Positive channel resistor control */ -#define SAADC_CH_CONFIG_RESP_Pos (0UL) /*!< Position of RESP field. */ -#define SAADC_CH_CONFIG_RESP_Msk (0x3UL << SAADC_CH_CONFIG_RESP_Pos) /*!< Bit mask of RESP field. */ -#define SAADC_CH_CONFIG_RESP_Bypass (0UL) /*!< Bypass resistor ladder */ -#define SAADC_CH_CONFIG_RESP_Pulldown (1UL) /*!< Pull-down to GND */ -#define SAADC_CH_CONFIG_RESP_Pullup (2UL) /*!< Pull-up to VDD */ -#define SAADC_CH_CONFIG_RESP_VDD1_2 (3UL) /*!< Set input at VDD/2 */ - -/* Register: SAADC_CH_LIMIT */ -/* Description: Description cluster[0]: High/low limits for event monitoring a channel */ - -/* Bits 31..16 : High level limit */ -#define SAADC_CH_LIMIT_HIGH_Pos (16UL) /*!< Position of HIGH field. */ -#define SAADC_CH_LIMIT_HIGH_Msk (0xFFFFUL << SAADC_CH_LIMIT_HIGH_Pos) /*!< Bit mask of HIGH field. */ - -/* Bits 15..0 : Low level limit */ -#define SAADC_CH_LIMIT_LOW_Pos (0UL) /*!< Position of LOW field. */ -#define SAADC_CH_LIMIT_LOW_Msk (0xFFFFUL << SAADC_CH_LIMIT_LOW_Pos) /*!< Bit mask of LOW field. */ - -/* Register: SAADC_RESOLUTION */ -/* Description: Resolution configuration */ - -/* Bits 2..0 : Set the resolution */ -#define SAADC_RESOLUTION_VAL_Pos (0UL) /*!< Position of VAL field. */ -#define SAADC_RESOLUTION_VAL_Msk (0x7UL << SAADC_RESOLUTION_VAL_Pos) /*!< Bit mask of VAL field. */ -#define SAADC_RESOLUTION_VAL_8bit (0UL) /*!< 8 bit */ -#define SAADC_RESOLUTION_VAL_10bit (1UL) /*!< 10 bit */ -#define SAADC_RESOLUTION_VAL_12bit (2UL) /*!< 12 bit */ -#define SAADC_RESOLUTION_VAL_14bit (3UL) /*!< 14 bit */ - -/* Register: SAADC_OVERSAMPLE */ -/* Description: Oversampling configuration. OVERSAMPLE should not be combined with SCAN. The RESOLUTION is applied before averaging, thus for high OVERSAMPLE a higher RESOLUTION should be used. */ - -/* Bits 3..0 : Oversample control */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Pos (0UL) /*!< Position of OVERSAMPLE field. */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Msk (0xFUL << SAADC_OVERSAMPLE_OVERSAMPLE_Pos) /*!< Bit mask of OVERSAMPLE field. */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Bypass (0UL) /*!< Bypass oversampling */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over2x (1UL) /*!< Oversample 2x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over4x (2UL) /*!< Oversample 4x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over8x (3UL) /*!< Oversample 8x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over16x (4UL) /*!< Oversample 16x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over32x (5UL) /*!< Oversample 32x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over64x (6UL) /*!< Oversample 64x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over128x (7UL) /*!< Oversample 128x */ -#define SAADC_OVERSAMPLE_OVERSAMPLE_Over256x (8UL) /*!< Oversample 256x */ - -/* Register: SAADC_SAMPLERATE */ -/* Description: Controls normal or continuous sample rate */ - -/* Bit 12 : Select mode for sample rate control */ -#define SAADC_SAMPLERATE_MODE_Pos (12UL) /*!< Position of MODE field. */ -#define SAADC_SAMPLERATE_MODE_Msk (0x1UL << SAADC_SAMPLERATE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define SAADC_SAMPLERATE_MODE_Task (0UL) /*!< Rate is controlled from SAMPLE task */ -#define SAADC_SAMPLERATE_MODE_Timers (1UL) /*!< Rate is controlled from local timer (use CC to control the rate) */ - -/* Bits 10..0 : Capture and compare value. Sample rate is 16 MHz/CC */ -#define SAADC_SAMPLERATE_CC_Pos (0UL) /*!< Position of CC field. */ -#define SAADC_SAMPLERATE_CC_Msk (0x7FFUL << SAADC_SAMPLERATE_CC_Pos) /*!< Bit mask of CC field. */ - -/* Register: SAADC_RESULT_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define SAADC_RESULT_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SAADC_RESULT_PTR_PTR_Msk (0xFFFFFFFFUL << SAADC_RESULT_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SAADC_RESULT_MAXCNT */ -/* Description: Maximum number of buffer words to transfer */ - -/* Bits 14..0 : Maximum number of buffer words to transfer */ -#define SAADC_RESULT_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SAADC_RESULT_MAXCNT_MAXCNT_Msk (0x7FFFUL << SAADC_RESULT_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SAADC_RESULT_AMOUNT */ -/* Description: Number of buffer words transferred since last START */ - -/* Bits 14..0 : Number of buffer words transferred since last START. This register can be read after an END or STOPPED event. */ -#define SAADC_RESULT_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SAADC_RESULT_AMOUNT_AMOUNT_Msk (0x7FFFUL << SAADC_RESULT_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - - -/* Peripheral: SPI */ -/* Description: Serial Peripheral Interface 0 */ - -/* Register: SPI_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 2 : Write '1' to Enable interrupt for READY event */ -#define SPI_INTENSET_READY_Pos (2UL) /*!< Position of READY field. */ -#define SPI_INTENSET_READY_Msk (0x1UL << SPI_INTENSET_READY_Pos) /*!< Bit mask of READY field. */ -#define SPI_INTENSET_READY_Disabled (0UL) /*!< Read: Disabled */ -#define SPI_INTENSET_READY_Enabled (1UL) /*!< Read: Enabled */ -#define SPI_INTENSET_READY_Set (1UL) /*!< Enable */ - -/* Register: SPI_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 2 : Write '1' to Disable interrupt for READY event */ -#define SPI_INTENCLR_READY_Pos (2UL) /*!< Position of READY field. */ -#define SPI_INTENCLR_READY_Msk (0x1UL << SPI_INTENCLR_READY_Pos) /*!< Bit mask of READY field. */ -#define SPI_INTENCLR_READY_Disabled (0UL) /*!< Read: Disabled */ -#define SPI_INTENCLR_READY_Enabled (1UL) /*!< Read: Enabled */ -#define SPI_INTENCLR_READY_Clear (1UL) /*!< Disable */ - -/* Register: SPI_ENABLE */ -/* Description: Enable SPI */ - -/* Bits 3..0 : Enable or disable SPI */ -#define SPI_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPI_ENABLE_ENABLE_Msk (0xFUL << SPI_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPI_ENABLE_ENABLE_Disabled (0UL) /*!< Disable SPI */ -#define SPI_ENABLE_ENABLE_Enabled (1UL) /*!< Enable SPI */ - -/* Register: SPI_PSEL_SCK */ -/* Description: Pin select for SCK */ - -/* Bit 31 : Connection */ -#define SPI_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPI_PSEL_SCK_CONNECT_Msk (0x1UL << SPI_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPI_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define SPI_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPI_PSEL_SCK_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPI_PSEL_SCK_PORT_Msk (0x1UL << SPI_PSEL_SCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPI_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPI_PSEL_SCK_PIN_Msk (0x1FUL << SPI_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPI_PSEL_MOSI */ -/* Description: Pin select for MOSI signal */ - -/* Bit 31 : Connection */ -#define SPI_PSEL_MOSI_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPI_PSEL_MOSI_CONNECT_Msk (0x1UL << SPI_PSEL_MOSI_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPI_PSEL_MOSI_CONNECT_Connected (0UL) /*!< Connect */ -#define SPI_PSEL_MOSI_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPI_PSEL_MOSI_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPI_PSEL_MOSI_PORT_Msk (0x1UL << SPI_PSEL_MOSI_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPI_PSEL_MOSI_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPI_PSEL_MOSI_PIN_Msk (0x1FUL << SPI_PSEL_MOSI_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPI_PSEL_MISO */ -/* Description: Pin select for MISO signal */ - -/* Bit 31 : Connection */ -#define SPI_PSEL_MISO_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPI_PSEL_MISO_CONNECT_Msk (0x1UL << SPI_PSEL_MISO_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPI_PSEL_MISO_CONNECT_Connected (0UL) /*!< Connect */ -#define SPI_PSEL_MISO_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPI_PSEL_MISO_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPI_PSEL_MISO_PORT_Msk (0x1UL << SPI_PSEL_MISO_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPI_PSEL_MISO_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPI_PSEL_MISO_PIN_Msk (0x1FUL << SPI_PSEL_MISO_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPI_RXD */ -/* Description: RXD register */ - -/* Bits 7..0 : RX data received. Double buffered */ -#define SPI_RXD_RXD_Pos (0UL) /*!< Position of RXD field. */ -#define SPI_RXD_RXD_Msk (0xFFUL << SPI_RXD_RXD_Pos) /*!< Bit mask of RXD field. */ - -/* Register: SPI_TXD */ -/* Description: TXD register */ - -/* Bits 7..0 : TX data to send. Double buffered */ -#define SPI_TXD_TXD_Pos (0UL) /*!< Position of TXD field. */ -#define SPI_TXD_TXD_Msk (0xFFUL << SPI_TXD_TXD_Pos) /*!< Bit mask of TXD field. */ - -/* Register: SPI_FREQUENCY */ -/* Description: SPI frequency. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : SPI master data rate */ -#define SPI_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define SPI_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << SPI_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define SPI_FREQUENCY_FREQUENCY_K125 (0x02000000UL) /*!< 125 kbps */ -#define SPI_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */ -#define SPI_FREQUENCY_FREQUENCY_K500 (0x08000000UL) /*!< 500 kbps */ -#define SPI_FREQUENCY_FREQUENCY_M1 (0x10000000UL) /*!< 1 Mbps */ -#define SPI_FREQUENCY_FREQUENCY_M2 (0x20000000UL) /*!< 2 Mbps */ -#define SPI_FREQUENCY_FREQUENCY_M4 (0x40000000UL) /*!< 4 Mbps */ -#define SPI_FREQUENCY_FREQUENCY_M8 (0x80000000UL) /*!< 8 Mbps */ - -/* Register: SPI_CONFIG */ -/* Description: Configuration register */ - -/* Bit 2 : Serial clock (SCK) polarity */ -#define SPI_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPI_CONFIG_CPOL_Msk (0x1UL << SPI_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPI_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high */ -#define SPI_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low */ - -/* Bit 1 : Serial clock (SCK) phase */ -#define SPI_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPI_CONFIG_CPHA_Msk (0x1UL << SPI_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPI_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of clock, shift serial data on trailing edge */ -#define SPI_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of clock, shift serial data on leading edge */ - -/* Bit 0 : Bit order */ -#define SPI_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPI_CONFIG_ORDER_Msk (0x1UL << SPI_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPI_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit shifted out first */ -#define SPI_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit shifted out first */ - - -/* Peripheral: SPIM */ -/* Description: Serial Peripheral Interface Master with EasyDMA 0 */ - -/* Register: SPIM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 17 : Shortcut between END event and START task */ -#define SPIM_SHORTS_END_START_Pos (17UL) /*!< Position of END_START field. */ -#define SPIM_SHORTS_END_START_Msk (0x1UL << SPIM_SHORTS_END_START_Pos) /*!< Bit mask of END_START field. */ -#define SPIM_SHORTS_END_START_Disabled (0UL) /*!< Disable shortcut */ -#define SPIM_SHORTS_END_START_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: SPIM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 19 : Write '1' to Enable interrupt for STARTED event */ -#define SPIM_INTENSET_STARTED_Pos (19UL) /*!< Position of STARTED field. */ -#define SPIM_INTENSET_STARTED_Msk (0x1UL << SPIM_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SPIM_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for ENDTX event */ -#define SPIM_INTENSET_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define SPIM_INTENSET_ENDTX_Msk (0x1UL << SPIM_INTENSET_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define SPIM_INTENSET_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_ENDTX_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for END event */ -#define SPIM_INTENSET_END_Pos (6UL) /*!< Position of END field. */ -#define SPIM_INTENSET_END_Msk (0x1UL << SPIM_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SPIM_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDRX event */ -#define SPIM_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIM_INTENSET_ENDRX_Msk (0x1UL << SPIM_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIM_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define SPIM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define SPIM_INTENSET_STOPPED_Msk (0x1UL << SPIM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SPIM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: SPIM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 19 : Write '1' to Disable interrupt for STARTED event */ -#define SPIM_INTENCLR_STARTED_Pos (19UL) /*!< Position of STARTED field. */ -#define SPIM_INTENCLR_STARTED_Msk (0x1UL << SPIM_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define SPIM_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for ENDTX event */ -#define SPIM_INTENCLR_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define SPIM_INTENCLR_ENDTX_Msk (0x1UL << SPIM_INTENCLR_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define SPIM_INTENCLR_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_ENDTX_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for END event */ -#define SPIM_INTENCLR_END_Pos (6UL) /*!< Position of END field. */ -#define SPIM_INTENCLR_END_Msk (0x1UL << SPIM_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SPIM_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDRX event */ -#define SPIM_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIM_INTENCLR_ENDRX_Msk (0x1UL << SPIM_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIM_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define SPIM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define SPIM_INTENCLR_STOPPED_Msk (0x1UL << SPIM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define SPIM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: SPIM_STALLSTAT */ -/* Description: Stall status for EasyDMA RAM accesses. The fields in this register is set to STALL by hardware whenever a stall occurres and can be cleared (set to NOSTALL) by the CPU. */ - -/* Bit 1 : Stall status for EasyDMA RAM writes */ -#define SPIM_STALLSTAT_RX_Pos (1UL) /*!< Position of RX field. */ -#define SPIM_STALLSTAT_RX_Msk (0x1UL << SPIM_STALLSTAT_RX_Pos) /*!< Bit mask of RX field. */ -#define SPIM_STALLSTAT_RX_NOSTALL (0UL) /*!< No stall */ -#define SPIM_STALLSTAT_RX_STALL (1UL) /*!< A stall has occurred */ - -/* Bit 0 : Stall status for EasyDMA RAM reads */ -#define SPIM_STALLSTAT_TX_Pos (0UL) /*!< Position of TX field. */ -#define SPIM_STALLSTAT_TX_Msk (0x1UL << SPIM_STALLSTAT_TX_Pos) /*!< Bit mask of TX field. */ -#define SPIM_STALLSTAT_TX_NOSTALL (0UL) /*!< No stall */ -#define SPIM_STALLSTAT_TX_STALL (1UL) /*!< A stall has occurred */ - -/* Register: SPIM_ENABLE */ -/* Description: Enable SPIM */ - -/* Bits 3..0 : Enable or disable SPIM */ -#define SPIM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPIM_ENABLE_ENABLE_Msk (0xFUL << SPIM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPIM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable SPIM */ -#define SPIM_ENABLE_ENABLE_Enabled (7UL) /*!< Enable SPIM */ - -/* Register: SPIM_PSEL_SCK */ -/* Description: Pin select for SCK */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_SCK_CONNECT_Msk (0x1UL << SPIM_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIM_PSEL_SCK_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIM_PSEL_SCK_PORT_Msk (0x1UL << SPIM_PSEL_SCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_SCK_PIN_Msk (0x1FUL << SPIM_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_PSEL_MOSI */ -/* Description: Pin select for MOSI signal */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_MOSI_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_MOSI_CONNECT_Msk (0x1UL << SPIM_PSEL_MOSI_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_MOSI_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_MOSI_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIM_PSEL_MOSI_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIM_PSEL_MOSI_PORT_Msk (0x1UL << SPIM_PSEL_MOSI_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_MOSI_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_MOSI_PIN_Msk (0x1FUL << SPIM_PSEL_MOSI_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_PSEL_MISO */ -/* Description: Pin select for MISO signal */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_MISO_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_MISO_CONNECT_Msk (0x1UL << SPIM_PSEL_MISO_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_MISO_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_MISO_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIM_PSEL_MISO_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIM_PSEL_MISO_PORT_Msk (0x1UL << SPIM_PSEL_MISO_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_MISO_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_MISO_PIN_Msk (0x1FUL << SPIM_PSEL_MISO_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_PSEL_CSN */ -/* Description: Pin select for CSN */ - -/* Bit 31 : Connection */ -#define SPIM_PSEL_CSN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSEL_CSN_CONNECT_Msk (0x1UL << SPIM_PSEL_CSN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSEL_CSN_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSEL_CSN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIM_PSEL_CSN_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIM_PSEL_CSN_PORT_Msk (0x1UL << SPIM_PSEL_CSN_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSEL_CSN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSEL_CSN_PIN_Msk (0x1FUL << SPIM_PSEL_CSN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_FREQUENCY */ -/* Description: SPI frequency. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : SPI master data rate */ -#define SPIM_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define SPIM_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << SPIM_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define SPIM_FREQUENCY_FREQUENCY_K125 (0x02000000UL) /*!< 125 kbps */ -#define SPIM_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */ -#define SPIM_FREQUENCY_FREQUENCY_K500 (0x08000000UL) /*!< 500 kbps */ -#define SPIM_FREQUENCY_FREQUENCY_M16 (0x0A000000UL) /*!< 16 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M1 (0x10000000UL) /*!< 1 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M32 (0x14000000UL) /*!< 32 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M2 (0x20000000UL) /*!< 2 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M4 (0x40000000UL) /*!< 4 Mbps */ -#define SPIM_FREQUENCY_FREQUENCY_M8 (0x80000000UL) /*!< 8 Mbps */ - -/* Register: SPIM_RXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define SPIM_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIM_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIM_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIM_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 15..0 : Maximum number of bytes in receive buffer */ -#define SPIM_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIM_RXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << SPIM_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIM_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last transaction */ -#define SPIM_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIM_RXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << SPIM_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIM_RXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 1..0 : List type */ -#define SPIM_RXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define SPIM_RXD_LIST_LIST_Msk (0x3UL << SPIM_RXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define SPIM_RXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define SPIM_RXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: SPIM_TXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define SPIM_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIM_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIM_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIM_TXD_MAXCNT */ -/* Description: Number of bytes in transmit buffer */ - -/* Bits 15..0 : Maximum number of bytes in transmit buffer */ -#define SPIM_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIM_TXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << SPIM_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIM_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last transaction */ -#define SPIM_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIM_TXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << SPIM_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIM_TXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 1..0 : List type */ -#define SPIM_TXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define SPIM_TXD_LIST_LIST_Msk (0x3UL << SPIM_TXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define SPIM_TXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define SPIM_TXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: SPIM_CONFIG */ -/* Description: Configuration register */ - -/* Bit 2 : Serial clock (SCK) polarity */ -#define SPIM_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPIM_CONFIG_CPOL_Msk (0x1UL << SPIM_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPIM_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high */ -#define SPIM_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low */ - -/* Bit 1 : Serial clock (SCK) phase */ -#define SPIM_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPIM_CONFIG_CPHA_Msk (0x1UL << SPIM_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPIM_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of clock, shift serial data on trailing edge */ -#define SPIM_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of clock, shift serial data on leading edge */ - -/* Bit 0 : Bit order */ -#define SPIM_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPIM_CONFIG_ORDER_Msk (0x1UL << SPIM_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPIM_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit shifted out first */ -#define SPIM_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit shifted out first */ - -/* Register: SPIM_IFTIMING_RXDELAY */ -/* Description: Sample delay for input serial data on MISO */ - -/* Bits 2..0 : Sample delay for input serial data on MISO. The value specifies the number of 64 MHz clock cycles (15.625 ns) delay from the the sampling edge of SCK (leading edge for CONFIG.CPHA = 0, trailing edge for CONFIG.CPHA = 1) until the input serial data is sampled. As en example, if RXDELAY = 0 and CONFIG.CPHA = 0, the input serial data is sampled on the rising edge of SCK. */ -#define SPIM_IFTIMING_RXDELAY_RXDELAY_Pos (0UL) /*!< Position of RXDELAY field. */ -#define SPIM_IFTIMING_RXDELAY_RXDELAY_Msk (0x7UL << SPIM_IFTIMING_RXDELAY_RXDELAY_Pos) /*!< Bit mask of RXDELAY field. */ - -/* Register: SPIM_IFTIMING_CSNDUR */ -/* Description: Minimum duration between edge of CSN and edge of SCK and minimum duration CSN must stay high between transactions */ - -/* Bits 7..0 : Minimum duration between edge of CSN and edge of SCK and minimum duration CSN must stay high between transactions. The value is specified in number of 64 MHz clock cycles (15.625 ns). */ -#define SPIM_IFTIMING_CSNDUR_CSNDUR_Pos (0UL) /*!< Position of CSNDUR field. */ -#define SPIM_IFTIMING_CSNDUR_CSNDUR_Msk (0xFFUL << SPIM_IFTIMING_CSNDUR_CSNDUR_Pos) /*!< Bit mask of CSNDUR field. */ - -/* Register: SPIM_CSNPOL */ -/* Description: Polarity of CSN output */ - -/* Bit 0 : Polarity of CSN output */ -#define SPIM_CSNPOL_CSNPOL_Pos (0UL) /*!< Position of CSNPOL field. */ -#define SPIM_CSNPOL_CSNPOL_Msk (0x1UL << SPIM_CSNPOL_CSNPOL_Pos) /*!< Bit mask of CSNPOL field. */ -#define SPIM_CSNPOL_CSNPOL_LOW (0UL) /*!< Active low (idle state high) */ -#define SPIM_CSNPOL_CSNPOL_HIGH (1UL) /*!< Active high (idle state low) */ - -/* Register: SPIM_PSELDCX */ -/* Description: Pin select for DCX signal */ - -/* Bit 31 : Connection */ -#define SPIM_PSELDCX_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIM_PSELDCX_CONNECT_Msk (0x1UL << SPIM_PSELDCX_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIM_PSELDCX_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIM_PSELDCX_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIM_PSELDCX_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIM_PSELDCX_PORT_Msk (0x1UL << SPIM_PSELDCX_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIM_PSELDCX_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIM_PSELDCX_PIN_Msk (0x1FUL << SPIM_PSELDCX_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIM_DCXCNT */ -/* Description: DCX configuration */ - -/* Bits 3..0 : This register specifies the number of command bytes preceding the data bytes. The PSEL.DCX line will be low during transmission of command bytes and high during transmission of data bytes. Value 0xF indicates that all bytes are command bytes. */ -#define SPIM_DCXCNT_DCXCNT_Pos (0UL) /*!< Position of DCXCNT field. */ -#define SPIM_DCXCNT_DCXCNT_Msk (0xFUL << SPIM_DCXCNT_DCXCNT_Pos) /*!< Bit mask of DCXCNT field. */ - -/* Register: SPIM_ORC */ -/* Description: Byte transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT */ - -/* Bits 7..0 : Byte transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT. */ -#define SPIM_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define SPIM_ORC_ORC_Msk (0xFFUL << SPIM_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - - -/* Peripheral: SPIS */ -/* Description: SPI Slave 0 */ - -/* Register: SPIS_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 2 : Shortcut between END event and ACQUIRE task */ -#define SPIS_SHORTS_END_ACQUIRE_Pos (2UL) /*!< Position of END_ACQUIRE field. */ -#define SPIS_SHORTS_END_ACQUIRE_Msk (0x1UL << SPIS_SHORTS_END_ACQUIRE_Pos) /*!< Bit mask of END_ACQUIRE field. */ -#define SPIS_SHORTS_END_ACQUIRE_Disabled (0UL) /*!< Disable shortcut */ -#define SPIS_SHORTS_END_ACQUIRE_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: SPIS_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 10 : Write '1' to Enable interrupt for ACQUIRED event */ -#define SPIS_INTENSET_ACQUIRED_Pos (10UL) /*!< Position of ACQUIRED field. */ -#define SPIS_INTENSET_ACQUIRED_Msk (0x1UL << SPIS_INTENSET_ACQUIRED_Pos) /*!< Bit mask of ACQUIRED field. */ -#define SPIS_INTENSET_ACQUIRED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENSET_ACQUIRED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENSET_ACQUIRED_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDRX event */ -#define SPIS_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIS_INTENSET_ENDRX_Msk (0x1UL << SPIS_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIS_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for END event */ -#define SPIS_INTENSET_END_Pos (1UL) /*!< Position of END field. */ -#define SPIS_INTENSET_END_Msk (0x1UL << SPIS_INTENSET_END_Pos) /*!< Bit mask of END field. */ -#define SPIS_INTENSET_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENSET_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENSET_END_Set (1UL) /*!< Enable */ - -/* Register: SPIS_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 10 : Write '1' to Disable interrupt for ACQUIRED event */ -#define SPIS_INTENCLR_ACQUIRED_Pos (10UL) /*!< Position of ACQUIRED field. */ -#define SPIS_INTENCLR_ACQUIRED_Msk (0x1UL << SPIS_INTENCLR_ACQUIRED_Pos) /*!< Bit mask of ACQUIRED field. */ -#define SPIS_INTENCLR_ACQUIRED_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENCLR_ACQUIRED_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENCLR_ACQUIRED_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDRX event */ -#define SPIS_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define SPIS_INTENCLR_ENDRX_Msk (0x1UL << SPIS_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define SPIS_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for END event */ -#define SPIS_INTENCLR_END_Pos (1UL) /*!< Position of END field. */ -#define SPIS_INTENCLR_END_Msk (0x1UL << SPIS_INTENCLR_END_Pos) /*!< Bit mask of END field. */ -#define SPIS_INTENCLR_END_Disabled (0UL) /*!< Read: Disabled */ -#define SPIS_INTENCLR_END_Enabled (1UL) /*!< Read: Enabled */ -#define SPIS_INTENCLR_END_Clear (1UL) /*!< Disable */ - -/* Register: SPIS_SEMSTAT */ -/* Description: Semaphore status register */ - -/* Bits 1..0 : Semaphore status */ -#define SPIS_SEMSTAT_SEMSTAT_Pos (0UL) /*!< Position of SEMSTAT field. */ -#define SPIS_SEMSTAT_SEMSTAT_Msk (0x3UL << SPIS_SEMSTAT_SEMSTAT_Pos) /*!< Bit mask of SEMSTAT field. */ -#define SPIS_SEMSTAT_SEMSTAT_Free (0UL) /*!< Semaphore is free */ -#define SPIS_SEMSTAT_SEMSTAT_CPU (1UL) /*!< Semaphore is assigned to CPU */ -#define SPIS_SEMSTAT_SEMSTAT_SPIS (2UL) /*!< Semaphore is assigned to SPI slave */ -#define SPIS_SEMSTAT_SEMSTAT_CPUPending (3UL) /*!< Semaphore is assigned to SPI but a handover to the CPU is pending */ - -/* Register: SPIS_STATUS */ -/* Description: Status from last transaction */ - -/* Bit 1 : RX buffer overflow detected, and prevented */ -#define SPIS_STATUS_OVERFLOW_Pos (1UL) /*!< Position of OVERFLOW field. */ -#define SPIS_STATUS_OVERFLOW_Msk (0x1UL << SPIS_STATUS_OVERFLOW_Pos) /*!< Bit mask of OVERFLOW field. */ -#define SPIS_STATUS_OVERFLOW_NotPresent (0UL) /*!< Read: error not present */ -#define SPIS_STATUS_OVERFLOW_Present (1UL) /*!< Read: error present */ -#define SPIS_STATUS_OVERFLOW_Clear (1UL) /*!< Write: clear error on writing '1' */ - -/* Bit 0 : TX buffer over-read detected, and prevented */ -#define SPIS_STATUS_OVERREAD_Pos (0UL) /*!< Position of OVERREAD field. */ -#define SPIS_STATUS_OVERREAD_Msk (0x1UL << SPIS_STATUS_OVERREAD_Pos) /*!< Bit mask of OVERREAD field. */ -#define SPIS_STATUS_OVERREAD_NotPresent (0UL) /*!< Read: error not present */ -#define SPIS_STATUS_OVERREAD_Present (1UL) /*!< Read: error present */ -#define SPIS_STATUS_OVERREAD_Clear (1UL) /*!< Write: clear error on writing '1' */ - -/* Register: SPIS_ENABLE */ -/* Description: Enable SPI slave */ - -/* Bits 3..0 : Enable or disable SPI slave */ -#define SPIS_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define SPIS_ENABLE_ENABLE_Msk (0xFUL << SPIS_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define SPIS_ENABLE_ENABLE_Disabled (0UL) /*!< Disable SPI slave */ -#define SPIS_ENABLE_ENABLE_Enabled (2UL) /*!< Enable SPI slave */ - -/* Register: SPIS_PSEL_SCK */ -/* Description: Pin select for SCK */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_SCK_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_SCK_CONNECT_Msk (0x1UL << SPIS_PSEL_SCK_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_SCK_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_SCK_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIS_PSEL_SCK_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIS_PSEL_SCK_PORT_Msk (0x1UL << SPIS_PSEL_SCK_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_SCK_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_SCK_PIN_Msk (0x1FUL << SPIS_PSEL_SCK_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_PSEL_MISO */ -/* Description: Pin select for MISO signal */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_MISO_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_MISO_CONNECT_Msk (0x1UL << SPIS_PSEL_MISO_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_MISO_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_MISO_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIS_PSEL_MISO_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIS_PSEL_MISO_PORT_Msk (0x1UL << SPIS_PSEL_MISO_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_MISO_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_MISO_PIN_Msk (0x1FUL << SPIS_PSEL_MISO_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_PSEL_MOSI */ -/* Description: Pin select for MOSI signal */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_MOSI_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_MOSI_CONNECT_Msk (0x1UL << SPIS_PSEL_MOSI_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_MOSI_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_MOSI_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIS_PSEL_MOSI_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIS_PSEL_MOSI_PORT_Msk (0x1UL << SPIS_PSEL_MOSI_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_MOSI_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_MOSI_PIN_Msk (0x1FUL << SPIS_PSEL_MOSI_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_PSEL_CSN */ -/* Description: Pin select for CSN signal */ - -/* Bit 31 : Connection */ -#define SPIS_PSEL_CSN_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define SPIS_PSEL_CSN_CONNECT_Msk (0x1UL << SPIS_PSEL_CSN_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define SPIS_PSEL_CSN_CONNECT_Connected (0UL) /*!< Connect */ -#define SPIS_PSEL_CSN_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define SPIS_PSEL_CSN_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define SPIS_PSEL_CSN_PORT_Msk (0x1UL << SPIS_PSEL_CSN_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define SPIS_PSEL_CSN_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define SPIS_PSEL_CSN_PIN_Msk (0x1FUL << SPIS_PSEL_CSN_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: SPIS_RXD_PTR */ -/* Description: RXD data pointer */ - -/* Bits 31..0 : RXD data pointer */ -#define SPIS_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIS_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIS_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIS_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 15..0 : Maximum number of bytes in receive buffer */ -#define SPIS_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIS_RXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << SPIS_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIS_RXD_AMOUNT */ -/* Description: Number of bytes received in last granted transaction */ - -/* Bits 15..0 : Number of bytes received in the last granted transaction */ -#define SPIS_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIS_RXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << SPIS_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIS_TXD_PTR */ -/* Description: TXD data pointer */ - -/* Bits 31..0 : TXD data pointer */ -#define SPIS_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define SPIS_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << SPIS_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: SPIS_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 15..0 : Maximum number of bytes in transmit buffer */ -#define SPIS_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define SPIS_TXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << SPIS_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: SPIS_TXD_AMOUNT */ -/* Description: Number of bytes transmitted in last granted transaction */ - -/* Bits 15..0 : Number of bytes transmitted in last granted transaction */ -#define SPIS_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define SPIS_TXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << SPIS_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: SPIS_CONFIG */ -/* Description: Configuration register */ - -/* Bit 2 : Serial clock (SCK) polarity */ -#define SPIS_CONFIG_CPOL_Pos (2UL) /*!< Position of CPOL field. */ -#define SPIS_CONFIG_CPOL_Msk (0x1UL << SPIS_CONFIG_CPOL_Pos) /*!< Bit mask of CPOL field. */ -#define SPIS_CONFIG_CPOL_ActiveHigh (0UL) /*!< Active high */ -#define SPIS_CONFIG_CPOL_ActiveLow (1UL) /*!< Active low */ - -/* Bit 1 : Serial clock (SCK) phase */ -#define SPIS_CONFIG_CPHA_Pos (1UL) /*!< Position of CPHA field. */ -#define SPIS_CONFIG_CPHA_Msk (0x1UL << SPIS_CONFIG_CPHA_Pos) /*!< Bit mask of CPHA field. */ -#define SPIS_CONFIG_CPHA_Leading (0UL) /*!< Sample on leading edge of clock, shift serial data on trailing edge */ -#define SPIS_CONFIG_CPHA_Trailing (1UL) /*!< Sample on trailing edge of clock, shift serial data on leading edge */ - -/* Bit 0 : Bit order */ -#define SPIS_CONFIG_ORDER_Pos (0UL) /*!< Position of ORDER field. */ -#define SPIS_CONFIG_ORDER_Msk (0x1UL << SPIS_CONFIG_ORDER_Pos) /*!< Bit mask of ORDER field. */ -#define SPIS_CONFIG_ORDER_MsbFirst (0UL) /*!< Most significant bit shifted out first */ -#define SPIS_CONFIG_ORDER_LsbFirst (1UL) /*!< Least significant bit shifted out first */ - -/* Register: SPIS_DEF */ -/* Description: Default character. Character clocked out in case of an ignored transaction. */ - -/* Bits 7..0 : Default character. Character clocked out in case of an ignored transaction. */ -#define SPIS_DEF_DEF_Pos (0UL) /*!< Position of DEF field. */ -#define SPIS_DEF_DEF_Msk (0xFFUL << SPIS_DEF_DEF_Pos) /*!< Bit mask of DEF field. */ - -/* Register: SPIS_ORC */ -/* Description: Over-read character */ - -/* Bits 7..0 : Over-read character. Character clocked out after an over-read of the transmit buffer. */ -#define SPIS_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define SPIS_ORC_ORC_Msk (0xFFUL << SPIS_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - - -/* Peripheral: TEMP */ -/* Description: Temperature Sensor */ - -/* Register: TEMP_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for DATARDY event */ -#define TEMP_INTENSET_DATARDY_Pos (0UL) /*!< Position of DATARDY field. */ -#define TEMP_INTENSET_DATARDY_Msk (0x1UL << TEMP_INTENSET_DATARDY_Pos) /*!< Bit mask of DATARDY field. */ -#define TEMP_INTENSET_DATARDY_Disabled (0UL) /*!< Read: Disabled */ -#define TEMP_INTENSET_DATARDY_Enabled (1UL) /*!< Read: Enabled */ -#define TEMP_INTENSET_DATARDY_Set (1UL) /*!< Enable */ - -/* Register: TEMP_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for DATARDY event */ -#define TEMP_INTENCLR_DATARDY_Pos (0UL) /*!< Position of DATARDY field. */ -#define TEMP_INTENCLR_DATARDY_Msk (0x1UL << TEMP_INTENCLR_DATARDY_Pos) /*!< Bit mask of DATARDY field. */ -#define TEMP_INTENCLR_DATARDY_Disabled (0UL) /*!< Read: Disabled */ -#define TEMP_INTENCLR_DATARDY_Enabled (1UL) /*!< Read: Enabled */ -#define TEMP_INTENCLR_DATARDY_Clear (1UL) /*!< Disable */ - -/* Register: TEMP_TEMP */ -/* Description: Temperature in degC (0.25deg steps) */ - -/* Bits 31..0 : Temperature in degC (0.25deg steps) */ -#define TEMP_TEMP_TEMP_Pos (0UL) /*!< Position of TEMP field. */ -#define TEMP_TEMP_TEMP_Msk (0xFFFFFFFFUL << TEMP_TEMP_TEMP_Pos) /*!< Bit mask of TEMP field. */ - -/* Register: TEMP_A0 */ -/* Description: Slope of 1st piece wise linear function */ - -/* Bits 11..0 : Slope of 1st piece wise linear function */ -#define TEMP_A0_A0_Pos (0UL) /*!< Position of A0 field. */ -#define TEMP_A0_A0_Msk (0xFFFUL << TEMP_A0_A0_Pos) /*!< Bit mask of A0 field. */ - -/* Register: TEMP_A1 */ -/* Description: Slope of 2nd piece wise linear function */ - -/* Bits 11..0 : Slope of 2nd piece wise linear function */ -#define TEMP_A1_A1_Pos (0UL) /*!< Position of A1 field. */ -#define TEMP_A1_A1_Msk (0xFFFUL << TEMP_A1_A1_Pos) /*!< Bit mask of A1 field. */ - -/* Register: TEMP_A2 */ -/* Description: Slope of 3rd piece wise linear function */ - -/* Bits 11..0 : Slope of 3rd piece wise linear function */ -#define TEMP_A2_A2_Pos (0UL) /*!< Position of A2 field. */ -#define TEMP_A2_A2_Msk (0xFFFUL << TEMP_A2_A2_Pos) /*!< Bit mask of A2 field. */ - -/* Register: TEMP_A3 */ -/* Description: Slope of 4th piece wise linear function */ - -/* Bits 11..0 : Slope of 4th piece wise linear function */ -#define TEMP_A3_A3_Pos (0UL) /*!< Position of A3 field. */ -#define TEMP_A3_A3_Msk (0xFFFUL << TEMP_A3_A3_Pos) /*!< Bit mask of A3 field. */ - -/* Register: TEMP_A4 */ -/* Description: Slope of 5th piece wise linear function */ - -/* Bits 11..0 : Slope of 5th piece wise linear function */ -#define TEMP_A4_A4_Pos (0UL) /*!< Position of A4 field. */ -#define TEMP_A4_A4_Msk (0xFFFUL << TEMP_A4_A4_Pos) /*!< Bit mask of A4 field. */ - -/* Register: TEMP_A5 */ -/* Description: Slope of 6th piece wise linear function */ - -/* Bits 11..0 : Slope of 6th piece wise linear function */ -#define TEMP_A5_A5_Pos (0UL) /*!< Position of A5 field. */ -#define TEMP_A5_A5_Msk (0xFFFUL << TEMP_A5_A5_Pos) /*!< Bit mask of A5 field. */ - -/* Register: TEMP_B0 */ -/* Description: y-intercept of 1st piece wise linear function */ - -/* Bits 13..0 : y-intercept of 1st piece wise linear function */ -#define TEMP_B0_B0_Pos (0UL) /*!< Position of B0 field. */ -#define TEMP_B0_B0_Msk (0x3FFFUL << TEMP_B0_B0_Pos) /*!< Bit mask of B0 field. */ - -/* Register: TEMP_B1 */ -/* Description: y-intercept of 2nd piece wise linear function */ - -/* Bits 13..0 : y-intercept of 2nd piece wise linear function */ -#define TEMP_B1_B1_Pos (0UL) /*!< Position of B1 field. */ -#define TEMP_B1_B1_Msk (0x3FFFUL << TEMP_B1_B1_Pos) /*!< Bit mask of B1 field. */ - -/* Register: TEMP_B2 */ -/* Description: y-intercept of 3rd piece wise linear function */ - -/* Bits 13..0 : y-intercept of 3rd piece wise linear function */ -#define TEMP_B2_B2_Pos (0UL) /*!< Position of B2 field. */ -#define TEMP_B2_B2_Msk (0x3FFFUL << TEMP_B2_B2_Pos) /*!< Bit mask of B2 field. */ - -/* Register: TEMP_B3 */ -/* Description: y-intercept of 4th piece wise linear function */ - -/* Bits 13..0 : y-intercept of 4th piece wise linear function */ -#define TEMP_B3_B3_Pos (0UL) /*!< Position of B3 field. */ -#define TEMP_B3_B3_Msk (0x3FFFUL << TEMP_B3_B3_Pos) /*!< Bit mask of B3 field. */ - -/* Register: TEMP_B4 */ -/* Description: y-intercept of 5th piece wise linear function */ - -/* Bits 13..0 : y-intercept of 5th piece wise linear function */ -#define TEMP_B4_B4_Pos (0UL) /*!< Position of B4 field. */ -#define TEMP_B4_B4_Msk (0x3FFFUL << TEMP_B4_B4_Pos) /*!< Bit mask of B4 field. */ - -/* Register: TEMP_B5 */ -/* Description: y-intercept of 6th piece wise linear function */ - -/* Bits 13..0 : y-intercept of 6th piece wise linear function */ -#define TEMP_B5_B5_Pos (0UL) /*!< Position of B5 field. */ -#define TEMP_B5_B5_Msk (0x3FFFUL << TEMP_B5_B5_Pos) /*!< Bit mask of B5 field. */ - -/* Register: TEMP_T0 */ -/* Description: End point of 1st piece wise linear function */ - -/* Bits 7..0 : End point of 1st piece wise linear function */ -#define TEMP_T0_T0_Pos (0UL) /*!< Position of T0 field. */ -#define TEMP_T0_T0_Msk (0xFFUL << TEMP_T0_T0_Pos) /*!< Bit mask of T0 field. */ - -/* Register: TEMP_T1 */ -/* Description: End point of 2nd piece wise linear function */ - -/* Bits 7..0 : End point of 2nd piece wise linear function */ -#define TEMP_T1_T1_Pos (0UL) /*!< Position of T1 field. */ -#define TEMP_T1_T1_Msk (0xFFUL << TEMP_T1_T1_Pos) /*!< Bit mask of T1 field. */ - -/* Register: TEMP_T2 */ -/* Description: End point of 3rd piece wise linear function */ - -/* Bits 7..0 : End point of 3rd piece wise linear function */ -#define TEMP_T2_T2_Pos (0UL) /*!< Position of T2 field. */ -#define TEMP_T2_T2_Msk (0xFFUL << TEMP_T2_T2_Pos) /*!< Bit mask of T2 field. */ - -/* Register: TEMP_T3 */ -/* Description: End point of 4th piece wise linear function */ - -/* Bits 7..0 : End point of 4th piece wise linear function */ -#define TEMP_T3_T3_Pos (0UL) /*!< Position of T3 field. */ -#define TEMP_T3_T3_Msk (0xFFUL << TEMP_T3_T3_Pos) /*!< Bit mask of T3 field. */ - -/* Register: TEMP_T4 */ -/* Description: End point of 5th piece wise linear function */ - -/* Bits 7..0 : End point of 5th piece wise linear function */ -#define TEMP_T4_T4_Pos (0UL) /*!< Position of T4 field. */ -#define TEMP_T4_T4_Msk (0xFFUL << TEMP_T4_T4_Pos) /*!< Bit mask of T4 field. */ - - -/* Peripheral: TIMER */ -/* Description: Timer/Counter 0 */ - -/* Register: TIMER_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 13 : Shortcut between COMPARE[5] event and STOP task */ -#define TIMER_SHORTS_COMPARE5_STOP_Pos (13UL) /*!< Position of COMPARE5_STOP field. */ -#define TIMER_SHORTS_COMPARE5_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE5_STOP_Pos) /*!< Bit mask of COMPARE5_STOP field. */ -#define TIMER_SHORTS_COMPARE5_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE5_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 12 : Shortcut between COMPARE[4] event and STOP task */ -#define TIMER_SHORTS_COMPARE4_STOP_Pos (12UL) /*!< Position of COMPARE4_STOP field. */ -#define TIMER_SHORTS_COMPARE4_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE4_STOP_Pos) /*!< Bit mask of COMPARE4_STOP field. */ -#define TIMER_SHORTS_COMPARE4_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE4_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 11 : Shortcut between COMPARE[3] event and STOP task */ -#define TIMER_SHORTS_COMPARE3_STOP_Pos (11UL) /*!< Position of COMPARE3_STOP field. */ -#define TIMER_SHORTS_COMPARE3_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE3_STOP_Pos) /*!< Bit mask of COMPARE3_STOP field. */ -#define TIMER_SHORTS_COMPARE3_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE3_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 10 : Shortcut between COMPARE[2] event and STOP task */ -#define TIMER_SHORTS_COMPARE2_STOP_Pos (10UL) /*!< Position of COMPARE2_STOP field. */ -#define TIMER_SHORTS_COMPARE2_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE2_STOP_Pos) /*!< Bit mask of COMPARE2_STOP field. */ -#define TIMER_SHORTS_COMPARE2_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE2_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 9 : Shortcut between COMPARE[1] event and STOP task */ -#define TIMER_SHORTS_COMPARE1_STOP_Pos (9UL) /*!< Position of COMPARE1_STOP field. */ -#define TIMER_SHORTS_COMPARE1_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE1_STOP_Pos) /*!< Bit mask of COMPARE1_STOP field. */ -#define TIMER_SHORTS_COMPARE1_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE1_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 8 : Shortcut between COMPARE[0] event and STOP task */ -#define TIMER_SHORTS_COMPARE0_STOP_Pos (8UL) /*!< Position of COMPARE0_STOP field. */ -#define TIMER_SHORTS_COMPARE0_STOP_Msk (0x1UL << TIMER_SHORTS_COMPARE0_STOP_Pos) /*!< Bit mask of COMPARE0_STOP field. */ -#define TIMER_SHORTS_COMPARE0_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE0_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between COMPARE[5] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Pos (5UL) /*!< Position of COMPARE5_CLEAR field. */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE5_CLEAR_Pos) /*!< Bit mask of COMPARE5_CLEAR field. */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE5_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 4 : Shortcut between COMPARE[4] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Pos (4UL) /*!< Position of COMPARE4_CLEAR field. */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE4_CLEAR_Pos) /*!< Bit mask of COMPARE4_CLEAR field. */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE4_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between COMPARE[3] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Pos (3UL) /*!< Position of COMPARE3_CLEAR field. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE3_CLEAR_Pos) /*!< Bit mask of COMPARE3_CLEAR field. */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE3_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between COMPARE[2] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Pos (2UL) /*!< Position of COMPARE2_CLEAR field. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE2_CLEAR_Pos) /*!< Bit mask of COMPARE2_CLEAR field. */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE2_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between COMPARE[1] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Pos (1UL) /*!< Position of COMPARE1_CLEAR field. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE1_CLEAR_Pos) /*!< Bit mask of COMPARE1_CLEAR field. */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE1_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between COMPARE[0] event and CLEAR task */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Pos (0UL) /*!< Position of COMPARE0_CLEAR field. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Msk (0x1UL << TIMER_SHORTS_COMPARE0_CLEAR_Pos) /*!< Bit mask of COMPARE0_CLEAR field. */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Disabled (0UL) /*!< Disable shortcut */ -#define TIMER_SHORTS_COMPARE0_CLEAR_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TIMER_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 21 : Write '1' to Enable interrupt for COMPARE[5] event */ -#define TIMER_INTENSET_COMPARE5_Pos (21UL) /*!< Position of COMPARE5 field. */ -#define TIMER_INTENSET_COMPARE5_Msk (0x1UL << TIMER_INTENSET_COMPARE5_Pos) /*!< Bit mask of COMPARE5 field. */ -#define TIMER_INTENSET_COMPARE5_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE5_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE5_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for COMPARE[4] event */ -#define TIMER_INTENSET_COMPARE4_Pos (20UL) /*!< Position of COMPARE4 field. */ -#define TIMER_INTENSET_COMPARE4_Msk (0x1UL << TIMER_INTENSET_COMPARE4_Pos) /*!< Bit mask of COMPARE4 field. */ -#define TIMER_INTENSET_COMPARE4_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE4_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE4_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for COMPARE[3] event */ -#define TIMER_INTENSET_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define TIMER_INTENSET_COMPARE3_Msk (0x1UL << TIMER_INTENSET_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define TIMER_INTENSET_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE3_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for COMPARE[2] event */ -#define TIMER_INTENSET_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define TIMER_INTENSET_COMPARE2_Msk (0x1UL << TIMER_INTENSET_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define TIMER_INTENSET_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE2_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for COMPARE[1] event */ -#define TIMER_INTENSET_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define TIMER_INTENSET_COMPARE1_Msk (0x1UL << TIMER_INTENSET_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define TIMER_INTENSET_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE1_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for COMPARE[0] event */ -#define TIMER_INTENSET_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define TIMER_INTENSET_COMPARE0_Msk (0x1UL << TIMER_INTENSET_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define TIMER_INTENSET_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENSET_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENSET_COMPARE0_Set (1UL) /*!< Enable */ - -/* Register: TIMER_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 21 : Write '1' to Disable interrupt for COMPARE[5] event */ -#define TIMER_INTENCLR_COMPARE5_Pos (21UL) /*!< Position of COMPARE5 field. */ -#define TIMER_INTENCLR_COMPARE5_Msk (0x1UL << TIMER_INTENCLR_COMPARE5_Pos) /*!< Bit mask of COMPARE5 field. */ -#define TIMER_INTENCLR_COMPARE5_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE5_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE5_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for COMPARE[4] event */ -#define TIMER_INTENCLR_COMPARE4_Pos (20UL) /*!< Position of COMPARE4 field. */ -#define TIMER_INTENCLR_COMPARE4_Msk (0x1UL << TIMER_INTENCLR_COMPARE4_Pos) /*!< Bit mask of COMPARE4 field. */ -#define TIMER_INTENCLR_COMPARE4_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE4_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE4_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for COMPARE[3] event */ -#define TIMER_INTENCLR_COMPARE3_Pos (19UL) /*!< Position of COMPARE3 field. */ -#define TIMER_INTENCLR_COMPARE3_Msk (0x1UL << TIMER_INTENCLR_COMPARE3_Pos) /*!< Bit mask of COMPARE3 field. */ -#define TIMER_INTENCLR_COMPARE3_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE3_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE3_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for COMPARE[2] event */ -#define TIMER_INTENCLR_COMPARE2_Pos (18UL) /*!< Position of COMPARE2 field. */ -#define TIMER_INTENCLR_COMPARE2_Msk (0x1UL << TIMER_INTENCLR_COMPARE2_Pos) /*!< Bit mask of COMPARE2 field. */ -#define TIMER_INTENCLR_COMPARE2_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE2_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE2_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for COMPARE[1] event */ -#define TIMER_INTENCLR_COMPARE1_Pos (17UL) /*!< Position of COMPARE1 field. */ -#define TIMER_INTENCLR_COMPARE1_Msk (0x1UL << TIMER_INTENCLR_COMPARE1_Pos) /*!< Bit mask of COMPARE1 field. */ -#define TIMER_INTENCLR_COMPARE1_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE1_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE1_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for COMPARE[0] event */ -#define TIMER_INTENCLR_COMPARE0_Pos (16UL) /*!< Position of COMPARE0 field. */ -#define TIMER_INTENCLR_COMPARE0_Msk (0x1UL << TIMER_INTENCLR_COMPARE0_Pos) /*!< Bit mask of COMPARE0 field. */ -#define TIMER_INTENCLR_COMPARE0_Disabled (0UL) /*!< Read: Disabled */ -#define TIMER_INTENCLR_COMPARE0_Enabled (1UL) /*!< Read: Enabled */ -#define TIMER_INTENCLR_COMPARE0_Clear (1UL) /*!< Disable */ - -/* Register: TIMER_MODE */ -/* Description: Timer mode selection */ - -/* Bits 1..0 : Timer mode */ -#define TIMER_MODE_MODE_Pos (0UL) /*!< Position of MODE field. */ -#define TIMER_MODE_MODE_Msk (0x3UL << TIMER_MODE_MODE_Pos) /*!< Bit mask of MODE field. */ -#define TIMER_MODE_MODE_Timer (0UL) /*!< Select Timer mode */ -#define TIMER_MODE_MODE_Counter (1UL) /*!< Deprecated enumerator - Select Counter mode */ -#define TIMER_MODE_MODE_LowPowerCounter (2UL) /*!< Select Low Power Counter mode */ - -/* Register: TIMER_BITMODE */ -/* Description: Configure the number of bits used by the TIMER */ - -/* Bits 1..0 : Timer bit width */ -#define TIMER_BITMODE_BITMODE_Pos (0UL) /*!< Position of BITMODE field. */ -#define TIMER_BITMODE_BITMODE_Msk (0x3UL << TIMER_BITMODE_BITMODE_Pos) /*!< Bit mask of BITMODE field. */ -#define TIMER_BITMODE_BITMODE_16Bit (0UL) /*!< 16 bit timer bit width */ -#define TIMER_BITMODE_BITMODE_08Bit (1UL) /*!< 8 bit timer bit width */ -#define TIMER_BITMODE_BITMODE_24Bit (2UL) /*!< 24 bit timer bit width */ -#define TIMER_BITMODE_BITMODE_32Bit (3UL) /*!< 32 bit timer bit width */ - -/* Register: TIMER_PRESCALER */ -/* Description: Timer prescaler register */ - -/* Bits 3..0 : Prescaler value */ -#define TIMER_PRESCALER_PRESCALER_Pos (0UL) /*!< Position of PRESCALER field. */ -#define TIMER_PRESCALER_PRESCALER_Msk (0xFUL << TIMER_PRESCALER_PRESCALER_Pos) /*!< Bit mask of PRESCALER field. */ - -/* Register: TIMER_CC */ -/* Description: Description collection[0]: Capture/Compare register 0 */ - -/* Bits 31..0 : Capture/Compare value */ -#define TIMER_CC_CC_Pos (0UL) /*!< Position of CC field. */ -#define TIMER_CC_CC_Msk (0xFFFFFFFFUL << TIMER_CC_CC_Pos) /*!< Bit mask of CC field. */ - - -/* Peripheral: TWI */ -/* Description: I2C compatible Two-Wire Interface 0 */ - -/* Register: TWI_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 1 : Shortcut between BB event and STOP task */ -#define TWI_SHORTS_BB_STOP_Pos (1UL) /*!< Position of BB_STOP field. */ -#define TWI_SHORTS_BB_STOP_Msk (0x1UL << TWI_SHORTS_BB_STOP_Pos) /*!< Bit mask of BB_STOP field. */ -#define TWI_SHORTS_BB_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TWI_SHORTS_BB_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between BB event and SUSPEND task */ -#define TWI_SHORTS_BB_SUSPEND_Pos (0UL) /*!< Position of BB_SUSPEND field. */ -#define TWI_SHORTS_BB_SUSPEND_Msk (0x1UL << TWI_SHORTS_BB_SUSPEND_Pos) /*!< Bit mask of BB_SUSPEND field. */ -#define TWI_SHORTS_BB_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWI_SHORTS_BB_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TWI_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 18 : Write '1' to Enable interrupt for SUSPENDED event */ -#define TWI_INTENSET_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWI_INTENSET_SUSPENDED_Msk (0x1UL << TWI_INTENSET_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWI_INTENSET_SUSPENDED_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENSET_SUSPENDED_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENSET_SUSPENDED_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for BB event */ -#define TWI_INTENSET_BB_Pos (14UL) /*!< Position of BB field. */ -#define TWI_INTENSET_BB_Msk (0x1UL << TWI_INTENSET_BB_Pos) /*!< Bit mask of BB field. */ -#define TWI_INTENSET_BB_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENSET_BB_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENSET_BB_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define TWI_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWI_INTENSET_ERROR_Msk (0x1UL << TWI_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWI_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for TXDSENT event */ -#define TWI_INTENSET_TXDSENT_Pos (7UL) /*!< Position of TXDSENT field. */ -#define TWI_INTENSET_TXDSENT_Msk (0x1UL << TWI_INTENSET_TXDSENT_Pos) /*!< Bit mask of TXDSENT field. */ -#define TWI_INTENSET_TXDSENT_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENSET_TXDSENT_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENSET_TXDSENT_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for RXDREADY event */ -#define TWI_INTENSET_RXDREADY_Pos (2UL) /*!< Position of RXDREADY field. */ -#define TWI_INTENSET_RXDREADY_Msk (0x1UL << TWI_INTENSET_RXDREADY_Pos) /*!< Bit mask of RXDREADY field. */ -#define TWI_INTENSET_RXDREADY_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENSET_RXDREADY_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENSET_RXDREADY_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define TWI_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWI_INTENSET_STOPPED_Msk (0x1UL << TWI_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWI_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: TWI_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 18 : Write '1' to Disable interrupt for SUSPENDED event */ -#define TWI_INTENCLR_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWI_INTENCLR_SUSPENDED_Msk (0x1UL << TWI_INTENCLR_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWI_INTENCLR_SUSPENDED_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENCLR_SUSPENDED_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENCLR_SUSPENDED_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for BB event */ -#define TWI_INTENCLR_BB_Pos (14UL) /*!< Position of BB field. */ -#define TWI_INTENCLR_BB_Msk (0x1UL << TWI_INTENCLR_BB_Pos) /*!< Bit mask of BB field. */ -#define TWI_INTENCLR_BB_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENCLR_BB_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENCLR_BB_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define TWI_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWI_INTENCLR_ERROR_Msk (0x1UL << TWI_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWI_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for TXDSENT event */ -#define TWI_INTENCLR_TXDSENT_Pos (7UL) /*!< Position of TXDSENT field. */ -#define TWI_INTENCLR_TXDSENT_Msk (0x1UL << TWI_INTENCLR_TXDSENT_Pos) /*!< Bit mask of TXDSENT field. */ -#define TWI_INTENCLR_TXDSENT_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENCLR_TXDSENT_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENCLR_TXDSENT_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for RXDREADY event */ -#define TWI_INTENCLR_RXDREADY_Pos (2UL) /*!< Position of RXDREADY field. */ -#define TWI_INTENCLR_RXDREADY_Msk (0x1UL << TWI_INTENCLR_RXDREADY_Pos) /*!< Bit mask of RXDREADY field. */ -#define TWI_INTENCLR_RXDREADY_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENCLR_RXDREADY_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENCLR_RXDREADY_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define TWI_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWI_INTENCLR_STOPPED_Msk (0x1UL << TWI_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWI_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWI_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWI_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: TWI_ERRORSRC */ -/* Description: Error source */ - -/* Bit 2 : NACK received after sending a data byte (write '1' to clear) */ -#define TWI_ERRORSRC_DNACK_Pos (2UL) /*!< Position of DNACK field. */ -#define TWI_ERRORSRC_DNACK_Msk (0x1UL << TWI_ERRORSRC_DNACK_Pos) /*!< Bit mask of DNACK field. */ -#define TWI_ERRORSRC_DNACK_NotPresent (0UL) /*!< Read: error not present */ -#define TWI_ERRORSRC_DNACK_Present (1UL) /*!< Read: error present */ - -/* Bit 1 : NACK received after sending the address (write '1' to clear) */ -#define TWI_ERRORSRC_ANACK_Pos (1UL) /*!< Position of ANACK field. */ -#define TWI_ERRORSRC_ANACK_Msk (0x1UL << TWI_ERRORSRC_ANACK_Pos) /*!< Bit mask of ANACK field. */ -#define TWI_ERRORSRC_ANACK_NotPresent (0UL) /*!< Read: error not present */ -#define TWI_ERRORSRC_ANACK_Present (1UL) /*!< Read: error present */ - -/* Bit 0 : Overrun error */ -#define TWI_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define TWI_ERRORSRC_OVERRUN_Msk (0x1UL << TWI_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define TWI_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Read: no overrun occured */ -#define TWI_ERRORSRC_OVERRUN_Present (1UL) /*!< Read: overrun occured */ - -/* Register: TWI_ENABLE */ -/* Description: Enable TWI */ - -/* Bits 3..0 : Enable or disable TWI */ -#define TWI_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define TWI_ENABLE_ENABLE_Msk (0xFUL << TWI_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define TWI_ENABLE_ENABLE_Disabled (0UL) /*!< Disable TWI */ -#define TWI_ENABLE_ENABLE_Enabled (5UL) /*!< Enable TWI */ - -/* Register: TWI_PSEL_SCL */ -/* Description: Pin select for SCL */ - -/* Bit 31 : Connection */ -#define TWI_PSEL_SCL_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWI_PSEL_SCL_CONNECT_Msk (0x1UL << TWI_PSEL_SCL_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWI_PSEL_SCL_CONNECT_Connected (0UL) /*!< Connect */ -#define TWI_PSEL_SCL_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define TWI_PSEL_SCL_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define TWI_PSEL_SCL_PORT_Msk (0x1UL << TWI_PSEL_SCL_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define TWI_PSEL_SCL_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWI_PSEL_SCL_PIN_Msk (0x1FUL << TWI_PSEL_SCL_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWI_PSEL_SDA */ -/* Description: Pin select for SDA */ - -/* Bit 31 : Connection */ -#define TWI_PSEL_SDA_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWI_PSEL_SDA_CONNECT_Msk (0x1UL << TWI_PSEL_SDA_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWI_PSEL_SDA_CONNECT_Connected (0UL) /*!< Connect */ -#define TWI_PSEL_SDA_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define TWI_PSEL_SDA_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define TWI_PSEL_SDA_PORT_Msk (0x1UL << TWI_PSEL_SDA_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define TWI_PSEL_SDA_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWI_PSEL_SDA_PIN_Msk (0x1FUL << TWI_PSEL_SDA_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWI_RXD */ -/* Description: RXD register */ - -/* Bits 7..0 : RXD register */ -#define TWI_RXD_RXD_Pos (0UL) /*!< Position of RXD field. */ -#define TWI_RXD_RXD_Msk (0xFFUL << TWI_RXD_RXD_Pos) /*!< Bit mask of RXD field. */ - -/* Register: TWI_TXD */ -/* Description: TXD register */ - -/* Bits 7..0 : TXD register */ -#define TWI_TXD_TXD_Pos (0UL) /*!< Position of TXD field. */ -#define TWI_TXD_TXD_Msk (0xFFUL << TWI_TXD_TXD_Pos) /*!< Bit mask of TXD field. */ - -/* Register: TWI_FREQUENCY */ -/* Description: TWI frequency. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : TWI master clock frequency */ -#define TWI_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define TWI_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << TWI_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define TWI_FREQUENCY_FREQUENCY_K100 (0x01980000UL) /*!< 100 kbps */ -#define TWI_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */ -#define TWI_FREQUENCY_FREQUENCY_K400 (0x06680000UL) /*!< 400 kbps (actual rate 410.256 kbps) */ - -/* Register: TWI_ADDRESS */ -/* Description: Address used in the TWI transfer */ - -/* Bits 6..0 : Address used in the TWI transfer */ -#define TWI_ADDRESS_ADDRESS_Pos (0UL) /*!< Position of ADDRESS field. */ -#define TWI_ADDRESS_ADDRESS_Msk (0x7FUL << TWI_ADDRESS_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ - - -/* Peripheral: TWIM */ -/* Description: I2C compatible Two-Wire Master Interface with EasyDMA 0 */ - -/* Register: TWIM_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 12 : Shortcut between LASTRX event and STOP task */ -#define TWIM_SHORTS_LASTRX_STOP_Pos (12UL) /*!< Position of LASTRX_STOP field. */ -#define TWIM_SHORTS_LASTRX_STOP_Msk (0x1UL << TWIM_SHORTS_LASTRX_STOP_Pos) /*!< Bit mask of LASTRX_STOP field. */ -#define TWIM_SHORTS_LASTRX_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTRX_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 10 : Shortcut between LASTRX event and STARTTX task */ -#define TWIM_SHORTS_LASTRX_STARTTX_Pos (10UL) /*!< Position of LASTRX_STARTTX field. */ -#define TWIM_SHORTS_LASTRX_STARTTX_Msk (0x1UL << TWIM_SHORTS_LASTRX_STARTTX_Pos) /*!< Bit mask of LASTRX_STARTTX field. */ -#define TWIM_SHORTS_LASTRX_STARTTX_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTRX_STARTTX_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 9 : Shortcut between LASTTX event and STOP task */ -#define TWIM_SHORTS_LASTTX_STOP_Pos (9UL) /*!< Position of LASTTX_STOP field. */ -#define TWIM_SHORTS_LASTTX_STOP_Msk (0x1UL << TWIM_SHORTS_LASTTX_STOP_Pos) /*!< Bit mask of LASTTX_STOP field. */ -#define TWIM_SHORTS_LASTTX_STOP_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTTX_STOP_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 8 : Shortcut between LASTTX event and SUSPEND task */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Pos (8UL) /*!< Position of LASTTX_SUSPEND field. */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Msk (0x1UL << TWIM_SHORTS_LASTTX_SUSPEND_Pos) /*!< Bit mask of LASTTX_SUSPEND field. */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTTX_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 7 : Shortcut between LASTTX event and STARTRX task */ -#define TWIM_SHORTS_LASTTX_STARTRX_Pos (7UL) /*!< Position of LASTTX_STARTRX field. */ -#define TWIM_SHORTS_LASTTX_STARTRX_Msk (0x1UL << TWIM_SHORTS_LASTTX_STARTRX_Pos) /*!< Bit mask of LASTTX_STARTRX field. */ -#define TWIM_SHORTS_LASTTX_STARTRX_Disabled (0UL) /*!< Disable shortcut */ -#define TWIM_SHORTS_LASTTX_STARTRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TWIM_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 24 : Enable or disable interrupt for LASTTX event */ -#define TWIM_INTEN_LASTTX_Pos (24UL) /*!< Position of LASTTX field. */ -#define TWIM_INTEN_LASTTX_Msk (0x1UL << TWIM_INTEN_LASTTX_Pos) /*!< Bit mask of LASTTX field. */ -#define TWIM_INTEN_LASTTX_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_LASTTX_Enabled (1UL) /*!< Enable */ - -/* Bit 23 : Enable or disable interrupt for LASTRX event */ -#define TWIM_INTEN_LASTRX_Pos (23UL) /*!< Position of LASTRX field. */ -#define TWIM_INTEN_LASTRX_Msk (0x1UL << TWIM_INTEN_LASTRX_Pos) /*!< Bit mask of LASTRX field. */ -#define TWIM_INTEN_LASTRX_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_LASTRX_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for TXSTARTED event */ -#define TWIM_INTEN_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIM_INTEN_TXSTARTED_Msk (0x1UL << TWIM_INTEN_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIM_INTEN_TXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_TXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for RXSTARTED event */ -#define TWIM_INTEN_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIM_INTEN_RXSTARTED_Msk (0x1UL << TWIM_INTEN_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIM_INTEN_RXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_RXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable interrupt for SUSPENDED event */ -#define TWIM_INTEN_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWIM_INTEN_SUSPENDED_Msk (0x1UL << TWIM_INTEN_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWIM_INTEN_SUSPENDED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_SUSPENDED_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ERROR event */ -#define TWIM_INTEN_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIM_INTEN_ERROR_Msk (0x1UL << TWIM_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIM_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define TWIM_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIM_INTEN_STOPPED_Msk (0x1UL << TWIM_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIM_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define TWIM_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Register: TWIM_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 24 : Write '1' to Enable interrupt for LASTTX event */ -#define TWIM_INTENSET_LASTTX_Pos (24UL) /*!< Position of LASTTX field. */ -#define TWIM_INTENSET_LASTTX_Msk (0x1UL << TWIM_INTENSET_LASTTX_Pos) /*!< Bit mask of LASTTX field. */ -#define TWIM_INTENSET_LASTTX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_LASTTX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_LASTTX_Set (1UL) /*!< Enable */ - -/* Bit 23 : Write '1' to Enable interrupt for LASTRX event */ -#define TWIM_INTENSET_LASTRX_Pos (23UL) /*!< Position of LASTRX field. */ -#define TWIM_INTENSET_LASTRX_Msk (0x1UL << TWIM_INTENSET_LASTRX_Pos) /*!< Bit mask of LASTRX field. */ -#define TWIM_INTENSET_LASTRX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_LASTRX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_LASTRX_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for TXSTARTED event */ -#define TWIM_INTENSET_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIM_INTENSET_TXSTARTED_Msk (0x1UL << TWIM_INTENSET_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIM_INTENSET_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_TXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for RXSTARTED event */ -#define TWIM_INTENSET_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIM_INTENSET_RXSTARTED_Msk (0x1UL << TWIM_INTENSET_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIM_INTENSET_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_RXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for SUSPENDED event */ -#define TWIM_INTENSET_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWIM_INTENSET_SUSPENDED_Msk (0x1UL << TWIM_INTENSET_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWIM_INTENSET_SUSPENDED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_SUSPENDED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_SUSPENDED_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define TWIM_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIM_INTENSET_ERROR_Msk (0x1UL << TWIM_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIM_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define TWIM_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIM_INTENSET_STOPPED_Msk (0x1UL << TWIM_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIM_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: TWIM_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 24 : Write '1' to Disable interrupt for LASTTX event */ -#define TWIM_INTENCLR_LASTTX_Pos (24UL) /*!< Position of LASTTX field. */ -#define TWIM_INTENCLR_LASTTX_Msk (0x1UL << TWIM_INTENCLR_LASTTX_Pos) /*!< Bit mask of LASTTX field. */ -#define TWIM_INTENCLR_LASTTX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_LASTTX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_LASTTX_Clear (1UL) /*!< Disable */ - -/* Bit 23 : Write '1' to Disable interrupt for LASTRX event */ -#define TWIM_INTENCLR_LASTRX_Pos (23UL) /*!< Position of LASTRX field. */ -#define TWIM_INTENCLR_LASTRX_Msk (0x1UL << TWIM_INTENCLR_LASTRX_Pos) /*!< Bit mask of LASTRX field. */ -#define TWIM_INTENCLR_LASTRX_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_LASTRX_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_LASTRX_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for TXSTARTED event */ -#define TWIM_INTENCLR_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIM_INTENCLR_TXSTARTED_Msk (0x1UL << TWIM_INTENCLR_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIM_INTENCLR_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_TXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for RXSTARTED event */ -#define TWIM_INTENCLR_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIM_INTENCLR_RXSTARTED_Msk (0x1UL << TWIM_INTENCLR_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIM_INTENCLR_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_RXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for SUSPENDED event */ -#define TWIM_INTENCLR_SUSPENDED_Pos (18UL) /*!< Position of SUSPENDED field. */ -#define TWIM_INTENCLR_SUSPENDED_Msk (0x1UL << TWIM_INTENCLR_SUSPENDED_Pos) /*!< Bit mask of SUSPENDED field. */ -#define TWIM_INTENCLR_SUSPENDED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_SUSPENDED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_SUSPENDED_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define TWIM_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIM_INTENCLR_ERROR_Msk (0x1UL << TWIM_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIM_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define TWIM_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIM_INTENCLR_STOPPED_Msk (0x1UL << TWIM_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIM_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIM_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIM_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: TWIM_ERRORSRC */ -/* Description: Error source */ - -/* Bit 2 : NACK received after sending a data byte (write '1' to clear) */ -#define TWIM_ERRORSRC_DNACK_Pos (2UL) /*!< Position of DNACK field. */ -#define TWIM_ERRORSRC_DNACK_Msk (0x1UL << TWIM_ERRORSRC_DNACK_Pos) /*!< Bit mask of DNACK field. */ -#define TWIM_ERRORSRC_DNACK_NotReceived (0UL) /*!< Error did not occur */ -#define TWIM_ERRORSRC_DNACK_Received (1UL) /*!< Error occurred */ - -/* Bit 1 : NACK received after sending the address (write '1' to clear) */ -#define TWIM_ERRORSRC_ANACK_Pos (1UL) /*!< Position of ANACK field. */ -#define TWIM_ERRORSRC_ANACK_Msk (0x1UL << TWIM_ERRORSRC_ANACK_Pos) /*!< Bit mask of ANACK field. */ -#define TWIM_ERRORSRC_ANACK_NotReceived (0UL) /*!< Error did not occur */ -#define TWIM_ERRORSRC_ANACK_Received (1UL) /*!< Error occurred */ - -/* Bit 0 : Overrun error */ -#define TWIM_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define TWIM_ERRORSRC_OVERRUN_Msk (0x1UL << TWIM_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define TWIM_ERRORSRC_OVERRUN_NotReceived (0UL) /*!< Error did not occur */ -#define TWIM_ERRORSRC_OVERRUN_Received (1UL) /*!< Error occurred */ - -/* Register: TWIM_ENABLE */ -/* Description: Enable TWIM */ - -/* Bits 3..0 : Enable or disable TWIM */ -#define TWIM_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define TWIM_ENABLE_ENABLE_Msk (0xFUL << TWIM_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define TWIM_ENABLE_ENABLE_Disabled (0UL) /*!< Disable TWIM */ -#define TWIM_ENABLE_ENABLE_Enabled (6UL) /*!< Enable TWIM */ - -/* Register: TWIM_PSEL_SCL */ -/* Description: Pin select for SCL signal */ - -/* Bit 31 : Connection */ -#define TWIM_PSEL_SCL_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIM_PSEL_SCL_CONNECT_Msk (0x1UL << TWIM_PSEL_SCL_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIM_PSEL_SCL_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIM_PSEL_SCL_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define TWIM_PSEL_SCL_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define TWIM_PSEL_SCL_PORT_Msk (0x1UL << TWIM_PSEL_SCL_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define TWIM_PSEL_SCL_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIM_PSEL_SCL_PIN_Msk (0x1FUL << TWIM_PSEL_SCL_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIM_PSEL_SDA */ -/* Description: Pin select for SDA signal */ - -/* Bit 31 : Connection */ -#define TWIM_PSEL_SDA_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIM_PSEL_SDA_CONNECT_Msk (0x1UL << TWIM_PSEL_SDA_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIM_PSEL_SDA_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIM_PSEL_SDA_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define TWIM_PSEL_SDA_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define TWIM_PSEL_SDA_PORT_Msk (0x1UL << TWIM_PSEL_SDA_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define TWIM_PSEL_SDA_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIM_PSEL_SDA_PIN_Msk (0x1FUL << TWIM_PSEL_SDA_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIM_FREQUENCY */ -/* Description: TWI frequency. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : TWI master clock frequency */ -#define TWIM_FREQUENCY_FREQUENCY_Pos (0UL) /*!< Position of FREQUENCY field. */ -#define TWIM_FREQUENCY_FREQUENCY_Msk (0xFFFFFFFFUL << TWIM_FREQUENCY_FREQUENCY_Pos) /*!< Bit mask of FREQUENCY field. */ -#define TWIM_FREQUENCY_FREQUENCY_K100 (0x01980000UL) /*!< 100 kbps */ -#define TWIM_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */ -#define TWIM_FREQUENCY_FREQUENCY_K400 (0x06400000UL) /*!< 400 kbps */ - -/* Register: TWIM_RXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define TWIM_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIM_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIM_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIM_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 15..0 : Maximum number of bytes in receive buffer */ -#define TWIM_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIM_RXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << TWIM_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIM_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte. */ -#define TWIM_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIM_RXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << TWIM_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIM_RXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 2..0 : List type */ -#define TWIM_RXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define TWIM_RXD_LIST_LIST_Msk (0x7UL << TWIM_RXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define TWIM_RXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define TWIM_RXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: TWIM_TXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define TWIM_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIM_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIM_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIM_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 15..0 : Maximum number of bytes in transmit buffer */ -#define TWIM_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIM_TXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << TWIM_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIM_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte. */ -#define TWIM_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIM_TXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << TWIM_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIM_TXD_LIST */ -/* Description: EasyDMA list type */ - -/* Bits 2..0 : List type */ -#define TWIM_TXD_LIST_LIST_Pos (0UL) /*!< Position of LIST field. */ -#define TWIM_TXD_LIST_LIST_Msk (0x7UL << TWIM_TXD_LIST_LIST_Pos) /*!< Bit mask of LIST field. */ -#define TWIM_TXD_LIST_LIST_Disabled (0UL) /*!< Disable EasyDMA list */ -#define TWIM_TXD_LIST_LIST_ArrayList (1UL) /*!< Use array list */ - -/* Register: TWIM_ADDRESS */ -/* Description: Address used in the TWI transfer */ - -/* Bits 6..0 : Address used in the TWI transfer */ -#define TWIM_ADDRESS_ADDRESS_Pos (0UL) /*!< Position of ADDRESS field. */ -#define TWIM_ADDRESS_ADDRESS_Msk (0x7FUL << TWIM_ADDRESS_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ - - -/* Peripheral: TWIS */ -/* Description: I2C compatible Two-Wire Slave Interface with EasyDMA 0 */ - -/* Register: TWIS_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 14 : Shortcut between READ event and SUSPEND task */ -#define TWIS_SHORTS_READ_SUSPEND_Pos (14UL) /*!< Position of READ_SUSPEND field. */ -#define TWIS_SHORTS_READ_SUSPEND_Msk (0x1UL << TWIS_SHORTS_READ_SUSPEND_Pos) /*!< Bit mask of READ_SUSPEND field. */ -#define TWIS_SHORTS_READ_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWIS_SHORTS_READ_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 13 : Shortcut between WRITE event and SUSPEND task */ -#define TWIS_SHORTS_WRITE_SUSPEND_Pos (13UL) /*!< Position of WRITE_SUSPEND field. */ -#define TWIS_SHORTS_WRITE_SUSPEND_Msk (0x1UL << TWIS_SHORTS_WRITE_SUSPEND_Pos) /*!< Bit mask of WRITE_SUSPEND field. */ -#define TWIS_SHORTS_WRITE_SUSPEND_Disabled (0UL) /*!< Disable shortcut */ -#define TWIS_SHORTS_WRITE_SUSPEND_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: TWIS_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 26 : Enable or disable interrupt for READ event */ -#define TWIS_INTEN_READ_Pos (26UL) /*!< Position of READ field. */ -#define TWIS_INTEN_READ_Msk (0x1UL << TWIS_INTEN_READ_Pos) /*!< Bit mask of READ field. */ -#define TWIS_INTEN_READ_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_READ_Enabled (1UL) /*!< Enable */ - -/* Bit 25 : Enable or disable interrupt for WRITE event */ -#define TWIS_INTEN_WRITE_Pos (25UL) /*!< Position of WRITE field. */ -#define TWIS_INTEN_WRITE_Msk (0x1UL << TWIS_INTEN_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define TWIS_INTEN_WRITE_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_WRITE_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for TXSTARTED event */ -#define TWIS_INTEN_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIS_INTEN_TXSTARTED_Msk (0x1UL << TWIS_INTEN_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIS_INTEN_TXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_TXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for RXSTARTED event */ -#define TWIS_INTEN_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIS_INTEN_RXSTARTED_Msk (0x1UL << TWIS_INTEN_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIS_INTEN_RXSTARTED_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_RXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ERROR event */ -#define TWIS_INTEN_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIS_INTEN_ERROR_Msk (0x1UL << TWIS_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIS_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STOPPED event */ -#define TWIS_INTEN_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIS_INTEN_STOPPED_Msk (0x1UL << TWIS_INTEN_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIS_INTEN_STOPPED_Disabled (0UL) /*!< Disable */ -#define TWIS_INTEN_STOPPED_Enabled (1UL) /*!< Enable */ - -/* Register: TWIS_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 26 : Write '1' to Enable interrupt for READ event */ -#define TWIS_INTENSET_READ_Pos (26UL) /*!< Position of READ field. */ -#define TWIS_INTENSET_READ_Msk (0x1UL << TWIS_INTENSET_READ_Pos) /*!< Bit mask of READ field. */ -#define TWIS_INTENSET_READ_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_READ_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_READ_Set (1UL) /*!< Enable */ - -/* Bit 25 : Write '1' to Enable interrupt for WRITE event */ -#define TWIS_INTENSET_WRITE_Pos (25UL) /*!< Position of WRITE field. */ -#define TWIS_INTENSET_WRITE_Msk (0x1UL << TWIS_INTENSET_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define TWIS_INTENSET_WRITE_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_WRITE_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_WRITE_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for TXSTARTED event */ -#define TWIS_INTENSET_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIS_INTENSET_TXSTARTED_Msk (0x1UL << TWIS_INTENSET_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIS_INTENSET_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_TXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for RXSTARTED event */ -#define TWIS_INTENSET_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIS_INTENSET_RXSTARTED_Msk (0x1UL << TWIS_INTENSET_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIS_INTENSET_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_RXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define TWIS_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIS_INTENSET_ERROR_Msk (0x1UL << TWIS_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIS_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STOPPED event */ -#define TWIS_INTENSET_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIS_INTENSET_STOPPED_Msk (0x1UL << TWIS_INTENSET_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIS_INTENSET_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENSET_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENSET_STOPPED_Set (1UL) /*!< Enable */ - -/* Register: TWIS_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 26 : Write '1' to Disable interrupt for READ event */ -#define TWIS_INTENCLR_READ_Pos (26UL) /*!< Position of READ field. */ -#define TWIS_INTENCLR_READ_Msk (0x1UL << TWIS_INTENCLR_READ_Pos) /*!< Bit mask of READ field. */ -#define TWIS_INTENCLR_READ_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_READ_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_READ_Clear (1UL) /*!< Disable */ - -/* Bit 25 : Write '1' to Disable interrupt for WRITE event */ -#define TWIS_INTENCLR_WRITE_Pos (25UL) /*!< Position of WRITE field. */ -#define TWIS_INTENCLR_WRITE_Msk (0x1UL << TWIS_INTENCLR_WRITE_Pos) /*!< Bit mask of WRITE field. */ -#define TWIS_INTENCLR_WRITE_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_WRITE_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_WRITE_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for TXSTARTED event */ -#define TWIS_INTENCLR_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define TWIS_INTENCLR_TXSTARTED_Msk (0x1UL << TWIS_INTENCLR_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define TWIS_INTENCLR_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_TXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for RXSTARTED event */ -#define TWIS_INTENCLR_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define TWIS_INTENCLR_RXSTARTED_Msk (0x1UL << TWIS_INTENCLR_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define TWIS_INTENCLR_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_RXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define TWIS_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define TWIS_INTENCLR_ERROR_Msk (0x1UL << TWIS_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define TWIS_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STOPPED event */ -#define TWIS_INTENCLR_STOPPED_Pos (1UL) /*!< Position of STOPPED field. */ -#define TWIS_INTENCLR_STOPPED_Msk (0x1UL << TWIS_INTENCLR_STOPPED_Pos) /*!< Bit mask of STOPPED field. */ -#define TWIS_INTENCLR_STOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define TWIS_INTENCLR_STOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define TWIS_INTENCLR_STOPPED_Clear (1UL) /*!< Disable */ - -/* Register: TWIS_ERRORSRC */ -/* Description: Error source */ - -/* Bit 3 : TX buffer over-read detected, and prevented */ -#define TWIS_ERRORSRC_OVERREAD_Pos (3UL) /*!< Position of OVERREAD field. */ -#define TWIS_ERRORSRC_OVERREAD_Msk (0x1UL << TWIS_ERRORSRC_OVERREAD_Pos) /*!< Bit mask of OVERREAD field. */ -#define TWIS_ERRORSRC_OVERREAD_NotDetected (0UL) /*!< Error did not occur */ -#define TWIS_ERRORSRC_OVERREAD_Detected (1UL) /*!< Error occurred */ - -/* Bit 2 : NACK sent after receiving a data byte */ -#define TWIS_ERRORSRC_DNACK_Pos (2UL) /*!< Position of DNACK field. */ -#define TWIS_ERRORSRC_DNACK_Msk (0x1UL << TWIS_ERRORSRC_DNACK_Pos) /*!< Bit mask of DNACK field. */ -#define TWIS_ERRORSRC_DNACK_NotReceived (0UL) /*!< Error did not occur */ -#define TWIS_ERRORSRC_DNACK_Received (1UL) /*!< Error occurred */ - -/* Bit 0 : RX buffer overflow detected, and prevented */ -#define TWIS_ERRORSRC_OVERFLOW_Pos (0UL) /*!< Position of OVERFLOW field. */ -#define TWIS_ERRORSRC_OVERFLOW_Msk (0x1UL << TWIS_ERRORSRC_OVERFLOW_Pos) /*!< Bit mask of OVERFLOW field. */ -#define TWIS_ERRORSRC_OVERFLOW_NotDetected (0UL) /*!< Error did not occur */ -#define TWIS_ERRORSRC_OVERFLOW_Detected (1UL) /*!< Error occurred */ - -/* Register: TWIS_MATCH */ -/* Description: Status register indicating which address had a match */ - -/* Bit 0 : Which of the addresses in {ADDRESS} matched the incoming address */ -#define TWIS_MATCH_MATCH_Pos (0UL) /*!< Position of MATCH field. */ -#define TWIS_MATCH_MATCH_Msk (0x1UL << TWIS_MATCH_MATCH_Pos) /*!< Bit mask of MATCH field. */ - -/* Register: TWIS_ENABLE */ -/* Description: Enable TWIS */ - -/* Bits 3..0 : Enable or disable TWIS */ -#define TWIS_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define TWIS_ENABLE_ENABLE_Msk (0xFUL << TWIS_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define TWIS_ENABLE_ENABLE_Disabled (0UL) /*!< Disable TWIS */ -#define TWIS_ENABLE_ENABLE_Enabled (9UL) /*!< Enable TWIS */ - -/* Register: TWIS_PSEL_SCL */ -/* Description: Pin select for SCL signal */ - -/* Bit 31 : Connection */ -#define TWIS_PSEL_SCL_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIS_PSEL_SCL_CONNECT_Msk (0x1UL << TWIS_PSEL_SCL_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIS_PSEL_SCL_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIS_PSEL_SCL_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define TWIS_PSEL_SCL_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define TWIS_PSEL_SCL_PORT_Msk (0x1UL << TWIS_PSEL_SCL_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define TWIS_PSEL_SCL_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIS_PSEL_SCL_PIN_Msk (0x1FUL << TWIS_PSEL_SCL_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIS_PSEL_SDA */ -/* Description: Pin select for SDA signal */ - -/* Bit 31 : Connection */ -#define TWIS_PSEL_SDA_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define TWIS_PSEL_SDA_CONNECT_Msk (0x1UL << TWIS_PSEL_SDA_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define TWIS_PSEL_SDA_CONNECT_Connected (0UL) /*!< Connect */ -#define TWIS_PSEL_SDA_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define TWIS_PSEL_SDA_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define TWIS_PSEL_SDA_PORT_Msk (0x1UL << TWIS_PSEL_SDA_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define TWIS_PSEL_SDA_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define TWIS_PSEL_SDA_PIN_Msk (0x1FUL << TWIS_PSEL_SDA_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: TWIS_RXD_PTR */ -/* Description: RXD Data pointer */ - -/* Bits 31..0 : RXD Data pointer */ -#define TWIS_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIS_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIS_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIS_RXD_MAXCNT */ -/* Description: Maximum number of bytes in RXD buffer */ - -/* Bits 15..0 : Maximum number of bytes in RXD buffer */ -#define TWIS_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIS_RXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << TWIS_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIS_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last RXD transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last RXD transaction */ -#define TWIS_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIS_RXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << TWIS_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIS_TXD_PTR */ -/* Description: TXD Data pointer */ - -/* Bits 31..0 : TXD Data pointer */ -#define TWIS_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define TWIS_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << TWIS_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: TWIS_TXD_MAXCNT */ -/* Description: Maximum number of bytes in TXD buffer */ - -/* Bits 15..0 : Maximum number of bytes in TXD buffer */ -#define TWIS_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define TWIS_TXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << TWIS_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: TWIS_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last TXD transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last TXD transaction */ -#define TWIS_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define TWIS_TXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << TWIS_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: TWIS_ADDRESS */ -/* Description: Description collection[0]: TWI slave address 0 */ - -/* Bits 6..0 : TWI slave address */ -#define TWIS_ADDRESS_ADDRESS_Pos (0UL) /*!< Position of ADDRESS field. */ -#define TWIS_ADDRESS_ADDRESS_Msk (0x7FUL << TWIS_ADDRESS_ADDRESS_Pos) /*!< Bit mask of ADDRESS field. */ - -/* Register: TWIS_CONFIG */ -/* Description: Configuration register for the address match mechanism */ - -/* Bit 1 : Enable or disable address matching on ADDRESS[1] */ -#define TWIS_CONFIG_ADDRESS1_Pos (1UL) /*!< Position of ADDRESS1 field. */ -#define TWIS_CONFIG_ADDRESS1_Msk (0x1UL << TWIS_CONFIG_ADDRESS1_Pos) /*!< Bit mask of ADDRESS1 field. */ -#define TWIS_CONFIG_ADDRESS1_Disabled (0UL) /*!< Disabled */ -#define TWIS_CONFIG_ADDRESS1_Enabled (1UL) /*!< Enabled */ - -/* Bit 0 : Enable or disable address matching on ADDRESS[0] */ -#define TWIS_CONFIG_ADDRESS0_Pos (0UL) /*!< Position of ADDRESS0 field. */ -#define TWIS_CONFIG_ADDRESS0_Msk (0x1UL << TWIS_CONFIG_ADDRESS0_Pos) /*!< Bit mask of ADDRESS0 field. */ -#define TWIS_CONFIG_ADDRESS0_Disabled (0UL) /*!< Disabled */ -#define TWIS_CONFIG_ADDRESS0_Enabled (1UL) /*!< Enabled */ - -/* Register: TWIS_ORC */ -/* Description: Over-read character. Character sent out in case of an over-read of the transmit buffer. */ - -/* Bits 7..0 : Over-read character. Character sent out in case of an over-read of the transmit buffer. */ -#define TWIS_ORC_ORC_Pos (0UL) /*!< Position of ORC field. */ -#define TWIS_ORC_ORC_Msk (0xFFUL << TWIS_ORC_ORC_Pos) /*!< Bit mask of ORC field. */ - - -/* Peripheral: UART */ -/* Description: Universal Asynchronous Receiver/Transmitter */ - -/* Register: UART_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between NCTS event and STOPRX task */ -#define UART_SHORTS_NCTS_STOPRX_Pos (4UL) /*!< Position of NCTS_STOPRX field. */ -#define UART_SHORTS_NCTS_STOPRX_Msk (0x1UL << UART_SHORTS_NCTS_STOPRX_Pos) /*!< Bit mask of NCTS_STOPRX field. */ -#define UART_SHORTS_NCTS_STOPRX_Disabled (0UL) /*!< Disable shortcut */ -#define UART_SHORTS_NCTS_STOPRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between CTS event and STARTRX task */ -#define UART_SHORTS_CTS_STARTRX_Pos (3UL) /*!< Position of CTS_STARTRX field. */ -#define UART_SHORTS_CTS_STARTRX_Msk (0x1UL << UART_SHORTS_CTS_STARTRX_Pos) /*!< Bit mask of CTS_STARTRX field. */ -#define UART_SHORTS_CTS_STARTRX_Disabled (0UL) /*!< Disable shortcut */ -#define UART_SHORTS_CTS_STARTRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: UART_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 17 : Write '1' to Enable interrupt for RXTO event */ -#define UART_INTENSET_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UART_INTENSET_RXTO_Msk (0x1UL << UART_INTENSET_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UART_INTENSET_RXTO_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENSET_RXTO_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENSET_RXTO_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define UART_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UART_INTENSET_ERROR_Msk (0x1UL << UART_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UART_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for TXDRDY event */ -#define UART_INTENSET_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UART_INTENSET_TXDRDY_Msk (0x1UL << UART_INTENSET_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UART_INTENSET_TXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENSET_TXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENSET_TXDRDY_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for RXDRDY event */ -#define UART_INTENSET_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UART_INTENSET_RXDRDY_Msk (0x1UL << UART_INTENSET_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UART_INTENSET_RXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENSET_RXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENSET_RXDRDY_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for NCTS event */ -#define UART_INTENSET_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UART_INTENSET_NCTS_Msk (0x1UL << UART_INTENSET_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UART_INTENSET_NCTS_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENSET_NCTS_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENSET_NCTS_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for CTS event */ -#define UART_INTENSET_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UART_INTENSET_CTS_Msk (0x1UL << UART_INTENSET_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UART_INTENSET_CTS_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENSET_CTS_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENSET_CTS_Set (1UL) /*!< Enable */ - -/* Register: UART_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 17 : Write '1' to Disable interrupt for RXTO event */ -#define UART_INTENCLR_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UART_INTENCLR_RXTO_Msk (0x1UL << UART_INTENCLR_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UART_INTENCLR_RXTO_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENCLR_RXTO_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENCLR_RXTO_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define UART_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UART_INTENCLR_ERROR_Msk (0x1UL << UART_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UART_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for TXDRDY event */ -#define UART_INTENCLR_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UART_INTENCLR_TXDRDY_Msk (0x1UL << UART_INTENCLR_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UART_INTENCLR_TXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENCLR_TXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENCLR_TXDRDY_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for RXDRDY event */ -#define UART_INTENCLR_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UART_INTENCLR_RXDRDY_Msk (0x1UL << UART_INTENCLR_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UART_INTENCLR_RXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENCLR_RXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENCLR_RXDRDY_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for NCTS event */ -#define UART_INTENCLR_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UART_INTENCLR_NCTS_Msk (0x1UL << UART_INTENCLR_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UART_INTENCLR_NCTS_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENCLR_NCTS_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENCLR_NCTS_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for CTS event */ -#define UART_INTENCLR_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UART_INTENCLR_CTS_Msk (0x1UL << UART_INTENCLR_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UART_INTENCLR_CTS_Disabled (0UL) /*!< Read: Disabled */ -#define UART_INTENCLR_CTS_Enabled (1UL) /*!< Read: Enabled */ -#define UART_INTENCLR_CTS_Clear (1UL) /*!< Disable */ - -/* Register: UART_ERRORSRC */ -/* Description: Error source */ - -/* Bit 3 : Break condition */ -#define UART_ERRORSRC_BREAK_Pos (3UL) /*!< Position of BREAK field. */ -#define UART_ERRORSRC_BREAK_Msk (0x1UL << UART_ERRORSRC_BREAK_Pos) /*!< Bit mask of BREAK field. */ -#define UART_ERRORSRC_BREAK_NotPresent (0UL) /*!< Read: error not present */ -#define UART_ERRORSRC_BREAK_Present (1UL) /*!< Read: error present */ - -/* Bit 2 : Framing error occurred */ -#define UART_ERRORSRC_FRAMING_Pos (2UL) /*!< Position of FRAMING field. */ -#define UART_ERRORSRC_FRAMING_Msk (0x1UL << UART_ERRORSRC_FRAMING_Pos) /*!< Bit mask of FRAMING field. */ -#define UART_ERRORSRC_FRAMING_NotPresent (0UL) /*!< Read: error not present */ -#define UART_ERRORSRC_FRAMING_Present (1UL) /*!< Read: error present */ - -/* Bit 1 : Parity error */ -#define UART_ERRORSRC_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UART_ERRORSRC_PARITY_Msk (0x1UL << UART_ERRORSRC_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UART_ERRORSRC_PARITY_NotPresent (0UL) /*!< Read: error not present */ -#define UART_ERRORSRC_PARITY_Present (1UL) /*!< Read: error present */ - -/* Bit 0 : Overrun error */ -#define UART_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define UART_ERRORSRC_OVERRUN_Msk (0x1UL << UART_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define UART_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Read: error not present */ -#define UART_ERRORSRC_OVERRUN_Present (1UL) /*!< Read: error present */ - -/* Register: UART_ENABLE */ -/* Description: Enable UART */ - -/* Bits 3..0 : Enable or disable UART */ -#define UART_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define UART_ENABLE_ENABLE_Msk (0xFUL << UART_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define UART_ENABLE_ENABLE_Disabled (0UL) /*!< Disable UART */ -#define UART_ENABLE_ENABLE_Enabled (4UL) /*!< Enable UART */ - -/* Register: UART_PSEL_RTS */ -/* Description: Pin select for RTS */ - -/* Bit 31 : Connection */ -#define UART_PSEL_RTS_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UART_PSEL_RTS_CONNECT_Msk (0x1UL << UART_PSEL_RTS_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UART_PSEL_RTS_CONNECT_Connected (0UL) /*!< Connect */ -#define UART_PSEL_RTS_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UART_PSEL_RTS_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UART_PSEL_RTS_PORT_Msk (0x1UL << UART_PSEL_RTS_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UART_PSEL_RTS_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UART_PSEL_RTS_PIN_Msk (0x1FUL << UART_PSEL_RTS_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UART_PSEL_TXD */ -/* Description: Pin select for TXD */ - -/* Bit 31 : Connection */ -#define UART_PSEL_TXD_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UART_PSEL_TXD_CONNECT_Msk (0x1UL << UART_PSEL_TXD_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UART_PSEL_TXD_CONNECT_Connected (0UL) /*!< Connect */ -#define UART_PSEL_TXD_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UART_PSEL_TXD_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UART_PSEL_TXD_PORT_Msk (0x1UL << UART_PSEL_TXD_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UART_PSEL_TXD_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UART_PSEL_TXD_PIN_Msk (0x1FUL << UART_PSEL_TXD_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UART_PSEL_CTS */ -/* Description: Pin select for CTS */ - -/* Bit 31 : Connection */ -#define UART_PSEL_CTS_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UART_PSEL_CTS_CONNECT_Msk (0x1UL << UART_PSEL_CTS_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UART_PSEL_CTS_CONNECT_Connected (0UL) /*!< Connect */ -#define UART_PSEL_CTS_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UART_PSEL_CTS_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UART_PSEL_CTS_PORT_Msk (0x1UL << UART_PSEL_CTS_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UART_PSEL_CTS_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UART_PSEL_CTS_PIN_Msk (0x1FUL << UART_PSEL_CTS_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UART_PSEL_RXD */ -/* Description: Pin select for RXD */ - -/* Bit 31 : Connection */ -#define UART_PSEL_RXD_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UART_PSEL_RXD_CONNECT_Msk (0x1UL << UART_PSEL_RXD_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UART_PSEL_RXD_CONNECT_Connected (0UL) /*!< Connect */ -#define UART_PSEL_RXD_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UART_PSEL_RXD_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UART_PSEL_RXD_PORT_Msk (0x1UL << UART_PSEL_RXD_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UART_PSEL_RXD_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UART_PSEL_RXD_PIN_Msk (0x1FUL << UART_PSEL_RXD_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UART_RXD */ -/* Description: RXD register */ - -/* Bits 7..0 : RX data received in previous transfers, double buffered */ -#define UART_RXD_RXD_Pos (0UL) /*!< Position of RXD field. */ -#define UART_RXD_RXD_Msk (0xFFUL << UART_RXD_RXD_Pos) /*!< Bit mask of RXD field. */ - -/* Register: UART_TXD */ -/* Description: TXD register */ - -/* Bits 7..0 : TX data to be transferred */ -#define UART_TXD_TXD_Pos (0UL) /*!< Position of TXD field. */ -#define UART_TXD_TXD_Msk (0xFFUL << UART_TXD_TXD_Pos) /*!< Bit mask of TXD field. */ - -/* Register: UART_BAUDRATE */ -/* Description: Baud rate. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : Baud rate */ -#define UART_BAUDRATE_BAUDRATE_Pos (0UL) /*!< Position of BAUDRATE field. */ -#define UART_BAUDRATE_BAUDRATE_Msk (0xFFFFFFFFUL << UART_BAUDRATE_BAUDRATE_Pos) /*!< Bit mask of BAUDRATE field. */ -#define UART_BAUDRATE_BAUDRATE_Baud1200 (0x0004F000UL) /*!< 1200 baud (actual rate: 1205) */ -#define UART_BAUDRATE_BAUDRATE_Baud2400 (0x0009D000UL) /*!< 2400 baud (actual rate: 2396) */ -#define UART_BAUDRATE_BAUDRATE_Baud4800 (0x0013B000UL) /*!< 4800 baud (actual rate: 4808) */ -#define UART_BAUDRATE_BAUDRATE_Baud9600 (0x00275000UL) /*!< 9600 baud (actual rate: 9598) */ -#define UART_BAUDRATE_BAUDRATE_Baud14400 (0x003B0000UL) /*!< 14400 baud (actual rate: 14414) */ -#define UART_BAUDRATE_BAUDRATE_Baud19200 (0x004EA000UL) /*!< 19200 baud (actual rate: 19208) */ -#define UART_BAUDRATE_BAUDRATE_Baud28800 (0x0075F000UL) /*!< 28800 baud (actual rate: 28829) */ -#define UART_BAUDRATE_BAUDRATE_Baud31250 (0x00800000UL) /*!< 31250 baud */ -#define UART_BAUDRATE_BAUDRATE_Baud38400 (0x009D5000UL) /*!< 38400 baud (actual rate: 38462) */ -#define UART_BAUDRATE_BAUDRATE_Baud56000 (0x00E50000UL) /*!< 56000 baud (actual rate: 55944) */ -#define UART_BAUDRATE_BAUDRATE_Baud57600 (0x00EBF000UL) /*!< 57600 baud (actual rate: 57762) */ -#define UART_BAUDRATE_BAUDRATE_Baud76800 (0x013A9000UL) /*!< 76800 baud (actual rate: 76923) */ -#define UART_BAUDRATE_BAUDRATE_Baud115200 (0x01D7E000UL) /*!< 115200 baud (actual rate: 115942) */ -#define UART_BAUDRATE_BAUDRATE_Baud230400 (0x03AFB000UL) /*!< 230400 baud (actual rate: 231884) */ -#define UART_BAUDRATE_BAUDRATE_Baud250000 (0x04000000UL) /*!< 250000 baud */ -#define UART_BAUDRATE_BAUDRATE_Baud460800 (0x075F7000UL) /*!< 460800 baud (actual rate: 470588) */ -#define UART_BAUDRATE_BAUDRATE_Baud921600 (0x0EBED000UL) /*!< 921600 baud (actual rate: 941176) */ -#define UART_BAUDRATE_BAUDRATE_Baud1M (0x10000000UL) /*!< 1Mega baud */ - -/* Register: UART_CONFIG */ -/* Description: Configuration of parity and hardware flow control */ - -/* Bits 3..1 : Parity */ -#define UART_CONFIG_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UART_CONFIG_PARITY_Msk (0x7UL << UART_CONFIG_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UART_CONFIG_PARITY_Excluded (0x0UL) /*!< Exclude parity bit */ -#define UART_CONFIG_PARITY_Included (0x7UL) /*!< Include parity bit */ - -/* Bit 0 : Hardware flow control */ -#define UART_CONFIG_HWFC_Pos (0UL) /*!< Position of HWFC field. */ -#define UART_CONFIG_HWFC_Msk (0x1UL << UART_CONFIG_HWFC_Pos) /*!< Bit mask of HWFC field. */ -#define UART_CONFIG_HWFC_Disabled (0UL) /*!< Disabled */ -#define UART_CONFIG_HWFC_Enabled (1UL) /*!< Enabled */ - - -/* Peripheral: UARTE */ -/* Description: UART with EasyDMA 0 */ - -/* Register: UARTE_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 6 : Shortcut between ENDRX event and STOPRX task */ -#define UARTE_SHORTS_ENDRX_STOPRX_Pos (6UL) /*!< Position of ENDRX_STOPRX field. */ -#define UARTE_SHORTS_ENDRX_STOPRX_Msk (0x1UL << UARTE_SHORTS_ENDRX_STOPRX_Pos) /*!< Bit mask of ENDRX_STOPRX field. */ -#define UARTE_SHORTS_ENDRX_STOPRX_Disabled (0UL) /*!< Disable shortcut */ -#define UARTE_SHORTS_ENDRX_STOPRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 5 : Shortcut between ENDRX event and STARTRX task */ -#define UARTE_SHORTS_ENDRX_STARTRX_Pos (5UL) /*!< Position of ENDRX_STARTRX field. */ -#define UARTE_SHORTS_ENDRX_STARTRX_Msk (0x1UL << UARTE_SHORTS_ENDRX_STARTRX_Pos) /*!< Bit mask of ENDRX_STARTRX field. */ -#define UARTE_SHORTS_ENDRX_STARTRX_Disabled (0UL) /*!< Disable shortcut */ -#define UARTE_SHORTS_ENDRX_STARTRX_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: UARTE_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 22 : Enable or disable interrupt for TXSTOPPED event */ -#define UARTE_INTEN_TXSTOPPED_Pos (22UL) /*!< Position of TXSTOPPED field. */ -#define UARTE_INTEN_TXSTOPPED_Msk (0x1UL << UARTE_INTEN_TXSTOPPED_Pos) /*!< Bit mask of TXSTOPPED field. */ -#define UARTE_INTEN_TXSTOPPED_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_TXSTOPPED_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for TXSTARTED event */ -#define UARTE_INTEN_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define UARTE_INTEN_TXSTARTED_Msk (0x1UL << UARTE_INTEN_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define UARTE_INTEN_TXSTARTED_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_TXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for RXSTARTED event */ -#define UARTE_INTEN_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define UARTE_INTEN_RXSTARTED_Msk (0x1UL << UARTE_INTEN_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define UARTE_INTEN_RXSTARTED_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_RXSTARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable interrupt for RXTO event */ -#define UARTE_INTEN_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UARTE_INTEN_RXTO_Msk (0x1UL << UARTE_INTEN_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UARTE_INTEN_RXTO_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_RXTO_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ERROR event */ -#define UARTE_INTEN_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UARTE_INTEN_ERROR_Msk (0x1UL << UARTE_INTEN_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UARTE_INTEN_ERROR_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_ERROR_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for ENDTX event */ -#define UARTE_INTEN_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define UARTE_INTEN_ENDTX_Msk (0x1UL << UARTE_INTEN_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define UARTE_INTEN_ENDTX_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_ENDTX_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for TXDRDY event */ -#define UARTE_INTEN_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UARTE_INTEN_TXDRDY_Msk (0x1UL << UARTE_INTEN_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UARTE_INTEN_TXDRDY_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_TXDRDY_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for ENDRX event */ -#define UARTE_INTEN_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define UARTE_INTEN_ENDRX_Msk (0x1UL << UARTE_INTEN_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define UARTE_INTEN_ENDRX_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_ENDRX_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for RXDRDY event */ -#define UARTE_INTEN_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UARTE_INTEN_RXDRDY_Msk (0x1UL << UARTE_INTEN_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UARTE_INTEN_RXDRDY_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_RXDRDY_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for NCTS event */ -#define UARTE_INTEN_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UARTE_INTEN_NCTS_Msk (0x1UL << UARTE_INTEN_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UARTE_INTEN_NCTS_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_NCTS_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for CTS event */ -#define UARTE_INTEN_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UARTE_INTEN_CTS_Msk (0x1UL << UARTE_INTEN_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UARTE_INTEN_CTS_Disabled (0UL) /*!< Disable */ -#define UARTE_INTEN_CTS_Enabled (1UL) /*!< Enable */ - -/* Register: UARTE_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 22 : Write '1' to Enable interrupt for TXSTOPPED event */ -#define UARTE_INTENSET_TXSTOPPED_Pos (22UL) /*!< Position of TXSTOPPED field. */ -#define UARTE_INTENSET_TXSTOPPED_Msk (0x1UL << UARTE_INTENSET_TXSTOPPED_Pos) /*!< Bit mask of TXSTOPPED field. */ -#define UARTE_INTENSET_TXSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_TXSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_TXSTOPPED_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for TXSTARTED event */ -#define UARTE_INTENSET_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define UARTE_INTENSET_TXSTARTED_Msk (0x1UL << UARTE_INTENSET_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define UARTE_INTENSET_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_TXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for RXSTARTED event */ -#define UARTE_INTENSET_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define UARTE_INTENSET_RXSTARTED_Msk (0x1UL << UARTE_INTENSET_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define UARTE_INTENSET_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_RXSTARTED_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for RXTO event */ -#define UARTE_INTENSET_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UARTE_INTENSET_RXTO_Msk (0x1UL << UARTE_INTENSET_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UARTE_INTENSET_RXTO_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_RXTO_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_RXTO_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ERROR event */ -#define UARTE_INTENSET_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UARTE_INTENSET_ERROR_Msk (0x1UL << UARTE_INTENSET_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UARTE_INTENSET_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_ERROR_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for ENDTX event */ -#define UARTE_INTENSET_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define UARTE_INTENSET_ENDTX_Msk (0x1UL << UARTE_INTENSET_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define UARTE_INTENSET_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_ENDTX_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for TXDRDY event */ -#define UARTE_INTENSET_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UARTE_INTENSET_TXDRDY_Msk (0x1UL << UARTE_INTENSET_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UARTE_INTENSET_TXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_TXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_TXDRDY_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDRX event */ -#define UARTE_INTENSET_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define UARTE_INTENSET_ENDRX_Msk (0x1UL << UARTE_INTENSET_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define UARTE_INTENSET_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_ENDRX_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for RXDRDY event */ -#define UARTE_INTENSET_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UARTE_INTENSET_RXDRDY_Msk (0x1UL << UARTE_INTENSET_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UARTE_INTENSET_RXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_RXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_RXDRDY_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for NCTS event */ -#define UARTE_INTENSET_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UARTE_INTENSET_NCTS_Msk (0x1UL << UARTE_INTENSET_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UARTE_INTENSET_NCTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_NCTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_NCTS_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for CTS event */ -#define UARTE_INTENSET_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UARTE_INTENSET_CTS_Msk (0x1UL << UARTE_INTENSET_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UARTE_INTENSET_CTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENSET_CTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENSET_CTS_Set (1UL) /*!< Enable */ - -/* Register: UARTE_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 22 : Write '1' to Disable interrupt for TXSTOPPED event */ -#define UARTE_INTENCLR_TXSTOPPED_Pos (22UL) /*!< Position of TXSTOPPED field. */ -#define UARTE_INTENCLR_TXSTOPPED_Msk (0x1UL << UARTE_INTENCLR_TXSTOPPED_Pos) /*!< Bit mask of TXSTOPPED field. */ -#define UARTE_INTENCLR_TXSTOPPED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_TXSTOPPED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_TXSTOPPED_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for TXSTARTED event */ -#define UARTE_INTENCLR_TXSTARTED_Pos (20UL) /*!< Position of TXSTARTED field. */ -#define UARTE_INTENCLR_TXSTARTED_Msk (0x1UL << UARTE_INTENCLR_TXSTARTED_Pos) /*!< Bit mask of TXSTARTED field. */ -#define UARTE_INTENCLR_TXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_TXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_TXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for RXSTARTED event */ -#define UARTE_INTENCLR_RXSTARTED_Pos (19UL) /*!< Position of RXSTARTED field. */ -#define UARTE_INTENCLR_RXSTARTED_Msk (0x1UL << UARTE_INTENCLR_RXSTARTED_Pos) /*!< Bit mask of RXSTARTED field. */ -#define UARTE_INTENCLR_RXSTARTED_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_RXSTARTED_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_RXSTARTED_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for RXTO event */ -#define UARTE_INTENCLR_RXTO_Pos (17UL) /*!< Position of RXTO field. */ -#define UARTE_INTENCLR_RXTO_Msk (0x1UL << UARTE_INTENCLR_RXTO_Pos) /*!< Bit mask of RXTO field. */ -#define UARTE_INTENCLR_RXTO_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_RXTO_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_RXTO_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ERROR event */ -#define UARTE_INTENCLR_ERROR_Pos (9UL) /*!< Position of ERROR field. */ -#define UARTE_INTENCLR_ERROR_Msk (0x1UL << UARTE_INTENCLR_ERROR_Pos) /*!< Bit mask of ERROR field. */ -#define UARTE_INTENCLR_ERROR_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_ERROR_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_ERROR_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for ENDTX event */ -#define UARTE_INTENCLR_ENDTX_Pos (8UL) /*!< Position of ENDTX field. */ -#define UARTE_INTENCLR_ENDTX_Msk (0x1UL << UARTE_INTENCLR_ENDTX_Pos) /*!< Bit mask of ENDTX field. */ -#define UARTE_INTENCLR_ENDTX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_ENDTX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_ENDTX_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for TXDRDY event */ -#define UARTE_INTENCLR_TXDRDY_Pos (7UL) /*!< Position of TXDRDY field. */ -#define UARTE_INTENCLR_TXDRDY_Msk (0x1UL << UARTE_INTENCLR_TXDRDY_Pos) /*!< Bit mask of TXDRDY field. */ -#define UARTE_INTENCLR_TXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_TXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_TXDRDY_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDRX event */ -#define UARTE_INTENCLR_ENDRX_Pos (4UL) /*!< Position of ENDRX field. */ -#define UARTE_INTENCLR_ENDRX_Msk (0x1UL << UARTE_INTENCLR_ENDRX_Pos) /*!< Bit mask of ENDRX field. */ -#define UARTE_INTENCLR_ENDRX_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_ENDRX_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_ENDRX_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for RXDRDY event */ -#define UARTE_INTENCLR_RXDRDY_Pos (2UL) /*!< Position of RXDRDY field. */ -#define UARTE_INTENCLR_RXDRDY_Msk (0x1UL << UARTE_INTENCLR_RXDRDY_Pos) /*!< Bit mask of RXDRDY field. */ -#define UARTE_INTENCLR_RXDRDY_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_RXDRDY_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_RXDRDY_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for NCTS event */ -#define UARTE_INTENCLR_NCTS_Pos (1UL) /*!< Position of NCTS field. */ -#define UARTE_INTENCLR_NCTS_Msk (0x1UL << UARTE_INTENCLR_NCTS_Pos) /*!< Bit mask of NCTS field. */ -#define UARTE_INTENCLR_NCTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_NCTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_NCTS_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for CTS event */ -#define UARTE_INTENCLR_CTS_Pos (0UL) /*!< Position of CTS field. */ -#define UARTE_INTENCLR_CTS_Msk (0x1UL << UARTE_INTENCLR_CTS_Pos) /*!< Bit mask of CTS field. */ -#define UARTE_INTENCLR_CTS_Disabled (0UL) /*!< Read: Disabled */ -#define UARTE_INTENCLR_CTS_Enabled (1UL) /*!< Read: Enabled */ -#define UARTE_INTENCLR_CTS_Clear (1UL) /*!< Disable */ - -/* Register: UARTE_ERRORSRC */ -/* Description: Error source Note : this register is read / write one to clear. */ - -/* Bit 3 : Break condition */ -#define UARTE_ERRORSRC_BREAK_Pos (3UL) /*!< Position of BREAK field. */ -#define UARTE_ERRORSRC_BREAK_Msk (0x1UL << UARTE_ERRORSRC_BREAK_Pos) /*!< Bit mask of BREAK field. */ -#define UARTE_ERRORSRC_BREAK_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_BREAK_Present (1UL) /*!< Read: error present */ - -/* Bit 2 : Framing error occurred */ -#define UARTE_ERRORSRC_FRAMING_Pos (2UL) /*!< Position of FRAMING field. */ -#define UARTE_ERRORSRC_FRAMING_Msk (0x1UL << UARTE_ERRORSRC_FRAMING_Pos) /*!< Bit mask of FRAMING field. */ -#define UARTE_ERRORSRC_FRAMING_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_FRAMING_Present (1UL) /*!< Read: error present */ - -/* Bit 1 : Parity error */ -#define UARTE_ERRORSRC_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UARTE_ERRORSRC_PARITY_Msk (0x1UL << UARTE_ERRORSRC_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UARTE_ERRORSRC_PARITY_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_PARITY_Present (1UL) /*!< Read: error present */ - -/* Bit 0 : Overrun error */ -#define UARTE_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */ -#define UARTE_ERRORSRC_OVERRUN_Msk (0x1UL << UARTE_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */ -#define UARTE_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Read: error not present */ -#define UARTE_ERRORSRC_OVERRUN_Present (1UL) /*!< Read: error present */ - -/* Register: UARTE_ENABLE */ -/* Description: Enable UART */ - -/* Bits 3..0 : Enable or disable UARTE */ -#define UARTE_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define UARTE_ENABLE_ENABLE_Msk (0xFUL << UARTE_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define UARTE_ENABLE_ENABLE_Disabled (0UL) /*!< Disable UARTE */ -#define UARTE_ENABLE_ENABLE_Enabled (8UL) /*!< Enable UARTE */ - -/* Register: UARTE_PSEL_RTS */ -/* Description: Pin select for RTS signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_RTS_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_RTS_CONNECT_Msk (0x1UL << UARTE_PSEL_RTS_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_RTS_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_RTS_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UARTE_PSEL_RTS_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UARTE_PSEL_RTS_PORT_Msk (0x1UL << UARTE_PSEL_RTS_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_RTS_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_RTS_PIN_Msk (0x1FUL << UARTE_PSEL_RTS_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_PSEL_TXD */ -/* Description: Pin select for TXD signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_TXD_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_TXD_CONNECT_Msk (0x1UL << UARTE_PSEL_TXD_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_TXD_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_TXD_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UARTE_PSEL_TXD_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UARTE_PSEL_TXD_PORT_Msk (0x1UL << UARTE_PSEL_TXD_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_TXD_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_TXD_PIN_Msk (0x1FUL << UARTE_PSEL_TXD_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_PSEL_CTS */ -/* Description: Pin select for CTS signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_CTS_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_CTS_CONNECT_Msk (0x1UL << UARTE_PSEL_CTS_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_CTS_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_CTS_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UARTE_PSEL_CTS_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UARTE_PSEL_CTS_PORT_Msk (0x1UL << UARTE_PSEL_CTS_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_CTS_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_CTS_PIN_Msk (0x1FUL << UARTE_PSEL_CTS_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_PSEL_RXD */ -/* Description: Pin select for RXD signal */ - -/* Bit 31 : Connection */ -#define UARTE_PSEL_RXD_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UARTE_PSEL_RXD_CONNECT_Msk (0x1UL << UARTE_PSEL_RXD_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UARTE_PSEL_RXD_CONNECT_Connected (0UL) /*!< Connect */ -#define UARTE_PSEL_RXD_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number */ -#define UARTE_PSEL_RXD_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UARTE_PSEL_RXD_PORT_Msk (0x1UL << UARTE_PSEL_RXD_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number */ -#define UARTE_PSEL_RXD_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UARTE_PSEL_RXD_PIN_Msk (0x1FUL << UARTE_PSEL_RXD_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UARTE_BAUDRATE */ -/* Description: Baud rate. Accuracy depends on the HFCLK source selected. */ - -/* Bits 31..0 : Baud rate */ -#define UARTE_BAUDRATE_BAUDRATE_Pos (0UL) /*!< Position of BAUDRATE field. */ -#define UARTE_BAUDRATE_BAUDRATE_Msk (0xFFFFFFFFUL << UARTE_BAUDRATE_BAUDRATE_Pos) /*!< Bit mask of BAUDRATE field. */ -#define UARTE_BAUDRATE_BAUDRATE_Baud1200 (0x0004F000UL) /*!< 1200 baud (actual rate: 1205) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud2400 (0x0009D000UL) /*!< 2400 baud (actual rate: 2396) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud4800 (0x0013B000UL) /*!< 4800 baud (actual rate: 4808) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud9600 (0x00275000UL) /*!< 9600 baud (actual rate: 9598) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud14400 (0x003AF000UL) /*!< 14400 baud (actual rate: 14401) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud19200 (0x004EA000UL) /*!< 19200 baud (actual rate: 19208) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud28800 (0x0075C000UL) /*!< 28800 baud (actual rate: 28777) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud31250 (0x00800000UL) /*!< 31250 baud */ -#define UARTE_BAUDRATE_BAUDRATE_Baud38400 (0x009D0000UL) /*!< 38400 baud (actual rate: 38369) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud56000 (0x00E50000UL) /*!< 56000 baud (actual rate: 55944) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud57600 (0x00EB0000UL) /*!< 57600 baud (actual rate: 57554) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud76800 (0x013A9000UL) /*!< 76800 baud (actual rate: 76923) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud115200 (0x01D60000UL) /*!< 115200 baud (actual rate: 115108) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud230400 (0x03B00000UL) /*!< 230400 baud (actual rate: 231884) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud250000 (0x04000000UL) /*!< 250000 baud */ -#define UARTE_BAUDRATE_BAUDRATE_Baud460800 (0x07400000UL) /*!< 460800 baud (actual rate: 457143) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud921600 (0x0F000000UL) /*!< 921600 baud (actual rate: 941176) */ -#define UARTE_BAUDRATE_BAUDRATE_Baud1M (0x10000000UL) /*!< 1Mega baud */ - -/* Register: UARTE_RXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define UARTE_RXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define UARTE_RXD_PTR_PTR_Msk (0xFFFFFFFFUL << UARTE_RXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: UARTE_RXD_MAXCNT */ -/* Description: Maximum number of bytes in receive buffer */ - -/* Bits 15..0 : Maximum number of bytes in receive buffer */ -#define UARTE_RXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define UARTE_RXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << UARTE_RXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: UARTE_RXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last transaction */ -#define UARTE_RXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define UARTE_RXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << UARTE_RXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: UARTE_TXD_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer */ -#define UARTE_TXD_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define UARTE_TXD_PTR_PTR_Msk (0xFFFFFFFFUL << UARTE_TXD_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: UARTE_TXD_MAXCNT */ -/* Description: Maximum number of bytes in transmit buffer */ - -/* Bits 15..0 : Maximum number of bytes in transmit buffer */ -#define UARTE_TXD_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define UARTE_TXD_MAXCNT_MAXCNT_Msk (0xFFFFUL << UARTE_TXD_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: UARTE_TXD_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 15..0 : Number of bytes transferred in the last transaction */ -#define UARTE_TXD_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define UARTE_TXD_AMOUNT_AMOUNT_Msk (0xFFFFUL << UARTE_TXD_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: UARTE_CONFIG */ -/* Description: Configuration of parity and hardware flow control */ - -/* Bit 4 : Stop bits */ -#define UARTE_CONFIG_STOP_Pos (4UL) /*!< Position of STOP field. */ -#define UARTE_CONFIG_STOP_Msk (0x1UL << UARTE_CONFIG_STOP_Pos) /*!< Bit mask of STOP field. */ -#define UARTE_CONFIG_STOP_One (0UL) /*!< One stop bit */ -#define UARTE_CONFIG_STOP_Two (1UL) /*!< Two stop bits */ - -/* Bits 3..1 : Parity */ -#define UARTE_CONFIG_PARITY_Pos (1UL) /*!< Position of PARITY field. */ -#define UARTE_CONFIG_PARITY_Msk (0x7UL << UARTE_CONFIG_PARITY_Pos) /*!< Bit mask of PARITY field. */ -#define UARTE_CONFIG_PARITY_Excluded (0x0UL) /*!< Exclude parity bit */ -#define UARTE_CONFIG_PARITY_Included (0x7UL) /*!< Include even parity bit */ - -/* Bit 0 : Hardware flow control */ -#define UARTE_CONFIG_HWFC_Pos (0UL) /*!< Position of HWFC field. */ -#define UARTE_CONFIG_HWFC_Msk (0x1UL << UARTE_CONFIG_HWFC_Pos) /*!< Bit mask of HWFC field. */ -#define UARTE_CONFIG_HWFC_Disabled (0UL) /*!< Disabled */ -#define UARTE_CONFIG_HWFC_Enabled (1UL) /*!< Enabled */ - - -/* Peripheral: UICR */ -/* Description: User information configuration registers */ - -/* Register: UICR_NRFFW */ -/* Description: Description collection[0]: Reserved for Nordic firmware design */ - -/* Bits 31..0 : Reserved for Nordic firmware design */ -#define UICR_NRFFW_NRFFW_Pos (0UL) /*!< Position of NRFFW field. */ -#define UICR_NRFFW_NRFFW_Msk (0xFFFFFFFFUL << UICR_NRFFW_NRFFW_Pos) /*!< Bit mask of NRFFW field. */ - -/* Register: UICR_NRFHW */ -/* Description: Description collection[0]: Reserved for Nordic hardware design */ - -/* Bits 31..0 : Reserved for Nordic hardware design */ -#define UICR_NRFHW_NRFHW_Pos (0UL) /*!< Position of NRFHW field. */ -#define UICR_NRFHW_NRFHW_Msk (0xFFFFFFFFUL << UICR_NRFHW_NRFHW_Pos) /*!< Bit mask of NRFHW field. */ - -/* Register: UICR_CUSTOMER */ -/* Description: Description collection[0]: Reserved for customer */ - -/* Bits 31..0 : Reserved for customer */ -#define UICR_CUSTOMER_CUSTOMER_Pos (0UL) /*!< Position of CUSTOMER field. */ -#define UICR_CUSTOMER_CUSTOMER_Msk (0xFFFFFFFFUL << UICR_CUSTOMER_CUSTOMER_Pos) /*!< Bit mask of CUSTOMER field. */ - -/* Register: UICR_PSELRESET */ -/* Description: Description collection[0]: Mapping of the nRESET function */ - -/* Bit 31 : Connection */ -#define UICR_PSELRESET_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */ -#define UICR_PSELRESET_CONNECT_Msk (0x1UL << UICR_PSELRESET_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define UICR_PSELRESET_CONNECT_Connected (0UL) /*!< Connect */ -#define UICR_PSELRESET_CONNECT_Disconnected (1UL) /*!< Disconnect */ - -/* Bit 5 : Port number onto which nRESET is exposed */ -#define UICR_PSELRESET_PORT_Pos (5UL) /*!< Position of PORT field. */ -#define UICR_PSELRESET_PORT_Msk (0x1UL << UICR_PSELRESET_PORT_Pos) /*!< Bit mask of PORT field. */ - -/* Bits 4..0 : Pin number of PORT onto which nRESET is exposed */ -#define UICR_PSELRESET_PIN_Pos (0UL) /*!< Position of PIN field. */ -#define UICR_PSELRESET_PIN_Msk (0x1FUL << UICR_PSELRESET_PIN_Pos) /*!< Bit mask of PIN field. */ - -/* Register: UICR_APPROTECT */ -/* Description: Access port protection */ - -/* Bits 7..0 : Enable or disable access port protection. */ -#define UICR_APPROTECT_PALL_Pos (0UL) /*!< Position of PALL field. */ -#define UICR_APPROTECT_PALL_Msk (0xFFUL << UICR_APPROTECT_PALL_Pos) /*!< Bit mask of PALL field. */ -#define UICR_APPROTECT_PALL_Enabled (0x00UL) /*!< Enable */ -#define UICR_APPROTECT_PALL_Disabled (0xFFUL) /*!< Disable */ - -/* Register: UICR_NFCPINS */ -/* Description: Setting of pins dedicated to NFC functionality: NFC antenna or GPIO */ - -/* Bit 0 : Setting of pins dedicated to NFC functionality */ -#define UICR_NFCPINS_PROTECT_Pos (0UL) /*!< Position of PROTECT field. */ -#define UICR_NFCPINS_PROTECT_Msk (0x1UL << UICR_NFCPINS_PROTECT_Pos) /*!< Bit mask of PROTECT field. */ -#define UICR_NFCPINS_PROTECT_Disabled (0UL) /*!< Operation as GPIO pins. Same protection as normal GPIO pins */ -#define UICR_NFCPINS_PROTECT_NFC (1UL) /*!< Operation as NFC antenna pins. Configures the protection for NFC operation */ - -/* Register: UICR_DEBUGCTRL */ -/* Description: Processor debug control */ - -/* Bits 15..8 : Configure CPU flash patch and breakpoint (FPB) unit behavior */ -#define UICR_DEBUGCTRL_CPUFPBEN_Pos (8UL) /*!< Position of CPUFPBEN field. */ -#define UICR_DEBUGCTRL_CPUFPBEN_Msk (0xFFUL << UICR_DEBUGCTRL_CPUFPBEN_Pos) /*!< Bit mask of CPUFPBEN field. */ -#define UICR_DEBUGCTRL_CPUFPBEN_Disabled (0x00UL) /*!< Disable CPU FPB unit. Writes into the FPB registers will be ignored. */ -#define UICR_DEBUGCTRL_CPUFPBEN_Enabled (0xFFUL) /*!< Enable CPU FPB unit (default behavior) */ - -/* Bits 7..0 : Configure CPU non-intrusive debug features */ -#define UICR_DEBUGCTRL_CPUNIDEN_Pos (0UL) /*!< Position of CPUNIDEN field. */ -#define UICR_DEBUGCTRL_CPUNIDEN_Msk (0xFFUL << UICR_DEBUGCTRL_CPUNIDEN_Pos) /*!< Bit mask of CPUNIDEN field. */ -#define UICR_DEBUGCTRL_CPUNIDEN_Disabled (0x00UL) /*!< Disable CPU ITM and ETM functionality */ -#define UICR_DEBUGCTRL_CPUNIDEN_Enabled (0xFFUL) /*!< Enable CPU ITM and ETM functionality (default behavior) */ - -/* Register: UICR_DCDCDRIVE0 */ -/* Description: Set drive level for REG0 DCDC mode. Using high drive will slightly reduce DCDC efficiency. */ - -/* Bit 0 : Set drive level for REG0 DCDC mode. */ -#define UICR_DCDCDRIVE0_DCDCDRIVE0_Pos (0UL) /*!< Position of DCDCDRIVE0 field. */ -#define UICR_DCDCDRIVE0_DCDCDRIVE0_Msk (0x1UL << UICR_DCDCDRIVE0_DCDCDRIVE0_Pos) /*!< Bit mask of DCDCDRIVE0 field. */ -#define UICR_DCDCDRIVE0_DCDCDRIVE0_Low (0UL) /*!< Low drive */ -#define UICR_DCDCDRIVE0_DCDCDRIVE0_High (1UL) /*!< High drive */ - -/* Register: UICR_REGOUT0 */ -/* Description: GPIO reference voltage / external output supply voltage in high voltage mode */ - -/* Bits 2..0 : Output voltage from of REG0 regulator stage. The maximum output voltage from this stage is given as VDDH - VEXDIF. */ -#define UICR_REGOUT0_VOUT_Pos (0UL) /*!< Position of VOUT field. */ -#define UICR_REGOUT0_VOUT_Msk (0x7UL << UICR_REGOUT0_VOUT_Pos) /*!< Bit mask of VOUT field. */ -#define UICR_REGOUT0_VOUT_1V8 (0UL) /*!< 1.8 V */ -#define UICR_REGOUT0_VOUT_2V1 (1UL) /*!< 2.1 V */ -#define UICR_REGOUT0_VOUT_2V4 (2UL) /*!< 2.4 V */ -#define UICR_REGOUT0_VOUT_2V7 (3UL) /*!< 2.7 V */ -#define UICR_REGOUT0_VOUT_3V0 (4UL) /*!< 3.0 V */ -#define UICR_REGOUT0_VOUT_3V3 (5UL) /*!< 3.3 V */ -#define UICR_REGOUT0_VOUT_DEFAULT (7UL) /*!< Default voltage: 1.8 V */ - - -/* Peripheral: USBD */ -/* Description: Universal Serial Bus device */ - -/* Register: USBD_SHORTS */ -/* Description: Shortcut register */ - -/* Bit 4 : Shortcut between ENDEPOUT[0] event and EP0RCVOUT task */ -#define USBD_SHORTS_ENDEPOUT0_EP0RCVOUT_Pos (4UL) /*!< Position of ENDEPOUT0_EP0RCVOUT field. */ -#define USBD_SHORTS_ENDEPOUT0_EP0RCVOUT_Msk (0x1UL << USBD_SHORTS_ENDEPOUT0_EP0RCVOUT_Pos) /*!< Bit mask of ENDEPOUT0_EP0RCVOUT field. */ -#define USBD_SHORTS_ENDEPOUT0_EP0RCVOUT_Disabled (0UL) /*!< Disable shortcut */ -#define USBD_SHORTS_ENDEPOUT0_EP0RCVOUT_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 3 : Shortcut between ENDEPOUT[0] event and EP0STATUS task */ -#define USBD_SHORTS_ENDEPOUT0_EP0STATUS_Pos (3UL) /*!< Position of ENDEPOUT0_EP0STATUS field. */ -#define USBD_SHORTS_ENDEPOUT0_EP0STATUS_Msk (0x1UL << USBD_SHORTS_ENDEPOUT0_EP0STATUS_Pos) /*!< Bit mask of ENDEPOUT0_EP0STATUS field. */ -#define USBD_SHORTS_ENDEPOUT0_EP0STATUS_Disabled (0UL) /*!< Disable shortcut */ -#define USBD_SHORTS_ENDEPOUT0_EP0STATUS_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 2 : Shortcut between EP0DATADONE event and EP0STATUS task */ -#define USBD_SHORTS_EP0DATADONE_EP0STATUS_Pos (2UL) /*!< Position of EP0DATADONE_EP0STATUS field. */ -#define USBD_SHORTS_EP0DATADONE_EP0STATUS_Msk (0x1UL << USBD_SHORTS_EP0DATADONE_EP0STATUS_Pos) /*!< Bit mask of EP0DATADONE_EP0STATUS field. */ -#define USBD_SHORTS_EP0DATADONE_EP0STATUS_Disabled (0UL) /*!< Disable shortcut */ -#define USBD_SHORTS_EP0DATADONE_EP0STATUS_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 1 : Shortcut between EP0DATADONE event and STARTEPOUT[0] task */ -#define USBD_SHORTS_EP0DATADONE_STARTEPOUT0_Pos (1UL) /*!< Position of EP0DATADONE_STARTEPOUT0 field. */ -#define USBD_SHORTS_EP0DATADONE_STARTEPOUT0_Msk (0x1UL << USBD_SHORTS_EP0DATADONE_STARTEPOUT0_Pos) /*!< Bit mask of EP0DATADONE_STARTEPOUT0 field. */ -#define USBD_SHORTS_EP0DATADONE_STARTEPOUT0_Disabled (0UL) /*!< Disable shortcut */ -#define USBD_SHORTS_EP0DATADONE_STARTEPOUT0_Enabled (1UL) /*!< Enable shortcut */ - -/* Bit 0 : Shortcut between EP0DATADONE event and STARTEPIN[0] task */ -#define USBD_SHORTS_EP0DATADONE_STARTEPIN0_Pos (0UL) /*!< Position of EP0DATADONE_STARTEPIN0 field. */ -#define USBD_SHORTS_EP0DATADONE_STARTEPIN0_Msk (0x1UL << USBD_SHORTS_EP0DATADONE_STARTEPIN0_Pos) /*!< Bit mask of EP0DATADONE_STARTEPIN0 field. */ -#define USBD_SHORTS_EP0DATADONE_STARTEPIN0_Disabled (0UL) /*!< Disable shortcut */ -#define USBD_SHORTS_EP0DATADONE_STARTEPIN0_Enabled (1UL) /*!< Enable shortcut */ - -/* Register: USBD_INTEN */ -/* Description: Enable or disable interrupt */ - -/* Bit 25 : Enable or disable interrupt for ACCESSFAULT event */ -#define USBD_INTEN_ACCESSFAULT_Pos (25UL) /*!< Position of ACCESSFAULT field. */ -#define USBD_INTEN_ACCESSFAULT_Msk (0x1UL << USBD_INTEN_ACCESSFAULT_Pos) /*!< Bit mask of ACCESSFAULT field. */ -#define USBD_INTEN_ACCESSFAULT_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ACCESSFAULT_Enabled (1UL) /*!< Enable */ - -/* Bit 24 : Enable or disable interrupt for EPDATA event */ -#define USBD_INTEN_EPDATA_Pos (24UL) /*!< Position of EPDATA field. */ -#define USBD_INTEN_EPDATA_Msk (0x1UL << USBD_INTEN_EPDATA_Pos) /*!< Bit mask of EPDATA field. */ -#define USBD_INTEN_EPDATA_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_EPDATA_Enabled (1UL) /*!< Enable */ - -/* Bit 23 : Enable or disable interrupt for EP0SETUP event */ -#define USBD_INTEN_EP0SETUP_Pos (23UL) /*!< Position of EP0SETUP field. */ -#define USBD_INTEN_EP0SETUP_Msk (0x1UL << USBD_INTEN_EP0SETUP_Pos) /*!< Bit mask of EP0SETUP field. */ -#define USBD_INTEN_EP0SETUP_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_EP0SETUP_Enabled (1UL) /*!< Enable */ - -/* Bit 22 : Enable or disable interrupt for USBEVENT event */ -#define USBD_INTEN_USBEVENT_Pos (22UL) /*!< Position of USBEVENT field. */ -#define USBD_INTEN_USBEVENT_Msk (0x1UL << USBD_INTEN_USBEVENT_Pos) /*!< Bit mask of USBEVENT field. */ -#define USBD_INTEN_USBEVENT_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_USBEVENT_Enabled (1UL) /*!< Enable */ - -/* Bit 21 : Enable or disable interrupt for SOF event */ -#define USBD_INTEN_SOF_Pos (21UL) /*!< Position of SOF field. */ -#define USBD_INTEN_SOF_Msk (0x1UL << USBD_INTEN_SOF_Pos) /*!< Bit mask of SOF field. */ -#define USBD_INTEN_SOF_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_SOF_Enabled (1UL) /*!< Enable */ - -/* Bit 20 : Enable or disable interrupt for ENDISOOUT event */ -#define USBD_INTEN_ENDISOOUT_Pos (20UL) /*!< Position of ENDISOOUT field. */ -#define USBD_INTEN_ENDISOOUT_Msk (0x1UL << USBD_INTEN_ENDISOOUT_Pos) /*!< Bit mask of ENDISOOUT field. */ -#define USBD_INTEN_ENDISOOUT_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDISOOUT_Enabled (1UL) /*!< Enable */ - -/* Bit 19 : Enable or disable interrupt for ENDEPOUT[7] event */ -#define USBD_INTEN_ENDEPOUT7_Pos (19UL) /*!< Position of ENDEPOUT7 field. */ -#define USBD_INTEN_ENDEPOUT7_Msk (0x1UL << USBD_INTEN_ENDEPOUT7_Pos) /*!< Bit mask of ENDEPOUT7 field. */ -#define USBD_INTEN_ENDEPOUT7_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT7_Enabled (1UL) /*!< Enable */ - -/* Bit 18 : Enable or disable interrupt for ENDEPOUT[6] event */ -#define USBD_INTEN_ENDEPOUT6_Pos (18UL) /*!< Position of ENDEPOUT6 field. */ -#define USBD_INTEN_ENDEPOUT6_Msk (0x1UL << USBD_INTEN_ENDEPOUT6_Pos) /*!< Bit mask of ENDEPOUT6 field. */ -#define USBD_INTEN_ENDEPOUT6_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT6_Enabled (1UL) /*!< Enable */ - -/* Bit 17 : Enable or disable interrupt for ENDEPOUT[5] event */ -#define USBD_INTEN_ENDEPOUT5_Pos (17UL) /*!< Position of ENDEPOUT5 field. */ -#define USBD_INTEN_ENDEPOUT5_Msk (0x1UL << USBD_INTEN_ENDEPOUT5_Pos) /*!< Bit mask of ENDEPOUT5 field. */ -#define USBD_INTEN_ENDEPOUT5_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT5_Enabled (1UL) /*!< Enable */ - -/* Bit 16 : Enable or disable interrupt for ENDEPOUT[4] event */ -#define USBD_INTEN_ENDEPOUT4_Pos (16UL) /*!< Position of ENDEPOUT4 field. */ -#define USBD_INTEN_ENDEPOUT4_Msk (0x1UL << USBD_INTEN_ENDEPOUT4_Pos) /*!< Bit mask of ENDEPOUT4 field. */ -#define USBD_INTEN_ENDEPOUT4_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT4_Enabled (1UL) /*!< Enable */ - -/* Bit 15 : Enable or disable interrupt for ENDEPOUT[3] event */ -#define USBD_INTEN_ENDEPOUT3_Pos (15UL) /*!< Position of ENDEPOUT3 field. */ -#define USBD_INTEN_ENDEPOUT3_Msk (0x1UL << USBD_INTEN_ENDEPOUT3_Pos) /*!< Bit mask of ENDEPOUT3 field. */ -#define USBD_INTEN_ENDEPOUT3_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT3_Enabled (1UL) /*!< Enable */ - -/* Bit 14 : Enable or disable interrupt for ENDEPOUT[2] event */ -#define USBD_INTEN_ENDEPOUT2_Pos (14UL) /*!< Position of ENDEPOUT2 field. */ -#define USBD_INTEN_ENDEPOUT2_Msk (0x1UL << USBD_INTEN_ENDEPOUT2_Pos) /*!< Bit mask of ENDEPOUT2 field. */ -#define USBD_INTEN_ENDEPOUT2_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT2_Enabled (1UL) /*!< Enable */ - -/* Bit 13 : Enable or disable interrupt for ENDEPOUT[1] event */ -#define USBD_INTEN_ENDEPOUT1_Pos (13UL) /*!< Position of ENDEPOUT1 field. */ -#define USBD_INTEN_ENDEPOUT1_Msk (0x1UL << USBD_INTEN_ENDEPOUT1_Pos) /*!< Bit mask of ENDEPOUT1 field. */ -#define USBD_INTEN_ENDEPOUT1_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT1_Enabled (1UL) /*!< Enable */ - -/* Bit 12 : Enable or disable interrupt for ENDEPOUT[0] event */ -#define USBD_INTEN_ENDEPOUT0_Pos (12UL) /*!< Position of ENDEPOUT0 field. */ -#define USBD_INTEN_ENDEPOUT0_Msk (0x1UL << USBD_INTEN_ENDEPOUT0_Pos) /*!< Bit mask of ENDEPOUT0 field. */ -#define USBD_INTEN_ENDEPOUT0_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPOUT0_Enabled (1UL) /*!< Enable */ - -/* Bit 11 : Enable or disable interrupt for ENDISOIN event */ -#define USBD_INTEN_ENDISOIN_Pos (11UL) /*!< Position of ENDISOIN field. */ -#define USBD_INTEN_ENDISOIN_Msk (0x1UL << USBD_INTEN_ENDISOIN_Pos) /*!< Bit mask of ENDISOIN field. */ -#define USBD_INTEN_ENDISOIN_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDISOIN_Enabled (1UL) /*!< Enable */ - -/* Bit 10 : Enable or disable interrupt for EP0DATADONE event */ -#define USBD_INTEN_EP0DATADONE_Pos (10UL) /*!< Position of EP0DATADONE field. */ -#define USBD_INTEN_EP0DATADONE_Msk (0x1UL << USBD_INTEN_EP0DATADONE_Pos) /*!< Bit mask of EP0DATADONE field. */ -#define USBD_INTEN_EP0DATADONE_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_EP0DATADONE_Enabled (1UL) /*!< Enable */ - -/* Bit 9 : Enable or disable interrupt for ENDEPIN[7] event */ -#define USBD_INTEN_ENDEPIN7_Pos (9UL) /*!< Position of ENDEPIN7 field. */ -#define USBD_INTEN_ENDEPIN7_Msk (0x1UL << USBD_INTEN_ENDEPIN7_Pos) /*!< Bit mask of ENDEPIN7 field. */ -#define USBD_INTEN_ENDEPIN7_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN7_Enabled (1UL) /*!< Enable */ - -/* Bit 8 : Enable or disable interrupt for ENDEPIN[6] event */ -#define USBD_INTEN_ENDEPIN6_Pos (8UL) /*!< Position of ENDEPIN6 field. */ -#define USBD_INTEN_ENDEPIN6_Msk (0x1UL << USBD_INTEN_ENDEPIN6_Pos) /*!< Bit mask of ENDEPIN6 field. */ -#define USBD_INTEN_ENDEPIN6_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN6_Enabled (1UL) /*!< Enable */ - -/* Bit 7 : Enable or disable interrupt for ENDEPIN[5] event */ -#define USBD_INTEN_ENDEPIN5_Pos (7UL) /*!< Position of ENDEPIN5 field. */ -#define USBD_INTEN_ENDEPIN5_Msk (0x1UL << USBD_INTEN_ENDEPIN5_Pos) /*!< Bit mask of ENDEPIN5 field. */ -#define USBD_INTEN_ENDEPIN5_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN5_Enabled (1UL) /*!< Enable */ - -/* Bit 6 : Enable or disable interrupt for ENDEPIN[4] event */ -#define USBD_INTEN_ENDEPIN4_Pos (6UL) /*!< Position of ENDEPIN4 field. */ -#define USBD_INTEN_ENDEPIN4_Msk (0x1UL << USBD_INTEN_ENDEPIN4_Pos) /*!< Bit mask of ENDEPIN4 field. */ -#define USBD_INTEN_ENDEPIN4_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN4_Enabled (1UL) /*!< Enable */ - -/* Bit 5 : Enable or disable interrupt for ENDEPIN[3] event */ -#define USBD_INTEN_ENDEPIN3_Pos (5UL) /*!< Position of ENDEPIN3 field. */ -#define USBD_INTEN_ENDEPIN3_Msk (0x1UL << USBD_INTEN_ENDEPIN3_Pos) /*!< Bit mask of ENDEPIN3 field. */ -#define USBD_INTEN_ENDEPIN3_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN3_Enabled (1UL) /*!< Enable */ - -/* Bit 4 : Enable or disable interrupt for ENDEPIN[2] event */ -#define USBD_INTEN_ENDEPIN2_Pos (4UL) /*!< Position of ENDEPIN2 field. */ -#define USBD_INTEN_ENDEPIN2_Msk (0x1UL << USBD_INTEN_ENDEPIN2_Pos) /*!< Bit mask of ENDEPIN2 field. */ -#define USBD_INTEN_ENDEPIN2_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN2_Enabled (1UL) /*!< Enable */ - -/* Bit 3 : Enable or disable interrupt for ENDEPIN[1] event */ -#define USBD_INTEN_ENDEPIN1_Pos (3UL) /*!< Position of ENDEPIN1 field. */ -#define USBD_INTEN_ENDEPIN1_Msk (0x1UL << USBD_INTEN_ENDEPIN1_Pos) /*!< Bit mask of ENDEPIN1 field. */ -#define USBD_INTEN_ENDEPIN1_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN1_Enabled (1UL) /*!< Enable */ - -/* Bit 2 : Enable or disable interrupt for ENDEPIN[0] event */ -#define USBD_INTEN_ENDEPIN0_Pos (2UL) /*!< Position of ENDEPIN0 field. */ -#define USBD_INTEN_ENDEPIN0_Msk (0x1UL << USBD_INTEN_ENDEPIN0_Pos) /*!< Bit mask of ENDEPIN0 field. */ -#define USBD_INTEN_ENDEPIN0_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_ENDEPIN0_Enabled (1UL) /*!< Enable */ - -/* Bit 1 : Enable or disable interrupt for STARTED event */ -#define USBD_INTEN_STARTED_Pos (1UL) /*!< Position of STARTED field. */ -#define USBD_INTEN_STARTED_Msk (0x1UL << USBD_INTEN_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define USBD_INTEN_STARTED_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_STARTED_Enabled (1UL) /*!< Enable */ - -/* Bit 0 : Enable or disable interrupt for USBRESET event */ -#define USBD_INTEN_USBRESET_Pos (0UL) /*!< Position of USBRESET field. */ -#define USBD_INTEN_USBRESET_Msk (0x1UL << USBD_INTEN_USBRESET_Pos) /*!< Bit mask of USBRESET field. */ -#define USBD_INTEN_USBRESET_Disabled (0UL) /*!< Disable */ -#define USBD_INTEN_USBRESET_Enabled (1UL) /*!< Enable */ - -/* Register: USBD_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 25 : Write '1' to Enable interrupt for ACCESSFAULT event */ -#define USBD_INTENSET_ACCESSFAULT_Pos (25UL) /*!< Position of ACCESSFAULT field. */ -#define USBD_INTENSET_ACCESSFAULT_Msk (0x1UL << USBD_INTENSET_ACCESSFAULT_Pos) /*!< Bit mask of ACCESSFAULT field. */ -#define USBD_INTENSET_ACCESSFAULT_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ACCESSFAULT_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ACCESSFAULT_Set (1UL) /*!< Enable */ - -/* Bit 24 : Write '1' to Enable interrupt for EPDATA event */ -#define USBD_INTENSET_EPDATA_Pos (24UL) /*!< Position of EPDATA field. */ -#define USBD_INTENSET_EPDATA_Msk (0x1UL << USBD_INTENSET_EPDATA_Pos) /*!< Bit mask of EPDATA field. */ -#define USBD_INTENSET_EPDATA_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_EPDATA_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_EPDATA_Set (1UL) /*!< Enable */ - -/* Bit 23 : Write '1' to Enable interrupt for EP0SETUP event */ -#define USBD_INTENSET_EP0SETUP_Pos (23UL) /*!< Position of EP0SETUP field. */ -#define USBD_INTENSET_EP0SETUP_Msk (0x1UL << USBD_INTENSET_EP0SETUP_Pos) /*!< Bit mask of EP0SETUP field. */ -#define USBD_INTENSET_EP0SETUP_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_EP0SETUP_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_EP0SETUP_Set (1UL) /*!< Enable */ - -/* Bit 22 : Write '1' to Enable interrupt for USBEVENT event */ -#define USBD_INTENSET_USBEVENT_Pos (22UL) /*!< Position of USBEVENT field. */ -#define USBD_INTENSET_USBEVENT_Msk (0x1UL << USBD_INTENSET_USBEVENT_Pos) /*!< Bit mask of USBEVENT field. */ -#define USBD_INTENSET_USBEVENT_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_USBEVENT_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_USBEVENT_Set (1UL) /*!< Enable */ - -/* Bit 21 : Write '1' to Enable interrupt for SOF event */ -#define USBD_INTENSET_SOF_Pos (21UL) /*!< Position of SOF field. */ -#define USBD_INTENSET_SOF_Msk (0x1UL << USBD_INTENSET_SOF_Pos) /*!< Bit mask of SOF field. */ -#define USBD_INTENSET_SOF_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_SOF_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_SOF_Set (1UL) /*!< Enable */ - -/* Bit 20 : Write '1' to Enable interrupt for ENDISOOUT event */ -#define USBD_INTENSET_ENDISOOUT_Pos (20UL) /*!< Position of ENDISOOUT field. */ -#define USBD_INTENSET_ENDISOOUT_Msk (0x1UL << USBD_INTENSET_ENDISOOUT_Pos) /*!< Bit mask of ENDISOOUT field. */ -#define USBD_INTENSET_ENDISOOUT_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDISOOUT_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDISOOUT_Set (1UL) /*!< Enable */ - -/* Bit 19 : Write '1' to Enable interrupt for ENDEPOUT[7] event */ -#define USBD_INTENSET_ENDEPOUT7_Pos (19UL) /*!< Position of ENDEPOUT7 field. */ -#define USBD_INTENSET_ENDEPOUT7_Msk (0x1UL << USBD_INTENSET_ENDEPOUT7_Pos) /*!< Bit mask of ENDEPOUT7 field. */ -#define USBD_INTENSET_ENDEPOUT7_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT7_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT7_Set (1UL) /*!< Enable */ - -/* Bit 18 : Write '1' to Enable interrupt for ENDEPOUT[6] event */ -#define USBD_INTENSET_ENDEPOUT6_Pos (18UL) /*!< Position of ENDEPOUT6 field. */ -#define USBD_INTENSET_ENDEPOUT6_Msk (0x1UL << USBD_INTENSET_ENDEPOUT6_Pos) /*!< Bit mask of ENDEPOUT6 field. */ -#define USBD_INTENSET_ENDEPOUT6_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT6_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT6_Set (1UL) /*!< Enable */ - -/* Bit 17 : Write '1' to Enable interrupt for ENDEPOUT[5] event */ -#define USBD_INTENSET_ENDEPOUT5_Pos (17UL) /*!< Position of ENDEPOUT5 field. */ -#define USBD_INTENSET_ENDEPOUT5_Msk (0x1UL << USBD_INTENSET_ENDEPOUT5_Pos) /*!< Bit mask of ENDEPOUT5 field. */ -#define USBD_INTENSET_ENDEPOUT5_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT5_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT5_Set (1UL) /*!< Enable */ - -/* Bit 16 : Write '1' to Enable interrupt for ENDEPOUT[4] event */ -#define USBD_INTENSET_ENDEPOUT4_Pos (16UL) /*!< Position of ENDEPOUT4 field. */ -#define USBD_INTENSET_ENDEPOUT4_Msk (0x1UL << USBD_INTENSET_ENDEPOUT4_Pos) /*!< Bit mask of ENDEPOUT4 field. */ -#define USBD_INTENSET_ENDEPOUT4_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT4_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT4_Set (1UL) /*!< Enable */ - -/* Bit 15 : Write '1' to Enable interrupt for ENDEPOUT[3] event */ -#define USBD_INTENSET_ENDEPOUT3_Pos (15UL) /*!< Position of ENDEPOUT3 field. */ -#define USBD_INTENSET_ENDEPOUT3_Msk (0x1UL << USBD_INTENSET_ENDEPOUT3_Pos) /*!< Bit mask of ENDEPOUT3 field. */ -#define USBD_INTENSET_ENDEPOUT3_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT3_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT3_Set (1UL) /*!< Enable */ - -/* Bit 14 : Write '1' to Enable interrupt for ENDEPOUT[2] event */ -#define USBD_INTENSET_ENDEPOUT2_Pos (14UL) /*!< Position of ENDEPOUT2 field. */ -#define USBD_INTENSET_ENDEPOUT2_Msk (0x1UL << USBD_INTENSET_ENDEPOUT2_Pos) /*!< Bit mask of ENDEPOUT2 field. */ -#define USBD_INTENSET_ENDEPOUT2_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT2_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT2_Set (1UL) /*!< Enable */ - -/* Bit 13 : Write '1' to Enable interrupt for ENDEPOUT[1] event */ -#define USBD_INTENSET_ENDEPOUT1_Pos (13UL) /*!< Position of ENDEPOUT1 field. */ -#define USBD_INTENSET_ENDEPOUT1_Msk (0x1UL << USBD_INTENSET_ENDEPOUT1_Pos) /*!< Bit mask of ENDEPOUT1 field. */ -#define USBD_INTENSET_ENDEPOUT1_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT1_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT1_Set (1UL) /*!< Enable */ - -/* Bit 12 : Write '1' to Enable interrupt for ENDEPOUT[0] event */ -#define USBD_INTENSET_ENDEPOUT0_Pos (12UL) /*!< Position of ENDEPOUT0 field. */ -#define USBD_INTENSET_ENDEPOUT0_Msk (0x1UL << USBD_INTENSET_ENDEPOUT0_Pos) /*!< Bit mask of ENDEPOUT0 field. */ -#define USBD_INTENSET_ENDEPOUT0_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPOUT0_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPOUT0_Set (1UL) /*!< Enable */ - -/* Bit 11 : Write '1' to Enable interrupt for ENDISOIN event */ -#define USBD_INTENSET_ENDISOIN_Pos (11UL) /*!< Position of ENDISOIN field. */ -#define USBD_INTENSET_ENDISOIN_Msk (0x1UL << USBD_INTENSET_ENDISOIN_Pos) /*!< Bit mask of ENDISOIN field. */ -#define USBD_INTENSET_ENDISOIN_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDISOIN_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDISOIN_Set (1UL) /*!< Enable */ - -/* Bit 10 : Write '1' to Enable interrupt for EP0DATADONE event */ -#define USBD_INTENSET_EP0DATADONE_Pos (10UL) /*!< Position of EP0DATADONE field. */ -#define USBD_INTENSET_EP0DATADONE_Msk (0x1UL << USBD_INTENSET_EP0DATADONE_Pos) /*!< Bit mask of EP0DATADONE field. */ -#define USBD_INTENSET_EP0DATADONE_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_EP0DATADONE_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_EP0DATADONE_Set (1UL) /*!< Enable */ - -/* Bit 9 : Write '1' to Enable interrupt for ENDEPIN[7] event */ -#define USBD_INTENSET_ENDEPIN7_Pos (9UL) /*!< Position of ENDEPIN7 field. */ -#define USBD_INTENSET_ENDEPIN7_Msk (0x1UL << USBD_INTENSET_ENDEPIN7_Pos) /*!< Bit mask of ENDEPIN7 field. */ -#define USBD_INTENSET_ENDEPIN7_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN7_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN7_Set (1UL) /*!< Enable */ - -/* Bit 8 : Write '1' to Enable interrupt for ENDEPIN[6] event */ -#define USBD_INTENSET_ENDEPIN6_Pos (8UL) /*!< Position of ENDEPIN6 field. */ -#define USBD_INTENSET_ENDEPIN6_Msk (0x1UL << USBD_INTENSET_ENDEPIN6_Pos) /*!< Bit mask of ENDEPIN6 field. */ -#define USBD_INTENSET_ENDEPIN6_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN6_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN6_Set (1UL) /*!< Enable */ - -/* Bit 7 : Write '1' to Enable interrupt for ENDEPIN[5] event */ -#define USBD_INTENSET_ENDEPIN5_Pos (7UL) /*!< Position of ENDEPIN5 field. */ -#define USBD_INTENSET_ENDEPIN5_Msk (0x1UL << USBD_INTENSET_ENDEPIN5_Pos) /*!< Bit mask of ENDEPIN5 field. */ -#define USBD_INTENSET_ENDEPIN5_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN5_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN5_Set (1UL) /*!< Enable */ - -/* Bit 6 : Write '1' to Enable interrupt for ENDEPIN[4] event */ -#define USBD_INTENSET_ENDEPIN4_Pos (6UL) /*!< Position of ENDEPIN4 field. */ -#define USBD_INTENSET_ENDEPIN4_Msk (0x1UL << USBD_INTENSET_ENDEPIN4_Pos) /*!< Bit mask of ENDEPIN4 field. */ -#define USBD_INTENSET_ENDEPIN4_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN4_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN4_Set (1UL) /*!< Enable */ - -/* Bit 5 : Write '1' to Enable interrupt for ENDEPIN[3] event */ -#define USBD_INTENSET_ENDEPIN3_Pos (5UL) /*!< Position of ENDEPIN3 field. */ -#define USBD_INTENSET_ENDEPIN3_Msk (0x1UL << USBD_INTENSET_ENDEPIN3_Pos) /*!< Bit mask of ENDEPIN3 field. */ -#define USBD_INTENSET_ENDEPIN3_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN3_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN3_Set (1UL) /*!< Enable */ - -/* Bit 4 : Write '1' to Enable interrupt for ENDEPIN[2] event */ -#define USBD_INTENSET_ENDEPIN2_Pos (4UL) /*!< Position of ENDEPIN2 field. */ -#define USBD_INTENSET_ENDEPIN2_Msk (0x1UL << USBD_INTENSET_ENDEPIN2_Pos) /*!< Bit mask of ENDEPIN2 field. */ -#define USBD_INTENSET_ENDEPIN2_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN2_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN2_Set (1UL) /*!< Enable */ - -/* Bit 3 : Write '1' to Enable interrupt for ENDEPIN[1] event */ -#define USBD_INTENSET_ENDEPIN1_Pos (3UL) /*!< Position of ENDEPIN1 field. */ -#define USBD_INTENSET_ENDEPIN1_Msk (0x1UL << USBD_INTENSET_ENDEPIN1_Pos) /*!< Bit mask of ENDEPIN1 field. */ -#define USBD_INTENSET_ENDEPIN1_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN1_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN1_Set (1UL) /*!< Enable */ - -/* Bit 2 : Write '1' to Enable interrupt for ENDEPIN[0] event */ -#define USBD_INTENSET_ENDEPIN0_Pos (2UL) /*!< Position of ENDEPIN0 field. */ -#define USBD_INTENSET_ENDEPIN0_Msk (0x1UL << USBD_INTENSET_ENDEPIN0_Pos) /*!< Bit mask of ENDEPIN0 field. */ -#define USBD_INTENSET_ENDEPIN0_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_ENDEPIN0_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_ENDEPIN0_Set (1UL) /*!< Enable */ - -/* Bit 1 : Write '1' to Enable interrupt for STARTED event */ -#define USBD_INTENSET_STARTED_Pos (1UL) /*!< Position of STARTED field. */ -#define USBD_INTENSET_STARTED_Msk (0x1UL << USBD_INTENSET_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define USBD_INTENSET_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_STARTED_Set (1UL) /*!< Enable */ - -/* Bit 0 : Write '1' to Enable interrupt for USBRESET event */ -#define USBD_INTENSET_USBRESET_Pos (0UL) /*!< Position of USBRESET field. */ -#define USBD_INTENSET_USBRESET_Msk (0x1UL << USBD_INTENSET_USBRESET_Pos) /*!< Bit mask of USBRESET field. */ -#define USBD_INTENSET_USBRESET_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENSET_USBRESET_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENSET_USBRESET_Set (1UL) /*!< Enable */ - -/* Register: USBD_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 25 : Write '1' to Disable interrupt for ACCESSFAULT event */ -#define USBD_INTENCLR_ACCESSFAULT_Pos (25UL) /*!< Position of ACCESSFAULT field. */ -#define USBD_INTENCLR_ACCESSFAULT_Msk (0x1UL << USBD_INTENCLR_ACCESSFAULT_Pos) /*!< Bit mask of ACCESSFAULT field. */ -#define USBD_INTENCLR_ACCESSFAULT_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ACCESSFAULT_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ACCESSFAULT_Clear (1UL) /*!< Disable */ - -/* Bit 24 : Write '1' to Disable interrupt for EPDATA event */ -#define USBD_INTENCLR_EPDATA_Pos (24UL) /*!< Position of EPDATA field. */ -#define USBD_INTENCLR_EPDATA_Msk (0x1UL << USBD_INTENCLR_EPDATA_Pos) /*!< Bit mask of EPDATA field. */ -#define USBD_INTENCLR_EPDATA_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_EPDATA_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_EPDATA_Clear (1UL) /*!< Disable */ - -/* Bit 23 : Write '1' to Disable interrupt for EP0SETUP event */ -#define USBD_INTENCLR_EP0SETUP_Pos (23UL) /*!< Position of EP0SETUP field. */ -#define USBD_INTENCLR_EP0SETUP_Msk (0x1UL << USBD_INTENCLR_EP0SETUP_Pos) /*!< Bit mask of EP0SETUP field. */ -#define USBD_INTENCLR_EP0SETUP_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_EP0SETUP_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_EP0SETUP_Clear (1UL) /*!< Disable */ - -/* Bit 22 : Write '1' to Disable interrupt for USBEVENT event */ -#define USBD_INTENCLR_USBEVENT_Pos (22UL) /*!< Position of USBEVENT field. */ -#define USBD_INTENCLR_USBEVENT_Msk (0x1UL << USBD_INTENCLR_USBEVENT_Pos) /*!< Bit mask of USBEVENT field. */ -#define USBD_INTENCLR_USBEVENT_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_USBEVENT_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_USBEVENT_Clear (1UL) /*!< Disable */ - -/* Bit 21 : Write '1' to Disable interrupt for SOF event */ -#define USBD_INTENCLR_SOF_Pos (21UL) /*!< Position of SOF field. */ -#define USBD_INTENCLR_SOF_Msk (0x1UL << USBD_INTENCLR_SOF_Pos) /*!< Bit mask of SOF field. */ -#define USBD_INTENCLR_SOF_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_SOF_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_SOF_Clear (1UL) /*!< Disable */ - -/* Bit 20 : Write '1' to Disable interrupt for ENDISOOUT event */ -#define USBD_INTENCLR_ENDISOOUT_Pos (20UL) /*!< Position of ENDISOOUT field. */ -#define USBD_INTENCLR_ENDISOOUT_Msk (0x1UL << USBD_INTENCLR_ENDISOOUT_Pos) /*!< Bit mask of ENDISOOUT field. */ -#define USBD_INTENCLR_ENDISOOUT_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDISOOUT_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDISOOUT_Clear (1UL) /*!< Disable */ - -/* Bit 19 : Write '1' to Disable interrupt for ENDEPOUT[7] event */ -#define USBD_INTENCLR_ENDEPOUT7_Pos (19UL) /*!< Position of ENDEPOUT7 field. */ -#define USBD_INTENCLR_ENDEPOUT7_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT7_Pos) /*!< Bit mask of ENDEPOUT7 field. */ -#define USBD_INTENCLR_ENDEPOUT7_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT7_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT7_Clear (1UL) /*!< Disable */ - -/* Bit 18 : Write '1' to Disable interrupt for ENDEPOUT[6] event */ -#define USBD_INTENCLR_ENDEPOUT6_Pos (18UL) /*!< Position of ENDEPOUT6 field. */ -#define USBD_INTENCLR_ENDEPOUT6_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT6_Pos) /*!< Bit mask of ENDEPOUT6 field. */ -#define USBD_INTENCLR_ENDEPOUT6_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT6_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT6_Clear (1UL) /*!< Disable */ - -/* Bit 17 : Write '1' to Disable interrupt for ENDEPOUT[5] event */ -#define USBD_INTENCLR_ENDEPOUT5_Pos (17UL) /*!< Position of ENDEPOUT5 field. */ -#define USBD_INTENCLR_ENDEPOUT5_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT5_Pos) /*!< Bit mask of ENDEPOUT5 field. */ -#define USBD_INTENCLR_ENDEPOUT5_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT5_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT5_Clear (1UL) /*!< Disable */ - -/* Bit 16 : Write '1' to Disable interrupt for ENDEPOUT[4] event */ -#define USBD_INTENCLR_ENDEPOUT4_Pos (16UL) /*!< Position of ENDEPOUT4 field. */ -#define USBD_INTENCLR_ENDEPOUT4_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT4_Pos) /*!< Bit mask of ENDEPOUT4 field. */ -#define USBD_INTENCLR_ENDEPOUT4_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT4_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT4_Clear (1UL) /*!< Disable */ - -/* Bit 15 : Write '1' to Disable interrupt for ENDEPOUT[3] event */ -#define USBD_INTENCLR_ENDEPOUT3_Pos (15UL) /*!< Position of ENDEPOUT3 field. */ -#define USBD_INTENCLR_ENDEPOUT3_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT3_Pos) /*!< Bit mask of ENDEPOUT3 field. */ -#define USBD_INTENCLR_ENDEPOUT3_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT3_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT3_Clear (1UL) /*!< Disable */ - -/* Bit 14 : Write '1' to Disable interrupt for ENDEPOUT[2] event */ -#define USBD_INTENCLR_ENDEPOUT2_Pos (14UL) /*!< Position of ENDEPOUT2 field. */ -#define USBD_INTENCLR_ENDEPOUT2_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT2_Pos) /*!< Bit mask of ENDEPOUT2 field. */ -#define USBD_INTENCLR_ENDEPOUT2_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT2_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT2_Clear (1UL) /*!< Disable */ - -/* Bit 13 : Write '1' to Disable interrupt for ENDEPOUT[1] event */ -#define USBD_INTENCLR_ENDEPOUT1_Pos (13UL) /*!< Position of ENDEPOUT1 field. */ -#define USBD_INTENCLR_ENDEPOUT1_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT1_Pos) /*!< Bit mask of ENDEPOUT1 field. */ -#define USBD_INTENCLR_ENDEPOUT1_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT1_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT1_Clear (1UL) /*!< Disable */ - -/* Bit 12 : Write '1' to Disable interrupt for ENDEPOUT[0] event */ -#define USBD_INTENCLR_ENDEPOUT0_Pos (12UL) /*!< Position of ENDEPOUT0 field. */ -#define USBD_INTENCLR_ENDEPOUT0_Msk (0x1UL << USBD_INTENCLR_ENDEPOUT0_Pos) /*!< Bit mask of ENDEPOUT0 field. */ -#define USBD_INTENCLR_ENDEPOUT0_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPOUT0_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPOUT0_Clear (1UL) /*!< Disable */ - -/* Bit 11 : Write '1' to Disable interrupt for ENDISOIN event */ -#define USBD_INTENCLR_ENDISOIN_Pos (11UL) /*!< Position of ENDISOIN field. */ -#define USBD_INTENCLR_ENDISOIN_Msk (0x1UL << USBD_INTENCLR_ENDISOIN_Pos) /*!< Bit mask of ENDISOIN field. */ -#define USBD_INTENCLR_ENDISOIN_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDISOIN_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDISOIN_Clear (1UL) /*!< Disable */ - -/* Bit 10 : Write '1' to Disable interrupt for EP0DATADONE event */ -#define USBD_INTENCLR_EP0DATADONE_Pos (10UL) /*!< Position of EP0DATADONE field. */ -#define USBD_INTENCLR_EP0DATADONE_Msk (0x1UL << USBD_INTENCLR_EP0DATADONE_Pos) /*!< Bit mask of EP0DATADONE field. */ -#define USBD_INTENCLR_EP0DATADONE_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_EP0DATADONE_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_EP0DATADONE_Clear (1UL) /*!< Disable */ - -/* Bit 9 : Write '1' to Disable interrupt for ENDEPIN[7] event */ -#define USBD_INTENCLR_ENDEPIN7_Pos (9UL) /*!< Position of ENDEPIN7 field. */ -#define USBD_INTENCLR_ENDEPIN7_Msk (0x1UL << USBD_INTENCLR_ENDEPIN7_Pos) /*!< Bit mask of ENDEPIN7 field. */ -#define USBD_INTENCLR_ENDEPIN7_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN7_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN7_Clear (1UL) /*!< Disable */ - -/* Bit 8 : Write '1' to Disable interrupt for ENDEPIN[6] event */ -#define USBD_INTENCLR_ENDEPIN6_Pos (8UL) /*!< Position of ENDEPIN6 field. */ -#define USBD_INTENCLR_ENDEPIN6_Msk (0x1UL << USBD_INTENCLR_ENDEPIN6_Pos) /*!< Bit mask of ENDEPIN6 field. */ -#define USBD_INTENCLR_ENDEPIN6_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN6_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN6_Clear (1UL) /*!< Disable */ - -/* Bit 7 : Write '1' to Disable interrupt for ENDEPIN[5] event */ -#define USBD_INTENCLR_ENDEPIN5_Pos (7UL) /*!< Position of ENDEPIN5 field. */ -#define USBD_INTENCLR_ENDEPIN5_Msk (0x1UL << USBD_INTENCLR_ENDEPIN5_Pos) /*!< Bit mask of ENDEPIN5 field. */ -#define USBD_INTENCLR_ENDEPIN5_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN5_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN5_Clear (1UL) /*!< Disable */ - -/* Bit 6 : Write '1' to Disable interrupt for ENDEPIN[4] event */ -#define USBD_INTENCLR_ENDEPIN4_Pos (6UL) /*!< Position of ENDEPIN4 field. */ -#define USBD_INTENCLR_ENDEPIN4_Msk (0x1UL << USBD_INTENCLR_ENDEPIN4_Pos) /*!< Bit mask of ENDEPIN4 field. */ -#define USBD_INTENCLR_ENDEPIN4_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN4_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN4_Clear (1UL) /*!< Disable */ - -/* Bit 5 : Write '1' to Disable interrupt for ENDEPIN[3] event */ -#define USBD_INTENCLR_ENDEPIN3_Pos (5UL) /*!< Position of ENDEPIN3 field. */ -#define USBD_INTENCLR_ENDEPIN3_Msk (0x1UL << USBD_INTENCLR_ENDEPIN3_Pos) /*!< Bit mask of ENDEPIN3 field. */ -#define USBD_INTENCLR_ENDEPIN3_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN3_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN3_Clear (1UL) /*!< Disable */ - -/* Bit 4 : Write '1' to Disable interrupt for ENDEPIN[2] event */ -#define USBD_INTENCLR_ENDEPIN2_Pos (4UL) /*!< Position of ENDEPIN2 field. */ -#define USBD_INTENCLR_ENDEPIN2_Msk (0x1UL << USBD_INTENCLR_ENDEPIN2_Pos) /*!< Bit mask of ENDEPIN2 field. */ -#define USBD_INTENCLR_ENDEPIN2_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN2_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN2_Clear (1UL) /*!< Disable */ - -/* Bit 3 : Write '1' to Disable interrupt for ENDEPIN[1] event */ -#define USBD_INTENCLR_ENDEPIN1_Pos (3UL) /*!< Position of ENDEPIN1 field. */ -#define USBD_INTENCLR_ENDEPIN1_Msk (0x1UL << USBD_INTENCLR_ENDEPIN1_Pos) /*!< Bit mask of ENDEPIN1 field. */ -#define USBD_INTENCLR_ENDEPIN1_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN1_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN1_Clear (1UL) /*!< Disable */ - -/* Bit 2 : Write '1' to Disable interrupt for ENDEPIN[0] event */ -#define USBD_INTENCLR_ENDEPIN0_Pos (2UL) /*!< Position of ENDEPIN0 field. */ -#define USBD_INTENCLR_ENDEPIN0_Msk (0x1UL << USBD_INTENCLR_ENDEPIN0_Pos) /*!< Bit mask of ENDEPIN0 field. */ -#define USBD_INTENCLR_ENDEPIN0_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_ENDEPIN0_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_ENDEPIN0_Clear (1UL) /*!< Disable */ - -/* Bit 1 : Write '1' to Disable interrupt for STARTED event */ -#define USBD_INTENCLR_STARTED_Pos (1UL) /*!< Position of STARTED field. */ -#define USBD_INTENCLR_STARTED_Msk (0x1UL << USBD_INTENCLR_STARTED_Pos) /*!< Bit mask of STARTED field. */ -#define USBD_INTENCLR_STARTED_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_STARTED_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_STARTED_Clear (1UL) /*!< Disable */ - -/* Bit 0 : Write '1' to Disable interrupt for USBRESET event */ -#define USBD_INTENCLR_USBRESET_Pos (0UL) /*!< Position of USBRESET field. */ -#define USBD_INTENCLR_USBRESET_Msk (0x1UL << USBD_INTENCLR_USBRESET_Pos) /*!< Bit mask of USBRESET field. */ -#define USBD_INTENCLR_USBRESET_Disabled (0UL) /*!< Read: Disabled */ -#define USBD_INTENCLR_USBRESET_Enabled (1UL) /*!< Read: Enabled */ -#define USBD_INTENCLR_USBRESET_Clear (1UL) /*!< Disable */ - -/* Register: USBD_EVENTCAUSE */ -/* Description: Details on event that caused the USBEVENT event */ - -/* Bit 11 : Wrapper has re-initialized SFRs to the proper values. MAC is ready for normal operation. Write '1' to clear. */ -#define USBD_EVENTCAUSE_READY_Pos (11UL) /*!< Position of READY field. */ -#define USBD_EVENTCAUSE_READY_Msk (0x1UL << USBD_EVENTCAUSE_READY_Pos) /*!< Bit mask of READY field. */ -#define USBD_EVENTCAUSE_READY_NotDetected (0UL) /*!< USBEVENT was not issued due to USBD peripheral ready */ -#define USBD_EVENTCAUSE_READY_Ready (1UL) /*!< USBD peripheral is ready */ - -/* Bit 9 : Signals that a RESUME condition (K state or activity restart) has been detected on the USB lines. Write '1' to clear. */ -#define USBD_EVENTCAUSE_RESUME_Pos (9UL) /*!< Position of RESUME field. */ -#define USBD_EVENTCAUSE_RESUME_Msk (0x1UL << USBD_EVENTCAUSE_RESUME_Pos) /*!< Bit mask of RESUME field. */ -#define USBD_EVENTCAUSE_RESUME_NotDetected (0UL) /*!< Resume not detected */ -#define USBD_EVENTCAUSE_RESUME_Detected (1UL) /*!< Resume detected */ - -/* Bit 8 : Signals that the USB lines have been seen idle long enough for the device to enter suspend. Write '1' to clear. */ -#define USBD_EVENTCAUSE_SUSPEND_Pos (8UL) /*!< Position of SUSPEND field. */ -#define USBD_EVENTCAUSE_SUSPEND_Msk (0x1UL << USBD_EVENTCAUSE_SUSPEND_Pos) /*!< Bit mask of SUSPEND field. */ -#define USBD_EVENTCAUSE_SUSPEND_NotDetected (0UL) /*!< Suspend not detected */ -#define USBD_EVENTCAUSE_SUSPEND_Detected (1UL) /*!< Suspend detected */ - -/* Bit 0 : CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear. */ -#define USBD_EVENTCAUSE_ISOOUTCRC_Pos (0UL) /*!< Position of ISOOUTCRC field. */ -#define USBD_EVENTCAUSE_ISOOUTCRC_Msk (0x1UL << USBD_EVENTCAUSE_ISOOUTCRC_Pos) /*!< Bit mask of ISOOUTCRC field. */ -#define USBD_EVENTCAUSE_ISOOUTCRC_NotDetected (0UL) /*!< No error detected */ -#define USBD_EVENTCAUSE_ISOOUTCRC_Detected (1UL) /*!< Error detected */ - -/* Register: USBD_BUSSTATE */ -/* Description: Provides the logic state of the D+ and D- lines */ - -/* Bit 1 : State of the D+ line */ -#define USBD_BUSSTATE_DP_Pos (1UL) /*!< Position of DP field. */ -#define USBD_BUSSTATE_DP_Msk (0x1UL << USBD_BUSSTATE_DP_Pos) /*!< Bit mask of DP field. */ -#define USBD_BUSSTATE_DP_Low (0UL) /*!< Low */ -#define USBD_BUSSTATE_DP_High (1UL) /*!< High */ - -/* Bit 0 : State of the D- line */ -#define USBD_BUSSTATE_DM_Pos (0UL) /*!< Position of DM field. */ -#define USBD_BUSSTATE_DM_Msk (0x1UL << USBD_BUSSTATE_DM_Pos) /*!< Bit mask of DM field. */ -#define USBD_BUSSTATE_DM_Low (0UL) /*!< Low */ -#define USBD_BUSSTATE_DM_High (1UL) /*!< High */ - -/* Register: USBD_HALTED_EPIN */ -/* Description: Description collection[0]: IN endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint. */ - -/* Bits 15..0 : IN endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint. */ -#define USBD_HALTED_EPIN_GETSTATUS_Pos (0UL) /*!< Position of GETSTATUS field. */ -#define USBD_HALTED_EPIN_GETSTATUS_Msk (0xFFFFUL << USBD_HALTED_EPIN_GETSTATUS_Pos) /*!< Bit mask of GETSTATUS field. */ -#define USBD_HALTED_EPIN_GETSTATUS_NotHalted (0UL) /*!< Endpoint is not halted */ -#define USBD_HALTED_EPIN_GETSTATUS_Halted (1UL) /*!< Endpoint is halted */ - -/* Register: USBD_HALTED_EPOUT */ -/* Description: Description collection[0]: OUT endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint. */ - -/* Bits 15..0 : OUT endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint. */ -#define USBD_HALTED_EPOUT_GETSTATUS_Pos (0UL) /*!< Position of GETSTATUS field. */ -#define USBD_HALTED_EPOUT_GETSTATUS_Msk (0xFFFFUL << USBD_HALTED_EPOUT_GETSTATUS_Pos) /*!< Bit mask of GETSTATUS field. */ -#define USBD_HALTED_EPOUT_GETSTATUS_NotHalted (0UL) /*!< Endpoint is not halted */ -#define USBD_HALTED_EPOUT_GETSTATUS_Halted (1UL) /*!< Endpoint is halted */ - -/* Register: USBD_EPSTATUS */ -/* Description: Provides information on which endpoint's EasyDMA registers have been captured */ - -/* Bit 24 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT8_Pos (24UL) /*!< Position of EPOUT8 field. */ -#define USBD_EPSTATUS_EPOUT8_Msk (0x1UL << USBD_EPSTATUS_EPOUT8_Pos) /*!< Bit mask of EPOUT8 field. */ -#define USBD_EPSTATUS_EPOUT8_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT8_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 23 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT7_Pos (23UL) /*!< Position of EPOUT7 field. */ -#define USBD_EPSTATUS_EPOUT7_Msk (0x1UL << USBD_EPSTATUS_EPOUT7_Pos) /*!< Bit mask of EPOUT7 field. */ -#define USBD_EPSTATUS_EPOUT7_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT7_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 22 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT6_Pos (22UL) /*!< Position of EPOUT6 field. */ -#define USBD_EPSTATUS_EPOUT6_Msk (0x1UL << USBD_EPSTATUS_EPOUT6_Pos) /*!< Bit mask of EPOUT6 field. */ -#define USBD_EPSTATUS_EPOUT6_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT6_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 21 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT5_Pos (21UL) /*!< Position of EPOUT5 field. */ -#define USBD_EPSTATUS_EPOUT5_Msk (0x1UL << USBD_EPSTATUS_EPOUT5_Pos) /*!< Bit mask of EPOUT5 field. */ -#define USBD_EPSTATUS_EPOUT5_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT5_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 20 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT4_Pos (20UL) /*!< Position of EPOUT4 field. */ -#define USBD_EPSTATUS_EPOUT4_Msk (0x1UL << USBD_EPSTATUS_EPOUT4_Pos) /*!< Bit mask of EPOUT4 field. */ -#define USBD_EPSTATUS_EPOUT4_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT4_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 19 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT3_Pos (19UL) /*!< Position of EPOUT3 field. */ -#define USBD_EPSTATUS_EPOUT3_Msk (0x1UL << USBD_EPSTATUS_EPOUT3_Pos) /*!< Bit mask of EPOUT3 field. */ -#define USBD_EPSTATUS_EPOUT3_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT3_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 18 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT2_Pos (18UL) /*!< Position of EPOUT2 field. */ -#define USBD_EPSTATUS_EPOUT2_Msk (0x1UL << USBD_EPSTATUS_EPOUT2_Pos) /*!< Bit mask of EPOUT2 field. */ -#define USBD_EPSTATUS_EPOUT2_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT2_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 17 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT1_Pos (17UL) /*!< Position of EPOUT1 field. */ -#define USBD_EPSTATUS_EPOUT1_Msk (0x1UL << USBD_EPSTATUS_EPOUT1_Pos) /*!< Bit mask of EPOUT1 field. */ -#define USBD_EPSTATUS_EPOUT1_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT1_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 16 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPOUT0_Pos (16UL) /*!< Position of EPOUT0 field. */ -#define USBD_EPSTATUS_EPOUT0_Msk (0x1UL << USBD_EPSTATUS_EPOUT0_Pos) /*!< Bit mask of EPOUT0 field. */ -#define USBD_EPSTATUS_EPOUT0_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPOUT0_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 8 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN8_Pos (8UL) /*!< Position of EPIN8 field. */ -#define USBD_EPSTATUS_EPIN8_Msk (0x1UL << USBD_EPSTATUS_EPIN8_Pos) /*!< Bit mask of EPIN8 field. */ -#define USBD_EPSTATUS_EPIN8_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN8_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 7 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN7_Pos (7UL) /*!< Position of EPIN7 field. */ -#define USBD_EPSTATUS_EPIN7_Msk (0x1UL << USBD_EPSTATUS_EPIN7_Pos) /*!< Bit mask of EPIN7 field. */ -#define USBD_EPSTATUS_EPIN7_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN7_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 6 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN6_Pos (6UL) /*!< Position of EPIN6 field. */ -#define USBD_EPSTATUS_EPIN6_Msk (0x1UL << USBD_EPSTATUS_EPIN6_Pos) /*!< Bit mask of EPIN6 field. */ -#define USBD_EPSTATUS_EPIN6_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN6_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 5 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN5_Pos (5UL) /*!< Position of EPIN5 field. */ -#define USBD_EPSTATUS_EPIN5_Msk (0x1UL << USBD_EPSTATUS_EPIN5_Pos) /*!< Bit mask of EPIN5 field. */ -#define USBD_EPSTATUS_EPIN5_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN5_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 4 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN4_Pos (4UL) /*!< Position of EPIN4 field. */ -#define USBD_EPSTATUS_EPIN4_Msk (0x1UL << USBD_EPSTATUS_EPIN4_Pos) /*!< Bit mask of EPIN4 field. */ -#define USBD_EPSTATUS_EPIN4_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN4_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 3 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN3_Pos (3UL) /*!< Position of EPIN3 field. */ -#define USBD_EPSTATUS_EPIN3_Msk (0x1UL << USBD_EPSTATUS_EPIN3_Pos) /*!< Bit mask of EPIN3 field. */ -#define USBD_EPSTATUS_EPIN3_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN3_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 2 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN2_Pos (2UL) /*!< Position of EPIN2 field. */ -#define USBD_EPSTATUS_EPIN2_Msk (0x1UL << USBD_EPSTATUS_EPIN2_Pos) /*!< Bit mask of EPIN2 field. */ -#define USBD_EPSTATUS_EPIN2_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN2_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 1 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN1_Pos (1UL) /*!< Position of EPIN1 field. */ -#define USBD_EPSTATUS_EPIN1_Msk (0x1UL << USBD_EPSTATUS_EPIN1_Pos) /*!< Bit mask of EPIN1 field. */ -#define USBD_EPSTATUS_EPIN1_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN1_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Bit 0 : Endpoint's EasyDMA registers captured state. Write '1' to clear. */ -#define USBD_EPSTATUS_EPIN0_Pos (0UL) /*!< Position of EPIN0 field. */ -#define USBD_EPSTATUS_EPIN0_Msk (0x1UL << USBD_EPSTATUS_EPIN0_Pos) /*!< Bit mask of EPIN0 field. */ -#define USBD_EPSTATUS_EPIN0_NoData (0UL) /*!< EasyDMA registers have not been captured for this endpoint */ -#define USBD_EPSTATUS_EPIN0_DataDone (1UL) /*!< EasyDMA registers have been captured for this endpoint */ - -/* Register: USBD_EPDATASTATUS */ -/* Description: Provides information on which endpoint(s) an acknowledged data transfer has occurred (EPDATA event) */ - -/* Bit 23 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT7_Pos (23UL) /*!< Position of EPOUT7 field. */ -#define USBD_EPDATASTATUS_EPOUT7_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT7_Pos) /*!< Bit mask of EPOUT7 field. */ -#define USBD_EPDATASTATUS_EPOUT7_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT7_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 22 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT6_Pos (22UL) /*!< Position of EPOUT6 field. */ -#define USBD_EPDATASTATUS_EPOUT6_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT6_Pos) /*!< Bit mask of EPOUT6 field. */ -#define USBD_EPDATASTATUS_EPOUT6_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT6_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 21 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT5_Pos (21UL) /*!< Position of EPOUT5 field. */ -#define USBD_EPDATASTATUS_EPOUT5_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT5_Pos) /*!< Bit mask of EPOUT5 field. */ -#define USBD_EPDATASTATUS_EPOUT5_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT5_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 20 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT4_Pos (20UL) /*!< Position of EPOUT4 field. */ -#define USBD_EPDATASTATUS_EPOUT4_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT4_Pos) /*!< Bit mask of EPOUT4 field. */ -#define USBD_EPDATASTATUS_EPOUT4_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT4_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 19 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT3_Pos (19UL) /*!< Position of EPOUT3 field. */ -#define USBD_EPDATASTATUS_EPOUT3_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT3_Pos) /*!< Bit mask of EPOUT3 field. */ -#define USBD_EPDATASTATUS_EPOUT3_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT3_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 18 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT2_Pos (18UL) /*!< Position of EPOUT2 field. */ -#define USBD_EPDATASTATUS_EPOUT2_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT2_Pos) /*!< Bit mask of EPOUT2 field. */ -#define USBD_EPDATASTATUS_EPOUT2_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT2_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 17 : Acknowledged data transfer on this OUT endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPOUT1_Pos (17UL) /*!< Position of EPOUT1 field. */ -#define USBD_EPDATASTATUS_EPOUT1_Msk (0x1UL << USBD_EPDATASTATUS_EPOUT1_Pos) /*!< Bit mask of EPOUT1 field. */ -#define USBD_EPDATASTATUS_EPOUT1_NotStarted (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPOUT1_Started (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 7 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN7_Pos (7UL) /*!< Position of EPIN7 field. */ -#define USBD_EPDATASTATUS_EPIN7_Msk (0x1UL << USBD_EPDATASTATUS_EPIN7_Pos) /*!< Bit mask of EPIN7 field. */ -#define USBD_EPDATASTATUS_EPIN7_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN7_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 6 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN6_Pos (6UL) /*!< Position of EPIN6 field. */ -#define USBD_EPDATASTATUS_EPIN6_Msk (0x1UL << USBD_EPDATASTATUS_EPIN6_Pos) /*!< Bit mask of EPIN6 field. */ -#define USBD_EPDATASTATUS_EPIN6_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN6_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 5 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN5_Pos (5UL) /*!< Position of EPIN5 field. */ -#define USBD_EPDATASTATUS_EPIN5_Msk (0x1UL << USBD_EPDATASTATUS_EPIN5_Pos) /*!< Bit mask of EPIN5 field. */ -#define USBD_EPDATASTATUS_EPIN5_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN5_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 4 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN4_Pos (4UL) /*!< Position of EPIN4 field. */ -#define USBD_EPDATASTATUS_EPIN4_Msk (0x1UL << USBD_EPDATASTATUS_EPIN4_Pos) /*!< Bit mask of EPIN4 field. */ -#define USBD_EPDATASTATUS_EPIN4_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN4_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 3 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN3_Pos (3UL) /*!< Position of EPIN3 field. */ -#define USBD_EPDATASTATUS_EPIN3_Msk (0x1UL << USBD_EPDATASTATUS_EPIN3_Pos) /*!< Bit mask of EPIN3 field. */ -#define USBD_EPDATASTATUS_EPIN3_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN3_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 2 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN2_Pos (2UL) /*!< Position of EPIN2 field. */ -#define USBD_EPDATASTATUS_EPIN2_Msk (0x1UL << USBD_EPDATASTATUS_EPIN2_Pos) /*!< Bit mask of EPIN2 field. */ -#define USBD_EPDATASTATUS_EPIN2_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN2_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Bit 1 : Acknowledged data transfer on this IN endpoint. Write '1' to clear. */ -#define USBD_EPDATASTATUS_EPIN1_Pos (1UL) /*!< Position of EPIN1 field. */ -#define USBD_EPDATASTATUS_EPIN1_Msk (0x1UL << USBD_EPDATASTATUS_EPIN1_Pos) /*!< Bit mask of EPIN1 field. */ -#define USBD_EPDATASTATUS_EPIN1_NotDone (0UL) /*!< No acknowledged data transfer on this endpoint */ -#define USBD_EPDATASTATUS_EPIN1_DataDone (1UL) /*!< Acknowledged data transfer on this endpoint has occurred */ - -/* Register: USBD_USBADDR */ -/* Description: Device USB address */ - -/* Bits 6..0 : Device USB address */ -#define USBD_USBADDR_ADDR_Pos (0UL) /*!< Position of ADDR field. */ -#define USBD_USBADDR_ADDR_Msk (0x7FUL << USBD_USBADDR_ADDR_Pos) /*!< Bit mask of ADDR field. */ - -/* Register: USBD_BMREQUESTTYPE */ -/* Description: SETUP data, byte 0, bmRequestType */ - -/* Bit 7 : Data transfer direction */ -#define USBD_BMREQUESTTYPE_DIRECTION_Pos (7UL) /*!< Position of DIRECTION field. */ -#define USBD_BMREQUESTTYPE_DIRECTION_Msk (0x1UL << USBD_BMREQUESTTYPE_DIRECTION_Pos) /*!< Bit mask of DIRECTION field. */ -#define USBD_BMREQUESTTYPE_DIRECTION_HostToDevice (0UL) /*!< Host-to-device */ -#define USBD_BMREQUESTTYPE_DIRECTION_DeviceToHost (1UL) /*!< Device-to-host */ - -/* Bits 6..5 : Data transfer type */ -#define USBD_BMREQUESTTYPE_TYPE_Pos (5UL) /*!< Position of TYPE field. */ -#define USBD_BMREQUESTTYPE_TYPE_Msk (0x3UL << USBD_BMREQUESTTYPE_TYPE_Pos) /*!< Bit mask of TYPE field. */ -#define USBD_BMREQUESTTYPE_TYPE_Standard (0UL) /*!< Standard */ -#define USBD_BMREQUESTTYPE_TYPE_Class (1UL) /*!< Class */ -#define USBD_BMREQUESTTYPE_TYPE_Vendor (2UL) /*!< Vendor */ - -/* Bits 4..0 : Data transfer type */ -#define USBD_BMREQUESTTYPE_RECIPIENT_Pos (0UL) /*!< Position of RECIPIENT field. */ -#define USBD_BMREQUESTTYPE_RECIPIENT_Msk (0x1FUL << USBD_BMREQUESTTYPE_RECIPIENT_Pos) /*!< Bit mask of RECIPIENT field. */ -#define USBD_BMREQUESTTYPE_RECIPIENT_Device (0UL) /*!< Device */ -#define USBD_BMREQUESTTYPE_RECIPIENT_Interface (1UL) /*!< Interface */ -#define USBD_BMREQUESTTYPE_RECIPIENT_Endpoint (2UL) /*!< Endpoint */ -#define USBD_BMREQUESTTYPE_RECIPIENT_Other (3UL) /*!< Other */ - -/* Register: USBD_BREQUEST */ -/* Description: SETUP data, byte 1, bRequest */ - -/* Bits 7..0 : SETUP data, byte 1, bRequest. Values provides for standard requests only, user must implement Class and Vendor values. */ -#define USBD_BREQUEST_BREQUEST_Pos (0UL) /*!< Position of BREQUEST field. */ -#define USBD_BREQUEST_BREQUEST_Msk (0xFFUL << USBD_BREQUEST_BREQUEST_Pos) /*!< Bit mask of BREQUEST field. */ -#define USBD_BREQUEST_BREQUEST_STD_GET_STATUS (0UL) /*!< Standard request GET_STATUS */ -#define USBD_BREQUEST_BREQUEST_STD_CLEAR_FEATURE (1UL) /*!< Standard request CLEAR_FEATURE */ -#define USBD_BREQUEST_BREQUEST_STD_SET_FEATURE (3UL) /*!< Standard request SET_FEATURE */ -#define USBD_BREQUEST_BREQUEST_STD_SET_ADDRESS (5UL) /*!< Standard request SET_ADDRESS */ -#define USBD_BREQUEST_BREQUEST_STD_GET_DESCRIPTOR (6UL) /*!< Standard request GET_DESCRIPTOR */ -#define USBD_BREQUEST_BREQUEST_STD_SET_DESCRIPTOR (7UL) /*!< Standard request SET_DESCRIPTOR */ -#define USBD_BREQUEST_BREQUEST_STD_GET_CONFIGURATION (8UL) /*!< Standard request GET_CONFIGURATION */ -#define USBD_BREQUEST_BREQUEST_STD_SET_CONFIGURATION (9UL) /*!< Standard request SET_CONFIGURATION */ -#define USBD_BREQUEST_BREQUEST_STD_GET_INTERFACE (10UL) /*!< Standard request GET_INTERFACE */ -#define USBD_BREQUEST_BREQUEST_STD_SET_INTERFACE (11UL) /*!< Standard request SET_INTERFACE */ -#define USBD_BREQUEST_BREQUEST_STD_SYNCH_FRAME (12UL) /*!< Standard request SYNCH_FRAME */ - -/* Register: USBD_WVALUEL */ -/* Description: SETUP data, byte 2, LSB of wValue */ - -/* Bits 7..0 : SETUP data, byte 2, LSB of wValue */ -#define USBD_WVALUEL_WVALUEL_Pos (0UL) /*!< Position of WVALUEL field. */ -#define USBD_WVALUEL_WVALUEL_Msk (0xFFUL << USBD_WVALUEL_WVALUEL_Pos) /*!< Bit mask of WVALUEL field. */ - -/* Register: USBD_WVALUEH */ -/* Description: SETUP data, byte 3, MSB of wValue */ - -/* Bits 7..0 : SETUP data, byte 3, MSB of wValue */ -#define USBD_WVALUEH_WVALUEH_Pos (0UL) /*!< Position of WVALUEH field. */ -#define USBD_WVALUEH_WVALUEH_Msk (0xFFUL << USBD_WVALUEH_WVALUEH_Pos) /*!< Bit mask of WVALUEH field. */ - -/* Register: USBD_WINDEXL */ -/* Description: SETUP data, byte 4, LSB of wIndex */ - -/* Bits 7..0 : SETUP data, byte 4, LSB of wIndex */ -#define USBD_WINDEXL_WINDEXL_Pos (0UL) /*!< Position of WINDEXL field. */ -#define USBD_WINDEXL_WINDEXL_Msk (0xFFUL << USBD_WINDEXL_WINDEXL_Pos) /*!< Bit mask of WINDEXL field. */ - -/* Register: USBD_WINDEXH */ -/* Description: SETUP data, byte 5, MSB of wIndex */ - -/* Bits 7..0 : SETUP data, byte 5, MSB of wIndex */ -#define USBD_WINDEXH_WINDEXH_Pos (0UL) /*!< Position of WINDEXH field. */ -#define USBD_WINDEXH_WINDEXH_Msk (0xFFUL << USBD_WINDEXH_WINDEXH_Pos) /*!< Bit mask of WINDEXH field. */ - -/* Register: USBD_WLENGTHL */ -/* Description: SETUP data, byte 6, LSB of wLength */ - -/* Bits 7..0 : SETUP data, byte 6, LSB of wLength */ -#define USBD_WLENGTHL_WLENGTHL_Pos (0UL) /*!< Position of WLENGTHL field. */ -#define USBD_WLENGTHL_WLENGTHL_Msk (0xFFUL << USBD_WLENGTHL_WLENGTHL_Pos) /*!< Bit mask of WLENGTHL field. */ - -/* Register: USBD_WLENGTHH */ -/* Description: SETUP data, byte 7, MSB of wLength */ - -/* Bits 7..0 : SETUP data, byte 7, MSB of wLength */ -#define USBD_WLENGTHH_WLENGTHH_Pos (0UL) /*!< Position of WLENGTHH field. */ -#define USBD_WLENGTHH_WLENGTHH_Msk (0xFFUL << USBD_WLENGTHH_WLENGTHH_Pos) /*!< Bit mask of WLENGTHH field. */ - -/* Register: USBD_SIZE_EPOUT */ -/* Description: Description collection[0]: Amount of bytes received last in the data stage of this OUT endpoint */ - -/* Bits 6..0 : Amount of bytes received last in the data stage of this OUT endpoint */ -#define USBD_SIZE_EPOUT_SIZE_Pos (0UL) /*!< Position of SIZE field. */ -#define USBD_SIZE_EPOUT_SIZE_Msk (0x7FUL << USBD_SIZE_EPOUT_SIZE_Pos) /*!< Bit mask of SIZE field. */ - -/* Register: USBD_SIZE_ISOOUT */ -/* Description: Amount of bytes received last on this iso OUT data endpoint */ - -/* Bit 16 : Zero-length data packet received */ -#define USBD_SIZE_ISOOUT_ZERO_Pos (16UL) /*!< Position of ZERO field. */ -#define USBD_SIZE_ISOOUT_ZERO_Msk (0x1UL << USBD_SIZE_ISOOUT_ZERO_Pos) /*!< Bit mask of ZERO field. */ -#define USBD_SIZE_ISOOUT_ZERO_Normal (0UL) /*!< No zero-length data received, use value in SIZE */ -#define USBD_SIZE_ISOOUT_ZERO_ZeroData (1UL) /*!< Zero-length data received, ignore value in SIZE */ - -/* Bits 9..0 : Amount of bytes received last on this iso OUT data endpoint */ -#define USBD_SIZE_ISOOUT_SIZE_Pos (0UL) /*!< Position of SIZE field. */ -#define USBD_SIZE_ISOOUT_SIZE_Msk (0x3FFUL << USBD_SIZE_ISOOUT_SIZE_Pos) /*!< Bit mask of SIZE field. */ - -/* Register: USBD_ENABLE */ -/* Description: Enable USB */ - -/* Bit 0 : Enable USB */ -#define USBD_ENABLE_ENABLE_Pos (0UL) /*!< Position of ENABLE field. */ -#define USBD_ENABLE_ENABLE_Msk (0x1UL << USBD_ENABLE_ENABLE_Pos) /*!< Bit mask of ENABLE field. */ -#define USBD_ENABLE_ENABLE_Disabled (0UL) /*!< USB peripheral is disabled */ -#define USBD_ENABLE_ENABLE_Enabled (1UL) /*!< USB peripheral is enabled */ - -/* Register: USBD_USBPULLUP */ -/* Description: Control of the USB pull-up */ - -/* Bit 0 : Control of the USB pull-up on the D+ line */ -#define USBD_USBPULLUP_CONNECT_Pos (0UL) /*!< Position of CONNECT field. */ -#define USBD_USBPULLUP_CONNECT_Msk (0x1UL << USBD_USBPULLUP_CONNECT_Pos) /*!< Bit mask of CONNECT field. */ -#define USBD_USBPULLUP_CONNECT_Disabled (0UL) /*!< Pull-up is disconnected */ -#define USBD_USBPULLUP_CONNECT_Enabled (1UL) /*!< Pull-up is connected to D+ */ - -/* Register: USBD_DPDMVALUE */ -/* Description: State at which the DPDMDRIVE task will force D+ and D-. The DPDMNODRIVE task reverts the control of the lines to MAC IP (no forcing). */ - -/* Bits 4..0 : State at which the DPDMDRIVE task will force D+ and D- */ -#define USBD_DPDMVALUE_STATE_Pos (0UL) /*!< Position of STATE field. */ -#define USBD_DPDMVALUE_STATE_Msk (0x1FUL << USBD_DPDMVALUE_STATE_Pos) /*!< Bit mask of STATE field. */ -#define USBD_DPDMVALUE_STATE_Resume (1UL) /*!< D+ forced low, D- forced high (K state) for a timing pre-set in hardware (50 us or 5 ms, depending on bus state) */ -#define USBD_DPDMVALUE_STATE_J (2UL) /*!< D+ forced high, D- forced low (J state) */ -#define USBD_DPDMVALUE_STATE_K (4UL) /*!< D+ forced low, D- forced high (K state) */ - -/* Register: USBD_DTOGGLE */ -/* Description: Data toggle control and status. */ - -/* Bits 9..8 : Data toggle value */ -#define USBD_DTOGGLE_VALUE_Pos (8UL) /*!< Position of VALUE field. */ -#define USBD_DTOGGLE_VALUE_Msk (0x3UL << USBD_DTOGGLE_VALUE_Pos) /*!< Bit mask of VALUE field. */ -#define USBD_DTOGGLE_VALUE_Nop (0UL) /*!< No action on data toggle when writing the register with this value */ -#define USBD_DTOGGLE_VALUE_Data0 (1UL) /*!< Data toggle is DATA0 on endpoint set by EP and IO */ -#define USBD_DTOGGLE_VALUE_Data1 (2UL) /*!< Data toggle is DATA1 on endpoint set by EP and IO */ - -/* Bit 7 : Selects IN or OUT endpoint */ -#define USBD_DTOGGLE_IO_Pos (7UL) /*!< Position of IO field. */ -#define USBD_DTOGGLE_IO_Msk (0x1UL << USBD_DTOGGLE_IO_Pos) /*!< Bit mask of IO field. */ -#define USBD_DTOGGLE_IO_Out (0UL) /*!< Selects OUT endpoint */ -#define USBD_DTOGGLE_IO_In (1UL) /*!< Selects IN endpoint */ - -/* Bits 2..0 : Select bulk endpoint number */ -#define USBD_DTOGGLE_EP_Pos (0UL) /*!< Position of EP field. */ -#define USBD_DTOGGLE_EP_Msk (0x7UL << USBD_DTOGGLE_EP_Pos) /*!< Bit mask of EP field. */ - -/* Register: USBD_EPINEN */ -/* Description: Endpoint IN enable */ - -/* Bit 8 : Enable iso IN endpoint */ -#define USBD_EPINEN_ISOIN_Pos (8UL) /*!< Position of ISOIN field. */ -#define USBD_EPINEN_ISOIN_Msk (0x1UL << USBD_EPINEN_ISOIN_Pos) /*!< Bit mask of ISOIN field. */ -#define USBD_EPINEN_ISOIN_Disable (0UL) /*!< Disable iso IN endpoint 8 */ -#define USBD_EPINEN_ISOIN_Enable (1UL) /*!< Enable iso IN endpoint 8 */ - -/* Bit 7 : Enable IN endpoint 7 */ -#define USBD_EPINEN_IN7_Pos (7UL) /*!< Position of IN7 field. */ -#define USBD_EPINEN_IN7_Msk (0x1UL << USBD_EPINEN_IN7_Pos) /*!< Bit mask of IN7 field. */ -#define USBD_EPINEN_IN7_Disable (0UL) /*!< Disable endpoint IN 7 (no response to IN tokens) */ -#define USBD_EPINEN_IN7_Enable (1UL) /*!< Enable endpoint IN 7 (response to IN tokens) */ - -/* Bit 6 : Enable IN endpoint 6 */ -#define USBD_EPINEN_IN6_Pos (6UL) /*!< Position of IN6 field. */ -#define USBD_EPINEN_IN6_Msk (0x1UL << USBD_EPINEN_IN6_Pos) /*!< Bit mask of IN6 field. */ -#define USBD_EPINEN_IN6_Disable (0UL) /*!< Disable endpoint IN 6 (no response to IN tokens) */ -#define USBD_EPINEN_IN6_Enable (1UL) /*!< Enable endpoint IN 6 (response to IN tokens) */ - -/* Bit 5 : Enable IN endpoint 5 */ -#define USBD_EPINEN_IN5_Pos (5UL) /*!< Position of IN5 field. */ -#define USBD_EPINEN_IN5_Msk (0x1UL << USBD_EPINEN_IN5_Pos) /*!< Bit mask of IN5 field. */ -#define USBD_EPINEN_IN5_Disable (0UL) /*!< Disable endpoint IN 5 (no response to IN tokens) */ -#define USBD_EPINEN_IN5_Enable (1UL) /*!< Enable endpoint IN 5 (response to IN tokens) */ - -/* Bit 4 : Enable IN endpoint 4 */ -#define USBD_EPINEN_IN4_Pos (4UL) /*!< Position of IN4 field. */ -#define USBD_EPINEN_IN4_Msk (0x1UL << USBD_EPINEN_IN4_Pos) /*!< Bit mask of IN4 field. */ -#define USBD_EPINEN_IN4_Disable (0UL) /*!< Disable endpoint IN 4 (no response to IN tokens) */ -#define USBD_EPINEN_IN4_Enable (1UL) /*!< Enable endpoint IN 4 (response to IN tokens) */ - -/* Bit 3 : Enable IN endpoint 3 */ -#define USBD_EPINEN_IN3_Pos (3UL) /*!< Position of IN3 field. */ -#define USBD_EPINEN_IN3_Msk (0x1UL << USBD_EPINEN_IN3_Pos) /*!< Bit mask of IN3 field. */ -#define USBD_EPINEN_IN3_Disable (0UL) /*!< Disable endpoint IN 3 (no response to IN tokens) */ -#define USBD_EPINEN_IN3_Enable (1UL) /*!< Enable endpoint IN 3 (response to IN tokens) */ - -/* Bit 2 : Enable IN endpoint 2 */ -#define USBD_EPINEN_IN2_Pos (2UL) /*!< Position of IN2 field. */ -#define USBD_EPINEN_IN2_Msk (0x1UL << USBD_EPINEN_IN2_Pos) /*!< Bit mask of IN2 field. */ -#define USBD_EPINEN_IN2_Disable (0UL) /*!< Disable endpoint IN 2 (no response to IN tokens) */ -#define USBD_EPINEN_IN2_Enable (1UL) /*!< Enable endpoint IN 2 (response to IN tokens) */ - -/* Bit 1 : Enable IN endpoint 1 */ -#define USBD_EPINEN_IN1_Pos (1UL) /*!< Position of IN1 field. */ -#define USBD_EPINEN_IN1_Msk (0x1UL << USBD_EPINEN_IN1_Pos) /*!< Bit mask of IN1 field. */ -#define USBD_EPINEN_IN1_Disable (0UL) /*!< Disable endpoint IN 1 (no response to IN tokens) */ -#define USBD_EPINEN_IN1_Enable (1UL) /*!< Enable endpoint IN 1 (response to IN tokens) */ - -/* Bit 0 : Enable IN endpoint 0 */ -#define USBD_EPINEN_IN0_Pos (0UL) /*!< Position of IN0 field. */ -#define USBD_EPINEN_IN0_Msk (0x1UL << USBD_EPINEN_IN0_Pos) /*!< Bit mask of IN0 field. */ -#define USBD_EPINEN_IN0_Disable (0UL) /*!< Disable endpoint IN 0 (no response to IN tokens) */ -#define USBD_EPINEN_IN0_Enable (1UL) /*!< Enable endpoint IN 0 (response to IN tokens) */ - -/* Register: USBD_EPOUTEN */ -/* Description: Endpoint OUT enable */ - -/* Bit 8 : Enable iso OUT endpoint 8 */ -#define USBD_EPOUTEN_ISOOUT_Pos (8UL) /*!< Position of ISOOUT field. */ -#define USBD_EPOUTEN_ISOOUT_Msk (0x1UL << USBD_EPOUTEN_ISOOUT_Pos) /*!< Bit mask of ISOOUT field. */ -#define USBD_EPOUTEN_ISOOUT_Disable (0UL) /*!< Disable iso OUT endpoint 8 */ -#define USBD_EPOUTEN_ISOOUT_Enable (1UL) /*!< Enable iso OUT endpoint 8 */ - -/* Bit 7 : Enable OUT endpoint 7 */ -#define USBD_EPOUTEN_OUT7_Pos (7UL) /*!< Position of OUT7 field. */ -#define USBD_EPOUTEN_OUT7_Msk (0x1UL << USBD_EPOUTEN_OUT7_Pos) /*!< Bit mask of OUT7 field. */ -#define USBD_EPOUTEN_OUT7_Disable (0UL) /*!< Disable endpoint OUT 7 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT7_Enable (1UL) /*!< Enable endpoint OUT 7 (response to OUT tokens) */ - -/* Bit 6 : Enable OUT endpoint 6 */ -#define USBD_EPOUTEN_OUT6_Pos (6UL) /*!< Position of OUT6 field. */ -#define USBD_EPOUTEN_OUT6_Msk (0x1UL << USBD_EPOUTEN_OUT6_Pos) /*!< Bit mask of OUT6 field. */ -#define USBD_EPOUTEN_OUT6_Disable (0UL) /*!< Disable endpoint OUT 6 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT6_Enable (1UL) /*!< Enable endpoint OUT 6 (response to OUT tokens) */ - -/* Bit 5 : Enable OUT endpoint 5 */ -#define USBD_EPOUTEN_OUT5_Pos (5UL) /*!< Position of OUT5 field. */ -#define USBD_EPOUTEN_OUT5_Msk (0x1UL << USBD_EPOUTEN_OUT5_Pos) /*!< Bit mask of OUT5 field. */ -#define USBD_EPOUTEN_OUT5_Disable (0UL) /*!< Disable endpoint OUT 5 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT5_Enable (1UL) /*!< Enable endpoint OUT 5 (response to OUT tokens) */ - -/* Bit 4 : Enable OUT endpoint 4 */ -#define USBD_EPOUTEN_OUT4_Pos (4UL) /*!< Position of OUT4 field. */ -#define USBD_EPOUTEN_OUT4_Msk (0x1UL << USBD_EPOUTEN_OUT4_Pos) /*!< Bit mask of OUT4 field. */ -#define USBD_EPOUTEN_OUT4_Disable (0UL) /*!< Disable endpoint OUT 4 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT4_Enable (1UL) /*!< Enable endpoint OUT 4 (response to OUT tokens) */ - -/* Bit 3 : Enable OUT endpoint 3 */ -#define USBD_EPOUTEN_OUT3_Pos (3UL) /*!< Position of OUT3 field. */ -#define USBD_EPOUTEN_OUT3_Msk (0x1UL << USBD_EPOUTEN_OUT3_Pos) /*!< Bit mask of OUT3 field. */ -#define USBD_EPOUTEN_OUT3_Disable (0UL) /*!< Disable endpoint OUT 3 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT3_Enable (1UL) /*!< Enable endpoint OUT 3 (response to OUT tokens) */ - -/* Bit 2 : Enable OUT endpoint 2 */ -#define USBD_EPOUTEN_OUT2_Pos (2UL) /*!< Position of OUT2 field. */ -#define USBD_EPOUTEN_OUT2_Msk (0x1UL << USBD_EPOUTEN_OUT2_Pos) /*!< Bit mask of OUT2 field. */ -#define USBD_EPOUTEN_OUT2_Disable (0UL) /*!< Disable endpoint OUT 2 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT2_Enable (1UL) /*!< Enable endpoint OUT 2 (response to OUT tokens) */ - -/* Bit 1 : Enable OUT endpoint 1 */ -#define USBD_EPOUTEN_OUT1_Pos (1UL) /*!< Position of OUT1 field. */ -#define USBD_EPOUTEN_OUT1_Msk (0x1UL << USBD_EPOUTEN_OUT1_Pos) /*!< Bit mask of OUT1 field. */ -#define USBD_EPOUTEN_OUT1_Disable (0UL) /*!< Disable endpoint OUT 1 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT1_Enable (1UL) /*!< Enable endpoint OUT 1 (response to OUT tokens) */ - -/* Bit 0 : Enable OUT endpoint 0 */ -#define USBD_EPOUTEN_OUT0_Pos (0UL) /*!< Position of OUT0 field. */ -#define USBD_EPOUTEN_OUT0_Msk (0x1UL << USBD_EPOUTEN_OUT0_Pos) /*!< Bit mask of OUT0 field. */ -#define USBD_EPOUTEN_OUT0_Disable (0UL) /*!< Disable endpoint OUT 0 (no response to OUT tokens) */ -#define USBD_EPOUTEN_OUT0_Enable (1UL) /*!< Enable endpoint OUT 0 (response to OUT tokens) */ - -/* Register: USBD_EPSTALL */ -/* Description: STALL endpoints */ - -/* Bit 8 : Stall selected endpoint */ -#define USBD_EPSTALL_STALL_Pos (8UL) /*!< Position of STALL field. */ -#define USBD_EPSTALL_STALL_Msk (0x1UL << USBD_EPSTALL_STALL_Pos) /*!< Bit mask of STALL field. */ -#define USBD_EPSTALL_STALL_UnStall (0UL) /*!< Don't stall selected endpoint */ -#define USBD_EPSTALL_STALL_Stall (1UL) /*!< Stall selected endpoint */ - -/* Bit 7 : Selects IN or OUT endpoint */ -#define USBD_EPSTALL_IO_Pos (7UL) /*!< Position of IO field. */ -#define USBD_EPSTALL_IO_Msk (0x1UL << USBD_EPSTALL_IO_Pos) /*!< Bit mask of IO field. */ -#define USBD_EPSTALL_IO_Out (0UL) /*!< Selects OUT endpoint */ -#define USBD_EPSTALL_IO_In (1UL) /*!< Selects IN endpoint */ - -/* Bits 2..0 : Select endpoint number */ -#define USBD_EPSTALL_EP_Pos (0UL) /*!< Position of EP field. */ -#define USBD_EPSTALL_EP_Msk (0x7UL << USBD_EPSTALL_EP_Pos) /*!< Bit mask of EP field. */ - -/* Register: USBD_ISOSPLIT */ -/* Description: Controls the split of ISO buffers */ - -/* Bits 15..0 : Controls the split of ISO buffers */ -#define USBD_ISOSPLIT_SPLIT_Pos (0UL) /*!< Position of SPLIT field. */ -#define USBD_ISOSPLIT_SPLIT_Msk (0xFFFFUL << USBD_ISOSPLIT_SPLIT_Pos) /*!< Bit mask of SPLIT field. */ -#define USBD_ISOSPLIT_SPLIT_OneDir (0x0000UL) /*!< Full buffer dedicated to either iso IN or OUT */ -#define USBD_ISOSPLIT_SPLIT_HalfIN (0x0080UL) /*!< Lower half for IN, upper half for OUT */ - -/* Register: USBD_FRAMECNTR */ -/* Description: Returns the current value of the start of frame counter */ - -/* Bits 10..0 : Returns the current value of the start of frame counter */ -#define USBD_FRAMECNTR_FRAMECNTR_Pos (0UL) /*!< Position of FRAMECNTR field. */ -#define USBD_FRAMECNTR_FRAMECNTR_Msk (0x7FFUL << USBD_FRAMECNTR_FRAMECNTR_Pos) /*!< Bit mask of FRAMECNTR field. */ - -/* Register: USBD_LOWPOWER */ -/* Description: Controls USBD peripheral low-power mode during USB suspend */ - -/* Bit 0 : Controls USBD peripheral low-power mode during USB suspend */ -#define USBD_LOWPOWER_LOWPOWER_Pos (0UL) /*!< Position of LOWPOWER field. */ -#define USBD_LOWPOWER_LOWPOWER_Msk (0x1UL << USBD_LOWPOWER_LOWPOWER_Pos) /*!< Bit mask of LOWPOWER field. */ -#define USBD_LOWPOWER_LOWPOWER_ForceNormal (0UL) /*!< Software must write this value to exit low power mode and before performing a remote wake-up */ -#define USBD_LOWPOWER_LOWPOWER_LowPower (1UL) /*!< Software must write this value to enter low power mode after DMA and software have finished interacting with the USB peripheral */ - -/* Register: USBD_ISOINCONFIG */ -/* Description: Controls the response of the ISO IN endpoint to an IN token when no data is ready to be sent */ - -/* Bit 0 : Controls the response of the ISO IN endpoint to an IN token when no data is ready to be sent */ -#define USBD_ISOINCONFIG_RESPONSE_Pos (0UL) /*!< Position of RESPONSE field. */ -#define USBD_ISOINCONFIG_RESPONSE_Msk (0x1UL << USBD_ISOINCONFIG_RESPONSE_Pos) /*!< Bit mask of RESPONSE field. */ -#define USBD_ISOINCONFIG_RESPONSE_NoResp (0UL) /*!< Endpoint does not respond in that case */ -#define USBD_ISOINCONFIG_RESPONSE_ZeroData (1UL) /*!< Endpoint responds with a zero-length data packet in that case */ - -/* Register: USBD_EPIN_PTR */ -/* Description: Description cluster[0]: Data pointer */ - -/* Bits 31..0 : Data pointer. Accepts any address in Data RAM. */ -#define USBD_EPIN_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define USBD_EPIN_PTR_PTR_Msk (0xFFFFFFFFUL << USBD_EPIN_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: USBD_EPIN_MAXCNT */ -/* Description: Description cluster[0]: Maximum number of bytes to transfer */ - -/* Bits 6..0 : Maximum number of bytes to transfer */ -#define USBD_EPIN_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define USBD_EPIN_MAXCNT_MAXCNT_Msk (0x7FUL << USBD_EPIN_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: USBD_EPIN_AMOUNT */ -/* Description: Description cluster[0]: Number of bytes transferred in the last transaction */ - -/* Bits 6..0 : Number of bytes transferred in the last transaction */ -#define USBD_EPIN_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define USBD_EPIN_AMOUNT_AMOUNT_Msk (0x7FUL << USBD_EPIN_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: USBD_ISOIN_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer. Accepts any address in Data RAM. */ -#define USBD_ISOIN_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define USBD_ISOIN_PTR_PTR_Msk (0xFFFFFFFFUL << USBD_ISOIN_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: USBD_ISOIN_MAXCNT */ -/* Description: Maximum number of bytes to transfer */ - -/* Bits 9..0 : Maximum number of bytes to transfer */ -#define USBD_ISOIN_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define USBD_ISOIN_MAXCNT_MAXCNT_Msk (0x3FFUL << USBD_ISOIN_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: USBD_ISOIN_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last transaction */ -#define USBD_ISOIN_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define USBD_ISOIN_AMOUNT_AMOUNT_Msk (0x3FFUL << USBD_ISOIN_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: USBD_EPOUT_PTR */ -/* Description: Description cluster[0]: Data pointer */ - -/* Bits 31..0 : Data pointer. Accepts any address in Data RAM. */ -#define USBD_EPOUT_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define USBD_EPOUT_PTR_PTR_Msk (0xFFFFFFFFUL << USBD_EPOUT_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: USBD_EPOUT_MAXCNT */ -/* Description: Description cluster[0]: Maximum number of bytes to transfer */ - -/* Bits 6..0 : Maximum number of bytes to transfer */ -#define USBD_EPOUT_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define USBD_EPOUT_MAXCNT_MAXCNT_Msk (0x7FUL << USBD_EPOUT_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: USBD_EPOUT_AMOUNT */ -/* Description: Description cluster[0]: Number of bytes transferred in the last transaction */ - -/* Bits 6..0 : Number of bytes transferred in the last transaction */ -#define USBD_EPOUT_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define USBD_EPOUT_AMOUNT_AMOUNT_Msk (0x7FUL << USBD_EPOUT_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - -/* Register: USBD_ISOOUT_PTR */ -/* Description: Data pointer */ - -/* Bits 31..0 : Data pointer. Accepts any address in Data RAM. */ -#define USBD_ISOOUT_PTR_PTR_Pos (0UL) /*!< Position of PTR field. */ -#define USBD_ISOOUT_PTR_PTR_Msk (0xFFFFFFFFUL << USBD_ISOOUT_PTR_PTR_Pos) /*!< Bit mask of PTR field. */ - -/* Register: USBD_ISOOUT_MAXCNT */ -/* Description: Maximum number of bytes to transfer */ - -/* Bits 9..0 : Maximum number of bytes to transfer */ -#define USBD_ISOOUT_MAXCNT_MAXCNT_Pos (0UL) /*!< Position of MAXCNT field. */ -#define USBD_ISOOUT_MAXCNT_MAXCNT_Msk (0x3FFUL << USBD_ISOOUT_MAXCNT_MAXCNT_Pos) /*!< Bit mask of MAXCNT field. */ - -/* Register: USBD_ISOOUT_AMOUNT */ -/* Description: Number of bytes transferred in the last transaction */ - -/* Bits 9..0 : Number of bytes transferred in the last transaction */ -#define USBD_ISOOUT_AMOUNT_AMOUNT_Pos (0UL) /*!< Position of AMOUNT field. */ -#define USBD_ISOOUT_AMOUNT_AMOUNT_Msk (0x3FFUL << USBD_ISOOUT_AMOUNT_AMOUNT_Pos) /*!< Bit mask of AMOUNT field. */ - - -/* Peripheral: WDT */ -/* Description: Watchdog Timer */ - -/* Register: WDT_INTENSET */ -/* Description: Enable interrupt */ - -/* Bit 0 : Write '1' to Enable interrupt for TIMEOUT event */ -#define WDT_INTENSET_TIMEOUT_Pos (0UL) /*!< Position of TIMEOUT field. */ -#define WDT_INTENSET_TIMEOUT_Msk (0x1UL << WDT_INTENSET_TIMEOUT_Pos) /*!< Bit mask of TIMEOUT field. */ -#define WDT_INTENSET_TIMEOUT_Disabled (0UL) /*!< Read: Disabled */ -#define WDT_INTENSET_TIMEOUT_Enabled (1UL) /*!< Read: Enabled */ -#define WDT_INTENSET_TIMEOUT_Set (1UL) /*!< Enable */ - -/* Register: WDT_INTENCLR */ -/* Description: Disable interrupt */ - -/* Bit 0 : Write '1' to Disable interrupt for TIMEOUT event */ -#define WDT_INTENCLR_TIMEOUT_Pos (0UL) /*!< Position of TIMEOUT field. */ -#define WDT_INTENCLR_TIMEOUT_Msk (0x1UL << WDT_INTENCLR_TIMEOUT_Pos) /*!< Bit mask of TIMEOUT field. */ -#define WDT_INTENCLR_TIMEOUT_Disabled (0UL) /*!< Read: Disabled */ -#define WDT_INTENCLR_TIMEOUT_Enabled (1UL) /*!< Read: Enabled */ -#define WDT_INTENCLR_TIMEOUT_Clear (1UL) /*!< Disable */ - -/* Register: WDT_RUNSTATUS */ -/* Description: Run status */ - -/* Bit 0 : Indicates whether or not the watchdog is running */ -#define WDT_RUNSTATUS_RUNSTATUS_Pos (0UL) /*!< Position of RUNSTATUS field. */ -#define WDT_RUNSTATUS_RUNSTATUS_Msk (0x1UL << WDT_RUNSTATUS_RUNSTATUS_Pos) /*!< Bit mask of RUNSTATUS field. */ -#define WDT_RUNSTATUS_RUNSTATUS_NotRunning (0UL) /*!< Watchdog not running */ -#define WDT_RUNSTATUS_RUNSTATUS_Running (1UL) /*!< Watchdog is running */ - -/* Register: WDT_REQSTATUS */ -/* Description: Request status */ - -/* Bit 7 : Request status for RR[7] register */ -#define WDT_REQSTATUS_RR7_Pos (7UL) /*!< Position of RR7 field. */ -#define WDT_REQSTATUS_RR7_Msk (0x1UL << WDT_REQSTATUS_RR7_Pos) /*!< Bit mask of RR7 field. */ -#define WDT_REQSTATUS_RR7_DisabledOrRequested (0UL) /*!< RR[7] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR7_EnabledAndUnrequested (1UL) /*!< RR[7] register is enabled, and are not yet requesting reload */ - -/* Bit 6 : Request status for RR[6] register */ -#define WDT_REQSTATUS_RR6_Pos (6UL) /*!< Position of RR6 field. */ -#define WDT_REQSTATUS_RR6_Msk (0x1UL << WDT_REQSTATUS_RR6_Pos) /*!< Bit mask of RR6 field. */ -#define WDT_REQSTATUS_RR6_DisabledOrRequested (0UL) /*!< RR[6] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR6_EnabledAndUnrequested (1UL) /*!< RR[6] register is enabled, and are not yet requesting reload */ - -/* Bit 5 : Request status for RR[5] register */ -#define WDT_REQSTATUS_RR5_Pos (5UL) /*!< Position of RR5 field. */ -#define WDT_REQSTATUS_RR5_Msk (0x1UL << WDT_REQSTATUS_RR5_Pos) /*!< Bit mask of RR5 field. */ -#define WDT_REQSTATUS_RR5_DisabledOrRequested (0UL) /*!< RR[5] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR5_EnabledAndUnrequested (1UL) /*!< RR[5] register is enabled, and are not yet requesting reload */ - -/* Bit 4 : Request status for RR[4] register */ -#define WDT_REQSTATUS_RR4_Pos (4UL) /*!< Position of RR4 field. */ -#define WDT_REQSTATUS_RR4_Msk (0x1UL << WDT_REQSTATUS_RR4_Pos) /*!< Bit mask of RR4 field. */ -#define WDT_REQSTATUS_RR4_DisabledOrRequested (0UL) /*!< RR[4] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR4_EnabledAndUnrequested (1UL) /*!< RR[4] register is enabled, and are not yet requesting reload */ - -/* Bit 3 : Request status for RR[3] register */ -#define WDT_REQSTATUS_RR3_Pos (3UL) /*!< Position of RR3 field. */ -#define WDT_REQSTATUS_RR3_Msk (0x1UL << WDT_REQSTATUS_RR3_Pos) /*!< Bit mask of RR3 field. */ -#define WDT_REQSTATUS_RR3_DisabledOrRequested (0UL) /*!< RR[3] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR3_EnabledAndUnrequested (1UL) /*!< RR[3] register is enabled, and are not yet requesting reload */ - -/* Bit 2 : Request status for RR[2] register */ -#define WDT_REQSTATUS_RR2_Pos (2UL) /*!< Position of RR2 field. */ -#define WDT_REQSTATUS_RR2_Msk (0x1UL << WDT_REQSTATUS_RR2_Pos) /*!< Bit mask of RR2 field. */ -#define WDT_REQSTATUS_RR2_DisabledOrRequested (0UL) /*!< RR[2] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR2_EnabledAndUnrequested (1UL) /*!< RR[2] register is enabled, and are not yet requesting reload */ - -/* Bit 1 : Request status for RR[1] register */ -#define WDT_REQSTATUS_RR1_Pos (1UL) /*!< Position of RR1 field. */ -#define WDT_REQSTATUS_RR1_Msk (0x1UL << WDT_REQSTATUS_RR1_Pos) /*!< Bit mask of RR1 field. */ -#define WDT_REQSTATUS_RR1_DisabledOrRequested (0UL) /*!< RR[1] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR1_EnabledAndUnrequested (1UL) /*!< RR[1] register is enabled, and are not yet requesting reload */ - -/* Bit 0 : Request status for RR[0] register */ -#define WDT_REQSTATUS_RR0_Pos (0UL) /*!< Position of RR0 field. */ -#define WDT_REQSTATUS_RR0_Msk (0x1UL << WDT_REQSTATUS_RR0_Pos) /*!< Bit mask of RR0 field. */ -#define WDT_REQSTATUS_RR0_DisabledOrRequested (0UL) /*!< RR[0] register is not enabled, or are already requesting reload */ -#define WDT_REQSTATUS_RR0_EnabledAndUnrequested (1UL) /*!< RR[0] register is enabled, and are not yet requesting reload */ - -/* Register: WDT_CRV */ -/* Description: Counter reload value */ - -/* Bits 31..0 : Counter reload value in number of cycles of the 32.768 kHz clock */ -#define WDT_CRV_CRV_Pos (0UL) /*!< Position of CRV field. */ -#define WDT_CRV_CRV_Msk (0xFFFFFFFFUL << WDT_CRV_CRV_Pos) /*!< Bit mask of CRV field. */ - -/* Register: WDT_RREN */ -/* Description: Enable register for reload request registers */ - -/* Bit 7 : Enable or disable RR[7] register */ -#define WDT_RREN_RR7_Pos (7UL) /*!< Position of RR7 field. */ -#define WDT_RREN_RR7_Msk (0x1UL << WDT_RREN_RR7_Pos) /*!< Bit mask of RR7 field. */ -#define WDT_RREN_RR7_Disabled (0UL) /*!< Disable RR[7] register */ -#define WDT_RREN_RR7_Enabled (1UL) /*!< Enable RR[7] register */ - -/* Bit 6 : Enable or disable RR[6] register */ -#define WDT_RREN_RR6_Pos (6UL) /*!< Position of RR6 field. */ -#define WDT_RREN_RR6_Msk (0x1UL << WDT_RREN_RR6_Pos) /*!< Bit mask of RR6 field. */ -#define WDT_RREN_RR6_Disabled (0UL) /*!< Disable RR[6] register */ -#define WDT_RREN_RR6_Enabled (1UL) /*!< Enable RR[6] register */ - -/* Bit 5 : Enable or disable RR[5] register */ -#define WDT_RREN_RR5_Pos (5UL) /*!< Position of RR5 field. */ -#define WDT_RREN_RR5_Msk (0x1UL << WDT_RREN_RR5_Pos) /*!< Bit mask of RR5 field. */ -#define WDT_RREN_RR5_Disabled (0UL) /*!< Disable RR[5] register */ -#define WDT_RREN_RR5_Enabled (1UL) /*!< Enable RR[5] register */ - -/* Bit 4 : Enable or disable RR[4] register */ -#define WDT_RREN_RR4_Pos (4UL) /*!< Position of RR4 field. */ -#define WDT_RREN_RR4_Msk (0x1UL << WDT_RREN_RR4_Pos) /*!< Bit mask of RR4 field. */ -#define WDT_RREN_RR4_Disabled (0UL) /*!< Disable RR[4] register */ -#define WDT_RREN_RR4_Enabled (1UL) /*!< Enable RR[4] register */ - -/* Bit 3 : Enable or disable RR[3] register */ -#define WDT_RREN_RR3_Pos (3UL) /*!< Position of RR3 field. */ -#define WDT_RREN_RR3_Msk (0x1UL << WDT_RREN_RR3_Pos) /*!< Bit mask of RR3 field. */ -#define WDT_RREN_RR3_Disabled (0UL) /*!< Disable RR[3] register */ -#define WDT_RREN_RR3_Enabled (1UL) /*!< Enable RR[3] register */ - -/* Bit 2 : Enable or disable RR[2] register */ -#define WDT_RREN_RR2_Pos (2UL) /*!< Position of RR2 field. */ -#define WDT_RREN_RR2_Msk (0x1UL << WDT_RREN_RR2_Pos) /*!< Bit mask of RR2 field. */ -#define WDT_RREN_RR2_Disabled (0UL) /*!< Disable RR[2] register */ -#define WDT_RREN_RR2_Enabled (1UL) /*!< Enable RR[2] register */ - -/* Bit 1 : Enable or disable RR[1] register */ -#define WDT_RREN_RR1_Pos (1UL) /*!< Position of RR1 field. */ -#define WDT_RREN_RR1_Msk (0x1UL << WDT_RREN_RR1_Pos) /*!< Bit mask of RR1 field. */ -#define WDT_RREN_RR1_Disabled (0UL) /*!< Disable RR[1] register */ -#define WDT_RREN_RR1_Enabled (1UL) /*!< Enable RR[1] register */ - -/* Bit 0 : Enable or disable RR[0] register */ -#define WDT_RREN_RR0_Pos (0UL) /*!< Position of RR0 field. */ -#define WDT_RREN_RR0_Msk (0x1UL << WDT_RREN_RR0_Pos) /*!< Bit mask of RR0 field. */ -#define WDT_RREN_RR0_Disabled (0UL) /*!< Disable RR[0] register */ -#define WDT_RREN_RR0_Enabled (1UL) /*!< Enable RR[0] register */ - -/* Register: WDT_CONFIG */ -/* Description: Configuration register */ - -/* Bit 3 : Configure the watchdog to either be paused, or kept running, while the CPU is halted by the debugger */ -#define WDT_CONFIG_HALT_Pos (3UL) /*!< Position of HALT field. */ -#define WDT_CONFIG_HALT_Msk (0x1UL << WDT_CONFIG_HALT_Pos) /*!< Bit mask of HALT field. */ -#define WDT_CONFIG_HALT_Pause (0UL) /*!< Pause watchdog while the CPU is halted by the debugger */ -#define WDT_CONFIG_HALT_Run (1UL) /*!< Keep the watchdog running while the CPU is halted by the debugger */ - -/* Bit 0 : Configure the watchdog to either be paused, or kept running, while the CPU is sleeping */ -#define WDT_CONFIG_SLEEP_Pos (0UL) /*!< Position of SLEEP field. */ -#define WDT_CONFIG_SLEEP_Msk (0x1UL << WDT_CONFIG_SLEEP_Pos) /*!< Bit mask of SLEEP field. */ -#define WDT_CONFIG_SLEEP_Pause (0UL) /*!< Pause watchdog while the CPU is sleeping */ -#define WDT_CONFIG_SLEEP_Run (1UL) /*!< Keep the watchdog running while the CPU is sleeping */ - -/* Register: WDT_RR */ -/* Description: Description collection[0]: Reload request 0 */ - -/* Bits 31..0 : Reload request register */ -#define WDT_RR_RR_Pos (0UL) /*!< Position of RR field. */ -#define WDT_RR_RR_Msk (0xFFFFFFFFUL << WDT_RR_RR_Pos) /*!< Bit mask of RR field. */ -#define WDT_RR_RR_Reload (0x6E524635UL) /*!< Value to request a reload of the watchdog timer */ - - -/*lint --flb "Leave library region" */ -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_peripherals.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_peripherals.h deleted file mode 100644 index d2c0364..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52840_peripherals.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - -Copyright (c) 2010 - 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 _NRF52840_PERIPHERALS_H -#define _NRF52840_PERIPHERALS_H - - -/* Power Peripheral */ -#define POWER_PRESENT -#define POWER_COUNT 1 - -#define POWER_FEATURE_RAM_REGISTERS_PRESENT -#define POWER_FEATURE_RAM_REGISTERS_COUNT 9 - -#define POWER_FEATURE_VDDH_PRESENT - -/* Floating Point Unit */ -#define FPU_PRESENT -#define FPU_COUNT 1 - -/* Systick timer */ -#define SYSTICK_PRESENT -#define SYSTICK_COUNT 1 - -/* Software Interrupts */ -#define SWI_PRESENT -#define SWI_COUNT 6 - -/* Memory Watch Unit */ -#define MWU_PRESENT -#define MWU_COUNT 1 - -/* GPIO */ -#define GPIO_PRESENT -#define GPIO_COUNT 2 - -#define P0_PIN_NUM 32 -#define P1_PIN_NUM 16 - -/* ACL */ -#define ACL_PRESENT - -#define ACL_REGIONS_COUNT 8 - -/* Radio */ -#define RADIO_PRESENT -#define RADIO_COUNT 1 - -#define RADIO_EASYDMA_MAXCNT_SIZE 8 - -/* Accelerated Address Resolver */ -#define AAR_PRESENT -#define AAR_COUNT 1 - -#define AAR_MAX_IRK_NUM 16 - -/* AES Electronic CodeBook mode encryption */ -#define ECB_PRESENT -#define ECB_COUNT 1 - -/* AES CCM mode encryption */ -#define CCM_PRESENT -#define CCM_COUNT 1 - -/* NFC Tag */ -#define NFCT_PRESENT -#define NFCT_COUNT 1 - -#define NFCT_EASYDMA_MAXCNT_SIZE 9 - -/* Peripheral to Peripheral Interconnect */ -#define PPI_PRESENT -#define PPI_COUNT 1 - -#define PPI_CH_NUM 20 -#define PPI_FIXED_CH_NUM 12 -#define PPI_GROUP_NUM 6 -#define PPI_FEATURE_FORKS_PRESENT - -/* Event Generator Unit */ -#define EGU_PRESENT -#define EGU_COUNT 6 - -#define EGU0_CH_NUM 16 -#define EGU1_CH_NUM 16 -#define EGU2_CH_NUM 16 -#define EGU3_CH_NUM 16 -#define EGU4_CH_NUM 16 -#define EGU5_CH_NUM 16 - -/* Timer/Counter */ -#define TIMER_PRESENT -#define TIMER_COUNT 5 - -#define TIMER0_MAX_SIZE 32 -#define TIMER1_MAX_SIZE 32 -#define TIMER2_MAX_SIZE 32 -#define TIMER3_MAX_SIZE 32 -#define TIMER4_MAX_SIZE 32 - -#define TIMER0_CC_NUM 4 -#define TIMER1_CC_NUM 4 -#define TIMER2_CC_NUM 4 -#define TIMER3_CC_NUM 6 -#define TIMER4_CC_NUM 6 - -/* Real Time Counter */ -#define RTC_PRESENT -#define RTC_COUNT 3 - -#define RTC0_CC_NUM 3 -#define RTC1_CC_NUM 4 -#define RTC2_CC_NUM 4 - -/* RNG */ -#define RNG_PRESENT -#define RNG_COUNT 1 - -/* Watchdog Timer */ -#define WDT_PRESENT -#define WDT_COUNT 1 - -/* Temperature Sensor */ -#define TEMP_PRESENT -#define TEMP_COUNT 1 - -/* Serial Peripheral Interface Master */ -#define SPI_PRESENT -#define SPI_COUNT 3 - -/* Serial Peripheral Interface Master with DMA */ -#define SPIM_PRESENT -#define SPIM_COUNT 4 - -#define SPIM0_MAX_DATARATE 8 -#define SPIM1_MAX_DATARATE 8 -#define SPIM2_MAX_DATARATE 8 -#define SPIM3_MAX_DATARATE 32 - -#define SPIM0_FEATURE_HARDWARE_CSN_PRESENT 0 -#define SPIM1_FEATURE_HARDWARE_CSN_PRESENT 0 -#define SPIM2_FEATURE_HARDWARE_CSN_PRESENT 0 -#define SPIM3_FEATURE_HARDWARE_CSN_PRESENT 1 - -#define SPIM0_EASYDMA_MAXCNT_SIZE 16 -#define SPIM1_EASYDMA_MAXCNT_SIZE 16 -#define SPIM2_EASYDMA_MAXCNT_SIZE 16 -#define SPIM3_EASYDMA_MAXCNT_SIZE 16 - -/* Serial Peripheral Interface Slave with DMA*/ -#define SPIS_PRESENT -#define SPIS_COUNT 3 - -#define SPIS0_EASYDMA_MAXCNT_SIZE 16 -#define SPIS1_EASYDMA_MAXCNT_SIZE 16 -#define SPIS2_EASYDMA_MAXCNT_SIZE 16 - -/* Two Wire Interface Master */ -#define TWI_PRESENT -#define TWI_COUNT 2 - -/* Two Wire Interface Master with DMA */ -#define TWIM_PRESENT -#define TWIM_COUNT 2 - -#define TWIM0_EASYDMA_MAXCNT_SIZE 16 -#define TWIM1_EASYDMA_MAXCNT_SIZE 16 - -/* Two Wire Interface Slave with DMA */ -#define TWIS_PRESENT -#define TWIS_COUNT 2 - -#define TWIS0_EASYDMA_MAXCNT_SIZE 16 -#define TWIS1_EASYDMA_MAXCNT_SIZE 16 - -/* Universal Asynchronous Receiver-Transmitter */ -#define UART_PRESENT -#define UART_COUNT 1 - -/* Universal Asynchronous Receiver-Transmitter with DMA */ -#define UARTE_PRESENT -#define UARTE_COUNT 2 - -#define UARTE0_EASYDMA_MAXCNT_SIZE 16 -#define UARTE1_EASYDMA_MAXCNT_SIZE 16 - -/* Quadrature Decoder */ -#define QDEC_PRESENT -#define QDEC_COUNT 1 - -/* Successive Approximation Analog to Digital Converter */ -#define SAADC_PRESENT -#define SAADC_COUNT 1 - -#define SAADC_EASYDMA_MAXCNT_SIZE 15 - -/* GPIO Tasks and Events */ -#define GPIOTE_PRESENT -#define GPIOTE_COUNT 1 - -#define GPIOTE_CH_NUM 8 - -#define GPIOTE_FEATURE_SET_PRESENT -#define GPIOTE_FEATURE_CLR_PRESENT - -/* Low Power Comparator */ -#define LPCOMP_PRESENT -#define LPCOMP_COUNT 1 - -#define LPCOMP_REFSEL_RESOLUTION 16 - -#define LPCOMP_FEATURE_HYST_PRESENT - -/* Comparator */ -#define COMP_PRESENT -#define COMP_COUNT 1 - -/* Pulse Width Modulator */ -#define PWM_PRESENT -#define PWM_COUNT 4 - -#define PWM0_CH_NUM 4 -#define PWM1_CH_NUM 4 -#define PWM2_CH_NUM 4 -#define PWM3_CH_NUM 4 - -#define PWM0_EASYDMA_MAXCNT_SIZE 15 -#define PWM1_EASYDMA_MAXCNT_SIZE 15 -#define PWM2_EASYDMA_MAXCNT_SIZE 15 -#define PWM3_EASYDMA_MAXCNT_SIZE 15 - -/* Pulse Density Modulator */ -#define PDM_PRESENT -#define PDM_COUNT 1 - -#define PDM_EASYDMA_MAXCNT_SIZE 15 - -/* Inter-IC Sound Interface */ -#define I2S_PRESENT -#define I2S_COUNT 1 - -#define I2S_EASYDMA_MAXCNT_SIZE 14 - -/* Universal Serial Bus Device */ -#define USBD_PRESENT -#define USBD_COUNT 1 - -#define USBD_EASYDMA_MAXCNT_SIZE 7 - -/* ARM TrustZone Cryptocell 310 */ -#define CRYPTOCELL_PRESENT -#define CRYPTOCELL_COUNT 1 - -/* Quad SPI */ -#define QSPI_PRESENT -#define QSPI_COUNT 1 - -#define QSPI_EASYDMA_MAXCNT_SIZE 20 - -#endif // _NRF52840_PERIPHERALS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52810.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52810.h deleted file mode 100644 index a441496..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52810.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - -Copyright (c) 2010 - 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 NRF52_TO_NRF52810_H -#define NRF52_TO_NRF52810_H - -/*lint ++flb "Enter library region */ - -/* This file is given to prevent your SW from not compiling with the name changes between nRF51 or nRF52832 and nRF52840 devices. - * It redefines the old nRF51 or nRF52832 names into the new ones as long as the functionality is still supported. If the - * functionality is gone, there old names are not defined, so compilation will fail. Note that also includes macros - * from the nrf52_namechange.h file. */ - -/* Differences between latest nRF52 headers and nRF52810 headers. */ - -/* Interrupt service routines handlers. Note that handlers SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler and - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler are not redefined since functionality is not equivalent. */ -#define UARTE0_UART0_IRQHandler UARTE0_IRQHandler -#define COMP_LPCOMP_IRQHandler COMP_IRQHandler -#define SWI2_EGU2_IRQHandler SWI2_IRQHandler -#define SWI3_EGU3_IRQHandler SWI3_IRQHandler -#define SWI4_EGU4_IRQHandler SWI4_IRQHandler -#define SWI5_EGU5_IRQHandler SWI5_IRQHandler - -/* Interrupt service routines index. Note that indexes SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn and - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn are not redefined since functionality is not equivalent. */ -#define UARTE0_UART0_IRQn UARTE0_IRQn -#define COMP_LPCOMP_IRQn COMP_IRQn -#define SWI2_EGU2_IRQn SWI2_IRQn -#define SWI3_EGU3_IRQn SWI3_IRQn -#define SWI4_EGU4_IRQn SWI4_IRQn -#define SWI5_EGU5_IRQn SWI5_IRQn - - -/* From nrf52_name_change.h. Several macros changed in different versions of nRF52 headers. By defining the following, any code written for any version of nRF52 headers will still compile. */ - -/* I2S */ -/* Several enumerations changed case. Adding old macros to keep compilation compatibility. */ -#define I2S_ENABLE_ENABLE_DISABLE I2S_ENABLE_ENABLE_Disabled -#define I2S_ENABLE_ENABLE_ENABLE I2S_ENABLE_ENABLE_Enabled -#define I2S_CONFIG_MODE_MODE_MASTER I2S_CONFIG_MODE_MODE_Master -#define I2S_CONFIG_MODE_MODE_SLAVE I2S_CONFIG_MODE_MODE_Slave -#define I2S_CONFIG_RXEN_RXEN_DISABLE I2S_CONFIG_RXEN_RXEN_Disabled -#define I2S_CONFIG_RXEN_RXEN_ENABLE I2S_CONFIG_RXEN_RXEN_Enabled -#define I2S_CONFIG_TXEN_TXEN_DISABLE I2S_CONFIG_TXEN_TXEN_Disabled -#define I2S_CONFIG_TXEN_TXEN_ENABLE I2S_CONFIG_TXEN_TXEN_Enabled -#define I2S_CONFIG_MCKEN_MCKEN_DISABLE I2S_CONFIG_MCKEN_MCKEN_Disabled -#define I2S_CONFIG_MCKEN_MCKEN_ENABLE I2S_CONFIG_MCKEN_MCKEN_Enabled -#define I2S_CONFIG_SWIDTH_SWIDTH_8BIT I2S_CONFIG_SWIDTH_SWIDTH_8Bit -#define I2S_CONFIG_SWIDTH_SWIDTH_16BIT I2S_CONFIG_SWIDTH_SWIDTH_16Bit -#define I2S_CONFIG_SWIDTH_SWIDTH_24BIT I2S_CONFIG_SWIDTH_SWIDTH_24Bit -#define I2S_CONFIG_ALIGN_ALIGN_LEFT I2S_CONFIG_ALIGN_ALIGN_Left -#define I2S_CONFIG_ALIGN_ALIGN_RIGHT I2S_CONFIG_ALIGN_ALIGN_Right -#define I2S_CONFIG_FORMAT_FORMAT_ALIGNED I2S_CONFIG_FORMAT_FORMAT_Aligned -#define I2S_CONFIG_CHANNELS_CHANNELS_STEREO I2S_CONFIG_CHANNELS_CHANNELS_Stereo -#define I2S_CONFIG_CHANNELS_CHANNELS_LEFT I2S_CONFIG_CHANNELS_CHANNELS_Left -#define I2S_CONFIG_CHANNELS_CHANNELS_RIGHT I2S_CONFIG_CHANNELS_CHANNELS_Right - -/* LPCOMP */ -/* Corrected typo in RESULT register. */ -#define LPCOMP_RESULT_RESULT_Bellow LPCOMP_RESULT_RESULT_Below - - -/*lint --flb "Leave library region" */ - -#endif /* NRF51_TO_NRF52810_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52840.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52840.h deleted file mode 100644 index 03d13f1..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/device/nrf52_to_nrf52840.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - -Copyright (c) 2010 - 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 NRF52_TO_NRF52840_H -#define NRF52_TO_NRF52840_H - -/*lint ++flb "Enter library region */ - -/* This file is given to prevent your SW from not compiling with the name changes between nRF51 or nRF52832 and nRF52840 devices. - * It redefines the old nRF51 or nRF52832 names into the new ones as long as the functionality is still supported. If the - * functionality is gone, there old names are not defined, so compilation will fail. Note that also includes macros - * from the nrf52_namechange.h file. */ - -/* Differences between latest nRF52 headers and nRF52840 headers. */ - -/* UART */ -/* The registers PSELRTS, PSELTXD, PSELCTS, PSELRXD were restructured into a struct. */ -#define PSELRTS PSEL.RTS -#define PSELTXD PSEL.TXD -#define PSELCTS PSEL.CTS -#define PSELRXD PSEL.RXD - -/* TWI */ -/* The registers PSELSCL, PSELSDA were restructured into a struct. */ -#define PSELSCL PSEL.SCL -#define PSELSDA PSEL.SDA - - -/* LPCOMP */ -/* The hysteresis control enumerated values has changed name for nRF52840 devices. */ -#define LPCOMP_HYST_HYST_NoHyst LPCOMP_HYST_HYST_Disabled -#define LPCOMP_HYST_HYST_Hyst50mV LPCOMP_HYST_HYST_Enabled - - -/* From nrf52_name_change.h. Several macros changed in different versions of nRF52 headers. By defining the following, any code written for any version of nRF52 headers will still compile. */ - -/* I2S */ -/* Several enumerations changed case. Adding old macros to keep compilation compatibility. */ -#define I2S_ENABLE_ENABLE_DISABLE I2S_ENABLE_ENABLE_Disabled -#define I2S_ENABLE_ENABLE_ENABLE I2S_ENABLE_ENABLE_Enabled -#define I2S_CONFIG_MODE_MODE_MASTER I2S_CONFIG_MODE_MODE_Master -#define I2S_CONFIG_MODE_MODE_SLAVE I2S_CONFIG_MODE_MODE_Slave -#define I2S_CONFIG_RXEN_RXEN_DISABLE I2S_CONFIG_RXEN_RXEN_Disabled -#define I2S_CONFIG_RXEN_RXEN_ENABLE I2S_CONFIG_RXEN_RXEN_Enabled -#define I2S_CONFIG_TXEN_TXEN_DISABLE I2S_CONFIG_TXEN_TXEN_Disabled -#define I2S_CONFIG_TXEN_TXEN_ENABLE I2S_CONFIG_TXEN_TXEN_Enabled -#define I2S_CONFIG_MCKEN_MCKEN_DISABLE I2S_CONFIG_MCKEN_MCKEN_Disabled -#define I2S_CONFIG_MCKEN_MCKEN_ENABLE I2S_CONFIG_MCKEN_MCKEN_Enabled -#define I2S_CONFIG_SWIDTH_SWIDTH_8BIT I2S_CONFIG_SWIDTH_SWIDTH_8Bit -#define I2S_CONFIG_SWIDTH_SWIDTH_16BIT I2S_CONFIG_SWIDTH_SWIDTH_16Bit -#define I2S_CONFIG_SWIDTH_SWIDTH_24BIT I2S_CONFIG_SWIDTH_SWIDTH_24Bit -#define I2S_CONFIG_ALIGN_ALIGN_LEFT I2S_CONFIG_ALIGN_ALIGN_Left -#define I2S_CONFIG_ALIGN_ALIGN_RIGHT I2S_CONFIG_ALIGN_ALIGN_Right -#define I2S_CONFIG_FORMAT_FORMAT_ALIGNED I2S_CONFIG_FORMAT_FORMAT_Aligned -#define I2S_CONFIG_CHANNELS_CHANNELS_STEREO I2S_CONFIG_CHANNELS_CHANNELS_Stereo -#define I2S_CONFIG_CHANNELS_CHANNELS_LEFT I2S_CONFIG_CHANNELS_CHANNELS_Left -#define I2S_CONFIG_CHANNELS_CHANNELS_RIGHT I2S_CONFIG_CHANNELS_CHANNELS_Right - -/* LPCOMP */ -/* Corrected typo in RESULT register. */ -#define LPCOMP_RESULT_RESULT_Bellow LPCOMP_RESULT_RESULT_Below - - -/*lint --flb "Leave library region" */ - -#endif /* NRF51_TO_NRF52840_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.c deleted file mode 100644 index 25368ad..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.c +++ /dev/null @@ -1,313 +0,0 @@ -/** - * Copyright (c) 2012 - 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 "ble_flash.h" -#include -#include -#include -#include "nrf_soc.h" -#include "nordic_common.h" -#include "nrf_error.h" -#include "nrf.h" -#include "app_util.h" - - -static volatile bool m_radio_active = false; /**< TRUE if radio is active (or about to become active), FALSE otherwise. */ - - -uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_crc) -{ - uint16_t i; - uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc; - - for (i = 0; i < size; i++) - { - crc = (unsigned char)(crc >> 8) | (crc << 8); - crc ^= p_data[i]; - crc ^= (unsigned char)(crc & 0xff) >> 4; - crc ^= (crc << 8) << 4; - crc ^= ((crc & 0xff) << 4) << 1; - } - return crc; -} - - -/**@brief Function for erasing a page in flash. - * - * @param[in] p_page Pointer to first word in page to be erased. - */ -static void flash_page_erase(uint32_t * p_page) -{ - // Turn on flash erase enable and wait until the NVMC is ready. - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } - - // Erase page. - NRF_NVMC->ERASEPAGE = (uint32_t)p_page; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } - - // Turn off flash erase enable and wait until the NVMC is ready. - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing - } -} - - -/**@brief Function for writing one word to flash. Unprotected write, which can interfere with radio communication. - * - * @details This function DOES NOT use the m_radio_active variable, but will force the write even - * when the radio is active. To be used only from @ref ble_flash_page_write. - * - * @note Flash location to be written must have been erased previously. - * - * @param[in] p_address Pointer to flash location to be written. - * @param[in] value Value to write to flash. - */ -static void flash_word_unprotected_write(uint32_t * p_address, uint32_t value) -{ - // Turn on flash write enable and wait until the NVMC is ready. - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } - *p_address = value; - - // Wait flash write to finish - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } - - // Turn off flash write enable and wait until the NVMC is ready. - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } -} - - -/**@brief Function for writing one word to flash. - * - * @note Flash location to be written must have been erased previously. - * - * @param[in] p_address Pointer to flash location to be written. - * @param[in] value Value to write to flash. - */ -static void flash_word_write(uint32_t * p_address, uint32_t value) -{ - // If radio is active, wait for it to become inactive. - while (m_radio_active) - { - // Do nothing (just wait for radio to become inactive). - (void) sd_app_evt_wait(); - } - - // Turn on flash write enable and wait until the NVMC is ready. - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } - - *p_address = value; - // Wait flash write to finish - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing. - } - // Turn off flash write enable and wait until the NVMC is ready. - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy) - { - // Do nothing - } -} - - -uint32_t ble_flash_word_write(uint32_t * p_address, uint32_t value) -{ - flash_word_write(p_address, value); - return NRF_SUCCESS; -} - - -uint32_t ble_flash_block_write(uint32_t * p_address, uint32_t * p_in_array, uint16_t word_count) -{ - uint16_t i; - - for (i = 0; i < word_count; i++) - { - flash_word_write(p_address, p_in_array[i]); - p_address++; - } - - return NRF_SUCCESS; -} - - -uint32_t ble_flash_page_erase(uint8_t page_num) -{ - uint32_t * p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num); - flash_page_erase(p_page); - - return NRF_SUCCESS; -} - - -uint32_t ble_flash_page_write(uint8_t page_num, uint32_t * p_in_array, uint8_t word_count) -{ - int i; - uint32_t * p_page; - uint32_t * p_curr_addr; - uint16_t in_data_crc; - uint16_t flash_crc; - uint32_t flash_header; - - p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num); - p_curr_addr = p_page; - - // Calculate CRC of the data to write. - in_data_crc = ble_flash_crc16_compute((uint8_t *)p_in_array, - word_count * sizeof(uint32_t), - NULL); - - // Compare the calculated to the one in flash. - flash_header = *p_curr_addr; - flash_crc = (uint16_t)flash_header; - - if (flash_crc == in_data_crc) - { - // Data is the same as the data already stored in flash, return without modifying flash. - return NRF_SUCCESS; - } - - // Erase flash page - flash_page_erase(p_page); - - // Reserve space for magic number (for detecting if flash content is valid). - p_curr_addr++; - - // Reserve space for saving word_count. - p_curr_addr++; - - // Write data - for (i = 0; i < word_count; i++) - { - flash_word_unprotected_write(p_curr_addr, p_in_array[i]); - p_curr_addr++; - } - - // Write number of elements. - flash_word_write(p_page + 1, (uint32_t)(word_count)); - - // Write magic number and CRC to indicate that flash content is valid. - flash_header = BLE_FLASH_MAGIC_NUMBER | (uint32_t)in_data_crc; - flash_word_write(p_page, flash_header); - - return NRF_SUCCESS; -} - - -uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count) -{ - int byte_count; - uint32_t * p_page; - uint32_t * p_curr_addr; - uint32_t flash_header; - uint32_t calc_header; - uint16_t calc_crc; - uint32_t tmp; - - p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num); - p_curr_addr = p_page; - - // Check if block is valid - flash_header = *p_curr_addr; - tmp = flash_header & 0xFFFF0000; - if (tmp != BLE_FLASH_MAGIC_NUMBER) - { - *p_word_count = 0; - return NRF_ERROR_NOT_FOUND; - } - p_curr_addr++; - - // Read number of elements - *p_word_count = (uint8_t)(*(p_curr_addr)); - p_curr_addr++; - - // Read data - byte_count = (*p_word_count) * sizeof(uint32_t); - memcpy(p_out_array, p_curr_addr, byte_count); - - // Check CRC - calc_crc = ble_flash_crc16_compute((uint8_t *)p_out_array, - (*p_word_count) * sizeof(uint32_t), - NULL); - calc_header = BLE_FLASH_MAGIC_NUMBER | (uint32_t)calc_crc; - - if (calc_header != flash_header) - { - return NRF_ERROR_NOT_FOUND; - } - - return NRF_SUCCESS; -} - - -uint32_t ble_flash_page_addr(uint8_t page_num, uint32_t ** pp_page_addr) -{ - *pp_page_addr = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num); - return NRF_SUCCESS; -} - - -void ble_flash_on_radio_active_evt(bool radio_active) -{ - m_radio_active = radio_active; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.h deleted file mode 100644 index 8fffeb6..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ble_flash/ble_flash.h +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) 2012 - 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 ble_flash_module Flash Manager - * @{ - * @ingroup ble_sdk_lib - * @brief Module for accessing flash memory. - * - * @details It contains functions for reading, writing and erasing one page in flash. - * - * The module uses the first 32 bits of the flash page to write a magic number in order to - * determine if the page has been written or not. - * - * @note Be careful not to use a page number in the SoftDevice area (which currently occupies the - * range 0 to 127), or in your application space! In both cases, this would end up - * with a hard fault. - */ - -#ifndef BLE_FLASH_H__ -#define BLE_FLASH_H__ - -#include -#include -#include "nrf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define BLE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */ -#define BLE_FLASH_MAGIC_NUMBER 0x45DE0000 /**< Magic value to identify if flash contains valid data. */ -#define BLE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */ - - -/**@brief Macro for getting the end of the flash available for application. - * - * @details The result flash page number indicates the end boundary of the flash available - * to the application. If a bootloader is used, the end will be the start of the - * bootloader region. Otherwise, the end will be the size of the flash. - */ -#define BLE_FLASH_PAGE_END \ - ((NRF_UICR->NRFFW[0] != BLE_FLASH_EMPTY_MASK) \ - ? (NRF_UICR->NRFFW[0] / BLE_FLASH_PAGE_SIZE) \ - : NRF_FICR->CODESIZE) - -/**@brief Function for erasing the specified flash page, and then writes the given data to this page. - * - * @warning This operation blocks the CPU. DO NOT use while in a connection! - * - * @param[in] page_num Page number to update. - * @param[in] p_in_array Pointer to a RAM area containing the elements to write in flash. - * This area has to be 32 bits aligned. - * @param[in] word_count Number of 32 bits words to write in flash. - * - * @return NRF_SUCCESS on successful flash write, otherwise an error code. - */ -uint32_t ble_flash_page_write(uint8_t page_num, uint32_t * p_in_array, uint8_t word_count); - -/**@brief Function for reading data from flash to RAM. - * - * @param[in] page_num Page number to read. - * @param[out] p_out_array Pointer to a RAM area where the found data will be written. - * This area has to be 32 bits aligned. - * @param[out] p_word_count Number of 32 bits words read. - * - * @return NRF_SUCCESS on successful upload, NRF_ERROR_NOT_FOUND if no valid data has been found - * in flash (first 32 bits not equal to the MAGIC_NUMBER + CRC). - */ -uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count); - -/**@brief Function for erasing a flash page. - * - * @note This operation blocks the CPU, so it should not be done while the radio is running! - * - * @param[in] page_num Page number to erase. - * - * @return NRF_SUCCESS on success, an error_code otherwise. - */ -uint32_t ble_flash_page_erase(uint8_t page_num); - -/**@brief Function for writing one word to flash. - * - * @note Flash location to be written must have been erased previously. - * - * @param[in] p_address Pointer to flash location to be written. - * @param[in] value Value to write to flash. - * - * @return NRF_SUCCESS. - */ -uint32_t ble_flash_word_write(uint32_t * p_address, uint32_t value); - -/**@brief Function for writing a data block to flash. - * - * @note Flash locations to be written must have been erased previously. - * - * @param[in] p_address Pointer to start of flash location to be written. - * @param[in] p_in_array Pointer to start of flash block to be written. - * @param[in] word_count Number of words to be written. - * - * @return NRF_SUCCESS. - */ -uint32_t ble_flash_block_write(uint32_t * p_address, uint32_t * p_in_array, uint16_t word_count); - -/**@brief Function for computing pointer to start of specified flash page. - * - * @param[in] page_num Page number. - * @param[out] pp_page_addr Pointer to start of flash page. - * - * @return NRF_SUCCESS. - */ -uint32_t ble_flash_page_addr(uint8_t page_num, uint32_t ** pp_page_addr); - -/**@brief Function for calculating a 16 bit CRC using the CRC-16-CCITT scheme. - * - * @param[in] p_data Pointer to data on which the CRC is to be calculated. - * @param[in] size Number of bytes on which the CRC is to be calculated. - * @param[in] p_crc Initial CRC value (if NULL, a preset value is used as the initial value). - * - * @return Calculated CRC. - */ -uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_crc); - -/**@brief Function for handling flashing module Radio Notification event. - * - * @note For flash writing to work safely while in a connection or while advertising, this function - * MUST be called from the Radio Notification module's event handler (see - * @ref ble_radio_notification for details). - * - * @param[in] radio_active TRUE if radio is active (or about to become active), FALSE otherwise. - */ -void ble_flash_on_radio_active_evt(bool radio_active); - - -#ifdef __cplusplus -} -#endif - -#endif // BLE_FLASH_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.c deleted file mode 100644 index 8d93e97..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.c +++ /dev/null @@ -1,297 +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 -#include "nrf_drv_common.h" -#include "nrf_assert.h" -#include "app_util_platform.h" -#include "nrf_peripherals.h" - -#if NRF_DRV_COMMON_POWER_CLOCK_ISR -#include "nrf_drv_power.h" -#include "nrf_drv_clock.h" -#endif -#ifdef SOFTDEVICE_PRESENT -#include "nrf_soc.h" -#endif - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -#define NRF_LOG_MODULE_NAME common - -#if COMMON_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL COMMON_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR COMMON_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR COMMON_CONFIG_DEBUG_COLOR -#else //COMMON_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //COMMON_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - -typedef struct { - nrf_drv_irq_handler_t handler; - bool acquired; -} shared_resource_t; - -// SPIM0, SPIS0, SPI0, TWIM0, TWIS0, TWI0 -#if (NRF_MODULE_ENABLED(SPI0) || NRF_MODULE_ENABLED(SPIS0) || NRF_MODULE_ENABLED(TWI0) || NRF_MODULE_ENABLED(TWIS0)) - #define SERIAL_BOX_0_IN_USE - // [this checking may need a different form in unit tests, hence macro] - #ifndef IS_SERIAL_BOX_0 - #define IS_SERIAL_BOX_0(p_per_base) (p_per_base == NRF_SPI0) - #endif - - static shared_resource_t m_serial_box_0 = { .acquired = false }; - void SPI0_TWI0_IRQHandler(void) - { - ASSERT(m_serial_box_0.handler); - m_serial_box_0.handler(); - } -#endif // (NRF_MODULE_ENABLED(SPI0) || NRF_MODULE_ENABLED(SPIS0) || NRF_MODULE_ENABLED(TWI0) || NRF_MODULE_ENABLED(TWIS0)) - -// SPIM1, SPIS1, SPI1, TWIM1, TWIS1, TWI1 -#if (NRF_MODULE_ENABLED(SPI1) || NRF_MODULE_ENABLED(SPIS1) || NRF_MODULE_ENABLED(TWI1) || NRF_MODULE_ENABLED(TWIS1)) - #define SERIAL_BOX_1_IN_USE - // [this checking may need a different form in unit tests, hence macro] - #ifndef IS_SERIAL_BOX_1 - #define IS_SERIAL_BOX_1(p_per_base) (p_per_base == NRF_SPI1) - #endif - - static shared_resource_t m_serial_box_1 = { .acquired = false }; -#ifdef TWIM_PRESENT - void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void) -#else - void SPI1_TWI1_IRQHandler(void) -#endif - { - ASSERT(m_serial_box_1.handler); - m_serial_box_1.handler(); - } -#endif // (NRF_MODULE_ENABLED(SPI1) || NRF_MODULE_ENABLED(SPIS1) || NRF_MODULE_ENABLED(TWI1) || NRF_MODULE_ENABLED(TWIS1)) - -// SPIM2, SPIS2, SPI2 -#if (NRF_MODULE_ENABLED(SPI2) || NRF_MODULE_ENABLED(SPIS2)) - #define SERIAL_BOX_2_IN_USE - // [this checking may need a different form in unit tests, hence macro] - #ifndef IS_SERIAL_BOX_2 - #define IS_SERIAL_BOX_2(p_per_base) (p_per_base == NRF_SPI2) - #endif - - static shared_resource_t m_serial_box_2 = { .acquired = false }; - void SPIM2_SPIS2_SPI2_IRQHandler(void) - { - ASSERT(m_serial_box_2.handler); - m_serial_box_2.handler(); - } -#endif // (NRF_MODULE_ENABLED(SPI2) || NRF_MODULE_ENABLED(SPIS2)) - -// COMP, LPCOMP -#if (NRF_MODULE_ENABLED(COMP) || NRF_MODULE_ENABLED(LPCOMP)) - #define COMP_LPCOMP_IN_USE - - #ifndef IS_COMP_LPCOMP - #define IS_COMP_LPCOMP(p_per_base) ((p_per_base) == NRF_LPCOMP) - #endif - - static shared_resource_t m_comp_lpcomp = { .acquired = false }; - void LPCOMP_IRQHandler(void) - { - ASSERT(m_comp_lpcomp.handler); - m_comp_lpcomp.handler(); - } -#endif // (NRF_MODULE_ENABLED(COMP) || NRF_MODULE_ENABLED(LPCOMP)) - -#if defined(SERIAL_BOX_0_IN_USE) || \ - defined(SERIAL_BOX_1_IN_USE) || \ - defined(SERIAL_BOX_2_IN_USE) || \ - defined(COMP_LPCOMP_IN_USE) -static ret_code_t acquire_shared_resource(shared_resource_t * p_resource, - nrf_drv_irq_handler_t handler) -{ - ret_code_t err_code; - - bool busy = false; - - CRITICAL_REGION_ENTER(); - if (p_resource->acquired) - { - busy = true; - } - else - { - p_resource->acquired = true; - } - CRITICAL_REGION_EXIT(); - - if (busy) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - p_resource->handler = handler; - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} -#endif - -ret_code_t nrf_drv_common_per_res_acquire(void const * p_per_base, - nrf_drv_irq_handler_t handler) -{ -#ifdef SERIAL_BOX_0_IN_USE - if (IS_SERIAL_BOX_0(p_per_base)) - { - return acquire_shared_resource(&m_serial_box_0, handler); - } -#endif - -#ifdef SERIAL_BOX_1_IN_USE - if (IS_SERIAL_BOX_1(p_per_base)) - { - return acquire_shared_resource(&m_serial_box_1, handler); - } -#endif - -#ifdef SERIAL_BOX_2_IN_USE - if (IS_SERIAL_BOX_2(p_per_base)) - { - return acquire_shared_resource(&m_serial_box_2, handler); - } -#endif - -#ifdef COMP_LPCOMP_IN_USE - if (IS_COMP_LPCOMP(p_per_base)) - { - return acquire_shared_resource(&m_comp_lpcomp, handler); - } -#endif - ret_code_t err_code; - - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -void nrf_drv_common_per_res_release(void const * p_per_base) -{ -#ifdef SERIAL_BOX_0_IN_USE - if (IS_SERIAL_BOX_0(p_per_base)) - { - m_serial_box_0.acquired = false; - } - else -#endif - -#ifdef SERIAL_BOX_1_IN_USE - if (IS_SERIAL_BOX_1(p_per_base)) - { - m_serial_box_1.acquired = false; - } - else -#endif - -#ifdef SERIAL_BOX_2_IN_USE - if (IS_SERIAL_BOX_2(p_per_base)) - { - m_serial_box_2.acquired = false; - } - else -#endif - -#ifdef COMP_LPCOMP_IN_USE - if (IS_COMP_LPCOMP(p_per_base)) - { - m_comp_lpcomp.acquired = false; - } - else -#endif - - {} -} - -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -#if NRF_MODULE_ENABLED(POWER) -void nrf_drv_common_power_irq_disable(void) -{ -#if NRF_DRV_COMMON_POWER_CLOCK_ISR - if (!nrf_drv_clock_init_check()) -#endif - { - nrf_drv_common_irq_disable(POWER_CLOCK_IRQn); - } -} -#endif - -#if NRF_MODULE_ENABLED(CLOCK) -void nrf_drv_common_clock_irq_disable(void) -{ -#if NRF_DRV_COMMON_POWER_CLOCK_ISR - if (!nrf_drv_power_init_check()) -#endif - { - nrf_drv_common_irq_disable(POWER_CLOCK_IRQn); - } -} -#endif - -#if NRF_DRV_COMMON_POWER_CLOCK_ISR -void POWER_CLOCK_IRQHandler(void) -{ - extern void nrf_drv_clock_onIRQ(void); - extern void nrf_drv_power_onIRQ(void); - - nrf_drv_clock_onIRQ(); - nrf_drv_power_onIRQ(); -} -#endif // NRF_DRV_COMMON_POWER_CLOCK_ISR - - -void nrf_drv_common_irq_enable(IRQn_Type IRQn, uint8_t priority) -{ - INTERRUPT_PRIORITY_ASSERT(priority); - - NVIC_SetPriority(IRQn, priority); - NVIC_ClearPendingIRQ(IRQn); - NVIC_EnableIRQ(IRQn); -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.h deleted file mode 100644 index cdf866a..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/common/nrf_drv_common.h +++ /dev/null @@ -1,358 +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 NRF_DRV_COMMON_H__ -#define NRF_DRV_COMMON_H__ - -#include -#include -#include "nrf.h" -#include "sdk_errors.h" -#include "sdk_common.h" -#include "nrf_assert.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef NRF51 -#ifdef SOFTDEVICE_PRESENT -#define INTERRUPT_PRIORITY_IS_VALID(pri) (((pri) == 1) || ((pri) == 3)) -#else -#define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 4) -#endif //SOFTDEVICE_PRESENT -#else -#ifdef SOFTDEVICE_PRESENT -#define INTERRUPT_PRIORITY_IS_VALID(pri) ((((pri) > 1) && ((pri) < 4)) || \ - (((pri) > 4) && ((pri) < 8))) -#else -#define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 8) -#endif //SOFTDEVICE_PRESENT -#endif //NRF52 - -#define INTERRUPT_PRIORITY_VALIDATION(pri) STATIC_ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri))) -#define INTERRUPT_PRIORITY_ASSERT(pri) ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri))) - -/** - * @defgroup nrf_drv_common Peripheral drivers common module - * @{ - * @ingroup nrf_drivers - */ - -/** - * @brief Offset of event registers in every peripheral instance. - * - * This is the offset where event registers start in every peripheral. - */ -#define NRF_DRV_COMMON_EVREGS_OFFSET 0x100U - -/** - * @brief The flag that is set when POWER_CLOCK ISR is implemented in common module - * - * This flag means that the function POWER_CLOCK_IRQHandler is implemented in - * nrf_drv_common.c file. In the @c clock and @c power modules functions - * nrf_drv_clock_onIRQ nrf_drv_power_onIRQ should be implemented - * and they would be called from common implementation. - * - * None of the checking is done here. - * The implementation functions in @c clock and @c power are required to handle - * correctly the case when they are called without any event bit set. - */ -#define NRF_DRV_COMMON_POWER_CLOCK_ISR (NRF_MODULE_ENABLED(CLOCK) && NRF_MODULE_ENABLED(POWER)) - -/** - * @brief Driver state. - */ -typedef enum -{ - NRF_DRV_STATE_UNINITIALIZED, /**< Uninitialized. */ - NRF_DRV_STATE_INITIALIZED, /**< Initialized but powered off. */ - NRF_DRV_STATE_POWERED_ON -} nrf_drv_state_t; - -/** - * @brief Driver power state selection. - */ -typedef enum -{ - NRF_DRV_PWR_CTRL_ON, /**< Power on request. */ - NRF_DRV_PWR_CTRL_OFF /**< Power off request. */ -} nrf_drv_pwr_ctrl_t; - -/** - * @brief IRQ handler type. - */ -typedef void (*nrf_drv_irq_handler_t)(void); - - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -/** - * @brief Function for acquiring shared peripheral resources associated with - * the specified peripheral. - * - * Certain resources and registers are shared among peripherals that have - * the same ID (for example: SPI0, SPIM0, SPIS0, TWI0, TWIM0, and TWIS0). - * Only one of them can be utilized at a given time. This function reserves - * proper resources to be used by the specified peripheral. - * If PERIPHERAL_RESOURCE_SHARING_ENABLED is set to a non-zero value, IRQ - * handlers for peripherals that are sharing resources with others are - * implemented by the nrf_drv_common module instead of individual drivers. - * The drivers must then specify their interrupt handling routines and - * register them by using this function. - * - * @param[in] p_per_base Requested peripheral base pointer. - * @param[in] handler Interrupt handler to register. May be NULL - * if interrupts are not used for the peripheral. - * - * @retval NRF_SUCCESS If resources were acquired successfully. - * @retval NRF_ERROR_BUSY If resources were already acquired. - * @retval NRF_ERROR_INVALID_PARAM If the specified peripheral is not enabled - * or the peripheral does not share resources - * with other peripherals. - */ -ret_code_t nrf_drv_common_per_res_acquire(void const * p_per_base, - nrf_drv_irq_handler_t handler); - -/** - * @brief Function for releasing shared resources reserved previously by - * @ref nrf_drv_common_per_res_acquire() for the specified peripheral. - * - * @param[in] p_per_base Requested peripheral base pointer. - */ -void nrf_drv_common_per_res_release(void const * p_per_base); - -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - - -/** - * @brief Function sets priority and enables NVIC interrupt - * - * @note Function checks if correct priority is used when softdevice is present - * - * @param[in] IRQn Interrupt id - * @param[in] priority Interrupt priority - */ -void nrf_drv_common_irq_enable(IRQn_Type IRQn, uint8_t priority); - -#if NRF_MODULE_ENABLED(POWER) -/** - * @brief Disable power IRQ - * - * Power and clock peripheral uses the same IRQ. - * This function disables POWER_CLOCK IRQ only if CLOCK driver - * is uninitialized. - * - * @sa nrf_drv_common_power_clock_irq_init - */ -void nrf_drv_common_power_irq_disable(void); -#endif - -#if NRF_MODULE_ENABLED(CLOCK) -/** - * @brief Disable clock IRQ - * - * Power and clock peripheral uses the same IRQ. - * This function disables POWER_CLOCK IRQ only if POWER driver - * is uninitialized. - * - * @sa nrf_drv_common_power_clock_irq_init - */ -void nrf_drv_common_clock_irq_disable(void); -#endif - -/** - * @brief Check if interrupt is enabled - * - * Function that checks if selected interrupt is enabled. - * - * @param[in] IRQn Interrupt id - * - * @retval true Selected IRQ is enabled. - * @retval false Selected IRQ is disabled. - */ -__STATIC_INLINE bool nrf_drv_common_irq_enable_check(IRQn_Type IRQn); - -/** - * @brief Function disables NVIC interrupt - * - * @param[in] IRQn Interrupt id - */ -__STATIC_INLINE void nrf_drv_common_irq_disable(IRQn_Type IRQn); - -/** - * @brief Convert bit position to event code - * - * Function for converting the bit position in INTEN register to event code - * that is equivalent to the offset of the event register from the beginning - * of peripheral instance. - * - * For example the result of this function can be casted directly to - * the types like @ref nrf_twis_event_t or @ref nrf_rng_event_t - * - * @param bit Bit position in INTEN register - * @return Event code to be casted to the right enum type or to be used in functions like - * @ref nrf_rng_event_get - * - * @sa nrf_drv_event_to_bitpos - */ -__STATIC_INLINE uint32_t nrf_drv_bitpos_to_event(uint32_t bit); - -/** - * @brief Convert event code to bit position - * - * This function can be used to get bit position in INTEN register from event code. - * - * @param event Event code that may be casted from enum values from types like - * @ref nrf_twis_event_t or @ref nrf_rng_event_t - * @return Bit position in INTEN register that corresponds to the given code. - * - * @sa nrf_drv_bitpos_to_event - */ -__STATIC_INLINE uint32_t nrf_drv_event_to_bitpos(uint32_t event); - -/** - * @brief Get interrupt number connected with given instance - * - * Function returns interrupt number for a given instance of any peripheral. - * @param[in] pinst Pointer to peripheral registry - * @return Interrupt number - */ -__STATIC_INLINE IRQn_Type nrf_drv_get_IRQn(void const * const pinst); - -#if NRF_MODULE_ENABLED(CLOCK) || NRF_MODULE_ENABLED(POWER) -/** - * @brief Enable and setup power clock IRQ - * - * This function would be called from @ref nrf_drv_clock and @ref nrf_drv_power - * to enable related interrupt. - * This function avoids multiple interrupt configuration. - * - * @note - * This function is aviable only if @ref nrf_drv_clock or @ref nrf_drv_power - * module is enabled. - * - * @note - * If both @ref nrf_drv_clock and @ref nrf_drv_power modules are enabled, - * during the compilation the check is made that - * @ref CLOCK_CONFIG_IRQ_PRIORITY equals @ref POWER_CONFIG_IRQ_PRIORITY. - * - * @sa nrf_drv_common_power_irq_disable - * @sa nrf_drv_common_clock_irq_disable - */ -__STATIC_INLINE void nrf_drv_common_power_clock_irq_init(void); -#endif - -/** - * @brief Check if given object is in RAM - * - * Function for analyzing if given location is placed in RAM. - * This function is used to determine if we have address that can be supported by EasyDMA. - * @param[in] ptr Pointer to the object - * @retval true Object is located in RAM - * @retval false Object is not located in RAM - */ -__STATIC_INLINE bool nrf_drv_is_in_RAM(void const * const ptr); - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE bool nrf_drv_common_irq_enable_check(IRQn_Type IRQn) -{ - return 0 != (NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] & - (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))); -} - -__STATIC_INLINE void nrf_drv_common_irq_disable(IRQn_Type IRQn) -{ - NVIC_DisableIRQ(IRQn); -} - -__STATIC_INLINE uint32_t nrf_drv_bitpos_to_event(uint32_t bit) -{ - return NRF_DRV_COMMON_EVREGS_OFFSET + bit * sizeof(uint32_t); -} - -__STATIC_INLINE uint32_t nrf_drv_event_to_bitpos(uint32_t event) -{ - return (event - NRF_DRV_COMMON_EVREGS_OFFSET) / sizeof(uint32_t); -} - -__STATIC_INLINE IRQn_Type nrf_drv_get_IRQn(void const * const pinst) -{ - uint8_t ret = (uint8_t)((uint32_t)pinst>>12U); - return (IRQn_Type) ret; -} - -#if NRF_MODULE_ENABLED(CLOCK) || NRF_MODULE_ENABLED(POWER) -__STATIC_INLINE void nrf_drv_common_power_clock_irq_init(void) -{ - if (!nrf_drv_common_irq_enable_check(POWER_CLOCK_IRQn)) - { - nrf_drv_common_irq_enable( - POWER_CLOCK_IRQn, -#if NRF_DRV_COMMON_POWER_CLOCK_ISR - #if CLOCK_CONFIG_IRQ_PRIORITY != POWER_CONFIG_IRQ_PRIORITY - #error CLOCK_CONFIG_IRQ_PRIORITY and POWER_CONFIG_IRQ_PRIORITY have to be the same. - #endif - CLOCK_CONFIG_IRQ_PRIORITY -#elif NRF_MODULE_ENABLED(CLOCK) - CLOCK_CONFIG_IRQ_PRIORITY -#elif NRF_MODULE_ENABLED(POWER) - POWER_CONFIG_IRQ_PRIORITY -#endif - ); - } -} -#endif - -__STATIC_INLINE bool nrf_drv_is_in_RAM(void const * const ptr) -{ - return ((((uintptr_t)ptr) & 0xE0000000u) == 0x20000000u); -} - -#endif // SUPPRESS_INLINE_IMPLEMENTATION - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_COMMON_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.c deleted file mode 100644 index 90d56e0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.c +++ /dev/null @@ -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(COMP) -#include "nrf_drv_comp.h" - -#include "nrf_assert.h" -#include "nrf_error.h" -#include "nrf_soc.h" -#include "nrf_drv_common.h" -#include "app_util_platform.h" -#include -#include -#include - -#define NRF_LOG_MODULE_NAME comp - -#if COMP_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL COMP_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR COMP_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR COMP_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_COMP_EVENT_READY ? "NRF_COMP_EVENT_READY" : \ - (event == NRF_COMP_EVENT_DOWN ? "NRF_COMP_EVENT_DOWN" : \ - (event == NRF_COMP_EVENT_UP ? "NRF_COMP_EVENT_UP" : \ - (event == NRF_COMP_EVENT_CROSS ? "NRF_COMP_EVENT_CROSS" : "UNKNOWN ERROR")))) -#else //COMP_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //COMP_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - - -static comp_events_handler_t m_comp_events_handler = NULL; -static nrf_drv_state_t m_state = NRF_DRV_STATE_UNINITIALIZED; - -static const nrf_drv_comp_config_t m_default_config = NRF_DRV_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_0); - -static void comp_execute_handler(nrf_comp_event_t event, uint32_t event_mask) -{ - if ( nrf_comp_event_check(event) && nrf_comp_int_enable_check(event_mask) ) - { - nrf_comp_event_clear(event); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(event)); - - m_comp_events_handler(event); - } -} - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - #define IRQ_HANDLER_NAME irq_handler_for_comp - #define IRQ_HANDLER static void IRQ_HANDLER_NAME(void) - - IRQ_HANDLER; -#else - #define IRQ_HANDLER void COMP_LPCOMP_IRQHandler(void) -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -IRQ_HANDLER -{ - comp_execute_handler(NRF_COMP_EVENT_READY, COMP_INTENSET_READY_Msk); - comp_execute_handler(NRF_COMP_EVENT_DOWN, COMP_INTENSET_DOWN_Msk); - comp_execute_handler(NRF_COMP_EVENT_UP, COMP_INTENSET_UP_Msk); - comp_execute_handler(NRF_COMP_EVENT_CROSS, COMP_INTENSET_CROSS_Msk); -} - - -ret_code_t nrf_drv_comp_init(const nrf_drv_comp_config_t * p_config, - comp_events_handler_t event_handler) -{ - ret_code_t err_code; - - if (m_state != NRF_DRV_STATE_UNINITIALIZED) - { // COMP driver is already initialized - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - if (p_config == NULL) - { - p_config = &m_default_config; - } - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - if (nrf_drv_common_per_res_acquire(NRF_COMP, IRQ_HANDLER_NAME) != NRF_SUCCESS) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } -#endif - - nrf_comp_task_trigger(NRF_COMP_TASK_STOP); - nrf_comp_enable(); - - // Clear events to be sure there are no leftovers. - nrf_comp_event_clear(NRF_COMP_EVENT_READY); - nrf_comp_event_clear(NRF_COMP_EVENT_DOWN); - nrf_comp_event_clear(NRF_COMP_EVENT_UP); - nrf_comp_event_clear(NRF_COMP_EVENT_CROSS); - - nrf_comp_ref_set(p_config->reference); - - //If external source is chosen, write to appropriate register. - if (p_config->reference == COMP_REFSEL_REFSEL_ARef) - { - nrf_comp_ext_ref_set(p_config->ext_ref); - } - - nrf_comp_th_set(p_config->threshold); - nrf_comp_main_mode_set(p_config->main_mode); - nrf_comp_speed_mode_set(p_config->speed_mode); - nrf_comp_hysteresis_set(p_config->hyst); -#if defined (COMP_ISOURCE_ISOURCE_Msk) - nrf_comp_isource_set(p_config->isource); -#endif - nrf_comp_shorts_disable(NRF_DRV_COMP_SHORT_STOP_AFTER_CROSS_EVT | NRF_DRV_COMP_SHORT_STOP_AFTER_UP_EVT | - NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT); - nrf_comp_int_disable(COMP_INTENCLR_CROSS_Msk | COMP_INTENCLR_UP_Msk | - COMP_INTENCLR_DOWN_Msk | COMP_INTENCLR_READY_Msk); - - if (event_handler) - { - m_comp_events_handler = event_handler; - } - else - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - nrf_comp_input_select(p_config->input); - - nrf_drv_common_irq_enable(COMP_LPCOMP_IRQn, p_config->interrupt_priority); - - m_state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_comp_uninit(void) -{ - ASSERT(m_state != NRF_DRV_STATE_UNINITIALIZED); - nrf_drv_common_irq_disable(COMP_LPCOMP_IRQn); - nrf_comp_disable(); -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - nrf_drv_common_per_res_release(NRF_COMP); -#endif - m_state = NRF_DRV_STATE_UNINITIALIZED; - m_comp_events_handler = NULL; - NRF_LOG_INFO("Uninitialized."); -} - -void nrf_drv_comp_pin_select(nrf_comp_input_t psel) -{ - bool comp_enable_state = nrf_comp_enable_check(); - nrf_comp_task_trigger(NRF_COMP_TASK_STOP); - if (m_state == NRF_DRV_STATE_POWERED_ON) - { - m_state = NRF_DRV_STATE_INITIALIZED; - } - nrf_comp_disable(); - nrf_comp_input_select(psel); - if (comp_enable_state == true) - { - nrf_comp_enable(); - } -} - -void nrf_drv_comp_start(uint32_t comp_int_mask, uint32_t comp_shorts_mask) -{ - ASSERT(m_state == NRF_DRV_STATE_INITIALIZED); - nrf_comp_int_enable(comp_int_mask); - nrf_comp_shorts_enable(comp_shorts_mask); - nrf_comp_task_trigger(NRF_COMP_TASK_START); - m_state = NRF_DRV_STATE_POWERED_ON; - NRF_LOG_INFO("Enabled."); -} - -void nrf_drv_comp_stop(void) -{ - ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); - nrf_comp_shorts_disable(UINT32_MAX); - nrf_comp_int_disable(UINT32_MAX); - nrf_comp_task_trigger(NRF_COMP_TASK_STOP); - m_state = NRF_DRV_STATE_INITIALIZED; - NRF_LOG_INFO("Disabled."); -} - -uint32_t nrf_drv_comp_sample() -{ - ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); - nrf_comp_task_trigger(NRF_COMP_TASK_SAMPLE); - return nrf_comp_result_get(); -} -#endif //NRF_MODULE_ENABLED(COMP) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.h deleted file mode 100644 index 3c03c1d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/comp/nrf_drv_comp.h +++ /dev/null @@ -1,258 +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 NRF_DRV_COMP_H__ -#define NRF_DRV_COMP_H__ - -#include "sdk_config.h" -#include "nrf_comp.h" -#include "sdk_errors.h" -#include "nrf_drv_common.h" -#include "app_util_platform.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup nrf_comp COMP HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Comparator (COMP) APIs. - * @details The COMP HAL provides basic APIs for accessing the registers of Comparator. - * The COMP driver provides APIs on a higher level. - * - * @defgroup nrf_drv_comp COMP driver - * @{ - * @ingroup nrf_comp - * @brief @tagAPI52 Comparator (COMP) driver. - */ - -/** - * @brief Macro to convert the threshold voltage to an integer value (needed by the COMP_TH register). - * - * @param[in] vol Voltage to be changed to COMP_TH register value. This value must not be smaller than - * reference voltage divided by 64. - * @param[in] ref Reference voltage. - */ -#define VOLTAGE_THRESHOLD_TO_INT(vol, ref) (uint8_t)(((vol) > ((ref) / 64)) ? (ROUNDED_DIV((vol) * 64,(ref)) - 1) : 0) - -/**@brief COMP event handler function type. - * @param[in] event COMP event. - */ -typedef void (* comp_events_handler_t)(nrf_comp_event_t event); - -/** - * @enum nrf_drv_comp_short_mask_t - * @brief COMP shortcut masks. - */ -typedef enum -{ - NRF_DRV_COMP_SHORT_STOP_AFTER_CROSS_EVT = COMP_SHORTS_CROSS_STOP_Msk, /*!< Shortcut between the CROSS event and the STOP task. */ - NRF_DRV_COMP_SHORT_STOP_AFTER_UP_EVT = COMP_SHORTS_UP_STOP_Msk, /*!< Shortcut between the UP event and the STOP task. */ - NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT = COMP_SHORTS_DOWN_STOP_Msk /*!< Shortcut between the DOWN event and the STOP task. */ -}nrf_drv_comp_short_mask_t; - -/** - * @enum nrf_drv_comp_evt_en_mask_t - * @brief COMP events masks. - */ -typedef enum -{ - NRF_DRV_COMP_EVT_EN_CROSS_MASK = COMP_INTENSET_CROSS_Msk, /*!< CROSS event (generated after VIN+ == VIN-). */ - NRF_DRV_COMP_EVT_EN_UP_MASK = COMP_INTENSET_UP_Msk, /*!< UP event (generated when VIN+ crosses VIN- while increasing). */ - NRF_DRV_COMP_EVT_EN_DOWN_MASK = COMP_INTENSET_DOWN_Msk, /*!< DOWN event (generated when VIN+ crosses VIN- while decreasing). */ - NRF_DRV_COMP_EVT_EN_READY_MASK = COMP_INTENSET_READY_Msk /*!< READY event (generated when the module is ready). */ -}nrf_drv_comp_evt_en_mask_t; - -/**@brief COMP configuration. - */ -typedef struct -{ - nrf_comp_ref_t reference; /**< Reference selection. */ - nrf_comp_ext_ref_t ext_ref; /**< External analog reference selection. */ - nrf_comp_main_mode_t main_mode; /**< Main operation mode. */ - nrf_comp_th_t threshold; /**< Structure holding THDOWN and THUP values needed by the COMP_TH register. */ - nrf_comp_sp_mode_t speed_mode; /**< Speed and power mode. */ - nrf_comp_hyst_t hyst; /**< Comparator hysteresis.*/ -#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__SDK_DOXYGEN__) - nrf_isource_t isource; /**< Current source selected on analog input. */ -#endif - nrf_comp_input_t input; /**< Input to be monitored. */ - uint8_t interrupt_priority; /**< Interrupt priority. */ -} nrf_drv_comp_config_t; - -/** @brief COMP threshold default configuration. */ -#define COMP_CONFIG_TH \ -{ \ - .th_down = VOLTAGE_THRESHOLD_TO_INT(0.5, 1.8), \ - .th_up = VOLTAGE_THRESHOLD_TO_INT(1.5, 1.8) \ -} - -/** @brief COMP driver default configuration including the COMP HAL configuration. */ -#if defined (COMP_ISOURCE_ISOURCE_Msk) -#define NRF_DRV_COMP_DEFAULT_CONFIG(INPUT) \ -{ \ - .reference = (nrf_comp_ref_t)COMP_CONFIG_REF, \ - .main_mode = (nrf_comp_main_mode_t)COMP_CONFIG_MAIN_MODE, \ - .threshold = COMP_CONFIG_TH, \ - .speed_mode = (nrf_comp_sp_mode_t)COMP_CONFIG_SPEED_MODE, \ - .hyst = (nrf_comp_hyst_t)COMP_CONFIG_HYST, \ - .isource = (nrf_isource_t)COMP_CONFIG_ISOURCE, \ - .input = (nrf_comp_input_t)INPUT, \ - .interrupt_priority = COMP_CONFIG_IRQ_PRIORITY \ -} -#else -#define NRF_DRV_COMP_DEFAULT_CONFIG(INPUT) \ -{ \ - .reference = (nrf_comp_ref_t)COMP_CONFIG_REF, \ - .main_mode = (nrf_comp_main_mode_t)COMP_CONFIG_MAIN_MODE, \ - .threshold = COMP_CONFIG_TH, \ - .speed_mode = (nrf_comp_sp_mode_t)COMP_CONFIG_SPEED_MODE, \ - .hyst = (nrf_comp_hyst_t)COMP_CONFIG_HYST, \ - .input = (nrf_comp_input_t)INPUT, \ - .interrupt_priority = COMP_CONFIG_IRQ_PRIORITY \ -} -#endif - -/** - * @brief Function for initializing the COMP driver. - * - * This function initializes the COMP driver, but does not enable the peripheral or any interrupts. - * To start the driver, call the function @ref nrf_drv_comp_start() after initialization. - * - * If no configuration structure is provided, the driver is initialized with the default settings. - * - * @param[in] p_config Initial configuration. If NULL, the default configuration is used. - * @param[in] event_handler Handler function. - * - * @retval NRF_ERROR_INVALID_PARAM If the configuration is invalid. - * @retval NRF_ERROR_INVALID_STATE If the driver has already been initialized. - * @retval NRF_ERROR_BUSY If the LPCOMP driver is initialized. - */ -ret_code_t nrf_drv_comp_init(const nrf_drv_comp_config_t * p_config, - comp_events_handler_t event_handler); - - -/** - * @brief Function for uninitializing the COMP driver. - * - * This function uninitializes the COMP driver. The COMP peripheral and - * its interrupts are disabled, and local variables are cleaned. After this call, you must - * initialize the driver again by calling nrf_drv_comp_init() if you want to use it. - * - * @sa nrf_drv_comp_stop() - */ -void nrf_drv_comp_uninit(void); - -/** - * @brief Function for setting the analog input. - * - * @param[in] psel COMP analog pin selection. - */ -void nrf_drv_comp_pin_select(nrf_comp_input_t psel); - -/** - * @brief Function for starting the COMP peripheral and interrupts. - * - * Before calling this function, the driver must be initialized. This function - * enables the COMP peripheral and its interrupts. - * - * @param[in] comp_evt_en_mask Mask of events to be enabled. This parameter should be built as - * 'or' of elements from @ref nrf_drv_comp_evt_en_mask_t. - * @param[in] comp_shorts_mask Mask of shorts to be enabled. This parameter should be built as - * 'or' of elements from @ref nrf_drv_comp_short_mask_t. - * - * @sa nrf_drv_comp_init() - * - */ -void nrf_drv_comp_start(uint32_t comp_evt_en_mask, uint32_t comp_shorts_mask); - -/**@brief Function for stopping the COMP peripheral. - * - * Before calling this function, the driver must be enabled. This function disables the COMP - * peripheral and its interrupts. - * - * @sa nrf_drv_comp_uninit() - * - */ -void nrf_drv_comp_stop(void); - -/** - * @brief Function for copying the current state of the comparator result to the RESULT register. - * - * @retval 0 If the input voltage is below the threshold (VIN+ < VIN-). - * @retval 1 If the input voltage is above the threshold (VIN+ > VIN-). - */ -uint32_t nrf_drv_comp_sample(void); - -/** - * @brief Function for getting the task address. - * - * Before calling this function, the driver must be enabled. - * - * @param[in] comp_task COMP task. - * - * @return Address of the given COMP task. - */ -__STATIC_INLINE uint32_t nrf_drv_comp_task_address_get(nrf_comp_task_t comp_task) -{ - return (uint32_t)nrf_comp_task_address_get(comp_task); -} - -/** - * @brief Function for getting the event address. - * - * @param[in] comp_event COMP event. - * - * @return Address of the given COMP event. - */ -__STATIC_INLINE uint32_t nrf_drv_comp_event_address_get(nrf_comp_event_t comp_event) -{ - return (uint32_t)nrf_comp_event_address_get(comp_event); -} - -/** - *@} - **/ - - -#ifdef __cplusplus -} -#endif -#endif /* NRF_DRV_COMP_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/delay/nrf_delay.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/delay/nrf_delay.h deleted file mode 100644 index 0a62f7d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/delay/nrf_delay.h +++ /dev/null @@ -1,269 +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 _NRF_DELAY_H -#define _NRF_DELAY_H - -#include "nrf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define CLOCK_FREQ_16MHz (16000000UL) - -#ifdef NRF52_SERIES - #define CPU_FREQ_64MHz -#endif - -/** - * @brief Function for delaying execution for number of microseconds. - * - * @note NRF52 has instruction cache and because of that delay is not precise. - * - * @param number_of_us - * - */ -/*lint -e{438, 522, 40, 10, 563} */ -__STATIC_INLINE void nrf_delay_us(uint32_t number_of_us); - - -/** - * @brief Function for delaying execution for number of miliseconds. - * - * @note NRF52 has instruction cache and because of that delay is not precise. - * - * @note Function internally calls @ref nrf_delay_us so the maximum delay is the - * same as in case of @ref nrf_delay_us, approx. 71 minutes. - * - * @param number_of_ms - * - */ - -/*lint -e{438, 522, 40, 10, 563} */ -__STATIC_INLINE void nrf_delay_ms(uint32_t number_of_ms); - -#if defined ( __CC_ARM ) -__STATIC_INLINE void nrf_delay_us(uint32_t number_of_us) -{ - if (!number_of_us) - return; -__asm - { -loop: - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - CMP SystemCoreClock, CLOCK_FREQ_16MHz - BEQ cond - NOP -#ifdef CPU_FREQ_64MHz - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP -#endif //CPU_FREQ_64MHz -cond: - SUBS number_of_us, #1 - BNE loop - } -} - -#elif defined ( _WIN32 ) || defined ( __unix ) || defined( __APPLE__ ) - - -#ifndef CUSTOM_NRF_DELAY_US -__STATIC_INLINE void nrf_delay_us(uint32_t number_of_us) -{} -#endif - -#elif defined ( __GNUC__ ) || ( __ICCARM__ ) - -__STATIC_INLINE void nrf_delay_us(uint32_t number_of_us) -{ - const uint32_t clock16MHz = CLOCK_FREQ_16MHz; - if (number_of_us) - { -__ASM volatile ( -#if ( defined(__GNUC__) && (__CORTEX_M == (0x00U) ) ) - ".syntax unified\n" -#endif -"1:\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " CMP %[SystemCoreClock], %[clock16MHz]\n" - " BEQ.N 2f\n" - " NOP\n" -#ifdef CPU_FREQ_64MHz - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" -#endif //CPU_FREQ_64MHz -"2:\n" - " SUBS %[number_of_us], %[number_of_us], #1\n" - " BNE.N 1b\n" -#if ( defined(__GNUC__) && (__CORTEX_M == (0x00U) ) ) - ".syntax divided\n" -#endif -#if ( __CORTEX_M == (0x00U) ) - // The SUBS instruction in Cortex-M0 is available only in 16-bit encoding, - // hence it requires a "lo" register (r0-r7) as an operand. - : [number_of_us] "=l" (number_of_us) -#else - : [number_of_us] "=r" (number_of_us) -#endif - : [SystemCoreClock] "r" (SystemCoreClock), - [clock16MHz] "r" (clock16MHz), - "[number_of_us]" (number_of_us) - : "cc" - ); - } -} -#endif - -__STATIC_INLINE void nrf_delay_ms(uint32_t number_of_ms) -{ - nrf_delay_us(1000*number_of_ms); -} - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/gpiote/nrf_drv_gpiote.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/gpiote/nrf_drv_gpiote.h deleted file mode 100644 index 6c5f627..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/gpiote/nrf_drv_gpiote.h +++ /dev/null @@ -1,385 +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 NRF_DRV_GPIOTE__ -#define NRF_DRV_GPIOTE__ - -/** - * @addtogroup nrf_gpiote GPIOTE abstraction and driver - * @ingroup nrf_drivers - * @brief GPIOTE APIs. - * @defgroup nrf_drv_gpiote GPIOTE driver - * @{ - * @ingroup nrf_gpiote - * @brief GPIOTE driver for managing input and output pins. - */ - -#include "nrf_gpiote.h" -#include "nrf_gpio.h" -#include "sdk_errors.h" -#include -#include -#include "sdk_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Input pin configuration. */ -typedef struct -{ - nrf_gpiote_polarity_t sense; /**< Transition that triggers interrupt. */ - nrf_gpio_pin_pull_t pull; /**< Pulling mode. */ - bool is_watcher; /**< True when the input pin is tracking an output pin. */ - bool hi_accuracy;/**< True when high accuracy (IN_EVENT) is used. */ -} nrf_drv_gpiote_in_config_t; - -/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect low-to-high transition. - * @details Set hi_accu to true to use IN_EVENT. */ -#define GPIOTE_CONFIG_IN_SENSE_LOTOHI(hi_accu) \ - { \ - .is_watcher = false, \ - .hi_accuracy = hi_accu, \ - .pull = NRF_GPIO_PIN_NOPULL, \ - .sense = NRF_GPIOTE_POLARITY_LOTOHI, \ - } - -/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect high-to-low transition. - * @details Set hi_accu to true to use IN_EVENT. */ -#define GPIOTE_CONFIG_IN_SENSE_HITOLO(hi_accu) \ - { \ - .is_watcher = false, \ - .hi_accuracy = hi_accu, \ - .pull = NRF_GPIO_PIN_NOPULL, \ - .sense = NRF_GPIOTE_POLARITY_HITOLO, \ - } - -/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect any change on the pin. - * @details Set hi_accu to true to use IN_EVENT.*/ -#define GPIOTE_CONFIG_IN_SENSE_TOGGLE(hi_accu) \ - { \ - .is_watcher = false, \ - .hi_accuracy = hi_accu, \ - .pull = NRF_GPIO_PIN_NOPULL, \ - .sense = NRF_GPIOTE_POLARITY_TOGGLE, \ - } - -/**@brief Output pin configuration. */ -typedef struct -{ - nrf_gpiote_polarity_t action; /**< Configuration of the pin task. */ - nrf_gpiote_outinit_t init_state; /**< Initial state of the output pin. */ - bool task_pin; /**< True if the pin is controlled by a GPIOTE task. */ -} nrf_drv_gpiote_out_config_t; - -/**@brief Macro for configuring a pin to use as output. GPIOTE is not used for the pin. */ -#define GPIOTE_CONFIG_OUT_SIMPLE(init_high) \ - { \ - .init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \ - .task_pin = false, \ - } - -/**@brief Macro for configuring a pin to use the GPIO OUT TASK to change the state from high to low. - * @details The task will clear the pin. Therefore, the pin is set initially. */ -#define GPIOTE_CONFIG_OUT_TASK_LOW \ - { \ - .init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH, \ - .task_pin = true, \ - .action = NRF_GPIOTE_POLARITY_HITOLO, \ - } - -/**@brief Macro for configuring a pin to use the GPIO OUT TASK to change the state from low to high. - * @details The task will set the pin. Therefore, the pin is cleared initially. */ -#define GPIOTE_CONFIG_OUT_TASK_HIGH \ - { \ - .init_state = NRF_GPIOTE_INITIAL_VALUE_LOW, \ - .task_pin = true, \ - .action = NRF_GPIOTE_POLARITY_LOTOHI, \ - } - -/**@brief Macro for configuring a pin to use the GPIO OUT TASK to toggle the pin state. - * @details The initial pin state must be provided. */ -#define GPIOTE_CONFIG_OUT_TASK_TOGGLE(init_high) \ - { \ - .init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \ - .task_pin = true, \ - .action = NRF_GPIOTE_POLARITY_TOGGLE, \ - } - -/** @brief Pin. */ -typedef uint32_t nrf_drv_gpiote_pin_t; - -/** - * @brief Pin event handler prototype. - * @param pin Pin that triggered this event. - * @param action Action that lead to triggering this event. - */ -typedef void (*nrf_drv_gpiote_evt_handler_t)(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action); - -/** - * @brief Function for initializing the GPIOTE module. - * - * @details Only static configuration is supported to prevent the shared - * resource being customized by the initiator. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. - */ -ret_code_t nrf_drv_gpiote_init(void); - -/** - * @brief Function for checking if the GPIOTE module is initialized. - * - * @details The GPIOTE module is a shared module. Therefore, you should check if - * the module is already initialized and skip initialization if it is. - * - * @retval true If the module is already initialized. - * @retval false If the module is not initialized. - */ -bool nrf_drv_gpiote_is_init(void); - -/** - * @brief Function for uninitializing the GPIOTE module. - */ -void nrf_drv_gpiote_uninit(void); - -/** - * @brief Function for initializing a GPIOTE output pin. - * @details The output pin can be controlled by the CPU or by PPI. The initial - * configuration specifies which mode is used. If PPI mode is used, the driver - * attempts to allocate one of the available GPIOTE channels. If no channel is - * available, an error is returned. - * - * @param[in] pin Pin. - * @param[in] p_config Initial configuration. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used. - * @retval NRF_ERROR_NO_MEM If no GPIOTE channel is available. - */ -ret_code_t nrf_drv_gpiote_out_init(nrf_drv_gpiote_pin_t pin, - nrf_drv_gpiote_out_config_t const * p_config); - -/** - * @brief Function for uninitializing a GPIOTE output pin. - * @details The driver frees the GPIOTE channel if the output pin was using one. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_uninit(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for setting a GPIOTE output pin. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_set(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for clearing a GPIOTE output pin. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_clear(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for toggling a GPIOTE output pin. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_toggle(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for enabling a GPIOTE output pin task. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_task_enable(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for disabling a GPIOTE output pin task. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_task_disable(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for getting the address of a configurable GPIOTE task. - * - * @param[in] pin Pin. - * - * @return Address of OUT task. - */ -uint32_t nrf_drv_gpiote_out_task_addr_get(nrf_drv_gpiote_pin_t pin); - -#if defined(GPIOTE_FEATURE_SET_PRESENT) -/** - * @brief Function for getting the address of a configurable GPIOTE task. - * - * @param[in] pin Pin. - * - * @return Address of SET task. - */ -uint32_t nrf_drv_gpiote_set_task_addr_get(nrf_drv_gpiote_pin_t pin); -#endif // defined(GPIOTE_FEATURE_SET_PRESENT) - -#if defined(GPIOTE_FEATURE_CLR_PRESENT) -/** - * @brief Function for getting the address of a configurable GPIOTE task. - * - * @param[in] pin Pin. - * - * @return Address of CLR task. - */ -uint32_t nrf_drv_gpiote_clr_task_addr_get(nrf_drv_gpiote_pin_t pin); -#endif // defined(GPIOTE_FEATURE_CLR_PRESENT) - -/** - * @brief Function for initializing a GPIOTE input pin. - * @details The input pin can act in two ways: - * - lower accuracy but low power (high frequency clock not needed) - * - higher accuracy (high frequency clock required) - * - * The initial configuration specifies which mode is used. - * If high-accuracy mode is used, the driver attempts to allocate one - * of the available GPIOTE channels. If no channel is - * available, an error is returned. - * In low accuracy mode SENSE feature is used. In this case only one active pin - * can be detected at a time. It can be worked around by setting all of the used - * low accuracy pins to toggle mode. - * For more information about SENSE functionality, refer to Product Specification. - * - * @param[in] pin Pin. - * @param[in] p_config Initial configuration. - * @param[in] evt_handler User function to be called when the configured transition occurs. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used. - * @retval NRF_ERROR_NO_MEM If no GPIOTE channel is available. - */ -ret_code_t nrf_drv_gpiote_in_init(nrf_drv_gpiote_pin_t pin, - nrf_drv_gpiote_in_config_t const * p_config, - nrf_drv_gpiote_evt_handler_t evt_handler); - -/** - * @brief Function for uninitializing a GPIOTE input pin. - * @details The driver frees the GPIOTE channel if the input pin was using one. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_in_uninit(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for enabling sensing of a GPIOTE input pin. - * - * @details If the input pin is configured as high-accuracy pin, the function - * enables an IN_EVENT. Otherwise, the function enables the GPIO sense mechanism. - * Note that a PORT event is shared between multiple pins, therefore the - * interrupt is always enabled. - * - * @param[in] pin Pin. - * @param[in] int_enable True to enable the interrupt. Always valid for a high-accuracy pin. - */ -void nrf_drv_gpiote_in_event_enable(nrf_drv_gpiote_pin_t pin, bool int_enable); - -/** - * @brief Function for disabling a GPIOTE input pin. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_in_event_disable(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for checking if a GPIOTE input pin is set. - * - * @param[in] pin Pin. - * @retval true If the input pin is set. - * @retval false If the input pin is not set. - */ -bool nrf_drv_gpiote_in_is_set(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for getting the address of a GPIOTE input pin event. - * @details If the pin is configured to use low-accuracy mode, the address of the PORT event is returned. - * - * @param[in] pin Pin. - */ -uint32_t nrf_drv_gpiote_in_event_addr_get(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for forcing a specific state on the pin configured as task. - * - * @param[in] pin Pin. - * @param[in] state Pin state. - */ -void nrf_drv_gpiote_out_task_force(nrf_drv_gpiote_pin_t pin, uint8_t state); - -/** - * @brief Function for triggering the task OUT manually. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_out_task_trigger(nrf_drv_gpiote_pin_t pin); - -#ifdef NRF52_SERIES -/** - * @brief Function for triggering the task SET manually. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_set_task_trigger(nrf_drv_gpiote_pin_t pin); - -/** - * @brief Function for triggering the task CLR manually. - * - * @param[in] pin Pin. - */ -void nrf_drv_gpiote_clr_task_trigger(nrf_drv_gpiote_pin_t pin); -#endif - -/** - *@} - **/ - - -#ifdef __cplusplus -} -#endif - -#endif //NRF_DRV_GPIOTE__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_clock.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_clock.h deleted file mode 100644 index 50a7271..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_clock.h +++ /dev/null @@ -1,401 +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 NRF_CLOCK_H__ -#define NRF_CLOCK_H__ - -#include -#include - -#include "nrf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup nrf_clock_hal Clock HAL - * @{ - * @ingroup nrf_clock - * @brief Hardware access layer for managing the low-frequency clock (LFCLK) and the high-frequency clock (HFCLK). - */ - -#define NRF_CLOCK_TASK_TRIGGER (1UL) -#define NRF_CLOCK_EVENT_CLEAR (0UL) - -/** - * @brief Low-frequency clock sources. - * @details Used by LFCLKSRC, LFCLKSTAT, and LFCLKSRCCOPY registers. - */ -typedef enum -{ - NRF_CLOCK_LFCLK_RC = CLOCK_LFCLKSRC_SRC_RC, /**< Internal 32 kHz RC oscillator. */ - NRF_CLOCK_LFCLK_Xtal = CLOCK_LFCLKSRC_SRC_Xtal, /**< External 32 kHz crystal. */ - NRF_CLOCK_LFCLK_Synth = CLOCK_LFCLKSRC_SRC_Synth /**< Internal 32 kHz synthesizer from HFCLK system clock. */ -} nrf_clock_lfclk_t; - -/** - * @brief High-frequency clock sources. - */ -typedef enum -{ - NRF_CLOCK_HFCLK_LOW_ACCURACY = CLOCK_HFCLKSTAT_SRC_RC, /**< Internal 16 MHz RC oscillator. */ - NRF_CLOCK_HFCLK_HIGH_ACCURACY = CLOCK_HFCLKSTAT_SRC_Xtal /**< External 16 MHz/32 MHz crystal oscillator. */ -} nrf_clock_hfclk_t; - -/** - * @brief Trigger status of task LFCLKSTART/HFCLKSTART. - * @details Used by LFCLKRUN and HFCLKRUN registers. - */ -typedef enum -{ - NRF_CLOCK_START_TASK_NOT_TRIGGERED = CLOCK_LFCLKRUN_STATUS_NotTriggered, /**< Task LFCLKSTART/HFCLKSTART has not been triggered. */ - NRF_CLOCK_START_TASK_TRIGGERED = CLOCK_LFCLKRUN_STATUS_Triggered /**< Task LFCLKSTART/HFCLKSTART has been triggered. */ -} nrf_clock_start_task_status_t; - -/** - * @brief Interrupts. - */ -typedef enum -{ - NRF_CLOCK_INT_HF_STARTED_MASK = CLOCK_INTENSET_HFCLKSTARTED_Msk, /**< Interrupt on HFCLKSTARTED event. */ - NRF_CLOCK_INT_LF_STARTED_MASK = CLOCK_INTENSET_LFCLKSTARTED_Msk, /**< Interrupt on LFCLKSTARTED event. */ - NRF_CLOCK_INT_DONE_MASK = CLOCK_INTENSET_DONE_Msk, /**< Interrupt on DONE event. */ - NRF_CLOCK_INT_CTTO_MASK = CLOCK_INTENSET_CTTO_Msk /**< Interrupt on CTTO event. */ -} nrf_clock_int_mask_t; - -/** - * @brief Tasks. - * - * @details The NRF_CLOCK_TASK_LFCLKSTOP task cannot be set when the low-frequency clock is not running. - * The NRF_CLOCK_TASK_HFCLKSTOP task cannot be set when the high-frequency clock is not running. - */ -typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */ -{ - NRF_CLOCK_TASK_HFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTART), /**< Start HFCLK clock source.*/ - NRF_CLOCK_TASK_HFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTOP), /**< Stop HFCLK clock source.*/ - NRF_CLOCK_TASK_LFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTART), /**< Start LFCLK clock source.*/ - NRF_CLOCK_TASK_LFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTOP), /**< Stop LFCLK clock source.*/ - NRF_CLOCK_TASK_CAL = offsetof(NRF_CLOCK_Type, TASKS_CAL), /**< Start calibration of LFCLK RC oscillator.*/ - NRF_CLOCK_TASK_CTSTART = offsetof(NRF_CLOCK_Type, TASKS_CTSTART), /**< Start calibration timer.*/ - NRF_CLOCK_TASK_CTSTOP = offsetof(NRF_CLOCK_Type, TASKS_CTSTOP) /**< Stop calibration timer.*/ -} nrf_clock_task_t; /*lint -restore */ - -/** - * @brief Events. - */ -typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */ -{ - NRF_CLOCK_EVENT_HFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLKSTARTED), /**< HFCLK oscillator started.*/ - NRF_CLOCK_EVENT_LFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_LFCLKSTARTED), /**< LFCLK oscillator started.*/ - NRF_CLOCK_EVENT_DONE = offsetof(NRF_CLOCK_Type, EVENTS_DONE), /**< Calibration of LFCLK RC oscillator completed.*/ - NRF_CLOCK_EVENT_CTTO = offsetof(NRF_CLOCK_Type, EVENTS_CTTO) /**< Calibration timer time-out.*/ -} nrf_clock_event_t; /*lint -restore */ - -/** - * @brief Function for enabling a specific interrupt. - * - * @param[in] int_mask Interrupt. - */ -__STATIC_INLINE void nrf_clock_int_enable(uint32_t int_mask); - -/** - * @brief Function for disabling a specific interrupt. - * - * @param[in] int_mask Interrupt. - */ -__STATIC_INLINE void nrf_clock_int_disable(uint32_t int_mask); - -/** - * @brief Function for retrieving the state of a specific interrupt. - * - * @param[in] int_mask Interrupt. - * - * @retval true If the interrupt is enabled. - * @retval false If the interrupt is not enabled. - */ -__STATIC_INLINE bool nrf_clock_int_enable_check(nrf_clock_int_mask_t int_mask); - -/** - * @brief Function for retrieving the address of a specific task. - * @details This function can be used by the PPI module. - * - * @param[in] task Task. - * - * @return Address of the requested task register. - */ -__STATIC_INLINE uint32_t nrf_clock_task_address_get(nrf_clock_task_t task); - -/** - * @brief Function for setting a specific task. - * - * @param[in] task Task. - */ -__STATIC_INLINE void nrf_clock_task_trigger(nrf_clock_task_t task); - -/** - * @brief Function for retrieving the address of a specific event. - * @details This function can be used by the PPI module. - * - * @param[in] event Event. - * - * @return Address of the requested event register. - */ -__STATIC_INLINE uint32_t nrf_clock_event_address_get(nrf_clock_event_t event); - -/** - * @brief Function for clearing a specific event. - * - * @param[in] event Event. - */ -__STATIC_INLINE void nrf_clock_event_clear(nrf_clock_event_t event); - -/** - * @brief Function for retrieving the state of a specific event. - * - * @param[in] event Event. - * - * @retval true If the event is set. - * @retval false If the event is not set. - */ -__STATIC_INLINE bool nrf_clock_event_check(nrf_clock_event_t event); - -/** - * @brief Function for changing the low-frequency clock source. - * @details This function cannot be called when the low-frequency clock is running. - * - * @param[in] source New low-frequency clock source. - * - */ -__STATIC_INLINE void nrf_clock_lf_src_set(nrf_clock_lfclk_t source); - -/** - * @brief Function for retrieving the selected source for the low-frequency clock. - * - * @retval NRF_CLOCK_LFCLK_RC If the internal 32 kHz RC oscillator is the selected source for the low-frequency clock. - * @retval NRF_CLOCK_LFCLK_Xtal If an external 32 kHz crystal oscillator is the selected source for the low-frequency clock. - * @retval NRF_CLOCK_LFCLK_Synth If the internal 32 kHz synthesizer from the HFCLK is the selected source for the low-frequency clock. - */ -__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(void); - -/** - * @brief Function for retrieving the active source of the low-frequency clock. - * - * @retval NRF_CLOCK_LFCLK_RC If the internal 32 kHz RC oscillator is the active source of the low-frequency clock. - * @retval NRF_CLOCK_LFCLK_Xtal If an external 32 kHz crystal oscillator is the active source of the low-frequency clock. - * @retval NRF_CLOCK_LFCLK_Synth If the internal 32 kHz synthesizer from the HFCLK is the active source of the low-frequency clock. - */ -__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_actv_src_get(void); - -/** - * @brief Function for retrieving the clock source for the LFCLK clock when the task LKCLKSTART is triggered. - * - * @retval NRF_CLOCK_LFCLK_RC If the internal 32 kHz RC oscillator is running and generating the LFCLK clock. - * @retval NRF_CLOCK_LFCLK_Xtal If an external 32 kHz crystal oscillator is running and generating the LFCLK clock. - * @retval NRF_CLOCK_LFCLK_Synth If the internal 32 kHz synthesizer from the HFCLK is running and generating the LFCLK clock. - */ -__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(void); - -/** - * @brief Function for retrieving the state of the LFCLK clock. - * - * @retval false If the LFCLK clock is not running. - * @retval true If the LFCLK clock is running. - */ -__STATIC_INLINE bool nrf_clock_lf_is_running(void); - -/** - * @brief Function for retrieving the trigger status of the task LFCLKSTART. - * - * @retval NRF_CLOCK_START_TASK_NOT_TRIGGERED If the task LFCLKSTART has not been triggered. - * @retval NRF_CLOCK_START_TASK_TRIGGERED If the task LFCLKSTART has been triggered. - */ -__STATIC_INLINE nrf_clock_start_task_status_t nrf_clock_lf_start_task_status_get(void); - -/** - * @brief Function for retrieving the active source of the high-frequency clock. - * - * @retval NRF_CLOCK_HFCLK_LOW_ACCURACY If the internal 16 MHz RC oscillator is the active source of the high-frequency clock. - * @retval NRF_CLOCK_HFCLK_HIGH_ACCURACY If an external 16 MHz/32 MHz crystal oscillator is the active source of the high-frequency clock. - */ -__STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(void); - -/** - * @brief Function for retrieving the state of the HFCLK clock. - * - * @param[in] clk_src Clock source to be checked. - * - * @retval false If the HFCLK clock is not running. - * @retval true If the HFCLK clock is running. - */ -__STATIC_INLINE bool nrf_clock_hf_is_running(nrf_clock_hfclk_t clk_src); - -/** - * @brief Function for retrieving the trigger status of the task HFCLKSTART. - * - * @retval NRF_CLOCK_START_TASK_NOT_TRIGGERED If the task HFCLKSTART has not been triggered. - * @retval NRF_CLOCK_START_TASK_TRIGGERED If the task HFCLKSTART has been triggered. - */ -__STATIC_INLINE nrf_clock_start_task_status_t nrf_clock_hf_start_task_status_get(void); - -/** - * @brief Function for changing the calibration timer interval. - * - * @param[in] interval New calibration timer interval in 0.25 s resolution (range: 0.25 seconds to 31.75 seconds). - */ -__STATIC_INLINE void nrf_clock_cal_timer_timeout_set(uint32_t interval); - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_clock_int_enable(uint32_t int_mask) -{ - NRF_CLOCK->INTENSET = int_mask; -} - -__STATIC_INLINE void nrf_clock_int_disable(uint32_t int_mask) -{ - NRF_CLOCK->INTENCLR = int_mask; -} - -__STATIC_INLINE bool nrf_clock_int_enable_check(nrf_clock_int_mask_t int_mask) -{ - return (bool)(NRF_CLOCK->INTENCLR & int_mask); -} - -__STATIC_INLINE uint32_t nrf_clock_task_address_get(nrf_clock_task_t task) -{ - return ((uint32_t )NRF_CLOCK + task); -} - -__STATIC_INLINE void nrf_clock_task_trigger(nrf_clock_task_t task) -{ - *((volatile uint32_t *)((uint8_t *)NRF_CLOCK + task)) = NRF_CLOCK_TASK_TRIGGER; -} - -__STATIC_INLINE uint32_t nrf_clock_event_address_get(nrf_clock_event_t event) -{ - return ((uint32_t)NRF_CLOCK + event); -} - -__STATIC_INLINE void nrf_clock_event_clear(nrf_clock_event_t event) -{ - *((volatile uint32_t *)((uint8_t *)NRF_CLOCK + event)) = NRF_CLOCK_EVENT_CLEAR; -#if __CORTEX_M == 0x04 - volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_CLOCK + event)); - (void)dummy; -#endif -} - -__STATIC_INLINE bool nrf_clock_event_check(nrf_clock_event_t event) -{ - return (bool)*((volatile uint32_t *)((uint8_t *)NRF_CLOCK + event)); -} - -__STATIC_INLINE void nrf_clock_lf_src_set(nrf_clock_lfclk_t source) -{ - NRF_CLOCK->LFCLKSRC = - (uint32_t)((source << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); -} - -__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(void) -{ - return (nrf_clock_lfclk_t)((NRF_CLOCK->LFCLKSRC & - CLOCK_LFCLKSRC_SRC_Msk) >> CLOCK_LFCLKSRC_SRC_Pos); -} - -__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_actv_src_get(void) -{ - return (nrf_clock_lfclk_t)((NRF_CLOCK->LFCLKSTAT & - CLOCK_LFCLKSTAT_SRC_Msk) >> CLOCK_LFCLKSTAT_SRC_Pos); -} - -__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(void) -{ - return (nrf_clock_lfclk_t)((NRF_CLOCK->LFCLKSRCCOPY & - CLOCK_LFCLKSRCCOPY_SRC_Msk) >> CLOCK_LFCLKSRCCOPY_SRC_Pos); -} - -__STATIC_INLINE bool nrf_clock_lf_is_running(void) -{ - return ((NRF_CLOCK->LFCLKSTAT & - CLOCK_LFCLKSTAT_STATE_Msk) >> CLOCK_LFCLKSTAT_STATE_Pos); -} - -__STATIC_INLINE nrf_clock_start_task_status_t nrf_clock_lf_start_task_status_get(void) -{ - return (nrf_clock_start_task_status_t)((NRF_CLOCK->LFCLKRUN & - CLOCK_LFCLKRUN_STATUS_Msk) >> - CLOCK_LFCLKRUN_STATUS_Pos); -} - -__STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(void) -{ - return (nrf_clock_hfclk_t)((NRF_CLOCK->HFCLKSTAT & - CLOCK_HFCLKSTAT_SRC_Msk) >> CLOCK_HFCLKSTAT_SRC_Pos); -} - -__STATIC_INLINE bool nrf_clock_hf_is_running(nrf_clock_hfclk_t clk_src) -{ - return (NRF_CLOCK->HFCLKSTAT & (CLOCK_HFCLKSTAT_STATE_Msk | CLOCK_HFCLKSTAT_SRC_Msk)) == - (CLOCK_HFCLKSTAT_STATE_Msk | (clk_src << CLOCK_HFCLKSTAT_SRC_Pos)); -} - -__STATIC_INLINE nrf_clock_start_task_status_t nrf_clock_hf_start_task_status_get(void) -{ - return (nrf_clock_start_task_status_t)((NRF_CLOCK->HFCLKRUN & - CLOCK_HFCLKRUN_STATUS_Msk) >> - CLOCK_HFCLKRUN_STATUS_Pos); -} - -__STATIC_INLINE void nrf_clock_cal_timer_timeout_set(uint32_t interval) -{ - NRF_CLOCK->CTIV = ((interval << CLOCK_CTIV_CTIV_Pos) & CLOCK_CTIV_CTIV_Msk); -} - -#endif // SUPPRESS_INLINE_IMPLEMENTATION - -/** - *@} - **/ - -#ifdef __cplusplus -} -#endif - -#endif // NRF_CLOCK_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_comp.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_comp.h deleted file mode 100644 index 31e2ff3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_comp.h +++ /dev/null @@ -1,518 +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 - * @brief COMP HAL API. - */ - -#ifndef NRF_COMP_H_ -#define NRF_COMP_H_ - -/** - * @defgroup nrf_comp_hal COMP HAL - * @{ - * @ingroup nrf_comp - * @brief @tagAPI52 Hardware access layer for managing the Comparator (COMP). - */ - -#include "nrf.h" - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @enum nrf_comp_input_t - * @brief COMP analog pin selection. - */ -typedef enum -{ - NRF_COMP_INPUT_0 = COMP_PSEL_PSEL_AnalogInput0, /*!< AIN0 selected as analog input. */ - NRF_COMP_INPUT_1 = COMP_PSEL_PSEL_AnalogInput1, /*!< AIN1 selected as analog input. */ - NRF_COMP_INPUT_2 = COMP_PSEL_PSEL_AnalogInput2, /*!< AIN2 selected as analog input. */ - NRF_COMP_INPUT_3 = COMP_PSEL_PSEL_AnalogInput3, /*!< AIN3 selected as analog input. */ - NRF_COMP_INPUT_4 = COMP_PSEL_PSEL_AnalogInput4, /*!< AIN4 selected as analog input. */ - NRF_COMP_INPUT_5 = COMP_PSEL_PSEL_AnalogInput5, /*!< AIN5 selected as analog input. */ - NRF_COMP_INPUT_6 = COMP_PSEL_PSEL_AnalogInput6, /*!< AIN6 selected as analog input. */ -#if defined (COMP_PSEL_PSEL_AnalogInput7) || defined (__SDK_DOXYGEN__) - NRF_COMP_INPUT_7 = COMP_PSEL_PSEL_AnalogInput7, /*!< AIN7 selected as analog input. */ -#endif -#if defined (COMP_PSEL_PSEL_VddDiv2) || defined (__SDK_DOXYGEN__) - NRF_COMP_VDD_DIV2 = COMP_PSEL_PSEL_VddDiv2, /*!< VDD/2 selected as analog input. */ -#endif -}nrf_comp_input_t; - -/** - * @enum nrf_comp_ref_t - * @brief COMP reference selection. - */ -typedef enum -{ - NRF_COMP_REF_Int1V2 = COMP_REFSEL_REFSEL_Int1V2, /*!< VREF = internal 1.2 V reference (VDD >= 1.7 V). */ - NRF_COMP_REF_Int1V8 = COMP_REFSEL_REFSEL_Int1V8, /*!< VREF = internal 1.8 V reference (VDD >= VREF + 0.2 V). */ - NRF_COMP_REF_Int2V4 = COMP_REFSEL_REFSEL_Int2V4, /*!< VREF = internal 2.4 V reference (VDD >= VREF + 0.2 V). */ - NRF_COMP_REF_VDD = COMP_REFSEL_REFSEL_VDD, /*!< VREF = VDD. */ - NRF_COMP_REF_ARef = COMP_REFSEL_REFSEL_ARef /*!< VREF = AREF (VDD >= VREF >= AREFMIN). */ -}nrf_comp_ref_t; - -/** - * @enum nrf_comp_ext_ref_t - * @brief COMP external analog reference selection. - */ -typedef enum -{ - NRF_COMP_EXT_REF_0 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference0, /*!< Use AIN0 as external analog reference. */ - NRF_COMP_EXT_REF_1 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference1 /*!< Use AIN1 as external analog reference. */ -}nrf_comp_ext_ref_t; - -/** - * @brief COMP THDOWN and THUP values that are used to calculate the threshold voltages VDOWN and VUP. - */ -typedef struct -{ - uint8_t th_down; /*!< THDOWN value. */ - uint8_t th_up; /*!< THUP value. */ -}nrf_comp_th_t; - -/** - * @enum nrf_comp_main_mode_t - * @brief COMP main operation mode. - */ -typedef enum -{ - NRF_COMP_MAIN_MODE_SE = COMP_MODE_MAIN_SE, /*!< Single ended mode. */ - NRF_COMP_MAIN_MODE_Diff = COMP_MODE_MAIN_Diff /*!< Differential mode. */ -}nrf_comp_main_mode_t; - -/** - * @enum nrf_comp_sp_mode_t - * @brief COMP speed and power mode. - */ -typedef enum -{ - NRF_COMP_SP_MODE_Low = COMP_MODE_SP_Low, /*!< Low power mode. */ - NRF_COMP_SP_MODE_Normal = COMP_MODE_SP_Normal, /*!< Normal mode. */ - NRF_COMP_SP_MODE_High = COMP_MODE_SP_High /*!< High speed mode. */ -}nrf_comp_sp_mode_t; - -/** - * @enum nrf_comp_hyst_t - * @brief COMP comparator hysteresis. - */ -typedef enum -{ - NRF_COMP_HYST_NoHyst = COMP_HYST_HYST_NoHyst, /*!< Comparator hysteresis disabled. */ - NRF_COMP_HYST_50mV = COMP_HYST_HYST_Hyst50mV /*!< Comparator hysteresis enabled. */ -}nrf_comp_hyst_t; - -#if defined (COMP_ISOURCE_ISOURCE_Msk) -/** - * @brief COMP current source selection on analog input. - */ -typedef enum -{ - NRF_COMP_ISOURCE_Off = COMP_ISOURCE_ISOURCE_Off, /*!< Current source disabled. */ - NRF_COMP_ISOURCE_Ien2uA5 = COMP_ISOURCE_ISOURCE_Ien2mA5, /*!< Current source enabled (+/- 2.5 uA). */ - NRF_COMP_ISOURCE_Ien5uA = COMP_ISOURCE_ISOURCE_Ien5mA, /*!< Current source enabled (+/- 5 uA). */ - NRF_COMP_ISOURCE_Ien10uA = COMP_ISOURCE_ISOURCE_Ien10mA /*!< Current source enabled (+/- 10 uA). */ -}nrf_isource_t; -#endif - -/** - * @enum nrf_comp_task_t - * @brief COMP tasks. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_COMP_TASK_START = offsetof(NRF_COMP_Type, TASKS_START), /*!< COMP start sampling task. */ - NRF_COMP_TASK_STOP = offsetof(NRF_COMP_Type, TASKS_STOP), /*!< COMP stop sampling task. */ - NRF_COMP_TASK_SAMPLE = offsetof(NRF_COMP_Type, TASKS_SAMPLE) /*!< Sample comparator value. */ - /*lint -restore*/ -}nrf_comp_task_t; - -/** - * @enum nrf_comp_event_t - * @brief COMP events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_COMP_EVENT_READY = offsetof(NRF_COMP_Type, EVENTS_READY), /*!< COMP is ready and output is valid. */ - NRF_COMP_EVENT_DOWN = offsetof(NRF_COMP_Type, EVENTS_DOWN), /*!< Input voltage crossed the threshold going down. */ - NRF_COMP_EVENT_UP = offsetof(NRF_COMP_Type, EVENTS_UP), /*!< Input voltage crossed the threshold going up. */ - NRF_COMP_EVENT_CROSS = offsetof(NRF_COMP_Type, EVENTS_CROSS) /*!< Input voltage crossed the threshold in any direction. */ - /*lint -restore*/ -}nrf_comp_event_t; - -/** - * @brief COMP reference configuration. - */ -typedef struct -{ - nrf_comp_ref_t reference; /*!< COMP reference selection. */ - nrf_comp_ext_ref_t external; /*!< COMP external analog reference selection. */ -}nrf_comp_ref_conf_t; - - -/** - * @brief Function for enabling the COMP peripheral. - */ -__STATIC_INLINE void nrf_comp_enable(void); - - -/** - * @brief Function for disabling the COMP peripheral. - */ - -__STATIC_INLINE void nrf_comp_disable(void); - -/** - * @brief Function for checking if the COMP peripheral is enabled. - * - * @retval true If the COMP peripheral is enabled. - * @retval false If the COMP peripheral is not enabled. - */ -__STATIC_INLINE bool nrf_comp_enable_check(void); - -/** - * @brief Function for setting the reference source. - * - * @param[in] reference COMP reference selection. - */ -__STATIC_INLINE void nrf_comp_ref_set(nrf_comp_ref_t reference); - - -/** - * @brief Function for setting the external analog reference source. - * - * @param[in] ext_ref COMP external analog reference selection. - */ -__STATIC_INLINE void nrf_comp_ext_ref_set(nrf_comp_ext_ref_t ext_ref); - - -/** - * @brief Function for setting threshold voltages. - * - * @param[in] threshold COMP VDOWN and VUP thresholds. - */ -__STATIC_INLINE void nrf_comp_th_set(nrf_comp_th_t threshold); - - -/** - * @brief Function for setting the main mode. - * - * @param[in] main_mode COMP main operation mode. - */ -__STATIC_INLINE void nrf_comp_main_mode_set(nrf_comp_main_mode_t main_mode); - - -/** - * @brief Function for setting the speed mode. - * - * @param[in] speed_mode COMP speed and power mode. - */ -__STATIC_INLINE void nrf_comp_speed_mode_set(nrf_comp_sp_mode_t speed_mode); - - -/** - * @brief Function for setting the hysteresis. - * - * @param[in] hyst COMP comparator hysteresis. - */ -__STATIC_INLINE void nrf_comp_hysteresis_set(nrf_comp_hyst_t hyst); - -#if defined (COMP_ISOURCE_ISOURCE_Msk) -/** - * @brief Function for setting the current source on the analog input. - * - * @param[in] isource COMP current source selection on analog input. - */ -__STATIC_INLINE void nrf_comp_isource_set(nrf_isource_t isource); -#endif - -/** - * @brief Function for selecting the active input of the COMP. - * - * @param[in] input Input to be selected. - */ -__STATIC_INLINE void nrf_comp_input_select(nrf_comp_input_t input); - - -/** - * @brief Function for getting the last COMP compare result. - * - * @return The last compare result. If 0, then VIN+ < VIN-. If 1, then VIN+ > VIN-. - * - * @note If VIN+ == VIN-, the return value depends on the previous result. - */ -__STATIC_INLINE uint32_t nrf_comp_result_get(void); - - -/** - * @brief Function for enabling interrupts from COMP. - * - * @param[in] comp_int_mask Mask of interrupts to be enabled. - * - * @sa nrf_comp_int_enable_check() - */ -__STATIC_INLINE void nrf_comp_int_enable(uint32_t comp_int_mask); - -/** - * @brief Function for disabling interrupts from COMP. - * - * @param[in] comp_int_mask Mask of interrupts to be disabled. - * - * @sa nrf_comp_int_enable_check() - */ -__STATIC_INLINE void nrf_comp_int_disable(uint32_t comp_int_mask); - - -/** - * @brief Function for getting the enabled interrupts of COMP. - * - * @param[in] comp_int_mask Mask of interrupts to be checked. - * - * @retval true If any interrupts of the specified mask are enabled. - */ -__STATIC_INLINE bool nrf_comp_int_enable_check(uint32_t comp_int_mask); - - - -/** - * @brief Function for getting the address of a specific COMP task register. - * - * @param[in] comp_task COMP task. - * - * @return Address of the specified COMP task. - */ -__STATIC_INLINE uint32_t * nrf_comp_task_address_get(nrf_comp_task_t comp_task); - - -/** - * @brief Function for getting the address of a specific COMP event register. - * - * @param[in] comp_event COMP event. - * - * @return Address of the specified COMP event. - */ -__STATIC_INLINE uint32_t * nrf_comp_event_address_get(nrf_comp_event_t comp_event); - - -/** - * @brief Function for setting COMP shorts. - * - * @param[in] comp_short_mask COMP shorts by mask. - * - */ -__STATIC_INLINE void nrf_comp_shorts_enable(uint32_t comp_short_mask); - - -/** - * @brief Function for clearing COMP shorts by mask. - * - * @param[in] comp_short_mask COMP shorts to be cleared. - * - */ -__STATIC_INLINE void nrf_comp_shorts_disable(uint32_t comp_short_mask); - - -/** - * @brief Function for setting a specific COMP task. - * - * @param[in] comp_task COMP task to be set. - * - */ -__STATIC_INLINE void nrf_comp_task_trigger(nrf_comp_task_t comp_task); - - -/** - * @brief Function for clearing a specific COMP event. - * - * @param[in] comp_event COMP event to be cleared. - * - */ -__STATIC_INLINE void nrf_comp_event_clear(nrf_comp_event_t comp_event); - - -/** - * @brief Function for getting the state of a specific COMP event. - * - * @retval true If the specified COMP event is active. - * - */ -__STATIC_INLINE bool nrf_comp_event_check(nrf_comp_event_t comp_event); - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_comp_enable(void) -{ - NRF_COMP->ENABLE = (COMP_ENABLE_ENABLE_Enabled << COMP_ENABLE_ENABLE_Pos); -} - -__STATIC_INLINE void nrf_comp_disable(void) -{ - NRF_COMP->ENABLE = (COMP_ENABLE_ENABLE_Disabled << COMP_ENABLE_ENABLE_Pos); -} - -__STATIC_INLINE bool nrf_comp_enable_check(void) -{ - return ((NRF_COMP->ENABLE) & COMP_ENABLE_ENABLE_Enabled); -} - -__STATIC_INLINE void nrf_comp_ref_set(nrf_comp_ref_t reference) -{ - NRF_COMP->REFSEL = (reference << COMP_REFSEL_REFSEL_Pos); -} - -__STATIC_INLINE void nrf_comp_ext_ref_set(nrf_comp_ext_ref_t ext_ref) -{ - NRF_COMP->EXTREFSEL = (ext_ref << COMP_EXTREFSEL_EXTREFSEL_Pos); -} - -__STATIC_INLINE void nrf_comp_th_set(nrf_comp_th_t threshold) -{ - NRF_COMP->TH = - ((threshold.th_down << COMP_TH_THDOWN_Pos) & COMP_TH_THDOWN_Msk) | - ((threshold.th_up << COMP_TH_THUP_Pos) & COMP_TH_THUP_Msk); -} - -__STATIC_INLINE void nrf_comp_main_mode_set(nrf_comp_main_mode_t main_mode) -{ - NRF_COMP->MODE |= (main_mode << COMP_MODE_MAIN_Pos); -} - -__STATIC_INLINE void nrf_comp_speed_mode_set(nrf_comp_sp_mode_t speed_mode) -{ - NRF_COMP->MODE |= (speed_mode << COMP_MODE_SP_Pos); -} - -__STATIC_INLINE void nrf_comp_hysteresis_set(nrf_comp_hyst_t hyst) -{ - NRF_COMP->HYST = (hyst << COMP_HYST_HYST_Pos) & COMP_HYST_HYST_Msk; -} - -#if defined (COMP_ISOURCE_ISOURCE_Msk) -__STATIC_INLINE void nrf_comp_isource_set(nrf_isource_t isource) -{ - NRF_COMP->ISOURCE = (isource << COMP_ISOURCE_ISOURCE_Pos) & COMP_ISOURCE_ISOURCE_Msk; -} -#endif - -__STATIC_INLINE void nrf_comp_input_select(nrf_comp_input_t input) -{ - NRF_COMP->PSEL = ((uint32_t)input << COMP_PSEL_PSEL_Pos); -} - -__STATIC_INLINE uint32_t nrf_comp_result_get(void) -{ - return (uint32_t)NRF_COMP->RESULT; -} - -__STATIC_INLINE void nrf_comp_int_enable(uint32_t comp_int_mask) -{ - NRF_COMP->INTENSET = comp_int_mask; -} - -__STATIC_INLINE void nrf_comp_int_disable(uint32_t comp_int_mask) -{ - NRF_COMP->INTENCLR = comp_int_mask; -} - -__STATIC_INLINE bool nrf_comp_int_enable_check(uint32_t comp_int_mask) -{ - return (NRF_COMP->INTENSET & comp_int_mask); // when read this register will return the value of INTEN. -} - -__STATIC_INLINE uint32_t * nrf_comp_task_address_get(nrf_comp_task_t comp_task) -{ - return (uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)comp_task); -} - -__STATIC_INLINE uint32_t * nrf_comp_event_address_get(nrf_comp_event_t comp_event) -{ - return (uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)comp_event); -} - -__STATIC_INLINE void nrf_comp_shorts_enable(uint32_t comp_short_mask) -{ - NRF_COMP->SHORTS |= comp_short_mask; -} - -__STATIC_INLINE void nrf_comp_shorts_disable(uint32_t comp_short_mask) -{ - NRF_COMP->SHORTS &= ~comp_short_mask; -} - -__STATIC_INLINE void nrf_comp_task_trigger(nrf_comp_task_t comp_task) -{ - *( (volatile uint32_t *)( (uint8_t *)NRF_COMP + comp_task) ) = 1; -} - -__STATIC_INLINE void nrf_comp_event_clear(nrf_comp_event_t comp_event) -{ - *( (volatile uint32_t *)( (uint8_t *)NRF_COMP + (uint32_t)comp_event) ) = 0; -#if __CORTEX_M == 0x04 - volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)comp_event)); - (void)dummy; -#endif -} - -__STATIC_INLINE bool nrf_comp_event_check(nrf_comp_event_t comp_event) -{ - return (bool) (*(volatile uint32_t *)( (uint8_t *)NRF_COMP + comp_event)); -} - -#endif // SUPPRESS_INLINE_IMPLEMENTATION - -/** - *@} - **/ - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_COMP_H_ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_peripherals.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_peripherals.h deleted file mode 100644 index a1cdd3b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_peripherals.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_PERIPHERALS_H -#define NRF_PERIPHERALS_H - -/*lint ++flb "Enter library region */ - -#ifdef NRF51422 -#include "nrf51422_peripherals.h" -#endif - -#ifdef NRF51802 -#include "nrf51802_peripherals.h" -#endif - -#ifdef NRF51822 -#include "nrf51822_peripherals.h" -#endif - -#ifdef NRF52810_XXAA -#include "nrf52810_peripherals.h" -#endif - -#ifdef NRF52832_XXAA -#include "nrf52832_peripherals.h" -#endif - -#ifdef NRF52840_XXAA -#include "nrf52840_peripherals.h" -#endif - - -/*lint --flb "Leave library region" */ - -#endif /* NRF_PERIPHERALS_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_rtc.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_rtc.h deleted file mode 100644 index 1b1f839..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_rtc.h +++ /dev/null @@ -1,343 +0,0 @@ -/** - * Copyright (c) 2014 - 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 - * @brief RTC HAL API. - */ - -#ifndef NRF_RTC_H -#define NRF_RTC_H - -/** - * @defgroup nrf_rtc_hal RTC HAL - * @{ - * @ingroup nrf_rtc - * @brief Hardware access layer for managing the real time counter (RTC). - */ - -#include -#include -#include -#include "nrf.h" -#include "nrf_assert.h" -#include "nrf_peripherals.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Macro for getting the number of compare channels available - * in a given RTC instance. - */ - -#define NRF_RTC_CC_CHANNEL_COUNT(id) CONCAT_3(RTC, id, _CC_NUM) - -#define RTC_INPUT_FREQ 32768 /**< Input frequency of the RTC instance. */ - -/** - * @brief Macro for converting expected frequency to prescaler setting. - */ -#define RTC_FREQ_TO_PRESCALER(FREQ) (uint16_t)(((RTC_INPUT_FREQ) / (FREQ)) - 1) - -/**< Macro for wrapping values to RTC capacity. */ -#define RTC_WRAP(val) ((val) & RTC_COUNTER_COUNTER_Msk) - -#define RTC_CHANNEL_INT_MASK(ch) ((uint32_t)(NRF_RTC_INT_COMPARE0_MASK) << (ch)) -#define RTC_CHANNEL_EVENT_ADDR(ch) (nrf_rtc_event_t)((NRF_RTC_EVENT_COMPARE_0) + (ch) * sizeof(uint32_t)) -/** - * @enum nrf_rtc_task_t - * @brief RTC tasks. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_RTC_TASK_START = offsetof(NRF_RTC_Type,TASKS_START), /**< Start. */ - NRF_RTC_TASK_STOP = offsetof(NRF_RTC_Type,TASKS_STOP), /**< Stop. */ - NRF_RTC_TASK_CLEAR = offsetof(NRF_RTC_Type,TASKS_CLEAR), /**< Clear. */ - NRF_RTC_TASK_TRIGGER_OVERFLOW = offsetof(NRF_RTC_Type,TASKS_TRIGOVRFLW),/**< Trigger overflow. */ - /*lint -restore*/ -} nrf_rtc_task_t; - -/** - * @enum nrf_rtc_event_t - * @brief RTC events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_RTC_EVENT_TICK = offsetof(NRF_RTC_Type,EVENTS_TICK), /**< Tick event. */ - NRF_RTC_EVENT_OVERFLOW = offsetof(NRF_RTC_Type,EVENTS_OVRFLW), /**< Overflow event. */ - NRF_RTC_EVENT_COMPARE_0 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[0]), /**< Compare 0 event. */ - NRF_RTC_EVENT_COMPARE_1 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[1]), /**< Compare 1 event. */ - NRF_RTC_EVENT_COMPARE_2 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[2]), /**< Compare 2 event. */ - NRF_RTC_EVENT_COMPARE_3 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[3]) /**< Compare 3 event. */ - /*lint -restore*/ -} nrf_rtc_event_t; - -/** - * @enum nrf_rtc_int_t - * @brief RTC interrupts. - */ -typedef enum -{ - NRF_RTC_INT_TICK_MASK = RTC_INTENSET_TICK_Msk, /**< RTC interrupt from tick event. */ - NRF_RTC_INT_OVERFLOW_MASK = RTC_INTENSET_OVRFLW_Msk, /**< RTC interrupt from overflow event. */ - NRF_RTC_INT_COMPARE0_MASK = RTC_INTENSET_COMPARE0_Msk, /**< RTC interrupt from compare event on channel 0. */ - NRF_RTC_INT_COMPARE1_MASK = RTC_INTENSET_COMPARE1_Msk, /**< RTC interrupt from compare event on channel 1. */ - NRF_RTC_INT_COMPARE2_MASK = RTC_INTENSET_COMPARE2_Msk, /**< RTC interrupt from compare event on channel 2. */ - NRF_RTC_INT_COMPARE3_MASK = RTC_INTENSET_COMPARE3_Msk /**< RTC interrupt from compare event on channel 3. */ -} nrf_rtc_int_t; - -/**@brief Function for setting a compare value for a channel. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] ch Channel. - * @param[in] cc_val Compare value to set. - */ -__STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_rtc, uint32_t ch, uint32_t cc_val); - -/**@brief Function for returning the compare value for a channel. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] ch Channel. - * - * @return COMPARE[ch] value. - */ -__STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_rtc, uint32_t ch); - -/**@brief Function for enabling interrupts. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] mask Interrupt mask to be enabled. - */ -__STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_rtc, uint32_t mask); - -/**@brief Function for disabling interrupts. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] mask Interrupt mask to be disabled. - */ -__STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_rtc, uint32_t mask); - -/**@brief Function for checking if interrupts are enabled. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] mask Mask of interrupt flags to check. - * - * @return Mask with enabled interrupts. - */ -__STATIC_INLINE uint32_t nrf_rtc_int_is_enabled(NRF_RTC_Type * p_rtc, uint32_t mask); - -/**@brief Function for returning the status of currently enabled interrupts. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * - * @return Value in INTEN register. - */ -__STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_rtc); - -/**@brief Function for checking if an event is pending. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] event Address of the event. - * - * @return Mask of pending events. - */ -__STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event); - -/**@brief Function for clearing an event. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] event Event to clear. - */ -__STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event); - -/**@brief Function for returning a counter value. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * - * @return Counter value. - */ -__STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_rtc); - -/**@brief Function for setting a prescaler value. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] val Value to set the prescaler to. - */ -__STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_rtc, uint32_t val); - -/**@brief Function for returning the address of an event. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] event Requested event. - * - * @return Address of the requested event register. - */ -__STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event); - -/**@brief Function for returning the address of a task. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] task Requested task. - * - * @return Address of the requested task register. - */ -__STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task); - -/**@brief Function for starting a task. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] task Requested task. - */ -__STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task); - -/**@brief Function for enabling events. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] mask Mask of event flags to enable. - */ -__STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_rtc, uint32_t mask); - -/**@brief Function for disabling an event. - * - * @param[in] p_rtc Pointer to the peripheral registers structure. - * @param[in] event Requested event. - */ -__STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_rtc, uint32_t event); - -/** - *@} - **/ - - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_rtc, uint32_t ch, uint32_t cc_val) -{ - p_rtc->CC[ch] = cc_val; -} - -__STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_rtc, uint32_t ch) -{ - return p_rtc->CC[ch]; -} - -__STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_rtc, uint32_t mask) -{ - p_rtc->INTENSET = mask; -} - -__STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_rtc, uint32_t mask) -{ - p_rtc->INTENCLR = mask; -} - -__STATIC_INLINE uint32_t nrf_rtc_int_is_enabled(NRF_RTC_Type * p_rtc, uint32_t mask) -{ - return (p_rtc->INTENSET & mask); -} - -__STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_rtc) -{ - return p_rtc->INTENSET; -} - -__STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event) -{ - return *(volatile uint32_t *)((uint8_t *)p_rtc + (uint32_t)event); -} - -__STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event) -{ - *((volatile uint32_t *)((uint8_t *)p_rtc + (uint32_t)event)) = 0; -#if __CORTEX_M == 0x04 - volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_rtc + (uint32_t)event)); - (void)dummy; -#endif -} - -__STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_rtc) -{ - return p_rtc->COUNTER; -} - -__STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_rtc, uint32_t val) -{ - ASSERT(val <= (RTC_PRESCALER_PRESCALER_Msk >> RTC_PRESCALER_PRESCALER_Pos)); - p_rtc->PRESCALER = val; -} -__STATIC_INLINE uint32_t rtc_prescaler_get(NRF_RTC_Type * p_rtc) -{ - return p_rtc->PRESCALER; -} - -__STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event) -{ - return (uint32_t)p_rtc + event; -} - -__STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task) -{ - return (uint32_t)p_rtc + task; -} - -__STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task) -{ - *(__IO uint32_t *)((uint32_t)p_rtc + task) = 1; -} - -__STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_rtc, uint32_t mask) -{ - p_rtc->EVTENSET = mask; -} -__STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_rtc, uint32_t mask) -{ - p_rtc->EVTENCLR = mask; -} -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_RTC_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_saadc.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_saadc.c deleted file mode 100644 index c028eaa..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_saadc.c +++ /dev/null @@ -1,62 +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 - * @brief SAADC HAL implementation - */ -#include "sdk_config.h" -#if SAADC_ENABLED -#include "nrf_saadc.h" - -void nrf_saadc_channel_init(uint8_t channel, nrf_saadc_channel_config_t const * const config) -{ - NRF_SAADC->CH[channel].CONFIG = - ((config->resistor_p << SAADC_CH_CONFIG_RESP_Pos) & SAADC_CH_CONFIG_RESP_Msk) - | ((config->resistor_n << SAADC_CH_CONFIG_RESN_Pos) & SAADC_CH_CONFIG_RESN_Msk) - | ((config->gain << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk) - | ((config->reference << SAADC_CH_CONFIG_REFSEL_Pos) & SAADC_CH_CONFIG_REFSEL_Msk) - | ((config->acq_time << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk) - | ((config->mode << SAADC_CH_CONFIG_MODE_Pos) & SAADC_CH_CONFIG_MODE_Msk) - | ((config->burst << SAADC_CH_CONFIG_BURST_Pos) & SAADC_CH_CONFIG_BURST_Msk); - nrf_saadc_channel_input_set(channel, config->pin_p, config->pin_n); - return; -} -#endif //SAADC_ENABLED - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_spim.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_spim.h deleted file mode 100644 index d20eaa4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_spim.h +++ /dev/null @@ -1,571 +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. - * - */ -/** - * @defgroup nrf_spim_hal SPIM HAL - * @{ - * @ingroup nrf_spi - * - * @brief Hardware access layer for accessing the SPIM peripheral. - */ - -#ifndef NRF_SPIM_H__ -#define NRF_SPIM_H__ - -#include -#include -#include - -#include "nrf.h" -#include "nrf_peripherals.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * @brief This value can be used as a parameter for the @ref nrf_spim_pins_set - * function to specify that a given SPI signal (SCK, MOSI, or MISO) - * shall not be connected to a physical pin. - */ -#define NRF_SPIM_PIN_NOT_CONNECTED 0xFFFFFFFF - - -/** - * @brief SPIM tasks. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_SPIM_TASK_START = offsetof(NRF_SPIM_Type, TASKS_START), ///< Start SPI transaction. - NRF_SPIM_TASK_STOP = offsetof(NRF_SPIM_Type, TASKS_STOP), ///< Stop SPI transaction. - NRF_SPIM_TASK_SUSPEND = offsetof(NRF_SPIM_Type, TASKS_SUSPEND), ///< Suspend SPI transaction. - NRF_SPIM_TASK_RESUME = offsetof(NRF_SPIM_Type, TASKS_RESUME) ///< Resume SPI transaction. - /*lint -restore*/ -} nrf_spim_task_t; - -/** - * @brief SPIM events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_SPIM_EVENT_STOPPED = offsetof(NRF_SPIM_Type, EVENTS_STOPPED), ///< SPI transaction has stopped. - NRF_SPIM_EVENT_ENDRX = offsetof(NRF_SPIM_Type, EVENTS_ENDRX), ///< End of RXD buffer reached. - NRF_SPIM_EVENT_END = offsetof(NRF_SPIM_Type, EVENTS_END), ///< End of RXD buffer and TXD buffer reached. - NRF_SPIM_EVENT_ENDTX = offsetof(NRF_SPIM_Type, EVENTS_ENDTX), ///< End of TXD buffer reached. - NRF_SPIM_EVENT_STARTED = offsetof(NRF_SPIM_Type, EVENTS_STARTED) ///< Transaction started. - /*lint -restore*/ -} nrf_spim_event_t; - -/** - * @brief SPIM shortcuts. - */ -typedef enum -{ - NRF_SPIM_SHORT_END_START_MASK = SPIM_SHORTS_END_START_Msk ///< Shortcut between END event and START task. -} nrf_spim_short_mask_t; - -/** - * @brief SPIM interrupts. - */ -typedef enum -{ - NRF_SPIM_INT_STOPPED_MASK = SPIM_INTENSET_STOPPED_Msk, ///< Interrupt on STOPPED event. - NRF_SPIM_INT_ENDRX_MASK = SPIM_INTENSET_ENDRX_Msk, ///< Interrupt on ENDRX event. - NRF_SPIM_INT_END_MASK = SPIM_INTENSET_END_Msk, ///< Interrupt on END event. - NRF_SPIM_INT_ENDTX_MASK = SPIM_INTENSET_ENDTX_Msk, ///< Interrupt on ENDTX event. - NRF_SPIM_INT_STARTED_MASK = SPIM_INTENSET_STARTED_Msk ///< Interrupt on STARTED event. -} nrf_spim_int_mask_t; - -/** - * @brief SPI master data rates. - */ -typedef enum -{ - NRF_SPIM_FREQ_125K = SPIM_FREQUENCY_FREQUENCY_K125, ///< 125 kbps. - NRF_SPIM_FREQ_250K = SPIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps. - NRF_SPIM_FREQ_500K = SPIM_FREQUENCY_FREQUENCY_K500, ///< 500 kbps. - NRF_SPIM_FREQ_1M = SPIM_FREQUENCY_FREQUENCY_M1, ///< 1 Mbps. - NRF_SPIM_FREQ_2M = SPIM_FREQUENCY_FREQUENCY_M2, ///< 2 Mbps. - NRF_SPIM_FREQ_4M = SPIM_FREQUENCY_FREQUENCY_M4, ///< 4 Mbps. - // [conversion to 'int' needed to prevent compilers from complaining - // that the provided value (0x80000000UL) is out of range of "int"] - NRF_SPIM_FREQ_8M = (int)SPIM_FREQUENCY_FREQUENCY_M8,///< 8 Mbps. -#ifndef SPI_PRESENT - NRF_SPI_FREQ_125K = NRF_SPIM_FREQ_125K, - NRF_SPI_FREQ_250K = NRF_SPIM_FREQ_250K, - NRF_SPI_FREQ_500K = NRF_SPIM_FREQ_500K, - NRF_SPI_FREQ_1M = NRF_SPIM_FREQ_1M, - NRF_SPI_FREQ_2M = NRF_SPIM_FREQ_2M, - NRF_SPI_FREQ_4M = NRF_SPIM_FREQ_4M, - NRF_SPI_FREQ_8M = NRF_SPIM_FREQ_8M, -#endif -} nrf_spim_frequency_t; - -/** - * @brief SPI modes. - */ -typedef enum -{ - NRF_SPIM_MODE_0, ///< SCK active high, sample on leading edge of clock. - NRF_SPIM_MODE_1, ///< SCK active high, sample on trailing edge of clock. - NRF_SPIM_MODE_2, ///< SCK active low, sample on leading edge of clock. - NRF_SPIM_MODE_3, ///< SCK active low, sample on trailing edge of clock. -#ifndef SPI_PRESENT - NRF_SPI_MODE_0 = NRF_SPIM_MODE_0, - NRF_SPI_MODE_1 = NRF_SPIM_MODE_1, - NRF_SPI_MODE_2 = NRF_SPIM_MODE_2, - NRF_SPI_MODE_3 = NRF_SPIM_MODE_3, -#endif -} nrf_spim_mode_t; - -/** - * @brief SPI bit orders. - */ -typedef enum -{ - NRF_SPIM_BIT_ORDER_MSB_FIRST = SPIM_CONFIG_ORDER_MsbFirst, ///< Most significant bit shifted out first. - NRF_SPIM_BIT_ORDER_LSB_FIRST = SPIM_CONFIG_ORDER_LsbFirst, ///< Least significant bit shifted out first. -#ifndef SPI_PRESENT - NRF_SPI_BIT_ORDER_MSB_FIRST = NRF_SPIM_BIT_ORDER_MSB_FIRST, - NRF_SPI_BIT_ORDER_LSB_FIRST = NRF_SPIM_BIT_ORDER_LSB_FIRST, -#endif -} nrf_spim_bit_order_t; - - -/** - * @brief Function for activating a specific SPIM task. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_task Task to activate. - */ -__STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg, - nrf_spim_task_t spim_task); - -/** - * @brief Function for getting the address of a specific SPIM task register. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_task Requested task. - * - * @return Address of the specified task register. - */ -__STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type * p_reg, - nrf_spim_task_t spim_task); - -/** - * @brief Function for clearing a specific SPIM event. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_event Event to clear. - */ -__STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg, - nrf_spim_event_t spim_event); - -/** - * @brief Function for checking the state of a specific SPIM event. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_event Event to check. - * - * @retval true If the event is set. - * @retval false If the event is not set. - */ -__STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type * p_reg, - nrf_spim_event_t spim_event); - -/** - * @brief Function for getting the address of a specific SPIM event register. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_event Requested event. - * - * @return Address of the specified event register. - */ -__STATIC_INLINE uint32_t nrf_spim_event_address_get(NRF_SPIM_Type * p_reg, - nrf_spim_event_t spim_event); -/** - * @brief Function for enabling specified shortcuts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_shorts_mask Shortcuts to enable. - */ -__STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg, - uint32_t spim_shorts_mask); - -/** - * @brief Function for disabling specified shortcuts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_shorts_mask Shortcuts to disable. - */ -__STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg, - uint32_t spim_shorts_mask); - -/** - * @brief Function for getting shorts setting. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type * p_reg); - -/** - * @brief Function for enabling specified interrupts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_int_mask Interrupts to enable. - */ -__STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg, - uint32_t spim_int_mask); - -/** - * @brief Function for disabling specified interrupts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_int_mask Interrupts to disable. - */ -__STATIC_INLINE void nrf_spim_int_disable(NRF_SPIM_Type * p_reg, - uint32_t spim_int_mask); - -/** - * @brief Function for retrieving the state of a given interrupt. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spim_int Interrupt to check. - * - * @retval true If the interrupt is enabled. - * @retval false If the interrupt is not enabled. - */ -__STATIC_INLINE bool nrf_spim_int_enable_check(NRF_SPIM_Type * p_reg, - nrf_spim_int_mask_t spim_int); - -/** - * @brief Function for enabling the SPIM peripheral. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_spim_enable(NRF_SPIM_Type * p_reg); - -/** - * @brief Function for disabling the SPIM peripheral. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg); - -/** - * @brief Function for configuring SPIM pins. - * - * If a given signal is not needed, pass the @ref NRF_SPIM_PIN_NOT_CONNECTED - * value instead of its pin number. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] sck_pin SCK pin number. - * @param[in] mosi_pin MOSI pin number. - * @param[in] miso_pin MISO pin number. - */ -__STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg, - uint32_t sck_pin, - uint32_t mosi_pin, - uint32_t miso_pin); - -/** - * @brief Function for setting the SPI master data rate. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] frequency SPI frequency. - */ -__STATIC_INLINE void nrf_spim_frequency_set(NRF_SPIM_Type * p_reg, - nrf_spim_frequency_t frequency); - -/** - * @brief Function for setting the transmit buffer. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] p_buffer Pointer to the buffer with data to send. - * @param[in] length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg, - uint8_t const * p_buffer, - uint8_t length); - -/** - * @brief Function for setting the receive buffer. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] p_buffer Pointer to the buffer for received data. - * @param[in] length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg, - uint8_t * p_buffer, - uint8_t length); - -/** - * @brief Function for setting the SPI configuration. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] spi_mode SPI mode. - * @param[in] spi_bit_order SPI bit order. - */ -__STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg, - nrf_spim_mode_t spi_mode, - nrf_spim_bit_order_t spi_bit_order); - -/** - * @brief Function for setting the over-read character. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] orc Over-read character that is clocked out in case of - * an over-read of the TXD buffer. - */ -__STATIC_INLINE void nrf_spim_orc_set(NRF_SPIM_Type * p_reg, - uint8_t orc); - -/** - * @brief Function for enabling the TX list feature. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_spim_tx_list_enable(NRF_SPIM_Type * p_reg); - -/** - * @brief Function for disabling the TX list feature. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_spim_tx_list_disable(NRF_SPIM_Type * p_reg); - -/** - * @brief Function for enabling the RX list feature. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_spim_rx_list_enable(NRF_SPIM_Type * p_reg); - -/** - * @brief Function for disabling the RX list feature. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_spim_rx_list_disable(NRF_SPIM_Type * p_reg); - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg, - nrf_spim_task_t spim_task) -{ - *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)spim_task)) = 0x1UL; -} - -__STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type * p_reg, - nrf_spim_task_t spim_task) -{ - return (uint32_t)((uint8_t *)p_reg + (uint32_t)spim_task); -} - -__STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg, - nrf_spim_event_t spim_event) -{ - *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)spim_event)) = 0x0UL; -#if __CORTEX_M == 0x04 - volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)spim_event)); - (void)dummy; -#endif -} - -__STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type * p_reg, - nrf_spim_event_t spim_event) -{ - return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)spim_event); -} - -__STATIC_INLINE uint32_t nrf_spim_event_address_get(NRF_SPIM_Type * p_reg, - nrf_spim_event_t spim_event) -{ - return (uint32_t)((uint8_t *)p_reg + (uint32_t)spim_event); -} - -__STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg, - uint32_t spim_shorts_mask) -{ - p_reg->SHORTS |= spim_shorts_mask; -} - -__STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg, - uint32_t spim_shorts_mask) -{ - p_reg->SHORTS &= ~(spim_shorts_mask); -} - -__STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type * p_reg) -{ - return p_reg->SHORTS; -} - -__STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg, - uint32_t spim_int_mask) -{ - p_reg->INTENSET = spim_int_mask; -} - -__STATIC_INLINE void nrf_spim_int_disable(NRF_SPIM_Type * p_reg, - uint32_t spim_int_mask) -{ - p_reg->INTENCLR = spim_int_mask; -} - -__STATIC_INLINE bool nrf_spim_int_enable_check(NRF_SPIM_Type * p_reg, - nrf_spim_int_mask_t spim_int) -{ - return (bool)(p_reg->INTENSET & spim_int); -} - -__STATIC_INLINE void nrf_spim_enable(NRF_SPIM_Type * p_reg) -{ - p_reg->ENABLE = (SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos); -} - -__STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg) -{ - p_reg->ENABLE = (SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos); -} - -__STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg, - uint32_t sck_pin, - uint32_t mosi_pin, - uint32_t miso_pin) -{ - p_reg->PSEL.SCK = sck_pin; - p_reg->PSEL.MOSI = mosi_pin; - p_reg->PSEL.MISO = miso_pin; -} - -__STATIC_INLINE void nrf_spim_frequency_set(NRF_SPIM_Type * p_reg, - nrf_spim_frequency_t frequency) -{ - p_reg->FREQUENCY = frequency; -} - -__STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg, - uint8_t const * p_buffer, - uint8_t length) -{ - p_reg->TXD.PTR = (uint32_t)p_buffer; - p_reg->TXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg, - uint8_t * p_buffer, - uint8_t length) -{ - p_reg->RXD.PTR = (uint32_t)p_buffer; - p_reg->RXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg, - nrf_spim_mode_t spi_mode, - nrf_spim_bit_order_t spi_bit_order) -{ - uint32_t config = (spi_bit_order == NRF_SPIM_BIT_ORDER_MSB_FIRST ? - SPIM_CONFIG_ORDER_MsbFirst : SPIM_CONFIG_ORDER_LsbFirst); - switch (spi_mode) - { - default: - case NRF_SPIM_MODE_0: - config |= (SPIM_CONFIG_CPOL_ActiveHigh << SPIM_CONFIG_CPOL_Pos) | - (SPIM_CONFIG_CPHA_Leading << SPIM_CONFIG_CPHA_Pos); - break; - - case NRF_SPIM_MODE_1: - config |= (SPIM_CONFIG_CPOL_ActiveHigh << SPIM_CONFIG_CPOL_Pos) | - (SPIM_CONFIG_CPHA_Trailing << SPIM_CONFIG_CPHA_Pos); - break; - - case NRF_SPIM_MODE_2: - config |= (SPIM_CONFIG_CPOL_ActiveLow << SPIM_CONFIG_CPOL_Pos) | - (SPIM_CONFIG_CPHA_Leading << SPIM_CONFIG_CPHA_Pos); - break; - - case NRF_SPIM_MODE_3: - config |= (SPIM_CONFIG_CPOL_ActiveLow << SPIM_CONFIG_CPOL_Pos) | - (SPIM_CONFIG_CPHA_Trailing << SPIM_CONFIG_CPHA_Pos); - break; - } - p_reg->CONFIG = config; -} - -__STATIC_INLINE void nrf_spim_orc_set(NRF_SPIM_Type * p_reg, - uint8_t orc) -{ - p_reg->ORC = orc; -} - - -__STATIC_INLINE void nrf_spim_tx_list_enable(NRF_SPIM_Type * p_reg) -{ - p_reg->TXD.LIST = 1; -} - -__STATIC_INLINE void nrf_spim_tx_list_disable(NRF_SPIM_Type * p_reg) -{ - p_reg->TXD.LIST = 0; -} - -__STATIC_INLINE void nrf_spim_rx_list_enable(NRF_SPIM_Type * p_reg) -{ - p_reg->RXD.LIST = 1; -} - -__STATIC_INLINE void nrf_spim_rx_list_disable(NRF_SPIM_Type * p_reg) -{ - p_reg->RXD.LIST = 0; -} - -#endif // SUPPRESS_INLINE_IMPLEMENTATION - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_SPIM_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_twis.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_twis.h deleted file mode 100644 index 3cd56d6..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_twis.h +++ /dev/null @@ -1,706 +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. - * - */ -/** - * @ingroup nrf_twis - * @defgroup nrf_twis_hal TWIS HAL - * @{ - * - * @brief @tagAPI52 Hardware access layer for Two Wire Interface Slave with EasyDMA - * (TWIS) peripheral. - */ -#ifndef NRF_TWIS_H__ -#define NRF_TWIS_H__ - -#include "nrf.h" -#include "sdk_config.h" -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief TWIS tasks - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_TWIS_TASK_STOP = offsetof(NRF_TWIS_Type, TASKS_STOP), /**< Stop TWIS transaction */ - NRF_TWIS_TASK_SUSPEND = offsetof(NRF_TWIS_Type, TASKS_SUSPEND), /**< Suspend TWIS transaction */ - NRF_TWIS_TASK_RESUME = offsetof(NRF_TWIS_Type, TASKS_RESUME), /**< Resume TWIS transaction */ - NRF_TWIS_TASK_PREPARERX = offsetof(NRF_TWIS_Type, TASKS_PREPARERX), /**< Prepare the TWIS slave to respond to a write command */ - NRF_TWIS_TASK_PREPARETX = offsetof(NRF_TWIS_Type, TASKS_PREPARETX) /**< Prepare the TWIS slave to respond to a read command */ - /*lint -restore*/ -} nrf_twis_task_t; - -/** - * @brief TWIS events - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_TWIS_EVENT_STOPPED = offsetof(NRF_TWIS_Type, EVENTS_STOPPED), /**< TWIS stopped */ - NRF_TWIS_EVENT_ERROR = offsetof(NRF_TWIS_Type, EVENTS_ERROR), /**< TWIS error */ - NRF_TWIS_EVENT_RXSTARTED = offsetof(NRF_TWIS_Type, EVENTS_RXSTARTED), /**< Receive sequence started */ - NRF_TWIS_EVENT_TXSTARTED = offsetof(NRF_TWIS_Type, EVENTS_TXSTARTED), /**< Transmit sequence started */ - NRF_TWIS_EVENT_WRITE = offsetof(NRF_TWIS_Type, EVENTS_WRITE), /**< Write command received */ - NRF_TWIS_EVENT_READ = offsetof(NRF_TWIS_Type, EVENTS_READ) /**< Read command received */ - /*lint -restore*/ -} nrf_twis_event_t; - -/** - * @brief TWIS shortcuts - */ -typedef enum -{ - NRF_TWIS_SHORT_WRITE_SUSPEND_MASK = TWIS_SHORTS_WRITE_SUSPEND_Msk, /**< Shortcut between WRITE event and SUSPEND task */ - NRF_TWIS_SHORT_READ_SUSPEND_MASK = TWIS_SHORTS_READ_SUSPEND_Msk, /**< Shortcut between READ event and SUSPEND task */ -} nrf_twis_short_mask_t; - -/** - * @brief TWIS interrupts - */ -typedef enum -{ - NRF_TWIS_INT_STOPPED_MASK = TWIS_INTEN_STOPPED_Msk, /**< Interrupt on STOPPED event */ - NRF_TWIS_INT_ERROR_MASK = TWIS_INTEN_ERROR_Msk, /**< Interrupt on ERROR event */ - NRF_TWIS_INT_RXSTARTED_MASK = TWIS_INTEN_RXSTARTED_Msk, /**< Interrupt on RXSTARTED event */ - NRF_TWIS_INT_TXSTARTED_MASK = TWIS_INTEN_TXSTARTED_Msk, /**< Interrupt on TXSTARTED event */ - NRF_TWIS_INT_WRITE_MASK = TWIS_INTEN_WRITE_Msk, /**< Interrupt on WRITE event */ - NRF_TWIS_INT_READ_MASK = TWIS_INTEN_READ_Msk, /**< Interrupt on READ event */ -} nrf_twis_int_mask_t; - -/** - * @brief TWIS error source - */ -typedef enum -{ - NRF_TWIS_ERROR_OVERFLOW = TWIS_ERRORSRC_OVERFLOW_Msk, /**< RX buffer overflow detected, and prevented */ - NRF_TWIS_ERROR_DATA_NACK = TWIS_ERRORSRC_DNACK_Msk, /**< NACK sent after receiving a data byte */ - NRF_TWIS_ERROR_OVERREAD = TWIS_ERRORSRC_OVERREAD_Msk /**< TX buffer over-read detected, and prevented */ -} nrf_twis_error_t; - -/** - * @brief TWIS address matching configuration - */ -typedef enum -{ - NRF_TWIS_CONFIG_ADDRESS0_MASK = TWIS_CONFIG_ADDRESS0_Msk, /**< Enable or disable address matching on ADDRESS[0] */ - NRF_TWIS_CONFIG_ADDRESS1_MASK = TWIS_CONFIG_ADDRESS1_Msk, /**< Enable or disable address matching on ADDRESS[1] */ - NRF_TWIS_CONFIG_ADDRESS01_MASK = TWIS_CONFIG_ADDRESS0_Msk | TWIS_CONFIG_ADDRESS1_Msk /**< Enable both address matching */ -} nrf_twis_config_addr_mask_t; - -/** - * @brief Variable type to hold amount of data for EasyDMA - * - * Variable of the minimum size that can hold the amount of data to transfer. - * - * @note - * Defined to make it simple to change if EasyDMA would be updated to support more data in - * the future devices to. - */ -typedef uint8_t nrf_twis_amount_t; - -/** - * @brief Smallest variable type to hold TWI address - * - * Variable of the minimum size that can hold single TWI address. - * - * @note - * Defined to make it simple to change if new TWI would support for example - * 10 bit addressing mode. - */ -typedef uint8_t nrf_twis_address_t; - - -/** - * @brief Function for activating a specific TWIS task. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param task Task. - */ -__STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * const p_reg, nrf_twis_task_t task); - -/** - * @brief Function for returning the address of a specific TWIS task register. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_twis_task_address_get( - NRF_TWIS_Type const * const p_reg, - nrf_twis_task_t task); - -/** - * @brief Function for clearing a specific event. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param event Event. - */ -__STATIC_INLINE void nrf_twis_event_clear( - NRF_TWIS_Type * const p_reg, - nrf_twis_event_t event); -/** - * @brief Function for returning the state of a specific event. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param event Event. - * - * @retval true If the event is set. - * @retval false If the event is not set. - */ -__STATIC_INLINE bool nrf_twis_event_check( - NRF_TWIS_Type const * const p_reg, - nrf_twis_event_t event); - - -/** - * @brief Function for getting and clearing the state of specific event - * - * This function checks the state of the event and clears it. - * @param[in,out] p_reg Pointer to the peripheral registers structure. - * @param event Event. - * - * @retval true If the event was set. - * @retval false If the event was not set. - */ -__STATIC_INLINE bool nrf_twis_event_get_and_clear( - NRF_TWIS_Type * const p_reg, - nrf_twis_event_t event); - - -/** - * @brief Function for returning the address of a specific TWIS event register. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param event Event. - * - * @return Address. - */ -__STATIC_INLINE uint32_t nrf_twis_event_address_get( - NRF_TWIS_Type const * const p_reg, - nrf_twis_event_t event); - -/** - * @brief Function for setting a shortcut. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param short_mask Shortcuts mask. - */ -__STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * const p_reg, uint32_t short_mask); - -/** - * @brief Function for clearing shortcuts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param short_mask Shortcuts mask. - */ -__STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * const p_reg, uint32_t short_mask); - -/** - * @brief Get the shorts mask - * - * Function returns shorts register. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @return Flags of currently enabled shortcuts - */ -__STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type * const p_reg); - -/** - * @brief Function for enabling selected interrupts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param int_mask Interrupts mask. - */ -__STATIC_INLINE void nrf_twis_int_enable(NRF_TWIS_Type * const p_reg, uint32_t int_mask); - -/** - * @brief Function for retrieving the state of selected interrupts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param int_mask Interrupts mask. - * - * @retval true If any of selected interrupts is enabled. - * @retval false If none of selected interrupts is enabled. - */ -__STATIC_INLINE bool nrf_twis_int_enable_check(NRF_TWIS_Type const * const p_reg, uint32_t int_mask); - -/** - * @brief Function for disabling selected interrupts. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param int_mask Interrupts mask. - */ -__STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * const p_reg, uint32_t int_mask); - -/** - * @brief Function for retrieving and clearing the TWIS error source. - * - * @attention Error sources are cleared after read. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @return Error source mask with values from @ref nrf_twis_error_t. - */ -__STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * const p_reg); - -/** - * @brief Get information which of addresses matched - * - * Function returns index in the address table - * that points to the address that already matched. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @return Index of matched address - */ -__STATIC_INLINE uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_reg); - -/** - * @brief Function for enabling TWIS. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_twis_enable(NRF_TWIS_Type * const p_reg); - -/** - * @brief Function for disabling TWIS. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - */ -__STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * const p_reg); - -/** - * @brief Function for configuring TWIS pins. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param scl SCL pin number. - * @param sda SDA pin number. - */ -__STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * const p_reg, uint32_t scl, uint32_t sda); - -/** - * @brief Function for setting the receive buffer. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param p_buf Pointer to the buffer for received data. - * @param length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_twis_rx_buffer_set( - NRF_TWIS_Type * const p_reg, - uint8_t * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function that prepares TWIS for receiving - * - * This function sets receive buffer and then sets NRF_TWIS_TASK_PREPARERX task. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param p_buf Pointer to the buffer for received data. - * @param length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_twis_rx_prepare( - NRF_TWIS_Type * const p_reg, - uint8_t * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function for getting number of bytes received in the last transaction. - * - * @param[in] p_reg TWIS instance. - * @return Amount of bytes received. - * */ -__STATIC_INLINE nrf_twis_amount_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * const p_reg); - -/** - * @brief Function for setting the transmit buffer. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param p_buf Pointer to the buffer with data to send. - * @param length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_twis_tx_buffer_set( - NRF_TWIS_Type * const p_reg, - uint8_t const * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function that prepares TWIS for transmitting - * - * This function sets transmit buffer and then sets NRF_TWIS_TASK_PREPARETX task. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param p_buf Pointer to the buffer with data to send. - * @param length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_twis_tx_prepare( - NRF_TWIS_Type * const p_reg, - uint8_t const * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function for getting number of bytes transmitted in the last transaction. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @return Amount of bytes transmitted. - */ -__STATIC_INLINE nrf_twis_amount_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * const p_reg); - -/** - * @brief Function for setting slave address - * - * Function sets the selected address for this TWI interface. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param n Index of address to set - * @param addr Addres to set - * @sa nrf_twis_config_address_set - * @sa nrf_twis_config_address_get - */ -__STATIC_INLINE void nrf_twis_address_set( - NRF_TWIS_Type * const p_reg, - uint_fast8_t n, - nrf_twis_address_t addr); - -/** - * @brief Function for retrieving configured slave address - * - * Function gets the selected address for this TWI interface. - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param n Index of address to get - */ -__STATIC_INLINE nrf_twis_address_t nrf_twis_address_get( - NRF_TWIS_Type const * const p_reg, - uint_fast8_t n); - -/** - * @brief Function for setting the device address configuration. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param addr_mask Mask of address indexes of what device should answer to. - * - * @sa nrf_twis_address_set - */ -__STATIC_INLINE void nrf_twis_config_address_set( - NRF_TWIS_Type * const p_reg, - nrf_twis_config_addr_mask_t addr_mask); - -/** - * @brief Function for retrieving the device address configuration. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * - * @return Mask of address indexes of what device should answer to. - */ -__STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get( - NRF_TWIS_Type const * const p_reg); - -/** - * @brief Function for setting the over-read character. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @param[in] orc Over-read character. Character clocked out in case of - * over-read of the TXD buffer. - */ -__STATIC_INLINE void nrf_twis_orc_set( - NRF_TWIS_Type * const p_reg, - uint8_t orc); - -/** - * @brief Function for setting the over-read character. - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * - * @return Over-read character configured for selected instance. - */ -__STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * const p_reg); - - -/** @} */ /* End of nrf_twis_hal */ - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -/* ------------------------------------------------------------------------------------------------ - * Internal functions - */ - -/** - * @internal - * @brief Internal function for getting task/event register address - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @oaram offset Offset of the register from the instance beginning - * - * @attention offset has to be modulo 4 value. In other case we can get hardware fault. - * @return Pointer to the register - */ -__STATIC_INLINE volatile uint32_t* nrf_twis_getRegPtr(NRF_TWIS_Type * const p_reg, uint32_t offset) -{ - return (volatile uint32_t*)((uint8_t *)p_reg + (uint32_t)offset); -} - -/** - * @internal - * @brief Internal function for getting task/event register address - constant version - * - * @param[in] p_reg Pointer to the peripheral registers structure. - * @oaram offset Offset of the register from the instance beginning - * - * @attention offset has to be modulo 4 value. In other case we can get hardware fault. - * @return Pointer to the register - */ -__STATIC_INLINE volatile const uint32_t* nrf_twis_getRegPtr_c(NRF_TWIS_Type const * const p_reg, uint32_t offset) -{ - return (volatile const uint32_t*)((uint8_t *)p_reg + (uint32_t)offset); -} - - -/* ------------------------------------------------------------------------------------------------ - * Interface functions definitions - */ - - -void nrf_twis_task_trigger(NRF_TWIS_Type * const p_reg, nrf_twis_task_t task) -{ - *(nrf_twis_getRegPtr(p_reg, (uint32_t)task)) = 1UL; -} - -uint32_t nrf_twis_task_address_get( - NRF_TWIS_Type const * const p_reg, - nrf_twis_task_t task) -{ - return (uint32_t)nrf_twis_getRegPtr_c(p_reg, (uint32_t)task); -} - -void nrf_twis_event_clear( - NRF_TWIS_Type * const p_reg, - nrf_twis_event_t event) -{ - *(nrf_twis_getRegPtr(p_reg, (uint32_t)event)) = 0UL; -#if __CORTEX_M == 0x04 - volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)); - (void)dummy; -#endif -} - -bool nrf_twis_event_check( - NRF_TWIS_Type const * const p_reg, - nrf_twis_event_t event) -{ - return (bool)*nrf_twis_getRegPtr_c(p_reg, (uint32_t)event); -} - -bool nrf_twis_event_get_and_clear( - NRF_TWIS_Type * const p_reg, - nrf_twis_event_t event) -{ - bool ret = nrf_twis_event_check(p_reg, event); - if (ret) - { - nrf_twis_event_clear(p_reg, event); - } - return ret; -} - -uint32_t nrf_twis_event_address_get( - NRF_TWIS_Type const * const p_reg, - nrf_twis_event_t event) -{ - return (uint32_t)nrf_twis_getRegPtr_c(p_reg, (uint32_t)event); -} - -void nrf_twis_shorts_enable(NRF_TWIS_Type * const p_reg, uint32_t short_mask) -{ - p_reg->SHORTS |= short_mask; -} - -void nrf_twis_shorts_disable(NRF_TWIS_Type * const p_reg, uint32_t short_mask) -{ - if (~0U == short_mask) - { - /* Optimized version for "disable all" */ - p_reg->SHORTS = 0; - } - else - { - p_reg->SHORTS &= ~short_mask; - } -} - -uint32_t nrf_twis_shorts_get(NRF_TWIS_Type * const p_reg) -{ - return p_reg->SHORTS; -} - -void nrf_twis_int_enable(NRF_TWIS_Type * const p_reg, uint32_t int_mask) -{ - p_reg->INTENSET = int_mask; -} - -bool nrf_twis_int_enable_check(NRF_TWIS_Type const * const p_reg, uint32_t int_mask) -{ - return (bool)(p_reg->INTENSET & int_mask); -} - -void nrf_twis_int_disable(NRF_TWIS_Type * const p_reg, uint32_t int_mask) -{ - p_reg->INTENCLR = int_mask; -} - -uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * const p_reg) -{ - uint32_t ret = p_reg->ERRORSRC; - p_reg->ERRORSRC = ret; - return ret; -} - -uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_reg) -{ - return (uint_fast8_t)p_reg->MATCH; -} - -void nrf_twis_enable(NRF_TWIS_Type * const p_reg) -{ - p_reg->ENABLE = (TWIS_ENABLE_ENABLE_Enabled << TWIS_ENABLE_ENABLE_Pos); -} - -void nrf_twis_disable(NRF_TWIS_Type * const p_reg) -{ - p_reg->ENABLE = (TWIS_ENABLE_ENABLE_Disabled << TWIS_ENABLE_ENABLE_Pos); -} - -void nrf_twis_pins_set(NRF_TWIS_Type * const p_reg, uint32_t scl, uint32_t sda) -{ - p_reg->PSEL.SCL = scl; - p_reg->PSEL.SDA = sda; -} - -void nrf_twis_rx_buffer_set( - NRF_TWIS_Type * const p_reg, - uint8_t * p_buf, - nrf_twis_amount_t length) -{ - p_reg->RXD.PTR = (uint32_t)p_buf; - p_reg->RXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_twis_rx_prepare( - NRF_TWIS_Type * const p_reg, - uint8_t * p_buf, - nrf_twis_amount_t length) -{ - nrf_twis_rx_buffer_set(p_reg, p_buf, length); - nrf_twis_task_trigger(p_reg, NRF_TWIS_TASK_PREPARERX); -} - -nrf_twis_amount_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * const p_reg) -{ - return (nrf_twis_amount_t)p_reg->RXD.AMOUNT; -} - -void nrf_twis_tx_buffer_set( - NRF_TWIS_Type * const p_reg, - uint8_t const * p_buf, - nrf_twis_amount_t length) -{ - p_reg->TXD.PTR = (uint32_t)p_buf; - p_reg->TXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_twis_tx_prepare( - NRF_TWIS_Type * const p_reg, - uint8_t const * p_buf, - nrf_twis_amount_t length) -{ - nrf_twis_tx_buffer_set(p_reg, p_buf, length); - nrf_twis_task_trigger(p_reg, NRF_TWIS_TASK_PREPARETX); -} - -nrf_twis_amount_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * const p_reg) -{ - return (nrf_twis_amount_t)p_reg->TXD.AMOUNT; -} - -void nrf_twis_address_set( - NRF_TWIS_Type * const p_reg, - uint_fast8_t n, - nrf_twis_address_t addr) -{ - p_reg->ADDRESS[n] = addr; -} - -nrf_twis_address_t nrf_twis_address_get( - NRF_TWIS_Type const * const p_reg, - uint_fast8_t n) -{ - return (nrf_twis_address_t)p_reg->ADDRESS[n]; -} -void nrf_twis_config_address_set( - NRF_TWIS_Type * const p_reg, - nrf_twis_config_addr_mask_t addr_mask) -{ - /* This is the only configuration in TWIS - just write it without masking */ - p_reg->CONFIG = addr_mask; -} - -nrf_twis_config_addr_mask_t nrf_twis_config_address_get(NRF_TWIS_Type const * const p_reg) -{ - return (nrf_twis_config_addr_mask_t)(p_reg->CONFIG & TWIS_ADDRESS_ADDRESS_Msk); -} - -void nrf_twis_orc_set( - NRF_TWIS_Type * const p_reg, - uint8_t orc) -{ - p_reg->ORC = orc; -} - -uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * const p_reg) -{ - return (uint8_t)p_reg->ORC; -} - -#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ - - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_TWIS_H__ */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.c deleted file mode 100644 index ba4fe01..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.c +++ /dev/null @@ -1,446 +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(I2S) -#include "nrf_drv_i2s.h" -#include "nrf_drv_common.h" -#include "nrf_gpio.h" -#include "nrf_assert.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME i2s - -#if I2S_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL I2S_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR I2S_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR I2S_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_I2S_EVENT_RXPTRUPD ? "NRF_I2S_EVENT_RXPTRUPD" : \ - (event == NRF_I2S_EVENT_TXPTRUPD ? "NRF_I2S_EVENT_TXPTRUPD" : \ - (event == NRF_I2S_EVENT_STOPPED ? "NRF_I2S_EVENT_STOPPED" : "UNKNOWN EVENT"))) -#else //I2S_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //I2S_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#define MODULE_INITIALIZED (m_cb.state == NRF_DRV_STATE_INITIALIZED) /**< Macro designating whether the module has been initialized properly. */ - -// Control block - driver instance local data. -typedef struct -{ - nrf_drv_i2s_data_handler_t handler; - nrf_drv_state_t state; - - bool synchronized_mode : 1; - bool rx_ready : 1; - bool tx_ready : 1; - bool just_started : 1; - uint16_t buffer_half_size; - uint32_t * p_rx_buffer; - uint32_t * p_tx_buffer; -} i2s_control_block_t; -static i2s_control_block_t m_cb; - - -static nrf_drv_i2s_config_t const m_default_config = NRF_DRV_I2S_DEFAULT_CONFIG; - - -static void configure_pins(nrf_drv_i2s_config_t const * p_config) -{ - uint32_t mck_pin, sdout_pin, sdin_pin; - - // Configure pins used by the peripheral: - - // - SCK and LRCK (required) - depending on the mode of operation these - // pins are configured as outputs (in Master mode) or inputs (in Slave - // mode). - if (p_config->mode == NRF_I2S_MODE_MASTER) - { - nrf_gpio_cfg_output(p_config->sck_pin); - nrf_gpio_cfg_output(p_config->lrck_pin); - } - else - { - nrf_gpio_cfg_input(p_config->sck_pin, NRF_GPIO_PIN_NOPULL); - nrf_gpio_cfg_input(p_config->lrck_pin, NRF_GPIO_PIN_NOPULL); - } - - // - MCK (optional) - always output, - if (p_config->mck_pin != NRF_DRV_I2S_PIN_NOT_USED) - { - mck_pin = p_config->mck_pin; - nrf_gpio_cfg_output(mck_pin); - } - else - { - mck_pin = NRF_I2S_PIN_NOT_CONNECTED; - } - - // - SDOUT (optional) - always output, - if (p_config->sdout_pin != NRF_DRV_I2S_PIN_NOT_USED) - { - sdout_pin = p_config->sdout_pin; - nrf_gpio_cfg_output(sdout_pin); - } - else - { - sdout_pin = NRF_I2S_PIN_NOT_CONNECTED; - } - - // - SDIN (optional) - always input. - if (p_config->sdin_pin != NRF_DRV_I2S_PIN_NOT_USED) - { - sdin_pin = p_config->sdin_pin; - nrf_gpio_cfg_input(sdin_pin, NRF_GPIO_PIN_NOPULL); - } - else - { - sdin_pin = NRF_I2S_PIN_NOT_CONNECTED; - } - - nrf_i2s_pins_set(NRF_I2S, p_config->sck_pin, p_config->lrck_pin, - mck_pin, sdout_pin, sdin_pin); -} - - -ret_code_t nrf_drv_i2s_init(nrf_drv_i2s_config_t const * p_config, - nrf_drv_i2s_data_handler_t handler) -{ - ASSERT(handler); - - ret_code_t err_code; - - if (m_cb.state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - if (p_config == NULL) - { - p_config = &m_default_config; - } - - if (!nrf_i2s_configure(NRF_I2S, p_config->mode, - p_config->format, - p_config->alignment, - p_config->sample_width, - p_config->channels, - p_config->mck_setup, - p_config->ratio)) - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - configure_pins(p_config); - - m_cb.handler = handler; - - nrf_drv_common_irq_enable(I2S_IRQn, p_config->irq_priority); - - m_cb.state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_i2s_uninit(void) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_drv_i2s_stop(); - - nrf_drv_common_irq_disable(I2S_IRQn); - - m_cb.state = NRF_DRV_STATE_UNINITIALIZED; - NRF_LOG_INFO("Uninitialized."); -} - - -ret_code_t nrf_drv_i2s_start(uint32_t * p_rx_buffer, - uint32_t * p_tx_buffer, - uint16_t buffer_size, - uint8_t flags) -{ - ASSERT((p_rx_buffer != NULL) || (p_tx_buffer != NULL)); - - uint16_t buffer_half_size = buffer_size / 2; - ASSERT(buffer_half_size != 0); - - VERIFY_MODULE_INITIALIZED(); - - ret_code_t err_code; - - if ((p_rx_buffer != NULL) && !nrf_drv_is_in_RAM(p_rx_buffer)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - if ((p_tx_buffer != NULL) && !nrf_drv_is_in_RAM(p_tx_buffer)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - // Initially we set up the peripheral to use the first half of each buffer, - // then in 'I2S_IRQHandler' we will switch to the second half. - nrf_i2s_transfer_set(NRF_I2S, buffer_half_size, p_rx_buffer, p_tx_buffer); - - m_cb.p_rx_buffer = p_rx_buffer; - m_cb.p_tx_buffer = p_tx_buffer; - m_cb.buffer_half_size = buffer_half_size; - m_cb.just_started = true; - - if ((flags & NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE) && - // [synchronized mode makes sense only when both RX and TX are enabled] - (m_cb.p_rx_buffer != NULL) && (m_cb.p_tx_buffer != NULL)) - { - m_cb.synchronized_mode = true; - m_cb.rx_ready = false; - m_cb.tx_ready = false; - } - else - { - m_cb.synchronized_mode = false; - } - - nrf_i2s_enable(NRF_I2S); - - m_cb.state = NRF_DRV_STATE_POWERED_ON; - - if (m_cb.p_tx_buffer != NULL) - { - // Get from the application the first portion of data to be sent - we - // need to have it in the transmit buffer before we start the transfer. - // Unless the synchronized mode is active. In this mode we must wait - // with this until the first portion of data is received, so here we - // just make sure that there will be silence on the SDOUT line prior - // to that moment. - if (m_cb.synchronized_mode) - { - memset(m_cb.p_tx_buffer, 0, - m_cb.buffer_half_size * sizeof(uint32_t)); - } - else - { - m_cb.handler(NULL, m_cb.p_tx_buffer, m_cb.buffer_half_size); - } - } - - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_RXPTRUPD); - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_TXPTRUPD); - nrf_i2s_int_enable(NRF_I2S, - NRF_I2S_INT_RXPTRUPD_MASK | NRF_I2S_INT_TXPTRUPD_MASK); - nrf_i2s_task_trigger(NRF_I2S, NRF_I2S_TASK_START); - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_i2s_stop(void) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - - // First disable interrupts, then trigger the STOP task, so no spurious - // RXPTRUPD and TXPTRUPD events (see FTPAN-55) will be processed. - nrf_i2s_int_disable(NRF_I2S, - NRF_I2S_INT_RXPTRUPD_MASK | NRF_I2S_INT_TXPTRUPD_MASK); - - nrf_i2s_task_trigger(NRF_I2S, NRF_I2S_TASK_STOP); - - nrf_i2s_disable(NRF_I2S); - - m_cb.state = NRF_DRV_STATE_INITIALIZED; - - NRF_LOG_INFO("Disabled."); -} - - -void I2S_IRQHandler(void) -{ - uint32_t const * p_data_received = NULL; - uint32_t * p_data_to_send = NULL; - - if (nrf_i2s_event_check(NRF_I2S, NRF_I2S_EVENT_TXPTRUPD)) - { - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_TXPTRUPD); - NRF_LOG_DEBUG("Event: %s.", - (uint32_t)EVT_TO_STR(NRF_I2S_EVENT_TXPTRUPD)); - - // If transmission is not enabled, but for some reason the TXPTRUPD - // event has been generated, just ignore it. - if (m_cb.p_tx_buffer != NULL) - { - uint32_t * p_tx_buffer_next; - if (nrf_i2s_tx_buffer_get(NRF_I2S) == m_cb.p_tx_buffer) - { - p_tx_buffer_next = m_cb.p_tx_buffer + m_cb.buffer_half_size; - } - else - { - p_tx_buffer_next = m_cb.p_tx_buffer; - } - nrf_i2s_tx_buffer_set(NRF_I2S, p_tx_buffer_next); - - m_cb.tx_ready = true; - - // Now the part of the buffer that we've configured as "next" should - // be filled by the application with proper data to be sent; - // the peripheral is sending data from the other part of the buffer - // (but it will finish soon...). - p_data_to_send = p_tx_buffer_next; - - } - } - - if (nrf_i2s_event_check(NRF_I2S, NRF_I2S_EVENT_RXPTRUPD)) - { - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_RXPTRUPD); - NRF_LOG_DEBUG("Event: %s.", - (uint32_t)EVT_TO_STR(NRF_I2S_EVENT_RXPTRUPD)); - - // If reception is not enabled, but for some reason the RXPTRUPD event - // has been generated, just ignore it. - if (m_cb.p_rx_buffer != NULL) - { - uint32_t * p_rx_buffer_next; - if (nrf_i2s_rx_buffer_get(NRF_I2S) == m_cb.p_rx_buffer) - { - p_rx_buffer_next = m_cb.p_rx_buffer + m_cb.buffer_half_size; - } - else - { - p_rx_buffer_next = m_cb.p_rx_buffer; - } - nrf_i2s_rx_buffer_set(NRF_I2S, p_rx_buffer_next); - - m_cb.rx_ready = true; - - // The RXPTRUPD event is generated for the first time right after - // the transfer is started. Since there is no data received yet at - // this point we only update the buffer pointer (it is done above), - // there is no callback to the application. - // [for synchronized mode this has to be handled differently - - // see below] - if (m_cb.just_started && !m_cb.synchronized_mode) - { - m_cb.just_started = false; - } - else - { - // The RXPTRUPD event indicates that from now on the peripheral - // will be filling the part of the buffer that was pointed at - // the time the event has been generated, hence now we can let - // the application process the data stored in the other part of - // the buffer - the one that we've just set to be filled next. - p_data_received = p_rx_buffer_next; - } - } - } - - // Call the data handler passing received data to the application and/or - // requesting data to be sent. - if (!m_cb.synchronized_mode) - { - if ((p_data_received != NULL) || (p_data_to_send != NULL)) - { - if (p_data_received != NULL) - { - NRF_LOG_DEBUG("Rx data:"); - NRF_LOG_HEXDUMP_DEBUG(p_data_received, - m_cb.buffer_half_size * sizeof(p_data_received[0])); - } - m_cb.handler(p_data_received, p_data_to_send, - m_cb.buffer_half_size); - if (p_data_to_send != NULL) - { - NRF_LOG_DEBUG("Tx data:"); - NRF_LOG_HEXDUMP_DEBUG(p_data_to_send, - m_cb.buffer_half_size * sizeof(p_data_to_send[0])); - } - } - } - // In the synchronized mode wait until the events for both RX and TX occur. - // And ignore the initial occurrences of these events, since they only - // indicate that the transfer has started - no data is received yet at - // that moment, so we have got nothing to pass to the application. - else - { - if (m_cb.rx_ready && m_cb.tx_ready) - { - m_cb.rx_ready = false; - m_cb.tx_ready = false; - - if (m_cb.just_started) - { - m_cb.just_started = false; - } - else - { - NRF_LOG_DEBUG("Rx data:"); - NRF_LOG_HEXDUMP_DEBUG(nrf_i2s_rx_buffer_get(NRF_I2S), - m_cb.buffer_half_size * sizeof(p_data_to_send[0])); - m_cb.handler(nrf_i2s_rx_buffer_get(NRF_I2S), - nrf_i2s_tx_buffer_get(NRF_I2S), - m_cb.buffer_half_size); - NRF_LOG_DEBUG("Tx data:"); - NRF_LOG_HEXDUMP_DEBUG(nrf_i2s_tx_buffer_get(NRF_I2S), - m_cb.buffer_half_size * sizeof(p_data_to_send[0])); - } - } - } -} -#endif //NRF_MODULE_ENABLED(I2S) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.h deleted file mode 100644 index 9ed4bf7..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/i2s/nrf_drv_i2s.h +++ /dev/null @@ -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. - * - */ -/**@file - * @addtogroup nrf_i2s I2S HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Inter-IC Sound (I2S) interface APIs. - * - * @defgroup nrf_drv_i2s I2S driver - * @{ - * @ingroup nrf_i2s - * @brief @tagAPI52 Inter-IC Sound (I2S) interface driver. - */ - - -#ifndef NRF_DRV_I2S_H__ -#define NRF_DRV_I2S_H__ - -#include "nordic_common.h" -#include "sdk_config.h" -#include "nrf_i2s.h" -#include "sdk_errors.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * @brief This value can be provided instead of a pin number for the signals - * SDOUT, SDIN, and MCK to specify that a given signal is not used - * and therefore does not need to be connected to a pin. - */ -#define NRF_DRV_I2S_PIN_NOT_USED 0xFF - -/** - * @brief Flag indicating that calls to the data handler for RX and TX should - * be synchronized, thus always combined into one call. - * - * Use this flag when calling @ref nrf_drv_i2s_start to force a common call - * to the @ref nrf_drv_i2s_data_handler_t "data handler" for RX and TX data. - * This is useful, for example, when received data should be processed and - * then be sent back. Obviously, this flag is only applicable when both - * directions (RX and TX) are enabled. - */ -#define NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE 0x01 - -/** - * @brief I2S driver configuration structure. - */ -typedef struct -{ - uint8_t sck_pin; ///< SCK pin number. - uint8_t lrck_pin; ///< LRCK pin number. - uint8_t mck_pin; ///< MCK pin number. - /**< Optional. Use @ref NRF_DRV_I2S_PIN_NOT_USED - * if this signal is not needed. */ - uint8_t sdout_pin; ///< SDOUT pin number. - /**< Optional. Use @ref NRF_DRV_I2S_PIN_NOT_USED - * if this signal is not needed. */ - uint8_t sdin_pin; ///< SDIN pin number. - /**< Optional. Use @ref NRF_DRV_I2S_PIN_NOT_USED - * if this signal is not needed. */ - uint8_t irq_priority; ///< Interrupt priority. - - nrf_i2s_mode_t mode; ///< Mode of operation. - nrf_i2s_format_t format; ///< Frame format. - nrf_i2s_align_t alignment; ///< Alignment of sample within a frame. - nrf_i2s_swidth_t sample_width; ///< Sample width. - nrf_i2s_channels_t channels; ///< Enabled channels. - nrf_i2s_mck_t mck_setup; ///< Master clock setup. - nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio. -} nrf_drv_i2s_config_t; - -/** - * @brief I2S driver default configuration. - */ -#define NRF_DRV_I2S_DEFAULT_CONFIG \ -{ \ - .sck_pin = I2S_CONFIG_SCK_PIN, \ - .lrck_pin = I2S_CONFIG_LRCK_PIN, \ - .mck_pin = I2S_CONFIG_MCK_PIN, \ - .sdout_pin = I2S_CONFIG_SDOUT_PIN, \ - .sdin_pin = I2S_CONFIG_SDIN_PIN, \ - .irq_priority = I2S_CONFIG_IRQ_PRIORITY, \ - .mode = (nrf_i2s_mode_t)I2S_CONFIG_MASTER, \ - .format = (nrf_i2s_format_t)I2S_CONFIG_FORMAT, \ - .alignment = (nrf_i2s_align_t)I2S_CONFIG_ALIGN, \ - .sample_width = (nrf_i2s_swidth_t)I2S_CONFIG_SWIDTH, \ - .channels = (nrf_i2s_channels_t)I2S_CONFIG_CHANNELS, \ - .mck_setup = (nrf_i2s_mck_t)I2S_CONFIG_MCK_SETUP, \ - .ratio = (nrf_i2s_ratio_t)I2S_CONFIG_RATIO, \ -} - -/** - * @brief I2S driver data handler type. - * - * A data handling function of this type must be specified during initialization - * of the driver. The driver will call this function when a new portion of data - * is received or a new portion of data should be prepared for transmission. - * The first case is indicated by a non-NULL value in the @p p_data_received - * parameter (which points to the memory containing the received data). - * Similarly, the second case is indicated by a non-NULL value in the - * @p p_data_to_send parameter (which points to where the data to be transmitted - * should be placed). - * - * @note The two cases mentioned above may be indicated separately or combined - * into one call (depending on the environment in which the driver is - * used). Therefore, both parameters should be checked and handled - * properly in every call. @ref NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE - * "Synchronized mode" can be used to always combine these indications. - * - * @param[in] p_data_received Pointer to the buffer with received data, - * or NULL if the handler is called to prepare - * transmission only. - * @param[out] p_data_to_send Pointer to the buffer where data to be sent - * should be written, or NULL if the handler is - * called for received data only. - * @param[in] number_of_words Length of data received and/or to be written - * (in 32-bit words). This value is always equal to - * half the size of the buffers set by the call - * to the @ref nrf_drv_i2s_start function. - */ -typedef void (* nrf_drv_i2s_data_handler_t)(uint32_t const * p_data_received, - uint32_t * p_data_to_send, - uint16_t number_of_words); - - -/** - * @brief Function for initializing the I2S driver. - * - * @param[in] p_config Pointer to the structure with initial configuration. - * If NULL, the default configuration is used. - * @param[in] handler Data handler provided by the user. Must not be NULL. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. - * @retval NRF_ERROR_INVALID_PARAM If the requested combination of configuration - * options is not allowed by the I2S peripheral. - */ -ret_code_t nrf_drv_i2s_init(nrf_drv_i2s_config_t const * p_config, - nrf_drv_i2s_data_handler_t handler); - -/** - * @brief Function for uninitializing the I2S driver. - */ -void nrf_drv_i2s_uninit(void); - -/** - * @brief Function for starting the continuous I2S transfer. - * - * The I2S data transfer can be performed in one of three modes: RX (reception) - * only, TX (transmission) only, or in both directions simultaneously. - * The mode is selected by specifying a proper buffer for a given direction - * in the call to this function or by passing NULL instead if this direction - * should be disabled. - * - * The length of the buffer (which is a common value for RX and TX if both - * directions are enabled) is specified in 32-bit words. One 32-bit memory - * word can either contain four 8-bit samples, two 16-bit samples, or one - * right-aligned 24-bit sample sign-extended to a 32-bit value. - * For a detailed memory mapping for different supported configurations, - * see the @linkProductSpecification52. - * - * The provided buffers are logically divided into two parts of equal size. - * One of them is in use by the peripheral (for storing received data or for - * getting data to be transmitted, respectively). The other part is provided - * to the application via a call to the defined @ref nrf_drv_i2s_data_handler_t - * "data handling function", so that the application can process the received - * data or prepare the next portion of data to be sent. The two parts are - * swapped every time @p buffer_size/2 data words are received or transmitted. - * - * Additional options are provided using the @p flags parameter: - * - @ref NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE - the calls to data handler should - * be done in a synchronized manner (one common call for TX and RX). - * Applicable only when both RX and TX are enabled. - * - * @attention All data exchange is done in the data handler only. In particular, - * no data should be written to the transmit buffer before calling - * this function (a proper call to the data handler to get the first - * portion of data to be sent will be done before the actual transfer - * starts). - * - * @note Peripherals using EasyDMA (like I2S) require the transfer buffers - * to be placed in the Data RAM region. If this condition is not met, - * this function will fail with the error code NRF_ERROR_INVALID_ADDR. - * - * @param[in] p_rx_buffer Pointer to the receive buffer. - * Pass NULL if reception is not required. - * @param[in] p_tx_buffer Pointer to the transmit buffer. - * Pass NULL if transmission is not required. - * @param[in] buffer_size Size of the buffers (in 32-bit words). - * The size must be an even number greater than 0. - * @param[in] flags Transfer options (0 for default settings). - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_STATE If a transfer was already started or - * the driver has not been initialized. - * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed - * in the Data RAM region. - */ -ret_code_t nrf_drv_i2s_start(uint32_t * p_rx_buffer, - uint32_t * p_tx_buffer, - uint16_t buffer_size, - uint8_t flags); - -/** - * @brief Function for stopping the I2S transfer. - */ -void nrf_drv_i2s_stop(void); - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_I2S_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c deleted file mode 100644 index 38be84b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c +++ /dev/null @@ -1,205 +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(LPCOMP) -#include "nrf_drv_lpcomp.h" -#include "nrf_assert.h" -#include "nrf_error.h" -#include "nrf_soc.h" -#include "nrf_drv_common.h" -#include "app_util_platform.h" -#include -#include -#include - -#define NRF_LOG_MODULE_NAME lpcomp - -#if LPCOMP_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL LPCOMP_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR LPCOMP_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR LPCOMP_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_LPCOMP_EVENT_READY ? "NRF_LPCOMP_EVENT_READY" : \ - (event == NRF_LPCOMP_EVENT_DOWN ? "NRF_LPCOMP_EVENT_DOWN" : \ - (event == NRF_LPCOMP_EVENT_UP ? "NRF_LPCOMP_EVENT_UP" : \ - (event == NRF_LPCOMP_EVENT_CROSS ? "NRF_LPCOMP_EVENT_CROSS" : "UNKNOWN EVENT")))) -#else //LPCOMP_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //LPCOMP_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - -static lpcomp_events_handler_t m_lpcomp_events_handler = NULL; -static nrf_drv_state_t m_state = NRF_DRV_STATE_UNINITIALIZED; - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - #define IRQ_HANDLER_NAME irq_handler_for_lpcomp - #define IRQ_HANDLER static void IRQ_HANDLER_NAME(void) - - IRQ_HANDLER; -#else - #define IRQ_HANDLER void LPCOMP_IRQHandler(void) -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -static void lpcomp_execute_handler(nrf_lpcomp_event_t event, uint32_t event_mask) -{ - if ( nrf_lpcomp_event_check(event) && nrf_lpcomp_int_enable_check(event_mask) ) - { - nrf_lpcomp_event_clear(event); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(event)); - - m_lpcomp_events_handler(event); - } -} - - -IRQ_HANDLER -{ - lpcomp_execute_handler(NRF_LPCOMP_EVENT_READY, LPCOMP_INTENSET_READY_Msk); - lpcomp_execute_handler(NRF_LPCOMP_EVENT_DOWN, LPCOMP_INTENSET_DOWN_Msk); - lpcomp_execute_handler(NRF_LPCOMP_EVENT_UP, LPCOMP_INTENSET_UP_Msk); - lpcomp_execute_handler(NRF_LPCOMP_EVENT_CROSS, LPCOMP_INTENSET_CROSS_Msk); -} - - -ret_code_t nrf_drv_lpcomp_init(const nrf_drv_lpcomp_config_t * p_config, - lpcomp_events_handler_t events_handler) -{ - ASSERT(p_config); - ret_code_t err_code; - - if (m_state != NRF_DRV_STATE_UNINITIALIZED) - { // LPCOMP driver is already initialized - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - if (nrf_drv_common_per_res_acquire(NRF_LPCOMP, IRQ_HANDLER_NAME) != NRF_SUCCESS) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } -#endif - - nrf_lpcomp_configure(&(p_config->hal) ); - - if (events_handler) - { - m_lpcomp_events_handler = events_handler; - } - else - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - nrf_lpcomp_input_select(p_config->input); - - switch (p_config->hal.detection) - { - case NRF_LPCOMP_DETECT_UP: - nrf_lpcomp_int_enable(LPCOMP_INTENSET_UP_Msk); - break; - - case NRF_LPCOMP_DETECT_DOWN: - nrf_lpcomp_int_enable(LPCOMP_INTENSET_DOWN_Msk); - break; - - case NRF_LPCOMP_DETECT_CROSS: - nrf_lpcomp_int_enable(LPCOMP_INTENSET_CROSS_Msk); - break; - - default: - break; - } - nrf_lpcomp_shorts_enable(NRF_LPCOMP_SHORT_READY_SAMPLE_MASK); - - nrf_drv_common_irq_enable(LPCOMP_IRQn, p_config->interrupt_priority); - - m_state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_lpcomp_uninit(void) -{ - ASSERT(m_state != NRF_DRV_STATE_UNINITIALIZED); - nrf_drv_common_irq_disable(LPCOMP_IRQn); - nrf_drv_lpcomp_disable(); -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - nrf_drv_common_per_res_release(NRF_LPCOMP); -#endif - m_state = NRF_DRV_STATE_UNINITIALIZED; - m_lpcomp_events_handler = NULL; - NRF_LOG_INFO("Uninitialized."); -} - -void nrf_drv_lpcomp_enable(void) -{ - ASSERT(m_state == NRF_DRV_STATE_INITIALIZED); - nrf_lpcomp_enable(); - nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_START); - m_state = NRF_DRV_STATE_POWERED_ON; - NRF_LOG_INFO("Enabled."); -} - -void nrf_drv_lpcomp_disable(void) -{ - ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); - nrf_lpcomp_disable(); - nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_STOP); - m_state = NRF_DRV_STATE_INITIALIZED; - NRF_LOG_INFO("Disabled."); -} - -void nrf_drv_lpcomp_event_handler_register(lpcomp_events_handler_t lpcomp_events_handler) -{ - m_lpcomp_events_handler = lpcomp_events_handler; -} - -#endif //NRF_MODULE_ENABLED(LPCOMP) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h deleted file mode 100644 index 7cd1852..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright (c) 2014 - 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 NRF_DRV_LPCOMP_H__ -#define NRF_DRV_LPCOMP_H__ - -#include "nrf_lpcomp.h" -#include "sdk_errors.h" -#include "nrf_drv_common.h" -#include "sdk_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup nrf_lpcomp LPCOMP HAL and driver - * @ingroup nrf_drivers - * @brief Low Power Comparator (LPCOMP) APIs. - * @details The LPCOMP HAL provides basic APIs for accessing the registers of Low Power Comparator. - * The LPCOMP driver provides APIs on a higher level. - * - * @defgroup nrf_drv_lpcomp LPCOMP driver - * @{ - * @ingroup nrf_lpcomp - * @brief Low Power Comparator (LPCOMP) driver. - */ - -/**@brief LPCOMP event handler function type. - * @param[in] event LPCOMP event. - */ -typedef void (* lpcomp_events_handler_t)(nrf_lpcomp_event_t event); - -/**@brief LPCOMP configuration. - */ -typedef struct -{ - nrf_lpcomp_config_t hal; /**< LPCOMP HAL configuration. */ - nrf_lpcomp_input_t input; /**< Input to be monitored. */ - uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */ -} nrf_drv_lpcomp_config_t; - -/** @brief LPCOMP driver default configuration including the LPCOMP HAL configuration. */ -#ifdef NRF52_SERIES -#define NRF_DRV_LPCOMP_DEFAULT_CONFIG \ - { \ - .hal = {(nrf_lpcomp_ref_t)LPCOMP_CONFIG_REFERENCE , (nrf_lpcomp_detect_t)LPCOMP_CONFIG_DETECTION, \ - (nrf_lpcomp_hysteresis_t)LPCOMP_CONFIG_HYST}, \ - .input = (nrf_lpcomp_input_t)LPCOMP_CONFIG_INPUT, \ - .interrupt_priority = LPCOMP_CONFIG_IRQ_PRIORITY \ - } -#else -#define NRF_DRV_LPCOMP_DEFAULT_CONFIG \ - { \ - .hal = {(nrf_lpcomp_ref_t)LPCOMP_CONFIG_REFERENCE , (nrf_lpcomp_detect_t)LPCOMP_CONFIG_DETECTION}, \ - .input = (nrf_lpcomp_input_t)LPCOMP_CONFIG_INPUT, \ - .interrupt_priority = LPCOMP_CONFIG_IRQ_PRIORITY \ - } -#endif - -/** - * @brief Function for initializing the LPCOMP driver. - * - * This function initializes the LPCOMP driver, but does not enable the peripheral or any interrupts. - * To start the driver, call the function nrf_drv_lpcomp_enable() after initialization. - * - * If no configuration structure is provided, the driver is initialized with the default settings. - * - * @param[in] p_config Initial configuration. If NULL, the default configuration is used. - * @param[in] events_handler Handler function. - * @retval NRF_ERROR_INVALID_PARAM If the configuration is invalid. - * @retval NRF_ERROR_INVALID_STATE If the driver has already been initialized. - */ -ret_code_t nrf_drv_lpcomp_init(const nrf_drv_lpcomp_config_t * p_config, - lpcomp_events_handler_t events_handler); - - -/** - * @brief Function for uninitializing the LCOMP driver. - * - * This function uninitializes the LPCOMP driver. The LPCOMP peripheral and - * its interrupts are disabled, and local variables are cleaned. After this call, you must - * initialize the driver again by calling nrf_drv_lpcomp_init() if you want to use it. - * - * @sa nrf_drv_lpcomp_disable() - * @sa nrf_drv_lpcomp_init() - */ -void nrf_drv_lpcomp_uninit(void); - -/**@brief Function for enabling the LPCOMP peripheral and interrupts. - * - * Before calling this function, the driver must be initialized. This function - * enables the LPCOMP peripheral and its interrupts. - * - * @sa nrf_drv_lpcomp_disable() - */ -void nrf_drv_lpcomp_enable(void); - -/**@brief Function for disabling the LPCOMP peripheral. - * - * Before calling this function, the driver must be initialized. This function disables the LPCOMP - * peripheral and its interrupts. - * - * @sa nrf_drv_lpcomp_enable() - */ -void nrf_drv_lpcomp_disable(void); - -/** - *@} - **/ - - -#ifdef __cplusplus -} -#endif - - #endif /* NRF_DRV_LPCOMP_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.c deleted file mode 100644 index 5a7aca4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.c +++ /dev/null @@ -1,365 +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(PDM) -#include "nrf_drv_pdm.h" -#include "nrf_assert.h" -#include "nrf_drv_common.h" -#include "nrf_gpio.h" - -#define NRF_LOG_MODULE_NAME pdm - -#if PDM_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL PDM_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR PDM_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR PDM_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_PDM_EVENT_STARTED ? "NRF_PDM_EVENT_STARTED" : \ - (event == NRF_PDM_EVENT_STOPPED ? "NRF_PDM_EVENT_STOPPED" : \ - (event == NRF_PDM_EVENT_END ? "NRF_PDM_EVENT_END" : "UNKNOWN EVENT"))) -#else //PDM_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //PDM_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - -/** @brief PDM interface status. */ -typedef enum -{ - NRF_PDM_STATE_IDLE, - NRF_PDM_STATE_RUNNING, - NRF_PDM_STATE_STARTING, - NRF_PDM_STATE_STOPPING -} nrf_drv_pdm_state_t; - - -/** @brief PDM interface control block.*/ -typedef struct -{ - nrf_drv_pdm_event_handler_t event_handler; ///< Event handler function pointer. - int16_t * buff_address[2]; ///< Sample buffers. - uint16_t buff_length[2]; ///< Length of the sample buffers. - nrf_drv_state_t drv_state; ///< Driver state. - volatile nrf_drv_pdm_state_t op_state; ///< PDM peripheral operation state. - uint8_t active_buffer; ///< Number of currently active buffer. - uint8_t error; ///< Driver error flag. - uint8_t irq_priority; ///< Interrupt priority. - volatile uint8_t irq_buff_request; ///< Request the next buffer in the ISR. -} nrf_drv_pdm_cb_t; - - -static nrf_drv_pdm_cb_t m_cb; - - -void PDM_IRQHandler(void) -{ - if (nrf_pdm_event_check(NRF_PDM_EVENT_STARTED)) - { - nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_PDM_EVENT_STARTED)); - - nrf_drv_pdm_evt_t evt; - uint8_t finished_buffer = m_cb.active_buffer; - - // Check if the next buffer was set before. - uint8_t next_buffer = (~m_cb.active_buffer) & 0x01; - if (m_cb.buff_address[next_buffer] || m_cb.op_state == NRF_PDM_STATE_STARTING) - { - evt.error = PDM_NO_ERROR; - m_cb.error = 0; - - // Release the full buffer if ready and request the next one. - if (m_cb.op_state == NRF_PDM_STATE_STARTING) - { - evt.buffer_released = 0; - m_cb.op_state = NRF_PDM_STATE_RUNNING; - } - else - { - evt.buffer_released = m_cb.buff_address[finished_buffer]; - m_cb.buff_address[finished_buffer] = 0; - m_cb.active_buffer = next_buffer; - } - evt.buffer_requested = true; - m_cb.event_handler(&evt); - } - else - { - // No next buffer available. Report an error. - // Do not request the new buffer as it was already done. - if (m_cb.error == 0) - { - evt.error = PDM_ERROR_OVERFLOW; - evt.buffer_released = 0; - evt.buffer_requested = false; - m_cb.error = 1; - m_cb.event_handler(&evt); - } - } - - if (m_cb.op_state == NRF_PDM_STATE_STARTING) - { - m_cb.op_state = NRF_PDM_STATE_RUNNING; - } - } - else if (nrf_pdm_event_check(NRF_PDM_EVENT_STOPPED)) - { - nrf_pdm_event_clear(NRF_PDM_EVENT_STOPPED); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_PDM_EVENT_STOPPED)); - nrf_pdm_disable(); - m_cb.op_state = NRF_PDM_STATE_IDLE; - - // Release the buffers. - nrf_drv_pdm_evt_t evt; - evt.error = PDM_NO_ERROR; - evt.buffer_requested = false; - if (m_cb.buff_address[m_cb.active_buffer]) - { - evt.buffer_released = m_cb.buff_address[m_cb.active_buffer]; - m_cb.buff_address[m_cb.active_buffer] = 0; - m_cb.event_handler(&evt); - } - - uint8_t second_buffer = (~m_cb.active_buffer) & 0x01; - if (m_cb.buff_address[second_buffer]) - { - evt.buffer_released = m_cb.buff_address[second_buffer]; - m_cb.buff_address[second_buffer] = 0; - m_cb.event_handler(&evt); - } - m_cb.active_buffer = 0; - - - } - - if (m_cb.irq_buff_request) - { - nrf_drv_pdm_evt_t evt; - evt.buffer_released = 0; - evt.error = PDM_NO_ERROR; - evt.buffer_requested = true; - m_cb.irq_buff_request = 0; - m_cb.event_handler(&evt); - } -} - - -ret_code_t nrf_drv_pdm_init(nrf_drv_pdm_config_t const * p_config, - nrf_drv_pdm_event_handler_t event_handler) -{ - ret_code_t err_code; - - if (m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - if ((p_config == NULL) - || (event_handler == NULL)) - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - if (p_config->gain_l > NRF_PDM_GAIN_MAXIMUM - || p_config->gain_r > NRF_PDM_GAIN_MAXIMUM) - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - - m_cb.buff_address[0] = 0; - m_cb.buff_address[1] = 0; - m_cb.active_buffer = 0; - m_cb.error = 0; - m_cb.event_handler = event_handler; - m_cb.op_state = NRF_PDM_STATE_IDLE; - - nrf_pdm_clock_set(p_config->clock_freq); - nrf_pdm_mode_set(p_config->mode, p_config->edge); - nrf_pdm_gain_set(p_config->gain_l, p_config->gain_r); - - nrf_gpio_cfg_output(p_config->pin_clk); - nrf_gpio_pin_clear(p_config->pin_clk); - nrf_gpio_cfg_input(p_config->pin_din, NRF_GPIO_PIN_NOPULL); - nrf_pdm_psel_connect(p_config->pin_clk, p_config->pin_din); - - nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED); - nrf_pdm_event_clear(NRF_PDM_EVENT_END); - nrf_pdm_event_clear(NRF_PDM_EVENT_STOPPED); - nrf_pdm_int_enable(NRF_PDM_INT_STARTED | NRF_PDM_INT_STOPPED); - m_cb.irq_priority = p_config->interrupt_priority; - nrf_drv_common_irq_enable(PDM_IRQn, m_cb.irq_priority); - m_cb.drv_state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_pdm_uninit(void) -{ - nrf_pdm_disable(); - nrf_pdm_psel_disconnect(); - m_cb.drv_state = NRF_DRV_STATE_UNINITIALIZED; - NRF_LOG_INFO("Uninitialized."); -} - -static void pdm_start() -{ - m_cb.drv_state = NRF_DRV_STATE_POWERED_ON; - nrf_pdm_enable(); - nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED); - nrf_pdm_task_trigger(NRF_PDM_TASK_START); -} - -static void pdm_buf_request() -{ - m_cb.irq_buff_request = 1; - NVIC_SetPendingIRQ(PDM_IRQn); -} - -ret_code_t nrf_drv_pdm_start(void) -{ - ASSERT(m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED); - ret_code_t err_code; - - if (m_cb.op_state != NRF_PDM_STATE_IDLE) - { - if (m_cb.op_state == NRF_PDM_STATE_RUNNING) - { - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - m_cb.op_state = NRF_PDM_STATE_STARTING; - pdm_buf_request(); - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -ret_code_t nrf_drv_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length) -{ - if (m_cb.drv_state == NRF_DRV_STATE_UNINITIALIZED) - { - return NRF_ERROR_INVALID_STATE; - } - if (m_cb.op_state == NRF_PDM_STATE_STOPPING) - { - return NRF_ERROR_BUSY; - } - if ((!buffer) || (buffer_length > NRF_PDM_MAX_BUFFER_SIZE)) - { - return NRF_ERROR_INVALID_PARAM; - } - - ret_code_t err_code = NRF_SUCCESS; - - // Enter the PDM critical section. - nrf_drv_common_irq_disable(PDM_IRQn); - - uint8_t next_buffer = (~m_cb.active_buffer) & 0x01; - if (m_cb.op_state == NRF_PDM_STATE_STARTING) - { - next_buffer = 0; - } - - if (m_cb.buff_address[next_buffer]) - { - // Buffer already set. - err_code = NRF_ERROR_BUSY; - } - else - { - m_cb.buff_address[next_buffer] = buffer; - m_cb.buff_length[next_buffer] = buffer_length; - nrf_pdm_buffer_set((uint32_t *)buffer, buffer_length); - - if (m_cb.drv_state != NRF_DRV_STATE_POWERED_ON) - { - pdm_start(); - } - } - - nrf_drv_common_irq_enable(PDM_IRQn, m_cb.irq_priority); - return err_code; -} - -ret_code_t nrf_drv_pdm_stop(void) -{ - ASSERT(m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED); - ret_code_t err_code; - - if (m_cb.op_state != NRF_PDM_STATE_RUNNING) - { - if (m_cb.op_state == NRF_PDM_STATE_IDLE || m_cb.op_state == NRF_PDM_STATE_STARTING) - { - nrf_pdm_disable(); - m_cb.op_state = NRF_PDM_STATE_IDLE; - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - m_cb.drv_state = NRF_DRV_STATE_INITIALIZED; - m_cb.op_state = NRF_PDM_STATE_STOPPING; - - nrf_pdm_task_trigger(NRF_PDM_TASK_STOP); - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -#endif //NRF_MODULE_ENABLED(PDM) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.h deleted file mode 100644 index 7e71885..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pdm/nrf_drv_pdm.h +++ /dev/null @@ -1,226 +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. - * - */ -/** - * @addtogroup nrf_pdm PDM HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Pulse density modulation (PDM) interface APIs. - * - * The PDM HAL provides basic APIs for accessing the registers of the PDM interface peripheral. - * The PDM driver provides APIs on a higher level. - * - * @defgroup nrf_drv_pdm PDM driver - * @{ - * @ingroup nrf_pdm - * - * @brief @tagAPI52 Pulse density modulation (PDM) interface driver. - */ - - -#ifndef NRF_DRV_PDM_H__ -#define NRF_DRV_PDM_H__ - -#include "sdk_config.h" -#include "nrf_pdm.h" -#include "sdk_errors.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define NRF_PDM_MAX_BUFFER_SIZE 32767 - - -/** - * @brief PDM error type. - */ -typedef enum -{ - PDM_NO_ERROR = 0, - PDM_ERROR_OVERFLOW = 1 -} nrf_drv_pdm_error_t; - -/** - * @brief PDM event structure. - */ -typedef struct -{ - bool buffer_requested; ///< Buffer request flag. - int16_t * buffer_released; ///< Pointer to the released buffer. Can be NULL. - nrf_drv_pdm_error_t error; ///< Error type. -} nrf_drv_pdm_evt_t; - -/** - * @brief PDM interface driver configuration structure. - */ -typedef struct -{ - nrf_pdm_mode_t mode; ///< Interface operation mode. - nrf_pdm_edge_t edge; ///< Sampling mode. - uint8_t pin_clk; ///< CLK pin. - uint8_t pin_din; ///< DIN pin. - nrf_pdm_freq_t clock_freq; ///< Clock frequency. - nrf_pdm_gain_t gain_l; ///< Left channel gain. - nrf_pdm_gain_t gain_r; ///< Right channel gain. - uint8_t interrupt_priority; ///< Interrupt priority. -} nrf_drv_pdm_config_t; - - -/** - * @brief Macro for setting @ref nrf_drv_pdm_config_t to default settings - * in single ended mode. - * - * @param PIN_CLK CLK output pin. - * @param PIN_DIN DIN input pin. - */ -#define NRF_DRV_PDM_DEFAULT_CONFIG(PIN_CLK, PIN_DIN) \ -{ \ - .mode = (nrf_pdm_mode_t)PDM_CONFIG_MODE, \ - .edge = (nrf_pdm_edge_t)PDM_CONFIG_EDGE, \ - .pin_clk = PIN_CLK, \ - .pin_din = PIN_DIN, \ - .clock_freq = (nrf_pdm_freq_t)PDM_CONFIG_CLOCK_FREQ, \ - .gain_l = NRF_PDM_GAIN_DEFAULT, \ - .gain_r = NRF_PDM_GAIN_DEFAULT, \ - .interrupt_priority = PDM_CONFIG_IRQ_PRIORITY \ -} - - -/** - * @brief Handler for PDM interface ready events. - * - * This event handler is called on buffer request, error or when a buffer is full - * and ready to be processed. - * - * @param[in] evt Pointer to the PDM event structure. - */ -typedef void (*nrf_drv_pdm_event_handler_t)(nrf_drv_pdm_evt_t const * const evt); - - -/** - * @brief Function for initializing the PDM interface. - * - * @param[in] p_config Pointer to a configuration structure. Cannot be NULL. - * @param[in] event_handler Event handler provided by the user. Cannot be NULL. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. - * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were specified. - */ -ret_code_t nrf_drv_pdm_init(nrf_drv_pdm_config_t const * p_config, - nrf_drv_pdm_event_handler_t event_handler); - - -/** - * @brief Function for uninitializing the PDM interface. - * - * This function stops PDM sampling, if it is in progress. - */ -void nrf_drv_pdm_uninit(void); - - -/** - * @brief Function for getting the address of a PDM interface task. - * - * @param[in] task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_pdm_task_address_get(nrf_pdm_task_t task) -{ - return nrf_pdm_task_address_get(task); -} - - -/** - * @brief Function for getting the state of the PDM interface. - * - * @retval TRUE If the PDM interface is enabled. - * @retval FALSE If the PDM interface is disabled. - */ -__STATIC_INLINE bool nrf_drv_pdm_enable_check() -{ - return nrf_pdm_enable_check(); -} - - -/** - * @brief Function for starting PDM sampling. - * - * @retval NRF_SUCCESS If sampling was started successfully or was already in progress. - * @retval NRF_ERROR_BUSY If a previous start/stop operation is in progress. - */ -ret_code_t nrf_drv_pdm_start(void); - - -/** - * @brief Function for stopping PDM sampling. - * - * When this function is called, the PDM interface is stopped after finishing - * the current frame. - * The event handler function might be called once more after calling this function. - * - * @retval NRF_SUCCESS If sampling was stopped successfully or was already stopped before. - * @retval NRF_ERROR_BUSY If a previous start/stop operation is in progress. - */ -ret_code_t nrf_drv_pdm_stop(void); - -/** - * @brief Function for supplying the sample buffer. - * - * Call this function after every buffer request event. - * - * @param[in] buffer Pointer to the receive buffer. Cannot be NULL. - * @param[in] buffer_length Length of the receive buffer in 16-bit words. - * - * @retval NRF_SUCCESS If the buffer was applied successfully. - * @retval NRF_ERROR_BUSY If the buffer was already supplied or the peripheral is currently being stopped. - * @retval NRF_ERROR_INVALID_STATE If the driver was not initialized. - * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were provided. - */ -ret_code_t nrf_drv_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length); - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_PDM_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.h deleted file mode 100644 index bb645e3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.h +++ /dev/null @@ -1,371 +0,0 @@ -/** - * Copyright (c) 2017 - 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 NRF_DRV_POWER_H__ -#define NRF_DRV_POWER_H__ - -#include -#include -#include "nrf_power.h" -#include "sdk_config.h" -#include "nrf_drv_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup nrf_power Power HAL and driver - * @ingroup nrf_drivers - * @brief POWER peripheral APIs. - * - * The power peripheral HAL provides basic APIs for accessing - * the registers of the POWER peripheral. - * The POWER driver provides APIs on a higher level. - */ - -/** - * @defgroup nrf_drv_power POWER driver - * @{ - * @ingroup nrf_power - * @brief Driver for managing events and the state of POWER peripheral. - * - */ - -/** - * @brief Power mode possible configurations - */ -typedef enum -{ - NRF_DRV_POWER_MODE_CONSTLAT, /**< Constant latency mode *///!< NRF_DRV_POWER_MODE_CONSTLAT - NRF_DRV_POWER_MODE_LOWPWR /**< Low power mode *///!< NRF_DRV_POWER_MODE_LOWPWR -}nrf_drv_power_mode_t; - -#if NRF_POWER_HAS_SLEEPEVT -/** - * @brief Events from power system - */ -typedef enum -{ - NRF_DRV_POWER_SLEEP_EVT_ENTER, /**< CPU entered WFI/WFE sleep - * - * Keep in mind that if this interrupt is enabled, - * it means that CPU was waken up just after WFI by this interrupt. - */ - NRF_DRV_POWER_SLEEP_EVT_EXIT /**< CPU exited WFI/WFE sleep */ -}nrf_drv_power_sleep_evt_t; -#endif /* NRF_POWER_HAS_SLEEPEVT */ - -#if NRF_POWER_HAS_USBREG -/** - * @brief Events from USB power system - */ -typedef enum -{ - NRF_DRV_POWER_USB_EVT_DETECTED, /**< USB power detected on the connector (plugged in). */ - NRF_DRV_POWER_USB_EVT_REMOVED, /**< USB power removed from the connector. */ - NRF_DRV_POWER_USB_EVT_READY /**< USB power regulator ready. */ -}nrf_drv_power_usb_evt_t; - -/** - * @brief USB power state - * - * The single enumerator that holds all data about current state of USB - * related POWER. - * - * Organized this way that higher power state has higher numeric value - */ -typedef enum -{ - NRF_DRV_POWER_USB_STATE_DISCONNECTED, /**< No power on USB lines detected */ - NRF_DRV_POWER_USB_STATE_CONNECTED, /**< The USB power is detected, but USB power regulator is not ready */ - NRF_DRV_POWER_USB_STATE_READY /**< From the power point of view USB is ready for working */ -}nrf_drv_power_usb_state_t; -#endif /* NRF_POWER_HAS_USBREG */ - -/** - * @name Callback types - * - * Defined types of callback functions - * @{ - */ -/** - * @brief Event handler for power failure warning - */ -typedef void (*nrf_drv_power_pofwarn_event_handler_t)(void); - -#if NRF_POWER_HAS_SLEEPEVT -/** - * @brief Event handler for entering/exiting sleep - * - * @param event Event type - */ -typedef void (*nrf_drv_power_sleep_event_handler_t)(nrf_drv_power_sleep_evt_t event); -#endif - -#if NRF_POWER_HAS_USBREG -/** - * @brief Event handler for USB related power events - * - * @param event Event type - */ -typedef void (*nrf_drv_power_usb_event_handler_t)(nrf_drv_power_usb_evt_t event); -#endif -/** @} */ - -/** - * @brief General power configuration - * - * Parameters required to initialize power driver. - */ -typedef struct -{ - /** - * @brief Enable main DCDC regulator - * - * This bit only informs the driver that elements for DCDC regulator - * are installed and regulator can be used. - * The regulator would be enabled or disabled automatically - * automatically by the hardware, basing on current power requirement. - */ - bool dcdcen:1; - -#if NRF_POWER_HAS_VDDH - /** - * @brief Enable HV DCDC regulator - * - * This bit only informs the driver that elements for DCDC regulator - * are installed and regulator can be used. - * The regulator would be enabled or disabled automatically - * automatically by the hardware, basing on current power requirement. - */ - bool dcdcenhv: 1; -#endif -}nrf_drv_power_config_t; - -/** - * @brief The configuration for power failure comparator - * - * Configuration used to enable and configure power failure comparator - */ -typedef struct -{ - nrf_drv_power_pofwarn_event_handler_t handler; //!< Event handler - nrf_power_pof_thr_t thr; //!< Threshold for power failure detection -#if NRF_POWER_HAS_VDDH - nrf_power_pof_thrvddh_t thrvddh; //!< Threshold for power failure detection on VDDH pin -#endif -}nrf_drv_power_pofwarn_config_t; - -#if NRF_POWER_HAS_SLEEPEVT -/** - * @brief The configuration of sleep event processing - * - * Configuration used to enable and configure sleep event handling - */ -typedef struct -{ - nrf_drv_power_sleep_event_handler_t handler; //!< Event handler - bool en_enter:1; //!< Enable event on sleep entering - bool en_exit :1; //!< Enable event on sleep exiting -}nrf_drv_power_sleepevt_config_t; -#endif - -#if NRF_POWER_HAS_USBREG -/** - * @brief The configuration of USB related power events - * - * Configuration used to enable and configure USB power event handling - */ -typedef struct -{ - nrf_drv_power_usb_event_handler_t handler; //!< Event processing -}nrf_drv_power_usbevt_config_t; -#endif /* NRF_POWER_HAS_USBREG */ - -/** - * @brief Function for checking if driver is already initialized - * - * This function is used to check whatever common POWER_CLOCK common interrupt - * should be disabled or not if @ref nrf_drv_clock tries to disable the interrupt. - * - * @retval true Driver is initialized - * @retval false Driver is uninitialized - * - * @sa nrf_drv_power_uninit - */ -bool nrf_drv_power_init_check(void); - -/** - * @brief Initialize power module driver - * - * Enabled power module driver would process all the interrupts from power system. - * - * @param[in] p_config Driver configuration. Can be NULL - the default configuration - * from @em sdk_config.h file would be used then. - * - * @retval NRF_ERROR_INVALID_STATE Power driver has to be enabled - * before SoftDevice. - * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED Module is initialized already. - * @retval NRF_SUCCESS Successfully initialized. - */ -ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config); - -/** - * @brief Unintialize power module driver - * - * Disables all the interrupt handling in the module. - * - * @sa nrf_drv_power_init - */ -void nrf_drv_power_uninit(void); - -/** - * @brief Initialize power failure comparator - * - * Configures and setups the power failure comparator and enables it. - * - * @param[in] p_config Configuration with values and event handler. - * If event handler is set to NULL, interrupt would be disabled. - * - * @retval NRF_ERROR_INVALID_STATE POF is initialized when SD is enabled and - * the configuration differs from the old one and - * is not possible to be set using SD interface. - * @retval NRF_SUCCESS Successfully initialized and configured. - */ -ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_config); - -/** - * @brief Turn off the power failure comparator - * - * Disables and clears the settings of the power failure comparator. - */ -void nrf_drv_power_pof_uninit(void); - -#if NRF_POWER_HAS_SLEEPEVT -/** - * @brief Initialize sleep entering and exiting events processing - * - * Configures and setups the sleep event processing. - * - * @param[in] p_config Configuration with values and event handler. - * - * @sa nrf_drv_power_sleepevt_uninit - * - * @note Sleep events are not available when SoftDevice is enabled. - * @note If sleep event is enabled when SoftDevice is initialized, sleep events - * would be automatically disabled - it is the limitation of the - * SoftDevice itself. - * - * @retval NRF_ERROR_INVALID_STATE This event cannot be initialized - * when SD is enabled. - * @retval NRF_SUCCESS Successfully initialized and configured. - */ -ret_code_t nrf_drv_power_sleepevt_init(nrf_drv_power_sleepevt_config_t const * p_config); - -/** - * @brief Uninitialize sleep entering and exiting events processing - * - * @sa nrf_drv_power_sleepevt_init - */ -void nrf_drv_power_sleepevt_uninit(void); -#endif /* NRF_POWER_HAS_SLEEPEVT */ - -#if NRF_POWER_HAS_USBREG -/** - * @brief Initialize USB power event processing - * - * Configures and setups the USB power event processing. - * - * @param[in] p_config Configuration with values and event handler. - * - * @sa nrf_drv_power_usbevt_uninit - * - * @retval NRF_ERROR_INVALID_STATE This event cannot be initialized - * when SD is enabled and SD does not support - * USB power events. - * @retval NRF_SUCCESS Successfully initialized and configured. - */ -ret_code_t nrf_drv_power_usbevt_init(nrf_drv_power_usbevt_config_t const * p_config); - -/** - * @brief Uninitalize USB power event processing - * - * @sa nrf_drv_power_usbevt_init - */ -void nrf_drv_power_usbevt_uninit(void); - -/** - * @brief Get the status of USB power - * - * @return Current USB power status - */ -__STATIC_INLINE nrf_drv_power_usb_state_t nrf_drv_power_usbstatus_get(void); - -#endif /* NRF_POWER_HAS_USBREG */ - -/** @} */ - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -#if NRF_POWER_HAS_USBREG -__STATIC_INLINE nrf_drv_power_usb_state_t nrf_drv_power_usbstatus_get(void) -{ - uint32_t status = nrf_power_usbregstatus_get(); - if (0 == (status & NRF_POWER_USBREGSTATUS_VBUSDETECT_MASK)) - { - return NRF_DRV_POWER_USB_STATE_DISCONNECTED; - } - if (0 == (status & NRF_POWER_USBREGSTATUS_OUTPUTRDY_MASK)) - { - return NRF_DRV_POWER_USB_STATE_CONNECTED; - } - return NRF_DRV_POWER_USB_STATE_READY; -} -#endif /* NRF_POWER_HAS_USBREG */ - -#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ - - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_DRV_POWER_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.c deleted file mode 100644 index 54611d8..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.c +++ /dev/null @@ -1,540 +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(PPI) -#include - -#include "nrf.h" -#include "nrf_drv_ppi.h" -#include "nrf_drv_common.h" -#include "nrf_ppi.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME ppi - -#if PPI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL PPI_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR PPI_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR PPI_CONFIG_DEBUG_COLOR -#else //PPI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //PPI_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - -static nrf_drv_state_t m_drv_state; /**< Driver state */ -static uint32_t m_channels_allocated; /**< Bitmap representing channels availability. 1 when a channel is allocated, 0 otherwise. */ -static uint8_t m_groups_allocated; /**< Bitmap representing groups availability. 1 when a group is allocated, 0 otherwise.*/ - - -/**@brief Compute a group mask (needed for driver internals, not used for NRF_PPI registers). - * @param[in] group Group number to transform to a mask. - * @retval Group mask. - */ -__STATIC_INLINE uint32_t group_to_mask(nrf_ppi_channel_group_t group) -{ - return (1uL << (uint32_t) group); -} - - -/**@brief Check whether a channel is a programmable channel and can be used by an application. - * @param[in] channel Channel to check. - * @retval true The channel is a programmable application channel. - * false The channel is used by a SoftDevice or is preprogrammed. - */ -__STATIC_INLINE bool is_programmable_app_channel(nrf_ppi_channel_t channel) -{ - return ((NRF_PPI_PROG_APP_CHANNELS_MASK & nrf_drv_ppi_channel_to_mask(channel)) != 0); -} - - -/**@brief Check whether a channels can be used by an application. - * @param[in] channel Channel mask to check. - * @retval true All specified channels can be used by an application. - * false At least one specified channel is used by a SoftDevice. - */ -__STATIC_INLINE bool are_app_channels(uint32_t channel_mask) -{ - //lint -e(587) - return ((~(NRF_PPI_ALL_APP_CHANNELS_MASK) & channel_mask) == 0); -} - - -/**@brief Check whether a channel can be used by an application. - * @param[in] channel Channel to check. - * @retval true The channel can be used by an application. - * false The channel is used by a SoftDevice. - */ -__STATIC_INLINE bool is_app_channel(nrf_ppi_channel_t channel) -{ - return are_app_channels(nrf_drv_ppi_channel_to_mask(channel)); -} - - -/**@brief Check whether a channel group can be used by an application. - * @param[in] group Group to check. - * @retval true The group is an application group. - * false The group is not an application group (this group either does not exist or - * it is used by a SoftDevice). - */ -__STATIC_INLINE bool is_app_group(nrf_ppi_channel_group_t group) -{ - return ((NRF_PPI_ALL_APP_GROUPS_MASK & group_to_mask(group)) != 0); -} - - -/**@brief Check whether a channel is allocated. - * @param[in] channel_num Channel number to check. - * @retval true The channel is allocated. - * false The channel is not allocated. - */ -__STATIC_INLINE bool is_allocated_channel(nrf_ppi_channel_t channel) -{ - return ((m_channels_allocated & nrf_drv_ppi_channel_to_mask(channel)) != 0); -} - - -/**@brief Set channel allocated indication. - * @param[in] channel_num Specifies the channel to set the "allocated" indication. - */ -__STATIC_INLINE void channel_allocated_set(nrf_ppi_channel_t channel) -{ - m_channels_allocated |= nrf_drv_ppi_channel_to_mask(channel); -} - - -/**@brief Clear channel allocated indication. - * @param[in] channel_num Specifies the channel to clear the "allocated" indication. - */ -__STATIC_INLINE void channel_allocated_clr(nrf_ppi_channel_t channel) -{ - m_channels_allocated &= ~nrf_drv_ppi_channel_to_mask(channel); -} - - -/**@brief Clear all allocated channels. - */ -__STATIC_INLINE void channel_allocated_clr_all(void) -{ - m_channels_allocated &= ~NRF_PPI_ALL_APP_CHANNELS_MASK; -} - - -/**@brief Check whether a group is allocated. - * @param[in] group_num Group number to check. - * @retval true The group is allocated. - * false The group is not allocated. - */ -__STATIC_INLINE bool is_allocated_group(nrf_ppi_channel_group_t group) -{ - return ((m_groups_allocated & group_to_mask(group)) != 0); -} - - -/**@brief Set group allocated indication. - * @param[in] group_num Specifies the group to set the "allocated" indication. - */ -__STATIC_INLINE void group_allocated_set(nrf_ppi_channel_group_t group) -{ - m_groups_allocated |= group_to_mask(group); -} - - -/**@brief Clear group allocated indication. - * @param[in] group_num Specifies the group to clear the "allocated" indication. - */ -__STATIC_INLINE void group_allocated_clr(nrf_ppi_channel_group_t group) -{ - m_groups_allocated &= ~group_to_mask(group); -} - - -/**@brief Clear all allocated groups. - */ -__STATIC_INLINE void group_allocated_clr_all() -{ - m_groups_allocated &= ~NRF_PPI_ALL_APP_GROUPS_MASK; -} - - -uint32_t nrf_drv_ppi_init(void) -{ - uint32_t err_code; - - if (m_drv_state == NRF_DRV_STATE_UNINITIALIZED) - { - m_drv_state = NRF_DRV_STATE_INITIALIZED; - err_code = NRF_SUCCESS; - } - else - { - - err_code = NRF_ERROR_MODULE_ALREADY_INITIALIZED; - } - - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_uninit(void) -{ - ret_code_t err_code = NRF_SUCCESS; - uint32_t mask = NRF_PPI_ALL_APP_GROUPS_MASK; - nrf_ppi_channel_group_t group; - - if (m_drv_state == NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - m_drv_state = NRF_DRV_STATE_UNINITIALIZED; - - // Disable all channels and groups - nrf_ppi_channels_disable(NRF_PPI_ALL_APP_CHANNELS_MASK); - - for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++) - { - if (mask & group_to_mask(group)) - { - nrf_ppi_channel_group_clear(group); - } - } - channel_allocated_clr_all(); - group_allocated_clr_all(); - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel) -{ - uint32_t err_code = NRF_SUCCESS; - nrf_ppi_channel_t channel; - uint32_t mask = 0; - - err_code = NRF_ERROR_NO_MEM; - - mask = NRF_PPI_PROG_APP_CHANNELS_MASK; - for (channel = NRF_PPI_CHANNEL0; mask != 0; mask &= ~nrf_drv_ppi_channel_to_mask(channel), channel++) - { - CRITICAL_REGION_ENTER(); - if ((mask & nrf_drv_ppi_channel_to_mask(channel)) && (!is_allocated_channel(channel))) - { - channel_allocated_set(channel); - *p_channel = channel; - err_code = NRF_SUCCESS; - } - CRITICAL_REGION_EXIT(); - if (err_code == NRF_SUCCESS) - { - NRF_LOG_INFO("Allocated channel: %d.", channel); - break; - } - } - - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_channel_free(nrf_ppi_channel_t channel) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_programmable_app_channel(channel)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else - { - // First disable this channel - nrf_ppi_channel_disable(channel); - CRITICAL_REGION_ENTER(); - channel_allocated_clr(channel); - CRITICAL_REGION_EXIT(); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep) -{ - VERIFY_PARAM_NOT_NULL((uint32_t *)eep); - VERIFY_PARAM_NOT_NULL((uint32_t *)tep); - - ret_code_t err_code = NRF_SUCCESS; - - if (!is_programmable_app_channel(channel)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (!is_allocated_channel(channel)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else - { - nrf_ppi_channel_endpoint_setup(channel, eep, tep); - NRF_LOG_INFO("Assigned channel: %d, event end point: %x, task end point: %x.", channel, eep, tep); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -uint32_t nrf_drv_ppi_channel_fork_assign(nrf_ppi_channel_t channel, uint32_t fork_tep) -{ - ret_code_t err_code = NRF_SUCCESS; -#ifdef PPI_FEATURE_FORKS_PRESENT - if (!is_programmable_app_channel(channel)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (!is_allocated_channel(channel)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else - { - nrf_ppi_fork_endpoint_setup(channel, fork_tep); - NRF_LOG_INFO("Fork assigned channel: %d, task end point: %d.", channel, fork_tep); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -#else - err_code = NRF_ERROR_NOT_SUPPORTED; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -#endif -} - -uint32_t nrf_drv_ppi_channel_enable(nrf_ppi_channel_t channel) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_channel(channel)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (is_programmable_app_channel(channel) && !is_allocated_channel(channel)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else - { - nrf_ppi_channel_enable(channel); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_channel_disable(nrf_ppi_channel_t channel) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_channel(channel)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (is_programmable_app_channel(channel) && !is_allocated_channel(channel)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else - { - nrf_ppi_channel_disable(channel); - err_code = NRF_SUCCESS; - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group) -{ - uint32_t err_code; - uint32_t mask = 0; - nrf_ppi_channel_group_t group; - - err_code = NRF_ERROR_NO_MEM; - - mask = NRF_PPI_ALL_APP_GROUPS_MASK; - for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++) - { - CRITICAL_REGION_ENTER(); - if ((mask & group_to_mask(group)) && (!is_allocated_group(group))) - { - group_allocated_set(group); - *p_group = group; - err_code = NRF_SUCCESS; - } - CRITICAL_REGION_EXIT(); - if (err_code == NRF_SUCCESS) - { - NRF_LOG_INFO("Allocated group: %d.", group); - break; - } - } - - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_group(group)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_group(group)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else - { - nrf_ppi_group_disable(group); - CRITICAL_REGION_ENTER(); - group_allocated_clr(group); - CRITICAL_REGION_EXIT(); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_group(group)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (!is_allocated_group(group)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else - { - nrf_ppi_group_enable(group); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -uint32_t nrf_drv_ppi_group_disable(nrf_ppi_channel_group_t group) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_group(group)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else - { - nrf_ppi_group_disable(group); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -uint32_t nrf_drv_ppi_channels_remove_from_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_group(group)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (!is_allocated_group(group)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else if (!are_app_channels(channel_mask)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else - { - CRITICAL_REGION_ENTER(); - nrf_ppi_channels_remove_from_group(channel_mask, group); - CRITICAL_REGION_EXIT(); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group) -{ - ret_code_t err_code = NRF_SUCCESS; - - if (!is_app_group(group)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else if (!is_allocated_group(group)) - { - err_code = NRF_ERROR_INVALID_STATE; - } - else if (!are_app_channels(channel_mask)) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - else - { - CRITICAL_REGION_ENTER(); - nrf_ppi_channels_include_in_group(channel_mask, group); - CRITICAL_REGION_EXIT(); - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} -#endif //NRF_MODULE_ENABLED(PPI) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.h deleted file mode 100644 index 91fdf96..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/ppi/nrf_drv_ppi.h +++ /dev/null @@ -1,316 +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 NRF_DRV_PPI_H -#define NRF_DRV_PPI_H - -/*lint ++flb "Enter library region" */ -#include "sdk_errors.h" -#include "nrf_ppi.h" -#include -#include - -/** @file - * - * @addtogroup nrf_ppi PPI HAL and driver - * @ingroup nrf_drivers - * @brief Programmable Peripheral Interconnect (PPI) APIs. - * - * @details The PPI HAL provides basic APIs for accessing the registers of the PPI. - * The PPI driver provides APIs on a higher level. - * - * @defgroup nrf_drv_ppi PPI driver - * @{ - * @ingroup nrf_ppi - * - * @brief Programmable Peripheral Interconnect (PPI) driver. - */ - -#include "sdk_resources.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if PPI_CH_NUM > 16 -#define NRF_PPI_ALL_APP_CHANNELS_MASK ((uint32_t)0xFFFFFFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< All PPI channels available to the application. */ -#define NRF_PPI_PROG_APP_CHANNELS_MASK ((uint32_t)0x000FFFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< Programmable PPI channels available to the application. */ -#else -#define NRF_PPI_ALL_APP_CHANNELS_MASK ((uint32_t)0xFFF0FFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< All PPI channels available to the application. */ -#define NRF_PPI_PROG_APP_CHANNELS_MASK ((uint32_t)0x0000FFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< Programmable PPI channels available to the application. */ -#endif - -#define NRF_PPI_ALL_APP_GROUPS_MASK (((1uL << PPI_GROUP_NUM) - 1) & ~(NRF_PPI_GROUPS_USED)) /**< All PPI groups available to the application. */ - - -/**@brief Function for initializing PPI module. - * - * @retval NRF_SUCCESS If the module was successfully initialized. - * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized. - */ -uint32_t nrf_drv_ppi_init(void); - -/**@brief Function for uninitializing the PPI module. - * - * This function also disables all channels and clears the channel groups. - * - * @retval NRF_SUCCESS If the module was successfully uninitialized. - * @retval NRF_ERROR_INVALID_STATE If the module has not been initialized yet. - * @retval NRF_ERROR_INTERNAL If the channels or groups could not be disabled. - */ -uint32_t nrf_drv_ppi_uninit(void); - -/**@brief Function for allocating a PPI channel. - * @details This function allocates the first unused PPI channel. - * - * @param[out] p_channel Pointer to the PPI channel that has been allocated. - * - * @retval NRF_SUCCESS If the channel was successfully allocated. - * @retval NRF_ERROR_NO_MEM If there is no available channel to be used. - */ -uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel); - -/**@brief Function for freeing a PPI channel. - * @details This function also disables the chosen channel. - * - * @param[in] channel PPI channel to be freed. - * - * @retval NRF_SUCCESS If the channel was successfully freed. - * @retval NRF_ERROR_INVALID_PARAM If the channel is not user-configurable. - */ -uint32_t nrf_drv_ppi_channel_free(nrf_ppi_channel_t channel); - -/**@brief Function for assigning task and event endpoints to the PPI channel. - * - * @param[in] channel PPI channel to be assigned endpoints. - * - * @param[in] eep Event endpoint address. - * - * @param[in] tep Task endpoint address. - * - * @retval NRF_SUCCESS If the channel was successfully assigned. - * @retval NRF_ERROR_INVALID_STATE If the channel is not allocated for the user. - * @retval NRF_ERROR_INVALID_PARAM If the channel is not user-configurable. - */ -uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep); - -/**@brief Function for assigning or clearing fork endpoint to the PPI channel. - * - * @param[in] channel PPI channel to be assigned endpoints. - * - * @param[in] fork_tep Fork task endpoint address or 0 to clear. - * - * @retval NRF_SUCCESS If the channel was successfully assigned. - * @retval NRF_ERROR_INVALID_STATE If the channel is not allocated for the user. - * @retval NRF_ERROR_INVALID_PARAM If the channel is not user-configurable. - * @retval NRF_ERROR_NOT_SUPPORTED If function is not supported. - */ -uint32_t nrf_drv_ppi_channel_fork_assign(nrf_ppi_channel_t channel, uint32_t fork_tep); - -/**@brief Function for enabling a PPI channel. - * - * @param[in] channel PPI channel to be enabled. - * - * @retval NRF_SUCCESS If the channel was successfully enabled. - * @retval NRF_ERROR_INVALID_STATE If the user-configurable channel is not allocated. - * @retval NRF_ERROR_INVALID_PARAM If the channel cannot be enabled by the user. - */ -uint32_t nrf_drv_ppi_channel_enable(nrf_ppi_channel_t channel); - -/**@brief Function for disabling a PPI channel. - * - * @param[in] channel PPI channel to be disabled. - * - * @retval NRF_SUCCESS If the channel was successfully disabled. - * @retval NRF_ERROR_INVALID_STATE If the user-configurable channel is not allocated. - * @retval NRF_ERROR_INVALID_PARAM If the channel cannot be disabled by the user. - */ -uint32_t nrf_drv_ppi_channel_disable(nrf_ppi_channel_t channel); - -/**@brief Function for allocating a PPI channel group. - * @details This function allocates the first unused PPI group. - * - * @param[out] p_group Pointer to the PPI channel group that has been allocated. - * - * @retval NRF_SUCCESS If the channel group was successfully allocated. - * @retval NRF_ERROR_NO_MEM If there is no available channel group to be used. - */ -uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group); - -/**@brief Function for freeing a PPI channel group. - * @details This function also disables the chosen group. - * - * @param[in] group PPI channel group to be freed. - * - * @retval NRF_SUCCESS If the channel group was successfully freed. - * @retval NRF_ERROR_INVALID_PARAM If the channel group is not user-configurable. - */ -uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group); - -/**@brief Compute a channel mask for NRF_PPI registers. - * - * @param[in] channel Channel number to transform to a mask. - * - * @retval Channel mask. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_channel_to_mask(nrf_ppi_channel_t channel) -{ - return (1uL << (uint32_t) channel); -} - -/**@brief Function for including multiple PPI channels in a channel group. - * - * @param[in] channel_mask PPI channels to be added. - * @param[in] group Channel group in which to include the channels. - * - * @retval NRF_SUCCESS If the channels was successfully included. - */ -uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group); - -/**@brief Function for including a PPI channel in a channel group. - * - * @param[in] channel PPI channel to be added. - * @param[in] group Channel group in which to include the channel. - * - * @retval NRF_SUCCESS If the channel was successfully included. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_channel_include_in_group(nrf_ppi_channel_t channel, - nrf_ppi_channel_group_t group) -{ - return nrf_drv_ppi_channels_include_in_group(nrf_drv_ppi_channel_to_mask(channel), group); -} - -/**@brief Function for removing multiple PPI channels from a channel group. - * - * @param[in] channel_mask PPI channels to be removed. - * @param[in] group Channel group from which to remove the channels. - * - * @retval NRF_SUCCESS If the channel was successfully removed. - */ -uint32_t nrf_drv_ppi_channels_remove_from_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group); - -/**@brief Function for removing a PPI channel from a channel group. - * - * @param[in] channel PPI channel to be removed. - * @param[in] group Channel group from which to remove the channel. - * - * @retval NRF_SUCCESS If the channel was successfully removed. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_channel_remove_from_group(nrf_ppi_channel_t channel, - nrf_ppi_channel_group_t group) -{ - return nrf_drv_ppi_channels_remove_from_group(nrf_drv_ppi_channel_to_mask(channel), group); -} - -/**@brief Function for clearing a PPI channel group. - * - * @param[in] group Channel group to be cleared. - * - * @retval NRF_SUCCESS If the group was successfully cleared. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_group_clear(nrf_ppi_channel_group_t group) -{ - return nrf_drv_ppi_channels_remove_from_group(NRF_PPI_ALL_APP_CHANNELS_MASK, group); -} - -/**@brief Function for enabling a PPI channel group. - * - * @param[in] group Channel group to be enabled. - * - * @retval NRF_SUCCESS If the group was successfully enabled. - */ -uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group); - -/**@brief Function for disabling a PPI channel group. - * - * @param[in] group Channel group to be disabled. - * - * @retval NRF_SUCCESS If the group was successfully disabled. - */ -uint32_t nrf_drv_ppi_group_disable(nrf_ppi_channel_group_t group); - -/** - * @brief Function for getting the address of a PPI task. - * - * @param[in] task Task. - * - * @retval Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_task_addr_get(nrf_ppi_task_t task) -{ - return (uint32_t) nrf_ppi_task_address_get(task); -} - -/** - * @brief Function for getting the address of a PPI group enable task. - * - * @param[in] group PPI channel group - * - * @retval Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group) -{ - return (uint32_t) nrf_ppi_task_group_enable_address_get(group); -} - -/** - * @brief Function for getting the address of a PPI group enable task. - * - * @param[in] group PPI channel group - * - * @retval Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group) -{ - return (uint32_t) nrf_ppi_task_group_disable_address_get(group); -} - -/** - *@} - **/ - -/*lint --flb "Leave library region" */ - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_PPI_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pwm/nrf_drv_pwm.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pwm/nrf_drv_pwm.h deleted file mode 100644 index a5cece0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/pwm/nrf_drv_pwm.h +++ /dev/null @@ -1,512 +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 - * @addtogroup nrf_pwm PWM HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Pulse Width Modulation (PWM) module APIs. - * - * @defgroup nrf_drv_pwm PWM driver - * @{ - * @ingroup nrf_pwm - * @brief @tagAPI52 Pulse Width Modulation (PWM) module driver. - */ - - -#ifndef NRF_DRV_PWM_H__ -#define NRF_DRV_PWM_H__ - -#include "nordic_common.h" -#include "sdk_config.h" -#include "nrf_pwm.h" -#include "sdk_errors.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef PWM0_ENABLED -#define PWM0_ENABLED 0 -#endif -#ifndef PWM1_ENABLED -#define PWM1_ENABLED 0 -#endif -#ifndef PWM2_ENABLED -#define PWM2_ENABLED 0 -#endif -#ifndef PWM3_ENABLED -#define PWM3_ENABLED 0 -#endif -/** - * @brief PWM driver instance data structure. - */ -typedef struct -{ - NRF_PWM_Type * p_registers; ///< Pointer to the structure with PWM peripheral instance registers. - uint8_t drv_inst_idx; ///< Driver instance index. -} nrf_drv_pwm_t; - -#define PWM0_INSTANCE_INDEX 0 -#define PWM1_INSTANCE_INDEX PWM0_INSTANCE_INDEX+PWM0_ENABLED -#define PWM2_INSTANCE_INDEX PWM1_INSTANCE_INDEX+PWM1_ENABLED -#define PWM3_INSTANCE_INDEX PWM2_INSTANCE_INDEX+PWM2_ENABLED - -/** - * @brief Macro for creating a PWM driver instance. - */ -#define NRF_DRV_PWM_INSTANCE(id) \ -{ \ - .p_registers = CONCAT_2(NRF_PWM, id), \ - .drv_inst_idx = CONCAT_3(PWM, id, _INSTANCE_INDEX), \ -} - - -/** - * @brief This value can be provided instead of a pin number for any channel - * to specify that its output is not used and therefore does not need - * to be connected to a pin. - */ -#define NRF_DRV_PWM_PIN_NOT_USED 0xFF - -/** - * @brief This value can be added to a pin number to inverse its polarity - * (set idle state = 1). - */ -#define NRF_DRV_PWM_PIN_INVERTED 0x80 - -/** - * @brief PWM driver configuration structure. - */ -typedef struct -{ - uint8_t output_pins[NRF_PWM_CHANNEL_COUNT]; ///< Pin numbers for individual output channels (optional). - /**< Use @ref NRF_DRV_PWM_PIN_NOT_USED - * if a given output channel is not needed. */ - uint8_t irq_priority; ///< Interrupt priority. - nrf_pwm_clk_t base_clock; ///< Base clock frequency. - nrf_pwm_mode_t count_mode; ///< Operating mode of the pulse generator counter. - uint16_t top_value; ///< Value up to which the pulse generator counter counts. - nrf_pwm_dec_load_t load_mode; ///< Mode of loading sequence data from RAM. - nrf_pwm_dec_step_t step_mode; ///< Mode of advancing the active sequence. -} nrf_drv_pwm_config_t; - -/** - * @brief PWM driver default configuration. - */ -#define NRF_DRV_PWM_DEFAULT_CONFIG \ -{ \ - .output_pins = {PWM_DEFAULT_CONFIG_OUT0_PIN, \ - PWM_DEFAULT_CONFIG_OUT1_PIN, \ - PWM_DEFAULT_CONFIG_OUT2_PIN, \ - PWM_DEFAULT_CONFIG_OUT3_PIN }, \ - .irq_priority = PWM_DEFAULT_CONFIG_IRQ_PRIORITY, \ - .base_clock = (nrf_pwm_clk_t)PWM_DEFAULT_CONFIG_BASE_CLOCK, \ - .count_mode = (nrf_pwm_mode_t)PWM_DEFAULT_CONFIG_COUNT_MODE, \ - .top_value = PWM_DEFAULT_CONFIG_TOP_VALUE, \ - .load_mode = (nrf_pwm_dec_load_t)PWM_DEFAULT_CONFIG_LOAD_MODE, \ - .step_mode = (nrf_pwm_dec_step_t)PWM_DEFAULT_CONFIG_STEP_MODE, \ -} - - -/** - * @brief PWM flags providing additional playback options. - */ -typedef enum -{ - NRF_DRV_PWM_FLAG_STOP = 0x01, /**< When the requested playback is finished, - the peripheral should be stopped. - @note The STOP task is triggered when - the last value of the final sequence is - loaded from RAM, and the peripheral stops - at the end of the current PWM period. - For sequences with configured repeating - of duty cycle values, this might result in - less than the requested number of repeats - of the last value. */ - NRF_DRV_PWM_FLAG_LOOP = 0x02, /**< When the requested playback is finished, - it should be started from the beginning. - This flag is ignored if used together - with @ref NRF_DRV_PWM_FLAG_STOP. - @note The playback restart is done via a - shortcut configured in the PWM peripheral. - This shortcut triggers the proper starting - task when the final value of previous - playback is read from RAM and applied to - the pulse generator counter. - When this mechanism is used together with - the @ref NRF_PWM_STEP_TRIGGERED mode, - the playback restart will occur right - after switching to the final value (this - final value will be played only once). */ - NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0 = 0x04, /**< The event handler should be - called when the last value - from sequence 0 is loaded. */ - NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1 = 0x08, /**< The event handler should be - called when the last value - from sequence 1 is loaded. */ - NRF_DRV_PWM_FLAG_NO_EVT_FINISHED = 0x10, /**< The playback finished event - (enabled by default) should be - suppressed. */ - NRF_DRV_PWM_FLAG_START_VIA_TASK = 0x80, /**< The playback should not be - started directly by the called - function. Instead, the function - should only prepare it and - return the address of the task - to be triggered to start the - playback. */ -} nrf_drv_pwm_flag_t; - - -/** - * @brief PWM driver event type. - */ -typedef enum -{ - NRF_DRV_PWM_EVT_FINISHED, ///< Sequence playback finished. - NRF_DRV_PWM_EVT_END_SEQ0, /**< End of sequence 0 reached. Its data can be - safely modified now. */ - NRF_DRV_PWM_EVT_END_SEQ1, /**< End of sequence 1 reached. Its data can be - safely modified now. */ - NRF_DRV_PWM_EVT_STOPPED, ///< The PWM peripheral has been stopped. -} nrf_drv_pwm_evt_type_t; - -/** - * @brief PWM driver event handler type. - */ -typedef void (* nrf_drv_pwm_handler_t)(nrf_drv_pwm_evt_type_t event_type); - - -/** - * @brief Function for initializing the PWM driver. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_config Pointer to the structure with initial configuration. - * - * @param[in] handler Event handler provided by the user. If NULL is passed - * instead, event notifications are not done and PWM - * interrupts are disabled. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. - */ -ret_code_t nrf_drv_pwm_init(nrf_drv_pwm_t const * const p_instance, - nrf_drv_pwm_config_t const * p_config, - nrf_drv_pwm_handler_t handler); - -/** - * @brief Function for uninitializing the PWM driver. - * - * If any sequence playback is in progress, it is stopped immediately. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_pwm_uninit(nrf_drv_pwm_t const * const p_instance); - -/** - * @brief Function for starting a single sequence playback. - * - * To take advantage of the looping mechanism in the PWM peripheral, both - * sequences must be used (single sequence can be played back only once by - * the peripheral). Therefore, the provided sequence is internally set and - * played back as both sequence 0 and sequence 1. Consequently, if end of - * sequence notifications are required, events for both sequences should be - * used (that means that both the @ref NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0 flag - * and the @ref NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1 flag should be specified and - * the @ref NRF_DRV_PWM_EVT_END_SEQ0 event and the @ref NRF_DRV_PWM_EVT_END_SEQ1 - * event should be handled in the same way). - * - * Use the @ref NRF_DRV_PWM_FLAG_START_VIA_TASK flag if you want the playback - * to be only prepared by this function, and you want to start it later by - * triggering a task (using PPI for instance). The function will then return - * the address of the task to be triggered. - * - * @note The array containing the duty cycle values for the specified sequence - * must be in RAM and cannot be allocated on stack. - * For detailed information, see @ref nrf_pwm_sequence_t. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_sequence Sequence to be played back. - * @param[in] playback_count Number of playbacks to be performed (must not be 0). - * @param[in] flags Additional options. Pass any combination of - * @ref nrf_drv_pwm_flag_t "playback flags", or 0 - * for default settings. - * - * @return Address of the task to be triggered to start the playback if the @ref - * NRF_DRV_PWM_FLAG_START_VIA_TASK flag was used, 0 otherwise. - */ -uint32_t nrf_drv_pwm_simple_playback(nrf_drv_pwm_t const * const p_instance, - nrf_pwm_sequence_t const * p_sequence, - uint16_t playback_count, - uint32_t flags); - -/** - * @brief Function for starting a two-sequence playback. - * - * Use the @ref NRF_DRV_PWM_FLAG_START_VIA_TASK flag if you want the playback - * to be only prepared by this function, and you want to start it later by - * triggering a task (using PPI for instance). The function will then return - * the address of the task to be triggered. - * - * @note The array containing the duty cycle values for the specified sequence - * must be in RAM and cannot be allocated on stack. - * For detailed information, see @ref nrf_pwm_sequence_t. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_sequence_0 First sequence to be played back. - * @param[in] p_sequence_1 Second sequence to be played back. - * @param[in] playback_count Number of playbacks to be performed (must not be 0). - * @param[in] flags Additional options. Pass any combination of - * @ref nrf_drv_pwm_flag_t "playback flags", or 0 - * for default settings. - * - * @return Address of the task to be triggered to start the playback if the @ref - * NRF_DRV_PWM_FLAG_START_VIA_TASK flag was used, 0 otherwise. - */ -uint32_t nrf_drv_pwm_complex_playback(nrf_drv_pwm_t const * const p_instance, - nrf_pwm_sequence_t const * p_sequence_0, - nrf_pwm_sequence_t const * p_sequence_1, - uint16_t playback_count, - uint32_t flags); - -/** - * @brief Function for advancing the active sequence. - * - * This function only applies to @ref NRF_PWM_STEP_TRIGGERED mode. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -__STATIC_INLINE void nrf_drv_pwm_step(nrf_drv_pwm_t const * const p_instance); - -/** - * @brief Function for stopping the sequence playback. - * - * The playback is stopped at the end of the current PWM period. - * This means that if the active sequence is configured to repeat each duty - * cycle value for a certain number of PWM periods, the last played value - * might appear on the output less times than requested. - * - * @note This function can be instructed to wait until the playback is stopped - * (by setting @p wait_until_stopped to true). Note that, depending on - * the length of the PMW period, this might take a significant amount of - * time. Alternatively, the @ref nrf_drv_pwm_is_stopped function can be - * used to poll the status, or the @ref NRF_DRV_PWM_EVT_STOPPED event can - * be used to get the notification when the playback is stopped, provided - * the event handler is defined. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] wait_until_stopped If true, the function will not return until - * the playback is stopped. - * - * @retval true If the PWM peripheral is stopped. - * @retval false If the PWM peripheral is not stopped. - */ -bool nrf_drv_pwm_stop(nrf_drv_pwm_t const * const p_instance, - bool wait_until_stopped); - -/** - * @brief Function for checking the status of the PWM peripheral. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true If the PWM peripheral is stopped. - * @retval false If the PWM peripheral is not stopped. - */ -bool nrf_drv_pwm_is_stopped(nrf_drv_pwm_t const * const p_instance); - -/** - * @brief Function for updating the sequence data during playback. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] seq_id Identifier of the sequence (0 or 1). - * @param[in] p_sequence Pointer to the new sequence definition. - */ -__STATIC_INLINE void nrf_drv_pwm_sequence_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - nrf_pwm_sequence_t const * p_sequence); - -/** - * @brief Function for updating the pointer to the duty cycle values - * in the specified sequence during playback. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] seq_id Identifier of the sequence (0 or 1). - * @param[in] values New pointer to the duty cycle values. - */ -__STATIC_INLINE void nrf_drv_pwm_sequence_values_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - nrf_pwm_values_t values); - -/** - * @brief Function for updating the number of duty cycle values - * in the specified sequence during playback. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] seq_id Identifier of the sequence (0 or 1). - * @param[in] length New number of the duty cycle values. - */ -__STATIC_INLINE void nrf_drv_pwm_sequence_length_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - uint16_t length); - -/** - * @brief Function for updating the number of repeats for duty cycle values - * in specified sequence during playback. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] seq_id Identifier of the sequence (0 or 1). - * @param[in] repeats New number of repeats. - */ -__STATIC_INLINE void nrf_drv_pwm_sequence_repeats_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - uint32_t repeats); - -/** - * @brief Function for updating the additional delay after the specified - * sequence during playback. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] seq_id Identifier of the sequence (0 or 1). - * @param[in] end_delay New end delay value (in PWM periods). - */ -__STATIC_INLINE void nrf_drv_pwm_sequence_end_delay_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - uint32_t end_delay); - -/** - * @brief Function for returning the address of a specified PWM task that can - * be used in PPI module. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] task Requested task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_pwm_task_address_get( - nrf_drv_pwm_t const * const p_instance, - nrf_pwm_task_t task); - -/**@brief Function for returning the address of a specified PWM event that can - * be used in PPI module. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] event Requested event. - * - * @return Event address. - */ -__STATIC_INLINE uint32_t nrf_drv_pwm_event_address_get( - nrf_drv_pwm_t const * const p_instance, - nrf_pwm_event_t event); - - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_drv_pwm_step(nrf_drv_pwm_t const * const p_instance) -{ - nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_NEXTSTEP); -} - -__STATIC_INLINE void nrf_drv_pwm_sequence_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - nrf_pwm_sequence_t const * p_sequence) -{ - nrf_pwm_sequence_set(p_instance->p_registers, seq_id, p_sequence); -} - -__STATIC_INLINE void nrf_drv_pwm_sequence_values_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - nrf_pwm_values_t values) -{ - nrf_pwm_seq_ptr_set(p_instance->p_registers, seq_id, values.p_raw); -} - -__STATIC_INLINE void nrf_drv_pwm_sequence_length_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - uint16_t length) -{ - nrf_pwm_seq_cnt_set(p_instance->p_registers, seq_id, length); -} - -__STATIC_INLINE void nrf_drv_pwm_sequence_repeats_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - uint32_t repeats) -{ - nrf_pwm_seq_refresh_set(p_instance->p_registers, seq_id, repeats); -} - -__STATIC_INLINE void nrf_drv_pwm_sequence_end_delay_update( - nrf_drv_pwm_t const * const p_instance, - uint8_t seq_id, - uint32_t end_delay) -{ - nrf_pwm_seq_end_delay_set(p_instance->p_registers, seq_id, end_delay); -} - -__STATIC_INLINE uint32_t nrf_drv_pwm_task_address_get( - nrf_drv_pwm_t const * const p_instance, - nrf_pwm_task_t task) -{ - return nrf_pwm_task_address_get(p_instance->p_registers, task); -} - -__STATIC_INLINE uint32_t nrf_drv_pwm_event_address_get( - nrf_drv_pwm_t const * const p_instance, - nrf_pwm_event_t event) -{ - return nrf_pwm_event_address_get(p_instance->p_registers, event); -} - -#endif // SUPPRESS_INLINE_IMPLEMENTATION - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_PWM_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qdec/nrf_drv_qdec.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qdec/nrf_drv_qdec.h deleted file mode 100644 index 8327d28..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qdec/nrf_drv_qdec.h +++ /dev/null @@ -1,185 +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 NRF_DRV_QDEC_H__ -#define NRF_DRV_QDEC_H__ - -#include "nrf_qdec.h" -#include "sdk_config.h" -#include "sdk_errors.h" -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup nrf_qdec QDEC HAL and driver - * @ingroup nrf_drivers - * @brief Quadrature decoder (QDEC) APIs. - * @details The QDEC HAL provides basic APIs for accessing the registers of the QDEC. - * The QDEC driver provides APIs on a higher level. - * - * @defgroup nrf_drv_qdec QDEC driver - * @{ - * @ingroup nrf_qdec - * @brief Quadrature decoder (QDEC) driver. - */ - -/**@brief QDEC configuration structure.*/ -typedef struct -{ - nrf_qdec_reportper_t reportper; /**< Report period in samples. */ - nrf_qdec_sampleper_t sampleper; /**< Sampling period in microseconds. */ - uint32_t psela; /**< Pin number for A input. */ - uint32_t pselb; /**< Pin number for B input. */ - uint32_t pselled; /**< Pin number for LED output. */ - uint32_t ledpre; /**< Time (in microseconds) how long LED is switched on before sampling. */ - nrf_qdec_ledpol_t ledpol; /**< Active LED polarity. */ - bool dbfen; /**< State of debouncing filter. */ - bool sample_inten; /**< Enabling sample ready interrupt. */ - uint8_t interrupt_priority; /**< QDEC interrupt priority. */ -} nrf_drv_qdec_config_t; - -/**@brief QDEC default configuration. */ -#define NRF_DRV_QDEC_DEFAULT_CONFIG \ - { \ - .reportper = (nrf_qdec_reportper_t)QDEC_CONFIG_REPORTPER, \ - .sampleper = (nrf_qdec_sampleper_t)QDEC_CONFIG_SAMPLEPER, \ - .psela = QDEC_CONFIG_PIO_A, \ - .pselb = QDEC_CONFIG_PIO_B, \ - .pselled = QDEC_CONFIG_PIO_LED, \ - .ledpre = QDEC_CONFIG_LEDPRE, \ - .ledpol = (nrf_qdec_ledpol_t)QDEC_CONFIG_LEDPOL, \ - .interrupt_priority = QDEC_CONFIG_IRQ_PRIORITY, \ - .dbfen = QDEC_CONFIG_DBFEN, \ - .sample_inten = QDEC_CONFIG_SAMPLE_INTEN \ - } - -/**@brief QDEC sample event data.*/ -typedef struct -{ - int8_t value; /**< Sample value. */ -} nrf_drv_qdec_sample_data_evt_t; - -/**@brief QDEC report event data.*/ -typedef struct -{ - int16_t acc; /**< Accumulated transitions. */ - uint16_t accdbl; /**< Accumulated double transitions. */ -} nrf_drv_qdec_report_data_evt_t; - -/**@brief QDEC event handler structure. */ -typedef struct -{ - nrf_qdec_event_t type; - union - { - nrf_drv_qdec_sample_data_evt_t sample; /**< Sample event data. */ - nrf_drv_qdec_report_data_evt_t report; /**< Report event data. */ - } data; -} nrf_drv_qdec_event_t; - -/**@brief QDEC event handler. - * @param[in] event QDEC event structure. - */ -typedef void (*qdec_event_handler_t)(nrf_drv_qdec_event_t event); - -/**@brief Function for initializing QDEC. - * - * @param[in] p_config Pointer to configuration parameters. - * @param[in] event_handler Event handler function. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were supplied. - * @retval NRF_ERROR_INVALID_STATE If QDEC was already initialized. - */ -ret_code_t nrf_drv_qdec_init(nrf_drv_qdec_config_t const * p_config, - qdec_event_handler_t event_handler); - -/**@brief Function for uninitializing QDEC. - * @note Function asserts if module is uninitialized. - */ -void nrf_drv_qdec_uninit(void); - -/**@brief Function for enabling QDEC. - * @note Function asserts if module is uninitialized or enabled. - */ -void nrf_drv_qdec_enable(void); - -/**@brief Function for disabling QDEC. - * @note Function asserts if module is uninitialized or disabled. - */ -void nrf_drv_qdec_disable(void); - -/**@brief Function for reading accumulated transitions QDEC. - * @note Function asserts if module is not enabled. - * @note Accumulators are cleared after reading. - * - * @param[out] p_acc Pointer to store accumulated transitions. - * @param[out] p_accdbl Pointer to store accumulated double transitions. - */ -void nrf_drv_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl); - -/** - * @brief Function for returning the address of a specific timer task. - * - * @param[in] task QDEC task. - * @param[out] p_task Task address. - */ -void nrf_drv_qdec_task_address_get(nrf_qdec_task_t task, uint32_t * p_task); - -/** - * @brief Function for returning the address of a specific timer event. - * - * @param[in] event QDEC event. - * @param[out] p_event Event address. - */ -void nrf_drv_qdec_event_address_get(nrf_qdec_event_t event, uint32_t * p_event); - -/** - *@} - **/ - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_DRV_QDEC_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.c deleted file mode 100644 index 8328731..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.c +++ /dev/null @@ -1,308 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" - -#if QSPI_ENABLED - -#include "nrf_drv_qspi.h" -#include "nrf_drv_common.h" -#include "app_util.h" -#include "nrf_gpio.h" -#include "nrf_assert.h" - -/** - * @brief Command byte used to read status register. - * - */ -#define QSPI_STD_CMD_RDSR 0x05 - -/** - * @brief Byte used to mask status register and retrieve the write-in-progess bit. - * - */ -#define QSPI_MEM_STATUSREG_WIP_Pos 0x01 - -#define QSPI_WAIT_READY() do { \ - while (!nrf_qspi_event_check(NRF_QSPI, NRF_QSPI_EVENT_READY)); \ - } while (0) - -/** - * @brief Control block - driver instance local data. - * - */ -typedef struct -{ - nrf_drv_qspi_handler_t handler; /**< Handler. */ - nrf_drv_state_t state; /**< Driver state. */ - volatile bool interrupt_driven; /**< Information if the current operation is performed and is interrupt-driven. */ - void * p_context; /**< Driver context used in interrupt. */ -} qspi_control_block_t; - -static qspi_control_block_t m_cb; - -static ret_code_t qspi_task_perform(nrf_qspi_task_t task) -{ - // Wait for peripheral - if (m_cb.interrupt_driven) - { - return NRF_ERROR_BUSY; - } - - nrf_qspi_event_clear(NRF_QSPI, NRF_QSPI_EVENT_READY); - - if (m_cb.handler) - { - m_cb.interrupt_driven = true; - nrf_qspi_int_enable(NRF_QSPI, NRF_QSPI_INT_READY_MASK); - } - - nrf_qspi_task_trigger(NRF_QSPI, task); - - if (m_cb.handler == NULL) - { - QSPI_WAIT_READY(); - } - return NRF_SUCCESS; -} - -static bool qspi_pins_configure(nrf_qspi_pins_t const * p_config) -{ - // Check if the user set meaningful values to struct fields. If not, return false. - if ((p_config->sck_pin == NRF_QSPI_PIN_NOT_CONNECTED) || - (p_config->csn_pin == NRF_QSPI_PIN_NOT_CONNECTED) || - (p_config->io0_pin == NRF_QSPI_PIN_NOT_CONNECTED) || - (p_config->io1_pin == NRF_QSPI_PIN_NOT_CONNECTED)) - { - return false; - } - - nrf_qspi_pins_set(NRF_QSPI, p_config); - - return true; -} - -ret_code_t nrf_drv_qspi_init(nrf_drv_qspi_config_t const * p_config, - nrf_drv_qspi_handler_t handler, - void * p_context) -{ - if (m_cb.state != NRF_DRV_STATE_UNINITIALIZED) - { - return NRF_ERROR_INVALID_STATE; - } - - if (!qspi_pins_configure(&p_config->pins)) - { - return NRF_ERROR_INVALID_PARAM; - } - - nrf_qspi_ifconfig0_set(NRF_QSPI, &p_config->prot_if); - nrf_qspi_ifconfig1_set(NRF_QSPI, &p_config->phy_if); - - m_cb.interrupt_driven = false; - m_cb.handler = handler; - m_cb.p_context = p_context; - - /* QSPI interrupt is disabled because the device should be enabled in polling mode (wait for activate - task event ready)*/ - nrf_qspi_int_disable(NRF_QSPI, NRF_QSPI_INT_READY_MASK); - - if (handler) - { - nrf_drv_common_irq_enable(QSPI_IRQn, p_config->irq_priority); - } - - m_cb.state = NRF_DRV_STATE_INITIALIZED; - - nrf_qspi_enable(NRF_QSPI); - - nrf_qspi_event_clear(NRF_QSPI, NRF_QSPI_EVENT_READY); - nrf_qspi_task_trigger(NRF_QSPI, NRF_QSPI_TASK_ACTIVATE); - - // Waiting for the peripheral to activate - QSPI_WAIT_READY(); - - return NRF_SUCCESS; -} - -ret_code_t nrf_drv_qspi_cinstr_xfer(nrf_qspi_cinstr_conf_t const * p_config, - void const * p_tx_buffer, - void * p_rx_buffer) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - - if (m_cb.interrupt_driven) - { - return NRF_ERROR_BUSY; - } - - nrf_qspi_event_clear(NRF_QSPI, NRF_QSPI_EVENT_READY); - /* In some cases, only opcode should be sent. To prevent execution, set function code is - * surrounded by an if. - */ - if (p_tx_buffer) - { - nrf_qspi_cinstrdata_set(NRF_QSPI, p_config->length, p_tx_buffer); - } - nrf_qspi_int_disable(NRF_QSPI, NRF_QSPI_INT_READY_MASK); - - nrf_qspi_cinstr_transfer_start(NRF_QSPI, p_config); - - QSPI_WAIT_READY(); - nrf_qspi_event_clear(NRF_QSPI, NRF_QSPI_EVENT_READY); - nrf_qspi_int_enable(NRF_QSPI, NRF_QSPI_INT_READY_MASK); - - if (p_rx_buffer) - { - nrf_qspi_cinstrdata_get(NRF_QSPI, p_config->length, p_rx_buffer); - } - - return NRF_SUCCESS; -} - -ret_code_t nrf_drv_qspi_cinstr_quick_send(uint8_t opcode, - nrf_qspi_cinstr_len_t length, - void const * p_tx_buffer) -{ - nrf_qspi_cinstr_conf_t config = NRF_DRV_QSPI_DEFAULT_CINSTR(opcode, length); - return nrf_drv_qspi_cinstr_xfer(&config, p_tx_buffer, NULL); -} - -ret_code_t nrf_drv_qspi_mem_busy_check(void) -{ - ret_code_t ret_code; - uint8_t status_value = 0; - - nrf_qspi_cinstr_conf_t config = NRF_DRV_QSPI_DEFAULT_CINSTR(QSPI_STD_CMD_RDSR, - NRF_QSPI_CINSTR_LEN_2B); - - ret_code = nrf_drv_qspi_cinstr_xfer(&config, &status_value, &status_value); - - if (ret_code != NRF_SUCCESS) - { - return ret_code; - } - - if ((status_value & QSPI_MEM_STATUSREG_WIP_Pos) != 0x00) - { - return NRF_ERROR_BUSY; - } - - return NRF_SUCCESS; -} - -void nrf_drv_qspi_uninit(void) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_qspi_int_disable(NRF_QSPI, NRF_QSPI_INT_READY_MASK); - - nrf_qspi_disable(NRF_QSPI); - - nrf_drv_common_irq_disable(QSPI_IRQn); - - nrf_qspi_event_clear(NRF_QSPI, NRF_QSPI_EVENT_READY); - - m_cb.state = NRF_DRV_STATE_UNINITIALIZED; -} - -ret_code_t nrf_drv_qspi_write(void const * p_tx_buffer, - size_t tx_buffer_length, - uint32_t dst_address) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(p_tx_buffer != NULL); - /* Checking word alignment. */ - ASSERT(is_word_aligned(p_tx_buffer)); - - if (!nrf_drv_is_in_RAM(p_tx_buffer)) - { - return NRF_ERROR_INVALID_ADDR; - } - - nrf_qspi_write_buffer_set(NRF_QSPI, p_tx_buffer, tx_buffer_length, dst_address); - return qspi_task_perform(NRF_QSPI_TASK_WRITESTART); - -} - -ret_code_t nrf_drv_qspi_read(void * p_rx_buffer, - size_t rx_buffer_length, - uint32_t src_address) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(p_rx_buffer != NULL); - /* Checking word alignment. */ - ASSERT(is_word_aligned(p_rx_buffer)); - - if (!nrf_drv_is_in_RAM(p_rx_buffer)) - { - return NRF_ERROR_INVALID_ADDR; - } - - nrf_qspi_read_buffer_set(NRF_QSPI, p_rx_buffer, rx_buffer_length, src_address); - return qspi_task_perform(NRF_QSPI_TASK_READSTART); -} - -ret_code_t nrf_drv_qspi_erase(nrf_qspi_erase_len_t length, - uint32_t start_address) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - /* Checking word alignment. */ - ASSERT(is_word_aligned((void *)start_address)); - nrf_qspi_erase_ptr_set(NRF_QSPI, start_address, length); - return qspi_task_perform(NRF_QSPI_TASK_ERASESTART); -} - -ret_code_t nrf_drv_qspi_chip_erase(void) -{ - return nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_ALL, 0); -} - -void QSPI_IRQHandler(void) -{ - // Catch Event ready interrupts - if (nrf_qspi_event_check(NRF_QSPI, NRF_QSPI_EVENT_READY)) - { - m_cb.interrupt_driven = false; - nrf_qspi_event_clear(NRF_QSPI, NRF_QSPI_EVENT_READY); - m_cb.handler(NRF_DRV_QSPI_EVENT_DONE, m_cb.p_context); - } -} - -#endif // QSPI_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.h deleted file mode 100644 index 35ce036..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/qspi/nrf_drv_qspi.h +++ /dev/null @@ -1,311 +0,0 @@ -/** - * Copyright (c) 2016 - 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 - * @addtogroup nrf_qspi QSPI HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52840 Quad serial peripheral interface (QSPI) APIs. - * - * @defgroup nrf_drv_qspi QSPI driver - * @{ - * @ingroup nrf_qspi - * @brief @tagAPI52840 Quad serial peripheral interface (QSPI) driver. - */ - -#ifndef NRF_DRV_QSPI_H__ -#define NRF_DRV_QSPI_H__ - -#include "nordic_common.h" -#include "sdk_config.h" -#include "nrf_qspi.h" -#include "sdk_errors.h" -#include "boards.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief QSPI driver instance configuration structure. - */ -typedef struct -{ - nrf_qspi_pins_t pins; /**< Pins configuration structure. */ - nrf_qspi_prot_conf_t prot_if; /**< Protocol layer interface configuration structure. */ - nrf_qspi_phy_conf_t phy_if; /**< Physical layer interface configuration structure. */ - uint8_t irq_priority; /**< Interrupt priority. */ -} nrf_drv_qspi_config_t; - -#if QSPI_PIN_SCK == NRF_QSPI_PIN_NOT_CONNECTED - #undef QSPI_PIN_SCK - #define QSPI_PIN_SCK BSP_QSPI_SCK_PIN -#endif -#if QSPI_PIN_CSN == NRF_QSPI_PIN_NOT_CONNECTED - #undef QSPI_PIN_CSN - #define QSPI_PIN_CSN BSP_QSPI_CSN_PIN -#endif -#if QSPI_PIN_IO0 == NRF_QSPI_PIN_NOT_CONNECTED - #undef QSPI_PIN_IO0 - #define QSPI_PIN_IO0 BSP_QSPI_IO0_PIN -#endif -#if QSPI_PIN_IO1 == NRF_QSPI_PIN_NOT_CONNECTED - #undef QSPI_PIN_IO1 - #define QSPI_PIN_IO1 BSP_QSPI_IO1_PIN -#endif -#if QSPI_PIN_IO2 == NRF_QSPI_PIN_NOT_CONNECTED - #undef QSPI_PIN_IO2 - #define QSPI_PIN_IO2 BSP_QSPI_IO2_PIN -#endif -#if QSPI_PIN_IO3 == NRF_QSPI_PIN_NOT_CONNECTED - #undef QSPI_PIN_IO3 - #define QSPI_PIN_IO3 BSP_QSPI_IO3_PIN -#endif -/** - * @brief QSPI instance default configuration. - */ -#define NRF_DRV_QSPI_DEFAULT_CONFIG \ -{ \ - .pins = { \ - .sck_pin = QSPI_PIN_SCK, \ - .csn_pin = QSPI_PIN_CSN, \ - .io0_pin = QSPI_PIN_IO0, \ - .io1_pin = QSPI_PIN_IO1, \ - .io2_pin = QSPI_PIN_IO2, \ - .io3_pin = QSPI_PIN_IO3, \ - }, \ - .irq_priority = (uint8_t)QSPI_CONFIG_IRQ_PRIORITY, \ - .prot_if = { \ - .readoc = (nrf_qspi_readoc_t) QSPI_CONFIG_READOC, \ - .writeoc = (nrf_qspi_writeoc_t) QSPI_CONFIG_WRITEOC, \ - .addrmode = (nrf_qspi_addrmode_t) QSPI_CONFIG_ADDRMODE, \ - .dpmconfig = false, \ - }, \ - .phy_if = { \ - .sck_freq = (nrf_qspi_frequency_t) QSPI_CONFIG_FREQUENCY, \ - .sck_delay = (uint8_t) QSPI_CONFIG_SCK_DELAY, \ - .spi_mode = (nrf_qspi_spi_mode_t) QSPI_CONFIG_MODE, \ - .dpmen = false \ - } \ -} - - -/** - * @brief QSPI custom instruction helper with default configuration. - */ -#define NRF_DRV_QSPI_DEFAULT_CINSTR(opc, len) \ -{ \ - .opcode = (opc), \ - .length = (len), \ - .io2_level = false, \ - .io3_level = false, \ - .wipwait = false, \ - .wren = false \ -} - -/** - * @brief QSPI master driver event types, passed to the handler routine provided - * during initialization. - */ -typedef enum -{ - NRF_DRV_QSPI_EVENT_DONE, /**< Transfer done. */ -} nrf_drv_qspi_evt_t; - -/** - * @brief QSPI driver event handler type. - */ -typedef void (*nrf_drv_qspi_handler_t)(nrf_drv_qspi_evt_t event, void * p_context); - -/** - * @brief Function for initializing the QSPI driver instance. - * - * @param[in] p_config Pointer to the structure with the initial configuration. - * @param[in] handler Event handler provided by the user. If NULL, transfers - * will be performed in blocking mode. - * @param[in] p_context Pointer to context. Use in interrupt handler. - * - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. - * @retval NRF_ERROR_INVALID_PARAM If the pin configuration was incorrect. - */ -ret_code_t nrf_drv_qspi_init(nrf_drv_qspi_config_t const * p_config, - nrf_drv_qspi_handler_t handler, - void * p_context); - -/** - * @brief Function for uninitializing the QSPI driver instance. - */ -void nrf_drv_qspi_uninit(void); - -/** - * @brief Function for reading data from QSPI memory. - * - * Write, read, and erase operations check memory device busy state before starting the operation. - * If the memory is busy, the resulting action depends on the mode in which the read operation is used: - * - blocking mode (without handler) - a delay occurs until the last operation still runs and - * until operation data is still being read. - * - interrupt mode (with handler) - event emission occurs after the last operation - * and reading of data are finished. - * - * @param[out] p_rx_buffer Pointer to the receive buffer. - * @param[in] rx_buffer_length Size of the data to read. - * @param[in] src_address Address in memory to read from. - * - * @retval NRF_SUCCESS If the operation was successful (blocking mode) or operation - * was commissioned (handler mode). - * @retval NRF_ERROR_BUSY If the driver currently handles another operation. - * @retval NRF_ERROR_INVALID_ADDR If the provided buffer is not placed in the Data RAM region. - */ -ret_code_t nrf_drv_qspi_read(void * p_rx_buffer, - size_t rx_buffer_length, - uint32_t src_address); - -/** - * @brief Function for writing data to QSPI memory. - * - * Write, read, and erase operations check memory device busy state before starting the operation. - * If the memory is busy, the resulting action depends on the mode in which the write operation is used: - * - blocking mode (without handler) - a delay occurs until the last operation still runs and - * until operation data is still being sent. - * - interrupt mode (with handler) - event emission occurs after the last operation - * and sending of operation data are finished. - * To manually control operation execution in the memory device, use @ref nrf_drv_qspi_mem_busy_check - * after executing the write function. - * Remember that an incoming event signalizes only that data was sent to the memory device and the periheral - * before the write operation checked if memory was busy. - * - * @param[in] p_tx_buffer Pointer to the writing buffer. - * @param[in] tx_buffer_length Size of the data to write. - * @param[in] dst_address Address in memory to write to. - * - * @retval NRF_SUCCESS If the operation was successful (blocking mode) or operation - * was commissioned (handler mode). - * @retval NRF_ERROR_BUSY If the driver currently handles other operation. - * @retval NRF_ERROR_INVALID_ADDR If the provided buffer is not placed in the Data RAM region. - */ -ret_code_t nrf_drv_qspi_write(void const * p_tx_buffer, - size_t tx_buffer_length, - uint32_t dst_address); - -/** - * @brief Function for starting erasing of one memory block - 4KB, 64KB, or the whole chip. - * - * Write, read, and erase operations check memory device busy state before starting the operation. - * If the memory is busy, the resulting action depends on the mode in which the erase operation is used: - * - blocking mode (without handler) - a delay occurs until the last operation still runs and - * until operation data is still being sent. - * - interrupt mode (with handler) - event emission occurs after the last operation - * and sending of operation data are finished. - * To manually control operation execution in the memory device, use @ref nrf_drv_qspi_mem_busy_check - * after executing the erase function. - * Remember that an incoming event signalizes only that data was sent to the memory device and the periheral - * before the erase operation checked if memory was busy. - * - * @param[in] length Size of data to erase. See @ref nrf_qspi_erase_len_t. - * @param[in] start_address Memory address to start erasing. If chip erase is performed, address - * field is ommited. - * - * @retval NRF_SUCCESS If the operation was successful (blocking mode) or operation - * was commissioned (handler mode). - * @retval NRF_ERROR_BUSY If the driver currently handles another operation. - */ -ret_code_t nrf_drv_qspi_erase(nrf_qspi_erase_len_t length, - uint32_t start_address); - -/** - * @brief Function for starting an erase operation of the whole chip. - * - * @retval NRF_SUCCESS If the operation was successful (blocking mode) or operation - * was commissioned (handler mode). - * @retval NRF_ERROR_BUSY If the driver currently handles another operation. - */ -ret_code_t nrf_drv_qspi_chip_erase(void); - -/** - * @brief Function for getting the current driver status and status byte of memory device with - * testing WIP (write in progress) bit. - * - * @retval NRF_SUCCESS If the driver and memory are ready to handle a new operation. - * @retval NRF_ERROR_BUSY If the driver or memory currently handle another operation. - */ -ret_code_t nrf_drv_qspi_mem_busy_check(void); - -/** - * @brief Function for sending operation code, sending data, and receiving data from the memory device. - * - * Use this function to transfer configuration data to memory and to receive data from memory. - * Pointers can be addresses from flash memory. - * This function is a synchronous function and should be used only if necessary. - * See more: @ref hardware_driver_qspi. - * - * @param[in] p_config Pointer to the structure with opcode and transfer configuration. - * @param[in] p_tx_buffer Pointer to the array with data to send. Can be NULL if only opcode is transmitted. - * @param[out] p_rx_buffer Pointer to the array for data to receive. Can be NULL if there is nothing to receive. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_BUSY If the driver currently handles other operation. - */ -ret_code_t nrf_drv_qspi_cinstr_xfer(nrf_qspi_cinstr_conf_t const * p_config, - void const * p_tx_buffer, - void * p_rx_buffer); -/** - * @brief Function for sending operation code and data to the memory device with simpler configuration. - * - * Use this function to transfer configuration data to memory and to receive data from memory. - * This function is a synchronous function and should be used only if necessary. - * - * @param[in] opcode Operation code. Sending first. - * @param[in] length Length of the data to send and opcode. See @ref nrf_qspi_cinstr_len_t. - * @param[in] p_tx_buffer Pointer to input data array. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_BUSY If the driver currently handles another operation. - */ -ret_code_t nrf_drv_qspi_cinstr_quick_send(uint8_t opcode, - nrf_qspi_cinstr_len_t length, - void const * p_tx_buffer); - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_QSPI_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.c deleted file mode 100644 index 551580f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.c +++ /dev/null @@ -1,356 +0,0 @@ -/** - * Copyright (c) 2014 - 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(RTC) -#define ENABLED_RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED+RTC2_ENABLED) -#if ENABLED_RTC_COUNT - -#include "nrf_drv_rtc.h" -#include "nrf_rtc.h" -#include "nrf_assert.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME rtc - -#if RTC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL RTC_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR RTC_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR RTC_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_RTC_EVENT_TICK ? "NRF_RTC_EVENT_TICK" : \ - (event == NRF_RTC_EVENT_OVERFLOW ? "NRF_RTC_EVENT_OVERFLOW" : \ - (event == NRF_RTC_EVENT_COMPARE_0 ? "NRF_RTC_EVENT_COMPARE_0" : \ - (event == NRF_RTC_EVENT_COMPARE_1 ? "NRF_RTC_EVENT_COMPARE_1" : \ - (event == NRF_RTC_EVENT_COMPARE_2 ? "NRF_RTC_EVENT_COMPARE_2" : \ - (event == NRF_RTC_EVENT_COMPARE_3 ? "NRF_RTC_EVENT_COMPARE_3" : "UNKNOWN EVENT") -#else //RTC_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //RTC_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -/**@brief RTC driver instance control block structure. */ -typedef struct -{ - nrf_drv_state_t state; /**< Instance state. */ - bool reliable; /**< Reliable mode flag. */ - uint8_t tick_latency; /**< Maximum length of interrupt handler in ticks (max 7.7 ms). */ -} nrf_drv_rtc_cb_t; - -// User callbacks local storage. -static nrf_drv_rtc_handler_t m_handlers[ENABLED_RTC_COUNT]; -static nrf_drv_rtc_cb_t m_cb[ENABLED_RTC_COUNT]; - -ret_code_t nrf_drv_rtc_init(nrf_drv_rtc_t const * const p_instance, - nrf_drv_rtc_config_t const * p_config, - nrf_drv_rtc_handler_t handler) -{ - ASSERT(p_config != NULL); - - ret_code_t err_code; - - if (handler) - { - m_handlers[p_instance->instance_id] = handler; - } - else - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - if (m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - nrf_drv_common_irq_enable(p_instance->irq, p_config->interrupt_priority); - nrf_rtc_prescaler_set(p_instance->p_reg, p_config->prescaler); - m_cb[p_instance->instance_id].reliable = p_config->reliable; - m_cb[p_instance->instance_id].tick_latency = p_config->tick_latency; - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -void nrf_drv_rtc_uninit(nrf_drv_rtc_t const * const p_instance) -{ - uint32_t mask = NRF_RTC_INT_TICK_MASK | - NRF_RTC_INT_OVERFLOW_MASK | - NRF_RTC_INT_COMPARE0_MASK | - NRF_RTC_INT_COMPARE1_MASK | - NRF_RTC_INT_COMPARE2_MASK | - NRF_RTC_INT_COMPARE3_MASK; - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_drv_common_irq_disable(p_instance->irq); - - nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_STOP); - nrf_rtc_event_disable(p_instance->p_reg, mask); - nrf_rtc_int_disable(p_instance->p_reg, mask); - - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_UNINITIALIZED; - NRF_LOG_INFO("Uninitialized."); -} - -void nrf_drv_rtc_enable(nrf_drv_rtc_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state == NRF_DRV_STATE_INITIALIZED); - - nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_START); - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_POWERED_ON; - NRF_LOG_INFO("Enabled."); -} - -void nrf_drv_rtc_disable(nrf_drv_rtc_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_STOP); - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_INITIALIZED; - NRF_LOG_INFO("Disabled."); -} - -ret_code_t nrf_drv_rtc_cc_disable(nrf_drv_rtc_t const * const p_instance, uint32_t channel) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(channelcc_channel_count); - - ret_code_t err_code; - uint32_t int_mask = RTC_CHANNEL_INT_MASK(channel); - nrf_rtc_event_t event = RTC_CHANNEL_EVENT_ADDR(channel); - - nrf_rtc_event_disable(p_instance->p_reg,int_mask); - if (nrf_rtc_int_is_enabled(p_instance->p_reg,int_mask)) - { - nrf_rtc_int_disable(p_instance->p_reg,int_mask); - if (nrf_rtc_event_pending(p_instance->p_reg,event)) - { - nrf_rtc_event_clear(p_instance->p_reg,event); - err_code = NRF_ERROR_TIMEOUT; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - } - NRF_LOG_INFO("RTC id: %d, channel disabled: %d.", p_instance->instance_id, channel); - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -ret_code_t nrf_drv_rtc_cc_set(nrf_drv_rtc_t const * const p_instance, - uint32_t channel, - uint32_t val, - bool enable_irq) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(channelcc_channel_count); - - ret_code_t err_code; - uint32_t int_mask = RTC_CHANNEL_INT_MASK(channel); - nrf_rtc_event_t event = RTC_CHANNEL_EVENT_ADDR(channel); - - nrf_rtc_event_disable(p_instance->p_reg, int_mask); - nrf_rtc_int_disable(p_instance->p_reg, int_mask); - - val = RTC_WRAP(val); - if (m_cb[p_instance->instance_id].reliable) - { - nrf_rtc_cc_set(p_instance->p_reg,channel,val); - uint32_t cnt = nrf_rtc_counter_get(p_instance->p_reg); - int32_t diff = cnt - val; - if (cnt < val) - { - diff += RTC_COUNTER_COUNTER_Msk; - } - if (diff < m_cb[p_instance->instance_id].tick_latency) - { - err_code = NRF_ERROR_TIMEOUT; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - } - else - { - nrf_rtc_cc_set(p_instance->p_reg,channel,val); - } - - if (enable_irq) - { - nrf_rtc_event_clear(p_instance->p_reg,event); - nrf_rtc_int_enable(p_instance->p_reg, int_mask); - } - nrf_rtc_event_enable(p_instance->p_reg,int_mask); - - NRF_LOG_INFO("RTC id: %d, channel enabled: %d, compare value: %d.", p_instance->instance_id, channel, val); - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -void nrf_drv_rtc_tick_enable(nrf_drv_rtc_t const * const p_instance, bool enable_irq) -{ - nrf_rtc_event_t event = NRF_RTC_EVENT_TICK; - uint32_t mask = NRF_RTC_INT_TICK_MASK; - - nrf_rtc_event_clear(p_instance->p_reg, event); - nrf_rtc_event_enable(p_instance->p_reg, mask); - if (enable_irq) - { - nrf_rtc_int_enable(p_instance->p_reg, mask); - } - NRF_LOG_INFO("Tick events enabled."); -} - -void nrf_drv_rtc_tick_disable(nrf_drv_rtc_t const * const p_instance) -{ - uint32_t mask = NRF_RTC_INT_TICK_MASK; - - nrf_rtc_event_disable(p_instance->p_reg, mask); - nrf_rtc_int_disable(p_instance->p_reg, mask); - NRF_LOG_INFO("Tick events disabled."); -} - -void nrf_drv_rtc_overflow_enable(nrf_drv_rtc_t const * const p_instance, bool enable_irq) -{ - nrf_rtc_event_t event = NRF_RTC_EVENT_OVERFLOW; - uint32_t mask = NRF_RTC_INT_OVERFLOW_MASK; - - nrf_rtc_event_clear(p_instance->p_reg, event); - nrf_rtc_event_enable(p_instance->p_reg, mask); - if (enable_irq) - { - nrf_rtc_int_enable(p_instance->p_reg, mask); - } -} -void nrf_drv_rtc_overflow_disable(nrf_drv_rtc_t const * const p_instance) -{ - uint32_t mask = NRF_RTC_INT_OVERFLOW_MASK; - nrf_rtc_event_disable(p_instance->p_reg, mask); - nrf_rtc_int_disable(p_instance->p_reg, mask); -} - -uint32_t nrf_drv_rtc_max_ticks_get(nrf_drv_rtc_t const * const p_instance) -{ - uint32_t ticks; - if (m_cb[p_instance->instance_id].reliable) - { - ticks = RTC_COUNTER_COUNTER_Msk - m_cb[p_instance->instance_id].tick_latency; - } - else - { - ticks = RTC_COUNTER_COUNTER_Msk; - } - return ticks; -} - -/**@brief Generic function for handling RTC interrupt - * - * @param[in] p_reg Pointer to instance register structure. - * @param[in] instance_id Index of instance. - */ -__STATIC_INLINE void nrf_drv_rtc_int_handler(NRF_RTC_Type * p_reg, - uint32_t instance_id, - uint32_t channel_count) -{ - uint32_t i; - uint32_t int_mask = (uint32_t)NRF_RTC_INT_COMPARE0_MASK; - nrf_rtc_event_t event = NRF_RTC_EVENT_COMPARE_0; - - for (i = 0; i < channel_count; i++) - { - if (nrf_rtc_int_is_enabled(p_reg,int_mask) && nrf_rtc_event_pending(p_reg,event)) - { - nrf_rtc_event_disable(p_reg,int_mask); - nrf_rtc_int_disable(p_reg,int_mask); - nrf_rtc_event_clear(p_reg,event); - NRF_LOG_DEBUG("Event: %s, instance id: %d.", - (uint32_t)EVT_TO_STR(event), (uint32_t)instance_id); - m_handlers[instance_id]((nrf_drv_rtc_int_type_t)i); - } - int_mask <<= 1; - event = (nrf_rtc_event_t)((uint32_t)event + sizeof(uint32_t)); - } - event = NRF_RTC_EVENT_TICK; - if (nrf_rtc_int_is_enabled(p_reg,NRF_RTC_INT_TICK_MASK) && - nrf_rtc_event_pending(p_reg, event)) - { - nrf_rtc_event_clear(p_reg, event); - NRF_LOG_DEBUG("Event: %s, instance id: %d.", (uint32_t)EVT_TO_STR(event), instance_id); - m_handlers[instance_id](NRF_DRV_RTC_INT_TICK); - } - - event = NRF_RTC_EVENT_OVERFLOW; - if (nrf_rtc_int_is_enabled(p_reg,NRF_RTC_INT_OVERFLOW_MASK) && - nrf_rtc_event_pending(p_reg, event)) - { - nrf_rtc_event_clear(p_reg,event); - NRF_LOG_DEBUG("Event: %s, instance id: %d.", (uint32_t)EVT_TO_STR(event), instance_id); - m_handlers[instance_id](NRF_DRV_RTC_INT_OVERFLOW); - } -} - -#if NRF_MODULE_ENABLED(RTC0) -void RTC0_IRQHandler(void) -{ - nrf_drv_rtc_int_handler(NRF_RTC0,RTC0_INSTANCE_INDEX, NRF_RTC_CC_CHANNEL_COUNT(0)); -} -#endif - -#if NRF_MODULE_ENABLED(RTC1) -void RTC1_IRQHandler(void) -{ - nrf_drv_rtc_int_handler(NRF_RTC1,RTC1_INSTANCE_INDEX, NRF_RTC_CC_CHANNEL_COUNT(1)); -} -#endif - -#if NRF_MODULE_ENABLED(RTC2) -void RTC2_IRQHandler(void) -{ - nrf_drv_rtc_int_handler(NRF_RTC2,RTC2_INSTANCE_INDEX, NRF_RTC_CC_CHANNEL_COUNT(2)); -} -#endif -#endif //ENABLED_RTC_COUNT -#endif //NRF_MODULE_ENABLED(RTC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.h deleted file mode 100644 index 8e55c76..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rtc/nrf_drv_rtc.h +++ /dev/null @@ -1,365 +0,0 @@ -/** - * Copyright (c) 2014 - 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 NRF_DRV_RTC_H -#define NRF_DRV_RTC_H - - -#include "sdk_config.h" -#include "nordic_common.h" -#include "nrf_drv_common.h" -#include "nrf_rtc.h" -#include "sdk_errors.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup nrf_rtc RTC HAL and driver - * @ingroup nrf_drivers - * @brief Real timer counter (RTC) APIs. - * @details The RTC HAL provides basic APIs for accessing the registers of the real time counter (RTC). - * The RTC driver provides APIs on a higher level. - * - * @defgroup nrf_drv_rtc RTC driver - * @{ - * @ingroup nrf_rtc - * @brief Real timer counter (RTC) driver. - */ - -/**@brief Macro to convert microseconds into ticks. */ -#define RTC_US_TO_TICKS(us,freq) (((us) * (freq)) / 1000000U) - -/** - * @enum nrf_drv_rtc_int_type_t - * @brief RTC driver interrupt types. - */ -typedef enum -{ - NRF_DRV_RTC_INT_COMPARE0 = 0, /**< Interrupt from COMPARE0 event. */ - NRF_DRV_RTC_INT_COMPARE1 = 1, /**< Interrupt from COMPARE1 event. */ - NRF_DRV_RTC_INT_COMPARE2 = 2, /**< Interrupt from COMPARE2 event. */ - NRF_DRV_RTC_INT_COMPARE3 = 3, /**< Interrupt from COMPARE3 event. */ - NRF_DRV_RTC_INT_TICK = 4, /**< Interrupt from TICK event. */ - NRF_DRV_RTC_INT_OVERFLOW = 5 /**< Interrupt from OVERFLOW event. */ -} nrf_drv_rtc_int_type_t; - -/**@brief RTC driver instance structure. */ -typedef struct -{ - NRF_RTC_Type * p_reg; /**< Pointer to instance register set. */ - IRQn_Type irq; /**< Instance IRQ ID. */ - uint8_t instance_id; /**< Instance index. */ - uint8_t cc_channel_count; /**< Number of capture/compare channels. */ -} nrf_drv_rtc_t; - -#define RTC0_INSTANCE_INDEX 0 -#define RTC1_INSTANCE_INDEX RTC0_INSTANCE_INDEX+RTC0_ENABLED -#define RTC2_INSTANCE_INDEX RTC1_INSTANCE_INDEX+RTC1_ENABLED - -/**@brief Macro for creating RTC driver instance.*/ -#define NRF_DRV_RTC_INSTANCE(id) \ -{ \ - .p_reg = CONCAT_2(NRF_RTC, id), \ - .irq = CONCAT_3(RTC, id, _IRQn), \ - .instance_id = CONCAT_3(RTC, id, _INSTANCE_INDEX),\ - .cc_channel_count = NRF_RTC_CC_CHANNEL_COUNT(id), \ -} - -/**@brief RTC driver instance configuration structure. */ -typedef struct -{ - uint16_t prescaler; /**< Prescaler. */ - uint8_t interrupt_priority; /**< Interrupt priority. */ - uint8_t tick_latency; /**< Maximum length of interrupt handler in ticks (max 7.7 ms). */ - bool reliable; /**< Reliable mode flag. */ -} nrf_drv_rtc_config_t; - -/**@brief RTC instance default configuration. */ -#define NRF_DRV_RTC_DEFAULT_CONFIG \ -{ \ - .prescaler = RTC_FREQ_TO_PRESCALER(RTC_DEFAULT_CONFIG_FREQUENCY), \ - .interrupt_priority = RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \ - .reliable = RTC_DEFAULT_CONFIG_RELIABLE, \ - .tick_latency = RTC_US_TO_TICKS(NRF_MAXIMUM_LATENCY_US, RTC_DEFAULT_CONFIG_FREQUENCY), \ -} - -/**@brief RTC driver instance handler type. */ -typedef void (*nrf_drv_rtc_handler_t)(nrf_drv_rtc_int_type_t int_type); - -/**@brief Function for initializing the RTC driver instance. - * - * After initialization, the instance is in power off state. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_config Initial configuration. - * @param[in] handler User's event handler. - * - * @retval NRF_SUCCESS If successfully initialized. - * @retval NRF_ERROR_INVALID_PARAM If no handler was provided. - * @retval NRF_ERROR_INVALID_STATE If the instance is already initialized. - */ -ret_code_t nrf_drv_rtc_init(nrf_drv_rtc_t const * const p_instance, - nrf_drv_rtc_config_t const * p_config, - nrf_drv_rtc_handler_t handler); - -/**@brief Function for uninitializing the RTC driver instance. - * - * After uninitialization, the instance is in idle state. The hardware should return to the state - * before initialization. The function asserts if the instance is in idle state. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_rtc_uninit(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for enabling the RTC driver instance. - * - * @note Function asserts if instance is enabled. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_rtc_enable(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for disabling the RTC driver instance. - * - * @note Function asserts if instance is disabled. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_rtc_disable(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for setting a compare channel. - * - * The function asserts if the instance is not initialized or if the channel parameter is - * wrong. The function powers on the instance if the instance was in power off state. - * - * The driver is not entering a critical section when configuring RTC, which means that it can be - * preempted for a certain amount of time. When the driver was preempted and the value to be set - * is short in time, there is a risk that the driver sets a compare value that is - * behind. If RTCn_CONFIG_RELIABLE is 1 for the given instance, the Reliable mode handles that case. - * However, to detect if the requested value is behind, this mode makes the following assumptions: - * - The maximum preemption time in ticks (8 - bit value) is known and is less than 7.7 ms - * (for prescaler = 0, RTC frequency 32 kHz). - * - The requested absolute compare value is not bigger than (0x00FFFFFF) - tick_latency. It is - * the user's responsibility to ensure that. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] channel One of the instance's channels. - * @param[in] val Absolute value to be set in the compare register. - * @param[in] enable_irq True to enable the interrupt. False to disable the interrupt. - * - * @retval NRF_SUCCESS If the procedure was successful. - * @retval NRF_ERROR_TIMEOUT If the compare was not set because the request value is behind the current counter - * value. This error can only be reported if RTCn_CONFIG_RELIABLE = 1. - */ -ret_code_t nrf_drv_rtc_cc_set(nrf_drv_rtc_t const * const p_instance, - uint32_t channel, - uint32_t val, - bool enable_irq); - -/**@brief Function for disabling a channel. - * - * This function disables channel events and channel interrupts. The function asserts if the instance is not - * initialized or if the channel parameter is wrong. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] channel One of the instance's channels. - * - * @retval NRF_SUCCESS If the procedure was successful. - * @retval NRF_ERROR_TIMEOUT If an interrupt was pending on the requested channel. - */ -ret_code_t nrf_drv_rtc_cc_disable(nrf_drv_rtc_t const * const p_instance, uint32_t channel); - -/**@brief Function for enabling tick. - * - * This function enables the tick event and optionally the interrupt. The function asserts if the instance is not - * powered on. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] enable_irq True to enable the interrupt. False to disable the interrupt. - */ -void nrf_drv_rtc_tick_enable(nrf_drv_rtc_t const * const p_instance, bool enable_irq); - -/**@brief Function for disabling tick. - * - * This function disables the tick event and interrupt. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_rtc_tick_disable(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for enabling overflow. - * - * This function enables the overflow event and optionally the interrupt. The function asserts if the instance is - * not powered on. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] enable_irq True to enable the interrupt. False to disable the interrupt. - */ -void nrf_drv_rtc_overflow_enable(nrf_drv_rtc_t const * const p_instance, bool enable_irq); - -/**@brief Function for disabling overflow. - * - * This function disables the overflow event and interrupt. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_rtc_overflow_disable(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for getting the maximum relative ticks value that can be set in the compare channel. - * - * When a SoftDevice is used, it occupies the highest level interrupt, so that the application code can be - * interrupted at any moment for a certain period of time. If Reliable mode is enabled, the provided - * maximum latency is taken into account and the return value is smaller than the RTC counter - * resolution. If Reliable mode is disabled, the return value equals the counter resolution. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval ticks Maximum ticks value. - */ -uint32_t nrf_drv_rtc_max_ticks_get(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for disabling all instance interrupts. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_mask Pointer to the location where the mask is filled. - */ -__STATIC_INLINE void nrf_drv_rtc_int_disable(nrf_drv_rtc_t const * const p_instance, - uint32_t * p_mask); - -/**@brief Function for enabling instance interrupts. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] mask Mask of interrupts to enable. - */ -__STATIC_INLINE void nrf_drv_rtc_int_enable(nrf_drv_rtc_t const * const p_instance, uint32_t mask); - -/**@brief Function for retrieving the current counter value. - * - * This function asserts if the instance is not powered on or if p_val is NULL. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval value Counter value. - */ -__STATIC_INLINE uint32_t nrf_drv_rtc_counter_get(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for clearing the counter value. - * - * This function asserts if the instance is not powered on. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -__STATIC_INLINE void nrf_drv_rtc_counter_clear(nrf_drv_rtc_t const * const p_instance); - -/**@brief Function for returning a requested task address for the RTC driver instance. - * - * This function asserts if the output pointer is NULL. The task address can be used by the PPI module. - * - * @param[in] p_instance Pointer to the instance. - * @param[in] task One of the peripheral tasks. - * - * @retval Address of task register. - */ -__STATIC_INLINE uint32_t nrf_drv_rtc_task_address_get(nrf_drv_rtc_t const * const p_instance, - nrf_rtc_task_t task); - -/**@brief Function for returning a requested event address for the RTC driver instance. - * - * This function asserts if the output pointer is NULL. The event address can be used by the PPI module. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] event One of the peripheral events. - * - * @retval Address of event register. - */ -__STATIC_INLINE uint32_t nrf_drv_rtc_event_address_get(nrf_drv_rtc_t const * const p_instance, - nrf_rtc_event_t event); -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_drv_rtc_int_disable(nrf_drv_rtc_t const * const p_instance, - uint32_t * p_mask) -{ - *p_mask = nrf_rtc_int_get(p_instance->p_reg); - nrf_rtc_int_disable(p_instance->p_reg, NRF_RTC_INT_TICK_MASK | - NRF_RTC_INT_OVERFLOW_MASK | - NRF_RTC_INT_COMPARE0_MASK | - NRF_RTC_INT_COMPARE1_MASK | - NRF_RTC_INT_COMPARE2_MASK | - NRF_RTC_INT_COMPARE3_MASK); -} - -__STATIC_INLINE void nrf_drv_rtc_int_enable(nrf_drv_rtc_t const * const p_instance, uint32_t mask) -{ - nrf_rtc_int_enable(p_instance->p_reg, mask); -} - -__STATIC_INLINE uint32_t nrf_drv_rtc_counter_get(nrf_drv_rtc_t const * const p_instance) -{ - return nrf_rtc_counter_get(p_instance->p_reg); -} - -__STATIC_INLINE void nrf_drv_rtc_counter_clear(nrf_drv_rtc_t const * const p_instance) -{ - nrf_rtc_task_trigger(p_instance->p_reg,NRF_RTC_TASK_CLEAR); -} - -__STATIC_INLINE uint32_t nrf_drv_rtc_task_address_get(nrf_drv_rtc_t const * const p_instance, - nrf_rtc_task_t task) -{ - return nrf_rtc_task_address_get(p_instance->p_reg, task); -} - -__STATIC_INLINE uint32_t nrf_drv_rtc_event_address_get(nrf_drv_rtc_t const * const p_instance, - nrf_rtc_event_t event) -{ - return nrf_rtc_event_address_get(p_instance->p_reg, event); -} -#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ - -/** - *@} - **/ - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_DRV_RTC_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/saadc/nrf_drv_saadc.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/saadc/nrf_drv_saadc.h deleted file mode 100644 index 45b4204..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/saadc/nrf_drv_saadc.h +++ /dev/null @@ -1,326 +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. - * - */ -/** - * @addtogroup nrf_saadc SAADC HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Successive Approximation Analog-to-Digital Converter (SAADC) APIs. - * @details The SAADC HAL provides basic APIs for accessing the registers of the SAADC peripheral. - * The SAADC driver provides APIs on a higher level. - * - * @defgroup nrf_drv_saadc SAADC driver - * @{ - * @ingroup nrf_saadc - * - * @brief @tagAPI52 Successive Approximation Analog-to-Digital Converter (SAADC) driver. - */ - -#ifndef NRF_DRV_SAADC_H__ -#define NRF_DRV_SAADC_H__ - -#include "sdk_config.h" -#include "nrf_saadc.h" -#include "sdk_errors.h" -#include "nrf_drv_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Value that should be set as high limit to disable limit detection. - */ -#define NRF_DRV_SAADC_LIMITH_DISABLED (2047) -/** - * @brief Value that should be set as low limit to disable limit detection. - */ -#define NRF_DRV_SAADC_LIMITL_DISABLED (-2048) - -/** - * @brief Macro for setting @ref nrf_drv_saadc_config_t to default settings. - */ -#define NRF_DRV_SAADC_DEFAULT_CONFIG \ - { \ - .resolution = (nrf_saadc_resolution_t)SAADC_CONFIG_RESOLUTION, \ - .oversample = (nrf_saadc_oversample_t)SAADC_CONFIG_OVERSAMPLE, \ - .interrupt_priority = SAADC_CONFIG_IRQ_PRIORITY, \ - .low_power_mode = SAADC_CONFIG_LP_MODE \ - } - -/** - * @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings - * in single ended mode. - * - * @param PIN_P Analog input. - */ -#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) \ - { \ - .resistor_p = NRF_SAADC_RESISTOR_DISABLED, \ - .resistor_n = NRF_SAADC_RESISTOR_DISABLED, \ - .gain = NRF_SAADC_GAIN1_6, \ - .reference = NRF_SAADC_REFERENCE_INTERNAL, \ - .acq_time = NRF_SAADC_ACQTIME_10US, \ - .mode = NRF_SAADC_MODE_SINGLE_ENDED, \ - .burst = NRF_SAADC_BURST_DISABLED, \ - .pin_p = (nrf_saadc_input_t)(PIN_P), \ - .pin_n = NRF_SAADC_INPUT_DISABLED \ - } - -/** - * @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings - * in differential mode. - * - * @param PIN_P Positive analog input. - * @param PIN_N Negative analog input. - */ -#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(PIN_P, PIN_N) \ - { \ - .resistor_p = NRF_SAADC_RESISTOR_DISABLED, \ - .resistor_n = NRF_SAADC_RESISTOR_DISABLED, \ - .gain = NRF_SAADC_GAIN1_6, \ - .reference = NRF_SAADC_REFERENCE_INTERNAL, \ - .acq_time = NRF_SAADC_ACQTIME_10US, \ - .mode = NRF_SAADC_MODE_DIFFERENTIAL, \ - .pin_p = (nrf_saadc_input_t)(PIN_P), \ - .pin_n = (nrf_saadc_input_t)(PIN_N) \ - } - -/** - * @brief Analog-to-digital converter driver configuration structure. - */ -typedef struct -{ - nrf_saadc_resolution_t resolution; ///< Resolution configuration. - nrf_saadc_oversample_t oversample; ///< Oversampling configuration. - uint8_t interrupt_priority; ///< Interrupt priority. - bool low_power_mode; ///< Indicates if low power mode is active. -} nrf_drv_saadc_config_t; - -/** - * @brief Driver event types. - */ -typedef enum -{ - NRF_DRV_SAADC_EVT_DONE, ///< Event generated when the buffer is filled with samples. - NRF_DRV_SAADC_EVT_LIMIT, ///< Event generated after one of the limits is reached. - NRF_DRV_SAADC_EVT_CALIBRATEDONE ///< Event generated when the calibration is complete. -} nrf_drv_saadc_evt_type_t; - -/** - * @brief Analog-to-digital converter driver done event data. - */ -typedef struct -{ - nrf_saadc_value_t * p_buffer; ///< Pointer to buffer with converted samples. - uint16_t size; ///< Number of samples in the buffer. -} nrf_drv_saadc_done_evt_t; - -/** - * @brief Analog-to-digital converter driver limit event data. - */ -typedef struct -{ - uint8_t channel; ///< Channel on which the limit was detected. - nrf_saadc_limit_t limit_type; ///< Type of limit detected. -} nrf_drv_saadc_limit_evt_t; - -/** - * @brief Analog-to-digital converter driver event structure. - */ -typedef struct -{ - nrf_drv_saadc_evt_type_t type; ///< Event type. - union - { - nrf_drv_saadc_done_evt_t done; ///< Data for @ref NRF_DRV_SAADC_EVT_DONE event. - nrf_drv_saadc_limit_evt_t limit; ///< Data for @ref NRF_DRV_SAADC_EVT_LIMIT event. - } data; -} nrf_drv_saadc_evt_t; - -/** - * @brief ADC event handler. - * - * @param[in] p_event Pointer to an ADC event. The event structure is allocated on - * the stack, so it is valid only within the context of - * the event handler. - */ -typedef void (* nrf_drv_saadc_event_handler_t)(nrf_drv_saadc_evt_t const * p_event); - -/** - * @brief Function for initializing the SAADC. - * - * @param[in] p_config Pointer to a configuration structure. If NULL, the default one is used. - * @param[in] event_handler Event handler provided by the user. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. - * @retval NRF_ERROR_INVALID_PARAM If event_handler is NULL. - */ -ret_code_t nrf_drv_saadc_init(nrf_drv_saadc_config_t const * p_config, - nrf_drv_saadc_event_handler_t event_handler); - -/** - * @brief Function for uninitializing the SAADC. - * - * This function stops all ongoing conversions and disables all channels. - */ -void nrf_drv_saadc_uninit(void); - - -/** - * @brief Function for getting the address of a SAMPLE SAADC task. - * - * @return Task address. - */ -uint32_t nrf_drv_saadc_sample_task_get(void); - -/** - * @brief Function for initializing an SAADC channel. - * - * This function configures and enables the channel. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the ADC was not initialized. - * @retval NRF_ERROR_NO_MEM If the specified channel was already allocated. - */ -ret_code_t nrf_drv_saadc_channel_init(uint8_t channel, - nrf_saadc_channel_config_t const * const p_config); - - -/** - * @brief Function for uninitializing an SAADC channel. - * - * @retval NRF_SUCCESS If uninitialization was successful. - * @retval NRF_ERROR_BUSY If the ADC is busy. - */ -ret_code_t nrf_drv_saadc_channel_uninit(uint8_t channel); - -/** - * @brief Function for starting SAADC sampling. - * - * @retval NRF_SUCCESS If ADC sampling was triggered. - * @retval NRF_ERROR_INVALID_STATE If ADC is in idle state. - */ -ret_code_t nrf_drv_saadc_sample(void); - -/** - * @brief Blocking function for executing a single ADC conversion. - * - * This function selects the desired input, starts a single conversion, - * waits for it to finish, and returns the result. - * - * The function will fail if ADC is busy. - * - * @param[in] channel Channel. - * @param[out] p_value Pointer to the location where the result should be placed. - * - * @retval NRF_SUCCESS If conversion was successful. - * @retval NRF_ERROR_BUSY If the ADC driver is busy. - */ -ret_code_t nrf_drv_saadc_sample_convert(uint8_t channel, nrf_saadc_value_t * p_value); - -/** - * @brief Function for issuing conversion of data to the buffer. - * - * This function is non-blocking. The application is notified about filling the buffer by the event handler. - * Conversion will be done on all enabled channels. If the ADC is in idle state, the function will set up Easy - * DMA for the conversion. The ADC will be ready for sampling and wait for the SAMPLE task. It can be - * triggered manually by the @ref nrf_drv_saadc_sample function or by PPI using the @ref NRF_SAADC_TASK_SAMPLE - * task. If one buffer is already set and the conversion is ongoing, calling this function will - * result in queuing the given buffer. The driver will start filling the issued buffer when the first one is - * completed. If the function is called again before the first buffer is filled or calibration is in progress, - * it will return with error. - * - * @param[in] buffer Result buffer. - * @param[in] size Buffer size in words. - * - * @retval NRF_SUCCESS If conversion was successful. - * @retval NRF_ERROR_BUSY If the driver already has two buffers set or calibration is in progress. - */ -ret_code_t nrf_drv_saadc_buffer_convert(nrf_saadc_value_t * buffer, uint16_t size); - -/** - * @brief Function for triggering the ADC offset calibration. - * - * This function is non-blocking. The application is notified about completion by the event handler. - * Calibration will also trigger DONE and RESULTDONE events. - * - * The function will fail if ADC is busy or calibration is already in progress. - * - * @retval NRF_SUCCESS If calibration was started successfully. - * @retval NRF_ERROR_BUSY If the ADC driver is busy. - */ -ret_code_t nrf_drv_saadc_calibrate_offset(void); - -/** - * @brief Function for retrieving the SAADC state. - * - * @retval true If the ADC is busy. - * @retval false If the ADC is ready. - */ -bool nrf_drv_saadc_is_busy(void); - -/** - * @brief Function for aborting ongoing and buffered conversions. - * @note @ref NRF_DRV_SAADC_EVT_DONE event will be generated if there is a conversion in progress. - * Event will contain number of words in the sample buffer. - */ -void nrf_drv_saadc_abort(void); - -/** - * @brief Function for setting the SAADC channel limits. - * When limits are enabled and the result exceeds the defined bounds, the limit handler function is called. - * - * @param[in] channel SAADC channel number. - * @param[in] limit_low Lower limit (valid values from @ref NRF_DRV_SAADC_LIMITL_DISABLED to - * @ref NRF_DRV_SAADC_LIMITH_DISABLED). Conversion results below this value will trigger - * the handler function. Set to @ref NRF_DRV_SAADC_LIMITL_DISABLED to disable this limit. - * @param[in] limit_high Upper limit (valid values from @ref NRF_DRV_SAADC_LIMITL_DISABLED to - * @ref NRF_DRV_SAADC_LIMITH_DISABLED). Conversion results above this value will trigger - * the handler function. Set to @ref NRF_DRV_SAADC_LIMITH_DISABLED to disable this limit. - */ -void nrf_drv_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high); - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_SAADC_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.c deleted file mode 100644 index 88459e5..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.c +++ /dev/null @@ -1,774 +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(SPI) -#include "nrf_drv_spi.h" -#if ENABLED_SPI_COUNT -#include "nrf_drv_common.h" -#include "nrf_gpio.h" -#include "nrf_assert.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME spi - - -#if SPI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL SPI_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR SPI_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR SPI_CONFIG_DEBUG_COLOR - -#else //SPI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //SPI_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - -#define SPIM_ONLY ( defined(SPIM_PRESENT) && !defined(SPI_PRESENT)) -#define SPI_SPIM_PRESENT ( defined(SPIM_PRESENT) && defined(SPI_PRESENT)) -#define SPI_ONLY (!defined(SPIM_PRESENT) && defined(SPI_PRESENT)) - -#define SPI0_WITH_DMA (defined(SPI0_USE_EASY_DMA) && SPI0_USE_EASY_DMA && SPI0_ENABLED) -#define SPI1_WITH_DMA (defined(SPI1_USE_EASY_DMA) && SPI1_USE_EASY_DMA && SPI1_ENABLED) -#define SPI2_WITH_DMA (defined(SPI2_USE_EASY_DMA) && SPI2_USE_EASY_DMA && SPI2_ENABLED) - -#define SPI0_WITHOUT_DMA (defined(SPI0_USE_EASY_DMA) && !SPI0_USE_EASY_DMA && SPI0_ENABLED) -#define SPI1_WITHOUT_DMA (defined(SPI1_USE_EASY_DMA) && !SPI1_USE_EASY_DMA && SPI1_ENABLED) -#define SPI2_WITHOUT_DMA (defined(SPI2_USE_EASY_DMA) && !SPI2_USE_EASY_DMA && SPI2_ENABLED) - -// suppress: non-standard use of 'defined' preprocessor operator -/*lint -save -e491*/ -#if (SPI_ONLY && ENABLED_SPI_COUNT) || ((SPI_SPIM_PRESENT) && \ - (SPI0_WITHOUT_DMA || SPI1_WITHOUT_DMA || SPI2_WITHOUT_DMA)) - #define SPI_IN_USE 1 -#endif - -#if (SPIM_ONLY && ENABLED_SPI_COUNT) || ((SPI_SPIM_PRESENT) && \ - (SPI0_WITH_DMA || SPI1_WITH_DMA || SPI2_WITH_DMA)) - #define SPIM_IN_USE 1 -#endif - - -#if defined(SPIM_IN_USE) && defined(SPI_IN_USE) - // SPIM and SPI combined - #define CODE_FOR_SPIM(code) if (p_instance->use_easy_dma) { code } - #define CODE_FOR_SPI(code) else { code } -#elif defined(SPIM_IN_USE) && !defined(SPI_IN_USE) - // SPIM only - #define CODE_FOR_SPIM(code) { code } - #define CODE_FOR_SPI(code) -#elif !defined(SPIM_IN_USE) && defined(SPI_IN_USE) - // SPI only - #define CODE_FOR_SPIM(code) - #define CODE_FOR_SPI(code) { code } -#else - #error "Wrong configuration." -#endif - -#ifdef SPIM_IN_USE -#define END_INT_MASK NRF_SPIM_INT_END_MASK -#endif - -// Control block - driver instance local data. -typedef struct -{ - nrf_drv_spi_evt_handler_t handler; - void * p_context; - nrf_drv_spi_evt_t evt; // Keep the struct that is ready for event handler. Less memcpy. - nrf_drv_state_t state; - volatile bool transfer_in_progress; - - // [no need for 'volatile' attribute for the following members, as they - // are not concurrently used in IRQ handlers and main line code] - uint8_t ss_pin; - uint8_t orc; - uint8_t bytes_transferred; - -#if NRF_MODULE_ENABLED(SPIM_NRF52_ANOMALY_109_WORKAROUND) - uint8_t tx_length; - uint8_t rx_length; -#endif - - bool tx_done : 1; - bool rx_done : 1; - bool abort : 1; -} spi_control_block_t; -static spi_control_block_t m_cb[ENABLED_SPI_COUNT]; - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - #define IRQ_HANDLER_NAME(n) irq_handler_for_instance_##n - #define IRQ_HANDLER(n) static void IRQ_HANDLER_NAME(n)(void) - - #if NRF_MODULE_ENABLED(SPI0) - IRQ_HANDLER(0); - #endif - #if NRF_MODULE_ENABLED(SPI1) - IRQ_HANDLER(1); - #endif - #if NRF_MODULE_ENABLED(SPI2) - IRQ_HANDLER(2); - #endif - static nrf_drv_irq_handler_t const m_irq_handlers[ENABLED_SPI_COUNT] = { - #if NRF_MODULE_ENABLED(SPI0) - IRQ_HANDLER_NAME(0), - #endif - #if NRF_MODULE_ENABLED(SPI1) - IRQ_HANDLER_NAME(1), - #endif - #if NRF_MODULE_ENABLED(SPI2) - IRQ_HANDLER_NAME(2), - #endif - }; -#else - #define IRQ_HANDLER(n) void SPI##n##_IRQ_HANDLER(void) -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -ret_code_t nrf_drv_spi_init(nrf_drv_spi_t const * const p_instance, - nrf_drv_spi_config_t const * p_config, - nrf_drv_spi_evt_handler_t handler, - void * p_context) -{ - ASSERT(p_config); - spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ret_code_t err_code; - - if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - if (nrf_drv_common_per_res_acquire(p_instance->p_registers, - m_irq_handlers[p_instance->drv_inst_idx]) != NRF_SUCCESS) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } -#endif - - p_cb->handler = handler; - p_cb->p_context = p_context; - - uint32_t mosi_pin; - uint32_t miso_pin; - // Configure pins used by the peripheral: - // - SCK - output with initial value corresponding with the SPI mode used: - // 0 - for modes 0 and 1 (CPOL = 0), 1 - for modes 2 and 3 (CPOL = 1); - // according to the reference manual guidelines this pin and its input - // buffer must always be connected for the SPI to work. - if (p_config->mode <= NRF_DRV_SPI_MODE_1) - { - nrf_gpio_pin_clear(p_config->sck_pin); - } - else - { - nrf_gpio_pin_set(p_config->sck_pin); - } - nrf_gpio_cfg(p_config->sck_pin, - NRF_GPIO_PIN_DIR_OUTPUT, - NRF_GPIO_PIN_INPUT_CONNECT, - NRF_GPIO_PIN_NOPULL, - NRF_GPIO_PIN_S0S1, - NRF_GPIO_PIN_NOSENSE); - // - MOSI (optional) - output with initial value 0, - if (p_config->mosi_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - mosi_pin = p_config->mosi_pin; - nrf_gpio_pin_clear(mosi_pin); - nrf_gpio_cfg_output(mosi_pin); - } - else - { - mosi_pin = NRF_SPI_PIN_NOT_CONNECTED; - } - // - MISO (optional) - input, - if (p_config->miso_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - miso_pin = p_config->miso_pin; - nrf_gpio_cfg_input(miso_pin, (nrf_gpio_pin_pull_t)NRF_SPI_DRV_MISO_PULLUP_CFG); - } - else - { - miso_pin = NRF_SPI_PIN_NOT_CONNECTED; - } - // - Slave Select (optional) - output with initial value 1 (inactive). - if (p_config->ss_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - nrf_gpio_pin_set(p_config->ss_pin); - nrf_gpio_cfg_output(p_config->ss_pin); - } - m_cb[p_instance->drv_inst_idx].ss_pin = p_config->ss_pin; - - CODE_FOR_SPIM - ( - NRF_SPIM_Type * p_spim = (NRF_SPIM_Type *)p_instance->p_registers; - nrf_spim_pins_set(p_spim, p_config->sck_pin, mosi_pin, miso_pin); - nrf_spim_frequency_set(p_spim, - (nrf_spim_frequency_t)p_config->frequency); - nrf_spim_configure(p_spim, - (nrf_spim_mode_t)p_config->mode, - (nrf_spim_bit_order_t)p_config->bit_order); - - nrf_spim_orc_set(p_spim, p_config->orc); - - if (p_cb->handler) - { - nrf_spim_int_enable(p_spim, END_INT_MASK); - } - - nrf_spim_enable(p_spim); - ) - CODE_FOR_SPI - ( - NRF_SPI_Type * p_spi = p_instance->p_registers; - nrf_spi_pins_set(p_spi, p_config->sck_pin, mosi_pin, miso_pin); - nrf_spi_frequency_set(p_spi, - (nrf_spi_frequency_t)p_config->frequency); - nrf_spi_configure(p_spi, - (nrf_spi_mode_t)p_config->mode, - (nrf_spi_bit_order_t)p_config->bit_order); - - m_cb[p_instance->drv_inst_idx].orc = p_config->orc; - - if (p_cb->handler) - { - nrf_spi_int_enable(p_spi, NRF_SPI_INT_READY_MASK); - } - - nrf_spi_enable(p_spi); - ) - - if (p_cb->handler) - { - nrf_drv_common_irq_enable(p_instance->irq, p_config->irq_priority); - } - - p_cb->transfer_in_progress = false; - p_cb->state = NRF_DRV_STATE_INITIALIZED; - - NRF_LOG_INFO("Init"); - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -void nrf_drv_spi_uninit(nrf_drv_spi_t const * const p_instance) -{ - spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); - - if (p_cb->handler) - { - nrf_drv_common_irq_disable(p_instance->irq); - } - - #define DISABLE_ALL 0xFFFFFFFF - - CODE_FOR_SPIM - ( - NRF_SPIM_Type * p_spim = (NRF_SPIM_Type *)p_instance->p_registers; - if (p_cb->handler) - { - nrf_spim_int_disable(p_spim, DISABLE_ALL); - if (p_cb->transfer_in_progress) - { - // Ensure that SPI is not performing any transfer. - nrf_spim_task_trigger(p_spim, NRF_SPIM_TASK_STOP); - while (!nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_STOPPED)) {} - p_cb->transfer_in_progress = false; - } - } - nrf_spim_event_clear(p_spim, NRF_SPIM_EVENT_END); - nrf_spim_disable(p_spim); - ) - CODE_FOR_SPI - ( - NRF_SPI_Type * p_spi = p_instance->p_registers; - if (p_cb->handler) - { - nrf_spi_int_disable(p_spi, DISABLE_ALL); - } - nrf_spi_disable(p_spi); - ) - #undef DISABLE_ALL - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - nrf_drv_common_per_res_release(p_instance->p_registers); -#endif - - p_cb->state = NRF_DRV_STATE_UNINITIALIZED; -} - -ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance, - uint8_t const * p_tx_buffer, - uint8_t tx_buffer_length, - uint8_t * p_rx_buffer, - uint8_t rx_buffer_length) -{ - nrf_drv_spi_xfer_desc_t xfer_desc; - xfer_desc.p_tx_buffer = p_tx_buffer; - xfer_desc.p_rx_buffer = p_rx_buffer; - xfer_desc.tx_length = tx_buffer_length; - xfer_desc.rx_length = rx_buffer_length; - - NRF_LOG_INFO("Transfer tx_len:%d, rx_len:%d.", tx_buffer_length, rx_buffer_length); - NRF_LOG_DEBUG("Tx data:"); - NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_tx_buffer, tx_buffer_length * sizeof(p_tx_buffer[0])); - return nrf_drv_spi_xfer(p_instance, &xfer_desc, 0); -} - -static void finish_transfer(spi_control_block_t * p_cb) -{ - // If Slave Select signal is used, this is the time to deactivate it. - if (p_cb->ss_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - nrf_gpio_pin_set(p_cb->ss_pin); - } - - // By clearing this flag before calling the handler we allow subsequent - // transfers to be started directly from the handler function. - p_cb->transfer_in_progress = false; - p_cb->evt.type = NRF_DRV_SPI_EVENT_DONE; - NRF_LOG_INFO("Transfer completed rx_len:%d.", p_cb->evt.data.done.rx_length); - NRF_LOG_DEBUG("Rx data:"); - NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_cb->evt.data.done.p_rx_buffer, - p_cb->evt.data.done.rx_length * - sizeof(p_cb->evt.data.done.p_rx_buffer[0])); - p_cb->handler(&p_cb->evt, p_cb->p_context); -} - -#ifdef SPI_IN_USE -// This function is called from IRQ handler or, in blocking mode, directly -// from the 'nrf_drv_spi_transfer' function. -// It returns true as long as the transfer should be continued, otherwise (when -// there is nothing more to send/receive) it returns false. -static bool transfer_byte(NRF_SPI_Type * p_spi, spi_control_block_t * p_cb) -{ - // Read the data byte received in this transfer and store it in RX buffer, - // if needed. - volatile uint8_t rx_data = nrf_spi_rxd_get(p_spi); - if (p_cb->bytes_transferred < p_cb->evt.data.done.rx_length) - { - p_cb->evt.data.done.p_rx_buffer[p_cb->bytes_transferred] = rx_data; - } - - ++p_cb->bytes_transferred; - - // Check if there are more bytes to send or receive and write proper data - // byte (next one from TX buffer or over-run character) to the TXD register - // when needed. - // NOTE - we've already used 'p_cb->bytes_transferred + 1' bytes from our - // buffers, because we take advantage of double buffering of TXD - // register (so in effect one byte is still being transmitted now); - // see how the transfer is started in the 'nrf_drv_spi_transfer' - // function. - uint16_t bytes_used = p_cb->bytes_transferred + 1; - - if (p_cb->abort) - { - if (bytes_used < p_cb->evt.data.done.tx_length) - { - p_cb->evt.data.done.tx_length = bytes_used; - } - if (bytes_used < p_cb->evt.data.done.rx_length) - { - p_cb->evt.data.done.rx_length = bytes_used; - } - } - - if (bytes_used < p_cb->evt.data.done.tx_length) - { - nrf_spi_txd_set(p_spi, p_cb->evt.data.done.p_tx_buffer[bytes_used]); - return true; - } - else if (bytes_used < p_cb->evt.data.done.rx_length) - { - nrf_spi_txd_set(p_spi, p_cb->orc); - return true; - } - - return (p_cb->bytes_transferred < p_cb->evt.data.done.tx_length || - p_cb->bytes_transferred < p_cb->evt.data.done.rx_length); -} - -static void spi_xfer(NRF_SPI_Type * p_spi, - spi_control_block_t * p_cb, - nrf_drv_spi_xfer_desc_t const * p_xfer_desc) -{ - p_cb->bytes_transferred = 0; - nrf_spi_int_disable(p_spi, NRF_SPI_INT_READY_MASK); - - nrf_spi_event_clear(p_spi, NRF_SPI_EVENT_READY); - - // Start the transfer by writing some byte to the TXD register; - // if TX buffer is not empty, take the first byte from this buffer, - // otherwise - use over-run character. - nrf_spi_txd_set(p_spi, - (p_xfer_desc->tx_length > 0 ? p_xfer_desc->p_tx_buffer[0] : p_cb->orc)); - - // TXD register is double buffered, so next byte to be transmitted can - // be written immediately, if needed, i.e. if TX or RX transfer is to - // be more that 1 byte long. Again - if there is something more in TX - // buffer send it, otherwise use over-run character. - if (p_xfer_desc->tx_length > 1) - { - nrf_spi_txd_set(p_spi, p_xfer_desc->p_tx_buffer[1]); - } - else if (p_xfer_desc->rx_length > 1) - { - nrf_spi_txd_set(p_spi, p_cb->orc); - } - - // For blocking mode (user handler not provided) wait here for READY - // events (indicating that the byte from TXD register was transmitted - // and a new incoming byte was moved to the RXD register) and continue - // transaction until all requested bytes are transferred. - // In non-blocking mode - IRQ service routine will do this stuff. - if (p_cb->handler) - { - nrf_spi_int_enable(p_spi, NRF_SPI_INT_READY_MASK); - } - else - { - do { - while (!nrf_spi_event_check(p_spi, NRF_SPI_EVENT_READY)) {} - nrf_spi_event_clear(p_spi, NRF_SPI_EVENT_READY); - NRF_LOG_DEBUG("SPI: Event: NRF_SPI_EVENT_READY."); - } while (transfer_byte(p_spi, p_cb)); - if (p_cb->ss_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - nrf_gpio_pin_set(p_cb->ss_pin); - } - } -} -#endif // SPI_IN_USE - -#ifdef SPIM_IN_USE -__STATIC_INLINE void spim_int_enable(NRF_SPIM_Type * p_spim, bool enable) -{ - if (!enable) - { - nrf_spim_int_disable(p_spim, END_INT_MASK); - } - else - { - nrf_spim_int_enable(p_spim, END_INT_MASK); - } -} - -__STATIC_INLINE void spim_list_enable_handle(NRF_SPIM_Type * p_spim, uint32_t flags) -{ - if (NRF_DRV_SPI_FLAG_TX_POSTINC & flags) - { - nrf_spim_tx_list_enable(p_spim); - } - else - { - nrf_spim_tx_list_disable(p_spim); - } - - if (NRF_DRV_SPI_FLAG_RX_POSTINC & flags) - { - nrf_spim_rx_list_enable(p_spim); - } - else - { - nrf_spim_rx_list_disable(p_spim); - } -} - -static ret_code_t spim_xfer(NRF_SPIM_Type * p_spim, - spi_control_block_t * p_cb, - nrf_drv_spi_xfer_desc_t const * p_xfer_desc, - uint32_t flags) -{ - ret_code_t err_code; - // EasyDMA requires that transfer buffers are placed in Data RAM region; - // signal error if they are not. - if ((p_xfer_desc->p_tx_buffer != NULL && !nrf_drv_is_in_RAM(p_xfer_desc->p_tx_buffer)) || - (p_xfer_desc->p_rx_buffer != NULL && !nrf_drv_is_in_RAM(p_xfer_desc->p_rx_buffer))) - { - p_cb->transfer_in_progress = false; - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - -#if NRF_MODULE_ENABLED(SPIM_NRF52_ANOMALY_109_WORKAROUND) - p_cb->tx_length = 0; - p_cb->rx_length = 0; -#endif - - nrf_spim_tx_buffer_set(p_spim, p_xfer_desc->p_tx_buffer, p_xfer_desc->tx_length); - nrf_spim_rx_buffer_set(p_spim, p_xfer_desc->p_rx_buffer, p_xfer_desc->rx_length); - - nrf_spim_event_clear(p_spim, NRF_SPIM_EVENT_END); - - spim_list_enable_handle(p_spim, flags); - - if (!(flags & NRF_DRV_SPI_FLAG_HOLD_XFER)) - { - nrf_spim_task_trigger(p_spim, NRF_SPIM_TASK_START); - } -#if NRF_MODULE_ENABLED(SPIM_NRF52_ANOMALY_109_WORKAROUND) - if (flags & NRF_DRV_SPI_FLAG_HOLD_XFER) - { - nrf_spim_event_clear(p_spim, NRF_SPIM_EVENT_STARTED); - p_cb->tx_length = p_xfer_desc->tx_length; - p_cb->rx_length = p_xfer_desc->rx_length; - nrf_spim_tx_buffer_set(p_spim, p_xfer_desc->p_tx_buffer, 0); - nrf_spim_rx_buffer_set(p_spim, p_xfer_desc->p_rx_buffer, 0); - nrf_spim_int_enable(p_spim, NRF_SPIM_INT_STARTED_MASK); - } -#endif - - if (!p_cb->handler) - { - while (!nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_END)){} - if (p_cb->ss_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - nrf_gpio_pin_set(p_cb->ss_pin); - } - } - else - { - spim_int_enable(p_spim, !(flags & NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER)); - } - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} -#endif - -ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance, - nrf_drv_spi_xfer_desc_t const * p_xfer_desc, - uint32_t flags) -{ - spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(p_xfer_desc->p_tx_buffer != NULL || p_xfer_desc->tx_length == 0); - ASSERT(p_xfer_desc->p_rx_buffer != NULL || p_xfer_desc->rx_length == 0); - - ret_code_t err_code = NRF_SUCCESS; - - if (p_cb->transfer_in_progress) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - else - { - if (p_cb->handler && !(flags & (NRF_DRV_SPI_FLAG_REPEATED_XFER | - NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER))) - { - p_cb->transfer_in_progress = true; - } - } - - p_cb->evt.data.done = *p_xfer_desc; - p_cb->tx_done = false; - p_cb->rx_done = false; - p_cb->abort = false; - - if (p_cb->ss_pin != NRF_DRV_SPI_PIN_NOT_USED) - { - nrf_gpio_pin_clear(p_cb->ss_pin); - } - CODE_FOR_SPIM - ( - return spim_xfer(p_instance->p_registers, p_cb, p_xfer_desc, flags); - ) - CODE_FOR_SPI - ( - if (flags) - { - p_cb->transfer_in_progress = false; - err_code = NRF_ERROR_NOT_SUPPORTED; - } - else - { - spi_xfer(p_instance->p_registers, p_cb, p_xfer_desc); - } - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - ) -} - - -void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance) -{ - spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); - - CODE_FOR_SPIM - ( - nrf_spim_task_trigger(p_instance->p_registers, NRF_SPIM_TASK_STOP); - while (!nrf_spim_event_check(p_instance->p_registers, NRF_SPIM_EVENT_STOPPED)) {} - p_cb->transfer_in_progress = false; - ) - CODE_FOR_SPI - ( - p_cb->abort = true; - ) -} - - -#ifdef SPIM_IN_USE -static void irq_handler_spim(NRF_SPIM_Type * p_spim, spi_control_block_t * p_cb) -{ - -#if NRF_MODULE_ENABLED(SPIM_NRF52_ANOMALY_109_WORKAROUND) - if ((nrf_spim_int_enable_check(p_spim, NRF_SPIM_INT_STARTED_MASK)) && - (nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_STARTED)) ) - { - /* Handle first, zero-length, auxiliary transmission. */ - nrf_spim_event_clear(p_spim, NRF_SPIM_EVENT_STARTED); - nrf_spim_event_clear(p_spim, NRF_SPIM_EVENT_END); - - ASSERT(p_spim->TXD.MAXCNT == 0); - p_spim->TXD.MAXCNT = p_cb->tx_length; - - ASSERT(p_spim->RXD.MAXCNT == 0); - p_spim->RXD.MAXCNT = p_cb->rx_length; - - /* Disable STARTED interrupt, used only in auxiliary transmission. */ - nrf_spim_int_disable(p_spim, NRF_SPIM_INT_STARTED_MASK); - - /* Start the actual, glitch-free transmission. */ - nrf_spim_task_trigger(p_spim, NRF_SPIM_TASK_START); - return; - } -#endif - - if (nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_END)) - { - nrf_spim_event_clear(p_spim, NRF_SPIM_EVENT_END); - ASSERT(p_cb->handler); - NRF_LOG_DEBUG("SPIM: Event: NRF_SPIM_EVENT_END."); - finish_transfer(p_cb); - } -} - -uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance) -{ - NRF_SPIM_Type * p_spim = (NRF_SPIM_Type *)p_instance->p_registers; - return nrf_spim_task_address_get(p_spim, NRF_SPIM_TASK_START); -} - -uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance) -{ - NRF_SPIM_Type * p_spim = (NRF_SPIM_Type *)p_instance->p_registers; - return nrf_spim_event_address_get(p_spim, NRF_SPIM_EVENT_END); -} -#endif // SPIM_IN_USE - -#ifdef SPI_IN_USE -static void irq_handler_spi(NRF_SPI_Type * p_spi, spi_control_block_t * p_cb) -{ - ASSERT(p_cb->handler); - - nrf_spi_event_clear(p_spi, NRF_SPI_EVENT_READY); - NRF_LOG_DEBUG("SPI: Event: NRF_SPI_EVENT_READY."); - - if (!transfer_byte(p_spi, p_cb)) - { - finish_transfer(p_cb); - } -} -#endif // SPI_IN_USE - -#if NRF_MODULE_ENABLED(SPI0) -IRQ_HANDLER(0) -{ - spi_control_block_t * p_cb = &m_cb[SPI0_INSTANCE_INDEX]; - #if (SPI0_WITH_DMA || SPIM_ONLY) - irq_handler_spim(NRF_SPIM0, p_cb); - #else - irq_handler_spi(NRF_SPI0, p_cb); - #endif -} -#endif // NRF_MODULE_ENABLED(SPI0) - -#if NRF_MODULE_ENABLED(SPI1) -IRQ_HANDLER(1) -{ - spi_control_block_t * p_cb = &m_cb[SPI1_INSTANCE_INDEX]; - #if (SPI1_WITH_DMA || SPIM_ONLY) - irq_handler_spim(NRF_SPIM1, p_cb); - #else - irq_handler_spi(NRF_SPI1, p_cb); - #endif -} -#endif // NRF_MODULE_ENABLED(SPI1) - -#if NRF_MODULE_ENABLED(SPI2) -IRQ_HANDLER(2) -{ - spi_control_block_t * p_cb = &m_cb[SPI2_INSTANCE_INDEX]; - #if (SPI2_WITH_DMA || SPIM_ONLY) - irq_handler_spim(NRF_SPIM2, p_cb); - #else - irq_handler_spi(NRF_SPI2, p_cb); - #endif -} -/*lint -restore*/ -#endif // NRF_MODULE_ENABLED(SPI2) -#endif // ENABLED_SPI_COUNT -#endif // NRF_MODULE_ENABLED(SPI) - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_slave/nrf_drv_spis.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_slave/nrf_drv_spis.h deleted file mode 100644 index 069773d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_slave/nrf_drv_spis.h +++ /dev/null @@ -1,286 +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 - * @addtogroup nrf_spis SPIS HAL and driver - * @ingroup nrf_drivers - * @brief SPIS APIs. - * - */ - -#ifndef SPI_SLAVE_H__ -#define SPI_SLAVE_H__ - -#include -#include "nrf.h" -#include "nrf_error.h" -#include "sdk_config.h" -#include "nrf_spis.h" -#include "nrf_gpio.h" -#include "sdk_common.h" -#include "app_util_platform.h" -#include "nrf_peripherals.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef SPIS0_ENABLED -#define SPIS0_INCR SPIS0_ENABLED -#else -#define SPIS0_INCR 0 -#endif - -#ifdef SPIS1_ENABLED -#define SPIS1_INCR SPIS1_ENABLED -#else -#define SPIS1_INCR 0 -#endif - -#ifdef SPIS2_ENABLED -#define SPIS2_INCR SPIS2_ENABLED -#else -#define SPIS2_INCR 0 -#endif - -#define ENABLED_SPIS_COUNT (SPIS0_INCR + SPIS1_INCR + SPIS2_INCR) - -#ifdef NRF52810_XXAA - #define SPIS0_IRQ SPIM0_SPIS0_IRQn - #define SPIS0_IRQ_HANDLER SPIM0_SPIS0_IRQHandler -#else - #define SPIS0_IRQ SPI0_TWI0_IRQn - #define SPIS0_IRQ_HANDLER SPI0_TWI0_IRQHandler - #define SPIS1_IRQ SPI1_TWI1_IRQn - #define SPIS1_IRQ_HANDLER SPI1_TWI1_IRQHandler -#if SPIS_COUNT > 2 - #define SPIS2_IRQ SPIM2_SPIS2_SPI2_IRQn - #define SPIS2_IRQ_HANDLER SPIM2_SPIS2_SPI2_IRQHandler -#endif -#endif // NRF52810_XXAA -/** - * @defgroup nrf_drv_spis SPI slave driver - * @{ - * @ingroup nrf_spis - * @brief Multi-instance SPI slave driver. - */ - -#define NRF_DRV_SPIS_DEFAULT_CSN_PULLUP NRF_GPIO_PIN_NOPULL /**< Default pull-up configuration of the SPI CS. */ -#define NRF_DRV_SPIS_DEFAULT_MISO_DRIVE NRF_GPIO_PIN_S0S1 /**< Default drive configuration of the SPI MISO. */ - -/** -* @brief This value can be provided instead of a pin number for the signals MOSI -* and MISO to specify that the given signal is not used and therefore -* does not need to be connected to a pin. -*/ -#define NRF_DRV_SPIS_PIN_NOT_USED 0xFF - -/** @brief SPIS transaction bit order definitions. */ -typedef enum -{ - NRF_DRV_SPIS_BIT_ORDER_LSB_FIRST = NRF_SPIS_BIT_ORDER_LSB_FIRST, /**< Least significant bit shifted out first. */ - NRF_DRV_SPIS_BIT_ORDER_MSB_FIRST = NRF_SPIS_BIT_ORDER_MSB_FIRST /**< Most significant bit shifted out first. */ -} nrf_drv_spis_endian_t; - -/** @brief SPIS mode definitions for clock polarity and phase. */ -typedef enum -{ - NRF_DRV_SPIS_MODE_0 = NRF_SPIS_MODE_0, /**< (CPOL = 0, CPHA = 0). */ - NRF_DRV_SPIS_MODE_1 = NRF_SPIS_MODE_1, /**< (CPOL = 0, CPHA = 1). */ - NRF_DRV_SPIS_MODE_2 = NRF_SPIS_MODE_2, /**< (CPOL = 1, CPHA = 0). */ - NRF_DRV_SPIS_MODE_3 = NRF_SPIS_MODE_3 /**< (CPOL = 1, CPHA = 1). */ -} nrf_drv_spis_mode_t; - -/** @brief Event callback function event definitions. */ -typedef enum -{ - NRF_DRV_SPIS_BUFFERS_SET_DONE, /**< Memory buffer set event. Memory buffers have been set successfully to the SPI slave device, and SPI transactions can be done. */ - NRF_DRV_SPIS_XFER_DONE, /**< SPI transaction event. SPI transaction has been completed. */ - NRF_DRV_SPIS_EVT_TYPE_MAX /**< Enumeration upper bound. */ -} nrf_drv_spis_event_type_t; - -/** @brief Structure containing the event context from the SPI slave driver. */ -typedef struct -{ - nrf_drv_spis_event_type_t evt_type; //!< Type of event. - uint32_t rx_amount; //!< Number of bytes received in last transaction. This parameter is only valid for @ref NRF_DRV_SPIS_XFER_DONE events. - uint32_t tx_amount; //!< Number of bytes transmitted in last transaction. This parameter is only valid for @ref NRF_DRV_SPIS_XFER_DONE events. -} nrf_drv_spis_event_t; - -/** @brief SPI slave driver instance data structure. */ -typedef struct -{ - NRF_SPIS_Type * p_reg; //!< SPIS instance register. - uint8_t instance_id; //!< SPIS instance ID. - IRQn_Type irq; //!< IRQ of the specific instance. -} nrf_drv_spis_t; - -#define SPIS0_INSTANCE_INDEX 0 -#define SPIS1_INSTANCE_INDEX SPIS0_INSTANCE_INDEX+SPIS0_ENABLED -#define SPIS2_INSTANCE_INDEX SPIS1_INSTANCE_INDEX+SPIS1_ENABLED - -/** @brief Macro for creating an SPI slave driver instance. */ -#define NRF_DRV_SPIS_INSTANCE(id) \ -{ \ - .p_reg = CONCAT_2(NRF_SPIS, id), \ - .irq = CONCAT_3(SPIS, id, _IRQ), \ - .instance_id = CONCAT_3(SPIS, id, _INSTANCE_INDEX), \ -} - -/** @brief SPI slave instance default configuration. */ -#define NRF_DRV_SPIS_DEFAULT_CONFIG \ -{ \ - .sck_pin = NRF_DRV_SPIS_PIN_NOT_USED, \ - .mosi_pin = NRF_DRV_SPIS_PIN_NOT_USED, \ - .miso_pin = NRF_DRV_SPIS_PIN_NOT_USED, \ - .csn_pin = NRF_DRV_SPIS_PIN_NOT_USED, \ - .miso_drive = NRF_DRV_SPIS_DEFAULT_MISO_DRIVE, \ - .csn_pullup = NRF_DRV_SPIS_DEFAULT_CSN_PULLUP, \ - .orc = SPIS_DEFAULT_ORC, \ - .def = SPIS_DEFAULT_DEF, \ - .mode = (nrf_drv_spis_mode_t)SPIS_DEFAULT_MODE, \ - .bit_order = (nrf_drv_spis_endian_t)SPIS_DEFAULT_BIT_ORDER, \ - .irq_priority = SPIS_DEFAULT_CONFIG_IRQ_PRIORITY, \ -} - -/** @brief SPI peripheral device configuration data. */ -typedef struct -{ - uint32_t miso_pin; //!< SPI MISO pin (optional). - /**< Set @ref NRF_DRV_SPIS_PIN_NOT_USED - * if this signal is not needed. */ - uint32_t mosi_pin; //!< SPI MOSI pin (optional). - /**< Set @ref NRF_DRV_SPIS_PIN_NOT_USED - * if this signal is not needed. */ - uint32_t sck_pin; //!< SPI SCK pin. - uint32_t csn_pin; //!< SPI CSN pin. - nrf_drv_spis_mode_t mode; //!< SPI mode. - nrf_drv_spis_endian_t bit_order; //!< SPI transaction bit order. - nrf_gpio_pin_pull_t csn_pullup; //!< CSN pin pull-up configuration. - nrf_gpio_pin_drive_t miso_drive; //!< MISO pin drive configuration. - uint8_t def; //!< Character clocked out in case of an ignored transaction. - uint8_t orc; //!< Character clocked out after an over-read of the transmit buffer. - uint8_t irq_priority; //!< Interrupt priority. -} nrf_drv_spis_config_t; - - -/** @brief SPI slave event callback function type. - * - * @param[in] event SPI slave driver event. - */ -typedef void (*nrf_drv_spis_event_handler_t)(nrf_drv_spis_event_t event); - -/** @brief Function for initializing the SPI slave driver instance. - * - * @note When the nRF52 Anomaly 109 workaround for SPIS is enabled, this function - * initializes the GPIOTE driver as well, and uses one of GPIOTE channels - * to detect falling edges on CSN pin. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_config Pointer to the structure with the initial configuration. - * If NULL, the default configuration will be used. - * @param[in] event_handler Function to be called by the SPI slave driver upon event. - * - * @retval NRF_SUCCESS If the initialization was successful. - * @retval NRF_ERROR_INVALID_PARAM If an invalid parameter is supplied. - * @retval NRF_ERROR_BUSY If some other peripheral with the same - * instance ID is already in use. This is - * possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED - * is set to a value other than zero. - * @retval NRF_ERROR_INTERNAL GPIOTE channel for detecting falling edges - * on CSN pin cannot be initialized. Possible - * only when using nRF52 Anomaly 109 workaround. - */ -ret_code_t nrf_drv_spis_init(nrf_drv_spis_t const * const p_instance, - nrf_drv_spis_config_t const * p_config, - nrf_drv_spis_event_handler_t event_handler); - -/** - * @brief Function for uninitializing the SPI slave driver instance. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_spis_uninit(nrf_drv_spis_t const * const p_instance); - -/** @brief Function for preparing the SPI slave instance for a single SPI transaction. - * - * This function prepares the SPI slave device to be ready for a single SPI transaction. It configures - * the SPI slave device to use the memory supplied with the function call in SPI transactions. - * - * When either the memory buffer configuration or the SPI transaction has been - * completed, the event callback function will be called with the appropriate event - * @ref nrf_drv_spis_event_type_t. Note that the callback function can be called before returning from - * this function, because it is called from the SPI slave interrupt context. - * - * @note This function can be called from the callback function context. - * - * @note Client applications must call this function after every @ref NRF_DRV_SPIS_XFER_DONE event if - * the SPI slave driver should be prepared for a possible new SPI transaction. - * - * @note Peripherals that are using EasyDMA (for example, SPIS) require the transfer buffers - * to be placed in the Data RAM region. Otherwise, this function will fail - * with the error code NRF_ERROR_INVALID_ADDR. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_tx_buffer Pointer to the TX buffer. - * @param[in] p_rx_buffer Pointer to the RX buffer. - * @param[in] tx_buffer_length Length of the TX buffer in bytes. - * @param[in] rx_buffer_length Length of the RX buffer in bytes. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_NULL If the operation failed because a NULL pointer was supplied. - * @retval NRF_ERROR_INVALID_STATE If the operation failed because the SPI slave device is in an incorrect state. - * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the Data - * RAM region. - * @retval NRF_ERROR_INTERNAL If the operation failed because of an internal error. - */ -ret_code_t nrf_drv_spis_buffers_set(nrf_drv_spis_t const * const p_instance, - const uint8_t * p_tx_buffer, - uint8_t tx_buffer_length, - uint8_t * p_rx_buffer, - uint8_t rx_buffer_length); - - -#ifdef __cplusplus -} -#endif - -#endif // SPI_SLAVE_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.c deleted file mode 100644 index 0d1ad30..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.c +++ /dev/null @@ -1,508 +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 "nrf_drv_common.h" -#include "nrf_error.h" -#include "nrf_assert.h" -#include -#include -#include -#include "nrf_drv_swi.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME swi - -#if EGU_ENABLED -#if SWI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL SWI_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR SWI_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR SWI_CONFIG_DEBUG_COLOR -#else //SWI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //SWI_CONFIG_LOG_ENABLED -#endif //EGU_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -STATIC_ASSERT(SWI_COUNT > 0); - -#ifdef SWI_DISABLE0 - #undef SWI_DISABLE0 - #define SWI_DISABLE0 1uL -#else - #if SWI_COUNT > 0 - #define SWI_DISABLE0 0uL - #else - #define SWI_DISABLE0 1uL - #endif -#endif - -#ifdef SWI_DISABLE1 - #undef SWI_DISABLE1 - #define SWI_DISABLE1 1uL -#else - #if SWI_COUNT > 1 - #define SWI_DISABLE1 0uL - #else - #define SWI_DISABLE1 1uL - #endif -#endif - -#ifdef SWI_DISABLE2 - #undef SWI_DISABLE2 - #define SWI_DISABLE2 1uL -#else - #if SWI_COUNT > 2 - #define SWI_DISABLE2 0uL - #else - #define SWI_DISABLE2 1uL - #endif -#endif - -#ifdef SWI_DISABLE3 - #undef SWI_DISABLE3 - #define SWI_DISABLE3 1uL -#else - #if SWI_COUNT > 3 - #define SWI_DISABLE3 0uL - #else - #define SWI_DISABLE3 1uL - #endif -#endif - -#ifdef SWI_DISABLE4 - #undef SWI_DISABLE4 - #define SWI_DISABLE4 1uL -#else - #if SWI_COUNT > 4 - #define SWI_DISABLE4 0uL - #else - #define SWI_DISABLE4 1uL - #endif -#endif - -#ifdef SWI_DISABLE5 - #undef SWI_DISABLE5 - #define SWI_DISABLE5 1uL -#else - #if SWI_COUNT > 5 - #define SWI_DISABLE5 0uL - #else - #define SWI_DISABLE5 1uL - #endif -#endif - -#define SWI_START_NUMBER ( (SWI_DISABLE0) \ - + (SWI_DISABLE0 * SWI_DISABLE1) \ - + (SWI_DISABLE0 * SWI_DISABLE1 * SWI_DISABLE2) \ - + (SWI_DISABLE0 * SWI_DISABLE1 * SWI_DISABLE2 * SWI_DISABLE3) \ - + (SWI_DISABLE0 * SWI_DISABLE1 * SWI_DISABLE2 * SWI_DISABLE3 * SWI_DISABLE4) \ - + (SWI_DISABLE0 * SWI_DISABLE1 * SWI_DISABLE2 * SWI_DISABLE3 * SWI_DISABLE4 \ - * SWI_DISABLE5) ) - -#if (SWI_COUNT <= SWI_START_NUMBER) - #define SWI_ARRAY_SIZE 1 -#else - #define SWI_ARRAY_SIZE (SWI_COUNT - SWI_START_NUMBER) -#endif - -static nrf_drv_state_t m_drv_state = NRF_DRV_STATE_UNINITIALIZED; -static nrf_swi_handler_t m_swi_handlers[SWI_ARRAY_SIZE]; - -#if !EGU_ENABLED - static nrf_swi_flags_t m_swi_flags[SWI_ARRAY_SIZE]; - #define SWI_EGU_MIXED (0) - #define SWI_MAX_FLAGS (16u) -#elif ((SWI_ARRAY_SIZE > EGU_COUNT) && (SWI_COUNT > EGU_COUNT)) - #define SWI_EGU_MIXED (1u) - #define SWI_MAX_FLAGS (16u) - static nrf_swi_flags_t m_swi_flags[SWI_ARRAY_SIZE - EGU_COUNT]; -#else - #define SWI_EGU_MIXED (0) -#endif - -#if NRF_MODULE_ENABLED(EGU) -#define SWI_EGU_CH_DEF(_idx_, _arg_) CONCAT_3(EGU, _idx_, _CH_NUM), -#endif -/**@brief Function for getting max channel number of given SWI. - * - * @param[in] swi SWI number. - * @return number of available channels. - */ -uint32_t swi_channel_number(nrf_swi_t swi) -{ -#if NRF_MODULE_ENABLED(EGU) - static uint8_t const egu_ch_count[] = {MACRO_REPEAT_FOR(EGU_COUNT, SWI_EGU_CH_DEF)}; - - if (swi < EGU_COUNT) - { - return (uint32_t)egu_ch_count[swi]; - } - #if SWI_EGU_MIXED - if (swi < SWI_COUNT) - { - return (uint32_t)SWI_MAX_FLAGS; - } - #endif -#else // only SWI - if (swi < SWI_COUNT) - { - return (uint32_t)SWI_MAX_FLAGS; - } -#endif // NRF_MODULE_ENABLED(EGU) - - return 0; -} - -#if NRF_MODULE_ENABLED(EGU) -/**@brief Get the specific EGU instance. */ -__STATIC_INLINE NRF_EGU_Type * egu_instance_get(nrf_swi_t swi) -{ -#if SWI_EGU_MIXED - if (!(swi < EGU_COUNT)) - { - return NULL; - } -#endif - return (NRF_EGU_Type*) (NRF_EGU0_BASE + - (((uint32_t) swi) * (NRF_EGU1_BASE - NRF_EGU0_BASE))); -} - -/**@brief Software interrupt handler (can be using EGU). */ -static void nrf_drv_swi_process(nrf_swi_t swi, nrf_swi_flags_t flags) -{ - ASSERT(swi < SWI_COUNT); - - ASSERT(m_swi_handlers[swi - SWI_START_NUMBER]); - NRF_EGU_Type * NRF_EGUx = egu_instance_get(swi); - - if (NRF_EGUx != NULL) - { - flags = 0; - for (uint8_t i = 0; i < swi_channel_number(swi); ++i) - { - nrf_egu_event_t egu_event = nrf_egu_event_triggered_get(NRF_EGUx, i); - if (nrf_egu_event_check(NRF_EGUx, egu_event)) - { - flags |= (1u << i); - nrf_egu_event_clear(NRF_EGUx, egu_event); - } - } - } -#if SWI_EGU_MIXED // this code is needed to handle SWI instances without EGU - else - { - m_swi_flags[swi - SWI_START_NUMBER - EGU_COUNT] &= ~flags; - } -#endif - m_swi_handlers[swi - SWI_START_NUMBER](swi, flags); -} - -#else -/**@brief Software interrupt handler (without EGU). */ -static void nrf_drv_swi_process(nrf_swi_t swi, nrf_swi_flags_t flags) -{ - ASSERT(m_swi_handlers[swi - SWI_START_NUMBER]); - m_swi_flags[swi - SWI_START_NUMBER] &= ~flags; - m_swi_handlers[swi - SWI_START_NUMBER](swi, flags); -} -#endif - -#if NRF_MODULE_ENABLED(EGU) - #if SWI_EGU_MIXED - #define SWI_EGU_HANDLER_TEMPLATE(NUM) void SWI##NUM##_EGU##NUM##_IRQHandler(void) \ - { \ - nrf_drv_swi_process(NUM, 0); \ - } - #define SWI_HANDLER_TEMPLATE(NUM) void SWI##NUM##_IRQHandler(void) \ - { \ - nrf_drv_swi_process((NUM), \ - m_swi_flags[(NUM) - SWI_START_NUMBER - EGU_COUNT]);\ - } - #else - #define SWI_HANDLER_TEMPLATE(NUM) void SWI##NUM##_EGU##NUM##_IRQHandler(void) \ - { \ - nrf_drv_swi_process(NUM, 0); \ - } - #endif // SWI_EGU_MIXED -#else - #define SWI_HANDLER_TEMPLATE(NUM) void SWI##NUM##_IRQHandler(void) \ - { \ - nrf_drv_swi_process((NUM), m_swi_flags[(NUM) - SWI_START_NUMBER]); \ - } -#endif // NRF_MODULE_ENABLED(EGU) - - -#if SWI_EGU_MIXED == 0 - #if SWI_DISABLE0 == 0 - SWI_HANDLER_TEMPLATE(0) - #endif - - #if SWI_DISABLE1 == 0 - SWI_HANDLER_TEMPLATE(1) - #endif - - #if SWI_DISABLE2 == 0 - SWI_HANDLER_TEMPLATE(2) - #endif - - #if SWI_DISABLE3 == 0 - SWI_HANDLER_TEMPLATE(3) - #endif - - #if SWI_DISABLE4 == 0 - SWI_HANDLER_TEMPLATE(4) - #endif - - #if SWI_DISABLE5 == 0 - SWI_HANDLER_TEMPLATE(5) - #endif -#else // SWI_EGU_MIXED == 1: SWI and SWI_EGU handlers - #if SWI_DISABLE0 == 0 - SWI_EGU_HANDLER_TEMPLATE(0) - #endif - - #if SWI_DISABLE1 == 0 - SWI_EGU_HANDLER_TEMPLATE(1) // NRF52810_XXAA has 2xSWI-EGU and 4xSWI - #endif - - #if SWI_DISABLE2 == 0 - SWI_HANDLER_TEMPLATE(2) - #endif - - #if SWI_DISABLE3 == 0 - SWI_HANDLER_TEMPLATE(3) - #endif - - #if SWI_DISABLE4 == 0 - SWI_HANDLER_TEMPLATE(4) - #endif - - #if SWI_DISABLE5 == 0 - SWI_HANDLER_TEMPLATE(5) - #endif -#endif // SWI_EGU_MIXED == 0 - -#define AVAILABLE_SWI (0x3FuL & ~( \ - (SWI_DISABLE0 << 0) | (SWI_DISABLE1 << 1) | (SWI_DISABLE2 << 2) \ - | (SWI_DISABLE3 << 3) | (SWI_DISABLE4 << 4) | (SWI_DISABLE5 << 5) \ - )) - -#if (AVAILABLE_SWI == 0) - #warning No available SWIs. -#endif - -/**@brief Function for converting SWI number to system interrupt number. - * - * @param[in] swi SWI number. - * - * @retval IRQ number. - */ -__STATIC_INLINE IRQn_Type nrf_drv_swi_irq_of(nrf_swi_t swi) -{ - return (IRQn_Type)((uint32_t)SWI0_IRQn + (uint32_t)swi); -} - - -/**@brief Function for checking if given SWI is allocated. - * - * @param[in] swi SWI number. - */ -__STATIC_INLINE bool swi_is_allocated(nrf_swi_t swi) -{ - ASSERT(swi < SWI_COUNT); -#if SWI_START_NUMBER > 0 - if (swi < SWI_START_NUMBER) - { - return false; - } -#endif - /*lint -e(661) out of range case handled by assert above*/ - return m_swi_handlers[swi - SWI_START_NUMBER]; -} - -ret_code_t nrf_drv_swi_init(void) -{ - ret_code_t err_code; - - if (m_drv_state == NRF_DRV_STATE_UNINITIALIZED) - { - m_drv_state = NRF_DRV_STATE_INITIALIZED; - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - err_code = NRF_ERROR_MODULE_ALREADY_INITIALIZED; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_swi_uninit(void) -{ - ASSERT(m_drv_state != NRF_DRV_STATE_UNINITIALIZED) - - for (uint32_t i = SWI_START_NUMBER; i < SWI_COUNT; ++i) - { - m_swi_handlers[i - SWI_START_NUMBER] = NULL; - nrf_drv_common_irq_disable(nrf_drv_swi_irq_of((nrf_swi_t) i)); -#if NRF_MODULE_ENABLED(EGU) - NRF_EGU_Type * NRF_EGUx = egu_instance_get(i); - if (NRF_EGUx != NULL) - { - nrf_egu_int_disable(NRF_EGUx, NRF_EGU_INT_ALL); - } -#endif - } - m_drv_state = NRF_DRV_STATE_UNINITIALIZED; - return; -} - - -void nrf_drv_swi_free(nrf_swi_t * p_swi) -{ - ASSERT(swi_is_allocated(*p_swi)); - nrf_drv_common_irq_disable(nrf_drv_swi_irq_of(*p_swi)); - m_swi_handlers[(*p_swi) - SWI_START_NUMBER] = NULL; - *p_swi = NRF_SWI_UNALLOCATED; -} - - -ret_code_t nrf_drv_swi_alloc(nrf_swi_t * p_swi, nrf_swi_handler_t event_handler, uint32_t priority) -{ -#if !NRF_MODULE_ENABLED(EGU) - ASSERT(event_handler); -#endif - uint32_t err_code = NRF_ERROR_NO_MEM; - - for (uint32_t i = SWI_START_NUMBER; i < SWI_COUNT; i++) - { - CRITICAL_REGION_ENTER(); - if ((!swi_is_allocated(i)) && (AVAILABLE_SWI & (1 << i))) - { - m_swi_handlers[i - SWI_START_NUMBER] = event_handler; - *p_swi = (nrf_swi_t) i; - nrf_drv_common_irq_enable(nrf_drv_swi_irq_of(*p_swi), priority); -#if NRF_MODULE_ENABLED(EGU) - if ((event_handler != NULL) && (i < EGU_COUNT)) - { - NRF_EGU_Type * NRF_EGUx = egu_instance_get(i); - if (NRF_EGUx != NULL) - { - nrf_egu_int_enable(NRF_EGUx, NRF_EGU_INT_ALL); - } - } - #if SWI_EGU_MIXED - if (i >= EGU_COUNT) - { - ASSERT(event_handler); - } - #endif -#endif // NRF_MODULE_ENABLED(EGU) - err_code = NRF_SUCCESS; - } - CRITICAL_REGION_EXIT(); - if (err_code == NRF_SUCCESS) - { - NRF_LOG_INFO("SWI channel allocated: %d.", (*p_swi)); - break; - } - } - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_swi_trigger(nrf_swi_t swi, uint8_t flag_number) -{ - ASSERT(swi_is_allocated((uint32_t) swi)); - ASSERT(flag_number < swi_channel_number(swi)); -#if NRF_MODULE_ENABLED(EGU) - NRF_EGU_Type * NRF_EGUx = egu_instance_get(swi); - if (NRF_EGUx != NULL) - { - nrf_egu_task_trigger(NRF_EGUx, nrf_egu_task_trigger_get(NRF_EGUx, flag_number)); - } -#if SWI_EGU_MIXED - else - { - if (swi < SWI_COUNT) - { - /* for swi < EGU_COUNT above code will be executed */ - m_swi_flags[swi - SWI_START_NUMBER - EGU_COUNT] |= (1 << flag_number); - NVIC_SetPendingIRQ(nrf_drv_swi_irq_of(swi)); - } - } -#endif // SWI_EGU_MIXED -#else - m_swi_flags[swi - SWI_START_NUMBER] |= (1 << flag_number); - NVIC_SetPendingIRQ(nrf_drv_swi_irq_of(swi)); -#endif // NRF_MODULE_ENABLED(EGU) -} - - -#if NRF_MODULE_ENABLED(EGU) - -uint32_t nrf_drv_swi_task_trigger_address_get(nrf_swi_t swi, uint8_t channel) -{ - NRF_EGU_Type * NRF_EGUx = egu_instance_get(swi); - if (NRF_EGUx != NULL) - { - return (uint32_t)nrf_egu_task_trigger_address_get(NRF_EGUx, channel); - } - else - { - return 0; - } -} - -uint32_t nrf_drv_swi_event_triggered_address_get(nrf_swi_t swi, uint8_t channel) -{ - NRF_EGU_Type * NRF_EGUx = egu_instance_get(swi); - if (NRF_EGUx != NULL) - { - return (uint32_t)nrf_egu_event_triggered_address_get(NRF_EGUx, channel); - } - else - { - return 0; - } -} - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.h deleted file mode 100644 index a3a4a0e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/swi/nrf_drv_swi.h +++ /dev/null @@ -1,212 +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 nrf_drv_swi SWI driver - * @{ - * @ingroup nrf_drivers - * - * @brief Driver for software interrupts (SWI). - * @details The SWI driver allows the user to allocate SWIs and pass extra flags to interrupt handler functions. - */ - -#ifndef NRF_DRV_SWI_H__ -#define NRF_DRV_SWI_H__ - -#include -#include -#include "sdk_config.h" -#include "app_util.h" -#include "app_util_platform.h" -#include "sdk_common.h" -#include "sdk_errors.h" -#include "nrf_peripherals.h" - -#ifndef EGU_ENABLED - #define EGU_ENABLED 0 -#endif - -#if NRF_MODULE_ENABLED(EGU) -#include "nrf_egu.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef uint8_t nrf_swi_t; ///< @brief SWI channel (unsigned integer). - -/** @brief SWI user flags (unsigned integer). - * - * User flags are set during the SWI trigger and passed to the callback function as an argument. - */ -typedef uint16_t nrf_swi_flags_t; - -/** @brief Unallocated channel value. */ -#define NRF_SWI_UNALLOCATED ((nrf_swi_t) 0xFFFFFFFFuL) - -/** @brief SWI handler function. - * - * Takes two arguments: SWI number (nrf_swi_t) and flags (nrf_swi_flags_t). - */ -typedef void (* nrf_swi_handler_t)(nrf_swi_t, nrf_swi_flags_t); - -#ifdef SOFTDEVICE_PRESENT - #if SWI_COUNT > 2 - #undef SWI_COUNT - #ifdef NRF52810_XXAA - #define SWI_COUNT 3 // SoftDevice for NRF52810_XXAA utilizes 3 SWIs - #else - #define SWI_COUNT 2 // usually, SoftDevice utilizes 4 SWIs - #endif - #endif -#else - #ifdef SVCALL_AS_NORMAL_FUNCTION - // Serialization is enabled. - #if SWI_COUNT > 2 - #undef SWI_COUNT - #ifdef NRF52810_XXAA - #define SWI_COUNT 3 // SoftDevice for NRF52810_XXAA will utilize 3 SWIs - #else - #define SWI_COUNT 2 // usually, SoftDevice utilizes 4 SWIs - #endif - #endif - #endif -#endif - -#if NRF_MODULE_ENABLED(PWM_NRF52_ANOMALY_109_WORKAROUND) - #if (PWM_NRF52_ANOMALY_109_EGU_INSTANCE == 0) - #define SWI_DISABLE0 - #elif (PWM_NRF52_ANOMALY_109_EGU_INSTANCE == 1) - #define SWI_DISABLE1 - #elif (PWM_NRF52_ANOMALY_109_EGU_INSTANCE == 2) - #define SWI_DISABLE2 - #elif (PWM_NRF52_ANOMALY_109_EGU_INSTANCE == 3) - #define SWI_DISABLE3 - #elif (PWM_NRF52_ANOMALY_109_EGU_INSTANCE == 4) - #define SWI_DISABLE4 - #elif (PWM_NRF52_ANOMALY_109_EGU_INSTANCE == 5) - #define SWI_DISABLE5 - #endif -#endif - -/**@brief Default SWI priority. */ -#define SWI_DEFAULT_PRIORITY APP_IRQ_PRIORITY_LOWEST - - -/**@brief Function for initializing the SWI module. - * - * @retval NRF_SUCCESS If the module was successfully initialized. - * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized. - */ -ret_code_t nrf_drv_swi_init(void); - - -/**@brief Function for uninitializing the SWI module. - * - * This function also disables all SWIs. - */ -void nrf_drv_swi_uninit(void); - - -/**@brief Function for allocating a first unused SWI instance and setting a handler. - * @details The event handler function returns void and takes one uint32_t argument (SWI number). - * - * @param[out] p_swi Pointer to the SWI that has been allocated. - * @param[in] event_handler Event handler function. - * If NULL, no interrupt will be enabled (can be NULL only if the EGU - driver is enabled and available. For some microcontrollers, it is - possible that number of EGUs and SWIs differ). - * For classic SWI, must be a valid handler pointer. - * @param[in] priority Interrupt priority. - * - * @retval NRF_SUCCESS If the SWI was successfully allocated. - * @retval NRF_ERROR_NO_MEM If there is no available SWI to be used. - */ -ret_code_t nrf_drv_swi_alloc(nrf_swi_t * p_swi, nrf_swi_handler_t event_handler, uint32_t priority); - - -/**@brief Function for freeing a previously allocated SWI. - * - * @param[in,out] p_swi SWI to free. The value is changed to NRF_SWI_UNALLOCATED on success. - */ -void nrf_drv_swi_free(nrf_swi_t * p_swi); - - -/**@brief Function for triggering the SWI. - * - * @param[in] swi SWI to trigger. - * @param[in] flag_number Number of user flag to trigger. - */ -void nrf_drv_swi_trigger(nrf_swi_t swi, uint8_t flag_number); - - -#if (EGU_ENABLED > 0) || defined(__SDK_DOXYGEN__) - - -/**@brief Function for returning the EGU trigger task address. - * - * @param[in] swi SWI instance. - * @param[in] channel Number of the EGU channel. - * - * @returns EGU trigger task address. - */ -uint32_t nrf_drv_swi_task_trigger_address_get(nrf_swi_t swi, uint8_t channel); - -/**@brief Function for returning the EGU triggered event address. - * - * @param[in] swi SWI instance. - * @param[in] channel Number of the EGU channel. - * - * @returns EGU triggered event address. - */ -uint32_t nrf_drv_swi_event_triggered_address_get(nrf_swi_t swi, uint8_t channel); - -#endif // NRF_MODULE_ENABLED(EGU) - - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_SWI_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.c deleted file mode 100644 index 5aa048b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.c +++ /dev/null @@ -1,339 +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(TIMER) -#define ENABLED_TIMER_COUNT (TIMER0_ENABLED+TIMER1_ENABLED+TIMER2_ENABLED+TIMER3_ENABLED+TIMER4_ENABLED) -#if ENABLED_TIMER_COUNT -#include "nrf_drv_timer.h" -#include "nrf_drv_common.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME timer - -#if TIMER_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL TIMER_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR TIMER_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR TIMER_CONFIG_DEBUG_COLOR -#else //TIMER_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //TIMER_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -/**@brief Timer control block. */ -typedef struct -{ - nrf_timer_event_handler_t handler; - void * context; - nrf_drv_state_t state; -} timer_control_block_t; - -static timer_control_block_t m_cb[ENABLED_TIMER_COUNT]; - -ret_code_t nrf_drv_timer_init(nrf_drv_timer_t const * const p_instance, - nrf_drv_timer_config_t const * p_config, - nrf_timer_event_handler_t timer_event_handler) -{ - timer_control_block_t * p_cb = &m_cb[p_instance->instance_id]; - ASSERT(((p_instance->p_reg == NRF_TIMER0) && TIMER0_ENABLED) || (p_instance->p_reg != NRF_TIMER0)); - ASSERT(((p_instance->p_reg == NRF_TIMER1) && TIMER1_ENABLED) || (p_instance->p_reg != NRF_TIMER1)); - ASSERT(((p_instance->p_reg == NRF_TIMER2) && TIMER2_ENABLED) || (p_instance->p_reg != NRF_TIMER2)); -#if defined (NRF_TIMER3) - ASSERT(((p_instance->p_reg == NRF_TIMER3) && TIMER3_ENABLED) || (p_instance->p_reg != NRF_TIMER3)); -#endif -#if defined (NRF_TIMER4) - ASSERT(((p_instance->p_reg == NRF_TIMER4) && TIMER4_ENABLED) || (p_instance->p_reg != NRF_TIMER4)); -#endif -#ifdef SOFTDEVICE_PRESENT - ASSERT(p_instance->p_reg != NRF_TIMER0); -#endif - ASSERT(p_config); - - ret_code_t err_code; - - if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - if (timer_event_handler == NULL) - { - err_code = NRF_ERROR_INVALID_PARAM; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - /* Warning 685: Relational operator '<=' always evaluates to 'true'" - * Warning in NRF_TIMER_IS_BIT_WIDTH_VALID macro. Macro validate timers resolution. - * Not necessary in nRF52 based systems. Obligatory in nRF51 based systems. - */ - - /*lint -save -e685 */ - - ASSERT(NRF_TIMER_IS_BIT_WIDTH_VALID(p_instance->p_reg, p_config->bit_width)); - - //lint -restore - - p_cb->handler = timer_event_handler; - p_cb->context = p_config->p_context; - - uint8_t i; - for (i = 0; i < p_instance->cc_channel_count; ++i) - { - nrf_timer_event_clear(p_instance->p_reg, - nrf_timer_compare_event_get(i)); - } - - nrf_drv_common_irq_enable(nrf_drv_get_IRQn(p_instance->p_reg), - p_config->interrupt_priority); - - nrf_timer_mode_set(p_instance->p_reg, p_config->mode); - nrf_timer_bit_width_set(p_instance->p_reg, p_config->bit_width); - nrf_timer_frequency_set(p_instance->p_reg, p_config->frequency); - - p_cb->state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -void nrf_drv_timer_uninit(nrf_drv_timer_t const * const p_instance) -{ - nrf_drv_common_irq_disable(nrf_drv_get_IRQn(p_instance->p_reg)); - - #define DISABLE_ALL UINT32_MAX - nrf_timer_shorts_disable(p_instance->p_reg, DISABLE_ALL); - nrf_timer_int_disable(p_instance->p_reg, DISABLE_ALL); - #undef DISABLE_ALL - - if (m_cb[p_instance->instance_id].state == NRF_DRV_STATE_POWERED_ON) - { - nrf_drv_timer_disable(p_instance); - } - - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_UNINITIALIZED; - NRF_LOG_INFO("Uninitialized instance: %d.", p_instance->instance_id); -} - -void nrf_drv_timer_enable(nrf_drv_timer_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state == NRF_DRV_STATE_INITIALIZED); - nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_START); - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_POWERED_ON; - NRF_LOG_INFO("Enabled instance: %d.", p_instance->instance_id); -} - -void nrf_drv_timer_disable(nrf_drv_timer_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state == NRF_DRV_STATE_POWERED_ON); - nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_SHUTDOWN); - m_cb[p_instance->instance_id].state = NRF_DRV_STATE_INITIALIZED; - NRF_LOG_INFO("Disabled instance: %d.", p_instance->instance_id); -} - -void nrf_drv_timer_resume(nrf_drv_timer_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state == NRF_DRV_STATE_POWERED_ON); - nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_START); - NRF_LOG_INFO("Resumed instance: %d.", p_instance->instance_id); -} - -void nrf_drv_timer_pause(nrf_drv_timer_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state == NRF_DRV_STATE_POWERED_ON); - nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_STOP); - NRF_LOG_INFO("Paused instance: %d.", p_instance->instance_id); -} - -void nrf_drv_timer_clear(nrf_drv_timer_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_CLEAR); -} - -void nrf_drv_timer_increment(nrf_drv_timer_t const * const p_instance) -{ - ASSERT(m_cb[p_instance->instance_id].state == NRF_DRV_STATE_POWERED_ON); - ASSERT(nrf_timer_mode_get(p_instance->p_reg) != NRF_TIMER_MODE_TIMER); - - nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_COUNT); -} - -uint32_t nrf_drv_timer_capture(nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(cc_channel < p_instance->cc_channel_count); - - nrf_timer_task_trigger(p_instance->p_reg, - nrf_timer_capture_task_get(cc_channel)); - return nrf_timer_cc_read(p_instance->p_reg, cc_channel); -} - -void nrf_drv_timer_compare(nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel, - uint32_t cc_value, - bool enable_int) -{ - nrf_timer_int_mask_t timer_int = nrf_timer_compare_int_get(cc_channel); - - if (enable_int) - { - nrf_timer_int_enable(p_instance->p_reg, timer_int); - } - else - { - nrf_timer_int_disable(p_instance->p_reg, timer_int); - } - - nrf_timer_cc_write(p_instance->p_reg, cc_channel, cc_value); - NRF_LOG_INFO("Timer id: %d, capture value set: %d, channel: %d.", p_instance->instance_id, cc_value, cc_channel); -} - -void nrf_drv_timer_extended_compare(nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel, - uint32_t cc_value, - nrf_timer_short_mask_t timer_short_mask, - bool enable_int) -{ - nrf_timer_shorts_disable(p_instance->p_reg, - (TIMER_SHORTS_COMPARE0_STOP_Msk << cc_channel) | - (TIMER_SHORTS_COMPARE0_CLEAR_Msk << cc_channel)); - - nrf_timer_shorts_enable(p_instance->p_reg, timer_short_mask); - - (void)nrf_drv_timer_compare(p_instance, - cc_channel, - cc_value, - enable_int); - NRF_LOG_INFO("Timer id: %d, capture value set: %d, channel: %d.", p_instance->instance_id, cc_value, cc_channel); -} - -void nrf_drv_timer_compare_int_enable(nrf_drv_timer_t const * const p_instance, - uint32_t channel) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(channel < p_instance->cc_channel_count); - - nrf_timer_event_clear(p_instance->p_reg, - nrf_timer_compare_event_get(channel)); - nrf_timer_int_enable(p_instance->p_reg, - nrf_timer_compare_int_get(channel)); -} - -void nrf_drv_timer_compare_int_disable(nrf_drv_timer_t const * const p_instance, - uint32_t channel) -{ - ASSERT(m_cb[p_instance->instance_id].state != NRF_DRV_STATE_UNINITIALIZED); - ASSERT(channel < p_instance->cc_channel_count); - - nrf_timer_int_disable(p_instance->p_reg, - nrf_timer_compare_int_get(channel)); -} - -static void irq_handler(NRF_TIMER_Type * p_reg, - timer_control_block_t * p_cb, - uint8_t channel_count) -{ - uint8_t i; - for (i = 0; i < channel_count; ++i) - { - nrf_timer_event_t event = nrf_timer_compare_event_get(i); - nrf_timer_int_mask_t int_mask = nrf_timer_compare_int_get(i); - - if (nrf_timer_event_check(p_reg, event) && - nrf_timer_int_enable_check(p_reg, int_mask)) - { - nrf_timer_event_clear(p_reg, event); - NRF_LOG_DEBUG("Compare event, channel: %d.", i); - p_cb->handler(event, p_cb->context); - } - } -} - -#if NRF_MODULE_ENABLED(TIMER0) -void TIMER0_IRQHandler(void) -{ - irq_handler(NRF_TIMER0, &m_cb[TIMER0_INSTANCE_INDEX], - NRF_TIMER_CC_CHANNEL_COUNT(0)); -} -#endif - -#if NRF_MODULE_ENABLED(TIMER1) -void TIMER1_IRQHandler(void) -{ - irq_handler(NRF_TIMER1, &m_cb[TIMER1_INSTANCE_INDEX], - NRF_TIMER_CC_CHANNEL_COUNT(1)); -} -#endif - -#if NRF_MODULE_ENABLED(TIMER2) -void TIMER2_IRQHandler(void) -{ - irq_handler(NRF_TIMER2, &m_cb[TIMER2_INSTANCE_INDEX], - NRF_TIMER_CC_CHANNEL_COUNT(2)); -} -#endif - -#if defined (NRF_TIMER3) -#if NRF_MODULE_ENABLED(TIMER3) -void TIMER3_IRQHandler(void) -{ - irq_handler(NRF_TIMER3, &m_cb[TIMER3_INSTANCE_INDEX], - NRF_TIMER_CC_CHANNEL_COUNT(3)); -} -#endif -#endif - -#if defined (NRF_TIMER4) -#if NRF_MODULE_ENABLED(TIMER4) -void TIMER4_IRQHandler(void) -{ - irq_handler(NRF_TIMER4, &m_cb[TIMER4_INSTANCE_INDEX], - NRF_TIMER_CC_CHANNEL_COUNT(4)); -} -#endif -#endif - -#endif // ENABLED_TIMER_COUNT -#endif // NRF_MODULE_ENABLED(TIMER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.h deleted file mode 100644 index 8d8cba0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/timer/nrf_drv_timer.h +++ /dev/null @@ -1,410 +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 - * @addtogroup nrf_timer Timer HAL and driver - * @ingroup nrf_drivers - * @brief Timer APIs. - * @details The timer HAL provides basic APIs for accessing the registers - * of the timer. The timer driver provides APIs on a higher level. - * - * @defgroup nrf_drv_timer Timer driver - * @{ - * @ingroup nrf_timer - * @brief Multi-instance timer driver. - */ - -#ifndef NRF_DRV_TIMER_H__ -#define NRF_DRV_TIMER_H__ - -#include "nordic_common.h" -#include "sdk_config.h" -#include "nrf_timer.h" -#include "sdk_errors.h" -#include "nrf_assert.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Timer driver instance data structure. - */ -typedef struct -{ - NRF_TIMER_Type * p_reg; ///< Pointer to the structure with TIMER peripheral instance registers. - uint8_t instance_id; ///< Driver instance index. - uint8_t cc_channel_count; ///< Number of capture/compare channels. -} nrf_drv_timer_t; - -#define ENABLED_TIMER_COUNT (TIMER0_ENABLED+TIMER1_ENABLED+TIMER2_ENABLED+TIMER3_ENABLED+TIMER4_ENABLED) - -#define TIMER0_INSTANCE_INDEX 0 -#define TIMER1_INSTANCE_INDEX TIMER0_INSTANCE_INDEX+TIMER0_ENABLED -#define TIMER2_INSTANCE_INDEX TIMER1_INSTANCE_INDEX+TIMER1_ENABLED -#define TIMER3_INSTANCE_INDEX TIMER2_INSTANCE_INDEX+TIMER2_ENABLED -#define TIMER4_INSTANCE_INDEX TIMER3_INSTANCE_INDEX+TIMER3_ENABLED - -/** - * @brief Macro for creating a timer driver instance. - */ -#define NRF_DRV_TIMER_INSTANCE(id) \ -{ \ - .p_reg = CONCAT_2(NRF_TIMER, id), \ - .instance_id = CONCAT_3(TIMER, id, _INSTANCE_INDEX), \ - .cc_channel_count = NRF_TIMER_CC_CHANNEL_COUNT(id), \ -} - -/** - * @brief Timer driver instance configuration structure. - */ -typedef struct -{ - nrf_timer_frequency_t frequency; ///< Frequency. - nrf_timer_mode_t mode; ///< Mode of operation. - nrf_timer_bit_width_t bit_width; ///< Bit width. - uint8_t interrupt_priority; ///< Interrupt priority. - void * p_context; ///< Context passed to interrupt handler. -} nrf_drv_timer_config_t; - -/** - * @brief Timer driver instance default configuration. - */ -#define NRF_DRV_TIMER_DEFAULT_CONFIG \ -{ \ - .frequency = (nrf_timer_frequency_t)TIMER_DEFAULT_CONFIG_FREQUENCY,\ - .mode = (nrf_timer_mode_t)TIMER_DEFAULT_CONFIG_MODE, \ - .bit_width = (nrf_timer_bit_width_t)TIMER_DEFAULT_CONFIG_BIT_WIDTH,\ - .interrupt_priority = TIMER_DEFAULT_CONFIG_IRQ_PRIORITY, \ - .p_context = NULL \ -} - -/** - * @brief Timer driver event handler type. - * - * @param[in] event_type Timer event. - * @param[in] p_context General purpose parameter set during initialization of - * the timer. This parameter can be used to pass - * additional information to the handler function, for - * example, the timer ID. - */ -typedef void (* nrf_timer_event_handler_t)(nrf_timer_event_t event_type, - void * p_context); - -/** - * @brief Function for initializing the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_config Initial configuration. Must not be NULL. - * @param[in] timer_event_handler Event handler provided by the user. - * Must not be NULL. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the instance is already initialized. - * @retval NRF_ERROR_INVALID_PARAM If no handler was provided. - */ -ret_code_t nrf_drv_timer_init(nrf_drv_timer_t const * const p_instance, - nrf_drv_timer_config_t const * p_config, - nrf_timer_event_handler_t timer_event_handler); - -/** - * @brief Function for uninitializing the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_uninit(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for turning on the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_enable(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for turning off the timer. - * - * Note that the timer will allow to enter the lowest possible SYSTEM_ON state - * only after this function is called. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_disable(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for pausing the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_pause(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for resuming the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_resume(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for clearing the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_clear(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for incrementing the timer. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_timer_increment(nrf_drv_timer_t const * const p_instance); - -/** - * @brief Function for returning the address of a specific timer task. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] timer_task Timer task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_task_address_get( - nrf_drv_timer_t const * const p_instance, - nrf_timer_task_t timer_task); - -/** - * @brief Function for returning the address of a specific timer capture task. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] channel Capture channel number. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_capture_task_address_get( - nrf_drv_timer_t const * const p_instance, - uint32_t channel); - -/** - * @brief Function for returning the address of a specific timer event. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] timer_event Timer event. - * - * @return Event address. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_event_address_get( - nrf_drv_timer_t const * const p_instance, - nrf_timer_event_t timer_event); - -/** - * @brief Function for returning the address of a specific timer compare event. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] channel Compare channel number. - * - * @return Event address. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_compare_event_address_get( - nrf_drv_timer_t const * const p_instance, - uint32_t channel); - -/** - * @brief Function for capturing the timer value. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] cc_channel Capture channel number. - * - * @return Captured value. - */ -uint32_t nrf_drv_timer_capture(nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel); - -/** - * @brief Function for returning the capture value from a specific channel. - * - * Use this function to read channel values when PPI is used for capturing. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] cc_channel Capture channel number. - * - * @return Captured value. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_capture_get( - nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel); - -/** - * @brief Function for setting the timer channel in compare mode. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] cc_channel Compare channel number. - * @param[in] cc_value Compare value. - * @param[in] enable_int Enable or disable the interrupt for the compare channel. - */ -void nrf_drv_timer_compare(nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel, - uint32_t cc_value, - bool enable_int); - -/** - * @brief Function for setting the timer channel in extended compare mode. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] cc_channel Compare channel number. - * @param[in] cc_value Compare value. - * @param[in] timer_short_mask Shortcut between the compare event on the channel - * and the timer task (STOP or CLEAR). - * @param[in] enable_int Enable or disable the interrupt for the compare - * channel. - */ -void nrf_drv_timer_extended_compare(nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel, - uint32_t cc_value, - nrf_timer_short_mask_t timer_short_mask, - bool enable_int); - -/** - * @brief Function for converting time in microseconds to timer ticks. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] time_us Time in microseconds. - * - * @return Number of ticks. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_us_to_ticks( - nrf_drv_timer_t const * const p_instance, - uint32_t time_us); - -/** - * @brief Function for converting time in milliseconds to timer ticks. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] time_ms Time in milliseconds. - * - * @return Number of ticks. - */ -__STATIC_INLINE uint32_t nrf_drv_timer_ms_to_ticks( - nrf_drv_timer_t const * const p_instance, - uint32_t time_ms); - -/** - * @brief Function for enabling timer compare interrupt. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] channel Compare channel. - */ -void nrf_drv_timer_compare_int_enable(nrf_drv_timer_t const * const p_instance, - uint32_t channel); - -/** - * @brief Function for disabling timer compare interrupt. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] channel Compare channel. - */ -void nrf_drv_timer_compare_int_disable(nrf_drv_timer_t const * const p_instance, - uint32_t channel); - - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE uint32_t nrf_drv_timer_task_address_get( - nrf_drv_timer_t const * const p_instance, - nrf_timer_task_t timer_task) -{ - return (uint32_t)nrf_timer_task_address_get(p_instance->p_reg, timer_task); -} - -__STATIC_INLINE uint32_t nrf_drv_timer_capture_task_address_get( - nrf_drv_timer_t const * const p_instance, - uint32_t channel) -{ - ASSERT(channel < p_instance->cc_channel_count); - return (uint32_t)nrf_timer_task_address_get(p_instance->p_reg, - nrf_timer_capture_task_get(channel)); -} - -__STATIC_INLINE uint32_t nrf_drv_timer_event_address_get( - nrf_drv_timer_t const * const p_instance, - nrf_timer_event_t timer_event) -{ - return (uint32_t)nrf_timer_event_address_get(p_instance->p_reg, timer_event); -} - -__STATIC_INLINE uint32_t nrf_drv_timer_compare_event_address_get( - nrf_drv_timer_t const * const p_instance, - uint32_t channel) -{ - ASSERT(channel < p_instance->cc_channel_count); - return (uint32_t)nrf_timer_event_address_get(p_instance->p_reg, - nrf_timer_compare_event_get(channel)); -} - -__STATIC_INLINE uint32_t nrf_drv_timer_capture_get( - nrf_drv_timer_t const * const p_instance, - nrf_timer_cc_channel_t cc_channel) -{ - return nrf_timer_cc_read(p_instance->p_reg, cc_channel); -} - -__STATIC_INLINE uint32_t nrf_drv_timer_us_to_ticks( - nrf_drv_timer_t const * const p_instance, - uint32_t timer_us) -{ - return nrf_timer_us_to_ticks(timer_us, - nrf_timer_frequency_get(p_instance->p_reg)); -} - -__STATIC_INLINE uint32_t nrf_drv_timer_ms_to_ticks( - nrf_drv_timer_t const * const p_instance, - uint32_t timer_ms) -{ - return nrf_timer_ms_to_ticks(timer_ms, - nrf_timer_frequency_get(p_instance->p_reg)); -} - -#endif // SUPPRESS_INLINE_IMPLEMENTATION - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_TIMER_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.c deleted file mode 100644 index c321de8..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.c +++ /dev/null @@ -1,1267 +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(TWI) -#include "nrf_drv_twi.h" -#if ENABLED_TWI_COUNT -#include "nrf_drv_common.h" -#include "nrf_gpio.h" -#include "nrf_assert.h" -#include "app_util_platform.h" -#include "nrf_delay.h" - -#include - -#define NRF_LOG_MODULE_NAME twi - -/*lint -save -e491*/ - -#if TWI_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL TWI_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR TWI_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR TWI_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_DRV_TWI_EVT_DONE ? "EVT_DONE" : \ - (event == NRF_DRV_TWI_EVT_ADDRESS_NACK ? "EVT_ADDRESS_NACK" : \ - (event == NRF_DRV_TWI_EVT_DATA_NACK ? "EVT_DATA_NACK" : "UNKNOWN ERROR"))) -#define EVT_TO_STR_TWI(event) (event == NRF_TWI_EVENT_STOPPED ? "NRF_TWI_EVENT_STOPPED" : \ - (event == NRF_TWI_EVENT_RXDREADY ? "NRF_TWI_EVENT_RXDREADY" : \ - (event == NRF_TWI_EVENT_TXDSENT ? "NRF_TWI_EVENT_TXDSENT" : \ - (event == NRF_TWI_EVENT_ERROR ? "NRF_TWI_EVENT_ERROR" : \ - (event == NRF_TWI_EVENT_BB ? "NRF_TWI_EVENT_BB" : \ - (event == NRF_TWI_EVENT_SUSPENDED ? "NRF_TWI_EVENT_SUSPENDED" : "UNKNOWN ERROR")))))) -#define EVT_TO_STR_TWIM(event) (event == NRF_TWIM_EVENT_STOPPED ? "NRF_TWIM_EVENT_STOPPED" : \ - (event == NRF_TWIM_EVENT_ERROR ? "NRF_TWIM_EVENT_ERROR" : \ - (event == NRF_TWIM_EVENT_SUSPENDED ? "NRF_TWIM_EVENT_SUSPENDED" : \ - (event == NRF_TWIM_EVENT_RXSTARTED ? "NRF_TWIM_EVENT_RXSTARTED" : \ - (event == NRF_TWIM_EVENT_TXSTARTED ? "NRF_TWIM_EVENT_TXSTARTED" : \ - (event == NRF_TWIM_EVENT_LASTRX ? "NRF_TWIM_EVENT_LASTRX" : \ - (event == NRF_TWIM_EVENT_LASTTX ? "NRF_TWIM_EVENT_LASTTX" : "UNKNOWN ERROR"))))))) -#define TRANSFER_TO_STR(type) (type == NRF_DRV_TWI_XFER_TX ? "XFER_TX" : \ - (type == NRF_DRV_TWI_XFER_RX ? "XFER_RX" : \ - (type == NRF_DRV_TWI_XFER_TXRX ? "XFER_TXRX" : \ - (type == NRF_DRV_TWI_XFER_TXTX ? "XFER_TXTX" : "UNKNOWN TRANSFER TYPE")))) -#else //TWI_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define EVT_TO_STR_TWI(event) "" -#define EVT_TO_STR_TWIM(event) "" -#define TRANSFER_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //TWI_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#if (defined(TWIM_IN_USE) && defined(TWI_IN_USE)) - // TWIM and TWI combined - #define CODE_FOR_TWIM(code) if (p_instance->use_easy_dma) { code } - #define CODE_FOR_TWI(code) else { code } -#elif (defined(TWIM_IN_USE) && !defined(TWI_IN_USE)) - // TWIM only - #define CODE_FOR_TWIM(code) { code } - #define CODE_FOR_TWI(code) -#elif (!defined(TWIM_IN_USE) && defined(TWI_IN_USE)) - // TWI only - #define CODE_FOR_TWIM(code) - #define CODE_FOR_TWI(code) { code } -#else - #error "Wrong configuration." -#endif - -// All interrupt flags -#define DISABLE_ALL_INT_SHORT 0xFFFFFFFF - -#define SCL_PIN_INIT_CONF ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ - | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \ - | (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) \ - | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ - | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)) -#define SDA_PIN_INIT_CONF SCL_PIN_INIT_CONF - -#define SDA_PIN_UNINIT_CONF ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ - | (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) \ - | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \ - | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) \ - | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)) -#define SCL_PIN_UNINIT_CONF SDA_PIN_UNINIT_CONF - -#define SCL_PIN_INIT_CONF_CLR ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ - | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \ - | (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) \ - | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ - | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)) -#define SDA_PIN_INIT_CONF_CLR SCL_PIN_INIT_CONF_CLR - -#define HW_TIMEOUT 10000 - -// Control block - driver instance local data. -typedef struct -{ - nrf_drv_twi_evt_handler_t handler; - void * p_context; - volatile uint32_t int_mask; - nrf_drv_twi_xfer_desc_t xfer_desc; - uint32_t flags; - uint8_t * p_curr_buf; - uint8_t curr_length; - bool curr_no_stop; - nrf_drv_state_t state; - bool error; - volatile bool busy; - bool repeated; - uint8_t bytes_transferred; - bool hold_bus_uninit; -#if NRF_MODULE_ENABLED(TWIM_NRF52_ANOMALY_109_WORKAROUND) - nrf_twim_frequency_t bus_frequency; -#endif -} twi_control_block_t; - -static twi_control_block_t m_cb[ENABLED_TWI_COUNT]; - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - #define IRQ_HANDLER_NAME(n) irq_handler_for_instance_##n - #define IRQ_HANDLER(n) static void IRQ_HANDLER_NAME(n)(void) - - #if NRF_MODULE_ENABLED(TWI0) - IRQ_HANDLER(0); - #endif - #if NRF_MODULE_ENABLED(TWI1) - IRQ_HANDLER(1); - #endif - static nrf_drv_irq_handler_t const m_irq_handlers[ENABLED_TWI_COUNT] = { - #if NRF_MODULE_ENABLED(TWI0) - IRQ_HANDLER_NAME(0), - #endif - #if NRF_MODULE_ENABLED(TWI1) - IRQ_HANDLER_NAME(1), - #endif - }; -#else - #if defined (NRF52810_XXAA) - #define IRQ_HANDLER(n) void TWIM##n##_TWIS##n##_IRQHandler(void) - #else - #define IRQ_HANDLER(n) void SPI##n##_TWI##n##_IRQHandler(void) - #endif -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -static ret_code_t twi_process_error(uint32_t errorsrc) -{ - ret_code_t ret = NRF_ERROR_INTERNAL; -#ifdef TWI_IN_USE - if (errorsrc & NRF_TWI_ERROR_OVERRUN) - { - ret = NRF_ERROR_DRV_TWI_ERR_OVERRUN; - } -#endif - if (errorsrc & NRF_TWI_ERROR_ADDRESS_NACK) - { - ret = NRF_ERROR_DRV_TWI_ERR_ANACK; - } - - if (errorsrc & NRF_TWI_ERROR_DATA_NACK) - { - ret = NRF_ERROR_DRV_TWI_ERR_DNACK; - } - - return ret; -} - -static void twi_clear_bus(nrf_drv_twi_config_t const * p_config) -{ - NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF; - NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF; - - nrf_gpio_pin_set(p_config->scl); - nrf_gpio_pin_set(p_config->sda); - - NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF_CLR; - NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF_CLR; - - nrf_delay_us(4); - - for (int i = 0; i < 9; i++) - { - if (nrf_gpio_pin_read(p_config->sda)) - { - if (i == 0) - { - return; - } - else - { - break; - } - } - nrf_gpio_pin_clear(p_config->scl); - nrf_delay_us(4); - nrf_gpio_pin_set(p_config->scl); - nrf_delay_us(4); - } - nrf_gpio_pin_clear(p_config->sda); - nrf_delay_us(4); - nrf_gpio_pin_set(p_config->sda); -} - -ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const * p_instance, - nrf_drv_twi_config_t const * p_config, - nrf_drv_twi_evt_handler_t event_handler, - void * p_context) -{ - ASSERT(p_config); - ASSERT(p_config->scl != p_config->sda); - twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ret_code_t err_code; - - if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - if (nrf_drv_common_per_res_acquire(p_instance->reg.p_regs, - m_irq_handlers[p_instance->drv_inst_idx]) != NRF_SUCCESS) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - - p_cb->handler = event_handler; - p_cb->p_context = p_context; - p_cb->int_mask = 0; - p_cb->repeated = false; - p_cb->busy = false; - p_cb->hold_bus_uninit = p_config->hold_bus_uninit; -#if NRF_MODULE_ENABLED(TWIM_NRF52_ANOMALY_109_WORKAROUND) - p_cb->bus_frequency = (nrf_twim_frequency_t)p_config->frequency; -#endif - - if (p_config->clear_bus_init) - { - /* Send clocks (max 9) until slave device back from stuck mode */ - twi_clear_bus(p_config); - } - - /* To secure correct signal levels on the pins used by the TWI - master when the system is in OFF mode, and when the TWI master is - disabled, these pins must be configured in the GPIO peripheral. - */ - NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF; - NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF; - - CODE_FOR_TWIM - ( - NRF_TWIM_Type * p_twim = p_instance->reg.p_twim; - nrf_twim_pins_set(p_twim, p_config->scl, p_config->sda); - nrf_twim_frequency_set(p_twim, - (nrf_twim_frequency_t)p_config->frequency); - ) - CODE_FOR_TWI - ( - NRF_TWI_Type * p_twi = p_instance->reg.p_twi; - nrf_twi_pins_set(p_twi, p_config->scl, p_config->sda); - nrf_twi_frequency_set(p_twi, - (nrf_twi_frequency_t)p_config->frequency); - ) - - if (p_cb->handler) - { - CODE_FOR_TWIM - ( - nrf_drv_common_irq_enable(nrf_drv_get_IRQn((void *)p_instance->reg.p_twim), - p_config->interrupt_priority); - ) - CODE_FOR_TWI - ( - nrf_drv_common_irq_enable(nrf_drv_get_IRQn((void *)p_instance->reg.p_twi), - p_config->interrupt_priority); - ) - } - - p_cb->state = NRF_DRV_STATE_INITIALIZED; - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -void nrf_drv_twi_uninit(nrf_drv_twi_t const * p_instance) -{ - twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); - - if (p_cb->handler) - { - CODE_FOR_TWIM - ( - nrf_drv_common_irq_disable(nrf_drv_get_IRQn((void *)p_instance->reg.p_twim)); - ) - CODE_FOR_TWI - ( - nrf_drv_common_irq_disable(nrf_drv_get_IRQn((void *)p_instance->reg.p_twi)); - ) - } - nrf_drv_twi_disable(p_instance); - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - nrf_drv_common_per_res_release(p_instance->reg.p_regs); -#endif - - if (!p_cb->hold_bus_uninit) - { - CODE_FOR_TWIM - ( - NRF_GPIO->PIN_CNF[p_instance->reg.p_twim->PSEL.SCL] = SCL_PIN_UNINIT_CONF; - NRF_GPIO->PIN_CNF[p_instance->reg.p_twim->PSEL.SDA] = SDA_PIN_UNINIT_CONF; - ) - CODE_FOR_TWI - ( - NRF_GPIO->PIN_CNF[p_instance->reg.p_twi->PSELSCL] = SCL_PIN_UNINIT_CONF; - NRF_GPIO->PIN_CNF[p_instance->reg.p_twi->PSELSDA] = SDA_PIN_UNINIT_CONF; - ) - } - - p_cb->state = NRF_DRV_STATE_UNINITIALIZED; - NRF_LOG_INFO("Instance uninitialized: %d.", p_instance->drv_inst_idx); -} - -void nrf_drv_twi_enable(nrf_drv_twi_t const * p_instance) -{ - twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state == NRF_DRV_STATE_INITIALIZED); - - CODE_FOR_TWIM - ( - NRF_TWIM_Type * p_twim = p_instance->reg.p_twim; - - nrf_twim_enable(p_twim); - ) - CODE_FOR_TWI - ( - NRF_TWI_Type * p_twi = p_instance->reg.p_twi; - - nrf_twi_enable(p_twi); - ) - - p_cb->state = NRF_DRV_STATE_POWERED_ON; - NRF_LOG_INFO("Instance enabled: %d.", p_instance->drv_inst_idx); -} - -void nrf_drv_twi_disable(nrf_drv_twi_t const * p_instance) -{ - twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); - - CODE_FOR_TWIM - ( - NRF_TWIM_Type * p_twim = p_instance->reg.p_twim; - p_cb->int_mask = 0; - nrf_twim_int_disable(p_twim, DISABLE_ALL_INT_SHORT); - nrf_twim_shorts_disable(p_twim, DISABLE_ALL_INT_SHORT); - nrf_twim_disable(p_twim); - ) - CODE_FOR_TWI - ( - NRF_TWI_Type * p_twi = p_instance->reg.p_twi; - nrf_twi_int_disable(p_twi, DISABLE_ALL_INT_SHORT); - nrf_twi_shorts_disable(p_twi, DISABLE_ALL_INT_SHORT); - nrf_twi_disable(p_twi); - ) - - p_cb->state = NRF_DRV_STATE_INITIALIZED; - NRF_LOG_INFO("Instance disabled: %d.", p_instance->drv_inst_idx); -} - -#ifdef TWI_IN_USE -static bool twi_send_byte(NRF_TWI_Type * p_twi, - uint8_t const * p_data, - uint8_t length, - uint8_t * p_bytes_transferred, - bool no_stop) -{ - if (*p_bytes_transferred < length) - { - nrf_twi_txd_set(p_twi, p_data[*p_bytes_transferred]); - ++(*p_bytes_transferred); - } - else - { - if (no_stop) - { - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_SUSPEND); - return false; - } - else - { - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP); - } - } - return true; -} - -static void twi_receive_byte(NRF_TWI_Type * p_twi, - uint8_t * p_data, - uint8_t length, - uint8_t * p_bytes_transferred) -{ - if (*p_bytes_transferred < length) - { - p_data[*p_bytes_transferred] = nrf_twi_rxd_get(p_twi); - - ++(*p_bytes_transferred); - - if (*p_bytes_transferred == length - 1) - { - nrf_twi_shorts_set(p_twi, NRF_TWI_SHORT_BB_STOP_MASK); - } - else if (*p_bytes_transferred == length) - { - return; - } - - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_RESUME); - } -} - -static bool twi_transfer(NRF_TWI_Type * p_twi, - bool * p_error, - uint8_t * p_bytes_transferred, - uint8_t * p_data, - uint8_t length, - bool no_stop) -{ - bool do_stop_check = ((*p_error) || ((*p_bytes_transferred) == length)); - - if (*p_error) - { - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_RXDREADY); - } - else if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR)) - { - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR); - NRF_LOG_DEBUG("TWI: Event: %s.", (uint32_t)EVT_TO_STR_TWI(NRF_TWI_EVENT_ERROR)); - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP); - *p_error = true; - } - else - { - if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_TXDSENT)) - { - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT); - NRF_LOG_DEBUG("TWI: Event: %s.", (uint32_t)EVT_TO_STR_TWI(NRF_TWI_EVENT_TXDSENT)); - if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR)) - { - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR); - NRF_LOG_DEBUG("TWI: Event: %s.", (uint32_t)EVT_TO_STR_TWI(NRF_TWI_EVENT_ERROR)); - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP); - *p_error = true; - } - else - { - if (!twi_send_byte(p_twi, p_data, length, p_bytes_transferred, no_stop)) - { - return false; - } - } - } - else if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_RXDREADY)) - { - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_RXDREADY); - NRF_LOG_DEBUG("TWI: Event: %s.", (uint32_t)EVT_TO_STR_TWI(NRF_TWI_EVENT_RXDREADY)); - if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR)) - { - NRF_LOG_DEBUG("TWI: Event: %s.", (uint32_t)EVT_TO_STR_TWI(NRF_TWI_EVENT_ERROR)); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR); - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP); - *p_error = true; - } - else - { - twi_receive_byte(p_twi, p_data, length, p_bytes_transferred); - } - } - } - - if (do_stop_check && nrf_twi_event_check(p_twi, NRF_TWI_EVENT_STOPPED)) - { - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED); - NRF_LOG_DEBUG("TWI: Event: %s.", (uint32_t)EVT_TO_STR_TWI(NRF_TWI_EVENT_STOPPED)); - return false; - } - - return true; -} - -static ret_code_t twi_tx_start_transfer(twi_control_block_t * p_cb, - NRF_TWI_Type * p_twi, - uint8_t const * p_data, - uint8_t length, - bool no_stop) -{ - ret_code_t ret_code = NRF_SUCCESS; - volatile int32_t hw_timeout; - - hw_timeout = HW_TIMEOUT; - - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_RXDREADY); - nrf_twi_shorts_set(p_twi, 0); - - p_cb->bytes_transferred = 0; - p_cb->error = false; - - // In case TWI is suspended resume its operation. - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_RESUME); - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STARTTX); - - (void)twi_send_byte(p_twi, p_data, length, &p_cb->bytes_transferred, no_stop); - - if (p_cb->handler) - { - p_cb->int_mask = NRF_TWI_INT_STOPPED_MASK | - NRF_TWI_INT_ERROR_MASK | - NRF_TWI_INT_TXDSENT_MASK | - NRF_TWI_INT_RXDREADY_MASK; - nrf_twi_int_enable(p_twi, p_cb->int_mask); - } - else - { - while ((hw_timeout > 0) && - twi_transfer(p_twi, - &p_cb->error, - &p_cb->bytes_transferred, - (uint8_t *)p_data, - length, - no_stop)) - { - hw_timeout--; - } - - if (p_cb->error) - { - uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(p_twi); - - if (errorsrc) - { - ret_code = twi_process_error(errorsrc); - } - } - - if (hw_timeout <= 0) - { - nrf_twi_disable(p_twi); - nrf_twi_enable(p_twi); - ret_code = NRF_ERROR_INTERNAL; - } - - } - return ret_code; -} - -static ret_code_t twi_rx_start_transfer(twi_control_block_t * p_cb, - NRF_TWI_Type * p_twi, - uint8_t const * p_data, - uint8_t length) -{ - ret_code_t ret_code = NRF_SUCCESS; - volatile int32_t hw_timeout; - - hw_timeout = HW_TIMEOUT; - - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT); - nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_RXDREADY); - - p_cb->bytes_transferred = 0; - p_cb->error = false; - - if (length == 1) - { - nrf_twi_shorts_set(p_twi, NRF_TWI_SHORT_BB_STOP_MASK); - } - else - { - nrf_twi_shorts_set(p_twi, NRF_TWI_SHORT_BB_SUSPEND_MASK); - } - // In case TWI is suspended resume its operation. - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_RESUME); - nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STARTRX); - - if (p_cb->handler) - { - p_cb->int_mask = NRF_TWI_INT_STOPPED_MASK | - NRF_TWI_INT_ERROR_MASK | - NRF_TWI_INT_TXDSENT_MASK | - NRF_TWI_INT_RXDREADY_MASK; - nrf_twi_int_enable(p_twi, p_cb->int_mask); - } - else - { - while ((hw_timeout > 0) && - twi_transfer(p_twi, - &p_cb->error, - &p_cb->bytes_transferred, - (uint8_t*)p_data, - length, - false)) - { - hw_timeout--; - } - - if (p_cb->error) - { - uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(p_twi); - - if (errorsrc) - { - ret_code = twi_process_error(errorsrc); - } - } - if (hw_timeout <= 0) - { - nrf_twi_disable(p_twi); - nrf_twi_enable(p_twi); - ret_code = NRF_ERROR_INTERNAL; - } - } - return ret_code; -} - -__STATIC_INLINE ret_code_t twi_xfer(twi_control_block_t * p_cb, - NRF_TWI_Type * p_twi, - nrf_drv_twi_xfer_desc_t const * p_xfer_desc, - uint32_t flags) -{ - - ret_code_t err_code = NRF_SUCCESS; - - /* Block TWI interrupts to ensure that function is not interrupted by TWI interrupt. */ - nrf_twi_int_disable(p_twi, DISABLE_ALL_INT_SHORT); - - if (p_cb->busy) - { - nrf_twi_int_enable(p_twi, p_cb->int_mask); - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - else - { - p_cb->busy = (NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER & flags) ? false : true; - } - - if (flags & NRF_DRV_TWI_FLAG_HOLD_XFER) - { - err_code = NRF_ERROR_NOT_SUPPORTED; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - p_cb->flags = flags; - p_cb->xfer_desc = *p_xfer_desc; - p_cb->curr_length = p_xfer_desc->primary_length; - p_cb->p_curr_buf = p_xfer_desc->p_primary_buf; - nrf_twi_address_set(p_twi, p_xfer_desc->address); - - if (p_xfer_desc->type != NRF_DRV_TWI_XFER_RX) - { - p_cb->curr_no_stop = ((p_xfer_desc->type == NRF_DRV_TWI_XFER_TX) && - !(flags & NRF_DRV_TWI_FLAG_TX_NO_STOP)) ? false : true; - - err_code = twi_tx_start_transfer(p_cb, - p_twi, - p_xfer_desc->p_primary_buf, - p_xfer_desc->primary_length, - p_cb->curr_no_stop); - } - else - { - p_cb->curr_no_stop = false; - - err_code = twi_rx_start_transfer(p_cb, - p_twi, - p_xfer_desc->p_primary_buf, - p_xfer_desc->primary_length); - } - if (p_cb->handler == NULL) - { - p_cb->busy = false; - } - return err_code; -} -#endif - - -bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance) -{ - twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - return p_cb->busy; -} - - -#ifdef TWIM_IN_USE -__STATIC_INLINE void twim_list_enable_handle(NRF_TWIM_Type * p_twim, uint32_t flags) -{ - if (NRF_DRV_TWI_FLAG_TX_POSTINC & flags) - { - nrf_twim_tx_list_enable(p_twim); - } - else - { - nrf_twim_tx_list_disable(p_twim); - } - - if (NRF_DRV_TWI_FLAG_RX_POSTINC & flags) - { - nrf_twim_rx_list_enable(p_twim); - } - else - { - nrf_twim_rx_list_disable(p_twim); - } -} -__STATIC_INLINE ret_code_t twim_xfer(twi_control_block_t * p_cb, - NRF_TWIM_Type * p_twim, - nrf_drv_twi_xfer_desc_t const * p_xfer_desc, - uint32_t flags) -{ - ret_code_t err_code = NRF_SUCCESS; - nrf_twim_task_t start_task = NRF_TWIM_TASK_STARTTX; - nrf_twim_event_t evt_to_wait = NRF_TWIM_EVENT_STOPPED; - - if (!nrf_drv_is_in_RAM(p_xfer_desc->p_primary_buf)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - /* Block TWI interrupts to ensure that function is not interrupted by TWI interrupt. */ - nrf_twim_int_disable(p_twim, DISABLE_ALL_INT_SHORT); - if (p_cb->busy) - { - nrf_twim_int_enable(p_twim, p_cb->int_mask); - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - else - { - p_cb->busy = ((NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER & flags) || - (NRF_DRV_TWI_FLAG_REPEATED_XFER & flags)) ? false: true; - } - - p_cb->xfer_desc = *p_xfer_desc; - p_cb->repeated = (flags & NRF_DRV_TWI_FLAG_REPEATED_XFER) ? true : false; - nrf_twim_address_set(p_twim, p_xfer_desc->address); - - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_STOPPED); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR); - - twim_list_enable_handle(p_twim, flags); - switch (p_xfer_desc->type) - { - case NRF_DRV_TWI_XFER_TXTX: - ASSERT(!(flags & NRF_DRV_TWI_FLAG_REPEATED_XFER)); - ASSERT(!(flags & NRF_DRV_TWI_FLAG_HOLD_XFER)); - ASSERT(!(flags & NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER)); - if (!nrf_drv_is_in_RAM(p_xfer_desc->p_secondary_buf)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK); - nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTTX); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STARTTX); - while (!nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_TXSTARTED)) - {} - NRF_LOG_DEBUG("TWIM: Event: %s.", (uint32_t)EVT_TO_STR_TWIM(NRF_TWIM_EVENT_TXSTARTED)); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED); - nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_secondary_buf, p_xfer_desc->secondary_length); - p_cb->int_mask = NRF_TWIM_INT_SUSPENDED_MASK | NRF_TWIM_INT_ERROR_MASK; - break; - case NRF_DRV_TWI_XFER_TXRX: - nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length); - if (!nrf_drv_is_in_RAM(p_xfer_desc->p_secondary_buf)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - nrf_twim_rx_buffer_set(p_twim, p_xfer_desc->p_secondary_buf, p_xfer_desc->secondary_length); - nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_STARTRX_MASK | - NRF_TWIM_SHORT_LASTRX_STOP_MASK); - p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK; - break; - case NRF_DRV_TWI_XFER_TX: - nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length); - if (NRF_DRV_TWI_FLAG_TX_NO_STOP & flags) - { - nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK); - p_cb->int_mask = NRF_TWIM_INT_SUSPENDED_MASK | NRF_TWIM_INT_ERROR_MASK; - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED); - evt_to_wait = NRF_TWIM_EVENT_SUSPENDED; - } - else - { - nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_STOP_MASK); - p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK; - } - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME); - break; - case NRF_DRV_TWI_XFER_RX: - nrf_twim_rx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length); - nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTRX_STOP_MASK); - p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK; - start_task = NRF_TWIM_TASK_STARTRX; - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME); - break; - default: - err_code = NRF_ERROR_INVALID_PARAM; - break; - } - - if (!(flags & NRF_DRV_TWI_FLAG_HOLD_XFER) && (p_xfer_desc->type != NRF_DRV_TWI_XFER_TXTX)) - { - nrf_twim_task_trigger(p_twim, start_task); - } - - if (p_cb->handler) - { - if (flags & NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER) - { - p_cb->int_mask = NRF_TWIM_INT_ERROR_MASK; - } - nrf_twim_int_enable(p_twim, p_cb->int_mask); - -#if NRF_MODULE_ENABLED(TWIM_NRF52_ANOMALY_109_WORKAROUND) - if ((flags & NRF_DRV_TWI_FLAG_HOLD_XFER) && ((p_xfer_desc->type == NRF_DRV_TWI_XFER_TX) || - (p_xfer_desc->type == NRF_DRV_TWI_XFER_TXRX))) - { - p_cb->flags = flags; - twim_list_enable_handle(p_twim, 0); - p_twim->FREQUENCY = 0; - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED); - nrf_twim_int_enable(p_twim, NRF_TWIM_INT_TXSTARTED_MASK); - } -#endif - } - else - { - while (!nrf_twim_event_check(p_twim, evt_to_wait)) - { - if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR)) - { - NRF_LOG_DEBUG("TWIM: Event: %s.", - (uint32_t)EVT_TO_STR_TWIM(NRF_TWIM_EVENT_ERROR)); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP); - evt_to_wait = NRF_TWIM_EVENT_STOPPED; - } - } - - uint32_t errorsrc = nrf_twim_errorsrc_get_and_clear(p_twim); - - p_cb->busy = false; - - if (errorsrc) - { - err_code = twi_process_error(errorsrc); - } - } - return err_code; -} -#endif - -ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance, - nrf_drv_twi_xfer_desc_t const * p_xfer_desc, - uint32_t flags) -{ - - ret_code_t err_code = NRF_SUCCESS; - twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - - // TXRX and TXTX transfers are support only in non-blocking mode. - ASSERT( !((p_cb->handler == NULL) && (p_xfer_desc->type == NRF_DRV_TWI_XFER_TXRX))); - ASSERT( !((p_cb->handler == NULL) && (p_xfer_desc->type == NRF_DRV_TWI_XFER_TXTX))); - - NRF_LOG_INFO("Transfer type: %s.", (uint32_t)TRANSFER_TO_STR(p_xfer_desc->type)); - NRF_LOG_INFO("Transfer buffers length: primary: %d, secondary: %d.", - p_xfer_desc->primary_length, p_xfer_desc->secondary_length); - NRF_LOG_DEBUG("Primary buffer data:"); - NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_xfer_desc->p_primary_buf, - p_xfer_desc->primary_length * sizeof(p_xfer_desc->p_primary_buf[0])); - NRF_LOG_DEBUG("Secondary buffer data:"); - NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_xfer_desc->p_secondary_buf, - p_xfer_desc->secondary_length * sizeof(p_xfer_desc->p_secondary_buf[0])); - - CODE_FOR_TWIM - ( - - err_code = twim_xfer(p_cb, (NRF_TWIM_Type *)p_instance->reg.p_twim, p_xfer_desc, flags); - ) - CODE_FOR_TWI - ( - if ( (NRF_DRV_TWI_FLAG_TX_POSTINC | NRF_DRV_TWI_FLAG_RX_POSTINC) & flags) - { - err_code = NRF_ERROR_NOT_SUPPORTED; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - err_code = twi_xfer(p_cb, (NRF_TWI_Type *)p_instance->reg.p_twi, p_xfer_desc, flags); - ) - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - -ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance, - uint8_t address, - uint8_t const * p_data, - uint8_t length, - bool no_stop) -{ - nrf_drv_twi_xfer_desc_t xfer = NRF_DRV_TWI_XFER_DESC_TX(address, (uint8_t*)p_data, length); - - return nrf_drv_twi_xfer(p_instance, &xfer, no_stop ? NRF_DRV_TWI_FLAG_TX_NO_STOP : 0); -} - -ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance, - uint8_t address, - uint8_t * p_data, - uint8_t length) -{ - nrf_drv_twi_xfer_desc_t xfer = NRF_DRV_TWI_XFER_DESC_RX(address, p_data, length); - return nrf_drv_twi_xfer(p_instance, &xfer, 0); -} - -uint32_t nrf_drv_twi_data_count_get(nrf_drv_twi_t const * const p_instance) -{ - CODE_FOR_TWIM - ( - ASSERT(false); - return 0; - ) - CODE_FOR_TWI - ( - return m_cb[p_instance->drv_inst_idx].bytes_transferred; - ) -} - -uint32_t nrf_drv_twi_start_task_get(nrf_drv_twi_t const * p_instance, - nrf_drv_twi_xfer_type_t xfer_type) -{ - CODE_FOR_TWIM - ( - return (uint32_t)nrf_twim_task_address_get(p_instance->reg.p_twim, - (xfer_type != NRF_DRV_TWI_XFER_RX) ? NRF_TWIM_TASK_STARTTX : NRF_TWIM_TASK_STARTRX); - ) - CODE_FOR_TWI - ( - return (uint32_t)nrf_twi_task_address_get(p_instance->reg.p_twi, - (xfer_type != NRF_DRV_TWI_XFER_RX) ? NRF_TWI_TASK_STARTTX : NRF_TWI_TASK_STARTRX); - ) -} - -uint32_t nrf_drv_twi_stopped_event_get(nrf_drv_twi_t const * p_instance) -{ - CODE_FOR_TWIM - ( - return (uint32_t)nrf_twim_event_address_get(p_instance->reg.p_twim, NRF_TWIM_EVENT_STOPPED); - ) - CODE_FOR_TWI - ( - return (uint32_t)nrf_twi_event_address_get(p_instance->reg.p_twi, NRF_TWI_EVENT_STOPPED); - ) -} - -#ifdef TWIM_IN_USE -static void irq_handler_twim(NRF_TWIM_Type * p_twim, twi_control_block_t * p_cb) -{ - -#if NRF_MODULE_ENABLED(TWIM_NRF52_ANOMALY_109_WORKAROUND) - /* Handle only workaround case. Can be used without TWIM handler in IRQs. */ - if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_TXSTARTED)) - { - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED); - nrf_twim_int_disable(p_twim, NRF_TWIM_INT_TXSTARTED_MASK); - if (p_twim->FREQUENCY == 0) - { - // Set enable to zero to reset TWIM internal state. - nrf_twim_disable(p_twim); - nrf_twim_enable(p_twim); - - // Set proper frequency. - nrf_twim_frequency_set(p_twim, p_cb->bus_frequency); - twim_list_enable_handle(p_twim, p_cb->flags); - - // Start proper transmission. - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STARTTX); - return; - } - } -#endif - - ASSERT(p_cb->handler); - - if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR)) - { - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR); - NRF_LOG_DEBUG("TWIM: Event: %s.", (uint32_t)EVT_TO_STR_TWIM(NRF_TWIM_EVENT_ERROR)); - if (!nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_STOPPED)) - { - nrf_twim_int_disable(p_twim, p_cb->int_mask); - p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK; - nrf_twim_int_enable(p_twim, p_cb->int_mask); - - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP); - return; - } - } - - nrf_drv_twi_evt_t event; - - if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_STOPPED)) - { - NRF_LOG_DEBUG("TWIM: Event: %s.", (uint32_t)EVT_TO_STR_TWIM(NRF_TWIM_EVENT_STOPPED)); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_STOPPED); - event.xfer_desc = p_cb->xfer_desc; - if (p_cb->error) - { - - event.xfer_desc.primary_length = (p_cb->xfer_desc.type == NRF_DRV_TWI_XFER_RX) ? - (uint8_t)nrf_twim_rxd_amount_get(p_twim) : (uint8_t)nrf_twim_txd_amount_get(p_twim); - event.xfer_desc.secondary_length = (p_cb->xfer_desc.type == NRF_DRV_TWI_XFER_TXRX) ? - (uint8_t)nrf_twim_rxd_amount_get(p_twim) : (uint8_t)nrf_twim_txd_amount_get(p_twim); - - } - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTTX); - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTRX); - if (!p_cb->repeated || p_cb->error) - { - nrf_twim_shorts_set(p_twim, 0); - p_cb->int_mask = 0; - nrf_twim_int_disable(p_twim, DISABLE_ALL_INT_SHORT); - } - } - else - { - nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED); - NRF_LOG_DEBUG("TWIM: Event: %s.", (uint32_t)EVT_TO_STR_TWIM(NRF_TWIM_EVENT_SUSPENDED)); - if (p_cb->xfer_desc.type == NRF_DRV_TWI_XFER_TX) - { - event.xfer_desc = p_cb->xfer_desc; - if (!p_cb->repeated) - { - nrf_twim_shorts_set(p_twim, 0); - p_cb->int_mask = 0; - nrf_twim_int_disable(p_twim, DISABLE_ALL_INT_SHORT); - } - } - else - { - nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_STOP_MASK); - p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK; - nrf_twim_int_disable(p_twim, DISABLE_ALL_INT_SHORT); - nrf_twim_int_enable(p_twim, p_cb->int_mask); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STARTTX); - nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME); - return; - } - } - - uint32_t errorsrc = nrf_twim_errorsrc_get_and_clear(p_twim); - if (errorsrc & NRF_TWIM_ERROR_ADDRESS_NACK) - { - event.type = NRF_DRV_TWI_EVT_ADDRESS_NACK; - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_DRV_TWI_EVT_ADDRESS_NACK)); - } - else if (errorsrc & NRF_TWIM_ERROR_DATA_NACK) - { - event.type = NRF_DRV_TWI_EVT_DATA_NACK; - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_DRV_TWI_EVT_DATA_NACK)); - } - else - { - event.type = NRF_DRV_TWI_EVT_DONE; - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_DRV_TWI_EVT_DONE)); - } - - if (!p_cb->repeated) - { - p_cb->busy = false; - } - p_cb->handler(&event, p_cb->p_context); -} -#endif // TWIM_IN_USE - -#ifdef TWI_IN_USE -static void irq_handler_twi(NRF_TWI_Type * p_twi, twi_control_block_t * p_cb) -{ - ASSERT(p_cb->handler); - - if (twi_transfer(p_twi, - &p_cb->error, - &p_cb->bytes_transferred, - p_cb->p_curr_buf, - p_cb->curr_length, - p_cb->curr_no_stop )) - { - return; - } - - if (!p_cb->error && - ((p_cb->xfer_desc.type == NRF_DRV_TWI_XFER_TXRX) || - (p_cb->xfer_desc.type == NRF_DRV_TWI_XFER_TXTX)) && - p_cb->p_curr_buf == p_cb->xfer_desc.p_primary_buf) - { - p_cb->p_curr_buf = p_cb->xfer_desc.p_secondary_buf; - p_cb->curr_length = p_cb->xfer_desc.secondary_length; - p_cb->curr_no_stop = (p_cb->flags & NRF_DRV_TWI_FLAG_TX_NO_STOP); - - if (p_cb->xfer_desc.type == NRF_DRV_TWI_XFER_TXTX) - { - (void)twi_tx_start_transfer(p_cb, - p_twi, - p_cb->p_curr_buf, - p_cb->curr_length, - p_cb->curr_no_stop); - } - else - { - (void)twi_rx_start_transfer(p_cb, p_twi, p_cb->p_curr_buf, p_cb->curr_length); - } - } - else - { - nrf_drv_twi_evt_t event; - event.xfer_desc = p_cb->xfer_desc; - - if (p_cb->error) - { - uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(p_twi); - if (errorsrc & NRF_TWI_ERROR_ADDRESS_NACK) - { - event.type = NRF_DRV_TWI_EVT_ADDRESS_NACK; - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_DRV_TWI_EVT_ADDRESS_NACK)); - } - else if (errorsrc & NRF_TWI_ERROR_DATA_NACK) - { - event.type = NRF_DRV_TWI_EVT_DATA_NACK; - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_DRV_TWI_EVT_DATA_NACK)); - } - } - else - { - event.type = NRF_DRV_TWI_EVT_DONE; - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_DRV_TWI_EVT_DONE)); - } - - p_cb->busy = false; - - if (!(NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER & p_cb->flags)) - { - p_cb->handler(&event, p_cb->p_context); - } - } - -} -#endif // TWI_IN_USE - -#if NRF_MODULE_ENABLED(TWI0) -IRQ_HANDLER(0) -{ - #if (TWIM_ONLY || TWI0_WITH_DMA) - irq_handler_twim(NRF_TWIM0, - #else - irq_handler_twi(NRF_TWI0, - #endif - &m_cb[TWI0_INSTANCE_INDEX]); -} -#endif // NRF_MODULE_ENABLED(TWI0) - -#if NRF_MODULE_ENABLED(TWI1) -IRQ_HANDLER(1) -{ - #if (TWIM_ONLY || TWI1_WITH_DMA) - irq_handler_twim(NRF_TWIM1, - #else - irq_handler_twi(NRF_TWI1, - #endif - &m_cb[TWI1_INSTANCE_INDEX]); -} -#endif // NRF_MODULE_ENABLED(TWI1) -#endif // TWI_COUNT -/*lint -restore*/ -#endif // NRF_MODULE_ENABLED(TWI) - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.c deleted file mode 100644 index d06dec9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.c +++ /dev/null @@ -1,977 +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(TWIS) -#include "nrf_drv_twis.h" -#if ENABLED_TWIS_COUNT -#include "nrf_assert.h" -#include "app_util_platform.h" -#include "compiler_abstraction.h" - -#define NRF_LOG_MODULE_NAME twis - -#if TWIS_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL TWIS_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR TWIS_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR TWIS_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_TWIS_EVENT_STOPPED ? "NRF_TWIS_EVENT_STOPPED" : \ - (event == NRF_TWIS_EVENT_ERROR ? "NRF_TWIS_EVENT_ERROR" : \ - (event == NRF_TWIS_EVENT_RXSTARTED ? "NRF_TWIS_EVENT_RXSTARTED" : \ - (event == NRF_TWIS_EVENT_TXSTARTED ? "NRF_TWIS_EVENT_TXSTARTED" : \ - (event == NRF_TWIS_EVENT_WRITE ? "NRF_TWIS_EVENT_WRITE" : \ - (event == NRF_TWIS_EVENT_READ ? "NRF_TWIS_EVENT_READ" : "UNKNOWN EVENT")))))) -#else //TWIS_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //TWIS_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -/** - * @internal - * @ingroup lib_twis_drv - * @defgroup lib_twis_drv_ivars Software controlled TWI Slave internal variables - * - * Internal variables for TWIS. - * @{ - */ - -/** - * @brief Actual state of internal state machine - * - * Current substate of powered on state. - */ -typedef enum -{ - NRF_DRV_TWIS_SUBSTATE_IDLE, ///< No ongoing transmission - NRF_DRV_TWIS_SUBSTATE_READ_WAITING, ///< Read request received, waiting for data - NRF_DRV_TWIS_SUBSTATE_READ_PENDING, ///< Reading is actually pending (data sending) - NRF_DRV_TWIS_SUBSTATE_WRITE_WAITING, ///< Write request received, waiting for data buffer - NRF_DRV_TWIS_SUBSTATE_WRITE_PENDING, ///< Writing is actually pending (data receiving) -}nrf_drv_twis_substate_t; - -/** - * @brief Constant instance part - * - * Instance data that have not to change. - * It may be placed in FLASH memory. - */ -typedef struct -{ - NRF_TWIS_Type * const p_reg; ///< Peripheral registry address -} nrf_drv_twis_const_inst_t; - -/** - * @brief Variable instance part - * - * There are all informations for the instance that may change. - */ -typedef struct -{ - nrf_drv_state_t state; ///< Actual driver state - volatile nrf_drv_twis_substate_t substate; ///< Actual driver substate - nrf_drv_twis_event_handler_t ev_handler; ///< Event handler functiomn - volatile uint32_t error; ///< Internal error flags - /**< Internal copy of hardware errors flags merged - * with specific internal driver errors flags. - * - * @note This value can be changed in the interrupt - * and cleared in the main program. - * Always use Atomic load-store when updating - * this value in main loop. - */ -}nrf_drv_twis_var_inst_t; - - -/** The constant instance part implementation */ -static const nrf_drv_twis_const_inst_t m_const_inst[ENABLED_TWIS_COUNT] = -{ - #define X(n) { .p_reg = NRF_TWIS##n }, - #include "nrf_drv_twis_inst.def" -}; - -/** The variable instance part implementation */ -static nrf_drv_twis_var_inst_t m_var_inst[ENABLED_TWIS_COUNT] = -{ - #define X(n) { .state = NRF_DRV_STATE_UNINITIALIZED, \ - .substate = NRF_DRV_TWIS_SUBSTATE_IDLE, \ - .ev_handler = NULL, \ - .error = 0 }, - #include "nrf_drv_twis_inst.def" -}; - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - #define IRQ_HANDLER_NAME(n) irq_handler_for_instance_##n - #define IRQ_HANDLER(n) static void IRQ_HANDLER_NAME(n)(void) - - #if NRF_MODULE_ENABLED(TWIS0) - IRQ_HANDLER(0); - #endif - #if NRF_MODULE_ENABLED(TWIS1) - IRQ_HANDLER(1); - #endif - static nrf_drv_irq_handler_t const m_irq_handlers[ENABLED_TWIS_COUNT] = { - #if NRF_MODULE_ENABLED(TWIS0) - IRQ_HANDLER_NAME(0), - #endif - #if NRF_MODULE_ENABLED(TWIS1) - IRQ_HANDLER_NAME(1), - #endif - }; -#else - #if defined (NRF52810_XXAA) - #define IRQ_HANDLER(n) void TWIM##n##_TWIS##n##_IRQHandler(void) - #else - #define IRQ_HANDLER(n) \ - void SPIM##n##_SPIS##n##_TWIM##n##_TWIS##n##_SPI##n##_TWI##n##_IRQHandler(void) - #endif -#endif // NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - -/** - * @brief State processing semaphore - * - * There are semaphores used when when working in synchronous mode (without interrupts activated). - * @note - * In synchronous mode before every state checking the state machine is executed. - * But the situation where state checking function is called from main task and in the same from - * interrupt task has to be considered. - * In such a situation the @ref nrf_drv_twis_state_machine function may be interrupted by second - * call to the same function. - * If in this second call any event will be detected it may be lost because new substate would be - * overwritten when interrupted function finishes. - * In the same time information about event would be lost because it is cleared in interrupting - * function. - * @note - * To make situation described above safe, simple semaphore is implemented. - * It is just a binary flag that informs that state machine is actually executing and should not - * be processed in any interrupting function. - * Because of how it is used no atomic instructions are required to support this kind of semaphore. - * It is not waitable semaphore - function executed or not depending of its state. - */ -static uint8_t m_sm_semaphore[ENABLED_TWIS_COUNT]; - -/** - * @brief Used interrupts mask - * - * Mask for all interrupts used by this library - */ -static const uint32_t m_used_ints_mask = - NRF_TWIS_INT_STOPPED_MASK | - NRF_TWIS_INT_ERROR_MASK | - NRF_TWIS_INT_RXSTARTED_MASK | - NRF_TWIS_INT_TXSTARTED_MASK | - NRF_TWIS_INT_WRITE_MASK | - NRF_TWIS_INT_READ_MASK; - - -/** @} */ /* End of lib_driver_twis_slave_ivars */ - -/** - * @internal - * @ingroup lib_twis_drv - * @defgroup lib_twis_drv_ifunc Software controlled TWI Slave auxiliary internal functions - * - * Internal variables for TWIS. - * @{ - */ - -/** - * @brief Clear all events - * - * Function clears all actually pending events - */ -static void nrf_drv_twis_clear_all_events(NRF_TWIS_Type * const p_reg) -{ - /* Clear all events */ - nrf_twis_event_clear(p_reg, NRF_TWIS_EVENT_STOPPED); - nrf_twis_event_clear(p_reg, NRF_TWIS_EVENT_ERROR); - nrf_twis_event_clear(p_reg, NRF_TWIS_EVENT_RXSTARTED); - nrf_twis_event_clear(p_reg, NRF_TWIS_EVENT_TXSTARTED); - nrf_twis_event_clear(p_reg, NRF_TWIS_EVENT_WRITE); - nrf_twis_event_clear(p_reg, NRF_TWIS_EVENT_READ); -} - -/** - * @brief Reset all the registers to known state - * - * This function clears all registers that requires it to known state. - * TWIS is left disabled after this function. - * All events are cleared. - * @param[out] p_reg TWIS to reset register address - */ -static inline void nrf_drv_twis_swreset(NRF_TWIS_Type * const p_reg) -{ - /* Disable TWIS */ - nrf_twis_disable(p_reg); - - /* Disconnect pins */ - nrf_twis_pins_set(p_reg, ~0U, ~0U); - - /* Disable interrupt global for the instance */ - nrf_drv_common_irq_disable(nrf_drv_get_IRQn(p_reg)); - - /* Disable interrupts */ - nrf_twis_int_disable(p_reg, ~0U); -} - -/** - * @brief Configure pin - * - * Function configures selected for work as SDA or SCL. - * @param pin Pin number to configure - */ -static inline void nrf_drv_twis_config_pin(uint32_t pin, nrf_gpio_pin_pull_t pull) -{ - nrf_gpio_cfg(pin, - NRF_GPIO_PIN_DIR_INPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - pull, - NRF_GPIO_PIN_S0D1, - NRF_GPIO_PIN_NOSENSE); -} - -/** - * @brief Call event handler - * - * Function that calls event handler. - * The event handler would be only called if its value is != NULL. - * @param instNr Driver instance number that has called this runtime. - * @param[in] pev Event structure to pass to event handler - * @note - * Remember about possible multithreading. - * It is acceptable to call old event function if it was already disabled. - * What is unacceptable is jump into NULL pointer. - */ -static void nrf_drv_call_event_handler(uint8_t instNr, nrf_drv_twis_evt_t const * const pev) -{ - nrf_drv_twis_event_handler_t evh = m_var_inst[instNr].ev_handler; - if (NULL != evh) - { - evh(pev); - } -} - -/** - * @brief Auxiliary function for getting event state on right bit possition - * - * This function calls @ref nrf_twis_event_get function but the the result - * is shifted to match INTEN register scheme. - * - * @param[in,out] p_reg TWIS to read event from - * @param ev Event code - * - * @return Selected event state shifted by @ref nrf_drv_event_to_bitpos - * - * @sa nrf_twis_event_get - * @sa nrf_drv_event_to_bitpos - */ -static inline uint32_t nrf_drv_twis_event_bit_get(NRF_TWIS_Type * const p_reg, nrf_twis_event_t ev) -{ - return (uint32_t)nrf_twis_event_get_and_clear(p_reg, ev) << nrf_drv_event_to_bitpos(ev); -} - -/** - * @brief Auxiliary function for checking event bit inside given flags value - * - * Function used here to check presence of the event inside given flags value. - * It transforms given event to bit possition and then checks if in given variable it is cleared. - * - * @param flags Flags to test - * @param ev Event code - * - * @retval true Flag for selected event is set - * @retval false Flag for selected event is cleared - */ -static inline bool nrf_drv_twis_check_bit(uint32_t flags, nrf_twis_event_t ev) -{ - return 0 != (flags & (1U<TXD.PTR, - evdata.data.tx_amount * sizeof(uint8_t)); - nrf_drv_call_event_handler(instNr, &evdata); - /* Go to idle and repeat the state machine if READ or WRITE events detected. - * This time READ or WRITE would be started */ - substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - ev = nrf_drv_twis_clear_bit(ev, NRF_TWIS_EVENT_STOPPED); - } - else - { - nrf_drv_twis_process_error(instNr, - TWIS_EVT_READ_ERROR, - nrf_twis_error_source_get_and_clear(p_reg)); - substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - ev = 0; - } - break; - case NRF_DRV_TWIS_SUBSTATE_WRITE_WAITING: - if (nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_RXSTARTED) || - nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_WRITE) || - nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_READ) || - nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_STOPPED)) - { - substate = NRF_DRV_TWIS_SUBSTATE_WRITE_PENDING; - /* Any other bits requires further processing in PENDING substate */ - ev = nrf_drv_twis_clear_bit(ev, NRF_TWIS_EVENT_RXSTARTED); - } - else - { - nrf_drv_twis_process_error(instNr, - TWIS_EVT_WRITE_ERROR, - nrf_twis_error_source_get_and_clear(p_reg)); - substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - ev = 0; - } - break; - case NRF_DRV_TWIS_SUBSTATE_WRITE_PENDING: - if (nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_WRITE) || - nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_READ) || - nrf_drv_twis_check_bit(ev, NRF_TWIS_EVENT_STOPPED)) - { - evdata.type = TWIS_EVT_WRITE_DONE; - evdata.data.rx_amount = nrf_twis_rx_amount_get(p_reg); - nrf_drv_call_event_handler(instNr, &evdata); - /* Go to idle and repeat the state machine if READ or WRITE events detected. - * This time READ or WRITE would be started */ - substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - ev = nrf_drv_twis_clear_bit(ev, NRF_TWIS_EVENT_STOPPED); - } - else - { - nrf_drv_twis_process_error(instNr, - TWIS_EVT_WRITE_ERROR, - nrf_twis_error_source_get_and_clear(p_reg)); - substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - ev = 0; - } - break; - default: - substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - /* Do not clear any events and repeat the machine */ - break; - } - } - - m_var_inst[instNr].substate = substate; - if (!TWIS_NO_SYNC_MODE) - { - m_sm_semaphore[instNr] = 0; - } -} - -/** - * @brief This function - */ -static inline void nrf_drv_twis_preprocess_status(uint8_t instNr) -{ - if (!TWIS_NO_SYNC_MODE) - { - if (NULL == m_var_inst[instNr].ev_handler) - { - nrf_drv_twis_state_machine(instNr); - } - } -} - -/** - * @brief Interrupt service - * - * This function is called by all interrupts runtime for instances enabled in this library. - * @param instNr Driver instance number that has called this runtime. - */ -static inline void nrf_drv_twis_on_ISR(uint8_t instNr) -{ - nrf_drv_twis_state_machine(instNr); -} - -/** @} */ /* End of lib_driver_twis_slave_ifunc */ - - -/* ------------------------------------------------------------------------- - * Implementation of IRQ Handlers - */ -#define X(n) \ - IRQ_HANDLER(n) \ - { \ - nrf_drv_twis_on_ISR(TWIS##n##_INSTANCE_INDEX); \ - } -#include "nrf_drv_twis_inst.def" - -/* ------------------------------------------------------------------------- - * Implementation of interface functions - * - */ - - -ret_code_t nrf_drv_twis_init( - nrf_drv_twis_t const * const p_instance, - nrf_drv_twis_config_t const * p_config, - nrf_drv_twis_event_handler_t const event_handler) -{ - ASSERT(p_config); - ASSERT(p_config->scl != p_config->sda); - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type * const p_reg = m_const_inst[instNr].p_reg; - nrf_twis_config_addr_mask_t addr_mask = (nrf_twis_config_addr_mask_t)0; - ret_code_t err_code; - - if (m_var_inst[instNr].state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - if (nrf_drv_common_per_res_acquire(p_reg, m_irq_handlers[instNr]) != NRF_SUCCESS) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } -#endif - - if (!TWIS_ASSUME_INIT_AFTER_RESET_ONLY) - { - nrf_drv_twis_swreset(p_reg); - } - - nrf_drv_twis_config_pin(p_config->scl, p_config->scl_pull); - nrf_drv_twis_config_pin(p_config->sda, p_config->sda_pull); - - if (0 == (p_config->addr[0] | p_config->addr[1])) - addr_mask = NRF_TWIS_CONFIG_ADDRESS0_MASK; - else - { - if (0 != p_config->addr[0]) - { - addr_mask |= NRF_TWIS_CONFIG_ADDRESS0_MASK; - } - if (0 != p_config->addr[1]) - { - addr_mask |= NRF_TWIS_CONFIG_ADDRESS1_MASK; - } - } - - /* Peripheral interrupt configure - * (note - interrupts still needs to be configured in INTEN register. - * This is done in enable function) */ - nrf_drv_common_irq_enable(nrf_drv_get_IRQn(p_reg), p_config->interrupt_priority); - - /* Configure */ - nrf_twis_pins_set (p_reg, p_config->scl, p_config->sda); - nrf_twis_address_set (p_reg, 0, p_config->addr[0]); - nrf_twis_address_set (p_reg, 1, p_config->addr[1]); - nrf_twis_config_address_set(p_reg, addr_mask); - - /* Clear semaphore */ - if (!TWIS_NO_SYNC_MODE) - { - m_sm_semaphore[instNr] = 0; - } - /* Set internal instance variables */ - m_var_inst[instNr].substate = NRF_DRV_TWIS_SUBSTATE_IDLE; - m_var_inst[instNr].ev_handler = event_handler; - m_var_inst[instNr].state = NRF_DRV_STATE_INITIALIZED; - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_twis_uninit(nrf_drv_twis_t const * const p_instance) -{ - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type * const p_reg = m_const_inst[instNr].p_reg; - TWIS_PSEL_Type psel = p_reg->PSEL; - - ASSERT(m_var_inst[instNr].state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_drv_twis_swreset(p_reg); - - /* Clear pins state if */ - if (!(TWIS_PSEL_SCL_CONNECT_Msk & psel.SCL)) - { - nrf_gpio_cfg_default(psel.SCL); - } - if (!(TWIS_PSEL_SDA_CONNECT_Msk & psel.SDA)) - { - nrf_gpio_cfg_default(psel.SDA); - } - -#if NRF_MODULE_ENABLED(PERIPHERAL_RESOURCE_SHARING) - nrf_drv_common_per_res_release(p_reg); -#endif - - /* Clear variables */ - m_var_inst[instNr].ev_handler = NULL; - m_var_inst[instNr].state = NRF_DRV_STATE_UNINITIALIZED; -} - - -void nrf_drv_twis_enable(nrf_drv_twis_t const * const p_instance) -{ - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type * const p_reg = m_const_inst[instNr].p_reg; - nrf_drv_twis_var_inst_t * const p_var_inst = &m_var_inst[instNr]; - - ASSERT(m_var_inst[instNr].state == NRF_DRV_STATE_INITIALIZED); - - nrf_drv_twis_clear_all_events(p_reg); - - /* Enable interrupts */ - if (NULL != p_var_inst->ev_handler) - { - nrf_twis_int_enable(p_reg, m_used_ints_mask); - } - - nrf_twis_enable(p_reg); - p_var_inst->error = 0; - p_var_inst->state = NRF_DRV_STATE_POWERED_ON; - p_var_inst->substate = NRF_DRV_TWIS_SUBSTATE_IDLE; -} - - -void nrf_drv_twis_disable(nrf_drv_twis_t const * const p_instance) -{ - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type * const p_reg = m_const_inst[instNr].p_reg; - - ASSERT(m_var_inst[instNr].state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_twis_int_disable(p_reg, m_used_ints_mask); - - nrf_twis_disable(p_reg); - m_var_inst[instNr].state = NRF_DRV_STATE_INITIALIZED; -} - -/* ARM recommends not using the LDREX and STREX instructions in C code. - * This is because the compiler might generate loads and stores between - * LDREX and STREX, potentially clearing the exclusive monitor set by LDREX. - * This recommendation also applies to the byte, halfword, and doubleword - * variants LDREXB, STREXB, LDREXH, STREXH, LDREXD, and STREXD. - * - * This is the reason for the function below to be implemented in assembly. - */ -//lint -save -e578 -#if defined (__CC_ARM ) -static __ASM uint32_t nrf_drv_twis_error_get_and_clear_internal(uint32_t volatile * const perror) -{ - mov r3, r0 - mov r1, #0 -nrf_drv_twis_error_get_and_clear_internal_try - ldrex r0, [r3] - strex r2, r1, [r3] - cmp r2, r1 /* did this succeed? */ - bne nrf_drv_twis_error_get_and_clear_internal_try /* no – try again */ - bx lr -} -#elif defined ( __GNUC__ ) -static uint32_t nrf_drv_twis_error_get_and_clear_internal(uint32_t volatile * const perror) -{ - uint32_t ret; - uint32_t temp; - __ASM volatile( - " .syntax unified \n" - "nrf_drv_twis_error_get_and_clear_internal_try: \n" - " ldrex %[ret], [%[perror]] \n" - " strex %[temp], %[zero], [%[perror]] \n" - " cmp %[temp], %[zero] \n" - " bne nrf_drv_twis_error_get_and_clear_internal_try \n" - : /* Output */ - [ret]"=&l"(ret), - [temp]"=&l"(temp) - : /* Input */ - [zero]"l"(0), - [perror]"l"(perror) - ); - UNUSED_VARIABLE(temp); - return ret; -} -#elif defined ( __ICCARM__ ) -static uint32_t nrf_drv_twis_error_get_and_clear_internal(uint32_t volatile * const perror) -{ - uint32_t ret; - uint32_t temp; - __ASM volatile( - "1: \n" - " ldrex %[ret], [%[perror]] \n" - " strex %[temp], %[zero], [%[perror]] \n" - " cmp %[temp], %[zero] \n" - " bne.n 1b \n" - : /* Output */ - [ret]"=&l"(ret), - [temp]"=&l"(temp) - : /* Input */ - [zero]"l"(0), - [perror]"l"(perror) - ); - UNUSED_VARIABLE(temp); - return ret; -} -#else - #error Unknown compiler -#endif -//lint -restore - -uint32_t nrf_drv_twis_error_get_and_clear(nrf_drv_twis_t const * const p_instance) -{ - nrf_drv_twis_var_inst_t * const p_var_inst = &m_var_inst[p_instance->instNr]; - nrf_drv_twis_preprocess_status(p_instance->instNr); - /* Make sure that access to error member is atomic - * so there is no bit that is cleared if it is not copied to local variable already. */ - return nrf_drv_twis_error_get_and_clear_internal(&p_var_inst->error); -} - - -ret_code_t nrf_drv_twis_tx_prepare( - nrf_drv_twis_t const * const p_instance, - void const * const p_buf, - size_t size) -{ - ret_code_t err_code = NRF_SUCCESS; - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type * const p_reg = m_const_inst[instNr].p_reg; - nrf_drv_twis_var_inst_t * const p_var_inst = &m_var_inst[instNr]; - - /* Check power state*/ - if (p_var_inst->state != NRF_DRV_STATE_POWERED_ON) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - /* Check data address */ - if (!nrf_drv_is_in_RAM(p_buf)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - /* Check data size */ - if ((size & TWIS_TXD_MAXCNT_MAXCNT_Msk) != size) - { - err_code = NRF_ERROR_INVALID_LENGTH; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - nrf_twis_tx_prepare(p_reg, (uint8_t const *)p_buf, (nrf_twis_amount_t)size); - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - -} - - -size_t nrf_drv_twis_tx_amount(nrf_drv_twis_t const * const p_instance) -{ - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type const * const p_reg = m_const_inst[instNr].p_reg; - - return nrf_twis_tx_amount_get(p_reg); -} - - -ret_code_t nrf_drv_twis_rx_prepare( - nrf_drv_twis_t const * const p_instance, - void * const p_buf, - size_t size) -{ - ret_code_t err_code; - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type * const p_reg = m_const_inst[instNr].p_reg; - nrf_drv_twis_var_inst_t * const p_var_inst = &m_var_inst[instNr]; - - /* Check power state*/ - if (p_var_inst->state != NRF_DRV_STATE_POWERED_ON) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - /* Check data address */ - if (!nrf_drv_is_in_RAM(p_buf)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - /* Check data size */ - if ((size & TWIS_RXD_MAXCNT_MAXCNT_Msk) != size) - { - err_code = NRF_ERROR_INVALID_LENGTH; - NRF_LOG_WARNING("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - nrf_twis_rx_prepare(p_reg, (uint8_t *)p_buf, (nrf_twis_amount_t)size); - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, - (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -size_t nrf_drv_twis_rx_amount(nrf_drv_twis_t const * const p_instance) -{ - uint8_t instNr = p_instance->instNr; - NRF_TWIS_Type const * const p_reg = m_const_inst[instNr].p_reg; - - return nrf_twis_rx_amount_get(p_reg); -} - - -bool nrf_drv_twis_is_busy(nrf_drv_twis_t const * const p_instance) -{ - nrf_drv_twis_preprocess_status(p_instance->instNr); - return NRF_DRV_TWIS_SUBSTATE_IDLE != m_var_inst[(p_instance->instNr)].substate; -} - -bool nrf_drv_twis_is_waiting_tx_buff(nrf_drv_twis_t const * const p_instance) -{ - nrf_drv_twis_preprocess_status(p_instance->instNr); - return NRF_DRV_TWIS_SUBSTATE_READ_WAITING == m_var_inst[(p_instance->instNr)].substate; -} - -bool nrf_drv_twis_is_waiting_rx_buff(nrf_drv_twis_t const * const p_instance) -{ - nrf_drv_twis_preprocess_status(p_instance->instNr); - return NRF_DRV_TWIS_SUBSTATE_WRITE_WAITING == m_var_inst[(p_instance->instNr)].substate; -} - -bool nrf_drv_twis_is_pending_tx(nrf_drv_twis_t const * const p_instance) -{ - nrf_drv_twis_preprocess_status(p_instance->instNr); - return NRF_DRV_TWIS_SUBSTATE_READ_PENDING == m_var_inst[(p_instance->instNr)].substate; -} - -bool nrf_drv_twis_is_pending_rx(nrf_drv_twis_t const * const p_instance) -{ - nrf_drv_twis_preprocess_status(p_instance->instNr); - return NRF_DRV_TWIS_SUBSTATE_WRITE_PENDING == m_var_inst[(p_instance->instNr)].substate; -} -#endif // TWIS_COUNT -#endif // NRF_MODULE_ENABLED(TWIS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.h deleted file mode 100644 index aa70da2..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis.h +++ /dev/null @@ -1,409 +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 NRF_DRV_TWIS_H__ -#define NRF_DRV_TWIS_H__ - -#include "sdk_config.h" -#include "nrf_drv_common.h" -#include "nrf_gpio.h" -#include "sdk_errors.h" -#include "nrf_twis.h" -#include -#include "app_util.h" - -#ifdef __cplusplus -extern "C" { -#endif -/**@file - * @addtogroup nrf_twis Two Wire slave interface (TWIS) - * @ingroup nrf_drivers - * @brief Two Wire slave interface (TWIS) APIs. - * - * - * @defgroup nrf_drv_twis TWIS driver - * @{ - * @ingroup nrf_twis - * @brief TWI slave APIs. - */ - -#ifdef TWIS0_ENABLED -#define TWIS0_INCR TWIS0_ENABLED -#else -#define TWIS0_INCR 0 -#endif - -#ifdef TWIS1_ENABLED -#define TWIS1_INCR TWIS1_ENABLED -#else -#define TWIS1_INCR 0 -#endif - -#define ENABLED_TWIS_COUNT (TWIS0_INCR + TWIS1_INCR) -/** - * @brief Event callback function event definitions. - */ -typedef enum -{ - TWIS_EVT_READ_REQ, ///< Read request detected - /**< If there is no buffer prepared, buf_req flag in the even will be set. - Call then @ref nrf_drv_twis_tx_prepare to give parameters for buffer. - */ - TWIS_EVT_READ_DONE, ///< Read request has finished - free any data - TWIS_EVT_READ_ERROR, ///< Read request finished with error - TWIS_EVT_WRITE_REQ, ///< Write request detected - /**< If there is no buffer prepared, buf_req flag in the even will be set. - Call then @ref nrf_drv_twis_rx_prepare to give parameters for buffer. - */ - TWIS_EVT_WRITE_DONE, ///< Write request has finished - process data - TWIS_EVT_WRITE_ERROR, ///< Write request finished with error - TWIS_EVT_GENERAL_ERROR ///< Error that happens not inside WRITE or READ transaction -} nrf_drv_twis_evt_type_t; - -/** - * @brief TWIS driver instance structure - * - * @note We only need instance number here so we could really use just a number - * that would be send to every driver function. - * But for compatibility reason this number is inserted into the structure. - */ -typedef struct -{ - uint8_t instNr; /**< Instance number */ -}nrf_drv_twis_t; - -/** - * @brief TWIS driver event structure - */ -typedef struct -{ - nrf_drv_twis_evt_type_t type; ///< Event type - union - { - bool buf_req; ///< Flag for @ref TWIS_EVT_READ_REQ and @ref TWIS_EVT_WRITE_REQ - /**< Information if transmission buffer requires to be prepared */ - uint32_t tx_amount; ///< Data for @ref TWIS_EVT_READ_DONE - uint32_t rx_amount; ///< Data for @ref TWIS_EVT_WRITE_DONE - uint32_t error; ///< Data for @ref TWIS_EVT_GENERAL_ERROR - }data; -}nrf_drv_twis_evt_t; - -/** - * @brief TWI slave event callback function type. - * - * @param[in] p_event Event information structure. - */ -typedef void (*nrf_drv_twis_event_handler_t)(nrf_drv_twis_evt_t const * const p_event); - -/** - * @brief Structure for TWIS configuration - */ -typedef struct -{ - uint32_t addr[2]; //!< Set addresses that this slave should respond. Set 0 to disable. - uint32_t scl; //!< SCL pin number - nrf_gpio_pin_pull_t scl_pull; //!< SCL pin pull - uint32_t sda; //!< SDA pin number - nrf_gpio_pin_pull_t sda_pull; //!< SDA pin pull - uint8_t interrupt_priority; //!< The priority of interrupt for the module to set -}nrf_drv_twis_config_t; - -/** - * @brief Possible error sources - * - * This is flag enum - values from this enum can be connected using logical or operator. - * @note - * We could use directly @ref nrf_twis_error_t. Error type enum is redefined here becouse - * of possible future extension (eg. supporting timeouts and synchronous mode). - */ -typedef enum -{ - NRF_DRV_TWIS_ERROR_OVERFLOW = NRF_TWIS_ERROR_OVERFLOW, /**< RX buffer overflow detected, and prevented */ - NRF_DRV_TWIS_ERROR_DATA_NACK = NRF_TWIS_ERROR_DATA_NACK, /**< NACK sent after receiving a data byte */ - NRF_DRV_TWIS_ERROR_OVERREAD = NRF_TWIS_ERROR_OVERREAD, /**< TX buffer over-read detected, and prevented */ - NRF_DRV_TWIS_ERROR_UNEXPECTED_EVENT = 1 << 8 /**< Unexpected event detected by state machine */ -}nrf_drv_twis_error_t; - -/** - * @internal - * @brief Internal macro for creating TWIS driver instance - * - * Second level of indirection in creating the instance. - * Do not use this macro directly. - * Use @ref NRF_DRV_TWIS_INSTANCE instead. - */ -#define NRF_DRV_TWIS_INSTANCE_x(id) \ - { \ - TWIS##id##_INSTANCE_INDEX \ - } - -/** - * @brief Macro for creating TWIS driver instance - * - * @param[in] id Instance index. Use 0 for TWIS0 and 1 for TWIS1 - */ -#define NRF_DRV_TWIS_INSTANCE(id) NRF_DRV_TWIS_INSTANCE_x(id) - -#define TWIS0_INSTANCE_INDEX 0 -#define TWIS1_INSTANCE_INDEX TWIS0_INSTANCE_INDEX+TWIS0_ENABLED - -/** - * @brief Generate default configuration for TWIS driver instance - */ -#define NRF_DRV_TWIS_DEFAULT_CONFIG \ -{ \ - .addr = { TWIS_DEFAULT_CONFIG_ADDR0, TWIS_DEFAULT_CONFIG_ADDR1 }, \ - .scl = 31, \ - .scl_pull = (nrf_gpio_pin_pull_t)TWIS_DEFAULT_CONFIG_SCL_PULL, \ - .sda = 31, \ - .sda_pull = (nrf_gpio_pin_pull_t)TWIS_DEFAULT_CONFIG_SDA_PULL, \ - .interrupt_priority = TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \ -} - -/** - * @brief Function for initializing the TWIS driver instance. - * - * Function initializes and enables TWIS driver. - * @attention After driver initialization enable it by @ref nrf_drv_twis_enable - * - * @param[in] p_instance Pointer to the driver instance structure. - * @attention @em p_instance has to be global object. - * It would be used by interrupts so make it sure that object - * would not be destroyed when function is leaving. - * @param[in] p_config Initial configuration. - * @param[in] event_handler Event handler provided by the user. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. - * @retval NRF_ERROR_BUSY If some other peripheral with the same - * instance ID is already in use. This is - * possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED - * is set to a value other than zero. - */ -ret_code_t nrf_drv_twis_init( - nrf_drv_twis_t const * const p_instance, - nrf_drv_twis_config_t const * p_config, - nrf_drv_twis_event_handler_t const event_handler); - -/** - * @brief Function for uninitializing the TWIS driver instance. - * - * Function initializes the peripheral and resets all registers to default values. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @note - * It is safe to call nrf_drv_twis_uninit even before initialization. - * Actually @ref nrf_drv_twis_init function calls this function to - * make sure that TWIS state is known. - * @note - * If TWIS driver was in uninitialized state before calling this function, - * selected pins would not be reset to default configuration. - */ -void nrf_drv_twis_uninit(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Enable TWIS instance - * - * This function enables TWIS instance. - * Function defined if there is needs for dynamically enabling and disabling the peripheral. - * Use @ref nrf_drv_twis_enable and @ref nrf_drv_twis_disable functions. - * They do not change any configuration registers. - * - * @param p_instance Pointer to the driver instance structure. - */ -void nrf_drv_twis_enable(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Disable TWIS instance - * - * Disabling TWIS instance gives possibility to turn off the TWIS while - * holding configuration done by @ref nrf_drv_twis_init - * - * @param p_instance Pointer to the driver instance structure. - */ -void nrf_drv_twis_disable(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Get and clear last error flags - * - * Function gets information about errors. - * This is also the only possibility to exit from error substate of the internal state machine. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @return Error flags defined in @ref nrf_drv_twis_error_t - * @attention - * This function clears error state and flags. - */ -uint32_t nrf_drv_twis_error_get_and_clear(nrf_drv_twis_t const * const p_instance); - - -/** - * @brief Prepare data for sending - * - * This function should be used in response for @ref TWIS_EVT_READ_REQ event. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_buf Transmission buffer - * @attention Transmission buffer has to be placed in RAM. - * @param size Maximum number of bytes that master may read from buffer given. - * - * @retval NRF_SUCCESS Preparation finished properly - * @retval NRF_ERROR_INVALID_ADDR Given @em p_buf is not placed inside the RAM - * @retval NRF_ERROR_INVALID_LENGTH Wrong value in @em size parameter - * @retval NRF_ERROR_INVALID_STATE Module not initialized or not enabled - */ -ret_code_t nrf_drv_twis_tx_prepare( - nrf_drv_twis_t const * const p_instance, - void const * const p_buf, - size_t size); - -/** - * @brief Get number of transmitted bytes - * - * Function returns number of bytes sent. - * This function may be called after @ref TWIS_EVT_READ_DONE or @ref TWIS_EVT_READ_ERROR events. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @return Number of bytes sent. - */ -size_t nrf_drv_twis_tx_amount(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Prepare data for receiving - * - * This function should be used in response for @ref TWIS_EVT_WRITE_REQ event. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_buf Buffer that would be filled with received data - * @attention Receiving buffer has to be placed in RAM. - * @param size Size of the buffer (maximum amount of data to receive) - * - * @retval NRF_SUCCESS Preparation finished properly - * @retval NRF_ERROR_INVALID_ADDR Given @em p_buf is not placed inside the RAM - * @retval NRF_ERROR_INVALID_LENGTH Wrong value in @em size parameter - * @retval NRF_ERROR_INVALID_STATE Module not initialized or not enabled - */ -ret_code_t nrf_drv_twis_rx_prepare( - nrf_drv_twis_t const * const p_instance, - void * const p_buf, - size_t size); - -/** - * @brief Get number of received bytes - * - * Function returns number of bytes received. - * This function may be called after @ref TWIS_EVT_WRITE_DONE or @ref TWIS_EVT_WRITE_ERROR events. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @return Number of bytes received. - */ -size_t nrf_drv_twis_rx_amount(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Function checks if driver is busy right now - * - * Actual driver substate is tested. - * If driver is in any other state than IDLE or ERROR this function returns true. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true Driver is in state other than ERROR or IDLE - * @retval false There is no transmission pending. - */ -bool nrf_drv_twis_is_busy(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Function checks if driver is waiting for tx buffer - * - * If this function returns true, it means that driver is stalled expecting - * of the @ref nrf_drv_twis_tx_prepare function call. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true Driver waits for @ref nrf_drv_twis_tx_prepare - * @retval false Driver is not in the state where it waits for preparing tx buffer. - */ -bool nrf_drv_twis_is_waiting_tx_buff(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Function checks if driver is waiting for rx buffer - * - * If this function returns true, it means that driver is staled expecting - * of the @ref nrf_drv_twis_rx_prepare function call. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true Driver waits for @ref nrf_drv_twis_rx_prepare - * @retval false Driver is not in the state where it waits for preparing rx buffer. - */ -bool nrf_drv_twis_is_waiting_rx_buff(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Check if driver is sending data - * - * If this function returns true, it means that there is ongoing output transmission. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true There is ongoing output transmission. - * @retval false Driver is in other state. - */ -bool nrf_drv_twis_is_pending_tx(nrf_drv_twis_t const * const p_instance); - -/** - * @brief Check if driver is receiving data - * - * If this function returns true, it means that there is ongoing input transmission. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true There is ongoing input transmission. - * @retval false Driver is in other state. - */ -bool nrf_drv_twis_is_pending_rx(nrf_drv_twis_t const * const p_instance); - -/** @} */ /* End of lib_twis_drv group */ - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_DRV_TWIS_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis_inst.def b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis_inst.def deleted file mode 100644 index be40002..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twis_slave/nrf_drv_twis_inst.def +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * @brief Xmacro file with contains enumeration of TWIS instances to implement - * - * Use this file everywhere where anything has to be generated for all active TWIS instances. - * Xmacro format: - * - * @code - X(n) - * @endcode - * - * Where @em n is number of the instance itself (0 for NRF_TWIS0). - */ -#if (TWIS0_ENABLED == 1) - X(0) -#endif -#if (TWIS1_ENABLED == 1) - X(1) -#endif -#undef X diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.c deleted file mode 100644 index 495a92b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.c +++ /dev/null @@ -1,990 +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(UART) -#include "nrf_drv_uart.h" -#include "nrf_assert.h" -#include "nrf_drv_common.h" -#include "nrf_gpio.h" -#include "app_util_platform.h" - -#define NRF_LOG_MODULE_NAME uart - -#if UART_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL UART_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR UART_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR UART_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_UART_EVENT_ERROR ? "NRF_UART_EVENT_ERROR" : "UNKNOWN EVENT") -#else //UART_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 -#endif //UART_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#if (defined(UARTE_IN_USE) && defined(UART_IN_USE)) - // UARTE and UART combined - #define CODE_FOR_UARTE(code) if (m_cb[p_instance->drv_inst_idx].use_easy_dma) { code } - #define CODE_FOR_UARTE_INT(idx, code) if (m_cb[idx].use_easy_dma) { code } - #define CODE_FOR_UART(code) else { code } -#elif (defined(UARTE_IN_USE) && !defined(UART_IN_USE)) - // UARTE only - #define CODE_FOR_UARTE(code) { code } - #define CODE_FOR_UARTE_INT(idx, code) { code } - #define CODE_FOR_UART(code) -#elif (!defined(UARTE_IN_USE) && defined(UART_IN_USE)) - // UART only - #define CODE_FOR_UARTE(code) - #define CODE_FOR_UARTE_INT(idx, code) - #define CODE_FOR_UART(code) { code } -#else - #error "Wrong configuration." -#endif - -#define TX_COUNTER_ABORT_REQ_VALUE 256 - -typedef struct -{ - void * p_context; - nrf_uart_event_handler_t handler; - uint8_t const * p_tx_buffer; - uint8_t * p_rx_buffer; - uint8_t * p_rx_secondary_buffer; - volatile uint16_t tx_counter; - uint8_t tx_buffer_length; - uint8_t rx_buffer_length; - uint8_t rx_secondary_buffer_length; - volatile uint8_t rx_counter; - bool rx_enabled; - nrf_drv_state_t state; -#if (defined(UARTE_IN_USE) && defined(UART_IN_USE)) - bool use_easy_dma; -#endif -} uart_control_block_t; - -static uart_control_block_t m_cb[UART_ENABLED_COUNT]; - -#ifdef NRF52810_XXAA - #define IRQ_HANDLER(n) void UARTE##n##_IRQHandler(void) -#else - #define IRQ_HANDLER(n) void UART##n##_IRQHandler(void) -#endif - -__STATIC_INLINE void apply_config(nrf_drv_uart_t const * p_instance, nrf_drv_uart_config_t const * p_config) -{ - if (p_config->pseltxd != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_pin_set(p_config->pseltxd); - nrf_gpio_cfg_output(p_config->pseltxd); - } - if (p_config->pselrxd != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_NOPULL); - } - - CODE_FOR_UARTE - ( - nrf_uarte_baudrate_set(p_instance->reg.p_uarte, (nrf_uarte_baudrate_t)p_config->baudrate); - nrf_uarte_configure(p_instance->reg.p_uarte, (nrf_uarte_parity_t)p_config->parity, - (nrf_uarte_hwfc_t)p_config->hwfc); - nrf_uarte_txrx_pins_set(p_instance->reg.p_uarte, p_config->pseltxd, p_config->pselrxd); - if (p_config->hwfc == NRF_UART_HWFC_ENABLED) - { - if (p_config->pselcts != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_input(p_config->pselcts, NRF_GPIO_PIN_NOPULL); - } - if (p_config->pselrts != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_pin_set(p_config->pselrts); - nrf_gpio_cfg_output(p_config->pselrts); - } - nrf_uarte_hwfc_pins_set(p_instance->reg.p_uarte, p_config->pselrts, p_config->pselcts); - } - ) - CODE_FOR_UART - ( - nrf_uart_baudrate_set(p_instance->reg.p_uart, p_config->baudrate); - nrf_uart_configure(p_instance->reg.p_uart, p_config->parity, p_config->hwfc); - nrf_uart_txrx_pins_set(p_instance->reg.p_uart, p_config->pseltxd, p_config->pselrxd); - if (p_config->hwfc == NRF_UART_HWFC_ENABLED) - { - if (p_config->pselcts != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_input(p_config->pselcts, NRF_GPIO_PIN_NOPULL); - } - if (p_config->pselrts != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_pin_set(p_config->pselrts); - nrf_gpio_cfg_output(p_config->pselrts); - } - nrf_uart_hwfc_pins_set(p_instance->reg.p_uart, p_config->pselrts, p_config->pselcts); - } - ) -} - -__STATIC_INLINE void interrupts_enable(const nrf_drv_uart_t * p_instance, uint8_t interrupt_priority) -{ - CODE_FOR_UARTE - ( - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDRX); - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDTX); - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ERROR); - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_RXTO); - nrf_uarte_int_enable(p_instance->reg.p_uarte, NRF_UARTE_INT_ENDRX_MASK | - NRF_UARTE_INT_ENDTX_MASK | - NRF_UARTE_INT_ERROR_MASK | - NRF_UARTE_INT_RXTO_MASK); - nrf_drv_common_irq_enable(nrf_drv_get_IRQn((void *)p_instance->reg.p_uarte), interrupt_priority); - ) - CODE_FOR_UART - ( - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_TXDRDY); - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_RXTO); - nrf_uart_int_enable(p_instance->reg.p_uart, NRF_UART_INT_MASK_TXDRDY | - NRF_UART_INT_MASK_RXTO); - nrf_drv_common_irq_enable(nrf_drv_get_IRQn((void *)p_instance->reg.p_uart), interrupt_priority); - ) -} - -__STATIC_INLINE void interrupts_disable(const nrf_drv_uart_t * p_instance) -{ - CODE_FOR_UARTE - ( - nrf_uarte_int_disable(p_instance->reg.p_uarte, NRF_UARTE_INT_ENDRX_MASK | - NRF_UARTE_INT_ENDTX_MASK | - NRF_UARTE_INT_ERROR_MASK | - NRF_UARTE_INT_RXTO_MASK); - nrf_drv_common_irq_disable(nrf_drv_get_IRQn((void *)p_instance->reg.p_uarte)); - ) - CODE_FOR_UART - ( - nrf_uart_int_disable(p_instance->reg.p_uart, NRF_UART_INT_MASK_RXDRDY | - NRF_UART_INT_MASK_TXDRDY | - NRF_UART_INT_MASK_ERROR | - NRF_UART_INT_MASK_RXTO); - nrf_drv_common_irq_disable(nrf_drv_get_IRQn((void *)p_instance->reg.p_uart)); - ) - -} - -__STATIC_INLINE void pins_to_default(const nrf_drv_uart_t * p_instance) -{ - /* Reset pins to default states */ - uint32_t txd; - uint32_t rxd; - uint32_t rts; - uint32_t cts; - - CODE_FOR_UARTE - ( - txd = nrf_uarte_tx_pin_get(p_instance->reg.p_uarte); - rxd = nrf_uarte_rx_pin_get(p_instance->reg.p_uarte); - rts = nrf_uarte_rts_pin_get(p_instance->reg.p_uarte); - cts = nrf_uarte_cts_pin_get(p_instance->reg.p_uarte); - nrf_uarte_txrx_pins_disconnect(p_instance->reg.p_uarte); - nrf_uarte_hwfc_pins_disconnect(p_instance->reg.p_uarte); - ) - CODE_FOR_UART - ( - txd = nrf_uart_tx_pin_get(p_instance->reg.p_uart); - rxd = nrf_uart_rx_pin_get(p_instance->reg.p_uart); - rts = nrf_uart_rts_pin_get(p_instance->reg.p_uart); - cts = nrf_uart_cts_pin_get(p_instance->reg.p_uart); - nrf_uart_txrx_pins_disconnect(p_instance->reg.p_uart); - nrf_uart_hwfc_pins_disconnect(p_instance->reg.p_uart); - ) - - if (txd != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_default(txd); - } - - if (rxd != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_default(rxd); - } - - if (cts != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_default(cts); - } - - if (rts != NRF_UART_PSEL_DISCONNECTED) - { - nrf_gpio_cfg_default(rts); - } - -} - -__STATIC_INLINE void uart_enable(const nrf_drv_uart_t * p_instance) -{ - CODE_FOR_UARTE(nrf_uarte_enable(p_instance->reg.p_uarte);) - CODE_FOR_UART(nrf_uart_enable(p_instance->reg.p_uart);); -} - -__STATIC_INLINE void uart_disable(const nrf_drv_uart_t * p_instance) -{ - CODE_FOR_UARTE(nrf_uarte_disable(p_instance->reg.p_uarte);) - CODE_FOR_UART(nrf_uart_disable(p_instance->reg.p_uart);); -} - -ret_code_t nrf_drv_uart_init(const nrf_drv_uart_t * p_instance, nrf_drv_uart_config_t const * p_config, - nrf_uart_event_handler_t event_handler) -{ - ASSERT(p_config); - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ret_code_t err_code = NRF_SUCCESS; - - if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED) - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_ERROR("Init failed. id:%d in wrong state", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); - return err_code; - } - -#if (defined(UARTE_IN_USE) && defined(UART_IN_USE)) - p_cb->use_easy_dma = p_config->use_easy_dma; -#endif - apply_config(p_instance, p_config); - - p_cb->handler = event_handler; - p_cb->p_context = p_config->p_context; - - if (p_cb->handler) - { - interrupts_enable(p_instance, p_config->interrupt_priority); - } - - uart_enable(p_instance); - p_cb->rx_buffer_length = 0; - p_cb->rx_secondary_buffer_length = 0; - p_cb->tx_buffer_length = 0; - p_cb->state = NRF_DRV_STATE_INITIALIZED; - p_cb->rx_enabled = false; - return err_code; -} - -void nrf_drv_uart_uninit(const nrf_drv_uart_t * p_instance) -{ - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - - uart_disable(p_instance); - - if (p_cb->handler) - { - interrupts_disable(p_instance); - } - - pins_to_default(p_instance); - - p_cb->state = NRF_DRV_STATE_UNINITIALIZED; - p_cb->handler = NULL; - NRF_LOG_INFO("Uninit id: %d.", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); -} - -#if defined(UART_IN_USE) -__STATIC_INLINE void tx_byte(NRF_UART_Type * p_uart, uart_control_block_t * p_cb) -{ - nrf_uart_event_clear(p_uart, NRF_UART_EVENT_TXDRDY); - uint8_t txd = p_cb->p_tx_buffer[p_cb->tx_counter]; - p_cb->tx_counter++; - nrf_uart_txd_set(p_uart, txd); -} - -__STATIC_INLINE ret_code_t nrf_drv_uart_tx_for_uart(const nrf_drv_uart_t * p_instance) -{ - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ret_code_t err_code = NRF_SUCCESS; - - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_TXDRDY); - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STARTTX); - - tx_byte(p_instance->reg.p_uart, p_cb); - - if (p_cb->handler == NULL) - { - while (p_cb->tx_counter < (uint16_t) p_cb->tx_buffer_length) - { - while (!nrf_uart_event_check(p_instance->reg.p_uart, NRF_UART_EVENT_TXDRDY) && - p_cb->tx_counter != TX_COUNTER_ABORT_REQ_VALUE) - { - } - if (p_cb->tx_counter != TX_COUNTER_ABORT_REQ_VALUE) - { - tx_byte(p_instance->reg.p_uart, p_cb); - } - } - - if (p_cb->tx_counter == TX_COUNTER_ABORT_REQ_VALUE) - { - err_code = NRF_ERROR_FORBIDDEN; - } - else - { - while (!nrf_uart_event_check(p_instance->reg.p_uart, NRF_UART_EVENT_TXDRDY)) - { - } - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STOPTX); - } - p_cb->tx_buffer_length = 0; - } - return err_code; -} -#endif - -#if defined(UARTE_IN_USE) -__STATIC_INLINE ret_code_t nrf_drv_uart_tx_for_uarte(const nrf_drv_uart_t * p_instance) -{ - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ret_code_t err_code = NRF_SUCCESS; - - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDTX); - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_TXSTOPPED); - nrf_uarte_tx_buffer_set(p_instance->reg.p_uarte, p_cb->p_tx_buffer, p_cb->tx_buffer_length); - nrf_uarte_task_trigger(p_instance->reg.p_uarte, NRF_UARTE_TASK_STARTTX); - - if (p_cb->handler == NULL) - { - bool endtx; - bool txstopped; - do - { - endtx = nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDTX); - txstopped = nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_TXSTOPPED); - } - while ((!endtx) && (!txstopped)); - - if (txstopped) - { - err_code = NRF_ERROR_FORBIDDEN; - } - p_cb->tx_buffer_length = 0; - } - return err_code; -} -#endif - -ret_code_t nrf_drv_uart_tx(const nrf_drv_uart_t * p_instance, uint8_t const * const p_data, uint8_t length) -{ - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - ASSERT(p_cb->state == NRF_DRV_STATE_INITIALIZED); - ASSERT(length>0); - ASSERT(p_data); - - ret_code_t err_code; - - CODE_FOR_UARTE - ( - // EasyDMA requires that transfer buffers are placed in DataRAM, - // signal error if the are not. - if (!nrf_drv_is_in_RAM(p_data)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_ERROR("Id:%d, Easy-DMA buffer not in RAM: %08x", - nrf_drv_get_IRQn((void *)p_instance->reg.p_reg), p_data); - return err_code; - } - ) - - if (nrf_drv_uart_tx_in_progress(p_instance)) - { - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("Id:%d busy",nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); - return err_code; - } - p_cb->tx_buffer_length = length; - p_cb->p_tx_buffer = p_data; - p_cb->tx_counter = 0; - - NRF_LOG_INFO("TX req id:%d length: %d.", - nrf_drv_get_IRQn((void *)p_instance->reg.p_reg), - p_cb->tx_buffer_length); - NRF_LOG_DEBUG("Tx data:"); - NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_cb->p_tx_buffer, - p_cb->tx_buffer_length * sizeof(p_cb->p_tx_buffer[0])); - - CODE_FOR_UARTE - ( - return nrf_drv_uart_tx_for_uarte(p_instance); - ) - CODE_FOR_UART - ( - return nrf_drv_uart_tx_for_uart(p_instance); - ) -} - -bool nrf_drv_uart_tx_in_progress(const nrf_drv_uart_t * p_instance) -{ - return (m_cb[p_instance->drv_inst_idx].tx_buffer_length != 0); -} - -#if defined(UART_IN_USE) -__STATIC_INLINE void rx_enable(const nrf_drv_uart_t * p_instance) -{ - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_ERROR); - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_RXDRDY); - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STARTRX); -} - -__STATIC_INLINE void rx_byte(NRF_UART_Type * p_uart, uart_control_block_t * p_cb) -{ - if (!p_cb->rx_buffer_length) - { - nrf_uart_event_clear(p_uart, NRF_UART_EVENT_RXDRDY); - // Byte received when buffer is not set - data lost. - (void) nrf_uart_rxd_get(p_uart); - return; - } - nrf_uart_event_clear(p_uart, NRF_UART_EVENT_RXDRDY); - p_cb->p_rx_buffer[p_cb->rx_counter] = nrf_uart_rxd_get(p_uart); - p_cb->rx_counter++; -} - -__STATIC_INLINE ret_code_t nrf_drv_uart_rx_for_uart(const nrf_drv_uart_t * p_instance, uint8_t * p_data, uint8_t length, bool second_buffer) -{ - ret_code_t err_code; - - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - - if ((!p_cb->rx_enabled) && (!second_buffer)) - { - rx_enable(p_instance); - } - - if (p_cb->handler == NULL) - { - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_RXTO); - - bool rxrdy; - bool rxto; - bool error; - do - { - do - { - error = nrf_uart_event_check(p_instance->reg.p_uart, NRF_UART_EVENT_ERROR); - rxrdy = nrf_uart_event_check(p_instance->reg.p_uart, NRF_UART_EVENT_RXDRDY); - rxto = nrf_uart_event_check(p_instance->reg.p_uart, NRF_UART_EVENT_RXTO); - } while ((!rxrdy) && (!rxto) && (!error)); - - if (error || rxto) - { - break; - } - rx_byte(p_instance->reg.p_uart, p_cb); - } while (p_cb->rx_buffer_length > p_cb->rx_counter); - - p_cb->rx_buffer_length = 0; - if (error) - { - err_code = NRF_ERROR_INTERNAL; - NRF_LOG_WARNING("RX Id: %d, transfer error.", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); - return err_code; - } - - if (rxto) - { - NRF_LOG_WARNING("RX Id: %d, aborted.", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); - err_code = NRF_ERROR_FORBIDDEN; - return err_code; - } - - if (p_cb->rx_enabled) - { - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STARTRX); - } - else - { - // Skip stopping RX if driver is forced to be enabled. - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STOPRX); - } - } - else - { - nrf_uart_int_enable(p_instance->reg.p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_ERROR); - } - err_code = NRF_SUCCESS; - return err_code; -} -#endif - -#if defined(UARTE_IN_USE) -__STATIC_INLINE ret_code_t nrf_drv_uart_rx_for_uarte(const nrf_drv_uart_t * p_instance, uint8_t * p_data, uint8_t length, bool second_buffer) -{ - ret_code_t err_code = NRF_SUCCESS; - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDRX); - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_RXTO); - nrf_uarte_rx_buffer_set(p_instance->reg.p_uarte, p_data, length); - if (!second_buffer) - { - nrf_uarte_task_trigger(p_instance->reg.p_uarte, NRF_UARTE_TASK_STARTRX); - } - else - { - nrf_uarte_shorts_enable(p_instance->reg.p_uarte, NRF_UARTE_SHORT_ENDRX_STARTRX); - } - - if (m_cb[p_instance->drv_inst_idx].handler == NULL) - { - bool endrx; - bool rxto; - bool error; - do { - endrx = nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDRX); - rxto = nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_RXTO); - error = nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ERROR); - }while ((!endrx) && (!rxto) && (!error)); - - m_cb[p_instance->drv_inst_idx].rx_buffer_length = 0; - - if (error) - { - err_code = NRF_ERROR_INTERNAL; - } - - if (rxto) - { - err_code = NRF_ERROR_FORBIDDEN; - } - } - else - { - nrf_uarte_int_enable(p_instance->reg.p_uarte, NRF_UARTE_INT_ERROR_MASK | NRF_UARTE_INT_ENDRX_MASK); - } - return err_code; -} -#endif - -ret_code_t nrf_drv_uart_rx(const nrf_drv_uart_t * p_instance, uint8_t * p_data, uint8_t length) -{ - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - - ASSERT(m_cb[p_instance->drv_inst_idx].state == NRF_DRV_STATE_INITIALIZED); - ASSERT(length>0); - - ret_code_t err_code; - - CODE_FOR_UARTE - ( - // EasyDMA requires that transfer buffers are placed in DataRAM, - // signal error if the are not. - if (!nrf_drv_is_in_RAM(p_data)) - { - err_code = NRF_ERROR_INVALID_ADDR; - NRF_LOG_ERROR("Id:%d, Easy-DMA buffer not in RAM: %08x", - nrf_drv_get_IRQn((void *)p_instance->reg.p_reg), p_data); - return err_code; - } - ) - - bool second_buffer = false; - - if (p_cb->handler) - { - CODE_FOR_UARTE - ( - nrf_uarte_int_disable(p_instance->reg.p_uarte, NRF_UARTE_INT_ERROR_MASK | NRF_UARTE_INT_ENDRX_MASK); - ) - CODE_FOR_UART - ( - nrf_uart_int_disable(p_instance->reg.p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_ERROR); - ) - } - if (p_cb->rx_buffer_length != 0) - { - if (p_cb->rx_secondary_buffer_length != 0) - { - if (p_cb->handler) - { - CODE_FOR_UARTE - ( - nrf_uarte_int_enable(p_instance->reg.p_uarte, NRF_UARTE_INT_ERROR_MASK | NRF_UARTE_INT_ENDRX_MASK); - ) - CODE_FOR_UART - ( - nrf_uart_int_enable(p_instance->reg.p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_ERROR); - ) - } - err_code = NRF_ERROR_BUSY; - NRF_LOG_WARNING("RX Id:%d, busy", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); - return err_code; - } - second_buffer = true; - } - - if (!second_buffer) - { - p_cb->rx_buffer_length = length; - p_cb->p_rx_buffer = p_data; - p_cb->rx_counter = 0; - p_cb->rx_secondary_buffer_length = 0; - } - else - { - p_cb->p_rx_secondary_buffer = p_data; - p_cb->rx_secondary_buffer_length = length; - } - - NRF_LOG_INFO("RX Id:%d len:%d", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg), length); - - CODE_FOR_UARTE - ( - return nrf_drv_uart_rx_for_uarte(p_instance, p_data, length, second_buffer); - ) - CODE_FOR_UART - ( - return nrf_drv_uart_rx_for_uart(p_instance, p_data, length, second_buffer); - ) -} - -bool nrf_drv_uart_rx_ready(nrf_drv_uart_t const * p_instance) -{ - CODE_FOR_UARTE - ( - return nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ENDRX); - ) - CODE_FOR_UART - ( - return nrf_uart_event_check(p_instance->reg.p_uart, NRF_UART_EVENT_RXDRDY); - ) -} - -void nrf_drv_uart_rx_enable(const nrf_drv_uart_t * p_instance) -{ - //Easy dma mode does not support enabling receiver without setting up buffer. - CODE_FOR_UARTE - ( - ASSERT(false); - ) - CODE_FOR_UART - ( - if (!m_cb[p_instance->drv_inst_idx].rx_enabled) - { - rx_enable(p_instance); - m_cb[p_instance->drv_inst_idx].rx_enabled = true; - } - ) -} - -void nrf_drv_uart_rx_disable(const nrf_drv_uart_t * p_instance) -{ - //Easy dma mode does not support enabling receiver without setting up buffer. - CODE_FOR_UARTE - ( - ASSERT(false); - ) - CODE_FOR_UART - ( - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STOPRX); - m_cb[p_instance->drv_inst_idx].rx_enabled = false; - ) -} - -uint32_t nrf_drv_uart_errorsrc_get(const nrf_drv_uart_t * p_instance) -{ - uint32_t errsrc; - CODE_FOR_UARTE - ( - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_ERROR); - errsrc = nrf_uarte_errorsrc_get_and_clear(p_instance->reg.p_uarte); - ) - CODE_FOR_UART - ( - nrf_uart_event_clear(p_instance->reg.p_uart, NRF_UART_EVENT_ERROR); - errsrc = nrf_uart_errorsrc_get_and_clear(p_instance->reg.p_uart); - ) - return errsrc; -} - -__STATIC_INLINE void rx_done_event(uart_control_block_t * p_cb, uint8_t bytes, uint8_t * p_data) -{ - nrf_drv_uart_event_t event; - - event.type = NRF_DRV_UART_EVT_RX_DONE; - event.data.rxtx.bytes = bytes; - event.data.rxtx.p_data = p_data; - - p_cb->handler(&event, p_cb->p_context); -} - -__STATIC_INLINE void tx_done_event(uart_control_block_t * p_cb, uint8_t bytes) -{ - nrf_drv_uart_event_t event; - - event.type = NRF_DRV_UART_EVT_TX_DONE; - event.data.rxtx.bytes = bytes; - event.data.rxtx.p_data = (uint8_t *)p_cb->p_tx_buffer; - - p_cb->tx_buffer_length = 0; - - NRF_LOG_INFO("TX done len:%d", bytes); - p_cb->handler(&event, p_cb->p_context); -} - -void nrf_drv_uart_tx_abort(const nrf_drv_uart_t * p_instance) -{ - uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; - - CODE_FOR_UARTE - ( - nrf_uarte_event_clear(p_instance->reg.p_uarte, NRF_UARTE_EVENT_TXSTOPPED); - nrf_uarte_task_trigger(p_instance->reg.p_uarte, NRF_UARTE_TASK_STOPTX); - if (p_cb->handler == NULL) - { - while (!nrf_uarte_event_check(p_instance->reg.p_uarte, NRF_UARTE_EVENT_TXSTOPPED)); - } - ) - CODE_FOR_UART - ( - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STOPTX); - if (p_cb->handler) - { - tx_done_event(p_cb, p_cb->tx_counter); - } - else - { - p_cb->tx_counter = TX_COUNTER_ABORT_REQ_VALUE; - } - ) - NRF_LOG_INFO("TX abort Id:%d", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); -} - -void nrf_drv_uart_rx_abort(const nrf_drv_uart_t * p_instance) -{ - CODE_FOR_UARTE - ( - nrf_uarte_task_trigger(p_instance->reg.p_uarte, NRF_UARTE_TASK_STOPRX); - ) - CODE_FOR_UART - ( - nrf_uart_int_disable(p_instance->reg.p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_ERROR); - nrf_uart_task_trigger(p_instance->reg.p_uart, NRF_UART_TASK_STOPRX); - ) - NRF_LOG_INFO("RX abort Id:%d", nrf_drv_get_IRQn((void *)p_instance->reg.p_reg)); -} - - -#if defined(UART_IN_USE) -__STATIC_INLINE void uart_irq_handler(NRF_UART_Type * p_uart, uart_control_block_t * p_cb) -{ - if (nrf_uart_int_enable_check(p_uart, NRF_UART_INT_MASK_ERROR) && - nrf_uart_event_check(p_uart, NRF_UART_EVENT_ERROR)) - { - nrf_drv_uart_event_t event; - nrf_uart_event_clear(p_uart, NRF_UART_EVENT_ERROR); - nrf_uart_int_disable(p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_ERROR); - if (!p_cb->rx_enabled) - { - nrf_uart_task_trigger(p_uart, NRF_UART_TASK_STOPRX); - } - event.type = NRF_DRV_UART_EVT_ERROR; - event.data.error.error_mask = nrf_uart_errorsrc_get_and_clear(p_uart); - event.data.error.rxtx.bytes = p_cb->rx_buffer_length; - event.data.error.rxtx.p_data = p_cb->p_rx_buffer; - - //abort transfer - p_cb->rx_buffer_length = 0; - p_cb->rx_secondary_buffer_length = 0; - - p_cb->handler(&event,p_cb->p_context); - } - else if (nrf_uart_int_enable_check(p_uart, NRF_UART_INT_MASK_RXDRDY) && - nrf_uart_event_check(p_uart, NRF_UART_EVENT_RXDRDY)) - { - rx_byte(p_uart, p_cb); - if (p_cb->rx_buffer_length == p_cb->rx_counter) - { - if (p_cb->rx_secondary_buffer_length) - { - uint8_t * p_data = p_cb->p_rx_buffer; - uint8_t rx_counter = p_cb->rx_counter; - - //Switch to secondary buffer. - p_cb->rx_buffer_length = p_cb->rx_secondary_buffer_length; - p_cb->p_rx_buffer = p_cb->p_rx_secondary_buffer; - p_cb->rx_secondary_buffer_length = 0; - p_cb->rx_counter = 0; - rx_done_event(p_cb, rx_counter, p_data); - } - else - { - if (!p_cb->rx_enabled) - { - nrf_uart_task_trigger(p_uart, NRF_UART_TASK_STOPRX); - } - nrf_uart_int_disable(p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_ERROR); - p_cb->rx_buffer_length = 0; - rx_done_event(p_cb, p_cb->rx_counter, p_cb->p_rx_buffer); - } - } - } - - if (nrf_uart_event_check(p_uart, NRF_UART_EVENT_TXDRDY)) - { - if (p_cb->tx_counter < (uint16_t) p_cb->tx_buffer_length) - { - tx_byte(p_uart, p_cb); - } - else - { - nrf_uart_event_clear(p_uart, NRF_UART_EVENT_TXDRDY); - if (p_cb->tx_buffer_length) - { - tx_done_event(p_cb, p_cb->tx_buffer_length); - } - } - } - - if (nrf_uart_event_check(p_uart, NRF_UART_EVENT_RXTO)) - { - nrf_uart_event_clear(p_uart, NRF_UART_EVENT_RXTO); - - // RXTO event may be triggered as a result of abort call. In th - if (p_cb->rx_enabled) - { - nrf_uart_task_trigger(p_uart, NRF_UART_TASK_STARTRX); - } - if (p_cb->rx_buffer_length) - { - p_cb->rx_buffer_length = 0; - rx_done_event(p_cb, p_cb->rx_counter, p_cb->p_rx_buffer); - } - } -} -#endif - -#if defined(UARTE_IN_USE) -__STATIC_INLINE void uarte_irq_handler(NRF_UARTE_Type * p_uarte, uart_control_block_t * p_cb) -{ - if (nrf_uarte_event_check(p_uarte, NRF_UARTE_EVENT_ERROR)) - { - nrf_drv_uart_event_t event; - - nrf_uarte_event_clear(p_uarte, NRF_UARTE_EVENT_ERROR); - - event.type = NRF_DRV_UART_EVT_ERROR; - event.data.error.error_mask = nrf_uarte_errorsrc_get_and_clear(p_uarte); - event.data.error.rxtx.bytes = nrf_uarte_rx_amount_get(p_uarte); - event.data.error.rxtx.p_data = p_cb->p_rx_buffer; - - //abort transfer - p_cb->rx_buffer_length = 0; - p_cb->rx_secondary_buffer_length = 0; - - p_cb->handler(&event, p_cb->p_context); - } - else if (nrf_uarte_event_check(p_uarte, NRF_UARTE_EVENT_ENDRX)) - { - nrf_uarte_event_clear(p_uarte, NRF_UARTE_EVENT_ENDRX); - uint8_t amount = nrf_uarte_rx_amount_get(p_uarte); - // If the transfer was stopped before completion, amount of transfered bytes - // will not be equal to the buffer length. Interrupted trunsfer is ignored. - if (amount == p_cb->rx_buffer_length) - { - if (p_cb->rx_secondary_buffer_length) - { - uint8_t * p_data = p_cb->p_rx_buffer; - nrf_uarte_shorts_disable(p_uarte, NRF_UARTE_SHORT_ENDRX_STARTRX); - p_cb->rx_buffer_length = p_cb->rx_secondary_buffer_length; - p_cb->p_rx_buffer = p_cb->p_rx_secondary_buffer; - p_cb->rx_secondary_buffer_length = 0; - rx_done_event(p_cb, amount, p_data); - } - else - { - p_cb->rx_buffer_length = 0; - rx_done_event(p_cb, amount, p_cb->p_rx_buffer); - } - } - } - - if (nrf_uarte_event_check(p_uarte, NRF_UARTE_EVENT_RXTO)) - { - nrf_uarte_event_clear(p_uarte, NRF_UARTE_EVENT_RXTO); - if (p_cb->rx_buffer_length) - { - p_cb->rx_buffer_length = 0; - rx_done_event(p_cb, nrf_uarte_rx_amount_get(p_uarte), p_cb->p_rx_buffer); - } - } - - if (nrf_uarte_event_check(p_uarte, NRF_UARTE_EVENT_ENDTX)) - { - nrf_uarte_event_clear(p_uarte, NRF_UARTE_EVENT_ENDTX); - if (p_cb->tx_buffer_length) - { - tx_done_event(p_cb, nrf_uarte_tx_amount_get(p_uarte)); - } - } -} -#endif - -#if UART0_ENABLED -IRQ_HANDLER(0) -{ - CODE_FOR_UARTE_INT - ( - UART0_INSTANCE_INDEX, - uarte_irq_handler(NRF_UARTE0, &m_cb[UART0_INSTANCE_INDEX]); - ) - CODE_FOR_UART - ( - uart_irq_handler(NRF_UART0, &m_cb[UART0_INSTANCE_INDEX]); - ) -} -#endif - -#if UART1_ENABLED -void UARTE1_IRQHandler(void) -{ - CODE_FOR_UARTE_INT - ( - UART1_INSTANCE_INDEX, - uarte_irq_handler(NRF_UARTE1, &m_cb[UART1_INSTANCE_INDEX]); - ) - CODE_FOR_UART - ( - uart_irq_handler(NRF_UART1, &m_cb[UART1_INSTANCE_INDEX]); - ) -} -#endif -#endif //NRF_MODULE_ENABLED(UART) - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.h deleted file mode 100644 index 3821922..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/uart/nrf_drv_uart.h +++ /dev/null @@ -1,465 +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 - * @addtogroup nrf_uart UART driver and HAL - * @ingroup nrf_drivers - * @brief UART API. - * @details The UART driver provides APIs for utilizing the UART peripheral. - * - * @defgroup nrf_drv_uart UART driver - * @{ - * @ingroup nrf_uart - * - * @brief UART driver. - */ - -#ifndef NRF_DRV_UART_H -#define NRF_DRV_UART_H - -#include "nrf_peripherals.h" - -#ifdef UART_PRESENT -#include "nrf_uart.h" -#endif - -#ifdef UARTE_PRESENT -#include "nrf_uarte.h" -#endif - -#include "sdk_errors.h" -#include "sdk_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef UART1_ENABLED -#define UART1_ENABLED 0 -#endif - -#ifndef UART0_ENABLED -#define UART0_ENABLED 0 -#endif - -#define UART0_INSTANCE_INDEX 0 -#define UART1_INSTANCE_INDEX UART0_ENABLED -#define UART_ENABLED_COUNT UART0_ENABLED + UART1_ENABLED - -#if defined(UARTE_PRESENT) && defined(UART_PRESENT) - #define NRF_DRV_UART_PERIPHERAL(id) \ - (CONCAT_3(UART, id, _CONFIG_USE_EASY_DMA) == 1 ? \ - (void *)CONCAT_2(NRF_UARTE, id) \ - : (void *)CONCAT_2(NRF_UART, id)) -#elif defined(UART_PRESENT) - #define NRF_DRV_UART_PERIPHERAL(id) (void *)CONCAT_2(NRF_UART, id) -#else //UARTE_PRESENT !UART_PRESENT - #define NRF_DRV_UART_PERIPHERAL(id) (void *)CONCAT_2(NRF_UARTE, id) -#endif - -// This set of macros makes it possible to exclude parts of code, when one type -// of supported peripherals is not used. - -#if defined(UARTE_PRESENT) && defined(UART_PRESENT) - -#if (UART_EASY_DMA_SUPPORT == 1) -#define UARTE_IN_USE -#endif - -#if (UART_LEGACY_SUPPORT == 1) -#define UART_IN_USE -#endif - -#if (UART_ENABLED == 1) && ((!defined(UARTE_IN_USE) && !defined(UART_IN_USE)) || ((UART_EASY_DMA_SUPPORT == 0) && (UART_LEGACY_SUPPORT == 0))) -#error "Illegal settings in uart module!" -#endif - -#elif defined(UART_PRESENT) -#define UART_IN_USE -#elif defined(UARTE_PRESENT) -#define UARTE_IN_USE -#endif - -#if defined(UARTE_PRESENT) && !defined(UART_PRESENT) -typedef nrf_uarte_hwfc_t nrf_uart_hwfc_t; -typedef nrf_uarte_parity_t nrf_uart_parity_t; -typedef nrf_uarte_baudrate_t nrf_uart_baudrate_t; -typedef nrf_uarte_error_mask_t nrf_uart_error_mask_t; -typedef nrf_uarte_task_t nrf_uart_task_t; -typedef nrf_uarte_event_t nrf_uart_event_t; -#ifndef NRF_UART_PSEL_DISCONNECTED -#define NRF_UART_PSEL_DISCONNECTED 0xFFFFFFFF -#endif -#endif - -/** - * @brief Structure for the UART driver instance. - */ -typedef struct -{ - union - { -#if (defined(UARTE_IN_USE)) - NRF_UARTE_Type * p_uarte; ///< Pointer to a structure with UARTE registers. -#endif -#if (defined(UART_IN_USE) || (UART_ENABLED == 0)) - NRF_UART_Type * p_uart; ///< Pointer to a structure with UART registers. -#endif - void * p_reg; - } reg; - uint8_t drv_inst_idx; ///< Driver instance index. -} nrf_drv_uart_t; - -/** - * @brief Macro for creating an UART driver instance. - */ -#define NRF_DRV_UART_INSTANCE(id) \ -{ \ - .reg = {NRF_DRV_UART_PERIPHERAL(id)}, \ - .drv_inst_idx = CONCAT_3(UART, id, _INSTANCE_INDEX),\ -} - -/** - * @brief Types of UART driver events. - */ -typedef enum -{ - NRF_DRV_UART_EVT_TX_DONE, ///< Requested TX transfer completed. - NRF_DRV_UART_EVT_RX_DONE, ///< Requested RX transfer completed. - NRF_DRV_UART_EVT_ERROR, ///< Error reported by UART peripheral. -} nrf_drv_uart_evt_type_t; - -/**@brief Structure for UART configuration. */ -typedef struct -{ - uint32_t pseltxd; ///< TXD pin number. - uint32_t pselrxd; ///< RXD pin number. - uint32_t pselcts; ///< CTS pin number. - uint32_t pselrts; ///< RTS pin number. - void * p_context; ///< Context passed to interrupt handler. - nrf_uart_hwfc_t hwfc; ///< Flow control configuration. - nrf_uart_parity_t parity; ///< Parity configuration. - nrf_uart_baudrate_t baudrate; ///< Baudrate. - uint8_t interrupt_priority; ///< Interrupt priority. -#ifdef UARTE_PRESENT - bool use_easy_dma; -#endif -} nrf_drv_uart_config_t; - -/**@brief UART default configuration. */ -#ifdef UARTE_PRESENT -#if !UART_LEGACY_SUPPORT -#define DEFAULT_CONFIG_USE_EASY_DMA true -#elif !UART_EASY_DMA_SUPPORT -#define DEFAULT_CONFIG_USE_EASY_DMA false -#else -#define DEFAULT_CONFIG_USE_EASY_DMA UART0_USE_EASY_DMA -#endif -#define NRF_DRV_UART_DEFAULT_CONFIG \ - { \ - .pseltxd = NRF_UART_PSEL_DISCONNECTED, \ - .pselrxd = NRF_UART_PSEL_DISCONNECTED, \ - .pselcts = NRF_UART_PSEL_DISCONNECTED, \ - .pselrts = NRF_UART_PSEL_DISCONNECTED, \ - .p_context = NULL, \ - .hwfc = (nrf_uart_hwfc_t)UART_DEFAULT_CONFIG_HWFC, \ - .parity = (nrf_uart_parity_t)UART_DEFAULT_CONFIG_PARITY, \ - .baudrate = (nrf_uart_baudrate_t)UART_DEFAULT_CONFIG_BAUDRATE, \ - .interrupt_priority = UART_DEFAULT_CONFIG_IRQ_PRIORITY, \ - .use_easy_dma = true \ - } -#else -#define NRF_DRV_UART_DEFAULT_CONFIG \ - { \ - .pseltxd = NRF_UART_PSEL_DISCONNECTED, \ - .pselrxd = NRF_UART_PSEL_DISCONNECTED, \ - .pselcts = NRF_UART_PSEL_DISCONNECTED, \ - .pselrts = NRF_UART_PSEL_DISCONNECTED, \ - .p_context = NULL, \ - .hwfc = (nrf_uart_hwfc_t)UART_DEFAULT_CONFIG_HWFC, \ - .parity = (nrf_uart_parity_t)UART_DEFAULT_CONFIG_PARITY, \ - .baudrate = (nrf_uart_baudrate_t)UART_DEFAULT_CONFIG_BAUDRATE, \ - .interrupt_priority = UART_DEFAULT_CONFIG_IRQ_PRIORITY, \ - } -#endif - -/**@brief Structure for UART transfer completion event. */ -typedef struct -{ - uint8_t * p_data; ///< Pointer to memory used for transfer. - uint8_t bytes; ///< Number of bytes transfered. -} nrf_drv_uart_xfer_evt_t; - -/**@brief Structure for UART error event. */ -typedef struct -{ - nrf_drv_uart_xfer_evt_t rxtx; ///< Transfer details includes number of bytes transfered. - uint32_t error_mask;///< Mask of error flags that generated the event. -} nrf_drv_uart_error_evt_t; - -/**@brief Structure for UART event. */ -typedef struct -{ - nrf_drv_uart_evt_type_t type; ///< Event type. - union - { - nrf_drv_uart_xfer_evt_t rxtx; ///< Data provided for transfer completion events. - nrf_drv_uart_error_evt_t error;///< Data provided for error event. - } data; -} nrf_drv_uart_event_t; - -/** - * @brief UART interrupt event handler. - * - * @param[in] p_event Pointer to event structure. Event is allocated on the stack so it is available - * only within the context of the event handler. - * @param[in] p_context Context passed to interrupt handler, set on initialization. - */ -typedef void (*nrf_uart_event_handler_t)(nrf_drv_uart_event_t * p_event, void * p_context); - -/** - * @brief Function for initializing the UART driver. - * - * This function configures and enables UART. After this function GPIO pins are controlled by UART. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_config Initial configuration. - * @param[in] event_handler Event handler provided by the user. If not provided driver works in - * blocking mode. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If driver is already initialized. - */ -ret_code_t nrf_drv_uart_init(nrf_drv_uart_t const * p_instance, - nrf_drv_uart_config_t const * p_config, - nrf_uart_event_handler_t event_handler); - -/** - * @brief Function for uninitializing the UART driver. - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_uart_uninit(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for getting the address of a specific UART task. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_uart_task_address_get(nrf_drv_uart_t const * p_instance, - nrf_uart_task_t task); - -/** - * @brief Function for getting the address of a specific UART event. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] event Event. - * - * @return Event address. - */ -__STATIC_INLINE uint32_t nrf_drv_uart_event_address_get(nrf_drv_uart_t const * p_instance, - nrf_uart_event_t event); - -/** - * @brief Function for sending data over UART. - * - * If an event handler was provided in nrf_drv_uart_init() call, this function - * returns immediately and the handler is called when the transfer is done. - * Otherwise, the transfer is performed in blocking mode, i.e. this function - * returns when the transfer is finished. Blocking mode is not using interrupt so - * there is no context switching inside the function. - * - * @note Peripherals using EasyDMA (i.e. UARTE) require that the transfer buffers - * are placed in the Data RAM region. If they are not and UARTE instance is - * used, this function will fail with error code NRF_ERROR_INVALID_ADDR. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_data Pointer to data. - * @param[in] length Number of bytes to send. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_BUSY If driver is already transferring. - * @retval NRF_ERROR_FORBIDDEN If the transfer was aborted from a different context - * (blocking mode only, also see @ref nrf_drv_uart_rx_disable). - * @retval NRF_ERROR_INVALID_ADDR If p_data does not point to RAM buffer (UARTE only). - */ -ret_code_t nrf_drv_uart_tx(nrf_drv_uart_t const * p_instance, - uint8_t const * const p_data, uint8_t length); - -/** - * @brief Function for checking if UART is currently transmitting. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true If UART is transmitting. - * @retval false If UART is not transmitting. - */ -bool nrf_drv_uart_tx_in_progress(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for aborting any ongoing transmission. - * @note @ref NRF_DRV_UART_EVT_TX_DONE event will be generated in non-blocking mode. Event will - * contain number of bytes sent until abort was called. If Easy DMA is not used event will be - * called from the function context. If Easy DMA is used it will be called from UART interrupt - * context. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_uart_tx_abort(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for receiving data over UART. - * - * If an event handler was provided in the nrf_drv_uart_init() call, this function - * returns immediately and the handler is called when the transfer is done. - * Otherwise, the transfer is performed in blocking mode, i.e. this function - * returns when the transfer is finished. Blocking mode is not using interrupt so - * there is no context switching inside the function. - * The receive buffer pointer is double buffered in non-blocking mode. The secondary - * buffer can be set immediately after starting the transfer and will be filled - * when the primary buffer is full. The double buffering feature allows - * receiving data continuously. - * - * @note Peripherals using EasyDMA (i.e. UARTE) require that the transfer buffers - * are placed in the Data RAM region. If they are not and UARTE driver instance - * is used, this function will fail with error code NRF_ERROR_INVALID_ADDR. - * - * @param[in] p_instance Pointer to the driver instance structure. - * @param[in] p_data Pointer to data. - * @param[in] length Number of bytes to receive. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_BUSY If the driver is already receiving - * (and the secondary buffer has already been set - * in non-blocking mode). - * @retval NRF_ERROR_FORBIDDEN If the transfer was aborted from a different context - * (blocking mode only, also see @ref nrf_drv_uart_rx_disable). - * @retval NRF_ERROR_INTERNAL If UART peripheral reported an error. - * @retval NRF_ERROR_INVALID_ADDR If p_data does not point to RAM buffer (UARTE only). - */ -ret_code_t nrf_drv_uart_rx(nrf_drv_uart_t const * p_instance, - uint8_t * p_data, uint8_t length); - - - -/** - * @brief Function for testing the receiver state in blocking mode. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval true If the receiver has at least one byte of data to get. - * @retval false If the receiver is empty. - */ -bool nrf_drv_uart_rx_ready(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for enabling the receiver. - * - * UART has a 6-byte-long RX FIFO and it is used to store incoming data. If a user does not call the - * UART receive function before the FIFO is filled, an overrun error will appear. Enabling the receiver - * without specifying an RX buffer is supported only in UART mode (without Easy DMA). The receiver must be - * explicitly closed by the user @sa nrf_drv_uart_rx_disable. This function asserts if the mode is wrong. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_uart_rx_enable(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for disabling the receiver. - * - * This function must be called to close the receiver after it has been explicitly enabled by - * @sa nrf_drv_uart_rx_enable. The feature is supported only in UART mode (without Easy DMA). The function - * asserts if mode is wrong. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_uart_rx_disable(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for aborting any ongoing reception. - * @note @ref NRF_DRV_UART_EVT_RX_DONE event will be generated in non-blocking mode. The event will - * contain the number of bytes received until abort was called. The event is called from UART interrupt - * context. - * - * @param[in] p_instance Pointer to the driver instance structure. - */ -void nrf_drv_uart_rx_abort(nrf_drv_uart_t const * p_instance); - -/** - * @brief Function for reading error source mask. Mask contains values from @ref nrf_uart_error_mask_t. - * @note Function should be used in blocking mode only. In case of non-blocking mode, an error event is - * generated. Function clears error sources after reading. - * - * @param[in] p_instance Pointer to the driver instance structure. - * - * @retval Mask of reported errors. - */ -uint32_t nrf_drv_uart_errorsrc_get(nrf_drv_uart_t const * p_instance); - - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION -__STATIC_INLINE uint32_t nrf_drv_uart_task_address_get(nrf_drv_uart_t const * p_instance, - nrf_uart_task_t task) -{ -#ifdef UART_IN_USE - return nrf_uart_task_address_get(p_instance->reg.p_uart, task); -#else - return nrf_uarte_task_address_get(p_instance->reg.p_uarte, (nrf_uarte_task_t)task); -#endif -} - -__STATIC_INLINE uint32_t nrf_drv_uart_event_address_get(nrf_drv_uart_t const * p_instance, - nrf_uart_event_t event) -{ -#ifdef UART_IN_USE - return nrf_uart_event_address_get(p_instance->reg.p_uart, event); -#else - return nrf_uarte_event_address_get(p_instance->reg.p_uarte, (nrf_uarte_event_t)event); -#endif -} -#endif //SUPPRESS_INLINE_IMPLEMENTATION - -#ifdef __cplusplus -} -#endif - -#endif //NRF_DRV_UART_H -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd.h deleted file mode 100644 index 25d7b34..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd.h +++ /dev/null @@ -1,947 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_DRV_USBD_H__ -#define NRF_DRV_USBD_H__ - -#include "nrf_drv_common.h" -#include "sdk_errors.h" -#include "nrf_usbd.h" -#include -#include -#include "app_util.h" -#include "nrf_drv_usbd_errata.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup nrf_drv_usbd USB Device HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52840 USB Device APIs. - * @details The USB Device HAL provides basic APIs for accessing - * the registers of the USBD. - * The USB Device driver provides APIs on a higher level. - * - * @{ - */ - -/** - * @name Possible schemes of DMA scheduling - * - * Definition of available configuration constants used by DMA scheduler - * @{ - */ - /** - * @brief Highly prioritized access - * - * Endpoint with lower number has always higher priority and its data would - * be transfered first. - * OUT endpoints ale processed before IN endpoints - */ - #define NRF_DRV_USBD_DMASCHEDULER_PRIORITIZED 0 - - /** - * @brief Round robin scheme - * - * All endpoints are processed in round-robin scheme. - * It means that when one endpoint is processed next in order would be - * the nearest with lower number. - * When no endpoints with lower number requires processing - then - * all endpoints from 0 are tested. - */ - #define NRF_DRV_USBD_DMASCHEDULER_ROUNDROBIN 1 - -/** @} */ - -/** - * @brief Number of bytes in the endpoint - * - * Constant that informs about endpoint size - */ -#define NRF_DRV_USBD_EPSIZE 64 - -/** - * @brief Number of bytes for isochronous endpoints - * - * Number of bytes for isochronous endpoints in total. - * This number would be shared between IN and OUT endpoint. - * It may be also assigned totaly to one endpoint. - * @sa nrf_usbd_isosplit_set - * @sa nrf_usbd_isosplit_get - */ -#define NRF_DRV_USBD_ISOSIZE 1024 - -/** - * @brief The size of internal feeder buffer. - * - * @sa nrf_drv_usbd_feeder_buffer_get - */ -#define NRF_DRV_USBD_FEEDER_BUFFER_SIZE NRF_DRV_USBD_EPSIZE - -/** - * @name Macros for creating endpoint identifiers - * - * Auxiliary macros to be used to create Endpoint identifier that is compatible - * with USB specification. - * @{ - */ - - /** - * @brief Create identifier for IN endpoint - * - * Simple macro to create IN endpoint identifier for given endpoint number. - * - * @param[in] n Endpoint number. - * - * @return Endpoint identifier that connects endpoint number and endpoint direction. - */ - #define NRF_DRV_USBD_EPIN(n) ((nrf_drv_usbd_ep_t)NRF_USBD_EPIN(n)) - /** - * @brief Create identifier for OUT endpoint - * - * Simple macro to create OUT endpoint identifier for given endpoint number. - * - * @param[in] n Endpoint number. - * - * @return Endpoint identifier that connects endpoint number and endpoint direction. - */ - #define NRF_DRV_USBD_EPOUT(n) ((nrf_drv_usbd_ep_t)NRF_USBD_EPOUT(n)) - -/** @} */ - -/** - * @brief Endpoint identifier - * - * Endpoint identifier used in the driver. - * This endpoint number is consistent with USB 2.0 specification. - */ -typedef enum -{ - NRF_DRV_USBD_EPOUT0 = NRF_USBD_EPOUT(0), /**< Endpoint OUT 0 */ - NRF_DRV_USBD_EPOUT1 = NRF_USBD_EPOUT(1), /**< Endpoint OUT 1 */ - NRF_DRV_USBD_EPOUT2 = NRF_USBD_EPOUT(2), /**< Endpoint OUT 2 */ - NRF_DRV_USBD_EPOUT3 = NRF_USBD_EPOUT(3), /**< Endpoint OUT 3 */ - NRF_DRV_USBD_EPOUT4 = NRF_USBD_EPOUT(4), /**< Endpoint OUT 4 */ - NRF_DRV_USBD_EPOUT5 = NRF_USBD_EPOUT(5), /**< Endpoint OUT 5 */ - NRF_DRV_USBD_EPOUT6 = NRF_USBD_EPOUT(6), /**< Endpoint OUT 6 */ - NRF_DRV_USBD_EPOUT7 = NRF_USBD_EPOUT(7), /**< Endpoint OUT 7 */ - NRF_DRV_USBD_EPOUT8 = NRF_USBD_EPOUT(8), /**< Endpoint OUT 8 */ - - NRF_DRV_USBD_EPIN0 = NRF_USBD_EPIN(0), /**< Endpoint IN 0 */ - NRF_DRV_USBD_EPIN1 = NRF_USBD_EPIN(1), /**< Endpoint IN 1 */ - NRF_DRV_USBD_EPIN2 = NRF_USBD_EPIN(2), /**< Endpoint IN 2 */ - NRF_DRV_USBD_EPIN3 = NRF_USBD_EPIN(3), /**< Endpoint IN 3 */ - NRF_DRV_USBD_EPIN4 = NRF_USBD_EPIN(4), /**< Endpoint IN 4 */ - NRF_DRV_USBD_EPIN5 = NRF_USBD_EPIN(5), /**< Endpoint IN 5 */ - NRF_DRV_USBD_EPIN6 = NRF_USBD_EPIN(6), /**< Endpoint IN 6 */ - NRF_DRV_USBD_EPIN7 = NRF_USBD_EPIN(7), /**< Endpoint IN 7 */ - NRF_DRV_USBD_EPIN8 = NRF_USBD_EPIN(8), /**< Endpoint IN 8 */ -}nrf_drv_usbd_ep_t; - -/** - * @brief Events generated by the library - * - * Enumeration of possible events that may be generated by the library. - */ -typedef enum -{ - NRF_DRV_USBD_EVT_SOF, /**< Start Of Frame event on USB bus detected */ - NRF_DRV_USBD_EVT_RESET, /**< Reset condition on USB bus detected */ - NRF_DRV_USBD_EVT_SUSPEND, /**< This device should go to suspend mode now */ - NRF_DRV_USBD_EVT_RESUME, /**< This device should resume from suspend now */ - NRF_DRV_USBD_EVT_WUREQ, /**< Wakeup request - the USBD peripheral is ready to generate WAKEUP signal after exiting low power mode. */ - NRF_DRV_USBD_EVT_SETUP, /**< Setup frame received and decoded */ - NRF_DRV_USBD_EVT_EPTRANSFER, /**< - * For Rx (OUT: Host->Device): - * 1. The packet has been received but there is no buffer prepared for transfer already. - * 2. Whole transfer has been finished - * - * For Tx (IN: Device->Host): - * The last packet from requested transfer has been transfered over USB bus and acknowledged - */ - NRF_DRV_USBD_EVT_CNT /**< Number of defined events */ -}nrf_drv_usbd_event_type_t; - -/** - * @brief Possible endpoint error codes - * - * Error codes that may be returned with @ref NRF_DRV_USBD_EVT_EPTRANSFER - */ -typedef enum -{ - NRF_USBD_EP_OK, /**< No error */ - NRF_USBD_EP_WAITING, /**< Data received, no buffer prepared already - waiting for configured transfer */ - NRF_USBD_EP_OVERLOAD, /**< Received number of bytes cannot fit given buffer - * This error would also be returned when next_transfer function has been defined - * but currently received data cannot fit completely in current buffer. - * No data split from single endpoint transmission is supported. - * - * When this error is reported - data is left inside endpoint buffer. - * Clear endpoint or prepare new buffer and read it. - */ - NRF_USBD_EP_ABORTED, /**< EP0 transfer can be aborted when new setup comes. - * Any other transfer can be aborted by USB reset or library stopping. - */ -}nrf_drv_usbd_ep_status_t; - - -/** - * @brief Event structure - * - * Structure passed to event handler - */ -typedef struct -{ - nrf_drv_usbd_event_type_t type; - union - { - struct{ - uint16_t framecnt; //!< Current value of frame counter - }sof; //!< Data aviable for @ref NRF_DRV_USBD_EVT_SOF - struct{ - nrf_drv_usbd_ep_t ep; //!< Endpoint number - }isocrc; - struct{ - nrf_drv_usbd_ep_t ep; //!< Endpoint number - nrf_drv_usbd_ep_status_t status; //!< Status for the endpoint - }eptransfer; - }data; -}nrf_drv_usbd_evt_t; - -/** - * @brief USBD event callback function type. - * - * @param[in] p_event Event information structure. - */ -typedef void (*nrf_drv_usbd_event_handler_t)(nrf_drv_usbd_evt_t const * const p_event); - -/** - * @brief Universal data pointer. - * - * Universal data pointer that can be used for any type of transfer. - */ -typedef union -{ - void const * tx; //!< Constant TX buffer pointer. - void * rx; //!< Writable RX buffer pointer. - uint32_t ptr; //!< Numeric value used internally by the library. -}nrf_drv_usbd_data_ptr_t; - -/** - * @brief Structure to be filled with information about the next transfer. - * - * This is used mainly for transfer feeders and consumers. - * It describes a single endpoint transfer and therefore the size of the buffer - * can never be higher than the endpoint size. - */ -typedef struct -{ - nrf_drv_usbd_data_ptr_t p_data; //!< Union with available data pointers used by the library. - size_t size; //!< Size of the requested transfer. -}nrf_drv_usbd_ep_transfer_t; - -/** - * @brief Flags for the current transfer. - * - * Flags configured for the transfer that can be merged using the bitwise 'or' operator (|). - */ -typedef enum -{ - NRF_DRV_USBD_TRANSFER_ZLP_FLAG = 1U << 0, //!< Add a zero-length packet. -}nrf_drv_usbd_transfer_flags_t; - -/** - * @brief Total transfer configuration. - * - * This structure is used to configure total transfer information. - * It is used by internal built-in feeders and consumers. - */ -typedef struct -{ - nrf_drv_usbd_data_ptr_t p_data; //!< Union with available data pointers used by the library. - size_t size; //!< Total size of the requested transfer. - uint32_t flags; //!< Transfer flags. - /**< Use the @ref nrf_drv_usbd_transfer_flags_t values. */ -}nrf_drv_usbd_transfer_t; - - -/** - * @brief Auxiliary macro for declaring IN transfer description with flags. - * - * The base macro for creating transfers with any configuration option. - * - * @param name Instance name. - * @param tx_buff Buffer to transfer. - * @param tx_size Transfer size. - * @param tx_flags Flags for the transfer (see @ref nrf_drv_usbd_transfer_flags_t). - * - * @return Configured variable with total transfer description. - */ -#define NRF_DRV_USBD_TRANSFER_IN_FLAGS(name, tx_buff, tx_size, tx_flags) \ - const nrf_drv_usbd_transfer_t name = { \ - .p_data = { .tx = (tx_buff) }, \ - .size = (tx_size), \ - .flags = (tx_flags) \ - } - -/** - * @brief Helper macro for declaring IN transfer description - * - * Normal transfer mode, no ZLP would be automatically generated. - * - * @sa nrf_drv_usbd_transfer_t - * @sa NRF_DRV_USBD_TRANSFER_IN_ZLP - * - * @param name Instance name - * @param tx_buff Buffer to transfer - * @param tx_size Transfer size - * - * @return Configured variable with total transfer description - * - */ -#define NRF_DRV_USBD_TRANSFER_IN(name, tx_buff, tx_size) \ - NRF_DRV_USBD_TRANSFER_IN_FLAGS(name, tx_buff, tx_size, 0) - -/** - * @brief Helper macro for declaring IN transfer description - * - * ZLP mode - Zero Length Packet would be generated on the end of the transfer - * (always!). - * - * @sa nrf_drv_usbd_transfer_t - * @sa NRF_DRV_USBD_TRANSFER_IN - * - * @param name Instance name - * @param tx_buff Buffer to transfer - * @param tx_size Transfer size - * - * @return Configured variable with total transfer description - */ -#define NRF_DRV_USBD_TRANSFER_IN_ZLP(name, tx_buff, tx_size) \ - NRF_DRV_USBD_TRANSFER_IN_FLAGS( \ - name, \ - tx_buff, \ - tx_size, \ - NRF_DRV_USBD_TRANSFER_ZLP_FLAG) - -/** - * @brief Helper macro for declaring OUT transfer item (@ref nrf_drv_usbd_transfer_t) - * - * @param name Instance name - * @param rx_buff Buffer to transfer - * @param rx_size Transfer size - * */ -#define NRF_DRV_USBD_TRANSFER_OUT(name, rx_buff, rx_size) \ - const nrf_drv_usbd_transfer_t name = { \ - .p_data = { .rx = (rx_buff) }, \ - .size = (rx_size), \ - .flags = 0 \ - } - -/** - * @brief USBD transfer feeder. - * - * Pointer for a transfer feeder. - * Transfer feeder is a feedback function used to prepare a single - * TX (Device->Host) endpoint transfer. - * - * The transfers provided by the feeder must be simple: - * - The size of the transfer provided by this function is limited to a single endpoint buffer. - * Bigger transfers are not handled automatically in this case. - * - Flash transfers are not automatically supported- you must copy them to the RAM buffer before. - * - * @note - * This function may use @ref nrf_drv_usbd_feeder_buffer_get to gain a temporary buffer - * that can be used to prepare transfer. - * - * @param[out] p_next Structure with the data for the next transfer to be filled. - * Required only if the function returns true. - * @param[in,out] p_context Context variable configured with the transfer. - * @param[in] ep_size The endpoint size. - * - * @retval false The current transfer is the last one - you do not need to call - * the function again. - * @retval true There is more data to be prepared and when the current transfer - * finishes, the feeder function is expected to be called again. - */ -typedef bool (*nrf_drv_usbd_feeder_t)( - nrf_drv_usbd_ep_transfer_t * p_next, - void * p_context, - size_t ep_size); - -/** - * @brief USBD transfer consumer. - * - * Pointer for a transfer consumer. - * Transfer consumer is a feedback function used to prepare a single - * RX (Host->Device) endpoint transfer. - * - * The transfer must provide a buffer big enough to fit the whole data from the endpoint. - * Otherwise, the NRF_USBD_EP_OVERLOAD event is generated. - * - * @param[out] p_next Structure with the data for the next transfer to be filled. - * Required only if the function returns true. - * @param[in,out] p_context Context variable configured with the transfer. - * @param[in] ep_size The endpoint size. - * @param[in] data_size Number of received bytes in the endpoint buffer. - * - * @retval false Current transfer is the last one - you do not need to call - * the function again. - * @retval true There is more data to be prepared and when current transfer - * finishes, the feeder function is expected to be called again. - */ -typedef bool (*nrf_drv_usbd_consumer_t)( - nrf_drv_usbd_ep_transfer_t * p_next, - void * p_context, - size_t ep_size, - size_t data_size); - -/** - * @brief Universal transfer handler. - * - * Union with feeder and consumer function pointer. - */ -typedef union -{ - nrf_drv_usbd_feeder_t feeder; //!< Feeder function pointer. - nrf_drv_usbd_consumer_t consumer; //!< Consumer function pointer. -}nrf_drv_usbd_handler_t; - -/** - * @brief USBD transfer descriptor. - * - * Universal structure that may hold the setup for callback configuration for - * IN or OUT type of the transfer. - */ -typedef struct -{ - nrf_drv_usbd_handler_t handler; //!< Handler for the current transfer, function pointer. - void * p_context; //!< Context for the transfer handler. -}nrf_drv_usbd_handler_desc_t; - -/** - * @brief Setup packet structure - * - * Structure that contains interpreted SETUP packet. - */ -typedef struct -{ - uint8_t bmRequestType; //!< byte 0 - uint8_t bmRequest; //!< byte 1 - uint16_t wValue; //!< byte 2 - uint16_t wIndex; //!< byte 4, 5 - uint16_t wLength; //!< byte 6, 7 -}nrf_drv_usbd_setup_t; - -/** - * @brief Library initialization - * - * @param[in] event_handler Event handler provided by the user. - */ -ret_code_t nrf_drv_usbd_init(nrf_drv_usbd_event_handler_t const event_handler); - -/** - * @brief Library deinitialization - */ -ret_code_t nrf_drv_usbd_uninit(void); - -/** - * @brief Enable the USBD port - * - * After calling this function USBD peripheral would be enabled. - * The USB LDO would be enabled. - * Enabled USBD peripheral would request HFCLK. - * This function does not enable external oscillator, so if it is not enabled by other part of the - * program after enabling USBD driver HFINT would be used for the USBD peripheral. - * It is perfectly fine until USBD is started. See @ref nrf_drv_usbd_start. - * - * In normal situation this function should be called in reaction to USBDETECTED - * event from POWER peripheral. - * - * Interrupts and USB pins pull-up would stay disabled until @ref nrf_drv_usbd_start - * function is called. - */ -void nrf_drv_usbd_enable(void); - -/** - * @brief Disable the USBD port - * - * After calling this function USBD peripheral would be disabled. - * No events would be detected or processed by the library. - * Clock for the peripheral would be disconnected. - */ -void nrf_drv_usbd_disable(void); - -/** - * @brief Start USB functionality - * - * After calling this function USBD peripheral should be fully functional - * and all new incoming events / interrupts would be processed by the library. - * - * Also only after calling this function host sees new connected device. - * - * Call this function when USBD power LDO regulator is ready - on USBPWRRDY event - * from POWER peripheral. - * - * Before USBD interrupts are enabled, external HFXO is requested. - * - * @param enable_sof The flag that is used to enable SOF processing. - * If it is false, SOF interrupt is left disabled and will not be generated. - * This improves power saving if SOF is not required. - * - * @note If the isochronous endpoints are going to be used, - * it is required to enable the SOF. - * In other case any isochronous endpoint would stay busy - * after first transmission. - */ -void nrf_drv_usbd_start(bool enable_sof); - -/** - * @brief Stop USB functionality - * - * This function disables USBD pull-up and interrupts. - * - * The HFXO request is released in this function. - * - * @note - * This function can also be used to logically disconnect USB from the HOST that - * would force it to enumerate device after calling @ref nrf_drv_usbd_start. - */ -void nrf_drv_usbd_stop(void); - -/** - * @brief Check if driver is initialized - * - * @retval false Driver is not initialized - * @retval true Driver is initialized - */ -bool nrf_drv_usbd_is_initialized(void); - -/** - * @brief Check if driver is enabled - * - * @retval false Driver is disabled - * @retval true Driver is enabled - */ -bool nrf_drv_usbd_is_enabled(void); - -/** - * @brief Check if driver is started - * - * @retval false Driver is not started - * @retval true Driver is started (fully functional) - * @note The USBD peripheral interrupt state is checked - */ -bool nrf_drv_usbd_is_started(void); - -/** - * @brief Suspend USBD operation - * - * The USBD peripheral is forced to go into the low power mode. - * The function has to be called in the reaction to @ref NRF_DRV_USBD_EVT_SUSPEND event - * when the firmware is ready. - * - * After successful call of this function most of the USBD registers would be unavailable. - * - * @note Check returned value for the feedback if suspending was successful. - * - * @retval true USBD peripheral successfully suspended - * @retval false USBD peripheral was not suspended due to resume detection. - * - */ -bool nrf_drv_usbd_suspend(void); - -/** - * @brief Start wake up procedure - * - * The USBD peripheral is forced to quit the low power mode. - * After calling this function all the USBD registers would be available. - * - * The hardware starts measuring time when wake up is possible. - * This may take 0-5 ms depending on how long the SUSPEND state was kept on the USB line. - - * When NRF_DRV_USBD_EVT_WUREQ event is generated it means that Wake Up signaling has just been - * started on the USB lines. - * - * @note Do not expect only @ref NRF_DRV_USBD_EVT_WUREQ event. - * There always may appear @ref NRF_DRV_USBD_EVT_RESUME event. - * @note NRF_DRV_USBD_EVT_WUREQ event means that Remote WakeUp signal - * has just begun to be generated. - * This may take up to 20 ms for the bus to become active. - * - * @retval true WakeUp procedure started. - * @retval false No WakeUp procedure started - bus is already active. - */ -bool nrf_drv_usbd_wakeup_req(void); - -/** - * @brief Check if USBD is in SUSPEND mode - * - * @note This is the information about peripheral itself, not about the bus state. - * - * @retval true USBD peripheral is suspended - * @retval false USBD peripheral is active - */ -bool nrf_drv_usbd_suspend_check(void); - -/** - * @brief Enable only interrupts that should be processed in SUSPEND mode - * - * Auxiliary function to help with SUSPEND mode integration. - * It enables only the interrupts that can be properly processed without stable HFCLK. - * - * Normally all the interrupts are enabled. - * Use this function to suspend interrupt processing that may require stable HFCLK until the - * clock is enabled. - * - * @sa nrf_drv_usbd_active_irq_config - */ -void nrf_drv_usbd_suspend_irq_config(void); - -/** - * @brief Default active interrupt configuration - * - * Default interrupt configuration. - * Use in a pair with @ref nrf_drv_usbd_active_irq_config. - * - * @sa nrf_drv_usbd_suspend_irq_config - */ -void nrf_drv_usbd_active_irq_config(void); - -/** - * @brief Check the bus state - * - * This function checks if the bus state is suspended - * - * @note The value returned by this function changes on SUSPEND and RESUME event processing. - * - * @retval true USBD bus is suspended - * @retval false USBD bus is active - */ -bool nrf_drv_usbd_bus_suspend_check(void); - -/** - * @brief Configure packet size that should be supported by the endpoint - * - * The real endpoint buffer size is always the same. - * This value sets max packet size that would be transmitted over the endpoint. - * This is required by the library - * - * @param[in] ep Endpoint number - * @param[in] size Required maximum packet size - * - * @note Endpoint size is always set to @ref NRF_DRV_USBD_EPSIZE or @ref NRF_DRV_USBD_ISOSIZE / 2 - * when @ref nrf_drv_usbd_ep_enable function is called. - */ -void nrf_drv_usbd_ep_max_packet_size_set(nrf_drv_usbd_ep_t ep, uint16_t size); - -/** - * @brief Get configured endpoint packet size - * - * Function to get configured endpoint size on the buffer. - * - * @param[in] ep Endpoint number - * - * @return Maximum pocket size configured on selected endpoint - */ -uint16_t nrf_drv_usbd_ep_max_packet_size_get(nrf_drv_usbd_ep_t ep); - -/** - * @brief Check if the selected endpoint is enabled. - * - * @param ep Endpoint number to check. - * - * @retval true Endpoint is enabled. - * @retval false Endpoint is disabled. - */ -bool nrf_drv_usbd_ep_enable_check(nrf_drv_usbd_ep_t ep); - -/** - * @brief Enable selected endpoint - * - * This function enables endpoint itself and its interrupts. - * @param ep Endpoint number to enable - * - * @note - * Max packet size is set to endpoint default maximum value. - * - * @sa nrf_drv_usbd_ep_max_packet_size_set - */ -void nrf_drv_usbd_ep_enable(nrf_drv_usbd_ep_t ep); - -/** - * @brief Disable selected endpoint - * - * This function disables endpoint itself and its interrupts. - * @param ep Endpoint number to disable - */ -void nrf_drv_usbd_ep_disable(nrf_drv_usbd_ep_t ep); - -/** - * @brief Disable all endpoints except for EP0 - * - * Disable all endpoints that can be disabled in USB device while it is still active. - */ -void nrf_drv_usbd_ep_default_config(void); - -/** - * @brief Start sending data over endpoint - * - * Function initializes endpoint transmission. - * This is asynchronous function - it finishes immediately after configuration - * for transmission is prepared. - * - * @note Data buffer pointed by p_data have to be kept active till - * @ref NRF_DRV_USBD_EVT_EPTRANSFER event is generated. - * - * @param[in] ep Endpoint number. - * For IN endpoint sending would be initiated. - * For OUT endpoint receiving would be initiated. - * @param[in] p_transfer - * - * @retval NRF_ERROR_BUSY Selected endpoint is pending. - * @retval NRF_ERROR_INVALID_ADDR Unexpected transfer on EPIN0 or EPOUT0. - * @retval NRF_ERROR_FORBIDDEN Endpoint stalled. - * @retval NRF_SUCCESS Transfer queued or started. - */ -ret_code_t nrf_drv_usbd_ep_transfer( - nrf_drv_usbd_ep_t ep, - nrf_drv_usbd_transfer_t const * const p_transfer); - -/** - * @brief Start sending data over the endpoint using the transfer handler function. - * - * This function initializes an endpoint transmission. - * Just before data is transmitted, the transfer handler - * is called and it prepares a data chunk. - * - * @param[in] ep Endpoint number. - * For an IN endpoint, sending is initiated. - * For an OUT endpoint, receiving is initiated. - * @param p_handler Transfer handler - feeder for IN direction and consumer for - * OUT direction. - * - * @retval NRF_ERROR_BUSY Selected endpoint is pending. - * @retval NRF_ERROR_INVALID_ADDR Unexpected transfer on EPIN0 or EPOUT0. - * @retval NRF_ERROR_FORBIDDEN Endpoint stalled. - * @retval NRF_SUCCESS Transfer queued or started. - */ -ret_code_t nrf_drv_usbd_ep_handled_transfer( - nrf_drv_usbd_ep_t ep, - nrf_drv_usbd_handler_desc_t const * const p_handler); - -/** - * @brief Get the temporary buffer to be used by the feeder. - * - * This buffer is used for TX transfers and it can be reused automatically - * when the transfer is finished. - * Use it for transfer preparation. - * - * May be used inside the feeder configured in @ref nrf_drv_usbd_ep_handled_transfer. - * - * @return Pointer to the buffer that can be used temporarily. - * - * @sa NRF_DRV_USBD_FEEDER_BUFFER_SIZE - */ -void * nrf_drv_usbd_feeder_buffer_get(void); - -/** - * @brief Get the information about last finished or current transfer - * - * Function returns the status of the last buffer set for transfer on selected endpoint. - * The status considers last buffer set by @ref nrf_drv_usbd_ep_transfer function or - * by transfer callback function. - * - * @param[in] ep Endpoint number. - * @param[out] p_size Information about the current/last transfer size. - * - * @retval NRF_SUCCESS Transfer already finished - * @retval NRF_ERROR_BUSY Ongoing transfer - * @retval NRF_ERROR_DATA_SIZE Too much of data received that cannot fit into buffer and cannot be splited into chunks. - * This may happen if buffer size is not a multiplication of endpoint buffer size. - */ -ret_code_t nrf_drv_usbd_ep_status_get(nrf_drv_usbd_ep_t ep, size_t * p_size); - -/** - * @brief Get number of received bytes - * - * Get the number of received bytes. - * The function behavior is undefined when called on IN endpoint. - * - * @param ep Endpoint number. - * - * @return Number of received bytes - */ -size_t nrf_drv_usbd_epout_size_get(nrf_drv_usbd_ep_t ep); - -/** - * @brief Check if endpoint buffer is ready or is under USB IP control - * - * Function to test if endpoint is busy. - * Endpoint that is busy cannot be accessed by MCU. - * It means that: - * - OUT (TX) endpoint: Last uploaded data is still in endpoint and is waiting - * to be received by the host. - * - IN (RX) endpoint: Endpoint is ready to receive data from the host - * and the endpoint does not have any data. - * When endpoint is not busy: - * - OUT (TX) endpoint: New data can be uploaded. - * - IN (RX) endpoint: New data can be downloaded using @ref nrf_drv_usbd_ep_transfer - * function. - */ -bool nrf_drv_usbd_ep_is_busy(nrf_drv_usbd_ep_t ep); - -/** - * @brief Stall endpoint - * - * Stall endpoit to send error information during next transfer request from - * the host. - * - * @note To stall endpoint it is safer to use @ref nrf_drv_usbd_setup_stall - * @note Stalled endpoint would not be cleared when DMA transfer finishes. - * - * @param ep Endpoint number to stall - * - */ -void nrf_drv_usbd_ep_stall(nrf_drv_usbd_ep_t ep); - -/** - * @brief Clear stall flag on endpoint - * - * This function clears endpoint that is stalled. - * @note - * If it is OUT endpoint (receiving) it would be also prepared for reception. - * It means that busy flag would be set. - * @note - * In endpoint (transmitting) would not be cleared - it gives possibility to - * write new data before transmitting. - */ -void nrf_drv_usbd_ep_stall_clear(nrf_drv_usbd_ep_t ep); - -/** - * @brief Check if endpoint is stalled - * - * This function gets stall state of selected endpoint - * - * @param ep Endpoint number to check - */ -bool nrf_drv_usbd_ep_stall_check(nrf_drv_usbd_ep_t ep); - -/** - * @brief Clear current endpoint data toggle - * - * @param ep Endpoint number to clear - */ -void nrf_drv_usbd_ep_dtoggle_clear(nrf_drv_usbd_ep_t ep); - -/** - * @brief Get parsed setup data - * - * Function fills the parsed setup data structure. - * - * @param[out] p_setup Pointer to data structure that would be filled by - * parsed data. - */ -void nrf_drv_usbd_setup_get(nrf_drv_usbd_setup_t * const p_setup); - -/** - * @brief Clear only for data transmission on setup endpoint - * - * This function may be called if any more data in control write transfer is expected. - * Clears only OUT endpoint to be able to take another OUT data token. - * It does not allow STATUS stage. - * @sa nrf_drv_usbd_setup_clear - */ -void nrf_drv_usbd_setup_data_clear(void); - -/** - * @brief Clear setup endpoint - * - * This function acknowledges setup when SETUP command was received and processed. - * It has to be called if no data respond for the SETUP command is sent. - * - * When there is any data transmission after SETUP command the data transmission - * itself would clear the endpoint. - */ -void nrf_drv_usbd_setup_clear(void); - -/** - * @brief Stall setup endpoint - * - * Mark and error on setup endpoint. - */ -void nrf_drv_usbd_setup_stall(void); - -/** -* @note -* This function locks interrupts that may be costly. -* It is good idea to test if the endpoint is still busy before calling this function: -* @code - (m_ep_dma_waiting & (1U << ep2bit(ep))) -* @endcode -* This function would check it again, but it makes it inside critical section. -*/ -void nrf_drv_usbd_ep_abort(nrf_drv_usbd_ep_t ep); - -/** - * @brief Get the information about expected transfer SETUP data direction - * - * Function returns the information about last expected transfer direction. - * - * @retval NRF_DRV_USBD_EPOUT0 Expecting OUT (Host->Device) direction or no data - * @retval NRF_DRV_USBD_EPIN0 Expecting IN (Device->Host) direction - */ -nrf_drv_usbd_ep_t nrf_drv_usbd_last_setup_dir_get(void); - -/** - * @brief Drop transfer on OUT endpoint - * - * @param[in] ep OUT endpoint ID - */ -void nrf_drv_usbd_transfer_out_drop(nrf_drv_usbd_ep_t ep); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* NRF_DRV_USBD_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd_errata.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd_errata.h deleted file mode 100644 index 00371e9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/usbd/nrf_drv_usbd_errata.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Copyright (c) 2017 - 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 NRF_DRV_USBD_ERRATA_H__ -#define NRF_DRV_USBD_ERRATA_H__ - -#include -/** - * @defgroup nrf_drv_usbd_errata Functions to check if selected PAN is present in current chip - * @{ - * @ingroup nrf_drv_usbd - * - * Functions here are checking the presence of an error in current chip. - * The checking is done at runtime based on the microcontroller version. - * This file is subject to removal when nRF51840 prototype support is removed. - */ - -#ifndef NRF_DRV_USBD_ERRATA_ENABLE -/** - * @brief The constant that informs if errata should be enabled at all - * - * If this constant is set to 0, all the Errata bug fixes will be automatically disabled. - */ -#define NRF_DRV_USBD_ERRATA_ENABLE 1 -#endif - -/** - * @brief Internal auxiliary function to check if the program is running on NRF52840 chip - * @retval true It is NRF52480 chip - * @retval false It is other chip - */ -static inline bool nrf_drv_usbd_errata_type_52840(void) -{ - return ((((*(uint32_t *)0xF0000FE0) & 0xFF) == 0x08) && - (((*(uint32_t *)0xF0000FE4) & 0x0F) == 0x0)); -} - -/** - * @brief Internal auxiliary function to check if the program is running on first sample of - * NRF52840 chip - * @retval true It is NRF52480 chip and it is first sample version - * @retval false It is other chip - */ -static inline bool nrf_drv_usbd_errata_type_52840_proto1(void) -{ - return ( nrf_drv_usbd_errata_type_52840() && - ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x00 ) && - ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) ); -} - -/** - * @brief Function to check if chip requires errata 104 - * - * Errata: USBD: EPDATA event is not always generated. - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_104(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); -} - -/** - * @brief Function to check if chip requires errata 154 - * - * Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task. - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_154(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); -} - -/** - * @brief Function to check if chip requires errata 166 - * - * Errata: ISO double buffering not functional - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_166(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && true; -} - -/** - * @brief Function to check if chip requires errata ??? - * - * Errata: SIZE.EPOUT not writable - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_sizeepout_rw(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); -} - -/** @} */ -#endif /* NRF_DRV_USBD_ERRATA_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/wdt/nrf_drv_wdt.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/wdt/nrf_drv_wdt.c deleted file mode 100644 index 7a2f92d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/wdt/nrf_drv_wdt.c +++ /dev/null @@ -1,173 +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(WDT) -#include "nrf_drv_wdt.h" -#include "nrf_drv_common.h" -#include "nrf_error.h" -#include "nrf_assert.h" -#include "nrf_wdt.h" -#include "app_util_platform.h" -#include -#include - -#define NRF_LOG_MODULE_NAME wdt - -#if WDT_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL WDT_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR WDT_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR WDT_CONFIG_DEBUG_COLOR -#else //WDT_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //WDT_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - - -/**@brief WDT event handler. */ -static nrf_wdt_event_handler_t m_wdt_event_handler; - -/**@brief WDT state. */ -static nrf_drv_state_t m_state; - -/**@brief WDT alloc table. */ -static uint32_t m_alloc_index; - -static const nrf_drv_wdt_config_t m_default_config = NRF_DRV_WDT_DEAFULT_CONFIG; - -/**@brief WDT interrupt handler. */ -void WDT_IRQHandler(void) -{ - if (nrf_wdt_int_enable_check(NRF_WDT_INT_TIMEOUT_MASK) == true) - { - nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT); - m_wdt_event_handler(); - } -} - - -ret_code_t nrf_drv_wdt_init(nrf_drv_wdt_config_t const * p_config, - nrf_wdt_event_handler_t wdt_event_handler) -{ - ASSERT(wdt_event_handler != NULL); - ret_code_t err_code; - m_wdt_event_handler = wdt_event_handler; - - if (m_state == NRF_DRV_STATE_UNINITIALIZED) - { - m_state = NRF_DRV_STATE_INITIALIZED; - } - else - { - err_code = NRF_ERROR_INVALID_STATE; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; - } - - if (p_config == NULL) - { - p_config = &m_default_config; - } - - nrf_wdt_behaviour_set(p_config->behaviour); - - if ((((uint64_t) p_config->reload_value * 32768) / 1000) > UINT32_MAX) // Check for overflow - { - return NRF_ERROR_INVALID_PARAM; - } - nrf_wdt_reload_value_set(((uint64_t) p_config->reload_value * 32768) / 1000); - - nrf_drv_common_irq_enable(WDT_IRQn, p_config->interrupt_priority); - - err_code = NRF_SUCCESS; - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); - return err_code; -} - - -void nrf_drv_wdt_enable(void) -{ - ASSERT(m_alloc_index != 0); - ASSERT(m_state == NRF_DRV_STATE_INITIALIZED); - nrf_wdt_int_enable(NRF_WDT_INT_TIMEOUT_MASK); - nrf_wdt_task_trigger(NRF_WDT_TASK_START); - m_state = NRF_DRV_STATE_POWERED_ON; - NRF_LOG_INFO("Enabled."); -} - - -void nrf_drv_wdt_feed(void) -{ - ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); - for (uint32_t i = 0; i < m_alloc_index; i++) - { - nrf_wdt_reload_request_set((nrf_wdt_rr_register_t)(NRF_WDT_RR0 + i)); - } -} - -ret_code_t nrf_drv_wdt_channel_alloc(nrf_drv_wdt_channel_id * p_channel_id) -{ - ret_code_t result; - ASSERT(p_channel_id); - ASSERT(m_state == NRF_DRV_STATE_INITIALIZED); - - CRITICAL_REGION_ENTER(); - if (m_alloc_index < NRF_WDT_CHANNEL_NUMBER) - { - *p_channel_id = (nrf_drv_wdt_channel_id)(NRF_WDT_RR0 + m_alloc_index); - m_alloc_index++; - nrf_wdt_reload_request_enable(*p_channel_id); - result = NRF_SUCCESS; - } - else - { - result = NRF_ERROR_NO_MEM; - } - CRITICAL_REGION_EXIT(); - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(result)); - return result; -} - -void nrf_drv_wdt_channel_feed(nrf_drv_wdt_channel_id channel_id) -{ - ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); - nrf_wdt_reload_request_set(channel_id); -} -#endif //NRF_MODULE_ENABLED(WDT) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.c deleted file mode 100644 index 1461f76..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.c +++ /dev/null @@ -1,1252 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "nrf_ble_dfu.h" - -#include -#include "boards.h" -#include "sdk_common.h" -#include "nrf_dfu_transport.h" -#include "nrf_dfu_req_handler.h" -#include "nrf_dfu_handling_error.h" -#include "nrf_dfu_mbr.h" -#include "nrf_bootloader_info.h" -#include "ble_conn_params.h" -#include "ble_hci.h" -#include "nrf_sdh.h" -#include "nrf_sdh_ble.h" -#include "nrf_log.h" -#include "nrf_delay.h" -#include "app_timer.h" -#include "nrf_dfu_svci.h" -#include "nrf_dfu_settings.h" - - -#define ADVERTISING_LED_PIN_NO BSP_LED_0 /**< Is on when device is advertising. */ -#define CONNECTED_LED_PIN_NO BSP_LED_1 /**< Is on when device has connected. */ - -#define DEVICE_NAME "DfuTarg" /**< Name of device included in the advertising data. Must be shorter than or equal to 20 bytes. */ -#define MANUFACTURER_NAME "NordicSemiconductor" /**< Manufacturer. Will be passed to Device Information Service. */ - -#define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */ - -#define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(7.5, UNIT_1_25_MS)) /**< Minimum acceptable connection interval. */ -#define MAX_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(30, UNIT_1_25_MS)) /**< Maximum acceptable connection interval. */ -#define SLAVE_LATENCY 0 /**< Slave latency. */ -#define CONN_SUP_TIMEOUT (4 * 100) /**< Connection supervisory timeout (4 seconds). */ - -#define MAX_ADV_NAME_LENGTH 20 /**< Maximum length of advertising name. */ - -#define APP_ADV_DATA_HEADER_SIZE (9) /**< Size of encoded advertisement data header (not including device name). */ - -#define APP_ADV_INTERVAL MSEC_TO_UNITS(25, UNIT_0_625_MS) /**< The advertising interval (25 ms.). */ -#define APP_ADV_TIMEOUT_IN_SECONDS BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising timeout in units of seconds. This is set to @ref BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED so that the advertisement is done as long as there there is a call to @ref dfu_transport_close function.*/ - -#define APP_FEATURE_NOT_SUPPORTED BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2 /**< Reply when unsupported features are requested. */ - -#define SEC_PARAM_BOND 0 /**< Perform bonding. */ -#define SEC_PARAM_MITM 0 /**< Man In The Middle protection not required. */ -#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */ -#define SEC_PARAM_OOB 0 /**< Out Of Band data not available. */ -#define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */ -#define SEC_PARAM_MAX_KEY_SIZE 16 /**< Maximum encryption key size. */ - -#define OPCODE_LEN 1 /**< Length of opcode inside Heart Rate Measurement packet. */ -#define HANDLE_LEN 2 /**< Length of handle inside Heart Rate Measurement packet. */ -#define MAX_DFU_PKT_LEN NRF_SDH_BLE_GATT_MAX_MTU_SIZE - OPCODE_LEN - HANDLE_LEN /**< Maximum length (in bytes) of the DFU Packet characteristic. */ -STATIC_ASSERT(MAX_DFU_PKT_LEN <= FLASH_BUFFER_LENGTH); /**< Assert to prevent buffer overflow. Every write to the DFU Packet control point is buffered and written to flash. */ - -#define PKT_CREATE_PARAM_LEN (6) /**< Length (in bytes) of the parameters for Create Object request. */ -#define PKT_SET_PRN_PARAM_LEN (3) /**< Length (in bytes) of the parameters for Set Packet Receipt Notification request. */ -#define PKT_READ_OBJECT_INFO_PARAM_LEN (2) /**< Length (in bytes) of the parameters for Read Object Info request. */ -#define MAX_RESPONSE_LEN (17) /**< Maximum length (in bytes) of the response to a Control Point command. */ - -#define DFU_BLE_FLAG_NONE (0) -#define DFU_BLE_FLAG_SERVICE_INITIALIZED (1 << 0) /**< Flag to check if the DFU service was initialized by the application.*/ -#define DFU_BLE_FLAG_USE_ADV_NAME (1 << 1) /**< Flag to indicate that advertisement name is to be used. */ -#define DFU_BLE_RESETTING_SOON (1 << 2) /**< Flag to indicate that the device will reset soon. */ - -#define BLE_OBSERVER_PRIO 2 /**< BLE observer priority. Controls the priority for BLE event handler. */ - -DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const dfu_trans) = -{ - .init_func = ble_dfu_transport_init, - .close_func = ble_dfu_transport_close -}; - -static ble_dfu_t m_dfu; /**< Structure used to identify the Device Firmware Update service. */ -static uint16_t m_pkt_notif_target; /**< Number of packets of firmware data to be received before transmitting the next Packet Receipt Notification to the DFU Controller. */ -static uint16_t m_pkt_notif_target_cnt; /**< Number of packets of firmware data received after sending last Packet Receipt Notification or since the receipt of a @ref BLE_DFU_PKT_RCPT_NOTIF_ENABLED event from the DFU service, which ever occurs later.*/ -static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< Handle of the current connection. */ -static uint32_t m_flags; -static uint8_t m_notif_buffer[MAX_RESPONSE_LEN]; /**< Buffer used for sending notifications to peer. */ - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) -static nrf_dfu_peer_data_t m_peer_data; -static ble_gap_addr_t const * m_whitelist[1]; /**< List of peers in whitelist (only one) */ -static ble_gap_id_key_t const * m_gap_ids[1]; -#else -static nrf_dfu_adv_name_t m_adv_name; -#endif - - -/**@brief Function for the Advertising functionality initialization. - * - * @details Encodes the required advertising data and passes it to the stack. - * The advertising data encoded here is specific for DFU. - * Setting advertising data can by done by calling @ref ble_advdata_set. - */ -static uint32_t advertising_init(uint8_t adv_flags) -{ - uint32_t err_code; - uint16_t len_advdata = APP_ADV_DATA_HEADER_SIZE; - uint16_t actual_device_name_length = BLE_GAP_ADV_MAX_SIZE - APP_ADV_DATA_HEADER_SIZE; - uint8_t p_encoded_advdata[BLE_GAP_ADV_MAX_SIZE]; - - // Encode flags. - p_encoded_advdata[0] = 0x2; - p_encoded_advdata[1] = BLE_GAP_AD_TYPE_FLAGS; - p_encoded_advdata[2] = adv_flags; - - // Encode 'more available' UUID list. - p_encoded_advdata[3] = 0x3; - p_encoded_advdata[4] = BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE; - p_encoded_advdata[5] = LSB_16(BLE_DFU_SERVICE_UUID); - p_encoded_advdata[6] = MSB_16(BLE_DFU_SERVICE_UUID); - - // Get GAP device name and length. - err_code = sd_ble_gap_device_name_get(&p_encoded_advdata[9], &actual_device_name_length); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - // Set GAP device in advertising data. - p_encoded_advdata[7] = actual_device_name_length + 1; // (actual_length + ADV_AD_TYPE_FIELD_SIZE(1)) - p_encoded_advdata[8] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME; - len_advdata += actual_device_name_length; - - return sd_ble_gap_adv_data_set(p_encoded_advdata, len_advdata, NULL, 0); -} - - -/**@brief Function for starting advertising. - */ -static uint32_t advertising_start(void) -{ - uint32_t err_code; - ble_gap_adv_params_t adv_params = - { - .type = BLE_GAP_ADV_TYPE_ADV_IND, - .p_peer_addr = NULL, - .fp = BLE_GAP_ADV_FP_ANY, - .interval = APP_ADV_INTERVAL, - .timeout = APP_ADV_TIMEOUT_IN_SECONDS, - }; - uint8_t adv_flag = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - ble_gap_irk_t empty_irk = {{0}}; - - NRF_LOG_DEBUG("##### Setting adv with peer data ####"); - if (memcmp(m_peer_data.ble_id.id_info.irk, empty_irk.irk, sizeof(ble_gap_irk_t)) == 0) - { - NRF_LOG_DEBUG("##### No IRK, General discovery"); - } - else - { - NRF_LOG_DEBUG("##### IRK Found. Setting whitelist ####"); - - // API versions lower than 3 are not supported. - STATIC_ASSERT(NRF_SD_BLE_API_VERSION >= 3); - - m_whitelist[0] = &m_peer_data.ble_id.id_addr_info; - err_code = sd_ble_gap_whitelist_set(m_whitelist, 1); - VERIFY_SUCCESS(err_code); - - m_gap_ids[0] = &m_peer_data.ble_id; - sd_ble_gap_device_identities_set(m_gap_ids, NULL, 1); - VERIFY_SUCCESS(err_code); - - adv_flag = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; - adv_params.fp = BLE_GAP_ADV_FP_FILTER_CONNREQ; - } -#else - { - NRF_LOG_DEBUG("#### Advertising NO BONDING ####"); - } -#endif // NRF_DFU_BLE_REQUIRES_BONDS - - err_code = advertising_init(adv_flag); - VERIFY_SUCCESS(err_code); - - (void) sd_ble_gap_adv_stop(); - err_code = sd_ble_gap_adv_start(&adv_params, APP_BLE_CONN_CFG_TAG); - VERIFY_SUCCESS(err_code); - - nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO); - nrf_gpio_pin_set(CONNECTED_LED_PIN_NO); - - return NRF_SUCCESS; -} - - -/**@brief Function for stopping advertising. - */ -static void advertising_stop(void) -{ - (void)sd_ble_gap_adv_stop(); - nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO); - -} - - -static bool is_cccd_configured(ble_dfu_t * p_dfu) -{ - uint8_t cccd_val_buf[BLE_CCCD_VALUE_LEN]; - ble_gatts_value_t gatts_value = {0}; - - gatts_value.len = BLE_CCCD_VALUE_LEN; - gatts_value.p_value = cccd_val_buf; - - // Check the CCCD Value of DFU Control Point. - uint32_t err_code = sd_ble_gatts_value_get(m_conn_handle, - p_dfu->dfu_ctrl_pt_handles.cccd_handle, - &gatts_value); - VERIFY_SUCCESS(err_code); - - return ble_srv_is_notification_enabled(cccd_val_buf); -} - - -static uint32_t send_hvx(uint16_t conn_handle, uint16_t value_handle, uint16_t len) -{ - ble_gatts_hvx_params_t hvx_params = {0}; - - hvx_params.handle = value_handle; - hvx_params.type = BLE_GATT_HVX_NOTIFICATION; - hvx_params.p_len = &len; - hvx_params.p_data = m_notif_buffer; - - return sd_ble_gatts_hvx(conn_handle, &hvx_params); -} - - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) -static uint32_t service_changed_send(void) -{ - uint32_t err_code; - - NRF_LOG_DEBUG("Sending Service Changed indication"); - - err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, - m_peer_data.sys_serv_attr, - sizeof(m_peer_data.sys_serv_attr), - BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS); - VERIFY_SUCCESS(err_code); - - - err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, - NULL, - 0, - BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS); - - VERIFY_SUCCESS(err_code); - - err_code = sd_ble_gatts_service_changed(m_conn_handle, m_dfu.service_handle, 0xFFFF); - - if ((err_code == BLE_ERROR_INVALID_CONN_HANDLE) || - (err_code == NRF_ERROR_INVALID_STATE) || - (err_code == NRF_ERROR_BUSY)) - { - // Those errors can be expected when sending trying to send Service Changed indication - // if the CCCD is not set to indicate. Thus set the returning error code to success. - NRF_LOG_WARNING("Client did not have the Service Changed indication set to enabled. Error: 0x%08x", err_code); - err_code = NRF_SUCCESS; - } - - return err_code; -} -#endif - - -static uint32_t response_send(ble_dfu_t * p_dfu, - uint8_t op_code, - nrf_dfu_res_code_t resp_val) -{ - uint16_t index = 0; - - NRF_LOG_DEBUG("Sending Response: [0x%01x, 0x%01x]", op_code, resp_val); - - ASSERT(p_dfu != NULL); - - if ((m_conn_handle == BLE_CONN_HANDLE_INVALID) || (m_flags & DFU_BLE_FLAG_SERVICE_INITIALIZED) == 0) - { - return NRF_ERROR_INVALID_STATE; - } - - m_notif_buffer[index++] = BLE_DFU_OP_CODE_RESPONSE; - - // Encode the Request Op code. - m_notif_buffer[index++] = op_code; - - // Encode the Response Value. - m_notif_buffer[index++] = (uint8_t)resp_val; - - // If the error was an extended error code, add the error to the response. - if (resp_val == NRF_DFU_RES_CODE_EXT_ERROR) - { - m_notif_buffer[index++] = ext_error_get(); - // Clear the last extended error code. - (void) ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR); - } - - return send_hvx(m_conn_handle, p_dfu->dfu_ctrl_pt_handles.value_handle, index); -} - - -static uint32_t response_crc_cmd_send(ble_dfu_t * p_dfu, - uint32_t offset, - uint32_t crc) -{ - uint16_t index = 0; - - NRF_LOG_DEBUG("Sending CRC: [0x60, 0x03, 0x01, 0:x%08x, CRC:0x%08x]", offset, crc); - - ASSERT(p_dfu != NULL); - - if ((m_conn_handle == BLE_CONN_HANDLE_INVALID) || (m_flags & DFU_BLE_FLAG_SERVICE_INITIALIZED) == 0) - { - return NRF_ERROR_INVALID_STATE; - } - - m_notif_buffer[index++] = BLE_DFU_OP_CODE_RESPONSE; - - // Encode the Request Op code - m_notif_buffer[index++] = BLE_DFU_OP_CODE_CALCULATE_CRC; - - // Encode the Response Value. - m_notif_buffer[index++] = (uint8_t)NRF_DFU_RES_CODE_SUCCESS; - - // Encode the Offset Value. - index += uint32_encode(offset, &m_notif_buffer[index]); - - // Encode the Crc Value. - index += uint32_encode(crc, &m_notif_buffer[index]); - - return send_hvx(m_conn_handle, p_dfu->dfu_ctrl_pt_handles.value_handle, index); -} - - -static uint32_t response_select_object_cmd_send(ble_dfu_t * p_dfu, - uint32_t max_size, - uint32_t offset, - uint32_t crc) -{ - uint16_t index = 0; - - NRF_LOG_DEBUG("Sending Object Info: [0x60, 0x06, 0x01 max: 0:x%08x 0:x%08x, CRC:0x%08x]", - max_size, offset, crc); - - ASSERT(p_dfu != NULL); - - if ((m_conn_handle == BLE_CONN_HANDLE_INVALID) || (m_flags & DFU_BLE_FLAG_SERVICE_INITIALIZED) == 0) - { - return NRF_ERROR_INVALID_STATE; - } - - m_notif_buffer[index++] = BLE_DFU_OP_CODE_RESPONSE; - - // Encode the Request Op code. - m_notif_buffer[index++] = BLE_DFU_OP_CODE_SELECT_OBJECT; - - // Encode the Success Response Value. - m_notif_buffer[index++] = (uint8_t)NRF_DFU_RES_CODE_SUCCESS; - - // Encode the Max Size Value. - index += uint32_encode(max_size, &m_notif_buffer[index]); - - // Encode the Offset Value. - index += uint32_encode(offset, &m_notif_buffer[index]); - - // Encode the CRC Value. - index += uint32_encode(crc, &m_notif_buffer[index]); - - return send_hvx(m_conn_handle, p_dfu->dfu_ctrl_pt_handles.value_handle, index); -} - - -/**@brief Function for handling a Write event on the Control Point characteristic. - * - * @param[in] p_dfu DFU Service Structure. - * @param[in] p_ble_write_evt Pointer to the write event received from BLE stack. - * - * @return NRF_SUCCESS on successful processing of control point write. Otherwise an error code. - */ -static uint32_t on_ctrl_pt_write(ble_dfu_t * p_dfu, ble_gatts_evt_write_t const * p_ble_write_evt) -{ - nrf_dfu_res_code_t res_code; - nrf_dfu_req_t dfu_req; - nrf_dfu_res_t dfu_res = {{{0}}}; - - memset(&dfu_req, 0, sizeof(nrf_dfu_req_t)); - - switch (p_ble_write_evt->data[0]) - { - case BLE_DFU_OP_CODE_CREATE_OBJECT: - - if (p_ble_write_evt->len != PKT_CREATE_PARAM_LEN) - { - return response_send(p_dfu, - BLE_DFU_OP_CODE_CREATE_OBJECT, - NRF_DFU_RES_CODE_INVALID_PARAMETER); - } - - NRF_LOG_DEBUG("Received create object"); - - // Reset the packet receipt notification on create object - m_pkt_notif_target_cnt = m_pkt_notif_target; - - // Get type parameter - //lint -save -e415 - dfu_req.obj_type = p_ble_write_evt->data[1]; - //lint -restore - - // Get length value - //lint -save -e416 - dfu_req.object_size = uint32_decode(&(p_ble_write_evt->data[2])); - //lint -restore - - // Set req type - dfu_req.req_type = NRF_DFU_OBJECT_OP_CREATE; - - res_code = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - return response_send(p_dfu, BLE_DFU_OP_CODE_CREATE_OBJECT, res_code); - - case BLE_DFU_OP_CODE_EXECUTE_OBJECT: - NRF_LOG_DEBUG("Received execute object"); - - // Set req type - dfu_req.req_type = NRF_DFU_OBJECT_OP_EXECUTE; - - res_code = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - return response_send(p_dfu, BLE_DFU_OP_CODE_EXECUTE_OBJECT, res_code); - - case BLE_DFU_OP_CODE_SET_RECEIPT_NOTIF: - NRF_LOG_DEBUG("Set receipt notif"); - if (p_ble_write_evt->len != PKT_SET_PRN_PARAM_LEN) - { - return (response_send(p_dfu, - BLE_DFU_OP_CODE_SET_RECEIPT_NOTIF, - NRF_DFU_RES_CODE_INVALID_PARAMETER)); - } - - //lint -save -e415 - m_pkt_notif_target = uint16_decode(&(p_ble_write_evt->data[1])); - //lint -restore - m_pkt_notif_target_cnt = m_pkt_notif_target; - - return response_send(p_dfu, BLE_DFU_OP_CODE_SET_RECEIPT_NOTIF, NRF_DFU_RES_CODE_SUCCESS); - - case BLE_DFU_OP_CODE_CALCULATE_CRC: - NRF_LOG_DEBUG("Received calculate CRC"); - - dfu_req.req_type = NRF_DFU_OBJECT_OP_CRC; - - res_code = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - if (res_code == NRF_DFU_RES_CODE_SUCCESS) - { - return response_crc_cmd_send(p_dfu, dfu_res.offset, dfu_res.crc); - } - else - { - return response_send(p_dfu, BLE_DFU_OP_CODE_CALCULATE_CRC, res_code); - } - - case BLE_DFU_OP_CODE_SELECT_OBJECT: - - NRF_LOG_DEBUG("Received select object"); - if (p_ble_write_evt->len != PKT_READ_OBJECT_INFO_PARAM_LEN) - { - return response_send(p_dfu, - BLE_DFU_OP_CODE_SELECT_OBJECT, - NRF_DFU_RES_CODE_INVALID_PARAMETER); - } - - // Set object type to read info about - //lint -save -e415 - dfu_req.obj_type = p_ble_write_evt->data[1]; - //lint -restore - - dfu_req.req_type = NRF_DFU_OBJECT_OP_SELECT; - - res_code = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - if (res_code == NRF_DFU_RES_CODE_SUCCESS) - { - return response_select_object_cmd_send(p_dfu, dfu_res.max_size, dfu_res.offset, dfu_res.crc); - } - else - { - return response_send(p_dfu, BLE_DFU_OP_CODE_SELECT_OBJECT, res_code); - } - - default: - NRF_LOG_WARNING("Received unsupported OP code"); - // Unsupported op code. - return response_send(p_dfu, - p_ble_write_evt->data[0], - NRF_DFU_RES_CODE_INVALID_PARAMETER); - } -} - - -/**@brief Function for handling the @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event from the - * SoftDevice. - * - * @param[in] p_dfu DFU Service Structure. - * @param[in] p_ble_evt Pointer to the event received from BLE stack. - */ -static bool on_rw_authorize_req(ble_dfu_t * p_dfu, ble_evt_t const * p_ble_evt) -{ - uint32_t err_code; - ble_gatts_rw_authorize_reply_params_t auth_reply = {0}; - - ble_gatts_evt_rw_authorize_request_t const * p_authorize_request; - ble_gatts_evt_write_t const * p_ble_write_evt; - - p_authorize_request = &(p_ble_evt->evt.gatts_evt.params.authorize_request); - p_ble_write_evt = &(p_ble_evt->evt.gatts_evt.params.authorize_request.request.write); - - if ((p_authorize_request->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) && - (p_authorize_request->request.write.handle == p_dfu->dfu_ctrl_pt_handles.value_handle) && - (p_authorize_request->request.write.op != BLE_GATTS_OP_PREP_WRITE_REQ) && - (p_authorize_request->request.write.op != BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) && - (p_authorize_request->request.write.op != BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL) ) - { - auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; - auth_reply.params.write.update = 1; - auth_reply.params.write.offset = p_ble_write_evt->offset; - auth_reply.params.write.len = p_ble_write_evt->len; - auth_reply.params.write.p_data = p_ble_write_evt->data; - - if (!is_cccd_configured(p_dfu)) - { - // Send an error response to the peer indicating that the CCCD is improperly configured. - auth_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR; - - // Ignore response of auth reply - (void)sd_ble_gatts_rw_authorize_reply(m_conn_handle, &auth_reply); - return false; - } - - auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; - - err_code = sd_ble_gatts_rw_authorize_reply(m_conn_handle, &auth_reply); - return err_code == NRF_SUCCESS ? true: false; - } - else - { - return false; - } -} - - -/**@brief Function for handling the @ref BLE_GATTS_EVT_WRITE event from the SoftDevice. - * - * @param[in] p_dfu DFU Service Structure. - * @param[in] p_ble_evt Pointer to the event received from BLE stack. - */ -static void on_write(ble_dfu_t * p_dfu, ble_evt_t const * p_ble_evt) -{ - if (p_ble_evt->evt.gatts_evt.params.write.handle == p_dfu->dfu_pkt_handles.value_handle) - { - nrf_dfu_res_code_t res_code; - nrf_dfu_req_t dfu_req; - nrf_dfu_res_t dfu_res = {{{0}}}; - - memset(&dfu_req, 0, sizeof(nrf_dfu_req_t)); - - // Set req type - dfu_req.req_type = NRF_DFU_OBJECT_OP_WRITE; - - // Set data and length - dfu_req.p_req = (uint8_t*)p_ble_evt->evt.gatts_evt.params.write.data; - dfu_req.req_len = p_ble_evt->evt.gatts_evt.params.write.len; - - res_code = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - if (res_code != NRF_DFU_RES_CODE_SUCCESS) - { - NRF_LOG_ERROR("Failure to run packet write"); - } - - // Check if a packet receipt notification is needed to be sent. - if (m_pkt_notif_target != 0 && --m_pkt_notif_target_cnt == 0) - { - (void)response_crc_cmd_send(p_dfu, dfu_res.offset, dfu_res.crc); - - // Reset the counter for the number of firmware packets. - m_pkt_notif_target_cnt = m_pkt_notif_target; - } - } -} - -/**@brief Function for handling the HVC event. - * - * @details Handles HVC events from the BLE stack. - * - * @param[in] p_dfu DFU Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_hvc(ble_dfu_t * p_dfu, ble_evt_t const * p_ble_evt) -{ - ble_gatts_evt_hvc_t const * p_hvc = &p_ble_evt->evt.gatts_evt.params.hvc; - - if (p_hvc->handle == BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED) - { - NRF_LOG_DEBUG("on_hvx: service_changed handle"); - } - else - { - NRF_LOG_DEBUG("on_hvx: Handle: 0x%04x", p_hvc->handle); - } -} - - -/**@brief Function for the Application's SoftDevice event handler. - * - * @param[in] p_ble_evt SoftDevice event. - */ -static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) -{ - uint32_t err_code = NRF_SUCCESS; - - switch (p_ble_evt->header.evt_id) - { - case BLE_GAP_EVT_CONNECTED: - { - nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO); - nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO); - - m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - } break; - - case BLE_GAP_EVT_DISCONNECTED: - { - // Restart advertising so that the DFU Controller can reconnect if possible. - nrf_gpio_pin_set(CONNECTED_LED_PIN_NO); - - if ((m_flags & DFU_BLE_RESETTING_SOON) == 0) - { - err_code = advertising_start(); - APP_ERROR_CHECK(err_code); - } - - m_conn_handle = BLE_CONN_HANDLE_INVALID; - } break; - - case BLE_GATTS_EVT_HVN_TX_COMPLETE: - { - nrf_dfu_req_handler_reset_if_dfu_complete(); - } break; - - case BLE_GAP_EVT_SEC_PARAMS_REQUEST: - { - NRF_LOG_DEBUG("Received: BLE_GAP_EVT_SEC_PARAMS_REQUEST"); - uint16_t cccd; - ble_gatts_value_t value = - { - .len = BLE_CCCD_VALUE_LEN, - .offset = 0, - .p_value = (uint8_t*)&cccd - }; - - err_code = sd_ble_gatts_value_get(m_conn_handle, BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED, &value); - APP_ERROR_CHECK(err_code); - - NRF_LOG_DEBUG("CCCD for the service changed is 0x%04x", cccd); - - ble_gap_sec_keyset_t * p_keys = NULL; - ble_gap_sec_params_t * p_sec_params = NULL; - - err_code = sd_ble_gap_sec_params_reply(m_conn_handle, - BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, - p_sec_params, - p_keys); - APP_ERROR_CHECK(err_code); - } break; - - case BLE_GAP_EVT_CONN_PARAM_UPDATE: - { - NRF_LOG_DEBUG("Received: BLE_GAP_EVT_CONN_PARAM_UPDATE"); - NRF_LOG_DEBUG("conn_sup_timeout: %d\r\nmax_conn_interval: %d\r\nmin_conn_interval: %d\r\nslave_latency %d", - p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.conn_sup_timeout, - p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.max_conn_interval, - p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.min_conn_interval, - p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.slave_latency); - } break; - - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: - { - NRF_LOG_DEBUG("Received: BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST"); - err_code = sd_ble_gap_conn_param_update(m_conn_handle, &p_ble_evt->evt.gap_evt.params.conn_param_update_request.conn_params); - if(err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failure to update connection parameter request: 0x%x", err_code); - } - - APP_ERROR_CHECK(err_code); - } break; - -#ifndef S140 - case BLE_GAP_EVT_PHY_UPDATE_REQUEST: - { - NRF_LOG_DEBUG("PHY update request."); - ble_gap_phys_t const phys = - { - .rx_phys = BLE_GAP_PHY_AUTO, - .tx_phys = BLE_GAP_PHY_AUTO, - }; - err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys); - APP_ERROR_CHECK(err_code); - } break; - -#endif - - case BLE_GATTS_EVT_TIMEOUT: - { - if (p_ble_evt->evt.gatts_evt.params.timeout.src == BLE_GATT_TIMEOUT_SRC_PROTOCOL) - { - err_code = sd_ble_gap_disconnect(m_conn_handle, - BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); - APP_ERROR_CHECK(err_code); - } - } break; - - case BLE_EVT_USER_MEM_REQUEST: - { - err_code = sd_ble_user_mem_reply(m_conn_handle, NULL); - APP_ERROR_CHECK(err_code); - } break; - - case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: - { - if (p_ble_evt->evt.gatts_evt.params.authorize_request.type - != BLE_GATTS_AUTHORIZE_TYPE_INVALID) - { - if (on_rw_authorize_req(&m_dfu, p_ble_evt)) - { - err_code = on_ctrl_pt_write(&m_dfu, - &(p_ble_evt->evt.gatts_evt.params.authorize_request.request.write)); -#ifdef NRF_DFU_DEBUG_VERSION - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Could not handle on_ctrl_pt_write. err_code: 0x%04x", err_code); - } -#else - // Swallow result - (void) err_code; -#endif - } - } - } break; - - case BLE_GAP_EVT_SEC_INFO_REQUEST: - { - NRF_LOG_DEBUG("== conn sec update request"); - ble_gap_enc_info_t * p_enc_info = NULL; - ble_gap_irk_t * p_id_info = NULL; - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - // If there is a match in diversifier, then set the correct keys. - if (p_ble_evt->evt.gap_evt.params.sec_info_request.master_id.ediv == - m_peer_data.enc_key.master_id.ediv) - { - p_enc_info = &m_peer_data.enc_key.enc_info; - } - p_id_info = &m_peer_data.ble_id.id_info; -#endif - err_code = sd_ble_gap_sec_info_reply(p_ble_evt->evt.gap_evt.conn_handle, - p_enc_info, - p_id_info, - NULL); - APP_ERROR_CHECK(err_code); - } break; - - case BLE_GAP_EVT_CONN_SEC_UPDATE: - case BLE_GATTS_EVT_SYS_ATTR_MISSING: - { -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - err_code = service_changed_send(); -#else - err_code = sd_ble_gatts_sys_attr_set(p_ble_evt->evt.gap_evt.conn_handle, NULL, 0, 0); -#endif - APP_ERROR_CHECK(err_code); - NRF_LOG_DEBUG("== We are finished handling conn sec update"); - } break; - - case BLE_GATTS_EVT_WRITE: - { - on_write(&m_dfu, p_ble_evt); - } break; - -#if (NRF_SD_BLE_API_VERSION >= 3) - case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: - { - err_code = sd_ble_gatts_exchange_mtu_reply(p_ble_evt->evt.gatts_evt.conn_handle, - NRF_SDH_BLE_GATT_MAX_MTU_SIZE); - APP_ERROR_CHECK(err_code); - } break; // BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST - - case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: - { - ble_gap_data_length_params_t const dlp = - { - .max_rx_octets = BLE_GAP_DATA_LENGTH_AUTO, - .max_tx_octets = BLE_GAP_DATA_LENGTH_AUTO, - }; - - err_code = sd_ble_gap_data_length_update(p_ble_evt->evt.gatts_evt.conn_handle, - &dlp, NULL); - APP_ERROR_CHECK(err_code); - } break; // BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST -#endif - - case BLE_GATTS_EVT_HVC: - on_hvc(&m_dfu, p_ble_evt); - break; - - case BLE_GATTS_EVT_SC_CONFIRM: - NRF_LOG_DEBUG("Service Changed was handled"); - break; - - default: - // No implementation needed. - break; - } -} - - -/**@brief Function for the LEDs initialization. - * - * @details Initializes all LEDs used by this application. - */ -static void leds_init(void) -{ - nrf_gpio_cfg_output(ADVERTISING_LED_PIN_NO); - nrf_gpio_cfg_output(CONNECTED_LED_PIN_NO); - nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO); - nrf_gpio_pin_set(CONNECTED_LED_PIN_NO); -} - - -#if !defined(NRF_DFU_BLE_REQUIRES_BONDS) || (NRF_DFU_BLE_REQUIRES_BONDS == 0) -static uint32_t gap_address_change(void) -{ - uint32_t err_code; - ble_gap_addr_t addr; - -#if (NRF_SD_BLE_API_VERSION < 3) - err_code = sd_ble_gap_address_get(&addr); -#else - err_code = sd_ble_gap_addr_get(&addr); -#endif - - VERIFY_SUCCESS(err_code); - - // Increase the BLE address by one when advertising openly. - addr.addr[0] += 1; - -#if (NRF_SD_BLE_API_VERSION < 3) - err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr); -#else - err_code = sd_ble_gap_addr_set(&addr); -#endif - - VERIFY_SUCCESS(err_code); - - return NRF_SUCCESS; -} -#endif - - -/**@brief Function for GAP initialization. - * - * @details This function will set up all necessary GAP (Generic Access Profile) parameters of - * the device. It also sets the permissions and appearance. - */ -static uint32_t gap_params_init(void) -{ - uint32_t err_code; - ble_gap_conn_params_t gap_conn_params = {0}; - ble_gap_conn_sec_mode_t sec_mode; - uint8_t const * device_name; - uint32_t name_len; - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); - -#if !defined(NRF_DFU_BLE_REQUIRES_BONDS) || (NRF_DFU_BLE_REQUIRES_BONDS == 0) - - err_code = gap_address_change(); - VERIFY_SUCCESS(err_code); - - if ((m_flags & DFU_BLE_FLAG_USE_ADV_NAME) != 0) - { - NRF_LOG_DEBUG("Setting adv name: %s, length: %d", (uint32_t)m_adv_name.name, m_adv_name.len); - device_name = m_adv_name.name; - name_len = m_adv_name.len; - } - else -#endif - { - NRF_LOG_DEBUG("Regular adv name"); - device_name = (uint8_t const *)DEVICE_NAME; - name_len = strlen(DEVICE_NAME); - } - - err_code = sd_ble_gap_device_name_set(&sec_mode, device_name, name_len); - VERIFY_SUCCESS(err_code); - - 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); - return err_code; -} - - -static uint32_t ble_stack_init(bool init_softdevice) -{ - uint32_t err_code; - uint32_t ram_start = 0; - ble_cfg_t ble_cfg = {{0}}; - - #if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - ble_cfg_t ble_gatts_cfg_service_changed = {{0}}; - #endif - - if (init_softdevice) - { - err_code = nrf_dfu_mbr_init_sd(); - VERIFY_SUCCESS(err_code); - } - - NRF_LOG_DEBUG("vector table: 0x%08x", BOOTLOADER_START_ADDR); - err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_START_ADDR); - VERIFY_SUCCESS(err_code); - NRF_LOG_DEBUG("vector table: 0x%08x", BOOTLOADER_START_ADDR); - - NRF_LOG_DEBUG("Error code - sd_softdevice_vector_table_base_set: 0x%08x", err_code); - - err_code = nrf_sdh_enable_request(); - APP_ERROR_CHECK(err_code); - - // Fetch the start address of the application RAM. - err_code = nrf_sdh_ble_app_ram_start_get(&ram_start); - VERIFY_SUCCESS(err_code); - - // Configure the maximum number of connections. - memset(&ble_cfg, 0, sizeof(ble_cfg)); - ble_cfg.gap_cfg.role_count_cfg.periph_role_count = 1; - 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); - - memset(&ble_cfg, 0x00, sizeof(ble_cfg)); - ble_cfg.conn_cfg.conn_cfg_tag = APP_BLE_CONN_CFG_TAG; - ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE; - - err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start); - - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Error code - sd_ble_cfg_set: 0x%08x", err_code); - return err_code; - } - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - NRF_LOG_DEBUG("Running Service Changed config"); - - ble_gatts_cfg_service_changed.gatts_cfg.service_changed.service_changed = 1; - err_code = sd_ble_cfg_set(BLE_GATTS_CFG_SERVICE_CHANGED, &ble_gatts_cfg_service_changed, ram_start); - VERIFY_SUCCESS(err_code); - - NRF_LOG_DEBUG("Finished running Service Changed config"); -#endif - - NRF_LOG_DEBUG("Enabling SoftDevice."); - - // Enable BLE stack. - err_code = nrf_sdh_ble_enable(&ram_start); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed softdevice_enable: 0x%08x", err_code); - } - else - { - NRF_LOG_DEBUG("SoftDevice enabled."); - } - - NRF_SDH_BLE_OBSERVER(m_ble_evt_observer, BLE_OBSERVER_PRIO, ble_evt_handler, NULL); - - return err_code; -} - - -/**@brief Function for adding DFU Packet characteristic to the BLE Stack. - * - * @param[in] p_dfu DFU Service structure. - * - * @return NRF_SUCCESS on success. Otherwise an error code. - */ -static uint32_t dfu_pkt_char_add(ble_dfu_t * const p_dfu) -{ - ble_gatts_char_md_t char_md = {{0}}; - ble_gatts_attr_t attr_char_value = {0}; - ble_gatts_attr_md_t attr_md = {{0}}; - ble_uuid_t char_uuid; - - char_md.char_props.write_wo_resp = 1; - - char_uuid.type = p_dfu->uuid_type; - char_uuid.uuid = BLE_DFU_PKT_CHAR_UUID; - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm); -#else - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); -#endif - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.vlen = 1; - - attr_char_value.p_uuid = &char_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.max_len = MAX_DFU_PKT_LEN; - attr_char_value.p_value = NULL; - - return sd_ble_gatts_characteristic_add(p_dfu->service_handle, - &char_md, - &attr_char_value, - &p_dfu->dfu_pkt_handles); -} - - -/**@brief Function for adding DFU Control Point characteristic to the BLE Stack. - * - * @param[in] p_dfu DFU Service structure. - * - * @return NRF_SUCCESS on success. Otherwise an error code. - */ -static uint32_t dfu_ctrl_pt_add(ble_dfu_t * const p_dfu) -{ - ble_gatts_char_md_t char_md = {{0}}; - ble_gatts_attr_t attr_char_value = {0}; - ble_gatts_attr_md_t attr_md = {{0}}; - ble_uuid_t char_uuid; - - char_md.char_props.write = 1; - char_md.char_props.notify = 1; - - char_uuid.type = p_dfu->uuid_type; - char_uuid.uuid = BLE_DFU_CTRL_PT_UUID; - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm); -#else - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); -#endif - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.wr_auth = 1; - attr_md.vlen = 1; - - attr_char_value.p_uuid = &char_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.max_len = BLE_GATT_ATT_MTU_DEFAULT; - attr_char_value.p_value = NULL; - - return sd_ble_gatts_characteristic_add(p_dfu->service_handle, - &char_md, - &attr_char_value, - &p_dfu->dfu_ctrl_pt_handles); -} - - -/**@brief Function for checking if the CCCD of DFU Control point is configured for Notification. - * - * @details This function checks if the CCCD of DFU Control Point characteristic is configured - * for Notification by the DFU Controller. - * - * @param[in] p_dfu DFU Service structure. - * - * @return True if the CCCD of DFU Control Point characteristic is configured for Notification. - * False otherwise. - */ -uint32_t ble_dfu_init(ble_dfu_t * p_dfu) -{ - ble_uuid_t service_uuid; - uint32_t err_code; - - ASSERT(p_dfu != NULL); - - m_conn_handle = BLE_CONN_HANDLE_INVALID; - - BLE_UUID_BLE_ASSIGN(service_uuid, BLE_DFU_SERVICE_UUID); - - err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, - &service_uuid, - &(p_dfu->service_handle)); - VERIFY_SUCCESS(err_code); - - ble_uuid128_t const base_uuid128 = - { - { - 0x50, 0xEA, 0xDA, 0x30, 0x88, 0x83, 0xB8, 0x9F, - 0x60, 0x4F, 0x15, 0xF3, 0x00, 0x00, 0xC9, 0x8E - } - }; - - err_code = sd_ble_uuid_vs_add(&base_uuid128, &p_dfu->uuid_type); - VERIFY_SUCCESS(err_code); - - err_code = dfu_pkt_char_add(p_dfu); - VERIFY_SUCCESS(err_code); - - err_code = dfu_ctrl_pt_add(p_dfu); - VERIFY_SUCCESS(err_code); - - m_flags |= DFU_BLE_FLAG_SERVICE_INITIALIZED; - - return NRF_SUCCESS; -} - - -uint32_t ble_dfu_transport_init(void) -{ - uint32_t err_code; - - NRF_LOG_DEBUG("Initializing BLE DFU transport"); - - leds_init(); - -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) - // Copy out the peer data if bonds are required - if (nrf_dfu_settings_peer_data_is_valid()) - { - NRF_LOG_DEBUG("Copying peer data"); - (void)nrf_dfu_settings_peer_data_copy(&m_peer_data); - - } - else - { - APP_ERROR_HANDLER(NRF_ERROR_INTERNAL); - } -#endif - - err_code = ble_stack_init(true); - VERIFY_SUCCESS(err_code); - -#if !defined(NRF_DFU_BLE_REQUIRES_BONDS) || (NRF_DFU_BLE_REQUIRES_BONDS == 0) - // Copy out the new advertisement name when bonds are not required and name is set. - if (nrf_dfu_settings_adv_name_is_valid()) - { - (void)nrf_dfu_settings_adv_name_copy(&m_adv_name); - - // Set flags for advertisement name that is to be used - m_flags |= DFU_BLE_FLAG_USE_ADV_NAME; - - NRF_LOG_DEBUG("nrf_dfu_settings_adv_name_is_valid TRUE"); - } - else - { - NRF_LOG_DEBUG("nrf_dfu_settings_adv_name_is_valid FALSE"); - } -#endif - - err_code = gap_params_init(); - VERIFY_SUCCESS(err_code); - - // Initialize the Device Firmware Update Service. - err_code = ble_dfu_init(&m_dfu); - VERIFY_SUCCESS(err_code); - - err_code = advertising_start(); - VERIFY_SUCCESS(err_code); - - NRF_LOG_DEBUG("Finished initializing BLE DFU transport"); - - return NRF_SUCCESS; -} - - -uint32_t ble_dfu_transport_close(void) -{ - uint32_t err_code = NRF_SUCCESS; - - NRF_LOG_DEBUG("Shutting down BLE transport."); - - if (m_conn_handle != BLE_CONN_HANDLE_INVALID) - { - NRF_LOG_DEBUG("Disconnecting."); - - // Set flag to prevent advertisement from starting - m_flags |= DFU_BLE_RESETTING_SOON; - - // Disconnect from peer. - err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); - VERIFY_SUCCESS(err_code); - - // Wait a bit for the disconnect event to be sent on air. - nrf_delay_ms(200); - } - else - { - advertising_stop(); - } - - NRF_LOG_DEBUG("BLE transport shut down."); - - return err_code; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.c deleted file mode 100644 index 750def2..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.c +++ /dev/null @@ -1,238 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "nrf_dfu.h" - -#include "boards.h" -#include "nrf_power.h" -#include "nrf_soc.h" -#include "nrf_clock.h" -#include "nrf_drv_clock.h" - -#include "nrf_bootloader_app_start.h" -#include "nrf_bootloader_info.h" -#include "nrf_dfu_settings.h" -#include "nrf_dfu_utils.h" -#include "nrf_dfu_transport.h" -#include "nrf_dfu_req_handler.h" -#include "app_scheduler.h" -#include "app_timer.h" -#include "nrf_log.h" -#include "nrf_log_ctrl.h" - -#ifdef NRF_DFU_DEBUG_VERSION -#include "nrf_delay.h" -#endif //NRF_DFU_DEBUG_VERSION - - -#define BOOTLOADER_DFU_START 0xB1 /**< Magic value written to retention register when starting buttonless DFU. */ -#define SCHED_QUEUE_SIZE 16 /**< Maximum number of events in the scheduler queue. */ - - -// Inactivity timer to resets the device. -// It can be stopped by transports when they are active and restarted as necessary. -static app_timer_t nrf_dfu_inactivity_timeout_timer = {{0}}; -const app_timer_id_t nrf_dfu_inactivity_timeout_timer_id = &nrf_dfu_inactivity_timeout_timer; - - -/** @brief Weak implemenation of nrf_dfu_check_enter. - * - * @note This function must be overridden to enable entering DFU mode at will. - * Default behaviour is to enter DFU when BOOTLOADER_BUTTON is pressed. - */ -__WEAK bool nrf_dfu_enter_check(void) -{ - if (nrf_dfu_button_enter_check() == true) - { - return true; - } - - if (nrf_power_gpregret_get() == BOOTLOADER_DFU_START) - { - return true; - } - - if (s_dfu_settings.enter_buttonless_dfu == 1) - { - s_dfu_settings.enter_buttonless_dfu = 0; - APP_ERROR_CHECK(nrf_dfu_settings_write(NULL)); - return true; - } - return false; -} - - -static void clock_init(void) -{ - ret_code_t err_code; - - NRF_LOG_DEBUG("Initializing the clock."); - err_code = nrf_drv_clock_init(); - APP_ERROR_CHECK(err_code); - - nrf_drv_clock_lfclk_request(NULL); - - // Wait for the clock to be ready. - while (!nrf_clock_lf_is_running()) {;} -} - - -/**@brief Function for initializing the timer module. */ -static void timers_init(void) -{ - ret_code_t err_code; - - err_code = app_timer_init(); - APP_ERROR_CHECK(err_code); - - // Start a single shot timer that will reset the DFU on timeout. - err_code = app_timer_create(&nrf_dfu_inactivity_timeout_timer_id, - APP_TIMER_MODE_SINGLE_SHOT, - nrf_dfu_reset_timeout_handler); - APP_ERROR_CHECK(err_code); -} - - -/** @brief Function for initializing the event scheduler. */ -static void scheduler_init(void) -{ - APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); -} - - -static void wait_for_event() -{ - while (true) - { - app_sched_execute(); - if (!NRF_LOG_PROCESS()) - { - #ifdef BLE_STACK_SUPPORT_REQD - (void)sd_app_evt_wait(); - #else - __WFE(); - #endif - } - } -} - - -uint32_t nrf_dfu_init() -{ - uint32_t ret_val = NRF_SUCCESS; - uint32_t enter_bootloader_mode = 0; - - NRF_LOG_DEBUG("In real nrf_dfu_init"); - - nrf_dfu_settings_init(false); - - // Initialize the clock and timers. - clock_init(); - timers_init(); - - // Continue ongoing DFU operations - // Note that this part does not rely on SoftDevice interaction - ret_val = nrf_dfu_continue(&enter_bootloader_mode); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_DEBUG("Could not continue DFU operation: 0x%08x", ret_val); - enter_bootloader_mode = 1; - } - - // Check if there is a reason to enter DFU mode - // besides the effect of the continuation - if (nrf_dfu_enter_check()) - { - NRF_LOG_DEBUG("Application sent bootloader request"); - enter_bootloader_mode = 1; - } - - nrf_power_gpregret_set(0); - - if (enter_bootloader_mode != 0 || !nrf_dfu_app_is_valid()) - { - scheduler_init(); - - // Start the inactivity timer. - ret_val = app_timer_start(nrf_dfu_inactivity_timeout_timer_id, - APP_TIMER_TICKS(NRF_DFU_INACTIVITY_TIMEOUT_MS), - NULL); - - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("Could not initialize inactivity timer"); - return ret_val; - } - - // Initializing transports - ret_val = nrf_dfu_transports_init(); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("Could not initalize DFU transport: 0x%08x", ret_val); - return ret_val; - } - - (void)nrf_dfu_req_handler_init(); - - // This function will never return - NRF_LOG_DEBUG("Waiting for events"); - wait_for_event(); - NRF_LOG_DEBUG("After waiting for events"); - } - - // Erase additional data like peer data or advertisement name - ret_val = nrf_dfu_settings_additional_erase(); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (nrf_dfu_app_is_valid()) - { - // Uninitialize the clock driver to prevent interfering with app. - nrf_drv_clock_uninit(); - - NRF_LOG_DEBUG("Jumping to: 0x%08x", MAIN_APPLICATION_START_ADDR); - nrf_bootloader_app_start(MAIN_APPLICATION_START_ADDR); - } - - // Should not be reached! - NRF_LOG_INFO("After real nrf_dfu_init"); - return NRF_SUCCESS; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.h deleted file mode 100644 index 5b63bad..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2016 - 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 sdk_nrf_dfu_mbr MBR functions - * @{ - * @ingroup nrf_dfu - */ - -#ifndef NRF_DFU_MBR_H__ -#define NRF_DFU_MBR_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief Function for copying the bootloader using an MBR command. - * - * @param[in] p_src Source address of the bootloader data to copy. - * @param[in] len Length of the data to copy in bytes. - * - * @return This function will return only if the command request could not be run. - * See @ref sd_mbr_command_copy_bl_t for possible return values. - */ -uint32_t nrf_dfu_mbr_copy_bl(uint32_t * p_src, uint32_t len); - - -/** @brief Function for copying the SoftDevice using an MBR command. - * - * @param[in] p_dst Target of the SoftDevice copy. - * @param[in] p_src Source address of the SoftDevice image to copy. - * @param[in] len Length of the data to copy in bytes. - * - * @retval NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly. - * @retval NRF_ERROR_INVALID_LENGTH Invalid len - * @retval NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF). - * @retval NRF_ERROR_INVALID_PARAM if an invalid command is given. - * @retval NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying. - */ -uint32_t nrf_dfu_mbr_copy_sd(uint32_t * p_dst, uint32_t * p_src, uint32_t len); - - -/** @brief Function for initializing the SoftDevice using an MBR command. - * - * @retval NRF_SUCCESS If the SoftDevice was copied successfully. - * Any other return value indicates that the SoftDevice - * could not be copied. - */ -uint32_t nrf_dfu_mbr_init_sd(void); - - -/** @brief Function for comparing source and target using an MBR command. - * - * @param[in] p_ptr1 First pointer to data to compare. - * @param[in] p_ptr2 Second pointer to data to compare. - * @param[in] len Length of the data to compare in bytes. - * - * @retval NRF_SUCCESS If the content of both memory blocks is equal. - * @retval NRF_ERROR_NULL If the content of the memory blocks differs. - */ -uint32_t nrf_dfu_mbr_compare(uint32_t * p_ptr1, uint32_t * p_ptr2, uint32_t len); - - -/** @brief Function for setting the address of the vector table using an MBR command. - * - * @param[in] address Address of the new vector table. - * - * @retval NRF_SUCCESS If the address of the new vector table was set. Any other - * return value indicates that the address could not be set. - */ -uint32_t nrf_dfu_mbr_vector_table_set(uint32_t address); - - -#ifndef SOFTDEVICE_PRESENT -/** @brief Function for setting the address of the irq table using an MBR command. - * - * @param[in] address Address of the new irq table. - * - * @retval NRF_SUCCESS If the address of the new irq table was set. Any other - * return value indicates that the address could not be set. - */ -uint32_t nrf_dfu_mbr_irq_forward_address_set(uint32_t address); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DFU_MBR_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h deleted file mode 100644 index d48b69d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) 2016 - 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 sdk_nrf_dfu_req_handler Request handling - * @{ - * @ingroup nrf_dfu - */ - -#ifndef NRF_DFU_REQ_HANDLER_H__ -#define NRF_DFU_REQ_HANDLER_H__ - -#include -#include -#include "nrf_dfu_types.h" -#include "nrf_dfu_handling_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**@brief DFU object types. - */ -typedef enum -{ - NRF_DFU_OBJ_TYPE_INVALID, /**< Invalid object type.*/ - NRF_DFU_OBJ_TYPE_COMMAND, /**< Command object packet.*/ - NRF_DFU_OBJ_TYPE_DATA, /**< Data object.*/ -} nrf_dfu_obj_type_t; - - -/**@brief DFU request operation codes. - * - * @details The DFU transport layer creates request events of these types. The implementation of @ref nrf_dfu_req_handler_on_req handles requests of these types. - */ -typedef enum -{ - - NRF_DFU_OBJECT_OP_NONE = 0, /**< No operation set. */ - NRF_DFU_OBJECT_OP_CREATE = 1, /**< Create operation. The length of the request indicates the required size. When called, the created object is selected. */ - NRF_DFU_OBJECT_OP_WRITE = 2, /**< Write operation. When called, offset and CRC of the selected object are reported back. */ - NRF_DFU_OBJECT_OP_EXECUTE = 3, /**< Execute operation. When called, the selected object is executed. */ - NRF_DFU_OBJECT_OP_CRC = 4, /**< Calculate checksum operation. When called, offset and CRC of the selected object are reported back. */ - NRF_DFU_OBJECT_OP_SELECT = 6, /**< Select operation. When called, the object of the given type is selected, and information about the object is reported back. */ - NRF_DFU_OBJECT_OP_OTHER = 7, /**< A user-defined DFU request type. The application must define how to interpret the request. */ -} nrf_dfu_req_op_t; - - -#if defined(__CC_ARM) - #pragma push - #pragma anon_unions -#elif defined(__ICCARM__) - #pragma language=extended -#elif defined(__GNUC__) - // Anonymous unions are enabled by default. -#endif - - -/** @brief Definition of a DFU request sent from the transport layer. - * - * @details When the transport layer gets a DFU event, it calls the function @ref nrf_dfu_req_handler_on_req to handle the DFU request. - */ -typedef struct -{ - nrf_dfu_req_op_t req_type; /**< Request operation type. */ - - union - { - struct - { - uint32_t obj_type; /**< Object type of the object to be created for a request of type @ref NRF_DFU_OBJECT_OP_CREATE. */ - uint32_t object_size; /**< Size of the object to be created for a request of type @ref NRF_DFU_OBJECT_OP_CREATE. Note that the object size is not the same as the size of the firmware. */ - }; - - struct - { - uint8_t * p_req; /**< Pointer to an array holding the serialized version of the request. */ - uint32_t req_len; /**< Length of the request array. */ - }; - }; -} nrf_dfu_req_t; - - -/** @brief Response used during DFU operations. - */ -typedef struct -{ - union - { - struct - { - uint8_t * p_res; /**< Pointer to an array holding the serialized version of the response. */ - uint32_t res_len; /**< Length of the response array. */ - }; - - struct - { - uint32_t max_size; /**< Maximum size of the object of a given type. */ - uint32_t offset; /**< Current offset. */ - uint32_t crc; /**< Current CRC. */ - }; - }; -} nrf_dfu_res_t; - -#if defined(__CC_ARM) - #pragma pop -#elif defined(__ICCARM__) - // Leave anonymous unions enabled. -#elif defined(__GNUC__) - // Anonymous unions are enabled by default. -#endif - - -/** @brief Function for initializing the request handling module. - * - * @details This function initializes the flash with or without the SoftDevice, depending on the project configuration. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_STATE If the fstorage module could not be initiated or the SoftDevice could not set the event handler. - */ -uint32_t nrf_dfu_req_handler_init(void); - - -/** @brief Function type for handling a DFU request. - * - * @param[in,out] p_context Pointer to context-specific RAM required for - * running the command request. - * This value may be NULL if the command request - * does not require context-specific RAM. - * @param[in,out] p_req Pointer to the structure holding the DFU request. - * @param[in,out] p_res Pointer to the structure holding the DFU response. - * - * @retval NRF_DFU_RES_CODE_SUCCESS If the command request was executed successfully. - * Any other error code indicates that the request - * could not be handled. - */ -nrf_dfu_res_code_t nrf_dfu_req_handler_on_req(void * p_context, nrf_dfu_req_t * p_req, nrf_dfu_res_t * p_res); - - -/** @brief Function for resetting the device when the DFU process is complete. - * - * @details Checks if the DFU transfer is complete. If it is complete, all transports are closed down - * and reset is called. - */ -void nrf_dfu_req_handler_reset_if_dfu_complete(void); - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DFU_REQ_HANDLER_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.c deleted file mode 100644 index 1410dda..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.c +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "nrf_dfu_settings.h" -#include -#include -#include "app_error.h" -#include "nrf_dfu_flash.h" -#include "nrf_soc.h" -#include "crc32.h" -#include "nrf_nvmc.h" - -#define DFU_SETTINGS_INIT_COMMAND_OFFSET offsetof(nrf_dfu_settings_t, init_command) // -#include -#include "nrf_log.h" -#include "nrf_sdm.h" - -/** @brief External definitions of symbols for the start of the application image. - */ -#if (__LINT__ == 1) - // No implementation -#elif defined ( __CC_ARM ) - extern uint32_t* Image$$ER_IROM1$$Base __attribute__((used)); -#elif defined (__SES_ARM) && defined (__GNUC__) - extern uint32_t * _vectors; -#elif defined ( __GNUC__ ) - extern uint32_t * __isr_vector; -#elif defined ( __ICCARM__ ) - extern void * __vector_table; -#else - #error Not a valid compiler/linker for application image symbols. -#endif - - -/** @brief Macro for getting the start address of the application image. - * - * This macro is valid only when absolute placement is used for the application - * image. The macro is not a compile time symbol. It cannot be used as a - * constant expression, for example, inside a static assert or linker script - * at-placement. - */ -#if (__LINT__ == 1) - #define APP_START_ADDR (0x1F000) -#elif APP_START_ADDR - // Bootloader start address is defined at project level -#elif defined (__CC_ARM) - #define APP_START_ADDR (uint32_t)&Image$$ER_IROM1$$Base -#elif defined (__SES_ARM) && defined (__GNUC__) - #define APP_START_ADDR (uint32_t)&_vectors -#elif defined (__GNUC__) - #define APP_START_ADDR (uint32_t)&__isr_vector -#elif defined (__ICCARM__) - #define APP_START_ADDR (uint32_t)&__vector_table -#else - #error Not a valid compiler/linker for APP_START_ADDR. -#endif - - -uint32_t nrf_dfu_svci_vector_table_set(void) -{ - uint32_t err_code; - - if (NRF_UICR->NRFFW[0] != 0xFFFFFFFF) - { - NRF_LOG_INFO("Setting vector table to bootloader: 0x%08x", NRF_UICR->NRFFW[0]); - err_code = sd_softdevice_vector_table_base_set(NRF_UICR->NRFFW[0]); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed running sd_softdevice_vector_table_base_set"); - return err_code; - } - - return NRF_SUCCESS; - } - - NRF_LOG_ERROR("No bootloader was found"); - return NRF_ERROR_NO_MEM; -} - - -uint32_t nrf_dfu_svci_vector_table_unset(void) -{ - uint32_t err_code; - - NRF_LOG_INFO("Setting vector table to main app: 0x%08x", APP_START_ADDR); - err_code = sd_softdevice_vector_table_base_set(APP_START_ADDR); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed running sd_softdevice_vector_table_base_set"); - return err_code; - } - - return NRF_SUCCESS; -} - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_types.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_types.h deleted file mode 100644 index 0939d87..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_types.h +++ /dev/null @@ -1,327 +0,0 @@ -/** - * Copyright (c) 2016 - 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 sdk_nrf_dfu_types DFU types - * @{ - * @ingroup nrf_dfu - */ - -#ifndef NRF_DFU_TYPES_H__ -#define NRF_DFU_TYPES_H__ - -#include -#include - -#include "nrf.h" -#include "nrf_mbr.h" -#include "app_util_platform.h" - -#ifdef SOFTDEVICE_PRESENT -#include "nrf_sdm.h" -#include "ble_gap.h" -#endif - -#if defined(NRF_DFU_SVCI_ENABLED) - #include "nrf_dfu_svci.h" -#else - // Dummy type for nrf_dfu_peer_data_t if DFU SVCI is not in use - typedef struct - { - uint32_t crc; - } nrf_dfu_peer_data_t; - - // Dummy type for nrf_dfu_adv_name_t if DFU SVCI is not in use - typedef struct - { - uint32_t crc; - } nrf_dfu_adv_name_t; - -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(SOFTDEVICE_PRESENT) - -#include "nrf_sdm.h" - -/** @brief Start address of the SoftDevice (excluding the area for the MBR). - */ -#define SOFTDEVICE_REGION_START MBR_SIZE - - -#ifndef CODE_REGION_1_START -#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) -#endif - - -#else - -#ifndef CODE_REGION_1_START -#define CODE_REGION_1_START MBR_SIZE -#endif - -#endif - - -#define INIT_COMMAND_MAX_SIZE 256 /**< Maximum size of the init command stored in dfu_settings. */ - -/** @brief Size of a flash codepage. This value is used for calculating the size of the reserved - * flash space in the bootloader region. It is checked against NRF_UICR->CODEPAGESIZE - * at run time to ensure that the region is correct. - */ -#if defined(NRF51) - #define CODE_PAGE_SIZE (PAGE_SIZE_IN_WORDS * sizeof(uint32_t)) -#elif defined(NRF52) || defined(NRF52840_XXAA) - #define CODE_PAGE_SIZE (MBR_PAGE_SIZE_IN_WORDS * sizeof(uint32_t)) -#else - #error "Architecture not set." -#endif - - -/** @brief Maximum size of a data object.*/ -#if defined( NRF51 ) - #define DATA_OBJECT_MAX_SIZE (CODE_PAGE_SIZE * 4) -#elif defined( NRF52_SERIES ) || defined ( __SDK_DOXYGEN__ ) - #define DATA_OBJECT_MAX_SIZE (CODE_PAGE_SIZE) -#else - #error "Architecture not set." -#endif - -/** @brief Page location of the bootloader settings address. - */ - -#if defined ( NRF51 ) - #define BOOTLOADER_SETTINGS_ADDRESS (0x0003FC00UL) -#elif defined( NRF52832_XXAA ) - #define BOOTLOADER_SETTINGS_ADDRESS (0x0007F000UL) -#elif defined( NRF52840_XXAA ) - #define BOOTLOADER_SETTINGS_ADDRESS (0x000FF000UL) -#else - #error No valid target set for BOOTLOADER_SETTINGS_ADDRESS. -#endif - - -#if defined(NRF52832_XXAA) - -/** - * @brief MBR parameters page in UICR. - * - * Register location in UICR where the page address of the MBR parameters page is stored (only used by the nRF52 MBR). - * - * @note If the value at the given location is 0xFFFFFFFF, no MBR parameters page is set. - */ -#define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18) - - -/** @brief Page location of the MBR parameters page address. - * - */ - -#if !defined(NRF52840_XXAA_ENGA) -#define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0007E000UL) -#else -#define NRF_MBR_PARAMS_PAGE_ADDRESS (0x000FE000UL) -#endif - -#endif - -#if defined(NRF52840_XXAA) - -/** - * @brief MBR parameters page in UICR. - * - * Register location in UICR where the page address of the MBR parameters page is stored (only used by the nRF52 MBR). - * - * @note If the value at the given location is 0xFFFFFFFF, no MBR parameters page is set. - */ -#define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18) - - -/** @brief Page location of the MBR parameters page address. - * - */ -#define NRF_MBR_PARAMS_PAGE_ADDRESS (0x000FE000UL) - -#endif - - -/** @brief Size of the flash space reserved for application data. - */ -#ifndef DFU_APP_DATA_RESERVED -#define DFU_APP_DATA_RESERVED CODE_PAGE_SIZE * 3 -#endif - - -/** @brief Total size of the region between the SoftDevice and the bootloader. - */ -#define DFU_REGION_TOTAL_SIZE ((* (uint32_t *)NRF_UICR_BOOTLOADER_START_ADDRESS) - CODE_REGION_1_START) - -#ifdef SOFTDEVICE_PRESENT -/** @brief Start address of the SoftDevice (excluding the area for the MBR). - */ -#define SOFTDEVICE_REGION_START MBR_SIZE - - -/** @brief Size of the Code Region 0, found in the UICR.CLEN0 register. - * - * @details This value is identical to the start of Code Region 1. This value is used for - * compilation safety, because the linker will fail if the application expands - * into the bootloader. At run time, the bootloader uses the value found in UICR.CLEN0. - */ - -#ifndef CODE_REGION_1_START -#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) -#endif -#else -#ifndef CODE_REGION_1_START -#define CODE_REGION_1_START MBR_SIZE -#endif -#endif - -#define NRF_DFU_CURRENT_BANK_0 0x00 -#define NRF_DFU_CURRENT_BANK_1 0x01 - -#define NRF_DFU_BANK_LAYOUT_DUAL 0x00 -#define NRF_DFU_BANK_LAYOUT_SINGLE 0x01 - - -/** @brief DFU bank state codes. - * - * @details The DFU bank state indicates the content of a bank: - * A valid image of a certain type or an invalid image. - */ - -#define NRF_DFU_BANK_INVALID 0x00 /**< Invalid image. */ -#define NRF_DFU_BANK_VALID_APP 0x01 /**< Valid application. */ -#define NRF_DFU_BANK_VALID_SD 0xA5 /**< Valid SoftDevice. */ -#define NRF_DFU_BANK_VALID_BL 0xAA /**< Valid bootloader. */ -#define NRF_DFU_BANK_VALID_SD_BL 0xAC /**< Valid SoftDevice and bootloader. */ - - -/** @brief Description of a single bank. */ -#pragma pack(4) -typedef struct -{ - uint32_t image_size; /**< Size of the image in the bank. */ - uint32_t image_crc; /**< CRC of the image. If set to 0, the CRC is ignored. */ - uint32_t bank_code; /**< Identifier code for the bank. */ -} nrf_dfu_bank_t; - -/**@brief DFU progress. - * - * Be aware of the difference between objects and firmware images. A firmware image consists of multiple objects, each of a maximum size @ref DATA_OBJECT_MAX_SIZE. - * - * @note The union inside this struct is cleared when CREATE_OBJECT of command type is executed, and when there is a valid post-validation. - * In DFU activation (after reset) the @ref sd_start_address will be used in case of a SD/SD+BL update. - */ -ANON_UNIONS_ENABLE -typedef struct -{ - uint32_t command_size; /**< The size of the current init command stored in the DFU settings. */ - uint32_t command_offset; /**< The offset of the currently received init command data. The offset will increase as the init command is received. */ - uint32_t command_crc; /**< The calculated CRC of the init command (calculated after the transfer is completed). */ - - uint32_t data_object_size; /**< The size of the last object created. Note that this size is not the size of the whole firmware image.*/ - - union - { - struct - { - uint32_t firmware_image_crc; /**< CRC value of the current firmware (continuously calculated as data is received). */ - uint32_t firmware_image_crc_last; /**< The CRC of the last executed object. */ - uint32_t firmware_image_offset; /**< The offset of the current firmware image being transferred. Note that this offset is the offset in the entire firmware image and not only the current object. */ - uint32_t firmware_image_offset_last;/**< The offset of the last executed object from the start of the firmware image. */ - }; - struct - { - uint32_t sd_start_address; /**< Value indicating the start address of the SoftDevice source. Used for an SD/SD+BL update where the SD changes size or if the DFU process had a power loss when updating a SD with changed size. */ - }; - }; -} dfu_progress_t; -ANON_UNIONS_DISABLE - - -/**@brief DFU settings for application and bank data. - */ -typedef struct -{ - uint32_t crc; /**< CRC for the stored DFU settings, not including the CRC itself. If 0xFFFFFFF, the CRC has never been calculated. */ - uint32_t settings_version; /**< Version of the currect DFU settings struct layout. */ - uint32_t app_version; /**< Version of the last stored application. */ - uint32_t bootloader_version; /**< Version of the last stored bootloader. */ - - uint32_t bank_layout; /**< Bank layout: single bank or dual bank. This value can change. */ - uint32_t bank_current; /**< The bank that is currently used. */ - - nrf_dfu_bank_t bank_0; /**< Bank 0. */ - nrf_dfu_bank_t bank_1; /**< Bank 1. */ - - uint32_t write_offset; /**< Write offset for the current operation. */ - uint32_t sd_size; /**< SoftDevice size (if combined BL and SD). */ - - dfu_progress_t progress; /**< Current DFU progress. */ - - uint32_t enter_buttonless_dfu; - uint8_t init_command[INIT_COMMAND_MAX_SIZE]; /**< Buffer for storing the init command. */ - - nrf_dfu_peer_data_t peer_data; /**< Not included in calculated CRC. */ - nrf_dfu_adv_name_t adv_name; /**< Not included in calculated CRC. */ -} nrf_dfu_settings_t; - - -#ifdef SOFTDEVICE_PRESENT - - -#endif // SYSTEM_SERVICE_ATT_SIZE - - -#pragma pack() // revert pack settings - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DFU_TYPES_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.c deleted file mode 100644 index c2e2d2e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.c +++ /dev/null @@ -1,678 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "nrf_dfu_utils.h" - -#include -#include "nrf_dfu_settings.h" -#include "nrf_dfu_mbr.h" -#include "nrf_bootloader_app_start.h" -#include "nrf_bootloader_info.h" -#include "crc32.h" -#include "nrf_log.h" -#include "nrf_log_ctrl.h" -#include "app_timer.h" -#include "nrf_delay.h" - - -static app_timer_t nrf_dfu_post_sd_bl_timeout_timer = { {0} }; -const app_timer_id_t nrf_dfu_post_sd_bl_timeout_timer_id = &nrf_dfu_post_sd_bl_timeout_timer; - -/** - * Round up val to the next page boundry - */ -static uint32_t align_to_page(uint32_t val) -{ - return ((val + CODE_PAGE_SIZE - 1 ) &~ (CODE_PAGE_SIZE - 1)); -} - - -static void nrf_dfu_invalidate_bank(nrf_dfu_bank_t * p_bank) -{ - // Set the bank-code to invalid, and reset size/CRC - memset(p_bank, 0, sizeof(nrf_dfu_bank_t)); - - // Reset write pointer after completed operation - s_dfu_settings.write_offset = 0; - - // Reset SD size - s_dfu_settings.sd_size = 0; - - // Promote dual bank layout - s_dfu_settings.bank_layout = NRF_DFU_BANK_LAYOUT_DUAL; - - // Signify that bank 0 is empty - s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_0; -} - - -/** @brief Function to continue application update. - * - * @details This function will be called after reset if there is a valid application in Bank1 - * required to be copied down to Bank 0. - * - * @param[in] src_addr Source address of the application to copy from Bank1 to Bank0. - * - * @retval NRF_SUCCESS Continuation was successful. - * @retval NRF_ERROR_NULL Invalid data during compare. - * @retval FS_ERR_UNALIGNED_ADDR A call to fstorage was not aligned to a page boundary or the address was not word aliged. - * @retval FS_ERR_INVALID_ADDR The destination of a call to fstorage does not point to - * the start of a flash page or the operation would - * go beyond the flash memory boundary. - * @retval FS_ERR_NOT_INITIALIZED The fstorage module is not initialized. - * @retval FS_ERR_INVALID_CFG The initialization of the fstorage module is invalid. - * @retval FS_ERR_NULL_ARG A call to fstorage had an invalid NULL argument. - * @retval FS_ERR_INVALID_ARG A call to fstorage had invalid arguments. - * @retval FS_ERR_QUEUE_FULL If the internal operation queue of the fstorage module is full. - * @retval FS_ERR_FAILURE_SINCE_LAST If an error occurred in another transaction and fstorage cannot continue before - * the event has been dealt with. - */ -static uint32_t nrf_dfu_app_continue(uint32_t src_addr) -{ - // This function is only in use when new app is present in Bank 1 - uint32_t const image_size = s_dfu_settings.bank_1.image_size; - uint32_t const split_size = CODE_PAGE_SIZE; // Must be page aligned - - uint32_t ret_val = NRF_SUCCESS; - uint32_t target_addr = MAIN_APPLICATION_START_ADDR + s_dfu_settings.write_offset; - uint32_t length_left = (image_size - s_dfu_settings.write_offset); - uint32_t cur_len; - uint32_t crc; - - NRF_LOG_DEBUG("Enter nrf_dfu_app_continue"); - - src_addr += s_dfu_settings.write_offset; - - // Copy the application down safely - do - { - cur_len = (length_left > split_size) ? split_size : length_left; - - // Erase the target page - ret_val = nrf_dfu_flash_erase(target_addr, split_size / CODE_PAGE_SIZE, NULL); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // Flash one page - ret_val = nrf_dfu_flash_store(target_addr, (uint32_t*)src_addr, cur_len, NULL); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_dfu_mbr_compare((uint32_t*)target_addr, (uint32_t*)src_addr, cur_len); - if (ret_val != NRF_SUCCESS) - { - // We will not retry the copy - NRF_LOG_ERROR("Invalid data during compare: target: 0x%08x, src: 0x%08x", target_addr, src_addr); - return ret_val; - } - - s_dfu_settings.write_offset += cur_len; - ret_val = nrf_dfu_settings_write(NULL); - - target_addr += cur_len; - src_addr += cur_len; - - length_left -= cur_len; - } - while (length_left > 0); - - // Check the CRC of the copied data. Enable if so. - crc = crc32_compute((uint8_t*)MAIN_APPLICATION_START_ADDR, image_size, NULL); - - if (crc == s_dfu_settings.bank_1.image_crc) - { - NRF_LOG_DEBUG("Setting app as valid"); - s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_VALID_APP; - s_dfu_settings.bank_0.image_crc = crc; - s_dfu_settings.bank_0.image_size = image_size; - } - else - { - NRF_LOG_ERROR("CRC computation failed for copied app: " - "src crc: 0x%08x, res crc: 0x%08x", - s_dfu_settings.bank_1.image_crc, - crc); - } - - nrf_dfu_invalidate_bank(&s_dfu_settings.bank_1); - ret_val = nrf_dfu_settings_write(NULL); - - return ret_val; -} - -/** - * @brief Flash storage callback used to reset the device if no new DFU is initiated within the timer's expiration. - * - * After the completion of a SD, BL or SD + BL update, the controller might want to update the - * application as well. Because of this, the DFU target will stay in bootloader mode for some - * time after completion. However, if no such update is received, the device should reset - * to look for a valid app and resume regular operation. - */ -static void reset_device_callback(nrf_fstorage_evt_t * p_evt) -{ - uint32_t err_code; - - // Verify that the current application is valid. - if (nrf_dfu_app_is_valid()) - { - NRF_LOG_DEBUG("Starting reset delay timer"); - - err_code = app_timer_create(&nrf_dfu_post_sd_bl_timeout_timer_id, APP_TIMER_MODE_SINGLE_SHOT, nrf_dfu_reset_timeout_handler); - APP_ERROR_CHECK(err_code); - // 3400 ms is the smallest stable value with nRF Connect for PC v1.1.1. - // 7500 ms is the smallest stable value with nRF Connect for Android v1.1.1. - // Smaller values may allow the device to reset before the next DFU transation is started. - err_code = app_timer_start(nrf_dfu_post_sd_bl_timeout_timer_id, APP_TIMER_TICKS(NRF_DFU_POST_SD_BL_TIMEOUT_MS), NULL); - APP_ERROR_CHECK(err_code); - } -} - - -/** @brief Function to execute the continuation of a SoftDevice update. - * - * @param[in] src_addr Source address of the SoftDevice to copy from. - * @param[in] p_bank Pointer to the bank where the SoftDevice resides. - * - * @retval NRF_SUCCESS Continuation was successful. - * @retval NRF_ERROR_INVALID_LENGTH Invalid length. - * @retval NRF_ERROR_NO_MEM If UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF). - * @retval NRF_ERROR_INVALID_PARAM If an invalid command is given. - * @retval NRF_ERROR_INTERNAL Indicates that the contents of the memory blocks were not verified correctly after copying. - * @retval NRF_ERROR_NULL If the content of the memory blocks differs after copying. - */ -#if defined(SOFTDEVICE_PRESENT) -static uint32_t nrf_dfu_sd_continue_impl(uint32_t src_addr, - nrf_dfu_bank_t * p_bank) -{ - uint32_t ret_val = NRF_SUCCESS; - uint32_t target_addr = SOFTDEVICE_REGION_START + s_dfu_settings.write_offset; - uint32_t length_left = align_to_page(s_dfu_settings.sd_size - s_dfu_settings.write_offset); - uint32_t split_size = align_to_page(length_left / 4); - - NRF_LOG_DEBUG("Enter nrf_bootloader_dfu_sd_continue"); - - // This can be a continuation due to a power failure - src_addr += s_dfu_settings.write_offset; - - if (s_dfu_settings.sd_size != 0 && s_dfu_settings.write_offset == s_dfu_settings.sd_size) - { - NRF_LOG_DEBUG("SD already copied"); - return NRF_SUCCESS; - } - - if (s_dfu_settings.write_offset == 0) - { - NRF_LOG_DEBUG("Updating SD. Old SD ver: %d, New ver: %d", - SD_VERSION_GET(MBR_SIZE) / 100000, SD_VERSION_GET(src_addr) / 100000); - - // Save the absolute address of SD in case SD/SD+BL update. - s_dfu_settings.progress.sd_start_address = src_addr; - } - - do - { - // If less than split size remain, reduce split size to avoid overwriting Bank 0. - if (split_size > length_left) - { - split_size = align_to_page(length_left); - } - - NRF_LOG_DEBUG("Copying [0x%08x-0x%08x] to [0x%08x-0x%08x]: Len: 0x%08x", src_addr, src_addr + split_size, target_addr, target_addr + split_size, split_size); - - // Copy a chunk of the SD. Size in words - ret_val = nrf_dfu_mbr_copy_sd((uint32_t*)target_addr, (uint32_t*)src_addr, split_size); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed to copy SD: target: 0x%08x, src: 0x%08x, len: 0x%08x", target_addr, src_addr, split_size); - return ret_val; - } - - NRF_LOG_DEBUG("Finished copying [0x%08x-0x%08x] to [0x%08x-0x%08x]: Len: 0x%08x", src_addr, src_addr + split_size, target_addr, target_addr + split_size, split_size); - - // Validate copy. Size in words - ret_val = nrf_dfu_mbr_compare((uint32_t*)target_addr, (uint32_t*)src_addr, split_size); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed to Compare SD: target: 0x%08x, src: 0x%08x, len: 0x%08x", target_addr, src_addr, split_size); - return ret_val; - } - - NRF_LOG_DEBUG("Validated 0x%08x-0x%08x to 0x%08x-0x%08x: Size: 0x%08x", src_addr, src_addr + split_size, target_addr, target_addr + split_size, split_size); - - target_addr += split_size; - src_addr += split_size; - - if (split_size > length_left) - { - length_left = 0; - } - else - { - length_left -= split_size; - } - - NRF_LOG_DEBUG("Finished with the SD update."); - - // Save the updated point of writes in case of power loss - s_dfu_settings.write_offset = s_dfu_settings.sd_size - length_left; - ret_val = nrf_dfu_settings_write(NULL); - } - while (length_left > 0); - - return ret_val; -} - - -/** @brief Function to continue SoftDevice update. - * - * @details This function will be called after reset if there is a valid SoftDevice in Bank0 or Bank1 - * required to be relocated and activated through MBR commands. - * - * @param[in] src_addr Source address of the SoftDevice to copy from. - * @param[in] p_bank Pointer to the bank where the SoftDevice resides. - * - * @retval NRF_SUCCESS Continuation was successful. - * @retval NRF_ERROR_INVALID_LENGTH Invalid length. - * @retval NRF_ERROR_NO_MEM If UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF). - * @retval NRF_ERROR_INVALID_PARAM If an invalid command is given. - * @retval NRF_ERROR_INTERNAL Indicates that the contents of the memory blocks were not verified correctly after copying. - * @retval NRF_ERROR_NULL If the content of the memory blocks differs after copying. - */ -static uint32_t nrf_dfu_sd_continue(uint32_t src_addr, - nrf_dfu_bank_t * p_bank) -{ - uint32_t ret_val; - - // If the continuation is after a power loss, SoftDevice may already have started to be copied. - // In this case, use the absolute value of the SoftDevice start address to ensure correct copy. - if (s_dfu_settings.progress.sd_start_address != 0) - { - src_addr = s_dfu_settings.progress.sd_start_address; - } - - ret_val = nrf_dfu_sd_continue_impl(src_addr, p_bank); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("SD update continuation failed"); - return ret_val; - } - - nrf_dfu_invalidate_bank(p_bank); - - // Upon successful completion, the callback function will be called and reset the device. If a valid app is present, it will launch. - NRF_LOG_DEBUG("Writing settings and reseting device."); - ret_val = nrf_dfu_settings_write(reset_device_callback); - - return ret_val; -} -#endif - -/** @brief Function to continue bootloader update. - * - * @details This function will be called after reset if there is a valid bootloader in Bank 0 or Bank 1 - * required to be relocated and activated through MBR commands. - * - * @param[in] src_addr Source address of the BL to copy from. - * @param[in] p_bank Pointer to the bank where the SoftDevice resides. - * - * @return This function will not return if the bootloader is copied successfully. - * After the copy is verified, the device will reset and start the new bootloader. - * - * @retval NRF_SUCCESS Continuation was successful. - * @retval NRF_ERROR_INVALID_LENGTH Invalid length of flash operation. - * @retval NRF_ERROR_NO_MEM If no parameter page is provided (see sds for more info). - * @retval NRF_ERROR_INVALID_PARAM If an invalid command is given. - * @retval NRF_ERROR_INTERNAL Internal error that should not happen. - * @retval NRF_ERROR_FORBIDDEN If NRF_UICR->BOOTADDR is not set. - */ -static uint32_t nrf_dfu_bl_continue(uint32_t src_addr, nrf_dfu_bank_t * p_bank) -{ - uint32_t ret_val = NRF_ERROR_NULL; - uint32_t const len = (p_bank->image_size - s_dfu_settings.sd_size); - - NRF_LOG_DEBUG("Verifying BL: Addr: 0x%08x, Src: 0x%08x, Len: 0x%08x", BOOTLOADER_START_ADDR, src_addr, len); - -#if NRF_DFU_WORKAROUND_PRE_SDK_14_1_0_SD_BL_UPDATE - // This code is a configurable workaround for updating SD+BL from SDK 12.x.y - 14.1.0 - // SoftDevice size increase would lead to unaligned source address when comparing new BL in SD+BL updates. - // This workaround is not required once BL is successfully installed with a version that is compiled SDK 14.1.0 -#if defined(NRF52832_XXAA) - if (p_bank->bank_code == NRF_DFU_BANK_VALID_SD_BL) - { - ret_val = nrf_dfu_mbr_compare((uint32_t*)BOOTLOADER_START_ADDR, (uint32_t*)(src_addr - 0x4000), len); - } -#endif // defined(NRF52832_XXAA) -#endif // #if NRF_DFU_WORKAROUND_PRE_SDK_14_1_0_SD_BL_UPDATE - - // Check if the BL has already been copied. - if (ret_val != NRF_SUCCESS) - { - ret_val = nrf_dfu_mbr_compare((uint32_t*)BOOTLOADER_START_ADDR, (uint32_t*)src_addr, len); - } - - // If the bootloader is the same as the banked version, the copy is finished - if (ret_val == NRF_SUCCESS) - { - NRF_LOG_DEBUG("Bootloader was verified"); - - // Invalidate bank, marking completion - nrf_dfu_invalidate_bank(p_bank); - - // Upon successful completion, the callback function will be called and reset the device. If a valid app is present, it will launch. - NRF_LOG_DEBUG("Writing settings and reseting device."); - ret_val = nrf_dfu_settings_write(reset_device_callback); - } - else - { - NRF_LOG_DEBUG("Bootloader not verified, copying: Src: 0x%08x, Len: 0x%08x", src_addr, len); - // Bootloader is different than the banked version. Continue copy - // Note that if the SD and BL was combined, then the split point between them is in s_dfu_settings.sd_size - ret_val = nrf_dfu_mbr_copy_bl((uint32_t*)src_addr, len); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("Request to copy BL failed"); - } - } - - return ret_val; -} - - -/** @brief Function to continue combined bootloader and SoftDevice update. - * - * @details This function will be called after reset if there is a valid bootloader and SoftDevice in Bank 0 or Bank 1 - * required to be relocated and activated through MBR commands. - * - * @param[in] src_addr Source address of the combined bootloader and SoftDevice to copy from. - * @param[in] p_bank Pointer to the bank where the SoftDevice resides. - * - * @retval NRF_SUCCESS Continuation was successful. - * @retval NRF_ERROR_INVALID_LENGTH Invalid length. - * @retval NRF_ERROR_NO_MEM If UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF). - * @retval NRF_ERROR_INVALID_PARAM If an invalid command is given. - * @retval NRF_ERROR_INTERNAL Indicates that the contents of the memory blocks where not verified correctly after copying. - * @retval NRF_ERROR_NULL If the content of the memory blocks differs after copying. - * @retval NRF_ERROR_FORBIDDEN If NRF_UICR->BOOTADDR is not set. - */ -#if defined(SOFTDEVICE_PRESENT) -static uint32_t nrf_dfu_sd_bl_continue(uint32_t src_addr, nrf_dfu_bank_t * p_bank) -{ - uint32_t ret_val = NRF_SUCCESS; - - NRF_LOG_DEBUG("Enter nrf_dfu_sd_bl_continue"); - - // If the continuation is after a power loss, SoftDevice may already have started to be copied. - // In this case, use the absolute value of the SoftDevice start address to ensure correct copy. - if (s_dfu_settings.progress.sd_start_address != 0) - { - src_addr = s_dfu_settings.progress.sd_start_address; - } - - ret_val = nrf_dfu_sd_continue_impl(src_addr, p_bank); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("SD+BL: SD copy failed"); - return ret_val; - } - - src_addr += s_dfu_settings.sd_size; - - ret_val = nrf_dfu_bl_continue(src_addr, p_bank); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_ERROR("SD+BL: BL copy failed"); - return ret_val; - } - - return ret_val; -} -#endif - -static uint32_t nrf_dfu_continue_bank(nrf_dfu_bank_t * p_bank, uint32_t src_addr, uint32_t * p_enter_dfu_mode) -{ - uint32_t ret_val = NRF_SUCCESS; - - switch (p_bank->bank_code) - { - case NRF_DFU_BANK_VALID_APP: - NRF_LOG_DEBUG("Valid App"); - if(s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_1) - { - // Only continue copying if valid app in Bank 1 - ret_val = nrf_dfu_app_continue(src_addr); - } - break; -#if defined(SOFTDEVICE_PRESENT) - case NRF_DFU_BANK_VALID_SD: - NRF_LOG_DEBUG("Valid SD"); - // There is a valid SD that needs to be copied (or continued) - ret_val = nrf_dfu_sd_continue(src_addr, p_bank); - (*p_enter_dfu_mode) = 1; - break; -#endif - - case NRF_DFU_BANK_VALID_BL: - NRF_LOG_DEBUG("Valid BL"); - // There is a valid BL that must be copied (or continued) - ret_val = nrf_dfu_bl_continue(src_addr, p_bank); - break; - -#if defined(SOFTDEVICE_PRESENT) - case NRF_DFU_BANK_VALID_SD_BL: - NRF_LOG_DEBUG("Valid SD + BL"); - // There is a valid SD + BL that must be copied (or continued) - ret_val = nrf_dfu_sd_bl_continue(src_addr, p_bank); - (*p_enter_dfu_mode) = 1; - // Set the bank-code to invalid, and reset size/CRC - break; -#endif - - case NRF_DFU_BANK_INVALID: - default: - NRF_LOG_ERROR("Single: Invalid bank"); - break; - } - - return ret_val; -} - - -void nrf_dfu_reset_timeout_handler(void * p_context) -{ - UNUSED_PARAMETER(p_context); - - NRF_LOG_DEBUG("DFU reset due to inactivity timeout."); - -#ifdef NRF_DFU_DEBUG_VERSION - NRF_LOG_FLUSH(); - nrf_delay_ms(100); -#endif - - NVIC_SystemReset(); -} - - -uint32_t nrf_dfu_continue(uint32_t * p_enter_dfu_mode) -{ - uint32_t ret_val; - nrf_dfu_bank_t * p_bank; - uint32_t src_addr = CODE_REGION_1_START; - - NRF_LOG_DEBUG("Enter nrf_dfu_continue"); - - if (s_dfu_settings.bank_layout == NRF_DFU_BANK_LAYOUT_SINGLE ) - { - p_bank = &s_dfu_settings.bank_0; - } - else if(s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_0) - { - p_bank = &s_dfu_settings.bank_0; - } - else - { - p_bank = &s_dfu_settings.bank_1; - src_addr += align_to_page(s_dfu_settings.bank_0.image_size); - } - - ret_val = nrf_dfu_continue_bank(p_bank, src_addr, p_enter_dfu_mode); - return ret_val; -} - - -bool nrf_dfu_app_is_valid(void) -{ - NRF_LOG_DEBUG("Enter nrf_dfu_app_is_valid"); - if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP) - { - // Bank 0 has no valid app. Nothing to boot - NRF_LOG_DEBUG("Return false in valid app check"); - return false; - } - - // If CRC == 0, the CRC check is skipped. - if (s_dfu_settings.bank_0.image_crc != 0) - { - uint32_t crc = crc32_compute((uint8_t*) CODE_REGION_1_START, - s_dfu_settings.bank_0.image_size, - NULL); - - if (crc != s_dfu_settings.bank_0.image_crc) - { - // CRC does not match with what is stored. - NRF_LOG_DEBUG("Return false in CRC"); - return false; - } - } - - NRF_LOG_DEBUG("Return true. App was valid"); - return true; -} - - -uint32_t nrf_dfu_find_cache(uint32_t size_req, bool dual_bank_only, uint32_t * p_address) -{ - uint32_t free_size = DFU_REGION_TOTAL_SIZE - DFU_APP_DATA_RESERVED; - nrf_dfu_bank_t * p_bank; - - NRF_LOG_DEBUG("Enter nrf_dfu_find_cache"); - - if (p_address == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - - // Simple check whether the size requirement can be met - if(free_size < size_req) - { - NRF_LOG_DEBUG("No way to fit the new firmware on device"); - return NRF_ERROR_NO_MEM; - } - - NRF_LOG_DEBUG("Bank content"); - NRF_LOG_DEBUG("Bank type: %d", s_dfu_settings.bank_layout); - NRF_LOG_DEBUG("Bank 0 code: 0x%02x: Size: %d", s_dfu_settings.bank_0.bank_code, s_dfu_settings.bank_0.image_size); - NRF_LOG_DEBUG("Bank 1 code: 0x%02x: Size: %d", s_dfu_settings.bank_1.bank_code, s_dfu_settings.bank_1.image_size); - - // Setting Bank 0 as candidate - p_bank = &s_dfu_settings.bank_0; - - // Setting candidate address - (*p_address) = MAIN_APPLICATION_START_ADDR; - - // Calculate free size - if (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_VALID_APP) - { - // Valid app present. - - NRF_LOG_DEBUG("free_size before bank select: %d", free_size); - - free_size -= align_to_page(p_bank->image_size); - - NRF_LOG_DEBUG("free_size: %d, size_req: %d", free_size, size_req); - - // Check if we can fit the new app in the free space or if removal of old app is required. - if (size_req > free_size) - { - // Not enough room in free space (Bank 1) - if (dual_bank_only) - { - NRF_LOG_ERROR("Failure: dual bank restriction"); - return NRF_ERROR_NO_MEM; - } - - // Can only support single bank update, clearing old app. - s_dfu_settings.bank_layout = NRF_DFU_BANK_LAYOUT_SINGLE; - s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_0; - p_bank = &s_dfu_settings.bank_0; - NRF_LOG_DEBUG("Enforcing single bank"); - } - else - { - // Room in Bank 1 for update - // Ensure we are using dual bank layout - s_dfu_settings.bank_layout = NRF_DFU_BANK_LAYOUT_DUAL; - s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_1; - p_bank = &s_dfu_settings.bank_1; - // Set to first free page boundary after previous app - (*p_address) += align_to_page(s_dfu_settings.bank_0.image_size); - NRF_LOG_DEBUG("Using second bank"); - } - } - else - { - // No valid app present. Promoting dual bank. - s_dfu_settings.bank_layout = NRF_DFU_BANK_LAYOUT_DUAL; - s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_0; - - p_bank = &s_dfu_settings.bank_0; - NRF_LOG_DEBUG("No previous, using bank 0"); - } - - // Set the bank-code to invalid, and reset size/CRC - memset(p_bank, 0, sizeof(nrf_dfu_bank_t)); - - // Store the Firmware size in the bank for continuations - p_bank->image_size = size_req; - return NRF_SUCCESS; -} - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_asm.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_asm.c deleted file mode 100644 index 408bd6b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_asm.c +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) 2016 - 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 -#include "compiler_abstraction.h" - -#if defined ( __CC_ARM ) -__ASM void nrf_bootloader_app_start_impl(uint32_t start_addr) -{ - LDR R5, [R0] ; Get App initial MSP for bootloader. - MSR MSP, R5 ; Set the main stack pointer to the applications MSP. - LDR R0, [R0, #0x04] ; Load Reset handler into R0. This will be first argument to branch instruction (BX). - - MOVS R4, #0xFF ; Load ones to R4. - SXTB R4, R4 ; Sign extend R4 to obtain 0xFFFFFFFF instead of 0xFF. - MRS R5, IPSR ; Load IPSR to R5 to check for handler or thread mode. - CMP R5, #0x00 ; Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader. - BNE isr_abort ; If not zero we need to exit current ISR and jump to reset handler of bootloader. - - MRS R1, CONTROL ; Get CONTROL register value - MOVS R2, #0x02 ; load 2 to r2 - BICS R1, R2 ; clear value of CONTROL->SPSEL - > make sure MSP will be used - MSR CONTROL, R1 ; set the stack pointer to MSP - - MOV LR, R4 ; Clear the link register and set to ones to ensure no return, R4 = 0xFFFFFFFF. - BX R0 ; Branch to reset handler of bootloader. - -isr_abort - ; R4 contains ones from line above. Will be popped as R12 when exiting ISR (Cleaning up the registers). - MOV R5, R4 ; Fill with ones before jumping to reset handling. We be popped as LR when exiting ISR. Ensures no return to application. - MOV R6, R0 ; Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR. - MOVS r7, #0x21 ; Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21. - REV r7, r7 ; Reverse byte order to put 0x21 as MSB. - PUSH {r4-r7} ; Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR. - - MOVS R4, #0x00 ; Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers). - MOVS R5, #0x00 ; Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers). - MOVS R6, #0x00 ; Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers). - MOVS R7, #0x00 ; Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers). - PUSH {r4-r7} ; Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine. - - MOVS R0, #0xF9 ; Move the execution return command into register, 0xFFFFFFF9. - SXTB R0, R0 ; Sign extend R0 to obtain 0xFFFFFFF9 instead of 0xF9. - BX R0 ; No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application. - ALIGN -} - -#elif defined ( __GNUC__ ) || defined ( __SES_ARM ) - -void __attribute__ ((noinline)) nrf_bootloader_app_start_impl(uint32_t start_addr) -{ - __ASM volatile( - "ldr r0, [%0]\t\n" // Get App initial MSP for bootloader. - "msr msp, r0\t\n" // Set the main stack pointer to the applications MSP. - "ldr r0, [%0, #0x04]\t\n" // Load Reset handler into R0. - - "movs r4, #0xFF\t\n" // Move ones to R4. - "sxtb r4, r4\t\n" // Sign extend R4 to obtain 0xFFFFFFFF instead of 0xFF. - - "mrs r5, IPSR\t\n" // Load IPSR to R5 to check for handler or thread mode. - "cmp r5, #0x00\t\n" // Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader. - "bne isr_abort\t\n" // If not zero we need to exit current ISR and jump to reset handler of bootloader. - - "mrs r1, control\t\n" // Get CONTROL register value - "movs r2, #0x02\t\n" // load 2 to r2 - "bic r1, r2\t\n" // clear value of CONTROL->SPSEL - > make sure MSP will be used - "msr control, r1\t\n" // set the stack pointer to MSP - - "mov lr, r4\t\n" // Clear the link register and set to ones to ensure no return. - "bx r0\t\n" // Branch to reset handler of bootloader. - - "isr_abort: \t\n" - - "mov r5, r4\t\n" // Fill with ones before jumping to reset handling. Will be popped as LR when exiting ISR. Ensures no return to application. - "mov r6, r0\t\n" // Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR. - "movs r7, #0x21\t\n" // Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21. - "rev r7, r7\t\n" // Reverse byte order to put 0x21 as MSB. - "push {r4-r7}\t\n" // Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR. - - "movs r4, #0x00\t\n" // Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers). - "movs r5, #0x00\t\n" // Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers). - "movs r6, #0x00\t\n" // Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers). - "movs r7, #0x00\t\n" // Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers). - "push {r4-r7}\t\n" // Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine. - - "movs r0, #0xF9\t\n" // Move the execution return command into register, 0xFFFFFFF9. - "sxtb r0, r0\t\n" // Sign extend R0 to obtain 0xFFFFFFF9 instead of 0xF9. - "bx r0\t\n" // No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application. - ".align\t\n" - :: "r" (start_addr) // Argument list for the gcc assembly. start_addr is %0. - : "r0", "r4", "r5", "r6", "r7" // List of register maintained manually. - ); -} - -#elif defined ( __ICCARM__ ) - -void nrf_bootloader_app_start_impl(uint32_t start_addr) -{ - __ASM("ldr r5, [%0]\n" // Get App initial MSP for bootloader. - "msr msp, r5\n" // Set the main stack pointer to the applications MSP. - "ldr r0, [%0, #0x04]\n" // Load Reset handler into R0. - - "movs r4, #0x00\n" // Load zero into R4. - "mvns r4, r4\n" // Invert R4 to ensure it contain ones. - - "mrs r5, IPSR\n" // Load IPSR to R5 to check for handler or thread mode - "cmp r5, #0x00\n" // Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader. - "bne.n isr_abort\n" // If not zero we need to exit current ISR and jump to reset handler of bootloader. - - "mrs r1, control\n" // Get CONTROL register value - "movs r2, #0x02\n" // load 2 to r2 - "bics r1, r2\n" // clear value of CONTROL->SPSEL - > make sure MSP will be used - "msr control, r1\n" // set the stack pointer to MSP - - "mov lr, r4\n" // Clear the link register and set to ones to ensure no return. - "bx r0\n" // Branch to reset handler of bootloader. - - "isr_abort: \n" - // R4 contains ones from line above. We be popped as R12 when exiting ISR (Cleaning up the registers). - "mov r5, r4\n" // Fill with ones before jumping to reset handling. Will be popped as LR when exiting ISR. Ensures no return to application. - "mov r6, r0\n" // Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR. - "movs r7, #0x21\n" // Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21. - "rev r7, r7\n" // Reverse byte order to put 0x21 as MSB. - "push {r4-r7}\n" // Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR. - - "movs r4, #0x00\n" // Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers). - "movs r5, #0x00\n" // Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers). - "movs r6, #0x00\n" // Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers). - "movs r7, #0x00\n" // Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers). - "push {r4-r7}\n" // Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine. - - "movs r0, #0x06\n" // Load 0x06 into R6 to prepare for exec return command. - "mvns r0, r0\n" // Invert 0x06 to obtain EXEC_RETURN, 0xFFFFFFF9. - "bx r0\n" // No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application. - :: "r" (start_addr) // Argument list for the IAR assembly. start_addr is %0. - : "r0", "r4", "r5", "r6", "r7"); // List of register maintained manually. -} - -#else - -#error Compiler not supported. - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.h deleted file mode 100644 index 5e2b17c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2016 - 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 sdk_bootloader_info Information - * @{ - * @ingroup sdk_bootloader - */ - -#ifndef NRF_BOOTLOADER_INFO_H__ -#define NRF_BOOTLOADER_INFO_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "nrf.h" -#include "nrf_mbr.h" - -#if defined(SOFTDEVICE_PRESENT) -#include "nrf_sdm.h" -#else -#include "nrf_mbr.h" -#endif - -/** @brief External definitions of symbols for the start of the application image. - */ -#if (__LINT__ == 1) - // No implementation -#elif defined ( __CC_ARM ) - extern uint32_t* Image$$ER_IROM1$$Base __attribute__((used)); -#elif defined (__SES_ARM) && defined (__GNUC__) - extern uint32_t * _vectors; -#elif defined ( __GNUC__ ) - extern uint32_t * __isr_vector; -#elif defined ( __ICCARM__ ) - extern void * __vector_table; -#else - #error Not a valid compiler/linker for application image symbols. -#endif - - -/** @brief Macro for getting the start address of the application image. - * - * This macro is valid only when absolute placement is used for the application - * image. The macro is not a compile time symbol. It cannot be used as a - * constant expression, for example, inside a static assert or linker script - * at-placement. - */ -#if (__LINT__ == 1) - #define BOOTLOADER_START_ADDR (0x3AC00) -#elif BOOTLOADER_START_ADDR - // Bootloader start address is defined at project level -#elif defined (__CC_ARM) - #define BOOTLOADER_START_ADDR (uint32_t)&Image$$ER_IROM1$$Base -#elif defined (__SES_ARM) && defined (__GNUC__) - #define BOOTLOADER_START_ADDR (uint32_t)&_vectors -#elif defined (__GNUC__) - #define BOOTLOADER_START_ADDR (uint32_t)&__isr_vector -#elif defined (__ICCARM__) - #define BOOTLOADER_START_ADDR (uint32_t)&__vector_table -#else - #error Not a valid compiler/linker for BOOTLOADER_START_ADDR. -#endif - - -/** - * @brief Bootloader start address in UICR. - * - * Register location in UICR where the bootloader start address is stored. - * - * @note If the value at the given location is 0xFFFFFFFF, the bootloader address is not set. - */ -#define NRF_UICR_BOOTLOADER_START_ADDRESS (NRF_UICR_BASE + 0x14) - - -#ifndef MAIN_APPLICATION_START_ADDR - - -#if defined(SOFTDEVICE_PRESENT) - -/** @brief Main application start address (if the project uses a SoftDevice). - * - * @note The start address is equal to the end address of the SoftDevice. - */ -#define MAIN_APPLICATION_START_ADDR (SD_SIZE_GET(MBR_SIZE)) - -#else -#define MAIN_APPLICATION_START_ADDR MBR_SIZE -#endif // #ifdef SOFTDEVICE_PRESENT -#endif // #ifndef MAIN_APPLICATION_START_ADDR - - -#ifdef __cplusplus -} -#endif - -#endif // #ifndef NRF_BOOTLOADER_INFO_H__ -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.c deleted file mode 100644 index 506130f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.c +++ /dev/null @@ -1,432 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "nrf_serial_dfu.h" - -#include -#include "boards.h" -#include "app_util_platform.h" -#include "nrf_dfu_transport.h" -#include "nrf_dfu_req_handler.h" -#include "slip.h" -#include "nrf_log.h" - - -#define AVAILABLE_LED_PIN_NO BSP_LED_0 /**< Is on when serial DFU transport is enabled (but not connected). */ -#define CONNECTED_LED_PIN_NO BSP_LED_1 /**< Is on when device has connected. */ - - -#define CREATE_OBJECT_REQUEST_LEN (sizeof(uint8_t)+sizeof(uint32_t)) -#define SET_RECEIPT_NOTIF_REQUEST_LEN (sizeof(uint16_t)) -#define CALCULATE_CRC_REQUEST_LEN 0 -#define EXECUTE_OBJECT_REQUEST_LEN 0 -#define SELECT_OBJECT_REQUEST_LEN (sizeof(uint8_t)) -#define GET_SERIAL_MTU_REQUEST_LEN 0 - -#define MAX_RESPONSE_SIZE (1+1+3*4) - -static serial_dfu_t m_dfu; - - -DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const dfu_trans) = -{ - .init_func = serial_dfu_transport_init, - .close_func = serial_dfu_transport_close -}; - - -ANON_UNIONS_ENABLE - -typedef struct -{ - uint8_t op_code; - nrf_dfu_res_code_t resp_val; - union - { - struct - { - uint32_t offset; - uint32_t crc; - } crc_response; - - struct - { - uint32_t max_size; - uint32_t offset; - uint32_t crc; - } select_response; - - struct - { - uint16_t mtu; - } serial_mtu_response; - - struct - { - uint8_t ping_id; - } ping_response; - }; - -} serial_dfu_response_t; - -ANON_UNIONS_DISABLE - - -/**@brief Function for the LEDs initialization. - * - * @details Initializes all LEDs used by this application. - */ -static void leds_init(void) -{ - nrf_gpio_cfg_output(AVAILABLE_LED_PIN_NO); - nrf_gpio_cfg_output(CONNECTED_LED_PIN_NO); - nrf_gpio_pin_clear(AVAILABLE_LED_PIN_NO); - nrf_gpio_pin_set(CONNECTED_LED_PIN_NO); -} - -static void response_send(serial_dfu_t * p_dfu, - serial_dfu_response_t * p_response) -{ - static uint8_t encoded_response[(2 * MAX_RESPONSE_SIZE) + 1] = {0}; - uint8_t response_buffer[MAX_RESPONSE_SIZE] = {0}; - uint32_t encoded_response_length = 0; - - uint16_t index = 0; - - NRF_LOG_DEBUG("Sending Response: [0x%01x, 0x%01x]", p_response->op_code, p_response->resp_val); - - response_buffer[index++] = SERIAL_DFU_OP_CODE_RESPONSE; - - // Encode the Request Op code - response_buffer[index++] = p_response->op_code; - - // Encode the Response Value. - response_buffer[index++] = (uint8_t)p_response->resp_val; - - if (p_response->resp_val == NRF_DFU_RES_CODE_SUCCESS) - { - switch (p_response->op_code) - { - case SERIAL_DFU_OP_CODE_CALCULATE_CRC: - index += uint32_encode(p_response->crc_response.offset, &response_buffer[index]); - index += uint32_encode(p_response->crc_response.crc, &response_buffer[index]); - break; - - case SERIAL_DFU_OP_CODE_SELECT_OBJECT: - index += uint32_encode(p_response->select_response.max_size, &response_buffer[index]); - index += uint32_encode(p_response->select_response.offset, &response_buffer[index]); - index += uint32_encode(p_response->select_response.crc, &response_buffer[index]); - break; - - case SERIAL_DFU_OP_CODE_GET_SERIAL_MTU: - index += uint16_encode(p_response->serial_mtu_response.mtu, &response_buffer[index]); - break; - - case SERIAL_DFU_OP_CODE_PING: - response_buffer[index] = p_response->ping_response.ping_id; - index += sizeof(uint8_t); - break; - - default: - // no implementation - break; - } - } - else if (p_response->resp_val == NRF_DFU_RES_CODE_EXT_ERROR) - { - response_buffer[index++] = ext_error_get(); - // Clear the last extended error code - (void) ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR); - } - - // encode into slip - (void)slip_encode(encoded_response, response_buffer, index, &encoded_response_length); - - // send - (void)nrf_drv_uart_tx(&p_dfu->uart_instance, encoded_response, encoded_response_length); -} - -static void on_packet_received(serial_dfu_t * p_dfu) -{ - nrf_dfu_req_t dfu_req; - nrf_dfu_res_t dfu_res = {{{0}}}; - serial_dfu_response_t serial_response = {0}; - - memset(&dfu_req, 0, sizeof(nrf_dfu_req_t)); - - const serial_dfu_op_code_t op_code = (serial_dfu_op_code_t)p_dfu->recv_buffer[0]; - const uint16_t packet_payload_len = p_dfu->slip.current_index - 1; - uint8_t * p_payload = &p_dfu->recv_buffer[1]; - - serial_response.op_code = op_code; - - nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO); - nrf_gpio_pin_set(AVAILABLE_LED_PIN_NO); - - switch (op_code) - { - case SERIAL_DFU_OP_CODE_CREATE_OBJECT: - - if (packet_payload_len != CREATE_OBJECT_REQUEST_LEN) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - NRF_LOG_DEBUG("Received create object"); - - // Reset the packet receipt notification on create object - p_dfu->pkt_notif_target_count = p_dfu->pkt_notif_target; - - // Get type parameter - dfu_req.obj_type = p_payload[0]; - - // Get length value - dfu_req.object_size = uint32_decode(&p_payload[1]); - - // Set req type - dfu_req.req_type = NRF_DFU_OBJECT_OP_CREATE; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - break; - - case SERIAL_DFU_OP_CODE_SET_RECEIPT_NOTIF: - NRF_LOG_DEBUG("Set receipt notif"); - if (packet_payload_len != SET_RECEIPT_NOTIF_REQUEST_LEN) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - p_dfu->pkt_notif_target = uint16_decode(&p_payload[0]); - p_dfu->pkt_notif_target_count = p_dfu->pkt_notif_target; - - serial_response.resp_val = NRF_DFU_RES_CODE_SUCCESS; - break; - - case SERIAL_DFU_OP_CODE_CALCULATE_CRC: - NRF_LOG_DEBUG("Received calculate CRC"); - - dfu_req.req_type = NRF_DFU_OBJECT_OP_CRC; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - serial_response.crc_response.offset = dfu_res.offset; - serial_response.crc_response.crc = dfu_res.crc; - break; - - case SERIAL_DFU_OP_CODE_EXECUTE_OBJECT: - NRF_LOG_DEBUG("Received execute object"); - - // Set req type - dfu_req.req_type = NRF_DFU_OBJECT_OP_EXECUTE; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - break; - - case SERIAL_DFU_OP_CODE_SELECT_OBJECT: - - NRF_LOG_DEBUG("Received select object"); - if (packet_payload_len != SELECT_OBJECT_REQUEST_LEN) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - // Set object type to read info about - dfu_req.obj_type = p_payload[0]; - - dfu_req.req_type = NRF_DFU_OBJECT_OP_SELECT; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - serial_response.select_response.max_size = dfu_res.max_size; - serial_response.select_response.offset = dfu_res.offset; - serial_response.select_response.crc = dfu_res.crc; - break; - - case SERIAL_DFU_OP_CODE_GET_SERIAL_MTU: - NRF_LOG_DEBUG("Received get serial mtu"); - - serial_response.resp_val = NRF_DFU_RES_CODE_SUCCESS; - serial_response.serial_mtu_response.mtu = sizeof(p_dfu->recv_buffer); - break; - - case SERIAL_DFU_OP_CODE_WRITE_OBJECT: - // Set req type - dfu_req.req_type = NRF_DFU_OBJECT_OP_WRITE; - - // Set data and length - dfu_req.p_req = &p_payload[0]; - dfu_req.req_len = packet_payload_len; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - if (serial_response.resp_val != NRF_DFU_RES_CODE_SUCCESS) - { - NRF_LOG_ERROR("Failure to run packet write"); - } - - // Check if a packet receipt notification is needed to be sent. - if (p_dfu->pkt_notif_target != 0 && --p_dfu->pkt_notif_target_count == 0) - { - serial_response.op_code = SERIAL_DFU_OP_CODE_CALCULATE_CRC; - serial_response.crc_response.offset = dfu_res.offset; - serial_response.crc_response.crc = dfu_res.crc; - - // Reset the counter for the number of firmware packets. - p_dfu->pkt_notif_target_count = p_dfu->pkt_notif_target; - - response_send(p_dfu, &serial_response); - } - break; - - case SERIAL_DFU_OP_CODE_PING: - if (packet_payload_len != sizeof(serial_response.ping_response)) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - serial_response.resp_val = NRF_DFU_RES_CODE_SUCCESS; - serial_response.ping_response.ping_id = p_payload[0]; - - NRF_LOG_DEBUG("Received ping %d", p_payload[0]); - break; - - default: - // Unsupported op code. - NRF_LOG_WARNING("Received unsupported OP code"); - serial_response.resp_val = NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED; - break; - } - - if (op_code != SERIAL_DFU_OP_CODE_WRITE_OBJECT) - { - response_send(p_dfu, &serial_response); - } -} - - -static __INLINE void on_rx_complete(serial_dfu_t * p_dfu, uint8_t * p_data, uint8_t len) -{ - ret_code_t ret_code; - - ret_code = slip_decode_add_byte(&p_dfu->slip, p_data[0]); - - if (ret_code == NRF_SUCCESS) - { - on_packet_received(p_dfu); - - // reset the slip decoding - p_dfu->slip.current_index = 0; - p_dfu->slip.state = SLIP_STATE_DECODING; - } - - (void)nrf_drv_uart_rx(&m_dfu.uart_instance, &m_dfu.uart_buffer, 1); -} - - -static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) -{ - switch (p_event->type) - { - case NRF_DRV_UART_EVT_TX_DONE: - nrf_dfu_req_handler_reset_if_dfu_complete(); - break; - - case NRF_DRV_UART_EVT_RX_DONE: - on_rx_complete((serial_dfu_t*)p_context, p_event->data.rxtx.p_data, p_event->data.rxtx.bytes); - break; - - case NRF_DRV_UART_EVT_ERROR: - APP_ERROR_HANDLER(p_event->data.error.error_mask); - break; - } -} - - -uint32_t serial_dfu_transport_init(void) -{ - uint32_t err_code; - - leds_init(); - - m_dfu.slip.p_buffer = m_dfu.recv_buffer; - m_dfu.slip.current_index = 0; - m_dfu.slip.buffer_len = sizeof(m_dfu.recv_buffer); - m_dfu.slip.state = SLIP_STATE_DECODING; - - nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG; - - uart_config.pseltxd = TX_PIN_NUMBER; - uart_config.pselrxd = RX_PIN_NUMBER; - uart_config.pselcts = CTS_PIN_NUMBER; - uart_config.pselrts = RTS_PIN_NUMBER; - uart_config.hwfc = NRF_UART_HWFC_ENABLED; - uart_config.p_context = &m_dfu; - - - nrf_drv_uart_t instance = NRF_DRV_UART_INSTANCE(0); - memcpy(&m_dfu.uart_instance, &instance, sizeof(instance)); - - err_code = nrf_drv_uart_init(&m_dfu.uart_instance, &uart_config, uart_event_handler); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed initializing uart"); - return err_code; - } - - nrf_drv_uart_rx_enable(&m_dfu.uart_instance); - - err_code = nrf_drv_uart_rx(&m_dfu.uart_instance, &m_dfu.uart_buffer, 1); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed initializing rx"); - } - - NRF_LOG_DEBUG("UART initialized"); - - return err_code; -} - - -uint32_t serial_dfu_transport_close(void) -{ - nrf_drv_uart_uninit(&m_dfu.uart_instance); - return NRF_SUCCESS; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.h deleted file mode 100644 index 1223f00..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/serial_dfu/nrf_serial_dfu.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2016 - 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 nrf_serial_dfu Serial DFU transport layer - * @{ - * @ingroup sdk_nrf_bootloader - * @brief Device Firmware Update (DFU) transport layer using UART. - * - * @details The transport layer can be used for performing firmware updates over UART. - * The implementation uses SLIP to encode packets. - */ - -#ifndef NRF_SERIAL_DFU_H__ -#define NRF_SERIAL_DFU_H__ - -#include -#include "nrf_drv_uart.h" -#include "slip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Serial DFU opcodes. - */ -typedef enum -{ - SERIAL_DFU_OP_CODE_CREATE_OBJECT = 0x01, /**< Value of the opcode field for a 'Create object' request. */ - SERIAL_DFU_OP_CODE_SET_RECEIPT_NOTIF = 0x02, /**< Value of the opcode field for a 'Set Packet Receipt Notification' request. */ - SERIAL_DFU_OP_CODE_CALCULATE_CRC = 0x03, /**< Value of the opcode field for a 'Calculating checksum' request. */ - SERIAL_DFU_OP_CODE_EXECUTE_OBJECT = 0x04, /**< Value of the opcode field for an 'Initialize DFU parameters' request. */ - SERIAL_DFU_OP_CODE_SELECT_OBJECT = 0x06, /**< Value of the opcode field for a 'Select object' request. */ - SERIAL_DFU_OP_CODE_GET_SERIAL_MTU = 0x07, /**< Value of the opcode field for a 'Get Serial MTU' request. */ - SERIAL_DFU_OP_CODE_WRITE_OBJECT = 0x08, /**< Value of the opcode indicating a write to the current object. */ - SERIAL_DFU_OP_CODE_PING = 0x09, /**< Value of the opcode for a ping command. */ - SERIAL_DFU_OP_CODE_RESPONSE = 0x60 /**< Value of the opcode field for a response.*/ -} serial_dfu_op_code_t; - -/**@brief DFU transport layer state. - * - * @details This structure contains status information related to the transport layer. - */ -typedef struct -{ - nrf_drv_uart_t uart_instance; /**< Structure holding the state of the UART driver. */ - slip_t slip; - - uint8_t uart_buffer; - uint8_t recv_buffer[128 + 1]; - - uint16_t pkt_notif_target; - uint16_t pkt_notif_target_count; -} serial_dfu_t; - - -/**@brief Function for initializing the transport layer. - * - * @retval NRF_SUCCESS If the transport layer was successfully initialized. Otherwise, an error code is returned. - */ -uint32_t serial_dfu_transport_init(void); - - -/**@brief Function for closing down the transport layer. - * - * @retval NRF_SUCCESS If the transport layer was correctly closed down. - */ -uint32_t serial_dfu_transport_close(void); - -#ifdef __cplusplus -} -#endif - -#endif // NRF_SERIAL_DFU_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.c deleted file mode 100644 index 30f6264..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.c +++ /dev/null @@ -1,590 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "nrf_usb_dfu.h" - -#include -#include "boards.h" -#include "nrf_dfu_req_handler.h" -#include "nrf_dfu_transport.h" -#include "slip.h" - -#include "nrf_gpio.h" -#include "nrf_drv_power.h" -#include "nrf_drv_usbd.h" - -#include "app_scheduler.h" -#include "app_timer.h" -#include "app_usbd.h" -#include "app_usbd_cdc_acm.h" -#include "app_usbd_core.h" -#include "app_usbd_string_desc.h" -#include "app_util_platform.h" - -#include "nrf_log.h" - - -#define CREATE_OBJECT_REQUEST_LEN (sizeof(uint8_t) + sizeof(uint32_t)) -#define SET_RECEIPT_NOTIF_REQUEST_LEN (sizeof(uint16_t)) -#define CALCULATE_CRC_REQUEST_LEN 0 -#define EXECUTE_OBJECT_REQUEST_LEN 0 -#define SELECT_OBJECT_REQUEST_LEN (sizeof(uint8_t)) -#define GET_SERIAL_MTU_REQUEST_LEN 0 -#define SERIAL_NUMBER_STRING_SIZE (16) -#define MAX_RESPONSE_SIZE (1 + 1 + 3 * 4) - -#define CDC_ACM_COMM_INTERFACE 0 -#define CDC_ACM_COMM_EPIN NRF_DRV_USBD_EPIN2 -#define CDC_ACM_DATA_INTERFACE 1 -#define CDC_ACM_DATA_EPIN NRF_DRV_USBD_EPIN1 -#define CDC_ACM_DATA_EPOUT NRF_DRV_USBD_EPOUT1 - -/** - * @brief Enable power USB detection - * - * Configure if example supports USB port connection - */ -#ifndef USBD_POWER_DETECTION -#define USBD_POWER_DETECTION true -#endif - -/** - * @brief Interfaces list passed to @ref APP_USBD_CDC_ACM_GLOBAL_DEF - * */ -#define CDC_ACM_INTERFACES_CONFIG() \ - APP_USBD_CDC_ACM_CONFIG(CDC_ACM_COMM_INTERFACE, \ - CDC_ACM_COMM_EPIN, \ - CDC_ACM_DATA_INTERFACE, \ - CDC_ACM_DATA_EPIN, \ - CDC_ACM_DATA_EPOUT) - - -ANON_UNIONS_ENABLE -typedef struct -{ - uint8_t op_code; - nrf_dfu_res_code_t resp_val; - union { - struct - { - uint32_t offset; - uint32_t crc; - } crc_response; - struct - { - uint32_t max_size; - uint32_t offset; - uint32_t crc; - } select_response; - struct - { - uint16_t mtu; - } serial_mtu_response; - }; - -} usb_dfu_response_t; -ANON_UNIONS_DISABLE - - -static usb_dfu_t m_dfu; -uint16_t g_extern_serial_number[SERIAL_NUMBER_STRING_SIZE + 1]; - -DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const dfu_trans) = -{ - .init_func = usb_dfu_transport_init, - .close_func = usb_dfu_transport_close -}; - -/*lint -save -e26 -e64 -e505 -e651 */ -static const uint8_t m_cdc_acm_class_descriptors[] = -{ - APP_USBD_CDC_ACM_DEFAULT_DESC(CDC_ACM_COMM_INTERFACE, - CDC_ACM_COMM_EPIN, - CDC_ACM_DATA_INTERFACE, - CDC_ACM_DATA_EPIN, - CDC_ACM_DATA_EPOUT) -}; - -static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_cdc_acm_user_event_t event); - -/**@brief CDC_ACM class instance. */ -APP_USBD_CDC_ACM_GLOBAL_DEF(m_app_cdc_acm, - CDC_ACM_INTERFACES_CONFIG(), - cdc_acm_user_ev_handler, - m_cdc_acm_class_descriptors); -/*lint -restore */ - - -static void serial_number_string_create(void) -{ - g_extern_serial_number[0] = - (uint16_t)APP_USBD_DESCRIPTOR_STRING << 8 | sizeof(g_extern_serial_number); - - uint32_t dev_id_hi = NRF_FICR->DEVICEID[1]; - uint32_t dev_id_lo = NRF_FICR->DEVICEID[0]; - - uint64_t device_id = (((uint64_t)dev_id_hi) << 32) | dev_id_lo; - - for (size_t i = 1; i < SERIAL_NUMBER_STRING_SIZE + 1; ++i) - { - char tmp[2]; - (void)snprintf(tmp, sizeof(tmp), "%x", (unsigned int)(device_id & 0xF)); - g_extern_serial_number[i] = tmp[0]; - device_id >>= 4; - } -} - - -static void response_send(usb_dfu_t * p_dfu, usb_dfu_response_t * p_response) -{ - // Should be statically allocated since the response is sent asynchronously. - static uint8_t encoded_response[MAX_RESPONSE_SIZE * 2 + 1] = {0}; - uint8_t response_buffer[MAX_RESPONSE_SIZE] = {0}; - uint32_t encoded_response_length = 0; - uint16_t index = 0; - ret_code_t ret_code; - - NRF_LOG_DEBUG("Sending Response: [0x%01x, 0x%01x]", p_response->op_code, p_response->resp_val); - - response_buffer[index++] = USB_DFU_OP_CODE_RESPONSE; - - // Encode the Request Op code - response_buffer[index++] = p_response->op_code; - - // Encode the Response Value. - response_buffer[index++] = (uint8_t)p_response->resp_val; - - if (p_response->resp_val == NRF_DFU_RES_CODE_SUCCESS) - { - switch (p_response->op_code) - { - case USB_DFU_OP_CODE_CALCULATE_CRC: - { - index += uint32_encode(p_response->crc_response.offset, &response_buffer[index]); - index += uint32_encode(p_response->crc_response.crc, &response_buffer[index]); - } break; - - case USB_DFU_OP_CODE_SELECT_OBJECT: - { - index += - uint32_encode(p_response->select_response.max_size, &response_buffer[index]); - index += uint32_encode(p_response->select_response.offset, &response_buffer[index]); - index += uint32_encode(p_response->select_response.crc, &response_buffer[index]); - } break; - - case USB_DFU_OP_CODE_GET_SERIAL_MTU: - { - index += - uint16_encode(p_response->serial_mtu_response.mtu, &response_buffer[index]); - } break; - - default: - break; - } - } - else if (p_response->resp_val == NRF_DFU_RES_CODE_EXT_ERROR) - { - response_buffer[index++] = ext_error_get(); - // Clear the last extended error code - (void)ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR); - } - - // Encode into slip - ret_code = slip_encode(encoded_response, response_buffer, index, &encoded_response_length); - if (ret_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed to slip encode response"); - } - - // Send - ret_code = app_usbd_cdc_acm_write(&m_app_cdc_acm, encoded_response, encoded_response_length); - if (ret_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed send response"); - } -} - - -static void on_packet_received(usb_dfu_t * p_dfu) -{ - nrf_dfu_req_t dfu_req; - nrf_dfu_res_t dfu_res = {{{0}}}; - - memset(&dfu_req, 0x00, sizeof(dfu_req)); - - usb_dfu_response_t serial_response; - - const usb_dfu_op_code_t op_code = (usb_dfu_op_code_t)p_dfu->recv_buffer[0]; - const uint16_t packet_payload_len = p_dfu->slip.current_index - 1; - uint8_t * p_payload = &p_dfu->recv_buffer[1]; - - serial_response.op_code = op_code; - - switch (op_code) - { - case USB_DFU_OP_CODE_CREATE_OBJECT: - { - NRF_LOG_DEBUG("Received create object"); - if (packet_payload_len != CREATE_OBJECT_REQUEST_LEN) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - // Reset the packet receipt notification on create object - p_dfu->pkt_notif_target_count = p_dfu->pkt_notif_target; - dfu_req.obj_type = p_payload[0]; - dfu_req.object_size = uint32_decode(&p_payload[1]); - dfu_req.req_type = NRF_DFU_OBJECT_OP_CREATE; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - } break; - - case USB_DFU_OP_CODE_SET_RECEIPT_NOTIF: - { - NRF_LOG_DEBUG("Set receipt notif"); - if (packet_payload_len != SET_RECEIPT_NOTIF_REQUEST_LEN) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - p_dfu->pkt_notif_target = uint16_decode(&p_payload[0]); - p_dfu->pkt_notif_target_count = p_dfu->pkt_notif_target; - - serial_response.resp_val = NRF_DFU_RES_CODE_SUCCESS; - } break; - - case USB_DFU_OP_CODE_CALCULATE_CRC: - { - NRF_LOG_DEBUG("Received calculate CRC"); - dfu_req.req_type = NRF_DFU_OBJECT_OP_CRC; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - serial_response.crc_response.offset = dfu_res.offset; - serial_response.crc_response.crc = dfu_res.crc; - } break; - - case USB_DFU_OP_CODE_EXECUTE_OBJECT: - { - NRF_LOG_DEBUG("Received execute object"); - dfu_req.req_type = NRF_DFU_OBJECT_OP_EXECUTE; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - } break; - - case USB_DFU_OP_CODE_SELECT_OBJECT: - { - NRF_LOG_DEBUG("Received select object"); - if (packet_payload_len != SELECT_OBJECT_REQUEST_LEN) - { - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - break; - } - - // Set object type to read info about - dfu_req.obj_type = p_payload[0]; - dfu_req.req_type = NRF_DFU_OBJECT_OP_SELECT; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - serial_response.select_response.max_size = dfu_res.max_size; - serial_response.select_response.offset = dfu_res.offset; - serial_response.select_response.crc = dfu_res.crc; - } break; - - case USB_DFU_OP_CODE_GET_SERIAL_MTU: - { - NRF_LOG_DEBUG("Received get serial mtu"); - serial_response.serial_mtu_response.mtu = sizeof(p_dfu->recv_buffer); - serial_response.resp_val = NRF_DFU_RES_CODE_SUCCESS; - } break; - - case USB_DFU_OP_CODE_WRITE_OBJECT: - { - dfu_req.req_type = NRF_DFU_OBJECT_OP_WRITE; - dfu_req.p_req = &p_payload[0]; - dfu_req.req_len = packet_payload_len; - - serial_response.resp_val = nrf_dfu_req_handler_on_req(NULL, &dfu_req, &dfu_res); - if (serial_response.resp_val != NRF_DFU_RES_CODE_SUCCESS) - { - NRF_LOG_WARNING("Failure to run packet write"); - } - - // Check if a packet receipt notification is needed to be sent. - if (p_dfu->pkt_notif_target != 0 && --p_dfu->pkt_notif_target_count == 0) - { - serial_response.op_code = USB_DFU_OP_CODE_CALCULATE_CRC; - serial_response.crc_response.offset = dfu_res.offset; - serial_response.crc_response.crc = dfu_res.crc; - - // Reset the counter for the number of firmware packets. - p_dfu->pkt_notif_target_count = p_dfu->pkt_notif_target; - - response_send(p_dfu, &serial_response); - } - } break; - - default: - { - // Unsupported op code. - NRF_LOG_WARNING("Received unsupported OP code"); - serial_response.resp_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; - } break; - } - - if (op_code != USB_DFU_OP_CODE_WRITE_OBJECT) - { - response_send(p_dfu, &serial_response); - } -} - - -static void on_rx_complete(usb_dfu_t * p_dfu, uint8_t * p_data, uint8_t len) -{ - ret_code_t ret_code; - for (uint32_t i = 0; i < len; i++) - { - ret_code = slip_decode_add_byte(&p_dfu->slip, p_data[i]); - if (ret_code == NRF_SUCCESS) - { - on_packet_received(p_dfu); - - // reset the slip decoding - p_dfu->slip.current_index = 0; - p_dfu->slip.state = SLIP_STATE_DECODING; - } - } -} - - -/** - * @brief User event handler @ref app_usbd_cdc_acm_user_ev_handler_t (headphones) - * */ -static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_cdc_acm_user_event_t event) -{ - ret_code_t ret_code; - app_usbd_cdc_acm_t const * p_cdc_acm = app_usbd_cdc_acm_class_get(p_inst); - - switch (event) - { - case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN: - { - // Setup first transfer - ret_code = - app_usbd_cdc_acm_read(&m_app_cdc_acm, m_dfu.usb_buffer, sizeof(m_dfu.usb_buffer)); - ASSERT(ret_code == NRF_SUCCESS); - } break; - - case APP_USBD_CDC_ACM_USER_EVT_TX_DONE: - { - nrf_dfu_req_handler_reset_if_dfu_complete(); - } break; - - case APP_USBD_CDC_ACM_USER_EVT_RX_DONE: - { - on_rx_complete( - &m_dfu, (uint8_t *)m_dfu.usb_buffer, app_usbd_cdc_acm_rx_size(p_cdc_acm)); - - // Setup next transfer - ret_code = - app_usbd_cdc_acm_read(&m_app_cdc_acm, m_dfu.usb_buffer, sizeof(m_dfu.usb_buffer)); - - ASSERT(ret_code == NRF_SUCCESS); - } break; - - case APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE: - { - nrf_dfu_req_handler_reset_if_dfu_complete(); - } break; - - default: - break; - } -} - - -static void power_usb_event_handler(nrf_drv_power_usb_evt_t event) -{ - switch (event) - { - case NRF_DRV_POWER_USB_EVT_DETECTED: - { - NRF_LOG_INFO("USB power detected"); - if (!nrf_drv_usbd_is_enabled()) - { - app_usbd_enable(); - } - - nrf_gpio_pin_set(BSP_LED_0); - nrf_gpio_pin_clear(BSP_LED_1); - } break; - - case NRF_DRV_POWER_USB_EVT_REMOVED: - { - NRF_LOG_INFO("USB power removed"); - app_usbd_stop(); - nrf_gpio_pin_set(BSP_LED_1); - nrf_gpio_pin_clear(BSP_LED_0); - } break; - - case NRF_DRV_POWER_USB_EVT_READY: - { - NRF_LOG_INFO("USB ready"); - app_usbd_start(); - } break; - - default: - ASSERT(false); - } -} - - -static ret_code_t usb_start(void) -{ - - if (USBD_POWER_DETECTION) - { - static const nrf_drv_power_usbevt_config_t config = {.handler = power_usb_event_handler}; - - return nrf_drv_power_usbevt_init(&config); - } - else - { - NRF_LOG_DEBUG("No USB power detection enabled\r\nStarting USB now"); - - app_usbd_enable(); - app_usbd_start(); - } - - return NRF_SUCCESS; -} - - -/**@brief Function for the LEDs initialization. - * - * @details Initializes all LEDs used by this application. - */ -static void leds_init(void) -{ - nrf_gpio_cfg_output(BSP_LED_0); - nrf_gpio_cfg_output(BSP_LED_1); - nrf_gpio_pin_clear(BSP_LED_0); - nrf_gpio_pin_set(BSP_LED_1); -} - - -static void usbd_dfu_transport_ev_handler(app_usbd_event_type_t event) -{ - switch (event) - { - case APP_USBD_EVT_STOPPED: - app_usbd_disable(); - break; - - default: - break; - } -} - - -static void usbd_sched_event_handler(void * p_event_data, uint16_t event_size) -{ - app_usbd_event_execute(p_event_data); -} - - -static void usbd_event_handler(app_usbd_internal_evt_t const * const p_event) -{ - uint32_t ret; - ret = app_sched_event_put(p_event, sizeof(app_usbd_internal_evt_t), usbd_sched_event_handler); - ASSERT(NRF_SUCCESS == ret); -} - - -uint32_t usb_dfu_transport_init(void) -{ - /* Execute event directly in interrupt handler */ - static const app_usbd_config_t usbd_config = - { - .ev_handler = usbd_event_handler, - .ev_state_proc = usbd_dfu_transport_ev_handler - }; - - uint32_t err_code; - - m_dfu.slip.p_buffer = m_dfu.recv_buffer; - m_dfu.slip.current_index = 0; - m_dfu.slip.buffer_len = sizeof(m_dfu.recv_buffer); - m_dfu.slip.state = SLIP_STATE_DECODING; - - leds_init(); - - NRF_LOG_DEBUG("Initializing power driver."); - - err_code = nrf_drv_power_init(NULL); - VERIFY_SUCCESS(err_code); - - serial_number_string_create(); - - err_code = app_usbd_init(&usbd_config); - VERIFY_SUCCESS(err_code); - - app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm); - err_code = app_usbd_class_append(class_cdc_acm); - VERIFY_SUCCESS(err_code); - - NRF_LOG_DEBUG("Starting USB"); - - err_code = usb_start(); - VERIFY_SUCCESS(err_code); - - NRF_LOG_DEBUG("USB Transport initialized"); - - return err_code; -} - - -uint32_t usb_dfu_transport_close(void) -{ - return NRF_SUCCESS; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.h deleted file mode 100644 index f049a68..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/usb_dfu/nrf_usb_dfu.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2016 - 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 nrf_usb_dfu USB DFU Transport layer - * @{ - * @ingroup sdk_nrf_bootloader - * @brief Device Firmware Update (DFU) transport layer using USB. - * - * @details The transport layer can be used for performing firmware updates over USB. - * The implementation uses SLIP to encode packets. - */ - -#ifndef NRF_USB_DFU_H__ -#define NRF_USB_DFU_H__ - -#include -#include "slip.h" -#include "nrf_drv_usbd.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SECURE_DFU_USB_MTU 64 - -/**@brief USB DFU opcodes. - */ -typedef enum -{ - USB_DFU_OP_CODE_CREATE_OBJECT = 0x01, /**< Value of the opcode field for a 'Create object' request. */ - USB_DFU_OP_CODE_SET_RECEIPT_NOTIF = 0x02, /**< Value of the opcode field for a 'Set Packet Receipt Notification' request. */ - USB_DFU_OP_CODE_CALCULATE_CRC = 0x03, /**< Value of the opcode field for a 'Calculating checksum' request. */ - USB_DFU_OP_CODE_EXECUTE_OBJECT = 0x04, /**< Value of the opcode field for an 'Initialize DFU parameters' request. */ - USB_DFU_OP_CODE_SELECT_OBJECT = 0x06, /**< Value of the opcode field for a 'Select object' request. */ - USB_DFU_OP_CODE_GET_SERIAL_MTU = 0x07, /**< Value of the opcode field for a 'Get Serial MTU' request. */ - USB_DFU_OP_CODE_WRITE_OBJECT = 0x08, /**< Value of the opcode indicating a write to the current object. */ - USB_DFU_OP_CODE_RESPONSE = 0x60 /**< Value of the opcode field for a response.*/ -} usb_dfu_op_code_t; - -/**@brief DFU Service. - * - * @details This structure contains status information related to the service. - */ -typedef struct -{ - slip_t slip; - - uint8_t usb_buffer[NRF_DRV_USBD_EPSIZE]; - uint8_t recv_buffer[2*SECURE_DFU_USB_MTU + 1]; - - uint16_t pkt_notif_target; - uint16_t pkt_notif_target_count; -} usb_dfu_t; - - -/**@brief Function for initializing the transport layer. - * - * @retval NRF_SUCCESS If the transport layer was successfully initialized. Otherwise, an error code is returned. - */ -uint32_t usb_dfu_transport_init(void); - - -/**@brief Function for closing down the transport layer. - * - * @retval NRF_SUCCESS If the transport layer was correctly closed down. - */ -uint32_t usb_dfu_transport_close(void); - -#ifdef __cplusplus -} -#endif - -#endif // NRF_USB_DFU_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.c deleted file mode 100644 index 9cc9000..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.c +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Copyright (c) 2012 - 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(BUTTON) -#include "app_button.h" -#include "app_timer.h" -#include "app_error.h" -#include "nrf_drv_gpiote.h" -#include "nrf_assert.h" - - -static app_button_cfg_t const * mp_buttons = NULL; /**< Button configuration. */ -static uint8_t m_button_count; /**< Number of configured buttons. */ -static uint32_t m_detection_delay; /**< Delay before a button is reported as pushed. */ -APP_TIMER_DEF(m_detection_delay_timer_id); /**< Polling timer id. */ - - -static uint32_t m_pin_state; -static uint32_t m_pin_transition; - -/**@brief Function for handling the timeout that delays reporting buttons as pushed. - * - * @details The detection_delay_timeout_handler(...) is a call-back issued from the app_timer - * module. It is called with the p_context parameter. The p_context parameter is - * provided to the app_timer module when a timer is started, using the call - * @ref app_timer_start. On @ref app_timer_start the p_context will be holding the - * currently pressed buttons. - * - * @param[in] p_context Pointer used for passing information app_start_timer() was called. - * In the app_button module the p_context holds information on pressed - * buttons. - */ -static void detection_delay_timeout_handler(void * p_context) -{ - uint8_t i; - - // Pushed button(s) detected, execute button handler(s). - for (i = 0; i < m_button_count; i++) - { - app_button_cfg_t const * p_btn = &mp_buttons[i]; - uint32_t btn_mask = 1 << p_btn->pin_no; - if (btn_mask & m_pin_transition) - { - m_pin_transition &= ~btn_mask; - bool pin_is_set = nrf_drv_gpiote_in_is_set(p_btn->pin_no); - if ((m_pin_state & (1 << p_btn->pin_no)) == (pin_is_set << p_btn->pin_no)) - { - uint32_t transition = !(pin_is_set ^ (p_btn->active_state == APP_BUTTON_ACTIVE_HIGH)); - - if (p_btn->button_handler) - { - p_btn->button_handler(p_btn->pin_no, transition); - } - } - } - } -} - -static void gpiote_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) -{ - uint32_t err_code; - uint32_t pin_mask = 1 << pin; - - // Start detection timer. If timer is already running, the detection period is restarted. - // NOTE: Using the p_context parameter of app_timer_start() to transfer the pin states to the - // timeout handler (by casting event_pins_mask into the equally sized void * p_context - // parameter). - err_code = app_timer_stop(m_detection_delay_timer_id); - if (err_code != NRF_SUCCESS) - { - // The impact in app_button of the app_timer queue running full is losing a button press. - // The current implementation ensures that the system will continue working as normal. - return; - } - - if (!(m_pin_transition & pin_mask)) - { - if (nrf_drv_gpiote_in_is_set(pin)) - { - m_pin_state |= pin_mask; - } - else - { - m_pin_state &= ~(pin_mask); - } - m_pin_transition |= (pin_mask); - - err_code = app_timer_start(m_detection_delay_timer_id, m_detection_delay, NULL); - if (err_code != NRF_SUCCESS) - { - // The impact in app_button of the app_timer queue running full is losing a button press. - // The current implementation ensures that the system will continue working as normal. - } - } - else - { - m_pin_transition &= ~pin_mask; - } -} - -uint32_t app_button_init(app_button_cfg_t const * p_buttons, - uint8_t button_count, - uint32_t detection_delay) -{ - uint32_t err_code; - - if (detection_delay < APP_TIMER_MIN_TIMEOUT_TICKS) - { - return NRF_ERROR_INVALID_PARAM; - } - - if (!nrf_drv_gpiote_is_init()) - { - err_code = nrf_drv_gpiote_init(); - VERIFY_SUCCESS(err_code); - } - - // Save configuration. - mp_buttons = p_buttons; - m_button_count = button_count; - m_detection_delay = detection_delay; - - m_pin_state = 0; - m_pin_transition = 0; - - while (button_count--) - { - app_button_cfg_t const * p_btn = &p_buttons[button_count]; - - nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); - config.pull = p_btn->pull_cfg; - - err_code = nrf_drv_gpiote_in_init(p_btn->pin_no, &config, gpiote_event_handler); - VERIFY_SUCCESS(err_code); - } - - // Create polling timer. - return app_timer_create(&m_detection_delay_timer_id, - APP_TIMER_MODE_SINGLE_SHOT, - detection_delay_timeout_handler); -} - -uint32_t app_button_enable(void) -{ - ASSERT(mp_buttons); - - uint32_t i; - for (i = 0; i < m_button_count; i++) - { - nrf_drv_gpiote_in_event_enable(mp_buttons[i].pin_no, true); - } - - return NRF_SUCCESS; -} - - -uint32_t app_button_disable(void) -{ - ASSERT(mp_buttons); - - uint32_t i; - for (i = 0; i < m_button_count; i++) - { - nrf_drv_gpiote_in_event_disable(mp_buttons[i].pin_no); - } - - // Make sure polling timer is not running. - return app_timer_stop(m_detection_delay_timer_id); -} - - -bool app_button_is_pushed(uint8_t button_id) -{ - ASSERT(button_id <= m_button_count); - ASSERT(mp_buttons != NULL); - - app_button_cfg_t const * p_btn = &mp_buttons[button_id]; - bool is_set = nrf_drv_gpiote_in_is_set(p_btn->pin_no); - - return !(is_set ^ (p_btn->active_state == APP_BUTTON_ACTIVE_HIGH)); -} -#endif //NRF_MODULE_ENABLED(BUTTON) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdh.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdh.c deleted file mode 100644 index 9e2c833..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdh.c +++ /dev/null @@ -1,234 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) -#include "nrf_crypto_hash.h" -#include "nrf_crypto_ecdh.h" - -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) - -#include -#include "cc310_lib_init.h" -#include "cc310_lib_keys.h" -#include "cc310_lib_shared.h" -#include "nrf_log.h" -#include "nrf_crypto_types.h" -#include "crys_ecpki_dh.h" - -static void swap_array_endian(uint8_t * p_in, uint32_t len, uint8_t * p_out) -{ - for (uint32_t i = 0; i < len; i++) - { - p_out[len-i-1] = p_in[i]; - } -} - -static uint32_t ecdh_shared_secret_compute_result_get(CRYSError_t error) -{ - uint32_t ret_val; - - switch (error) - { - case CRYS_OK: - ret_val = NRF_SUCCESS; - break; - - /* From calling CRYS_ECDH_SVDP_DH */ - case CRYS_ECDH_SVDP_DH_INVALID_PARTNER_PUBL_KEY_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_ECDH_SVDP_DH_PARTNER_PUBL_KEY_VALID_TAG_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_ECDH_SVDP_DH_INVALID_USER_PRIV_KEY_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_ECDH_SVDP_DH_USER_PRIV_KEY_VALID_TAG_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_ECDH_SVDP_DH_INVALID_TEMP_DATA_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_LENGTH; - break; - - case CRYS_ECDH_SVDP_DH_ILLEGAL_DOMAIN_ID_ERROR: - ret_val = NRF_ERROR_NOT_SUPPORTED; - break; - - case CRYS_ECDH_SVDP_DH_NOT_CONCENT_PUBL_AND_PRIV_DOMAIN_ID_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - /* From calling EcWrstDhDeriveSharedSecret */ - #if 0 - case ECWRST_DH_SHARED_VALUE_IS_ON_INFINITY_ERROR: - ret_val = NRF_ERROR_INTERNAL; - break; - #endif - default: - ret_val = NRF_ERROR_INTERNAL; - break; - - } - - return ret_val; -} - - -uint32_t nrf_crypto_ecdh_shared_secret_compute(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t const * p_public_key, - nrf_value_length_t * p_shared_secret) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_ECPKI_Domain_t * p_domain; - CRYS_ECPKI_UserPrivKey_t * p_private_key_user; - CRYS_ECPKI_UserPublKey_t * p_public_key_user; - CRYS_ECDH_TempData_t temp_buffer; - uint32_t shared_secret_size; - uint32_t shared_secret_size_temp; - __ALIGN(4) uint8_t shared_secret[NRF_CRYPTO_ECDH_SHARED_SECRET_MAX_SIZE]; - - // Check that the library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_private_key == NULL || - p_public_key == NULL || - p_shared_secret == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_public_key->p_value == NULL || - p_shared_secret->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Get the curve domain from curve_type - if (!cc310_curve_domain_get(curve_info.curve_type, &p_domain)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Ensure the private key size is valid - if (p_private_key->length != NRF_CRYPTO_ECC_PRIVATE_KEY_MAX_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Ensure the public key size is valid - if (p_public_key->length != NRF_CRYPTO_ECC_PUBLIC_KEY_MAX_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - ret_val = nrf_crypto_ecdh_shared_secret_size_get(curve_info.curve_type, &shared_secret_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - shared_secret_size_temp = shared_secret_size; - - // Ensure the shared secret can hold the output - if (p_shared_secret->length != shared_secret_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Convert to the cc310 user types for private and public keys - p_private_key_user = (CRYS_ECPKI_UserPrivKey_t *) p_private_key->p_value; - p_public_key_user = (CRYS_ECPKI_UserPublKey_t *) p_public_key->p_value; - - crys_error = CRYS_ECDH_SVDP_DH(p_public_key_user, - p_private_key_user, - shared_secret, - &shared_secret_size_temp, - &temp_buffer); - - ret_val = ecdh_shared_secret_compute_result_get(crys_error); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (shared_secret_size_temp != shared_secret_size) - { - return NRF_ERROR_INTERNAL; - } - - // Convert result to Little endian - if (curve_info.endian_type == NRF_CRYPTO_ENDIAN_LE) - { - swap_array_endian(shared_secret, shared_secret_size, p_shared_secret->p_value); - } - else - { - memcpy(p_shared_secret->p_value, shared_secret, shared_secret_size); - } - - - return ret_val; -} - -#endif // NRF_CRYPTO_BACKEND_CC310_LIB - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.c deleted file mode 100644 index a9f20cc..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.c +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) - -#include "cc310_lib_ecdsa.h" -#include "cc310_lib_init.h" -#include "cc310_lib_shared.h" -#include "ssi_pal_types.h" -#include "ssi_pal_mem.h" -#include "sns_silib.h" -#include "crys_rnd.h" -#include "crys_ecpki_ecdsa.h" -#include "crys_kdf_error.h" -#include "crys_hash_error.h" -#include "nrf_crypto_types.h" -#include "nrf_error.h" - -extern CRYS_RND_Context_t * gp_rnd_context; - - -static uint32_t ecdsa_result_get(CRYSError_t error) -{ - uint32_t ret_val = NRF_ERROR_INTERNAL; - - // TODO: Invalid data - switch (error) - { - /* From calling CRYS_KDF_KeyDerivFunc */ - case CRYS_KDF_INVALID_ARGUMENT_POINTER_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_KDF_INVALID_ARGUMENT_HASH_MODE_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_KDF_INVALID_KEY_DERIVATION_MODE_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_KDF_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_KDF_INVALID_OTHER_INFO_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_KDF_INVALID_KEYING_DATA_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - /* From calling CRYS_HASH_Init, CRYS_HASH_Update and CRYS_HASH_Finish (KDF internal) */ - case CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_DATA_IN_POINTER_INVALID_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_DATA_SIZE_ILLEGAL: - ret_val = NRF_ERROR_INVALID_LENGTH; - break; - - case CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_DATA_SIZE_IS_ILLEGAL_FOR_CSI_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_ILLEGAL_PARAMS_ERROR: - - break; - } - - return ret_val; -} - -/**@brief Internal function to get the hash type that was used to generate the hash - * used for ECDSA sign/verify. - */ -bool ecdsa_hash_algorithm_get(nrf_hash_type_t hash_type, - CRYS_ECPKI_HASH_OpMode_t * p_hash_mode) -{ - switch (hash_type) - { - case NRF_CRYPTO_HASH_TYPE_SHA1: - (*p_hash_mode) = CRYS_ECPKI_AFTER_HASH_SHA1_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA224: - (*p_hash_mode) = CRYS_ECPKI_AFTER_HASH_SHA224_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA256: - (*p_hash_mode) = CRYS_ECPKI_AFTER_HASH_SHA256_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA384: - (*p_hash_mode) = CRYS_ECPKI_AFTER_HASH_SHA384_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA512: - (*p_hash_mode) = CRYS_ECPKI_AFTER_HASH_SHA512_mode; - break; - - default: - return false; - } - - return true; -} - - -uint32_t nrf_crypto_ecdsa_sign_hash(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t const * p_hash, - nrf_value_length_t * p_signature) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_ECPKI_Domain_t * p_domain; - nrf_crypto_ecdsa_sizes_t sig_sizes; - - // TODO: What is this? - CRYS_ECDSA_SignUserContext_t * p_sig_user_context = NULL; - CRYS_ECPKI_UserPrivKey_t * p_private_key_user; - CRYS_ECPKI_HASH_OpMode_t hash_mode; - - // Check if library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - // Basic parameter testing. - if (p_private_key == NULL || - p_signature == NULL || - p_hash == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_hash->p_value == NULL || - p_signature->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Get the sizes for the keys, hash and signature - ret_val = nrf_crypto_ecdsa_sizes_get(sig_info, &sig_sizes); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // Check signature size. - if (p_signature->length != sig_sizes.signature_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check if private key size. - if (p_private_key->length != sig_sizes.private_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the hash size. - if (p_hash->length != sig_sizes.hash_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Try to get the correct curve domain. - if (!cc310_curve_domain_get(sig_info.curve_type, &p_domain)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Get the hash type to indicate that hash has already been calculated. - if (!ecdsa_hash_algorithm_get(sig_info.hash_type, &hash_mode)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - p_private_key_user = (CRYS_ECPKI_UserPrivKey_t*)p_private_key->p_value; - - crys_error = CRYS_ECDSA_Sign(gp_rnd_context, - p_sig_user_context, - p_private_key_user, - hash_mode, - p_hash->p_value, - p_hash->length, - p_signature->p_value, - &p_signature->length); - - ret_val = ecdsa_result_get(crys_error); - return ret_val; -} - - -uint32_t nrf_crypto_ecdsa_verify_hash(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t const * p_public_key, - nrf_value_length_t const * p_hash, - nrf_value_length_t const * p_signature) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_ECPKI_Domain_t * p_domain; - CRYS_ECDSA_VerifyUserContext_t * p_verify_context_user = NULL; - nrf_crypto_ecdsa_sizes_t sig_sizes; - CRYS_ECPKI_UserPublKey_t * p_public_key_user; - CRYS_ECPKI_HASH_OpMode_t hash_mode; - - // Check if library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_public_key == NULL || - p_hash == NULL || - p_signature == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_public_key->p_value == NULL || - p_hash->p_value == NULL || - p_signature->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Get the sizes for the keys, hash and signature - ret_val = nrf_crypto_ecdsa_sizes_get(sig_info, &sig_sizes); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // Check the signature size. - if (p_signature->length != sig_sizes.signature_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the private key size. - if (p_public_key->length != sig_sizes.public_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the hash size. - if (p_hash->length != sig_sizes.hash_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Try to get the correct curve domain - if (!cc310_curve_domain_get(sig_info.curve_type, &p_domain)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Get the hash type to indicate that hash has already been calculated. - if (!ecdsa_hash_algorithm_get(sig_info.hash_type, &hash_mode)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - p_public_key_user = (CRYS_ECPKI_UserPublKey_t *)p_public_key->p_value; - - crys_error = CRYS_ECDSA_Verify(p_verify_context_user, - p_public_key_user, - hash_mode, - p_signature->p_value, - p_signature->length, - p_hash->p_value, - p_hash->length); - - ret_val = ecdsa_result_get(crys_error); - return ret_val; -} - -#endif // NRF_CRYPTO_BACKEND_CC310_LIB - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.c deleted file mode 100644 index 305c232..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.c +++ /dev/null @@ -1,333 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) - -#include "cc310_lib_hash.h" -#include "cc310_lib_init.h" -#include -#include "crys_hash.h" -#include "crys_hash_error.h" -#include "nrf_error.h" -#include "crys_rnd.h" - -bool hash_algorithm_get(nrf_hash_type_t hash_type, CRYS_HASH_OperationMode_t * p_hash_mode) -{ - if (p_hash_mode == NULL) - { - return false; - } - - switch (hash_type) - { - case NRF_CRYPTO_HASH_TYPE_MD5: - (*p_hash_mode) = CRYS_HASH_MD5_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA1: - (*p_hash_mode) = CRYS_HASH_SHA1_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA224: - (*p_hash_mode) = CRYS_HASH_SHA224_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA256: - (*p_hash_mode) = CRYS_HASH_SHA256_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA384: - (*p_hash_mode) = CRYS_HASH_SHA384_mode; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA512: - (*p_hash_mode) = CRYS_HASH_SHA512_mode; - break; - - default: - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - - -static uint32_t hash_result_get(CRYSError_t error) -{ - uint32_t ret_val; - - switch (error) - { - case CRYS_OK: - ret_val = NRF_SUCCESS; - break; - - case CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR: - ret_val = NRF_ERROR_NOT_SUPPORTED; - break; - - case CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR: - ret_val = NRF_ERROR_INVALID_DATA; - break; - - case CRYS_HASH_DATA_IN_POINTER_INVALID_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_HASH_DATA_SIZE_ILLEGAL: - ret_val = NRF_ERROR_INVALID_LENGTH; - break; - - case CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_HASH_DATA_SIZE_IS_ILLEGAL_FOR_CSI_ERROR: - ret_val = NRF_ERROR_INVALID_LENGTH; - break; - - case CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - - case CRYS_HASH_ILLEGAL_PARAMS_ERROR: - ret_val = NRF_ERROR_INTERNAL; - break; - - case CRYS_HASH_CTX_SIZES_ERROR: - ret_val = NRF_ERROR_INVALID_LENGTH; - break; - - case CRYS_HASH_IS_NOT_SUPPORTED: - ret_val = NRF_ERROR_NOT_SUPPORTED; - break; - - default: - ret_val = NRF_ERROR_INTERNAL; - break; - } - - return ret_val; -} - - -uint32_t nrf_crypto_hash_init(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_HASH_OperationMode_t hash_type = CRYS_HASH_OperationModeLast; - CRYS_HASHUserContext_t * p_hash_context_user; - - // Check if library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_hash_context == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_hash_context->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - if (p_hash_context->length != NRF_CRYPTO_HASH_CONTEXT_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (!hash_algorithm_get(hash_info.hash_type, &hash_type)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - if (hash_info.endian_type != NRF_CRYPTO_ENDIAN_LE) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Convert hash context to cc310 user format - p_hash_context_user = (CRYS_HASHUserContext_t *)p_hash_context->p_value; - - crys_error = CRYS_HASH_Init(p_hash_context_user, hash_type); - ret_val = hash_result_get(crys_error); - return ret_val; -} - - -uint32_t nrf_crypto_hash_update(nrf_value_length_t * p_hash_context, - uint8_t const * p_data, - uint32_t len) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_HASHUserContext_t * p_hash_context_user; - - // Check if library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_hash_context == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - - if (p_hash_context->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - if (p_hash_context->length != NRF_CRYPTO_HASH_CONTEXT_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Convert hash context to cc310 user format - p_hash_context_user = (CRYS_HASHUserContext_t *)p_hash_context->p_value; - - crys_error = CRYS_HASH_Update(p_hash_context_user, (uint8_t*)p_data, len); - ret_val = hash_result_get(crys_error); - return ret_val; -} - - -uint32_t nrf_crypto_hash_finalize(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context, - nrf_value_length_t * p_hash) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_HASHUserContext_t * p_hash_context_user; - CRYS_HASH_Result_t * p_hash_result = (CRYS_HASH_Result_t *)p_hash->p_value; - - // Check if library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - // Check the parameters - if (p_hash_context == NULL || - p_hash == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_hash_context->p_value == NULL || - p_hash->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Check the length of the hash context - if (p_hash_context->length != NRF_CRYPTO_HASH_CONTEXT_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the length of the hash - - - // Convert hash context to cc310 user format - p_hash_context_user = (CRYS_HASHUserContext_t *)p_hash_context->p_value; - - // Not sure about this - crys_error = CRYS_HASH_Finish(p_hash_context_user, *p_hash_result); - ret_val = hash_result_get(crys_error); - return ret_val; -} - - -uint32_t nrf_crypto_hash_compute(nrf_crypto_hash_info_t hash_info, - uint8_t const * p_data, - uint32_t len, - nrf_value_length_t * p_hash) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_HASH_OperationMode_t hash_type = CRYS_HASH_OperationModeLast; - CRYS_HASH_Result_t * p_hash_result; - - if (p_data == NULL || p_hash == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_hash->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - if (!hash_algorithm_get(hash_info.hash_type, &hash_type)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Currently only supporting LE hash - if (hash_info.endian_type != NRF_CRYPTO_ENDIAN_LE) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Convert output buffer to valid. - p_hash_result = (CRYS_HASH_Result_t *)p_hash->p_value; - - - crys_error = CRYS_HASH(hash_type, (uint8_t*)p_data, len, *p_hash_result); - ret_val = hash_result_get(crys_error); - return ret_val; -} - -#endif // NRF_CRYPTO_BACKEND_CC310_LIB - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.c deleted file mode 100644 index 02257c5..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.c +++ /dev/null @@ -1,465 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) - -#include -#include "nrf_crypto_keys.h" -#include "cc310_lib_keys.h" -#include "cc310_lib_init.h" -#include "cc310_lib_shared.h" -#include "nrf_log.h" -#include "nrf_crypto_types.h" -#include "crys_ecpki_error.h" -#include "crys_ecpki_build.h" -#include "crys_ecpki_kg.h" -#include "string.h" - -extern CRYS_RND_Context_t * gp_rnd_context; - -static void swap_array_endian(uint8_t * p_in, uint32_t len, uint8_t * p_out) -{ - uint32_t i; - for (i = 0; i < len; i++) - { - p_out[len-i-1] = p_in[i]; - } -} - -static uint32_t key_pair_generate_result_get(CRYSError_t crys_error) -{ - uint32_t ret_val= NRF_ERROR_INTERNAL; - - switch (crys_error) - { - case CRYS_OK: - ret_val = NRF_SUCCESS; - break; - case CRYS_ECPKI_RND_CONTEXT_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - - case CRYS_ECPKI_ILLEGAL_D0MAIN_ID_ERROR: - ret_val = NRF_ERROR_NOT_SUPPORTED; - break; - - case CRYS_ECPKI_DOMAIN_PTR_ERROR: - ret_val = NRF_ERROR_INTERNAL; - break; - - case CRYS_ECPKI_GEN_KEY_INVALID_PRIVATE_KEY_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_ECPKI_GEN_KEY_INVALID_PUBLIC_KEY_PTR_ERROR: - ret_val = NRF_ERROR_INVALID_ADDR; - break; - - case CRYS_ECPKI_GEN_KEY_INVALID_TEMP_DATA_PTR_ERROR: - ret_val = NRF_ERROR_INTERNAL; - break; - - #if 0 - /* From calling CRYS_RND_GenerateVectorInRange */ - case CRYS_RND_GEN_VECTOR_FUNC_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - - case CRYS_RND_VECTOR_OUT_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - - case CRYS_RND_CONTEXT_PTR_INVALID_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - - case CRYS_RND_MAX_VECTOR_IS_TOO_SMALL_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - #endif - - #if 0 - case ECWRST_SCALAR_MULT_INVALID_SCALAR_VALUE_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - - case ECWRST_SCALAR_MULT_INVALID_MOD_ORDER_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_STATE; - break; - #endif - default: - ret_val = NRF_ERROR_INTERNAL; - break; - } - - - return ret_val; -} - - -static uint32_t public_key_calculate_result_get(CRYSError_t crys_error) -{ - uint32_t ret_val; - - switch (crys_error) - { - case CRYS_OK: - ret_val = NRF_SUCCESS; - break; - - default: - ret_val = NRF_ERROR_INTERNAL; - break; - } - - return ret_val; -} - - -static uint32_t public_key_build_result_get(CRYSError_t crys_error) -{ - uint32_t ret_val; - - switch (crys_error) - { - case CRYS_OK: - NRF_LOG_INFO("Key build result successful!"); - ret_val = NRF_SUCCESS; - break; - - default: - ret_val = NRF_ERROR_INTERNAL; - break; - } - - return ret_val; - -} - -static uint32_t public_key_export_result_get(CRYSError_t crys_error) -{ - uint32_t ret_val = NRF_SUCCESS; - - switch (crys_error) - { - case CRYS_OK: - NRF_LOG_INFO("Key build result successful!"); - ret_val = NRF_SUCCESS; - break; - - #if 0 - case CRYS_COMMON_DATA_SIZE_ILLEGAL: - ret_val = NRF_ERROR_INTERNAL; - break; - #endif - - case CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_ERROR: - ret_val = NRF_ERROR_INVALID_LENGTH; - break; - - default: - ret_val = NRF_ERROR_INTERNAL; - break; - } - - return ret_val; - -} - -uint32_t nrf_crypto_ecc_key_pair_generate(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t * p_private_key, - nrf_value_length_t * p_public_key) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_ECPKI_Domain_t * p_domain; - - CRYS_ECPKI_KG_TempData_t temp_ecpki_kg_buffer; - - CRYS_ECPKI_UserPrivKey_t * p_private_key_user; - CRYS_ECPKI_UserPublKey_t * p_public_key_user; - - // Check that the library has been initialized - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_private_key == NULL || p_public_key == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - - // Get the curve domain from curve_type - if (!cc310_curve_domain_get(curve_type.curve_type, &p_domain)) - { - NRF_LOG_INFO("Could not get curve domain!"); - return NRF_ERROR_NOT_SUPPORTED; - } - - - // Ensure the private key can hold the internal type. - if (p_private_key->length != NRF_CRYPTO_ECC_PRIVATE_KEY_MAX_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Ensure the public key can hold the external type. - if (p_public_key->length != NRF_CRYPTO_ECC_PUBLIC_KEY_MAX_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - - p_private_key_user = (CRYS_ECPKI_UserPrivKey_t *)p_private_key->p_value; - p_public_key_user = (CRYS_ECPKI_UserPublKey_t *)p_public_key->p_value; - - crys_error = CRYS_ECPKI_GenKeyPair(gp_rnd_context, - p_domain, - p_private_key_user, - p_public_key_user, - &temp_ecpki_kg_buffer, - NULL ); - - - - ret_val = key_pair_generate_result_get(crys_error); - return ret_val; -} - - -uint32_t nrf_crypto_ecc_public_key_calculate(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t const * p_private_key, - nrf_value_length_t * p_public_key) -{ - uint32_t ret_val; - - ret_val = public_key_calculate_result_get(CRYS_OK); - return ret_val; -} - - -uint32_t nrf_crypto_ecc_private_key_to_raw(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t * p_private_key_raw) -{ - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecc_public_key_to_raw(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t const * p_public_key, - nrf_value_length_t * p_raw_key) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_ECPKI_UserPublKey_t * p_public_key_user; - CRYS_ECPKI_Domain_t * p_domain; - uint32_t raw_param_size; - uint32_t compact_key_size; - uint32_t public_key_raw_size; - __ALIGN(4) uint8_t public_key_buffer[NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP521R1 + 1]; - - // Check that both the public key and raw key is valid - if (p_public_key == NULL || p_raw_key == NULL) - { - return NRF_ERROR_NULL; - } - - // Get the curve domain from curve_type - if (!cc310_curve_domain_get(curve_type.curve_type, &p_domain)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - ret_val = nrf_crypto_ecc_public_key_size_get(curve_type.curve_type, &public_key_raw_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // Ensure the public key can hold the raw representation. - if (public_key_raw_size != p_raw_key->length) - { - return NRF_ERROR_INVALID_LENGTH; - } - - compact_key_size = public_key_raw_size + 1; - - // Convert the key to the - p_public_key_user = (CRYS_ECPKI_UserPublKey_t *)p_public_key->p_value; - - crys_error = CRYS_ECPKI_ExportPublKey(p_public_key_user, - CRYS_EC_PointUncompressed, - public_key_buffer, - &compact_key_size); - ret_val = public_key_export_result_get(crys_error); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // format is [tag][x][y] - if (compact_key_size != public_key_raw_size + 1) - { - return NRF_ERROR_INTERNAL; - } - - if (public_key_buffer[0] != 0x04) - { - return NRF_ERROR_INTERNAL; - } - - raw_param_size = compact_key_size / 2; - - if (curve_type.endian_type == NRF_CRYPTO_ENDIAN_LE) - { - // Swap X value - swap_array_endian(public_key_buffer + 1, raw_param_size, p_raw_key->p_value); - // Swap Y value - swap_array_endian(public_key_buffer + raw_param_size + 1, raw_param_size, p_raw_key->p_value + raw_param_size); - } - else - { - // X and Y value is already in the correct order. - memcpy(p_raw_key->p_value, public_key_buffer + 1, compact_key_size); - } - - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecc_public_key_from_raw(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t * p_public_key_raw, - nrf_value_length_t * p_public_key) -{ - uint32_t ret_val; - CRYSError_t crys_error; - CRYS_ECPKI_UserPublKey_t * p_public_key_user; - CRYS_ECPKI_Domain_t * p_domain; - uint32_t raw_key_size; - uint32_t raw_param_size; - - // Compact representation of public key according to IEEE1363, - // using 1 byte to designate the format. - // Using a largest public key for size (used key will be equal or smaller). - __ALIGN(4) uint8_t compact_rep[NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP521R1 + 1]; - - // Check that both the public key and raw key is valid - if (p_public_key == NULL || p_public_key_raw == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_public_key->p_value == NULL || - p_public_key_raw->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Get the curve domain from curve_type - if (!cc310_curve_domain_get(curve_type.curve_type, &p_domain)) - { - NRF_LOG_INFO("Could not get curve domain"); - return NRF_ERROR_NOT_SUPPORTED; - } - - ret_val = nrf_crypto_ecc_public_key_size_get(curve_type.curve_type, &raw_key_size); - if (ret_val != NRF_SUCCESS) - { - NRF_LOG_INFO("Could not get key size"); - return NRF_SUCCESS; - } - - // Ensure the public key can hold the external type. - if (p_public_key_raw->length != raw_key_size) - { - NRF_LOG_INFO("p_raw_key->length != raw_key_size"); - return NRF_ERROR_INVALID_LENGTH; - } - - // Ensure the public key can hold the internal type. - if (p_public_key->length != sizeof(CRYS_ECPKI_UserPublKey_t)) - { - NRF_LOG_INFO("p_public_key->length != sizeof(CRYS_ECPKI_UserPublKey_t)"); - return NRF_ERROR_INVALID_LENGTH; - } - - raw_param_size = raw_key_size / 2; - - // Add one to hold the prefix. - raw_key_size += 1; - - // Compact representation is big-endian by IEEE1636 spec. - // Indicate that we have a key with X and Y (non-compressed) - compact_rep[0] = 0x04; - if (curve_type.endian_type == NRF_CRYPTO_ENDIAN_LE) - { - // Swap X value - swap_array_endian(p_public_key_raw->p_value, raw_param_size, compact_rep + 1); - // Swap Y value - swap_array_endian(p_public_key_raw->p_value + raw_param_size, raw_param_size, compact_rep + raw_param_size + 1); - } - else - { - // X and Y value is already in the correct order for CryptoCell. - memcpy(compact_rep + 1, p_public_key_raw->p_value, raw_key_size); - } - - // Set the pointer to be the return value. - p_public_key_user = (CRYS_ECPKI_UserPublKey_t *)p_public_key->p_value; - - NRF_LOG_INFO("Building public key!"); - crys_error = CRYS_ECPKI_BuildPublKey(p_domain, - compact_rep, - raw_key_size, - p_public_key_user); - NRF_LOG_INFO("Finished building public key: 0x%08x!", crys_error); - - ret_val = public_key_build_result_get(crys_error); - return ret_val; -} - - -#endif // NRF_CRYPTO_BACKEND_CC310_LIB - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdh.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdh.c deleted file mode 100644 index 9294671..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdh.c +++ /dev/null @@ -1,165 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if (NRF_CRYPTO_BACKEND_MICRO_ECC && NRF_CRYPTO_BACKEND_MICRO_ECC_RNG) - -#include "nrf_crypto.h" -#include "micro_ecc_lib_ecdh.h" -#include "micro_ecc_lib_keys.h" -#include "micro_ecc_lib_init.h" -#include "micro_ecc_lib_shared.h" - -#include "uECC.h" - - -static void swap_array_endian(uint8_t * p_in, uint32_t len, uint8_t * p_out) -{ - uint32_t i; - for (i = 0; i < len; i++) - { - p_out[len-i-1] = p_in[i]; - } -} - - -uint32_t nrf_crypto_ecdh_shared_secret_compute(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t const * p_public_key, - nrf_value_length_t * p_shared_secret) -{ - uint32_t ret_val; - uint32_t public_key_size; - uint32_t private_key_size; - uint32_t shared_secret_size; - const struct uECC_Curve_t * p_curve; - __ALIGN(4) uint8_t shared_secret[NRF_CRYPTO_ECDH_SHARED_SECRET_MAX_SIZE]; - - // This function does not require initialized nrf_crypto for this backend. - - // Check private key - if (p_private_key == NULL || - p_public_key == NULL || - p_shared_secret == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_public_key->p_value == NULL || - p_shared_secret->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Check type alignment - if (!is_word_aligned(p_private_key->p_value) || - !is_word_aligned(p_public_key->p_value) || - !is_word_aligned(p_shared_secret->p_value) ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Check public key size - ret_val = nrf_crypto_ecc_public_key_size_get(curve_info.curve_type, &public_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (public_key_size != p_public_key->length) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check private key size - ret_val = nrf_crypto_ecc_private_key_size_get(curve_info.curve_type, &private_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (private_key_size != p_private_key->length) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check shared secret size - ret_val = nrf_crypto_ecdh_shared_secret_size_get(curve_info.curve_type, &shared_secret_size); - if (ret_val != NRF_SUCCESS) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (shared_secret_size != p_shared_secret->length) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (!micro_ecc_curve_domain_get(curve_info.curve_type, &p_curve)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - if (!uECC_shared_secret(p_public_key->p_value, - p_private_key->p_value, - shared_secret, - p_curve)) - { - return NRF_ERROR_INTERNAL; - } - - // Convert result to Little endian - if (curve_info.endian_type == NRF_CRYPTO_ENDIAN_LE) - { - memcpy(p_shared_secret->p_value, shared_secret, shared_secret_size); - } - else - { - swap_array_endian(shared_secret, shared_secret_size, p_shared_secret->p_value); - } - - - return NRF_SUCCESS; -} - -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC && NRF_CRYPTO_BACKEND_MICRO_ECC_RNG -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.c deleted file mode 100644 index b012ed2..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.c +++ /dev/null @@ -1,214 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if NRF_CRYPTO_BACKEND_MICRO_ECC - -#include "nrf_crypto_hash.h" -#include "nrf_crypto_ecdsa.h" -#include "nrf_crypto_types.h" -#include "micro_ecc_lib_ecdsa.h" -#include "micro_ecc_lib_keys.h" -#include "micro_ecc_lib_shared.h" -#include "nrf_log.h" - -#include "uECC.h" - -#if NRF_CRYPTO_BACKEND_MICRO_ECC_RNG - -uint32_t nrf_crypto_ecdsa_sign_hash(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t const * p_hash, - nrf_value_length_t * p_signature) -{ - uint32_t ret_val; - nrf_crypto_ecdsa_sizes_t sig_sizes; - const struct uECC_Curve_t * p_curve = uECC_secp256r1(); - - // Parameter NULL testing. - if (p_private_key == NULL || - p_hash == NULL || - p_signature == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_hash->p_value == NULL || - p_signature->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Ensure data is aligned - if (!is_word_aligned(p_private_key->p_value) || - !is_word_aligned(p_hash->p_value) || - !is_word_aligned(p_signature->p_value) ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Get the sizes for the keys, hash and signature - ret_val = nrf_crypto_ecdsa_sizes_get(sig_info, &sig_sizes); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // Check the private key size. - if (p_private_key->length != sig_sizes.private_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check if hash size. - if (p_hash->length != sig_sizes.hash_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the signature size. - if (p_signature->length != sig_sizes.signature_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Get the curve domain to use for signing - if (!micro_ecc_curve_domain_get(sig_info.curve_type, &p_curve)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Create a signature of the hash data. - if (uECC_sign(p_private_key->p_value, p_hash->p_value, p_hash->length, p_signature->p_value, p_curve)) - { - return NRF_ERROR_INTERNAL; - } - - return NRF_SUCCESS; -} - -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC_RNG - - -uint32_t nrf_crypto_ecdsa_verify_hash(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t const * p_public_key, - nrf_value_length_t const * p_hash, - nrf_value_length_t const * p_signature) -{ - uint32_t ret_val; - nrf_crypto_ecdsa_sizes_t sig_sizes; - const struct uECC_Curve_t * p_curve = uECC_secp256r1(); - - // Parameter NULL testing - if (p_public_key == NULL || - p_hash == NULL || - p_signature == NULL ) - { - return NRF_ERROR_NULL; - } - - if (p_public_key->p_value == NULL || - p_hash->p_value == NULL || - p_signature->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Check alignment for data. - if (!is_word_aligned(p_public_key->p_value) || - !is_word_aligned(p_hash->p_value) || - !is_word_aligned(p_signature->p_value) ) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Get the sizes for the keys, hash and signature - ret_val = nrf_crypto_ecdsa_sizes_get(sig_info, &sig_sizes); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - // Check the public key size. - if (p_public_key->length != sig_sizes.public_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the hash size. - if (p_hash->length != sig_sizes.hash_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Check the signature size. - if (p_signature->length != sig_sizes.signature_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Get the curve domain to use for verifying - #if 0 - // Optimizer in keil/gcc not able to optimize away other unused curves. - // Setting to only supported curve type. - if (!micro_ecc_curve_domain_get(sig_info.curve_type, &p_curve)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - #else - if (sig_info.curve_type != NRF_CRYPTO_CURVE_SECP256R1) - { - return NRF_ERROR_NOT_SUPPORTED; - } - #endif - - // Verify the signature by the hash - if (uECC_verify(p_public_key->p_value, p_hash->p_value, p_hash->length, p_signature->p_value, p_curve) == 0) - { - return NRF_ERROR_INVALID_DATA; - } - - return NRF_SUCCESS; -} - -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.c deleted file mode 100644 index 75b8d6e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.c +++ /dev/null @@ -1,280 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if NRF_CRYPTO_BACKEND_MICRO_ECC - -#include "micro_ecc_lib_keys.h" -#include "micro_ecc_lib_shared.h" -#include "micro_ecc_lib_init.h" -#include "nrf_crypto_types.h" - -#include "uECC.h" - - -#if !defined(NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256) -#error Enable NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 in SDK config for key generation (required random number generator) -#endif - -#if NRF_CRYPTO_BACKEND_MICRO_ECC_RNG - -uint32_t nrf_crypto_ecc_key_pair_generate(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t * p_private_key, - nrf_value_length_t * p_public_key) -{ - uint32_t ret_val; - uint32_t private_key_size; - uint32_t public_key_size; - const struct uECC_Curve_t * p_curve; - - if (!nrf_crypto_is_initialized()) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_private_key == NULL || - p_public_key == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_public_key->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - if (!is_word_aligned(p_private_key->p_value) || !is_word_aligned(p_public_key->p_value)) - { - return NRF_ERROR_INVALID_ADDR; - } - - ret_val = nrf_crypto_ecc_private_key_size_get(curve_type.curve_type, &private_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (p_private_key->length != private_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - ret_val = nrf_crypto_ecc_public_key_size_get(curve_type.curve_type, &public_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (p_public_key->length != public_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (!micro_ecc_curve_domain_get(curve_type.curve_type, &p_curve)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - if (uECC_make_key(p_public_key->p_value, p_private_key->p_value, p_curve) == 0) - { - return NRF_ERROR_INTERNAL; - } - - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecc_public_key_calculate(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t const * p_private_key, - nrf_value_length_t * p_public_key) -{ - uint32_t ret_val; - uint32_t private_key_size; - uint32_t public_key_size; - const struct uECC_Curve_t * p_curve; - - // This function does not require initialized nrf_crypto backend library. - - if (p_private_key == NULL || p_public_key == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_public_key->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - ret_val = nrf_crypto_ecc_private_key_size_get(curve_type.curve_type, &private_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (p_private_key->length != private_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - ret_val = nrf_crypto_ecc_public_key_size_get(curve_type.curve_type, &public_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (p_public_key->length != public_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (!is_word_aligned(p_private_key->p_value) || !is_word_aligned(p_public_key->p_value)) - { - return NRF_ERROR_INVALID_ADDR; - } - - if (!micro_ecc_curve_domain_get(curve_type.curve_type, &p_curve)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - if (uECC_compute_public_key(p_private_key->p_value, p_public_key->p_value, p_curve) == 0) - { - return NRF_ERROR_INTERNAL; - } - - return NRF_SUCCESS; -} - -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC_RNG - - -uint32_t nrf_crypto_ecc_private_key_to_raw(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t * p_private_key_raw) -{ - uint32_t ret_val; - uint32_t private_key_size; - - if (p_private_key == NULL || p_private_key_raw == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_private_key->p_value == NULL || - p_private_key_raw->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - ret_val = nrf_crypto_ecc_private_key_size_get(curve_info.curve_type, &private_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (p_private_key_raw->length != private_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (p_private_key->length != private_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Copy the private key directly. - memcpy(p_private_key_raw->p_value, p_private_key->p_value, private_key_size); - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecc_public_key_to_raw(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_public_key, - nrf_value_length_t * p_raw_key) -{ - uint32_t ret_val; - uint32_t public_key_size; - - if (p_public_key == NULL || p_raw_key == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_public_key->p_value == NULL || - p_raw_key->p_value == NULL ) - { - return NRF_ERROR_INVALID_ADDR; - } - - ret_val = nrf_crypto_ecc_public_key_size_get(curve_info.curve_type, &public_key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (p_raw_key->length != public_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (p_public_key->length != public_key_size) - { - return NRF_ERROR_INVALID_LENGTH; - } - - memcpy(p_raw_key->p_value, p_public_key->p_value, p_raw_key->length); - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecc_public_key_from_raw(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t * p_public_key_raw, - nrf_value_length_t * p_public_key) -{ - // TODO: Parameter testing - memcpy(p_public_key->p_value, p_public_key_raw->p_value, p_public_key_raw->length); - return NRF_SUCCESS; -} - -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.c deleted file mode 100644 index d63ea59..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.c +++ /dev/null @@ -1,218 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#if defined(NRF_CRYPTO_BACKEND_MICRO_ECC) && (NRF_CRYPTO_BACKEND_MICRO_ECC == 1) - -#include "nrf_crypto_hash.h" -#include "nrf_crypto_mem.h" -#include "nrf_crypto_sw_hash.h" -#include "sha256.h" -#include "nrf_log.h" - -uint32_t nrf_crypto_hash_init(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context) -{ - uint32_t ret_val; - sha256_context_t * p_hash_context_user; - - if (p_hash_context == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_hash_context->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - if (p_hash_context->length < NRF_CRYPTO_HASH_CONTEXT_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - // Currently SHA256 is the only available hash algorithm - if (hash_info.hash_type != NRF_CRYPTO_HASH_TYPE_SHA256) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - p_hash_context_user = (sha256_context_t *)p_hash_context->p_value; - - ret_val = sha256_init(p_hash_context_user); - return ret_val; -} - -uint32_t nrf_crypto_hash_update(nrf_value_length_t * p_hash_context, - uint8_t const * p_data, - uint32_t len) -{ - uint32_t ret_val; - sha256_context_t * p_hash_context_user; - - if (p_hash_context == NULL || p_data == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - - if (p_hash_context->length < NRF_CRYPTO_HASH_CONTEXT_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - p_hash_context_user = (sha256_context_t *)p_hash_context->p_value; - - ret_val = sha256_update(p_hash_context_user, p_data, len); - return ret_val; -} - - -uint32_t nrf_crypto_hash_finalize(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context, - nrf_value_length_t * p_hash) -{ - uint32_t ret_val; - sha256_context_t * p_hash_context_user; - uint8_t endian_type; - uint32_t hash_size; - - if (p_hash_context == NULL || p_hash == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - - // Check hash context size - if (p_hash_context->length != NRF_CRYPTO_HASH_CONTEXT_SIZE) - { - return NRF_ERROR_INVALID_LENGTH; - } - - p_hash_context_user = (sha256_context_t *)p_hash_context->p_value; - - // Check if hash is correct size - ret_val = nrf_crypto_hash_size_get(hash_info.hash_type, &hash_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (hash_size != p_hash->length) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (hash_info.endian_type == NRF_CRYPTO_ENDIAN_LE) - { - endian_type = 1; - } - else - { - endian_type = 0; - } - - ret_val = sha256_final(p_hash_context_user, p_hash->p_value, endian_type); - return ret_val; -} - - -uint32_t nrf_crypto_hash_compute(nrf_crypto_hash_info_t hash_info, - uint8_t const * p_data, - uint32_t len, - nrf_value_length_t * p_hash) -{ - uint32_t ret_val; - uint32_t hash_size; - sha256_context_t hash_context; - nrf_value_length_t hash_context_desc = - { - .p_value = (uint8_t*)&hash_context, - .length = sizeof(hash_context) - }; - - // Basic parameter testing. - if (p_hash == NULL || p_data == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_hash->p_value == NULL) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Currently SHA256 is the only available hash algorithm - if (hash_info.hash_type != NRF_CRYPTO_HASH_TYPE_SHA256) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - // Check if hash is correct size. - ret_val = nrf_crypto_hash_size_get(hash_info.hash_type, &hash_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - if (hash_size != p_hash->length) - { - return NRF_ERROR_INVALID_LENGTH; - } - - ret_val = nrf_crypto_hash_init(hash_info, &hash_context_desc); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_hash_update(&hash_context_desc, p_data, len); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_hash_finalize(hash_info, &hash_context_desc, p_hash); - return ret_val; -} - - -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.c deleted file mode 100644 index 5243a76..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.c +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#include "nrf_crypto_ecdh.h" -#include "nrf_crypto_mem.h" - -#if NRF_CRYPTO_BACKEND_MICRO_ECC -#include "micro_ecc_lib_ecdh.h" -#endif - -uint32_t nrf_crypto_ecdh_shared_secret_size_get(nrf_ecc_curve_type_t curve_type, - uint32_t * p_size) -{ - if (p_size == NULL) - { - return NRF_ERROR_NULL; - } - - switch (curve_type) - { - case NRF_CRYPTO_CURVE_SECP160R1: - (*p_size)= NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP160R1; - break; - - case NRF_CRYPTO_CURVE_SECP192R1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP192R1; - break; - - case NRF_CRYPTO_CURVE_SECP224R1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP224R1; - break; - - case NRF_CRYPTO_CURVE_SECP256R1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP256R1; - break; - - case NRF_CRYPTO_CURVE_SECP384R1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP384R1; - break; - - case NRF_CRYPTO_CURVE_SECP521R1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP521R1; - break; - - case NRF_CRYPTO_CURVE_SECP192K1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP192K1; - break; - - case NRF_CRYPTO_CURVE_SECP224K1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP224K1; - break; - - case NRF_CRYPTO_CURVE_SECP256K1: - (*p_size) = NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP256K1; - break; - - default: - (*p_size) = 0; - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecdh_shared_secret_allocate(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t * p_shared_secret, - nrf_value_length_t const * p_raw_shared_secret) -{ - uint32_t ret_val; - uint32_t shared_secret_size; - - if (p_shared_secret == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_ecdh_shared_secret_size_get(curve_type.curve_type, &shared_secret_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_mem_allocate(shared_secret_size, p_shared_secret); - if (ret_val == NRF_SUCCESS) - { - return ret_val; - } - - return ret_val; -} - - -uint32_t nrf_crypto_ecdh_shared_secret_free(nrf_value_length_t * p_shared_secret) -{ - uint32_t ret_val; - - if (p_shared_secret == NULL) - { - return NRF_ERROR_NULL; - } - - // Memory was already freed - if (p_shared_secret->length == 0) - { - return NRF_SUCCESS; - } - - ret_val = nrf_crypto_mem_free(p_shared_secret); - return ret_val; -} - - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.h deleted file mode 100644 index 7d39fa7..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdh.h +++ /dev/null @@ -1,186 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_CRYPTO_ECDH_H__ -#define NRF_CRYPTO_ECDH_H__ - -/** @file - * - * @defgroup nrf_crypto_ecdh ECDH related functions - * @{ - * @ingroup nrf_crypto - * - * @brief Provides ECDH related functionality through nrf_crypto. - */ - -#include -#include "nrf_crypto_types.h" - -#ifdef __cplusplus -extern "C" { -#if 0 -} -#endif -#endif - - -/** @brief Macro to create an instance of a ECDH shared secret with a given name. - * - * @note This creates the value length structure used for nrf_crypto APIs and a - * buffer to hold the shared secret without using dynamically allocated memory. - * - * @param[in] name Name of the variable to hold an ECDH shared secret. - * @param[in] type Either SECP160R1, SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#define NRF_CRYPTO_ECDH_SHARED_SECRET_INSTANCE_CREATE(name, type) \ -__ALIGN(4) static uint8_t \ - name ## _backing[STRING_CONCATENATE(NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_, type)]; \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _backing, \ - .length = STRING_CONCATENATE(NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_, type) \ -} - - -/** @brief Macro to create an instance of a ECDH shared secret with a given name, type and input. - * - * If the input is not of the correct size a static assert will be occur compile-time. - * - * @note This creates the value length structure used for nrf_crypto APIs and a - * buffer to hold the shared secret without using dynamically allocated memory. - * - * @param[in] name Name of the variable to hold an ECDH shared secret. - * @param[in] type Either SECP160R1, SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - * @param[in] input Input must be an array of correct size according to the curve type. - */ -#define NRF_CRYPTO_ECDH_SHARED_SECRET_CREATE_FROM_ARRAY(name, type, input) \ -STATIC_ASSERT(sizeof(input) == STRING_CONCATENATE(NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_, type)); \ -static nrf_value_length_t name = \ -{ \ - .p_value = input, \ - .length = STRING_CONCATENATE(NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_, type) \ -} - - -/**@brief Function to get the shared secret size given curve type. - * - * @param[in] curve_type Elliptic curve to use. - * @param[in,out] p_size Pointer to variable to hold size of shared secret. - * - * @retval NRF_SUCCESS Shared secret size was calculated. - * @retval NRF_ERROR_NOT_SUPPORTED Selected curve was not supported. - */ -uint32_t nrf_crypto_ecdh_shared_secret_size_get(nrf_ecc_curve_type_t curve_type, - uint32_t * p_size); - - -/**@brief Function to allocate dynamic memory for ECDH shared secret. - * - * @param[in] curve_type Elliptic curve to use. - * @param[in,out] p_shared_secret Pointer to structure to hold a shared secret. - * @param[in] p_raw_shared_secret Pointer to structure holding a raw representation - * of a shared secret. If this is not NULL, the value - * will be copied to the allocated memory. - * - * @retval NRF_SUCCESS Memory for the public key was successfully allocated. - @retval NRF_ERROR_NULL If any of the parameters was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecdh_shared_secret_allocate(nrf_crypto_curve_info_t curve_type, - nrf_value_length_t * p_shared_secret, - nrf_value_length_t const * p_raw_shared_secret); - - -/**@brief Function to free allocated memory for ECDH shared secret. - * - * @param[in] p_shared_secret - * - * @retval NRF_SUCCESS Memory for the ECDH shared secret was successfully freed. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecdh_shared_secret_free(nrf_value_length_t * p_shared_secret); - - -/**@brief Function for computing a shared secret from a key pair. - * - * @note Length of allocated buffers for private key, public key and - * shared secret is taken as input. - * - * @param[in] curve_info Elliptic curve to use, and requested endianness of @p p_shared_secret. - * @param[in] p_private_key Pointer to structure holding private key. - * @param[in] p_public_key Pointer to structure holding public key. - * @param[in,out] p_shared_secret Pointer to structure to hold the calculated shared secret. - * After the call the length variable will be updated to the - * actual length of the shared secret data - * - * @retval NRF_SUCCESS If the shared secret was computed successfully. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. - * @retval NRF_ERROR_NULL If the provided key, hash or signature parameters was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected elliptic curve is not supported. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_DATA If any of the keys or result data is deemed invalid by the - * nrf_crypto backend. - * @retval NRF_ERROR_INVALID_LENGTH If the length of allocated data for keys or result is - * incorrect. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_ecdh_shared_secret_compute(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t const * p_public_key, - nrf_value_length_t * p_shared_secret); - - -/**@brief Macro to express curve information for Bluetooth LE Secure Connection (LESC) - */ -#define NRF_CRYPTO_BLE_ECDH_CURVE_INFO (nrf_crypto_curve_info_t) \ -{ \ - .curve_type = NRF_CRYPTO_CURVE_SECP256R1, \ - .endian_type = NRF_CRYPTO_ENDIAN_LE \ -} - - -#ifdef __cplusplus -} -#endif - -/**@} */ - -#endif // #ifndef NRF_CRYPTO_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.c deleted file mode 100644 index 6d56f5d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.c +++ /dev/null @@ -1,227 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#include "nrf_crypto_ecdsa.h" -#include "nrf_crypto_hash.h" -#include "nrf_crypto_mem.h" - -#if NRF_CRYPTO_BACKEND_CC310_LIB -#include "cc310_lib_ecdsa.h" -#endif - -#if NRF_CRYPTO_BACKEND_MICRO_ECC -#include "micro_ecc_lib_ecdsa.h" -#endif - - -uint32_t nrf_crypto_ecdsa_signature_size_get(nrf_ecc_curve_type_t curve_type, uint32_t * p_sig_size) -{ - switch (curve_type) - { - case NRF_CRYPTO_CURVE_SECP160R1: - (*p_sig_size)= NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP160R1; - break; - - case NRF_CRYPTO_CURVE_SECP192R1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP192R1; - break; - - case NRF_CRYPTO_CURVE_SECP224R1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP224R1; - break; - - case NRF_CRYPTO_CURVE_SECP256R1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP256R1; - break; - - case NRF_CRYPTO_CURVE_SECP384R1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP384R1; - break; - - case NRF_CRYPTO_CURVE_SECP521R1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP521R1; - break; - - case NRF_CRYPTO_CURVE_SECP192K1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP192K1; - break; - - case NRF_CRYPTO_CURVE_SECP224K1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP224K1; - break; - - case NRF_CRYPTO_CURVE_SECP256K1: - (*p_sig_size) = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP256K1; - break; - - case NRF_CRYPTO_CURVE_CURVE25519: - // Not supported. Use Ed25519 instead of ECDSA. - (*p_sig_size) = 0; - return NRF_ERROR_NOT_SUPPORTED; - - default: - (*p_sig_size) = 0; - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecdsa_sizes_get(nrf_crypto_signature_info_t sig_info, - nrf_crypto_ecdsa_sizes_t * p_sizes) -{ - uint32_t ret_val; - - switch (sig_info.curve_type) - { - case NRF_CRYPTO_CURVE_SECP160R1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP160R1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP160R1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP160R1; - break; - - case NRF_CRYPTO_CURVE_SECP192R1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP192R1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP192R1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP192R1; - break; - - case NRF_CRYPTO_CURVE_SECP224R1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP224R1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP224R1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP224R1; - break; - - case NRF_CRYPTO_CURVE_SECP256R1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP256R1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP256R1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP256R1; - break; - - case NRF_CRYPTO_CURVE_SECP384R1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP384R1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP384R1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP384R1; - break; - - case NRF_CRYPTO_CURVE_SECP521R1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP521R1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP521R1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP521R1; - break; - - case NRF_CRYPTO_CURVE_SECP192K1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP192K1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP192K1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP192K1; - break; - - case NRF_CRYPTO_CURVE_SECP224K1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP224K1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP224K1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP224K1; - break; - - case NRF_CRYPTO_CURVE_SECP256K1: - p_sizes->private_key_size = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP256K1; - p_sizes->public_key_size = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP256K1; - p_sizes->signature_size = NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP256K1; - break; - - case NRF_CRYPTO_CURVE_CURVE25519: - // Not supported. Use Ed25519 (EDDSA) instead of ECDSA. - p_sizes->private_key_size = 0; - p_sizes->public_key_size = 0; - p_sizes->signature_size = 0; - return NRF_ERROR_NOT_SUPPORTED; - - default: - p_sizes->private_key_size = 0; - p_sizes->public_key_size = 0; - p_sizes->signature_size = 0; - return NRF_ERROR_NOT_SUPPORTED; - } - - ret_val = nrf_crypto_hash_size_get(sig_info.hash_type, &p_sizes->hash_size); - return ret_val; -} - - -uint32_t nrf_crypto_ecdsa_signature_allocate(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t * p_signature, - nrf_value_length_t const * p_raw_signature) -{ - uint32_t ret_val; - uint32_t sig_size; - - if (p_signature == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_ecdsa_signature_size_get(sig_info.curve_type, &sig_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_mem_allocate(sig_size, p_signature); - return ret_val; -} - - -uint32_t nrf_crypto_ecdsa_signature_free(nrf_value_length_t * p_signature) -{ - uint32_t ret_val; - - if (p_signature == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_mem_free(p_signature); - return ret_val; -} - - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.h deleted file mode 100644 index 8b27908..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_ecdsa.h +++ /dev/null @@ -1,254 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_CRYPTO_ECDSA_H__ -#define NRF_CRYPTO_ECDSA_H__ - -/** @file - * - * @defgroup nrf_crypto_ecdsa ECDSA related functions - * @{ - * @ingroup nrf_crypto - * - * @brief Provides ECDSA related functionality through nrf_crypto. - */ - -#include -#include "nrf_crypto_types.h" - -#ifdef __cplusplus -extern "C" { -#if 0 -} -#endif -#endif - - -/** @brief Macro to create an instance of a ECDSA sign context by a given name. - * - * @note This creates the value length structure used for nrf_crypto APIs and a - * buffer to hold the sign context without using dynamically allocated memory. - */ -#define NRF_CRYPTO_ECDSA_SIGN_CONTEXT_INSTANCE_CREATE(name) \ -__ALIGN(4) static uint8_t name ## _buffer[NRF_CRYPTO_ECDSA_SIGN_CONTEXT_SIZE]; \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_SIGN_CONTEXT_SIZE \ -} - - -/** @brief Macro to create an instance of a ECDSA verify context by a given name. - * - * @note This creates the value length structure used for nrf_crypto APIs and a - * buffer to hold the verify context without using dynamically allocated memory. - */ -#define NRF_CRYPTO_VERIFY_CONTEXT_INSTANCE_CREATE(name) \ -__ALIGN(4) static uint8_t name ## _buffer[NRF_CRYPTO_ECDSA_VERIFY_CONTEXT_SIZE]; \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_ECDSA_VERIFY_CONTEXT_SIZE \ -} - - -/** @brief Macro to create an instance of an ECDSA signature by a given name and type. - * - * @param[in] name Name of the ECDSA signature instance. - * @param[in] type Either SECP160R1, SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1 - * - * @note This creates the value length structure used for nrf_crypto APIs and a - * buffer to hold the signature without using dynamically allocated memory. - */ -#define NRF_CRYPTO_ECDSA_SIGNATURE_CREATE(name, type) \ -__ALIGN(4) static uint8_t name ## _buffer[STRING_CONCATENATE(NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_, type)]; \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = STRING_CONCATENATE(NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_, type) \ -} - - -/** @brief Macro to create an instance of an ECDSA signature by a given name, type and input. - * - * If the input is not of the correct size a static assert will be occur compile-time. - * - * @note This creates the value length structure used for nrf_crypto APIs and a - * buffer to hold the signature without using dynamically allocated memory. - * - * @param[in] name Name of the ECDSA signature instance. - * @param[in] type Either SECP160R1, SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1 - * @param[in] input Input must be an array of correct size according to the curve type. - * - */ -#define NRF_CRYPTO_ECDSA_SIGNATURE_INSTANCE_CREATE_FROM_INPUT(name, type, input) \ -STATIC_ASSERT(sizeof(input) == STRING_CONCATENATE(NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_, type)); \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = STRING_CONCATENATE(NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_, type) \ -} - - -/**@brief Function to get the size of a ECDSA signature given curve type. - * - * @param[in] curve_type Elliptic curve to use. - * @param[in] p_sig_size Pointer to variable to hold size of a signature. - * - * @retval NRF_SUCCESS If the he signature size was calculated. - * @retval NRF_ERROR_NULL If p_sizes was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED Selected curve was not supported. - */ -uint32_t nrf_crypto_ecdsa_signature_size_get(nrf_ecc_curve_type_t curve_type, uint32_t * p_sig_size); - - -/**@brief Function to get the sizes used for ECDSA sign/verify given curve_type - * - * @details This function will report back the private/public key, signature and hash sizes. - * - * @param[in] sig_info Elliptic curve and hash to use. - * @param[in] p_sizes Pointer to variable to hold the key, hash and signature sizes. - * - * @retval NRF_SUCCESS If the ECDSA sizes was calculated. - * @retval NRF_ERROR_NULL If p_sizes was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED Selected curve or hash was not supported. - */ -uint32_t nrf_crypto_ecdsa_sizes_get(nrf_crypto_signature_info_t sig_info, - nrf_crypto_ecdsa_sizes_t * p_sizes); - - -/**@brief Function to allocate dynamic memory for holding a signature - * - * @note The signature must be allocated before calling this - * function. - * - * @note If p_raw_signature is not NULL, then the content will be copied to the - * allocated buffer. - * - * @param[in] sig_info Curve and hash function used for representing a signature - * @param[in,out] p_signature Pointer to value-length structure to hold the signature. - * @param[in] p_raw_signature Pointer to byte representation of raw key given curve type. - * - * @retval NRF_SUCCESS Memory for the signature was successfully allocated. - * @retval NRF_ERROR_NULL Signature parameter was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecdsa_signature_allocate(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t * p_signature, - nrf_value_length_t const * p_raw_signature); - - -/**@brief Function to free dynamic memory allocated for holding a signature - * - * @param[in,out] p_signature Pointer to value-length structure that holds the - * allocated space to be freed. - * - * @retval NRF_SUCCESS Memory for the signature was successfully allocated. - * @retval NRF_ERROR_NULL Signature parameter was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecdsa_signature_free(nrf_value_length_t * p_signature); - - -/**@brief Function for signing a hash using a private key. - * - * @note Key sizes and signature must be allocated before calling this - * function. - * - * @param[in] sig_info Elliptic curve to use for signing and endianness - * of the resulting signature. - * @param[in] p_private_key Pointer to structure holding private key. - * @param[in] p_hash Pointer to structure holding hash to use for signing. - * @param[in,out] p_signature Pointer to structure holding signature. - * - * @retval NRF_SUCCESS If the signature was created successfully. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the provided key, hash or signature parameters was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected curve or hash type is not supported. - * @retval NRF_ERROR_INVALID_ADDR If the key, hash or signature paramenters aren't aligned. - * @retval NRF_ERROR_INVALID_LENGTH If the allocated length of the provided private key or hash - * is invalid or the signature is bigger than the size of the - * provided buffer. - * @retval NRF_ERROR_INVALID_DATA If any of the keys or result data is deemed invalid by the - * nrf_crypto backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_ecdsa_sign_hash(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t const * p_hash, - nrf_value_length_t * p_signature); - - -/**@brief Function for verifying a hash using a public key. - * - * @note Key sizes and signature must be allocated before calling this - * function. - * - * @param[in] sig_info Elliptic curve to use for verification and endianness - * of the signature given as input. - * @param[in] p_public_key Pointer to structure holding public key. - * @param[in] p_hash Pointer to structure holding hash to use for verification. - * @param[in,out] p_signature Pointer to structure holding signature. - * - * @retval NRF_SUCCESS If the signature was verified and is valid. - * @retval NRF_ERROR_INVALID_DATA If the signature did not match the provided hash. - * @retval NRF_ERROR_INVALID_ADDR If the key, hash or signature data aren't aligned. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. - * @retval NRF_ERROR_NULL If the provided key, hash or signature parameters was NULL. - * @retval NRF_ERROR_INVALID_LENGTH If the length of the provided public key, hash, or signature - * is invalid. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected curve or hash type is not supported. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers is invalid. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_ecdsa_verify_hash(nrf_crypto_signature_info_t sig_info, - nrf_value_length_t const * p_public_key, - nrf_value_length_t const * p_hash, - nrf_value_length_t const * p_signature); - -#ifdef __cplusplus -} -#endif - -/**@} */ - -#endif // #ifndef NRF_CRYPTO_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.c deleted file mode 100644 index 909eec0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.c +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#include "nrf_crypto_hash.h" -#include "nrf_crypto_mem.h" - -#if NRF_CRYPTO_BACKEND_CC310_LIB -#include "cc310_lib_hash.h" -#endif - -#if NRF_CRYPTO_BACKEND_MICRO_ECC && NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 -#include "nrf_crypto_sw_hash.h" -#endif - -uint32_t nrf_crypto_hash_size_get(nrf_hash_type_t hash_type, uint32_t * p_hash_size) -{ - switch (hash_type) - { - case NRF_CRYPTO_HASH_TYPE_MD5: - (*p_hash_size) = NRF_CRYPTO_HASH_SIZE_MD5; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA1: - (*p_hash_size) = NRF_CRYPTO_HASH_SIZE_SHA1; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA224: - (*p_hash_size) = NRF_CRYPTO_HASH_SIZE_SHA224; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA256: - (*p_hash_size) = NRF_CRYPTO_HASH_SIZE_SHA256; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA384: - (*p_hash_size) = NRF_CRYPTO_HASH_SIZE_SHA384; - break; - - case NRF_CRYPTO_HASH_TYPE_SHA512: - (*p_hash_size) = NRF_CRYPTO_HASH_SIZE_SHA512; - break; - - default: - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_hash_context_allocate(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context) -{ - uint32_t ret_val; - uint32_t hash_context_size = NRF_CRYPTO_HASH_CONTEXT_SIZE; - - if (p_hash_context == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_mem_allocate(hash_context_size, p_hash_context); - return ret_val; -} - - -uint32_t nrf_crypto_hash_context_free(nrf_value_length_t * p_hash_context) -{ - uint32_t ret_val; - - if (p_hash_context == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_mem_free(p_hash_context); - return ret_val; -} - - -uint32_t nrf_crypto_hash_allocate(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash, - nrf_value_length_t const * p_raw_hash) -{ - uint32_t ret_val; - uint32_t hash_size; - - if (p_hash == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_hash_size_get(hash_info.hash_type, &hash_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_mem_allocate(hash_size, p_hash); - if (ret_val == NRF_SUCCESS) - { - return ret_val; - } - - return ret_val; - -} - - -uint32_t nrf_crypto_hash_free(nrf_value_length_t * p_hash) -{ - uint32_t ret_val; - - if (p_hash == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_mem_free(p_hash); - return ret_val; -} - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.h deleted file mode 100644 index 77c6809..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_hash.h +++ /dev/null @@ -1,303 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_CRYPTO_HASH_H__ -#define NRF_CRYPTO_HASH_H__ - -/** @file - * - * @defgroup nrf_crypto_hash Cryptographic hash related functions. - * @{ - * @ingroup nrf_crypto - * - * @brief Provides cryptographic hash related functionality through nrf_crypto. - */ - -#include -#include "nrf_crypto_types.h" -#include "app_util.h" - -#ifdef __cplusplus -extern "C" { -#if 0 -} -#endif -#endif - - -/** @brief Internal macro to get the size of a given hash type - * - * @param[in] type Either MD5, SHA0, SHA1, SHA224, SHA256, SHA384 or SHA512 - */ -#define NRF_CRYPTO_HASH_SIZE(type) \ - STRING_CONCATENATE(NRF_CRYPTO_HASH_SIZE_, type) - - -/** @brief Macro to create an instance of a hash context by a given name and type. - * - * @note This creates the value length structure and - * a backing buffer without using dynamically allocated memory. - */ -#define NRF_CRYPTO_HASH_CONTEXT_CREATE(name, type) \ -__ALIGN(4) static uint8_t name ## _buffer[NRF_CRYPTO_HASH_CONTEXT_MAX_SIZE]; \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_HASH_CONTEXT_MAX_SIZE \ -} - - -/** @brief Macro to create an instance of a hash by a given name and type. - * - * @param[in] name Name of the hash instance. - * @param[in] type Either MD5, SHA0, SHA1, SHA224, SHA256, SHA384 or SHA512. - * - * @note This creates the value length structure and a backing - * buffer without using dynamically allocated memory. - */ -#define NRF_CRYPTO_HASH_CREATE(name, type) \ -__ALIGN(4) static uint8_t name ## _buffer[NRF_CRYPTO_HASH_SIZE(type)]; \ -static nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_HASH_SIZE(type) \ -} - - -/** @brief Macro to create an instance of a hash by a given name and type and - * input buffer. - * - * If the input is not of the correct size a static assert will be occur compile-time. - * - * @param[in] name Name of the hash instance. - * @param[in] type Either MD5, SHA0, SHA1, SHA224, SHA256, SHA384 or SHA512. - * @param[in] input Array used as input buffer. - * - * @note This creates the value length structure and a backing - * buffer without using dynamically allocated memory. - */ -#define NRF_CRYPTO_HASH_CREATE_FROM_ARRAY(name, type, input) \ -STATIC_ASSERT(sizeof(input) == NRF_CRYPTO_HASH_SIZE(type)) \ -static nrf_value_length_t name = \ -{ \ - .p_value = (uint8_t*) input, \ - .length = NRF_CRYPTO_HASH_SIZE(type) \ -} - - -/**@brief Function to get the size of a given hash type - * - * @param[in] hash_type Type of hash. - * @param[in,out] p_hash_size Pointer to variable to hold the hash size. Must not be NULL. - * - * @retval NRF_SUCCESS Hash function found. - * @retval NRF_ERROR_NULL p_hash_size was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED Requested hash type isn't supported. - */ -uint32_t nrf_crypto_hash_size_get(nrf_hash_type_t hash_type, uint32_t * p_hash_size); - - -/**@brief Function to dynamically allocate memory to hold a hash context used - * when calculating hash as a non-integrated step. - * - * @param[in] hash_info Hashing algorithm to create context for - * @param[in,out] p_hash_context Pointer to value-length structure to hold allocated space. - * - * @retval NRF_SUCCESS Space was successfully allocated. - */ -uint32_t nrf_crypto_hash_context_allocate(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context); - - -/**@brief Function to free dynamically allocated memory for hash context - * used when calculating hash as a non-integrated step. - * - * @note The length value of the value length structure will be set to - * zero when the memory is freed. There is no impact of running this - * function on already deallocated memory. - * - * @param[in,out] p_hash_context Pointer a to value-length structure that holds the allocated space - * to be freed. - * @retval NRF_SUCCESS Space was successfully freed. - */ -uint32_t nrf_crypto_hash_context_free(nrf_value_length_t * p_hash_context); - - -/**@brief Function to dynamically allocate memory to hold a hash value. - * - * @param[in] hash_info Structure holding info about hash algorithm to use and - * endianness for the computed hash. - * @param[in,out] p_hash Pointer to value-length structure to hold allocated space. - * @param[in] p_raw_hash Pointer to value length structure to hold raw representation - * of hash. - * - * @retval NRF_SUCCESS Space was successfully alloacted. - */ -uint32_t nrf_crypto_hash_allocate(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash, - nrf_value_length_t const * p_raw_hash); - - -/** @brief Function to free dynamically allocated memory for a hash value. - * - * @note The length value of the value length structure will be set to - * zero when the memory is freed. There is no impact of running this - * function on already deallocated memory. - * - * @param[in,out] p_hash Pointer to a value-length structure that holds the - * allocated space to be freed. - * - * @retval NRF_SUCCESS Space was successfully freed. - */ -uint32_t nrf_crypto_hash_free(nrf_value_length_t * p_hash); - - -/**@brief Function for computing a hash from arbitrary data. - * - * @note The context object is assumed to be an opaque type defined by the - * nrf_crypto backend. See @ref NRF_CRYPTO_HASH_CONTEXT_SIZE for the relevant - * nrf_crypto backend. - * - * @param[in] hash_info Structure holding info about hash algorithm to use and - * endianness for the computed hash. - * @param[in,out] p_hash_context Pointer to structure holding context information for - * the hash computation. - * - * @retval NRF_SUCCESS If the hash initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the hash context parameter was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the hash is bigger than the size of the provided buffer. - * @retval NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_hash_init(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context); - - -/**@brief Function for computing a hash or a digest from arbitrary data. - * - * @note The context object is assumed to be an opaque type defined by the - * nrf_crypto backend. See @ref NRF_CRYPTO_HASH_CONTEXT_SIZE for the relevant - * nrf_crypto backend. - * - * @param[in,out] p_hash_context Pointer to structure holding context information for - * the hash computation. - * @param[in] p_data Pointer to data to be hashed. - * @param[in] len Length of the data to be hashed. - * - * @retval NRF_SUCCESS If the hash was computed successfully. - * @retval NRF_ERROR_NULL If the hash context parameter was NULL. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the size of the hash context is invalid. - * @retval NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_hash_update(nrf_value_length_t * p_hash_context, - uint8_t const * p_data, - uint32_t len); - - -/**@brief Function for computing a hash from arbitrary data. - * - * @note The context object is assumed to be an opaque type defined by the - * nrf_crypto backend. See @ref NRF_CRYPTO_HASH_CONTEXT_SIZE for the relevant - * nrf_crypto backend. - * - * @param[in] hash_info Structure holding info about hash algorithm to use. - * @param[in,out] p_hash_context Pointer to structure holding context information for - * the hash computation. - * @param[in,out] p_hash Pointer to structure holding the calculated hash. - * - * @retval NRF_SUCCESS If the hash was computed successfully. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the any of the parameters was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the hash is bigger than the size of the provided buffer - * or the size of the hash context is invalid. - * @retval NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_hash_finalize(nrf_crypto_hash_info_t hash_info, - nrf_value_length_t * p_hash_context, - nrf_value_length_t * p_hash); - - -/**@brief Function for computing a hash from arbitrary data in a single integrated step. - * - * @param[in] hash_info Structure holding info about hash algorithm to use and endianness - * for the computed hash. - * @param[in] p_data Pointer to data to be hashed. - * @param[in] len Length of the data to be hashed. - * @param[in,out] p_hash Pointer to structure holding the calculated hash. - * - * @retval NRF_SUCCESS If the hash was computed successfully. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the hash is bigger than the size of the provided buffer - * or the size of the hash context is invalid. - * @retval NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_hash_compute(nrf_crypto_hash_info_t hash_info, - uint8_t const * p_data, - uint32_t len, - nrf_value_length_t * p_hash); - - -#ifdef __cplusplus -} -#endif - -/**@} */ - -#endif // #ifndef NRF_CRYPTO_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.c deleted file mode 100644 index d57b353..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.c +++ /dev/null @@ -1,246 +0,0 @@ -/** - * Copyright (c) 2016 - 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(NRF_CRYPTO) - -#include "nrf_crypto_keys.h" -#include "nrf_crypto_mem.h" - -#if NRF_CRYPTO_BACKEND_CC310_LIB -#include "cc310_lib_keys.h" -#endif - -#if NRF_CRYPTO_BACKEND_MICRO_ECC -#include "micro_ecc_lib_keys.h" -#endif - - -uint32_t nrf_crypto_ecc_private_key_size_get(nrf_ecc_curve_type_t curve_type, - uint32_t * p_key_size) -{ - if (p_key_size == NULL) - { - return NRF_ERROR_NULL; - } - - switch (curve_type) - { - case NRF_CRYPTO_CURVE_SECP160R1: - (*p_key_size)= NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP160R1; - break; - - case NRF_CRYPTO_CURVE_SECP192R1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP192R1; - break; - - case NRF_CRYPTO_CURVE_SECP224R1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP224R1; - break; - - case NRF_CRYPTO_CURVE_SECP256R1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP256R1; - break; - - case NRF_CRYPTO_CURVE_SECP384R1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP384R1; - break; - - case NRF_CRYPTO_CURVE_SECP521R1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP521R1; - break; - - case NRF_CRYPTO_CURVE_SECP192K1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP192K1; - break; - - case NRF_CRYPTO_CURVE_SECP224K1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP224K1; - break; - - case NRF_CRYPTO_CURVE_SECP256K1: - (*p_key_size) = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP256K1; - break; - - default: - (*p_key_size) = 0; - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - -uint32_t nrf_crypto_ecc_public_key_size_get(nrf_ecc_curve_type_t curve_type, - uint32_t * p_key_size) -{ - if (p_key_size == NULL) - { - return NRF_ERROR_NULL; - } - - switch (curve_type) - { - case NRF_CRYPTO_CURVE_SECP160R1: - (*p_key_size)= NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP160R1; - break; - - case NRF_CRYPTO_CURVE_SECP192R1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP192R1; - break; - - case NRF_CRYPTO_CURVE_SECP224R1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP224R1; - break; - - case NRF_CRYPTO_CURVE_SECP256R1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP256R1; - break; - - case NRF_CRYPTO_CURVE_SECP384R1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP384R1; - break; - - case NRF_CRYPTO_CURVE_SECP521R1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP521R1; - break; - - case NRF_CRYPTO_CURVE_SECP192K1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP192K1; - break; - - case NRF_CRYPTO_CURVE_SECP224K1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP224K1; - break; - - case NRF_CRYPTO_CURVE_SECP256K1: - (*p_key_size) = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP256K1; - break; - - default: - (*p_key_size) = 0; - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - - -uint32_t nrf_crypto_ecc_private_key_allocate(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t * p_private_key, - nrf_value_length_t const * p_raw_key) -{ - uint32_t ret_val; - uint32_t key_size; - - if (p_private_key == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_ecc_private_key_size_get(curve_info.curve_type, &key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_mem_allocate(key_size, p_private_key); - if (ret_val == NRF_SUCCESS) - { - return ret_val; - } - - return ret_val; -} - -uint32_t nrf_crypto_ecc_private_key_free(nrf_value_length_t * p_private_key) -{ - uint32_t ret_val; - - if (p_private_key == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_mem_free(p_private_key); - return ret_val; -} - -uint32_t nrf_crypto_ecc_public_key_allocate(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t * p_public_key, - nrf_value_length_t const * p_raw_key) -{ - uint32_t ret_val; - uint32_t key_size; - - if (p_public_key == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_ecc_public_key_size_get(curve_info.curve_type, &key_size); - if (ret_val != NRF_SUCCESS) - { - return ret_val; - } - - ret_val = nrf_crypto_mem_allocate(key_size, p_public_key); - if (ret_val == NRF_SUCCESS) - { - return ret_val; - } - - return ret_val; -} - - -uint32_t nrf_crypto_ecc_public_key_free(nrf_value_length_t * p_public_key) -{ - uint32_t ret_val; - - if (p_public_key == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_crypto_mem_free(p_public_key); - return ret_val; -} - - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.h deleted file mode 100644 index 3848e73..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_keys.h +++ /dev/null @@ -1,531 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_CRYPTO_KEYS_H__ -#define NRF_CRYPTO_KEYS_H__ - -/** @file - * - * @defgroup nrf_crypto_keys ECC key handling functions. - * @{ - * @ingroup nrf_crypto - * - * @brief Provides functions to allocate, free, generate and convert ECC key types. - */ - -#include -#include "nrf_crypto_types.h" - -#include "sdk_config.h" -#if NRF_CRYPTO_BACKEND_CC310_LIB -#include "cc310_lib_keys.h" -#endif - -#if NRF_CRYPTO_BACKEND_MICRO_ECC -#include "micro_ecc_lib_keys.h" -#endif - - -#ifdef __cplusplus -extern "C" { -#if 0 -} -#endif -#endif - - -/** @brief Internal macro to calculate size required to hold a ECC private key - * given curve type(domain), according to the used nrf_crypto backend. - * - * @warning The size representation by running this macro is described by the - * memory requirements of the nrf_crypto backend. This size does not - * correspond to the size required to hold a raw key. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) - -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE(type) \ - (NRF_CRYPTO_ECC_PRIVATE_KEY_MAX_SIZE) - -#else - -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE(type) \ - (STRING_CONCATENATE(NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_, type)) - -#endif // defined(NRF_CRYPTO_BACKEND_CC310_LIB) - - -/** @brief Internal macro to calculate size required to hold a ECC public key - * given curve type(domain), according to the used nrf_crypto backend. - * - * @warning The size representation by running this macro is described by the - * memory requirements of the nrf_crypto backend. This size does not - * correspond to the size required to hold a raw key. - * - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) - -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE(type) \ - (NRF_CRYPTO_ECC_PUBLIC_KEY_MAX_SIZE) - -#else - -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE(type) \ - (STRING_CONCATENATE(NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_, type)) - -#endif // defined(NRF_CRYPTO_BACKEND_CC310_LIB) - -/** @brief Macro to create an instance of an ECC private key - * given name and type. - * - * @note This creates the value length structure used for Nordic APIs with a buffer - * to hold the actual ECC private key data. The ECC private key type is opaque and - * the size and format of the data is dependant on the nrf_crypto backend. - * - * @note To convert this key to a raw representation required for external APIS, please - * use the function @ref nrf_crypto_ecc_public_key_to_raw. - * This may not be supported by all nrf_crypto backends. - * - * @param[in] name Name of the ECC private key instance. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#define NRF_CRYPTO_ECC_PRIVATE_KEY_CREATE(name, type) \ -__ALIGN(4) static uint8_t \ - name ## _buffer[NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE(type)]; \ -nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE(type) \ -} - - -/** @brief Macro to create an instance of an ECC public key by a given name and type. - * - * @note This creates the value length structure used for Nordic APIs with a buffer - * to hold the actual ECC public key data. The ECC public key type is opaque and - * the size and format of the data is dependant on the nrf_crypto backend. - * - * @note To convert this key to a raw representation required for external APIS, please - * use the function @ref nrf_crypto_ecc_public_key_to_raw. - * This may not be supported by all nrf_crypto backends. - * - * @param[in] name Name of the ECC PUBLIC key instance. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#define NRF_CRYPTO_ECC_PUBLIC_KEY_CREATE(name, type) \ -__ALIGN(4) static uint8_t \ - name ## _buffer[NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE(type)]; \ -nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE(type) \ -} - - -/** @brief Internal macro to calculate size required to hold a ECC private key - * in raw format given curve type(domain), according to the used - * nrf_crypto backend. - * - * @warning The size representation by running this macro is described by the - * memory requirements of the nrf_crypto backend. This size does not - * correspond to the size required to hold a raw key. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ - -#define NRF_CRYPTO_ECC_PRIVATE_RAW_KEY_SIZE(type) \ - (STRING_CONCATENATE(NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_, type)) - - -/** @brief Internal macro to calculate size required to hold a ECC public key - * in raw representatio given curve type(domain), - * according to the used nrf_crypto backend. - * - * @warning The size representation by running this macro is described by the - * memory requirements of the nrf_crypto backend. This size does not - * correspond to the size required to hold a raw key. - * - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#define NRF_CRYPTO_ECC_PUBLIC_RAW_KEY_SIZE(type) \ - (STRING_CONCATENATE(NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_, type)) - - -/** @brief Macro to create an instance of a raw representation of an ECC private key - * given name and type. - * - * @note This creates the value length structure used for external APIs that require - * an aligned version of a private key where curve-domain and endianness is - * described elsewhere. - * - * @warning The raw private key can not be used directly in the nrf_crypto APIs. - * - * @warning The output of this macro is subject to change. - * - * @param[in] name Name of the ECC private key instance. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#define NRF_CRYPTO_ECC_PRIVATE_KEY_RAW_CREATE(name, type) \ -__ALIGN(4) static uint8_t \ - name ## _buffer[NRF_CRYPTO_ECC_PRIVATE_RAW_KEY_SIZE(type)]; \ -nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_ECC_PRIVATE_RAW_KEY_SIZE(type) \ -} - - -/** @brief Macro to create a value length structure to represent a raw ECC private key - * by a given name, type and an uint8_t array buffer to hold the raw private key. - * If the input is not of the correct size a static assert will be occur compile-time. - * - * - * @note This creates the value length structure used for external APIs that require - * an aligned version of a private key where curve-domain and endianness is - * described elsewhere. - * - * @note The value length pair generated by running this macro can be used as input in the - * function @ref nrf_crypto_ecc_private_key_to_raw to hold a raw private key type. - * - * @warning There is no API function to convert private key from a raw representation in the - * nrf_crypto CryptoCell (cc310) backend. Running this macro while nrf_crypto - * CryptoCell backend is enabled will cause a static assertion. - * - * @param[in] name Name of the ECC private key instance. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - * @param[in] input Array holding the private key. - */ -#define NRF_CRYPTO_ECC_PRIVATE_KEY_RAW_CREATE_FROM_ARRAY(name, type, input) \ -STATIC_ASSERT(sizeof(input) == NRF_CRYPTO_ECC_PRIVATE_RAW_KEY_SIZE(type)) \ -static nrf_value_length_t name = \ -{ \ - .p_value = (uint8_t*)input, \ - .length = NRF_CRYPTO_ECC_PRIVATE_RAW_KEY_SIZE(type) \ -} - -/** @brief Macro to create an instance of a araw representation of an ECC public key - * given name and type. - * - * @note This creates the value length structure used for external APIs that require - * an aligned version of a public key where curve-domain and endianness is - * described elsewhere. - * - * @note The value length pair generated by running this macro can be used as input in the - * function @ref nrf_crypto_ecc_public_key_to_raw to hold a raw private key type. - * - * @param[in] name Name of the ECC PUBLIC key instance. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - */ -#define NRF_CRYPTO_ECC_PUBLIC_KEY_RAW_CREATE(name, type) \ -__ALIGN(4) static uint8_t \ - name ## _buffer[NRF_CRYPTO_ECC_PUBLIC_RAW_KEY_SIZE(type)]; \ -nrf_value_length_t name = \ -{ \ - .p_value = name ## _buffer, \ - .length = NRF_CRYPTO_ECC_PUBLIC_RAW_KEY_SIZE(type) \ -} - - -/** @brief Macro to create an instance of an ECC public key by a given - * name, type and array input. - * If the input is not of the correct size a static assert will be occur compile-time. - * - * - * @note This creates the value length structure used for external APIs that require - * an aligned version of a private key where curve-domain and endianness is - * described elsewhere. - * - * @note The value length pair generated by running this macro can be used as input in the - * function @ref nrf_crypto_ecc_private_key_to_raw to hold a raw public key type. - * - * @param[in] name Name of the ECC PUBLIC key instance. - * @param[in] type Curve type. Either SECP192R1, SECP224R1, SECP256R1, SECP384R1, - * SECP521R1, SECP192K1, SECP224K1, or SECP256K1. - * @param[in] input Array of data used as the buffer. - */ -#define NRF_CRYPTO_ECC_PUBLIC_KEY_RAW_CREATE_FROM_ARRAY(name, type, input) \ -STATIC_ASSERT(sizeof(input) == NRF_CRYPTO_ECC_PUBLIC_RAW_KEY_SIZE(type)); \ -static nrf_value_length_t name = \ -{ \ - .p_value = (uint8_t*)input, \ - .length = NRF_CRYPTO_ECC_PUBLIC_RAW_KEY_SIZE(type) \ -} - -/**@brief Function to get the private key size given curve_type. - * - * @param[in] curve_type Curve type to get private key size for. - * @param[in,out] p_key_size Pointer to variable to hold the private key size. - * - * @retval NRF_SUCCESS If the private key size was successfully found. - * @retval NRF_ERROR_NULL If the p_key_size was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED If the curve type was not supported. - */ -uint32_t nrf_crypto_ecc_private_key_size_get(nrf_ecc_curve_type_t curve_type, - uint32_t * p_key_size); - - -/**@brief Function to get the public key size given curve_type. - * - * @param[in] curve_type Curve type to get public key size for. - * @param[in,out] p_key_size Pointer to variable to hold the public key size. - * - * @retval NRF_SUCCESS If the public key size was successfully found. - * @retval NRF_ERROR_NULL If the p_key_size was NULL. - * @retval NRF_ERROR_NOT_SUPPORTED If the curve type was not supported. - */ -uint32_t nrf_crypto_ecc_public_key_size_get(nrf_ecc_curve_type_t curve_type, - uint32_t * p_key_size); - - -/**@brief Function to allocate dynamic memory for holding a ECC private key. - * - * @note Memory dynamically allocated by calling this function will be aligned to a - * uint32_t address. - * - * @param[in] curve_info Curve type used for ECC private key. - * @param[in,out] p_private_key Pointer to a value length structure to hold a private key. - * @param[in] p_raw_key Pointer to value length structure holding raw - * representation of a private key taken as input. - * If this is set to NULL, no initialization will take place. - * - * @retval NRF_SUCCESS If memory for the private key was successfully allocated. - * @retval NRF_ERROR_NULL If p_private_key was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecc_private_key_allocate(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t * p_private_key, - nrf_value_length_t const * p_raw_key); - - -/**@brief Function to free allocated memory for ECC private key. - * - * @note Memory dynamically allocated by calling this function will be aligned to a - * uint32_t address. - * - * @param[in] p_private_key Pointer to structure holdign - * - - * @retval NRF_SUCCESS if memory for the private key was successfully freed. - * @retval NRF_ERROR_NULL If p_private_key was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecc_private_key_free(nrf_value_length_t * p_private_key); - - -/**@brief Function to allocate dynamic memory for holdign a ECC public key. - * - * @param[in] curve_info Curve type used for ECC public key. - * @param[in,out] p_public_key Pointer to a value length structure to hold a public key. - * @param[in] p_raw_key Pointer to value length structure holding raw - * representation of a public key taken as input. - * If this is set to NULL, no initialization will take place. - * - * @retval NRF_SUCCESS If memory for the public key was successfully allocated. - * @retval NRF_ERROR_NULL If p_public_key was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecc_public_key_allocate(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t * p_public_key, - nrf_value_length_t const * p_raw_key); - - -/**@brief Function to free allocated memory for ECC private key. - * - * @param[in] p_public_key Pointer to value length structure holding public key to free. - * - * @retval NRF_SUCCESS If memory for the public key was successfully freed. - * @retval NRF_ERROR_NULL If p_public_key was NULL. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_ecc_public_key_free(nrf_value_length_t * p_public_key); - - -/**@brief Function to generate ECC private public keypair given curve type. - * - * @note This function will not allocate any memory. Private and public keys given as - * input must be pointing to previously allocated memory. - * - * @note This function needs RNG functionality. See @ref NRF_CRYPTO_BACKEND_MICRO_ECC_RNG for the - * nrf_crypto backends that require external source of RNG data. - * - * @param[in] curve_info Curve type used for key pair generation. - * @param[in,out] p_private_key Pointer to a value length structure to hold a private key. - * @param[in,out] p_public_key Pointer to a value length structure to hold a public key. - * - * @retval NRF_SUCCESS The ECC key pair was generated successfully. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the any of the parameters was NULL. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the key pair size is different to the provided buffers. - * @retval NRF_ERROR_NOT_SUPPORTED If the key pair generation is not supported for the given curve type. - * @retval NRF_ERROR_INTERNAL Unexpected error. Possibly because @ref NRF_CRYPTO_BACKEND_MICRO_ECC_RNG is 0. - */ -uint32_t nrf_crypto_ecc_key_pair_generate(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t * p_private_key, - nrf_value_length_t * p_public_key); - - -/**@brief Function to calculate ECC public key given a ECC private key as input - * - * @note This function will not allocate any memory. The public key given as input - * must be pointing to previously allocated memory. - * - * @param[in] curve_info Curve type used for public key. - * @param[in] p_private_key Pointer to a value length structure holding a private key. - * @param[in, out] p_public_key Pointer to a value length structure to hold the calculated - * key. - * - * @retval NRF_SUCCESS If the public key was calculated successfully. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the any of the parameters was NULL. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the key pair size is different to the provided buffers. - * @retval NRF_ERROR_NOT_SUPPORTED If the public key calculation is not supported. - */ -uint32_t nrf_crypto_ecc_public_key_calculate(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t * p_public_key); - - -/**@brief Function to convert ECC private key to a raw representation for use in external APIs. - * - * @note This function will not allocate any memory. The raw public key given as output parameter - * must be pointing to previously allocated memory. - * - * @note The format of the data for the converted ECC public key must be aligned and will - * use the least amount of space required to represent the key. - * - * @warning The nrf_crypto backend may not support converting a private key to a raw representation. - * This is subject to change. - * - * @param[in] curve_info Info of the curve type (domain) and the endianness of the - * resulting raw key. - * @param[in] p_private_key Value length structure holding a private key to be - * converted to a raw representation. - * @param[in,out] p_private_key_raw Value length structure to hold the converted private key. - * - * @retval NRF_SUCCESS If the private key was converted to raw representation. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the any of the parameters was NULL. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the size of the public key and result is invalid. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected curve is not supported. - * @retval NRF_ERROR_INVALID_DATA If the private key was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_ecc_private_key_to_raw(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_private_key, - nrf_value_length_t * p_private_key_raw); - - -/**@brief Function to convert ECC public key to a raw representation for use in external APIs. - * - * @note This function will not allocate any memory. The raw public key given as output parameter - * must be pointing to previously allocated memory. - * The format of the data for the converted ECC public key must be aligned and will - * use the least amount of space required to represent the key. - * - * @param[in] curve_info Info of the curve type (domain) and the endianness of - * the resulting raw key. - * @param[in] p_public_key Value length structure holding a public key to be - * converted to a raw representation. - * @param[in,out] p_public_key_raw Value length structure to hold the converted public key. - * - * @retval NRF_SUCCESS If the public key was converted to raw representation. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the any of the parameters was NULL. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_INVALID_LENGTH If the size of the public key and result is invalid. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected curve is not supported. - * @retval NRF_ERROR_INVALID_DATA If the public key was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_ecc_public_key_to_raw(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t const * p_public_key, - nrf_value_length_t * p_public_key_raw); - - -/**@brief Function to convert ECC public key from a raw representation for use in nrf_crypto API. - * - * @note This function will not allocate any memory. The public key given as output parameter - * must be pointing to previously allocated memory. - * The format of the data for the converted ECC public key must be aligned and will - * use the least amount of space required to represent the key. - * - * @param[in] curve_info Info of the curve type (domain) and the endianness of the - * raw public key given as input. - * @param[in] p_public_key_raw Value length structure to hold the converted public key. - * @param[in,out] p_public_key Value length structure holding a private key to be converted to a raw representation. - * - * @retval NRF_SUCCESS If the public key was converted fron raw representation. - * @retval NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was - * uninitialized. - * @retval NRF_ERROR_NULL If the any of the parameters was NULL. - * @retval NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. - * @retval NRF_ERROR_NOT_SUPPORTED If the selected curve is not supported. - * @retval NRF_ERROR_INVALID_LENGTH If the size of the public key and result is invalid. - * @retval NRF_ERROR_INVALID_DATA If the public key was deemed invalid by the nrf_crypto - * backend. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_ecc_public_key_from_raw(nrf_crypto_curve_info_t curve_info, - nrf_value_length_t * p_public_key_raw, - nrf_value_length_t * p_public_key); -#ifdef __cplusplus -} -#endif - - /**@} */ - -#endif // NRF_CRYPTO_KEYS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_types.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_types.h deleted file mode 100644 index 4e71a8a..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_types.h +++ /dev/null @@ -1,252 +0,0 @@ -/** - * Copyright (c) 2016 - 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 NRF_CRYPTO_TYPES_H__ -#define NRF_CRYPTO_TYPES_H__ - -/** @file - * - * @defgroup nrf_crypto_types Commonly shared types - * @{ - * @ingroup nrf_crypto - * - * @brief Provides definitions of commonly shared cryptographic types like hashes and curves used in the nrf_crypto APIs. - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Generic type to hold pointer to value and length - */ -typedef struct -{ - uint8_t * p_value; - uint32_t length; - -} nrf_value_length_t; - - -/**@defgroup NRF_CRYPTO_CURVES Cryptographic curves - * @brief Cryptographic curves that are available to the application. - * @{ */ -typedef enum -{ - NRF_CRYPTO_CURVE_INVALID = 0x00, //!< Invalid curve. - NRF_CRYPTO_CURVE_SECP160R1 = 0x01, //!< NIST 160-bit. - NRF_CRYPTO_CURVE_SECP192R1 = 0x02, //!< NIST 192-bit. - NRF_CRYPTO_CURVE_SECP224R1 = 0x03, //!< NIST 224-bit. - NRF_CRYPTO_CURVE_SECP256R1 = 0x04, //!< NIST 256-bit. - NRF_CRYPTO_CURVE_SECP384R1 = 0x05, //!< NIST 384-bit. - NRF_CRYPTO_CURVE_SECP521R1 = 0x06, //!< NIST 521-bit. - NRF_CRYPTO_CURVE_SECP192K1 = 0x07, //!< Koblitz 192-bit. - NRF_CRYPTO_CURVE_SECP224K1 = 0x08, //!< Koblitz 224-bit. - NRF_CRYPTO_CURVE_SECP256K1 = 0x09, //!< Koblitz 256-bit. - NRF_CRYPTO_CURVE_CURVE25519 = 0x0A, //!< Curve 25519. -} nrf_ecc_curve_type_t; -/** @} */ - -/** @brief Hashing algorithms that are available through nrf_crypto. - * - * @note All cryptographic hash types may not be available through the nrf_crypto backend. - */ -typedef enum -{ - NRF_CRYPTO_HASH_TYPE_INVALID = 0x00, //!< Invalid hashing algorithm. - NRF_CRYPTO_HASH_TYPE_MD5 = 0x01, //!< MD5. - NRF_CRYPTO_HASH_TYPE_SHA1 = 0x03, //!< SHA-1. - NRF_CRYPTO_HASH_TYPE_SHA224 = 0x04, //!< SHA-224 (SHA-2). - NRF_CRYPTO_HASH_TYPE_SHA256 = 0x05, //!< SHA-256 (SHA-2). - NRF_CRYPTO_HASH_TYPE_SHA384 = 0x06, //!< SHA-384 (SHA-2). - NRF_CRYPTO_HASH_TYPE_SHA512 = 0x07, //!< SHA-512 (SHA-2). - -} nrf_hash_type_t; - -/**@defgroup NRF_CRYPTO_HASH_SIZES Cryptographic hash sizes - * @brief Sizes of different cryptographic hashes. - * @{ */ -#define NRF_CRYPTO_HASH_SIZE_MD5 (20) -#define NRF_CRYPTO_HASH_SIZE_SHA1 (20) -#define NRF_CRYPTO_HASH_SIZE_SHA224 (28) -#define NRF_CRYPTO_HASH_SIZE_SHA256 (32) -#define NRF_CRYPTO_HASH_SIZE_SHA384 (48) -#define NRF_CRYPTO_HASH_SIZE_SHA512 (64) -/** @} */ - -/**@defgroup NRF_CRYPTO_ECDSA_SIGNATURE_SIZES ECDSA signature sizes. - * @brief Sizes of different ECDSA signatures. - * @{ */ -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP160R1 (40) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP192R1 (48) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP224R1 (56) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP256R1 (64) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP384R1 (96) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP521R1 (132) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP192K1 (48) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP224K1 (56) -#define NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP256K1 (64) -#define NRF_CRYPTO_ECDSA_SIGNATURE_MAX_SIZE NRF_CRYPTO_ECDSA_SIGNATURE_SIZE_SECP521R1 -/** @} */ - - -/**@defgroup NRF_CRYPTO_ECC_PRIVATE_KEY_SIZES ECC private key sizes. - * @brief Sizes of different elliptical curve cryptography private keys. - * @{ */ -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP160R1 (20) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP192R1 (24) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP224R1 (28) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP256R1 (32) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP384R1 (48) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP521R1 (66) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP192K1 (24) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP224K1 (28) -#define NRF_CRYPTO_ECC_PRIVATE_KEY_SIZE_SECP256K1 (32) -/** @} */ - -/**@defgroup NRF_CRYPTO_ECC_PUBLIC_KEY_SIZES ECC public key sizes. - * @brief Sizes of different elliptical curve cryptographic public keys. - * @{ */ -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP160R1 (40) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP192R1 (48) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP224R1 (56) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP256R1 (64) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP384R1 (96) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP521R1 (132) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP192K1 (48) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP224K1 (56) -#define NRF_CRYPTO_ECC_PUBLIC_KEY_SIZE_SECP256K1 (64) -/** @} */ - -/**@defgroup NRF_CRYPTO_ECDH_SHARED_SECRET_SIZES ECDH shared secret sizes. - * @brief Sizes of ECDH shared secret values. - * @{ */ -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP160R1 (20) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP192R1 (24) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP224R1 (28) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP256R1 (32) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP384R1 (48) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP521R1 (66) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP192K1 (24) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP224K1 (28) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP256K1 (32) -#define NRF_CRYPTO_ECDH_SHARED_SECRET_MAX_SIZE NRF_CRYPTO_ECDH_SHARED_SECRET_SIZE_SECP521R1 -/** @} */ - - - - -/** @brief Type definition for endianness. - */ -typedef enum -{ - NRF_CRYPTO_ENDIAN_LE = 0x00, - NRF_CRYPTO_ENDIAN_BE = 0x01 - -} nrf_endian_type_t; - - -/** @brief Combined structure containing curve type, hash type and endian type. - */ -typedef struct -{ - nrf_ecc_curve_type_t curve_type; - nrf_hash_type_t hash_type; - nrf_endian_type_t endian_type; - -} nrf_crypto_signature_info_t; - - -/** @brief Combined structure containin curve type and endian type. - */ -typedef struct -{ - nrf_ecc_curve_type_t curve_type; - nrf_endian_type_t endian_type; - -} nrf_crypto_curve_info_t; - - -/** @brief Combined structure containing hash type and endian type. - */ -typedef struct -{ - nrf_hash_type_t hash_type; - nrf_endian_type_t endian_type; - -} nrf_crypto_hash_info_t; - - -/**@brief Combined to hold sizes used by ECDSA sign/verify. - */ -typedef struct -{ - uint32_t public_key_size; //!< Public key size. - uint32_t private_key_size; //!< Private key size. - uint32_t signature_size; //!< Signature size. - uint32_t hash_size; //!< Hash size. -} nrf_crypto_ecdsa_sizes_t; - - -/**@brief Structure holding hash size according to algorithm. - */ -typedef struct -{ - uint32_t hash_size; -} nrf_crypto_hash_sizes_t; - - -/**@brief Macro to declare a cryptographic curve used in - * BLE Secure Connections (LESC). - */ -#define BLE_LESC_CURVE_TYPE_INFO \ -(nrf_crypto_curve_info_t) \ -{ \ - .curve_type = NRF_CRYPTO_CURVE_SECP256R1, \ - .endian_type = NRF_CRYPTO_ENDIAN_LE \ -} - -#ifdef __cplusplus -} -#endif - -/**@} */ - -#endif // #ifndef NRF_CRYPTO_TYPES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_adc.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_adc.c deleted file mode 100644 index 689af6b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_adc.c +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2016 - 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 "app_error.h" -#include "es_battery_voltage.h" -#include "nrf_drv_adc.h" - -static uint16_t m_batt_lvl_in_milli_volts; - -#define ADC_REF_VOLTAGE_IN_MILLIVOLTS 600 // /< Reference voltage (in milli volts) used by ADC while doing conversion. -#define DIODE_FWD_VOLT_DROP_MILLIVOLTS 270 // /< Typical forward voltage drop of the diode (Part no: SD103ATW-7-F) that is connected in series with the voltage supply. This is the voltage drop when the forward current is 1mA. Source: Data sheet of 'SURFACE MOUNT SCHOTTKY BARRIER DIODE ARRAY' available at www.diodes.com. -#define ADC_RES_10BIT 1024 // /< Maximum digital value for 10-bit ADC conversion. -#define ADC_PRE_SCALING_COMPENSATION 6 // /< The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage. -#define ADC_REF_VBG_VOLTAGE_IN_MILLIVOLTS 1200 // /< Value in millivolts for voltage used as reference in ADC conversion on NRF51. -#define ADC_INPUT_PRESCALER 3 // /< Input prescaler for ADC convestion on NRF51. - -static nrf_adc_value_t adc_buf[1]; -#define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE) \ - ((((ADC_VALUE) *ADC_REF_VBG_VOLTAGE_IN_MILLIVOLTS) / ADC_RES_10BIT) * ADC_INPUT_PRESCALER) - -static void adc_event_handler(nrf_drv_adc_evt_t const * p_event) -{ - if (p_event->type == NRF_DRV_ADC_EVT_DONE) - { - nrf_adc_value_t adc_result; - ret_code_t err_code; - - adc_result = p_event->data.done.p_buffer[0]; - - err_code = nrf_drv_adc_buffer_convert(p_event->data.done.p_buffer, 1); - APP_ERROR_CHECK(err_code); - - m_batt_lvl_in_milli_volts = - ADC_RESULT_IN_MILLI_VOLTS(adc_result) + DIODE_FWD_VOLT_DROP_MILLIVOLTS; - } -} - - -void es_battery_voltage_init(void) -{ - ret_code_t err_code = nrf_drv_adc_init(NULL, adc_event_handler); - - APP_ERROR_CHECK(err_code); - - static nrf_drv_adc_channel_t channel = - NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_DISABLED); - channel.config.config.input = (uint32_t)NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD; - nrf_drv_adc_channel_enable(&channel); - - err_code = nrf_drv_adc_buffer_convert(&adc_buf[0], 1); - APP_ERROR_CHECK(err_code); - nrf_drv_adc_sample(); -} - - -void es_battery_voltage_get(uint16_t * p_vbatt) -{ - *p_vbatt = m_batt_lvl_in_milli_volts; - if (!nrf_adc_is_busy()) - { - nrf_drv_adc_sample(); - } -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.c deleted file mode 100644 index dcda9ed..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.c +++ /dev/null @@ -1,530 +0,0 @@ -/** - * Copyright (c) 2016 - 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 -#include -#include "es_security.h" -#include "aes.h" -#include "app_timer.h" -#include "cifra_eax_aes.h" -#include "es_flash.h" -#include "es_stopwatch.h" -#include "fds.h" -#include "modes.h" -#include "occ_curve25519.h" -#include "occ_hmac_sha256.h" - -#define TK_ROLLOVER 0x10000 - -#define NONCE_SIZE (6) -#define TAG_SIZE (2) -#define SALT_SIZE (2) -#define TLM_DATA_SIZE (ES_TLM_LENGTH - 2) -#define EIK_SIZE (ESCS_AES_KEY_SIZE) - -/**@brief Timing structure. */ -typedef struct -{ - uint32_t time_counter; - uint8_t k_scaler; -} es_security_timing_t; - -/**@brief Security slot structure. */ -typedef struct -{ - nrf_ecb_hal_data_t aes_ecb_ik; - nrf_ecb_hal_data_t aes_ecb_tk; - uint8_t eid[ES_EID_ID_LENGTH]; - es_security_timing_t timing; - bool is_occupied; -} es_security_slot_t; - -/**@brief Key pair structure. */ -typedef struct -{ - uint8_t private[ESCS_ECDH_KEY_SIZE]; - uint8_t public[ESCS_ECDH_KEY_SIZE]; -} ecdh_key_pair_t; - -/**@brief ECDH structure. */ -typedef struct -{ - ecdh_key_pair_t ecdh_key_pair; -} es_security_ecdh_t; - -static nrf_ecb_hal_data_t m_aes_ecb_lk; -static es_security_slot_t m_security_slot[APP_MAX_EID_SLOTS]; -static es_security_ecdh_t m_ecdh; -static es_security_msg_cb_t m_security_callback; -static es_stopwatch_id_t m_seconds_passed_sw_id; - -/**@brief Generates a EID with the Temporary Key*/ -static void eid_generate(uint8_t slot_no) -{ - memset(m_security_slot[slot_no].aes_ecb_tk.cleartext, 0, ESCS_AES_KEY_SIZE); - m_security_slot[slot_no].aes_ecb_tk.cleartext[11] = m_security_slot[slot_no].timing.k_scaler; - - uint32_t k_bits_cleared_time = - (m_security_slot[slot_no].timing.time_counter >> m_security_slot[slot_no].timing.k_scaler) - << m_security_slot[slot_no].timing.k_scaler; - - m_security_slot[slot_no].aes_ecb_tk.cleartext[12] = - (uint8_t)((k_bits_cleared_time >> 24) & 0xff); - m_security_slot[slot_no].aes_ecb_tk.cleartext[13] = - (uint8_t)((k_bits_cleared_time >> 16) & 0xff); - m_security_slot[slot_no].aes_ecb_tk.cleartext[14] = (uint8_t)((k_bits_cleared_time >> 8) & 0xff); - m_security_slot[slot_no].aes_ecb_tk.cleartext[15] = (uint8_t)((k_bits_cleared_time) & 0xff); - - AES128_ECB_encrypt(m_security_slot[slot_no].aes_ecb_tk.cleartext, - m_security_slot[slot_no].aes_ecb_tk.key, - m_security_slot[slot_no].aes_ecb_tk.ciphertext); - - memcpy(m_security_slot[slot_no].eid, - m_security_slot[slot_no].aes_ecb_tk.ciphertext, - ES_EID_ID_LENGTH); - - m_security_callback(slot_no, ES_SECURITY_MSG_EID); -} - - -/**@brief Generates a temporary key with the Identity key. */ -static void temp_key_generate(uint8_t slot_no) -{ - memset(m_security_slot[slot_no].aes_ecb_ik.cleartext, 0, ESCS_AES_KEY_SIZE); - m_security_slot[slot_no].aes_ecb_ik.cleartext[11] = 0xFF; - m_security_slot[slot_no].aes_ecb_ik.cleartext[14] = - (uint8_t)((m_security_slot[slot_no].timing.time_counter >> 24) & 0xff); - m_security_slot[slot_no].aes_ecb_ik.cleartext[15] = - (uint8_t)((m_security_slot[slot_no].timing.time_counter >> 16) & 0xff); - - AES128_ECB_encrypt(m_security_slot[slot_no].aes_ecb_ik.cleartext, - m_security_slot[slot_no].aes_ecb_ik.key, - m_security_slot[slot_no].aes_ecb_ik.ciphertext); - - memcpy(m_security_slot[slot_no].aes_ecb_tk.key, - m_security_slot[slot_no].aes_ecb_ik.ciphertext, - ESCS_AES_KEY_SIZE); -} - - -static void check_rollovers_and_update_eid(uint8_t slot_no) -{ - if (m_security_slot[slot_no].timing.time_counter % TK_ROLLOVER == 0) - { - temp_key_generate(slot_no); - } - /*lint -save -e573 */ - if ((m_security_slot[slot_no].timing.time_counter % - (2 << (m_security_slot[slot_no].timing.k_scaler - 1))) == 0) - { - eid_generate(slot_no); - } - /*lint -restore */ -} - - -/**@brief Initialize lock code from flash. If it does not exist, copy from APP_CONFIG_LOCK_CODE. - */ -static void lock_code_init(uint8_t * p_lock_buff) -{ - ret_code_t err_code; - - err_code = es_flash_access_lock_key(p_lock_buff, ES_FLASH_ACCESS_READ); - FLASH_ACCES_ERROR_CHECK_ALLOW_NOT_FOUND(err_code); - - // If no lock keys exist, then generate one and copy it to buffer. - if (err_code == FDS_ERR_NOT_FOUND) - { - uint8_t lock_code[16] = APP_CONFIG_LOCK_CODE; - - memcpy(p_lock_buff, lock_code, sizeof(lock_code)); - - err_code = es_flash_access_lock_key(p_lock_buff, ES_FLASH_ACCESS_WRITE); - APP_ERROR_CHECK(err_code); - } -} - - -/**@brief Generates a the private/public ECDH key pair. - * - * @param[out] p_priv_buffer buffer of size 32 bytes to hold the private key. - * @param[out] p_pub_buffer buffer of size 32 bytes to hold the public key. - */ -static void es_beacon_ecdh_pair_generate(uint8_t * p_priv_buffer, uint8_t * p_pub_buffer) -{ - // Generate random beacon private key. - uint8_t pool_size; - uint8_t bytes_available; - - (void)sd_rand_application_pool_capacity_get(&pool_size); - (void)sd_rand_application_bytes_available_get(&bytes_available); - - while (bytes_available < pool_size) - { - // wait for SD to acquire enough RNs. - (void)sd_rand_application_bytes_available_get(&bytes_available); - } - - (void)sd_rand_application_vector_get(p_priv_buffer, pool_size); - - if (pool_size < ESCS_ECDH_KEY_SIZE) - { - (void)sd_rand_application_bytes_available_get(&bytes_available); - - while (bytes_available < (ESCS_ECDH_KEY_SIZE - pool_size)) - { - // Wait for SD to acquire enough RNs. - (void)sd_rand_application_bytes_available_get(&bytes_available); - } - (void)sd_rand_application_vector_get(p_priv_buffer + pool_size, - ESCS_ECDH_KEY_SIZE - pool_size); - } - - // Create beacon public 32-byte ECDH key from private 32-byte ECDH key. - occ_curve25519_scalarmult_base(p_pub_buffer, p_priv_buffer); -} - - -void es_security_update_time(void) -{ - static uint32_t timer_persist; - uint32_t second_since_last_invocation = es_stopwatch_check(m_seconds_passed_sw_id); - - if (second_since_last_invocation > 0) - { - for (uint32_t i = 0; i < APP_MAX_EID_SLOTS; ++i) - { - if (m_security_slot[i].is_occupied) - { - m_security_slot[i].timing.time_counter += second_since_last_invocation; - check_rollovers_and_update_eid(i); - } - } - - // Every 24 hr, write the new EID timer to flash. - timer_persist += second_since_last_invocation; - const uint32_t TWENTY_FOUR_HOURS = 60 * 60 * 24; - if (timer_persist >= TWENTY_FOUR_HOURS) - { - for (uint32_t i = 0; i < APP_MAX_EID_SLOTS; ++i) - { - if (m_security_slot[i].is_occupied) - { - m_security_callback(i, ES_SECURITY_MSG_STORE_TIME); - } - } - timer_persist = 0; - } - } -} - - -void es_security_eid_slots_restore(uint8_t slot_no, - uint8_t k_scaler, - uint32_t time_counter, - const uint8_t * p_ik) -{ - m_security_slot[slot_no].timing.k_scaler = k_scaler; - m_security_slot[slot_no].timing.time_counter = time_counter; - memcpy(m_security_slot[slot_no].aes_ecb_ik.key, p_ik, ESCS_AES_KEY_SIZE); - m_security_slot[slot_no].is_occupied = true; - m_security_callback(slot_no, ES_SECURITY_MSG_IK); - temp_key_generate(slot_no); - eid_generate(slot_no); -} - - -ret_code_t es_security_lock_code_update(uint8_t * p_ecrypted_key) -{ - uint8_t temp_buff[ESCS_AES_KEY_SIZE] = {0}; - - AES128_ECB_decrypt(p_ecrypted_key, m_aes_ecb_lk.key, temp_buff); - - memcpy(m_aes_ecb_lk.key, temp_buff, ESCS_AES_KEY_SIZE); - return es_flash_access_lock_key(m_aes_ecb_lk.key, ES_FLASH_ACCESS_WRITE); -} - - -void es_security_unlock_prepare(uint8_t * p_challenge) -{ - memcpy(m_aes_ecb_lk.cleartext, p_challenge, ESCS_AES_KEY_SIZE); - AES128_ECB_encrypt(m_aes_ecb_lk.cleartext, m_aes_ecb_lk.key, m_aes_ecb_lk.ciphertext); -} - - -void es_security_unlock_verify(uint8_t * p_unlock_token) -{ - if (memcmp(p_unlock_token, m_aes_ecb_lk.ciphertext, ESCS_AES_KEY_SIZE) == 0) - { - m_security_callback(0, ES_SECURITY_MSG_UNLOCKED); - } -} - - -ret_code_t es_security_random_challenge_generate(uint8_t * p_rand_chlg_buff) -{ - return sd_rand_application_vector_get(p_rand_chlg_buff, ESCS_AES_KEY_SIZE); -} - - -void es_security_shared_ik_receive(uint8_t slot_no, uint8_t * p_encrypted_ik, uint8_t scaler_k) -{ - m_security_slot[slot_no].is_occupied = true; - m_security_slot[slot_no].timing.k_scaler = scaler_k; - m_security_slot[slot_no].timing.time_counter = APP_CONFIG_TIMING_INIT_VALUE; - - AES128_ECB_decrypt(p_encrypted_ik, m_aes_ecb_lk.key, m_security_slot[slot_no].aes_ecb_ik.key); - - temp_key_generate(slot_no); - eid_generate(slot_no); - - m_security_callback(slot_no, ES_SECURITY_MSG_IK); -} - - -void es_security_client_pub_ecdh_receive(uint8_t slot_no, uint8_t * p_pub_ecdh, uint8_t scaler_k) -{ - static uint8_t attempt_counter = 0; - - m_security_slot[slot_no].is_occupied = true; - m_security_slot[slot_no].timing.k_scaler = scaler_k; - m_security_slot[slot_no].timing.time_counter = APP_CONFIG_TIMING_INIT_VALUE; - - uint8_t beacon_private[ESCS_ECDH_KEY_SIZE]; // Beacon private ECDH key - uint8_t beacon_public[ESCS_ECDH_KEY_SIZE]; // Beacon public ECDH key - uint8_t phone_public[ESCS_ECDH_KEY_SIZE]; // Phone public ECDH key - uint8_t shared[ESCS_ECDH_KEY_SIZE]; // Shared secret ECDH key - const uint8_t salt[1] = {0x01}; // Salt - uint8_t identity_key[ESCS_AES_KEY_SIZE]; // Identity Key - - // Get public 32-byte service ECDH key from phone. - memcpy(phone_public, p_pub_ecdh, ESCS_ECDH_KEY_SIZE); - - // Generate new set of keys for use with this EID slot. - es_beacon_ecdh_pair_generate(beacon_private, beacon_public); - memcpy(m_ecdh.ecdh_key_pair.private, beacon_private, ESCS_ECDH_KEY_SIZE); - memcpy(m_ecdh.ecdh_key_pair.public, beacon_public, ESCS_ECDH_KEY_SIZE); - - // Generate shared 32-byte ECDH secret from beacon private service ECDH key and phone public ECDH key. - occ_curve25519_scalarmult(shared, beacon_private, phone_public); - - // Generate key material using shared ECDH secret as salt and public_keys as key material. RFC 2104 HMAC-SHA256. - uint8_t digest[64]; - uint8_t public_keys[64]; - memcpy(public_keys, phone_public, 32); - memcpy(public_keys + 32, beacon_public, 32); - - occ_hmac_sha256(digest, public_keys, 64, shared, 32); - - // Zero check of the shared secret becoming zero, try generating a new key pair if so. Max attempt limit twice. - uint8_t empty_check[32] = {0}; - - if (memcmp(empty_check, shared, 32) == 0) - { - if (attempt_counter < 2) - { - attempt_counter++; - es_beacon_ecdh_pair_generate(beacon_private, beacon_public); - } - } - else - { - attempt_counter = 0; - } - - // Generate 16-byte Identity Key from shared ECDH secret using RFC 2104 HMAC-SHA256 and salt. - uint8_t digest_salted[64]; - occ_hmac_sha256(digest_salted, digest, 32, salt, 1); - - memcpy(identity_key, digest_salted, ESCS_AES_KEY_SIZE); - - memcpy(m_security_slot[slot_no].aes_ecb_ik.key, identity_key, ESCS_AES_KEY_SIZE); - - temp_key_generate(slot_no); - eid_generate(slot_no); - - m_security_callback(slot_no, ES_SECURITY_MSG_ECDH); - m_security_callback(slot_no, ES_SECURITY_MSG_IK); -} - - -void es_security_pub_ecdh_get(uint8_t slot_no, uint8_t * p_edch_buffer) -{ - memcpy(p_edch_buffer, m_ecdh.ecdh_key_pair.public, ESCS_ECDH_KEY_SIZE); -} - - -uint32_t es_security_clock_get(uint8_t slot_no) -{ - return m_security_slot[slot_no].timing.time_counter; -} - - -void es_security_eid_slot_destroy(uint8_t slot_no) -{ - memset(&m_security_slot[slot_no], 0, sizeof(es_security_slot_t)); -} - - -uint8_t es_security_scaler_get(uint8_t slot_no) -{ - return m_security_slot[slot_no].timing.k_scaler; -} - - -void es_security_eid_get(uint8_t slot_no, uint8_t * p_eid_buffer) -{ - memcpy(p_eid_buffer, m_security_slot[slot_no].eid, ES_EID_ID_LENGTH); -} - - -void es_security_encrypted_eid_id_key_get(uint8_t slot_no, uint8_t * p_key_buffer) -{ - memcpy(m_aes_ecb_lk.cleartext, m_security_slot[slot_no].aes_ecb_ik.key, ESCS_AES_KEY_SIZE); - AES128_ECB_encrypt(m_aes_ecb_lk.cleartext, m_aes_ecb_lk.key, m_aes_ecb_lk.ciphertext); - memcpy(p_key_buffer, m_aes_ecb_lk.ciphertext, ESCS_AES_KEY_SIZE); -} - - -void es_security_plain_eid_id_key_get(uint8_t slot_no, uint8_t * p_key_buffer) -{ - memcpy(p_key_buffer, m_security_slot[slot_no].aes_ecb_ik.key, ESCS_AES_KEY_SIZE); -} - - -void es_security_tlm_to_etlm(uint8_t ik_slot_no, es_tlm_frame_t * p_tlm, es_etlm_frame_t * p_etlm) -{ - cf_prp prp; // Describe the block cipher to use. - - uint8_t plain[TLM_DATA_SIZE] = {0}; // Plaintext tlm, without the frame byte and version. - size_t nplain = TLM_DATA_SIZE; // Length of message plaintext. - - /*lint -save -e420 */ - memcpy(plain, &p_tlm->vbatt[0], sizeof(plain)); - - const uint8_t header = 0; // Additionally authenticated data (AAD). - size_t nheader = 0; // Length of header (AAD). May be zero. - - uint8_t key[EIK_SIZE] = {0}; // Encryption/decryption key: EIK. - size_t nkey = EIK_SIZE; // Length of encryption/decryption key. - - memcpy(key, &m_security_slot[ik_slot_no].aes_ecb_ik.key[0], EIK_SIZE); - /*lint -restore */ - - uint8_t nonce[NONCE_SIZE] = {0}; // Nonce. This must not repeat for a given key. - size_t nnonce = NONCE_SIZE; // Length of nonce.First 4 bytes are beacon time base with k-bits cleared. - // Last two bits are randomly generated - - // Take the current timestamp and clear the lowest K bits, use it as nonce. - uint32_t k_bits_cleared_time = (m_security_slot[ik_slot_no].timing.time_counter - >> m_security_slot[ik_slot_no].timing.k_scaler) - << m_security_slot[ik_slot_no].timing.k_scaler; - - - nonce[0] = (uint8_t)((k_bits_cleared_time >> 24) & 0xff); - nonce[1] = (uint8_t)((k_bits_cleared_time >> 16) & 0xff); - nonce[2] = (uint8_t)((k_bits_cleared_time >> 8) & 0xff); - nonce[3] = (uint8_t)((k_bits_cleared_time) & 0xff); - - // Generate random salt. - uint8_t salt[SALT_SIZE] = {0}; - (void)sd_rand_application_vector_get(salt, SALT_SIZE); - memcpy(&nonce[4], salt, SALT_SIZE); - - uint8_t cipher[ES_ETLM_ECRYPTED_LENGTH]; // Ciphertext output. nplain bytes are written. - uint8_t tag[TAG_SIZE] = {0}; // Authentication tag. ntag bytes are written. - size_t ntag = TAG_SIZE; // Length of authentication tag. - - // Encryption - // -------------------------------------------------------------------------- - cf_aes_context ctx; - cf_aes_init(&ctx, key, nkey); - - prp.encrypt = (cf_prp_block)cf_aes_encrypt; // Encryption context - prp.decrypt = (cf_prp_block)cf_aes_decrypt; // Decryption context - prp.blocksz = ESCS_AES_KEY_SIZE; - - cf_eax_encrypt(&prp, - &ctx, - plain, // Plaintext input, aka TLM - nplain, // Length of TLM - &header, // Empty - nheader, // Empty - nonce, // Nonce input - nnonce, // Length of nonce - cipher, // Encrypted output - tag, // Authentication tag output - ntag // Length of authentication tag - ); - - // Construct the eTLM. - // -------------------------------------------------------------------------- - p_etlm->frame_type = p_tlm->frame_type; - p_etlm->version = ES_TLM_VERSION_ETLM; - memcpy(p_etlm->encrypted_tlm, cipher, ES_ETLM_ECRYPTED_LENGTH); - memcpy((uint8_t *)&p_etlm->random_salt, salt, SALT_SIZE); - memcpy((uint8_t *)&p_etlm->msg_integrity_check, tag, TAG_SIZE); -} - - -ret_code_t es_security_init(es_security_msg_cb_t security_callback) -{ - ret_code_t err_code; - - if (security_callback == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } - - // Get lock code from 'es_app_config.h', or fetch it from flash if exists. - lock_code_init(m_aes_ecb_lk.key); - - m_security_callback = security_callback; - - memset(&m_ecdh, 0, sizeof(es_security_ecdh_t)); - - for (uint32_t i = 0; i < APP_MAX_EID_SLOTS; ++i) - { - m_security_slot[i].timing.time_counter = APP_CONFIG_TIMING_INIT_VALUE; - } - err_code = es_stopwatch_create(&m_seconds_passed_sw_id, APP_TIMER_TICKS(1000)); - APP_ERROR_CHECK(err_code); - - return NRF_SUCCESS; -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.h deleted file mode 100644 index 65e092c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.h +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) 2017 - 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 APP_TWI_H__ -#define APP_TWI_H__ - -#include "../twi_mngr/nrf_twi_mngr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - */ - -/** - * @defgroup app_twi, nrf_twi_mngr_wrapper - * @{ - * @ingroup app_common - * - * @brief nrf_twi_mngr wrapper. - * - * @warning This is a duplicate of nrf_twi_mngr module, app_twi is soon to be deprecated. - * Switch to nrf_twi_mngr as soon as possible. - * To switch replace every app_twi component according to macros below. - */ - -//If TWIM is present buffers can only be in RAM - -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_BUFFERS_IN_RAM - */ -#define APP_TWI_BUFFERS_IN_RAM NRF_TWI_MNGR_BUFFERS_IN_RAM - -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_BUFFER_LOC_IND - */ -#define APP_TWI_BUFFER_LOC_IND NRF_TWI_MNGR_BUFFER_LOC_IND - -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_NO_STOP - */ -#define APP_TWI_NO_STOP NRF_TWI_MNGR_NO_STOP - - -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_WRITE - */ -#define APP_TWI_WRITE NRF_TWI_MNGR_WRITE -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_READ - */ -#define APP_TWI_READ NRF_TWI_MNGR_READ -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_TRANSFER - */ -#define APP_TWI_TRANSFER NRF_TWI_MNGR_TRANSFER -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_WRITE_OP - */ -#define APP_TWI_WRITE_OP NRF_TWI_MNGR_WRITE_OP -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_READ_OP - */ -#define APP_TWI_READ_OP NRF_TWI_MNGR_READ_OP -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_IS_READ_OP - */ -#define APP_TWI_IS_READ_OP NRF_TWI_MNGR_IS_READ_OP -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_OP_ADDRESS - */ -#define APP_TWI_OP_ADDRESS NRF_TWI_MNGR_OP_ADDRESS - -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_callback_t - */ -#define app_twi_callback_t nrf_twi_mngr_callback_t -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_transfer_t - */ -#define app_twi_transfer_t nrf_twi_mngr_transfer_t -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_transaction_t - */ -#define app_twi_transaction_t nrf_twi_mngr_transaction_t -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_cb_t - */ -#define app_twi_cb_t nrf_twi_mngr_cb_t -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_t - */ -#define app_twi_t nrf_twi_mngr_t - -/** - * @brief Macro for forwarding the new implementation. See @ref NRF_TWI_MNGR_DEF - */ -#define APP_TWI_DEF NRF_TWI_MNGR_DEF - -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_init - */ -#define app_twi_init nrf_twi_mngr_init -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_uninit - */ -#define app_twi_uninit nrf_twi_mngr_uninit -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_schedule - */ -#define app_twi_schedule nrf_twi_mngr_schedule -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_perform - */ -#define app_twi_perform(p_nrf_twi_mngr, p_transfers, number_of_transfers, user_function) \ - nrf_twi_mngr_perform(p_nrf_twi_mngr, NULL, p_transfers, number_of_transfers, user_function) -/** - * @brief Macro for forwarding the new implementation. See @ref nrf_twi_mngr_is_idle - */ -#define app_twi_is_idle nrf_twi_mngr_is_idle - - -/** - *@} - **/ - - -#ifdef __cplusplus -} -#endif - -#endif // APP_TWI_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_langid.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_langid.h deleted file mode 100644 index 23c2370..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_langid.h +++ /dev/null @@ -1,286 +0,0 @@ -/** - * Copyright (c) 2016 - 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 APP_USBD_LANGID_H__ -#define APP_USBD_LANGID_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file - * @brief This file contains LANGID variable type with all defined values - * - * This file was created using Language Identifiers (LANGIDs) 3/29/00 Version 1.0, - * available on USB web page: - * http://www.usb.org/developers/docs/USB_LANGIDs.pdf - * - * @note - * Do not include this file directly to the project. - * It is included by @file app_usbd_request.h. - */ - -/** - * Offset of the lowest bit of primary language identifier - * @sa app_usbd_langid_t - */ -#define APP_USB_LANG_OFFSET 0 - -/** - * Bitmask for a primary language identifier - * @sa app_usbd_langid_t - */ -#define APP_USB_LANG_MASK BF_MASK(10, APP_USB_LANG_OFFSET) - -/** - * Offset of the lowest bit of sub-language identifier - * @sa app_usbd_langid_t - */ -#define APP_USB_SUBLANG_OFFSET 10 - -/** - * Bitmask for a sub-language identifier - * @sa app_usbd_langid_t - */ -#define APP_USB_SUBLANG_MASK BF_MASK(6, APP_USB_SUBLANG_OFFSET) - -/** - * @brief Primary language identifiers - * - * Mnemonics for primary language identifiers. - * This mnemonics can be combined using logical OR operator with @ref app_usbd_langid_sub_t. - */ -typedef enum -{ - APP_USBD_LANG_ARABIC = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Arabic */ - APP_USBD_LANG_BULGARIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Bulgarian */ - APP_USBD_LANG_CATALAN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Catalan */ - APP_USBD_LANG_CHINESE = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Chinese */ - APP_USBD_LANG_CZECH = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Czech */ - APP_USBD_LANG_DANISH = 0x06U << ( APP_USB_LANG_OFFSET ), /**< Danish */ - APP_USBD_LANG_GERMAN = 0x07U << ( APP_USB_LANG_OFFSET ), /**< German */ - APP_USBD_LANG_GREEK = 0x08U << ( APP_USB_LANG_OFFSET ), /**< Greek */ - APP_USBD_LANG_ENGLISH = 0x09U << ( APP_USB_LANG_OFFSET ), /**< English */ - APP_USBD_LANG_SPANISH = 0x0aU << ( APP_USB_LANG_OFFSET ), /**< Spanish */ - APP_USBD_LANG_FINNISH = 0x0bU << ( APP_USB_LANG_OFFSET ), /**< Finnish */ - APP_USBD_LANG_FRENCH = 0x0cU << ( APP_USB_LANG_OFFSET ), /**< French */ - APP_USBD_LANG_HEBREW = 0x0dU << ( APP_USB_LANG_OFFSET ), /**< Hebrew */ - APP_USBD_LANG_HUNGARIAN = 0x0eU << ( APP_USB_LANG_OFFSET ), /**< Hungarian */ - APP_USBD_LANG_ICELANDIC = 0x0fU << ( APP_USB_LANG_OFFSET ), /**< Icelandic */ - APP_USBD_LANG_ITALIAN = 0x10U << ( APP_USB_LANG_OFFSET ), /**< Italian */ - APP_USBD_LANG_JAPANESE = 0x11U << ( APP_USB_LANG_OFFSET ), /**< Japanese */ - APP_USBD_LANG_KOREAN = 0x12U << ( APP_USB_LANG_OFFSET ), /**< Korean */ - APP_USBD_LANG_DUTCH = 0x13U << ( APP_USB_LANG_OFFSET ), /**< Dutch */ - APP_USBD_LANG_NORWEGIAN = 0x14U << ( APP_USB_LANG_OFFSET ), /**< Norwegian */ - APP_USBD_LANG_POLISH = 0x15U << ( APP_USB_LANG_OFFSET ), /**< Polish */ - APP_USBD_LANG_PORTUGUESE = 0x16U << ( APP_USB_LANG_OFFSET ), /**< Portuguese */ - APP_USBD_LANG_ROMANIAN = 0x18U << ( APP_USB_LANG_OFFSET ), /**< Romanian */ - APP_USBD_LANG_RUSSIAN = 0x19U << ( APP_USB_LANG_OFFSET ), /**< Russian */ - APP_USBD_LANG_CROATIAN = 0x1aU << ( APP_USB_LANG_OFFSET ), /**< Croatian */ - APP_USBD_LANG_SERBIAN = 0x1aU << ( APP_USB_LANG_OFFSET ), /**< Serbian */ - APP_USBD_LANG_SLOVAK = 0x1bU << ( APP_USB_LANG_OFFSET ), /**< Slovak */ - APP_USBD_LANG_ALBANIAN = 0x1cU << ( APP_USB_LANG_OFFSET ), /**< Albanian */ - APP_USBD_LANG_SWEDISH = 0x1dU << ( APP_USB_LANG_OFFSET ), /**< Swedish */ - APP_USBD_LANG_THAI = 0x1eU << ( APP_USB_LANG_OFFSET ), /**< Thai */ - APP_USBD_LANG_TURKISH = 0x1fU << ( APP_USB_LANG_OFFSET ), /**< Turkish */ - APP_USBD_LANG_URDU = 0x20U << ( APP_USB_LANG_OFFSET ), /**< Urdu */ - APP_USBD_LANG_INDONESIAN = 0x21U << ( APP_USB_LANG_OFFSET ), /**< Indonesian */ - APP_USBD_LANG_UKRANIAN = 0x22U << ( APP_USB_LANG_OFFSET ), /**< Ukrainian */ - APP_USBD_LANG_BELARUSIAN = 0x23U << ( APP_USB_LANG_OFFSET ), /**< Belarusian */ - APP_USBD_LANG_SLOVENIAN = 0x24U << ( APP_USB_LANG_OFFSET ), /**< Slovenian */ - APP_USBD_LANG_ESTONIAN = 0x25U << ( APP_USB_LANG_OFFSET ), /**< Estonian */ - APP_USBD_LANG_LATVIAN = 0x26U << ( APP_USB_LANG_OFFSET ), /**< Latvian */ - APP_USBD_LANG_LITHUANIAN = 0x27U << ( APP_USB_LANG_OFFSET ), /**< Lithuanian */ - APP_USBD_LANG_FARSI = 0x29U << ( APP_USB_LANG_OFFSET ), /**< Farsi */ - APP_USBD_LANG_VIETNAMESE = 0x2aU << ( APP_USB_LANG_OFFSET ), /**< Vietnamese */ - APP_USBD_LANG_ARMENIAN = 0x2bU << ( APP_USB_LANG_OFFSET ), /**< Armenian */ - APP_USBD_LANG_AZERI = 0x2cU << ( APP_USB_LANG_OFFSET ), /**< Azeri */ - APP_USBD_LANG_BASQUE = 0x2dU << ( APP_USB_LANG_OFFSET ), /**< Basque */ - APP_USBD_LANG_MACEDONIAN = 0x2fU << ( APP_USB_LANG_OFFSET ), /**< Macedonian */ - APP_USBD_LANG_AFRIKAANS = 0x36U << ( APP_USB_LANG_OFFSET ), /**< Afrikaans */ - APP_USBD_LANG_GEORGIAN = 0x37U << ( APP_USB_LANG_OFFSET ), /**< Georgian */ - APP_USBD_LANG_FAEROESE = 0x38U << ( APP_USB_LANG_OFFSET ), /**< Faeroese */ - APP_USBD_LANG_HINDI = 0x39U << ( APP_USB_LANG_OFFSET ), /**< Hindi */ - APP_USBD_LANG_MALAY = 0x3eU << ( APP_USB_LANG_OFFSET ), /**< Malay */ - APP_USBD_LANG_KAZAK = 0x3fU << ( APP_USB_LANG_OFFSET ), /**< Kazak */ - APP_USBD_LANG_SWAHILI = 0x41U << ( APP_USB_LANG_OFFSET ), /**< Swahili */ - APP_USBD_LANG_UZBEK = 0x43U << ( APP_USB_LANG_OFFSET ), /**< Uzbek */ - APP_USBD_LANG_TATAR = 0x44U << ( APP_USB_LANG_OFFSET ), /**< Tatar */ - APP_USBD_LANG_BENGALI = 0x45U << ( APP_USB_LANG_OFFSET ), /**< Bengali */ - APP_USBD_LANG_PUNJABI = 0x46U << ( APP_USB_LANG_OFFSET ), /**< Punjabi */ - APP_USBD_LANG_GUJARATI = 0x47U << ( APP_USB_LANG_OFFSET ), /**< Gujarati */ - APP_USBD_LANG_ORIYA = 0x48U << ( APP_USB_LANG_OFFSET ), /**< Oriya */ - APP_USBD_LANG_TAMIL = 0x49U << ( APP_USB_LANG_OFFSET ), /**< Tamil */ - APP_USBD_LANG_TELUGU = 0x4aU << ( APP_USB_LANG_OFFSET ), /**< Telugu */ - APP_USBD_LANG_KANNADA = 0x4bU << ( APP_USB_LANG_OFFSET ), /**< Kannada */ - APP_USBD_LANG_MALAYALAM = 0x4cU << ( APP_USB_LANG_OFFSET ), /**< Malayalam */ - APP_USBD_LANG_ASSAMESE = 0x4dU << ( APP_USB_LANG_OFFSET ), /**< Assamese */ - APP_USBD_LANG_MARATHI = 0x4eU << ( APP_USB_LANG_OFFSET ), /**< Marathi */ - APP_USBD_LANG_SANSKRIT = 0x4fU << ( APP_USB_LANG_OFFSET ), /**< Sanskrit */ - APP_USBD_LANG_KONKANI = 0x57U << ( APP_USB_LANG_OFFSET ), /**< Konkani */ - APP_USBD_LANG_MANIPURI = 0x58U << ( APP_USB_LANG_OFFSET ), /**< Manipuri */ - APP_USBD_LANG_SINDHI = 0x59U << ( APP_USB_LANG_OFFSET ), /**< Sindhi */ - APP_USBD_LANG_KASHMIRI = 0x60U << ( APP_USB_LANG_OFFSET ), /**< Kashmiri */ - APP_USBD_LANG_NEPALI = 0x61U << ( APP_USB_LANG_OFFSET ), /**< Nepali */ - APP_USBD_LANG_HID = 0xffU << ( APP_USB_LANG_OFFSET ), /**< Reserved for USB HID Class use */ -}app_usbd_langid_primary_t; - -/** - * @brief Sublanguage identifiers - * - * Mnemonics with sublanguage values. - * Use them in combination with @ref app_usbd_langid_primary_t. - */ -typedef enum -{ - APP_USBD_SUBLANG_ARABIC_SAUDI_ARABIA = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Saudi Arabia) */ - APP_USBD_SUBLANG_ARABIC_IRAQ = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Iraq) */ - APP_USBD_SUBLANG_ARABIC_EGYPT = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Egypt) */ - APP_USBD_SUBLANG_ARABIC_LIBYA = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Libya) */ - APP_USBD_SUBLANG_ARABIC_ALGERIA = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Algeria) */ - APP_USBD_SUBLANG_ARABIC_MOROCCO = 0x06U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Morocco) */ - APP_USBD_SUBLANG_ARABIC_TUNISIA = 0x07U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Tunisia) */ - APP_USBD_SUBLANG_ARABIC_OMAN = 0x08U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Oman) */ - APP_USBD_SUBLANG_ARABIC_YEMEN = 0x09U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Yemen) */ - APP_USBD_SUBLANG_ARABIC_SYRIA = 0x10U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Syria) */ - APP_USBD_SUBLANG_ARABIC_JORDAN = 0x11U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Jordan) */ - APP_USBD_SUBLANG_ARABIC_LEBANON = 0x12U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Lebanon) */ - APP_USBD_SUBLANG_ARABIC_KUWAIT = 0x13U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Kuwait) */ - APP_USBD_SUBLANG_ARABIC_UAE = 0x14U << ( APP_USB_LANG_OFFSET ), /**< Arabic (U.A.E.) */ - APP_USBD_SUBLANG_ARABIC_BAHRAIN = 0x15U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Bahrain) */ - APP_USBD_SUBLANG_ARABIC_QATAR = 0x16U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Qatar) */ - APP_USBD_SUBLANG_AZERI_CYRILLIC = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Azeri (Cyrillic) */ - APP_USBD_SUBLANG_AZERI_LATIN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Azeri (Latin) */ - APP_USBD_SUBLANG_CHINESE_TRADITIONAL = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Traditional) */ - APP_USBD_SUBLANG_CHINESE_SIMPLIFIED = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Simplified) */ - APP_USBD_SUBLANG_CHINESE_HONGKONG = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Hong Kong SAR, PRC) */ - APP_USBD_SUBLANG_CHINESE_SINGAPORE = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Singapore) */ - APP_USBD_SUBLANG_CHINESE_MACAU = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Macau SAR) */ - APP_USBD_SUBLANG_DUTCH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Dutch */ - APP_USBD_SUBLANG_DUTCH_BELGIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Dutch (Belgian) */ - APP_USBD_SUBLANG_ENGLISH_US = 0x01U << ( APP_USB_LANG_OFFSET ), /**< English (US) */ - APP_USBD_SUBLANG_ENGLISH_UK = 0x02U << ( APP_USB_LANG_OFFSET ), /**< English (UK) */ - APP_USBD_SUBLANG_ENGLISH_AUS = 0x03U << ( APP_USB_LANG_OFFSET ), /**< English (Australian) */ - APP_USBD_SUBLANG_ENGLISH_CAN = 0x04U << ( APP_USB_LANG_OFFSET ), /**< English (Canadian) */ - APP_USBD_SUBLANG_ENGLISH_NZ = 0x05U << ( APP_USB_LANG_OFFSET ), /**< English (New Zealand) */ - APP_USBD_SUBLANG_ENGLISH_EIRE = 0x06U << ( APP_USB_LANG_OFFSET ), /**< English (Ireland) */ - APP_USBD_SUBLANG_ENGLISH_SOUTH_AFRICA = 0x07U << ( APP_USB_LANG_OFFSET ), /**< English (South Africa) */ - APP_USBD_SUBLANG_ENGLISH_JAMAICA = 0x08U << ( APP_USB_LANG_OFFSET ), /**< English (Jamaica) */ - APP_USBD_SUBLANG_ENGLISH_CARIBBEAN = 0x09U << ( APP_USB_LANG_OFFSET ), /**< English (Caribbean) */ - APP_USBD_SUBLANG_ENGLISH_BELIZE = 0x0aU << ( APP_USB_LANG_OFFSET ), /**< English (Belize) */ - APP_USBD_SUBLANG_ENGLISH_TRINIDAD = 0x0bU << ( APP_USB_LANG_OFFSET ), /**< English (Trinidad) */ - APP_USBD_SUBLANG_ENGLISH_PHILIPPINES = 0x0cU << ( APP_USB_LANG_OFFSET ), /**< English (Zimbabwe) */ - APP_USBD_SUBLANG_ENGLISH_ZIMBABWE = 0x0dU << ( APP_USB_LANG_OFFSET ), /**< English (Philippines) */ - APP_USBD_SUBLANG_FRENCH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< French */ - APP_USBD_SUBLANG_FRENCH_BELGIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< French (Belgian) */ - APP_USBD_SUBLANG_FRENCH_CANADIAN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< French (Canadian) */ - APP_USBD_SUBLANG_FRENCH_SWISS = 0x04U << ( APP_USB_LANG_OFFSET ), /**< French (Swiss) */ - APP_USBD_SUBLANG_FRENCH_LUXEMBOURG = 0x05U << ( APP_USB_LANG_OFFSET ), /**< French (Luxembourg) */ - APP_USBD_SUBLANG_FRENCH_MONACO = 0x06U << ( APP_USB_LANG_OFFSET ), /**< French (Monaco) */ - APP_USBD_SUBLANG_GERMAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< German */ - APP_USBD_SUBLANG_GERMAN_SWISS = 0x02U << ( APP_USB_LANG_OFFSET ), /**< German (Swiss) */ - APP_USBD_SUBLANG_GERMAN_AUSTRIAN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< German (Austrian) */ - APP_USBD_SUBLANG_GERMAN_LUXEMBOURG = 0x04U << ( APP_USB_LANG_OFFSET ), /**< German (Luxembourg) */ - APP_USBD_SUBLANG_GERMAN_LIECHTENSTEIN = 0x05U << ( APP_USB_LANG_OFFSET ), /**< German (Liechtenstein) */ - APP_USBD_SUBLANG_ITALIAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Italian */ - APP_USBD_SUBLANG_ITALIAN_SWISS = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Italian (Swiss) */ - APP_USBD_SUBLANG_KASHMIRI_INDIA = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Kashmiri (India) */ - APP_USBD_SUBLANG_KOREAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Korean */ - APP_USBD_SUBLANG_LITHUANIAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Lithuanian */ - APP_USBD_SUBLANG_MALAY_MALAYSIA = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Malay (Malaysia) */ - APP_USBD_SUBLANG_MALAY_BRUNEI_DARUSSALAM = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Malay (Brunei Darassalam) */ - APP_USBD_SUBLANG_NEPALI_INDIA = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Nepali (India) */ - APP_USBD_SUBLANG_NORWEGIAN_BOKMAL = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Norwegian (Bokmal) */ - APP_USBD_SUBLANG_NORWEGIAN_NYNORSK = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Norwegian (Nynorsk) */ - APP_USBD_SUBLANG_PORTUGUESE = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Portuguese (Brazilian) */ - APP_USBD_SUBLANG_PORTUGUESE_BRAZILIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Portuguese */ - APP_USBD_SUBLANG_SERBIAN_LATIN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Serbian (Latin) */ - APP_USBD_SUBLANG_SERBIAN_CYRILLIC = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Serbian (Cyrillic) */ - APP_USBD_SUBLANG_SPANISH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Castilian) */ - APP_USBD_SUBLANG_SPANISH_MEXICAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Mexican) */ - APP_USBD_SUBLANG_SPANISH_MODERN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Modern) */ - APP_USBD_SUBLANG_SPANISH_GUATEMALA = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Guatemala) */ - APP_USBD_SUBLANG_SPANISH_COSTA_RICA = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Costa Rica) */ - APP_USBD_SUBLANG_SPANISH_PANAMA = 0x06U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Panama) */ - APP_USBD_SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x07U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Dominican Republic) */ - APP_USBD_SUBLANG_SPANISH_VENEZUELA = 0x08U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Venezuela) */ - APP_USBD_SUBLANG_SPANISH_COLOMBIA = 0x09U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Colombia) */ - APP_USBD_SUBLANG_SPANISH_PERU = 0x0aU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Peru) */ - APP_USBD_SUBLANG_SPANISH_ARGENTINA = 0x0bU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Argentina) */ - APP_USBD_SUBLANG_SPANISH_ECUADOR = 0x0cU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Ecuador) */ - APP_USBD_SUBLANG_SPANISH_CHILE = 0x0dU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Chile) */ - APP_USBD_SUBLANG_SPANISH_URUGUAY = 0x0eU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Uruguay) */ - APP_USBD_SUBLANG_SPANISH_PARAGUAY = 0x0fU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Paraguay) */ - APP_USBD_SUBLANG_SPANISH_BOLIVIA = 0x10U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Bolivia) */ - APP_USBD_SUBLANG_SPANISH_EL_SALVADOR = 0x11U << ( APP_USB_LANG_OFFSET ), /**< Spanish (El Salvador) */ - APP_USBD_SUBLANG_SPANISH_HONDURAS = 0x12U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Honduras) */ - APP_USBD_SUBLANG_SPANISH_NICARAGUA = 0x13U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Nicaragua) */ - APP_USBD_SUBLANG_SPANISH_PUERTO_RICO = 0x14U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Puerto Rico) */ - APP_USBD_SUBLANG_SWEDISH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Swedish */ - APP_USBD_SUBLANG_SWEDISH_FINLAND = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Swedish (Finland) */ - APP_USBD_SUBLANG_URDU_PAKISTAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Urdu (Pakistan) */ - APP_USBD_SUBLANG_URDU_INDIA = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Urdu (India) */ - APP_USBD_SUBLANG_UZBEK_LATIN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Uzbek (Latin) */ - APP_USBD_SUBLANG_UZBEK_CYRILLIC = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Uzbek (Cyrillic) */ - APP_USBD_SUBLANG_HID_USAGE_DATA_DESCRIPTOR = 0x01U << ( APP_USB_LANG_OFFSET ), /**< HID (Usage Data Descriptor) */ - APP_USBD_SUBLANG_HID_VENDOR_DEFINED_1 = 0x3cU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 1) */ - APP_USBD_SUBLANG_HID_VENDOR_DEFINED_2 = 0x3dU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 2) */ - APP_USBD_SUBLANG_HID_VENDOR_DEFINED_3 = 0x3eU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 3) */ - APP_USBD_SUBLANG_HID_VENDOR_DEFINED_4 = 0x3fU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 4) */ -}app_usbd_langid_sub_t; - -/** - * @brief LANGID variable - * - * The LANGID value is composed from: - * - 10-bit (9-0) of Primary Language Identifiers - * - 6-bit (15-10) of Sublanguage Identifiers. - * - * @sa app_usbd_langid_primary_t - * @sa app_usbd_langid_sub_t - */ -typedef uint16_t app_usbd_langid_t; - -#ifdef __cplusplus -} -#endif - -#endif /* APP_USBD_LANGID_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_string_desc.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_string_desc.c deleted file mode 100644 index 3d4b47d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_string_desc.c +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if APP_USBD_ENABLED -#include "app_usbd_string_desc.h" -#include "app_usbd_langid.h" -#include "app_usbd_core.h" -#include "nordic_common.h" - -/** - * @defgroup app_usbd_string_desc - * @ingroup app_usbd - * - * USBD string descriptors management - * @{ - */ - -/** - * @brief Array with language identifiers - * - * This array would be used to search the proper string for selected language. - */ -static const uint16_t m_langids[] = { APP_USBD_STRINGS_LANGIDS }; - -/** - * @brief Language ID descriptor - * - * Language - */ - - -/** - * @brief Mnemonics for the string positions in the array - * - * The mnemonics for the indexes of the strings inside the string array. - */ -enum { - APP_USBD_STRING_ID_LANGIDS_ARRAY_POS = 0, /**< Supported language identifiers */ - APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS, /**< Manufacturer name */ - APP_USBD_STRING_ID_PRODUCT_ARRAY_POS, /**< Product name */ - APP_USBD_STRING_ID_SERIAL_ARRAY_POS, /**< Serial number */ -#define X(mnemonic, str_idx, ...) CONCAT_2(mnemonic, _ARRAY_POS), - APP_USBD_STRINGS_USER -#undef X -}; - -/** - * @brief String index into internal array index conversion table - * - * The array that transforms the USB string indexes into internal array position. - * @note Value 0 used to mark non-existing string. - */ -static const uint8_t m_string_translation[APP_USBD_STRING_ID_CNT] = -{ - [APP_USBD_STRING_ID_LANGIDS ] = APP_USBD_STRING_ID_LANGIDS_ARRAY_POS, - [APP_USBD_STRING_ID_MANUFACTURER] = APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS, - [APP_USBD_STRING_ID_PRODUCT ] = APP_USBD_STRING_ID_PRODUCT_ARRAY_POS, - [APP_USBD_STRING_ID_SERIAL ] = APP_USBD_STRING_ID_SERIAL_ARRAY_POS, -#define X(mnemonic, str_idx, ...) [mnemonic] = CONCAT_2(mnemonic, _ARRAY_POS), - APP_USBD_STRINGS_USER -#undef X -}; - -#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN -#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 -#endif - -#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN -#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 -#endif - -#ifndef APP_USBD_STRING_SERIAL_EXTERN -#define APP_USBD_STRING_SERIAL_EXTERN 0 -#endif - -#if APP_USBD_STRINGS_MANUFACTURER_EXTERN -extern uint16_t APP_USBD_STRINGS_MANUFACTURER[]; -#endif - -#if APP_USBD_STRINGS_PRODUCT_EXTERN -extern uint16_t APP_USBD_STRINGS_PRODUCT[]; -#endif - -#if APP_USBD_STRING_SERIAL_EXTERN -extern uint16_t APP_USBD_STRING_SERIAL[]; -#endif - - -/** - * @brief String descriptors table - * */ -static const uint16_t * m_string_dsc[APP_USBD_STRING_ID_CNT][ARRAY_SIZE(m_langids)] = -{ - [APP_USBD_STRING_ID_LANGIDS_ARRAY_POS] = { APP_USBD_STRING_DESC(APP_USBD_STRINGS_LANGIDS) }, - [APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS] = { APP_USBD_STRINGS_MANUFACTURER }, - [APP_USBD_STRING_ID_PRODUCT_ARRAY_POS] = { APP_USBD_STRINGS_PRODUCT }, - [APP_USBD_STRING_ID_SERIAL_ARRAY_POS] = { APP_USBD_STRING_SERIAL }, -#define X(mnemonic, str_idx, ...) [CONCAT_2(mnemonic, _ARRAY_POS)] = { __VA_ARGS__ }, - APP_USBD_STRINGS_USER -#undef X -}; - - - -uint16_t const * app_usbd_string_desc_get(app_usbd_string_desc_idx_t idx, uint16_t langid) -{ - /* LANGID string */ - if (APP_USBD_STRING_ID_LANGIDS == idx) - { - return m_string_dsc[APP_USBD_STRING_ID_LANGIDS_ARRAY_POS][0]; - } - - /* Searching for the language */ - uint8_t lang_idx = 0; - if (ARRAY_SIZE(m_langids) > 1) - { - while (m_langids[lang_idx] != langid) - { - if (++lang_idx >= ARRAY_SIZE(m_langids)) - { - return NULL; - } - } - } - - /* Get the string index in array */ - if (idx >= ARRAY_SIZE(m_string_translation)) - { - return NULL; - } - - uint8_t str_pos = m_string_translation[idx]; - if (str_pos == 0) - { - return NULL; - } - - uint16_t const * p_str = m_string_dsc[str_pos][lang_idx]; - if ((ARRAY_SIZE(m_langids) > 1) && (lang_idx != 0)) - { - if (p_str == NULL) - { - p_str = m_string_dsc[str_pos][0]; - } - } - - return p_str; -} - -/** @} */ -#endif // APP_USBD_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.c deleted file mode 100644 index 41e107d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.c +++ /dev/null @@ -1,559 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if APP_USBD_CLASS_AUDIO_ENABLED -#include "app_usbd_audio.h" -#include "app_util_platform.h" - -/** - * @defgroup app_usbd_audio_internals USBD Audio internals - * @{ - * @ingroup app_usbd_audio - * @internal - */ - -STATIC_ASSERT(sizeof(app_usbd_audio_ac_iface_header_desc_t) == 8); -STATIC_ASSERT(sizeof(app_usbd_audio_input_terminal_desc_t) == 12); -STATIC_ASSERT(sizeof(app_usbd_audio_output_terminal_desc_t) == 9); -STATIC_ASSERT(sizeof(app_usbd_audio_feature_unit_desc_t) == 6); -STATIC_ASSERT(sizeof(app_usbd_audio_as_iface_desc_t) == 7); -STATIC_ASSERT(sizeof(app_usbd_audio_as_format_type_one_desc_t) == 8); -STATIC_ASSERT(sizeof(app_usbd_audio_as_format_type_two_desc_t) == 9); -STATIC_ASSERT(sizeof(app_usbd_audio_as_format_type_three_desc_t) == 8); -STATIC_ASSERT(sizeof(app_usbd_audio_as_endpoint_desc_t) == 7); - -#define APP_USBD_AUDIO_CONTROL_IFACE_IDX 0 /**< Audio class control interface index */ -#define APP_USBD_AUDIO_STREAMING_IFACE_IDX 1 /**< Audio class streaming interface index */ - -#define APP_USBD_CDC_AUDIO_STREAMING_EP_IDX 0 /**< Audio streaming isochronous endpoint index */ - -/** - * @brief Auxiliary function to access audio class instance data - * - * @param[in] p_inst Class instance data - * @return Audio class instance data @ref app_usbd_audio_t - */ -static inline app_usbd_audio_t const * audio_get(app_usbd_class_inst_t const * p_inst) -{ - ASSERT(p_inst != NULL); - return (app_usbd_audio_t const *)p_inst; -} - -/** - * @brief Auxiliary function to access audio class context data - * - * @param[in] p_audio Audio class instance data - * @return Audio class context data @ref app_usbd_audio_ctx_t - */ -static inline app_usbd_audio_ctx_t * audio_ctx_get(app_usbd_audio_t const * p_audio) -{ - ASSERT(p_audio != NULL); - ASSERT(p_audio->specific.p_data != NULL); - return &p_audio->specific.p_data->ctx; -} - - -/** - * @brief User event handler - * - * @param[in] p_inst Class instance - * @param[in] event user Event type @ref app_usbd_audio_user_event_t - */ -static inline void user_event_handler( - app_usbd_class_inst_t const * p_inst, - app_usbd_audio_user_event_t event) -{ - app_usbd_audio_t const * p_audio = audio_get(p_inst); - if (p_audio->specific.inst.user_ev_handler != NULL) - { - p_audio->specific.inst.user_ev_handler(p_inst, event); - } -} - -/** - * @brief Select interface - * - * @param[in,out] p_inst Instance of the class - * @param[in] iface_idx Index of the interface inside class structure - * @param[in] alternate Alternate setting that should be selected - */ -static ret_code_t iface_select( - app_usbd_class_inst_t const * const p_inst, - uint8_t iface_idx, - uint8_t alternate) -{ - app_usbd_class_iface_conf_t const * p_iface = app_usbd_class_iface_get(p_inst, iface_idx); - /* Simple check if this is data interface */ - uint8_t const ep_count = app_usbd_class_iface_ep_count_get(p_iface); - if (ep_count > 0) - { - if (alternate > 1) - { - return NRF_ERROR_INVALID_PARAM; - } - app_usbd_audio_t const * p_audio = audio_get(p_inst); - app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); - p_audio_ctx->streaming = (alternate != 0); - - uint8_t i; - for (i=0; iep_cnt > 0) - { - app_usbd_audio_t const * p_audio = audio_get(p_inst); - app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); - p_audio_ctx->streaming = false; - } - /* Note that all the interface endpoints would be disabled automatically after this function */ -} - -static uint8_t iface_selection_get( - app_usbd_class_inst_t const * const p_inst, - uint8_t iface_idx) -{ - app_usbd_class_iface_conf_t const * p_iface = app_usbd_class_iface_get(p_inst, iface_idx); - /* Simple check if this is data interface */ - uint8_t const ep_count = app_usbd_class_iface_ep_count_get(p_iface); - if (ep_count > 0) - { - app_usbd_audio_t const * p_audio = audio_get(p_inst); - app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); - return (p_audio_ctx->streaming) ? 1 : 0; - } - return 0; -} - -/** - * @brief Internal SETUP standard IN request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - /* Only Get Descriptor standard IN request is supported by Audio class */ - if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) - && - (p_setup_ev->setup.bmRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) - { - size_t dsc_len = 0; - /* Try to find descriptor in class internals*/ - void const * p_dsc = app_usbd_class_descriptor_find( - p_inst, - p_setup_ev->setup.wValue.hb, - p_setup_ev->setup.wValue.lb, - &dsc_len); - if (p_dsc != NULL) - { - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_dsc, dsc_len); - } - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Internal SETUP class IN request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_req_class_in( - app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_AUDIO_REQ_GET_CUR: - case APP_USBD_AUDIO_REQ_GET_MIN: - case APP_USBD_AUDIO_REQ_GET_MAX: - case APP_USBD_AUDIO_REQ_SET_RES: - case APP_USBD_AUDIO_REQ_GET_MEM: - { - app_usbd_audio_t const * p_audio = audio_get(p_inst); - app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); - - - p_audio_ctx->request.req_type = (app_usbd_audio_req_type_t)p_setup_ev->setup.bmRequest; - p_audio_ctx->request.control = p_setup_ev->setup.wValue.hb; - p_audio_ctx->request.channel = p_setup_ev->setup.wValue.lb; - p_audio_ctx->request.interface = p_setup_ev->setup.wIndex.hb; - p_audio_ctx->request.entity = p_setup_ev->setup.wIndex.lb; - - p_audio_ctx->request.length = p_setup_ev->setup.wLength.w; - - p_audio_ctx->request.req_target = APP_USBD_AUDIO_CLASS_REQ_IN; - - app_usbd_setup_reqrec_t rec = app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType); - if (rec == APP_USBD_SETUP_REQREC_ENDPOINT) - { - p_audio_ctx->request.req_target = APP_USBD_AUDIO_EP_REQ_IN; - } - - user_event_handler((app_usbd_class_inst_t const *)p_audio, - APP_USBD_AUDIO_USER_EVT_CLASS_REQ); - - return app_usbd_core_setup_rsp(&p_setup_ev->setup, - p_audio_ctx->request.payload, - p_audio_ctx->request.length); - } - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -static ret_code_t audio_req_out_data_cb(nrf_drv_usbd_ep_status_t status, void * p_context) -{ - if (status == NRF_USBD_EP_OK) - { - app_usbd_audio_t const * p_audio = p_context; - - user_event_handler((app_usbd_class_inst_t const *)p_audio, - APP_USBD_AUDIO_USER_EVT_CLASS_REQ); - } - - return NRF_SUCCESS; -} - -static ret_code_t audio_req_out( - app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_audio_t const * p_audio = audio_get(p_inst); - app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); - - - p_audio_ctx->request.req_type = (app_usbd_audio_req_type_t)p_setup_ev->setup.bmRequest; - p_audio_ctx->request.control = p_setup_ev->setup.wValue.hb; - p_audio_ctx->request.channel = p_setup_ev->setup.wValue.lb; - p_audio_ctx->request.interface = p_setup_ev->setup.wIndex.hb; - p_audio_ctx->request.entity = p_setup_ev->setup.wIndex.lb; - - p_audio_ctx->request.length = p_setup_ev->setup.wLength.w; - - p_audio_ctx->request.req_target = APP_USBD_AUDIO_CLASS_REQ_OUT; - if (app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_ENDPOINT) - { - p_audio_ctx->request.req_target = APP_USBD_AUDIO_EP_REQ_OUT; - } - - /*Request setup data*/ - NRF_DRV_USBD_TRANSFER_OUT(transfer, p_audio_ctx->request.payload, p_audio_ctx->request.length); - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); - if (ret == NRF_SUCCESS) - { - app_usbd_core_setup_data_handler_desc_t desc = { - .handler = audio_req_out_data_cb, - .p_context = (void*)p_audio - }; - - ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -/** - * @brief Internal SETUP class OUT request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_req_class_out( - app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_AUDIO_REQ_SET_CUR: - case APP_USBD_AUDIO_REQ_SET_MIN: - case APP_USBD_AUDIO_REQ_SET_MAX: - case APP_USBD_AUDIO_REQ_SET_RES: - case APP_USBD_AUDIO_REQ_SET_MEM: - return audio_req_out(p_inst, p_setup_ev); - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Control endpoint handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_event_handler( - app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - ASSERT(p_inst != NULL); - ASSERT(p_setup_ev != NULL); - - if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) - { - switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) - { - case APP_USBD_SETUP_REQTYPE_STD: - return setup_req_std_in(p_inst, p_setup_ev); - case APP_USBD_SETUP_REQTYPE_CLASS: - return setup_req_class_in(p_inst, p_setup_ev); - default: - break; - } - } - else /*APP_USBD_SETUP_REQDIR_OUT*/ - { - switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) - { - case APP_USBD_SETUP_REQTYPE_CLASS: - return setup_req_class_out(p_inst, p_setup_ev); - default: - break; - } - } - - return NRF_ERROR_NOT_SUPPORTED; -} - - -/** - * @brief Endpoint IN event handler - * - * @param[in] p_inst Generic class instance - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t endpoint_in_event_handler(app_usbd_class_inst_t const * p_inst) -{ - user_event_handler(p_inst, APP_USBD_AUDIO_USER_EVT_TX_DONE); - return NRF_SUCCESS; -} - - -/** - * @brief Endpoint OUT event handler - * - * @param[in] p_inst Generic class instance - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t endpoint_out_event_handler(app_usbd_class_inst_t const * p_inst) -{ - user_event_handler(p_inst, APP_USBD_AUDIO_USER_EVT_RX_DONE); - return NRF_SUCCESS; -} - -/** -* @brief Auxiliary function to access isochronous endpoint address -* -* @param[in] p_inst Class instance data -* -* @return ISO endpoint address -*/ -static inline nrf_drv_usbd_ep_t ep_iso_addr_get(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_class_iface_conf_t const * class_iface; - class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_AUDIO_STREAMING_IFACE_IDX); - - app_usbd_class_ep_conf_t const * ep_cfg; - ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_AUDIO_STREAMING_EP_IDX); - - return app_usbd_class_ep_address_get(ep_cfg); -} - -/** - * @brief @ref app_usbd_class_methods_t::event_handler - */ -static ret_code_t audio_event_handler( - app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - ASSERT(p_inst != NULL); - ASSERT(p_event != NULL); - - ret_code_t ret = NRF_SUCCESS; - switch (p_event->app_evt.type) - { - case APP_USBD_EVT_DRV_RESET: - break; - case APP_USBD_EVT_DRV_SETUP: - ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *)p_event); - break; - case APP_USBD_EVT_DRV_EPTRANSFER: - if (NRF_USBD_EPIN_CHECK(p_event->drv_evt.data.eptransfer.ep)) - { - ret = endpoint_in_event_handler(p_inst); - } - else - { - ret = endpoint_out_event_handler(p_inst); - } - break; - case APP_USBD_EVT_DRV_SUSPEND: - break; - case APP_USBD_EVT_DRV_RESUME: - break; - case APP_USBD_EVT_INST_APPEND: - break; - case APP_USBD_EVT_INST_REMOVE: - break; - case APP_USBD_EVT_STARTED: - break; - case APP_USBD_EVT_STOPPED: - break; - default: - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - - return ret; -} - -/** - * @brief @ref app_usbd_class_methods_t::get_descriptors - */ -static const void * audio_get_descriptors( - app_usbd_class_inst_t const * p_inst, - size_t * p_size) -{ - ASSERT(p_size != NULL); - app_usbd_audio_t const * p_audio = audio_get(p_inst); - - *p_size = p_audio->specific.inst.raw_desc_size; - return p_audio->specific.inst.p_raw_desc; -} - -/** @} */ - -const app_usbd_class_methods_t app_usbd_audio_class_methods = { - .event_handler = audio_event_handler, - .get_descriptors = audio_get_descriptors, - .iface_select = iface_select, - .iface_deselect = iface_deselect, - .iface_selection_get = iface_selection_get, -}; - - -size_t app_usbd_audio_class_rx_size_get(app_usbd_class_inst_t const * p_inst) -{ - nrf_drv_usbd_ep_t ep_addr; - ep_addr = ep_iso_addr_get(p_inst); - ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); - - return (size_t)nrf_drv_usbd_epout_size_get(ep_addr); -} - -ret_code_t app_usbd_audio_class_rx_start( - app_usbd_class_inst_t const * p_inst, - void * p_buff, - size_t size) -{ - nrf_drv_usbd_ep_t ep_addr; - ep_addr = ep_iso_addr_get(p_inst); - ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); - - NRF_DRV_USBD_TRANSFER_OUT(transfer, p_buff, size); - return app_usbd_ep_transfer(ep_addr, &transfer); -} - -ret_code_t app_usbd_audio_class_tx_start( - app_usbd_class_inst_t const * p_inst, - const void * p_buff, - size_t size) -{ - nrf_drv_usbd_ep_t ep_addr; - ep_addr = ep_iso_addr_get(p_inst); - ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); - - NRF_DRV_USBD_TRANSFER_IN(transfer, p_buff, size); - return app_usbd_ep_transfer(ep_addr, &transfer); -} - -#endif //APP_USBD_CLASS_AUDIO_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_internal.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_internal.h deleted file mode 100644 index a3a9060..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_internal.h +++ /dev/null @@ -1,231 +0,0 @@ -/** - * Copyright (c) 2016 - 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 APP_USBD_AUDIO_INTERNAL_H__ -#define APP_USBD_AUDIO_INTERNAL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * @defgroup app_usbd_audio_internal USB Audio internals - * @brief @tagAPI52840 USB Audio class internals. - * @ingroup app_usbd_audio - * @{ - */ - -/** - * @brief Forward declaration of type defined by @ref APP_USBD_CLASS_TYPEDEF in audio class - * - */ -APP_USBD_CLASS_FORWARD(app_usbd_audio); - -/*lint -save -e165*/ -/** - * @brief Forward declaration of @ref app_usbd_audio_user_event_e - * - */ -enum app_usbd_audio_user_event_e; - -/*lint -restore*/ - -/** - * @brief User event handler - * - * @param[in] p_inst Class instance - * @param[in] event User event - * - */ -typedef void (*app_usbd_audio_user_ev_handler_t)(app_usbd_class_inst_t const * p_inst, - enum app_usbd_audio_user_event_e event); - -/** - * @brief Audio class part of class instance data - */ -typedef struct { - uint8_t const * p_raw_desc; //!< Audio class descriptors - size_t raw_desc_size; //!< Audio class descriptors size - - app_usbd_audio_user_ev_handler_t user_ev_handler; //!< User event handler -} app_usbd_audio_inst_t; - -/** - * @brief Audio class request target - */ -typedef enum { - APP_USBD_AUDIO_CLASS_REQ_IN, /**< Audio class request IN */ - APP_USBD_AUDIO_CLASS_REQ_OUT, /**< Audio class request OUT */ - APP_USBD_AUDIO_EP_REQ_IN, /**< Audio class endpoint request IN */ - APP_USBD_AUDIO_EP_REQ_OUT, /**< Audio class endpoint request OUT */ -} app_usbd_audio_class_req_target_t; - -/** - * @brief Audio class specific request handled via control endpoint - */ -typedef struct { - app_usbd_audio_class_req_target_t req_target; //!< Request target - app_usbd_audio_req_type_t req_type; //!< Request type - - uint8_t control; //!< Request control field - uint8_t channel; //!< Channel ID - uint8_t interface; //!< Interface ID - uint8_t entity; //!< Entity ID - uint16_t length; //!< Request payload length - - uint8_t payload[64]; //!< Request payload -} app_usbd_audio_req_t; - - -/** - * @brief Audio class context - * - */ -typedef struct { - app_usbd_audio_req_t request; //!< Audio class request - bool streaming; //!< Streaming flag -} app_usbd_audio_ctx_t; - - -/** - * @brief Audio class configuration macro - * - * Used by @ref APP_USBD_AUDIO_GLOBAL_DEF - * - * @param iface_control Interface number of audio control - * @param iface_stream Interface number of audio stream - */ -#define APP_USBD_AUDIO_CONFIG(iface_control, iface_stream) \ - ((iface_control), \ - (iface_stream, 0)) - -/** - * @brief Only IN audio stream configuration - * - * @param iface_control Interface number of audio control - * @param iface_stream_in Interface number of audio stream on IN endpoint - */ -#define APP_USBD_AUDIO_CONFIG_IN(iface_control, iface_stream_in) \ - ((iface_control), (iface_stream_in, NRF_DRV_USBD_EPIN8)) - - -/** - * @brief Only OUT audio stream configuration - * - * @param iface_control Interface number of audio control - * @param iface_stream_out Interface number of audio stream on OUT endpoint - */ -#define APP_USBD_AUDIO_CONFIG_OUT(iface_control, iface_stream_out) \ - ((iface_control), (iface_stream_out, NRF_DRV_USBD_EPOUT8)) - -/** - * @brief Specific class constant data for audio class - * - * @ref app_usbd_audio_inst_t - */ -#define APP_USBD_AUDIO_INSTANCE_SPECIFIC_DEC app_usbd_audio_inst_t inst; - - -/** - * @brief Configures audio class instance - * - * @param descriptors Mass storage class descriptors (raw table) - * @param user_event_handler User event handler - */ -#define APP_USBD_AUDIO_INST_CONFIG(descriptors, user_event_handler) \ - .inst = { \ - .p_raw_desc = descriptors, \ - .raw_desc_size = sizeof(descriptors), \ - .user_ev_handler = user_event_handler, \ - } - -/** - * @brief Specific class data for audio class - * - * @ref app_usbd_audio_ctx_t - */ -#define APP_USBD_AUDIO_DATA_SPECIFIC_DEC app_usbd_audio_ctx_t ctx; - - -/** - * @brief Audio class descriptors config macro - * - * @param interface_number Interface number - * @param ... Extracted endpoint list - */ -#define APP_USBD_AUDIO_DSC_CONFIG(interface_number, ...) { \ - APP_USBD_AUDIO_INTERFACE_DSC(interface_number, \ - 0, \ - 0, \ - APP_USBD_AUDIO_SUBCLASS_AUDIOCONTROL) \ - } - -/** - * @brief Public audio class interface - * - */ -extern const app_usbd_class_methods_t app_usbd_audio_class_methods; - -/** - * @brief Global definition of @ref app_usbd_audio_t class - * - */ -#define APP_USBD_AUDIO_GLOBAL_DEF_INTERNAL(instance_name, \ - interfaces_configs, \ - user_ev_handler, \ - raw_descriptors) \ - APP_USBD_CLASS_INST_GLOBAL_DEF( \ - instance_name, \ - app_usbd_audio, \ - &app_usbd_audio_class_methods, \ - interfaces_configs, \ - (APP_USBD_AUDIO_INST_CONFIG(raw_descriptors, \ - user_ev_handler)) \ - ) - - -/** @} */ - - -#ifdef __cplusplus -} -#endif - -#endif /* APP_USBD_AUDIO_INTERNAL_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c deleted file mode 100644 index ce662bc..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c +++ /dev/null @@ -1,724 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if APP_USBD_CLASS_CDC_ACM_ENABLED -#include "app_usbd_cdc_acm.h" -#include - -/** - * @defgroup app_usbd_cdc_acm_internal CDC ACM internals - * @{ - * @ingroup app_usbd_cdc - * @internal - */ - - -#define NRF_LOG_MODULE_NAME cdc_acm - -#if APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#else //APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#define APP_USBD_CDC_ACM_COMM_IFACE_IDX 0 /**< CDC ACM class comm interface index. */ -#define APP_USBD_CDC_ACM_DATA_IFACE_IDX 1 /**< CDC ACM class data interface index. */ - -#define APP_USBD_CDC_ACM_COMM_EPIN_IDX 0 /**< CDC ACM comm class endpoint IN index. */ -#define APP_USBD_CDC_ACM_DATA_EPIN_IDX 0 /**< CDC ACM data class endpoint IN index. */ -#define APP_USBD_CDC_ACM_DATA_EPOUT_IDX 1 /**< CDC ACM data class endpoint OUT index. */ - -/** - * @brief Auxiliary function to access cdc_acm class instance data. - * - * @param[in] p_inst Class instance data. - * - * @return CDC ACM class instance. - */ -static inline app_usbd_cdc_acm_t const * cdc_acm_get(app_usbd_class_inst_t const * p_inst) -{ - ASSERT(p_inst != NULL); - return (app_usbd_cdc_acm_t const *)p_inst; -} - -/** - * @brief Auxiliary function to access cdc_acm class context data. - * - * @param[in] p_cdc_acm CDC ACM class instance data. - * - * @return CDC ACM class instance context. - */ -static inline app_usbd_cdc_acm_ctx_t * cdc_acm_ctx_get(app_usbd_cdc_acm_t const * p_cdc_acm) -{ - ASSERT(p_cdc_acm != NULL); - ASSERT(p_cdc_acm->specific.p_data != NULL); - return &p_cdc_acm->specific.p_data->ctx; -} - -/** - * @brief User event handler. - * - * @param[in] p_inst Class instance. - * @param[in] event user Event type. - */ -static inline void user_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_cdc_acm_user_event_t event) -{ - app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); - if (p_cdc_acm->specific.inst.user_ev_handler != NULL) - { - p_cdc_acm->specific.inst.user_ev_handler(p_inst, event); - } -} - -/** - * @brief Auxiliary function to access CDC ACM COMM IN endpoint address. - * - * @param[in] p_inst Class instance data. - * - * @return IN endpoint address. - */ -static inline nrf_drv_usbd_ep_t comm_ep_in_addr_get(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_class_iface_conf_t const * class_iface; - class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_CDC_ACM_COMM_IFACE_IDX); - - app_usbd_class_ep_conf_t const * ep_cfg; - ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_ACM_COMM_EPIN_IDX); - - return app_usbd_class_ep_address_get(ep_cfg); -} - -/** - * @brief Auxiliary function to access CDC ACM DATA IN endpoint address. - * - * @param[in] p_inst Class instance data. - * - * @return IN endpoint address. - */ -static inline nrf_drv_usbd_ep_t data_ep_in_addr_get(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_class_iface_conf_t const * class_iface; - class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_CDC_ACM_DATA_IFACE_IDX); - - app_usbd_class_ep_conf_t const * ep_cfg; - ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_ACM_DATA_EPIN_IDX); - - return app_usbd_class_ep_address_get(ep_cfg); -} - -/** - * @brief Auxiliary function to access CDC ACM DATA OUT endpoint address. - * - * @param[in] p_inst Class instance data. - * - * @return OUT endpoint address. - */ -static inline nrf_drv_usbd_ep_t data_ep_out_addr_get(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_class_iface_conf_t const * class_iface; - class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_CDC_ACM_DATA_IFACE_IDX); - - app_usbd_class_ep_conf_t const * ep_cfg; - ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_ACM_DATA_EPOUT_IDX); - - return app_usbd_class_ep_address_get(ep_cfg); -} - -/** - * @brief Internal SETUP standard IN request handler. - * - * @param[in] p_inst Generic class instance. - * @param[in] p_setup_ev Setup event. - * - * @return Standard error code. - */ -static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR: - { - size_t dsc_len = 0; - - /* Try to find descriptor in class internals*/ - void const * p_dsc = app_usbd_class_descriptor_find(p_inst, - p_setup_ev->setup.wValue.hb, - p_setup_ev->setup.wValue.lb, - &dsc_len); - if (p_dsc != NULL) - { - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_dsc, dsc_len); - } - - break; - } - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Internal SETUP standard OUT request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code. - */ -static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - - switch (p_setup_ev->setup.bmRequest) - { - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Internal SETUP class IN request handler. - * - * @param[in] p_inst Generic class instance. - * @param[in] p_setup_ev Setup event. - * - * @return Standard error code. - */ -static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_CDC_REQ_GET_LINE_CODING: - { - if (p_setup_ev->setup.wLength.w != sizeof(app_usbd_cdc_line_coding_t)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - return app_usbd_core_setup_rsp(&p_setup_ev->setup, - &p_cdc_acm_ctx->line_coding, - sizeof(app_usbd_cdc_line_coding_t)); - } - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Class specific OUT request data callback. - * - * @param status Endpoint status. - * @param p_context Context of transfer (set by @ref app_usbd_core_setup_data_handler_set). - * - * @return Standard error code. - */ -static ret_code_t cdc_acm_req_out_data_cb(nrf_drv_usbd_ep_status_t status, void * p_context) -{ - if (status != NRF_USBD_EP_OK) - { - return NRF_ERROR_INTERNAL; - } - - app_usbd_cdc_acm_t const * p_cdc_acm = p_context; - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - switch (p_cdc_acm_ctx->request.type) - { - case APP_USBD_CDC_REQ_SET_LINE_CODING: - { - memcpy(&p_cdc_acm_ctx->line_coding, - &p_cdc_acm_ctx->request.payload.line_coding, - sizeof(app_usbd_cdc_line_coding_t)); - - NRF_LOG_INFO("REQ_SET_LINE_CODING: baudrate: %"PRIu32", databits: %u, " - "format: %u, parity: %u", - uint32_decode(p_cdc_acm_ctx->line_coding.dwDTERate), - p_cdc_acm_ctx->line_coding.bDataBits, - p_cdc_acm_ctx->line_coding.bCharFormat, - p_cdc_acm_ctx->line_coding.bParityType); - break; - } - default: - return NRF_ERROR_NOT_SUPPORTED; - } - - return NRF_SUCCESS; -} - - -/** - * @brief Class specific request data stage setup. - * - * @param[in] p_inst Generic class instance. - * @param[in] p_setup_ev Setup event. - * - * @return Standard error code. - */ -static ret_code_t cdc_acm_req_out_datastage(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - p_cdc_acm_ctx->request.type = p_setup_ev->setup.bmRequest; - p_cdc_acm_ctx->request.len = p_setup_ev->setup.wLength.w; - - /*Request setup data*/ - NRF_DRV_USBD_TRANSFER_OUT(transfer, - &p_cdc_acm_ctx->request.payload, - p_cdc_acm_ctx->request.len); - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); - if (ret == NRF_SUCCESS) - { - const app_usbd_core_setup_data_handler_desc_t desc = { - .handler = cdc_acm_req_out_data_cb, - .p_context = (void*)p_cdc_acm - }; - - ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -/** - * @brief Internal SETUP class OUT request handler. - * - * @param[in] p_inst Generic class instance. - * @param[in] p_setup_ev Setup event. - * - * @return Standard error code. - */ -static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_CDC_REQ_SET_LINE_CODING: - { - if (p_setup_ev->setup.wLength.w != sizeof(app_usbd_cdc_line_coding_t)) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - return cdc_acm_req_out_datastage(p_inst, p_setup_ev); - } - case APP_USBD_CDC_REQ_SET_CONTROL_LINE_STATE: - { - if (p_setup_ev->setup.wLength.w != 0) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - NRF_LOG_INFO("REQ_SET_CONTROL_LINE_STATE: 0x%x", p_setup_ev->setup.wValue.w); - - bool old_dtr = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? - true : false; - p_cdc_acm_ctx->line_state = p_setup_ev->setup.wValue.w; - - bool new_dtr = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? - true : false; - - if (old_dtr == new_dtr) - { - return NRF_SUCCESS; - } - - const app_usbd_cdc_acm_user_event_t ev = new_dtr ? - APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN : APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE; - - user_event_handler(p_inst, ev); - - if (!new_dtr) - { - /*Abort DATA endpoints on port close */ - nrf_drv_usbd_ep_t ep; - ep = data_ep_in_addr_get(p_inst); - nrf_drv_usbd_ep_abort(ep); - ep = data_ep_out_addr_get(p_inst); - nrf_drv_usbd_ep_abort(ep); - } - - return NRF_SUCCESS; - } - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Control endpoint handler. - * - * @param[in] p_inst Generic class instance. - * @param[in] p_setup_ev Setup event. - * - * @return Standard error code. - */ -static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - ASSERT(p_inst != NULL); - ASSERT(p_setup_ev != NULL); - - if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) - { - switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) - { - case APP_USBD_SETUP_REQTYPE_STD: - return setup_req_std_in(p_inst, p_setup_ev); - case APP_USBD_SETUP_REQTYPE_CLASS: - return setup_req_class_in(p_inst, p_setup_ev); - default: - break; - } - } - else /*APP_USBD_SETUP_REQDIR_OUT*/ - { - switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) - { - case APP_USBD_SETUP_REQTYPE_STD: - return setup_req_std_out(p_inst, p_setup_ev); - case APP_USBD_SETUP_REQTYPE_CLASS: - return setup_req_class_out(p_inst, p_setup_ev); - default: - break; - } - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Class specific endpoint transfer handler. - * - * @param[in] p_inst Generic class instance. - * @param[in] p_setup_ev Setup event. - * - * @return Standard error code. - */ -static ret_code_t cdc_acm_endpoint_ev(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - if (comm_ep_in_addr_get(p_inst) == p_event->drv_evt.data.eptransfer.ep) - { - NRF_LOG_INFO("EPIN_COMM: notify"); - return NRF_SUCCESS; - } - - if (NRF_USBD_EPIN_CHECK(p_event->drv_evt.data.eptransfer.ep)) - { - switch (p_event->drv_evt.data.eptransfer.status) - { - case NRF_USBD_EP_OK: - NRF_LOG_INFO("EPIN_DATA: %02x done", p_event->drv_evt.data.eptransfer.ep); - user_event_handler(p_inst, APP_USBD_CDC_ACM_USER_EVT_TX_DONE); - return NRF_SUCCESS; - case NRF_USBD_EP_ABORTED: - return NRF_SUCCESS; - default: - return NRF_ERROR_INTERNAL; - } - } - - if (NRF_USBD_EPOUT_CHECK(p_event->drv_evt.data.eptransfer.ep)) - { - switch (p_event->drv_evt.data.eptransfer.status) - { - case NRF_USBD_EP_OK: - NRF_LOG_INFO("EPOUT_DATA: %02x done", p_event->drv_evt.data.eptransfer.ep); - user_event_handler(p_inst, APP_USBD_CDC_ACM_USER_EVT_RX_DONE); - return NRF_SUCCESS; - case NRF_USBD_EP_WAITING: - case NRF_USBD_EP_ABORTED: - return NRF_SUCCESS; - default: - return NRF_ERROR_INTERNAL; - } - } - - return NRF_ERROR_NOT_SUPPORTED; -} - - -/** - * @brief @ref app_usbd_class_methods_t::event_handler - */ -static ret_code_t cdc_acm_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - ASSERT(p_inst != NULL); - ASSERT(p_event != NULL); - - ret_code_t ret = NRF_SUCCESS; - switch (p_event->app_evt.type) - { - case APP_USBD_EVT_DRV_SOF: - break; - case APP_USBD_EVT_DRV_RESET: - break; - case APP_USBD_EVT_DRV_SETUP: - ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *)p_event); - break; - case APP_USBD_EVT_DRV_EPTRANSFER: - ret = cdc_acm_endpoint_ev(p_inst, p_event); - break; - case APP_USBD_EVT_DRV_SUSPEND: - break; - case APP_USBD_EVT_DRV_RESUME: - break; - case APP_USBD_EVT_INST_APPEND: - { - ret = app_usbd_class_sof_register(p_inst); - break; - } - case APP_USBD_EVT_INST_REMOVE: - { - ret = app_usbd_class_sof_unregister(p_inst); - break; - } - case APP_USBD_EVT_STARTED: - break; - case APP_USBD_EVT_STOPPED: - break; - default: - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - - return ret; -} - -/** - * @brief @ref app_usbd_class_methods_t::get_descriptors - */ -static const void * cdc_acm_get_descriptors(app_usbd_class_inst_t const * p_inst, - size_t * p_size) -{ - ASSERT(p_size != NULL); - app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); - - *p_size = p_cdc_acm->specific.inst.raw_desc_size; - return p_cdc_acm->specific.inst.p_raw_desc; -} - -/** - * @brief Public cdc_acm class interface - * - */ -const app_usbd_class_methods_t app_usbd_cdc_acm_class_methods = { - .event_handler = cdc_acm_event_handler, - .get_descriptors = cdc_acm_get_descriptors, -}; - - -ret_code_t app_usbd_cdc_acm_write(app_usbd_cdc_acm_t const * p_cdc_acm, - const void * p_buf, - size_t length) -{ - app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - bool dtr_state = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? - true : false; - if (!dtr_state) - { - /*Port is not opened*/ - return NRF_ERROR_INVALID_STATE; - } - - nrf_drv_usbd_ep_t ep = data_ep_in_addr_get(p_inst); - NRF_DRV_USBD_TRANSFER_IN(transfer, p_buf, length); - return app_usbd_ep_transfer(ep, &transfer); -} - -size_t app_usbd_cdc_acm_rx_size(app_usbd_cdc_acm_t const * p_cdc_acm) -{ - app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); - nrf_drv_usbd_ep_t ep = data_ep_out_addr_get(p_inst); - - size_t size; - ret_code_t ret = nrf_drv_usbd_ep_status_get(ep, &size); - if (ret != NRF_SUCCESS) - { - return 0; - } - - return size; -} - -ret_code_t app_usbd_cdc_acm_read(app_usbd_cdc_acm_t const * p_cdc_acm, - void * p_buf, - size_t length) -{ - ASSERT((length % NRF_DRV_USBD_EPSIZE) == 0); - app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - bool dtr_state = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? - true : false; - if (!dtr_state) - { - /*Port is not opened*/ - return NRF_ERROR_INVALID_STATE; - } - - nrf_drv_usbd_ep_t ep = data_ep_out_addr_get(p_inst); - NRF_DRV_USBD_TRANSFER_OUT(transfer, p_buf, length); - return app_usbd_ep_transfer(ep, &transfer); -} - -static ret_code_t cdc_acm_serial_state_notify(app_usbd_cdc_acm_t const * p_cdc_acm) -{ - app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - nrf_drv_usbd_ep_t ep = comm_ep_in_addr_get(p_inst); - - NRF_DRV_USBD_TRANSFER_OUT(transfer, - &p_cdc_acm_ctx->request.payload, - sizeof(app_usbd_cdc_acm_notify_t)); - return app_usbd_ep_transfer(ep, &transfer); -} - -ret_code_t app_usbd_cdc_acm_serial_state_notify(app_usbd_cdc_acm_t const * p_cdc_acm, - app_usbd_cdc_acm_serial_state_t serial_state, - bool value) -{ - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = NRF_SUCCESS; - switch (serial_state) - { - case APP_USBD_CDC_ACM_SERIAL_STATE_DCD: - case APP_USBD_CDC_ACM_SERIAL_STATE_DSR: - case APP_USBD_CDC_ACM_SERIAL_STATE_BREAK: - case APP_USBD_CDC_ACM_SERIAL_STATE_RING: - case APP_USBD_CDC_ACM_SERIAL_STATE_FRAMING: - case APP_USBD_CDC_ACM_SERIAL_STATE_PARITY: - case APP_USBD_CDC_ACM_SERIAL_STATE_OVERRUN: - - if (value) - { - p_cdc_acm_ctx->serial_state |= serial_state; - } - else - { - p_cdc_acm_ctx->serial_state &= ~serial_state; - } - - break; - default: - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - - if (ret == NRF_SUCCESS) - { - app_usbd_cdc_acm_notify_t * notify = &p_cdc_acm_ctx->request.payload.notify; - notify->cdc_notify.bmRequestType = app_usbd_setup_req_val(APP_USBD_SETUP_REQREC_INTERFACE, - APP_USBD_SETUP_REQTYPE_CLASS, - APP_USBD_SETUP_REQDIR_IN); - notify->cdc_notify.bmRequest = APP_USBD_CDC_NOTIF_SERIAL_STATE; - notify->cdc_notify.wValue = 0; - notify->cdc_notify.wIndex = 0; - notify->cdc_notify.wLength = sizeof(notify->serial_state); - - notify->serial_state = p_cdc_acm_ctx->serial_state; - - ret = cdc_acm_serial_state_notify(p_cdc_acm); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -ret_code_t app_usbd_cdc_acm_line_state_get(app_usbd_cdc_acm_t const * p_cdc_acm, - app_usbd_cdc_acm_line_state_t line_state, - uint32_t * value) -{ - app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = NRF_SUCCESS; - switch (line_state) - { - case APP_USBD_CDC_ACM_LINE_STATE_DTR: - case APP_USBD_CDC_ACM_LINE_STATE_RTS: - *value = (p_cdc_acm_ctx->line_state & line_state) != 0; - break; - default: - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -#endif /* APP_USBD_CLASS_CDC_ACM_ENABLED */ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h deleted file mode 100644 index 9ffa5af..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Copyright (c) 2016 - 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 APP_USBD_CDC_ACM_INTERNAL_H__ -#define APP_USBD_CDC_ACM_INTERNAL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -#include "app_util.h" - -/** - * @defgroup app_usbd_cdc_acm_internal USB CDC ACM internals - * @ingroup app_usbd_cdc_acm - * @brief @tagAPI52840 Internals of the USB ACM class implementation. - * @{ - */ - -/** - * @brief Forward declaration of type defined by @ref APP_USBD_CLASS_TYPEDEF in cdc_acm class. - * - */ -APP_USBD_CLASS_FORWARD(app_usbd_cdc_acm); - -/*lint -save -e165*/ -/** - * @brief Forward declaration of @ref app_usbd_cdc_acm_user_event_e. - * - */ -enum app_usbd_cdc_acm_user_event_e; - -/*lint -restore*/ - -/** - * @brief User event handler. - * - * @param[in] p_inst Class instance. - * @param[in] event User event. - * - */ -typedef void (*app_usbd_cdc_acm_user_ev_handler_t)(app_usbd_class_inst_t const * p_inst, - enum app_usbd_cdc_acm_user_event_e event); - -/** - * @brief CDC ACM class part of class instance data. - */ -typedef struct { - uint8_t const * p_raw_desc; //!< CDC ACM class descriptors. - size_t raw_desc_size; //!< CDC ACM class descriptors size. - - app_usbd_cdc_acm_user_ev_handler_t user_ev_handler; //!< User event handler. -} app_usbd_cdc_acm_inst_t; - - -/** - * @brief CDC ACM serial state class notify - */ -typedef struct { - app_usbd_cdc_notify_t cdc_notify; //!< CDC notify. - uint16_t serial_state; //!< Serial port state. -} app_usbd_cdc_acm_notify_t; - -/** - * @brief CDC ACM class specific request handled via control endpoint. - */ -typedef struct { - uint8_t type; //!< Request type. - uint8_t len; //!< Request length. - - union { - app_usbd_cdc_line_coding_t line_coding; //!< CDC ACM current line coding. - app_usbd_cdc_acm_notify_t notify; //!< CDC ACM class notify. - } payload; -} app_usbd_cdc_acm_req_t; - - -/** - * @brief CDC ACM class context - */ -typedef struct { - app_usbd_cdc_acm_req_t request; //!< CDC ACM class request. - app_usbd_cdc_line_coding_t line_coding; //!< CDC ACM current line coding. - - uint16_t line_state; //!< CDC ACM line state bitmap, DTE side. - uint16_t serial_state; //!< CDC ACM serial state bitmap, DCE side. -} app_usbd_cdc_acm_ctx_t; - - -/** - * @brief CDC ACM class configuration macro. - * - * Used by @ref APP_USBD_CDC_ACM_GLOBAL_DEF - * - * @param iface_comm Interface number of cdc_acm control. - * @param epin_comm COMM subclass IN endpoint. - * @param iface_data Interface number of cdc_acm DATA. - * @param epin_data COMM subclass IN endpoint. - * @param epout_data COMM subclass OUT endpoint. - * - */ -#define APP_USBD_CDC_ACM_CONFIG(iface_comm, epin_comm, iface_data, epin_data, epout_data) \ - ((iface_comm, epin_comm), \ - (iface_data, epin_data, epout_data)) - - -/** - * @brief Specific class constant data for cdc_acm class. - * - * @ref app_usbd_cdc_acm_inst_t - */ -#define APP_USBD_CDC_ACM_INSTANCE_SPECIFIC_DEC app_usbd_cdc_acm_inst_t inst; - - -/** - * @brief Configures cdc_acm class instance. - * - * @param descriptors Mass storage class descriptors (raw table). - * @param user_event_handler User event handler. - */ -#define APP_USBD_CDC_ACM_INST_CONFIG(descriptors, user_event_handler) \ - .inst = { \ - .p_raw_desc = descriptors, \ - .raw_desc_size = sizeof(descriptors), \ - .user_ev_handler = user_event_handler, \ - } - -/** - * @brief Specific class data for cdc_acm class. - * - * @ref app_usbd_cdc_acm_ctx_t - */ -#define APP_USBD_CDC_ACM_DATA_SPECIFIC_DEC app_usbd_cdc_acm_ctx_t ctx; - - -/** - * @brief CDC ACM class descriptors config macro. - * - * @param interface_number Interface number. - * @param ... Extracted endpoint list. - */ -#define APP_USBD_CDC_ACM_DSC_CONFIG(interface_number, ...) { \ - APP_USBD_CDC_ACM_INTERFACE_DSC(interface_number, \ - 0, \ - 0, \ - APP_USBD_CDC_ACM_SUBCLASS_CDC_ACMCONTROL) \ -} - -/** - * @brief Public cdc_acm class interface. - * - */ -extern const app_usbd_class_methods_t app_usbd_cdc_acm_class_methods; - -/** - * @brief Global definition of @ref app_usbd_cdc_acm_t class. - * - * @param instance_name Name of global instance. - * @param interfaces_configs Interfaces configurations. - * @param user_ev_handler User event handler (optional). - * @param raw_descriptors Raw descriptor table. - */ -#define APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL(instance_name, \ - interfaces_configs, \ - user_ev_handler, \ - raw_descriptors) \ - APP_USBD_CLASS_INST_GLOBAL_DEF( \ - instance_name, \ - app_usbd_cdc_acm, \ - &app_usbd_cdc_acm_class_methods, \ - interfaces_configs, \ - (APP_USBD_CDC_ACM_INST_CONFIG(raw_descriptors, user_ev_handler)) \ - ) - - -/** @} */ - - - -#ifdef __cplusplus -} -#endif - -#endif /* APP_USBD_CDC_ACM_INTERNAL_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c deleted file mode 100644 index 8391b6b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c +++ /dev/null @@ -1,343 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if APP_USBD_HID_GENERIC_ENABLED -#include - -#include "sdk_common.h" -#include "app_usbd_hid_generic.h" -#include "app_util_platform.h" - - -/** - * @ingroup app_usbd_hid_generic - * - * Module with types, definitions and API used by HID generic. - * @{ - */ - -/** - * @brief Auxiliary function to access HID generic context data. - * - * @param[in] p_generic HID generic instance. - * - * @return HID generic class instance data context. - */ -static inline app_usbd_hid_generic_ctx_t * -hid_generic_ctx_get(app_usbd_hid_generic_t const * p_generic) -{ - ASSERT(p_generic != NULL); - ASSERT(p_generic->specific.p_data != NULL); - return &p_generic->specific.p_data->ctx; -} - -/** - * @brief Auxiliary function to access HID generic instance data. - * - * @param[in] p_inst Class instance data. - * - * @return HID generic class instance data. - */ -static inline app_usbd_hid_generic_t const * -hid_generic_get(app_usbd_class_inst_t const * p_inst) -{ - ASSERT(p_inst != NULL); - return (app_usbd_hid_generic_t const *)p_inst; -} - - -/** - * @brief Returns report ID buffer descriptor. - * - * @param[in] p_generic Internal HID generic context. - * - * @return HID report buffer. - */ -static inline app_usbd_hid_report_buffer_t * -hid_generic_rep_buffer_get(app_usbd_hid_generic_t const * p_generic) -{ - ASSERT(p_generic != NULL); - app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; - - return app_usbd_hid_rep_buff_in_get(p_hinst); -} - -/** - * @brief Auxiliary function to prepare report transfer buffer to next transfer. - * - * @param[in] p_generic HID generic instance. - * - * @retval true Next transfer required. - * @retval false Next transfer not required. - */ -static inline bool hid_generic_transfer_next(app_usbd_hid_generic_t const * p_generic) -{ - nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; - return !nrf_queue_is_empty(p_rep_in_queue); -} - - -/** - * @brief Triggers IN endpoint transfer. - * - * @param[in] p_generic HID generic instance. - * - * @return Standard error code. - */ -static inline ret_code_t hid_generic_transfer_set(app_usbd_hid_generic_t const * p_generic) -{ - app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_generic; - app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); - - nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); - app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, - APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); - - if (!hid_generic_transfer_next(p_generic)) - { - return NRF_SUCCESS; - } - - app_usbd_hid_report_buffer_t * p_rep_buff = hid_generic_rep_buffer_get(p_generic); - nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; - - ret_code_t ret = nrf_queue_pop(p_rep_in_queue, p_rep_buff); - ASSERT(ret == NRF_SUCCESS); - - NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buff->p_buff, p_rep_buff->size); - CRITICAL_REGION_ENTER(); - ret = app_usbd_ep_transfer(ep_addr, &transfer); - if (ret == NRF_SUCCESS) - { - app_usbd_hid_state_flag_set(&p_generic_ctx->hid_ctx, - APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -ret_code_t app_usbd_hid_generic_in_report_set(app_usbd_hid_generic_t const * p_generic, - const void * p_buff, - size_t size) -{ - app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); - nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; - const app_usbd_hid_report_buffer_t rep_buff = { - .p_buff = (void *)p_buff, - .size = size, - }; - - if (nrf_queue_push(p_rep_in_queue, &rep_buff) != NRF_SUCCESS) - { - return NRF_ERROR_BUSY; - } - - ret_code_t ret = NRF_SUCCESS; - if (app_usbd_hid_trans_required(&p_generic_ctx->hid_ctx)) - { - ret = hid_generic_transfer_set(p_generic); - } - - return ret; -} - -const void * app_usbd_hid_generic_in_report_get(app_usbd_hid_generic_t const * p_generic, - size_t * p_size) -{ - app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; - *p_size = p_hinst->p_rep_buffer_in->size; - return p_hinst->p_rep_buffer_in->p_buff; -} - -const void * app_usbd_hid_generic_out_report_get(app_usbd_hid_generic_t const * p_generic, - size_t * p_size) -{ - app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; - *p_size = p_hinst->p_rep_buffer_out->size; - return p_hinst->p_rep_buffer_out->p_buff; -} - -/** - * @brief @ref app_usbd_hid_interface_t::on_get_report - */ -static ret_code_t hid_generic_on_get_report(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - return NRF_ERROR_NOT_SUPPORTED; -} - - -static ret_code_t hid_generic_on_set_report_data_cb(nrf_drv_usbd_ep_status_t status, - void * p_context) -{ - app_usbd_hid_user_ev_handler_t handler; - app_usbd_hid_generic_t const * p_generic = (app_usbd_hid_generic_t const *)p_context; - - if (status != NRF_USBD_EP_OK) - { - return NRF_ERROR_INTERNAL; - } - - handler = p_generic->specific.inst.hid_inst.user_event_handler; - handler((app_usbd_class_inst_t const *)p_generic, - APP_USBD_HID_USER_EVT_OUT_REPORT_READY); - return NRF_SUCCESS; -} - - - -/** - * @brief @ref app_usbd_hid_interface_t::on_set_report - */ -static ret_code_t hid_generic_on_set_report(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); - - /*Request setup data*/ - app_usbd_hid_report_buffer_t const * p_rep_buff; - p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_generic->specific.inst.hid_inst); - - p_rep_buff->p_buff[0] = p_setup_ev->setup.wValue.lb; - NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1); - - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); - if (ret == NRF_SUCCESS) - { - app_usbd_core_setup_data_handler_desc_t desc = { - .handler = hid_generic_on_set_report_data_cb, - .p_context = (void*)p_generic - }; - - ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -/** - * @brief @ref app_usbd_hid_interface_t::ep_transfer_in - */ -static ret_code_t hid_generic_ep_transfer_in(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); - app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); - - nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; - - if (nrf_queue_is_empty(p_rep_in_queue)) - { - app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, - APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); - return NRF_SUCCESS; - } - - /* Get next report to send */ - return hid_generic_transfer_set((app_usbd_hid_generic_t const *)p_inst); -} - -/** - * @brief @ref app_usbd_hid_interface_t::ep_transfer_out - */ -static ret_code_t hid_generic_ep_transfer_out(app_usbd_class_inst_t const * p_inst) -{ - - app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); - nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epout_addr_get(p_inst); - - /*Request setup data*/ - app_usbd_hid_report_buffer_t const * p_rep_buff; - p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_generic->specific.inst.hid_inst); - NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff, p_rep_buff->size); - - return app_usbd_ep_transfer(ep_addr, &transfer); -} - -/** - * @brief @ref app_usbd_class_interface_t::event_handler - */ -static ret_code_t hid_generic_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - ASSERT(p_inst != NULL); - ASSERT(p_event != NULL); - - app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); - app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; - app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); - app_usbd_hid_ctx_t * p_hid_ctx = &p_generic_ctx->hid_ctx; - - /*Try handle event by generic HID event handler*/ - return app_usbd_hid_event_handler(p_inst, p_hinst, p_hid_ctx, p_event); -} - -/** - * @brief @ref app_usbd_class_interface_t::get_descriptors - */ -static const void * hid_generic_get_descriptors(app_usbd_class_inst_t const * p_inst, - size_t * p_size) -{ - ASSERT(p_size != NULL); - app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); - app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; - - *p_size = p_hinst->raw_desc_size; - return p_hinst->p_raw_desc; -} - -/** @} */ - -const app_usbd_hid_methods_t app_usbd_hid_generic_methods = { - .on_get_report = hid_generic_on_get_report, - .on_set_report = hid_generic_on_set_report, - .ep_transfer_in = hid_generic_ep_transfer_in, - .ep_transfer_out = hid_generic_ep_transfer_out, -}; - -const app_usbd_class_methods_t app_usbd_generic_class_methods = { - .event_handler = hid_generic_event_handler, - .get_descriptors = hid_generic_get_descriptors, -}; - -#endif // APP_USBD_HID_GENERIC_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c deleted file mode 100644 index f87987e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c +++ /dev/null @@ -1,392 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if APP_USBD_HID_KBD_ENABLED -#include - -#include "sdk_common.h" -#include "app_usbd_hid_kbd.h" -#include "app_util_platform.h" - - -/** - * @defgroup app_usbd_hid_kbd_internals USB HID keyboard internals - * @{ - * @ingroup app_usbd_hid_kbd - * @internal - */ - -STATIC_ASSERT(sizeof(app_usbd_hid_descriptor_t) == 6); - -/** - * @brief Auxiliary function to access HID keyboard context data. - * - * @param[in] p_inst class instance data. - * - * @return HID keyboard instance data context. - */ -static inline app_usbd_hid_kbd_ctx_t * hid_kbd_ctx_get(app_usbd_hid_kbd_t const * p_kbd) -{ - ASSERT(p_kbd != NULL); - ASSERT(p_kbd->specific.p_data != NULL); - return &p_kbd->specific.p_data->ctx; -} - -/** - * @brief Auxiliary function to access HID keyboard instance data. - * - * @param[in] p_inst class instance data. - * - * @return HID keyboard instance data. - */ -static inline app_usbd_hid_kbd_t const * hid_kbd_get(app_usbd_class_inst_t const * p_inst) -{ - ASSERT(p_inst != NULL); - return (app_usbd_hid_kbd_t const *)p_inst; -} - -/** - * @brief Returns keyboard report buffer handle. - * - * @param[in] p_kbd HID keyboard instance. - * - * @return HID report buffer. - */ -static inline -app_usbd_hid_report_buffer_t const * hid_kbd_rep_buffer_get(app_usbd_hid_kbd_t const * p_kbd) -{ - ASSERT(p_kbd != NULL); - app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - app_usbd_hid_report_buffer_t * p_rep_buff = app_usbd_hid_rep_buff_in_get(p_hinst); - - p_rep_buff->p_buff = p_kbd_ctx->report_buff; - p_rep_buff->size = sizeof(p_kbd_ctx->report_buff); - - /*Keyboard has only one report input/output report buffer */ - return p_rep_buff; -} - - -/** - * @brief Auxiliary function to prepare report transfer buffer to next transfer. - * - * @param[in] p_kbd HID keyboard instance. - * - * @retval true Next transfer is required. - * @retval false Next transfer is not required. - */ -static inline bool hid_kbd_transfer_next(app_usbd_hid_kbd_t const * p_kbd) -{ - /*Send report only when state has changed*/ - app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - - if (memcmp(p_rep_buffer->p_buff, &p_kbd_ctx->rep, p_rep_buffer->size)) - { - memcpy(p_rep_buffer->p_buff, &p_kbd_ctx->rep, p_rep_buffer->size); - return true; - } - - return false; -} - - -/** - * @brief Triggers IN endpoint transfer. - * - * @param[in] p_kbd HID keyboard instance. - * - * @return Standard error code. - */ -static inline ret_code_t hid_kbd_transfer_set(app_usbd_hid_kbd_t const * p_kbd) -{ - app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_kbd; - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - - nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); - - app_usbd_hid_state_flag_clr(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); - - if (!hid_kbd_transfer_next(p_kbd)) - { - /* Transfer buffer hasn't changed since last transfer. No need to setup - * next transfer. - * */ - return NRF_SUCCESS; - } - - app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); - NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buffer->p_buff, p_rep_buffer->size); - - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = app_usbd_ep_transfer(ep_addr, &transfer); - if (ret == NRF_SUCCESS) - { - app_usbd_hid_state_flag_set(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -ret_code_t app_usbd_hid_kbd_modifier_state_set(app_usbd_hid_kbd_t const * p_kbd, - app_usbd_hid_kbd_modifier_t modifier, - bool state) -{ - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - bool actual_state = (p_kbd_ctx->rep.modifier & modifier) != 0; - - if (actual_state == state) - { - /*Modifier has already the same state*/ - return NRF_SUCCESS; - } - - app_usbd_hid_access_lock(&p_kbd_ctx->hid_ctx); - - if (state) - { - p_kbd_ctx->rep.modifier |= modifier; - } - else - { - p_kbd_ctx->rep.modifier &= ~modifier; - } - app_usbd_hid_access_unlock(&p_kbd_ctx->hid_ctx); - - if (app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx)) - { - /*New transfer need to be triggered*/ - return hid_kbd_transfer_set(p_kbd); - } - - return NRF_SUCCESS; -} - - -ret_code_t app_usbd_hid_kbd_key_control(app_usbd_hid_kbd_t const * p_kbd, - app_usbd_hid_kbd_codes_t key, - bool press) -{ - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - uint8_t * destination = NULL; - if (press) - { - for (size_t i = 0; i < ARRAY_SIZE(p_kbd_ctx->rep.key_table); ++i) { - if (p_kbd_ctx->rep.key_table[i] == key) - { - /*Already pressed*/ - return NRF_SUCCESS; - } - - if ((destination == NULL) && (p_kbd_ctx->rep.key_table[i] == 0)) - { - destination = &p_kbd_ctx->rep.key_table[i]; - } - } - - if (destination == NULL) - { - return NRF_ERROR_BUSY; - } - } - else - { - /*Find if key is pressed*/ - for (size_t i = 0; i < ARRAY_SIZE(p_kbd_ctx->rep.key_table); ++i) { - if (p_kbd_ctx->rep.key_table[i] == key) - { - destination = &p_kbd_ctx->rep.key_table[i]; - break; - } - } - - if (destination == NULL) - { - /*Key hasn't been pressed*/ - return NRF_SUCCESS; - } - } - - /*Save destination*/ - app_usbd_hid_access_lock(&p_kbd_ctx->hid_ctx); - *destination = press ? key : 0; - app_usbd_hid_access_unlock(&p_kbd_ctx->hid_ctx); - - if (app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx)) - { - /*New transfer need to be triggered*/ - return hid_kbd_transfer_set(p_kbd); - } - - return NRF_SUCCESS; -} - -bool app_usbd_hid_kbd_led_state_get(app_usbd_hid_kbd_t const * p_kbd, - app_usbd_hid_kbd_led_t led) -{ - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - - return (p_kbd_ctx->leds_state & led) != 0; -} - -/** - * @brief @ref app_usbd_hid_interface_t::on_get_report - */ -static ret_code_t hid_kbd_on_get_report(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); - app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); - - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_rep_buffer->p_buff, p_rep_buffer->size); -} - - -static ret_code_t hid_kbd_on_set_report_data_cb(nrf_drv_usbd_ep_status_t status, void * p_context) -{ - if (status != NRF_USBD_EP_OK) - { - return NRF_ERROR_INTERNAL; - } - - app_usbd_hid_kbd_t const * p_kbd = p_context; - app_usbd_hid_report_buffer_t const * p_rep_buff; - p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_kbd->specific.inst.hid_inst); - - /*Update LEDs state*/ - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - p_kbd_ctx->leds_state = p_rep_buff->p_buff[1]; - - app_usbd_hid_user_ev_handler_t handler = p_kbd->specific.inst.hid_inst.user_event_handler; - handler((app_usbd_class_inst_t const *)(p_kbd), APP_USBD_HID_USER_EVT_OUT_REPORT_READY); - return NRF_SUCCESS; -} - -/** - * @brief @ref app_usbd_hid_interface_t::hid_kbd_on_set_report - */ -static ret_code_t hid_kbd_on_set_report(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); - - /*Request setup data*/ - app_usbd_hid_report_buffer_t const * p_rep_buff; - p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_kbd->specific.inst.hid_inst); - - p_rep_buff->p_buff[0] = 0; - NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1); - - ret_code_t ret; - CRITICAL_REGION_ENTER(); - ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); - if (ret == NRF_SUCCESS) - { - app_usbd_core_setup_data_handler_desc_t desc = { - .handler = hid_kbd_on_set_report_data_cb, - .p_context = (app_usbd_hid_kbd_t *)p_kbd - }; - - ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); - } - CRITICAL_REGION_EXIT(); - - return ret; -} - -/** - * @brief @ref app_usbd_hid_interface_t::hid_kbd_ep_transfer_in - */ -static ret_code_t hid_kbd_ep_transfer_in(app_usbd_class_inst_t const * p_inst) -{ - return hid_kbd_transfer_set((app_usbd_hid_kbd_t const *)p_inst); -} - -/** - * @brief @ref app_usbd_class_interface_t::event_handler - */ -static ret_code_t hid_kbd_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - ASSERT(p_inst != NULL); - ASSERT(p_event != NULL); - - app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); - app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; - - app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); - app_usbd_hid_ctx_t * p_hid_ctx = &p_kbd_ctx->hid_ctx; - - /*Try handle event by generic HID event handler*/ - return app_usbd_hid_event_handler(p_inst, p_hinst, p_hid_ctx, p_event); -} - -/** - * @brief @ref app_usbd_class_interface_t::get_descriptors - */ -static const void * hid_kbd_get_descriptors(app_usbd_class_inst_t const * p_inst, - size_t * p_size) -{ - ASSERT(p_size != NULL); - app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); - app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; - - *p_size = p_hinst->raw_desc_size; - return p_hinst->p_raw_desc; -} - -/** @} */ - -const app_usbd_hid_methods_t app_usbd_hid_kbd_methods = { - .on_get_report = hid_kbd_on_get_report, - .on_set_report = hid_kbd_on_set_report, - .ep_transfer_in = hid_kbd_ep_transfer_in, - .ep_transfer_out = NULL, -}; - -const app_usbd_class_methods_t app_usbd_hid_kbd_class_methods = { - .event_handler = hid_kbd_event_handler, - .get_descriptors = hid_kbd_get_descriptors, -}; - -#endif // APP_USBD_HID_KBD_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.c deleted file mode 100644 index ebc550d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.c +++ /dev/null @@ -1,2194 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if APP_USBD_MSC_ENABLED -#include -#include - -#include "app_usbd.h" -#include "sdk_common.h" -#include "app_usbd_msc.h" -#include "app_usbd_string_desc.h" - -/** - * @defgroup app_usbd_msc_internal USBD MSC internals - * @{ - * @ingroup app_usbd_msc - * @internal - */ - -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_requestsense_t) == 6); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_requestsense_resp_t) == 18); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_inquiry_t) == 6); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_inquiry_resp_t) == 36); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_read6_t) == 6); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_write6_t) == 6); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense6_t) == 6); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense6_resp_t) == 4); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_readcapacity10_t) == 10); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_readcapacity10_resp_t) == 8); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_read10_t) == 10); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_write10_t) == 10); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense10_t) == 10); -STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense10_resp_t) == 8); - -STATIC_ASSERT(sizeof(app_usbd_msc_cbw_t) == 31); -STATIC_ASSERT(sizeof(app_usbd_msc_csw_t) == 13); - -#define NRF_LOG_MODULE_NAME usbd_msc - -#if APP_USBD_MSC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL APP_USBD_MSC_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR APP_USBD_MSC_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR APP_USBD_MSC_CONFIG_DEBUG_COLOR -#else //APP_USBD_MSC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif //APP_USBD_MSC_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#define APP_USBD_MSC_IFACE_IDX 0 /**< Mass storage class interface index */ -#define APP_USBD_MSC_EPIN_IDX 0 /**< Mass storage class endpoint IN index */ -#define APP_USBD_MSC_EPOUT_IDX 1 /**< Mass storage class endpoint OUT index */ - -/** - * @brief Set request buffer busy flag - * - * @param[in] val Bitmask to set - * @param[in] id Buffer id - * */ -#define APP_USBD_MSC_REQ_BUSY_SET(val, id) SET_BIT(val, id) - -/** - * @brief Clear request buffer busy flag - * - * @param[in] val Bitmask to set - * @param[in] id Buffer id - * */ -#define APP_USBD_MSC_REQ_BUSY_CLR(val, id) CLR_BIT(val, id) - -#define APP_USBD_MSC_REQ_BUSY_FULL_MASK (0x03) /**< Request busy mask */ - -static void msc_blockdev_ev_handler(nrf_block_dev_t const * p_blk_dev, - nrf_block_dev_event_t const * p_event); - -/** - * @brief Auxiliary function to access MSC instance data - * - * @param[in] p_inst Class instance data - * - * @return MSC instance data @ref app_usbd_msc_t - */ -static inline app_usbd_msc_t const * msc_get(app_usbd_class_inst_t const * p_inst) -{ - ASSERT(p_inst != NULL); - return (app_usbd_msc_t const *)p_inst; -} - -/** - * @brief Auxiliary function to access MSC context data - * - * @param[in] p_msc MSC instance data - * @return MSC context data @ref app_usbd_msc_ctx_t - */ -static inline app_usbd_msc_ctx_t * msc_ctx_get(app_usbd_msc_t const * p_msc) -{ - ASSERT(p_msc != NULL); - ASSERT(p_msc->specific.p_data != NULL); - return &p_msc->specific.p_data->ctx; -} - -/** - * @brief Auxiliary function to access MSC IN endpoint address - * - * @param[in] p_inst Class instance data - * - * @return IN endpoint address - */ -static inline nrf_drv_usbd_ep_t ep_in_addr_get(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_class_iface_conf_t const * class_iface; - class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_MSC_IFACE_IDX); - - app_usbd_class_ep_conf_t const * ep_cfg; - ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_MSC_EPIN_IDX); - - return app_usbd_class_ep_address_get(ep_cfg); -} - -/** - * @brief Auxiliary function to access MSC OUT endpoint address - * - * @param[in] p_inst Class instance data - * - * @return OUT endpoint address - */ -static inline nrf_drv_usbd_ep_t ep_out_addr_get(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_class_iface_conf_t const * class_iface; - class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_MSC_IFACE_IDX); - - app_usbd_class_ep_conf_t const * ep_cfg; - ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_MSC_EPOUT_IDX); - - return app_usbd_class_ep_address_get(ep_cfg); -} - -/** - * @brief Command Block Wrapper trigger - * - * @param[in] p_inst Generic class instance - * @param[in] state Next state transition - * - * @return Standard error code - * */ -static ret_code_t cbw_wait_start(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - nrf_drv_usbd_ep_t ep_addr_out = ep_out_addr_get(p_inst); - - NRF_LOG_DEBUG("cbw_wait_start"); - memset(&p_msc_ctx->cbw, 0, sizeof(app_usbd_msc_cbw_t)); - NRF_DRV_USBD_TRANSFER_OUT(cbw, &p_msc_ctx->cbw, sizeof(app_usbd_msc_cbw_t)); - ret_code_t ret = app_usbd_ep_transfer(ep_addr_out, &cbw); - if (ret == NRF_SUCCESS) - { - p_msc_ctx->state = APP_USBD_MSC_STATE_CBW; - } - - return ret; -} - -/** - * @brief Command Status Wrapper trigger - * - * @param[in] p_inst Generic class instance - * @param[in] state Next state transition - * - * @return Standard error code - * */ -static ret_code_t csw_wait_start(app_usbd_class_inst_t const * p_inst, uint8_t status) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - nrf_drv_usbd_ep_t ep_addr_in = ep_in_addr_get(p_inst); - - memset(&p_msc_ctx->csw, 0, sizeof(app_usbd_msc_csw_t)); - memcpy(p_msc_ctx->csw.signature, APP_USBD_MSC_CSW_SIGNATURE, sizeof(p_msc_ctx->csw.signature)); - memcpy(p_msc_ctx->csw.tag, p_msc_ctx->cbw.tag, sizeof(p_msc_ctx->csw.tag)); - memcpy(p_msc_ctx->csw.residue, &p_msc_ctx->current.residue, sizeof(uint32_t)); - p_msc_ctx->csw.status = status; - - NRF_DRV_USBD_TRANSFER_IN(csw, &p_msc_ctx->csw, sizeof(app_usbd_msc_csw_t)); - ret_code_t ret = app_usbd_ep_transfer(ep_addr_in, &csw); - if (ret == NRF_SUCCESS) - { - p_msc_ctx->state = APP_USBD_MSC_STATE_CSW; - } - - return ret; -} - -/** - * @brief IN transfer trigger - * - * @param[in] p_inst Generic class instance - * @param[in] p_buff IN transfer data buffer - * @param[in] size IN transfer size - * @param[in] state Next state transition - * - * @return Standard error code - * */ -static ret_code_t transfer_in_start(app_usbd_class_inst_t const * p_inst, - void const * p_buff, - size_t size, - app_usbd_msc_state_t state) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - NRF_LOG_DEBUG("transfer_in_start: p_buff: %p, size: %u", (uint32_t)p_buff, size); - - nrf_drv_usbd_ep_t ep_addr_in = ep_in_addr_get(p_inst); - - NRF_DRV_USBD_TRANSFER_IN(resp, p_buff, size); - ret_code_t ret = app_usbd_ep_transfer(ep_addr_in, &resp); - if (ret == NRF_SUCCESS) - { - p_msc_ctx->state = state; - } - return ret; -} - -/** - * @brief MSC reset request handler @ref APP_USBD_MSC_REQ_BULK_RESET - * - * @param[in] p_inst Generic class instance - * - * */ -static void bulk_ep_reset(app_usbd_class_inst_t const * p_inst) -{ - nrf_drv_usbd_ep_t ep_addr_in = ep_in_addr_get(p_inst); - nrf_drv_usbd_ep_t ep_addr_out = ep_out_addr_get(p_inst); - - nrf_drv_usbd_ep_abort(ep_addr_in); - nrf_drv_usbd_ep_abort(ep_addr_out); -} - - -/** - * @brief OUT transfer trigger - * - * @param[in] p_inst Generic class instance - * @param[in] p_buff OUT transfer data buffer - * @param[in] size OUT transfer size - * @param[in] state Next state transition - * - * @return Standard error code - * */ -static ret_code_t transfer_out_start(app_usbd_class_inst_t const * p_inst, - void * p_buff, - size_t size, - app_usbd_msc_state_t state) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - NRF_LOG_DEBUG("transfer_out_start: p_buff: %p, size: %u", (uint32_t)p_buff, size); - nrf_drv_usbd_ep_t ep_addr_out = ep_out_addr_get(p_inst); - - NRF_DRV_USBD_TRANSFER_OUT(resp, p_buff, size); - ret_code_t ret = app_usbd_ep_transfer(ep_addr_out, &resp); - if (ret == NRF_SUCCESS) - { - p_msc_ctx->state = state; - } - return ret; -} - -/** - * @brief Generic function to stall communication endpoints and mark error state - * - * Function used internally to stall all communication endpoints and mark current state. - * - * @param p_inst Generic class instance - * @param state State to set - */ -static void status_generic_error_stall(app_usbd_class_inst_t const * p_inst, app_usbd_msc_state_t state) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - nrf_drv_usbd_ep_t ep_in = ep_in_addr_get(p_inst); - nrf_drv_usbd_ep_t ep_out = ep_out_addr_get(p_inst); - - nrf_drv_usbd_ep_stall(ep_in); - nrf_drv_usbd_ep_stall(ep_out); - nrf_drv_usbd_ep_abort(ep_in); - nrf_drv_usbd_ep_abort(ep_out); - - p_msc_ctx->state = state; -} -/** - * @brief Start status stage of unsupported SCSI command - * - * @param[in,out] p_inst Generic class instance - * - * @return Standard error code - * - * @sa status_generic_error_stall - */ -static ret_code_t status_unsupported_start(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - bool data_stage = uint32_decode(p_msc_ctx->cbw.datlen) != 0; - - if (!data_stage) - { - /* Try to transfer the response now */ - ret_code_t ret; - ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); - if (ret == NRF_SUCCESS) - { - return ret; - } - } - - /* Cannot transfer failed response in current command - stall the endpoints and postpone the answer */ - status_generic_error_stall(p_inst, APP_USBD_MSC_STATE_UNSUPPORTED); - if (data_stage) - { - if (!(p_msc_ctx->cbw.flags & APP_USBD_MSC_CBW_DIRECTION_IN)) - { - nrf_drv_usbd_transfer_out_drop(ep_out_addr_get(p_inst)); - } - /* Unsupported command so we did not process any data - mark it in current residue value */ - p_msc_ctx->current.residue = uint32_decode(p_msc_ctx->cbw.datlen); - } - return NRF_SUCCESS; -} - -/** - * @brief Start status stage of CBW invalid - * - * @param[in,out] p_inst Generic class instance - * - * @sa status_generic_error_stall - */ -static void status_cbwinvalid_start(app_usbd_class_inst_t const * p_inst) -{ - status_generic_error_stall(p_inst, APP_USBD_MSC_STATE_CBW_INVALID); -} - -/** - * @brief Start status stage of internal device error - * - * Kind of error that requires bulk reset but does not stall endpoint permanently - the correct - * answer is possible. - * - * @param[in] p_inst Generic class instance - * - * @sa status_generic_error_stall - */ -static void status_deverror_start(app_usbd_class_inst_t const * p_inst) -{ - status_generic_error_stall(p_inst, APP_USBD_MSC_STATE_DEVICE_ERROR); -} - -/** - * @brief Internal SETUP standard IN request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - /*Only Get Descriptor standard IN request is supported by MSC class*/ - if (p_setup_ev->setup.bmRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR) - { - size_t dsc_len = 0; - /* Try to find descriptor in class internals*/ - void const * p_dsc = app_usbd_class_descriptor_find( - p_inst, - p_setup_ev->setup.wValue.hb, - p_setup_ev->setup.wValue.lb, - &dsc_len); - if (p_dsc != NULL) - { - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_dsc, dsc_len); - } - } - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Internal SETUP standard OUT request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - * @retval NRF_ERROR_FORBIDDEN if endpoint stall cannot be cleared because of internal state - */ -static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - app_usbd_setup_reqrec_t req_rec = app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType); - if ((req_rec == APP_USBD_SETUP_REQREC_ENDPOINT ) && - (p_setup_ev->setup.bmRequest == APP_USBD_SETUP_STDREQ_CLEAR_FEATURE ) && - (p_setup_ev->setup.wValue.w == APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT)) - { - if (p_msc_ctx->state == APP_USBD_MSC_STATE_CBW_INVALID) - { - return NRF_ERROR_FORBIDDEN; - } - ret_code_t ret = NRF_SUCCESS; - /* Clearing endpoint here. It is done normally inside app_usbd, but we are overwritting this functionality */ - nrf_drv_usbd_ep_t ep_addr = (nrf_drv_usbd_ep_t)(p_setup_ev->setup.wIndex.lb); - nrf_drv_usbd_ep_dtoggle_clear(ep_addr); - nrf_drv_usbd_ep_stall_clear(ep_addr); - if (NRF_USBD_EPIN_CHECK(ep_addr)) - { - switch (p_msc_ctx->state) - { - case APP_USBD_MSC_STATE_UNSUPPORTED: - { - nrf_drv_usbd_ep_stall_clear(ep_out_addr_get(p_inst)); - /*Unsupported command handle: status stage*/ - ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); - if (ret != NRF_SUCCESS) - { - NRF_LOG_ERROR("Unexpected csw_wait_start on ep clear: %d", ret); - } - break; - } - case APP_USBD_MSC_STATE_DEVICE_ERROR: - { - nrf_drv_usbd_ep_stall_clear(ep_out_addr_get(p_inst)); - /*Unsupported command handle: status stage*/ - ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PE); - if (ret != NRF_SUCCESS) - { - NRF_LOG_ERROR("Unexpected csw_wait_start on ep clear: %d", ret); - } - break; - } - default: - break; - } - } - return ret; - } - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Internal SETUP class IN request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_MSC_REQ_GET_MAX_LUN: - { - - if (p_setup_ev->setup.wValue.w != 0) - { - break; - } - - if (p_setup_ev->setup.wLength.w != 1) - { - break; - } - - size_t tx_size; - uint16_t * p_tx_buff = app_usbd_core_setup_transfer_buff_get(&tx_size); - ASSERT(p_msc->specific.inst.block_devs_count != 0); - p_tx_buff[0] = p_msc->specific.inst.block_devs_count - 1; - - ret_code_t ret = cbw_wait_start(p_inst); - UNUSED_VARIABLE(ret); - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_tx_buff, sizeof(uint8_t)); - } - default: - break; - - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Internal SETUP class OUT request handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - switch (p_setup_ev->setup.bmRequest) - { - case APP_USBD_MSC_REQ_BULK_RESET: - { - if (p_setup_ev->setup.wValue.w != 0) - { - break; - } - - if (p_setup_ev->setup.wLength.w != 0) - { - break; - } - - /* - * Reset internal state to be ready for next CBW - */ - NRF_LOG_DEBUG("bulk ep reset"); - bulk_ep_reset(p_inst); - - if (p_msc_ctx->state != APP_USBD_MSC_STATE_CBW) - { - ret_code_t ret = cbw_wait_start(p_inst); - UNUSED_VARIABLE(ret); - } - - return NRF_SUCCESS; - } - default: - break; - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Control endpoint handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) -{ - ASSERT(p_inst != NULL); - ASSERT(p_setup_ev != NULL); - - if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) - { - switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) - { - case APP_USBD_SETUP_REQTYPE_STD: - return setup_req_std_in(p_inst, p_setup_ev); - case APP_USBD_SETUP_REQTYPE_CLASS: - return setup_req_class_in(p_inst, p_setup_ev); - default: - break; - } - } - else /* APP_USBD_SETUP_REQDIR_OUT */ - { - switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) - { - case APP_USBD_SETUP_REQTYPE_STD: - return setup_req_std_out(p_inst, p_setup_ev); - case APP_USBD_SETUP_REQTYPE_CLASS: - return setup_req_class_out(p_inst, p_setup_ev); - default: - break; - } - } - - return NRF_ERROR_NOT_SUPPORTED; -} - -/** - * @brief Handle read6/read10 command data stage - * - * @param[in] p_inst Generic class instance - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t state_data_in_handle(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - ret_code_t ret = NRF_SUCCESS; - - p_msc_ctx->current.trans_in_progress = false; - APP_USBD_MSC_REQ_BUSY_CLR(p_msc_ctx->current.req_busy_mask, p_msc_ctx->current.trans_req_id); - - if (p_msc_ctx->current.blk_datasize == 0 && p_msc_ctx->current.req_busy_mask == 0) - { - p_msc_ctx->current.blk_idx = p_msc_ctx->current.blk_size = 0; - ret = csw_wait_start(p_inst, p_msc_ctx->current.csw_status); - return ret; - } - - ASSERT(p_msc_ctx->current.blk_size != 0); - - if (p_msc_ctx->current.req_busy_mask == 0) - { - nrf_block_dev_t const * p_blkd = - p_msc->specific.inst.pp_block_devs[p_msc_ctx->current.lun]; - - /*Trigger new block read request*/ - p_msc_ctx->current.workbuff_pos ^= p_msc->specific.inst.block_buff_size; - uint32_t req_pos = p_msc_ctx->current.workbuff_pos != 0 ? 1 : 0; - APP_USBD_MSC_REQ_BUSY_SET(p_msc_ctx->current.req_busy_mask, req_pos); - - NRF_BLOCK_DEV_REQUEST(req, - p_msc_ctx->current.blk_idx, - p_msc_ctx->current.blk_count, - ((uint8_t *)p_msc->specific.inst.p_block_buff + - p_msc_ctx->current.workbuff_pos)); - - NRF_LOG_DEBUG("nrf_blk_dev_read_req 3: id: %u, count: %u, left: %u, ptr: %p", - req.blk_id, - req.blk_count, - p_msc_ctx->current.blk_datasize, - (uint32_t)req.p_buff); - - ret = nrf_blk_dev_read_req(p_blkd, &req); - NRF_LOG_DEBUG("nrf_blk_dev_read_req 3: ret: %u", ret); - return ret; - } - - uint32_t blk_size = p_msc_ctx->current.blk_size; - p_msc_ctx->current.trans_req_id ^= 1; - - nrf_block_req_t * p_req = &p_msc_ctx->current.req; - if (p_req->p_buff == NULL) - { - p_msc_ctx->current.trans_req_id ^= 1; - return NRF_SUCCESS; - } - - ret = transfer_in_start(p_inst, - p_req->p_buff, - p_req->blk_count * blk_size, - APP_USBD_MSC_STATE_DATA_IN); - - if (ret == NRF_SUCCESS) - { - /*Clear processed block request.*/ - memset(p_req, 0, sizeof(nrf_block_req_t)); - p_msc_ctx->current.trans_in_progress = true; - } - - return ret; -} - -/** - * @brief Endpoint IN event handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t endpoint_in_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - NRF_LOG_DEBUG("state: %d, ep in event, status: %d", - p_msc_ctx->state, - p_event->drv_evt.data.eptransfer.status); - - if (p_event->drv_evt.data.eptransfer.status != NRF_USBD_EP_OK) - { - return NRF_SUCCESS; - } - - ret_code_t ret = NRF_SUCCESS; - switch (p_msc_ctx->state) { - case APP_USBD_MSC_STATE_CMD_IN: - { - ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); - break; - } - case APP_USBD_MSC_STATE_DATA_IN: - { - ret = state_data_in_handle(p_inst); - break; - } - case APP_USBD_MSC_STATE_CSW: - { - break; - } - case APP_USBD_MSC_STATE_DATA_OUT: - { - break; - } - case APP_USBD_MSC_STATE_UNSUPPORTED: - { - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - default: - { - ret = NRF_ERROR_INTERNAL; - break; - } - } - - return ret; -} - - -/** - * @brief Helper function to calculate next block transfer block count - * - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * - * @return Blocks to transfer - * */ -static uint32_t next_transfer_blkcnt_calc(app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - uint32_t blkcnt = p_msc->specific.inst.block_buff_size / p_msc_ctx->current.blk_size; - if (blkcnt > (p_msc_ctx->current.blk_datasize / p_msc_ctx->current.blk_size)) - { - blkcnt = p_msc_ctx->current.blk_datasize / p_msc_ctx->current.blk_size; - } - - return blkcnt; -} - -/** - * @brief Helper function to calculate next transfer size - * - * @param[in] p_msc_ctx MSC context - * - * @return Blocks to transfer - * */ -static uint32_t next_transfer_size_calc(app_usbd_msc_ctx_t * p_msc_ctx) -{ - uint32_t blk_cnt = p_msc_ctx->current.blk_count; - uint32_t blk_size = p_msc_ctx->current.blk_size; - - return p_msc_ctx->current.blk_datasize > blk_size * blk_cnt ? - blk_size * blk_cnt : p_msc_ctx->current.blk_datasize; -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_TESTUNITREADY handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_testunitready(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: TESTUNITREADY"); - if (uint32_decode(p_msc_ctx->cbw.datlen) != 0) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.cdb_length != APP_USBD_SCSI_CMD_TESTUNITREADY_LEN) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_REQUESTSENSE handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_requestsense(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: REQUESTSENSE"); - app_usbd_scsi_cmd_requestsense_t const * p_reqs = (const void *)p_msc_ctx->cbw.cdb; - UNUSED_VARIABLE(p_reqs); - - if ((p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_requestsense_t))) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - p_msc_ctx->resp_len = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->resp_len = MIN(p_msc_ctx->resp_len, - sizeof(app_usbd_scsi_cmd_requestsense_resp_t)); - - if (p_msc_ctx->resp_len == 0) - { - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); - } - - memset(&p_msc_ctx->scsi_resp, 0, sizeof(app_usbd_scsi_cmd_requestsense_resp_t)); - p_msc_ctx->scsi_resp.requestsense.code = APP_USBD_SCSI_CMD_REQSENSE_CODE_VALID | - APP_USBD_SCSI_CMD_REQSENSE_CODE_CURRENT; - - p_msc_ctx->scsi_resp.requestsense.len = sizeof(app_usbd_scsi_cmd_requestsense_resp_t) - - offsetof(app_usbd_scsi_cmd_requestsense_resp_t, len); - - return transfer_in_start(p_inst, - &p_msc_ctx->scsi_resp, - p_msc_ctx->resp_len, - APP_USBD_MSC_STATE_CMD_IN); -} - - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_FORMAT_UNIT handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_formatunit(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: FORMAT_UNIT"); - return status_unsupported_start(p_inst); -} - -static ret_code_t cmd_read_start(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - - p_msc_ctx->current.trans_in_progress = false; - p_msc_ctx->current.req_busy_mask = 0; - p_msc_ctx->current.workbuff_pos = 0; - - APP_USBD_MSC_REQ_BUSY_SET(p_msc_ctx->current.req_busy_mask, 0); - NRF_BLOCK_DEV_REQUEST(req, - p_msc_ctx->current.blk_idx, - p_msc_ctx->current.blk_count, - ((uint8_t *)p_msc->specific.inst.p_block_buff + - p_msc_ctx->current.workbuff_pos)); - - NRF_LOG_DEBUG("cmd_read_start"); - NRF_LOG_DEBUG("nrf_blk_dev_read_req 1: id: %u, count: %u, left: %u, ptr: %p", - req.blk_id, - req.blk_count, - p_msc_ctx->current.blk_datasize, - (uint32_t)req.p_buff); - - ret_code_t ret = nrf_blk_dev_read_req(p_blkd, &req); - NRF_LOG_DEBUG("nrf_blk_dev_read_req 1: ret: %u", ret); - - return ret; -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_READ6 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_read6(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: READ6"); - app_usbd_scsi_cmd_read6_t const * p_read6 = (const void *)p_msc_ctx->cbw.cdb; - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_read6_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - - p_msc_ctx->current.lun = p_msc_ctx->cbw.lun; - p_msc_ctx->current.blk_idx = ((p_read6->mslba & 0x1F) << 16) | - uint16_big_decode(p_read6->lslba); - p_msc_ctx->current.blk_datasize = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->current.blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; - p_msc_ctx->current.blk_count = next_transfer_blkcnt_calc(p_msc, p_msc_ctx); - - if (p_msc_ctx->current.blk_datasize > p_msc_ctx->current.blk_size * p_read6->xfrlen) - { - p_msc_ctx->current.residue = p_msc_ctx->current.blk_datasize - - p_msc_ctx->current.blk_size * p_read6->xfrlen; - } - - return cmd_read_start(p_inst, p_msc, p_msc_ctx); -} - -static ret_code_t cmd_write_start(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("cmd_write_start"); - ret_code_t ret = transfer_out_start(p_inst, - ((uint8_t *)p_msc->specific.inst.p_block_buff + - p_msc_ctx->current.workbuff_pos), - next_transfer_size_calc(p_msc_ctx), - APP_USBD_MSC_STATE_DATA_OUT); - - if (ret == NRF_SUCCESS) - { - p_msc_ctx->current.trans_req_id = 0; - APP_USBD_MSC_REQ_BUSY_SET(p_msc_ctx->current.req_busy_mask, - p_msc_ctx->current.trans_req_id); - p_msc_ctx->current.workbuff_pos ^= p_msc->specific.inst.block_buff_size; - p_msc_ctx->current.trans_in_progress = true; - } - - return ret; -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_WRITE6 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_write6(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: WRITE6"); - app_usbd_scsi_cmd_write6_t const * p_write6 = (const void *)p_msc_ctx->cbw.cdb; - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_write6_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - - p_msc_ctx->current.lun = p_msc_ctx->cbw.lun; - p_msc_ctx->current.blk_idx = (p_write6->mslba & 0x1F << 16) | - uint16_big_decode(p_write6->lslba); - p_msc_ctx->current.blk_datasize = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->current.blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; - p_msc_ctx->current.blk_count = next_transfer_blkcnt_calc(p_msc, p_msc_ctx); - - if (p_msc_ctx->current.blk_datasize > p_msc_ctx->current.blk_size * p_write6->xfrlen) - { - p_msc_ctx->current.residue = p_msc_ctx->current.blk_datasize - - p_msc_ctx->current.blk_size * p_write6->xfrlen; - } - - return cmd_write_start(p_inst, p_msc, p_msc_ctx); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_INQUIRY handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_inquiry(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: INQUIRY"); - app_usbd_scsi_cmd_inquiry_t const * p_inq = (const void *)p_msc_ctx->cbw.cdb; - if (p_inq->pagecode != 0) - { - NRF_LOG_WARNING("unsupported pagecode"); - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - NRF_LOG_WARNING("unsupported LUN"); - return status_unsupported_start(p_inst); - } - - p_msc_ctx->resp_len = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->resp_len = MIN(p_msc_ctx->resp_len, - sizeof(app_usbd_scsi_cmd_inquiry_resp_t)); - - if (p_msc_ctx->resp_len == 0) - { - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); - } - - - p_msc_ctx->scsi_resp.inquiry.qualtype = APP_USBD_MSC_SCSI_INQ_QUAL_CONNECTED | - APP_USBD_MSC_SCSI_INQ_TYPE_DIR_ACCESS; - p_msc_ctx->scsi_resp.inquiry.flags1 = APP_USBD_MSC_SCSI_INQ_FLAG1_RMB; - p_msc_ctx->scsi_resp.inquiry.version = APP_USBD_SCSI_INQ_VER_SPC4; - p_msc_ctx->scsi_resp.inquiry.flags2 = APP_USBD_MSC_SCSI_INQ_FLAG2_RSP_SPC2 | - APP_USBD_MSC_SCSI_INQ_FLAG2_HISUP; - p_msc_ctx->scsi_resp.inquiry.len = sizeof(app_usbd_scsi_cmd_inquiry_resp_t) - - offsetof(app_usbd_scsi_cmd_inquiry_resp_t, len); - - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - nrf_block_dev_info_strings_t * p_strings = NULL; - UNUSED_RETURN_VALUE(nrf_blk_dev_ioctl(p_blkd, - NRF_BLOCK_DEV_IOCTL_REQ_INFO_STRINGS, - &p_strings)); - - if (p_strings) - { - UNUSED_RETURN_VALUE(strncpy((char *)p_msc_ctx->scsi_resp.inquiry.vendorid, - p_strings->p_vendor, - sizeof(p_msc_ctx->scsi_resp.inquiry.vendorid))); - - UNUSED_RETURN_VALUE(strncpy((char *)p_msc_ctx->scsi_resp.inquiry.productid, - p_strings->p_product, - sizeof(p_msc_ctx->scsi_resp.inquiry.productid))); - - UNUSED_RETURN_VALUE(strncpy((char *)p_msc_ctx->scsi_resp.inquiry.revision, - p_strings->p_revision, - sizeof(p_msc_ctx->scsi_resp.inquiry.revision))); - } - else { - memset(p_msc_ctx->scsi_resp.inquiry.vendorid, - 0, - sizeof(p_msc_ctx->scsi_resp.inquiry.vendorid)); - memset(p_msc_ctx->scsi_resp.inquiry.productid, - 0, - sizeof(p_msc_ctx->scsi_resp.inquiry.productid)); - memset(p_msc_ctx->scsi_resp.inquiry.revision, - 0, - sizeof(p_msc_ctx->scsi_resp.inquiry.revision)); - } - - return transfer_in_start(p_inst, - &p_msc_ctx->scsi_resp, - p_msc_ctx->resp_len, - APP_USBD_MSC_STATE_CMD_IN); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESELECT6 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_modeselect6(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: MODESELECT6"); - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); -} - - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESENSE6 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_modesense6(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: MODESENSE6"); - app_usbd_scsi_cmd_modesense6_t const * p_sense6 = (const void *)p_msc_ctx->cbw.cdb; - UNUSED_VARIABLE(p_sense6); - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_modesense6_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - p_msc_ctx->resp_len = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->resp_len = MIN(p_msc_ctx->resp_len, - sizeof(app_usbd_scsi_cmd_modesense6_resp_t)); - - app_usbd_scsi_cmd_modesense6_resp_t * p_resp = &p_msc_ctx->scsi_resp.modesense6; - p_resp->mdlen = sizeof(app_usbd_scsi_cmd_modesense6_resp_t) - 1; - p_resp->type = 0; - p_resp->param = 0; - p_resp->bdlen = 0; - - return transfer_in_start(p_inst, - &p_msc_ctx->scsi_resp, - p_msc_ctx->resp_len, - APP_USBD_MSC_STATE_CMD_IN); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_STARTSTOPUNIT handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_startstopunit(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: STARTSTOPUNIT"); - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); -} - - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_SENDDIAGNOSTIC handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_senddiagnostic(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: SENDDIAGNOSTIC"); - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_PREVENTMEDIAREMOVAL handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_preventremoval(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: PREVENTMEDIAREMOVAL"); - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_READCAPACITY10 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_readcapacity10(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: READCAPACITY10"); - - app_usbd_scsi_cmd_readcapacity10_t const * p_cap10 = (const void *)p_msc_ctx->cbw.cdb; - UNUSED_VARIABLE(p_cap10); - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_readcapacity10_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - p_msc_ctx->resp_len = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->resp_len = MIN(p_msc_ctx->resp_len, - sizeof(app_usbd_scsi_cmd_readcapacity10_resp_t)); - - if (p_msc_ctx->resp_len == 0) - { - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); - } - - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - nrf_block_dev_geometry_t const * p_geometry = nrf_blk_dev_geometry(p_blkd); - - (void)uint32_big_encode(p_geometry->blk_count - 1, p_msc_ctx->scsi_resp.readcapacity10.lba); - (void)uint32_big_encode(p_geometry->blk_size, p_msc_ctx->scsi_resp.readcapacity10.blklen); - - return transfer_in_start(p_inst, - &p_msc_ctx->scsi_resp, - p_msc_ctx->resp_len, - APP_USBD_MSC_STATE_CMD_IN); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_READ10 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_read10(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: READ10"); - app_usbd_scsi_cmd_read10_t const * p_read10 = (const void *)p_msc_ctx->cbw.cdb; - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_read10_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - if (uint32_decode(p_msc_ctx->cbw.datlen) == 0) - { - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); - } - - if ((p_msc_ctx->cbw.flags & APP_USBD_MSC_CBW_DIRECTION_IN) == 0) - { - return status_unsupported_start(p_inst); - } - - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - - p_msc_ctx->current.lun = p_msc_ctx->cbw.lun; - p_msc_ctx->current.blk_idx = uint32_big_decode(p_read10->lba); - p_msc_ctx->current.blk_datasize = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->current.blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; - p_msc_ctx->current.blk_count = next_transfer_blkcnt_calc(p_msc, p_msc_ctx); - - uint16_t blocks = uint16_big_decode(p_read10->xfrlen); - p_msc_ctx->current.csw_status = - uint32_decode(p_msc_ctx->cbw.datlen) < p_msc_ctx->current.blk_size * blocks ? - APP_USBD_MSC_CSW_STATUS_FAIL : APP_USBD_MSC_CSW_STATUS_PASS; - - if (p_msc_ctx->current.blk_datasize > p_msc_ctx->current.blk_size * blocks) - { - p_msc_ctx->current.residue = p_msc_ctx->current.blk_datasize - - p_msc_ctx->current.blk_size * blocks; - } - - return cmd_read_start(p_inst, p_msc, p_msc_ctx); -} - - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_WRITE10 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_write10(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: WRITE10"); - app_usbd_scsi_cmd_write10_t const * p_write10 = (const void *)p_msc_ctx->cbw.cdb; - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_write10_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - if (uint32_decode(p_msc_ctx->cbw.datlen) == 0) - { - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); - } - - - if ((p_msc_ctx->cbw.flags & APP_USBD_MSC_CBW_DIRECTION_IN) != 0) - { - return status_unsupported_start(p_inst); - } - - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; - - p_msc_ctx->current.lun = p_msc_ctx->cbw.lun; - p_msc_ctx->current.blk_idx = uint32_big_decode(p_write10->lba); - p_msc_ctx->current.blk_datasize = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->current.blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; - p_msc_ctx->current.blk_count = next_transfer_blkcnt_calc(p_msc, p_msc_ctx); - - uint16_t blocks = uint16_big_decode(p_write10->xfrlen); - p_msc_ctx->current.csw_status = - uint32_decode(p_msc_ctx->cbw.datlen) < p_msc_ctx->current.blk_size * blocks ? - APP_USBD_MSC_CSW_STATUS_FAIL : APP_USBD_MSC_CSW_STATUS_PASS; - - if (p_msc_ctx->current.blk_datasize > p_msc_ctx->current.blk_size * blocks) - { - p_msc_ctx->current.residue = p_msc_ctx->current.blk_datasize - - p_msc_ctx->current.blk_size * blocks; - } - - return cmd_write_start(p_inst, p_msc, p_msc_ctx); -} - - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESELECT10 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_modeselect10(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: MODESELECT10"); - return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); -} - -/** - * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESENSE10 handle - * - * @param[in] p_inst Generic class instance - * @param[in] p_msc MSC instance - * @param[in] p_msc_ctx MSC context - * @return Standard error code - * */ -static ret_code_t cmd_modesense10(app_usbd_class_inst_t const * p_inst, - app_usbd_msc_t const * p_msc, - app_usbd_msc_ctx_t * p_msc_ctx) -{ - NRF_LOG_DEBUG("CMD: MODESENSE10"); - app_usbd_scsi_cmd_modesense10_t const * p_sense10 = (const void *)p_msc_ctx->cbw.cdb; - UNUSED_VARIABLE(p_sense10); - if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_modesense10_t)) - { - return status_unsupported_start(p_inst); - } - - if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) - { - return status_unsupported_start(p_inst); - } - - p_msc_ctx->resp_len = uint32_decode(p_msc_ctx->cbw.datlen); - p_msc_ctx->resp_len = MIN(p_msc_ctx->resp_len, - sizeof(app_usbd_scsi_cmd_modesense6_resp_t)); - - app_usbd_scsi_cmd_modesense10_resp_t * p_resp = &p_msc_ctx->scsi_resp.modesense10; - - memset(p_resp, 0, sizeof(app_usbd_scsi_cmd_modesense10_resp_t)); - uint16_t len = sizeof(app_usbd_scsi_cmd_modesense10_resp_t) - sizeof(p_resp->mdlen); - p_resp->mdlen[1] = len & 0xff; - p_resp->mdlen[0] = (len >> 8) & 0xff; - - return transfer_in_start(p_inst, - &p_msc_ctx->scsi_resp, - p_msc_ctx->resp_len, - APP_USBD_MSC_STATE_CMD_IN); -} - -/** - * @brief Get the size of the last OUT transfer - * - * @param p_inst Generic class instance - * - * @return Number of received bytes or 0 if none. - */ -static size_t get_last_out_size(app_usbd_class_inst_t const * p_inst) -{ - nrf_drv_usbd_ep_t ep = ep_out_addr_get(p_inst); - size_t size; - ret_code_t ret = nrf_drv_usbd_ep_status_get(ep, &size); - if (ret != NRF_SUCCESS) - { - size = 0; - } - - return size; -} - -/** - * @brief SCSI Command Block Wrapper handler - * - * @param[in] p_inst Generic class instance - * @return Standard error code - * */ -static ret_code_t state_cbw(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - memset(&p_msc_ctx->current, 0, sizeof(p_msc_ctx->current)); - - /*Verify the transfer size*/ - if (get_last_out_size(p_inst) != sizeof(app_usbd_msc_cbw_t)) - { - NRF_LOG_DEBUG("CMD: size error: %u", get_last_out_size(p_inst)); - status_cbwinvalid_start(p_inst); - return NRF_SUCCESS; - } - - /*Verify CBW signature*/ - if (memcmp(p_msc_ctx->cbw.signature, - APP_USBD_MSC_CBW_SIGNATURE, - sizeof(p_msc_ctx->cbw.signature)) != 0) - { - NRF_LOG_DEBUG("CMD: header error: 0x%02x%02x%02x%02x", - p_msc_ctx->cbw.signature[0], p_msc_ctx->cbw.signature[1], - p_msc_ctx->cbw.signature[2], p_msc_ctx->cbw.signature[3]); - - status_cbwinvalid_start(p_inst); - return NRF_SUCCESS; - } - - ret_code_t ret = NRF_SUCCESS; - switch (p_msc_ctx->cbw.cdb[0]) - { - case APP_USBD_SCSI_CMD_TESTUNITREADY: - ret = cmd_testunitready(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_REQUESTSENSE: - ret = cmd_requestsense(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_FORMAT_UNIT: - ret = cmd_formatunit(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_READ6: - ret = cmd_read6(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_WRITE6: - ret = cmd_write6(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_INQUIRY: - ret = cmd_inquiry(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_MODESELECT6: - ret = cmd_modeselect6(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_MODESENSE6: - ret = cmd_modesense6(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_STARTSTOPUNIT: - ret = cmd_startstopunit(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_SENDDIAGNOSTIC: - ret = cmd_senddiagnostic(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_PREVENTMEDIAREMOVAL: - ret = cmd_preventremoval(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_READCAPACITY10: - ret = cmd_readcapacity10(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_READ10: - ret = cmd_read10(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_WRITE10: - ret = cmd_write10(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_MODESELECT10: - ret = cmd_modeselect10(p_inst, p_msc, p_msc_ctx); - break; - case APP_USBD_SCSI_CMD_MODESENSE10: - ret = cmd_modesense10(p_inst, p_msc, p_msc_ctx); - break; - default: - NRF_LOG_DEBUG("CMD: UNSUPPORTED"); - NRF_LOG_HEXDUMP_DEBUG(&(p_msc_ctx->cbw), sizeof(p_msc_ctx->cbw)); - if (uint32_decode(p_msc_ctx->cbw.datlen) != 0) - { - ret = status_unsupported_start(p_inst); - } - else - { - ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); - } - break; - } - - return ret; -} - - -/** - * @brief Handle write6/write10 command data stage - * - * @param[in] p_inst Generic class instance - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t state_data_out_handle(app_usbd_class_inst_t const * p_inst) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - ret_code_t ret = NRF_SUCCESS; - uint32_t blk_size = p_msc_ctx->current.blk_size; - - NRF_LOG_DEBUG("APP_USBD_MSC_STATE_DATA_OUT"); - - p_msc_ctx->current.trans_in_progress = false; - if ((p_msc_ctx->current.req_busy_mask != APP_USBD_MSC_REQ_BUSY_FULL_MASK) && - (p_msc_ctx->current.blk_datasize > p_msc_ctx->current.blk_count * blk_size)) - { - size_t size = p_msc_ctx->current.blk_datasize - p_msc_ctx->current.blk_count * blk_size; - if (size > p_msc_ctx->current.blk_count * blk_size) - { - size = p_msc_ctx->current.blk_count * blk_size; - } - - if (size) - { - ret = transfer_out_start(p_inst, - ((uint8_t *)p_msc->specific.inst.p_block_buff + - p_msc_ctx->current.workbuff_pos), - size, - APP_USBD_MSC_STATE_DATA_OUT); - if (ret == NRF_SUCCESS) - { - p_msc_ctx->current.trans_req_id ^= 1; - APP_USBD_MSC_REQ_BUSY_SET(p_msc_ctx->current.req_busy_mask, - p_msc_ctx->current.trans_req_id); - p_msc_ctx->current.workbuff_pos ^= p_msc->specific.inst.block_buff_size; - p_msc_ctx->current.trans_in_progress = true; - } - } - } - - if (!p_msc_ctx->current.block_req_in_progress) - { - nrf_block_dev_t const * p_blkd = - p_msc->specific.inst.pp_block_devs[p_msc_ctx->current.lun]; - - size_t pos = p_msc_ctx->current.workbuff_pos; - if (p_msc_ctx->current.req_busy_mask != APP_USBD_MSC_REQ_BUSY_FULL_MASK) - { - pos ^= p_msc->specific.inst.block_buff_size; - } - - NRF_BLOCK_DEV_REQUEST(req, - p_msc_ctx->current.blk_idx, - p_msc_ctx->current.blk_count, - ((uint8_t *)p_msc->specific.inst.p_block_buff + pos)); - - NRF_LOG_DEBUG("nrf_blk_dev_write_req 1: id: %u, count: %u, left: %u, ptr: %p", - req.blk_id, - req.blk_count, - p_msc_ctx->current.blk_datasize, - (uint32_t)req.p_buff); - - p_msc_ctx->current.block_req_in_progress = true; - ret = nrf_blk_dev_write_req(p_blkd, &req); - NRF_LOG_DEBUG("nrf_blk_dev_write_req 1: ret: %u", ret); - } - - return ret; -} - -/** - * @brief Endpoint OUT event handler - * - * @param[in] p_inst Generic class instance - * @param[in] p_setup_ev Setup event - * - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported - */ -static ret_code_t endpoint_out_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - NRF_LOG_DEBUG("state: %d, ep out event, status: %d", - p_msc_ctx->state, - p_event->drv_evt.data.eptransfer.status); - - ret_code_t ret = NRF_SUCCESS; - if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_WAITING) - { - if (p_msc_ctx->state == APP_USBD_MSC_STATE_DATA_OUT) - { - NRF_LOG_DEBUG("NRF_USBD_EP_WAITING"); - } - else if (p_msc_ctx->state == APP_USBD_MSC_STATE_CSW || - p_msc_ctx->state == APP_USBD_MSC_STATE_IDLE) - { - ret = cbw_wait_start(p_inst); - } - - return ret; - } - else if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_ABORTED) - { - p_msc_ctx->state = APP_USBD_MSC_STATE_IDLE; - return NRF_SUCCESS; - } - else if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_OVERLOAD) - { - NRF_LOG_ERROR("Data overload"); - switch (p_msc_ctx->state) - { - case APP_USBD_MSC_STATE_DATA_OUT: - { - status_deverror_start(p_inst); - } - /* Default action is the same like CBW - stall totally until bulk reset */ - case APP_USBD_MSC_STATE_CBW: - default: - { - status_cbwinvalid_start(p_inst); - } - } - return NRF_SUCCESS; - } - else /*NRF_USBD_EP_OK*/ - { - switch (p_msc_ctx->state) - { - case APP_USBD_MSC_STATE_CBW: - { - ret = state_cbw(p_inst); - break; - } - case APP_USBD_MSC_STATE_CMD_OUT: - { - ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); - break; - } - case APP_USBD_MSC_STATE_DATA_OUT: - { - CRITICAL_REGION_ENTER(); - ret = state_data_out_handle(p_inst); - CRITICAL_REGION_EXIT(); - break; - } - case APP_USBD_MSC_STATE_UNSUPPORTED: - { - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - case APP_USBD_MSC_STATE_CSW: - break; - default: - { - ASSERT(0); - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - } - } - - NRF_LOG_DEBUG("Ep proc status: %d", ret); - return ret; -} - - -/** - * @brief @ref app_usbd_class_methods_t::event_handler - */ -static ret_code_t msc_event_handler(app_usbd_class_inst_t const * p_inst, - app_usbd_complex_evt_t const * p_event) -{ - ASSERT(p_inst != NULL); - ASSERT(p_event != NULL); - - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - UNUSED_VARIABLE(p_msc); - UNUSED_VARIABLE(p_msc_ctx); - - ret_code_t ret = NRF_SUCCESS; - switch (p_event->app_evt.type) - { - case APP_USBD_EVT_DRV_SOF: - break; - case APP_USBD_EVT_DRV_RESET: - break; - case APP_USBD_EVT_DRV_SETUP: - ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *)p_event); - break; - case APP_USBD_EVT_DRV_EPTRANSFER: - if (NRF_USBD_EPIN_CHECK(p_event->drv_evt.data.eptransfer.ep)) - { - ret = endpoint_in_event_handler(p_inst, p_event); - } - else - { - ret = endpoint_out_event_handler(p_inst, p_event); - } - break; - case APP_USBD_EVT_DRV_SUSPEND: - { - /*Flush all block devices cache on suspend*/ - - for (size_t i = 0; i < p_msc->specific.inst.block_devs_count; ++i) - { - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[i]; - (void)nrf_blk_dev_ioctl(p_blkd, NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH, NULL); - } - - break; - } - case APP_USBD_EVT_DRV_RESUME: - break; - case APP_USBD_EVT_INST_APPEND: - { - /*Verify serial number string*/ - uint16_t const * p_serial_str = app_usbd_string_desc_get(APP_USBD_STRING_ID_SERIAL, 0); - if (p_serial_str == NULL) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - size_t len = app_usbd_string_desc_length(p_serial_str) / sizeof(uint16_t); - if (len < APP_USBD_MSC_MINIMAL_SERIAL_STRING_SIZE) - { - return NRF_ERROR_NOT_SUPPORTED; - } - - for (size_t i = 1; i < len; ++i) - { - if (isxdigit(p_serial_str[i]) == 0) - { - return NRF_ERROR_NOT_SUPPORTED; - } - } - - ret = app_usbd_class_sof_register(p_inst); - if (ret != NRF_SUCCESS) - { - break; - } - - break; - } - case APP_USBD_EVT_INST_REMOVE: - { - ret = app_usbd_class_sof_unregister(p_inst); - break; - } - case APP_USBD_EVT_STARTED: - { - /*Initialize all block devices*/ - ASSERT(p_msc->specific.inst.block_devs_count <= 16); - for (size_t i = 0; i < p_msc->specific.inst.block_devs_count; ++i) - { - nrf_block_dev_t const * p_blk_dev = p_msc->specific.inst.pp_block_devs[i]; - ret = nrf_blk_dev_init(p_blk_dev, msc_blockdev_ev_handler, p_msc); - if (ret != NRF_SUCCESS) - { - continue; - } - - p_msc_ctx->blk_dev_init_mask |= 1u << i; - ASSERT(nrf_blk_dev_geometry(p_blk_dev)->blk_size <= - p_msc->specific.inst.block_buff_size); - } - - break; - } - case APP_USBD_EVT_STOPPED: - { - /*Un-initialize all block devices*/ - ASSERT(p_msc->specific.inst.block_devs_count <= 16); - size_t i; - for (i = 0; i < p_msc->specific.inst.block_devs_count; ++i) - { - nrf_block_dev_t const * p_blk_dev = p_msc->specific.inst.pp_block_devs[i]; - ret = nrf_blk_dev_uninit(p_blk_dev); - if (ret != NRF_SUCCESS) - { - continue; - } - - p_msc_ctx->blk_dev_init_mask &= ~(1u << i); - } - - break; - } - default: - ret = NRF_ERROR_NOT_SUPPORTED; - break; - } - - return ret; -} - -/** - * @brief @ref app_usbd_class_methods_t::get_descriptors - */ -static const void * msc_get_descriptors(app_usbd_class_inst_t const * p_inst, size_t * p_size) -{ - ASSERT(p_size != NULL); - app_usbd_msc_t const * p_msc = msc_get(p_inst); - - *p_size = p_msc->specific.inst.raw_desc_size; - return p_msc->specific.inst.p_raw_desc; -} - -const app_usbd_class_methods_t app_usbd_msc_class_methods = { - .event_handler = msc_event_handler, - .get_descriptors = msc_get_descriptors, -}; - - -/** - * @brief Block device read done event handler. - * - * @ref NRF_BLOCK_DEV_EVT_BLK_READ_DONE - * - * @param p_blk_dev Block device handle - * @param p_event Block device event - * - * */ -static void msc_blockdev_read_done_handler(nrf_block_dev_t const * p_blk_dev, - nrf_block_dev_event_t const * p_event) -{ - ret_code_t ret; - - app_usbd_class_inst_t const * p_inst = p_event->p_context; - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - uint32_t blk_cnt = p_msc_ctx->current.blk_count; - uint32_t blk_size = p_msc_ctx->current.blk_size; - - /*Save actual request*/ - size_t req_pos = (p_msc_ctx->current.workbuff_pos != 0) ? 1 : 0; - p_msc_ctx->current.req = *p_event->p_blk_req; - - p_msc_ctx->current.block_req_in_progress = false; - - /*Decrement transfer counter*/ - p_msc_ctx->current.blk_idx += blk_cnt; - if (p_msc_ctx->current.blk_datasize > blk_size * blk_cnt) - { - p_msc_ctx->current.blk_datasize -= blk_size * blk_cnt; - } - else - { - p_msc_ctx->current.blk_datasize = 0; - } - - NRF_LOG_DEBUG("read_done_handler: p_buff: %p, size: %u data size: %u req_pos: %u", - (uint32_t)p_event->p_blk_req->p_buff, - p_event->p_blk_req->blk_count, - p_msc_ctx->current.blk_datasize, - req_pos); - - /*Calculate next block request size*/ - p_msc_ctx->current.blk_count = next_transfer_blkcnt_calc(p_msc, p_msc_ctx); - - if (!p_msc_ctx->current.trans_in_progress) - { - /*Trigger new transfer.*/ - p_msc_ctx->current.trans_req_id = req_pos; - nrf_block_req_t * p_req = &p_msc_ctx->current.req; - - ret = transfer_in_start(p_inst, - p_req->p_buff, - p_req->blk_count * blk_size, - APP_USBD_MSC_STATE_DATA_IN); - if (ret != NRF_SUCCESS) - { - UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); - } - else - { - /*Clear processed block request.*/ - memset(p_req, 0, sizeof(nrf_block_req_t)); - p_msc_ctx->current.trans_in_progress = true; - } - - } - - if (p_msc_ctx->current.req_busy_mask == APP_USBD_MSC_REQ_BUSY_FULL_MASK) - { - /* No need to perform next block read request. USB transfers need to catch-up - * block device readings */ - return; - } - - if (p_msc_ctx->current.blk_count == 0) - { - /*All data has been read. No need to trigger new block request.*/ - return; - } - - /*Trigger new block read request*/ - p_msc_ctx->current.workbuff_pos ^= p_msc->specific.inst.block_buff_size; - req_pos = p_msc_ctx->current.workbuff_pos != 0 ? 1 : 0; - - APP_USBD_MSC_REQ_BUSY_SET(p_msc_ctx->current.req_busy_mask, req_pos); - - NRF_BLOCK_DEV_REQUEST(req, - p_msc_ctx->current.blk_idx, - p_msc_ctx->current.blk_count, - ((uint8_t *)p_msc->specific.inst.p_block_buff + - p_msc_ctx->current.workbuff_pos)); - - - NRF_LOG_DEBUG("nrf_blk_dev_read_req 2: id: %u, count: %u, left: %u, ptr: %p", - req.blk_id, - req.blk_count, - p_msc_ctx->current.blk_datasize, - (uint32_t)req.p_buff); - - ret = nrf_blk_dev_read_req(p_blk_dev, &req); - NRF_LOG_DEBUG("nrf_blk_dev_read_req 2: ret: %u", ret); - - if (ret != NRF_SUCCESS) - { - UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); - } -} - -/** - * @brief Block device write done event handler. - * - * @ref NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE - * - * @param p_blk_dev Block device handle - * @param p_event Block device event - * - * */ -static void msc_blockdev_write_done_handler(nrf_block_dev_t const * p_blk_dev, - nrf_block_dev_event_t const * p_event) -{ - app_usbd_class_inst_t const * p_inst = p_event->p_context; - app_usbd_msc_t const * p_msc = msc_get(p_inst); - app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); - - uint32_t blk_cnt = p_msc_ctx->current.blk_count; - uint32_t blk_size = p_msc_ctx->current.blk_size; - - /*Save actual request*/ - size_t req_pos = (p_event->p_blk_req->p_buff == p_msc->specific.inst.p_block_buff) ? 0 : 1; - p_msc_ctx->current.req = *p_event->p_blk_req; - - APP_USBD_MSC_REQ_BUSY_CLR(p_msc_ctx->current.req_busy_mask, req_pos); - p_msc_ctx->current.block_req_in_progress = false; - - p_msc_ctx->current.blk_idx += blk_cnt; - - if (p_msc_ctx->current.blk_datasize > blk_size * blk_cnt) - { - p_msc_ctx->current.blk_datasize -= blk_size * blk_cnt; - } - else - { - p_msc_ctx->current.blk_datasize = 0; - } - - NRF_LOG_DEBUG("write_done_handler: p_buff: %p, size: %u data size: %u req_pos: %u", - (uint32_t)p_event->p_blk_req->p_buff, - p_event->p_blk_req->blk_count, - p_msc_ctx->current.blk_datasize, - req_pos); - - if (p_msc_ctx->current.blk_datasize == 0) - { - p_msc_ctx ->current.blk_idx = p_msc_ctx ->current.blk_size = 0; - UNUSED_RETURN_VALUE(csw_wait_start(p_inst, p_msc_ctx->current.csw_status)); - return; - } - - if (p_msc_ctx->current.blk_datasize <= p_msc_ctx->current.blk_count * blk_size) - { - size_t pos = p_msc_ctx->current.workbuff_pos; - if (p_msc_ctx->current.req_busy_mask != APP_USBD_MSC_REQ_BUSY_FULL_MASK) - { - pos ^= p_msc->specific.inst.block_buff_size; - } - - NRF_BLOCK_DEV_REQUEST(req, - p_msc_ctx->current.blk_idx, - p_msc_ctx->current.blk_count, - ((uint8_t *)p_msc->specific.inst.p_block_buff + pos)); - - NRF_LOG_DEBUG("nrf_blk_dev_write_req 2: id: %u, count: %u, left: %u, ptr: %p", - req.blk_id, - req.blk_count, - p_msc_ctx->current.blk_datasize, - (uint32_t)req.p_buff); - - p_msc_ctx->current.block_req_in_progress = true; - ret_code_t ret = nrf_blk_dev_write_req(p_blk_dev, &req); - NRF_LOG_DEBUG("nrf_blk_dev_write_req 2: ret: %u", ret); - - if (ret != NRF_SUCCESS) - { - UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); - } - - return; - } - - if (!p_msc_ctx->current.trans_in_progress && - (p_msc_ctx->current.blk_datasize > p_msc_ctx->current.blk_count * blk_size)) - { - size_t size = p_msc_ctx->current.blk_datasize - p_msc_ctx->current.blk_count * blk_size; - if (size > p_msc_ctx->current.blk_count * blk_size) - { - size = p_msc_ctx->current.blk_count * blk_size; - } - - if (size > 0) - { - /*Trigger new transfer.*/ - p_msc_ctx->current.blk_count = next_transfer_blkcnt_calc(p_msc, p_msc_ctx); - ret_code_t ret = transfer_out_start(p_inst, - ((uint8_t *)p_msc->specific.inst.p_block_buff + - p_msc_ctx->current.workbuff_pos), - size, - APP_USBD_MSC_STATE_DATA_OUT); - if (ret == NRF_SUCCESS) - { - p_msc_ctx->current.trans_req_id ^= 1; - APP_USBD_MSC_REQ_BUSY_SET(p_msc_ctx->current.req_busy_mask, - p_msc_ctx->current.trans_req_id); - p_msc_ctx->current.workbuff_pos ^= p_msc->specific.inst.block_buff_size; - p_msc_ctx->current.trans_in_progress = true; - } - else - { - UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); - } - } - } -} - - -/** - * @brief Block device event handler. - * - * Mass storage block device event handler. Need to be pined to all block devices - * from initializer list. - * - * @param p_blk_dev Block device handle - * @param p_event Block device event - * - * */ -static void msc_blockdev_ev_handler(nrf_block_dev_t const * p_blk_dev, - nrf_block_dev_event_t const * p_event) -{ - switch (p_event->ev_type) { - case NRF_BLOCK_DEV_EVT_INIT: - break; - case NRF_BLOCK_DEV_EVT_UNINIT: - break; - case NRF_BLOCK_DEV_EVT_BLK_READ_DONE: - CRITICAL_REGION_ENTER(); - msc_blockdev_read_done_handler(p_blk_dev, p_event); - CRITICAL_REGION_EXIT(); - break; - case NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE: - CRITICAL_REGION_ENTER(); - msc_blockdev_write_done_handler(p_blk_dev, p_event); - CRITICAL_REGION_EXIT(); - break; - default: - break; - } -} - - -bool app_usbd_msc_sync(app_usbd_msc_t const * p_msc) -{ - bool rc = true; - ret_code_t ret = NRF_SUCCESS; - - for (size_t i = 0; i < p_msc->specific.inst.block_devs_count; ++i) - { - nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[i]; - bool flush_in_progress = true; - - ret = nrf_blk_dev_ioctl(p_blkd, - NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH, - &flush_in_progress); - - if ((ret != NRF_SUCCESS) || flush_in_progress) - { - rc = false; - } - } - - return rc; -} - -/** @} */ - -#endif // APP_USBD_MSC_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/config/app_usbd_string_config.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/config/app_usbd_string_config.h deleted file mode 100644 index 34a815f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/config/app_usbd_string_config.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2016 - 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 APP_USBD_STRING_CONFIG_H -#define APP_USBD_STRING_CONFIG_H - -/** - * @defgroup app_usbd_string_conf USBD string configuration - * @ingroup app_usbd_string_desc - * - * @brief @tagAPI52840 Configuration of the string module that can be easily affected by the final - * user. - * @{ - */ - -/** - * @brief Supported languages identifiers - * - * Comma separated list of supported languages. - */ -#define APP_USBD_STRINGS_LANGIDS \ - ((uint16_t)APP_USBD_LANG_ENGLISH | (uint16_t)APP_USBD_SUBLANG_ENGLISH_US) - -/** - * @brief Manufacturer name string descriptor - * - * Comma separated list of manufacturer names for each defined language. - * Use @ref APP_USBD_STRING_DESC macro to create string descriptor. - * - * The order of manufacturer names has to be the same like in - * @ref APP_USBD_STRINGS_LANGIDS. - */ -#define APP_USBD_STRINGS_MANUFACTURER \ - APP_USBD_STRING_DESC('N', 'o', 'r', 'd', 'i', 'c', ' ', 'S', 'e', 'm', 'i', 'c', 'o', 'n', 'd', 'u', 'c', 't', 'o', 'r') - -/** - * @brief Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by @ref APP_USBD_STRING_DESC - * or declared as global variable. - * */ -#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 - -/** - * @brief Product name string descriptor - * - * List of product names defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER - */ -#define APP_USBD_STRINGS_PRODUCT \ - APP_USBD_STRING_DESC('n', 'R', 'F', '5', '2', ' ', 'U', 'S', 'B', ' ', 'D', 'e', 'm', 'o') - - -/** - * @brief Define whether @ref APP_USBD_STRINGS_PRODUCT is created by @ref APP_USBD_STRING_DESC - * or declared as global variable. - * */ -#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 - -/** - * @brief Serial number string descriptor - * - * Create serial number string descriptor using @ref APP_USBD_STRING_DESC, - * or configure it to point to any internal variable pointer filled with descriptor. - * - * @note - * There is only one SERIAL number inside the library and it is Language independent. - */ -#define APP_USBD_STRING_SERIAL \ - APP_USBD_STRING_DESC('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0') - -/** - * @brief Define whether @ref APP_USBD_STRING_SERIAL is created by @ref APP_USBD_STRING_DESC - * or declared as global variable. - * */ -#define APP_USBD_STRING_SERIAL_EXTERN 0 - -/** - * @brief User strings default values - * - * This value stores all application specific user strings with its default initialization. - * The setup is done by X-macros. - * Expected macro parameters: - * @code - * X(mnemonic, [=str_idx], ...) - * @endcode - * - @c mnemonic: Mnemonic of the string descriptor that would be added to - * @ref app_usbd_string_desc_idx_t enumerator. - * - @c str_idx : String index value, may be set or left empty. - * For example WinUSB driver requires descriptor to be present on 0xEE index. - * Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) - * - @c ... : List of string descriptors for each defined language. - */ -#define APP_USBD_STRINGS_USER \ - X(APP_USER_1, , APP_USBD_STRING_DESC('U', 's', 'e', 'r', ' ', '1')) - -/** @} */ -#endif /* APP_USBD_STRING_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.c deleted file mode 100644 index d435a31..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.c +++ /dev/null @@ -1,867 +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_config.h" -#if NFC_T2T_HAL_ENABLED - -#include "hal_nfc_t2t.h" -#include -#include -#include "nfc_t2t_lib.h" -#include "nfc_fixes.h" -#include "nrf.h" -#include "app_util_platform.h" -#include "nordic_common.h" -#include "nrf_drv_clock.h" - -#define NRF_LOG_MODULE_NAME hal_nfc -#if HAL_NFC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL HAL_NFC_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR HAL_NFC_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR HAL_NFC_CONFIG_DEBUG_COLOR -#else // HAL_NFC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif // HAL_NFC_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#if HAL_NFC_CONFIG_DEBUG_PIN_ENABLED - #include "nrf_gpio.h" - - #define HAL_NFC_DEBUG_PIN_CONFIG(pin_num) nrf_gpio_cfg_output(pin_num) - #define HAL_NFC_DEBUG_PIN_CLEAR(pin_num) nrf_gpio_pin_clear(pin_num) - #define HAL_NFC_DEBUG_PIN_SET(pin_num) nrf_gpio_pin_set(pin_num) - - #define HAL_NFC_DEBUG_PINS_INITIALIZE() \ - do{ \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_HCLOCK_ON_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_NFC_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_NFC_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_DETECT_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_DETECT_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_TIMER4_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_TIMER4_EVENT_DEBUG_PIN); \ - } while(0) -#else - #define HAL_NFC_DEBUG_PIN_CLEAR(pin_num) - #define HAL_NFC_DEBUG_PIN_SET(pin_num) - #define HAL_NFC_DEBUG_PINS_INITIALIZE() -#endif // HAL_NFC_CONFIG_DEBUG_PIN_ENABLED - - -/* NFC library version history: - * #define NFC_LIB_VERSION 0x00 first experimental version intended for nRF52 IC rev. Engineering A (PCA10036, part of nRF52 Preview Development Kit) - * #define NFC_LIB_VERSION 0x01 experimental version intended for nRF52 IC rev. Engineering B (PCA10040, part of nRF52 Development Kit) - * #define NFC_LIB_VERSION 0x02 experimental version intended for fix IC-12826 and fix: not released HFCLK in SENSE mode - * #define NFC_LIB_VERSION 0x03 experimental version intended for support logging module - * #define NFC_LIB_VERSION 0x04 experimental version intended for nRF52840 IC rev. Engineering A (PCA10056, part of nRF52840 Preview Development Kit). Removed PCA10036 support. - */ - -#define NFC_LIB_VERSION 0x03u /**< Internal: current NFC lib. version */ - -#define T2T_INTERNAL_BYTES_NR 10u /**< Number of internal bytes defined by Type 2 Tag Operation Technical Specification */ -#define CASCADE_TAG_BYTE 0x88u /**< Constant defined by ISO/EIC 14443-3 */ - -#define NFCID1_3RD_LAST_BYTE2_SHIFT 16u /**< Shift value for NFC ID byte 2 */ -#define NFCID1_3RD_LAST_BYTE1_SHIFT 8u /**< Shift value for NFC ID byte 1 */ -#define NFCID1_3RD_LAST_BYTE0_SHIFT 0u /**< Shift value for NFC ID byte 0 */ -#define NFCID1_2ND_LAST_BYTE2_SHIFT 16u /**< Shift value for NFC ID byte 2 */ -#define NFCID1_2ND_LAST_BYTE1_SHIFT 8u /**< Shift value for NFC ID byte 1 */ -#define NFCID1_2ND_LAST_BYTE0_SHIFT 0u /**< Shift value for NFC ID byte 0 */ -#define NFCID1_LAST_BYTE3_SHIFT 24u /**< Shift value for NFC ID byte 3 */ -#define NFCID1_LAST_BYTE2_SHIFT 16u /**< Shift value for NFC ID byte 2 */ -#define NFCID1_LAST_BYTE1_SHIFT 8u /**< Shift value for NFC ID byte 1 */ -#define NFCID1_LAST_BYTE0_SHIFT 0u /**< Shift value for NFC ID byte 0 */ - -#define NFCID1_SINGLE_SIZE 4u /**< Length of single size NFCID1 */ -#define NFCID1_DOUBLE_SIZE 7u /**< Length of double size NFCID1 */ -#define NFCID1_TRIPLE_SIZE 10u /**< Length of triple size NFCID1 */ -#define NFCID1_DEFAULT_LENGHT NFCID1_DOUBLE_SIZE /**< Length of NFCID1 if user does not provide one */ -#define NFCID1_MAX_LENGHT NFCID1_TRIPLE_SIZE /**< Maximum length of NFCID1 */ - -#define NFC_RX_BUFFER_SIZE 16u /**< NFC Rx data buffer size */ -#define T2T_READ_CMD 0x30u /**< Type 2 Tag Read command identifier */ -#define NFC_SLP_REQ_CMD 0x50u /**< NFC SLP_REQ command identifier */ -#define NFC_CRC_SIZE 2u /**< CRC size in bytes */ - -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - #define NRF_NFCT_ERRORSTATUS_ALL (NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk) /**< Mask for clearing all error flags in NFCT_ERRORSTATUS register */ -#else - #define NRF_NFCT_ERRORSTATUS_ALL (NFCT_ERRORSTATUS_NFCFIELDTOOWEAK_Msk | \ - NFCT_ERRORSTATUS_NFCFIELDTOOSTRONG_Msk | \ - NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk) /**< Mask for clearing all error flags in NFCT_ERRORSTATUS register */ -#endif // HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - -#define NRF_NFCT_FRAMESTATUS_RX_MSK (NFCT_FRAMESTATUS_RX_OVERRUN_Msk | \ - NFCT_FRAMESTATUS_RX_PARITYSTATUS_Msk | \ - NFCT_FRAMESTATUS_RX_CRCERROR_Msk) /**< Mask for clearing all flags in NFCT_FRAMESTATUS_RX register */ -#define NFC_FIELD_ON_MASK NFCT_FIELDPRESENT_LOCKDETECT_Msk /**< Mask for checking FIELDPRESENT register for state: FIELD ON. */ -#define NFC_FIELD_OFF_MASK NFCT_FIELDPRESENT_FIELDPRESENT_Msk /**< Mask for checking FIELDPRESENT register for state: FIELD OFF. */ - -typedef enum -{ - NFC_FIELD_STATE_NONE, /**< Initial value indicating no NFCT Field events. */ - NFC_FIELD_STATE_OFF, /**< NFCT FIELDLOST Event has been set. */ - NFC_FIELD_STATE_ON, /**< NFCT FIELDDETECTED Event has been set. */ - NFC_FIELD_STATE_UNKNOWN /**< Both NFCT Field Events have been set - ambiguous state. */ -}nfct_field_sense_state_t; - -/* Static function declarations */ -static inline void nrf_nfct_event_clear(volatile uint32_t * p_event); -static inline void nrf_nfct_clock_event_handler(nrf_drv_clock_evt_type_t event); -static inline void nrf_nfct_field_event_handler(volatile nfct_field_sense_state_t field_state); -static void hal_nfc_nfcid1_default_bytes(void); -static void hal_nfc_nfcid1_registers_setup(void); -static void hal_nfc_internal_bytes_setup(void); - -/* Static data */ -static hal_nfc_callback_t m_nfc_lib_callback = (hal_nfc_callback_t) NULL; /**< Callback to nfc_lib layer */ -static void * m_nfc_lib_context; /**< Callback execution context */ -static volatile uint8_t m_nfc_rx_buffer[NFC_RX_BUFFER_SIZE] = {0}; /**< Buffer for NFC Rx data */ -static volatile bool m_slp_req_received = false; /**< Flag indicating that SLP_REQ Command was received */ -static volatile bool m_field_on = false; /**< Flag indicating that NFC Tag field is present */ -static nrf_drv_clock_handler_item_t m_clock_handler_item; /**< Clock event handler item structure */ -static uint8_t m_nfcid1_length = 0; /**< Length of NFCID1 provided by user or 0 if not initialized yet */ -static uint8_t m_nfcid1_data[NFCID1_MAX_LENGHT] = {0}; /**< Content of NFCID1 */ - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - static volatile uint32_t m_nfc_fieldpresent_mask = NFC_FIELD_OFF_MASK; /**< Mask used for NFC Field polling in NFCT_FIELDPRESENT register */ -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#define NRF_NFCT_POWER (*(uint32_t volatile *)(0x40005FFC)) - -#define NFC_HAL_FIELDPRESENT_MASK (NFCT_FIELDPRESENT_LOCKDETECT_Msk | \ - NFCT_FIELDPRESENT_FIELDPRESENT_Msk) - -#define NFC_HAL_FIELDPRESENT_IS_LOST ((NFCT_FIELDPRESENT_FIELDPRESENT_NoField << \ - NFCT_FIELDPRESENT_FIELDPRESENT_Pos) | \ - (NFCT_FIELDPRESENT_LOCKDETECT_NotLocked << \ - NFCT_FIELDPRESENT_LOCKDETECT_Pos)) - -#ifndef HAL_NFC_FIELD_TIMER_PERIOD - #define HAL_NFC_FIELD_TIMER_PERIOD 100 /* unit - us */ -#endif - -static inline void hal_nfc_re_setup(void); -static void hal_nfc_field_check(void); - -static void field_timer_with_callback_config() -{ - NRF_TIMER4->MODE = TIMER_MODE_MODE_Timer << TIMER_MODE_MODE_Pos; - NRF_TIMER4->BITMODE = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos; - NRF_TIMER4->PRESCALER = 4 << TIMER_PRESCALER_PRESCALER_Pos; - NRF_TIMER4->CC[0] = HAL_NFC_FIELD_TIMER_PERIOD << TIMER_CC_CC_Pos; - NRF_TIMER4->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos; - NRF_TIMER4->INTENSET = TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos; - - NVIC_ClearPendingIRQ(TIMER4_IRQn); - NVIC_SetPriority(TIMER4_IRQn, NFCT_CONFIG_IRQ_PRIORITY); - NVIC_EnableIRQ(TIMER4_IRQn); -} - -void TIMER4_IRQHandler(void) -{ - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_TIMER4_EVENT_DEBUG_PIN); - hal_nfc_field_check(); - NRF_TIMER4->EVENTS_COMPARE[0] = 0; - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_TIMER4_EVENT_DEBUG_PIN); -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -/** - * @brief Common part of setup used for NFCT initialization and reinitialization. - */ -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -static void hal_nfc_common_hw_setup() -#else -static inline void hal_nfc_common_hw_setup() -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -{ -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND -/* Begin: Bugfix for FTPAN-98 */ - *(volatile uint32_t *) 0x4000568C = 0x00038148; -/* End: Bugfix for FTPAN-98 */ -/* Begin: Bugfix for FTPAN-144 */ - *(volatile uint32_t *) 0x4000561c = 0x01; - *(volatile uint32_t *) 0x4000562c = 0x3F; - *(volatile uint32_t *) 0x4000563c = 0x0; -/* End: Bugfix for FTPAN-144 */ -#endif // HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - NRF_NFCT->INTENSET = (NFCT_INTENSET_FIELDDETECTED_Enabled << NFCT_INTENSET_FIELDDETECTED_Pos); -#else - NRF_NFCT->INTENSET = (NFCT_INTENSET_FIELDDETECTED_Enabled << NFCT_INTENSET_FIELDDETECTED_Pos) | - (NFCT_INTENSET_FIELDLOST_Enabled << NFCT_INTENSET_FIELDLOST_Pos); -#endif - - NRF_NFCT->INTENSET = (NFCT_INTENSET_ERROR_Enabled << NFCT_INTENSET_ERROR_Pos) | - (NFCT_INTENSET_SELECTED_Enabled << NFCT_INTENSET_SELECTED_Pos); - - hal_nfc_nfcid1_registers_setup(); -} - -/** @brief Setup NRF_NFCT->NFCID1 and NRF_NFCT->SENSRES registers based on m_nfcid1_data and m_nfcid1_length variables. - */ -static void hal_nfc_nfcid1_registers_setup(void) -{ - uint32_t sens_res_size; // Value that will be written to NRF_NFCT->SENSRES - uint8_t* p_nfcid_remaining_data; // Points to the first byte of m_nfcid1_data remaining to write to NRF_NFCT->NFCID1 registers - - p_nfcid_remaining_data = m_nfcid1_data; - - if (m_nfcid1_length == NFCID1_SINGLE_SIZE) - { - sens_res_size = NFCT_SENSRES_NFCIDSIZE_NFCID1Single; - } - else - { - if (m_nfcid1_length == NFCID1_DOUBLE_SIZE) - { - sens_res_size = NFCT_SENSRES_NFCIDSIZE_NFCID1Double; - } - else // then m_nfcid1_length == NFCID1_TRIPLE_SIZE - { - /* MSB of NFCID1_3RD_LAST register is not used - always 0 */ - NRF_NFCT->NFCID1_3RD_LAST = - ((uint32_t) p_nfcid_remaining_data[0] << NFCID1_3RD_LAST_BYTE2_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[1] << NFCID1_3RD_LAST_BYTE1_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[2] << NFCID1_3RD_LAST_BYTE0_SHIFT); - p_nfcid_remaining_data += 3; - sens_res_size = NFCT_SENSRES_NFCIDSIZE_NFCID1Triple; - } - /* MSB of NFCID1_2ND_LAST register is not used - always 0 */ - NRF_NFCT->NFCID1_2ND_LAST = - ((uint32_t) p_nfcid_remaining_data[0] << NFCID1_2ND_LAST_BYTE2_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[1] << NFCID1_2ND_LAST_BYTE1_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[2] << NFCID1_2ND_LAST_BYTE0_SHIFT); - p_nfcid_remaining_data += 3; - } - - NRF_NFCT->NFCID1_LAST = - ((uint32_t) p_nfcid_remaining_data[0] << NFCID1_LAST_BYTE3_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[1] << NFCID1_LAST_BYTE2_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[2] << NFCID1_LAST_BYTE1_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[3] << NFCID1_LAST_BYTE0_SHIFT); - - /* Begin: Bugfix for FTPAN-25 (IC-9929) */ - /* Workaround for wrong SENSRES values require using SDD00001, but here SDD00100 is used - because it's required to operate with Windows Phone */ - NRF_NFCT->SENSRES = - (sens_res_size << NFCT_SENSRES_NFCIDSIZE_Pos) | - (NFCT_SENSRES_BITFRAMESDD_SDD00100 << NFCT_SENSRES_BITFRAMESDD_Pos); - /* End: Bugfix for FTPAN-25 (IC-9929)*/ -} - -/** @brief Call nfc_t2t_internal_set() with data generated based on m_nfcid1_data and m_nfcid1_length variables. - */ -static void hal_nfc_internal_bytes_setup(void) -{ - if (m_nfcid1_length == NFCID1_TRIPLE_SIZE) - { - (void) nfc_t2t_internal_set(m_nfcid1_data, T2T_INTERNAL_BYTES_NR); - } - else - { - uint8_t nfc_internal[T2T_INTERNAL_BYTES_NR]; - - if (m_nfcid1_length == NFCID1_DOUBLE_SIZE) - { - // CASCADE TAG send over the air, but not included in internal data - nfc_internal[0] = m_nfcid1_data[0]; // UID0 = Manufacturer ID - nfc_internal[1] = m_nfcid1_data[1]; // UID1 - nfc_internal[2] = m_nfcid1_data[2]; // UID2 - nfc_internal[3] = (uint8_t) CASCADE_TAG_BYTE ^ nfc_internal[0] ^ - nfc_internal[1] ^ nfc_internal[2]; // BCC0 = XOR over the 4 previous bytes - nfc_internal[4] = m_nfcid1_data[3]; // UID3 - nfc_internal[5] = m_nfcid1_data[4]; // UID4 - nfc_internal[6] = m_nfcid1_data[5]; // UID5 - nfc_internal[7] = m_nfcid1_data[6]; // UID6 - nfc_internal[8] = nfc_internal[4] ^ nfc_internal[5] ^ - nfc_internal[6] ^ nfc_internal[7]; // BCC1 = XOR over the 4 previous bytes - nfc_internal[9] = NFC_LIB_VERSION; // For internal use - } - else // then m_nfcid1_length == NFCID1_SINGLE_SIZE - { - nfc_internal[0] = m_nfcid1_data[0]; // UID0 = Manufacturer ID - nfc_internal[1] = m_nfcid1_data[1]; // UID1 - nfc_internal[2] = m_nfcid1_data[2]; // UID2 - nfc_internal[3] = m_nfcid1_data[3]; // UID3 - nfc_internal[4] = nfc_internal[0] ^ nfc_internal[1] ^ - nfc_internal[2] ^ nfc_internal[3]; // BCC0 = XOR over the 4 previous bytes - memset(&nfc_internal[5], 0xFF, 4); // 4-byte padding - nfc_internal[9] = NFC_LIB_VERSION; // For internal use - } - - (void) nfc_t2t_internal_set(nfc_internal, T2T_INTERNAL_BYTES_NR); - } -} - -ret_code_t hal_nfc_setup(hal_nfc_callback_t callback, void * p_context) -{ - m_nfc_lib_callback = callback; - m_nfc_lib_context = p_context; - - if (m_nfcid1_length == 0) - { - m_nfcid1_length = NFCID1_DEFAULT_LENGHT; - hal_nfc_nfcid1_default_bytes(); - } - - hal_nfc_common_hw_setup(); - hal_nfc_internal_bytes_setup(); - - /* Initialize SDK Clock module for handling high precission clock requests */ - m_clock_handler_item.event_handler = nrf_nfct_clock_event_handler; - m_clock_handler_item.p_next = NULL; - - ret_code_t err_code = nrf_drv_clock_init(); - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - field_timer_with_callback_config(); -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - - NRF_LOG_INFO("Init"); - HAL_NFC_DEBUG_PINS_INITIALIZE(); - - if ((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_MODULE_ALREADY_INITIALIZED)) - { - return NRF_SUCCESS; - } - else - { - return NRF_ERROR_INTERNAL; - } -} - -/**@brief Function for clearing an event flag in NRF_NFCT registers. - * - * @param[in] p_event Pointer to event register. - * - */ -static inline void nrf_nfct_event_clear(volatile uint32_t * p_event) -{ - *p_event = 0; - - /* Perform read to ensure clearing is effective */ - volatile uint32_t dummy = *p_event; - (void)dummy; -} - -/**@brief Function for handling events from Clock Module. - * - * @param[in] event Clock event. - * - */ -static inline void nrf_nfct_clock_event_handler(nrf_drv_clock_evt_type_t event) -{ - switch(event) - { - case NRF_DRV_CLOCK_EVT_HFCLK_STARTED: - /* Activate NFCT only when HFXO is running */ - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); //DEBUG! - NRF_NFCT->TASKS_ACTIVATE = 1; - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); //DEBUG! - break; - - default: - /* No implementation required */ - break; - } -} - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -static inline void nrf_nfct_field_lost_hfclk_handle(void) -{ - /* Begin: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - // reset the NFC for release HFCLK - __DMB(); - NRF_NFCT_POWER = 0; - __DMB(); - NRF_NFCT_POWER = 1; - /* END: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -/**@brief Function for evaluating and handling NFC field events. - * - * @param[in] field_state Current field state. - * - */ -static inline void nrf_nfct_field_event_handler(volatile nfct_field_sense_state_t field_state) -{ - if (field_state == NFC_FIELD_STATE_UNKNOWN) - { - /* Probe NFC field */ - uint32_t field_present = NRF_NFCT->FIELDPRESENT; - - if (field_present & m_nfc_fieldpresent_mask) - { - field_state = NFC_FIELD_STATE_ON; - } - else - { - field_state = NFC_FIELD_STATE_OFF; - } - } - - /* Field event service */ - switch(field_state) - { - case NFC_FIELD_STATE_ON: - if (!m_field_on) - { - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); //DEBUG! - nrf_drv_clock_hfclk_request(&m_clock_handler_item); - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); //DEBUG! - } - m_field_on = true; - break; - - case NFC_FIELD_STATE_OFF: - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); //DEBUG! - -/* Begin: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - *(volatile uint32_t *)0x40005010 = 1; -#endif // HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND -/* END: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - - NRF_NFCT->TASKS_SENSE = 1; - nrf_drv_clock_hfclk_release(); - m_field_on = false; - - NRF_NFCT->INTENCLR = - (NFCT_INTENCLR_RXFRAMEEND_Clear << NFCT_INTENCLR_RXFRAMEEND_Pos) | - (NFCT_INTENCLR_RXERROR_Clear << NFCT_INTENCLR_RXERROR_Pos); - - /* Change mask to FIELD_OFF state - trigger FIELD_ON even if HW has not locked to the field */ - m_nfc_fieldpresent_mask = NFC_FIELD_OFF_MASK; - - if ((m_nfc_lib_callback != NULL) ) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_FIELD_OFF, 0, 0); - } - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); //DEBUG! - break; - - default: - /* No implementation required */ - break; - } -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - - -/** @brief Writes default values to m_nfcid1_data based on NRF_FICR->NFC registers. - */ -static void hal_nfc_nfcid1_default_bytes(void) -{ - uint32_t nfc_tag_header0 = NRF_FICR->NFC.TAGHEADER0; - uint32_t nfc_tag_header1 = NRF_FICR->NFC.TAGHEADER1; - uint32_t nfc_tag_header2 = NRF_FICR->NFC.TAGHEADER2; - - m_nfcid1_data[0] = (uint8_t) LSB_32(nfc_tag_header0 >> 0); - m_nfcid1_data[1] = (uint8_t) LSB_32(nfc_tag_header0 >> 8); - m_nfcid1_data[2] = (uint8_t) LSB_32(nfc_tag_header0 >> 16); - m_nfcid1_data[3] = (uint8_t) LSB_32(nfc_tag_header1 >> 0); - m_nfcid1_data[4] = (uint8_t) LSB_32(nfc_tag_header1 >> 8); - m_nfcid1_data[5] = (uint8_t) LSB_32(nfc_tag_header1 >> 16); - m_nfcid1_data[6] = (uint8_t) LSB_32(nfc_tag_header1 >> 24); - m_nfcid1_data[7] = (uint8_t) LSB_32(nfc_tag_header2 >> 0); - m_nfcid1_data[8] = (uint8_t) LSB_32(nfc_tag_header2 >> 8); - m_nfcid1_data[9] = (uint8_t) LSB_32(nfc_tag_header2 >> 16); -} - - - -ret_code_t hal_nfc_parameter_set(hal_nfc_param_id_t id, void * p_data, size_t data_length) -{ - if (id == HAL_NFC_PARAM_ID_NFCID1) - { - if (data_length == 1) - { - uint8_t id_length = *((uint8_t *) p_data); - if (id_length == NFCID1_SINGLE_SIZE || id_length == NFCID1_DOUBLE_SIZE || - id_length == NFCID1_TRIPLE_SIZE) - { - m_nfcid1_length = id_length; - hal_nfc_nfcid1_default_bytes(); - } - else - { - return NRF_ERROR_INVALID_LENGTH; - } - } - else if (data_length == NFCID1_SINGLE_SIZE || data_length == NFCID1_DOUBLE_SIZE || - data_length == NFCID1_TRIPLE_SIZE) - { - m_nfcid1_length = (uint8_t) data_length; - memcpy(m_nfcid1_data, p_data, data_length); - } - else - { - return NRF_ERROR_INVALID_LENGTH; - } - hal_nfc_nfcid1_registers_setup(); - hal_nfc_internal_bytes_setup(); - } - - return NRF_SUCCESS; -} - -ret_code_t hal_nfc_parameter_get(hal_nfc_param_id_t id, void * p_data, size_t * p_max_data_length) -{ - if (id == HAL_NFC_PARAM_ID_NFCID1) - { - if (m_nfcid1_length == 0) - { - m_nfcid1_length = NFCID1_DEFAULT_LENGHT; - hal_nfc_nfcid1_default_bytes(); - } - - if (*p_max_data_length < (size_t) m_nfcid1_length) - { - return NRF_ERROR_DATA_SIZE; - } - - *p_max_data_length = (size_t) m_nfcid1_length; - memcpy(p_data, m_nfcid1_data, m_nfcid1_length); - } - - return NRF_SUCCESS; -} - - -ret_code_t hal_nfc_start(void) -{ - NRF_NFCT->ERRORSTATUS = NRF_NFCT_ERRORSTATUS_ALL; - NRF_NFCT->TASKS_SENSE = 1; - - NVIC_ClearPendingIRQ(NFCT_IRQn); - NVIC_SetPriority(NFCT_IRQn, NFCT_CONFIG_IRQ_PRIORITY); - NVIC_EnableIRQ(NFCT_IRQn); - - NRF_LOG_INFO("Start"); - return NRF_SUCCESS; -} - -ret_code_t hal_nfc_send(const uint8_t * p_data, size_t data_length) -{ - if (data_length == 0) - { - return NRF_ERROR_DATA_SIZE; - } - - /* Ignore previous TX END events, SW takes care only for data frames which tranmission is triggered in this function */ - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMEEND); - - NRF_NFCT->PACKETPTR = (uint32_t) p_data; - NRF_NFCT->TXD.AMOUNT = (data_length << NFCT_TXD_AMOUNT_TXDATABYTES_Pos) & - NFCT_TXD_AMOUNT_TXDATABYTES_Msk; - NRF_NFCT->INTENSET = (NFCT_INTENSET_TXFRAMEEND_Enabled << NFCT_INTENSET_TXFRAMEEND_Pos); - NRF_NFCT->TASKS_STARTTX = 1; - - NRF_LOG_INFO("Send"); - return NRF_SUCCESS; -} - -ret_code_t hal_nfc_stop(void) -{ - NRF_NFCT->TASKS_DISABLE = 1; - - NRF_LOG_INFO("Stop"); - return NRF_SUCCESS; -} - -ret_code_t hal_nfc_done(void) -{ - m_nfc_lib_callback = (hal_nfc_callback_t) NULL; - - return NRF_SUCCESS; -} - -void NFCT_IRQHandler(void) -{ - nfct_field_sense_state_t current_field = NFC_FIELD_STATE_NONE; - - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_NFC_EVENT_DEBUG_PIN); //DEBUG! - - if (NRF_NFCT->EVENTS_FIELDDETECTED && (NRF_NFCT->INTEN & NFCT_INTEN_FIELDDETECTED_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_FIELDDETECTED); - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_DETECT_EVENT_DEBUG_PIN); //DEBUG! - current_field = NFC_FIELD_STATE_ON; - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_DETECT_EVENT_DEBUG_PIN); //DEBUG! - - NRF_LOG_DEBUG("Field detected"); - } - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - if (NRF_NFCT->EVENTS_FIELDLOST && (NRF_NFCT->INTEN & NFCT_INTEN_FIELDLOST_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_FIELDLOST); - current_field = - (current_field == NFC_FIELD_STATE_NONE) ? NFC_FIELD_STATE_OFF : NFC_FIELD_STATE_UNKNOWN; - - NRF_LOG_DEBUG("Field lost"); - } -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - - /* Perform actions if any FIELD event is active */ - if (current_field != NFC_FIELD_STATE_NONE) - { - nrf_nfct_field_event_handler(current_field); - } - - if (NRF_NFCT->EVENTS_RXFRAMEEND && (NRF_NFCT->INTEN & NFCT_INTEN_RXFRAMEEND_Msk)) - { - /* Take into account only number of whole bytes */ - uint32_t rx_data_size = ((NRF_NFCT->RXD.AMOUNT & NFCT_RXD_AMOUNT_RXDATABYTES_Msk) >> - NFCT_RXD_AMOUNT_RXDATABYTES_Pos) - NFC_CRC_SIZE; - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXFRAMEEND); - - /* Look for Tag 2 Type READ Command */ - if (m_nfc_rx_buffer[0] == T2T_READ_CMD) - { - if(m_nfc_lib_callback != NULL) - { - /* This callback should trigger transmission of READ Response */ - m_nfc_lib_callback(m_nfc_lib_context, - HAL_NFC_EVENT_DATA_RECEIVED, - (void*)m_nfc_rx_buffer, - rx_data_size); - } - } - else - { - /* Indicate that SLP_REQ was received - this will cause FRAMEDELAYTIMEOUT error */ - if(m_nfc_rx_buffer[0] == NFC_SLP_REQ_CMD) - { - m_slp_req_received = true; - } - /* Not a READ Command, so wait for next frame reception */ - NRF_NFCT->TASKS_ENABLERXDATA = 1; - } - - NRF_LOG_DEBUG("Rx fend"); - } - - if (NRF_NFCT->EVENTS_TXFRAMEEND && (NRF_NFCT->INTEN & NFCT_INTEN_TXFRAMEEND_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMEEND); - - /* Disable TX END event to ignore frame transmission other than READ response */ - NRF_NFCT->INTENCLR = (NFCT_INTENCLR_TXFRAMEEND_Clear << NFCT_INTENCLR_TXFRAMEEND_Pos); - - /* Set up for reception */ - NRF_NFCT->PACKETPTR = (uint32_t) m_nfc_rx_buffer; - NRF_NFCT->MAXLEN = NFC_RX_BUFFER_SIZE; - NRF_NFCT->TASKS_ENABLERXDATA = 1; - - if (m_nfc_lib_callback != NULL) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_DATA_TRANSMITTED, 0, 0); - } - - NRF_LOG_DEBUG("Tx fend"); - } - - if (NRF_NFCT->EVENTS_SELECTED && (NRF_NFCT->INTEN & NFCT_INTEN_SELECTED_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_SELECTED); - /* Clear also RX END and RXERROR events because SW does not take care of commands which were received before selecting the tag */ - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXFRAMEEND); - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXERROR); - - /* Set up registers for EasyDMA and start receiving packets */ - NRF_NFCT->PACKETPTR = (uint32_t) m_nfc_rx_buffer; - NRF_NFCT->MAXLEN = NFC_RX_BUFFER_SIZE; - NRF_NFCT->TASKS_ENABLERXDATA = 1; - - NRF_NFCT->INTENSET = (NFCT_INTENSET_RXFRAMEEND_Enabled << NFCT_INTENSET_RXFRAMEEND_Pos) | - (NFCT_INTENSET_RXERROR_Enabled << NFCT_INTENSET_RXERROR_Pos); - - /* At this point any previous error status can be ignored */ - NRF_NFCT->FRAMESTATUS.RX = NRF_NFCT_FRAMESTATUS_RX_MSK; - NRF_NFCT->ERRORSTATUS = NRF_NFCT_ERRORSTATUS_ALL; - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - /* Change mask to FIELD_ON state - trigger FIELD_ON only if HW has locked to the field */ - m_nfc_fieldpresent_mask = NFC_FIELD_ON_MASK; -#endif - - if (m_nfc_lib_callback != NULL) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_FIELD_ON, 0, 0); - } - - NRF_LOG_DEBUG("Selected"); - } - - if (NRF_NFCT->EVENTS_RXERROR && (NRF_NFCT->INTEN & NFCT_INTEN_RXERROR_Msk)) - { - uint32_t rx_status = NRF_NFCT->FRAMESTATUS.RX; - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXERROR); - - NRF_LOG_DEBUG("Rx error (0x%x)", (unsigned int) rx_status); - (void) rx_status; - - /* Clear rx frame status */ - NRF_NFCT->FRAMESTATUS.RX = NRF_NFCT_FRAMESTATUS_RX_MSK; - } - - if (NRF_NFCT->EVENTS_ERROR && (NRF_NFCT->INTEN & NFCT_INTEN_ERROR_Msk)) - { - uint32_t err_status = NRF_NFCT->ERRORSTATUS; - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_ERROR); - - /* Clear FRAMEDELAYTIMEOUT error (expected HW behaviour) when SLP_REQ command was received */ - if ((err_status & NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk) && m_slp_req_received) - { - NRF_NFCT->ERRORSTATUS = NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk; - m_slp_req_received = false; - - NRF_LOG_DEBUG("Error (SLP_REQ)"); - } - /* Report any other error */ - err_status &= ~NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk; - if (err_status) - { - NRF_LOG_DEBUG("Error (0x%x)", (unsigned int) err_status); - } - - /* Clear error status */ - NRF_NFCT->ERRORSTATUS = NRF_NFCT_ERRORSTATUS_ALL; - } - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_NFC_EVENT_DEBUG_PIN); //DEBUG! -} - - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - #error Wrong workaround combination -#endif - -static uint32_t field_state_cnt = 0; -/** - * @brief Function for evaluating and handling NFC fieldlost event. - */ -static void hal_nfc_field_check(void) -{ - uint32_t nfc_fieldpresen_masked; - - nfc_fieldpresen_masked = NRF_NFCT->FIELDPRESENT & NFC_HAL_FIELDPRESENT_MASK; - - if (nfc_fieldpresen_masked == NFC_HAL_FIELDPRESENT_IS_LOST) - { - ++field_state_cnt; - if (field_state_cnt > 7) - { - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); //DEBUG! - - NRF_TIMER4->TASKS_SHUTDOWN = 1; - - nrf_drv_clock_hfclk_release(); - - nrf_nfct_field_lost_hfclk_handle(); - - if ((m_nfc_lib_callback != NULL)) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_FIELD_OFF, 0, 0); - } - m_field_on = false; - - /* Begin: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - // resume the NFCT to initialized state - hal_nfc_re_setup(); - /* End: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); //DEBUG! - } - - return; - } - - field_state_cnt = 0; -} - -/** - * @brief Function for enablinge hight precision clock and start eveluating fieldlost event. - */ -static inline void nrf_nfct_field_event_handler(volatile nfct_field_sense_state_t field_state) -{ - if (!m_field_on) - { - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); //DEBUG! - nrf_drv_clock_hfclk_request(&m_clock_handler_item); - - NRF_TIMER4->TASKS_CLEAR = 1; - NRF_TIMER4->TASKS_START = 1; - field_state_cnt = 0; - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); //DEBUG! - } - m_field_on = true; -} - -/** - * @brief Function for resume the NFCT to initialized state after software's reset. - */ -static inline void hal_nfc_re_setup(void) -{ - hal_nfc_common_hw_setup(); - - NRF_LOG_INFO("Reinitialize"); -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#endif // NFC_T2T_HAL_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.h deleted file mode 100644 index fa52344..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.h +++ /dev/null @@ -1,203 +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 HAL_NFC_H__ -#define HAL_NFC_H__ - -/** @file - * @defgroup nfc_t2t_hal NFC Type 2 Tag HAL - * @{ - * @ingroup nfc_t2t - * @brief @tagAPI52 Hardware abstraction layer for the NFC Type 2 Tag library. - * - * @note Before the NFCT peripheral enters ACTIVATED state, the HFXO must be running. - * To fulfill this requirement and allow other software modules to also request the HFXO, the NFC Type 4 Tag HAL uses @ref nrf_drv_clock module. - * - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief Events passed to the upper-layer callback function. */ -typedef enum { - HAL_NFC_EVENT_FIELD_ON, ///< Field is detected. - HAL_NFC_EVENT_FIELD_OFF, ///< Field is lost. - HAL_NFC_EVENT_DATA_RECEIVED, ///< Data is received. - HAL_NFC_EVENT_DATA_TRANSMITTED ///< Data is Transmitted. -} hal_nfc_event_t; - - -/** @brief Parameter IDs for set/get function. */ -typedef enum { - HAL_NFC_PARAM_ID_TESTING, ///< Used for unit tests. - HAL_NFC_PARAM_ID_NFCID1, /**< NFCID1 value, data can be 4, 7, or 10 bytes long (single, double, or triple size). - To use default NFCID1 of specific length pass one byte containing requested length. - Default 7-byte NFCID1 will be used if this parameter was not set. This parameter can be - set before nfc_t2t_setup() to set initial NFCID1 and it can be changed later. */ - HAL_NFC_PARAM_ID_UNKNOWN -} hal_nfc_param_id_t; - - -/** @brief Callback from HAL_NFC layer into the upper layer. - * - * If event == HAL_NFC_EVENT_DATA_RECEIVED: - * p_data points to the received packet. The memory belongs to the HAL_NFC layer and - * is guaranteed to be valid only until the callback returns. - * - * If event == HAL_NFC_EVENT_DATA_TRANSMITTED: - * p_data points to the transmitted packet. The memory belongs to the application. - * - * If event == \: - * p_data definition is event-specific (to be defined). - * - * @param[in] p_context Context for callback execution. - * @param[in] event The event that occurred. - * @param[in] p_data Received/transmitted data or NULL. - * @param[in] data_length Size of the received/transmitted packet. - */ -typedef void (* hal_nfc_callback_t)(void * p_context, - hal_nfc_event_t event, - const uint8_t * p_data, - size_t data_length); - - -/** @brief Function for initializing the NFC layer. - * - * This function provides a pointer to a callback function and the callback context - * to the NFC layer. - * - * @param[in] callback Pointer to the callback function. - * @param[in] p_context Context of callback. - * - * @retval NRF_SUCCESS If the NFC layer was initialized successfully. If one - * of the arguments was invalid, an error code is returned. - */ -ret_code_t hal_nfc_setup(hal_nfc_callback_t callback, void * p_context); - - -/** @brief Function for setting a HAL_NFC parameter. - * - * This function allows to set any parameter defined as available by HAL_NFC. - * - * @param[in] id ID of the parameter to set. - * @param[in] p_data Pointer to the buffer containing the data to set. - * @param[in] data_length Size of the buffer containing the data to set. - * - * @retval NRF_SUCCESS If the parameter was set successfully. If one of the arguments - * was invalid (for example, wrong data length), an error code - * is returned. - */ -ret_code_t hal_nfc_parameter_set(hal_nfc_param_id_t id, void * p_data, size_t data_length); - - -/** @brief Function for querying a HAL_NFC parameter value. - * - * The queried value will be placed into the passed data buffer. If the buffer - * is too small, maxDataLength will contain the required buffer size. - * - * @param[in] id ID of the parameter to query. - * @param[in] p_data Pointer to a buffer receiving the queried data. - * @param[in, out] p_max_data_length Size of the buffer. It receives the required size if buffer is too small. - * - * @retval NRF_SUCCESS If the parameter was received successfully. If one of the arguments - * was invalid (for example, the buffer was too small), an error code - * is returned. - */ -ret_code_t hal_nfc_parameter_get(hal_nfc_param_id_t id, void * p_data, size_t * p_max_data_length); - - -/** @brief Function for starting the NFC subsystem. - * - * After this function completes, NFC readers will be able to detect the chip. - * - * @retval NRF_SUCCESS If the NFC subsystem was started successfully. If the NFC - * subsystem could not be started, an error code is returned. - */ -ret_code_t hal_nfc_start(void); - - -/** @brief Function for sending a packet to the connected NFC reader. - * - * The provided data buffer belongs to the caller and is guaranteed to be - * valid until the HAL_NFC_EVENT_DATA_TRANSMITTED event is received by the - * callback. - * - * @note Provided pointer must point to RAM region. - * - * @param[in] p_data Pointer to the memory area in RAM containing data packet to send. - * @param[in] data_length Size of the packet in bytes. - * - * @retval NRF_SUCCESS If the packet was sent. Otherwise, an error code is returned. - */ -ret_code_t hal_nfc_send(const uint8_t * p_data, size_t data_length); - - -/** @brief Function for stopping the NFC subsystem. - * - * After this function returns, NFC readers will no longer be able to connect - * to the chip. - * - * @retval NRF_SUCCESS If the NFC subsystem was stopped. Otherwise, an error code - * is returned. - */ -ret_code_t hal_nfc_stop(void); - - -/** @brief Function for releasing resources. - * - * After this call returns, the callback is considered invalid and no more - * events will be posted to it. - * - * @retval NRF_SUCCESS This function always succeeds. - */ -ret_code_t hal_nfc_done(void); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* HAL_NFC_H__ */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.c deleted file mode 100644 index b69af59..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.c +++ /dev/null @@ -1,1152 +0,0 @@ -/** - * Copyright (c) 2016 - 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_config.h" -#if NFC_T4T_HAL_ENABLED - -#include "hal_nfc_t4t.h" -#include -#include -#include "nfc_t4t_lib.h" -#include "nfc_fixes.h" -#include "nrf.h" -#include "app_util_platform.h" -#include "nordic_common.h" -#include "nrf_drv_clock.h" - -#define NRF_LOG_MODULE_NAME hal_nfc -#if HAL_NFC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL HAL_NFC_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR HAL_NFC_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR HAL_NFC_CONFIG_DEBUG_COLOR -#else // HAL_NFC_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL 0 -#endif // HAL_NFC_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - -#if HAL_NFC_CONFIG_DEBUG_PIN_ENABLED - #include "nrf_gpio.h" - - #define HAL_NFC_DEBUG_PIN_CONFIG(pin_num) nrf_gpio_cfg_output(pin_num) - #define HAL_NFC_DEBUG_PIN_CLEAR(pin_num) nrf_gpio_pin_clear(pin_num) - #define HAL_NFC_DEBUG_PIN_SET(pin_num) nrf_gpio_pin_set(pin_num) - - #define HAL_NFC_DEBUG_PINS_INITIALIZE() \ - do{ \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_HCLOCK_ON_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_NFC_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_NFC_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_DETECT_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_DETECT_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CONFIG(HAL_NFC_TIMER4_EVENT_DEBUG_PIN); \ - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_TIMER4_EVENT_DEBUG_PIN); \ - } while(0) -#else - #define HAL_NFC_DEBUG_PIN_CLEAR(pin_num) - #define HAL_NFC_DEBUG_PIN_SET(pin_num) - #define HAL_NFC_DEBUG_PINS_INITIALIZE() -#endif // HAL_NFC_DEBUG_PIN_ENABLE - - -/* NFC library version history: - * #define NFC_LIB_VERSION 0x00 first experimental version intended for nRF52840 IC rev. Engineering A (PCA10056, part of nRF52840 Preview Development Kit) - */ - -#define NFC_LIB_VERSION 0x00u /**< Internal: current NFC lib. version */ - -#define CASCADE_TAG_BYTE 0x88u /**< Constant defined by ISO/EIC 14443-3 */ -#define NFCID1_3RD_LAST_BYTE2_SHIFT 16u /**< Shift value for NFC ID byte 2 */ -#define NFCID1_3RD_LAST_BYTE1_SHIFT 8u /**< Shift value for NFC ID byte 1 */ -#define NFCID1_3RD_LAST_BYTE0_SHIFT 0u /**< Shift value for NFC ID byte 0 */ -#define NFCID1_2ND_LAST_BYTE2_SHIFT 16u /**< Shift value for NFC ID byte 2 */ -#define NFCID1_2ND_LAST_BYTE1_SHIFT 8u /**< Shift value for NFC ID byte 1 */ -#define NFCID1_2ND_LAST_BYTE0_SHIFT 0u /**< Shift value for NFC ID byte 0 */ -#define NFCID1_LAST_BYTE3_SHIFT 24u /**< Shift value for NFC ID byte 3 */ -#define NFCID1_LAST_BYTE2_SHIFT 16u /**< Shift value for NFC ID byte 2 */ -#define NFCID1_LAST_BYTE1_SHIFT 8u /**< Shift value for NFC ID byte 1 */ -#define NFCID1_LAST_BYTE0_SHIFT 0u /**< Shift value for NFC ID byte 0 */ -#define NFCID1_SINGLE_SIZE 4u /**< Length of single size NFCID1 */ -#define NFCID1_DOUBLE_SIZE 7u /**< Length of double size NFCID1 */ -#define NFCID1_TRIPLE_SIZE 10u /**< Length of triple size NFCID1 */ -#define NFCID1_DEFAULT_LENGHT NFCID1_DOUBLE_SIZE /**< Length of NFCID1 if user does not provide one */ -#define NFCID1_MAX_LENGHT NFCID1_TRIPLE_SIZE /**< Maximum length of NFCID1 */ -#define NFC_RX_BUFFER_SIZE 256u /**< NFC Rx data buffer size */ -#define NFC_SLP_REQ_CMD 0x50u /**< NFC SLP_REQ command identifier */ -#define NFC_CRC_SIZE 2u /**< CRC size in bytes */ -#define NFC_T4T_SELRES_PROTOCOL 1u /**< Type 4A Tag PROTOCOL bit setup (b7:b6) for SEL_RES Response frame */ -#define NFC_T4T_SELRES_PROTOCOL_MSK 0x03u /**< PROTOCOL bits mask for SEL_RES Response frame */ -#define NFC_T4T_FWI_MAX 4u /**< Maximum FWI parameter value */ -#define NFC_T4T_RATS_CMD 0xE0u /**< RATS Command Byte */ -#define NFC_T4T_S_DESELECT 0xC2u /**< S(DESELECT) Block identifier */ -#define NFC_T4T_S_WTX 0xF2u /**< S(WTX)Block identifier */ -#define NFC_T4T_S_BLOCK_MSK 0xF7u /**< S-Block Mask */ -#define NFC_T4T_I_BLOCK 0x02u /**< I-Block identifier */ -#define NFC_T4T_BLOCK_MSK 0xE6u /**< I/R- block mask (NAD not supported, expect this bit equal 0) */ -#define NFC_T4T_ISO_DEP_MSK 0x02u /**< ISO-DEP block mask */ -#define NFC_T4T_R_BLOCK 0xA2u /**< R- Block identifier (static bits) */ -#define NFC_T4T_WTXM_MAX 0x10u /**< WTXM maximum value based on 'NFC Forum Digital Protocol Specification Version 1.1, Requirement 15.2.2.9', and FRAMEDELAYMAX maximum register setting */ -#define NFC_T4T_WTX_NO_DID_SIZE 0x02 /**< WTX data buffer size without DID field. */ -#define NFC_T4T_WTX_DID_SIZE 0x03 /**< WTX data buffer size with DID field. */ -#define NFC_T4T_DID_BIT 0x08 /**< Indicates if DID present in ISO-DEP block. */ -#define NFC_T4T_DID_MASK 0x0F /**< DID field mask */ -#define NFCT_INTEN_MSK 0x1C5CFFu /**< Mask for all NFCT interrupts */ - - -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - #define NRF_NFCT_ERRORSTATUS_ALL (NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk) /**< Mask for clearing all error flags in NFCT_ERRORSTATUS register */ -#else - #define NRF_NFCT_ERRORSTATUS_ALL (NFCT_ERRORSTATUS_NFCFIELDTOOWEAK_Msk | \ - NFCT_ERRORSTATUS_NFCFIELDTOOSTRONG_Msk | \ - NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk) /**< Mask for clearing all error flags in NFCT_ERRORSTATUS register */ -#endif // HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - -#define NRF_NFCT_FRAMESTATUS_RX_MSK (NFCT_FRAMESTATUS_RX_OVERRUN_Msk | \ - NFCT_FRAMESTATUS_RX_PARITYSTATUS_Msk | \ - NFCT_FRAMESTATUS_RX_CRCERROR_Msk) /**< Mask for clearing all flags in NFCT_FRAMESTATUS_RX register */ -#define NFC_FIELD_ON_MASK NFCT_FIELDPRESENT_LOCKDETECT_Msk /**< Mask for checking FIELDPRESENT register for state: FIELD ON. */ -#define NFC_FIELD_OFF_MASK NFCT_FIELDPRESENT_FIELDPRESENT_Msk /**< Mask for checking FIELDPRESENT register for state: FIELD OFF. */ - -#define NFC_T4T_FWI_TO_FWT(FWI) (256u * 16u * (1 << (FWI))) /**< Macro for calculating FWT (in number of NFC carrier periods) from FWI parameter. */ - -/* Begin: Bugfix for FTPAN-xx (AUTOCOLRESCONFIG) */ -#define NRF_NFCT_AUTOCOLRESCONFIG (*(uint32_t volatile *)(0x4000559C)) -#define NRF_NFCT_AUTOCOLRESCONFIG_Pos 0 -/* End: Bugfix for FTPAN-xx */ - -typedef enum -{ - NFC_FIELD_STATE_NONE, /**< Initial value indicating no NFCT Field events. */ - NFC_FIELD_STATE_OFF, /**< NFCT FIELDLOST Event has been set. */ - NFC_FIELD_STATE_ON, /**< NFCT FIELDDETECTED Event has been set. */ - NFC_FIELD_STATE_UNKNOWN /**< Both NFCT Field Events have been set - ambiguous state. */ -}nfct_field_sense_state_t; - -/* Static function declarations */ -static inline void nrf_nfct_event_clear(volatile uint32_t * p_event); -static inline void nrf_nfct_clock_event_handler(nrf_drv_clock_evt_type_t event); -static inline void nrf_nfct_field_event_handler(volatile nfct_field_sense_state_t field_state); -static void hal_nfc_nfcid1_default_bytes(void); -static void hal_nfc_nfcid1_registers_setup(void); - -/* Static data */ -static hal_nfc_callback_t m_nfc_lib_callback = (hal_nfc_callback_t) NULL; /**< Callback to nfc_lib layer */ -static void * m_nfc_lib_context; /**< Callback execution context */ -static volatile uint8_t m_nfc_rx_buffer[NFC_RX_BUFFER_SIZE] = {0}; /**< Buffer for NFC Rx data */ -static volatile bool m_slp_req_received = false; /**< Flag indicating that SLP_REQ Command was received */ -static volatile bool m_field_on = false; /**< Flag indicating that NFC Tag field is present */ -static nrf_drv_clock_handler_item_t m_clock_handler_item; /**< Clock event handler item structure */ -static volatile uint8_t m_fwi; /**< FWI parameter */ -static volatile uint8_t m_wtx_data[3]; /**< Tx buffer for an S(WTX) block */ -static volatile bool m_deselect = false; /**< Flag indicating reception of DESELECT command */ -static volatile bool m_swtx_sent = false; /**< Flag indicating that SWTX command has been sended. */ -static volatile bool m_pending_msg = false; /**< Flag signaling pending message during SWTX command execution. */ -static volatile const uint8_t * m_pending_msg_ptr = NULL; /**< Pointer to pending message buffer. */ -static volatile size_t m_pending_data_length = 0; /**< Length of pending message data. */ -static volatile bool m_t4t_tx_waiting = false; /**< Indicates if HAL is waiting for upper layer response to received command */ -static volatile uint8_t m_t4t_selres = NFC_T4T_SELRES_PROTOCOL; /**< Protocol bits setup in SEL_RES frame - can be modified using the library API */ -static volatile uint8_t m_did = 0; /**< DID field value. */ -static uint8_t m_nfcid1_length = 0; /**< Length of NFCID1 provided by user or 0 if not initialized yet */ -static uint8_t m_nfcid1_data[NFCID1_MAX_LENGHT] = {0}; /**< Content of NFCID1 */ -static volatile uint8_t m_t4t_active = false; /**< Indicates if NFC Tag is in 4A state (on reception of correct RATS command). */ - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -static volatile uint32_t m_nfc_fieldpresent_mask = NFC_FIELD_OFF_MASK; /**< Mask used for NFC Field polling in NFCT_FIELDPRESENT register */ -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -static inline void hal_nfc_re_setup(void); -static void hal_nfc_field_check(void); - -#define NRF_NFCT_POWER (*(uint32_t volatile *)(0x40005FFC)) - -#define NFC_HAL_FIELDPRESENT_MASK (NFCT_FIELDPRESENT_LOCKDETECT_Msk | \ - NFCT_FIELDPRESENT_FIELDPRESENT_Msk) - -#define NFC_HAL_FIELDPRESENT_IS_LOST ((NFCT_FIELDPRESENT_FIELDPRESENT_NoField << \ - NFCT_FIELDPRESENT_FIELDPRESENT_Pos) | \ - (NFCT_FIELDPRESENT_LOCKDETECT_NotLocked << \ - NFCT_FIELDPRESENT_LOCKDETECT_Pos)) - -static void field_timer_with_callback_config() -{ - NRF_TIMER4->MODE = TIMER_MODE_MODE_Timer << TIMER_MODE_MODE_Pos; - NRF_TIMER4->BITMODE = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos; - NRF_TIMER4->PRESCALER = 4 << TIMER_PRESCALER_PRESCALER_Pos; - NRF_TIMER4->CC[0] = HAL_NFC_FIELD_TIMER_PERIOD << TIMER_CC_CC_Pos; - NRF_TIMER4->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos; - NRF_TIMER4->INTENSET = TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos; - - NVIC_ClearPendingIRQ(TIMER4_IRQn); - NVIC_SetPriority(TIMER4_IRQn, NFCT_CONFIG_IRQ_PRIORITY); - NVIC_EnableIRQ(TIMER4_IRQn); -} - - -void TIMER4_IRQHandler(void) -{ - HAL_NFC_DEBUG_PIN_SET(TIMER4_EVENT_PIN); - hal_nfc_field_check(); - NRF_TIMER4->EVENTS_COMPARE[0] = 0; - HAL_NFC_DEBUG_PIN_CLEAR(TIMER4_EVENT_PIN); -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -/** - * @brief Common part of setup used for NFCT initialization and reinitialization. - */ -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -static void hal_nfc_common_hw_setup() -#else -static inline void hal_nfc_common_hw_setup() -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -{ -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND -/* Begin: Bugfix for FTPAN-98 */ - *(volatile uint32_t *) 0x4000568C = 0x00038148; -/* End: Bugfix for FTPAN-98 */ -/* Begin: Bugfix for FTPAN-144 */ - *(volatile uint32_t *) 0x4000561c = 0x01; - *(volatile uint32_t *) 0x4000562c = 0x3F; - *(volatile uint32_t *) 0x4000563c = 0x0; -/* End: Bugfix for FTPAN-144 */ -#endif // HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - -/* Begin: Bugfix for FTPAN-17 */ -/* fixed by avoiding usage of FIELDLOST event */ -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - NRF_NFCT->INTENSET = (NFCT_INTENSET_FIELDDETECTED_Enabled << NFCT_INTENSET_FIELDDETECTED_Pos); -#else - NRF_NFCT->INTENSET = (NFCT_INTENSET_FIELDDETECTED_Enabled << NFCT_INTENSET_FIELDDETECTED_Pos) | - (NFCT_INTENSET_FIELDLOST_Enabled << NFCT_INTENSET_FIELDLOST_Pos); -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -/* End: Bugfix for FTPAN-17 */ - - NRF_NFCT->INTENSET = (NFCT_INTENSET_TXFRAMESTART_Enabled << NFCT_INTENSET_TXFRAMESTART_Pos); - - NRF_NFCT->INTENSET = (NFCT_INTENSET_ERROR_Enabled << NFCT_INTENSET_ERROR_Pos) | - (NFCT_INTENSET_SELECTED_Enabled << NFCT_INTENSET_SELECTED_Pos); - - hal_nfc_nfcid1_registers_setup(); - - /* Set FRAMEDELAYMAX to maximum available setting, corresponding to FWI = 4 */ - NRF_NFCT->FRAMEDELAYMAX = NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Msk; - m_fwi = 4; - - /* Set PROTOCOL bits for Type 4A Tag */ - NRF_NFCT->SELRES = - (m_t4t_selres << NFCT_SELRES_PROTOCOL_Pos) & NFCT_SELRES_PROTOCOL_Msk; - - m_swtx_sent = false; - m_pending_msg = false; - m_pending_msg_ptr = NULL; - m_pending_data_length = 0; -} - -/** @brief Setup NRF_NFCT->NFCID1 and NRF_NFCT->SENSRES registers based on m_nfcid1_data and m_nfcid1_length variables. - */ -static void hal_nfc_nfcid1_registers_setup(void) -{ - uint32_t sens_res_size; // Value that will be written to NRF_NFCT->SENSRES - uint8_t* p_nfcid_remaining_data; // Points to the first byte of m_nfcid1_data remaining to write to NRF_NFCT->NFCID1 registers - - p_nfcid_remaining_data = m_nfcid1_data; - - if (m_nfcid1_length == NFCID1_SINGLE_SIZE) - { - sens_res_size = NFCT_SENSRES_NFCIDSIZE_NFCID1Single; - } - else - { - if (m_nfcid1_length == NFCID1_DOUBLE_SIZE) - { - sens_res_size = NFCT_SENSRES_NFCIDSIZE_NFCID1Double; - } - else // then m_nfcid1_length == NFCID1_TRIPLE_SIZE - { - /* MSB of NFCID1_3RD_LAST register is not used - always 0 */ - NRF_NFCT->NFCID1_3RD_LAST = - ((uint32_t) p_nfcid_remaining_data[0] << NFCID1_3RD_LAST_BYTE2_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[1] << NFCID1_3RD_LAST_BYTE1_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[2] << NFCID1_3RD_LAST_BYTE0_SHIFT); - p_nfcid_remaining_data += 3; - sens_res_size = NFCT_SENSRES_NFCIDSIZE_NFCID1Triple; - } - /* MSB of NFCID1_2ND_LAST register is not used - always 0 */ - NRF_NFCT->NFCID1_2ND_LAST = - ((uint32_t) p_nfcid_remaining_data[0] << NFCID1_2ND_LAST_BYTE2_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[1] << NFCID1_2ND_LAST_BYTE1_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[2] << NFCID1_2ND_LAST_BYTE0_SHIFT); - p_nfcid_remaining_data += 3; - } - - NRF_NFCT->NFCID1_LAST = - ((uint32_t) p_nfcid_remaining_data[0] << NFCID1_LAST_BYTE3_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[1] << NFCID1_LAST_BYTE2_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[2] << NFCID1_LAST_BYTE1_SHIFT) | - ((uint32_t) p_nfcid_remaining_data[3] << NFCID1_LAST_BYTE0_SHIFT); - - /* Begin: Bugfix for FTPAN-25 (IC-9929) */ - /* Workaround for wrong SENSRES values require using SDD00001, but here SDD00100 is used - because it's required to operate with Windows Phone */ - NRF_NFCT->SENSRES = - (sens_res_size << NFCT_SENSRES_NFCIDSIZE_Pos) | - (NFCT_SENSRES_BITFRAMESDD_SDD00100 << NFCT_SENSRES_BITFRAMESDD_Pos); - /* End: Bugfix for FTPAN-25 (IC-9929)*/ - - m_t4t_active = false; - m_swtx_sent = false; - m_pending_msg = false; - m_pending_msg_ptr = NULL; - m_pending_data_length = 0; -} - - -ret_code_t hal_nfc_setup(hal_nfc_callback_t callback, void * p_context) -{ - m_nfc_lib_callback = callback; - m_nfc_lib_context = p_context; - - if (m_nfcid1_length == 0) - { - m_nfcid1_length = NFCID1_DEFAULT_LENGHT; - hal_nfc_nfcid1_default_bytes(); - } - - hal_nfc_common_hw_setup(); - - /* Initialize SDK Clock module for handling high precission clock requests */ - m_clock_handler_item.event_handler = nrf_nfct_clock_event_handler; - m_clock_handler_item.p_next = NULL; - - ret_code_t err_code = nrf_drv_clock_init(); - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - field_timer_with_callback_config(); -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - - NRF_LOG_INFO("Init"); - HAL_NFC_DEBUG_PINS_INITIALIZE(); - - if ((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_MODULE_ALREADY_INITIALIZED)) - { - return NRF_SUCCESS; - } - else - { - return NRF_ERROR_INTERNAL; - } -} - - -/**@brief Function for clearing an event flag in NRF_NFCT registers. - * - * @param[in] p_event Pointer to event register. - * - */ -static inline void nrf_nfct_event_clear(volatile uint32_t * p_event) -{ - *p_event = 0; - - /* Perform read to ensure clearing is effective */ - volatile uint32_t dummy = *p_event; - (void)dummy; -} - - -/**@brief Function for handling events from Clock Module. - * - * @param[in] event Clock event. - * - */ -static inline void nrf_nfct_clock_event_handler(nrf_drv_clock_evt_type_t event) -{ - switch (event) - { - case NRF_DRV_CLOCK_EVT_HFCLK_STARTED: - /* Activate NFCT only when HFXO is running */ - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG! - NRF_NFCT->TASKS_ACTIVATE = 1; - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG! - break; - - default: - /* No implementation required */ - break; - } -} - - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -static inline void nrf_nfct_field_lost_hfclk_handle(void) -{ - /* Begin: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - // reset the NFC for release HFCLK - __DMB(); - NRF_NFCT_POWER = 0; - __DMB(); - NRF_NFCT_POWER = 1; - /* END: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -/**@brief Function for evaluating and handling NFC field events. - * - * @param[in] field_state Current field state. - * - */ -static inline void nrf_nfct_field_event_handler(volatile nfct_field_sense_state_t field_state) -{ - if (field_state == NFC_FIELD_STATE_UNKNOWN) - { - /* Probe NFC field */ - uint32_t field_present = NRF_NFCT->FIELDPRESENT; - - if (field_present & m_nfc_fieldpresent_mask) - { - field_state = NFC_FIELD_STATE_ON; - } - else - { - field_state = NFC_FIELD_STATE_OFF; - } - } - - /* Field event service */ - switch (field_state) - { - case NFC_FIELD_STATE_ON: - if (!m_field_on) - { - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG! - nrf_drv_clock_hfclk_request(&m_clock_handler_item); - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG! - } - m_field_on = true; - break; - - case NFC_FIELD_STATE_OFF: - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); // DEBUG! - -/* Begin: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - *(volatile uint32_t *)0x40005010 = 1; -#endif // HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND -/* END: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - - NRF_NFCT->TASKS_SENSE = 1; - nrf_drv_clock_hfclk_release(); - m_field_on = false; - - NRF_NFCT->INTENCLR = - (NFCT_INTENCLR_RXFRAMEEND_Clear << NFCT_INTENCLR_RXFRAMEEND_Pos) | - (NFCT_INTENCLR_RXERROR_Clear << NFCT_INTENCLR_RXERROR_Pos); - - /* Change mask to FIELD_OFF state - trigger FIELD_ON even if HW has not locked to the field */ - m_nfc_fieldpresent_mask = NFC_FIELD_OFF_MASK; - - if ((m_nfc_lib_callback != NULL) ) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_FIELD_OFF, 0, 0); - } - - /* Re-enable Auto Collision Resolution */ - NRF_NFCT_AUTOCOLRESCONFIG = NRF_NFCT_AUTOCOLRESCONFIG & - ~(1u << NRF_NFCT_AUTOCOLRESCONFIG_Pos); - m_t4t_active = false; - - /* Go back to default frame delay mode, bugfix for tag locking. */ - NRF_NFCT->FRAMEDELAYMODE = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_WindowGrid << - NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Pos; - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); // DEBUG! - break; - - default: - /* No implementation required */ - break; - } -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -__STATIC_INLINE void hal_nfc_wtx_data_set(bool did_present) -{ - uint32_t wtx_data_size; - - m_wtx_data[0] = NFC_T4T_S_WTX; - if (did_present) - { - m_wtx_data[0] |= NFC_T4T_DID_BIT; - m_wtx_data[1] = m_did; - m_wtx_data[2] = NFC_T4T_WTXM_MAX; - wtx_data_size = NFC_T4T_WTX_DID_SIZE; - } - else - { - m_wtx_data[1] = NFC_T4T_WTXM_MAX; - wtx_data_size = NFC_T4T_WTX_NO_DID_SIZE; - } - - NRF_NFCT->PACKETPTR = (uint32_t) m_wtx_data; - NRF_NFCT->TXD.AMOUNT = (wtx_data_size << NFCT_TXD_AMOUNT_TXDATABYTES_Pos) & - NFCT_TXD_AMOUNT_TXDATABYTES_Msk; - NRF_NFCT->FRAMEDELAYMODE = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_ExactVal << - NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Pos; - NRF_NFCT->TASKS_STARTTX = 1; - m_t4t_tx_waiting = true; -} - - -/** @brief Writes default values to m_nfcid1_data based on NRF_FICR->NFC registers. - */ -static void hal_nfc_nfcid1_default_bytes(void) -{ - uint32_t nfc_tag_header0 = NRF_FICR->NFC.TAGHEADER0; - uint32_t nfc_tag_header1 = NRF_FICR->NFC.TAGHEADER1; - uint32_t nfc_tag_header2 = NRF_FICR->NFC.TAGHEADER2; - - m_nfcid1_data[0] = (uint8_t) LSB_32(nfc_tag_header0 >> 0); - m_nfcid1_data[1] = (uint8_t) LSB_32(nfc_tag_header0 >> 8); - m_nfcid1_data[2] = (uint8_t) LSB_32(nfc_tag_header0 >> 16); - m_nfcid1_data[3] = (uint8_t) LSB_32(nfc_tag_header1 >> 0); - m_nfcid1_data[4] = (uint8_t) LSB_32(nfc_tag_header1 >> 8); - m_nfcid1_data[5] = (uint8_t) LSB_32(nfc_tag_header1 >> 16); - m_nfcid1_data[6] = (uint8_t) LSB_32(nfc_tag_header1 >> 24); - m_nfcid1_data[7] = (uint8_t) LSB_32(nfc_tag_header2 >> 0); - m_nfcid1_data[8] = (uint8_t) LSB_32(nfc_tag_header2 >> 8); - m_nfcid1_data[9] = (uint8_t) LSB_32(nfc_tag_header2 >> 16); -} - - -ret_code_t hal_nfc_parameter_set(hal_nfc_param_id_t id, void * p_data, size_t data_length) -{ - /* Parameter validation is done in upper-layer */ - - if (id == HAL_NFC_PARAM_FWI) - { - /* Update Frame Wait Time setting; possible settings are limited by NFCT hardware */ - m_fwi = *((uint8_t *)p_data); - - if (data_length != sizeof(uint8_t)) - { - return NRF_ERROR_DATA_SIZE; - } - if (m_fwi > NFC_T4T_FWI_MAX) - { - return NRF_ERROR_INVALID_PARAM; - } - - /* Set FRAMEDELAYTIME */ - if (m_fwi == NFC_T4T_FWI_MAX) - { - NRF_NFCT->FRAMEDELAYMAX = NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Msk; - } - else - { - NRF_NFCT->FRAMEDELAYMAX = NFC_T4T_FWI_TO_FWT(m_fwi); - } - } - else if (id == HAL_NFC_PARAM_SELRES) - { - /* Update SEL_RES 'Protocol' bits setting */ - uint8_t sel_res = *((uint8_t *)p_data); - - if (data_length != sizeof(uint8_t)) - { - return NRF_ERROR_DATA_SIZE; - } - if (sel_res > NFC_T4T_SELRES_PROTOCOL_MSK) - { - return NRF_ERROR_INVALID_PARAM; - } - - m_t4t_selres = sel_res; - NRF_NFCT->SELRES = - (m_t4t_selres << NFCT_SELRES_PROTOCOL_Pos) & NFCT_SELRES_PROTOCOL_Msk; - } - else if (id == HAL_NFC_PARAM_DID) - { - if (data_length > sizeof(uint8_t)) - { - return NRF_ERROR_DATA_SIZE; - } - - m_did = (data_length == sizeof(m_did)) ? *((uint8_t *)p_data) : 0; - } - else if (id == HAL_NFC_PARAM_NFCID1) - { - if (data_length == 1) - { - uint8_t id_length = *((uint8_t *) p_data); - if (id_length == NFCID1_SINGLE_SIZE || id_length == NFCID1_DOUBLE_SIZE || - id_length == NFCID1_TRIPLE_SIZE) - { - m_nfcid1_length = id_length; - hal_nfc_nfcid1_default_bytes(); - } - else - { - return NRF_ERROR_INVALID_LENGTH; - } - } - else if (data_length == NFCID1_SINGLE_SIZE || data_length == NFCID1_DOUBLE_SIZE || - data_length == NFCID1_TRIPLE_SIZE) - { - m_nfcid1_length = (uint8_t) data_length; - memcpy(m_nfcid1_data, p_data, data_length); - } - else - { - return NRF_ERROR_INVALID_LENGTH; - } - hal_nfc_nfcid1_registers_setup(); - } - else - { - /* No implementation needed */ - } - - return NRF_SUCCESS; -} - -/* This function is used by nfc_lib for unit testing only */ -ret_code_t hal_nfc_parameter_get(hal_nfc_param_id_t id, void * p_data, size_t * p_max_data_length) -{ - if (*p_max_data_length < 1) - { - *p_max_data_length = 1; - return NRF_ERROR_DATA_SIZE; - } - - if (id == HAL_NFC_PARAM_FWI) - { - *((uint8_t *) p_data) = m_fwi; - *p_max_data_length = sizeof(m_fwi); - } - else if (id == HAL_NFC_PARAM_SELRES) - { - /* Get SEL_RES 'Protocol' bits setting */ - *((uint8_t *) p_data) = m_t4t_selres; - *p_max_data_length = sizeof(m_t4t_selres); - } - else if (id == HAL_NFC_PARAM_DID) - { - *((uint8_t *) p_data) = m_did; - *p_max_data_length = sizeof(m_did); - } - else if (id == HAL_NFC_PARAM_NFCID1) - { - if (m_nfcid1_length == 0) - { - m_nfcid1_length = NFCID1_DEFAULT_LENGHT; - hal_nfc_nfcid1_default_bytes(); - } - - if (*p_max_data_length < (size_t) m_nfcid1_length) - { - return NRF_ERROR_DATA_SIZE; - } - - *p_max_data_length = (size_t) m_nfcid1_length; - memcpy(p_data, m_nfcid1_data, m_nfcid1_length); - } - else - { - /* No implementation needed */ - } - - return NRF_SUCCESS; -} - - -ret_code_t hal_nfc_start(void) -{ - NRF_NFCT->ERRORSTATUS = NRF_NFCT_ERRORSTATUS_ALL; - NRF_NFCT->TASKS_SENSE = 1; - - NVIC_ClearPendingIRQ(NFCT_IRQn); - NVIC_SetPriority(NFCT_IRQn, NFCT_CONFIG_IRQ_PRIORITY); - NVIC_EnableIRQ(NFCT_IRQn); - - NRF_LOG_INFO("Start"); - return NRF_SUCCESS; -} - - -ret_code_t hal_nfc_send(const uint8_t * p_data, size_t data_length) -{ - if (data_length == 0) - { - return NRF_ERROR_DATA_SIZE; - } - - if(m_swtx_sent) - { - m_pending_msg_ptr = p_data; - m_pending_data_length = data_length; - m_pending_msg = true; - - NRF_LOG_DEBUG("Pending message."); - return NRF_SUCCESS; - } - - m_t4t_tx_waiting = false; - - /* Ignore previous TX END events, SW takes care only for data frames which tranmission is triggered in this function */ - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMEEND); - - NRF_NFCT->INTENSET = (NFCT_INTENSET_TXFRAMEEND_Enabled << NFCT_INTENSET_TXFRAMEEND_Pos); //Moved to the end in T4T to avoid delaying TASKS_STARTX - NRF_NFCT->PACKETPTR = (uint32_t) p_data; - NRF_NFCT->TXD.AMOUNT = (data_length << NFCT_TXD_AMOUNT_TXDATABYTES_Pos) & - NFCT_TXD_AMOUNT_TXDATABYTES_Msk; - NRF_NFCT->FRAMEDELAYMODE = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_WindowGrid << - NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Pos; - NRF_NFCT->TASKS_STARTTX = 1; - - NRF_LOG_INFO("Send"); - return NRF_SUCCESS; -} - - -ret_code_t hal_nfc_stop(void) -{ - NRF_NFCT->TASKS_DISABLE = 1; - - NRF_LOG_INFO("Stop"); - return NRF_SUCCESS; -} - - -ret_code_t hal_nfc_done(void) -{ - m_nfc_lib_callback = (hal_nfc_callback_t) NULL; - - return NRF_SUCCESS; -} - - -void NFCT_IRQHandler(void) -{ - nfct_field_sense_state_t current_field = NFC_FIELD_STATE_NONE; - - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_NFC_EVENT_DEBUG_PIN); // DEBUG! - - if (NRF_NFCT->EVENTS_FIELDDETECTED && (NRF_NFCT->INTEN & NFCT_INTEN_FIELDDETECTED_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_FIELDDETECTED); - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_DETECT_EVENT_DEBUG_PIN); // DEBUG! - current_field = NFC_FIELD_STATE_ON; - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_DETECT_EVENT_DEBUG_PIN); // DEBUG! - - NRF_LOG_DEBUG("Field detected"); - } - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - if (NRF_NFCT->EVENTS_FIELDLOST && (NRF_NFCT->INTEN & NFCT_INTEN_FIELDLOST_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_FIELDLOST); - current_field = - (current_field == NFC_FIELD_STATE_NONE) ? NFC_FIELD_STATE_OFF : NFC_FIELD_STATE_UNKNOWN; - - NRF_LOG_DEBUG("Field lost"); - } -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - - /* Perform actions if any FIELD event is active */ - if (current_field != NFC_FIELD_STATE_NONE) - { - nrf_nfct_field_event_handler(current_field); - } - - if (NRF_NFCT->EVENTS_RXFRAMEEND && (NRF_NFCT->INTEN & NFCT_INTEN_RXFRAMEEND_Msk)) - { - /* Take into account only number of whole bytes */ - uint32_t rx_status = 0; - uint32_t rx_data_size = ((NRF_NFCT->RXD.AMOUNT & NFCT_RXD_AMOUNT_RXDATABYTES_Msk) >> - NFCT_RXD_AMOUNT_RXDATABYTES_Pos) - NFC_CRC_SIZE; - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXFRAMEEND); - - if (NRF_NFCT->EVENTS_RXERROR && (NRF_NFCT->INTEN & NFCT_INTEN_RXERROR_Msk)) - { - rx_status = NRF_NFCT->FRAMESTATUS.RX; - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXERROR); - - NRF_LOG_DEBUG("Rx error (0x%x)", (unsigned int) rx_status); - - /* Clear rx frame status */ - NRF_NFCT->FRAMESTATUS.RX = NRF_NFCT_FRAMESTATUS_RX_MSK; - } - - /* Ignore all NFC-A data frames with Transmission Error */ - if (rx_status & NRF_NFCT_FRAMESTATUS_RX_MSK) - { - /* Go back to idle state if currently in the ACTIVE_A state */ - if (!m_t4t_active) - { - NRF_NFCT->TASKS_GOIDLE = 1; - /* Disable RX here (will be enabled at SELECTED) */ - NRF_NFCT->INTENCLR = NFCT_INTENCLR_RXFRAMEEND_Clear << - NFCT_INTENCLR_RXFRAMEEND_Pos; - } - /* Stay in the CARD_EMULATOR_4A state */ - else - { - /* Command with Transmission Error, so wait for next frame reception */ - NRF_NFCT->TASKS_ENABLERXDATA = 1; - } - } - else - { - /* Look for NFC-A Commands */ - if (!m_t4t_active) - { - if (m_nfc_rx_buffer[0] == NFC_T4T_RATS_CMD) - { - /* Disable Auto Collision Resolution */ - NRF_NFCT_AUTOCOLRESCONFIG = NRF_NFCT_AUTOCOLRESCONFIG | - (1u << NRF_NFCT_AUTOCOLRESCONFIG_Pos); - m_t4t_active = true; - NRF_LOG_DEBUG("RX: T4T Activate"); - } - /* Indicate that SLP_REQ was received - this will cause FRAMEDELAYTIMEOUT error */ - else if (m_nfc_rx_buffer[0] == NFC_SLP_REQ_CMD) - { - // disable RX here (will enable at SELECTED) - m_slp_req_received = true; - NRF_NFCT->INTENCLR = NFCT_INTENCLR_RXFRAMEEND_Clear << NFCT_INTENCLR_RXFRAMEEND_Pos; - } - else - { - NRF_NFCT->TASKS_GOIDLE = 1; - /* Disable RX here (will be enabled at SELECTED) */ - NRF_NFCT->INTENCLR = NFCT_INTENCLR_RXFRAMEEND_Clear << - NFCT_INTENCLR_RXFRAMEEND_Pos; - } - } - /* Look for Tag 4 Type Commands */ - else - { - bool did_present; - uint8_t did; - - did_present = (m_nfc_rx_buffer[0] & NFC_T4T_DID_BIT) != 0; - did = m_did; - - // React only to the ISO-DEP blocks that are directed to our tag. - if ((!did_present) || (did == (m_nfc_rx_buffer[1] & NFC_T4T_DID_MASK))) - { - if ((m_nfc_rx_buffer[0] & NFC_T4T_S_BLOCK_MSK) == NFC_T4T_S_DESELECT) - { - m_deselect = true; - NRF_LOG_DEBUG("RX: T4T Go to sleep"); - } - else if (m_swtx_sent && ((m_nfc_rx_buffer[0] & NFC_T4T_S_BLOCK_MSK) == NFC_T4T_S_WTX)) - { - m_swtx_sent = false; - - NRF_LOG_DEBUG("RX: S(WTX) reponse"); - - if (m_pending_msg) - { - m_pending_msg = false; - - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMEEND); - - NRF_NFCT->INTENSET = (NFCT_INTENSET_TXFRAMEEND_Enabled << - NFCT_INTENSET_TXFRAMEEND_Pos); - NRF_NFCT->PACKETPTR = (uint32_t) m_pending_msg_ptr; - NRF_NFCT->TXD.AMOUNT = (m_pending_data_length << - NFCT_TXD_AMOUNT_TXDATABYTES_Pos) & - NFCT_TXD_AMOUNT_TXDATABYTES_Msk; - NRF_NFCT->FRAMEDELAYMODE = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_WindowGrid << - NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Pos; - NRF_NFCT->TASKS_STARTTX = 1; - - m_t4t_tx_waiting = false; - NRF_LOG_DEBUG("Sending pending message!"); - } - else - { - hal_nfc_wtx_data_set(did_present); - } - } - else if ((m_nfc_rx_buffer[0] & NFC_T4T_BLOCK_MSK) == NFC_T4T_I_BLOCK) - { - /* Set up default transmission of S(WTX) block. Tx will be executed only if FDT timer - * expires (FrameDelayMode-ExactVal) before hal_nfc_send is called */ - hal_nfc_wtx_data_set(did_present); - - NRF_NFCT->INTENSET = (NFCT_INTENSET_TXFRAMEEND_Enabled << - NFCT_INTENSET_TXFRAMEEND_Pos); - } - else - { - /* Not a valid ISO-DEP block, so wait for next frame reception */ - NRF_NFCT->TASKS_ENABLERXDATA = 1; - } - } - else - { - /* Not our ISO-DEP block, so wait for next frame reception */ - NRF_NFCT->TASKS_ENABLERXDATA = 1; - } - } - - if (m_nfc_lib_callback != NULL) - { - /* This callback should trigger transmission of READ Response */ - m_nfc_lib_callback(m_nfc_lib_context, - HAL_NFC_EVENT_DATA_RECEIVED, - (void *)m_nfc_rx_buffer, - rx_data_size); - } - /* Clear TXFRAMESTART EVENT so it can be checked in hal_nfc_send */ - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMESTART); - } - NRF_LOG_DEBUG("Rx fend"); - } - - if (NRF_NFCT->EVENTS_TXFRAMEEND && (NRF_NFCT->INTEN & NFCT_INTEN_TXFRAMEEND_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMEEND); - - /* Disable TX END event to ignore frame transmission other than READ response */ - NRF_NFCT->INTENCLR = (NFCT_INTENCLR_TXFRAMEEND_Clear << NFCT_INTENCLR_TXFRAMEEND_Pos); - - if (m_deselect) - { - /* Re-enable Auto Collision Resolution */ - NRF_NFCT_AUTOCOLRESCONFIG = NRF_NFCT_AUTOCOLRESCONFIG & - ~(1u << NRF_NFCT_AUTOCOLRESCONFIG_Pos); - NRF_NFCT->TASKS_GOSLEEP = 1; - /* Disable RX here (will be enabled at SELECTED) */ - NRF_NFCT->INTENCLR = NFCT_INTENCLR_RXFRAMEEND_Clear << - NFCT_INTENCLR_RXFRAMEEND_Pos; - m_deselect = false; - m_t4t_active = false; - } - else - { - /* Set up for reception */ - NRF_NFCT->PACKETPTR = (uint32_t) m_nfc_rx_buffer; - NRF_NFCT->MAXLEN = NFC_RX_BUFFER_SIZE; - NRF_NFCT->TASKS_ENABLERXDATA = 1; - NRF_NFCT->INTENSET = - (NFCT_INTENSET_RXFRAMEEND_Enabled << NFCT_INTENSET_RXFRAMEEND_Pos) | - (NFCT_INTENSET_RXERROR_Enabled << NFCT_INTENSET_RXERROR_Pos); - } - - if (m_nfc_lib_callback != NULL) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_DATA_TRANSMITTED, 0, 0); - } - - NRF_LOG_DEBUG("Tx fend"); - } - - if (NRF_NFCT->EVENTS_SELECTED && (NRF_NFCT->INTEN & NFCT_INTEN_SELECTED_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_SELECTED); - - /* Clear also RX END and RXERROR events because SW does not take care of commands which were received before selecting the tag */ - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXFRAMEEND); - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_RXERROR); - - /* Set up registers for EasyDMA and start receiving packets */ - NRF_NFCT->PACKETPTR = (uint32_t) m_nfc_rx_buffer; - NRF_NFCT->MAXLEN = NFC_RX_BUFFER_SIZE; - NRF_NFCT->TASKS_ENABLERXDATA = 1; - - NRF_NFCT->INTENSET = (NFCT_INTENSET_RXFRAMEEND_Enabled << NFCT_INTENSET_RXFRAMEEND_Pos) | - (NFCT_INTENSET_RXERROR_Enabled << NFCT_INTENSET_RXERROR_Pos); - - /* At this point any previous error status can be ignored */ - NRF_NFCT->FRAMESTATUS.RX = NRF_NFCT_FRAMESTATUS_RX_MSK; - NRF_NFCT->ERRORSTATUS = NRF_NFCT_ERRORSTATUS_ALL; - -#ifndef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - /* Change mask to FIELD_ON state - trigger FIELD_ON only if HW has locked to the field */ - m_nfc_fieldpresent_mask = NFC_FIELD_ON_MASK; -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - - if (m_nfc_lib_callback != NULL) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_FIELD_ON, 0, 0); - } - - m_t4t_active = false; - m_swtx_sent = false; - m_pending_msg = false; - m_pending_msg_ptr = NULL; - m_pending_data_length = 0; - - NRF_LOG_DEBUG("Selected"); - } - - if (NRF_NFCT->EVENTS_ERROR && (NRF_NFCT->INTEN & NFCT_INTEN_ERROR_Msk)) - { - uint32_t err_status = NRF_NFCT->ERRORSTATUS; - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_ERROR); - - /* Clear FRAMEDELAYTIMEOUT error (expected HW behaviour) when SLP_REQ command was received */ - if ((err_status & NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk) && m_slp_req_received) - { - NRF_NFCT->ERRORSTATUS = NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk; - m_slp_req_received = false; - - NRF_LOG_DEBUG("RX: SLP_REQ"); - } - /* Report any other error */ - err_status &= ~NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk; - - if (err_status) - { - NRF_LOG_DEBUG("Error (0x%x)", (unsigned int) err_status); - } - - /* Clear error status */ - NRF_NFCT->ERRORSTATUS = NRF_NFCT_ERRORSTATUS_ALL; - } - - if (NRF_NFCT->EVENTS_TXFRAMESTART && (NRF_NFCT->INTEN & NFCT_INTEN_TXFRAMESTART_Msk)) - { - nrf_nfct_event_clear(&NRF_NFCT->EVENTS_TXFRAMESTART); - - if (m_t4t_tx_waiting) - { - m_t4t_tx_waiting = false; - m_swtx_sent = true; - - NRF_LOG_DEBUG("Response timeout, sending WTX!"); - } - } - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_NFC_EVENT_DEBUG_PIN); // DEBUG! -} - - -#ifdef HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#ifdef HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND - #error Wrong workaround combination -#endif - -static uint32_t field_state_cnt = 0; -/** - * @brief Function for evaluating and handling NFC fieldlost event. - */ -static void hal_nfc_field_check(void) -{ - uint32_t nfc_fieldpresen_masked; - - nfc_fieldpresen_masked = NRF_NFCT->FIELDPRESENT & NFC_HAL_FIELDPRESENT_MASK; - - if (nfc_fieldpresen_masked == NFC_HAL_FIELDPRESENT_IS_LOST) - { - ++field_state_cnt; - if (field_state_cnt > 7) - { - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); // DEBUG! - - NRF_TIMER4->TASKS_SHUTDOWN = 1; - - nrf_drv_clock_hfclk_release(); - - nrf_nfct_field_lost_hfclk_handle(); - - if ((m_nfc_lib_callback != NULL) ) - { - m_nfc_lib_callback(m_nfc_lib_context, HAL_NFC_EVENT_FIELD_OFF, 0, 0); - } - m_field_on = false; - - /* Begin: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - // resume the NFCT to initialized state - hal_nfc_re_setup(); - /* End: Bugfix for FTPAN-116 (IC-12886) NFCT won't release HFCLK */ - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_OFF_DEBUG_PIN); // DEBUG! - } - - return; - } - - field_state_cnt = 0; -} - - -/** - * @brief Function for enablinge hight precision clock and start eveluating fieldlost event. - */ -static inline void nrf_nfct_field_event_handler(volatile nfct_field_sense_state_t field_state) -{ - if (!m_field_on) - { - HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG! - nrf_drv_clock_hfclk_request(&m_clock_handler_item); - - NRF_TIMER4->TASKS_CLEAR = 1; - NRF_TIMER4->TASKS_START = 1; - field_state_cnt = 0; - - HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG! - } - m_field_on = true; -} - - -/** - * @brief Function for resume the NFCT to initialized state after software's reset. - */ -static inline void hal_nfc_re_setup(void) -{ - hal_nfc_common_hw_setup(); - - NRF_LOG_INFO("Reinitialize"); -} -#endif // HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND - -#endif // NFC_T4T_HAL_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.h deleted file mode 100644 index e8b31c7..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/hal_t4t/hal_nfc_t4t.h +++ /dev/null @@ -1,203 +0,0 @@ -/** - * Copyright (c) 2016 - 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 HAL_NFC_H__ -#define HAL_NFC_H__ - -/** @file - * @defgroup nfc_t4t_hal NFC Type 4 Tag HAL - * @{ - * @ingroup nfc_t4t - * @brief @tagAPI52 Hardware abstraction layer for the NFC Type 4 Tag library. - * - * @note Before the NFCT peripheral enters ACTIVATED state, the HFXO must be running. - * To fulfill this requirement and allow other software modules to also request the HFXO, the NFC Type 4 Tag HAL uses @ref nrf_drv_clock module. - * - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief Events passed to the upper-layer callback function. */ -typedef enum { - HAL_NFC_EVENT_FIELD_ON, ///< Field is detected. - HAL_NFC_EVENT_FIELD_OFF, ///< Field is lost. - HAL_NFC_EVENT_DATA_RECEIVED, ///< Data is received. - HAL_NFC_EVENT_DATA_TRANSMITTED ///< Data is transmitted. -} hal_nfc_event_t; - - -/** @brief Parameter IDs for the set/get function. */ -typedef enum { - HAL_NFC_PARAM_ID_TESTING, ///< Used for unit tests. - HAL_NFC_PARAM_FWI, ///< Frame Wait Time parameter. - HAL_NFC_PARAM_SELRES, ///< Parameter for setting the 'Protocol' bits for SEL_RES packet. - HAL_NFC_PARAM_NFCID1, /**< NFCID1 value, data can be 4, 7, or 10 bytes long (simple, double, or triple size). - To use default NFCID1 of specific length pass one byte containing requested length. - Default 7-byte NFCID1 will be used if this parameter was not set before nfc_t4t_setup(). */ - HAL_NFC_PARAM_DID, ///< Parameter for DID field management. - HAL_NFC_PARAM_ID_UNKNOWN -} hal_nfc_param_id_t; - - -/** @brief Callback from HAL_NFC layer into the upper layer. - * - * If event == HAL_NFC_EVENT_DATA_RECEIVED: - * p_data points to the received packet. The memory belongs to the HAL_NFC layer and - * is guaranteed to be valid only until the callback returns. - * - * If event == HAL_NFC_EVENT_DATA_TRANSMITTED: - * p_data points to the transmitted packet. The memory belongs to the application. - * - * If event == \: - * p_data definition is event-specific (to be defined). - * - * @param[in] p_context Context for callback execution. - * @param[in] event The event that occurred. - * @param[in] p_data Received/transmitted data or NULL. - * @param[in] data_length Size of the received/transmitted packet. - */ -typedef void (* hal_nfc_callback_t)(void * p_context, - hal_nfc_event_t event, - const uint8_t * p_data, - size_t data_length); - - -/** @brief Function for initializing the NFC layer. - * - * This function provides a pointer to a callback function and the callback context - * to the NFC layer. - * - * @param[in] callback Pointer to the callback function. - * @param[in] p_context Context of callback. - * - * @retval NRF_SUCCESS If the NFC layer was initialized successfully. If one - * of the arguments was invalid, an error code is returned. - */ -ret_code_t hal_nfc_setup(hal_nfc_callback_t callback, void * p_context); - - -/** @brief Function for setting a HAL_NFC parameter. - * - * This function allows to set any parameter defined as available by HAL_NFC. - * - * @param[in] id ID of the parameter to set. - * @param[in] p_data Pointer to the buffer containing the data to set. - * @param[in] data_length Size of the buffer containing the data to set. - * - * @retval NRF_SUCCESS If the parameter was set successfully. If one of the arguments - * was invalid (for example, wrong data length), an error code - * is returned. - */ -ret_code_t hal_nfc_parameter_set(hal_nfc_param_id_t id, void * p_data, size_t data_length); - - -/** @brief Function for querying a HAL_NFC parameter value. - * - * The queried value will be placed into the passed data buffer. If the buffer - * is too small, p_max_data_length will contain the required buffer size. - * - * @param[in] id ID of the parameter to query. - * @param[in, out] p_data Pointer to a buffer receiving the queried data. - * @param[in, out] p_max_data_length Size of the buffer. It receives the required size if buffer is too small. - * - * @retval NRF_SUCCESS If the parameter was received successfully. If one of the arguments - * was invalid (for example, the buffer was too small), an error code - * is returned. - */ -ret_code_t hal_nfc_parameter_get(hal_nfc_param_id_t id, void * p_data, size_t * p_max_data_length); - - -/** @brief Function for starting the NFC subsystem. - * - * After this function completes, NFC readers will be able to detect the chip. - * - * @retval NRF_SUCCESS If the NFC subsystem was started successfully. If the NFC - * subsystem could not be started, an error code is returned. - */ -ret_code_t hal_nfc_start(void); - - -/** @brief Function for sending a packet to the connected NFC reader. - * - * The provided data buffer belongs to the caller and is guaranteed to be - * valid until the HAL_NFC_EVENT_DATA_TRANSMITTED event is received by the - * callback. - * - * @param[in] p_data The data packet to send. - * @param[in] data_length Size of the packet in bytes. - * - * @retval NRF_SUCCESS If the packet was sent. Otherwise, an error code is returned. - */ -ret_code_t hal_nfc_send(const uint8_t * p_data, size_t data_length); - - -/** @brief Function for stopping the NFC subsystem. - * - * After this function returns, NFC readers will no longer be able to connect - * to the chip. - * - * @retval NRF_SUCCESS If the NFC subsystem was stopped. Otherwise, an error code - * is returned. - */ -ret_code_t hal_nfc_stop(void); - - -/** @brief Function for releasing resources. - * - * After this call returns, the callback is considered invalid and no more - * events will be posted to it. - * - * @retval NRF_SUCCESS This function always succeeds. - */ -ret_code_t hal_nfc_done(void); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* HAL_NFC_H__ */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_fixes.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_fixes.h deleted file mode 100644 index 3093f84..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_fixes.h +++ /dev/null @@ -1,85 +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 NFC_FIXES_H__ -#define NFC_FIXES_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @file - * @defgroup nfc_fixes NFC fixes and workarounds - * @{ - * @ingroup nfc_t4t - * @brief @tagAPI52 Fixes for hardware-related anomalies. - * - * If you are using PCA10040 (part of nRF52 Development Kit), - * you must define the macro HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND in order to apply - * workarounds for the following anomalies: - * - 79. NFCT: A false EVENTS_FIELDDETECTED event occurs after the field is lost. - * - 116. NFCT does not release HFCLK when switching from ACTIVATED to SENSE mode. - * - * If you are using PCA10056 (part of nRF52840 Development Kit), - * you must define the macro HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND in order to apply - * workarounds for the following anomalies: - * - 98. NFCT: The NFCT is not able to communicate with the peer. - * - 116. NFCT does not release HFCLK when switching from ACTIVATED to SENSE mode. - * - * The current code contains a patch for anomaly 25 (NFCT: Reset value of - * SENSRES register is incorrect), so that it now works on Windows Phone. - */ - -#ifdef BOARD_PCA10040 // assume nRF52832 chip in IC rev. Engineering B or Engineering C - #define HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND -#elif defined(BOARD_PCA10056) // assume nRF52840 chip in IC rev. Engineering A - #define HAL_NFC_NRF52840_ENGINEERING_A_WORKAROUND -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* NFC_FIXES_H__ */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf51822_5.0.0_release-notes.pdf b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf51822_5.0.0_release-notes.pdf deleted file mode 100644 index 0cff6f8c314cead8d5a26b10d50b81c07cfc5d70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35595 zcmcG#b9iM@mnR(CPAa&uZQHhO+eXEF=j`HSYG@1NksYHlVYkkJ)OAPwn2tMs`oZx-6t-9Z1`K&t7!|Bp zWK4#HiI5WV^P9hwJLyP678`;KGUesu`MHApx%4myMPfWAxC;E6S_Adt5D5N|C(H~@ z5W(|D?ss6F#_cv>78*)`yfYVnJ0gfLFt+GX( z$;NL6ru5&F@?+92yMB;c>(y@&nVL=xItl%l-O4np?qJ0iNHyW1Ej@)fi)}ARsBN{PBp>x6bqULo`a|oHBV;`V zWNo=wTe3;bKShwjGxleYzFLHf-j(>9&_&7};MI?-6=RJc5@oicWzqYTcGs3H9P;JZ z&@#ma+5`zP{1n)et@)C~$cjOuP3;z2M*1TMBi57BY|oA8`EeegP28=}EgX|mA2YwH zS3C=EVPa8oT{Ikn<2kpv9Q|zi_~5(6f#{Km>tqkPq{&EnVtVM{TpEKnOK#&Iqczk> zjuKU~{mnawkjf()pRr5s6|@x01+~J4T@q64DJ$!4K~mx*Xi~D>!EOjHdJx52@+Z$O z7VD2aw}N~#3M{oKe6dMb%`-K#^KVSeigs=U#!VZOCwMvR!OaA-3FbWM-p^L}>}sym zjm((U0??-a!aRUp#ni(EKrdQ(H?qV|!bA%C8Dvj9*ohU5#A+&Q-?J&iZSv#xB~-jLdYLi~v?PMmjbC z3lk?DGYf!~oq>*n?SC5@$G;BkpR1gaot5doSmx>4@|zq;0o!-fG#9WE!$WS_(%boI z-4-WGkWpWRH_R_;KdhTi{14f)exLb1bAQ zrq`ET&sZDagz%z7W5Ru71Pq^?2810@pC9xjrbs0u3DDEq;7n2!Pfi#6EQN+(Ml9a< zO|AXgf~X8Z{F`JzIW%N6DA7Uk_KV%uYVyV5LO6`grK-8zSgNi4IPEu(xFq#llDi?w zse!)aOjJZ5y_#@B62_9h+YIC=f;fs22%?lTi{&Pu*N9}A3;SBQXa!L(X{`#Nve}u< zIGdNF8)n}hQv$|NZTc+_8w7vjuS4Olhht1xa0+VQuM!nDj9?_f?9f{E8?Q4?6ttK{ zGuvP&a`u}s3>pU`dD#$q*br;66di!s&KWaH630y$jq|i3^R(hM;c8j`cxPhphB zrQ-?1UxC732~U-z?l8BV*&9#(fh3(VHw*f$A9S4&Hc*P0FL+Yu4q=9hN#3L!te^pH z*dt%lVgsuJiYeG&XtLh2<%Uz3T~5YQDjVT_Oe|Q73gl`!Rtse@%XqqwR*8yi4x^p} z(-wJQQG6YWZ%wS3a7pS?bNy}(1N(q(?K=C_;#FfM=k)~dr3cmZ_`=PLJGm4S3qy?rsGJu?tU3EX`}WgxV_B`1DvW)7 zWBR%!nZS!%HqIWJPj!=B?jic|6WgDjEt3-*Y_|JTS&2RhgTm{+glW32d6;o%D-Nq^ zFF^ZewVRfAZ*rUJ7X{>=-P?z`w}%p8$07v%8UQGqlM5jbN|o5U{=Ky+CRx_}112@IE1BYbPD?WxR7w1(q&7v4Ur zJcFF6b{9^Nzwq*ajiO?hehF}%ISa;Fb6Z8xK=0t*cWtRvk;EL^RZ+4edM)_g-u>AD z@hCw-qqyr_s`6B6_r$%bIr78;FUh};ciFj>G*&)a)c$U}m6W0c|EpQGDX<0*Z{Vpb zyh;F=T|0M{pQxT?v+d4%7x69o;OtF6i)NtGtV#4L)x$Pg`8! zhHlitDhZh^hj;h$T&^M~`{Kz}b^kS4&+Vdg!kv35VY}emidzh5@fJN zS}@NYCPRQfx+N(Bef6gM6hdN4R0!dKS>1XPilhnOs9ZWfo8{~K^$MN2)LcgOH zW#aacYEGS%2Tl*|BH8i&wIa*Su^QB#19u?Bo_Tt}cQYAzSa6qz2%OOe3g<5AmA&_} z#vJ?Jn?8dB+c3jFulLPX%eH~GwM7bh6P3qHwT1CeWyC!%LGP03CHa;t zW^Zw4{&Q@gEVc_Ybhr2$iO$EM`!G&*)P$S#({+H&9B_-g_zQM%`#Qf5hs4svZCv_& zGT58TZ;GGB_zr=*65BALFzzcWHrqZm1LSQ43& zX`m(2AJGSVx0j!8o?iMjY~47Nx%>1cBH7evkP4#QYHFcefwqbqX2pg)aEkL!=% ze(~$Hw2i2pPqlM!+Sca;rN3;GbAxhcUeSlJvfoMh^ry(JQ9#xljlLezj)H$Ev2evB z3{$-;e2u1hmaw^%ZiB72#cPzSY+p%kL&cK4aEo$NebmuTK%EL*sg|!NENmz1StsWY z&Q^$P|1~~{KcG95lbruv#o+wcz41R*G5&6z|E($py%;lq?QbXlm99ZAXlG~d;;j8w z(@^@~ws*$AYRSLV;u+Z){`2kKRK62tKmh6dh`M!g!1>Clt~m%JNc4A~(76yCA+pil z)pNxqcp{*2YWjTg{4!h^M7ddOSfb)5W5EEFnhuz_Jr>tQSFqWS-)`oWhQ#2QjeY@5 zf*IgX%&}?>=obEKqD#AxSaouJ1ZE(a2)!9BUkKxa^=9aJv@s)~5ZkF3j-< z{Vz7*Y#P&FBojFkZYUcbU&uz8wj+%1N#XRm3TRuK;NyS#|K<%8kJ8vBmx~W{2R9~% z!3Ls-K#F+MA-_hWFn2r*@uHE-AyHL>fr`5pgjOC2W3)`+%BbUoQJ7w|VIlK`ssbKS zx_;8}nvu>1^R&k0)*MADpcn813nwE|nPwsqWFYo3DGP9bAxLI$HNr|#%RmMDSt4*C zBTpetifzbIEOmbpv8z$u#;hQPKT_a8PnIAcNk=#qN%oqeg9U9&Za6LkRn{emz9hp! z2Aw|_ur6@Hfs%Lu7mG{lhWlM^m(r9($w*ovC^5sU219gU=q9}pImj|hiH|o2H$`UF zPQp3gC7z?U#04l%K?^bg)v^ZKq6S(@@_T|8?Ym_Qu$j~az?GVvgM`v^@B{ISzh{LbYyASN<4ROMCuZXL?W37ta$^h zq|~G&Kz_#rfa^O>)pwwV531$O`Ypy%OLGzeH!L!YkFHG-7bav?0zU{MLM=Q#H9LPX z%(AZ4r!%hyApSVHb7NR%Kd z`4LiF-K^YKHmbznAe2X0H9M|?V!8D2FC9TvzSYxIC~k(yTP*o{$XCe;RLLn&N&khT zmMg!DPYqXq%wHni2nnJg>u(N~&0y9>)h7dItR>(VF;^ii*B~X$Mr8qxrAqGtRO_W~ zC|}DoWL17IAx^3>s6oOd;12*Sq#&wEAUaF9%&bK5v9ttQNe)N>9*ZDGMm}`oDhy5p zi!U$Ln26e}MIDwXEmOnb|G%TTp4%4JDixUn;MlM8XZ882GwMYVo=%fc4K-i(6mEt3BD)Yv3gr|jiD5|& z*uF}{rKy4inUV__85rq&;hCbO92P>wTBY}_@Ng-@W4@`h3SM-dY|1HE^C?)#=@-1O z%T=E8jbT;s&R?*92Ha8vDCx#X;!|#VYT$-d3d1#S$DT;}vydteh+-LscN}4TBbq@<^?w;-!V8$;gQE%TbBkOo;Vi z-6Pq3*p{2;VhUtOXVr>^h?HwW%s2q>v?;^bUR3&J7#6>Y@Djo9ZPNs9g{YY^^#`&F zqr0=Ds4B$W)dw(vWi?_b`80=YoJ5{3tRDBcJywAl_h43|V8zRi>i@{qYnWASp1+a$ z8)WVEoL8CYFRK1|9z5mun4qdIpcyusZ^U4an5`fkc)l?DyomE|cgzHzl$!qn>p8p7+RHmZ)ypkzDGC*TzyJqiC*88@pxRQb zyX!*JLKQ5jS0?xt^PK()eZb{+2^tJk4q*W4j&Nt+H}-0L42{A?s6DP1GQ; zDyPF%4>A=duS8GzW8SYqkA2$ljbKXdX4$cokyQ6rP6IIygx1VrijW$(P+8@bDbVR3 z8eNAyG>`4k@38c75~XWR!gCm|@H;g7w2yJsz%lxS?jUB*E@%|mJ!c-iGo5*>$u;Pm z1(99U`R)T-H-(U8HlHPEjQ#`DQ9TB*J-whfc?i}>XJE(Gzv{X!9A1{l6;mp`E4fgtft~bFy%e#ODcv!y8=%)za7PH_z-j6PK7j)PouxS08ak`QHzTByxc|IYrEIkFuS?BvCPv;jlkJ^qm&4j(RHhPvVRd;Qu$=YBCj3c?G;4oS)j;*RG=NB;qY>P!efi_q! z!?zfc8#pEt1_rG=9GFa2Zrn4RLA2#xL^MVQLdDNElDTF!AAv^Hc_|CVWD!1>ZEm-6@o~m z^$N{#*vmt_XG0UvUHN-(OP7|tV0p$+Pi8%8VrI^W-fQ4dV_HFbryzhIcN*4w#oY!Tyh2`jq+T9m3nXs%b5PU zzW#F#LV(ZHkRxaD2c+vdquFcFIdyrSh}!EY45JeNP1i~!Z}@y7l^BlrT{Bno@WLq9 zpQCehhJLF%OMfP<%E#50t5s8IWJcpRgxu-GmP~1?88eY6RtQB7fLOv=gEv`ZCeO|kskQkmj3x(us|&buBry~v)C<+<8S>5ZMA2g1 z@I1%ZMk3;AoKn=u?)K@k8yCdj)Y z)kk?c*vgSmz?m4vWV2kOS&#AJHV(Bh6k&s!!i14#UKaH}crZ0Chnp^ONJJiUF(GpP zAwWS^9?c>e5!E}|3ZJjw<%tpgp~fIf*{hK&kF?cp%jpN*KO!}U#Hl zS!%gaHFK+4PCd^~VCc@X=h*`sd~9mz0Od4wX?W!2pbR=qk#ApRrU+z9CF>1>UW-o{ zSmEvg4=m*exP0)wiHyh0AjYy2&D9jP?lXg{ywAi0NRlRfsMQ?Ny$9($ycG6UtEm4* z%y}_KzqY2el4~9Jj@0SB3+S?F+3B&vyR;yC{O$yh{g(Sjm=$j+nv*{v}T^Q8Q3PdS8%AdcMfL6querKQ4&44Yc`jY?nITO|6zHuLjbeSKT}mKbrV`FAfB|zbW|EC+MHhX6aoG#iAn_`{-{7DRK1I zk^iV^hdkKTCLHLZz1F$`@*n%z{O6<9Hr9RpsLlM@w7`Ph?uHvb+m0oTNF9^fWG<+u zs~`kU?EYxC5VmopbK-0%YjKK9l?$5$8Rg0mv6eBDFeo2;t$DGUw^3;kRM*+2LS!%` zq63z1^>>N%%#*ce1$89PgD545-6(my7CQVpf#jD#581BNNbnyxM*aq@{^@i0k6l^+ z@JjqYb&UL<;j;hFzN~+Zn=$_T7&J302jhS4Dyh+0w_BG$@m*2BHwGDk>-3x%1Zu3A z^jK+=aDoVa5Xvt}9f}aKk{HJ~X85x!pHq1XD>(rTeojQsXQlRVvaqzIYVwJdEeA;# z<$F2Am_-Lsbn<)RcU<6EyB=D7S)jq6pqp*T4O8{tKkqB1QGobHawzqqt~_>qK1gJ-_9H^+lx%7c@!}o|!aE)e zVrmU%fuU!^5HXk6 zbt^fEu}WDufV-Geh~z-D;_r}z2k|}$yPq^=B!+lFx?|t3!2G10b~p`x5gE3M()-MG)S(7MQ>d%_b|7WML4p zE?-7SX)Vfx#dZsCO+f&|rM4SJ0CNvgh{A)yOv+Xg2PJL| zl~T4f1@dI^ff!d$8T{s8Bi+<-y2$)1?*!2kv_=m z-}o%eb*)G*{wb5C*wb_atx91VQ8ibfT2)=(svkjGnx z=f)<`o&6x5oER#D1Ji(+J9^_H`r`fQ{jN0Y@A&^+(Kq!^j)51Qo@PNSSu!z)si&?mpJ9u zUs@6)BHwdIPLj*(7yH0|gi@uqqyX>FfpHCleAQS@6#uXt(23KKgEs$*DBZ-$gblDT zCvZ-#2F2Qh6dgfYYi_${W$F%TE$piL8_d=rJ0W5IZPQgXEs|FYwpmuGD6r{V$~0C6 zseb?oKKxsWs1W(2#?CKhgrx=+=eck)K{C7`yb^GcXbVbO28o(^ki8YEngm5H;gZsS zjJ`xv276jV@R!=`>j zFU>Wfo+`?Q!gZ=}-y2grYIU0#c_G>W8=oV~_)GM)W`(#YOR`1y!S1lEkOd662r!NW zEcKw(Cr_pCB!N}S%FXfSAn^Hxt|NILQP!8OP&fNnyzA=Rx^R22Z(Okb;;CsOs#|r_ zU!uP%>)rD%xyle%POd0`L&>RSiN!NnTi^y zn}Kes#@`g2saj z6jkfpyR(oWptn%a@=}%m5DBNVsF-0&yQ%GWWGBrQiD#^wD;-vOO^Nw0Gu2(2Ya~oA zgvIF0lGQu@7=>}uU7W(OT`=EBvg%z=X{;2uh1BGignIMb(<^+-Ri*T!TgDxgr^f#7 zcrP{1E+Yuvex<#9p7Izr4#~(0{_HT!%Q!J%3NS;mi}l{+JTYsN^XI7`XabpzH)@Q-V521nC(uE2T+eK z$1@+*$D`X}lyCiD_+_hEJ?;X_nWh_%d%*M^*Wr(yhc|GCn40E$spvAeSPTEt$E0GsIwx&`pam9&Au3e88Xm}%AQmFrq&bF1 z1SV9I1tanat|V3Y7(x4SqUyAByJOTF2=-A1R$MMug<7Q_j`BNnhQ>%GI(=?BIkAS^ z(U3b(Nd?9;?r(Q6#U$HBSE^_-4y}Ucwwc0Q+1WFFFX!inr&b=me4SYS8NNN(f4Fe- zWf~Mz@-MLek;4ySusVNaX3b}>;*;4wODuFHrT5)_JLs@dVlmP5dlgvQ0H#|5zSvpKau_;i!935O&?y9nA@mr6><51|ieFkmjoA z4FUg{&+V08#(E2G1wMtzF|#o(IiD-5iMsHbfbXW`6w{~Q(bzAV^3hdsh%58;4Ga)N z^mDpijS@% z0sHgLyxng@YLTIJ*wx=>jp99q(1M}dv(OSC_1-ud!lsPxv@EPSxA<@7*xNc$10ht$ zc0BTMINF)iMI7*zIZOnMo&xoncL zm!h)1AbI$REl3;1;|`X-Y0SmVlUEHk+B5;?@cZ76EjvE57opFS-+AZz}X7MGd@5mXKxn5p5@4?-(V6An!lIe|&U#&fT8kO{nWK z4Ym-q3A?_wdzF^gdTj7N92jIL&8fx(uWPz>Z?>{APdah% zVmI_JdGq28u4>#;kCDrd@#~X#d_vy3>9m>ET)lojJAXZVJwNnvbL7Q~=|!M7SI1o8 zB~?M%h22Q)B$H?zHl`L6nvSbr?69^EgkA!Z$4-Xy>}LZH@q@NI^UZit5eIRbfnD#> zJ6>Wab&I~wJ>GFKZLa3O*8n3@+ve*vzWKTCrfx7X+t`lppBwXYFYD&~-tJa=#@hMr zU_|T8$}i>8>{aylS>k65)=|SN)m>_uRqi2{)d6xW$njgEy34B72gbJjn8%1hU|+;{*mKf`wDgZ+VS zD-F;71H<=kQs{qf`2M%&iT>XhzJHTG{*N312FCxw@J-Rybzf)uGJNa$jJ@Or5&_RG zh~BYy)G?i(l{D-Zc8|vlD5ec55-G*!UjDLvr_*o{KqnjpPOnJ13C!*7Sd(yor@FBd zpWP@GaJ|gP7b~V5dB2Qz)*D`a8KN7Ggk5uw&k>UA;e&ntKM%uJg-Qt`&^^6bB2+iU z!`i{h2QM)BI6lqxwqyikOC(6o`p*2oSu_|_@dn>G%MM}B9%7gU;MEi!Gf`Hzc;h5!rf(RgiN_0bEz3O3M)n^Z7l$|$mJR~k^FwWxdh{6Vf zX$KZNn($cFXJ1>qPtK1UG5&5R`3#ibCRIE(g}%Pr0icEVsiR2BQwp#k6&;Weqrfp2 zj<_KND0?In+$vEiI!jt`Hh|tLlL?0kS7!F)DrWcdtKD-1kBQN6f#?9^ga#t# z6kw#*zzKwj-EkyQlrX|{D`QlgR-6tB(`TNn(A2*-l|wJn<+ zQN$<;8zLQYe;OCFG8CPdPXhXGz-Eea3wQpp1dO%Xg&B?x#pkqJA~3aBQ3M@2|bQokTW6gQ8B zIsPO1focu-h4RZ4LAc~sFQU*5Y8p%$37|H`rA1x@OB#JJN2SI&@i0II9nFbA578ux zRy-Y!_;N*nMR}TWnr2`j;YuO+3Kn}MR;@-cQ+G6GP%F`e?U}17_u2uyG)h&WEd(-- z@$frNLvfZ&DIW@ie#w8CX;|w(Ls-2C*Lroo0xvSaR4)9*k{DD;7Y=^1tIr8C{t*|& zX=6&+Oej=1SNPJebZ}@F4Rh1u4t2&-uFr{l=)E}sI73ezl6ivnnh_^jI0o1KZjot% ziE*FvckMi!`>)zK-wEB43iGEjh|o^4OoDHm@tl`1I2l6@>a*??RouiAn|w<$%{%c& z@!aRB#WQ%VN~i6hjjH;f6FEqC3u181;uCmonkF6O^GRy%VzHf`Gi@;SNoJbRR8;J7< z95~(sON#3gOX~}lmS135l%@8-F(m(zlA?FHXLY)tQYOQ^e++n7D|{J^Xs=QcT|`fWr?7x#mdT`lrH6#w3llu$6d`^mbh|HLFp2FEOYI4j zQCw%7m81P&=(`~5^qQ>@kj_;2;NVrN6JoN|k#I2zH{AM#W`@d!ZIgjtV>KRdj zn5D$|io^MO_%FZ{oE${mez+jyNWr~D35}B3p6(0b5k|0PV#*uKi}463MThl`7|R0H z1O0aWKIwGo|Cq4pXGGjS6lC^IRZPqwR7=Iyj4w&Ls4Ya;chqU`Xwr;U zOwI1?AFIMl-?hLETGk!dc`pbqMGe z-hVA_@v7X@o-4aE5IB<}F3=(_VYTI}O`-)y=fa*4RMR%`07uhJU2b0D(}P zR^S`-X)S?9n^tiVfAQDQtYae`$JhW=JzB?wHf(;Dh^e{0C6C=}gPx(E%z+({EDYS^%MymNQ2DvsaB+lYjUEs>CO!K~0mw8u8m z=Yd2jU0r#bU35J%u5Q|lU$-;ICw^~Xuv;U|AM>K^Q#QT-SJaT+)FU9G*2YTeqY zY%ys0-W@&%N#-A^`paqg<*oHHRSrRG&V;2V+YiM8D1qGb zjtlUM9!i4SgN5B54x`TbnC7@J(wb=>KkpDe1*($QAAF`Q)$SD2_%OzEhHH94%RlY) zU@GLlYoM>cS7^js*y|gXT*AwjAf_3cFn{;r=NMdwIx%`Z^Ko?N&Y`6%ON;t-pVoOI zA%{TRRTRyHH|*A5NP`2v4Rm!AePF(3rLpdC73i0jYk~6O*GrqGLiqD3$2w0T|YSwUr{$58)KPe?fa0e(}^-x5iT?i*Rgr?8gWQKmto0S3!?yWSW zsL{9jD}fTH4mfDK8*kk0yASin6__fB+J_|-It^6c*Q`@7A zvFCEn*Mx|$qq~qo+JMJS?Hh$Dbkk zqNdgr!~PXdSTBRIZxslZAz?YW+A>8~+qv|1N91>%>%;43O((m%w-8Rp7gG;Q7cPwa zz1e!(cnLD9XnXc_$1Z$1y1DxB&JhBi?F&Htnpjrrz74lSxT)Vy(rED#D>!JlxhU6v z#WtTx2}$GLQ>J_B>h$tNrIqnJ0y@qF5}GU&kr_+4X~J*%X}B=ItKG zI>oPJSPnLX&tP}(BS0U+-#z_xS#%38WhxmgCb&N~K*?<}Hb9Qt!_jF*nWZi02|ZWl z7KYeRGa1pq$+5vBwa|Y0Qb$&HV6HST{W*fuAsSOs7BosYZ+LU5x3-pFht{l(ok-tZ zG??$VcXiP-9-V4bcWjmMY57|?L!g?{%A1q=sSLXxA@Z(%2I;mhA+k_ds%6t%OZovd zg@n37&dSE3z$X}IzEVH5(L*LZGJXZ;IHLtru#|&Ag&z(S z-Sk5V){u?pAbJ(?=ja7UA0N0?&^ZHpQs}n$N#*vvzxI92e#(8#qD4&CeIiclgNqwOqJ@qsFpMXDd_IFhIJ8kR z_NzZq9ps~O;`;NWXW_2>Fe3>%cFzIxpL&ZG?vz1&2acg~kJ&^8yN-=B-9>8`8U#z& zxQr^9f~&hB+z)k2S~y_C2Lp(dy3D0=zm*RWZHlLCOTdq_hD{{C=tMJ&E5-3i+*vfd7EYN|H`D@I)UO zLR*UXx#Oe)yJV2T_PS1Sl`uIfsyqSypuw^(*{8?Jj;Z|Y9bGp{G-`@!sth&vQ#spEY=%!VP~rxpEV^QYKqpMTmdXtl}vP!oJI^iGGbCTm8# zT*5%Z?_P*Kk)NWe;1u)X4F7Cs%skd#2M~`OmVuR@Rb^h9=9(9E?d~Plx^0xhCS^{N zNjH*kRUZB@d`Ue!;02}k?+^?I^!1YD!%hQ|qbfDUoq!>2XZ(q~eLAR;t`6M;j>)lc8BID_X;wyL;A$IrMh?g zTEis=@H+qeQ?{Qr_6K;-;pOB%a8vv}xAC95DgJQ`;H|L;@_VhWnp0YFOD*_ zXzMz!i#7Tl)uoRVkN1P5_or=}Xv+E2*-$g(oG(AnVu%P4Ed%jWkVm4HF{2LiGN0 zi5gv+?=ydX8Z{}DP&9&EZPPNTic}2a?J0>ifRqPGd#||NyczXMfPK1mX$Q!rz^eX~ zOqMuG=C9ZDm#QQpv|rn=Ld+g>bA>{3wn@%Oh!7Kg|ekw7Ylbp-Jz z$Y51tdZJTur=}??HlhRXA={BanJ5XW0Y!%J;?(QSE?7icSXKq>Y2C3C9H`=|#SAVw~BTah7pdaenHZIFr|K zl;Ihop?heYNRtr(Zqrvy$|4$co038nM>^KV`wNPMxllq?{cG&W4yl^o%(KF3iNBf4 zaZE*FNc$4WEnH;PzUhNXtld=r7BM$ zwo?ctlNdbEi$yWs;lN9%}C-GK6;$W-+v4sP^x3(*Rp$`Zero6Sh?#qb#`)n|k=-04wI6WjfnxW{OqZ zQ<)tY13asJp{b%FunVC~LRaX4+Y0IS5v8>2j3T@E5<9@nf|*Z^uGT3E41{vn*}NkA zsN#{LQIH#tkTqy8LynkWzIBlqV^Lv57L2R#JEPo7&sPU)(wy##U=A&fkLawiw z*yUpciNzXW)7w(c6bd=**O9Ie}SWqbt4sp-4j2Yu3@ukI)^auLmX- z-z46fvGpdPExX^U1HKvj-7#3&YM*RVx7$tqLWmvi*#sV(S7h6>NKF^JsdZ=p$Se zU7s=WQLJ$&h*yp8m9CQgZTe8i>q6;j-_@a@8Eu0?v%cP<9-+*Rn>JK`k~$Q;(~xI! zx=JmQRvzC&Axx!|R&s46z(Mu<|Adb2iz+Ftv9_wxDqlyX(5O;dQD{W#-*-}={7@y8 zsrqlYU2Ju)zR3!^cUBB8Wnl2imaa0|Cb*adx#6q;>U{!`rN>;Wbl6W2p1Ue!U zObRd&?eo~*mr+GA&CaO^;-fW=gK%)W#hRN}10G@6T_y7f1EOq3uHXfeAY5pg7aIk9 za{{HT{rT7FWQL zxb6qO$8a?djDJxvUBA9V6>XF)db*2AOvB2JIo~Cd@Ay~((dwR?V}ZnT@*`+886~C| zafK~5I@YDGWjGq}Q^vgfGO>yA*QkDDiSSY?IU`)`tk#M`V@Y`%iG&x)&5ER+<5Ea} zdngX*$yxaX!(ncdLuyoP`NVSIK8}_z5Alj-+Xk&)`|AP0 z?x3M^TueLH}NM;LJA)0Exe;EyFT1R-+E`o7PZx(O?uFJ*dDow=?rY6& z+$LrGsOA#~r&G7W7Pzv?q1DrH2W=m#a5KI31@iCC*`CcBcI$$;S+x~mVm4=j)ol-- zwZFpuM{{o(73a3Bjp8oB-QA^ecXuba2MOM|ySqCCcMnc*2oNA>g1cLA3%8SX&OS@_ z{r0%yyFX6OxHzEDLF8b!RTX9GXAteQ!EQS-$ z-0YEtRn9)bu{sj{l8g^u-Yr$zcUaD!*xp}VhQ|wkA&r~tk}bLFI38qOI98q-Vpo`& z4WN>!J|$v?CI0SIWi?X8n%EkiYKrUs)+`agRaV$zOH1H$2hiz{%FjZw52rh2*j=yV zOf|^imwmvx-CPngAR4ScRbG|)R0LZ^FWt z`VH7!Ee3)-`}5#7Y-hN0-k|Y$lE3Cq7aiLsGR<%{q=R2iW0a-F4ASkzo44INoTyv3 z&5Kozt1a96V+dJ8&}Xb-KW5LX9n*7``j5Nsdi*zjf?3wtW(DiG3w9}Y8;buBb#OLv zr%`#oh@>NUB*=vtK7fMga0;ZU&+F;>`EaUCrSXBKa*LZMwUwT{?AT=n^|*wdbnn^)ja1=}vZa-7KyU z_%$5o=8kI)n-3+UD3$WzJ0`wb0cbxXXj>G&n~>uKsLvw!I}KzaT)yE>;6*)!F{IKj zV=H`yfZzRzQOvZ`Y>)C`VM`IRh@UGQMGK;`)(yubS5&4nge*~KqQ9+el0%#vkQ%W#kicD&-HvLHNBV zZboqkE}>H<*po3DEdO0uHb3Z;3x(~F7oVHQT%LE({k@%?wU^_SRmh}GRRF=zbcZRs z{!xWVS=`7GEK=Utv_8{NZz3J$EWv7wwD&on zQ$P#LK`hzyuHnd_BAU?Qwa9DaaxDl7-->d*`gT2c0|xCb#XiPpfi>ZI=_|Z7K5K8# zY`MwLk-#=R6wkzp=h}DPQR+fK0XO?zJ$@;K(?9El)PC+@&J;$TN>`M*aW+&vTW(Cu zL)d9&GwMfk?ad-h6zA2|w|OM$$gTDP6>gKrcN9AIY#D9h)9SjYr10RI!TcuYhe|S} zbFA%m9k||^+mk6Z#+0zi4gingC@M6KTD(4`s);FAqrC($ccw1(uY@L^o27>qf(u(; zB{s*e7@IcX_*c5IzH?7l)iVOpLVQye%Fh(NDw_yq<1c2p2<4gFwB+7mT|ubt`1xjH zWR#)YTSD#70esr=2(NN(9yCa=JN4q*d|&O&HOTfQsmFESCrB0vZ`dlnuVM)0H=n}% zb`-YKyt%}AEJGMK$#gwizk;fKqB8l#0e08DXjg&##Z3J?a2i-0aDKEp?+gU`ULI{d zK5p$I5I^|c{50j=Zo%@~Ji}?`1)nvl#l)=M%^BG^`$F`6-v1~Wn~%u%d3;FxIW?%D zH<|We6#6i4YJ(tM_0c?Q!gkdr;{`cu!x>n8H&9Civp8A+m3LMVhNq@jnY4FOP4H+H z|0aj7@H0nJs@46w%Ad0*G&vR?_WMl{6P*e&+MDOEIcNxXTOW6A9`5EJI=QveamJ(1 z`4i;sA`4*!bH7iWFV>~wR9$hi^zL2~G=!X1PMlI7>7AbT)=jezY*{x@*RwG?S1sHD z49V;6KRv!G)~=sSTG4S;-9I5Q>9Q#|$~~sNMp|kX`uCi8Mh9_c6&md7y@DXPdR+_m zwfP@+KYsLAZL92eAUb3yDsz*271e!lcDUIEH+-DGG=T8_QuNhT2R|&zL&@0(RUbC z_Av6qFEJrqf)FL}2$^%piXxj&*sP&#Rb1i7$_crA0jgAae0n&^Mgl|k%cMO7*-YQ% zRWTwy2b)SFQ;-Yb-(=5-Pg@ThAm`nhLWtVWakqgrKLL9IM%!Lbvi6e~{sK?HOaGs8 zXrBM3W$_=;G1&h1z+?Q+l>+vE0%CCR0R96aMy~#{^UiRh?|EJMh-yZdWAFX@uz|!j zc{R*$6yG+TSU;WFa8YthLrm{D_J-wmWTxukT)>=!*&&u8W&#sZQ_~?1da?7<5RG=6 zHg?-}YH?`Bhw7qxv3vHVb;*gb3-4KQU(L|&w|p+oU++!3BU}=x@YZ_uD4q5~VHWZC z8}>)Qwr5J(Z9DIMXBZ&@UtQf16X?{yiz4UC6K3x2NEz8#WK`oj9)?hTUfmkNJMK{r zCN~Pv6Q$a5f=y%DS!AKW-Y9*T8&^+!FvNUU|F$?3C%b{;u2Em!Isjo)NGcSk{|zFR zAsRs_LN&G*JH8pd+-Hk6wH?TOKLi)lQ(IC2bMiNZ)FLJb5v63!Z!skTjYW54lpyEe z@7U~8sSsG`tNB8a-UB`}s@N+yDe#Xw$ugcYUYUvu$ahbm)0jtKnES~o7%`-Vd1-kB zmZB_XmMD#?Eq<7Q+8ySIL8E1Ujk}w}6G@khraPvr2 z+0n+u4-#QeBO20Qwt{Uf7IdFi7|2hVz{H4paB&^TMwvy`@M&X*4ItL##ZOs813Gjl zz_(dIO&%GWK_@$)$0KQzR(v0qYHP2sqBkCrK8 zw0&%vi`HAylZ8$PJJUR_&a{xH0HiS%9XUwu@ZrK_aWoK6qey2Au^GM+$~=NWGVBLJ zd{}!FNplxk3bV^kV}*=mf!X5QpdXwL_Ee-6HVU)FbsZ&K2L*%R3o5_0^T2UDz}e*U z%&D_|-N8c_PircWL4JZen*s_&iKfG|K{2`$n^DWzOt?%C&1&vAj>M!AoF$OFr?oV1 z14Wp!EKtp+4U*9n?@i!9sU;I0-mT?a0s}i+DPL)PCWGsN*=^%BnKE{o5Se&BsX8Su za*CQf$sn@th4K1V8uP=VqD4EI_OX#(K?+ znL{;LrUrGK5LRi^qo6mIQ!av76qC7RXy&|@@^Z+YD%eLIV4@~mOcdjW@$BsZTe|E&%S4eiN|YCL9PM|%dBj-LRiKR| z&WkUtMPlrUGv+FqO73JAOpNN}lIrE|;3lZOzj^b+tQx}>t^&ZSG&-uY8UxY;(IO8t z2iA*h>IkZT%RNn~?3&_|Yo|7TLNgyvN`VeFyHO}{OZ%*`U=@p(4kbVk&xT6Hxy94! zh0v013uG*;nJ={YQZo;aSA_vukOL!E(cp#eRoK86(Em0!p{0Y^f?dv00jMC1B0Xe| z3#-J2Cx-k!T2?AdNVF7G0U`Emc*BWI)M!hiL!gr(9~7vaqhvqKmym?*aH6yhnZpHs z#!ikw@(of*++n08d^9nS9%GHkHBCw^sgurB*uhMes*)Fu82*A0QhOz$x50z@-vKU4 zyn<@j762pMC;J^=jLt6~TKKMm$%%QDRV3oBpd=4?P$?Ai$yCjGkxdspgUB1c1b^ZK zeV?%&!=5?lL=3Vbe~4mV)Gn81lzhY!R0vR+%f zjLs54^ax+AZE`@9Xk~*25!NL(5g)>#f{*MT5Guq2mo#^{ho^hyHOI<;z_!P`M@*Hc zjti@LGE_#!n`mM+yL?rb-#;M3Z3wKRT2f4O`<52+~V6h@xmhuqYp*4ZPhp z!x%gS4%k=Pr$$qh3D>7UcDXT=K-*X>RgUez`6e2hDWjshc;2!(eWF;v<{m2&w}D7F z05xt;ARxaSI|lf`cFX2PEp`j;k-`gFM0X>HZ)s>w@@Y!*p>Tdr!!JYDGX*}ec-(DA z5L%!BNG#HGNwjpG=tKnZ-32buJt3x@Ic8a8Jj1#!(8vyq)YwNV9xZr+*WDD@+SuoU zpuT9{p$H#Wan08^HefboT&`#iq7HLyGNif(jw?3`e_-onr>hh;~Tq{hsNtzajr%4Oggg8;*+Hwoa^&K@bx3Yj}cSF)#YrR8{ zg;nnlFkFx=u|_#ew{r?xnfffvT4ATPx@}k!^Sz8|0)kmR%D4Sd9p$2Kq=RYk;vig5 z$PjK`x)XnAdSE*(SJ%uKf<7hHgGx1*Q%smV;sFbyRbHi=Gf)hY3r$TxYid=wUARXz zrn^~%ec@^?JxGE4>l^ysAOl?`1q_%_zRVVOX$*9aEwmU*Ua?>WnW02E-nhBsrfkx@ zYg4^7c}KEuT_h_IaOr*{+YfgGR87bwg0KY&Jk-Z4&q`Y)-sJYX zr>t}r{}|2^wSdxv*K~C@N>4C`3LC4K4>lx9>Yxy8_j)sNHRHpgeU6n)lj%ibSF!@T zTjl8%PA?o!%`w^Ni$rA1R`@RMWk94`MzOF}-a1^UTc-CEvW>>>d0y_89#y@*yXp~K zZ7}70q>{vurX2rG$kITh1=HP|cCuVWW~j%g`K!}`{i=NCpLycY&!@0hG5qk6%EXFo z@AInCU$kcCN3Q(+U*p{$#?NWA&&R1FblXz}9GX+sjgg@7%8O zQRoil{SB>T)f6f8s;yYD62V3KS$+7)tR@IJGM=0)3H3|yiBa8TCe6%F&XJ~X%=t*$ zb+#y4)?CDy@W`X}y4L6%{O64i*$7R}yt`)}U((_Nb6(llf2h84BdC^)tnuH-6XJ@UFRw4^H83CPZ-sg**Be&*z zc$L6+SVqZ?*keIs!G=&*oOG}}5o@5HYINNq+Kto<({z$|-WpbToDF{Xii|AuzMd6W zx*?{=br5s)LmPrFK@S-t`T20Q(6FWK{w*Sva3|5wbq-r|mQ&?1p%Y4Cdl#hmXfKM& zqbxWO8~b2gD94DzOg3Ea;Y7hls+TW$l4#ClWyatr?u*l%=CY_vScDJd&YdWiZ5RDW z?jk{#^GzdxrzZb9?DHDL-D%4S1U#oSYwx_qIJ(~8pTurm6!%c50=ovHL2J7Rc%_mi z*u>FiLVDeO-b0X8-+Qxk`8nAiIKRL})Hi zm4-@(w=$zq)ejtTESHK}tR*Ja=S@pjI_F&4vhy32&Mmy*>6T;2R)_@Q>?#&no+^NI zDL2(+&*}=29&JGD`|e>m-{IteuTR_TfT$}^sd4n~bHil>maF+fm?qbGA}#BZd)I^B zlyI*%pQXv71XEVCl)n0fG2nZbNdh|T*|)3&gvPCOpx2#;?ki+$_^_%K=ss^yz?U2L z;a9maHHh_ZXL{z+`w65(%#8c5) zW}|n#Hdw6gh2QqDODyR1gp@(^37@_eJ>K``vryg0D18;WGOj2?wls!9k!J<;)5cxS zsb`c{ax1dOG*gev2lYY2ttY8+p~F;dmfJ>x?uM=r?$l&lOZ~UG^@RG zXd`#dM(p(b-Yji<-y31{)%7#1h=;l5EW-~OR%Hbj>%ebceGRv>Ptr6PQz5>S>yYnD zX&R4o%Gd{3KpbdD@`Mt0S5SbA@#ZUr!rD-SzEGcHwX=Err{hBvz) z_el}gfcDo!9=PvVj^7F{qI6}s6+W~DX4Tnjl$WF^U?HmXZ&)d~-O?y80e159x0($-IUbM_ih>qZ-9Mn=ZM zi-u6xu4-Nj+Cm?F$&aWfViOkY$^uKsiLGoCO-rjC-PMK?3QEn6WF z;ou&QYqac`2eIj8`LzX6f#%sq# zUsP@;um8rm!zrXm7j(mW-ci>|E~mmm9NjO%Kk+h0;z5RP%4fSTAD=flC!hH0I~f6x zFPO~F;D&Hb5wd22Zy+>E=4mhc33RQ(Z%e$Mb^LN1p-NdZ7Gqf`?jqYlT1v2S%VamO%x(}%9rw`RcJfdWAAN2^3%*_4zp`8$ zZ~23FR=6Pkv$MzkA5m0)H_`sLfrYUD8(dXZ-v0n)U!rH^0=hHhzgYIk43K;wlK?g* zv=Wod^ZpE-2AJaNl}><6p^B{+sUb@r_hkL7>VUHZExHV!*?A~_kI@!Qf*t(=+2PNe z$Ba`rnnXLw-mt>>B|X{*+n>3gG)A4O7Dw$Fa@gNUqR^xJ{?1>lL6Kv~ z&upx6o038F32OBz2tVGbSWkOxQWvX|oBeLJP~1 z$;H3-ZdWaaC$0u1oJ&@)N<3pa_@fBam;o#4PPILm?!qtM=FXET3=$Foi-R24X+3tAXu*;w(v9npt3jc7?H{0gQWkeGs4 z3e-F_2d4HBdunMXYy+%-5{XTGWUYLnwz^3mZ#B+qmO>6`Y2)p@f&!S()ImVSE(L1n zm;>QtHdWwgBV@iTVnI>vA4BELGf|Ge1?}ZS6Q9WbF})(J5zR)ml385Z6|ijPW5)u8 zk@j29o?6$f2RtSP~3p0!u(}Hi{-89NX8SY(|EI_Z?aeQvRAc-$N--nlol;9IqE+ALMd+5<$T1c0T3Y;1B%M;m2tT3*Cl6PEq2lm7pkA_MCYJ9P~B@OAIk-#7YexGNF zD3<>gva|+OqbnO1sQQ^&ne@lIS|jubv<6}g{2hfesmK^KLUp3q#qA#qGky=D?`V7B zcptwr^vcBbl|RchYx_}sXX%AQzHTw{OWepf$`Hz_pZ+Mczz6ADUYQiwBN^8dDlzjb z)I`1knIBO16_Kx*@DHxaDbh zjQ>|l@a*gnMsNy_Ev`m4#sLv8CMm)|KQ1@IzCq?=G*dH-W|$V!Ydg)x8Z-Eg(YgDa z4uJS*=J!~1KnlSup?bK#SU%soR0V_nkk6_#gLClc!W6?(Xb;K3Ig;BdTZRB&G|Z8} zQAVstxs(!l(;EOhew#XKOUo0KLrRFe?Gj9?GlA?F=~@-YCCyt?xFb@!0t;5%Av`u3*%c zBybA~Y+NdpE~`H88|M=y$}p|CfSJQl1|Bc{9+`u_fj(kvnHa=bn?)pavR5!-#X z^4VM3l+%kx=H_&=LS!SibNIJ)q`yksTLBYauMyL=PKivYsdpMKF=1deSDo7t1~w{; zf0%HJ#o*B*W8^@HwTU;b76G}4UxLCUKbF1}fmC}CQ$Xv=q+x0zMJhwKHe}@USDz03 z=Tqov>QR>lC>FN#Vj0=udT_PqU6acJWh(~~CjXJnjk+%4P!DU|t)t5qocVNTim1od zqYiaX?{0==wd>9wx65x$-$hawO`YzW`qK}!TGLP_b8z)+L}K4qQev*tAT#6B8yy^0 zU13!NZ=UTuTfKmOm$N_i=f6GeW;+~5ZZgUkO**xFtBaG=BkZ8@7sfQwdP&!8IvekK zY9+63CJPX%wl;5&gHz?JYjo2& ze+XCpd_OQE4e-HKqn&$Oj*Q(@Q>*ko@EC1TvlrtTqq_B3f1$e`5Mjx%V}>S-t;m3W zc^ST+E^Ht$_LbxHo;HKc3UjOWabGOMg={Ym5h-R*>N{Nrr;zHc1w$o1r%peH7p4Zo zn9L-QtsSxbg>lP#8eWT^$Kc6%OGhM;p@rr1$no=lv+LkmFSKh}-hObNVV5jA>FpIFZ?R^99>1J*%!!q%D z2A>W5;40-0E793#V8i-={$i)i*9;TO9zJA*=UHQ!no8t0k$G*4k4K;V)&i$>HYKD? z8Xl0UD)_D|l$y&rhB3Z`%{j48CFr>5gpMCe5q^p&--}7vzH;H|GWB#}@MCi5Xy9Ab-TwMQrKt-UpBg_fr=?wdhRl!%sVc$*%g&yb>MY}F^Wcci)0ipU z3TJA)tEV>#mPb_4tj9d$z%opIRX^I)-(bbH=s4TV>Wj!nW>VPZ3Bdea(1x}LN|fM8 zNeKICC7U6s6onT+pRKQS&sN&2l4msKWw4*`Y`Rs~)9puJt2&+XDpRg6-1SfQ?BBMryS=?48GUX5cb(f@IF)^K2v#wop$5P%rgEqjOeZk%lWJgbiNy*n zv(jp)yGRbF*&%u-BXlaxdlg6+Nl^=bBZ0jr;k#^-=7UZTg_Bz7uu}<{l zWk0ki>$55oEKq}D6Rf$2b2?EeMzy#0;%_8_6i(uIdEEvyZ_n$F6MYUe=;-KOC&h!c z(RTvVGWlY?uL&$ap{K@YzfvU|85hMQkQ=eyrdrC?Ye?5~(zUCU(&zAPsabF{RTW8K zK8C<<_GD~*Dq2=89-y^iGf%F?L@vfo!VB{1wauQLKeLyOX4~ip;(4tYgn3iSzzrBJ zt@R6O3!;zSc2ZVo@Na&eYT!RKMm6ec*B2V=_muQ3GElrZD}~v`9p-xTQajYjMAkTe zOwh2#eJo6>oA(`PJwOrC)(Bu?aFh1c6}PZP-+)&z#TVRxA0nCK9D0oBmAJ6{jLu7t zwir23k$u!&H1|B2S_TfM6k*QhSN=o79(A(x``U^v*13023Vnp{jQc(bs0;*qJ%rGB zT`h%skX(W&3{>5Db#=;grXQPxI&&(+i#l!X#;Ym^8lj%(7X6KV=d_U9?vR_e^T!1_ zkmu*WXs{%la@=FaPc4m5_D>z~rK0CC_97OZ8dWvh#mwCd;Sd!+XR^~nxoyPM<(0?igS3Zl|{Vo|c z!UNY(xNOoL2D^!oCe?bt@SVWJW>S}1k|;N|btOmvxh21X$KA25;Do`FHHOl!jdM}s zJ@Dch)|5AnDZ8{eIkgQ*yx@qZXn%7x;HSuTdL*u?SIS!5OD}qp+32(e*9!(;=G(48 z2y60p+Z?hn`A=5OxO+`;!@Y(NYj7me_`ToNL;Uyb=j}2u>rQHBA8_Cdh<+lqI&Ttx zeDzae6@;{NbLSHiT?guProV7KU~zr+SUY zLzc5qkwg^>DVXFfph;kk=lA`JYA`owD=>;w=|X89;|Dzi52@=|ht2r*Ps#285ZH~>weBVkb%O3rAMPBU0;9Hx(N8dv%cxH$_!^_FzXV!#s=K< zJTM%6JI|i7;~VX%!b|4cbs+CmT7Mjq*oN+;akV{9-4yxo(mp_pr5N9LKi#mkMp(!f z7&hs;cZ+|zwx-}I=qGf$H$uSD7_B>fWHyV%(JVhhm$%yp3GEVmvJ`i>xWwyfWok|Ejgc0ku~=~B zGo4pVN9_^Eb#K6lAawtfV;IQF4Um;-YsWX}TDe2wF3 zH4 zJ-q5iKn<>xae2&XD6&SW_64My*EG7y;ex2}93i#0&69z5#$nw2*}6Kz)rdiGfK@v# z6L&Ww+~>m7?oXl5Jb1}uXnS_B^)+ngh4)0&pRwE5G;J@$x?(womv9F>eDMg2_7ED| zBMVsy!RJeloz z`(+GoSyK-Q8^7G?Zba8L`M-|f>@t3qz%TQ7wa1pOpsDHNbjJ4d0}b-)Xm)>Z**kfp zOL}4CEex3}fF?^_0_*+u!ye9p&55^DT~@q}{aW73ZOWXj)B_cjTRE=7w2#HKJhAjug>}>9QuxrYtDclIU81rffqq!eY+; zHuC3Z1|xEJ>{e82XUOI75pM747HCEE?XUDwq%PQi2wi*Dr$QX71!8z?K%K6FF0&LE z=iaBXb*lF3{x>3eycZiMst|gzXWrH*=v4cuA3d0O@qZtYCdxm`)We zo1_KkB&%b`RU;H98kj0hheCN~y!blU4?8w>V)(Z4qGj|=OCH*2d1!v9NAFBj7b&qq z62~X*Dx@&X5tWe(j7WZ@i{ww^;)o=ac;C94%{Ofm$!r8E5>yd|;kza9?`1<;t7Vg5 z?k!XM61H$Fk1yB~(&UdX8mKkAO>+8Bc)e*6hj(@7{3hQ9gJH)`jfm)GA$-8HSzN@H zWfgK*z=gGrWsTE`S9hf3ttT$4of@e)zGB2%(4CuT{AHGjpb}BOw8@2M8so8BYG0d> zLk&uGxat;FyMDb{2TpWJ=wI(@N-c zX;UO1lCTV0@|pfOk`35M9F&WeKQ`YjI!bsC{#<_nc~1snN4}V(4<;L8n`84K`SLmR zyiA87mQ%RT#_slOQfQrISouwih!m5L@ErsqNr;`XkvybN(`REDCnO-0k!2>%5Ts9L zNuJ^ryL{IQHD?-<7dEF@jb-gvF*r-p3S#KYShoNPQj&SYvZhp!msy5=n_L71-m+ur z8#C&+7D-+ehXOjRGoOp%WNOT7$MWE{;J<^9RL+e>o@NdXd0%G1h{{p;n6+-N$m_Rm zPc%KCg&G^{$)~+%VlOHFrNx53uQnWre&iJ+%7ko}ttk}^Qo>Ro&T=9azj4XvDx-4= zW+0E1w9ycd!aSxtt+Jq|SW7@a% zaYd51Flt-2@2B_>CXfo9Fx$S=e0bN#hfv2xt%1Ku&_wi@;SSSk5tlh4&^xzs{9dNs zTt3{WW-zGr-55%wm=;0_jk>LhJmj)vYGP~~w-!-{MF8)}S0-Ntz6ntg(1L^SjYK?9 zwpbJiyyLBu*t+nRxs;r@&Blj&oYB@BYdWqEC=iT|kn4f*zy($?^?Wi|W~N2QNxP%v zSdmu7*}%cliSiJo?TN3SnsqIZig~0C*og*vN_Yd>`e8y(px!vOelY8MGg)Mr+@cfV zD-X~=9t+Sg{hl>B6chY$ixV5atoIBv}W8O1e2zsiNrpb3Oy~;h=kM%!7i3=lAH~;6Oz-TU9Fzj^{ASbxhZ;M z);w;jwAhp#^m%u6~L?YIsZ6Ku4Ua^FHd)Fm>Cel1JluAsJV7fO6Plj?&*1=>3(+x z?NrAY@^v282nQ91228P#D{*-8scx3G@D!1dNDOa>#HWvRX!TodW!0*Q6)qFw!uEe!37jYRb1ooh6Rir&|}(vsO!+IZdxc1qd#D_T_9XHvsFA)+l^6+_V$Rz^Izo z@6DA{4iO)8OjK&O*~N2N<@%eZA-~=lt-&hkM`gw3n}S)o1zy*o?k!y0%sOfamH@mr zvlxSpxTrr9Khg5ENyElFJh*$`;8)4m0Jb zeHX78$@ZiVxh&k%i#-WCjsMe4EYVNq{1|os$A}rHpy&S3tEa7}{n^#i#pS^X9BGx= zo@IYMETS&7;L5E!R~%hb9HPQ~<#8FnfUuZ{Ha0N; z7IT(RoFM1$IsVf;g+}rf{E7-=Q(`IE<&Q;PwU76^kK0cVyCD?&Xm0p%sTKHHH1}ug zssVO04X+>EDg2gJF&6bgc|T}M$|9cE2}d{T64g5%!HqZueviUxW~pSlpK0VxNVO+C zb#TVED3m2|v2%+$^;2I;+Xv!|kn%HrX({R=-OwqF&|I~Y-p%fZm=7Y80O8YUx7dSS z!a&0-9Ug7LJaKGr47$g_;Uc>P;(vww`QxnmAg(j_XxWCURr7__o(hz8ABcA?$|cvk zFlKo)=5XkwaTMFYh@%LQzyxH(V;RkDS66c&2IISQAf5O|l}=DrHKs_4(S-+iu)#J$5GWUX znh&pP>8ftfoRm}D@CH&g%GV5kKF-eH?9Puw&QOkBGrX86I~IErF{)>8;RJg?-QNyO zO3VhF_YF@iRX!oa)nF-SoGyzSm?c4iJ+<0=>W()>1bQNV-q6DA%Mkgfv6giRNYSwd za`6U8S2t+;8CEJ@!YwFYfM-fB?K$f7T)X1u?&bFyuHA#R2iGEbk>;FrFx^w6M9oX3 zhS%`R9*$;Ydz1dG@9^o#GBOmMl0+GYnVFds$UZ&uDnf%bMkR$je4~AuI4zJo2PWhhQ7=DAzA9v(bsY=GGa(sUv48m+j%8gdCHsrIH>d8hxdwjwkS#s}qRwDg$ zS7Lo|l)LtG_UUr)o`@rzMxa_j(CA2?Dve3QHUomJn)*s(XKZ@jk68j1O>1Ct1NDNS za$kiQVFR%vE~-C3-fpiMxH`RvEUt+zy?L!iyRn3-kE!ytlrE@8I7wj!1f&EZo6x{s z!{$)#WcxjL1Hr99u)L?w>h#ve;+R?3?qgqj#=$3C*nR7x#&_`$;qHvZ9Gfm=HuLzd zM_AL-fg}zE&P?&@S8xzW&W{&yU}Q>ealYrfdfAPtUVu<#Q80Rfwf6iR#Eztm-nx7L zre*k~L4}sr>g=+&K4%>R@D7TQ7mk@OVL60mJ~=alsaA3addcK8*W$SN7OY>-3xrRz z>AGo$mG$F@<029oNysu&ZbL(txR-dF=T32?#9-+*6rRNOdU1Kya8V0AiJTzR-@}$^ zeXV#ITJGdV@G9^9i0rm7WU|a+j86NpGM9FOy^p0g?#Dcf`nT*JBg(y(cCwuu@_`ij zW!mp@Hsi9SyL7vhVCJfJm51Rb*X@Lx>$*9tv4-Zv~^Nr!}B z$W(R2*%-Zsu(+=TCgaaodj#gjO$1ZvdVLKRwM+z|Ig}gIC|r4-&q!PjhSFQ%w?0k7&Z>$ndbg{Tw3tLd1^2@p)cjdK1R z(kN)tEYLSNAI@hTvL5`)C(!{8g+>bZW=j6`oaG9vsr&byTQ{focO$}6KVhq6d%^$B zzq|ht8kPNjBQz@eKcP`U6YKxaBSCxDZ5)*IL?z4WNmj!utb*+fv^S zA^$44jxHA>rrYZD#=P4 z7j5(sNU?Ucgl0P^h=S#}1$T*~_t}kHcZD6%kfuz!m1A+f2npBxn@If$X63)8x3K>n z^vfddVDD;S@9IMO+bjRSb|(Hm&$R{o>1Ne`Tlwpbm>P?Og^R1+uR|qjEIPVxLGRq0 z+{`?nO&PFgSi9O;(7Lbz*p2L+EjihZIGI_QSxKEO>?}-NEJ#5!jV)a0{&aimPnXU# zJRL1ql!2~x*7g=IAWs18T}jzk6ii%PNq?K72FeNNe|`9qjQ@e!5d-Ov0=bYy#=_3c z!qwW$gh|Z7&ioIQo!`HZv^R4wx3;%p(YCf1wRf@p*JpL0sp~HTep$ixKf?diLi(rh z{|mW)O8S4v1#Q{c+QRw&Lh3)C0DwQj^xL;8CRYFBSXLH!Yjc-BqDcBXtfarEEvu2T z{n|6=?Uyjn+wa6AW&4BW_faA>QuaSs*nhM9X*%`qEdDF((f_Lff9PlbeW&nGB7XD# zmk3!69SvG`W;SMSx<8!qmmRSEA>j`*|EQlo%lXskq2Id~H*qzwbFlhXhLN)Wk<7nj zDms{3uxPqi{44u@DvVCFy_DxOhNm_3K4y|6eq~FZiZ^(Ae1i&IelaE8c%w%gzgW1pJ-G z3i>1R7aA)o4<{&!f2Fap{z{|2(%5+b|DXX_e`Ua5`2g%(|F93h@hcdA<>Th!_=h|Y zmfPRgvaxY+|C7eW2@3yT3m-ekSAX{bD9F5^LisBnCoAvY^|Eua zbN^ijJ1+;v-~G(a%k|H=f&B9K{Q>|S9DmmVBK^9l`xjdP04|=t>jeOKIsXxJ0M9>Z z92`9V;N#%r{QG_Z99$fKijk|ciM5@DGlGBsi<*N2=o$X2Ak|o8B}nxI0Bk&#W}Lhx zCZ?t)JlyQ8oNT717ACB`761UZDH|(~kN_7uCnvil7n_+GFTm791AKvLDMy(~b*0jd`lR}*K~-_-&Dg`ER|ib_&h3gQ0&llcrb diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_migration-document.pdf b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_migration-document.pdf deleted file mode 100644 index afd9ec7f417a65d00913eebe6eaebdfd90a17931..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 99118 zcmd43W0YmlmNgi*ZQHnE+qQYbwj;wfGi;j~wrywF%8bacI$zbRuIm2YsOn!m>i#+V z>~r_pYwY`D&NbJ(hf-Nwl981O07rRnIJX4HLBc}fXlet;&(ACmbg*=@B4OiT;b4}u zwsQlzFiYB*xB7sC8I$=O%}?qwHY zH=m3dy~_n5$(KmfcX}=IdDtG2Y2@v8gBV$cN+-ACkUogTXXrD*%o8*&1S=dcA9}Wk zZ~gozeiuK6+bd>b6Jxs*d1u&}3j&N=bU{(}B^bj2-z-(9ni(!O@l@a^q-!nmtcg^s z$5@lz9~gy7@^%*=!SU9^+v@Fy zAGkfNx3G%aw&vRw%xAKSM=TH-aaMKJr&E(V(!Ii4?451658Y90_!)6#Prg$H$qED* zO!AvAyW&mqw^R^w<}hxmj$Wp-%0{PYvId8;$9j)fqN5d?tDSIpsj{Tbuq%k#JivJH zu&<*haOB`#Mc-P_(r5=6io=JuVqtRB0wJQTteU?~Ij!mn&)B1s8e3&sW<@MtIA1M1 z;y_u7Z8g(y)mbn>r09qla+Q>pc++B%vk<<<;oxbpCz#pU@KXYE9-70|aFU4zh%Cp7 z^4471G%)B%P%@9@2)o{vx8Zr`+F3?q1h_r0D@3#sae0kn@tzt9hA=U48Hw@@ zg%3rNzibLV*s<-#{?wcfh`n<;7fe>@q&wtgbZMeV-jO_d=z2l6>wvnz8Hd-u2tzw# ztDiD$l%o(fNc3SG{{nN!-#hQvi=_AB_=P-ttac-t5_|W#2}uQ zdfrnp-nmY$F`}>sWO_UjNyS8|m2L!RYA?b`9{2^3Wsp%fo9YCjAzPEt$)42r@J^=> z^}Z$B)3Tvz1s_Qu5>&f4PGKDxCaMm@C!bKz-Vt}{^Z4Yi+LCOrCLl47kZh-!31U;C zIyZ50_EGzato{y33}=pEpntUPB}+@3(&+0(VuD7*9wUVaWXBZpw5G+P&>4G?Rd;-? z6B_1;YTsf|P&d9REp&M>fYg;X(F^vCF#y7330Mm-6UO0xUo~&8wsG1bdWiULdPSEY z2c3nPzK5=FnkE>juSV=tMWC-wa96Ukh9WN4Bj%jGs^l1N<`97&dmHuRXPOi7%o%M^ zrCiX@u0S$@U@4{obK^M^*+02V5-tYI6tiq4^K(Pw2D{}RT9|+lT$4R-ZB>;*$7QO3 zL2boo=$7mH#pHngTeUq%R>LurOV($IVTQ0c$S$L&b*Hl~Wz8Q&90Lt&&L1{1k?s_L z-zr$yDUCA78FF{(SJL`$YPTewZjACCz^Ii|o@o}#3bVX}cfXM*UWsEcYr~b&sy@v0 zC?CSLQQ->3T7{>gpE0WivOTmi*pwE6N5G_*aO>{4sm`ut+*FfbwbZRnqZL!ViL1eW zxqIDI{6^^{l_3Z#>|@c?KP)I|4N&T=XWlOK#D_DS_|dYNpoI*c%bkKrT_y+~wDV*B zwvJ9VLC}k6gTE*chS}&&EUw(HA1G%Mg`iD$#*LV^7 z5DueD4SQ+Ylz^SOYe#QeM{j&ItjA;u|L^(2WHl z#o6(+4-mFiTg{EKcxsflZSZg0PT=hh{+>pSeL$K z>F!;RZ43e5_(*x03OS<~GDB*|r-}Na0BSS#_WAamt`0am;M?(^ljtNJ#1WMDU%Vjjgx)j`BC)o6JnoE8 zGwK1K-i5vUsL0V8QeVabE?Z4CSY_Z&iz@_3$ojNKkN#lI&~8eq14yE%>3q;Y>@2%a zM-*1dw$>U}7N<$xhY~9Kv#qXcusbu61B!t^vsxRt1{qyW?knM2Pp%~dQS z+?kV0K%uR0{#3YHXkHf7k7_0=rcuVw^NSL-Zzy{Enrv)kXTSJ#(LZ*L7|24=g z(7-U}Ob|V3-0b=3S$iemKiBvrttW#c#Z$&15E$6UmfON`j1b5d^l5B%ZbDY*kz zxSS?x<@iAn{Z;E}6T&^s9dW=i$i%Q~qVl}($6P8}B9k8wx0x1WK9%m>&C|cFkY5io zWd2+}b7mPCDmdJnEZF&=&QM`{E=|4MF1X!2IIv~s%Ws+4jk!Co+72K-9&PdC?aq8* zaVRtEAfc^_z0V`**r=IM0yIxxL#Z}?XU9Vv{RK~c8{n)Vsfr;z_ z5w<@B-M!{oewRBgJj^_d%(%OG3*^i9#r276Wvp3Z@y-fdJUS(`;e}FglEN;f_p7$c zT%MF*GZQsbq=)Cp(@EvTd*EaE0rxrRfP_=7I+kr7uPRV;OS(iFuMEjR zIgS7*U8;NZG0)RZWIV%?!6H`ylS~{HhDCGbfUYwK5f((e)T}smIl5OquRK}u@RF%Bg`FynIZhrr;x)0Zi}k^BEc!HOhU8>VZ<0@?J#rr$4 zhzNP{Iwk53>>fTO3W@QsgAhRma)zRI>4CwloJ}SF7nyCTZ zNc5QhGE5R?b)c6U3A2p-->-@O^D6ewtBe7&D&|Nj4Jpe;=@u0RAx$ z{QF^60GeByh&p=dvHYFl;Nf6m<0jz-urhIT8wd*iBmI9Q&Gq-$|BJ!0vHuSYwnzKl z8SI$Ww3xH$sh8D#K_ z_5h3#R7CL56v4N?SVelvb8%3UJSnyCil79NO{O?PaU#TpaNq0OA^*t3#n4P-6hWj* zQsR~#by3pX0f-hM#dps-diF>Vzz!*;0Y`VQiT~B-4x~+B_Ki=%4aOI0BJAlBjxT{H z85?c*da5ixz?ks$%#EyZmAS#L{wd_o_^ziB8~_qgI)Cvka*w%U+8( z+?Tdlp?|Vaa-5LB@ZwVo(TeAl!_nj-e$bea)XLAud*gzGLN9_Ai&#lRlVSydrj82h z8Z7}zGG?3xH;^lc<4XMV+2#@-MY6($>HlMi7#UJcAt?V`1C&{0%e$bHrWOG9oQ>4V z)xtzpYLY>|K?oB8uP&;Y69H&Xr@J|Y17n5LJYG6I{5>eqi)wb0C1-|1Ld<&u!L|0> z$iT0+NgSdu=8^>zQ9F80(-uKnRDplR6I~HlnP`n|Ps5F_2vA$H6**g=;q;nh*$1pa zDO$@?L0sd(fPKTEeXB$gJb0d{5ZT0$rdMNEGu%x425vnbZD|7%H@y6f6Ke4_i;A+x zE%z-#>CU79?Bx%cED7luuQ+bPY-BsEY zkLB&tA!#R_tm{x=HHzQXYiiA4HM(p&;Q3^TJ?`ZDofm{A9F3wr+WpuQbMuszBhy!2 zkI(lH*MQ%2T|c_Jy#t+Jn!{bGouJeIar)%@{v=#j%RPVu$&>~3n?#$HTnS42XBtyyT( zyGUD<0p`MMx%^CRVmJQGnpYtKX7;?(?DW&EX4Rk>OvUs-kkJTaK2)O?AR{8kub53<1EKL;xsk83gQ8!JlpSJ%4%vkpH4JX!lDe;W04 zb#&$lwH}C=Z#y;BVBU_`qG0aFglQ|Y8Nm)_mod2f#CDfh&90+tL-AvY;QmQd{R?U!b%x%t5sd zSLxU{D>U!*G?-twrQ%-Xg-K7yMecMuK+@8|9O{mGNM@=2QWVC>C>p^z!1KF%Z99iK z%5=*vtK7=_W6*;Gu^kwB<%IVQ0;AQn@F1{ztsKN=#{hZr*1AgQW10xTTo0Y}8p zUZy8CNIw#&66BDJQp=q_wDHV;_dNrDVd52vU|I)SNrbgeaxnow_F8j=r&X* zMBiS_`~tDJrIHVv1n4FRlKVuQZ5o?wtDrM@%02>zZ#{7}(R?FCwOpRn7E5Y(U_S9~ zBVcZYXf8Np?{%2LAbcfI%0CjAR1P{IX0^II(UTqGfE1UP05j%M!?YPwNMR2vd&l=;CT0}s2t1A$3R6-@% zp)()k`Y_x+mRy~Bq}A0J5ipm($4_@bQW)Ba`s&`=Db-8q z-57WBC)iprmoZ_e#P;v0&9B|0m`ZPXGiP!U>Ilg2ztf0|bOr}YCH?s5#tK#Orw*P< zREocPyo;ym2#`p3KL-_bBQ@`j%`6A$KH{Vm9} ztvSf8@Gwe^+c%DoKhzMj`8wm$sDU@ruCAeus|<8T$J-1>(-Ib;yY}I@Ot%3VN7X$m z6HCq3Ogz3=Jz0Es-e>5Tb}7^r5-)=+gPwS&Cy=|hTfL`cVM8r?OpLT3`Bi#`B*^|5J5jpy8D=v(|@jlMeW%*aPoNEK~y+JxJ>9I%F_ z0R1w-#F2BT+wV3R1+){n#7Dd!ZKeSZAE4FcxPHufEUM~Rd6~G%#xAOdXq2V9=uc5` z!8WUmHeO#^y8x*<*AFhH2b3+7(%`X5TCLKvW5^|sOHEHpduyb@Is}` zpKuz3N+KWZniuT!@tsUJOOr2T$w)M)2cbJqy{!;xs2_Wbi4+(@ycJ+UHGqCS>!%?S z>|bZc%Yi;_CrW|$@6DEh&!?6N3Eh=nKCc&ky!Qb=?*+$uz2FIkeAEX035nzg57Ny* ziLOH0F}~5cjt`f|jl;7>JQ)@AciED%!Gu8kg!jXlHc2Y2zKi;SCIfm&0ox`+^%8x=Or#`@$et{DEn zljC$uaWy2P3)8|+gEtm1Ip7O!5}kPo_aFgw)OJ)?w*tCveu%B0fka|C znYGl_LL_60G!BRh60Dl=L_aPTTc(_TPV?Q(T7Dk=`MsQbHUQdDcJ>8^O`G?hmy6_qwQ1QeSBl2S7ac#OYQFb6rRGm;7zb2-bv9WmxF80;&8 zym7dglxT*yeePWNlAlj)83@1JYYu66jZJUa=}f13*Q(}W2amHKcxR#s!ef&v@d1(F zGA37XN&3ve*N>VYC3qMhm`)MoNCy#g?Tinuqbmn|2+fQVEe6dHEN>PWHbt?M|&H%>8pCQ2vinIDZ zWim;rLT0dCe-+MmarQ+_i*Vx|X{(}_SL+_wZYj2{o?bOnC>#G4A+d8`FuR>w?lt3< zeMYc<`BJ(bad}RcFg%*I27VQ-2kvN-`U9~f^uivAPrl8ec-u-E&a9Z>DB$?f!dokQ zxiFN_1Nk1QiIv`@e_*473%H(1X$L8 zh!6i182&ZF{sYbaw;?R+f6;RO17bP2{|AVj(Xn^j;zaqZGjh%kFOk-X^4XmSwN5sr zT_m%=a_DD+iB=f9FrP>|0t_{LHRX4b(@vDUlexPGjXKq^-{$fCButQc9q{5{lZPRQ zfdGvy8yy+gGaq`N^(g%v31B}Vg%(^+CXalP0CkO)F2qGj*4u(_I9cyW4FB&o(* ztHrAiC!e^3~(Q)rG+ zk?Isr{T?B@xw*2jURfOpuf=;sLYVn!7+DuYXk^8+rx$uqfr(~vco3E>Vm^+nWA^Z9s2Ds$LcS2RZc#YXQ?y7{Dkk(Um><|UT1L&T6Fo^G zpxc;TQ(6uu$IxgHkY9rpiKQizC-RO%ZS9v)DfpxQ4kV&3cy|%{5&Z<$ z;wIa3H$0=5zw<@IY_>39o3=3z_!ZrNtPoLIG+@?xspes=zyZd32;+*|Gj5@*oM;;( zthCb!5!blDIk>4Dc^_?Q%B#;DI1cH4#?{wB6&xU;-{@4gOQrBnkuhK|rRMe{+Xw8s zj>T>rO71+h)gl{e#$WE)U^9&xC`K)gjH$Ri%DK6+;u%R1GyP0pc90Z$w-;cTpFA45LkYB!XcX86dK3^=l&m8OeIcs+ z?z4@ye{=7>Ra?MFE94j%g({UfCX@hLDqdG{e#k1w9@X`AFrs(CMZ`nj-y@_Bq+VzL`MX%kKZoX^MxO%HkaWJ!dj! z-v#?5mxR{VBI1qS>UxDz-8Oramg^BXHfpgwqP@nMdspuYyFk|#C>?sjv)4e?Ct8EL zHUR+@6lJAU`ob?!)0`bf-h;U&BX!AFL`pvI7>w1k-)ndys%HF6T%Jv}Zq6XSJLqq? z-yErL_^Y_EJm~kusVX@1ySLIhUo_W)SESVX8{tumwMS7`pF(>N^$$@n;kMA&_qaSi z%1s?!dgpcq+xeS9vvFigs+Hoc?w~e{y~KzweN67Ey4A#!p)v}dKaB?F@UT(*3z+z018Gi3XIQenCIOohj`4<6>xXWjE$ofy=44}%K)gK?*{wmF zF8-wweIv|b-%BYZXKx4&HbOH}MaM#sV9_=z!5dyJ8}80}wp~r@F^l%10}E~~VJrT) zF4piEQe?qqhg~ZmI!?g+vwvet1QzR84metM0SiPUCg`=vT)?kxEXc6(qFXiKMgiAc zdwT^k=bE;s|4zK$busbi*$W>ctBVs#91*O3FfBi2%g>yGete6g_3>by^(B{DK@>gv zTrPz}CJjD)f(AF~gCNU2MoWYx|3TZvI8?9sxWPxxkNuNQhRwI1o^8m1;F5F4*0D)3AzlQ=sP~XmH+d3q+f9+e zCt+)g79?$(PXk4_PUbgbrM_`rfh@9|D9i7ltOYZn%t{EZ za9-_GLC|NGW_apzi|UP6j9J>*3UP7K^#1F+^qX@4znSwmEa4$gLmEUWa9Vg@^wj1A zt03O1Mu%;FKjB=~V!#GH)o3n3(>fUf|9fa7uZVMJvU5Z9Ao?G%u|6HXVvLjxK~(&E zUIb#+QS20`!KVg2{2KGZ`K1iz;EX>TDQg2UPceHN^#cb(2}>k-w%U>N=VC4EG=Cmn z_%JXlrh%$<#ZBs@lE_Nsh59Dzk@IX?clU0g5IKb#!|1^{2kzv59Amy2Fq+QNNw6$D zU_tYPTBg03aUs*W!q8TyRa^B+2^V+`#&0^6+jgp-RVkCwsihvDGr?ifap-n3r6 zHSD1Wdg0%QRgF$7J6#Zn%DV0mB&>xf$opK!F7d=UCiCujF{|2qvFCr@2?OQ>%j!=7tFSaq@>I>lG2F}~C#W>hVFA%%=y)y;NaWQ*t(msR71Kz48g zpoOo>=xIWV&Z0xuK~Nt@5I~TOI&DD!wekW2Z<&UOM4$J)bCDsrf~$nSf+0;;bMCpX z@___QCg=jhetbfC&D0mqJ%5z&Vde;Wh7{iIB+<*aSuv`zo>PYZIH@rprREy?expOT z@$X1cVIbwEkuA#rZYwiagH?GP7w7L2*O6D(vwfek54x}a5p|d&6Rf(b>LO_h%bJrT z;EA%!wViGFO_=!Cm`u-ZhnQ!)N)R~;%vi1Fr&!vW^(Su6Y;mr>zgYdEvO+u=1QJZ~ zn~Hh<2StzMh(>y;w~jgkcWAG3e|5e3N89Hkv=$2I_6^0j63-{ zL3-_igRGN{k}*LpcKbM^Wd#&POWI|d!m~3!v){QftdQdhXF1nMvx(hUvWL@l2$__RclC$bI?K$^%s^t)|4e_X4#lNwlF>%V-slwR*@2ZFy}_ zGL5+u8oSV#VnbMiBx`PL1}>DB`C2#~L#h^akI?B@8NUW}mP0?6_2k>|{$`LANRU6> zG_LZW@3rP#QCOow&Jy`VnhRXWRAg$IGjd~FV@UYX7IUeUW#6$(bN-`1Am#!qQS-1# zzjayACTbMsv!osG*E3RMCTO<@Wy=p0*^d~LS0eB!<($2ZUNu(6*07Vz;YI?RSDF=o za%9nAaGOEMru5L}t9u91@!2x@2s4hKHbXI|V0)z*tO^F0PBO{$kAYnuCYddcO6%5G zv>MrN-3H#4-s^&c`s}VvwszXUgv9Wf9kw<*JBbods0@==f+dwEMEIrZvmXWabLB*f zF5WQ=T4pyWv+m=oEE}S>_|uG2ByCvt71mlhT5h;hC!5KbtE=@>?p*_J!Znd4Bl;Jq zN%R$9vXq|pjU}1zg)DklD@i3-HAuCNzFJbMGmqi53cr2LmlD#Ly$Y|Wtxe|PMIigpVYT4bA}s;g8ZzN{zvF7eG6$r&+U*9p0$IXKfA>76m3 zhseDrxSC9uj6t1ZC|X$`#W%7fnI`IcSxcqmB+|f2gEQ5;RyzV=h+)=@-vzejQ0o93 zVKPl^dP$Q!OQkJsJz&!~ae7d#KgLK>1f_K5;(HV9cf7|L_4~jFrib04z1H8KlNILE z!%Tg2G9jIibV>8@>U2fp^<+RaOf30n{<^}GgJLb)JM;c(<_~tx{A3HPN5~KDat_#{ zRPkO&A(>}zo!Zm)BN^EBAwNUE)wagT`JfWH;qX`YXorq>B z7tmyDAa1KWRERb(zoRq)7su`UrXGv*bq(bPg^tO~x{97nGn*)(7 z6#AXZ&j_SU)#)yHTqI0nLOm&)aR`ue%pcdppXEM^;@7NWFu63d@LVMoKw_3xd+3WQ zhT4^r^3yNxj-kujRg`4WwKozC_cHU8!ssp|Y=yIO*9qj%$6w$oW-sq^8UIPKJmj|% z8(|)lu^LM!|JR@3@iU~feFUy-?yNBH7DW^yV_NOqSae=cq(qjvrL#-IXE+$7zHpte zw66jNf-_6`^bvQgpLdpc$o>n?b~YWsu4HC%oN)cPbN4hIGxJB{L0w*tD93Wi;S+v6 z$xr=BEt6(6_fKm>nZgfknZ6K2%LiWrpA>RppPJm(Cn}2L;Sse6GoW0-TTbXS2_cB) z&S{W5);~esKkL4J*WH{sOdvec({|8)!=msYBm4Xi&Qp7yo3GSc-mPap1wEl1C+6xd zYhJre2stmW7Gb$Dc$C6c-NhImFn9ZOMP7BUZYx~CS9Rw^-fV<0-)WKW^j3rMZ=LZK zy0F_*E^usNv>VWC1%gxgZE)44oNWe!~jueypyG3q|lNle3G7C`~io#1?}#{ zPd2ICVLsK|6D&G4OKEl_Df~Uz$DXv*6R$y`&TUl9?#U4`W`=J#3(PIfk4z?~g z7vXvRODxpQETl&JDpY)x`d~F_$hqNq4MER~zkKs7td4yaR{hDhNajjr_E7Zg(nZyMI@jVhQQLE6IXUMG887()aM$fcF%yN}}9EkkMldA9i*Qr86c6PZl6N zVgD6tvg!@%c8x@Z4kZ9$6?ZOUgHB|=(C4)uM+b=_Q^e1gnbU?=CU)tly*fQ>{yZnr zJZJY}fy>CAjV5VnnSyPBJ!CheZ4cvoIRd7O35G3;w$$NJj>2`rHuP&Ze9j5@F1;03 zS_`8W139MY>AMwheK`NgY2UfH&^}f&XXy+xLsbKXg;r+$Ow$F8!1e;}6AK#Y?E?Sy zB`EHBgH#4i4b{OTeU;*XH3gmk5s)x}aat8Y6Mu=wIJH&@aGVH)KlQ_^9mH{I3ThFK zNKtT~I&v7HLOQPap;LGCY|m8>T23+$!zwX5w}k^87|VP+&Mx{*s+-Kfl0To(XxS(a z$O7Qvi5t*NIX+^NbwResGb1}!AOS*=pi74DT>m*aJLqw%-CTaE2KePRUDtX&>8=%P zq6V=dpF#^z8Fw?RV-+dQkkc~7`$?Ub4#0tjTz$Rmk9nP9|-Nv2-O)@4SXjEnQ74PlkiRZaiA zRLtjtmW49dO%zP%4@%w3MyNP|2}+IX!SIuHn0mr{OUOf@l9^+a3P$Mnf~HpFmg%-r zHZ7CWF~B2&3g9IKL-Jj^lyQnaO}LM#HfAA8*mDD+4uQ@29#Jgkwe0rfI{Ag$4X}sgi|p^9jHo&E5a@d%02lE&8wmM|o~;f>wU^oR>=L z!}ctd1R&cLuAExVW#lbv6tY*RxrM%*p7MM=Uk|&^N-2u(1+&B>KgQZdl2_)Lt)J5- zW9+&}D#|2>)e z-{@#${VzTJe`@#aY%Hw*J(kkzD_~T+syjN2W`DKtr^t!FHzx1BTVpZFBR=v=}TUx6Hf^yIzfj&}=}y z_d5ImO3$?4AEoEdHQe9xD_4DA_wyE#=ok^KU4dNi*0KKfT9b-2k2IOfFBP{wIUl~7 zb1ora45GdNAarp%fKw=vZ;+7!-m? zvGm>OXXL#?qbqJ=rhHxeHE+fb?HX9-j6hd{IR-k~{ga9^#_?6SpUYkPCEK|Tu)hgiS})bPdDe~~wll%5OsCy+qEbi}eeR5^mU4Mw69 zP=p5oN<(6(*4k;|7tBmS7_!ARrQ?z6(7|Q2A$3Rw)8VVP?1^5pmPO>K!_K66AQljT z48^+g&R?SSfV-h*5Ji*18fh$PQqc3L zYNS72&MA$hryXS7F|A-ss@+#UkdXaVYziS$P2C^~ABG+Xu%n)KO zs5}^OgoaH_P3X2jf0GkHl<|gEuKA-Ep-0m}YZwix6A=naDTnP@ROW|?h;&u1JQRq8 z)@o`#@yY*@s0>e6o?J+CLn*hu8ii z+jKqhDtMcizo%>c_jIQ&%Kn~i9PQ%1Xq71;Hf*3%F;6yd{-Cb%{NzlpKc#H8D@!)2wldi>XL;oT$B^^W}c z!c!mr>meZK?r^`c0{NI%2m}95>X**-JtA*vmuVn>!Pt9;uu*i8WPi!JaSKDVmJHPD zXrYwx(7t_+E4)Gw$t8)0XgsgYC^nT@dN4=Ox#iIeAz zy`}CeV_y3xw}75%UmcFV$Z41(zo=>Q6SGNj*&@H}uUkaG(t3p`I^(&dD#6o?aKv2s z8Lf?Eh4~JuffYi489!(j90&M5Yx8GZg7u_ogk1U|T`+uqsP23kH%<(H2O54k)m z)uaz!g(V-)JFunAaU7BQPGf9mEsK1dG`qBtlkzu$Yz|$ zuU4I=)u3!vmc!vO5Ssx;=>cQy{-T++gxI~?Z$uPXO)vd}#uJ^{f!*B`btgi=n0(Ec z%j4r2cMo4r*IsQV=6YtYgvpx>bWjPFH%LWcwFPm8Ff%0o8&JDo3f%nwZ+qvytX+eC zNQIZsHoO7B3u=N^V?AVB8)e1$i@PSlNK5iSpDJ~|Ey68u-lM(&*T3%fnYGK0M!^O_ z?P4?dpK1%}ljZcySC?|$Ugnqb6(H;|*|u@TDkk3E&H`VlxpPAPyxI9*^x66KnFRWo z2}=(Iznf7*x~I5~iE53Z9jZS-XB?Sx$3QP=+=vb^z{%IGL~d@a{V#mp?=j5;Vbe8 zoRH>Jg5i4oervQdPS6!PnGf5FZ{K|i6T^t=s9%}9J<(Ezd=XYLQeHdHWg|CJ!x-OzSG*+@axD-&wRepvYAHCJF|arvb+0f zD3GZ?`I$$tj9z;jI&O1LyW}&L^vx zzDx?Ij}Z`M#`%!VF^UFxZ<{z6RQsmZsvW%8o0)1XYyQfVv|g~a#0LobGp3HzYu9WL zAbCk3Sq8gf%>P?$3xDI@QIFt4q>k50A>PBj}X$7rJ~f`^oDz zE8~k}WQn(4#tkKB^ZS&d`gUa8hGq>R5em&q0*Oat?sJk%hqXQv0Ca5*iwM+SZ=h-Z zJzVhuUabkTv8aF0UK)#^?lC?IgBqvZp9z!hjIqx1^C%xd#Tgt1*GlYM?&VO{Y8u2s zn{V=jkb|lAd7}&J?V0%d2;T$?%4#P`j%?t5f4f7psj}?<9jyCVgAp^J zO3Zzl9NJ2M$p8ABr=Dp7LMDZ@U1@2K*CZ4Zl3swcZEC2Rtpw|eNx<-n9(k4yVAxWC zgPe|eD)xf#fjH`-Ikn}lac#72?qLk-|Mb(fedM%+I`)sS>L5~}$h1;1!YNdnx))wA zK9ex-uZ9Ra_Er=qx?kdKfVILEDGa%@1N=6(VpNKFEfX{myD9E`ef`{(RE_|vmv z=lVTVGT+!2Tm|W%_VMG{&%1ZL?o=!0$r(}X5y{X=fMC?)YUv!ed)BOh_W{u!q}kzu zVov&#elsPpnU*3wTUMewIw2)+@P1d|B&Gdlecy}uaTu*k5yaSSH;p_Emq+b2pd0}nL}_^bDj9|`QeRZfqRx>7KB2Yc~+_d0oQlxxzZ?cRY6ip{eSqA`M3gjMUEYp zb_f^Te-nc`bI+L(IRCX`EDI0PjFtBeo}h5g{|!8E2@q!C@iWa@$mFXr?NY5(&A~Wt z38!Sww;(mk^nF6_C<`6X_l9a<2+Q28X`SF!fT&;oFhCXyj;H=5=Z6=5h+=R11batO zSGCF=kIwcXJ_-vLQhcbLG^=XAR*XoDP+7G`Ulme{Bh5}+k`E>G(#St zBYr~jy#@Asp}kWpLD53oljB9*6ig>lk%ESd4E_oN$+6GmOgGF~nCFjCgL|vLTMQQt z4VsK~?pra01qO*=j4m!M9Q}Q_g%=M&hACIN(Qk&L4QYIZGHX}u{lchC$ys-J zadss$&6#CcoO5V+&LK2^r-jt`Lo zE)G^9Nw}MfEG;Ylz60T=NJ$$CFx-Y4Y`~tBt)dm-Vl_AfjY zobWau3o9V0GdFLGj<{M3XJ&8VjOezFI*K*U=A!y?$(mIOmOWNXro8MrLt_U`5s{dXE6uzCCwQ)#lNl4UUlh zQ1=|{>mCsyrhJ9Q!`v>(?+cDgW7uww{zMIb!FsAp63y7Br#Ae+4rrAD2#T-r=ahvVe@$*QmQDoVB8mAK+ zJ992Ssh40pW`r!T>p84uE1pEZgMcnlvI-NWZdId$?8%5Y>iO!$kN*mh?5DqhtQ6Rn zkuU&uk1amF%LQ8eHt!wry)H6P;`PD^*wu@VdYkuCpa+EY#7Q2_rH)HoDO3@_&$9&I zzduMw6mlC=xBlQ}2CfP)$K?h(izI@i$G|Msy9oFe&P;J}y*%AIINskH^~@THDb`1( z#;E!vaW-6l8(?uMfbN;Er$abRL=~RQSJ`d&eNz`eog> zZQIuD*|u%>Y}>YN+qUhVZQHgv+qQ4Nd+&AQJ$J8t);%ZUoY>zgDyqgmMpZ;+j?7;^ zPu+CHVhWCcQ^3s8DbuTPJ^dH95Ojm0QTjwoP!?Sis%n}c2 zInSYQYkM6sxX;^aQAPLO!_Vv9Hh}X&%$Y;$HB>SLRdf$mv3hQRr+>2`;N0b@F#PBf zV6GRmUJB7bXU*4 z@N@2J-01hGL^%C1mjOkhSWy*DaJk>(M{QNI#w`I|d;Rc(0-#=fSr-7|$W9*0dR`_l z$W@#DcJm}u$6{`^suDG3IWA238Jg)HiuF1;zgOTfXmDyY9*b;R5mQ2972W!thTgI#ZMF-(C*&HJ=G4@Ikj8>aLa zZ;GP{>Q47ZNgc?Wd?o5_U1{%2)8Kr3`bLo}0bxjhrQs<`OX-FnN1HvB;zsO~k?3jp zOTbh>@DEs0itE0r4vfIHRPBQ2u}Pjli#5N>ayTrb57dP+dM86u@pVrX#ZA@myVgD1 z3Amv{*2#`tfElse)t&c)wgA^BO46T|&Ij*#TJXF*`5FQiZ6Om6z}7zp?KP6*EY5&2 z`kO4^GcNG5mCyE#)Fv8X4kj?ANlbo3k}M=R0hV0V^Sjn_IJPuZa@P*1pPR%J(U@qu zkWg(WQ2nNgh5Ln$+xYgUwmqbyAFp(EY(;GNXa3=zH5;^?{F0%=NhJJ{O(Vn!u!1s z*@Idgey>NYnN>9znXo~97e(f>_tbrKoEIZGL9;I(dlk`9KQx za$6Af4PeR~0f$|;6}~&rR}^MZ+;si3<&Qc5nMS`Tp3b4xH9TTlHtZl40C(kzI~hPr zurg$4dkxPoSV@X|r-%W|CR-}Eb4AiAqL%Jzq4B<5=@)`m?k)>H4|`HuXH;ht?XCzD zs($pkksVy25D{Bx8JfduRUgk2)Kv(P(3BjWOqAVJ&;X)+xG0U(B25p^)>P&q6sOTGira{(3w5@^%wq?>?ITV2St9|?`^07ZQ zTVAhCPCzc9=Mb=`Ox-W84(%h`8yj8P@2TA%C(6B__@7F^A3l$tut&POFaNnzW%wH` z|IbU+f2#%m8<(nogD?M4sxq>&{Lf3(-)dS8>rLOKYE9347Ri1D!aKmI;p@&ocvkd9 z3-kU)T3dgfu)6-wxNtGG$&UvuPozSU1oMPZwx#%$fPlf?OMy@G&IoGkAiQ3^(7lQD zfhF1{mGPk_>}OL8_G1&*uMpvH5wVZQ_9%vNX!#v*%lEn4P5{m|Z3@o&+6%uEC!SMz zhqDMJb&xurvoug1MBzkNJ#a;Z60=twf@T&0*_dwym#5sTmpZ-LC-!kYx zf%9iNVn{2TpfT-6XWz6k5oqXKod+%u|9xk~)QjMi2pAzF7rqS$PCVZcx4^OzFSPvT zSb~A-Iyf`R7`)s+I~Wk!0D45!flY&Z54OZ;TIhg!^E4n0iyh{kAtBxr26?~~0kiPO z+OePda2FMrze@1qrf8@*K-oUMLMZFK`2bWQ3=`nkbsl; zt4+_{Bg2O(;F99(qG!YRrcv>r>r1CGSvlmAS{g!$Wln|~?Jf4?f1l!DYBQP3!AURg z2AzMX;2#irNVTl@Lt+iu2zgIGXO(X0y>fVzD`;VwfU394b-IDliN4Ux%HF%!=cTWFXW4S5?SJJi2D%8Lon0X zA)2_H5;Rb~a#p4R{!-1v-d){HCSs}GEZbX4?|0B_y5i(aiSO2Hi%Q5&BCR%8zWj(c zwT1#xv3yVMAk3UxV$ly*di0MlJ&Hc2a9e^GFqR!5Bx$Vh8h3I?x)Qi%IIXxxCM_|K zt_lqB#3~sEv|wW@DRC*+AH*oV3dRG!;%~!k3k?Wh2Gu(gxV{fD2w^!UGgk{RdJF$8 zTPL}Q^B-;Mnx#M? zB~ApUFtFtt!+|ZA%U>5yM_k*MHLYY+L<7UO{#Y?C1b9Q8ohhB?nn$=bw^ZXR&R z(2y@5-3Z&Wyx6|JFeJ|qV{+Jf9>euV#2lf2h3Z3#YWVceuin6@*5BFg*wwgZ7lbrU zGzl+F%r;WuN30rWu?Q>W=ZnN-I5AEyQ;eUTw7HHjDkef?=dL$sP?2+S!AE&Yt+{36 z%Mzs_{)R7C4j<;wQI>TJo*k~YzGdR%Up3ZBWE^UlDDhlz%yQTw&(v*Grw%Vu72~d9 ziGW$ec72TM#%(o0G>uP99LUzv@@kXe*&Hx`i(X^Tky9>Gmud<$jo#@Becxql`*SC4NPNI5qOH`Kum&j$~HKp2~Oa+4VS#tg;~UobP66PbN@CL zJSZqN*MlV=dsqu$IN-Axn5fw>xjLT7L*kT7D+AlX)TC@$xE@{9IGktfQ>zHCBG{ar zq1O^xEba%V?TPWMW5VI+Omr*FqbIVeQBep^)zYFuT-gB>!weC}r6N1XWyT+zwt z+w6goqt19{k?pP!aVD0akk|z&^hDl6qy9iGK^AKSkh)dnJ+lvEv6`;w%YL#Sy)Qv&$ci!Y)8yfPPgO;6OKwciLfxCG&?`ga4_gDI0Q=P1fv|WHgbhgUg6=1h< zLfRoTP*X(+xjRjq7o4MK%Z=A9t*e;XTt&V;z}a7MtwyB;y<~#Rrq7qOPap9-(vphG z8eR~)2u1U}4$hRUxzvsRARQEAys{!=L2Q8`wTFZXqIW7pvB=Sx6VcTO(c@jrda)Vl zzo{mlclauLs#U1J(I($Tyh~G7fa_> z%MbXaKLJG~16?*mbjw886gYG?3#;Wae-1)CcPKn!ZL&pMl=6DAv3qfwzchkC?Nz|p z`)cu8R>x6pT4hXL#9sL6?*&^bA%$f>B~mItGZQ(s4dt#Xs7yFY@3g6by^79f-LsY} z$|uZO!p*AHVIX^gBEhtx=udjr2L(Z6TzkJu?^Vy=W~n_Qcq&W70&NU`*gZ3_A`#wr zB+t_(2z6Lr$c~yL9FurZlcH^#?ndf&eQU<``N9?pCls8wl;MZk|QwBy}C{eL32@BV5^+mzVwjfWw z6N^<`h1GPH4|q9lDT@3UO%}dOa{MfWn^kW$?5KYjw z__|(7?YA|L|0DBh7z&&QK?vI9S24geBO5`%I#^qlJd9Nh`9&u2W;cd-0AB{#!y9(X zJJ0zJxP(IGFk$2N{zRUV<^i#BaE4t5Ke-cdM}&Ly>-OpU{8C^`cKpa^O{H!txyS5! zi&t}Z*4R3*opUw3UJn4qctfN3Y|$|SPYuIk(Dr0o`X9_jYu@U?k7h~3&+c!8xN2^7 z>Yr4Te_JW}FRICZ7rpxLg%C6RjePz`4av&zFQ}7A_3w>QHl)u>o!%I$StH?a_i;e* zmZ;`s!T92^_0IMS0XZwOn{2Dr`glvbman-ScSg?yQ_kc}M?b+>RReoG9-OIIM#U~T z?HF)CanJ%YiJ|#kQ?6&aXATHc1Tw@{eA`~ynHNsVWn}0pWmDG6o8noO*vY;1CXW?=d=i0@Z+(vNDx>dP*5jqh%?%* zuhN~l zfy&t$m?2__QZCyFS~i-Tjz>-7O`i7s8mw7rjBm(fZ;BFtz4%s@Oho=BOi_R(h`=Iz zy7Uk~ki>zo7=B8D*@*;ML@1;eDpw!^Aaa<~!XOvhs(Qrv)w5^IF*->OSd02B;^lZ-~Cv0faqtd7SVLoJg_2)%?9 zM+)sMbuNI_E5DSlSNyxu*EgC8BSJWt38KsvOwOO!Y7IuVXwi7(&jcex4jGtR@-J(H zSQE&o^Y6ZMJWIZ@absmJ0<{GSBX)ou!psoV^EulY+VBs90pepj8HIF~;6Fbyb6LRT zcUZupcGxUtujka2Hb4mK8OlY( zv7*K@S09Ihnw^!&?T+Hl?rRH~LXfa+l+M`AYvhW?vjTuG2zG{nwox0VmrlbKgpU4= z2FqAvn1h;447=HS2!mgy!9~qBRXiEXM;enOs+I~|juse+o+7w(>tNZnZ|`&*;y&1_LK+{E;q9kGjMpQrj3+T82selR`)mdvM{E zIYJjW0yiIt%4+?OX%Xbj_bv1%)(_RFrBVP}Fpc-bSiuJBSW#xhR7h%zYO%Jigqf{(-J!(H-|& z5vY~&XFbJF5_$B7mvm=%a3#L-koH&|8xvG13ws5sn#0!-iZ94jhC-HsPl2h5Mk)D{C>qE zRMuzqfOwog{@mFlcDOE9{RCo@VOoD+`eI0VajF~hlZu;0{r#>i|MqTKq<*ONF|V@= zKWP2T{v%}^hf9|ug?4mxI05F%!E5x!bq5&p9%ez4o4lx~Ae?y!5)E3XgLD=Tju zG9N~>p#)jzhmEH06^HEDpgG(bmlve`k9I%1BZV1ws*u|Z=1pxr%9?7r^DD#Zx6)&s zv9n)SGMj?^ZbbpPHxJ?uC7?>$d^DixLZ?TAxxGwr+h>5Aqioc z`_5mT(oPD0QPx5l@G>E1tL}{EgT>mpP}#{_gV*=Vyxs*zS3a0pj+eba(Za<6xxZ^* zrnjra0r84bG;qJkrj88hU5bWz`J>)Xz*-zY&L%K3GEj0TPc#J&IqAdlcw}aEbc^UB zQRu{1p4vg6U(unzQSlgNo2qvN(w67Fd>$n}ysRAaM&KEvMZ>>VUB#L%2n6JiS9Glm zOxx$W0<1E8N%Ok2L+e5nojc!!Y)i-*m{VPuX>}zDo)}k1VMy)>n#s#A*>G?yw<~V7 zmDxc|S|^t4Ki|*q?t*cnfWXrFc=+(Z$4=Y%C+E?wx6DFp9YyT0>xoBeo&5s|40xwx zU^jxZ$nH*Oo!4N^vzvT9R?Ga(YZV|4El%y8x29`tDThX57%hRD^;XWv*>52?j5>aZgw^5i|wazGW zGi4#2)e{CU+Q@V^SY&c)b%OFtrT2R-C}D3NsX(6UTO)6gn31`}U)#l?fgR{Zx@qq2 zZiIQb+@2oK9UWON+vDX9jqz}}CtCS z#YHx`gspOcrIAT6NY;hm4tnEJXo=WJMD*^N3L5FQ;D-0#9pCA@J)dgiy}4f9o^J}9 z=lO0i-AqF`q9|1~UfZGpM3NWv0vC!*4H=O;OnvhM6HkG3OPrilG50to*XXw2ULnur zriwxFQs1pB6}2qF42@b1)F?3QTD1`j}@l1O;aB+93Jm!FPL&4cd28lPosSg#i)B>Up zzZuK zS<{c~_E0aebB4r;tME|82}i*;+k>more(sAS+;?FUQ|EjO>GPB*}gtUN!iM%?<^ll zhirE8I31vWs&Ii@q-pe%TFJqR=Li`hb<{F_{j6R&?p3#SoFeAQf0O2|Ur!k&9DMhb z7mgxh){1~2V8Ade8~KVhjE)=iPcZ-1s8J^|j5`S=&;mp*d>`zZ(J9LCpXF6c}BPx;XvLT5@x%t&ycpDoGe z222Wtj?emF9!`zeJCp7E@0+XS6mc;g>3IF=7uoL1QUWWU2_bGcUw2eK+#NULg6F`%KHO|<+GM3XF6{TSRXesN{b3c z#16nnj}f89Y!Ah(4U+S7B3?A@2Q-2_#^Af4Lyt7iW)OwTPeDvMC@Rk8htd?RQw-5h zvb9AZ-T#dA2@{L-j`)1#6j2(mPrQ+u><(iax81uKT4nF22TqXgdR1FLjwy|T_~r8^ z4Z=etjEVe1#*Dxm-*pi`o{bcwM03!4ee?XS zm*|2+Sc*v*wWnsnvpI?>{ih;8_2`02nhcTy!0cSYiCIEUBNbvM-6E0o>)4S~71~3Y zahjN6(;w`El^s{cPzLlJD11b%x;RZa_tHT4k$WH;D5reW2H74a6m{cTNF#UCqRd(& zQy3fbO@iYKv(usobBSpS;AW(Q+zU2@JXUpce<#(!dj@B1#pP23Yj%XQi7DQ;$AS% zw%=}TEw%jFNbSMoXiEF01^#DKxv62IEL7=CZbGJ2VEIWzYmB=Iir!d}1k(K-@?rx_ znJdf!YL%REQ@_1a zmXM1kW@+TciOn*J33|DA7}t>z9pm;i{Q3Ev#Lrqx5T7J(3>-DIbAy>wF25bC#{??w zFttH$*e_ljDce}3$4pvanDr>)a8IF*i~EO6@=?T-$zc28^p(t34z-MqA`42JcQTJM z4`-`uzPA(L(q5Wyf6JDQ-+8}O)xZzq>tOL}a55#Z!&zs+PUZFAIJt_(`I*MA^-K~M zhZp>h0hc(-_SIUYrx;$7-l>N^$ln(_=RW-xY1i&Bmc7Ea!WB?h$UTpu}{sHYtMUa*28lrqf5d zhIL3s)D}PwYsBLUI^>ymlSWp0PenVHS|$qX4K>~x#%$UnA?L7$g_=gpgWWr`QL z?rPi(DM;yMcN{Yg*mwQHb(-&LrCu-j@%mv9hyLj=(Sq^N4VebUlGj`+qIs=H z_W@KDU-k{VX64=_l)o#wHaY@t>I<)a97mX;xmNvC{HIh0NS;czThDu4uo`!N;KbRCc zuAzks2~*b(Pkr!GW_crDJ~;nLYWUmQ&3~i@hJP2&{D1Y&8U9@l{l8h`=5L_gKQaO{ z^S_e%QeC%R7eV;u)Fu@4O2&epBqPw|ELWu~R^Wt6DDr)CN0SBu(StNcog>~oOh!qi zCCW!gC=ejpsMtN6o&QX%=JANrYKenssDxStU`rsYxD$KD8xmP013tw=b?<+`#}oBi zoNRhv3WzuNGEiCPhy`0C{>B`BSXm0I+?Tt0x2#m2%lSq5qetiES08&cWRw2rfNLMh zKG-)3z?Lpd1t&MT(mgk!CJsHiU@M$vT9lKn{-PGW?_QaX7WaZ-wcd@*8BL6geah{108UX`f&+1_}LEz8}_R>6))hM+ZyY5@0DBu z^9EFE_U3WowPk1bFV-)1o?$|r-J{ZS=P|(3mhIH7yHD*FQY^xscce2W{S#qA=d5-0 z+XH$OZ1#$RV1r2A+8(QqXzXUK0sX_b$uGPQ@Je6(1?ZW*2U$|EcLy0c9VKy6*1N}z zI960n$YX{M#ylYOS+FkHwpZ`W zS*faBR|%7@d@|f>XP%iqp#GDj&&A8`l3+(>5;%#DC_0CX^M>lH9o=04@3~}u||5sC{Dn<`?Kt3 zbU1Mmc69d69+Y^qZK5=um(&)Y!0y-L#V8S-D%3~+C?LcOOMDcpDBsy?`*lR^@%hsm zA)EY@8m{6a5wT6xmT=>jd~)rGz1RtZ0pb?iTZ%FY|Fk{NYbLs3s7PrvF$9Edio%xx zFSX)264N`CW%qBR#BZg|hJI}gtD5jm0-A8G2KmG1@U4`z8#PDtK}3&05@^mlC@5c!xXz z13p4`rBaxd^uX`B79iLa2xto?nW_(i-X-)k!AeiLRMYyZ%lA~ab-z0HQ-?q{hK!o} zyskeYbrlq?hHiqGJSCE{9`)%wB8KH~RN5~@XKqG^Pl%X=2G;bra<%j?h)T(>uG9ep z_UoA|IBH)`>;NYD5ogvQJk1rC;jj<|m9Ggkt+@ryLpF$tXTi#TpS%t|Wap|Ay!FbV zr14&tF@)qRMm%|`mxU^<$nd@HL@6<6=MMden)Of%R-1Dp=>%L^VA`4A;kZZf zp<3T0!Z$d6awmup;?{xBCYb!vO--GHjfA^Rfu|D;8D8y8{e_Bb)EHr#_yul0!#~#u zIC9f@yTOGCUx^5+v|v8{7LFu;gQ;=ix<(VX>iF)wCw;Th#ql=I>BEe@ze%fG_3P=m zVbVQIuVMnePpMIpFaU^z8p+(V}WMCzd8ZG1!Ux4)@cd|EN3e6SNcISJi(`g^Yhg zpZ}{=_}@|WlJRdK&p%Qj0~6E#oP*g^wfYv8{!7hkMZB9N``*(9$0pm`4%K9DAq-bd zdd-XjCb*wSm;ku`)Mr0ujT-@@HfUxcYjgoGO3m6P$HXPaBhIEV#{>&hgHC^)4!SWR z?NPjamLjjss7HPO8gIDUEV2*$B8K+|NP6veEfzdM|fN;fJkLvpx+oU^}gk5l%6c?*eP0`*#_Bd zrwa4(guF3fGq1&!zaG_1Di(5gi4nv0NI4hhKM0{x;E0@2;C{arZL#j?sQTlY+%~sc?s2BeJJtD9gGQ;Olvtk*feN*pbqT1WnRvsirz%`maMnk^j2H|U;B%1kJ*8qbq&#Lpc z-IfiZuzKh7x8Es(j#-5xkkyxCsl(_cwb|n!#R+%gkQ6bRLvyq>~gmPiO6@3NiXp|FmAbu9ZH%^K@U(=aFzCk<)#h= znhHraC8Bb~DxKnVIWj(q)b?s9^7dZ5nQ3%5PG@F_QuQ;`l6ynX2-@v~w(gPa14CIWpxGA#E5!XADsPxbvo1^}-LumBCv+57uQd`fY`qJ`q=d~{y zBeO@1IoOM)M^J|r!qB#H_q8J>f0h*?0J5)2gcbcrN2d7leDnU`cJpNw`-!n3_w|SD zgk+KCM0^>hVT+PyTS|ocHZ1{Uf?nP(bMchnZ-k}d>lK`iOAg4hdbx5sW zCHp3FIx+{^T4N~2Ncvr8-ixYfKf#jRlD>^8J(~JXkrl++2KE{bbXE0}An3NrZb!-W z)ph&y*V%Yp`j_|{_|G4E3I8Op{|yxUF9Q3&#nAsdsN?_tT^z>0&D8%9*jd^B#V*dp zUoKB9e?8;u&`%XY0B$9m1nB?7ZSERWo*!Mng{2liQjky-8>?PF={`_shXz6rAB|t5 zV01e+#Bu1|3<%f^06msn%J4Hvm@#6486~KD1wPAq7_Be60Ks#sWqU!~@@Y(!o~qLE zX%N?MC4}q%_%KO60!zf^oOeF{wGKLO#f?={_7K6`jM3{eIN+Z;LLN6PFxH7$ibq$v zT{jaEi`h4t`Vglyvw)=$C#V^s5JODK1rS=#XvK+OQUKdEX|f-}#sVAm3D~!;hxu^L zUBFL}M?o@|>igJ%y6vWuAtsde^B03+@6V7`maj`7CC`LQ%P4E?FUVN5qfHD898OHL zFuzrpvm^WJp4Ny5CFf$RVV57G8ZRzZ`!R=t!mLW`u|}e`THG!pdhS`JO0Gs3Qg*|| zT?#4rFP85tXJ*irSyJSdqzW18vSeL%T`cUrYxSWW?Px&HEICoz#@tqZ zRS9Mu58m>l3&l$bVOJeB(nD!1DuwCpzu+3IzU``59u{)9i`R#IfC>lQSckBNWkgs` z!i2kkY90zK3&{VJT9(y;4Lu7zfz98<}$$WepF6F+;=|9jwTURan-rgTs7a zKAb5=oM&7J&eO~YPllPBMw+IB!#y?ayT%a)lf??IcP|msm5b0xs6TUGFbS?dYh#+p zoUL_IPRwKf*+5pD-$;naY_|L`t0M}U=msW_mHyki#C4<;Z8)wC7We&IgYeKhXv$}2 zazIUJwR{YxCZ%mG6LbMuNjfpFqH>}wo>BrENnQnWQcNXH5dY38De3#|ZA|qzS#_KY zB_7i|PF0CrgZ)Dd(?UGV$h@LGicrjIxLO2NUd)L~6Hp=Tmh8eB8b56I(;eIXuF!(6qy*6?UG97A!@_I*agIaC6D2Lw=* zpo|nP<{Ih5_fbCkd-*k`goMkVt)GMd&)d~4h9A~sYiOr2Tg&$H`?xGcbqQE&g7O`J zugXmNN4JpP)H|+phiwLYtYwa^A+B$ZEkRa%YMYy^YKpC-TIyJ`r)_=o&&@c)#*vV) z6Obgd!vvDk`5x*WKRHud{LoNQ3Mz#%JA6kvPz;->e%h0d*vIuaONen{9SQ@PkKwtD z4>;@wIz_2Qjn%b9dHI@0H83p47jc&N?ec)Gn&l?gr_(kFAyNC0qAZmbxi~QgriIwJ zvwATEKMWZH4$6v-Q_-X&v!5aNe!yJ;SA>ljx~7EXr4C=8J+5BNUgEI1()X>%^Wc{x z7!k5+Hg8t4!oWYKnzNXg9F&V)?a%H{oovh$5Na@wh@@ZDLMF=T{-QyTz`2iERn=3N z8?QH3pja-ic|6hNIwlaiD%;3{pKnA`gZlg?Vtc9sy!2Qv0IElrtw8W2TGY|}<1OgH z%*xHq$hu=cpin?2(8ED0A#rKw9NAMu1u}~k3)t~(iyAukA}M7W?3>%7WPq!mHEgT~XO*=Kp%xY-IfH5POvQ!6~K#*YrbqWSIN$#bbRIyrN? zEo~yCDd0RAR+yozL&ZBVhQxotRJfNV#ge^bzZ-phxWl&qOg&&#W6D}g3c`c=1 zJonS59;J|f=v^K49!4w?*~HvCZtuXl`Dn4(QlFppy)3uw$geC0&3z)YS#$mTEilou zg|(ZvJr~NKyOwz=S+=P!z`OUH)(s8pd;B{Cm3DPHZd-y{9G0qL z3v;5aI`l+@*(9QaoccoT8GBA2Gkn8RUuGa(JJu}f$lGPhR`)gYLPJCQO1oyk;du7; zb%pvS_gdWbME{xf0AH}`4*X9t|KISg|0?tU-&3~y-!n>Wg#v`qwW@|zg31B$uI{I@3W%3IZ03!o9L=}+we;j0v8+S&4_TPJ zhc(an+cvTkk`#;-d9#M3{IR9I)?xJuO4>#%-eu?DkXe{_c!w>SaWnrr$`W;T%JAQn zg!Kg0GV;%X|QS1@Sn=lh@>U(Rh2QI3M2HL)PII#95^EAJ}1CoUy=j0 z>>eLh*lK!@yuap+@2;==N!N-Zy9L6)Rey`)hBbmpu!99y0(BU9F~*I7oTZ>NeKL`_ z<;DzvIXlBI&Y0<-J?30t(5Nfr*=Rm>sMqO_GkmGK>G5^dTBuISH18x1Yq*i5_*1xu z))%;|5Kh_1K^vA&MCVr(lQg?4ZKA%kX|@;tW~5|a8wh06S*yy&*S5QN0JX8A@7J!# zZnNl@lmJ}6rdotYi8I@F+Oh14XNT0=lAo* z=R;FD7@DasF89|q*U!C!MprxMB~qc}nSo#ma^XxLcCGFxfo`uo@uwv*7S6;9vo~db z<+nahhqQBTt?8xtmrBRqnzDLKX_duB?9^I3+kESrL4~dPW)vhhri7%f6HDee8(lfm zLv(3dlSA|I&ctGM@Ia*LM3^6H_4!2mB0jhyj;DsOd_S{k$D7uoWn^f=ch7pw=%4qW zS6}7@kNMI~OH4)0J$7w|-~mPTM9oBvh6kcwyCj=QTnouKRcJY?@seV>%^z^tK=Bqc zB911geyzx_$*p@ts-CDr$40Wp(i2ttw z>i;=)x&LLGT*kjfS^poQdwSM?p%6T&qV;VEgW|PZ(;};8;R@4Ds<#qQPomM*=)maG zANw6Ve}<{A+fkEh$$baU_eV-(I?^pYft0M|j!_IsO55e1!3lLWq$jy|Zkt zxSmiHc|?lW>^s*$Z@eIped9atxIt46^^plR@|$?qbVI3q+hR$M$v9nG_w41}e1NvS zWc)?+wm)wJoY;Ef7(^Jz#zn(o7zJinpZ2h;i!R)BM6)LZrmaL>4Ntlz@a!K-cUxoB zn=E!E{Io}z03Qu%;kPCAA0$bHSQtPI)9(pAq1;2r@2P|<_KOa)e03D+D@|JxLPH5@ zOI66PU6wwWKyoNmVuC#tZPOMlNna)9bi&p@N?ZTkLil*9tO4_*q6n55F&`}t3d^iw zCQN1099YOQ5cVcyu`T#{9w7ZpWWIbju2z8q($q z8Q)91rSgI6$}7ri%B#u>v_-DRHOLB6$pEGkvmD)7iI|GFC?MK0V<$?=zIv&spxTF$ zBPOf$6XTqzN5bMAnH6OOuN5z)+0RU8<*BV+we5kWq0Y^MNwEX!taVG$l}^YOo8K>I zpYTRh#}i#d66dCl;3*Hyv`CZI!8sKrLNA?d|N5BKPs^WH6_ypq_-B;wHutPGeZ-e4 zfml696&(|i?9+#wyjg}g%x}6i8qy)1*c%4840BVLVAU2kdSB7#x)fRaUV(AyY_!XB z2MzZI&LMjX9?K3T;)84c(FDqSo^Ey*>{(0p7W(_U|2Tyfn9 zoED4l);&IxXhW>hzab}&zXVTvv|eR~ME*H;={)SsuTV;CeEq>&}+>V{89t zLBH}eg0MXIlF{vT*{@(%KiK%E!=a?)$Fuj8q!b_~;5=Xn>HpIJFMw_fradV7^KpETG;pXAcE zp~fk`HeA(f&k)HLk1;GC^eXalXVEj);_H1RDUuhfy0Z%j+xpi6fjU2HZaKvQSx#KPHeaf4 zeuA9XWM*+wKfJ<|=P?y_%@DkAo8?N~9Cxet#pf{MZS%l#X9ivgMKQ()p&@*U@t;#%_98TZrXm6j}hb`nljRSvFF*{L}QKYvU9@T{e<#Q`pHcaYH1$ z=ccq;{L!PLIZc*RSBZ|lDZosqzhtSaxmpOR|HX9rM~1ArUYBII4_}6C@|%`R`?Cfg z2hY`T%aH*sQO5Itrfh)4Cq?TaGAYetmHR@9#)shbsPGFE2>s&(l$42{p;RQnE}v`!%3E!5RO-FxzPR3AYSluzvw*r2PUdmi z)lUCt^UxjVeKT;$N`w}oeu6%2xG<37MyFUZO%gJ7Dv5=>(Ju`%e!_Gr5Bgr3Sv52P zQ-H(v(K_u}9`S_e0OxRc^=*2r?uKu3825^`LYdXj8U(VhUM0HN;1{Y1e36x z+3d5x;ERKo8O5gag(H`2ey+Pe<7CSC@Q_#vAp#j+2dR=R^*ejn&dw-LN?BC2)rWJw z7o}wl8Z0Q@5wWDC$Ty>$xBQlme3rZrOHNLJOtls*#<0|M zPXY9)Y{b&8mK<9O_qpFXAz+$ZXwRLuq!IZzlICp5q_A8V zo}KbaP|KcV)nnlSMWyb;BT#BbwEJs-;;;!KCS6)iO+UE7s2bWx%)Moh=5No@x-^lI*TFLTF9WAQ=ICKQKps5#>nnaKGFiGGf3I;ujUec;n_u zNoB1MEP`8Qeqj$izTxCGjb9H!JY$0F`QQc)AC(*fwWWE9xz{lJLxVi(>v4AZtqL&p z{*cWeose^j3crP091p^%)a`qD7H*1SJ#1v3r8WqJ@(xM&oEj%ZNw-&%ZY$_3j`{%y znMwtMdfVDGFG&MGA4~K>X zS0Kp~v|hB#s4ZLWNl1=(Jj!9?j+mu!0QK~dG~rW#dp8|q%NrWdQ*|NNdx(|JjKh>!tDQ_(?8R{ z<`o$KJMs!l|Cv`{U}pIjx*ZpP*|xC#rSzS9n^?#N)5~d6-ZZvP5msXV`($Fmx=ED@ zay3&fzc1qAeEC438JpEVo{AECdR=*}PMwbxu1%H|>pEq%W^{rqPPB@GNSr={yaB#} zmT|p)bB4T`G2|U=-)FK^dTZkI!6pNRk(MYAfA9Tp;z?k9*1qUqq`?wi$mU*tx-I*I zM`Mzr*JpAO#&OSAZaA+RG{U^%72E2G{8Y5g6UTo7K67Z3{1W3rn(@zeqv&tzy*8Th2$pO+}Mf(iBbLoRTLw7FTsTd zdgl?-gx_G)tPt&^N3e#vv+%g%Pa&m}YVD(UWvKrTbMF|PX|wHn$LZKs$F|vV(y`s~ z9ou%twr$(C?R0G0I$3M)eabkBPv#RF&&)<9{f&gz8I_kGK(IE-v7kn9EPr5Z_HpH4op6IG>PMHSvs1|EWSZMIMzM zF&$XB&jG42tiu73kM@MtKiZDSqCqGjEGP-}Cs!0luv_RiIv5@crOCLR)XtU$aX9gE zbi6H3H$;pZv=cw4bU%^cboFnF9H3E9GTY|B(}V$FHgL1n&OmA6H3d`g zzU9zjEg@*=22^mSoP0iecW4&yT5e=!uSnFx{A`9YMktU3(I?U9ZB-L~2>+Tu3(ZNO z6c|uLIteYUpPmN~EQY%6cFZDfX2XKh(fi3@z7oV9#KY50klR35Zi&On$pYD>96tpN z&~w4a>c3u-*>tAAlCnnSHaMZl{MSR6N992{8^jM>-7+yuDC?VUI~cXeJskiuA>&sMzfG_0t?MGw&FQJ@%gvK#YI%9^!;7;=_Qx+Nmz_1W0bj=T&~lAuU`YF!Q#U zedwU9`7#mL1@;xdz_4v>zI7}N3bzgTX{IT#1O~WHkk$`i40^T2`>hK%fg8L7@s(I* zPsvrUj!K;H-hEa4)LXY1USoE^B#oVv%9%=_!RJdSC}1Ukzp~Eh>_Qri9nqELDENtV z#FgtaIsf*Dj5c1EC#P8b@yc7@z#C7B69^*RU2}uvpb7~!v`V*VX{h0;eaYZa<698r5#X zJ&(sAdb9l5E7i*E_Vm&g{lg+J`*N^8bQc6%obtodYn*;nLEC9MEp6qBEUISMT_90n z7*2e5+AlqmC>Et1QCYn|lX3Z7p2lSio*&2B!4Xjt(>;LTYZjz-&MvXsiJDBOuYIOj z!_U7;1Ws3=s=m}vvMSSh_EN8RdU9GcWX?Bf)tdDI{Hbn7+%-S;A|}DV&(ITwDNrd4Ep!#0H|J`lDo|h zDB+R~i7~kQbFRz4cJAcj+i4pP)IY#jDB$oP5Bh5@k6XH?b3$;OgSh4QGcYTGPY2C=nKDD-*bPumCSFRJ-_HHHUK#E<>Fxd@P32EbwF z*#X!tC0empd2$IO-rn+AJcXC5YNcxdFQjBQZ@#V=EqNu{1Gl`_BO*@ei-esl`u4p zkW66oyf&iGxiKib!1I*qOl3De-VjMFm+m<2_DphBZ3v5UV!H$inw_v-_^s0^>RNg5E=h3C$~|d*YpzdKspQ zTH%vp-d29hV8zW93d#eQB(A8QQJQ`qV+gVs(- z;fJF(Wvq1GVkDXl?W{9Pd<|zG@3Rcul~ZbGS4yk9;LQ(Wvrzg|Vwi}(H&pI%)w;b6+sZ2+VtB#tI%FjwN|=ivhsOYx`PgAP*8ef_^U0{^|T>z}91 z|2rNqrtkk2I~M(4c7?J03uPDE-?_pj)c#VazFu5C#!aUN*y@ChGIhQpp+ZyfTdDAx zndL}=A^A%67j&eRSY#wNRup~}*gpD8f;Gk4?tUS@ANDZ6iP<$vGe=lnlhkmYD$G8^!mX1g4|DEJyFd|~ z8O(i~MhkSt>%2{fwCepzosTb~lBgDXiMXlPy?T2Y_WFd^l? z48O|J_}+md6TRDQfLCq9Dv`{Oa8z!v&-qdxJS`hR9iP z#&V(2a0SIeX9}(EQ@3VQ@+aiABKTN?&yJn^Ygyt?%4~s}@369nwhZg_Y(x`-=C|Wc zA-jupP7p*p`~V^bzA~efa5dKKH+<7k)qCNX=&xu4aSDRt*mOvrQ+f(Hda=!Pw)S~0 z6ZT|6iHmYwygVUWx`=jqYMoroy08E?ocX=fOl%z&F7bkdS2L_bZ}!K4p+2+M+aDl= zH>^be;p*_LX=VkMZXHudf+U_TQwq9M1_V_RIl-Yooh|G4EOLZ5+1#{E;F7lfxacT? z-uR?y=&INSBXHtP1etex3Jl!Bm2!{4rl0+U(25i;*g}aylf;=8oID;pM}rS?U9-|b zq$xpwm0#bGoK^NAF!*U7pp_%g2`{q;)IDW=4K_!jo=%pA^ibJ;Vxz=C+ zEFz2|xD!zU3}9FFuz6GNzL*q(PzwD$bfy@PKOE6LzXc#RyD+5Fr)fxlT-uHX^;{>4 zDSNU1)KI{2LLuu(441Hc|bT)t9srs(M z2Y1y~ZnmN5Nbgav+B#ac05zv;DN=h>KLOlRMtwc(HgWalXD_$nZk(~;z}B0--5Y^p za6#&s6{!KT)<2(~CZ1hR2tY>7mf15c+Sfc~0odG~BMh0QWwV$Y0A&=m z_JZEw7|@*CaoCcDqk}%Ai7y&##z{!a zj?o;#S?8<(f?o+OLOZaj`kbkh33aUNsmrJ5;_AXcIq*8#nmt{E)>AuO7|v!|2!}t4 zmMVe>E$vkWHlNNkJ`lKbB?Wgd*Ng%V`ALNF1gR@_X7pq8?e}pIcEWckQJr;{jCRc2 zxL(PUjdOQ2b#=^>;lVv1ziX4zG?Ro5F&B-N7juY!8u8H7w2cUDiqR<{_YIk=Bh{jb zF0?>v!Z~%QGhrAAsgWHUuXx><+o}h+2*XOM-Bfq?sfP|iAk8XBiFLE$7hKIRTAU?8 zJ=2Ht&5D&t|`LZTA@l-iI|NZWk^4k_qua;PfCSxZoZ^MoEgu779D{{$6%ThXS>%JdB^zg%$ z0qgzxYrQHf4TkhU#Oy38UH5bWkPK&@*m3RrLXMI7%x3lR1dl*y!l}j7J(58p-)5 zsz5APT)*p~hZ9AP_EBF#-xgY>w}TdRRmLL$MLvAg_dB5m@AD@flJdAO+E%(;BoP6R zQ=7_Umdti@Hs4x-KbI{~hNARu?4<=LpH-VR-6D@Rd+2X4WD zR*Cjd<-k`~pLBQQ!@fy&C5Hs$RiyhdP2{n8(!g&mp3=|vOt}8RB)h9=Bb29G$kjc& zzLe3Lt^9KBD=?C`8PwJZ{KXQ3Ck7o4vi#HCj1dEjC78s}AQ531_;y{Mu9+f+uP0&E zbQ!X4mB1}>$Omvw|6_2W}uk^~?taT5ljCqmLnH14_#PL0Guf z(EA5UzqhU7y8^i37qyCZN0b&ymz2Vzv2UCc ziYP3_og}g%Oy!87DYs|AOkF_pjKM(XN-zwoPuzbp7oBU~Xku$x12i0Td7jvdem*{? z8ip0R9>$T{p;~i>-@M^#B&TXh@^%>3`;av(r7654rvaa7Do`KKaheAuW35NwC4D1C z;y?OqeghW$=t(oHP}lIxVVof}M(769T>d93`fSt?0V-HPxVnRW@XmL-NQ!UlPI5N1 zyy4S&RwDjo3$=cY%X)**x3s)!dno7*=nd03Y~~O_i`cs9X+LlK+Q3L*&oIpKAn$iK zd4dVmb(@sn_=jX0xX)(rNz4y>cEuPd`vG)0+CN>mGP>1i53;sqc7sO5Sl2EY1&NW( zi7%lD3E(dfh!Uhv>q}?MRVs9~(SN5esjK7evV3FswYf9jx2Il|2Z5kIzoIqI^gE(? zQZhy`qhkNdt1jQ8tWxzo0cK{8)dR_u7z)>^M+4Hhc2NM;*^M#{8+~8pav~GOI4uw__eXKn_{CW%FnE>J!S(A#(7cu93+;%*P%*x> zm+R3%56oJq$A{JpZ|0Wglo+~AGe;5kEsdRaLfT2;x}ahf_U@~M%F0^&`lwEed5BPz zSagnjNAq;A!8RY|d>E=J22abJ`p)epflxM@ffDe!Z=*5%32;$c~)uuTbDCkVkR zp%Z|LqHLSPg7HKK^K|~a+w~Jt{bl%abd@@B6{O0s%)>KtuHljutXTne>vg0ALwRBp z_BI`tJFCS>jd8E$HFBW9N=E{;2dL>6ZJiONq6n*;5}>QJB^C492iu5OeQz@Q?1^*Z zxb0|sa7eRa8)dxx)!bf*6mMA%;;S-Yq-a(19!rOUsa#05dv!^Nb{$dg&avLdhLAUx zbVNT8sEvnZ=m|N9qs4tCDmP5s-3xxkj5&kS{Mig!q;mE^o8B#qk2?ywN8x7)EmqWu2&(ZA_CJTS%-@k%DOMLnjOhT=$#>}i?3LaNT40BeWZTO z^Fn@wN-Pyt&c1q_q;_l+keAP2QQT3Gj&QNS~WRI&9?Z?b633=;@Quf0ZS34)LY zWzKk$k3w?PxS^TUT(kyVUrVGfeW#kvawbvWqZJ%9p)^V%Tqwxl%X@<^Y^ex*uS`dwmZ1@3u(!WlnXAY8Iqbh%j73qUk@&f zz+MlI8KW*tskZ7SbsMdL7m2q@lN(v1PQe`4s|O4xl{@VRs1TlzGQ|Q0rZtU5j-vnr zMbTiU=!so4NK`^bOv)KcAxBiQWVj*8?}QS~1Y=>cDh3zQ2n$VF{2GI$+!Z+wJVFJQ zbOC6`xKBOG1liWy0p`#ql1K}3j1$@v5oc1Kf45&M2W(6|BsJ-u^GeTCYwcPL1x%ZK z&1><$&kOORe1Z^H!JmOMAP5*v`pBebRwcKvus-}d60POaehRLiV4KTdpPcY5Z?U2U zL6n6P4BW^r7@fwF)XYp`>>KjTY#f7k0|zaNo zCt?$rRuKmiNIo)6Np3_-0kIx*2U@jNiTU~Xf2_U&JTOZE<7taEzsj!_6J?4opgB#O zE2Q}(BVa6851!E@I`WV9ixTtWU+q1LvhxgKxcno^X^%9j^Y4>M0Wht=7Mw$wLYxvB zgK`-(diN_=%CS57Ec3=tfMGw~mcjCZQa+qQw|<5i9@hC!6aO7~nQ;UQ=FY4L?Jgt| z!a8sZ7TZf;^o3VpHEaQ+vKiH?F2Xpf*Jc`Vd&THWS@ONwk%O#Z_NuPTcV9?i`WzRz z2h!21_}R@@G{NA#ZYg(l7Q+PI=(*Y#VVSxieaVe1tr&p(FLrjZe647UI`zcca>^yN zmZ{Q0GJsGj>$6()f?HU4omqE&j87so`Toq%P+>7-hbE?-8r6L3B-^pu-1JV)PhZ@1 zJ{AN@L|OJ{%hnP6q*EH%)0<83XGo~G%i+_dxFCxLb@a_xjjmib@@zicjqbe8boMLK zHDIdgC^5PP)PwhPYPGSupzGJWw|AP1Hy%k@@~>Ef^-IiV=Z6&#gTvlV^gSGMAs)zj zsa1E?=u6=ElCtvnJ`+5nCr}JJE(>j=n$c>LdV;w%-9>0A78|J{IpE$^WsE_boWSUK z#Dz_??VZ6r4ZjO7>z#q~*$D{K*p2raW5DQ1YB>gcS?xu$v$jPjRS>X5AzX?v8kei< zFWfup})R*^yUE*Q5!8 z`@86F4u3pik`j)+C!APpZ}cce1f2@Bs{jU@unc^|!mhnbITg{)c6Nvy&^z!{!%X$@c)0$@Lr6$%E>PFVeOzoAi`&>@n z99Mx)qPfto2piEN(m}Ti(yi&uG-lW`7eG33pZp46YVk-qa8AF2 z)V1aJlb^_xUG{uDD<6qcpk}=1i1!xfN?3|HFSmGUOjA7oLGt@_6O%EM zLqb{EamXFUktp5ZP~FJDogEvmOw^P;>B z(f$ev-WFw1nM2$<+GxLKu_tv(Cd3d9f?<1uO{Ai+nI{7m#A@U#ekL@RjZlaUF!ja^ zZtO$Otsd{*W3H}`!LtC-`jh(Byc4-6`cK^mLK?6OK}b5rpg=lwJW`i9xC?}f(EZ(Q z${cX)=>6&pL%f1@=N~*(48Hp<(llJzkuM-5-*N`*79M9qE+ndPTDmCHK%5l6prO?T z8u3d_&D_<*YIA1dCd-hOi_5@tNkIVIo@y2DaNONxQ>W1pL>PgzVUW1~VW$on3*zf` z^dNlFZ+v}~A+mY>%HAWDq*krf3*NJh8S>Sahskq4$(FqU6pAKV$1ccS(WM!J>A=@%kn3(`E<1&GtxV7{5(h&)$mu(!)+~w5 zj4Y|yTXyT0S=zhPa*RX68$CCkmCFS;3~JQ*rHa${RkrT~PB6569&nn|8yCdE3wVj( zc6H~|nMD0}hq}XgkzrxCFwdng=Y`~Pbt?{R8Cr#Nb$2IrH?_xL*={3*#pJ4&kdLv1 z+6^{GGA*B^Z{SP0;M^JbQO0qgi8HFoeJswmL!1|b?#|^%Lv9B3knumWUR^c~St8Tn zVAL&^sE>J@kMY~@gRiYtx3D(xv(mNlhq`e6Db`=l-pY+@T>T*9JvnyER-WTj)*)f5 z>tJbf$76UqD9%6xuh@HLSmi=itzJ6=&XQ;^>%6@Xq@(tjzcghytScj=#gM4fCEC=+63h%Sd1Vt2Q;EcTXG#0rt@QTt-IrCZ0}| zE**?fmdp!{t5cpC_@wDy?IPNNT|wT~pAL>R`yUI{EzQ;bY`)K4poioa@=v~x*&J9O2Z8rwK`^q zx)`>L35;OzNuPK-$+gY9TyS5^Zf??36e$)Y=|=Ta9s!mR`N?H%OX4S>+nvdNH^Xfl z)6!Gc{JcZA&$)r$iL1@3EW27pu`zY%#YNdfYIv(jcVL%hQ{)bEm}HU6bu|uhWKlN3 zk1gU-hotqQE+9B)!csWZRyXBg*L|3eX0m5&s{hnJ)g&7?Ir;{jUoDxf7uOY*yY;UL zo}FLM0@SNUN{6XDCTS*ZFY0iveB8zt7!UejLe`nL z4?W_>h_-xSmy0{EKnU|JFq4X6g~Jyr2lyq+(xTI2RXyF6D?5et<8?~L@A?CkS?Tg! zOs;YnR3F&~8tv;8(IFSVzgZ<6a^L159PYENqr0fHGAIwzXSy6Pj4W3-n=5$UYVLKY zgzr1A;wJl#V~S13agA0*z9@ltDe@g34U3=2_uYEaAC-=vmF)v!I}}`48JO)%UVGv1 z?>zx8VV$Bpz39X8v`twG>Ktww6vJmX)cmiZluG$KdM3M*9$3HIIC!5CqF}K!vdmvc z3_WEl$GESYkH%inaS9`ZF+lu)@*qa9eS9R<#9aCP%(E_7>0k`KtXVTDI;LnT&Ny{ZaxpZaEX-!e=V#ua4LTOc*~+J{@gwKVOde>{V#6F zf6?audtMjIKe7uH=>IzgkmcX7fd92HfUJMfK>kO1EE7A^-=)WXVE{S)%@G_80Z;rz z3w_yIz93r9w^d{pi9z)vnrXz=v?JxjKz)A1Q;4@%NsBjC)YVH~luKt0+DjpP|HX}K z%H@JinhBYwh7(?ou<9&L-g>-hQ-*Z~zv(?!3{So~po*tIans%Ki_fcaB~dbbFms{N z7-?N_&Wx8WuW;4)D~ft0%QrJUONw*HK|I z{aKv)fI3(?gp?oWwXCusH8O6UB5uTk1`M2h%+-In@uvrdtqPe)WV{?CoWB}+GZ&+& zrEuylN}21SOM1zj23Bw|Xn`rxl+WrI8Ji{IZzNO4`jd=3!gdW@;uKVG-6?Gg`5F?u zc9D(#M?Dr%+AFVg)W_+N?QWCGbNGwiXZ=B4`D#GAK>Pq~qDZVvb~=;z3N6je9$ENB z4mZ!s>B12Xy`{I|hB(xT^~6R1`n`sKpnz7-hb{tysmt#-&b7W>U=NzUBkTuwk~wlY z+;Zna{+90n9?CX0mOIt~6&PZa*#_J5%|F~A;%tz_FLjX)w%fl+m^gRiJmvgoSK%K7 zs|L5j@tHqJw?4(`BM9hnj$byB|;MGBgfZ@g+;l_ zASZXe^MI$in3|w+7(R219oi%mFeW93W=f5@Zx8}@L@GJ+`N;QCBPTzAoiL>P9C~*m zIVj?i3jhimeKeHSi@zzWteP=*4Qt2M$L#}@57Xki1hvdY;rgyuEY!)=CE|^Oe>hPa z%bhNr;nx-Bl*F?H9*!A6Ed*mKZ{+Vv&8*+=ZGgP7mIE;NR*-6F*2_HR+-8GBsVX{KPEI9P0@&)o8cx!meR~{7DUSk8qM*#Q-8ObCl+z0ivI0cDZ!?Vk=Fe}GGszENoR zoFC?sIu};tWgthVrLzX^f0h4`D~3LAswXkWYYb_o7gSd%L7l zesn)X9Dr$i9p)5PP8_k(=E}%?eaK!yU6PN-2Wke@hR|% zah4y>^FJGX*1rg`{}ZGCPy70RH2U}d-y6#M7qQR3+j>rxzo8*bDE|)`z_ zOYDlsA7AU*uU*|FWux~>_lF7QqyL^=3fg5*yAwH@i5zJ2e#E;^Yv@qL_;3&&mkyUD zqo?||RqwOf?`O8P;{*fQ9e=BpuDvONTw4nKV@|!+*#0bOH`&QtiuOF5X5BQzv3QU> z9q^h8XnWT1M8NrtkCej&9D)@Xi3`v{Q2u3K!XHZ>3w$;c+@?Baq)Ufjo4x7O#-R?v zGBO*4jdCl#Q#YkmKD%!FTc|0%yH6q5;0;Kd{&N!q2%=~~yRgLHb0C@&xNFNTHNPxq zHQXN_#0NYJ9`apCW)0w)`oX3#LY`wwlOp%$?C0u$gJ$z`hAg2vv%L)}k}>QK zt53lHAgosRMMqE1EI$R%QSCXobX%08oia6+1wwSje~%7srMd) zb2c=_;E#eobF@JH*nUqJqi| zT}kKC>D@-P0Ec_TekuV*9xtw_&t&cX+cApFNxI$rw;d0xce@|aI4`1BK8A(AsZ ziCphIpPd*A^QmH*_5~qbICb}RaC>CxuAL;ah0p0&U`7r5VE8QnvZr!JS88ePIX(Hf zz0q}OFp}oJO+0TN%F-7dv6t!}+cimE>A{lfrNu2Frb>Os{x1j9Ehu?u5fq(x#IBs`3!n4>#7-+*^->|1}nfC<2>ClTBFVwr|16163*Xv){slTY@ z{xduEf4sQZ|FWi!^)FhAe>YD|3~YaApVYos1B3r4N2_+1BM$34LE7?WVoUHxsl}w~ zJU=*9^E>=E35^vCN(nSd?h}zuNiQ?whcHQr#{K>l3fMmGy~&iiI%DIYkG@y0vuBbB zOld`?OxL`c$GXR$L&YCb94+@CHz@6&69#;oj~gA2BjaHTu~%S+^gQ^aEY(hcGnQO0 zFr#^#RrRF}?~YXiFz-cG{3k<3J=^X$c!d=7Yn(xaNgJi(=Qi2!u?F_X+GsGZR0aI+ zhL~GCx7kbx$UpL+RvFgtoKcWQizpepx*rG)MO)Hirb%LKP?1+wd|c*-Fel}ldOfg7 zL9J%hgQii?A14SZ6<;4Y=$$wpiT?o46?p=U!cXbxyXETgozZs6Dntcy{-VVGw>uK=k1!Re(CQ z7L@p!iX06b#S|AXoF(@s<=r028?YUek}e|kptvAVZDZ72kA6+f!*ksb~n>AnJ+|ylp>Bms=?$5o3kP} z+v@pcSqfQ4{Cd6FGU>XMVPtT9%k6Wh3bVV5c`)wXc&$8z zAvrJxo3qM+1!YnbKegGFfQ!-euzWi|~IW*@0DY{}N^(+)A|r zlWOK9SY?QBC~+~RH~5~N6Rt8CVmoSrtIltVIeCylnqa%bbY^SB2#^;`wZ%3JWC<(Y zrx{ADt!JU#*N25Nru0t%1TsmQq^t3ms*S#6?8gK0#ilC|{*fu&%#q(o>`QWr3d9?L z=7XJPNF_-sVaf0=2h9;Qij`X2u6xVKpCsSb$2)Hv;Q|)LCNiiv>~?1B zZW)}UXKw4pUjl}e7`9;Psnudw3-#QHcDTNHL^xWS*eL&3>`EgY`hI^3I&E5Ex)R7c&K=N@qkzi5o%0OaR+}1{Ie1mg!9H4lW{YM^mIJE6 zYg9hD2yYv$F=Ac$&uwI?QrUT(k+_ zl>`iiATIj#pR`sZcE9H%FLiVg`vADyokM%ACc5n3iv}#nm>;fvadWH>_@kfgq=kP; zmDYB0r6fdP$L!WQy6JR)s+3~Jk%Wah*POzWiXNZ@vc@xYs+o@XM7XYyg3NNqt4 z203Ry+bE|5(WYCBNR5X{FU-C+DKugdN=thP;LFJZ844|lm07vu7hnf0`W=n=3_ETl zDvK=U0>`?vJ`6)<;FG4%^cId1KB^6z$;t)f3UJi1QaDqn7`Ccc=|N_jp;Z&I`vIMA z;(&;NYO_mnTX)7--B?-+JtR87XM|RPbpG*a+Sp8KrY!RFA?hzevrDvl>$Kk@kRQnl zp9@e=pb16T*RMM&ttO+CZMSK0S|}(lGMD$^iv$FYqLXUUTSFGK{}w!bu~vEF0fLXC zjUSq#Y?en(E$~+8iEt6_8!u_L82}P#hKeNMVvmV01g$PQCh4VIZU>%1Y`B51VO1k^K&Qbxh9svPG-jMM^~0Dw2lOpJ6sN{V z^u&+AlLDPuZle?_Z3WrvRLY~wx04^m+vOEY&>(rx2~?@mjG)pE&6Y1`3luYc!On!$xwwH0P%!Qw-FtbBO$BO97swi(6XrkYK+% zB=j{SK0RN!KK1S%cJ4gDymc}^?ARu!L^1Y`_JE2RScjaes6q_zGEq&K1;JZ=3+c}L z_TnZyKCHyw-tJUM-tqlB96L$b^*a)N`i8k_?C9})r}0WHt+wiAJWvg)9`xp;at@;H zC`nZOUhot-WPQ_QT&2BdJy=Blaf`>v*{asKqj}@6sI^bpo-V^)Mr)ewjE)cl&lLEH z+&gV!nbmmSnr@*XFi7#!ZI}<@>Ur3Cq{{B7h`rgq502wIp+I^v=&pV*Z-S6C*m&Wa zBF$maRN!*b6oNp|C1zt-<)t@D&aXb8(ABzQ#~L!RuXjv~u7&mz{}9P3((#yecZUGm z=`=1x1U{Zl{tF>d4snr!;Kl$>kgoJbwm{N-h7~enzI$ps2V3c_%AJ~nEMCD*PNUj= zCe#~J=JL}!YZ-P_CbzQccE^8Qrs_KIa`Ct@*46Gp<4ZXEE|2%@5{!E!cBdZ>SjP}r z3d`xO0j9KZ|028j59b^+eyORP{(OL)IdGB7W;#<^t!qm zd8Vr-gC?4N+zY46JDEZfB8A>&ZClQjaA$jk_1-qr+St9veXwWgM31d zTzNU==V8>wSak5yMzGSRlv$76(#ti(tI^2}!7Sd+4-lrUb^?R2-C|;d^3D7>#}zz)(~2p->Wld2KG(a=PSCha%5vIj~qsty=(DA5yky zTf1XCSa0`yJs{h3Oin&d{ns>++3FFE*qrE;t+XaYYNOk~jTy`4mBi`g-w4qAHisnx ztN_d_{gUjEUnIG!3-Y_!ACRuJkAy4pV@5So44HNg;5#SF=O?1o7l8=gZ%U0C+s;5(Pbt6=B&#YYg?Eya6BTb`%2m&mBT`ySc2XdvH8qA6z*t@-IE|r&|_>?X)&sSgyPpYwEr~BTh+WY-6<(>kb;4 zCy;@Q2FlA5ZQ~Nawb&N8OcxWDrSwNQe`6jpOgwP>6#g}aq_bPAIg_>wOE)UIRUT=o zYs@PBRh#&s!@$`DO*J+=2J}X-ooWJ^e>b=^*j|koSH1*eANx>Eo=q(?v(V<&*!^dJ znQ|uSx!3YXs0{ySiTprV#f1EO3x)7+N7Yj^W&Lvr7MD%ADk{b)GsA}U059eGkch!$ zCg{iHcH*mi!PE((wvt@cbGc3GI5vMP{#6D-lCb7vnAq|bVxp#Dn4gPs_G_V`W(OKE z6H-Q_2aX6`!svW^J`xqBH*9&5k96kf3hfemM3vxeK|1}g6X8pY3u%CsW&5T!GCtdv zc*l|T5Zoa{6aR?AVfa;Hr>-vMv<0&yq=&r%2fS0($Ir_p*&N~L%ZM&uFadh5f3ZRQ zMJM>5Z4mzzi#W0V1z`0bS7w&Kg`27$Tdj#Be@qpbz@jH}*l<~FjN|(Z+4`NyFkxxd zy&5ziY8XoD_X=%q8)T71aVdMsMW35!$px&3Kkc} zU%q}>nRgP(`lAm2%+2#@$e7mN^zlxRmY;|bGmUWl-h0y#&BdF6!*x@94tyLz_u9m^ z*i}BO5B7P|0M28}uZFpd|69bpM0k6 za7+tfim@UDNjpa~3w_SFG|_$!pbN$j*cc8geoviI0bE|F+DwF&M|^5zM&S?4D8u>Q z``ex2Q+J%XKcM*oz_T@1Ln7f@GGQFuO+{fbFahCQSMyK}7Le_OtPWNt5b%3M722D` zuT3*XNBu%#crH7cQ5S91f<`EBio-x%1Zzi{13re~Ks_KkVvP5=$gA^!K=E>*&R1gr z;l5#;^Ka4L=*^J9`j`jMxaZkH_8s+)8|G2q1Z%^A$n0)kR7e(P4I(X0u!i-dgp5?= zgb~zZuoDfLmK3z3IP6RiFf03-Reed^hF?-3e5HszgoZ13r@vniw!wQ~jf*qnp-E$o zrz&-`BoXEdgRVM$S9R&PahaJCbSVOJ_RxNi!@=faiFjIl?fcra-SICZy$ zyVTsdF8@eDTdWIgc?_%7etv`r5){su;L}@)EzdT^9wI*Y#)6^99@}0gy%;S@VyTiq zf+nqCEIAV`?I^Yyin`KzP|-d1E;3wN3Egf!)@ISORVf{04r(Fy41D$d+YCqZOT*JF zph5g+?e@L~ODc}wctp?2Ll@*rH314N*>(I@n%P1pdXqYlc-*@xW(#ozUnO=h+SF31 z{CK`b40@$AQ-GzNDGb(=Q<^bUQtA5Q0{JwPI-n(c4gzGz5iOKm zS^9&p7MH}Y0J>-FV8PZaB~);nWcag@NWBCYIJlyC4HmZi(NOoA3Ebog!FtlA1D)3N z+0HG8p)@Z!Z7aoN@i9}X{N3d2+cZV`{Y~r z#hJ8cngG_a`Z_n5FA^>+_{!rM`C4Pp7(p#(Wf-O5xKoP(ch8E)kHP-%_RGPCBkXD< zayS=RYO`b3Y{XdOedF(p5>2$r4W{6-Q@(X(V3e(eq>=)yme7o8$eAR{8GZ%_2zP5B zW6qxQ(Xi#-+Of6Ni9Y)DMzYIvFbvA6%c~(~y41~pT94&0mfGzm8_nR_sHOvkW(mSs zh&*^Fov?hW#%y}I?$o@{z0-nbVjQ_d6{Fh-?Cb3FZ-Qvq?PHqV>V>))_s6SOf=LiP zGB|y_m$fkZUAqV*bCN!q4x|^?D)Syt+Jq;qrD^sGf`cEhpAsN{ev~6B-GbtU?o0dk z=p?|kps<>mX)YX5P;pC!H4#6_RVL8&XsG0mZCDLeLPzH!0TT&DO{uc|{KQmUGA{Rvd) zRw}KjamF0>uc)*Oo)N8oe3ZkW^1U~*`DYmA3E=7>(aLUsrS zg$@K9hzx_)e@IfouzIBq7L`e`1hrF>0~bP?c@C0iCx0V2KK0?@hS)NF14&iD?cQ{V0xD(AK~3srB=xlkWX}P(nTo$acew; zHy1>?8U{J+F3VQ|_R3HqD)d3)>DSrb-Hfz^H%>dn&3I&+9Y)LV{wpMHyOgM2ov|X! zb7M|9~D9>$K*_0FT&?%vVt+R@zH($bol5gaQ**SH00TQy9KR$Ebb zuQC5slEw^&bO~fFQ;0p8NwvP|Xmb8Y8T^wb`y0W`hyfF5vN0slh_HkM2zL1QbTc(h zRI%mAQHth$b-Far^+)e+K8Be4%HBpTAF*9=@-zp!)9PZ$%)WsNlT{1axrq&$$Kh1? z@t8&`(b9V|<&+;%%8U>IlW`tp&wKgxNCD1%23C9*VaQkDB#2x@5#=Ac+%&18fL?Nr zz{_U$Fv%g8)qrh|n>#CV1Jv&r1V89DbUM14+tdAeANoCbFXZ_A^_=>zP^0XKQsQIa z`nEXOiu)J{VbwY}0Ird=0%Otw5_8xzy7Q40uInZKK~A7Q)&GR$n>$XyWDeh2Ot~Bi zvw95)-=|pgLgA%BR1Yz9_x|?jVWwgQRm~_xT#nThBSHak;xf8v8OuJV9s!-7i$OU7 zp&qOMZ_K?@kZx_erJ1&E+qP|ErES}`ZD+2uZQHhOugsOs%KEFTVn^@4`|H@zQBkM! zjW_0VHpg?1G45*%$(X3Gy;^F~Sl*<7VnBEjkm^?uiMFhG60IG_M*Nh&MvAnxytKBW zKY1>&hH?gUs6Lyadtwo2PggluRL90j2A6ZigN~qB4t30-PdW_K*poX4(Tzuah;~}_ zk`XU)5MnEC)2ZVI^YO>UDZ6RtnsSvhr8pMmvHa!w?d0t?nKWC2N1tWOQ+p&L8UiG%!j2d;MR&5#z8Wb(t`+=r- z$&_9gc9>|sa6VL00C+Oga0_@)7e?VK^3=&uUx6i=DX`X+)UqS0u7tOr!pxTfva>lP zbyKWZG1K>M<5Gc+>&3Z%SL2T5o4Dt}lQ_1scea^NGK|V?T0z)J(eZbE4i(iwggdyJ zUWz62OCHf40NRGBwA`NRT0ZcHeo(`gNjpP~+e?`dtHGM1Z4Fo!$oBDi>SsjauDT5UNuP9_K` z2?}LWGH&bQ_d(tUD2dc>W9WwMsio0$g8E%L*Ir%b$FXU-N*8jn-Qb}Q>o%VRXb zi%uL30_3*vm!-%0Nwu;`Zt1OCpggcO7nEGIjkftjOs#TI^xSF2#j{XrxgCKDRmw4!SF>ie$BDvnIa1>^~#eeqtz$Qx1I_(!Ymg zLh3?C=18PKvXM&pEXaCCs$>jY6^goBg_dkNXeK)6qc*VC!oVhgH+V%-0~HdNB3om> zf{Ee)ULT&0cU+}W!4%erv5LILG?UpC)t(fR$u|h+Q>Ki4!Y+Vt*xD1@1)9@kKqaR3 zcs#SR`=*s*#R^d*H?725S4vv6YuTYT&jx?}=D_)ISx&d>_GZ zy(7pLt#fh@JjnL&Ryw~74(HeeDlWM)@3%jgsC{B1g88Lw(lNqL2vKu>(@{ow=o)fVV5vY8;Ea)iYe=ovV&cv zqJ0eAg0khz!-=lBu_oIIA_xns(X;Z;79L}EL9K#7B9LtR-9dz3%3k@(D36w)+RMjQ(?n2(A|{ZvC)=zD7eUQwjLZMU}$WC68XipY00 z>NeO*UA{2(Lr;~xgDt!92Rsydsc%?Z<$&l`Zo9qe-WLxeI-Oh>oa`zT`f^BRZ-`f?GAf$?lRYEK6aXKP#yl_#5-=$kj0E-Ea}*2~EBw z!r7NiC{X%CfN+i^g+FVM2F2dS%jY?Yth7dQLu#QWtZGR_8Wf|w{ zA=W=)kcU~}sn>DNvCW*MNcO3hEwaiPEq=aux$v>|bPR`#?ZEmIm=_uW{9u=MD`Mzyqym_N7}B)#6ZR**4QKrr3n zF513mdc-BtHMh;4qD>z&dzdL?UF<(!kUQFvPcpX_Y>KS=lt>foxRY~mh(YW$Kb2@~ zr5U4iuYV3G-!=KHk?``&$s7P)c7fQzpM zyjn;r{VWFJ%Y{q$?JTH;>2T*@*-^u&aLru`U=U~Wr* zxD2SA$}<|cm%}ghNAN-B6(d9;lWbyZ3Z+KMLTOQDdJnz_Ept*ovT1@sfuNn8ZhJSbafoYtDJ;h$@Z~~W5xN&C6M`Yz!<>*vsr4Cmkmnm2o6u?QjWWje@|Qc%Z(+retV_MQH$4?MJueP0%q>d-@wWgzl`x0Crsjh&QbnM1_m-?YDP> z0ZPH7LK!=*hHjW_z%Fk!PRY)mrhR8<00&&OtCj1NMc$C)N7GeFY$enUu;~Z{^;- zL&I@&6)(a!&=yP4a3-9w*lhO;>?w*wqk{p6Qs;c3e=gnZK-t4-fVY zpG{-V3tPHA9vDL`g#%BB^L>`DHucL=Wfr@$bK(Zh;UJ)i^htXQQgkY4eRG-e&I>gc zEaz!wD62A+?u+p=@JBE`Mb3LocB-=zk^4;d?*l^Mf$GJ*VEp9H0%bftkwe&L&>V(X zz~Lz!_V2Klrv_z#^YT&}Gc~1fkq?U3B=*k$sio)Sb2$KP94w!NH61PLu>(^Siqnk1 z`tOa_rnNyZ#uKm>f5I}Lpd=Fo3-qA4#V}RXwQ-5Y|f=Nu}`-Al;8Fi zKfO*TFy^p$j*(@G;2>T~jH#1cFv4ar0Glb@DRYLljVN3!O!cC^=*nh&1uI3tMNP4I zG+1l;&?T0dXT!J-TRTN4u$J~x2Z?IL5k%`3_>-RlMAe(=2l<~D{+tV5>tE*rQkG*W zlm=eygX3*7q50RjEO3;pf*nA(_04O;a5-4?!CLSa+y2HNd9Fz<&HeN#e-Goi?iF^d zTr_SpDs5aoYVh*}vI$)>M?1u=fNO!##F09h=s@!RBDEAy8viim3Taw*!OykDs7mN}8af0k&1rfCj5YL#3!@h4^_&$DnGgv#>RPg3 zwCdIZLCFe4!N8Rwtob}~^jo+)AoFb+6NMdIYTg?%1nv@{P8r4#A_a!VCX|Lh-^<;_)cxi#3wM$ukO*RzOta@Ow#mbUMC4bTImVl?j97$ypDZ7x$@2cCO zKxbt#?HeUqt^DW5outzu2yFv?cx2g{*>8sqy_n&8<4VC=%T!5^#krLGIrI*kffJC0 zgDh3e?MSrKtpMOnQKju;jR#cD*ZYq<1`tFQo?dw2&U6SslH@^aTAWxKcGZ<*mt`S= z8<265CQuDF7s&nbN-f7v=JAC>b4gu`zSXA&FKU2>KFYGv4Z7=xDWzSc$m`0JHJ8e9n=9WRqir1i zmDVN1b+6FoCR?qfkuX85vz~6NEn29n9%UTP?dHSIC4RTpcC^_cFaOi&%rP4fr zF|Q2OY}Gwlh?o*qFNtOsu=NQbf+`TFoSs9BMuEVB1&Xl&`hU~BvP5zP$M#NXuq`qF4NSeTy$R_JZ5mSZl2q^=4M9zwY$s$y4 z6%WdZ2zGRFN!Q5jOj&3{BE#xpj77kBK8wH|5}b&zV8nD=ad9LZb;6UY zlczl{F1EhEF2}V0ne$Cby9EylJ0*+bxd8XEr5j?}M!^lBI|6VMr8{XhIS^zVy9Nsf z+n`&_)bF^FanVtGRO3rz{o6MMS`&S!J#*9_6>?~whJQe`HA~$Y?$}uofQoMFQ^Du& z?1_7UR-?0=Wf%~Hy`#-;NSO(?V%wc6)%HA$>s+!Sn5D+MHpU9eJ}>W4)D6~B-z(b) z12%ngj$gz9_uXN6XyP(IT{1u!J$?#-?*ZpB$QM%~>j8{Q^KxRQNUP7cYL##-eKy1I z&EW^V3?5qUoG@XDp;^<2{bH6y&!rkz@;LjbkB_@)^!KdZKHxe+j9^TW3?-$B-HP%oL4!0(}e+sn>C9vExgIug3wf0 z>lB2F6Qun)J%7{mWTf)~Zu*Ho+Lq&w|$2N`lJC5KVRt1AQQe zre%5vnWpIJivqDisPRq7+Cca8q8jXfeX2?iQA6FC-osJEEdsJ(GwvmwX-QXw5T6?b zo|P%zGzxT#SD zFlcYSkJkzTLC=-XG0SYvai^pjs`=9AvB6b%eQSKfv+O00{DHvU1IK|%gZbR+S(L}p=_4=nEgTCkS?ub1`oUB{OgJ54ffyAv6o+ca;lp*V*W&B$ z@bm*M-hXh^#_y>bbtcXOi(CJ5aRh`__2)U<$(J4CPLvso>--H5b=&vrM83Kye45SJ zqI4z{Fr#f4M`itO?5uz?C0thJ)#7NHN(Wdl*v8E;ka<39 zXS!L;rWm}rwGJM}TZ*bD>@^0HLN)qUnHmu8_A&Gm(8;|auW5iM;-F0f>+{e%rZx~> zD{8FWz7G3{8yzYm^NtYh#M>pkkgJ{bnCxT}U0+o#^wovGb)2!mThHxjkop&n_6-Fc(eYF7BT!4aR0f69ue+ zgdGIQOA3H@Kb?3yRW&b<`OztpG*pfE2Pmsu#n@0!U~UuWJ$0kMIQ!XiDd-7_HYM}q zXq{3uoPv0?Uay9bwXs!ywCe`t$NrF3q0g7KY9{&c7Q*s;c$&ZNB8&lBs7J=vW8}NaV+`T|_MVi`v|fCV z2!cA9ly9M_2FF!s)_v*`Y=L?JaXdr2E2eOTsKb>g;FoX#gOP3aHIiA1x$BEnr0Fh$FyG8Cl4D3Ute2Mz_nG!t-<$**5f@nz(U(?8RvGI;hbRh zFlWLHPtV#nxicX24l2dD7$Ti!nu_o2qH{ix7o~!_@3La>RBX)=g$p&z7iN-l(%V@Y zzSDIScO7`@I)8jbJ)hm}m$l%Y*Ls~(1?>r;kerex{~&oOUH1d5hLp|zH#f9@&h!84 zGW5UahW1~Y_x|UsKO-j#!~c8jv{_@@akB-f=Tv!*h*_4KPRjqg+X?41TK-6HwORd3J3&JA(FzZ+Ro-aH4{U+UAh zo!7zFgSMroLVq5v><{d(uXO{uc9*aBG-W2BNZKV9R$?=!Vem07p)7Oju zHY}`ewehT!kV{k?Ca64w+l*PzKP zw2Y||3uiybl}DT~>w(93A+DK*CT2gxXcl%y?ZEJCQ+Mr*ZEvl_7a}2EbnZ$cgmYbsHd_ zp|;|O-(QCSZuBSR7si3&*^mXUZ4Q^z6<`Zh6hlmFk^R_%;z3CP_JIwBU^{zNYnCsD zRlOoVI2suYo-!lvguw?G9IXynOp%A}#z`sV(W9>yUkn(36T?6^z&Va#?NI+lYd>=9 zsQswe@oIPkTNF!mf9xRO{AgKL=uEh)wVJPu`fck62AUTU*bWf)tsGSb-U&k_aZ(Ex zq#NW{9|8dJCjD)`O@4?MhTsv`6b9iGBuO|hR=?+YmuYf5{w@EZj2jjZzCBd%ofDy8 z_;11?ZuEmN$6mi1UwE0aAdpj`UjjyCg!}CX=tN~WQDg|W0D*&fd3*U0?{+)iuH6#! z{Jt{iX|3m3lbx4~V3;DvaK`2Y9->+`|TU&@6`mC9TXR% zT^sRqUKAh}txrbML*EUK>fxzNR!T?9yM=_;%C8FOv};pb4O3JNNS9qmv&>*czhb3| z6a&>7O2YioR8Wsio>`xx1O(=jKo zo3tR->e7D6*!8h_JzdDIL^f7|JK`mA(V?Ga;1XJRIz8RIT~GULgu`khdfc^4X41*d zHrz1l?0>nqxa2+|CYDrIP0loi%|_BBM5Px#X6eWs8n;cv{8}MZ2~7EwU=1FTPTLy4 z{@eGAK>aS#EWVV~d)1L#QSaFU7=f7_LKpsn`i%0Sn1+_b?s!3g(U8 z5IBp3%!|xid=kZP85=r6sN28d2Mg|pPePCE^uxo1^8Mr76_=i~IJ*+?SccuDN8DkAbKJ1B&fLxv^JCBrlf5K=XWRP~-Z9-f*3nH4>7-HZ z3(yiru0=H7^eq@C^#kc8V6$1`I8_k$PQ6ugZ|8@USd&uI!46M?Sa=o~c*S&PLAv$2q;J2R zTwHwI*quNJAWkzO|9IBF)Jg36N!ZoeohrL#zw)c_l0J&YlOnoQgNI^bd4R|pulQmD zjVW3WG3iyKF*F%(hp@k@E3R|$I^knRPwP+Bc`zbF%vc;`_}if-KhhyeBVA~~WjjU0 zid%S3z12_}_68x!d<+JG;IT94gzUUDG$0GW-ytiD&aRzP;zK;#-;3!4pf^nZlIWgO zVNll=g15^8jQ<28m%k#UzrupSD;6@f)M9smR7B!N(w&0u^F`U8v;*|UU4VrC6h#}U2wKQnW@vuLga~IledI|)WUoE9!sh{O=uz7@CGWw(J@f*B<|A3#T z+&N_4Zav^5u`;ep-$JGJ#wO-`XQkt!^}TR#9Erv(W-R*TgTVf@XQNfWt}KASS;RR` zNF~V@Rvl!Jj}TeSB@cXhupVZhT2s zYeDPX&l~X*x`LHUkzU5jxo{_aqk}B;=$+|<{{(;L8!$Mhzxm%tlYfrdv;FUj+W(iN z$-fERv$6eyH2GPLY`gWZ)yOh>3mo<)N^S*rgIqf(wujnXj!;c>Ak{_90l#NQ;8@>UI^3H~_rUX9p+8U8PVSL;A z`u8D$Vwi_E;X8ixCmbQ6PX6m4g}xw%XF(A34wSI)U7FCf77_5CO-kux@GA}M&?wzl zkj=hRS}UN^exkpW|B6k)|svcrT6?CMFhp8T(K1i-FVrnPJDrAzvtK-qYG&WcJ& zNWBsAqRVE>hg2Krk=k6o@@O8AhlqG#ii2K_mJUx%-fpfou5^HY2GQ`~r6Mzbr2spO z-^Z@wj$>+fvBiq1gNCC6?x#kYFpXTMOA$q9} zM`0QnjvQc4K(?~V7ExJt2SP7=5rh7t8j*+}zeYHz?S0dWDWQ)S0m%DfkMC^<9|$sx z0ZA(gTxfrRcLIJ$71EDOAZqlR_4oaOmWN}nv7$*Gr<*V3ZT~WY#uxK+o?%BRZV#*W*fpcgR%6^;&~^( z^Za^KdSuM*%6{*i;<4L5?1kRV%6W-u&K)uMeaW0tkV4?g9;V_=>rFi7mQEV z&r}tvUr0=pP4w`$yJgWY*V#bcf*b4x&@ym%t)A+B^zPyyq_@rc%e&{7Hf}WZ{GU*< zyis!H4Fuph^4s{DO07STso7pRFq{5i*fhO~52XlTlE26VRfEYn z1IFYSG~KdG?)%%8J8W1{01aAJXJ7E6czF?oCt+!zv)p53l{hF;=n$GaY626=kPj

BDFr^J>ikY=5W1=}yphQv4L67Y3uGpN0%$RN4XT8? z#?(HN$CYq@C%CiJAj{`^N)NTrv7`VmqhGWkOxu_PzvI&nN=?;^jPZFubdn(S=|>3h zUomY70KI7m@g}OK-%7!KcC~Y*@3C33PhFUwX7Nz3VlScBo3xLdM15L@K#-*iSB08T zm2*KPo}MDN{m!r*jCG*0a0hDm z3u?@jlz4T*NHp$^v09@Ai~S~or56FN+MR}wn_qPH5y-aI++ei@8wJ<@fOAiyfsqXA ziA;zjadj0!T-7$Q_RXPF^rZ9E=IW|j{ zMw7Oi>xE|q-V%%II_cah?#2CMUPm^2^gVBSJsT)Deu@r-XO$2BOT1*cQH3^-zB6maOgLGNq1-QF*-t*tSt@IDHSpc_ZCQG>K$b(pcbX`4 zJi5uiLp0aDMa@|^cgPUb0iu>R_-ntL+dCMgqUzhb3J1qiIXiocRV|;}Z7XU4b;=35 zm8f}K3t^K7ASbH6o}nFc_}hX@W=Tb%PLBXt^t6Moj1DIH6GL(Ofn9DA?;<3km0r~^ zP}R6QnSb*M{^v3S+y9AW2DX1wW?=tE|5n2$X|o0K2X7r9Uwxfx5O~`m$92@y^kVtdxIPQMcN!lI--Z@K$b~#&wo|GWI5I@gC zn&j=wiuuX$#`92yPJ*Zr=lwwM{=FIQaWs9FrpKEYH;_!C7`Urm^s~}*HLET1_x;x;BJzCqur*>7RfC$kP9SHxVN@|xG)8LjA*0!{+u zh2?&p>H~-^T3eIz4{&B7%x*{T-`xV-xRRkS(4o<3CairgvC#-7(f*`vh?QKJKW;l# zjDLi&NV)Tqf9M2!WwAcJoq|QT1J%!aaMyl=V*rm9*j^ZJJWTq+17+}bKD%pRwDfh3 z7RLw}mjzY)yNK_#KWIy{v_?2ex3i8()0ipZ7ja_gepe)OV=crpFrX;GI}41&p(4OW zA-2d-maE-iN?E1KX4F0+Z}TAp9h+t%toofoq=p0?*z)BI4*ZOg0PvHkjkRiFvpKavFfDE+d zemhSfcNexp4E6aHqt9z8a?M&~0?J~Ji`93kXpDp9Pr1u939(Y}oD=Y~?IoBFHqcyV z9nC4(umgj+ZoO=@Dg>_)4VIz$=Ra#kU=~|OvAkG+)0^jv*ls-)4#V3Zbf#c9kYc>% zV2rS_<|y0~GzKBinh;r;e%@j-UufDVAtPIaS{clSmZGn?=>`_IfTfSq2PceW_u4O1 zmfxa~-&bW7JvX>g7*O&9O`v(M6CU%^qWFcOocDy5GB?O}3jEOnrC7?JhiO z#FQZ{D%QeW$OMLgmL$pQxrF+S9K6a&NkYlRL_g6`W~VTbX{iB4IWY|yY2_|_VJd4$ z=tzX^t~VQ%r3!uV`{+8xoPN*elLg(Whl;dZWVs1@K&wAOlN8+}!J)jl|DaSnj=a|( ztk56qT_7OMo`pl-tT=tgp0cyNj1x+Fb>K@)17!|j4aM-gh{oGfCNgs@ga9+_6Cj>0 zuaMN{4%u6vH`hO<1I%Nx(w2&z9#D-t#hY!o8w(l_HmLqKX**BBG1)=jY~EZSrvcXx z(_jg8M;sTLXJP3WEWfwwOLF*vcQz_ig}VKK6j86iaT!%sHnVsLpO)iG?g%Z2)^WE) zm?yS;XWE#s2hXkimXrmPo61#{Kz=*Ep*#S>cw9>|v)%Dem?@oJL?;pQ(d(1d0&6gR z8YvUt5|`4w7Rgoxa@icRY|@mzK@jg%7)au>5nKuScY9`!_urH0&elb@)ui+H(^}o$ ztiZ<-JKs!gpRO>Yg>=tM&y8{r$t2cxfG#ds3cx(vKZ3MO^Da0_0DK|Slb~Ha$klMm zxpsS`Vj9J`ZD3;%x$)2sZ=@i9Y7{gB=DG2RKyrtEi6FRtesP;qam}L@b`o5QCeY%< zSHE;oY0h6KS&$uRLgf6wd$5_{NsSG9EFHe5m71tx{}@Ea{kR`Svi)&=xmRiefcvby zh$&^qyhLaqEE2S7397W5#tAg;;99|-sqZ;6#?2*k?A>n>4v$2k1sMgp4alv`WjLy>-{3n4QjAu{J;epTf}| z4;g*liy>Yvw3)weN4d7pb1#r>y%sx@Y^IPkNBC>3(-LESWJ=j`6dcn8Z0Nn{{^Fi+6?ni-UOca!IV=S->!UIdL9#>w;2pU} z1i{qs+ZK}%CbmZjc=S+0IdyP7O8n&SY;CDJzx>{r_xtn3@zKTdaUC+3@yKKSvU-Gd zP%+Q*-=vEDU!P~HZbkB6f~g&>ok{ZFkl%CIJt6^I_&N15g>(v*8Ac#DcQ^E*HfHIo z=zJz$>&U}FgIDK8^0_?RHms2jP$gA2`PaS<@n2AKT&vsmtPnBdn17C1)sFjH&vxC8 z!te&6vw0t~SlvsJm4wi8@(u+nMs!b`YiLxN>BUbk!}6YZ0cHhrO$;fyeeT#z)~gr` zZr$4hpTjRt?+|862sb7VS3$S4xT3I-h%y+P%q=$vf!`0FVLvQG5h}vW!EQj)jx6?$ z=_?jJ6^-Ai=N<*=d8)&{V3jVcx>p~&ZvDddt^s}(~ zIPouuk3DkH&p;?1>WUv+Rd;2j7db-Z~uHa1O{QC|Blk{Exk`d3CoBD8u`>0_^S>L6bI*AiJFY4Tk{IW z%}YZ%W`9dk{YlagMuwBI_I`5V+z+C%I*eoMAg{{T?f!jrvHafK-w)?@qjY~)@bQ;e zOrv4cZ{9@sD~ijC{Y0wDaV1#0rBbFw(; zLzz~{m%c%$6r_1d)G532MGraXmQe&erzg*XCdOh6jE|)pOfkoh<6VXui7jtl1zk#F zPE~6R7H#+jXq5j`b}7SmPgau@aOI+>IW)Ihoqjln;y&J1)7hxqgCGqP1z^#SLtBmI zh9>TPIE~}vC+6jHs+=a+U)Md}p?Ji)vJAXUSQ#@O8=xH1h35vbbJonp%I@pV_a-qN6(zGDB0yEc(DgtH5XKx zI)%jx6JX^;=9rWI&MUP8fiq!XH&5GwJZ#r0Me|@ETtio*paMUr4E)%U6nI+kC-orI zEDKKuycw|1N+`?H|2Su7^ROW78#-2>z$dl(Y=)G;h;arD2bkNp^?8nSxC?*ui*NM% zy^e9}Vm-ow^ae?8l%$1jc6lTI+B4Q^x)bibyi&783tpIsE)!?co?I#%3NF$VHrp@0 zox2}k2t3H$lW*{6d>?ZOy1{mC^$l!Hmff(MM?GhTs<7)qA00ERzd@^|>sGN=CMjI> zx{o5nOyH~UAgu}>+Q;8^oQA?deF+?VrqXraUCi8cfA{i!x@y_=awGWd#wjBULCTYRpQ%N%@;k_k@0k^hyz2o$%ZlLp&ri z{b513+5o4m^Og5wgothyC<*t@&Ww1UEN?bP3Zu|Ij{Js4;4fd7V=iNHMSh=~go}uA z5@%r?zKjnZ5*oy(VzC@99N}G$Ytfl;zIdp_X?uAWix59ddIt8rR7p}cv|ecUy*=TY zFuQIBsKF zvK%_cn?|etkWAQKc8IYUTmE71p-u?tLDW)U%lP9z+;g7=-8638e>-r!;Ws1!?$jGY z8;y;(E=V@()?_1!N6T((ST7xv%8PBt{I+Inh$HZRU1QbmkaYPX6FCN) zd{WkHhfHExEzYFOe=wFDAifmyiSmMBTDE|>HG`AUgJPw(1)yli3V!lH5a$#CG}EmF zg$Bk=P5Cqf0<=OH!6H`u4PAY|RD`$|8qe*pQkO3DWscvTs7DnebRq`CdqcA&?_ZBrmqRIte181KPY6fcxFL9P- z|LC8S0Le~^F{P=})|3iXPQ#WS5Ihx(4ORd1l%?#69ah@Xg<*q*!&2i@4GV`|5Z4TFvw}bheX-R@g~>l_4t z=N=^9R$8lH5gtU<{Q3b|SJ-e6=0IpV(;{!D{Gs$_nqkxoCH?e0!B&jrTx`lqQ{eXAmM+cQu;-u0DAWeY=sr!{zwLLxz(HSPU8BG$_TICe^ zSI+&Lp1oF~q3Wj%V@5>;e!7s<`;8?E5i z^7cFaXV5;vYw3>F3EM!bEraIMw2-1qKWx`hzk#RslO9kG={kqTMlVXa}xE5(rtGb1q8W z(B0KgdzhQ4`5&_>0b>aYBh!rHY_x*c1sbclS7Qr0QJ6ZQ9~Wb}6owbW*0-isE^v(NRJ_!HPcA&@`&Q=EnKUVy#HwEjE(K}! zROkRM44*KY38y5q^L0JOIKxQ0YZ=&|Gp#mMC8#*H0%rA^2&AsP5bbpvwR% zqoNecDTE1VD!A4N2N{rb6tB9gBLZ2n{{E z2d!3r(_NpSPzDUcWB^AqMQAohYiaX6dzKUbL>=7Q89%JC5QMwVx$Bwe07PYFbuI{{ zRrr7Z4kV24WSmm+DtKv?RH;l1+Q?ht%G#@4x}BV%;%LjvLuneraf~S*@O)?2I2L z`28q+Ej`&Se^>9>>2K)l=w*=2eyMAFtM-mjtaz1MQkpm-wU73yhE5WnzL#pgTN!8$ zWH~1N$aux?drIT&U?MJ!ejc;54O(?{yB}fSo2Lz5htI)s;f~Wi@wS`adN4{-=g!=J*E;L$k(a?9v!!&tK&wRS2 z`0zCDWHevC^OQ7m@oB-8p5KgRjpA`Tj%PH^_-I&|GQU-_L;<6%_cUzK@ZyESK!bk^ z+am3Q|HWw>t76#yszV>)iG)qjkcj0dO9T8{S6VJ)3l1#aK1M?vMe$xvr&r| z5+UDm9acQ*BVUP2Mi=KzD?%T=;aRS-sA5XUiPbzvvKKoEquOU=wnu?3X46>u6t9Ae z%Z%I6+aC8hlDpS;-UX;Q3eFZFwsaq$S$4e&9aN@EwZxL5fglWAb_ks5k6GxCv&E1M z4P3VVgF~vQ56zG>=t*m%%lZ!HEc=;(0kyEfuUQ5ukTBz(0P~;$Mo<`3c0V1}rd6VP z(PwJS*SQf*>v>y8$}u=lPt^Fll3sU|wB6j3R8Gi!EYyo#Rca;pd33yGOiTdeC5K6$ zN-`yY_vu)0Nov`I5PI)*A#*cP!Le-n(5|uBtT!VRBhIqPHk)m$)zt&0eR~gL8rR*_ z7}~7<(O6|K9B%(%8)sa<;rzCU*xjU~W$v$lrRJ(mXw;8HCf$M?{aMsPyMrhQF`AX` z*o}ONEwE7ox!N4+yzK*;DmMkJ#{^77xf%7z3PWGXZIsspiykpOnjofH%z@#+)3=~n zHMS2pe4-o3)7C#ZO6ywaPu`zSp0V{;ln>(-pm-`lC8CrgV$;?~9IyRGw};0=o;*3+ zr~)0_73-8)(Y1WlUhK%|w9?H2485c0`=N~!4@%g%MKpgu;5vVqli~zlulG>O9=s&@ zQnE;H0GkW}DR-_Upw%0-i>ecM&4;u{PQ-w*@Egs48$^Dl@=O$2HM@9WA>T%4G6X)+sRVaa%Lri}aF=>Yos<9`C{zG3bYuO@NGpYs*IOnG!v~YBAaB+%gAnbI9(fh zi_WG`=K{8tLPYGKz7mAaY#alPV*r~}ArB?Q@X~P~V*bn%`se+@EcFVpzVypNmCPa- zoY=C-_>U6jwuOt9d?cmh#OkWVNvQXRPSTLD%%KgN<-t8G2Fl7WQ)+|M3Ot^peHNN- zVe0uvIn*}7$P2M8G}Yakn;5_Ft+oMnSD1n%g_{gFm^7c(>db@QBWoEKIDWNv-h8WG zBJ21$Bvo3zfl^S$Tw+2gq6l;b;$y{+XKk`>-TIE?=r$`Ttbx;8n=~?O%Soe2 zG5AAEjY_3JVm%}AlFx>`nDZbm7qz72`v)8-KH~x>A1WQHkURg8UTP1sij`TIjoo6&KNhb zP9iExCGjS_DGrC6Wz{F<;@|-~w%&LW#BTib!n(+d)`voUxd?j&g`Mayjys=4e{6Yru1vk`w zin(~{0q5~)bk7^ z?;G>`zJT$l$jDC{4FnwaB+z(34=p%2`$mhdJ1UQsA>Nk(^_LA>a_dY=acmypWLz6_ zBC7CGqbIG;x3-4!3yh?0-)FmOUlETM+)OSZ7_iOnVU(;&^3(cU<6H~poYX+dsTHNK zR_~2edbcBs=Y#dG9kU7&W~%e!vTo(Kxpv9o-j@c7IpJ%_n7(~@B#DGl@LVgx4tB(J>;DXE~d`G?|!TX?h&Z<^nq)gj)$xH0|9W zGl_Nu_n@@=JDt2Q7GJ|hn@8qR9rr7l8uxj>H@upj$(I4j`!4frefp&BeRRMDDapnQtpr_sL4}Z?cY8l`gw18QU;=Z7JN$V44RjUL1#{rRz9S z;q^ufwd(WZ2<54*r##%BqoODxNRi2X3HU;=j>{~a$(v8R)RXeQVW-}1#C(b_hUr7k zi$$Kn_*{a49}){dlbp=UW(~b=*$ETlztzjwEA1eB#X?eE00g%+ z@$gy!0m8tOU>P@$psULcijgzAR3wh)ipJXkoR{!(WgApeS!jK`Q=Z=p*&r{&x_D%L zak^4GnwC_2sg=(+XP4(!k7pqtM`>z#>E=)~&vlG8^Ls`{LI1#Wt zy8Wd_M`{D%k4E;D>1M-sIi-Wa=~Q}{cY5V@(UEcxf)eEKq3jA`NPug_8Nn4H&be?U z9{Sd2I8l^cdE+#b2;P}Wtd6kVTY>7#q&jTVV&Q3QCHewxmT&vzcwB5p^)tYoaKFDM z%A@5<1Z5K?DQ`Y4%%u*wyLl^B=76>REO9QE+UqcBCDwuAcV+_| zLe>*uqe~TyTuuvc!|LlP(>e-~YkFI1=vbDfyzB`4b$sTf7Un7vm}F+)37J@va~eJ4 z+XkQa!UVDY`mhNJpQCM>(0%;Q7|bSYaVo4Lll-nkjn+ z1HEnuKXYA6lNuRLIV$HmicUpn#wp(L+=#DO^HP+$bfMXJab=8xndZWq8k)TlySE13 zkItNtWMjc|-ywn*?LOHqqDW7fr)ox_M!jhCRZu~7iw3=dH+Ca4u3A6nGRf@h`mTs6 z&>}U&&}m|?*ON|9s(FF#ziP({a-_!)z3ijf-n{IK2hp40o|fus2E7PN*7#%1!nkCY zyt2ofV3dytwe z7^xJ}k_XAT3d&)Sq2na!Q`aNa)(zX(NKN|@bB#5`pMBeGpvKz`O44$&Gn+Jc7JsJU z#GWX^lh&Ab?utBeb)VzPkuGA%J&wGA*Xwj1PrBzqEePCO{n6rDw#059k*( z2kF>%+FS^=ZCoT1y9`@qNX}^cl^~lCdEn7Ux?HU@m^d1y#ggAES2d|IeuT9G!Ph|m z-;>4R;)phayX>S~(1!#T!ah z3}`uDyTWRNx(U!_Byx0fp-$-u%728;t{+(c$ znzd~v8^Y&Q^-VEFsR9~Zja_keQjzC!X4NILWcrpfcDC;v40h)n zkJrMiLcJDKEvdnWM13VB3+sLZc01}4HM&M;Y=&~UOQCVP|A4A{WiQS&KZ!jSJf~4) zTiWUlPc7A+!7!?u!~B+zschchPp{M!4w3{)ddw<^%qGKmf|ax$^d%Qw+a*XW?Dmom zz@g{Ub@aAIXU931boS?53gmb_Jon|UhGoTsM_Xp+ab=bBe!m3w)0o;%6kA&4cH3O-UNg~Uu z$vb($o!@Cz-2M$Z@9JY`|07f9m3CVz^NSmnrpT7InDMKaUu>N*$pRtrSX3C`4)z4r z_YV5KZyEnM8GVm{s$V%+lYTy@K-WUUe!>E(EQ$;)ebn@YX zIc%x?6H;iiE>q3|l1A|@9@3#Dj}tQ~vR

#P*WNgkM;8`$M3XR;bZ=KmC9kpLZi zQ*Ta|%fpp&xqTH+h%TtuFsw@S0MV3kO!4STyDkqp;DDXX$7ujTs3Qnys-9FWw2MOt zV`D&VRnk@!&ghZwW1)YW$4-YTx}O87Ox;Pd=eN&qtzEy!!k>?%+DGj z?19PD8+!*2TIvvWRb5M1LoG^P7g$NOQX;&9q{MaLyvR2{AXH+SBaZpKC%Rxc-1e% zXb$i9q54GCxq{0lbdCFD3YYn=CzCV?`MM)Rsx=!zrwAI4nQ}{vMEZ}2J{aSdpVS8p zT){Mm)AC4La!E($$Suw(6*{>cLXhn;O~-}@q!s*ro67uzsEjLE{bRyY$Oqk`HK^Jh zp_;bh&`{kB*;_y!s>rU4O}Rys#Kk=V0U?W*P#$Fo!q`aLM38^Le!9>8!5Ks;1Jml* zb3mMq4N23S;b56~ ziK$+O$*e1|S1ay7+RDE)3*5dz9&%v~xrrvQ(;?>wgMy8tv)*loLuBGj07Pub$eDaF(2D{hK zkmkFKg4+R1ylnN{`R)LKx5MA>b#(B01Gtk(>8mu**0 zSU#;2pSGT&CPSAHW)I47uvZs2#}N6=-xI}HB2rerV+DH1AhZ`Uy01_F&4bR&f^cSg zGSUQ8Wy9pyXwaFHV3=lHlZhn7vfx`R!jc{92npyD24Y<@cpwQ}fQHAOP4d@Y<7iNU zwQk90i#%hZl1~ft74DV5d#RtgbrRFcaZ5eT$y?OVT;3hG}fPE9+Fc> zfv8+Np*l&32y7>%sP|KJ=99RUw0{)jVVPZ5J87o@fPkI%tb1r1OX6EE%$3aVL zZewC=Xl&zT>_B7l-OSw3(b(FY#?aQ9mi)WH_k-U}6rBy6-0h5MrOa(CX%&nOoirJl z>1e)5>a0vGG;}O@Of26Qc05*QW*SCDZ62P#Uazfz1r*!gxHJFZ1TZo){G0kHlUnOB zn5;Wa)k; zAe@~9hXRK1XwFj^VZ^a$wwbi$mr<9wQAUt1Fs5;%imhNwXv~mIk!dwYMA@Sgs4dMo zLgV`dTzY@GdhB<+c_>cDQp<%9IK0E|)<|fQ{Y#uW3w|Z6*RTeQiDYo);SVq-of}Mc;HrkR zva({Y?xal>)0=t%i;Jr=(nVvvaRQpjzDg_Ok3WViqWTNbeb01Jm5fx}QVrg578;fZ z(Xd97%;|y%6-ffpmD;F70~jzf2Yg7Zngvb}dTVR5>&F37vk>z}5_lY%v@-JeMCmv} zi%H@n*cnSMR&e|`0tDp|iEKra{nMLP1AV~!>r1hpJh)B?VDcTRJYuGXM(47Oz5J4p zb!Ozd6=3{s?7f4JYK3t;l{B$Zm*ljtmT(DYvh;l_ugPkdO@+>+?I=T5`FgI4Mw)N} zHv)FNJvfG!gY?!oK3AA+wr@cJ&pj%!m6Rz48|J7k6LtO|8Y~_`A$V^1y~fU73PQe) z_(Iv=d{8W~HNo{r83xhByc_-~*!bSxMgf6*5O!*bG}vIfhe5xV>?QEOJH5kP>i@tI z{>mK^ZRA5R%rDXO^-%NUABUJT!`N;3>+jZrx-=-rT>~6){KC3>)kfnIs_i$bc%yV? zQFc$&Lyn`6lsJuP92#f|M5sVvYw4R^OQj10M1pjPJ}=d%J|zGW3Zh$jMObP}q|%!} z^1o0gVavdW&=Ipzj+Y4$CmM0CEVlRvftE!0(I>WTNIsNhqCZT9DVAfLFKPx6fQF={ zGE6E=w737dsM_FDE_@I=rdM%_&+sQv$_@bn5Y8WA$Q&W)7qX7VFnKW1Uf`w(N@ca0 z{;fVk*jhN=&`?q1XTzob3_}2uh6r0FKZ1^ol|ObR$^shRg%*MNM-{XLLSnDlGg@IA z(lcEz37&AWQuMrnp}__}gbGv`X-O@;J{T|&(!tMV#YUZZVUREg{fbBY3TIOFo>XF> z)p{vA7D0rLxRo-3ESN;GxN{BJ#aCFg6g-Nc_^x4vD9*{g7iRj?5JxP7U%BTE3N5p}FtbNx~xuti76^7kbTt zVF4U{{2(tb9MbYM!3szQ+Jm&Pl1l9b2nT5$dQ_@hc0vRs5J0!|hOpceN42RS>@%#c z0uZCu z!3Nwo^hutx6~+m9)vSl*J^rAi;*kQA=R_P>S!r1M-PDPBfqrXNQ4a90Cuf{s^j!ul z!*4{vSJO|!LMnVK+hRj=nYC{>x&sH{F8)6C)a7t}3?Z zEQ*9cKVEa;DDX z8xjb3s&u`D&zm)bd`e(M(s2kiebXV~SPtH}L?QN>Ao|83X)6EOx07|5zVxTQDYQ4l zt1$FGR@(@W=QkM0`f2^Q0S&cvPbG|98`VIHWs$bF>sm?EgS>M>Qzk0->ZHESDsNR{q-y(odOfw$ zI}hVs@*UMTP-Z^Yf6srAl{JYQfwa9Bwo zA1j$#`-nWT=fLRxFlkWBQR%Y&qEXS*+}>|eMNQwmwV5?w-pUa%Z`0j|$a-JdVl#Mo zWz#N~eU`8CUf0g;z1*d{S~4Cz!4m?JlvcL*W1EJ?>67*HX#pqU@~TE{6Kj2vqIK1p2J4Ty!NU(5aF5o7#j54@ zx5cL{w#n+{N;VqTXVKi$)a&Qa&Cq0m@*fmEK0a#L%A4()#@5Z3(I)(yGy{#V_T3tp zDX)p^i|y@!xnlCvPvF8^S63&9r6kyc-t9W)s)M%}Kb8B^*5TK2CF<;Fy;NV%j6GstPB74OWoBL zb<@}5qdZUZ1FKi0$aj9EE}oL*VC2f~e(Ex$jB@Lx+v_%KOy&biI3VL!EPih*Z%|M} z4LHn~p8ccQ?AFxvQgQq`ApaDC**fqh?ix1X{(>%?nafZ z`TCePXR{t5-LAH2o!y2^;Viafs&@A0LU9dyK%&nEA0K5& zxSN+fkH%J3=egNgrbAJ#$@25rqm3uWluQ6zSoNUqw4h0v&y#{6RD33nntFr#;F)K(R3p<*{Lm z$oAS_vV-f_7eEG$F%a{_a_Ogo=_;RZAk<;0*=$Y^P|{CYQd<|>Jsv05cS{~*m< zb8916(IjDXRx6`jC(Za!XMa3+J$`3+EiW^VD(B*JmIeO~T<) zJv3MAcBXT`ITyvSz`3|Uc~S91#Oh{kgSw~mcQsHZw`g>BT(%>Qm-t4fSy4)_)pBcd zGhlRiy}W*NR5B#Rp2Gk1c|@-no@u09X>9V{55BG5GVzw+<-1z4RPqH)q6YNKdoDCn zs0c*^ZI?3n9pmPZ&DZ1^v99KB1NU<{wpGyA|v3@f2+hL3%5qvc-8BZ1=NH0t;zB$gC~N4~g)_$fH6@FM)SmaCWputR zr4A$C?Ktniq*o`8;~P_X`*~bHUYbRf~OD%0$62+UoQ~Wx& z8NtOC;7aPJT^fFX?>4)o9Ezu(reK`@X(u>;3`PV`d_p(zox1y{0NgvS+J8v*OecN; zx*K0y{pa|a?Qcm4|02HrN3{6=Mtn`nZ)0QYY|nUEIH3J5R+k_u_BRQ1aBV#93K}RM1YZyu;=ub_6Q9?0)hFs6Un61 z@P0h18Wz?CjSJdqN!A22w%0md7yP{%XNF~ULu|T?)3~EvdD;!;RQECrwvL7E_9=p8 z6MXhQsS zFb2JhVd3>ngn3}K(lEH?$>05ZD4-DHIw`3yV>IG|MQtEo(M_3L*hC&2B= zVvM`?+yU=_gw02Etzd%oCkI^l6-Rzx;?HgPt!!pSp82$w{U9Qspg_D%jdrw9_UloJ zEC~{`bg?`_fp4_vp--SO59#0=SSTa?iETYi>LRKMiET~HvanE=h45hZ=BCTJhE5Q( ziXi}neQ8pqPoWCS24_wv6wA`biEX{Ha&1PLn_oE)lCH5hmlB3;Eeq!8sTK(G-Gx&_ zMr%ll7V}PtnPC9$=a0n!{v*i_a{@OQ1VA(J0SEoAIUH;9YW=idez?wX@?8`PDvWA$ zSVjg7MvrY16!e;;FlO=vTzSmXjCY56pE@Wp+?;7mbz?To_k{y$sue+0+X91U5-}Y- zo{sMHob7I4&>IP+7B>&@wdJ!3;b!S~7e9~PoWG{PNPwn6rxOPGFWw6!FevphZj!`r z>gSPnek7e!A*XVcTZkBr{OYMoPd13^Gtl1TOFsr}_2t!{-_-f8p#}MdRjPO}{)(}F z6V{tje99Du*uW<{%O{^bc=H;~#YNNrl&-?A5oA2lN^|dqU8|N_szT)0f3uLJcX8zEW42qY&Xb2x$FO1)l|SxHkzbQBon5p!@2+$pp>hFmvV$e-XAH_N zxJ#grPmdBsS46M*Jv)oYE4G^am>IdPW#9@d7YyqDVi$A@8YJeWXZ%!BvJQoq?u5InDV^eP@fB7o98Y97>8;&28=vF@pNy zVOkox`szpm+H>u`^TIaH`U>mxf&28fxLWGW4z~UZ8t6$Sd={;}HSZw895od-m2EOw zNtGXJ#zI$eZmAMu&Oye%v3rG{R6iyF*mE(9pirU>)ib&%$}vL-MLgo%;i+E7OF>3(1PH)DO8m4)HpRzbpfXD}VS4}hhDl#Ly7O_oyej)_ zOWJNL`dNS{sI9>tS|@bc?-?E>%}X4(R<9%!5W=;lOTYOc&Zh&tLUvMbASBbTMxp z4uB`|4TD>++~o^iN>W7~N8ySKDuTf&JXD_W&M5%FQsvESI_SiL)fY)|!-`pvIrY7n z>IPrHDDqW`e`00-MpOP*R`xFo_J7C9{_m)JvHfRG3Xq*7 zZ=1vse5PxoMqCo)ZIb51fmQoDjm=C1VCxK6Fd(-hk>dAXFQuxBv@`>hue#bzjD za*MLdp3GiZ9U4+nNNfubKy_lI_21mRgYy9Z1Y?2Kc_wFGTm4zEPk>KTWA7N7CQ=a78$$o_2sV_Kch&{NBfoV_IPTMF>AG4 z2ZfkA%7dNM67sLr1Aa|;^K%qguUsJ@A1BQneoV#>yRwkBI#*(cl}VqdxK_q>x`2M z_zJ4iTW|V-P9`Fc09*nb=#g2&wHH`hN{|qa_EW}n8XAUIPAh`X|0c5lfNKLuiY3e; ziI1NMxiz(eRNsyUTfgrT-#6EPw}smbLQht|C>v3sF$j-iA|R=UEwSzBj$>j6p(y}n zS$}18UkF@%D-kcw+)p;tYPDsfD4)wlodyh2u~Z!is*VVhX0#9jr36otMOU6a7|fZ& zKT|GsksC75@e~3)72nEpxkhTO9SkYUQY^2ZN(@rUj=XP9s~?Epg)YmH1@3=%Mj_At^iSXB-vVJB``D+LI%jZD~~g-m;FZyBn*gHYud zi=#>?<%*a4B|SuV0k=TT%v%3ZcyWQ)KY+BE3&^3z!v(M9)y?dp5x{uWTBDyFl--E6p zWsf`;&2_CwfnkcZnPaF0%*z*rSDzRF+X;C{8@$+sjjG0x>qk4G)yZ&$hUjsEU@;34gui?S|`}N=tXl?6U85ps?N*1|tee66miw6u7Bc<4bIJG_>1@MI)VG)@eyENgGx5M$$rOKl~f4Mwp#!6hi~c)c72K?RDOg*zg8VeDVdP`Q!pM>&YKd^-0= zDKf&rM(C&N*@9IE-0R-;m1T8cfsJ79?LxPT3GjQ$T(pC6=bQ<3#vPNIhFER5V;3zw z@0v90%NHb)=%XykQ!Eu`8T)Bz1HuvsJXrz(!31%-zrIMut$Ux*k4Mz%tJf<~wM#B? zID<0*=7rEiGSjb$4m=_)@Xbfl-{O@HLEe=L(Ljd8@2toEe44mtD^vUNZZEM~so_>- zPfSf$XA3;pE*r1GxDZ%^rAniqQK4!PPjU>2_S{-5u?*Q4=d;BAgvCO4*CNLeN@CcG zKWkWJsq9*e0cdeBl{pc$Qe3`^Rj+ zdt1|fh^t9lZQ*px$xINpf;OG`nny;18oApzxSr$0-7vEtH@NAKNHDb?I5U&&7wc3s zFIim=Rsc0ls?;}zOaQQIe;9TGdwN0+XTg5R++Ha8MvrDYB8|7uw>-FP7#Vm}cBG0o zb2R#WeLM8BBCDLej}si8sQm3|(|fZgcSP+8nrXrj;ri`-T~l1%Ng6cLp$_7$9&>|w zkty*w_sEoDouvk|uTAu!RSgrdrr%hL6G`DGA!4C1dQ1vrsfvSp2^08)nFv4K(rwQx z6d6+3OO6e1=iHRo!mXe2{f5EqRhYD09|Rq_#6de8=Tid0AnZ)90?7?yLC=y-N& zZvWKxe#A0d2;)BJ{2Aj{1vHn4=XJG?CN!BhP{6<@n2qR)gasYrk`r{FWEuglXl?(7 z1y5q)Cb0JbyJ85z;G<0toOE001O0TzQi6&`_+{69HEvb7j&%`t_LeU(UQ>5KlgaEf zEuW+CyZC#sF4e^XvsP&ESTgOvSZoPeLs8;|-d~|)cU01hvtWsg?hGvfpCX*7{&!w( zJ($uVDBFnenrJTb0xDKN2eM40lZRbr#a1-`bb>Di-_A$T-1I!|`5=!+9iBQ3aIq+T zOQxldl%mTl=tGmVJg>u+*B*oUMxIxYM~bdag*5DYzW(eu4Ko_znpG(ghJLk?XE@|@ z#yu`aI?8%9*#L1nI=bSJ?XX^+#b0(G0V#^DZz74xz>`5zX*8^lhSg5}0hgNS0F9s7 zr?*m-n;GSV=eBZo`c4SVksCUk_!{sn=>(f7poz1Lj)KyE=d7YEGR;H1C8WlO);(=H z`+jkU6c)b)Jm*9Q@cB7EI0zAI8;;hAEgKy2Q&y40_jHWXDL!HWEs_Oo_&wCS4Rg-b z`;3Wp7_FzMc3J)QLMdfg{%5m&Ltp+$;(X$TCr2$COjIj+!)8-uZG|CvVl@V4=Jj3% zs=He5gFU_Hg3YZZ4Bhyjn2g?-FWhd5fYG6cTj1v1uMbi681mV%*gBA`Ywv=_`yWew zZ#%L2c1)Knw5K-r)8uZkhfbJV`HT1P>)>isSiUTs5Hi=18=8rlkj^*u zce-H6OcDPiQ2F<4)_+6-|F;7bS`lVEwtwg!|Ibr!*!~ICm5q`4e;l$5ehU(>i~O}G zIAMs@g1JR|nTSm3uQ{wjMa(aU1|nQVMS@a#Lm=q8FMBzWAQ_)zJX#XiM>l})YBHte z@)XCL+^i@Jy1bBj-p8aMqIj5irzoFh!G^j)$?+aO-A$Peg`3>{C6BKlg@!er`zSfc zfL+w=Kw!LVR2H7M+HR#vom4GRX2$3Hk`=&_4clhDf;t~nx%ebw`OG>=4_l;eBujR= zadJYH)M|jKS58xJU1xD(lpl{wj#)KK1#hgi-f6QOkDc6#_l0;nZ^CRc>o|}PsR+Zk z8ew+nEbDvIfeI^Y9KsGjtb}<#8E~k09tz0vs@*b<-QxY`8TCMi+f*B99~ZB~%Jy@f zx&|wG73FuKAuxu5Oo3Gyi=%keFZcl$=Ea!T*7f?VBCLkB;baX31XO!{LJts83-^gx%}4==AE%W*OFIY} z+)=q<-Cf2R6oVxC>tN}uKUbRkV94a1GIjb(2b7CPHsa}z zo5E7%F7~6dXg&{mUIcUY&cGg>T1$v4ZITp*R5A8jBF#WB6h^BRSI(|MWp5QN^ys)^ z#c8CNg$?B)7)cz~gN4qV=~pO5)PGKTO0nE?rB2z8%d@FLLZL9)_B)k!q~Fwxv3HEm zC50Mi7J_Q&b_XjX9NT+d#BaC?Z^Q?4A- zgEu+mh7$_pfS)zWvi=(n^9`##1m?GD9!(ujITy5h&=0B{iW4wUqO8~;$5tk>t2!)0 z9RnH@jG>rTs|exIcC22)&YB4VnmQGQ+xZI|6?OT6`XJnjvP*+CEWox2h!c*Ony5_C zdc1c)x7eC0wrPA(ba$fNaVvc(Mj6(9C*@?i^{`^)UPmy+4yeAmJ|1;&@j?6ycxOo3 zVbq|2SH^rwEqinp8}{ZYW|Auulaq9+X9>~_h14sd<{0RJ1+Z3OV#Cr|;R`yr@tj;f zwjzutc|Ufvp@2mSbGtapAcRZv8k-o|!9^~~go|uDsV+SjaiB=QxLcG&ts`|Meb$dI zYble`pK}$~p6RjC$VB=RWzV*VFJbfD&?;R62hdU(>#9H6W~{n{5HKfn_2!A+QBJBN zS$!+ab}vU6U4oD17D$_Q(b$52BG*jsS(>kPF?F8a$%7yS0IZltu=+p9dGS z**U~(J_*G%Xe+wKap)|gIC)=_D2t|_KYDd{V!hx_4Snhwew}%o$#zGJCJqhJvT@wH z0ld)mGvw$#r+ch&V9N#FOj=@b1(r6rl39l$E&=`8mM_i}NC-B#o2R=nIkDe%i&$;6 zrN^)7ijG~jg`*^#y|p+D?T>Um0Jl#14gHg%kWHl~!;MDJE5>uuAjQRQ{J~|6ka{O} znk2DXWcz*e;ljkj^KMvwxQySa0#hQfgRCp^_88)(sF?8*wD-5JS4-+En(FWl>#5TB zIWDs7`7zBNB&~fNi1TaA7*3tk;~-(nr7Z!HdNW>c= zwl*(Vk7@ut04ba2#EI*K4iFm{UdYx#N5$QPZ<%i|(smD9JM5T~DL7SxAFFPHfh$3> z>+n2v(>YUlu%0cns4b~7X1Q3RDO3@?J>1TDZ5z8@mG$~#c5?DD`s?ZbV4Z);WQD{# zieOR{BTY|}S(v{L-Bz7^r+3wG08@vdMeO`8SZPvUCQ?|17;#5aX3({SHcO(^O)#I! zkobO5|0ZRWs*|LP7_Nbc3{tD(Aat}$pKYSTc{iwin8=K4cpx#YsMi>9>r<7l#%)))KoZQ3xx-7LN<0NA_*jwxJR*nx~0M6IfuQmeq-r#}NnGUayYU2LEb*c5fdL(a-wQ{wk-e zeDwJc5)Jm@!8K4@?kHv3}Y~-=Ak+sU!>{zOHk|k2$;W zSZiuD2{;HA$S|WDWlQSl?dY)@gtuiXm{eqsktb==jZ~DpCO5M*osljS1@B{UW_|Mw z%xvJuw3S^1Y)!rchg>5APdvZ8&phT-P-Jki55R$6uo^4D_DBYDhDCI8#lkgDE_A+@ zT48`}D@Wq1WjwR#)_GT3Lj` z^A7|@gV>}hq3tTUHrzQw2R*lXh&U<&kGI* zC(;`S?j7ig^-44s!)M;{Lf}3EU4dVqBDRanArlT=Rj9{mil`e2UXUvfrw0J z<-);ag$nciERz+!gqcAKQj0Jw=73zk3&hj+FJ>zaQvFceOg(IV*1c}(7xoy7h|9XQH+#RY=LV!?$h2D!N((Xo2b71bXsN#dQgsHUd7`gi>} zw*s91oKaVef5R9Uk4?fC4^11Oi_SU0w~FGItc9<$V`Mn;TEz}5ukvl6XF&KS4=PzI zz~DhAa3DkR=}(F^D_k>0-SGQ<>RWq$?LT8~y>-INQqP3DEt@<2n7in*h@^9gazlJ{ zj$x_sBb%`}ruQl!0TK~lF~A=o!1N@RnO`>B@~H?N2J>VRfw0TB<&*gE2go$$%rCMd zy<@&VXSl`Z2)>;B%{_8kd1YRlPOC)MPrwJG_FBEJ#9lp|+;NT8Y!u-Sh;nA9c%~V- z9$7zwfNpab88*~tDE~pk84Bxc6)QlQ6g)2JGV7ri5px&y)J40l++Tjbh2*67Yja1v zA>+M4uyX_Qms{8(Y19Z#LEzD`q37@@LUN1%0JD-EpxHL*zH1_70{5OGmyrUc>yijy z+12Eeo;>kkF+Jn6LNN-m_hp65!1dA-Y=Wtb%KwS|mJ z3gneXSPh8R6c=5crqMdh6N~n=N{g0b&rNjm|iT zk&@;(bn0K4O0egni-*Qszq1C=RErt^APrI>@=bdnefgk%pwzd>kH7nFX8dSL4MX6m zl1ngVhvsWi$9Uk?o+5l^Iz?LGt~?3xo-x9@c)7MeD}a{Vb2k;%QdVl>my7WzqJJO5M7eT_F)y=f9h**d`O6VnMp z7+(WdY@}Q{zBpVAw8zAInb^+cDgkxs)9$6{z~ZEQ)x4(XCzLfe_y<5}-;KQAQVa?GDyJL~nA-docVwMAg2&%OH}{v@+|m&e{0iT6lN==5*qAaVS`N>}Wr{@nqpuoO<4k?hBX{ z6W{coT`u;&CGz~MbLD?frD&D@$`g{)H#Ppw6LPe5b}%${{LVL$bFej3G4xBl0h^qyBf!mD&HsKl`sP7abkb|9F$; zQcW{)UIf)=xtdM(f{#A>>X%imGG8i6DG`-k0(gjmdBKxfI2DGtiGacj?Mtbr%r@01 z&Ulb`c1mwkOxxRe^|bb@9=Em{%RpEE9y)69qnCbX9giAIeJ7b8=6JBJ{k!RS?XKtf zrY9!Ucq~2?L3(!+5U)X1JSFuoPrWzF$82F*W1UZ(#W>)rWi_={V$hCA{C-?da>#ST`(kjV^H8T{Pp9EO&3;jA(}oxJnPx@@ zkn#OmSdRjz^DjVXS;O-Vg~ssa!9?Sy$g>k9>+!VkAI>{*$f{W$cR?6uOU_oP?40G4 zt0m-+>I9W+9ZdCb?Q@87xuVN5BaMxFQ6<`=6~Ch->BH4hqsU>g#o?-Le{->~&V+*v z3=4^_gyM^6nIaZlka)1|@W~vE1(Ju#*V*F@^FK>Q4ND1gztLcgfW0P8>;VusO@&QW z4Ehnn<@ojT2b>ESF;344*aSn~PpYBUlP#4u;33%OA<4_K6{!qPF#0)VX?oDo=ZS?8 z69%-hb+jFZOu)NjZu$kMGn^&<8OJWrBa@V$MT&fA>|u=BgeW~>P8~rGBn1&vk0wW& zjp-i3lq+)Dza}#TazviQsKh>_9%$63A{vySnGNt`jFJ~3@j$eoWpERqOIl3bZP>3y zG|p|ik9sY%@jOQKFtrc*7|Vx_LYg}?2#=S2#zt6SaTHXmsI2!H)X#c+DXXaV_dRfi zH}>B?tUI7Kat74iwz>CNcNjTQbcVI6YYH`i{3yG~Iby9jz?l4V_PJ+z7HLO_x&nt| zAv&;4NMJBy=zO9?I+-}Qr~djrEF6JWJ&(q#)gjgGb9d>+aj}@j2>*U7{^Z<^xoF=+MfJU2F44jfo zHoc}yAH^q1wyqvX;VX11gPQ`dPs^q)rA#&W#a!lO<$`;g#f=3wJ|#-btG&xhq}QZM zunZ?*3Ao!@$>#MsvHH9guJ(>4+n zt+iF6(~1|n^ef$KO_!NH=;z_y05Qvh2p2$KSpcYdwa=jsjKZsvxxPC3)Ez6ziY0E-Kl%7{ozp)X*$vOi1d*sx5F(FT*aZlG5b1xH zg{qI~*P{5cz@d*J#}l&o2A7EAZobwa%oq^*$LRVka+G|zH|9O9Z0jI<`qtlH;N7XC zk1+GPO;;;EW2WOpg94DTxYM>F7((uUWPWfmYjt>id?X4-n7X|h=--VXw)D*7z;*Y( zJ8jSMz|>HmZ$Z+-h5?K3PjMDsldQ1=ipl?f&0Tp|Q^yvUf-FLD-%5q6PXw!yyXRgN zl+`K%C9(*zG?0LS5HtyvR0OIhZr}p4C{UFmDil#FxPVrXq9P)qfS_zDqG&-;D4V`} z6PGN0@AZBC=jES#`Q_ZR&6zW2CX<=OzTJ$rqdDWj{7idPv!VO3>(Be(A5!>-OX3>z zzN*hzZIW86f4ZQwJEdpct9-ZFRqu4)elI8~Xf9ZRb(ZDnPmIQVpB!*X4(v;08Qo-L zQ~NtE_GKkLO+J?XxNE4_@^Gg1JuCOOe;DY^8Yz^#OT6-gU2}Y+`rDMB<3@Wl^qug` z7(UGWtIaI6-=~cgH;r1n+EJ<5o1ZB#w!Bw1&~eSs`L!T4d`H=cB<_xV!bazcg<*o4 z&1p^Wx%$!Jr~3Zll?7`Y`7>=sOz#|#ewCZc>QOg#u6|zpWS-kIID1lFu5QpI(!0}Y z-k?==HAWU%*Bmbie(CP9Bqe5e45)o_ZBSCl!QY|zfrDf+>t{~cnu2e7 z?&cTkH8hBFvouqrZEej&_Ezat$yY-~_)@tvg&KjHn58JAjAq|nY2dAC9S5o5Ocr8l5)~)Y% zJbmYL7u)7vF5Yi^Hr-|F0}nHDOVmqJBOlaiJxUfI_yKqqHBVIBGV{>1YTXwvyZ-c! zoMQUs*bn`zyxyi4PCiY$+>9b5f)Q65D^9D8X)|mRFL-G<;Ie)E)sts3!&gP@IBxIs zU_o}-7M)~P4dB(Aq!r;YT}v&jdru|W7Wa{iU_T|Li^S>PEQxq`tqmXI48P3&@|dxec5!t3V{fuQpb>O0w;iTUNot}U4ogW!;Uv%jqJ!5K5_rknrk zNy*$Z-=}5n6qP?@8@ATZjd{Cc?ygc{`_n!zQ`5u9)~)Nv>Yq#MW{lMto;o`#sHHNd zt$yh2CcCKRMa01cWl^QjFa(qd5!HvTf@E2#3xVV(X6!=gmwy$!+3|TgJQ0aDEEz3coTmmTTB{9R`VZ zb?!X9#M7(8XJG-rMdM z=em4bD=@?A@_qI~s-S!w+gbL7fHQ1cyW4$fn)Us{u)=4aI-B_qQGx$aV~f4MZ9{%9 zx9#uR&E;NEIm~j_Bm*6P#CG4hvoQ|$7pFCsFBrI%vp&_T_(8kJxFQc% z{FYmZx6VAPgZ++Hr?;HBANQ>w_}g%U#1ept`9!mnuV}CkQpWa@PAz%;wn{I+WP^MeJrGMvEdN`pgHC|FjMrO3w;d ze%&0{Jo52!FWzlqJGLZtppsR#R$|iFm|ZkETitJmVOH>|SB}+lADic%ho`&yJP+O| z!OPPHzEj(#+ZYvD3dR(i3QOnej^Fqwt9?n=*W+ z%n*}Drl`B#jqWLUlef#Wrq=uRy3;I4v0JcYa$QGAO^U=s^k}`IaaxLrw|7lY{fW{0 z1izfi8<+ljF5h!%_Eq!dFLP!!xlYSFRJft>6|X3K-!LlS%@z)pJD z;h@FF?vpQ9@P-#@MB7dZigvENRWP-({YAlRD`Io_iyX_Nwer=etbU$}(eNXKfF=ywTXL}<1qQl0Xy-{6TwKYv!;_Gup z3{7z|;w{dMHjgzq_h2D3a?N_R6F!#)eVfffEiOb3x3>p0I2hqO4KB{ExajEAd-;OC znsr0!>T$Xg8Kvqt_1m6L%>|LbkFURhtj9{bi3UCZK7s`V0rLE z!|&XFBirk}R`Ab`T<32CZ|EIJ{-Jb5*qHB%%e6MuByP^sE;8VFEW2X2tTCn5vldPn z{3+&-yxckSgQ{zw2R=*Zm9BG^i4|lUU_?S1^zsp>2F6=h+TUxq7RH ze$(pSqm3IzY;EUtSs%z7{qVw2RPm@&SBumK0{sTgUtD@VgB>im?Rj&wptc~V$7b+S zl%-~LbibGH;|bB@Mt8Tj-!am8!b-DrEHf`FcU*M5>s~}!%dJDYGs+G2U+=Cm!R^lh zkNSr;-ipXFa~LqnjZ*X5-W2Gf^!xd_${;4))$sp2KbPA?@xcPwC73o`k$4q7 zduK6LdU#UrOpIwpP`?3rGhBFLKG#$PA>qCPVE`5mgzy4|Y%woX0B}P6!$PQIO=f>O zjf9ljb0S@)a0(Oic>=D8VI3MK5CafnIa?$KNLmvXwJ;$3_~8=|xxar|u|-^Zse zm%olH=J~VdS%vaBG7n3?uod`+a(IG3hC5GSDG>2Ke*SQt3ath7iMd=QqRRXq@Rh3% zKJukZ7V@~lf4~)zYcXZE|I`!GEjaWEGSoWIN8X?O?BvJitqtS;1LfsH;X}01zbeWV zc^{(!WZ3gKB3T3iQX&ANm%~^9B&`zxNZPXiNE)sHBwYssU}?kxFx{ps0G6K2C-*-> zSk8HWQvp~e8*NY(yp-k&&P>5>!Tl%1BTtiJS`5zD*E#@8iFz0xGi&li7yJ zY{R6s0hqMg0GNyfmyzHy5?n@tOG)HZkY1$qzo{U-j*A6IZxo>3WVSJ7<}+pHOaE%h z0tlIGLiQbebG9r<=@ror z5rw{IBvVWp2`oU`8Z1C|wHP2v-tubFZhfz&GCcPr5iO)gADY0FVo^(q%S-Vrjz`b4_jL z!yv>2aRh`Q1VPa`AZ!AHCbJpVLasFN{zs}$vcrYkfKk+0RUkBqI`Q`X3&1f9!GHkZ zJqBZRtI;n&@E#*EjP{KZhSPfml`tlgY9|GZ`T(iW;UMjKMLL*CH-jREfpo|zVKChV z6fvBnLthbNLZ}KI!BnvWBuJ*Reh`S!0iwVU0-1CIQp6CD&H)M-i4k;fRKOqvrW2GR zhNFZkh7-#6LL>~U$R$xo*)|v=FlC=oPom0xfl&fc!7vb}`m}<6lt<|fu7JTfLQi{@ zFpSOsiWmXWx`f{ zonsXF;TWAnl`tlqkQFf!p~p@o45M!-RKQROrbh`S3{~+xih!W9|4_>Mo^){ z2^Bw6>k=wtA*ZAZ6++4~P!gk4n4-=k6IZqugGf+0b}?$ktt0bUDuo4W;H-lg8?|~7XbQmLH_`R z3v#G|8R2pf%wi$NK>|p~-=B@55X$DF{)9ghA^b2D;vz6YFfF_pOQ};VscM1}NwHnQ e`;kkR7F4+*60?P3X|X{kcyyGpv8|KcsDA@o1}jDY diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.build_log.htm b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.build_log.htm deleted file mode 100644 index 8a4dcf3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.build_log.htm +++ /dev/null @@ -1,103 +0,0 @@ - - -
-

µVision Build Log

-

Tool Versions:

-IDE-Version: µVision V5.17.0.0 -Copyright (C) 2015 ARM Ltd and ARM Germany GmbH. All rights reserved. -License Information: Jonathan Fattouh Insight SiP Flex license: MDK-ARM Standard Cortex-M only: 1 user(s) (mdk_cm_std) Operation stops: 30 Jun 2018 - -Tool Versions: -Toolchain: MDK-ARM Standard Cortex-M only: 1 user(s) Version: 5.17 -Toolchain Path: C:\Keil_v5\ARM\ARMCC\Bin -C Compiler: Armcc.exe V5.06 update 1 (build 61) -Assembler: Armasm.exe V5.06 update 1 (build 61) -Linker/Locator: ArmLink.exe V5.06 update 1 (build 61) -Library Manager: ArmAr.exe V5.06 update 1 (build 61) -Hex Converter: FromElf.exe V5.06 update 1 (build 61) -CPU DLL: -Dialog DLL: -Target DLL: Segger\JL2CM3.dll V2.99.16.0 -Dialog DLL: TCM.DLL V1.14.6.0 - -

Project:

-C:\Workspace\Software\Projects\BLE_LORA\Embedded\ble_app_proximity\src\isp1708\s132\arm5_no_packs\ble_app_proximity_isp1708_s132.uvprojx -Project File Date: 05/24/2018 - -

Output:

-*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' -Build target 'flash_s132_nrf52_5.0.0_softdevice' -Before Build - User command #1: attrib +R ..\..\..\..\..\..\..\..\SDK\nRF5_SDK_14.2.0_17b948a\components\softdevice\s132\hex\\* -compiling spi-board.c... -..\..\..\..\boards\board.h(10): error: #5: cannot open source input file "nrf_gpio.h": No such file or directory - #include "nrf_gpio.h" -..\..\..\..\boards\spi-board.c: 0 warnings, 1 error -compiling board.c... -..\..\..\..\boards\board.h(10): error: #5: cannot open source input file "nrf_gpio.h": No such file or directory - #include "nrf_gpio.h" -..\..\..\..\boards\board.c: 0 warnings, 1 error -compiling main.c... -..\..\..\main.c(58): error: #5: cannot open source input file "ble_advertising.h": No such file or directory - #include "ble_advertising.h" -..\..\..\main.c: 0 warnings, 1 error -compiling timer.c... -..\..\..\system\timer.c(22): error: #5: cannot open source input file "board.h": No such file or directory - #include "board.h" -..\..\..\system\timer.c: 0 warnings, 1 error -compiling delay.c... -..\..\..\system\delay.c(23): error: #5: cannot open source input file "nrf_delay.h": No such file or directory - #include "nrf_delay.h" -..\..\..\system\delay.c: 0 warnings, 1 error -compiling sx1276-board.c... -..\..\..\..\boards\board.h(10): error: #5: cannot open source input file "nrf_gpio.h": No such file or directory - #include "nrf_gpio.h" -..\..\..\..\boards\sx1276-board.c: 0 warnings, 1 error -compiling sx1276.c... -..\..\..\radio\sx1276\sx1276.c(17): error: #5: cannot open source input file "board.h": No such file or directory - #include "board.h" -..\..\..\radio\sx1276\sx1276.c: 0 warnings, 1 error -compiling nrf_drv_spi.c... -..\..\..\..\..\..\..\..\SDK\nRF5_SDK_14.2.0_17b948a\components\drivers_nrf\spi_master\nrf_drv_spi.c(40): error: #5: cannot open source input file "sdk_common.h": No such file or directory - #include "sdk_common.h" -..\..\..\..\..\..\..\..\SDK\nRF5_SDK_14.2.0_17b948a\components\drivers_nrf\spi_master\nrf_drv_spi.c: 0 warnings, 1 error -compiling utilities.c... -..\..\..\..\boards\board.h(10): error: #5: cannot open source input file "nrf_gpio.h": No such file or directory - #include "nrf_gpio.h" -..\..\..\..\boards\utilities.c: 0 warnings, 1 error -compiling gpio-board.c... -..\..\..\..\boards\board.h(10): error: #5: cannot open source input file "nrf_gpio.h": No such file or directory - #include "nrf_gpio.h" -..\..\..\..\boards\gpio-board.c: 0 warnings, 1 error -"..\..\..\..\..\..\..\..\SDK\nRF5_SDK_14.2.0_17b948a\components\softdevice\s132\hex\s132_nrf52_5.0.0_softdevice.hex" - 10 Error(s), 0 Warning(s). - -

Software Packages used:

- -Package Vendor: ARM - http://www.keil.com/pack/ARM.CMSIS.5.0.1.pack - ARM::CMSIS:CORE:5.0.1 - CMSIS (Cortex Microcontroller Software Interface Standard) - * Component: CORE Version: 5.0.1 - -Package Vendor: NordicSemiconductor - http://developer.nordicsemi.com/nRF5_SDK/pieces/nRF_DeviceFamilyPack/NordicSemiconductor.nRF_DeviceFamilyPack.8.16.0.pack - NordicSemiconductor::Device:Startup:8.16.0 - Nordic Semiconductor nRF ARM devices Device Family Pack with Nordic License. - * Component: Startup Version: 8.16.0 - -

Collection of Component include folders:

- C:\Workspace\Software\Projects\BLE_LORA\Embedded\ble_app_proximity\src\isp1708\s132\arm5_no_packs\RTE - C:\Keil_v5\ARM\PACK\NordicSemiconductor\nRF_DeviceFamilyPack\8.16.0\Device\Include - -

Collection of Component Files used:

- - * Component: ARM::CMSIS:CORE:5.0.1 - - * Component: NordicSemiconductor::Device:Startup:8.16.0 - Source file: Device\Source\system_nrf52.c - Include file: Device\Include\system_nrf52.h - Source file: Device\Source\arm\arm_startup_nrf52.s -Target not created. -Build Time Elapsed: 00:00:00 -
- - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.sct b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.sct deleted file mode 100644 index 359d5dd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.sct +++ /dev/null @@ -1,15 +0,0 @@ -; ************************************************************* -; *** Scatter-Loading Description File generated by uVision *** -; ************************************************************* - -LR_IROM1 0x00023000 0x0005D000 { ; load region size_region - ER_IROM1 0x00023000 0x0005D000 { ; load address = execution address - *.o (RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) - } - RW_IRAM1 0x200020E0 0x0000DF20 { ; RW data - .ANY (+RW +ZI) - } -} - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld deleted file mode 100644 index 1ae0828..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x23000, LENGTH = 0x5d000 - RAM (rwx) : ORIGIN = 0x20001368, LENGTH = 0xec98 - -} - -SECTIONS -{ -} - -SECTIONS -{ - . = ALIGN(4); - .mem_section_dummy_ram : - { - } - -} INSERT AFTER .data; - -SECTIONS -{ - .mem_section_dummy_rom : - { - } - - -} INSERT AFTER .text - -INCLUDE "nrf5x_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf51.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf51.s deleted file mode 100644 index 668f3cd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf51.s +++ /dev/null @@ -1,259 +0,0 @@ -; Copyright (c) 2009-2017 ARM Limited. All rights reserved. -; -; SPDX-License-Identifier: Apache-2.0 -; -; Licensed under the Apache License, Version 2.0 (the License); you may -; not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an AS IS BASIS, WITHOUT -; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; NOTICE: This file has been modified by Nordic Semiconductor ASA. - - IF :DEF: __STARTUP_CONFIG -#include "startup_config.h" -#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT -#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 -#endif - ENDIF - - IF :DEF: __STARTUP_CONFIG -Stack_Size EQU __STARTUP_CONFIG_STACK_SIZE - ELIF :DEF: __STACK_SIZE -Stack_Size EQU __STACK_SIZE - ELSE -Stack_Size EQU 2048 - ENDIF - - IF :DEF: __STARTUP_CONFIG -Stack_Align EQU __STARTUP_CONFIG_STACK_ALIGNEMENT - ELSE -Stack_Align EQU 3 - ENDIF - - AREA STACK, NOINIT, READWRITE, ALIGN=Stack_Align -Stack_Mem SPACE Stack_Size -__initial_sp - - IF :DEF: __STARTUP_CONFIG -Heap_Size EQU __STARTUP_CONFIG_HEAP_SIZE - ELIF :DEF: __HEAP_SIZE -Heap_Size EQU __HEAP_SIZE - ELSE -Heap_Size EQU 2048 - ENDIF - - AREA HEAP, NOINIT, READWRITE, ALIGN=3 -__heap_base -Heap_Mem SPACE Heap_Size -__heap_limit - - PRESERVE8 - THUMB - -; Vector Table Mapped to Address 0 at Reset - - AREA RESET, DATA, READONLY - EXPORT __Vectors - EXPORT __Vectors_End - EXPORT __Vectors_Size - -__Vectors DCD __initial_sp ; Top of Stack - DCD Reset_Handler - DCD NMI_Handler - DCD HardFault_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD PendSV_Handler - DCD SysTick_Handler - - ; External Interrupts - DCD POWER_CLOCK_IRQHandler - DCD RADIO_IRQHandler - DCD UART0_IRQHandler - DCD SPI0_TWI0_IRQHandler - DCD SPI1_TWI1_IRQHandler - DCD 0 ; Reserved - DCD GPIOTE_IRQHandler - DCD ADC_IRQHandler - DCD TIMER0_IRQHandler - DCD TIMER1_IRQHandler - DCD TIMER2_IRQHandler - DCD RTC0_IRQHandler - DCD TEMP_IRQHandler - DCD RNG_IRQHandler - DCD ECB_IRQHandler - DCD CCM_AAR_IRQHandler - DCD WDT_IRQHandler - DCD RTC1_IRQHandler - DCD QDEC_IRQHandler - DCD LPCOMP_IRQHandler - DCD SWI0_IRQHandler - DCD SWI1_IRQHandler - DCD SWI2_IRQHandler - DCD SWI3_IRQHandler - DCD SWI4_IRQHandler - DCD SWI5_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - -__Vectors_End - -__Vectors_Size EQU __Vectors_End - __Vectors - - AREA |.text|, CODE, READONLY - -; Reset Handler - -NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address -NRF_POWER_RAMONB_ADDRESS EQU 0x40000554 ; NRF_POWER->RAMONB address -NRF_POWER_RAMONx_RAMxON_ONMODE_Msk EQU 0x3 ; All RAM blocks on in onmode bit mask - -Reset_Handler PROC - EXPORT Reset_Handler [WEAK] - IMPORT SystemInit - IMPORT __main - - MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk - - LDR R0, =NRF_POWER_RAMON_ADDRESS - LDR R2, [R0] - ORRS R2, R2, R1 - STR R2, [R0] - - LDR R0, =NRF_POWER_RAMONB_ADDRESS - LDR R2, [R0] - ORRS R2, R2, R1 - STR R2, [R0] - - LDR R0, =SystemInit - BLX R0 - LDR R0, =__main - BX R0 - ENDP - -; Dummy Exception Handlers (infinite loops which can be modified) - -NMI_Handler PROC - EXPORT NMI_Handler [WEAK] - B . - ENDP -HardFault_Handler\ - PROC - EXPORT HardFault_Handler [WEAK] - B . - ENDP -SVC_Handler PROC - EXPORT SVC_Handler [WEAK] - B . - ENDP -PendSV_Handler PROC - EXPORT PendSV_Handler [WEAK] - B . - ENDP -SysTick_Handler PROC - EXPORT SysTick_Handler [WEAK] - B . - ENDP - -Default_Handler PROC - - EXPORT POWER_CLOCK_IRQHandler [WEAK] - EXPORT RADIO_IRQHandler [WEAK] - EXPORT UART0_IRQHandler [WEAK] - EXPORT SPI0_TWI0_IRQHandler [WEAK] - EXPORT SPI1_TWI1_IRQHandler [WEAK] - EXPORT GPIOTE_IRQHandler [WEAK] - EXPORT ADC_IRQHandler [WEAK] - EXPORT TIMER0_IRQHandler [WEAK] - EXPORT TIMER1_IRQHandler [WEAK] - EXPORT TIMER2_IRQHandler [WEAK] - EXPORT RTC0_IRQHandler [WEAK] - EXPORT TEMP_IRQHandler [WEAK] - EXPORT RNG_IRQHandler [WEAK] - EXPORT ECB_IRQHandler [WEAK] - EXPORT CCM_AAR_IRQHandler [WEAK] - EXPORT WDT_IRQHandler [WEAK] - EXPORT RTC1_IRQHandler [WEAK] - EXPORT QDEC_IRQHandler [WEAK] - EXPORT LPCOMP_IRQHandler [WEAK] - EXPORT SWI0_IRQHandler [WEAK] - EXPORT SWI1_IRQHandler [WEAK] - EXPORT SWI2_IRQHandler [WEAK] - EXPORT SWI3_IRQHandler [WEAK] - EXPORT SWI4_IRQHandler [WEAK] - EXPORT SWI5_IRQHandler [WEAK] -POWER_CLOCK_IRQHandler -RADIO_IRQHandler -UART0_IRQHandler -SPI0_TWI0_IRQHandler -SPI1_TWI1_IRQHandler -GPIOTE_IRQHandler -ADC_IRQHandler -TIMER0_IRQHandler -TIMER1_IRQHandler -TIMER2_IRQHandler -RTC0_IRQHandler -TEMP_IRQHandler -RNG_IRQHandler -ECB_IRQHandler -CCM_AAR_IRQHandler -WDT_IRQHandler -RTC1_IRQHandler -QDEC_IRQHandler -LPCOMP_IRQHandler -SWI0_IRQHandler -SWI1_IRQHandler -SWI2_IRQHandler -SWI3_IRQHandler -SWI4_IRQHandler -SWI5_IRQHandler - B . - ENDP - ALIGN - -; User Initial Stack & Heap - - IF :DEF:__MICROLIB - - EXPORT __initial_sp - EXPORT __heap_base - EXPORT __heap_limit - - ELSE - - IMPORT __use_two_region_memory - EXPORT __user_initial_stackheap - -__user_initial_stackheap PROC - - LDR R0, = Heap_Mem - LDR R1, = (Stack_Mem + Stack_Size) - LDR R2, = (Heap_Mem + Heap_Size) - LDR R3, = Stack_Mem - BX LR - ENDP - - ALIGN - - ENDIF - - END diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52810.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52810.s deleted file mode 100644 index 6f9d902..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52810.s +++ /dev/null @@ -1,349 +0,0 @@ -; Copyright (c) 2009-2017 ARM Limited. All rights reserved. -; -; SPDX-License-Identifier: Apache-2.0 -; -; Licensed under the Apache License, Version 2.0 (the License); you may -; not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an AS IS BASIS, WITHOUT -; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; NOTICE: This file has been modified by Nordic Semiconductor ASA. - - IF :DEF: __STARTUP_CONFIG -#include "startup_config.h" -#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT -#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 -#endif - ENDIF - - IF :DEF: __STARTUP_CONFIG -Stack_Size EQU __STARTUP_CONFIG_STACK_SIZE - ELIF :DEF: __STACK_SIZE -Stack_Size EQU __STACK_SIZE - ELSE -Stack_Size EQU 2048 - ENDIF - - IF :DEF: __STARTUP_CONFIG -Stack_Align EQU __STARTUP_CONFIG_STACK_ALIGNEMENT - ELSE -Stack_Align EQU 3 - ENDIF - - AREA STACK, NOINIT, READWRITE, ALIGN=Stack_Align -Stack_Mem SPACE Stack_Size -__initial_sp - - IF :DEF: __STARTUP_CONFIG -Heap_Size EQU __STARTUP_CONFIG_HEAP_SIZE - ELIF :DEF: __HEAP_SIZE -Heap_Size EQU __HEAP_SIZE - ELSE -Heap_Size EQU 2048 - ENDIF - - AREA HEAP, NOINIT, READWRITE, ALIGN=3 -__heap_base -Heap_Mem SPACE Heap_Size -__heap_limit - - PRESERVE8 - THUMB - -; Vector Table Mapped to Address 0 at Reset - - AREA RESET, DATA, READONLY - EXPORT __Vectors - EXPORT __Vectors_End - EXPORT __Vectors_Size - -__Vectors DCD __initial_sp ; Top of Stack - DCD Reset_Handler - DCD NMI_Handler - DCD HardFault_Handler - DCD MemoryManagement_Handler - DCD BusFault_Handler - DCD UsageFault_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler - DCD DebugMon_Handler - DCD 0 ; Reserved - DCD PendSV_Handler - DCD SysTick_Handler - - ; External Interrupts - DCD POWER_CLOCK_IRQHandler - DCD RADIO_IRQHandler - DCD UARTE0_IRQHandler - DCD TWIM0_TWIS0_IRQHandler - DCD SPIM0_SPIS0_IRQHandler - DCD 0 ; Reserved - DCD GPIOTE_IRQHandler - DCD SAADC_IRQHandler - DCD TIMER0_IRQHandler - DCD TIMER1_IRQHandler - DCD TIMER2_IRQHandler - DCD RTC0_IRQHandler - DCD TEMP_IRQHandler - DCD RNG_IRQHandler - DCD ECB_IRQHandler - DCD CCM_AAR_IRQHandler - DCD WDT_IRQHandler - DCD RTC1_IRQHandler - DCD QDEC_IRQHandler - DCD COMP_IRQHandler - DCD SWI0_EGU0_IRQHandler - DCD SWI1_EGU1_IRQHandler - DCD SWI2_IRQHandler - DCD SWI3_IRQHandler - DCD SWI4_IRQHandler - DCD SWI5_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD PWM0_IRQHandler - DCD PDM_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - -__Vectors_End - -__Vectors_Size EQU __Vectors_End - __Vectors - - AREA |.text|, CODE, READONLY - -; Reset Handler - - -Reset_Handler PROC - EXPORT Reset_Handler [WEAK] - IMPORT SystemInit - IMPORT __main - - - LDR R0, =SystemInit - BLX R0 - LDR R0, =__main - BX R0 - ENDP - -; Dummy Exception Handlers (infinite loops which can be modified) - -NMI_Handler PROC - EXPORT NMI_Handler [WEAK] - B . - ENDP -HardFault_Handler\ - PROC - EXPORT HardFault_Handler [WEAK] - B . - ENDP -MemoryManagement_Handler\ - PROC - EXPORT MemoryManagement_Handler [WEAK] - B . - ENDP -BusFault_Handler\ - PROC - EXPORT BusFault_Handler [WEAK] - B . - ENDP -UsageFault_Handler\ - PROC - EXPORT UsageFault_Handler [WEAK] - B . - ENDP -SVC_Handler PROC - EXPORT SVC_Handler [WEAK] - B . - ENDP -DebugMon_Handler\ - PROC - EXPORT DebugMon_Handler [WEAK] - B . - ENDP -PendSV_Handler PROC - EXPORT PendSV_Handler [WEAK] - B . - ENDP -SysTick_Handler PROC - EXPORT SysTick_Handler [WEAK] - B . - ENDP - -Default_Handler PROC - - EXPORT POWER_CLOCK_IRQHandler [WEAK] - EXPORT RADIO_IRQHandler [WEAK] - EXPORT UARTE0_IRQHandler [WEAK] - EXPORT TWIM0_TWIS0_IRQHandler [WEAK] - EXPORT SPIM0_SPIS0_IRQHandler [WEAK] - EXPORT GPIOTE_IRQHandler [WEAK] - EXPORT SAADC_IRQHandler [WEAK] - EXPORT TIMER0_IRQHandler [WEAK] - EXPORT TIMER1_IRQHandler [WEAK] - EXPORT TIMER2_IRQHandler [WEAK] - EXPORT RTC0_IRQHandler [WEAK] - EXPORT TEMP_IRQHandler [WEAK] - EXPORT RNG_IRQHandler [WEAK] - EXPORT ECB_IRQHandler [WEAK] - EXPORT CCM_AAR_IRQHandler [WEAK] - EXPORT WDT_IRQHandler [WEAK] - EXPORT RTC1_IRQHandler [WEAK] - EXPORT QDEC_IRQHandler [WEAK] - EXPORT COMP_IRQHandler [WEAK] - EXPORT SWI0_EGU0_IRQHandler [WEAK] - EXPORT SWI1_EGU1_IRQHandler [WEAK] - EXPORT SWI2_IRQHandler [WEAK] - EXPORT SWI3_IRQHandler [WEAK] - EXPORT SWI4_IRQHandler [WEAK] - EXPORT SWI5_IRQHandler [WEAK] - EXPORT PWM0_IRQHandler [WEAK] - EXPORT PDM_IRQHandler [WEAK] -POWER_CLOCK_IRQHandler -RADIO_IRQHandler -UARTE0_IRQHandler -TWIM0_TWIS0_IRQHandler -SPIM0_SPIS0_IRQHandler -GPIOTE_IRQHandler -SAADC_IRQHandler -TIMER0_IRQHandler -TIMER1_IRQHandler -TIMER2_IRQHandler -RTC0_IRQHandler -TEMP_IRQHandler -RNG_IRQHandler -ECB_IRQHandler -CCM_AAR_IRQHandler -WDT_IRQHandler -RTC1_IRQHandler -QDEC_IRQHandler -COMP_IRQHandler -SWI0_EGU0_IRQHandler -SWI1_EGU1_IRQHandler -SWI2_IRQHandler -SWI3_IRQHandler -SWI4_IRQHandler -SWI5_IRQHandler -PWM0_IRQHandler -PDM_IRQHandler - B . - ENDP - ALIGN - -; User Initial Stack & Heap - - IF :DEF:__MICROLIB - - EXPORT __initial_sp - EXPORT __heap_base - EXPORT __heap_limit - - ELSE - - IMPORT __use_two_region_memory - EXPORT __user_initial_stackheap - -__user_initial_stackheap PROC - - LDR R0, = Heap_Mem - LDR R1, = (Stack_Mem + Stack_Size) - LDR R2, = (Heap_Mem + Heap_Size) - LDR R3, = Stack_Mem - BX LR - ENDP - - ALIGN - - ENDIF - - END diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52840.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52840.s deleted file mode 100644 index ff9d60d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/arm_startup_nrf52840.s +++ /dev/null @@ -1,381 +0,0 @@ -; Copyright (c) 2009-2017 ARM Limited. All rights reserved. -; -; SPDX-License-Identifier: Apache-2.0 -; -; Licensed under the Apache License, Version 2.0 (the License); you may -; not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an AS IS BASIS, WITHOUT -; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; NOTICE: This file has been modified by Nordic Semiconductor ASA. - - IF :DEF: __STARTUP_CONFIG -#include "startup_config.h" -#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT -#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 -#endif - ENDIF - - IF :DEF: __STARTUP_CONFIG -Stack_Size EQU __STARTUP_CONFIG_STACK_SIZE - ELIF :DEF: __STACK_SIZE -Stack_Size EQU __STACK_SIZE - ELSE -Stack_Size EQU 8192 - ENDIF - - IF :DEF: __STARTUP_CONFIG -Stack_Align EQU __STARTUP_CONFIG_STACK_ALIGNEMENT - ELSE -Stack_Align EQU 3 - ENDIF - - AREA STACK, NOINIT, READWRITE, ALIGN=Stack_Align -Stack_Mem SPACE Stack_Size -__initial_sp - - IF :DEF: __STARTUP_CONFIG -Heap_Size EQU __STARTUP_CONFIG_HEAP_SIZE - ELIF :DEF: __HEAP_SIZE -Heap_Size EQU __HEAP_SIZE - ELSE -Heap_Size EQU 8192 - ENDIF - - AREA HEAP, NOINIT, READWRITE, ALIGN=3 -__heap_base -Heap_Mem SPACE Heap_Size -__heap_limit - - PRESERVE8 - THUMB - -; Vector Table Mapped to Address 0 at Reset - - AREA RESET, DATA, READONLY - EXPORT __Vectors - EXPORT __Vectors_End - EXPORT __Vectors_Size - -__Vectors DCD __initial_sp ; Top of Stack - DCD Reset_Handler - DCD NMI_Handler - DCD HardFault_Handler - DCD MemoryManagement_Handler - DCD BusFault_Handler - DCD UsageFault_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler - DCD DebugMon_Handler - DCD 0 ; Reserved - DCD PendSV_Handler - DCD SysTick_Handler - - ; External Interrupts - DCD POWER_CLOCK_IRQHandler - DCD RADIO_IRQHandler - DCD UARTE0_UART0_IRQHandler - DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - DCD NFCT_IRQHandler - DCD GPIOTE_IRQHandler - DCD SAADC_IRQHandler - DCD TIMER0_IRQHandler - DCD TIMER1_IRQHandler - DCD TIMER2_IRQHandler - DCD RTC0_IRQHandler - DCD TEMP_IRQHandler - DCD RNG_IRQHandler - DCD ECB_IRQHandler - DCD CCM_AAR_IRQHandler - DCD WDT_IRQHandler - DCD RTC1_IRQHandler - DCD QDEC_IRQHandler - DCD COMP_LPCOMP_IRQHandler - DCD SWI0_EGU0_IRQHandler - DCD SWI1_EGU1_IRQHandler - DCD SWI2_EGU2_IRQHandler - DCD SWI3_EGU3_IRQHandler - DCD SWI4_EGU4_IRQHandler - DCD SWI5_EGU5_IRQHandler - DCD TIMER3_IRQHandler - DCD TIMER4_IRQHandler - DCD PWM0_IRQHandler - DCD PDM_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD MWU_IRQHandler - DCD PWM1_IRQHandler - DCD PWM2_IRQHandler - DCD SPIM2_SPIS2_SPI2_IRQHandler - DCD RTC2_IRQHandler - DCD I2S_IRQHandler - DCD FPU_IRQHandler - DCD USBD_IRQHandler - DCD UARTE1_IRQHandler - DCD QSPI_IRQHandler - DCD CRYPTOCELL_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD PWM3_IRQHandler - DCD 0 ; Reserved - DCD SPIM3_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - -__Vectors_End - -__Vectors_Size EQU __Vectors_End - __Vectors - - AREA |.text|, CODE, READONLY - -; Reset Handler - - -Reset_Handler PROC - EXPORT Reset_Handler [WEAK] - IMPORT SystemInit - IMPORT __main - - - LDR R0, =SystemInit - BLX R0 - LDR R0, =__main - BX R0 - ENDP - -; Dummy Exception Handlers (infinite loops which can be modified) - -NMI_Handler PROC - EXPORT NMI_Handler [WEAK] - B . - ENDP -HardFault_Handler\ - PROC - EXPORT HardFault_Handler [WEAK] - B . - ENDP -MemoryManagement_Handler\ - PROC - EXPORT MemoryManagement_Handler [WEAK] - B . - ENDP -BusFault_Handler\ - PROC - EXPORT BusFault_Handler [WEAK] - B . - ENDP -UsageFault_Handler\ - PROC - EXPORT UsageFault_Handler [WEAK] - B . - ENDP -SVC_Handler PROC - EXPORT SVC_Handler [WEAK] - B . - ENDP -DebugMon_Handler\ - PROC - EXPORT DebugMon_Handler [WEAK] - B . - ENDP -PendSV_Handler PROC - EXPORT PendSV_Handler [WEAK] - B . - ENDP -SysTick_Handler PROC - EXPORT SysTick_Handler [WEAK] - B . - ENDP - -Default_Handler PROC - - EXPORT POWER_CLOCK_IRQHandler [WEAK] - EXPORT RADIO_IRQHandler [WEAK] - EXPORT UARTE0_UART0_IRQHandler [WEAK] - EXPORT SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler [WEAK] - EXPORT SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler [WEAK] - EXPORT NFCT_IRQHandler [WEAK] - EXPORT GPIOTE_IRQHandler [WEAK] - EXPORT SAADC_IRQHandler [WEAK] - EXPORT TIMER0_IRQHandler [WEAK] - EXPORT TIMER1_IRQHandler [WEAK] - EXPORT TIMER2_IRQHandler [WEAK] - EXPORT RTC0_IRQHandler [WEAK] - EXPORT TEMP_IRQHandler [WEAK] - EXPORT RNG_IRQHandler [WEAK] - EXPORT ECB_IRQHandler [WEAK] - EXPORT CCM_AAR_IRQHandler [WEAK] - EXPORT WDT_IRQHandler [WEAK] - EXPORT RTC1_IRQHandler [WEAK] - EXPORT QDEC_IRQHandler [WEAK] - EXPORT COMP_LPCOMP_IRQHandler [WEAK] - EXPORT SWI0_EGU0_IRQHandler [WEAK] - EXPORT SWI1_EGU1_IRQHandler [WEAK] - EXPORT SWI2_EGU2_IRQHandler [WEAK] - EXPORT SWI3_EGU3_IRQHandler [WEAK] - EXPORT SWI4_EGU4_IRQHandler [WEAK] - EXPORT SWI5_EGU5_IRQHandler [WEAK] - EXPORT TIMER3_IRQHandler [WEAK] - EXPORT TIMER4_IRQHandler [WEAK] - EXPORT PWM0_IRQHandler [WEAK] - EXPORT PDM_IRQHandler [WEAK] - EXPORT MWU_IRQHandler [WEAK] - EXPORT PWM1_IRQHandler [WEAK] - EXPORT PWM2_IRQHandler [WEAK] - EXPORT SPIM2_SPIS2_SPI2_IRQHandler [WEAK] - EXPORT RTC2_IRQHandler [WEAK] - EXPORT I2S_IRQHandler [WEAK] - EXPORT FPU_IRQHandler [WEAK] - EXPORT USBD_IRQHandler [WEAK] - EXPORT UARTE1_IRQHandler [WEAK] - EXPORT QSPI_IRQHandler [WEAK] - EXPORT CRYPTOCELL_IRQHandler [WEAK] - EXPORT PWM3_IRQHandler [WEAK] - EXPORT SPIM3_IRQHandler [WEAK] -POWER_CLOCK_IRQHandler -RADIO_IRQHandler -UARTE0_UART0_IRQHandler -SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler -SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler -NFCT_IRQHandler -GPIOTE_IRQHandler -SAADC_IRQHandler -TIMER0_IRQHandler -TIMER1_IRQHandler -TIMER2_IRQHandler -RTC0_IRQHandler -TEMP_IRQHandler -RNG_IRQHandler -ECB_IRQHandler -CCM_AAR_IRQHandler -WDT_IRQHandler -RTC1_IRQHandler -QDEC_IRQHandler -COMP_LPCOMP_IRQHandler -SWI0_EGU0_IRQHandler -SWI1_EGU1_IRQHandler -SWI2_EGU2_IRQHandler -SWI3_EGU3_IRQHandler -SWI4_EGU4_IRQHandler -SWI5_EGU5_IRQHandler -TIMER3_IRQHandler -TIMER4_IRQHandler -PWM0_IRQHandler -PDM_IRQHandler -MWU_IRQHandler -PWM1_IRQHandler -PWM2_IRQHandler -SPIM2_SPIS2_SPI2_IRQHandler -RTC2_IRQHandler -I2S_IRQHandler -FPU_IRQHandler -USBD_IRQHandler -UARTE1_IRQHandler -QSPI_IRQHandler -CRYPTOCELL_IRQHandler -PWM3_IRQHandler -SPIM3_IRQHandler - B . - ENDP - ALIGN - -; User Initial Stack & Heap - - IF :DEF:__MICROLIB - - EXPORT __initial_sp - EXPORT __heap_base - EXPORT __heap_limit - - ELSE - - IMPORT __use_two_region_memory - EXPORT __user_initial_stackheap - -__user_initial_stackheap PROC - - LDR R0, = Heap_Mem - LDR R1, = (Stack_Mem + Stack_Size) - LDR R2, = (Heap_Mem + Heap_Size) - LDR R3, = Stack_Mem - BX LR - ENDP - - ALIGN - - ENDIF - - END diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.posix b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.posix deleted file mode 100644 index 03294a5..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.posix +++ /dev/null @@ -1,3 +0,0 @@ -GNU_INSTALL_ROOT := /usr/local/gcc-arm-none-eabi-4_9-2015q3/bin/ -GNU_VERSION := 4.9.3 -GNU_PREFIX := arm-none-eabi diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf51.S b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf51.S deleted file mode 100644 index b0dfe6c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf51.S +++ /dev/null @@ -1,298 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - - .syntax unified - .arch armv6-m - -#ifdef __STARTUP_CONFIG -#include "startup_config.h" -#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT -#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 -#endif -#endif - - .section .stack -#if defined(__STARTUP_CONFIG) - .align __STARTUP_CONFIG_STACK_ALIGNEMENT - .equ Stack_Size, __STARTUP_CONFIG_STACK_SIZE -#elif defined(__STACK_SIZE) - .align 3 - .equ Stack_Size, __STACK_SIZE -#else - .align 3 - .equ Stack_Size, 2048 -#endif - .globl __StackTop - .globl __StackLimit -__StackLimit: - .space Stack_Size - .size __StackLimit, . - __StackLimit -__StackTop: - .size __StackTop, . - __StackTop - - .section .heap - .align 3 -#if defined(__STARTUP_CONFIG) - .equ Heap_Size, __STARTUP_CONFIG_HEAP_SIZE -#elif defined(__HEAP_SIZE) - .equ Heap_Size, __HEAP_SIZE -#else - .equ Heap_Size, 2048 -#endif - .globl __HeapBase - .globl __HeapLimit -__HeapBase: - .if Heap_Size - .space Heap_Size - .endif - .size __HeapBase, . - __HeapBase -__HeapLimit: - .size __HeapLimit, . - __HeapLimit - - .section .isr_vector - .align 2 - .globl __isr_vector -__isr_vector: - .long __StackTop /* Top of Stack */ - .long Reset_Handler - .long NMI_Handler - .long HardFault_Handler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long SVC_Handler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long PendSV_Handler - .long SysTick_Handler - - /* External Interrupts */ - .long POWER_CLOCK_IRQHandler - .long RADIO_IRQHandler - .long UART0_IRQHandler - .long SPI0_TWI0_IRQHandler - .long SPI1_TWI1_IRQHandler - .long 0 /*Reserved */ - .long GPIOTE_IRQHandler - .long ADC_IRQHandler - .long TIMER0_IRQHandler - .long TIMER1_IRQHandler - .long TIMER2_IRQHandler - .long RTC0_IRQHandler - .long TEMP_IRQHandler - .long RNG_IRQHandler - .long ECB_IRQHandler - .long CCM_AAR_IRQHandler - .long WDT_IRQHandler - .long RTC1_IRQHandler - .long QDEC_IRQHandler - .long LPCOMP_IRQHandler - .long SWI0_IRQHandler - .long SWI1_IRQHandler - .long SWI2_IRQHandler - .long SWI3_IRQHandler - .long SWI4_IRQHandler - .long SWI5_IRQHandler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - - .size __isr_vector, . - __isr_vector - -/* Reset Handler */ - - .equ NRF_POWER_RAMON_ADDRESS, 0x40000524 - .equ NRF_POWER_RAMONB_ADDRESS, 0x40000554 - .equ NRF_POWER_RAMONx_RAMxON_ONMODE_Msk, 0x3 - - .text - .thumb - .thumb_func - .align 1 - .globl Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - - MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk - - LDR R0, =NRF_POWER_RAMON_ADDRESS - LDR R2, [R0] - ORRS R2, R1 - STR R2, [R0] - - LDR R0, =NRF_POWER_RAMONB_ADDRESS - LDR R2, [R0] - ORRS R2, R1 - STR R2, [R0] - -/* Loop to copy data from read only memory to RAM. - * The ranges of copy from/to are specified by following symbols: - * __etext: LMA of start of the section to copy from. Usually end of text - * __data_start__: VMA of start of the section to copy to. - * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__ - * the user can add their own initialized data section before BSS section with the INTERT AFTER command. - * - * All addresses must be aligned to 4 bytes boundary. - */ - ldr r1, =__etext - ldr r2, =__data_start__ - ldr r3, =__bss_start__ - - subs r3, r2 - ble .L_loop1_done - -.L_loop1: - subs r3, #4 - ldr r0, [r1,r3] - str r0, [r2,r3] - bgt .L_loop1 - -.L_loop1_done: - -/* This part of work usually is done in C library startup code. Otherwise, - * define __STARTUP_CLEAR_BSS to enable it in this startup. This section - * clears the RAM where BSS data is located. - * - * The BSS section is specified by following symbols - * __bss_start__: start of the BSS section. - * __bss_end__: end of the BSS section. - * - * All addresses must be aligned to 4 bytes boundary. - */ -#ifdef __STARTUP_CLEAR_BSS - ldr r1, =__bss_start__ - ldr r2, =__bss_end__ - - movs r0, 0 - - subs r2, r1 - ble .L_loop3_done - -.L_loop3: - subs r2, #4 - str r0, [r1, r2] - bgt .L_loop3 - -.L_loop3_done: -#endif /* __STARTUP_CLEAR_BSS */ - -/* Execute SystemInit function. */ - bl SystemInit - -/* Call _start function provided by libraries. - * If those libraries are not accessible, define __START as your entry point. - */ -#ifndef __START -#define __START _start -#endif - bl __START - - .pool - .size Reset_Handler,.-Reset_Handler - - .section ".text" - - -/* Dummy Exception Handlers (infinite loops which can be modified) */ - - .weak NMI_Handler - .type NMI_Handler, %function -NMI_Handler: - b . - .size NMI_Handler, . - NMI_Handler - - - .weak HardFault_Handler - .type HardFault_Handler, %function -HardFault_Handler: - b . - .size HardFault_Handler, . - HardFault_Handler - - - .weak SVC_Handler - .type SVC_Handler, %function -SVC_Handler: - b . - .size SVC_Handler, . - SVC_Handler - - - .weak PendSV_Handler - .type PendSV_Handler, %function -PendSV_Handler: - b . - .size PendSV_Handler, . - PendSV_Handler - - - .weak SysTick_Handler - .type SysTick_Handler, %function -SysTick_Handler: - b . - .size SysTick_Handler, . - SysTick_Handler - - -/* IRQ Handlers */ - - .globl Default_Handler - .type Default_Handler, %function -Default_Handler: - b . - .size Default_Handler, . - Default_Handler - - .macro IRQ handler - .weak \handler - .set \handler, Default_Handler - .endm - - IRQ POWER_CLOCK_IRQHandler - IRQ RADIO_IRQHandler - IRQ UART0_IRQHandler - IRQ SPI0_TWI0_IRQHandler - IRQ SPI1_TWI1_IRQHandler - IRQ GPIOTE_IRQHandler - IRQ ADC_IRQHandler - IRQ TIMER0_IRQHandler - IRQ TIMER1_IRQHandler - IRQ TIMER2_IRQHandler - IRQ RTC0_IRQHandler - IRQ TEMP_IRQHandler - IRQ RNG_IRQHandler - IRQ ECB_IRQHandler - IRQ CCM_AAR_IRQHandler - IRQ WDT_IRQHandler - IRQ RTC1_IRQHandler - IRQ QDEC_IRQHandler - IRQ LPCOMP_IRQHandler - IRQ SWI0_IRQHandler - IRQ SWI1_IRQHandler - IRQ SWI2_IRQHandler - IRQ SWI3_IRQHandler - IRQ SWI4_IRQHandler - IRQ SWI5_IRQHandler - - .end diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52810.S b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52810.S deleted file mode 100644 index 6a56579..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52810.S +++ /dev/null @@ -1,394 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - - .syntax unified - .arch armv7e-m - -#ifdef __STARTUP_CONFIG -#include "startup_config.h" -#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT -#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 -#endif -#endif - - .section .stack -#if defined(__STARTUP_CONFIG) - .align __STARTUP_CONFIG_STACK_ALIGNEMENT - .equ Stack_Size, __STARTUP_CONFIG_STACK_SIZE -#elif defined(__STACK_SIZE) - .align 3 - .equ Stack_Size, __STACK_SIZE -#else - .align 3 - .equ Stack_Size, 2048 -#endif - .globl __StackTop - .globl __StackLimit -__StackLimit: - .space Stack_Size - .size __StackLimit, . - __StackLimit -__StackTop: - .size __StackTop, . - __StackTop - - .section .heap - .align 3 -#if defined(__STARTUP_CONFIG) - .equ Heap_Size, __STARTUP_CONFIG_HEAP_SIZE -#elif defined(__HEAP_SIZE) - .equ Heap_Size, __HEAP_SIZE -#else - .equ Heap_Size, 2048 -#endif - .globl __HeapBase - .globl __HeapLimit -__HeapBase: - .if Heap_Size - .space Heap_Size - .endif - .size __HeapBase, . - __HeapBase -__HeapLimit: - .size __HeapLimit, . - __HeapLimit - - .section .isr_vector - .align 2 - .globl __isr_vector -__isr_vector: - .long __StackTop /* Top of Stack */ - .long Reset_Handler - .long NMI_Handler - .long HardFault_Handler - .long MemoryManagement_Handler - .long BusFault_Handler - .long UsageFault_Handler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long SVC_Handler - .long DebugMon_Handler - .long 0 /*Reserved */ - .long PendSV_Handler - .long SysTick_Handler - - /* External Interrupts */ - .long POWER_CLOCK_IRQHandler - .long RADIO_IRQHandler - .long UARTE0_IRQHandler - .long TWIM0_TWIS0_IRQHandler - .long SPIM0_SPIS0_IRQHandler - .long 0 /*Reserved */ - .long GPIOTE_IRQHandler - .long SAADC_IRQHandler - .long TIMER0_IRQHandler - .long TIMER1_IRQHandler - .long TIMER2_IRQHandler - .long RTC0_IRQHandler - .long TEMP_IRQHandler - .long RNG_IRQHandler - .long ECB_IRQHandler - .long CCM_AAR_IRQHandler - .long WDT_IRQHandler - .long RTC1_IRQHandler - .long QDEC_IRQHandler - .long COMP_IRQHandler - .long SWI0_EGU0_IRQHandler - .long SWI1_EGU1_IRQHandler - .long SWI2_IRQHandler - .long SWI3_IRQHandler - .long SWI4_IRQHandler - .long SWI5_IRQHandler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long PWM0_IRQHandler - .long PDM_IRQHandler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - - .size __isr_vector, . - __isr_vector - -/* Reset Handler */ - - - .text - .thumb - .thumb_func - .align 1 - .globl Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - - -/* Loop to copy data from read only memory to RAM. - * The ranges of copy from/to are specified by following symbols: - * __etext: LMA of start of the section to copy from. Usually end of text - * __data_start__: VMA of start of the section to copy to. - * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__ - * the user can add their own initialized data section before BSS section with the INTERT AFTER command. - * - * All addresses must be aligned to 4 bytes boundary. - */ - ldr r1, =__etext - ldr r2, =__data_start__ - ldr r3, =__bss_start__ - - subs r3, r2 - ble .L_loop1_done - -.L_loop1: - subs r3, #4 - ldr r0, [r1,r3] - str r0, [r2,r3] - bgt .L_loop1 - -.L_loop1_done: - -/* This part of work usually is done in C library startup code. Otherwise, - * define __STARTUP_CLEAR_BSS to enable it in this startup. This section - * clears the RAM where BSS data is located. - * - * The BSS section is specified by following symbols - * __bss_start__: start of the BSS section. - * __bss_end__: end of the BSS section. - * - * All addresses must be aligned to 4 bytes boundary. - */ -#ifdef __STARTUP_CLEAR_BSS - ldr r1, =__bss_start__ - ldr r2, =__bss_end__ - - movs r0, 0 - - subs r2, r1 - ble .L_loop3_done - -.L_loop3: - subs r2, #4 - str r0, [r1, r2] - bgt .L_loop3 - -.L_loop3_done: -#endif /* __STARTUP_CLEAR_BSS */ - -/* Execute SystemInit function. */ - bl SystemInit - -/* Call _start function provided by libraries. - * If those libraries are not accessible, define __START as your entry point. - */ -#ifndef __START -#define __START _start -#endif - bl __START - - .pool - .size Reset_Handler,.-Reset_Handler - - .section ".text" - - -/* Dummy Exception Handlers (infinite loops which can be modified) */ - - .weak NMI_Handler - .type NMI_Handler, %function -NMI_Handler: - b . - .size NMI_Handler, . - NMI_Handler - - - .weak HardFault_Handler - .type HardFault_Handler, %function -HardFault_Handler: - b . - .size HardFault_Handler, . - HardFault_Handler - - - .weak MemoryManagement_Handler - .type MemoryManagement_Handler, %function -MemoryManagement_Handler: - b . - .size MemoryManagement_Handler, . - MemoryManagement_Handler - - - .weak BusFault_Handler - .type BusFault_Handler, %function -BusFault_Handler: - b . - .size BusFault_Handler, . - BusFault_Handler - - - .weak UsageFault_Handler - .type UsageFault_Handler, %function -UsageFault_Handler: - b . - .size UsageFault_Handler, . - UsageFault_Handler - - - .weak SVC_Handler - .type SVC_Handler, %function -SVC_Handler: - b . - .size SVC_Handler, . - SVC_Handler - - - .weak DebugMon_Handler - .type DebugMon_Handler, %function -DebugMon_Handler: - b . - .size DebugMon_Handler, . - DebugMon_Handler - - - .weak PendSV_Handler - .type PendSV_Handler, %function -PendSV_Handler: - b . - .size PendSV_Handler, . - PendSV_Handler - - - .weak SysTick_Handler - .type SysTick_Handler, %function -SysTick_Handler: - b . - .size SysTick_Handler, . - SysTick_Handler - - -/* IRQ Handlers */ - - .globl Default_Handler - .type Default_Handler, %function -Default_Handler: - b . - .size Default_Handler, . - Default_Handler - - .macro IRQ handler - .weak \handler - .set \handler, Default_Handler - .endm - - IRQ POWER_CLOCK_IRQHandler - IRQ RADIO_IRQHandler - IRQ UARTE0_IRQHandler - IRQ TWIM0_TWIS0_IRQHandler - IRQ SPIM0_SPIS0_IRQHandler - IRQ GPIOTE_IRQHandler - IRQ SAADC_IRQHandler - IRQ TIMER0_IRQHandler - IRQ TIMER1_IRQHandler - IRQ TIMER2_IRQHandler - IRQ RTC0_IRQHandler - IRQ TEMP_IRQHandler - IRQ RNG_IRQHandler - IRQ ECB_IRQHandler - IRQ CCM_AAR_IRQHandler - IRQ WDT_IRQHandler - IRQ RTC1_IRQHandler - IRQ QDEC_IRQHandler - IRQ COMP_IRQHandler - IRQ SWI0_EGU0_IRQHandler - IRQ SWI1_EGU1_IRQHandler - IRQ SWI2_IRQHandler - IRQ SWI3_IRQHandler - IRQ SWI4_IRQHandler - IRQ SWI5_IRQHandler - IRQ PWM0_IRQHandler - IRQ PDM_IRQHandler - - .end diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52840.S b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52840.S deleted file mode 100644 index ad45d5e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_startup_nrf52840.S +++ /dev/null @@ -1,410 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - - .syntax unified - .arch armv7e-m - -#ifdef __STARTUP_CONFIG -#include "startup_config.h" -#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT -#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 -#endif -#endif - - .section .stack -#if defined(__STARTUP_CONFIG) - .align __STARTUP_CONFIG_STACK_ALIGNEMENT - .equ Stack_Size, __STARTUP_CONFIG_STACK_SIZE -#elif defined(__STACK_SIZE) - .align 3 - .equ Stack_Size, __STACK_SIZE -#else - .align 3 - .equ Stack_Size, 8192 -#endif - .globl __StackTop - .globl __StackLimit -__StackLimit: - .space Stack_Size - .size __StackLimit, . - __StackLimit -__StackTop: - .size __StackTop, . - __StackTop - - .section .heap - .align 3 -#if defined(__STARTUP_CONFIG) - .equ Heap_Size, __STARTUP_CONFIG_HEAP_SIZE -#elif defined(__HEAP_SIZE) - .equ Heap_Size, __HEAP_SIZE -#else - .equ Heap_Size, 8192 -#endif - .globl __HeapBase - .globl __HeapLimit -__HeapBase: - .if Heap_Size - .space Heap_Size - .endif - .size __HeapBase, . - __HeapBase -__HeapLimit: - .size __HeapLimit, . - __HeapLimit - - .section .isr_vector - .align 2 - .globl __isr_vector -__isr_vector: - .long __StackTop /* Top of Stack */ - .long Reset_Handler - .long NMI_Handler - .long HardFault_Handler - .long MemoryManagement_Handler - .long BusFault_Handler - .long UsageFault_Handler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long SVC_Handler - .long DebugMon_Handler - .long 0 /*Reserved */ - .long PendSV_Handler - .long SysTick_Handler - - /* External Interrupts */ - .long POWER_CLOCK_IRQHandler - .long RADIO_IRQHandler - .long UARTE0_UART0_IRQHandler - .long SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - .long SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - .long NFCT_IRQHandler - .long GPIOTE_IRQHandler - .long SAADC_IRQHandler - .long TIMER0_IRQHandler - .long TIMER1_IRQHandler - .long TIMER2_IRQHandler - .long RTC0_IRQHandler - .long TEMP_IRQHandler - .long RNG_IRQHandler - .long ECB_IRQHandler - .long CCM_AAR_IRQHandler - .long WDT_IRQHandler - .long RTC1_IRQHandler - .long QDEC_IRQHandler - .long COMP_LPCOMP_IRQHandler - .long SWI0_EGU0_IRQHandler - .long SWI1_EGU1_IRQHandler - .long SWI2_EGU2_IRQHandler - .long SWI3_EGU3_IRQHandler - .long SWI4_EGU4_IRQHandler - .long SWI5_EGU5_IRQHandler - .long TIMER3_IRQHandler - .long TIMER4_IRQHandler - .long PWM0_IRQHandler - .long PDM_IRQHandler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long MWU_IRQHandler - .long PWM1_IRQHandler - .long PWM2_IRQHandler - .long SPIM2_SPIS2_SPI2_IRQHandler - .long RTC2_IRQHandler - .long I2S_IRQHandler - .long FPU_IRQHandler - .long USBD_IRQHandler - .long UARTE1_IRQHandler - .long QSPI_IRQHandler - .long CRYPTOCELL_IRQHandler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long PWM3_IRQHandler - .long 0 /*Reserved */ - .long SPIM3_IRQHandler - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - .long 0 /*Reserved */ - - .size __isr_vector, . - __isr_vector - -/* Reset Handler */ - - - .text - .thumb - .thumb_func - .align 1 - .globl Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - - -/* Loop to copy data from read only memory to RAM. - * The ranges of copy from/to are specified by following symbols: - * __etext: LMA of start of the section to copy from. Usually end of text - * __data_start__: VMA of start of the section to copy to. - * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__ - * the user can add their own initialized data section before BSS section with the INTERT AFTER command. - * - * All addresses must be aligned to 4 bytes boundary. - */ - ldr r1, =__etext - ldr r2, =__data_start__ - ldr r3, =__bss_start__ - - subs r3, r2 - ble .L_loop1_done - -.L_loop1: - subs r3, #4 - ldr r0, [r1,r3] - str r0, [r2,r3] - bgt .L_loop1 - -.L_loop1_done: - -/* This part of work usually is done in C library startup code. Otherwise, - * define __STARTUP_CLEAR_BSS to enable it in this startup. This section - * clears the RAM where BSS data is located. - * - * The BSS section is specified by following symbols - * __bss_start__: start of the BSS section. - * __bss_end__: end of the BSS section. - * - * All addresses must be aligned to 4 bytes boundary. - */ -#ifdef __STARTUP_CLEAR_BSS - ldr r1, =__bss_start__ - ldr r2, =__bss_end__ - - movs r0, 0 - - subs r2, r1 - ble .L_loop3_done - -.L_loop3: - subs r2, #4 - str r0, [r1, r2] - bgt .L_loop3 - -.L_loop3_done: -#endif /* __STARTUP_CLEAR_BSS */ - -/* Execute SystemInit function. */ - bl SystemInit - -/* Call _start function provided by libraries. - * If those libraries are not accessible, define __START as your entry point. - */ -#ifndef __START -#define __START _start -#endif - bl __START - - .pool - .size Reset_Handler,.-Reset_Handler - - .section ".text" - - -/* Dummy Exception Handlers (infinite loops which can be modified) */ - - .weak NMI_Handler - .type NMI_Handler, %function -NMI_Handler: - b . - .size NMI_Handler, . - NMI_Handler - - - .weak HardFault_Handler - .type HardFault_Handler, %function -HardFault_Handler: - b . - .size HardFault_Handler, . - HardFault_Handler - - - .weak MemoryManagement_Handler - .type MemoryManagement_Handler, %function -MemoryManagement_Handler: - b . - .size MemoryManagement_Handler, . - MemoryManagement_Handler - - - .weak BusFault_Handler - .type BusFault_Handler, %function -BusFault_Handler: - b . - .size BusFault_Handler, . - BusFault_Handler - - - .weak UsageFault_Handler - .type UsageFault_Handler, %function -UsageFault_Handler: - b . - .size UsageFault_Handler, . - UsageFault_Handler - - - .weak SVC_Handler - .type SVC_Handler, %function -SVC_Handler: - b . - .size SVC_Handler, . - SVC_Handler - - - .weak DebugMon_Handler - .type DebugMon_Handler, %function -DebugMon_Handler: - b . - .size DebugMon_Handler, . - DebugMon_Handler - - - .weak PendSV_Handler - .type PendSV_Handler, %function -PendSV_Handler: - b . - .size PendSV_Handler, . - PendSV_Handler - - - .weak SysTick_Handler - .type SysTick_Handler, %function -SysTick_Handler: - b . - .size SysTick_Handler, . - SysTick_Handler - - -/* IRQ Handlers */ - - .globl Default_Handler - .type Default_Handler, %function -Default_Handler: - b . - .size Default_Handler, . - Default_Handler - - .macro IRQ handler - .weak \handler - .set \handler, Default_Handler - .endm - - IRQ POWER_CLOCK_IRQHandler - IRQ RADIO_IRQHandler - IRQ UARTE0_UART0_IRQHandler - IRQ SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - IRQ SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - IRQ NFCT_IRQHandler - IRQ GPIOTE_IRQHandler - IRQ SAADC_IRQHandler - IRQ TIMER0_IRQHandler - IRQ TIMER1_IRQHandler - IRQ TIMER2_IRQHandler - IRQ RTC0_IRQHandler - IRQ TEMP_IRQHandler - IRQ RNG_IRQHandler - IRQ ECB_IRQHandler - IRQ CCM_AAR_IRQHandler - IRQ WDT_IRQHandler - IRQ RTC1_IRQHandler - IRQ QDEC_IRQHandler - IRQ COMP_LPCOMP_IRQHandler - IRQ SWI0_EGU0_IRQHandler - IRQ SWI1_EGU1_IRQHandler - IRQ SWI2_EGU2_IRQHandler - IRQ SWI3_EGU3_IRQHandler - IRQ SWI4_EGU4_IRQHandler - IRQ SWI5_EGU5_IRQHandler - IRQ TIMER3_IRQHandler - IRQ TIMER4_IRQHandler - IRQ PWM0_IRQHandler - IRQ PDM_IRQHandler - IRQ MWU_IRQHandler - IRQ PWM1_IRQHandler - IRQ PWM2_IRQHandler - IRQ SPIM2_SPIS2_SPI2_IRQHandler - IRQ RTC2_IRQHandler - IRQ I2S_IRQHandler - IRQ FPU_IRQHandler - IRQ USBD_IRQHandler - IRQ UARTE1_IRQHandler - IRQ QSPI_IRQHandler - IRQ CRYPTOCELL_IRQHandler - IRQ PWM3_IRQHandler - IRQ SPIM3_IRQHandler - - .end diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxaa.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxaa.ld deleted file mode 100644 index ab9a5d2..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxaa.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 -} - - -INCLUDE "nrf51_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxab.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxab.ld deleted file mode 100644 index 95804ae..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf51_xxab.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x20000 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 -} - - -INCLUDE "nrf51_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52810_xxaa.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52810_xxaa.ld deleted file mode 100644 index 9b0dc12..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52810_xxaa.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x30000 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x6000 -} - - -INCLUDE "nrf52_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52840_xxaa.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52840_xxaa.ld deleted file mode 100644 index 24c4e13..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf52840_xxaa.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 -} - - -INCLUDE "nrf52_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf5x_common.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf5x_common.ld deleted file mode 100644 index c6999cb..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/nrf5x_common.ld +++ /dev/null @@ -1,168 +0,0 @@ -/* Linker script for Nordic Semiconductor nRF51 devices - * - * Version: Sourcery G++ 4.5-1 - * Support: https://support.codesourcery.com/GNUToolchain/ - * - * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc. - * - * The authors hereby grant permission to use, copy, modify, distribute, - * and license this software and its documentation for any purpose, provided - * that existing copyright notices are retained in all copies and that this - * notice is included verbatim in any distributions. No written agreement, - * license, or royalty fee is required for any of the authorized uses. - * Modifications to this software may be copyrighted by their authors - * and need not follow the licensing terms described here, provided that - * the new terms are clearly indicated on the first page of each file where - * they apply. - */ -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") - -/* Linker script to place sections and symbol values. Should be used together - * with other linker script that defines memory regions FLASH and RAM. - * It references following symbols, which must be defined in code: - * Reset_Handler : Entry of reset handler - * - * It defines following symbols, which code can use without definition: - * __exidx_start - * __exidx_end - * __etext - * __data_start__ - * __preinit_array_start - * __preinit_array_end - * __init_array_start - * __init_array_end - * __fini_array_start - * __fini_array_end - * __data_end__ - * __bss_start__ - * __bss_end__ - * __end__ - * end - * __HeapBase - * __HeapLimit - * __StackLimit - * __StackTop - * __stack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.text*) - - KEEP(*(.init)) - KEEP(*(.fini)) - - /* .ctors */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - - /* .dtors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.rodata*) - - KEEP(*(.eh_frame*)) - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - - __etext = .; - - .data : AT (__etext) - { - __data_start__ = .; - *(vtable) - *(.data*) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(4); - /* All data end */ - __data_end__ = .; - - } > RAM - - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - *(.bss*) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (COPY): - { - __HeapBase = .; - __end__ = .; - PROVIDE(end = .); - KEEP(*(.heap*)) - __HeapLimit = .; - } > RAM - - /* .stack_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later */ - .stack_dummy (COPY): - { - KEEP(*(.stack*)) - } > RAM - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ORIGIN(RAM) + LENGTH(RAM); - __StackLimit = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") - - /* Check if text sections + data exceeds FLASH limit */ - DataInitFlashUsed = __bss_start__ - __data_start__; - CodeFlashUsed = __etext - ORIGIN(FLASH); - TotalFlashUsed = CodeFlashUsed + DataInitFlashUsed; - ASSERT(TotalFlashUsed <= LENGTH(FLASH), "region FLASH overflowed with .data and user data") - -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf51.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf51.s deleted file mode 100644 index 9580131..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf51.s +++ /dev/null @@ -1,311 +0,0 @@ -; Copyright (c) 2009-2017 ARM Limited. All rights reserved. -; -; SPDX-License-Identifier: Apache-2.0 -; -; Licensed under the Apache License, Version 2.0 (the License); you may -; not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an AS IS BASIS, WITHOUT -; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; NOTICE: This file has been modified by Nordic Semiconductor ASA. - -; The modules in this file are included in the libraries, and may be replaced -; by any user-defined modules that define the PUBLIC symbol _program_start or -; a user defined start symbol. -; To override the cstartup defined in the library, simply add your modified -; version to the workbench project. -; -; The vector table is normally located at address 0. -; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. -; The name "__vector_table" has special meaning for C-SPY: -; it is where the SP start value is found, and the NVIC vector -; table register (VTOR) is initialized to this address if != 0. - - MODULE ?cstartup - -#if defined(__STARTUP_CONFIG) - - #include "startup_config.h" - - #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT - #define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 - #endif - - SECTION CSTACK:DATA:NOROOT(__STARTUP_CONFIG_STACK_ALIGNEMENT) - DS8 __STARTUP_CONFIG_STACK_SIZE - - SECTION HEAP:DATA:NOROOT(3) - DS8 __STARTUP_CONFIG_HEAP_SIZE - -#else - - ;; Stack size default : Defined in *.icf (linker file). Can be modified inside EW. - ;; Heap size default : Defined in *.icf (linker file). Can be modified inside EW. - - ;; Forward declaration of sections. - SECTION CSTACK:DATA:NOROOT(3) - -#endif - - - SECTION .intvec:CODE:NOROOT(2) - - EXTERN __iar_program_start - EXTERN SystemInit - PUBLIC __vector_table - PUBLIC __Vectors - PUBLIC __Vectors_End - PUBLIC __Vectors_Size - - DATA - -__vector_table - DCD sfe(CSTACK) - DCD Reset_Handler - DCD NMI_Handler - DCD HardFault_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD PendSV_Handler - DCD SysTick_Handler - - ; External Interrupts - DCD POWER_CLOCK_IRQHandler - DCD RADIO_IRQHandler - DCD UART0_IRQHandler - DCD SPI0_TWI0_IRQHandler - DCD SPI1_TWI1_IRQHandler - DCD 0 ; Reserved - DCD GPIOTE_IRQHandler - DCD ADC_IRQHandler - DCD TIMER0_IRQHandler - DCD TIMER1_IRQHandler - DCD TIMER2_IRQHandler - DCD RTC0_IRQHandler - DCD TEMP_IRQHandler - DCD RNG_IRQHandler - DCD ECB_IRQHandler - DCD CCM_AAR_IRQHandler - DCD WDT_IRQHandler - DCD RTC1_IRQHandler - DCD QDEC_IRQHandler - DCD LPCOMP_IRQHandler - DCD SWI0_IRQHandler - DCD SWI1_IRQHandler - DCD SWI2_IRQHandler - DCD SWI3_IRQHandler - DCD SWI4_IRQHandler - DCD SWI5_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - -__Vectors_End -__Vectors EQU __vector_table -__Vectors_Size EQU __Vectors_End - __Vectors - -NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address -NRF_POWER_RAMONB_ADDRESS EQU 0x40000554 ; NRF_POWER->RAMONB address -NRF_POWER_RAMONx_RAMxON_ONMODE_Msk EQU 0x3 ; All RAM blocks on in onmode bit mask - -; Default handlers. - THUMB - - PUBWEAK Reset_Handler - SECTION .text:CODE:REORDER:NOROOT(2) -Reset_Handler - MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk - - LDR R0, =NRF_POWER_RAMON_ADDRESS - LDR R2, [R0] - ORRS R2, R2, R1 - STR R2, [R0] - - LDR R0, =NRF_POWER_RAMONB_ADDRESS - LDR R2, [R0] - ORRS R2, R2, R1 - STR R2, [R0] - - LDR R0, =SystemInit - BLX R0 - LDR R0, =__iar_program_start - BX R0 - - ; Dummy exception handlers - - - PUBWEAK NMI_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -NMI_Handler - B . - - PUBWEAK HardFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -HardFault_Handler - B . - - PUBWEAK SVC_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -SVC_Handler - B . - - PUBWEAK PendSV_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -PendSV_Handler - B . - - PUBWEAK SysTick_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -SysTick_Handler - B . - - - ; Dummy interrupt handlers - - PUBWEAK POWER_CLOCK_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -POWER_CLOCK_IRQHandler - B . - - PUBWEAK RADIO_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RADIO_IRQHandler - B . - - PUBWEAK UART0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -UART0_IRQHandler - B . - - PUBWEAK SPI0_TWI0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPI0_TWI0_IRQHandler - B . - - PUBWEAK SPI1_TWI1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPI1_TWI1_IRQHandler - B . - - PUBWEAK GPIOTE_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -GPIOTE_IRQHandler - B . - - PUBWEAK ADC_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -ADC_IRQHandler - B . - - PUBWEAK TIMER0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER0_IRQHandler - B . - - PUBWEAK TIMER1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER1_IRQHandler - B . - - PUBWEAK TIMER2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER2_IRQHandler - B . - - PUBWEAK RTC0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC0_IRQHandler - B . - - PUBWEAK TEMP_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TEMP_IRQHandler - B . - - PUBWEAK RNG_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RNG_IRQHandler - B . - - PUBWEAK ECB_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -ECB_IRQHandler - B . - - PUBWEAK CCM_AAR_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -CCM_AAR_IRQHandler - B . - - PUBWEAK WDT_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -WDT_IRQHandler - B . - - PUBWEAK RTC1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC1_IRQHandler - B . - - PUBWEAK QDEC_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -QDEC_IRQHandler - B . - - PUBWEAK LPCOMP_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -LPCOMP_IRQHandler - B . - - PUBWEAK SWI0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI0_IRQHandler - B . - - PUBWEAK SWI1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI1_IRQHandler - B . - - PUBWEAK SWI2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI2_IRQHandler - B . - - PUBWEAK SWI3_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI3_IRQHandler - B . - - PUBWEAK SWI4_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI4_IRQHandler - B . - - PUBWEAK SWI5_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI5_IRQHandler - B . - - - END - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52810.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52810.s deleted file mode 100644 index f43ed94..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52810.s +++ /dev/null @@ -1,407 +0,0 @@ -; Copyright (c) 2009-2017 ARM Limited. All rights reserved. -; -; SPDX-License-Identifier: Apache-2.0 -; -; Licensed under the Apache License, Version 2.0 (the License); you may -; not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an AS IS BASIS, WITHOUT -; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; NOTICE: This file has been modified by Nordic Semiconductor ASA. - -; The modules in this file are included in the libraries, and may be replaced -; by any user-defined modules that define the PUBLIC symbol _program_start or -; a user defined start symbol. -; To override the cstartup defined in the library, simply add your modified -; version to the workbench project. -; -; The vector table is normally located at address 0. -; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. -; The name "__vector_table" has special meaning for C-SPY: -; it is where the SP start value is found, and the NVIC vector -; table register (VTOR) is initialized to this address if != 0. - - MODULE ?cstartup - -#if defined(__STARTUP_CONFIG) - - #include "startup_config.h" - - #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT - #define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 - #endif - - SECTION CSTACK:DATA:NOROOT(__STARTUP_CONFIG_STACK_ALIGNEMENT) - DS8 __STARTUP_CONFIG_STACK_SIZE - - SECTION HEAP:DATA:NOROOT(3) - DS8 __STARTUP_CONFIG_HEAP_SIZE - -#else - - ;; Stack size default : Defined in *.icf (linker file). Can be modified inside EW. - ;; Heap size default : Defined in *.icf (linker file). Can be modified inside EW. - - ;; Forward declaration of sections. - SECTION CSTACK:DATA:NOROOT(3) - -#endif - - - SECTION .intvec:CODE:NOROOT(2) - - EXTERN __iar_program_start - EXTERN SystemInit - PUBLIC __vector_table - PUBLIC __Vectors - PUBLIC __Vectors_End - PUBLIC __Vectors_Size - - DATA - -__vector_table - DCD sfe(CSTACK) - DCD Reset_Handler - DCD NMI_Handler - DCD HardFault_Handler - DCD MemoryManagement_Handler - DCD BusFault_Handler - DCD UsageFault_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler - DCD DebugMon_Handler - DCD 0 ; Reserved - DCD PendSV_Handler - DCD SysTick_Handler - - ; External Interrupts - DCD POWER_CLOCK_IRQHandler - DCD RADIO_IRQHandler - DCD UARTE0_IRQHandler - DCD TWIM0_TWIS0_IRQHandler - DCD SPIM0_SPIS0_IRQHandler - DCD 0 ; Reserved - DCD GPIOTE_IRQHandler - DCD SAADC_IRQHandler - DCD TIMER0_IRQHandler - DCD TIMER1_IRQHandler - DCD TIMER2_IRQHandler - DCD RTC0_IRQHandler - DCD TEMP_IRQHandler - DCD RNG_IRQHandler - DCD ECB_IRQHandler - DCD CCM_AAR_IRQHandler - DCD WDT_IRQHandler - DCD RTC1_IRQHandler - DCD QDEC_IRQHandler - DCD COMP_IRQHandler - DCD SWI0_EGU0_IRQHandler - DCD SWI1_EGU1_IRQHandler - DCD SWI2_IRQHandler - DCD SWI3_IRQHandler - DCD SWI4_IRQHandler - DCD SWI5_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD PWM0_IRQHandler - DCD PDM_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - -__Vectors_End -__Vectors EQU __vector_table -__Vectors_Size EQU __Vectors_End - __Vectors - - -; Default handlers. - THUMB - - PUBWEAK Reset_Handler - SECTION .text:CODE:REORDER:NOROOT(2) -Reset_Handler - - LDR R0, =SystemInit - BLX R0 - LDR R0, =__iar_program_start - BX R0 - - ; Dummy exception handlers - - - PUBWEAK NMI_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -NMI_Handler - B . - - PUBWEAK HardFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -HardFault_Handler - B . - - PUBWEAK MemoryManagement_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -MemoryManagement_Handler - B . - - PUBWEAK BusFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -BusFault_Handler - B . - - PUBWEAK UsageFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -UsageFault_Handler - B . - - PUBWEAK SVC_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -SVC_Handler - B . - - PUBWEAK DebugMon_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -DebugMon_Handler - B . - - PUBWEAK PendSV_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -PendSV_Handler - B . - - PUBWEAK SysTick_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -SysTick_Handler - B . - - - ; Dummy interrupt handlers - - PUBWEAK POWER_CLOCK_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -POWER_CLOCK_IRQHandler - B . - - PUBWEAK RADIO_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RADIO_IRQHandler - B . - - PUBWEAK UARTE0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -UARTE0_IRQHandler - B . - - PUBWEAK TWIM0_TWIS0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TWIM0_TWIS0_IRQHandler - B . - - PUBWEAK SPIM0_SPIS0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPIM0_SPIS0_IRQHandler - B . - - PUBWEAK GPIOTE_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -GPIOTE_IRQHandler - B . - - PUBWEAK SAADC_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SAADC_IRQHandler - B . - - PUBWEAK TIMER0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER0_IRQHandler - B . - - PUBWEAK TIMER1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER1_IRQHandler - B . - - PUBWEAK TIMER2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER2_IRQHandler - B . - - PUBWEAK RTC0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC0_IRQHandler - B . - - PUBWEAK TEMP_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TEMP_IRQHandler - B . - - PUBWEAK RNG_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RNG_IRQHandler - B . - - PUBWEAK ECB_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -ECB_IRQHandler - B . - - PUBWEAK CCM_AAR_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -CCM_AAR_IRQHandler - B . - - PUBWEAK WDT_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -WDT_IRQHandler - B . - - PUBWEAK RTC1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC1_IRQHandler - B . - - PUBWEAK QDEC_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -QDEC_IRQHandler - B . - - PUBWEAK COMP_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -COMP_IRQHandler - B . - - PUBWEAK SWI0_EGU0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI0_EGU0_IRQHandler - B . - - PUBWEAK SWI1_EGU1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI1_EGU1_IRQHandler - B . - - PUBWEAK SWI2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI2_IRQHandler - B . - - PUBWEAK SWI3_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI3_IRQHandler - B . - - PUBWEAK SWI4_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI4_IRQHandler - B . - - PUBWEAK SWI5_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI5_IRQHandler - B . - - PUBWEAK PWM0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PWM0_IRQHandler - B . - - PUBWEAK PDM_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PDM_IRQHandler - B . - - - END - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52840.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52840.s deleted file mode 100644 index c5fd37d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_startup_nrf52840.s +++ /dev/null @@ -1,487 +0,0 @@ -; Copyright (c) 2009-2017 ARM Limited. All rights reserved. -; -; SPDX-License-Identifier: Apache-2.0 -; -; Licensed under the Apache License, Version 2.0 (the License); you may -; not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an AS IS BASIS, WITHOUT -; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; NOTICE: This file has been modified by Nordic Semiconductor ASA. - -; The modules in this file are included in the libraries, and may be replaced -; by any user-defined modules that define the PUBLIC symbol _program_start or -; a user defined start symbol. -; To override the cstartup defined in the library, simply add your modified -; version to the workbench project. -; -; The vector table is normally located at address 0. -; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. -; The name "__vector_table" has special meaning for C-SPY: -; it is where the SP start value is found, and the NVIC vector -; table register (VTOR) is initialized to this address if != 0. - - MODULE ?cstartup - -#if defined(__STARTUP_CONFIG) - - #include "startup_config.h" - - #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT - #define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 - #endif - - SECTION CSTACK:DATA:NOROOT(__STARTUP_CONFIG_STACK_ALIGNEMENT) - DS8 __STARTUP_CONFIG_STACK_SIZE - - SECTION HEAP:DATA:NOROOT(3) - DS8 __STARTUP_CONFIG_HEAP_SIZE - -#else - - ;; Stack size default : Defined in *.icf (linker file). Can be modified inside EW. - ;; Heap size default : Defined in *.icf (linker file). Can be modified inside EW. - - ;; Forward declaration of sections. - SECTION CSTACK:DATA:NOROOT(3) - -#endif - - - SECTION .intvec:CODE:NOROOT(2) - - EXTERN __iar_program_start - EXTERN SystemInit - PUBLIC __vector_table - PUBLIC __Vectors - PUBLIC __Vectors_End - PUBLIC __Vectors_Size - - DATA - -__vector_table - DCD sfe(CSTACK) - DCD Reset_Handler - DCD NMI_Handler - DCD HardFault_Handler - DCD MemoryManagement_Handler - DCD BusFault_Handler - DCD UsageFault_Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler - DCD DebugMon_Handler - DCD 0 ; Reserved - DCD PendSV_Handler - DCD SysTick_Handler - - ; External Interrupts - DCD POWER_CLOCK_IRQHandler - DCD RADIO_IRQHandler - DCD UARTE0_UART0_IRQHandler - DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - DCD NFCT_IRQHandler - DCD GPIOTE_IRQHandler - DCD SAADC_IRQHandler - DCD TIMER0_IRQHandler - DCD TIMER1_IRQHandler - DCD TIMER2_IRQHandler - DCD RTC0_IRQHandler - DCD TEMP_IRQHandler - DCD RNG_IRQHandler - DCD ECB_IRQHandler - DCD CCM_AAR_IRQHandler - DCD WDT_IRQHandler - DCD RTC1_IRQHandler - DCD QDEC_IRQHandler - DCD COMP_LPCOMP_IRQHandler - DCD SWI0_EGU0_IRQHandler - DCD SWI1_EGU1_IRQHandler - DCD SWI2_EGU2_IRQHandler - DCD SWI3_EGU3_IRQHandler - DCD SWI4_EGU4_IRQHandler - DCD SWI5_EGU5_IRQHandler - DCD TIMER3_IRQHandler - DCD TIMER4_IRQHandler - DCD PWM0_IRQHandler - DCD PDM_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD MWU_IRQHandler - DCD PWM1_IRQHandler - DCD PWM2_IRQHandler - DCD SPIM2_SPIS2_SPI2_IRQHandler - DCD RTC2_IRQHandler - DCD I2S_IRQHandler - DCD FPU_IRQHandler - DCD USBD_IRQHandler - DCD UARTE1_IRQHandler - DCD QSPI_IRQHandler - DCD CRYPTOCELL_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD PWM3_IRQHandler - DCD 0 ; Reserved - DCD SPIM3_IRQHandler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - -__Vectors_End -__Vectors EQU __vector_table -__Vectors_Size EQU __Vectors_End - __Vectors - - -; Default handlers. - THUMB - - PUBWEAK Reset_Handler - SECTION .text:CODE:REORDER:NOROOT(2) -Reset_Handler - - LDR R0, =SystemInit - BLX R0 - LDR R0, =__iar_program_start - BX R0 - - ; Dummy exception handlers - - - PUBWEAK NMI_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -NMI_Handler - B . - - PUBWEAK HardFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -HardFault_Handler - B . - - PUBWEAK MemoryManagement_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -MemoryManagement_Handler - B . - - PUBWEAK BusFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -BusFault_Handler - B . - - PUBWEAK UsageFault_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -UsageFault_Handler - B . - - PUBWEAK SVC_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -SVC_Handler - B . - - PUBWEAK DebugMon_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -DebugMon_Handler - B . - - PUBWEAK PendSV_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -PendSV_Handler - B . - - PUBWEAK SysTick_Handler - SECTION .text:CODE:REORDER:NOROOT(1) -SysTick_Handler - B . - - - ; Dummy interrupt handlers - - PUBWEAK POWER_CLOCK_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -POWER_CLOCK_IRQHandler - B . - - PUBWEAK RADIO_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RADIO_IRQHandler - B . - - PUBWEAK UARTE0_UART0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -UARTE0_UART0_IRQHandler - B . - - PUBWEAK SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - B . - - PUBWEAK SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - B . - - PUBWEAK NFCT_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -NFCT_IRQHandler - B . - - PUBWEAK GPIOTE_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -GPIOTE_IRQHandler - B . - - PUBWEAK SAADC_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SAADC_IRQHandler - B . - - PUBWEAK TIMER0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER0_IRQHandler - B . - - PUBWEAK TIMER1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER1_IRQHandler - B . - - PUBWEAK TIMER2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER2_IRQHandler - B . - - PUBWEAK RTC0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC0_IRQHandler - B . - - PUBWEAK TEMP_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TEMP_IRQHandler - B . - - PUBWEAK RNG_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RNG_IRQHandler - B . - - PUBWEAK ECB_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -ECB_IRQHandler - B . - - PUBWEAK CCM_AAR_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -CCM_AAR_IRQHandler - B . - - PUBWEAK WDT_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -WDT_IRQHandler - B . - - PUBWEAK RTC1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC1_IRQHandler - B . - - PUBWEAK QDEC_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -QDEC_IRQHandler - B . - - PUBWEAK COMP_LPCOMP_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -COMP_LPCOMP_IRQHandler - B . - - PUBWEAK SWI0_EGU0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI0_EGU0_IRQHandler - B . - - PUBWEAK SWI1_EGU1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI1_EGU1_IRQHandler - B . - - PUBWEAK SWI2_EGU2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI2_EGU2_IRQHandler - B . - - PUBWEAK SWI3_EGU3_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI3_EGU3_IRQHandler - B . - - PUBWEAK SWI4_EGU4_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI4_EGU4_IRQHandler - B . - - PUBWEAK SWI5_EGU5_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SWI5_EGU5_IRQHandler - B . - - PUBWEAK TIMER3_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER3_IRQHandler - B . - - PUBWEAK TIMER4_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -TIMER4_IRQHandler - B . - - PUBWEAK PWM0_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PWM0_IRQHandler - B . - - PUBWEAK PDM_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PDM_IRQHandler - B . - - PUBWEAK MWU_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -MWU_IRQHandler - B . - - PUBWEAK PWM1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PWM1_IRQHandler - B . - - PUBWEAK PWM2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PWM2_IRQHandler - B . - - PUBWEAK SPIM2_SPIS2_SPI2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPIM2_SPIS2_SPI2_IRQHandler - B . - - PUBWEAK RTC2_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -RTC2_IRQHandler - B . - - PUBWEAK I2S_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -I2S_IRQHandler - B . - - PUBWEAK FPU_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -FPU_IRQHandler - B . - - PUBWEAK USBD_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -USBD_IRQHandler - B . - - PUBWEAK UARTE1_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -UARTE1_IRQHandler - B . - - PUBWEAK QSPI_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -QSPI_IRQHandler - B . - - PUBWEAK CRYPTOCELL_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -CRYPTOCELL_IRQHandler - B . - - PUBWEAK PWM3_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -PWM3_IRQHandler - B . - - PUBWEAK SPIM3_IRQHandler - SECTION .text:CODE:REORDER:NOROOT(1) -SPIM3_IRQHandler - B . - - - END - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf51_Vectors.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf51_Vectors.s deleted file mode 100644 index 9b824d9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf51_Vectors.s +++ /dev/null @@ -1,329 +0,0 @@ -/***************************************************************************** - * SEGGER Microcontroller GmbH & Co. KG * - * Solutions for real time microcontroller applications * - ***************************************************************************** - * * - * (c) 2017 SEGGER Microcontroller GmbH & Co. KG * - * * - * Internet: www.segger.com Support: support@segger.com * - * * - *****************************************************************************/ - -/***************************************************************************** - * Preprocessor Definitions * - * ------------------------ * - * VECTORS_IN_RAM * - * * - * If defined, an area of RAM will large enough to store the vector table * - * will be reserved. * - * * - *****************************************************************************/ - - .syntax unified - .code 16 - - .section .init, "ax" - .align 0 - -/***************************************************************************** - * Default Exception Handlers * - *****************************************************************************/ - - .thumb_func - .weak NMI_Handler -NMI_Handler: - b . - - .thumb_func - .weak HardFault_Handler -HardFault_Handler: - b . - - .thumb_func - .weak SVC_Handler -SVC_Handler: - b . - - .thumb_func - .weak PendSV_Handler -PendSV_Handler: - b . - - .thumb_func - .weak SysTick_Handler -SysTick_Handler: - b . - - .thumb_func -Dummy_Handler: - b . - -#if defined(__OPTIMIZATION_SMALL) - - .weak POWER_CLOCK_IRQHandler - .thumb_set POWER_CLOCK_IRQHandler,Dummy_Handler - - .weak RADIO_IRQHandler - .thumb_set RADIO_IRQHandler,Dummy_Handler - - .weak UART0_IRQHandler - .thumb_set UART0_IRQHandler,Dummy_Handler - - .weak SPI0_TWI0_IRQHandler - .thumb_set SPI0_TWI0_IRQHandler,Dummy_Handler - - .weak SPI1_TWI1_IRQHandler - .thumb_set SPI1_TWI1_IRQHandler,Dummy_Handler - - .weak GPIOTE_IRQHandler - .thumb_set GPIOTE_IRQHandler,Dummy_Handler - - .weak ADC_IRQHandler - .thumb_set ADC_IRQHandler,Dummy_Handler - - .weak TIMER0_IRQHandler - .thumb_set TIMER0_IRQHandler,Dummy_Handler - - .weak TIMER1_IRQHandler - .thumb_set TIMER1_IRQHandler,Dummy_Handler - - .weak TIMER2_IRQHandler - .thumb_set TIMER2_IRQHandler,Dummy_Handler - - .weak RTC0_IRQHandler - .thumb_set RTC0_IRQHandler,Dummy_Handler - - .weak TEMP_IRQHandler - .thumb_set TEMP_IRQHandler,Dummy_Handler - - .weak RNG_IRQHandler - .thumb_set RNG_IRQHandler,Dummy_Handler - - .weak ECB_IRQHandler - .thumb_set ECB_IRQHandler,Dummy_Handler - - .weak CCM_AAR_IRQHandler - .thumb_set CCM_AAR_IRQHandler,Dummy_Handler - - .weak WDT_IRQHandler - .thumb_set WDT_IRQHandler,Dummy_Handler - - .weak RTC1_IRQHandler - .thumb_set RTC1_IRQHandler,Dummy_Handler - - .weak QDEC_IRQHandler - .thumb_set QDEC_IRQHandler,Dummy_Handler - - .weak LPCOMP_IRQHandler - .thumb_set LPCOMP_IRQHandler,Dummy_Handler - - .weak SWI0_IRQHandler - .thumb_set SWI0_IRQHandler,Dummy_Handler - - .weak SWI1_IRQHandler - .thumb_set SWI1_IRQHandler,Dummy_Handler - - .weak SWI2_IRQHandler - .thumb_set SWI2_IRQHandler,Dummy_Handler - - .weak SWI3_IRQHandler - .thumb_set SWI3_IRQHandler,Dummy_Handler - - .weak SWI4_IRQHandler - .thumb_set SWI4_IRQHandler,Dummy_Handler - - .weak SWI5_IRQHandler - .thumb_set SWI5_IRQHandler,Dummy_Handler - -#else - - .thumb_func - .weak POWER_CLOCK_IRQHandler -POWER_CLOCK_IRQHandler: - b . - - .thumb_func - .weak RADIO_IRQHandler -RADIO_IRQHandler: - b . - - .thumb_func - .weak UART0_IRQHandler -UART0_IRQHandler: - b . - - .thumb_func - .weak SPI0_TWI0_IRQHandler -SPI0_TWI0_IRQHandler: - b . - - .thumb_func - .weak SPI1_TWI1_IRQHandler -SPI1_TWI1_IRQHandler: - b . - - .thumb_func - .weak GPIOTE_IRQHandler -GPIOTE_IRQHandler: - b . - - .thumb_func - .weak ADC_IRQHandler -ADC_IRQHandler: - b . - - .thumb_func - .weak TIMER0_IRQHandler -TIMER0_IRQHandler: - b . - - .thumb_func - .weak TIMER1_IRQHandler -TIMER1_IRQHandler: - b . - - .thumb_func - .weak TIMER2_IRQHandler -TIMER2_IRQHandler: - b . - - .thumb_func - .weak RTC0_IRQHandler -RTC0_IRQHandler: - b . - - .thumb_func - .weak TEMP_IRQHandler -TEMP_IRQHandler: - b . - - .thumb_func - .weak RNG_IRQHandler -RNG_IRQHandler: - b . - - .thumb_func - .weak ECB_IRQHandler -ECB_IRQHandler: - b . - - .thumb_func - .weak CCM_AAR_IRQHandler -CCM_AAR_IRQHandler: - b . - - .thumb_func - .weak WDT_IRQHandler -WDT_IRQHandler: - b . - - .thumb_func - .weak RTC1_IRQHandler -RTC1_IRQHandler: - b . - - .thumb_func - .weak QDEC_IRQHandler -QDEC_IRQHandler: - b . - - .thumb_func - .weak LPCOMP_IRQHandler -LPCOMP_IRQHandler: - b . - - .thumb_func - .weak SWI0_IRQHandler -SWI0_IRQHandler: - b . - - .thumb_func - .weak SWI1_IRQHandler -SWI1_IRQHandler: - b . - - .thumb_func - .weak SWI2_IRQHandler -SWI2_IRQHandler: - b . - - .thumb_func - .weak SWI3_IRQHandler -SWI3_IRQHandler: - b . - - .thumb_func - .weak SWI4_IRQHandler -SWI4_IRQHandler: - b . - - .thumb_func - .weak SWI5_IRQHandler -SWI5_IRQHandler: - b . - -#endif - -/***************************************************************************** - * Vector Table * - *****************************************************************************/ - - .section .vectors, "ax" - .align 0 - .global _vectors - .extern __stack_end__ - .extern Reset_Handler - -_vectors: - .word __stack_end__ - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word SVC_Handler - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word PendSV_Handler - .word SysTick_Handler - .word POWER_CLOCK_IRQHandler - .word RADIO_IRQHandler - .word UART0_IRQHandler - .word SPI0_TWI0_IRQHandler - .word SPI1_TWI1_IRQHandler - .word Dummy_Handler /* Reserved */ - .word GPIOTE_IRQHandler - .word ADC_IRQHandler - .word TIMER0_IRQHandler - .word TIMER1_IRQHandler - .word TIMER2_IRQHandler - .word RTC0_IRQHandler - .word TEMP_IRQHandler - .word RNG_IRQHandler - .word ECB_IRQHandler - .word CCM_AAR_IRQHandler - .word WDT_IRQHandler - .word RTC1_IRQHandler - .word QDEC_IRQHandler - .word LPCOMP_IRQHandler - .word SWI0_IRQHandler - .word SWI1_IRQHandler - .word SWI2_IRQHandler - .word SWI3_IRQHandler - .word SWI4_IRQHandler - .word SWI5_IRQHandler -_vectors_end: - -#ifdef VECTORS_IN_RAM - .section .vectors_ram, "ax" - .align 0 - .global _vectors_ram - -_vectors_ram: - .space _vectors_end - _vectors, 0 -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52810_Vectors.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52810_Vectors.s deleted file mode 100644 index f504da3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52810_Vectors.s +++ /dev/null @@ -1,369 +0,0 @@ -/***************************************************************************** - * SEGGER Microcontroller GmbH & Co. KG * - * Solutions for real time microcontroller applications * - ***************************************************************************** - * * - * (c) 2017 SEGGER Microcontroller GmbH & Co. KG * - * * - * Internet: www.segger.com Support: support@segger.com * - * * - *****************************************************************************/ - -/***************************************************************************** - * Preprocessor Definitions * - * ------------------------ * - * VECTORS_IN_RAM * - * * - * If defined, an area of RAM will large enough to store the vector table * - * will be reserved. * - * * - *****************************************************************************/ - - .syntax unified - .code 16 - - .section .init, "ax" - .align 0 - -/***************************************************************************** - * Default Exception Handlers * - *****************************************************************************/ - - .thumb_func - .weak NMI_Handler -NMI_Handler: - b . - - .thumb_func - .weak HardFault_Handler -HardFault_Handler: - b . - - .thumb_func - .weak MemoryManagement_Handler -MemoryManagement_Handler: - b . - - .thumb_func - .weak BusFault_Handler -BusFault_Handler: - b . - - .thumb_func - .weak UsageFault_Handler -UsageFault_Handler: - b . - - .thumb_func - .weak SVC_Handler -SVC_Handler: - b . - - .thumb_func - .weak DebugMon_Handler -DebugMon_Handler: - b . - - .thumb_func - .weak PendSV_Handler -PendSV_Handler: - b . - - .thumb_func - .weak SysTick_Handler -SysTick_Handler: - b . - - .thumb_func -Dummy_Handler: - b . - -#if defined(__OPTIMIZATION_SMALL) - - .weak POWER_CLOCK_IRQHandler - .thumb_set POWER_CLOCK_IRQHandler,Dummy_Handler - - .weak RADIO_IRQHandler - .thumb_set RADIO_IRQHandler,Dummy_Handler - - .weak UARTE0_IRQHandler - .thumb_set UARTE0_IRQHandler,Dummy_Handler - - .weak TWIM0_TWIS0_IRQHandler - .thumb_set TWIM0_TWIS0_IRQHandler,Dummy_Handler - - .weak SPIM0_SPIS0_IRQHandler - .thumb_set SPIM0_SPIS0_IRQHandler,Dummy_Handler - - .weak GPIOTE_IRQHandler - .thumb_set GPIOTE_IRQHandler,Dummy_Handler - - .weak SAADC_IRQHandler - .thumb_set SAADC_IRQHandler,Dummy_Handler - - .weak TIMER0_IRQHandler - .thumb_set TIMER0_IRQHandler,Dummy_Handler - - .weak TIMER1_IRQHandler - .thumb_set TIMER1_IRQHandler,Dummy_Handler - - .weak TIMER2_IRQHandler - .thumb_set TIMER2_IRQHandler,Dummy_Handler - - .weak RTC0_IRQHandler - .thumb_set RTC0_IRQHandler,Dummy_Handler - - .weak TEMP_IRQHandler - .thumb_set TEMP_IRQHandler,Dummy_Handler - - .weak RNG_IRQHandler - .thumb_set RNG_IRQHandler,Dummy_Handler - - .weak ECB_IRQHandler - .thumb_set ECB_IRQHandler,Dummy_Handler - - .weak CCM_AAR_IRQHandler - .thumb_set CCM_AAR_IRQHandler,Dummy_Handler - - .weak WDT_IRQHandler - .thumb_set WDT_IRQHandler,Dummy_Handler - - .weak RTC1_IRQHandler - .thumb_set RTC1_IRQHandler,Dummy_Handler - - .weak QDEC_IRQHandler - .thumb_set QDEC_IRQHandler,Dummy_Handler - - .weak COMP_IRQHandler - .thumb_set COMP_IRQHandler,Dummy_Handler - - .weak SWI0_EGU0_IRQHandler - .thumb_set SWI0_EGU0_IRQHandler,Dummy_Handler - - .weak SWI1_EGU1_IRQHandler - .thumb_set SWI1_EGU1_IRQHandler,Dummy_Handler - - .weak SWI2_IRQHandler - .thumb_set SWI2_IRQHandler,Dummy_Handler - - .weak SWI3_IRQHandler - .thumb_set SWI3_IRQHandler,Dummy_Handler - - .weak SWI4_IRQHandler - .thumb_set SWI4_IRQHandler,Dummy_Handler - - .weak SWI5_IRQHandler - .thumb_set SWI5_IRQHandler,Dummy_Handler - - .weak PWM0_IRQHandler - .thumb_set PWM0_IRQHandler,Dummy_Handler - - .weak PDM_IRQHandler - .thumb_set PDM_IRQHandler,Dummy_Handler - -#else - - .thumb_func - .weak POWER_CLOCK_IRQHandler -POWER_CLOCK_IRQHandler: - b . - - .thumb_func - .weak RADIO_IRQHandler -RADIO_IRQHandler: - b . - - .thumb_func - .weak UARTE0_IRQHandler -UARTE0_IRQHandler: - b . - - .thumb_func - .weak TWIM0_TWIS0_IRQHandler -TWIM0_TWIS0_IRQHandler: - b . - - .thumb_func - .weak SPIM0_SPIS0_IRQHandler -SPIM0_SPIS0_IRQHandler: - b . - - .thumb_func - .weak GPIOTE_IRQHandler -GPIOTE_IRQHandler: - b . - - .thumb_func - .weak SAADC_IRQHandler -SAADC_IRQHandler: - b . - - .thumb_func - .weak TIMER0_IRQHandler -TIMER0_IRQHandler: - b . - - .thumb_func - .weak TIMER1_IRQHandler -TIMER1_IRQHandler: - b . - - .thumb_func - .weak TIMER2_IRQHandler -TIMER2_IRQHandler: - b . - - .thumb_func - .weak RTC0_IRQHandler -RTC0_IRQHandler: - b . - - .thumb_func - .weak TEMP_IRQHandler -TEMP_IRQHandler: - b . - - .thumb_func - .weak RNG_IRQHandler -RNG_IRQHandler: - b . - - .thumb_func - .weak ECB_IRQHandler -ECB_IRQHandler: - b . - - .thumb_func - .weak CCM_AAR_IRQHandler -CCM_AAR_IRQHandler: - b . - - .thumb_func - .weak WDT_IRQHandler -WDT_IRQHandler: - b . - - .thumb_func - .weak RTC1_IRQHandler -RTC1_IRQHandler: - b . - - .thumb_func - .weak QDEC_IRQHandler -QDEC_IRQHandler: - b . - - .thumb_func - .weak COMP_IRQHandler -COMP_IRQHandler: - b . - - .thumb_func - .weak SWI0_EGU0_IRQHandler -SWI0_EGU0_IRQHandler: - b . - - .thumb_func - .weak SWI1_EGU1_IRQHandler -SWI1_EGU1_IRQHandler: - b . - - .thumb_func - .weak SWI2_IRQHandler -SWI2_IRQHandler: - b . - - .thumb_func - .weak SWI3_IRQHandler -SWI3_IRQHandler: - b . - - .thumb_func - .weak SWI4_IRQHandler -SWI4_IRQHandler: - b . - - .thumb_func - .weak SWI5_IRQHandler -SWI5_IRQHandler: - b . - - .thumb_func - .weak PWM0_IRQHandler -PWM0_IRQHandler: - b . - - .thumb_func - .weak PDM_IRQHandler -PDM_IRQHandler: - b . - -#endif - -/***************************************************************************** - * Vector Table * - *****************************************************************************/ - - .section .vectors, "ax" - .align 0 - .global _vectors - .extern __stack_end__ - .extern Reset_Handler - -_vectors: - .word __stack_end__ - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemoryManagement_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word SVC_Handler - .word DebugMon_Handler - .word 0 /* Reserved */ - .word PendSV_Handler - .word SysTick_Handler - .word POWER_CLOCK_IRQHandler - .word RADIO_IRQHandler - .word UARTE0_IRQHandler - .word TWIM0_TWIS0_IRQHandler - .word SPIM0_SPIS0_IRQHandler - .word 0 - .word GPIOTE_IRQHandler - .word SAADC_IRQHandler - .word TIMER0_IRQHandler - .word TIMER1_IRQHandler - .word TIMER2_IRQHandler - .word RTC0_IRQHandler - .word TEMP_IRQHandler - .word RNG_IRQHandler - .word ECB_IRQHandler - .word CCM_AAR_IRQHandler - .word WDT_IRQHandler - .word RTC1_IRQHandler - .word QDEC_IRQHandler - .word COMP_IRQHandler - .word SWI0_EGU0_IRQHandler - .word SWI1_EGU1_IRQHandler - .word SWI2_IRQHandler - .word SWI3_IRQHandler - .word SWI4_IRQHandler - .word SWI5_IRQHandler - .word 0 - .word 0 - .word PWM0_IRQHandler - .word PDM_IRQHandler -_vectors_end: - -#ifdef VECTORS_IN_RAM - .section .vectors_ram, "ax" - .align 0 - .global _vectors_ram - -_vectors_ram: - .space _vectors_end - _vectors, 0 -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52840_Vectors.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52840_Vectors.s deleted file mode 100644 index 1606c79..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52840_Vectors.s +++ /dev/null @@ -1,513 +0,0 @@ -/***************************************************************************** - * SEGGER Microcontroller GmbH & Co. KG * - * Solutions for real time microcontroller applications * - ***************************************************************************** - * * - * (c) 2017 SEGGER Microcontroller GmbH & Co. KG * - * * - * Internet: www.segger.com Support: support@segger.com * - * * - *****************************************************************************/ - -/***************************************************************************** - * Preprocessor Definitions * - * ------------------------ * - * VECTORS_IN_RAM * - * * - * If defined, an area of RAM will large enough to store the vector table * - * will be reserved. * - * * - *****************************************************************************/ - - .syntax unified - .code 16 - - .section .init, "ax" - .align 0 - -/***************************************************************************** - * Default Exception Handlers * - *****************************************************************************/ - - .thumb_func - .weak NMI_Handler -NMI_Handler: - b . - - .thumb_func - .weak HardFault_Handler -HardFault_Handler: - b . - - .thumb_func - .weak MemoryManagement_Handler -MemoryManagement_Handler: - b . - - .thumb_func - .weak BusFault_Handler -BusFault_Handler: - b . - - .thumb_func - .weak UsageFault_Handler -UsageFault_Handler: - b . - - .thumb_func - .weak SVC_Handler -SVC_Handler: - b . - - .thumb_func - .weak DebugMon_Handler -DebugMon_Handler: - b . - - .thumb_func - .weak PendSV_Handler -PendSV_Handler: - b . - - .thumb_func - .weak SysTick_Handler -SysTick_Handler: - b . - - .thumb_func -Dummy_Handler: - b . - -#if defined(__OPTIMIZATION_SMALL) - - .weak POWER_CLOCK_IRQHandler - .thumb_set POWER_CLOCK_IRQHandler,Dummy_Handler - - .weak RADIO_IRQHandler - .thumb_set RADIO_IRQHandler,Dummy_Handler - - .weak UARTE0_UART0_IRQHandler - .thumb_set UARTE0_UART0_IRQHandler,Dummy_Handler - - .weak SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - .thumb_set SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler,Dummy_Handler - - .weak SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - .thumb_set SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler,Dummy_Handler - - .weak NFCT_IRQHandler - .thumb_set NFCT_IRQHandler,Dummy_Handler - - .weak GPIOTE_IRQHandler - .thumb_set GPIOTE_IRQHandler,Dummy_Handler - - .weak SAADC_IRQHandler - .thumb_set SAADC_IRQHandler,Dummy_Handler - - .weak TIMER0_IRQHandler - .thumb_set TIMER0_IRQHandler,Dummy_Handler - - .weak TIMER1_IRQHandler - .thumb_set TIMER1_IRQHandler,Dummy_Handler - - .weak TIMER2_IRQHandler - .thumb_set TIMER2_IRQHandler,Dummy_Handler - - .weak RTC0_IRQHandler - .thumb_set RTC0_IRQHandler,Dummy_Handler - - .weak TEMP_IRQHandler - .thumb_set TEMP_IRQHandler,Dummy_Handler - - .weak RNG_IRQHandler - .thumb_set RNG_IRQHandler,Dummy_Handler - - .weak ECB_IRQHandler - .thumb_set ECB_IRQHandler,Dummy_Handler - - .weak CCM_AAR_IRQHandler - .thumb_set CCM_AAR_IRQHandler,Dummy_Handler - - .weak WDT_IRQHandler - .thumb_set WDT_IRQHandler,Dummy_Handler - - .weak RTC1_IRQHandler - .thumb_set RTC1_IRQHandler,Dummy_Handler - - .weak QDEC_IRQHandler - .thumb_set QDEC_IRQHandler,Dummy_Handler - - .weak COMP_LPCOMP_IRQHandler - .thumb_set COMP_LPCOMP_IRQHandler,Dummy_Handler - - .weak SWI0_EGU0_IRQHandler - .thumb_set SWI0_EGU0_IRQHandler,Dummy_Handler - - .weak SWI1_EGU1_IRQHandler - .thumb_set SWI1_EGU1_IRQHandler,Dummy_Handler - - .weak SWI2_EGU2_IRQHandler - .thumb_set SWI2_EGU2_IRQHandler,Dummy_Handler - - .weak SWI3_EGU3_IRQHandler - .thumb_set SWI3_EGU3_IRQHandler,Dummy_Handler - - .weak SWI4_EGU4_IRQHandler - .thumb_set SWI4_EGU4_IRQHandler,Dummy_Handler - - .weak SWI5_EGU5_IRQHandler - .thumb_set SWI5_EGU5_IRQHandler,Dummy_Handler - - .weak TIMER3_IRQHandler - .thumb_set TIMER3_IRQHandler,Dummy_Handler - - .weak TIMER4_IRQHandler - .thumb_set TIMER4_IRQHandler,Dummy_Handler - - .weak PWM0_IRQHandler - .thumb_set PWM0_IRQHandler,Dummy_Handler - - .weak PDM_IRQHandler - .thumb_set PDM_IRQHandler,Dummy_Handler - - .weak MWU_IRQHandler - .thumb_set MWU_IRQHandler,Dummy_Handler - - .weak PWM1_IRQHandler - .thumb_set PWM1_IRQHandler,Dummy_Handler - - .weak PWM2_IRQHandler - .thumb_set PWM2_IRQHandler,Dummy_Handler - - .weak SPIM2_SPIS2_SPI2_IRQHandler - .thumb_set SPIM2_SPIS2_SPI2_IRQHandler,Dummy_Handler - - .weak RTC2_IRQHandler - .thumb_set RTC2_IRQHandler,Dummy_Handler - - .weak I2S_IRQHandler - .thumb_set I2S_IRQHandler,Dummy_Handler - - .weak FPU_IRQHandler - .thumb_set FPU_IRQHandler,Dummy_Handler - - .weak USBD_IRQHandler - .thumb_set USBD_IRQHandler,Dummy_Handler - - .weak UARTE1_IRQHandler - .thumb_set UARTE1_IRQHandler,Dummy_Handler - - .weak QSPI_IRQHandler - .thumb_set QSPI_IRQHandler,Dummy_Handler - - .weak CRYPTOCELL_IRQHandler - .thumb_set CRYPTOCELL_IRQHandler,Dummy_Handler - - .weak SPIM3_IRQHandler - .thumb_set SPIM3_IRQHandler,Dummy_Handler - - .weak PWM3_IRQHandler - .thumb_set PWM3_IRQHandler,Dummy_Handler - -#else - - .thumb_func - .weak POWER_CLOCK_IRQHandler -POWER_CLOCK_IRQHandler: - b . - - .thumb_func - .weak RADIO_IRQHandler -RADIO_IRQHandler: - b . - - .thumb_func - .weak UARTE0_UART0_IRQHandler -UARTE0_UART0_IRQHandler: - b . - - .thumb_func - .weak SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler -SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler: - b . - - .thumb_func - .weak SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler -SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler: - b . - - .thumb_func - .weak NFCT_IRQHandler -NFCT_IRQHandler: - b . - - .thumb_func - .weak GPIOTE_IRQHandler -GPIOTE_IRQHandler: - b . - - .thumb_func - .weak SAADC_IRQHandler -SAADC_IRQHandler: - b . - - .thumb_func - .weak TIMER0_IRQHandler -TIMER0_IRQHandler: - b . - - .thumb_func - .weak TIMER1_IRQHandler -TIMER1_IRQHandler: - b . - - .thumb_func - .weak TIMER2_IRQHandler -TIMER2_IRQHandler: - b . - - .thumb_func - .weak RTC0_IRQHandler -RTC0_IRQHandler: - b . - - .thumb_func - .weak TEMP_IRQHandler -TEMP_IRQHandler: - b . - - .thumb_func - .weak RNG_IRQHandler -RNG_IRQHandler: - b . - - .thumb_func - .weak ECB_IRQHandler -ECB_IRQHandler: - b . - - .thumb_func - .weak CCM_AAR_IRQHandler -CCM_AAR_IRQHandler: - b . - - .thumb_func - .weak WDT_IRQHandler -WDT_IRQHandler: - b . - - .thumb_func - .weak RTC1_IRQHandler -RTC1_IRQHandler: - b . - - .thumb_func - .weak QDEC_IRQHandler -QDEC_IRQHandler: - b . - - .thumb_func - .weak COMP_LPCOMP_IRQHandler -COMP_LPCOMP_IRQHandler: - b . - - .thumb_func - .weak SWI0_EGU0_IRQHandler -SWI0_EGU0_IRQHandler: - b . - - .thumb_func - .weak SWI1_EGU1_IRQHandler -SWI1_EGU1_IRQHandler: - b . - - .thumb_func - .weak SWI2_EGU2_IRQHandler -SWI2_EGU2_IRQHandler: - b . - - .thumb_func - .weak SWI3_EGU3_IRQHandler -SWI3_EGU3_IRQHandler: - b . - - .thumb_func - .weak SWI4_EGU4_IRQHandler -SWI4_EGU4_IRQHandler: - b . - - .thumb_func - .weak SWI5_EGU5_IRQHandler -SWI5_EGU5_IRQHandler: - b . - - .thumb_func - .weak TIMER3_IRQHandler -TIMER3_IRQHandler: - b . - - .thumb_func - .weak TIMER4_IRQHandler -TIMER4_IRQHandler: - b . - - .thumb_func - .weak PWM0_IRQHandler -PWM0_IRQHandler: - b . - - .thumb_func - .weak PDM_IRQHandler -PDM_IRQHandler: - b . - - .thumb_func - .weak MWU_IRQHandler -MWU_IRQHandler: - b . - - .thumb_func - .weak PWM1_IRQHandler -PWM1_IRQHandler: - b . - - .thumb_func - .weak PWM2_IRQHandler -PWM2_IRQHandler: - b . - - .thumb_func - .weak SPIM2_SPIS2_SPI2_IRQHandler -SPIM2_SPIS2_SPI2_IRQHandler: - b . - - .thumb_func - .weak RTC2_IRQHandler -RTC2_IRQHandler: - b . - - .thumb_func - .weak I2S_IRQHandler -I2S_IRQHandler: - b . - - .thumb_func - .weak FPU_IRQHandler -FPU_IRQHandler: - b . - - .thumb_func - .weak USBD_IRQHandler -USBD_IRQHandler: - b . - - .thumb_func - .weak UARTE1_IRQHandler -UARTE1_IRQHandler: - b . - - .thumb_func - .weak QSPI_IRQHandler -QSPI_IRQHandler: - b . - - .thumb_func - .weak CRYPTOCELL_IRQHandler -CRYPTOCELL_IRQHandler: - b . - - .thumb_func - .weak SPIM3_IRQHandler -SPIM3_IRQHandler: - b . - - .thumb_func - .weak PWM3_IRQHandler -PWM3_IRQHandler: - b . - -#endif - -/***************************************************************************** - * Vector Table * - *****************************************************************************/ - - .section .vectors, "ax" - .align 0 - .global _vectors - .extern __stack_end__ - .extern Reset_Handler - -_vectors: - .word __stack_end__ - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemoryManagement_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word SVC_Handler - .word DebugMon_Handler - .word 0 /* Reserved */ - .word PendSV_Handler - .word SysTick_Handler - .word POWER_CLOCK_IRQHandler - .word RADIO_IRQHandler - .word UARTE0_UART0_IRQHandler - .word SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - .word SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - .word NFCT_IRQHandler - .word GPIOTE_IRQHandler - .word SAADC_IRQHandler - .word TIMER0_IRQHandler - .word TIMER1_IRQHandler - .word TIMER2_IRQHandler - .word RTC0_IRQHandler - .word TEMP_IRQHandler - .word RNG_IRQHandler - .word ECB_IRQHandler - .word CCM_AAR_IRQHandler - .word WDT_IRQHandler - .word RTC1_IRQHandler - .word QDEC_IRQHandler - .word COMP_LPCOMP_IRQHandler - .word SWI0_EGU0_IRQHandler - .word SWI1_EGU1_IRQHandler - .word SWI2_EGU2_IRQHandler - .word SWI3_EGU3_IRQHandler - .word SWI4_EGU4_IRQHandler - .word SWI5_EGU5_IRQHandler - .word TIMER3_IRQHandler - .word TIMER4_IRQHandler - .word PWM0_IRQHandler - .word PDM_IRQHandler - .word Dummy_Handler /* Reserved */ - .word Dummy_Handler /* Reserved */ - .word MWU_IRQHandler - .word PWM1_IRQHandler - .word PWM2_IRQHandler - .word SPIM2_SPIS2_SPI2_IRQHandler - .word RTC2_IRQHandler - .word I2S_IRQHandler - .word FPU_IRQHandler - .word USBD_IRQHandler - .word UARTE1_IRQHandler - .word QSPI_IRQHandler - .word CRYPTOCELL_IRQHandler - .word SPIM3_IRQHandler - .word Dummy_Handler /* Reserved */ - .word PWM3_IRQHandler -_vectors_end: - -#ifdef VECTORS_IN_RAM - .section .vectors_ram, "ax" - .align 0 - .global _vectors_ram - -_vectors_ram: - .space _vectors_end - _vectors, 0 -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52_Vectors.s b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52_Vectors.s deleted file mode 100644 index 4e486d4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/ses/ses_nrf52_Vectors.s +++ /dev/null @@ -1,458 +0,0 @@ -/***************************************************************************** - * SEGGER Microcontroller GmbH & Co. KG * - * Solutions for real time microcontroller applications * - ***************************************************************************** - * * - * (c) 2017 SEGGER Microcontroller GmbH & Co. KG * - * * - * Internet: www.segger.com Support: support@segger.com * - * * - *****************************************************************************/ - -/***************************************************************************** - * Preprocessor Definitions * - * ------------------------ * - * VECTORS_IN_RAM * - * * - * If defined, an area of RAM will large enough to store the vector table * - * will be reserved. * - * * - *****************************************************************************/ - - .syntax unified - .code 16 - - .section .init, "ax" - .align 0 - -/***************************************************************************** - * Default Exception Handlers * - *****************************************************************************/ - - .thumb_func - .weak NMI_Handler -NMI_Handler: - b . - - .thumb_func - .weak HardFault_Handler -HardFault_Handler: - b . - - .thumb_func - .weak MemoryManagement_Handler -MemoryManagement_Handler: - b . - - .thumb_func - .weak BusFault_Handler -BusFault_Handler: - b . - - .thumb_func - .weak UsageFault_Handler -UsageFault_Handler: - b . - - .thumb_func - .weak SVC_Handler -SVC_Handler: - b . - - .thumb_func - .weak DebugMon_Handler -DebugMon_Handler: - b . - - .thumb_func - .weak PendSV_Handler -PendSV_Handler: - b . - - .thumb_func - .weak SysTick_Handler -SysTick_Handler: - b . - - .thumb_func -Dummy_Handler: - b . - -#if defined(__OPTIMIZATION_SMALL) - - .weak POWER_CLOCK_IRQHandler - .thumb_set POWER_CLOCK_IRQHandler,Dummy_Handler - - .weak RADIO_IRQHandler - .thumb_set RADIO_IRQHandler,Dummy_Handler - - .weak UARTE0_UART0_IRQHandler - .thumb_set UARTE0_UART0_IRQHandler,Dummy_Handler - - .weak SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - .thumb_set SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler,Dummy_Handler - - .weak SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - .thumb_set SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler,Dummy_Handler - - .weak NFCT_IRQHandler - .thumb_set NFCT_IRQHandler,Dummy_Handler - - .weak GPIOTE_IRQHandler - .thumb_set GPIOTE_IRQHandler,Dummy_Handler - - .weak SAADC_IRQHandler - .thumb_set SAADC_IRQHandler,Dummy_Handler - - .weak TIMER0_IRQHandler - .thumb_set TIMER0_IRQHandler,Dummy_Handler - - .weak TIMER1_IRQHandler - .thumb_set TIMER1_IRQHandler,Dummy_Handler - - .weak TIMER2_IRQHandler - .thumb_set TIMER2_IRQHandler,Dummy_Handler - - .weak RTC0_IRQHandler - .thumb_set RTC0_IRQHandler,Dummy_Handler - - .weak TEMP_IRQHandler - .thumb_set TEMP_IRQHandler,Dummy_Handler - - .weak RNG_IRQHandler - .thumb_set RNG_IRQHandler,Dummy_Handler - - .weak ECB_IRQHandler - .thumb_set ECB_IRQHandler,Dummy_Handler - - .weak CCM_AAR_IRQHandler - .thumb_set CCM_AAR_IRQHandler,Dummy_Handler - - .weak WDT_IRQHandler - .thumb_set WDT_IRQHandler,Dummy_Handler - - .weak RTC1_IRQHandler - .thumb_set RTC1_IRQHandler,Dummy_Handler - - .weak QDEC_IRQHandler - .thumb_set QDEC_IRQHandler,Dummy_Handler - - .weak COMP_LPCOMP_IRQHandler - .thumb_set COMP_LPCOMP_IRQHandler,Dummy_Handler - - .weak SWI0_EGU0_IRQHandler - .thumb_set SWI0_EGU0_IRQHandler,Dummy_Handler - - .weak SWI1_EGU1_IRQHandler - .thumb_set SWI1_EGU1_IRQHandler,Dummy_Handler - - .weak SWI2_EGU2_IRQHandler - .thumb_set SWI2_EGU2_IRQHandler,Dummy_Handler - - .weak SWI3_EGU3_IRQHandler - .thumb_set SWI3_EGU3_IRQHandler,Dummy_Handler - - .weak SWI4_EGU4_IRQHandler - .thumb_set SWI4_EGU4_IRQHandler,Dummy_Handler - - .weak SWI5_EGU5_IRQHandler - .thumb_set SWI5_EGU5_IRQHandler,Dummy_Handler - - .weak TIMER3_IRQHandler - .thumb_set TIMER3_IRQHandler,Dummy_Handler - - .weak TIMER4_IRQHandler - .thumb_set TIMER4_IRQHandler,Dummy_Handler - - .weak PWM0_IRQHandler - .thumb_set PWM0_IRQHandler,Dummy_Handler - - .weak PDM_IRQHandler - .thumb_set PDM_IRQHandler,Dummy_Handler - - .weak MWU_IRQHandler - .thumb_set MWU_IRQHandler,Dummy_Handler - - .weak PWM1_IRQHandler - .thumb_set PWM1_IRQHandler,Dummy_Handler - - .weak PWM2_IRQHandler - .thumb_set PWM2_IRQHandler,Dummy_Handler - - .weak SPIM2_SPIS2_SPI2_IRQHandler - .thumb_set SPIM2_SPIS2_SPI2_IRQHandler,Dummy_Handler - - .weak RTC2_IRQHandler - .thumb_set RTC2_IRQHandler,Dummy_Handler - - .weak I2S_IRQHandler - .thumb_set I2S_IRQHandler,Dummy_Handler - - .weak FPU_IRQHandler - .thumb_set FPU_IRQHandler,Dummy_Handler - -#else - - .thumb_func - .weak POWER_CLOCK_IRQHandler -POWER_CLOCK_IRQHandler: - b . - - .thumb_func - .weak RADIO_IRQHandler -RADIO_IRQHandler: - b . - - .thumb_func - .weak UARTE0_UART0_IRQHandler -UARTE0_UART0_IRQHandler: - b . - - .thumb_func - .weak SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler -SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler: - b . - - .thumb_func - .weak SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler -SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler: - b . - - .thumb_func - .weak NFCT_IRQHandler -NFCT_IRQHandler: - b . - - .thumb_func - .weak GPIOTE_IRQHandler -GPIOTE_IRQHandler: - b . - - .thumb_func - .weak SAADC_IRQHandler -SAADC_IRQHandler: - b . - - .thumb_func - .weak TIMER0_IRQHandler -TIMER0_IRQHandler: - b . - - .thumb_func - .weak TIMER1_IRQHandler -TIMER1_IRQHandler: - b . - - .thumb_func - .weak TIMER2_IRQHandler -TIMER2_IRQHandler: - b . - - .thumb_func - .weak RTC0_IRQHandler -RTC0_IRQHandler: - b . - - .thumb_func - .weak TEMP_IRQHandler -TEMP_IRQHandler: - b . - - .thumb_func - .weak RNG_IRQHandler -RNG_IRQHandler: - b . - - .thumb_func - .weak ECB_IRQHandler -ECB_IRQHandler: - b . - - .thumb_func - .weak CCM_AAR_IRQHandler -CCM_AAR_IRQHandler: - b . - - .thumb_func - .weak WDT_IRQHandler -WDT_IRQHandler: - b . - - .thumb_func - .weak RTC1_IRQHandler -RTC1_IRQHandler: - b . - - .thumb_func - .weak QDEC_IRQHandler -QDEC_IRQHandler: - b . - - .thumb_func - .weak COMP_LPCOMP_IRQHandler -COMP_LPCOMP_IRQHandler: - b . - - .thumb_func - .weak SWI0_EGU0_IRQHandler -SWI0_EGU0_IRQHandler: - b . - - .thumb_func - .weak SWI1_EGU1_IRQHandler -SWI1_EGU1_IRQHandler: - b . - - .thumb_func - .weak SWI2_EGU2_IRQHandler -SWI2_EGU2_IRQHandler: - b . - - .thumb_func - .weak SWI3_EGU3_IRQHandler -SWI3_EGU3_IRQHandler: - b . - - .thumb_func - .weak SWI4_EGU4_IRQHandler -SWI4_EGU4_IRQHandler: - b . - - .thumb_func - .weak SWI5_EGU5_IRQHandler -SWI5_EGU5_IRQHandler: - b . - - .thumb_func - .weak TIMER3_IRQHandler -TIMER3_IRQHandler: - b . - - .thumb_func - .weak TIMER4_IRQHandler -TIMER4_IRQHandler: - b . - - .thumb_func - .weak PWM0_IRQHandler -PWM0_IRQHandler: - b . - - .thumb_func - .weak PDM_IRQHandler -PDM_IRQHandler: - b . - - .thumb_func - .weak MWU_IRQHandler -MWU_IRQHandler: - b . - - .thumb_func - .weak PWM1_IRQHandler -PWM1_IRQHandler: - b . - - .thumb_func - .weak PWM2_IRQHandler -PWM2_IRQHandler: - b . - - .thumb_func - .weak SPIM2_SPIS2_SPI2_IRQHandler -SPIM2_SPIS2_SPI2_IRQHandler: - b . - - .thumb_func - .weak RTC2_IRQHandler -RTC2_IRQHandler: - b . - - .thumb_func - .weak I2S_IRQHandler -I2S_IRQHandler: - b . - - .thumb_func - .weak FPU_IRQHandler -FPU_IRQHandler: - b . - -#endif - -/***************************************************************************** - * Vector Table * - *****************************************************************************/ - - .section .vectors, "ax" - .align 0 - .global _vectors - .extern __stack_end__ - .extern Reset_Handler - -_vectors: - .word __stack_end__ - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemoryManagement_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word SVC_Handler - .word DebugMon_Handler - .word 0 /* Reserved */ - .word PendSV_Handler - .word SysTick_Handler - .word POWER_CLOCK_IRQHandler - .word RADIO_IRQHandler - .word UARTE0_UART0_IRQHandler - .word SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler - .word SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler - .word NFCT_IRQHandler - .word GPIOTE_IRQHandler - .word SAADC_IRQHandler - .word TIMER0_IRQHandler - .word TIMER1_IRQHandler - .word TIMER2_IRQHandler - .word RTC0_IRQHandler - .word TEMP_IRQHandler - .word RNG_IRQHandler - .word ECB_IRQHandler - .word CCM_AAR_IRQHandler - .word WDT_IRQHandler - .word RTC1_IRQHandler - .word QDEC_IRQHandler - .word COMP_LPCOMP_IRQHandler - .word SWI0_EGU0_IRQHandler - .word SWI1_EGU1_IRQHandler - .word SWI2_EGU2_IRQHandler - .word SWI3_EGU3_IRQHandler - .word SWI4_EGU4_IRQHandler - .word SWI5_EGU5_IRQHandler - .word TIMER3_IRQHandler - .word TIMER4_IRQHandler - .word PWM0_IRQHandler - .word PDM_IRQHandler - .word Dummy_Handler /* Reserved */ - .word Dummy_Handler /* Reserved */ - .word MWU_IRQHandler - .word PWM1_IRQHandler - .word PWM2_IRQHandler - .word SPIM2_SPIS2_SPI2_IRQHandler - .word RTC2_IRQHandler - .word I2S_IRQHandler - .word FPU_IRQHandler -_vectors_end: - -#ifdef VECTORS_IN_RAM - .section .vectors_ram, "ax" - .align 0 - .global _vectors_ram - -_vectors_ram: - .space _vectors_end - _vectors, 0 -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.c deleted file mode 100644 index 54f499c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - -/* NOTE: Template files (including this one) are application specific and therefore expected to - be copied into the application project folder prior to its use! */ - -#include -#include -#include "nrf.h" -#include "system_nrf51.h" - -/*lint ++flb "Enter library region" */ - - -#define __SYSTEM_CLOCK (16000000UL) /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */ - -static bool is_manual_peripheral_setup_needed(void); -static bool is_disabled_in_debug_needed(void); -static bool is_peripheral_domain_setup_needed(void); - - -#if defined ( __CC_ARM ) - uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK; -#elif defined ( __ICCARM__ ) - __root uint32_t SystemCoreClock = __SYSTEM_CLOCK; -#elif defined ( __GNUC__ ) - uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK; -#endif - -void SystemCoreClockUpdate(void) -{ - SystemCoreClock = __SYSTEM_CLOCK; -} - -void SystemInit(void) -{ - /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. - It can also be done in the application main() function. */ - - /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required - to enable the use of peripherals" found at Product Anomaly document for your device found at - https://www.nordicsemi.com/. The side effect of executing these instructions in the devices - that do not need it is that the new peripherals in the second generation devices (LPCOMP for - example) will not be available. */ - if (is_manual_peripheral_setup_needed()) - { - *(uint32_t volatile *)0x40000504 = 0xC007FFDF; - *(uint32_t volatile *)0x40006C18 = 0x00008000; - } - - /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG - register is incorrect" found at Product Anomaly document for your device found at - https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */ - if (is_disabled_in_debug_needed()) - { - NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; - } - - /* Execute the following code to eliminate excessive current in sleep mode with RAM retention in nRF51802 devices, - as indicated by PAN 76 "System: Excessive current in sleep mode with retention" found at Product Anomaly document - for your device found at https://www.nordicsemi.com/. */ - if (is_peripheral_domain_setup_needed()){ - if (*(uint32_t volatile *)0x4006EC00 != 1){ - *(uint32_t volatile *)0x4006EC00 = 0x9375; - while (*(uint32_t volatile *)0x4006EC00 != 1){ - } - } - *(uint32_t volatile *)0x4006EC14 = 0xC0; - } -} - - -static bool is_manual_peripheral_setup_needed(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)) - { - if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x00) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0)) - { - return true; - } - if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x10) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0)) - { - return true; - } - if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0)) - { - return true; - } - } - - return false; -} - -static bool is_disabled_in_debug_needed(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)) - { - if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0)) - { - return true; - } - } - - return false; -} - -static bool is_peripheral_domain_setup_needed(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)) - { - if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0xA0) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0)) - { - return true; - } - if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0xD0) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0)) - { - return true; - } - } - - return false; -} - -/*lint --flb "Leave library region" */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.h deleted file mode 100644 index d999723..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf51.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - -#ifndef SYSTEM_NRF51_H -#define SYSTEM_NRF51_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ - -/** - * Initialize the system - * - * @param none - * @return none - * - * @brief Setup the microcontroller system. - * Initialize the System and update the SystemCoreClock variable. - */ -extern void SystemInit (void); - -/** - * Update SystemCoreClock variable - * - * @param none - * @return none - * - * @brief Updates the SystemCoreClock with current core Clock - * retrieved from cpu registers. - */ -extern void SystemCoreClockUpdate (void); - -#ifdef __cplusplus -} -#endif - -#endif /* SYSTEM_NRF51_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.c deleted file mode 100644 index 6eb609d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.c +++ /dev/null @@ -1,394 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - -/* NOTE: Template files (including this one) are application specific and therefore expected to - be copied into the application project folder prior to its use! */ - -#include -#include -#include "nrf.h" -#include "system_nrf52810.h" - -/*lint ++flb "Enter library region" */ - -#define __SYSTEM_CLOCK_64M (64000000UL) - -static bool errata_31(void); -static bool errata_36(void); -static bool errata_66(void); -static bool errata_103(void); -static bool errata_136(void); - -/* Helper functions for Errata workarounds in nRF52832 */ -#if defined (DEVELOP_IN_NRF52832) -static bool errata_12(void); -static bool errata_16(void); -static bool errata_32(void); -static bool errata_37(void); -static bool errata_57(void); -static bool errata_108(void); -#endif - -#if defined ( __CC_ARM ) - uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M; -#elif defined ( __ICCARM__ ) - __root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M; -#elif defined ( __GNUC__ ) - uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M; -#endif - -void SystemCoreClockUpdate(void) -{ - SystemCoreClock = __SYSTEM_CLOCK_64M; -} - -void SystemInit(void) -{ - /* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product - Specification to see which one). Only available if the developing environment is an nRF52832 device. */ - #if defined (DEVELOP_IN_NRF52832) && defined (ENABLE_SWO) - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos; - NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - #endif - - /* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product - Specification to see which ones). Only available if the developing environment is an nRF52832 device. */ - #if defined (DEVELOP_IN_NRF52832) && defined (ENABLE_TRACE) - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos; - NRF_P0->PIN_CNF[14] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P0->PIN_CNF[15] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P0->PIN_CNF[16] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P0->PIN_CNF[20] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - #endif - - #if defined (DEVELOP_IN_NRF52832) - /* Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated" found at the Errata document - for nRF52832 device located at https://infocenter.nordicsemi.com/ */ - if (errata_12()){ - *(volatile uint32_t *)0x40013540 = (*(uint32_t *)0x10000324 & 0x00001F00) >> 8; - } - #endif - - #if defined (DEVELOP_IN_NRF52832) - /* Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE" found at the Errata document - for nRF52832 device located at https://infocenter.nordicsemi.com/ */ - if (errata_16()){ - *(volatile uint32_t *)0x4007C074 = 3131961357ul; - } - #endif - - /* Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_31()){ - *(volatile uint32_t *)0x4000053C = ((*(volatile uint32_t *)0x10000244) & 0x0000E000) >> 13; - } - - #if defined (DEVELOP_IN_NRF52832) - /* Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins" found at the Errata document - for nRF52832 device located at https://infocenter.nordicsemi.com/ */ - if (errata_32()){ - CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk; - } - #endif - - /* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_36()){ - NRF_CLOCK->EVENTS_DONE = 0; - NRF_CLOCK->EVENTS_CTTO = 0; - NRF_CLOCK->CTIV = 0; - } - - #if defined (DEVELOP_IN_NRF52832) - /* Workaround for Errata 37 "RADIO: Encryption engine is slow by default" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_37()){ - *(volatile uint32_t *)0x400005A0 = 0x3; - } - #endif - - #if defined (DEVELOP_IN_NRF52832) - /* Workaround for Errata 57 "NFCT: NFC Modulation amplitude" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_57()){ - *(volatile uint32_t *)0x40005610 = 0x00000005; - *(volatile uint32_t *)0x40005688 = 0x00000001; - *(volatile uint32_t *)0x40005618 = 0x00000000; - *(volatile uint32_t *)0x40005614 = 0x0000003F; - } - #endif - - /* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_66()){ - NRF_TEMP->A0 = NRF_FICR->TEMP.A0; - NRF_TEMP->A1 = NRF_FICR->TEMP.A1; - NRF_TEMP->A2 = NRF_FICR->TEMP.A2; - NRF_TEMP->A3 = NRF_FICR->TEMP.A3; - NRF_TEMP->A4 = NRF_FICR->TEMP.A4; - NRF_TEMP->A5 = NRF_FICR->TEMP.A5; - NRF_TEMP->B0 = NRF_FICR->TEMP.B0; - NRF_TEMP->B1 = NRF_FICR->TEMP.B1; - NRF_TEMP->B2 = NRF_FICR->TEMP.B2; - NRF_TEMP->B3 = NRF_FICR->TEMP.B3; - NRF_TEMP->B4 = NRF_FICR->TEMP.B4; - NRF_TEMP->B5 = NRF_FICR->TEMP.B5; - NRF_TEMP->T0 = NRF_FICR->TEMP.T0; - NRF_TEMP->T1 = NRF_FICR->TEMP.T1; - NRF_TEMP->T2 = NRF_FICR->TEMP.T2; - NRF_TEMP->T3 = NRF_FICR->TEMP.T3; - NRF_TEMP->T4 = NRF_FICR->TEMP.T4; - } - - /* Workaround for Errata 103 "CCM: Wrong reset value of CCM MAXPACKETSIZE" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_103()){ - NRF_CCM->MAXPACKETSIZE = 0xFBul; - } - - #if defined (DEVELOP_IN_NRF52832) - /* Workaround for Errata 108 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_108()){ - *(volatile uint32_t *)0x40000EE4 = *(volatile uint32_t *)0x10000258 & 0x0000004F; - } - #endif - - /* Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_136()){ - if (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk){ - NRF_POWER->RESETREAS = ~POWER_RESETREAS_RESETPIN_Msk; - } - } - - /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not - defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be - reserved for PinReset and not available as normal GPIO. */ - #if defined (CONFIG_GPIO_AS_PINRESET) - if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) || - ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){ - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_UICR->PSELRESET[0] = 21; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_UICR->PSELRESET[1] = 21; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NVIC_SystemReset(); - } - #endif - - SystemCoreClockUpdate(); -} - -#if defined (DEVELOP_IN_NRF52832) -static bool errata_12(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ - return true; - } - } - - return false; -} -#endif - -#if defined (DEVELOP_IN_NRF52832) -static bool errata_16(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - } - - return false; -} -#endif - -static bool errata_31(void) -{ - if ((*(uint32_t *)0x10000130ul == 0xAul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - #if defined (DEVELOP_IN_NRF52832) - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ - return true; - } - } - #endif - - return true; -} - -#if defined (DEVELOP_IN_NRF52832) -static bool errata_32(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - } - - return false; -} -#endif - -static bool errata_36(void) -{ - if ((*(uint32_t *)0x10000130ul == 0xAul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - #if defined (DEVELOP_IN_NRF52832) - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ - return true; - } - } - #endif - - return true; -} - -#if defined (DEVELOP_IN_NRF52832) -static bool errata_37(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - } - - return false; -} -#endif - -#if defined (DEVELOP_IN_NRF52832) -static bool errata_57(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - } - - return false; -} -#endif - -static bool errata_66(void) -{ - if ((*(uint32_t *)0x10000130ul == 0xAul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - #if defined (DEVELOP_IN_NRF52832) - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ - return true; - } - } - #endif - - return true; -} - -static bool errata_103(void) -{ - if ((*(uint32_t *)0x10000130ul == 0xAul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return true; -} - -#if defined (DEVELOP_IN_NRF52832) -static bool errata_108(void) -{ - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ - return true; - } - } - - return false; -} -#endif - -static bool errata_136(void) -{ - if ((*(uint32_t *)0x10000130ul == 0xAul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - #if defined (DEVELOP_IN_NRF52832) - if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ - return true; - } - if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ - return true; - } - } - #endif - - return true; -} - - -/*lint --flb "Leave library region" */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.h deleted file mode 100644 index 7d2e952..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52810.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - -#ifndef SYSTEM_NRF52810_H -#define SYSTEM_NRF52810_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ - -/** - * Initialize the system - * - * @param none - * @return none - * - * @brief Setup the microcontroller system. - * Initialize the System and update the SystemCoreClock variable. - */ -extern void SystemInit (void); - -/** - * Update SystemCoreClock variable - * - * @param none - * @return none - * - * @brief Updates the SystemCoreClock with current core Clock - * retrieved from cpu registers. - */ -extern void SystemCoreClockUpdate (void); - -#ifdef __cplusplus -} -#endif - -#endif /* SYSTEM_NRF52810_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.c deleted file mode 100644 index dd821df..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - -/* NOTE: Template files (including this one) are application specific and therefore expected to - be copied into the application project folder prior to its use! */ - -#include -#include -#include "nrf.h" -#include "system_nrf52840.h" - -/*lint ++flb "Enter library region" */ - -#define __SYSTEM_CLOCK_64M (64000000UL) - -static bool errata_36(void); -static bool errata_66(void); -static bool errata_98(void); -static bool errata_103(void); -static bool errata_115(void); -static bool errata_120(void); -static bool errata_136(void); - - -#if defined ( __CC_ARM ) - uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M; -#elif defined ( __ICCARM__ ) - __root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M; -#elif defined ( __GNUC__ ) - uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M; -#endif - -void SystemCoreClockUpdate(void) -{ - SystemCoreClock = __SYSTEM_CLOCK_64M; -} - -void SystemInit(void) -{ - /* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product - Specification to see which one). */ - #if defined (ENABLE_SWO) - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos; - NRF_P1->PIN_CNF[0] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - #endif - - /* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product - Specification to see which ones). */ - #if defined (ENABLE_TRACE) - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos; - NRF_P0->PIN_CNF[7] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P1->PIN_CNF[0] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P0->PIN_CNF[12] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P0->PIN_CNF[11] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - NRF_P1->PIN_CNF[9] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - #endif - - /* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_36()){ - NRF_CLOCK->EVENTS_DONE = 0; - NRF_CLOCK->EVENTS_CTTO = 0; - NRF_CLOCK->CTIV = 0; - } - - /* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_66()){ - NRF_TEMP->A0 = NRF_FICR->TEMP.A0; - NRF_TEMP->A1 = NRF_FICR->TEMP.A1; - NRF_TEMP->A2 = NRF_FICR->TEMP.A2; - NRF_TEMP->A3 = NRF_FICR->TEMP.A3; - NRF_TEMP->A4 = NRF_FICR->TEMP.A4; - NRF_TEMP->A5 = NRF_FICR->TEMP.A5; - NRF_TEMP->B0 = NRF_FICR->TEMP.B0; - NRF_TEMP->B1 = NRF_FICR->TEMP.B1; - NRF_TEMP->B2 = NRF_FICR->TEMP.B2; - NRF_TEMP->B3 = NRF_FICR->TEMP.B3; - NRF_TEMP->B4 = NRF_FICR->TEMP.B4; - NRF_TEMP->B5 = NRF_FICR->TEMP.B5; - NRF_TEMP->T0 = NRF_FICR->TEMP.T0; - NRF_TEMP->T1 = NRF_FICR->TEMP.T1; - NRF_TEMP->T2 = NRF_FICR->TEMP.T2; - NRF_TEMP->T3 = NRF_FICR->TEMP.T3; - NRF_TEMP->T4 = NRF_FICR->TEMP.T4; - } - - /* Workaround for Errata 98 "NFCT: Not able to communicate with the peer" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_98()){ - *(volatile uint32_t *)0x4000568Cul = 0x00038148ul; - } - - /* Workaround for Errata 103 "CCM: Wrong reset value of CCM MAXPACKETSIZE" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_103()){ - NRF_CCM->MAXPACKETSIZE = 0xFBul; - } - - /* Workaround for Errata 115 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_115()){ - *(volatile uint32_t *)0x40000EE4 = (*(volatile uint32_t *)0x40000EE4 & 0xFFFFFFF0) | (*(uint32_t *)0x10000258 & 0x0000000F); - } - - /* Workaround for Errata 120 "QSPI: Data read or written is corrupted" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_120()){ - *(volatile uint32_t *)0x40029640ul = 0x200ul; - } - - /* Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be" found at the Errata document - for your device located at https://infocenter.nordicsemi.com/ */ - if (errata_136()){ - if (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk){ - NRF_POWER->RESETREAS = ~POWER_RESETREAS_RESETPIN_Msk; - } - } - - /* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the - * compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit - * operations are not used in your code. */ - #if (__FPU_USED == 1) - SCB->CPACR |= (3UL << 20) | (3UL << 22); - __DSB(); - __ISB(); - #endif - - /* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined, - two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as - normal GPIOs. */ - #if defined (CONFIG_NFCT_PINS_AS_GPIOS) - if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){ - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NVIC_SystemReset(); - } - #endif - - /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not - defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be - reserved for PinReset and not available as normal GPIO. */ - #if defined (CONFIG_GPIO_AS_PINRESET) - if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) || - ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){ - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_UICR->PSELRESET[0] = 18; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_UICR->PSELRESET[1] = 18; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} - NVIC_SystemReset(); - } - #endif - - SystemCoreClockUpdate(); -} - - -static bool errata_36(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - - -static bool errata_66(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - - -static bool errata_98(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - - -static bool errata_103(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - - -static bool errata_115(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - - -static bool errata_120(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - - -static bool errata_136(void) -{ - if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){ - return true; - } - - return false; -} - -/*lint --flb "Leave library region" */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.h deleted file mode 100644 index 5a1e794..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/system_nrf52840.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - -Copyright (c) 2009-2017 ARM Limited. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the License); you may -not use this file except in compliance with the License. -You may obtain a copy of the License at - - www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an AS IS BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -NOTICE: This file has been modified by Nordic Semiconductor ASA. - -*/ - -#ifndef SYSTEM_NRF52840_H -#define SYSTEM_NRF52840_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ - -/** - * Initialize the system - * - * @param none - * @return none - * - * @brief Setup the microcontroller system. - * Initialize the System and update the SystemCoreClock variable. - */ -extern void SystemInit (void); - -/** - * Update SystemCoreClock variable - * - * @param none - * @return none - * - * @brief Updates the SystemCoreClock with current core Clock - * retrieved from cpu registers. - */ -extern void SystemCoreClockUpdate (void); - -#ifdef __cplusplus -} -#endif - -#endif /* SYSTEM_NRF52840_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/license/license.txt b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/license/license.txt deleted file mode 100644 index be959bb..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/license/license.txt +++ /dev/null @@ -1,394 +0,0 @@ -The FreeRTOS source code is licensed by a *modified* GNU General Public -License (GPL). The modification is provided in the form of an exception. - -NOTE: The modification to the GPL is included to allow you to distribute a -combined work that includes FreeRTOS without being obliged to provide the source -code for proprietary components outside of the FreeRTOS kernel. - - - ----------------------------------------------------------------------------- - -The FreeRTOS GPL Exception Text: - -Any FreeRTOS source code, whether modified or in it's original release form, -or whether in whole or in part, can only be distributed by you under the terms -of the GNU General Public License plus this exception. An independent module is -a module which is not derived from or based on FreeRTOS. - -Clause 1: - -Linking FreeRTOS statically or dynamically with other modules is making a -combined work based on FreeRTOS. Thus, the terms and conditions of the GNU -General Public License cover the whole combination. - -As a special exception, the copyright holder of FreeRTOS gives you permission -to link FreeRTOS with independent modules that communicate with FreeRTOS -solely through the FreeRTOS API interface, regardless of the license terms of -these independent modules, and to copy and distribute the resulting combined -work under terms of your choice, provided that - - + Every copy of the combined work is accompanied by a written statement that - details to the recipient the version of FreeRTOS used and an offer by yourself - to provide the FreeRTOS source code (including any modifications you may have - made) should the recipient request it. - - + The combined work is not itself an RTOS, scheduler, kernel or related product. - - + The independent modules add significant and primary functionality to FreeRTOS - and do not merely extend the existing functionality already present in FreeRTOS. - -Clause 2: - -FreeRTOS may not be used for any competitive or comparative purpose, including the -publication of any form of run time or compile time metric, without the express -permission of Real Time Engineers Ltd. (this is the norm within the industry and -is intended to ensure information accuracy). - - --------------------------------------------------------------------- - -The standard GPL exception text: - - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License** as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/port.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/port.c deleted file mode 100644 index 5823dc4..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/port.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM4F port. - *----------------------------------------------------------*/ - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" - -/* - * Start first task is a separate function so it can be tested in isolation. - */ -void vPortStartFirstTask( void ); - -/* - * Exception handlers. - */ -void xPortPendSVHandler( void ); -void vPortSVCHandler( void ); - - -/*-----------------------------------------------------------*/ - -__asm void vPortSVCHandler( void ) -{ - /* This function is no longer used, but retained for backward - compatibility. */ -} -/*-----------------------------------------------------------*/ - -__asm void vPortStartFirstTask( void ) -{ - PRESERVE8 - EXTERN __Vectors - - /* Use the NVIC offset register to locate the stack. */ - ldr r0, =__Vectors - ldr r0, [r0] - /* Set the msp back to the start of the stack. */ - msr msp, r0 - - ldr r3, =pxCurrentTCB /* Obtain location of pxCurrentTCB. */ - ldr r1, [r3] - ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */ - adds r0, #32 /* Discard everything up to r0. */ - msr psp, r0 /* This is now the new top of stack to use in the task. */ - movs r0, #2 /* Switch to the psp stack. */ - msr CONTROL, r0 - pop {r0-r5} /* Pop the registers that are saved automatically. */ - mov lr, r5 /* lr is now in r5. */ - cpsie i /* The first task has its context and interrupts can be enabled. */ - pop {pc} /* Finally, pop the PC to jump to the user defined task code. */ - - ALIGN -} -/*-----------------------------------------------------------*/ - -__asm void xPortPendSVHandler( void ) -{ - extern vPortSafeTaskSwitchContext - extern pxCurrentTCB - - PRESERVE8 - - mrs r0, psp - - ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */ - ldr r2, [r3] - - subs r0, #32 /* Make space for the remaining low registers. */ - str r0, [r2] /* Save the new top of stack. */ - stmia r0!, {r4-r7} /* Store the low registers that are not saved automatically. */ - mov r4, r8 /* Store the high registers. */ - mov r5, r9 - mov r6, r10 - mov r7, r11 - stmia r0!, {r4-r7} - - push {r3, r14} - bl vPortSafeTaskSwitchContext - pop {r2, r3} /* lr goes in r3. r2 now holds tcb pointer. */ - - ldr r1, [r2] - ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */ - adds r0, #16 /* Move to the high registers. */ - ldmia r0!, {r4-r7} /* Pop the high registers. */ - mov r8, r4 - mov r9, r5 - mov r10, r6 - mov r11, r7 - - msr psp, r0 /* Remember the new top of stack for the task. */ - - subs r0, #32 /* Go back for the low registers that are not automatically restored. */ - ldmia r0!, {r4-r7} /* Pop low registers. */ - - bx r3 - ALIGN -} -/*-----------------------------------------------------------*/ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/portmacro.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/portmacro.h deleted file mode 100644 index 0148dfa..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf51/portmacro.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#include "portmacro_cmsis.h" - -#endif /* PORTMACRO_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/port.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/port.c deleted file mode 100644 index 918759b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/port.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM4F port. - *----------------------------------------------------------*/ - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" - - -/* - * Start first task is a separate function so it can be tested in isolation. - */ -void vPortStartFirstTask( void ); - -/* - * Exception handlers. - */ -void xPortPendSVHandler( void ); -void vPortSVCHandler( void ); - - -/*-----------------------------------------------------------*/ - -__asm void vPortSVCHandler( void ) -{ - PRESERVE8 - - /* Get the location of the current TCB. */ - ldr r3, =pxCurrentTCB - ldr r1, [r3] - ldr r0, [r1] - /* Pop the core registers. */ - ldmia r0!, {r4-r11, r14} - msr psp, r0 - isb - mov r0, #0 - msr basepri, r0 - bx r14 -} -/*-----------------------------------------------------------*/ - -__asm void vPortStartFirstTask( void ) -{ - PRESERVE8 - EXTERN __Vectors - - /* Use the NVIC offset register to locate the stack. */ - ldr r0, =__Vectors - ldr r0, [r0] - /* Set the msp back to the start of the stack. */ - msr msp, r0 - /* Globally enable interrupts. */ - cpsie i - cpsie f - dsb - isb -#ifdef SOFTDEVICE_PRESENT - /* Block kernel interrupts only (PendSV) before calling SVC */ - mov r0, #(configKERNEL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) - msr basepri, r0 -#endif - /* Call SVC to start the first task. */ - svc 0 - - ALIGN -} -/*-----------------------------------------------------------*/ - -__asm void xPortPendSVHandler( void ) -{ - extern uxCriticalNesting; - extern pxCurrentTCB; - extern vTaskSwitchContext; - - PRESERVE8 - - mrs r0, psp - isb - /* Get the location of the current TCB. */ - ldr r3, =pxCurrentTCB - ldr r2, [r3] - - /* Is the task using the FPU context? If so, push high vfp registers. */ - tst r14, #0x10 - it eq - vstmdbeq r0!, {s16-s31} - - /* Save the core registers. */ - stmdb r0!, {r4-r11, r14} - - /* Save the new top of stack into the first member of the TCB. */ - str r0, [r2] - - stmdb sp!, {r3} - mov r0, #(configMAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) - msr basepri, r0 - dsb - isb - bl vTaskSwitchContext - mov r0, #0 - msr basepri, r0 - ldmia sp!, {r3} - - /* The first item in pxCurrentTCB is the task top of stack. */ - ldr r1, [r3] - ldr r0, [r1] - - /* Pop the core registers. */ - ldmia r0!, {r4-r11, r14} - - /* Is the task using the FPU context? If so, pop the high vfp registers - too. */ - tst r14, #0x10 - it eq - vldmiaeq r0!, {s16-s31} - - msr psp, r0 - isb - - bx r14 - - ALIGN -} -/*-----------------------------------------------------------*/ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/portmacro.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/portmacro.h deleted file mode 100644 index 0148dfa..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/ARM/nrf52/portmacro.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#include "portmacro_cmsis.h" - -#endif /* PORTMACRO_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/portmacro.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/portmacro.h deleted file mode 100644 index 337d905..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/portmacro.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#include "portmacro_cmsis.h" - -#endif /* PORTMACRO_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/portmacro.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/portmacro.h deleted file mode 100644 index 337d905..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/portmacro.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#include "portmacro_cmsis.h" - -#endif /* PORTMACRO_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/portmacro.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/portmacro.h deleted file mode 100644 index d5db218..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/portmacro.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#include "portmacro_cmsis.h" - -/* Suppress warnings that are generated by the IAR tools, but cannot be fixed in -the source code because to do so would cause other compilers to generate -warnings. */ -#pragma diag_suppress=Pe191 -#pragma diag_suppress=Pa082 - -#endif /* PORTMACRO_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/portmacro.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/portmacro.h deleted file mode 100644 index d5db218..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/portmacro.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#include "portmacro_cmsis.h" - -/* Suppress warnings that are generated by the IAR tools, but cannot be fixed in -the source code because to do so would cause other compilers to generate -warnings. */ -#pragma diag_suppress=Pe191 -#pragma diag_suppress=Pa082 - -#endif /* PORTMACRO_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/StackMacros.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/StackMacros.h deleted file mode 100644 index 9e33cd8..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/StackMacros.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef STACK_MACROS_H -#define STACK_MACROS_H - -/* - * Call the stack overflow hook function if the stack of the task being swapped - * out is currently overflowed, or looks like it might have overflowed in the - * past. - * - * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check - * the current stack state only - comparing the current top of stack value to - * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 - * will also cause the last few stack bytes to be checked to ensure the value - * to which the bytes were set when the task was created have not been - * overwritten. Note this second test does not guarantee that an overflowed - * stack will always be recognised. - */ - -/*-----------------------------------------------------------*/ - -#if ( configCHECK_FOR_STACK_OVERFLOW == 0 ) - - /* FreeRTOSConfig.h is not set to check for stack overflows. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() - -#endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ -/*-----------------------------------------------------------*/ - -#if ( configCHECK_FOR_STACK_OVERFLOW == 1 ) - - /* FreeRTOSConfig.h is only set to use the first method of - overflow checking. */ - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() - -#endif -/*-----------------------------------------------------------*/ - -#if ( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) - - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if ( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ -/*-----------------------------------------------------------*/ - -#if ( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) - - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if ( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ -/*-----------------------------------------------------------*/ - -#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if ( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* #if ( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ -/*-----------------------------------------------------------*/ - -#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if ( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* #if ( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ -/*-----------------------------------------------------------*/ - -#endif /* STACK_MACROS_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/mpu_wrappers.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/mpu_wrappers.h deleted file mode 100644 index 2e30964..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/mpu_wrappers.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef MPU_WRAPPERS_H -#define MPU_WRAPPERS_H - -/* This file redefines API functions to be called through a wrapper macro, but -only for ports that are using the MPU. */ -#ifdef portUSING_MPU_WRAPPERS - - /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is - included from queue.c or task.c to prevent it from having an effect within - those files. */ - #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - - #define xTaskGenericCreate MPU_xTaskGenericCreate - #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions - #define vTaskDelete MPU_vTaskDelete - #define vTaskDelayUntil MPU_vTaskDelayUntil - #define vTaskDelay MPU_vTaskDelay - #define uxTaskPriorityGet MPU_uxTaskPriorityGet - #define vTaskPrioritySet MPU_vTaskPrioritySet - #define eTaskGetState MPU_eTaskGetState - #define vTaskSuspend MPU_vTaskSuspend - #define vTaskResume MPU_vTaskResume - #define vTaskSuspendAll MPU_vTaskSuspendAll - #define xTaskResumeAll MPU_xTaskResumeAll - #define xTaskGetTickCount MPU_xTaskGetTickCount - #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks - #define vTaskList MPU_vTaskList - #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats - #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag - #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook - #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark - #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle - #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState - #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle - #define uxTaskGetSystemState MPU_uxTaskGetSystemState - - #define xQueueGenericCreate MPU_xQueueGenericCreate - #define xQueueCreateMutex MPU_xQueueCreateMutex - #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive - #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive - #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore - #define xQueueGenericSend MPU_xQueueGenericSend - #define xQueueAltGenericSend MPU_xQueueAltGenericSend - #define xQueueAltGenericReceive MPU_xQueueAltGenericReceive - #define xQueueGenericReceive MPU_xQueueGenericReceive - #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting - #define vQueueDelete MPU_vQueueDelete - #define xQueueGenericReset MPU_xQueueGenericReset - #define xQueueCreateSet MPU_xQueueCreateSet - #define xQueueSelectFromSet MPU_xQueueSelectFromSet - #define xQueueAddToSet MPU_xQueueAddToSet - #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet - #define xQueuePeekFromISR MPU_xQueuePeekFromISR - #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder - - #define pvPortMalloc MPU_pvPortMalloc - #define vPortFree MPU_vPortFree - #define xPortGetFreeHeapSize MPU_xPortGetFreeHeapSize - #define vPortInitialiseBlocks MPU_vPortInitialiseBlocks - - #if configQUEUE_REGISTRY_SIZE > 0 - #define vQueueAddToRegistry MPU_vQueueAddToRegistry - #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue - #endif - - /* Remove the privileged function macro. */ - #define PRIVILEGED_FUNCTION - - #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - - /* Ensure API functions go in the privileged execution section. */ - #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - - #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - -#else /* portUSING_MPU_WRAPPERS */ - - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA - #define portUSING_MPU_WRAPPERS 0 - -#endif /* portUSING_MPU_WRAPPERS */ - - -#endif /* MPU_WRAPPERS_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/projdefs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/projdefs.h deleted file mode 100644 index 12dd72b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/projdefs.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PROJDEFS_H -#define PROJDEFS_H - -/* - * Defines the prototype to which task functions must conform. Defined in this - * file to ensure the type is known before portable.h is included. - */ -typedef void (*TaskFunction_t)( void * ); - -/* Converts a time in milliseconds to a time in ticks. */ -#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) - -#define pdFALSE ( ( BaseType_t ) 0 ) -#define pdTRUE ( ( BaseType_t ) 1 ) - -#define pdPASS ( pdTRUE ) -#define pdFAIL ( pdFALSE ) -#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) -#define errQUEUE_FULL ( ( BaseType_t ) 0 ) - -/* FreeRTOS error definitions. */ -#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) -#define errQUEUE_BLOCKED ( -4 ) -#define errQUEUE_YIELD ( -5 ) - -/* Macros used for basic data corruption checks. */ -#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES - #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 -#endif - -#if ( configUSE_16_BIT_TICKS == 1 ) - #define pdINTEGRITY_CHECK_VALUE 0x5a5a -#else - #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL -#endif - -/* The following endian values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_LITTLE_ENDIAN 0 -#define pdFREERTOS_BIG_ENDIAN 1 - -#endif /* PROJDEFS_H */ - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/semphr.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/semphr.h deleted file mode 100644 index 4b7c15b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/semphr.h +++ /dev/null @@ -1,844 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef SEMAPHORE_H -#define SEMAPHORE_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include semphr.h" -#endif - -#include "queue.h" - -typedef QueueHandle_t SemaphoreHandle_t; - -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) -#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) - - -/** - * semphr. h - *
vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
- * - * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the - * xSemaphoreCreateBinary() function. Note that binary semaphores created using - * the vSemaphoreCreateBinary() macro are created in a state such that the - * first call to 'take' the semaphore would pass, whereas binary semaphores - * created using xSemaphoreCreateBinary() are created in a state such that the - * the semaphore must first be 'given' before it can be 'taken'. - * - * Macro that implements a semaphore by using the existing queue mechanism. - * The queue length is 1 as this is a binary semaphore. The data size is 0 - * as we don't want to actually store any data - we just want to know if the - * queue is empty or full. - * - * This type of semaphore can be used for pure synchronisation between tasks or - * between an interrupt and a task. The semaphore need not be given back once - * obtained, so one task/interrupt can continuously 'give' the semaphore while - * another continuously 'takes' the semaphore. For this reason this type of - * semaphore does not use a priority inheritance mechanism. For an alternative - * that does use priority inheritance see xSemaphoreCreateMutex(). - * - * @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if ( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary - * \ingroup Semaphores - */ -#define vSemaphoreCreateBinary( xSemaphore ) \ - { \ - ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ - if ( ( xSemaphore ) != NULL ) \ - { \ - ( void ) xSemaphoreGive( ( xSemaphore ) ); \ - } \ - } - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateBinary( void )
- * - * The old vSemaphoreCreateBinary() macro is now deprecated in favour of this - * xSemaphoreCreateBinary() function. Note that binary semaphores created using - * the vSemaphoreCreateBinary() macro are created in a state such that the - * first call to 'take' the semaphore would pass, whereas binary semaphores - * created using xSemaphoreCreateBinary() are created in a state such that the - * the semaphore must first be 'given' before it can be 'taken'. - * - * Function that creates a semaphore by using the existing queue mechanism. - * The queue length is 1 as this is a binary semaphore. The data size is 0 - * as nothing is actually stored - all that is important is whether the queue is - * empty or full (the binary semaphore is available or not). - * - * This type of semaphore can be used for pure synchronisation between tasks or - * between an interrupt and a task. The semaphore need not be given back once - * obtained, so one task/interrupt can continuously 'give' the semaphore while - * another continuously 'takes' the semaphore. For this reason this type of - * semaphore does not use a priority inheritance mechanism. For an alternative - * that does use priority inheritance see xSemaphoreCreateMutex(). - * - * @return Handle to the created semaphore. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateBinary();
-
-    if ( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary - * \ingroup Semaphores - */ -#define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) - -/** - * semphr. h - *
xSemaphoreTake(
- *                   SemaphoreHandle_t xSemaphore,
- *                   TickType_t xBlockTime
- *               )
- * - * Macro to obtain a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting(). - * - * @param xSemaphore A handle to the semaphore being taken - obtained when - * the semaphore was created. - * - * @param xBlockTime The time in ticks to wait for the semaphore to become - * available. The macro portTICK_PERIOD_MS can be used to convert this to a - * real time. A block time of zero can be used to poll the semaphore. A block - * time of portMAX_DELAY can be used to block indefinitely (provided - * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h). - * - * @return pdTRUE if the semaphore was obtained. pdFALSE - * if xBlockTime expired without the semaphore becoming available. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- // A task that creates a semaphore.
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
- }
-
- // A task that uses the semaphore.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if ( xSemaphore != NULL )
-    {
-        // See if we can obtain the semaphore.  If the semaphore is not available
-        // wait 10 ticks to see if it becomes free.
-        if ( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the semaphore and can now access the
-            // shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource.  Release the
-            // semaphore.
-            xSemaphoreGive( xSemaphore );
-        }
-        else
-        {
-            // We could not obtain the semaphore and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTake xSemaphoreTake - * \ingroup Semaphores - */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) - -/** - * semphr. h - * xSemaphoreTakeRecursive( - * SemaphoreHandle_t xMutex, - * TickType_t xBlockTime - * ) - * - * Macro to recursively obtain, or 'take', a mutex type semaphore. - * The mutex must have previously been created using a call to - * xSemaphoreCreateRecursiveMutex(); - * - * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this - * macro to be available. - * - * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * @param xMutex A handle to the mutex being obtained. This is the - * handle returned by xSemaphoreCreateRecursiveMutex(); - * - * @param xBlockTime The time in ticks to wait for the semaphore to become - * available. The macro portTICK_PERIOD_MS can be used to convert this to a - * real time. A block time of zero can be used to poll the semaphore. If - * the task already owns the semaphore then xSemaphoreTakeRecursive() will - * return immediately no matter what the value of xBlockTime. - * - * @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime - * expired without the semaphore becoming available. - * - * Example usage: -
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if ( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.
-        if ( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, but instead buried in a more complex
-			// call structure.  This is just for illustrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive - * \ingroup Semaphores - */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - - -/* - * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) - -/** - * semphr. h - *
xSemaphoreGive( SemaphoreHandle_t xSemaphore )
- * - * Macro to release a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting(). and obtained using sSemaphoreTake(). - * - * This macro must not be used from an ISR. See xSemaphoreGiveFromISR () for - * an alternative which can be used from an ISR. - * - * This macro must also not be used on semaphores created using - * xSemaphoreCreateRecursiveMutex(). - * - * @param xSemaphore A handle to the semaphore being released. This is the - * handle returned when the semaphore was created. - * - * @return pdTRUE if the semaphore was released. pdFALSE if an error occurred. - * Semaphores are implemented using queues. An error can occur if there is - * no space on the queue to post a message - indicating that the - * semaphore was not first obtained correctly. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if ( xSemaphore != NULL )
-    {
-        if ( xSemaphoreGive( xSemaphore ) != pdTRUE )
-        {
-            // We would expect this call to fail because we cannot give
-            // a semaphore without first "taking" it!
-        }
-
-        // Obtain the semaphore - don't block if the semaphore is not
-        // immediately available.
-        if ( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
-        {
-            // We now have the semaphore and can access the shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource so can free the
-            // semaphore.
-            if ( xSemaphoreGive( xSemaphore ) != pdTRUE )
-            {
-                // We would not expect this call to fail because we must have
-                // obtained the semaphore to get here.
-            }
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGive xSemaphoreGive - * \ingroup Semaphores - */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** - * semphr. h - *
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
- * - * Macro to recursively release, or 'give', a mutex type semaphore. - * The mutex must have previously been created using a call to - * xSemaphoreCreateRecursiveMutex(); - * - * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this - * macro to be available. - * - * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * @param xMutex A handle to the mutex being released, or 'given'. This is the - * handle returned by xSemaphoreCreateMutex(); - * - * @return pdTRUE if the semaphore was given. - * - * Example usage: -
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if ( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.
-        if ( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, it would be more likely that the calls
-			// to xSemaphoreGiveRecursive() would be called as a call stack
-			// unwound.  This is just for demonstrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive - * \ingroup Semaphores - */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) - -/* - * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** - * semphr. h - *
- xSemaphoreGiveFromISR(
-                          SemaphoreHandle_t xSemaphore,
-                          BaseType_t *pxHigherPriorityTaskWoken
-                      )
- * - * Macro to release a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting(). - * - * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) - * must not be used with this macro. - * - * This macro can be used from an ISR. - * - * @param xSemaphore A handle to the semaphore being released. This is the - * handle returned when the semaphore was created. - * - * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL. - * - * Example usage: -
- \#define LONG_TIME 0xffff
- \#define TICKS_TO_WAIT	10
- SemaphoreHandle_t xSemaphore = NULL;
-
- // Repetitive task.
- void vATask( void * pvParameters )
- {
-    for ( ;; )
-    {
-        // We want this task to run every 10 ticks of a timer.  The semaphore
-        // was created before this task was started.
-
-        // Block waiting for the semaphore to become available.
-        if ( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
-        {
-            // It is time to execute.
-
-            // ...
-
-            // We have finished our task.  Return to the top of the loop where
-            // we will block on the semaphore until it is time to execute
-            // again.  Note when using the semaphore for synchronisation with an
-			// ISR in this manner there is no need to 'give' the semaphore back.
-        }
-    }
- }
-
- // Timer ISR
- void vTimerISR( void * pvParameters )
- {
- static uint8_t ucLocalTickCount = 0;
- static BaseType_t xHigherPriorityTaskWoken;
-
-    // A timer tick has occurred.
-
-    // ... Do other time functions.
-
-    // Is it time for vATask () to run?
-	xHigherPriorityTaskWoken = pdFALSE;
-    ucLocalTickCount++;
-    if ( ucLocalTickCount >= TICKS_TO_WAIT )
-    {
-        // Unblock the task by releasing the semaphore.
-        xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
-
-        // Reset the count so we release the semaphore again in 10 ticks time.
-        ucLocalTickCount = 0;
-    }
-
-    if ( xHigherPriorityTaskWoken != pdFALSE )
-    {
-        // We can force a context switch here.  Context switching from an
-        // ISR uses port specific syntax.  Check the demo task for your port
-        // to find the syntax required.
-    }
- }
- 
- * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR - * \ingroup Semaphores - */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) - -/** - * semphr. h - *
- xSemaphoreTakeFromISR(
-                          SemaphoreHandle_t xSemaphore,
-                          BaseType_t *pxHigherPriorityTaskWoken
-                      )
- * - * Macro to take a semaphore from an ISR. The semaphore must have - * previously been created with a call to vSemaphoreCreateBinary() or - * xSemaphoreCreateCounting(). - * - * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) - * must not be used with this macro. - * - * This macro can be used from an ISR, however taking a semaphore from an ISR - * is not a common operation. It is likely to only be useful when taking a - * counting semaphore when an interrupt is obtaining an object from a resource - * pool (when the semaphore count indicates the number of resources available). - * - * @param xSemaphore A handle to the semaphore being taken. This is the - * handle returned when the semaphore was created. - * - * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the semaphore was successfully taken, otherwise - * pdFALSE - */ -#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateMutex( void )
- * - * Macro that implements a mutex semaphore by using the existing queue - * mechanism. - * - * Mutexes created using this macro can be accessed using the xSemaphoreTake() - * and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and - * xSemaphoreGiveRecursive() macros should not be used. - * - * This type of semaphore uses a priority inheritance mechanism so a task - * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the - * semaphore it is no longer required. - * - * Mutex type semaphores cannot be used from within interrupt service routines. - * - * See vSemaphoreCreateBinary() for an alternative implementation that can be - * used for pure synchronisation (where one task or interrupt always 'gives' the - * semaphore and another always 'takes' the semaphore) and from within interrupt - * service routines. - * - * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateMutex();
-
-    if ( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex - * \ingroup Semaphores - */ -#define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) - - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )
- * - * Macro that implements a recursive mutex by using the existing queue - * mechanism. - * - * Mutexes created using this macro can be accessed using the - * xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The - * xSemaphoreTake() and xSemaphoreGive() macros should not be used. - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * This type of semaphore uses a priority inheritance mechanism so a task - * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the - * semaphore it is no longer required. - * - * Mutex type semaphores cannot be used from within interrupt service routines. - * - * See vSemaphoreCreateBinary() for an alternative implementation that can be - * used for pure synchronisation (where one task or interrupt always 'gives' the - * semaphore and another always 'takes' the semaphore) and from within interrupt - * service routines. - * - * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateRecursiveMutex();
-
-    if ( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex - * \ingroup Semaphores - */ -#define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )
- * - * Macro that creates a counting semaphore by using the existing - * queue mechanism. - * - * Counting semaphores are typically used for two things: - * - * 1) Counting events. - * - * In this usage scenario an event handler will 'give' a semaphore each time - * an event occurs (incrementing the semaphore count value), and a handler - * task will 'take' a semaphore each time it processes an event - * (decrementing the semaphore count value). The count value is therefore - * the difference between the number of events that have occurred and the - * number that have been processed. In this case it is desirable for the - * initial count value to be zero. - * - * 2) Resource management. - * - * In this usage scenario the count value indicates the number of resources - * available. To obtain control of a resource a task must first obtain a - * semaphore - decrementing the semaphore count value. When the count value - * reaches zero there are no free resources. When a task finishes with the - * resource it 'gives' the semaphore back - incrementing the semaphore count - * value. In this case it is desirable for the initial count value to be - * equal to the maximum count value, indicating that all resources are free. - * - * @param uxMaxCount The maximum count value that can be reached. When the - * semaphore reaches this value it can no longer be 'given'. - * - * @param uxInitialCount The count value assigned to the semaphore when it is - * created. - * - * @return Handle to the created semaphore. Null if the semaphore could not be - * created. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
- SemaphoreHandle_t xSemaphore = NULL;
-
-    // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
-    // The max value to which the semaphore can count should be 10, and the
-    // initial value assigned to the count should be 0.
-    xSemaphore = xSemaphoreCreateCounting( 10, 0 );
-
-    if ( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting - * \ingroup Semaphores - */ -#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) - -/** - * semphr. h - *
void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );
- * - * Delete a semaphore. This function must be used with care. For example, - * do not delete a mutex type semaphore if the mutex is held by a task. - * - * @param xSemaphore A handle to the semaphore to be deleted. - * - * \defgroup vSemaphoreDelete vSemaphoreDelete - * \ingroup Semaphores - */ -#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) - -/** - * semphr.h - *
TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );
- * - * If xMutex is indeed a mutex type semaphore, return the current mutex holder. - * If xMutex is not a mutex type semaphore, or the mutex is available (not held - * by a task), return NULL. - * - * Note: This is a good way of determining if the calling task is the mutex - * holder, but not a good way of determining the identity of the mutex holder as - * the holder may change between the function exiting and the returned value - * being tested. - */ -#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) - -#endif /* SEMAPHORE_H */ - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_1.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_1.c deleted file mode 100644 index f2a0f9f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_1.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -/* - * The simplest possible implementation of pvPortMalloc(). Note that this - * implementation does NOT allow allocated memory to be freed again. - * - * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* A few bytes might be lost to byte aligning the heap start address. */ -#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) - -/* Allocate the memory for the heap. */ -static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; -static size_t xNextFreeByte = ( size_t ) 0; - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -void *pvReturn = NULL; -static uint8_t *pucAlignedHeap = NULL; - - /* Ensure that blocks are always aligned to the required number of bytes. */ - #if portBYTE_ALIGNMENT != 1 - if ( xWantedSize & portBYTE_ALIGNMENT_MASK ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - #endif - - vTaskSuspendAll(); - { - if ( pucAlignedHeap == NULL ) - { - /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); - } - - /* Check there is enough room left for the allocation. */ - if ( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && - ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ - { - /* Return the next free byte then increment the index past this - block. */ - pvReturn = pucAlignedHeap + xNextFreeByte; - xNextFreeByte += xWantedSize; - } - - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if ( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ - /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and - heap_4.c for alternative implementations, and the memory management pages of - http://www.FreeRTOS.org for more information. */ - ( void ) pv; - - /* Force an assert as it is invalid to call this function. */ - configASSERT( pv == NULL ); -} -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks( void ) -{ - /* Only required when static memory is not cleared. */ - xNextFreeByte = ( size_t ) 0; -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return ( configADJUSTED_HEAP_SIZE - xNextFreeByte ); -} - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_3.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_3.c deleted file mode 100644 index 4c44279..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_3.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -/* - * Implementation of pvPortMalloc() and vPortFree() that relies on the - * compilers own malloc() and free() implementations. - * - * This file can only be used if the linker is configured to to generate - * a heap memory area. - * - * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ - -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -void *pvReturn; - - vTaskSuspendAll(); - { - pvReturn = malloc( xWantedSize ); - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if ( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ - if ( pv ) - { - vTaskSuspendAll(); - { - free( pv ); - traceFREE( pv, 0 ); - } - ( void ) xTaskResumeAll(); - } -} - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/readme.txt b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/readme.txt deleted file mode 100644 index ad9b3a1..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -Each real time kernel port consists of three files that contain the core kernel -components and are common to every port, and one or more files that are -specific to a particular microcontroller and/or compiler. - - -+ The FreeRTOS/Source/Portable/MemMang directory contains the three sample -memory allocators as described on the http://www.FreeRTOS.org WEB site. - -+ The other directories each contain files specific to a particular -microcontroller or compiler. - - - -For example, if you are interested in the GCC port for the ATMega323 -microcontroller then the port specific files are contained in -FreeRTOS/Source/Portable/GCC/ATMega323 directory. If this is the only -port you are interested in then all the other directories can be -ignored. - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.bat b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.bat deleted file mode 100644 index a9bbecd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.bat +++ /dev/null @@ -1,25 +0,0 @@ -@ECHO OFF - -:: This script will use git (must be in %PATH%) and arm-none-eabi tools in combination with GNU Make -:: to both fetch and compile all variants of micro-ecc for the nRF5 families -:: pushd and popd are commands that are provided by both Windows and *NIX based OSes. - -WHERE >nul 2>nul git -IF %ERRORLEVEL% NEQ 0 ( -ECHO "git was not found in PATH, please install and append to our PATH" -) - -IF NOT EXIST micro-ecc/uECC.c ( - ECHO "micro-ecc not found! Let's pull it from HEAD." - git clone https://github.com/kmackay/micro-ecc.git -) - -pushd nrf51_armgcc\armgcc && make && popd -pushd nrf51_iar\armgcc && make && popd -pushd nrf51_keil\armgcc && make && popd -pushd nrf52hf_armgcc\armgcc && make && popd -pushd nrf52hf_iar\armgcc && make && popd -pushd nrf52hf_keil\armgcc && make && popd -pushd nrf52nf_armgcc\armgcc && make && popd -pushd nrf52nf_iar\armgcc && make && popd -pushd nrf52nf_keil\armgcc && make && popd diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld deleted file mode 100644 index 077581f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 - RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - -} - -SECTIONS -{ -} - -SECTIONS -{ - . = ALIGN(4); - .mem_section_dummy_ram : - { - } - -} INSERT AFTER .data; - -SECTIONS -{ - .mem_section_dummy_rom : - { - } - - -} INSERT AFTER .text - -INCLUDE "nrf5x_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld deleted file mode 100644 index 077581f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 - RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - -} - -SECTIONS -{ -} - -SECTIONS -{ - . = ALIGN(4); - .mem_section_dummy_ram : - { - } - -} INSERT AFTER .data; - -SECTIONS -{ - .mem_section_dummy_rom : - { - } - - -} INSERT AFTER .text - -INCLUDE "nrf5x_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld deleted file mode 100644 index 077581f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 - RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - -} - -SECTIONS -{ -} - -SECTIONS -{ - . = ALIGN(4); - .mem_section_dummy_ram : - { - } - -} INSERT AFTER .data; - -SECTIONS -{ - .mem_section_dummy_rom : - { - } - - -} INSERT AFTER .text - -INCLUDE "nrf5x_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld deleted file mode 100644 index 077581f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 - RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - -} - -SECTIONS -{ -} - -SECTIONS -{ - . = ALIGN(4); - .mem_section_dummy_ram : - { - } - -} INSERT AFTER .data; - -SECTIONS -{ - .mem_section_dummy_rom : - { - } - - -} INSERT AFTER .text - -INCLUDE "nrf5x_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld deleted file mode 100644 index 077581f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 - RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - -} - -SECTIONS -{ -} - -SECTIONS -{ - . = ALIGN(4); - .mem_section_dummy_ram : - { - } - -} INSERT AFTER .data; - -SECTIONS -{ - .mem_section_dummy_rom : - { - } - - -} INSERT AFTER .text - -INCLUDE "nrf5x_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_defs.h deleted file mode 100644 index 5b9b384..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_defs.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. -#include -#include - -#include "SEGGER_RTT.h" - -#if DX_LINUX_PLATFORM -extern uint32_t g_free_mem_addr; -extern uint32_t *g_test_stack_base_addr; -extern uint32_t g_rom_base_addr; -extern uint32_t g_env_rom_base_addr; -#endif - - -SaSiError_t mapEnvMemory(void); -void unmapMemory(void); -SaSiError_t integration_tests_setup(void); -void integration_tests_clear(void); - - -#define REG_BASE_ADR DX_BASE_CC -#define REG_AREA_LEN 0x20000 -#define ENV_REG_BASE_ADR DX_BASE_ENV_REGS -#define ENV_REG_AREA_LEN 0x20000 -#define SRAM_BASE_ADR 0 -#define TEST_DATA_START_ADDRESS sizeof(CRYS_RND_Context_t)+sizeof(CRYS_RND_WorkBuff_t) - -/* Zynq EVBs have 1GB and we reserve the memory at offset 768M */ -#define FREE_MEM_BASE_ADR 0x20020000 -#define CONTIG_FREE_MEM 0x8000 -/* Free memory is dedicated for SW image storage */ -#define BOOT_FREE_MEM_BASE_ADR FREE_MEM_BASE_ADR -#define BOOT_FREE_MEM_LEN 0x500000 - -/* user space follows the free memory, and uses for stack and workspace memory */ -#define PTHREAD_STACK_BASE_ADR (FREE_MEM_BASE_ADR + CONTIG_FREE_MEM) -#define PTHREAD_STACK_SIZE 16*1024 - -#define WORKSPACE_BASE_ADDR (PTHREAD_STACK_BASE_ADR + PTHREAD_STACK_SIZE) - -#define INTEG_TEST_PRINT(...) SEGGER_RTT_printf(0, __VA_ARGS__) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_utils.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_utils.c deleted file mode 100644 index bfeddce..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_plat_utils.c +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. -#ifdef DX_LINUX_PLATFORM -#include //for mmap -#include //for close() -#include //open() -#include //open() -#include //open() -#include //for printf -#include //for errno -#include -#endif -#include -#include "ssi_pal_types.h" -#include "ssi_regs.h" -//#include "integration_test_ssi_defs.h" -#include "integration_test_plat_defs.h" -#include "crys_rnd.h" - -#include "nrf52840.h" - - -void CRYPTOCELL_IRQHandler(void) -{ - INTEG_TEST_PRINT("Got Cryptocell interrupt\r\n"); -} - -/*Globals*/ -uint32_t g_free_mem_addr; -uint32_t *g_test_stack_base_addr; -uint32_t g_rom_base_addr; -uint32_t g_env_rom_base_addr; - - -CRYS_RND_Context_t* rndContext_ptr; -CRYS_RND_WorkBuff_t* rndWorkBuff_ptr; - -#if defined(__CC_ARM) -CRYS_RND_Context_t rndContext = {0}; -CRYS_RND_WorkBuff_t rndWorkBuff = {0}; -#else -CRYS_RND_Context_t rndContext; -CRYS_RND_WorkBuff_t rndWorkBuff; -#endif - -uint32_t* UserSpace = 0; -int fd_mem; - -//initializatoins that need to be done prior to running the integration tests. -SaSiError_t integration_tests_setup(void) -{ - SaSiError_t ret = 0; - rndContext_ptr = &rndContext; - rndWorkBuff_ptr = &rndWorkBuff; - - // Initialize Segger RTT logging - - (void)SEGGER_RTT_Init(); - - INTEG_TEST_PRINT("==================== TEST START ====================\r\n"); - - NRF_CRYPTOCELL->ENABLE = 1; - - return ret; -} - -void integration_tests_clear(void) -{ - INTEG_TEST_PRINT("==================== TEST END ====================\r\n"); - while(1); -} - -void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) -{ - (void)id; - (void)pc; - (void)info; - while(1); -} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_defs.h deleted file mode 100644 index 2d333f3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_defs.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. -#define SHARED_SECRET_MAX_LENGHT 250 -#define ECC_KEY_MAX_LENGHT 0x256 -#define AES_KEY_MAX_LENGHT_IN_BYTES 0x10 - - - -#define HASH_TESTS_NUMBER 0x3 -#define AES_TESTS_NUMBER 0x4 -#define AES_CCM_TESTS_NUMBER 0x1 -#define ECC_SIGN_TESTS_NUMBER 0x2 -#define ECC_DH_TESTS_NUMBER 0x2 -#define CHACHA_TESTS_NUMBER 0xA -#define CHACHA_POLY_TESTS_NUMBER 0x2 -#define HMAC_TESTS_NUMBER 0x2 -#define RSA_ENCDEC_OEP_TESTS_NUMBER 0x2 -#define RSA_SIGN_VERIFY_OEP_TESTS_NUMBER 0x1 -#define HKDF_TESTS_NUMBER 0x8 -#define OPERATIONS_NUMBER 0x2//Integrated/noniNtegrated - - -typedef enum OperationType_enum -{ - INTEGRATED_OPERATION , - NON_INTEGRATED_OPERATION , - OperationTypeLast= 0x7FFFFFFF, - -}OperationType_t; - -typedef enum BufferType_enum -{ - NON_INPLACE_BUFFER , - INPLACE_BUFFER , - BufferTypeLast= 0x7FFFFFFF, - -}BufferType_t; - -typedef enum RSAType_enum -{ - NON_CRT_MODE , - CRT_MODE , - RSATypeLast= 0x7FFFFFFF, - -}RSAType_enum; - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm.h deleted file mode 100644 index 3b6f20e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm.h +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_AESCCM_H -#define CRYS_AESCCM_H - -#include "ssi_pal_types.h" -#include "crys_error.h" - -#include "ssi_aes.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This file contains all of the enums and definitions that are used for the CRYS AESCCM APIs, as well as the APIs themselves. -The API supports AES-CCM and AES-CCM* as defined in ieee-802.15.4. - -@note -Regarding the AES-CCM*, the API supports only AES-CCM* as defined in ieee-802.15.4-2011; With the instantiations as defined in B.3.2 and the nonce as defined in 7.3.2. -in case of AES-CCM* the flow should be as follows: -
  • AES-CCM* integrated
  • -
    • CRYS_AESCCMStar_NonceGenerate
    • -
    • CRYS_AESCCMStar
-
  • AES-CCM* non-integrated
  • -
    • CRYS_AESCCMStar_NonceGenerate
    • -
    • CRYS_AESCCMStar_Init
    • -
    • CRYS_AESCCM_BlockAdata
    • -
    • CRYS_AESCCM_BlockTextData
    • -
    • CRYS_AESCCM_Finish
-*/ - -/************************ Defines ******************************/ - -#define CRYS_AESCCM_USER_CTX_SIZE_IN_WORDS (152/4) - -/* key and key buffer sizes definitions */ -#define CRYS_AESCCM_KEY_SIZE_WORDS 8 - -/* nonce and AESCCM-MAC sizes definitions */ -#define CRYS_AESCCM_NONCE_MIN_SIZE_BYTES 7 -#define CRYS_AESCCM_NONCE_MAX_SIZE_BYTES 13 -#define CRYS_AESCCM_MAC_MIN_SIZE_BYTES 4 -#define CRYS_AESCCM_MAC_MAX_SIZE_BYTES 16 - -#define CRYS_AESCCM_STAR_NONCE_SIZE_BYTES 13 -#define CRYS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES 8 - -#define CRYS_AESCCM_MODE_CCM 0 -#define CRYS_AESCCM_MODE_STAR 1 - - -/************************ Typedefs ****************************/ - -typedef enum { - CRYS_AES_Key128BitSize = 0, - CRYS_AES_Key192BitSize = 1, - CRYS_AES_Key256BitSize = 2, - CRYS_AES_Key512BitSize = 3, - - CRYS_AES_KeySizeNumOfOptions, - - CRYS_AES_KeySizeLast = 0x7FFFFFFF, - -}CRYS_AESCCM_KeySize_t; - -/* Defines the AES_CCM key buffer */ -typedef uint8_t CRYS_AESCCM_Key_t[CRYS_AESCCM_KEY_SIZE_WORDS * sizeof(uint32_t)]; -typedef uint8_t CRYS_AESCCM_Mac_Res_t[SASI_AES_BLOCK_SIZE_IN_BYTES]; - -/* Defines the AES_CCM_STAR source address buffer */ -typedef uint8_t CRYS_AESCCMStar_SourceAddress_t[CRYS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES]; -/* Defines the AES_CCM_STAR source address buffer */ -typedef uint8_t CRYS_AESCCMStar_Nonce_t[CRYS_AESCCM_STAR_NONCE_SIZE_BYTES]; - -/******************* Context Structure ***********************/ -/* The user's context structure - the argument type that is passed by the user - to the APIs called */ -typedef struct CRYS_AESCCM_UserContext_t -{ - uint32_t buff[CRYS_AESCCM_USER_CTX_SIZE_IN_WORDS]; -}CRYS_AESCCM_UserContext_t; - - -/************************ Public Functions **********************/ - -/*! -@brief This function initializes the AES CCM context. - -It formats of the input data, calculates AES-MAC value for the formatted B0 block containing control information and -CCM unique value (Nonce), and initializes the AES context structure including the initial CTR0 value. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_aesccm_error.h. -*/ -CRYSError_t CC_AESCCM_Init( - CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the AES context buffer that is allocated by the user and is used for - the AES operation. */ - SaSiAesEncryptMode_t EncrDecrMode, /*!< [in] Flag specifying whether Encrypt (::SASI_AES_ENCRYPT) or Decrypt - (::SASI_AES_DECRYPT) operation should be performed. */ - CRYS_AESCCM_Key_t CCM_Key, /*!< [in] Pointer to the AES-CCM key. */ - CRYS_AESCCM_KeySize_t KeySizeId, /*!< [in] Enumerator defining the key size (only 128 bit is valid). */ - uint32_t AdataSize, /*!< [in] Full byte length of additional (associated) data. If set to zero, - calling ::CRYS_AESCCM_BlockAdata on the same context would return an error. */ - uint32_t TextSizeQ, /*!< [in] Full length of plain text data. */ - uint8_t *N_ptr, /*!< [in] Pointer to the Nonce. */ - uint8_t SizeOfN, /*!< [in] Nonce byte size. The valid values depend on the ccm mode: -
  • CCM: valid values = [7 .. 13].
  • -
  • CCM*: valid values = [13].
*/ - uint8_t SizeOfT, /*!< [in] AES-CCM MAC (tag) byte size. The valid values depend on the ccm mode: -
  • CCM: valid values = [4, 6, 8, 10, 12, 14, 16].
  • -
  • CCM*: valid values = [0, 4, 8, 16].
*/ - uint32_t ccmMode /*!< [in] Flag specifying whether AES-CCM or AES-CCM* should be performed. */ -); - -#define CRYS_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT) \ - CC_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT, CRYS_AESCCM_MODE_CCM) - -#define CRYS_AESCCMStar_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT) \ - CC_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT, CRYS_AESCCM_MODE_STAR) - -/*! -@brief This function receives a CCM context and a block of additional data, and adds it to the AES MAC -calculation. -This API can be called only once per operation context. It should not be called in case AdataSize was set to -zero in ::CRYS_AESCCM_Init. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_aesccm_error.h. -*/ -CRYSError_t CRYS_AESCCM_BlockAdata( - CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ - uint8_t *DataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ - uint32_t DataInSize /*!< [in] Byte size of the additional data. Must match AdataSize parameter provided to - ::CRYS_AESCCM_Init. */ -); - -/*! -@brief This function can be invoked for any block of Text data whose size is a multiple of 16 bytes, -excluding the last block that must be processed by ::CRYS_AESCCM_Finish. -
  • If encrypting: - Continues calculation of the intermediate AES_MAC value of the text data, while simultaneously encrypting the text data using AES_CTR, - starting from CTR value = CTR0+1.
  • -
  • If decrypting: - Continues decryption of the text data, while calculating the intermediate AES_MAC value of decrypted data.
- -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_aesccm_error.h. -*/ -CRYSError_t CRYS_AESCCM_BlockTextData( - CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ - uint8_t *DataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ - uint32_t DataInSize, /*!< [in] Byte size of the text data block. Must be a multiple of 16 bytes. */ - uint8_t *DataOut_ptr /*!< [out] Pointer to the output data. The size of the output buffer must be at least DataInSize. - The buffer must be contiguous. */ -); - -/*! -@brief This function must be the last to be called on the text data. -It can either be called on the entire text data (if transferred as one block), or on the last block of the text data, -even if total size of text data is equal to 0. -It performs the same operations as ::CRYS_AESCCM_BlockTextData, but additionally: -
  • If encrypting:
  • -
    • If the size of text data is not in multiples of 16 bytes, it pads the remaining bytes with zeros to a full 16-bytes block and - processes the data using AES_MAC and AES_CTR algorithms.
    • -
    • Encrypts the AES_MAC result with AES_CTR using the CTR0 value saved in the context and places the SizeOfT bytes of MAC (tag) - at the end.
-
  • If decrypting:
  • -
    • Processes the text data, except for the last SizeOfT bytes (tag), using AES_CTR and then AES_MAC algorithms.
    • -
    • Encrypts the calculated MAC using AES_CTR based on the saved CTR0 value, and compares it with SizeOfT last bytes of input data (i.e. - tag value).
    • -
    • The function saves the validation result (Valid/Invalid) in the context.
    • -
    • Returns (as the error code) the final CCM-MAC verification result.
- -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_aesccm_error.h. -*/ -CEXPORT_C CRYSError_t CRYS_AESCCM_Finish( - CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ - uint8_t *DataIn_ptr, /*!< [in] Pointer to the last input data. The buffer must be contiguous. */ - uint32_t DataInSize, /*!< [in] Byte size of the last text data block. Can be zero. */ - uint8_t *DataOut_ptr, /*!< [in] Pointer to the output (cipher or plain text data) data. The buffer must - be contiguous. If DataInSize = 0, output buffer is not required. */ - CRYS_AESCCM_Mac_Res_t MacRes, /*!< [in] MAC result buffer pointer. */ - uint8_t *SizeOfT /*!< [out] AES-CCM MAC byte size as defined in CRYS_AESCCM_Init. */ -); - -/****************************************************************************************************/ -/******** AESCCM FUNCTION ******/ -/****************************************************************************************************/ -/*! -@brief AES CCM combines Counter mode encryption with CBC-MAC authentication. -Input to CCM includes the following elements: -
  • Payload - text data that is both authenticated and encrypted.
  • -
  • Associated data (Adata) - data that is authenticated but not encrypted, e.g., a header.
  • -
  • Nonce - A unique value that is assigned to the payload and the associated data.
  • - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_aesccm_error.h. -*/ -CIMPORT_C CRYSError_t CC_AESCCM( - SaSiAesEncryptMode_t EncrDecrMode, /*!< [in] A flag specifying whether an AES Encrypt (::SASI_AES_ENCRYPT) or Decrypt - (::SASI_AES_DECRYPT) operation should be performed. */ - CRYS_AESCCM_Key_t CCM_Key, /*!< [in] Pointer to AES-CCM key. */ - CRYS_AESCCM_KeySize_t KeySizeId, /*!< [in] Enumerator defining the key size (only 128 bit is valid). */ - uint8_t *N_ptr, /*!< [in] Pointer to the Nonce. */ - uint8_t SizeOfN, /*!< [in] Nonce byte size. The valid values depend on the ccm mode: -
    • CCM: valid values = [7 .. 13].
    • -
    • CCM*: valid values = [13].
    */ - uint8_t *ADataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ - uint32_t ADataInSize, /*!< [in] Byte size of the additional data. */ - uint8_t *TextDataIn_ptr, /*!< [in] Pointer to the plain-text data for encryption or cipher-text data for decryption. - The buffer must be contiguous. */ - uint32_t TextDataInSize, /*!< [in] Byte size of the full text data. */ - uint8_t *TextDataOut_ptr, /*!< [out] Pointer to the output (cipher or plain text data according to encrypt-decrypt mode) - data. The buffer must be contiguous. */ - uint8_t SizeOfT, /*!< [in] AES-CCM MAC (tag) byte size. The valid values depend on the ccm mode: -
    • CCM: valid values = [4, 6, 8, 10, 12, 14, 16].
    • -
    • CCM*: valid values = [0, 4, 8, 16].
    */ - CRYS_AESCCM_Mac_Res_t Mac_Res, /*!< [in/out] Pointer to the MAC result buffer. */ - uint32_t ccmMode /*!< [in] Flag specifying whether AES-CCM or AES-CCM* should be performed. */ -); - -#define CRYS_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res) \ - CC_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res, CRYS_AESCCM_MODE_CCM) - -#define CRYS_AESCCMStar(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res) \ - CC_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res, CRYS_AESCCM_MODE_STAR) - - -/*! -@brief This function receives the MAC source address, the frame counter and the MAC size -and returns the required nonce for AES-CCM* as defined in ieee-802.15.4. -This API should be called before CRYS_AESCCMStar and CRYS_AESCCMStar_Init, -and the generated nonce should be provided to these functions. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_aesccm_error.h. -*/ -CRYSError_t CRYS_AESCCMStar_NonceGenerate( - CRYS_AESCCMStar_SourceAddress_t srcAddr, /*!< [in] The MAC address in EUI-64 format. */ - uint32_t FrameCounter, /*!< [in] The MAC frame counter. */ - uint8_t SizeOfT, /*!< [in] AES-CCM* MAC (tag) byte size. Valid values = [0,4,8,16]. */ - CRYS_AESCCMStar_Nonce_t nonce /*!< [out] The required nonce for AES-CCM*. */ -); - -#ifdef __cplusplus -} -#endif - -#endif /*#ifndef CRYS_AESCCM_H*/ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm_error.h deleted file mode 100644 index e37d6e1..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_aesccm_error.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef CRYS_AESCCM_ERROR_H -#define CRYS_AESCCM_ERROR_H - - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS AESCCM errors. -*/ - -/************************ Defines ******************************/ - -/* The CRYS AESCCM module errors. - CRYS_AESCCM_MODULE_ERROR_BASE = 0x00F01500 */ -#define CRYS_AESCCM_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x00UL) -#define CRYS_AESCCM_ILLEGAL_KEY_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x01UL) -#define CRYS_AESCCM_INVALID_KEY_POINTER_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x02UL) -#define CRYS_AESCCM_INVALID_ENCRYPT_MODE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x03UL) -#define CRYS_AESCCM_USER_CONTEXT_CORRUPTED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x04UL) -#define CRYS_AESCCM_DATA_IN_POINTER_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x05UL) -#define CRYS_AESCCM_DATA_OUT_POINTER_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x06UL) -#define CRYS_AESCCM_DATA_IN_SIZE_ILLEGAL (CRYS_AESCCM_MODULE_ERROR_BASE + 0x07UL) -#define CRYS_AESCCM_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x08UL) -#define CRYS_AESCCM_DATA_OUT_SIZE_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x09UL) -#define CRYS_AESCCM_ADDITIONAL_BLOCK_NOT_PERMITTED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0AUL) -#define CRYS_AESCCM_ILLEGAL_DMA_BUFF_TYPE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0BUL) -#define CRYS_AESCCM_ILLEGAL_PARAMETER_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0CUL) -#define CRYS_AESCCM_ILLEGAL_PARAMETER_PTR_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0DUL) -#define CRYS_AESCCM_ILLEGAL_DATA_TYPE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0EUL) -#define CRYS_AESCCM_CCM_MAC_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0FUL) -#define CRYS_AESCCM_LAST_BLOCK_NOT_PERMITTED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x10UL) -#define CRYS_AESCCM_ILLEGAL_PARAMETER_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x11UL) -#define CRYS_AESCCM_NOT_ALL_ADATA_WAS_PROCESSED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x13UL) -#define CRYS_AESCCM_NOT_ALL_DATA_WAS_PROCESSED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x14UL) -#define CRYS_AESCCM_ADATA_WAS_PROCESSED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x15UL) -#define CRYS_AESCCM_ILLEGAL_NONCE_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x16UL) -#define CRYS_AESCCM_ILLEGAL_TAG_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x17UL) - -#define CRYS_AESCCM_CTX_SIZES_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x28UL) -#define CRYS_AESCCM_ILLEGAL_PARAMS_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x29UL) -#define CRYS_AESCCM_IS_NOT_SUPPORTED (CRYS_AESCCM_MODULE_ERROR_BASE + 0xFFUL) - -/************************ Enums ********************************/ - -/************************ Typedefs ****************************/ - -/************************ Structs *****************************/ - -/************************ Public Variables *********************/ - -/************************ Public Functions *********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_error.h deleted file mode 100644 index c60c293..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_error.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_CHACHA_ERROR_H -#define CRYS_CHACHA_ERROR_H - - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS CHACHA errors. -*/ - - - -/************************ Defines ******************************/ - -/* The CRYS AES module errors base address - 0x00F02200 */ -#define CRYS_CHACHA_INVALID_NONCE_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x01UL) -#define CRYS_CHACHA_ILLEGAL_KEY_SIZE_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x02UL) -#define CRYS_CHACHA_INVALID_KEY_POINTER_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x03UL) -#define CRYS_CHACHA_INVALID_ENCRYPT_MODE_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x04UL) -#define CRYS_CHACHA_DATA_IN_POINTER_INVALID_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x05UL) -#define CRYS_CHACHA_DATA_OUT_POINTER_INVALID_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x06UL) -#define CRYS_CHACHA_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x07UL) -#define CRYS_CHACHA_CTX_SIZES_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x08UL) -#define CRYS_CHACHA_INVALID_NONCE_PTR_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x09UL) -#define CRYS_CHACHA_DATA_IN_SIZE_ILLEGAL (CRYS_CHACHA_MODULE_ERROR_BASE + 0x0AUL) -#define CRYS_CHACHA_GENERAL_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x0BUL) -#define CRYS_CHACHA_IS_NOT_SUPPORTED (CRYS_CHACHA_MODULE_ERROR_BASE + 0xFFUL) - -/************************ Enums ********************************/ - -/************************ Typedefs ****************************/ - -/************************ Structs *****************************/ - -/************************ Public Variables *********************/ - -/************************ Public Functions *********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly.h deleted file mode 100644 index 08648c1..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains all of the enums and definitions that are used for the - CRYS CHACHA-POLY APIs, as well as the APIs themselves. -*/ -#ifndef CRYS_CHACHA_POLY_H -#define CRYS_CHACHA_POLY_H - - -#include "ssi_pal_types.h" -#include "crys_error.h" -#include "crys_chacha.h" -#include "crys_poly.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/*! -@brief This function is used to perform the CHACHA-POLY encryption and authentication operation. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_chacha_poly_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_CHACHA_POLY( - CRYS_CHACHA_Nonce_t pNonce, /*!< [in] A pointer to a buffer containing the nonce value. */ - CRYS_CHACHA_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ - CRYS_CHACHA_EncryptMode_t encryptDecryptFlag, /*!< [in] A flag specifying whether the CHACHA-POLY should perform an Encrypt or - Decrypt operation. */ - uint8_t *pAddData, /*!< [in] A pointer to the buffer of the additional data to the POLY. - The pointer does not need to be aligned. must not be null. */ - size_t addDataSize, /*!< [in] The size of the input data. must not be 0. */ - uint8_t *pDataIn, /*!< [in] A pointer to the buffer of the input data to the CHACHA. - The pointer does not need to be aligned. must not be null. */ - size_t dataInSize, /*!< [in] The size of the input data. must not be 0. */ - uint8_t *pDataOut, /*!< [out] A pointer to the buffer of the output data from the CHACHA. - must not be null. */ - CRYS_POLY_Mac_t macRes /*!< [in/out] Pointer to the MAC result buffer.*/ -); - - - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef CRYS_CHACHA_POLY_H */ - - - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly_error.h deleted file mode 100644 index f2948d0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha_poly_error.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_CHACHA_POLY_ERROR_H -#define CRYS_CHACHA_POLY_ERROR_H - - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS CHACHA POLY errors. -*/ - - - -/************************ Defines ******************************/ - -/* The CRYS CHACHA POLY module errors base address - 0x00F02400 */ -#define CRYS_CHACHA_POLY_ADATA_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x01UL) -#define CRYS_CHACHA_POLY_DATA_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x02UL) -#define CRYS_CHACHA_POLY_ENC_MODE_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x03UL) -#define CRYS_CHACHA_POLY_DATA_SIZE_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x04UL) -#define CRYS_CHACHA_POLY_GEN_KEY_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x05UL) -#define CRYS_CHACHA_POLY_ENCRYPTION_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x06UL) -#define CRYS_CHACHA_POLY_AUTH_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x07UL) -#define CRYS_CHACHA_POLY_MAC_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x08UL) - -/************************ Enums ********************************/ - -/************************ Typedefs ****************************/ - -/************************ Structs *****************************/ - -/************************ Public Variables *********************/ - -/************************ Public Functions *********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common_error.h deleted file mode 100644 index 9efd543..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common_error.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - #ifndef CRYS_COMMON_ERROR_H -#define CRYS_COMMON_ERROR_H - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/************************ Defines ******************************/ - -/* CRYS COMMON module errors. Base address - 0x00F00D00 */ - -#define CRYS_COMMON_INIT_HW_SEM_CREATION_FAILURE (CRYS_COMMON_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_COMMON_DATA_IN_POINTER_INVALID_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_COMMON_DATA_SIZE_ILLEGAL (CRYS_COMMON_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_COMMON_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x6UL) -#define CRYS_COMMON_DATA_OUT_POINTER_INVALID_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x7UL) -#define CRYS_COMMON_OUTPUT_BUFF_SIZE_ILLEGAL (CRYS_COMMON_MODULE_ERROR_BASE + 0x9UL) - -#define CRYS_COMMON_TST_UTIL_CHUNK_SIZE_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x10UL) -#define CRYS_COMMON_ERROR_IN_SAVING_LLI_DATA_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x11UL) - - -#define CRYS_COMMON_TST_UTIL_LLI_ENTRY_SIZE_TOO_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x12UL) -#define CRYS_COMMON_TST_CSI_DATA_SIZE_EXCEED_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x13UL) -#define CRYS_COMMON_TST_CSI_MODULE_ID_OUT_OF_RANGE (CRYS_COMMON_MODULE_ERROR_BASE + 0x14UL) -#define CRYS_COMMON_TST_CSI_MEMORY_MAPPING_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x15UL) - -#define CRYS_COMMON_TERM_HW_SEM_DELETE_FAILURE (CRYS_COMMON_MODULE_ERROR_BASE + 0x16UL) - -#define CRYS_COMMON_TST_UTIL_NOT_INTEGER_CHAR_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x17UL) -#define CRYS_COMMON_TST_UTIL_BUFFER_IS_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x18UL) -#define CRYS_COMMON_POINTER_NOT_ALIGNED_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x19UL) - - -/************************ Enums ********************************/ - - -/************************ Typedefs ****************************/ - - -/************************ Structs ******************************/ - - -/************************ Public Variables **********************/ - - -/************************ Public Functions **********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_error.h deleted file mode 100644 index 48500f7..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_error.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_DH_ERROR_H -#define CRYS_DH_ERROR_H - - -#include "crys_error.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This file contains error codes definitions for CRYS DH module. -*/ -/************************ Defines ******************************/ -/* DH module on the CRYS layer base address - 0x00F00500 */ -/* The CRYS DH module errors */ -#define CRYS_DH_INVALID_ARGUMENT_POINTER_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_DH_INVALID_ARGUMENT_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_DH_INVALID_ARGUMENT_OPERATION_MODE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2UL) -#define CRYS_DH_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x3UL) - -/*the derived secret key size needed is wrong*/ -#define CRYS_DH_SECRET_KEYING_DATA_SIZE_ILLEGAL_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_DH_INVALID_L_ARGUMENT_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_DH_ARGUMENT_PRIME_SMALLER_THAN_GENERATOR_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x6UL) -#define CRYS_DH_ARGUMENT_GENERATOR_SMALLER_THAN_ZERO_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x7UL) -#define CRYS_DH_ARGUMENT_PRV_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x8UL) -#define CRYS_DH_ARGUMENT_BUFFER_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x9UL) -#define CRYS_DH_INVALID_SHARED_SECRET_VALUE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0xAUL) -#define CRYS_DH_IS_NOT_SUPPORTED (CRYS_DH_MODULE_ERROR_BASE + 0xFUL) - -#define CRYS_DH_X942_HYBRID_SIZE1_BUFFER_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x15UL) - -/*The requested derived secret key size is invalid*/ -#define CRYS_DH_SECRET_KEY_SIZE_NEEDED_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x16UL) -#define CRYS_DH_SECRET_KEY_SIZE_OUTPUT_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x17UL) -#define CRYS_DH_OTHERINFO_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x18UL) - -/* DH domain and key generation and checking errors */ -#define CRYS_DH_INVALID_MODULUS_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x20UL) -#define CRYS_DH_INVALID_ORDER_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x21UL) -#define CRYS_DH_INVALID_SEED_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x22UL) -#define CRYS_DH_INVALID_J_FACTOR_PTR_OR_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x23UL) -#define CRYS_DH_INVALID_GENERATOR_PTR_OR_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x24UL) - -#define CRYS_DH_CHECK_DOMAIN_PRIMES_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x25UL) -#define CRYS_DH_CHECK_DOMAIN_GENERATOR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x26UL) -#define CRYS_DH_INVALID_PUBLIC_KEY_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x27UL) -#define CRYS_DH_CHECK_PUB_KEY_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x28UL) -#define CRYS_DH_CHECK_GENERATOR_SIZE_OR_PTR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x29UL) -#define CRYS_DH_CHECK_SEED_SIZE_OR_PTR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2AUL) -#define CRYS_DH_CHECK_GENERATOR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2BUL) -#define CRYS_DH_PRIME_P_GENERATION_FAILURE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2CUL) -#define CRYS_DH_INVALID_PUBLIC_KEY_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2DUL) -#define CRYS_DH_PASSED_INVALID_SEED_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2EUL) - -#define CRYS_DH_HOST_MSG_GENERAL_RPC_A_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x30UL) -#define CRYS_DH_HOST_MSG_GENERAL_RPC_B_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x31UL) -#define CRYS_DH_HOST_MSG_GENERAL_RPC_C_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x32UL) - - - - - -/************************ Enums ********************************/ - - -/************************ Typedefs ****************************/ - - -/************************ Structs ******************************/ - - -/************************ Public Variables **********************/ - - -/************************ Public Functions **********************/ - - - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_kg.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_kg.h deleted file mode 100644 index a286d26..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh_kg.h +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _CRYS_DH_KG_H -#define _CRYS_DH_KG_H - - -#include "crys_dh.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! @file -@brief This module defines the API that supports Diffie-Hellman domain. -*/ - -/************************ Defines ******************************/ - -#define CRYS_DH_SEED_MIN_SIZE_IN_BYTES CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES -#define CRYS_DH_SEED_MIN_SIZE_IN_BITS (CRYS_DH_SEED_MIN_SIZE_IN_BYTES * 8) - -/************************ Enums ********************************/ - - -/************************ Typedefs ****************************/ - -/* temp buffers, used in different DH KG functions */ - -/* temp data buffer structure for domain parameters generation in DH */ -typedef struct CRYS_DHKGData_t -{ - /* The aligned input and output temp buffers */ - uint32_t TempBuff1[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - uint32_t TempBuff2[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - uint32_t TempBuff3[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - uint32_t TempBuff4[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - uint32_t TempBuff5[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - uint32_t TempBuff6[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - - CRYS_DH_Temp_t ExpTemps; -}CRYS_DHKGData_t; - -typedef struct CRYS_DHKG_CheckTemp_t -{ - uint32_t CheckTempBuff[3*CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; - CRYS_DHKGData_t DhKgBuff; -}CRYS_DHKG_CheckTemp_t; - -/* DH Domain generation values definitions */ -#define DH_X942_PRIME_MOD_MIN_VAL 1024 -#define DH_X942_PRIME_MOD_MAX_VAL 2048 -#define DH_X942_PGEN_COUNTER_CONST 4096 -#define DH_X942_HASH_SIZE_BITS 160 -#define DH_SEED_MAX_ADDING_VAL 0xFFFFFFFF - -/************************ Structs ******************************/ - -/************************ Public Variables **********************/ - -/************************ Public Functions **********************/ - - -/******************************************************************************************/ -/*! -@brief This function generates DH domain parameters in Galois prime field according to standard [ANS X9.42]. -It receives the required sizes (in bits) of the modulus, the generator's order, and the seed, and then generates the prime modulus and the generator -according to these parameters. -If generateSeed argument is set to 1, the function generates and outputs the random seed. Otherwise (if set to 0), the seed has to be passed as an input argument. -According to implementation value of the user passed seed should be not greate, than (2^seedSizeBits - 2^32). -The Seed and some additional parameters, generated by the function (factorJ, pgenCounter), are used for checking that all domain parameters are generated -according to the standard and not forged. -\note All buffer parameters should be in Big-Endian form. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_dh_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_DH_CreateDomainParams( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint32_t modPsizeBits, /*!< [in] Size of the modulus (Prime) in bits equal 256*n, where n >= 4. FIPS 186-4 - defines sizes 1024 and 2048 bit. */ - uint32_t orderQsizeBits, /*!< [in] Size of the Generator's order in bits. FIPS 186-4 defines orderQSizeBits = 160 - for modulus 1024 bit and 224 or 256 bit for modPSizeBits = 2048. We not recommend - sizes > 256 and returns an error if orderQSizeBits > modPSizeBits/4 */ - uint32_t seedSizeBits, /*!< [in] Seed size in bits. Requirements: modPSizeBits >= seedSizeBits >= orderQSizeBits - (the first is required by our implementation). */ - uint8_t *modP_ptr, /*!< [out] Pointer to the modulus (Prime) buffer of defined structure. The size of the - buffer for output generated value must be no less than modulus size. */ - uint8_t *orderQ_ptr, /*!< [out] Pointer to the order Q of generator. The size of the buffer for output generated - value must be no less than the order size. */ - uint8_t *generatorG_ptr, /*!< [out] Pointer to the generator of multiplicative subgroup in GF(P). - If the user does not need this output, then both the pointer and the buffer size must be set - to 0. */ - uint32_t *generGsizeBytes_ptr, /*!< [in/out] Pointer to the one word buffer for outputting the generator's size. - The passed size (if needed) must be no less than modulus size. - The function returns the actual size of the generator. */ - uint8_t *factorJ_ptr, /*!< [out] Pointer to the buffer for integer factor J. If NULL, the function does not output - this parameter. */ - uint32_t *JsizeBytes_ptr, /*!< [in/out] Pointer to the size of integer factor J. If NULL, the function does not output - this parameter. */ - uint8_t *seedS_ptr, /*!< [in/out] Random seed used for prime generation. The size of the buffer for output - generated value must be at least the seed size. */ - int8_t generateSeed, /*!< [in] Flag defining whether the seed should be generated randomly by the function - (1) or passed by the user (0). */ - uint32_t *pgenCounter_ptr, /*!< [out] Pointer to counter of tries to generate the primes. If NULL, the function does not - output this parameter. */ - CRYS_DHKGData_t *DHKGbuff_ptr /*!< [out] The temp buffer of defined structure for internal calculations. */ -); - - -/******************************************************************************************/ -/*! -@brief This function receives DH domain parameters, seed and prime generation counter and then verifies that the domain was created according to -the standard [ANS X9.42]. According to implementation value of the user passed seed should be not greate, than -(2^seedSizeBits - 2^32). Otherwise an error is returned. -\note All buffer parameters should be in Big-Endian form. For a description of -the parameters see ::_DX_ECPKI_BuildPublKey. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_dh_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_DH_CheckDomainParams( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint8_t *modP_ptr, /*!< [in] Pointer to the modulus (Prime). */ - uint32_t modPsizeBytes, /*!< [in] Size of the modulus (Prime) in bytes. */ - uint8_t *orderQ_ptr, /*!< [in] Pointer to the order Q of generator. The size of the buffer for output generated value - must be no less than the order size. */ - uint32_t orderQsizeBytes, /*!< [in] Size of the Generator's order in bytes. */ - uint8_t *generatorG_ptr, /*!< [in] Pointer to the generator of the multiplicative subgroup in GF(P). */ - uint32_t generatorSizeBytes, /*!< [in] Size of the generator in bytes. */ - uint8_t *seedS_ptr, /*!< [in] Random seed used for prime generation. */ - uint32_t seedSizeBits, /*!< [in] Seed size in bits. */ - uint32_t pgenCounter, /*!< [in] Counter of prime generation attempts. */ - CRYS_DHKG_CheckTemp_t *checkTempBuff_ptr /*!< [in] Temporary buffer for internal calculations. */ - -); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_edw_api.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_edw_api.h deleted file mode 100644 index 3d81783..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_edw_api.h +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_EC_EDW_API_H -#define CRYS_EC_EDW_API_H - -#include "ssi_pal_types.h" -#include "crys_hash.h" -#include "crys_rnd.h" -#include "crys_pka_defs_hw.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*! -@file -@brief This file contains the CRYS APIs used for EC EDW (Edwards) ed25519 algorithms. - -\note Algorithms of Montgomery and Edwards elliptic curves cryptography were developed by - Daniel.J.Bernstein. -*/ - -/*! EC Edwards ed25519 modulus and order sizes in bits, words and bytes */ -#define CRYS_ECEDW_MOD_SIZE_IN_BITS 255U /*!<\internal MOD - EC Edw modulus size*/ -#define CRYS_ECEDW_ORD_SIZE_IN_BITS 255U /*!<\internal ORD - EC Edw generator order size*/ -#define CRYS_ECEDW_MOD_SIZE_IN_32BIT_WORDS \ - ((CRYS_ECEDW_MOD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / SASI_BITS_IN_32BIT_WORD) -#define CRYS_ECEDW_MOD_SIZE_IN_BYTES (CRYS_ECEDW_MOD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) -#define CRYS_ECEDW_ORD_SIZE_IN_32BIT_WORDS \ - ((CRYS_ECEDW_ORD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / SASI_BITS_IN_32BIT_WORD) -#define CRYS_ECEDW_ORD_SIZE_IN_BYTES (CRYS_ECEDW_ORD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) - -/*! Constant sizes of special EC_MONT buffers and arrays */ -#define CRYS_ECEDW_SEED_BYTES CRYS_ECEDW_MOD_SIZE_IN_BYTES -#define CRYS_ECEDW_SECRET_KEY_BYTES (2 * CRYS_ECEDW_MOD_SIZE_IN_BYTES) -#define CRYS_ECEDW_SIGNATURE_BYTES (2 * CRYS_ECEDW_ORD_SIZE_IN_BYTES) -#define CRYS_ECEDW_SCALAR_BYTES CRYS_ECEDW_ORD_SIZE_IN_BYTES -#define CRYS_ECEDW_SCALARMULT_BYTES CRYS_ECEDW_MOD_SIZE_IN_BYTES - -/*! EC_EDW temp buffer size definition */ -#define CRYS_ECEDW_TEMP_BUFF_SIZE_IN_32BIT_WORD \ - (10*CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS + \ - (sizeof(CRYS_HASHUserContext_t)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE) - -/*! EC_EDW temp buffer type definition */ -typedef struct { - uint32_t buff[CRYS_ECEDW_TEMP_BUFF_SIZE_IN_32BIT_WORD]; -} CRYS_ECEDW_TempBuff_t; - - -/******************************************************************************/ -/*! -@brief The function creates EC Edwards signature on the message. -\note Used detached form of signature, separated from the message. - Implemented algorithm of Bernstein D. etc. sign ed25519. - -@return CRYS_OK on success, -@return A non-zero value on failure as defined crys_ec_mont_edw_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECEDW_Sign ( - uint8_t *pSign, /*!< [out] Pointer to the detached signature. */ - size_t *pSignSize, /*!< [in/out] Pointer to the total size of the signature ; - In - the buffer size, which (must be at least 2*EC order size); - Out - the actual size of output data. */ - const uint8_t *pMsg, /*!< [in] Pointer to the message. */ - size_t msgSize, /*!< [in] Message size in bytes: must be less, than - (CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES - 2*(EC_EDW modulus size)). */ - const uint8_t *pSignSecrKey, /*!< [in] Pointer to the signer secret key (seed || pulKey) */ - size_t secrKeySize, /*!< [in] Size of signer secret key in bytes: (must be 2*EC order size). */ - CRYS_ECEDW_TempBuff_t *pTempBuff); /*!< [in] Pointer to the temp buffer. */ - - - -/******************************************************************************/ -/*! -@brief The function verifies the EC Edwards ed25519 signature on the message. -\note The input signature is in detached form, i.e. separated from the message. - -@return CRYS_OK on success, -@return A non-zero value on failure as defined crys_ec_mont_edw_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECEDW_Verify( - const uint8_t *pSign, /*!< [in] Pointer to detached signature, i.e. the - signature is separated from the message. */ - size_t signSize, /*!< [in] Size of the signature in bytes, it must be - equal to two EC Order size in bytes. */ - const uint8_t *pSignPublKey, /*!< [in] Pointer to signer public key. */ - size_t publKeySize, /*!< [in] Size of the signer public key in bytes; must be - equal to EC modulus size. */ - uint8_t *pMsg, /*!< [in] Pointer to the message. */ - size_t msgSize, /*!< [in] Pointer to the message size in bytes. Must be less than - (CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES - 2*(EC_EDW modulus size)). */ - CRYS_ECEDW_TempBuff_t *pTempBuff); /*!< [in] Pointer to the temp buffer, for internal use. */ - - -/******************************************************************************/ -/*! -@brief The function randomly generates Ec ed25519 private and public keys - using given seed. - The generation is performed using EC Edwards ed25519 algorithm. - -@return CRYS_OK on success, -@return A non-zero value on failure as defined crys_ec_mont_edw_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECEDW_SeedKeyPair ( - const uint8_t *pSeed, /*!< [in] Pointer to the given seed. */ - size_t seedSize, /*!< [in] Size of the seed in bytes, must be equal the EC order size - in bytes. */ - uint8_t *pSecrKey, /*!< [out] Pointer to the secret key, including the seed, concatenated - with the public key. */ - size_t *pSecrKeySize, /*!< [in/out] Pointer to the size of the secret key buffer in bytes - (must be at least 2*EC order size). */ - uint8_t *pPublKey, /*!< [out] Pointer to the public key. */ - size_t *pPublKeySize, /*!< [in/out] Pointer to the size of the public key in bytes. - In - the size of buffer must be at least EC modulus size; - Out - the actual size. */ - CRYS_ECEDW_TempBuff_t *pTempBuff); /*!< [in] Pointer to the temp buffer, for internal use. */ - -/*******************************************************************/ -/*! - @brief The function randomly generates the EC Edwards ed25519 private and - public keys. - The generation is performed using EC Edwards ed25519 algorithm. - -@return CRYS_OK on success, -@return A non-zero value on failure as defined crys_ec_mont_edw_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECEDW_KeyPair ( - uint8_t *pSecrKey, /*!< [out] Pointer to the secret key (including seed and public key). */ - size_t *pSecrKeySize, /*!< [in/out] Pointer to the size of the secret key in bytes, - (must be at least 2*EC order size). */ - uint8_t *pPublKey, /*!< [out] Pointer to the public key. */ - size_t *pPublKeySize, /*!< [in/out] - Pointer to the size of the public key in bytes. - In - the size of buffer must be at least EC modulus size; - Out - the actual size. */ - CRYS_RND_Context_t *pRndContext, /*!< [in/out] Pointer to the RND context buffer. */ - CRYS_ECEDW_TempBuff_t *pTempBuff); /*!< [in] Pointer to the temp buffer. */ - - -#ifdef __cplusplus -} -#endif - -#endif - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_build.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_build.h deleted file mode 100644 index 0a39fdb..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_build.h +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_ECPKI_BUILD_H -#define CRYS_ECPKI_BUILD_H - -/*! -@file -@brief This module defines functions for building key structures used in Elliptic Curves Cryptography (ECC). -*/ - - -#include "crys_error.h" -#include "crys_ecpki_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/********************************************************************************** - * CRYS_ECPKI_BuildPrivKey function * - **********************************************************************************/ -/*! -@brief Builds (imports) the user private key structure from an existing private key so -that this structure can be used by other EC primitives. -This function should be called before using of the private key. Input -domain structure must be initialized by EC parameters and auxiliary -values, using CRYS_ECPKI_GetDomain or CRYS_ECPKI_SetDomain functions. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECPKI_BuildPrivKey( - const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] The EC domain (curve). */ - const uint8_t *pPrivKeyIn, /*!< [in] Pointer to private key data. */ - uint32_t PrivKeySizeInBytes, /*!< [in] Size of private key data (in bytes). */ - CRYS_ECPKI_UserPrivKey_t *pUserPrivKey /*!< [out] Pointer to the private key structure. - This structure is used as input to the ECPKI cryptographic primitives. */ - ); - -/********************************************************************************** - * _DX_ECPKI_BuildPublKey function * - **********************************************************************************/ -/*! -@brief Builds a user public key structure from an imported public key, -so it can be used by other EC primitives. -When operating the EC cryptographic algorithms with imported EC public -key, this function should be called before using of the public key. - -\note The Incoming public key PublKeyIn structure is big endian bytes array, containing -concatenation of PC||X||Y, where: -
    • PC - point control single byte, defining the type of point: 0x4 - uncompressed, -06,07 - hybrid, 2,3 - compressed.
    • -
    • X,Y - EC point coordinates of public key (y is omitted in compressed form), -size of X and Y must be equal to size of EC modulus.
    - -The user may call this function by appropriate macros, according to necessary validation level [SEC1. ECC standard: 3.2, ANS X9.62]: -
    • checking the input pointers and sizes only - ::CRYS_ECPKI_BuildPublKey.
    • -
    • partly checking of public key - ::CRYS_ECPKI_BuildPublKeyPartlyCheck.
    • -
    • full checking of public key - ::CRYS_ECPKI_BuildPublKeyFullCheck.
    - -\note Full check mode takes long time and should be used when it is actually needed. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -*/ -/* -The function performs the following operations: -- Checks validity of incoming variables and pointers; -- Converts incoming key data from big endian into little endian; -- If public key is given in compressed form (i.e. byte[0] = 2 or 3 and - coordinate Y is omitted), then the function uncompress it; -- Performs checking of input key according to CheckMode parameter. -- Initializes variables and structures. -*/ -CIMPORT_C CRYSError_t _DX_ECPKI_BuildPublKey( - const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] The EC domain (curve). */ - uint8_t *PublKeyIn_ptr, /*!< [in] Pointer to the input public key data, in compressed or - uncompressed or hybrid form: - [PC||X||Y] Big-Endian representation, structured according to - [IEEE1363], where: -
    • X and Y are the public key's EC point coordinates. - In compressed form, Y is omitted.
    • -
    • The sizes of X and Y are equal to the size of the EC modulus.
    • -
    • PC is a one-byte point control that defines the type of point - compression.
    */ - uint32_t PublKeySizeInBytes, /*!< [in] The size of public key data (in bytes). */ - EC_PublKeyCheckMode_t CheckMode, /*!< [in] The required level of public key verification - (higher verification level means longer verification time): -
    • 0 = preliminary validation.
    • -
    • 1 = partial validation.
    • -
    • 2 = full validation.
    */ - CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [out] Pointer to the output public key structure. - This structure is used as input to the ECPKI cryptographic primitives. */ - CRYS_ECPKI_BUILD_TempData_t *pTempBuff /*!< [in] Pointer for a temporary buffer required for the build function. */ - ); - - -/********************************************************************************** - * CRYS_ECPKI_BuildPublKey macro * - **********************************************************************************/ -/*! -@brief This macro calls _DX_ECPKI_BuildPublKey function for building the public key -while checking input pointers and sizes. For a description of the parameters see ::_DX_ECPKI_BuildPublKey. -*/ -#define CRYS_ECPKI_BuildPublKey(pDomain, PublKeyIn_ptr, PublKeySizeInBytes, pUserPublKey) \ - _DX_ECPKI_BuildPublKey((pDomain), (PublKeyIn_ptr), (PublKeySizeInBytes), CheckPointersAndSizesOnly, (pUserPublKey), NULL) - - -/********************************************************************************** - * CRYS_ECPKI_BuildPublKeyPartlyCheck macro * - **********************************************************************************/ -/*! -@brief This macro calls _DX_ECPKI_BuildPublKey function for building the public key with partial validation of the key [SEC1] - 3.2.3. -For a description of the parameters see ::_DX_ECPKI_BuildPublKey. -*/ -#define CRYS_ECPKI_BuildPublKeyPartlyCheck(pDomain, PublKeyIn_ptr, PublKeySizeInBytes, pUserPublKey, pTempBuff) \ - _DX_ECPKI_BuildPublKey((pDomain), (PublKeyIn_ptr), (PublKeySizeInBytes), ECpublKeyPartlyCheck, (pUserPublKey), (pTempBuff)) - - -/********************************************************************************** - * CRYS_ECPKI_BuildPublKeyFullCheck macro * - **********************************************************************************/ -/*! -@brief This macro calls _DX_ECPKI_BuildPublKey function for building the public key with full validation of the key [SEC1] - 3.2.2. -For a description of the parameters and return values see _DX_ECPKI_BuildPublKey. -*/ -#define CRYS_ECPKI_BuildPublKeyFullCheck(pDomain, PublKeyIn_ptr, PublKeySizeInBytes, pUserPublKey, pTempBuff) \ - _DX_ECPKI_BuildPublKey((pDomain), (PublKeyIn_ptr), (PublKeySizeInBytes), (ECpublKeyFullCheck), (pUserPublKey), (pTempBuff)) - - -/*********************************************************************************** - * CRYS_ECPKI_ExportPublKey function * - ***********************************************************************************/ -/*! -@brief Converts an existing public key from internal representation to Big-Endian export representation. -The function converts the X,Y coordinates of public key EC point to big endianness, -and sets the public key as follows: -
    • In case "Uncompressed" point: PubKey = PC||X||Y, PC = 0x4 - single byte;
    • -
    • In case of "Hybrid" key PC = 0x6.
    • -
    • In case of "Compressed" key PC = 0x2.
    -\note Size of output X and Y coordinates is equal to ModSizeInBytes. -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECPKI_ExportPublKey( - CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [in] Pointer to the input public key structure (in Little-Endian form). */ - CRYS_ECPKI_PointCompression_t compression, /*!< [in] Compression mode: Compressed, Uncompressed or Hybrid. */ - uint8_t *pExternPublKey, /*!< [out] Pointer to the exported public key array, in compressed or uncompressed - or hybrid form: - [PC||X||Y] Big-Endian representation, structured according to [IEEE1363]. - In compressed form, Y is omitted. */ - uint32_t *pPublKeySizeBytes /*!< [in/out] Pointer used for the input of the user public key buffer size - (in bytes), and the output of the size of the converted public key in bytes. */ - ); - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_dh.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_dh.h deleted file mode 100644 index e381878..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_dh.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_ECPKI_DH_H -#define CRYS_ECPKI_DH_H - -/*! @file -@brief Defines the API that supports EC Diffie-Hellman shared secret value derivation primitives. -*/ - - -#include "crys_ecpki_types.h" -#include "crys_ecpki_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*********************************************************************** - * CRYS_ECDH_SVDP_DH function * - ***********************************************************************/ -/*! -@brief Creates the shared secret value according to [IEEE1363, ANS X9.63]: - -
    1. Checks input-parameter pointers and EC Domain in public and private -keys.
    2. -
    3. Derives the partner public key and calls the EcWrstDhDeriveSharedSecret -function, which performs EC SVDP operations.
    -\note The term "User" -refers to any party that calculates a shared secret value using this primitive. -The term "Partner" refers to any other party of shared secret value calculation. -Partner's public key shall be validated before using in this primitive. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECDH_SVDP_DH( - CRYS_ECPKI_UserPublKey_t *PartnerPublKey_ptr, /*!< [in] Pointer to a partner public key. */ - CRYS_ECPKI_UserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to a user private key. */ - uint8_t *SharedSecretValue_ptr, /*!< [out] Pointer to an output buffer that will contain the shared - secret value. */ - uint32_t *SharedSecrValSize_ptr, /*!< [in/out] Pointer to the size of user-passed buffer (in) and - actual size of output of calculated shared secret value - (out). */ - CRYS_ECDH_TempData_t *TempBuff_ptr /*!< [in] Pointer to a temporary buffer. */); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_domain.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_domain.h deleted file mode 100644 index b2b7be0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_domain.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_ECPKI_DOMAIN_H -#define CRYS_ECPKI_DOMAIN_H - - -/*! -@file -@brief Defines the ecpki build domain API. -*/ - - -#include "crys_error.h" -#include "crys_ecpki_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - - - -/********************************************************************************** - * CRYS_ECPKI_GetEcDomain function * - **********************************************************************************/ - -/*! - * @brief The function returns a pointer to an ECDSA saved domain (one of the supported domains). - * - * @return Domain pointer on success. - * @return NULL on failure. - */ - -const CRYS_ECPKI_Domain_t *CRYS_ECPKI_GetEcDomain(CRYS_ECPKI_DomainID_t domainId /*!< [in] Index of one of the domain Id (must be one of the supported domains). */); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_ecdsa.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_ecdsa.h deleted file mode 100644 index d132795..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_ecdsa.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_ECPKI_ECDSA_H -#define CRYS_ECPKI_ECDSA_H - -/*! -@file -@brief Defines the APIs that support the ECDSA functions. -*/ - -#include "crys_error.h" -#include "crys_ecpki_types.h" -#include "crys_hash.h" -#include "crys_rnd.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - - -/************************************************************************** - * CRYS_ECDSA_Sign - integrated function - **************************************************************************/ -/*! -@brief This function performs an ECDSA sign operation in integrated form. - -\note -Using of HASH functions with HASH size greater than EC modulus size, is not recommended!. -Algorithm according [ANS X9.62] standard - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -**/ -CIMPORT_C CRYSError_t CRYS_ECDSA_Sign( - CRYS_RND_Context_t *pRndContext, /*!< [in/out] Pointer to the RND context buffer. */ - CRYS_ECDSA_SignUserContext_t *pSignUserContext, /*!< [in/out] Pointer to the user buffer for signing the database. */ - CRYS_ECPKI_UserPrivKey_t *pSignerPrivKey, /*!< [in] A pointer to a user private key structure. */ - CRYS_ECPKI_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in - ::CRYS_ECPKI_HASH_OpMode_t. - \note MD5 is not supported. */ - uint8_t *pMessageDataIn, /*!< [in] Pointer to the input data to be signed. - The size of the scatter/gather list representing the data buffer - is limited to 128 entries, and the size of each entry is limited - to 64KB (fragments larger than 64KB are broken into - fragments <= 64KB). */ - uint32_t messageSizeInBytes, /*!< [in] Size of message data in bytes. */ - uint8_t *pSignatureOut, /*!< [in] Pointer to a buffer for output of signature. */ - uint32_t *pSignatureOutSize /*!< [in/out] Pointer to the signature size. Used to pass the size of - the SignatureOut buffer (in), which must be >= 2 - * OrderSizeInBytes. When the API returns, - it is replaced with the size of the actual signature (out). */ - ); - - - -/************************************************************************** - * CRYS_ECDSA_Verify integrated function - **************************************************************************/ -/*! -@brief This function performs an ECDSA verify operation in integrated form. -Algorithm according [ANS X9.62] standard - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECDSA_Verify ( - CRYS_ECDSA_VerifyUserContext_t *pVerifyUserContext, /*!< [in] Pointer to the user buffer for signing the database. */ - CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [in] Pointer to a user public key structure. */ - CRYS_ECPKI_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in - ::CRYS_ECPKI_HASH_OpMode_t. - \note MD5 is not supported. */ - uint8_t *pSignatureIn, /*!< [in] Pointer to the signature to be verified. */ - uint32_t SignatureSizeBytes, /*!< [in] Size of the signature (in bytes). */ - uint8_t *pMessageDataIn, /*!< [in] Pointer to the input data that was signed (same as given to - the signing function). The size of the scatter/gather list representing - the data buffer is limited to 128 entries, and the size of each entry is - limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). */ - uint32_t messageSizeInBytes /*!< [in] Size of the input data (in bytes). */ - ); - - -/**********************************************************************************************************/ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_error.h deleted file mode 100644 index d1e2942..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_error.h +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_ECPKI_ERROR_H -#define CRYS_ECPKI_ERROR_H - - -/*! -@file -@brief This module contains the definitions of the CRYS ECPKI errors. -*/ - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/************************ Defines ******************************/ - -/* CRYS_ECPKI_MODULE_ERROR_BASE = 0x00F00800 */ - -/********************************************************************************************* - * CRYS ECPKI MODULE ERRORS * - *********************************************************************************************/ -#define CRYS_ECPKI_ILLEGAL_D0MAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_ECPKI_DOMAIN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x2UL) -/* The CRYS ECPKI GEN KEY PAIR module errors */ -#define CRYS_ECPKI_GEN_KEY_INVALID_PRIVATE_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x3UL) -#define CRYS_ECPKI_GEN_KEY_INVALID_PUBLIC_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_ECPKI_GEN_KEY_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_ECPKI_RND_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x6UL) - -/************************************************************************************************************ -* The CRYS ECPKI BUILD KEYS MODULE ERRORS * -*************************************************************************************************************/ -#define CRYS_ECPKI_BUILD_KEY_INVALID_COMPRESSION_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x07UL) -#define CRYS_ECPKI_BUILD_KEY_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x08UL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x09UL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0AUL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0BUL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0CUL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0DUL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_USER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0EUL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0FUL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x10UL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_CHECK_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x11UL) -#define CRYS_ECPKI_BUILD_KEY_INVALID_TEMP_BUFF_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x12UL) -#define CRYS_ECPKI_BUILD_KEY_UNCOMPRESSION_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x13UL) - -/* The CRYS ECPKI EXPORT PUBLIC KEY MODULE ERRORS */ -#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_USER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x14UL) -#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_COMPRESSION_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x15UL) -#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_EXTERN_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x16UL) -#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x17UL) -#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x18UL) -#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x19UL) -#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1AUL) - -/* The CRYS ECPKI BUILD ECC DOMAIN ERRORS */ -#define CRYS_ECPKI_BUILD_DOMAIN_ID_IS_NOT_VALID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x20UL) -#define CRYS_ECPKI_BUILD_DOMAIN_DOMAIN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x21UL) -#define CRYS_ECPKI_BUILD_DOMAIN_EC_PARAMETR_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x22UL) -#define CRYS_ECPKI_BUILD_DOMAIN_EC_PARAMETR_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x23UL) -#define CRYS_ECPKI_BUILD_DOMAIN_COFACTOR_PARAMS_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x24UL) -#define CRYS_ECPKI_BUILD_DOMAIN_SECURITY_STRENGTH_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x25UL) - -#define CRYS_ECPKI_BUILD_SCA_RESIST_ILLEGAL_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x26UL) - - -/************************************************************************************************************ - * CRYS EC DIFFIE-HELLMAN MODULE ERRORS -*************************************************************************************************************/ -/* The CRYS EC SVDP_DH Function errors */ -#define CRYS_ECDH_SVDP_DH_INVALID_PARTNER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x31UL) -#define CRYS_ECDH_SVDP_DH_PARTNER_PUBL_KEY_VALID_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x32UL) -#define CRYS_ECDH_SVDP_DH_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x33UL) -#define CRYS_ECDH_SVDP_DH_USER_PRIV_KEY_VALID_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x34UL) -#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x35UL) -#define CRYS_ECDH_SVDP_DH_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x36UL) -#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x37UL) -#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x38UL) -#define CRYS_ECDH_SVDP_DH_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x39UL) -#define CRYS_ECDH_SVDP_DH_NOT_CONCENT_PUBL_AND_PRIV_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x3AUL) - - -/************************************************************************************************************ - * CRYS ECDSA MODULE ERRORS - ************************************************************************************************************/ -/* The CRYS ECDSA Signing errors */ -#define CRYS_ECDSA_SIGN_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x50UL) -#define CRYS_ECDSA_SIGN_INVALID_USER_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x51UL) -#define CRYS_ECDSA_SIGN_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x52UL) -#define CRYS_ECDSA_SIGN_ILLEGAL_HASH_OP_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x53UL) -#define CRYS_ECDSA_SIGN_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x54UL) -#define CRYS_ECDSA_SIGN_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x55UL) -#define CRYS_ECDSA_SIGN_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x57UL) -#define CRYS_ECDSA_SIGN_USER_PRIV_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x58UL) -#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x60UL) -#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x61UL) -#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x62UL) -#define CRYS_ECDSA_SIGN_INVALID_IS_EPHEMER_KEY_INTERNAL_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x63UL) -#define CRYS_ECDSA_SIGN_INVALID_EPHEMERAL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x64UL) -#define CRYS_ECDSA_SIGN_INVALID_RND_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x65UL) -#define CRYS_ECDSA_SIGN_INVALID_RND_FUNCTION_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x66UL) - -/* The CRYS ECDSA Verifying errors */ -#define CRYS_ECDSA_VERIFY_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x70UL) -#define CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x71UL) -#define CRYS_ECDSA_VERIFY_INVALID_SIGNER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x72UL) -#define CRYS_ECDSA_VERIFY_ILLEGAL_HASH_OP_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x73UL) -#define CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x76UL) -#define CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x77UL) -#define CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x80UL) -#define CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x81UL) -#define CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x82UL) -#define CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x83UL) -#define CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x84UL) - - -/************************************************************************************************************ - * CRYS EC ELGAMAL MODULE ERRORS - ************************************************************************************************************/ -/* The CRYS EC ELGAMAL Encrypt function errors */ -#define CRYS_EC_ELGAMAL_ENCR_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB1UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_RECEIVER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB2UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB3UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB4UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_ENCR_MESSAGE_OUT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB5UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_ENCR_MESS_OUT_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB6UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_ENCR_MESSAGE_OUT_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB7UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_TEMP_DATA_BUFFER_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB8UL) -#define CRYS_EC_ELGAMAL_RECEIVER_PUBL_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xB9UL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_EPHEMERAL_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xBAUL) -#define CRYS_EC_ELGAMAL_ENCR_INVALID_EPHEMERAL_PRIV_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xBBUL) - -/* The CRYS EC ELGAMAL Decrypt function errors */ -#define CRYS_EC_ELGAMAL_DECR_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC1UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_RECEIVER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC2UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_ENCR_MESSAGE_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC3UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_DECR_MESSAGE_OUT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC4UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_TEMP_DATA_BUFFER_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC5UL) -#define CRYS_EC_ELGAMAL_RECEIVER_PRIV_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC6UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_ENCR_MESSAGE_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC7UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_DECR_MESSAGE_OUT_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC8UL) -#define CRYS_EC_ELGAMAL_DECR_INVALID_DECR_MESSAGE_OUT_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC9UL) - - -#define CRYS_ECC_HOST_MSG_GENERAL_RPC_A_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE+0xD0UL) -#define CRYS_ECC_HOST_MSG_GENERAL_RPC_B_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE+0xD1UL) -#define CRYS_ECC_HOST_MSG_GENERAL_RPC_C_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE+0xD2UL) - -#define CRYS_ECC_ILLEGAL_PARAMS_ACCORDING_TO_PRIV_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xD3UL) - -#define CRYS_ECC_ILLEGAL_HASH_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE0UL) - - -/************************************************************************************************************ - * CRYS ECPKI MODULE COMMON ERRORS -*************************************************************************************************************/ -#define CRYS_ECPKI_INVALID_RND_FUNC_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x90UL) -#define CRYS_ECPKI_INVALID_RND_CTX_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x91UL) -#define CRYS_ECPKI_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x92UL) -#define CRYS_ECPKI_INVALID_PRIV_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x93UL) -#define CRYS_ECPKI_INVALID_PUBL_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x94UL) -#define CRYS_ECPKI_INVALID_DATA_IN_PASSED_STRUCT_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x95UL) - -/************************************************************************************************************ - * CRYS ECIES MODULE ERRORS -*************************************************************************************************************/ -#define CRYS_ECIES_INVALID_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE0UL) -#define CRYS_ECIES_INVALID_PUBL_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE1UL) -#define CRYS_ECIES_INVALID_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE2UL) -#define CRYS_ECIES_INVALID_PRIV_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE3UL) -#define CRYS_ECIES_INVALID_PRIV_KEY_VALUE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE4UL) -#define CRYS_ECIES_INVALID_KDF_DERIV_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE5UL) -#define CRYS_ECIES_INVALID_KDF_HASH_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE6UL) -#define CRYS_ECIES_INVALID_SECRET_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE7UL) -#define CRYS_ECIES_INVALID_SECRET_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE8UL) -#define CRYS_ECIES_INVALID_CIPHER_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE9UL) -#define CRYS_ECIES_INVALID_CIPHER_DATA_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEAUL) -#define CRYS_ECIES_INVALID_CIPHER_DATA_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEBUL) -#define CRYS_ECIES_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xECUL) -#define CRYS_ECIES_INVALID_EPHEM_KEY_PAIR_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEDUL) - -/************************ Enums ********************************/ - -/************************ Typedefs ****************************/ - -/************************ Structs ******************************/ - -/************************ Public Variables **********************/ - -/************************ Public Functions **********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_kg.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_kg.h deleted file mode 100644 index 07f521c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_kg.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_ECPKI_KG_H -#define CRYS_ECPKI_KG_H - -/*! @file -@brief Defines the API for generation of ECC private and public keys. -*/ - - -#include "crys_error.h" -#include "crys_rnd.h" -#include "crys_ecpki_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/***************** CRYS_ECPKI_GenKeyPair function **********************/ -/*! -@brief Generates a pair of private and public keys in internal representation according to [ANS X9.62]. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_ecpki_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_ECPKI_GenKeyPair( - CRYS_RND_Context_t *pRndContext, /*!< [in/out] Pointer to the RND context buffer. */ - const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] Pointer to EC domain (curve). */ - CRYS_ECPKI_UserPrivKey_t *pUserPrivKey, /*!< [out] Pointer to the private key structure. This structure is used as input to the - ECPKI cryptographic primitives. */ - CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [out] Pointer to the public key structure. This structure is used as input to the - ECPKI cryptographic primitives. */ - CRYS_ECPKI_KG_TempData_t *pTempData, /*!< [in] Temporary buffers for internal use, defined in ::CRYS_ECPKI_KG_TempData_t. */ - CRYS_ECPKI_KG_FipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ -); - - - -#ifdef __cplusplus -} -#endif - -#endif - - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_types.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_types.h deleted file mode 100644 index 53c7654..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ecpki_types.h +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_ECPKI_TYPES_H -#define CRYS_ECPKI_TYPES_H - -/*! -@file -@brief Contains all of the enums and definitions that are used for the CRYS ECPKI APIs. -*/ - -#include "ssi_pal_types_plat.h" -#include "crys_hash.h" -#include "crys_pka_defs_hw.h" -#include "ssi_pal_compiler.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/************************ Defines ******************************/ - -#define CRYS_PKA_DOMAIN_LLF_BUFF_SIZE_IN_WORDS (10 + 3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS) - -/* The type defines integer array of lengths of maximum lengths of EC modulus */ -typedef uint32_t CRYS_ECPKI_ARRAY_t[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - -/************************************************************************************** - * Enumerators - ***************************************************************************************/ - -/*------------------------------------------------------------------*/ -/*! Enumerator for the EC Domain idetifier - References: [13] - SEC 2: Recommended elliptic curve domain parameters. - Version 1.0. Certicom 2000. - [8] - WAP-261-WTLS-20010406-a, Version 06-April-2001. */ - -typedef enum -{ - /* For prime field */ - CRYS_ECPKI_DomainID_secp160k1, /*!< EC secp160r1 */ - CRYS_ECPKI_DomainID_secp160r1, /*!< EC secp160k1 */ - CRYS_ECPKI_DomainID_secp160r2, /*!< EC secp160r2 */ - CRYS_ECPKI_DomainID_secp192k1, /*!< EC secp192k1 */ - CRYS_ECPKI_DomainID_secp192r1, /*!< EC secp192r1 */ - CRYS_ECPKI_DomainID_secp224k1, /*!< EC secp224k1 */ - CRYS_ECPKI_DomainID_secp224r1, /*!< EC secp224r1 */ - CRYS_ECPKI_DomainID_secp256k1, /*!< EC secp256k1 */ - CRYS_ECPKI_DomainID_secp256r1, /*!< EC secp256r1 */ - CRYS_ECPKI_DomainID_secp384r1, /*!< EC secp384r1 */ - CRYS_ECPKI_DomainID_secp521r1, /*!< EC secp521r1 */ - - CRYS_ECPKI_DomainID_Builded, /*!< User given, not identified. */ - CRYS_ECPKI_DomainID_OffMode, - - CRYS_ECPKI_DomainIDLast = 0x7FFFFFFF, - -}CRYS_ECPKI_DomainID_t; - - -/*------------------------------------------------------------------*/ -/*! Defines the enum for the HASH operation mode. - * The enumerator defines 6 HASH modes according to IEEE 1363. - * - */ -typedef enum -{ - CRYS_ECPKI_HASH_SHA1_mode = 0, /*!< HASH SHA1 mode. */ - CRYS_ECPKI_HASH_SHA224_mode = 1, /*!< HASH SHA224 mode. */ - CRYS_ECPKI_HASH_SHA256_mode = 2, /*!< HASH SHA256 mode. */ - CRYS_ECPKI_HASH_SHA384_mode = 3, /*!< HASH SHA384 mode. */ - CRYS_ECPKI_HASH_SHA512_mode = 4, /*!< HASH SHA512 mode. */ - - CRYS_ECPKI_AFTER_HASH_SHA1_mode = 5, /*!< After HASH SHA1 mode (message was already hashed). */ - CRYS_ECPKI_AFTER_HASH_SHA224_mode = 6, /*!< After HASH SHA224 mode (message was already hashed). */ - CRYS_ECPKI_AFTER_HASH_SHA256_mode = 7, /*!< After HASH SHA256 mode (message was already hashed). */ - CRYS_ECPKI_AFTER_HASH_SHA384_mode = 8, /*!< After HASH SHA384 mode (message was already hashed). */ - CRYS_ECPKI_AFTER_HASH_SHA512_mode = 9, /*!< After HASH SHA512 mode (message was already hashed). */ - - - CRYS_ECPKI_HASH_NumOfModes, - CRYS_ECPKI_HASH_OpModeLast = 0x7FFFFFFF, - -}CRYS_ECPKI_HASH_OpMode_t; - - -/*---------------------------------------------------*/ -/*! Enumerator for the EC point compression idetifier. */ -typedef enum -{ - CRYS_EC_PointCompressed = 2, - CRYS_EC_PointUncompressed = 4, - CRYS_EC_PointContWrong = 5, /* wrong Point Control value */ - CRYS_EC_PointHybrid = 6, - - CRYS_EC_PointCompresOffMode = 8, - - CRYS_ECPKI_PointCompressionLast= 0x7FFFFFFF, - -}CRYS_ECPKI_PointCompression_t; - -/*----------------------------------------------------*/ -/* Enumerator for compatibility of the DHC - with cofactor multiplication to DH ordinary */ -typedef enum -{ - CRYS_ECPKI_SVDP_DHC_CompatibleDH = 0, /* Requested compatiblity of SVDP_DHC with cofactor to SVDP_DH */ - CRYS_ECPKI_SVDP_DHC_NonCompatibleDH = 1, /* Compatiblity of SVDP_DHC with cofactor to SVDP_DH is not requested */ - - CRYS_ECPKI_SVDP_DHC_OffMode, - - CRYS_ECPKI_SVDP_DHC_OpModeLast = 0x7FFFFFFF, - -}CRYS_ECPKI_SVDP_DHC_OpMode_t; - -/*----------------------------------------------------*/ -/* Enumerator for indication what checking of EC public key must be performed */ -typedef enum { - CheckPointersAndSizesOnly = 0, /* Only preliminary input parameters checking */ - ECpublKeyPartlyCheck = 1, /* In addition check that EC PubKey is point on curve */ - ECpublKeyFullCheck = 2, /* In addition check that EC_GeneratorOrder*PubKey = O */ - - PublKeyChecingOffMode, - EC_PublKeyCheckModeLast = 0x7FFFFFFF, -}EC_PublKeyCheckMode_t; - -/*----------------------------------------------------*/ -/* This SCAP is related to included SCA_PROTECTION measures in * -* SW part of algoritthms but not in HW itself */ -typedef enum { - SCAP_Inactive, - SCAP_Active, - SCAP_OFF_MODE, - SCAP_LAST = 0x7FFFFFFF -} CRYS_ECPKI_ScaProtection_t; - - -/************************************************************************************** - * EC Domain structure definition - ***************************************************************************************/ - -/*! The structure containing the EC domain parameters in little-endian form - EC equation: Y^2 = X^3 + A*X + B over prime fild GFp. */ -typedef struct { - - /*! EC modulus: P. */ - uint32_t ecP [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - /*! EC equation parameters a, b. */ - uint32_t ecA [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - uint32_t ecB [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - /*! Order of generator. */ - uint32_t ecR [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1]; - /*! EC cofactor EC_Cofactor_K - Generator (EC base point) coordinates in projective form. */ - uint32_t ecGx [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - uint32_t ecGy [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - uint32_t ecH; - /*! include the specific fields that are used by the low level.*/ - uint32_t llfBuff[CRYS_PKA_DOMAIN_LLF_BUFF_SIZE_IN_WORDS]; - /*! Size of fields in bits. */ - uint32_t modSizeInBits; - uint32_t ordSizeInBits; - /*! Size of each inserted Barret tag in words; 0 - if not inserted.*/ - uint32_t barrTagSizeInWords; - /*! EC Domain identifier.*/ - CRYS_ECPKI_DomainID_t DomainID; - int8_t name[20]; - -} CRYS_ECPKI_Domain_t; - - - -/************************************************************************************** - * EC point structures definitions - ***************************************************************************************/ - -/*! The structure containing the EC point in affine coordinates - and little endian form. */ -typedef struct -{ - /*! Point coordinates. */ - uint32_t x[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - uint32_t y[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - -}CRYS_ECPKI_PointAffine_t; - - -/************************************************************************************** - * ECPKI public and private key Structures - ***************************************************************************************/ - -/* --------------------------------------------------------------------- */ -/* .................. The public key structures definitions ............ */ -/* --------------------------------------------------------------------- */ - -/*! The structure containing the Public Key in affine coordinates.*/ - -/* Size = 2*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1 + - ( sizeof(LLF_ECPKI_publ_key_db_def.h) = 0 ). */ - -typedef struct -{ - /*! Public Key coordinates. */ - uint32_t x[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - uint32_t y[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; - CRYS_ECPKI_Domain_t domain; - uint32_t pointType; -} CRYS_ECPKI_PublKey_t; - - -/*! The user structure containing EC public key data base form.*/ - -/* Size = 2*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 2 + - ( sizeof(LLF_ECPKI_publ_key_db_def.h) = 0 ). */ - -typedef struct CRYS_ECPKI_UserPublKey_t -{ - uint32_t valid_tag; - uint32_t PublKeyDbBuff[(sizeof(CRYS_ECPKI_PublKey_t)+3)/4]; - -} CRYS_ECPKI_UserPublKey_t; - - -/* --------------------------------------------------------------------- */ -/* .................. The private key structures definitions ........... */ -/* --------------------------------------------------------------------- */ - -/*! The EC private key structure in little endian form.*/ - -/* Size = CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 2 + - ( sizeof(LLF_ECPKI_priv_key_db_def.h) = 0 ). */ -typedef struct -{ - /*! Private Key data. */ - uint32_t PrivKey[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1]; - CRYS_ECPKI_Domain_t domain; - CRYS_ECPKI_ScaProtection_t scaProtection; - -}CRYS_ECPKI_PrivKey_t; - - -/*! The user structure containing EC private key data base in little endian form. */ - -/* Size = CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 3 + - ( sizeof(LLF_ECPKI_priv_key_db_def.h) = 0 ) */ -typedef struct CRYS_ECPKI_UserPrivKey_t -{ - uint32_t valid_tag; - uint32_t PrivKeyDbBuff[(sizeof(CRYS_ECPKI_PrivKey_t)+3)/4]; - -} CRYS_ECPKI_UserPrivKey_t; - -/*! The ECDH temporary data type */ -typedef struct CRYS_ECDH_TempData_t -{ - uint32_t crysEcdhIntBuff[CRYS_PKA_ECDH_BUFF_MAX_LENGTH_IN_WORDS]; -}CRYS_ECDH_TempData_t; - -typedef struct CRYS_ECPKI_BUILD_TempData_t -{ - uint32_t crysBuildTmpIntBuff[CRYS_PKA_ECPKI_BUILD_TMP_BUFF_MAX_LENGTH_IN_WORDS]; -}CRYS_ECPKI_BUILD_TempData_t; - - - -/************************************************************************** - * CRYS ECDSA context structures - **************************************************************************/ - -/* --------------------------------------------------------------------- */ -/* CRYS ECDSA Signing context structure */ -/* --------------------------------------------------------------------- */ - -typedef uint32_t CRYS_ECDSA_SignIntBuff[CRYS_PKA_ECDSA_SIGN_BUFF_MAX_LENGTH_IN_WORDS]; -typedef struct -{ - /* A user's buffer for the Private Key Object -*/ - CRYS_ECPKI_UserPrivKey_t ECDSA_SignerPrivKey; - - /*HASH specific data and buffers */ - uint32_t hashUserCtxBuff[sizeof(CRYS_HASHUserContext_t)]; - CRYS_HASH_Result_t hashResult; - uint32_t hashResultSizeWords; - CRYS_ECPKI_HASH_OpMode_t hashMode; - - CRYS_ECDSA_SignIntBuff crysEcdsaSignIntBuff; -}ECDSA_SignContext_t; - - -/* --------------------------------------------------------------------- */ -/* CRYS ECDSA Signing User context database */ -/* --------------------------------------------------------------------- */ - - -typedef struct CRYS_ECDSA_SignUserContext_t -{ - uint32_t context_buff [(sizeof(ECDSA_SignContext_t)+3)/4]; - uint32_t valid_tag; -} CRYS_ECDSA_SignUserContext_t; - - - -/****************************************************************************/ - -/* --------------------------------------------------------------------- */ -/* CRYS ECDSA Verifying context structure */ -/* --------------------------------------------------------------------- */ - -typedef uint32_t CRYS_ECDSA_VerifyIntBuff[CRYS_PKA_ECDSA_VERIFY_BUFF_MAX_LENGTH_IN_WORDS]; - -typedef struct -{ - /* A user's buffer for the Private Key Object -*/ - CRYS_ECPKI_UserPublKey_t ECDSA_SignerPublKey; - - /*HASH specific data and buffers */ - uint32_t hashUserCtxBuff[sizeof(CRYS_HASHUserContext_t)]; - CRYS_HASH_Result_t hashResult; - uint32_t hashResultSizeWords; - CRYS_ECPKI_HASH_OpMode_t hashMode; - - CRYS_ECDSA_VerifyIntBuff crysEcdsaVerIntBuff; - -}ECDSA_VerifyContext_t; - - -/* --------------------------------------------------------------------- */ -/* CRYS ECDSA Verifying User context database */ -/* --------------------------------------------------------------------- */ - -typedef struct CRYS_ECDSA_VerifyUserContext_t -{ - uint32_t context_buff[(sizeof(ECDSA_VerifyContext_t)+3)/4]; - uint32_t valid_tag; -}CRYS_ECDSA_VerifyUserContext_t; - - - - -/* --------------------------------------------------------------------- */ -/* .................. key generation temp buffer ........... */ -/* --------------------------------------------------------------------- */ - -/*! The ECPKI KG temporary data type */ -typedef struct CRYS_ECPKI_KG_TempData_t -{ - uint32_t crysKGIntBuff[CRYS_PKA_KG_BUFF_MAX_LENGTH_IN_WORDS]; -}CRYS_ECPKI_KG_TempData_t; - - -typedef struct CRYS_ECIES_TempData_t { - - CRYS_ECPKI_UserPrivKey_t PrivKey; - CRYS_ECPKI_UserPublKey_t PublKey; - uint32_t zz[3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1]; - union { - CRYS_ECPKI_BUILD_TempData_t buildTempbuff; - CRYS_ECPKI_KG_TempData_t KgTempBuff; - CRYS_ECDH_TempData_t DhTempBuff; - } tmp; - -}CRYS_ECIES_TempData_t; - - -/* --------------------------------------------------------------------- */ -/* .................. defines for FIPS ........... */ -/* --------------------------------------------------------------------- */ - -#define CRYS_ECPKI_FIPS_ORDER_LENGTH (256/SASI_BITS_IN_BYTE) // the order of secp256r1 in bytes - -/*! Required for internal FIPS verification for ECPKI key generation. */ -typedef struct CRYS_ECPKI_KG_FipsContext_t -{ - union { - CRYS_ECDSA_SignUserContext_t signCtx; - CRYS_ECDSA_VerifyUserContext_t verifyCtx; - }operationCtx; - uint32_t signBuff[2*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS]; -}CRYS_ECPKI_KG_FipsContext_t; - - - -/*! Required for internal FIPS verification for ECDSA KAT. * -* The ECDSA KAT tests defined for domain 256r1. */ -typedef struct CRYS_ECDSAFipsKatContext_t{ - union { - struct { - CRYS_ECPKI_UserPrivKey_t PrivKey; - CRYS_ECDSA_SignUserContext_t signCtx; - }userSignData; - struct { - CRYS_ECPKI_UserPublKey_t PublKey; - union { - CRYS_ECDSA_VerifyUserContext_t verifyCtx; - CRYS_ECPKI_BUILD_TempData_t tempData; - }buildOrVerify; - }userVerifyData; - }keyContextData; - - uint8_t signBuff[2*CRYS_ECPKI_FIPS_ORDER_LENGTH]; -}CRYS_ECDSAFipsKatContext_t; - -/*! Required for internal FIPS verification for ECDH KAT. */ -typedef struct CRYS_ECDHFipsKatContext_t{ - CRYS_ECPKI_UserPublKey_t pubKey; - CRYS_ECPKI_UserPrivKey_t privKey; - union { - CRYS_ECPKI_BUILD_TempData_t ecpkiTempData; - CRYS_ECDH_TempData_t ecdhTempBuff; - }tmpData; - uint8_t secretBuff[CRYS_ECPKI_FIPS_ORDER_LENGTH]; -}CRYS_ECDHFipsKatContext_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_defs.h deleted file mode 100644 index b8e1bd6..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_defs.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_HASH_DEFS_H -#define CRYS_HASH_DEFS_H - -/*! -@file -@brief This file contains HASH definitions. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/************************ Defines ******************************/ - -/*! The size of user's context prototype (see CRYS_HASHUserContext_t) in words. */ -#define CRYS_HASH_USER_CTX_SIZE_IN_WORDS 60 - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_error.h deleted file mode 100644 index ee00dfe..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash_error.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef CRYS_HASH_ERROR_H -#define CRYS_HASH_ERROR_H - - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS HASH errors. -*/ - - - - -/************************ Defines ******************************/ -/*HASH module on the CRYS layer base address - 0x00F00200*/ -/* The CRYS HASH module errors */ -#define CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x2UL) -#define CRYS_HASH_DATA_IN_POINTER_INVALID_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x3UL) -#define CRYS_HASH_DATA_SIZE_ILLEGAL (CRYS_HASH_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_HASH_DATA_SIZE_IS_ILLEGAL_FOR_CSI_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x8UL) -#define CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xCUL) -#define CRYS_HASH_ILLEGAL_PARAMS_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xDUL) - -#define CRYS_HASH_CTX_SIZES_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xEUL) - -#define CRYS_HASH_IS_NOT_SUPPORTED (CRYS_HASH_MODULE_ERROR_BASE + 0xFUL) - - - -/************************ Enums ********************************/ - - -/************************ Typedefs ****************************/ - - -/************************ Structs ******************************/ - - -/************************ Public Variables **********************/ - - -/************************ Public Functions **********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf.h deleted file mode 100644 index 5381f35..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_HKDF_H -#define CRYS_HKDF_H - -#include "crys_hash.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module defines the API that supports HMAC Key derivation function as defined by RFC5869. -*/ - -#define CRYS_HKDF_MAX_HASH_KEY_SIZE_IN_BYTES 512 - - -#define CRYS_HKDF_MAX_HASH_DIGEST_SIZE_IN_BYTES CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES - -/************************ Defines ******************************/ - -/************************ Enums ********************************/ - -typedef enum -{ - CRYS_HKDF_HASH_SHA1_mode = 0, - CRYS_HKDF_HASH_SHA224_mode = 1, - CRYS_HKDF_HASH_SHA256_mode = 2, - CRYS_HKDF_HASH_SHA384_mode = 3, - CRYS_HKDF_HASH_SHA512_mode = 4, - - CRYS_HKDF_HASH_NumOfModes, - - CRYS_HKDF_HASH_OpModeLast = 0x7FFFFFFF, - -}CRYS_HKDF_HASH_OpMode_t; - -/************************ Typedefs ****************************/ - -/************************ Structs ******************************/ - -/************************ Public Variables **********************/ - -/************************ Public Functions **********************/ - -/****************************************************************/ - - -/*********************************************************************************************************/ -/** - * @brief CRYS_HKDF_KeyDerivFunc performs the HMAC-based key derivation, according to RFC5869 - - @return CRYSError_t - On success the value CRYS_OK is returned, - and on failure an ERROR as defined in CRYS_KDF_error.h: - CRYS_HKDF_INVALID_ARGUMENT_POINTER_ERROR - CRYS_HKDF_INVALID_ARGUMENT_SIZE_ERROR - CRYS_HKDF_INVALID_ARGUMENT_HASH_MODE_ERROR -*/ -CEXPORT_C CRYSError_t CRYS_HKDF_KeyDerivFunc( - CRYS_HKDF_HASH_OpMode_t HKDFhashMode, /*!< [in] The HKDF identifier of hash function to be used. */ - uint8_t* Salt_ptr, /*!< [in] A pointer to a non secret random value. can be NULL. */ - size_t SaltLen, /*!< [in] The size of the salt_ptr. */ - uint8_t* Ikm_ptr, /*!< [in] A pointer to a input key message. */ - uint32_t IkmLen, /*!< [in] The size of the input key message */ - uint8_t* Info, /*!< [in] A pointer to an optional context and application specific information. can be NULL */ - uint32_t InfoLen, /*!< [in] The size of the info. */ - uint8_t* Okm, /*!< [in] A pointer to a output key material. */ - uint32_t OkmLen, /*!< [in] The size of the output key material. */ - SaSiBool IsStrongKey /*!< [in] if TRUE , then no need to perform the extraction phase. */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf_error.h deleted file mode 100644 index af78574..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hkdf_error.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_HKDF_ERROR_H -#define CRYS_HKDF_ERROR_H - -#include "crys_error.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS HKDF errors. - */ - - -/************************ Defines *******************************/ - -/* The CRYS KDF module errors / base address - 0x00F01100*/ -#define CRYS_HKDF_INVALID_ARGUMENT_POINTER_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_HKDF_INVALID_ARGUMENT_SIZE_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_HKDF_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x3UL) -#define CRYS_HKDF_IS_NOT_SUPPORTED (CRYS_HKDF_MODULE_ERROR_BASE + 0xFFUL) - -/************************ Enums *********************************/ - -/************************ Typedefs *****************************/ - -/************************ Structs ******************************/ - -/************************ Public Variables **********************/ - -/************************ Public Functions **********************/ - - - - -#ifdef __cplusplus -} -#endif - -#endif - - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_defs.h deleted file mode 100644 index 6b3c0aa..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_defs.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_HMAC_DEFS_H -#define CRYS_HMAC_DEFS_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/************************ Defines ******************************/ -#define CRYS_HMAC_USER_CTX_SIZE_IN_WORDS 94 - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_error.h deleted file mode 100644 index 7206f68..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac_error.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_HMAC_ERROR_H -#define CRYS_HMAC_ERROR_H - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! @file -* @brief This module contains the definitions of the CRYS HMAC errors. -* -*/ - - - -/************************ Defines ******************************/ - -/* The CRYS HASH module errors */ -#define CRYS_HMAC_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_HMAC_ILLEGAL_OPERATION_MODE_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_HMAC_USER_CONTEXT_CORRUPTED_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x2UL) -#define CRYS_HMAC_DATA_IN_POINTER_INVALID_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x3UL) -#define CRYS_HMAC_DATA_SIZE_ILLEGAL (CRYS_HMAC_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_HMAC_INVALID_RESULT_BUFFER_POINTER_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_HMAC_INVALID_KEY_POINTER_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x6UL) -#define CRYS_HMAC_UNVALID_KEY_SIZE_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x7UL) -#define CRYS_HMAC_LAST_BLOCK_ALREADY_PROCESSED_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0xBUL) -#define CRYS_HMAC_ILLEGAL_PARAMS_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0xCUL) - -#define CRYS_HMAC_CTX_SIZES_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0xEUL) - -#define CRYS_HMAC_IS_NOT_SUPPORTED (CRYS_HMAC_MODULE_ERROR_BASE + 0xFUL) - - - -/************************ Enums ********************************/ - - -/************************ Typedefs ****************************/ - - -/************************ Structs ******************************/ - - -/************************ Public Variables **********************/ - - -/************************ Public Functions **********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf.h deleted file mode 100644 index bb2b542..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf.h +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_KDF_H -#define CRYS_KDF_H - - -#include "crys_hash.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module defines the API that supports Key derivation function in modes -as defined in PKCS#3, ANSI X9.42-2001, and ANSI X9.63-1999. -*/ - -#include "crys_hash.h" - -/************************ Defines ******************************/ - -/* Shared secret value max size in bytes: must be defined according to * -* DH max. modulus size definition! */ -#define CRYS_KDF_MAX_SIZE_OF_SHARED_SECRET_VALUE 1024 /*!< Size is in bytes*/ - -/* Count and max. sizeof OtherInfo entries (pointers to data buffers) */ -#define CRYS_KDF_COUNT_OF_OTHER_INFO_ENTRIES 5 -#define CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY 64 /*!< Size is in bytes*/ -/* Max size of keying data in bytes to generate */ -#define CRYS_KDF_MAX_SIZE_OF_KEYING_DATA 2048 - -/************************ Enums ********************************/ - -typedef enum -{ - CRYS_KDF_HASH_SHA1_mode = 0, - CRYS_KDF_HASH_SHA224_mode = 1, - CRYS_KDF_HASH_SHA256_mode = 2, - CRYS_KDF_HASH_SHA384_mode = 3, - CRYS_KDF_HASH_SHA512_mode = 4, - - CRYS_KDF_HASH_NumOfModes, - - CRYS_KDF_HASH_OpModeLast = 0x7FFFFFFF, - -}CRYS_KDF_HASH_OpMode_t; - -typedef enum -{ - CRYS_KDF_ASN1_DerivMode = 0, - CRYS_KDF_ConcatDerivMode = 1, - CRYS_KDF_X963_DerivMode = CRYS_KDF_ConcatDerivMode, - CRYS_KDF_ISO18033_KDF1_DerivMode = 3, - CRYS_KDF_ISO18033_KDF2_DerivMode = 4, - - CRYS_KDF_DerivFunc_NumOfModes = 5, - - CRYS_KDF_DerivFuncModeLast= 0x7FFFFFFF, - -}CRYS_KDF_DerivFuncMode_t; - -/************************ Typedefs ****************************/ - -/* Structure, containing the optional data for KDF, - if any data is not needed, then the pointer value and - the size must be set to NULL */ -typedef struct -{ - /* a unique object identifier (OID), indicating algorithm(s) - for which the keying data is used*/ - uint8_t AlgorithmID[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; - uint32_t SizeOfAlgorithmID; - /* Public information contributed by the initiator */ - uint8_t PartyUInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; - uint32_t SizeOfPartyUInfo; - /* Public information contributed by the responder */ - uint8_t PartyVInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; - uint32_t SizeOfPartyVInfo; - /* Mutually-known private information, e.g. shared information - communicated throgh a separate channel */ - uint8_t SuppPrivInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; - uint32_t SizeOfSuppPrivInfo; - /* Mutually-known public information, */ - uint8_t SuppPubInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; - uint32_t SizeOfSuppPubInfo; - -}CRYS_KDF_OtherInfo_t; - -/************************ Structs ******************************/ - -/************************ Public Variables **********************/ - -/************************ Public Functions **********************/ - -/****************************************************************/ - - -/*********************************************************************************************************/ -/*! - @brief CRYS_KDF_KeyDerivFunc performs key derivation according to one of the modes defined in standards: - ANS X9.42-2001, ANS X9.63, ISO/IEC 18033-2. - -The present implementation of the function allows the following operation modes: -
    • CRYS_KDF_ASN1_DerivMode - mode based on ASN.1 DER encoding;
    • -
    • CRYS_KDF_ConcatDerivMode - mode based on concatenation;
    • -
    • CRYS_KDF_X963_DerivMode = CRYS_KDF_ConcatDerivMode;
    • -
    • CRYS_KDF_ISO18033_KDF1_DerivMode - specific mode according to ECIES-KEM algorithm (ISO/IEC 18033-2).
    - -The purpose of this function is to derive a keying data from the shared secret value and some -other optional shared information (SharedInfo). - -\note -
    • The length in Bytes of the hash result buffer is denoted by "hashlen".
    • -
    • All buffers arguments are represented in Big-Endian format.
    • - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_kdf_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_KDF_KeyDerivFunc( - uint8_t *ZZSecret_ptr, /*!< [in] A pointer to shared secret value octet string. */ - uint32_t ZZSecretSize, /*!< [in] The size of the shared secret value in bytes. - The maximal size is defined as: CRYS_KDF_MAX_SIZE_OF_SHARED_SECRET_VALUE. */ - CRYS_KDF_OtherInfo_t *OtherInfo_ptr, /*!< [in] The pointer to structure, containing the data, shared by two entities of - agreement and the data sizes. This argument may be optional in several modes - (if it is not needed - set NULL). - On two ISO/IEC 18033-2 modes - set NULL. - On KDF ASN1 mode the OtherInfo and its AlgorithmID entry are mandatory. */ - CRYS_KDF_HASH_OpMode_t KDFhashMode, /*!< [in] The KDF identifier of hash function to be used. The hash function output - must be at least 160 bits. */ - CRYS_KDF_DerivFuncMode_t derivation_mode, /*!< [in] Specifies one of above described derivation modes. */ - uint8_t *KeyingData_ptr, /*!< [out] A pointer to the buffer for derived keying data. */ - uint32_t KeyingDataSizeBytes /*!< [in] The size in bytes of the keying data to be derived. - The maximal size is defined as: CRYS_KDF_MAX_SIZE_OF_KEYING_DATA. */ -); - -/* alias for backward compatibility */ -#define _DX_KDF_KeyDerivFunc CRYS_KDF_KeyDerivFunc - -/*********************************************************************************************************/ -/*! - CRYS_KDF_ASN1_KeyDerivFunc is A MACRO that performs key derivation according to ASN1 DER encoding method defined - in standard ANS X9.42-2001, 7.2.1. For a description of the parameters see ::CRYS_KDF_KeyDerivFunc. -*/ -#define CRYS_KDF_ASN1_KeyDerivFunc(ZZSecret_ptr,ZZSecretSize,OtherInfo_ptr,KDFhashMode,KeyingData_ptr,KeyLenInBytes)\ - CRYS_KDF_KeyDerivFunc((ZZSecret_ptr),(ZZSecretSize),(OtherInfo_ptr),(KDFhashMode),CRYS_KDF_ASN1_DerivMode,(KeyingData_ptr),(KeyLenInBytes)) - - -/*********************************************************************************************************/ -/*! - CRYS_KDF_ConcatKeyDerivFunc is a MACRO that performs key derivation according to concatenation mode defined - in standard ANS X9.42-2001, 7.2.2. For a description of the parameters see - ::CRYS_KDF_KeyDerivFunc. -*/ -#define CRYS_KDF_ConcatKeyDerivFunc(ZZSecret_ptr,ZZSecretSize,OtherInfo_ptr,KDFhashMode,KeyingData_ptr,KeyLenInBytes)\ - CRYS_KDF_KeyDerivFunc((ZZSecret_ptr),(ZZSecretSize),(OtherInfo_ptr),(KDFhashMode),CRYS_KDF_ConcatDerivMode,(KeyingData_ptr),(KeyLenInBytes)) - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf_error.h deleted file mode 100644 index 363b845..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_kdf_error.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_KDF_ERROR_H -#define CRYS_KDF_ERROR_H - -#include "crys_error.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS KDF errors. - */ - - -/************************ Defines *******************************/ - -/* The CRYS KDF module errors / base address - 0x00F01100*/ -#define CRYS_KDF_INVALID_ARGUMENT_POINTER_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_KDF_INVALID_ARGUMENT_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_KDF_INVALID_ARGUMENT_OPERATION_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x2UL) -#define CRYS_KDF_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x3UL) -#define CRYS_KDF_INVALID_KEY_DERIVATION_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_KDF_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_KDF_INVALID_OTHER_INFO_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x6UL) -#define CRYS_KDF_INVALID_KEYING_DATA_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x7UL) -#define CRYS_KDF_INVALID_ALGORITHM_ID_POINTER_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x8UL) -#define CRYS_KDF_INVALID_ALGORITHM_ID_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x9UL) - -#define CRYS_KDF_HOST_MSG_GENERAL_RPC_A_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0xAUL) -#define CRYS_KDF_HOST_MSG_GENERAL_RPC_B_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0xBUL) -#define CRYS_KDF_HOST_MSG_GENERAL_RPC_C_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0xCUL) - -#define CRYS_KDF_IS_NOT_SUPPORTED (CRYS_KDF_MODULE_ERROR_BASE + 0xFFUL) - -/************************ Enums *********************************/ - -/************************ Typedefs *****************************/ - -/************************ Structs ******************************/ - -/************************ Public Variables **********************/ - -/************************ Public Functions **********************/ - - - - -#ifdef __cplusplus -} -#endif - -#endif - - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_pka_defs_hw.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_pka_defs_hw.h deleted file mode 100644 index 8a81da0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_pka_defs_hw.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _CRYS_PKA_DEFS_HW_H_ -#define _CRYS_PKA_DEFS_HW_H_ - -#include "ssi_pal_types.h" -#include "ssi_pka_hw_plat_defs.h" - -/*! -@file -@brief The file contains all of the enums and definitions that are used in the PKA related code. -*/ - - -/* The valid key sizes in bits for RSA primitives (exponentiation) */ -#define CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS ((CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS + SASI_PKA_WORD_SIZE_IN_BITS) / SASI_BITS_IN_32BIT_WORD ) -#define CRYS_ECPKI_MODUL_MAX_LENGTH_IN_BITS 521 - -/*! size of buffers for Barrett modulus tag NP, used in PKI algorithms. */ -#define CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS 5 -#define CRYS_PKA_ECPKI_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS - -#define CRYS_PKA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS - -#define CRYS_PKA_PUB_KEY_BUFF_SIZE_IN_WORDS (2*CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS) - -#define CRYS_PKA_PRIV_KEY_BUFF_SIZE_IN_WORDS (2*CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS) - -#define CRYS_PKA_KGDATA_BUFF_SIZE_IN_WORDS (3*CRYS_PKA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS) - - -/*! The valid maximum EC modulus size in 32-bit words. */ -#define CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS 18 /*!< \internal [(CRYS_ECPKI_MODUL_MAX_LENGTH_IN_BITS + 31)/(sizeof(uint32_t)) + 1] */ -#define CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS (CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1) - -#define CRYS_PKA_DOMAIN_BUFF_SIZE_IN_WORDS (2*CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS) - -#define CRYS_PKA_EL_GAMAL_BUFF_MAX_LENGTH_IN_WORDS (4*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 4) - -/* ECC NAF buffer definitions */ -#define COUNT_NAF_WORDS_PER_KEY_WORD 8 /*!< \internal Change according to NAF representation (? 2)*/ -#define CRYS_PKA_ECDSA_NAF_BUFF_MAX_LENGTH_IN_WORDS (COUNT_NAF_WORDS_PER_KEY_WORD*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS + 1) - -#ifndef SSI_SUPPORT_ECC_SCA_SW_PROTECT -/* on fast SCA non protected mode required additional buffers for NAF key */ -#define CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS (CRYS_PKA_ECDSA_NAF_BUFF_MAX_LENGTH_IN_WORDS+CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS+2) -#else -#define CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS 1 /*(4*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS)*/ -#endif - -#define CRYS_PKA_ECPKI_BUILD_TMP_BUFF_MAX_LENGTH_IN_WORDS (3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS+CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) - -#define CRYS_PKA_ECDSA_SIGN_BUFF_MAX_LENGTH_IN_WORDS (6*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS+CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) - -#define CRYS_PKA_ECDH_BUFF_MAX_LENGTH_IN_WORDS (2*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS + CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) - -#define CRYS_PKA_KG_BUFF_MAX_LENGTH_IN_WORDS (2*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS + CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) - -#define CRYS_PKA_ECDSA_VERIFY_BUFF_MAX_LENGTH_IN_WORDS (3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS) - -/* *************************************************************************** */ -/*! Definitions of maximal size of modulus buffers for CRYS_EC_MONT and EC_EDW */ -#define CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_BYTES 32U /*!< \internal for Curve25519 */ -#define CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS 8U /*!< \internal for Curve25519 */ - -#define CRYS_EC_MONT_TEMP_BUFF_SIZE_IN_32BIT_WORDS (8 * CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS) - -#define CRYS_EC_EDW_TEMP_BUFF_SIZE_IN_32BIT_WORD \ - (8*CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS + \ - (sizeof(CRYS_HASHUserContext_t)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE) - -#endif /*_CRYS_PKA_DEFS_HW_H_*/ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_poly.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_poly.h deleted file mode 100644 index c4d734e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_poly.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains all of the enums and definitions that are used for the - CRYS POLY APIs, as well as the APIs themselves. -*/ -#ifndef CRYS_POLY_H -#define CRYS_POLY_H - - -#include "ssi_pal_types.h" -#include "crys_error.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/************************ Defines ******************************/ -/*! The POLY KEY size in bytes. */ -#define CRYS_POLY_KEY_SIZE_IN_WORDS 8 -#define CRYS_POLY_KEY_SIZE_IN_BYTES (CRYS_POLY_KEY_SIZE_IN_WORDS*SASI_32BIT_WORD_SIZE) - -/*! The POLY MAC size in bytes. */ -#define CRYS_POLY_MAC_SIZE_IN_WORDS 4 -#define CRYS_POLY_MAC_SIZE_IN_BYTES (CRYS_POLY_MAC_SIZE_IN_WORDS*SASI_32BIT_WORD_SIZE) - -/************************ Typedefs ****************************/ - -/*! Defines the CHACHA key buffer. */ -typedef uint32_t CRYS_POLY_Mac_t[CRYS_POLY_MAC_SIZE_IN_WORDS]; - -/*! Defines the CHACHA key buffer. */ -typedef uint32_t CRYS_POLY_Key_t[CRYS_POLY_KEY_SIZE_IN_WORDS]; - -/************************ Public Functions **********************/ - -/****************************************************************************************************/ -/*! -@brief This function is used to perform the POLY MAC Calculation. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_poly_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_POLY( - CRYS_POLY_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ - uint8_t *pDataIn, /*!< [in] A pointer to the buffer of the input data to the CHACHA. - must not be null. */ - size_t dataInSize, /*!< [in] The size of the input data. must not be 0. */ - CRYS_POLY_Mac_t macRes /*!< [in/out] Pointer to the MAC result buffer.*/ -); - - - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef CRYS_POLY_H */ - - - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd.h deleted file mode 100644 index b072920..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd.h +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef CRYS_RND_H -#define CRYS_RND_H - -#include "crys_error.h" -#include "ssi_aes.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This file contains the CRYS APIs used for random number generation. -The random-number generation module implements referenced standard [SP800-90]. -*/ - -/************************ Defines ******************************/ - -/*! Maximal reseed counter - indicates maximal number of -requests allowed between reseeds; according to NIST 800-90 -it is (2^48 - 1), our restriction is : (0xFFFFFFFF - 0xF).*/ -#define CRYS_RND_MAX_RESEED_COUNTER (0xFFFFFFFF - 0xF) - -/* maximal requested size counter (12 bits active) - maximal count -of generated random 128 bit blocks allowed per one request of -Generate function according NIST 800-90 it is (2^12 - 1) = 0x3FFFF */ -#define CRYS_RND_REQUESTED_SIZE_COUNTER 0x3FFFF - -/*! AES output block size in words. */ -#define CRYS_RND_AES_BLOCK_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS - - -/* RND seed and additional input sizes */ -#define CRYS_RND_SEED_MAX_SIZE_WORDS 12 -#ifndef CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS -#define CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS CRYS_RND_SEED_MAX_SIZE_WORDS -#endif - -/* Max size of generated random vector in bits according uint16_t type of * -* input size parameter in CRYS_RND_Generate function */ -#define CRYS_RND_MAX_GEN_VECTOR_SIZE_BYTES 0xFFFF - -/* allowed sizes of AES Key, in words */ -#define CRYS_RND_AES_KEY_128_SIZE_WORDS 4 -#define CRYS_RND_AES_KEY_192_SIZE_WORDS 6 -#define CRYS_RND_AES_KEY_256_SIZE_WORDS 8 - -/* Definitions of temp buffer for RND_DMA version of CRYS_RND */ -/*******************************************************************/ -/* Definitions of temp buffer for DMA version of CRYS_RND */ - -#define CRYS_RND_WORK_BUFFER_SIZE_WORDS 1528 - -/*! A definition for RAM buffer to be internally used in instantiation (or reseeding) operation. */ -typedef struct -{ - /* include the specific fields that are used by the low level */ - uint32_t crysRndWorkBuff[CRYS_RND_WORK_BUFFER_SIZE_WORDS]; -}CRYS_RND_WorkBuff_t; - -#define CRYS_RND_EntropyEstimatData_t CRYS_RND_WorkBuff_t -#define crysRndEntrIntBuff crysRndWorkBuff - - -/* RND source buffer inner (entrpopy) offset */ -#define CRYS_RND_TRNG_SRC_INNER_OFFSET_WORDS 2 - - -/* Max size for one RNG operation */ -#define CRYS_RND_MAX_SIZE_OF_OUTPUT_BYTES 3*1024 - -/* Size of the expected output buffer used by FIPS KAT */ -#define CRYS_PRNG_FIPS_KAT_OUT_DATA_SIZE 64 - -/************************ Enumerators ****************************/ - -/* Definition of Fast or Slow mode of random generator (TRNG)*/ -typedef enum -{ - CRYS_RND_Fast = 0, - CRYS_RND_Slow = 1, - CRYS_RND_ModeLast = 0x7FFFFFFF, -} CRYS_RND_mode_t; - - - -/************************ Structs *****************************/ - - -/* The internal state of DRBG mechanism based on AES CTR and CBC-MAC - algorithms. It is set as global data defined by the following - structure */ -typedef struct -{ - /* Seed buffer, consists from concatenated Key||V: max size 12 words */ - uint32_t Seed[CRYS_RND_SEED_MAX_SIZE_WORDS]; - /* Previous value for continuous test */ - uint32_t PreviousRandValue[SASI_AES_BLOCK_SIZE_IN_WORDS]; - - /* AdditionalInput buffer max size = seed max size words + 4w for padding*/ - uint32_t PreviousAdditionalInput[CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS+3]; - uint32_t AdditionalInput[CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS+4]; - uint32_t AddInputSizeWords; /* size of additional data set by user, words */ - - /* entropy source size in words */ - uint32_t EntropySourceSizeWords; - - /* reseed counter (32 bits active) - indicates number of requests for entropy - since instantiation or reseeding */ - uint32_t ReseedCounter; - - /* key size: 4 or 8 words according to security strength 128 bits or 256 bits*/ - uint32_t KeySizeWords; - - /* State flag (see definition of StateFlag above), containing bit-fields, defining: - - b'0: instantiation steps: 0 - not done, 1 - done; - - 2b'9,8: working or testing mode: 0 - working, 1 - KAT DRBG test, 2 - - KAT TRNG test; - b'16: flag defining is Previous random valid or not: - 0 - not valid, 1 - valid */ - uint32_t StateFlag; - - /* Trng processing flag - indicates which ROSC lengths are: - - allowed (bits 0-3); - - total started (bits 8-11); - - processed (bits 16-19); - - started, but not processed (bits24-27) */ - uint32_t TrngProcesState; - - /* validation tag */ - uint32_t ValidTag; - - /* Rnd source entropy size in bits */ - uint32_t EntropySizeBits; - -} CRYS_RND_State_t; - - -/*! The RND Generate vector function pointer type definition. - The prototype intendent for External and CRYS internal RND functions - pointers definitions. - Full description can be found in ::CRYS_RND_GenerateVector function API. */ -typedef uint32_t (*SaSiRndGenerateVectWorkFunc_t)( \ - CRYS_RND_State_t *rndState_ptr, /*context*/ \ - uint16_t outSizeBytes, /*in*/ \ - uint8_t *out_ptr /*out*/); - - -/*! definition of RND context that includes CRYS RND state structure and a function pointer for rnd generate function */ -typedef struct -{ - /* The pointer to internal state of RND */ - CRYS_RND_State_t rndState; - - /* The pointer to user given function for generation random vector */ - SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc; -} CRYS_RND_Context_t; - - -/*! Required for internal FIPS verification for PRNG KAT. */ -typedef struct -{ - CRYS_RND_WorkBuff_t rndWorkBuff; - uint8_t rndOutputBuff[CRYS_PRNG_FIPS_KAT_OUT_DATA_SIZE]; -} CRYS_PrngFipsKatCtx_t; - - -/*****************************************************************************/ -/********************** Public Functions *************************/ -/*****************************************************************************/ - -/*! -@brief This function initializes the RND context. -It must be called at least once prior to using this context with any API that requires it as a parameter (e.g., other RND APIs, asymmetric -cryptography key generation and signatures). -It is called as part of ARM TrustZone CryptoCell library initialization, which initializes and returns the primary RND context. -This primary context can be used as a single global context for all RND needs. -Alternatively, other contexts may be initialized and used with a more limited scope (for specific applications or specific threads). -The call to this function must be followed by a call to ::CRYS_RND_SetGenerateVectorFunc API to set the generate vector function. -It implements referenced standard [SP800-90] - 10.2.1.3.2 - CTR-DRBG Instantiate algorithm using AES (FIPS-PUB 197) and Derivation Function (DF). -\note Additional data can be mixed with the random seed (personalization data or nonce). If required, this data should be provided by calling ::CRYS_RND_AddAdditionalInput prior to using this API. - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_Instantiation( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer allocated by the user, which is used to - maintain the RND state, as well as pointers to the functions used for - random vector generation. This context must be saved and provided as a - parameter to any API that uses the RND module. - \note the context must be cleared before sent to the function. */ - CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in/out] Scratchpad for the RND module's work. */ -); - - -/*! -@brief Clears existing RNG instantiation state. - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_UnInstantiation( - CRYS_RND_Context_t *rndContext_ptr /*!< [in/out] Pointer to the RND context buffer. */ -); - - -/*! -@brief This function is used for reseeding the RNG with additional entropy and additional user-provided input. -(additional data should be provided by calling ::CRYS_RND_AddAdditionalInput prior to using this API). -It implements referenced standard [SP800-90] - 10.2.1.4.2 - CTR-DRBG Reseeding algorithm, using AES (FIPS-PUB 197) and Derivation Function (DF). - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_Reseeding( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in/out] Scratchpad for the RND module's work. */ -); - - -/****************************************************************************************/ -/*! -@brief Generates a random vector according to the algorithm defined in referenced standard [SP800-90] - 10.2.1.5.2 - CTR-DRBG. -The generation algorithm uses AES (FIPS-PUB 197) and Derivation Function (DF). - -\note -
      • The RND module must be instantiated prior to invocation of this API.
      • -
      • In the following cases, Reseeding operation must be performed prior to vector generation:
      • -
        • Prediction resistance is required.
        • -
        • The function returns CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR, stating that the Reseed Counter has passed its upper-limit (2^32-2).
      - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_GenerateVector( - CRYS_RND_State_t *rndState_ptr, /*!< [in/out] Pointer to the RND state structure, which is part of the RND context structure. - Use rndContext->rndState field of the context for this parameter. */ - uint16_t outSizeBytes, /*!< [in] The size in bytes of the random vector required. The maximal size is 2^16 -1 bytes. */ - uint8_t *out_ptr /*!< [out] The pointer to output buffer. */ -); - - -/****************************************************************************************/ -/*! - -@brief This function sets the RND vector generation function into the RND context. - -It must be called after ::CRYS_RND_Instantiation, and prior to any other API that requires the RND context as parameter. -It is called as part of ARM TrustZone CryptoCell library initialization, to set the RND vector generation function into the primary RND context, -after ::CRYS_RND_Instantiation is called. - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CRYSError_t CRYS_RND_SetGenerateVectorFunc( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer allocated by the user, - which is used to maintain the RND state as well as pointers - to the functions used for random vector generation. */ - SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc /*!< [in] Pointer to the random vector generation function. - The pointer should point to the ::CRYS_RND_GenerateVector function. */ -); - - -/**********************************************************************************************************/ -/*! -@brief Generates a random vector with specific limitations by testing candidates (described and used in FIPS 186-4: B.1.2, B.4.2 etc.). - -This function will draw a random vector, compare it to the range limits, and if within range - return it in rndVect_ptr. -If outside the range, the function will continue retrying until a conforming vector is found, or the maximal retries limit is exceeded. -If maxVect_ptr is provided, rndSizeInBits specifies its size, and the output vector must conform to the range [1 < rndVect < maxVect_ptr]. -If maxVect_ptr is NULL, rndSizeInBits specifies the exact required vector size, and the output vector must be the exact same -bit size (with its most significant bit = 1). -\note -The RND module must be instantiated prior to invocation of this API. - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_GenerateVectorInRange( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint32_t rndSizeInBits, /*!< [in] The size in bits of the random vector required. The allowed size in range 2 <= rndSizeInBits < 2^19-1, bits. */ - uint8_t *maxVect_ptr, /*!< [in] Pointer to the vector defining the upper limit for the random vector output, Given as little-endian byte array. - If not NULL, its actual size is treated as [(rndSizeInBits+7)/8] bytes. */ - uint8_t *rndVect_ptr /*!< [in/out] Pointer to the output buffer for the random vector. Must be at least [(rndSizeInBits+7)/8] bytes. - Treated as little-endian byte array. */ -); - - -/*************************************************************************************/ -/*! -@brief Used for adding additional input/personalization data provided by the user, -to be later used by the ::CRYS_RND_Instantiation/::CRYS_RND_Reseeding/::CRYS_RND_GenerateVector functions. - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_AddAdditionalInput( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint8_t *additonalInput_ptr, /*!< [in] The Additional Input buffer. */ - uint16_t additonalInputSize /*!< [in] The size of the Additional Input buffer. Must be <= 48, and a multiple of 4. */ -); - -/*! -@brief The CRYS_RND_EnterKatMode function sets KAT mode bit into StateFlag of global CRYS_RND_WorkingState structure. - -The user must call this function before calling functions performing KAT tests. - -\note Total size of entropy and nonce must be not great than: ::CRYS_RND_MAX_KAT_ENTROPY_AND_NONCE_SIZE, defined. - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C CRYSError_t CRYS_RND_EnterKatMode( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint8_t *entrData_ptr, /*!< [in] Entropy data. */ - uint32_t entrSize, /*!< [in] Entropy size in bytes. */ - uint8_t *nonce_ptr, /*!< [in] Nonce. */ - uint32_t nonceSize, /*!< [in] Entropy size in bytes. */ - CRYS_RND_WorkBuff_t *workBuff_ptr /*!< [out] RND working buffer, must be the same buffer, which should be passed into - Instantiation/Reseeding functions. */ -); - -/**********************************************************************************************************/ -/*! -@brief The CRYS_RND_DisableKatMode function disables KAT mode bit into StateFlag of global CRYS_RND_WorkingState structure. - -The user must call this function after KAT tests before actual using RND module (Instantiation etc.). - -@return CRYS_OK on success. -@return A non-zero value from crys_rnd_error.h on failure. -*/ -CIMPORT_C void CRYS_RND_DisableKatMode( - CRYS_RND_Context_t *rndContext_ptr /*!< [in/out] Pointer to the RND context buffer. */ -); - - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef CRYS_RND_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd_error.h deleted file mode 100644 index dd23f49..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rnd_error.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef CRYS_RND_ERROR_H -#define CRYS_RND_ERROR_H - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/*! -@file -@brief This module contains the definitions of the CRYS RND errors. -*/ - - - - -/************************ Defines ******************************/ -/* RND module on the CRYS layer base address - 0x00F00C00 */ - -#define CRYS_RND_DATA_OUT_POINTER_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x0UL) -#define CRYS_RND_CAN_NOT_GENERATE_RAND_IN_RANGE (CRYS_RND_MODULE_ERROR_BASE + 0x1UL) -#define CRYS_RND_CPRNG_TEST_FAIL_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x2UL) -#define CRYS_RND_ADDITIONAL_INPUT_BUFFER_NULL (CRYS_RND_MODULE_ERROR_BASE + 0x3UL) -#define CRYS_RND_ADDITIONAL_INPUT_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x4UL) -#define CRYS_RND_DATA_SIZE_OVERFLOW_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x5UL) -#define CRYS_RND_VECTOR_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x6UL) -#define CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x7UL) -#define CRYS_RND_INSTANTIATION_NOT_DONE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x8UL) -#define CRYS_RND_TRNG_LOSS_SAMPLES_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x9UL) -#define CRYS_RND_TRNG_TIME_EXCEED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xAUL) -#define CRYS_RND_TRNG_LOSS_SAMPLES_AND_TIME_EXCEED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xBUL) -#define CRYS_RND_IS_KAT_MODE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xCUL) -#define CRYS_RND_OPERATION_IS_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xDUL) -#define CRYS_RND_STATE_VALIDATION_TAG_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xEUL) - -#define CRYS_RND_IS_NOT_SUPPORTED (CRYS_RND_MODULE_ERROR_BASE + 0xFUL) - -#define CRYS_RND_GEN_A_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x10UL) -#define CRYS_RND_GEN_B_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x11UL) -#define CRYS_RND_GEN_C_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x12UL) -#define CRYS_RND_ILLEGAL_PARAMS_ACCORDING_TO_PRIV_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x13UL) -#define CRYS_RND_GEN_VECTOR_FUNC_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x14UL) - -#define CRYS_RND_WORK_BUFFER_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x20UL) -#define CRYS_RND_ILLEGAL_AES_KEY_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x21UL) -#define CRYS_RND_ILLEGAL_DATA_PTR_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x22UL) -#define CRYS_RND_ILLEGAL_DATA_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x23UL) -#define CRYS_RND_ILLEGAL_PARAMETER_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x24UL) -#define CRYS_RND_STATE_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x25UL) -#define CRYS_RND_TRNG_ERRORS_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x26UL) -#define CRYS_RND_CONTEXT_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x27UL) - -#define CRYS_RND_VECTOR_OUT_PTR_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x30UL) -#define CRYS_RND_VECTOR_OUT_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x31UL) -#define CRYS_RND_MAX_VECTOR_IS_TOO_SMALL_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x32UL) -#define CRYS_RND_KAT_DATA_PARAMS_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x33UL) -#define CRYS_RND_TRNG_KAT_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x34UL) -#define CRYS_RND_SRAM_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x35UL) - - -/************************ Enums ********************************/ - - -/************************ Typedefs ****************************/ - - -/************************ Structs ******************************/ - - -/************************ Public Variables **********************/ - - -/************************ Public Functions **********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_kg.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_kg.h deleted file mode 100644 index 209e5f0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_kg.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef CRYS_RSA_KG_H -#define CRYS_RSA_KG_H - -#include "crys_rsa_types.h" -#include "crys_rnd.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief Generates a RSA pair of public and private keys. -*/ - -/************************ Defines ******************************/ - -/* Max allowed size and values of public exponent for key generation in CRYS */ -#define CRYS_RSA_KG_PUB_EXP_MAX_SIZE_BITS 17 -#define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_1 0x000003 -#define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_2 0x000011 -#define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_3 0x010001 - - - - -/***********************************************************************************************/ - -/*! -@brief CRYS_RSA_KG_GenerateKeyPair generates a Pair of public and private keys on non CRT mode according to [ANS X9.31]. - -\note To be FIPS 186-4 [5.1] compliant use only the following key sizes (in bits): 1024, 2048 and 3072. - -@return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. - -*/ -CIMPORT_C CRYSError_t CRYS_RSA_KG_GenerateKeyPair( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint8_t *pubExp_ptr, /*!< [in] The pointer to the public exponent (public key). */ - uint16_t pubExpSizeInBytes, /*!< [in] The public exponent size in bytes. */ - uint32_t keySize, /*!< [in] The size of the key, in bits. Supported sizes are - 512, 1024, 2048, 3072 and 4096 bit. */ - CRYS_RSAUserPrivKey_t *userPrivKey_ptr, /*!< [out] Pointer to the private key structure. */ - CRYS_RSAUserPubKey_t *userPubKey_ptr, /*!< [out] Pointer to the public key structure. */ - CRYS_RSAKGData_t *keyGenData_ptr, /*!< [in] Pointer to a temporary structure required for the KeyGen operation. */ - CRYS_RSAKGFipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ -); - -/***********************************************************************************************/ -/*! -@brief Generates a pair of public and private keys on CRT mode according to [ANS X9.31]. - -\note To be FIPS 186-4 [5.1] compliant use only the following key sizes (in bits): 1024, 2048 and 3072. - -@return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. -*/ - -CIMPORT_C CRYSError_t CRYS_RSA_KG_GenerateKeyPairCRT( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ - uint8_t *pubExp_ptr, /*!< [in] The pointer to the public exponent (public key). */ - uint16_t pubExpSizeInBytes, /*!< [in] The public exponent size in bytes. */ - uint32_t keySize, /*!< [in] The size of the key, in bits. Supported sizes are - 512, 1024, 2048, 3072 and 4096 bit. */ - CRYS_RSAUserPrivKey_t *userPrivKey_ptr, /*!< [out] Pointer to the private key structure. */ - CRYS_RSAUserPubKey_t *userPubKey_ptr, /*!< [out] Pointer to the public key structure. */ - CRYS_RSAKGData_t *keyGenData_ptr, /*!< [in] Pointer to a temporary structure required for the KeyGen operation. */ - CRYS_RSAKGFipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ -); - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_prim.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_prim.h deleted file mode 100644 index 2293648..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_prim.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef CRYS_RSA_PRIM_H -#define CRYS_RSA_PRIM_H - -#include "crys_rsa_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module defines the API that implements the [PKCS1_2.1] primitive functions. - -\note Direct use of primitive functions, rather than schemes to protect data, is strongly discouraged as primitive functions are -susceptible to well-known attacks. -*/ - - - -/**********************************************************************************/ -/*! -@brief Implements the RSAEP algorithm, as defined in [PKCS1_2.1] - 6.1.1. - -@return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. - */ -CIMPORT_C CRYSError_t CRYS_RSA_PRIM_Encrypt( - CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] Pointer to the public key data structure. */ - CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure containing internal buffers. */ - uint8_t *Data_ptr, /*!< [in] Pointer to the data to encrypt. */ - uint16_t DataSize, /*!< [in] The size (in bytes) of the data to encrypt. Data size must be ≤ Modulus size. - It can be smaller than the modulus size but it is not recommended. - If smaller, the data is zero-padded up to the modulus size. - Since the result of decryption is always the size of the modulus, - this will cause the size of the decrypted data to be larger than the - originally encrypted data. */ - uint8_t *Output_ptr /*!< [out] Pointer to the encrypted data. The buffer size must be ≥ the modulus size. */ -); - - -/**********************************************************************************/ -/*! -@brief Implements the RSADP algorithm, as defined in [PKCS1_2.1] - 6.1.2. - -@return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. - -*/ -CIMPORT_C CRYSError_t CRYS_RSA_PRIM_Decrypt( - CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to the private key data structure. - The representation (pair or quintuple) and hence the algorithm (CRT or not-CRT) - is determined by the Private Key data structure - using - ::CRYS_RSA_Build_PrivKey or ::CRYS_RSA_Build_PrivKeyCRT - to determine which algorithm is used.*/ - CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure containing internal buffers required for - the RSA operation. */ - uint8_t *Data_ptr, /*!< [in] Pointer to the data to be decrypted. */ - uint16_t DataSize, /*!< [in] The size (in bytes) of the data to decrypt. Must be equal to the modulus size. */ - uint8_t *Output_ptr /*!< [out] Pointer to the decrypted data. The buffer size must be ≤ the modulus size. */ -); - - -/*! -@brief Implements the RSASP1 algorithm, as defined in [PKCS1_2.1] - 6.2.1, as a call to ::CRYS_RSA_PRIM_Decrypt, -since the signature primitive is identical to the decryption primitive. -*/ -#define CRYS_RSA_PRIM_Sign CRYS_RSA_PRIM_Decrypt - -/*! -@brief Implements the RSAVP1 algorithm, as defined in [PKCS1_2.1] - 6.2.2, as a call to ::CRYS_RSA_PRIM_Encrypt. -*/ -#define CRYS_RSA_PRIM_Verify CRYS_RSA_PRIM_Encrypt - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp.h deleted file mode 100644 index 9633bcd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp.h +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains all of the enums and definitions that are used for the - CRYS SRP APIs, as well as the APIs themselves. -*/ -#ifndef CRYS_SRP_H -#define CRYS_SRP_H - - -#include "ssi_pal_types.h" -#include "crys_error.h" -#include "crys_pka_defs_hw.h" -#include "crys_hash.h" -#include "crys_rnd.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/************************ Defines ******************************/ -/*! The SRP modulus sizes. */ -#define CRYS_SRP_MODULUS_SIZE_1024_BITS 1024 -#define CRYS_SRP_MODULUS_SIZE_1536_BITS 1536 -#define CRYS_SRP_MODULUS_SIZE_2048_BITS 2048 -#define CRYS_SRP_MODULUS_SIZE_3072_BITS 3072 - -#define CRYS_SRP_MAX_MODULUS_IN_BITS CRYS_SRP_MODULUS_SIZE_3072_BITS -#define CRYS_SRP_MAX_MODULUS (CRYS_SRP_MAX_MODULUS_IN_BITS/SASI_BITS_IN_BYTE) -#define CRYS_SRP_MAX_MODULUS_IN_WORDS (CRYS_SRP_MAX_MODULUS_IN_BITS/SASI_BITS_IN_32BIT_WORD) - -/*! The SRP private number size range. */ -#define CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_BITS (256) -#define CRYS_SRP_PRIV_NUM_MIN_SIZE (CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_BITS/SASI_BITS_IN_BYTE) -#define CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_WORDS (CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_BITS/SASI_BITS_IN_32BIT_WORD) -#define CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_BITS (CRYS_SRP_MAX_MODULUS_IN_BITS) -#define CRYS_SRP_PRIV_NUM_MAX_SIZE (CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_BITS/SASI_BITS_IN_BYTE) -#define CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_WORDS (CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_BITS/SASI_BITS_IN_32BIT_WORD) - -/*! The SRP HASH digest max size in bytes. */ -#define CRYS_SRP_MAX_DIGEST_IN_WORDS CRYS_HASH_RESULT_SIZE_IN_WORDS -#define CRYS_SRP_MAX_DIGEST (CRYS_SRP_MAX_DIGEST_IN_WORDS*SASI_32BIT_WORD_SIZE) - -/*! The SRP salt size range. */ -#define CRYS_SRP_MIN_SALT_SIZE (8) -#define CRYS_SRP_MIN_SALT_SIZE_IN_WORDS (CRYS_SRP_MIN_SALT_SIZE/SASI_32BIT_WORD_SIZE) -#define CRYS_SRP_MAX_SALT_SIZE (64) -#define CRYS_SRP_MAX_SALT_SIZE_IN_WORDS (CRYS_SRP_MAX_SALT_SIZE/SASI_32BIT_WORD_SIZE) - -/************************ Typedefs ****************************/ -/*! Defines the SRP modulus sized buffer. */ -typedef uint8_t CRYS_SRP_Modulus_t[CRYS_SRP_MAX_MODULUS]; - -/*! Defines the SRP digest sized buffer. */ -typedef uint8_t CRYS_SRP_Digest_t[CRYS_SRP_MAX_DIGEST]; - -/*! Defines the SRP secret sized buffer. */ -typedef uint8_t CRYS_SRP_Secret_t[2*CRYS_SRP_MAX_DIGEST]; - -/************************ Enums ********************************/ - -/*! -SRP supported versions -*/ -typedef enum { - CRYS_SRP_VER_3 = 0, /*!< VER 3*/ - CRYS_SRP_VER_6 = 1, /*!< VER 6 */ - CRYS_SRP_VER_6A = 2, /*!< VER 6A */ - CRYS_SRP_VER_HK = 3, /*!< VER 6A */ - - CRYS_SRP_NumOfVersions, - - CRYS_SRP_VersionLast= 0x7FFFFFFF, - -}CRYS_SRP_Version_t; - -/*! -SRP entity type -*/ -typedef enum { - CRYS_SRP_HOST = 1, /*!< Host entity, called also server, verifier, or Accessory in Home-Kit */ - CRYS_SRP_USER = 2, /*!< User entity, called also client, or Device in Home-Kit */ - - CRYS_SRP_NumOfEntityType, - - CRYS_SRP_EntityLast= 0x7FFFFFFF, - -}CRYS_SRP_Entity_t; - -/************************ Structs ******************************/ - -/* The group parameters for the SRP - defines the modulus and the generatetoe used */ -typedef struct CRYS_SRP_GroupParam_t { - CRYS_SRP_Modulus_t modulus; - uint8_t gen; - size_t modSizeInBits; - uint32_t validNp; - uint32_t Np[CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; -}CRYS_SRP_GroupParam_t; - -/************************ context Structs ******************************/ -/* The SRP context prototype */ -typedef struct CRYS_SRP_Context_t { - CRYS_SRP_Entity_t srpType; - CRYS_SRP_Version_t srpVer; - CRYS_SRP_GroupParam_t groupParam; // N, g, Np - CRYS_HASH_OperationMode_t hashMode; - size_t hashDigestSize; - CRYS_RND_Context_t *pRndCtx; - CRYS_SRP_Modulus_t ephemPriv; // a or b - size_t ephemPrivSize; - CRYS_SRP_Digest_t userNameDigest; // M - CRYS_SRP_Digest_t credDigest; // p - CRYS_SRP_Digest_t kMult; // k multiplier -}CRYS_SRP_Context_t; - - -/************************ SRP common Functions **********************/ -/****************************************************************************************************/ -/*! -@brief This function initiates the SRP context. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_Init( - CRYS_SRP_Entity_t srpType, /*!< [in] SRP entity type. */ - CRYS_SRP_Version_t srpVer, /*!< [in] SRP version. */ - CRYS_SRP_Modulus_t srpModulus, /*!< [in] A pointer to the SRP modulus, BE byte buffer. */ - uint8_t srpGen, /*!< [in] The SRP generator param. */ - size_t modSizeInBits, /*!< [in] The SRP modulus size in bits:1024, 1536, 2048 & 3072 */ - CRYS_HASH_OperationMode_t hashMode, /*!< [in] Enumerator defining the HASH mode. */ - uint8_t *pUserName, /*!< [in] A Pointer to user name. */ - size_t userNameSize, /*!< [in] The user name buffer size > 0. */ - uint8_t *pPwd, /*!< [in] A Pointer to user password. */ - size_t pwdSize, /*!< [in] The user password buffer size > 0 if pPwd is valid. */ - CRYS_RND_Context_t *pRndCtx, /*!< [in] A Pointer to RND context.*/ - CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP host context.*/ -); - -#define CRYS_SRP_HK_INIT(srpType, srpModulus, srpGen, modSizeInBits, pUserName, userNameSize, pPwd, pwdSize, pRndCtx, pCtx) \ - CRYS_SRP_Init(srpType, CRYS_SRP_VER_HK, srpModulus, srpGen, modSizeInBits, CRYS_HASH_SHA512_mode, pUserName, userNameSize, pPwd, pwdSize, pRndCtx, pCtx) - - -/****************************************************************************************************/ -/*! -@brief This function calculates pSalt & password verifier - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_PwdVerCreate( - size_t saltSize, /*!< [in] The size of the random salt to generate, - The range is between CRYS_SRP_MIN_SALT_SIZE - to CRYS_SRP_MAX_SALT_SIZE. */ - uint8_t *pSalt, /*!< [out] A Pointer to the pSalt number (s).*/ - CRYS_SRP_Modulus_t pwdVerifier, /*!< [out] A Pointer to the password verifier (v). */ - CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP context.*/ -); - - -/****************************************************************************************************/ -/*! -@brief Clears the SRP context. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_Clear( - CRYS_SRP_Context_t *pCtx /*!< [in/out] A Pointer to the SRP context.*/ -); - - -/************************ SRP Host Functions **********************/ -/****************************************************************************************************/ -/*! -@brief This function generates host public & private ephemeral key, known as B & b in RFC - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_HostPubKeyCreate( - size_t ephemPrivSize, /*!< [in] The size of the generated ephemeral private key (b). - The range is between CRYS_SRP_PRIV_NUM_MIN_SIZE to - CRYS_SRP_PRIV_NUM_MAX_SIZE */ - CRYS_SRP_Modulus_t pwdVerifier, /*!< [in] A Pointer to the verifier (v). */ - CRYS_SRP_Modulus_t hostPubKeyB, /*!< [out] A Pointer to the host ephemeral public key (B). */ - CRYS_SRP_Context_t *pCtx /*!< [in/out] A Pointer to the SRP context.*/ -); - - -/*! -@brief Verifies the user Proof and calculates the Host message proof. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_HostProofVerifyAndCalc( - size_t saltSize, /*!< [in] The size of the random salt, - The range is between CRYS_SRP_MIN_SALT_SIZE - to CRYS_SRP_MAX_SALT_SIZE. */ - uint8_t *pSalt, /*!< [in] A Pointer to the pSalt number.*/ - CRYS_SRP_Modulus_t pwdVerifier, /*!< [in] A Pointer to the password verifier (v). */ - CRYS_SRP_Modulus_t userPubKeyA, /*!< [in] A Pointer to the user ephemeral public key (A). */ - CRYS_SRP_Modulus_t hostPubKeyB, /*!< [in] A Pointer to the host ephemeral public key (B). */ - CRYS_SRP_Digest_t userProof, /*!< [in] A Pointer to the SRP user proof buffer (M1).*/ - CRYS_SRP_Digest_t hostProof, /*!< [out] A Pointer to the SRP host proof buffer (M2).*/ - CRYS_SRP_Secret_t sharedSecret, /*!< [out] A Pointer to the SRP shared secret (K).*/ - CRYS_SRP_Context_t *pCtx /*!< [in] A Pointer to the SRP context.*/ -); - - - -/************************ SRP User Functions **********************/ -/****************************************************************************************************/ -/*! -@brief This function generates user public & private ephemeral key, known as A & a in RFC - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_UserPubKeyCreate( - size_t ephemPrivSize, /*!< [in] The size of the generated ephemeral private key (a). - The range is between CRYS_SRP_PRIV_NUM_MIN_SIZE to - CRYS_SRP_PRIV_NUM_MAX_SIZE */ - CRYS_SRP_Modulus_t userPubKeyA, /*!< [out] A Pointer to the user ephemeral public key (A). */ - CRYS_SRP_Context_t *pCtx /*!< [in/out] A Pointer to the SRP context.*/ -); - - -/****************************************************************************************************/ -/*! -@brief This function calculates the user proof. - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_UserProofCalc( - size_t saltSize, /*!< [in] The size of the random salt, - The range is between CRYS_SRP_MIN_SALT_SIZE - to CRYS_SRP_MAX_SALT_SIZE. */ - uint8_t *pSalt, /*!< [in] A Pointer to the pSalt number.*/ - CRYS_SRP_Modulus_t userPubKeyA, /*!< [in] A Pointer to the user public ephmeral key (A).*/ - CRYS_SRP_Modulus_t hostPubKeyB, /*!< [in] A Pointer to the host public ephmeral key (B).*/ - CRYS_SRP_Digest_t userProof, /*!< [out] A Pointer to the SRP user proof buffer (M1).*/ - CRYS_SRP_Secret_t sharedSecret, /*!< [out] A Pointer to the SRP shared secret (K).*/ - CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP context.*/ -); - -/****************************************************************************************************/ -/*! -@brief This function verifies the host proof - -@return CRYS_OK on success. -@return A non-zero value on failure as defined crys_srp_error.h. -*/ -CIMPORT_C CRYSError_t CRYS_SRP_UserProofVerify( - CRYS_SRP_Secret_t sharedSecret, /*!< [in] A Pointer to the SRP shared secret (K).*/ - CRYS_SRP_Modulus_t userPubKeyA, /*!< [in] A Pointer to the user public ephmeral key (A).*/ - CRYS_SRP_Digest_t userProof, /*!< [in] A Pointer to the SRP user proof buffer (M1).*/ - CRYS_SRP_Digest_t hostProof, /*!< [in] A Pointer to the SRP host proof buffer (M2).*/ - CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP user context.*/ -); - - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef CRYS_SRP_H */ - - - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp_error.h deleted file mode 100644 index d523d01..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_srp_error.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRYS_SRP_ERROR_H -#define CRYS_SRP_ERROR_H - - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This module contains the definitions of the CRYS SRP errors. -*/ - - - -/************************ Defines ******************************/ - -/* The CRYS SRP module errors base address - 0x00F02600 */ -#define CRYS_SRP_PARAM_INVALID_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x01UL) -#define CRYS_SRP_MOD_SIZE_INVALID_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x02UL) -#define CRYS_SRP_STATE_UNINITIALIZED_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x03UL) -#define CRYS_SRP_RESULT_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x04UL) -#define CRYS_SRP_PARAM_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x05UL) - -/************************ Enums ********************************/ - -/************************ Typedefs ****************************/ - -/************************ Structs *****************************/ - -/************************ Public Variables *********************/ - -/************************ Public Functions *********************/ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/dx_reg_base_host.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/dx_reg_base_host.h deleted file mode 100644 index 8f48543..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/dx_reg_base_host.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef __DX_REG_BASE_HOST_H__ -#define __DX_REG_BASE_HOST_H__ - -/* Identify platform: Xilinx Zynq7000 ZC706 */ -#define DX_PLAT_ZYNQ7000 1 -#define DX_PLAT_ZYNQ7000_ZC706 1 - -/* SEP core clock frequency in MHz */ -#define DX_SEP_FREQ_MHZ 64 -#define DX_BASE_CC 0x5002B000 - -#define DX_BASE_ENV_REGS 0x40008000 -#define DX_BASE_ENV_CC_MEMORIES 0x40008000 -#define DX_BASE_ENV_FLASH 0x40008700 -#define DX_BASE_ENV_PERF_RAM 0x40009000 - -#define DX_BASE_HOST_RGF 0x0UL -#define DX_BASE_CRY_KERNEL 0x0UL -#define DX_BASE_ROM 0x40000000 - -#define DX_BASE_RNG 0x0000UL -#endif /*__DX_REG_BASE_HOST_H__*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/sns_silib.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/sns_silib.h deleted file mode 100644 index eb7ad0c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/sns_silib.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains all of the enums and definitions that are used for the - CryptoCell Lib init and finish APIs, as well as the APIs themselves. -*/ - -#ifndef __SNS_SILIB_H__ -#define __SNS_SILIB_H__ - -#include "ssi_pal_types.h" -#include "crys_rnd.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* definitions for error returns */ -typedef enum { - SA_SILIB_RET_OK = 0, - SA_SILIB_RET_EINVAL_CTX_PTR, - SA_SILIB_RET_EINVAL_WORK_BUF_PTR, - SA_SILIB_RET_HAL, - SA_SILIB_RET_PAL, - SA_SILIB_RET_RND_INST_ERR, - SA_SILIB_RET_EINVAL_HW_VERSION, /* Invalid HW version */ - SA_SILIB_RET_EINVAL_HW_SIGNATURE, /* Invalid HW signature */ - SA_SILIB_RESERVE32B = 0x7FFFFFFFL -} SA_SilibRetCode_t; - - -#define DX_VERSION_PRODUCT_BIT_SHIFT 0x18UL -#define DX_VERSION_PRODUCT_BIT_SIZE 0x8UL - - - -/*! -@brief This function Perform global initialization of the ARM CryptoCell 3xx runtime library; -it must be called once per ARM CryptoCell for 3xx cold boot cycle. -Among other initializations, this function calls CRYS_RND_Instantiation and CRYS_RND_SetGenerateVectorFunc -to initialize the TRNG and the primary RND context. An initialized RND context is required for calling RND -APIs and asymmetric cryptography key generation and signatures. The primary context returned by this -function can be used as a single global context for all RND needs. Alternatively, other contexts may -be initialized and used with a more limited scope (for specific applications or specific threads). -\note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library, -this API is not thread-safe. -@return SA_SILIB_RET_OK on success. -@return A non-zero value in case of failure. -*/ -SA_SilibRetCode_t SaSi_LibInit(CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer, - allocated by the user. The context is used to maintain the RND state as - well as pointers to a function used for random vector generation. - This context must be saved and provided as parameter to any API that - uses the RND module.*/ - CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in] Scratchpad for the RND module's work. */); - -/*! -@brief This function finalize the library operations. It frees the associated resources (mutexes) and call hal and pal terminate functions. -the function also call CRYS_RND_UnInstantiation to clean the rnd context. -@return SA_SILIB_RET_OK on success. -@return A non-zero value in case of failure. -*/ -SA_SilibRetCode_t SaSi_LibFini(CRYS_RND_Context_t *rndContext_ptr /*!< [in/out] Pointer to the RND context buffer that was - initialized in SaSi_LibInit.*/); - -#ifdef __cplusplus -} -#endif - -#endif /*__DX_CCLIB_H__*/ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes.h deleted file mode 100644 index d436e7d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes.h +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! @file -@brief This file contains all of the enums and definitions that are used for the -CryptoCell AES APIs, as well as the APIs themselves. -*/ - -#ifndef SSI_AES_H -#define SSI_AES_H - -#include "ssi_pal_types.h" -#include "ssi_aes_error.h" -#include "ssi_aes_defs.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/************************ Defines ******************************/ - - -/************************ Enums ********************************/ - -/*! -Encrypt or Decrypt operation mode. -*/ -typedef enum { - SASI_AES_ENCRYPT = 0, /*!< Encrypt mode. */ - SASI_AES_DECRYPT = 1, /*!< Decrypt mode. */ - - SASI_AES_NUM_OF_ENCRYPT_MODES, - SASI_AES_ENCRYPT_MODE_LAST = 0x7FFFFFFF -}SaSiAesEncryptMode_t; - -/*! -AES operation mode. -*/ -typedef enum { - SASI_AES_MODE_ECB = 0, /*!< ECB mode. */ - SASI_AES_MODE_CBC = 1, /*!< CBC mode. */ - SASI_AES_MODE_CBC_MAC = 2, /*!< CBC-MAC mode. */ - SASI_AES_MODE_CTR = 3, /*!< CTR mode. */ - SASI_AES_MODE_XCBC_MAC = 4, /*!< XCBC-MAC mode. */ - SASI_AES_MODE_CMAC = 5, /*!< CMAC mode. */ - SASI_AES_MODE_XTS = 6, /*!< XTS mode. */ - SASI_AES_MODE_CBC_CTS = 7, /*!< CBC-CTS mode. */ - SASI_AES_MODE_OFB = 8, /*!< OFB mode. */ - - SASI_AES_NUM_OF_OPERATION_MODES, - SASI_AES_OPERATION_MODE_LAST = 0x7FFFFFFF -}SaSiAesOperationMode_t; - -/*! -AES padding type. -*/ -typedef enum { - SASI_AES_PADDING_NONE = 0, /*!< No padding. */ - SASI_AES_PADDING_PKCS7 = 1, /*!< PKCS7 padding. */ - - SASI_AES_NUM_OF_PADDING_TYPES, - SASI_AES_PADDING_TYPE_LAST = 0x7FFFFFFF -}SaSiAesPaddingType_t; - -/*! -AES key type. -*/ -typedef enum { - SASI_AES_USER_KEY = 0, /*!< user key. */ - SASI_AES_PLATFORM_KEY = 1, /*!< Kplt hardware key. */ - SASI_AES_CUSTOMER_KEY = 2, /*!< Kcst hardware key. */ - - SASI_AES_NUM_OF_KEY_TYPES, - SASI_AES_KEY_TYPE_LAST = 0x7FFFFFFF -}SaSiAesKeyType_t; - -/************************ Typedefs ****************************/ - -/*! Defines the IV buffer - 16 bytes array. */ -typedef uint8_t SaSiAesIv_t[SASI_AES_IV_SIZE_IN_BYTES]; - -/*! Defines the AES key data buffer. */ -typedef uint8_t SaSiAesKeyBuffer_t[SASI_AES_KEY_MAX_SIZE_IN_BYTES]; - -/************************ Structs ******************************/ - -/*! The user's context prototype - the argument type that is passed by the user - to the APIs called. */ -typedef struct SaSiAesUserContext_t { - uint32_t buff[SASI_AES_USER_CTX_SIZE_IN_WORDS]; /*!< Buffer for the AES context. */ -}SaSiAesUserContext_t; - - -/*! AES User Key Data. */ -typedef struct SaSiAesUserKeyData_t { - uint8_t * pKey; /*!< Pointer to the key. */ - size_t keySize; /*!< The key size in bytes. Valid values: - - For XTS mode - 32 or 64 byte, indicating the full size of the double key (2x128 or 2x256 bit). - - For XCBC-MAC mode - 16 byte (limited by the standard). - - For all other modes - 16, 24 or 32 byte. */ -}SaSiAesUserKeyData_t; - -/*! AES HW Key Data - this structure is likely to be changed when we'll start using it. */ -typedef struct SaSiAesHwKeyData_t { - size_t slotNumber; /*!< Slot number. */ -}SaSiAesHwKeyData_t; - - -/************************ Functions *****************************/ - -/*! -@brief This function is used to initialize an AES operation context. - To operate the AES machine, this must be the first API called. - -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesInit( - SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context buffer that is allocated by the caller and initialized by this API. - Should be used in all subsequent calls that are part of the same operation. */ - SaSiAesEncryptMode_t encryptDecryptFlag, /*!< [in] A flag specifying whether an AES Encrypt (SASI_AES_Encrypt) or Decrypt (SASI_AES_Decrypt) operation should be performed. - Must be set to CRYS_AES_Encrypt in CBC-MAC, XCBC-MAC and CMAC modes. */ - SaSiAesOperationMode_t operationMode, /*!< [in] The operation cipher/mode. */ - SaSiAesPaddingType_t paddingType /*!< [in] The padding type for AES operation: - - NONE - supported for all operation modes. - - PKCS7 - supported for ECB, CBC, CBC-MAC operation modes. */ -); - - -/*! -@brief This function sets the key information for the AES operation, in the context that was initialized by SaSi_AesInit. -\note When FIPS certification mode is set to ON, and the mode is AES-XTS, weak keys are not allowed (128/256 lsb bits must be -different than 128/256 msb bits, according to the key size). -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesSetKey( - SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context, after it was initialized by SaSi_AesInit. */ - SaSiAesKeyType_t keyType, /*!< [in] The type of key to be used for the AES operation. - Currently only SASI_AES_USER_KEY is supported - the key is plaintext and provided in the pKeyData parameter. */ - void * pKeyData, /*!< [in] Pointer to the key data structure (to be casted to the relevant struct type). */ - size_t keyDataSize /*!< [in] The size of data passed in pKeyData in bytes. */ -); - - -/*! -@brief This function sets the IV, counter or tweak data for the following AES operation on the same context. - The context must be first initialized by SaSi_AesInit. - It must be called at least once prior to the first SaSi_AesBlock operation on the same context - for those ciphers that require it. - If needed, it can also be called to override the IV in the middle of a sequence of SaSi_AesBlock operations. - -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesSetIv( - SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ - SaSiAesIv_t pIV /*!< [in] Pointer to the buffer of the IV, counter or tweak. -
      • For CBC, CBC-CTS, OFB and CBC-MAC modes - the IV value.
      • -
      • For CTR mode - the counter.
      • -
      • For XTS mode - the tweak value.
      • -
      • For all other modes - N/A.
      */ -); - - -/*! -@brief This function retrieves the current IV, counter or tweak from the AES context. - -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesGetIv( - SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ - SaSiAesIv_t pIV /*!< [out] Pointer to the buffer of the IV, counter or tweak. -
      • For CBC, CBC-CTS, OFB and CBC-MAC modes - the IV value.
      • -
      • For CTR mode - the counter.
      • -
      • For XTS mode - the tweak value.
      • -
      • For all other modes - N/A.
      */ -); - - -/*! -@brief This function performs an AES operation on an input data buffer, according to the configuration defined in the context parameter. - It can be called as many times as needed, until all the input data is processed. - SaSi_AesInit, SaSi_AesSetKey, and for some ciphers SaSi_AesSetIv, must be called before - the first call to this API with the same context. - -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesBlock( - SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ - uint8_t * pDataIn, /*!< [in] Pointer to the buffer of the input data to the AES. The pointer does not need to be aligned. - For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, - and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). - For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ - size_t dataInSize, /*!< [in] Size of the input data in bytes. -
      • For all modes except XTS, must be multiple of 16 bytes.
      • -
      • For XTS mode, only the following data sizes are supported: 64, 512, 520, 521, 1024 and 4096 bytes. - The data passed in a single SaSi_AesBlock call is considered to be a single XTS unit. - All subsequent calls to this API with the same context must use the same data size.
      */ - uint8_t * pDataOut /*!< [out] Pointer to the output buffer. The pointer does not need to be aligned. - For CBC-MAC, XCBC-MAC, CMAC modes it may be NULL. - For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, - and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). - For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ -); - - -/*! -@brief This function is used to finish AES operation. - - It processes the last data block if needed, finalizes the AES operation (cipher-specific), - and produces operation results (for MAC operations). - \note In case AES padding is used (PKCS#7) Din and Dout user's buffers must include extra space for - the padding scheme. - -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesFinish( - SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ - size_t dataSize, /*!< [in] The size of the input data in bytes. -
      • For CBC-CTS mode, must be > 16. Can be <=16 only if this is the only data (no previous calls were - made to SaSi_AesBlock with the same context).
      • -
      • For XTS mode, the data size must conform to the dataInSize rules as listed for XTS under the - SaSi_AesBlock API, and match the data size passed in the previous calls to SaSi_AesBlock with the - same context.
      • -
      • For all other modes, zero is a valid size.
      • -
      • For ECB, CBC, CBC-MAC modes:
      • -
        • Must be >= 0, if direction is SASI_AES_ENCRYPT and padding type is SASI_AES_PADDING_PKCS7.
        • -
        • Must be >= 16 and a multiple of 16 bytes, if direction is SASI_AES_DECRYPT and padding type - is SASI_AES_PADDING_PKCS7.
        • -
        • Must be a multiple of 16 bytes, otherwise.
      */ - uint8_t * pDataIn, /*!< [in] Pointer of the input data buffer. - For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, - and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). - For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ - size_t dataInBuffSize, /*!< [in] Size of pDataIn buffer in bytes. -
      • Must be >= dataSize.
      • -
      • According to padding type, must be >= dataSize + padding. For PKCS7, padding size is - maximum SASI_AES_BLOCK_SIZE_IN_BYTES.
      */ - uint8_t * pDataOut, /*!< [out] Pointer to the output buffer. - For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, - and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). - For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ - size_t * dataOutBuffSize /*!< [in,out] In - Size of pDataOut buffer in bytes. - The output buffer size must be no less than: -
      • For CBC-MAC, XCBC-MAC, CMAC modes - 16 bytes (for MAC result).
      • -
      • For non-MAC modes - dataInBuffSize.
      - Out - The size in bytes of the actual output data: -
      • If direction is SASI_AES_ENCRYPT and padding type is SASI_AES_PADDING_PKCS7, it is the actual size - with the padding.
      • -
      • If direction is SASI_AES_DECRYPT and padding type is SASI_AES_PADDING_PKCS7, it is the size without - the padding.
      • -
      • For CBC-MAC, XCBC-MAC, CMAC modes - always 16 bytes.
      */ -); - - -/*! -@brief This function releases and crears resources after AES operations. - -@return SASI_OK on success, -@return A non-zero value from ssi_aes_error.h on failure. -*/ -CIMPORT_C SaSiError_t SaSi_AesFree( - SaSiAesUserContext_t * pContext /*!< [in] Pointer to the AES context. */ -); - - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef SSI_AES_H */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_defs.h deleted file mode 100644 index 276446f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_defs.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains definitions that are used for the ARM CryptoCell 3xx version of the CryptoCell AES APIs. -*/ - -#ifndef SSI_AES_DEFS_H -#define SSI_AES_DEFS_H - -#include "ssi_pal_types.h" - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/************************ Defines ******************************/ - -/*! The size of the user's context prototype (see SaSiAesUserContext_t) in words. */ -#define SASI_AES_USER_CTX_SIZE_IN_WORDS (4+4+7+4) - -/*! The AES block size in words. */ -#define SASI_AES_BLOCK_SIZE_IN_WORDS 4 -/*! The AES block size in bytes. */ -#define SASI_AES_BLOCK_SIZE_IN_BYTES (SASI_AES_BLOCK_SIZE_IN_WORDS * sizeof(uint32_t)) - -/*! The size of the IV buffer in words. */ -#define SASI_AES_IV_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS -/*! The size of the IV buffer in bytes. */ -#define SASI_AES_IV_SIZE_IN_BYTES (SASI_AES_IV_SIZE_IN_WORDS * sizeof(uint32_t)) - -/*! The maximum size of the AES KEY in words. */ -#define SASI_AES_KEY_MAX_SIZE_IN_WORDS 4 -/*! The maximum size of the AES KEY in bytes. */ -#define SASI_AES_KEY_MAX_SIZE_IN_BYTES (SASI_AES_KEY_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) - - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef SSI_AES_DEFS_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_error.h deleted file mode 100644 index 47d4ab0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_aes_error.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains the definitions of the CryptoCell AES errors. -*/ - -#ifndef SSI_AES_ERROR_H -#define SSI_AES_ERROR_H - -#include "crys_error.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/************************ Defines ******************************/ - -/* generic errors */ -#define SASI_FATAL_ERROR CRYS_FATAL_ERROR -#define SASI_OUT_OF_RESOURCE_ERROR CRYS_OUT_OF_RESOURCE_ERROR -#define SASI_ILLEGAL_RESOURCE_VAL_ERROR CRYS_ILLEGAL_RESOURCE_VAL_ERROR - -/* CRYS_AES_MODULE_ERROR_BASE - 0x00F00000 */ -#define SASI_AES_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x00UL) -#define SASI_AES_INVALID_IV_OR_TWEAK_PTR_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x01UL) -#define SASI_AES_ILLEGAL_OPERATION_MODE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x02UL) -#define SASI_AES_ILLEGAL_KEY_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x03UL) -#define SASI_AES_INVALID_KEY_POINTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x04UL) -#define SASI_AES_KEY_TYPE_NOT_SUPPORTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x05UL) -#define SASI_AES_INVALID_ENCRYPT_MODE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x06UL) -#define SASI_AES_USER_CONTEXT_CORRUPTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x07UL) -#define SASI_AES_DATA_IN_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x08UL) -#define SASI_AES_DATA_OUT_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x09UL) -#define SASI_AES_DATA_IN_SIZE_ILLEGAL (CRYS_AES_MODULE_ERROR_BASE + 0x0AUL) -#define SASI_AES_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0BUL) -#define SASI_AES_DATA_IN_BUFFER_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0CUL) -#define SASI_AES_DATA_OUT_BUFFER_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0DUL) -#define SASI_AES_ILLEGAL_PADDING_TYPE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0EUL) -#define SASI_AES_INCORRECT_PADDING_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0FUL) -#define SASI_AES_CORRUPTED_OUTPUT_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x10UL) -#define SASI_AES_DATA_OUT_SIZE_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x11UL) -#define SASI_AES_DECRYPTION_NOT_ALLOWED_ON_THIS_MODE (CRYS_AES_MODULE_ERROR_BASE + 0x12UL) - -#define SASI_AES_ADDITIONAL_BLOCK_NOT_PERMITTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x15UL) -#define SASI_AES_CTX_SIZES_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x16UL) - -#define SASI_AES_ILLEGAL_PARAMS_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x60UL) -#define SASI_AES_CTR_ILLEGAL_BLOCK_OFFSET_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x70UL) -#define SASI_AES_CTR_ILLEGAL_COUNTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x71UL) -#define SASI_AES_IS_NOT_SUPPORTED (CRYS_AES_MODULE_ERROR_BASE + 0xFFUL) - -/************************ Enums ********************************/ - -/************************ Typedefs ****************************/ - -/************************ Structs *****************************/ - -/************************ Public Variables *********************/ - -/************************ Public Functions *********************/ - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef SSI_AES_ERROR_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_bitops.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_bitops.h deleted file mode 100644 index bc09224..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_bitops.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * \file ssi_bitops.h - * Bit fields operations macros. - */ -#ifndef _SSI_BITOPS_H_ -#define _SSI_BITOPS_H_ - -#define BITMASK(mask_size) (((mask_size) < 32) ? \ - ((1UL << (mask_size)) - 1) : 0xFFFFFFFFUL) -#define BITMASK_AT(mask_size, mask_offset) (BITMASK(mask_size) << (mask_offset)) - -#define BITFIELD_GET(word, bit_offset, bit_size) \ - (((word) >> (bit_offset)) & BITMASK(bit_size)) -#define BITFIELD_SET(word, bit_offset, bit_size, new_val) do { \ - word = ((word) & ~BITMASK_AT(bit_size, bit_offset)) | \ - (((new_val) & BITMASK(bit_size)) << (bit_offset)); \ -} while (0) - -/* Is val aligned to "align" ("align" must be power of 2) */ -#ifndef IS_ALIGNED -#define IS_ALIGNED(val, align) \ - (((uint32_t)(val) & ((align) - 1)) == 0) -#endif - -#define SWAP_ENDIAN(word) \ - (((word) >> 24) | (((word) & 0x00FF0000) >> 8) | \ - (((word) & 0x0000FF00) << 8) | (((word) & 0x000000FF) << 24)) - -#ifdef BIG__ENDIAN -#define SWAP_TO_LE(word) SWAP_ENDIAN(word) -#define SWAP_TO_BE(word) word -#else -#define SWAP_TO_LE(word) word -#define SWAP_TO_BE(word) SWAP_ENDIAN(word) -#endif - - - -/* Is val a multiple of "mult" ("mult" must be power of 2) */ -#define IS_MULT(val, mult) \ - (((val) & ((mult) - 1)) == 0) - -#define IS_NULL_ADDR(adr) \ - (!(adr)) - -#endif /*_SSI_BITOPS_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort.h deleted file mode 100644 index 2909a6f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_PAL_ABORT_H -#define _SSI_PAL_ABORT_H - - -#include "ssi_pal_abort_plat.h" - -/*! -@file -@brief This file contains definitions for PAL Abort API. -*/ - -/*! -This function performs the "Abort" operation, should be implemented according to platform and OS. -*/ - -#define SaSi_PalAbort(msg) _SaSi_PalAbort(msg) - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort_plat.h deleted file mode 100644 index 904ba91..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_abort_plat.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_PAL_ABORT_PLAT_H -#define _SSI_PAL_ABORT_PLAT_H - -#include "ssi_pal_log.h" -#include - -#define _SaSi_PalAbort(exp) do { \ - SASI_PAL_LOG_ERR("ASSERT:%s:%d: %s", __FILE__, __LINE__, (#exp)); \ - abort(); \ - } while (0) - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_barrier.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_barrier.h deleted file mode 100644 index 8a5d1fd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_barrier.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef _SSI_PAL_BARRIER_H -#define _SSI_PAL_BARRIER_H - -/*! -@file -@brief This file contains the definitions and APIs for memory barrier implementation. -* This is a place holder for platform specific memory barrier implementation -* The secure core driver should include a memory barrier before and after the last word of the descriptor -* to allow correct order between the words and different descriptors. -*/ - -/*! - * This MACRO is responsible to put the memory barrier after the write operation. - * - * @return None - */ - -void SaSi_PalWmb(void); - -/*! - * This MACRO is responsible to put the memory barrier before the read operation. - * - * @return None - */ -void SaSi_PalRmb(void); - - -#endif - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma.h deleted file mode 100644 index 3fcf96e..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma.h +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_DMA_H -#define _SSI_PAL_DMA_H - -/*! -@file -@brief This file contains definitions that are used for the DMA related APIs. The implementation of these functions -need to be replaced according to Platform and OS. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "ssi_pal_types.h" -#include "ssi_pal_dma_plat.h" -#include "ssi_pal_dma_defs.h" - -/*! User buffer scatter information. */ -typedef struct { - SaSiDmaAddr_t blockPhysAddr; - uint32_t blockSize; -}SaSi_PalDmaBlockInfo_t; - -#ifdef BIG__ENDIAN -#define SET_WORD_LE(val) cpu_to_le32(val) -#else -#define SET_WORD_LE -#endif - -/** - * @brief This function is called by the ARM TrustZone CryptoCell TEE runtime library before the HW is used. - * It maps a given data buffer (virtual address) for ARM TrustZone CryptoCell TEE HW DMA use (physical address), and returns the list of - * one or more DMA-able (physical) blocks. It may lock the buffer for ARM TrustZone CryptoCell TEE HW use. Once it is called, - * only ARM TrustZone CryptoCell TEE HW access to the buffer is allowed, until it is unmapped. - * If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, - * this API does not have to perform any actual mapping operation, but only return the list of DMA-able blocks. - * - * @return A non-zero value in case of failure. - */ -uint32_t SaSi_PalDmaBufferMap(uint8_t *pDataBuffer, /*!< [in] Address of the buffer to map. */ - uint32_t buffSize, /*!< [in] Buffer size in bytes. */ - SaSi_PalDmaBufferDirection_t copyDirection, /*!< [in] Copy direction of the buffer, according to ::SaSi_PalDmaBufferDirection_t, -
      • TO_DEVICE - the original buffer is the input to the operation, - and this function should copy it to the temp buffer, - prior to the activating the HW on the temp buffer.
      • -
      • FROM_DEVICE - not relevant for this API.
      • -
      • BI_DIRECTION - used when the crypto operation is "in-place", meaning - the result of encryption or decryption is written over the original data - at the same address. Should be treated by this API same as - TO_DEVICE.
      */ - uint32_t *pNumOfBlocks, /*!< [in/out] Maximum numOfBlocks to fill, as output the actual number. */ - SaSi_PalDmaBlockInfo_t *pDmaBlockList, /*!< [out] List of DMA-able blocks that the buffer maps to. */ - SaSi_PalDmaBufferHandle *dmaBuffHandle /*!< [out] A handle to the mapped buffer private resources.*/ ); - - -/** - * @brief This function is called by the ARM TrustZone CryptoCell TEE runtime library after the HW is used. - * It unmaps a given buffer, and frees its associated resources, if needed. It may unlock the buffer and flush it for CPU use. - * Once it is called, ARM TrustZone CryptoCell TEE HW does not require access to this buffer anymore. - * If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, this API does - * not have to perform any un-mapping operation, and the actual un-mapping can be done by the Secure OS outside the context - * of the ARM TrustZone CryptoCell TEE runtime library. - * @return A non-zero value in case of failure. - */ -uint32_t SaSi_PalDmaBufferUnmap(uint8_t *pDataBuffer, /*!< [in] Address of the buffer to unmap. */ - uint32_t buffSize, /*!< [in] Buffer size in bytes. */ - SaSi_PalDmaBufferDirection_t copyDirection, /*!< [in] Copy direction of the buffer, according to ::SaSi_PalDmaBufferDirection_t -
      • TO_DEVICE - not relevant for this API.
      • -
      • FROM_DEVICE - the temp buffer holds the output of the HW, and this - API should copy it to the actual output buffer.
      • -
      • BI_DIRECTION - used when the crypto operation is "in-place", meaning - the result of encryption or decryption is written over the original data - at the same address. Should be treated by this API same as - FROM_DEVICE.
      */ - uint32_t numOfBlocks, /*!< [in] Number of DMA-able blocks that the buffer maps to. */ - SaSi_PalDmaBlockInfo_t *pDmaBlockList, /*!< [in] List of DMA-able blocks that the buffer maps to. */ - SaSi_PalDmaBufferHandle dmaBuffHandle /*!< [in] A handle to the mapped buffer private resources. */); - - -/** - * @brief Allocates a DMA-contiguous buffer for CPU use, and returns its virtual address. - * Before passing the buffer to the ARM TrustZone CryptoCell TEE HW, ::SaSi_PalDmaBufferMap should be called. - * \note The returned address must be aligned to 32 bits. - * - * - * @return A non-zero value in case of failure. - */ -uint32_t SaSi_PalDmaContigBufferAllocate(uint32_t buffSize, /*!< [in] Buffer size in bytes.*/ - uint8_t **ppVirtBuffAddr /*!< [out] Virtual address of the allocated buffer.*/); - - - -/** - * @brief Frees resources previously allocated by ::SaSi_PalDmaContigBufferAllocate. - * - * - * @return A non-zero value in case of failure. - */ -uint32_t SaSi_PalDmaContigBufferFree(uint32_t buffSize, /*!< [in] Buffer size in Bytes. */ - uint8_t *pVirtBuffAddr /*!< [in] Virtual address of the buffer to free. */); - - - -/** - * @brief Checks whether the buffer is guaranteed to be a single contiguous DMA block. - * - * - * @return Returns TRUE if the buffer is guaranteed to be a single contiguous DMA block, and FALSE otherwise. - */ -uint32_t SaSi_PalIsDmaBufferContiguous(uint8_t *pDataBuffer, /*!< [in] User buffer address. */ - uint32_t buffSize /*!< [in] User buffer size. */); - - -/** - * @brief Maps virtual address to physical address. - * - * - * @return Physical address. - */ -SaSiDmaAddr_t SaSi_PalMapVirtualToPhysical(uint8_t *pVirtualAddr /*!< [in] Pointer to virtual address. */); - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_defs.h deleted file mode 100644 index dddffb3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_defs.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -/*! -@file -@brief This file contains the platform dependent DMA definitions. -*/ - -#ifndef _SSI_PAL_DMA_DEFS_H -#define _SSI_PAL_DMA_DEFS_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef void * SaSi_PalDmaBufferHandle; - -/* DMA directions configuration */ -typedef enum { - SASI_PAL_DMA_DIR_NONE = 0, /*!< No direction. */ - SASI_PAL_DMA_DIR_TO_DEVICE = 1, /*!< The original buffer is the input to the operation, and should be copied/mapped to a temp buffer, - prior to activating the HW on the temp buffer. */ - SASI_PAL_DMA_DIR_FROM_DEVICE = 2, /*!< The temp buffer holds the output of the HW, and this API should copy/map it to the original output buffer.*/ - SASI_PAL_DMA_DIR_BI_DIRECTION = 3, /*!< Used when the result is written over the original data at the same address. should be treated as 1 & 2.*/ - SASI_PAL_DMA_DIR_MAX, - SASI_PAL_DMA_DIR_RESERVE32 = 0x7FFFFFFF -}SaSi_PalDmaBufferDirection_t; - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_plat.h deleted file mode 100644 index dadfa3b..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_dma_plat.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_DMA_PLAT_H -#define _SSI_PAL_DMA_PLAT_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @brief stub function, the function should initialize the DMA mapping of the platform (if needed) - * - * @param[in] buffSize - buffer size in Bytes - * @param[in] physBuffAddr - physical start address of the memory to map - * - * @return Virtual start address of contiguous memory - */ -extern uint32_t SaSi_PalDmaInit(uint32_t buffSize, - uint32_t physBuffAddr); - -/** - * @brief free system resources created in PD_PAL_DmaInit() - * - * - * @return void - */ -extern void SaSi_PalDmaTerminate(void); -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_error.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_error.h deleted file mode 100644 index 3c51c59..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_error.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_PAL_ERROR_H -#define _SSI_PAL_ERROR_H - -/*! -@file -@brief This file contains the platform dependent error definitions. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define SASI_PAL_BASE_ERROR 0x0F000000 - -/* Memory error returns */ -#define SASI_PAL_MEM_BUF1_GREATER SASI_PAL_BASE_ERROR + 0x01UL -#define SASI_PAL_MEM_BUF2_GREATER SASI_PAL_BASE_ERROR + 0x02UL - -/* Semaphore error returns */ -#define SASI_PAL_SEM_CREATE_FAILED SASI_PAL_BASE_ERROR + 0x03UL -#define SASI_PAL_SEM_DELETE_FAILED SASI_PAL_BASE_ERROR + 0x04UL -#define SASI_PAL_SEM_WAIT_TIMEOUT SASI_PAL_BASE_ERROR + 0x05UL -#define SASI_PAL_SEM_WAIT_FAILED SASI_PAL_BASE_ERROR + 0x06UL -#define SASI_PAL_SEM_RELEASE_FAILED SASI_PAL_BASE_ERROR + 0x07UL - -#define SASI_PAL_ILLEGAL_ADDRESS SASI_PAL_BASE_ERROR + 0x08UL - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_file_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_file_plat.h deleted file mode 100644 index 0fa7aa2..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_file_plat.h +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_FILE_INT_H -#define _SSI_PAL_FILE_INT_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "stdio.h" - -/** -* @brief File Description: -* This file contains wrapper functions for file related operations. -*/ - -/**** ----- Files General Definitions ----- ****/ - -/* Definitions for file modes */ -#define SASI_PAL_MAX_SIZE_MODE 4 -#define SASI_PAL_NUM_OF_SUPPORT_MODES 12 - -typedef char SaSiPalFileModeStr_t[SASI_PAL_MAX_SIZE_MODE]; - -typedef SaSiPalFileModeStr_t SaSiPalFileModesTable_t[SASI_PAL_NUM_OF_SUPPORT_MODES]; - -extern const SaSiPalFileModeStr_t SaSiPalFileModeTable[]; -/**** ------------------------------------- ****/ - -//#define _SaSiFile_t FILE - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ -/** -* @brief A wrapper for fopen functionality (to create a new file, the file is opened for read and -* write). -* -*/ -#define _SaSi_PalFileCreate(aFileName) SaSi_PalFOpen(aFileName, SASI_PAL_WriteAndRead) - -/** -* @brief A wrapper for fopen functionality. SaSiPalFileModeTable contains all possible modes -* for fopen -* -*/ -#define _SaSi_PalFOpen(aFileName, aFileMode) ((SaSiFile_t)fopen(aFileName, SaSiPalFileModeTable[aFileMode])) - -/** - * @brief A wrapper for fclose functionality. - * - */ -#define _SaSi_PalFClose(aFileHandle) fclose((FILE*)aFileHandle) - -/** - * @brief A wrapper for fseek functionality - * - */ -#define _SaSi_PalFSeek(aFileHandle, aOffset, aSeekOrigin) fseek((FILE*)aFileHandle, aOffset, aSeekOrigin) - -/** - * @brief A wrapper for ftell functionality - * - */ -#define _SaSi_PalFTell(aFileHandle) ftell((FILE*)aFileHandle) - -/** -* @brief A wrapper for fread functionality -* -*/ -#define _SaSi_PalFRead(aFileHandle, aBuffer, aSize) fread(aBuffer, 1, aSize, (FILE*)aFileHandle) - -/** -* @brief A wrapper for fwrite functionality -* -*/ -#define _SaSi_PalFWrite(aFileHandle, aBuffer, aSize) fwrite(aBuffer, 1, aSize, (FILE*)aFileHandle) -/** - * @brief A wrapper for fflush functionality - * - */ -#define _SaSi_PalFFlush(aFileHandle) fflush((FILE*)aFileHandle) - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_init.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_init.h deleted file mode 100644 index c5887b3..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_init.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef _SSI_PAL_INIT_H -#define _SSI_PAL_INIT_H - -#include "ssi_pal_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief This file contains the PAL layer entry point, it includes the definitions and APIs for PAL initialization and termination. -*/ - -/** - * @brief This function Performs all initializations that may be required by the customer's PAL implementation, specifically by the DMA-able buffer - * scheme. The existing implementation allocates a contiguous memory pool that is later used by the ARM TrustZone CryptoCell TEE implementation. - * In case no initializations are needed in the customer's environment, the function can be minimized to return OK. - * It is called by ::SaSi_LibInit. - * - * @return A non-zero value in case of failure. - */ -int SaSi_PalInit(void); - - - -/** - * @brief This function is used to terminate the PAL implementation and free the resources that were taken by ::SaSi_PalInit. - * - * @return Void. - */ -void SaSi_PalTerminate(void); - - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log.h deleted file mode 100644 index 70817a0..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log.h +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_PAL_LOG_H_ -#define _SSI_PAL_LOG_H_ - -#include "ssi_pal_types.h" -#include "ssi_pal_log_plat.h" - -#define SASI_PAL_MAX_LOG_LEVEL 3 - - -/*! -@file -@brief This file contains the PAL layer log definitions, by default the log is disabled. -*/ - -/* PAL log levels (to be used in SASI_PAL_logLevel) */ -#define SASI_PAL_LOG_LEVEL_NULL -1 /*!< \internal Disable logging */ -#define SASI_PAL_LOG_LEVEL_ERR 0 -#define SASI_PAL_LOG_LEVEL_WARN 1 -#define SASI_PAL_LOG_LEVEL_INFO 2 -#define SASI_PAL_LOG_LEVEL_DEBUG 3 -#define SASI_PAL_LOG_LEVEL_TRACE 4 -#define SASI_PAL_LOG_LEVEL_DATA 5 - -#ifndef SASI_PAL_LOG_CUR_COMPONENT -/* Setting default component mask in case caller did not define */ -/* (a mask that is always on for every log mask value but full masking) */ -#define SASI_PAL_LOG_CUR_COMPONENT 0xFFFFFFFF -#endif -#ifndef SASI_PAL_LOG_CUR_COMPONENT_NAME -#define SASI_PAL_LOG_CUR_COMPONENT_NAME "Dx" -#endif - -/* Select compile time log level (default if not explicitly specified by caller) */ -#ifndef SASI_PAL_MAX_LOG_LEVEL /* Can be overriden by external definition of this constant */ -#ifdef DEBUG -#define SASI_PAL_MAX_LOG_LEVEL SASI_PAL_LOG_LEVEL_ERR /*SASI_PAL_LOG_LEVEL_DEBUG*/ -#else /* Disable logging */ -#define SASI_PAL_MAX_LOG_LEVEL SASI_PAL_LOG_LEVEL_NULL -#endif -#endif /*SASI_PAL_MAX_LOG_LEVEL*/ -/* Evaluate SASI_PAL_MAX_LOG_LEVEL in case provided by caller */ -#define __SASI_PAL_LOG_LEVEL_EVAL(level) level -#define _SASI_PAL_MAX_LOG_LEVEL __SASI_PAL_LOG_LEVEL_EVAL(SASI_PAL_MAX_LOG_LEVEL) - - -#ifdef ARM_DSM -#define SaSi_PalLogInit() do {} while (0) -#define SaSi_PalLogLevelSet(setLevel) do {} while (0) -#define SaSi_PalLogMaskSet(setMask) do {} while (0) -#else -#if _SASI_PAL_MAX_LOG_LEVEL > SASI_PAL_LOG_LEVEL_NULL -void SaSi_PalLogInit(void); -void SaSi_PalLogLevelSet(int setLevel); -void SaSi_PalLogMaskSet(uint32_t setMask); -extern int SaSi_PAL_logLevel; -extern uint32_t SaSi_PAL_logMask; -#else /* No log */ -static inline void SaSi_PalLogInit(void) {} -static inline void SaSi_PalLogLevelSet(int setLevel) {SASI_UNUSED_PARAM(setLevel);} -static inline void SaSi_PalLogMaskSet(uint32_t setMask) {SASI_UNUSED_PARAM(setMask);} -#endif -#endif - -/* Filter logging based on logMask and dispatch to platform specific logging mechanism */ -#define _SASI_PAL_LOG(level, format, ...) \ - if (SaSi_PAL_logMask & SASI_PAL_LOG_CUR_COMPONENT) \ - __SASI_PAL_LOG_PLAT(SASI_PAL_LOG_LEVEL_ ## level, "%s:%s: " format, SASI_PAL_LOG_CUR_COMPONENT_NAME, __func__, ##__VA_ARGS__) - -#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_ERR) -#define SASI_PAL_LOG_ERR(format, ... ) \ - _SASI_PAL_LOG(ERR, format, ##__VA_ARGS__) -#else -#define SASI_PAL_LOG_ERR( ... ) do {} while (0) -#endif - -#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_WARN) -#define SASI_PAL_LOG_WARN(format, ... ) \ - if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_WARN) \ - _SASI_PAL_LOG(WARN, format, ##__VA_ARGS__) -#else -#define SASI_PAL_LOG_WARN( ... ) do {} while (0) -#endif - -#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_INFO) -#define SASI_PAL_LOG_INFO(format, ... ) \ - if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_INFO) \ - _SASI_PAL_LOG(INFO, format, ##__VA_ARGS__) -#else -#define SASI_PAL_LOG_INFO( ... ) do {} while (0) -#endif - -#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_DEBUG) -#define SASI_PAL_LOG_DEBUG(format, ... ) \ - if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_DEBUG) \ - _SASI_PAL_LOG(DEBUG, format, ##__VA_ARGS__) - -#define SASI_PAL_LOG_DUMP_BUF(msg, buf, size) \ - do { \ - int i; \ - uint8_t *pData = (uint8_t*)buf; \ - \ - PRINTF("%s (%d):\n", msg, size); \ - for (i = 0; i < size; i++) { \ - PRINTF("0x%02X ", pData[i]); \ - if ((i & 0xF) == 0xF) { \ - PRINTF("\n"); \ - } \ - } \ - PRINTF("\n"); \ - } while (0) -#else -#define SASI_PAL_LOG_DEBUG( ... ) do {} while (0) -#define SASI_PAL_LOG_DUMP_BUF(msg, buf, size) do {} while (0) -#endif - -#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_TRACE) -#define SASI_PAL_LOG_TRACE(format, ... ) \ - if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_TRACE) \ - _SASI_PAL_LOG(TRACE, format, ##__VA_ARGS__) -#else -#define SASI_PAL_LOG_TRACE(...) do {} while (0) -#endif - -#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_TRACE) -#define SASI_PAL_LOG_DATA(format, ...) \ - if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_TRACE) \ - _SASI_PAL_LOG(DATA, format, ##__VA_ARGS__) -#else -#define SASI_PAL_LOG_DATA( ...) do {} while (0) -#endif - -#endif /*_SSI_PAL_LOG_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log_plat.h deleted file mode 100644 index 3754f60..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_log_plat.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_PAL_LOG_PLAT_H_ -#define _SSI_PAL_LOG_PLAT_H_ - -#include "dx_log_mask.h" -#include - -/************** PRINTF rules ******************/ -#if defined(DEBUG) - -#define PRINTF printf - -#else /* Disable all prints */ - -#define PRINTF(...) do {} while (0) - -#endif - -#define __SASI_PAL_LOG_PLAT(level, format, ...) PRINTF(format, ##__VA_ARGS__) - -#endif /*_SSI_PAL_LOG_PLAT_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_malloc_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_malloc_plat.h deleted file mode 100644 index fe03189..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_malloc_plat.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_MEMALLOC_INT_H -#define _SSI_PAL_MEMALLOC_INT_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -/** -* @brief File Description: -* This file contains wrappers for memory operations APIs. -*/ - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/** - * @brief A wrapper over malloc functionality. The function allocates a buffer according to given size - * - */ - #define _SaSi_PalMemMalloc malloc - - -/** - * @brief A wrapper over realloc functionality. The function allocates and copy a buffer - * according to size - * - */ -#define _SaSi_PalMemRealloc realloc - - -/** - * @brief A wrapper over free functionality/ The function will free allocated memory. - * - */ -#define _SaSi_PalMemFree free - - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem.h deleted file mode 100644 index 0f1d3a9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem.h +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_MEM_H -#define _SSI_PAL_MEM_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "ssi_pal_types.h" -#include "ssi_pal_mem_plat.h" -#include "ssi_pal_malloc_plat.h" - -/*! -@file -@brief This file contains functions for memory operations. The functions implementations -* are generally just wrappers to different operating system calls. -* None of the described functions will check the input parameters so the behavior -* of the APIs in illegal parameters case is dependent on the operating system behavior. -*/ - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/**** ----- Memory Operations APIs ----- ****/ - -/*! -* @brief This function purpose is to compare between two given buffers according to given size. -* -* @return The return values is according to operating system return values. -*/ - - -int32_t SaSi_PalMemCmp( const void* aTarget, /*!< [in] The target buffer to compare. */ - const void* aSource, /*!< [in] The Source buffer to compare to. */ - uint32_t aSize /*!< [in] Number of bytes to compare. */); - -/* Definition for MemCmp */ -#define SaSi_PalMemCmp _SaSi_PalMemCmp - -/*! - * @brief This function purpose is to perform secured memory comparison between two given - * buffers according to given size. The function will compare each byte till aSize - * number of bytes was compared even if the bytes are different. - * The function should be used to avoid security timing attacks. - * - * @return SASI_SUCCESS in case of success, - * @return value on failure as defined in ssi_pal_error.h. - */ -SaSiError_t SaSi_PalSecMemCmp( const uint8_t* aTarget, /*!< [in] The target buffer to compare. */ - const uint8_t* aSource, /*!< [in] The Source buffer to compare to. */ - uint32_t aSize /*!< [in] Number of bytes to compare. */); - -/*! - * @brief This function purpose is to copy aSize bytes from source buffer to destination buffer. - * - * @return void. - */ -void SaSi_PalMemCopy( const void* aDestination, /*!< [out] The destination buffer to copy bytes to. */ - const void* aSource, /*!< [in] The Source buffer to copy from. */ - uint32_t aSize /*!< [in] Number of bytes to copy. */ ); - -/*! - * @brief This function purpose is to copy aSize bytes from source buffer to destination buffer. - * This function Supports overlapped buffers. - * - * @return void. - */ -void SaSi_PalMemMove( const void* aDestination, /*!< [out] The destination buffer to copy bytes to. */ - const void* aSource, /*!< [in] The Source buffer to copy from. */ - uint32_t aSize /*!< [in] Number of bytes to copy. */); - -/* Definition for MemCopy */ -#define SaSi_PalMemCopy _SaSi_PalMemCopy -#define SaSi_PalMemMove _SaSi_PalMemMove - - -/*! - * @brief This function purpose is to set aSize bytes in the given buffer with aChar. - * - * @return void. - */ -void SaSi_PalMemSet( const void* aTarget, /*!< [out] The target buffer to set. */ - const uint8_t aChar, /*!< [in] The char to set into aTarget. */ - uint32_t aSize /*!< [in] Number of bytes to set. */); - -/* Definition for MemSet */ -#define SaSi_PalMemSet(aTarget, aChar, aSize) _SaSi_PalMemSet(aTarget, aChar, aSize) - -/*! - * @brief This function purpose is to set aSize bytes in the given buffer with zeroes. - * - * @return void. - */ -void SaSi_PalMemSetZero( const void* aTarget, /*!< [out] The target buffer to set. */ - uint32_t aSize /*!< [in] Number of bytes to set. */); - -#define SaSi_PalMemSetZero(aTarget, aSize) _SaSi_PalMemSetZero(aTarget, aSize) - -/**** ----- Memory Allocation APIs ----- ****/ - -/*! - * @brief This function purpose is to allocate a memory buffer according to aSize. - * - * - * @return The function will return a pointer to allocated buffer or NULL if allocation failed. - */ -void* SaSi_PalMemMalloc(uint32_t aSize /*!< [in] Number of bytes to allocate. */); - -/* Definition for MemMalloc */ -#define SaSi_PalMemMalloc _SaSi_PalMemMalloc - -/*! - * @brief This function purpose is to reallocate a memory buffer according to aNewSize. - * The content of the old buffer is moved to the new location. - * - * @return The function will return a pointer to the newly allocated buffer or NULL if allocation failed. - */ -void* SaSi_PalMemRealloc( void* aBuffer, /*!< [in] Pointer to allocated buffer. */ - uint32_t aNewSize /*!< [in] Number of bytes to reallocate. */); - -/* Definition for MemRealloc */ -#define SaSi_PalMemRealloc _SaSi_PalMemRealloc - -/*! - * @brief This function purpose is to free allocated buffer. - * - * - * @return void. - */ -void SaSi_PalMemFree(void* aBuffer /*!< [in] Pointer to allocated buffer.*/); - -/* Definition for MemFree */ -#define SaSi_PalMemFree _SaSi_PalMemFree - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem_plat.h deleted file mode 100644 index 6415330..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mem_plat.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_MEM_PLAT_H -#define _SSI_PAL_MEM_PLAT_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -/** -* @brief File Description: -* This file contains the implementation for memory operations APIs. -* The functions implementations are generally just wrappers to different operating system calls. -*/ - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/** - * @brief A wrapper over memcmp functionality. The function compares two given buffers - * according to size. - */ -#define _SaSi_PalMemCmp memcmp - -/** - * @brief A wrapper over memmove functionality, the function copies from one - * buffer to another according to given size - * - */ -#define _SaSi_PalMemCopy memmove - -#define _SaSi_PalMemMove memmove - -/** - * @brief A wrapper over memset functionality, the function sets a buffer with given value - * according to size - * - */ -#define _SaSi_PalMemSet(aTarget, aChar, aSize) memset(aTarget, aChar, aSize) - -/** - * @brief A wrapper over memset functionality, the function sets a buffer with zeroes - * according to size - * - */ -#define _SaSi_PalMemSetZero(aTarget, aSize) _SaSi_PalMemSet(aTarget,0x00, aSize) - - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_memmap.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_memmap.h deleted file mode 100644 index 6a8d7bd..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_memmap.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_MEMMAP_H -#define _SSI_PAL_MEMMAP_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -#include "ssi_pal_types.h" -/*! -* @file -* @brief This file contains functions for memory mapping -* None of the described functions will check the input parameters so the behavior -* of the APIs in illegal parameters case is dependent on the operating system behavior. -* -*/ - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/** - * @brief This function purpose is to return the base virtual address that maps the - * base physical address - * - * @return Zero on success. - * @return A non-zero value in case of failure. - */ -uint32_t SaSi_PalMemMap(uint32_t physicalAddress, /*!< [in] Start physical address of the I/O range to be mapped. */ - uint32_t mapSize, /*!< [in] Number of bytes that were mapped. */ - uint32_t **ppVirtBuffAddr /*!< [out] Pointer to the base virtual address to which the physical pages were mapped. */ ); - - -/** - * @brief This function purpose is to Unmap a specified address range previously mapped - * by SaSi_PalMemMap. - * - * @return Zero on success. - * @return A non-zero value in case of failure. - */ -uint32_t SaSi_PalMemUnMap(uint32_t *pVirtBuffAddr, /*!< [in] Pointer to the base virtual address to which the physical pages were mapped. */ - uint32_t mapSize /*!< [in] Number of bytes that were mapped. */); - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex.h deleted file mode 100644 index fdb342d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef _SSI_PAL_MUTEX_H -#define _SSI_PAL_MUTEX_H - -#include "ssi_pal_mutex_plat.h" -#include "ssi_pal_types_plat.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -* @file -* @brief This file contains functions for resource management (mutex operations). -* The functions implementations are generally just wrappers to different operating system calls. -* None of the described functions will check the input parameters so the behavior -* of the APIs in illegal parameters case is dependent on the operating system behavior. -* -*/ - - - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/** - * @brief This function purpose is to create a mutex. - * - * - * @return Zero on success. - * @return A non-zero value on failure. - */ -SaSiError_t SaSi_PalMutexCreate(SaSi_PalMutex *pMutexId /*!< [out] Pointer to created mutex handle. */); - - -/** - * @brief This function purpose is to destroy a mutex. - * - * - * @return Zero on success. - * @return A non-zero value on failure. - */ -SaSiError_t SaSi_PalMutexDestroy(SaSi_PalMutex *pMutexId /*!< [in] Pointer to mutex handle. */); - - -/** - * @brief This function purpose is to Wait for Mutex with aTimeOut. aTimeOut is - * specified in milliseconds (SASI_INFINITE is blocking). - * - * @return Zero on success. - * @return A non-zero value on failure. - */ -SaSiError_t SaSi_PalMutexLock (SaSi_PalMutex *pMutexId, /*!< [in] Pointer to Mutex handle. */ - uint32_t aTimeOut /*!< [in] Timeout in mSec, or SASI_INFINITE. */); - - -/** - * @brief This function purpose is to release the mutex. - * - * @return Zero on success. - * @return A non-zero value on failure. - */ -SaSiError_t SaSi_PalMutexUnlock (SaSi_PalMutex *pMutexId/*!< [in] Pointer to Mutex handle. */); - - - - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex_plat.h deleted file mode 100644 index 03d988d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_mutex_plat.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_MUTEX_PLAT_H -#define _SSI_PAL_MUTEX_PLAT_H - - - -#ifdef __cplusplus -extern "C" -{ -#endif -/** -* @brief File Description: -* This file contains functions for resource management (semaphor operations). -* The functions implementations are generally just wrappers to different operating system calls. -* None of the described functions will check the input parameters so the behavior -* of the APIs in illegal parameters case is dependent on the operating system behavior. -* -*/ - -typedef uint32_t SaSi_PalMutex; - - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_perf_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_perf_plat.h deleted file mode 100644 index 8a9f67f..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_perf_plat.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_PAL_PERF_PLAT_H__ -#define _SSI_PAL_PERF_PLAT_H__ - - - - -typedef unsigned int SaSi_PalPerfData_t; - -/** - * @brief DSM environment bug - sometimes very long write operation. - * to overcome this bug we added while to make sure write opeartion is completed - * - * @param[in] - * * - * @return None - */ -void SaSi_PalDsmWorkarround(); - - -#endif /*_SSI_PAL_PERF_PLAT_H__*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_sem_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_sem_plat.h deleted file mode 100644 index a271a16..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_sem_plat.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_SEM_INT__H -#define _SSI_PAL_SEM_INT__H - - - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "ssi_pal_types.h" -/** -* @brief File Description: -* This file contains functions for resource management (semaphor operations). -* The functions implementations are generally just wrappers to different operating system calls. -* None of the described functions will check the input parameters so the behavior -* of the APIs in illegal parameters case is dependent on the operating system behavior. -* -*/ - -typedef int DX_PAL_SEM; - - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/** - * @brief This function purpose is to create a semaphore. - * - * - * @param[out] aSemId - Pointer to created semaphor handle - * @param[in] aInitialVal - Initial semaphore value - * - * @return The return values is according to operating system return values. - */ -SaSiError_t _SaSi_PalSemCreate( DX_PAL_SEM *aSemId, uint32_t aInitialVal ); - -#define _SaSi_PalSemCreate(aSemId,aInitialVal) SASI_SUCCESS -/** - * @brief This function purpose is to delete a semaphore - * - * - * @param[in] aSemId - Semaphore handle - * - * @return The return values is according to operating system return values. - */ -SaSiError_t _SaSi_PalSemDelete( DX_PAL_SEM *aSemId ); - -#define _SaSi_PalSemDelete( aSemId ) SASI_SUCCESS -/** - * @brief This function purpose is to Wait for semaphore with aTimeOut. aTimeOut is - * specified in milliseconds. - * - * - * @param[in] aSemId - Semaphore handle - * @param[in] aTimeOut - timeout in mSec, or SASI_INFINITE - * - * @return The return values is according to operating system return values. - */ -SaSiError_t _SaSi_PalSemWait(DX_PAL_SEM aSemId, uint32_t aTimeOut); - -#define _SaSi_PalSemWait(aSemId, aTimeOut) SASI_SUCCESS -/** - * @brief This function purpose is to signal the semaphore. - * - * - * @param[in] aSemId - Semaphore handle - * - * @return The return values is according to operating system return values. - */ -SaSiError_t _SaSi_PalSemGive(DX_PAL_SEM aSemId); - -#define _SaSi_PalSemGive(aSemId) SASI_SUCCESS - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_string_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_string_plat.h deleted file mode 100644 index cdb8b2c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_string_plat.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - - -#ifndef _SSI_PAL_STRING_INT_H -#define _SSI_PAL_STRING_INT_H - - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -/** -* @brief File Description: -* This file contains wrapper functions for string manipulation. -*/ - - -/*---------------------------- - PUBLIC FUNCTIONS ------------------------------------*/ - -/** - * @brief A wrapper function for strlen functionality. The function returns the size of a given string - * - */ -#define _SaSi_PalStrLen strlen - -/** - * @brief A wrapper function for strstr functionality. The functions find a string in a string and - * return a pointer to it. - * - */ -#define _SaSi_PalFindStr strstr - -/** - * @brief A wrapper function for strchr functionality. The function finds a char in a given string. - * - */ -#define _SaSi_PalStrChr strchr - -/** - * @brief A wrapper function for strrchr functionality. The function finds a char inside a string - * (from the end) and returns a pointer to it - * - */ -#define _SaSi_PalStrRChr strrchr - -/** - * @brief A wrapper for strncpy functionality. The function copies a string. - * - */ -#define _SaSi_PalStrNCopy strncpy - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types.h deleted file mode 100644 index 4c50c7d..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! -@file -@brief This file contains the platform dependent definitions and types. -*/ - -#ifndef SSI_PAL_TYPES_H -#define SSI_PAL_TYPES_H - -#include "ssi_pal_types_plat.h" - -typedef enum { - SASI_FALSE = 0, - SASI_TRUE = 1 -} SaSiBool; - -#define SASI_SUCCESS 0UL -#define SASI_FAIL 1UL - -#define SASI_1K_SIZE_IN_BYTES 1024 -#define SASI_BITS_IN_BYTE 8 -#define SASI_BITS_IN_32BIT_WORD 32 -#define SASI_32BIT_WORD_SIZE (sizeof(uint32_t)) - -#define SASI_OK SASI_SUCCESS - -#define SASI_UNUSED_PARAM(prm) ((void)prm) - -#define SASI_MAX_UINT32_VAL (0xFFFFFFFF) - - -/* Minimum and Maximum macros */ -#ifdef min -#define CRYS_MIN(a,b) min( a , b ) -#else -#define CRYS_MIN( a , b ) ( ( (a) < (b) ) ? (a) : (b) ) -#endif - -#ifdef max -#define CRYS_MAX(a,b) max( a , b ) -#else -#define CRYS_MAX( a , b ) ( ( (a) > (b) ) ? (a) : (b) ) -#endif - - -#define CALC_FULL_BYTES(numBits) (((numBits) + (SASI_BITS_IN_BYTE -1))/SASI_BITS_IN_BYTE) -#define CALC_FULL_32BIT_WORDS(numBits) (((numBits) + (SASI_BITS_IN_32BIT_WORD -1))/SASI_BITS_IN_32BIT_WORD) -#define CALC_32BIT_WORDS_FROM_BYTES(sizeBytes) (((sizeBytes) + SASI_32BIT_WORD_SIZE - 1) / SASI_32BIT_WORD_SIZE) -#define ROUNDUP_BITS_TO_32BIT_WORD(numBits) (CALC_FULL_32BIT_WORDS(numBits)*SASI_BITS_IN_32BIT_WORD) -#define ROUNDUP_BITS_TO_BYTES(numBits) (CALC_FULL_BYTES(numBits)*SASI_BITS_IN_BYTE) -#define ROUNDUP_BYTES_TO_32BIT_WORD(numBytes) (SASI_32BIT_WORD_SIZE*(((numBytes)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE)) - - - -#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types_plat.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types_plat.h deleted file mode 100644 index b3ebf7c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_types_plat.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! @file -@brief This file contains basic type definitions that are platform dependent. -*/ -#ifndef SSI_PAL_TYPES_PLAT_H -#define SSI_PAL_TYPES_PLAT_H -/* Host specific types for standard (ISO-C99) compilant platforms */ - -#include -#include -#include - -typedef uintptr_t SaSiVirtAddr_t; -typedef uint32_t SaSiBool_t; -typedef uint32_t SaSiStatus; - -#define SaSiError_t SaSiStatus -#define SASI_INFINITE 0xFFFFFFFF - -#define CEXPORT_C -#define CIMPORT_C - -#endif /*SSI_PAL_TYPES_PLAT_H*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h deleted file mode 100644 index 08c6523..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef PKA_HW_PLAT_DEFS_H -#define PKA_HW_PLAT_DEFS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! -@file -@brief Contains the enums and definitions that are used in the PKA code (definitions that are platform dependent). -*/ - -#define SASI_PKA_WORD_SIZE_IN_BITS 64 - -#define CRYS_SRP_MAX_MODULUS_SIZE_IN_BITS 3072 - -#define CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 2048 - -#define CRYS_RSA_MAX_KEY_GENERATION_HW_SIZE_BITS 2048 - -/* PKA operations maximal count of extra bits: */ -#define PKA_EXTRA_BITS 8 -#define PKA_MAX_COUNT_OF_PHYS_MEM_REGS 32 - - -#ifdef __cplusplus -} -#endif - -#endif //PKA_HW_PLAT_DEFS_H - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_regs.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_regs.h deleted file mode 100644 index e6a3869..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_regs.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - - -/*! - * @file - * @brief Macro definitions for accessing ARM TrustZone CryptoCell register space. - */ - -#ifndef _SSI_REGS_H_ -#define _SSI_REGS_H_ - -#include "ssi_bitops.h" - -/* Register Offset macro */ -#define SASI_REG_OFFSET(unit_name, reg_name) \ - (DX_BASE_ ## unit_name + DX_ ## reg_name ## _REG_OFFSET) - -#define SASI_REG_BIT_SHIFT(reg_name, field_name) \ - (DX_ ## reg_name ## _ ## field_name ## _BIT_SHIFT) - -/* Register Offset macros (from registers base address in host) */ -#if defined(DX_CC_REE) || defined(DX_CC_TEE) || defined(DX_CONFIG_IOT_SUPPORTED) - -#include "dx_reg_base_host.h" - -/* Indexed GPR offset macros - note the (not original) preprocessor tricks...*/ -/* (Using the macro without the "_" prefix is allowed with another macro * - * as the gpr_idx) */ -#define _SEP_HOST_GPR_REG_OFFSET(gpr_idx) \ - SASI_REG_OFFSET(HOST_RGF, HOST_SEP_HOST_GPR ## gpr_idx) -#define SEP_HOST_GPR_REG_OFFSET(gpr_idx) _SEP_HOST_GPR_REG_OFFSET(gpr_idx) -#define _HOST_SEP_GPR_REG_OFFSET(gpr_idx) \ - SASI_REG_OFFSET(HOST_RGF, HOST_HOST_SEP_GPR ## gpr_idx) -#define HOST_SEP_GPR_REG_OFFSET(gpr_idx) _HOST_SEP_GPR_REG_OFFSET(gpr_idx) - -/* GPR IRQ bit shift/mask by GPR index */ -#define _SEP_HOST_GPR_IRQ_SHIFT(gpr_idx) \ - DX_HOST_IRR_SEP_HOST_GPR ## gpr_idx ## _INT_BIT_SHIFT -#define SEP_HOST_GPR_IRQ_SHIFT(gpr_idx) \ - _SEP_HOST_GPR_IRQ_SHIFT(gpr_idx) -#define SEP_HOST_GPR_IRQ_MASK(gpr_idx) \ - (1 << SEP_HOST_GPR_IRQ_CAUSE_SHIFT(gpr_idx)) - -/* Read-Modify-Write a field of a register */ -#define MODIFY_REGISTER_FLD(unitName, regName, fldName, fldVal) \ -do { \ - uint32_t regVal; \ - regVal = READ_REGISTER(SASI_REG_ADDR(unitName, regName)); \ - SASI_REG_FLD_SET(unitName, regName, fldName, regVal, fldVal); \ - WRITE_REGISTER(SASI_REG_ADDR(unitName, regName), regVal); \ -} while (0) - -#elif defined(DX_CC_SEP) - -#include "dx_reg_base_sep.h" - -/* We only provide this macro for SEP code because other platforms require usage - of (mapping base + offset), i.e., use of SASI_REG_OFFSET */ -/* PLEASE AVOID USING THIS MACRO FOR NEW SEP CODE. USE THE OFFSET MACROS. */ -#define SASI_REG_ADDR(unit_name, reg_name) \ - (DX_BASE_CC_PERIF + DX_BASE_ ## unit_name + \ - DX_ ## reg_name ## _REG_OFFSET) - -/* Indexed GPR address macros - note the (not original) preprocessor tricks...*/ -/* (Using the macro without the "_" prefix is allowed with another macro * - * as the gpr_idx) */ -#define _SEP_HOST_GPR_REG_ADDR(gpr_idx) \ - SASI_REG_ADDR(SEP_RGF, SEP_SEP_HOST_GPR ## gpr_idx) -#define SEP_HOST_GPR_REG_ADDR(gpr_idx) _SEP_HOST_GPR_REG_ADDR(gpr_idx) -#define _HOST_SEP_GPR_REG_ADDR(gpr_idx) \ - SASI_REG_ADDR(SEP_RGF, SEP_HOST_SEP_GPR ## gpr_idx) -#define HOST_SEP_GPR_REG_ADDR(gpr_idx) _HOST_SEP_GPR_REG_ADDR(gpr_idx) - -#else -#error Execution domain is not DX_CC_SEP/DX_CC_REE/DX_CC_TEE/DX_CONFIG_IOT_SUPPORTED -#endif - -/* Registers address macros for ENV registers (development FPGA only) */ -#ifdef DX_BASE_ENV_REGS - -#ifndef DX_CC_SEP /* Irrelevant for SeP code */ -/* This offset should be added to mapping address of DX_BASE_ENV_REGS */ -#define SASI_ENV_REG_OFFSET(reg_name) (DX_ENV_ ## reg_name ## _REG_OFFSET) -#endif - -#endif /*DX_BASE_ENV_REGS*/ - -/* Bit fields access */ -#define SASI_REG_FLD_GET(unit_name, reg_name, fld_name, reg_val) \ - (DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20 ? \ - reg_val /*!< \internal Optimization for 32b fields */ : \ - BITFIELD_GET(reg_val, DX_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ - DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE)) - -/* Bit fields access */ -#define SASI2_REG_FLD_GET(unit_name, reg_name, fld_name, reg_val) \ - (SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20 ? \ - reg_val /*!< \internal Optimization for 32b fields */ : \ - BITFIELD_GET(reg_val, SASI_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ - SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE)) - -#define SASI_REG_FLD_SET( \ - unit_name, reg_name, fld_name, reg_shadow_var, new_fld_val) \ -do { \ - if (DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20) \ - reg_shadow_var = new_fld_val; /*!< \internal Optimization for 32b fields */\ - else \ - BITFIELD_SET(reg_shadow_var, \ - DX_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ - DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE, \ - new_fld_val); \ -} while (0) - -#define SASI2_REG_FLD_SET( \ - unit_name, reg_name, fld_name, reg_shadow_var, new_fld_val) \ -do { \ - if (SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20) \ - reg_shadow_var = new_fld_val; /*!< \internal Optimization for 32b fields */\ - else \ - BITFIELD_SET(reg_shadow_var, \ - SASI_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ - SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE, \ - new_fld_val); \ -} while (0) - -/* Usage example: - uint32_t reg_shadow = READ_REGISTER(SASI_REG_ADDR(CRY_KERNEL,AES_CONTROL)); - SASI_REG_FLD_SET(CRY_KERNEL,AES_CONTROL,NK_KEY0,reg_shadow, 3); - SASI_REG_FLD_SET(CRY_KERNEL,AES_CONTROL,NK_KEY1,reg_shadow, 1); - WRITE_REGISTER(SASI_REG_ADDR(CRY_KERNEL,AES_CONTROL), reg_shadow); - */ - -#endif /*_SSI_REGS_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_sram_map.h b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_sram_map.h deleted file mode 100644 index b8f1f47..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_sram_map.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _SSI_SRAM_MAP_H_ -#define _SSI_SRAM_MAP_H_ - -/*! -@file -@brief This file contains internal SRAM mapping definitions. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define SASI_SRAM_PKA_BASE_ADDRESS 0x0 -#define SASI_PKA_SRAM_SIZE_IN_KBYTES 4 - - -#define SASI_SRAM_RND_HW_DMA_ADDRESS 0x0 -#define SASI_SRAM_RND_MAX_SIZE 0x800 /*!< Addresses 0K-4KB in SRAM reserved for RND operations - same as the PKA. */ - -#define SASI_SRAM_MAX_SIZE 0x1000 /*!< 4KB in SRAM. */ - -#ifdef __cplusplus -} -#endif - -#endif /*_SSI_SRAM_MAP_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/lib/license.txt b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/lib/license.txt deleted file mode 100644 index 45b35c9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/lib/license.txt +++ /dev/null @@ -1,30 +0,0 @@ -ARM Object Code and Header Files License - -Version 1.0 - -Redistribution. Redistribution and use of object code, header files, and -documentation, without modification, are permitted provided that the following -conditions are met: - -1) Redistributions must reproduce the above copyright notice and the - following disclaimer in the documentation and/or other materials - provided with the distribution. - -2) Unless to the extent explicitly permitted by law, no reverse - engineering, decompilation, or disassembly of is permitted. - -3) Redistribution and use is permitted solely for the purpose of - developing or executing applications that are targeted for use - on an ARM-based product. - -DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT -NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, -AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDERS 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. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/license.txt b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/license.txt deleted file mode 100644 index 45b35c9..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/license.txt +++ /dev/null @@ -1,30 +0,0 @@ -ARM Object Code and Header Files License - -Version 1.0 - -Redistribution. Redistribution and use of object code, header files, and -documentation, without modification, are permitted provided that the following -conditions are met: - -1) Redistributions must reproduce the above copyright notice and the - following disclaimer in the documentation and/or other materials - provided with the distribution. - -2) Unless to the extent explicitly permitted by law, no reverse - engineering, decompilation, or disassembly of is permitted. - -3) Redistribution and use is permitted solely for the purpose of - developing or executing applications that are targeted for use - on an ARM-based product. - -DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT -NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, -AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDERS 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. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/aes.c b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/aes.c deleted file mode 100644 index 4e55704..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/aes.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - -This is an implementation of the AES128 algorithm, specifically ECB and CBC mode. - -The implementation is verified against the test vectors in: - National Institute of Standards and Technology Special Publication 800-38A 2001 ED - -ECB-AES128 ----------- - - plain-text: - 6bc1bee22e409f96e93d7e117393172a - ae2d8a571e03ac9c9eb76fac45af8e51 - 30c81c46a35ce411e5fbc1191a0a52ef - f69f2445df4f9b17ad2b417be66c3710 - - key: - 2b7e151628aed2a6abf7158809cf4f3c - - resulting cipher - 3ad77bb40d7a3660a89ecaf32466ef97 - f5d3d58503b9699de785895a96fdbaaf - 43b1cd7f598ece23881b00e3ed030688 - 7b0c785e27e8ad3f8223207104725dd4 - - -NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0) - You should pad the end of the string with zeros if this is not the case. - -*/ - - -/*****************************************************************************/ -/* Includes: */ -/*****************************************************************************/ -#include -#include // CBC mode, for memset -#include "aes.h" - - -/*****************************************************************************/ -/* Defines: */ -/*****************************************************************************/ -// The number of columns comprising a state in AES. This is a constant in AES. Value=4 -#define Nb 4 -// The number of 32 bit words in a key. -#define Nk 4 -// Key length in bytes [128 bit] -#define KEYLEN 16 -// The number of rounds in AES Cipher. -#define Nr 10 - -// jcallan@github points out that declaring Multiply as a function -// reduces code size considerably with the Keil ARM compiler. -// See this link for more information: https://github.com/kokke/tiny-AES128-C/pull/3 -#ifndef MULTIPLY_AS_A_FUNCTION - #define MULTIPLY_AS_A_FUNCTION 0 -#endif - - -/*****************************************************************************/ -/* Private variables: */ -/*****************************************************************************/ -// state - array holding the intermediate results during decryption. -typedef uint8_t state_t[4][4]; -static state_t* state; - -// The array that stores the round keys. -static uint8_t RoundKey[176]; - -// The Key input to the AES Program -static const uint8_t* Key; - -#if defined(CBC) && CBC - // Initial Vector used only for CBC mode - static uint8_t* Iv; -#endif - -// The lookup-tables are marked const so they can be placed in read-only storage instead of RAM -// The numbers below can be computed dynamically trading ROM for RAM - -// This can be useful in (embedded) bootloader applications, where ROM is often limited. -static const uint8_t sbox[256] = { - //0 1 2 3 4 5 6 7 8 9 A B C D E F - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; - -static const uint8_t rsbox[256] = -{ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, - 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, - 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, - 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, - 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, - 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, - 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, - 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, - 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, - 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, - 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, - 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, - 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, - 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, - 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, - 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; - - -// The round constant word array, Rcon[i], contains the values given by -// x to th e power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8) -// Note that i starts at 1, not 0). -static const uint8_t Rcon[255] = { - 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, - 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, - 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, - 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, - 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, - 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, - 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, - 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, - 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, - 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, - 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, - 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, - 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, - 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, - 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, - 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb }; - - -/*****************************************************************************/ -/* Private functions: */ -/*****************************************************************************/ -static uint8_t getSBoxValue(uint8_t num) -{ - return sbox[num]; -} - -static uint8_t getSBoxInvert(uint8_t num) -{ - return rsbox[num]; -} - -// This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states. -static void KeyExpansion(void) -{ - uint32_t i, j, k; - uint8_t tempa[4]; // Used for the column/row operations - - // The first round key is the key itself. - for(i = 0; i < Nk; ++i) - { - RoundKey[(i * 4) + 0] = Key[(i * 4) + 0]; - RoundKey[(i * 4) + 1] = Key[(i * 4) + 1]; - RoundKey[(i * 4) + 2] = Key[(i * 4) + 2]; - RoundKey[(i * 4) + 3] = Key[(i * 4) + 3]; - } - - // All other round keys are found from the previous round keys. - for(; (i < (Nb * (Nr + 1))); ++i) - { - for(j = 0; j < 4; ++j) - { - tempa[j]=RoundKey[(i-1) * 4 + j]; - } - if (i % Nk == 0) - { - // This function rotates the 4 bytes in a word to the left once. - // [a0,a1,a2,a3] becomes [a1,a2,a3,a0] - - // Function RotWord() - { - k = tempa[0]; - tempa[0] = tempa[1]; - tempa[1] = tempa[2]; - tempa[2] = tempa[3]; - tempa[3] = k; - } - - // SubWord() is a function that takes a four-byte input word and - // applies the S-box to each of the four bytes to produce an output word. - - // Function Subword() - { - tempa[0] = getSBoxValue(tempa[0]); - tempa[1] = getSBoxValue(tempa[1]); - tempa[2] = getSBoxValue(tempa[2]); - tempa[3] = getSBoxValue(tempa[3]); - } - - tempa[0] = tempa[0] ^ Rcon[i/Nk]; - } - else if (Nk > 6 && i % Nk == 4) - { - // Function Subword() - { - tempa[0] = getSBoxValue(tempa[0]); - tempa[1] = getSBoxValue(tempa[1]); - tempa[2] = getSBoxValue(tempa[2]); - tempa[3] = getSBoxValue(tempa[3]); - } - } - RoundKey[i * 4 + 0] = RoundKey[(i - Nk) * 4 + 0] ^ tempa[0]; - RoundKey[i * 4 + 1] = RoundKey[(i - Nk) * 4 + 1] ^ tempa[1]; - RoundKey[i * 4 + 2] = RoundKey[(i - Nk) * 4 + 2] ^ tempa[2]; - RoundKey[i * 4 + 3] = RoundKey[(i - Nk) * 4 + 3] ^ tempa[3]; - } -} - -// This function adds the round key to state. -// The round key is added to the state by an XOR function. -static void AddRoundKey(uint8_t round) -{ - uint8_t i,j; - for(i=0;i<4;++i) - { - for(j = 0; j < 4; ++j) - { - (*state)[i][j] ^= RoundKey[round * Nb * 4 + i * Nb + j]; - } - } -} - -// The SubBytes Function Substitutes the values in the -// state matrix with values in an S-box. -static void SubBytes(void) -{ - uint8_t i, j; - for(i = 0; i < 4; ++i) - { - for(j = 0; j < 4; ++j) - { - (*state)[j][i] = getSBoxValue((*state)[j][i]); - } - } -} - -// The ShiftRows() function shifts the rows in the state to the left. -// Each row is shifted with different offset. -// Offset = Row number. So the first row is not shifted. -static void ShiftRows(void) -{ - uint8_t temp; - - // Rotate first row 1 columns to left - temp = (*state)[0][1]; - (*state)[0][1] = (*state)[1][1]; - (*state)[1][1] = (*state)[2][1]; - (*state)[2][1] = (*state)[3][1]; - (*state)[3][1] = temp; - - // Rotate second row 2 columns to left - temp = (*state)[0][2]; - (*state)[0][2] = (*state)[2][2]; - (*state)[2][2] = temp; - - temp = (*state)[1][2]; - (*state)[1][2] = (*state)[3][2]; - (*state)[3][2] = temp; - - // Rotate third row 3 columns to left - temp = (*state)[0][3]; - (*state)[0][3] = (*state)[3][3]; - (*state)[3][3] = (*state)[2][3]; - (*state)[2][3] = (*state)[1][3]; - (*state)[1][3] = temp; -} - -static uint8_t xtime(uint8_t x) -{ - return ((x<<1) ^ (((x>>7) & 1) * 0x1b)); -} - -// MixColumns function mixes the columns of the state matrix -static void MixColumns(void) -{ - uint8_t i; - uint8_t Tmp,Tm,t; - for(i = 0; i < 4; ++i) - { - t = (*state)[i][0]; - Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ; - Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ; - Tm = (*state)[i][1] ^ (*state)[i][2] ; Tm = xtime(Tm); (*state)[i][1] ^= Tm ^ Tmp ; - Tm = (*state)[i][2] ^ (*state)[i][3] ; Tm = xtime(Tm); (*state)[i][2] ^= Tm ^ Tmp ; - Tm = (*state)[i][3] ^ t ; Tm = xtime(Tm); (*state)[i][3] ^= Tm ^ Tmp ; - } -} - -// Multiply is used to multiply numbers in the field GF(2^8) -#if MULTIPLY_AS_A_FUNCTION -static uint8_t Multiply(uint8_t x, uint8_t y) -{ - return (((y & 1) * x) ^ - ((y>>1 & 1) * xtime(x)) ^ - ((y>>2 & 1) * xtime(xtime(x))) ^ - ((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ - ((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))); - } -#else -#define Multiply(x, y) \ - ( ((y & 1) * x) ^ \ - ((y>>1 & 1) * xtime(x)) ^ \ - ((y>>2 & 1) * xtime(xtime(x))) ^ \ - ((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ \ - ((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))) \ - -#endif - -// MixColumns function mixes the columns of the state matrix. -// The method used to multiply may be difficult to understand for the inexperienced. -// Please use the references to gain more information. -static void InvMixColumns(void) -{ - int i; - uint8_t a,b,c,d; - for(i=0;i<4;++i) - { - a = (*state)[i][0]; - b = (*state)[i][1]; - c = (*state)[i][2]; - d = (*state)[i][3]; - - (*state)[i][0] = Multiply(a, 0x0e) ^ Multiply(b, 0x0b) ^ Multiply(c, 0x0d) ^ Multiply(d, 0x09); - (*state)[i][1] = Multiply(a, 0x09) ^ Multiply(b, 0x0e) ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d); - (*state)[i][2] = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b); - (*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e); - } -} - - -// The SubBytes Function Substitutes the values in the -// state matrix with values in an S-box. -static void InvSubBytes(void) -{ - uint8_t i,j; - for(i=0;i<4;++i) - { - for(j=0;j<4;++j) - { - (*state)[j][i] = getSBoxInvert((*state)[j][i]); - } - } -} - -static void InvShiftRows(void) -{ - uint8_t temp; - - // Rotate first row 1 columns to right - temp=(*state)[3][1]; - (*state)[3][1]=(*state)[2][1]; - (*state)[2][1]=(*state)[1][1]; - (*state)[1][1]=(*state)[0][1]; - (*state)[0][1]=temp; - - // Rotate second row 2 columns to right - temp=(*state)[0][2]; - (*state)[0][2]=(*state)[2][2]; - (*state)[2][2]=temp; - - temp=(*state)[1][2]; - (*state)[1][2]=(*state)[3][2]; - (*state)[3][2]=temp; - - // Rotate third row 3 columns to right - temp=(*state)[0][3]; - (*state)[0][3]=(*state)[1][3]; - (*state)[1][3]=(*state)[2][3]; - (*state)[2][3]=(*state)[3][3]; - (*state)[3][3]=temp; -} - - -// Cipher is the main function that encrypts the PlainText. -static void Cipher(void) -{ - uint8_t round = 0; - - // Add the First round key to the state before starting the rounds. - AddRoundKey(0); - - // There will be Nr rounds. - // The first Nr-1 rounds are identical. - // These Nr-1 rounds are executed in the loop below. - for(round = 1; round < Nr; ++round) - { - SubBytes(); - ShiftRows(); - MixColumns(); - AddRoundKey(round); - } - - // The last round is given below. - // The MixColumns function is not here in the last round. - SubBytes(); - ShiftRows(); - AddRoundKey(Nr); -} - -static void InvCipher(void) -{ - uint8_t round=0; - - // Add the First round key to the state before starting the rounds. - AddRoundKey(Nr); - - // There will be Nr rounds. - // The first Nr-1 rounds are identical. - // These Nr-1 rounds are executed in the loop below. - for(round=Nr-1;round>0;round--) - { - InvShiftRows(); - InvSubBytes(); - AddRoundKey(round); - InvMixColumns(); - } - - // The last round is given below. - // The MixColumns function is not here in the last round. - InvShiftRows(); - InvSubBytes(); - AddRoundKey(0); -} - -static void BlockCopy(uint8_t* output, uint8_t* input) -{ - uint8_t i; - for (i=0;i - - -// #define the macros below to 1/0 to enable/disable the mode of operation. -// -// CBC enables AES128 encryption in CBC-mode of operation and handles 0-padding. -// ECB enables the basic ECB 16-byte block algorithm. Both can be enabled simultaneously. - -// The #ifndef-guard allows it to be configured before #include'ing or at compile time. -#ifndef CBC - #define CBC 1 -#endif - -#ifndef ECB - #define ECB 1 -#endif - - - -#if defined(ECB) && ECB - -void AES128_ECB_encrypt(uint8_t* input, const uint8_t* key, uint8_t *output); -void AES128_ECB_decrypt(uint8_t* input, const uint8_t* key, uint8_t *output); - -#endif // #if defined(ECB) && ECB - - -#if defined(CBC) && CBC - -void AES128_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv); -void AES128_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv); - -#endif // #if defined(CBC) && CBC - - - -#endif //_AES_H_ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/origin.txt b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/origin.txt deleted file mode 100644 index 874b35c..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/origin.txt +++ /dev/null @@ -1 +0,0 @@ -https://github.com/kokke/tiny-AES128-C \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/unlicense.txt b/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/unlicense.txt deleted file mode 100644 index 00d2e13..0000000 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/tiny-AES128/unlicense.txt +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.c new file mode 100644 index 0000000..6f7a389 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.c @@ -0,0 +1,813 @@ +/** + * Copyright (c) 2015 - 2019, 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(BLE_ADVERTISING) +#include "ble_advdata.h" +#include "ble_advertising.h" +#include "nrf_soc.h" +#include "nrf_log.h" +#include "sdk_errors.h" +#include "nrf_sdh_ble.h" + +#define BLE_ADV_MODES (5) /**< Total number of possible advertising modes. */ + + +/**@brief Function for checking if the whitelist is in use. + * + * @param[in] p_advertising Advertising module instance. + */ +static bool whitelist_has_entries(ble_advertising_t * const p_advertising) +{ + return p_advertising->whitelist_in_use; +} + + +/**@brief Function for checking if an address is valid. + * + * @param[in] p_addr Pointer to a bluetooth address. + */ +static bool addr_is_valid(uint8_t const * const p_addr) +{ + for (uint32_t i = 0; i < BLE_GAP_ADDR_LEN; i++) + { + if (p_addr[i] != 0) + { + return true; + } + } + return false; +} + + +/**@brief Function for checking the next advertising mode. + * + * @param[in] adv_mode Current advertising mode. + */ +static ble_adv_mode_t adv_mode_next_get(ble_adv_mode_t adv_mode) +{ + return (ble_adv_mode_t)((adv_mode + 1) % BLE_ADV_MODES); +} + + +/**@brief Function for handling the Connected event. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_connected(ble_advertising_t * const p_advertising, ble_evt_t const * p_ble_evt) +{ + if (p_ble_evt->evt.gap_evt.params.connected.role == BLE_GAP_ROLE_PERIPH) + { + p_advertising->current_slave_link_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + } +} + + +/**@brief Function for handling the Disconnected event. + * + * @param[in] p_advertising Advertising module instance. + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_disconnected(ble_advertising_t * const p_advertising, ble_evt_t const * p_ble_evt) +{ + uint32_t ret; + + p_advertising->whitelist_temporarily_disabled = false; + + if (p_ble_evt->evt.gap_evt.conn_handle == p_advertising->current_slave_link_conn_handle && + p_advertising->adv_modes_config.ble_adv_on_disconnect_disabled == false) + { + ret = ble_advertising_start(p_advertising, BLE_ADV_MODE_DIRECTED_HIGH_DUTY); + if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) + { + p_advertising->error_handler(ret); + } + } +} + + +/**@brief Function for handling the Timeout event. + * + * @param[in] p_advertising Advertising module instance. + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_terminated(ble_advertising_t * const p_advertising, ble_evt_t const * p_ble_evt) +{ + ret_code_t ret; + + if (p_ble_evt->header.evt_id != BLE_GAP_EVT_ADV_SET_TERMINATED) + { + // Nothing to do. + return; + } + + if ( p_ble_evt->evt.gap_evt.params.adv_set_terminated.reason == BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT + ||p_ble_evt->evt.gap_evt.params.adv_set_terminated.reason == BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_LIMIT_REACHED) + { + // Start advertising in the next mode. + ret = ble_advertising_start(p_advertising, adv_mode_next_get(p_advertising->adv_mode_current)); + + if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) + { + p_advertising->error_handler(ret); + } + } +} + + +/**@brief Get the next available advertising mode. + * + * @param[in] p_advertising Advertising module instance. + * @param[in] adv_mode Requested advertising mode. + * + * @returns adv_mode if possible, or the best available mode if not. + */ +static ble_adv_mode_t adv_mode_next_avail_get(ble_advertising_t * const p_advertising, + ble_adv_mode_t adv_mode) +{ + bool peer_addr_is_valid = addr_is_valid(p_advertising->peer_address.addr); + + // If a mode is disabled, continue to the next mode. + + switch (adv_mode) + { + case BLE_ADV_MODE_DIRECTED_HIGH_DUTY: + if ( (p_advertising->adv_modes_config.ble_adv_directed_high_duty_enabled) + && (!p_advertising->adv_modes_config.ble_adv_extended_enabled) + && (peer_addr_is_valid)) + { + return BLE_ADV_MODE_DIRECTED_HIGH_DUTY; + } + // Fallthrough. + + case BLE_ADV_MODE_DIRECTED: + if ((p_advertising->adv_modes_config.ble_adv_directed_enabled) && peer_addr_is_valid) + { + return BLE_ADV_MODE_DIRECTED; + } + // Fallthrough. + + case BLE_ADV_MODE_FAST: + if (p_advertising->adv_modes_config.ble_adv_fast_enabled) + { + return BLE_ADV_MODE_FAST; + } + // Fallthrough. + + case BLE_ADV_MODE_SLOW: + if (p_advertising->adv_modes_config.ble_adv_slow_enabled) + { + return BLE_ADV_MODE_SLOW; + } + // Fallthrough. + + default: + return BLE_ADV_MODE_IDLE; + } +} + + +/**@brief Function for starting high duty directed advertising. + * + * @param[in] p_advertising Advertising instance. + * @param[out] p_adv_params Advertising parameters. + * + * @return NRF_SUCCESS + */ +static ret_code_t set_adv_mode_directed_high_duty(ble_advertising_t * const p_advertising, + ble_gap_adv_params_t * p_adv_params) +{ + p_advertising->adv_evt = BLE_ADV_EVT_DIRECTED_HIGH_DUTY; + p_advertising->p_adv_data = NULL; + + p_adv_params->p_peer_addr = &(p_advertising->peer_address); + p_adv_params->interval = 0; + p_adv_params->properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE; + p_adv_params->duration = BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX; + + return NRF_SUCCESS; +} + + +/**@brief Function for starting directed slow advertising. + * + * @param[in] p_advertising Advertising module instance. + * @param[out] p_adv_params Advertising parameters. + * + * @return NRF_SUCCESS + */ +static ret_code_t set_adv_mode_directed(ble_advertising_t * const p_advertising, + ble_gap_adv_params_t * p_adv_params) +{ + p_advertising->adv_evt = BLE_ADV_EVT_DIRECTED; +#if !defined (S112) && !defined(S312) && !defined(S113) + if (p_advertising->adv_modes_config.ble_adv_extended_enabled) + { + p_adv_params->properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_DIRECTED; + } + else + { +#endif // !defined (S112) && !defined(S312) + p_adv_params->properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED; +#if !defined (S112) && !defined(S312) && !defined(S113) + } +#endif // !defined (S112) && !defined(S312) && !defined(S113) + p_adv_params->duration = p_advertising->adv_modes_config.ble_adv_directed_timeout; + + p_advertising->p_adv_data = NULL; + + p_adv_params->p_peer_addr = &p_advertising->peer_address; + p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_directed_interval; + + return NRF_SUCCESS; +} + + +/**@brief Function for indicating whether to use whitelist for advertising. + * + * @param[in] p_advertising Advertising module instance. + * + * @return Whether to use whitelist. + */ +static bool use_whitelist(ble_advertising_t * const p_advertising) +{ + return((p_advertising->adv_modes_config.ble_adv_whitelist_enabled) && + (!p_advertising->whitelist_temporarily_disabled) && + (whitelist_has_entries(p_advertising))); +} + + +/**@brief Function for setting new advertising flags in the advertising parameters. + * + * @param[in] p_advertising Advertising module instance. + * @param[in] flags New flags. + * + * @return Any error from @ref sd_ble_gap_adv_set_configure. + */ +static ret_code_t flags_set(ble_advertising_t * const p_advertising, uint8_t flags) +{ + uint8_t * p_flags = ble_advdata_parse(p_advertising->adv_data.adv_data.p_data, + p_advertising->adv_data.adv_data.len, + BLE_GAP_AD_TYPE_FLAGS); + + if (p_flags != NULL) + { + *p_flags = flags; + } + + return sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, &p_advertising->adv_data, &p_advertising->adv_params); +} + + +/**@brief Function for starting fast advertising. + * + * @param[in] p_advertising Advertising module instance. + * @param[out] p_adv_params Advertising parameters. + * + * @return NRF_SUCCESS or an error from @ref flags_set(). + */ +static ret_code_t set_adv_mode_fast(ble_advertising_t * const p_advertising, + ble_gap_adv_params_t * p_adv_params) +{ + ret_code_t ret; + + p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_fast_interval; + p_adv_params->duration = p_advertising->adv_modes_config.ble_adv_fast_timeout; + +#if !defined (S112) && !defined(S312) && !defined(S113) + if (p_advertising->adv_modes_config.ble_adv_extended_enabled) + { + p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED; + } + else + { +#endif // !defined (S112) && !defined(S312) && !defined(S113) + p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; +#if !defined (S112) && !defined(S312) && !defined(S113) + } +#endif // !defined (S112) && !defined(S312) && !defined(S113) + + if (use_whitelist(p_advertising)) + { + p_adv_params->filter_policy = BLE_GAP_ADV_FP_FILTER_CONNREQ; + + // Set correct flags. + ret = flags_set(p_advertising, BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED); + VERIFY_SUCCESS(ret); + + p_advertising->adv_evt = BLE_ADV_EVT_FAST_WHITELIST; + } + else + { + p_advertising->adv_evt = BLE_ADV_EVT_FAST; + } + p_advertising->p_adv_data = &(p_advertising->adv_data); + return NRF_SUCCESS; +} + + +/**@brief Function for starting slow advertising. + * + * @param[in] p_advertising Advertising module instance. + * @param[out] p_adv_params Advertising parameters. + * + * @return NRF_SUCCESS or an error from @ref flags_set(). + */ +static ret_code_t set_adv_mode_slow(ble_advertising_t * const p_advertising, + ble_gap_adv_params_t * p_adv_params) +{ + ret_code_t ret; + + p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_slow_interval; + p_adv_params->duration = p_advertising->adv_modes_config.ble_adv_slow_timeout; + +#if !defined (S112) && !defined(S312) && !defined(S113) + if (p_advertising->adv_modes_config.ble_adv_extended_enabled) + { + p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED; + } + else + { +#endif // !defined (S112) && !defined(S312) && !defined(S113) + p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; +#if !defined (S112) && !defined(S312) && !defined(S113) + } +#endif // !defined (S112) && !defined(S312) && !defined(S113) + + if (use_whitelist(p_advertising)) + { + p_adv_params->filter_policy = BLE_GAP_ADV_FP_FILTER_CONNREQ; + + // Set correct flags. + ret = flags_set(p_advertising, BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED); + VERIFY_SUCCESS(ret); + + p_advertising->adv_evt = BLE_ADV_EVT_SLOW_WHITELIST; + } + else + { + p_advertising->adv_evt = BLE_ADV_EVT_SLOW; + } + p_advertising->p_adv_data = &(p_advertising->adv_data); + return NRF_SUCCESS; +} + + +/**@brief Function for checking if an advertising module configuration is legal. + * + * @details Advertising module can not be initialized if high duty directed advertising is used + * together with extended advertising. + * + * @param[in] p_config Pointer to the configuration. + * + * @return True If the configuration is valid. + * @return False If the configuration is invalid. + */ +static bool config_is_valid(ble_adv_modes_config_t const * const p_config) +{ + if ((p_config->ble_adv_directed_high_duty_enabled == true) && + (p_config->ble_adv_extended_enabled == true)) + { + return false; + } +#if !defined (S140) + else if ( p_config->ble_adv_primary_phy == BLE_GAP_PHY_CODED || + p_config->ble_adv_secondary_phy == BLE_GAP_PHY_CODED) + { + return false; + } +#endif // !defined (S140) + else + { + return true; + } +} + + +/**@brief Function for getting the maximum size of the advertising data buffer. + * + * @param[in] p_advertising Advertising module instance. + * + * @returns The maximum size of the advertising data buffer. + */ +static uint16_t adv_set_data_size_max_get(ble_advertising_t const * const p_advertising) +{ + uint16_t adv_set_data_size_max; + + if (p_advertising->adv_modes_config.ble_adv_extended_enabled == true) + { +#ifdef BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED + adv_set_data_size_max = BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED; +#else + adv_set_data_size_max = BLE_GAP_ADV_SET_DATA_SIZE_MAX; +#endif // BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED + } + else + { + adv_set_data_size_max = BLE_GAP_ADV_SET_DATA_SIZE_MAX; + } + + return adv_set_data_size_max; +} + + +void ble_advertising_conn_cfg_tag_set(ble_advertising_t * const p_advertising, + uint8_t ble_cfg_tag) +{ + p_advertising->conn_cfg_tag = ble_cfg_tag; +} + + +uint32_t ble_advertising_init(ble_advertising_t * const p_advertising, + ble_advertising_init_t const * const p_init) +{ + uint32_t ret; + if ((p_init == NULL) || (p_advertising == NULL)) + { + return NRF_ERROR_NULL; + } + if (!config_is_valid(&p_init->config)) + { + return NRF_ERROR_INVALID_PARAM; + } + + p_advertising->adv_mode_current = BLE_ADV_MODE_IDLE; + p_advertising->adv_modes_config = p_init->config; + p_advertising->conn_cfg_tag = BLE_CONN_CFG_TAG_DEFAULT; + p_advertising->evt_handler = p_init->evt_handler; + p_advertising->error_handler = p_init->error_handler; + p_advertising->current_slave_link_conn_handle = BLE_CONN_HANDLE_INVALID; + p_advertising->p_adv_data = &p_advertising->adv_data; + + memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address)); + + // Copy advertising data. + if (!p_advertising->initialized) + { + p_advertising->adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; + } + p_advertising->adv_data.adv_data.p_data = p_advertising->enc_advdata[0]; + p_advertising->adv_data.adv_data.len = adv_set_data_size_max_get(p_advertising); + + ret = ble_advdata_encode(&p_init->advdata, p_advertising->enc_advdata[0], &p_advertising->adv_data.adv_data.len); + VERIFY_SUCCESS(ret); + + p_advertising->adv_data.scan_rsp_data.p_data = p_advertising->enc_scan_rsp_data[0]; + p_advertising->adv_data.scan_rsp_data.len = adv_set_data_size_max_get(p_advertising); + + ret = ble_advdata_encode(&p_init->srdata, + p_advertising->adv_data.scan_rsp_data.p_data, + &p_advertising->adv_data.scan_rsp_data.len); + VERIFY_SUCCESS(ret); + + // Configure a initial advertising configuration. The advertising data and and advertising + // parameters will be changed later when we call @ref ble_advertising_start, but must be set + // to legal values here to define an advertising handle. + p_advertising->adv_params.primary_phy = BLE_GAP_PHY_1MBPS; + p_advertising->adv_params.duration = p_advertising->adv_modes_config.ble_adv_fast_timeout; + p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + p_advertising->adv_params.p_peer_addr = NULL; + p_advertising->adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; + p_advertising->adv_params.interval = p_advertising->adv_modes_config.ble_adv_fast_interval; + + ret = sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, NULL, &p_advertising->adv_params); + VERIFY_SUCCESS(ret); + + p_advertising->initialized = true; + return ret; +} + + +/**@brief Function for checking that a phy define value matches one of the valid phys from the SD. + * + * @param[in] PHY to be validated. + * + * @retval true If the PHY value is valid (1mbit, 2mbit, coded). + * @retval false If the PHY value is invalid. + */ +static bool phy_is_valid(uint32_t const * const p_phy) +{ + if ((*p_phy) == BLE_GAP_PHY_1MBPS || + (*p_phy) == BLE_GAP_PHY_2MBPS +#if defined (S140) + || (*p_phy) == BLE_GAP_PHY_CODED +#endif // !defined (S140) + ) + { + return true; + } + else + { + return false; + } +} + + +uint32_t ble_advertising_start(ble_advertising_t * const p_advertising, + ble_adv_mode_t advertising_mode) +{ + uint32_t ret; + + if (p_advertising->initialized == false) + { + return NRF_ERROR_INVALID_STATE; + } + + p_advertising->adv_mode_current = advertising_mode; + + memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address)); + + if ( ((p_advertising->adv_modes_config.ble_adv_directed_high_duty_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED_HIGH_DUTY)) + ||((p_advertising->adv_modes_config.ble_adv_directed_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED_HIGH_DUTY)) + ||((p_advertising->adv_modes_config.ble_adv_directed_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED)) + ) + { + if (p_advertising->evt_handler != NULL) + { + p_advertising->peer_addr_reply_expected = true; + p_advertising->evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST); + } + else + { + p_advertising->peer_addr_reply_expected = false; + } + } + + p_advertising->adv_mode_current = adv_mode_next_avail_get(p_advertising, advertising_mode); + + // Fetch the whitelist. + if ((p_advertising->evt_handler != NULL) && + (p_advertising->adv_mode_current == BLE_ADV_MODE_FAST || p_advertising->adv_mode_current == BLE_ADV_MODE_SLOW) && + (p_advertising->adv_modes_config.ble_adv_whitelist_enabled) && + (!p_advertising->whitelist_temporarily_disabled)) + { + p_advertising->whitelist_in_use = false; + p_advertising->whitelist_reply_expected = true; + p_advertising->evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST); + } + else + { + p_advertising->whitelist_reply_expected = false; + } + + // Initialize advertising parameters with default values. + memset(&p_advertising->adv_params, 0, sizeof(p_advertising->adv_params)); + + p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + + // Use 1MBIT as primary phy if no phy was selected. + if (phy_is_valid(&p_advertising->adv_modes_config.ble_adv_primary_phy)) + { + p_advertising->adv_params.primary_phy = p_advertising->adv_modes_config.ble_adv_primary_phy; + } + else + { + p_advertising->adv_params.primary_phy = BLE_GAP_PHY_1MBPS; + } + + if (p_advertising->adv_modes_config.ble_adv_extended_enabled) + { + // Use 1MBIT as secondary phy if no phy was selected. + if (phy_is_valid(&p_advertising->adv_modes_config.ble_adv_secondary_phy)) + { + p_advertising->adv_params.secondary_phy = p_advertising->adv_modes_config.ble_adv_secondary_phy; + } + else + { + p_advertising->adv_params.secondary_phy = BLE_GAP_PHY_1MBPS; + } + } + p_advertising->adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; + + // Set advertising parameters and events according to selected advertising mode. + switch (p_advertising->adv_mode_current) + { + case BLE_ADV_MODE_DIRECTED_HIGH_DUTY: + ret = set_adv_mode_directed_high_duty(p_advertising, &p_advertising->adv_params); + break; + + case BLE_ADV_MODE_DIRECTED: + ret = set_adv_mode_directed(p_advertising, &p_advertising->adv_params); + break; + + case BLE_ADV_MODE_FAST: + ret = set_adv_mode_fast(p_advertising, &p_advertising->adv_params); + break; + + case BLE_ADV_MODE_SLOW: + ret = set_adv_mode_slow(p_advertising, &p_advertising->adv_params); + break; + + case BLE_ADV_MODE_IDLE: + p_advertising->adv_evt = BLE_ADV_EVT_IDLE; + break; + + default: + break; + } + + if (p_advertising->adv_mode_current != BLE_ADV_MODE_IDLE) + { + + ret = sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, p_advertising->p_adv_data, &p_advertising->adv_params); + if (ret != NRF_SUCCESS) + { + return ret; + } + ret = sd_ble_gap_adv_start(p_advertising->adv_handle, p_advertising->conn_cfg_tag); + + if (ret != NRF_SUCCESS) + { + return ret; + } + } + + if (p_advertising->evt_handler != NULL) + { + p_advertising->evt_handler(p_advertising->adv_evt); + } + + return NRF_SUCCESS; +} + + +void ble_advertising_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) +{ + ble_advertising_t * p_advertising = (ble_advertising_t *)p_context; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + on_connected(p_advertising, p_ble_evt); + break; + + // Upon disconnection, whitelist will be activated and direct advertising is started. + case BLE_GAP_EVT_DISCONNECTED: + on_disconnected(p_advertising, p_ble_evt); + break; + + // Upon terminated advertising (time-out), the next advertising mode is started. + case BLE_GAP_EVT_ADV_SET_TERMINATED: + on_terminated(p_advertising, p_ble_evt); + break; + + default: + break; + } +} + + +uint32_t ble_advertising_peer_addr_reply(ble_advertising_t * const p_advertising, + ble_gap_addr_t * p_peer_address) +{ + if (!p_advertising->peer_addr_reply_expected) + { + return NRF_ERROR_INVALID_STATE; + } + + p_advertising->peer_addr_reply_expected = false; + + memcpy(&p_advertising->peer_address, p_peer_address, sizeof(p_advertising->peer_address)); + + return NRF_SUCCESS; +} + + +uint32_t ble_advertising_whitelist_reply(ble_advertising_t * const p_advertising, + ble_gap_addr_t const * p_gap_addrs, + uint32_t addr_cnt, + ble_gap_irk_t const * p_gap_irks, + uint32_t irk_cnt) +{ + if (!p_advertising->whitelist_reply_expected) + { + return NRF_ERROR_INVALID_STATE; + } + + p_advertising->whitelist_reply_expected = false; + p_advertising->whitelist_in_use = ((addr_cnt > 0) || (irk_cnt > 0)); + + return NRF_SUCCESS; +} + + +uint32_t ble_advertising_restart_without_whitelist(ble_advertising_t * const p_advertising) +{ + ret_code_t ret; + + (void) sd_ble_gap_adv_stop(p_advertising->adv_handle); + + p_advertising->whitelist_temporarily_disabled = true; + p_advertising->whitelist_in_use = false; + p_advertising->adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; + // Set correct flags. + ret = flags_set(p_advertising, BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); + VERIFY_SUCCESS(ret); + + ret = ble_advertising_start(p_advertising, p_advertising->adv_mode_current); + if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL)) + { + p_advertising->error_handler(ret); + } + + return NRF_SUCCESS; +} + + +void ble_advertising_modes_config_set(ble_advertising_t * const p_advertising, + ble_adv_modes_config_t const * const p_adv_modes_config) +{ + p_advertising->adv_modes_config = *p_adv_modes_config; +} + + +ret_code_t ble_advertising_advdata_update(ble_advertising_t * const p_advertising, + ble_advdata_t const * const p_advdata, + ble_advdata_t const * const p_srdata) +{ + VERIFY_PARAM_NOT_NULL(p_advertising); + if (p_advertising->initialized == false) + { + return NRF_ERROR_INVALID_STATE; + } + + if ((p_advdata == NULL) && (p_srdata == NULL)) + { + return NRF_ERROR_NULL; + } + + ble_gap_adv_data_t new_adv_data; + memset(&new_adv_data, 0, sizeof(new_adv_data)); + + if (p_advdata != NULL) + { + new_adv_data.adv_data.p_data = + (p_advertising->p_adv_data->adv_data.p_data != p_advertising->enc_advdata[0]) ? + p_advertising->enc_advdata[0] : p_advertising->enc_advdata[1]; + new_adv_data.adv_data.len = adv_set_data_size_max_get(p_advertising); + + ret_code_t ret = ble_advdata_encode(p_advdata, + new_adv_data.adv_data.p_data, + &new_adv_data.adv_data.len); + VERIFY_SUCCESS(ret); + } + + if (p_srdata != NULL) + { + new_adv_data.scan_rsp_data.p_data = + (p_advertising->p_adv_data->scan_rsp_data.p_data != p_advertising->enc_scan_rsp_data[0]) ? + p_advertising->enc_scan_rsp_data[0] : p_advertising->enc_scan_rsp_data[1]; + new_adv_data.scan_rsp_data.len = adv_set_data_size_max_get(p_advertising); + + ret_code_t ret = ble_advdata_encode(p_srdata, + new_adv_data.scan_rsp_data.p_data, + &new_adv_data.scan_rsp_data.len); + VERIFY_SUCCESS(ret); + } + + memcpy(&p_advertising->adv_data, &new_adv_data, sizeof(p_advertising->adv_data)); + p_advertising->p_adv_data = &p_advertising->adv_data; + + return sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, + p_advertising->p_adv_data, + NULL); +} + + +#endif // NRF_MODULE_ENABLED(BLE_ADVERTISING) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.h index 4e1e199..8dc165a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_advertising/ble_advertising.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_advertising/ble_advertising.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -59,6 +59,7 @@ #include #include "nrf_error.h" #include "ble.h" +#include "ble_gap.h" #include "ble_gattc.h" #include "ble_advdata.h" @@ -75,20 +76,17 @@ extern "C" { static ble_advertising_t _name; \ NRF_SDH_BLE_OBSERVER(_name ## _ble_obs, \ BLE_ADV_BLE_OBSERVER_PRIO, \ - ble_advertising_on_ble_evt, &_name); \ -NRF_SDH_SOC_OBSERVER(_name ## _soc_obs, \ - BLE_ADV_SOC_OBSERVER_PRIO, \ - ble_advertising_on_sys_evt, &_name) + ble_advertising_on_ble_evt, &_name) /**@brief Advertising modes. */ typedef enum { - BLE_ADV_MODE_IDLE, /**< Idle; no connectable advertising is ongoing. */ - BLE_ADV_MODE_DIRECTED, /**< Directed advertising attempts to connect to the most recently disconnected peer. */ - BLE_ADV_MODE_DIRECTED_SLOW, /**< Directed advertising (low duty cycle) attempts to connect to the most recently disconnected peer. */ - BLE_ADV_MODE_FAST, /**< Fast advertising will connect to any peer device, or filter with a whitelist if one exists. */ - BLE_ADV_MODE_SLOW, /**< Slow advertising is similar to fast advertising. By default, it uses a longer advertising interval and time-out than fast advertising. However, these options are defined by the user. */ + BLE_ADV_MODE_IDLE, /**< Idle; no connectable advertising is ongoing. */ + BLE_ADV_MODE_DIRECTED_HIGH_DUTY, /**< Directed advertising (high duty cycle) attempts to connect to the most recently disconnected peer. */ + BLE_ADV_MODE_DIRECTED, /**< Directed advertising (low duty cycle) attempts to connect to the most recently disconnected peer. */ + BLE_ADV_MODE_FAST, /**< Fast advertising will connect to any peer device, or filter with a whitelist if one exists. */ + BLE_ADV_MODE_SLOW, /**< Slow advertising is similar to fast advertising. By default, it uses a longer advertising interval and time-out than fast advertising. However, these options are defined by the user. */ } ble_adv_mode_t; /**@brief Advertising events. @@ -101,8 +99,8 @@ typedef enum typedef enum { BLE_ADV_EVT_IDLE, /**< Idle; no connectable advertising is ongoing.*/ - BLE_ADV_EVT_DIRECTED, /**< Direct advertising mode has started. */ - BLE_ADV_EVT_DIRECTED_SLOW, /**< Directed advertising (low duty cycle) has started. */ + BLE_ADV_EVT_DIRECTED_HIGH_DUTY, /**< Direct advertising mode has started. */ + BLE_ADV_EVT_DIRECTED, /**< Directed advertising (low duty cycle) has started. */ BLE_ADV_EVT_FAST, /**< Fast advertising mode has started. */ BLE_ADV_EVT_SLOW, /**< Slow advertising mode has started. */ BLE_ADV_EVT_FAST_WHITELIST, /**< Fast advertising mode using the whitelist has started. */ @@ -118,18 +116,21 @@ typedef enum */ typedef struct { - bool ble_adv_on_disconnect_disabled; /**< Enable or disable automatic return to advertising upon disconnecting.*/ - bool ble_adv_whitelist_enabled; /**< Enable or disable use of the whitelist. */ - bool ble_adv_directed_enabled; /**< Enable or disable direct advertising mode. */ - bool ble_adv_directed_slow_enabled; /**< Enable or disable direct advertising mode. */ - bool ble_adv_fast_enabled; /**< Enable or disable fast advertising mode. */ - bool ble_adv_slow_enabled; /**< Enable or disable slow advertising mode. */ - uint32_t ble_adv_directed_slow_interval; /**< Advertising interval for directed advertising. */ - uint32_t ble_adv_directed_slow_timeout; /**< Time-out (number of tries) for direct advertising. */ - uint32_t ble_adv_fast_interval; /**< Advertising interval for fast advertising. */ - uint32_t ble_adv_fast_timeout; /**< Time-out (in seconds) for fast advertising. */ - uint32_t ble_adv_slow_interval; /**< Advertising interval for slow advertising. */ - uint32_t ble_adv_slow_timeout; /**< Time-out (in seconds) for slow advertising. */ + bool ble_adv_on_disconnect_disabled; /**< Enable or disable automatic return to advertising upon disconnecting.*/ + bool ble_adv_whitelist_enabled; /**< Enable or disable use of the whitelist. */ + bool ble_adv_directed_high_duty_enabled; /**< Enable or disable high duty direct advertising mode. Can not be used together with extended advertising. */ + bool ble_adv_directed_enabled; /**< Enable or disable direct advertising mode. */ + bool ble_adv_fast_enabled; /**< Enable or disable fast advertising mode. */ + bool ble_adv_slow_enabled; /**< Enable or disable slow advertising mode. */ + uint32_t ble_adv_directed_interval; /**< Advertising interval for directed advertising. */ + uint32_t ble_adv_directed_timeout; /**< Time-out (number of tries) for direct advertising. */ + uint32_t ble_adv_fast_interval; /**< Advertising interval for fast advertising. */ + uint32_t ble_adv_fast_timeout; /**< Time-out (in units of 10ms) for fast advertising. */ + uint32_t ble_adv_slow_interval; /**< Advertising interval for slow advertising. */ + uint32_t ble_adv_slow_timeout; /**< Time-out (in units of 10ms) for slow advertising. */ + bool ble_adv_extended_enabled; /**< Enable or disable extended advertising. */ + uint32_t ble_adv_secondary_phy; /**< PHY for the secondary (extended) advertising @ref BLE_GAP_PHYS (BLE_GAP_PHY_1MBPS, BLE_GAP_PHY_2MBPS or BLE_GAP_PHY_CODED). */ + uint32_t ble_adv_primary_phy; /**< PHY for the primary advertising. @ref BLE_GAP_PHYS (BLE_GAP_PHY_1MBPS, BLE_GAP_PHY_2MBPS or BLE_GAP_PHY_CODED). */ } ble_adv_modes_config_t; /**@brief BLE advertising event handler type. */ @@ -140,52 +141,36 @@ typedef void (*ble_adv_error_handler_t) (uint32_t nrf_error); typedef struct { - bool initialized; - bool advertising_start_pending; /**< Flag to keep track of ongoing operations in flash. */ - - ble_adv_evt_t adv_evt; /**< Advertising event propogated to the main application. The event is either a transaction to a new advertising mode, or a request for whitelist or peer address. */ - - ble_adv_mode_t adv_mode_current; /**< Variable to keep track of the current advertising mode. */ - ble_adv_modes_config_t adv_modes_config; /**< Struct to keep track of disabled and enabled advertising modes, as well as time-outs and intervals.*/ - uint8_t conn_cfg_tag; /**< Variable to keep track of what connection settings will be used if the advertising results in a connection. */ - - ble_gap_addr_t peer_address; /**< Address of the most recently connected peer, used for direct advertising. */ - bool peer_addr_reply_expected; /**< Flag to verify that peer address is only set when requested. */ - - ble_advdata_t advdata; /**< Used by the initialization function to set name, appearance, and UUIDs and advertising flags visible to peer devices. */ - ble_advdata_manuf_data_t manuf_specific_data; /**< Manufacturer specific data structure*/ - uint8_t manuf_data_array[BLE_GAP_ADV_MAX_SIZE]; /**< Array to store the Manufacturer specific data*/ - ble_advdata_service_data_t service_data; /**< Service data structure. */ - uint8_t service_data_array[BLE_GAP_ADV_MAX_SIZE]; /**< Array to store the service data. */ - ble_advdata_conn_int_t slave_conn_int; /**< Connection interval range structure.*/ - uint16_t current_slave_link_conn_handle; /**< Connection handle for the active link. */ - - ble_adv_evt_handler_t evt_handler; /**< Handler for the advertising events. Can be initialized as NULL if no handling is implemented on in the main application. */ - ble_adv_error_handler_t error_handler; /**< Handler for the advertising error events. */ - - bool whitelist_temporarily_disabled; /**< Flag to keep track of temporary disabling of the whitelist. */ - bool whitelist_reply_expected; - -#if (NRF_SD_BLE_API_VERSION <= 2) - // For SoftDevices v 2.x, this module caches a whitelist which is retrieved from the - // application using an event, and which is passed as a parameter when calling - // sd_ble_gap_adv_start(). - ble_gap_addr_t * p_whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; - ble_gap_irk_t * p_whitelist_irks[BLE_GAP_WHITELIST_IRK_MAX_COUNT]; - ble_gap_addr_t whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; - ble_gap_irk_t whitelist_irks[BLE_GAP_WHITELIST_IRK_MAX_COUNT]; - - ble_gap_whitelist_t m_whitelist = - { - .pp_addrs = p_whitelist_addrs, - .pp_irks = p_whitelist_irks - }; + bool initialized; + bool advertising_start_pending; /**< Flag to keep track of ongoing operations in flash. */ + ble_adv_mode_t adv_mode_current; /**< Variable to keep track of the current advertising mode. */ + ble_adv_modes_config_t adv_modes_config; /**< Struct to keep track of disabled and enabled advertising modes, as well as time-outs and intervals.*/ + uint8_t conn_cfg_tag; /**< Variable to keep track of what connection settings will be used if the advertising results in a connection. */ + + ble_adv_evt_t adv_evt; /**< Advertising event propogated to the main application. The event is either a transaction to a new advertising mode, or a request for whitelist or peer address. */ + ble_adv_evt_handler_t evt_handler; /**< Handler for the advertising events. Can be initialized as NULL if no handling is implemented on in the main application. */ + ble_adv_error_handler_t error_handler; /**< Handler for the advertising error events. */ + + ble_gap_adv_params_t adv_params; /**< GAP advertising parameters. */ + uint8_t adv_handle; /**< Handle for the advertising set. */ + +#ifdef BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED + uint8_t enc_advdata[2][BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED]; /**< Advertising data sets in encoded form. Current and swap buffer. */ + uint8_t enc_scan_rsp_data[2][BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED]; /**< Scan response data sets in encoded form. Current and swap buffer. */ #else - // For SoftDevices v 3.x, this module does not need to cache a whitelist, but it needs to - // be aware of whether or not a whitelist has been set (e.g. using the Peer Manager) - // in order to start advertising with the proper advertising params (filter policy). - bool whitelist_in_use; -#endif + uint8_t enc_advdata[2][BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Current advertising data in encoded form. */ + uint8_t enc_scan_rsp_data[2][BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Current scan response data in encoded form. */ +#endif // BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED + + ble_gap_adv_data_t adv_data; /**< Advertising data. */ + ble_gap_adv_data_t *p_adv_data; /**< Will be set to point to @ref ble_advertising_t::adv_data for undirected advertising, and will be set to NULL for directed advertising. */ + + uint16_t current_slave_link_conn_handle; /**< Connection handle for the active link. */ + ble_gap_addr_t peer_address; /**< Address of the most recently connected peer, used for direct advertising. */ + bool peer_addr_reply_expected; /**< Flag to verify that peer address is only set when requested. */ + bool whitelist_temporarily_disabled; /**< Flag to keep track of temporary disabling of the whitelist. */ + bool whitelist_reply_expected; /**< Flag to verify that the whitelist is only set when requested. */ + bool whitelist_in_use; /**< This module needs to be aware of whether or not a whitelist has been set (e.g. using the Peer Manager) in order to start advertising with the proper advertising params (filter policy). */ } ble_advertising_t; typedef struct @@ -215,37 +200,29 @@ typedef struct * the module to handle BLE events that are relevant for the Advertising Module. * * @param[in] p_ble_evt BLE stack event. - * @param[in] p_adv Advertising module instance. + * @param[in] p_adv Advertising Module instance. */ void ble_advertising_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_adv); -/**@brief Function for handling system events. - * - * @details This function must be called to handle system events that are relevant - * for the Advertising Module. Specifically, the advertising module can not use the - * softdevice as long as there are pending writes to the flash memory. This - * event handler is designed to delay advertising until there is no flash operation. - * - * @param[in] sys_evt System event. - * @param[in] p_adv Advertising module instance. - */ -void ble_advertising_on_sys_evt(uint32_t sys_evt, void * p_adv); - - /**@brief Function for initializing the Advertising Module. * * @details Encodes the required advertising data and passes it to the stack. * Also builds a structure to be passed to the stack when starting advertising. - * The supplied advertising data is copied to a local structure and is manipulated + * Most of the supplied data is copied into a local structure where it is manipulated * depending on what advertising modes are started in @ref ble_advertising_start. + * The exception is advdata_t::uuids_more_available, advdata_t::uuids_complete, and + * advdata_t::uuids_solicited which are stored as pointers. The main application must + * store these UUIDs. * - * @param[out] p_advertising Advertising module instance. This structure must be supplied by + * @param[out] p_advertising Advertising Module instance. This structure must be supplied by * the application. It is initialized by this function and will later * be used to identify this particular module instance. * @param[in] p_init Information needed to initialize the module. * - * @retval NRF_SUCCESS If initialization was successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_PARAM If the advertising configuration in \p p_init is invalid. + * @return If functions from other modules return errors to this function, the @ref nrf_error are propagated. */ uint32_t ble_advertising_init(ble_advertising_t * const p_advertising, ble_advertising_init_t const * const p_init); @@ -256,7 +233,7 @@ uint32_t ble_advertising_init(ble_advertising_t * const p_advertising * @details See @ref sd_ble_cfg_set for more details about changing connection settings. If this * function is never called, @ref BLE_CONN_CFG_TAG_DEFAULT will be used. * - * @param[in] p_advertising Advertising module instance. + * @param[in] p_advertising Advertising Module instance. * @param[in] ble_cfg_tag Configuration for the connection settings (see @ref sd_ble_cfg_set). */ void ble_advertising_conn_cfg_tag_set(ble_advertising_t * const p_advertising, uint8_t ble_cfg_tag); @@ -266,8 +243,8 @@ void ble_advertising_conn_cfg_tag_set(ble_advertising_t * const p_advertising, u * @details You can start advertising in any of the advertising modes that you enabled * during initialization. * - * @param[in] p_advertising Advertising module instance. - * @param[in] advertising_mode Advertising mode. + * @param[in] p_advertising Advertising Module instance. + * @param[in] advertising_mode Advertising mode. * * @retval @ref NRF_SUCCESS On success, else an error code indicating reason for failure. * @retval @ref NRF_ERROR_INVALID_STATE If the module is not initialized. @@ -282,10 +259,10 @@ uint32_t ble_advertising_start(ble_advertising_t * const p_advertising, * @ref BLE_ADV_EVT_PEER_ADDR_REQUEST event. Without the peer address, the directed * advertising mode will not be run. * - * @param[in] p_advertising Advertising module instance. - * @param[in] p_peer_addr Pointer to a peer address. + * @param[in] p_advertising Advertising Module instance. + * @param[in] p_peer_addr Pointer to a peer address. * - * @retval @ref NRF_SUCCESS Successfully stored the peer address pointer in the advertising module. + * @retval @ref NRF_SUCCESS Successfully stored the peer address pointer in the Advertising Module. * @retval @ref NRF_ERROR_INVALID_STATE If a reply was not expected. */ uint32_t ble_advertising_peer_addr_reply(ble_advertising_t * const p_advertising, @@ -298,21 +275,21 @@ uint32_t ble_advertising_peer_addr_reply(ble_advertising_t * const p_advertising * @ref BLE_ADV_EVT_WHITELIST_REQUEST event. Without the whitelist, the whitelist * advertising for fast and slow modes will not be run. * - * @param[in] p_advertising Advertising module instance. + * @param[in] p_advertising Advertising Module instance. * @param[in] p_gap_addrs The list of GAP addresses to whitelist. * @param[in] addr_cnt The number of GAP addresses to whitelist. * @param[in] p_gap_irks The list of peer IRK to whitelist. * @param[in] irk_cnt The number of peer IRK to whitelist. * - * @retval @ref NRF_SUCCESS If the operation was successful. - * @retval @ref NRF_ERROR_INVALID_STATE If a call to this function was made without a - * BLE_ADV_EVT_WHITELIST_REQUEST event being received. + * @retval @ref NRF_SUCCESS If the operation was successful. + * @retval @ref NRF_ERROR_INVALID_STATE If a call to this function was made without a + * BLE_ADV_EVT_WHITELIST_REQUEST event being received. */ uint32_t ble_advertising_whitelist_reply(ble_advertising_t * const p_advertising, ble_gap_addr_t const * p_gap_addrs, - uint32_t addr_cnt, - ble_gap_irk_t const * p_gap_irks, - uint32_t irk_cnt); + uint32_t addr_cnt, + ble_gap_irk_t const * p_gap_irks, + uint32_t irk_cnt); /**@brief Function for disabling whitelist advertising. @@ -320,7 +297,7 @@ uint32_t ble_advertising_whitelist_reply(ble_advertising_t * const p_advertising * @details This function temporarily disables whitelist advertising. * Calling this function resets the current time-out countdown. * - * @param[in] p_advertising Advertising module instance. + * @param[in] p_advertising Advertising Module instance. * * @retval @ref NRF_SUCCESS On success, else an error message propogated from the Softdevice. */ @@ -330,19 +307,42 @@ uint32_t ble_advertising_restart_without_whitelist(ble_advertising_t * const p_a /**@brief Function for changing advertising modes configuration. * * @details This function can be called if you wish to reconfigure the advertising modes that the - * advertising module will cycle through. Enable or disable modes as listed in + * Advertising Module will cycle through. Enable or disable modes as listed in * @ref ble_adv_mode_t; or change the duration of the advertising and use of whitelist. * * Keep in mind that @ref ble_adv_modes_config_t is also supplied when calling * @ref ble_advertising_init. Calling @ref ble_advertising_modes_config_set * is only necessary if your application requires this behaviour to change. * - * @param[in] p_advertising Advertising module instance. + * @param[in] p_advertising Advertising Module instance. * @param[in] p_adv_modes_config Struct to keep track of disabled and enabled advertising modes, * as well as time-outs and intervals. */ void ble_advertising_modes_config_set(ble_advertising_t * const p_advertising, ble_adv_modes_config_t const * const p_adv_modes_config); + + +/**@brief Function for updating advertising data. + * + * @details This function can be called if you wish to reconfigure the advertising data The update + * will be effective even if advertising has already been started. + * + * @param[in] p_advertising Advertising Module instance. + * @param[in] p_advdata Pointer to the structure for specifying the content of advertising data. + * Or null if there should be no advertising data. + * @param[in] p_srdata Pointer to the structure for specifying the content of scan response data. + * Or null if there should be no advertising data. + * + * @retval @ref NRF_ERROR_NULL If advertising instance was null. + * If both \p p_advdata and \p p_srdata are null. + * @retval @ref NRF_ERROR_INVALID_STATE If advertising instance was not initialized. + * @retval @ref NRF_SUCCESS or any error from @ref ble_advdata_encode or + * @ref sd_ble_gap_adv_set_configure(). + */ +ret_code_t ble_advertising_advdata_update(ble_advertising_t * const p_advertising, + ble_advdata_t const * const p_advdata, + ble_advdata_t const * const p_srdata); + /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.c similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.c index d54d6ef..aef67ea 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_db_discovery/ble_db_discovery.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -54,23 +54,10 @@ NRF_LOG_MODULE_REGISTER(); /**@brief Array of structures containing information about the registered application modules. */ -static ble_uuid_t m_registered_handlers[DB_DISCOVERY_MAX_USERS]; - +static ble_uuid_t m_registered_handlers[DB_DISCOVERY_MAX_USERS]; +static ble_db_discovery_evt_handler_t m_evt_handler; +static nrf_ble_gq_t * mp_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ -/**@brief Array of structures containing pending events to be sent to the application modules. - * - * @details Whenever a discovery related event is to be raised to a user module, it will be stored - * in this array first. When all services needed to be discovered have been - * discovered, all pending events will be sent to the corresponding user modules. - **/ -static struct -{ - ble_db_discovery_evt_t evt; /**< The pending event. */ - ble_db_discovery_evt_handler_t evt_handler; /**< The event handler which should be called to raise this event. */ -} m_pending_user_evts[DB_DISCOVERY_MAX_USERS]; - -static ble_db_discovery_evt_handler_t m_evt_handler; -static uint32_t m_pending_usr_evt_index; /**< The index to the pending user event array, pointing to the last added pending user event. */ static uint32_t m_num_of_handlers_reg; /**< The number of handlers registered with the DB Discovery module. */ static bool m_initialized = false; /**< This variable Indicates if the module is initialized or not. */ @@ -127,15 +114,41 @@ static uint32_t registered_handler_set(ble_uuid_t const * p_ /**@brief Function for sending all pending discovery events to the corresponding user modules. */ -static void pending_user_evts_send(void) +static void pending_user_evts_send(ble_db_discovery_t * p_db_discovery) { for (uint32_t i = 0; i < m_num_of_handlers_reg; i++) { // Pass the event to the corresponding event handler. - m_pending_user_evts[i].evt_handler(&(m_pending_user_evts[i].evt)); + p_db_discovery->pending_usr_evts[i].evt_handler(&(p_db_discovery->pending_usr_evts[i].evt)); } - m_pending_usr_evt_index = 0; + p_db_discovery->pending_usr_evt_index = 0; +} + +/**@brief Function for indicating availability of DB discovery instance. + * + * @details This function triggers an event indicating the finish of a discovery process. + * If the event has happened, then the application can perform the next discovery + * procedure on this DB discovery instance. + * + * @param[in] p_db_discovery Pointer to the DB discovery structure. + * @param[in] conn_handle Connection Handle. + */ +static void discovery_available_evt_trigger(ble_db_discovery_t * const p_db_discovery, + uint16_t const conn_handle) +{ + ble_db_discovery_evt_t evt; + + memset(&evt, 0, sizeof(evt)); + + evt.conn_handle = conn_handle; + evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; + evt.params.p_db_instance = (void *)p_db_discovery; + + if (m_evt_handler) + { + m_evt_handler(&evt); + } } @@ -176,6 +189,25 @@ static void discovery_error_evt_trigger(ble_db_discovery_t * p_db_discovery, } +/**@brief Function for interception of GATTC and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void discovery_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_db_discovery_t * p_db_discovery = (ble_db_discovery_t *)p_ctx; + p_db_discovery->discovery_in_progress = false; + + discovery_error_evt_trigger(p_db_discovery, nrf_error, conn_handle); + discovery_available_evt_trigger(p_db_discovery, conn_handle); +} + + + /**@brief Function for triggering a Discovery Complete or Service Not Found event to the * application. * @@ -201,32 +233,32 @@ static void discovery_complete_evt_trigger(ble_db_discovery_t * p_db_discovery, if (p_evt_handler != NULL) { - if (m_pending_usr_evt_index < DB_DISCOVERY_MAX_USERS) + if (p_db_discovery->pending_usr_evt_index < DB_DISCOVERY_MAX_USERS) { // Insert an event into the pending event list. - m_pending_user_evts[m_pending_usr_evt_index].evt.conn_handle = conn_handle; - m_pending_user_evts[m_pending_usr_evt_index].evt.params.discovered_db = + p_db_discovery->pending_usr_evts[p_db_discovery->pending_usr_evt_index].evt.conn_handle = conn_handle; + p_db_discovery->pending_usr_evts[p_db_discovery->pending_usr_evt_index].evt.params.discovered_db = *p_srv_being_discovered; if (is_srv_found) { - m_pending_user_evts[m_pending_usr_evt_index].evt.evt_type = + p_db_discovery->pending_usr_evts[p_db_discovery->pending_usr_evt_index].evt.evt_type = BLE_DB_DISCOVERY_COMPLETE; } else { - m_pending_user_evts[m_pending_usr_evt_index].evt.evt_type = + p_db_discovery->pending_usr_evts[p_db_discovery->pending_usr_evt_index].evt.evt_type = BLE_DB_DISCOVERY_SRV_NOT_FOUND; } - m_pending_user_evts[m_pending_usr_evt_index].evt_handler = p_evt_handler; - m_pending_usr_evt_index++; + p_db_discovery->pending_usr_evts[p_db_discovery->pending_usr_evt_index].evt_handler = p_evt_handler; + p_db_discovery->pending_usr_evt_index++; - if (m_pending_usr_evt_index == m_num_of_handlers_reg) + if (p_db_discovery->pending_usr_evt_index == m_num_of_handlers_reg) { // All registered modules have pending events. Send all pending events to the user // modules. - pending_user_evts_send(); + pending_user_evts_send(p_db_discovery); } else { @@ -248,6 +280,10 @@ static void discovery_complete_evt_trigger(ble_db_discovery_t * p_db_discovery, static void on_srv_disc_completion(ble_db_discovery_t * p_db_discovery, uint16_t conn_handle) { + nrf_ble_gq_req_t db_srv_disc_req; + + memset(&db_srv_disc_req, 0, sizeof(nrf_ble_gq_req_t)); + p_db_discovery->discoveries_count++; // Check if more services need to be discovered. @@ -274,20 +310,17 @@ static void on_srv_disc_completion(ble_db_discovery_t * p_db_discovery, uint32_t err_code; - err_code = sd_ble_gattc_primary_services_discover(conn_handle, - SRV_DISC_START_HANDLE, - &(p_srv_being_discovered->srv_uuid)); + db_srv_disc_req.type = NRF_BLE_GQ_REQ_SRV_DISCOVERY; + db_srv_disc_req.params.gattc_srv_disc.start_handle = SRV_DISC_START_HANDLE; + db_srv_disc_req.params.gattc_srv_disc.srvc_uuid = p_srv_being_discovered->srv_uuid; + db_srv_disc_req.error_handler.p_ctx = p_db_discovery; + db_srv_disc_req.error_handler.cb = discovery_error_handler; + + err_code = nrf_ble_gq_item_add(mp_gatt_queue, &db_srv_disc_req, conn_handle); if (err_code != NRF_SUCCESS) { - p_db_discovery->discovery_in_progress = false; - - // Error with discovering the service. - // Indicate the error to the registered user application. - discovery_error_evt_trigger(p_db_discovery, err_code, conn_handle); - - m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; - m_pending_user_evts[0].evt.conn_handle = conn_handle; + discovery_error_handler(err_code, p_db_discovery, conn_handle); return; } @@ -296,8 +329,8 @@ static void on_srv_disc_completion(ble_db_discovery_t * p_db_discovery, { // No more service discovery is needed. p_db_discovery->discovery_in_progress = false; - m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; - m_pending_user_evts[0].evt.conn_handle = conn_handle; + + discovery_available_evt_trigger(p_db_discovery, conn_handle); } } @@ -411,6 +444,10 @@ static uint32_t characteristics_discover(ble_db_discovery_t * p_db_discovery, { ble_gatt_db_srv_t * p_srv_being_discovered; ble_gattc_handle_range_t handle_range; + nrf_ble_gq_req_t db_char_disc_req; + + memset(&db_char_disc_req, 0, sizeof(nrf_ble_gq_req_t)); + memset(&handle_range, 0, sizeof(ble_gattc_handle_range_t)); p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]); @@ -435,7 +472,12 @@ static uint32_t characteristics_discover(ble_db_discovery_t * p_db_discovery, handle_range.end_handle = p_srv_being_discovered->handle_range.end_handle; - return sd_ble_gattc_characteristics_discover(conn_handle, &handle_range); + db_char_disc_req.type = NRF_BLE_GQ_REQ_CHAR_DISCOVERY; + db_char_disc_req.params.gattc_char_disc = handle_range; + db_char_disc_req.error_handler.p_ctx = p_db_discovery; + db_char_disc_req.error_handler.cb = discovery_error_handler; + + return nrf_ble_gq_item_add(mp_gatt_queue, &db_char_disc_req, conn_handle); } @@ -464,8 +506,11 @@ static uint32_t descriptors_discover(ble_db_discovery_t * p_db_discovery, ble_gattc_handle_range_t handle_range; ble_gatt_db_char_t * p_curr_char_being_discovered; ble_gatt_db_srv_t * p_srv_being_discovered; + nrf_ble_gq_req_t db_desc_disc_req; bool is_discovery_reqd = false; + memset(&db_desc_disc_req, 0, sizeof(nrf_ble_gq_req_t)); + p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]); p_curr_char_being_discovered = @@ -525,7 +570,12 @@ static uint32_t descriptors_discover(ble_db_discovery_t * p_db_discovery, *p_raise_discov_complete = false; - return sd_ble_gattc_descriptors_discover(conn_handle, &handle_range); + db_desc_disc_req.type = NRF_BLE_GQ_REQ_DESC_DISCOVERY; + db_desc_disc_req.params.gattc_desc_disc = handle_range; + db_desc_disc_req.error_handler.p_ctx = p_db_discovery; + db_desc_disc_req.error_handler.cb = discovery_error_handler; + + return nrf_ble_gq_item_add(mp_gatt_queue, &db_desc_disc_req, conn_handle); } @@ -558,21 +608,32 @@ static void on_primary_srv_discovery_rsp(ble_db_discovery_t * p_db_discove p_prim_srvc_disc_rsp_evt = &(p_ble_gattc_evt->params.prim_srvc_disc_rsp); - p_srv_being_discovered->srv_uuid = p_prim_srvc_disc_rsp_evt->services[0].uuid; p_srv_being_discovered->handle_range = p_prim_srvc_disc_rsp_evt->services[0].handle_range; - err_code = characteristics_discover(p_db_discovery, p_ble_gattc_evt->conn_handle); + // Number of services, previously discovered. + uint8_t num_srv_previous_disc = p_db_discovery->srv_count; - if (err_code != NRF_SUCCESS) + // Number of services, currently discovered. + uint8_t current_srv_disc = p_prim_srvc_disc_rsp_evt->count; + + if ((num_srv_previous_disc + current_srv_disc) <= BLE_DB_DISCOVERY_MAX_SRV) { - p_db_discovery->discovery_in_progress = false; + p_db_discovery->srv_count += current_srv_disc; + } + else + { + p_db_discovery->srv_count = BLE_DB_DISCOVERY_MAX_SRV; - // Error with discovering the service. - // Indicate the error to the registered user application. - discovery_error_evt_trigger(p_db_discovery, err_code, p_ble_gattc_evt->conn_handle); + NRF_LOG_WARNING("Not enough space for services."); + NRF_LOG_WARNING("Increase BLE_DB_DISCOVERY_MAX_SRV to be able to store more " + "services!"); + } + + err_code = characteristics_discover(p_db_discovery, p_ble_gattc_evt->conn_handle); - m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; - m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle; + if (err_code != NRF_SUCCESS) + { + discovery_error_handler(err_code, p_db_discovery, p_ble_gattc_evt->conn_handle); } } else @@ -629,6 +690,10 @@ static void on_characteristic_discovery_rsp(ble_db_discovery_t * p_db_disc // The number of characteristics discovered at the peer is more than the supported // maximum. This module will store only the characteristics found up to this point. p_srv_being_discovered->char_count = BLE_GATT_DB_MAX_CHARS; + NRF_LOG_WARNING("Not enough space for characteristics associated with " + "service 0x%04X !", p_srv_being_discovered->srv_uuid.uuid); + NRF_LOG_WARNING("Increase BLE_GATT_DB_MAX_CHARS to be able to store more " + "characteristics for each service!"); } uint32_t i; @@ -666,12 +731,7 @@ static void on_characteristic_discovery_rsp(ble_db_discovery_t * p_db_disc if (err_code != NRF_SUCCESS) { - p_db_discovery->discovery_in_progress = false; - - discovery_error_evt_trigger(p_db_discovery, err_code, p_ble_gattc_evt->conn_handle); - - m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; - m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle; + discovery_error_handler(err_code, p_db_discovery, p_ble_gattc_evt->conn_handle); return; } @@ -696,12 +756,7 @@ static void on_characteristic_discovery_rsp(ble_db_discovery_t * p_db_disc if (err_code != NRF_SUCCESS) { - p_db_discovery->discovery_in_progress = false; - - discovery_error_evt_trigger(p_db_discovery, err_code, p_ble_gattc_evt->conn_handle); - - m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; - m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle; + discovery_error_handler(err_code, p_db_discovery, p_ble_gattc_evt->conn_handle); return; } @@ -807,14 +862,7 @@ static void on_descriptor_discovery_rsp(ble_db_discovery_t * const p_db_disco if (err_code != NRF_SUCCESS) { - p_db_discovery->discovery_in_progress = false; - - // Error with discovering the service. - // Indicate the error to the registered user application. - discovery_error_evt_trigger(p_db_discovery, err_code, p_ble_gattc_evt->conn_handle); - - m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; - m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle; + discovery_error_handler(err_code, p_db_discovery, p_ble_gattc_evt->conn_handle); return; } @@ -833,26 +881,28 @@ static void on_descriptor_discovery_rsp(ble_db_discovery_t * const p_db_disco } -uint32_t ble_db_discovery_init(const ble_db_discovery_evt_handler_t evt_handler) +uint32_t ble_db_discovery_init(ble_db_discovery_init_t * p_db_init) { uint32_t err_code = NRF_SUCCESS; - VERIFY_PARAM_NOT_NULL(evt_handler); + VERIFY_PARAM_NOT_NULL(p_db_init); + VERIFY_PARAM_NOT_NULL(p_db_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_db_init->p_gatt_queue); m_num_of_handlers_reg = 0; m_initialized = true; - m_pending_usr_evt_index = 0; - m_evt_handler = evt_handler; + m_evt_handler = p_db_init->evt_handler; + mp_gatt_queue = p_db_init->p_gatt_queue; - return err_code; + return err_code; } -uint32_t ble_db_discovery_close() +uint32_t ble_db_discovery_close(ble_db_discovery_t * const p_db_discovery) { - m_num_of_handlers_reg = 0; - m_initialized = false; - m_pending_usr_evt_index = 0; + m_num_of_handlers_reg = 0; + m_initialized = false; + p_db_discovery->pending_usr_evt_index = 0; return NRF_SUCCESS; } @@ -869,14 +919,19 @@ uint32_t ble_db_discovery_evt_register(ble_uuid_t const * p_uuid) static uint32_t discovery_start(ble_db_discovery_t * const p_db_discovery, uint16_t conn_handle) { - uint32_t err_code; + ret_code_t err_code; ble_gatt_db_srv_t * p_srv_being_discovered; + nrf_ble_gq_req_t db_srv_disc_req; memset(p_db_discovery, 0x00, sizeof(ble_db_discovery_t)); + memset(&db_srv_disc_req, 0x00, sizeof(nrf_ble_gq_req_t)); + + err_code = nrf_ble_gq_conn_handle_register(mp_gatt_queue, conn_handle); + VERIFY_SUCCESS(err_code); p_db_discovery->conn_handle = conn_handle; - m_pending_usr_evt_index = 0; + p_db_discovery->pending_usr_evt_index = 0; p_db_discovery->discoveries_count = 0; p_db_discovery->curr_srv_ind = 0; @@ -888,22 +943,20 @@ static uint32_t discovery_start(ble_db_discovery_t * const p_db_discovery, uint1 NRF_LOG_DEBUG("Starting discovery of service with UUID 0x%x on connection handle 0x%x.", p_srv_being_discovered->srv_uuid.uuid, conn_handle); - err_code = sd_ble_gattc_primary_services_discover(conn_handle, - SRV_DISC_START_HANDLE, - &(p_srv_being_discovered->srv_uuid)); - if (err_code != NRF_ERROR_BUSY) - { - VERIFY_SUCCESS(err_code); - p_db_discovery->discovery_in_progress = true; - p_db_discovery->discovery_pending = false; - } - else + db_srv_disc_req.type = NRF_BLE_GQ_REQ_SRV_DISCOVERY; + db_srv_disc_req.params.gattc_srv_disc.start_handle = SRV_DISC_START_HANDLE; + db_srv_disc_req.params.gattc_srv_disc.srvc_uuid = p_srv_being_discovered->srv_uuid; + db_srv_disc_req.error_handler.p_ctx = p_db_discovery; + db_srv_disc_req.error_handler.cb = discovery_error_handler; + + err_code = nrf_ble_gq_item_add(mp_gatt_queue, &db_srv_disc_req, conn_handle); + + if (err_code == NRF_SUCCESS) { p_db_discovery->discovery_in_progress = true; - p_db_discovery->discovery_pending = true; } - return NRF_SUCCESS; + return err_code; } @@ -938,7 +991,6 @@ static void on_disconnected(ble_db_discovery_t * p_db_discovery, if (p_evt->conn_handle == p_db_discovery->conn_handle) { p_db_discovery->discovery_in_progress = false; - p_db_discovery->discovery_pending = false; p_db_discovery->conn_handle = BLE_CONN_HANDLE_INVALID; } } @@ -974,13 +1026,5 @@ void ble_db_discovery_on_ble_evt(ble_evt_t const * p_ble_evt, default: break; } - - if ( (p_db_discovery->discovery_pending) - && (p_ble_evt->header.evt_id >= BLE_GATTC_EVT_BASE) - && (p_ble_evt->header.evt_id <= BLE_GATTC_EVT_LAST) - && (p_ble_evt->evt.gattc_evt.conn_handle == p_db_discovery->conn_handle)) - { - (void)discovery_start(p_db_discovery, p_db_discovery->conn_handle); - } } #endif // NRF_MODULE_ENABLED(BLE_DB_DISCOVERY) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.h new file mode 100644 index 0000000..5b1f6b9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_db_discovery/ble_db_discovery.h @@ -0,0 +1,271 @@ +/** + * Copyright (c) 2013 - 2019, 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 ble_db_discovery Database Discovery + * @{ + * @ingroup ble_sdk_lib + * + * @brief Database discovery module. + * + * @details This module contains the APIs and types exposed by the DB Discovery module. These APIs + * and types can be used by the application to perform discovery of a service and its + * characteristics at the peer server. This module can also be used to discover the + * desired services in multiple remote devices. + * + * @warning The maximum number of characteristics per service that can be discovered by this module + * is determined by the number of characteristics in the service structure defined in + * db_disc_config.h. If the peer has more than the supported number of characteristics, then + * the first found will be discovered and any further characteristics will be ignored. Only the + * following descriptors will be searched for at the peer: Client Characteristic Configuration, + * Characteristic Extended Properties, Characteristic User Description, and Report Reference. + * + * @note Presently only one instance of a Primary Service can be discovered by this module. If + * there are multiple instances of the service at the peer, only the first instance + * of it at the peer is fetched and returned to the application. + * + * @note The application must propagate BLE stack events to this module by calling + * ble_db_discovery_on_ble_evt(). + * + */ + +#ifndef BLE_DB_DISCOVERY_H__ +#define BLE_DB_DISCOVERY_H__ + +#include +#include +#include "nrf_error.h" +#include "ble.h" +#include "ble_gattc.h" +#include "ble_gatt_db.h" +#include "nrf_ble_gq.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !(defined(__LINT__)) +/**@brief Macro for defining a ble_db_discovery instance. + * + * @param _name Name of the instance. + * @hideinitializer + */ +#define BLE_DB_DISCOVERY_DEF(_name) \ +static ble_db_discovery_t _name = {.discovery_in_progress = 0, \ + .conn_handle = BLE_CONN_HANDLE_INVALID}; \ +NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_DB_DISC_BLE_OBSERVER_PRIO, \ + ble_db_discovery_on_ble_evt, &_name) + + +/** @brief Macro for defining multiple ble_db_discovery instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + */ +#define BLE_DB_DISCOVERY_ARRAY_DEF(_name, _cnt) \ +static ble_db_discovery_t _name[_cnt] = {MACRO_REPEAT(_cnt, DB_INIT)}; \ + \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_DB_DISC_BLE_OBSERVER_PRIO, \ + ble_db_discovery_on_ble_evt, &_name, _cnt) + +#if !(defined(DOXYGEN)) +#define DB_INIT() \ +{ \ + .discovery_in_progress = 0, \ + .conn_handle = BLE_CONN_HANDLE_INVALID, \ +}, +#endif + +#else // __LINT__ +/* Swallow semicolons */ +/*lint -save -esym(528, *) -esym(529, *) : Symbol not referenced. */ +#define BLE_DB_DISCOVERY_ARRAY_DEF(A, B) static ble_db_discovery_t A[B] +#define BLE_DB_DISCOVERY_DEF(A) static ble_db_discovery_t A +/*lint -restore */ +#endif //!(defined(__LINT__)) + +#define BLE_DB_DISCOVERY_MAX_SRV 6 /**< Maximum number of services supported by this module. This also indicates the maximum number of users allowed to be registered to this module (one user per service). */ + + +/**@brief DB Discovery event type. */ +typedef enum +{ + BLE_DB_DISCOVERY_COMPLETE, /**< Event indicating that the discovery of one service is complete. */ + BLE_DB_DISCOVERY_ERROR, /**< Event indicating that an internal error has occurred in the DB Discovery module. This could typically be because of the SoftDevice API returning an error code during the DB discover.*/ + BLE_DB_DISCOVERY_SRV_NOT_FOUND, /**< Event indicating that the service was not found at the peer.*/ + BLE_DB_DISCOVERY_AVAILABLE /**< Event indicating that the DB discovery instance is available.*/ +} ble_db_discovery_evt_type_t; + +/**@brief Structure containing the event from the DB discovery module to the application. */ +typedef struct +{ + ble_db_discovery_evt_type_t evt_type; /**< Type of event. */ + uint16_t conn_handle; /**< Handle of the connection for which this event has occurred. */ + union + { + ble_gatt_db_srv_t discovered_db; /**< Structure containing the information about the GATT Database at the server. This will be filled when the event type is @ref BLE_DB_DISCOVERY_COMPLETE. The UUID field of this will be filled when the event type is @ref BLE_DB_DISCOVERY_SRV_NOT_FOUND. */ + void const * p_db_instance; /**< Pointer to DB discovery instance @ref ble_db_discovery_t, indicating availability to the new discovery process. This will be filled when the event type is @ref BLE_DB_DISCOVERY_AVAILABLE. */ + uint32_t err_code; /**< nRF Error code indicating the type of error which occurred in the DB Discovery module. This will be filled when the event type is @ref BLE_DB_DISCOVERY_ERROR. */ + } params; +} ble_db_discovery_evt_t; + +/**@brief DB Discovery event handler type. */ +typedef void (* ble_db_discovery_evt_handler_t)(ble_db_discovery_evt_t * p_evt); + +/**@brief Structure containing the pending event. */ +typedef struct +{ + ble_db_discovery_evt_t evt; /**< Pending event. */ + ble_db_discovery_evt_handler_t evt_handler; /**< Event handler which should be called to raise this event. */ +} ble_db_discovery_user_evt_t; + +/**@brief Structure for holding the information related to the GATT database at the server. + * + * @details This module identifies a remote database. Use one instance of this structure per + * connection. + * + * @warning This structure must be zero-initialized. + */ +typedef struct +{ + ble_gatt_db_srv_t services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered. This is intended for internal use during service discovery.*/ + uint8_t srv_count; /**< Number of services at the peer's GATT database.*/ + uint8_t curr_char_ind; /**< Index of the current characteristic being discovered. This is intended for internal use during service discovery.*/ + uint8_t curr_srv_ind; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/ + uint8_t discoveries_count; /**< Number of service discoveries made, both successful and unsuccessful. */ + bool discovery_in_progress; /**< Variable to indicate whether there is a service discovery in progress. */ + uint16_t conn_handle; /**< Connection handle on which the discovery is started. */ + uint32_t pending_usr_evt_index; /**< The index to the pending user event array, pointing to the last added pending user event. */ + ble_db_discovery_user_evt_t pending_usr_evts[BLE_DB_DISCOVERY_MAX_SRV]; /**< Whenever a discovery related event is to be raised to a user module, it is stored in this array first. When all expected services have been discovered, all pending events are sent to the corresponding user modules. */ +} ble_db_discovery_t; + +/**@brief DB discovery module initialization struct. */ +typedef struct +{ + ble_db_discovery_evt_handler_t evt_handler; /**< Event handler to be called by the DB Discovery module. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ +} ble_db_discovery_init_t; + + +/**@brief Function for initializing the DB Discovery module. + * + * @param[in] p_db_init Pointer to DB discovery initialization structure. + * + * @retval NRF_SUCCESS On successful initialization. + * @retval NRF_ERROR_NULL If the initialization structure was NULL or + * the structure content is empty. + */ +uint32_t ble_db_discovery_init(ble_db_discovery_init_t * p_db_init); + + +/**@brief Function for closing the DB Discovery module. + * + * @details This function will clear up any internal variables and states maintained by the + * module. To re-use the module after calling this function, the function @ref + * ble_db_discovery_init must be called again. When using more than one DB Discovery + * instance, this function should be called for each instance. + * + * @param[out] p_db_discovery Pointer to the DB discovery structure. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ble_db_discovery_close(ble_db_discovery_t * const p_db_discovery); + + +/**@brief Function for registering with the DB Discovery module. + * + * @details The application can use this function to inform which service it is interested in + * discovering at the server. + * + * @param[in] p_uuid Pointer to the UUID of the service to be discovered at the server. + * + * @note The total number of services that can be discovered by this module is @ref + * BLE_DB_DISCOVERY_MAX_SRV. This effectively means that the maximum number of + * registrations possible is equal to the @ref BLE_DB_DISCOVERY_MAX_SRV. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL When a NULL pointer is passed as input. + * @retval NRF_ERROR_INVALID_STATE If this function is called without calling the + * @ref ble_db_discovery_init. + * @retval NRF_ERROR_NO_MEM The maximum number of registrations allowed by this module + * has been reached. + */ +uint32_t ble_db_discovery_evt_register(const ble_uuid_t * const p_uuid); + + +/**@brief Function for starting the discovery of the GATT database at the server. + * + * @param[out] p_db_discovery Pointer to the DB Discovery structure. + * @param[in] conn_handle The handle of the connection for which the discovery should be + * started. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL When a NULL pointer is passed as input. + * @retval NRF_ERROR_INVALID_STATE If this function is called without calling the + * @ref ble_db_discovery_init, or without calling + * @ref ble_db_discovery_evt_register. + * @retval NRF_ERROR_BUSY If a discovery is already in progress using + * @p p_db_discovery. Use a different @ref ble_db_discovery_t + * structure, or wait for a DB Discovery event before retrying. + * @return This API propagates the error code returned by functions: + * @ref nrf_ble_gq_conn_handle_register and @ref nrf_ble_gq_item_add. + */ +uint32_t ble_db_discovery_start(ble_db_discovery_t * p_db_discovery, + uint16_t conn_handle); + + +/**@brief Function for handling the Application's BLE Stack events. + * + * @param[in] p_ble_evt Pointer to the BLE event received. + * @param[in,out] p_context Pointer to the DB Discovery structure. + */ +void ble_db_discovery_on_ble_evt(ble_evt_t const * p_ble_evt, + void * p_context); + + +#ifdef __cplusplus +} +#endif + +#endif // BLE_DB_DISCOVERY_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm.c similarity index 77% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm.c index 3aa8f1c..8317e8b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_DTM) @@ -130,7 +130,7 @@ static uint32_t m_current_time = 0; /** // Nordic specific configuration values (not defined by BLE standard). // Definition of initial values found in ble_dtm.h -static int32_t m_tx_power = DEFAULT_TX_POWER; /**< TX power for transmission test, default to maximum value (+4 dBm). */ +static uint32_t m_tx_power = DEFAULT_TX_POWER; /**< TX power for transmission test, default 0 dBm. */ static NRF_TIMER_Type * mp_timer = DEFAULT_TIMER; /**< Timer to be used. */ static IRQn_Type m_timer_irq = DEFAULT_TIMER_IRQn; /**< which interrupt line to clear on every timeout */ @@ -152,6 +152,15 @@ static uint32_t m_crc_init = 0x00555555; /** static uint8_t m_radio_mode = RADIO_MODE_MODE_Ble_1Mbit; /**< nRF51 specific radio mode value. */ static uint32_t m_txIntervaluS = 2500; /**< Time between start of Tx packets (in uS). */ +// The variables and defines below are related to the workaround for nRF52840 anomaly 172 +static bool anomaly_172_wa_enabled = false; /**< Enable or disable the workaround for Errata 172. */ +static uint8_t m_strict_mode = 0; /**< Enable or disable strict mode to workaround Errata 172. */ +#define BLOCKER_FIX_RSSI_THRESHOLD 95 /**< The RSSI threshold at which to toggle strict mode. */ +#define BLOCKER_FIX_WAIT_DEFAULT 1250 /**< 1250 * 8 = 10000 us = 10 ms. */ +#define BLOCKER_FIX_WAIT_END 63 /**< 63 * 8 = ~500us. */ +#define BLOCKER_FIX_CNTDETECTTHR 15 /**< Threshold used to determine necessary strict mode status changes. */ +#define BLOCKER_FIX_CNTADDRTHR 2 /**< Threshold used to determine necessary strict mode status changes. */ + /**@brief Function for verifying that a received PDU has the expected structure and content. */ @@ -170,21 +179,21 @@ static bool check_pdu(void) { return false; } - + // If the 1Mbit or 2Mbit radio mode is active, check that one of the three valid uncoded DTM packet types are selected. if ((m_radio_mode == RADIO_MODE_MODE_Ble_1Mbit || m_radio_mode == RADIO_MODE_MODE_Ble_2Mbit) && (pdu_packet_type > (dtm_pkt_type_t)DTM_PKT_0X55)) { return false; } -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) // If a long range radio mode is active, check that one of the four valid coded DTM packet types are selected. if ((m_radio_mode == RADIO_MODE_MODE_Ble_LR500Kbit || m_radio_mode == RADIO_MODE_MODE_Ble_LR125Kbit) && (pdu_packet_type > (dtm_pkt_type_t)DTM_PKT_0XFF)) { return false; } -#endif - +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) + if (pdu_packet_type == DTM_PKT_PRBS9) { // Payload does not consist of one repeated octet; must compare ir with entire block into @@ -208,7 +217,7 @@ static bool check_pdu(void) // No valid packet type set. return false; } - + for (k = 0; k < length; k++) { // Check repeated pattern filling the PDU payload @@ -280,7 +289,7 @@ static uint32_t radio_init(void) (m_packetHeaderLFlen << RADIO_PCNF0_LFLEN_Pos) | (m_packetHeaderPlen << RADIO_PCNF0_PLEN_Pos); } -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) else { // Coded PHY (Long range) @@ -291,7 +300,7 @@ static uint32_t radio_init(void) (2 << RADIO_PCNF0_CILEN_Pos) | (m_packetHeaderPlen << RADIO_PCNF0_PLEN_Pos); } -#endif +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) NRF_RADIO->PCNF1 = (m_whitening << RADIO_PCNF1_WHITEEN_Pos) | (m_endian << RADIO_PCNF1_ENDIAN_Pos) | @@ -303,6 +312,46 @@ static uint32_t radio_init(void) } +// Strict mode setting will be used only by devices affected by nRF52840 anomaly 172 +void set_strict_mode (bool enable) +{ + uint8_t dbcCorrTh; + uint8_t dsssMinPeakCount; + if (enable == true) + { + dbcCorrTh = 0x7d; + dsssMinPeakCount = 6; + *(volatile uint32_t *) 0x4000173c = ((*((volatile uint32_t *) 0x4000173c)) & 0x7FFFFF00) | 0x80000000 | (((uint32_t)(dbcCorrTh)) << 0); + *(volatile uint32_t *) 0x4000177c = ((*((volatile uint32_t *) 0x4000177c)) & 0x7FFFFF8F) | 0x80000000 | ((((uint32_t)dsssMinPeakCount) & 0x00000007) << 4); + } + else + { + *(volatile uint32_t *) 0x4000173c = 0x40003034; + *(volatile uint32_t *) 0x4000177c = ((*((volatile uint32_t *) 0x4000177c)) & 0x7FFFFFFF); // Unset override of dsssMinPeakCount + } + + m_strict_mode = enable; +} + + +// Radio configuration used as a workaround for nRF52840 anomaly 172 +void anomaly_172_radio_operation(void) +{ + *(volatile uint32_t *) 0x40001040 = 1; + *(volatile uint32_t *) 0x40001038 = 1; +} + + +// Function to gather RSSI data and set strict mode accordingly. Used as part of the workaround for nRF52840 anomaly 172 +uint8_t anomaly_172_rssi_check(void) +{ + NRF_RADIO->EVENTS_RSSIEND = 0; + NRF_RADIO->TASKS_RSSISTART = 1; + while (NRF_RADIO->EVENTS_RSSIEND == 0); + uint8_t rssi = NRF_RADIO->RSSISAMPLE; + return rssi; +} + /**@brief Function for preparing the radio. At start of each test: Turn off RF, clear interrupt flags of RF, initialize the radio * at given RF channel. * @@ -321,12 +370,27 @@ static void radio_prepare(bool rx) if (rx) { + // Enable strict mode if running on a device affected by nRF52840 anomaly 172 + if (anomaly_172_wa_enabled) + { + set_strict_mode(1); + } + NRF_RADIO->EVENTS_END = 0; NRF_RADIO->TASKS_RXEN = 1; // shorts will start radio in RX mode when it is ready } else // tx { - NRF_RADIO->TXPOWER = m_tx_power; + NRF_RADIO->TXPOWER = m_tx_power & RADIO_TXPOWER_TXPOWER_Msk; + + // Stop the timer used by nRF52840 anomaly 172 if running on an affected device. + if (anomaly_172_wa_enabled) + { + ANOMALY_172_TIMER->TASKS_CLEAR = 1; + ANOMALY_172_TIMER->TASKS_STOP = 1; + ANOMALY_172_TIMER->EVENTS_COMPARE[0] = 0; + ANOMALY_172_TIMER->EVENTS_COMPARE[1] = 0; + } } } @@ -340,6 +404,8 @@ static void dtm_test_done(void) NRF_PPI->CH[0].EEP = 0; // Break connection from timer to radio to stop transmit loop NRF_PPI->CH[0].TEP = 0; + ANOMALY_172_TIMER->TASKS_SHUTDOWN = 1; + radio_reset(); m_state = STATE_IDLE; } @@ -375,6 +441,27 @@ static uint32_t timer_init(void) mp_timer->CC[1] = UART_POLL_CYCLE; // Depends on the baud rate of the UART. Default baud rate of 19200 will result in a 260uS time with 1MHz clock to the timer mp_timer->TASKS_START = 1; // Start the timer - it will be running continuously m_current_time = 0; + + + // Enable the timer used by nRF52840 anomaly 172 if running on an affected device. + if (true) + { + ANOMALY_172_TIMER->TASKS_STOP = 1; // Stop timer, if it was running + ANOMALY_172_TIMER->TASKS_CLEAR = 1; + ANOMALY_172_TIMER->MODE = TIMER_MODE_MODE_Timer; // Timer mode (not counter) + ANOMALY_172_TIMER->EVENTS_COMPARE[0] = 0; // clean up possible old events + ANOMALY_172_TIMER->EVENTS_COMPARE[1] = 0; + ANOMALY_172_TIMER->EVENTS_COMPARE[2] = 0; + ANOMALY_172_TIMER->EVENTS_COMPARE[3] = 0; + + ANOMALY_172_TIMER->CC[0] = BLOCKER_FIX_WAIT_DEFAULT; + ANOMALY_172_TIMER->CC[1] = 0; + + NVIC_ClearPendingIRQ(ANOMALY_172_TIMER_IRQn); + + ANOMALY_172_TIMER->PRESCALER = 7; // Input clock is 16MHz, timer clock = 2 ^ prescale -> interval 1us + } + return DTM_SUCCESS; } @@ -459,7 +546,7 @@ static uint32_t dtm_packet_interval_calculate(uint32_t test_payload_length, uint // 24 CRC overhead_bits = 80; // 10 bytes } -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) else if (mode == RADIO_MODE_MODE_Ble_LR125Kbit) { // 80 preamble @@ -486,10 +573,10 @@ static uint32_t dtm_packet_interval_calculate(uint32_t test_payload_length, uint // assumption the radio will handle this overhead_bits = 462; // 57.75 bytes } -#endif +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) /* add PDU payload test_payload length */ test_packet_length = (test_payload_length * 8); // in bits -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) // account for the encoding of PDU if (mode == RADIO_MODE_MODE_Ble_LR125Kbit) { @@ -499,7 +586,7 @@ static uint32_t dtm_packet_interval_calculate(uint32_t test_payload_length, uint { test_packet_length *= 2; // 1 to 2 encoding } -#endif +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) // add overhead calculated above test_packet_length += overhead_bits; // we remember this bits are us in 1Mbit @@ -531,6 +618,7 @@ uint32_t dtm_init(void) { return DTM_ERROR_ILLEGAL_CONFIGURATION; } + m_new_event = false; m_state = STATE_IDLE; m_packet_length = 0; @@ -538,6 +626,10 @@ uint32_t dtm_init(void) // Enable wake-up on event SCB->SCR |= SCB_SCR_SEVONPEND_Msk; +#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA) || defined(NRF52833_XXAA) + // Enable cache + NRF_NVMC->ICACHECNF = (NVMC_ICACHECNF_CACHEEN_Enabled << NVMC_ICACHECNF_CACHEEN_Pos) & NVMC_ICACHECNF_CACHEEN_Msk; +#endif return DTM_SUCCESS; } @@ -549,6 +641,16 @@ uint32_t dtm_wait(void) for (;;) { + + if (m_state == STATE_RECEIVER_TEST && NRF_RADIO->EVENTS_ADDRESS == 1) + { + NRF_RADIO->EVENTS_ADDRESS = 0; + if (anomaly_172_wa_enabled) + { + ANOMALY_172_TIMER->TASKS_SHUTDOWN = 1; + } + } + // Event may be the reception of a packet - // handle radio first, to give it highest priority: if (NRF_RADIO->EVENTS_END != 0) @@ -559,6 +661,16 @@ uint32_t dtm_wait(void) if (m_state == STATE_RECEIVER_TEST) { NRF_RADIO->TASKS_RXEN = 1; + if (anomaly_172_wa_enabled) + { + ANOMALY_172_TIMER->CC[0] = BLOCKER_FIX_WAIT_DEFAULT; + ANOMALY_172_TIMER->CC[1] = BLOCKER_FIX_WAIT_END; + ANOMALY_172_TIMER->TASKS_CLEAR = 1; + ANOMALY_172_TIMER->EVENTS_COMPARE[0] = 0; + ANOMALY_172_TIMER->EVENTS_COMPARE[1] = 0; + ANOMALY_172_TIMER->TASKS_START = 1; + } + if ((NRF_RADIO->CRCSTATUS == 1) && check_pdu()) { // Count the number of successfully received packets @@ -572,6 +684,16 @@ uint32_t dtm_wait(void) // If no RECEIVER_TEST is running, ignore incoming packets (but do clear IRQ!) } + if (m_state == STATE_RECEIVER_TEST && NRF_RADIO->EVENTS_READY == 1) + { + NRF_RADIO->EVENTS_READY = 0; + if (anomaly_172_wa_enabled) + { + ANOMALY_172_TIMER->TASKS_CLEAR = 1; + ANOMALY_172_TIMER->TASKS_START = 1; + } + } + // Check for timeouts: if (mp_timer->EVENTS_COMPARE[0] != 0) { @@ -584,11 +706,64 @@ uint32_t dtm_wait(void) NVIC_ClearPendingIRQ(m_timer_irq); return ++m_current_time; } + + if (ANOMALY_172_TIMER->EVENTS_COMPARE[0] == 1) { + uint8_t rssi = anomaly_172_rssi_check(); + if (m_strict_mode) { + if (rssi > BLOCKER_FIX_RSSI_THRESHOLD) { + set_strict_mode(0); + } + } + else + { + bool too_many_detects = false; + uint32_t packetcnt2 = *(volatile uint32_t *) 0x40001574; + uint32_t detect_cnt = packetcnt2 & 0xffff; + uint32_t addr_cnt = (packetcnt2 >> 16) & 0xffff; + + if ((detect_cnt > BLOCKER_FIX_CNTDETECTTHR) && (addr_cnt < BLOCKER_FIX_CNTADDRTHR)) { + too_many_detects = true; + } + + if ((rssi < BLOCKER_FIX_RSSI_THRESHOLD) || too_many_detects) { + set_strict_mode(1); + } + } + + anomaly_172_radio_operation(); + + ANOMALY_172_TIMER->CC[0] = BLOCKER_FIX_WAIT_DEFAULT; + ANOMALY_172_TIMER->TASKS_STOP = 1; + ANOMALY_172_TIMER->TASKS_CLEAR = 1; + ANOMALY_172_TIMER->EVENTS_COMPARE[0] = 0; + ANOMALY_172_TIMER->TASKS_START = 1; + + NVIC_ClearPendingIRQ(ANOMALY_172_TIMER_IRQn); + } + + if (ANOMALY_172_TIMER->EVENTS_COMPARE[1] != 0) { + uint8_t rssi = anomaly_172_rssi_check(); + if (rssi >= BLOCKER_FIX_RSSI_THRESHOLD) { + set_strict_mode(0); + } + else + { + set_strict_mode(1); + } + + anomaly_172_radio_operation(); + + // Disable this event. + ANOMALY_172_TIMER->CC[1] = 0; + ANOMALY_172_TIMER->EVENTS_COMPARE[1] = 0; + NVIC_ClearPendingIRQ(ANOMALY_172_TIMER_IRQn); + } // Other events: No processing } } + uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t payload) { // Save specified packet in static variable for tx/rx functions to use. @@ -639,13 +814,13 @@ uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t m_packetHeaderPlen = RADIO_PCNF0_PLEN_8bit; #ifdef NRF52840_XXAA - // Workaround for Errata ID 164 - *(volatile uint32_t *)0x4000173C &= ~0x80000000; + // Workaround for Errata ID 191 + *(volatile uint32_t *) 0x40001740 = ((*((volatile uint32_t *) 0x40001740)) & 0x7FFFFFFF); #endif } else if (freq == LE_TEST_SETUP_SET_UPPER) { - if (length > 0x03) + if (length > 0x03) { m_event = LE_TEST_STATUS_EVENT_ERROR; return DTM_ERROR_ILLEGAL_CONFIGURATION; @@ -661,9 +836,13 @@ uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t m_packetHeaderPlen = RADIO_PCNF0_PLEN_8bit; #ifdef NRF52840_XXAA - // Workaround for Errata ID 164 - *(volatile uint32_t *)0x4000173C &= ~0x80000000; + // Workaround for Errata ID 191 + *(volatile uint32_t *) 0x40001740 = ((*((volatile uint32_t *) 0x40001740)) & 0x7FFFFFFF); #endif + // Disable the workaround for nRF52840 anomaly 172. + set_strict_mode(0); + ANOMALY_172_TIMER->TASKS_SHUTDOWN = 1; + anomaly_172_wa_enabled = false; return radio_init(); @@ -672,34 +851,52 @@ uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t m_packetHeaderPlen = RADIO_PCNF0_PLEN_16bit; #ifdef NRF52840_XXAA - // Workaround for Errata ID 164 - *(volatile uint32_t *)0x4000173C &= ~0x80000000; + // Workaround for Errata ID 191 + *(volatile uint32_t *) 0x40001740 = ((*((volatile uint32_t *) 0x40001740)) & 0x7FFFFFFF); #endif + + // Disable the workaround for nRF52840 anomaly 172. + set_strict_mode(0); + ANOMALY_172_TIMER->TASKS_SHUTDOWN = 1; + anomaly_172_wa_enabled = false; return radio_init(); case LE_PHY_LE_CODED_S8: -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) m_radio_mode = RADIO_MODE_MODE_Ble_LR125Kbit; m_packetHeaderPlen = RADIO_PCNF0_PLEN_LongRange; +#ifdef NRF52840_XXAA + // Workaround for Errata ID 191 + *(volatile uint32_t *) 0x40001740 = ((*((volatile uint32_t *) 0x40001740)) & 0x7FFF00FF) | 0x80000000 | (((uint32_t)(196)) << 8); - // Workaround for Errata ID 164 - *(volatile uint32_t *)0x4000173C |= 0x80000000; - *(volatile uint32_t *)0x4000173C = ((*(volatile uint32_t *)0x4000173C & 0xFFFFFF00) | 0x5C); + // Enable the workaround for nRF52840 anomaly 172 on affected devices. + if ((*(volatile uint32_t *)0x40001788) == 0) + { + anomaly_172_wa_enabled = true; + } +#endif //NRF52840_XXAA return radio_init(); #else m_event = LE_TEST_STATUS_EVENT_ERROR; return DTM_ERROR_ILLEGAL_CONFIGURATION; -#endif // NRF52840_XXAA +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) case LE_PHY_LE_CODED_S2: -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(NRF52811_XXAA) m_radio_mode = RADIO_MODE_MODE_Ble_LR500Kbit; m_packetHeaderPlen = RADIO_PCNF0_PLEN_LongRange; - // Workaround for Errata ID 164 - *(volatile uint32_t *)0x4000173C |= 0x80000000; - *(volatile uint32_t *)0x4000173C = ((*(volatile uint32_t *)0x4000173C & 0xFFFFFF00) | 0x5C); +#ifdef NRF52840_XXAA + // Workaround for Errata ID 191 + *(volatile uint32_t *) 0x40001740 = ((*((volatile uint32_t *) 0x40001740)) & 0x7FFF00FF) | 0x80000000 | (((uint32_t)(196)) << 8); + + // Enable the workaround for nRF52840 anomaly 172 on affected devices. + if ((*(volatile uint32_t *)0x40001788) == 0) + { + anomaly_172_wa_enabled = true; + } +#endif //NRF52840_XXAA return radio_init(); #else @@ -711,7 +908,7 @@ uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t return DTM_ERROR_ILLEGAL_CONFIGURATION; } } - else if(freq == LE_TEST_SETUP_SELECT_MODULATION) + else if (freq == LE_TEST_SETUP_SELECT_MODULATION) { if (length > 0x01) { @@ -899,14 +1096,14 @@ bool dtm_event_get(dtm_event_t *p_dtm_event) */ bool dtm_set_txpower(uint32_t new_tx_power) { - // radio->TXPOWER register is 32 bits, low octet a signed value, upper 24 bits zeroed - int8_t new_power8 = (int8_t)(new_tx_power & 0xFF); + // radio->TXPOWER register is 32 bits, low octet a tx power value, upper 24 bits zeroed + uint8_t new_power8 = (uint8_t)(new_tx_power & 0xFF); // The two most significant bits are not sent in the 6 bit field of the DTM command. // These two bits are 1's if and only if the tx_power is a negative number. - // All valid negative values have the fourth most significant bit as 1. - // All valid positive values have the fourth most significant bit as 0. - // By checking this bit, the two most significant bits can be determined. + // All valid negative values have a non zero bit in among the two most significant + // of the 6-bit value. + // By checking these bits, the two most significant bits can be determined. new_power8 = (new_power8 & 0x30) != 0 ? (new_power8 | 0xC0) : new_power8; if (m_state > STATE_IDLE) @@ -915,6 +1112,11 @@ bool dtm_set_txpower(uint32_t new_tx_power) return false; } + if (dtm_radio_validate(new_power8, m_radio_mode) != DTM_SUCCESS) + { + return false; + } + m_tx_power = new_power8; return true; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm.h index 04066cb..bbe3a49 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -63,6 +63,10 @@ extern "C" { #define DEFAULT_TIMER NRF_TIMER0 /**< Default timer used for timing. */ #define DEFAULT_TIMER_IRQn TIMER0_IRQn /**< IRQ used for timer. NOTE: MUST correspond to DEFAULT_TIMER. */ +#define ANOMALY_172_TIMER NRF_TIMER1 /**< Timer used for the workaround for errata 172 on affected nRF5 devices. */ +#define ANOMALY_172_TIMER_IRQn TIMER1_IRQn /**< IRQ used for timer. NOTE: MUST correspond to ERRATA_172_TIMER. */ +#define ANOMALY_172_TIMER_IRQHandler TIMER1_IRQHandler /**< IRQHandler used for timer. NOTE: MUST correspond to ERRATA_172_TIMER. */ + /**@brief BLE DTM command codes. */ typedef uint32_t dtm_cmd_t; /**< DTM command type. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw.h index c63d155..89da848 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -92,7 +92,7 @@ void dtm_constant_carrier(void); * @retval DTM_SUCCESS if input parameters values are correct. * @retval DTM_ERROR_ILLEGAL_CONFIGURATION if input parameters values are not correct. */ -uint32_t dtm_radio_validate(int32_t m_tx_power, uint8_t m_radio_mode); +uint32_t dtm_radio_validate(uint32_t m_tx_power, uint8_t m_radio_mode); #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw_nrf51.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw_nrf51.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw_nrf51.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw_nrf51.c index f0e238e..32fc5e7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw_nrf51.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw_nrf51.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_dtm_hw.h" #include "ble_dtm.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw_nrf52.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw_nrf52.c similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw_nrf52.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw_nrf52.c index 9f5f4b4..eb9cc19 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_dtm/ble_dtm_hw_nrf52.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_dtm/ble_dtm_hw_nrf52.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_dtm_hw.h" #include "ble_dtm.h" @@ -56,27 +56,37 @@ NRF_RADIO->MODECNF0 = (RADIO_MODECNF0_RU_Default << RADIO_MODECNF0_RU_Pos) | } -uint32_t dtm_radio_validate(int32_t m_tx_power, uint8_t m_radio_mode) +uint32_t dtm_radio_validate(uint32_t m_tx_power, uint8_t m_radio_mode) { // Initializing code below is quite generic - for BLE, the values are fixed, and expressions // are constant. Non-constant values are essentially set in radio_prepare(). - if (!(m_tx_power == RADIO_TXPOWER_TXPOWER_0dBm || + if (!( +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) + m_tx_power == RADIO_TXPOWER_TXPOWER_Pos8dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Pos7dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Pos6dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Pos5dBm || +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA) m_tx_power == RADIO_TXPOWER_TXPOWER_Pos4dBm || - m_tx_power == RADIO_TXPOWER_TXPOWER_Neg30dBm || - m_tx_power == RADIO_TXPOWER_TXPOWER_Neg20dBm || - m_tx_power == RADIO_TXPOWER_TXPOWER_Neg16dBm || - m_tx_power == RADIO_TXPOWER_TXPOWER_Neg12dBm || - m_tx_power == RADIO_TXPOWER_TXPOWER_Neg8dBm || - m_tx_power == RADIO_TXPOWER_TXPOWER_Neg4dBm || m_tx_power == RADIO_TXPOWER_TXPOWER_Pos3dBm || +#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) + m_tx_power == RADIO_TXPOWER_TXPOWER_Pos2dBm || +#endif //defined(NRF52840_XXAA) || defined(NRF52833_XXAA)A + m_tx_power == RADIO_TXPOWER_TXPOWER_0dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Neg4dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Neg8dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Neg12dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Neg16dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Neg20dBm || + m_tx_power == RADIO_TXPOWER_TXPOWER_Neg30dBm || m_tx_power == RADIO_TXPOWER_TXPOWER_Neg40dBm ) || !( -#ifdef NRF52840_XXAA +#if defined(NRF52840_XXAA) || defined(NRF52811_XXAA) || defined(NRF52833_XXAA) m_radio_mode == RADIO_MODE_MODE_Ble_LR125Kbit || m_radio_mode == RADIO_MODE_MODE_Ble_LR500Kbit || -#endif //NRF52840_XXAA +#endif //defined(NRF52840_XXAA) || defined(NRF52811_XXAA) || defined(NRF52833_XXAA) m_radio_mode == RADIO_MODE_MODE_Ble_1Mbit || m_radio_mode == RADIO_MODE_MODE_Ble_2Mbit ) @@ -106,7 +116,7 @@ bool dtm_hw_set_timer(NRF_TIMER_Type ** mp_timer, IRQn_Type * m_timer_irq, uint3 *mp_timer = NRF_TIMER2; *m_timer_irq = TIMER2_IRQn; } -#ifndef NRF52810_XXAA +#if !defined(NRF52810_XXAA) && !defined(NRF52811_XXAA) else if (new_timer == 3) { *mp_timer = NRF_TIMER3; @@ -117,7 +127,7 @@ bool dtm_hw_set_timer(NRF_TIMER_Type ** mp_timer, IRQn_Type * m_timer_irq, uint3 *mp_timer = NRF_TIMER4; *m_timer_irq = TIMER4_IRQn; } -#endif //NRF52810_XXAA +#endif //!defined(NRF52810_XXAA) && !defined(NRF52811_XXAA) else { // Parameter error: Only TIMER 0, 1, 2, 3 and 4 provided by nRF52 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c index e64fc61..92077be 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,53 +35,45 @@ * 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 "ble_link_ctx_manager.h" #include "sdk_common.h" -#if NRF_MODULE_ENABLED(NRF_CRYPTO) -#if NRF_CRYPTO_BACKEND_MICRO_ECC -#include "micro_ecc_lib_init.h" -#include "nrf_crypto_rng.h" -#include "uECC.h" - -static bool g_is_initialized = false; - -uint32_t nrf_crypto_init(void) +ret_code_t blcm_link_ctx_get(blcm_link_ctx_storage_t const * const p_link_ctx_storage, + uint16_t const conn_handle, + void ** const pp_ctx_data) { - uint32_t ret_val = NRF_SUCCESS; - -#if NRF_CRYPTO_BACKEND_MICRO_ECC_RNG - - ret_val = nrf_crypto_rng_init(); + uint8_t conn_id; -#endif - - if (ret_val == NRF_SUCCESS) + if (pp_ctx_data == NULL) { - g_is_initialized = true; + return NRF_ERROR_NULL; } else { - g_is_initialized = false; + *pp_ctx_data = NULL; } - return ret_val; -} + VERIFY_PARAM_NOT_NULL(p_link_ctx_storage); + VERIFY_PARAM_NOT_NULL(p_link_ctx_storage->p_ctx_data_pool); + VERIFY_TRUE((p_link_ctx_storage->link_ctx_size % BYTES_PER_WORD) == 0, NRF_ERROR_INVALID_PARAM); + conn_id = ble_conn_state_conn_idx(conn_handle); -uint32_t nrf_crypto_uninit(void) -{ - // Not possible in this nrf_crypto backend. - return NRF_SUCCESS; -} + if (conn_id == BLE_CONN_STATE_MAX_CONNECTIONS) + { + return NRF_ERROR_NOT_FOUND; + } + if (conn_id >= p_link_ctx_storage->max_links_cnt) + { + return NRF_ERROR_NO_MEM; + } -bool nrf_crypto_is_initialized(void) -{ - return g_is_initialized; + *pp_ctx_data = (void *) ((uint8_t *) p_link_ctx_storage->p_ctx_data_pool + + conn_id * p_link_ctx_storage->link_ctx_size); + return NRF_SUCCESS; } -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.h new file mode 100644 index 0000000..57bd09f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.h @@ -0,0 +1,127 @@ +/** + * Copyright (c) 2017 - 2019, 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 ble_link_ctx_manager BLE Link Context Manager + * @{ + * @ingroup ble_sdk_lib + * @brief Storage for link-related data. + * + * @details BLE Link Context Manager can be used as a simple storage for link-related data. + * Each link context data is uniquely identified within the storage by its connection + * handle and can be retrieved from it by using this handle. + * + */ +#ifndef BLE_LINK_CTX_MANAGER_H__ +#define BLE_LINK_CTX_MANAGER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "ble_conn_state.h" +#include "sdk_errors.h" + + +/**@brief Macro for defining a blcm_link_ctx_storage instance. + * + * @param[in] _name Name of the instance. + * @param[in] _max_clients Maximum number of clients connected at a time. + * @param[in] _link_ctx_size Context size in bytes for a single link. + */ +#define BLE_LINK_CTX_MANAGER_DEF(_name, _max_clients, _link_ctx_size) \ + STATIC_ASSERT((_max_clients) <= BLE_CONN_STATE_MAX_CONNECTIONS); \ + static uint32_t CONCAT_2(_name, _ctx_data_pool)[(_max_clients)*BYTES_TO_WORDS(_link_ctx_size)]; \ + static blcm_link_ctx_storage_t _name = \ + { \ + .p_ctx_data_pool = CONCAT_2(_name, _ctx_data_pool), \ + .max_links_cnt = (_max_clients), \ + .link_ctx_size = sizeof(CONCAT_2(_name, _ctx_data_pool))/(_max_clients) \ + } + + +/** + * @brief Type of description that is used for registry of all current connections. + */ +typedef struct +{ + void * const p_ctx_data_pool; /**< Pointer to links context memory pool. */ + uint8_t const max_links_cnt; /**< Maximum number of concurrent links. */ + uint16_t const link_ctx_size; /**< Context size in bytes for a single link (word-aligned). */ +} blcm_link_ctx_storage_t; + + +/** + * @brief Function for getting the link context from the link registry. + * + * This function finds the link context in the registry. The link to find is identified by the + * connection handle within the registry. + * + * The context is preserved for the lifetime of the connection. When a new connection occurs, the + * value of its context is undefined, and should be initialized. + * + * @param[in] p_link_ctx_storage Pointer to the link storage descriptor. + * @param[in] conn_handle Connection whose context to find. + * @param[out] pp_ctx_data Pointer to data with context for the connection. + * + * @retval NRF_ERROR_NULL If \p p_link_ctx_storage is NULL or contains a NULL pointer, or if + * \p pp_ctx_data is NULL. + * @retval NRF_ERROR_INVALID_PARAM If \p p_link_ctx_storage::link_ctx_size is not multiple of word + * size. + * @retval NRF_ERROR_NOT_FOUND If \p conn_handle does not refer to an active or recently + * disconnected link. + * @retval NRF_ERROR_NO_MEM If there is not enough memory to store context for the given + * connection handle. This can happen if the number of links is + * greater than \p p_link_ctx_storage::max_links_cnt. + * @retval NRF_SUCCESS If the operation was successful. + */ +ret_code_t blcm_link_ctx_get(blcm_link_ctx_storage_t const * const p_link_ctx_storage, + uint16_t const conn_handle, + void ** const pp_ctx_data); + + +#ifdef __cplusplus +} +#endif + +#endif // BLE_LINK_CTX_MANAGER_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_racp/ble_racp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_racp/ble_racp.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_racp/ble_racp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_racp/ble_racp.c index 41a4ccb..585d008 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_racp/ble_racp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_racp/ble_racp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_RACP) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_racp/ble_racp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_racp/ble_racp.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_racp/ble_racp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_racp/ble_racp.h index ae4b7b3..3a58eea 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_racp/ble_racp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_racp/ble_racp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -77,7 +77,8 @@ extern "C" { #define RACP_OPERATOR_RFU_START 7 /**< Record Access Control Point operator - Start of Reserved for Future Use area. */ /**@brief Record Access Control Point Operand Filter Type Value. */ -#define RACP_OPERAND_FILTER_TYPE_TIME_OFFSET 1 /**< Record Access Control Point Operand Filter Type Value - Time Offset- */ +#define RACP_OPERAND_FILTER_TYPE_TIME_OFFSET 1 /**< Record Access Control Point Operand Filter Type Value - Time Offset. */ +#define RACP_OPERAND_FILTER_TYPE_FACING_TIME 2 /**< Record Access Control Point Operand Filter Type Value - User Facing Time. */ /**@brief Record Access Control Point response codes. */ #define RACP_RESPONSE_RESERVED 0 /**< Record Access Control Point response code - Reserved for future use. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_radio_notification/ble_radio_notification.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_radio_notification/ble_radio_notification.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_radio_notification/ble_radio_notification.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_radio_notification/ble_radio_notification.c index ffdfdaa..997f3de 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_radio_notification/ble_radio_notification.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_radio_notification/ble_radio_notification.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,9 +35,10 @@ * 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 "ble_radio_notification.h" +#include "nrf_nvic.h" #include diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_radio_notification/ble_radio_notification.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_radio_notification/ble_radio_notification.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_radio_notification/ble_radio_notification.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_radio_notification/ble_radio_notification.h index 43e7946..91f4ad3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_radio_notification/ble_radio_notification.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_radio_notification/ble_radio_notification.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c new file mode 100644 index 0000000..303e982 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c @@ -0,0 +1,390 @@ +/** + * Copyright (c) 2016 - 2019, 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. + * + */ +/* Disclaimer: This client implementation of the Apple Notification Center Service can and will be changed at any time by Nordic Semiconductor ASA. + * Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working. + */ + +#include "ancs_app_attr_get.h" +#include "nrf_ble_ancs_c.h" +#include "sdk_macros.h" +#include "nrf_log.h" +#include "string.h" + +#define GATTC_OPCODE_SIZE 1 /**< Size of the GATTC OPCODE. */ +#define GATTC_ATTR_HANDLE_SIZE 4 /**< Size of the attribute handle. */ + + +#define ANCS_GATTC_WRITE_PAYLOAD_LEN_MAX (BLE_GATT_ATT_MTU_DEFAULT - GATTC_OPCODE_SIZE - GATTC_ATTR_HANDLE_SIZE) /**< Maximum length of the data that can be sent in one write. */ + + +/**@brief Enumeration for keeping track of the state-based encoding while requesting app attributes. */ +typedef enum +{ + APP_ATTR_COMMAND_ID, /**< Currently encoding the command ID. */ + APP_ATTR_APP_ID, /**< Currently encoding the app ID. */ + APP_ATTR_ATTR_ID, /**< Currently encoding the attribute ID. */ + APP_ATTR_DONE /**< Encoding done. */ +}encode_app_attr_t; + + +/**@brief Function for determining whether an attribute is requested. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * + * @return True If it is requested + * @return False If it is not requested. +*/ +static bool app_attr_is_requested(ble_ancs_c_t * p_ancs, uint32_t attr_id) +{ + if (p_ancs->ancs_app_attr_list[attr_id].get == true) + { + return true; + } + return false; +} + +/**@brief Function for counting the number of attributes that will be requested upon a "get app attributes" command. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * + * @return Number of attributes that will be requested upon a "get app attributes" command. +*/ +static uint32_t app_attr_nb_to_get(ble_ancs_c_t * p_ancs) +{ + uint32_t attr_nb_to_get = 0; + for (uint32_t i = 0; i < (sizeof(p_ancs->ancs_app_attr_list)/sizeof(ble_ancs_c_attr_list_t)); i++) + { + if (app_attr_is_requested(p_ancs,i)) + { + attr_nb_to_get++; + } + } + return attr_nb_to_get; +} + + +/**@brief Function for encoding the command ID as part of assembling a "get app attributes" command. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * @param[in] handle_value The handle that receives the execute command. + * @param[in] p_offset Pointer to the offset for the write. + * @param[in] p_index Pointer to the length encoded so far for the current write. + * @param[in,out] p_gq_req Pointer to the BLE GATT request structure. + */ +static ret_code_t queued_write_tx_message(ble_ancs_c_t * p_ancs, + uint16_t handle_value, + uint16_t * p_offset, + uint32_t * p_index, + nrf_ble_gq_req_t * p_gq_req) +{ + NRF_LOG_DEBUG("Starting new tx message."); + + p_gq_req->type = NRF_BLE_GQ_REQ_GATTC_WRITE; + p_gq_req->error_handler.cb = p_ancs->gatt_err_handler; + p_gq_req->error_handler.p_ctx = p_ancs; + p_gq_req->params.gattc_write.len = *p_index; + p_gq_req->params.gattc_write.offset = *p_offset; + p_gq_req->params.gattc_write.write_op = BLE_GATT_OP_PREP_WRITE_REQ; + p_gq_req->params.gattc_write.handle = handle_value; + + return nrf_ble_gq_item_add(p_ancs->p_gatt_queue, p_gq_req, p_ancs->conn_handle); +} + + +/**@brief Function for encoding the command ID as part of assembling a "get app attributes" command. + * + * @param[in] p_index Pointer to the length encoded so far for the current write. + * @param[in,out] p_gq_req Pointer to the BLE GATT request structure. + */ +static encode_app_attr_t app_attr_encode_cmd_id(uint32_t * index, + nrf_ble_gq_req_t * p_gq_req) +{ + uint8_t * p_value = (uint8_t *)p_gq_req->params.gattc_write.p_value; + NRF_LOG_DEBUG("Encoding command ID."); + + // Encode Command ID. + p_value[(*index)++] = BLE_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES; + return APP_ATTR_APP_ID; +} + +/**@brief Function for encoding the app ID as part of assembling a "get app attributes" command. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * @param[in] p_app_id The app ID of the app for which to request app attributes. + * @param[in] app_id_len Length of the app ID. + * @param[in] p_index Pointer to the length encoded so far for the current write. + * @param[in] p_offset Pointer to the accumulated offset for the next write. + * @param[in] p_gq_req Pointer to the BLE GATT request structure. + * @param[in] p_app_id_bytes_encoded_count Variable to keep count of the encoded app ID bytes. + * As long as it is lower than the length of the app ID, + * parsing continues. + */ +static encode_app_attr_t app_attr_encode_app_id(ble_ancs_c_t * p_ancs, + uint32_t * p_index, + uint16_t * p_offset, + nrf_ble_gq_req_t * p_gq_req, + const uint8_t * p_app_id, + const uint32_t app_id_len, + uint32_t * p_app_id_bytes_encoded_count) +{ + ret_code_t err_code; + uint8_t * p_value = (uint8_t *)p_gq_req->params.gattc_write.p_value; + + NRF_LOG_DEBUG("Encoding app ID."); + if (*p_index >= ANCS_GATTC_WRITE_PAYLOAD_LEN_MAX) + { + err_code = queued_write_tx_message(p_ancs, + p_ancs->service.control_point_char.handle_value, + p_offset, + p_index, + p_gq_req); + + if ((err_code != NRF_SUCCESS) && (p_ancs->error_handler != NULL)) + { + p_ancs->error_handler(err_code); + } + + *(p_offset) += *p_index; + *p_index = 0; + } + + //Encode app identifier. + if (*p_app_id_bytes_encoded_count == app_id_len) + { + p_value[(*p_index)++] = '\0'; + (*p_app_id_bytes_encoded_count)++; + } + NRF_LOG_DEBUG("%c", p_app_id[(*p_app_id_bytes_encoded_count)]); + if (*p_app_id_bytes_encoded_count < app_id_len) + { + p_value[(*p_index)++] = p_app_id[(*p_app_id_bytes_encoded_count)++]; + } + if (*p_app_id_bytes_encoded_count > app_id_len) + { + return APP_ATTR_ATTR_ID; + } + return APP_ATTR_APP_ID; +} + +/**@brief Function for encoding the attribute ID as part of assembling a "get app attributes" command. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * @param[in] p_index Pointer to the length encoded so far for the current write. + * @param[in] p_offset Pointer to the accumulated offset for the next write. + * @param[in,out] p_gq_req Pointer to the BLE GATT request structure. + * @param[in] p_attr_count Pointer to a variable that iterates the possible app attributes. + */ +static encode_app_attr_t app_attr_encode_attr_id(ble_ancs_c_t * p_ancs, + uint32_t * p_index, + uint16_t * p_offset, + nrf_ble_gq_req_t * p_gq_req, + uint32_t * p_attr_count, + uint32_t * attr_get_total_nb) +{ + ret_code_t err_code; + uint8_t * p_value = (uint8_t *)p_gq_req->params.gattc_write.p_value; + + NRF_LOG_DEBUG("Encoding attribute ID."); + if ((*p_index) >= ANCS_GATTC_WRITE_PAYLOAD_LEN_MAX) + { + err_code = queued_write_tx_message(p_ancs, + p_ancs->service.control_point_char.handle_value, + p_offset, + p_index, + p_gq_req); + + if ((err_code != NRF_SUCCESS) && (p_ancs->error_handler != NULL)) + { + p_ancs->error_handler(err_code); + } + *(p_offset) += *p_index; + *p_index = 0; + } + //Encode Attribute ID. + if (*p_attr_count < BLE_ANCS_NB_OF_APP_ATTR) + { + if (app_attr_is_requested(p_ancs, *p_attr_count)) + { + p_value[(*p_index)] = *p_attr_count; + p_ancs->number_of_requested_attr++; + (*p_index)++; + NRF_LOG_DEBUG("offset %i", *p_offset); + } + (*p_attr_count)++; + } + if (*p_attr_count == BLE_ANCS_NB_OF_APP_ATTR) + { + return APP_ATTR_DONE; + } + return APP_ATTR_APP_ID; +} + +/**@brief Function for writing the "execute write" command to a handle for a given connection. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * @param[in] handle_value Handle that receives the "execute write" command. + * @param[in] p_gq_req Pointer to the BLE GATT request structure. + */ +static ret_code_t app_attr_execute_write(ble_ancs_c_t * p_ancs, + uint16_t handle_value, + nrf_ble_gq_req_t * p_gq_req) +{ + NRF_LOG_DEBUG("Sending Execute Write command."); + memset(p_gq_req, 0, sizeof(nrf_ble_gq_req_t)); + + p_gq_req->type = NRF_BLE_GQ_REQ_GATTC_WRITE; + p_gq_req->error_handler.cb = p_ancs->gatt_err_handler; + p_gq_req->error_handler.p_ctx = p_ancs; + p_gq_req->params.gattc_write.handle = handle_value; + p_gq_req->params.gattc_write.offset = 0; + p_gq_req->params.gattc_write.write_op = BLE_GATT_OP_EXEC_WRITE_REQ; + p_gq_req->params.gattc_write.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE; + p_gq_req->params.gattc_write.len = 0; + + return nrf_ble_gq_item_add(p_ancs->p_gatt_queue, p_gq_req, p_ancs->conn_handle); +} + + +/**@brief Function for sending a "get app attributes" request. + * + * @details Since the app ID may not fit in a single write, long write + * with a state machine is used to encode the "get app attributes" request. + * + * @param[in] p_ancs iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. + * @param[in] p_app_id The app ID of the app for which to request app attributes. + * @param[in] app_id_len Length of the app ID. + * +*/ +static uint32_t app_attr_get(ble_ancs_c_t * p_ancs, + const uint8_t * p_app_id, + uint32_t app_id_len) +{ + uint32_t index = 0; + uint32_t attr_bytes_encoded_count = 0; + uint16_t offset = 0; + uint32_t app_id_bytes_encoded_count = 0; + encode_app_attr_t state = APP_ATTR_COMMAND_ID; + ret_code_t err_code; + + p_ancs->number_of_requested_attr = 0; + + uint32_t attr_get_total_nb = app_attr_nb_to_get(p_ancs); + nrf_ble_gq_req_t ancs_req; + uint8_t gatt_value[BLE_ANCS_WRITE_MAX_MSG_LENGTH]; + + memset(&ancs_req, 0, sizeof(nrf_ble_gq_req_t)); + + ancs_req.params.gattc_write.p_value = gatt_value; + + while (state != APP_ATTR_DONE) + { + switch (state) + { + case APP_ATTR_COMMAND_ID: + state = app_attr_encode_cmd_id(&index, + &ancs_req); + break; + case APP_ATTR_APP_ID: + state = app_attr_encode_app_id(p_ancs, + &index, + &offset, + &ancs_req, + p_app_id, + app_id_len, + &app_id_bytes_encoded_count); + break; + case APP_ATTR_ATTR_ID: + state = app_attr_encode_attr_id(p_ancs, + &index, + &offset, + &ancs_req, + &attr_bytes_encoded_count, + &attr_get_total_nb); + break; + case APP_ATTR_DONE: + break; + default: + break; + } + } + err_code = queued_write_tx_message(p_ancs, + p_ancs->service.control_point_char.handle_value, + &offset, + &index, + &ancs_req); + VERIFY_SUCCESS(err_code); + + err_code = app_attr_execute_write(p_ancs, + p_ancs->service.control_point_char.handle_value, + &ancs_req); + + p_ancs->parse_info.expected_number_of_attrs = p_ancs->number_of_requested_attr; + + return err_code; +} + + +uint32_t ancs_c_app_attr_request(ble_ancs_c_t * p_ancs, + const uint8_t * p_app_id, + uint32_t len) +{ + uint32_t err_code; + + if (len == 0) + { + return NRF_ERROR_DATA_SIZE; + } + if (p_app_id[len] != '\0') // App ID to be requested must be null-terminated. + { + return NRF_ERROR_INVALID_PARAM; + } + + p_ancs->parse_info.parse_state = COMMAND_ID; + err_code = app_attr_get(p_ancs, p_app_id, len); + VERIFY_SUCCESS(err_code); + return NRF_SUCCESS; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h index 708d295..ebeb775 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ANCS_APP_ATTR_GET_H__ #define ANCS_APP_ATTR_GET_H__ @@ -47,6 +47,8 @@ * @{ */ +#define BLE_ANCS_WRITE_MAX_MSG_LENGTH 20 /**< Maximum GATTC write length. */ + /**@brief Function for requesting attributes for an app. * * @param[in] p_ancs iOS notification structure. This structure must be supplied by diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c index e106856..001b431 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Disclaimer: This client implementation of the Apple Notification Center Service can and will be changed at any time by Nordic Semiconductor ASA. * Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h index 32c69d7..e7d378b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 BLE_ANCS_ATTR_PARSER_H__ #define BLE_ANCS_ATTR_PARSER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c index c89269d..fb1fcaf 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Disclaimer: This client implementation of the Apple Notification Center Service can and will be changed at any time by Nordic Semiconductor ASA. * Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working. @@ -43,7 +43,6 @@ #include "sdk_common.h" #if NRF_MODULE_ENABLED(BLE_ANCS_C) #include "nrf_ble_ancs_c.h" -#include "ancs_tx_buffer.h" #include "ancs_attr_parser.h" #include "ancs_app_attr_get.h" #include "ble_err.h" @@ -54,15 +53,15 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define BLE_ANCS_NOTIF_EVT_ID_INDEX 0 /**< Index of the Event ID field when parsing notifications. */ -#define BLE_ANCS_NOTIF_FLAGS_INDEX 1 /**< Index of the Flags field when parsing notifications. */ -#define BLE_ANCS_NOTIF_CATEGORY_ID_INDEX 2 /**< Index of the Category ID field when parsing notifications. */ -#define BLE_ANCS_NOTIF_CATEGORY_CNT_INDEX 3 /**< Index of the Category Count field when parsing notifications. */ -#define BLE_ANCS_NOTIF_NOTIF_UID 4 /**< Index of the Notification UID field when patsin notifications. */ +#define BLE_ANCS_NOTIF_EVT_ID_INDEX 0 /**< Index of the Event ID field when parsing notifications. */ +#define BLE_ANCS_NOTIF_FLAGS_INDEX 1 /**< Index of the Flags field when parsing notifications. */ +#define BLE_ANCS_NOTIF_CATEGORY_ID_INDEX 2 /**< Index of the Category ID field when parsing notifications. */ +#define BLE_ANCS_NOTIF_CATEGORY_CNT_INDEX 3 /**< Index of the Category Count field when parsing notifications. */ +#define BLE_ANCS_NOTIF_NOTIF_UID 4 /**< Index of the Notification UID field when parsing notifications. */ -#define BLE_CCCD_NOTIFY_BIT_MASK 0x0001 /**< Enable notification bit. */ +#define BLE_CCCD_NOTIFY_BIT_MASK 0x0001 /**< Enables notification bit. */ -#define TIME_STRING_LEN 15 /**< Unicode Technical Standard (UTS) #35 date format pattern "yyyyMMdd'T'HHmmSS" + "'\0'". */ +#define TIME_STRING_LEN 15 /**< Unicode Technical Standard (UTS) #35 date format pattern "yyyyMMdd'T'HHmmSS" + "'\0'". */ /**@brief 128-bit service UUID for the Apple Notification Center Service. */ @@ -108,11 +107,32 @@ ble_uuid128_t const ble_ancs_ds_base_uuid128 = }; +/**@brief Function for intercepting errors of GATTC and BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_ancs_c_t * p_ancs = (ble_ancs_c_t *)p_ctx; + + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0x%x", conn_handle); + + if (p_ancs->error_handler != NULL) + { + p_ancs->error_handler(nrf_error); + } +} + + /**@brief Function for handling Disconnected event received from the SoftDevice. * - * @details This function check if the disconnect event is happening on the link - * associated with the current instance of the module, if so it will set its - * conn_handle to invalid. + * @details This function checks whether the disconnect event is happening on the link + * associated with the current instance of the module. If the event is happening, + * the function sets the conn_handle of the instance to invalid. * * @param[in] p_ancs Pointer to the ANCS client structure. * @param[in] p_ble_evt Pointer to the BLE event received. @@ -128,14 +148,14 @@ static void on_disconnected(ble_ancs_c_t * p_ancs, ble_evt_t const * p_ble_evt) void ble_ancs_c_on_db_disc_evt(ble_ancs_c_t * p_ancs, ble_db_discovery_evt_t * p_evt) { - NRF_LOG_INFO("Database Discovery handler called with event 0x%x", p_evt->evt_type); + NRF_LOG_DEBUG("Database Discovery handler called with event 0x%x", p_evt->evt_type); ble_ancs_c_evt_t evt; ble_gatt_db_char_t * p_chars; p_chars = p_evt->params.discovered_db.charateristics; - // Check if the ANCS Service was discovered. + // Check whether the ANCS Service was discovered. if ( (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE) && (p_evt->params.discovered_db.srv_uuid.uuid == ANCS_UUID_SERVICE) && (p_evt->params.discovered_db.srv_uuid.type == p_ancs->service.service.uuid.type)) @@ -146,14 +166,14 @@ void ble_ancs_c_on_db_disc_evt(ble_ancs_c_t * p_ancs, ble_db_discovery_evt_t * p switch (p_chars[i].characteristic.uuid.uuid) { case ANCS_UUID_CHAR_CONTROL_POINT: - NRF_LOG_INFO("Control Point Characteristic found."); + NRF_LOG_INFO("Control Point characteristic found."); memcpy(&evt.service.control_point_char, &p_chars[i].characteristic, sizeof(ble_gattc_char_t)); break; case ANCS_UUID_CHAR_DATA_SOURCE: - NRF_LOG_INFO("Data Source Characteristic found."); + NRF_LOG_INFO("Data Source characteristic found."); memcpy(&evt.service.data_source_char, &p_chars[i].characteristic, sizeof(ble_gattc_char_t)); @@ -161,7 +181,7 @@ void ble_ancs_c_on_db_disc_evt(ble_ancs_c_t * p_ancs, ble_db_discovery_evt_t * p break; case ANCS_UUID_CHAR_NOTIFICATION_SOURCE: - NRF_LOG_INFO("Notification point Characteristic found."); + NRF_LOG_INFO("Notification Point characteristic found."); memcpy(&evt.service.notif_source_char, &p_chars[i].characteristic, sizeof(ble_gattc_char_t)); @@ -174,17 +194,22 @@ void ble_ancs_c_on_db_disc_evt(ble_ancs_c_t * p_ancs, ble_db_discovery_evt_t * p } evt.evt_type = BLE_ANCS_C_EVT_DISCOVERY_COMPLETE; evt.conn_handle = p_evt->conn_handle; - p_ancs->evt_handler(&evt); } - else + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) { evt.evt_type = BLE_ANCS_C_EVT_DISCOVERY_FAILED; - p_ancs->evt_handler(&evt); } + else + { + return; + } + + p_ancs->evt_handler(&evt); } -/**@brief Function for checking if data in an iOS notification is out of bounds. +/**@brief Function for checking whether the data in an iOS notification is out of bounds. * * @param[in] notif An iOS notification. * @@ -204,8 +229,8 @@ static uint32_t ble_ancs_verify_notification_format(ble_ancs_c_evt_notif_t const /**@brief Function for receiving and validating notifications received from the Notification Provider. * * @param[in] p_ancs Pointer to an ANCS instance to which the event belongs. - * @param[in] p_data_src Pointer to data that was received from the Notification Provider. - * @param[in] hvx_len Length of the data that was received by the Notification Provider. + * @param[in] p_data_src Pointer to the data that was received from the Notification Provider. + * @param[in] hvx_len Length of the data that was received from the Notification Provider. */ static void parse_notif(ble_ancs_c_t const * p_ancs, uint8_t const * p_data_src, @@ -219,7 +244,7 @@ static void parse_notif(ble_ancs_c_t const * p_ancs, p_ancs->evt_handler(&ancs_evt); } - /*lint --e{415} --e{416} -save suppress Warning 415: possible access out of bond */ + /*lint --e{415} --e{416} -save suppress Warning 415: possible access out of bound*/ ancs_evt.notif.evt_id = (ble_ancs_c_evt_id_values_t) p_data_src[BLE_ANCS_NOTIF_EVT_ID_INDEX]; @@ -297,7 +322,7 @@ static void on_evt_gattc_notif(ble_ancs_c_t * p_ancs, ble_evt_t const * p_ble_ev /**@brief Function for handling error response events. * - * @param[in] p_ancs_c Pointer to the Battery Service Client Structure. + * @param[in] p_ancs Pointer to an ANCS instance to which the event belongs. * @param[in] p_ble_evt Pointer to the SoftDevice event. */ static void on_ctrlpt_error_rsp(ble_ancs_c_t * p_ancs, ble_evt_t const * p_ble_evt) @@ -312,12 +337,12 @@ static void on_ctrlpt_error_rsp(ble_ancs_c_t * p_ancs, ble_evt_t const * p_ble_e /**@brief Function for handling write response events. * - * @param[in] p_ancs_c Pointer to the Battery Service Client Structure. + * @param[in] p_ancs Pointer to an ANCS instance to which the event belongs. * @param[in] p_ble_evt Pointer to the SoftDevice event. */ static void on_write_rsp(ble_ancs_c_t * p_ancs, ble_evt_t const* p_ble_evt) { - // Check if the event if on the link for this instance + // Check if the event is on the link for this instance. if (p_ancs->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { return; @@ -327,8 +352,6 @@ static void on_write_rsp(ble_ancs_c_t * p_ancs, ble_evt_t const* p_ble_evt) { on_ctrlpt_error_rsp(p_ancs,p_ble_evt); } - // Check if there is any message to be sent across to the peer and send it. - tx_buffer_process(); } @@ -361,27 +384,28 @@ ret_code_t ble_ancs_c_init(ble_ancs_c_t * p_ancs, ble_ancs_c_init_t const * p_an { uint32_t err_code; - //Verify that the parameters needed for to initialize this instance of ANCS are not NULL. + // Verify that the parameters needed for initializing this instance of ANCS are not NULL. VERIFY_PARAM_NOT_NULL(p_ancs); VERIFY_PARAM_NOT_NULL(p_ancs_init); VERIFY_PARAM_NOT_NULL(p_ancs_init->evt_handler); - //Initialize state for the attribute parsing state machine. - p_ancs->parse_info.parse_state = COMMAND_ID; - p_ancs->parse_info.p_data_dest = NULL; + // Initialize state for the attribute-parsing state machine. + p_ancs->parse_info.parse_state = COMMAND_ID; + p_ancs->parse_info.p_data_dest = NULL; p_ancs->parse_info.current_attr_index = 0; p_ancs->parse_info.current_app_id_index = 0; - p_ancs->evt_handler = p_ancs_init->evt_handler; - p_ancs->error_handler = p_ancs_init->error_handler; - p_ancs->conn_handle = BLE_CONN_HANDLE_INVALID; + p_ancs->evt_handler = p_ancs_init->evt_handler; + p_ancs->error_handler = p_ancs_init->error_handler; + p_ancs->conn_handle = BLE_CONN_HANDLE_INVALID; + p_ancs->p_gatt_queue = p_ancs_init->p_gatt_queue; + p_ancs->gatt_err_handler = gatt_error_handler; p_ancs->service.data_source_cccd.uuid.uuid = BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG; p_ancs->service.notif_source_cccd.uuid.uuid = BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG; - // Make sure instance of service is clear. GATT handles inside the service and characteristics are set to @ref BLE_GATT_HANDLE_INVALID. + // Make sure that the instance of service is clear. GATT handles inside the service and characteristics are set to @ref BLE_GATT_HANDLE_INVALID. memset(&p_ancs->service, 0, sizeof(ble_ancs_c_service_t)); - tx_buffer_init(); // Assign UUID types. err_code = sd_ble_uuid_vs_add(&ble_ancs_base_uuid128, &p_ancs->service.service.uuid.type); @@ -404,113 +428,121 @@ ret_code_t ble_ancs_c_init(ble_ancs_c_t * p_ancs, ble_ancs_c_init_t const * p_an } -/**@brief Function for creating a TX message for writing a CCCD. +/**@brief Function for creating a tx message for writing a CCCD. * - * @param[in] conn_handle Connection handle on which to perform the configuration. + * @param[in] p_ancs Pointer to the iOS notification structure. This structure must be supplied by + * the application. It identifies the particular client instance to use. * @param[in] handle_cccd Handle of the CCCD. - * @param[in] enable Enable or disable GATTC notifications. + * @param[in] enable Enables or disables GATTC notifications. * - * @retval NRF_SUCCESS If the message was created successfully. - * @retval NRF_ERROR_INVALID_PARAM If one of the input parameters was invalid. + * @retval NRF_SUCCESS If the message is created successfully. + * @retval NRF_ERROR_INVALID_PARAM If one of the input parameters is invalid. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ -static uint32_t cccd_configure(const uint16_t conn_handle, const uint16_t handle_cccd, bool enable) +static uint32_t cccd_configure(ble_ancs_c_t const * const p_ancs, + uint16_t const handle_cccd, + bool notification_enable) { - tx_message_t p_msg; - memset(&p_msg, 0, sizeof(tx_message_t)); - uint16_t cccd_val = enable ? BLE_CCCD_NOTIFY_BIT_MASK : 0; - - p_msg.req.write_req.gattc_params.handle = handle_cccd; - p_msg.req.write_req.gattc_params.len = 2; - p_msg.req.write_req.gattc_params.p_value = p_msg.req.write_req.gattc_value; - p_msg.req.write_req.gattc_params.offset = 0; - p_msg.req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg.req.write_req.gattc_value[0] = LSB_16(cccd_val); - p_msg.req.write_req.gattc_value[1] = MSB_16(cccd_val); - p_msg.conn_handle = conn_handle; - p_msg.type = WRITE_REQ; - - tx_buffer_insert(&p_msg); - - tx_buffer_process(); - return NRF_SUCCESS; + nrf_ble_gq_req_t ancs_c_req; + uint8_t cccd[BLE_CCCD_VALUE_LEN]; + uint16_t cccd_val = notification_enable ? BLE_GATT_HVX_NOTIFICATION : 0; + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + memset(&ancs_c_req, 0, sizeof(nrf_ble_gq_req_t)); + + ancs_c_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + ancs_c_req.error_handler.cb = p_ancs->gatt_err_handler; + ancs_c_req.error_handler.p_ctx = (ble_ancs_c_t *)p_ancs; + ancs_c_req.params.gattc_write.handle = handle_cccd; + ancs_c_req.params.gattc_write.len = BLE_CCCD_VALUE_LEN; + ancs_c_req.params.gattc_write.offset = 0; + ancs_c_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + ancs_c_req.params.gattc_write.p_value = cccd; + + return nrf_ble_gq_item_add(p_ancs->p_gatt_queue, &ancs_c_req, p_ancs->conn_handle); } ret_code_t ble_ancs_c_notif_source_notif_enable(ble_ancs_c_t const * p_ancs) { - NRF_LOG_INFO("Enable Notification Source notifications. writing to handle: %i ", + NRF_LOG_INFO("Enable Notification Source. Writing to CCCD handle: %i. ", p_ancs->service.notif_source_cccd.handle); - return cccd_configure(p_ancs->conn_handle, p_ancs->service.notif_source_cccd.handle, true); + return cccd_configure(p_ancs, p_ancs->service.notif_source_cccd.handle, true); } ret_code_t ble_ancs_c_notif_source_notif_disable(ble_ancs_c_t const * p_ancs) { - return cccd_configure(p_ancs->conn_handle, p_ancs->service.notif_source_cccd.handle, false); + return cccd_configure(p_ancs, p_ancs->service.notif_source_cccd.handle, false); } ret_code_t ble_ancs_c_data_source_notif_enable(ble_ancs_c_t const * p_ancs) { - NRF_LOG_INFO("Enable Data Source notifications. Writing to handle: %i ", + NRF_LOG_INFO("Enable Notification Data Source. Writing to CCCD handle: %i. ", p_ancs->service.data_source_cccd.handle); - return cccd_configure(p_ancs->conn_handle, p_ancs->service.data_source_cccd.handle, true); + return cccd_configure(p_ancs, p_ancs->service.data_source_cccd.handle, true); } ret_code_t ble_ancs_c_data_source_notif_disable(ble_ancs_c_t const * p_ancs) { - return cccd_configure(p_ancs->conn_handle, p_ancs->service.data_source_cccd.handle, false); + return cccd_configure(p_ancs, p_ancs->service.data_source_cccd.handle, false); } uint32_t ble_ancs_get_notif_attrs(ble_ancs_c_t * p_ancs, uint32_t const p_uid) { - tx_message_t p_msg; - memset(&p_msg, 0, sizeof(tx_message_t)); + nrf_ble_gq_req_t ancs_req; + uint8_t gattc_value[BLE_ANCS_WRITE_MAX_MSG_LENGTH]; + + memset(&ancs_req, 0, sizeof(nrf_ble_gq_req_t)); uint32_t index = 0; p_ancs->number_of_requested_attr = 0; - - p_msg.req.write_req.gattc_params.handle = p_ancs->service.control_point_char.handle_value; - p_msg.req.write_req.gattc_params.p_value = p_msg.req.write_req.gattc_value; - p_msg.req.write_req.gattc_params.offset = 0; - p_msg.req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; + ancs_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + ancs_req.error_handler.cb = p_ancs->gatt_err_handler; + ancs_req.error_handler.p_ctx = p_ancs; + ancs_req.params.gattc_write.handle = p_ancs->service.control_point_char.handle_value; + ancs_req.params.gattc_write.offset = 0; + ancs_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + ancs_req.params.gattc_write.p_value = gattc_value; //Encode Command ID. - p_msg.req.write_req.gattc_value[index++] = BLE_ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES; + gattc_value[index++] = BLE_ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES; //Encode Notification UID. - index += uint32_encode(p_uid, &(p_msg.req.write_req.gattc_value[index])); + index += uint32_encode(p_uid, &(gattc_value[index])); //Encode Attribute ID. for (uint32_t attr = 0; attr < BLE_ANCS_NB_OF_NOTIF_ATTR; attr++) { if (p_ancs->ancs_notif_attr_list[attr].get == true) { - p_msg.req.write_req.gattc_value[index++] = attr; + gattc_value[index++] = (uint8_t)attr; + if ((attr == BLE_ANCS_NOTIF_ATTR_ID_TITLE) || (attr == BLE_ANCS_NOTIF_ATTR_ID_SUBTITLE) || (attr == BLE_ANCS_NOTIF_ATTR_ID_MESSAGE)) { - //Encode Length field, only applicable for Title, Subtitle and Message + //Encode Length field. Only applicable for Title, Subtitle, and Message. index += uint16_encode(p_ancs->ancs_notif_attr_list[attr].attr_len, - &(p_msg.req.write_req.gattc_value[index])); + &(gattc_value[index])); } + p_ancs->number_of_requested_attr++; } } - p_msg.req.write_req.gattc_params.len = index; - p_msg.conn_handle = p_ancs->conn_handle; - p_msg.type = WRITE_REQ; - p_ancs->parse_info.expected_number_of_attrs = p_ancs->number_of_requested_attr; - tx_buffer_insert(&p_msg); - tx_buffer_process(); + ancs_req.params.gattc_write.len = index; + p_ancs->parse_info.expected_number_of_attrs = p_ancs->number_of_requested_attr; - return NRF_SUCCESS; + return nrf_ble_gq_item_add(p_ancs->p_gatt_queue, &ancs_req, p_ancs->conn_handle); } @@ -609,24 +641,23 @@ ret_code_t nrf_ancs_perform_notif_action(ble_ancs_c_t * p_ancs, uint32_t uid, bl { VERIFY_PARAM_NOT_NULL(p_ancs); - tx_message_t msg; - memset(&msg, 0, sizeof(tx_message_t)); - - uint16_t len = encode_notif_action(msg.req.write_req.gattc_value, uid, action_id); + nrf_ble_gq_req_t ancs_req; + uint8_t gattc_value[BLE_ANCS_WRITE_MAX_MSG_LENGTH]; - msg.req.write_req.gattc_params.handle = p_ancs->service.control_point_char.handle_value; - msg.req.write_req.gattc_params.p_value = msg.req.write_req.gattc_value; - msg.req.write_req.gattc_params.offset = 0; - msg.req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; + memset(&ancs_req, 0, sizeof(nrf_ble_gq_req_t)); - msg.req.write_req.gattc_params.len = len; - msg.conn_handle = p_ancs->conn_handle; - msg.type = WRITE_REQ; + uint16_t len = encode_notif_action(gattc_value, uid, action_id); - tx_buffer_insert(&msg); - tx_buffer_process(); + ancs_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + ancs_req.error_handler.cb = p_ancs->gatt_err_handler; + ancs_req.error_handler.p_ctx = p_ancs; + ancs_req.params.gattc_write.handle = p_ancs->service.control_point_char.handle_value; + ancs_req.params.gattc_write.p_value = gattc_value; + ancs_req.params.gattc_write.offset = 0; + ancs_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + ancs_req.params.gattc_write.len = len; - return NRF_SUCCESS; + return nrf_ble_gq_item_add(p_ancs->p_gatt_queue, &ancs_req, p_ancs->conn_handle); } ret_code_t nrf_ble_ancs_c_handles_assign(ble_ancs_c_t * p_ancs, @@ -646,7 +677,7 @@ ret_code_t nrf_ble_ancs_c_handles_assign(ble_ancs_c_t * p_ancs, p_ancs->service.notif_source_char.handle_value = p_peer_handles->notif_source_char.handle_value; } - return NRF_SUCCESS; + return nrf_ble_gq_conn_handle_register(p_ancs->p_gatt_queue, conn_handle); } #endif// NRF_MODULE_ENABLED(BLE_ANCS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h index d461b2a..79fecb6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,15 +35,15 @@ * 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 ble_ancs_c Apple Notification Service client + * @defgroup ble_ancs_c Apple Notification Service Client * @{ * @ingroup ble_sdk_srv * - * @brief Apple Notification Center Service Client Module. + * @brief Apple Notification Center Service Client module. * * @details Disclaimer: This client implementation of the Apple Notification Center Service can * be changed at any time by Nordic Semiconductor ASA. Server implementations such as the @@ -53,14 +53,14 @@ * This module implements the Apple Notification Center Service (ANCS) client. * This client can be used as a Notification Consumer (NC) that receives data * notifications from a Notification Provider (NP). The NP is typically an iOS - * device acting as a server. For terminology and up-to-date specs, see + * device that is acting as a server. For terminology and up-to-date specs, see * http://developer.apple.com. * * The term "notification" is used in two different meanings: * - An iOS notification is the data received from the Notification Provider. * - A GATTC notification is a way to transfer data with Bluetooth Smart. - * In this module, we receive iOS notifications using GATTC notifications. - * We use the full term (iOS notification or GATTC notification) where required to avoid confusion. + * In this module, iOS notifications are received through the GATTC notifications. + * The full term (iOS notification or GATTC notification) is used where required to avoid confusion. * * Upon initializing the module, you must add the different iOS notification attributes you * would like to receive for iOS notifications (see @ref nrf_ble_ancs_c_attr_add). @@ -71,13 +71,13 @@ * assigned to an ANCS_C instance using the @ref nrf_ble_ancs_c_handles_assign function. For more * information about service discovery, see the @ref lib_ble_db_discovery documentation. * - * The application can now subscribe to iOS notifications using - * @ref ble_ancs_c_notif_source_notif_enable. They arrive in the @ref BLE_ANCS_C_EVT_NOTIF event. - * @ref nrf_ble_ancs_c_request_attrs can be used to request attributes for the notifications. They + * The application can now subscribe to iOS notifications with + * @ref ble_ancs_c_notif_source_notif_enable. The notifications arrive in the @ref BLE_ANCS_C_EVT_NOTIF event. + * @ref nrf_ble_ancs_c_request_attrs can be used to request attributes for the notifications. The attributes * arrive in the @ref BLE_ANCS_C_EVT_NOTIF_ATTRIBUTE event. - * @ref nrf_ble_ancs_c_app_attr_request can be used to request attributes of the app that issued - * the notifications. They arrive in the @ref BLE_ANCS_C_EVT_APP_ATTRIBUTE event. - * @ref nrf_ancs_perform_notif_action can be used to make the Notification Provider perform an + * Use @ref nrf_ble_ancs_c_app_attr_request to request attributes of the app that issued + * the notifications. The app attributes arrive in the @ref BLE_ANCS_C_EVT_APP_ATTRIBUTE event. + * Use @ref nrf_ancs_perform_notif_action to make the Notification Provider perform an * action based on the provided notification. * * @msc @@ -103,7 +103,7 @@ * |||; * @endmsc * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_ancs_c_t instance; @@ -119,6 +119,7 @@ #include "sdk_errors.h" #include "ble_db_discovery.h" #include "nrf_sdh_ble.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -135,8 +136,20 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_ANCS_C_BLE_OBSERVER_PRIO, \ ble_ancs_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple ble_ancs_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_ANCS_C_ARRAY_DEF(_name, _cnt) \ +sstatic ble_ancs_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_ANCS_C_BLE_OBSERVER_PRIO, \ + ble_ancs_c_on_ble_evt, &_name, _cnt) + #define BLE_ANCS_ATTR_DATA_MAX 32 //!< Maximum data length of an iOS notification attribute. -#define BLE_ANCS_NB_OF_CATEGORY_ID 12 //!< Number of iOS notification categories: Other, Incoming Call, Missed Call, Voice Mail, Social, Schedule, Email, News, Health And Fitness, Business And Finance, Location, Entertainment. +#define BLE_ANCS_NB_OF_CATEGORY_ID 12 //!< Number of iOS notification categories: Other, Incoming Call, Missed Call, Voice Mail, Social, Schedule, Email, News, Health and Fitness, Business and Finance, Location, Entertainment. #define BLE_ANCS_NB_OF_NOTIF_ATTR 8 //!< Number of iOS notification attributes: AppIdentifier, Title, Subtitle, Message, MessageSize, Date, PositiveActionLabel, NegativeActionLabel. #define BLE_ANCS_NB_OF_APP_ATTR 1 //!< Number of iOS application attributes: DisplayName. #define BLE_ANCS_NB_OF_EVT_ID 3 //!< Number of iOS notification events: Added, Modified, Removed. @@ -165,7 +178,7 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, * @{ */ #define BLE_ANCS_NP_UNKNOWN_COMMAND 0x01A0 //!< The command ID is unknown to the NP. #define BLE_ANCS_NP_INVALID_COMMAND 0x01A1 //!< The command format is invalid. -#define BLE_ANCS_NP_INVALID_PARAMETER 0x01A2 //!< One or more parameters does not exist in the NP. +#define BLE_ANCS_NP_INVALID_PARAMETER 0x01A2 //!< One or more parameters do not exist in the NP. #define BLE_ANCS_NP_ACTION_FAILED 0x01A3 //!< The action failed to be performed by the NP. /** @} */ @@ -185,16 +198,16 @@ typedef enum /**@brief Category IDs for iOS notifications. */ typedef enum { - BLE_ANCS_CATEGORY_ID_OTHER, /**< The iOS notification belongs to the "other" category. */ + BLE_ANCS_CATEGORY_ID_OTHER, /**< The iOS notification belongs to the "Other" category. */ BLE_ANCS_CATEGORY_ID_INCOMING_CALL, /**< The iOS notification belongs to the "Incoming Call" category. */ BLE_ANCS_CATEGORY_ID_MISSED_CALL, /**< The iOS notification belongs to the "Missed Call" category. */ BLE_ANCS_CATEGORY_ID_VOICE_MAIL, /**< The iOS notification belongs to the "Voice Mail" category. */ BLE_ANCS_CATEGORY_ID_SOCIAL, /**< The iOS notification belongs to the "Social" category. */ BLE_ANCS_CATEGORY_ID_SCHEDULE, /**< The iOS notification belongs to the "Schedule" category. */ - BLE_ANCS_CATEGORY_ID_EMAIL, /**< The iOS notification belongs to the "E-mail" category. */ + BLE_ANCS_CATEGORY_ID_EMAIL, /**< The iOS notification belongs to the "Email" category. */ BLE_ANCS_CATEGORY_ID_NEWS, /**< The iOS notification belongs to the "News" category. */ BLE_ANCS_CATEGORY_ID_HEALTH_AND_FITNESS, /**< The iOS notification belongs to the "Health and Fitness" category. */ - BLE_ANCS_CATEGORY_ID_BUSINESS_AND_FINANCE, /**< The iOS notification belongs to the "Buisness and Finance" category. */ + BLE_ANCS_CATEGORY_ID_BUSINESS_AND_FINANCE, /**< The iOS notification belongs to the "Business and Finance" category. */ BLE_ANCS_CATEGORY_ID_LOCATION, /**< The iOS notification belongs to the "Location" category. */ BLE_ANCS_CATEGORY_ID_ENTERTAINMENT /**< The iOS notification belongs to the "Entertainment" category. */ } ble_ancs_c_category_id_val_t; @@ -212,7 +225,7 @@ typedef enum { BLE_ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES, /**< Requests attributes to be sent from the NP to the NC for a given notification. */ BLE_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES, /**< Requests attributes to be sent from the NP to the NC for a given iOS app. */ - BLE_ANCS_COMMAND_ID_GET_PERFORM_NOTIF_ACTION, /**< Requests an action to be performed on a given notification, for example, dismiss an alarm. */ + BLE_ANCS_COMMAND_ID_GET_PERFORM_NOTIF_ACTION, /**< Requests an action to be performed on a given notification. For example, dismiss an alarm. */ } ble_ancs_c_cmd_id_val_t; /**@brief IDs for actions that can be performed for iOS notifications. */ @@ -224,7 +237,7 @@ typedef enum /**@brief App attribute ID values. * @details Currently, only one value is defined. However, the number of app - * attributes might increase. Therefore, they are stored in an enumeration. + * attributes might increase. For this reason, they are stored in an enumeration. */ typedef enum { @@ -264,7 +277,7 @@ typedef enum ATTR_LEN1, /**< Parsing the LSB of the attribute length. */ ATTR_LEN2, /**< Parsing the MSB of the attribute length. */ ATTR_DATA, /**< Parsing the attribute data. */ - ATTR_SKIP, /**< Parsing is skipped for the rest (or entire) of an attribute. */ + ATTR_SKIP, /**< Parsing is skipped for the rest of an attribute (or entire attribute). */ DONE, /**< Parsing for one attribute is done. */ } ble_ancs_c_parse_state_t; @@ -273,8 +286,8 @@ typedef struct { uint32_t notif_uid; //!< Notification UID. ble_ancs_c_evt_id_values_t evt_id; //!< Whether the notification was added, removed, or modified. - ble_ancs_c_notif_flags_t evt_flags; //!< Bitmask to signal if a special condition applies to the notification, for example, "Silent" or "Important". - ble_ancs_c_category_id_val_t category_id; //!< Classification of the notification type, for example, email or location. + ble_ancs_c_notif_flags_t evt_flags; //!< Bitmask to signal whether a special condition applies to the notification. For example, "Silent" or "Important". + ble_ancs_c_category_id_val_t category_id; //!< Classification of the notification type. For example, email or location. uint8_t category_count; //!< Current number of active notifications for this category ID. } ble_ancs_c_evt_notif_t; @@ -282,7 +295,7 @@ typedef struct typedef struct { uint16_t attr_len; //!< Length of the received attribute data. - uint32_t attr_id; //!< Classification of the attribute type, for example, title or date. + uint32_t attr_id; //!< Classification of the attribute type. For example, "Title" or "Date". uint8_t * p_attr_data; //!< Pointer to where the memory is allocated for storing incoming attributes. } ble_ancs_c_attr_t; @@ -296,16 +309,16 @@ typedef struct typedef struct { uint16_t attr_len; //!< Length of the received attribute data. - uint32_t attr_id; //!< Classification of the attribute type, for example, title or date. + uint32_t attr_id; //!< Classification of the attribute type. For example, "Title" or "Date". uint8_t * p_attr_data; //!< Pointer to where the memory is allocated for storing incoming attributes. } ble_ancs_c_evt_app_attr_t; -/**@brief iOS notification attribute content wanted by our application. */ +/**@brief iOS notification attribute content requested by the application. */ typedef struct { - bool get; //!< Boolean to determine if this attribute will be requested from the Notification Provider. + bool get; //!< Boolean to determine whether this attribute will be requested from the Notification Provider. uint32_t attr_id; //!< Attribute ID: AppIdentifier(0), Title(1), Subtitle(2), Message(3), MessageSize(4), Date(5), PositiveActionLabel(6), NegativeActionLabel(7). - uint16_t attr_len; //!< Length of the attribute. If more data is received from the Notification Provider, all data beyond this length is discarded. + uint16_t attr_len; //!< Length of the attribute. If more data is received from the Notification Provider, all the data beyond this length is discarded. uint8_t * p_attr_data; //!< Pointer to where the memory is allocated for storing incoming attributes. } ble_ancs_c_attr_list_t; @@ -324,18 +337,18 @@ typedef struct /**@brief ANCS client module event structure. * - * @details The structure contains the event that should be handled by the main application. + * @details The structure contains the event that is to be handled by the main application. */ typedef struct { ble_ancs_c_evt_type_t evt_type; //!< Type of event. - uint16_t conn_handle; //!< Connection handle on which the ANCS service was discovered on the peer device. This field will be filled if the @p evt_type is @ref BLE_ANCS_C_EVT_DISCOVERY_COMPLETE. - ble_ancs_c_evt_notif_t notif; //!< iOS notification. This field will be filled if @p evt_type is @ref BLE_ANCS_C_EVT_NOTIF. - uint16_t err_code_np; //!< An error coming from the Notification Provider. This field will be filled with @ref BLE_ANCS_NP_ERROR_CODES if @p evt_type is @ref BLE_ANCS_C_EVT_NP_ERROR. + uint16_t conn_handle; //!< Connection handle on which the ANCS service was discovered on the peer device. This is filled if the @p evt_type is @ref BLE_ANCS_C_EVT_DISCOVERY_COMPLETE. + ble_ancs_c_evt_notif_t notif; //!< iOS notification. This is filled if @p evt_type is @ref BLE_ANCS_C_EVT_NOTIF. + uint16_t err_code_np; //!< An error coming from the Notification Provider. This is filled with @ref BLE_ANCS_NP_ERROR_CODES if @p evt_type is @ref BLE_ANCS_C_EVT_NP_ERROR. ble_ancs_c_attr_t attr; //!< iOS notification attribute or app attribute, depending on the event type. uint32_t notif_uid; //!< Notification UID. uint8_t app_id[BLE_ANCS_ATTR_DATA_MAX]; //!< App identifier. - ble_ancs_c_service_t service; //!< Information on the discovered Alert Notification Service. This field will be filled if the @p evt_type is @ref BLE_ANCS_C_EVT_DISCOVERY_COMPLETE. + ble_ancs_c_service_t service; //!< Information on the discovered Alert Notification Service. This is filled if the @p evt_type is @ref BLE_ANCS_C_EVT_DISCOVERY_COMPLETE. } ble_ancs_c_evt_t; /**@brief iOS notification event handler type. */ @@ -343,47 +356,51 @@ typedef void (*ble_ancs_c_evt_handler_t) (ble_ancs_c_evt_t * p_evt); typedef struct { - ble_ancs_c_attr_list_t * p_attr_list; //!< The current list of attributes being parsed. This field will point to either @ref ble_ancs_c_t::ancs_notif_attr_list or @ref ble_ancs_c_t::ancs_app_attr_list. + ble_ancs_c_attr_list_t * p_attr_list; //!< The current list of attributes that are being parsed. This will point to either @ref ble_ancs_c_t::ancs_notif_attr_list or @ref ble_ancs_c_t::ancs_app_attr_list. uint32_t nb_of_attr; //!< Number of possible attributes. When parsing begins, it is set to either @ref BLE_ANCS_NB_OF_NOTIF_ATTR or @ref BLE_ANCS_NB_OF_APP_ATTR. uint32_t expected_number_of_attrs; //!< The number of attributes expected upon receiving attributes. Keeps track of when to stop reading incoming attributes. ble_ancs_c_parse_state_t parse_state; //!< ANCS notification attribute parsing state. - ble_ancs_c_cmd_id_val_t command_id; //!< Variable to keep track of what command type we are currently parsing ( @ref BLE_ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES or @ref BLE_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES. - uint8_t * p_data_dest; //!< Attribute that the parsed data will be copied into. - uint16_t current_attr_index; //!< Variable to keep track of how much (for a given attribute) we are done parsing. - uint32_t current_app_id_index; //!< Variable to keep track of how much (for a given app identifier) we are done parsing. + ble_ancs_c_cmd_id_val_t command_id; //!< Variable to keep track of what command type is being parsed ( @ref BLE_ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES or @ref BLE_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES). + uint8_t * p_data_dest; //!< Attribute that the parsed data is copied into. + uint16_t current_attr_index; //!< Variable to keep track of the parsing progress, for the given attribute. + uint32_t current_app_id_index; //!< Variable to keep track of the parsing progress, for the given app identifier. } ble_ancs_parse_sm_t; /**@brief iOS notification structure, which contains various status information for the client. */ typedef struct { - ble_ancs_c_evt_handler_t evt_handler; //!< Event handler to be called for handling events in the Apple Notification client application. - ble_srv_error_handler_t error_handler; //!< Function to be called in case of an error. - uint16_t conn_handle; //!< Handle of the current connection. Set with @ref nrf_ble_ancs_c_handles_assign when connected. - ble_ancs_c_service_t service; //!< Structure to store the different handles and UUIDs related to the service. - ble_ancs_c_attr_list_t ancs_notif_attr_list[BLE_ANCS_NB_OF_NOTIF_ATTR]; //!< For all attributes; contains whether they should be requested upon attribute request and the length and buffer of where to store attribute data. - ble_ancs_c_attr_list_t ancs_app_attr_list[BLE_ANCS_NB_OF_APP_ATTR]; //!< For all app attributes; contains whether they should be requested upon attribute request and the length and buffer of where to store attribute data. - uint32_t number_of_requested_attr; //!< The number of attributes that will be requested when an iOS notification attribute request is made. - ble_ancs_parse_sm_t parse_info; //!< Structure containing different information used to parse incoming attributes (from data_source characteristic) correctly. - ble_ancs_c_evt_t evt; //!< The event is filled with several iterations of the @ref ancs_parse_get_attrs_response function when requesting iOS notification attributes. So we must allocate memory for it here. + ble_ancs_c_evt_handler_t evt_handler; //!< Event handler to be called for handling events in the Apple Notification client application. + ble_srv_error_handler_t error_handler; //!< Function to be called in case of an error. + nrf_ble_gq_req_error_cb_t gatt_err_handler; //!< Error handler to be called in case of an error from SoftDevice. + uint16_t conn_handle; //!< Handle of the current connection. Set with @ref nrf_ble_ancs_c_handles_assign when connected. + ble_ancs_c_service_t service; //!< Structure to store the different handles and UUIDs related to the service. + ble_ancs_c_attr_list_t ancs_notif_attr_list[BLE_ANCS_NB_OF_NOTIF_ATTR]; //!< For all attributes: contains information about whether the attributes are to be requested upon attribute request, and the length and buffer of where to store attribute data. + ble_ancs_c_attr_list_t ancs_app_attr_list[BLE_ANCS_NB_OF_APP_ATTR]; //!< For all app attributes: contains information about whether the attributes are to be requested upon attribute request, and the length and buffer of where to store attribute data. + uint32_t number_of_requested_attr; //!< The number of attributes that are to be requested when an iOS notification attribute request is made. + ble_ancs_parse_sm_t parse_info; //!< Structure containing different information used to parse incoming attributes correctly (from data_source characteristic). + ble_ancs_c_evt_t evt; //!< Allocate memory for the event here. The event is filled with several iterations of the @ref ancs_parse_get_attrs_response function when requesting iOS notification attributes. + nrf_ble_gq_t * p_gatt_queue; //!< Pointer to the BLE GATT Queue instance. + } ble_ancs_c_t; /**@brief Apple Notification client init structure, which contains all options and data needed for * initialization of the client. */ typedef struct { - ble_ancs_c_evt_handler_t evt_handler; //!< Event handler to be called for handling events in the Battery Service. - ble_srv_error_handler_t error_handler; //!< Function to be called in case of an error. + ble_ancs_c_evt_handler_t evt_handler; //!< Event handler to be called for handling events in the Battery Service. + ble_srv_error_handler_t error_handler; //!< Function to be called in case of an error. + nrf_ble_gq_t * p_gatt_queue; //!< Pointer to the BLE GATT Queue instance. } ble_ancs_c_init_t; /**@brief Apple Notification Center Service UUIDs. */ extern const ble_uuid128_t ble_ancs_base_uuid128; //!< Service UUID. -extern const ble_uuid128_t ble_ancs_cp_base_uuid128; //!< Control point UUID. -extern const ble_uuid128_t ble_ancs_ns_base_uuid128; //!< Notification source UUID. -extern const ble_uuid128_t ble_ancs_ds_base_uuid128; //!< Data source UUID. +extern const ble_uuid128_t ble_ancs_cp_base_uuid128; //!< Control Point UUID. +extern const ble_uuid128_t ble_ancs_ns_base_uuid128; //!< Notification Source UUID. +extern const ble_uuid128_t ble_ancs_ds_base_uuid128; //!< Data Source UUID. -/**@brief Function for handling the application's BLE stack events. +/**@brief Function for handling BLE stack events of the application. * * @details Handles all events from the BLE stack that are of interest to the ANCS client. * @@ -393,16 +410,16 @@ extern const ble_uuid128_t ble_ancs_ds_base_uuid128; //!< Data source UUID. void ble_ancs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details This function will handle an event from the database discovery module and determine - * if it relates to the discovery of ANCS at the peer. If so, it will - * call the application's event handler indicating that ANCS has been - * discovered at the peer. It also populates the event with the service related + * @details This function handles an event from the Database Discovery module and determines + * whether it relates to the discovery of ANCS at the peer. If it does, this function + * calls the application's event handler to indicate that ANCS was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * * @param[in] p_ancs Pointer to the ANCS client structure. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void ble_ancs_c_on_db_disc_evt(ble_ancs_c_t * p_ancs, ble_db_discovery_evt_t * p_evt); @@ -424,7 +441,9 @@ ret_code_t ble_ancs_c_init(ble_ancs_c_t * p_ancs, ble_ancs_c_init_t const * p_an * @param[in] p_ancs iOS notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ ret_code_t ble_ancs_c_notif_source_notif_enable(ble_ancs_c_t const * p_ancs); @@ -434,7 +453,9 @@ ret_code_t ble_ancs_c_notif_source_notif_enable(ble_ancs_c_t const * p_ancs); * @param[in] p_ancs iOS notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ ret_code_t ble_ancs_c_data_source_notif_enable(ble_ancs_c_t const * p_ancs); @@ -444,7 +465,9 @@ ret_code_t ble_ancs_c_data_source_notif_enable(ble_ancs_c_t const * p_ancs); * @param[in] p_ancs iOS notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ ret_code_t ble_ancs_c_notif_source_notif_disable(ble_ancs_c_t const * p_ancs); @@ -454,7 +477,9 @@ ret_code_t ble_ancs_c_notif_source_notif_disable(ble_ancs_c_t const * p_ancs); * @param[in] p_ancs iOS notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If writing to the CCCD was successful. Otherwise, + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ ret_code_t ble_ancs_c_data_source_notif_disable(ble_ancs_c_t const * p_ancs); @@ -462,12 +487,12 @@ ret_code_t ble_ancs_c_data_source_notif_disable(ble_ancs_c_t const * p_ancs); /**@brief Function for registering attributes that will be requested when @ref nrf_ble_ancs_c_request_attrs * is called. * - * @param[in] p_ancs ANCS client instance on which the attribute will be registered. - * @param[in] id ID of the attribute that will be added. - * @param[in] p_data Pointer to a buffer where the data of the attribute can be stored. + * @param[in] p_ancs ANCS client instance on which the attribute is registered. + * @param[in] id ID of the attribute that is added. + * @param[in] p_data Pointer to the buffer where the data of the attribute can be stored. * @param[in] len Length of the buffer where the data of the attribute can be stored. - * @retval NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned. */ ret_code_t nrf_ble_ancs_c_attr_add(ble_ancs_c_t * p_ancs, ble_ancs_c_notif_attr_id_val_t const id, @@ -475,24 +500,24 @@ ret_code_t nrf_ble_ancs_c_attr_add(ble_ancs_c_t * p_ancs, uint16_t const len); -/**@brief Function for removing attributes so that they will no longer be requested when +/**@brief Function for removing attributes, so that they are no longer requested when * @ref nrf_ble_ancs_c_request_attrs is called. * - * @param[in] p_ancs ANCS client instance on which the attribute will be removed. - * @param[in] id ID of the attribute that will be removed. + * @param[in] p_ancs ANCS client instance on which the attribute is removed. + * @param[in] id ID of the attribute that is removed. * - * @retval NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned. */ ret_code_t nrf_ble_ancs_c_attr_remove(ble_ancs_c_t * p_ancs, ble_ancs_c_notif_attr_id_val_t const id); -/**@brief Function for removing attributes so that they will no longer be requested when +/**@brief Function for removing attributes, so that they are no longer requested when * @ref nrf_ble_ancs_c_app_attr_request is called. * - * @param[in] p_ancs ANCS client instance on which the attribute will be removed. - * @param[in] id ID of the attribute that will be removed. + * @param[in] p_ancs ANCS client instance on which the attribute is removed. + * @param[in] id ID of the attribute that is removed. * - * @retval NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned. */ ret_code_t nrf_ble_ancs_c_app_attr_remove(ble_ancs_c_t * p_ancs, ble_ancs_c_app_attr_id_val_t const id); @@ -501,12 +526,12 @@ ret_code_t nrf_ble_ancs_c_app_attr_remove(ble_ancs_c_t * p_a /**@brief Function for registering attributes that will be requested when @ref nrf_ble_ancs_c_app_attr_request * is called. * - * @param[in] p_ancs ANCS client instance on which the attribute will be registered. - * @param[in] id ID of the attribute that will be added. - * @param[in] p_data Pointer to a buffer where the data of the attribute can be stored. + * @param[in] p_ancs ANCS client instance on which the attribute is registered. + * @param[in] id ID of the attribute that is added. + * @param[in] p_data Pointer to the buffer where the data of the attribute can be stored. * @param[in] len Length of the buffer where the data of the attribute can be stored. * - * @retval NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned. */ ret_code_t nrf_ble_ancs_c_app_attr_add(ble_ancs_c_t * p_ancs, ble_ancs_c_app_attr_id_val_t const id, @@ -528,7 +553,7 @@ ret_code_t nrf_ble_ancs_c_attr_req_clear_all(ble_ancs_c_t * p_ancs); * @param[in] p_notif Pointer to the notification whose attributes will be requested from * the Notification Provider. * - * @retval NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned. */ ret_code_t nrf_ble_ancs_c_request_attrs(ble_ancs_c_t * p_ancs, ble_ancs_c_evt_notif_t const * p_notif); @@ -540,7 +565,7 @@ ret_code_t nrf_ble_ancs_c_request_attrs(ble_ancs_c_t * p_ancs, * @param[in] p_app_id App identifier of the app for which the app attributes are requested. * @param[in] len Length of the app identifier. * - * @retval NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned. */ ret_code_t nrf_ble_ancs_c_app_attr_request(ble_ancs_c_t * p_ancs, uint8_t const * p_app_id, @@ -554,8 +579,10 @@ ret_code_t nrf_ble_ancs_c_app_attr_request(ble_ancs_c_t * p_ancs, * @param[in] uuid The UUID of the notification for which to perform the action. * @param[in] action_id Perform a positive or negative action. * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_NULL If @p p_ancs was a NULL pointer. + * @retval NRF_SUCCESS If the operation is successful. + * @retval NRF_ERROR_NULL If @p p_ancs is a NULL pointer. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ancs_perform_notif_action(ble_ancs_c_t * p_ancs, uint32_t uuid, @@ -564,19 +591,20 @@ ret_code_t nrf_ancs_perform_notif_action(ble_ancs_c_t * p_ancs, /**@brief Function for assigning a handle to this instance of ancs_c. * * @details Call this function when a link has been established with a peer to - * associate this link to this instance of the module. This makes it - * possible to handle several link and associate each link to a particular - * instance of this module. The connection handle and attribute handles will be + * associate the link to this instance of the module. This makes it + * possible to handle several links and associate each link to a particular + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_ANCS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in] p_ancs Pointer to the ANCS client structure instance to associate with these - * handles. - * @param[in] conn_handle Connection handle to associate with the given ANCS instance. + * @param[in] p_ancs Pointer to the ANCS client structure instance for associating the link. + * @param[in] conn_handle Connection handle to associated with the given ANCS instance. * @param[in] p_service Attribute handles on the ANCS server that you want this ANCS client to * interact with. * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_NULL If @p p_ancs was a NULL pointer. + * @retval NRF_SUCCESS If the operation is successful. + * @retval NRF_ERROR_NULL If @p p_ancs is a NULL pointer. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_conn_handle_register. */ ret_code_t nrf_ble_ancs_c_handles_assign(ble_ancs_c_t * p_ancs, uint16_t const conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ans_c/ble_ans_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ans_c/ble_ans_c.c similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ans_c/ble_ans_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ans_c/ble_ans_c.c index 866ba43..df3796f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ans_c/ble_ans_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ans_c/ble_ans_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -53,71 +53,28 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define NOTIFICATION_DATA_LENGTH 2 /**< The mandatory length of notification data. After the mandatory data, the optional message is located. */ +#define NOTIFICATION_DATA_LENGTH 2 /**< The mandatory length of the notification data. After the mandatory data, the optional message is located. */ #define READ_DATA_LENGTH_MIN 1 /**< Minimum data length in a valid Alert Notification Read Response message. */ +#define WRITE_MESSAGE_LENGTH 2 /**< Length of the write message for CCCD and control point. */ -#define TX_BUFFER_MASK 0x07 /**< TX Buffer mask, must be a mask of contiguous zeroes, followed by contiguous sequence of ones: 000...111. */ -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of send buffer, which is 1 higher than the mask. */ -#define WRITE_MESSAGE_LENGTH 2 /**< Length of the write message for CCCD/control point. */ - -typedef enum -{ - READ_REQ = 1, /**< Type identifying that this tx_message is a read request. */ - WRITE_REQ /**< Type identifying that this tx_message is a write request. */ -} ans_tx_request_t; - - -/**@brief Structure for writing a message to the central, i.e. Control Point or CCCD. +/**@brief Function for intercepting GATTC and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. */ -typedef struct +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) { - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; /**< The message to write. */ - ble_gattc_write_params_t gattc_params; /**< GATTC parameters for this message. */ -} ans_write_params_t; - -/**@brief Structure for holding data to be transmitted to the connected central. - */ -typedef struct -{ - uint16_t conn_handle; /**< Connection handle to be used when transmitting this message. */ - ans_tx_request_t type; /**< Type of this message, i.e. read or write message. */ - union - { - uint16_t read_handle; /**< Read request message. */ - ans_write_params_t write_req; /**< Write request message. */ - } req; -} ans_tx_message_t; - -static ans_tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for messages to be transmitted to the central. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer from where the next message to be transmitted resides. */ + ble_ans_c_t * p_ans = (ble_ans_c_t *)p_ctx; + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); -/**@brief Function for passing any pending request from the buffer to the stack. - */ -static void tx_buffer_process(void) -{ - if (m_tx_index != m_tx_insert_index) + if (p_ans->error_handler != NULL) { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - ++m_tx_index; - m_tx_index &= TX_BUFFER_MASK; - } + p_ans->error_handler(nrf_error); } } @@ -134,7 +91,7 @@ static void char_cccd_set(ble_gattc_desc_t * p_cccd, uint16_t cccd_handle) p_cccd->handle = cccd_handle; } -/** @brief Function to check that all handles required by the client to use the server are present. +/** @brief Function for checking the presence of all the handles required by the client to use the server. */ static bool is_valid_ans_srv_discovered(ble_ans_c_service_t const * p_srv) { @@ -160,9 +117,8 @@ void ble_ans_c_on_db_disc_evt(ble_ans_c_t * p_ans, ble_db_discovery_evt_t const memset(&evt, 0, sizeof(ble_ans_c_evt_t)); evt.conn_handle = p_evt->conn_handle; - evt.evt_type = BLE_ANS_C_EVT_DISCOVERY_FAILED; - // Check if the Alert Notification Service was discovered. + // Check if the Alert Notification Service is discovered. if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE && p_evt->params.discovered_db.srv_uuid.uuid == BLE_UUID_ALERT_NOTIFICATION_SERVICE @@ -215,6 +171,16 @@ void ble_ans_c_on_db_disc_evt(ble_ans_c_t * p_ans, ble_db_discovery_evt_t const evt.evt_type = BLE_ANS_C_EVT_DISCOVERY_COMPLETE; } } + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) + { + evt.evt_type = BLE_ANS_C_EVT_DISCOVERY_FAILED; + } + else + { + return; + } + p_ans->evt_handler(&evt); } @@ -228,7 +194,7 @@ static void event_notify(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) ble_ans_alert_notification_t * p_alert = &event.data.alert; ble_gattc_evt_hvx_t const * p_notification = &p_ble_evt->evt.gattc_evt.params.hvx; - // Message is not valid -> ignore. + // If the message is not valid, then ignore. event.evt_type = BLE_ANS_C_EVT_NOTIFICATION; if (p_notification->len < NOTIFICATION_DATA_LENGTH) { @@ -265,14 +231,6 @@ static void event_notify(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) } -/**@brief Function for handling write response events. - */ -static void event_write_rsp(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) -{ - tx_buffer_process(); -} - - /**@brief Function for validating and passing the response to the application, * when a read response is received. */ @@ -286,7 +244,6 @@ static void event_read_rsp(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) if (p_response->len < READ_DATA_LENGTH_MIN) { - tx_buffer_process(); return; } @@ -300,8 +257,7 @@ static void event_read_rsp(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) } else { - // Bad response, ignore. - tx_buffer_process(); + // If the response is not valid, then ignore. return; } @@ -309,14 +265,12 @@ static void event_read_rsp(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) if (p_response->len == READ_DATA_LENGTH_MIN) { - // Those must default to 0, if they are not returned by central. + // These variables must default to 0, if they are not returned by central. event.data.settings.ans_high_prioritized_alert_support = 0; event.data.settings.ans_instant_message_support = 0; } p_ans->evt_handler(&event); - - tx_buffer_process(); } @@ -328,11 +282,11 @@ static void event_disconnect(ble_ans_c_t * p_ans, ble_evt_t const * p_ble_evt) { p_ans->conn_handle = BLE_CONN_HANDLE_INVALID; - // Clearing all data for the service will also set all handle values to @ref BLE_GATT_HANDLE_INVALID + // Clearing all data for the service also sets all handle values to @ref BLE_GATT_HANDLE_INVALID memset(&p_ans->service, 0, sizeof(ble_ans_c_service_t)); - // There was a valid instance of IAS on the peer. Send an event to the - // application, so that it can do any clean up related to this module. + // If there was a valid instance of IAS on the peer, send an event to the + // application, so that it can do any cleanup related to this module. ble_ans_c_evt_t evt; evt.evt_type = BLE_ANS_C_EVT_DISCONN_COMPLETE; @@ -352,10 +306,6 @@ void ble_ans_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) event_notify(p_ans, p_ble_evt); break; - case BLE_GATTC_EVT_WRITE_RSP: - event_write_rsp(p_ans, p_ble_evt); - break; - case BLE_GATTC_EVT_READ_RSP: event_read_rsp(p_ans, p_ble_evt); break; @@ -372,16 +322,17 @@ uint32_t ble_ans_c_init(ble_ans_c_t * p_ans, ble_ans_c_init_t const * p_ans_init VERIFY_PARAM_NOT_NULL(p_ans); VERIFY_PARAM_NOT_NULL(p_ans_init); VERIFY_PARAM_NOT_NULL(p_ans_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_ans_init->p_gatt_queue); - // clear all handles + // Clear all handles. memset(p_ans, 0, sizeof(ble_ans_c_t)); - memset(m_tx_buffer, 0, TX_BUFFER_SIZE); p_ans->conn_handle = BLE_CONN_HANDLE_INVALID; p_ans->evt_handler = p_ans_init->evt_handler; p_ans->error_handler = p_ans_init->error_handler; p_ans->message_buffer_size = p_ans_init->message_buffer_size; p_ans->p_message_buffer = p_ans_init->p_message_buffer; + p_ans->p_gatt_queue = p_ans_init->p_gatt_queue; BLE_UUID_BLE_ASSIGN(p_ans->service.service.uuid, BLE_UUID_ALERT_NOTIFICATION_SERVICE); BLE_UUID_BLE_ASSIGN(p_ans->service.new_alert.uuid, BLE_UUID_NEW_ALERT_CHAR); @@ -401,28 +352,31 @@ uint32_t ble_ans_c_init(ble_ans_c_t * p_ans, ble_ans_c_init_t const * p_ans_init } -/**@brief Function for creating a TX message for writing a CCCD. +/**@brief Function for creating a tx message for writing a CCCD. */ -static uint32_t cccd_configure(uint16_t conn_handle, uint16_t handle_cccd, bool enable) +static uint32_t cccd_configure(ble_ans_c_t const * const p_ans, + uint16_t handle_cccd, + bool notification_enable) { - ans_tx_message_t * p_msg; - uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; - - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; - - p_msg->req.write_req.gattc_params.handle = handle_cccd; - p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg->req.write_req.gattc_value[0] = LSB_16(cccd_val); - p_msg->req.write_req.gattc_value[1] = MSB_16(cccd_val); - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_process(); - return NRF_SUCCESS; + nrf_ble_gq_req_t cccd_req; + uint16_t cccd_val = notification_enable ? BLE_GATT_HVX_NOTIFICATION : 0; + uint8_t cccd[WRITE_MESSAGE_LENGTH]; + + memset(&cccd_req, 0, sizeof(nrf_ble_gq_req_t)); + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + cccd_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + cccd_req.error_handler.cb = gatt_error_handler; + cccd_req.error_handler.p_ctx = (ble_ans_c_t *)p_ans; + cccd_req.params.gattc_write.handle = handle_cccd; + cccd_req.params.gattc_write.len = WRITE_MESSAGE_LENGTH; + cccd_req.params.gattc_write.p_value = cccd; + cccd_req.params.gattc_write.offset = 0; + cccd_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ans->p_gatt_queue, &cccd_req, p_ans->conn_handle); } @@ -434,7 +388,7 @@ uint32_t ble_ans_c_enable_notif_new_alert(ble_ans_c_t const * p_ans) } else { - return cccd_configure(p_ans->conn_handle, + return cccd_configure(p_ans, p_ans->service.new_alert_cccd.handle, true); } @@ -443,7 +397,7 @@ uint32_t ble_ans_c_enable_notif_new_alert(ble_ans_c_t const * p_ans) uint32_t ble_ans_c_disable_notif_new_alert(ble_ans_c_t const * p_ans) { - return cccd_configure(p_ans->conn_handle, + return cccd_configure(p_ans, p_ans->service.new_alert_cccd.handle, false); } @@ -455,15 +409,15 @@ uint32_t ble_ans_c_enable_notif_unread_alert(ble_ans_c_t const * p_ans) { return NRF_ERROR_INVALID_STATE; } - return cccd_configure(p_ans->conn_handle, - p_ans->service.unread_alert_cccd.handle, + return cccd_configure(p_ans, + p_ans->service.unread_alert_cccd.handle, true); } uint32_t ble_ans_c_disable_notif_unread_alert(ble_ans_c_t const * p_ans) { - return cccd_configure(p_ans->conn_handle, + return cccd_configure(p_ans, p_ans->service.unread_alert_cccd.handle, false); } @@ -472,55 +426,56 @@ uint32_t ble_ans_c_disable_notif_unread_alert(ble_ans_c_t const * p_ans) uint32_t ble_ans_c_control_point_write(ble_ans_c_t const * p_ans, ble_ans_control_point_t const * p_control_point) { - ans_tx_message_t * p_msg; - - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; - - p_msg->req.write_req.gattc_params.handle = p_ans->service.alert_notif_ctrl_point.handle_value; - p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg->req.write_req.gattc_value[0] = p_control_point->command; - p_msg->req.write_req.gattc_value[1] = p_control_point->category; - p_msg->conn_handle = p_ans->conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_process(); - return NRF_SUCCESS; + nrf_ble_gq_req_t gq_req; + uint8_t write_data[WRITE_MESSAGE_LENGTH]; + + write_data[0] = p_control_point->command; + write_data[1] = p_control_point->category; + + memset(&gq_req, 0, sizeof(nrf_ble_gq_req_t)); + + gq_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + gq_req.error_handler.cb = gatt_error_handler; + gq_req.error_handler.p_ctx = (ble_ans_c_t *)p_ans; + gq_req.params.gattc_write.handle = p_ans->service.alert_notif_ctrl_point.handle_value; + gq_req.params.gattc_write.len = WRITE_MESSAGE_LENGTH; + gq_req.params.gattc_write.p_value = write_data; + gq_req.params.gattc_write.offset = 0; + gq_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ans->p_gatt_queue, &gq_req, p_ans->conn_handle); } uint32_t ble_ans_c_new_alert_read(ble_ans_c_t const * p_ans) { - ans_tx_message_t * msg; + nrf_ble_gq_req_t gq_req; - msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; + memset(&gq_req, 0, sizeof(nrf_ble_gq_req_t)); - msg->req.read_handle = p_ans->service.suported_new_alert_cat.handle_value; - msg->conn_handle = p_ans->conn_handle; - msg->type = READ_REQ; + gq_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + gq_req.error_handler.cb = gatt_error_handler; + gq_req.error_handler.p_ctx = (ble_ans_c_t *)p_ans; + gq_req.params.gattc_read.handle = p_ans->service.suported_new_alert_cat.handle_value; + gq_req.params.gattc_read.offset = 0; - tx_buffer_process(); - return NRF_SUCCESS; + return nrf_ble_gq_item_add(p_ans->p_gatt_queue, &gq_req, p_ans->conn_handle); } uint32_t ble_ans_c_unread_alert_read(ble_ans_c_t const * p_ans) { - ans_tx_message_t * msg; + nrf_ble_gq_req_t gq_req; - msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; + memset(&gq_req, 0, sizeof(nrf_ble_gq_req_t)); - msg->req.read_handle = p_ans->service.suported_unread_alert_cat.handle_value; - msg->conn_handle = p_ans->conn_handle; - msg->type = READ_REQ; + gq_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + gq_req.error_handler.cb = gatt_error_handler; + gq_req.error_handler.p_ctx = (ble_ans_c_t *)p_ans; + gq_req.params.gattc_read.handle = p_ans->service.suported_unread_alert_cat.handle_value; + gq_req.params.gattc_read.offset = 0; - tx_buffer_process(); - return NRF_SUCCESS; + return nrf_ble_gq_item_add(p_ans->p_gatt_queue, &gq_req, p_ans->conn_handle); } @@ -560,7 +515,7 @@ uint32_t ble_ans_c_handles_assign(ble_ans_c_t * p_ans, if (p_peer_handles != NULL) { - // Copy the handles from the discovered characteristics over to the provided client instance. + // Copy the handles from the discovered characteristics to the provided client instance. char_set(&p_ans->service.alert_notif_ctrl_point, &p_peer_handles->alert_notif_ctrl_point); char_set(&p_ans->service.suported_new_alert_cat, &p_peer_handles->suported_new_alert_cat); char_set(&p_ans->service.suported_unread_alert_cat, &p_peer_handles->suported_unread_alert_cat); @@ -570,6 +525,6 @@ uint32_t ble_ans_c_handles_assign(ble_ans_c_t * p_ans, char_cccd_set(&p_ans->service.unread_alert_cccd, p_peer_handles->unread_alert_cccd.handle); } - return NRF_SUCCESS; + return nrf_ble_gq_conn_handle_register(p_ans->p_gatt_queue, conn_handle); } #endif // NRF_MODULE_ENABLED(BLE_ANS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ans_c/ble_ans_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ans_c/ble_ans_c.h similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ans_c/ble_ans_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ans_c/ble_ans_c.h index f90c81d..57c0daf 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ans_c/ble_ans_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ans_c/ble_ans_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -47,7 +47,7 @@ * @details This module implements the Alert Notification Client according to the * Alert Notification Profile. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_ans_c_t instance; @@ -68,6 +68,7 @@ #include "sdk_common.h" #include "ble_srv_common.h" #include "ble_db_discovery.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus @@ -85,27 +86,38 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_ANS_C_BLE_OBSERVER_PRIO, \ ble_ans_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple ble_ans_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_ANS_C_ARRAY_DEF(_name, _cnt) \ +static ble_ans_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_ANS_C_BLE_OBSERVER_PRIO, \ + ble_ans_c_on_ble_evt, &_name, _cnt) // Forward declaration of the ble_ans_c_t type. typedef struct ble_ans_c_s ble_ans_c_t; -/** Alerts types as defined in the alert category id; UUID: 0x2A43. */ +/** Alert types, as defined in the alert category ID. UUID: 0x2A43. */ typedef enum { ANS_TYPE_SIMPLE_ALERT = 0, /**< General text alert or non-text alert.*/ - ANS_TYPE_EMAIL = 1, /**< Alert when email messages arrives.*/ + ANS_TYPE_EMAIL = 1, /**< Email message arrives.*/ ANS_TYPE_NEWS = 2, /**< News feeds such as RSS, Atom.*/ ANS_TYPE_NOTIFICATION_CALL = 3, /**< Incoming call.*/ ANS_TYPE_MISSED_CALL = 4, /**< Missed call.*/ - ANS_TYPE_SMS_MMS = 5, /**< SMS/MMS message arrives.*/ + ANS_TYPE_SMS_MMS = 5, /**< SMS or MMS message arrives.*/ ANS_TYPE_VOICE_MAIL = 6, /**< Voice mail.*/ - ANS_TYPE_SCHEDULE = 7, /**< Alert occurred on calendar, planner.*/ - ANS_TYPE_HIGH_PRIORITIZED_ALERT = 8, /**< Alert that should be handled as high priority.*/ + ANS_TYPE_SCHEDULE = 7, /**< Alert that occurs on calendar, planner.*/ + ANS_TYPE_HIGH_PRIORITIZED_ALERT = 8, /**< Alert to be handled as high priority.*/ ANS_TYPE_INSTANT_MESSAGE = 9, /**< Alert for incoming instant messages.*/ - ANS_TYPE_ALL_ALERTS = 0xFF /**< Identifies All Alerts. */ + ANS_TYPE_ALL_ALERTS = 0xFF /**< Identifies all alerts. */ } ble_ans_category_id_t; -/** Alerts notification control point commands as defined in the Alert Notification Specification; +/** Alert notification control point commands, as defined in the Alert Notification Specification. * UUID: 0x2A44. */ typedef enum @@ -118,43 +130,43 @@ typedef enum ANS_NOTIFY_UNREAD_CATEGORY_STATUS_IMMEDIATELY = 5, /**< Notify Unread Category Status immediately.*/ } ble_ans_command_id_t; -/**@brief Alert Notification Event types that are passed from client to application on an event. */ +/**@brief Alert Notification Event types that are passed from client to the application on an event. */ typedef enum { - BLE_ANS_C_EVT_DISCOVERY_COMPLETE, /**< A successful connection has been established and the characteristics of the server has been fetched. */ + BLE_ANS_C_EVT_DISCOVERY_COMPLETE, /**< A successful connection is established and the characteristics of the server were fetched. */ BLE_ANS_C_EVT_DISCOVERY_FAILED, /**< It was not possible to discover service or characteristics of the connected peer. */ - BLE_ANS_C_EVT_DISCONN_COMPLETE, /**< The connection has been taken down. */ - BLE_ANS_C_EVT_NOTIFICATION, /**< A valid Alert Notification has been received from the server.*/ - BLE_ANS_C_EVT_READ_RESP, /**< A read response has been received from the server.*/ - BLE_ANS_C_EVT_WRITE_RESP /**< A write response has been received from the server.*/ + BLE_ANS_C_EVT_DISCONN_COMPLETE, /**< The connection is taken down. */ + BLE_ANS_C_EVT_NOTIFICATION, /**< A valid notification was received from the server.*/ + BLE_ANS_C_EVT_READ_RESP, /**< A read response was received from the server.*/ + BLE_ANS_C_EVT_WRITE_RESP /**< A write response was received from the server.*/ } ble_ans_c_evt_type_t; /**@brief Alert Notification Control Point structure. */ typedef struct { - ble_ans_command_id_t command; /**< The command to be written to the control point, see @ref ble_ans_command_id_t. */ - ble_ans_category_id_t category; /**< The category for the control point for which the command applies, see @ref ble_ans_category_id_t. */ + ble_ans_command_id_t command; /**< The command to be written to the control point. See @ref ble_ans_command_id_t. */ + ble_ans_category_id_t category; /**< The category for the control point for which the command applies. See @ref ble_ans_category_id_t. */ } ble_ans_control_point_t; /**@brief Alert Notification Setting structure containing the supported alerts in the service. * *@details - * The structure contains bit fields describing which alerts that are supported: - * 0 = Unsupported - * 1 = Supported + * The structure contains bit fields that describe which alerts are supported: + * - 0 = Unsupported + * - 1 = Supported */ typedef struct { - uint8_t ans_simple_alert_support : 1; /**< Support for General text alert or non-text alert.*/ - uint8_t ans_email_support : 1; /**< Support for Alert when email messages arrives.*/ - uint8_t ans_news_support : 1; /**< Support for News feeds such as RSS, Atom.*/ - uint8_t ans_notification_call_support : 1; /**< Support for Incoming call.*/ - uint8_t ans_missed_call_support : 1; /**< Support for Missed call.*/ - uint8_t ans_sms_mms_support : 1; /**< Support for SMS/MMS message arrives.*/ - uint8_t ans_voice_mail_support : 1; /**< Support for Voice mail.*/ - uint8_t ans_schedule_support : 1; /**< Support for Alert occurred on calendar, planner.*/ - uint8_t ans_high_prioritized_alert_support : 1; /**< Support for Alert that should be handled as high priority.*/ - uint8_t ans_instant_message_support : 1; /**< Support for Alert for incoming instant messages.*/ + uint8_t ans_simple_alert_support : 1; /**< Support for general text alert or non-text alert.*/ + uint8_t ans_email_support : 1; /**< Support for alert when an email message arrives.*/ + uint8_t ans_news_support : 1; /**< Support for news feeds such as RSS, Atom.*/ + uint8_t ans_notification_call_support : 1; /**< Support for incoming call.*/ + uint8_t ans_missed_call_support : 1; /**< Support for missed call.*/ + uint8_t ans_sms_mms_support : 1; /**< Support for SMS or MMS message arrival.*/ + uint8_t ans_voice_mail_support : 1; /**< Support for voice mail.*/ + uint8_t ans_schedule_support : 1; /**< Support for alert that occurs on calendar or planner.*/ + uint8_t ans_high_prioritized_alert_support : 1; /**< Support for alert that should be handled as high priority.*/ + uint8_t ans_instant_message_support : 1; /**< Support for alert for incoming instant messages.*/ uint8_t reserved : 6; /**< Reserved for future use. */ } ble_ans_alert_settings_t; @@ -164,86 +176,88 @@ typedef struct { uint8_t alert_category; /**< Alert category to which this alert belongs.*/ uint8_t alert_category_count; /**< Number of alerts in the category. */ - uint32_t alert_msg_length; /**< Length of optional text message send by the server. */ - uint8_t * p_alert_msg_buf; /**< Pointer to buffer containing the optional text message. */ + uint32_t alert_msg_length; /**< Length of the optional text message sent by the server. */ + uint8_t * p_alert_msg_buf; /**< Pointer to the buffer that contains the optional text message. */ } ble_ans_alert_notification_t; -/**@brief Struct to hold information on the Alert Notification Service if found on the server. */ +/**@brief Structure for holding information on the Alert Notification Service, if found on the server. */ typedef struct { - ble_gattc_service_t service; /**< The GATT service holding the discovered Alert Notification Service. */ - ble_gattc_char_t alert_notif_ctrl_point; /**< Characteristic for the Alert Notification Control Point. @ref BLE_UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR */ - ble_gattc_char_t suported_new_alert_cat; /**< Characteristic for the Supported New Alert category. @ref BLE_UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR */ - ble_gattc_char_t suported_unread_alert_cat; /**< Characteristic for the Unread Alert category. @ref BLE_UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR */ - ble_gattc_char_t new_alert; /**< Characteristic for the New Alert Notification. @ref BLE_UUID_NEW_ALERT_CHAR */ - ble_gattc_desc_t new_alert_cccd; /**< Characteristic Descriptor for New Alert Category. Enables or Disables GATT notifications */ - ble_gattc_char_t unread_alert_status; /**< Characteristic for the Unread Alert Notification. @ref BLE_UUID_UNREAD_ALERT_CHAR */ - ble_gattc_desc_t unread_alert_cccd; /**< Characteristic Descriptor for Unread Alert Category. Enables or Disables GATT notifications */ + ble_gattc_service_t service; /**< The GATT service that holds the discovered Alert Notification Service. */ + ble_gattc_char_t alert_notif_ctrl_point; /**< Characteristic for the Alert Notification Control Point. See @ref BLE_UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR. */ + ble_gattc_char_t suported_new_alert_cat; /**< Characteristic for the Supported New Alert category. See @ref BLE_UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR. */ + ble_gattc_char_t suported_unread_alert_cat; /**< Characteristic for the Unread Alert category. See @ref BLE_UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR. */ + ble_gattc_char_t new_alert; /**< Characteristic for the New Alert Notification. See @ref BLE_UUID_NEW_ALERT_CHAR. */ + ble_gattc_desc_t new_alert_cccd; /**< Characteristic Descriptor for the New Alert category. Enables or disables GATT notifications. */ + ble_gattc_char_t unread_alert_status; /**< Characteristic for the Unread Alert Notification. See @ref BLE_UUID_UNREAD_ALERT_CHAR. */ + ble_gattc_desc_t unread_alert_cccd; /**< Characteristic Descriptor for the Unread Alert category. Enables or disables GATT notifications */ } ble_ans_c_service_t; /**@brief Alert Notification Event structure * - * @details The structure contains the event that should be handled, as well as + * @details Structure for holding information about the event that should be handled, as well as * additional information. */ typedef struct { ble_ans_c_evt_type_t evt_type; /**< Type of event. */ - uint16_t conn_handle; /**< Connection handle on which the ANS service was discovered on the peer device. This will be filled if the evt_type is @ref BLE_ANS_C_EVT_DISCOVERY_COMPLETE.*/ + uint16_t conn_handle; /**< Connection handle on which the ANS service was discovered on the peer device. This is filled if the evt_type is @ref BLE_ANS_C_EVT_DISCOVERY_COMPLETE.*/ ble_uuid_t uuid; /**< UUID of the event in case of an alert or notification. */ union { ble_ans_alert_settings_t settings; /**< Setting returned from server on read request. */ ble_ans_alert_notification_t alert; /**< Alert Notification data sent by the server. */ - uint32_t error_code; /**< Additional status/error code if the event was caused by a stack error or gatt status, e.g. during service discovery. */ - ble_ans_c_service_t service; /**< Info on the discovered Alert Notification Service discovered. This will be filled if the evt_type is @ref BLE_ANS_C_EVT_DISCOVERY_COMPLETE.*/ + uint32_t error_code; /**< Additional status or error code, if the event is caused by a stack error or GATT status, for example during service discovery. */ + ble_ans_c_service_t service; /**< Information on the discovered Alert Notification Service. This is filled if the evt_type is @ref BLE_ANS_C_EVT_DISCOVERY_COMPLETE.*/ } data; } ble_ans_c_evt_t; /**@brief Alert Notification event handler type. */ typedef void (*ble_ans_c_evt_handler_t) (ble_ans_c_evt_t * p_evt); -/**@brief Alert Notification structure. This contains various status information for the client. */ +/**@brief Alert Notification structure. Contains various status information for the client. */ struct ble_ans_c_s { ble_ans_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Alert Notification Client Application. */ ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ - uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ - uint8_t central_handle; /**< Handle for the currently connected central if peer is bonded. */ - uint8_t service_handle; /**< Handle to the service in the database to use for this instance. */ - uint32_t message_buffer_size; /**< Size of message buffer to hold the additional text messages received on notifications. */ + uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack; if not in a connection, the handle is BLE_CONN_HANDLE_INVALID). */ + uint8_t central_handle; /**< Handle for the currently connected central, if peer is bonded. */ + uint8_t service_handle; /**< Handle for the service in the database to be used for this instance. */ + uint32_t message_buffer_size; /**< Size of the message buffer to hold the additional text messages received on notifications. */ uint8_t * p_message_buffer; /**< Pointer to the buffer to be used for additional text message handling. */ - ble_ans_c_service_t service; /**< Struct to store the different handles and UUIDs related to the service. */ + ble_ans_c_service_t service; /**< Struct to store different handles and UUIDs related to the service. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ }; -/**@brief Alert Notification init structure. This contains all options and data needed for - * initialization of the client.*/ +/**@brief Alert Notification init structure. Contains all options and data needed for + * the initialization of the client.*/ typedef struct { ble_ans_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ - uint32_t message_buffer_size; /**< Size of buffer to handle messages. */ - uint8_t * p_message_buffer; /**< Pointer to buffer for passing messages. */ + uint32_t message_buffer_size; /**< Size of the buffer to handle messages. */ + uint8_t * p_message_buffer; /**< Pointer to the buffer for passing messages. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } ble_ans_c_init_t; -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details Call this function when getting a callback event from the DB discovery modue. - * This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of heart rate service at the peer. If so, it will - * call the application's event handler indicating that the heart rate service has been - * discovered at the peer. It also populates the event with the service related + * @details Call this function when you get a callback event from the Database Discovery module. + * This function handles an event from the Database Discovery module and determines + * whether it relates to the discovery of Heart Rate Service at the peer. If it does, this function + * calls the application's event handler to indicate that the Heart Rate Service was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * * @param[in] p_ans Pointer to the Alert Notification client structure instance that will handle * the discovery. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void ble_ans_c_on_db_disc_evt(ble_ans_c_t * p_ans, ble_db_discovery_evt_t const * p_evt); -/**@brief Function for handling the Application's BLE Stack events. +/**@brief Function for handling the application's BLE stack events. * * @details Handles all events from the BLE stack of interest to the Alert Notification Client. * @@ -255,49 +269,49 @@ void ble_ans_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); /**@brief Function for initializing the Alert Notification Client. * - * @param[out] p_ans Alert Notification Client structure. This structure will have to be - * supplied by the application. It will be initialized by this function, - * and will later be used to identify this particular client instance. + * @param[out] p_ans Alert Notification Client structure. This structure must be + * supplied by the application. It is initialized by this function, + * and is later used to identify this particular client instance. * @param[in] p_ans_init Information needed to initialize the client. * - * @return NRF_SUCCESS on successful initialization of client, otherwise an error code. + * @return NRF_SUCCESS on successful initialization of client. Otherwise, it returns an error code. */ uint32_t ble_ans_c_init(ble_ans_c_t * p_ans, ble_ans_c_init_t const * p_ans_init); /**@brief Function for writing the to CCCD to enable new alert notifications from the Alert Notification Service. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code. + * @return NRF_SUCCESS on successful writing of the CCCD. Otherwise, it returns an error code. */ uint32_t ble_ans_c_enable_notif_new_alert(ble_ans_c_t const * p_ans); /**@brief Function for writing to the CCCD to enable unread alert notifications from the Alert Notification Service. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code. + * @return NRF_SUCCESS on successful writing of the CCCD. Otherwise, it returns an error code. */ uint32_t ble_ans_c_enable_notif_unread_alert(ble_ans_c_t const * p_ans); /**@brief Function for writing to the CCCD to disable new alert notifications from the Alert Notification Service. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code. + * @return NRF_SUCCESS on successful writing of the CCCD. Otherwise, it returns an error code. */ uint32_t ble_ans_c_disable_notif_new_alert(ble_ans_c_t const * p_ans); /**@brief Function for writing to the CCCD to disable unread alert notifications from the Alert Notification Service. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code. @@ -308,14 +322,16 @@ uint32_t ble_ans_c_disable_notif_unread_alert(ble_ans_c_t const * p_ans); /**@brief Function for writing to the Alert Notification Control Point to specify alert notification behavior in the * Alert Notification Service on the Central. * - * @param[in] p_ans Alert Notification structure. This structure will have to be + * @param[in] p_ans Alert Notification structure. This structure must be * supplied by the application. It identifies the particular client * instance to use. * @param[in] p_control_point Alert Notification Control Point structure. This structure * specifies the values to write to the Alert Notification Control - * Point, UUID 0x2A44. + * Point (UUID 0x2A44). * - * @return NRF_SUCCESS on successful writing of the Control Point, otherwise an error code. + * @return NRF_SUCCESS on successful writing of the Control Point. Otherwise, + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ uint32_t ble_ans_c_control_point_write(ble_ans_c_t const * p_ans, ble_ans_control_point_t const * p_control_point); @@ -324,10 +340,12 @@ uint32_t ble_ans_c_control_point_write(ble_ans_c_t const * p_ans, /**@brief Function for reading the Supported New Alert characteristic value of the service. * The value describes the alerts supported in the central. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code. + * @return NRF_SUCCESS on successful transmission of the read request. Otherwise, + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ uint32_t ble_ans_c_new_alert_read(ble_ans_c_t const * p_ans); @@ -335,43 +353,45 @@ uint32_t ble_ans_c_new_alert_read(ble_ans_c_t const * p_ans); /**@brief Function for reading the Supported Unread Alert characteristic value of the service. * The value describes the alerts supported in the central. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * - * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code. + * @return NRF_SUCCESS on successful transmission of the read request. Otherwise, + * this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ uint32_t ble_ans_c_unread_alert_read(ble_ans_c_t const * p_ans); /**@brief Function for requesting the peer to notify the New Alert characteristics immediately. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * @param[in] category The category ID for which the peer should notify the client. * - * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code. + * @return NRF_SUCCESS on successful transmission of the read request. Otherwise, it returns an error code. */ uint32_t ble_ans_c_new_alert_notify(ble_ans_c_t const * p_ans, ble_ans_category_id_t category); /**@brief Function for requesting the peer to notify the Unread Alert characteristics immediately. * - * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by + * @param[in] p_ans Alert Notification structure. This structure must be supplied by * the application. It identifies the particular client instance to use. * @param[in] category The category ID for which the peer should notify the client. * - * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code. + * @return NRF_SUCCESS on successful transmission of the read request. Otherwise, it returns an error code. */ uint32_t ble_ans_c_unread_alert_notify(ble_ans_c_t const * p_ans, ble_ans_category_id_t category); -/**@brief Function for assigning a handles to a an instance of ans_c. +/**@brief Function for assigning handles to an instance of ans_c. * * @details Call this function when a link has been established with a peer to - * associate this link to an instance of the module. This makes it - * possible to handle several link and associate each link to a particular - * instance of the ans_c module. The connection handle and attribute handles will be - * provided from the discovery event @ref BLE_ANS_C_EVT_DISCOVERY_COMPLETE. + * associate the link to an instance of the module. This makes it possible + * to handle several links and associate each link to a particular + * instance of the ans_c module. The connection handle and attribute handles + * are provided from the discovery event @ref BLE_ANS_C_EVT_DISCOVERY_COMPLETE. * * @param[in] p_ans Pointer to the Alert Notification client structure instance to * associate with the handles. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas/ble_bas.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas/ble_bas.c similarity index 52% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas/ble_bas.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas/ble_bas.c index c0508df..5a5589e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas/ble_bas.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas/ble_bas.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -46,32 +46,21 @@ #include "ble_bas.h" #include #include "ble_srv_common.h" +#include "ble_conn_state.h" +#define NRF_LOG_MODULE_NAME ble_bas +#if BLE_BAS_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL BLE_BAS_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR BLE_BAS_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR BLE_BAS_CONFIG_DEBUG_COLOR +#else // BLE_BAS_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // BLE_BAS_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); -#define INVALID_BATTERY_LEVEL 255 - - -/**@brief Function for handling the Connect event. - * - * @param[in] p_bas Battery Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_connect(ble_bas_t * p_bas, ble_evt_t const * p_ble_evt) -{ - p_bas->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; -} - -/**@brief Function for handling the Disconnect event. - * - * @param[in] p_bas Battery Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_disconnect(ble_bas_t * p_bas, ble_evt_t const * p_ble_evt) -{ - UNUSED_PARAMETER(p_ble_evt); - p_bas->conn_handle = BLE_CONN_HANDLE_INVALID; -} +#define INVALID_BATTERY_LEVEL 255 /**@brief Function for handling the Write event. @@ -106,6 +95,7 @@ static void on_write(ble_bas_t * p_bas, ble_evt_t const * p_ble_evt) { evt.evt_type = BLE_BAS_EVT_NOTIFICATION_DISABLED; } + evt.conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; // CCCD written, call application event handler. p_bas->evt_handler(p_bas, &evt); @@ -124,14 +114,6 @@ void ble_bas_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) switch (p_ble_evt->header.evt_id) { - case BLE_GAP_EVT_CONNECTED: - on_connect(p_bas, p_ble_evt); - break; - - case BLE_GAP_EVT_DISCONNECTED: - on_disconnect(p_bas, p_ble_evt); - break; - case BLE_GATTS_EVT_WRITE: on_write(p_bas, p_ble_evt); break; @@ -150,65 +132,31 @@ void ble_bas_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) * * @return NRF_SUCCESS on success, otherwise an error code. */ -static uint32_t battery_level_char_add(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) +static ret_code_t battery_level_char_add(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) { - uint32_t err_code; - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t initial_battery_level; - uint8_t encoded_report_ref[BLE_SRV_ENCODED_REPORT_REF_LEN]; - uint8_t init_len; - - // Add Battery Level characteristic - if (p_bas->is_notification_supported) - { - memset(&cccd_md, 0, sizeof(cccd_md)); - - // According to BAS_SPEC_V10, the read operation on cccd should be possible without - // authentication. - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_bas_init->battery_level_char_attr_md.cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - } - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.notify = (p_bas->is_notification_supported) ? 1 : 0; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = (p_bas->is_notification_supported) ? &cccd_md : NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BATTERY_LEVEL_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_bas_init->battery_level_char_attr_md.read_perm; - attr_md.write_perm = p_bas_init->battery_level_char_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; + ret_code_t err_code; + ble_add_char_params_t add_char_params; + ble_add_descr_params_t add_descr_params; + uint8_t initial_battery_level; + uint8_t init_len; + uint8_t encoded_report_ref[BLE_SRV_ENCODED_REPORT_REF_LEN]; + // Add battery level characteristic initial_battery_level = p_bas_init->initial_batt_level; - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof(uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof(uint8_t); - attr_char_value.p_value = &initial_battery_level; - - err_code = sd_ble_gatts_characteristic_add(p_bas->service_handle, &char_md, - &attr_char_value, - &p_bas->battery_level_handles); + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_BATTERY_LEVEL_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = &initial_battery_level; + add_char_params.char_props.notify = p_bas->is_notification_supported; + add_char_params.char_props.read = 1; + add_char_params.cccd_write_access = p_bas_init->bl_cccd_wr_sec; + add_char_params.read_access = p_bas_init->bl_rd_sec; + + err_code = characteristic_add(p_bas->service_handle, + &add_char_params, + &(p_bas->battery_level_handles)); if (err_code != NRF_SUCCESS) { return err_code; @@ -217,36 +165,19 @@ static uint32_t battery_level_char_add(ble_bas_t * p_bas, const ble_bas_init_t * if (p_bas_init->p_report_ref != NULL) { // Add Report Reference descriptor - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_REPORT_REF_DESCR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_bas_init->battery_level_report_read_perm; - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - init_len = ble_srv_report_ref_encode(encoded_report_ref, p_bas_init->p_report_ref); - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = init_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = attr_char_value.init_len; - attr_char_value.p_value = encoded_report_ref; + memset(&add_descr_params, 0, sizeof(add_descr_params)); + add_descr_params.uuid = BLE_UUID_REPORT_REF_DESCR; + add_descr_params.read_access = p_bas_init->bl_report_rd_sec; + add_descr_params.init_len = init_len; + add_descr_params.max_len = add_descr_params.init_len; + add_descr_params.p_value = encoded_report_ref; - err_code = sd_ble_gatts_descriptor_add(p_bas->battery_level_handles.value_handle, - &attr_char_value, - &p_bas->report_ref_handle); - if (err_code != NRF_SUCCESS) - { - return err_code; - } + err_code = descriptor_add(p_bas->battery_level_handles.value_handle, + &add_descr_params, + &p_bas->report_ref_handle); + return err_code; } else { @@ -257,19 +188,18 @@ static uint32_t battery_level_char_add(ble_bas_t * p_bas, const ble_bas_init_t * } -uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) +ret_code_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) { if (p_bas == NULL || p_bas_init == NULL) { return NRF_ERROR_NULL; } - uint32_t err_code; + ret_code_t err_code; ble_uuid_t ble_uuid; // Initialize service structure p_bas->evt_handler = p_bas_init->evt_handler; - p_bas->conn_handle = BLE_CONN_HANDLE_INVALID; p_bas->is_notification_supported = p_bas_init->support_notification; p_bas->battery_level_last = INVALID_BATTERY_LEVEL; @@ -277,25 +207,50 @@ uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BATTERY_SERVICE); err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_bas->service_handle); - if (err_code != NRF_SUCCESS) - { - return err_code; - } + VERIFY_SUCCESS(err_code); // Add battery level characteristic - return battery_level_char_add(p_bas, p_bas_init); + err_code = battery_level_char_add(p_bas, p_bas_init); + return err_code; +} + + +/**@brief Function for sending notifications with the Battery Level characteristic. + * + * @param[in] p_hvx_params Pointer to structure with notification data. + * @param[in] conn_handle Connection handle. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static ret_code_t battery_notification_send(ble_gatts_hvx_params_t * const p_hvx_params, + uint16_t conn_handle) +{ + ret_code_t err_code = sd_ble_gatts_hvx(conn_handle, p_hvx_params); + if (err_code == NRF_SUCCESS) + { + NRF_LOG_INFO("Battery notification has been sent using conn_handle: 0x%04X", conn_handle); + } + else + { + NRF_LOG_DEBUG("Error: 0x%08X while sending notification with conn_handle: 0x%04X", + err_code, + conn_handle); + } + return err_code; } -uint32_t ble_bas_battery_level_update(ble_bas_t * p_bas, uint8_t battery_level) +ret_code_t ble_bas_battery_level_update(ble_bas_t * p_bas, + uint8_t battery_level, + uint16_t conn_handle) { if (p_bas == NULL) { return NRF_ERROR_NULL; } - uint32_t err_code = NRF_SUCCESS; - ble_gatts_value_t gatts_value; + ret_code_t err_code = NRF_SUCCESS; + ble_gatts_value_t gatts_value; if (battery_level != p_bas->battery_level_last) { @@ -307,21 +262,25 @@ uint32_t ble_bas_battery_level_update(ble_bas_t * p_bas, uint8_t battery_level) gatts_value.p_value = &battery_level; // Update database. - err_code = sd_ble_gatts_value_set(p_bas->conn_handle, + err_code = sd_ble_gatts_value_set(BLE_CONN_HANDLE_INVALID, p_bas->battery_level_handles.value_handle, &gatts_value); if (err_code == NRF_SUCCESS) { + NRF_LOG_INFO("Battery level has been updated: %d%%", battery_level) + // Save new battery value. p_bas->battery_level_last = battery_level; } else { + NRF_LOG_DEBUG("Error during battery level update: 0x%08X", err_code) + return err_code; } // Send value if connected and notifying. - if ((p_bas->conn_handle != BLE_CONN_HANDLE_INVALID) && p_bas->is_notification_supported) + if (p_bas->is_notification_supported) { ble_gatts_hvx_params_t hvx_params; @@ -333,7 +292,33 @@ uint32_t ble_bas_battery_level_update(ble_bas_t * p_bas, uint8_t battery_level) hvx_params.p_len = &gatts_value.len; hvx_params.p_data = gatts_value.p_value; - err_code = sd_ble_gatts_hvx(p_bas->conn_handle, &hvx_params); + if (conn_handle == BLE_CONN_HANDLE_ALL) + { + ble_conn_state_conn_handle_list_t conn_handles = ble_conn_state_conn_handles(); + + // Try sending notifications to all valid connection handles. + for (uint32_t i = 0; i < conn_handles.len; i++) + { + if (ble_conn_state_status(conn_handles.conn_handles[i]) == BLE_CONN_STATUS_CONNECTED) + { + if (err_code == NRF_SUCCESS) + { + err_code = battery_notification_send(&hvx_params, + conn_handles.conn_handles[i]); + } + else + { + // Preserve the first non-zero error code + UNUSED_RETURN_VALUE(battery_notification_send(&hvx_params, + conn_handles.conn_handles[i])); + } + } + } + } + else + { + err_code = battery_notification_send(&hvx_params, conn_handle); + } } else { @@ -343,4 +328,38 @@ uint32_t ble_bas_battery_level_update(ble_bas_t * p_bas, uint8_t battery_level) return err_code; } + + +ret_code_t ble_bas_battery_lvl_on_reconnection_update(ble_bas_t * p_bas, + uint16_t conn_handle) +{ + if (p_bas == NULL) + { + return NRF_ERROR_NULL; + } + + ret_code_t err_code; + + if (p_bas->is_notification_supported) + { + ble_gatts_hvx_params_t hvx_params; + uint16_t len = sizeof(uint8_t); + + memset(&hvx_params, 0, sizeof(hvx_params)); + + hvx_params.handle = p_bas->battery_level_handles.value_handle; + hvx_params.type = BLE_GATT_HVX_NOTIFICATION; + hvx_params.offset = 0; + hvx_params.p_len = &len; + hvx_params.p_data = &p_bas->battery_level_last; + + err_code = battery_notification_send(&hvx_params, conn_handle); + + return err_code; + } + + return NRF_ERROR_INVALID_STATE; +} + + #endif // NRF_MODULE_ENABLED(BLE_BAS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas/ble_bas.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas/ble_bas.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas/ble_bas.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas/ble_bas.h index b488d7a..6e80307 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas/ble_bas.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas/ble_bas.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -80,59 +80,60 @@ extern "C" { #endif -/**@brief Macro for defining a ble_bas instance. +/**@brief Macro for defining a ble_bas instance. * - * @param _name Name of the instance. + * @param _name Name of the instance. * @hideinitializer */ -#define BLE_BAS_DEF(_name) \ -static ble_bas_t _name; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - BLE_BAS_BLE_OBSERVER_PRIO, \ - ble_bas_on_ble_evt, &_name) - +#define BLE_BAS_DEF(_name) \ + static ble_bas_t _name; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_BAS_BLE_OBSERVER_PRIO, \ + ble_bas_on_ble_evt, \ + &_name) /**@brief Battery Service event type. */ typedef enum { - BLE_BAS_EVT_NOTIFICATION_ENABLED, /**< Battery value notification enabled event. */ - BLE_BAS_EVT_NOTIFICATION_DISABLED /**< Battery value notification disabled event. */ + BLE_BAS_EVT_NOTIFICATION_ENABLED, /**< Battery value notification enabled event. */ + BLE_BAS_EVT_NOTIFICATION_DISABLED /**< Battery value notification disabled event. */ } ble_bas_evt_type_t; /**@brief Battery Service event. */ typedef struct { - ble_bas_evt_type_t evt_type; /**< Type of event. */ + ble_bas_evt_type_t evt_type; /**< Type of event. */ + uint16_t conn_handle; /**< Connection handle. */ } ble_bas_evt_t; // Forward declaration of the ble_bas_t type. typedef struct ble_bas_s ble_bas_t; /**@brief Battery Service event handler type. */ -typedef void (*ble_bas_evt_handler_t) (ble_bas_t * p_bas, ble_bas_evt_t * p_evt); +typedef void (* ble_bas_evt_handler_t) (ble_bas_t * p_bas, ble_bas_evt_t * p_evt); /**@brief Battery Service init structure. This contains all options and data needed for * initialization of the service.*/ typedef struct { - ble_bas_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ - bool support_notification; /**< TRUE if notification of Battery Level measurement is supported. */ - ble_srv_report_ref_t * p_report_ref; /**< If not NULL, a Report Reference descriptor with the specified value will be added to the Battery Level characteristic */ - uint8_t initial_batt_level; /**< Initial battery level */ - ble_srv_cccd_security_mode_t battery_level_char_attr_md; /**< Initial security level for battery characteristics attribute */ - ble_gap_conn_sec_mode_t battery_level_report_read_perm; /**< Initial security level for battery report read attribute */ + ble_bas_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ + bool support_notification; /**< TRUE if notification of Battery Level measurement is supported. */ + ble_srv_report_ref_t * p_report_ref; /**< If not NULL, a Report Reference descriptor with the specified value will be added to the Battery Level characteristic */ + uint8_t initial_batt_level; /**< Initial battery level */ + security_req_t bl_rd_sec; /**< Security requirement for reading the BL characteristic value. */ + security_req_t bl_cccd_wr_sec; /**< Security requirement for writing the BL characteristic CCCD. */ + security_req_t bl_report_rd_sec; /**< Security requirement for reading the BL characteristic descriptor. */ } ble_bas_init_t; /**@brief Battery Service structure. This contains various status information for the service. */ struct ble_bas_s { - ble_bas_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ - uint16_t service_handle; /**< Handle of Battery Service (as provided by the BLE stack). */ - ble_gatts_char_handles_t battery_level_handles; /**< Handles related to the Battery Level characteristic. */ - uint16_t report_ref_handle; /**< Handle of the Report Reference descriptor. */ - uint8_t battery_level_last; /**< Last Battery Level measurement passed to the Battery Service. */ - uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ - bool is_notification_supported; /**< TRUE if notification of Battery Level is supported. */ + ble_bas_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ + uint16_t service_handle; /**< Handle of Battery Service (as provided by the BLE stack). */ + ble_gatts_char_handles_t battery_level_handles; /**< Handles related to the Battery Level characteristic. */ + uint16_t report_ref_handle; /**< Handle of the Report Reference descriptor. */ + uint8_t battery_level_last; /**< Last Battery Level measurement passed to the Battery Service. */ + bool is_notification_supported; /**< TRUE if notification of Battery Level is supported. */ }; @@ -145,7 +146,7 @@ struct ble_bas_s * * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. */ -uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init); +ret_code_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init); /**@brief Function for handling the Application's BLE Stack events. @@ -165,19 +166,41 @@ void ble_bas_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); /**@brief Function for updating the battery level. * - * @details The application calls this function after having performed a battery measurement. If - * notification has been enabled, the battery level characteristic is sent to the client. + * @details The application calls this function after having performed a battery measurement. + * The battery level characteristic will only be sent to the clients which have + * enabled notifications. \ref BLE_CONN_HANDLE_ALL can be used as a connection handle + * to send notifications to all connected devices. + * + * @param[in] p_bas Battery Service structure. + * @param[in] battery_level New battery measurement value (in percent of full capacity). + * @param[in] conn_handle Connection handle. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +ret_code_t ble_bas_battery_level_update(ble_bas_t * p_bas, + uint8_t battery_level, + uint16_t conn_handle); + + +/**@brief Function for sending the last battery level when bonded client reconnects. + * + * @details The application calls this function, in the case of a reconnection of + * a bonded client if the value of the battery has changed since + * its disconnection. * * @note For the requirements in the BAS specification to be fulfilled, * this function must be called upon reconnection if the battery level has changed * while the service has been disconnected from a bonded client. * * @param[in] p_bas Battery Service structure. - * @param[in] battery_level New battery measurement value (in percent of full capacity). + * @param[in] conn_handle Connection handle. * - * @return NRF_SUCCESS on success, otherwise an error code. + * @return NRF_SUCCESS on success, + * NRF_ERROR_INVALID_STATE when notification is not supported, + * otherwise an error code returned by @ref sd_ble_gatts_hvx. */ -uint32_t ble_bas_battery_level_update(ble_bas_t * p_bas, uint8_t battery_level); +ret_code_t ble_bas_battery_lvl_on_reconnection_update(ble_bas_t * p_bas, + uint16_t conn_handle); #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas_c/ble_bas_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas_c/ble_bas_c.c similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas_c/ble_bas_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas_c/ble_bas_c.c index f6936d2..f83f03e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas_c/ble_bas_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas_c/ble_bas_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,109 +35,43 @@ * 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(BLE_BAS_C) #include "ble_bas_c.h" #include "ble_types.h" #include "ble_db_discovery.h" -#include "ble_srv_common.h" #include "ble_gattc.h" #define NRF_LOG_MODULE_NAME ble_bas_c #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define TX_BUFFER_MASK 0x07 /**< TX Buffer mask, must be a mask of contiguous zeroes, followed by contiguous sequence of ones: 000...111. */ -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of the send buffer, which is 1 higher than the mask. */ -#define WRITE_MESSAGE_LENGTH BLE_CCCD_VALUE_LEN /**< Length of the write message for CCCD. */ - -typedef enum -{ - READ_REQ, /**< Type identifying that this tx_message is a read request. */ - WRITE_REQ /**< Type identifying that this tx_message is a write request. */ -} tx_request_t; - -/**@brief Structure for writing a message to the peer, i.e. CCCD. - */ -typedef struct -{ - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; /**< The message to write. */ - ble_gattc_write_params_t gattc_params; /**< The GATTC parameters for this message. */ -} write_params_t; - -/**@brief Structure for holding the data that will be transmitted to the connected central. - */ -typedef struct -{ - uint16_t conn_handle; /**< Connection handle to be used when transmitting this message. */ - tx_request_t type; /**< Type of message. (read or write). */ - union - { - uint16_t read_handle; /**< Read request handle. */ - write_params_t write_req; /**< Write request message. */ - } req; -} tx_message_t; - -static tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for the messages that will be transmitted to the central. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where the next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer containing the next message to be transmitted. */ - -/**@brief Function for passing any pending request from the buffer to the stack. +/**@brief Function for intercepting errors of GATTC and BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. */ -static void tx_buffer_process(void) +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) { - if (m_tx_index != m_tx_insert_index) - { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - NRF_LOG_DEBUG("SD Read/Write API returns Success.."); - m_tx_index++; - m_tx_index &= TX_BUFFER_MASK; - } - else - { - NRF_LOG_DEBUG("SD Read/Write API returns error. This message sending will be " - "attempted again.."); - } - } -} + ble_bas_c_t * p_bas_c = (ble_bas_c_t *)p_ctx; + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); -/**@brief Function for handling write response events. - * - * @param[in] p_bas_c Pointer to the Battery Service Client Structure. - * @param[in] p_ble_evt Pointer to the SoftDevice event. - */ -static void on_write_rsp(ble_bas_c_t * p_bas_c, ble_evt_t const * p_ble_evt) -{ - // Check if the event if on the link for this instance - if (p_bas_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) + if (p_bas_c->error_handler != NULL) { - return; + p_bas_c->error_handler(nrf_error); } - // Check if there is any message to be sent across to the peer and send it. - tx_buffer_process(); } /**@brief Function for handling read response events. * - * @details This function will validate the read response and raise the appropriate + * @details This function validates the read response and raises the appropriate * event to the application. * * @param[in] p_bas_c Pointer to the Battery Service Client Structure. @@ -147,7 +81,7 @@ static void on_read_rsp(ble_bas_c_t * p_bas_c, ble_evt_t const * p_ble_evt) { const ble_gattc_evt_read_rsp_t * p_response; - // Check if the event if on the link for this instance + // Check if the event is on the link for this instance. if (p_bas_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { return; @@ -166,16 +100,14 @@ static void on_read_rsp(ble_bas_c_t * p_bas_c, ble_evt_t const * p_ble_evt) p_bas_c->evt_handler(p_bas_c, &evt); } - // Check if there is any buffered transmissions and send them. - tx_buffer_process(); } /**@brief Function for handling Handle Value Notification received from the SoftDevice. * - * @details This function will handle the Handle Value Notification received from the SoftDevice - * and checks if it is a notification of the Battery Level measurement from the peer. If - * so, this function will decode the battery level measurement and send it to the + * @details This function handles the Handle Value Notification received from the SoftDevice + * and checks whether it is a notification of the Battery Level measurement from the peer. If + * it is, this function decodes the battery level measurement and sends it to the * application. * * @param[in] p_ble_bas_c Pointer to the Battery Service Client structure. @@ -183,7 +115,7 @@ static void on_read_rsp(ble_bas_c_t * p_bas_c, ble_evt_t const * p_ble_evt) */ static void on_hvx(ble_bas_c_t * p_ble_bas_c, ble_evt_t const * p_ble_evt) { - // Check if the event if on the link for this instance + // Check if the event is on the link for this instance. if (p_ble_bas_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { return; @@ -236,7 +168,7 @@ void ble_bas_on_db_disc_evt(ble_bas_c_t * p_ble_bas_c, const ble_db_discovery_ev NRF_LOG_DEBUG("Battery Service discovered at peer."); - //If the instance has been assigned prior to db_discovery, assign the db_handles + //If the instance has been assigned prior to db_discovery, assign the db_handles. if (p_ble_bas_c->conn_handle != BLE_CONN_HANDLE_INVALID) { if ((p_ble_bas_c->peer_bas_db.bl_cccd_handle == BLE_GATT_HANDLE_INVALID)&& @@ -247,38 +179,45 @@ void ble_bas_on_db_disc_evt(ble_bas_c_t * p_ble_bas_c, const ble_db_discovery_ev } p_ble_bas_c->evt_handler(p_ble_bas_c, &evt); } - else + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) { NRF_LOG_DEBUG("Battery Service discovery failure at peer. "); } + else + { + // Do nothing. + } } /**@brief Function for creating a message for writing to the CCCD. */ -static uint32_t cccd_configure(uint16_t conn_handle, uint16_t handle_cccd, bool notification_enable) +static uint32_t cccd_configure(ble_bas_c_t * p_ble_bas_c, bool notification_enable) { NRF_LOG_DEBUG("Configuring CCCD. CCCD Handle = %d, Connection Handle = %d", - handle_cccd,conn_handle); - - tx_message_t * p_msg; - uint16_t cccd_val = notification_enable ? BLE_GATT_HVX_NOTIFICATION : 0; - - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; - - p_msg->req.write_req.gattc_params.handle = handle_cccd; - p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg->req.write_req.gattc_value[0] = LSB_16(cccd_val); - p_msg->req.write_req.gattc_value[1] = MSB_16(cccd_val); - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_process(); - return NRF_SUCCESS; + p_ble_bas_c->peer_bas_db.bl_cccd_handle, + p_ble_bas_c->conn_handle); + + nrf_ble_gq_req_t bas_c_req; + uint8_t cccd[BLE_CCCD_VALUE_LEN]; + uint16_t cccd_val = notification_enable ? BLE_GATT_HVX_NOTIFICATION : 0; + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + memset(&bas_c_req, 0, sizeof(bas_c_req)); + + bas_c_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + bas_c_req.error_handler.cb = gatt_error_handler; + bas_c_req.error_handler.p_ctx = p_ble_bas_c; + bas_c_req.params.gattc_write.handle = p_ble_bas_c->peer_bas_db.bl_cccd_handle; + bas_c_req.params.gattc_write.len = BLE_CCCD_VALUE_LEN; + bas_c_req.params.gattc_write.p_value = cccd; + bas_c_req.params.gattc_write.offset = 0; + bas_c_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ble_bas_c->p_gatt_queue, &bas_c_req, p_ble_bas_c->conn_handle); } @@ -296,16 +235,18 @@ uint32_t ble_bas_c_init(ble_bas_c_t * p_ble_bas_c, ble_bas_c_init_t * p_ble_bas_ p_ble_bas_c->peer_bas_db.bl_cccd_handle = BLE_GATT_HANDLE_INVALID; p_ble_bas_c->peer_bas_db.bl_handle = BLE_GATT_HANDLE_INVALID; p_ble_bas_c->evt_handler = p_ble_bas_c_init->evt_handler; + p_ble_bas_c->error_handler = p_ble_bas_c_init->error_handler; + p_ble_bas_c->p_gatt_queue = p_ble_bas_c_init->p_gatt_queue; return ble_db_discovery_evt_register(&bas_uuid); } -/**@brief Function for handling Disconnected event received from the SoftDevice. +/**@brief Function for handling the Disconnected event received from the SoftDevice. * - * @details This function check if the disconnect event is happening on the link - * associated with the current instance of the module, if so it will set its - * conn_handle to invalid. + * @details This function checks whether the disconnect event is happening on the link + * associated with the current instance of the module. If the event is happening, + * the function sets the instance's conn_handle to invalid. * * @param[in] p_ble_bas_c Pointer to the Battery Service Client structure. * @param[in] p_ble_evt Pointer to the BLE event received. @@ -336,10 +277,6 @@ void ble_bas_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_hvx(p_ble_bas_c, p_ble_evt); break; - case BLE_GATTC_EVT_WRITE_RSP: - on_write_rsp(p_ble_bas_c, p_ble_evt); - break; - case BLE_GATTC_EVT_READ_RSP: on_read_rsp(p_ble_bas_c, p_ble_evt); break; @@ -363,7 +300,7 @@ uint32_t ble_bas_c_bl_notif_enable(ble_bas_c_t * p_ble_bas_c) return NRF_ERROR_INVALID_STATE; } - return cccd_configure(p_ble_bas_c->conn_handle, p_ble_bas_c->peer_bas_db.bl_cccd_handle, true); + return cccd_configure(p_ble_bas_c, true); } @@ -375,21 +312,19 @@ uint32_t ble_bas_c_bl_read(ble_bas_c_t * p_ble_bas_c) return NRF_ERROR_INVALID_STATE; } - tx_message_t * msg; - - msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; + nrf_ble_gq_req_t bas_c_req; - msg->req.read_handle = p_ble_bas_c->peer_bas_db.bl_handle; - msg->conn_handle = p_ble_bas_c->conn_handle; - msg->type = READ_REQ; + memset(&bas_c_req, 0, sizeof(bas_c_req)); + bas_c_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + bas_c_req.error_handler.cb = gatt_error_handler; + bas_c_req.error_handler.p_ctx = p_ble_bas_c; + bas_c_req.params.gattc_read.handle = p_ble_bas_c->peer_bas_db.bl_handle; - tx_buffer_process(); - return NRF_SUCCESS; + return nrf_ble_gq_item_add(p_ble_bas_c->p_gatt_queue, &bas_c_req, p_ble_bas_c->conn_handle); } -uint32_t ble_bas_c_handles_assign(ble_bas_c_t * p_ble_bas_c, +uint32_t ble_bas_c_handles_assign(ble_bas_c_t * p_ble_bas_c, uint16_t conn_handle, ble_bas_c_db_t * p_peer_handles) { @@ -400,6 +335,7 @@ uint32_t ble_bas_c_handles_assign(ble_bas_c_t * p_ble_bas_c, { p_ble_bas_c->peer_bas_db = *p_peer_handles; } - return NRF_SUCCESS; + + return nrf_ble_gq_conn_handle_register(p_ble_bas_c->p_gatt_queue, conn_handle); } #endif // NRF_MODULE_ENABLED(BLE_BAS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas_c/ble_bas_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas_c/ble_bas_c.h similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas_c/ble_bas_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas_c/ble_bas_c.h index 7551ea7..562b00d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bas_c/ble_bas_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bas_c/ble_bas_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -47,7 +47,7 @@ * @details This module contains APIs to read and interact with the Battery Service of a remote * device. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_bas_c_t instance; @@ -62,6 +62,8 @@ #include #include "ble.h" #include "ble_db_discovery.h" +#include "ble_srv_common.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus @@ -79,6 +81,18 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_BAS_C_BLE_OBSERVER_PRIO, \ ble_bas_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple ble_bas_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_BAS_C_ARRAY_DEF(_name, _cnt) \ +static ble_bas_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_BAS_C_BLE_OBSERVER_PRIO, \ + ble_bas_c_on_ble_evt, &_name, _cnt) + /** * @defgroup bas_c_enums Enumerations * @{ @@ -87,9 +101,9 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, /**@brief Battery Service Client event type. */ typedef enum { - BLE_BAS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the Battery Service has been discovered at the peer. */ - BLE_BAS_C_EVT_BATT_NOTIFICATION, /**< Event indicating that a notification of the Battery Level characteristic has been received from the peer. */ - BLE_BAS_C_EVT_BATT_READ_RESP /**< Event indicating that a read response on Battery Level characteristic has been received from peer. */ + BLE_BAS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the Battery Service was discovered at the peer. */ + BLE_BAS_C_EVT_BATT_NOTIFICATION, /**< Event indicating that a notification of the Battery Level characteristic was received from the peer. */ + BLE_BAS_C_EVT_BATT_READ_RESP /**< Event indicating that a read response on Battery Level characteristic was received from the peer. */ } ble_bas_c_evt_type_t; /** @} */ @@ -103,18 +117,18 @@ typedef enum typedef struct { uint16_t bl_cccd_handle; /**< Handle of the CCCD of the Battery Level characteristic. */ - uint16_t bl_handle; /**< Handle of the Battery Level characteristic as provided by the SoftDevice. */ + uint16_t bl_handle; /**< Handle of the Battery Level characteristic, as provided by the SoftDevice. */ } ble_bas_c_db_t; /**@brief Battery Service Client Event structure. */ typedef struct { ble_bas_c_evt_type_t evt_type; /**< Event Type. */ - uint16_t conn_handle; /**< Connection handle relevent to this event.*/ + uint16_t conn_handle; /**< Connection handle relevant to this event.*/ union { - ble_bas_c_db_t bas_db; /**< Battery Service related handles found on the peer device. This will be filled if the evt_type is @ref BLE_BAS_C_EVT_DISCOVERY_COMPLETE.*/ - uint8_t battery_level; /**< Battery level received from peer. This field will be used for the events @ref BLE_BAS_C_EVT_BATT_NOTIFICATION and @ref BLE_BAS_C_EVT_BATT_READ_RESP.*/ + ble_bas_c_db_t bas_db; /**< Handles related to the Battery Service, found on the peer device. This is filled if the evt_type is @ref BLE_BAS_C_EVT_DISCOVERY_COMPLETE.*/ + uint8_t battery_level; /**< Information about the battery level, received from peer. This field is used for the events @ref BLE_BAS_C_EVT_BATT_NOTIFICATION and @ref BLE_BAS_C_EVT_BATT_READ_RESP.*/ } params; } ble_bas_c_evt_t; @@ -130,8 +144,8 @@ typedef struct ble_bas_c_s ble_bas_c_t; /**@brief Event handler type. * - * @details This is the type of the event handler that should be provided by the application - * of this module in order to receive events. + * @details This is the type of the event handler that is to be provided by the application + * of the BAS module to receive events. */ typedef void (* ble_bas_c_evt_handler_t) (ble_bas_c_t * p_bas_bas_c, ble_bas_c_evt_t * p_evt); @@ -145,15 +159,19 @@ typedef void (* ble_bas_c_evt_handler_t) (ble_bas_c_t * p_bas_bas_c, ble_bas_c_e /**@brief Battery Service Client structure. */ struct ble_bas_c_s { - uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */ - ble_bas_c_db_t peer_bas_db; /**< Handles related to BAS on the peer*/ - ble_bas_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the Battery service. */ + uint16_t conn_handle; /**< Connection handle, as provided by the SoftDevice. */ + ble_bas_c_db_t peer_bas_db; /**< Handles related to BAS on the peer.*/ + ble_bas_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the Battery Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ }; /**@brief Battery Service Client initialization structure. */ typedef struct { - ble_bas_c_evt_handler_t evt_handler; /**< Event handler to be called by the Battery Service Client module whenever there is an event related to the Battery Service. */ + ble_bas_c_evt_handler_t evt_handler; /**< Event handler to be called by the Battery Service Client module when there is an event related to the Battery Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } ble_bas_c_init_t; /** @} */ @@ -165,25 +183,25 @@ typedef struct /**@brief Function for initializing the Battery Service Client module. * - * @details This function will initialize the module and set up Database Discovery to discover + * @details This function initializes the module and sets up database discovery to discover * the Battery Service. After calling this function, call @ref ble_db_discovery_start * to start discovery once a link with a peer has been established. * - * @param[out] p_ble_bas_c Pointer to the Battery Service client structure. - * @param[in] p_ble_bas_c_init Pointer to the Battery Service initialization structure containing + * @param[out] p_ble_bas_c Pointer to the Battery Service Client structure. + * @param[in] p_ble_bas_c_init Pointer to the Battery Service initialization structure that contains * the initialization information. * * @retval NRF_SUCCESS Operation success. * @retval NRF_ERROR_NULL A parameter is NULL. - * Otherwise, an error code returned by @ref ble_db_discovery_evt_register. + * @retval err_code Otherwise, an error code returned by @ref ble_db_discovery_evt_register. */ uint32_t ble_bas_c_init(ble_bas_c_t * p_ble_bas_c, ble_bas_c_init_t * p_ble_bas_c_init); /**@brief Function for handling BLE events from the SoftDevice. * - * @details This function will handle the BLE events received from the SoftDevice. If the BLE - * event is relevant for the Battery Service Client module, then it is used to update + * @details This function handles the BLE events received from the SoftDevice. If a BLE + * event is relevant to the Battery Service Client module, the function uses the event's data to update * interval variables and, if necessary, send events to the application. * * @note This function must be called by the application. @@ -196,14 +214,14 @@ void ble_bas_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); /**@brief Function for enabling notifications on the Battery Level characteristic. * - * @details This function will enable to notification of the Battery Level characteristic at the + * @details This function enables the notification of the Battery Level characteristic at the * peer by writing to the CCCD of the Battery Level Characteristic. * * @param p_ble_bas_c Pointer to the Battery Service client structure. * * @retval NRF_SUCCESS If the SoftDevice has been requested to write to the CCCD of the peer. - * NRF_ERROR_NULL Parameter is NULL. - * Otherwise, an error code returned by the SoftDevice API @ref + * @retval NRF_ERROR_NULL Parameter is NULL. + * @retval err_code Otherwise, an error code returned by the SoftDevice API @ref * sd_ble_gattc_write. */ uint32_t ble_bas_c_bl_notif_enable(ble_bas_c_t * p_ble_bas_c); @@ -218,32 +236,32 @@ uint32_t ble_bas_c_bl_notif_enable(ble_bas_c_t * p_ble_bas_c); uint32_t ble_bas_c_bl_read(ble_bas_c_t * p_ble_bas_c); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details Call this function when getting a callback event from the DB discovery modue. - * This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of Battery service at the peer. If so, it will - * call the application's event handler indicating that the Battery service has been - * discovered at the peer. It also populates the event with the service related + * @details Call this function when you get a callback event from the Database Discovery module. + * This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of Battery Service at the peer. If it does, this function + * calls the application's event handler to indicate that the Battery Service was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * * @param p_ble_bas_c Pointer to the Battery Service client structure. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. * */ void ble_bas_on_db_disc_evt(ble_bas_c_t * p_ble_bas_c, ble_db_discovery_evt_t const * p_evt); -/**@brief Function for assigning handles to a this instance of bas_c. +/**@brief Function for assigning handles to this instance of bas_c. * * @details Call this function when a link has been established with a peer to - * associate this link to this instance of the module. This makes it - * possible to handle several link and associate each link to a particular - * instance of this module. The connection handle and attribute handles will be + * associate the link to this instance of the module. This makes it + * possible to handle several links and associate each link to a particular + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_BAS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in] p_ble_bas_c Pointer to the Battery client structure instance to associate. - * @param[in] conn_handle Connection handle to associated with the given Battery Client Instance. + * @param[in] p_ble_bas_c Pointer to the Battery client structure instance for associating the link. + * @param[in] conn_handle Connection handle associated with the given Battery Client Instance. * @param[in] p_peer_handles Attribute handles on the BAS server you want this BAS client to * interact with. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bps/ble_bps.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bps/ble_bps.c similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bps/ble_bps.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bps/ble_bps.c index ddd9b91..3104eea 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bps/ble_bps.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bps/ble_bps.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -62,6 +62,25 @@ #define BPS_MEAS_MEASUREMENT_STATUS_FLAG_BIT (0x01 << 4) /**< Measurement Status Flag bit. */ +/**@brief Function for interception of GATT errors and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_bps_t * p_bps = (ble_bps_t *)p_ctx; + + if (p_bps->error_handler != NULL) + { + p_bps->error_handler(nrf_error); + } +} + + /**@brief Function for handling the Connect event. * * @param[in] p_bps Blood Pressure Service structure. @@ -69,7 +88,18 @@ */ static void on_connect(ble_bps_t * p_bps, ble_evt_t const * p_ble_evt) { - p_bps->conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; + ret_code_t err_code; + + p_bps->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + + err_code = nrf_ble_gq_conn_handle_register(p_bps->p_gatt_queue, + p_ble_evt->evt.gap_evt.conn_handle); + + if ((p_bps->error_handler != NULL) && + (err_code != NRF_SUCCESS)) + { + p_bps->error_handler(err_code); + } } @@ -255,129 +285,25 @@ static uint8_t bps_measurement_encode(ble_bps_t * p_bps, } -/**@brief Function for adding Blood Pressure Measurement characteristics. - * - * @param[in] p_bps Blood Pressure Service structure. - * @param[in] p_bps_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t bps_measurement_char_add(ble_bps_t * p_bps, ble_bps_init_t const * p_bps_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - ble_bps_meas_t initial_bpm; - uint8_t encoded_bpm[MAX_BPM_LEN]; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - cccd_md.write_perm = p_bps_init->bps_meas_attr_md.cccd_write_perm; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.indicate = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.read_perm = p_bps_init->bps_meas_attr_md.read_perm; - attr_md.write_perm = p_bps_init->bps_meas_attr_md.write_perm; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - memset(&initial_bpm, 0, sizeof(initial_bpm)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = bps_measurement_encode(p_bps, &initial_bpm, encoded_bpm); - attr_char_value.init_offs = 0; - attr_char_value.max_len = MAX_BPM_LEN; - attr_char_value.p_value = encoded_bpm; - - return sd_ble_gatts_characteristic_add(p_bps->service_handle, - &char_md, - &attr_char_value, - &p_bps->meas_handles); -} - - -/**@brief Function for adding Blood Pressure Feature characteristics. - * - * @param[in] p_bps Blood Pressure Service structure. - * @param[in] p_bps_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t bps_feature_char_add(ble_bps_t * p_bps, ble_bps_init_t const * p_bps_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t init_value_encoded[2]; - uint8_t init_value_len; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BLOOD_PRESSURE_FEATURE_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.read_perm = p_bps_init->bps_feature_attr_md.read_perm; - attr_md.write_perm = p_bps_init->bps_feature_attr_md.write_perm; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - init_value_len = uint16_encode(p_bps_init->feature, init_value_encoded); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = init_value_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = init_value_len; - attr_char_value.p_value = init_value_encoded; - - return sd_ble_gatts_characteristic_add(p_bps->service_handle, - &char_md, - &attr_char_value, - &p_bps->feature_handles); -} - - uint32_t ble_bps_init(ble_bps_t * p_bps, ble_bps_init_t const * p_bps_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + VERIFY_PARAM_NOT_NULL(p_bps); + VERIFY_PARAM_NOT_NULL(p_bps_init); + VERIFY_PARAM_NOT_NULL(p_bps_init->p_gatt_queue); + + uint32_t err_code; + uint8_t init_value_encoded[MAX_BPM_LEN]; + uint8_t initial_feature_len; + ble_bps_meas_t initial_bpm; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; // Initialize service structure - p_bps->evt_handler = p_bps_init->evt_handler; - p_bps->conn_handle = BLE_CONN_HANDLE_INVALID; - p_bps->feature = p_bps_init->feature; + p_bps->evt_handler = p_bps_init->evt_handler; + p_bps->error_handler = p_bps_init->error_handler; + p_bps->p_gatt_queue = p_bps_init->p_gatt_queue; + p_bps->conn_handle = BLE_CONN_HANDLE_INVALID; + p_bps->feature = p_bps_init->feature; // Add service BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BLOOD_PRESSURE_SERVICE); @@ -389,14 +315,36 @@ uint32_t ble_bps_init(ble_bps_t * p_bps, ble_bps_init_t const * p_bps_init) } // Add measurement characteristic - err_code = bps_measurement_char_add(p_bps, p_bps_init); + memset(&initial_bpm, 0, sizeof(initial_bpm)); + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR; + add_char_params.max_len = MAX_BPM_LEN; + add_char_params.is_var_len = true; + add_char_params.init_len = bps_measurement_encode(p_bps, &initial_bpm, init_value_encoded); + add_char_params.p_init_value = init_value_encoded; + add_char_params.char_props.indicate = 1; + add_char_params.cccd_write_access = p_bps_init->bp_cccd_wr_sec; + + err_code = characteristic_add(p_bps->service_handle, &add_char_params, &p_bps->meas_handles); if (err_code != NRF_SUCCESS) { return err_code; } // Add feature characteristic - err_code = bps_feature_char_add(p_bps, p_bps_init); + initial_feature_len = uint16_encode(p_bps_init->feature, init_value_encoded); + + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_BLOOD_PRESSURE_FEATURE_CHAR; + add_char_params.max_len = initial_feature_len; + add_char_params.init_len = initial_feature_len; + add_char_params.p_init_value = init_value_encoded; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_bps_init->bp_feature_rd_sec; + + err_code = characteristic_add(p_bps->service_handle, &add_char_params, &p_bps->feature_handles); if (err_code != NRF_SUCCESS) { return err_code; @@ -415,25 +363,22 @@ uint32_t ble_bps_measurement_send(ble_bps_t * p_bps, ble_bps_meas_t * p_bps_meas { uint8_t encoded_bps_meas[MAX_BPM_LEN]; uint16_t len; - uint16_t hvx_len; - ble_gatts_hvx_params_t hvx_params; + nrf_ble_gq_req_t bps_req; len = bps_measurement_encode(p_bps, p_bps_meas, encoded_bps_meas); - hvx_len = len; - memset(&hvx_params, 0, sizeof(hvx_params)); + memset(&bps_req, 0, sizeof(nrf_ble_gq_req_t)); - hvx_params.handle = p_bps->meas_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = encoded_bps_meas; + bps_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + bps_req.error_handler.cb = gatt_error_handler; + bps_req.error_handler.p_ctx = p_bps; + bps_req.params.gatts_hvx.handle = p_bps->meas_handles.value_handle; + bps_req.params.gatts_hvx.offset = 0; + bps_req.params.gatts_hvx.p_data = encoded_bps_meas; + bps_req.params.gatts_hvx.p_len = &len; + bps_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; - err_code = sd_ble_gatts_hvx(p_bps->conn_handle, &hvx_params); - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } + err_code = nrf_ble_gq_item_add(p_bps->p_gatt_queue, &bps_req, p_bps->conn_handle); } else { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bps/ble_bps.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bps/ble_bps.h similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bps/ble_bps.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bps/ble_bps.h index ed22cac..42b0ab6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_bps/ble_bps.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_bps/ble_bps.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -71,6 +71,7 @@ #include "ble_srv_common.h" #include "ble_date_time.h" #include "nrf_sdh_ble.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -130,9 +131,11 @@ typedef struct typedef struct { ble_bps_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Blood Pressure Service. */ - ble_srv_cccd_security_mode_t bps_meas_attr_md; /**< Initial security level for blood pressure measurement attribute */ - ble_srv_security_mode_t bps_feature_attr_md; /**< Initial security level for blood pressure feature attribute */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + security_req_t bp_cccd_wr_sec; /**< Security requirement for writing blood pressure measurement characteristic CCCD. */ + security_req_t bp_feature_rd_sec; /**< Security requirement for reading the blood pressure feature characteristic. */ uint16_t feature; /**< Initial value for blood pressure feature */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ } ble_bps_init_t; /**@brief Blood Pressure Service structure. This contains various status information for @@ -140,11 +143,13 @@ typedef struct struct ble_bps_s { ble_bps_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Blood Pressure Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ uint16_t service_handle; /**< Handle of Blood Pressure Service (as provided by the BLE stack). */ ble_gatts_char_handles_t meas_handles; /**< Handles related to the Blood Pressure Measurement characteristic. */ ble_gatts_char_handles_t feature_handles; /**< Handles related to the Blood Pressure Feature characteristic. */ uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ uint16_t feature; /**< Value of Blood Pressure feature. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ }; /**@brief Blood Pressure Service measurement structure. This contains a Blood Pressure diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_cscs.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_cscs.c similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_cscs.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_cscs.c index 7a91ab5..8c29134 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_cscs.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_cscs.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -204,178 +204,6 @@ static uint8_t csc_measurement_encode(ble_cscs_t * p_cscs, } -/**@brief Function for adding CSC Measurement characteristics. - * - * @param[in] p_cscs Cycling Speed and Cadence Service structure. - * @param[in] p_cscs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t csc_measurement_char_add(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - ble_cscs_meas_t initial_scm; - uint8_t encoded_scm[MAX_CSCM_LEN]; - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_cscs_init->csc_meas_attr_md.cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_CSC_MEASUREMENT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm ); - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = csc_measurement_encode(p_cscs, &initial_scm, encoded_scm); - attr_char_value.init_offs = 0; - attr_char_value.max_len = MAX_CSCM_LEN; - attr_char_value.p_value = encoded_scm; - - return sd_ble_gatts_characteristic_add(p_cscs->service_handle, - &char_md, - &attr_char_value, - &p_cscs->meas_handles); -} - - -/**@brief Function for adding CSC Feature characteristics. - * - * @param[in] p_cscs Cycling Speed and Cadence Service structure. - * @param[in] p_cscs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t csc_feature_char_add(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t init_value_encoded[2]; - uint8_t init_value_len; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_CSC_FEATURE_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_cscs_init->csc_feature_attr_md.read_perm; - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - init_value_len = uint16_encode(p_cscs_init->feature, &init_value_encoded[0]); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = init_value_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = init_value_len; - attr_char_value.p_value = init_value_encoded; - - return sd_ble_gatts_characteristic_add(p_cscs->service_handle, - &char_md, - &attr_char_value, - &p_cscs->feature_handles); -} - - -/**@brief Function for adding CSC Sensor Location characteristic. - * - * @param[in] p_cscs Cycling Speed and Cadence Service structure. - * @param[in] p_cscs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t csc_sensor_loc_char_add(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t init_value_len; - uint8_t encoded_init_value[1]; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_SENSOR_LOCATION_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_cscs_init->csc_sensor_loc_attr_md.read_perm; - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - init_value_len = sizeof(uint8_t); - if (p_cscs_init->sensor_location != NULL) - { - encoded_init_value[0] = *p_cscs_init->sensor_location; - } - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = init_value_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = init_value_len; - attr_char_value.p_value = encoded_init_value; - - return sd_ble_gatts_characteristic_add(p_cscs->service_handle, - &char_md, - &attr_char_value, - &p_cscs->sensor_loc_handles); -} - - uint32_t ble_cscs_init(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) { if (p_cscs == NULL || p_cscs_init == NULL) @@ -383,9 +211,12 @@ uint32_t ble_cscs_init(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) return NRF_ERROR_NULL; } - uint32_t err_code; - ble_uuid_t ble_uuid; - ble_cs_ctrlpt_init_t sc_ctrlpt_init; + uint32_t err_code; + uint8_t init_value_encoded[MAX_CSCM_LEN]; + ble_cscs_meas_t initial_scm = {0}; + ble_add_char_params_t add_char_params; + ble_uuid_t ble_uuid; + ble_cs_ctrlpt_init_t sc_ctrlpt_init; // Initialize service structure p_cscs->evt_handler = p_cscs_init->evt_handler; @@ -405,16 +236,33 @@ uint32_t ble_cscs_init(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) } // Add cycling speed and cadence measurement characteristic - err_code = csc_measurement_char_add(p_cscs, p_cscs_init); - + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_CSC_MEASUREMENT_CHAR; + add_char_params.max_len = MAX_CSCM_LEN; + add_char_params.is_var_len = true; + add_char_params.init_len = csc_measurement_encode(p_cscs, &initial_scm, init_value_encoded); + add_char_params.p_init_value = init_value_encoded; + add_char_params.char_props.notify = 1; + add_char_params.cccd_write_access = p_cscs_init->csc_meas_cccd_wr_sec; + + err_code = characteristic_add(p_cscs->service_handle, &add_char_params, &p_cscs->meas_handles); if (err_code != NRF_SUCCESS) { return err_code; } // Add cycling speed and cadence feature characteristic - err_code = csc_feature_char_add(p_cscs, p_cscs_init); - + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_CSC_FEATURE_CHAR; + add_char_params.max_len = sizeof(uint16_t); + add_char_params.init_len = uint16_encode(p_cscs_init->feature, &init_value_encoded[0]); + add_char_params.p_init_value = init_value_encoded; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_cscs_init->csc_feature_rd_sec; + + err_code = characteristic_add(p_cscs->service_handle, + &add_char_params, + &p_cscs->feature_handles); if (err_code != NRF_SUCCESS) { return err_code; @@ -423,22 +271,29 @@ uint32_t ble_cscs_init(ble_cscs_t * p_cscs, ble_cscs_init_t const * p_cscs_init) // Add Sensor Location characteristic (optional) if (p_cscs_init->sensor_location != NULL) { - err_code = csc_sensor_loc_char_add(p_cscs, p_cscs_init); - + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_SENSOR_LOCATION_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = (uint8_t *)p_cscs_init->sensor_location; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_cscs_init->csc_location_rd_sec; + + err_code = characteristic_add(p_cscs->service_handle, &add_char_params, &p_cscs->sensor_loc_handles); if (err_code != NRF_SUCCESS) { return err_code; } } - // Add speed and cadence control point characteristic sc_ctrlpt_init.error_handler = p_cscs_init->error_handler; sc_ctrlpt_init.size_list_supported_locations = p_cscs_init->size_list_supported_locations; sc_ctrlpt_init.supported_functions = p_cscs_init->ctrplt_supported_functions; sc_ctrlpt_init.evt_handler = p_cscs_init->ctrlpt_evt_handler; sc_ctrlpt_init.list_supported_locations = p_cscs_init->list_supported_locations; - sc_ctrlpt_init.sc_ctrlpt_attr_md = p_cscs_init->csc_ctrlpt_attr_md; + sc_ctrlpt_init.sc_ctrlpt_wr_sec = p_cscs_init->sc_ctrlpt_wr_sec; + sc_ctrlpt_init.sc_ctrlpt_cccd_wr_sec = p_cscs_init->sc_ctrlpt_cccd_wr_sec; sc_ctrlpt_init.sensor_location_handle = p_cscs->sensor_loc_handles.value_handle; sc_ctrlpt_init.service_handle = p_cscs->service_handle; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_cscs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_cscs.h similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_cscs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_cscs.h index 872f9c7..5d6bee6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_cscs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_cscs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -132,9 +132,11 @@ typedef void (*ble_cscs_evt_handler_t) (ble_cscs_t * p_cscs, ble_cscs_evt_t * p_ typedef struct { ble_cscs_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Cycling Speed and Cadence Service. */ - ble_srv_cccd_security_mode_t csc_meas_attr_md; /**< Initial security level for cycling speed and cadence measurement attribute */ - ble_srv_cccd_security_mode_t csc_ctrlpt_attr_md; /**< Initial security level for cycling speed and cadence control point attribute */ - ble_srv_security_mode_t csc_feature_attr_md; /**< Initial security level for feature attribute */ + security_req_t csc_meas_cccd_wr_sec; /**< Security requirement for writing cycling speed and cadence measurement characteristic CCCD. */ + security_req_t csc_feature_rd_sec; /**< Security requirement for reading cycling speed and cadence feature characteristic. */ + security_req_t csc_location_rd_sec; /**< Security requirement for reading cycling speed and cadence location characteristic. */ + security_req_t sc_ctrlpt_cccd_wr_sec; /**< Security requirement for writing speed and cadence control point characteristic CCCD. */ + security_req_t sc_ctrlpt_wr_sec; /**< Security requirement for writing speed and cadence control point characteristic. */ uint16_t feature; /**< Initial value for features of sensor @ref BLE_CSCS_FEATURES. */ uint8_t ctrplt_supported_functions; /**< Supported control point functionalities see @ref BLE_SRV_SC_CTRLPT_SUPP_FUNC. */ ble_sc_ctrlpt_evt_handler_t ctrlpt_evt_handler; /**< Event handler */ @@ -142,7 +144,6 @@ typedef struct uint8_t size_list_supported_locations; /**< Number of supported sensor locations in the list.*/ ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ ble_sensor_location_t *sensor_location; /**< Initial Sensor Location, if NULL, sensor_location characteristic is not added*/ - ble_srv_cccd_security_mode_t csc_sensor_loc_attr_md; /**< Initial security level for sensor location attribute */ } ble_cscs_init_t; /**@brief Cycling Speed and Cadence Service structure. This contains various status information for diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c index ab3853f..45fc89a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -61,11 +61,7 @@ uint32_t ble_sc_ctrlpt_init(ble_sc_ctrlpt_t * p_sc_ctrlpt, return NRF_ERROR_NULL; } - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; + ble_add_char_params_t add_char_params; p_sc_ctrlpt->conn_handle = BLE_CONN_HANDLE_INVALID; p_sc_ctrlpt->procedure_status = BLE_SCPT_NO_PROC_IN_PROGRESS; @@ -86,46 +82,20 @@ uint32_t ble_sc_ctrlpt_init(ble_sc_ctrlpt_t * p_sc_ctrlpt, p_sc_ctrlpt->sensor_location_handle = p_sc_ctrlpt_init->sensor_location_handle; p_sc_ctrlpt->error_handler = p_sc_ctrlpt_init->error_handler; - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_sc_ctrlpt_init->sc_ctrlpt_attr_md.cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.indicate = 1; - char_md.char_props.write = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_SC_CTRLPT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - attr_md.write_perm = p_sc_ctrlpt_init->sc_ctrlpt_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 1; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = BLE_SC_CTRLPT_MAX_LEN; - attr_char_value.p_value = 0; - - return sd_ble_gatts_characteristic_add(p_sc_ctrlpt->service_handle, - &char_md, - &attr_char_value, - &p_sc_ctrlpt->sc_ctrlpt_handles); + // Add speed and cadence control point characteristic + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_SC_CTRLPT_CHAR; + add_char_params.max_len = BLE_SC_CTRLPT_MAX_LEN; + add_char_params.is_var_len = true; + add_char_params.char_props.indicate = 1; + add_char_params.char_props.write = 1; + add_char_params.cccd_write_access = p_sc_ctrlpt_init->sc_ctrlpt_cccd_wr_sec; + add_char_params.write_access = p_sc_ctrlpt_init->sc_ctrlpt_wr_sec; + add_char_params.is_defered_write = true; + + return characteristic_add(p_sc_ctrlpt->service_handle, + &add_char_params, + &p_sc_ctrlpt->sc_ctrlpt_handles); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h index b1ab15b..e0d22b8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cscs/ble_sc_ctrlpt.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -156,7 +156,8 @@ typedef struct{ * needed for initialization of the Speed and Cadence Control Point module. */ typedef struct { - ble_srv_cccd_security_mode_t sc_ctrlpt_attr_md; /**< Initial security level for cycling speed and cadence control point attribute */ + security_req_t sc_ctrlpt_cccd_wr_sec; /**< Security requirement for writing speed and cadence control point characteristic CCCD. */ + security_req_t sc_ctrlpt_wr_sec; /**< Security requirement for writing speed and cadence control point characteristic. */ uint8_t supported_functions; /**< supported control point functionalities see @ref BLE_SRV_SC_CTRLPT_SUPP_FUNC. */ uint16_t service_handle; /**< Handle of the parent service (as provided by the BLE stack). */ ble_sc_ctrlpt_evt_handler_t evt_handler; /**< event handler */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cts_c/ble_cts_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cts_c/ble_cts_c.c similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cts_c/ble_cts_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cts_c/ble_cts_c.c index f737ee6..82cfc86 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cts_c/ble_cts_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cts_c/ble_cts_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_CTS_C) @@ -50,22 +50,43 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define CTS_YEAR_MIN 1582 /**< The lowest valid Current Time year is the year when the western calendar was introduced. */ -#define CTS_YEAR_MAX 9999 /**< The highest possible Current Time. */ +#define CTS_YEAR_MIN 1582 /**< The lowest valid Current Time year is the year when the Western calendar was introduced. */ +#define CTS_YEAR_MAX 9999 /**< The highest possible Current Time year. */ #define CTS_C_CURRENT_TIME_EXPECTED_LENGTH 10 /**< | Year |Month |Day |Hours |Minutes |Seconds |Weekday |Fraction|Reason | | 2 bytes |1 byte |1 byte |1 byte |1 byte |1 byte |1 byte |1 byte |1 byte | = 10 bytes. */ -/**@brief Function for handling events from the database discovery module. +/**@brief Function for intercepting errors of GATTC and the BLE GATT Queue. * - * @details This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of Current Time Service at the peer. If so, it will - * call the application's event handler indicating that the Current Time Service has been - * discovered at the peer. It also populates the event with the service related + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_cts_c_t * p_cts = (ble_cts_c_t *)p_ctx; + + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); + + if (p_cts->error_handler != NULL) + { + p_cts->error_handler(nrf_error); + } +} + + +/**@brief Function for handling events from the Database Discovery module. + * + * @details This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of Current Time Service at the peer. If it does, this function + * calls the application's event handler to indicate that the Current Time Service was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. * */ void ble_cts_c_on_db_disc_evt(ble_cts_c_t * p_cts, ble_db_discovery_evt_t * p_evt) @@ -75,7 +96,6 @@ void ble_cts_c_on_db_disc_evt(ble_cts_c_t * p_cts, ble_db_discovery_evt_t * p_ev ble_cts_c_evt_t evt; const ble_gatt_db_char_t * p_chars = p_evt->params.discovered_db.charateristics; - evt.evt_type = BLE_CTS_C_EVT_DISCOVERY_FAILED; evt.conn_handle = p_evt->conn_handle; // Check if the Current Time Service was discovered. @@ -100,17 +120,28 @@ void ble_cts_c_on_db_disc_evt(ble_cts_c_t * p_cts, ble_db_discovery_evt_t * p_ev evt.evt_type = BLE_CTS_C_EVT_DISCOVERY_COMPLETE; } + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) + { + evt.evt_type = BLE_CTS_C_EVT_DISCOVERY_FAILED; + } + else + { + return; + } + p_cts->evt_handler(p_cts, &evt); } uint32_t ble_cts_c_init(ble_cts_c_t * p_cts, ble_cts_c_init_t const * p_cts_init) { - //Verify that the parameters needed for to initialize this instance of CTS are not NULL. + // Verify that the parameters needed to initialize this instance of CTS are not NULL. VERIFY_PARAM_NOT_NULL(p_cts); VERIFY_PARAM_NOT_NULL(p_cts_init); VERIFY_PARAM_NOT_NULL(p_cts_init->error_handler); VERIFY_PARAM_NOT_NULL(p_cts_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_cts_init->p_gatt_queue); static ble_uuid_t cts_uuid; @@ -121,19 +152,20 @@ uint32_t ble_cts_c_init(ble_cts_c_t * p_cts, ble_cts_c_init_t const * p_cts_init p_cts->conn_handle = BLE_CONN_HANDLE_INVALID; p_cts->char_handles.cts_handle = BLE_GATT_HANDLE_INVALID; p_cts->char_handles.cts_cccd_handle = BLE_GATT_HANDLE_INVALID; + p_cts->p_gatt_queue = p_cts_init->p_gatt_queue; return ble_db_discovery_evt_register(&cts_uuid); } -/**@brief Function for decoding a read from the current time characteristic. +/**@brief Function for decoding a read from the Current Time characteristic. * * @param[in] p_time Current Time structure. - * @param[in] p_data Pointer to the buffer containing the current time. - * @param[in] length length of the buffer containing the current time. + * @param[in] p_data Pointer to the buffer containing the Current Time. + * @param[in] length Length of the buffer containing the Current Time. * - * @return NRF_SUCCESS if the time struct is valid. - * @return NRF_ERROR_DATA_SIZE if length does not match the expected size of the data. + * @retval NRF_SUCCESS If the time struct is valid. + * @retval NRF_ERROR_DATA_SIZE If the length does not match the expected size of the data. */ static uint32_t current_time_decode(current_time_char_t * p_time, uint8_t const * p_data, @@ -143,7 +175,7 @@ static uint32_t current_time_decode(current_time_char_t * p_time, if (length != CTS_C_CURRENT_TIME_EXPECTED_LENGTH) { - // Return to prevent accessing out of bounds data. + // Return to prevent accessing the out-of-bounds data. return NRF_ERROR_DATA_SIZE; } @@ -172,12 +204,12 @@ static uint32_t current_time_decode(current_time_char_t * p_time, } -/**@brief Function for decoding a read from the current time characteristic. +/**@brief Function for decoding a read from the Current Time characteristic. * * @param[in] p_time Current Time struct. * - * @return NRF_SUCCESS if the time struct is valid. - * @return NRF_ERROR_INVALID_DATA if the time is out of bounds. + * @retval NRF_SUCCESS If the time struct is valid. + * @retval NRF_ERROR_INVALID_DATA If the time is out of bounds. */ static uint32_t current_time_validate(current_time_char_t * p_time) { @@ -229,9 +261,9 @@ static uint32_t current_time_validate(current_time_char_t * p_time) } -/**@brief Function for reading the current time. The time is decoded, then it is validated. - * Depending on the outcome the cts event handler will be called with - * the current time event or an invalid time event. +/**@brief Function for reading the Current Time. The time is decoded, and then validated. + * Depending on the outcome, the CTS event handler will be called with + * the Current Time event or an invalid time event. * * @param[in] p_cts Current Time Service client structure. * @param[in] p_ble_evt Event received from the BLE stack. @@ -241,7 +273,7 @@ static void current_time_read(ble_cts_c_t * p_cts, ble_evt_t const * p_ble_evt) ble_cts_c_evt_t evt; uint32_t err_code = NRF_SUCCESS; - // Check if the event is on the same connection as this cts instance + // Check whether the event is on the same connection as this CTS instance if (p_cts->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { return; @@ -255,12 +287,12 @@ static void current_time_read(ble_cts_c_t * p_cts, ble_evt_t const * p_ble_evt) if (err_code != NRF_SUCCESS) { - // The data length was invalid, decoding was not completed. + // The data length was invalid. Decoding was not completed. evt.evt_type = BLE_CTS_C_EVT_INVALID_TIME; } else { - // Verify That the time is valid. + // Verify that the time is valid. err_code = current_time_validate(&evt.params.current_time); if (err_code != NRF_SUCCESS) @@ -293,7 +325,7 @@ static void on_disconnect(ble_cts_c_t * p_cts, ble_evt_t const * p_ble_evt) if (ble_cts_c_is_cts_discovered(p_cts)) { - // There was a valid instance of cts on the peer. Send an event to the + // There was a valid instance of CTS on the peer. Send an event to the // application, so that it can do any clean up related to this module. ble_cts_c_evt_t evt; @@ -335,7 +367,17 @@ uint32_t ble_cts_c_current_time_read(ble_cts_c_t const * p_cts) return NRF_ERROR_NOT_FOUND; } - return sd_ble_gattc_read(p_cts->conn_handle, p_cts->char_handles.cts_handle, 0); + nrf_ble_gq_req_t read_req; + + memset(&read_req, 0, sizeof(nrf_ble_gq_req_t)); + + read_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + read_req.error_handler.cb = gatt_error_handler; + read_req.error_handler.p_ctx = (ble_cts_c_t *)p_cts; + read_req.params.gattc_read.handle = p_cts->char_handles.cts_handle; + read_req.params.gattc_read.offset = 0; + + return nrf_ble_gq_item_add(p_cts->p_gatt_queue, &read_req, p_cts->conn_handle); } @@ -349,9 +391,9 @@ uint32_t ble_cts_c_handles_assign(ble_cts_c_t * p_cts, if (p_peer_handles != NULL) { p_cts->char_handles.cts_cccd_handle = p_peer_handles->cts_cccd_handle; - p_cts->char_handles.cts_handle = p_peer_handles->cts_handle; + p_cts->char_handles.cts_handle = p_peer_handles->cts_handle; } - return NRF_SUCCESS; + return nrf_ble_gq_conn_handle_register(p_cts->p_gatt_queue, conn_handle); } #endif // NRF_MODULE_ENABLED(BLE_CTS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cts_c/ble_cts_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cts_c/ble_cts_c.h similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cts_c/ble_cts_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cts_c/ble_cts_c.h index 5d402a7..abfad1e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_cts_c/ble_cts_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_cts_c/ble_cts_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,34 +35,34 @@ * 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 ble_cts_c Current Time Service client + * @defgroup ble_cts_c Current Time Service Client * @{ * @ingroup ble_sdk_srv - * @brief Current Time Service client module. + * @brief Current Time Service Client module. * * @details This module implements the Current Time Service (CTS) client-peripheral role of * the Time Profile. After security is established, the module tries to discover the - * Current Time Service and Characteristic on the central side. If this succeeds, + * Current Time Service and its characteristic on the central side. If this succeeds, * the application can trigger a read of the current time from the connected server. * - * The module informs the application about a successful discovery using the - * @ref BLE_CTS_C_EVT_DISCOVERY_COMPLETE event. The handles for the CTS server is now + * The module informs the application about the successful discovery with the + * @ref BLE_CTS_C_EVT_DISCOVERY_COMPLETE event. The handles for the CTS server are now * available in the @ref ble_cts_c_evt_t structure. These handles must be assigned to an - * instance of CTS_C, using @ref ble_cts_c_handles_assign. For more information about - * service discovery, see the ble_discovery module documentation @ref lib_ble_db_discovery. + * instance of CTS_C with @ref ble_cts_c_handles_assign. For more information about the + * service discovery, see the ble_discovery module documentation: @ref lib_ble_db_discovery. * - * The application can then use the function @ref ble_cts_c_current_time_read to read the - * current time. If the read succeeds, it will trigger either a - * @ref BLE_CTS_C_EVT_CURRENT_TIME event or a @ref BLE_CTS_C_EVT_INVALID_TIME event - * (depending on if the data that was read was actually a valid time), which is then sent + * After assigning the handles to an instance of CTS_C, the application can use the function + * @ref ble_cts_c_current_time_read to read the current time. If the read succeeds, it triggers either + * a @ref BLE_CTS_C_EVT_CURRENT_TIME event or a @ref BLE_CTS_C_EVT_INVALID_TIME event + * (depending whether the data that was read was actually a valid time). Then the read result is sent * to the application. The current time is then available in the params field of the * passed @ref ble_cts_c_evt_t structure. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_cts_c_t instance; @@ -79,6 +79,7 @@ #include "ble.h" #include "ble_date_time.h" #include "ble_db_discovery.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #include @@ -97,22 +98,34 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_CTS_C_BLE_OBSERVER_PRIO, \ ble_cts_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple ble_cts_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_CTS_C_ARRAY_DEF(_name, _cnt) \ +static ble_cts_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_CTS_C_BLE_OBSERVER_PRIO, \ + ble_cts_c_on_ble_evt, &_name, _cnt) + -/**@brief "Day Date Time" field of the "Exact Time 256" field of the Current Time Characteristic. */ +/**@brief "Day Date Time" field of the "Exact Time 256" field of the Current Time characteristic. */ typedef struct { ble_date_time_t date_time; uint8_t day_of_week; } day_date_time_t; -/**@brief "Exact Time 256" field of the Current Time Characteristic. */ +/**@brief "Exact Time 256" field of the Current Time characteristic. */ typedef struct { day_date_time_t day_date_time; uint8_t fractions256; } exact_time_256_t; -/**@brief "Adjust Reason" field of the Current Time Characteristic. */ +/**@brief "Adjust Reason" field of the Current Time characteristic. */ typedef struct { uint8_t manual_time_update : 1; @@ -121,7 +134,7 @@ typedef struct uint8_t change_of_daylight_savings_time : 1; } adjust_reason_t; -/**@brief Data structure for the Current Time Characteristic. */ +/**@brief Data structure for the Current Time characteristic. */ typedef struct { exact_time_256_t exact_time_256; @@ -136,15 +149,15 @@ typedef enum { BLE_CTS_C_EVT_DISCOVERY_COMPLETE, /**< The Current Time Service was found at the peer. */ BLE_CTS_C_EVT_DISCOVERY_FAILED, /**< The Current Time Service was not found at the peer. */ - BLE_CTS_C_EVT_DISCONN_COMPLETE, /**< Event indicating that the Current Time Service client module has finished processing the BLE_GAP_EVT_DISCONNECTED event. This event is raised only if a valid instance of the Current Time Service was found at the server. The event can be used by the application to do clean up related to the Current Time Service client.*/ - BLE_CTS_C_EVT_CURRENT_TIME, /**< A new current time reading has been received. */ - BLE_CTS_C_EVT_INVALID_TIME /**< The current time value received from the peer is invalid.*/ + BLE_CTS_C_EVT_DISCONN_COMPLETE, /**< Event indicating that the Current Time Service Client module finished processing the BLE_GAP_EVT_DISCONNECTED event. This event is triggered only if a valid instance of the Current Time Service was found at the server. The application can use this event to do a cleanup related to the Current Time Service client.*/ + BLE_CTS_C_EVT_CURRENT_TIME, /**< A new Current Time reading has been received. */ + BLE_CTS_C_EVT_INVALID_TIME /**< The Current Time value received from the peer is invalid.*/ } ble_cts_c_evt_type_t; /**@brief Structure containing the handles related to the Heart Rate Service found on the peer. */ typedef struct { - uint16_t cts_handle; /**< Handle of the Current Time characteristic as provided by the SoftDevice. */ + uint16_t cts_handle; /**< Handle of the Current Time characteristic, as provided by the SoftDevice. */ uint16_t cts_cccd_handle; /**< Handle of the CCCD of the Current Time characteristic. */ } ble_cts_c_handles_t; @@ -152,11 +165,11 @@ typedef struct typedef struct { ble_cts_c_evt_type_t evt_type; /**< Type of event. */ - uint16_t conn_handle; /**< Connection handle on which the CTS service was discovered on the peer device. This will be filled if the evt_type is @ref BLE_CTS_C_EVT_DISCOVERY_COMPLETE.*/ + uint16_t conn_handle; /**< Connection handle on which the CTS service was discovered on the peer device. This is filled if the evt_type is @ref BLE_CTS_C_EVT_DISCOVERY_COMPLETE.*/ union { - current_time_char_t current_time; /**< Current Time Characteristic data. This will be filled when the evt_type is @ref BLE_CTS_C_EVT_CURRENT_TIME. */ - ble_cts_c_handles_t char_handles; /**< Current Time related handles found on the peer device. This will be filled when the evt_type is @ref BLE_HRS_C_EVT_DISCOVERY_COMPLETE.*/ + current_time_char_t current_time; /**< Current Time characteristic data. This is filled when the evt_type is @ref BLE_CTS_C_EVT_CURRENT_TIME. */ + ble_cts_c_handles_t char_handles; /**< Handles related to Current Time, found on the peer device. This is filled when the evt_type is @ref BLE_HRS_C_EVT_DISCOVERY_COMPLETE.*/ } params; } ble_cts_c_evt_t; @@ -167,17 +180,19 @@ typedef void (* ble_cts_c_evt_handler_t) (ble_cts_c_t * p_cts, ble_cts_c_evt_t * /**@brief Current Time Service client structure. This structure contains status information for the client. */ struct ble_cts_c_s { - ble_cts_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Current Time Service client. */ - ble_srv_error_handler_t error_handler; /**< Function to be called if an error occurs. */ - ble_cts_c_handles_t char_handles; /**< Handles of Current Time Characteristic at the peer (handles are provided by the BLE stack through the DB Discovery module). */ - uint16_t conn_handle; /**< Handle of the current connection. BLE_CONN_HANDLE_INVALID if not in a connection. */ + ble_cts_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Current Time Service client. */ + ble_srv_error_handler_t error_handler; /**< Function to be called if an error occurs. */ + ble_cts_c_handles_t char_handles; /**< Handles of Current Time characteristic at the peer. (Handles are provided by the BLE stack through the Database Discovery module.) */ + uint16_t conn_handle; /**< Handle of the current connection. BLE_CONN_HANDLE_INVALID if not in a connection. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ }; -/**@brief Current Time Service client init structure. This structure contains all options and data needed for initialization of the client.*/ +/**@brief Current Time Service client init structure. This structure contains all options and data needed for the initialization of the client.*/ typedef struct { - ble_cts_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Current Time Service client. */ - ble_srv_error_handler_t error_handler; /**< Function to be called if an error occurs. */ + ble_cts_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Current Time Service client. */ + ble_srv_error_handler_t error_handler; /**< Function to be called if an error occurs. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } ble_cts_c_init_t; @@ -196,16 +211,16 @@ typedef struct uint32_t ble_cts_c_init(ble_cts_c_t * p_cts, const ble_cts_c_init_t * p_cts_init); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of CTS at the peer. If so, it will - * call the application's event handler indicating that CTS has been - * discovered. It also populates the event with the service related + * @details This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of CTS at the peer. If it does, the function + * calls the application's event handler to indicate that CTS was + * discovered. The function also populates the event with service-related * information before providing it to the application. * * @param[in] p_cts Pointer to the CTS client structure. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void ble_cts_c_on_db_disc_evt(ble_cts_c_t * p_cts, ble_db_discovery_evt_t * p_evt); @@ -214,7 +229,7 @@ uint32_t ble_cts_c_init(ble_cts_c_t * p_cts, const ble_cts_c_init_t * p_cts_init * * @details This function handles all events from the BLE stack that are of interest to the * Current Time Service client. This is a callback function that must be dispatched - * from main application context. + * from the main application context. * * @param[in] p_ble_evt Event received from the BLE stack. * @param[in] p_context Current Time Service client structure. @@ -233,30 +248,34 @@ static __INLINE bool ble_cts_c_is_cts_discovered(const ble_cts_c_t * p_cts) } -/**@brief Function for reading the peer's Current Time Service Current Time Characteristic. +/**@brief Function for reading the peer's Current Time Service Current Time characteristic. * * @param[in] p_cts Current Time Service client structure. * - * @retval NRF_SUCCESS If the operation is successful. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If the operation is successful. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ uint32_t ble_cts_c_current_time_read(ble_cts_c_t const * p_cts); -/**@brief Function for assigning handles to a this instance of cts_c. +/**@brief Function for assigning handles to this instance of cts_c. * * @details Call this function when a link has been established with a peer to - * associate the link to this instance of the module. This makes it + * associate the link to this instance of the module. This association makes it * possible to handle several links and associate each link to a particular - * instance of this module. The connection handle and attribute handles will be + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_CTS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in] p_cts Pointer to the CTS client structure instance to associate. - * @param[in] conn_handle Connection handle to associated with the given CTS instance. + * @param[in] p_cts Pointer to the CTS client structure instance for associating the link. + * @param[in] conn_handle Connection handle to associate with the given CTS instance. * @param[in] p_peer_handles Attribute handles for the CTS server you want this CTS client to * interact with. * * @retval NRF_SUCCESS If the operation was successful. * @retval NRF_ERROR_NULL If a p_cts was a NULL pointer. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_conn_handle_register. */ uint32_t ble_cts_c_handles_assign(ble_cts_c_t * p_cts, const uint16_t conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu.c similarity index 87% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu.c index ed59072..bd8d5ba 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -51,7 +51,8 @@ #include "nrf_sdm.h" #include "nrf_soc.h" #include "nrf_log.h" -#include "nrf_dfu_svci.h" +#include "nrf_dfu_ble_svci_bond_sharing.h" +#include "nrf_bootloader_info.h" #include "nrf_svci_async_function.h" #include "nrf_pwr_mgmt.h" #include "peer_manager.h" @@ -66,6 +67,15 @@ static ble_dfu_buttonless_t m_dfu; /**< Structu NRF_SDH_BLE_OBSERVER(m_dfus_obs, BLE_DFU_BLE_OBSERVER_PRIO, ble_dfu_buttonless_on_ble_evt, &m_dfu); + +/**@brief Function that is called if no event handler is provided. + */ +static void dummy_evt_handler(ble_dfu_buttonless_evt_type_t evt) +{ + NRF_LOG_DEBUG("Dummy event handler received event 0x%x", evt); +} + + /**@brief Function for handling write events to the Buttonless Secure DFU Service Service Control Point characteristic. * * @param[in] p_evt_write Write event received from the BLE stack. @@ -74,20 +84,22 @@ static void on_ctrlpt_write(ble_gatts_evt_write_t const * p_evt_write) { uint32_t err_code; - ble_gatts_rw_authorize_reply_params_t write_authorize_reply; memset(&write_authorize_reply, 0, sizeof(write_authorize_reply)); write_authorize_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; - if (m_dfu.is_ctrlpt_indication_enabled) + uint8_t cccd_val[2]; + ble_gatts_value_t value = {.p_value = cccd_val, .len = 2, .offset = 0}; + err_code = sd_ble_gatts_value_get(m_dfu.conn_handle, m_dfu.control_point_char.cccd_handle, &value); + if (err_code == NRF_SUCCESS && ble_srv_is_indication_enabled(cccd_val)) { write_authorize_reply.params.write.update = 1; write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; } else { - write_authorize_reply.params.write.gatt_status = DFU_RSP_CCCD_CONFIG_IMPROPER; + write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR; } // Authorize the write request @@ -151,7 +163,7 @@ static void on_connect(ble_evt_t const * p_ble_evt) */ static void on_disconnect(ble_evt_t const * p_ble_evt) { - if (m_dfu.conn_handle != p_ble_evt->evt.gatts_evt.conn_handle) + if (m_dfu.conn_handle != p_ble_evt->evt.gap_evt.conn_handle) { return; } @@ -160,30 +172,6 @@ static void on_disconnect(ble_evt_t const * p_ble_evt) } -/**@brief Write event handler. - * - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_write(ble_evt_t const * p_ble_evt) -{ - const ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; - - if (p_evt_write->handle != m_dfu.control_point_char.cccd_handle) - { - return; - } - - if (p_evt_write->len == BLE_CCCD_VALUE_LEN) - { - // CCCD written, update indications state - m_dfu.is_ctrlpt_indication_enabled = ble_srv_is_indication_enabled(p_evt_write->data); - - NRF_LOG_INFO("Received indication state %d", - m_dfu.is_ctrlpt_indication_enabled); - } -} - - /**@brief Function for handling the HVC events. * * @details Handles HVC events from the BLE stack. @@ -228,10 +216,6 @@ void ble_dfu_buttonless_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context on_rw_authorize_req(p_ble_evt); break; - case BLE_GATTS_EVT_WRITE: - on_write(p_ble_evt); - break; - case BLE_GATTS_EVT_HVC: on_hvc(p_ble_evt); break; @@ -245,26 +229,25 @@ void ble_dfu_buttonless_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context uint32_t ble_dfu_buttonless_resp_send(ble_dfu_buttonless_op_code_t op_code, ble_dfu_buttonless_rsp_code_t rsp_code) { - // Send notification + // Send indication uint32_t err_code; - const uint16_t len = 3; + const uint16_t len = MAX_CTRL_POINT_RESP_PARAM_LEN; uint16_t hvx_len; uint8_t hvx_data[MAX_CTRL_POINT_RESP_PARAM_LEN]; ble_gatts_hvx_params_t hvx_params; memset(&hvx_params, 0, sizeof(hvx_params)); - hvx_len = len; + hvx_len = len; hvx_data[0] = DFU_OP_RESPONSE_CODE; hvx_data[1] = (uint8_t)op_code; hvx_data[2] = (uint8_t)rsp_code; - hvx_params.handle = m_dfu.control_point_char.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = hvx_data; - + hvx_params.handle = m_dfu.control_point_char.value_handle; + hvx_params.type = BLE_GATT_HVX_INDICATION; + hvx_params.offset = 0; + hvx_params.p_len = &hvx_len; + hvx_params.p_data = hvx_data; err_code = sd_ble_gatts_hvx(m_dfu.conn_handle, &hvx_params); if ((err_code == NRF_SUCCESS) && (hvx_len != len)) @@ -310,11 +293,15 @@ uint32_t ble_dfu_buttonless_init(const ble_dfu_buttonless_init_t * p_dfu_init) m_dfu.conn_handle = BLE_CONN_HANDLE_INVALID; m_dfu.evt_handler = p_dfu_init->evt_handler; m_dfu.is_waiting_for_reset = false; - m_dfu.is_ctrlpt_indication_enabled = false; + + if (m_dfu.evt_handler == NULL) + { + m_dfu.evt_handler = dummy_evt_handler; + } err_code = ble_dfu_buttonless_backend_init(&m_dfu); VERIFY_SUCCESS(err_code); - + BLE_UUID_BLE_ASSIGN(service_uuid, BLE_DFU_SERVICE_UUID); // Add the DFU service declaration. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu.h similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu.h index c0b0ed3..3b816e2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -60,6 +60,7 @@ #include "ble_srv_common.h" #include "nrf_sdh_ble.h" + #ifdef __cplusplus extern "C" { #endif @@ -70,9 +71,6 @@ extern "C" { */ #define BLE_DFU_SOC_OBSERVER_PRIO 1 - -#define BOOTLOADER_DFU_START (0xB1) /**< Value to set in GPREGRET to boot to DFU mode. */ - #define BLE_DFU_BUTTONLESS_CHAR_UUID (0x0003) /**< Value combined with vendor-specific base to create Unbonded Buttonless characteristic UUID. */ #define BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID (0x0004) /**< Value combined with vendor-specific base to create Bonded Buttonless characteristic UUID. */ @@ -88,7 +86,8 @@ extern "C" { /**@brief Nordic Buttonless DFU Service event type . */ -typedef enum { +typedef enum +{ BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE, /**< Event indicating that the device is preparing to enter bootloader.*/ BLE_DFU_EVT_BOOTLOADER_ENTER, /**< Event indicating that the bootloader will be entered after return of this event.*/ BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED, /**< Failure to enter bootloader mode.*/ @@ -104,13 +103,12 @@ typedef void (*ble_dfu_buttonless_evt_handler_t) (ble_dfu_buttonless_evt_type_t typedef enum { DFU_RSP_INVALID = 0x00, /**< Invalid op code. */ - DFU_RSP_SUCCESS = 0x01, /**< Success. */ + DFU_RSP_SUCCESS = 0x01, /**< Success. */ DFU_RSP_OP_CODE_NOT_SUPPORTED = 0x02, /**< Op code not supported. */ DFU_RSP_OPERATION_FAILED = 0x04, /**< Operation failed. */ DFU_RSP_ADV_NAME_INVALID = 0x05, /**< Requested advertisement name is too short or too long. */ DFU_RSP_BUSY = 0x06, /**< Ongoing async operation. */ DFU_RSP_NOT_BONDED = 0x07, /**< Buttonless unavailable due to device not bonded. */ - DFU_RSP_CCCD_CONFIG_IMPROPER = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR /**< CCCD is improperly configured. */ } ble_dfu_buttonless_rsp_code_t; @@ -120,7 +118,7 @@ typedef enum { DFU_OP_RESERVED = 0x00, /**< Reserved for future use. */ DFU_OP_ENTER_BOOTLOADER = 0x01, /**< Enter bootloader. */ - DFU_OP_SET_ADV_NAME = 0x02, /**< Set advertisement name to use in DFU mode. */ + DFU_OP_SET_ADV_NAME = 0x02, /**< Set advertisement name to use in DFU mode. */ DFU_OP_RESPONSE_CODE = 0x20 /**< Response code. */ } ble_dfu_buttonless_op_code_t; @@ -129,22 +127,22 @@ typedef enum */ typedef struct { - uint8_t uuid_type; /**< UUID type for DFU UUID. */ - uint16_t service_handle; /**< Service Handle of DFU (as provided by the SoftDevice). */ - uint16_t conn_handle; /**< Connection handle for the current peer. */ - ble_gatts_char_handles_t control_point_char; /**< Handles related to the DFU Control Point characteristic. */ - uint32_t peers_count; /**< Counter to see how many persistently stored peers must be updated for Service Changed indication. This value will be counted down when comparing write requests. */ - ble_dfu_buttonless_evt_handler_t evt_handler; /**< Event handler that is called upon Buttonless DFU events. See @ref ble_dfu_buttonless_evt_type_t. */ - bool is_ctrlpt_indication_enabled; /**< Flag indicating that indication is enabled for the control point. */ - bool is_waiting_for_reset; /**< Flag indicating that the device will enter bootloader. */ - bool is_waiting_for_svci; /**< Flag indicating that the device is waiting for async SVCI operation */ + uint8_t uuid_type; /**< UUID type for DFU UUID. */ + uint16_t service_handle; /**< Service Handle of DFU (as provided by the SoftDevice). */ + uint16_t conn_handle; /**< Connection handle for the current peer. */ + ble_gatts_char_handles_t control_point_char; /**< Handles related to the DFU Control Point characteristic. */ + uint32_t peers_count; /**< Counter to see how many persistently stored peers must be updated for Service Changed indication. This value will be counted down when comparing write requests. */ + ble_dfu_buttonless_evt_handler_t evt_handler; /**< Event handler that is called upon Buttonless DFU events. See @ref ble_dfu_buttonless_evt_type_t. */ + bool is_waiting_for_reset; /**< Flag indicating that the device will enter bootloader. */ + bool is_waiting_for_svci; /**< Flag indicating that the device is waiting for async SVCI operation */ } ble_dfu_buttonless_t; /**@brief Type used to initialize the Secure DFU Buttonless Service. */ -typedef struct { - ble_dfu_buttonless_evt_handler_t evt_handler; /**< Bootloader event handler. */ +typedef struct +{ + ble_dfu_buttonless_evt_handler_t evt_handler; /**< Bootloader event handler. */ } ble_dfu_buttonless_init_t; @@ -175,7 +173,7 @@ uint32_t ble_dfu_buttonless_async_svci_init(void); * supports bonds or not. * * @note Do not call this function directly. It is called internally by @ref ble_dfu_buttonless_init. - * + * * @param[in] p_dfu Nordic DFU Service structure. * * @return NRF_SUCCESS On sucessfully initializing, otherwise an error code. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c index 2dbfdfa..53301e1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu_bonded.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,16 +35,14 @@ * 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 #include #include -#include "compiler_abstraction.h" -#include "nrf_dfu_svci.h" +#include "nrf_dfu_ble_svci_bond_sharing.h" #include "nordic_common.h" -#include "nrf_dfu_svci.h" #include "nrf_error.h" #include "ble_dfu.h" #include "nrf_log.h" @@ -52,18 +50,24 @@ #include "gatts_cache_manager.h" #include "peer_id.h" #include "nrf_sdh_soc.h" +#include "nrf_strerror.h" -#if defined(NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS) && (NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS == 1) +#if (NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS) + + +void ble_dfu_buttonless_on_sys_evt(uint32_t, void * ); +uint32_t nrf_dfu_svci_vector_table_set(void); +uint32_t nrf_dfu_svci_vector_table_unset(void); /**@brief Define function for async interface to set peer data. */ NRF_SVCI_ASYNC_FUNC_DEFINE(NRF_DFU_SVCI_SET_PEER_DATA, nrf_dfu_set_peer_data, nrf_dfu_peer_data_t); +// Register SoC observer for the Buttonless Secure DFU service +NRF_SDH_SOC_OBSERVER(m_dfu_buttonless_soc_obs, BLE_DFU_SOC_OBSERVER_PRIO, ble_dfu_buttonless_on_sys_evt, NULL); + ble_dfu_buttonless_t * mp_dfu; static nrf_dfu_peer_data_t m_peer_data; -void ble_dfu_buttonless_on_sys_evt(uint32_t, void * ); -// Register SoC observer for the Buttonless Secure DFU service -NRF_SDH_SOC_OBSERVER(m_dfu_buttonless_soc_obs, BLE_DFU_SOC_OBSERVER_PRIO, ble_dfu_buttonless_on_sys_evt, NULL); /**@brief Function for handling Peer Manager events. * @@ -71,7 +75,8 @@ NRF_SDH_SOC_OBSERVER(m_dfu_buttonless_soc_obs, BLE_DFU_SOC_OBSERVER_PRIO, ble_df */ static void pm_evt_handler(pm_evt_t const * p_evt) { - uint32_t err_code; + uint32_t ret; + if (mp_dfu == NULL) { return; @@ -86,7 +91,7 @@ static void pm_evt_handler(pm_evt_t const * p_evt) switch(p_evt->evt_id) { case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED: - if (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_GATT_LOCAL) + if (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_SERVICE_CHANGED_PENDING) { mp_dfu->peers_count--; NRF_LOG_DEBUG("Updating Service Changed indication for peers, %d left", mp_dfu->peers_count); @@ -94,63 +99,59 @@ static void pm_evt_handler(pm_evt_t const * p_evt) { NRF_LOG_DEBUG("Finished updating Service Changed indication for peers"); // We have updated Service Changed Indication for all devices. - err_code = ble_dfu_buttonless_bootloader_start_finalize(); - if (err_code != NRF_SUCCESS) + ret = ble_dfu_buttonless_bootloader_start_finalize(); + if (ret != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED); } } - break; } + break; case PM_EVT_PEER_DATA_UPDATE_FAILED: // Failure to update data. Service Changed cannot be sent but DFU mode is still possible - err_code = ble_dfu_buttonless_bootloader_start_finalize(); - if (err_code != NRF_SUCCESS) + ret = ble_dfu_buttonless_bootloader_start_finalize(); + if (ret != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED); } - break; default: break; } - } static uint32_t retrieve_peer_data(void) { - ret_code_t ret_code; - pm_peer_data_bonding_t bonding_data; + ret_code_t ret; + pm_peer_data_bonding_t bonding_data = {0}; pm_peer_id_t peer_id; - ret_code = pm_peer_id_get(mp_dfu->conn_handle, &peer_id); - VERIFY_SUCCESS(ret_code); + ret = pm_peer_id_get(mp_dfu->conn_handle, &peer_id); + VERIFY_SUCCESS(ret); if (peer_id == PM_PEER_ID_INVALID) { return NRF_ERROR_FORBIDDEN; } - ret_code = pm_peer_data_bonding_load(peer_id, &bonding_data); - VERIFY_SUCCESS(ret_code); + ret = pm_peer_data_bonding_load(peer_id, &bonding_data); + VERIFY_SUCCESS(ret); - memcpy(&m_peer_data.ble_id, &bonding_data.peer_ble_id, sizeof(ble_gap_id_key_t)); - memcpy(&m_peer_data.enc_key, &bonding_data.own_ltk, sizeof(ble_gap_enc_key_t)); + memcpy(&m_peer_data.ble_id, &bonding_data.peer_ble_id, sizeof(ble_gap_id_key_t)); + memcpy(&m_peer_data.enc_key, &bonding_data.own_ltk, sizeof(ble_gap_enc_key_t)); uint16_t len = SYSTEM_SERVICE_ATT_SIZE; - ret_code = sd_ble_gatts_sys_attr_get(mp_dfu->conn_handle, - m_peer_data.sys_serv_attr, - &len, - BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS); + ret = sd_ble_gatts_sys_attr_get(mp_dfu->conn_handle, + m_peer_data.sys_serv_attr, + &len, + BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS); - NRF_LOG_INFO("---------------system attribute table: %d--------------", len); + NRF_LOG_DEBUG("system attribute table len: %d", len); - VERIFY_SUCCESS(ret_code); - - return NRF_SUCCESS; + return ret; } @@ -160,99 +161,98 @@ static uint32_t retrieve_peer_data(void) */ static uint32_t enter_bootloader(void) { - uint32_t err_code; + uint32_t ret; - NRF_LOG_INFO("Writing peer data to the bootloader"); + NRF_LOG_INFO("Writing peer data to the bootloader..."); if (mp_dfu->is_waiting_for_svci) { return ble_dfu_buttonless_resp_send(DFU_OP_ENTER_BOOTLOADER, DFU_RSP_BUSY); } - // If retrieve_peer_data returns NRF_ERROR_FORBIDDEN, then - // the device was not bonded. - err_code = retrieve_peer_data(); - VERIFY_SUCCESS(err_code); + // If retrieve_peer_data returns NRF_ERROR_FORBIDDEN, then the device was not bonded. + ret = retrieve_peer_data(); + VERIFY_SUCCESS(ret); - err_code = nrf_dfu_set_peer_data(&m_peer_data); - if (err_code == NRF_SUCCESS) + ret = nrf_dfu_set_peer_data(&m_peer_data); + if (ret == NRF_SUCCESS) { - // The request was accepted. Waiting for - // sys events to progress. + // The request was accepted. Waiting for sys events to progress. mp_dfu->is_waiting_for_svci = true; } + else if (ret == NRF_ERROR_FORBIDDEN) + { + NRF_LOG_ERROR("The bootloader has write protected its settings page. This prohibits setting the peer data. "\ + "The bootloader must be compiled with NRF_BL_SETTINGS_PAGE_PROTECT=0 to allow setting the peer data."); + } - return err_code; + return ret; } uint32_t ble_dfu_buttonless_backend_init(ble_dfu_buttonless_t * p_dfu) { - uint32_t err_code = NRF_SUCCESS; - VERIFY_PARAM_NOT_NULL(p_dfu); - + // Set the memory used by the backend. mp_dfu = p_dfu; - + // Initialize the Peer manager handler. - err_code = pm_register(&pm_evt_handler); - VERIFY_SUCCESS(err_code); - - return NRF_SUCCESS; + return pm_register(pm_evt_handler); } -uint32_t nrf_dfu_svci_vector_table_set(void); -uint32_t nrf_dfu_svci_vector_table_unset(void); - - uint32_t ble_dfu_buttonless_async_svci_init(void) { - uint32_t ret_val; + uint32_t ret; // Set the vector table base address to the bootloader. - ret_val = nrf_dfu_svci_vector_table_set(); - VERIFY_SUCCESS(ret_val); + ret = nrf_dfu_svci_vector_table_set(); + NRF_LOG_DEBUG("nrf_dfu_svci_vector_table_set() -> %s", + (ret == NRF_SUCCESS) ? "success" : nrf_strerror_get(ret)); + VERIFY_SUCCESS(ret); // Initialize the asynchronous SuperVisor interface to set peer data in Secure DFU bootloader. - ret_val = nrf_dfu_set_peer_data_init(); - VERIFY_SUCCESS(ret_val); + ret = nrf_dfu_set_peer_data_init(); + NRF_LOG_DEBUG("nrf_dfu_set_peer_data_init() -> %s", + (ret == NRF_SUCCESS) ? "success" : nrf_strerror_get(ret)); + VERIFY_SUCCESS(ret); // Set the vector table base address back to main application. - ret_val = nrf_dfu_svci_vector_table_unset(); - VERIFY_SUCCESS(ret_val); + ret = nrf_dfu_svci_vector_table_unset(); + NRF_LOG_DEBUG("nrf_dfu_svci_vector_table_unset() -> %s", + (ret == NRF_SUCCESS) ? "success" : nrf_strerror_get(ret)); - return ret_val; + return ret; } void ble_dfu_buttonless_on_sys_evt(uint32_t sys_evt, void * p_context) { - uint32_t err_code; + uint32_t ret; if (!nrf_dfu_set_peer_data_is_initialized()) { return; } - err_code = nrf_dfu_set_peer_data_on_sys_evt(sys_evt); - if (err_code == NRF_ERROR_BUSY) + ret = nrf_dfu_set_peer_data_on_sys_evt(sys_evt); + if (ret == NRF_ERROR_INVALID_STATE) { - // The async operations are ongoing. - // No action is taken, and nothing is reported + // The system event is not from an operation started by buttonless DFU. + // No action is taken, and nothing is reported. } - else if (err_code == NRF_SUCCESS) + else if (ret == NRF_SUCCESS) { // Peer data was successfully forwarded to the Secure DFU bootloader. // Set the flag indicating that we are waiting for indication response // to activate the reset. mp_dfu->is_waiting_for_reset = true; - mp_dfu->is_waiting_for_svci = false; + mp_dfu->is_waiting_for_svci = false; // Report back the positive response - err_code = ble_dfu_buttonless_resp_send(DFU_OP_ENTER_BOOTLOADER, DFU_RSP_SUCCESS); - if (err_code != NRF_SUCCESS) + ret = ble_dfu_buttonless_resp_send(DFU_OP_ENTER_BOOTLOADER, DFU_RSP_SUCCESS); + if (ret != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_RESPONSE_SEND_ERROR); mp_dfu->is_waiting_for_reset = false; @@ -262,11 +262,11 @@ void ble_dfu_buttonless_on_sys_evt(uint32_t sys_evt, void * p_context) { // Failed to set peer data. Report this. mp_dfu->is_waiting_for_reset = false; - mp_dfu->is_waiting_for_svci = false; - err_code = ble_dfu_buttonless_resp_send(DFU_OP_ENTER_BOOTLOADER, DFU_RSP_OPERATION_FAILED); + mp_dfu->is_waiting_for_svci = false; + ret = ble_dfu_buttonless_resp_send(DFU_OP_ENTER_BOOTLOADER, DFU_RSP_BUSY); // Report the failure to send the response to the client - if (err_code != NRF_SUCCESS) + if (ret != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_RESPONSE_SEND_ERROR); } @@ -279,65 +279,44 @@ void ble_dfu_buttonless_on_sys_evt(uint32_t sys_evt, void * p_context) uint32_t ble_dfu_buttonless_char_add(ble_dfu_buttonless_t * p_dfu) { - ble_gatts_char_md_t char_md = {{0}}; - ble_gatts_attr_md_t cccd_md = {{0}}; - ble_gatts_attr_t attr_char_value = {0}; - ble_gatts_attr_md_t attr_md = {{0}}; - ble_uuid_t char_uuid; - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm); - - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - char_md.char_props.indicate = 1; - char_md.char_props.write = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - char_uuid.type = p_dfu->uuid_type; - char_uuid.uuid = BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID; - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 1; - attr_md.vlen = 1; - - attr_char_value.p_uuid = &char_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = BLE_GATT_ATT_MTU_DEFAULT; - attr_char_value.p_value = 0; - - return sd_ble_gatts_characteristic_add(p_dfu->service_handle, - &char_md, - &attr_char_value, - &p_dfu->control_point_char); + ble_add_char_params_t add_char_params; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID; + add_char_params.uuid_type = p_dfu->uuid_type; + add_char_params.char_props.indicate = 1; + add_char_params.char_props.write = 1; + add_char_params.is_defered_write = true; + add_char_params.is_var_len = true; + add_char_params.max_len = BLE_GATT_ATT_MTU_DEFAULT; + + add_char_params.cccd_write_access = SEC_JUST_WORKS; + add_char_params.write_access = SEC_JUST_WORKS; + add_char_params.read_access = SEC_OPEN; + + return characteristic_add(p_dfu->service_handle, &add_char_params, &p_dfu->control_point_char); } void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_write) { - uint32_t err_code; + uint32_t ret; ble_dfu_buttonless_rsp_code_t rsp_code = DFU_RSP_OPERATION_FAILED; // Start executing the control point write action switch (p_evt_write->data[0]) { case DFU_OP_ENTER_BOOTLOADER: - err_code = enter_bootloader(); - if (err_code == NRF_SUCCESS) + ret = enter_bootloader(); + if (ret == NRF_SUCCESS) { rsp_code = DFU_RSP_SUCCESS; } - else if (err_code == NRF_ERROR_FORBIDDEN) + else if (ret == NRF_ERROR_BUSY) + { + rsp_code = DFU_RSP_BUSY; + } + else if (ret == NRF_ERROR_FORBIDDEN) { rsp_code = DFU_RSP_NOT_BONDED; } @@ -348,12 +327,13 @@ void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_wri break; } - // Report back in case of error if (rsp_code != DFU_RSP_SUCCESS) { - err_code = ble_dfu_buttonless_resp_send((ble_dfu_buttonless_op_code_t)p_evt_write->data[0], rsp_code); - if (err_code != NRF_SUCCESS) + ret = ble_dfu_buttonless_resp_send((ble_dfu_buttonless_op_code_t)p_evt_write->data[0], + rsp_code); + + if (ret != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_RESPONSE_SEND_ERROR); } @@ -366,8 +346,6 @@ void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_wri uint32_t ble_dfu_buttonless_bootloader_start_prepare(void) { - uint32_t err_code; - NRF_LOG_DEBUG("In ble_dfu_buttonless_bootloader_start_prepare"); // Indicate to main app that DFU mode is starting. @@ -375,20 +353,6 @@ uint32_t ble_dfu_buttonless_bootloader_start_prepare(void) // bonded devices. mp_dfu->evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE); - // Disconnect from the device to enable Service Changed on next connection. - // (Stored in Peer Manager persistent storage for next bootup). - err_code = sd_ble_gap_disconnect(mp_dfu->conn_handle, - BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed to disconnect GAP connection"); - return err_code; - } - else - { - NRF_LOG_DEBUG("Disconnected peer"); - } - // Store the number of peers for which Peer Manager is expected to successfully write events. mp_dfu->peers_count = peer_id_n_ids(); @@ -396,8 +360,8 @@ uint32_t ble_dfu_buttonless_bootloader_start_prepare(void) // on next bootup (either because of a successful or aborted DFU). gscm_local_database_has_changed(); - return err_code; + return NRF_SUCCESS; } -#endif //defined(NRF_DFU_BOTTONLESS_SUPPORT_BOND) && (NRF_DFU_BOTTONLESS_SUPPORT_BOND == 1) +#endif // NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c similarity index 78% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c index 13792a9..5362167 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,36 +35,37 @@ * 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 #include #include -#include "compiler_abstraction.h" -#include "nrf_dfu_svci.h" +#include "nrf_dfu_ble_svci_bond_sharing.h" #include "nordic_common.h" -#include "nrf_dfu_svci.h" #include "nrf_error.h" #include "ble_dfu.h" #include "nrf_log.h" #include "nrf_sdh_soc.h" -#if !defined(NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS) || (NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS == 0) +#if (!NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS) #define NRF_DFU_ADV_NAME_MAX_LENGTH (20) +void ble_dfu_buttonless_on_sys_evt(uint32_t, void * ); +uint32_t nrf_dfu_svci_vector_table_set(void); +uint32_t nrf_dfu_svci_vector_table_unset(void); + /**@brief Define functions for async interface to set new advertisement name for DFU mode. */ NRF_SVCI_ASYNC_FUNC_DEFINE(NRF_DFU_SVCI_SET_ADV_NAME, nrf_dfu_set_adv_name, nrf_dfu_adv_name_t); -ble_dfu_buttonless_t * mp_dfu = NULL; -static nrf_dfu_adv_name_t m_adv_name; - -void ble_dfu_buttonless_on_sys_evt(uint32_t, void * ); // Register SoC observer for the Buttonless Secure DFU service NRF_SDH_SOC_OBSERVER(m_dfu_buttonless_soc_obs, BLE_DFU_SOC_OBSERVER_PRIO, ble_dfu_buttonless_on_sys_evt, NULL); +ble_dfu_buttonless_t * mp_dfu = NULL; +static nrf_dfu_adv_name_t m_adv_name; + /**@brief Function for setting an advertisement name. * @@ -89,6 +90,11 @@ static uint32_t set_adv_name(nrf_dfu_adv_name_t * p_adv_name) // The request was accepted. mp_dfu->is_waiting_for_svci = true; } + else if (err_code == NRF_ERROR_FORBIDDEN) + { + NRF_LOG_ERROR("The bootloader has write protected its settings page. This prohibits setting the advertising name. "\ + "The bootloader must be compiled with NRF_BL_SETTINGS_PAGE_PROTECT=0 to allow setting the advertising name."); + } return err_code; } @@ -125,19 +131,16 @@ static uint32_t enter_bootloader() } -uint32_t nrf_dfu_svci_vector_table_set(void); -uint32_t nrf_dfu_svci_vector_table_unset(void); - - uint32_t ble_dfu_buttonless_backend_init(ble_dfu_buttonless_t * p_dfu) { VERIFY_PARAM_NOT_NULL(p_dfu); - + mp_dfu = p_dfu; - + return NRF_SUCCESS; } + uint32_t ble_dfu_buttonless_async_svci_init(void) { uint32_t ret_val; @@ -164,11 +167,10 @@ void ble_dfu_buttonless_on_sys_evt(uint32_t sys_evt, void * p_context) } err_code = nrf_dfu_set_adv_name_on_sys_evt(sys_evt); - if (err_code == NRF_ERROR_BUSY) + if (err_code == NRF_ERROR_INVALID_STATE) { - // Async operations are ongoing. - // No action is taken, and nothing is reported - + // The system event is not from an operation started by buttonless DFU. + // No action is taken, and nothing is reported. } else if (err_code == NRF_SUCCESS) { @@ -189,59 +191,36 @@ void ble_dfu_buttonless_on_sys_evt(uint32_t sys_evt, void * p_context) // Invalid error code reported back. mp_dfu->is_waiting_for_svci = false; - err_code = ble_dfu_buttonless_resp_send(DFU_OP_SET_ADV_NAME, DFU_RSP_OPERATION_FAILED); + err_code = ble_dfu_buttonless_resp_send(DFU_OP_SET_ADV_NAME, DFU_RSP_BUSY); if (err_code != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_RESPONSE_SEND_ERROR); } + + // Report the failure to enter DFU mode + mp_dfu->evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED); } } uint32_t ble_dfu_buttonless_char_add(ble_dfu_buttonless_t * p_dfu) { - ble_gatts_char_md_t char_md = {{0}}; - ble_gatts_attr_md_t cccd_md = {{0}}; - ble_gatts_attr_t attr_char_value = {0}; - ble_gatts_attr_md_t attr_md = {{0}}; - ble_uuid_t char_uuid; - - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); - - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - char_md.char_props.indicate = 1; - char_md.char_props.write = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - char_uuid.type = p_dfu->uuid_type; - char_uuid.uuid = BLE_DFU_BUTTONLESS_CHAR_UUID; - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 1; - attr_md.vlen = 1; - - attr_char_value.p_uuid = &char_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = BLE_GATT_ATT_MTU_DEFAULT; - attr_char_value.p_value = 0; - - return sd_ble_gatts_characteristic_add(p_dfu->service_handle, - &char_md, - &attr_char_value, - &p_dfu->control_point_char); + ble_add_char_params_t add_char_params; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_DFU_BUTTONLESS_CHAR_UUID; + add_char_params.uuid_type = p_dfu->uuid_type; + add_char_params.char_props.indicate = 1; + add_char_params.char_props.write = 1; + add_char_params.is_defered_write = true; + add_char_params.is_var_len = true; + add_char_params.max_len = BLE_GATT_ATT_MTU_DEFAULT; + + add_char_params.cccd_write_access = SEC_OPEN; + add_char_params.write_access = SEC_OPEN; + add_char_params.read_access = SEC_OPEN; + + return characteristic_add(p_dfu->service_handle, &add_char_params, &p_dfu->control_point_char); } @@ -260,12 +239,15 @@ void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_wri { rsp_code = DFU_RSP_SUCCESS; } + else if (err_code == NRF_ERROR_BUSY) + { + rsp_code = DFU_RSP_BUSY; + } break; case DFU_OP_SET_ADV_NAME: - - if(p_evt_write->data[1] > NRF_DFU_ADV_NAME_MAX_LENGTH || - p_evt_write->data[1] == 0 ) + if( (p_evt_write->data[1] > NRF_DFU_ADV_NAME_MAX_LENGTH) + || (p_evt_write->data[1] == 0)) { // New advertisement name too short or too long. rsp_code = DFU_RSP_ADV_NAME_INVALID; @@ -280,7 +262,6 @@ void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_wri rsp_code = DFU_RSP_SUCCESS; } } - break; default: @@ -297,7 +278,10 @@ void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_wri if (err_code != NRF_SUCCESS) { mp_dfu->evt_handler(BLE_DFU_EVT_RESPONSE_SEND_ERROR); + } + // Report the error to the main application + mp_dfu->evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED); } } @@ -312,4 +296,4 @@ uint32_t ble_dfu_buttonless_bootloader_start_prepare(void) return err_code; } -#endif // #if defined(NRF_DFU_BOTTONLESS_SUPPORT_BOND) && (NRF_DFU_BOTTONLESS_SUPPORT_BOND == 1) +#endif // NRF_DFU_BOTTONLESS_SUPPORT_BOND diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dis/ble_dis.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis/ble_dis.c similarity index 83% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dis/ble_dis.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis/ble_dis.c index 8bb8340..ec22317 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dis/ble_dis.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis/ble_dis.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -116,7 +116,7 @@ static void pnp_id_encode(uint8_t * p_encoded_buffer, ble_dis_pnp_id_t const * p * @param[in] uuid UUID of characteristic to be added. * @param[in] p_char_value Initial value of characteristic to be added. * @param[in] char_len Length of initial value. This will also be the maximum value. - * @param[in] dis_attr_md Security settings of characteristic to be added. + * @param[in] rd_sec Security requirement for reading characteristic value. * @param[out] p_handles Handles of new characteristic. * * @return NRF_SUCCESS on success, otherwise an error code. @@ -124,48 +124,24 @@ static void pnp_id_encode(uint8_t * p_encoded_buffer, ble_dis_pnp_id_t const * p static uint32_t char_add(uint16_t uuid, uint8_t * p_char_value, uint16_t char_len, - ble_srv_security_mode_t const * dis_attr_md, + security_req_t const rd_sec, ble_gatts_char_handles_t * p_handles) { - ble_uuid_t ble_uuid; - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_gatts_attr_md_t attr_md; + ble_add_char_params_t add_char_params; APP_ERROR_CHECK_BOOL(p_char_value != NULL); APP_ERROR_CHECK_BOOL(char_len > 0); - // The ble_gatts_char_md_t structure uses bit fields. So we reset the memory to zero. - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, uuid); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = dis_attr_md->read_perm; - attr_md.write_perm = dis_attr_md->write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); + memset(&add_char_params, 0, sizeof(add_char_params)); - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = char_len; - attr_char_value.init_offs = 0; - attr_char_value.max_len = char_len; - attr_char_value.p_value = p_char_value; + add_char_params.uuid = uuid; + add_char_params.max_len = char_len; + add_char_params.init_len = char_len; + add_char_params.p_init_value = p_char_value; + add_char_params.char_props.read = 1; + add_char_params.read_access = rd_sec; - return sd_ble_gatts_characteristic_add(service_handle, &char_md, &attr_char_value, p_handles); + return characteristic_add(service_handle, &add_char_params, p_handles); } @@ -189,7 +165,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_MANUFACTURER_NAME_STRING_CHAR, p_dis_init->manufact_name_str.p_str, p_dis_init->manufact_name_str.length, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &manufact_name_handles); if (err_code != NRF_SUCCESS) { @@ -201,7 +177,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_MODEL_NUMBER_STRING_CHAR, p_dis_init->model_num_str.p_str, p_dis_init->model_num_str.length, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &model_num_handles); if (err_code != NRF_SUCCESS) { @@ -213,7 +189,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_SERIAL_NUMBER_STRING_CHAR, p_dis_init->serial_num_str.p_str, p_dis_init->serial_num_str.length, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &serial_num_handles); if (err_code != NRF_SUCCESS) { @@ -225,7 +201,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_HARDWARE_REVISION_STRING_CHAR, p_dis_init->hw_rev_str.p_str, p_dis_init->hw_rev_str.length, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &hw_rev_handles); if (err_code != NRF_SUCCESS) { @@ -237,7 +213,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_FIRMWARE_REVISION_STRING_CHAR, p_dis_init->fw_rev_str.p_str, p_dis_init->fw_rev_str.length, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &fw_rev_handles); if (err_code != NRF_SUCCESS) { @@ -249,7 +225,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_SOFTWARE_REVISION_STRING_CHAR, p_dis_init->sw_rev_str.p_str, p_dis_init->sw_rev_str.length, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &sw_rev_handles); if (err_code != NRF_SUCCESS) { @@ -264,7 +240,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_SYSTEM_ID_CHAR, encoded_sys_id, BLE_DIS_SYS_ID_LEN, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &sys_id_handles); if (err_code != NRF_SUCCESS) { @@ -276,7 +252,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR, p_dis_init->p_reg_cert_data_list->p_list, p_dis_init->p_reg_cert_data_list->list_len, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, ®_cert_data_list_handles); if (err_code != NRF_SUCCESS) { @@ -291,7 +267,7 @@ uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init) err_code = char_add(BLE_UUID_PNP_ID_CHAR, encoded_pnp_id, BLE_DIS_PNP_ID_LEN, - &p_dis_init->dis_attr_md, + p_dis_init->dis_char_rd_sec, &pnp_id_handles); if (err_code != NRF_SUCCESS) { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dis/ble_dis.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis/ble_dis.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dis/ble_dis.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis/ble_dis.h index 608e6f0..498e772 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_dis/ble_dis.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis/ble_dis.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -107,7 +107,7 @@ typedef struct ble_dis_sys_id_t * p_sys_id; /**< System ID. */ ble_dis_reg_cert_data_list_t * p_reg_cert_data_list; /**< IEEE 11073-20601 Regulatory Certification Data List. */ ble_dis_pnp_id_t * p_pnp_id; /**< PnP ID. */ - ble_srv_security_mode_t dis_attr_md; /**< Initial Security Setting for Device Information Characteristics. */ + security_req_t dis_char_rd_sec; /**< Security requirement for reading any DIS characteristic value. */ } ble_dis_init_t; /**@brief Function for initializing the Device Information Service. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.c new file mode 100644 index 0000000..1ab59f8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.c @@ -0,0 +1,516 @@ +/** + * Copyright (c) 2017 - 2019, 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(BLE_DIS_C) +#include + +#include "ble.h" +#include "ble_dis_c.h" +#include "ble_gattc.h" +#include "nrf_bitmask.h" +#include "app_error.h" + +#define NRF_LOG_MODULE_NAME ble_dis +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +// Value Field lengths for System ID characteristic. +#define BLE_DIS_C_MANUF_ID_LEN 5 /**< Length of Manufacturer ID field inside System ID characteristic. */ +#define BLE_DIS_C_OU_ID_LEN 3 /**< Length of Organizationally Unique ID field inside System ID characteristic. */ + +// Value Field lengths for PnP ID characteristic. +#define BLE_DIS_C_VENDOR_ID_SRC_LEN 1 /**< Length of Vendor ID Source field inside PnP ID characteristic. */ +#define BLE_DIS_C_VENDOR_ID_LEN 2 /**< Length of Vendor ID field inside PnP ID characteristic. */ +#define BLE_DIS_C_PRODUCT_ID_LEN 2 /**< Length of Product ID field inside PnP ID characteristic. */ +#define BLE_DIS_C_PRODUCT_VER_LEN 2 /**< Length of Product Version field inside PnP ID characteristic. */ + +#define BLE_DIS_C_ALL_CHARS_DISABLED_MASK 0x0000 /**< All DIS characteristics should be disabled. */ +#define BLE_DIS_C_ALL_CHARS_ENABLED_MASK 0xFFFF /**< All DIS characteristics should be enabled. */ + + +/**@brief Function for interception of gattc errors. + * + * @param[in] nrf_error Error code returned by SoftDevice. + * @param[in] p_contex Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, void * p_contex, uint16_t conn_handle) +{ + UNUSED_PARAMETER(conn_handle); + + ble_dis_c_t const * const p_ble_disc_c = (ble_dis_c_t *)p_contex; + + if (p_ble_disc_c != NULL) + { + p_ble_disc_c->error_handler(nrf_error); + } +} + + +/**@brief Function for decoding System ID characteristic value. + * + * @param[in] p_data Pointer to System ID characteristic data. + * @param[in] len Length of the System ID characteristic data. + * @param[out] p_sys_id Decoded System ID characteristic. + * + * @retval NRF_SUCCESS If the characteristic was initialized successfully. + * @retval NRF_ERROR_INVALID_LENGTH Any parameter is NULL. + */ +static ret_code_t system_id_decode(uint8_t const * p_data, + uint16_t len, + ble_dis_sys_id_t * const p_sys_id) +{ + uint16_t const expected_len = (BLE_DIS_C_MANUF_ID_LEN + BLE_DIS_C_OU_ID_LEN); + + // Validate response length. + if (expected_len != len) + { + NRF_LOG_ERROR("System ID characteristic data cannot be decoded."); + NRF_LOG_ERROR("Expected data length != Received data length: %d != %d", expected_len, len); + return NRF_ERROR_INVALID_LENGTH; + } + + // Decode Manufacturer ID. + p_sys_id->manufacturer_id = uint40_decode(p_data); + p_data += BLE_DIS_C_MANUF_ID_LEN; + + // Decode Organizationally unique ID. + p_sys_id->organizationally_unique_id = uint24_decode(p_data); + + return NRF_SUCCESS; +} + + +/**@brief Function for decoding PnP ID characteristic value. + * + * @param[in] p_data Pointer to PnP ID characteristic data. + * @param[in] len Length of the PnP ID characteristic data. + * @param[out] p_pnp_id Decoded PnP ID characteristic. + * + * @retval NRF_SUCCESS If the characteristic was initialized successfully. + * @retval NRF_ERROR_INVALID_LENGTH Any parameter is NULL. + */ +static ret_code_t pnp_id_decode(uint8_t const * p_data, + uint16_t len, + ble_dis_pnp_id_t * const p_pnp_id) +{ + uint16_t const expected_len = (BLE_DIS_C_VENDOR_ID_SRC_LEN + BLE_DIS_C_VENDOR_ID_LEN + + BLE_DIS_C_PRODUCT_ID_LEN + BLE_DIS_C_PRODUCT_VER_LEN); + + // Validate response length. + if (expected_len != len) + { + NRF_LOG_ERROR("PnP ID characteristic data cannot be decoded."); + NRF_LOG_ERROR("Expected data length != Received data length: %d != %d", expected_len, len); + return NRF_ERROR_INVALID_LENGTH; + } + + // Decode Vendor ID Source. + p_pnp_id->vendor_id_source = p_data[0]; + p_data += BLE_DIS_C_VENDOR_ID_SRC_LEN; + + // Decode Vendor ID. + p_pnp_id->vendor_id = uint16_decode(p_data); + p_data += BLE_DIS_C_VENDOR_ID_LEN; + + // Decode Product ID. + p_pnp_id->product_id = uint16_decode(p_data); + p_data += BLE_DIS_C_PRODUCT_ID_LEN; + + // Decode Product Version. + p_pnp_id->product_version = uint16_decode(p_data); + + return NRF_SUCCESS; +} + + +/**@brief Function for matching DIS Client characteristic type with the provided response handle. + * + * @param[in] p_ble_dis_c Pointer to the Device Information Client Structure. + * @param[in] response_handle Attribute handle from the response event. + */ +static ble_dis_c_char_type_t char_type_get(ble_dis_c_t * p_ble_dis_c, uint16_t response_handle) +{ + for (ble_dis_c_char_type_t char_type = (ble_dis_c_char_type_t) 0; + char_type < BLE_DIS_C_CHAR_TYPES_NUM; + char_type++) + { + if (response_handle == p_ble_dis_c->handles[char_type]) + { + return char_type; + } + } + return BLE_DIS_C_CHAR_TYPES_NUM; +} + + +/**@brief Function for handling read response events. + * + * @details This function will validate the read response and raise the appropriate + * event to the application. + * + * @param[in] p_ble_dis_c Pointer to the Device Information Client Structure. + * @param[in] p_ble_evt Pointer to the SoftDevice event. + */ +static void on_read_rsp(ble_dis_c_t * p_ble_dis_c, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_gattc_evt_read_rsp_t const * p_response = &p_ble_evt->evt.gattc_evt.params.read_rsp; + ble_dis_c_evt_t ble_dis_c_evt; + ble_dis_c_char_type_t char_type; + + // Check if the event is on the link for this instance and the event handler is present. + if ((p_ble_dis_c->evt_handler == NULL) || + (p_ble_dis_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle)) + { + return; + } + + char_type = char_type_get(p_ble_dis_c, p_response->handle); + if (char_type < BLE_DIS_C_CHAR_TYPES_NUM) // Characteristic type is valid. + { + memset(&ble_dis_c_evt, 0, sizeof(ble_dis_c_evt_t)); + + ble_dis_c_evt.conn_handle = p_ble_evt->evt.gattc_evt.conn_handle; + + if (p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_SUCCESS) + { + ble_dis_c_evt_read_rsp_t * const p_dis_rsp = &ble_dis_c_evt.params.read_rsp; + + ble_dis_c_evt.evt_type = BLE_DIS_C_EVT_DIS_C_READ_RSP; + + p_dis_rsp->char_type = char_type; + p_dis_rsp->handle = p_response->handle; + + // Decode characteristic value. + switch (char_type) + { + case BLE_DIS_C_MANUF_NAME: + case BLE_DIS_C_MODEL_NUM: + case BLE_DIS_C_SERIAL_NUM: + case BLE_DIS_C_HW_REV: + case BLE_DIS_C_FW_REV: + case BLE_DIS_C_SW_REV: + p_dis_rsp->content.string.p_data = (uint8_t *) p_response->data; + p_dis_rsp->content.string.len = p_response->len; + break; + + case BLE_DIS_C_SYS_ID: + err_code = system_id_decode(p_response->data, + p_response->len, + &p_dis_rsp->content.sys_id); + if ((p_ble_dis_c->error_handler != NULL) && (err_code != NRF_SUCCESS)) + { + p_ble_dis_c->error_handler(err_code); + } + break; + + case BLE_DIS_C_CERT_LIST: + p_dis_rsp->content.cert_list.p_list = (uint8_t *) p_response->data; + p_dis_rsp->content.cert_list.list_len = p_response->len; + break; + + case BLE_DIS_C_PNP_ID: + err_code = pnp_id_decode(p_response->data, + p_response->len, + &p_dis_rsp->content.pnp_id); + if ((p_ble_dis_c->error_handler != NULL) && (err_code != NRF_SUCCESS)) + { + p_ble_dis_c->error_handler(err_code); + } + break; + + default: + break; + } + + p_ble_dis_c->evt_handler(p_ble_dis_c, &ble_dis_c_evt); + NRF_LOG_DEBUG("Received correct read response."); + } + else // Generate error event. + { + ble_dis_c_evt.evt_type = BLE_DIS_C_EVT_DIS_C_READ_RSP_ERROR; + + ble_dis_c_evt.params.read_rsp_err.char_type = char_type; + ble_dis_c_evt.params.read_rsp_err.err_handle = p_ble_evt->evt.gattc_evt.error_handle; + ble_dis_c_evt.params.read_rsp_err.gatt_status = p_ble_evt->evt.gattc_evt.gatt_status; + + p_ble_dis_c->evt_handler(p_ble_dis_c, &ble_dis_c_evt); + NRF_LOG_ERROR("Read request failed: 0x%04X.", p_ble_evt->evt.gattc_evt.gatt_status); + } + } +} + + +/**@brief Function for handling Disconnected event received from the SoftDevice. + * + * @details This function checks if the disconnect event is happening on the link + * associated with the current instance of the module. If so, it will set its + * conn_handle to invalid. + * + * @param[in] p_ble_dis_c Pointer to the Device Information Client Structure. + * @param[in] p_ble_evt Pointer to the BLE event received. + */ +static void on_disconnected(ble_dis_c_t * p_ble_dis_c, const ble_evt_t * p_ble_evt) +{ + if (p_ble_dis_c->conn_handle == p_ble_evt->evt.gap_evt.conn_handle) + { + p_ble_dis_c->conn_handle = BLE_CONN_HANDLE_INVALID; + + if (p_ble_dis_c->evt_handler != NULL) + { + ble_dis_c_evt_t dis_c_evt = + { + .evt_type = BLE_DIS_C_EVT_DISCONNECTED, + .conn_handle = p_ble_evt->evt.gap_evt.conn_handle + }; + + p_ble_dis_c->evt_handler(p_ble_dis_c, &dis_c_evt); + } + } +} + + +ret_code_t ble_dis_c_init(ble_dis_c_t * p_ble_dis_c, ble_dis_c_init_t * p_ble_dis_c_init) +{ + ble_uuid_t dis_uuid; + + VERIFY_PARAM_NOT_NULL(p_ble_dis_c); + VERIFY_PARAM_NOT_NULL(p_ble_dis_c_init); + + dis_uuid.type = BLE_UUID_TYPE_BLE; + dis_uuid.uuid = BLE_UUID_DEVICE_INFORMATION_SERVICE; + + p_ble_dis_c->conn_handle = BLE_CONN_HANDLE_INVALID; + p_ble_dis_c->p_gatt_queue = p_ble_dis_c_init->p_gatt_queue; + p_ble_dis_c->evt_handler = p_ble_dis_c_init->evt_handler; + p_ble_dis_c->error_handler = p_ble_dis_c_init->error_handler; + memset(p_ble_dis_c->handles, BLE_GATT_HANDLE_INVALID, sizeof(p_ble_dis_c->handles)); + + // Enable only selected characteristics if characteristic group is defined. + if (p_ble_dis_c_init->char_group.p_char_type != NULL) + { + p_ble_dis_c->char_mask = BLE_DIS_C_ALL_CHARS_DISABLED_MASK; + + for (uint8_t i = 0; i < p_ble_dis_c_init->char_group.size; i++) + { + nrf_bitmask_bit_set(p_ble_dis_c_init->char_group.p_char_type[i], + &p_ble_dis_c->char_mask); + } + } + else + { + p_ble_dis_c->char_mask = BLE_DIS_C_ALL_CHARS_ENABLED_MASK; + } + + return ble_db_discovery_evt_register(&dis_uuid); +} + + +void ble_dis_c_on_db_disc_evt(ble_dis_c_t * p_ble_dis_c, ble_db_discovery_evt_t * p_evt) +{ + ble_gatt_db_char_t * p_chars = p_evt->params.discovered_db.charateristics; + ble_dis_c_evt_t ble_dis_c_evt; + + // Check if the service discovery is necessary for the link and if the event handler is present. + if ((p_ble_dis_c->evt_handler == NULL) || + (p_ble_dis_c->conn_handle == p_evt->conn_handle)) + { + return; + } + + // Check if the DIS was discovered. + if ((p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE) && + (p_evt->params.discovered_db.srv_uuid.uuid == BLE_UUID_DEVICE_INFORMATION_SERVICE) && + (p_evt->params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE)) + { + memset(&ble_dis_c_evt, 0, sizeof(ble_dis_c_evt_t)); + ble_dis_c_evt.evt_type = BLE_DIS_C_EVT_DISCOVERY_COMPLETE; + ble_dis_c_evt.conn_handle = p_evt->conn_handle; + + for (uint32_t i = 0; i < p_evt->params.discovered_db.char_count; i++) + { + switch (p_chars[i].characteristic.uuid.uuid) + { + case BLE_UUID_MANUFACTURER_NAME_STRING_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_MANUF_NAME] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_MODEL_NUMBER_STRING_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_MODEL_NUM] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_SERIAL_NUMBER_STRING_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_SERIAL_NUM] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_HARDWARE_REVISION_STRING_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_HW_REV] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_FIRMWARE_REVISION_STRING_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_FW_REV] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_SOFTWARE_REVISION_STRING_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_SW_REV] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_SYSTEM_ID_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_SYS_ID] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_CERT_LIST] = + p_chars[i].characteristic.handle_value; + break; + + case BLE_UUID_PNP_ID_CHAR: + ble_dis_c_evt.params.disc_complete.handles[BLE_DIS_C_PNP_ID] = + p_chars[i].characteristic.handle_value; + break; + + default: + break; + } + } + + // Forget handle values for disabled characteristics + for (ble_dis_c_char_type_t char_type = (ble_dis_c_char_type_t) 0; + char_type < BLE_DIS_C_CHAR_TYPES_NUM; + char_type++) + { + if (!nrf_bitmask_bit_is_set(char_type, &p_ble_dis_c->char_mask)) + { + ble_dis_c_evt.params.disc_complete.handles[char_type] = BLE_GATT_HANDLE_INVALID; + } + } + + p_ble_dis_c->evt_handler(p_ble_dis_c, &ble_dis_c_evt); + } +} + + +void ble_dis_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) +{ + ble_dis_c_t * p_ble_dis_c = (ble_dis_c_t *) p_context; + + if ((p_ble_dis_c == NULL) || (p_ble_evt == NULL)) + { + return; + } + + if (p_ble_dis_c->conn_handle == BLE_CONN_HANDLE_INVALID) + { + return; + } + + switch (p_ble_evt->header.evt_id) + { + case BLE_GATTC_EVT_READ_RSP: + on_read_rsp(p_ble_dis_c, p_ble_evt); + break; + + case BLE_GAP_EVT_DISCONNECTED: + on_disconnected(p_ble_dis_c, p_ble_evt); + break; + + default: + // No implementation needed. + break; + } +} + + +ret_code_t ble_dis_c_read(ble_dis_c_t * p_ble_dis_c, ble_dis_c_char_type_t char_type) +{ + ret_code_t err_code; + nrf_ble_gq_req_t dis_c_req; + + VERIFY_PARAM_NOT_NULL(p_ble_dis_c); + VERIFY_TRUE(char_type < BLE_DIS_C_CHAR_TYPES_NUM, NRF_ERROR_INVALID_PARAM); + + if ((p_ble_dis_c->conn_handle == BLE_CONN_HANDLE_INVALID) || + (p_ble_dis_c->handles[char_type] == BLE_GATT_HANDLE_INVALID)) + { + return NRF_ERROR_INVALID_STATE; + } + + memset(&dis_c_req, 0, sizeof(dis_c_req)); + dis_c_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + dis_c_req.error_handler.cb = gatt_error_handler; + dis_c_req.error_handler.p_ctx = p_ble_dis_c; + dis_c_req.params.gattc_read.handle = p_ble_dis_c->handles[char_type]; + + err_code = nrf_ble_gq_item_add(p_ble_dis_c->p_gatt_queue, &dis_c_req, p_ble_dis_c->conn_handle); + return err_code; +} + + +ret_code_t ble_dis_c_handles_assign(ble_dis_c_t * p_ble_dis_c, + uint16_t conn_handle, + ble_dis_c_handle_t const * p_peer_handles) +{ + VERIFY_PARAM_NOT_NULL(p_ble_dis_c); + + p_ble_dis_c->conn_handle = conn_handle; + if (p_peer_handles != NULL) + { + memcpy(p_ble_dis_c->handles, p_peer_handles, sizeof(p_ble_dis_c->handles)); + } + else + { + memset(p_ble_dis_c->handles, BLE_GATT_HANDLE_INVALID, sizeof(p_ble_dis_c->handles)); + } + return nrf_ble_gq_conn_handle_register(p_ble_dis_c->p_gatt_queue, conn_handle); +} + + +#endif // NRF_MODULE_ENABLED(BLE_DIS_C) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.h new file mode 100644 index 0000000..1a1b243 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_dis_c/ble_dis_c.h @@ -0,0 +1,311 @@ +/** + * Copyright (c) 2017 - 2019, 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 ble_dis_c Device Information Service Client + * @{ + * @ingroup ble_sdk_srv + * @brief Device information Service Client module. + * + * @details This module contains the APIs and types exposed by the Device information Service Client + * module. These APIs and types can be used by the application to perform discovery of + * the Device information Service at the peer and interact with it. + * + * @note The application must register this module as BLE event observer using the + * NRF_SDH_BLE_OBSERVER macro. Example: + * @code + * ble_dis_c_t instance; + * NRF_SDH_BLE_OBSERVER(anything, BLE_DIS_C_BLE_OBSERVER_PRIO, + * ble_dis_c_on_ble_evt, &instance); + * @endcode + * + */ + + +#ifndef BLE_DIS_C_H__ +#define BLE_DIS_C_H__ + +#include +#include +#include "ble.h" +#include "ble_gatt.h" +#include "ble_db_discovery.h" +#include "ble_srv_common.h" +#include "ble_dis.h" +#include "nrf_ble_gq.h" +#include "nrf_sdh_ble.h" + +#include "sdk_config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Macro for defining a ble_dis_c instance. + * + * @param _name Name of the instance. + * @hideinitializer + */ +#define BLE_DIS_C_DEF(_name) \ + static ble_dis_c_t _name; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_DIS_C_BLE_OBSERVER_PRIO, \ + ble_dis_c_on_ble_evt, &_name) + +/** @brief Macro for defining multiple ble_dis_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_DIS_C_ARRAY_DEF(_name, _cnt) \ + static ble_dis_c_t _name[_cnt]; \ + NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_DIS_C_BLE_OBSERVER_PRIO, \ + ble_dis_c_on_ble_evt, &_name, _cnt) + + +/**@brief DIS Client event type. */ +typedef enum +{ + BLE_DIS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the DIS and its characteristics were discovered. See @ref ble_dis_c_evt_disc_complete_t. */ + BLE_DIS_C_EVT_DIS_C_READ_RSP, /**< Event indicating that the client has received a read response from a peer. See @ref ble_dis_c_evt_read_rsp_t. */ + BLE_DIS_C_EVT_DIS_C_READ_RSP_ERROR, /**< Event indicating that the client's read request has failed. See @ref ble_dis_c_evt_read_rsp_err_t. */ + BLE_DIS_C_EVT_DISCONNECTED /**< Event indicating that the DIS server has disconnected. */ +} ble_dis_c_evt_type_t; + +/**@brief DIS Client characteristic type. */ +typedef enum +{ + BLE_DIS_C_MANUF_NAME, /**< Manufacturer Name String characteristic. */ + BLE_DIS_C_MODEL_NUM, /**< Model Number String characteristic. */ + BLE_DIS_C_SERIAL_NUM, /**< Serial Number String characteristic. */ + BLE_DIS_C_HW_REV, /**< Hardware Revision String characteristic. */ + BLE_DIS_C_FW_REV, /**< Firmware Revision String characteristic. */ + BLE_DIS_C_SW_REV, /**< Software Revision String characteristic. */ + BLE_DIS_C_SYS_ID, /**< System ID characteristic. */ + BLE_DIS_C_CERT_LIST, /**< IEEE 11073-20601 Regulatory Certification Data List characteristic. */ + BLE_DIS_C_PNP_ID, /**< PnP ID characteristic. */ + BLE_DIS_C_CHAR_TYPES_NUM /**< Number of all possible characteristic types. */ +} ble_dis_c_char_type_t; + +/**@brief Attribute handle pointing to DIS characteristics on the connected peer device. */ +typedef uint16_t ble_dis_c_handle_t; + +/**@brief Event structure for @ref BLE_DIS_C_EVT_DISCOVERY_COMPLETE. */ +typedef struct +{ + ble_dis_c_handle_t handles[BLE_DIS_C_CHAR_TYPES_NUM]; /**< Handles on the connected peer device needed to interact with it. */ +} ble_dis_c_evt_disc_complete_t; + +/**@brief Response data for string-based DIS characteristics. */ +typedef struct +{ + uint8_t * p_data; /**< Pointer to response data. */ + uint8_t len; /**< Response data length. */ +} ble_dis_c_string_t; + +/**@brief Event structure for @ref BLE_DIS_C_EVT_DIS_C_READ_RSP. */ +typedef struct +{ + ble_dis_c_char_type_t char_type; /**< Characteristic type. */ + ble_dis_c_handle_t handle; /**< Attribute handle from the response event. */ + union + { + ble_dis_c_string_t string; /**< String-based characteristics response data. Filled when char_type is in the following range: @ref BLE_DIS_C_MANUF_NAME - @ref BLE_DIS_C_SW_REV (inclusive). */ + ble_dis_sys_id_t sys_id; /**< System ID characteristic response data. Filled when char_type is @ref BLE_DIS_C_SYS_ID. */ + ble_dis_reg_cert_data_list_t cert_list; /**< IEEE 11073-20601 Regulatory Certification Data List characteristic response data. Filled when char_type is @ref BLE_DIS_C_CERT_LIST. */ + ble_dis_pnp_id_t pnp_id; /**< PnP ID characteristic response data. Filled when char_type is @ref BLE_DIS_C_PNP_ID. */ + } content; +} ble_dis_c_evt_read_rsp_t; + +/**@brief Event structure for @ref BLE_DIS_C_EVT_DIS_C_READ_RSP_ERROR. */ +typedef struct +{ + ble_dis_c_char_type_t char_type; /**< Characteristic type. */ + ble_dis_c_handle_t err_handle; /**< Attribute handle from the response event. */ + uint16_t gatt_status; /**< GATT status code for the read operation, see @ref BLE_GATT_STATUS_CODES. */ +} ble_dis_c_evt_read_rsp_err_t; + +/**@brief Structure containing the DIS event data received from the peer. */ +typedef struct +{ + ble_dis_c_evt_type_t evt_type; /**< Type of the event. */ + uint16_t conn_handle; /**< Connection handle on which the @ref ble_dis_c_evt_t event occurred.*/ + union + { + ble_dis_c_evt_disc_complete_t disc_complete; /**< Discovery Complete Event Parameters. Filled when evt_type is @ref BLE_DIS_C_EVT_DISCOVERY_COMPLETE. */ + ble_dis_c_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. Filled when evt_type is @ref BLE_DIS_C_EVT_DIS_C_READ_RSP. */ + ble_dis_c_evt_read_rsp_err_t read_rsp_err; /**< Read Response Error Event Parameters. Filled when evt_type is @ref BLE_DIS_C_EVT_DIS_C_READ_RSP_ERROR. */ + } params; +} ble_dis_c_evt_t; + +// Forward declaration of the ble_dis_t type. +typedef struct ble_dis_c_s ble_dis_c_t; + +/**@brief Event handler type. + * + * @details This is the type of the event handler that should be provided by the application + * of this module to receive events. + */ +typedef void (* ble_dis_c_evt_handler_t)(ble_dis_c_t * p_ble_dis_c, ble_dis_c_evt_t const * p_evt); + +/**@brief DIS Client structure. */ +struct ble_dis_c_s +{ + uint16_t conn_handle; /**< Handle of the current connection. Set with @ref ble_dis_c_handles_assign when connected. */ + uint16_t char_mask; /**< Mask with enabled DIS characteristics.*/ + ble_dis_c_handle_t handles[BLE_DIS_C_CHAR_TYPES_NUM]; /**< Handles on the connected peer device needed to interact with it. */ + ble_srv_error_handler_t error_handler; /**< Application error handler to be called in case of an error. */ + ble_dis_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the DIS. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ +}; + +/**@brief Structure describing the group of DIS characteristics with which this module can interact. */ +typedef struct +{ + ble_dis_c_char_type_t * p_char_type; /**< Pointer to array with selected characteristics. */ + uint8_t size; /**< Group size. */ +} ble_dis_c_char_group_t; + +/**@brief DIS Client initialization structure. */ +typedef struct +{ + ble_dis_c_char_group_t char_group; /**< Group of DIS characteristics that should be enabled for this module instance. */ + ble_srv_error_handler_t error_handler; /**< Application error handler to be called in case of an error. */ + ble_dis_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the Device Information service. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ +} ble_dis_c_init_t; + + +/**@brief Function for initializing the Device Information service client module. + * + * @details This function registers with the Database Discovery module + * for the DIS. Doing so will make the Database Discovery + * module look for the presence of a DIS instance at the peer when a + * discovery is started. + * + * @param[in] p_ble_dis_c Pointer to the DIS client structure. + * @param[in] p_ble_dis_c_init Pointer to the DIS initialization structure containing the + * initialization information. + * + * @retval NRF_SUCCESS If the module was initialized successfully. + * @retval NRF_ERROR_NULL Any parameter is NULL. + * @return If functions from other modules return errors to this function + * (@ref ble_db_discovery_evt_register), the @ref nrf_error are propagated. + */ +ret_code_t ble_dis_c_init(ble_dis_c_t * p_ble_dis_c, ble_dis_c_init_t * p_ble_dis_c_init); + + +/**@brief Function for handling events from the database discovery module. + * + * @details This function will handle an event from the database discovery module, and determine + * if it relates to the discovery of DIS at the peer. If so, it will + * call the application's event handler indicating that DIS has been + * discovered at the peer. It also populates the event with the service related + * information before providing it to the application. + * + * @param[in] p_ble_dis_c Pointer to the DIS client structure. + * @param[in] p_evt Pointer to the event received from the database discovery module. + */ +void ble_dis_c_on_db_disc_evt(ble_dis_c_t * p_ble_dis_c, ble_db_discovery_evt_t * p_evt); + + +/**@brief Function for handling BLE events from the SoftDevice. + * + * @details This function handles the BLE events received from the SoftDevice. If a BLE + * event is relevant to the DIS module, it is used to update internal variables + * and, if necessary, send events to the application. + * + * @param[in] p_ble_evt Pointer to the BLE event. + * @param[in] p_context Pointer to the DIS client structure. + */ +void ble_dis_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); + + +/**@brief Function for reading different characteristics from DIS. + * + * @details This function can be used to read different characteristics that are available + * inside DIS. The response data will be provided from the response event + * @ref BLE_DIS_C_EVT_DIS_C_READ_RSP. The @ref BLE_DIS_C_EVT_DIS_C_READ_RSP_ERROR + * event can be generated if the read operation is unsuccessful. + * + * @param[in] p_ble_dis_c Pointer to the DIS client structure. + * @param[in] char_type Type of characteristic to read. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_NULL If a \p p_ble_dis_c was a NULL pointer. + * @retval NRF_ERROR_INVALID_PARAM If a \p char_type is not valid. + * @retval NRF_ERROR_INVALID_STATE If connection handle or attribute handle is invalid. + * @retval NRF_ERROR_NO_MEM If the client request queue is full. + */ +ret_code_t ble_dis_c_read(ble_dis_c_t * p_ble_dis_c, ble_dis_c_char_type_t char_type); + + +/**@brief Function for assigning handles to this instance of dis_c. + * + * @details Call this function when a link has been established with a peer to + * associate this link to this instance of the module. This makes it + * possible to handle several links and associate each link to a particular + * instance of this module. The connection handle and attribute handles will be + * provided from the discovery event @ref BLE_DIS_C_EVT_DISCOVERY_COMPLETE. + * + * @param[in] p_ble_dis_c Pointer to the DIS client structure instance to associate with these + * handles. + * @param[in] conn_handle Connection handle associated with the given DIS Instance. + * @param[in] p_peer_handles Attribute handles on the DIS server that you want this DIS client to + * interact with. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_NULL If a \p p_ble_dis_c was a NULL pointer. + */ +ret_code_t ble_dis_c_handles_assign(ble_dis_c_t * p_ble_dis_c, + uint16_t conn_handle, + ble_dis_c_handle_t const * p_peer_handles); + + +#ifdef __cplusplus +} +#endif + +#endif // BLE_DIS_C_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/escs_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/escs_defs.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/escs_defs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/escs_defs.h index 0c93da4..10763b1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/escs_defs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/escs_defs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ESCS_DEFS_H__ #define ESCS_DEFS_H__ @@ -59,6 +59,8 @@ #define ESCS_EID_WRITE_ENC_ID_KEY_INDEX (1) #define ESCS_EID_WRITE_IDK_LENGTH (18) +#define ESCS_LOCK_STATE_READ_LENGTH (1) + #define ESCS_URL_MIN_WRITE_LENGTH (4) #define ESCS_URL_WRITE_LENGTH (19) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/nrf_ble_escs.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/nrf_ble_escs.c similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/nrf_ble_escs.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/nrf_ble_escs.c index df03fe7..64c51cb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/nrf_ble_escs.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/nrf_ble_escs.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_ble_escs.h" #include @@ -50,179 +50,196 @@ #define EID_BUFF_SIZE 64 -typedef struct -{ - uint16_t uuid; - uint8_t read:1; - uint8_t write:1; - uint8_t rd_auth:1; - uint8_t wr_auth:1; - uint8_t vlen:1; - uint8_t vloc:2; - uint8_t init_len; - uint8_t max_len; -} char_init_t; - typedef struct { uint16_t val_handle; uint16_t uuid; } val_handle_to_uuid_t; -static const char_init_t BROADCAST_CAP_CHAR_INIT = +static ble_add_char_params_t BROADCAST_CAP_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_BROADCAST_CAP_CHAR, - .read = 1, - .write = 0, - .rd_auth = 1, - .wr_auth = 0, - .vlen = 1, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = NRF_BLE_ESCS_BROADCAST_CAP_LEN, - .max_len = NRF_BLE_ESCS_BROADCAST_CAP_LEN + .uuid = BLE_UUID_ESCS_BROADCAST_CAP_CHAR, + .read_access = SEC_OPEN, + .char_props = + { + .read = 1, + }, + .is_defered_read = true, + .is_var_len = true, + .init_len = NRF_BLE_ESCS_BROADCAST_CAP_LEN, + .max_len = NRF_BLE_ESCS_BROADCAST_CAP_LEN, }; -static const char_init_t ACTIVE_SLOT_CHAR_INIT = +static ble_add_char_params_t ACTIVE_SLOT_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_ACTIVE_SLOT_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_USER, - .init_len = sizeof(nrf_ble_escs_active_slot_t), - .max_len = sizeof(nrf_ble_escs_active_slot_t) + .uuid = BLE_UUID_ESCS_ACTIVE_SLOT_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .is_value_user = true, + .init_len = sizeof(nrf_ble_escs_active_slot_t), + .max_len = sizeof(nrf_ble_escs_active_slot_t), }; -static const char_init_t ADV_INTERVAL_CHAR_INIT = +static ble_add_char_params_t ADV_INTERVAL_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_ADV_INTERVAL_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = sizeof(nrf_ble_escs_adv_interval_t), - .max_len = sizeof(nrf_ble_escs_adv_interval_t) + .uuid = BLE_UUID_ESCS_ADV_INTERVAL_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .init_len = sizeof(nrf_ble_escs_adv_interval_t), + .max_len = sizeof(nrf_ble_escs_adv_interval_t), }; -static const char_init_t RADIO_TX_PWR_CHAR_INIT = +static ble_add_char_params_t RADIO_TX_PWR_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_RADIO_TX_PWR_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = sizeof(nrf_ble_escs_radio_tx_pwr_t), - .max_len = sizeof(nrf_ble_escs_radio_tx_pwr_t) + .uuid = BLE_UUID_ESCS_RADIO_TX_PWR_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .init_len = sizeof(nrf_ble_escs_radio_tx_pwr_t), + .max_len = sizeof(nrf_ble_escs_radio_tx_pwr_t), }; -static const char_init_t ADV_TX_PWR_CHAR_INIT = +static ble_add_char_params_t ADV_TX_PWR_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_ADV_TX_PWR_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = sizeof(nrf_ble_escs_adv_tx_pwr_t), - .max_len = sizeof(nrf_ble_escs_adv_tx_pwr_t) + .uuid = BLE_UUID_ESCS_ADV_TX_PWR_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .init_len = sizeof(nrf_ble_escs_adv_tx_pwr_t), + .max_len = sizeof(nrf_ble_escs_adv_tx_pwr_t), }; -static const char_init_t LOCK_STATE_CHAR_INIT = +static ble_add_char_params_t LOCK_STATE_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_LOCK_STATE_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 1, - .vloc = BLE_GATTS_VLOC_USER, - .init_len = 1, - .max_len = 17 + .uuid = BLE_UUID_ESCS_LOCK_STATE_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .is_var_len = true, + .is_value_user = true, + .init_len = 1, + .max_len = 17, }; -static const char_init_t UNLOCK_CHAR_INIT = +static ble_add_char_params_t UNLOCK_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_UNLOCK_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = 1, - .max_len = ESCS_AES_KEY_SIZE + .uuid = BLE_UUID_ESCS_UNLOCK_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .init_len = 1, + .max_len = ESCS_AES_KEY_SIZE, }; -static const char_init_t PUBLIC_ECDH_KEY_CHAR_INIT = +static ble_add_char_params_t PUBLIC_ECDH_KEY_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_PUBLIC_ECDH_KEY_CHAR, - .read = 1, - .write = 0, - .rd_auth = 1, - .wr_auth = 0, - .vlen = 1, - .init_len = 1, - .vloc = BLE_GATTS_VLOC_STACK, - .max_len = ESCS_ECDH_KEY_SIZE + .uuid = BLE_UUID_ESCS_PUBLIC_ECDH_KEY_CHAR, + .read_access = SEC_OPEN, + .char_props = + { + .read = 1, + }, + .is_defered_read = true, + .is_var_len = true, + .init_len = 1, + .max_len = ESCS_ECDH_KEY_SIZE, }; -static const char_init_t EID_ID_KEY_CHAR_INIT = +static ble_add_char_params_t EID_ID_KEY_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_EID_ID_KEY_CHAR, - .read = 1, - .write = 0, - .rd_auth = 1, - .wr_auth = 0, - .vlen = 1, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = 1, - .max_len = ESCS_AES_KEY_SIZE + .uuid = BLE_UUID_ESCS_EID_ID_KEY_CHAR, + .read_access = SEC_OPEN, + .char_props = + { + .read = 1, + }, + .is_defered_read = true, + .is_var_len = true, + .init_len = 1, + .max_len = ESCS_AES_KEY_SIZE, }; -static const char_init_t RW_ADV_SLOT_CHAR_INIT = +static ble_add_char_params_t RW_ADV_SLOT_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_RW_ADV_SLOT_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 1, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = 0, - .max_len = ESCS_ADV_SLOT_CHAR_LENGTH_MAX + .uuid = BLE_UUID_ESCS_RW_ADV_SLOT_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .is_var_len = true, + .max_len = ESCS_ADV_SLOT_CHAR_LENGTH_MAX, }; -static const char_init_t FACTORY_RESET_CHAR_INIT = +static ble_add_char_params_t FACTORY_RESET_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_FACTORY_RESET_CHAR, - .read = 0, - .write = 1, - .rd_auth = 0, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = sizeof(nrf_ble_escs_factory_reset_t), - .max_len = sizeof(nrf_ble_escs_factory_reset_t) + .uuid = BLE_UUID_ESCS_FACTORY_RESET_CHAR, + .write_access = SEC_OPEN, + .char_props = + { + .write = 1, + }, + .is_defered_write = true, + .init_len = sizeof(nrf_ble_escs_factory_reset_t), + .max_len = sizeof(nrf_ble_escs_factory_reset_t), }; -static const char_init_t REMAIN_CONNECTABLE_CHAR_INIT = +static ble_add_char_params_t REMAIN_CONNECTABLE_CHAR_INIT = { - .uuid = BLE_UUID_ESCS_REMAIN_CONNECTABLE_CHAR, - .read = 1, - .write = 1, - .rd_auth = 1, - .wr_auth = 1, - .vlen = 0, - .vloc = BLE_GATTS_VLOC_STACK, - .init_len = 1, - .max_len = 1 + .uuid = BLE_UUID_ESCS_REMAIN_CONNECTABLE_CHAR, + .read_access = SEC_OPEN, + .write_access = SEC_OPEN, + .char_props = + { + .read = 1, + .write = 1, + }, + .is_defered_read = true, + .is_defered_write = true, + .init_len = 1, + .max_len = 1, }; static val_handle_to_uuid_t m_handle_to_uuid_map[BLE_ESCS_NUMBER_OF_CHARACTERISTICS]; //!< Map from handle to UUID. @@ -244,67 +261,24 @@ static ble_user_mem_block_t m_eid_mem_block = * * @return NRF_SUCCESS on success, otherwise an error code. */ -static uint32_t char_add(const char_init_t * p_char_init, +static uint32_t char_add(ble_add_char_params_t * p_char_init, nrf_ble_escs_t * p_escs, void * p_value, ble_gatts_char_handles_t * p_handles) { uint32_t err_code; - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; VERIFY_PARAM_NOT_NULL(p_char_init); VERIFY_PARAM_NOT_NULL(p_escs); VERIFY_PARAM_NOT_NULL(p_value); VERIFY_PARAM_NOT_NULL(p_handles); - memset(&char_md, 0, sizeof(char_md)); - memset(&attr_char_value, 0, sizeof(attr_char_value)); - memset(&ble_uuid, 0, sizeof(ble_uuid)); - memset(&attr_md, 0, sizeof(attr_md)); - - if (p_char_init->read) - { - char_md.char_props.read = 1; - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - } - - else - { - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - } - - if (p_char_init->write) - { - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); - char_md.char_props.write = 1; - } - - else - { - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - } - - ble_uuid.type = p_escs->uuid_type; - ble_uuid.uuid = p_char_init->uuid; - - attr_md.vloc = p_char_init->vloc; - attr_md.rd_auth = p_char_init->rd_auth; - attr_md.wr_auth = p_char_init->wr_auth; - attr_md.vlen = p_char_init->vlen; + p_char_init->uuid_type = p_escs->uuid_type; + p_char_init->p_init_value = p_value; - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = p_char_init->init_len; - attr_char_value.p_value = p_value; - attr_char_value.max_len = p_char_init->max_len; - - err_code = sd_ble_gatts_characteristic_add(p_escs->service_handle, - &char_md, - &attr_char_value, - p_handles); + err_code = characteristic_add(p_escs->service_handle, + p_char_init, + p_handles); if (err_code == NRF_SUCCESS) { @@ -515,6 +489,17 @@ static ret_code_t on_rw_authorize_req(nrf_ble_escs_t * p_escs, ble_evt_t const * { on_long_write(p_escs, p_ble_evt); } + else if (ar->request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL) + { + ble_gatts_rw_authorize_reply_params_t auth_reply; + memset(&auth_reply, 0, sizeof(auth_reply)); + + auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; + + err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gatts_evt.conn_handle, &auth_reply); + VERIFY_SUCCESS(err_code); + } else { } @@ -632,7 +617,7 @@ ret_code_t nrf_ble_escs_init(nrf_ble_escs_t * p_escs, const nrf_ble_escs_init_t VERIFY_SUCCESS(err_code); err_code = char_add(&LOCK_STATE_CHAR_INIT, p_escs, - p_escs->p_lock_state, &p_escs->lock_state_handles); + &p_escs->lock_state, &p_escs->lock_state_handles); VERIFY_SUCCESS(err_code); err_code = char_add(&UNLOCK_CHAR_INIT, p_escs, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/nrf_ble_escs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/nrf_ble_escs.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/nrf_ble_escs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/nrf_ble_escs.h index 15a702b..071af45 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_escs/nrf_ble_escs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_escs/nrf_ble_escs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_BLE_ESCS_H__ #define NRF_BLE_ESCS_H__ @@ -175,8 +175,6 @@ typedef struct nrf_ble_escs_adv_tx_pwr_t adv_tx_pwr; nrf_ble_escs_factory_reset_t factory_reset; nrf_ble_escs_remain_conntbl_t remain_connectable; - - } nrf_ble_escs_init_params_t; // Forward Declaration of nrf_ble_escs_t type. @@ -225,7 +223,7 @@ struct nrf_ble_escs_s nrf_ble_escs_write_evt_handler_t write_evt_handler; //!< Event handler to be called for handling write attempts. nrf_ble_escs_read_evt_handler_t read_evt_handler; //!< Event handler to be called for handling read attempts. uint8_t * p_active_slot; - nrf_ble_escs_lock_state_read_t * p_lock_state; + uint8_t lock_state; }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.c similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.c index e6d46a8..0cc7b19 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -53,45 +53,44 @@ #include "ble_srv_common.h" -#define OPERAND_FILTER_TYPE_SEQ_NUM 0x01 /**< Filter data using Sequence Number criteria. */ -#define OPERAND_FILTER_TYPE_FACING_TIME 0x02 /**< Filter data using User Facing Time criteria. */ -#define OPERAND_FILTER_TYPE_RFU_START 0x07 /**< Start of filter types reserved For Future Use range */ -#define OPERAND_FILTER_TYPE_RFU_END 0xFF /**< End of filter types reserved For Future Use range */ +#define OPERAND_FILTER_TYPE_SEQ_NUM 0x01 /**< Filter data using Sequence Number criteria. */ +#define OPERAND_FILTER_TYPE_FACING_TIME 0x02 /**< Filter data using User Facing Time criteria. */ +#define OPERAND_FILTER_TYPE_RFU_START 0x07 /**< Start of filter types reserved For Future Use range */ +#define OPERAND_FILTER_TYPE_RFU_END 0xFF /**< End of filter types reserved For Future Use range */ -#define OPCODE_LENGTH 1 /**< Length of opcode inside Glucose Measurement packet. */ -#define HANDLE_LENGTH 2 /**< Length of handle inside Glucose Measurement packet. */ -#define MAX_GLM_LEN (BLE_GATT_ATT_MTU_DEFAULT - OPCODE_LENGTH - HANDLE_LENGTH) /**< Maximum size of a transmitted Glucose Measurement. */ +#define OPCODE_LENGTH 1 /**< Length of opcode inside Glucose Measurement packet. */ +#define HANDLE_LENGTH 2 /**< Length of handle inside Glucose Measurement packet. */ +#define MAX_GLM_LEN (BLE_GATT_ATT_MTU_DEFAULT - OPCODE_LENGTH - \ + HANDLE_LENGTH) /**< Maximum size of a transmitted Glucose Measurement. */ +#define RACP_OPERAND_LEN 2 /**< Record Access Control Point operand length. */ -#define GLS_NACK_PROC_ALREADY_IN_PROGRESS BLE_GATT_STATUS_ATTERR_APP_BEGIN + 0 /**< Reply when a requested procedure is already in progress. */ -#define GLS_NACK_CCCD_IMPROPERLY_CONFIGURED BLE_GATT_STATUS_ATTERR_APP_BEGIN + 1 /**< Reply when the a s CCCD is improperly configured. */ +#define GLS_NACK_PROC_ALREADY_IN_PROGRESS BLE_GATT_STATUS_ATTERR_APP_BEGIN + 0 /**< Reply when a requested procedure is already in progress. */ +#define GLS_NACK_CCCD_IMPROPERLY_CONFIGURED BLE_GATT_STATUS_ATTERR_APP_BEGIN + 1 /**< Reply when the a s CCCD is improperly configured. */ -/**@brief Glucose Service communication state. */ -typedef enum -{ - STATE_NO_COMM, /**< The service is not in a communicating state. */ - STATE_RACP_PROC_ACTIVE, /**< Processing requested data. */ - STATE_RACP_RESPONSE_PENDING, /**< There is a RACP indication waiting to be sent. */ - STATE_RACP_RESPONSE_IND_VERIF /**< Waiting for a verification of a RACP indication. */ -} gls_state_t; - -static gls_state_t m_gls_state; /**< Current communication state. */ -static uint16_t m_next_seq_num; /**< Sequence number of the next database record. */ -static uint8_t m_racp_proc_operator; /**< Operator of current request. */ -static uint16_t m_racp_proc_seq_num; /**< Sequence number of current request. */ -static uint8_t m_racp_proc_record_ndx; /**< Current record index. */ -static uint8_t m_racp_proc_records_reported; /**< Number of reported records. */ -static uint8_t m_racp_proc_records_reported_since_txcomplete; /**< Number of reported records since last TX_COMPLETE event. */ -static ble_racp_value_t m_pending_racp_response; /**< RACP response to be sent. */ -static uint8_t m_pending_racp_response_operand[2]; /**< Operand of RACP response to be sent. */ - - -/**@brief Function for setting the GLS communication state. +static bool m_procesing_active; /**< Processing requested data. */ +static uint16_t m_next_seq_num; /**< Sequence number of the next database record. */ +static uint8_t m_racp_proc_operator; /**< Operator of current request. */ +static uint16_t m_racp_proc_seq_num; /**< Sequence number of current request. */ +static uint8_t m_racp_proc_record_ndx; /**< Current record index. */ +static uint8_t m_racp_proc_records_reported; /**< Number of reported records. */ + + +/**@brief Function for interception of GATT errors and @ref nrf_ble_gq errors. * - * @param[in] new_state New communication state. + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. */ -static void state_set(gls_state_t new_state) +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) { - m_gls_state = new_state; + ble_gls_t * p_gls = (ble_gls_t *)p_ctx; + + if ((p_gls->error_handler) != NULL && (nrf_error != NRF_ERROR_INVALID_STATE)) + { + p_gls->error_handler(nrf_error); + } } @@ -150,7 +149,7 @@ static uint8_t gls_meas_encode(const ble_gls_meas_t * p_meas, uint8_t * p_encode uint16_t encoded_concentration; encoded_concentration = ((p_meas->glucose_concentration.exponent << 12) & 0xF000) | - ((p_meas->glucose_concentration.mantissa << 0) & 0x0FFF); + ((p_meas->glucose_concentration.mantissa << 0) & 0x0FFF); p_encoded_buffer[len++] = (uint8_t)(encoded_concentration); p_encoded_buffer[len++] = (uint8_t)(encoded_concentration >> 8); @@ -166,191 +165,18 @@ static uint8_t gls_meas_encode(const ble_gls_meas_t * p_meas, uint8_t * p_encode } -/**@brief Function for adding the characteristic for a glucose measurement. - * - * @param[in] p_gls Service instance. - * - * @return NRF_SUCCESS if characteristic was successfully added, otherwise an error code. - */ -static uint32_t glucose_measurement_char_add(ble_gls_t * p_gls) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - ble_gls_rec_t initial_gls_rec_value; - uint8_t encoded_gls_meas[MAX_GLM_LEN]; - uint8_t num_recs; - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm); - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_GLUCOSE_MEASUREMENT_CHAR); - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - memset(&initial_gls_rec_value, 0, sizeof(initial_gls_rec_value)); - - num_recs = ble_gls_db_num_records_get(); - if (num_recs > 0) - { - uint32_t err_code = ble_gls_db_record_get(num_recs - 1, &initial_gls_rec_value); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = gls_meas_encode(&initial_gls_rec_value.meas, encoded_gls_meas); - attr_char_value.init_offs = 0; - attr_char_value.max_len = MAX_GLM_LEN; - attr_char_value.p_value = encoded_gls_meas; - - return sd_ble_gatts_characteristic_add(p_gls->service_handle, - &char_md, - &attr_char_value, - &p_gls->glm_handles); -} - - -/**@brief Function for adding the characteristic for a glucose feature. - * - * @param[in] p_gls Service instance. - * - * @return NRF_SUCCESS if characteristic was successfully added, otherwise an error code. - */ -static uint32_t glucose_feature_char_add(ble_gls_t * p_gls) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t encoded_initial_feature[2]; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_GLUCOSE_FEATURE_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - encoded_initial_feature[0] = (uint8_t)(p_gls->feature); - encoded_initial_feature[1] = (uint8_t)((p_gls->feature) >> 8); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (uint16_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint16_t); - attr_char_value.p_value = encoded_initial_feature; - - return sd_ble_gatts_characteristic_add(p_gls->service_handle, - &char_md, - &attr_char_value, - &p_gls->glf_handles); -} - - -/**@brief Function for adding the characteristic for a record access control point. - * - * @param[in] p_gls Service instance. - * - * @return NRF_SUCCESS if characteristic was successfully added, otherwise an error code. - */ -static uint32_t record_access_control_point_char_add(ble_gls_t * p_gls) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm); - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.indicate = 1; - char_md.char_props.write = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_RECORD_ACCESS_CONTROL_POINT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 1; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; - attr_char_value.init_offs = 0; - attr_char_value.max_len = BLE_GATT_ATT_MTU_DEFAULT; - attr_char_value.p_value = 0; - - return sd_ble_gatts_characteristic_add(p_gls->service_handle, - &char_md, - &attr_char_value, - &p_gls->racp_handles); -} - - uint32_t ble_gls_init(ble_gls_t * p_gls, const ble_gls_init_t * p_gls_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + VERIFY_PARAM_NOT_NULL(p_gls); + VERIFY_PARAM_NOT_NULL(p_gls_init); + VERIFY_PARAM_NOT_NULL(p_gls_init->p_gatt_queue); + + uint32_t err_code; + uint8_t num_recs; + uint8_t init_value_encoded[MAX_GLM_LEN]; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; + ble_gls_rec_t initial_gls_rec_value; // Initialize data base err_code = ble_gls_db_init(); @@ -371,37 +197,78 @@ uint32_t ble_gls_init(ble_gls_t * p_gls, const ble_gls_init_t * p_gls_init) p_gls->feature = p_gls_init->feature; p_gls->is_context_supported = p_gls_init->is_context_supported; p_gls->conn_handle = BLE_CONN_HANDLE_INVALID; - - - // Initialize global variables - state_set(STATE_NO_COMM); - m_racp_proc_records_reported_since_txcomplete = 0; + p_gls->p_gatt_queue = p_gls_init->p_gatt_queue; // Add service BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_GLUCOSE_SERVICE); - err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_gls->service_handle); + err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, + &ble_uuid, + &p_gls->service_handle); if (err_code != NRF_SUCCESS) { return err_code; } // Add glucose measurement characteristic - err_code = glucose_measurement_char_add(p_gls); + memset(&add_char_params, 0, sizeof(add_char_params)); + memset(&initial_gls_rec_value, 0, sizeof(initial_gls_rec_value)); + + num_recs = ble_gls_db_num_records_get(); + if (num_recs > 0) + { + err_code = ble_gls_db_record_get(num_recs - 1, &initial_gls_rec_value); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + add_char_params.uuid = BLE_UUID_GLUCOSE_MEASUREMENT_CHAR; + add_char_params.max_len = MAX_GLM_LEN; + add_char_params.init_len = gls_meas_encode(&initial_gls_rec_value.meas, + init_value_encoded); + add_char_params.is_var_len = true; + add_char_params.char_props.notify = 1; + add_char_params.cccd_write_access = p_gls_init->gl_meas_cccd_wr_sec; + add_char_params.p_init_value = init_value_encoded; + + err_code = characteristic_add(p_gls->service_handle, &add_char_params, &p_gls->glm_handles); if (err_code != NRF_SUCCESS) { return err_code; } // Add glucose measurement feature characteristic - err_code = glucose_feature_char_add(p_gls); + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_GLUCOSE_FEATURE_CHAR; + add_char_params.max_len = sizeof(uint16_t); + add_char_params.init_len = uint16_encode(p_gls->feature, init_value_encoded); + add_char_params.p_init_value = init_value_encoded; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_gls_init->gl_feature_rd_sec; + + err_code = characteristic_add(p_gls->service_handle, &add_char_params, &p_gls->glf_handles); if (err_code != NRF_SUCCESS) { return err_code; } // Add record control access point characteristic - err_code = record_access_control_point_char_add(p_gls); + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_RECORD_ACCESS_CONTROL_POINT_CHAR; + add_char_params.max_len = BLE_GATT_ATT_MTU_DEFAULT; + add_char_params.is_var_len = true; + add_char_params.char_props.indicate = 1; + add_char_params.char_props.write = 1; + add_char_params.cccd_write_access = p_gls_init->racp_cccd_wr_sec; + add_char_params.write_access = p_gls_init->racp_wr_sec; + add_char_params.is_defered_write = true; + + err_code = characteristic_add(p_gls->service_handle, + &add_char_params, + &p_gls->racp_handles); if (err_code != NRF_SUCCESS) { return err_code; @@ -418,69 +285,38 @@ uint32_t ble_gls_init(ble_gls_t * p_gls, const ble_gls_init_t * p_gls_init) */ static void racp_send(ble_gls_t * p_gls, ble_racp_value_t * p_racp_val) { - uint32_t err_code; - uint8_t encoded_resp[25]; - uint8_t len; - uint16_t hvx_len; - ble_gatts_hvx_params_t hvx_params; - - if ( - (m_gls_state != STATE_RACP_RESPONSE_PENDING) - && - (m_racp_proc_records_reported_since_txcomplete > 0) - ) - { - state_set(STATE_RACP_RESPONSE_PENDING); - return; - } + uint32_t err_code; + uint8_t encoded_resp[25]; + uint16_t len; // Send indication - len = ble_racp_encode(p_racp_val, encoded_resp); - hvx_len = len; + len = ble_racp_encode(p_racp_val, encoded_resp); - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_gls->racp_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = encoded_resp; + nrf_ble_gq_req_t gls_req; - err_code = sd_ble_gatts_hvx(p_gls->conn_handle, &hvx_params); + memset(&gls_req, 0, sizeof(nrf_ble_gq_req_t)); - // Error handling - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } - switch (err_code) - { - case NRF_SUCCESS: - // Wait for HVC event - state_set(STATE_RACP_RESPONSE_IND_VERIF); - break; + gls_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + gls_req.error_handler.cb = gatt_error_handler; + gls_req.error_handler.p_ctx = p_gls; + gls_req.params.gatts_hvx.handle = p_gls->racp_handles.value_handle; + gls_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; + gls_req.params.gatts_hvx.offset = 0; + gls_req.params.gatts_hvx.p_data = encoded_resp; + gls_req.params.gatts_hvx.p_len = &len; - case NRF_ERROR_BUSY: - // Wait for BLE_GATTS_EVT_HVC event to retry transmission - state_set(STATE_RACP_RESPONSE_PENDING); - break; + err_code = nrf_ble_gq_item_add(p_gls->p_gatt_queue, &gls_req, p_gls->conn_handle); - case NRF_ERROR_INVALID_STATE: - // Make sure state machine returns to the default state - state_set(STATE_NO_COMM); - break; - default: - // Report error to application - if (p_gls->error_handler != NULL) - { - p_gls->error_handler(err_code); - } + // Report error to application - // Make sure state machine returns to the default state - state_set(STATE_NO_COMM); - break; + if ((p_gls->error_handler != NULL) && + (err_code != NRF_SUCCESS) && + (err_code != NRF_ERROR_INVALID_STATE)) + { + p_gls->error_handler(err_code); } + } @@ -492,15 +328,20 @@ static void racp_send(ble_gls_t * p_gls, ble_racp_value_t * p_racp_val) */ static void racp_response_code_send(ble_gls_t * p_gls, uint8_t opcode, uint8_t value) { - m_pending_racp_response.opcode = RACP_OPCODE_RESPONSE_CODE; - m_pending_racp_response.operator = RACP_OPERATOR_NULL; - m_pending_racp_response.operand_len = 2; - m_pending_racp_response.p_operand = m_pending_racp_response_operand; + ble_racp_value_t racp_response; + uint8_t pending_racp_response_operand[RACP_OPERAND_LEN] = {0}; + + memset(&racp_response, 0, sizeof(racp_response)); + + racp_response.opcode = RACP_OPCODE_RESPONSE_CODE; + racp_response.operator = RACP_OPERATOR_NULL; + racp_response.operand_len = 2; + racp_response.p_operand = pending_racp_response_operand; - m_pending_racp_response_operand[0] = opcode; - m_pending_racp_response_operand[1] = value; + pending_racp_response_operand[0] = opcode; + pending_racp_response_operand[1] = value; - racp_send(p_gls, &m_pending_racp_response); + racp_send(p_gls, &racp_response); } @@ -522,7 +363,7 @@ static uint32_t glucose_meas_send(ble_gls_t * p_gls, ble_gls_rec_t * p_rec) len = gls_meas_encode(&p_rec->meas, encoded_glm); hvx_len = len; - memset(&hvx_params, 0, sizeof (hvx_params)); + memset(&hvx_params, 0, sizeof(hvx_params)); hvx_params.handle = p_gls->glm_handles.value_handle; hvx_params.type = BLE_GATT_HVX_NOTIFICATION; @@ -541,7 +382,6 @@ static uint32_t glucose_meas_send(ble_gls_t * p_gls, ble_gls_rec_t * p_rec) { // Measurement successfully sent m_racp_proc_records_reported++; - m_racp_proc_records_reported_since_txcomplete++; } } @@ -561,7 +401,7 @@ static uint32_t racp_report_records_all(ble_gls_t * p_gls) if (m_racp_proc_record_ndx >= total_records) { - state_set(STATE_NO_COMM); + m_procesing_active = false; } else { @@ -601,7 +441,7 @@ static uint32_t racp_report_records_first_last(ble_gls_t * p_gls) if ((m_racp_proc_records_reported != 0) || (total_records == 0)) { - state_set(STATE_NO_COMM); + m_procesing_active = false; } else { @@ -667,7 +507,7 @@ static uint32_t racp_report_records_greater_or_equal(ble_gls_t * p_gls) } if (m_racp_proc_record_ndx == total_records) { - state_set(STATE_NO_COMM); + m_procesing_active = false; } return NRF_SUCCESS; @@ -703,7 +543,7 @@ static void racp_report_records_procedure(ble_gls_t * p_gls) { uint32_t err_code; - while (m_gls_state == STATE_RACP_PROC_ACTIVE) + while (m_procesing_active) { // Execute requested procedure switch (m_racp_proc_operator) @@ -727,9 +567,6 @@ static void racp_report_records_procedure(ble_gls_t * p_gls) { p_gls->error_handler(NRF_ERROR_INTERNAL); } - - // Make sure state machine returns to the default state - state_set(STATE_NO_COMM); return; } @@ -737,7 +574,7 @@ static void racp_report_records_procedure(ble_gls_t * p_gls) switch (err_code) { case NRF_SUCCESS: - if (m_gls_state == STATE_RACP_PROC_ACTIVE) + if (m_procesing_active) { m_racp_proc_record_ndx++; } @@ -753,7 +590,7 @@ static void racp_report_records_procedure(ble_gls_t * p_gls) case NRF_ERROR_INVALID_STATE: // Notification is probably not enabled. Ignore request. - state_set(STATE_NO_COMM); + m_procesing_active = false; return; default: @@ -763,8 +600,6 @@ static void racp_report_records_procedure(ble_gls_t * p_gls) p_gls->error_handler(err_code); } - // Make sure state machine returns to the default state - state_set(STATE_NO_COMM); return; } } @@ -789,7 +624,7 @@ static bool is_request_to_be_executed(ble_racp_value_t const * p_racp_request, if (p_racp_request->opcode == RACP_OPCODE_ABORT_OPERATION) { - if (m_gls_state == STATE_RACP_PROC_ACTIVE) + if (m_procesing_active) { if (p_racp_request->operator != RACP_OPERATOR_NULL) { @@ -809,10 +644,11 @@ static bool is_request_to_be_executed(ble_racp_value_t const * p_racp_request, *p_response_code = RACP_RESPONSE_ABORT_FAILED; } } - else if (m_gls_state != STATE_NO_COMM) + else if (m_procesing_active) { return false; } + // Supported opcodes. else if ((p_racp_request->opcode == RACP_OPCODE_REPORT_RECS) || (p_racp_request->opcode == RACP_OPCODE_REPORT_NUM_RECS)) @@ -856,7 +692,7 @@ static bool is_request_to_be_executed(ble_racp_value_t const * p_racp_request, case RACP_OPERATOR_LESS_OR_EQUAL: case RACP_OPERATOR_RANGE: *p_response_code = RACP_RESPONSE_OPERATOR_UNSUPPORTED; - break; + break; // Invalid operators. case RACP_OPERATOR_NULL: @@ -884,7 +720,7 @@ static bool is_request_to_be_executed(ble_racp_value_t const * p_racp_request, } // NOTE: The computation of the return value will change slightly when deferred write has been - // implemented in the stack. + // implemented in the stack. return (*p_response_code == RACP_RESPONSE_RESERVED); } @@ -898,7 +734,7 @@ static void report_records_request_execute(ble_gls_t * p_gls, ble_racp_value_t * { uint16_t seq_num = (p_racp_request->p_operand[2] << 8) | p_racp_request->p_operand[1]; - state_set(STATE_RACP_PROC_ACTIVE); + m_procesing_active = true; m_racp_proc_record_ndx = 0; m_racp_proc_operator = p_racp_request->operator; @@ -963,15 +799,20 @@ static void report_num_records_request_execute(ble_gls_t * p_gls, ble_racp_value } } - m_pending_racp_response.opcode = RACP_OPCODE_NUM_RECS_RESPONSE; - m_pending_racp_response.operator = RACP_OPERATOR_NULL; - m_pending_racp_response.operand_len = sizeof(uint16_t); - m_pending_racp_response.p_operand = m_pending_racp_response_operand; + ble_racp_value_t racp_response; + uint8_t pending_racp_response_operand[RACP_OPERAND_LEN] = {0}; + + memset(&racp_response, 0, sizeof(racp_response)); - m_pending_racp_response_operand[0] = num_records & 0xFF; - m_pending_racp_response_operand[1] = num_records >> 8; + racp_response.opcode = RACP_OPCODE_NUM_RECS_RESPONSE; + racp_response.operator = RACP_OPERATOR_NULL; + racp_response.operand_len = sizeof(uint16_t); + racp_response.p_operand = pending_racp_response_operand; - racp_send(p_gls, &m_pending_racp_response); + pending_racp_response_operand[0] = num_records & 0xFF; + pending_racp_response_operand[1] = num_records >> 8; + + racp_send(p_gls, &racp_response); } @@ -982,10 +823,10 @@ static void report_num_records_request_execute(ble_gls_t * p_gls, ble_racp_value */ uint32_t ble_gls_are_cccd_configured(ble_gls_t * p_gls, bool * p_are_cccd_configured) { - uint32_t err_code; - uint8_t cccd_value_buf[BLE_CCCD_VALUE_LEN]; - bool is_glm_notif_enabled = false; - bool is_racp_indic_enabled = false; + uint32_t err_code; + uint8_t cccd_value_buf[BLE_CCCD_VALUE_LEN]; + bool is_glm_notif_enabled = false; + bool is_racp_indic_enabled = false; ble_gatts_value_t gatts_value; // Initialize value struct. @@ -1034,8 +875,8 @@ static void on_racp_value_write(ble_gls_t * p_gls, ble_gatts_evt_write_t const * ble_racp_value_t racp_request; uint8_t response_code; ble_gatts_rw_authorize_reply_params_t auth_reply; - bool are_cccd_configured; - uint32_t err_code; + bool are_cccd_configured; + uint32_t err_code; auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; auth_reply.params.write.offset = 0; @@ -1069,7 +910,7 @@ static void on_racp_value_write(ble_gls_t * p_gls, ble_gatts_evt_write_t const * } // Decode request. - ble_racp_decode(p_evt_write->len, (uint8_t*)p_evt_write->data, &racp_request); + ble_racp_decode(p_evt_write->len, (uint8_t *)p_evt_write->data, &racp_request); // Check if request is to be executed. if (is_request_to_be_executed(&racp_request, &response_code)) @@ -1115,7 +956,7 @@ static void on_racp_value_write(ble_gls_t * p_gls, ble_gatts_evt_write_t const * } // Abort any running procedure. - state_set(STATE_NO_COMM); + m_procesing_active = false; // Respond with error code. racp_response_code_send(p_gls, racp_request.opcode, response_code); @@ -1198,53 +1039,13 @@ static void on_write(ble_gls_t * p_gls, ble_evt_t const * p_ble_evt) */ static void on_tx_complete(ble_gls_t * p_gls, ble_evt_t const * p_ble_evt) { - m_racp_proc_records_reported_since_txcomplete = 0; - - if (m_gls_state == STATE_RACP_RESPONSE_PENDING) - { - racp_send(p_gls, &m_pending_racp_response); - } - else if (m_gls_state == STATE_RACP_PROC_ACTIVE) + if (m_procesing_active) { racp_report_records_procedure(p_gls); } } -/**@brief Function for handling the HVC event. - * - * @details Handles HVC events from the BLE stack. - * - * @param[in] p_gls Glucose Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_hvc(ble_gls_t * p_gls, ble_evt_t const * p_ble_evt) -{ - ble_gatts_evt_hvc_t const * p_hvc = &p_ble_evt->evt.gatts_evt.params.hvc; - - if (p_hvc->handle == p_gls->racp_handles.value_handle) - { - if (m_gls_state == STATE_RACP_RESPONSE_IND_VERIF) - { - // Indication has been acknowledged. Return to default state. - state_set(STATE_NO_COMM); - } - else if (m_gls_state == STATE_RACP_RESPONSE_PENDING) - { - racp_send(p_gls, &m_pending_racp_response); - } - else - { - // We did not expect this event in this state. Report error to application. - if (p_gls->error_handler != NULL) - { - p_gls->error_handler(NRF_ERROR_INVALID_STATE); - } - } - } -} - - static void on_rw_authorize_request(ble_gls_t * p_gls, ble_gatts_evt_t const * p_gatts_evt) { ble_gatts_evt_rw_authorize_request_t const * p_auth_req = @@ -1254,10 +1055,10 @@ static void on_rw_authorize_request(ble_gls_t * p_gls, ble_gatts_evt_t const * p { if ( (p_gatts_evt->params.authorize_request.request.write.op != BLE_GATTS_OP_PREP_WRITE_REQ) - && (p_gatts_evt->params.authorize_request.request.write.op - != BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) - && (p_gatts_evt->params.authorize_request.request.write.op - != BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL) + && (p_gatts_evt->params.authorize_request.request.write.op + != BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) + && (p_gatts_evt->params.authorize_request.request.write.op + != BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL) ) { if (p_auth_req->request.write.handle == p_gls->racp_handles.value_handle) @@ -1268,15 +1069,23 @@ static void on_rw_authorize_request(ble_gls_t * p_gls, ble_gatts_evt_t const * p } } + void ble_gls_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) { ble_gls_t * p_gls = (ble_gls_t *)p_context; + ret_code_t err_code; switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: p_gls->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - state_set(STATE_NO_COMM); + err_code = nrf_ble_gq_conn_handle_register(p_gls->p_gatt_queue, + p_ble_evt->evt.gap_evt.conn_handle); + + if ((err_code != NRF_SUCCESS) && (p_gls->error_handler != NULL)) + { + p_gls->error_handler(err_code); + } break; case BLE_GAP_EVT_DISCONNECTED: @@ -1295,10 +1104,6 @@ void ble_gls_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_rw_authorize_request(p_gls, &p_ble_evt->evt.gatts_evt); break; - case BLE_GATTS_EVT_HVC: - on_hvc(p_gls, p_ble_evt); - break; - default: // No implementation needed. break; @@ -1311,4 +1116,6 @@ uint32_t ble_gls_glucose_new_meas(ble_gls_t * p_gls, ble_gls_rec_t * p_rec) p_rec->meas.sequence_number = m_next_seq_num++; return ble_gls_db_record_add(p_rec); } + + #endif // NRF_MODULE_ENABLED(BLE_GLS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.h new file mode 100644 index 0000000..d5001fc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls.h @@ -0,0 +1,330 @@ +/** + * Copyright (c) 2012 - 2019, 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 ble_gls Glucose Service + * @{ + * @ingroup ble_sdk_srv + * @brief Glucose Service module. + * + * @details This module implements the Glucose Service. + * + * @note The application must register this module as BLE event observer using the + * NRF_SDH_BLE_OBSERVER macro. Example: + * @code + * ble_gls_t instance; + * NRF_SDH_BLE_OBSERVER(anything, BLE_GLS_BLE_OBSERVER_PRIO, + * ble_gls_on_ble_evt, &instance); + * @endcode + * + * @note Attention! + * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile + * qualification listings, this section of source code must not be modified. + */ + +#ifndef BLE_GLS_H__ +#define BLE_GLS_H__ + +#include +#include +#include "ble.h" +#include "ble_srv_common.h" +#include "ble_date_time.h" +#include "nrf_ble_gq.h" +#include "nrf_sdh_ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Macro for defining a ble_gls instance. + * + * @param _name Name of the instance. + * @hideinitializer + */ +#define BLE_GLS_DEF(_name) \ + static ble_gls_t _name; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_GLS_BLE_OBSERVER_PRIO, \ + ble_gls_on_ble_evt, &_name) + + +/**@brief Glucose feature */ +#define BLE_GLS_FEATURE_LOW_BATT 0x0001 /**< Low Battery Detection During Measurement Supported */ +#define BLE_GLS_FEATURE_MALFUNC 0x0002 /**< Sensor Malfunction Detection Supported */ +#define BLE_GLS_FEATURE_SAMPLE_SIZE 0x0004 /**< Sensor Sample Size Supported */ +#define BLE_GLS_FEATURE_INSERT_ERR 0x0008 /**< Sensor Strip Insertion Error Detection Supported */ +#define BLE_GLS_FEATURE_TYPE_ERR 0x0010 /**< Sensor Strip Type Error Detection Supported */ +#define BLE_GLS_FEATURE_RES_HIGH_LOW 0x0020 /**< Sensor Result High-Low Detection Supported */ +#define BLE_GLS_FEATURE_TEMP_HIGH_LOW 0x0040 /**< Sensor Temperature High-Low Detection Supported */ +#define BLE_GLS_FEATURE_READ_INT 0x0080 /**< Sensor Read Interrupt Detection Supported */ +#define BLE_GLS_FEATURE_GENERAL_FAULT 0x0100 /**< General Device Fault Supported */ +#define BLE_GLS_FEATURE_TIME_FAULT 0x0200 /**< Time Fault Supported */ +#define BLE_GLS_FEATURE_MULTI_BOND 0x0400 /**< Multiple Bond Supported */ + +/**@brief Glucose measurement flags */ +#define BLE_GLS_MEAS_FLAG_TIME_OFFSET 0x01 /**< Time Offset Present */ +#define BLE_GLS_MEAS_FLAG_CONC_TYPE_LOC 0x02 /**< Glucose Concentration, Type, and Sample Location Present */ +#define BLE_GLS_MEAS_FLAG_UNITS_KG_L 0x00 /**< Glucose Concentration Units kg/L */ +#define BLE_GLS_MEAS_FLAG_UNITS_MOL_L 0x04 /**< Glucose Concentration Units mol/L */ +#define BLE_GLS_MEAS_FLAG_SENSOR_STATUS 0x08 /**< Sensor Status Annunciation Present */ +#define BLE_GLS_MEAS_FLAG_CONTEXT_INFO 0x10 /**< Context Information Follows */ + +/**@brief Glucose measurement type */ +#define BLE_GLS_MEAS_TYPE_CAP_BLOOD 1 /**< Capillary whole blood */ +#define BLE_GLS_MEAS_TYPE_CAP_PLASMA 2 /**< Capillary plasma */ +#define BLE_GLS_MEAS_TYPE_VEN_BLOOD 3 /**< Venous whole blood */ +#define BLE_GLS_MEAS_TYPE_VEN_PLASMA 4 /**< Venous plasma */ +#define BLE_GLS_MEAS_TYPE_ART_BLOOD 5 /**< Arterial whole blood */ +#define BLE_GLS_MEAS_TYPE_ART_PLASMA 6 /**< Arterial plasma */ +#define BLE_GLS_MEAS_TYPE_UNDET_BLOOD 7 /**< Undetermined whole blood */ +#define BLE_GLS_MEAS_TYPE_UNDET_PLASMA 8 /**< Undetermined plasma */ +#define BLE_GLS_MEAS_TYPE_FLUID 9 /**< Interstitial fluid (ISF) */ +#define BLE_GLS_MEAS_TYPE_CONTROL 10 /**< Control solution */ + +/**@brief Glucose measurement location */ +#define BLE_GLS_MEAS_LOC_FINGER 1 /**< Finger */ +#define BLE_GLS_MEAS_LOC_AST 2 /**< Alternate Site Test (AST) */ +#define BLE_GLS_MEAS_LOC_EAR 3 /**< Earlobe */ +#define BLE_GLS_MEAS_LOC_CONTROL 4 /**< Control solution */ +#define BLE_GLS_MEAS_LOC_NOT_AVAIL 15 /**< Sample Location value not available */ + +/**@brief Glucose sensor status annunciation */ +#define BLE_GLS_MEAS_STATUS_BATT_LOW 0x0001 /**< Device battery low at time of measurement */ +#define BLE_GLS_MEAS_STATUS_SENSOR_FAULT 0x0002 /**< Sensor malfunction or faulting at time of measurement */ +#define BLE_GLS_MEAS_STATUS_SAMPLE_SIZE 0x0004 /**< Sample size for blood or control solution insufficient at time of measurement */ +#define BLE_GLS_MEAS_STATUS_STRIP_INSERT 0x0008 /**< Strip insertion error */ +#define BLE_GLS_MEAS_STATUS_STRIP_TYPE 0x0010 /**< Strip type incorrect for device */ +#define BLE_GLS_MEAS_STATUS_RESULT_HIGH 0x0020 /**< Sensor result higher than the device can process */ +#define BLE_GLS_MEAS_STATUS_RESULT_LOW 0x0040 /**< Sensor result lower than the device can process */ +#define BLE_GLS_MEAS_STATUS_TEMP_HIGH 0x0080 /**< Sensor temperature too high for valid test/result at time of measurement */ +#define BLE_GLS_MEAS_STATUS_TEMP_LOW 0x0100 /**< Sensor temperature too low for valid test/result at time of measurement */ +#define BLE_GLS_MEAS_STATUS_STRIP_PULL 0x0200 /**< Sensor read interrupted because strip was pulled too soon at time of measurement */ +#define BLE_GLS_MEAS_STATUS_GENERAL_FAULT 0x0400 /**< General device fault has occurred in the sensor */ +#define BLE_GLS_MEAS_STATUS_TIME_FAULT 0x0800 /**< Time fault has occurred in the sensor and time may be inaccurate */ + +/**@brief Glucose measurement context flags */ +#define BLE_GLS_CONTEXT_FLAG_CARB 0x01 /**< Carbohydrate id and carbohydrate present */ +#define BLE_GLS_CONTEXT_FLAG_MEAL 0x02 /**< Meal present */ +#define BLE_GLS_CONTEXT_FLAG_TESTER 0x04 /**< Tester-health present */ +#define BLE_GLS_CONTEXT_FLAG_EXERCISE 0x08 /**< Exercise duration and exercise intensity present */ +#define BLE_GLS_CONTEXT_FLAG_MED 0x10 /**< Medication ID and medication present */ +#define BLE_GLS_CONTEXT_FLAG_MED_KG 0x00 /**< Medication value units, kilograms */ +#define BLE_GLS_CONTEXT_FLAG_MED_L 0x20 /**< Medication value units, liters */ +#define BLE_GLS_CONTEXT_FLAG_HBA1C 0x40 /**< Hba1c present */ +#define BLE_GLS_CONTEXT_FLAG_EXT 0x80 /**< Extended flags present */ + +/**@brief Glucose measurement context carbohydrate ID */ +#define BLE_GLS_CONTEXT_CARB_BREAKFAST 1 /**< Breakfast */ +#define BLE_GLS_CONTEXT_CARB_LUNCH 2 /**< Lunch */ +#define BLE_GLS_CONTEXT_CARB_DINNER 3 /**< Dinner */ +#define BLE_GLS_CONTEXT_CARB_SNACK 4 /**< Snack */ +#define BLE_GLS_CONTEXT_CARB_DRINK 5 /**< Drink */ +#define BLE_GLS_CONTEXT_CARB_SUPPER 6 /**< Supper */ +#define BLE_GLS_CONTEXT_CARB_BRUNCH 7 /**< Brunch */ + +/**@brief Glucose measurement context meal */ +#define BLE_GLS_CONTEXT_MEAL_PREPRANDIAL 1 /**< Preprandial (before meal) */ +#define BLE_GLS_CONTEXT_MEAL_POSTPRANDIAL 2 /**< Postprandial (after meal) */ +#define BLE_GLS_CONTEXT_MEAL_FASTING 3 /**< Fasting */ +#define BLE_GLS_CONTEXT_MEAL_CASUAL 4 /**< Casual (snacks, drinks, etc.) */ +#define BLE_GLS_CONTEXT_MEAL_BEDTIME 5 /**< Bedtime */ + +/**@brief Glucose measurement context tester */ +#define BLE_GLS_CONTEXT_TESTER_SELF 1 /**< Self */ +#define BLE_GLS_CONTEXT_TESTER_PRO 2 /**< Health care professional */ +#define BLE_GLS_CONTEXT_TESTER_LAB 3 /**< Lab test */ +#define BLE_GLS_CONTEXT_TESTER_NOT_AVAIL 15 /**< Tester value not available */ + +/**@brief Glucose measurement context health */ +#define BLE_GLS_CONTEXT_HEALTH_MINOR 1 /**< Minor health issues */ +#define BLE_GLS_CONTEXT_HEALTH_MAJOR 2 /**< Major health issues */ +#define BLE_GLS_CONTEXT_HEALTH_MENSES 3 /**< During menses */ +#define BLE_GLS_CONTEXT_HEALTH_STRESS 4 /**< Under stress */ +#define BLE_GLS_CONTEXT_HEALTH_NONE 5 /**< No health issues */ +#define BLE_GLS_CONTEXT_HEALTH_NOT_AVAIL 15 /**< Health value not available */ + +/**@brief Glucose measurement context medication ID */ +#define BLE_GLS_CONTEXT_MED_RAPID 1 /**< Rapid acting insulin */ +#define BLE_GLS_CONTEXT_MED_SHORT 2 /**< Short acting insulin */ +#define BLE_GLS_CONTEXT_MED_INTERMED 3 /**< Intermediate acting insulin */ +#define BLE_GLS_CONTEXT_MED_LONG 4 /**< Long acting insulin */ +#define BLE_GLS_CONTEXT_MED_PREMIX 5 /**< Pre-mixed insulin */ + + +/**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, meaning 4 bits for exponent (base 10) and 12 bits mantissa) */ +typedef struct +{ + int8_t exponent; /**< Base 10 exponent, should be using only 4 bits */ + int16_t mantissa; /**< Mantissa, should be using only 12 bits */ +} sfloat_t; + +/**@brief Glucose Service event type. */ +typedef enum +{ + BLE_GLS_EVT_NOTIFICATION_ENABLED, /**< Glucose value notification enabled event. */ + BLE_GLS_EVT_NOTIFICATION_DISABLED /**< Glucose value notification disabled event. */ +} ble_gls_evt_type_t; + +/**@brief Glucose Service event. */ +typedef struct +{ + ble_gls_evt_type_t evt_type; /**< Type of event. */ +} ble_gls_evt_t; + +// Forward declaration of the ble_gls_t type. +typedef struct ble_gls_s ble_gls_t; + +/**@brief Glucose Service event handler type. */ +typedef void (*ble_gls_evt_handler_t)(ble_gls_t * p_gls, ble_gls_evt_t * p_evt); + +/**@brief Glucose Measurement structure. This contains glucose measurement value. */ +typedef struct +{ + uint8_t flags; /**< Flags */ + uint16_t sequence_number; /**< Sequence number */ + ble_date_time_t base_time; /**< Time stamp */ + int16_t time_offset; /**< Time offset */ + sfloat_t glucose_concentration; /**< Glucose concentration */ + uint8_t type; /**< Type */ + uint8_t sample_location; /**< Sample location */ + uint16_t sensor_status_annunciation; /**< Sensor status annunciation */ +} ble_gls_meas_t; + +/**@brief Glucose measurement context structure */ +typedef struct +{ + uint8_t flags; /**< Flags */ + uint8_t extended_flags; /**< Extended Flags */ + uint8_t carbohydrate_id; /**< Carbohydrate ID */ + sfloat_t carbohydrate; /**< Carbohydrate */ + uint8_t meal; /**< Meal */ + uint8_t tester_and_health; /**< Tester and health */ + uint16_t exercise_duration; /**< Exercise Duration */ + uint8_t exercise_intensity; /**< Exercise Intensity */ + uint8_t medication_id; /**< Medication ID */ + sfloat_t medication; /**< Medication */ + uint16_t hba1c; /**< HbA1c */ +} ble_gls_meas_context_t; + +/**@brief Glucose measurement record */ +typedef struct +{ + ble_gls_meas_t meas; /**< Glucose measurement */ + ble_gls_meas_context_t context; /**< Glucose measurement context */ +} ble_gls_rec_t; + +/**@brief Glucose Service init structure. This contains all options and data needed for + * initialization of the service. */ +typedef struct +{ + ble_gls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Glucose Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + uint16_t feature; /**< Glucose Feature value indicating supported features. */ + bool is_context_supported; /**< Determines if optional Glucose Measurement Context is to be supported. */ + security_req_t gl_meas_cccd_wr_sec; /**< Security requirement for writing glucose measurement characteristic CCCD. */ + security_req_t gl_feature_rd_sec; /**< Security requirement for reading glucose feature characteristic. */ + security_req_t racp_cccd_wr_sec; /**< Security requirement for writing RACP Characteristic CCCD. */ + security_req_t racp_wr_sec; /**< Security requirement for writing RACP Characteristic. (Service specification mandates authentication) */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ +} ble_gls_init_t; + +/**@brief Glucose Service structure. This contains various status information for the service. */ +struct ble_gls_s +{ + ble_gls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Glucose Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + uint16_t service_handle; /**< Handle of Glucose Service (as provided by the BLE stack). */ + ble_gatts_char_handles_t glm_handles; /**< Handles related to the Glucose Measurement characteristic. */ + ble_gatts_char_handles_t glm_context_handles; /**< Handles related to the Glucose Measurement Context characteristic. */ + ble_gatts_char_handles_t glf_handles; /**< Handles related to the Glucose Feature characteristic. */ + ble_gatts_char_handles_t racp_handles; /**< Handles related to the Record Access Control Point characteristic. */ + uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ + uint16_t feature; + bool is_context_supported; +}; + + +/**@brief Function for initializing the Glucose Service. + * + * @details This call allows the application to initialize the Glucose Service. + * + * @param[out] p_gls Glucose Service structure. This structure will have to be supplied by + * the application. It will be initialized by this function, and will later + * be used to identify this particular service instance. + * @param[in] p_gls_init Information needed to initialize the service. + * + * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. + */ +uint32_t ble_gls_init(ble_gls_t * p_gls, ble_gls_init_t const * p_gls_init); + + +/**@brief Function for handling the Application's BLE Stack events. + * + * @details Handles all events from the BLE stack of interest to the Glucose Service. + * + * @param[in] p_ble_evt Event received from the BLE stack. + * @param[in] p_context Glucose Service structure. + */ +void ble_gls_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); + + +/**@brief Function for reporting a new glucose measurement to the glucose service module. + * + * @details The application calls this function after having performed a new glucose measurement. + * The new measurement is recorded in the RACP database. + * + * @param[in] p_gls Glucose Service structure. + * @param[in] p_rec Pointer to glucose record (measurement plus context). + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +uint32_t ble_gls_glucose_new_meas(ble_gls_t * p_gls, ble_gls_rec_t * p_rec); + + +#ifdef __cplusplus +} +#endif + +#endif // BLE_GLS_H__ + +/** @} */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls_db.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls_db.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls_db.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls_db.c index c1bbe8b..b0cd292 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls_db.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls_db.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_GLS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls_db.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls_db.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls_db.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls_db.h index ffc928d..c0b7934 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_gls/ble_gls_db.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_gls/ble_gls_db.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.c new file mode 100644 index 0000000..9a8fe1e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.c @@ -0,0 +1,1576 @@ +/** + * Copyright (c) 2012 - 2019, 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. + * + */ +/* Attention! + * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile + * qualification listings, this section of source code must not be modified. + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(BLE_HIDS) +#include "ble_hids.h" +#include +#include "app_error.h" +#include "ble_srv_common.h" + + +// Protocol Mode values +#define PROTOCOL_MODE_BOOT 0x00 /**< Boot Protocol Mode. */ +#define PROTOCOL_MODE_REPORT 0x01 /**< Report Protocol Mode. */ + +// HID Control Point values +#define HIDS_CONTROL_POINT_SUSPEND 0 /**< Suspend command. */ +#define HIDS_CONTROL_POINT_EXIT_SUSPEND 1 /**< Exit Suspend command. */ + +#define DEFAULT_PROTOCOL_MODE PROTOCOL_MODE_REPORT /**< Default value for the Protocol Mode characteristic. */ +#define INITIAL_VALUE_HID_CONTROL_POINT HIDS_CONTROL_POINT_SUSPEND /**< Initial value for the HID Control Point characteristic. */ + +#define ENCODED_HID_INFORMATION_LEN 4 /**< Maximum size of an encoded HID Information characteristic. */ + +/**@brief Handles errors for HID service module. + * + * @param[in] _p_hids HID Service structure. + * @param[in] _err_code Maximum number of HID hosts connected at a time. + * + */ +#define BLE_HIDS_ERROR_HANDLE(_p_hids, _err_code) \ + do \ + { \ + if (((_err_code) != NRF_SUCCESS) && ((_p_hids)->error_handler != NULL)) \ + { \ + (_p_hids)->error_handler((_err_code)); \ + } \ + } while (0) + + +/**@brief Function for calculating the link context size for the HID service. + * + * @param[in] p_hids HID Service structure. + * + * @return Link context size. + */ +static size_t ble_hids_client_context_size_calc(ble_hids_t * p_hids) +{ + size_t client_size = sizeof(ble_hids_client_context_t) + (BOOT_KB_INPUT_REPORT_MAX_SIZE) + + (BOOT_KB_OUTPUT_REPORT_MAX_SIZE) + (BOOT_MOUSE_INPUT_REPORT_MAX_SIZE); + + if (p_hids->p_inp_rep_init_array != NULL) + { + for (uint32_t i = 0; i < p_hids->inp_rep_count; i++) + { + client_size += p_hids->p_inp_rep_init_array[i].max_len; + } + } + if (p_hids->p_outp_rep_init_array != NULL) + { + for (uint32_t i = 0; i < p_hids->outp_rep_count; i++) + { + client_size += p_hids->p_outp_rep_init_array[i].max_len; + } + } + if (p_hids->p_feature_rep_init_array != NULL) + { + for (uint32_t i = 0; i < p_hids->feature_rep_count; i++) + { + client_size += p_hids->p_feature_rep_init_array[i].max_len; + } + } + + return client_size; +} + + +/**@brief Function for making a HID Service characteristic id. + * + * @param[in] uuid UUID of characteristic. + * @param[in] rep_type Type of report. + * @param[in] rep_index Index of the characteristic. + * + * @return HID Service characteristic id structure. + */ +static ble_hids_char_id_t make_char_id(uint16_t uuid, uint8_t rep_type, uint8_t rep_index) +{ + ble_hids_char_id_t char_id = {0}; + + char_id.uuid = uuid; + char_id.rep_type = rep_type; + char_id.rep_index = rep_index; + + return char_id; +} + + +/**@brief Function for handling the Connect event. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_connect(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) +{ + uint32_t err_code; + ble_gatts_value_t gatts_value; + ble_hids_client_context_t * p_client = NULL; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + p_ble_evt->evt.gap_evt.conn_handle, + (void *) &p_client); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + + if (p_client == NULL) + { + return; + } + + memset(p_client, 0, ble_hids_client_context_size_calc(p_hids)); + + if (p_hids->protocol_mode_handles.value_handle) + { + // Set Protocol Mode characteristic value to default value + p_client->protocol_mode = DEFAULT_PROTOCOL_MODE; + + // Initialize value struct. + memset(&gatts_value, 0, sizeof(gatts_value)); + + gatts_value.len = sizeof(uint8_t); + gatts_value.offset = 0; + gatts_value.p_value = &p_client->protocol_mode; + + err_code = sd_ble_gatts_value_set(p_ble_evt->evt.gap_evt.conn_handle, + p_hids->protocol_mode_handles.value_handle, + &gatts_value); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + } +} + + +/**@brief Function for handling write events to the HID Control Point value. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_evt_write Write event received from the BLE stack. + */ +static void on_control_point_write(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_hids_client_context_t * p_host; + ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_host); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + + if (p_host == NULL) + { + return; + } + + if (p_evt_write->len == 1) + { + ble_hids_evt_t evt; + + switch (p_evt_write->data[0]) + { + case HIDS_CONTROL_POINT_SUSPEND: + evt.evt_type = BLE_HIDS_EVT_HOST_SUSP; + break; + + case HIDS_CONTROL_POINT_EXIT_SUSPEND: + evt.evt_type = BLE_HIDS_EVT_HOST_EXIT_SUSP; + break; + + default: + // Illegal Control Point value, ignore + return; + } + + // Store the new Control Point value for the host + p_host->ctrl_pt = p_evt_write->data[0]; + + // HID Control Point written, propagate event to application + if (p_hids->evt_handler != NULL) + { + evt.p_ble_evt = p_ble_evt; + p_hids->evt_handler(p_hids, &evt); + } + } +} + + +/**@brief Function for handling write events to the Protocol Mode value. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_ble_evt BLE event received from the BLE stack. + */ +static void on_protocol_mode_write(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_hids_client_context_t * p_host; + ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_host); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + + + if (p_host == NULL) + { + return; + } + + if (p_evt_write->len == 1) + { + ble_hids_evt_t evt; + + switch (p_evt_write->data[0]) + { + case PROTOCOL_MODE_BOOT: + evt.evt_type = BLE_HIDS_EVT_BOOT_MODE_ENTERED; + break; + + case PROTOCOL_MODE_REPORT: + evt.evt_type = BLE_HIDS_EVT_REPORT_MODE_ENTERED; + break; + + default: + // Illegal Protocol Mode value, ignore + return; + } + + // Store Protocol Mode of the host + p_host->protocol_mode = p_evt_write->data[0]; + + // HID Protocol Mode written, propagate event to application + if (p_hids->evt_handler != NULL) + { + evt.p_ble_evt = p_ble_evt; + p_hids->evt_handler(p_hids, &evt); + } + } +} + + +/**@brief Function for handling authorize read events to the Protocol Mode value. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_ble_evt BLE event received from the BLE stack. + */ +void on_protocol_mode_read_auth(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_gatts_rw_authorize_reply_params_t auth_read_params; + ble_hids_client_context_t * p_host; + ble_gatts_evt_rw_authorize_request_t const * p_read_auth = + &p_ble_evt->evt.gatts_evt.params.authorize_request; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_host); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + + // Update GATTS table with this host's Protocol Mode value and authorize Read + if (p_host != NULL) + { + memset(&auth_read_params, 0, sizeof(auth_read_params)); + + auth_read_params.type = BLE_GATTS_AUTHORIZE_TYPE_READ; + auth_read_params.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS; + auth_read_params.params.read.offset = p_read_auth->request.read.offset; + auth_read_params.params.read.len = sizeof(uint8_t); + auth_read_params.params.read.p_data = &p_host->protocol_mode; + auth_read_params.params.read.update = 1; + + err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gap_evt.conn_handle, + &auth_read_params); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + } +} + + +/**@brief Function for handling write events to a report CCCD. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_char_id Id of report characteristic. + * @param[in] p_ble_evt BLE event received from the BLE stack. + */ +static void on_report_cccd_write(ble_hids_t * p_hids, + ble_hids_char_id_t * p_char_id, + ble_evt_t const * p_ble_evt) +{ + ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + + if (p_evt_write->len == 2) + { + // CCCD written, update notification state + if (p_hids->evt_handler != NULL) + { + ble_hids_evt_t evt; + + if (ble_srv_is_notification_enabled(p_evt_write->data)) + { + evt.evt_type = BLE_HIDS_EVT_NOTIF_ENABLED; + } + else + { + evt.evt_type = BLE_HIDS_EVT_NOTIF_DISABLED; + } + evt.params.notification.char_id = *p_char_id; + evt.p_ble_evt = p_ble_evt; + + p_hids->evt_handler(p_hids, &evt); + } + } +} + + +/**@brief Function for handling write events to a report value. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_ble_evt Pointer to BLE event structure. + * @param[in] p_char_id Id of report characteristic. + * @param[in] rep_offset Offset to the affected HID report data. + * @param[in] rep_max_len Maximum HID report length. + */ +static void on_report_value_write(ble_hids_t * p_hids, + ble_evt_t const * p_ble_evt, + ble_hids_char_id_t * p_char_id, + uint16_t rep_offset, + uint16_t rep_max_len) +{ + // Update host's Output Report data + ret_code_t err_code; + uint8_t * p_report; + ble_hids_client_context_t * p_host; + ble_gatts_evt_write_t const * p_write = &p_ble_evt->evt.gatts_evt.params.write; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_host); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + + // Store the written values in host's report data + if ((p_host != NULL) && (p_write->len + p_write->offset <= rep_max_len)) + { + p_report = (uint8_t *) p_host + rep_offset; + memcpy(p_report, p_write->data, p_write->len); + } + else + { + return; + } + + // Notify the applicartion + if (p_hids->evt_handler != NULL) + { + ble_hids_evt_t evt; + + evt.evt_type = BLE_HIDS_EVT_REP_CHAR_WRITE; + evt.params.char_write.char_id = *p_char_id; + evt.params.char_write.offset = p_ble_evt->evt.gatts_evt.params.write.offset; + evt.params.char_write.len = p_ble_evt->evt.gatts_evt.params.write.len; + evt.params.char_write.data = p_ble_evt->evt.gatts_evt.params.write.data; + evt.p_ble_evt = p_ble_evt; + + p_hids->evt_handler(p_hids, &evt); + } +} + + +/**@brief Handle authorize read events to a report value. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_char_id Id of report characteristic. + * @param[in] p_ble_evt Pointer to BLE event structure. + * @param[in] rep_offset Report data offset. + * @param[in] rep_max_len Report maximum length. + */ +static void on_report_value_read_auth(ble_hids_t * p_hids, + ble_hids_char_id_t * p_char_id, + ble_evt_t const * p_ble_evt, + uint16_t rep_offset, + uint16_t rep_max_len) +{ + ble_gatts_rw_authorize_reply_params_t auth_read_params; + ble_hids_client_context_t * p_host; + uint8_t * p_report; + uint16_t read_offset; + uint32_t err_code = NRF_SUCCESS; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_host); + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + + // Update Report GATTS table with host's current report data + if (p_host != NULL) + { + read_offset = p_ble_evt->evt.gatts_evt.params.authorize_request.request.read.offset; + p_report = (uint8_t *) p_host + rep_offset; + memset(&auth_read_params, 0, sizeof(auth_read_params)); + + auth_read_params.type = BLE_GATTS_AUTHORIZE_TYPE_READ; + auth_read_params.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS; + auth_read_params.params.read.offset = read_offset; + auth_read_params.params.read.len = rep_max_len - read_offset; + auth_read_params.params.read.p_data = p_report + read_offset; + auth_read_params.params.read.update = 1; + + err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gap_evt.conn_handle, + &auth_read_params); + + BLE_HIDS_ERROR_HANDLE(p_hids, err_code); + } + else + { + return; + } + + if (p_hids->evt_handler != NULL) + { + ble_hids_evt_t evt; + + evt.evt_type = BLE_HIDS_EVT_REPORT_READ; + evt.params.char_auth_read.char_id = *p_char_id; + evt.p_ble_evt = p_ble_evt; + + p_hids->evt_handler(p_hids, &evt); + } +} + + +/**@brief Function for finding the Characteristic Id of a characteristic corresponding to a CCCD handle. + * + * @param[in] p_hids HID Service structure. + * @param[in] handle Handle to search for. + * @param[out] p_char_id Id of report characteristic. + * + * @return TRUE if CCCD handle was found, FALSE otherwise. + */ +static bool inp_rep_cccd_identify(ble_hids_t * p_hids, + uint16_t handle, + ble_hids_char_id_t * p_char_id) +{ + uint8_t i; + + for (i = 0; i < p_hids->inp_rep_count; i++) + { + if (handle == p_hids->inp_rep_array[i].char_handles.cccd_handle) + { + *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_INPUT, i); + return true; + } + } + + return false; +} + + +/**@brief Function for finding the Characteristic Id of a characteristic corresponding to a value handle. + * + * @param[in] p_hids HID Service structure. + * @param[in] handle Handle to search for. + * @param[out] p_char_id Id of report characteristic. + * @param[out] p_context_offset Pointer to offset to the report data within the host data. + * @param[out] p_rep_max_len Pointer to maximum report length. + * + * @return TRUE if value handle was found, FALSE otherwise. + */ +static bool rep_value_identify(ble_hids_t * p_hids, + uint16_t handle, + ble_hids_char_id_t * p_char_id, + uint16_t * p_context_offset, + uint16_t * p_rep_max_len) +{ + uint8_t i; + + /* Initialize the offset with size of non-report-related data */ + *p_context_offset = sizeof(ble_hids_client_context_t) + BOOT_KB_INPUT_REPORT_MAX_SIZE + + BOOT_KB_OUTPUT_REPORT_MAX_SIZE + BOOT_MOUSE_INPUT_REPORT_MAX_SIZE; + + if (p_hids->p_inp_rep_init_array != NULL) + { + for (i = 0; i < p_hids->inp_rep_count; i++) + { + if (handle == p_hids->inp_rep_array[i].char_handles.value_handle) + { + *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_INPUT, i); + *p_rep_max_len = p_hids->p_inp_rep_init_array[i].max_len; + return true; + } + *p_context_offset += p_hids->p_inp_rep_init_array[i].max_len; + } + } + if (p_hids->p_outp_rep_init_array != NULL) + { + for (i = 0; i < p_hids->outp_rep_count; i++) + { + if (handle == p_hids->outp_rep_array[i].char_handles.value_handle) + { + *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_OUTPUT, i); + *p_rep_max_len = p_hids->p_outp_rep_init_array[i].max_len; + return true; + } + *p_context_offset += p_hids->p_outp_rep_init_array[i].max_len; + } + } + if (p_hids->p_feature_rep_init_array != NULL) + { + for (i = 0; i < p_hids->feature_rep_count; i++) + { + if (handle == p_hids->feature_rep_array[i].char_handles.value_handle) + { + *p_char_id = make_char_id(BLE_UUID_REPORT_CHAR, BLE_HIDS_REP_TYPE_FEATURE, i); + *p_rep_max_len = p_hids->p_feature_rep_init_array[i].max_len; + return true; + } + *p_context_offset += p_hids->p_feature_rep_init_array[i].max_len; + } + } + + return false; +} + + +/**@brief Function for handling the Write event. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_write(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) +{ + ble_hids_char_id_t char_id; + ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + uint16_t rep_data_offset = sizeof(ble_hids_client_context_t); + uint16_t max_rep_len = 0; + + if (p_evt_write->handle == p_hids->hid_control_point_handles.value_handle) + { + on_control_point_write(p_hids, p_ble_evt); + } + else if (p_evt_write->handle == p_hids->protocol_mode_handles.value_handle) + { + on_protocol_mode_write(p_hids, p_ble_evt); + } + else if (p_evt_write->handle == p_hids->boot_kb_inp_rep_handles.cccd_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, 0, 0); + on_report_cccd_write(p_hids, &char_id, p_ble_evt); + } + else if (p_evt_write->handle == p_hids->boot_kb_inp_rep_handles.value_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, 0, 0); + max_rep_len = BOOT_KB_INPUT_REPORT_MAX_SIZE; + on_report_value_write(p_hids, p_ble_evt, &char_id, rep_data_offset, max_rep_len); + } + else if (p_evt_write->handle == p_hids->boot_kb_outp_rep_handles.value_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR, 0, 0); + rep_data_offset += BOOT_KB_INPUT_REPORT_MAX_SIZE; + max_rep_len = BOOT_KB_OUTPUT_REPORT_MAX_SIZE; + on_report_value_write(p_hids, p_ble_evt, &char_id, rep_data_offset, max_rep_len); + } + else if (p_evt_write->handle == p_hids->boot_mouse_inp_rep_handles.cccd_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, 0, 0); + on_report_cccd_write(p_hids, &char_id, p_ble_evt); + } + else if (p_evt_write->handle == p_hids->boot_mouse_inp_rep_handles.value_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, 0, 0); + rep_data_offset += BOOT_KB_INPUT_REPORT_MAX_SIZE + BOOT_KB_OUTPUT_REPORT_MAX_SIZE; + max_rep_len = BOOT_MOUSE_INPUT_REPORT_MAX_SIZE; + on_report_value_write(p_hids, p_ble_evt, &char_id, rep_data_offset, max_rep_len); + } + else if (inp_rep_cccd_identify(p_hids, p_evt_write->handle, &char_id)) + { + on_report_cccd_write(p_hids, &char_id, p_ble_evt); + } + else if (rep_value_identify(p_hids, + p_evt_write->handle, + &char_id, + &rep_data_offset, + &max_rep_len)) + { + on_report_value_write(p_hids, p_ble_evt, &char_id, rep_data_offset, max_rep_len); + } + else + { + // No implementation needed. + } +} + + +/**@brief Read/write authorize request event handler. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_rw_authorize_request(ble_hids_t * p_hids, ble_evt_t const * p_ble_evt) +{ + ble_gatts_evt_rw_authorize_request_t const * evt_rw_auth = + &p_ble_evt->evt.gatts_evt.params.authorize_request; + + ble_hids_char_id_t char_id; + uint16_t rep_data_offset = sizeof(ble_hids_client_context_t); + uint16_t max_rep_len = 0; + + if (evt_rw_auth->type != BLE_GATTS_AUTHORIZE_TYPE_READ) + { + // Unexpected operation + return; + } + + /* Update SD GATTS values of appropriate host before SD sends the Read Response */ + if (evt_rw_auth->request.read.handle == p_hids->protocol_mode_handles.value_handle) + { + on_protocol_mode_read_auth(p_hids, p_ble_evt); + } + else if (evt_rw_auth->request.read.handle == p_hids->boot_kb_inp_rep_handles.value_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, 0, 0); + max_rep_len = BOOT_KB_INPUT_REPORT_MAX_SIZE; + on_report_value_read_auth(p_hids, &char_id, p_ble_evt, rep_data_offset, max_rep_len); + } + else if (evt_rw_auth->request.read.handle == p_hids->boot_kb_outp_rep_handles.value_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR, 0, 0); + rep_data_offset += BOOT_KB_INPUT_REPORT_MAX_SIZE; + max_rep_len = BOOT_KB_OUTPUT_REPORT_MAX_SIZE; + on_report_value_read_auth(p_hids, &char_id, p_ble_evt, rep_data_offset, max_rep_len); + } + else if (evt_rw_auth->request.read.handle == p_hids->boot_mouse_inp_rep_handles.value_handle) + { + char_id = make_char_id(BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, 0, 0); + rep_data_offset += BOOT_KB_INPUT_REPORT_MAX_SIZE + BOOT_KB_OUTPUT_REPORT_MAX_SIZE; + max_rep_len = BOOT_MOUSE_INPUT_REPORT_MAX_SIZE; + on_report_value_read_auth(p_hids, &char_id, p_ble_evt, rep_data_offset, max_rep_len); + } + else if (rep_value_identify(p_hids, + evt_rw_auth->request.read.handle, + &char_id, + &rep_data_offset, + &max_rep_len)) + { + on_report_value_read_auth(p_hids, &char_id, p_ble_evt, rep_data_offset, max_rep_len); + } + else + { + // Do nothing. + } +} + + +void ble_hids_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) +{ + ble_hids_t * p_hids = (ble_hids_t *) p_context; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + on_connect(p_hids, p_ble_evt); + break; + + case BLE_GATTS_EVT_WRITE: + on_write(p_hids, p_ble_evt); + break; + + case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: + on_rw_authorize_request(p_hids, p_ble_evt); + break; + + default: + // No implementation needed. + break; + } +} + + +/**@brief Function for adding Protocol Mode characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] read_access Security requirement for reading characteristic value. + * @param[in] write_access Security requirement for writing characteristic value. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t protocol_mode_char_add(ble_hids_t * p_hids, + security_req_t read_access, + security_req_t write_access) +{ + ble_add_char_params_t add_char_params; + uint8_t initial_protocol_mode; + + initial_protocol_mode = DEFAULT_PROTOCOL_MODE; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_PROTOCOL_MODE_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = &initial_protocol_mode; + add_char_params.char_props.read = 1; + add_char_params.char_props.write_wo_resp = 1; + add_char_params.read_access = read_access; + add_char_params.write_access = write_access; + add_char_params.is_defered_read = true; + + return characteristic_add(p_hids->service_handle, + &add_char_params, + &p_hids->protocol_mode_handles); +} + + +/**@brief Function for adding report characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_properties Report characteristic properties. + * @param[in] max_len Maximum length of report value. + * @param[in] p_rep_ref Report Reference descriptor. + * @param[in] p_char_sec Characteristic security settings. + * @param[out] p_rep_char Handles of new characteristic. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t rep_char_add(ble_hids_t * p_hids, + ble_gatt_char_props_t * p_properties, + uint16_t max_len, + ble_srv_report_ref_t const * p_rep_ref, + ble_hids_char_sec_t const * const p_char_sec, + ble_hids_rep_char_t * p_rep_char) +{ + uint32_t err_code; + ble_add_char_params_t add_char_params; + ble_add_descr_params_t add_descr_params; + uint8_t encoded_rep_ref[BLE_SRV_ENCODED_REPORT_REF_LEN]; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_REPORT_CHAR; + add_char_params.max_len = max_len; + add_char_params.char_props = *p_properties; + add_char_params.read_access = p_char_sec->rd; + add_char_params.write_access = p_char_sec->wr; + add_char_params.cccd_write_access = p_char_sec->cccd_wr; + add_char_params.is_var_len = true; + add_char_params.is_defered_read = true; + + err_code = characteristic_add(p_hids->service_handle, + &add_char_params, + &p_rep_char->char_handles); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add Report Reference descriptor + memset(&add_descr_params, 0, sizeof(add_descr_params)); + add_descr_params.uuid = BLE_UUID_REPORT_REF_DESCR; + add_descr_params.read_access = p_char_sec->rd; + add_descr_params.write_access = p_char_sec->wr; + add_descr_params.init_len = ble_srv_report_ref_encode(encoded_rep_ref, p_rep_ref); + add_descr_params.max_len = add_descr_params.init_len; + add_descr_params.p_value = encoded_rep_ref; + + return descriptor_add(p_rep_char->char_handles.value_handle, + &add_descr_params, + &p_rep_char->ref_handle); +} + + +/**@brief Function for adding Report Map characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t rep_map_char_add(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init) +{ + uint32_t err_code; + ble_add_char_params_t add_char_params; + ble_add_descr_params_t add_descr_params; + + // Add Report Map characteristic + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_REPORT_MAP_CHAR; + add_char_params.max_len = p_hids_init->rep_map.data_len; + add_char_params.init_len = p_hids_init->rep_map.data_len; + add_char_params.p_init_value = p_hids_init->rep_map.p_data; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_hids_init->rep_map.rd_sec; + add_char_params.is_var_len = true; + + err_code = characteristic_add(p_hids->service_handle, + &add_char_params, + &p_hids->rep_map_handles); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + if (p_hids_init->rep_map.ext_rep_ref_num != 0 && p_hids_init->rep_map.p_ext_rep_ref == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + for (int i = 0; i < p_hids_init->rep_map.ext_rep_ref_num; ++i) + { + uint8_t encoded_rep_ref[sizeof(ble_uuid128_t)]; + uint8_t encoded_rep_ref_len; + + // Add External Report Reference descriptor + err_code = sd_ble_uuid_encode(&p_hids_init->rep_map.p_ext_rep_ref[i], + &encoded_rep_ref_len, + encoded_rep_ref); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + memset(&add_descr_params, 0, sizeof(add_descr_params)); + add_descr_params.uuid = BLE_UUID_EXTERNAL_REPORT_REF_DESCR; + add_descr_params.read_access = p_hids_init->rep_map.rd_sec; + add_descr_params.init_len = encoded_rep_ref_len; + add_descr_params.max_len = add_descr_params.init_len; + add_descr_params.p_value = encoded_rep_ref; + + err_code = descriptor_add(p_hids->rep_map_handles.value_handle, + &add_descr_params, + &p_hids->rep_map_ext_rep_ref_handle); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + return NRF_SUCCESS; +} + + +/**@brief Function for adding Input Report characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] uuid UUID of report characteristic to be added. + * @param[in] max_data_len Maximum length of report value. + * @param[in] p_char_sec Characteristic security settings. + * @param[out] p_char_handles Handles of new characteristic. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t boot_inp_rep_char_add(ble_hids_t * p_hids, + uint16_t uuid, + uint16_t max_data_len, + ble_hids_char_sec_t const * const p_char_sec, + ble_gatts_char_handles_t * p_char_handles) +{ + ble_add_char_params_t add_char_params; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = uuid; + add_char_params.max_len = max_data_len; + add_char_params.char_props.read = 1; + add_char_params.char_props.write = (p_char_sec->wr != SEC_NO_ACCESS) ? 1 : 0; + add_char_params.char_props.notify = 1; + add_char_params.read_access = p_char_sec->rd; + add_char_params.write_access = p_char_sec->wr; + add_char_params.cccd_write_access = p_char_sec->cccd_wr; + add_char_params.is_defered_read = true; + + return characteristic_add(p_hids->service_handle, + &add_char_params, + p_char_handles); +} + + +/**@brief Function for adding Boot Keyboard Output Report characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t boot_kb_outp_rep_char_add(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init) +{ + ble_add_char_params_t add_char_params; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR; + add_char_params.max_len = BOOT_KB_OUTPUT_REPORT_MAX_SIZE; + add_char_params.char_props.read = 1; + add_char_params.char_props.write = 1; + add_char_params.char_props.write_wo_resp = 1; + add_char_params.read_access = p_hids_init->boot_kb_outp_rep_sec.rd; + add_char_params.write_access = p_hids_init->boot_kb_outp_rep_sec.wr; + add_char_params.is_defered_read = true; + + return characteristic_add(p_hids->service_handle, + &add_char_params, + &p_hids->boot_kb_outp_rep_handles); +} + + +/**@brief Function for encoding a HID Information characteristic value. + * + * @param[out] p_encoded_buffer Buffer where the encoded data will be written. + * @param[in] p_hid_information Measurement to be encoded. + * + * @return Size of encoded data. + */ +static uint8_t encode_hid_information(uint8_t * p_encoded_buffer, + const ble_hids_hid_information_t * p_hid_information) +{ + uint8_t len = uint16_encode(p_hid_information->bcd_hid, p_encoded_buffer); + + p_encoded_buffer[len++] = p_hid_information->b_country_code; + p_encoded_buffer[len++] = p_hid_information->flags; + + APP_ERROR_CHECK_BOOL(len == ENCODED_HID_INFORMATION_LEN); + + return len; +} + + +/**@brief Function for adding HID Information characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t hid_information_char_add(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init) +{ + uint8_t encoded_hid_information[ENCODED_HID_INFORMATION_LEN]; + uint8_t hid_info_len; + ble_add_char_params_t add_char_params; + + hid_info_len = encode_hid_information(encoded_hid_information, &p_hids_init->hid_information); + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_HID_INFORMATION_CHAR; + add_char_params.max_len = hid_info_len; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_hids_init->hid_information.rd_sec; + add_char_params.init_len = hid_info_len; + add_char_params.p_init_value = encoded_hid_information; + + return characteristic_add(p_hids->service_handle, + &add_char_params, + &p_hids->hid_information_handles); +} + + +/**@brief Function for adding HID Control Point characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] write_access Security requirement for writing characteristic value. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t hid_control_point_char_add(ble_hids_t * p_hids, security_req_t write_access) +{ + uint8_t initial_hid_control_point; + ble_add_char_params_t add_char_params; + + initial_hid_control_point = INITIAL_VALUE_HID_CONTROL_POINT; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_HID_CONTROL_POINT_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.char_props.write_wo_resp = 1; + add_char_params.write_access = write_access; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = &initial_hid_control_point; + + return characteristic_add(p_hids->service_handle, + &add_char_params, + &p_hids->hid_control_point_handles); +} + + +/**@brief Function for adding input report characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t inp_rep_characteristics_add(ble_hids_t * p_hids, + const ble_hids_init_t * p_hids_init) +{ + if ((p_hids_init->inp_rep_count != 0) && (p_hids_init->p_inp_rep_array != NULL)) + { + uint8_t i; + + for (i = 0; i < p_hids_init->inp_rep_count; i++) + { + uint32_t err_code; + ble_hids_inp_rep_init_t const * p_rep_init = &p_hids_init->p_inp_rep_array[i]; + ble_gatt_char_props_t properties; + + memset(&properties, 0, sizeof(properties)); + + properties.read = true; + properties.write = (p_rep_init->sec.wr != SEC_NO_ACCESS) ? 1 : 0; + properties.notify = true; + + err_code = rep_char_add(p_hids, + &properties, + p_rep_init->max_len, + &p_rep_init->rep_ref, + &p_rep_init->sec, + &p_hids->inp_rep_array[i]); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + } + + return NRF_SUCCESS; +} + + +/**@brief Function for adding output report characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t outp_rep_characteristics_add(ble_hids_t * p_hids, + const ble_hids_init_t * p_hids_init) +{ + if ((p_hids_init->outp_rep_count != 0) && (p_hids_init->p_outp_rep_array != NULL)) + { + uint8_t i; + + for (i = 0; i < p_hids_init->outp_rep_count; i++) + { + uint32_t err_code; + ble_hids_outp_rep_init_t const * p_rep_init = &p_hids_init->p_outp_rep_array[i]; + ble_gatt_char_props_t properties; + + memset(&properties, 0, sizeof(properties)); + + properties.read = true; + properties.write = true; + properties.write_wo_resp = true; + + err_code = rep_char_add(p_hids, + &properties, + p_rep_init->max_len, + &p_rep_init->rep_ref, + &p_rep_init->sec, + &p_hids->outp_rep_array[i]); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + } + + return NRF_SUCCESS; +} + + +/**@brief Function for adding feature report characteristics. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t feature_rep_characteristics_add(ble_hids_t * p_hids, + const ble_hids_init_t * p_hids_init) +{ + if ((p_hids_init->feature_rep_count != 0) && (p_hids_init->p_feature_rep_array != NULL)) + { + uint8_t i; + + for (i = 0; i < p_hids_init->feature_rep_count; i++) + { + uint32_t err_code; + ble_hids_feature_rep_init_t const * p_rep_init = &p_hids_init->p_feature_rep_array[i]; + ble_gatt_char_props_t properties; + + memset(&properties, 0, sizeof(properties)); + + properties.read = true; + properties.write = true; + + err_code = rep_char_add(p_hids, + &properties, + p_rep_init->max_len, + &p_rep_init->rep_ref, + &p_rep_init->sec, + &p_hids->feature_rep_array[i]); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + } + + return NRF_SUCCESS; +} + + +/**@brief Function for adding included services. + * + * @param[in] p_hids HID Service structure. + * @param[in] p_hids_init Service initialization structure. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t includes_add(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init) +{ + uint32_t err_code; + uint8_t i; + uint16_t unused_include_handle; + + for (i = 0; i < p_hids_init->included_services_count; i++) + { + err_code = sd_ble_gatts_include_add(p_hids->service_handle, + p_hids_init->p_included_services_array[i], + &unused_include_handle); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + return NRF_SUCCESS; +} + + +uint32_t ble_hids_init(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init) +{ + VERIFY_PARAM_NOT_NULL(p_hids); + VERIFY_PARAM_NOT_NULL(p_hids_init); + + uint32_t err_code; + ble_uuid_t ble_uuid; + + if ((p_hids_init->inp_rep_count > BLE_HIDS_MAX_INPUT_REP) || + (p_hids_init->outp_rep_count > BLE_HIDS_MAX_OUTPUT_REP) || + (p_hids_init->feature_rep_count > BLE_HIDS_MAX_FEATURE_REP) + ) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Initialize service structure. + p_hids->evt_handler = p_hids_init->evt_handler; + p_hids->error_handler = p_hids_init->error_handler; + p_hids->inp_rep_count = p_hids_init->inp_rep_count; + p_hids->outp_rep_count = p_hids_init->outp_rep_count; + p_hids->feature_rep_count = p_hids_init->feature_rep_count; + + // Add service. + BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE); + + err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, + &ble_uuid, + &p_hids->service_handle); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add includes. + err_code = includes_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + if (p_hids_init->is_kb || p_hids_init->is_mouse) + { + // Add Protocol Mode characteristic. + err_code = protocol_mode_char_add(p_hids, + p_hids_init->protocol_mode_rd_sec, + p_hids_init->protocol_mode_wr_sec); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Add Input Report characteristics (if any). + err_code = inp_rep_characteristics_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add Output Report characteristics (if any). + err_code = outp_rep_characteristics_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add Feature Report characteristic (if any). + err_code = feature_rep_characteristics_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add Report Map characteristic. + err_code = rep_map_char_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + if (p_hids_init->is_kb) + { + // Add Boot Keyboard Input Report characteristic. + err_code = boot_inp_rep_char_add(p_hids, + BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR, + BOOT_KB_INPUT_REPORT_MAX_SIZE, + &p_hids_init->boot_kb_inp_rep_sec, + &p_hids->boot_kb_inp_rep_handles); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add Boot Keyboard Output Report characteristic. + err_code = boot_kb_outp_rep_char_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + if (p_hids_init->is_mouse) + { + // Add Boot Mouse Input Report characteristic. + err_code = boot_inp_rep_char_add(p_hids, + BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR, + BOOT_MOUSE_INPUT_REPORT_MAX_SIZE, + &p_hids_init->boot_mouse_inp_rep_sec, + &p_hids->boot_mouse_inp_rep_handles); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Add HID Information characteristic. + err_code = hid_information_char_add(p_hids, p_hids_init); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add HID Control Point characteristic. + err_code = hid_control_point_char_add(p_hids, p_hids_init->ctrl_point_wr_sec); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Set pointers to user-defined report arrays + p_hids->p_inp_rep_init_array = p_hids_init->p_inp_rep_array; + p_hids->p_outp_rep_init_array = p_hids_init->p_outp_rep_array; + p_hids->p_feature_rep_init_array = p_hids_init->p_feature_rep_array; + + return err_code; +} + + +uint32_t ble_hids_inp_rep_send(ble_hids_t * p_hids, + uint8_t rep_index, + uint16_t len, + uint8_t * p_data, + uint16_t conn_handle) +{ + VERIFY_PARAM_NOT_NULL(p_hids); + VERIFY_PARAM_NOT_NULL(p_data); + + uint32_t err_code; + + if (rep_index < p_hids->inp_rep_count) + { + ble_hids_rep_char_t * p_rep_char = &p_hids->inp_rep_array[rep_index]; + + if (conn_handle != BLE_CONN_HANDLE_INVALID) + { + ble_gatts_hvx_params_t hvx_params; + uint8_t index = 0; + uint16_t hvx_len = len; + uint8_t * p_host_rep_data; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + conn_handle, + (void *) &p_host_rep_data); + VERIFY_SUCCESS(err_code); + + p_host_rep_data += sizeof(ble_hids_client_context_t) + BOOT_KB_INPUT_REPORT_MAX_SIZE + + BOOT_KB_OUTPUT_REPORT_MAX_SIZE + BOOT_MOUSE_INPUT_REPORT_MAX_SIZE; + + // Store the new report data in host's context + while (index < rep_index) + { + p_host_rep_data += p_hids->p_inp_rep_init_array[index].max_len; + ++index; + } + + if (len <= p_hids->p_inp_rep_init_array[rep_index].max_len) + { + memcpy(p_host_rep_data, p_data, len); + } + else + { + return NRF_ERROR_DATA_SIZE; + } + + // Notify host + memset(&hvx_params, 0, sizeof(hvx_params)); + + hvx_params.handle = p_rep_char->char_handles.value_handle; + hvx_params.type = BLE_GATT_HVX_NOTIFICATION; + hvx_params.offset = 0; + hvx_params.p_len = &hvx_len; + hvx_params.p_data = p_data; + + err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params); + if ((err_code == NRF_SUCCESS) && (*hvx_params.p_len != len)) + { + err_code = NRF_ERROR_DATA_SIZE; + } + } + else + { + err_code = NRF_ERROR_INVALID_STATE; + } + } + else + { + err_code = NRF_ERROR_INVALID_PARAM; + } + + return err_code; +} + + +uint32_t ble_hids_boot_kb_inp_rep_send(ble_hids_t * p_hids, + uint16_t len, + uint8_t * p_data, + uint16_t conn_handle) +{ + VERIFY_PARAM_NOT_NULL(p_hids); + VERIFY_PARAM_NOT_NULL(p_data); + + uint32_t err_code; + + if (conn_handle != BLE_CONN_HANDLE_INVALID) + { + ble_gatts_hvx_params_t hvx_params; + uint16_t hvx_len = len; + uint8_t * p_host_rep_data; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + conn_handle, + (void *) &p_host_rep_data); + VERIFY_SUCCESS(err_code); + + p_host_rep_data += sizeof(ble_hids_client_context_t); + + // Store the new value in the host's context + if (len <= BOOT_KB_INPUT_REPORT_MAX_SIZE) + { + memcpy(p_host_rep_data, p_data, len); + } + + // Notify host + memset(&hvx_params, 0, sizeof(hvx_params)); + + hvx_params.handle = p_hids->boot_kb_inp_rep_handles.value_handle; + hvx_params.type = BLE_GATT_HVX_NOTIFICATION; + hvx_params.offset = 0; + hvx_params.p_len = &hvx_len; + hvx_params.p_data = p_data; + + err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params); + if ((err_code == NRF_SUCCESS) && (*hvx_params.p_len != len)) + { + err_code = NRF_ERROR_DATA_SIZE; + } + } + else + { + err_code = NRF_ERROR_INVALID_STATE; + } + + return err_code; +} + + +uint32_t ble_hids_boot_mouse_inp_rep_send(ble_hids_t * p_hids, + uint8_t buttons, + int8_t x_delta, + int8_t y_delta, + uint16_t optional_data_len, + uint8_t * p_optional_data, + uint16_t conn_handle) +{ + VERIFY_PARAM_NOT_NULL(p_hids); + + uint32_t err_code; + + if (conn_handle != BLE_CONN_HANDLE_INVALID) + { + uint16_t hvx_len = BOOT_MOUSE_INPUT_REPORT_MIN_SIZE + optional_data_len; + + if (hvx_len <= BOOT_MOUSE_INPUT_REPORT_MAX_SIZE) + { + uint8_t buffer[BOOT_MOUSE_INPUT_REPORT_MAX_SIZE]; + ble_gatts_hvx_params_t hvx_params; + uint8_t * p_host_rep_data; + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + conn_handle, + (void *) &p_host_rep_data); + VERIFY_SUCCESS(err_code); + + p_host_rep_data += sizeof(ble_hids_client_context_t) + BOOT_KB_INPUT_REPORT_MAX_SIZE + + BOOT_KB_OUTPUT_REPORT_MAX_SIZE; + + APP_ERROR_CHECK_BOOL(BOOT_MOUSE_INPUT_REPORT_MIN_SIZE == 3); + + // Build buffer + buffer[0] = buttons; + buffer[1] = (uint8_t)x_delta; + buffer[2] = (uint8_t)y_delta; + + if (optional_data_len > 0) + { + memcpy(&buffer[3], p_optional_data, optional_data_len); + } + + // Store the new value in the host's context + memcpy(p_host_rep_data, buffer, hvx_len); + + // Pass buffer to stack + memset(&hvx_params, 0, sizeof(hvx_params)); + + hvx_params.handle = p_hids->boot_mouse_inp_rep_handles.value_handle; + hvx_params.type = BLE_GATT_HVX_NOTIFICATION; + hvx_params.offset = 0; + hvx_params.p_len = &hvx_len; + hvx_params.p_data = buffer; + + err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params); + if ((err_code == NRF_SUCCESS) && + (*hvx_params.p_len != BOOT_MOUSE_INPUT_REPORT_MIN_SIZE + optional_data_len) + ) + { + err_code = NRF_ERROR_DATA_SIZE; + } + } + else + { + err_code = NRF_ERROR_DATA_SIZE; + } + } + else + { + err_code = NRF_ERROR_INVALID_STATE; + } + + return err_code; +} + + +uint32_t ble_hids_outp_rep_get(ble_hids_t * p_hids, + uint8_t rep_index, + uint16_t len, + uint8_t offset, + uint16_t conn_handle, + uint8_t * p_outp_rep) +{ + VERIFY_PARAM_NOT_NULL(p_hids); + VERIFY_PARAM_NOT_NULL(p_outp_rep); + + ret_code_t err_code; + uint8_t * p_rep_data; + uint8_t index; + + if (rep_index >= p_hids->outp_rep_count) + { + return NRF_ERROR_INVALID_PARAM; + } + + err_code = blcm_link_ctx_get(p_hids->p_link_ctx_storage, + conn_handle, + (void *) &p_rep_data); + VERIFY_SUCCESS(err_code); + + p_rep_data += sizeof(ble_hids_client_context_t) + BOOT_KB_INPUT_REPORT_MAX_SIZE + + BOOT_KB_OUTPUT_REPORT_MAX_SIZE + BOOT_MOUSE_INPUT_REPORT_MAX_SIZE; + + for (index = 0; index < p_hids->inp_rep_count; index++) + { + p_rep_data += p_hids->p_inp_rep_init_array[index].max_len; + } + + for (index = 0; index < rep_index; index++) + { + p_rep_data += p_hids->p_outp_rep_init_array[index].max_len; + } + + // Copy the requested output report data + if (len + offset <= p_hids->p_outp_rep_init_array[rep_index].max_len) + { + memcpy(p_outp_rep, p_rep_data + offset, len); + } + else + { + return NRF_ERROR_INVALID_LENGTH; + } + + return NRF_SUCCESS; +} + + +/** + @} + */ +#endif // NRF_MODULE_ENABLED(BLE_HIDS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.h similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.h index e963d05..2abcb6b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hids/ble_hids.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hids/ble_hids.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -75,22 +75,65 @@ #include #include "ble.h" #include "ble_srv_common.h" +#include "ble_link_ctx_manager.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus extern "C" { #endif -/**@brief Macro for defining a ble_hids instance. +/**@brief Allocate static data for keeping host connection contexts. + * + * @param _name Name of BLE HIDS instance. + * @param[in] _hids_max_clients Maximum number of HIDS clients connected at a time. + * @param[in] ... Lengths of HIDS reports. * - * @param _name Name of the instance. + * @details + * Mapping of HIDS reports in the HIDS report context: + * - Structure of type @ref ble_hids_client_context_t + * - Boot keyboard input report + * - Boot keyboard output report + * - Boot mouse input report + * - Input reports + * - Output reports + * - Feature reports * @hideinitializer */ -#define BLE_HIDS_DEF(_name) \ -static ble_hids_t _name; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - BLE_HIDS_BLE_OBSERVER_PRIO, \ - ble_hids_on_ble_evt, &_name) +#define BLE_HIDS_DEF(_name, \ + _hids_max_clients, \ + ...) \ + BLE_LINK_CTX_MANAGER_DEF(CONCAT_2(_name, _link_ctx_storage), \ + (_hids_max_clients), \ + BLE_HIDS_LINK_CTX_SIZE_CALC(__VA_ARGS__)); \ + static ble_hids_t _name = \ + { \ + .p_link_ctx_storage = &CONCAT_2(_name, _link_ctx_storage) \ + }; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_HIDS_BLE_OBSERVER_PRIO, \ + ble_hids_on_ble_evt, \ + &_name) + +/**@brief Helping macro for @ref BLE_HIDS_DEF, that calculates the link context size for BLE HIDS + * instance. + * + * @param[in] ... Lengths of HIDS reports + * @hideinitializer + */ +#define BLE_HIDS_LINK_CTX_SIZE_CALC(...) \ + (sizeof(ble_hids_client_context_t) + \ + MACRO_MAP_REC(BLE_HIDS_REPORT_ADD, __VA_ARGS__) \ + (BOOT_KB_INPUT_REPORT_MAX_SIZE) + \ + (BOOT_KB_OUTPUT_REPORT_MAX_SIZE) + \ + (BOOT_MOUSE_INPUT_REPORT_MAX_SIZE)) \ + +/**@brief Helping macro for @ref BLE_HIDS_LINK_CTX_SIZE_CALC, that adds Input/Output/Feature report + * lengths. + * + * @param[in] _report_size Length of the specific report. + * @hideinitializer + */ +#define BLE_HIDS_REPORT_ADD(_report_size) (_report_size) + /** @name Report Type values * @anchor BLE_HIDS_REPORT_TYPE @{ @@ -110,6 +153,11 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, #define HID_INFO_FLAG_REMOTE_WAKE_MSK 0x01 #define HID_INFO_FLAG_NORMALLY_CONNECTABLE_MSK 0x02 +#define BOOT_KB_INPUT_REPORT_MAX_SIZE 8 /**< Maximum size of a Boot Keyboard Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ +#define BOOT_KB_OUTPUT_REPORT_MAX_SIZE 1 /**< Maximum size of a Boot Keyboard Output Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ +#define BOOT_MOUSE_INPUT_REPORT_MIN_SIZE 3 /**< Minimum size of a Boot Mouse Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ +#define BOOT_MOUSE_INPUT_REPORT_MAX_SIZE 8 /**< Maximum size of a Boot Mouse Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11). */ + /**@brief HID Service characteristic id. */ typedef struct { @@ -146,7 +194,7 @@ typedef struct ble_hids_char_id_t char_id; /**< Id of characteristic having been written. */ uint16_t offset; /**< Offset for the write operation. */ uint16_t len; /**< Length of the incoming data. */ - uint8_t* data; /**< Incoming data, variable length */ + uint8_t const * data; /**< Incoming data, variable length */ } char_write; struct { @@ -162,13 +210,21 @@ typedef struct ble_hids_s ble_hids_t; /**@brief HID Service event handler type. */ typedef void (*ble_hids_evt_handler_t) (ble_hids_t * p_hids, ble_hids_evt_t * p_evt); +/**@brief Security requirements for HID Service characteristic. */ +typedef struct +{ + security_req_t rd; /**< Security requirement for reading HID Service characteristic value. */ + security_req_t wr; /**< Security requirement for writing HID Service characteristic value. */ + security_req_t cccd_wr; /**< Security requirement for writing HID Service characteristic CCCD. */ +} ble_hids_char_sec_t; + /**@brief HID Information characteristic value. */ typedef struct { uint16_t bcd_hid; /**< 16-bit unsigned integer representing version number of base USB HID Specification implemented by HID Device */ uint8_t b_country_code; /**< Identifies which country the hardware is localized for. Most hardware is not localized and thus this value would be zero (0). */ uint8_t flags; /**< See http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.hid_information.xml */ - ble_srv_security_mode_t security_mode; /**< Security mode for the HID Information characteristic. */ + security_req_t rd_sec; /**< Security requirement for reading HID Information characteristic value. */ } ble_hids_hid_information_t; /**@brief HID Service Input Report characteristic init structure. This contains all options and @@ -177,8 +233,7 @@ typedef struct { uint16_t max_len; /**< Maximum length of characteristic value. */ ble_srv_report_ref_t rep_ref; /**< Value of the Report Reference descriptor. */ - ble_srv_cccd_security_mode_t security_mode; /**< Security mode for the HID Input Report characteristic, including cccd. */ - uint8_t read_resp : 1; /**< Should application generate a response to read requests. */ + ble_hids_char_sec_t sec; /**< Security requirements for HID Service Input Report characteristic. */ } ble_hids_inp_rep_init_t; /**@brief HID Service Output Report characteristic init structure. This contains all options and @@ -187,8 +242,7 @@ typedef struct { uint16_t max_len; /**< Maximum length of characteristic value. */ ble_srv_report_ref_t rep_ref; /**< Value of the Report Reference descriptor. */ - ble_srv_cccd_security_mode_t security_mode; /**< Security mode for the HID Output Report characteristic, including cccd. */ - uint8_t read_resp : 1; /**< Should application generate a response to read requests. */ + ble_hids_char_sec_t sec; /**< Security requirements for HID Service Output Report characteristic. */ } ble_hids_outp_rep_init_t; /**@brief HID Service Feature Report characteristic init structure. This contains all options and @@ -197,8 +251,7 @@ typedef struct { uint16_t max_len; /**< Maximum length of characteristic value. */ ble_srv_report_ref_t rep_ref; /**< Value of the Report Reference descriptor. */ - ble_srv_cccd_security_mode_t security_mode; /**< Security mode for the HID Service Feature Report characteristic, including cccd. */ - uint8_t read_resp : 1; /**< Should application generate a response to read requests. */ + ble_hids_char_sec_t sec; /**< Security requirements for HID Service Feature Report characteristic. */ } ble_hids_feature_rep_init_t; /**@brief HID Service Report Map characteristic init structure. This contains all options and data @@ -208,8 +261,8 @@ typedef struct uint8_t * p_data; /**< Report map data. */ uint16_t data_len; /**< Length of report map data. */ uint8_t ext_rep_ref_num; /**< Number of Optional External Report Reference descriptors. */ - ble_uuid_t * p_ext_rep_ref; /**< Optional External Report Reference descriptor (will be added if != NULL). */ - ble_srv_security_mode_t security_mode; /**< Security mode for the HID Service Report Map characteristic. */ + ble_uuid_t const * p_ext_rep_ref; /**< Optional External Report Reference descriptor (will be added if != NULL). */ + security_req_t rd_sec; /**< Security requirement for HID Service Report Map characteristic. */ } ble_hids_rep_map_init_t; /**@brief HID Report characteristic structure. */ @@ -219,55 +272,65 @@ typedef struct uint16_t ref_handle; /**< Handle of the Report Reference descriptor. */ } ble_hids_rep_char_t; +/**@brief HID Host context structure. It keeps information relevant to a single host. */ +typedef struct +{ + uint8_t protocol_mode; /**< Protocol mode. */ + uint8_t ctrl_pt; /**< HID Control Point. */ +} ble_hids_client_context_t; + /**@brief HID Service init structure. This contains all options and data needed for initialization * of the service. */ typedef struct { - ble_hids_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the HID Service. */ - ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ - bool is_kb; /**< TRUE if device is operating as a keyboard, FALSE if it is not. */ - bool is_mouse; /**< TRUE if device is operating as a mouse, FALSE if it is not. */ - uint8_t inp_rep_count; /**< Number of Input Report characteristics. */ - ble_hids_inp_rep_init_t * p_inp_rep_array; /**< Information about the Input Report characteristics. */ - uint8_t outp_rep_count; /**< Number of Output Report characteristics. */ - ble_hids_outp_rep_init_t * p_outp_rep_array; /**< Information about the Output Report characteristics. */ - uint8_t feature_rep_count; /**< Number of Feature Report characteristics. */ - ble_hids_feature_rep_init_t * p_feature_rep_array; /**< Information about the Feature Report characteristics. */ - ble_hids_rep_map_init_t rep_map; /**< Information nedeed for initialization of the Report Map characteristic. */ - ble_hids_hid_information_t hid_information; /**< Value of the HID Information characteristic. */ - uint8_t included_services_count; /**< Number of services to include in HID service. */ - uint16_t * p_included_services_array; /**< Array of services to include in HID service. */ - ble_srv_security_mode_t security_mode_protocol; /**< Security settings for HID service protocol attribute */ - ble_srv_security_mode_t security_mode_ctrl_point; /**< Security settings for HID service Control Point attribute */ - ble_srv_cccd_security_mode_t security_mode_boot_mouse_inp_rep; /**< Security settings for HID service Mouse input report attribute */ - ble_srv_cccd_security_mode_t security_mode_boot_kb_inp_rep; /**< Security settings for HID service Keyboard input report attribute */ - ble_srv_security_mode_t security_mode_boot_kb_outp_rep; /**< Security settings for HID service Keyboard output report attribute */ + ble_hids_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the HID Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + bool is_kb; /**< TRUE if device is operating as a keyboard, FALSE if it is not. */ + bool is_mouse; /**< TRUE if device is operating as a mouse, FALSE if it is not. */ + uint8_t inp_rep_count; /**< Number of Input Report characteristics. */ + ble_hids_inp_rep_init_t const * p_inp_rep_array; /**< Information about the Input Report characteristics. */ + uint8_t outp_rep_count; /**< Number of Output Report characteristics. */ + ble_hids_outp_rep_init_t const * p_outp_rep_array; /**< Information about the Output Report characteristics. */ + uint8_t feature_rep_count; /**< Number of Feature Report characteristics. */ + ble_hids_feature_rep_init_t const * p_feature_rep_array; /**< Information about the Feature Report characteristics. */ + ble_hids_rep_map_init_t rep_map; /**< Information nedeed for initialization of the Report Map characteristic. */ + ble_hids_hid_information_t hid_information; /**< Value of the HID Information characteristic. */ + uint8_t included_services_count; /**< Number of services to include in HID service. */ + uint16_t * p_included_services_array; /**< Array of services to include in HID service. */ + security_req_t protocol_mode_rd_sec; /**< Security requirement for reading HID service Protocol Mode characteristic. */ + security_req_t protocol_mode_wr_sec; /**< Security requirement for writing HID service Protocol Mode characteristic. */ + security_req_t ctrl_point_wr_sec; /**< Security requirement for writing HID service Control Point characteristic. */ + ble_hids_char_sec_t boot_mouse_inp_rep_sec; /**< Security requirements for HID Boot Keyboard Input Report characteristic. */ + ble_hids_char_sec_t boot_kb_inp_rep_sec; /**< Security requirements for HID Boot Keyboard Input Report characteristic. */ + ble_hids_char_sec_t boot_kb_outp_rep_sec; /**< Security requirements for HID Boot Keyboard Output Report characteristic. */ } ble_hids_init_t; /**@brief HID Service structure. This contains various status information for the service. */ struct ble_hids_s { - ble_hids_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the HID Service. */ - ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ - uint16_t service_handle; /**< Handle of HID Service (as provided by the BLE stack). */ - ble_gatts_char_handles_t protocol_mode_handles; /**< Handles related to the Protocol Mode characteristic (will only be created if ble_hids_init_t.is_kb or ble_hids_init_t.is_mouse is set). */ - uint8_t inp_rep_count; /**< Number of Input Report characteristics. */ - ble_hids_rep_char_t inp_rep_array[BLE_HIDS_MAX_INPUT_REP]; /**< Information about the Input Report characteristics. */ - uint8_t outp_rep_count; /**< Number of Output Report characteristics. */ - ble_hids_rep_char_t outp_rep_array[BLE_HIDS_MAX_OUTPUT_REP]; /**< Information about the Output Report characteristics. */ - uint8_t feature_rep_count; /**< Number of Feature Report characteristics. */ - ble_hids_rep_char_t feature_rep_array[BLE_HIDS_MAX_FEATURE_REP]; /**< Information about the Feature Report characteristics. */ - ble_gatts_char_handles_t rep_map_handles; /**< Handles related to the Report Map characteristic. */ - uint16_t rep_map_ext_rep_ref_handle; /**< Handle of the Report Map External Report Reference descriptor. */ - ble_gatts_char_handles_t boot_kb_inp_rep_handles; /**< Handles related to the Boot Keyboard Input Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */ - ble_gatts_char_handles_t boot_kb_outp_rep_handles; /**< Handles related to the Boot Keyboard Output Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */ - ble_gatts_char_handles_t boot_mouse_inp_rep_handles; /**< Handles related to the Boot Mouse Input Report characteristic (will only be created if ble_hids_init_t.is_mouse is set). */ - ble_gatts_char_handles_t hid_information_handles; /**< Handles related to the Report Map characteristic. */ - ble_gatts_char_handles_t hid_control_point_handles; /**< Handles related to the Report Map characteristic. */ - uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ + ble_hids_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the HID Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + uint16_t service_handle; /**< Handle of HID Service (as provided by the BLE stack). */ + ble_gatts_char_handles_t protocol_mode_handles; /**< Handles related to the Protocol Mode characteristic (will only be created if ble_hids_init_t.is_kb or ble_hids_init_t.is_mouse is set). */ + uint8_t inp_rep_count; /**< Number of Input Report characteristics. */ + ble_hids_rep_char_t inp_rep_array[BLE_HIDS_MAX_INPUT_REP]; /**< Information about the Input Report characteristics. */ + uint8_t outp_rep_count; /**< Number of Output Report characteristics. */ + ble_hids_rep_char_t outp_rep_array[BLE_HIDS_MAX_OUTPUT_REP]; /**< Information about the Output Report characteristics. */ + uint8_t feature_rep_count; /**< Number of Feature Report characteristics. */ + ble_hids_rep_char_t feature_rep_array[BLE_HIDS_MAX_FEATURE_REP]; /**< Information about the Feature Report characteristics. */ + ble_gatts_char_handles_t rep_map_handles; /**< Handles related to the Report Map characteristic. */ + uint16_t rep_map_ext_rep_ref_handle; /**< Handle of the Report Map External Report Reference descriptor. */ + ble_gatts_char_handles_t boot_kb_inp_rep_handles; /**< Handles related to the Boot Keyboard Input Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */ + ble_gatts_char_handles_t boot_kb_outp_rep_handles; /**< Handles related to the Boot Keyboard Output Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */ + ble_gatts_char_handles_t boot_mouse_inp_rep_handles; /**< Handles related to the Boot Mouse Input Report characteristic (will only be created if ble_hids_init_t.is_mouse is set). */ + ble_gatts_char_handles_t hid_information_handles; /**< Handles related to the Report Map characteristic. */ + ble_gatts_char_handles_t hid_control_point_handles; /**< Handles related to the Report Map characteristic. */ + blcm_link_ctx_storage_t * const p_link_ctx_storage; /**< Link context storage with handles of all current connections and its data context. */ + ble_hids_inp_rep_init_t const * p_inp_rep_init_array; /**< Pointer to information about the Input Report characteristics. */ + ble_hids_outp_rep_init_t const * p_outp_rep_init_array; /**< Pointer to information about the Output Report characteristics. */ + ble_hids_feature_rep_init_t const * p_feature_rep_init_array; /**< Pointer to information about the Feature Report characteristics. */ }; - /**@brief Function for initializing the HID Service. * * @param[out] p_hids HID Service structure. This structure will have to be supplied by the @@ -279,7 +342,6 @@ struct ble_hids_s */ uint32_t ble_hids_init(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init); - /**@brief Function for handling the Application's BLE Stack events. * * @details Handles all events from the BLE stack of interest to the HID Service. @@ -289,7 +351,6 @@ uint32_t ble_hids_init(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init) */ void ble_hids_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); - /**@brief Function for sending Input Report. * * @details Sends data on an Input Report characteristic. @@ -299,14 +360,15 @@ void ble_hids_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); * ble_hids_t.inp_rep_array as passed to ble_hids_init()). * @param[in] len Length of data to be sent. * @param[in] p_data Pointer to data to be sent. + * @param[in] conn_handle Connection handle, where the notification will be sent. * * @return NRF_SUCCESS on successful sending of input report, otherwise an error code. */ uint32_t ble_hids_inp_rep_send(ble_hids_t * p_hids, uint8_t rep_index, uint16_t len, - uint8_t * p_data); - + uint8_t * p_data, + uint16_t conn_handle); /**@brief Function for sending Boot Keyboard Input Report. * @@ -315,13 +377,14 @@ uint32_t ble_hids_inp_rep_send(ble_hids_t * p_hids, * @param[in] p_hids HID Service structure. * @param[in] len Length of data to be sent. * @param[in] p_data Pointer to data to be sent. + * @param[in] conn_handle Connection handle, where the notification will be sent. * * @return NRF_SUCCESS on successful sending of the report, otherwise an error code. */ uint32_t ble_hids_boot_kb_inp_rep_send(ble_hids_t * p_hids, uint16_t len, - uint8_t * p_data); - + uint8_t * p_data, + uint16_t conn_handle); /**@brief Function for sending Boot Mouse Input Report. * @@ -333,6 +396,7 @@ uint32_t ble_hids_boot_kb_inp_rep_send(ble_hids_t * p_hids, * @param[in] y_delta Vertical movement. * @param[in] optional_data_len Length of optional part of Boot Mouse Input Report. * @param[in] p_optional_data Optional part of Boot Mouse Input Report. + * @param[in] conn_handle Connection handle. * * @return NRF_SUCCESS on successful sending of the report, otherwise an error code. */ @@ -341,8 +405,8 @@ uint32_t ble_hids_boot_mouse_inp_rep_send(ble_hids_t * p_hids, int8_t x_delta, int8_t y_delta, uint16_t optional_data_len, - uint8_t * p_optional_data); - + uint8_t * p_optional_data, + uint16_t conn_handle); /**@brief Function for getting the current value of Output Report from the stack. * @@ -353,6 +417,7 @@ uint32_t ble_hids_boot_mouse_inp_rep_send(ble_hids_t * p_hids, * ble_hids_t.outp_rep_array as passed to ble_hids_init()). * @param[in] len Length of output report needed. * @param[in] offset Offset in bytes to read from. + * @param[in] conn_handle Connection handle. * @param[out] p_outp_rep Pointer to the output report. * * @return NRF_SUCCESS on successful read of the report, otherwise an error code. @@ -361,7 +426,8 @@ uint32_t ble_hids_outp_rep_get(ble_hids_t * p_hids, uint8_t rep_index, uint16_t len, uint8_t offset, - uint8_t * p_outp_rep); + uint16_t conn_handle, + uint8_t * p_outp_rep); #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs/ble_hrs.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs/ble_hrs.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs/ble_hrs.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs/ble_hrs.c index 1524651..25dcebd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs/ble_hrs.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs/ble_hrs.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -217,119 +217,12 @@ static uint8_t hrm_encode(ble_hrs_t * p_hrs, uint16_t heart_rate, uint8_t * p_en } -/**@brief Function for adding the Heart Rate Measurement characteristic. - * - * @param[in] p_hrs Heart Rate Service structure. - * @param[in] p_hrs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t heart_rate_measurement_char_add(ble_hrs_t * p_hrs, - const ble_hrs_init_t * p_hrs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t encoded_initial_hrm[MAX_HRM_LEN]; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_hrs_init->hrs_hrm_attr_md.cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_MEASUREMENT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_hrs_init->hrs_hrm_attr_md.read_perm; - attr_md.write_perm = p_hrs_init->hrs_hrm_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = hrm_encode(p_hrs, INITIAL_VALUE_HRM, encoded_initial_hrm); - attr_char_value.init_offs = 0; - attr_char_value.max_len = MAX_HRM_LEN; - attr_char_value.p_value = encoded_initial_hrm; - - return sd_ble_gatts_characteristic_add(p_hrs->service_handle, - &char_md, - &attr_char_value, - &p_hrs->hrm_handles); -} - - -/**@brief Function for adding the Body Sensor Location characteristic. - * - * @param[in] p_hrs Heart Rate Service structure. - * @param[in] p_hrs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t body_sensor_location_char_add(ble_hrs_t * p_hrs, const ble_hrs_init_t * p_hrs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BODY_SENSOR_LOCATION_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_hrs_init->hrs_bsl_attr_md.read_perm; - attr_md.write_perm = p_hrs_init->hrs_bsl_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint8_t); - attr_char_value.p_value = p_hrs_init->p_body_sensor_location; - - return sd_ble_gatts_characteristic_add(p_hrs->service_handle, - &char_md, - &attr_char_value, - &p_hrs->bsl_handles); -} - - uint32_t ble_hrs_init(ble_hrs_t * p_hrs, const ble_hrs_init_t * p_hrs_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + uint32_t err_code; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; + uint8_t encoded_initial_hrm[MAX_HRM_LEN]; // Initialize service structure p_hrs->evt_handler = p_hrs_init->evt_handler; @@ -352,7 +245,17 @@ uint32_t ble_hrs_init(ble_hrs_t * p_hrs, const ble_hrs_init_t * p_hrs_init) } // Add heart rate measurement characteristic - err_code = heart_rate_measurement_char_add(p_hrs, p_hrs_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_HEART_RATE_MEASUREMENT_CHAR; + add_char_params.max_len = MAX_HRM_LEN; + add_char_params.init_len = hrm_encode(p_hrs, INITIAL_VALUE_HRM, encoded_initial_hrm); + add_char_params.p_init_value = encoded_initial_hrm; + add_char_params.is_var_len = true; + add_char_params.char_props.notify = 1; + add_char_params.cccd_write_access = p_hrs_init->hrm_cccd_wr_sec; + + err_code = characteristic_add(p_hrs->service_handle, &add_char_params, &(p_hrs->hrm_handles)); if (err_code != NRF_SUCCESS) { return err_code; @@ -361,7 +264,16 @@ uint32_t ble_hrs_init(ble_hrs_t * p_hrs, const ble_hrs_init_t * p_hrs_init) if (p_hrs_init->p_body_sensor_location != NULL) { // Add body sensor location characteristic - err_code = body_sensor_location_char_add(p_hrs, p_hrs_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_BODY_SENSOR_LOCATION_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = p_hrs_init->p_body_sensor_location; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_hrs_init->bsl_rd_sec; + + err_code = characteristic_add(p_hrs->service_handle, &add_char_params, &(p_hrs->bsl_handles)); if (err_code != NRF_SUCCESS) { return err_code; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs/ble_hrs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs/ble_hrs.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs/ble_hrs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs/ble_hrs.h index 3c3ce87..9a2620d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs/ble_hrs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs/ble_hrs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -136,8 +136,8 @@ typedef struct ble_hrs_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Heart Rate Service. */ bool is_sensor_contact_supported; /**< Determines if sensor contact detection is to be supported. */ uint8_t * p_body_sensor_location; /**< If not NULL, initial value of the Body Sensor Location characteristic. */ - ble_srv_cccd_security_mode_t hrs_hrm_attr_md; /**< Initial security level for heart rate service measurement attribute */ - ble_srv_security_mode_t hrs_bsl_attr_md; /**< Initial security level for body sensor location attribute */ + security_req_t hrm_cccd_wr_sec; /**< Security requirement for writing the HRM characteristic CCCD. */ + security_req_t bsl_rd_sec; /**< Security requirement for reading the BSL characteristic value. */ } ble_hrs_init_t; /**@brief Heart Rate Service structure. This contains various status information for the service. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c index 8f62f2f..45247f7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs_c/ble_hrs_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /**@cond To Make Doxygen skip documentation generation for this file. * @{ @@ -45,7 +45,6 @@ #include "ble_hrs_c.h" #include "ble_db_discovery.h" #include "ble_types.h" -#include "ble_srv_common.h" #include "ble_gattc.h" #define NRF_LOG_MODULE_NAME ble_hrs_c @@ -55,100 +54,33 @@ NRF_LOG_MODULE_REGISTER(); #define HRM_FLAG_MASK_HR_16BIT (0x01 << 0) /**< Bit mask used to extract the type of heart rate value. This is used to find if the received heart rate is a 16 bit value or an 8 bit value. */ #define HRM_FLAG_MASK_HR_RR_INT (0x01 << 4) /**< Bit mask used to extract the presence of RR_INTERVALS. This is used to find if the received measurement includes RR_INTERVALS. */ -#define TX_BUFFER_MASK 0x07 /**< TX Buffer mask, must be a mask of continuous zeroes, followed by continuous sequence of ones: 000...111. */ -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of send buffer, which is 1 higher than the mask. */ -#define WRITE_MESSAGE_LENGTH BLE_CCCD_VALUE_LEN /**< Length of the write message for CCCD. */ -#define WRITE_MESSAGE_LENGTH BLE_CCCD_VALUE_LEN /**< Length of the write message for CCCD. */ - -typedef enum -{ - READ_REQ, /**< Type identifying that this tx_message is a read request. */ - WRITE_REQ /**< Type identifying that this tx_message is a write request. */ -} tx_request_t; - -/**@brief Structure for writing a message to the peer, i.e. CCCD. - */ -typedef struct -{ - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; /**< The message to write. */ - ble_gattc_write_params_t gattc_params; /**< GATTC parameters for this message. */ -} write_params_t; - -/**@brief Structure for holding data to be transmitted to the connected central. +/**@brief Function for interception of the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. */ -typedef struct +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) { - uint16_t conn_handle; /**< Connection handle to be used when transmitting this message. */ - tx_request_t type; /**< Type of this message, i.e. read or write message. */ - union - { - uint16_t read_handle; /**< Read request message. */ - write_params_t write_req; /**< Write request message. */ - } req; -} tx_message_t; - + ble_hrs_c_t * p_ble_hrs_c = (ble_hrs_c_t *)p_ctx; -static tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for messages to be transmitted to the central. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where the next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer from where the next message to be transmitted resides. */ + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); - -/**@brief Function for passing any pending request from the buffer to the stack. - */ -static void tx_buffer_process(void) -{ - if (m_tx_index != m_tx_insert_index) + if (p_ble_hrs_c->error_handler != NULL) { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - m_tx_index++; - m_tx_index &= TX_BUFFER_MASK; - } - else - { - NRF_LOG_DEBUG("SD Read/Write API returns error. This message sending will be " - "attempted again.."); - } - } -} - - -/**@brief Function for handling write response events. - * - * @param[in] p_ble_hrs_c Pointer to the Heart Rate Client structure. - * @param[in] p_ble_evt Pointer to the BLE event received. - */ -static void on_write_rsp(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt) -{ - // Check if the event if on the link for this instance - if (p_ble_hrs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) - { - return; + p_ble_hrs_c->error_handler(nrf_error); } - // Check if there is any message to be sent across to the peer and send it. - tx_buffer_process(); } /**@brief Function for handling Handle Value Notification received from the SoftDevice. * - * @details This function will uses the Handle Value Notification received from the SoftDevice - * and checks if it is a notification of the heart rate measurement from the peer. If - * it is, this function will decode the heart rate measurement and send it to the + * @details This function uses the Handle Value Notification received from the SoftDevice + * and checks whether it is a notification of the heart rate measurement from the peer. If + * it is, this function decodes the heart rate measurement and sends it to the * application. * * @param[in] p_ble_hrs_c Pointer to the Heart Rate Client structure. @@ -156,10 +88,10 @@ static void on_write_rsp(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt) */ static void on_hvx(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt) { - // Check if the event is on the link for this instance + // Check if the event is on the link for this instance. if (p_ble_hrs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { - NRF_LOG_DEBUG("Received HVX on link 0x%x, not associated to this instance, ignore", + NRF_LOG_DEBUG("Received HVX on link 0x%x, not associated to this instance. Ignore.", p_ble_evt->evt.gattc_evt.conn_handle); return; } @@ -180,12 +112,12 @@ static void on_hvx(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt) if (!(p_ble_evt->evt.gattc_evt.params.hvx.data[index++] & HRM_FLAG_MASK_HR_16BIT)) { - // 8 Bit heart rate value received. + // 8-bit heart rate value received. ble_hrs_c_evt.params.hrm.hr_value = p_ble_evt->evt.gattc_evt.params.hvx.data[index++]; //lint !e415 suppress Lint Warning 415: Likely access out of bond } else { - // 16 bit heart rate value received. + // 16-bit heart rate value received. ble_hrs_c_evt.params.hrm.hr_value = uint16_decode(&(p_ble_evt->evt.gattc_evt.params.hvx.data[index])); index += sizeof(uint16_t); @@ -215,8 +147,8 @@ static void on_hvx(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt) /**@brief Function for handling Disconnected event received from the SoftDevice. * - * @details This function check if the disconnect event is happening on the link - * associated with the current instance of the module, if so it will set its + * @details This function checks whether the disconnect event is happening on the link + * associated with the current instance of the module. If the event is happening, the function sets the instance's * conn_handle to invalid. * * @param[in] p_ble_hrs_c Pointer to the Heart Rate Client structure. @@ -263,7 +195,7 @@ void ble_hrs_on_db_disc_evt(ble_hrs_c_t * p_ble_hrs_c, const ble_db_discovery_ev } NRF_LOG_DEBUG("Heart Rate Service discovered at peer."); - //If the instance has been assigned prior to db_discovery, assign the db_handles + //If the instance has been assigned prior to db_discovery, assign the db_handles. if (p_ble_hrs_c->conn_handle != BLE_CONN_HANDLE_INVALID) { if ((p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle == BLE_GATT_HANDLE_INVALID)&& @@ -289,8 +221,9 @@ uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_ hrs_uuid.type = BLE_UUID_TYPE_BLE; hrs_uuid.uuid = BLE_UUID_HEART_RATE_SERVICE; - p_ble_hrs_c->evt_handler = p_ble_hrs_c_init->evt_handler; + p_ble_hrs_c->error_handler = p_ble_hrs_c_init->error_handler; + p_ble_hrs_c->p_gatt_queue = p_ble_hrs_c_init->p_gatt_queue; p_ble_hrs_c->conn_handle = BLE_CONN_HANDLE_INVALID; p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle = BLE_GATT_HANDLE_INVALID; p_ble_hrs_c->peer_hrs_db.hrm_handle = BLE_GATT_HANDLE_INVALID; @@ -313,10 +246,6 @@ void ble_hrs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_hvx(p_ble_hrs_c, p_ble_evt); break; - case BLE_GATTC_EVT_WRITE_RSP: - on_write_rsp(p_ble_hrs_c, p_ble_evt); - break; - case BLE_GAP_EVT_DISCONNECTED: on_disconnected(p_ble_hrs_c, p_ble_evt); break; @@ -329,29 +258,30 @@ void ble_hrs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) /**@brief Function for creating a message for writing to the CCCD. */ -static uint32_t cccd_configure(uint16_t conn_handle, uint16_t handle_cccd, bool enable) +static uint32_t cccd_configure(ble_hrs_c_t * p_ble_hrs_c, bool enable) { NRF_LOG_DEBUG("Configuring CCCD. CCCD Handle = %d, Connection Handle = %d", - handle_cccd,conn_handle); - - tx_message_t * p_msg; - uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; - - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; - - p_msg->req.write_req.gattc_params.handle = handle_cccd; - p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg->req.write_req.gattc_value[0] = LSB_16(cccd_val); - p_msg->req.write_req.gattc_value[1] = MSB_16(cccd_val); - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_process(); - return NRF_SUCCESS; + p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle, + p_ble_hrs_c->conn_handle); + + nrf_ble_gq_req_t hrs_c_req; + uint8_t cccd[BLE_CCCD_VALUE_LEN]; + uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + memset(&hrs_c_req, 0, sizeof(hrs_c_req)); + + hrs_c_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + hrs_c_req.error_handler.cb = gatt_error_handler; + hrs_c_req.error_handler.p_ctx = p_ble_hrs_c; + hrs_c_req.params.gattc_write.handle = p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle; + hrs_c_req.params.gattc_write.len = BLE_CCCD_VALUE_LEN; + hrs_c_req.params.gattc_write.p_value = cccd; + hrs_c_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ble_hrs_c->p_gatt_queue, &hrs_c_req, p_ble_hrs_c->conn_handle); } @@ -359,14 +289,12 @@ uint32_t ble_hrs_c_hrm_notif_enable(ble_hrs_c_t * p_ble_hrs_c) { VERIFY_PARAM_NOT_NULL(p_ble_hrs_c); - return cccd_configure(p_ble_hrs_c->conn_handle, - p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle, - true); + return cccd_configure(p_ble_hrs_c, true); } -uint32_t ble_hrs_c_handles_assign(ble_hrs_c_t * p_ble_hrs_c, - uint16_t conn_handle, +uint32_t ble_hrs_c_handles_assign(ble_hrs_c_t * p_ble_hrs_c, + uint16_t conn_handle, const hrs_db_t * p_peer_hrs_handles) { VERIFY_PARAM_NOT_NULL(p_ble_hrs_c); @@ -376,7 +304,8 @@ uint32_t ble_hrs_c_handles_assign(ble_hrs_c_t * p_ble_hrs_c, { p_ble_hrs_c->peer_hrs_db = *p_peer_hrs_handles; } - return NRF_SUCCESS; + + return nrf_ble_gq_conn_handle_register(p_ble_hrs_c->p_gatt_queue, conn_handle); } /** @} * @endcond diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h similarity index 57% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h index 06049fd..33dd502 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hrs_c/ble_hrs_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -45,18 +45,18 @@ * @brief Heart Rate Service Client module. * * @details This module contains the APIs and types exposed by the Heart Rate Service Client - * module. These APIs and types can be used by the application to perform discovery of - * Heart Rate Service at the peer and interact with it. + * module. The application can use these APIs and types to perform the discovery of + * Heart Rate Service at the peer and to interact with it. * - * @warning Currently this module only has support for Heart Rate Measurement characteristic. This - * means that it will be able to enable notification of the characteristic at the peer and - * be able to receive Heart Rate Measurement notifications from the peer. It does not + * @warning Currently, this module only supports the Heart Rate Measurement characteristic. This + * means that it is able to enable notification of the characteristic at the peer and + * is able to receive Heart Rate Measurement notifications from the peer. It does not * support the Body Sensor Location and the Heart Rate Control Point characteristics. - * When a Heart Rate Measurement is received, this module will decode only the - * Heart Rate Measurement Value (both 8 bit and 16 bit) field from it and provide it to + * When a Heart Rate Measurement is received, this module decodes only the + * Heart Rate Measurement value field (both 8-bit and 16-bit) and provides it to * the application. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_hrs_c_t instance; @@ -71,7 +71,9 @@ #include #include "ble.h" #include "ble_db_discovery.h" +#include "ble_srv_common.h" #include "sdk_config.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus @@ -89,7 +91,20 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_HRS_C_BLE_OBSERVER_PRIO, \ ble_hrs_c_on_ble_evt, &_name) -/** @brief Maximum number of RR intervals to be decoded for each HRM notifications (any extra RR intervals will be ignored). +/** @brief Macro for defining multiple ble_hrs_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_HRS_C_ARRAY_DEF(_name, _cnt) \ +static ble_hrs_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_HRS_C_BLE_OBSERVER_PRIO, \ + ble_hrs_c_on_ble_evt, &_name, _cnt) + + +/** @brief Maximum number of RR intervals to be decoded for each HRM notifications (any extra RR intervals are ignored). * * This define should be defined in the sdk_config.h file to override the default. */ @@ -106,8 +121,8 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, /**@brief HRS Client event type. */ typedef enum { - BLE_HRS_C_EVT_DISCOVERY_COMPLETE = 1, /**< Event indicating that the Heart Rate Service has been discovered at the peer. */ - BLE_HRS_C_EVT_HRM_NOTIFICATION /**< Event indicating that a notification of the Heart Rate Measurement characteristic has been received from the peer. */ + BLE_HRS_C_EVT_DISCOVERY_COMPLETE = 1, /**< Event indicating that the Heart Rate Service was discovered at the peer. */ + BLE_HRS_C_EVT_HRM_NOTIFICATION /**< Event indicating that a notification of the Heart Rate Measurement characteristic was received from the peer. */ } ble_hrs_c_evt_type_t; /** @} */ @@ -117,7 +132,7 @@ typedef enum * @{ */ -/**@brief Structure containing the heart rate measurement received from the peer. */ +/**@brief Structure containing the Heart Rate Measurement received from the peer. */ typedef struct { uint16_t hr_value; /**< Heart Rate Value. */ @@ -129,7 +144,7 @@ typedef struct typedef struct { uint16_t hrm_cccd_handle; /**< Handle of the CCCD of the Heart Rate Measurement characteristic. */ - uint16_t hrm_handle; /**< Handle of the Heart Rate Measurement characteristic as provided by the SoftDevice. */ + uint16_t hrm_handle; /**< Handle of the Heart Rate Measurement characteristic, as provided by the SoftDevice. */ } hrs_db_t; /**@brief Heart Rate Event structure. */ @@ -139,8 +154,8 @@ typedef struct uint16_t conn_handle; /**< Connection handle on which the Heart Rate service was discovered on the peer device..*/ union { - hrs_db_t peer_db; /**< Heart Rate related handles found on the peer device.. This will be filled if the evt_type is @ref BLE_HRS_C_EVT_DISCOVERY_COMPLETE.*/ - ble_hrm_t hrm; /**< Heart rate measurement received. This will be filled if the evt_type is @ref BLE_HRS_C_EVT_HRM_NOTIFICATION. */ + hrs_db_t peer_db; /**< Handles related to the Heart Rate, found on the peer device. This is filled if the evt_type is @ref BLE_HRS_C_EVT_DISCOVERY_COMPLETE.*/ + ble_hrm_t hrm; /**< Heart Rate Measurement received. This is filled if the evt_type is @ref BLE_HRS_C_EVT_HRM_NOTIFICATION. */ } params; } ble_hrs_c_evt_t; @@ -156,8 +171,8 @@ typedef struct ble_hrs_c_s ble_hrs_c_t; /**@brief Event handler type. * - * @details This is the type of the event handler that should be provided by the application - * of this module in order to receive events. + * @details This is the type of the event handler that is to be provided by the application + * of this module to receive events. */ typedef void (* ble_hrs_c_evt_handler_t) (ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_evt_t * p_evt); @@ -172,16 +187,20 @@ typedef void (* ble_hrs_c_evt_handler_t) (ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_e */ struct ble_hrs_c_s { - uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */ - hrs_db_t peer_hrs_db; /**< Handles related to HRS on the peer*/ - ble_hrs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the heart rate service. */ + uint16_t conn_handle; /**< Connection handle, as provided by the SoftDevice. */ + hrs_db_t peer_hrs_db; /**< Handles related to HRS on the peer. */ + ble_hrs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the Heart Rate Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ }; /**@brief Heart Rate Client initialization structure. */ typedef struct { - ble_hrs_c_evt_handler_t evt_handler; /**< Event handler to be called by the Heart Rate Client module whenever there is an event related to the Heart Rate Service. */ + ble_hrs_c_evt_handler_t evt_handler; /**< Event handler to be called by the Heart Rate Client module when there is an event related to the Heart Rate Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } ble_hrs_c_init_t; /** @} */ @@ -192,19 +211,18 @@ typedef struct * @{ */ -/**@brief Function for initializing the heart rate client module. +/**@brief Function for initializing the Heart Rate Client module. * - * @details This function will register with the DB Discovery module. There it - * registers for the Heart Rate Service. Doing so will make the DB Discovery - * module look for the presence of a Heart Rate Service instance at the peer when a - * discovery is started. + * @details This function registers with the Database Discovery module for the Heart Rate Service. + * The module looks for the presence of a Heart Rate Service instance at the peer + * when a discovery is started. * - * @param[in] p_ble_hrs_c Pointer to the heart rate client structure. - * @param[in] p_ble_hrs_c_init Pointer to the heart rate initialization structure containing the - * initialization information. + * @param[in] p_ble_hrs_c Pointer to the Heart Rate Client structure. + * @param[in] p_ble_hrs_c_init Pointer to the Heart Rate initialization structure that contains + * the initialization information. * - * @retval NRF_SUCCESS On successful initialization. Otherwise an error code. This function - * propagates the error code returned by the Database Discovery module API + * @retval NRF_SUCCESS On successful initialization. + * @retval err_code Otherwise, this function propagates the error code returned by the Database Discovery module API * @ref ble_db_discovery_evt_register. */ uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_c_init); @@ -212,12 +230,12 @@ uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_ /**@brief Function for handling BLE events from the SoftDevice. * - * @details This function will handle the BLE events received from the SoftDevice. If a BLE - * event is relevant to the Heart Rate Client module, then it uses it to update + * @details This function handles the BLE events received from the SoftDevice. If a BLE + * event is relevant to the Heart Rate Client module, the function uses the event's data to update * interval variables and, if necessary, send events to the application. * * @param[in] p_ble_evt Pointer to the BLE event. - * @param[in] p_context Pointer to the heart rate client structure. + * @param[in] p_context Pointer to the Heart Rate Client structure. */ void ble_hrs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); @@ -225,44 +243,44 @@ void ble_hrs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); /**@brief Function for requesting the peer to start sending notification of Heart Rate * Measurement. * - * @details This function will enable to notification of the Heart Rate Measurement at the peer - * by writing to the CCCD of the Heart Rate Measurement Characteristic. + * @details This function enables notification of the Heart Rate Measurement at the peer + * by writing to the CCCD of the Heart Rate Measurement characteristic. * - * @param p_ble_hrs_c Pointer to the heart rate client structure. + * @param p_ble_hrs_c Pointer to the Heart Rate Client structure. * - * @retval NRF_SUCCESS If the SoftDevice has been requested to write to the CCCD of the peer. - * Otherwise, an error code. This function propagates the error code returned + * @retval NRF_SUCCESS If the SoftDevice is requested to write to the CCCD of the peer. + * @retval err_code Otherwise, this function propagates the error code returned * by the SoftDevice API @ref sd_ble_gattc_write. */ uint32_t ble_hrs_c_hrm_notif_enable(ble_hrs_c_t * p_ble_hrs_c); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details Call this function when getting a callback event from the DB discovery modue. - * This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of heart rate service at the peer. If so, it will - * call the application's event handler indicating that the heart rate service has been - * discovered at the peer. It also populates the event with the service related + * @details Call this function when you get a callback event from the Database Discovery module. + * This function handles an event from the Database Discovery module and determines + * whether it relates to the discovery of Heart Rate Service at the peer. If it does, the function + * calls the application's event handler to indicate that the Heart Rate Service was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * - * @param[in] p_ble_hrs_c Pointer to the heart rate client structure instance to associate. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_ble_hrs_c Pointer to the Heart Rate Client structure instance for associating the link. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. * */ void ble_hrs_on_db_disc_evt(ble_hrs_c_t * p_ble_hrs_c, const ble_db_discovery_evt_t * p_evt); -/**@brief Function for assigning a handles to a this instance of hrs_c. +/**@brief Function for assigning handles to an instance of hrs_c. * * @details Call this function when a link has been established with a peer to - * associate this link to this instance of the module. This makes it - * possible to handle several link and associate each link to a particular - * instance of this module.The connection handle and attribute handles will be + * associate the link to this instance of the module. This association makes it + * possible to handle several links and associate each link to a particular + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_HRS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in] p_ble_hrs_c Pointer to the heart rate client structure instance to associate. - * @param[in] conn_handle Connection handle to associated with the given Heart Rate Client Instance. + * @param[in] p_ble_hrs_c Pointer to the Heart Rate Client structure instance for associating the link. + * @param[in] conn_handle Connection handle to associate with the given Heart Rate Client Instance. * @param[in] p_peer_hrs_handles Attribute handles for the HRS server you want this HRS_C client to * interact with. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hts/ble_hts.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hts/ble_hts.c similarity index 66% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hts/ble_hts.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hts/ble_hts.c index d6bbccd..861a386 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hts/ble_hts.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hts/ble_hts.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -59,6 +59,25 @@ #define HTS_MEAS_FLAG_TEMP_TYPE_BIT (0x01 << 2) /**< Temperature Type flag. */ +/**@brief Function for interception of GATT errors and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_hts_t * p_hts = (ble_hts_t *)p_ctx; + + if (p_hts->error_handler != NULL) + { + p_hts->error_handler(nrf_error); + } +} + + /**@brief Function for handling the Connect event. * * @param[in] p_hts Health Thermometer Service structure. @@ -66,7 +85,17 @@ */ static void on_connect(ble_hts_t * p_hts, ble_evt_t const * p_ble_evt) { + ret_code_t err_code; + p_hts->conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; + + err_code = nrf_ble_gq_conn_handle_register(p_hts->p_gatt_queue, p_hts->conn_handle); + + if ((p_hts->error_handler != NULL) && + (err_code != NRF_SUCCESS)) + { + p_hts->error_handler(err_code); + } } @@ -239,130 +268,24 @@ static uint8_t hts_measurement_encode(ble_hts_t * p_hts, } -/**@brief Function for adding Health Thermometer Measurement characteristics. - * - * @param[in] p_hts Health Thermometer Service structure. - * @param[in] p_hts_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t hts_measurement_char_add(ble_hts_t * p_hts, ble_hts_init_t const * p_hts_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - ble_hts_meas_t initial_htm; - uint8_t encoded_htm[MAX_HTM_LEN]; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - cccd_md.write_perm = p_hts_init->hts_meas_attr_md.cccd_write_perm; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.indicate = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TEMPERATURE_MEASUREMENT_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.read_perm = p_hts_init->hts_meas_attr_md.read_perm; - attr_md.write_perm = p_hts_init->hts_meas_attr_md.write_perm; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - memset(&initial_htm, 0, sizeof(initial_htm)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = hts_measurement_encode(p_hts, &initial_htm, encoded_htm); - attr_char_value.init_offs = 0; - attr_char_value.max_len = MAX_HTM_LEN; - attr_char_value.p_value = encoded_htm; - - return sd_ble_gatts_characteristic_add(p_hts->service_handle, - &char_md, - &attr_char_value, - &p_hts->meas_handles); -} - - -/**@brief Function for adding Temperature Type characteristics. - * - * @param[in] p_hts Health Thermometer Service structure. - * @param[in] p_hts_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t hts_temp_type_char_add(ble_hts_t * p_hts, ble_hts_init_t const * p_hts_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t init_value_temp_type; - uint8_t init_value_encoded[1]; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TEMPERATURE_TYPE_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.read_perm = p_hts_init->hts_temp_type_attr_md.read_perm; - attr_md.write_perm = p_hts_init->hts_temp_type_attr_md.write_perm; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - init_value_temp_type = p_hts_init->temp_type; - init_value_encoded[0] = init_value_temp_type; - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint8_t); - attr_char_value.p_value = init_value_encoded; - - return sd_ble_gatts_characteristic_add(p_hts->service_handle, - &char_md, - &attr_char_value, - &p_hts->temp_type_handles); -} - - uint32_t ble_hts_init(ble_hts_t * p_hts, ble_hts_init_t const * p_hts_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + VERIFY_PARAM_NOT_NULL(p_hts); + VERIFY_PARAM_NOT_NULL(p_hts_init); + VERIFY_PARAM_NOT_NULL(p_hts_init->p_gatt_queue); + + uint32_t err_code; + uint8_t init_value[MAX_HTM_LEN]; + ble_hts_meas_t initial_htm; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; // Initialize service structure - p_hts->evt_handler = p_hts_init->evt_handler; - p_hts->conn_handle = BLE_CONN_HANDLE_INVALID; - p_hts->temp_type = p_hts_init->temp_type; + p_hts->evt_handler = p_hts_init->evt_handler; + p_hts->p_gatt_queue = p_hts_init->p_gatt_queue; + p_hts->error_handler = p_hts_init->error_handler; + p_hts->conn_handle = BLE_CONN_HANDLE_INVALID; + p_hts->temp_type = p_hts_init->temp_type; // Add service BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEALTH_THERMOMETER_SERVICE); @@ -374,7 +297,18 @@ uint32_t ble_hts_init(ble_hts_t * p_hts, ble_hts_init_t const * p_hts_init) } // Add measurement characteristic - err_code = hts_measurement_char_add(p_hts, p_hts_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + memset(&initial_htm, 0, sizeof(initial_htm)); + + add_char_params.uuid = BLE_UUID_TEMPERATURE_MEASUREMENT_CHAR; + add_char_params.init_len = hts_measurement_encode(p_hts, &initial_htm, init_value); + add_char_params.max_len = MAX_HTM_LEN; + add_char_params.p_init_value = init_value; + add_char_params.is_var_len = true; + add_char_params.char_props.indicate = 1; + add_char_params.cccd_write_access = p_hts_init->ht_meas_cccd_wr_sec; + + err_code = characteristic_add(p_hts->service_handle, &add_char_params, &p_hts->meas_handles); if (err_code != NRF_SUCCESS) { return err_code; @@ -383,7 +317,18 @@ uint32_t ble_hts_init(ble_hts_t * p_hts, ble_hts_init_t const * p_hts_init) // Add temperature type characteristic if (p_hts_init->temp_type_as_characteristic) { - err_code = hts_temp_type_char_add(p_hts, p_hts_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_TEMPERATURE_TYPE_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.char_props.read = 1; + add_char_params.read_access = p_hts_init->ht_type_rd_sec; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = (uint8_t *) &(p_hts_init->temp_type); + + err_code = characteristic_add(p_hts->service_handle, + &add_char_params, + &p_hts->temp_type_handles); if (err_code != NRF_SUCCESS) { return err_code; @@ -401,27 +346,24 @@ uint32_t ble_hts_measurement_send(ble_hts_t * p_hts, ble_hts_meas_t * p_hts_meas // Send value if connected if (p_hts->conn_handle != BLE_CONN_HANDLE_INVALID) { - uint8_t encoded_hts_meas[MAX_HTM_LEN]; - uint16_t len; - uint16_t hvx_len; - ble_gatts_hvx_params_t hvx_params; + uint8_t encoded_hts_meas[MAX_HTM_LEN]; + uint16_t len; + nrf_ble_gq_req_t hts_req; len = hts_measurement_encode(p_hts, p_hts_meas, encoded_hts_meas); - hvx_len = len; - memset(&hvx_params, 0, sizeof(hvx_params)); + memset(&hts_req, 0, sizeof(nrf_ble_gq_req_t)); - hvx_params.handle = p_hts->meas_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = encoded_hts_meas; + hts_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + hts_req.error_handler.cb = gatt_error_handler; + hts_req.error_handler.p_ctx = p_hts; + hts_req.params.gatts_hvx.handle = p_hts->meas_handles.value_handle; + hts_req.params.gatts_hvx.offset = 0; + hts_req.params.gatts_hvx.p_data = encoded_hts_meas; + hts_req.params.gatts_hvx.p_len = &len; + hts_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; - err_code = sd_ble_gatts_hvx(p_hts->conn_handle, &hvx_params); - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } + err_code = nrf_ble_gq_item_add(p_hts->p_gatt_queue, &hts_req, p_hts->conn_handle); } else { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hts/ble_hts.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hts/ble_hts.h similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hts/ble_hts.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hts/ble_hts.h index ae8d2b2..b973bdc 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_hts/ble_hts.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_hts/ble_hts.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -71,6 +71,7 @@ #include "ble_srv_common.h" #include "ble_date_time.h" #include "nrf_sdh_ble.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -132,10 +133,12 @@ typedef struct typedef struct { ble_hts_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Health Thermometer Service. */ - ble_srv_cccd_security_mode_t hts_meas_attr_md; /**< Initial security level for health thermometer measurement attribute */ - ble_srv_security_mode_t hts_temp_type_attr_md; /**< Initial security level for health thermometer tempearture type attribute */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + security_req_t ht_meas_cccd_wr_sec; /**< Security requirement for writing health thermometer measurement characteristic CCCD. */ + security_req_t ht_type_rd_sec; /**< Security requirement for reading health thermometer type characteristic. */ uint8_t temp_type_as_characteristic; /**< Set non-zero if temp type given as characteristic */ uint8_t temp_type; /**< Temperature type if temperature characteristic is used */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ } ble_hts_init_t; /**@brief Health Thermometer Service structure. This contains various status information for @@ -143,11 +146,13 @@ typedef struct struct ble_hts_s { ble_hts_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Health Thermometer Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ uint16_t service_handle; /**< Handle of Health Thermometer Service (as provided by the BLE stack). */ ble_gatts_char_handles_t meas_handles; /**< Handles related to the Health Thermometer Measurement characteristic. */ ble_gatts_char_handles_t temp_type_handles; /**< Handles related to the Health Thermometer Temperature Type characteristic. */ uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ uint8_t temp_type; /**< Temperature type indicates where the measurement was taken. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ }; /**@brief Health Thermometer Service measurement structure. This contains a Health Thermometer diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias/ble_ias.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias/ble_ias.c similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias/ble_ias.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias/ble_ias.c index 97413a9..572fa03 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias/ble_ias.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias/ble_ias.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -47,6 +47,17 @@ #include #include "ble_srv_common.h" +#define NRF_LOG_MODULE_NAME ble_ias +#if BLE_IAS_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL BLE_IAS_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR BLE_IAS_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR BLE_IAS_CONFIG_DEBUG_COLOR +#else // BLE_IAS_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // BLE_IAS_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + #define INITIAL_ALERT_LEVEL BLE_CHAR_ALERT_LEVEL_NO_ALERT @@ -58,9 +69,24 @@ */ static void on_connect(ble_ias_t * p_ias, ble_evt_t const * p_ble_evt) { - p_ias->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + ret_code_t err_code; + ble_ias_client_context_t * p_client = NULL; + + err_code = blcm_link_ctx_get(p_ias->p_link_ctx_storage, + p_ble_evt->evt.gap_evt.conn_handle, + (void *) &p_client); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Link context for 0x%02X connection handle could not be fetched.", + p_ble_evt->evt.gap_evt.conn_handle); + } + else + { + p_client->alert_level = INITIAL_ALERT_LEVEL; + } } + /**@brief Function for handling the Write event. * * @param[in] p_ias Immediate Alert Service structure. @@ -73,10 +99,26 @@ static void on_write(ble_ias_t * p_ias, ble_evt_t const * p_ble_evt) if ((p_evt_write->handle == p_ias->alert_level_handles.value_handle) && (p_evt_write->len == 1)) { // Alert level written, call application event handler - ble_ias_evt_t evt; - - evt.evt_type = BLE_IAS_EVT_ALERT_LEVEL_UPDATED; - evt.params.alert_level = p_evt_write->data[0]; + ret_code_t err_code; + ble_ias_evt_t evt; + ble_ias_client_context_t * p_client; + + err_code = blcm_link_ctx_get(p_ias->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_client); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Link context for 0x%02X connection handle could not be fetched.", + p_ble_evt->evt.gatts_evt.conn_handle); + } + else + { + p_client->alert_level = p_evt_write->data[0]; + } + + evt.evt_type = BLE_IAS_EVT_ALERT_LEVEL_UPDATED; + evt.conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; + evt.p_link_ctx = p_client; p_ias->evt_handler(p_ias, &evt); } @@ -104,63 +146,12 @@ void ble_ias_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) } -/**@brief Function for adding Alert Level characteristics. - * - * @param[in] p_ias Immediate Alert Service structure. - * @param[in] p_ias_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t alert_level_char_add(ble_ias_t * p_ias) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t initial_alert_level; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.write_wo_resp = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_ALERT_LEVEL_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm); - - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - initial_alert_level = INITIAL_ALERT_LEVEL; - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint8_t); - attr_char_value.p_value = &initial_alert_level; - - return sd_ble_gatts_characteristic_add(p_ias->service_handle, - &char_md, - &attr_char_value, - &p_ias->alert_level_handles); -} - - uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + uint32_t err_code; + uint8_t initial_alert_level; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; // Initialize service structure if (p_ias_init->evt_handler == NULL) @@ -175,30 +166,35 @@ uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init) err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_ias->service_handle); - - if (err_code != NRF_SUCCESS) - { - return err_code; - } + VERIFY_SUCCESS(err_code); // Add alert level characteristic - return alert_level_char_add(p_ias); + initial_alert_level = INITIAL_ALERT_LEVEL; + + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_ALERT_LEVEL_CHAR; + add_char_params.max_len = sizeof (uint8_t); + add_char_params.init_len = sizeof (uint8_t); + add_char_params.p_init_value = &initial_alert_level; + add_char_params.char_props.write_wo_resp = 1; + add_char_params.write_access = p_ias_init->alert_wr_sec; + + return characteristic_add(p_ias->service_handle, + &add_char_params, + &p_ias->alert_level_handles); } -uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint8_t * p_alert_level) +uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint16_t conn_handle, uint8_t * p_alert_level) { - ble_gatts_value_t gatts_value; + ret_code_t err_code; + ble_ias_client_context_t * p_client; - // Initialize value struct. - memset(&gatts_value, 0, sizeof(gatts_value)); + err_code = blcm_link_ctx_get(p_ias->p_link_ctx_storage, conn_handle, (void *) &p_client); + VERIFY_SUCCESS(err_code); - gatts_value.len = sizeof(uint8_t); - gatts_value.offset = 0; - gatts_value.p_value = p_alert_level; - - return sd_ble_gatts_value_get(p_ias->conn_handle, - p_ias->alert_level_handles.value_handle, - &gatts_value); + *p_alert_level = p_client->alert_level; + return NRF_SUCCESS; } + #endif // NRF_MODULE_ENABLED(BLE_IAS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias/ble_ias.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias/ble_ias.h similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias/ble_ias.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias/ble_ias.h index 33cb9a4..252de90 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias/ble_ias.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias/ble_ias.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -74,21 +74,32 @@ #include #include "ble.h" #include "nrf_sdh_ble.h" +#include "ble_link_ctx_manager.h" +#include "ble_srv_common.h" #ifdef __cplusplus extern "C" { #endif + /**@brief Macro for defining a ble_ias instance. * - * @param _name Name of the instance. + * @param _name Name of the instance. + * @param[in] _ias_max_clients Maximum number of IAS clients connected at a time. * @hideinitializer */ -#define BLE_IAS_DEF(_name) \ -static ble_ias_t _name; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - BLE_IAS_BLE_OBSERVER_PRIO, \ - ble_ias_on_ble_evt, &_name) +#define BLE_IAS_DEF(_name, _ias_max_clients) \ + BLE_LINK_CTX_MANAGER_DEF(CONCAT_2(_name, _link_ctx_storage), \ + (_ias_max_clients), \ + sizeof(ble_ias_client_context_t)); \ + static ble_ias_t _name = \ + { \ + .p_link_ctx_storage = &CONCAT_2(_name, _link_ctx_storage) \ + }; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_IAS_BLE_OBSERVER_PRIO, \ + ble_ias_on_ble_evt, \ + &_name) /**@brief Immediate Alert Service event type. */ @@ -97,37 +108,51 @@ typedef enum BLE_IAS_EVT_ALERT_LEVEL_UPDATED /**< Alert Level Updated event. */ } ble_ias_evt_type_t; + +/**@brief Immediate Alert Service client context structure. + * + * @details This structure contains state context related to hosts. + */ +typedef struct +{ + uint8_t alert_level; /**< New Alert Level value. */ +} ble_ias_client_context_t; + + /**@brief Immediate Alert Service event. */ typedef struct { - ble_ias_evt_type_t evt_type; /**< Type of event. */ - union - { - uint8_t alert_level; /**< New Alert Level value. */ - } params; + ble_ias_evt_type_t evt_type; /**< Type of event. */ + uint16_t conn_handle; /**< Connection handle. */ + ble_ias_client_context_t * p_link_ctx; /**< A pointer to the link context. */ } ble_ias_evt_t; + // Forward declaration of the ble_ias_t type. typedef struct ble_ias_s ble_ias_t; + /**@brief Immediate Alert Service event handler type. */ typedef void (*ble_ias_evt_handler_t) (ble_ias_t * p_ias, ble_ias_evt_t * p_evt); + /**@brief Immediate Alert Service init structure. This contains all options and data needed for * initialization of the service. */ typedef struct { ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */ + security_req_t alert_wr_sec; /**< Security requirement for writing Alert Level characteristic. */ } ble_ias_init_t; + /**@brief Immediate Alert Service structure. This contains various status information for the * service. */ struct ble_ias_s { - ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */ - uint16_t service_handle; /**< Handle of Immediate Alert Service (as provided by the BLE stack). */ - ble_gatts_char_handles_t alert_level_handles; /**< Handles related to the Alert Level characteristic. */ - uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ + ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */ + uint16_t service_handle; /**< Handle of Immediate Alert Service (as provided by the BLE stack). */ + ble_gatts_char_handles_t alert_level_handles; /**< Handles related to the Alert Level characteristic. */ + blcm_link_ctx_storage_t * const p_link_ctx_storage; /**< Pointer to link context storage with handles of all current connections and its context. */ }; @@ -153,12 +178,13 @@ uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init); void ble_ias_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); -/**@brief Function for getting current value of the Alert Level characteristic. +/**@brief Function for getting value of the Alert Level characteristic. * * @param[in] p_ias Immediate Alert Service structure. - * @param[out] p_alert_level Current Alert Level value. + * @param[in] conn_handle Connection handle of the destination client. + * @param[out] p_alert_level Alert Level value which has been set by the specific client. */ -uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint8_t * p_alert_level); +uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint16_t conn_handle, uint8_t * p_alert_level); #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias_c/ble_ias_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias_c/ble_ias_c.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias_c/ble_ias_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias_c/ble_ias_c.c index a9d1d1a..7be8f5c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias_c/ble_ias_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias_c/ble_ias_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_IAS_C) @@ -48,12 +48,32 @@ #include "ble_db_discovery.h" +/**@brief Function for intercepting the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + UNUSED_PARAMETER(conn_handle); + + ble_ias_c_t * p_ias_c = (ble_ias_c_t *)p_ctx; + + if (p_ias_c->error_handler != NULL) + { + p_ias_c->error_handler(nrf_error); + } +} + + void ble_ias_c_on_db_disc_evt(ble_ias_c_t * p_ias_c, ble_db_discovery_evt_t const * p_evt) { ble_ias_c_evt_t evt; memset(&evt, 0, sizeof(ble_ias_c_evt_t)); - evt.evt_type = BLE_IAS_C_EVT_DISCOVERY_FAILED; evt.conn_handle = p_evt->conn_handle; ble_gatt_db_char_t const * p_chars = p_evt->params.discovered_db.charateristics; @@ -83,7 +103,17 @@ void ble_ias_c_on_db_disc_evt(ble_ias_c_t * p_ias_c, ble_db_discovery_evt_t cons break; } } + } + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) + { + evt.evt_type = BLE_IAS_C_EVT_DISCOVERY_FAILED; } + else + { + return; + } + if (evt.alert_level.handle_value != BLE_GATT_HANDLE_INVALID) { evt.evt_type = BLE_IAS_C_EVT_DISCOVERY_COMPLETE; @@ -96,11 +126,13 @@ void ble_ias_c_on_db_disc_evt(ble_ias_c_t * p_ias_c, ble_db_discovery_evt_t cons uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, ble_ias_c_init_t const * p_ias_c_init) { VERIFY_PARAM_NOT_NULL(p_ias_c); - VERIFY_PARAM_NOT_NULL(p_ias_c_init->evt_handler); VERIFY_PARAM_NOT_NULL(p_ias_c_init); + VERIFY_PARAM_NOT_NULL(p_ias_c_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_ias_c_init->p_gatt_queue); p_ias_c->evt_handler = p_ias_c_init->evt_handler; p_ias_c->error_handler = p_ias_c_init->error_handler; + p_ias_c->p_gatt_queue = p_ias_c_init->p_gatt_queue; p_ias_c->conn_handle = BLE_CONN_HANDLE_INVALID; p_ias_c->alert_level_char.handle_value = BLE_GATT_HANDLE_INVALID; @@ -125,7 +157,7 @@ static void on_disconnect(ble_ias_c_t * p_ias_c, ble_evt_t const * p_ble_evt) if (ble_ias_c_is_discovered(p_ias_c)) { // There was a valid instance of IAS on the peer. Send an event to the - // application, so that it can do any clean up related to this module. + // application, so that it can do a cleanup related to this module. ble_ias_c_evt_t evt; evt.evt_type = BLE_IAS_C_EVT_DISCONN_COMPLETE; @@ -161,29 +193,30 @@ void ble_ias_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) /**@brief Function for performing a Write procedure. * - * @param[in] conn_handle Handle of the connection on which to perform the write operation. - * @param[in] write_handle Handle of the attribute to be written. + * @param[in] p_ias_c Pointer to Immediate Alert Service client structure. * @param[in] length Length of data to be written. * @param[in] p_value Data to be written. * * @return NRF_SUCCESS on success, otherwise an error code. */ -static uint32_t write_characteristic_value(uint16_t conn_handle, - uint16_t write_handle, - uint16_t length, - uint8_t * p_value) +static uint32_t write_characteristic_value(ble_ias_c_t const * const p_ias_c, + uint16_t length, + uint8_t * p_value) { - ble_gattc_write_params_t write_params; + nrf_ble_gq_req_t write_req; - memset(&write_params, 0, sizeof(write_params)); + memset(&write_req, 0, sizeof(nrf_ble_gq_req_t)); - write_params.handle = write_handle; - write_params.write_op = BLE_GATT_OP_WRITE_CMD; - write_params.offset = 0; - write_params.len = length; - write_params.p_value = p_value; + write_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + write_req.error_handler.cb = gatt_error_handler; + write_req.error_handler.p_ctx = (ble_ias_c_t *)p_ias_c; + write_req.params.gattc_write.handle = p_ias_c->alert_level_char.handle_value; + write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD; + write_req.params.gattc_write.offset = 0; + write_req.params.gattc_write.len = length; + write_req.params.gattc_write.p_value = p_value; - return sd_ble_gattc_write(conn_handle, &write_params); + return nrf_ble_gq_item_add(p_ias_c->p_gatt_queue, &write_req, p_ias_c->conn_handle); } @@ -194,8 +227,7 @@ uint32_t ble_ias_c_send_alert_level(ble_ias_c_t const * p_ias_c, uint8_t alert_l return NRF_ERROR_NOT_FOUND; } - return write_characteristic_value(p_ias_c->conn_handle, - p_ias_c->alert_level_char.handle_value, + return write_characteristic_value(p_ias_c, sizeof(uint8_t), &alert_level); } @@ -207,8 +239,9 @@ uint32_t ble_ias_c_handles_assign(ble_ias_c_t * p_ias_c, { VERIFY_PARAM_NOT_NULL(p_ias_c); - p_ias_c->conn_handle = conn_handle; + p_ias_c->conn_handle = conn_handle; p_ias_c->alert_level_char.handle_value = alert_level_handle; - return NRF_SUCCESS; + + return nrf_ble_gq_conn_handle_register(p_ias_c->p_gatt_queue, conn_handle); } #endif //NRF_MODULE_ENABLED(BLE_IAS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias_c/ble_ias_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias_c/ble_ias_c.h similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias_c/ble_ias_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias_c/ble_ias_c.h index 7e187d4..3c4028b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ias_c/ble_ias_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ias_c/ble_ias_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -44,14 +44,14 @@ * @ingroup ble_sdk_srv * @brief Immediate Alert Service Client module * - * @details This module implements the Immediate Alert Service client - locator role of the Find Me + * @details This module implements the Immediate Alert Service client - the locator role of the Find Me * profile. On @ref BLE_GAP_EVT_CONNECTED event, this module starts discovery of the * Immediate Alert Service with Alert Level characteristic at the peer. This module will - * indicate the application about a successful service & characteristic discovery using - * @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE event. The application can use @ref + * inform the application about the successful service and characteristic discovery with + * the @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE event. The application can use @ref * ble_ias_c_send_alert_level function to signal alerts to the peer. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_ias_c_t instance; @@ -68,6 +68,7 @@ #include "ble_gattc.h" #include "ble.h" #include "ble_db_discovery.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus @@ -85,6 +86,18 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_IAS_C_BLE_OBSERVER_PRIO, \ ble_ias_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple ble_ias_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_IAS_C_ARRAY_DEF(_name, _cnt) \ +static ble_ias_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_IAS_C_BLE_OBSERVER_PRIO, \ + ble_ias_c_on_ble_evt, &_name, _cnt) + // Forward declaration of the ble_ias_c_t type. typedef struct ble_ias_c_s ble_ias_c_t; @@ -94,21 +107,21 @@ typedef enum { BLE_IAS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the Immediate Alert Service is found at the peer. */ BLE_IAS_C_EVT_DISCOVERY_FAILED, /**< Event indicating that the Immediate Alert Service is not found at the peer. */ - BLE_IAS_C_EVT_DISCONN_COMPLETE /**< Event indicating that the Immediate Alert Service client module has completed the processing of BLE_GAP_EVT_DISCONNECTED event. This event is raised only if a valid instance of IAS was found at the peer during the discovery phase. This event can be used the application to do clean up related to the IAS Client.*/ + BLE_IAS_C_EVT_DISCONN_COMPLETE /**< Event indicating that the Immediate Alert Service Client module completed the processing of BLE_GAP_EVT_DISCONNECTED event. This event is triggered only if a valid instance of IAS was found at the peer during the discovery phase. The application can use this event to do a cleanup related to the IAS Client.*/ } ble_ias_c_evt_type_t; /**@brief Immediate Alert Service client event. */ typedef struct { ble_ias_c_evt_type_t evt_type; /**< Type of event. */ - uint16_t conn_handle; /**< Connection handle on which the IAS service was discovered on the peer device. This will be filled if the evt_type is @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE.*/ - ble_gattc_char_t alert_level; /**< Info on the discovered Alert Level characteristic discovered. This will be filled if the evt_type is @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE.*/ + uint16_t conn_handle; /**< Connection handle on which the IAS service was discovered on the peer device. This is filled if the evt_type is @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE.*/ + ble_gattc_char_t alert_level; /**< Information on the discovered Alert Level characteristic discovered. This is filled if the evt_type is @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE.*/ } ble_ias_c_evt_t; /**@brief Immediate Alert Service client event handler type. */ typedef void (*ble_ias_c_evt_handler_t) (ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt); -/**@brief IAS Client structure. This contains various status information for the client. */ +/**@brief IAS Client structure. Contains various status information for the client. */ struct ble_ias_c_s { ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service client. */ @@ -116,14 +129,16 @@ struct ble_ias_c_s uint16_t conn_handle; /**< Handle of the current connection. Set with @ref ble_ias_c_handles_assign when connected. */ ble_uuid_t service_uuid; /**< The GATT Service holding the discovered Immediate Service. */ ble_gattc_char_t alert_level_char; /**< IAS Alert Level Characteristic. Stores data about the alert characteristic found on the peer. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ }; -/**@brief IAS Client init structure. This contains all options and data needed for initialization of +/**@brief IAS Client init structure. Contains all options and data needed for the initialization of * the client.*/ typedef struct { ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Immediate Alert Service client. */ ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } ble_ias_c_init_t; @@ -131,9 +146,9 @@ typedef struct * * @details This call allows the application to initialize the Immediate Alert Service client. * - * @param[out] p_ias_c Immediate Alert Service client structure. This structure will have to - * be supplied by the application. It will be initialized by this - * function, and will later be used to identify this particular client + * @param[out] p_ias_c Immediate Alert Service client structure. This structure must + * be supplied by the application. It is initialized by this + * function, and is later used to identify this particular client * instance. * @param[in] p_ias_c_init Information needed to initialize the Immediate Alert Service client. * @@ -149,7 +164,9 @@ uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, ble_ias_c_init_t const * p_ias_c_ * @param[in] p_ias_c Immediate Alert Service client structure. * @param[in] alert_level Required alert level to be sent to the peer. * - * @return NRF_SUCCESS on success, otherwise an error code. + * @retval NRF_SUCCESS On success. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ uint32_t ble_ias_c_send_alert_level(ble_ias_c_t const * p_ias_c, uint8_t alert_level); @@ -164,13 +181,13 @@ uint32_t ble_ias_c_send_alert_level(ble_ias_c_t const * p_ias_c, uint8_t alert_l void ble_ias_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); -/**@brief Function for checking whether the peer's Immediate Alert Service instance and the alert level +/**@brief Function for checking whether the peer's Immediate Alert Service instance and the Alert Level * characteristic have been discovered. * * @param[in] p_ias_c Immediate Alert Service client structure. * - * @return TRUE if a handle has been assigned to alert_level_handle, meaning it must have been - * discovered. FALSE if the handle is invalid. + * @return True, if a handle is assigned to alert_level_handle, meaning it must have been discovered. + * @return False, if the handle is invalid. */ static __INLINE bool ble_ias_c_is_discovered(ble_ias_c_t const * p_ias_c) { @@ -178,18 +195,18 @@ static __INLINE bool ble_ias_c_is_discovered(ble_ias_c_t const * p_ias_c) } -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details Call this function when getting a callback event from the DB discovery modue. - * This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of heart rate service at the peer. If so, it will - * call the application's event handler indicating that the heart rate service has been - * discovered at the peer. It also populates the event with the service related + * @details Call this function when you get a callback event from the Database Discovery module. + * This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of Immediate Alert Service at the peer. If it does, the function + * calls the application's event handler to indicate that the Immediate Alert Service was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * - * @param[in] p_ias_c Pointer to the immediate alert client structure instance that will handle + * @param[in] p_ias_c Pointer to the Immediate Alert client structure instance that will handle * the discovery. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. * */ void ble_ias_c_on_db_disc_evt(ble_ias_c_t * p_ias_c, ble_db_discovery_evt_t const * p_evt); @@ -198,18 +215,20 @@ void ble_ias_c_on_db_disc_evt(ble_ias_c_t * p_ias_c, ble_db_discovery_evt_t cons /**@brief Function for assigning handles to an instance of ias_c. * * @details Call this function when a link has been established with a peer to - * associate this link to this instance of the module. This makes it + * associate the link to this instance of the module. This makes it * possible to handle several links and associate each link to a particular - * instance of this module. The connection handle and attribute handles will be + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_IAS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in] p_ias_c Pointer to the IAS client structure instance to associate. - * @param[in] conn_handle Connection handle to associated with the given IAS Instance. + * @param[in] p_ias_c Pointer to the IAS client structure instance for associating the link. + * @param[in] conn_handle Connection handle to associated with the given IAS instance. * @param[in] alert_level_handle Attribute handle on the IAS server that you want this IAS_C client to * interact with. * * @retval NRF_SUCCESS If the operation was successful. * @retval NRF_ERROR_NULL If a p_ias_c was a NULL pointer. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_conn_handle_register. */ uint32_t ble_ias_c_handles_assign(ble_ias_c_t * p_ias_c, uint16_t conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ipsp/ble_ipsp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ipsp/ble_ipsp.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ipsp/ble_ipsp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ipsp/ble_ipsp.c index 7cbcac6..fd7386e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ipsp/ble_ipsp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ipsp/ble_ipsp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -46,6 +46,7 @@ #include "nordic_common.h" #include "sdk_errors.h" #include "nrf.h" +#include "sdk_config.h" #include "ble_ipsp.h" #include "ble_srv_common.h" #include "sdk_os.h" @@ -56,7 +57,7 @@ * @details Macros used for creating module logs which can be useful in understanding handling * of events or actions on API requests. These are intended for debugging purposes and * can be enabled by defining the IOT_BLE_IPSP_CONFIG_LOG_ENABLED to 1. - * @note That if ENABLE_DEBUG_LOG_SUPPORT is disabled, having IOT_BLE_IPSP_CONFIG_LOG_ENABLED + * @note If NRF_LOG_ENABLED is disabled, having IOT_BLE_IPSP_CONFIG_LOG_ENABLED * has no effect. * @{ */ @@ -109,7 +110,7 @@ NRF_LOG_MODULE_REGISTER(); #define VERIFY_MODULE_IS_INITIALIZED() \ if (m_evt_handler == NULL) \ { \ - return (NRF_ERROR_MODULE_NOT_INITIALZED + NRF_ERROR_BLE_IPSP_ERR_BASE); \ + return (NRF_ERROR_MODULE_NOT_INITIALIZED + NRF_ERROR_BLE_IPSP_ERR_BASE); \ } /**@brief Macro to check is module is initialized before requesting one of the module @@ -341,6 +342,24 @@ static __INLINE void app_notify(ble_ipsp_handle_t * p_handle, ble_ipsp_evt_t * p } +/**@brief Verifies if the buffer is TX buffer on the channel or not. + * + * @param[in] ch_id Identifies the IPSP channel for which the procedure is requested. + * @param[in] p_buffer Address of the buffer being verified to be TX or not. + */ +static __INLINE bool is_tx_buffer(uint32_t ch_id, const uint8_t * p_buffer) +{ + // If the buffer is in the RX buffer list, then it is not TX! + if ((p_buffer >= (uint8_t *)&m_channel[ch_id].p_rx_buffer) && + (p_buffer < (uint8_t *)&m_channel[ch_id].p_rx_buffer[RX_BUFFER_TOTAL_SIZE])) + { + return false; + } + + return true; +} + + /**@brief Submit receive buffers to the softdevice for a channel. * * @param[in] ch_id Identifies the IPSP channel for which the procedure is requested. @@ -670,6 +689,33 @@ void ble_ipsp_evt_handler(ble_evt_t const * p_evt) } break; } + case BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED: + { + BLE_IPSP_TRC("BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED --> p_sdu_buf = %p, p_sdu_buf.p_data = %p", + &p_evt->evt.l2cap_evt.params.ch_sdu_buf_released.sdu_buf, + p_evt->evt.l2cap_evt.params.ch_sdu_buf_released.sdu_buf.p_data); + + retval = channel_search(p_evt->evt.l2cap_evt.conn_handle, + p_evt->evt.l2cap_evt.local_cid, + &ch_id); + + if ((ch_id != INVALID_CHANNEL_INSTANCE) && + (p_evt->evt.l2cap_evt.local_cid == m_channel[ch_id].cid) && + (is_tx_buffer(ch_id, p_evt->evt.l2cap_evt.params.ch_sdu_buf_released.sdu_buf.p_data))) + { + // Initialize the event. + ipsp_event.evt_id = BLE_IPSP_EVT_CHANNEL_DATA_TX_COMPLETE; + ipsp_event.evt_result = NRF_ERROR_BLE_IPSP_LINK_DISCONNECTED; + + // Initialize the handle. + handle.conn_handle = m_channel[ch_id].conn_handle; + handle.cid = m_channel[ch_id].cid; + + // Notify the event to the application. + notify_event = true; + } + break; + } case BLE_GAP_EVT_DISCONNECTED: { uint32_t peer_device_index = connected_device_search(handle.conn_handle); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ipsp/ble_ipsp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ipsp/ble_ipsp.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ipsp/ble_ipsp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ipsp/ble_ipsp.h index 4ff18b6..16f950c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_ipsp/ble_ipsp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_ipsp/ble_ipsp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs/ble_lbs.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs/ble_lbs.c similarity index 50% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs/ble_lbs.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs/ble_lbs.c index dc18494..ffb6b88 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs/ble_lbs.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs/ble_lbs.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_LBS) @@ -78,121 +78,11 @@ void ble_lbs_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) } -/**@brief Function for adding the LED Characteristic. - * - * @param[in] p_lbs LED Button Service structure. - * @param[in] p_lbs_init LED Button Service initialization structure. - * - * @retval NRF_SUCCESS on success, else an error value from the SoftDevice - */ -static uint32_t led_char_add(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.write = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - ble_uuid.type = p_lbs->uuid_type; - ble_uuid.uuid = LBS_UUID_LED_CHAR; - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof(uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof(uint8_t); - attr_char_value.p_value = NULL; - - return sd_ble_gatts_characteristic_add(p_lbs->service_handle, - &char_md, - &attr_char_value, - &p_lbs->led_char_handles); -} - - -/**@brief Function for adding the Button Characteristic. - * - * @param[in] p_lbs LED Button Service structure. - * @param[in] p_lbs_init LED Button Service initialization structure. - * - * @retval NRF_SUCCESS on success, else an error value from the SoftDevice - */ -static uint32_t button_char_add(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - ble_uuid.type = p_lbs->uuid_type; - ble_uuid.uuid = LBS_UUID_BUTTON_CHAR; - - memset(&attr_md, 0, sizeof(attr_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof(uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof(uint8_t); - attr_char_value.p_value = NULL; - - return sd_ble_gatts_characteristic_add(p_lbs->service_handle, - &char_md, - &attr_char_value, - &p_lbs->button_char_handles); -} - - uint32_t ble_lbs_init(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + uint32_t err_code; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; // Initialize service structure. p_lbs->led_write_handler = p_lbs_init->led_write_handler; @@ -208,14 +98,39 @@ uint32_t ble_lbs_init(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init) err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_lbs->service_handle); VERIFY_SUCCESS(err_code); - // Add characteristics. - err_code = button_char_add(p_lbs, p_lbs_init); - VERIFY_SUCCESS(err_code); + // Add Button characteristic. + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = LBS_UUID_BUTTON_CHAR; + add_char_params.uuid_type = p_lbs->uuid_type; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.max_len = sizeof(uint8_t); + add_char_params.char_props.read = 1; + add_char_params.char_props.notify = 1; + + add_char_params.read_access = SEC_OPEN; + add_char_params.cccd_write_access = SEC_OPEN; + + err_code = characteristic_add(p_lbs->service_handle, + &add_char_params, + &p_lbs->button_char_handles); + if (err_code != NRF_SUCCESS) + { + return err_code; + } - err_code = led_char_add(p_lbs, p_lbs_init); - VERIFY_SUCCESS(err_code); + // Add LED characteristic. + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = LBS_UUID_LED_CHAR; + add_char_params.uuid_type = p_lbs->uuid_type; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.max_len = sizeof(uint8_t); + add_char_params.char_props.read = 1; + add_char_params.char_props.write = 1; + + add_char_params.read_access = SEC_OPEN; + add_char_params.write_access = SEC_OPEN; - return NRF_SUCCESS; + return characteristic_add(p_lbs->service_handle, &add_char_params, &p_lbs->led_char_handles); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs/ble_lbs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs/ble_lbs.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs/ble_lbs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs/ble_lbs.h index 0be1256..75e00bd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs/ble_lbs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs/ble_lbs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c similarity index 57% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c index 907dca4..74b18a5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs_c/ble_lbs_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BLE_LBS_C) @@ -43,107 +43,40 @@ #include "ble_lbs_c.h" #include "ble_db_discovery.h" #include "ble_types.h" -#include "ble_srv_common.h" #include "ble_gattc.h" #define NRF_LOG_MODULE_NAME ble_lbs_c #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define TX_BUFFER_MASK 0x07 /**< TX Buffer mask, must be a mask of continuous zeroes, followed by continuous sequence of ones: 000...111. */ -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of send buffer, which is 1 higher than the mask. */ - -#define WRITE_MESSAGE_LENGTH BLE_CCCD_VALUE_LEN /**< Length of the write message for CCCD. */ #define WRITE_MESSAGE_LENGTH BLE_CCCD_VALUE_LEN /**< Length of the write message for CCCD. */ -typedef enum -{ - READ_REQ, /**< Type identifying that this tx_message is a read request. */ - WRITE_REQ /**< Type identifying that this tx_message is a write request. */ -} tx_request_t; - -/**@brief Structure for writing a message to the peer, i.e. CCCD. - */ -typedef struct -{ - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; /**< The message to write. */ - ble_gattc_write_params_t gattc_params; /**< GATTC parameters for this message. */ -} write_params_t; - -/**@brief Structure for holding data to be transmitted to the connected central. - */ -typedef struct -{ - uint16_t conn_handle; /**< Connection handle to be used when transmitting this message. */ - tx_request_t type; /**< Type of this message, i.e. read or write message. */ - union - { - uint16_t read_handle; /**< Read request message. */ - write_params_t write_req; /**< Write request message. */ - } req; -} tx_message_t; - - -static tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for messages to be transmitted to the central. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where the next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer from where the next message to be transmitted resides. */ - -/**@brief Function for passing any pending request from the buffer to the stack. +/**@brief Function for intercepting the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. */ -static void tx_buffer_process(void) +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) { - if (m_tx_index != m_tx_insert_index) - { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - NRF_LOG_DEBUG("SD Read/Write API returns Success.."); - m_tx_index++; - m_tx_index &= TX_BUFFER_MASK; - } - else - { - NRF_LOG_DEBUG("SD Read/Write API returns error. This message sending will be " - "attempted again.."); - } - } -} + ble_lbs_c_t * p_ble_lbs_c = (ble_lbs_c_t *)p_ctx; + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); -/**@brief Function for handling write response events. - * - * @param[in] p_ble_lbs_c Pointer to the Led Button Client structure. - * @param[in] p_ble_evt Pointer to the BLE event received. - */ -static void on_write_rsp(ble_lbs_c_t * p_ble_lbs_c, ble_evt_t const * p_ble_evt) -{ - // Check if the event if on the link for this instance - if (p_ble_lbs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) + if (p_ble_lbs_c->error_handler != NULL) { - return; + p_ble_lbs_c->error_handler(nrf_error); } - // Check if there is any message to be sent across to the peer and send it. - tx_buffer_process(); } /**@brief Function for handling Handle Value Notification received from the SoftDevice. * - * @details This function will uses the Handle Value Notification received from the SoftDevice - * and checks if it is a notification of Button state from the peer. If - * it is, this function will decode the state of the button and send it to the + * @details This function uses the Handle Value Notification received from the SoftDevice + * and checks whether it is a notification of Button state from the peer. If + * it is, this function decodes the state of the button and sends it to the * application. * * @param[in] p_ble_lbs_c Pointer to the Led Button Client structure. @@ -151,7 +84,7 @@ static void on_write_rsp(ble_lbs_c_t * p_ble_lbs_c, ble_evt_t const * p_ble_evt) */ static void on_hvx(ble_lbs_c_t * p_ble_lbs_c, ble_evt_t const * p_ble_evt) { - // Check if the event is on the link for this instance + // Check if the event is on the link for this instance. if (p_ble_lbs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { return; @@ -172,10 +105,10 @@ static void on_hvx(ble_lbs_c_t * p_ble_lbs_c, ble_evt_t const * p_ble_evt) } -/**@brief Function for handling Disconnected event received from the SoftDevice. +/**@brief Function for handling the Disconnected event received from the SoftDevice. * - * @details This function check if the disconnect event is happening on the link - * associated with the current instance of the module, if so it will set its + * @details This function checks whether the disconnect event is happening on the link + * associated with the current instance of the module. If the event is happening, the function sets the instance's * conn_handle to invalid. * * @param[in] p_ble_lbs_c Pointer to the Led Button Client structure. @@ -195,7 +128,7 @@ static void on_disconnected(ble_lbs_c_t * p_ble_lbs_c, ble_evt_t const * p_ble_e void ble_lbs_on_db_disc_evt(ble_lbs_c_t * p_ble_lbs_c, ble_db_discovery_evt_t const * p_evt) { - // Check if the Led Button Service was discovered. + // Check if the LED Button Service was discovered. if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE && p_evt->params.discovered_db.srv_uuid.uuid == LBS_UUID_SERVICE && p_evt->params.discovered_db.srv_uuid.type == p_ble_lbs_c->uuid_type) @@ -223,8 +156,8 @@ void ble_lbs_on_db_disc_evt(ble_lbs_c_t * p_ble_lbs_c, ble_db_discovery_evt_t co } } - NRF_LOG_DEBUG("Led Button Service discovered at peer."); - //If the instance has been assigned prior to db_discovery, assign the db_handles + NRF_LOG_DEBUG("LED Button Service discovered at peer."); + //If the instance was assigned prior to db_discovery, assign the db_handles if (p_ble_lbs_c->conn_handle != BLE_CONN_HANDLE_INVALID) { if ((p_ble_lbs_c->peer_lbs_db.led_handle == BLE_GATT_HANDLE_INVALID)&& @@ -250,12 +183,15 @@ uint32_t ble_lbs_c_init(ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_init_t * p_ble_lbs_ VERIFY_PARAM_NOT_NULL(p_ble_lbs_c); VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init); VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init->p_gatt_queue); p_ble_lbs_c->peer_lbs_db.button_cccd_handle = BLE_GATT_HANDLE_INVALID; p_ble_lbs_c->peer_lbs_db.button_handle = BLE_GATT_HANDLE_INVALID; p_ble_lbs_c->peer_lbs_db.led_handle = BLE_GATT_HANDLE_INVALID; p_ble_lbs_c->conn_handle = BLE_CONN_HANDLE_INVALID; p_ble_lbs_c->evt_handler = p_ble_lbs_c_init->evt_handler; + p_ble_lbs_c->p_gatt_queue = p_ble_lbs_c_init->p_gatt_queue; + p_ble_lbs_c->error_handler = p_ble_lbs_c_init->error_handler; err_code = sd_ble_uuid_vs_add(&lbs_base_uuid, &p_ble_lbs_c->uuid_type); if (err_code != NRF_SUCCESS) @@ -285,10 +221,6 @@ void ble_lbs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_hvx(p_ble_lbs_c, p_ble_evt); break; - case BLE_GATTC_EVT_WRITE_RSP: - on_write_rsp(p_ble_lbs_c, p_ble_evt); - break; - case BLE_GAP_EVT_DISCONNECTED: on_disconnected(p_ble_lbs_c, p_ble_evt); break; @@ -301,35 +233,34 @@ void ble_lbs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) /**@brief Function for configuring the CCCD. * - * @param[in] conn_handle The connection handle on which to configure the CCCD. - * @param[in] handle_cccd The handle of the CCCD to be configured. + * @param[in] p_ble_lbs_c Pointer to the LED Button Client structure. * @param[in] enable Whether to enable or disable the CCCD. * * @return NRF_SUCCESS if the CCCD configure was successfully sent to the peer. */ -static uint32_t cccd_configure(uint16_t conn_handle, uint16_t handle_cccd, bool enable) +static uint32_t cccd_configure(ble_lbs_c_t * p_ble_lbs_c, bool enable) { NRF_LOG_DEBUG("Configuring CCCD. CCCD Handle = %d, Connection Handle = %d", - handle_cccd,conn_handle); - - tx_message_t * p_msg; - uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; - - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; - - p_msg->req.write_req.gattc_params.handle = handle_cccd; - p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg->req.write_req.gattc_value[0] = LSB_16(cccd_val); - p_msg->req.write_req.gattc_value[1] = MSB_16(cccd_val); - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_process(); - return NRF_SUCCESS; + p_ble_lbs_c->peer_lbs_db.button_cccd_handle, + p_ble_lbs_c->conn_handle); + + nrf_ble_gq_req_t cccd_req; + uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; + uint8_t cccd[WRITE_MESSAGE_LENGTH]; + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + cccd_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + cccd_req.error_handler.cb = gatt_error_handler; + cccd_req.error_handler.p_ctx = p_ble_lbs_c; + cccd_req.params.gattc_write.handle = p_ble_lbs_c->peer_lbs_db.button_cccd_handle; + cccd_req.params.gattc_write.len = WRITE_MESSAGE_LENGTH; + cccd_req.params.gattc_write.offset = 0; + cccd_req.params.gattc_write.p_value = cccd; + cccd_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ble_lbs_c->p_gatt_queue, &cccd_req, p_ble_lbs_c->conn_handle); } @@ -342,8 +273,7 @@ uint32_t ble_lbs_c_button_notif_enable(ble_lbs_c_t * p_ble_lbs_c) return NRF_ERROR_INVALID_STATE; } - return cccd_configure(p_ble_lbs_c->conn_handle, - p_ble_lbs_c->peer_lbs_db.button_cccd_handle, + return cccd_configure(p_ble_lbs_c, true); } @@ -357,24 +287,22 @@ uint32_t ble_lbs_led_status_send(ble_lbs_c_t * p_ble_lbs_c, uint8_t status) return NRF_ERROR_INVALID_STATE; } - NRF_LOG_DEBUG("writing LED status 0x%x", status); + NRF_LOG_DEBUG("Writing LED status 0x%x", status); - tx_message_t * p_msg; + nrf_ble_gq_req_t write_req; - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; + memset(&write_req, 0, sizeof(nrf_ble_gq_req_t)); - p_msg->req.write_req.gattc_params.handle = p_ble_lbs_c->peer_lbs_db.led_handle; - p_msg->req.write_req.gattc_params.len = sizeof(status); - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_CMD; - p_msg->req.write_req.gattc_value[0] = status; - p_msg->conn_handle = p_ble_lbs_c->conn_handle; - p_msg->type = WRITE_REQ; + write_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + write_req.error_handler.cb = gatt_error_handler; + write_req.error_handler.p_ctx = p_ble_lbs_c; + write_req.params.gattc_write.handle = p_ble_lbs_c->peer_lbs_db.led_handle; + write_req.params.gattc_write.len = sizeof(status); + write_req.params.gattc_write.p_value = &status; + write_req.params.gattc_write.offset = 0; + write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD; - tx_buffer_process(); - return NRF_SUCCESS; + return nrf_ble_gq_item_add(p_ble_lbs_c->p_gatt_queue, &write_req, p_ble_lbs_c->conn_handle); } uint32_t ble_lbs_c_handles_assign(ble_lbs_c_t * p_ble_lbs_c, @@ -388,7 +316,7 @@ uint32_t ble_lbs_c_handles_assign(ble_lbs_c_t * p_ble_lbs_c, { p_ble_lbs_c->peer_lbs_db = *p_peer_handles; } - return NRF_SUCCESS; + return nrf_ble_gq_conn_handle_register(p_ble_lbs_c->p_gatt_queue, conn_handle); } #endif // NRF_MODULE_ENABLED(BLE_LBS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h index 8d3bf7d..8c7394b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lbs_c/ble_lbs_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,21 +35,21 @@ * 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 ble_lbs_c LED Button Service Client * @{ * @ingroup ble_sdk_srv - * @brief The LED Button Service client can be used to set a LED, and read a button state on a + * @brief The LED Button Service client can be used to set up a LED and read a button state on a * LED button service server. * * @details This module contains the APIs and types exposed by the LED Button Service Client - * module. These APIs and types can be used by the application to perform discovery of - * LED Button Service at the peer and interact with it. + * module. The application can use these APIs and types to perform the discovery of + * LED Button Service at the peer and to interact with it. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_lbs_c_t instance; @@ -64,6 +64,8 @@ #include #include "ble.h" #include "ble_db_discovery.h" +#include "ble_srv_common.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus @@ -102,8 +104,8 @@ NRF_SDH_BLE_OBSERVERS(_name ## _obs, /**@brief LBS Client event type. */ typedef enum { - BLE_LBS_C_EVT_DISCOVERY_COMPLETE = 1, /**< Event indicating that the LED Button Service has been discovered at the peer. */ - BLE_LBS_C_EVT_BUTTON_NOTIFICATION /**< Event indicating that a notification of the LED Button Button characteristic has been received from the peer. */ + BLE_LBS_C_EVT_DISCOVERY_COMPLETE = 1, /**< Event indicating that the LED Button Service was discovered at the peer. */ + BLE_LBS_C_EVT_BUTTON_NOTIFICATION /**< Event indicating that a notification of the LED Button Button characteristic was received from the peer. */ } ble_lbs_c_evt_type_t; /**@brief Structure containing the Button value received from the peer. */ @@ -127,8 +129,8 @@ typedef struct uint16_t conn_handle; /**< Connection handle on which the event occured.*/ union { - ble_button_t button; /**< Button Value received. This will be filled if the evt_type is @ref BLE_LBS_C_EVT_BUTTON_NOTIFICATION. */ - lbs_db_t peer_db; /**< LED Button Service related handles found on the peer device. This will be filled if the evt_type is @ref BLE_LBS_C_EVT_DISCOVERY_COMPLETE.*/ + ble_button_t button; /**< Button value received. This is filled if the evt_type is @ref BLE_LBS_C_EVT_BUTTON_NOTIFICATION. */ + lbs_db_t peer_db; /**< Handles related to the LED Button Service found on the peer device. This is filled if the evt_type is @ref BLE_LBS_C_EVT_DISCOVERY_COMPLETE.*/ } params; } ble_lbs_c_evt_t; @@ -137,7 +139,7 @@ typedef struct ble_lbs_c_s ble_lbs_c_t; /**@brief Event handler type. * - * @details This is the type of the event handler that should be provided by the application + * @details This is the type of the event handler that is to be provided by the application * of this module in order to receive events. */ typedef void (* ble_lbs_c_evt_handler_t) (ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_evt_t * p_evt); @@ -145,31 +147,35 @@ typedef void (* ble_lbs_c_evt_handler_t) (ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_e /**@brief LED Button Client structure. */ struct ble_lbs_c_s { - uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */ - lbs_db_t peer_lbs_db; /**< Handles related to LBS on the peer*/ - ble_lbs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the LED Button service. */ - uint8_t uuid_type; /**< UUID type. */ + uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */ + lbs_db_t peer_lbs_db; /**< Handles related to LBS on the peer. */ + ble_lbs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the LED Button service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + uint8_t uuid_type; /**< UUID type. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ }; /**@brief LED Button Client initialization structure. */ typedef struct { - ble_lbs_c_evt_handler_t evt_handler; /**< Event handler to be called by the LED Button Client module whenever there is an event related to the LED Button Service. */ + ble_lbs_c_evt_handler_t evt_handler; /**< Event handler to be called by the LED Button Client module when there is an event related to the LED Button Service. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ } ble_lbs_c_init_t; /**@brief Function for initializing the LED Button client module. * - * @details This function will register with the DB Discovery module. There it registers for the - * LED Button Service. Doing so will make the DB Discovery module look for the presence - * of a LED Button Service instance at the peer when a discovery is started. + * @details This function registers with the Database Discovery module for the + * LED Button Service. The module looks for the presence of a LED Button Service instance + * at the peer when a discovery is started. * * @param[in] p_ble_lbs_c Pointer to the LED Button client structure. - * @param[in] p_ble_lbs_c_init Pointer to the LED Button initialization structure containing the + * @param[in] p_ble_lbs_c_init Pointer to the LED Button initialization structure that contains the * initialization information. * - * @retval NRF_SUCCESS On successful initialization. Otherwise an error code. This function - * propagates the error code returned by the Database Discovery module API + * @retval NRF_SUCCESS On successful initialization. + * @retval err_code Otherwise, this function propagates the error code returned by the Database Discovery module API * @ref ble_db_discovery_evt_register. */ uint32_t ble_lbs_c_init(ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_init_t * p_ble_lbs_c_init); @@ -177,8 +183,8 @@ uint32_t ble_lbs_c_init(ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_init_t * p_ble_lbs_ /**@brief Function for handling BLE events from the SoftDevice. * - * @details This function will handle the BLE events received from the SoftDevice. If a BLE event - * is relevant to the LED Button Client module, then it uses it to update interval + * @details This function handles the BLE events received from the SoftDevice. If a BLE event + * is relevant to the LED Button Client module, the function uses the event's data to update interval * variables and, if necessary, send events to the application. * * @param[in] p_ble_evt Pointer to the BLE event. @@ -190,45 +196,49 @@ void ble_lbs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); /**@brief Function for requesting the peer to start sending notification of the Button * Characteristic. * - * @details This function will enable to notification of the Button at the peer - * by writing to the CCCD of the Button Characteristic. + * @details This function enables to notification of the Button at the peer + * by writing to the CCCD of the Button characteristic. * * @param[in] p_ble_lbs_c Pointer to the LED Button Client structure. * - * @retval NRF_SUCCESS If the SoftDevice has been requested to write to the CCCD of the peer. - * Otherwise, an error code. This function propagates the error code returned - * by the SoftDevice API @ref sd_ble_gattc_write. - * NRF_ERROR_INVALID_STATE if no connection handle has been assigned (@ref ble_lbs_c_handles_assign) - * NRF_ERROR_NULL if the given parameter is NULL + * @retval NRF_SUCCESS If the SoftDevice has been requested to write to the CCCD of the peer. + * @retval NRF_ERROR_INVALID_STATE If no connection handle has been assigned (@ref ble_lbs_c_handles_assign). + * @retval NRF_ERROR_NULL If the given parameter is NULL. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ uint32_t ble_lbs_c_button_notif_enable(ble_lbs_c_t * p_ble_lbs_c); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details Call this function when getting a callback event from the DB discovery module. This - * function will handle an event from the database discovery module, and determine if it - * relates to the discovery of LED Button service at the peer. If so, it will call the - * application's event handler indicating that the LED Button service has been discovered - * at the peer. It also populates the event with the service related information before + * @details Call this function when you get a callback event from the Database Discovery module. This + * function handles an event from the Database Discovery module, and determines whether it + * relates to the discovery of LED Button service at the peer. If it does, this function calls the + * application's event handler to indicate that the LED Button service was discovered + * at the peer. The function also populates the event with service-related information before * providing it to the application. * * @param[in] p_ble_lbs_c Pointer to the LED Button client structure. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void ble_lbs_on_db_disc_evt(ble_lbs_c_t * p_ble_lbs_c, const ble_db_discovery_evt_t * p_evt); -/**@brief Function for assigning a Handles to this instance of lbs_c. +/**@brief Function for assigning handles to this instance of lbs_c. * - * @details Call this function when a link has been established with a peer to associate this link - * to this instance of the module. This makes it possible to handle several links and + * @details Call this function when a link has been established with a peer to associate the link + * to this instance of the module. This makes it possible to handle several links and * associate each link to a particular instance of this module. * - * @param[in] p_ble_lbs_c Pointer to the LED Button client structure instance to associate. + * @param[in] p_ble_lbs_c Pointer to the LED Button client structure instance for associating the link. * @param[in] conn_handle Connection handle to associate with the given LED Button Client Instance. * @param[in] p_peer_handles LED Button Service handles found on the peer (from @ref BLE_LBS_C_EVT_DISCOVERY_COMPLETE event). * + * @retval NRF_SUCCESS If the status was sent successfully. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. + * */ uint32_t ble_lbs_c_handles_assign(ble_lbs_c_t * p_ble_lbs_c, uint16_t conn_handle, @@ -240,7 +250,9 @@ uint32_t ble_lbs_c_handles_assign(ble_lbs_c_t * p_ble_lbs_c, * @param[in] p_ble_lbs_c Pointer to the LED Button client structure. * @param[in] status LED status to send. * - * @retval NRF_SUCCESS If the staus was sent successfully. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If the status was sent successfully. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_conn_handle_register. */ uint32_t ble_lbs_led_status_send(ble_lbs_c_t * p_ble_lbs_c, uint8_t status); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lls/ble_lls.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lls/ble_lls.c similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lls/ble_lls.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lls/ble_lls.c index 6a12dd4..4cda359 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lls/ble_lls.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lls/ble_lls.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -149,62 +149,11 @@ void ble_lls_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) } -/**@brief Function for adding Alert Level characteristics. - * - * @param[in] p_lls Link Loss Service structure. - * @param[in] p_lls_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t alert_level_char_add(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t initial_alert_level; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.char_props.write = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_ALERT_LEVEL_CHAR); - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_lls_init->lls_attr_md.read_perm; - attr_md.write_perm = p_lls_init->lls_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - initial_alert_level = p_lls_init->initial_alert_level; - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (uint8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint8_t); - attr_char_value.p_value = &initial_alert_level; - - return sd_ble_gatts_characteristic_add(p_lls->service_handle, - &char_md, - &attr_char_value, - &p_lls->alert_level_handles); -} - - uint32_t ble_lls_init(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + uint32_t err_code; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; if (p_lls == NULL || p_lls_init == NULL) { @@ -226,14 +175,26 @@ uint32_t ble_lls_init(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init) err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_lls->service_handle); - if (err_code != NRF_SUCCESS) { return err_code; } // Add alert level characteristic - return alert_level_char_add(p_lls, p_lls_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + + add_char_params.uuid = BLE_UUID_ALERT_LEVEL_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.char_props.read = 1; + add_char_params.char_props.write = 1; + add_char_params.write_access = p_lls_init->alert_level_wr_sec; + add_char_params.read_access = p_lls_init->alert_level_rd_sec; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = (uint8_t *) &(p_lls_init->initial_alert_level); + + return characteristic_add(p_lls->service_handle, + &add_char_params, + &p_lls->alert_level_handles); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lls/ble_lls.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lls/ble_lls.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lls/ble_lls.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lls/ble_lls.h index 8b573ad..8af82a3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_lls/ble_lls.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_lls/ble_lls.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -120,7 +120,8 @@ typedef struct ble_lls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Link Loss Service. */ ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ uint8_t initial_alert_level; /**< Initial value of the Alert Level characteristic. */ - ble_srv_security_mode_t lls_attr_md; /**< Initial Security Setting for Link Loss Service Characteristics. */ + security_req_t alert_level_rd_sec; /**< Security requirement for reading Alert Level characteristic. */ + security_req_t alert_level_wr_sec; /**< Security requirement for writing Alert Level characteristic. */ } ble_lls_init_t; /**@brief Link Loss Service structure. This contains various status information for the service. */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.c new file mode 100644 index 0000000..9aa25f8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.c @@ -0,0 +1,354 @@ +/** + * Copyright (c) 2012 - 2019, 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(BLE_NUS) +#include "ble.h" +#include "ble_nus.h" +#include "ble_srv_common.h" + +#define NRF_LOG_MODULE_NAME ble_nus +#if BLE_NUS_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL BLE_NUS_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR BLE_NUS_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR BLE_NUS_CONFIG_DEBUG_COLOR +#else // BLE_NUS_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // BLE_NUS_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0003 /**< The UUID of the TX Characteristic. */ +#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0002 /**< The UUID of the RX Characteristic. */ + +#define BLE_NUS_MAX_RX_CHAR_LEN BLE_NUS_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */ +#define BLE_NUS_MAX_TX_CHAR_LEN BLE_NUS_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */ + +#define NUS_BASE_UUID {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */ + + +/**@brief Function for handling the @ref BLE_GAP_EVT_CONNECTED event from the SoftDevice. + * + * @param[in] p_nus Nordic UART Service structure. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_connect(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_nus_evt_t evt; + ble_gatts_value_t gatts_val; + uint8_t cccd_value[2]; + ble_nus_client_context_t * p_client = NULL; + + err_code = blcm_link_ctx_get(p_nus->p_link_ctx_storage, + p_ble_evt->evt.gap_evt.conn_handle, + (void *) &p_client); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Link context for 0x%02X connection handle could not be fetched.", + p_ble_evt->evt.gap_evt.conn_handle); + } + + /* Check the hosts CCCD value to inform of readiness to send data using the RX characteristic */ + memset(&gatts_val, 0, sizeof(ble_gatts_value_t)); + gatts_val.p_value = cccd_value; + gatts_val.len = sizeof(cccd_value); + gatts_val.offset = 0; + + err_code = sd_ble_gatts_value_get(p_ble_evt->evt.gap_evt.conn_handle, + p_nus->tx_handles.cccd_handle, + &gatts_val); + + if ((err_code == NRF_SUCCESS) && + (p_nus->data_handler != NULL) && + ble_srv_is_notification_enabled(gatts_val.p_value)) + { + if (p_client != NULL) + { + p_client->is_notification_enabled = true; + } + + memset(&evt, 0, sizeof(ble_nus_evt_t)); + evt.type = BLE_NUS_EVT_COMM_STARTED; + evt.p_nus = p_nus; + evt.conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + evt.p_link_ctx = p_client; + + p_nus->data_handler(&evt); + } +} + + +/**@brief Function for handling the @ref BLE_GATTS_EVT_WRITE event from the SoftDevice. + * + * @param[in] p_nus Nordic UART Service structure. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_write(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_nus_evt_t evt; + ble_nus_client_context_t * p_client; + ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + + err_code = blcm_link_ctx_get(p_nus->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_client); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Link context for 0x%02X connection handle could not be fetched.", + p_ble_evt->evt.gatts_evt.conn_handle); + } + + memset(&evt, 0, sizeof(ble_nus_evt_t)); + evt.p_nus = p_nus; + evt.conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; + evt.p_link_ctx = p_client; + + if ((p_evt_write->handle == p_nus->tx_handles.cccd_handle) && + (p_evt_write->len == 2)) + { + if (p_client != NULL) + { + if (ble_srv_is_notification_enabled(p_evt_write->data)) + { + p_client->is_notification_enabled = true; + evt.type = BLE_NUS_EVT_COMM_STARTED; + } + else + { + p_client->is_notification_enabled = false; + evt.type = BLE_NUS_EVT_COMM_STOPPED; + } + + if (p_nus->data_handler != NULL) + { + p_nus->data_handler(&evt); + } + + } + } + else if ((p_evt_write->handle == p_nus->rx_handles.value_handle) && + (p_nus->data_handler != NULL)) + { + evt.type = BLE_NUS_EVT_RX_DATA; + evt.params.rx_data.p_data = p_evt_write->data; + evt.params.rx_data.length = p_evt_write->len; + + p_nus->data_handler(&evt); + } + else + { + // Do Nothing. This event is not relevant for this service. + } +} + + +/**@brief Function for handling the @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event from the SoftDevice. + * + * @param[in] p_nus Nordic UART Service structure. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_hvx_tx_complete(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code; + ble_nus_evt_t evt; + ble_nus_client_context_t * p_client; + + err_code = blcm_link_ctx_get(p_nus->p_link_ctx_storage, + p_ble_evt->evt.gatts_evt.conn_handle, + (void *) &p_client); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Link context for 0x%02X connection handle could not be fetched.", + p_ble_evt->evt.gatts_evt.conn_handle); + return; + } + + if (p_client->is_notification_enabled) + { + memset(&evt, 0, sizeof(ble_nus_evt_t)); + evt.type = BLE_NUS_EVT_TX_RDY; + evt.p_nus = p_nus; + evt.conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; + evt.p_link_ctx = p_client; + + p_nus->data_handler(&evt); + } +} + + +void ble_nus_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) +{ + if ((p_context == NULL) || (p_ble_evt == NULL)) + { + return; + } + + ble_nus_t * p_nus = (ble_nus_t *)p_context; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + on_connect(p_nus, p_ble_evt); + break; + + case BLE_GATTS_EVT_WRITE: + on_write(p_nus, p_ble_evt); + break; + + case BLE_GATTS_EVT_HVN_TX_COMPLETE: + on_hvx_tx_complete(p_nus, p_ble_evt); + break; + + default: + // No implementation needed. + break; + } +} + + +uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init) +{ + ret_code_t err_code; + ble_uuid_t ble_uuid; + ble_uuid128_t nus_base_uuid = NUS_BASE_UUID; + ble_add_char_params_t add_char_params; + + VERIFY_PARAM_NOT_NULL(p_nus); + VERIFY_PARAM_NOT_NULL(p_nus_init); + + // Initialize the service structure. + p_nus->data_handler = p_nus_init->data_handler; + + /**@snippet [Adding proprietary Service to the SoftDevice] */ + // Add a custom base UUID. + err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type); + VERIFY_SUCCESS(err_code); + + ble_uuid.type = p_nus->uuid_type; + ble_uuid.uuid = BLE_UUID_NUS_SERVICE; + + // Add the service. + err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, + &ble_uuid, + &p_nus->service_handle); + /**@snippet [Adding proprietary Service to the SoftDevice] */ + VERIFY_SUCCESS(err_code); + + // Add the RX Characteristic. + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_NUS_RX_CHARACTERISTIC; + add_char_params.uuid_type = p_nus->uuid_type; + add_char_params.max_len = BLE_NUS_MAX_RX_CHAR_LEN; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.is_var_len = true; + add_char_params.char_props.write = 1; + add_char_params.char_props.write_wo_resp = 1; + + add_char_params.read_access = SEC_OPEN; + add_char_params.write_access = SEC_OPEN; + + err_code = characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->rx_handles); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Add the TX Characteristic. + /**@snippet [Adding proprietary characteristic to the SoftDevice] */ + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_NUS_TX_CHARACTERISTIC; + add_char_params.uuid_type = p_nus->uuid_type; + add_char_params.max_len = BLE_NUS_MAX_TX_CHAR_LEN; + add_char_params.init_len = sizeof(uint8_t); + add_char_params.is_var_len = true; + add_char_params.char_props.notify = 1; + + add_char_params.read_access = SEC_OPEN; + add_char_params.write_access = SEC_OPEN; + add_char_params.cccd_write_access = SEC_OPEN; + + return characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->tx_handles); + /**@snippet [Adding proprietary characteristic to the SoftDevice] */ +} + + +uint32_t ble_nus_data_send(ble_nus_t * p_nus, + uint8_t * p_data, + uint16_t * p_length, + uint16_t conn_handle) +{ + ret_code_t err_code; + ble_gatts_hvx_params_t hvx_params; + ble_nus_client_context_t * p_client; + + VERIFY_PARAM_NOT_NULL(p_nus); + + err_code = blcm_link_ctx_get(p_nus->p_link_ctx_storage, conn_handle, (void *) &p_client); + VERIFY_SUCCESS(err_code); + + if ((conn_handle == BLE_CONN_HANDLE_INVALID) || (p_client == NULL)) + { + return NRF_ERROR_NOT_FOUND; + } + + if (!p_client->is_notification_enabled) + { + return NRF_ERROR_INVALID_STATE; + } + + if (*p_length > BLE_NUS_MAX_DATA_LEN) + { + return NRF_ERROR_INVALID_PARAM; + } + + memset(&hvx_params, 0, sizeof(hvx_params)); + + hvx_params.handle = p_nus->tx_handles.value_handle; + hvx_params.p_data = p_data; + hvx_params.p_len = p_length; + hvx_params.type = BLE_GATT_HVX_NOTIFICATION; + + return sd_ble_gatts_hvx(conn_handle, &hvx_params); +} + + +#endif // NRF_MODULE_ENABLED(BLE_NUS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.h similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.h index 58ced4a..2926446 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus/ble_nus.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus/ble_nus.h @@ -1,30 +1,30 @@ -/** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + /** + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -69,6 +69,7 @@ #include "ble.h" #include "ble_srv_common.h" #include "nrf_sdh_ble.h" +#include "ble_link_ctx_manager.h" #ifdef __cplusplus extern "C" { @@ -76,19 +77,27 @@ extern "C" { /**@brief Macro for defining a ble_nus instance. * - * @param _name Name of the instance. + * @param _name Name of the instance. + * @param[in] _nus_max_clients Maximum number of NUS clients connected at a time. * @hideinitializer */ -#define BLE_NUS_DEF(_name) \ -static ble_nus_t _name; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - BLE_NUS_BLE_OBSERVER_PRIO, \ - ble_nus_on_ble_evt, &_name) - -#define BLE_UUID_NUS_SERVICE 0x0001 /**< The UUID of the Nordic UART Service. */ - -#define OPCODE_LENGTH 1 -#define HANDLE_LENGTH 2 +#define BLE_NUS_DEF(_name, _nus_max_clients) \ + BLE_LINK_CTX_MANAGER_DEF(CONCAT_2(_name, _link_ctx_storage), \ + (_nus_max_clients), \ + sizeof(ble_nus_client_context_t)); \ + static ble_nus_t _name = \ + { \ + .p_link_ctx_storage = &CONCAT_2(_name, _link_ctx_storage) \ + }; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + BLE_NUS_BLE_OBSERVER_PRIO, \ + ble_nus_on_ble_evt, \ + &_name) + +#define BLE_UUID_NUS_SERVICE 0x0001 /**< The UUID of the Nordic UART Service. */ + +#define OPCODE_LENGTH 1 +#define HANDLE_LENGTH 2 /**@brief Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */ #if defined(NRF_SDH_BLE_GATT_MAX_MTU_SIZE) && (NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 0) @@ -98,46 +107,62 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, #warning NRF_SDH_BLE_GATT_MAX_MTU_SIZE is not defined. #endif + /**@brief Nordic UART Service event types. */ typedef enum { - BLE_NUS_EVT_RX_DATA, /**< Data received. */ - BLE_NUS_EVT_TX_RDY, /**< Service is ready to accept new data to be transmitted. */ - BLE_NUS_EVT_COMM_STARTED, /**< Notification has been enabled. */ - BLE_NUS_EVT_COMM_STOPPED, /**< Notification has been disabled. */ + BLE_NUS_EVT_RX_DATA, /**< Data received. */ + BLE_NUS_EVT_TX_RDY, /**< Service is ready to accept new data to be transmitted. */ + BLE_NUS_EVT_COMM_STARTED, /**< Notification has been enabled. */ + BLE_NUS_EVT_COMM_STOPPED, /**< Notification has been disabled. */ } ble_nus_evt_type_t; - /* Forward declaration of the ble_nus_t type. */ typedef struct ble_nus_s ble_nus_t; + /**@brief Nordic UART Service @ref BLE_NUS_EVT_RX_DATA event data. * * @details This structure is passed to an event when @ref BLE_NUS_EVT_RX_DATA occurs. */ typedef struct { - uint8_t const * p_data; /**< A pointer to the buffer with received data. */ - uint16_t length; /**< Length of received data. */ + uint8_t const * p_data; /**< A pointer to the buffer with received data. */ + uint16_t length; /**< Length of received data. */ } ble_nus_evt_rx_data_t; + +/**@brief Nordic UART Service client context structure. + * + * @details This structure contains state context related to hosts. + */ +typedef struct +{ + bool is_notification_enabled; /**< Variable to indicate if the peer has enabled notification of the RX characteristic.*/ +} ble_nus_client_context_t; + + /**@brief Nordic UART Service event structure. * * @details This structure is passed to an event coming from service. */ typedef struct { - ble_nus_evt_type_t type; /**< Event type. */ - ble_nus_t * p_nus; /**< A pointer to the instance. */ + ble_nus_evt_type_t type; /**< Event type. */ + ble_nus_t * p_nus; /**< A pointer to the instance. */ + uint16_t conn_handle; /**< Connection handle. */ + ble_nus_client_context_t * p_link_ctx; /**< A pointer to the link context. */ union { ble_nus_evt_rx_data_t rx_data; /**< @ref BLE_NUS_EVT_RX_DATA event data. */ } params; } ble_nus_evt_t; -/**@brief Nordic UART Service event handler type. */ -typedef void (*ble_nus_data_handler_t) (ble_nus_evt_t * p_evt); + +/**@brief Nordic UART Service event handler type. */ +typedef void (* ble_nus_data_handler_t) (ble_nus_evt_t * p_evt); + /**@brief Nordic UART Service initialization structure. * @@ -150,19 +175,19 @@ typedef struct ble_nus_data_handler_t data_handler; /**< Event handler to be called for handling received data. */ } ble_nus_init_t; + /**@brief Nordic UART Service structure. * * @details This structure contains status information related to the service. */ struct ble_nus_s { - uint8_t uuid_type; /**< UUID type for Nordic UART Service Base UUID. */ - uint16_t service_handle; /**< Handle of Nordic UART Service (as provided by the SoftDevice). */ - ble_gatts_char_handles_t tx_handles; /**< Handles related to the TX characteristic (as provided by the SoftDevice). */ - ble_gatts_char_handles_t rx_handles; /**< Handles related to the RX characteristic (as provided by the SoftDevice). */ - uint16_t conn_handle; /**< Handle of the current connection (as provided by the SoftDevice). BLE_CONN_HANDLE_INVALID if not in a connection. */ - bool is_notification_enabled; /**< Variable to indicate if the peer has enabled notification of the RX characteristic.*/ - ble_nus_data_handler_t data_handler; /**< Event handler to be called for handling received data. */ + uint8_t uuid_type; /**< UUID type for Nordic UART Service Base UUID. */ + uint16_t service_handle; /**< Handle of Nordic UART Service (as provided by the SoftDevice). */ + ble_gatts_char_handles_t tx_handles; /**< Handles related to the TX characteristic (as provided by the SoftDevice). */ + ble_gatts_char_handles_t rx_handles; /**< Handles related to the RX characteristic (as provided by the SoftDevice). */ + blcm_link_ctx_storage_t * const p_link_ctx_storage; /**< Pointer to link context storage with handles of all current connections and its context. */ + ble_nus_data_handler_t data_handler; /**< Event handler to be called for handling received data. */ }; @@ -192,18 +217,22 @@ uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init); void ble_nus_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); -/**@brief Function for sending a string to the peer. +/**@brief Function for sending a data to the peer. * * @details This function sends the input string as an RX characteristic notification to the * peer. * - * @param[in] p_nus Pointer to the Nordic UART Service structure. - * @param[in] p_string String to be sent. - * @param[inout] p_length Pointer Length of the string. Amount of sent bytes. + * @param[in] p_nus Pointer to the Nordic UART Service structure. + * @param[in] p_data String to be sent. + * @param[in,out] p_length Pointer Length of the string. Amount of sent bytes. + * @param[in] conn_handle Connection Handle of the destination client. * * @retval NRF_SUCCESS If the string was sent successfully. Otherwise, an error code is returned. */ -uint32_t ble_nus_string_send(ble_nus_t * p_nus, uint8_t * p_string, uint16_t * p_length); +uint32_t ble_nus_data_send(ble_nus_t * p_nus, + uint8_t * p_data, + uint16_t * p_length, + uint16_t conn_handle); #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus_c/ble_nus_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus_c/ble_nus_c.c similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus_c/ble_nus_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus_c/ble_nus_c.c index b8f3cd3..6b243d8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus_c/ble_nus_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus_c/ble_nus_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -48,10 +48,32 @@ #include "ble_srv_common.h" #include "app_error.h" -#define NRF_LOG_MODULE_NAME ble_nus +#define NRF_LOG_MODULE_NAME ble_nus_c #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); + +/**@brief Function for intercepting the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_nus_c_t * p_ble_nus_c = (ble_nus_c_t *)p_ctx; + + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); + + if (p_ble_nus_c->error_handler != NULL) + { + p_ble_nus_c->error_handler(nrf_error); + } +} + + void ble_nus_c_on_db_disc_evt(ble_nus_c_t * p_ble_nus_c, ble_db_discovery_evt_t * p_evt) { ble_nus_c_evt_t nus_c_evt; @@ -92,11 +114,10 @@ void ble_nus_c_on_db_disc_evt(ble_nus_c_t * p_ble_nus_c, ble_db_discovery_evt_t /**@brief Function for handling Handle Value Notification received from the SoftDevice. * - * @details This function will uses the Handle Value Notification received from the SoftDevice - * and checks if it is a notification of the NUS TX characteristic from the peer. If - * it is, this function will decode the data and send it to the - * application. - * + * @details This function uses the Handle Value Notification received from the SoftDevice + * and checks if it is a notification of the NUS TX characteristic from the peer. + * If it is, this function decodes the data and sends it to the application. + * * @param[in] p_ble_nus_c Pointer to the NUS Client structure. * @param[in] p_ble_evt Pointer to the BLE event received. */ @@ -126,6 +147,7 @@ uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_ VERIFY_PARAM_NOT_NULL(p_ble_nus_c); VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init); + VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init->p_gatt_queue); err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type); VERIFY_SUCCESS(err_code); @@ -135,8 +157,10 @@ uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_ p_ble_nus_c->conn_handle = BLE_CONN_HANDLE_INVALID; p_ble_nus_c->evt_handler = p_ble_nus_c_init->evt_handler; + p_ble_nus_c->error_handler = p_ble_nus_c_init->error_handler; p_ble_nus_c->handles.nus_tx_handle = BLE_GATT_HANDLE_INVALID; p_ble_nus_c->handles.nus_rx_handle = BLE_GATT_HANDLE_INVALID; + p_ble_nus_c->p_gatt_queue = p_ble_nus_c_init->p_gatt_queue; return ble_db_discovery_evt_register(&uart_uuid); } @@ -150,8 +174,8 @@ void ble_nus_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) return; } - if ( (p_ble_nus_c->conn_handle != BLE_CONN_HANDLE_INVALID) - &&(p_ble_nus_c->conn_handle != p_ble_evt->evt.gap_evt.conn_handle) + if ( (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID) + ||(p_ble_nus_c->conn_handle != p_ble_evt->evt.gap_evt.conn_handle) ) { return; @@ -183,24 +207,28 @@ void ble_nus_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) } /**@brief Function for creating a message for writing to the CCCD. */ -static uint32_t cccd_configure(uint16_t conn_handle, uint16_t cccd_handle, bool enable) +static uint32_t cccd_configure(ble_nus_c_t * p_ble_nus_c, bool notification_enable) { - uint8_t buf[BLE_CCCD_VALUE_LEN]; - - buf[0] = enable ? BLE_GATT_HVX_NOTIFICATION : 0; - buf[1] = 0; - - ble_gattc_write_params_t const write_params = - { - .write_op = BLE_GATT_OP_WRITE_REQ, - .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE, - .handle = cccd_handle, - .offset = 0, - .len = sizeof(buf), - .p_value = buf - }; - - return sd_ble_gattc_write(conn_handle, &write_params); + nrf_ble_gq_req_t cccd_req; + uint8_t cccd[BLE_CCCD_VALUE_LEN]; + uint16_t cccd_val = notification_enable ? BLE_GATT_HVX_NOTIFICATION : 0; + + memset(&cccd_req, 0, sizeof(nrf_ble_gq_req_t)); + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + cccd_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + cccd_req.error_handler.cb = gatt_error_handler; + cccd_req.error_handler.p_ctx = p_ble_nus_c; + cccd_req.params.gattc_write.handle = p_ble_nus_c->handles.nus_tx_cccd_handle; + cccd_req.params.gattc_write.len = BLE_CCCD_VALUE_LEN; + cccd_req.params.gattc_write.offset = 0; + cccd_req.params.gattc_write.p_value = cccd; + cccd_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + cccd_req.params.gattc_write.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE; + + return nrf_ble_gq_item_add(p_ble_nus_c->p_gatt_queue, &cccd_req, p_ble_nus_c->conn_handle); } @@ -214,7 +242,7 @@ uint32_t ble_nus_c_tx_notif_enable(ble_nus_c_t * p_ble_nus_c) { return NRF_ERROR_INVALID_STATE; } - return cccd_configure(p_ble_nus_c->conn_handle,p_ble_nus_c->handles.nus_tx_cccd_handle, true); + return cccd_configure(p_ble_nus_c, true); } @@ -222,6 +250,10 @@ uint32_t ble_nus_c_string_send(ble_nus_c_t * p_ble_nus_c, uint8_t * p_string, ui { VERIFY_PARAM_NOT_NULL(p_ble_nus_c); + nrf_ble_gq_req_t write_req; + + memset(&write_req, 0, sizeof(nrf_ble_gq_req_t)); + if (length > BLE_NUS_MAX_DATA_LEN) { NRF_LOG_WARNING("Content too long."); @@ -233,17 +265,17 @@ uint32_t ble_nus_c_string_send(ble_nus_c_t * p_ble_nus_c, uint8_t * p_string, ui return NRF_ERROR_INVALID_STATE; } - ble_gattc_write_params_t const write_params = - { - .write_op = BLE_GATT_OP_WRITE_CMD, - .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE, - .handle = p_ble_nus_c->handles.nus_rx_handle, - .offset = 0, - .len = length, - .p_value = p_string - }; - - return sd_ble_gattc_write(p_ble_nus_c->conn_handle, &write_params); + write_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + write_req.error_handler.cb = gatt_error_handler; + write_req.error_handler.p_ctx = p_ble_nus_c; + write_req.params.gattc_write.handle = p_ble_nus_c->handles.nus_rx_handle; + write_req.params.gattc_write.len = length; + write_req.params.gattc_write.offset = 0; + write_req.params.gattc_write.p_value = p_string; + write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD; + write_req.params.gattc_write.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE; + + return nrf_ble_gq_item_add(p_ble_nus_c->p_gatt_queue, &write_req, p_ble_nus_c->conn_handle); } @@ -260,6 +292,6 @@ uint32_t ble_nus_c_handles_assign(ble_nus_c_t * p_ble_nus, p_ble_nus->handles.nus_tx_handle = p_peer_handles->nus_tx_handle; p_ble_nus->handles.nus_rx_handle = p_peer_handles->nus_rx_handle; } - return NRF_SUCCESS; + return nrf_ble_gq_conn_handle_register(p_ble_nus->p_gatt_queue, conn_handle); } #endif // NRF_MODULE_ENABLED(BLE_NUS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus_c/ble_nus_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus_c/ble_nus_c.h similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus_c/ble_nus_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus_c/ble_nus_c.h index c60e6f3..a04909b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_nus_c/ble_nus_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_nus_c/ble_nus_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -45,10 +45,10 @@ * @brief Nordic UART Service Client module. * * @details This module contains the APIs and types exposed by the Nordic UART Service Client - * module. These APIs and types can be used by the application to perform discovery of - * the Nordic UART Service at the peer and interact with it. + * module. The application can use these APIs and types to perform the discovery of + * the Nordic UART Service at the peer and to interact with it. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as the BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_nus_c_t instance; @@ -67,6 +67,8 @@ #include "ble.h" #include "ble_gatt.h" #include "ble_db_discovery.h" +#include "ble_srv_common.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #include "sdk_config.h" @@ -86,7 +88,19 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_NUS_C_BLE_OBSERVER_PRIO, \ ble_nus_c_on_ble_evt, &_name) -#define NUS_BASE_UUID {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */ +/** @brief Macro for defining multiple ble_nus_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_NUS_C_ARRAY_DEF(_name, _cnt) \ +static ble_nus_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_NUS_C_BLE_OBSERVER_PRIO, \ + ble_nus_c_on_ble_evt, &_name, _cnt) + +#define NUS_BASE_UUID {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor-specific UUID. */ #define BLE_UUID_NUS_SERVICE 0x0001 /**< The UUID of the Nordic UART Service. */ #define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0002 /**< The UUID of the RX Characteristic. */ @@ -107,17 +121,17 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, /**@brief NUS Client event type. */ typedef enum { - BLE_NUS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the NUS service and its characteristics was found. */ - BLE_NUS_C_EVT_NUS_TX_EVT, /**< Event indicating that the central has received something from a peer. */ - BLE_NUS_C_EVT_DISCONNECTED /**< Event indicating that the NUS server has disconnected. */ + BLE_NUS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the NUS service and its characteristics were found. */ + BLE_NUS_C_EVT_NUS_TX_EVT, /**< Event indicating that the central received something from a peer. */ + BLE_NUS_C_EVT_DISCONNECTED /**< Event indicating that the NUS server disconnected. */ } ble_nus_c_evt_type_t; /**@brief Handles on the connected peer device needed to interact with it. */ typedef struct { - uint16_t nus_tx_handle; /**< Handle of the NUS TX characteristic as provided by a discovery. */ - uint16_t nus_tx_cccd_handle; /**< Handle of the CCCD of the NUS TX characteristic as provided by a discovery. */ - uint16_t nus_rx_handle; /**< Handle of the NUS RX characteristic as provided by a discovery. */ + uint16_t nus_tx_handle; /**< Handle of the NUS TX characteristic, as provided by a discovery. */ + uint16_t nus_tx_cccd_handle; /**< Handle of the CCCD of the NUS TX characteristic, as provided by a discovery. */ + uint16_t nus_rx_handle; /**< Handle of the NUS RX characteristic, as provided by a discovery. */ } ble_nus_c_handles_t; /**@brief Structure containing the NUS event data received from the peer. */ @@ -127,8 +141,8 @@ typedef struct uint16_t conn_handle; uint16_t max_data_len; uint8_t * p_data; - uint8_t data_len; - ble_nus_c_handles_t handles; /**< Handles on which the Nordic Uart service characteristics was discovered on the peer device. This will be filled if the evt_type is @ref BLE_NUS_C_EVT_DISCOVERY_COMPLETE.*/ + uint16_t data_len; + ble_nus_c_handles_t handles; /**< Handles on which the Nordic UART service characteristics were discovered on the peer device. This is filled if the evt_type is @ref BLE_NUS_C_EVT_DISCOVERY_COMPLETE.*/ } ble_nus_c_evt_t; // Forward declaration of the ble_nus_t type. @@ -136,7 +150,7 @@ typedef struct ble_nus_c_s ble_nus_c_t; /**@brief Event handler type. * - * @details This is the type of the event handler that should be provided by the application + * @details This is the type of the event handler that is to be provided by the application * of this module to receive events. */ typedef void (* ble_nus_c_evt_handler_t)(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_evt); @@ -144,48 +158,51 @@ typedef void (* ble_nus_c_evt_handler_t)(ble_nus_c_t * p_ble_nus_c, ble_nus_c_ev /**@brief NUS Client structure. */ struct ble_nus_c_s { - uint8_t uuid_type; /**< UUID type. */ - uint16_t conn_handle; /**< Handle of the current connection. Set with @ref ble_nus_c_handles_assign when connected. */ - ble_nus_c_handles_t handles; /**< Handles on the connected peer device needed to interact with it. */ - ble_nus_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the NUS. */ + uint8_t uuid_type; /**< UUID type. */ + uint16_t conn_handle; /**< Handle of the current connection. Set with @ref ble_nus_c_handles_assign when connected. */ + ble_nus_c_handles_t handles; /**< Handles on the connected peer device needed to interact with it. */ + ble_nus_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the NUS. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ }; /**@brief NUS Client initialization structure. */ typedef struct { - ble_nus_c_evt_handler_t evt_handler; + ble_nus_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the NUS. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ } ble_nus_c_init_t; /**@brief Function for initializing the Nordic UART client module. * * @details This function registers with the Database Discovery module - * for the NUS. Doing so will make the Database Discovery - * module look for the presence of a NUS instance at the peer when a - * discovery is started. - * + * for the NUS. The Database Discovery module looks for the presence + * of a NUS instance at the peer when a discovery is started. + * * @param[in] p_ble_nus_c Pointer to the NUS client structure. - * @param[in] p_ble_nus_c_init Pointer to the NUS initialization structure containing the + * @param[in] p_ble_nus_c_init Pointer to the NUS initialization structure that contains the * initialization information. * - * @retval NRF_SUCCESS If the module was initialized successfully. Otherwise, an error - * code is returned. This function - * propagates the error code returned by the Database Discovery module API + * @retval NRF_SUCCESS If the module was initialized successfully. + * @retval err_code Otherwise, this function propagates the error code + * returned by the Database Discovery module API * @ref ble_db_discovery_evt_register. */ uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of NUS at the peer. If so, it will - * call the application's event handler indicating that NUS has been - * discovered at the peer. It also populates the event with the service related + * @details This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of NUS at the peer. If it does, the function + * calls the application's event handler to indicate that NUS was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * * @param[in] p_ble_nus_c Pointer to the NUS client structure. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void ble_nus_c_on_db_disc_evt(ble_nus_c_t * p_ble_nus_c, ble_db_discovery_evt_t * p_evt); @@ -193,7 +210,7 @@ uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_ /**@brief Function for handling BLE events from the SoftDevice. * * @details This function handles the BLE events received from the SoftDevice. If a BLE - * event is relevant to the NUS module, it is used to update + * event is relevant to the NUS module, the function uses the event's data to update * internal variables and, if necessary, send events to the application. * * @param[in] p_ble_evt Pointer to the BLE event. @@ -209,9 +226,8 @@ void ble_nus_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); * * @param p_ble_nus_c Pointer to the NUS client structure. * - * @retval NRF_SUCCESS If the SoftDevice has been requested to write to the CCCD of the peer. - * Otherwise, an error code is returned. This function propagates the error - * code returned by the SoftDevice API @ref sd_ble_gattc_write. + * @retval NRF_SUCCESS If the operation was successful. + * @retval err_code Otherwise, this API propagates the error code returned by function @ref nrf_ble_gq_item_add. */ uint32_t ble_nus_c_tx_notif_enable(ble_nus_c_t * p_ble_nus_c); @@ -224,17 +240,18 @@ uint32_t ble_nus_c_tx_notif_enable(ble_nus_c_t * p_ble_nus_c); * @param[in] p_string String to be sent. * @param[in] length Length of the string. * - * @retval NRF_SUCCESS If the string was sent successfully. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If the string was sent successfully. + * @retval err_code Otherwise, this API propagates the error code returned by function @ref nrf_ble_gq_item_add. */ uint32_t ble_nus_c_string_send(ble_nus_c_t * p_ble_nus_c, uint8_t * p_string, uint16_t length); -/**@brief Function for assigning handles to a this instance of nus_c. +/**@brief Function for assigning handles to this instance of nus_c. * * @details Call this function when a link has been established with a peer to - * associate this link to this instance of the module. This makes it - * possible to handle several link and associate each link to a particular - * instance of this module. The connection handle and attribute handles will be + * associate the link to this instance of the module. This makes it + * possible to handle several links and associate each link to a particular + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_NUS_C_EVT_DISCOVERY_COMPLETE. * * @param[in] p_ble_nus_c Pointer to the NUS client structure instance to associate with these @@ -245,6 +262,8 @@ uint32_t ble_nus_c_string_send(ble_nus_c_t * p_ble_nus_c, uint8_t * p_string, ui * * @retval NRF_SUCCESS If the operation was successful. * @retval NRF_ERROR_NULL If a p_nus was a NULL pointer. + * @retval err_code Otherwise, this API propagates the error code returned + * by function @ref nrf_ble_gq_item_add. */ uint32_t ble_nus_c_handles_assign(ble_nus_c_t * p_ble_nus_c, uint16_t conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs/ble_rscs.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs/ble_rscs.c similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs/ble_rscs.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs/ble_rscs.c index ede8fe9..84fad38 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs/ble_rscs.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs/ble_rscs.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -215,119 +215,6 @@ static uint8_t rsc_measurement_encode(const ble_rscs_t * p_rscs, } -/**@brief Function for adding RSC Measurement characteristics. - * - * @param[in] p_rscs Running Speed and Cadence Service structure. - * @param[in] p_rscs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t rsc_measurement_char_add(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_md_t cccd_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint8_t encoded_rcm[MAX_RSCM_LEN]; - - memset(&cccd_md, 0, sizeof(cccd_md)); - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - cccd_md.write_perm = p_rscs_init->rsc_meas_attr_md.cccd_write_perm; - cccd_md.vloc = BLE_GATTS_VLOC_STACK; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.notify = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = &cccd_md; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_RSC_MEASUREMENT_CHAR); - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_rscs_init->rsc_meas_attr_md.read_perm; - attr_md.write_perm = p_rscs_init->rsc_meas_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 1; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = rsc_measurement_encode(p_rscs, &p_rscs_init->initial_rcm, encoded_rcm); - attr_char_value.init_offs = 0; - attr_char_value.max_len = MAX_RSCM_LEN; - attr_char_value.p_value = encoded_rcm; - - return sd_ble_gatts_characteristic_add(p_rscs->service_handle, - &char_md, - &attr_char_value, - &p_rscs->meas_handles); -} - - -/**@brief Function for adding RSC Feature characteristics. - * - * @param[in] p_rscs Running Speed and Cadence Service structure. - * @param[in] p_rscs_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t rsc_feature_char_add(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - uint16_t init_value_feature; - uint8_t init_value_encoded[2]; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_RSC_FEATURE_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_rscs_init->rsc_feature_attr_md.read_perm; - attr_md.write_perm = p_rscs_init->rsc_feature_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - init_value_feature = p_rscs_init->feature; - init_value_encoded[0] = init_value_feature & 0xFF; - init_value_encoded[1] = (init_value_feature >> 8) & 0xFF; - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (uint16_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint16_t); - attr_char_value.p_value = init_value_encoded; - - return sd_ble_gatts_characteristic_add(p_rscs->service_handle, - &char_md, - &attr_char_value, - &p_rscs->feature_handles); -} - - uint32_t ble_rscs_init(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init) { if (p_rscs == NULL || p_rscs_init == NULL) @@ -335,8 +222,10 @@ uint32_t ble_rscs_init(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init) return NRF_ERROR_NULL; } - uint32_t err_code; - ble_uuid_t ble_uuid; + uint32_t err_code; + uint8_t init_value_encoded[MAX(MAX_RSCM_LEN, sizeof(uint16_t))]; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; // Initialize service structure p_rscs->evt_handler = p_rscs_init->evt_handler; @@ -356,14 +245,35 @@ uint32_t ble_rscs_init(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init) } // Add measurement characteristic - err_code = rsc_measurement_char_add(p_rscs, p_rscs_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_RSC_MEASUREMENT_CHAR; + add_char_params.max_len = MAX_RSCM_LEN; + add_char_params.is_var_len = true; + add_char_params.char_props.notify = 1; + add_char_params.cccd_write_access = p_rscs_init->rsc_meas_cccd_wr_sec; + add_char_params.p_init_value = init_value_encoded; + add_char_params.init_len = rsc_measurement_encode(p_rscs, + &p_rscs_init->initial_rcm, + init_value_encoded); + + err_code = characteristic_add(p_rscs->service_handle, &add_char_params, &p_rscs->meas_handles); if (err_code != NRF_SUCCESS) { return err_code; } // Add feature characteristic - err_code = rsc_feature_char_add(p_rscs, p_rscs_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_RSC_FEATURE_CHAR; + add_char_params.max_len = sizeof(uint16_t); + add_char_params.init_len = uint16_encode(p_rscs_init->feature, init_value_encoded); + add_char_params.p_init_value = init_value_encoded; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_rscs_init->rsc_feature_rd_sec; + + err_code = characteristic_add(p_rscs->service_handle, + &add_char_params, + &p_rscs->feature_handles); if (err_code != NRF_SUCCESS) { return err_code; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs/ble_rscs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs/ble_rscs.h similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs/ble_rscs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs/ble_rscs.h index bf09ffc..24a04c4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs/ble_rscs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs/ble_rscs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -134,11 +134,11 @@ struct ble_rscs_meas_s */ typedef struct { - ble_rscs_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Running Speed and Cadence Service. */ - ble_srv_cccd_security_mode_t rsc_meas_attr_md; /**< Initial security level for running speed and cadence measurement attribute */ - ble_srv_security_mode_t rsc_feature_attr_md; /**< Initial security level for feature attribute */ - uint16_t feature; /**< Initial value for features of sensor. */ - ble_rscs_meas_t initial_rcm; /**< Initial Running Speed Cadence Measurement.*/ + ble_rscs_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Running Speed and Cadence Service. */ + security_req_t rsc_meas_cccd_wr_sec; /**< Security requirement for writing running speed and cadence measurement characteristic CCCD. */ + security_req_t rsc_feature_rd_sec; /**< Security requirement for reading running speed and cadence feature characteristic. */ + uint16_t feature; /**< Initial value for features of sensor. */ + ble_rscs_meas_t initial_rcm; /**< Initial Running Speed Cadence Measurement.*/ } ble_rscs_init_t; /**@brief Running Speed and Cadence Service structure. This contains various status information for diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c similarity index 60% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c index 98fd37d..c56384d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs_c/ble_rscs_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /**@cond To Make Doxygen skip documentation generation for this file. * @{ @@ -45,107 +45,41 @@ #include "ble_rscs_c.h" #include "ble_db_discovery.h" #include "ble_types.h" -#include "ble_srv_common.h" #include "ble_gattc.h" #define NRF_LOG_MODULE_NAME ble_rscs_c #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define TX_BUFFER_MASK 0x07 /**< TX Buffer mask, must be a mask of continuous zeroes, followed by continuous sequence of ones: 000...111. */ -#define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of send buffer, which is 1 higher than the mask. */ - #define WRITE_MESSAGE_LENGTH BLE_CCCD_VALUE_LEN /**< Length of the write message for CCCD. */ -typedef enum -{ - READ_REQ, /**< Type identifying that this tx_message is a read request. */ - WRITE_REQ /**< Type identifying that this tx_message is a write request. */ -} tx_request_t; - -/**@brief Structure for writing a message to the peer, i.e. CCCD. - */ -typedef struct -{ - uint8_t gattc_value[WRITE_MESSAGE_LENGTH]; /**< The message to write. */ - ble_gattc_write_params_t gattc_params; /**< GATTC parameters for this message. */ -} write_params_t; -/**@brief Structure for holding data to be transmitted to the connected central. +/**@brief Function for intercepting the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. */ -typedef struct +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) { - uint16_t conn_handle; /**< Connection handle to be used when transmitting this message. */ - tx_request_t type; /**< Type of this message, i.e. read or write message. */ - union - { - uint16_t read_handle; /**< Read request message. */ - write_params_t write_req; /**< Write request message. */ - } req; -} tx_message_t; - + ble_rscs_c_t * p_ble_rscs_c = (ble_rscs_c_t *)p_ctx; -static tx_message_t m_tx_buffer[TX_BUFFER_SIZE]; /**< Transmit buffer for messages to be transmitted to the central. */ -static uint32_t m_tx_insert_index = 0; /**< Current index in the transmit buffer where the next message should be inserted. */ -static uint32_t m_tx_index = 0; /**< Current index in the transmit buffer from where the next message to be transmitted resides. */ + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); - -/**@brief Function for passing any pending request from the buffer to the stack. - */ -static void tx_buffer_process(void) -{ - if (m_tx_index != m_tx_insert_index) + if (p_ble_rscs_c->error_handler != NULL) { - uint32_t err_code; - - if (m_tx_buffer[m_tx_index].type == READ_REQ) - { - err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, - m_tx_buffer[m_tx_index].req.read_handle, - 0); - } - else - { - err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, - &m_tx_buffer[m_tx_index].req.write_req.gattc_params); - } - if (err_code == NRF_SUCCESS) - { - NRF_LOG_DEBUG("SD Read/Write API returns Success."); - m_tx_index++; - m_tx_index &= TX_BUFFER_MASK; - } - else - { - NRF_LOG_DEBUG("SD Read/Write API returns error. This message sending will be " - "attempted again.."); - } + p_ble_rscs_c->error_handler(nrf_error); } } -/**@brief Function for handling write response events. - * - * @param[in] p_ble_rscs_c Pointer to the Running Speed and Cadence Client structure. - * @param[in] p_ble_evt Pointer to the BLE event received. - */ -static void on_write_rsp(ble_rscs_c_t * p_ble_rscs_c, const ble_evt_t * p_ble_evt) -{ - // Check if the event if on the link for this instance - if (p_ble_rscs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) - { - return; - } - // Check if there is any message to be sent across to the peer and send it. - tx_buffer_process(); -} - - /**@brief Function for handling Handle Value Notification received from the SoftDevice. * - * @details This function will uses the Handle Value Notification received from the SoftDevice - * and checks if it is a notification of the Running Speed and Cadence measurement from - * the peer. If it is, this function will decode the Running Speed measurement and send it + * @details This function uses the Handle Value Notification received from the SoftDevice + * and checks whether it is a notification of the Running Speed and Cadence measurement from + * the peer. If it is, this function decodes the Running Speed measurement and sends it * to the application. * * @param[in] p_ble_rscs_c Pointer to the Running Speed and Cadence Client structure. @@ -155,7 +89,7 @@ static void on_hvx(ble_rscs_c_t * p_ble_rscs_c, const ble_evt_t * p_ble_evt) { const ble_gattc_evt_hvx_t * p_notif = &p_ble_evt->evt.gattc_evt.params.hvx; - // Check if the event if on the link for this instance + // Check if the event is on the link for this instance if (p_ble_rscs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle) { return; @@ -177,15 +111,15 @@ static void on_hvx(ble_rscs_c_t * p_ble_rscs_c, const ble_evt_t * p_ble_evt) ble_rscs_c_evt.params.rsc.is_running = p_notif->data[index] >> BLE_RSCS_WALKING_OR_RUNNING_STATUS_BIT & 0x01; index++; - // Instantaneous Speed + // Instantaneous speed ble_rscs_c_evt.params.rsc.inst_speed = uint16_decode(&p_notif->data[index]); index += sizeof(uint16_t); - // Instantaneous Cadence + // Instantaneous cadence ble_rscs_c_evt.params.rsc.inst_cadence = p_notif->data[index]; index++; - // Instantaneous Stride Length + // Instantaneous stride length if (ble_rscs_c_evt.params.rsc.is_inst_stride_len_present == true) { ble_rscs_c_evt.params.rsc.inst_stride_length = uint16_decode(&p_notif->data[index]); @@ -206,15 +140,15 @@ static void on_hvx(ble_rscs_c_t * p_ble_rscs_c, const ble_evt_t * p_ble_evt) } -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of heart rate service at the peer. If so, it will - * call the application's event handler indicating that the Running Speed and Cadence - * service has been discovered at the peer. It also populates the event with the service - * related information before providing it to the application. + * @details This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of Running Speed and Cadence service at the peer. If it does, the function + * calls the application's event handler to indicate that the Running Speed and Cadence + * service was discovered at the peer. The function also populates the event with service-related + * information before providing it to the application. * - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. * */ void ble_rscs_on_db_disc_evt(ble_rscs_c_t * p_ble_rscs_c, const ble_db_discovery_evt_t * p_evt) @@ -244,7 +178,7 @@ void ble_rscs_on_db_disc_evt(ble_rscs_c_t * p_ble_rscs_c, const ble_db_discovery NRF_LOG_DEBUG("Running Speed and Cadence Service discovered at peer."); - //If the instance has been assigned prior to db_discovery, assign the db_handles + // If the instance has been assigned prior to db_discovery, assign the db_handles. if (p_ble_rscs_c->conn_handle != BLE_CONN_HANDLE_INVALID) { if ((p_ble_rscs_c->peer_db.rsc_cccd_handle == BLE_GATT_HANDLE_INVALID)&& @@ -272,16 +206,18 @@ uint32_t ble_rscs_c_init(ble_rscs_c_t * p_ble_rscs_c, ble_rscs_c_init_t * p_ble_ rscs_uuid.uuid = BLE_UUID_RUNNING_SPEED_AND_CADENCE; p_ble_rscs_c->evt_handler = p_ble_rscs_c_init->evt_handler; + p_ble_rscs_c->error_handler = p_ble_rscs_c_init->error_handler; p_ble_rscs_c->conn_handle = BLE_CONN_HANDLE_INVALID; p_ble_rscs_c->peer_db.rsc_cccd_handle = BLE_GATT_HANDLE_INVALID; p_ble_rscs_c->peer_db.rsc_handle = BLE_GATT_HANDLE_INVALID; + p_ble_rscs_c->p_gatt_queue = p_ble_rscs_c_init->p_gatt_queue; return ble_db_discovery_evt_register(&rscs_uuid); } uint32_t ble_rscs_c_handles_assign(ble_rscs_c_t * p_ble_rscs_c, - uint16_t conn_handle, + uint16_t conn_handle, ble_rscs_c_db_t * p_peer_handles) { VERIFY_PARAM_NOT_NULL(p_ble_rscs_c); @@ -291,14 +227,14 @@ uint32_t ble_rscs_c_handles_assign(ble_rscs_c_t * p_ble_rscs_c, p_ble_rscs_c->peer_db = *p_peer_handles; } - return NRF_SUCCESS; + return nrf_ble_gq_conn_handle_register(p_ble_rscs_c->p_gatt_queue, conn_handle); } /**@brief Function for handling Disconnected event received from the SoftDevice. * - * @details This function check if the disconnect event is happening on the link - * associated with the current instance of the module, if so it will set its + * @details This function check whether the disconnect event is happening on the link + * associated with the current instance of the module. If the event is happening, the function sets the instance's * conn_handle to invalid. * * @param[in] p_ble_rscs_c Pointer to the RSC Client structure. @@ -330,10 +266,6 @@ void ble_rscs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_hvx(p_ble_rscs_c, p_ble_evt); break; - case BLE_GATTC_EVT_WRITE_RSP: - on_write_rsp(p_ble_rscs_c, p_ble_evt); - break; - case BLE_GAP_EVT_DISCONNECTED: on_disconnected(p_ble_rscs_c, p_ble_evt); break; @@ -346,29 +278,30 @@ void ble_rscs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) /**@brief Function for creating a message for writing to the CCCD. */ -static uint32_t cccd_configure(uint16_t conn_handle, uint16_t handle_cccd, bool enable) +static uint32_t cccd_configure(ble_rscs_c_t * p_ble_rscs_c, bool enable) { NRF_LOG_DEBUG("Configuring CCCD. CCCD Handle = %d, Connection Handle = %d", - handle_cccd, conn_handle); - - tx_message_t * p_msg; - uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; - - p_msg = &m_tx_buffer[m_tx_insert_index++]; - m_tx_insert_index &= TX_BUFFER_MASK; - - p_msg->req.write_req.gattc_params.handle = handle_cccd; - p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH; - p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value; - p_msg->req.write_req.gattc_params.offset = 0; - p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; - p_msg->req.write_req.gattc_value[0] = LSB_16(cccd_val); - p_msg->req.write_req.gattc_value[1] = MSB_16(cccd_val); - p_msg->conn_handle = conn_handle; - p_msg->type = WRITE_REQ; - - tx_buffer_process(); - return NRF_SUCCESS; + p_ble_rscs_c->peer_db.rsc_cccd_handle, + p_ble_rscs_c->conn_handle); + + uint8_t cccd[WRITE_MESSAGE_LENGTH]; + uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0; + nrf_ble_gq_req_t rscs_c_req; + + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + memset(&rscs_c_req, 0, sizeof(rscs_c_req)); + rscs_c_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + rscs_c_req.error_handler.cb = gatt_error_handler; + rscs_c_req.error_handler.p_ctx = p_ble_rscs_c; + rscs_c_req.params.gattc_write.handle = p_ble_rscs_c->peer_db.rsc_cccd_handle; + rscs_c_req.params.gattc_write.len = WRITE_MESSAGE_LENGTH; + rscs_c_req.params.gattc_write.p_value = cccd; + rscs_c_req.params.gattc_write.offset = 0; + rscs_c_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ble_rscs_c->p_gatt_queue, &rscs_c_req, p_ble_rscs_c->conn_handle); } @@ -381,7 +314,7 @@ uint32_t ble_rscs_c_rsc_notif_enable(ble_rscs_c_t * p_ble_rscs_c) return NRF_ERROR_INVALID_STATE; } - return cccd_configure(p_ble_rscs_c->conn_handle, p_ble_rscs_c->peer_db.rsc_cccd_handle, true); + return cccd_configure(p_ble_rscs_c, true); } /** @} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h similarity index 72% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h index 1157a07..b988eb2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_rscs_c/ble_rscs_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** * @defgroup ble_rscs_c Running Speed and Cadence Service Client @@ -43,10 +43,10 @@ * @ingroup ble_sdk_srv * * @details This module contains the APIs and types exposed by the Running Speed and Cadence - * Service Client module. These APIs and types can be used by the application to perform + * Service Client module. The application can use these APIs and types to perform * discovery of Running Speed and Cadence Service at the peer and interact with it. * - * @note The application must register this module as BLE event observer using the + * @note The application must register this module as BLE event observer by using the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_rscs_c_t instance; @@ -61,6 +61,8 @@ #include #include "ble.h" #include "ble_db_discovery.h" +#include "ble_srv_common.h" +#include "nrf_ble_gq.h" #include "nrf_sdh_ble.h" #ifdef __cplusplus @@ -78,6 +80,18 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_RSCS_C_BLE_OBSERVER_PRIO, \ ble_rscs_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple ble_rscs_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define BLE_RSCS_C_ARRAY_DEF(_name, _cnt) \ +static ble_rscs_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + BLE_RSCS_C_BLE_OBSERVER_PRIO, \ + ble_rscs_c_on_ble_evt, &_name, _cnt) + #define BLE_RSCS_INSTANT_STRIDE_LEN_PRESENT 0x00 /**< Instantaneous Stride Length Measurement Supported bit. */ #define BLE_RSCS_TOTAL_DISTANCE_PRESENT 0x01 /**< Total Distance Measurement Supported bit. */ #define BLE_RSCS_WALKING_OR_RUNNING_STATUS_BIT 0x02 /**< Walking or Running Status Supported bit. */ @@ -116,8 +130,8 @@ typedef struct uint16_t conn_handle; /**< Connection handle on which the rscs_c event occured.*/ union { - ble_rscs_c_db_t rscs_db; /**< Running Speed and Cadence Service related handles found on the peer device. This will be filled if the evt_type is @ref BLE_RSCS_C_EVT_DISCOVERY_COMPLETE.*/ - ble_rsc_t rsc; /**< Running Speed and Cadence measurement received. This will be filled if the evt_type is @ref BLE_RSCS_C_EVT_RSC_NOTIFICATION. */ + ble_rscs_c_db_t rscs_db; /**< Running Speed and Cadence Service related handles found on the peer device. This is filled if the evt_type is @ref BLE_RSCS_C_EVT_DISCOVERY_COMPLETE.*/ + ble_rsc_t rsc; /**< Running Speed and Cadence measurement received. This is filled if the evt_type is @ref BLE_RSCS_C_EVT_RSC_NOTIFICATION. */ } params; } ble_rscs_c_evt_t; @@ -126,7 +140,7 @@ typedef struct ble_rscs_c_s ble_rscs_c_t; /**@brief Event handler type. * - * @details This is the type of the event handler that should be provided by the application + * @details This is the type of the event handler that is to be provided by the application * of this module in order to receive events. */ typedef void (* ble_rscs_c_evt_handler_t) (ble_rscs_c_t * p_ble_rscs_c, ble_rscs_c_evt_t * p_evt); @@ -134,15 +148,19 @@ typedef void (* ble_rscs_c_evt_handler_t) (ble_rscs_c_t * p_ble_rscs_c, ble_rscs /**@brief Running Speed and Cadence client structure. */ struct ble_rscs_c_s { - uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */ - ble_rscs_c_db_t peer_db; /**< Handles related to RSCS on the peer*/ - ble_rscs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the Running Speed and Cadence service. */ + uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */ + ble_rscs_c_db_t peer_db; /**< Handles related to RSCS on the peer*/ + ble_rscs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the Running Speed and Cadence service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ }; /**@brief Running Speed and Cadence client initialization structure. */ typedef struct { - ble_rscs_c_evt_handler_t evt_handler; /**< Event handler to be called by the Running Speed and Cadence Client module whenever there is an event related to the Running Speed and Cadence Service. */ + ble_rscs_c_evt_handler_t evt_handler; /**< Event handler to be called by the Running Speed and Cadence Client module whenever there is an event related to the Running Speed and Cadence Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ } ble_rscs_c_init_t; @@ -152,24 +170,24 @@ typedef struct * the Running Speed and Cadence Service. After calling this function, call @ref ble_db_discovery_start * to start discovery once a link with a peer has been established. * - * @param[out] p_ble_rscs_c Pointer to the RSC Service client structure. + * @param[out] p_ble_rscs_c Pointer to the RSC Service Client structure. * @param[in] p_ble_rscs_c_init Pointer to the RSC Service initialization structure containing * the initialization information. * * @retval NRF_SUCCESS Operation success. * @retval NRF_ERROR_NULL A parameter is NULL. - * Otherwise, an error code returned by @ref ble_db_discovery_evt_register. + * @retval err_code Otherwise, this function propagates the error code returned by @ref ble_db_discovery_evt_register. */ uint32_t ble_rscs_c_init(ble_rscs_c_t * p_ble_rscs_c, ble_rscs_c_init_t * p_ble_rscs_c_init); /**@brief Function for handling the Application's BLE Stack events. * - * @details Handles all events from the BLE stack of interest to the Running Speed and Cadence - * Service client. + * @details Handles all events from the BLE stack that are of interest to the Running Speed and Cadence + * Service Client. * * @param[in] p_ble_evt Event received from the BLE stack. - * @param[in] p_context Running Speed and Cadence Service client structure. + * @param[in] p_context Running Speed and Cadence Service Client structure. */ void ble_rscs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); @@ -177,30 +195,30 @@ void ble_rscs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); uint32_t ble_rscs_c_rsc_notif_enable(ble_rscs_c_t * p_ble_rscs_c); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details Call this function when getting a callback event from the DB discovery modue. - * This function will handle an event from the database discovery module, and determine - * if it relates to the discovery of Running Speed and Cadence service at the peer. - * If so, it will call the application's event handler indicating that the RSC service has - * been discovered at the peer. It also populates the event with the service related + * @details Call this function when you get a callback event from the Database Discovery module. + * This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of Running Speed and Cadence Service at the peer. + * If it does, the function calls the application's event handler to indicate that the RSC Service was + * discovered at the peer. The function also populates the event with service-related * information before providing it to the application. * - * @param p_ble_rscs_c Pointer to the Runnind Speed and Cadence Service client structure. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param p_ble_rscs_c Pointer to the Runnind Speed and Cadence Service Client structure. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void ble_rscs_on_db_disc_evt(ble_rscs_c_t * p_ble_rscs_c, ble_db_discovery_evt_t const * p_evt); -/**@brief Function for assigning handles to a this instance of rscs_c. +/**@brief Function for assigning handles to this instance of rscs_c. * * @details Call this function when a link has been established with a peer to - * associate this link to this instance of the module. This makes it - * possible to handle several link and associate each link to a particular - * instance of this module. The connection handle and attribute handles will be + * associate the link to this instance of the module. This makes it + * possible to handle several links and associate each link to a particular + * instance of this module. The connection handle and attribute handles are * provided from the discovery event @ref BLE_RSCS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in] p_ble_rscs_c Pointer to the RSC client structure instance to associate. + * @param[in] p_ble_rscs_c Pointer to the RSC client structure instance for associating the link. * @param[in] conn_handle Connection handle to associated with the given RSCS Client Instance. * @param[in] p_peer_handles Attribute handles on the RSCS server that you want this RSCS client * to interact with. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_tps/ble_tps.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_tps/ble_tps.c similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_tps/ble_tps.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_tps/ble_tps.c index 64860f0..70b93e6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_tps/ble_tps.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_tps/ble_tps.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile @@ -76,63 +76,11 @@ void ble_tps_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) } -/**@brief Function for adding TX Power Level characteristics. - * - * @param[in] p_tps TX Power Service structure. - * @param[in] p_tps_init Information needed to initialize the service. - * - * @return NRF_SUCCESS on success, otherwise an error code. - */ -static uint32_t tx_power_level_char_add(ble_tps_t * p_tps, - const ble_tps_init_t * p_tps_init) -{ - ble_gatts_char_md_t char_md; - ble_gatts_attr_t attr_char_value; - ble_uuid_t ble_uuid; - ble_gatts_attr_md_t attr_md; - - memset(&char_md, 0, sizeof(char_md)); - - char_md.char_props.read = 1; - char_md.p_char_user_desc = NULL; - char_md.p_char_pf = NULL; - char_md.p_user_desc_md = NULL; - char_md.p_cccd_md = NULL; - char_md.p_sccd_md = NULL; - - BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TX_POWER_LEVEL_CHAR); - - memset(&attr_md, 0, sizeof(attr_md)); - - attr_md.read_perm = p_tps_init->tps_attr_md.read_perm; - attr_md.write_perm = p_tps_init->tps_attr_md.write_perm; - attr_md.vloc = BLE_GATTS_VLOC_STACK; - attr_md.rd_auth = 0; - attr_md.wr_auth = 0; - attr_md.vlen = 0; - - memset(&attr_char_value, 0, sizeof(attr_char_value)); - - memset(&attr_char_value, 0, sizeof (attr_char_value)); - - attr_char_value.p_uuid = &ble_uuid; - attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = sizeof (int8_t); - attr_char_value.init_offs = 0; - attr_char_value.max_len = sizeof (uint8_t); - attr_char_value.p_value = (uint8_t*)&p_tps_init->initial_tx_power_level; - - return sd_ble_gatts_characteristic_add(p_tps->service_handle, - &char_md, - &attr_char_value, - &p_tps->tx_power_level_handles); -} - - uint32_t ble_tps_init(ble_tps_t * p_tps, const ble_tps_init_t * p_tps_init) { - uint32_t err_code; - ble_uuid_t ble_uuid; + uint32_t err_code; + ble_uuid_t ble_uuid; + ble_add_char_params_t add_char_params; // Add service BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TX_POWER_SERVICE); @@ -147,7 +95,17 @@ uint32_t ble_tps_init(ble_tps_t * p_tps, const ble_tps_init_t * p_tps_init) } // Add TX Power Level characteristic - return tx_power_level_char_add(p_tps, p_tps_init); + memset(&add_char_params, 0, sizeof(add_char_params)); + add_char_params.uuid = BLE_UUID_TX_POWER_LEVEL_CHAR; + add_char_params.max_len = sizeof(uint8_t); + add_char_params.init_len = sizeof(uint8_t); + add_char_params.p_init_value = (uint8_t *) &p_tps_init->initial_tx_power_level; + add_char_params.char_props.read = 1; + add_char_params.read_access = p_tps_init->tpl_rd_sec; + + return characteristic_add(p_tps->service_handle, + &add_char_params, + &p_tps->tx_power_level_handles); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_tps/ble_tps.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_tps/ble_tps.h similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_tps/ble_tps.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_tps/ble_tps.h index 350d31e..2cd72d6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/ble_tps/ble_tps.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/ble_tps/ble_tps.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -84,8 +84,8 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, * initialization of the service. */ typedef struct { - int8_t initial_tx_power_level; /**< Initial value of the TX Power Level characteristic (in dBm). */ - ble_srv_security_mode_t tps_attr_md; /**< Initial Security Setting for TX Power Service Characteristics. */ + int8_t initial_tx_power_level; /**< Initial value of the TX Power Level characteristic (in dBm). */ + security_req_t tpl_rd_sec; /**< Security requirement for reading TX Power Level characteristic. */ } ble_tps_init_t; /**@brief TX Power Service structure. This contains various status information for the service. */ @@ -119,7 +119,7 @@ uint32_t ble_tps_init(ble_tps_t * p_hrs, const ble_tps_init_t * p_tps_init); void ble_tps_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); -/**@brief Function for setting the state of the Sensor Contact Detected bit. +/**@brief Function for setting the value of the TX Power Level characteristic. * * @param[in] p_tps TX Power Service structure. * @param[in] tx_power_level New TX Power Level (unit dBm, range -100 to 20). diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es.h index fbee66c..c71c069 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_H__ #define ES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv.c index aa17f9e..ef5c402 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "es_adv.h" #include "app_error.h" @@ -50,6 +50,26 @@ static bool m_remain_connectable = false; static uint8_t m_ecs_uuid_type = 0; //!< UUID type of the Eddystone Configuration Service. static uint16_t m_adv_interval = APP_CFG_NON_CONN_ADV_INTERVAL_MS; //!< Current advertisement interval. +static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; //!< Buffer for storing an encoded advertising set. +static uint8_t m_enc_scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; //!< Buffer for storing an encoded scan data. +static uint8_t *mp_adv_handle; //!< Pointer to the advertising handle. + +/**@brief Struct that contains pointers to the encoded advertising data. */ +static ble_gap_adv_data_t m_adv_data = +{ + .adv_data = + { + .p_data = m_enc_advdata, + .len = BLE_GAP_ADV_SET_DATA_SIZE_MAX + }, + .scan_rsp_data = + { + .p_data = m_enc_scan_response_data, + .len = BLE_GAP_ADV_SET_DATA_SIZE_MAX + + } +}; + /**@brief Function for invoking registered callback. * * @param[in] evt Event to issue to callback. @@ -71,7 +91,10 @@ static void adv_start(ble_gap_adv_params_t * p_adv_params) es_tlm_adv_cnt_inc(); - err_code = sd_ble_gap_adv_start(p_adv_params, BLE_CONN_CFG_TAG_DEFAULT); + err_code = sd_ble_gap_adv_set_configure(mp_adv_handle, &m_adv_data, p_adv_params); + APP_ERROR_CHECK(err_code); + + err_code = sd_ble_gap_adv_start(*mp_adv_handle, BLE_CONN_CFG_TAG_DEFAULT); if (err_code != NRF_ERROR_BUSY && err_code != NRF_SUCCESS) { @@ -89,14 +112,23 @@ static void get_adv_params(ble_gap_adv_params_t * p_adv_params, memset(p_adv_params, 0, sizeof(ble_gap_adv_params_t)); // Non-connectable - p_adv_params->type = - non_connectable ? BLE_GAP_ADV_TYPE_ADV_NONCONN_IND : BLE_GAP_ADV_TYPE_ADV_IND; - p_adv_params->p_peer_addr = NULL; // Undirected advertisement. - p_adv_params->fp = BLE_GAP_ADV_FP_ANY; - p_adv_params->interval = non_connectable ? BLE_GAP_ADV_INTERVAL_MAX : 1000; - p_adv_params->timeout = non_connectable - ? APP_CFG_NON_CONN_ADV_TIMEOUT - : (remain_connectable ? 0 : APP_CFG_CONNECTABLE_ADV_TIMEOUT); + p_adv_params->properties.type = non_connectable + ? BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED + : BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + p_adv_params->p_peer_addr = NULL; // Undirected advertisement. + p_adv_params->filter_policy = BLE_GAP_ADV_FP_ANY; + p_adv_params->primary_phy = BLE_GAP_PHY_1MBPS; + + if (non_connectable) + { + p_adv_params->interval = MSEC_TO_UNITS(m_adv_interval, UNIT_0_625_MS); + p_adv_params->duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED; + } + else + { + p_adv_params->interval = MSEC_TO_UNITS(APP_CFG_CONNECTABLE_ADV_INTERVAL_MS, UNIT_0_625_MS); + p_adv_params->duration = APP_CFG_CONNECTABLE_ADV_TIMEOUT; + } } @@ -113,8 +145,11 @@ static void connectable_adv_start(void) scrsp_data.uuids_complete.uuid_cnt = sizeof(scrp_uuids) / sizeof(scrp_uuids[0]); scrsp_data.uuids_complete.p_uuids = scrp_uuids; + m_adv_data.scan_rsp_data.p_data = m_enc_scan_response_data; + m_adv_data.scan_rsp_data.len = BLE_GAP_ADV_SET_DATA_SIZE_MAX; + // As the data to be written does not depend on the slot_no, we can safely send - es_adv_frame_fill_connectable_adv_data(&scrsp_data); + es_adv_frame_fill_connectable_adv_data(&scrsp_data, &m_adv_data); get_adv_params(&connectable_adv_params, false, m_remain_connectable); adv_start(&connectable_adv_params); @@ -127,7 +162,7 @@ static void adv_stop(void) { ret_code_t err_code; - err_code = sd_ble_gap_adv_stop(); + err_code = sd_ble_gap_adv_stop(*mp_adv_handle); if (err_code != NRF_ERROR_INVALID_STATE) { APP_ERROR_CHECK(err_code); @@ -162,8 +197,8 @@ static void adv_timing_callback(const es_adv_timing_evt_t * p_evt) const es_slot_reg_t * p_reg = es_slot_get_registry(); // As new advertisement data will be loaded, stop advertising. - err_code = sd_ble_gap_adv_stop(); - if (err_code != NRF_ERROR_INVALID_STATE) + err_code = sd_ble_gap_adv_stop(*mp_adv_handle); + if (err_code != NRF_ERROR_INVALID_STATE && err_code != BLE_ERROR_INVALID_ADV_HANDLE) { APP_ERROR_CHECK(err_code); } @@ -171,19 +206,21 @@ static void adv_timing_callback(const es_adv_timing_evt_t * p_evt) // If a non-eTLM frame is to be advertised. if (p_evt->evt_id == ES_ADV_TIMING_EVT_ADV_SLOT) { - err_code = sd_ble_gap_tx_power_set(p_reg->slots[p_evt->slot_no].radio_tx_pwr); - APP_ERROR_CHECK(err_code); - - es_adv_frame_fill_non_connectable_adv_data(p_evt->slot_no, false); - } + err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, 0, p_reg->slots[p_evt->slot_no].radio_tx_pwr); + if (err_code != BLE_ERROR_INVALID_ADV_HANDLE) + { + APP_ERROR_CHECK(err_code); + } + es_adv_frame_fill_non_connectable_adv_data(p_evt->slot_no, false, &m_adv_data); + } // If an eTLM frame is to be advertised else if (p_evt->evt_id == ES_ADV_TIMING_EVT_ADV_ETLM) { - err_code = sd_ble_gap_tx_power_set(p_reg->slots[p_reg->tlm_slot].radio_tx_pwr); + err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, 0, p_reg->slots[p_reg->tlm_slot].radio_tx_pwr); APP_ERROR_CHECK(err_code); - es_adv_frame_fill_non_connectable_adv_data(p_evt->slot_no, true); + es_adv_frame_fill_non_connectable_adv_data(p_evt->slot_no, true, &m_adv_data); } invoke_callback(ES_ADV_EVT_NON_CONN_ADV); @@ -242,8 +279,8 @@ void es_adv_on_ble_evt(ble_evt_t const * p_ble_evt) adv_restart(); break; - case BLE_GAP_EVT_TIMEOUT: - if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING && + case BLE_GAP_EVT_ADV_SET_TERMINATED: + if (p_ble_evt->evt.gap_evt.params.adv_set_terminated.reason == BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT && !m_is_connected) { invoke_callback(ES_ADV_EVT_CONNECTABLE_ADV_STOPPED); @@ -291,13 +328,15 @@ nrf_ble_escs_adv_interval_t es_adv_interval_get(void) void es_adv_init(uint8_t ecs_uuid_type, es_adv_evt_handler_t adv_event_handler, nrf_ble_escs_adv_interval_t adv_interval, - bool remain_connectable) + bool remain_connectable, + uint8_t * const p_adv_handle) { m_ecs_uuid_type = ecs_uuid_type; m_adv_evt_handler = adv_event_handler; m_is_connected = false; m_remain_connectable = remain_connectable; m_adv_interval = adv_interval; + mp_adv_handle = p_adv_handle; es_tlm_init(); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv.h index 0a659d3..2b80e28 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_ADV_H__ #define ES_ADV_H__ @@ -67,11 +67,13 @@ typedef void (*es_adv_evt_handler_t)(es_adv_evt_t evt); * @param[in] adv_event_handler Eddystone advertiser event handler. * @param[in] adv_interval Advertisement interval to use. * @param[in] remain_connectable Flag that specifies if advertisements should remain connectable. + * @param[in] p_adv_handle Pointer to the advertising handle used to start and stop advertising. */ void es_adv_init(uint8_t ecs_uuid_type, es_adv_evt_handler_t adv_event_handler, nrf_ble_escs_adv_interval_t adv_interval, - bool remain_connectable); + bool remain_connectable, + uint8_t * const p_adv_handle); /** @brief Function for passing BLE events to this module. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_frame.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_frame.c similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_frame.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_frame.c index aef3855..146fdb5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_frame.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_frame.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,18 +35,18 @@ * 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 "es_adv_frame.h" #include "es_slot.h" -/**@brief Function for setting advertisement data, using 'ble_advdata_set'. +/**@brief Function for setting advertisement data, using 'ble_advdata_encode'. * * @param[in] p_scrsp_data Scan response data. * @param[in] p_es_data_array Eddystone service data array. */ -static void fill_adv_data(ble_advdata_t * p_scrsp_data, uint8_array_t * p_es_data_array) +static void fill_adv_data(ble_advdata_t * p_scrsp_data, uint8_array_t * p_es_data_array, ble_gap_adv_data_t * const p_adv_data) { ble_advdata_t adv_data; ret_code_t err_code; @@ -69,18 +69,32 @@ static void fill_adv_data(ble_advdata_t * p_scrsp_data, uint8_array_t * p_es_dat adv_data.p_service_data_array = &service_data; adv_data.service_data_count = (p_es_data_array != NULL) ? 1 : 0; - err_code = ble_advdata_set(&adv_data, p_scrsp_data); + err_code = ble_advdata_encode(&adv_data, + p_adv_data->adv_data.p_data, + &p_adv_data->adv_data.len); APP_ERROR_CHECK(err_code); + if (p_scrsp_data != NULL) + { + err_code = ble_advdata_encode(p_scrsp_data, + p_adv_data->scan_rsp_data.p_data, + &p_adv_data->scan_rsp_data.len); + APP_ERROR_CHECK(err_code); + } + else + { + p_adv_data->scan_rsp_data.p_data = NULL; + p_adv_data->scan_rsp_data.len = 0; + } } -void es_adv_frame_fill_connectable_adv_data(ble_advdata_t * p_scrsp_data) +void es_adv_frame_fill_connectable_adv_data(ble_advdata_t * p_scrsp_data, ble_gap_adv_data_t * const p_adv_data) { - fill_adv_data(p_scrsp_data, NULL); + fill_adv_data(p_scrsp_data, NULL, p_adv_data); } -void es_adv_frame_fill_non_connectable_adv_data(uint8_t slot_no, bool etlm) +void es_adv_frame_fill_non_connectable_adv_data(uint8_t slot_no, bool etlm, ble_gap_adv_data_t * const p_adv_data) { uint8_array_t es_data_array = {0}; const es_slot_reg_t * p_reg = es_slot_get_registry(); @@ -102,5 +116,5 @@ void es_adv_frame_fill_non_connectable_adv_data(uint8_t slot_no, bool etlm) es_data_array.p_data = (uint8_t *)&p_reg->slots[slot_no].adv_frame.frame; es_data_array.size = p_reg->slots[slot_no].adv_frame.length; - fill_adv_data(NULL, &es_data_array); + fill_adv_data(NULL, &es_data_array, p_adv_data); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_frame.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_frame.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_frame.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_frame.h index 10eacb0..b408988 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_frame.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_frame.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_ADV_FRAME_H__ #define ES_ADV_FRAME_H__ @@ -50,19 +50,21 @@ */ /**@brief Function for setting up connectable advertisement data using @ref - * ble_advdata_set. + * ble_advdata_encode. * - * @param[in] p_scrsp_data Pointer to the scan response data. + * @param[in] p_scrsp_data Pointer to the scan response data that will be encoded. + * @param[in,out] p_adv_data Pointer to the encoded advertising data (including scan response). */ -void es_adv_frame_fill_connectable_adv_data(ble_advdata_t * p_scrsp_data); +void es_adv_frame_fill_connectable_adv_data(ble_advdata_t * p_scrsp_data, ble_gap_adv_data_t * const p_adv_data); /**@brief Function for setting up non-connectable advertisement data using @ref - * ble_advdata_set. + * ble_advdata_encode. * - * @param[in] slot_no Slot to fill in data for. - * @param[in] etlm Flag that specifies if Eddystone-TLM is required. + * @param[in] slot_no Slot to fill in data for. + * @param[in] etlm Flag that specifies if Eddystone-TLM is required. + * @param[in,out] p_adv_data Pointer to the encoded advertising data (including scan response). */ -void es_adv_frame_fill_non_connectable_adv_data(uint8_t slot_no, bool etlm); +void es_adv_frame_fill_non_connectable_adv_data(uint8_t slot_no, bool etlm, ble_gap_adv_data_t * const p_adv_data); /** * @} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing.c index c41aa88..7a9cf79 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "app_timer.h" #include "es_adv_timing.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing.h index f2747a4..583a7e1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_ADV_TIMING_H__ #define ES_ADV_TIMING_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing_resolver.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing_resolver.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing_resolver.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing_resolver.c index 7eca24e..cd47070 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing_resolver.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing_resolver.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "es_adv_timing_resolver.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing_resolver.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing_resolver.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing_resolver.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing_resolver.h index caf654d..30bb87c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_adv_timing_resolver.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_adv_timing_resolver.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_ADV_TIMING_RESOLVER_H__ #define ES_ADV_TIMING_RESOLVER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_battery_voltage.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_battery_voltage.h index f958243..7dbd910 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_battery_voltage.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_BATTERY_VOLTAGE_H__ #define ES_BATTERY_VOLTAGE_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_saadc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_battery_voltage_saadc.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_saadc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_battery_voltage_saadc.c index 70afa7a..3736c75 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_battery_voltage_saadc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_battery_voltage_saadc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "es_battery_voltage.h" #include "nrf_drv_saadc.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_flash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_flash.c similarity index 89% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_flash.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_flash.c index 07e240e..570f5ab 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_flash.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_flash.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include "es_flash.h" @@ -70,7 +70,7 @@ typedef struct } flash_access_params_t; static volatile uint32_t m_num_pending_ops; //!< Current number of outstanding FDS operations. -static volatile bool m_factory_reset; //!< Should factory reset be performed. +static volatile bool m_factory_reset_done; //!< Has a factory reset operation been completed. static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; //!< Current connection handle. @@ -97,7 +97,7 @@ static void fds_gc_event(void * p_event_data, uint16_t event_size) ret_code_t fds_err_code; fds_err_code = fds_gc(); - if (fds_err_code != FDS_SUCCESS) + if (fds_err_code != NRF_SUCCESS) APP_ERROR_CHECK_BOOL(NRF_ERROR_INTERNAL); m_num_pending_ops++; } @@ -116,8 +116,12 @@ static void fds_cb(fds_evt_t const * const p_evt) case FDS_EVT_INIT: m_num_pending_ops = 0; break; - case FDS_EVT_DEL_FILE: + if (p_evt->del.file_id == FILE_ID_ES_FLASH) + { + m_factory_reset_done = true; + } + // Fall through case FDS_EVT_DEL_RECORD: // Schedule garbage collection err_code = app_sched_event_put(NULL, 0, fds_gc_event); @@ -125,15 +129,27 @@ static void fds_cb(fds_evt_t const * const p_evt) break; case FDS_EVT_GC: - if (m_factory_reset && m_conn_handle != BLE_CONN_HANDLE_INVALID) + // During factory reset, a file is deleted, and garbage collection is scheduled + // when the callback for that deletion is invoked. + // So here we know that the factory reset is completed. + if (m_factory_reset_done) { - err_code = - sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); - APP_ERROR_CHECK(err_code); + if (m_conn_handle != BLE_CONN_HANDLE_INVALID) + { + err_code = + sd_ble_gap_disconnect(m_conn_handle, + BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + APP_ERROR_CHECK(err_code); + } + else + { + m_factory_reset_done = false; + (void)sd_nvic_SystemReset(); + } } - - // Fall through: + // Fall through: case FDS_EVT_UPDATE: + // Fall through: case FDS_EVT_WRITE: if (m_num_pending_ops > 0) { @@ -288,8 +304,6 @@ ret_code_t es_flash_factory_reset(void) // Delete everything except the lock key: ret_code_t ret_code = fds_file_delete(FILE_ID_ES_FLASH); - if (ret_code == FDS_SUCCESS) - m_factory_reset = true; return ret_code; } @@ -310,8 +324,9 @@ void es_flash_on_ble_evt(ble_evt_t const * p_evt) case BLE_GAP_EVT_DISCONNECTED: m_conn_handle = BLE_CONN_HANDLE_INVALID; - if (m_factory_reset) + if (m_factory_reset_done) { + m_factory_reset_done = false; (void)sd_nvic_SystemReset(); } break; @@ -327,7 +342,7 @@ ret_code_t es_flash_init(void) m_conn_handle = BLE_CONN_HANDLE_INVALID; - m_factory_reset = false; + m_factory_reset_done = false; err_code = fds_register(fds_cb); RETURN_IF_ERROR(err_code); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_flash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_flash.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_flash.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_flash.h index 8efcbe9..599a65d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_flash.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_flash.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_FLASH_H__ #define ES_FLASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts.c index 991c798..7c67b89 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "es_gatts.h" @@ -43,7 +43,6 @@ #include "es_gatts_write.h" #include "es_slot.h" -static nrf_ble_escs_lock_state_read_t m_lock_state; static uint8_t m_active_slot; /**@brief Function checking if beacon is unlocked. @@ -55,7 +54,7 @@ static uint8_t m_active_slot; */ static bool is_beacon_unlocked(const nrf_ble_escs_t * p_escs) { - return m_lock_state != NRF_BLE_ESCS_LOCK_STATE_LOCKED; + return p_escs->lock_state != NRF_BLE_ESCS_LOCK_STATE_LOCKED; } @@ -152,7 +151,7 @@ void es_gatts_handle_read(nrf_ble_escs_t * p_escs, uint16_t uuid, uint16_t val_h else { - err_code = es_gatts_read_handle_unlocked_read(p_escs, uuid, val_handle, m_active_slot, m_lock_state); + err_code = es_gatts_read_handle_unlocked_read(p_escs, uuid, val_handle, m_active_slot); APP_ERROR_CHECK(err_code); } } @@ -167,7 +166,7 @@ void es_gatts_handle_read(nrf_ble_escs_t * p_escs, uint16_t uuid, uint16_t val_h else { - err_code = es_gatts_read_handle_locked_read(p_escs, uuid, m_lock_state); + err_code = es_gatts_read_handle_locked_read(p_escs, uuid); APP_ERROR_CHECK(err_code); } } @@ -179,10 +178,9 @@ ret_code_t es_gatts_init(nrf_ble_escs_t * p_ble_escs) VERIFY_PARAM_NOT_NULL(p_ble_escs); m_active_slot = 0; - m_lock_state = NRF_BLE_ESCS_LOCK_STATE_LOCKED; - + p_ble_escs->p_active_slot = &m_active_slot; - p_ble_escs->p_lock_state = &m_lock_state; + p_ble_escs->lock_state = NRF_BLE_ESCS_LOCK_STATE_LOCKED; return NRF_SUCCESS; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts.h index bacdb1d..e4af15d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_GATTS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_read.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_read.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_read.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_read.c index 80b2977..47d2551 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_read.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_read.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "es_gatts_read.h" @@ -139,7 +139,7 @@ static ret_code_t read_adv_slot(nrf_ble_escs_t * p_escs, uint8_t active_slot, co } -ret_code_t es_gatts_read_handle_locked_read(nrf_ble_escs_t * p_escs, uint16_t uuid, uint8_t lock_state) +ret_code_t es_gatts_read_handle_locked_read(nrf_ble_escs_t * p_escs, uint16_t uuid) { VERIFY_PARAM_NOT_NULL(p_escs); @@ -151,7 +151,7 @@ ret_code_t es_gatts_read_handle_locked_read(nrf_ble_escs_t * p_escs, uint16_t uu else if (uuid == BLE_UUID_ESCS_LOCK_STATE_CHAR) { - return read_value(p_escs, sizeof(lock_state), &lock_state); + return read_value(p_escs, ESCS_LOCK_STATE_READ_LENGTH, &p_escs->lock_state); } else @@ -180,8 +180,7 @@ ret_code_t es_gatts_read_handle_unlock(nrf_ble_escs_t * p_escs) ret_code_t es_gatts_read_handle_unlocked_read(nrf_ble_escs_t * p_escs, uint16_t uuid, uint16_t val_handle, - uint8_t active_slot, - uint8_t lock_state) + uint8_t active_slot) { VERIFY_PARAM_NOT_NULL(p_escs); @@ -196,7 +195,7 @@ ret_code_t es_gatts_read_handle_unlocked_read(nrf_ble_escs_t * p_escs, return read_from_gattdb(p_escs, val_handle); case BLE_UUID_ESCS_LOCK_STATE_CHAR: - return read_value(p_escs, sizeof(lock_state), &lock_state); + return read_value(p_escs, ESCS_LOCK_STATE_READ_LENGTH, &p_escs->lock_state); case BLE_UUID_ESCS_ADV_INTERVAL_CHAR: { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_read.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_read.h similarity index 89% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_read.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_read.h index bacd519..8ad4166 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_read.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_read.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_GATTS_READ_H__ @@ -57,14 +57,12 @@ ret_code_t es_gatts_read_send_not_permitted(nrf_ble_escs_t * p_escs); ret_code_t es_gatts_read_handle_unlocked_read(nrf_ble_escs_t * p_escs, uint16_t uuid, uint16_t val_handle, - uint8_t active_slot, - uint8_t lock_state); + uint8_t active_slot); ret_code_t es_gatts_read_handle_unlock(nrf_ble_escs_t * p_escs); ret_code_t es_gatts_read_handle_locked_read(nrf_ble_escs_t * p_escs, - uint16_t uuid, - uint8_t lock_state); + uint16_t uuid); /** * @} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_write.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_write.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_write.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_write.c index d3976ca..d591db1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_write.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_write.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "es_gatts_write.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_write.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_write.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_write.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_write.h index 284d992..174c628 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_gatts_write.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_gatts_write.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_GATTS_WRITE_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.c new file mode 100644 index 0000000..fa8d975 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.c @@ -0,0 +1,606 @@ +/** + * Copyright (c) 2016 - 2019, 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 +#include +#include "es_security.h" +#include "app_timer.h" +#include "es_flash.h" +#include "es_stopwatch.h" +#include "fds.h" +#include "modes.h" +#include "nrf_crypto.h" +#include "nrf_soc.h" + +#define NONCE_SIZE (6) +#define TAG_SIZE (2) +#define SALT_SIZE (2) +#define TLM_DATA_SIZE (ES_TLM_LENGTH - 2) +#define EIK_SIZE (ESCS_AES_KEY_SIZE) +#define AES_ECB_CIPHERTEXT_LENGTH (16) +#define AES_ECB_CLEARTEXT_LENGTH (16) + +/**@brief Timing structure. */ +typedef struct +{ + uint32_t time_counter; + uint8_t k_scaler; +} es_security_timing_t; + +/**@brief Security slot structure. */ +typedef struct +{ + nrf_ecb_hal_data_t aes_ecb_ik; + nrf_ecb_hal_data_t aes_ecb_tk; + uint8_t eid[ES_EID_ID_LENGTH]; + es_security_timing_t timing; + bool is_occupied; +} es_security_slot_t; + +/**@brief Key pair structure. */ +typedef struct +{ + nrf_crypto_ecc_private_key_t private; + nrf_crypto_ecc_public_key_t public; +} ecdh_key_pair_t; + +/**@brief ECDH structure. */ +typedef struct +{ + ecdh_key_pair_t ecdh_key_pair; +} es_security_ecdh_t; + +static nrf_ecb_hal_data_t m_aes_ecb_lk; +static es_security_slot_t m_security_slot[APP_MAX_EID_SLOTS]; +static es_security_ecdh_t m_ecdh; +static es_security_msg_cb_t m_security_callback; +static es_stopwatch_id_t m_seconds_passed_sw_id; + +// Use static context variables to avoid stack allocation. +static nrf_crypto_aes_context_t m_aes_context; +static nrf_crypto_hmac_context_t m_hmac_context; +static nrf_crypto_aead_context_t m_aead_context; +static nrf_crypto_ecc_key_pair_generate_context_t ecc_key_pair_generate_context; +static nrf_crypto_ecdh_context_t ecdh_context; + +/**@brief Generates a temporary key with the Identity key. */ +static void temp_key_generate(uint8_t slot_no); + +/**@brief Generates a EID with the Temporary Key*/ +static void eid_generate(uint8_t slot_no) +{ + ret_code_t err_code; + size_t ciphertext_size = AES_ECB_CIPHERTEXT_LENGTH; + + temp_key_generate(slot_no); + + memset(m_security_slot[slot_no].aes_ecb_tk.cleartext, 0, ESCS_AES_KEY_SIZE); + m_security_slot[slot_no].aes_ecb_tk.cleartext[11] = m_security_slot[slot_no].timing.k_scaler; + + uint32_t k_bits_cleared_time = + (m_security_slot[slot_no].timing.time_counter >> m_security_slot[slot_no].timing.k_scaler) + << m_security_slot[slot_no].timing.k_scaler; + + m_security_slot[slot_no].aes_ecb_tk.cleartext[12] = + (uint8_t)((k_bits_cleared_time >> 24) & 0xff); + m_security_slot[slot_no].aes_ecb_tk.cleartext[13] = + (uint8_t)((k_bits_cleared_time >> 16) & 0xff); + m_security_slot[slot_no].aes_ecb_tk.cleartext[14] = (uint8_t)((k_bits_cleared_time >> 8) & 0xff); + m_security_slot[slot_no].aes_ecb_tk.cleartext[15] = (uint8_t)((k_bits_cleared_time) & 0xff); + + err_code = nrf_crypto_aes_crypt(&m_aes_context, + &g_nrf_crypto_aes_ecb_128_info, + NRF_CRYPTO_ENCRYPT, // Operation + m_security_slot[slot_no].aes_ecb_tk.key, // Key + NULL, // IV + m_security_slot[slot_no].aes_ecb_tk.cleartext, // Data in + AES_ECB_CLEARTEXT_LENGTH, // Data in size + m_security_slot[slot_no].aes_ecb_tk.ciphertext, // Data out + &ciphertext_size); // Data out size + + APP_ERROR_CHECK(err_code); + + memcpy(m_security_slot[slot_no].eid, + m_security_slot[slot_no].aes_ecb_tk.ciphertext, + ES_EID_ID_LENGTH); + + m_security_callback(slot_no, ES_SECURITY_MSG_EID); +} + + +/**@brief Generates a temporary key with the Identity key. */ +static void temp_key_generate(uint8_t slot_no) +{ + ret_code_t err_code; + size_t ciphertext_size = AES_ECB_CIPHERTEXT_LENGTH; + + memset(m_security_slot[slot_no].aes_ecb_ik.cleartext, 0, ESCS_AES_KEY_SIZE); + m_security_slot[slot_no].aes_ecb_ik.cleartext[11] = 0xFF; + m_security_slot[slot_no].aes_ecb_ik.cleartext[14] = + (uint8_t)((m_security_slot[slot_no].timing.time_counter >> 24) & 0xff); + m_security_slot[slot_no].aes_ecb_ik.cleartext[15] = + (uint8_t)((m_security_slot[slot_no].timing.time_counter >> 16) & 0xff); + + err_code = nrf_crypto_aes_crypt(&m_aes_context, + &g_nrf_crypto_aes_ecb_128_info, + NRF_CRYPTO_ENCRYPT, // Operation + m_security_slot[slot_no].aes_ecb_ik.key, // Key + NULL, // IV + m_security_slot[slot_no].aes_ecb_ik.cleartext, // Data in + AES_ECB_CLEARTEXT_LENGTH, // Data in size + m_security_slot[slot_no].aes_ecb_ik.ciphertext, // Data out + &ciphertext_size); // Data out size + + APP_ERROR_CHECK(err_code); + + memcpy(m_security_slot[slot_no].aes_ecb_tk.key, + m_security_slot[slot_no].aes_ecb_ik.ciphertext, + ESCS_AES_KEY_SIZE); +} + + +/**@brief See if EID should be re-calculated. + */ +static void check_rollovers_and_update_eid(uint8_t slot_no) +{ + static uint32_t last_invocation_time_counter = 0; + uint32_t scaler = 2 << (m_security_slot[slot_no].timing.k_scaler - 1); + uint32_t diff; + + if (last_invocation_time_counter == 0) + { + last_invocation_time_counter = m_security_slot[slot_no].timing.time_counter; + } + + diff = m_security_slot[slot_no].timing.time_counter - last_invocation_time_counter; + + if (diff >= scaler) + { + // Store to last scaler-aligned time. + last_invocation_time_counter = (m_security_slot[slot_no].timing.time_counter / scaler) * scaler; + + eid_generate(slot_no); + } +} + + +/**@brief Initialize lock code from flash. If it does not exist, copy from APP_CONFIG_LOCK_CODE. + */ +static void lock_code_init(uint8_t * p_lock_buff) +{ + ret_code_t err_code; + + err_code = es_flash_access_lock_key(p_lock_buff, ES_FLASH_ACCESS_READ); + FLASH_ACCES_ERROR_CHECK_ALLOW_NOT_FOUND(err_code); + + // If no lock keys exist, then generate one and copy it to buffer. + if (err_code == FDS_ERR_NOT_FOUND) + { + uint8_t lock_code[16] = APP_CONFIG_LOCK_CODE; + + memcpy(p_lock_buff, lock_code, sizeof(lock_code)); + + err_code = es_flash_access_lock_key(p_lock_buff, ES_FLASH_ACCESS_WRITE); + APP_ERROR_CHECK(err_code); + } +} + + +void es_security_update_time(void) +{ + static uint32_t timer_persist; + uint32_t second_since_last_invocation = es_stopwatch_check(m_seconds_passed_sw_id); + + if (second_since_last_invocation > 0) + { + for (uint32_t i = 0; i < APP_MAX_EID_SLOTS; ++i) + { + if (m_security_slot[i].is_occupied) + { + m_security_slot[i].timing.time_counter += second_since_last_invocation; + check_rollovers_and_update_eid(i); + } + } + + // Every 24 hr, write the new EID timer to flash. + timer_persist += second_since_last_invocation; + const uint32_t TWENTY_FOUR_HOURS = 60 * 60 * 24; + if (timer_persist >= TWENTY_FOUR_HOURS) + { + for (uint32_t i = 0; i < APP_MAX_EID_SLOTS; ++i) + { + if (m_security_slot[i].is_occupied) + { + m_security_callback(i, ES_SECURITY_MSG_STORE_TIME); + } + } + timer_persist = 0; + } + } +} + + +void es_security_eid_slots_restore(uint8_t slot_no, + uint8_t k_scaler, + uint32_t time_counter, + const uint8_t * p_ik) +{ + m_security_slot[slot_no].timing.k_scaler = k_scaler; + m_security_slot[slot_no].timing.time_counter = time_counter; + memcpy(m_security_slot[slot_no].aes_ecb_ik.key, p_ik, ESCS_AES_KEY_SIZE); + m_security_slot[slot_no].is_occupied = true; + m_security_callback(slot_no, ES_SECURITY_MSG_IK); + eid_generate(slot_no); +} + + +ret_code_t es_security_lock_code_update(uint8_t * p_ecrypted_key) +{ + ret_code_t err_code; + uint8_t temp_buff[ESCS_AES_KEY_SIZE] = {0}; + size_t temp_buff_size = sizeof(temp_buff); + + err_code = nrf_crypto_aes_crypt(&m_aes_context, + &g_nrf_crypto_aes_ecb_128_info, + NRF_CRYPTO_DECRYPT, // Operation + m_aes_ecb_lk.key, // Key + NULL, // IV + p_ecrypted_key, // Data in + 16, // Data in size + temp_buff, // Data out + &temp_buff_size); // Data out size + + VERIFY_SUCCESS(err_code); + + memcpy(m_aes_ecb_lk.key, temp_buff, ESCS_AES_KEY_SIZE); + return es_flash_access_lock_key(m_aes_ecb_lk.key, ES_FLASH_ACCESS_WRITE); +} + + +void es_security_unlock_prepare(uint8_t * p_challenge) +{ + ret_code_t err_code; + size_t ciphertext_size = AES_ECB_CIPHERTEXT_LENGTH; + + memcpy(m_aes_ecb_lk.cleartext, p_challenge, ESCS_AES_KEY_SIZE); + + err_code = nrf_crypto_aes_crypt(&m_aes_context, + &g_nrf_crypto_aes_ecb_128_info, + NRF_CRYPTO_ENCRYPT, // Operation + m_aes_ecb_lk.key, // Key + NULL, // IV + m_aes_ecb_lk.cleartext, // Data in + AES_ECB_CLEARTEXT_LENGTH, // Data in size + m_aes_ecb_lk.ciphertext, // Data out + &ciphertext_size); // Data out size + + APP_ERROR_CHECK(err_code); +} + + +void es_security_unlock_verify(uint8_t * p_unlock_token) +{ + if (memcmp(p_unlock_token, m_aes_ecb_lk.ciphertext, ESCS_AES_KEY_SIZE) == 0) + { + m_security_callback(0, ES_SECURITY_MSG_UNLOCKED); + } +} + + +ret_code_t es_security_random_challenge_generate(uint8_t * p_rand_chlg_buff) +{ + return nrf_crypto_rng_vector_generate(p_rand_chlg_buff, ESCS_AES_KEY_SIZE); +} + + +void es_security_shared_ik_receive(uint8_t slot_no, uint8_t * p_encrypted_ik, uint8_t scaler_k) +{ + ret_code_t err_code; + size_t cleartext_size = AES_ECB_CLEARTEXT_LENGTH; + + m_security_slot[slot_no].is_occupied = true; + m_security_slot[slot_no].timing.k_scaler = scaler_k; + m_security_slot[slot_no].timing.time_counter = APP_CONFIG_TIMING_INIT_VALUE; + + err_code = nrf_crypto_aes_crypt(&m_aes_context, + &g_nrf_crypto_aes_ecb_128_info, + NRF_CRYPTO_DECRYPT, // Operation + m_aes_ecb_lk.key, // Key + NULL, // IV + p_encrypted_ik, // Data in + 16, // Data in size + m_security_slot[slot_no].aes_ecb_ik.key, // Data out + &cleartext_size); // Data out size + + APP_ERROR_CHECK(err_code); + + eid_generate(slot_no); + + m_security_callback(slot_no, ES_SECURITY_MSG_IK); +} + + +void es_security_client_pub_ecdh_receive(uint8_t slot_no, uint8_t * p_pub_ecdh, uint8_t scaler_k) +{ + ret_code_t err_code; + nrf_crypto_ecc_public_key_t phone_public; // Phone public ECDH key + uint8_t beacon_public[ESCS_ECDH_KEY_SIZE]; // Beacon public ECDH key + uint8_t shared[ESCS_ECDH_KEY_SIZE]; // Shared secret ECDH key + uint8_t public_keys[64]; // Buffer for concatenated public keys + uint8_t key_material[64]; // Buffer for holding key material + uint8_t empty_check[ESCS_ECDH_KEY_SIZE] = {0}; + size_t beacon_public_size = sizeof(beacon_public); + size_t shared_size = sizeof(shared); + size_t key_material_size = sizeof(key_material); + + m_security_slot[slot_no].is_occupied = true; + m_security_slot[slot_no].timing.k_scaler = scaler_k; + m_security_slot[slot_no].timing.time_counter = APP_CONFIG_TIMING_INIT_VALUE; + + // Get public 32-byte service ECDH key from phone. + err_code = nrf_crypto_ecc_public_key_from_raw(&g_nrf_crypto_ecc_curve25519_curve_info, + &phone_public, + p_pub_ecdh, + ESCS_ECDH_KEY_SIZE); + + APP_ERROR_CHECK(err_code); + + // Generate key pair. + err_code = nrf_crypto_ecc_key_pair_generate(&ecc_key_pair_generate_context, + &g_nrf_crypto_ecc_curve25519_curve_info, + &m_ecdh.ecdh_key_pair.private, + &m_ecdh.ecdh_key_pair.public); + + APP_ERROR_CHECK(err_code); + + // Generate shared 32-byte ECDH secret from beacon private service ECDH key and phone public ECDH key. + err_code = nrf_crypto_ecdh_compute(&ecdh_context, + &m_ecdh.ecdh_key_pair.private, + &phone_public, + shared, + &shared_size); + + APP_ERROR_CHECK(err_code); + + // Verify that the shared secret is not zero at this point, and report an error/reset if it is. + if (memcmp(empty_check, shared, ESCS_ECDH_KEY_SIZE) == 0) + { + APP_ERROR_CHECK(NRF_ERROR_INTERNAL); + } + + // Concatenate the resolver's public key and beacon's public key + err_code = nrf_crypto_ecc_public_key_to_raw(&m_ecdh.ecdh_key_pair.public, + beacon_public, + &beacon_public_size); + + APP_ERROR_CHECK(err_code); + + memcpy(public_keys, p_pub_ecdh, 32); + memcpy(public_keys + 32, beacon_public, 32); + + // Convert the shared secret to key material using HKDF-SHA256. HKDF is used with the salt set + // to a concatenation of the resolver's public key and beacon's public key + err_code = nrf_crypto_hkdf_calculate(&m_hmac_context, + &g_nrf_crypto_hmac_sha256_info, + key_material, // Output key + &key_material_size, // Output key size + shared, // Input key + sizeof(shared), // Input key size + public_keys, // Salt + sizeof(public_keys), // Salt size + NULL, // Additional info + 0, // Additional info size + NRF_CRYPTO_HKDF_EXTRACT_AND_EXPAND); // Mode + + APP_ERROR_CHECK(err_code); + + // Truncate the key material to 128 bits to convert it to an AES-128 secret key (Identity key). + memcpy(m_security_slot[slot_no].aes_ecb_ik.key, key_material, ESCS_AES_KEY_SIZE); + + eid_generate(slot_no); + + m_security_callback(slot_no, ES_SECURITY_MSG_ECDH); + m_security_callback(slot_no, ES_SECURITY_MSG_IK); +} + + +void es_security_pub_ecdh_get(uint8_t slot_no, uint8_t * p_edch_buffer) +{ + ret_code_t err_code; + size_t buffer_size = ESCS_ECDH_KEY_SIZE; + + err_code = nrf_crypto_ecc_public_key_to_raw(&m_ecdh.ecdh_key_pair.public, + p_edch_buffer, + &buffer_size); + + APP_ERROR_CHECK(err_code); +} + + +uint32_t es_security_clock_get(uint8_t slot_no) +{ + return m_security_slot[slot_no].timing.time_counter; +} + + +void es_security_eid_slot_destroy(uint8_t slot_no) +{ + memset(&m_security_slot[slot_no], 0, sizeof(es_security_slot_t)); +} + + +uint8_t es_security_scaler_get(uint8_t slot_no) +{ + return m_security_slot[slot_no].timing.k_scaler; +} + + +void es_security_eid_get(uint8_t slot_no, uint8_t * p_eid_buffer) +{ + memcpy(p_eid_buffer, m_security_slot[slot_no].eid, ES_EID_ID_LENGTH); +} + + +void es_security_encrypted_eid_id_key_get(uint8_t slot_no, uint8_t * p_key_buffer) +{ + ret_code_t err_code; + size_t ciphertext_size = AES_ECB_CIPHERTEXT_LENGTH; + + memcpy(m_aes_ecb_lk.cleartext, m_security_slot[slot_no].aes_ecb_ik.key, ESCS_AES_KEY_SIZE); + + err_code = nrf_crypto_aes_crypt(&m_aes_context, + &g_nrf_crypto_aes_ecb_128_info, + NRF_CRYPTO_ENCRYPT, // Operation + m_aes_ecb_lk.key, // Key + NULL, // IV + m_aes_ecb_lk.cleartext, // Data in + AES_ECB_CLEARTEXT_LENGTH, // Data in size + m_aes_ecb_lk.ciphertext, // Data out + &ciphertext_size); // Data out size + + APP_ERROR_CHECK(err_code); + + memcpy(p_key_buffer, m_aes_ecb_lk.ciphertext, ESCS_AES_KEY_SIZE); +} + + +void es_security_plain_eid_id_key_get(uint8_t slot_no, uint8_t * p_key_buffer) +{ + memcpy(p_key_buffer, m_security_slot[slot_no].aes_ecb_ik.key, ESCS_AES_KEY_SIZE); +} + + +void es_security_tlm_to_etlm(uint8_t ik_slot_no, es_tlm_frame_t * p_tlm, es_etlm_frame_t * p_etlm) +{ + ret_code_t err_code; + uint8_t plain[TLM_DATA_SIZE] = {0}; // Plaintext tlm, without the frame byte and version. + size_t nplain = TLM_DATA_SIZE; // Length of message plaintext. + + /*lint -save -e420 */ + memcpy(plain, &p_tlm->vbatt[0], sizeof(plain)); + + uint8_t key[EIK_SIZE] = {0}; // Encryption/decryption key: EIK. + + memcpy(key, &m_security_slot[ik_slot_no].aes_ecb_ik.key[0], EIK_SIZE); + /*lint -restore */ + + uint8_t nonce[NONCE_SIZE] = {0}; // Nonce. This must not repeat for a given key. + size_t nnonce = NONCE_SIZE; // Length of nonce.First 4 bytes are beacon time base with k-bits cleared. + // Last two bits are randomly generated + + // Take the current timestamp and clear the lowest K bits, use it as nonce. + uint32_t k_bits_cleared_time = (m_security_slot[ik_slot_no].timing.time_counter + >> m_security_slot[ik_slot_no].timing.k_scaler) + << m_security_slot[ik_slot_no].timing.k_scaler; + + nonce[0] = (uint8_t)((k_bits_cleared_time >> 24) & 0xff); + nonce[1] = (uint8_t)((k_bits_cleared_time >> 16) & 0xff); + nonce[2] = (uint8_t)((k_bits_cleared_time >> 8) & 0xff); + nonce[3] = (uint8_t)((k_bits_cleared_time) & 0xff); + + // Generate random salt. + uint8_t salt[SALT_SIZE] = {0}; + err_code = nrf_crypto_rng_vector_generate(salt, SALT_SIZE); + APP_ERROR_CHECK(err_code); + memcpy(&nonce[4], salt, SALT_SIZE); + + uint8_t cipher[ES_ETLM_ECRYPTED_LENGTH]; // Ciphertext output. nplain bytes are written. + uint8_t tag[TAG_SIZE] = {0}; // Authentication tag. ntag bytes are written. + size_t ntag = TAG_SIZE; // Length of authentication tag. + + // Encryption + // -------------------------------------------------------------------------- + err_code = nrf_crypto_aead_init(&m_aead_context, &g_nrf_crypto_aes_eax_128_info, key); + APP_ERROR_CHECK(err_code); + + err_code = nrf_crypto_aead_crypt(&m_aead_context, + NRF_CRYPTO_ENCRYPT, // Operation + nonce, // Nonce + nnonce, // Nonce size + NULL, // Additional authenticated data (adata) + 0, // Additional authenticated data size + plain, // Input data + nplain, // Input data size + cipher, // Output data + tag, // MAC result output + ntag); // MAC size + + APP_ERROR_CHECK(err_code); + + err_code = nrf_crypto_aead_uninit(&m_aead_context); + APP_ERROR_CHECK(err_code); + + // Construct the eTLM. + // -------------------------------------------------------------------------- + p_etlm->frame_type = p_tlm->frame_type; + p_etlm->version = ES_TLM_VERSION_ETLM; + memcpy(p_etlm->encrypted_tlm, cipher, ES_ETLM_ECRYPTED_LENGTH); + memcpy((uint8_t *)&p_etlm->random_salt, salt, SALT_SIZE); + memcpy((uint8_t *)&p_etlm->msg_integrity_check, tag, TAG_SIZE); +} + + +ret_code_t es_security_init(es_security_msg_cb_t security_callback) +{ + ret_code_t err_code; + + if (security_callback == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Get lock code from 'es_app_config.h', or fetch it from flash if exists. + lock_code_init(m_aes_ecb_lk.key); + + m_security_callback = security_callback; + + memset(&m_ecdh, 0, sizeof(es_security_ecdh_t)); + + for (uint32_t i = 0; i < APP_MAX_EID_SLOTS; ++i) + { + m_security_slot[i].timing.time_counter = APP_CONFIG_TIMING_INIT_VALUE; + } + err_code = es_stopwatch_create(&m_seconds_passed_sw_id, APP_TIMER_TICKS(1000)); + APP_ERROR_CHECK(err_code); + + err_code = nrf_crypto_init(); + APP_ERROR_CHECK(err_code); + + return NRF_SUCCESS; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.h index 26c57a2..cb4e418 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_security.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_security.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_SECURITY_H__ #define ES_SECURITY_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot.c index 3767d6c..4f81058 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include @@ -209,18 +209,11 @@ static void configure_slot(uint8_t slot_no, uint8_t length, uint8_t const * p_fr */ static void configure_eid_slot(uint8_t slot_no, uint8_t length, uint8_t const * p_frame_data) { - bool clear_eid_slot = false; - // Do not update slot count, as this will be done when in the callback invoked when the EID data // is ready. // As it takes a while to do the calculation, temporarily remove the slot being overwritten. // The slot will be re-added in the callback invoked when the EID data is ready. - clear_eid_slot = es_slot_reg_clear_slot(&m_reg, slot_no); - - if (clear_eid_slot) - { - es_security_eid_slot_destroy(slot_no); - } + (void)es_slot_reg_clear_slot(&m_reg, slot_no); if (p_frame_data[0] != ES_FRAME_TYPE_EID) { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot.h index c19ff54..6ff8701 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_SLOT_H__ #define ES_SLOT_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot_reg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot_reg.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot_reg.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot_reg.c index 23fab92..6428ea8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot_reg.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot_reg.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,9 +35,10 @@ * 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 "es_slot_reg.h" +#include "es_security.h" #define ES_SLOT_NOT_CONFIGURED 0xab /** Value set in configured lists to indicate not configured slot. */ @@ -128,6 +129,11 @@ bool es_slot_reg_clear_slot(es_slot_reg_t * p_reg, uint8_t slot_no) memset(&p_reg->slots[slot_no], 0, sizeof(p_reg->slots[slot_no])); + if (eid_has_been_cleared) + { + es_security_eid_slot_destroy(slot_no); + } + return eid_has_been_cleared; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot_reg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot_reg.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot_reg.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot_reg.h index 690bb69..83c6b72 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_slot_reg.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_slot_reg.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_SLOT_REG_H__ #define ES_SLOT_REG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_stopwatch.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_stopwatch.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_stopwatch.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_stopwatch.c index d21027c..5d8db6e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_stopwatch.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_stopwatch.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -84,7 +84,7 @@ ret_code_t es_stopwatch_create(es_stopwatch_id_t * p_sw_id, uint32_t ticks_wrap) if (!m_initialized) { - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } *p_sw_id = m_nof_ids; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_stopwatch.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_stopwatch.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_stopwatch.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_stopwatch.h index ade07c8..b837bdb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_stopwatch.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_stopwatch.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_SECURITY_TIMING_H__ #define ES_SECURITY_TIMING_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_tlm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_tlm.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_tlm.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_tlm.c index ad7df37..1dbfff9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_tlm.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_tlm.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_tlm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_tlm.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_tlm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_tlm.h index dbc9952..c8f095b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_tlm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_tlm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 ES_TLM_H__ #define ES_TLM_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_util.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_util.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_util.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_util.h index 3db1302..5bfde32 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/es_util.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/es_util.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ // See https://github.com/pfultz2/Cloak/wiki/C-Preprocessor-tricks,-tips,-and-idioms diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/nrf_ble_es.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/nrf_ble_es.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/nrf_ble_es.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/nrf_ble_es.c index adc9346..341119b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/nrf_ble_es.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/nrf_ble_es.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -56,6 +56,8 @@ static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; static nrf_ble_escs_t m_ble_ecs; //!< Struct identifying the Eddystone Config Service. static nrf_ble_es_evt_handler_t m_evt_handler; //!< Event handler. +uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; //!< Advertising handle used to identify an advertising set. + /**@brief Function for invoking registered callback. * * @param[in] evt Event to issue to callback. @@ -91,15 +93,11 @@ static void new_address_set(void) (void)sd_rand_application_vector_get(new_address.addr, BLE_GAP_ADDR_LEN); // Stop advertising to ensure that it is possible to change the address. - (void)sd_ble_gap_adv_stop(); + (void)sd_ble_gap_adv_stop(m_adv_handle); do { -#if NRF_SD_BLE_API_VERSION >= 3 err_code = sd_ble_gap_addr_set(&new_address); -#else - err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &new_address); -#endif // NRF_SD_BLE_API_VERSION } while (err_code == NRF_ERROR_INVALID_STATE); APP_ERROR_CHECK(err_code); @@ -148,7 +146,7 @@ static void check_and_update_mac_address(bool demand_new_mac) */ static void lock_beacon(void) { - *(m_ble_ecs.p_lock_state) = NRF_BLE_ESCS_LOCK_STATE_LOCKED; + m_ble_ecs.lock_state = NRF_BLE_ESCS_LOCK_STATE_LOCKED; } @@ -190,7 +188,7 @@ static void on_ble_evt(ble_evt_t const * p_ble_evt) err_code = es_flash_access_beacon_config(&beacon_config, ES_FLASH_ACCESS_WRITE); APP_ERROR_CHECK(err_code); - if (*m_ble_ecs.p_lock_state == NRF_BLE_ESCS_LOCK_STATE_UNLOCKED) + if (m_ble_ecs.lock_state == NRF_BLE_ESCS_LOCK_STATE_UNLOCKED) { lock_beacon(); } @@ -225,7 +223,7 @@ static void nrf_ble_escs_security_cb(uint8_t slot_no, es_security_msg_t msg_type switch (msg_type) { case ES_SECURITY_MSG_UNLOCKED: - *(m_ble_ecs.p_lock_state) = NRF_BLE_ESCS_LOCK_STATE_UNLOCKED; + m_ble_ecs.lock_state = NRF_BLE_ESCS_LOCK_STATE_UNLOCKED; break; case ES_SECURITY_MSG_EID: @@ -365,7 +363,8 @@ static void adv_init(void) es_adv_init(m_ble_ecs.uuid_type, adv_evt_handler, beacon_config.adv_interval, - beacon_config.remain_connectable); + beacon_config.remain_connectable, + &m_adv_handle); } @@ -375,7 +374,7 @@ static void adv_slots_init(void) uint8_t default_frame_data[DEFAULT_FRAME_LENGTH] = DEFAULT_FRAME_DATA; es_slot_t default_adv_slot = {.slot_no = 0, - .radio_tx_pwr = 0, + .radio_tx_pwr = DEFAULT_FRAME_TX_POWER, .adv_frame.type = DEFAULT_FRAME_TYPE, .adv_frame.length = DEFAULT_FRAME_LENGTH, .adv_custom_tx_power = false, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/nrf_ble_es.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/nrf_ble_es.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/nrf_ble_es.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/nrf_ble_es.h index f41eefa..92f81c3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/eddystone/nrf_ble_es.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/eddystone/nrf_ble_es.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_ES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h index cc1152e..57bcf5f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_common.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c index f2a5eae..f2ae6d4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_ln_cp.h" #include "ble_ln_db.h" @@ -64,6 +64,26 @@ NRF_LOG_MODULE_REGISTER(); #define OPCODE_LENGTH 1 /**< Length of opcode inside Location and Navigation Measurement packet. */ #define HANDLE_LENGTH 2 /**< Length of handle inside Location and Navigation Measurement packet. */ + +/**@brief Function for interception of GATT errors and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_lncp_t * p_lncp = (ble_lncp_t *)p_ctx; + + if (p_lncp->error_handler != NULL) + { + p_lncp->error_handler(nrf_error); + } +} + + static ble_lncp_rsp_code_t notify_app(ble_lncp_t const * p_lncp, ble_lncp_evt_t const * p_evt) { ble_lncp_rsp_code_t rsp = LNCP_RSP_SUCCESS; @@ -82,10 +102,10 @@ static void resp_send(ble_lncp_t * p_lncp) // Send indication uint16_t hvx_len; uint8_t hvx_data[MAX_CTRL_POINT_RESP_PARAM_LEN]; - ble_gatts_hvx_params_t hvx_params; uint32_t err_code; + nrf_ble_gq_req_t lncp_req; - memset(&hvx_params, 0, sizeof(hvx_params)); + memset(&lncp_req, 0, sizeof(nrf_ble_gq_req_t)); hvx_len = 3 + p_lncp->pending_rsp.rsp_param_len; hvx_data[0] = LNCP_OP_RESPONSE_CODE; @@ -94,40 +114,23 @@ static void resp_send(ble_lncp_t * p_lncp) memcpy(&hvx_data[3], &p_lncp->pending_rsp.rsp_param[0], p_lncp->pending_rsp.rsp_param_len); - hvx_params.handle = p_lncp->ctrlpt_handles.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = hvx_data; + lncp_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + lncp_req.error_handler.cb = gatt_error_handler; + lncp_req.error_handler.p_ctx = p_lncp; + lncp_req.params.gatts_hvx.handle = p_lncp->ctrlpt_handles.value_handle; + lncp_req.params.gatts_hvx.offset = 0; + lncp_req.params.gatts_hvx.p_data = hvx_data; + lncp_req.params.gatts_hvx.p_len = &hvx_len; + lncp_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; - err_code = sd_ble_gatts_hvx(p_lncp->conn_handle, &hvx_params); + p_lncp->is_indication_pending = true; - // Error handling - if ((err_code == NRF_SUCCESS) && (hvx_len != p_lncp->pending_rsp.rsp_param_len + 3)) - { - err_code = NRF_ERROR_DATA_SIZE; - } + err_code = nrf_ble_gq_item_add(p_lncp->p_gatt_queue, &lncp_req, p_lncp->conn_handle); - switch (err_code) + if ((p_lncp->error_handler != NULL) && + (err_code != NRF_SUCCESS)) { - case NRF_SUCCESS: - p_lncp->procedure_status = LNCP_STATE_CONFIRMATION_PENDING; - // Wait for HVC event - break; - - case NRF_ERROR_RESOURCES: - // Wait for TX_COMPLETE event to retry transmission - p_lncp->procedure_status = LNCP_STATE_INDICATION_PENDING; - break; - - default: - p_lncp->procedure_status = LNCP_STATE_INDICATION_PENDING; - // error - if (p_lncp->error_handler != NULL) - { - p_lncp->error_handler(err_code); - } - break; + p_lncp->error_handler(err_code); } } @@ -136,7 +139,6 @@ static void on_connect(ble_lncp_t * p_lncp, ble_evt_t const * p_ble_evt) { memset(&p_lncp->mask, 0, sizeof(ble_lncp_mask_t)); p_lncp->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - p_lncp->procedure_status = LNCP_STATE_NO_PROC_IN_PROGRESS; } @@ -144,7 +146,6 @@ static void on_disconnect(ble_lncp_t * p_lncp, ble_evt_t const * p_ble_evt) { UNUSED_PARAMETER(p_ble_evt); p_lncp->conn_handle = BLE_CONN_HANDLE_INVALID; - p_lncp->procedure_status = LNCP_STATE_NO_PROC_IN_PROGRESS; } @@ -152,9 +153,9 @@ static void on_hvc_confirm(ble_lncp_t * p_lncp, ble_evt_t const * p_ble_evt) { if (p_ble_evt->evt.gatts_evt.params.hvc.handle == p_lncp->ctrlpt_handles.value_handle) { - if (p_lncp->procedure_status == LNCP_STATE_CONFIRMATION_PENDING) + if (p_lncp->is_indication_pending) { - p_lncp->procedure_status = LNCP_STATE_NO_PROC_IN_PROGRESS; + p_lncp->is_indication_pending = false; } else { @@ -167,15 +168,6 @@ static void on_hvc_confirm(ble_lncp_t * p_lncp, ble_evt_t const * p_ble_evt) } -static void on_tx_complete(ble_lncp_t * p_lncp) -{ - if (p_lncp->procedure_status == LNCP_STATE_INDICATION_PENDING) - { - resp_send(p_lncp); - } -} - - /**@brief Handle write events to the control point cccd. * * @param[in] p_lncp Location and Navigation Service structure. @@ -527,7 +519,7 @@ static void on_ctrlpt_write(ble_lncp_t * p_lncp, ble_gatts_evt_write_t const * p if (p_lncp->is_ctrlpt_indication_enabled) { - if (p_lncp->procedure_status == LNCP_STATE_NO_PROC_IN_PROGRESS) + if (!p_lncp->is_indication_pending) { write_authorize_reply.params.write.update = 1; write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; @@ -541,19 +533,19 @@ static void on_ctrlpt_write(ble_lncp_t * p_lncp, ble_gatts_evt_write_t const * p { if (!p_lncp->is_nav_notification_enabled) { - write_authorize_reply.params.write.gatt_status = LNCP_RSP_CCCD_CONFIG_IMPROPER; + write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR; } } } } else { - write_authorize_reply.params.write.gatt_status = LNCP_RSP_PROC_ALR_IN_PROG; + write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG; } } else { - write_authorize_reply.params.write.gatt_status = LNCP_RSP_CCCD_CONFIG_IMPROPER; + write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR; } // reply to the write authorization @@ -575,7 +567,6 @@ static void on_ctrlpt_write(ble_lncp_t * p_lncp, ble_gatts_evt_write_t const * p } // Start executing the control point write action - p_lncp->procedure_status = LNCP_STATE_INDICATION_PENDING; if (p_evt_write->len > 0) { p_lncp->pending_rsp.op_code = (ble_lncp_op_code_t) p_evt_write->data[0]; @@ -621,10 +612,6 @@ static void on_ctrlpt_write(ble_lncp_t * p_lncp, ble_gatts_evt_write_t const * p resp_send(p_lncp); } - else - { - p_lncp->procedure_status = LNCP_STATE_NO_PROC_IN_PROGRESS; - } } @@ -717,9 +704,6 @@ void ble_lncp_on_ble_evt(ble_lncp_t * p_lncp, ble_evt_t const * p_ble_evt) } break; - case BLE_GATTS_EVT_HVN_TX_COMPLETE: - on_tx_complete(p_lncp); - break; default: // no implementation @@ -777,6 +761,7 @@ ret_code_t ble_lncp_init(ble_lncp_t * p_lncp, ble_lncp_init_t const * p_lncp_ini { VERIFY_PARAM_NOT_NULL(p_lncp); VERIFY_PARAM_NOT_NULL(p_lncp_init); + VERIFY_PARAM_NOT_NULL(p_lncp_init->p_gatt_queue); ble_add_char_params_t add_char_params; @@ -785,6 +770,7 @@ ret_code_t ble_lncp_init(ble_lncp_t * p_lncp, ble_lncp_init_t const * p_lncp_ini p_lncp->service_handle = p_lncp_init->service_handle; p_lncp->evt_handler = p_lncp_init->evt_handler; p_lncp->error_handler = p_lncp_init->error_handler; + p_lncp->p_gatt_queue = p_lncp_init->p_gatt_queue; p_lncp->available_features = p_lncp_init->available_features; p_lncp->is_position_quality_present = p_lncp_init->is_position_quality_present; p_lncp->is_navigation_present = p_lncp_init->is_navigation_present; @@ -795,7 +781,6 @@ ret_code_t ble_lncp_init(ble_lncp_t * p_lncp, ble_lncp_init_t const * p_lncp_ini p_lncp->fix_rate = BLE_LNS_NO_FIX; p_lncp->selected_route = BLE_LNS_INVALID_ROUTE; - p_lncp->procedure_status = LNCP_STATE_NO_PROC_IN_PROGRESS; p_lncp->conn_handle = BLE_CONN_HANDLE_INVALID; p_lncp->is_navigation_running = false; p_lncp->is_nav_notification_enabled = false; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h index 6987da1..de9cc7c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_cp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -52,6 +52,7 @@ #include "ble_srv_common.h" #include "sdk_common.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -144,8 +145,6 @@ typedef enum LNCP_RSP_OP_CODE_NOT_SUPPORTED = 0x02, /**< Op Code not supported. */ LNCP_RSP_INVALID_PARAMETER = 0x03, /**< Invalid Parameter. */ LNCP_RSP_OPERATION_FAILED = 0x04, /**< Operation Failed. */ - LNCP_RSP_PROC_ALR_IN_PROG = BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG, /**< Control point procedure is already in progress. */ - LNCP_RSP_CCCD_CONFIG_IMPROPER = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR /**< CCCD is improperly configured. */ } ble_lncp_rsp_code_t; @@ -167,15 +166,6 @@ typedef enum } ble_lncp_op_code_t; -/** @brief Location and Navigation Control Point procedure status */ -typedef enum -{ - LNCP_STATE_NO_PROC_IN_PROGRESS, /**< No procedure in progress. */ - LNCP_STATE_INDICATION_PENDING, /**< Control Point indication is pending. */ - LNCP_STATE_CONFIRMATION_PENDING, /**< Waiting for the indication confirmation. */ -} ble_lncp_procedure_status_t; - - /** @brief Information included in a control point write response indication. */ typedef struct { @@ -192,6 +182,8 @@ typedef struct ble_lncp_evt_handler_t evt_handler; ble_srv_error_handler_t error_handler; + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT queue instance. */ + uint32_t available_features; /**< Value of the LN feature. */ bool is_position_quality_present; /**< If set to true, the position quality characteristic will be added. Else not. */ bool is_control_point_present; /**< If set to true, the control point characteristic will be added. Else not. */ @@ -214,9 +206,10 @@ struct ble_lncp_s ble_gatts_char_handles_t navigation_handles; ble_lncp_evt_handler_t evt_handler; ble_srv_error_handler_t error_handler; - ble_lncp_procedure_status_t procedure_status; ble_lncp_rsp_t pending_rsp; + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT queue instance. */ + ble_lncp_mask_t mask; uint32_t total_distance; uint32_t elevation; @@ -230,6 +223,8 @@ struct ble_lncp_s bool is_ctrlpt_indication_enabled; /**< True if indication is enabled on the Control Point characteristic. */ bool is_nav_notification_enabled; /**< True if notification is enabled on the Navigation characteristic. */ + + bool is_indication_pending; /**< True if Control Point indication is pending. */ }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c index c4ea62a..9855cda 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_db.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_ln_db.h" #include "ble_ln_common.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h index a3604cb..7468ea1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_ln_db.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_lns.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_lns.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_lns.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_lns.c index ea7f61f..6bd803e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_lns.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_lns.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_lns.h" #include "ble_ln_db.h" @@ -137,12 +137,23 @@ static void notification_buffer_process(ble_lns_t * p_lns) */ static void on_connect(ble_lns_t * p_lns, ble_evt_t const * p_ble_evt) { + ret_code_t err_code; + p_lns->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; // clear pending notifications p_lns->pending_loc_speed_notifications[0].is_pending = false; p_lns->pending_loc_speed_notifications[1].is_pending = false; p_lns->pending_navigation_notification.is_pending = false; + + err_code = nrf_ble_gq_conn_handle_register(p_lns->p_gatt_queue, + p_ble_evt->evt.gap_evt.conn_handle); + + if ((p_lns->error_handler != NULL) && + (err_code != NRF_SUCCESS)) + { + p_lns->error_handler(err_code); + } } @@ -793,6 +804,7 @@ ret_code_t ble_lns_init(ble_lns_t * p_lns, ble_lns_init_t const * p_lns_init) { VERIFY_PARAM_NOT_NULL(p_lns); VERIFY_PARAM_NOT_NULL(p_lns_init); + VERIFY_PARAM_NOT_NULL(p_lns_init->p_gatt_queue); if (init_param_mismatch_present(p_lns_init) == true) { @@ -809,6 +821,7 @@ ret_code_t ble_lns_init(ble_lns_t * p_lns, ble_lns_init_t const * p_lns_init) p_lns->conn_handle = BLE_CONN_HANDLE_INVALID; p_lns->available_features = p_lns_init->available_features; p_lns->is_navigation_present = p_lns_init->is_navigation_present; + p_lns->p_gatt_queue = p_lns_init->p_gatt_queue; // clear pending notifications p_lns->pending_loc_speed_notifications[0].is_pending = false; @@ -875,6 +888,7 @@ ret_code_t ble_lns_init(ble_lns_t * p_lns, ble_lns_init_t const * p_lns_init) lncp_init.available_features = p_lns_init->available_features; lncp_init.is_position_quality_present = p_lns_init->is_position_quality_present; lncp_init.is_navigation_present = p_lns_init->is_navigation_present; + lncp_init.p_gatt_queue = p_lns_init->p_gatt_queue; lncp_init.total_distance = p_lns_init->p_location_speed->total_distance; lncp_init.elevation = p_lns_init->p_location_speed->elevation; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_lns.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_lns.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_lns.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_lns.h index 7dcf876..b587ab0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_lns/ble_lns.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_lns/ble_lns.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -68,6 +68,7 @@ #include "ble_ln_cp.h" #include "sdk_common.h" #include "nrf_sdh_ble.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -115,11 +116,7 @@ typedef struct bool is_pending; uint16_t handle; uint16_t len; -#if (NRF_SD_BLE_API_VERSION <= 3) - uint8_t data[GATT_MTU_SIZE_DEFAULT]; -#else uint8_t data[BLE_GATT_ATT_MTU_DEFAULT]; -#endif } notification_t; @@ -136,6 +133,8 @@ struct ble_lns_init_s ble_lncp_evt_handler_t lncp_evt_handler; ble_srv_error_handler_t error_handler; /**< Errors will be sent back to this function. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT queue instance. */ + bool is_position_quality_present; /**< If set to true, the position quality characteristic will be added. Else not. */ bool is_control_point_present; /**< If set to true, the control point characteristic will be added. Else not. */ bool is_navigation_present; /**< If set to true, the navigation characteristic will be added. Else not. */ @@ -166,6 +165,8 @@ struct ble_lns_s ble_lns_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Location and Navigation Service. */ ble_srv_error_handler_t error_handler; /**< Error handler. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT queue instance. */ + bool is_navigation_present; /**< If set to true, the navigation characteristic is present. Else not. */ uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack; BLE_CONN_HANDLE_INVALID if not in a connection). */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots.c index 2e34744..3d1b44c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -124,7 +124,18 @@ static uint32_t feature_char_add(ble_ots_t * const p_ots, */ static void on_connect(ble_ots_t * p_ots, ble_evt_t const * p_ble_evt) { + ret_code_t err_code; + p_ots->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + + err_code = nrf_ble_gq_conn_handle_register(p_ots->p_gatt_queue, + p_ble_evt->evt.gap_evt.conn_handle); + + if ((p_ots->error_handler != NULL) && + (err_code != NRF_SUCCESS)) + { + p_ots->error_handler(err_code); + } } /**@brief Function for handling the BLE_GAP_EVT_DISCONNECTED event. @@ -149,6 +160,11 @@ uint32_t ble_ots_init(ble_ots_t * p_ots, ble_ots_init_t * p_ots_init) return NRF_ERROR_NULL; } + if (p_ots_init->p_gatt_queue == NULL) + { + return NRF_ERROR_NULL; + } + p_ots->conn_handle = BLE_CONN_HANDLE_INVALID; p_ots->error_handler = p_ots_init->error_handler; p_ots->evt_handler = p_ots_init->evt_handler; @@ -156,7 +172,7 @@ uint32_t ble_ots_init(ble_ots_t * p_ots, ble_ots_init_t * p_ots_init) p_ots->error_handler = p_ots_init->error_handler; p_ots->evt_handler = p_ots_init->evt_handler; p_ots->p_current_object = p_ots_init->p_object; - + p_ots->p_gatt_queue = p_ots_init->p_gatt_queue; ble_uuid_t service_uuid = { @@ -202,18 +218,6 @@ uint32_t ble_ots_init(ble_ots_t * p_ots, ble_ots_init_t * p_ots_init) return NRF_SUCCESS; } -/**@brief Function for handling the BLE_EVT_TX_COMPLETE event. Calls the hvx buffering module. - * @param[in] p_ots Object Transfer Service structure. */ -static inline void on_tx_complete(ble_ots_t * p_ots) -{ - uint32_t err_code; - err_code = ble_hvx_buffer_process(&p_ots->hvx_buf); - if (err_code != NRF_SUCCESS) - { - p_ots->error_handler(err_code); - } - -} void ble_ots_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) { @@ -237,10 +241,6 @@ void ble_ots_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_disconnect(p_ots, p_ble_evt); break; - case BLE_GATTS_EVT_HVN_TX_COMPLETE: - on_tx_complete(p_ots); - break; - default: // No implementation needed. break; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots.h index a02d979..c9a5c2f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -54,7 +54,7 @@ #include #include "ble_srv_common.h" #include "ble_date_time.h" -#include "ble_hvx_buffering.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -123,9 +123,9 @@ typedef struct { uint8_t name[BLE_OTS_NAME_MAX_SIZE]; /**< The name of the object. If the name is "", the object will be invalidated on disconnect. */ uint8_t data[BLE_OTS_MAX_OBJ_SIZE]; + uint32_t current_size; ble_ots_obj_type_t type; ble_ots_obj_properties_t properties; - uint32_t current_size; uint32_t alloc_len; bool is_valid; /**< States if the object will be shown in a list. */ bool is_locked; /**< When an object is written or read, the object will be locked. */ @@ -210,9 +210,10 @@ struct ble_ots_l2cap_s ble_l2cap_ch_rx_params_t rx_params; ble_l2cap_ch_tx_params_t tx_params; uint16_t remaining_bytes; /**< The number of remaining bytes in the current transfer. */ - uint16_t transfered_bytes; + uint16_t transmitted_bytes; + uint16_t received_bytes; uint16_t transfer_len; /**< The total number of bytes in the current transfer. */ - uint16_t local_cid; /**< Connection id of the current connection. */ + uint16_t local_cid; /**< Connection ID of the current connection. */ uint16_t conn_mtu; /**< The maximum transmission unit, that is the number of packets that can be sent or received. */ uint16_t conn_mps; /**< MPS defines the maximum payload size in bytes. */ }; @@ -370,8 +371,9 @@ typedef struct security_req_t feature_char_read_access; /**< Read security level for the feature characteristic value. */ ble_ots_object_chars_init_t object_chars_init; /**< The initialization structure of the object characteristics. */ ble_ots_oacp_init_t oacp_init; /**< The initialization structure of the object action control point. */ - uint16_t rx_mps; /**< Size of L2CAP Rx MPS (must be at least BLE_L2CAP_MPS_MIN).*/ - uint16_t rx_mtu; /**< Size of L2CAP Rx MTU (must be at least BLE_L2CAP_MTU_MIN).*/ + uint16_t rx_mps; /**< Size of L2CAP Rx MPS (must be at least BLE_L2CAP_MPS_MIN).*/ + uint16_t rx_mtu; /**< Size of L2CAP Rx MTU (must be at least BLE_L2CAP_MTU_MIN).*/ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT queue instance. */ } ble_ots_init_t; struct ble_ots_s @@ -384,7 +386,7 @@ struct ble_ots_s ble_ots_object_chars_t object_chars; /**< The structure holding the object characteristics representation. */ ble_ots_oacp_t oacp_chars; /**< The structure holding the object action control point characteristics representation. */ ble_ots_object_t * p_current_object; /**< Pointer to the currently selected object. */ - ble_hvx_buf_t hvx_buf; /**< A buffer holding unsent handle value indications/notifications. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT queue instance. */ }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c index b5b69e1..c45c3dd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_ots_l2cap.h" @@ -49,7 +49,7 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -#define SDU_SIZE 256 +#define SDU_SIZE 1024 static uint8_t data[SDU_SIZE]; @@ -106,39 +106,65 @@ uint32_t ble_ots_l2cap_init(ble_ots_l2cap_t * p_ots_l2cap, ble_ots_l2cap_init_t return NRF_SUCCESS; } +/**@brief This function receives the next MTU of the object. + * + * @param[in] p_ots_l2cap Object Transfer Service structure. + */ +static void receive_resume(ble_ots_l2cap_t * p_ots_l2cap) +{ + ret_code_t err_code; + ble_data_t sdu_buf; + + sdu_buf.p_data = &p_ots_l2cap->rx_params.sdu_buf.p_data[p_ots_l2cap->received_bytes]; + sdu_buf.len = p_ots_l2cap->rx_params.sdu_buf.len - p_ots_l2cap->received_bytes; + err_code = sd_ble_l2cap_ch_rx(p_ots_l2cap->p_ots_oacp->p_ots->conn_handle, + p_ots_l2cap->local_cid, + &sdu_buf); -/**@brief This function resumes sending data after an interrupt in the transfer. + if (err_code == NRF_ERROR_RESOURCES) + { + return; // Too many SDUs queued for transmission, the transmission will be tried again on the next BLE_L2CAP_EVT_CH_RX event. + } + + if (err_code != NRF_SUCCESS && p_ots_l2cap->p_ots_oacp->p_ots->error_handler != NULL) + { + p_ots_l2cap->p_ots_oacp->p_ots->error_handler(err_code); + } +} + +/**@brief This function sends the next MTU of the object. * - * @param[in] p_ots_l2cap Object Transfer Service structure. + * @param[in] p_ots_l2cap Object Transfer Service structure. */ -static void ble_ots_l2cap_resume_send(ble_ots_l2cap_t * p_ots_l2cap) +static void send_resume(ble_ots_l2cap_t * p_ots_l2cap) { - uint16_t transmit_size; - ble_data_t data_buf; + ret_code_t err_code; + uint16_t tx_size; - transmit_size = MIN(p_ots_l2cap->tx_params.tx_mtu, p_ots_l2cap->remaining_bytes); + tx_size = MIN(p_ots_l2cap->transfer_len - p_ots_l2cap->transmitted_bytes, + p_ots_l2cap->tx_params.tx_mtu); - data_buf.p_data = &p_ots_l2cap->tx_transfer_buffer.p_data[p_ots_l2cap->transfer_len - p_ots_l2cap->remaining_bytes]; - data_buf.len = transmit_size; + ble_data_t obj; + obj.p_data = &p_ots_l2cap->tx_transfer_buffer.p_data[p_ots_l2cap->transmitted_bytes]; + obj.len = tx_size; + err_code = sd_ble_l2cap_ch_tx(p_ots_l2cap->p_ots_oacp->p_ots->conn_handle, + p_ots_l2cap->local_cid, + &obj); + if (err_code == NRF_ERROR_RESOURCES) + { + return; // Too many SDUs queued for transmission, the transmission will be tried again on the next BLE_L2CAP_EVT_CH_TX event. + } - uint32_t err_code = sd_ble_l2cap_ch_tx(p_ots_l2cap->p_ots_oacp->p_ots->conn_handle, - p_ots_l2cap->local_cid, - &data_buf); - - if (err_code != NRF_SUCCESS && err_code != NRF_ERROR_BUSY) + if (err_code != NRF_SUCCESS && p_ots_l2cap->p_ots_oacp->p_ots->error_handler != NULL) { - if (p_ots_l2cap->p_ots_oacp->p_ots->error_handler != NULL) - { p_ots_l2cap->p_ots_oacp->p_ots->error_handler(err_code); - return; - } } } -uint32_t ble_ots_l2cap_start_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_data, uint16_t data_len) +uint32_t ble_ots_l2cap_obj_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_data, uint16_t data_len) { if (p_ots_l2cap == NULL) { @@ -164,12 +190,12 @@ uint32_t ble_ots_l2cap_start_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_dat p_ots_l2cap->tx_transfer_buffer.p_data = p_data; p_ots_l2cap->tx_transfer_buffer.len = data_len; - p_ots_l2cap->remaining_bytes = data_len; - p_ots_l2cap->transfer_len = data_len; + p_ots_l2cap->transmitted_bytes = 0; + p_ots_l2cap->transfer_len = data_len; p_ots_l2cap->state = SENDING; - ble_ots_l2cap_resume_send(p_ots_l2cap); + send_resume(p_ots_l2cap); return NRF_SUCCESS; } @@ -190,8 +216,7 @@ uint32_t ble_ots_l2cap_start_recv(ble_ots_l2cap_t * p_ots_l2cap, uint16_t len) { return NRF_ERROR_INVALID_STATE; } - p_ots_l2cap->transfered_bytes = 0; - p_ots_l2cap->remaining_bytes = len; + p_ots_l2cap->received_bytes = 0; p_ots_l2cap->transfer_len = len; err_code = sd_ble_l2cap_ch_rx(p_ots_l2cap->p_ots_oacp->p_ots->conn_handle, @@ -250,7 +275,6 @@ static inline void on_l2cap_ch_setup_request(ble_ots_l2cap_t * p_ots_l2cap, ble_ { p_ots_l2cap->p_ots_oacp->p_ots->error_handler(err_code); } - } NRF_LOG_INFO("Accepted L2CAP Channel"); } @@ -300,21 +324,32 @@ static inline void on_l2cap_ch_released(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t } -/**@brief This function ois called tx is completet. It continues to send if necessary. +/**@brief Function for handling the BLE_L2CAP_EVT_CH_TX event. * * @param[in] p_ots_l2cap Object transfer service l2cap module structure. * @param[in] p_ble_evt Pointer to the event received from BLE stack. */ -static void on_tx_complete(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p_ble_evt) +static void on_l2cap_ch_tx(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p_ble_evt) { if(p_ots_l2cap->local_cid != p_ble_evt->evt.l2cap_evt.local_cid) { return; } - p_ots_l2cap->remaining_bytes -= p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len; + NRF_LOG_DEBUG("Bytes sent in the previous PDU: %i", + p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len); + NRF_LOG_HEXDUMP_DEBUG(p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.p_data, + p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len); + + p_ots_l2cap->transmitted_bytes += p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len; + uint16_t remaining_tx_bytes = p_ots_l2cap->tx_transfer_buffer.len - p_ots_l2cap->transmitted_bytes; + + NRF_LOG_DEBUG("Total bytes transmitted: %i ", + (p_ots_l2cap->transmitted_bytes)); + NRF_LOG_DEBUG("Total bytes remaining: %i", + (remaining_tx_bytes)); - if (p_ots_l2cap->remaining_bytes == 0) + if (remaining_tx_bytes == 0) { ble_ots_l2cap_evt_t evt; @@ -327,11 +362,11 @@ static void on_tx_complete(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p_bl p_ots_l2cap->state = CONNECTED; - p_ots_l2cap->transfer_len = 0; + p_ots_l2cap->transfer_len = 0; } else { - ble_ots_l2cap_resume_send(p_ots_l2cap); + send_resume(p_ots_l2cap); } } @@ -343,46 +378,34 @@ static void on_l2cap_ch_rx(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p_bl return; } + NRF_LOG_DEBUG("Bytes received: %i", p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); + NRF_LOG_HEXDUMP_DEBUG(p_ble_evt->evt.l2cap_evt.params.rx.sdu_buf.p_data, + p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); + ble_ots_l2cap_evt_t evt; - memcpy(&p_ots_l2cap->p_ots_oacp->p_ots->p_current_object->data[p_ots_l2cap->transfered_bytes], + memcpy(&p_ots_l2cap->p_ots_oacp->p_ots->p_current_object->data[p_ots_l2cap->received_bytes], p_ble_evt->evt.l2cap_evt.params.rx.sdu_buf.p_data, p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); - NRF_LOG_DEBUG("Object buffer dump"); - NRF_LOG_HEXDUMP_DEBUG(p_ots_l2cap->rx_params.sdu_buf.p_data , p_ots_l2cap->rx_params.sdu_buf.len); - p_ots_l2cap->transfered_bytes += p_ble_evt->evt.l2cap_evt.params.rx.sdu_len; - p_ots_l2cap->remaining_bytes -= p_ble_evt->evt.l2cap_evt.params.rx.sdu_len; - NRF_LOG_INFO("Bytes remaining to receive: %i", p_ots_l2cap->remaining_bytes); - p_ots_l2cap->state = CONNECTED; - p_ots_l2cap->transfer_len = 0; + p_ots_l2cap->received_bytes += p_ble_evt->evt.l2cap_evt.params.rx.sdu_len; + + uint16_t remaining_bytes = (p_ots_l2cap->transfer_len - p_ots_l2cap->received_bytes); - if(p_ots_l2cap->remaining_bytes <= 0) + NRF_LOG_DEBUG("Remaining bytes to receive: %i", remaining_bytes); + + if(remaining_bytes == 0) { evt.type = BLE_OTS_L2CAP_EVT_RECV_COMPLETE; evt.param.len = p_ots_l2cap->rx_params.sdu_buf.len; evt.param.p_data = p_ots_l2cap->rx_params.sdu_buf.p_data; p_ots_l2cap->evt_handler(p_ots_l2cap, &evt); + p_ots_l2cap->state = CONNECTED; + p_ots_l2cap->transfer_len = 0; } else { - ret_code_t err_code; - - ble_data_t sdu_buf; - sdu_buf.p_data = &p_ots_l2cap->rx_params.sdu_buf.p_data[p_ots_l2cap->transfered_bytes]; - sdu_buf.len = p_ots_l2cap->rx_params.sdu_buf.len; - - err_code = sd_ble_l2cap_ch_rx(p_ots_l2cap->p_ots_oacp->p_ots->conn_handle, - p_ots_l2cap->local_cid, - &sdu_buf); - if (err_code == NRF_SUCCESS) - { - p_ots_l2cap->state = RECEIVING; - } - else - { - p_ots_l2cap->state = CONNECTED; - } + receive_resume(p_ots_l2cap); } } @@ -416,22 +439,23 @@ void ble_ots_l2cap_on_ble_evt(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p case BLE_L2CAP_EVT_CH_RELEASED: on_l2cap_ch_released(p_ots_l2cap, p_ble_evt); break; + case BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED: break; + case BLE_L2CAP_EVT_CH_CREDIT: break; + case BLE_L2CAP_EVT_CH_RX: on_l2cap_ch_rx(p_ots_l2cap, p_ble_evt); break; case BLE_L2CAP_EVT_CH_TX: - on_tx_complete(p_ots_l2cap, p_ble_evt); + on_l2cap_ch_tx(p_ots_l2cap, p_ble_evt); break; + default: // No implementation needed. break; } } - - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h index 601716b..18f63f9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_l2cap.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -57,13 +57,15 @@ /**@brief Function for initializing the Object Transfer Service l2cap module. * * @param[out] p_ots_l2cap Object Transfer Service l2cap structure. This structure will have to be - * supplied by the application. It will be initialized by this function, * and will later be used to identify this particular instance. - * @param[in] p_ots_l2cap_init Information needed to initialize the service. + * supplied by the application. It will be initialized by this function, + * and will later be used to identify this particular instance. + * @param[in] p_ots_l2cap_init Information needed to initialize the module. * * @return NRF_SUCCESS on successful initialization, otherwise an error code. */ uint32_t ble_ots_l2cap_init(ble_ots_l2cap_t * p_ots_l2cap, ble_ots_l2cap_init_t * p_ots_l2cap_init); + /**@brief Function for handling the Application's BLE Stack events. * * @details Handles all events from the BLE stack of interest to the l2cap module. @@ -73,6 +75,7 @@ uint32_t ble_ots_l2cap_init(ble_ots_l2cap_t * p_ots_l2cap, ble_ots_l2cap_init_t */ void ble_ots_l2cap_on_ble_evt(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p_ble_evt); + /**@brief Function starting to send the data in the transfer buffer. * * @param[in] p_ots_l2cap Object transfer service l2cap module structure. @@ -82,7 +85,8 @@ void ble_ots_l2cap_on_ble_evt(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p * @return NRF_SUCCESS If the transmission was started. * @return NRF_ERROR_INVALID_STATE When in an invalid state. Otherwise an other error code. */ -uint32_t ble_ots_l2cap_start_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_data, uint16_t data_len); +uint32_t ble_ots_l2cap_obj_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_data, uint16_t data_len); + /**@brief Function starting to receive data to the transfer buffer. * @@ -94,6 +98,7 @@ uint32_t ble_ots_l2cap_start_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_dat */ uint32_t ble_ots_l2cap_start_recv(ble_ots_l2cap_t * p_ots_l2cap, uint16_t len); + /**@brief Function that checks if the channel is available for transmission. * * @param[in] p_ots_l2cap Object transfer service l2cap module structure. @@ -102,6 +107,7 @@ uint32_t ble_ots_l2cap_start_recv(ble_ots_l2cap_t * p_ots_l2cap, uint16_t len); */ bool ble_ots_l2cap_is_channel_available(ble_ots_l2cap_t * p_ots_l2cap); + /**@brief Function starting to abort the current transmission. * * @param[in] p_ots_l2cap Object transfer service l2cap module structure. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c index c45d256..28724a5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_ots_oacp.h" @@ -54,12 +54,32 @@ NRF_LOG_MODULE_REGISTER(); #define OTS_FILE_ID 1234 #define OTS_FDS_KEY 4321 +#define OACP_INDICATION_LEN 3 /**< Indication data length. */ + +/**@brief Function for interception of GATT errors and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + ble_ots_t * p_ots = (ble_ots_t *)p_ctx; + + if (p_ots->error_handler != NULL) + { + p_ots->error_handler(nrf_error); + } +} + /**@brief Checks if the cccd handle is configured for indication * * @param[in] cccd_handle The CCCD handle. */ -bool is_cccd_configured(ble_ots_oacp_t * const p_ots_oacp) +static bool is_cccd_configured(ble_ots_oacp_t * const p_ots_oacp) { uint32_t err_code; uint8_t cccd_value_buf[BLE_CCCD_VALUE_LEN]; @@ -68,6 +88,7 @@ bool is_cccd_configured(ble_ots_oacp_t * const p_ots_oacp) uint16_t cccd_handle = p_ots_oacp->oacp_handles.cccd_handle; uint16_t conn_handle = p_ots_oacp->p_ots->conn_handle; + // Initialize value struct. memset(&gatts_value, 0, sizeof(gatts_value)); @@ -78,7 +99,12 @@ bool is_cccd_configured(ble_ots_oacp_t * const p_ots_oacp) err_code = sd_ble_gatts_value_get(conn_handle, cccd_handle, &gatts_value); - if (err_code != NRF_SUCCESS) + + if (err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING) + { + is_oacp_indic_enabled = false; + } + else if (err_code != NRF_SUCCESS) { // Report error to application if (p_ots_oacp->p_ots->error_handler != NULL) @@ -86,14 +112,14 @@ bool is_cccd_configured(ble_ots_oacp_t * const p_ots_oacp) p_ots_oacp->p_ots->error_handler(err_code); } } - - is_oacp_indic_enabled = ble_srv_is_indication_enabled(cccd_value_buf); - + else + { + is_oacp_indic_enabled = ble_srv_is_indication_enabled(cccd_value_buf); + } return is_oacp_indic_enabled; } - /** @brief This is the l2cap connection oriented channel event handler. * * @param[in] p_ots_l2cap Pointer to the l2cap module @@ -112,6 +138,7 @@ static void ots_l2cap_evt_handler(ble_ots_l2cap_t * p_ots_l2cap, ble_ots_l2cap_e NRF_LOG_INFO("BLE_OTS_L2CAP_EVT_CH_DISCONNECTED."); break; case BLE_OTS_L2CAP_EVT_SEND_COMPLETE: + NRF_LOG_INFO("BLE_OTS_L2CAP_EVT_SEND_COMPLETE."); p_ots_l2cap->p_ots_oacp->p_ots->p_current_object->is_locked = false; break; case BLE_OTS_L2CAP_EVT_RECV_COMPLETE: @@ -159,7 +186,7 @@ static uint32_t oacp_char_add(ble_ots_oacp_t * const p_ots_oacp, add_char_params.char_props.indicate = true; add_char_params.char_props.write = true; add_char_params.cccd_write_access = cccd_write_access; - //add_char_params.is_defered_write = true; + add_char_params.is_defered_write = true; add_char_params.write_access = write_access; return characteristic_add(service_handle, @@ -287,12 +314,12 @@ static inline ble_ots_oacp_res_code_t oacp_read_proc(ble_ots_oacp_t * p_ots_oacp p_ots_oacp->p_ots->evt_handler(p_ots_oacp->p_ots, &ble_ots_evt); - ret_code_t err_code = ble_ots_l2cap_start_send(&p_ots_oacp->ots_l2cap, - p_ots_oacp->p_ots->p_current_object->data, - p_ots_oacp->p_ots->p_current_object->current_size); + ret_code_t err_code = ble_ots_l2cap_obj_send(&p_ots_oacp->ots_l2cap, + p_ots_oacp->p_ots->p_current_object->data, + p_ots_oacp->p_ots->p_current_object->current_size); if (err_code != NRF_SUCCESS) { - NRF_LOG_ERROR("ble_ots_l2cap_start_send returned error 0x%x", err_code); + NRF_LOG_ERROR("ble_ots_l2cap_obj_send returned error 0x%x", err_code); } return BLE_OTS_OACP_RES_SUCCESS; } @@ -341,32 +368,33 @@ static uint32_t ble_ots_oacp_response_send(ble_ots_oacp_t * p_ots_oacp, ble_ots_oacp_res_code_t result_code, uint16_t conn_handle) { - uint16_t index = 0; - uint8_t * p_data; - ble_gatts_hvx_params_t *p_hvx_params; - - ble_hvx_t * p_hvx = ble_hvx_get_p_to_next_hvx(&p_ots_oacp->p_ots->hvx_buf); - p_data = p_hvx->data; - p_hvx_params = &p_hvx->params; + uint16_t index = 0; + uint8_t data[OACP_INDICATION_LEN]; + nrf_ble_gq_req_t ots_req; - p_data[index++] = BLE_OTS_OACP_PROC_RESP; + data[index++] = BLE_OTS_OACP_PROC_RESP; // Encode the Request Op code - p_data[index++] = (uint8_t)req_op_code; + data[index++] = (uint8_t)req_op_code; // Encode the Result code. - p_data[index++] = (uint8_t)result_code; + data[index++] = (uint8_t)result_code; - memset(p_hvx_params, 0, sizeof(ble_gatts_hvx_params_t)); + memset(&ots_req, 0, sizeof(nrf_ble_gq_req_t)); - p_hvx_params->handle = p_ots_oacp->oacp_handles.value_handle; - p_hvx_params->type = BLE_GATT_HVX_INDICATION; - p_hvx_params->offset = 0; - p_hvx_params->p_len = &index; - p_hvx_params->p_data = p_data; + ots_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + ots_req.error_handler.cb = gatt_error_handler; + ots_req.error_handler.p_ctx = p_ots_oacp->p_ots; + ots_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; + ots_req.params.gatts_hvx.handle = p_ots_oacp->oacp_handles.value_handle; + ots_req.params.gatts_hvx.offset = 0; + ots_req.params.gatts_hvx.p_data = data; + ots_req.params.gatts_hvx.p_len = &index; - return ble_hvx_buffer_process(&p_ots_oacp->p_ots->hvx_buf); + return nrf_ble_gq_item_add(p_ots_oacp->p_ots->p_gatt_queue, + &ots_req, + conn_handle); } /**@brief Decode an OACP command, and extract its data. @@ -467,6 +495,40 @@ static void on_oacp_write(ble_ots_oacp_t * p_ots_oacp, ble_gatts_evt_write_t con ble_ots_oacp_res_code_t oacp_status; ble_ots_oacp_proc_t oacp_proc; + ble_gatts_rw_authorize_reply_params_t auth_reply; + memset(&auth_reply, 0, sizeof(auth_reply)); + + auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; + auth_reply.params.write.offset = 0; + auth_reply.params.write.len = 0; + auth_reply.params.write.p_data = NULL; + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; + auth_reply.params.write.update = 1; + + if(is_cccd_configured(p_ots_oacp)) + { + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; + err_code = sd_ble_gatts_rw_authorize_reply(p_ots_oacp->p_ots->conn_handle, &auth_reply); + + if (err_code != NRF_SUCCESS && p_ots_oacp->p_ots->error_handler != NULL) + { + p_ots_oacp->p_ots->error_handler(err_code); + } + } + else + { + NRF_LOG_DEBUG("OACD indications not enabled."); + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR; + + err_code = sd_ble_gatts_rw_authorize_reply(p_ots_oacp->p_ots->conn_handle, &auth_reply); + + if (err_code != NRF_SUCCESS && p_ots_oacp->p_ots->error_handler != NULL) + { + p_ots_oacp->p_ots->error_handler(err_code); + } + return; + } + memset(&oacp_proc, 0, sizeof(oacp_proc)); oacp_status = decode_oacp_command(p_ble_evt_write, &oacp_proc); @@ -502,9 +564,29 @@ static void on_write(ble_ots_oacp_t * p_ots_oacp, ble_evt_t const * p_ble_evt) { on_cccd_write(p_ots_oacp, p_evt_write); } - if (p_evt_write->handle == p_ots_oacp->p_ots->oacp_chars.oacp_handles.value_handle) +} + + +static void on_rw_authorize_request(ble_ots_oacp_t * p_ots_oacp, ble_gatts_evt_t const * p_gatts_evt) +{ + ble_gatts_evt_rw_authorize_request_t const * p_auth_req = + &p_gatts_evt->params.authorize_request; + + if (p_auth_req->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) { - on_oacp_write(p_ots_oacp, p_evt_write); + if ( (p_gatts_evt->params.authorize_request.request.write.op + != BLE_GATTS_OP_PREP_WRITE_REQ) + && (p_gatts_evt->params.authorize_request.request.write.op + != BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) + && (p_gatts_evt->params.authorize_request.request.write.op + != BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL) + ) + { + if (p_auth_req->request.write.handle == p_ots_oacp->p_ots->oacp_chars.oacp_handles.value_handle) + { + on_oacp_write(p_ots_oacp, &p_auth_req->request.write); + } + } } } @@ -528,6 +610,9 @@ void ble_ots_oacp_on_ble_evt(ble_ots_oacp_t * p_ots_oacp, ble_evt_t const * p_bl case BLE_GATTS_EVT_WRITE: on_write(p_ots_oacp, p_ble_evt); break; + case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: + on_rw_authorize_request(p_ots_oacp, &p_ble_evt->evt.gatts_evt); + break; default: // No implementation needed. break; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h index 2479c81..b276bce 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_oacp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -53,6 +53,7 @@ #include #include "ble_ots.h" +#include "nrf_ble_gq.h" /**@brief Function for initializing the Object Transfer OACP characteristic. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c index a5da953..56eea90 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_object.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_ots_object.h" @@ -55,7 +55,7 @@ uint32_t ble_ots_object_refresh_current(ble_ots_object_chars_t * p_ots_object_chars) { uint32_t err_code; - ble_ots_object_t * p_obj; + ble_ots_object_t * p_obj; p_obj = p_ots_object_chars->p_ots->p_current_object; @@ -261,9 +261,6 @@ static uint32_t obj_prop_char_add(ble_ots_object_chars_t * const p_ots_object_ } - - - uint32_t ble_ots_object_representation_init(ble_ots_object_chars_t * p_ots_object_chars, ble_ots_object_chars_init_t * p_ots_object_chars_init) { @@ -446,7 +443,6 @@ uint32_t ble_ots_object_set_current_size(ble_ots_object_chars_t * p_ots_object_c static uint32_t on_obj_properties_write(ble_ots_object_chars_t * p_ots_object_chars, ble_evt_t const * p_ble_evt) { -// uint32_t err_code; ble_gatts_rw_authorize_reply_params_t write_authorize_reply; ble_gatts_evt_write_t const * p_write_evt; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h index ed37227..5a0159e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_ble_ots/ble_ots_object.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c index 69e27fa..e19d611 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -47,6 +47,7 @@ #define NRF_LOG_MODULE_NAME nrf_ble_gatts_c #include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #define GATTS_LOG NRF_LOG_DEBUG /**< A debug logger macro that can be used in this file to perform logging over UART. */ @@ -55,10 +56,32 @@ static const ble_uuid_t m_gatts_uuid = {BLE_UUID_GATT, BLE_UUID_TYPE_BLE}; /**< Service Changed indication UUID. */ +/**@brief Function for intercepting the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + nrf_ble_gatts_c_t * p_gattc = (nrf_ble_gatts_c_t *)p_ctx; + + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); + + if (p_gattc->err_handler != NULL) + { + p_gattc->err_handler(nrf_error); + } +} + + + /**@brief Function for handling the indication and notifications from the GATT Service Server. - @param[in] p_gatts_c Pointer to Service Changed client structure. - @param[in] p_ble_gattc_evt Pointer to a gattc event. + @param[in] p_gatts_c Pointer to Service Changed Client structure. + @param[in] p_ble_gattc_evt Pointer to a GATTC event. */ static void on_hvx(nrf_ble_gatts_c_t const * const p_gatts_c, ble_gattc_evt_t const * const p_ble_gattc_evt) @@ -87,7 +110,7 @@ static void on_hvx(nrf_ble_gatts_c_t const * const p_gatts_c, evt.evt_type = NRF_BLE_GATTS_C_EVT_SRV_CHANGED; evt.conn_handle = p_ble_gattc_evt->conn_handle; - GATTS_LOG ("Service Changed Indication.\n\r"); + GATTS_LOG ("Service Changed indication.\n\r"); evt_handler(&evt); } @@ -101,10 +124,13 @@ ret_code_t nrf_ble_gatts_c_init(nrf_ble_gatts_c_t * p_gatts_c, VERIFY_PARAM_NOT_NULL(p_gatts_c); VERIFY_PARAM_NOT_NULL(p_gatts_c_init); VERIFY_PARAM_NOT_NULL(p_gatts_c_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_gatts_c_init->p_gatt_queue); + memset (p_gatts_c, 0, sizeof(nrf_ble_gatts_c_t)); - p_gatts_c->conn_handle = BLE_CONN_HANDLE_INVALID; - p_gatts_c->evt_handler = p_gatts_c_init->evt_handler; + p_gatts_c->conn_handle = BLE_CONN_HANDLE_INVALID; + p_gatts_c->evt_handler = p_gatts_c_init->evt_handler; + p_gatts_c->p_gatt_queue = p_gatts_c_init->p_gatt_queue; err_code = ble_db_discovery_evt_register(&m_gatts_uuid); VERIFY_SUCCESS(err_code); @@ -115,12 +141,12 @@ ret_code_t nrf_ble_gatts_c_init(nrf_ble_gatts_c_t * p_gatts_c, /**@brief Function for checking whether the peer's GATT Service instance and the Service Changed - Characteristic have been discovered. + characteristic have been discovered. - @param[in] p_gatts_c Pointer to the GATT Service client structure instance. + @param[in] p_gatts_c Pointer to the GATT Service Client structure instance. - @return True if the Service Changed Characteristic handle is valid. - @return False if the Service Changed Characteristic handle is invalid. + @return True if the Service Changed characteristic handle is valid. + @return False if the Service Changed characteristic handle is invalid. */ static bool gatts_gatt_handles_are_valid(nrf_ble_gatts_c_t const * const p_gatts_c) { @@ -129,7 +155,7 @@ static bool gatts_gatt_handles_are_valid(nrf_ble_gatts_c_t const * const p_gatts ret_code_t nrf_ble_gatts_c_enable_indication(nrf_ble_gatts_c_t * const p_gatts_c, - bool const enable) + bool const indication_enable) { VERIFY_MODULE_INITIALIZED(); @@ -139,20 +165,25 @@ ret_code_t nrf_ble_gatts_c_enable_indication(nrf_ble_gatts_c_t * const p_gatts_c return NRF_ERROR_INVALID_STATE; } - ret_code_t err_code = NRF_SUCCESS; - uint16_t cccd_val = (enable) ? BLE_GATT_HVX_INDICATION : 0; + uint16_t cccd_val = (indication_enable) ? BLE_GATT_HVX_INDICATION : 0; + uint8_t cccd[BLE_CCCD_VALUE_LEN]; + nrf_ble_gq_req_t cccd_req; - ble_gattc_write_params_t gattc_params = - { - .handle = p_gatts_c->srv_changed_char.cccd_handle, - .len = BLE_CCCD_VALUE_LEN, - .p_value = (uint8_t *)&cccd_val, - .offset = 0, - .write_op = BLE_GATT_OP_WRITE_REQ, - }; - - err_code = sd_ble_gattc_write(p_gatts_c->conn_handle, &gattc_params); - return err_code; + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); + + memset(&cccd_req, 0, sizeof(nrf_ble_gq_req_t)); + + cccd_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + cccd_req.error_handler.cb = gatt_error_handler; + cccd_req.error_handler.p_ctx = p_gatts_c; + cccd_req.params.gattc_write.handle = p_gatts_c->srv_changed_char.cccd_handle; + cccd_req.params.gattc_write.len = BLE_CCCD_VALUE_LEN; + cccd_req.params.gattc_write.offset = 0; + cccd_req.params.gattc_write.p_value = cccd; + cccd_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_gatts_c->p_gatt_queue, &cccd_req, p_gatts_c->conn_handle); } @@ -164,28 +195,38 @@ void nrf_ble_gatts_c_on_db_disc_evt(nrf_ble_gatts_c_t const * const p_gatts_c, nrf_ble_gatts_c_evt_t evt; ble_gatt_db_char_t * p_chars; - p_chars = p_evt->params.discovered_db.charateristics; - evt.evt_type = NRF_BLE_GATTS_C_EVT_DISCOVERY_FAILED; + p_chars = p_evt->params.discovered_db.charateristics; if ( (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE) && (p_evt->params.discovered_db.srv_uuid.uuid == BLE_UUID_GATT) && (p_evt->params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE)) { - // Find the handles of the Service Changed Characteristics. + // Find the handles of the Service Changed characteristics. for (uint32_t i = 0; i < p_evt->params.discovered_db.char_count; i++) { if ( (p_chars[i].characteristic.uuid.uuid == BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED) && (p_chars[i].characteristic.char_props.indicate != 0)) { - memcpy(&evt.params.service, - &p_evt->params.discovered_db, - sizeof(ble_gatt_db_srv_t)); - evt.evt_type = NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE; - GATTS_LOG("Service Changed Characteristic found.\n\r"); + memcpy(&evt.params.srv_changed_char, + &p_chars[i], + sizeof(ble_gatt_db_char_t)); + + evt.evt_type = NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE; + GATTS_LOG("Service Changed characteristic found.\n\r"); break; } } } + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) + { + evt.evt_type = NRF_BLE_GATTS_C_EVT_DISCOVERY_FAILED; + } + else + { + return; + } + if (p_gatts_c->evt_handler != NULL) { @@ -198,7 +239,7 @@ void nrf_ble_gatts_c_on_db_disc_evt(nrf_ble_gatts_c_t const * const p_gatts_c, /**@brief Function for handling the Disconnect event. - @param[in] p_cts Pointer to the GATT Service client structure instance. + @param[in] p_cts Pointer to the GATT Service Client structure instance. @param[in] p_ble_evt Event received from the BLE stack. */ static void on_disconnect(nrf_ble_gatts_c_t * p_gatts_c, ble_evt_t const * p_ble_evt) @@ -210,7 +251,7 @@ static void on_disconnect(nrf_ble_gatts_c_t * p_gatts_c, ble_evt_t const * p_ble if (gatts_gatt_handles_are_valid(p_gatts_c)) { // There was a valid instance of GATTS on the peer. Send an event to the - // application, so that it can do any clean up related to this module. + // application, so that it can do a cleanup related to this module. nrf_ble_gatts_c_evt_t evt; evt.evt_type = NRF_BLE_GATTS_C_EVT_DISCONN_COMPLETE; @@ -269,6 +310,7 @@ ret_code_t nrf_ble_gatts_c_handles_assign(nrf_ble_gatts_c_t * const p_gat p_gatts_c->srv_changed_char.characteristic.handle_value = p_peer_handles->characteristic.handle_value; } - return NRF_SUCCESS; + + return nrf_ble_gq_conn_handle_register(p_gatts_c->p_gatt_queue, conn_handle); } #endif // NRF_MODULE_ENABLED(BLE_GATTS_C) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h similarity index 62% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h index 9d97cd3..d840124 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_gatts_c/nrf_ble_gatts_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -46,9 +46,9 @@ * @brief GATT Service Client module. * * @details This module implements a client for the Generic Attribute Profile (GATT) Service. - * It subscribes to indications from the Service Changed Characteristic (0x2A05). + * It subscribes to indications from the Service Changed characteristic (0x2A05). * - * @note The application must register this module as a BLE event observer using the + * @note The application must register this module as a BLE event observer with the * NRF_SDH_BLE_OBSERVER macro. Example: * @code * ble_gatts_t instance; @@ -67,6 +67,7 @@ #include "nrf_error.h" #include "ble_srv_common.h" #include "ble_db_discovery.h" +#include "nrf_ble_gq.h" #include "sdk_errors.h" #ifdef __cplusplus @@ -84,13 +85,24 @@ NRF_SDH_BLE_OBSERVER(_name ## _obs, NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO, \ nrf_ble_gatts_c_on_ble_evt, &_name) +/** @brief Macro for defining multiple nrf_ble_gatts_c instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define NRF_BLE_GATTS_C_ARRAY_DEF(_name, _cnt) \ +static nrf_ble_gatts_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO, \ + nrf_ble_gatts_c_on_ble_evt, &_name, _cnt) /**@brief Type of the GATT Service client event. */ typedef enum { - NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the GATT Service and Service Changed Characteristic have been found on the peer. */ + NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE, /**< Event indicating that the GATT Service and Service Changed characteristic have been found on the peer. */ NRF_BLE_GATTS_C_EVT_DISCOVERY_FAILED, /**< Event indicating that the Service Changed characteristic has not been found on the peer. */ - NRF_BLE_GATTS_C_EVT_DISCONN_COMPLETE, /**< Event indicating that the GATT Service client module has finished processing the BLE_GAP_EVT_DISCONNECTED event. The event can be used by the application to do cleanup related to the GATT Service client.*/ + NRF_BLE_GATTS_C_EVT_DISCONN_COMPLETE, /**< Event indicating that the GATT Service client module finished processing the BLE_GAP_EVT_DISCONNECTED event. The application can use this event to do a cleanup related to the GATT Service client.*/ NRF_BLE_GATTS_C_EVT_SRV_CHANGED, /**< Event indicating that a Service Changed indication has been received. */ } nrf_ble_gatts_c_evt_type_t; @@ -98,12 +110,12 @@ typedef enum */ typedef struct { - nrf_ble_gatts_c_evt_type_t evt_type; /**< Type of event. See @ref nrf_ble_gatts_c_evt_type_t. */ - uint16_t conn_handle; /**< Handle of the connection for which this event has occurred. */ + nrf_ble_gatts_c_evt_type_t evt_type; /**< Type of event. See @ref nrf_ble_gatts_c_evt_type_t. */ + uint16_t conn_handle; /**< Handle of the connection for which this event occurred. */ union { - ble_gatt_db_srv_t service; /**< Handles that the GATT service occupies in the peer device. Will be filled if the event type is @ref NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE.*/ - ble_gattc_handle_range_t handle_range; /**< The affected attribute handle range where the service has changed. Will be provided if the event type is @ref NRF_BLE_GATTS_C_EVT_SRV_CHANGED.*/ + ble_gatt_db_char_t srv_changed_char; /**< Handles for the Service Changed characteristic. This is filled if the event type is @ref NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE. */ + ble_gattc_handle_range_t handle_range; /**< The affected attribute handle range in which the service has changed. This will be provided if the event type is @ref NRF_BLE_GATTS_C_EVT_SRV_CHANGED.*/ } params; } nrf_ble_gatts_c_evt_t; @@ -112,38 +124,40 @@ typedef void (* nrf_ble_gatts_c_evt_handler_t)(nrf_ble_gatts_c_evt_t * p_evt); /**@brief Structure for holding the information related to the Service Changed indication at the server. * - * @details A GATT Server will never have more than one instance of the Service Changed Characteristic. - * Therefore, you never need more than one instance of the GATT Service client structure. + * @details A GATT Server never has more than one instance of the Service Changed characteristic. + * For this reason, you never need more than one instance of the GATT Service Client structure. * * @warning This structure must be zero-initialized. */ typedef struct { - bool initialized; /**< Boolean indicating whether the context has been initialized or not. */ - bool char_found; /**< Boolean indicating whether the Service Changed indication has been found.*/ - ble_gatt_db_char_t srv_changed_char; /**< Information of the Service Changed characteristics. */ - uint16_t conn_handle; /**< Active connection handle. */ - nrf_ble_gatts_c_evt_handler_t evt_handler; /**< Pointer to event handler function. */ - ble_srv_error_handler_t err_handler; /**< Pointer to error handler function. */ + bool initialized; /**< Boolean indicating whether the context has been initialized. */ + bool char_found; /**< Boolean indicating whether the Service Changed indication has been found.*/ + ble_gatt_db_char_t srv_changed_char; /**< Information of the Service Changed characteristics. */ + uint16_t conn_handle; /**< Active connection handle. */ + nrf_ble_gatts_c_evt_handler_t evt_handler; /**< Pointer to event handler function. */ + ble_srv_error_handler_t err_handler; /**< Pointer to error handler function. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } nrf_ble_gatts_c_t; /**@brief Initialization parameters. These must be supplied when calling @ref nrf_ble_gatts_c_init. */ typedef struct { - nrf_ble_gatts_c_evt_handler_t evt_handler; /**< Event handler that is called by the Service Changed client module when any related event occurs. */ - ble_srv_error_handler_t err_handler; /**< Error handler that is called by the Service Changed client module if any error occurs. */ + nrf_ble_gatts_c_evt_handler_t evt_handler; /**< Event handler that is called by the Service Changed Client module when any related event occurs. */ + ble_srv_error_handler_t err_handler; /**< Error handler that is called by the Service Changed Client module if any error occurs. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } nrf_ble_gatts_c_init_t; /**@brief Function for initializing the Service Changed client module. * - * @param[in,out] p_gatts_c Pointer to the GATT Service client structure instance. + * @param[in,out] p_gatts_c Pointer to the GATT Service Client structure instance. * @param[in] p_gatts_c_init Init parameters containing the event handler that is called by - * the Service Changed client module when any related event occurs. + * the Service Changed Client module when any related event occurs. * * @retval NRF_SUCCESS If the service was initialized successfully. * @retval NRF_ERROR_NULL If any of the input parameters are NULL. - * @return If functions from other modules return errors to this function, + * @retval err_code If functions from other modules return errors to this function, * the @ref nrf_error are propagated. */ ret_code_t nrf_ble_gatts_c_init(nrf_ble_gatts_c_t * p_gatts_c, @@ -152,26 +166,26 @@ ret_code_t nrf_ble_gatts_c_init(nrf_ble_gatts_c_t * p_gatts_c, /**@brief Function for enabling remote indication. * - * @param[in,out] p_gatts_c Pointer to the Service Changed client structure. - * @param[in] enable True to enable Service Changed remote indication, false to disable. + * @param[in,out] p_gatts_c Pointer to the Service Changed Client structure. + * @param[in] enable True to enable Service Changed remote indication; false to disable. * * @retval NRF_SUCCESS Operation success. - * @return If functions from other modules return errors to this function, - * the @ref nrf_error are propagated. + * @retval err_code Otherwise, this API propagates the error code + * returned by function @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ble_gatts_c_enable_indication(nrf_ble_gatts_c_t * p_gatts_c, bool enable); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. * - * @details This function handles an event from the database discovery module, and determine - * if it relates to the discovery of Service Changed characteristics at the peer. If so, - * it will call the application's event handler indicating that Service Changed + * @details This function handles an event from the Database Discovery module, and determines + * whether it relates to the discovery of Service Changed characteristics at the peer. If it does, + * the function calls the application's event handler to indicate that the Service Changed * characteristic has been discovered at the peer. * - * @param[in,out] p_gatts_c Pointer to the GATT Service client structure instance. - * @param[in] p_evt Pointer to the event received from the database discovery module. + * @param[in,out] p_gatts_c Pointer to the GATT Service Client structure instance. + * @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void nrf_ble_gatts_c_on_db_disc_evt(nrf_ble_gatts_c_t const * p_gatts_c, ble_db_discovery_evt_t * p_evt); @@ -186,24 +200,26 @@ void nrf_ble_gatts_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); -/**@brief Function for assigning handles to a GATT Service client instance. +/**@brief Function for assigning handles to a GATT Service Client instance. * * @details Call this function when a link has been established with a peer to - * associate this link to an instance of the module. This makes it + * associate the link to an instance of the module. This makes it * possible to handle several links and associate each link with a particular - * instance of the GATT Service client module. The connection handle and attribute + * instance of the GATT Service Client module. The connection handle and attribute * handles will be provided from the discovery event * @ref NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE. * - * @param[in,out] p_gatts_c Pointer to the GATT Service client structure instance to - * associate with the handles. + * @param[in,out] p_gatts_c Pointer to the GATT Service Client structure instance for + * associating the link. * @param[in] conn_handle Connection handle to be associated with the given - * GATT Service client Instance. + * GATT Service Client instance. * @param[in] p_peer_handles Attribute handles on the GATT Service server that you want this - * GATT Service client to interact with. + * GATT Service Client to interact with. * * @retval NRF_SUCCESS If the connection handle was successfully stored in the GATT Service instance. * @retval NRF_ERROR_NULL If any of the input parameters are NULL. + * @retval err_code Otherwise, this API propagates the error code returned by function + * @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ble_gatts_c_handles_assign(nrf_ble_gatts_c_t * p_gatts_c, uint16_t conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c index 2ae2fb6..0fcf6a2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include @@ -76,11 +76,10 @@ uint16_t cgms_db_num_records_get(void) ret_code_t cgms_db_record_get(uint8_t record_num, ble_cgms_rec_t * p_rec) { - if (record_num >= m_num_records) + if ((record_num >= m_num_records) || (m_num_records == 0)) { return NRF_ERROR_NOT_FOUND; } - // copy record to the specified memory *p_rec = m_database[m_database_crossref[record_num]].record; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h index ebd1c66..4fad58f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_db.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c index b13871d..7fc805b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include @@ -191,8 +191,7 @@ ret_code_t cgms_meas_send(nrf_ble_cgms_t * p_cgms, ble_cgms_rec_t * p_rec, uint8 else { // Measurement successfully sent - p_cgms->racp_data.racp_proc_records_reported++; - p_cgms->racp_data.racp_proc_records_reported_since_txcomplete++; + p_cgms->racp_data.racp_proc_records_reported += *p_count; } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h index 7b57f86..3d03fd2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_meas.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c index ba4a721..fd7007b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include @@ -43,11 +43,14 @@ #include "ble_srv_common.h" #include "cgms_racp.h" #include "cgms_db.h" +#include "nrf_ble_gq.h" #include "cgms_meas.h" -#define OPERAND_FILTER_TYPE_RESV 0x00 // !< Filter type value reserved for future use. -#define OPERAND_FILTER_TYPE_SEQ_NUM 0x01 // !< Filter data using Sequence Number criteria. -#define OPERAND_FILTER_TYPE_FACING_TIME 0x02 // !< Filter data using User Facing Time criteria. +#define OPERAND_LESS_GREATER_FILTER_TYPE_SIZE 1 // !< 1 byte. +#define OPERAND_LESS_GREATER_FILTER_PARAM_SIZE 2 // !< 2 bytes. +#define OPERAND_LESS_GREATER_SIZE OPERAND_LESS_GREATER_FILTER_TYPE_SIZE \ + + OPERAND_LESS_GREATER_FILTER_PARAM_SIZE // !< Total size of the operand. + /**@brief Function for adding a characteristic for the Record Access Control Point. * @@ -85,69 +88,33 @@ ret_code_t cgms_racp_char_add(nrf_ble_cgms_t * p_cgms) */ static void racp_send(nrf_ble_cgms_t * p_cgms, ble_racp_value_t * p_racp_val) { - uint32_t err_code; - uint8_t encoded_resp[25]; - uint8_t len; - uint16_t hvx_len; - ble_gatts_hvx_params_t hvx_params; + uint32_t err_code; + uint8_t encoded_resp[25]; + uint16_t len; + nrf_ble_gq_req_t cgms_req; - if ( - (p_cgms->cgms_com_state != STATE_RACP_RESPONSE_PENDING) - && - (p_cgms->racp_data.racp_proc_records_reported_since_txcomplete > 0) - ) - { - p_cgms->cgms_com_state = STATE_RACP_RESPONSE_PENDING; - return; - } + memset(&cgms_req, 0, sizeof(nrf_ble_gq_req_t)); // Send indication - len = ble_racp_encode(p_racp_val, encoded_resp); - hvx_len = len; - - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_cgms->char_handles.racp.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = encoded_resp; - - err_code = sd_ble_gatts_hvx(p_cgms->conn_handle, &hvx_params); - - // Error handling - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } - - switch (err_code) + len = ble_racp_encode(p_racp_val, encoded_resp); + + cgms_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + cgms_req.error_handler.cb = p_cgms->gatt_err_handler; + cgms_req.error_handler.p_ctx = p_cgms; + cgms_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; + cgms_req.params.gatts_hvx.handle = p_cgms->char_handles.racp.value_handle; + cgms_req.params.gatts_hvx.offset = 0; + cgms_req.params.gatts_hvx.p_data = encoded_resp; + cgms_req.params.gatts_hvx.p_len = &len; + + err_code = nrf_ble_gq_item_add(p_cgms->p_gatt_queue, &cgms_req, p_cgms->conn_handle); + + // Report error to application + if ((p_cgms->error_handler != NULL) && + (err_code != NRF_SUCCESS) && + (err_code != NRF_ERROR_INVALID_STATE)) { - case NRF_SUCCESS: - // Wait for HVC event. - p_cgms->cgms_com_state = STATE_RACP_RESPONSE_IND_VERIF; - break; - - case NRF_ERROR_RESOURCES: - // Wait for TX_COMPLETE event to retry transmission. - p_cgms->cgms_com_state = STATE_RACP_RESPONSE_PENDING; - break; - - case NRF_ERROR_INVALID_STATE: - // Make sure state machine returns to the default state. - p_cgms->cgms_com_state = STATE_NO_COMM; - break; - - default: - // Report error to application. - if (p_cgms->error_handler != NULL) - { - p_cgms->error_handler(err_code); - } - - // Make sure state machine returns to the default state. - p_cgms->cgms_com_state = STATE_NO_COMM; - break; + p_cgms->error_handler(err_code); } } @@ -188,7 +155,7 @@ static uint32_t racp_report_records_all(nrf_ble_cgms_t * p_cgms) if (p_cgms->racp_data.racp_proc_record_ndx >= total_records) { - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; } else { @@ -239,7 +206,7 @@ static uint32_t racp_report_records_first_last(nrf_ble_cgms_t * p_cgms) if ((p_cgms->racp_data.racp_proc_records_reported != 0) || (total_records == 0)) { - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; } else { @@ -280,39 +247,20 @@ static uint32_t racp_report_records_first_last(nrf_ble_cgms_t * p_cgms) */ static ret_code_t racp_report_records_less_equal(nrf_ble_cgms_t * p_cgms) { - uint16_t total_rec_nb; uint16_t total_rec_nb_to_send; uint16_t rec_nb_left_to_send; - uint8_t nb_rec_to_send; - uint16_t offset; + uint8_t nb_rec_to_send; uint16_t i; - if (p_cgms->racp_data.racp_request.operand_len != 2) - { - if (p_cgms->error_handler != NULL) - { - p_cgms->error_handler(NRF_ERROR_INVALID_LENGTH); - } - } - - total_rec_nb = cgms_db_num_records_get(); - - offset = uint16_decode(p_cgms->racp_data.racp_request.p_operand); - if (offset >= total_rec_nb) - { - p_cgms->cgms_com_state = STATE_NO_COMM; - return NRF_SUCCESS; - } - - total_rec_nb_to_send = offset; + total_rec_nb_to_send = p_cgms->racp_data.racp_proc_records_ndx_last_to_send +1; if (p_cgms->racp_data.racp_proc_record_ndx >= total_rec_nb_to_send) { - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; } else { - uint32_t err_code; + ret_code_t err_code; ble_cgms_rec_t rec[NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX]; rec_nb_left_to_send = total_rec_nb_to_send - p_cgms->racp_data.racp_proc_records_reported; @@ -326,8 +274,6 @@ static ret_code_t racp_report_records_less_equal(nrf_ble_cgms_t * p_cgms) nb_rec_to_send = (uint8_t)rec_nb_left_to_send; } - p_cgms->racp_data.racp_proc_record_ndx = 0; - for (i = 0; i < nb_rec_to_send; i++) { err_code = cgms_db_record_get(p_cgms->racp_data.racp_proc_record_ndx + i, &(rec[i])); @@ -356,73 +302,52 @@ static ret_code_t racp_report_records_less_equal(nrf_ble_cgms_t * p_cgms) */ static ret_code_t racp_report_records_greater_equal(nrf_ble_cgms_t * p_cgms) { - uint16_t total_rec_nb; - uint16_t total_rec_nb_to_send; - uint16_t rec_nb_left_to_send; - uint8_t nb_rec_to_send; - uint16_t offset; - uint16_t i; - - if (p_cgms->racp_data.racp_request.operand_len != 2) - { - if (p_cgms->error_handler != NULL) - { - p_cgms->error_handler(NRF_ERROR_INVALID_LENGTH); - } - } + ret_code_t err_code; + uint16_t total_rec_nb = cgms_db_num_records_get(); + uint16_t rec_nb_left_to_send; + uint8_t nb_rec_to_send; + uint16_t i; - total_rec_nb = cgms_db_num_records_get(); - offset = uint16_decode(p_cgms->racp_data.racp_request.p_operand); - if (offset >= total_rec_nb) + total_rec_nb = cgms_db_num_records_get(); + if (p_cgms->racp_data.racp_proc_record_ndx >= total_rec_nb) { - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; + return NRF_SUCCESS; } - total_rec_nb_to_send = total_rec_nb - offset; + ble_cgms_rec_t rec[NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX]; - if (p_cgms->racp_data.racp_proc_record_ndx >= total_rec_nb_to_send) + rec_nb_left_to_send = total_rec_nb - p_cgms->racp_data.racp_proc_record_ndx; + if (rec_nb_left_to_send > NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX) { - p_cgms->cgms_com_state = STATE_NO_COMM; + nb_rec_to_send = NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX; } else { - uint32_t err_code; - ble_cgms_rec_t rec[NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX]; - - rec_nb_left_to_send = total_rec_nb_to_send - p_cgms->racp_data.racp_proc_records_reported; - - if (rec_nb_left_to_send > NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX) - { - nb_rec_to_send = NRF_BLE_CGMS_MEAS_REC_PER_NOTIF_MAX; - } - else - { - nb_rec_to_send = (uint8_t)rec_nb_left_to_send; - } - - p_cgms->racp_data.racp_proc_record_ndx = offset; + nb_rec_to_send = (uint8_t)rec_nb_left_to_send; + } - for (i = 0; i < nb_rec_to_send; i++) - { - err_code = cgms_db_record_get(p_cgms->racp_data.racp_proc_record_ndx + i, &(rec[i])); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - } - err_code = cgms_meas_send(p_cgms, rec, &nb_rec_to_send); + for (i = 0; i < nb_rec_to_send; i++) + { + err_code = cgms_db_record_get(p_cgms->racp_data.racp_proc_record_ndx + i, &(rec[i])); if (err_code != NRF_SUCCESS) { return err_code; } - p_cgms->racp_data.racp_proc_record_ndx += nb_rec_to_send; } + err_code = cgms_meas_send(p_cgms, rec, &nb_rec_to_send); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + p_cgms->racp_data.racp_proc_record_ndx += nb_rec_to_send; return NRF_SUCCESS; } + /**@brief Function for informing that the REPORT RECORDS procedure is completed. * * @param[in] p_cgms Service instance. @@ -450,9 +375,9 @@ static void racp_report_records_completed(nrf_ble_cgms_t * p_cgms) */ static void racp_report_records_procedure(nrf_ble_cgms_t * p_cgms) { - uint32_t err_code; + ret_code_t err_code = NRF_SUCCESS; - while (p_cgms->cgms_com_state == STATE_RACP_PROC_ACTIVE) + while (p_cgms->racp_data.racp_procesing_active) { // Execute requested procedure switch (p_cgms->racp_data.racp_proc_operator) @@ -462,6 +387,7 @@ static void racp_report_records_procedure(nrf_ble_cgms_t * p_cgms) break; case RACP_OPERATOR_FIRST: + // Fall through. case RACP_OPERATOR_LAST: err_code = racp_report_records_first_last(p_cgms); break; @@ -478,9 +404,8 @@ static void racp_report_records_procedure(nrf_ble_cgms_t * p_cgms) p_cgms->error_handler(NRF_ERROR_INTERNAL); } - // Make sure state machine returns to the default state - // state_set(STATE_NO_COMM); - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; + return; } @@ -488,7 +413,7 @@ static void racp_report_records_procedure(nrf_ble_cgms_t * p_cgms) switch (err_code) { case NRF_SUCCESS: - if (p_cgms->cgms_com_state != STATE_RACP_PROC_ACTIVE) + if (!p_cgms->racp_data.racp_procesing_active) { racp_report_records_completed(p_cgms); } @@ -500,7 +425,7 @@ static void racp_report_records_procedure(nrf_ble_cgms_t * p_cgms) case NRF_ERROR_INVALID_STATE: // Notification is probably not enabled. Ignore request. - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false;; return; default: @@ -511,7 +436,7 @@ static void racp_report_records_procedure(nrf_ble_cgms_t * p_cgms) } // Make sure state machine returns to the default state. - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; return; } } @@ -537,7 +462,7 @@ static bool is_request_to_be_executed(nrf_ble_cgms_t * p_cgms, if (p_racp_request->opcode == RACP_OPCODE_ABORT_OPERATION) { - if (p_cgms->cgms_com_state == STATE_RACP_PROC_ACTIVE) + if (p_cgms->racp_data.racp_procesing_active) { if (p_racp_request->operator != RACP_OPERATOR_NULL) { @@ -557,19 +482,21 @@ static bool is_request_to_be_executed(nrf_ble_cgms_t * p_cgms, *p_response_code = RACP_RESPONSE_ABORT_FAILED; } } - else if (p_cgms->cgms_com_state != STATE_NO_COMM) + else if (p_cgms->racp_data.racp_procesing_active) { return false; } - // supported opcodes + // Supported opcodes else if ((p_racp_request->opcode == RACP_OPCODE_REPORT_RECS) || (p_racp_request->opcode == RACP_OPCODE_REPORT_NUM_RECS)) { switch (p_racp_request->operator) { - // operators WITHOUT a filter + // Operators without a filter. case RACP_OPERATOR_ALL: + // Fall through. case RACP_OPERATOR_FIRST: + // Fall through. case RACP_OPERATOR_LAST: if (p_racp_request->operand_len != 0) { @@ -577,43 +504,118 @@ static bool is_request_to_be_executed(nrf_ble_cgms_t * p_cgms, } break; - // operators WITH a filter + // Operators with a filter as part of the operand. + case RACP_OPERATOR_LESS_OR_EQUAL: + // Fall Through. case RACP_OPERATOR_GREATER_OR_EQUAL: - //*p_response_code = RACP_RESPONSE_OPERATOR_UNSUPPORTED; + if (*(p_racp_request->p_operand) == RACP_OPERAND_FILTER_TYPE_FACING_TIME) + { + *p_response_code = RACP_RESPONSE_PROCEDURE_NOT_DONE; + } + if (p_racp_request->operand_len != OPERAND_LESS_GREATER_SIZE) + { + *p_response_code = RACP_RESPONSE_INVALID_OPERAND; + } break; - // unsupported operators - case RACP_OPERATOR_LESS_OR_EQUAL: - break; case RACP_OPERATOR_RANGE: *p_response_code = RACP_RESPONSE_OPERATOR_UNSUPPORTED; break; - // invalid operators + // Invalid operators. case RACP_OPERATOR_NULL: + // Fall through. default: *p_response_code = RACP_RESPONSE_INVALID_OPERATOR; break; } } - // unsupported opcodes + // Unsupported opcodes. else if (p_racp_request->opcode == RACP_OPCODE_DELETE_RECS) { *p_response_code = RACP_RESPONSE_OPCODE_UNSUPPORTED; } - // unknown opcodes + // Unknown opcodes. else { *p_response_code = RACP_RESPONSE_OPCODE_UNSUPPORTED; } - // NOTE: The computation of the return value will change slightly when deferred write has been - // implemented in the stack. return (*p_response_code == RACP_RESPONSE_RESERVED); } + + +/**@brief Function for getting a record with time offset less or equal to the input param. + * + * @param[in] offset The record that this function returns must have an time offset less or greater to this. + * @param[out] record_num Pointer to the record index of the record that has the desired time offset. + * + * @retval NRF_SUCCESS If the record was successfully retrieved. + * @retval NRF_ERROR_NOT_FOUND A record with the desired offset does not exist in the database. + * @return If functions from other modules return errors to this function, + * the @ref nrf_error are propagated. + */ +static ret_code_t record_index_offset_less_or_equal_get(uint16_t offset, uint16_t * record_num) +{ + ret_code_t err_code; + ble_cgms_rec_t rec; + uint16_t upper_bound = cgms_db_num_records_get(); + + for((*record_num) = upper_bound; (*record_num)-- >0;) + { + err_code = cgms_db_record_get(*record_num, &rec); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + if (rec.meas.time_offset <= offset) + { + return NRF_SUCCESS; + } + } + return NRF_ERROR_NOT_FOUND; +} + + + +/**@brief Function for getting a record with time offset greater or equal to the input param. + * + * @param[in] offset The record that this function returns must have an time offset equal or + * greater to this. + * @param[out] record_num Pointer to the record index of the record that has the desired time offset. + * + * @retval NRF_SUCCESS If the record was successfully retrieved. + * @retval NRF_ERROR_NOT_FOUND A record with the desired offset does not exist in the database. + * @return If functions from other modules return errors to this function, + * the @ref nrf_error are propagated. + */ +static ret_code_t record_index_offset_greater_or_equal_get(uint16_t offset, uint16_t * record_num) +{ + ret_code_t err_code; + ble_cgms_rec_t rec; + uint16_t upper_bound = cgms_db_num_records_get(); + + for(*record_num = 0; *record_num < upper_bound; (*record_num)++) + { + err_code = cgms_db_record_get(*record_num, &rec); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + if (rec.meas.time_offset >= offset) + { + return NRF_SUCCESS; + } + } + return NRF_ERROR_NOT_FOUND; +} + + /**@brief Function for processing a REPORT RECORDS request. + * + * @details Set initial values before entering the state machine of racp_report_records_procedure(). * * @param[in] p_cgms Service instance. * @param[in] p_racp_request Request to be executed. @@ -621,12 +623,33 @@ static bool is_request_to_be_executed(nrf_ble_cgms_t * p_cgms, static void report_records_request_execute(nrf_ble_cgms_t * p_cgms, ble_racp_value_t * p_racp_request) { - p_cgms->cgms_com_state = STATE_RACP_PROC_ACTIVE; + p_cgms->racp_data.racp_procesing_active = true; + + p_cgms->racp_data.racp_proc_record_ndx = 0; + p_cgms->racp_data.racp_proc_operator = p_racp_request->operator; + p_cgms->racp_data.racp_proc_records_reported = 0; + p_cgms->racp_data.racp_proc_records_ndx_last_to_send = 0; + + if (p_cgms->racp_data.racp_proc_operator == RACP_OPERATOR_GREATER_OR_EQUAL) + { + uint16_t offset_requested = uint16_decode(&p_cgms->racp_data.racp_request.p_operand[OPERAND_LESS_GREATER_FILTER_TYPE_SIZE]); + ret_code_t err_code = record_index_offset_greater_or_equal_get(offset_requested, &p_cgms->racp_data.racp_proc_record_ndx); + if (err_code != NRF_SUCCESS) + { + racp_report_records_completed(p_cgms); + } - p_cgms->racp_data.racp_proc_record_ndx = 0; - p_cgms->racp_data.racp_proc_operator = p_racp_request->operator; - p_cgms->racp_data.racp_proc_records_reported = 0; - //p_cgms-> + } + if (p_cgms->racp_data.racp_proc_operator == RACP_OPERATOR_LESS_OR_EQUAL) + { + uint16_t offset_requested = uint16_decode(&p_cgms->racp_data.racp_request.p_operand[OPERAND_LESS_GREATER_FILTER_TYPE_SIZE]); + ret_code_t err_code = record_index_offset_less_or_equal_get(offset_requested, + &p_cgms->racp_data.racp_proc_records_ndx_last_to_send); + if (err_code != NRF_SUCCESS) + { + racp_report_records_completed(p_cgms); + } + } racp_report_records_procedure(p_cgms); } @@ -657,6 +680,21 @@ static void report_num_records_request_execute(nrf_ble_cgms_t * p_cgms, num_records = 1; } } + else if (p_racp_request->operator == RACP_OPERATOR_GREATER_OR_EQUAL) + { + uint16_t index_of_offset; + uint16_t offset_requested = uint16_decode(&p_cgms->racp_data.racp_request.p_operand[OPERAND_LESS_GREATER_FILTER_TYPE_SIZE]); + ret_code_t err_code = record_index_offset_greater_or_equal_get(offset_requested, &index_of_offset); + + if (err_code != NRF_SUCCESS) + { + num_records = 0; + } + else + { + num_records = total_records - index_of_offset; + } + } p_cgms->racp_data.pending_racp_response.opcode = RACP_OPCODE_NUM_RECS_RESPONSE; p_cgms->racp_data.pending_racp_response.operator = RACP_OPERATOR_NULL; @@ -689,11 +727,11 @@ static void on_racp_value_write(nrf_ble_cgms_t * p_cgms, ble_gatts_evt_write_t c auth_reply.params.write.len = 0; auth_reply.params.write.p_data = NULL; - // Decode request + // Decode request. ble_racp_decode(p_evt_write->len, p_evt_write->data, &p_cgms->racp_data.racp_request); // Check if request is to be executed - if (is_request_to_be_executed(p_cgms,&p_cgms->racp_data.racp_request, &response_code)) + if (is_request_to_be_executed(p_cgms, &p_cgms->racp_data.racp_request, &response_code)) { auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; auth_reply.params.write.update = 1; @@ -735,7 +773,7 @@ static void on_racp_value_write(nrf_ble_cgms_t * p_cgms, ble_gatts_evt_write_t c return; } // Abort any running procedure - p_cgms->cgms_com_state = STATE_NO_COMM; + p_cgms->racp_data.racp_procesing_active = false; // Respond with error code racp_response_code_send(p_cgms, p_cgms->racp_data.racp_request.opcode, response_code); @@ -779,13 +817,7 @@ void cgms_racp_on_rw_auth_req(nrf_ble_cgms_t * p_cgm */ void cgms_racp_on_tx_complete(nrf_ble_cgms_t * p_cgms) { - p_cgms->racp_data.racp_proc_records_reported_since_txcomplete = 0; - - if (p_cgms->cgms_com_state == STATE_RACP_RESPONSE_PENDING) - { - racp_send(p_cgms, &p_cgms->racp_data.pending_racp_response); - } - else if (p_cgms->cgms_com_state == STATE_RACP_PROC_ACTIVE) + if (p_cgms->racp_data.racp_procesing_active) { racp_report_records_procedure(p_cgms); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h index 4d48fd0..c8fa342 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_racp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c similarity index 89% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c index 3cc11e1..c327b60 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include @@ -43,6 +43,7 @@ #include "ble_srv_common.h" #include "cgms_sst.h" #include "cgms_socp.h" +#include "nrf_ble_gq.h" #define NRF_BLE_CGMS_PLUS_INFINTE 0x07FE @@ -175,59 +176,33 @@ ret_code_t cgms_socp_char_add(nrf_ble_cgms_t * p_cgms) */ static void socp_send(nrf_ble_cgms_t * p_cgms) { - uint32_t err_code; - uint8_t encoded_resp[25]; - uint8_t len; - uint16_t hvx_len; - ble_gatts_hvx_params_t hvx_params; + uint32_t err_code; + uint8_t encoded_resp[25]; + uint16_t len; + nrf_ble_gq_req_t cgms_req; - // Send indication - len = ble_socp_encode(&(p_cgms->socp_response), encoded_resp); - hvx_len = len; - - memset(&hvx_params, 0, sizeof(hvx_params)); - - hvx_params.handle = p_cgms->char_handles.socp.value_handle; - hvx_params.type = BLE_GATT_HVX_INDICATION; - hvx_params.offset = 0; - hvx_params.p_len = &hvx_len; - hvx_params.p_data = encoded_resp; - - err_code = sd_ble_gatts_hvx(p_cgms->conn_handle, &hvx_params); + memset(&cgms_req, 0, sizeof(nrf_ble_gq_req_t)); - // Error handling - if ((err_code == NRF_SUCCESS) && (hvx_len != len)) - { - err_code = NRF_ERROR_DATA_SIZE; - } - - switch (err_code) + // Send indication + len = ble_socp_encode(&(p_cgms->socp_response), encoded_resp); + + cgms_req.type = NRF_BLE_GQ_REQ_GATTS_HVX; + cgms_req.error_handler.cb = p_cgms->gatt_err_handler; + cgms_req.error_handler.p_ctx = p_cgms; + cgms_req.params.gatts_hvx.type = BLE_GATT_HVX_INDICATION; + cgms_req.params.gatts_hvx.handle = p_cgms->char_handles.socp.value_handle; + cgms_req.params.gatts_hvx.offset = 0; + cgms_req.params.gatts_hvx.p_data = encoded_resp; + cgms_req.params.gatts_hvx.p_len = &len; + + err_code = nrf_ble_gq_item_add(p_cgms->p_gatt_queue, &cgms_req, p_cgms->conn_handle); + + // Report error to application + if ((p_cgms->error_handler != NULL) && + (err_code != NRF_SUCCESS) && + (err_code != NRF_ERROR_INVALID_STATE)) { - case NRF_SUCCESS: - // Wait for HVC event. - p_cgms->cgms_com_state = STATE_SOCP_RESPONSE_IND_VERIF; - break; - - case NRF_ERROR_RESOURCES: - // Wait for TX_COMPLETE event to retry transmission. - p_cgms->cgms_com_state = STATE_SOCP_RESPONSE_PENDING; - break; - - case NRF_ERROR_INVALID_STATE: - // Make sure state machine returns to the default state. - p_cgms->cgms_com_state = STATE_NO_COMM; - break; - - default: - // Report error to application. - if (p_cgms->error_handler != NULL) - { - p_cgms->error_handler(err_code); - } - - // Make sure state machine returns to the default state. - p_cgms->cgms_com_state = STATE_NO_COMM; - break; + p_cgms->error_handler(err_code); } } @@ -420,12 +395,3 @@ void cgms_socp_on_rw_auth_req(nrf_ble_cgms_t * p_cgm } -void cgms_socp_on_tx_complete(nrf_ble_cgms_t * p_cgms) -{ - if (p_cgms->cgms_com_state == STATE_SOCP_RESPONSE_PENDING) - { - socp_send(p_cgms); - } -} - - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h index 18bf5fd..3170841 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_socp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -46,7 +46,7 @@ * * @details This module implements parts of the Continuous Glucose Monitoring that relate to the * Specific Operations Control Point. Events are propagated to this module from @ref ble_cgms - * using @ref cgms_socp_on_rw_auth_req and @ref cgms_socp_on_tx_complete. + * using @ref cgms_socp_on_rw_auth_req. * */ @@ -92,12 +92,6 @@ void cgms_socp_on_rw_auth_req(nrf_ble_cgms_t * p_cgm ble_gatts_evt_rw_authorize_request_t const * p_auth_req); -/**@brief Function for handling @ref BLE_GATTS_EVT_HVN_TX_COMPLETE events. - * - * @param[in] p_cgms Instance of the CGM Service. - */ -void cgms_socp_on_tx_complete(nrf_ble_cgms_t * p_cgms); - #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c index 91b32cb..39bfe86 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include @@ -192,6 +192,7 @@ ret_code_t cgms_sst_char_add(nrf_ble_cgms_t * p_cgms) add_char_params.write_access = SEC_JUST_WORKS; add_char_params.is_defered_write = 1; add_char_params.char_props.write = true; + add_char_params.char_props.read = true; return characteristic_add(p_cgms->service_handle, &add_char_params, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h index 483d656..b53baaa 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/cgms_sst.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c index 111032f..dd6e2c1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_racp.h" #include "ble_srv_common.h" @@ -55,6 +55,25 @@ #define OPERAND_FILTER_TYPE_FACING_TIME 0x02 /**< Filter data using User Facing Time criteria. */ +/**@brief Function for interception of GATT errors and @ref nrf_ble_gq errors. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + nrf_ble_cgms_t * p_cgms = (nrf_ble_cgms_t *)p_ctx; + + if ((p_cgms->error_handler) != NULL && (nrf_error != NRF_ERROR_INVALID_STATE)) + { + p_cgms->error_handler(nrf_error); + } +} + + /**@brief Function for setting next sequence number by reading the last record in the data base. * * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. @@ -181,12 +200,13 @@ static uint32_t srt_char_add(nrf_ble_cgms_t * p_cgms) len += uint16_encode(p_cgms->session_run_time, &(encoded_initial_srt[len])); - add_char_params.uuid = BLE_UUID_CGM_SESSION_RUN_TIME; - add_char_params.max_len = NRF_BLE_CGMS_SRT_LEN; - add_char_params.init_len = len; - add_char_params.p_init_value = encoded_initial_srt; - add_char_params.read_access = SEC_JUST_WORKS; - add_char_params.write_access = SEC_NO_ACCESS; + add_char_params.uuid = BLE_UUID_CGM_SESSION_RUN_TIME; + add_char_params.max_len = NRF_BLE_CGMS_SRT_LEN; + add_char_params.init_len = len; + add_char_params.p_init_value = encoded_initial_srt; + add_char_params.read_access = SEC_JUST_WORKS; + add_char_params.write_access = SEC_NO_ACCESS; + add_char_params.char_props.read = true; return characteristic_add(p_cgms->service_handle, &add_char_params, @@ -211,6 +231,7 @@ ret_code_t nrf_ble_cgms_init(nrf_ble_cgms_t * p_cgms, const nrf_ble_cgms_init_t VERIFY_PARAM_NOT_NULL(p_cgms); VERIFY_PARAM_NOT_NULL(p_cgms_init); VERIFY_PARAM_NOT_NULL(p_cgms_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_cgms_init->p_gatt_queue); uint32_t err_code; ble_uuid_t ble_uuid; @@ -231,12 +252,14 @@ ret_code_t nrf_ble_cgms_init(nrf_ble_cgms_t * p_cgms, const nrf_ble_cgms_init_t // Initialize service structure p_cgms->evt_handler = p_cgms_init->evt_handler; p_cgms->error_handler = p_cgms_init->error_handler; + p_cgms->p_gatt_queue = p_cgms_init->p_gatt_queue; p_cgms->feature = p_cgms_init->feature; p_cgms->sensor_status = p_cgms_init->initial_sensor_status; p_cgms->session_run_time = p_cgms_init->initial_run_time; p_cgms->is_session_started = false; p_cgms->nb_run_session = 0; p_cgms->conn_handle = BLE_CONN_HANDLE_INVALID; + p_cgms->gatt_err_handler = gatt_error_handler; p_cgms->feature.feature = 0; p_cgms->feature.feature |= NRF_BLE_CGMS_FEAT_MULTIPLE_BOND_SUPPORTED; @@ -247,10 +270,6 @@ ret_code_t nrf_ble_cgms_init(nrf_ble_cgms_t * p_cgms, const nrf_ble_cgms_init_t memcpy(p_cgms->calibration_val[0].value, init_calib_val, NRF_BLE_CGMS_MAX_CALIB_LEN); - // Initialize global variables - p_cgms->cgms_com_state = STATE_NO_COMM; - p_cgms->racp_data.racp_proc_records_reported_since_txcomplete = 0; - // Add service BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_CGM_SERVICE); @@ -339,56 +358,7 @@ static void on_write(nrf_ble_cgms_t * p_cgms, ble_evt_t const * p_ble_evt) */ static void on_tx_complete(nrf_ble_cgms_t * p_cgms, ble_evt_t const * p_ble_evt) { - p_cgms->racp_data.racp_proc_records_reported_since_txcomplete = 0; - cgms_racp_on_tx_complete(p_cgms); - cgms_socp_on_tx_complete(p_cgms); -} - - -/**@brief Function for handling the HVC event. - * - * @details Handles HVC events from the BLE stack. - * - * @param[in] p_cgms Glucose Service structure. - * @param[in] p_ble_evt Event received from the BLE stack. - */ -static void on_hvc(nrf_ble_cgms_t * p_cgms, ble_evt_t const * p_ble_evt) -{ - ble_gatts_evt_hvc_t const * p_hvc = &p_ble_evt->evt.gatts_evt.params.hvc; - - if (p_hvc->handle == p_cgms->char_handles.racp.value_handle) - { - if (p_cgms->cgms_com_state == STATE_RACP_RESPONSE_IND_VERIF) - { - // Indication has been acknowledged. Return to default state. - p_cgms->cgms_com_state = STATE_NO_COMM; - } - else - { - // We did not expect this event in this state. Report error to application. - if (p_cgms->error_handler != NULL) - { - p_cgms->error_handler(NRF_ERROR_INVALID_STATE); - } - } - } - if (p_hvc->handle == p_cgms->char_handles.socp.value_handle) - { - if (p_cgms->cgms_com_state == STATE_SOCP_RESPONSE_IND_VERIF) - { - // Indication has been acknowledged. Return to default state. - p_cgms->cgms_com_state = STATE_NO_COMM; - } - else - { - // We did not expect this event in this state. Report error to application. - if (p_cgms->error_handler != NULL) - { - p_cgms->error_handler(NRF_ERROR_INVALID_STATE); - } - } - } } @@ -411,7 +381,6 @@ void nrf_ble_cgms_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) { case BLE_GAP_EVT_CONNECTED: p_cgms->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - p_cgms->cgms_com_state = STATE_NO_COMM; break; case BLE_GAP_EVT_DISCONNECTED: @@ -430,10 +399,6 @@ void nrf_ble_cgms_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) on_rw_authorize_request(p_cgms, &p_ble_evt->evt.gatts_evt); break; - case BLE_GATTS_EVT_HVC: - on_hvc(p_cgms, p_ble_evt); - break; - default: // No implementation needed. break; @@ -478,8 +443,10 @@ ret_code_t nrf_ble_cgms_update_status(nrf_ble_cgms_t * p_cgms, nrf_ble_cgm_statu ret_code_t nrf_ble_cgms_conn_handle_assign(nrf_ble_cgms_t * p_cgms, uint16_t conn_handle) { VERIFY_PARAM_NOT_NULL(p_cgms); + p_cgms->conn_handle = conn_handle; - return NRF_SUCCESS; + + return nrf_ble_gq_conn_handle_register(p_cgms->p_gatt_queue, conn_handle); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h index 9cbf4d5..4578d4c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_cgms/nrf_ble_cgms.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -68,6 +68,7 @@ #include "sdk_errors.h" #include "ble_racp.h" #include "nrf_sdh_ble.h" +#include "nrf_ble_gq.h" #ifdef __cplusplus extern "C" { @@ -192,17 +193,6 @@ typedef enum } nrf_ble_cgms_evt_type_t; -/**@brief CGM Service communication states. */ -typedef enum -{ - STATE_NO_COMM, /**< The service is not in a communicating state. */ - STATE_RACP_PROC_ACTIVE, /**< Processing requested data. */ - STATE_RACP_RESPONSE_PENDING, /**< There is an RACP indication waiting to be sent. */ - STATE_RACP_RESPONSE_IND_VERIF, /**< Waiting for a verification of an RACP indication. */ - STATE_SOCP_RESPONSE_PENDING, /**< There is an SOCP indication waiting to be sent. */ - STATE_SOCP_RESPONSE_IND_VERIF /**< Waiting for a verification of an SOCP indication. */ -} nrf_ble_cgms_com_state_t; - /** @} */ // End tag for Enumeration group. /** @@ -286,11 +276,12 @@ typedef struct * initializing the service. */ typedef struct { - ble_cgms_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the CGM Service. */ - ble_srv_error_handler_t error_handler; /**< Function to be called when an error occurs. */ - nrf_ble_cgms_feature_t feature; /**< Features supported by the service. */ - nrf_ble_cgm_status_t initial_sensor_status; /**< Sensor status. */ - uint16_t initial_run_time; /**< Run time. */ + ble_cgms_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the CGM Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called when an error occurs. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ + nrf_ble_cgms_feature_t feature; /**< Features supported by the service. */ + nrf_ble_cgm_status_t initial_sensor_status; /**< Sensor status. */ + uint16_t initial_run_time; /**< Run time. */ } nrf_ble_cgms_init_t; @@ -316,11 +307,12 @@ typedef struct typedef struct { uint8_t racp_proc_operator; /**< Operator of the current request. */ - uint8_t racp_proc_record_ndx; /**< Current record index. */ - uint8_t racp_proc_records_reported; /**< Number of reported records. */ - uint8_t racp_proc_records_reported_since_txcomplete; /**< Number of reported records since the last TX_COMPLETE event. */ - ble_racp_value_t racp_request; + uint16_t racp_proc_record_ndx; /**< Current record index. */ + uint16_t racp_proc_records_ndx_last_to_send; /**< The last record to send, can be used together with racp_proc_record_ndx to determine a range of records to send. (used by greater/less filters). */ + uint16_t racp_proc_records_reported; /**< Number of reported records. */ + ble_racp_value_t racp_request; /**< RACP procedure that has been requested from the peer. */ ble_racp_value_t pending_racp_response; /**< RACP response to be sent. */ + bool racp_procesing_active; /**< RACP processing active. */ uint8_t pending_racp_response_operand[NRF_BLE_CGMS_RACP_PENDING_OPERANDS_MAX]; /**< Operand of the RACP response to be sent. */ } nrf_ble_cgms_racp_t; @@ -343,6 +335,8 @@ struct ble_cgms_s { ble_cgms_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the CGM Service. */ ble_srv_error_handler_t error_handler; /**< Function to be called if an error occurs. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to BLE GATT Queue instance. */ + nrf_ble_gq_req_error_cb_t gatt_err_handler; /**< Error handler to be called in case of an error from SoftDevice. */ uint16_t service_handle; /**< Handle of the CGM Service (as provided by the BLE stack). */ nrf_ble_cgms_char_handler_t char_handles; /**< GATTS characteristic handles for the different characteristics in the service. */ uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack; @ref BLE_CONN_HANDLE_INVALID if not in a connection). */ @@ -354,7 +348,6 @@ struct ble_cgms_s uint8_t nb_run_session; /**< Variable to keep track of the number of sessions that were run. */ uint16_t session_run_time; /**< Variable to store the expected run time of a session. */ nrf_ble_cgm_status_t sensor_status; /**< Structure to keep track of the sensor status. */ - nrf_ble_cgms_com_state_t cgms_com_state; /**< Current communication state. */ nrf_ble_cgms_racp_t racp_data; /**< Structure to manage Record Access requests. */ }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c index 3bde5e9..4916114 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -69,11 +69,32 @@ NRF_LOG_MODULE_REGISTER(); #define BLE_OTS_OLCP_SUPPORT_FEATURE_REQ_NUM_OBJECTS_bp 2 #define BLE_OTS_OLCP_SUPPORT_FEATURE_CLEAR_MARKING_bp 3 -#define MODULE_INITIALIZED (p_ots_c->initialized) /**< Macro designating whether the module has been initialized properly. */ +#define MODULE_INITIALIZED (p_ots_c->initialized) /**< Macro designating whether the module was initialized properly. */ static const ble_uuid_t m_ots_uuid = {BLE_UUID_OTS_SERVICE, BLE_UUID_TYPE_BLE}; /**< Object Transfer Service UUID. */ +/**@brief Function for intercepting the errors of GATTC and the BLE GATT Queue. + * + * @param[in] nrf_error Error code. + * @param[in] p_ctx Parameter from the event handler. + * @param[in] conn_handle Connection handle. + */ +static void gatt_error_handler(uint32_t nrf_error, + void * p_ctx, + uint16_t conn_handle) +{ + nrf_ble_ots_c_t * p_ots_c = (nrf_ble_ots_c_t *)p_ctx; + + NRF_LOG_DEBUG("A GATT Client error has occurred on conn_handle: 0X%X", conn_handle); + + if (p_ots_c->err_handler != NULL) + { + p_ots_c->err_handler(nrf_error); + } +} + + ret_code_t nrf_ble_ots_c_init(nrf_ble_ots_c_t * p_ots_c, nrf_ble_ots_c_init_t * p_ots_c_init) { @@ -81,15 +102,21 @@ ret_code_t nrf_ble_ots_c_init(nrf_ble_ots_c_t * p_ots_c, VERIFY_PARAM_NOT_NULL(p_ots_c); VERIFY_PARAM_NOT_NULL(p_ots_c_init); VERIFY_PARAM_NOT_NULL(p_ots_c_init->evt_handler); + VERIFY_PARAM_NOT_NULL(p_ots_c_init->p_gatt_queue); + memset (p_ots_c, 0, sizeof(nrf_ble_ots_c_t)); - p_ots_c->conn_handle = BLE_CONN_HANDLE_INVALID; - p_ots_c->evt_handler = p_ots_c_init->evt_handler; + p_ots_c->conn_handle = BLE_CONN_HANDLE_INVALID; + p_ots_c->evt_handler = p_ots_c_init->evt_handler; + p_ots_c->err_handler = p_ots_c_init->err_handler; + p_ots_c->p_gatt_queue = p_ots_c_init->p_gatt_queue; + p_ots_c->gatt_err_handler = gatt_error_handler; err_code = ble_db_discovery_evt_register(&m_ots_uuid); VERIFY_SUCCESS(err_code); p_ots_c->initialized = true; + return err_code; } @@ -98,8 +125,8 @@ ret_code_t nrf_ble_ots_c_init(nrf_ble_ots_c_t * p_ots_c, @param[in] p_ots_c Pointer to the GATT Service client structure instance. - @return True if the Object Transfer service handles are valid. - @return False if the Object Transfer service handles are invalid + @return True, if the Object Transfer service handles are valid. + @return False, if the Object Transfer service handles are invalid. */ static bool ots_gatt_handles_are_valid(const nrf_ble_ots_c_t * const p_ots_c) { @@ -114,11 +141,17 @@ ret_code_t nrf_ble_ots_c_feature_read(nrf_ble_ots_c_t * const p_ots_c) { VERIFY_MODULE_INITIALIZED(); - ret_code_t err_code; - err_code = sd_ble_gattc_read(p_ots_c->conn_handle, - p_ots_c->service.ots_feature_char.handle_value, - 0); - return err_code; + nrf_ble_gq_req_t read_req; + + memset(&read_req, 0, sizeof(nrf_ble_gq_req_t)); + + read_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + read_req.error_handler.cb = p_ots_c->gatt_err_handler; + read_req.error_handler.p_ctx = (nrf_ble_ots_c_t *)p_ots_c; + read_req.params.gattc_read.handle = p_ots_c->service.ots_feature_char.handle_value; + read_req.params.gattc_read.offset = 0; + + return nrf_ble_gq_item_add(p_ots_c->p_gatt_queue, &read_req, p_ots_c->conn_handle); } @@ -130,11 +163,57 @@ ret_code_t nrf_ble_ots_c_obj_size_read(nrf_ble_ots_c_t * const p_ots_c) { return NRF_ERROR_INVALID_STATE; } - ret_code_t err_code; - err_code = sd_ble_gattc_read(p_ots_c->conn_handle, - p_ots_c->service.object_size_char.handle_value, - 0); - return err_code; + + nrf_ble_gq_req_t read_req; + + memset(&read_req, 0, sizeof(nrf_ble_gq_req_t)); + + read_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + read_req.error_handler.cb = p_ots_c->gatt_err_handler; + read_req.error_handler.p_ctx = (nrf_ble_ots_c_t *)p_ots_c; + read_req.params.gattc_read.handle = p_ots_c->service.object_size_char.handle_value; + read_req.params.gattc_read.offset = 0; + + return nrf_ble_gq_item_add(p_ots_c->p_gatt_queue, &read_req, p_ots_c->conn_handle); +} + + +ret_code_t nrf_ble_ots_c_obj_properties_read(nrf_ble_ots_c_t * const p_ots_c) +{ + VERIFY_MODULE_INITIALIZED(); + + if( p_ots_c->service.object_prop_char.handle_value == BLE_GATT_HANDLE_INVALID) + { + return NRF_ERROR_INVALID_STATE; + } + + nrf_ble_gq_req_t read_req; + + memset(&read_req, 0, sizeof(nrf_ble_gq_req_t)); + + read_req.type = NRF_BLE_GQ_REQ_GATTC_READ; + read_req.error_handler.cb = p_ots_c->gatt_err_handler; + read_req.error_handler.p_ctx = (nrf_ble_ots_c_t *)p_ots_c; + read_req.params.gattc_read.handle = p_ots_c->service.object_prop_char.handle_value; + read_req.params.gattc_read.offset = 0; + + return nrf_ble_gq_item_add(p_ots_c->p_gatt_queue, &read_req, p_ots_c->conn_handle); +} + + +static void prop_read_rsp_decode(nrf_ble_ots_c_t * p_ots_c, const ble_evt_t * p_ble_evt) +{ + const ble_gattc_evt_read_rsp_t * p_response; + p_response = &p_ble_evt->evt.gattc_evt.params.read_rsp; + + uint32_t properties; + properties = uint32_decode(&p_response->data[0]); + + nrf_ble_ots_c_evt_t evt; + evt.conn_handle = p_ble_evt->evt.gattc_evt.conn_handle; + evt.params.prop.raw = properties; + evt.evt_type = NRF_BLE_OTS_C_EVT_PROP_READ_RESP; + p_ots_c->evt_handler(&evt); } /**@brief Function for handling read response events. @@ -142,7 +221,7 @@ ret_code_t nrf_ble_ots_c_obj_size_read(nrf_ble_ots_c_t * const p_ots_c) * @details This function will validate the read response and raise the appropriate * event to the application. * - * @param[in] p_bas_c Pointer to the Battery Service Client Structure. + * @param[in] p_ots_c Pointer to the Object Transfer instance. * @param[in] p_ble_evt Pointer to the SoftDevice event. */ static void on_read_rsp(nrf_ble_ots_c_t * p_ots_c, const ble_evt_t * p_ble_evt) @@ -208,6 +287,10 @@ static void on_read_rsp(nrf_ble_ots_c_t * p_ots_c, const ble_evt_t * p_ble_evt) p_ots_c->evt_handler(&evt); } + if (p_response->handle == p_ots_c->service.object_prop_char.handle_value) + { + prop_read_rsp_decode(p_ots_c, p_ble_evt); + } } @@ -226,7 +309,7 @@ void nrf_ble_ots_c_on_db_disc_evt(nrf_ble_ots_c_t const * const p_ots_c, (p_evt->params.discovered_db.srv_uuid.uuid == BLE_UUID_OTS_SERVICE) && (p_evt->params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE)) { - // Find the handles of the ANCS characteristic. + // Find the handles of the OTS characteristics. for (uint32_t i = 0; i < p_evt->params.discovered_db.char_count; i++) { switch (p_chars[i].characteristic.uuid.uuid) @@ -280,13 +363,18 @@ void nrf_ble_ots_c_on_db_disc_evt(nrf_ble_ots_c_t const * const p_ots_c, } evt.evt_type = NRF_BLE_OTS_C_EVT_DISCOVERY_COMPLETE; evt.conn_handle = p_evt->conn_handle; - p_ots_c->evt_handler(&evt); } - else + else if ((p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND) || + (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)) { evt.evt_type = NRF_BLE_OTS_C_EVT_DISCOVERY_FAILED; - p_ots_c->evt_handler(&evt); } + else + { + return; + } + + p_ots_c->evt_handler(&evt); } @@ -337,8 +425,21 @@ void nrf_ble_ots_c_on_ble_evt(ble_evt_t const * const p_ble_evt, break; case BLE_GATTC_EVT_WRITE_RSP: - //on_write_rsp() - NRF_LOG_DEBUG("error handle write response: %x\r\n", p_ble_evt->evt.gattc_evt.error_handle); + if ((p_ble_evt->evt.gattc_evt.error_handle != BLE_GATT_HANDLE_INVALID) + && (p_ble_evt->evt.gattc_evt.error_handle == + p_ots_c->service.object_action_cp_char.handle_value)) + { + if (p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR) + { + NRF_LOG_INFO("write to OACP failed, CCCD improperly configured, enable indications on OACP and try again"); + } + else + { + NRF_LOG_INFO("BLE_GATTC_EVT_WRITE_RSP error handle: %x error response %x\r\n", + p_ble_evt->evt.gattc_evt.error_handle, + p_ble_evt->evt.gattc_evt.gatt_status); + } + } break; default: @@ -349,7 +450,7 @@ void nrf_ble_ots_c_on_ble_evt(ble_evt_t const * const p_ble_evt, } -ret_code_t nrf_ble_ots_c_handles_assign(nrf_ble_ots_c_t * const p_ots_c, +ret_code_t nrf_ble_ots_c_handles_assign(nrf_ble_ots_c_t * const p_ots_c, uint16_t const conn_handle, nrf_ble_ots_c_service_t const * const p_peer_handles) { @@ -367,7 +468,8 @@ ret_code_t nrf_ble_ots_c_handles_assign(nrf_ble_ots_c_t * const p_ots_c->service.object_action_cp_cccd.handle = p_peer_handles->object_action_cp_cccd.handle; } - return NRF_SUCCESS; + + return nrf_ble_gq_conn_handle_register(p_ots_c->p_gatt_queue, conn_handle); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h index 5ccd1a7..fbf8769 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -43,9 +43,9 @@ * @defgroup nrf_ble_ots_c Object Transfer Service Client * @{ * @ingroup ble_sdk_srv - * @brief Object Transfer Service client module + * @brief Object Transfer Service Client module * - * @details This is the main module of the Object Transfer Service (OTS) client. + * @details This is the main module of the Object Transfer Service (OTS) Client. */ #ifndef NRF_BLE_OTS_C_H__ @@ -74,14 +74,26 @@ NRF_SDH_BLE_OBSERVER(_name ## _ble_obs, BLE_OTS_C_BLE_OBSERVER_PRIO, \ nrf_ble_ots_c_on_ble_evt, &_name) \ +/** @brief Macro for defining multiple ble_ots instances. + * + * @param _name Name of the array of instances. + * @param _cnt Number of instances to define. + * @hideinitializer + */ +#define NRF_BLE_OTS_C_ARRAY_DEF(_name, _cnt) \ +static nrf_ble_ots_c_t _name[_cnt]; \ +NRF_SDH_BLE_OBSERVERS(_name ## _ble_obs, \ + BLE_OTS_C_BLE_OBSERVER_PRIO, \ + nrf_ble_ots_c_on_ble_evt, &_name, _cnt) + /** @brief Types of Object Action Control Point Procedures. */ typedef enum { NRF_BLE_OTS_C_OACP_PROC_CREATE = 0x01, //!< Create object. NRF_BLE_OTS_C_OACP_PROC_DELETE = 0x02, //!< Delete object. - NRF_BLE_OTS_C_OACP_PROC_CALC_CHKSUM = 0x03, //!< Calculate Checksum. - NRF_BLE_OTS_C_OACP_PROC_EXECUTE = 0x04, //!< Execute Object. + NRF_BLE_OTS_C_OACP_PROC_CALC_CHKSUM = 0x03, //!< Calculate checksum. + NRF_BLE_OTS_C_OACP_PROC_EXECUTE = 0x04, //!< Execute object. NRF_BLE_OTS_C_OACP_PROC_READ = 0x05, //!< Read object. NRF_BLE_OTS_C_OACP_PROC_WRITE = 0x06, //!< Write object. NRF_BLE_OTS_C_OACP_PROC_ABORT = 0x07, //!< Abort object. @@ -92,32 +104,33 @@ typedef enum typedef enum { NRF_BLE_OTS_C_OACP_RES_SUCCESS = 0x01, //!< Success. - NRF_BLE_OTS_C_OACP_RES_OPCODE_NOT_SUP = 0x02, //!< Not supported - NRF_BLE_OTS_C_OACP_RES_INV_PARAM = 0x03, //!< Invalid parameter + NRF_BLE_OTS_C_OACP_RES_OPCODE_NOT_SUP = 0x02, //!< Not supported. + NRF_BLE_OTS_C_OACP_RES_INV_PARAM = 0x03, //!< Invalid parameter. NRF_BLE_OTS_C_OACP_RES_INSUFF_RES = 0x04, //!< Insufficient resources. NRF_BLE_OTS_C_OACP_RES_INV_OBJ = 0x05, //!< Invalid object. NRF_BLE_OTS_C_OACP_RES_CHAN_UNAVAIL = 0x06, //!< Channel unavailable. NRF_BLE_OTS_C_OACP_RES_UNSUP_TYPE = 0x07, //!< Unsupported procedure. NRF_BLE_OTS_C_OACP_RES_NOT_PERMITTED = 0x08, //!< Procedure not permitted. NRF_BLE_OTS_C_OACP_RES_OBJ_LOCKED = 0x09, //!< Object locked. - NRF_BLE_OTS_C_OACP_RES_OPER_FAILED = 0x0A //!< Operation Failed. + NRF_BLE_OTS_C_OACP_RES_OPER_FAILED = 0x0A //!< Operation failed. } ble_ots_c_oacp_res_code_t; -/**@brief Type of the Object Transfer Service client event. - */ +/**@brief Type of the Object Transfer Service Client event. */ typedef enum { NRF_BLE_OTS_C_EVT_DISCOVERY_FAILED, //!< Event indicating that the Object Transfer Service has not been found on the peer. NRF_BLE_OTS_C_EVT_DISCOVERY_COMPLETE, //!< Event indicating that the Object Transfer Service is present on the peer device. - NRF_BLE_OTS_C_EVT_DISCONN_COMPLETE, //!< Event indicating that the Object Transfer Service client module has finished processing the BLE_GAP_EVT_DISCONNECTED event. The event can be used by the application to do clean up related to the Object Transfer Service client. - NRF_BLE_OTS_C_EVT_FEATURE_READ_RESP, //!< Event indicating that the feature characteristic was read, The available features of the peer will be provided in the event. + NRF_BLE_OTS_C_EVT_DISCONN_COMPLETE, //!< Event indicating that the Object Transfer Service Client module finished processing the BLE_GAP_EVT_DISCONNECTED event. The application can use this event to do a cleanup related to the Object Transfer Service Client. + NRF_BLE_OTS_C_EVT_FEATURE_READ_RESP, //!< Event indicating that the feature characteristic was read. The available features of the peer will be provided in the event. NRF_BLE_OTS_C_EVT_OACP_RESP, //!< Event indicating that a response was received (result of a write to the OACP). - NRF_BLE_OTS_C_EVT_OBJ_READ, //!< Event indicating that the Object Transfer Service client finished reading object from the peer - NRF_BLE_OTS_C_EVT_CHANNEL_RELEASED, //!< Event indicating that the L2CAP Connection Oriented Channel has been disconnected - NRF_BLE_OTS_C_EVT_SIZE_READ_RESP //!< Event indicating that the object size characteristic was read. + NRF_BLE_OTS_C_EVT_OBJ_READ, //!< Event indicating that the Object Transfer Service Client finished reading object from the peer. + NRF_BLE_OTS_C_EVT_OBJ_WRITE, //!< Event indicating that the Object Transfer Service Client finished writing an object to the peer. + NRF_BLE_OTS_C_EVT_CHANNEL_RELEASED, //!< Event indicating that the L2CAP Connection Oriented Channel was disconnected. + NRF_BLE_OTS_C_EVT_SIZE_READ_RESP, //!< Event indicating that the object size characteristic was read. + NRF_BLE_OTS_C_EVT_PROP_READ_RESP //!< Event indicating that the object properties characteristic was read. } nrf_ble_ots_c_evt_type_t; -/** @brief Structure to hold the features of a server */ +/** @brief Structure to hold the features of a server. */ typedef struct { uint8_t oacp_create : 1; @@ -136,28 +149,48 @@ typedef struct uint8_t olcp_clear : 1; } nrf_ble_ots_c_feature_t; -/**@brief Structure used for holding the Apple Notification Center Service found during the + +/**@brief Properties of an Object Transfer Service object. */ +typedef union +{ + struct + { + bool is_delete_permitted :1; /**< Object can be deleted. */ + bool is_execute_permitted :1; /**< Object can be executed. */ + bool is_read_permitted :1; /**< Object can be read. */ + bool is_write_permitted :1; /**< Object can be written. */ + bool is_append_permitted :1; /**< Object can be appended. */ + bool is_truncate_permitted :1; /**< When writing using truncate mode, and the written length is shorter than the object, the object size is decreased. */ + bool is_patch_permitted :1; /**< When patching, a part of the object is replaced. */ + bool is_marked :1; /**< Boolean to keep track whether the object is marked or not. */ + } decoded; + uint32_t raw; +} nrf_ble_ots_c_obj_properties_t; + + +/**@brief Structure for holding the Object Transfer Service found during the discovery process. */ typedef struct { - ble_gattc_service_t service; //!< The Object Transfer Service holding the discovered Object Transfer Service. (0x1825). - ble_gattc_char_t ots_feature_char; //!< OTS Feature (0x2ABD) - ble_gattc_char_t object_name_char; //!< Object Name (0x2ABE) - ble_gattc_char_t object_type_char; //!< Object Type (0x2ABF) - ble_gattc_char_t object_size_char; //!< Object Size (0x2AC0) - ble_gattc_char_t object_prop_char; //!< Object Properties (0x2AC4) - ble_gattc_char_t object_action_cp_char; //!< Object Action Control Point (0x2AC5) - ble_gattc_desc_t object_action_cp_cccd; //!< Object Action Control Point Descriptor. Enables or disables Object Transfer notifications. + ble_gattc_service_t service; //!< The Object Transfer Service holding the discovered Object Transfer Service (0x1825). + ble_gattc_char_t ots_feature_char; //!< OTS Feature (0x2ABD). + ble_gattc_char_t object_name_char; //!< Object name (0x2ABE). + ble_gattc_char_t object_type_char; //!< Object type (0x2ABF). + ble_gattc_char_t object_size_char; //!< Object size (0x2AC0). + ble_gattc_char_t object_prop_char; //!< Object properties (0x2AC4). + ble_gattc_char_t object_action_cp_char; //!< Object action control point (0x2AC5). + ble_gattc_desc_t object_action_cp_cccd; //!< Object action control point descriptor. Enables or disables Object Transfer notifications. } nrf_ble_ots_c_service_t; - +/** @brief Structure to hold responses received when writing to the Object Action Control Point on the server. */ typedef struct { ble_ots_c_oacp_proc_type_t request_op_code; ble_ots_c_oacp_res_code_t result_code; } nrf_ble_ots_c_oacp_response_t; +/** @brief Structure to hold the size of the object on the server when read from the Object Size characteristic on the server. */ typedef struct { uint32_t current_size; @@ -172,11 +205,12 @@ typedef struct uint16_t conn_handle; /**< Handle of the connection for which this event has occurred. */ union { - nrf_ble_ots_c_feature_t feature; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_FEATURE_READ_RESP.*/ - nrf_ble_ots_c_service_t handles; /**< Handles that the Object Transfer service occupies in the peer device. Will be filled if the event type is @ref NRF_BLE_OTS_C_EVT_DISCOVERY_COMPLETE.*/ - nrf_ble_ots_c_oacp_response_t response; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_OACP_RESP. */ - ble_data_t object; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_OBJ_READ. */ - nrf_ble_ots_c_obj_size size; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_SIZE_READ_RESP. */ + nrf_ble_ots_c_feature_t feature; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_FEATURE_READ_RESP.*/ + nrf_ble_ots_c_service_t handles; /**< Handles that the Object Transfer service occupies in the peer device. Will be filled if the event type is @ref NRF_BLE_OTS_C_EVT_DISCOVERY_COMPLETE.*/ + nrf_ble_ots_c_oacp_response_t response; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_OACP_RESP. */ + ble_data_t object; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_OBJ_READ. */ + nrf_ble_ots_c_obj_size size; /**< Will be provided if the event type is @ref NRF_BLE_OTS_C_EVT_SIZE_READ_RESP. */ + nrf_ble_ots_c_obj_properties_t prop; /**< Will be provided if the eevnt type is @ref NRF_BLE_OTS_C_EVT_PROP_READ_RESP. */ } params; } nrf_ble_ots_c_evt_t; @@ -191,52 +225,53 @@ typedef void (* nrf_ble_ots_c_evt_handler_t)(nrf_ble_ots_c_evt_t * p_evt); */ typedef struct { - bool initialized; /**< Boolean telling whether the context has been initialized or not. */ - uint16_t conn_handle; /**< Active connection handle */ - nrf_ble_ots_c_service_t service; /**< Structure to store the different handles and UUIDs related to the service. */ - nrf_ble_ots_c_evt_handler_t evt_handler; /**< Pointer to event handler function. */ - ble_srv_error_handler_t err_handler; /**< Pointer to error handler function. */ - uint16_t local_cid; - ble_l2cap_evt_ch_setup_t ch_setup; /**< L2CAP Channel Setup Completed Event Parameters. */ - uint32_t current_credits; - uint32_t remaining_bytes; - uint32_t transmitted_bytes; - uint32_t received_bytes; - ble_data_t * current_obj; + bool initialized; /**< Boolean telling whether the context was initialized or not. */ + uint16_t conn_handle; /**< Active connection handle. */ + nrf_ble_ots_c_service_t service; /**< Structure to store the different handles and UUIDs related to the service. */ + nrf_ble_ots_c_evt_handler_t evt_handler; /**< Pointer to event handler function. */ + ble_srv_error_handler_t err_handler; /**< Pointer to error handler function. */ + nrf_ble_gq_req_error_cb_t gatt_err_handler; /**< Error handler to be called in case of an error from the SoftDevice. */ + uint16_t local_cid; /**< Connection ID of the current connection. */ + ble_l2cap_evt_ch_setup_t ch_setup; /**< Parameters of the L2CAP Channel Setup Completed event. */ + uint32_t transmitted_bytes; /**< Variable used when transferring an object to the peer. */ + uint32_t received_bytes; /**< Variable used when transferring an object from the peer. */ + ble_data_t * current_obj; /**< Pointer to the current object to be transferred. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } nrf_ble_ots_c_t; -/**@brief Initialization parameters, these must be supplied when calling @ref nrf_ble_ots_c_init. */ +/**@brief Initialization parameters. These must be supplied when calling @ref nrf_ble_ots_c_init. */ typedef struct { - nrf_ble_ots_c_evt_handler_t evt_handler; /**< The event handler that is called by the Object Transfer client module when any related event occurs. */ - ble_srv_error_handler_t err_handler; /**< the error handler that is called by the Object Transfer client module if any error occurs. */ + nrf_ble_ots_c_evt_handler_t evt_handler; /**< The event handler that is called by the Object Transfer client module when any related event occurs. */ + ble_srv_error_handler_t err_handler; /**< The error handler that is called by the Object Transfer client module if any error occurs. */ + nrf_ble_gq_t * p_gatt_queue; /**< Pointer to the BLE GATT Queue instance. */ } nrf_ble_ots_c_init_t; /**@brief Function for initializing the Object Transfer client module. @param[in,out] p_ots_c Pointer to the Object Transfer Service client structure instance. - @param[in] p_ots_c_init Init parameters contraining the event handler that is called by - the Object Transfer client module when any related event occurs. + @param[in] p_ots_c_init Init parameters that contain the event handler that is called + by the Object Transfer client module when any related event occurs. @retval NRF_SUCCESS If the service was initialized successfully. @retval NRF_ERROR_NULL If any of the input parameters are NULL. - @return If functions from other modules return errors to this function, + @retval err_code If functions from other modules return errors to this function, the @ref nrf_error are propagated. */ ret_code_t nrf_ble_ots_c_init(nrf_ble_ots_c_t * p_ots_c, nrf_ble_ots_c_init_t * p_ots_c_init); -/**@brief Function for handling events from the database discovery module. +/**@brief Function for handling events from the Database Discovery module. - @details This function will handle an event from the database discovery module, and determine - if it relates to the discovery of Object Transfer Service at the peer. If so, - it will call the application's event handler indicating that Object Transfer Service + @details This function handles an event from the Database Discovery module, and determines + whether it relates to the discovery of Object Transfer Service at the peer. If it does, + the function calls the application's event handler to indicate that Object Transfer Service has been discovered at the peer. @param[in,out] p_ots_c Pointer to the Object Transfer Service client structure instance. - @param[in] p_evt Pointer to the event received from the database discovery module. + @param[in] p_evt Pointer to the event received from the Database Discovery module. */ void nrf_ble_ots_c_on_db_disc_evt(nrf_ble_ots_c_t const * const p_ots_c, ble_db_discovery_evt_t * const p_evt); @@ -244,60 +279,68 @@ void nrf_ble_ots_c_on_db_disc_evt(nrf_ble_ots_c_t const * const p_ots_c, /**@brief Function for reading the features characteristic (@ref BLE_UUID_OTS_FEATURES) on the server. - @param[in,out] p_ots_c Pointer to Object Transfer client structure. + @param[in,out] p_ots_c Pointer to Object Transfer Client structure. @retval NRF_SUCCESS Operation success. - @return If functions from other modules return errors to this function, - the @ref nrf_error are propagated. + @retval err_code Otherwise, this API propagates the error code returned by function @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ble_ots_c_feature_read(nrf_ble_ots_c_t * const p_ots_c); /**@brief Function for reading the Object Size characteristic (@ref BLE_UUID_OTS_FEATURES) on the server. - @param[in,out] p_ots_c Pointer to Object Transfer client structure. + @param[in,out] p_ots_c Pointer to Object Transfer Client structure. - @retval NRF_SUCCESS Operation success. - @return NRF_ERROR_INVALID_STATE if the Object Size characteristic has not been discovered. If functions from other modules return errors to this function, - the @ref nrf_error are propagated. + @retval NRF_SUCCESS Operation success. + @retval NRF_ERROR_INVALID_STATE If the Object Size characteristic has not been discovered. + @retval err_code Otherwise, this API propagates the error code returned by function @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ble_ots_c_obj_size_read(nrf_ble_ots_c_t * const p_ots_c); +/**@brief Function for reading the Object properties (@ref BLE_UUID_OTS_OBJECT_PROPERTIES) on the server. + + @param[in,out] p_ots_c Pointer to Object Transfer Client structure. + + @retval NRF_SUCCESS Operation success. + @retval NRF_ERROR_INVALID_STATE If the Object Properties characteristic has not been discovered. + @retval err_code Otherwise, this API propagates the error code returned by function @ref nrf_ble_gq_item_add. +*/ +ret_code_t nrf_ble_ots_c_obj_properties_read(nrf_ble_ots_c_t * const p_ots_c); + + /**@brief Function for handling the Application's BLE Stack events. @param[in] p_ble_evt Pointer to the BLE event received. @param[in,out] p_context Pointer to the Object Transfer Service client structure instance. */ -void nrf_ble_ots_c_on_ble_evt(const ble_evt_t * const p_ble_evt, - void * p_context); +void nrf_ble_ots_c_on_ble_evt(const ble_evt_t * const p_ble_evt, void * p_context); ret_code_t nrf_ble_ots_c_obj_name_read(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj); ret_code_t nrf_ble_ots_c_obj_name_write(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj); ret_code_t nrf_ble_ots_c_obj_type_read(nrf_ble_ots_c_t * const p_ots_c); -ret_code_t nrf_ble_ots_c_obj_size_read(nrf_ble_ots_c_t * const p_ots_c); -ret_code_t nrf_ble_ots_c_obj_properties_read(nrf_ble_ots_c_t * const p_ots_c); -/**@brief Function for assigning handles to a Object Transfer Service client instance. +/**@brief Function for assigning handles to an Object Transfer Service Client instance. @details Call this function when a link has been established with a peer to - associate this link to an instance of the module. This makes it - possible to handle several link and associate each link to a particular - instance of the Object Transfer Service client module. The connection handle and - attribute handles will be provided from the discovery event + associate the link to an instance of the module. This makes it + possible to handle several links and associate each link to a particular + instance of the Object Transfer Service Client module. The connection handle and + attribute handles are provided from the discovery event @ref NRF_BLE_OTS_C_EVT_DISCOVERY_COMPLETE. - @param[in,out] p_ots_c Pointer to the Object Transfer Service client structure instance to associate - with the handles. - @param[in] conn_handle Connection handle to be associated with the given Object Transfer Service client - Instance. + @param[in,out] p_ots_c Pointer to the Object Transfer Service Client structure instance for associating the link. + @param[in] conn_handle Connection handle to be associated with the given Object Transfer Service Client + instance. @param[in] p_peer_handles Attribute handles on the Object Transfer Service server that you want this Object Transfer Service client to interact with. @retval NRF_SUCCESS If the connection handle was successfully stored in the Object Transfer Service instance. @retval NRF_ERROR_NULL If any of the input parameters are NULL. + @retval err_code Otherwise, this API propagates the error code returned by function + @ref nrf_ble_gq_conn_handle_register. */ ret_code_t nrf_ble_ots_c_handles_assign(nrf_ble_ots_c_t * const p_ots_c, uint16_t const conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c index 965c9b0..2b58bc6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -55,79 +55,144 @@ NRF_LOG_MODULE_REGISTER(); #define MODULE_INITIALIZED (p_ots_c->initialized) /**< Macro designating whether the module has been initialized properly. */ -static void on_l2cap_setup_complete(nrf_ble_ots_c_t * const p_ots_c, +/**@brief Function for handling the BLE_L2CAP_EVT_CH_SETUP event. + * + * @param[in] p_ots_c Object Transfer Service Instance. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_l2cap_ch_setup_complete(nrf_ble_ots_c_t * const p_ots_c, ble_evt_t const * const p_ble_evt) { p_ots_c->local_cid = p_ble_evt->evt.l2cap_evt.local_cid; p_ots_c->ch_setup.tx_params.peer_mps = p_ble_evt->evt.l2cap_evt.params.ch_setup.tx_params.peer_mps; - p_ots_c->ch_setup.tx_params.tx_mps = p_ble_evt->evt.l2cap_evt.params.ch_setup.tx_params.tx_mps; - p_ots_c->ch_setup.tx_params.tx_mtu = p_ble_evt->evt.l2cap_evt.params.ch_setup.tx_params.tx_mtu; + p_ots_c->ch_setup.tx_params.tx_mtu = p_ble_evt->evt.l2cap_evt.params.ch_setup.tx_params.tx_mtu; p_ots_c->ch_setup.tx_params.credits = p_ble_evt->evt.l2cap_evt.params.ch_setup.tx_params.credits; - p_ots_c->current_credits = p_ots_c->ch_setup.tx_params.credits; } -static void send_next_mtu(nrf_ble_ots_c_t * const p_ots_c) +/**@brief This function sends the next MTU of the object. + * + * @param[in] p_ots_c Object Transfer Service Instance. + */ +static void send_resume(nrf_ble_ots_c_t * const p_ots_c) { - // Remaining bytes to transmit. - if(p_ots_c->transmitted_bytes < p_ots_c->current_obj->len) + ret_code_t err_code; + uint16_t tx_size; + + tx_size = MIN((p_ots_c->current_obj->len - p_ots_c->transmitted_bytes), + p_ots_c->ch_setup.tx_params.tx_mtu); + + ble_data_t obj; + obj.len = tx_size; + obj.p_data = &p_ots_c->current_obj->p_data[p_ots_c->transmitted_bytes]; + + err_code = sd_ble_l2cap_ch_tx(p_ots_c->conn_handle, p_ots_c->local_cid, &obj); + + if (err_code == NRF_ERROR_RESOURCES) + { + return; // Too many SDUs queued for transmission, the transmission will be tried again on the next BLE_L2CAP_EVT_CH_TX event. + } + if(err_code != NRF_SUCCESS && p_ots_c->err_handler != NULL) + { + p_ots_c->err_handler(err_code); + } +} + + +/**@brief This function receives the next of the object. + * + * @param[in] p_ots_c Object Transfer Service Instance. + */ +static void receive_resume(nrf_ble_ots_c_t * const p_ots_c) +{ + ret_code_t err_code; + ble_data_t sdu_buf; + + sdu_buf.p_data = &p_ots_c->current_obj->p_data[p_ots_c->received_bytes]; + sdu_buf.len = p_ots_c->current_obj->len - p_ots_c->received_bytes; + + err_code = sd_ble_l2cap_ch_rx(p_ots_c->conn_handle, + p_ots_c->local_cid, + &sdu_buf); + + if (err_code == NRF_ERROR_RESOURCES) + { + return; // Too many SDUs queued for transmission, the transmission will be tried again on the next BLE_L2CAP_EVT_CH_RX event. + } + + if(err_code != NRF_SUCCESS && p_ots_c->err_handler != NULL) { - ret_code_t err_code; - uint16_t tx_size; - - tx_size = MIN((p_ots_c->current_obj->len - p_ots_c->transmitted_bytes), - p_ots_c->ch_setup.tx_params.tx_mtu); - ble_data_t obj; - obj.len = tx_size; - obj.p_data = &p_ots_c->current_obj->p_data[p_ots_c->transmitted_bytes]; - err_code = sd_ble_l2cap_ch_tx(p_ots_c->conn_handle, p_ots_c->local_cid, &obj); - if (err_code == NRF_ERROR_RESOURCES) - { - return; // Too many SDUs queued for transmission, the transmission will be tried again on the next BLE_L2CAP_EVT_CH_TX event. - } - if(err_code != NRF_SUCCESS && p_ots_c->err_handler != NULL) - { - p_ots_c->err_handler(err_code); - } + p_ots_c->err_handler(err_code); } } -static void on_l2cap_ch_tx(nrf_ble_ots_c_t * const p_ots_c, - ble_evt_t const * const p_ble_evt) +/**@brief Function for handling the BLE_L2CAP_EVT_CH_TX event. + * + * @param[in] p_ots_c Object Transfer Service Instance. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_l2cap_ch_tx(nrf_ble_ots_c_t * const p_ots_c, ble_evt_t const * const p_ble_evt) { - NRF_LOG_INFO("Bytes sent: %i", p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len); - NRF_LOG_HEXDUMP_INFO(p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.p_data, - p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len); + if(p_ots_c->local_cid != p_ble_evt->evt.l2cap_evt.local_cid) + { + return; + } + + NRF_LOG_DEBUG("Bytes sent in the previous PDU: %i", + p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len); + NRF_LOG_HEXDUMP_DEBUG(p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.p_data, + p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len); p_ots_c->transmitted_bytes += p_ble_evt->evt.l2cap_evt.params.tx.sdu_buf.len; + uint16_t remaining_tx_bytes = p_ots_c->current_obj->len - p_ots_c->transmitted_bytes; + + NRF_LOG_DEBUG("Total bytes transmitted: %i ", + (p_ots_c->transmitted_bytes)); + NRF_LOG_DEBUG("Total bytes remaining: %i", + (remaining_tx_bytes)); + + if (remaining_tx_bytes == 0) + { + nrf_ble_ots_c_evt_t evt; - NRF_LOG_INFO("\r\n Remaining bytes to send: %i", - (p_ots_c->current_obj->len - p_ots_c->transmitted_bytes)); - p_ots_c->current_credits --; - NRF_LOG_INFO("\r\n Remaining Credits: %i", - (p_ots_c->current_credits)); - if (p_ots_c->current_credits > 0) + evt.evt_type = NRF_BLE_OTS_C_EVT_OBJ_WRITE; + evt.params.object.len = p_ots_c->current_obj->len; + evt.params.object.p_data = p_ots_c->current_obj->p_data; + p_ots_c->evt_handler(&evt); + } + else { - send_next_mtu(p_ots_c); + send_resume(p_ots_c); } } +/**@brief Function for handling the BLE_L2CAP_EVT_CH_TR event. + * + * @param[in] p_ots_c Object Transfer Service Instance. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ static void on_l2cap_ch_rx(nrf_ble_ots_c_t * const p_ots_c, - ble_evt_t const * const p_ble_evt) + ble_evt_t const * const p_ble_evt) { - NRF_LOG_INFO("Bytes received: %i", p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); - NRF_LOG_HEXDUMP_INFO(p_ble_evt->evt.l2cap_evt.params.rx.sdu_buf.p_data, - p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); + if(p_ots_c->local_cid != p_ble_evt->evt.l2cap_evt.local_cid) + { + return; + } - memcpy(&p_ots_c->current_obj->p_data[p_ots_c->received_bytes], + NRF_LOG_DEBUG("Bytes received: %i", p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); + NRF_LOG_HEXDUMP_DEBUG(p_ble_evt->evt.l2cap_evt.params.rx.sdu_buf.p_data, + p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); + + memcpy(&p_ots_c->current_obj->p_data[p_ots_c->received_bytes], //Not needed`? buffer provied p_ble_evt->evt.l2cap_evt.params.rx.sdu_buf.p_data, p_ble_evt->evt.l2cap_evt.params.rx.sdu_len); + p_ots_c->received_bytes += p_ble_evt->evt.l2cap_evt.params.rx.sdu_len; - NRF_LOG_INFO("Remaining bytes to received: %i", (p_ots_c->current_obj->len - p_ots_c->received_bytes)); + uint16_t remaining_bytes = (p_ots_c->current_obj->len - p_ots_c->received_bytes); - if(p_ots_c->received_bytes >= p_ots_c->current_obj->len) + if(remaining_bytes == 0) { nrf_ble_ots_c_evt_t evt; @@ -138,43 +203,63 @@ static void on_l2cap_ch_rx(nrf_ble_ots_c_t * const p_ots_c, } else { - ret_code_t err_code; + receive_resume(p_ots_c); + } +} - ble_data_t sdu_buf; - sdu_buf.p_data = &p_ots_c->current_obj->p_data[p_ots_c->received_bytes]; - sdu_buf.len = p_ots_c->current_obj->len; - err_code = sd_ble_l2cap_ch_rx(p_ots_c->conn_handle, - p_ots_c->local_cid, - &sdu_buf); - UNUSED_PARAMETER(err_code); - } - +/**@brief Function for handling the BLE_L2CAP_EVT_CH_RELEASED event. + * + * @param[in] p_ots_c Object Transfer Service Instance. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_l2cap_ch_released(nrf_ble_ots_c_t * const p_ots_c, + ble_evt_t const * const p_ble_evt) +{ + nrf_ble_ots_c_evt_t evt; + + evt.evt_type = NRF_BLE_OTS_C_EVT_CHANNEL_RELEASED; + p_ots_c->evt_handler(&evt); } -static void on_l2cap_credit(nrf_ble_ots_c_t * const p_ots_c, - ble_evt_t const * const p_ble_evt) +ret_code_t nrf_ble_ots_c_l2cap_obj_send(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj) { - p_ots_c->current_credits = p_ble_evt->evt.l2cap_evt.params.credit.credits; - send_next_mtu(p_ots_c); + VERIFY_MODULE_INITIALIZED(); + VERIFY_PARAM_NOT_NULL(p_ots_c); + VERIFY_PARAM_NOT_NULL(p_obj); + + ret_code_t err_code; + uint16_t tx_size; + + p_ots_c->transmitted_bytes = 0; + tx_size = MIN(p_obj->len, p_ots_c->ch_setup.tx_params.tx_mtu); + p_ots_c->current_obj = p_obj; + + ble_data_t obj; + obj.len = tx_size; + obj.p_data = p_obj->p_data; + err_code = sd_ble_l2cap_ch_tx(p_ots_c->conn_handle, p_ots_c->local_cid, &obj); + return err_code; } -static void on_l2cap_released(nrf_ble_ots_c_t * const p_ots_c, - ble_evt_t const * const p_ble_evt) +ret_code_t nrf_ble_ots_c_l2cap_obj_receive(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj) { - nrf_ble_ots_c_evt_t evt; + uint32_t err_code; + p_ots_c->received_bytes = 0; + p_ots_c->current_obj = p_obj; - evt.evt_type = NRF_BLE_OTS_C_EVT_CHANNEL_RELEASED; - p_ots_c->evt_handler(&evt); + err_code = sd_ble_l2cap_ch_rx(p_ots_c->conn_handle, + p_ots_c->local_cid, + p_ots_c->current_obj); + return err_code; } void ots_c_l2cap_on_ble_evt(nrf_ble_ots_c_t * const p_ots_c, ble_evt_t const * const p_ble_evt) { - VERIFY_MODULE_INITIALIZED_VOID(); VERIFY_PARAM_NOT_NULL_VOID(p_ots_c); VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt); @@ -183,11 +268,12 @@ void ots_c_l2cap_on_ble_evt(nrf_ble_ots_c_t * const p_ots_c, { return; } + switch (p_ble_evt->header.evt_id) { case BLE_L2CAP_EVT_CH_SETUP: NRF_LOG_DEBUG("BLE_L2CAP_EVT_CH_SETUP"); - on_l2cap_setup_complete(p_ots_c, p_ble_evt); + on_l2cap_ch_setup_complete(p_ots_c, p_ble_evt); break; case BLE_L2CAP_EVT_CH_TX: @@ -202,43 +288,15 @@ void ots_c_l2cap_on_ble_evt(nrf_ble_ots_c_t * const p_ots_c, case BLE_L2CAP_EVT_CH_CREDIT: NRF_LOG_DEBUG("BLE_L2CAP_EVT_CH_CREDIT"); - on_l2cap_credit(p_ots_c, p_ble_evt); break; + case BLE_L2CAP_EVT_CH_RELEASED: NRF_LOG_DEBUG("BLE_L2CAP_EVT_CH_RELEASED"); - on_l2cap_released(p_ots_c, p_ble_evt); + on_l2cap_ch_released(p_ots_c, p_ble_evt); break; + default: break; } } - - -ret_code_t nrf_ble_ots_c_l2cap_obj_send(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj) -{ - ret_code_t err_code; - uint16_t tx_size; - p_ots_c->transmitted_bytes = 0; - tx_size = MIN(p_obj->len, p_ots_c->ch_setup.tx_params.tx_mtu); - p_ots_c->current_obj = p_obj; - - ble_data_t obj; - obj.len = tx_size; - obj.p_data = p_obj->p_data; - err_code = sd_ble_l2cap_ch_tx(p_ots_c->conn_handle, p_ots_c->local_cid, &obj); - return err_code; -} - - -ret_code_t nrf_ble_ots_c_l2cap_obj_receive(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj) -{ - uint32_t err_code; - p_ots_c->received_bytes = 0; - p_ots_c->current_obj = p_obj; - err_code = sd_ble_l2cap_ch_rx(p_ots_c->conn_handle, - p_ots_c->local_cid, - p_ots_c->current_obj); - return err_code; -} - #endif // NRF_MODULE_ENABLED(BLE_OTS_C_L2CAP) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h index bb9495a..d9599fe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_l2cap.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -71,7 +71,7 @@ extern "C" { @param[in] p_ble_evt Pointer to the BLE event received. */ void ots_c_l2cap_on_ble_evt(nrf_ble_ots_c_t * const p_ots_c, - ble_evt_t const * const p_ble_evt); + ble_evt_t const * const p_ble_evt); /**@brief Function sending an object. @@ -81,6 +81,9 @@ void ots_c_l2cap_on_ble_evt(nrf_ble_ots_c_t * const p_ots_c, @param[in,out] p_ots_c Pointer to Object Transfer client structure. @param[in,out] p_obj Pointer to object that will be sent to the peer. + + @retval NRF_ERROR_INVALID_STATE if the Object Transfer module is not initialized. + @retval NRF_ERROR_NULL if any of the input parameters are NULL. */ ret_code_t nrf_ble_ots_c_l2cap_obj_send(nrf_ble_ots_c_t * const p_ots_c, ble_data_t * p_obj); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c index fc02e2b..5ae4f43 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -72,8 +72,8 @@ static void oacp_response(nrf_ble_ots_c_t const * const p_ots_c, /**@brief Function for handling the indication and notifications from the GATT Service Server. - @param[in] p_ots_c Pointer to Object Transfer client structure. - @param[in] p_ble_gattc_evt Pointer to a gattc event. + @param[in] p_ots_c Pointer to Object Transfer client structure. + @param[in] p_ble_gattc_evt Pointer to a GATTC event. */ static void on_hvx(nrf_ble_ots_c_t const * const p_ots_c, ble_gattc_evt_t const * const p_ble_gattc_evt) @@ -103,10 +103,10 @@ static void on_hvx(nrf_ble_ots_c_t const * const p_ots_c, /**@brief Function for checking whether the peer's Object Transfer Service instance has been discovered. - @param[in] p_ots_c Pointer to the GATT Service client structure instance. + @param[in] p_ots_c Pointer to the GATT Service Client structure instance. - @return True if the Object Transfer service handles are valid. - @return False if the Object Transfer service handles are invalid + @return True if the Object Transfer Service handles are valid. + @return False if the Object Transfer Service handles are invalid. */ static bool ots_gatt_handles_are_valid(const nrf_ble_ots_c_t * const p_ots_c) { @@ -118,7 +118,7 @@ static bool ots_gatt_handles_are_valid(const nrf_ble_ots_c_t * const p_ots_c) ret_code_t nrf_ble_ots_c_indication_enable(nrf_ble_ots_c_t * const p_ots_c, - bool const enable) + bool const indication_enable) { VERIFY_MODULE_INITIALIZED(); VERIFY_TRUE(ots_gatt_handles_are_valid(p_ots_c), NRF_ERROR_INVALID_STATE); @@ -128,21 +128,25 @@ ret_code_t nrf_ble_ots_c_indication_enable(nrf_ble_ots_c_t * const p_ots_c, return NRF_ERROR_INVALID_STATE; } - ret_code_t err_code = NRF_SUCCESS; + uint8_t cccd[BLE_CCCD_VALUE_LEN]; + nrf_ble_gq_req_t cccd_req; + uint16_t cccd_val = (indication_enable) ? BLE_GATT_HVX_INDICATION : 0; - ble_gattc_write_params_t gattc_params; - - memset(&gattc_params, 0x00, sizeof(gattc_params)); - uint16_t cccd_val = (enable) ? BLE_GATT_HVX_INDICATION : 0; + cccd[0] = LSB_16(cccd_val); + cccd[1] = MSB_16(cccd_val); - gattc_params.handle = p_ots_c->service.object_action_cp_cccd.handle; - gattc_params.len = BLE_CCCD_VALUE_LEN; - gattc_params.p_value = (uint8_t *)&cccd_val; - gattc_params.offset = 0; - gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; + memset(&cccd_req, 0, sizeof(nrf_ble_gq_req_t)); - err_code = sd_ble_gattc_write(p_ots_c->conn_handle, &gattc_params); - return err_code; + cccd_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + cccd_req.error_handler.cb = p_ots_c->gatt_err_handler; + cccd_req.error_handler.p_ctx = (nrf_ble_ots_c_t *)p_ots_c; + cccd_req.params.gattc_write.handle = p_ots_c->service.object_action_cp_cccd.handle; + cccd_req.params.gattc_write.len = BLE_CCCD_VALUE_LEN; + cccd_req.params.gattc_write.offset = 0; + cccd_req.params.gattc_write.p_value = cccd; + cccd_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ots_c->p_gatt_queue, &cccd_req, p_ots_c->conn_handle); } @@ -173,16 +177,22 @@ ret_code_t nrf_ble_ots_c_oacp_write_object(nrf_ble_ots_c_t * const p_ots_c, uint i += uint32_encode(len, &val[i]); val[i] |= (truncate << 0); - ble_gattc_write_params_t gattc_params; - memset(&gattc_params, 0, sizeof(ble_gattc_write_params_t)); - gattc_params.handle = p_ots_c->service.object_action_cp_char.handle_value; - gattc_params.len = i; - gattc_params.p_value = (uint8_t *)val; - gattc_params.offset = 0; - gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; + nrf_ble_gq_req_t write_req; + + memset(&write_req, 0, sizeof(nrf_ble_gq_req_t)); + + write_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + write_req.error_handler.cb = p_ots_c->gatt_err_handler; + write_req.error_handler.p_ctx = (nrf_ble_ots_c_t *)p_ots_c; + write_req.params.gattc_write.handle = p_ots_c->service.object_action_cp_char.handle_value; + write_req.params.gattc_write.len = i; + write_req.params.gattc_write.offset = 0; + write_req.params.gattc_write.p_value = val; + write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + err_code = nrf_ble_gq_item_add(p_ots_c->p_gatt_queue, &write_req, p_ots_c->conn_handle); - err_code = sd_ble_gattc_write(p_ots_c->conn_handle, &gattc_params); if(err_code != NRF_SUCCESS) { p_ots_c->err_handler(err_code); @@ -200,8 +210,6 @@ ret_code_t nrf_ble_ots_c_oacp_read_object(nrf_ble_ots_c_t * const p_ots_c, uint3 return NRF_ERROR_INVALID_STATE; } - ret_code_t err_code = NRF_SUCCESS; - uint8_t val[BLE_OTS_OACP_READ_OP_SIZE]; memset(val, 0, sizeof(val)); @@ -216,17 +224,20 @@ ret_code_t nrf_ble_ots_c_oacp_read_object(nrf_ble_ots_c_t * const p_ots_c, uint3 //Len i += uint32_encode(len, &val[i]); - ble_gattc_write_params_t gattc_params; - memset(&gattc_params, 0, sizeof(ble_gattc_write_params_t)); + nrf_ble_gq_req_t write_req; - gattc_params.handle = p_ots_c->service.object_action_cp_char.handle_value; - gattc_params.len = sizeof(val); - gattc_params.p_value = (uint8_t *)val; - gattc_params.offset = 0; - gattc_params.write_op = BLE_GATT_OP_WRITE_REQ; + memset(&write_req, 0, sizeof(nrf_ble_gq_req_t)); - err_code = sd_ble_gattc_write(p_ots_c->conn_handle, &gattc_params); - return err_code; + write_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE; + write_req.error_handler.cb = p_ots_c->gatt_err_handler; + write_req.error_handler.p_ctx = (nrf_ble_ots_c_t *)p_ots_c; + write_req.params.gattc_write.handle = p_ots_c->service.object_action_cp_char.handle_value; + write_req.params.gattc_write.len = sizeof(val); + write_req.params.gattc_write.offset = 0; + write_req.params.gattc_write.p_value = val; + write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ; + + return nrf_ble_gq_item_add(p_ots_c->p_gatt_queue, &write_req, p_ots_c->conn_handle); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h index 8ab98b4..ccc99d8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/experimental_nrf_ble_ots_c/nrf_ble_ots_c_oacp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -45,7 +45,7 @@ * @ingroup nrf_ble_ots_c * @brief Object Action Control Point module * - * @details This is the Object Action Control Point module of the Object Transfer Service (OTS) client. + * @details This is the Object Action Control Point module of the Object Transfer Service (OTS) Client. */ #ifndef NRF_BLE_OTS_C_OACP_H__ @@ -67,11 +67,11 @@ extern "C" { /**@brief Function for enabling remote indication. - @param[in,out] p_ots_c Pointer to Object Transfer client structure. - @param[in] enable True to enable Object Action Control Point (OACP) indication, false to disable. + @param[in,out] p_ots_c Pointer to Object Transfer Client structure. + @param[in] enable True to enable Object Action Control Point (OACP) indication; false to disable. @retval NRF_SUCCESS Operation success. - @return If functions from other modules return errors to this function, + @retval err_code If functions from other modules return errors to this function, the @ref nrf_error are propagated. */ ret_code_t nrf_ble_ots_c_indication_enable(nrf_ble_ots_c_t * const p_ots_c, @@ -80,34 +80,32 @@ ret_code_t nrf_ble_ots_c_indication_enable(nrf_ble_ots_c_t * const p_ots_c, /**@brief Function for requesting a write of an object. - @details With this function we let the peer know the length of the object we want to write. + @details This function informs the peer about the length of the object to write. (The object itself is not written by this function.) - The peer will indicate a response on the Object Action Control Point. + The peer indicates a response on the Object Action Control Point. If the write is accepted (the event NRF_BLE_OTS_C_OACP_RES_SUCCESS ), an object can be transfered with @ref nrf_ble_ots_c_l2cap_obj_send. - @param[in,out] p_ots_c Pointer to Object Transfer client structure. + @param[in,out] p_ots_c Pointer to Object Transfer Client structure. @param[in] offset Offset of the write. - @param[in] len length of the object to write. + @param[in] len Length of the object to write. @param[in] truncate True to let the write truncate on the object. @retval NRF_SUCCESS Operation success. @retval NRF_ERROR_INVALID_STATE Module is not initialized, or the handles of the peer OACP are invalid. - @return If functions from other modules return errors to this function, - the @ref nrf_error are propagated. + @retval err_code Otherwise, this API propagates the error code returned by functions: @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ble_ots_c_oacp_write_object(nrf_ble_ots_c_t * const p_ots_c, uint32_t offset, uint32_t len, bool truncate); /**@brief Function for requesting a read of an object. - @param[in,out] p_ots_c Pointer to Object Transfer client structure. + @param[in,out] p_ots_c Pointer to Object Transfer Client structure. @param[in] offset Offset of the read. - @param[in] len length of the read. + @param[in] len Length of the read. @retval NRF_SUCCESS Operation success. - @return If functions from other modules return errors to this function, - the @ref nrf_error are propagated. + @return Otherwise this API propagates the error code returned by functions: @ref nrf_ble_gq_item_add. */ ret_code_t nrf_ble_ots_c_oacp_read_object(nrf_ble_ots_c_t * const p_ots_c, uint32_t offset, uint32_t len); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c index ac3cd11..294ad16 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h index 3db9f4b..713c23b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/ble_services/nrf_ble_bms/nrf_ble_bms.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_advdata.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_advdata.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_advdata.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_advdata.c index 2a6fb39..caa18a7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_advdata.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_advdata.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "ble_advdata.h" #include "ble_gap.h" @@ -44,39 +44,23 @@ // NOTE: For now, Security Manager Out of Band Flags (OOB) are omitted from the advertising data. -#define AD_LENGTH_FIELD_SIZE 1UL /**< Advertising Data and Scan Response format contains 1 octet for the length. */ -#define AD_TYPE_FIELD_SIZE 1UL /**< Advertising Data and Scan Response format contains 1 octet for the AD type. */ -#define AD_DATA_OFFSET (AD_LENGTH_FIELD_SIZE + AD_TYPE_FIELD_SIZE) /**< Offset for the AD data field of the Advertising Data and Scan Response format. */ - -#define AD_TYPE_BLE_DEVICE_ADDR_TYPE_SIZE 1UL /**< Data size (in octets) of the Address type of the LE Bluetooth Device Address AD type. */ -#define AD_TYPE_BLE_DEVICE_ADDR_DATA_SIZE (BLE_GAP_ADDR_LEN + \ - AD_TYPE_BLE_DEVICE_ADDR_TYPE_SIZE) /**< Data size (in octets) of the LE Bluetooth Device Address AD type. */ -#define AD_TYPE_BLE_DEVICE_ADDR_SIZE (AD_DATA_OFFSET + \ - AD_TYPE_BLE_DEVICE_ADDR_DATA_SIZE) /**< Size (in octets) of the LE Bluetooth Device Address AD type. */ -#define AD_TYPE_APPEARANCE_DATA_SIZE 2UL /**< Data size (in octets) of the Appearance AD type. */ -#define AD_TYPE_APPEARANCE_SIZE (AD_DATA_OFFSET + \ - AD_TYPE_APPEARANCE_DATA_SIZE) /**< Size (in octets) of the Appearance AD type. */ -#define AD_TYPE_FLAGS_DATA_SIZE 1UL /**< Data size (in octets) of the Flags AD type. */ -#define AD_TYPE_FLAGS_SIZE (AD_DATA_OFFSET + \ - AD_TYPE_FLAGS_DATA_SIZE) /**< Size (in octets) of the Flags AD type. */ -#define AD_TYPE_TX_POWER_LEVEL_DATA_SIZE 1UL /**< Data size (in octets) of the TX Power Level AD type. */ -#define AD_TYPE_TX_POWER_LEVEL_SIZE (AD_DATA_OFFSET + \ - AD_TYPE_TX_POWER_LEVEL_DATA_SIZE) /**< Size (in octets) of the TX Power Level AD type. */ -#define AD_TYPE_CONN_INT_DATA_SIZE 4UL /**< Data size (in octets) of the Slave Connection Interval Range AD type. */ -#define AD_TYPE_CONN_INT_SIZE (AD_DATA_OFFSET + \ - AD_TYPE_CONN_INT_DATA_SIZE) /**< Data size (in octets) of the Slave Connection Interval Range AD type. */ -#define AD_TYPE_MANUF_SPEC_DATA_ID_SIZE 2UL /**< Size (in octets) of the Company Identifier Code, which is a part of the Manufacturer Specific Data AD type. */ -#define AD_TYPE_SERV_DATA_16BIT_UUID_SIZE 2UL /**< Size (in octets) of the 16-bit UUID, which is a part of the Service Data AD type. */ // Types of LE Bluetooth Device Address AD type #define AD_TYPE_BLE_DEVICE_ADDR_TYPE_PUBLIC 0UL #define AD_TYPE_BLE_DEVICE_ADDR_TYPE_RANDOM 1UL -static uint32_t ble_device_addr_encode(uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +#define UUID16_SIZE 2 /**< Size of 16 bit UUID. */ +#define UUID32_SIZE 4 /**< Size of 32 bit UUID. */ +#define UUID128_SIZE 16 /**< Size of 128 bit UUID. */ + +#define N_AD_TYPES 2 /**< The number of Advertising data types to search for at a time. */ + + +static ret_code_t ble_device_addr_encode(uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { - uint32_t err_code; + ret_code_t err_code; ble_gap_addr_t device_addr; // Check for buffer overflow. @@ -86,11 +70,7 @@ static uint32_t ble_device_addr_encode(uint8_t * p_encoded_data, } // Get BLE address. - #if (NRF_SD_BLE_API_VERSION >= 3) - err_code = sd_ble_gap_addr_get(&device_addr); - #else - err_code = sd_ble_gap_address_get(&device_addr); - #endif + err_code = sd_ble_gap_addr_get(&device_addr); VERIFY_SUCCESS(err_code); // Encode LE Bluetooth Device Address. @@ -114,15 +94,15 @@ static uint32_t ble_device_addr_encode(uint8_t * p_encoded_data, return NRF_SUCCESS; } -static uint32_t name_encode(const ble_advdata_t * p_advdata, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t name_encode(const ble_advdata_t * p_advdata, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { - uint32_t err_code; - uint16_t rem_adv_data_len; - uint16_t actual_length; - uint8_t adv_data_format; + ret_code_t err_code; + uint16_t rem_adv_data_len; + uint16_t actual_length; + uint8_t adv_data_format; // Validate parameters @@ -148,7 +128,11 @@ static uint32_t name_encode(const ble_advdata_t * p_advdata, VERIFY_SUCCESS(err_code); // Check if device intend to use short name and it can fit available data size. - if ((p_advdata->name_type == BLE_ADVDATA_FULL_NAME) && (actual_length <= rem_adv_data_len)) + // If the name is shorter than the preferred short name length then it is no longer + // a short name and is in fact the complete name of the device. + if (((p_advdata->name_type == BLE_ADVDATA_FULL_NAME) || + (actual_length <= p_advdata->short_name_len)) && + (actual_length <= rem_adv_data_len)) { // Complete device name can fit, setting Complete Name in Adv Data. adv_data_format = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME; @@ -190,12 +174,12 @@ static uint32_t name_encode(const ble_advdata_t * p_advdata, } -static uint32_t appearance_encode(uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t appearance_encode(uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { - uint32_t err_code; - uint16_t appearance; + ret_code_t err_code; + uint16_t appearance; // Check for buffer overflow. if (((*p_offset) + AD_TYPE_APPEARANCE_SIZE) > max_size) @@ -217,10 +201,10 @@ static uint32_t appearance_encode(uint8_t * p_encoded_data, return NRF_SUCCESS; } -static uint32_t flags_encode(int8_t flags, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t flags_encode(int8_t flags, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { // Check for buffer overflow. if (((*p_offset) + AD_TYPE_FLAGS_SIZE) > max_size) @@ -239,10 +223,10 @@ static uint32_t flags_encode(int8_t flags, return NRF_SUCCESS; } -static uint32_t tx_power_level_encode(int8_t tx_power_level, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t tx_power_level_encode(int8_t tx_power_level, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { // Check for buffer overflow. if (((*p_offset) + AD_TYPE_TX_POWER_LEVEL_SIZE) > max_size) @@ -263,12 +247,12 @@ static uint32_t tx_power_level_encode(int8_t tx_power_level, } -static uint32_t uuid_list_sized_encode(const ble_advdata_uuid_list_t * p_uuid_list, - uint8_t adv_type, - uint8_t uuid_size, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t uuid_list_sized_encode(const ble_advdata_uuid_list_t * p_uuid_list, + uint8_t adv_type, + uint8_t uuid_size, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { int i; bool is_heading_written = false; @@ -277,7 +261,7 @@ static uint32_t uuid_list_sized_encode(const ble_advdata_uuid_list_t * p_uuid_li for (i = 0; i < p_uuid_list->uuid_cnt; i++) { - uint32_t err_code; + ret_code_t err_code; uint8_t encoded_size; ble_uuid_t uuid = p_uuid_list->p_uuids[i]; @@ -328,14 +312,14 @@ static uint32_t uuid_list_sized_encode(const ble_advdata_uuid_list_t * p_uuid_li } -static uint32_t uuid_list_encode(const ble_advdata_uuid_list_t * p_uuid_list, - uint8_t adv_type_16, - uint8_t adv_type_128, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t uuid_list_encode(const ble_advdata_uuid_list_t * p_uuid_list, + uint8_t adv_type_16, + uint8_t adv_type_128, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { - uint32_t err_code; + ret_code_t err_code; // Encode 16 bit UUIDs. err_code = uuid_list_sized_encode(p_uuid_list, @@ -359,7 +343,7 @@ static uint32_t uuid_list_encode(const ble_advdata_uuid_list_t * p_uuid_list, } -static uint32_t conn_int_check(const ble_advdata_conn_int_t *p_conn_int) +static ret_code_t conn_int_check(const ble_advdata_conn_int_t *p_conn_int) { // Check Minimum Connection Interval. if ((p_conn_int->min_conn_interval < 0x0006) || @@ -396,12 +380,12 @@ static uint32_t conn_int_check(const ble_advdata_conn_int_t *p_conn_int) } -static uint32_t conn_int_encode(const ble_advdata_conn_int_t * p_conn_int, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t conn_int_encode(const ble_advdata_conn_int_t * p_conn_int, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { - uint32_t err_code; + ret_code_t err_code; // Check for buffer overflow. if (((*p_offset) + AD_TYPE_CONN_INT_SIZE) > max_size) @@ -427,10 +411,10 @@ static uint32_t conn_int_encode(const ble_advdata_conn_int_t * p_conn_int, } -static uint32_t manuf_specific_data_encode(const ble_advdata_manuf_data_t * p_manuf_sp_data, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t manuf_specific_data_encode(const ble_advdata_manuf_data_t * p_manuf_sp_data, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { uint32_t data_size = AD_TYPE_MANUF_SPEC_DATA_ID_SIZE + p_manuf_sp_data->data.size; @@ -470,10 +454,10 @@ static uint32_t manuf_specific_data_encode(const ble_advdata_manuf_data_t * p_ma } // Implemented only for 16-bit UUIDs -static uint32_t service_data_encode(const ble_advdata_t * p_advdata, - uint8_t * p_encoded_data, - uint16_t * p_offset, - uint16_t max_size) +static ret_code_t service_data_encode(const ble_advdata_t * p_advdata, + uint8_t * p_encoded_data, + uint16_t * p_offset, + uint16_t max_size) { uint8_t i; @@ -522,12 +506,12 @@ static uint32_t service_data_encode(const ble_advdata_t * p_advdata, return NRF_SUCCESS; } -uint32_t ble_advdata_encode(ble_advdata_t const * const p_advdata, - uint8_t * const p_encoded_data, - uint16_t * const p_len) +ret_code_t ble_advdata_encode(ble_advdata_t const * const p_advdata, + uint8_t * const p_encoded_data, + uint16_t * const p_len) { - uint32_t err_code = NRF_SUCCESS; - uint16_t max_size = *p_len; + ret_code_t err_code = NRF_SUCCESS; + uint16_t max_size = *p_len; *p_len = 0; // Encode LE Bluetooth Device Address @@ -632,74 +616,223 @@ uint32_t ble_advdata_encode(ble_advdata_t const * const p_advdata, } -static uint32_t advdata_check(const ble_advdata_t * p_advdata) +uint16_t ble_advdata_search(uint8_t const * p_encoded_data, + uint16_t data_len, + uint16_t * p_offset, + uint8_t ad_type) { - // Flags must be included in advertising data, and the BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED flag must be set. - if ( - ((p_advdata->flags & BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) == 0) - ) + if ((p_encoded_data == NULL) || (p_offset == NULL)) { - return NRF_ERROR_INVALID_PARAM; + return 0; } - return NRF_SUCCESS; + uint16_t i = 0; + + while (((i < *p_offset) || (p_encoded_data[i + 1] != ad_type)) && (i < data_len)) + { + // Jump to next data. + i += (p_encoded_data[i] + 1); + } + + if (i >= data_len) + { + return 0; + } + else + { + uint16_t offset = i + 2; + uint16_t len = p_encoded_data[i] - 1; + if ((offset + len) > data_len) + { + // Malformed. Extends beyond provided data. + return 0; + } + *p_offset = offset; + return len; + } } -static uint32_t srdata_check(const ble_advdata_t * p_srdata) +uint8_t * ble_advdata_parse(uint8_t * p_encoded_data, + uint16_t data_len, + uint8_t ad_type) { - // Flags shall not be included in the scan response data. - if (p_srdata->flags) + uint16_t offset = 0; + uint16_t len = ble_advdata_search(p_encoded_data, data_len, &offset, ad_type); + + if (len == 0) { - return NRF_ERROR_INVALID_PARAM; + return NULL; } + else + { + return &p_encoded_data[offset]; + } +} - return NRF_SUCCESS; + +bool ble_advdata_name_find(uint8_t const * p_encoded_data, + uint16_t data_len, + char const * p_target_name) +{ + uint16_t parsed_name_len; + uint8_t const * p_parsed_name; + uint16_t data_offset = 0; + + if (p_target_name == NULL) + { + return false; + } + + + parsed_name_len = ble_advdata_search(p_encoded_data, + data_len, + &data_offset, + BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME); + + p_parsed_name = &p_encoded_data[data_offset]; + + if ( (data_offset != 0) + && (parsed_name_len != 0) + && (strlen(p_target_name) == parsed_name_len) + && (memcmp(p_target_name, p_parsed_name, parsed_name_len) == 0)) + { + return true; + } + + return false; } -uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata) +bool ble_advdata_short_name_find(uint8_t const * p_encoded_data, + uint16_t data_len, + char const * p_target_name, + uint8_t const short_name_min_len) { - uint32_t err_code; - uint16_t len_advdata = BLE_GAP_ADV_MAX_SIZE; - uint16_t len_srdata = BLE_GAP_ADV_MAX_SIZE; - uint8_t encoded_advdata[BLE_GAP_ADV_MAX_SIZE]; - uint8_t encoded_srdata[BLE_GAP_ADV_MAX_SIZE]; - uint8_t * p_encoded_advdata; - uint8_t * p_encoded_srdata; - - // Encode advertising data (if supplied). - if (p_advdata != NULL) - { - err_code = advdata_check(p_advdata); - VERIFY_SUCCESS(err_code); + uint16_t parsed_name_len; + uint8_t const * p_parsed_name; + uint16_t data_offset = 0; - err_code = ble_advdata_encode(p_advdata, encoded_advdata, &len_advdata); - VERIFY_SUCCESS(err_code); - p_encoded_advdata = encoded_advdata; + if (p_target_name == NULL) + { + return false; } - else + + parsed_name_len = ble_advdata_search(p_encoded_data, + data_len, + &data_offset, + BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME); + + p_parsed_name = &p_encoded_data[data_offset]; + + if ( (data_offset != 0) + && (parsed_name_len != 0) + && (parsed_name_len >= short_name_min_len) + && (parsed_name_len < strlen(p_target_name)) + && (memcmp(p_target_name, p_parsed_name, parsed_name_len) == 0)) { - p_encoded_advdata = NULL; - len_advdata = 0; + return true; } - // Encode scan response data (if supplied). - if (p_srdata != NULL) + return false; +} + + +bool ble_advdata_uuid_find(uint8_t const * p_encoded_data, + uint16_t data_len, + ble_uuid_t const * p_target_uuid) +{ + + ret_code_t err_code; + uint16_t data_offset = 0; + uint8_t raw_uuid_len = UUID128_SIZE; + uint8_t const * p_parsed_uuid; + uint16_t parsed_uuid_len = data_len; + uint8_t raw_uuid[UUID128_SIZE]; + uint8_t ad_types[N_AD_TYPES]; + + err_code = sd_ble_uuid_encode(p_target_uuid, &raw_uuid_len, raw_uuid); + + if ((p_encoded_data == NULL) || (err_code != NRF_SUCCESS)) { - err_code = srdata_check(p_srdata); - VERIFY_SUCCESS(err_code); + // Invalid p_encoded_data or p_target_uuid. + return false; + } - err_code = ble_advdata_encode(p_srdata, encoded_srdata, &len_srdata); - VERIFY_SUCCESS(err_code); - p_encoded_srdata = encoded_srdata; + switch (raw_uuid_len) + { + case UUID16_SIZE: + ad_types[0] = BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE; + ad_types[1] = BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE; + break; + + case UUID32_SIZE: + // Not currently supported by sd_ble_uuid_encode(). + ad_types[0] = BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE; + ad_types[1] = BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE; + break; + + case UUID128_SIZE: + ad_types[0] = BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE; + ad_types[1] = BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE; + break; + + default: + return false; } - else + + for (uint8_t i = 0; (i < N_AD_TYPES) && (data_offset == 0); i++) + { + parsed_uuid_len = ble_advdata_search(p_encoded_data, data_len, &data_offset, ad_types[i]); + } + + if (data_offset == 0) + { + // Could not find any relevant UUIDs in the encoded data. + return false; + } + + p_parsed_uuid = &p_encoded_data[data_offset]; + + // Verify if any UUID matches the given UUID. + for (uint16_t list_offset = 0; list_offset < parsed_uuid_len; list_offset += raw_uuid_len) + { + if (memcmp(&p_parsed_uuid[list_offset], raw_uuid, raw_uuid_len) == 0) + { + return true; + } + } + + // Could not find the UUID among the encoded data. + return false; +} + + +bool ble_advdata_appearance_find(uint8_t const * p_encoded_data, + uint16_t data_len, + uint16_t const * p_target_appearance) +{ + uint16_t data_offset = 0; + uint8_t appearance_len; + uint16_t decoded_appearance; + + appearance_len = ble_advdata_search(p_encoded_data, data_len, &data_offset, BLE_GAP_AD_TYPE_APPEARANCE); + + if ( (data_offset == 0) + || (p_target_appearance == NULL) + || (appearance_len == 0)) + { + // Could not find any Appearance in the encoded data, or invalid p_target_appearance. + return false; + } + + decoded_appearance = uint16_decode(&p_encoded_data[data_offset]); + + if (decoded_appearance == *p_target_appearance) { - p_encoded_srdata = NULL; - len_srdata = 0; + return true; } - // Pass encoded advertising data and/or scan response data to the stack. - return sd_ble_gap_adv_data_set(p_encoded_advdata, len_advdata, p_encoded_srdata, len_srdata); + // Could not find the appearance among the encoded data. + return false; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_advdata.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_advdata.h similarity index 62% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_advdata.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_advdata.h index b04fe68..88b645c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_advdata.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_advdata.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -53,7 +53,7 @@ #include #include #include "ble.h" -#include "app_util.h" +#include "sdk_common.h" #ifdef __cplusplus extern "C" { @@ -84,6 +84,8 @@ extern "C" { #define AD_TYPE_MANUF_SPEC_DATA_ID_SIZE 2UL /**< Size (in octets) of the Company Identifier Code, which is a part of the Manufacturer Specific Data AD type. */ #define AD_TYPE_SERV_DATA_16BIT_UUID_SIZE 2UL /**< Size (in octets) of the 16-bit UUID, which is a part of the Service Data AD type. */ +#define BLE_ADV_DATA_MATCH_FULL_NAME 0xff + /**@brief Security Manager TK value. */ typedef struct @@ -159,18 +161,15 @@ typedef struct ble_advdata_le_role_t le_role; /**< LE Role field. Included when different from @ref BLE_ADVDATA_ROLE_NOT_PRESENT. @warning This field can be used only for NFC. For BLE advertising, set it to NULL. */ ble_advdata_tk_value_t * p_tk_value; /**< Security Manager TK value field. Included when different from NULL. @warning This field can be used only for NFC. For BLE advertising, set it to NULL.*/ uint8_t * p_sec_mgr_oob_flags; /**< Security Manager Out Of Band Flags field. Included when different from NULL. @warning This field can be used only for NFC. For BLE advertising, set it to NULL.*/ -#if (NRF_SD_BLE_API_VERSION > 1) ble_gap_lesc_oob_data_t * p_lesc_data; /**< LE Secure Connections OOB data. Included when different from NULL. @warning This field can be used only for NFC. For BLE advertising, set it to NULL.*/ -#endif } ble_advdata_t; -/**@brief Function for encoding data in the Advertising and Scan Response data format - * (AD structures). +/**@brief Function for encoding data in the Advertising and Scan Response data format (AD structures). * * @details This function encodes data into the Advertising and Scan Response data format - * (AD structures) based on the selections in the supplied structures. This function can be used to - * create a payload of Advertising packet or Scan Response packet, or a payload of NFC - * message intended for initiating the Out-of-Band pairing. + * (AD structures) based on the fields in the supplied structures. This function can be + * used to create a payload of Advertising packet or Scan Response packet, or a payload of + * NFC message intended for initiating the Out-of-Band pairing. * * @param[in] p_advdata Pointer to the structure for specifying the content of encoded data. * @param[out] p_encoded_data Pointer to the buffer where encoded data will be returned. @@ -178,10 +177,11 @@ typedef struct * \c out: Length of encoded data. * * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in \p p_advdata. - * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could fit into the - * provided buffer or some encoded AD structure is too long and its - * length cannot be encoded with one octet. + * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in + * \p p_advdata. + * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could + * fit into the provided buffer or some encoded AD structure is too + * long and its length cannot be encoded with one octet. * * @warning This API may override the application's request to use the long name and use a short name * instead. This truncation will occur in case the long name does not fit the provided buffer size. @@ -192,36 +192,129 @@ typedef struct * However, it should be noted that this is just a preference that the application can specify, and * if the preference is too large to fit in the provided buffer, the name can be truncated further. */ -uint32_t ble_advdata_encode(ble_advdata_t const * const p_advdata, - uint8_t * const p_encoded_data, - uint16_t * const p_len); +ret_code_t ble_advdata_encode(ble_advdata_t const * const p_advdata, + uint8_t * const p_encoded_data, + uint16_t * const p_len); + -/**@brief Function for encoding and setting the advertising data and/or scan response data. +/**@brief Function for searching encoded Advertising or Scan Response data for specific data types. * - * @details This function encodes advertising data and/or scan response data based on the selections - * in the supplied structures, and passes the encoded data to the stack. + * @details This function searches through encoded data e.g. the data produced by + * @ref ble_advdata_encode, or the data found in Advertising reports + * (@ref BLE_GAP_EVT_ADV_REPORT), and gives the offset of the data within the data buffer. + * The data with type \p ad_type can be found at p_encoded_data[*p_offset] after calling + * the function. This function can iterate through multiple instances of data of one + * type by calling it again with the offset provided by the previous call. * - * @param[in] p_advdata Structure for specifying the content of the advertising data. - * Set to NULL if advertising data is not to be set. - * @param[in] p_srdata Structure for specifying the content of the scan response data. - * Set to NULL if scan response data is not to be set. + * Example code for finding multiple instances of one type of data: + * offset = 0; + * ble_advdata_search(&data, len, &offset, AD_TYPE); + * first_instance_of_data = data[offset]; + * ble_advdata_search(&data, len, &offset, AD_TYPE); + * second_instance_of_data = data[offset]; * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in \p p_advdata. - * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could fit into the - * advertising packet. The maximum size of the advertisement packet - * is @ref BLE_GAP_ADV_MAX_SIZE. + * @param[in] p_encoded_data The data buffer containing the encoded Advertising data. + * @param[in] data_len The length of the data buffer \p p_encoded_data. + * @param[inout] p_offset \c in: The offset to start searching from. + * \c out: The offset the data type can be found at. + * This value is not changed if the call returns 0. + * @param[in] ad_type The type of data to search for. * - * @warning This API may override the application's request to use the long name and use a short name - * instead. This truncation will occur in case the long name does not fit the provided buffer size. - * The application can specify a preferred short name length if truncation is required. - * For example, if the complete device name is ABCD_HRMonitor, the application can specify the short name - * length to be 8, so that the short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni - * if the available size for the short name is 9 or 12 respectively, to have a more appropriate short name. - * However, it should be noted that this is just a preference that the application can specify, and - * if the preference is too large to fit in the provided buffer, the name can be truncated further. + * @return The length of the found data, or 0 if no data was found with the the type \p ad_type, + * or if \p p_encoded_data or \p p_offset were NULL. + */ +uint16_t ble_advdata_search(uint8_t const * p_encoded_data, + uint16_t data_len, + uint16_t * p_offset, + uint8_t ad_type); + +/**@brief Function for getting specific data from encoded Advertising or Scan Response data. + * + * @details This function searches through encoded data e.g. the data produced by + * @ref ble_advdata_encode, or the data found in Advertising reports + * (@ref BLE_GAP_EVT_ADV_REPORT), and returns a pointer directly to the data within the + * data buffer. + * + * Example code: + * ad_type_data = ble_advdata_parse(&data, len, AD_TYPE); + * + * @param[in] p_encoded_data Data buffer containing the encoded Advertising data. + * @param[in] data_len Length of the data buffer \p p_encoded_data. + * @param[in] ad_type Type of data to search for. + * + * @return Pointer to the found data, or NULL if no data was found with the type \p ad_type, + * or if \p p_encoded_data or \p p_data_len were NULL. + */ +uint8_t * ble_advdata_parse(uint8_t * p_encoded_data, + uint16_t data_len, + uint8_t ad_type); + + +/**@brief Function for searching through encoded Advertising data for a complete local name. + * + * @param[in] p_encoded_data Data buffer containing the encoded Advertising data. + * @param[in] data_len Length of the data buffer \p p_encoded_data. + * @param[in] p_target_name Name to search for. + * + * @retval true If \p p_target_name was found among \p p_encoded_data, as a complete local name. + * @retval false If \p p_target_name was not found among \p p_encoded_data, or if \p p_encoded_data + * or \p p_target_name was NULL. + */ +bool ble_advdata_name_find(uint8_t const * p_encoded_data, + uint16_t data_len, + char const * p_target_name); + + +/**@brief Function for searching through encoded Advertising data for a device shortened name. + * + * @param[in] p_encoded_data Data buffer containing the encoded Advertising data. + * @param[in] data_len Length of the data buffer \p p_encoded_data. + * @param[in] p_target_name Name to search for. + * @param[in] short_name_min_len Minimum length of the shortened name. + * For example, if the advertising data has a shortened name 'No' and this parameter is + * set to 4 with a target_name set to Nordic_XXX it will return false, but if + * the shortened name in the advertising data is 'Nord', it will return true. + * @note: If the shortened name in the Advertising data has the same length as the target name, + * this function will return false, since this means that the complete name is actually + * longer, thus different than the target name. + * + * @retval true If \p p_target_name was found among \p p_encoded_data, as short local name. + * @retval false If \p p_target_name was not found among \p p_encoded_data, or if \p p_encoded_data + * or \p p_target_name was NULL. + */ +bool ble_advdata_short_name_find(uint8_t const * p_encoded_data, + uint16_t data_len, + char const * p_target_name, + uint8_t const short_name_min_len); + +/**@brief Function for searching through encoded Advertising data for a UUID (16-bit or 128-bit). + * + * @param[in] p_encoded_data Data buffer containing the encoded Advertising data. + * @param[in] data_len Length of the data buffer \p p_encoded_data. + * @param[in] p_target_uuid UUID to search for. + * + * @retval true If \p p_target_uuid was found among \p p_encoded_data. + * @retval false If \p p_target_uuid was not found among \p p_encoded_data, or if \p p_encoded_data + * or \p p_target_uuid was NULL. + */ +bool ble_advdata_uuid_find(uint8_t const * p_encoded_data, + uint16_t data_len, + ble_uuid_t const * p_target_uuid); + + +/**@brief Function for searching through encoded Advertising data for an appearance. + * + * @param[in] p_encoded_data Data buffer containing the encoded Advertising data. + * @param[in] data_len Length of the data buffer \p p_encoded_data. + * @param[in] p_target_appearance Appearance to search for. + * + * @retval true If \p p_target_appearance was found among \p p_encoded_data. + * @retval false If \p p_target_appearance was not found among \p p_encoded_data, or if \p p_encoded_data + * or \p p_target_appearance was NULL. */ -uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata); +bool ble_advdata_appearance_find(uint8_t const * p_encoded_data, + uint16_t data_len, + uint16_t const * p_target_appearance); #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_params.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_params.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_params.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_params.c index 3229571..291e7a1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_params.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_params.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_BLE_CONN_PARAMS) @@ -52,9 +52,9 @@ #include "app_util.h" -#define NRF_BLE_CONN_PARAMS_N_INSTANCES NRF_SDH_BLE_PERIPHERAL_LINK_COUNT //!< The number of @ref ble_conn_params_instance_t instances kept by the conn_params module. +#define NRF_BLE_CONN_PARAMS_INSTANCE_COUNT NRF_SDH_BLE_PERIPHERAL_LINK_COUNT //!< The number of @ref ble_conn_params_instance_t instances kept by the conn_params module. -#if (NRF_BLE_CONN_PARAMS_N_INSTANCES < 1) +#if (NRF_BLE_CONN_PARAMS_INSTANCE_COUNT < 1) #error Invalid NRF_SDH_BLE_PERIPHERAL_LINK_COUNT value. Set it in SDK config (nrf_sdh_ble). #endif @@ -69,10 +69,10 @@ typedef struct ble_gap_conn_params_t preferred_conn_params; //!< The desired connection parameters for this link. } ble_conn_params_instance_t; -static app_timer_t m_timer_data[NRF_BLE_CONN_PARAMS_N_INSTANCES] = {{{0}}}; //!< Data needed for timers. -static ble_conn_params_instance_t m_conn_params_instances[NRF_BLE_CONN_PARAMS_N_INSTANCES] = {{0}}; //!< Configuration data for each connection. -static ble_conn_params_init_t m_conn_params_config; //!< Configuration as provided by the application during intialization. -static ble_gap_conn_params_t m_preferred_conn_params; //!< The preferred connection parameters as specified during initialization. +static app_timer_t m_timer_data[NRF_BLE_CONN_PARAMS_INSTANCE_COUNT] = {{{0}}}; //!< Data needed for timers. +static ble_conn_params_instance_t m_conn_params_instances[NRF_BLE_CONN_PARAMS_INSTANCE_COUNT] = {{0}}; //!< Configuration data for each connection. +static ble_conn_params_init_t m_conn_params_config; //!< Configuration as provided by the application during intialization. +static ble_gap_conn_params_t m_preferred_conn_params; //!< The preferred connection parameters as specified during initialization. //lint -esym(551, m_preferred_conn_params) "Not accessed" @@ -84,8 +84,8 @@ static ble_gap_conn_params_t m_preferred_conn_params; */ static ble_conn_params_instance_t * instance_get(uint16_t conn_handle) { - //lint -save -e681 "Loop not entered" when NRF_BLE_CONN_PARAMS_N_INSTANCES is 0 - for (uint32_t i = 0; i < NRF_BLE_CONN_PARAMS_N_INSTANCES; i++) + //lint -save -e681 "Loop not entered" when NRF_BLE_CONN_PARAMS_INSTANCE_COUNT is 0 + for (uint32_t i = 0; i < NRF_BLE_CONN_PARAMS_INSTANCE_COUNT; i++) { if (m_conn_params_instances[i].conn_handle == conn_handle) { @@ -279,8 +279,8 @@ ret_code_t ble_conn_params_init(const ble_conn_params_init_t * p_init) } } - //lint -save -e681 "Loop not entered" when NRF_BLE_CONN_PARAMS_N_INSTANCES is 0 - for (uint32_t i = 0; i < NRF_BLE_CONN_PARAMS_N_INSTANCES; i++) + //lint -save -e681 "Loop not entered" when NRF_BLE_CONN_PARAMS_INSTANCE_COUNT is 0 + for (uint32_t i = 0; i < NRF_BLE_CONN_PARAMS_INSTANCE_COUNT; i++) { ble_conn_params_instance_t * p_instance = &m_conn_params_instances[i]; @@ -305,8 +305,8 @@ ret_code_t ble_conn_params_stop(void) { ret_code_t err_code; - //lint -save -e681 "Loop not entered" when NRF_BLE_CONN_PARAMS_N_INSTANCES is 0 - for (uint32_t i = 0; i < NRF_BLE_CONN_PARAMS_N_INSTANCES; i++) + //lint -save -e681 "Loop not entered" when NRF_BLE_CONN_PARAMS_INSTANCE_COUNT is 0 + for (uint32_t i = 0; i < NRF_BLE_CONN_PARAMS_INSTANCE_COUNT; i++) { err_code = app_timer_stop(m_conn_params_instances[i].timer_id); switch (err_code) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_params.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_params.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_params.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_params.h index 9ad2a01..b9632af 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_params.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_params.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.c new file mode 100644 index 0000000..825301c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.c @@ -0,0 +1,489 @@ +/** + * Copyright (c) 2015 - 2019, 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 "ble_conn_state.h" +#include +#include +#include +#include "ble.h" +#include "nrf_atflags.h" +#include "app_error.h" +#include "nrf_sdh_ble.h" +#include "app_util_platform.h" + + + +#define DEFAULT_FLAG_COLLECTION_COUNT 6 /**< The number of flags kept for each connection, excluding user flags. */ +#define TOTAL_FLAG_COLLECTION_COUNT (DEFAULT_FLAG_COLLECTION_COUNT \ + + BLE_CONN_STATE_USER_FLAG_COUNT) /**< The number of flags kept for each connection, including user flags. */ + +/**@brief Structure containing all the flag collections maintained by the Connection State module. + */ +typedef struct +{ + nrf_atflags_t valid_flags; /**< Flags indicating which connection handles are valid. */ + nrf_atflags_t connected_flags; /**< Flags indicating which connections are connected, since disconnected connection handles will not immediately be invalidated. */ + nrf_atflags_t central_flags; /**< Flags indicating in which connections the local device is the central. */ + nrf_atflags_t encrypted_flags; /**< Flags indicating which connections are encrypted. */ + nrf_atflags_t mitm_protected_flags; /**< Flags indicating which connections have encryption with protection from man-in-the-middle attacks. */ + nrf_atflags_t lesc_flags; /**< Flags indicating which connections have bonded using LE Secure Connections (LESC). */ + nrf_atflags_t user_flags[BLE_CONN_STATE_USER_FLAG_COUNT]; /**< Flags that can be reserved by the user. The flags will be cleared when a connection is invalidated, otherwise, the user is wholly responsible for the flag states. */ +} ble_conn_state_flag_collections_t; + + +ANON_UNIONS_ENABLE; + +/**@brief Structure containing the internal state of the Connection State module. + */ +typedef struct +{ + nrf_atflags_t acquired_flags; /**< Bitmap for keeping track of which user flags have been acquired. */ + union + { + ble_conn_state_flag_collections_t flags; /**< Flag collections kept by the Connection State module. */ + nrf_atflags_t flag_array[TOTAL_FLAG_COLLECTION_COUNT]; /**< Flag collections as array to allow iterating over all flag collections. */ + }; +} ble_conn_state_t; + +ANON_UNIONS_DISABLE; + + +static ble_conn_state_t m_bcs = {0}; /**< Instantiation of the internal state. */ + + +/**@brief Function for resetting all internal memory to the values it had at initialization. + */ +void bcs_internal_state_reset(void) +{ + memset( &m_bcs, 0, sizeof(ble_conn_state_t) ); +} + + +ble_conn_state_conn_handle_list_t conn_handle_list_get(nrf_atflags_t flags) +{ + ble_conn_state_conn_handle_list_t conn_handle_list; + conn_handle_list.len = 0; + + if (flags != 0) + { + for (uint32_t i = 0; i < BLE_CONN_STATE_MAX_CONNECTIONS; i++) + { + if (nrf_atflags_get(&flags, i)) + { + conn_handle_list.conn_handles[conn_handle_list.len++] = i; + } + } + } + + return conn_handle_list; +} + + +uint32_t active_flag_count(nrf_atflags_t flags) +{ + uint32_t set_flag_count = 0; + + for (uint32_t i = 0; i < BLE_CONN_STATE_MAX_CONNECTIONS; i++) + { + if (nrf_atflags_get(&flags, i)) + { + set_flag_count += 1; + } + } + return set_flag_count; +} + + +/**@brief Function for activating a connection record. + * + * @param p_record The record to activate. + * @param conn_handle The connection handle to copy into the record. + * @param role The role of the connection. + * + * @return whether the record was activated successfully. + */ +static bool record_activate(uint16_t conn_handle) +{ + if (conn_handle >= BLE_CONN_STATE_MAX_CONNECTIONS) + { + return false; + } + nrf_atflags_set(&m_bcs.flags.connected_flags, conn_handle); + nrf_atflags_set(&m_bcs.flags.valid_flags, conn_handle); + return true; +} + + +/**@brief Function for marking a connection record as invalid and resetting the values. + * + * @param p_record The record to invalidate. + */ +static void record_invalidate(uint16_t conn_handle) +{ + for (uint32_t i = 0; i < TOTAL_FLAG_COLLECTION_COUNT; i++) + { + nrf_atflags_clear(&m_bcs.flag_array[i], conn_handle); + } +} + + +/**@brief Function for marking a connection as disconnected. See @ref BLE_CONN_STATUS_DISCONNECTED. + * + * @param p_record The record of the connection to set as disconnected. + */ +static void record_set_disconnected(uint16_t conn_handle) +{ + nrf_atflags_clear(&m_bcs.flags.connected_flags, conn_handle); +} + + +/**@brief Function for invalidating records with a @ref BLE_CONN_STATUS_DISCONNECTED + * connection status + */ +static void record_purge_disconnected() +{ + nrf_atflags_t disconnected_flags = ~m_bcs.flags.connected_flags; + ble_conn_state_conn_handle_list_t disconnected_list; + + UNUSED_RETURN_VALUE(nrf_atomic_u32_and(&disconnected_flags, m_bcs.flags.valid_flags)); + disconnected_list = conn_handle_list_get(disconnected_flags); + + for (uint32_t i = 0; i < disconnected_list.len; i++) + { + record_invalidate(disconnected_list.conn_handles[i]); + } +} + + +/**@brief Function for checking if a user flag has been acquired. + * + * @param[in] flag_id Which flag to check. + * + * @return Whether the flag has been acquired. + */ +static bool user_flag_is_acquired(ble_conn_state_user_flag_id_t flag_id) +{ + return nrf_atflags_get(&m_bcs.acquired_flags, flag_id); +} + + +void ble_conn_state_init(void) +{ + bcs_internal_state_reset(); +} + +static void flag_toggle(nrf_atflags_t * p_flags, uint16_t conn_handle, bool value) +{ + if (value) + { + nrf_atflags_set(p_flags, conn_handle); + } + else + { + nrf_atflags_clear(p_flags, conn_handle); + } +} + +/** + * @brief Function for handling BLE events. + * + * @param[in] p_ble_evt Event received from the BLE stack. + * @param[in] p_context Context. + */ +static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) +{ + uint16_t conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + record_purge_disconnected(); + + if ( !record_activate(conn_handle) ) + { + // No more records available. Should not happen. + APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); + } + else if ((p_ble_evt->evt.gap_evt.params.connected.role != BLE_GAP_ROLE_PERIPH)) + { + // Central + nrf_atflags_set(&m_bcs.flags.central_flags, conn_handle); + } + + break; + + case BLE_GAP_EVT_DISCONNECTED: + record_set_disconnected(conn_handle); + break; + + case BLE_GAP_EVT_CONN_SEC_UPDATE: + { + uint8_t sec_lv = p_ble_evt->evt.gap_evt.params.conn_sec_update.conn_sec.sec_mode.lv; + // Set/unset flags based on security level. + flag_toggle(&m_bcs.flags.lesc_flags, conn_handle, sec_lv >= 4); + flag_toggle(&m_bcs.flags.mitm_protected_flags, conn_handle, sec_lv >= 3); + flag_toggle(&m_bcs.flags.encrypted_flags, conn_handle, sec_lv >= 2); + break; + } + + case BLE_GAP_EVT_AUTH_STATUS: + if (p_ble_evt->evt.gap_evt.params.auth_status.auth_status == BLE_GAP_SEC_STATUS_SUCCESS) + { + bool lesc = p_ble_evt->evt.gap_evt.params.auth_status.lesc; + flag_toggle(&m_bcs.flags.lesc_flags, conn_handle, lesc); + } + break; + } +} + +NRF_SDH_BLE_OBSERVER(m_ble_evt_observer, BLE_CONN_STATE_BLE_OBSERVER_PRIO, ble_evt_handler, NULL); + + +bool ble_conn_state_valid(uint16_t conn_handle) +{ + if (conn_handle >= BLE_CONN_STATE_MAX_CONNECTIONS) + { + return false; + } + return nrf_atflags_get(&m_bcs.flags.valid_flags, conn_handle); +} + + +uint8_t ble_conn_state_role(uint16_t conn_handle) +{ + uint8_t role = BLE_GAP_ROLE_INVALID; + + if (ble_conn_state_valid(conn_handle)) + { +#if !defined(S112) && !defined(S312) && !defined(S113) + bool central = nrf_atflags_get(&m_bcs.flags.central_flags, conn_handle); + role = central ? BLE_GAP_ROLE_CENTRAL : BLE_GAP_ROLE_PERIPH; +#else + role = BLE_GAP_ROLE_PERIPH; +#endif // !defined (S112) && !defined(S312) && !defined(S113) + } + + return role; +} + + +ble_conn_state_status_t ble_conn_state_status(uint16_t conn_handle) +{ + ble_conn_state_status_t conn_status = BLE_CONN_STATUS_INVALID; + + if (ble_conn_state_valid(conn_handle)) + { + bool connected = nrf_atflags_get(&m_bcs.flags.connected_flags, conn_handle); + conn_status = connected ? BLE_CONN_STATUS_CONNECTED : BLE_CONN_STATUS_DISCONNECTED; + } + + return conn_status; +} + + +bool ble_conn_state_encrypted(uint16_t conn_handle) +{ + if (ble_conn_state_valid(conn_handle)) + { + return nrf_atflags_get(&m_bcs.flags.encrypted_flags, conn_handle); + } + return false; +} + + +bool ble_conn_state_mitm_protected(uint16_t conn_handle) +{ + if (ble_conn_state_valid(conn_handle)) + { + return nrf_atflags_get(&m_bcs.flags.mitm_protected_flags, conn_handle); + } + return false; +} + +bool ble_conn_state_lesc(uint16_t conn_handle) +{ + if (ble_conn_state_valid(conn_handle)) + { + return nrf_atflags_get(&m_bcs.flags.lesc_flags, conn_handle); + } + return false; +} + + +uint32_t ble_conn_state_conn_count(void) +{ + return active_flag_count(m_bcs.flags.connected_flags); +} + + +uint32_t ble_conn_state_central_conn_count(void) +{ + nrf_atflags_t central_conn_flags = m_bcs.flags.central_flags; + UNUSED_RETURN_VALUE(nrf_atomic_u32_and(¢ral_conn_flags, m_bcs.flags.connected_flags)); + + return active_flag_count(central_conn_flags); +} + + +uint32_t ble_conn_state_peripheral_conn_count(void) +{ + nrf_atflags_t peripheral_conn_flags = ~m_bcs.flags.central_flags; + UNUSED_RETURN_VALUE(nrf_atomic_u32_and(&peripheral_conn_flags, m_bcs.flags.connected_flags)); + + return active_flag_count(peripheral_conn_flags); +} + + +ble_conn_state_conn_handle_list_t ble_conn_state_conn_handles(void) +{ + return conn_handle_list_get(m_bcs.flags.valid_flags); +} + + +ble_conn_state_conn_handle_list_t ble_conn_state_central_handles(void) +{ + nrf_atflags_t central_conn_flags = m_bcs.flags.central_flags; + UNUSED_RETURN_VALUE(nrf_atomic_u32_and(¢ral_conn_flags, m_bcs.flags.connected_flags)); + + return conn_handle_list_get(central_conn_flags); +} + + +ble_conn_state_conn_handle_list_t ble_conn_state_periph_handles(void) +{ + nrf_atflags_t peripheral_conn_flags = ~m_bcs.flags.central_flags; + UNUSED_RETURN_VALUE(nrf_atomic_u32_and(&peripheral_conn_flags, m_bcs.flags.connected_flags)); + + return conn_handle_list_get(peripheral_conn_flags); +} + + +uint16_t ble_conn_state_conn_idx(uint16_t conn_handle) +{ + if (ble_conn_state_valid(conn_handle)) + { + return conn_handle; + } + else + { + return BLE_CONN_STATE_MAX_CONNECTIONS; + } +} + + +ble_conn_state_user_flag_id_t ble_conn_state_user_flag_acquire(void) +{ + uint32_t acquired_flag = nrf_atflags_find_and_set_flag(&m_bcs.acquired_flags, + BLE_CONN_STATE_USER_FLAG_COUNT); + + if (acquired_flag == BLE_CONN_STATE_USER_FLAG_COUNT) + { + return BLE_CONN_STATE_USER_FLAG_INVALID; + } + return (ble_conn_state_user_flag_id_t)acquired_flag; +} + + +bool ble_conn_state_user_flag_get(uint16_t conn_handle, ble_conn_state_user_flag_id_t flag_id) +{ + if (user_flag_is_acquired(flag_id) && ble_conn_state_valid(conn_handle)) + { + return nrf_atflags_get(&m_bcs.flags.user_flags[flag_id], conn_handle); + } + else + { + return false; + } +} + + +void ble_conn_state_user_flag_set(uint16_t conn_handle, + ble_conn_state_user_flag_id_t flag_id, + bool value) +{ + if (user_flag_is_acquired(flag_id) && ble_conn_state_valid(conn_handle)) + { + flag_toggle(&m_bcs.flags.user_flags[flag_id], conn_handle, value); + } +} + + +static uint32_t for_each_set_flag(nrf_atflags_t flags, + ble_conn_state_user_function_t user_function, + void * p_context) +{ + if (user_function == NULL) + { + return 0; + } + + uint32_t call_count = 0; + + if (flags != 0) + { + for (uint32_t i = 0; i < BLE_CONN_STATE_MAX_CONNECTIONS; i++) + { + if (nrf_atflags_get(&flags, i)) + { + user_function(i, p_context); + call_count += 1; + } + } + } + return call_count; +} + + +uint32_t ble_conn_state_for_each_connected(ble_conn_state_user_function_t user_function, + void * p_context) +{ + return for_each_set_flag(m_bcs.flags.connected_flags, user_function, p_context); +} + + +uint32_t ble_conn_state_for_each_set_user_flag(ble_conn_state_user_flag_id_t flag_id, + ble_conn_state_user_function_t user_function, + void * p_context) +{ + if (!user_flag_is_acquired(flag_id)) + { + return 0; + } + + return for_each_set_flag(m_bcs.flags.user_flags[flag_id], user_function, p_context); +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.h index 6e0c9b2..9f39d56 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_conn_state.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_conn_state.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -52,8 +52,7 @@ * binary user states, or user flags. These are reset to 0 for new connections, but * otherwise not touched by this module. * - * This module uses the @ref sdk_mapped_flags module, with connection handles as keys and - * the connection states as flags. + * This module uses the @ref nrf_atomic module to make the flag operations thread-safe. * * @note A connection handle is not immediately invalidated when it is disconnected. Certain states, * such as the role, can still be queried until the next time a new connection is established @@ -67,7 +66,8 @@ #include #include #include "ble.h" -#include "sdk_mapped_flags.h" +#include "ble_gap.h" +#include "nrf_atomic.h" #ifdef __cplusplus extern "C" { @@ -82,10 +82,18 @@ typedef enum BLE_CONN_STATUS_CONNECTED, /**< The connection handle refers to an active connection. */ } ble_conn_state_status_t; -#define BLE_CONN_STATE_MAX_CONNECTIONS 20 /**< The maximum number of connections supported. */ -#define BLE_CONN_STATE_N_USER_FLAGS 24 /**< The number of available user flags. */ +#define BLE_CONN_STATE_MAX_CONNECTIONS BLE_GAP_ROLE_COUNT_COMBINED_MAX /**< The maximum number of connections supported. */ +#define BLE_CONN_STATE_USER_FLAG_COUNT 24 /**< The number of available user flags. */ +/**@brief Type used to present a list of conn_handles. + */ +typedef struct +{ + uint32_t len; /**< The length of the list. */ + uint16_t conn_handles[BLE_CONN_STATE_MAX_CONNECTIONS]; /**< The list of handles. */ +} ble_conn_state_conn_handle_list_t; + /**@brief One ID for each user flag collection. * * @details These IDs are used to identify user flag collections in the API calls. @@ -120,6 +128,15 @@ typedef enum } ble_conn_state_user_flag_id_t; +/**@brief Function to be called when a flag ID is set. See @ref ble_conn_state_for_each_set_user_flag. + * + * @param[in] conn_handle The connection the flag is set for. + * @param[in] p_context Arbitrary pointer provided by the caller of + * @ref ble_conn_state_for_each_set_user_flag. + */ +typedef void (*ble_conn_state_user_function_t)(uint16_t conn_handle, void * p_context); + + /** * @defgroup ble_conn_state_functions BLE connection state functions * @{ @@ -189,11 +206,27 @@ bool ble_conn_state_encrypted(uint16_t conn_handle); bool ble_conn_state_mitm_protected(uint16_t conn_handle); +/**@brief Function for querying whether a connection was bonded using LE Secure Connections (LESC). + * + * The connection must currently be encrypted. + * + * @note This function will report false if bonded, and the LESC bonding was unauthenticated + * ("Just Works") and happened in a previous connection. To detect such cases as well, check + * the stored bonding key, e.g. in Peer Manager, which has a LESC flag associated with it. + * + * @param[in] conn_handle Handle of connection to get the LESC state for. + * + * @retval true If the connection was bonded using LESC. + * @retval false If the connection has not been bonded using LESC, or conn_handle is invalid. + */ +bool ble_conn_state_lesc(uint16_t conn_handle); + + /**@brief Function for querying the total number of connections. * * @return The total number of valid connections for which the module has a record. */ -uint32_t ble_conn_state_n_connections(void); +uint32_t ble_conn_state_conn_count(void); /**@brief Function for querying the total number of connections in which the role of the local @@ -202,7 +235,7 @@ uint32_t ble_conn_state_n_connections(void); * @return The number of connections in which the role of the local device is * @ref BLE_GAP_ROLE_CENTRAL. */ -uint32_t ble_conn_state_n_centrals(void); +uint32_t ble_conn_state_central_conn_count(void); /**@brief Function for querying the total number of connections in which the role of the local @@ -211,7 +244,7 @@ uint32_t ble_conn_state_n_centrals(void); * @return The number of connections in which the role of the local device is * @ref BLE_GAP_ROLE_PERIPH. */ -uint32_t ble_conn_state_n_peripherals(void); +uint32_t ble_conn_state_peripheral_conn_count(void); /**@brief Function for obtaining a list of all connection handles for which the module has a record. @@ -220,7 +253,7 @@ uint32_t ble_conn_state_n_peripherals(void); * * @return A list of all valid connection handles for which the module has a record. */ -sdk_mapped_flags_key_list_t ble_conn_state_conn_handles(void); +ble_conn_state_conn_handle_list_t ble_conn_state_conn_handles(void); /**@brief Function for obtaining a list of connection handles in which the role of the local @@ -231,7 +264,7 @@ sdk_mapped_flags_key_list_t ble_conn_state_conn_handles(void); * @return A list of all valid connection handles for which the module has a record and in which * the role of local device is @ref BLE_GAP_ROLE_CENTRAL. */ -sdk_mapped_flags_key_list_t ble_conn_state_central_handles(void); +ble_conn_state_conn_handle_list_t ble_conn_state_central_handles(void); /**@brief Function for obtaining the handle for the connection in which the role of the local device @@ -242,7 +275,7 @@ sdk_mapped_flags_key_list_t ble_conn_state_central_handles(void); * @return A list of all valid connection handles for which the module has a record and in which * the role of local device is @ref BLE_GAP_ROLE_PERIPH. */ -sdk_mapped_flags_key_list_t ble_conn_state_periph_handles(void); +ble_conn_state_conn_handle_list_t ble_conn_state_periph_handles(void); /**@brief Function for translating a connection handle to a value that can be used as an array index. @@ -257,7 +290,7 @@ sdk_mapped_flags_key_list_t ble_conn_state_periph_handles(void); * @return An index unique to this connection. Or @ref BLE_CONN_STATE_MAX_CONNECTIONS if * @p conn_handle refers to an invalid connection. */ -uint8_t ble_conn_state_conn_idx(uint16_t conn_handle); +uint16_t ble_conn_state_conn_idx(uint16_t conn_handle); /**@brief Function for obtaining exclusive access to one of the user flag collections. @@ -294,17 +327,28 @@ void ble_conn_state_user_flag_set(uint16_t conn_handle, bool value); -/**@brief Function for getting the state of a user flag for all connection handles. +/**@brief Function for running a function for each active connection. + * + * @param[in] user_function The function to run for each connection. + * @param[in] p_context Arbitrary context to be passed to \p user_function. * - * @details The returned collection can be used with the @ref sdk_mapped_flags API. The returned - * collection is a copy, so modifying it has no effect on the conn_state module. + * @return The number of times \p user_function was run. + */ +uint32_t ble_conn_state_for_each_connected(ble_conn_state_user_function_t user_function, + void * p_context); + + +/**@brief Function for running a function for each flag that is set in a user flag collection. * - * @param[in] flag_id Which flag to get states for. + * @param[in] flag_id Which flags to check. + * @param[in] user_function The function to run when a flag is set. + * @param[in] p_context Arbitrary context to be passed to \p user_function. * - * @return The collection of flag states. The collection is always all zeros when the flag_id is - * unregistered. + * @return The number of times \p user_function was run. */ -sdk_mapped_flags_t ble_conn_state_user_flag_collection(ble_conn_state_user_flag_id_t flag_id); +uint32_t ble_conn_state_for_each_set_user_flag(ble_conn_state_user_flag_id_t flag_id, + ble_conn_state_user_function_t user_function, + void * p_context); /** @} */ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_date_time.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_date_time.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_date_time.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_date_time.h index 762784c..a41e597 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_date_time.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_date_time.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2011 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_gatt_db.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_gatt_db.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_gatt_db.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_gatt_db.h index 05c382b..edafba4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_gatt_db.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_gatt_db.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -50,12 +50,15 @@ #include #include "ble.h" #include "ble_gattc.h" +#include "sdk_config.h" #ifdef __cplusplus extern "C" { #endif +#ifndef BLE_GATT_DB_MAX_CHARS #define BLE_GATT_DB_MAX_CHARS 6 /**< The maximum number of characteristics present in a service record. */ +#endif // BLE_GATT_DB_MAX_CHARS /**@brief Structure for holding the characteristic and the handle of its CCCD present on a server. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_sensor_location.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_sensor_location.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_sensor_location.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_sensor_location.h index ca259f1..391d7f8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_sensor_location.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_sensor_location.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_srv_common.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_srv_common.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_srv_common.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_srv_common.c index 9ea8423..ef095b2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_srv_common.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_srv_common.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Attention! * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_srv_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_srv_common.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_srv_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_srv_common.h index c07b1a6..0683076 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/common/ble_srv_common.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/common/ble_srv_common.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_gatt/nrf_ble_gatt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gatt/nrf_ble_gatt.c similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_gatt/nrf_ble_gatt.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gatt/nrf_ble_gatt.c index baa4295..27bb186 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_gatt/nrf_ble_gatt.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gatt/nrf_ble_gatt.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -43,16 +43,17 @@ #include "nrf_ble_gatt.h" -#define NRF_LOG_MODULE_NAME ble_gatt +#define NRF_LOG_MODULE_NAME nrf_ble_gatt #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" -#define L2CAP_HDR_LEN 4 //!< Length of a L2CAP header, in bytes. +#define BLE_GAP_DATA_LENGTH_DEFAULT 27 //!< The stack's default data length. +#define BLE_GAP_DATA_LENGTH_MAX 251 //!< Maximum data length. -STATIC_ASSERT(NRF_SDH_BLE_GATT_MAX_MTU_SIZE <= 251); -STATIC_ASSERT(NRF_SDH_BLE_GATT_MAX_MTU_SIZE + L2CAP_HDR_LEN <= 255); +STATIC_ASSERT(NRF_SDH_BLE_GAP_DATA_LENGTH < 252); /**@brief Initialize a link's parameters to defaults. */ @@ -62,44 +63,58 @@ static void link_init(nrf_ble_gatt_link_t * p_link) p_link->att_mtu_effective = BLE_GATT_ATT_MTU_DEFAULT; p_link->att_mtu_exchange_pending = false; p_link->att_mtu_exchange_requested = false; -#if !defined (S112) - p_link->data_length_desired = NRF_SDH_BLE_GATT_MAX_MTU_SIZE + L2CAP_HDR_LEN; - p_link->data_length_effective = BLE_GATT_ATT_MTU_DEFAULT + L2CAP_HDR_LEN; -#endif // !defined (S112) +#if !defined (S112) && !defined(S312) + p_link->data_length_desired = NRF_SDH_BLE_GAP_DATA_LENGTH; + p_link->data_length_effective = BLE_GAP_DATA_LENGTH_DEFAULT; +#endif // !defined (S112) && !defined(S312) } -/**@brief Start a data length update request. - * @details This function is called to request a data length update upon connection. - * When the peer requests a data length update, sd_ble_gap_data_length_update() - * is called directly in response to the BLE_GAP_EVT_DATA_LENGTH_UPDATE event in - * on_data_length_update_evt(). - */ -#if !defined (S112) -static void data_length_update(uint16_t conn_handle, nrf_ble_gatt_t const * p_gatt) +/**@brief Start a data length update request procedure on a given connection. */ +#if !defined (S112) && !defined(S312) +static ret_code_t data_length_update(uint16_t conn_handle, uint16_t data_length) { - NRF_LOG_DEBUG("Requesting to update data length to %u on connection 0x%x.", - p_gatt->links[conn_handle].data_length_desired, conn_handle); + NRF_LOG_DEBUG("Updating data length to %u on connection 0x%x.", + data_length, conn_handle); ble_gap_data_length_params_t const dlp = { - .max_rx_octets = p_gatt->links[conn_handle].data_length_desired, - .max_tx_octets = p_gatt->links[conn_handle].data_length_desired, + .max_rx_octets = data_length, + .max_tx_octets = data_length, .max_rx_time_us = BLE_GAP_DATA_LENGTH_AUTO, .max_tx_time_us = BLE_GAP_DATA_LENGTH_AUTO, }; - ret_code_t err_code = sd_ble_gap_data_length_update(conn_handle, &dlp, NULL); + ble_gap_data_length_limitation_t dll = {0}; + + ret_code_t err_code = sd_ble_gap_data_length_update(conn_handle, &dlp, &dll); if (err_code != NRF_SUCCESS) { - NRF_LOG_ERROR("sd_ble_gap_data_length_update() (request)" - " on connection 0x%x returned unexpected value 0x%x.", - conn_handle, err_code); + NRF_LOG_ERROR("sd_ble_gap_data_length_update() (request) on connection 0x%x returned %s.", + conn_handle, nrf_strerror_get(err_code)); + + if ( (dll.tx_payload_limited_octets != 0) + || (dll.rx_payload_limited_octets != 0)) + { + NRF_LOG_ERROR("The requested TX/RX packet length is too long by %u/%u octets.", + dll.tx_payload_limited_octets, dll.rx_payload_limited_octets); + } + + if (dll.tx_rx_time_limited_us != 0) + { + NRF_LOG_ERROR("The requested combination of TX and RX packet lengths " + "is too long by %u microseconds.", + dll.tx_rx_time_limited_us); + } } + + return err_code; } -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) /**@brief Handle a connected event. + * + * Begins an ATT MTU exchange procedure, followed by a data length update request as necessary. * * @param[in] p_gatt GATT structure. * @param[in] p_ble_evt Event received from the BLE stack. @@ -111,19 +126,22 @@ static void on_connected_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_ble_ev nrf_ble_gatt_link_t * p_link = &p_gatt->links[conn_handle]; // Update the link desired settings to reflect the current global settings. -#if !defined (S112) +#if !defined (S112) && !defined(S312) p_link->data_length_desired = p_gatt->data_length; -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) + switch (p_ble_evt->evt.gap_evt.params.connected.role) { case BLE_GAP_ROLE_PERIPH: p_link->att_mtu_desired = p_gatt->att_mtu_desired_periph; break; -#if !defined (S112) + +#if !defined (S112) && !defined(S312) && !defined(S113) case BLE_GAP_ROLE_CENTRAL: p_link->att_mtu_desired = p_gatt->att_mtu_desired_central; break; -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) && !defined(S113) + default: // Ignore. break; @@ -149,19 +167,18 @@ static void on_connected_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_ble_ev } else { - NRF_LOG_ERROR("sd_ble_gattc_exchange_mtu_request()" - " returned unexpected value 0x%x.", - err_code); + NRF_LOG_ERROR("sd_ble_gattc_exchange_mtu_request() returned %s.", + nrf_strerror_get(err_code)); } } -#if !defined (S112) +#if !defined (S112) && !defined(S312) // Send a data length update request if necessary. if (p_link->data_length_desired > p_link->data_length_effective) { - data_length_update(conn_handle, p_gatt); + (void) data_length_update(conn_handle, p_link->data_length_desired); } -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) } @@ -242,8 +259,7 @@ static void on_exchange_mtu_request_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const if (err_code != NRF_SUCCESS) { - NRF_LOG_ERROR("sd_ble_gatts_exchange_mtu_reply() returned unexpected value 0x%x.", - err_code); + NRF_LOG_ERROR("sd_ble_gatts_exchange_mtu_reply() returned %s.", nrf_strerror_get(err_code)); } // If an ATT_MTU exchange was requested to the peer, defer sending @@ -276,13 +292,14 @@ static void on_exchange_mtu_request_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * @param[in] p_gatt GATT structure. * @param[in] p_ble_evt Event received from the BLE stack. */ -#if !defined (S112) +#if !defined (S112) && !defined(S312) static void on_data_length_update_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_ble_evt) { ble_gap_evt_t const gap_evt = p_ble_evt->evt.gap_evt; uint16_t const conn_handle = gap_evt.conn_handle; // Update the connection data length. + // The SoftDevice only supports symmetric RX/TX data length settings. p_gatt->links[conn_handle].data_length_effective = gap_evt.params.data_length_update.effective_params.max_tx_octets; @@ -311,7 +328,6 @@ static void on_data_length_update_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_gatt->evt_handler(p_gatt, &evt); } } -#endif // !defined (S112) /**@brief Handle a BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event. @@ -320,7 +336,7 @@ static void on_data_length_update_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * * link's preferred data length, and what requested by the peer. * The link preferred data length is set to the global preferred data length * upon connection and can be overridden by calling nrf_ble_gatt_data_length_set(). - * The default is NRF_SDH_BLE_GATT_MAX_MTU_SIZE + L2CAP_HDR_LEN. + * The default is NRF_SDH_BLE_GAP_DATA_LENGTH. * *@note The SoftDevice will not send any BLE_GAP_EVT_DATA_LENGTH_UPDATE events on this side. * Therefore, the connection data length is updated immediately and an event is sent @@ -329,41 +345,23 @@ static void on_data_length_update_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * * @param[in] p_gatt GATT structure. * @param[in] p_ble_evt Event received from the BLE stack. */ -#if !defined (S112) static void on_data_length_update_request_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_ble_evt) { - ret_code_t err_code; - ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt; nrf_ble_gatt_link_t * p_link = &p_gatt->links[p_gap_evt->conn_handle]; - uint8_t const data_length_peer = + // The SoftDevice only supports symmetric RX/TX data length settings. + uint8_t const data_length_requested = p_gap_evt->params.data_length_update_request.peer_params.max_tx_octets; NRF_LOG_DEBUG("Peer on connection 0x%x requested a data length of %u bytes.", - p_gap_evt->conn_handle, data_length_peer); - - uint8_t const data_length = MIN(p_link->data_length_desired, data_length_peer); - - ble_gap_data_length_params_t const dlp = - { - .max_rx_octets = data_length, - .max_tx_octets = data_length, - }; + p_gap_evt->conn_handle, data_length_requested); - NRF_LOG_DEBUG("Updating data length to %u bytes on connection 0x%x.", - data_length, p_gap_evt->conn_handle); + uint8_t const data_length_effective = MIN(p_link->data_length_desired, data_length_requested); - err_code = sd_ble_gap_data_length_update(p_gap_evt->conn_handle, &dlp, NULL); - - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("sd_ble_gap_data_length_update() (reply)" - " returned unexpected value 0x%x.", - err_code); - } + (void) data_length_update(p_gap_evt->conn_handle, data_length_effective); } -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) ret_code_t nrf_ble_gatt_init(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_handler_t evt_handler) @@ -373,7 +371,7 @@ ret_code_t nrf_ble_gatt_init(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_handler_t p_gatt->evt_handler = evt_handler; p_gatt->att_mtu_desired_periph = NRF_SDH_BLE_GATT_MAX_MTU_SIZE; p_gatt->att_mtu_desired_central = NRF_SDH_BLE_GATT_MAX_MTU_SIZE; - p_gatt->data_length = NRF_SDH_BLE_GATT_MAX_MTU_SIZE + L2CAP_HDR_LEN; + p_gatt->data_length = NRF_SDH_BLE_GAP_DATA_LENGTH; for (uint32_t i = 0; i < NRF_BLE_GATT_LINK_COUNT; i++) { @@ -422,21 +420,27 @@ uint16_t nrf_ble_gatt_eff_mtu_get(nrf_ble_gatt_t const * p_gatt, uint16_t conn_h return p_gatt->links[conn_handle].att_mtu_effective; } -#if !defined (S112) +#if !defined (S112) && !defined(S312) ret_code_t nrf_ble_gatt_data_length_set(nrf_ble_gatt_t * p_gatt, uint16_t conn_handle, uint8_t data_length) { - ret_code_t err_code; - if (p_gatt == NULL) { return NRF_ERROR_NULL; } + // Check early to avoid requesting an invalid data length for upcoming connections. + if ( (data_length > BLE_GAP_DATA_LENGTH_MAX) + || (data_length < BLE_GAP_DATA_LENGTH_DEFAULT)) + { + return NRF_ERROR_INVALID_PARAM; + } + if (conn_handle == BLE_CONN_HANDLE_INVALID) { - p_gatt->data_length = MIN(data_length, NRF_SDH_BLE_GATT_MAX_MTU_SIZE + L2CAP_HDR_LEN); + // Save value and request upon connection. + p_gatt->data_length = data_length; return NRF_SUCCESS; } @@ -445,21 +449,13 @@ ret_code_t nrf_ble_gatt_data_length_set(nrf_ble_gatt_t * p_gatt, return NRF_ERROR_INVALID_PARAM; } + // Request data length on existing link. p_gatt->links[conn_handle].data_length_desired = data_length; - ble_gap_data_length_params_t const dlp = - { - .max_rx_octets = data_length, - .max_tx_octets = data_length, - }; - - err_code = sd_ble_gap_data_length_update(conn_handle, &dlp, NULL); - return err_code; + return data_length_update(conn_handle, data_length); } -#endif // !defined (S112) -#if !defined (S112) ret_code_t nrf_ble_gatt_data_length_get(nrf_ble_gatt_t const * p_gatt, uint16_t conn_handle, uint8_t * p_data_length) @@ -483,7 +479,7 @@ ret_code_t nrf_ble_gatt_data_length_get(nrf_ble_gatt_t const * p_gatt, *p_data_length = p_gatt->links[conn_handle].data_length_effective; return NRF_SUCCESS; } -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) void nrf_ble_gatt_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) @@ -513,7 +509,8 @@ void nrf_ble_gatt_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: on_exchange_mtu_request_evt(p_gatt, p_ble_evt); break; -#if !defined (S112) + +#if !defined (S112) && !defined(S312) case BLE_GAP_EVT_DATA_LENGTH_UPDATE: on_data_length_update_evt(p_gatt, p_ble_evt); break; @@ -521,7 +518,8 @@ void nrf_ble_gatt_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: on_data_length_update_request_evt(p_gatt, p_ble_evt); break; -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) + default: break; } @@ -543,8 +541,8 @@ void nrf_ble_gatt_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) } else if (err_code != NRF_ERROR_BUSY) { - NRF_LOG_ERROR("sd_ble_gattc_exchange_mtu_request() returned unexpected value 0x%x.", - err_code); + NRF_LOG_ERROR("sd_ble_gattc_exchange_mtu_request() returned %s.", + nrf_strerror_get(err_code)); } } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_gatt/nrf_ble_gatt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gatt/nrf_ble_gatt.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_gatt/nrf_ble_gatt.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gatt/nrf_ble_gatt.h index fa2a63a..e497740 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_gatt/nrf_ble_gatt.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gatt/nrf_ble_gatt.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -93,9 +93,9 @@ typedef struct union { uint16_t att_mtu_effective; //!< Effective ATT_MTU. -#if !defined (S112) +#if !defined (S112) && !defined(S312) uint8_t data_length; //!< Data length value. -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) } params; } nrf_ble_gatt_evt_t; @@ -115,10 +115,10 @@ typedef struct uint16_t att_mtu_effective; //!< Effective ATT_MTU size (in bytes). bool att_mtu_exchange_pending; //!< Indicates that an ATT_MTU exchange request is pending (the call to @ref sd_ble_gattc_exchange_mtu_request returned @ref NRF_ERROR_BUSY). bool att_mtu_exchange_requested; //!< Indicates that an ATT_MTU exchange request was made. -#if !defined (S112) +#if !defined (S112) && !defined(S312) uint8_t data_length_desired; //!< Desired data length (in bytes). uint8_t data_length_effective; //!< Requested data length (in bytes). -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) } nrf_ble_gatt_link_t; @@ -182,11 +182,11 @@ ret_code_t nrf_ble_gatt_att_mtu_central_set(nrf_ble_gatt_t * p_gatt, uint16_t de * out (for example, if a default ATT_MTU size is used), the data length * is not changed. */ -#if !defined (S112) +#if !defined (S112) && !defined(S312) ret_code_t nrf_ble_gatt_data_length_set(nrf_ble_gatt_t * p_gatt, uint16_t conn_handle, uint8_t data_length); -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) /**@brief Function for retrieving the data length of a connection. * @@ -205,11 +205,11 @@ ret_code_t nrf_ble_gatt_data_length_set(nrf_ble_gatt_t * p_gatt, * @retval NRF_ERROR_NULL If @p p_gatt or @p p_data_length is NULL. * @retval NRF_ERROR_INVALID_PARAM If @p conn_handle is larger than @ref NRF_BLE_GATT_LINK_COUNT. */ -#if !defined (S112) +#if !defined (S112) && !defined(S312) ret_code_t nrf_ble_gatt_data_length_get(nrf_ble_gatt_t const * p_gatt, uint16_t conn_handle, uint8_t * p_data_length); -#endif // !defined (S112) +#endif // !defined (S112) && !defined(S312) /**@brief Function for handling BLE stack events. * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.c new file mode 100644 index 0000000..9ef131c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.c @@ -0,0 +1,611 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_BLE_GQ) + +#include "nrf_ble_gq.h" + +#define NRF_LOG_MODULE_NAME nrf_ble_gq +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/**@brief Pointer used to describe memory allocator for GATT request. */ +typedef ret_code_t (* req_data_alloc_t) (nrf_memobj_pool_t const * p_data_pool, + nrf_ble_gq_req_t * const p_req); + + +/**@brief Function allocates memory for data associated with @ref NRF_BLE_GQ_REQ_GATTC_WRITE + * request. + * + * @param[in] p_data_pool Pointer to general memory pool. + * @param[in] p_req Pointer to GATTC write request. + * + * @retval NRF_SUCCESS If the write data was allocated successfully. + * @retval NRF_ERROR_INVALID_LENGTH If data to be written is too long. + * @retval NRF_ERROR_NO_MEM If there was no room either in the data pool for new allocation. + */ +static ret_code_t gattc_write_alloc(nrf_memobj_pool_t const * p_data_pool, + nrf_ble_gq_req_t * const p_req) +{ + nrf_ble_gq_gattc_write_t * p_gattc_write = &p_req->params.gattc_write; + + // Check if the payload data is not too long. + if (p_gattc_write->len > NRF_BLE_GQ_GATTC_WRITE_MAX_DATA_LEN) + { + return NRF_ERROR_INVALID_LENGTH; + } + + // Allocate memory for GATTC write request. + p_req->p_mem_obj = nrf_memobj_alloc(p_data_pool, + p_gattc_write->len); + if (p_req->p_mem_obj == NULL) + { + return NRF_ERROR_NO_MEM; + } + + // Copy relevant data to the pool. + nrf_memobj_write(p_req->p_mem_obj, (void *) p_gattc_write->p_value, p_gattc_write->len, 0); + + NRF_LOG_DEBUG("Pointer to allocated memory block: %p.", p_req->p_mem_obj); + return NRF_SUCCESS; +} + + +/**@brief Function allocates memory for data associated with @ref NRF_BLE_GQ_REQ_GATTS_HVX + * request. + * + * @param[in] p_data_pool Pointer to general memory pool. + * @param[in] p_req Pointer to GATTS hvx request. + * + * @retval NRF_SUCCESS If the notification or indication data was allocated successfully. + * @retval NRF_ERROR_INVALID_LENGTH If data to be written is too long. + * @retval NRF_ERROR_NO_MEM If there was no room either in the data pool for new allocation. + */ +static ret_code_t gatts_hvx_alloc(nrf_memobj_pool_t const * p_data_pool, + nrf_ble_gq_req_t * const p_req) +{ + nrf_ble_gq_gatts_hvx_t * p_gatts_hvx = &p_req->params.gatts_hvx; + + // Check if the payload data is not too long. + if (*p_gatts_hvx->p_len > NRF_BLE_GQ_GATTS_HVX_MAX_DATA_LEN) + { + return NRF_ERROR_INVALID_LENGTH; + } + + // Allocate memory for GATTS notification or indication request. + p_req->p_mem_obj = nrf_memobj_alloc(p_data_pool, + *p_gatts_hvx->p_len + sizeof(uint16_t)); + if (p_req->p_mem_obj == NULL) + { + return NRF_ERROR_NO_MEM; + } + + // Copy relevant data to the pool. + nrf_memobj_write(p_req->p_mem_obj, (void *)p_gatts_hvx->p_len, sizeof(uint16_t), 0); + nrf_memobj_write(p_req->p_mem_obj, + (void *)p_gatts_hvx->p_data, + *p_gatts_hvx->p_len, + sizeof(uint16_t)); + + NRF_LOG_DEBUG("Pointer to allocated memory block: %p.", p_req->p_mem_obj); + return NRF_SUCCESS; +} + + +/**@brief Array of memory allocators for different types of @ref nrf_ble_gq_req_t. */ +static const req_data_alloc_t m_req_data_alloc[NRF_BLE_GQ_REQ_NUM] = +{ + [NRF_BLE_GQ_REQ_GATTC_READ] = NULL, + [NRF_BLE_GQ_REQ_GATTC_WRITE] = gattc_write_alloc, + [NRF_BLE_GQ_REQ_SRV_DISCOVERY] = NULL, + [NRF_BLE_GQ_REQ_CHAR_DISCOVERY] = NULL, + [NRF_BLE_GQ_REQ_DESC_DISCOVERY] = NULL, + [NRF_BLE_GQ_REQ_GATTS_HVX] = gatts_hvx_alloc +}; + + +/**@brief Function handles error codes returned by GATT requests. + * + * @param[in] p_req Pointer to GATT request. + * @param[in] err_code Error code returned by SoftDevice. + * @param[in] conn_handle Connection handle. + */ +__STATIC_INLINE void request_err_code_handle(nrf_ble_gq_req_t const * const p_req, + uint16_t conn_handle, + ret_code_t err_code) +{ + if (err_code == NRF_SUCCESS) + { + NRF_LOG_DEBUG("SD GATT procedure (%d) succeeded on connection handle: %d.", + p_req->type, + conn_handle); + } + else + { + NRF_LOG_ERROR("SD GATT procedure (%d) failed on connection handle %d with error: 0x%08X.", + p_req->type, conn_handle, err_code); + if (p_req->error_handler.cb != NULL) + { + p_req->error_handler.cb(err_code, p_req->error_handler.p_ctx, conn_handle); + } + } +} + + +/**@brief Function processes subsequent requests from the BGQ instance queue. + * + * @param[in] p_queue Pointer to the queue instance. + * @param[in] conn_handle Connection handle. + */ +static void queue_process(nrf_queue_t const * const p_queue, uint16_t conn_handle) +{ + ret_code_t err_code; + nrf_ble_gq_req_t ble_req; + + NRF_LOG_DEBUG("Processing the request queue..."); + + err_code = nrf_queue_peek(p_queue, &ble_req); + if (err_code == NRF_SUCCESS) // Queue is not empty + { + switch (ble_req.type) + { + case NRF_BLE_GQ_REQ_GATTC_READ: + NRF_LOG_DEBUG("GATTC Read Request"); + err_code = sd_ble_gattc_read(conn_handle, + ble_req.params.gattc_read.handle, + ble_req.params.gattc_read.offset); + break; + + case NRF_BLE_GQ_REQ_GATTC_WRITE: + { + uint8_t write_data[NRF_BLE_GQ_GATTC_WRITE_MAX_DATA_LEN]; + + // Retrieve allocated data. + ble_req.params.gattc_write.p_value = write_data; + nrf_memobj_read(ble_req.p_mem_obj, + (void *) ble_req.params.gattc_write.p_value, + ble_req.params.gattc_write.len, 0); + + NRF_LOG_DEBUG("GATTC Write Request"); + err_code = sd_ble_gattc_write(conn_handle, + &ble_req.params.gattc_write); + } break; + + case NRF_BLE_GQ_REQ_SRV_DISCOVERY: + { + NRF_LOG_DEBUG("GATTC Primary Service Discovery Request"); + err_code = sd_ble_gattc_primary_services_discover(conn_handle, + ble_req.params.gattc_srv_disc.start_handle, + &ble_req.params.gattc_srv_disc.srvc_uuid); + } break; + + case NRF_BLE_GQ_REQ_CHAR_DISCOVERY: + { + NRF_LOG_DEBUG("GATTC Characteristic Discovery Request"); + err_code = sd_ble_gattc_characteristics_discover(conn_handle, + &ble_req.params.gattc_char_disc); + } break; + + case NRF_BLE_GQ_REQ_DESC_DISCOVERY: + { + NRF_LOG_DEBUG("GATTC Characteristic Descriptor Discovery Request") + err_code = sd_ble_gattc_descriptors_discover(conn_handle, + &ble_req.params.gattc_desc_disc); + } break; + + case NRF_BLE_GQ_REQ_GATTS_HVX: + { + uint8_t hvx_data[NRF_BLE_GQ_GATTS_HVX_MAX_DATA_LEN]; + uint16_t len; + uint16_t hvx_len; + + // Retrieve allocated data. + ble_req.params.gatts_hvx.p_data = hvx_data; + nrf_memobj_read(ble_req.p_mem_obj, + (void *) &hvx_len, + sizeof(uint16_t), + 0); + ble_req.params.gatts_hvx.p_len = &hvx_len; + nrf_memobj_read(ble_req.p_mem_obj, + (void *) ble_req.params.gatts_hvx.p_data, + *ble_req.params.gatts_hvx.p_len, + sizeof(uint16_t)); + + len = hvx_len; + + NRF_LOG_DEBUG("GATTS HVX"); + err_code = sd_ble_gatts_hvx(conn_handle, + &ble_req.params.gatts_hvx); + + if ((err_code == NRF_SUCCESS) && + (len != hvx_len)) + { + err_code = NRF_ERROR_DATA_SIZE; + } + } break; + + default: + NRF_LOG_WARNING("Unimplemented GATT Request"); + break; + } + + if (err_code == NRF_ERROR_BUSY) // Softdevice is processing another GATT request. + { + NRF_LOG_DEBUG("SD is currently busy. The GATT request procedure will be attempted \ + again later."); + } + else + { + // Remove last request descriptor from the queue and free data associated with it. + if (m_req_data_alloc[ble_req.type] != NULL) + { + nrf_memobj_free(ble_req.p_mem_obj); + NRF_LOG_DEBUG("Pointer to freed memory block: %p.", ble_req.p_mem_obj); + } + UNUSED_RETURN_VALUE(nrf_queue_pop(p_queue, &ble_req)); + + request_err_code_handle(&ble_req, conn_handle, err_code); + } + } +} + + +/**@brief Function purges all requests from BGQ instance queues that are + * no longer used by any connection. + * + * @param[in] p_gatt_queue Pointer to the BGQ instance. + */ +static void queues_purge(nrf_ble_gq_t const * const p_gatt_queue) +{ + ret_code_t err_code; + uint16_t conn_id; + + err_code = nrf_queue_pop(p_gatt_queue->p_purge_queue, &conn_id); + + while (err_code == NRF_SUCCESS) + { + nrf_ble_gq_req_t ble_req; + nrf_queue_t const * p_queue; + + NRF_LOG_DEBUG("Purging request queue with id: %d", conn_id); + + p_queue = &p_gatt_queue->p_req_queue[conn_id]; + err_code = nrf_queue_pop(p_queue, &ble_req); + + while (err_code == NRF_SUCCESS) + { + // Free data associated with this request if there is any. + if (m_req_data_alloc[ble_req.type] != NULL) + { + nrf_memobj_free(ble_req.p_mem_obj); + NRF_LOG_DEBUG("Pointer to freed memory block: %p.", ble_req.p_mem_obj); + } + + err_code = nrf_queue_pop(p_queue, &ble_req); + } + + err_code = nrf_queue_pop(p_gatt_queue->p_purge_queue, &conn_id); + } +} + + +/**@brief Function processes single GATT request without queue. + * + * @param[in] p_req Pointer to GATT request. + * @param[in] conn_handle Connection handle. + * + * @retval true If request is accepted by Softdevice. + * @retval false If Softdevice is busy and the request should be queued. + */ +static bool request_process(nrf_ble_gq_req_t const * const p_req, uint16_t conn_handle) +{ + ret_code_t err_code = NRF_SUCCESS; + + switch (p_req->type) + { + case NRF_BLE_GQ_REQ_GATTC_READ: + NRF_LOG_DEBUG("GATTC Read Request"); + err_code = sd_ble_gattc_read(conn_handle, + p_req->params.gattc_read.handle, + p_req->params.gattc_read.offset); + break; + + case NRF_BLE_GQ_REQ_GATTC_WRITE: + NRF_LOG_DEBUG("GATTC Write Request"); + err_code = sd_ble_gattc_write(conn_handle, + &p_req->params.gattc_write); + break; + + case NRF_BLE_GQ_REQ_SRV_DISCOVERY: + NRF_LOG_DEBUG("GATTC Primary Services Discovery Request"); + err_code = sd_ble_gattc_primary_services_discover(conn_handle, + p_req->params.gattc_srv_disc.start_handle, + &p_req->params.gattc_srv_disc.srvc_uuid); + break; + + case NRF_BLE_GQ_REQ_CHAR_DISCOVERY: + NRF_LOG_DEBUG("GATTC Characteristic Discovery Request"); + err_code = sd_ble_gattc_characteristics_discover(conn_handle, + &p_req->params.gattc_char_disc); + break; + + case NRF_BLE_GQ_REQ_DESC_DISCOVERY: + NRF_LOG_DEBUG("GATTC Characteristic Descriptor Request"); + err_code = sd_ble_gattc_descriptors_discover(conn_handle, + &p_req->params.gattc_desc_disc); + break; + + case NRF_BLE_GQ_REQ_GATTS_HVX: + { + uint16_t len = *p_req->params.gatts_hvx.p_len; + + NRF_LOG_DEBUG("GATTS Notification or Indication"); + + err_code = sd_ble_gatts_hvx(conn_handle, + &p_req->params.gatts_hvx); + + if ((err_code == NRF_SUCCESS) && + (len != *p_req->params.gatts_hvx.p_len)) + { + err_code = NRF_ERROR_DATA_SIZE; + } + + } break; + + default: + NRF_LOG_WARNING("Unimplemented GATT Request"); + break; + } + + if (err_code == NRF_ERROR_BUSY) // Softdevice is processing another GATT request. + { + NRF_LOG_DEBUG("SD is currently busy. The GATT request procedure will be attempted \ + again later."); + return false; + } + else + { + request_err_code_handle(p_req, conn_handle, err_code); + return true; + } +} + + +/**@brief Function finds ID for the provided connection handle within nrf_ble_gq_t instance registry. + * + * @param[in] p_gatt_queue Pointer to the nrf_ble_gq_t instance. + * @param[in] conn_handle Connection handle. + * + * @return Connection ID. + */ +static uint16_t conn_handle_id_find(nrf_ble_gq_t const * const p_gatt_queue, uint16_t conn_handle) +{ + uint16_t id; + + for (id = 0; id < p_gatt_queue->max_conns; id++) + { + if (conn_handle == p_gatt_queue->p_conn_handles[id]) + { + return id; + } + } + return id; +} + + +/**@brief Function registers provided connection handle within nrf_ble_gq_t instance registry. + * + * @param[in] p_gatt_queue Pointer to the nrf_ble_gq_t instance. + * @param[in] conn_handle Connection handle. + * + * @retval NRF_SUCCESS If the registration was successful. + * @retval NRF_ERROR_NO_MEM If there was no space for another connection handle. + */ +static ret_code_t conn_handle_register(nrf_ble_gq_t const * const p_gatt_queue, uint16_t conn_handle) +{ + for (uint16_t id = 0; id < p_gatt_queue->max_conns; id++) + { + if (p_gatt_queue->p_conn_handles[id] == BLE_CONN_HANDLE_INVALID) + { + p_gatt_queue->p_conn_handles[id] = conn_handle; + return NRF_SUCCESS; + } + } + return NRF_ERROR_NO_MEM; +} + + +/**@brief Function checks if any connection handle is registered in nrf_ble_gq_t instance. + * + * @param[in] p_gatt_queue Pointer to the nrf_ble_gq_t instance. + * + * @retval true There is at least one registered connection handle. + * @retval false Connection handle registry is empty. + */ +static bool is_any_conn_handle_registered(nrf_ble_gq_t const * const p_gatt_queue) +{ + for (uint16_t id = 0; id < p_gatt_queue->max_conns; id++) + { + if (p_gatt_queue->p_conn_handles[id] != BLE_CONN_HANDLE_INVALID) + { + return true; + } + } + return false; +} + + +ret_code_t nrf_ble_gq_item_add(nrf_ble_gq_t const * const p_gatt_queue, + nrf_ble_gq_req_t * const p_req, + uint16_t conn_handle) +{ + ret_code_t err_code = NRF_SUCCESS; + uint16_t conn_id; + + NRF_LOG_DEBUG("Adding item to the request queue"); + + VERIFY_PARAM_NOT_NULL(p_gatt_queue); + VERIFY_PARAM_NOT_NULL(p_req); + + // Purge queues that are no longer used by any connection. + queues_purge(p_gatt_queue); + + // Check if connection handle is registered and if GATT request is valid. + conn_id = conn_handle_id_find(p_gatt_queue, conn_handle); + if ((p_req->type >= NRF_BLE_GQ_REQ_NUM) || (conn_id == p_gatt_queue->max_conns)) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Try processing a request without buffering. + if (nrf_queue_is_empty(&p_gatt_queue->p_req_queue[conn_id])) + { + bool req_processed = request_process(p_req, conn_handle); + if (req_processed) + { + return err_code; + } + } + + // Prepare request for buffering and add it to the queue. + if (m_req_data_alloc[p_req->type] != NULL) + { + VERIFY_PARAM_NOT_NULL(p_gatt_queue->p_data_pool); + + err_code = m_req_data_alloc[p_req->type](p_gatt_queue->p_data_pool, p_req); + VERIFY_SUCCESS(err_code); + } + + err_code = nrf_queue_push(&p_gatt_queue->p_req_queue[conn_id], p_req); + if ((err_code != NRF_SUCCESS) && (m_req_data_alloc[p_req->type] != NULL)) + { + nrf_memobj_free(p_req->p_mem_obj); + NRF_LOG_DEBUG("Pointer to freed memory block: %p.", p_req->p_mem_obj); + } + + // Check if Softdevice is still busy. + queue_process(&p_gatt_queue->p_req_queue[conn_id], conn_handle); + return err_code; +} + + +ret_code_t nrf_ble_gq_conn_handle_register(nrf_ble_gq_t * const p_gatt_queue, uint16_t conn_handle) +{ + ret_code_t err_code = NRF_SUCCESS; + uint16_t conn_id; + + VERIFY_PARAM_NOT_NULL(p_gatt_queue); + + // Purge queues that are no longer used by any connection. + queues_purge(p_gatt_queue); + + // Allow instance to claim connection handle only if it has not been claimed already. + conn_id = conn_handle_id_find(p_gatt_queue, conn_handle); + if (conn_id == p_gatt_queue->max_conns) + { + NRF_LOG_DEBUG("Registering connection handle: 0x%04X", conn_handle); + + // Initialize/reset data pool if possible. + if (!is_any_conn_handle_registered(p_gatt_queue)) + { + err_code = nrf_memobj_pool_init(p_gatt_queue->p_data_pool); + } + + err_code = conn_handle_register(p_gatt_queue, conn_handle); + VERIFY_SUCCESS(err_code); + } + return err_code; +} + + +void nrf_ble_gq_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) +{ + nrf_ble_gq_t * p_gatt_queue = (nrf_ble_gq_t *) p_context; + uint16_t conn_handle; + uint16_t conn_id; + + if ((p_ble_evt == NULL) || (p_gatt_queue == NULL)) + { + return; + } + + // Obtain connection handle and filter out the events that do not trigger queue processing. + if (p_ble_evt->header.evt_id == BLE_GAP_EVT_DISCONNECTED) + { + conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + } + else if ((p_ble_evt->header.evt_id >= BLE_GATTC_EVT_BASE) && + (p_ble_evt->header.evt_id <= BLE_GATTC_EVT_LAST)) + { + conn_handle = p_ble_evt->evt.gattc_evt.conn_handle; + } + else if ((p_ble_evt->header.evt_id >= BLE_GATTS_EVT_BASE) && + (p_ble_evt->header.evt_id <= BLE_GATTS_EVT_LAST)) + { + conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; + } + else + { + // These events are irrelevant for this module. + return; + } + + // Check if connection handle is registered. + conn_id = conn_handle_id_find(p_gatt_queue, conn_handle); + if (conn_id == p_gatt_queue->max_conns) + { + return; + } + + // Perform operations on the queue. + if (p_ble_evt->header.evt_id == BLE_GAP_EVT_DISCONNECTED) + { + p_gatt_queue->p_conn_handles[conn_id] = BLE_CONN_HANDLE_INVALID; + UNUSED_RETURN_VALUE(nrf_queue_push(p_gatt_queue->p_purge_queue, &conn_id)); + } + else + { + queue_process(&p_gatt_queue->p_req_queue[conn_id], conn_handle); + } +} + + +#endif // NRF_MODULE_ENABLED(NRF_BLE_GQ) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.h new file mode 100644 index 0000000..4796d1f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_gq/nrf_ble_gq.h @@ -0,0 +1,260 @@ +/** + * Copyright (c) 2018 - 2019, 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 nrf_ble_gq BLE GATT Queue + * @{ + * @ingroup ble_sdk_lib + * @brief Queue for the BLE GATT requests. + * + * @details The BLE GATT Queue (BGQ) module can be used to queue BLE GATT requests if the SoftDevice is not + * able to handle them at the moment. In this case, processing of queued request is + * postponed. Later on, when corresponding BLE event indicates that the SoftDevice may be + * free, the request is retried. For conceptual documentation of this module, see + * @ref lib_ble_gatt_queue. + * + */ +#ifndef NRF_BLE_GQ_H__ +#define NRF_BLE_GQ_H__ + +#include +#include "sdk_common.h" +#include "nrf_memobj.h" +#include "nrf_queue.h" +#include "nrf_sdh_ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Macro for defining a nrf_ble_gq_t instance with default parameters. + * + * @param _name Name of the instance. + * @param _max_connections The maximal number of connection handles that can be registered. + * @param _queue_size The maximal number of nrf_ble_gq_req_t instances that queue can hold. + * @hideinitializer + */ +#define NRF_BLE_GQ_DEF(_name, _max_connections, _queue_size) \ + NRF_BLE_GQ_CUSTOM_DEF(_name, \ + _max_connections, \ + _queue_size, \ + NRF_BLE_GQ_DATAPOOL_ELEMENT_SIZE, \ + NRF_BLE_GQ_DATAPOOL_ELEMENT_COUNT) + + +#if !(defined(__LINT__)) +/**@brief Macro for defining a nrf_ble_gq_t instance. + * + * @param _name Name of the instance. + * @param _max_connections The maximal number of connection handles that can be registered. + * @param _queue_size The maximal number of nrf_ble_gq_req_t instances that queue can hold. + * @param _pool_elem_size Size of a single element in the pool of memory objects. + * @param _pool_elem_count Number of elements in the pool of memory objects. + * @hideinitializer + */ +#define NRF_BLE_GQ_CUSTOM_DEF(_name, _max_connections, _queue_size, _pool_elem_size, _pool_elem_count) \ + static uint16_t CONCAT_2(_name, conn_handles_arr)[] = \ + { \ + MACRO_REPEAT(_max_connections, NRF_BLE_GQ_CONN_HANDLE_INIT) \ + }; \ + STATIC_ASSERT(ARRAY_SIZE(CONCAT_2(_name, conn_handles_arr)) == (_max_connections)); \ + NRF_QUEUE_ARRAY_DEF(nrf_ble_gq_req_t, CONCAT_2(_name, req_queue), _queue_size, \ + NRF_QUEUE_MODE_NO_OVERFLOW, _max_connections); \ + NRF_QUEUE_DEF(uint16_t, CONCAT_2(_name, purge_queue), _max_connections, \ + NRF_QUEUE_MODE_NO_OVERFLOW); \ + NRF_MEMOBJ_POOL_DEF(CONCAT_2(_name, pool), _pool_elem_size, _pool_elem_count); \ + static nrf_ble_gq_t _name = \ + { \ + .max_conns = (_max_connections), \ + .p_conn_handles = CONCAT_2(_name, conn_handles_arr), \ + .p_req_queue = CONCAT_2(_name, req_queue), \ + .p_purge_queue = &CONCAT_2(_name, purge_queue), \ + .p_data_pool = &CONCAT_2(_name, pool) \ + }; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + NRF_BLE_GQ_BLE_OBSERVER_PRIO, \ + nrf_ble_gq_on_ble_evt, &_name) +#else +#define NRF_BLE_GQ_CUSTOM_DEF(_name, _max_connections, _queue_size, _pool_elem_size, _pool_elem_count) \ + static nrf_ble_gq_t _name; +#endif // !(defined(__LINT__)) + +/**@brief Helping macro used to properly initialize connection handle array for nrf_ble_gq_t instance. + * Used in @ref NRF_BLE_GQ_CUSTOM_DEF. + */ +#define NRF_BLE_GQ_CONN_HANDLE_INIT(_arg) BLE_CONN_HANDLE_INVALID, + +/**@brief BLE GATT request types. */ +typedef enum +{ + NRF_BLE_GQ_REQ_GATTC_READ, /**< GATTC Read Request. See @ref nrf_ble_gq_gattc_read_t and @ref sd_ble_gattc_read */ + NRF_BLE_GQ_REQ_GATTC_WRITE, /**< GATTC Write Request. See @ref nrf_ble_gq_gattc_write_t and @ref sd_ble_gattc_write */ + NRF_BLE_GQ_REQ_SRV_DISCOVERY, /**< GATTC Service Discovery Request. See @ref nrf_ble_gq_gattc_write_t and @ref sd_ble_gattc_primary_services_discover. */ + NRF_BLE_GQ_REQ_CHAR_DISCOVERY, /**< GATTC Characteristic Discovery Request. See @ref nrf_ble_gq_gattc_char_disc_t and @ref sd_ble_gattc_characteristics_discover. */ + NRF_BLE_GQ_REQ_DESC_DISCOVERY, /**< GATTC Characteristic Descriptor Discovery Request. See @ref nrf_ble_gq_gattc_desc_disc_t and @ref sd_ble_gattc_descriptors_discover*/ + NRF_BLE_GQ_REQ_GATTS_HVX, /**< GATTS Handle Value Notification or Indication. See @ref nrf_ble_gq_gatts_hvx_t and @ref ble_gatts_hvx_params_t */ + NRF_BLE_GQ_REQ_NUM /**< Total number of different GATT Request types */ +} nrf_ble_gq_req_type_t; + +/**@brief Pointer used to describe error handler for GATTC request. */ +typedef void (* nrf_ble_gq_req_error_cb_t) (uint32_t nrf_error, + void * p_context, + uint16_t conn_handle); + +/**@brief Structure used to describe @ref NRF_BLE_GQ_REQ_GATTC_READ request type. */ +typedef struct +{ + uint16_t handle; /**< Handle of the Attribute to be read. */ + uint16_t offset; /**< Offset into the Attribute Value to be read. */ +} nrf_ble_gq_gattc_read_t; + +/**@brief Structure used to describe @ref NRF_BLE_GQ_REQ_GATTC_WRITE request type. */ +typedef ble_gattc_write_params_t nrf_ble_gq_gattc_write_t; + +/**@brief Structure used to describe @ref NRF_BLE_GQ_REQ_SRV_DISCOVERY request type. */ +typedef struct +{ + uint16_t start_handle; /**< The start handle value used during service discovery. */ + ble_uuid_t srvc_uuid; /**< The service UUID to be found. */ +} nrf_ble_gq_gattc_srv_discovery_t; + +/**@brief Structure used to describe @ref NRF_BLE_GQ_REQ_CHAR_DISCOVERY request type. */ +typedef ble_gattc_handle_range_t nrf_ble_gq_gattc_char_disc_t; + +/**@brief Structure used to describe @ref NRF_BLE_GQ_REQ_DESC_DISCOVERY request type. */ +typedef ble_gattc_handle_range_t nrf_ble_gq_gattc_desc_disc_t; + +/**@brief Structure used to describe @ref NRF_BLE_GQ_REQ_GATTS_HVX request type. */ +typedef ble_gatts_hvx_params_t nrf_ble_gq_gatts_hvx_t; + +/**@brief Structure used to handle SoftDevice error. */ +typedef struct +{ + nrf_ble_gq_req_error_cb_t cb; /**< Error handler to be called in case of an error from SoftDevice. */ + void * p_ctx; /**< Parameter to the error handler. */ +} nrf_ble_gq_req_error_handler_t; + + +/**@brief Structure used to describe BLE GATT request. */ +typedef struct +{ + nrf_ble_gq_req_type_t type; /**< Type of request. */ + nrf_memobj_t * p_mem_obj; /**< Memory object for data that cannot be contained in request descriptor. */ + nrf_ble_gq_req_error_handler_t error_handler; /**< Error handler structure. */ + union + { + nrf_ble_gq_gattc_read_t gattc_read; /**< GATTC read parameters. Filled when nrf_ble_gq_req_t::type is @ref NRF_BLE_GQ_REQ_GATTC_READ. */ + nrf_ble_gq_gattc_write_t gattc_write; /**< GATTC write parameters. Filled when nrf_ble_gq_req_t::type is @ref NRF_BLE_GQ_REQ_GATTC_WRITE. */ + nrf_ble_gq_gattc_srv_discovery_t gattc_srv_disc; /**< GATTC Service discovery parameters. Filled when nrf_ble_gq_req_t::type is @ref NRF_BLE_GQ_REQ_SRV_DISCOVERY. */ + nrf_ble_gq_gattc_char_disc_t gattc_char_disc; /**< GATTC characteristic discovery parameters. Filled when nrf_ble_gq_req_t::type is @ref NRF_BLE_GQ_REQ_CHAR_DISCOVERY. */ + nrf_ble_gq_gattc_desc_disc_t gattc_desc_disc; /**< GATTC characteristic descriptor discovery parameters. Filled when nrf_ble_gq_req_t::type is NRF_BLE_GQ_REQ_DESC_DISCOVERY. */ + nrf_ble_gq_gatts_hvx_t gatts_hvx; /**< GATTS Handle Value Notification or Indication Parameters. Filled when nrf_ble_gq_req_t::type is @ref NRF_BLE_GQ_REQ_GATTS_HVX. */ + } params; +} nrf_ble_gq_req_t; + +/**@brief Descriptor for the BLE GATT Queue instance. */ +typedef struct +{ + uint16_t const max_conns; /**< Maximal number of connection handles that can be registered. */ + uint16_t * p_conn_handles; /**< Pointer to array with registered connection handles.*/ + nrf_queue_t const * const p_req_queue; /**< Pointer to array of queue instances used to hold nrf_ble_gq_req_t instances.*/ + nrf_queue_t const * const p_purge_queue; /**< Pointer to the queue instance used to hold indexes of queues to purge.*/ + nrf_memobj_pool_t const * p_data_pool; /**< Memory pool used to obtain nrf_memobj_t instances.*/ +} nrf_ble_gq_t; + + +/**@brief Function for adding a GATT request to the BGQ instance. + * + * @details This function adds a request to the BGQ instance and allocates necessary memory + * for data that can be held within the request descriptor. If the SoftDevice is free, + * this request will be processed immediately. Otherwise, the request remains in + * in the queue and is processed later. + * + * @param[in] p_gatt_queue Pointer to the BGQ instance. + * @param[in] p_req Pointer to the request. + * @param[in] conn_handle Connection handle associated with the request. + * + * @retval NRF_SUCCESS If the request was added successfully. + * @retval NRF_ERROR_NULL Any parameter was NULL. + * @retval NRF_ERROR_NO_MEM There was no room in the queue or in the data pool. + * @retval NRF_ERROR_INVALID_PARAM If \p conn_handle is not registered or type of request - + * \p p_req is not valid. + * @retval err_code Other request specific error codes may be returned. + */ +ret_code_t nrf_ble_gq_item_add(nrf_ble_gq_t const * const p_gatt_queue, + nrf_ble_gq_req_t * const p_req, + uint16_t conn_handle); + + +/**@brief Function for registering connection handle in the BGQ instance. + * + * @details This function is used for registering connection handle in the BGQ instance. From this + * point, the BGQ instance can handle GATT requests associated with the handle until connection + * is no longer valid (disconnect event occurs). + * + * @param[in] p_gatt_queue Pointer to the BGQ instance. + * @param[in] conn_handle Connection handle. + * + * @retval NRF_SUCCESS If the registration was successful. + * @retval NRF_ERROR_NULL If \p p_gatt_queue was NULL. + * @retval NRF_ERROR_NO_MEM If there was no space for another connection handle. + */ +ret_code_t nrf_ble_gq_conn_handle_register(nrf_ble_gq_t * const p_gatt_queue, uint16_t conn_handle); + + +/**@brief Function for handling BLE events from the SoftDevice. + * + * @details This function handles the BLE events received from the SoftDevice. If a BLE + * event is relevant to the BGQ module, it is used to update internal variables, + * process queued GATT requests and, if necessary, send errors to the application. + * + * @param[in] p_ble_evt Pointer to the BLE event. + * @param[in] p_context Pointer to the BGQ instance. + */ +void nrf_ble_gq_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_BLE_GQ_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_qwr/nrf_ble_qwr.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_qwr/nrf_ble_qwr.c similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_qwr/nrf_ble_qwr.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_qwr/nrf_ble_qwr.c index e199dfb..c355740 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_qwr/nrf_ble_qwr.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_qwr/nrf_ble_qwr.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_BLE_QWR) @@ -59,25 +59,30 @@ ret_code_t nrf_ble_qwr_init(nrf_ble_qwr_t * p_qwr, return NRF_ERROR_INVALID_STATE; } + p_qwr->error_handler = p_qwr_init->error_handler; + p_qwr->initialized = NRF_BLE_QWR_INITIALIZED; + p_qwr->conn_handle = BLE_CONN_HANDLE_INVALID; +#if (NRF_BLE_QWR_MAX_ATTR > 0) memset(p_qwr->attr_handles, 0, sizeof(p_qwr->attr_handles)); p_qwr->nb_registered_attr = 0; - p_qwr->error_handler = p_qwr_init->error_handler; p_qwr->is_user_mem_reply_pending = false; - p_qwr->conn_handle = BLE_CONN_HANDLE_INVALID; - p_qwr->initialized = NRF_BLE_QWR_INITIALIZED; p_qwr->mem_buffer = p_qwr_init->mem_buffer; p_qwr->callback = p_qwr_init->callback; p_qwr->nb_written_handles = 0; +#endif return NRF_SUCCESS; } +#if (NRF_BLE_QWR_MAX_ATTR > 0) ret_code_t nrf_ble_qwr_attr_register(nrf_ble_qwr_t * p_qwr, uint16_t attr_handle) { VERIFY_PARAM_NOT_NULL(p_qwr); VERIFY_MODULE_INITIALIZED(); - if (p_qwr->nb_registered_attr == NRF_BLE_QWR_ATTR_LIST_SIZE) + if ((p_qwr->nb_registered_attr == NRF_BLE_QWR_MAX_ATTR) + || (p_qwr->mem_buffer.p_mem == NULL) + || (p_qwr->mem_buffer.len == 0)) { return (NRF_ERROR_NO_MEM); } @@ -145,6 +150,7 @@ ret_code_t nrf_ble_qwr_value_get(nrf_ble_qwr_t * p_qwr, *p_len = cur_len; return NRF_SUCCESS; } +#endif ret_code_t nrf_ble_qwr_conn_handle_assign(nrf_ble_qwr_t * p_qwr, @@ -165,7 +171,12 @@ static void user_mem_reply(nrf_ble_qwr_t * p_qwr) { if (p_qwr->is_user_mem_reply_pending) { - ret_code_t err_code = sd_ble_user_mem_reply(p_qwr->conn_handle, &p_qwr->mem_buffer); + ret_code_t err_code; +#if (NRF_BLE_QWR_MAX_ATTR == 0) + err_code = sd_ble_user_mem_reply(p_qwr->conn_handle, NULL); +#else + err_code = sd_ble_user_mem_reply(p_qwr->conn_handle, &p_qwr->mem_buffer); +#endif if (err_code == NRF_SUCCESS) { p_qwr->is_user_mem_reply_pending = false; @@ -190,13 +201,11 @@ static void user_mem_reply(nrf_ble_qwr_t * p_qwr) static void on_user_mem_request(nrf_ble_qwr_t * p_qwr, ble_common_evt_t const * p_common_evt) { - if (p_common_evt->conn_handle == p_qwr->conn_handle) + if ((p_common_evt->params.user_mem_request.type == BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES) && + (p_common_evt->conn_handle == p_qwr->conn_handle)) { - if (p_common_evt->params.user_mem_request.type == BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES) - { - p_qwr->is_user_mem_reply_pending = true; - user_mem_reply(p_qwr); - } + p_qwr->is_user_mem_reply_pending = true; + user_mem_reply(p_qwr); } } @@ -209,17 +218,18 @@ static void on_user_mem_request(nrf_ble_qwr_t * p_qwr, static void on_user_mem_release(nrf_ble_qwr_t * p_qwr, ble_common_evt_t const * p_common_evt) { - if (p_common_evt->conn_handle == p_qwr->conn_handle) +#if (NRF_BLE_QWR_MAX_ATTR > 0) + if ((p_common_evt->params.user_mem_release.type == BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES) && + (p_common_evt->conn_handle == p_qwr->conn_handle)) { - if (p_common_evt->params.user_mem_release.type == BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES) - { - // Cancel the current operation. - p_qwr->nb_written_handles = 0; - } + // Cancel the current operation. + p_qwr->nb_written_handles = 0; } +#endif } +#if (NRF_BLE_QWR_MAX_ATTR > 0) /**@brief Handle a prepare write event. * * @param[in] p_qwr QWR structure. @@ -362,7 +372,7 @@ static void on_cancel_write(nrf_ble_qwr_t * p_qwr, } p_qwr->nb_written_handles = 0; } - +#endif /**@brief Handle a rw_authorize_request event. * @@ -378,11 +388,38 @@ static void on_rw_authorize_request(nrf_ble_qwr_t * p_qwr, } ble_gatts_evt_rw_authorize_request_t const * p_auth_req = &p_gatts_evt->params.authorize_request; + if (p_auth_req->type != BLE_GATTS_AUTHORIZE_TYPE_WRITE) { return; } +#if (NRF_BLE_QWR_MAX_ATTR == 0) + // Handle only queued write related operations. + if ((p_auth_req->request.write.op != BLE_GATTS_OP_PREP_WRITE_REQ) && + (p_auth_req->request.write.op != BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) && + (p_auth_req->request.write.op != BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL)) + { + return; + } + + // Prepare the response. + ble_gatts_rw_authorize_reply_params_t auth_reply = {0}; + + auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; + auth_reply.params.write.gatt_status = NRF_BLE_QWR_REJ_REQUEST_ERR_CODE; + if (p_auth_req->request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL) + { + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; + } + + ret_code_t err_code = sd_ble_gatts_rw_authorize_reply(p_gatts_evt->conn_handle, &auth_reply); + if (err_code != NRF_SUCCESS) + { + // Report error to application. + p_qwr->error_handler(err_code); + } +#else switch (p_auth_req->request.write.op) { case BLE_GATTS_OP_PREP_WRITE_REQ: @@ -401,6 +438,7 @@ static void on_rw_authorize_request(nrf_ble_qwr_t * p_qwr, // No implementation needed. break; } +#endif } @@ -417,6 +455,7 @@ void nrf_ble_qwr_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) { user_mem_reply(p_qwr); } + switch (p_ble_evt->header.evt_id) { case BLE_EVT_USER_MEM_REQUEST: @@ -434,8 +473,10 @@ void nrf_ble_qwr_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) case BLE_GAP_EVT_DISCONNECTED: if (p_ble_evt->evt.gap_evt.conn_handle == p_qwr->conn_handle) { - p_qwr->conn_handle = BLE_CONN_HANDLE_INVALID; + p_qwr->conn_handle = BLE_CONN_HANDLE_INVALID; +#if (NRF_BLE_QWR_MAX_ATTR > 0) p_qwr->nb_written_handles = 0; +#endif } break; // BLE_GAP_EVT_DISCONNECTED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_qwr/nrf_ble_qwr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_qwr/nrf_ble_qwr.h similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_qwr/nrf_ble_qwr.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_qwr/nrf_ble_qwr.h index a7d7ad5..0ec84f2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/nrf_ble_qwr/nrf_ble_qwr.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_qwr/nrf_ble_qwr.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -51,13 +51,13 @@ * @ref nrf_ble_qwr_on_ble_evt(). */ +#ifndef NRF_BLE_QUEUED_WRITES_H__ +#define NRF_BLE_QUEUED_WRITES_H__ + #ifdef __cplusplus extern "C" { #endif -#ifndef NRF_BLE_QUEUED_WRITES_H__ -#define NRF_BLE_QUEUED_WRITES_H__ - #include #include "nordic_common.h" #include "sdk_common.h" @@ -69,31 +69,43 @@ extern "C" { * @param _name Name of the instance. * @hideinitializer */ -#define NRF_BLE_QWR_DEF(_name) \ -static nrf_ble_qwr_t _name; \ -NRF_SDH_BLE_OBSERVER(_name ## _obs, \ - NRF_BLE_QWR_BLE_OBSERVER_PRIO, \ - nrf_ble_qwr_on_ble_evt, &_name) - -#ifndef NRF_BLE_QWR_ATTR_LIST_SIZE -#define NRF_BLE_QWR_ATTR_LIST_SIZE 10 //!< Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. -#endif +#define NRF_BLE_QWR_DEF(_name) \ + static nrf_ble_qwr_t _name; \ + NRF_SDH_BLE_OBSERVER(_name ## _obs, \ + NRF_BLE_QWR_BLE_OBSERVER_PRIO, \ + nrf_ble_qwr_on_ble_evt, \ + &_name) + +/**@brief Macro for defining an array of nrf_ble_qwr instance. + * + * @param _name Name of the array. + * @param _cnt Size of the array. + * @hideinitializer + */ +#define NRF_BLE_QWRS_DEF(_name, _cnt) \ + static nrf_ble_qwr_t _name[_cnt]; \ + NRF_SDH_BLE_OBSERVERS(_name ## _obs, \ + NRF_BLE_QWR_BLE_OBSERVER_PRIO, \ + nrf_ble_qwr_on_ble_evt, \ + &_name, \ + _cnt) + -#define NRF_BLE_QWR_REJ_REQUEST_ERR_CODE BLE_GATT_STATUS_ATTERR_APP_BEGIN + 0 //!< Error code used by the module to reject prepare write requests on non-registered attributes. +#define NRF_BLE_QWR_REJ_REQUEST_ERR_CODE BLE_GATT_STATUS_ATTERR_APP_BEGIN + 0 //!< Error code used by the module to reject prepare write requests on non-registered attributes. /**@brief Queued Writes module event types. */ typedef enum { - NRF_BLE_QWR_EVT_EXECUTE_WRITE, //!< Event that indicates that an execute write command was received for a registered handle and that the received data was actually written and is now ready. - NRF_BLE_QWR_EVT_AUTH_REQUEST, //!< Event that indicates that an execute write command was received for a registered handle and that the write request must now be accepted or rejected. + NRF_BLE_QWR_EVT_EXECUTE_WRITE, //!< Event that indicates that an execute write command was received for a registered handle and that the received data was actually written and is now ready. + NRF_BLE_QWR_EVT_AUTH_REQUEST, //!< Event that indicates that an execute write command was received for a registered handle and that the write request must now be accepted or rejected. } nrf_ble_qwr_evt_type_t; /**@brief Queued Writes module events. */ typedef struct { - nrf_ble_qwr_evt_type_t evt_type; //!< Type of the event. - uint16_t attr_handle; //!< Handle of the attribute to which the event relates. + nrf_ble_qwr_evt_type_t evt_type; //!< Type of the event. + uint16_t attr_handle; //!< Handle of the attribute to which the event relates. } nrf_ble_qwr_evt_t; // Forward declaration of the nrf_ble_qwr_t type. @@ -111,16 +123,18 @@ typedef uint16_t (* nrf_ble_qwr_evt_handler_t) (struct nrf_ble_qwr_t * p_qwr, * @details This structure contains status information for the Queued Writes module. */ typedef struct nrf_ble_qwr_t { - uint8_t initialized; //!< Flag that indicates whether the module has been initialized. - uint16_t attr_handles[NRF_BLE_QWR_ATTR_LIST_SIZE]; //!< List of handles for registered attributes, for which the module accepts and handles prepare write operations. - uint8_t nb_registered_attr; //!< Number of registered attributes. - uint16_t written_attr_handles[NRF_BLE_QWR_ATTR_LIST_SIZE]; //!< List of attribute handles that have been written to during the current prepare write or execute write operation. - uint8_t nb_written_handles; //!< Number of attributes that have been written to during the current prepare write or execute write operation. - ble_user_mem_block_t mem_buffer; //!< Memory buffer that is provided to the SoftDevice on an ON_USER_MEM_REQUEST event. - ble_srv_error_handler_t error_handler; //!< Error handler. - bool is_user_mem_reply_pending; //!< Flag that indicates whether a mem_reply is pending (because a previous attempt returned busy). - uint16_t conn_handle; //!< Connection handle. - nrf_ble_qwr_evt_handler_t callback; //!< Event handler function that is called for events concerning the handles of all registered attributes. + uint8_t initialized; //!< Flag that indicates whether the module has been initialized. + uint16_t conn_handle; //!< Connection handle. + ble_srv_error_handler_t error_handler; //!< Error handler. + bool is_user_mem_reply_pending; //!< Flag that indicates whether a mem_reply is pending (because a previous attempt returned busy). +#if (NRF_BLE_QWR_MAX_ATTR > 0) + uint16_t attr_handles[NRF_BLE_QWR_MAX_ATTR]; //!< List of handles for registered attributes, for which the module accepts and handles prepare write operations. + uint8_t nb_registered_attr; //!< Number of registered attributes. + uint16_t written_attr_handles[NRF_BLE_QWR_MAX_ATTR]; //!< List of attribute handles that have been written to during the current prepare write or execute write operation. + uint8_t nb_written_handles; //!< Number of attributes that have been written to during the current prepare write or execute write operation. + ble_user_mem_block_t mem_buffer; //!< Memory buffer that is provided to the SoftDevice on an ON_USER_MEM_REQUEST event. + nrf_ble_qwr_evt_handler_t callback; //!< Event handler function that is called for events concerning the handles of all registered attributes. +#endif } nrf_ble_qwr_t; /**@brief Queued Writes init structure. @@ -128,9 +142,11 @@ typedef struct nrf_ble_qwr_t * that is needed to initialize the Queued Writes module. */ typedef struct { - ble_srv_error_handler_t error_handler; //!< Error handler. - ble_user_mem_block_t mem_buffer; //!< Memory buffer that is provided to the SoftDevice on an ON_USER_MEM_REQUEST event. - nrf_ble_qwr_evt_handler_t callback; //!< Event handler function that is called for events concerning the handles of all registered attributes. + ble_srv_error_handler_t error_handler; //!< Error handler. +#if (NRF_BLE_QWR_MAX_ATTR > 0) + ble_user_mem_block_t mem_buffer; //!< Memory buffer that is provided to the SoftDevice on an ON_USER_MEM_REQUEST event. + nrf_ble_qwr_evt_handler_t callback; //!< Event handler function that is called for events concerning the handles of all registered attributes. +#endif } nrf_ble_qwr_init_t; @@ -153,20 +169,22 @@ ret_code_t nrf_ble_qwr_init(nrf_ble_qwr_t * p_qwr, nrf_ble_qwr_init_t const * p_qwr_init); -/**@brief Function for registering an attribute with the Queued Writes module. +/**@brief Function for assigning a connection handle to a given instance of the Queued Writes module. * - * @details Call this function for each attribute that you want to enable for - * Queued Writes (thus a series of prepare write and execute write operations). + * @details Call this function when a link with a peer has been established to + * associate this link to the instance of the module. This makes it + * possible to handle several links and associate each link to a particular + * instance of this module. * * @param[in] p_qwr Queued Writes structure. - * @param[in] attr_handle Handle of the attribute to register. + * @param[in] conn_handle Connection handle to be associated with the given Queued Writes instance. * - * @retval NRF_SUCCESS If the registration was successful. - * @retval NRF_ERROR_NO_MEM If no more memory is available to add this registration. + * @retval NRF_SUCCESS If the assignment was successful. * @retval NRF_ERROR_NULL If any of the given pointers is NULL. * @retval NRF_ERROR_INVALID_STATE If the given context has not been initialized. */ -ret_code_t nrf_ble_qwr_attr_register(nrf_ble_qwr_t * p_qwr, uint16_t attr_handle); +ret_code_t nrf_ble_qwr_conn_handle_assign(nrf_ble_qwr_t * p_qwr, + uint16_t conn_handle); /**@brief Function for handling BLE stack events. @@ -179,6 +197,23 @@ ret_code_t nrf_ble_qwr_attr_register(nrf_ble_qwr_t * p_qwr, uint16_t attr_handle void nrf_ble_qwr_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context); +#if (NRF_BLE_QWR_MAX_ATTR > 0) +/**@brief Function for registering an attribute with the Queued Writes module. + * + * @details Call this function for each attribute that you want to enable for + * Queued Writes (thus a series of prepare write and execute write operations). + * + * @param[in] p_qwr Queued Writes structure. + * @param[in] attr_handle Handle of the attribute to register. + * + * @retval NRF_SUCCESS If the registration was successful. + * @retval NRF_ERROR_NO_MEM If no more memory is available to add this registration. + * @retval NRF_ERROR_NULL If any of the given pointers is NULL. + * @retval NRF_ERROR_INVALID_STATE If the given context has not been initialized. + */ +ret_code_t nrf_ble_qwr_attr_register(nrf_ble_qwr_t * p_qwr, uint16_t attr_handle); + + /**@brief Function for retrieving the received data for a given attribute. * * @details Call this function after receiving an @ref NRF_BLE_QWR_EVT_AUTH_REQUEST @@ -199,25 +234,9 @@ ret_code_t nrf_ble_qwr_value_get(nrf_ble_qwr_t * p_qwr, uint16_t attr_handle, uint8_t * p_mem, uint16_t * p_len); +#endif // (NRF_BLE_QWR_MAX_ATTR > 0) -/**@brief Function for assigning a connection handle to a given instance of the Queued Writes module. - * - * @details Call this function when a link with a peer has been established to - * associate this link to the instance of the module. This makes it - * possible to handle several links and associate each link to a particular - * instance of this module. - * - * @param[in] p_qwr Queued Writes structure. - * @param[in] conn_handle Connection handle to be associated with the given Queued Writes instance. - * - * @retval NRF_SUCCESS If the assignment was successful. - * @retval NRF_ERROR_NULL If any of the given pointers is NULL. - * @retval NRF_ERROR_INVALID_STATE If the given context has not been initialized. - */ -ret_code_t nrf_ble_qwr_conn_handle_assign(nrf_ble_qwr_t * p_qwr, - uint16_t conn_handle); - #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.c new file mode 100644 index 0000000..6d281b3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.c @@ -0,0 +1,1328 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_BLE_SCAN) + +#include "sdk_config.h" +#include + +#include "nrf_ble_scan.h" + +#include +#include "app_error.h" +#include "nrf_assert.h" +#include "sdk_macros.h" +#include "ble_advdata.h" + +#define NRF_LOG_MODULE_NAME ble_scan +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +/**@brief Function for establishing the connection with a device. + * + * @details Connection is established if @ref NRF_BLE_SCAN_EVT_FILTER_MATCH + * or @ref NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT occurs and the module was + * initialized in the automatic connection mode. This function can generate an event + * to the main application when @ref sd_ble_gap_connect is used inside the function and it returns value + * that is different than @ref NRF_SUCCESS. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] p_adv_report Advertising data. + */ +static void nrf_ble_scan_connect_with_target(nrf_ble_scan_t const * const p_scan_ctx, + ble_gap_evt_adv_report_t const * const p_adv_report) +{ + ret_code_t err_code; + scan_evt_t scan_evt; + + // For readability. + ble_gap_addr_t const * p_addr = &p_adv_report->peer_addr; + ble_gap_scan_params_t const * p_scan_params = &p_scan_ctx->scan_params; + ble_gap_conn_params_t const * p_conn_params = &p_scan_ctx->conn_params; + uint8_t con_cfg_tag = p_scan_ctx->conn_cfg_tag; + + // Return if the automatic connection is disabled. + if (!p_scan_ctx->connect_if_match) + { + return; + } + + // Stop scanning. + nrf_ble_scan_stop(); + + memset(&scan_evt, 0, sizeof(scan_evt)); + + // Establish connection. + err_code = sd_ble_gap_connect(p_addr, + p_scan_params, + p_conn_params, + con_cfg_tag); + + NRF_LOG_DEBUG("Connecting"); + + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_CONNECTING_ERROR; + scan_evt.params.connecting_err.err_code = err_code; + + NRF_LOG_DEBUG("Connection status: %d", err_code); + + // If an error occurred, send an event to the event handler. + if ((err_code != NRF_SUCCESS) && (p_scan_ctx->evt_handler != NULL)) + { + p_scan_ctx->evt_handler(&scan_evt); + } + +} + + +/**@brief Function for decoding the BLE address type. + * + * @param[in] p_addr The BLE address. + * + * @return Address type, or an error if the address type is incorrect, that is it does not match @ref BLE_GAP_ADDR_TYPES. + * + */ +static uint16_t nrf_ble_scan_address_type_decode(uint8_t const * p_addr) +{ + uint8_t addr_type = p_addr[0]; + + // See Bluetooth Core Specification Vol 6, Part B, section 1.3. + addr_type = addr_type >> 6; + addr_type &= 0x03; + + // Check address type. + switch (addr_type) + { + case 0: + { + return BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE; + } + + case 1: + { + return BLE_GAP_ADDR_TYPE_PUBLIC; + } + + case 2: + { + return BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE; + } + + case 3: + { + return BLE_GAP_ADDR_TYPE_RANDOM_STATIC; + } + + default: + { + return BLE_ERROR_GAP_INVALID_BLE_ADDR; + } + } +} + + +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + +/**@brief Function for searching for the provided address in the advertisement packets. + * + * @details Use this function to parse the received advertising data for the provided address. + * + * + * @param[in] p_adv_report Advertising data to parse. + * @param[in] p_addr Address to search for. The address length must correspond to @ref BLE_GAP_ADDR_LEN. + * + * @return True if the provided address was found, false otherwise. + */ +static bool find_peer_addr(ble_gap_evt_adv_report_t const * const p_adv_report, + ble_gap_addr_t const * p_addr) +{ + if (p_addr->addr_type == p_adv_report->peer_addr.addr_type) + { + // Compare addresses. + if (memcmp(p_addr->addr, + p_adv_report->peer_addr.addr, + sizeof(p_adv_report->peer_addr.addr)) == 0) + { + return true; + } + } + return false; +} + + +/** @brief Function for comparing the provided address with the addresses of the advertising devices. + * + * @param[in] p_adv_report Advertising data to parse. + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval True when the address matches with the addresses of the advertising devices. False otherwise. + */ +static bool adv_addr_compare(ble_gap_evt_adv_report_t const * const p_adv_report, + nrf_ble_scan_t const * const p_scan_ctx) +{ + ble_gap_addr_t const * p_addr = p_scan_ctx->scan_filters.addr_filter.target_addr; + uint8_t counter = p_scan_ctx->scan_filters.addr_filter.addr_cnt; + + for (uint8_t index = 0; index < counter; index++) + { + // Search for address. + if (find_peer_addr(p_adv_report, &p_addr[index])) + { + return true; + } + } + + return false; +} + + +/**@brief Function for adding target address to the scanning filter. + * + * @param[in] p_addr Target address in the format required by the SoftDevice. If you need to convert the address, use @ref nrf_ble_scan_copy_addr_to_sd_gap_addr. The address length must correspond to @ref BLE_GAP_ADDR_LEN. + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If the filter is added successfully or if you try to add a filter that was already added before. + * @retval NRF_ERROR_NO_MEMORY If the number of available filters is exceeded. + * @retval BLE_ERROR_GAP_INVALID_BLE_ADDR If the BLE address type is invalid. + */ +static ret_code_t nrf_ble_scan_addr_filter_add(nrf_ble_scan_t * const p_scan_ctx, + uint8_t const * p_addr) +{ + ble_gap_addr_t * p_addr_filter = p_scan_ctx->scan_filters.addr_filter.target_addr; + uint8_t * p_counter = &p_scan_ctx->scan_filters.addr_filter.addr_cnt; + uint8_t index; + uint16_t addr_type; + uint8_t temp_addr[BLE_GAP_ADDR_LEN]; + + // If no memory for filter. + if (*p_counter >= NRF_BLE_SCAN_ADDRESS_CNT) + { + return NRF_ERROR_NO_MEM; + } + + // Check for duplicated filter. + for (index = 0; index < NRF_BLE_SCAN_ADDRESS_CNT; index++) + { + if (!memcmp(p_addr_filter[index].addr, p_addr, BLE_GAP_ADDR_LEN)) + { + return NRF_SUCCESS; + } + } + + // Inverting the address. + for (uint8_t i = 0; i < BLE_GAP_ADDR_LEN; i++) + { + temp_addr[i] = p_addr[(BLE_GAP_ADDR_LEN - 1) - i]; + } + + // Decode address type. + addr_type = nrf_ble_scan_address_type_decode(temp_addr); + + if (addr_type == BLE_ERROR_GAP_INVALID_BLE_ADDR) + { + return BLE_ERROR_GAP_INVALID_BLE_ADDR; + } + + // Add target address to filter. + p_addr_filter[*p_counter].addr_type = (uint8_t)addr_type; + + for (uint8_t i = 0; i < BLE_GAP_ADDR_LEN; i++) + { + p_addr_filter[*p_counter].addr[i] = p_addr[i]; + } + + NRF_LOG_DEBUG("Filter set on address type %i, address 0x", + p_addr_filter[*p_counter].addr_type); + + for (index = 0; index < BLE_GAP_ADDR_LEN; index++) + { + NRF_LOG_DEBUG("%x", p_addr_filter[*p_counter].addr[index]); + } + + NRF_LOG_DEBUG("\n\r"); + + // Increase the address filter counter. + *p_counter += 1; + + return NRF_SUCCESS; +} + + +#endif // NRF_BLE_SCAN_ADDRESS_CNT + + +#if (NRF_BLE_SCAN_NAME_CNT > 0) +/** @brief Function for comparing the provided name with the advertised name. + * + * @param[in] p_adv_report Advertising data to parse. + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval True when the names match. False otherwise. + */ +static bool adv_name_compare(ble_gap_evt_adv_report_t const * p_adv_report, + nrf_ble_scan_t const * const p_scan_ctx) +{ + nrf_ble_scan_name_filter_t const * p_name_filter = &p_scan_ctx->scan_filters.name_filter; + uint8_t counter = + p_scan_ctx->scan_filters.name_filter.name_cnt; + uint8_t index; + uint16_t data_len; + + data_len = p_adv_report->data.len; + + // Compare the name found with the name filter. + for (index = 0; index < counter; index++) + { + if (ble_advdata_name_find(p_adv_report->data.p_data, + data_len, + p_name_filter->target_name[index])) + { + return true; + } + } + + return false; +} + + +/**@brief Function for adding name of the peripheral to the scanning filter. + * + * @param[in] p_name Peripheral name. + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If the filter is added successfully or if you try to add a filter that was already added before. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + * @retval NRF_ERROR_DATA_SIZE If the name filter length is too long. The maximum filter name length corresponds to @ref NRF_BLE_SCAN_NAME_MAX_LEN. + * @retval NRF_ERROR_NO_MEMORY If the number of available filters is exceeded. + */ +static ret_code_t nrf_ble_scan_name_filter_add(nrf_ble_scan_t * const p_scan_ctx, + char const * p_name) +{ + uint8_t index; + uint8_t * counter = &p_scan_ctx->scan_filters.name_filter.name_cnt; + uint8_t name_len = strlen(p_name); + + // Check the name length. + if ((name_len == 0) || (name_len > NRF_BLE_SCAN_NAME_MAX_LEN)) + { + return NRF_ERROR_DATA_SIZE; + } + + // If no memory for filter. + if (*counter >= NRF_BLE_SCAN_NAME_CNT) + { + return NRF_ERROR_NO_MEM; + } + + // Check for duplicated filter. + for (index = 0; index < NRF_BLE_SCAN_NAME_CNT; index++) + { + if (!strcmp(p_scan_ctx->scan_filters.name_filter.target_name[index], p_name)) + { + return NRF_SUCCESS; + } + } + + // Add name to filter. + memcpy(p_scan_ctx->scan_filters.name_filter.target_name[(*counter)++], + p_name, + strlen(p_name)); + + NRF_LOG_DEBUG("Adding filter on %s name", p_name); + + return NRF_SUCCESS; +} + + +#endif // NRF_BLE_SCAN_NAME_CNT + + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) +/** @brief Function for comparing the provided short name with the advertised short name. + * + * @param[in] p_adv_report Advertising data to parse. + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval True when the names match. False otherwise. + */ +static bool adv_short_name_compare(ble_gap_evt_adv_report_t const * const p_adv_report, + nrf_ble_scan_t const * const p_scan_ctx) +{ + nrf_ble_scan_short_name_filter_t const * p_name_filter = + &p_scan_ctx->scan_filters.short_name_filter; + uint8_t counter = p_scan_ctx->scan_filters.short_name_filter.name_cnt; + uint8_t index; + uint16_t data_len; + + data_len = p_adv_report->data.len; + + // Compare the name found with the name filters. + for (index = 0; index < counter; index++) + { + if (ble_advdata_short_name_find(p_adv_report->data.p_data, + data_len, + p_name_filter->short_name[index].short_target_name, + p_name_filter->short_name[index].short_name_min_len)) + { + return true; + } + } + + return false; +} + + +/**@brief Function for adding the short name of the peripheral to the scanning filter. + * + * @param[in] p_short_name Short name of the peripheral. + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If the filter is added successfully or if you try to add a filter that was already added before. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + * @retval NRF_ERROR_DATA_SIZE If the name filter length is too long. The maximum filter name length corresponds to @ref NRF_BLE_SCAN_SHORT_NAME_MAX_LEN. + * @retval NRF_ERROR_NO_MEMORY If the number of available filters is exceeded. + */ +static ret_code_t nrf_ble_scan_short_name_filter_add(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_short_name_t const * p_short_name) +{ + uint8_t index; + uint8_t * p_counter = + &p_scan_ctx->scan_filters.short_name_filter.name_cnt; + nrf_ble_scan_short_name_filter_t * p_short_name_filter = + &p_scan_ctx->scan_filters.short_name_filter; + uint8_t name_len = strlen(p_short_name->p_short_name); + + // Check the name length. + if ((name_len == 0) || (name_len > NRF_BLE_SCAN_SHORT_NAME_MAX_LEN)) + { + return NRF_ERROR_DATA_SIZE; + } + + // If no memory for filter. + if (*p_counter >= NRF_BLE_SCAN_SHORT_NAME_CNT) + { + return NRF_ERROR_NO_MEM; + } + + // Check for duplicated filter. + for (index = 0; index < NRF_BLE_SCAN_SHORT_NAME_CNT; index++) + { + if (!strcmp(p_short_name_filter->short_name[index].short_target_name, + p_short_name->p_short_name)) + { + return NRF_SUCCESS; + } + } + + // Add name to the filter. + p_short_name_filter->short_name[(*p_counter)].short_name_min_len = + p_short_name->short_name_min_len; + memcpy(p_short_name_filter->short_name[(*p_counter)++].short_target_name, + p_short_name->p_short_name, + strlen(p_short_name->p_short_name)); + + NRF_LOG_DEBUG("Adding filter on %s name", p_short_name->p_short_name); + + return NRF_SUCCESS; +} + + +#endif + + +#if (NRF_BLE_SCAN_UUID_CNT > 0) +/**@brief Function for comparing the provided UUID with the UUID in the advertisement packets. + * + * @param[in] p_adv_report Advertising data to parse. + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @return True if the UUIDs match. False otherwise. + */ +static bool adv_uuid_compare(ble_gap_evt_adv_report_t const * const p_adv_report, + nrf_ble_scan_t const * const p_scan_ctx) +{ + nrf_ble_scan_uuid_filter_t const * p_uuid_filter = &p_scan_ctx->scan_filters.uuid_filter; + bool const all_filters_mode = p_scan_ctx->scan_filters.all_filters_mode; + uint8_t const counter = + p_scan_ctx->scan_filters.uuid_filter.uuid_cnt; + uint8_t index; + uint16_t data_len; + uint8_t uuid_match_cnt = 0; + + data_len = p_adv_report->data.len; + + for (index = 0; index < counter; index++) + { + + if (ble_advdata_uuid_find(p_adv_report->data.p_data, + data_len, + &p_uuid_filter->uuid[index])) + { + uuid_match_cnt++; + + // In the normal filter mode, only one UUID is needed to match. + if (!all_filters_mode) + { + break; + } + } + else if (all_filters_mode) + { + break; + } + else + { + // Do nothing. + } + } + + // In the multifilter mode, all UUIDs must be found in the advertisement packets. + if ((all_filters_mode && (uuid_match_cnt == counter)) || + ((!all_filters_mode) && (uuid_match_cnt > 0))) + { + return true; + } + + return false; +} + + +/**@brief Function for adding UUID to the scanning filter. + * + * @param[in] uuid UUID, 16-bit size. + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If the scanning started. Otherwise, an error code is returned, also if you tried to add a filter that was already added before. + * @retval NRF_ERROR_NO_MEMORY If the number of available filters is exceeded. + */ +static ret_code_t nrf_ble_scan_uuid_filter_add(nrf_ble_scan_t * const p_scan_ctx, + ble_uuid_t const * p_uuid) +{ + ble_uuid_t * p_uuid_filter = p_scan_ctx->scan_filters.uuid_filter.uuid; + uint8_t * p_counter = &p_scan_ctx->scan_filters.uuid_filter.uuid_cnt; + uint8_t index; + + // If no memory. + if (*p_counter >= NRF_BLE_SCAN_UUID_CNT) + { + return NRF_ERROR_NO_MEM; + } + + // Check for duplicated filter. + for (index = 0; index < NRF_BLE_SCAN_UUID_CNT; index++) + { + if (p_uuid_filter[index].uuid == p_uuid->uuid) + { + return NRF_SUCCESS; + } + } + + // Add UUID to the filter. + p_uuid_filter[(*p_counter)++] = *p_uuid; + NRF_LOG_DEBUG("Added filter on UUID %x", p_uuid->uuid); + + return NRF_SUCCESS; +} + + +#endif // NRF_BLE_SCAN_UUID_CNT + + +#if (NRF_BLE_SCAN_APPEARANCE_CNT) +/**@brief Function for comparing the provided appearance with the appearance in the advertisement packets. + * + * @param[in] p_adv_report Advertising data to parse. + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @return True if the appearances match. False otherwise. + */ +static bool adv_appearance_compare(ble_gap_evt_adv_report_t const * const p_adv_report, + nrf_ble_scan_t const * const p_scan_ctx) +{ + nrf_ble_scan_appearance_filter_t const * p_appearance_filter = + &p_scan_ctx->scan_filters.appearance_filter; + uint8_t const counter = + p_scan_ctx->scan_filters.appearance_filter.appearance_cnt; + uint8_t index; + uint16_t data_len; + + data_len = p_adv_report->data.len; + + // Verify if the advertised appearance matches the provided appearance. + for (index = 0; index < counter; index++) + { + if (ble_advdata_appearance_find(p_adv_report->data.p_data, + data_len, + &p_appearance_filter->appearance[index])) + { + return true; + } + } + return false; +} + + +/**@brief Function for adding appearance to the scanning filter. + * + * @param[in] appearance Appearance to be added. + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If the filter is added successfully or if you try to add a filter that was already added before. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + * @retval NRF_ERROR_NO_MEMORY If the number of available filters is exceeded. + */ +static ret_code_t nrf_ble_scan_appearance_filter_add(nrf_ble_scan_t * const p_scan_ctx, + uint16_t appearance) +{ + uint16_t * p_appearance_filter = p_scan_ctx->scan_filters.appearance_filter.appearance; + uint8_t * p_counter = &p_scan_ctx->scan_filters.appearance_filter.appearance_cnt; + uint8_t index; + + // If no memory. + if (*p_counter >= NRF_BLE_SCAN_APPEARANCE_CNT) + { + return NRF_ERROR_NO_MEM; + } + + // Check for duplicated filter. + for ( index = 0; index < NRF_BLE_SCAN_APPEARANCE_CNT; index++) + { + if (p_appearance_filter[index] == appearance) + { + return NRF_SUCCESS; + } + } + + // Add appearance to the filter. + p_appearance_filter[(*p_counter)++] = appearance; + NRF_LOG_DEBUG("Added filter on appearance %x", appearance); + return NRF_SUCCESS; +} + + +#endif // NRF_BLE_SCAN_APPEARANCE_CNT + + +ret_code_t nrf_ble_scan_filter_set(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_filter_type_t type, + void const * p_data) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + VERIFY_PARAM_NOT_NULL(p_data); + + switch (type) + { +#if (NRF_BLE_SCAN_NAME_CNT > 0) + case SCAN_NAME_FILTER: + { + char * p_name = (char *)p_data; + return nrf_ble_scan_name_filter_add(p_scan_ctx, p_name); + } +#endif + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) + case SCAN_SHORT_NAME_FILTER: + { + nrf_ble_scan_short_name_t * p_short_name = (nrf_ble_scan_short_name_t *)p_data; + return nrf_ble_scan_short_name_filter_add(p_scan_ctx, p_short_name); + } +#endif + +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + case SCAN_ADDR_FILTER: + { + uint8_t * p_addr = (uint8_t *)p_data; + return nrf_ble_scan_addr_filter_add(p_scan_ctx, p_addr); + } +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) + case SCAN_UUID_FILTER: + { + ble_uuid_t * p_uuid = (ble_uuid_t *)p_data; + return nrf_ble_scan_uuid_filter_add(p_scan_ctx, p_uuid); + } +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + case SCAN_APPEARANCE_FILTER: + { + uint16_t appearance = *((uint16_t *)p_data); + return nrf_ble_scan_appearance_filter_add(p_scan_ctx, appearance); + } +#endif + + default: + return NRF_ERROR_INVALID_PARAM; + } +} + + +ret_code_t nrf_ble_scan_all_filter_remove(nrf_ble_scan_t * const p_scan_ctx) +{ +#if (NRF_BLE_SCAN_NAME_CNT > 0) + nrf_ble_scan_name_filter_t * p_name_filter = &p_scan_ctx->scan_filters.name_filter; + memset(p_name_filter->target_name, 0, sizeof(p_name_filter->target_name)); + p_name_filter->name_cnt = 0; +#endif + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) + nrf_ble_scan_short_name_filter_t * p_short_name_filter = + &p_scan_ctx->scan_filters.short_name_filter; + memset(p_short_name_filter->short_name, 0, sizeof(p_short_name_filter->short_name)); + p_short_name_filter->name_cnt = 0; +#endif + +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + nrf_ble_scan_addr_filter_t * p_addr_filter = &p_scan_ctx->scan_filters.addr_filter; + memset(p_addr_filter->target_addr, 0, sizeof(p_addr_filter->target_addr)); + p_addr_filter->addr_cnt = 0; +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) + nrf_ble_scan_uuid_filter_t * p_uuid_filter = &p_scan_ctx->scan_filters.uuid_filter; + memset(p_uuid_filter->uuid, 0, sizeof(p_uuid_filter->uuid)); + p_uuid_filter->uuid_cnt = 0; +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + nrf_ble_scan_appearance_filter_t * p_appearance_filter = + &p_scan_ctx->scan_filters.appearance_filter; + memset(p_appearance_filter->appearance, 0, sizeof(p_appearance_filter->appearance)); + p_appearance_filter->appearance_cnt = 0; +#endif + + return NRF_SUCCESS; +} + + +ret_code_t nrf_ble_scan_filters_enable(nrf_ble_scan_t * const p_scan_ctx, + uint8_t mode, + bool match_all) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + + // Check if the mode is correct. + if ((!(mode & NRF_BLE_SCAN_ADDR_FILTER)) && + (!(mode & NRF_BLE_SCAN_NAME_FILTER)) && + (!(mode & NRF_BLE_SCAN_UUID_FILTER)) && + (!(mode & NRF_BLE_SCAN_SHORT_NAME_FILTER)) && + (!(mode & NRF_BLE_SCAN_APPEARANCE_FILTER))) + { + return NRF_ERROR_INVALID_PARAM; + } + + ret_code_t err_code; + + // Disable filters. + err_code = nrf_ble_scan_filters_disable(p_scan_ctx); + ASSERT(err_code == NRF_SUCCESS); + + nrf_ble_scan_filters_t * p_filters = &p_scan_ctx->scan_filters; + + // Turn on the filters of your choice. +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + if (mode & NRF_BLE_SCAN_ADDR_FILTER) + { + p_filters->addr_filter.addr_filter_enabled = true; + } +#endif + +#if (NRF_BLE_SCAN_NAME_CNT > 0) + if (mode & NRF_BLE_SCAN_NAME_FILTER) + { + p_filters->name_filter.name_filter_enabled = true; + } +#endif + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) + if (mode & NRF_BLE_SCAN_SHORT_NAME_FILTER) + { + p_filters->short_name_filter.short_name_filter_enabled = true; + } +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) + if (mode & NRF_BLE_SCAN_UUID_FILTER) + { + p_filters->uuid_filter.uuid_filter_enabled = true; + } +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + if (mode & NRF_BLE_SCAN_APPEARANCE_FILTER) + { + p_filters->appearance_filter.appearance_filter_enabled = true; + } +#endif + + // Select the filter mode. + p_filters->all_filters_mode = match_all; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_ble_scan_filters_disable(nrf_ble_scan_t * const p_scan_ctx) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + + // Disable all filters. +#if (NRF_BLE_SCAN_NAME_CNT > 0) + bool * p_name_filter_enabled = &p_scan_ctx->scan_filters.name_filter.name_filter_enabled; + *p_name_filter_enabled = false; +#endif + +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + bool * p_addr_filter_enabled = &p_scan_ctx->scan_filters.addr_filter.addr_filter_enabled; + *p_addr_filter_enabled = false; +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) + bool * p_uuid_filter_enabled = &p_scan_ctx->scan_filters.uuid_filter.uuid_filter_enabled; + *p_uuid_filter_enabled = false; +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + bool * p_appearance_filter_enabled = + &p_scan_ctx->scan_filters.appearance_filter.appearance_filter_enabled; + *p_appearance_filter_enabled = false; +#endif + + return NRF_SUCCESS; +} + + +ret_code_t nrf_ble_scan_filter_get(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_filters_t * p_status) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + VERIFY_PARAM_NOT_NULL(p_status); + + *p_status = p_scan_ctx->scan_filters; + + return NRF_SUCCESS; +} + + +#endif // NRF_BLE_SCAN_FILTER_ENABLE + +/**@brief Function for calling the BLE_GAP_EVT_ADV_REPORT event to check whether the received + * scanning data matches the scan configuration. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] p_adv_report Advertising report. + */ +static void nrf_ble_scan_on_adv_report(nrf_ble_scan_t const * const p_scan_ctx, + ble_gap_evt_adv_report_t const * const p_adv_report) +{ + scan_evt_t scan_evt; + +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) + uint8_t filter_cnt = 0; + uint8_t filter_match_cnt = 0; +#endif + + memset(&scan_evt, 0, sizeof(scan_evt)); + + scan_evt.p_scan_params = &p_scan_ctx->scan_params; + + // If the whitelist is used, do not check the filters and return. + if (is_whitelist_used(p_scan_ctx)) + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT; + scan_evt.params.p_not_found = p_adv_report; + p_scan_ctx->evt_handler(&scan_evt); + + UNUSED_RETURN_VALUE(sd_ble_gap_scan_start(NULL, &p_scan_ctx->scan_buffer)); + nrf_ble_scan_connect_with_target(p_scan_ctx, p_adv_report); + + return; + } + +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) + bool const all_filter_mode = p_scan_ctx->scan_filters.all_filters_mode; + bool is_filter_matched = false; + +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + bool const addr_filter_enabled = p_scan_ctx->scan_filters.addr_filter.addr_filter_enabled; +#endif + +#if (NRF_BLE_SCAN_NAME_CNT > 0) + bool const name_filter_enabled = p_scan_ctx->scan_filters.name_filter.name_filter_enabled; +#endif + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) + bool const short_name_filter_enabled = + p_scan_ctx->scan_filters.short_name_filter.short_name_filter_enabled; +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) + bool const uuid_filter_enabled = p_scan_ctx->scan_filters.uuid_filter.uuid_filter_enabled; +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + bool const appearance_filter_enabled = + p_scan_ctx->scan_filters.appearance_filter.appearance_filter_enabled; +#endif + + +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + // Check the address filter. + if (addr_filter_enabled) + { + // Number of active filters. + filter_cnt++; + if (adv_addr_compare(p_adv_report, p_scan_ctx)) + { + // Number of filters matched. + filter_match_cnt++; + // Information about the filters matched. + scan_evt.params.filter_match.filter_match.address_filter_match = true; + is_filter_matched = true; + } + } +#endif + +#if (NRF_BLE_SCAN_NAME_CNT > 0) + // Check the name filter. + if (name_filter_enabled) + { + filter_cnt++; + if (adv_name_compare(p_adv_report, p_scan_ctx)) + { + filter_match_cnt++; + + // Information about the filters matched. + scan_evt.params.filter_match.filter_match.name_filter_match = true; + is_filter_matched = true; + } + } +#endif + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) + if (short_name_filter_enabled) + { + filter_cnt++; + if (adv_short_name_compare(p_adv_report, p_scan_ctx)) + { + filter_match_cnt++; + + // Information about the filters matched. + scan_evt.params.filter_match.filter_match.short_name_filter_match = true; + is_filter_matched = true; + } + } +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) + // Check the UUID filter. + if (uuid_filter_enabled) + { + filter_cnt++; + if (adv_uuid_compare(p_adv_report, p_scan_ctx)) + { + filter_match_cnt++; + // Information about the filters matched. + scan_evt.params.filter_match.filter_match.uuid_filter_match = true; + is_filter_matched = true; + } + } +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + // Check the appearance filter. + if (appearance_filter_enabled) + { + filter_cnt++; + if (adv_appearance_compare(p_adv_report, p_scan_ctx)) + { + filter_match_cnt++; + // Information about the filters matched. + scan_evt.params.filter_match.filter_match.appearance_filter_match = true; + is_filter_matched = true; + } + } + + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_NOT_FOUND; +#endif + + scan_evt.params.filter_match.p_adv_report = p_adv_report; + + // In the multifilter mode, the number of the active filters must equal the number of the filters matched to generate the notification. + if (all_filter_mode && (filter_match_cnt == filter_cnt)) + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_FILTER_MATCH; + nrf_ble_scan_connect_with_target(p_scan_ctx, p_adv_report); + } + // In the normal filter mode, only one filter match is needed to generate the notification to the main application. + else if ((!all_filter_mode) && is_filter_matched) + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_FILTER_MATCH; + nrf_ble_scan_connect_with_target(p_scan_ctx, p_adv_report); + } + else + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_NOT_FOUND; + scan_evt.params.p_not_found = p_adv_report; + + } + + // If the event handler is not NULL, notify the main application. + if (p_scan_ctx->evt_handler != NULL) + { + p_scan_ctx->evt_handler(&scan_evt); + } + +#endif // NRF_BLE_SCAN_FILTER_ENABLE + + // Resume the scanning. + UNUSED_RETURN_VALUE(sd_ble_gap_scan_start(NULL, &p_scan_ctx->scan_buffer)); +} + + +/**@brief Function for checking whether the whitelist is used. + * + * @param[in] p_scan_ctx Scanning Module instance. + */ +bool is_whitelist_used(nrf_ble_scan_t const * const p_scan_ctx) +{ + if (p_scan_ctx->scan_params.filter_policy == BLE_GAP_SCAN_FP_WHITELIST || + p_scan_ctx->scan_params.filter_policy == BLE_GAP_SCAN_FP_WHITELIST_NOT_RESOLVED_DIRECTED) + { + return true; + } + + return false; +} + + +/**@brief Function for restoring the default scanning parameters. + * + * @param[out] p_scan_ctx Pointer to the Scanning Module instance. + */ +static void nrf_ble_scan_default_param_set(nrf_ble_scan_t * const p_scan_ctx) +{ + // Set the default parameters. + p_scan_ctx->scan_params.active = 1; + p_scan_ctx->scan_params.interval = NRF_BLE_SCAN_SCAN_INTERVAL; + p_scan_ctx->scan_params.window = NRF_BLE_SCAN_SCAN_WINDOW; + p_scan_ctx->scan_params.timeout = NRF_BLE_SCAN_SCAN_DURATION; + p_scan_ctx->scan_params.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL; + p_scan_ctx->scan_params.scan_phys = BLE_GAP_PHY_1MBPS; +} + + +/**@brief Function for setting the default connection parameters. + * + * @param[out] p_scan_ctx Pointer to the Scanning Module instance. + */ +static void nrf_ble_scan_default_conn_param_set(nrf_ble_scan_t * const p_scan_ctx) +{ + p_scan_ctx->conn_params.conn_sup_timeout = + (uint16_t)MSEC_TO_UNITS(NRF_BLE_SCAN_SUPERVISION_TIMEOUT, UNIT_10_MS); + p_scan_ctx->conn_params.min_conn_interval = + (uint16_t)MSEC_TO_UNITS(NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL, UNIT_1_25_MS); + p_scan_ctx->conn_params.max_conn_interval = + (uint16_t)MSEC_TO_UNITS(NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL, UNIT_1_25_MS); + p_scan_ctx->conn_params.slave_latency = + (uint16_t)NRF_BLE_SCAN_SLAVE_LATENCY; +} + + +/**@brief Function for calling the BLE_GAP_EVT_TIMEOUT event. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] p_gap GAP event structure. + */ +static void nrf_ble_scan_on_timeout(nrf_ble_scan_t const * const p_scan_ctx, + ble_gap_evt_t const * const p_gap) +{ + ble_gap_evt_timeout_t const * p_timeout = &p_gap->params.timeout; + scan_evt_t scan_evt; + + memset(&scan_evt, 0, sizeof(scan_evt)); + + if (p_timeout->src == BLE_GAP_TIMEOUT_SRC_SCAN) + { + NRF_LOG_DEBUG("BLE_GAP_SCAN_TIMEOUT"); + if (p_scan_ctx->evt_handler != NULL) + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_SCAN_TIMEOUT; + scan_evt.p_scan_params = &p_scan_ctx->scan_params; + scan_evt.params.timeout.src = p_timeout->src; + + p_scan_ctx->evt_handler(&scan_evt); + } + } +} + + +/**@brief Function for calling the BLE_GAP_EVT_SCAN_REQ_REPORT event. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] p_gap GAP event structure. + */ +static void nrf_ble_scan_on_req_report(nrf_ble_scan_t const * const p_scan_ctx, + ble_gap_evt_t const * const p_gap) +{ + ble_gap_evt_scan_req_report_t const * p_req_report = &p_gap->params.scan_req_report; + scan_evt_t scan_evt; + + memset(&scan_evt, 0, sizeof(scan_evt)); + + if (p_scan_ctx->evt_handler != NULL) + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT; + scan_evt.p_scan_params = &p_scan_ctx->scan_params; + scan_evt.params.req_report = *p_req_report; + + p_scan_ctx->evt_handler(&scan_evt); + } +} + + +/**@brief Function for stopping the scanning. + */ +void nrf_ble_scan_stop(void) +{ + // It is ok to ignore the function return value here, because this function can return NRF_SUCCESS or + // NRF_ERROR_INVALID_STATE, when app is not in the scanning state. + UNUSED_RETURN_VALUE(sd_ble_gap_scan_stop()); +} + + +ret_code_t nrf_ble_scan_init(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_init_t const * const p_init, + nrf_ble_scan_evt_handler_t evt_handler) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + + p_scan_ctx->evt_handler = evt_handler; + +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) + // Disable all scanning filters. + memset(&p_scan_ctx->scan_filters, 0, sizeof(p_scan_ctx->scan_filters)); +#endif + + // If the pointer to the initialization structure exist, use it to scan the configuration. + if (p_init != NULL) + { + p_scan_ctx->connect_if_match = p_init->connect_if_match; + p_scan_ctx->conn_cfg_tag = p_init->conn_cfg_tag; + + if (p_init->p_scan_param != NULL) + { + p_scan_ctx->scan_params = *p_init->p_scan_param; + } + else + { + // Use the default static configuration. + nrf_ble_scan_default_param_set(p_scan_ctx); + } + + if (p_init->p_conn_param != NULL) + { + p_scan_ctx->conn_params = *p_init->p_conn_param; + } + else + { + // Use the default static configuration. + nrf_ble_scan_default_conn_param_set(p_scan_ctx); + } + } + // If pointer is NULL, use the static default configuration. + else + { + nrf_ble_scan_default_param_set(p_scan_ctx); + nrf_ble_scan_default_conn_param_set(p_scan_ctx); + + p_scan_ctx->connect_if_match = false; + } + + // Assign a buffer where the advertising reports are to be stored by the SoftDevice. + p_scan_ctx->scan_buffer.p_data = p_scan_ctx->scan_buffer_data; + p_scan_ctx->scan_buffer.len = NRF_BLE_SCAN_BUFFER; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_ble_scan_start(nrf_ble_scan_t const * const p_scan_ctx) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + + ret_code_t err_code; + scan_evt_t scan_evt; + + memset(&scan_evt, 0, sizeof(scan_evt)); + + nrf_ble_scan_stop(); + + // If the whitelist is used and the event handler is not NULL, send the whitelist request to the main application. + if (is_whitelist_used(p_scan_ctx)) + { + if (p_scan_ctx->evt_handler != NULL) + { + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_WHITELIST_REQUEST; + p_scan_ctx->evt_handler(&scan_evt); + } + } + + // Start the scanning. + err_code = sd_ble_gap_scan_start(&p_scan_ctx->scan_params, &p_scan_ctx->scan_buffer); + + // It is okay to ignore this error, because the scan stopped earlier. + if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_SUCCESS)) + { + NRF_LOG_ERROR("sd_ble_gap_scan_start returned 0x%x", err_code); + return (err_code); + } + NRF_LOG_DEBUG("Scanning"); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_ble_scan_params_set(nrf_ble_scan_t * const p_scan_ctx, + ble_gap_scan_params_t const * const p_scan_param) +{ + VERIFY_PARAM_NOT_NULL(p_scan_ctx); + + nrf_ble_scan_stop(); + + if (p_scan_param != NULL) + { + // Assign new scanning parameters. + p_scan_ctx->scan_params = *p_scan_param; + } + else + { + // If NULL, use the default static configuration. + nrf_ble_scan_default_param_set(p_scan_ctx); + } + + NRF_LOG_DEBUG("Scanning parameters have been changed successfully"); + + return NRF_SUCCESS; +} + + +/**@brief Function for calling the BLE_GAP_EVT_CONNECTED event. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] p_gap_evt GAP event structure. + */ +static void nrf_ble_scan_on_connected_evt(nrf_ble_scan_t const * const p_scan_ctx, + ble_gap_evt_t const * const p_gap_evt) +{ + scan_evt_t scan_evt; + + memset(&scan_evt, 0, sizeof(scan_evt)); + scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_CONNECTED; + scan_evt.params.connected.p_connected = &p_gap_evt->params.connected; + scan_evt.params.connected.conn_handle = p_gap_evt->conn_handle; + scan_evt.p_scan_params = &p_scan_ctx->scan_params; + + if (p_scan_ctx->evt_handler != NULL) + { + p_scan_ctx->evt_handler(&scan_evt); + } +} + + +ret_code_t nrf_ble_scan_copy_addr_to_sd_gap_addr(ble_gap_addr_t * p_gap_addr, + const uint8_t addr[BLE_GAP_ADDR_LEN]) +{ + uint16_t addr_type; + + addr_type = nrf_ble_scan_address_type_decode(addr); + + if (addr_type == BLE_ERROR_GAP_INVALID_BLE_ADDR) + { + return BLE_ERROR_GAP_INVALID_BLE_ADDR; + } + + p_gap_addr->addr_type = addr_type; + + for (uint8_t i = 0; i < BLE_GAP_ADDR_LEN; ++i) + { + p_gap_addr->addr[i] = addr[BLE_GAP_ADDR_LEN - (i + 1)]; + } + + return NRF_SUCCESS; +} + + +void nrf_ble_scan_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_contex) +{ + nrf_ble_scan_t * p_scan_data = (nrf_ble_scan_t *)p_contex; + ble_gap_evt_adv_report_t const * p_adv_report = &p_ble_evt->evt.gap_evt.params.adv_report; + ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_ADV_REPORT: + nrf_ble_scan_on_adv_report(p_scan_data, p_adv_report); + break; + + case BLE_GAP_EVT_TIMEOUT: + nrf_ble_scan_on_timeout(p_scan_data, p_gap_evt); + break; + + case BLE_GAP_EVT_SCAN_REQ_REPORT: + nrf_ble_scan_on_req_report(p_scan_data, p_gap_evt); + + break; + + case BLE_GAP_EVT_CONNECTED: + nrf_ble_scan_on_connected_evt(p_scan_data, p_gap_evt); + break; + + default: + break; + } +} + + +#endif // NRF_BLE_SCAN_ENABLED + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.h new file mode 100644 index 0000000..41ad1e7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/nrf_ble_scan/nrf_ble_scan.h @@ -0,0 +1,500 @@ +/** + * Copyright (c) 2018 - 2019, 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 nrf_ble_scan Scanning Module + * @{ + * @ingroup ble_sdk_lib + * @brief Module for handling the BLE scanning. + * + * @details The Scanning Module handles the BLE scanning for your application. + * The module offers several criteria for filtering the devices available for connection, + * and it can also work in the simple mode without using the filtering. + * If an event handler is provided, your main application can react to a filter match or to the need of setting the whitelist. + * The module can also be configured to automatically + * connect after it matches a filter or a device from the whitelist. + * + * @note The Scanning Module also supports applications with a multicentral link. + */ + +#ifndef NRF_BLE_SCAN_H__ +#define NRF_BLE_SCAN_H__ + +#include +#include +#include +#include "ble.h" +#include "ble_gap.h" +#include "app_util.h" +#include "sdk_errors.h" +#include "sdk_config.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/**@defgroup NRF_BLE_SCAN_FILTER_MODE Filter modes + * @{ */ +#define NRF_BLE_SCAN_NAME_FILTER (0x01) /**< Filters the device name. */ +#define NRF_BLE_SCAN_ADDR_FILTER (0x02) /**< Filters the device address. */ +#define NRF_BLE_SCAN_UUID_FILTER (0x04) /**< Filters the UUID. */ +#define NRF_BLE_SCAN_APPEARANCE_FILTER (0x08) /**< Filters the appearance. */ +#define NRF_BLE_SCAN_SHORT_NAME_FILTER (0x10) /**< Filters the device short name. */ +#define NRF_BLE_SCAN_ALL_FILTER (0x1F) /**< Uses the combination of all filters. */ +/* @} */ + +/**@brief Macro for defining a nrf_ble_scan instance. + * + * @param _name Name of the instance. + * @hideinitializer + */ +#define NRF_BLE_SCAN_DEF(_name) \ + static nrf_ble_scan_t _name; \ + NRF_SDH_BLE_OBSERVER(_name ## _ble_obs, \ + NRF_BLE_SCAN_OBSERVER_PRIO, \ + nrf_ble_scan_on_ble_evt, &_name); \ + + +/**@brief Enumeration for scanning events. + * + * @details These events are propagated to the main application if a handler is provided during + * the initialization of the Scanning Module. @ref NRF_BLE_SCAN_EVT_WHITELIST_REQUEST cannot be + * ignored if whitelist is used. + */ +typedef enum +{ + NRF_BLE_SCAN_EVT_FILTER_MATCH, /**< A filter is matched or all filters are matched in the multifilter mode. */ + NRF_BLE_SCAN_EVT_WHITELIST_REQUEST, /**< Request the whitelist from the main application. For whitelist scanning to work, the whitelist must be set when this event occurs. */ + NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT, /**< Send notification to the main application when a device from the whitelist is found. */ + NRF_BLE_SCAN_EVT_NOT_FOUND, /**< The filter was not matched for the scan data. */ + NRF_BLE_SCAN_EVT_SCAN_TIMEOUT, /**< Scan timeout. */ + NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT, /**< Scan request report. */ + NRF_BLE_SCAN_EVT_CONNECTING_ERROR, /**< Error occurred when establishing the connection. In this event, an error is passed from the function call @ref sd_ble_gap_connect. */ + NRF_BLE_SCAN_EVT_CONNECTED /**< Connected to device. */ +} nrf_ble_scan_evt_t; + + +/**@brief Types of filters. + */ +typedef enum +{ + SCAN_NAME_FILTER, /**< Filter for names. */ + SCAN_SHORT_NAME_FILTER, /**< Filter for short names. */ + SCAN_ADDR_FILTER, /**< Filter for addresses. */ + SCAN_UUID_FILTER, /**< Filter for UUIDs. */ + SCAN_APPEARANCE_FILTER, /**< Filter for appearances. */ +} nrf_ble_scan_filter_type_t; + + +typedef struct +{ + char const * p_short_name; /**< Pointer to the short name. */ + uint8_t short_name_min_len; /**< Minimum length of the short name. */ +} nrf_ble_scan_short_name_t; + +/**@brief Structure for Scanning Module initialization. + */ +typedef struct +{ + ble_gap_scan_params_t const * p_scan_param; /**< BLE GAP scan parameters required to initialize the module. Can be initialized as NULL. If NULL, the parameters required to initialize the module are loaded from the static configuration. */ + bool connect_if_match; /**< If set to true, the module automatically connects after a filter match or successful identification of a device from the whitelist. */ + ble_gap_conn_params_t const * p_conn_param; /**< Connection parameters. Can be initialized as NULL. If NULL, the default static configuration is used. */ + uint8_t conn_cfg_tag; /**< Variable to keep track of what connection settings will be used if a filer match or a whitelist match results in a connection. */ +} nrf_ble_scan_init_t; + + +/**@brief Structure for setting the filter status. + * + * @details This structure is used for sending filter status to the main application. + */ +typedef struct +{ + uint8_t name_filter_match : 1; /**< Set to 1 if name filter is matched. */ + uint8_t address_filter_match : 1; /**< Set to 1 if address filter is matched. */ + uint8_t uuid_filter_match : 1; /**< Set to 1 if uuid filter is matched. */ + uint8_t appearance_filter_match : 1; /**< Set to 1 if appearance filter is matched. */ + uint8_t short_name_filter_match : 1; /**< Set to 1 if short name filter is matched. */ +} nrf_ble_scan_filter_match; + + +/**@brief Event structure for @ref NRF_BLE_SCAN_EVT_FILTER_MATCH. + */ +typedef struct +{ + ble_gap_evt_adv_report_t const * p_adv_report; /**< Event structure for @ref BLE_GAP_EVT_ADV_REPORT. This data allows the main application to establish connection. */ + nrf_ble_scan_filter_match filter_match; /**< Matching filters. Information about matched filters. */ +} nrf_ble_scan_evt_filter_match_t; + + +/**@brief Event structure for @ref NRF_BLE_SCAN_EVT_CONNECTING_ERROR. + */ +typedef struct +{ + ret_code_t err_code; /**< Indicates success or failure of an API procedure. In case of failure, a comprehensive error code indicating the cause or reason for failure is provided. */ +} nrf_ble_scan_evt_connecting_err_t; + + +/**@brief Event structure for @ref NRF_BLE_SCAN_EVT_CONNECTED. + */ +typedef struct +{ + ble_gap_evt_connected_t const * p_connected; /**< Connected event parameters. */ + uint16_t conn_handle; /**< Connection handle of the device on which the event occurred. */ +} nrf_ble_scan_evt_connected_t; + + +/**@brief Structure for Scanning Module event data. + * + * @details This structure is used to send module event data to the main application when an event occurs. + */ +typedef struct +{ + nrf_ble_scan_evt_t scan_evt_id; /**< Type of event propagated to the main application. */ + union + { + nrf_ble_scan_evt_filter_match_t filter_match; /**< Scan filter match. */ + ble_gap_evt_scan_req_report_t req_report; /**< Scan request report parameters. */ + ble_gap_evt_timeout_t timeout; /**< Timeout event parameters. */ + ble_gap_evt_adv_report_t const * p_whitelist_adv_report; /**< Advertising report event parameters for whitelist. */ + ble_gap_evt_adv_report_t const * p_not_found; /**< Advertising report event parameters when filter is not found. */ + nrf_ble_scan_evt_connected_t connected; /**< Connected event parameters. */ + nrf_ble_scan_evt_connecting_err_t connecting_err; /**< Error event when connecting. Propagates the error code returned by the SoftDevice API @ref sd_ble_gap_scan_start. */ + } params; + ble_gap_scan_params_t const * p_scan_params; /**< GAP scanning parameters. These parameters are needed to establish connection. */ +} scan_evt_t; + + +/**@brief BLE scanning event handler type. + */ +typedef void (*nrf_ble_scan_evt_handler_t)(scan_evt_t const * p_scan_evt); + + +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) + +#if (NRF_BLE_SCAN_NAME_CNT > 0) +typedef struct +{ + char target_name[NRF_BLE_SCAN_NAME_CNT][NRF_BLE_SCAN_NAME_MAX_LEN]; /**< Names that the main application will scan for, and that will be advertised by the peripherals. */ + uint8_t name_cnt; /**< Name filter counter. */ + bool name_filter_enabled; /**< Flag to inform about enabling or disabling this filter. */ +} nrf_ble_scan_name_filter_t; +#endif + +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) +typedef struct +{ + struct + { + char short_target_name[NRF_BLE_SCAN_SHORT_NAME_MAX_LEN]; /**< Short names that the main application will scan for, and that will be advertised by the peripherals. */ + uint8_t short_name_min_len; /**< Minimum length of the short name. */ + } short_name[NRF_BLE_SCAN_SHORT_NAME_CNT]; + uint8_t name_cnt; /**< Short name filter counter. */ + bool short_name_filter_enabled; /**< Flag to inform about enabling or disabling this filter. */ +} nrf_ble_scan_short_name_filter_t; +#endif + +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) +typedef struct +{ + ble_gap_addr_t target_addr[NRF_BLE_SCAN_ADDRESS_CNT]; /**< Addresses in the same format as the format used by the SoftDevice that the main application will scan for, and that will be advertised by the peripherals. */ + uint8_t addr_cnt; /**< Address filter counter. */ + bool addr_filter_enabled; /**< Flag to inform about enabling or disabling this filter. */ +} nrf_ble_scan_addr_filter_t; +#endif + +#if (NRF_BLE_SCAN_UUID_CNT > 0) +typedef struct +{ + ble_uuid_t uuid[NRF_BLE_SCAN_UUID_CNT]; /**< UUIDs that the main application will scan for, and that will be advertised by the peripherals. */ + uint8_t uuid_cnt; /**< UUID filter counter. */ + bool uuid_filter_enabled; /**< Flag to inform about enabling or disabling this filter. */ +} nrf_ble_scan_uuid_filter_t; +#endif + +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) +typedef struct +{ + uint16_t appearance[NRF_BLE_SCAN_APPEARANCE_CNT]; /**< Apperances that the main application will scan for, and that will be advertised by the peripherals. */ + uint8_t appearance_cnt; /**< Appearance filter counter. */ + bool appearance_filter_enabled; /**< Flag to inform about enabling or disabling this filter. */ +} nrf_ble_scan_appearance_filter_t; +#endif + +/**@brief Filters data. + * + * @details This structure contains all filter data and the information about enabling and disabling any type of filters. + * Flag all_filter_mode informs about the filter mode. If this flag is set, then all types of enabled + * filters must be matched for the module to send a notification to the main application. Otherwise, it is enough to match + * one of filters to send notification. + */ +typedef struct +{ +#if (NRF_BLE_SCAN_NAME_CNT > 0) + nrf_ble_scan_name_filter_t name_filter; /**< Name filter data. */ +#endif +#if (NRF_BLE_SCAN_SHORT_NAME_CNT > 0) + nrf_ble_scan_short_name_filter_t short_name_filter; /**< Short name filter data. */ +#endif +#if (NRF_BLE_SCAN_ADDRESS_CNT > 0) + nrf_ble_scan_addr_filter_t addr_filter; /**< Address filter data. */ +#endif +#if (NRF_BLE_SCAN_UUID_CNT > 0) + nrf_ble_scan_uuid_filter_t uuid_filter; /**< UUID filter data. */ +#endif +#if (NRF_BLE_SCAN_APPEARANCE_CNT > 0) + nrf_ble_scan_appearance_filter_t appearance_filter; /**< Appearance filter data. */ +#endif + bool all_filters_mode; /**< Filter mode. If true, all set filters must be matched to generate an event.*/ +} nrf_ble_scan_filters_t; + +#endif // NRF_BLE_SCAN_FILTER_ENABLE + +/**@brief Scan module instance. Options for the different scanning modes. + * + * @details This structure stores all module settings. It is used to enable or disable scanning modes + * and to configure filters. + */ +typedef struct +{ +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) + nrf_ble_scan_filters_t scan_filters; /**< Filter data. */ +#endif + bool connect_if_match; /**< If set to true, the module automatically connects after a filter match or successful identification of a device from the whitelist. */ + ble_gap_conn_params_t conn_params; /**< Connection parameters. */ + uint8_t conn_cfg_tag; /**< Variable to keep track of what connection settings will be used if a filer match or a whitelist match results in a connection. */ + ble_gap_scan_params_t scan_params; /**< GAP scanning parameters. */ + nrf_ble_scan_evt_handler_t evt_handler; /**< Handler for the scanning events. Can be initialized as NULL if no handling is implemented in the main application. */ + uint8_t scan_buffer_data[NRF_BLE_SCAN_BUFFER]; /**< Buffer where advertising reports will be stored by the SoftDevice. */ + ble_data_t scan_buffer; /**< Structure-stored pointer to the buffer where advertising reports will be stored by the SoftDevice. */ +} nrf_ble_scan_t; + + +/**@brief Function for indicating that the Scanning Module is using the whitelist. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @return Whether the whitelist is used. + */ +bool is_whitelist_used(nrf_ble_scan_t const * const p_scan_ctx); + + +/**@brief Function for initializing the Scanning Module. + * + * @param[out] p_scan_ctx Pointer to the Scanning Module instance. This structure must be supplied by + * the application. It is initialized by this function and is later used + * to identify this particular module instance. + * + * @param[in] p_init Can be initialized as NULL. If NULL, the parameters required to initialize + * the module are loaded from static configuration. + * If module is to establish the connection automatically, this must be initialized + * with the relevant data. + * @param[in] evt_handler Handler for the scanning events. + * Can be initialized as NULL if no handling is implemented in the main application. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_NULL When the NULL pointer is passed as input. + */ +ret_code_t nrf_ble_scan_init(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_init_t const * const p_init, + nrf_ble_scan_evt_handler_t evt_handler); + + +/**@brief Function for starting scanning. + * + * @details This function starts the scanning according to the configuration set during the initialization. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If scanning started. Otherwise, an error code is returned. + * @retval NRF_ERROR_NULL If NULL pointer is passed as input. + * + * @return This API propagates the error code returned by the + * SoftDevice API @ref sd_ble_gap_scan_start. + */ +ret_code_t nrf_ble_scan_start(nrf_ble_scan_t const * const p_scan_ctx); + + +/**@brief Function for stopping scanning. + */ +void nrf_ble_scan_stop(void); + + +#if (NRF_BLE_SCAN_FILTER_ENABLE == 1) + +/**@brief Function for enabling filtering. + * + * @details The filters can be combined with each other. For example, you can enable one filter or several filters. + * For example, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER) enables UUID and name filters. + * + * @param[in] mode Filter mode: @ref NRF_BLE_SCAN_FILTER_MODE. + * @param[in] match_all If this flag is set, all types of enabled filters must be matched + * before generating @ref NRF_BLE_SCAN_EVT_FILTER_MATCH to the main application. Otherwise, it is enough to match + * one filter to trigger the filter match event. + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If the filters are enabled successfully. + * @retval NRF_ERROR_INVALID_PARAM If the filter mode is incorrect. Available filter modes: @ref NRF_BLE_SCAN_FILTER_MODE. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + */ +ret_code_t nrf_ble_scan_filters_enable(nrf_ble_scan_t * const p_scan_ctx, + uint8_t mode, + bool match_all); + + +/**@brief Function for disabling filtering. + * + * @details This function disables all filters. + * Even if the automatic connection establishing is enabled, + * the connection will not be established with the first + device found after this function is called. + * + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If filters are disabled successfully. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + */ +ret_code_t nrf_ble_scan_filters_disable(nrf_ble_scan_t * const p_scan_ctx); + + +/**@brief Function for getting filter status. + * + * @details This function returns the filter setting and whether it is enabled or disabled. + + * @param[out] p_status Filter status. + * @param[in] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If filter status is returned. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + */ +ret_code_t nrf_ble_scan_filter_get(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_filters_t * p_status); + + +/**@brief Function for adding any type of filter to the scanning. + * + * @details This function adds a new filter by type @ref nrf_ble_scan_filter_type_t. + * The filter will be added if the number of filters of a given type does not exceed @ref NRF_BLE_SCAN_UUID_CNT, + * @ref NRF_BLE_SCAN_NAME_CNT, @ref NRF_BLE_SCAN_ADDRESS_CNT, or @ref NRF_BLE_SCAN_APPEARANCE_CNT, depending on the filter type, + * and if the same filter has not already been set. + * + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] type Filter type. + * @param[in] p_data The filter data to add. + * + * @retval NRF_SUCCESS If the filter is added successfully. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + * @retval NRF_ERROR_DATA_SIZE If the name filter length is too long. Maximum name filter length corresponds to @ref NRF_BLE_SCAN_NAME_MAX_LEN. + * @retval NRF_ERROR_NO_MEMORY If the number of available filters is exceeded. + * @retval NRF_ERROR_INVALID_PARAM If the filter type is incorrect. Available filter types: @ref nrf_ble_scan_filter_type_t. + * @retval BLE_ERROR_GAP_INVALID_BLE_ADDR If the BLE address type is invalid. + */ +ret_code_t nrf_ble_scan_filter_set(nrf_ble_scan_t * const p_scan_ctx, + nrf_ble_scan_filter_type_t type, + void const * p_data); + + +/**@brief Function for removing all set filters. + * + * @details The function removes all previously set filters. + * + * @note After using this function the filters are still enabled. + * + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * + * @retval NRF_SUCCESS If all filters are removed successfully. + */ +ret_code_t nrf_ble_scan_all_filter_remove(nrf_ble_scan_t * const p_scan_ctx); + + +#endif // NRF_BLE_SCAN_FILTER_ENABLE + + +/**@brief Function for changing the scanning parameters. + * + **@details Use this function to change scanning parameters. During the parameter change + * the scan is stopped. To resume scanning, use @ref nrf_ble_scan_start. + * Scanning parameters can be set to NULL. If so, the default static configuration + * is used. For example, use this function when the @ref NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT event is generated. + * The generation of this event means that there is a risk that the whitelist is empty. In such case, this function can change + * the scanning parameters, so that the whitelist is not used, and you avoid the error caused by scanning with the whitelist + * when there are no devices on the whitelist. + * + * @param[in,out] p_scan_ctx Pointer to the Scanning Module instance. + * @param[in] p_scan_param GAP scanning parameters. Can be initialized as NULL. + * + * @retval NRF_SUCCESS If parameters are changed successfully. + * @retval NRF_ERROR_NULL If a NULL pointer is passed as input. + */ +ret_code_t nrf_ble_scan_params_set(nrf_ble_scan_t * const p_scan_ctx, + ble_gap_scan_params_t const * p_scan_param); + + +/**@brief Function for handling the BLE stack events of the application. + * + * @param[in] p_ble_evt Pointer to the BLE event received. + * @param[in,out] p_scan Pointer to the Scanning Module instance. + */ +void nrf_ble_scan_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_scan); + + +/**@brief Function for converting the raw address to the SoftDevice GAP address. + * + * @details This function inverts the byte order in the address. If you enter the address as it is displayed + * (for example, on a phone screen from left to right), you must use this function to + * convert the address to the SoftDevice address type. + * + * @param[in] addr Address to be converted to the SoftDevice address. + * @param[out] p_gap_addr The Bluetooth Low Energy address. + * + * @retval BLE_ERROR_GAP_INVALID_BLE_ADDR If the BLE address type is invalid. + * @retval NRF_SUCCESS If the address is copied and converted successfully. + */ +ret_code_t nrf_ble_scan_copy_addr_to_sd_gap_addr(ble_gap_addr_t * p_gap_addr, + uint8_t const addr[BLE_GAP_ADDR_LEN]); + +#ifdef __cplusplus +} +#endif + +#endif // NRF_BLE_SCAN_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.c new file mode 100644 index 0000000..f2807ec --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.c @@ -0,0 +1,340 @@ +/** + * Copyright (c) 2018 - 2019, 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(PEER_MANAGER) && NRF_MODULE_ENABLED(PM_RA_PROTECTION) +#include "auth_status_tracker.h" + +#include "app_timer.h" +#include "id_manager.h" + +#define NRF_LOG_MODULE_NAME peer_manager_ast +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" + +// Assume that waiting interval doubles with each failed authentication. +//lint --emacro((647),PENALITY_LVL_TO_PENALITY_MS) +#define PAIR_REWARD_TICKS APP_TIMER_TICKS(PM_RA_PROTECTION_REWARD_PERIOD) +#define PENALITY_LVL_TO_PENALITY_MS(_lvl) (PM_RA_PROTECTION_MIN_WAIT_INTERVAL * (1 << _lvl)) +#define PENALITY_LVL_TO_PENALITY_TICKS(_lvl) APP_TIMER_TICKS(PENALITY_LVL_TO_PENALITY_MS(_lvl)) +#define PENALITY_LVL_NEXT_SET(_lvl) \ + _lvl = (PENALITY_LVL_TO_PENALITY_MS(_lvl) >= (PM_RA_PROTECTION_MAX_WAIT_INTERVAL)) ? \ + (_lvl) : (_lvl + 1) + + +/**@brief Tracked peer state. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< BLE address, used to identify peer. */ + uint32_t reward_ticks; /**< Accumulated reward ticks, used to decrease penality level + after achieving certain threshold. */ + uint32_t penality_ticks; /**< Accumulated penality ticks, used to determine remaining time + in which pairing attempts should be rejected. */ + uint8_t penality_lvl; /**< Accumulated penality level, used to determine waiting interval + after failed authorization attempt. */ + bool is_active; /**< Flag indicating that the waiting interval for this peer has not + passed yet. */ + bool is_valid; /**< Flag indicating that this entry is valid in the peer blacklist. */ +} blacklisted_peer_t; + +APP_TIMER_DEF(m_pairing_attempt_timer); +static blacklisted_peer_t m_blacklisted_peers[PM_RA_PROTECTION_TRACKED_PEERS_NUM]; +static uint32_t m_ticks_cnt; + + +/**@brief Function for updating the state of blacklisted peers after timer has been stopped or + * timed out. + * + * @param[in] ticks_passed The number of ticks since the timer has started. + */ +static uint32_t blacklisted_peers_state_update(uint32_t ticks_passed) +{ + uint32_t minimal_ticks = UINT32_MAX; + + for (uint32_t id = 0; id < ARRAY_SIZE(m_blacklisted_peers); id++) + { + blacklisted_peer_t * p_bl_peer = &m_blacklisted_peers[id]; + + if (p_bl_peer->is_valid) + { + if (p_bl_peer->is_active) + { + if (p_bl_peer->penality_ticks > ticks_passed) + { + p_bl_peer->penality_ticks -= ticks_passed; + minimal_ticks = MIN(minimal_ticks, p_bl_peer->penality_ticks); + } + else + { + p_bl_peer->is_active = false; + + if (p_bl_peer->penality_lvl == 0) + { + p_bl_peer->is_valid = false; + NRF_LOG_DEBUG("Peer has been removed from the blacklist, its address:"); + NRF_LOG_HEXDUMP_DEBUG(p_bl_peer->peer_addr.addr, + sizeof(p_bl_peer->peer_addr.addr)); + } + else + { + minimal_ticks = MIN(minimal_ticks, PAIR_REWARD_TICKS); + } + + NRF_LOG_DEBUG("Pairing waiting interval has expired for:"); + NRF_LOG_HEXDUMP_DEBUG(p_bl_peer->peer_addr.addr, + sizeof(p_bl_peer->peer_addr.addr)); + } + } + else + { + if (p_bl_peer->penality_lvl == 0) + { + p_bl_peer->is_valid = false; + NRF_LOG_DEBUG("Peer has been removed from the blacklist, its address:"); + NRF_LOG_HEXDUMP_DEBUG(p_bl_peer->peer_addr.addr, + sizeof(p_bl_peer->peer_addr.addr)); + } + else + { + p_bl_peer->reward_ticks += ticks_passed; + if (p_bl_peer->reward_ticks >= PAIR_REWARD_TICKS) + { + p_bl_peer->penality_lvl--; + p_bl_peer->reward_ticks -= PAIR_REWARD_TICKS; + NRF_LOG_DEBUG("Peer penality level has decreased to %d for device:", + p_bl_peer->penality_lvl); + NRF_LOG_HEXDUMP_DEBUG(p_bl_peer->peer_addr.addr, + sizeof(p_bl_peer->peer_addr.addr)); + } + + minimal_ticks = MIN(minimal_ticks, + (PAIR_REWARD_TICKS - p_bl_peer->reward_ticks)); + } + } + } + } + + return minimal_ticks; +} + + +/**@brief Function for handling state transition of blacklisted peers. + * + * @param[in] context Context containing the number of ticks since the timer has started. + */ +static void blacklisted_peers_state_transition_handle(void * context) +{ + ret_code_t err_code; + uint32_t minimal_ticks; + uint32_t ticks_passed = (uint32_t) context; + + minimal_ticks = blacklisted_peers_state_update(ticks_passed); + m_ticks_cnt = app_timer_cnt_get(); + + if (minimal_ticks != UINT32_MAX) + { + err_code = app_timer_start(m_pairing_attempt_timer, + minimal_ticks, + (void *) minimal_ticks); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("app_timer_start() returned %s", nrf_strerror_get(err_code)); + } + NRF_LOG_DEBUG("Restarting the timer"); + } +} + + +ret_code_t ast_init(void) +{ + ret_code_t err_code = app_timer_create(&m_pairing_attempt_timer, + APP_TIMER_MODE_SINGLE_SHOT, + blacklisted_peers_state_transition_handle); + + return err_code; +} + + +void ast_auth_error_notify(uint16_t conn_handle) +{ + ret_code_t err_code; + ble_gap_addr_t peer_addr; + uint32_t new_timeout; + uint32_t free_id = ARRAY_SIZE(m_blacklisted_peers); + bool new_bl_entry = true; + + // Get the peer address associated with connection handle. + err_code = im_ble_addr_get(conn_handle, &peer_addr); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("im_ble_addr_get() returned %s. conn_handle: %d. " + "Link was likely disconnected.", + nrf_strerror_get(err_code), + conn_handle); + return; + } + + // Stop the timer and update the state of all blacklisted peers. + err_code = app_timer_stop(m_pairing_attempt_timer); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("app_timer_stop() returned %s", nrf_strerror_get(err_code)); + return; + } + + new_timeout = blacklisted_peers_state_update(app_timer_cnt_diff_compute(app_timer_cnt_get(), + m_ticks_cnt)); + m_ticks_cnt = app_timer_cnt_get(); + + // Check if authorization has failed for already blacklisted peer. + for (uint32_t id = 0; id < ARRAY_SIZE(m_blacklisted_peers); id++) + { + blacklisted_peer_t * p_bl_peer = &m_blacklisted_peers[id]; + + if (p_bl_peer->is_valid) + { + if (memcmp(peer_addr.addr, p_bl_peer->peer_addr.addr, BLE_GAP_ADDR_LEN) == 0) + { + uint8_t lvl = p_bl_peer->penality_lvl; + + PENALITY_LVL_NEXT_SET(lvl); + p_bl_peer->penality_lvl = lvl; + p_bl_peer->reward_ticks = 0; + p_bl_peer->penality_ticks = PENALITY_LVL_TO_PENALITY_TICKS(lvl); + + new_timeout = MIN(new_timeout, p_bl_peer->penality_ticks); + + p_bl_peer->is_active = true; + new_bl_entry = false; + + NRF_LOG_DEBUG("Pairing waiting interval has been renewed. " + "Penality level: %d for device:", + lvl); + NRF_LOG_HEXDUMP_DEBUG(p_bl_peer->peer_addr.addr, + sizeof(p_bl_peer->peer_addr.addr)); + } + } + else + { + free_id = id; + } + } + + // Add a new peer to the blacklist. + if (new_bl_entry) + { + if (free_id < ARRAY_SIZE(m_blacklisted_peers)) + { + blacklisted_peer_t * p_bl_peer = &m_blacklisted_peers[free_id]; + + memcpy(&p_bl_peer->peer_addr, &peer_addr, sizeof(peer_addr)); + + p_bl_peer->penality_lvl = 0; + p_bl_peer->reward_ticks = 0; + p_bl_peer->penality_ticks = PENALITY_LVL_TO_PENALITY_TICKS(p_bl_peer->penality_lvl); + + new_timeout = MIN(new_timeout, p_bl_peer->penality_ticks); + + p_bl_peer->is_active = true; + p_bl_peer->is_valid = true; + NRF_LOG_DEBUG("New peer has been added to the blacklist:"); + NRF_LOG_HEXDUMP_DEBUG(p_bl_peer->peer_addr.addr, sizeof(p_bl_peer->peer_addr.addr)); + } + else + { + NRF_LOG_WARNING("No space to blacklist another peer ID"); + } + } + + // Restart the timer. + if (new_timeout != UINT32_MAX) + { + err_code = app_timer_start(m_pairing_attempt_timer, + new_timeout, + (void *) new_timeout); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("app_timer_start() returned %s", nrf_strerror_get(err_code)); + } + } +} + + +bool ast_peer_blacklisted(uint16_t conn_handle) +{ + ret_code_t err_code; + ble_gap_addr_t peer_addr; + + err_code = im_ble_addr_get(conn_handle, &peer_addr); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("im_ble_addr_get() returned %s. conn_handle: %d. " + "Link was likely disconnected.", + nrf_strerror_get(err_code), + conn_handle); + return true; + } + + for (uint32_t id = 0; id < ARRAY_SIZE(m_blacklisted_peers); id++) + { + blacklisted_peer_t * p_bl_peer = &m_blacklisted_peers[id]; + + if (p_bl_peer->is_valid) + { + if ((memcmp(peer_addr.addr, p_bl_peer->peer_addr.addr, BLE_GAP_ADDR_LEN) == 0) && + (p_bl_peer->is_active)) + { + return true; + } + } + } + + return false; +} + + +#endif // NRF_MODULE_ENABLED(PEER_MANAGER) && NRF_MODULE_ENABLED(PM_RA_PROTECTION) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_ecb.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.h similarity index 60% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_ecb.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.h index b9bf4fb..a0ff6e0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_ecb.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/auth_status_tracker.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,67 +35,63 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/** - * @file - * @brief ECB driver API. - */ - -#ifndef NRF_ECB_H__ -#define NRF_ECB_H__ - -/** - * @defgroup nrf_ecb AES ECB encryption - * @{ - * @ingroup nrf_drivers - * @brief Driver for the AES Electronic Code Book (ECB) peripheral. * - * To encrypt data, the peripheral must first be powered on - * using @ref nrf_ecb_init. Next, the key must be set using @ref nrf_ecb_set_key. */ +#ifndef AUTH_STATUS_TRACKER_H__ +#define AUTH_STATUS_TRACKER_H__ #include +#include "sdk_errors.h" +#include "ble_gap.h" #ifdef __cplusplus extern "C" { #endif + /** - * @brief Function for initializing and powering on the ECB peripheral. + * @cond NO_DOXYGEN + * @defgroup auth_status_tracker Authorization Status Tracker + * @ingroup peer_manager + * @{ + * @brief An internal module of @ref peer_manager. A module for tracking peers with failed + * authorization attempts. It uses tracking policy, which is described in Bluetooth + * Core Specification v5.0, Vol 3, Part H, Section 2.3.6. + */ + + +/**@brief Function for initializing the Authorization Status Tracker module. * - * This function allocates memory for the ECBDATAPTR. - * @retval true If initialization was successful. - * @retval false If powering on failed. + * @retval NRF_SUCCESS Initialization was successful. + * @retval Other Other error codes might be returned by the @ref app_timer_create function. */ -bool nrf_ecb_init(void); +ret_code_t ast_init(void); -/** - * @brief Function for encrypting 16-byte data using current key. + +/**@brief Function for notifying about failed authorization attempts. * - * This function avoids unnecessary copying of data if the parameters point to the - * correct locations in the ECB data structure. + * @param[in] conn_handle Connection handle on which authorization attempt has failed. + */ +void ast_auth_error_notify(uint16_t conn_handle); + + +/**@brief Function for checking if pairing request must be rejected. * - * @param dst Result of encryption, 16 bytes will be written. - * @param src Source with 16-byte data to be encrypted. + * @param[in] conn_handle Connection handle on which this check must be performed. * - * @retval true If the encryption operation completed. - * @retval false If the encryption operation did not complete. + * @retval true If the connected peer is blacklisted. + * @retval false If the connected peer is not blacklisted. */ -bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src); +bool ast_peer_blacklisted(uint16_t conn_handle); -/** - * @brief Function for setting the key to be used for encryption. - * - * @param key Pointer to the key. 16 bytes will be read. + +/** @} + * @endcond */ -void nrf_ecb_set_key(const uint8_t * key); #ifdef __cplusplus } #endif -#endif // NRF_ECB_H__ - -/** @} */ +#endif /* AUTH_STATUS_TRACKER_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatt_cache_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatt_cache_manager.c similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatt_cache_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatt_cache_manager.c index 4d6d431..f2a13e6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatt_cache_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatt_cache_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -48,9 +48,22 @@ #include "peer_manager_internal.h" #include "id_manager.h" #include "gatts_cache_manager.h" +#include "peer_data_storage.h" #include "peer_database.h" -#include "pm_mutex.h" - +#include "nrf_mtx.h" + +#define NRF_LOG_MODULE_NAME peer_manager_gcm +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" // The number of registered event handlers. #define GCM_EVENT_HANDLERS_CNT (sizeof(m_evt_handlers) / sizeof(m_evt_handlers[0])) @@ -66,12 +79,21 @@ static pm_evt_handler_internal_t m_evt_handlers[] = }; static bool m_module_initialized; -static uint8_t m_db_update_in_progress_mutex; /**< Mutex indicating whether a local DB write operation is ongoing. */ +static nrf_mtx_t m_db_update_in_progress_mutex; /**< Mutex indicating whether a local DB write operation is ongoing. */ static ble_conn_state_user_flag_id_t m_flag_local_db_update_pending; /**< Flag ID for flag collection to keep track of which connections need a local DB update procedure. */ static ble_conn_state_user_flag_id_t m_flag_local_db_apply_pending; /**< Flag ID for flag collection to keep track of which connections need a local DB apply procedure. */ static ble_conn_state_user_flag_id_t m_flag_service_changed_pending; /**< Flag ID for flag collection to keep track of which connections need to be sent a service changed indication. */ static ble_conn_state_user_flag_id_t m_flag_service_changed_sent; /**< Flag ID for flag collection to keep track of which connections have been sent a service changed indication and are waiting for a handle value confirmation. */ +static ble_conn_state_user_flag_id_t m_flag_car_update_pending; /**< Flag ID for flag collection to keep track of which connections need to have their Central Address Resolution value stored. */ +static ble_conn_state_user_flag_id_t m_flag_car_handle_queried; /**< Flag ID for flag collection to keep track of which connections are pending Central Address Resolution handle reply. */ +static ble_conn_state_user_flag_id_t m_flag_car_value_queried; /**< Flag ID for flag collection to keep track of which connections are pending Central Address Resolution value reply. */ +#ifdef PM_SERVICE_CHANGED_ENABLED + STATIC_ASSERT(PM_SERVICE_CHANGED_ENABLED || !NRF_SDH_BLE_SERVICE_CHANGED, + "PM_SERVICE_CHANGED_ENABLED should be enabled if NRF_SDH_BLE_SERVICE_CHANGED is enabled."); +#else + #define PM_SERVICE_CHANGED_ENABLED 1 +#endif /**@brief Function for resetting the module variable(s) of the GSCM module. * @@ -125,7 +147,7 @@ static void send_unexpected_error(uint16_t conn_handle, ret_code_t err_code) { .error_unexpected = { - .error = err_code, + .error = err_code } } }; @@ -172,6 +194,9 @@ static void local_db_apply_in_evt(uint16_t conn_handle) case NRF_ERROR_INVALID_DATA: event.evt_id = PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED; + NRF_LOG_WARNING("The local database has changed, so some subscriptions to notifications "\ + "and indications could not be restored for conn_handle %d", + conn_handle); evt_send(&event); break; @@ -180,6 +205,10 @@ static void local_db_apply_in_evt(uint16_t conn_handle) break; default: + NRF_LOG_ERROR("gscm_local_db_cache_apply() returned %s which should not happen. "\ + "conn_handle: %d", + nrf_strerror_get(err_code), + conn_handle); send_unexpected_error(conn_handle, err_code); break; } @@ -237,11 +266,15 @@ static bool local_db_update_in_evt(uint16_t conn_handle) .conn_handle = conn_handle, }; + NRF_LOG_WARNING("Flash full. Could not store data for conn_handle: %d", conn_handle); evt_send(&event); break; } default: + NRF_LOG_ERROR("gscm_local_db_cache_update() returned %s for conn_handle: %d", + nrf_strerror_get(err_code), + conn_handle); send_unexpected_error(conn_handle, err_code); break; } @@ -251,6 +284,47 @@ static bool local_db_update_in_evt(uint16_t conn_handle) return success; } +#if PM_SERVICE_CHANGED_ENABLED + +/**@brief Function for getting the value of the CCCD for the service changed characteristic. + * + * @details This function will search all system handles consecutively. + * + * @param[in] conn_handle The connection to check. + * @param[out] p_cccd The CCCD value of the service changed characteristic for this link. + * + * @return Any error from @ref sd_ble_gatts_value_get or @ref sd_ble_gatts_attr_get. + */ +static ret_code_t service_changed_cccd(uint16_t conn_handle, uint16_t * p_cccd) +{ + bool sc_found = false; + uint16_t end_handle; + + ret_code_t err_code = sd_ble_gatts_initial_user_handle_get(&end_handle); + ASSERT(err_code == NRF_SUCCESS); + + for (uint16_t handle = 1; handle < end_handle; handle++) + { + ble_uuid_t uuid; + ble_gatts_value_t value = {.p_value = (uint8_t *)&uuid.uuid, .len = 2, .offset = 0}; + + err_code = sd_ble_gatts_attr_get(handle, &uuid, NULL); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + else if (!sc_found && (uuid.uuid == BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED)) + { + sc_found = true; + } + else if (sc_found && (uuid.uuid == BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG)) + { + value.p_value = (uint8_t *)p_cccd; + return sd_ble_gatts_value_get(conn_handle, handle, &value); + } + } + return NRF_ERROR_NOT_FOUND; +} /**@brief Function for sending a service changed indication in an event context, where no return * code can be given. @@ -287,9 +361,27 @@ static void service_changed_send_in_evt(uint16_t conn_handle) break; case NRF_ERROR_INVALID_STATE: - // CCCDs not enabled. Drop indication. - // Fallthrough. - + { + uint16_t cccd; + err_code = service_changed_cccd(conn_handle, &cccd); + if ((err_code == NRF_SUCCESS) && cccd) + { + // Possible ATT_MTU exchange ongoing. + // Do nothing, treat as busy. + break; + } + else + { + if (err_code != NRF_SUCCESS) + { + NRF_LOG_DEBUG("Unexpected error when looking for service changed CCCD: %s", + nrf_strerror_get(err_code)); + } + // CCCDs not enabled or an error happened. Drop indication. + // Fallthrough. + } + } + // Sometimes fallthrough. case NRF_ERROR_NOT_SUPPORTED: // Service changed not supported. Drop indication. sc_pending_state = false; @@ -305,6 +397,9 @@ static void service_changed_send_in_evt(uint16_t conn_handle) break; default: + NRF_LOG_ERROR("gscm_service_changed_ind_send() returned %s for conn_handle: %d", + nrf_strerror_get(err_code), + conn_handle); send_unexpected_error(conn_handle, err_code); break; } @@ -312,73 +407,114 @@ static void service_changed_send_in_evt(uint16_t conn_handle) ble_conn_state_user_flag_set(conn_handle, m_flag_service_changed_pending, sc_pending_state); ble_conn_state_user_flag_set(conn_handle, m_flag_service_changed_sent, sc_sent_state); } +#endif +static void apply_pending_handle(uint16_t conn_handle, void * p_context) +{ + UNUSED_PARAMETER(p_context); + local_db_apply_in_evt(conn_handle); +} -/**@brief Function for checking all flags for one id, and handling the ones that are set. - * - * @param[in] flag_id The flag id to check flags for. - */ -static void pending_flags_check(ble_conn_state_user_flag_id_t flag_id) + +static __INLINE void apply_pending_flags_check(void) { - // Quickly check if any flags are set. - if (sdk_mapped_flags_any_set(ble_conn_state_user_flag_collection(flag_id))) - { - sdk_mapped_flags_key_list_t conn_handle_list = ble_conn_state_conn_handles(); + UNUSED_RETURN_VALUE(ble_conn_state_for_each_set_user_flag(m_flag_local_db_apply_pending, + apply_pending_handle, + NULL)); +} + - // Check each flag. - for (uint32_t i = 0; i < conn_handle_list.len; i++) +static void db_update_pending_handle(uint16_t conn_handle, void * p_context) +{ + UNUSED_PARAMETER(p_context); + if (nrf_mtx_trylock(&m_db_update_in_progress_mutex)) + { + if (local_db_update_in_evt(conn_handle)) { - uint16_t conn_handle = conn_handle_list.flag_keys[i]; - if (ble_conn_state_user_flag_get(conn_handle, flag_id)) - { - // This flag is set. Handle depending on which flags we are checking. - if (flag_id == m_flag_local_db_apply_pending) - { - local_db_apply_in_evt(conn_handle); - } - else if (flag_id == m_flag_local_db_update_pending) - { - if (pm_mutex_lock(&m_db_update_in_progress_mutex, 0)) - { - if (local_db_update_in_evt(conn_handle)) - { - // Successfully started writing to flash. - return; - } - else - { - pm_mutex_unlock(&m_db_update_in_progress_mutex, 0); - } - } - } - else if (flag_id == m_flag_service_changed_pending) - { - if (!ble_conn_state_user_flag_get(conn_handle, m_flag_service_changed_sent)) - { - service_changed_send_in_evt(conn_handle); - } - } - } + // Successfully started writing to flash. + return; + } + else + { + nrf_mtx_unlock(&m_db_update_in_progress_mutex); } } } -static __INLINE void apply_pending_flags_check(void) +#if PM_SERVICE_CHANGED_ENABLED +static void sc_send_pending_handle(uint16_t conn_handle, void * p_context) { - pending_flags_check(m_flag_local_db_apply_pending); + UNUSED_PARAMETER(p_context); + if (!ble_conn_state_user_flag_get(conn_handle, m_flag_service_changed_sent)) + { + service_changed_send_in_evt(conn_handle); + } } -static __INLINE void update_pending_flags_check(void) +static __INLINE void service_changed_pending_flags_check(void) { - pending_flags_check(m_flag_local_db_update_pending); + UNUSED_RETURN_VALUE(ble_conn_state_for_each_set_user_flag(m_flag_service_changed_pending, + sc_send_pending_handle, + NULL)); } -static __INLINE void service_changed_pending_flags_check(void) +static void service_changed_needed(uint16_t conn_handle) +{ + if (gscm_service_changed_ind_needed(conn_handle)) + { + ble_conn_state_user_flag_set(conn_handle, m_flag_service_changed_pending, true); + } +} +#endif + + +static void car_update_pending_handle(uint16_t conn_handle, void * p_context) { - pending_flags_check(m_flag_service_changed_pending); + UNUSED_PARAMETER(p_context); + + ble_uuid_t car_uuid; + memset(&car_uuid, 0, sizeof(ble_uuid_t)); + car_uuid.uuid = BLE_UUID_GAP_CHARACTERISTIC_CAR; + car_uuid.type = BLE_UUID_TYPE_BLE; + + ble_gattc_handle_range_t const car_handle_range = {1, 0xFFFF}; + + ret_code_t err_code = sd_ble_gattc_char_value_by_uuid_read(conn_handle, &car_uuid, &car_handle_range); + if (err_code == NRF_SUCCESS) + { + ble_conn_state_user_flag_set(conn_handle, m_flag_car_handle_queried, true); + } +} + + +static void car_update_needed(uint16_t conn_handle) +{ + pm_peer_data_t peer_data; + if (pds_peer_data_read(im_peer_id_get_by_conn_handle(conn_handle), + PM_PEER_DATA_ID_CENTRAL_ADDR_RES, + &peer_data, + NULL) == NRF_ERROR_NOT_FOUND) + { + ble_conn_state_user_flag_set(conn_handle, m_flag_car_update_pending, true); + } +} + + +static __INLINE void update_pending_flags_check(void) +{ + uint32_t count = ble_conn_state_for_each_set_user_flag(m_flag_local_db_update_pending, + db_update_pending_handle, + NULL); + if (count == 0) + { + count = ble_conn_state_for_each_set_user_flag(m_flag_car_update_pending, + car_update_pending_handle, + NULL); + UNUSED_RETURN_VALUE(count); + } } @@ -393,10 +529,11 @@ void gcm_im_evt_handler(pm_evt_t * p_event) { case PM_EVT_BONDED_PEER_CONNECTED: local_db_apply_in_evt(p_event->conn_handle); - if (gscm_service_changed_ind_needed(p_event->conn_handle)) - { - ble_conn_state_user_flag_set(p_event->conn_handle, m_flag_service_changed_pending, true); - } +#if (PM_SERVICE_CHANGED_ENABLED == 1) + service_changed_needed(p_event->conn_handle); +#endif + car_update_needed(p_event->conn_handle); + update_pending_flags_check(); break; default: break; @@ -423,10 +560,12 @@ void gcm_pdb_evt_handler(pm_evt_t * p_event) if (conn_handle != BLE_CONN_HANDLE_INVALID) { local_db_update(conn_handle, true); + car_update_needed(conn_handle); } break; } +#if PM_SERVICE_CHANGED_ENABLED case PM_PEER_DATA_ID_SERVICE_CHANGED_PENDING: { ret_code_t err_code; @@ -450,9 +589,14 @@ void gcm_pdb_evt_handler(pm_evt_t * p_event) } break; } +#endif case PM_PEER_DATA_ID_GATT_LOCAL: - pm_mutex_unlock(&m_db_update_in_progress_mutex, 0); + if (m_db_update_in_progress_mutex == NRF_MTX_LOCKED) + { + nrf_mtx_unlock(&m_db_update_in_progress_mutex); + } + // Expecting a call to update_pending_flags_check() immediately. break; @@ -476,16 +620,25 @@ ret_code_t gcm_init() m_flag_local_db_apply_pending = ble_conn_state_user_flag_acquire(); m_flag_service_changed_pending = ble_conn_state_user_flag_acquire(); m_flag_service_changed_sent = ble_conn_state_user_flag_acquire(); + m_flag_car_update_pending = ble_conn_state_user_flag_acquire(); + m_flag_car_handle_queried = ble_conn_state_user_flag_acquire(); + m_flag_car_value_queried = ble_conn_state_user_flag_acquire(); if ((m_flag_local_db_update_pending == BLE_CONN_STATE_USER_FLAG_INVALID) || (m_flag_local_db_apply_pending == BLE_CONN_STATE_USER_FLAG_INVALID) || (m_flag_service_changed_pending == BLE_CONN_STATE_USER_FLAG_INVALID) - || (m_flag_service_changed_sent == BLE_CONN_STATE_USER_FLAG_INVALID)) + || (m_flag_service_changed_sent == BLE_CONN_STATE_USER_FLAG_INVALID) + || (m_flag_car_update_pending == BLE_CONN_STATE_USER_FLAG_INVALID) + || (m_flag_car_handle_queried == BLE_CONN_STATE_USER_FLAG_INVALID) + || (m_flag_car_value_queried == BLE_CONN_STATE_USER_FLAG_INVALID) + ) { + NRF_LOG_ERROR("Could not acquire conn_state user flags. Increase "\ + "BLE_CONN_STATE_USER_FLAG_COUNT in the ble_conn_state module."); return NRF_ERROR_INTERNAL; } - pm_mutex_init(&m_db_update_in_progress_mutex, 1); + nrf_mtx_init(&m_db_update_in_progress_mutex); m_module_initialized = true; @@ -493,6 +646,28 @@ ret_code_t gcm_init() } +void store_car_value(uint16_t conn_handle, bool car_value) +{ + // Use a uint32_t to enforce 4-byte alignment. + static const uint32_t car_value_true = true; + static const uint32_t car_value_false = false; + + pm_peer_data_const_t peer_data = + { + .data_id = PM_PEER_DATA_ID_CENTRAL_ADDR_RES, + .length_words = 1, + }; + + ble_conn_state_user_flag_set(conn_handle, m_flag_car_update_pending, false); + peer_data.p_central_addr_res = car_value ? &car_value_true : &car_value_false; + ret_code_t err_code = pds_peer_data_store(im_peer_id_get_by_conn_handle(conn_handle), &peer_data, NULL); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("CAR char value couldn't be stored (error: %s). Reattempt will happen on the next connection.", nrf_strerror_get(err_code)); + } +} + + /**@brief Callback function for BLE events from the SoftDevice. * * @param[in] p_ble_evt The BLE event from the SoftDevice. @@ -507,6 +682,7 @@ void gcm_ble_evt_handler(ble_evt_t const * p_ble_evt) local_db_apply_in_evt(conn_handle); break; +#if PM_SERVICE_CHANGED_ENABLED case BLE_GATTS_EVT_SC_CONFIRM: { pm_evt_t event = @@ -523,6 +699,7 @@ void gcm_ble_evt_handler(ble_evt_t const * p_ble_evt) evt_send(&event); break; } +#endif case BLE_GATTS_EVT_WRITE: if (cccd_written(&p_ble_evt->evt.gatts_evt.params.write)) @@ -531,10 +708,103 @@ void gcm_ble_evt_handler(ble_evt_t const * p_ble_evt) update_pending_flags_check(); } break; + + case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: + { + bool handle_found = false; + conn_handle = p_ble_evt->evt.gattc_evt.conn_handle; + const ble_gattc_evt_char_val_by_uuid_read_rsp_t * p_val = &p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp; + + if (!ble_conn_state_user_flag_get(conn_handle, m_flag_car_handle_queried)) + { + break; + } + + ble_conn_state_user_flag_set(conn_handle, m_flag_car_handle_queried, false); + + if (p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND) + { + // Store 0. + } + else if (p_ble_evt->evt.gattc_evt.gatt_status != BLE_GATT_STATUS_SUCCESS) + { + NRF_LOG_WARNING("Unexpected GATT status while getting CAR char value: 0x%x", + p_ble_evt->evt.gattc_evt.gatt_status); + // Store 0. + } + else + { + if (p_val->count != 1) + { + NRF_LOG_WARNING("Multiple (%d) CAR characteristics found, using the first.", + p_val->count); + } + + if (p_val->value_len != 1) + { + NRF_LOG_WARNING("Unexpected CAR characteristic value length (%d), store 0.", + p_val->value_len); + // Store 0. + } + else + { + ret_code_t err_code = sd_ble_gattc_read(conn_handle, *(uint16_t*)p_val->handle_value, 0); + if (err_code == NRF_SUCCESS) + { + handle_found = true; + ble_conn_state_user_flag_set(conn_handle, m_flag_car_value_queried, true); + } + } + } + + if (!handle_found) + { + store_car_value(conn_handle, false); + } + break; + } + + case BLE_GATTC_EVT_READ_RSP: + { + bool car_value = false; + conn_handle = p_ble_evt->evt.gattc_evt.conn_handle; + const ble_gattc_evt_read_rsp_t * p_val = &p_ble_evt->evt.gattc_evt.params.read_rsp; + + if (!ble_conn_state_user_flag_get(conn_handle, m_flag_car_value_queried)) + { + break; + } + + ble_conn_state_user_flag_set(conn_handle, m_flag_car_value_queried, false); + + if (p_ble_evt->evt.gattc_evt.gatt_status != BLE_GATT_STATUS_SUCCESS) + { + NRF_LOG_WARNING("Unexpected GATT status while getting CAR char value: 0x%x", + p_ble_evt->evt.gattc_evt.gatt_status); + // Store 0. + } + else + { + if (p_val->len != 1) + { + NRF_LOG_WARNING("Unexpected CAR characteristic value length (%d), store 0.", + p_val->len); + // Store 0. + } + else + { + car_value = *p_val->data; + } + } + + store_car_value(conn_handle, car_value); + } } apply_pending_flags_check(); +#if PM_SERVICE_CHANGED_ENABLED service_changed_pending_flags_check(); +#endif } @@ -549,20 +819,22 @@ ret_code_t gcm_local_db_cache_update(uint16_t conn_handle) } +#if PM_SERVICE_CHANGED_ENABLED void gcm_local_database_has_changed(void) { gscm_local_database_has_changed(); - sdk_mapped_flags_key_list_t conn_handles = ble_conn_state_conn_handles(); + ble_conn_state_conn_handle_list_t conn_handles = ble_conn_state_conn_handles(); for (uint16_t i = 0; i < conn_handles.len; i++) { - if (im_peer_id_get_by_conn_handle(conn_handles.flag_keys[i]) == PM_PEER_ID_INVALID) + if (im_peer_id_get_by_conn_handle(conn_handles.conn_handles[i]) == PM_PEER_ID_INVALID) { - ble_conn_state_user_flag_set(conn_handles.flag_keys[i], m_flag_service_changed_pending, true); + ble_conn_state_user_flag_set(conn_handles.conn_handles[i], m_flag_service_changed_pending, true); } } service_changed_pending_flags_check(); } +#endif #endif // NRF_MODULE_ENABLED(PEER_MANAGER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatt_cache_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatt_cache_manager.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatt_cache_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatt_cache_manager.h index 24d9f01..d24d718 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatt_cache_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatt_cache_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 GATT_CACHE_MANAGER_H__ #define GATT_CACHE_MANAGER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatts_cache_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatts_cache_manager.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatts_cache_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatts_cache_manager.c index b2d2aa6..51ccdf4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatts_cache_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatts_cache_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -47,8 +47,37 @@ #include "peer_manager_types.h" #include "peer_manager_internal.h" #include "peer_database.h" +#include "peer_data_storage.h" #include "id_manager.h" +#define NRF_LOG_MODULE_NAME peer_manager_gscm +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" + + +#if !defined(PM_SERVICE_CHANGED_ENABLED) || (PM_SERVICE_CHANGED_ENABLED == 1) +// The number of registered event handlers. +#define GSCM_EVENT_HANDLERS_CNT (sizeof(m_evt_handlers) / sizeof(m_evt_handlers[0])) + +// GATTS Cache Manager event handler in Peer Manager. +extern void pm_gscm_evt_handler(pm_evt_t * p_gcm_evt); + +// GATTS Cache Manager events' handlers. +// The number of elements in this array is GSCM_EVENT_HANDLERS_CNT. +static pm_evt_handler_internal_t m_evt_handlers[] = +{ + pm_gscm_evt_handler +}; +#endif // Syntactic sugar, two spoons. #define SYS_ATTR_SYS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS) @@ -65,6 +94,21 @@ static void internal_state_reset() { m_module_initialized = false; m_current_sc_store_peer_id = PM_PEER_ID_INVALID; + + // If PM_SERVICE_CHANGED_ENABLED is 0, this variable is unused. + UNUSED_VARIABLE(m_current_sc_store_peer_id); +} + + +#if !defined(PM_SERVICE_CHANGED_ENABLED) || (PM_SERVICE_CHANGED_ENABLED == 1) +static void evt_send(pm_evt_t * p_gscm_evt) +{ + p_gscm_evt->conn_handle = im_conn_handle_get(p_gscm_evt->peer_id); + + for (uint32_t i = 0; i < GSCM_EVENT_HANDLERS_CNT; i++) + { + m_evt_handlers[i](p_gscm_evt); + } } @@ -91,11 +135,35 @@ static void service_changed_pending_set(void) }; //lint -restore - err_code = pdb_raw_store(m_current_sc_store_peer_id, &peer_data, NULL); - while ((m_current_sc_store_peer_id != PM_PEER_ID_INVALID) && (err_code != NRF_ERROR_BUSY)) + while (m_current_sc_store_peer_id != PM_PEER_ID_INVALID) { - m_current_sc_store_peer_id = pdb_next_peer_id_get(m_current_sc_store_peer_id); - err_code = pdb_raw_store(m_current_sc_store_peer_id, &peer_data, NULL); + err_code = pds_peer_data_store(m_current_sc_store_peer_id, &peer_data, NULL); + if (err_code != NRF_SUCCESS) + { + pm_evt_t evt = {.peer_id = m_current_sc_store_peer_id}; + if (err_code == NRF_ERROR_BUSY) + { + // Do nothing. + } + else if (err_code == NRF_ERROR_STORAGE_FULL) + { + evt.evt_id = PM_EVT_STORAGE_FULL; + evt_send(&evt); + } + else + { + NRF_LOG_ERROR("pds_peer_data_store() returned %s while storing service changed"\ + "state for peer id %d.", + nrf_strerror_get(err_code), + m_current_sc_store_peer_id); + evt.evt_id = PM_EVT_ERROR_UNEXPECTED; + evt.params.error_unexpected.error = err_code; + evt_send(&evt); + } + break; + } + + m_current_sc_store_peer_id = pds_next_peer_id_get(m_current_sc_store_peer_id); } } //lint -restore @@ -105,7 +173,7 @@ static void service_changed_pending_set(void) /**@brief Event handler for events from the Peer Database module. * This function is extern in Peer Database. * - * @param[in] p_event The event that has happend with peer id and flags. + * @param[in] p_event The event that has happened with peer id and flags. */ void gscm_pdb_evt_handler(pm_evt_t * p_event) { @@ -114,6 +182,7 @@ void gscm_pdb_evt_handler(pm_evt_t * p_event) service_changed_pending_set(); } } +#endif ret_code_t gscm_init() @@ -177,6 +246,10 @@ ret_code_t gscm_local_db_cache_update(uint16_t conn_handle) ret_code_t err_code_release = pdb_write_buf_release(peer_id, PM_PEER_DATA_ID_GATT_LOCAL); if (err_code_release != NRF_SUCCESS) { + NRF_LOG_ERROR("Did another thread manipulate PM_PEER_DATA_ID_GATT_LOCAL for "\ + "peer_id %d at the same time? pdb_write_buf_release() returned %s.", + peer_id, + nrf_strerror_get(err_code_release)); err_code = NRF_ERROR_INTERNAL; } } @@ -249,6 +322,9 @@ ret_code_t gscm_local_db_cache_apply(uint16_t conn_handle) } else { + NRF_LOG_ERROR("sd_ble_gatts_sys_attr_set() returned NRF_ERROR_INVALID_DATA for NULL "\ + "pointer which should never happen. conn_handle: %d", + conn_handle); err_code = NRF_ERROR_INTERNAL; } } @@ -262,10 +338,11 @@ ret_code_t gscm_local_db_cache_apply(uint16_t conn_handle) return err_code; } +#if !defined(PM_SERVICE_CHANGED_ENABLED) || (PM_SERVICE_CHANGED_ENABLED == 1) void gscm_local_database_has_changed(void) { NRF_PM_DEBUG_CHECK(m_module_initialized); - m_current_sc_store_peer_id = pdb_next_peer_id_get(PM_PEER_ID_INVALID); + m_current_sc_store_peer_id = pds_next_peer_id_get(PM_PEER_ID_INVALID); service_changed_pending_set(); } @@ -300,6 +377,8 @@ ret_code_t gscm_service_changed_ind_send(uint16_t conn_handle) if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("sd_ble_gatts_initial_user_handle_get() returned %s which should not happen.", + nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } @@ -334,7 +413,8 @@ void gscm_db_change_notification_done(pm_peer_id_t peer_id) // Don't need to check return code, because all error conditions can be ignored. //lint -save -e550 - (void) pdb_raw_store(peer_id, &peer_data, NULL); + (void) pds_peer_data_store(peer_id, &peer_data, NULL); //lint -restore } +#endif #endif // NRF_MODULE_ENABLED(PEER_MANAGER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatts_cache_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatts_cache_manager.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatts_cache_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatts_cache_manager.h index 6e17ef8..18467a8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/gatts_cache_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/gatts_cache_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 GATTS_CACHE_MANAGER_H__ #define GATTS_CACHE_MANAGER_H__ @@ -101,7 +101,7 @@ ret_code_t gscm_local_db_cache_update(uint16_t conn_handle); * system part of the sys_attributes was attempted applied, * so service changed indications can be sent to subscribers. * @retval NRF_ERROR_BUSY Unable to perform operation at this time. Reattempt later. - * @return An unexpected return value from an internal function call. + * @retval NRF_ERROR_INTERNAL An unexpected error happened. */ ret_code_t gscm_local_db_cache_apply(uint16_t conn_handle); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/id_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/id_manager.c similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/id_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/id_manager.c index f496874..eca49ba 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/id_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/id_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -45,12 +45,23 @@ #include "ble.h" #include "ble_gap.h" #include "ble_err.h" -#include "ble_conn_state.h" #include "peer_manager_types.h" #include "peer_database.h" #include "peer_data_storage.h" #include "nrf_soc.h" +#include "ble_conn_state.h" +#define NRF_LOG_MODULE_NAME peer_manager_im +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); #define IM_MAX_CONN_HANDLES (20) #define IM_NO_INVALID_CONN_HANDLES (0xFF) @@ -73,35 +84,15 @@ static pm_evt_handler_internal_t const m_evt_handlers[] = gcm_im_evt_handler }; - typedef struct { pm_peer_id_t peer_id; - uint16_t conn_handle; ble_gap_addr_t peer_address; } im_connection_t; -static bool m_module_initialized; -static im_connection_t m_connections[IM_MAX_CONN_HANDLES]; -static ble_conn_state_user_flag_id_t m_conn_state_user_flag_id; - -static uint8_t m_wlisted_peer_cnt; -static pm_peer_id_t m_wlisted_peers[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; - -#if (NRF_SD_BLE_API_VERSION <= 2) - static ble_gap_addr_t m_current_id_addr; -#endif - - -static void internal_state_reset() -{ - m_conn_state_user_flag_id = BLE_CONN_STATE_USER_FLAG_INVALID; - - for (uint32_t i = 0; i < IM_MAX_CONN_HANDLES; i++) - { - m_connections[i].conn_handle = BLE_CONN_HANDLE_INVALID; - } -} +static im_connection_t m_connections[IM_MAX_CONN_HANDLES]; +static uint8_t m_wlisted_peer_cnt; +static pm_peer_id_t m_wlisted_peers[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; /**@brief Function for sending an event to all registered event handlers. @@ -116,87 +107,6 @@ static void evt_send(pm_evt_t * p_event) } } -/**@brief Function finding a free position in m_connections. - * - * @detail All connection handles in the m_connections array are checked against the connection - * state module. The index of the first one that is not a connection handle for a current - * connection is returned. This position in the array can safely be used for a new connection. - * - * @return Either the index of a free position in the array or IM_NO_INVALID_CONN_HANDLES if no free - position exists. - */ -uint8_t get_free_connection() -{ - for (uint32_t i = 0; i < IM_MAX_CONN_HANDLES; i++) - { - // Query the connection state module to check if the - // connection handle does not belong to a valid connection. - if (!ble_conn_state_user_flag_get(m_connections[i].conn_handle, m_conn_state_user_flag_id)) - { - return i; - } - } - // If all connection handles belong to a valid connection, return IM_NO_INVALID_CONN_HANDLES. - return IM_NO_INVALID_CONN_HANDLES; -} - - -/**@brief Function finding a particular connection handle m_connections. - * - * @param[in] conn_handle The handle to find. - * - * @return Either the index of the conn_handle in the array or IM_NO_INVALID_CONN_HANDLES if the - * handle was not found. - */ -uint8_t get_connection_by_conn_handle(uint16_t conn_handle) -{ - if (ble_conn_state_user_flag_get(conn_handle, m_conn_state_user_flag_id)) - { - for (uint32_t i = 0; i < IM_MAX_CONN_HANDLES; i++) - { - if (m_connections[i].conn_handle == conn_handle) - { - return i; - } - } - } - // If all connection handles belong to a valid connection, return IM_NO_INVALID_CONN_HANDLES. - return IM_NO_INVALID_CONN_HANDLES; -} - - -/**@brief Function for registering a new connection instance. - * - * @param[in] conn_handle The handle of the new connection. - * @param[in] p_ble_addr The address used to connect. - * - * @return Either the index of the new connection in the array or IM_NO_INVALID_CONN_HANDLES if no - * free position exists. - */ -uint8_t new_connection(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr) -{ - uint8_t conn_index = IM_NO_INVALID_CONN_HANDLES; - - if ((p_ble_addr != NULL) && (conn_handle != BLE_CONN_HANDLE_INVALID)) - { - ble_conn_state_user_flag_set(conn_handle, m_conn_state_user_flag_id, true); - - conn_index = get_connection_by_conn_handle(conn_handle); - if (conn_index == IM_NO_INVALID_CONN_HANDLES) - { - conn_index = get_free_connection(); - } - - if (conn_index != IM_NO_INVALID_CONN_HANDLES) - { - m_connections[conn_index].conn_handle = conn_handle; - m_connections[conn_index].peer_id = PM_PEER_ID_INVALID; - m_connections[conn_index].peer_address = *p_ble_addr; - } - } - return conn_index; -} - /**@brief Function checking the validity of an IRK * @@ -256,8 +166,6 @@ void im_ble_evt_handler(ble_evt_t const * ble_evt) ble_gap_evt_t gap_evt; pm_peer_id_t bonded_matching_peer_id; - NRF_PM_DEBUG_CHECK(m_module_initialized); - if (ble_evt->header.evt_id != BLE_GAP_EVT_CONNECTED) { // Nothing to do. @@ -318,14 +226,11 @@ void im_ble_evt_handler(ble_evt_t const * ble_evt) } } - uint8_t new_index = new_connection(gap_evt.conn_handle, - &gap_evt.params.connected.peer_addr); - UNUSED_VARIABLE(new_index); + m_connections[gap_evt.conn_handle].peer_id = bonded_matching_peer_id; + m_connections[gap_evt.conn_handle].peer_address = gap_evt.params.connected.peer_addr; if (bonded_matching_peer_id != PM_PEER_ID_INVALID) { - im_new_peer_id(gap_evt.conn_handle, bonded_matching_peer_id); - // Send a bonded peer event pm_evt_t im_evt; im_evt.conn_handle = gap_evt.conn_handle; @@ -393,72 +298,34 @@ pm_peer_id_t im_find_duplicate_bonding_data(pm_peer_data_bonding_t const * p_bon } -ret_code_t im_init(void) -{ - NRF_PM_DEBUG_CHECK(!m_module_initialized); - - internal_state_reset(); - - m_conn_state_user_flag_id = ble_conn_state_user_flag_acquire(); - if (m_conn_state_user_flag_id == BLE_CONN_STATE_USER_FLAG_INVALID) - { - return NRF_ERROR_INTERNAL; - } - - #if (NRF_SD_BLE_API_VERSION <= 2) - ret_code_t ret_code = sd_ble_gap_address_get(&m_current_id_addr); - if (ret_code != NRF_SUCCESS) - { - return NRF_ERROR_INTERNAL; - } - #endif - - m_module_initialized = true; - - return NRF_SUCCESS; -} - - pm_peer_id_t im_peer_id_get_by_conn_handle(uint16_t conn_handle) { - uint8_t conn_index; - - NRF_PM_DEBUG_CHECK(m_module_initialized); - - conn_index = get_connection_by_conn_handle(conn_handle); - - if (conn_index != IM_NO_INVALID_CONN_HANDLES) + if ((conn_handle >= IM_MAX_CONN_HANDLES) || !ble_conn_state_valid(conn_handle)) { - return m_connections[conn_index].peer_id; + return PM_PEER_ID_INVALID; } - return PM_PEER_ID_INVALID; + return m_connections[conn_handle].peer_id; } ret_code_t im_ble_addr_get(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr) { - uint8_t conn_index; - - NRF_PM_DEBUG_CHECK(m_module_initialized); NRF_PM_DEBUG_CHECK(p_ble_addr != NULL); - conn_index = get_connection_by_conn_handle(conn_handle); - - if (conn_index != IM_NO_INVALID_CONN_HANDLES) + if ((conn_handle >= IM_MAX_CONN_HANDLES) || !ble_conn_state_valid(conn_handle)) { - *p_ble_addr = m_connections[conn_index].peer_address; - return NRF_SUCCESS; + return BLE_ERROR_INVALID_CONN_HANDLE; } - return NRF_ERROR_NOT_FOUND; + *p_ble_addr = m_connections[conn_handle].peer_address; + return NRF_SUCCESS; } bool im_master_ids_compare(ble_gap_master_id_t const * p_master_id1, ble_gap_master_id_t const * p_master_id2) { - NRF_PM_DEBUG_CHECK(m_module_initialized); NRF_PM_DEBUG_CHECK(p_master_id1 != NULL); NRF_PM_DEBUG_CHECK(p_master_id2 != NULL); @@ -481,7 +348,6 @@ pm_peer_id_t im_peer_id_get_by_master_id(ble_gap_master_id_t const * p_master_id pm_peer_id_t peer_id; pm_peer_data_flash_t peer_data; - NRF_PM_DEBUG_CHECK(m_module_initialized); NRF_PM_DEBUG_CHECK(p_master_id != NULL); pds_peer_data_iterate_prepare(); @@ -504,13 +370,16 @@ pm_peer_id_t im_peer_id_get_by_master_id(ble_gap_master_id_t const * p_master_id uint16_t im_conn_handle_get(pm_peer_id_t peer_id) { - NRF_PM_DEBUG_CHECK(m_module_initialized); + if (peer_id == PM_PEER_ID_INVALID) + { + return BLE_CONN_HANDLE_INVALID; + } - for (uint32_t i = 0; i < IM_MAX_CONN_HANDLES; i++) + for (uint16_t conn_handle = 0; conn_handle < IM_MAX_CONN_HANDLES; conn_handle++) { - if (peer_id == m_connections[i].peer_id) + if ((m_connections[conn_handle].peer_id == peer_id) && ble_conn_state_valid(conn_handle)) { - return m_connections[i].conn_handle; + return conn_handle; } } return BLE_CONN_HANDLE_INVALID; @@ -519,8 +388,6 @@ uint16_t im_conn_handle_get(pm_peer_id_t peer_id) bool im_master_id_is_valid(ble_gap_master_id_t const * p_master_id) { - NRF_PM_DEBUG_CHECK(m_module_initialized); - if (p_master_id->ediv != 0) { return true; @@ -537,42 +404,26 @@ bool im_master_id_is_valid(ble_gap_master_id_t const * p_master_id) } -/**@brief Function to set the peer ID associated with a connection handle. - * - * @param[in] conn_handle The connection handle. - * @param[in] peer_id The peer ID to associate with @c conn_handle. - */ -static void peer_id_set(uint16_t conn_handle, pm_peer_id_t peer_id) +void im_new_peer_id(uint16_t conn_handle, pm_peer_id_t peer_id) { - uint8_t conn_index = get_connection_by_conn_handle(conn_handle); - if (conn_index != IM_NO_INVALID_CONN_HANDLES) + if (conn_handle < IM_MAX_CONN_HANDLES) { - m_connections[conn_index].peer_id = peer_id; + m_connections[conn_handle].peer_id = peer_id; } } -void im_new_peer_id(uint16_t conn_handle, pm_peer_id_t peer_id) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - - peer_id_set(conn_handle, peer_id); -} - - ret_code_t im_peer_free(pm_peer_id_t peer_id) { uint16_t conn_handle; ret_code_t ret; - NRF_PM_DEBUG_CHECK(m_module_initialized); - conn_handle = im_conn_handle_get(peer_id); ret = pdb_peer_free(peer_id); - if ((conn_handle != BLE_CONN_HANDLE_INVALID) && (ret == NRF_SUCCESS)) + if (ret == NRF_SUCCESS && (conn_handle < IM_MAX_CONN_HANDLES)) { - peer_id_set(conn_handle, PM_PEER_ID_INVALID); + m_connections[conn_handle].peer_id = PM_PEER_ID_INVALID; } return ret; } @@ -668,130 +519,71 @@ static ret_code_t peers_id_keys_get(pm_peer_id_t const * p_peers, ret_code_t im_device_identities_list_set(pm_peer_id_t const * p_peers, uint32_t peer_cnt) { - #if (NRF_SD_BLE_API_VERSION >= 3) - - ret_code_t ret; - pm_peer_data_t peer_data; - pm_peer_data_bonding_t bond_data; - - ble_gap_id_key_t keys[BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT]; - ble_gap_id_key_t const * key_ptrs[BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT]; - - if ((p_peers == NULL) || (peer_cnt == 0)) - { - // Clear the device identities list. - return sd_ble_gap_device_identities_set(NULL, NULL, 0); - } - - peer_data.p_bonding_data = &bond_data; - uint32_t const buf_size = sizeof(bond_data); - - memset(keys, 0x00, sizeof(keys)); - for (uint32_t i = 0; i < BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT; i++) - { - key_ptrs[i] = &keys[i]; - } - - for (uint32_t i = 0; i < peer_cnt; i++) - { - memset(&bond_data, 0x00, sizeof(bond_data)); - - // Read peer data from flash. - ret = pds_peer_data_read(p_peers[i], PM_PEER_DATA_ID_BONDING, - &peer_data, &buf_size); - - if ((ret == NRF_ERROR_NOT_FOUND) || (ret == NRF_ERROR_INVALID_PARAM)) - { - // Peer data coulnd't be found in flash or peer ID is not valid. - return NRF_ERROR_NOT_FOUND; - } - - uint8_t const addr_type = bond_data.peer_ble_id.id_addr_info.addr_type; - - if ((addr_type != BLE_GAP_ADDR_TYPE_PUBLIC) && - (addr_type != BLE_GAP_ADDR_TYPE_RANDOM_STATIC)) - { - // The address shared by the peer during bonding can't be whitelisted. - return BLE_ERROR_GAP_INVALID_BLE_ADDR; - } - - // Copy data to the buffer. - memcpy(&keys[i], &bond_data.peer_ble_id, sizeof(ble_gap_id_key_t)); - } - - return sd_ble_gap_device_identities_set(key_ptrs, NULL, peer_cnt); - - #else - - return NRF_ERROR_NOT_SUPPORTED; - - #endif -} - - -#if (NRF_SD_BLE_API_VERSION <= 2) - -static ret_code_t address_set_v2(uint8_t cycle_mode, ble_gap_addr_t * p_addr) -{ - NRF_PM_DEBUG_CHECK(p_addr != NULL); + ret_code_t ret; + pm_peer_data_t peer_data; + pm_peer_data_bonding_t bond_data; - ret_code_t ret = sd_ble_gap_address_set(cycle_mode, p_addr); + ble_gap_id_key_t keys[BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT]; + ble_gap_id_key_t const * key_ptrs[BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT]; - switch (ret) + if (peer_cnt > BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT) { - case NRF_SUCCESS: - case NRF_ERROR_BUSY: - case NRF_ERROR_INVALID_STATE: - case NRF_ERROR_INVALID_PARAM: // If cycle_mode is not AUTO or NONE. - case BLE_ERROR_GAP_INVALID_BLE_ADDR: // If the GAP address is not valid. - return ret; - - default: - return NRF_ERROR_INTERNAL; + return NRF_ERROR_INVALID_PARAM; } -} - -#endif + if ((p_peers == NULL) || (peer_cnt == 0)) + { + // Clear the device identities list. + return sd_ble_gap_device_identities_set(NULL, NULL, 0); + } -ret_code_t im_id_addr_set(ble_gap_addr_t const * p_addr) -{ - #if (NRF_SD_BLE_API_VERSION <= 2) + peer_data.p_bonding_data = &bond_data; + uint32_t const buf_size = sizeof(bond_data); - ret_code_t ret; - ble_gap_addr_t current_addr; + memset(keys, 0x00, sizeof(keys)); + for (uint32_t i = 0; i < BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT; i++) + { + key_ptrs[i] = &keys[i]; + } - NRF_PM_DEBUG_CHECK(p_addr != NULL); + for (uint32_t i = 0; i < peer_cnt; i++) + { + memset(&bond_data, 0x00, sizeof(bond_data)); - (void) sd_ble_gap_address_get(¤t_addr); + // Read peer data from flash. + ret = pds_peer_data_read(p_peers[i], PM_PEER_DATA_ID_BONDING, + &peer_data, &buf_size); - ret = address_set_v2(BLE_GAP_ADDR_CYCLE_MODE_NONE, (ble_gap_addr_t *)p_addr); - if (ret != NRF_SUCCESS) + if ((ret == NRF_ERROR_NOT_FOUND) || (ret == NRF_ERROR_INVALID_PARAM)) { - return ret; + NRF_LOG_WARNING("peer id %d: Peer data could not be found in flash. Remove the peer ID " + "from the peer list and try again.", + p_peers[i]); + return NRF_ERROR_NOT_FOUND; } - if ( current_addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE - || current_addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) + uint8_t const addr_type = bond_data.peer_ble_id.id_addr_info.addr_type; + + if ((addr_type != BLE_GAP_ADDR_TYPE_PUBLIC) && + (addr_type != BLE_GAP_ADDR_TYPE_RANDOM_STATIC)) { - // If currently using privacy, it must be re-enabled. - // We force AUTO when privacy is enabled. - ret = address_set_v2(BLE_GAP_ADDR_CYCLE_MODE_AUTO, ¤t_addr); - if (ret != NRF_SUCCESS) - { - return ret; - } + NRF_LOG_WARNING("peer id %d: The address shared by the peer during bonding cannot be " + "whitelisted. Remove the peer ID from the peer list and try again.", + p_peers[i]); + return BLE_ERROR_GAP_INVALID_BLE_ADDR; } - memcpy(&m_current_id_addr, p_addr, sizeof(ble_gap_addr_t)); - - return NRF_SUCCESS; + // Copy data to the buffer. + memcpy(&keys[i], &bond_data.peer_ble_id, sizeof(ble_gap_id_key_t)); + } - #else + return sd_ble_gap_device_identities_set(key_ptrs, NULL, peer_cnt); +} - return sd_ble_gap_addr_set(p_addr); - #endif +ret_code_t im_id_addr_set(ble_gap_addr_t const * p_addr) +{ + return sd_ble_gap_addr_set(p_addr); } @@ -799,102 +591,19 @@ ret_code_t im_id_addr_get(ble_gap_addr_t * p_addr) { NRF_PM_DEBUG_CHECK(p_addr != NULL); - #if (NRF_SD_BLE_API_VERSION <= 2) - memcpy(p_addr, &m_current_id_addr, sizeof(ble_gap_addr_t)); - return NRF_SUCCESS; - #else - return sd_ble_gap_addr_get(p_addr); - #endif + return sd_ble_gap_addr_get(p_addr); } ret_code_t im_privacy_set(pm_privacy_params_t const * p_privacy_params) { - #if (NRF_SD_BLE_API_VERSION <= 2) - - ret_code_t ret; - ble_gap_addr_t privacy_addr; - ble_gap_irk_t current_irk; - ble_opt_t privacy_options; - ble_opt_t current_privacy_options; - - NRF_PM_DEBUG_CHECK(p_privacy_params != NULL); - - privacy_addr.addr_type = p_privacy_params->private_addr_type; - privacy_options.gap_opt.privacy.p_irk = p_privacy_params->p_device_irk; - privacy_options.gap_opt.privacy.interval_s = p_privacy_params->private_addr_cycle_s; - current_privacy_options.gap_opt.privacy.p_irk = ¤t_irk; - - // Can not fail. - (void) sd_ble_opt_get(BLE_GAP_OPT_PRIVACY, ¤t_privacy_options); - (void) sd_ble_opt_set(BLE_GAP_OPT_PRIVACY, &privacy_options); - - if (p_privacy_params->privacy_mode == BLE_GAP_PRIVACY_MODE_OFF) - { - ret = address_set_v2(BLE_GAP_ADDR_CYCLE_MODE_NONE, &m_current_id_addr); - } - else - { - ret = address_set_v2(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &privacy_addr); - } - - if (ret != NRF_SUCCESS) - { - // Restore previous settings. - (void) sd_ble_opt_set(BLE_GAP_OPT_PRIVACY, ¤t_privacy_options); - } - - // NRF_ERROR_BUSY, - // NRF_ERROR_INVALID_STATE, - // NRF_ERROR_INVALID_PARAM, if address type is not valid. - return ret; - - #else - - return sd_ble_gap_privacy_set(p_privacy_params); - - #endif + return sd_ble_gap_privacy_set(p_privacy_params); } ret_code_t im_privacy_get(pm_privacy_params_t * p_privacy_params) { - #if (NRF_SD_BLE_API_VERSION <= 2) - - ble_gap_addr_t cur_addr; - ble_opt_t cur_privacy_opt; - - NRF_PM_DEBUG_CHECK(p_privacy_params != NULL); - NRF_PM_DEBUG_CHECK(p_privacy_params->p_device_irk != NULL); - - cur_privacy_opt.gap_opt.privacy.p_irk = p_privacy_params->p_device_irk; - - // Can not fail. - (void) sd_ble_gap_address_get(&cur_addr); - - if ( cur_addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE - || cur_addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) - { - p_privacy_params->privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY; - p_privacy_params->private_addr_type = cur_addr.addr_type; - } - else - { - p_privacy_params->privacy_mode = BLE_GAP_PRIVACY_MODE_OFF; - } - - // Can not fail. - (void) sd_ble_opt_get(BLE_GAP_OPT_PRIVACY, &cur_privacy_opt); - - p_privacy_params->private_addr_cycle_s = cur_privacy_opt.gap_opt.privacy.interval_s; - - return NRF_SUCCESS; - - #else - - return sd_ble_gap_privacy_get(p_privacy_params); - - #endif + return sd_ble_gap_privacy_get(p_privacy_params); } @@ -941,56 +650,42 @@ ret_code_t im_whitelist_set(pm_peer_id_t const * p_peers, { // Clear the current whitelist. m_wlisted_peer_cnt = 0; - #if (NRF_SD_BLE_API_VERSION >= 3) - // NRF_SUCCESS, or - // BLE_GAP_ERROR_WHITELIST_IN_USE - return sd_ble_gap_whitelist_set(NULL, 0); - #else - // The cached list of whitelisted peers is already cleared; nothing to do. - return NRF_SUCCESS; - #endif - } - // @todo emdi: should not ever cache more than BLE_GAP_WHITELIST_ADDR_MAX_COUNT... + // NRF_SUCCESS, or + // BLE_GAP_ERROR_WHITELIST_IN_USE + return sd_ble_gap_whitelist_set(NULL, 0); + } // Copy the new whitelisted peers. m_wlisted_peer_cnt = peer_cnt; memcpy(m_wlisted_peers, p_peers, sizeof(pm_peer_id_t) * peer_cnt); - #if (NRF_SD_BLE_API_VERSION >= 3) - - ret_code_t ret; - uint32_t wlist_addr_cnt = 0; - - ble_gap_addr_t const * addr_ptrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; - ble_gap_addr_t addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; - - memset(addrs, 0x00, sizeof(addrs)); + ret_code_t ret; + uint32_t wlist_addr_cnt = 0; - // Fetch GAP addresses for these peers, but don't fetch IRKs. - ret = peers_id_keys_get(p_peers, peer_cnt, addrs, &wlist_addr_cnt, NULL, NULL); + ble_gap_addr_t const * addr_ptrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; + ble_gap_addr_t addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; - if (ret != NRF_SUCCESS) - { - // NRF_ERROR_NOT_FOUND, if a peer or its data were not found. - // BLE_ERROR_GAP_INVALID_BLE_ADDR, if a peer address can not be used for whitelisting. - return ret; - } - - for (uint32_t i = 0; i < BLE_GAP_WHITELIST_ADDR_MAX_COUNT; i++) - { - addr_ptrs[i] = &addrs[i]; - } + memset(addrs, 0x00, sizeof(addrs)); - // NRF_ERROR_DATA_SIZE, if peer_cnt > BLE_GAP_WHITELIST_ADDR_MAX_COUNT. - // BLE_ERROR_GAP_WHITELIST_IN_USE, if a whitelist is in use. - return sd_ble_gap_whitelist_set(addr_ptrs, peer_cnt); + // Fetch GAP addresses for these peers, but don't fetch IRKs. + ret = peers_id_keys_get(p_peers, peer_cnt, addrs, &wlist_addr_cnt, NULL, NULL); - #else + if (ret != NRF_SUCCESS) + { + // NRF_ERROR_NOT_FOUND, if a peer or its data were not found. + // BLE_ERROR_GAP_INVALID_BLE_ADDR, if a peer address can not be used for whitelisting. + return ret; + } - return NRF_SUCCESS; + for (uint32_t i = 0; i < BLE_GAP_WHITELIST_ADDR_MAX_COUNT; i++) + { + addr_ptrs[i] = &addrs[i]; + } - #endif + // NRF_ERROR_DATA_SIZE, if peer_cnt > BLE_GAP_WHITELIST_ADDR_MAX_COUNT. + // BLE_ERROR_GAP_WHITELIST_IN_USE, if a whitelist is in use. + return sd_ble_gap_whitelist_set(addr_ptrs, peer_cnt); } @@ -1045,8 +740,6 @@ void ah(uint8_t const * p_k, uint8_t const * p_r, uint8_t * p_local_hash) bool im_address_resolve(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk) { - NRF_PM_DEBUG_CHECK(m_module_initialized); - uint8_t hash[IM_ADDR_CIPHERTEXT_LENGTH]; uint8_t local_hash[IM_ADDR_CIPHERTEXT_LENGTH]; uint8_t prand[IM_ADDR_CLEARTEXT_LENGTH]; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/id_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/id_manager.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/id_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/id_manager.h index 12758c7..8eb97a5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/id_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/id_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 PEER_ID_MANAGER_H__ #define PEER_ID_MANAGER_H__ @@ -62,14 +62,6 @@ extern "C" { */ -/**@brief Function for initializing the Identity manager. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INTERNAL If an error occurred. - */ -ret_code_t im_init(void); - - /**@brief Function for dispatching SoftDevice events to the ID Manager module. * * @param[in] p_ble_evt The SoftDevice event. @@ -100,7 +92,7 @@ pm_peer_id_t im_peer_id_get_by_master_id(ble_gap_master_id_t const * p_master_id * @param[in] peer_id The peer ID. * * @return The corresponding connection handle, or @ref BLE_CONN_HANDLE_INVALID if none could be - * resolved. + * resolved. The conn_handle can refer to a recently disconnected connection. */ uint16_t im_conn_handle_get(pm_peer_id_t peer_id); @@ -121,11 +113,10 @@ bool im_master_ids_compare(ble_gap_master_id_t const * p_master_id1, * * @param[in] conn_handle The connection handle. * @param[out] p_ble_addr The BLE address used by the peer when the connection specified by - * conn_handle was established. + * conn_handle was established. Cannot be NULL. * * @retval NRF_SUCCESS The address was found and copied. - * @retval BLE_ERROR_CONN_HANDLE_INVALID conn_handle does not refer to an active connection. - * @retval NRF_ERROR_NULL p_ble_addr was NULL. + * @retval BLE_ERROR_INVALID_CONN_HANDLE conn_handle does not refer to an active connection. */ ret_code_t im_ble_addr_get(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr); @@ -295,7 +286,7 @@ ret_code_t im_whitelist_set(pm_peer_id_t const * p_peers, * @param[inout] In: the size of the @p p_irks buffer. * Out: the number of IRKs copied into the buffer. * - * @retval NRF_SUCCESS If the whitelist was successfully retreived. + * @retval NRF_SUCCESS If the whitelist was successfully retrieved. * @retval BLE_ERROR_GAP_INVALID_BLE_ADDR If any peer has an address which can not be used for * whitelisting. * @retval NRF_ERROR_NOT_FOUND If the data for any of the cached whitelisted peers diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.c new file mode 100644 index 0000000..a03af5e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.c @@ -0,0 +1,445 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_BLE_LESC) + +#include "nrf_ble_lesc.h" +#include "nrf_crypto.h" + +#define NRF_LOG_MODULE_NAME nrf_ble_lesc +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/**@brief Descriptor of the peer public key. */ +typedef struct +{ + nrf_crypto_ecc_public_key_t value; /**< Peer public key. */ + bool is_requested; /**< Flag indicating that the public key has been requested to compute DH key. */ + bool is_valid; /**< Flag indicating that the public key is valid. */ +} nrf_ble_lesc_peer_pub_key_t; + +/**@brief The maximum number of peripheral and central connections combined. + * This value is based on what is configured in the SoftDevice handler sdk_config. + */ +#define NRF_BLE_LESC_LINK_COUNT (NRF_SDH_BLE_PERIPHERAL_LINK_COUNT + NRF_SDH_BLE_CENTRAL_LINK_COUNT) + +__ALIGN(4) static ble_gap_lesc_p256_pk_t m_lesc_public_key; /**< LESC ECC Public Key. */ +__ALIGN(4) static ble_gap_lesc_dhkey_t m_lesc_dh_key; /**< LESC ECC DH Key. */ + +static nrf_crypto_ecdh_context_t m_ecdh_context; /**< Context to do the LESC ECDH calculation */ + +static bool m_ble_lesc_internal_error; /**< Flag indicating that the module encountered an internal error. */ +static bool m_keypair_generated; /**< Flag indicating that the local ECDH key pair was generated. */ +static nrf_crypto_ecc_key_pair_generate_context_t m_keygen_context; /**< Context to generate private/public key pair. */ +static nrf_crypto_ecc_private_key_t m_private_key; /**< Allocated private key type to use for LESC DH generation. */ +static nrf_crypto_ecc_public_key_t m_public_key; /**< Allocated public key type to use for LESC DH generation. */ +static nrf_ble_lesc_peer_pub_key_t m_peer_keys[NRF_BLE_LESC_LINK_COUNT]; /**< Array of pointers to peer public keys, used for LESC DH generation. */ + +static bool m_lesc_oobd_own_generated; +static ble_gap_lesc_oob_data_t m_ble_lesc_oobd_own; /**< LESC OOB data used in LESC OOB pairing mode. */ +static nrf_ble_lesc_peer_oob_data_handler m_lesc_oobd_peer_handler; + +ret_code_t nrf_ble_lesc_init(void) +{ + ret_code_t err_code; + + memset((void *) m_peer_keys, 0, sizeof(m_peer_keys)); + +#if NRF_CRYPTO_ALLOCATOR == NRF_CRYPTO_ALLOCATOR_NRF_MALLOC + // Initialize mem_manager if used by nrf_crypto. + err_code = nrf_mem_init(); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_mem_init() returned error 0x%x.", err_code); + return err_code; + } +#endif + + // Ensure that nrf_crypto has been initialized. + err_code = nrf_crypto_init(); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_init() returned error 0x%x.", err_code); + return err_code; + } + NRF_LOG_DEBUG("Initialized nrf_crypto."); + +#if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) + // Do nothing. RNG is initialized with nrf_crypto_init call. +#elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0) + // Initialize the RNG. + err_code = nrf_crypto_rng_init(NULL, NULL); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_rng_init() returned error 0x%x.", err_code); + return err_code; + } +#else + #error Invalid sdk_config.h (does not contain NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) +#endif // defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) + NRF_LOG_DEBUG("Initialized nrf_ble_lesc."); + + // Reset module state. + m_ble_lesc_internal_error = false; + m_keypair_generated = false; + + // Generate ECC key pair. Only one key pair is automatically generated by this module. + err_code = nrf_ble_lesc_keypair_generate(); + return err_code; +} + + +ret_code_t nrf_ble_lesc_keypair_generate(void) +{ + ret_code_t err_code; + size_t public_len = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE; + + // Check if any DH computation is pending + for (uint32_t i = 0; i < ARRAY_SIZE(m_peer_keys); i++) + { + if (m_peer_keys[i].is_valid) + { + return NRF_ERROR_BUSY; + } + } + + // Update flag to indicate that there is no valid private key. + m_keypair_generated = false; + m_lesc_oobd_own_generated = false; + + NRF_LOG_DEBUG("Generating ECC key pair"); + err_code = nrf_crypto_ecc_key_pair_generate(&m_keygen_context, + &g_nrf_crypto_ecc_secp256r1_curve_info, + &m_private_key, + &m_public_key); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_ecc_key_pair_generate() returned error 0x%x.", err_code); + return err_code; + } + + // Convert to a raw type. + err_code = nrf_crypto_ecc_public_key_to_raw(&m_public_key, + m_lesc_public_key.pk, + &public_len); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_ecc_public_key_to_raw() returned error 0x%x.", err_code); + return err_code; + } + + // Invert the raw type to little-endian (required for BLE). + err_code = nrf_crypto_ecc_byte_order_invert(&g_nrf_crypto_ecc_secp256r1_curve_info, + m_lesc_public_key.pk, + m_lesc_public_key.pk, + NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_ecc_byte_order_invert() returned error 0x%x.", err_code); + } + else + { + // Set the flag to indicate that there is a valid ECDH key pair generated. + m_keypair_generated = true; + } + + return err_code; +} + + +ret_code_t nrf_ble_lesc_own_oob_data_generate(void) +{ + ret_code_t err_code = NRF_ERROR_INVALID_STATE; + + m_lesc_oobd_own_generated = false; + + if (m_keypair_generated) + { + err_code = sd_ble_gap_lesc_oob_data_get(BLE_CONN_HANDLE_INVALID, + &m_lesc_public_key, + &m_ble_lesc_oobd_own); + if (err_code == NRF_SUCCESS) + { + m_lesc_oobd_own_generated = true; + } + } + + return err_code; +} + + +ble_gap_lesc_p256_pk_t * nrf_ble_lesc_public_key_get(void) +{ + ble_gap_lesc_p256_pk_t * p_lesc_pk = NULL; + + if (m_keypair_generated) + { + p_lesc_pk = &m_lesc_public_key; + } + else + { + NRF_LOG_ERROR("Trying to access LESC public key that has not been generated yet."); + } + + return p_lesc_pk; +} + + +ble_gap_lesc_oob_data_t * nrf_ble_lesc_own_oob_data_get(void) +{ + ble_gap_lesc_oob_data_t * p_lesc_oobd_own = NULL; + + if (m_lesc_oobd_own_generated) + { + p_lesc_oobd_own = &m_ble_lesc_oobd_own; + } + else + { + NRF_LOG_ERROR("Trying to access LESC OOB data that have not been generated yet."); + } + + return p_lesc_oobd_own; +} + + +void nrf_ble_lesc_peer_oob_data_handler_set(nrf_ble_lesc_peer_oob_data_handler handler) +{ + m_lesc_oobd_peer_handler = handler; +} + + +/**@brief Function for calculating a DH key and responding to the DH key request on a given + * connection handle. + * + * @param[in] p_peer_public_key ECC peer public key, used to compute shared secret. + * @param[in] conn_handle Connection handle. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval Other Other error codes might be returned by the @ref nrf_crypto_ecdh_compute, @ref + * nrf_crypto_ecc_byte_order_invert, and @ref sd_ble_gap_lesc_dhkey_reply functions. + */ +static ret_code_t compute_and_give_dhkey(nrf_ble_lesc_peer_pub_key_t * p_peer_public_key, + uint16_t conn_handle) +{ + ret_code_t err_code = NRF_ERROR_INTERNAL; + size_t shared_secret_size = BLE_GAP_LESC_DHKEY_LEN; + uint8_t * p_shared_secret = m_lesc_dh_key.key; + + // Check if there is a valid generated and set a local ECDH public key. + if (!m_keypair_generated) + { + return NRF_ERROR_INTERNAL; + } + + // Check if the public_key is valid + if (p_peer_public_key->is_valid) + { + err_code = nrf_crypto_ecdh_compute(&m_ecdh_context, + &m_private_key, + &p_peer_public_key->value, + p_shared_secret, + &shared_secret_size); + } + + if (err_code == NRF_SUCCESS) + { + // Invert the shared secret for little endian format. + err_code = nrf_crypto_ecc_byte_order_invert(&g_nrf_crypto_ecc_secp256r1_curve_info, + p_shared_secret, + p_shared_secret, + BLE_GAP_LESC_DHKEY_LEN); + VERIFY_SUCCESS(err_code); + } + else + { + NRF_LOG_WARNING("Creating invalid shared secret to make LESC fail."); + err_code = nrf_crypto_rng_vector_generate(p_shared_secret, BLE_GAP_LESC_DHKEY_LEN); + VERIFY_SUCCESS(err_code); + } + + NRF_LOG_INFO("Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: %d", conn_handle); + err_code = sd_ble_gap_lesc_dhkey_reply(conn_handle, &m_lesc_dh_key); + + return err_code; +} + + +ret_code_t nrf_ble_lesc_request_handler(void) +{ + ret_code_t err_code = NRF_SUCCESS; + + // If the LESC module is in an invalid state, a restart is required. + if (m_ble_lesc_internal_error) + { + return NRF_ERROR_INTERNAL; + } + + for (uint16_t i = 0; i < NRF_BLE_LESC_LINK_COUNT; i++) + { + if (m_peer_keys[i].is_requested) + { + err_code = compute_and_give_dhkey(&m_peer_keys[i], i); + m_peer_keys[i].is_requested = false; + m_peer_keys[i].is_valid = false; + VERIFY_SUCCESS(err_code); + + } + } + + return err_code; +} + + +/**@brief Function for handling a DH key request event. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dhkey_request DH key request descriptor. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval Other Other error codes might be returned by the @ref nrf_crypto_ecc_byte_order_invert + * and @ref nrf_crypto_ecc_public_key_from_raw functions. + */ +static ret_code_t on_dhkey_request(uint16_t conn_handle, + ble_gap_evt_lesc_dhkey_request_t const * p_dhkey_request) +{ + ret_code_t err_code = NRF_SUCCESS; + uint8_t public_raw[BLE_GAP_LESC_P256_PK_LEN]; + uint8_t * p_public_raw; + size_t public_raw_len; + + // Convert the received public key from big-endian to little endian. + p_public_raw = p_dhkey_request->p_pk_peer->pk; + public_raw_len = BLE_GAP_LESC_P256_PK_LEN; + err_code = nrf_crypto_ecc_byte_order_invert(&g_nrf_crypto_ecc_secp256r1_curve_info, + p_public_raw, + public_raw, + public_raw_len); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_ecc_byte_order_invert() returned error 0x%x.", err_code); + return err_code; + } + + // Copy peer public key to the allocated context. The dhkey calculation will be performed in + // @ref nrf_ble_lesc_request_handler, so it does not block normal operation. + err_code = nrf_crypto_ecc_public_key_from_raw(&g_nrf_crypto_ecc_secp256r1_curve_info, + &m_peer_keys[conn_handle].value, + public_raw, + public_raw_len); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_ecc_public_key_from_raw() returned error 0x%x.", err_code); + m_peer_keys[conn_handle].is_valid = false; + } + else + { + m_peer_keys[conn_handle].is_valid = true; + } + m_peer_keys[conn_handle].is_requested = true; + + return NRF_SUCCESS; +} + + +/**@brief Function for setting LESC OOB data. + * + * @param[in] conn_handle Connection handle. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval Other Other error codes might be returned by the @ref sd_ble_gap_lesc_oob_data_set. + */ +static ret_code_t lesc_oob_data_set(uint16_t conn_handle) +{ + ret_code_t err_code; + ble_gap_lesc_oob_data_t * p_lesc_oobd_own; + ble_gap_lesc_oob_data_t * p_lesc_oobd_peer; + + p_lesc_oobd_own = (m_lesc_oobd_own_generated) ? &m_ble_lesc_oobd_own : NULL; + p_lesc_oobd_peer = (m_lesc_oobd_peer_handler != NULL) ? + m_lesc_oobd_peer_handler(conn_handle) : NULL; + + err_code = sd_ble_gap_lesc_oob_data_set(conn_handle, + p_lesc_oobd_own, + p_lesc_oobd_peer); + return err_code; +} + + +void nrf_ble_lesc_on_ble_evt(ble_evt_t const * p_ble_evt) +{ + ret_code_t err_code = NRF_SUCCESS; + uint16_t conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_DISCONNECTED: + m_peer_keys[conn_handle].is_valid = false; + m_peer_keys[conn_handle].is_requested = false; + break; + + case BLE_GAP_EVT_LESC_DHKEY_REQUEST: + NRF_LOG_DEBUG("BLE_GAP_EVT_LESC_DHKEY_REQUEST"); + + if (p_ble_evt->evt.gap_evt.params.lesc_dhkey_request.oobd_req) + { + err_code = lesc_oob_data_set(conn_handle); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_gap_lesc_oob_data_set() returned error 0x%x.", err_code); + m_ble_lesc_internal_error = true; + } + } + + err_code = on_dhkey_request(conn_handle, + &p_ble_evt->evt.gap_evt.params.lesc_dhkey_request); + if (err_code != NRF_SUCCESS) + { + m_ble_lesc_internal_error = true; + } + break; + + default: + break; + } +} + + +#endif // NRF_BLE_LESC_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.h new file mode 100644 index 0000000..93cc4cc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/nrf_ble_lesc.h @@ -0,0 +1,164 @@ +/** + * Copyright (c) 2018 - 2019, 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 nrf_ble_lesc LESC module + * @{ + * @ingroup peer_manager + * @brief Module for handling LESC related events. + */ + +#ifndef NRF_BLE_LESC_H__ +#define NRF_BLE_LESC_H__ + +#include +#include +#include "ble.h" +#include "sdk_errors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Peer OOB Data handler prototype. */ +typedef ble_gap_lesc_oob_data_t * (* nrf_ble_lesc_peer_oob_data_handler)(uint16_t conn_handle); + +/**@brief Function for initializing the LESC module. + * + * @details This function initializes the nrf_crypto for ECC and ECDH calculations, which are + * required to handle LESC authentication procedures. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval Other Other error codes might be returned by the @ref nrf_crypto_init or + * @ref nrf_ble_lesc_keypair_generate functions. + */ +ret_code_t nrf_ble_lesc_init(void); + + +/**@brief Function for generating ECC keypair used for the LESC procedure. + * + * @details This function generates an ECC key pair, which consists of a private and public key. Keys are + * generated using ECC and are used to create LESC DH key during authentication procedures. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_BUSY If any pending request needs to be processed by @ref nrf_ble_lesc_request_handler. + * @retval Other Other error codes might be returned by the @ref nrf_crypto_ecc_key_pair_generate, + * @ref nrf_crypto_ecc_public_key_to_raw and @ref nrf_crypto_ecc_byte_order_invert + * functions. + */ +ret_code_t nrf_ble_lesc_keypair_generate(void); + + +/**@brief Function for generating LESC OOB data. + * + * @details This function generates LESC OOB data, which can be transmitted Out-Of-Band to the peer + * device and used during LESC procedure. It is required to generate ECC keypair with @ref + * nrf_ble_lesc_keypair_generate before calling this function. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_INVALID_STATE If the ECC keypair hasn't been generated or is currently + * being generated. + */ +ret_code_t nrf_ble_lesc_own_oob_data_generate(void); + + +/**@brief Function for accessing the ECC public key used for LESC DH key generation. + * + * @details This function can be used to access the ECC public key, which is required to generate a LESC DH key + * at the peer side. + * + * @return Pointer to the generated public key or NULL if the key has not been generated yet. + */ +ble_gap_lesc_p256_pk_t * nrf_ble_lesc_public_key_get(void); + + +/**@brief Function for accessing LESC OOB data. + * + * @details This function can be used to access LESC OOB data that is associated with this device. + * It is required to regenerate LESC OOB data with @ref nrf_ble_lesc_own_oob_data_generate, + * after each change of ECC keypair with @ref nrf_ble_lesc_keypair_generate. + * + * @return Pointer to the LESC OOB data or NULL if the data has not been generated yet or is no + * no longer valid. + */ +ble_gap_lesc_oob_data_t * nrf_ble_lesc_own_oob_data_get(void); + + +/**@brief Function for setting the handler used to retrieve peer OOB data. + * + * @param[in] handler Function to retrieve peer OOB data. + */ +void nrf_ble_lesc_peer_oob_data_handler_set(nrf_ble_lesc_peer_oob_data_handler handler); + + +/**@brief Function for responding to a DH key requests. + * + * @details This function calculates DH keys and supplies them to the SoftDevice if there are any + * pending requests for keys. + * + * @note This function should be called systematically (e.g. in the main application loop) to handle + * any pending DH key requests. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_INTERNAL If the LESC module encountered an internal error. The only way to recover from + * this type of error is to reset the application. + * @retval Other Other error codes might be returned by the @ref nrf_crypto_ecdh_compute, + * @ref nrf_crypto_ecc_byte_order_invert, and @ref sd_ble_gap_lesc_dhkey_reply + * functions. + */ +ret_code_t nrf_ble_lesc_request_handler(void); + + +/**@brief Function for handling BLE stack events. + * + * @details This function handles events from the BLE stack that are of interest to the module. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +void nrf_ble_lesc_on_ble_evt(ble_evt_t const * p_ble_evt); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_BLE_LESC_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_data_storage.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_data_storage.c similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_data_storage.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_data_storage.c index aa25bf2..7f802d9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_data_storage.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_data_storage.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -49,6 +49,17 @@ #include "peer_id.h" #include "fds.h" +#define NRF_LOG_MODULE_NAME peer_manager_pds +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); // Macro for verifying that the peer id is within a valid range. #define VERIFY_PEER_ID_IN_RANGE(id) VERIFY_FALSE((id >= PM_PEER_ID_N_AVAILABLE_IDS), \ @@ -72,9 +83,8 @@ static pm_evt_handler_internal_t const m_evt_handlers[] = pdb_pds_evt_handler, }; -static bool m_module_initialized = false; -static bool m_peer_delete_queued = false; -static bool m_peer_delete_ongoing = false; +static bool m_module_initialized = false; +static volatile bool m_peer_delete_deferred = false; // A token used for Flash Data Storage searches. static fds_find_token_t m_fds_ftok; @@ -143,14 +153,15 @@ static bool peer_data_id_is_valid(pm_peer_data_id_t data_id) (data_id == PM_PEER_DATA_ID_GATT_LOCAL) || (data_id == PM_PEER_DATA_ID_GATT_REMOTE) || (data_id == PM_PEER_DATA_ID_PEER_RANK) || + (data_id == PM_PEER_DATA_ID_CENTRAL_ADDR_RES) || (data_id == PM_PEER_DATA_ID_APPLICATION)); } /**@brief Function for sending a PM_EVT_ERROR_UNEXPECTED event. * - * @param[in] peer_id The peer the event pertains to. - * @param[in] err_code The unexpected error that occurred. + * @param[in] peer_id The peer the event pertains to. + * @param[in] err_code The unexpected error that occurred. */ static void send_unexpected_error(pm_peer_id_t peer_id, ret_code_t err_code) { @@ -172,7 +183,7 @@ static void send_unexpected_error(pm_peer_id_t peer_id, ret_code_t err_code) // Function for deleting all data beloning to a peer. // These operations will be sent to FDS one at a time. -static void peer_data_delete() +static void peer_data_delete_process() { ret_code_t ret; pm_peer_id_t peer_id; @@ -180,6 +191,8 @@ static void peer_data_delete() fds_record_desc_t desc; fds_find_token_t ftok; + m_peer_delete_deferred = false; + memset(&ftok, 0x00, sizeof(fds_find_token_t)); peer_id = peer_id_get_next_deleted(PM_PEER_ID_INVALID); @@ -191,21 +204,20 @@ static void peer_data_delete() peer_id = peer_id_get_next_deleted(peer_id); } - if (!m_peer_delete_ongoing && (peer_id != PM_PEER_ID_INVALID)) + if (peer_id != PM_PEER_ID_INVALID) { - m_peer_delete_ongoing = true; - file_id = peer_id_to_file_id(peer_id); ret = fds_file_delete(file_id); if (ret == FDS_ERR_NO_SPACE_IN_QUEUES) { - m_peer_delete_queued = true; + m_peer_delete_deferred = true; } else if (ret != NRF_SUCCESS) { - m_peer_delete_ongoing = false; - + NRF_LOG_ERROR("Could not delete peer data. fds_file_delete() returned 0x%x for peer_id: %d", + ret, + peer_id); send_unexpected_error(peer_id, ret); } } @@ -230,7 +242,7 @@ static ret_code_t peer_data_find(pm_peer_id_t peer_id, ret = fds_record_find(file_id, record_key, p_desc, &ftok); - if (ret != FDS_SUCCESS) + if (ret != NRF_SUCCESS) { return NRF_ERROR_NOT_FOUND; } @@ -249,7 +261,7 @@ static void peer_ids_load() uint16_t const record_key = peer_data_id_to_record_key(PM_PEER_DATA_ID_BONDING); - while (fds_record_find_by_key(record_key, &record_desc, &ftok) == FDS_SUCCESS) + while (fds_record_find_by_key(record_key, &record_desc, &ftok) == NRF_SUCCESS) { pm_peer_id_t peer_id; @@ -286,7 +298,7 @@ static void fds_evt_handler(fds_evt_t const * const p_fds_evt) : PM_PEER_DATA_OP_UPDATE; pds_evt.params.peer_data_update_succeeded.token = p_fds_evt->write.record_id; - if (p_fds_evt->result == FDS_SUCCESS) + if (p_fds_evt->result == NRF_SUCCESS) { pds_evt.evt_id = PM_EVT_PEER_DATA_UPDATE_SUCCEEDED; pds_evt.params.peer_data_update_succeeded.flash_changed = true; @@ -305,7 +317,7 @@ static void fds_evt_handler(fds_evt_t const * const p_fds_evt) if ( file_id_within_pm_range(p_fds_evt->del.file_id) && (p_fds_evt->del.record_key == FDS_RECORD_KEY_DIRTY)) { - if (p_fds_evt->result == FDS_SUCCESS) + if (p_fds_evt->result == NRF_SUCCESS) { pds_evt.evt_id = PM_EVT_PEER_DELETE_SUCCEEDED; peer_id_free(pds_evt.peer_id); @@ -313,21 +325,26 @@ static void fds_evt_handler(fds_evt_t const * const p_fds_evt) else { pds_evt.evt_id = PM_EVT_PEER_DELETE_FAILED; + pds_evt.params.peer_delete_failed.error = p_fds_evt->result; } - m_peer_delete_queued = false; - m_peer_delete_ongoing = false; - - peer_data_delete(); + m_peer_delete_deferred = true; // Trigger remaining deletes. pds_evt_send(&pds_evt); } break; case FDS_EVT_GC: - pds_evt.evt_id = PM_EVT_FLASH_GARBAGE_COLLECTED; + if (p_fds_evt->result == NRF_SUCCESS) + { + pds_evt.evt_id = PM_EVT_FLASH_GARBAGE_COLLECTED; + } + else + { + pds_evt.evt_id = PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED; + pds_evt.params.garbage_collection_failed.error = p_fds_evt->result; + } pds_evt.peer_id = PM_PEER_ID_INVALID; - pds_evt_send(&pds_evt); break; @@ -336,10 +353,9 @@ static void fds_evt_handler(fds_evt_t const * const p_fds_evt) break; } - if (m_peer_delete_queued) + if (m_peer_delete_deferred) { - m_peer_delete_queued = false; - peer_data_delete(); + peer_data_delete_process(); } } @@ -354,12 +370,14 @@ ret_code_t pds_init() ret = fds_register(fds_evt_handler); if (ret != NRF_SUCCESS) { + NRF_LOG_ERROR("Could not initialize flash storage. fds_register() returned 0x%x.", ret); return NRF_ERROR_INTERNAL; } ret = fds_init(); if (ret != NRF_SUCCESS) { + NRF_LOG_ERROR("Could not initialize flash storage. fds_init() returned 0x%x.", ret); return NRF_ERROR_STORAGE_FULL; } @@ -417,14 +435,13 @@ ret_code_t pds_peer_data_read(pm_peer_id_t peer_id, else { uint32_t const data_len_bytes = (p_data->length_words * sizeof(uint32_t)); + uint32_t const copy_len_bytes = MIN((*p_buf_len), (p_data->length_words * sizeof(uint32_t))); - if ((*p_buf_len) >= data_len_bytes) - { - memcpy(p_data->p_all_data, rec_flash.p_data, data_len_bytes); - } - else + memcpy(p_data->p_all_data, rec_flash.p_data, copy_len_bytes); + + if (copy_len_bytes < data_len_bytes) { - return NRF_ERROR_NO_MEM; + return NRF_ERROR_DATA_SIZE; } } @@ -485,57 +502,8 @@ bool pds_peer_data_iterate(pm_peer_data_id_t data_id, } -ret_code_t pds_space_reserve(pm_peer_data_const_t const * p_peer_data, - pm_prepare_token_t * p_prepare_token) -{ - ret_code_t ret; - - NRF_PM_DEBUG_CHECK(m_module_initialized); - NRF_PM_DEBUG_CHECK(p_peer_data != NULL); - NRF_PM_DEBUG_CHECK(p_prepare_token != NULL); - - VERIFY_PEER_DATA_ID_IN_RANGE(p_peer_data->data_id); - - ret = fds_reserve((fds_reserve_token_t*)p_prepare_token, p_peer_data->length_words); - - switch (ret) - { - case FDS_SUCCESS: - return NRF_SUCCESS; - - case FDS_ERR_RECORD_TOO_LARGE: - return NRF_ERROR_INVALID_LENGTH; - - case FDS_ERR_NO_SPACE_IN_FLASH: - return NRF_ERROR_STORAGE_FULL; - - default: - return NRF_ERROR_INTERNAL; - } -} - - -ret_code_t pds_space_reserve_cancel(pm_prepare_token_t prepare_token) -{ - ret_code_t ret; - - NRF_PM_DEBUG_CHECK(m_module_initialized); - NRF_PM_DEBUG_CHECK(prepare_token != PDS_PREPARE_TOKEN_INVALID); - - ret = fds_reserve_cancel((fds_reserve_token_t*)&prepare_token); - - if (ret != FDS_SUCCESS) - { - return NRF_ERROR_INTERNAL; - } - - return NRF_SUCCESS; -} - - ret_code_t pds_peer_data_store(pm_peer_id_t peer_id, pm_peer_data_const_t const * p_peer_data, - pm_prepare_token_t prepare_token, pm_store_token_t * p_store_token) { ret_code_t ret; @@ -558,32 +526,17 @@ ret_code_t pds_peer_data_store(pm_peer_id_t peer_id, if (ret == NRF_ERROR_NOT_FOUND) { - // No previous data exists in flash. - if (prepare_token == PDS_PREPARE_TOKEN_INVALID) - { - // No space was previously reserved. - ret = fds_record_write(&rec_desc, &rec); - } - else - { - // Space for this record was previously reserved. - ret = fds_record_write_reserved(&rec_desc, &rec, (fds_reserve_token_t*)&prepare_token); - } + ret = fds_record_write(&rec_desc, &rec); } else // NRF_SUCCESS { - if (prepare_token != PDS_PREPARE_TOKEN_INVALID) - { - (void)fds_reserve_cancel((fds_reserve_token_t*)&prepare_token); - } - // Update existing record. ret = fds_record_update(&rec_desc, &rec); } switch (ret) { - case FDS_SUCCESS: + case NRF_SUCCESS: if (p_store_token != NULL) { // Update the store token. @@ -599,6 +552,10 @@ ret_code_t pds_peer_data_store(pm_peer_id_t peer_id, return NRF_ERROR_STORAGE_FULL; default: + NRF_LOG_ERROR("Could not write data to flash. fds_record_{write|update}() returned 0x%x. "\ + "peer_id: %d", + ret, + peer_id); return NRF_ERROR_INTERNAL; } } @@ -625,13 +582,18 @@ ret_code_t pds_peer_data_delete(pm_peer_id_t peer_id, pm_peer_data_id_t data_id) switch (ret) { - case FDS_SUCCESS: + case NRF_SUCCESS: return NRF_SUCCESS; case FDS_ERR_NO_SPACE_IN_QUEUES: return NRF_ERROR_BUSY; default: + NRF_LOG_ERROR("Could not delete peer. fds_record_delete() returned 0x%x. peer_id: %d, "\ + "data_id: %d.", + ret, + peer_id, + data_id); return NRF_ERROR_INTERNAL; } } @@ -650,7 +612,7 @@ ret_code_t pds_peer_id_free(pm_peer_id_t peer_id) VERIFY_PEER_ID_IN_RANGE(peer_id); (void)peer_id_delete(peer_id); - peer_data_delete(); + peer_data_delete_process(); return NRF_SUCCESS; } @@ -663,6 +625,13 @@ bool pds_peer_id_is_allocated(pm_peer_id_t peer_id) } +bool pds_peer_id_is_deleted(pm_peer_id_t peer_id) +{ + NRF_PM_DEBUG_CHECK(m_module_initialized); + return peer_id_is_deleted(peer_id); +} + + pm_peer_id_t pds_next_peer_id_get(pm_peer_id_t prev_peer_id) { NRF_PM_DEBUG_CHECK(m_module_initialized); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_data_storage.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_data_storage.h similarity index 83% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_data_storage.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_data_storage.h index 2138a3b..e88e423 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_data_storage.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_data_storage.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 PEER_DATA_STORAGE_H__ #define PEER_DATA_STORAGE_H__ @@ -63,7 +63,6 @@ extern "C" { * @details This module uses Flash Data Storage (FDS) to interface with persistent storage. */ -#define PDS_PREPARE_TOKEN_INVALID (0) /**< Invalid value for prepare token. */ #define PDS_FIRST_RESERVED_FILE_ID (0xC000) /**< The beginning of the range of file IDs reserved for Peer Manager. */ #define PDS_LAST_RESERVED_FILE_ID (0xFFFE) /**< The end of the range of file IDs reserved for Peer Manager. */ #define PDS_FIRST_RESERVED_RECORD_KEY (0xC000) /**< The beginning of the range of record keys reserved for Peer Manager. */ @@ -88,14 +87,16 @@ ret_code_t pds_init(void); * * @param[in] peer_id The peer the data belongs to. * @param[in] data_id The data to retrieve. - * @param[out] p_data The peer data. May not be @c NULL. + * @param[out] p_data The peer data. May not be @c NULL. p_data.length_words and p_data.data_id + * are ignored. p_data.p_all_data is ignored if @p p_buf_len is @c NULL. * @param[in] p_buf_len Length of the provided buffer, in bytes. Pass @c NULL to only copy * a pointer to the data in flash. * * @retval NRF_SUCCESS If the operation was successful. * @retval NRF_ERROR_INVALID_PARAM If @p peer_id or @p data_id are invalid. * @retval NRF_ERROR_NOT_FOUND If the data was not found in flash. - * @retval NRF_ERROR_NO_MEM If the provided buffer is too small. + * @retval NRF_ERROR_DATA_SIZE If the provided buffer is too small. The data is still copied, + * filling the provided buffer. */ ret_code_t pds_peer_data_read(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, @@ -124,32 +125,6 @@ bool pds_peer_data_iterate(pm_peer_data_id_t data_id, pm_peer_data_flash_t * const p_data); -/**@brief Function for reserving space in flash to store data. - * - * @param[in] p_peer_data The data to be stored in flash. Only data length and type (ID) are - * relevant for this operation. May not be @c NULL. - * @param[out] p_prepare_token A token identifying the reserved space. May not be @c NULL. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_PARAM If the data ID in @p p_peer_data is invalid. - * @retval NRF_ERROR_INVALID_LENGTH If data length exceeds the maximum allowed length. - * @retval NRF_ERROR_STORAGE_FULL If no space is available in flash. - * @retval NRF_ERROR_INTERNAL If an unexpected error occurred. - */ -ret_code_t pds_space_reserve(pm_peer_data_const_t const * p_peer_data, - pm_prepare_token_t * p_prepare_token); - - -/**@brief Function for undoing a previous call to @ref pds_space_reserve. - * - * @param[in] prepare_token A token identifying the reservation to cancel. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INTERNAL If an unexpected error occurred. - */ -ret_code_t pds_space_reserve_cancel(pm_prepare_token_t prepare_token); - - /**@brief Function for storing peer data in flash. If the same piece of data already exists for the * given peer, it will be updated. This operation is asynchronous. * Expect a @ref PM_EVT_PEER_DATA_UPDATE_SUCCEEDED or @ref PM_EVT_PEER_DATA_UPDATE_FAILED @@ -157,22 +132,18 @@ ret_code_t pds_space_reserve_cancel(pm_prepare_token_t prepare_token); * * @param[in] peer_id The peer the data belongs to. * @param[in] p_peer_data The peer data. May not be @c NULL. - * @param[in] prepare_token A token identifying the reservation made in flash to store the data. - * Pass @ref PDS_PREPARE_TOKEN_INVALID if no space was reserved. * @param[out] p_store_token A token identifying this particular store operation. The token can be * used to identify events pertaining to this operation. Pass @p NULL * if not used. * * @retval NRF_SUCCESS If the operation was initiated successfully. * @retval NRF_ERROR_INVALID_PARAM If @p peer_id or the data ID in @p_peer_data are invalid. - * @retval NRF_ERROR_STORAGE_FULL If no space is available in flash. This can only happen if - * @p p_prepare_token is @ref PDS_PREPARE_TOKEN_INVALID. + * @retval NRF_ERROR_STORAGE_FULL If no space is available in flash. * @retval NRF_ERROR_BUSY If the flash filesystem was busy. * @retval NRF_ERROR_INTERNAL If an unexpected error occurred. */ ret_code_t pds_peer_data_store(pm_peer_id_t peer_id, pm_peer_data_const_t const * p_peer_data, - pm_prepare_token_t prepare_token, pm_store_token_t * p_store_token); @@ -219,6 +190,15 @@ ret_code_t pds_peer_id_free(pm_peer_id_t peer_id); bool pds_peer_id_is_allocated(pm_peer_id_t peer_id); +/**@brief Function for finding out whether a peer ID is marked for deletion. + * + * @param[in] peer_id The peer ID to inquire about. + * + * @retval true @p peer_id is marked for deletion. + * @retval false @p peer_id is not marked for deletion. + */ +bool pds_peer_id_is_deleted(pm_peer_id_t peer_id); + /**@brief Function for getting the next peer ID in the sequence of all used peer IDs. Can be * used to loop through all used peer IDs. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_database.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_database.c similarity index 77% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_database.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_database.c index 9216136..2326d60 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_database.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_database.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -47,6 +47,18 @@ #include "peer_data_storage.h" #include "pm_buffer.h" +#define NRF_LOG_MODULE_NAME peer_manager_pdb +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" /**@brief Macro for verifying that the data ID is among the values eligible for using the write buffer. * @@ -70,7 +82,9 @@ do // Peer Database event handlers in other Peer Manager submodules. extern void pm_pdb_evt_handler(pm_evt_t * p_event); extern void sm_pdb_evt_handler(pm_evt_t * p_event); +#if !defined(PM_SERVICE_CHANGED_ENABLED) || (PM_SERVICE_CHANGED_ENABLED == 1) extern void gscm_pdb_evt_handler(pm_evt_t * p_event); +#endif extern void gcm_pdb_evt_handler(pm_evt_t * p_event); // Peer Database events' handlers. @@ -79,7 +93,9 @@ static pm_evt_handler_internal_t const m_evt_handlers[] = { pm_pdb_evt_handler, sm_pdb_evt_handler, +#if !defined(PM_SERVICE_CHANGED_ENABLED) || (PM_SERVICE_CHANGED_ENABLED == 1) gscm_pdb_evt_handler, +#endif gcm_pdb_evt_handler, }; @@ -91,7 +107,6 @@ typedef struct { pm_peer_id_t peer_id; /**< The peer ID this buffer belongs to. */ pm_peer_data_id_t data_id; /**< The data ID this buffer belongs to. */ - pm_prepare_token_t prepare_token; /**< Token given by Peer Data Storage if room in flash has been reserved. */ pm_store_token_t store_token; /**< Token given by Peer Data Storage when a flash write has been successfully requested. This is used as the check for whether such an operation has been successfully requested. */ uint8_t n_bufs; /**< The number of buffer blocks containing peer data. */ uint8_t buffer_block_id; /**< The index of the first (or only) buffer block containing peer data. */ @@ -101,9 +116,9 @@ typedef struct static bool m_module_initialized; -static pm_buffer_t m_write_buffer; /**< The state of the write buffer. */ +static pm_buffer_t m_write_buffer; /**< The internal states of the write buffer. */ static pdb_buffer_record_t m_write_buffer_records[PM_FLASH_BUFFERS]; /**< The available write buffer records. */ -static uint32_t m_n_pending_writes; /**< The number of pending (Not yet successfully requested in Peer Data Storage) store operations. */ +static bool m_pending_store = false; /**< Whether there are any pending (Not yet successfully requested in Peer Data Storage) store operations. This flag is for convenience only. The real bookkeeping is in the records (@ref m_write_buffer_records). */ @@ -119,7 +134,6 @@ static void write_buffer_record_invalidate(pdb_buffer_record_t * p_record) p_record->store_busy = false; p_record->store_flash_full = false; p_record->n_bufs = 0; - p_record->prepare_token = PDS_PREPARE_TOKEN_INVALID; p_record->store_token = PM_STORE_TOKEN_INVALID; } @@ -318,8 +332,7 @@ static void write_buf_length_words_set(pm_peer_data_const_t * p_peer_data) * @retval NRF_SUCCESS Data storing was successfully started. * @retval NRF_ERROR_STORAGE_FULL No space available in persistent storage. Please clear some * space, the operation will be reattempted after the next compress - * procedure. This error will not happen if - * @ref pdb_write_buf_store_prepare is called beforehand. + * procedure. * @retval NRF_ERROR_INVALID_PARAM Data ID was invalid. * @retval NRF_ERROR_INVALID_STATE Module is not initialized. * @retval NRF_ERROR_INTERNAL Unexpected internal error. @@ -333,6 +346,8 @@ ret_code_t write_buf_store(pdb_buffer_record_t * p_write_buffer_record) p_buffer_memory = pm_buffer_ptr_get(&m_write_buffer, p_write_buffer_record->buffer_block_id); if (p_buffer_memory == NULL) { + NRF_LOG_ERROR("pm_buffer_ptr_get() could not retrieve RAM buffer. block_id: %d", + p_write_buffer_record->buffer_block_id); return NRF_ERROR_INTERNAL; } @@ -344,13 +359,8 @@ ret_code_t write_buf_store(pdb_buffer_record_t * p_write_buffer_record) err_code = pds_peer_data_store(p_write_buffer_record->peer_id, &peer_data, - p_write_buffer_record->prepare_token, &p_write_buffer_record->store_token); - if (p_write_buffer_record->store_busy && p_write_buffer_record->store_flash_full) - { - m_n_pending_writes--; - } switch (err_code) { @@ -360,19 +370,17 @@ ret_code_t write_buf_store(pdb_buffer_record_t * p_write_buffer_record) break; case NRF_ERROR_BUSY: - m_n_pending_writes++; - p_write_buffer_record->store_busy = true; p_write_buffer_record->store_flash_full = false; + m_pending_store = true; err_code = NRF_SUCCESS; break; case NRF_ERROR_STORAGE_FULL: - m_n_pending_writes++; - p_write_buffer_record->store_busy = false; p_write_buffer_record->store_flash_full = true; + m_pending_store = true; break; case NRF_ERROR_INVALID_PARAM: @@ -380,6 +388,9 @@ ret_code_t write_buf_store(pdb_buffer_record_t * p_write_buffer_record) break; default: + NRF_LOG_ERROR("pds_peer_data_store() returned %s. peer_id: %d", + nrf_strerror_get(err_code), + p_write_buffer_record->peer_id); err_code = NRF_ERROR_INTERNAL; break; } @@ -413,6 +424,11 @@ static bool write_buf_store_in_event(pdb_buffer_record_t * p_write_buffer_record { event.evt_id = PM_EVT_ERROR_UNEXPECTED; event.params.error_unexpected.error = err_code; + + NRF_LOG_ERROR("Some peer data was not properly written to flash. write_buf_store() "\ + "returned %s for peer_id: %d", + nrf_strerror_get(err_code), + p_write_buffer_record->peer_id); } pdb_evt_send(&event); @@ -432,23 +448,26 @@ static bool write_buf_store_in_event(pdb_buffer_record_t * p_write_buffer_record */ static void reattempt_previous_operations(bool retry_flash_full) { - // Reattempt previously rejected store operations. - - if (m_n_pending_writes == 0) + if (!m_pending_store) { return; } + m_pending_store = false; + for (uint32_t i = 0; i < PM_FLASH_BUFFERS; i++) { if ((m_write_buffer_records[i].store_busy) - || (m_write_buffer_records[i].store_flash_full && retry_flash_full)) + || (m_write_buffer_records[i].store_flash_full)) { - bool success = write_buf_store_in_event(&m_write_buffer_records[i]); + m_pending_store = true; - if (!success) + if (m_write_buffer_records[i].store_busy || retry_flash_full) { - break; + if (!write_buf_store_in_event(&m_write_buffer_records[i])) + { + return; + } } } } @@ -484,9 +503,9 @@ void pdb_pds_evt_handler(pm_evt_t * p_event) && (p_write_buffer_record != NULL)) { // The write came from PDB, retry. - m_n_pending_writes++; p_write_buffer_record->store_token = PM_STORE_TOKEN_INVALID; p_write_buffer_record->store_busy = true; + m_pending_store = true; evt_send = false; } break; @@ -511,16 +530,17 @@ void pdb_pds_evt_handler(pm_evt_t * p_event) ret_code_t pdb_init() { - ret_code_t ret; + ret_code_t err_code; NRF_PM_DEBUG_CHECK(!m_module_initialized); internal_state_reset(); - PM_BUFFER_INIT(&m_write_buffer, PM_FLASH_BUFFERS, PDB_WRITE_BUF_SIZE, ret); + PM_BUFFER_INIT(&m_write_buffer, PM_FLASH_BUFFERS, PDB_WRITE_BUF_SIZE, err_code); - if (ret != NRF_SUCCESS) + if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("PM_BUFFER_INIT() returned %s.", nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } @@ -530,17 +550,9 @@ ret_code_t pdb_init() } -pm_peer_id_t pdb_peer_allocate(void) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - return pds_peer_id_allocate(); -} - - ret_code_t pdb_peer_free(pm_peer_id_t peer_id) { - ret_code_t err_code_in = NRF_SUCCESS; - ret_code_t err_code_out = NRF_SUCCESS; + ret_code_t err_code; NRF_PM_DEBUG_CHECK(m_module_initialized); @@ -549,37 +561,37 @@ ret_code_t pdb_peer_free(pm_peer_id_t peer_id) while (p_record != NULL) { - err_code_in = pdb_write_buf_release(peer_id, p_record->data_id); + err_code = pdb_write_buf_release(peer_id, p_record->data_id); + UNUSED_VARIABLE(err_code); // All return values are acceptable. - if ( (err_code_in != NRF_SUCCESS) - && (err_code_in != NRF_ERROR_NOT_FOUND)) + if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_NOT_FOUND)) { - err_code_out = NRF_ERROR_INTERNAL; + NRF_LOG_ERROR("pdb_write_buf_release() returned %s which should not happen. peer_id: %d, "\ + "data_id: %d", + nrf_strerror_get(err_code), + peer_id, + p_record->data_id); + return NRF_ERROR_INTERNAL; } index++; p_record = write_buffer_record_find_next(peer_id, &index); } - if (err_code_out == NRF_SUCCESS) - { - err_code_in = pds_peer_id_free(peer_id); + err_code = pds_peer_id_free(peer_id); - if (err_code_in == NRF_SUCCESS) - { - // No action needed. - } - else if (err_code_in == NRF_ERROR_INVALID_PARAM) - { - err_code_out = NRF_ERROR_INVALID_PARAM; - } - else - { - err_code_out = NRF_ERROR_INTERNAL; - } + if ((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_INVALID_PARAM)) + { + return err_code; + } + else + { + NRF_LOG_ERROR("Peer ID %d was not properly released. pds_peer_id_free() returned %s. "\ + "peer_id: %d", + peer_id, + nrf_strerror_get(err_code)); + return NRF_ERROR_INTERNAL; } - - return err_code_out; } @@ -606,9 +618,7 @@ ret_code_t pdb_write_buf_get(pm_peer_id_t peer_id, VERIFY_PARAM_NOT_NULL(p_peer_data); VERIFY_DATA_ID_WRITE_BUF(data_id); - if ( (n_bufs == 0) - || (n_bufs > PM_FLASH_BUFFERS) - || !pds_peer_id_is_allocated(peer_id)) + if ((n_bufs == 0) || (n_bufs > PM_FLASH_BUFFERS)) { return NRF_ERROR_INVALID_PARAM; } @@ -616,39 +626,10 @@ ret_code_t pdb_write_buf_get(pm_peer_id_t peer_id, pdb_buffer_record_t * p_write_buffer_record; uint8_t * p_buffer_memory; bool new_record = false; - bool find_new_buffer = false; p_write_buffer_record = write_buffer_record_find(peer_id, data_id); if (p_write_buffer_record == NULL) - { - find_new_buffer = true; - } - else if (p_write_buffer_record->n_bufs < n_bufs) - { - // @TODO: Copy? - // Existing buffer is too small. - for (uint8_t i = 0; i < p_write_buffer_record->n_bufs; i++) - { - pm_buffer_release(&m_write_buffer, p_write_buffer_record->buffer_block_id + i); - } - write_buffer_record_invalidate(p_write_buffer_record); - find_new_buffer = true; - } - else if (p_write_buffer_record->n_bufs > n_bufs) - { - // Release excess blocks. - for (uint8_t i = n_bufs; i < p_write_buffer_record->n_bufs; i++) - { - pm_buffer_release(&m_write_buffer, p_write_buffer_record->buffer_block_id + i); - } - } - else - { - // Do nothing. - } - - if (find_new_buffer) { // No buffer exists. write_buffer_record_acquire(&p_write_buffer_record, peer_id, data_id); @@ -657,6 +638,11 @@ ret_code_t pdb_write_buf_get(pm_peer_id_t peer_id, return NRF_ERROR_BUSY; } } + else if (p_write_buffer_record->n_bufs != n_bufs) + { + // Buffer exists with a different n_bufs from what was requested. + return NRF_ERROR_FORBIDDEN; + } if (p_write_buffer_record->buffer_block_id == PM_BUFFER_INVALID_ID) { @@ -677,6 +663,9 @@ ret_code_t pdb_write_buf_get(pm_peer_id_t peer_id, if (p_buffer_memory == NULL) { + NRF_LOG_ERROR("Cannot store data to flash because pm_buffer_ptr_get() could not retrieve "\ + "RAM buffer. Is block_id %d not allocated?", + p_write_buffer_record->buffer_block_id); return NRF_ERROR_INTERNAL; } @@ -694,7 +683,6 @@ ret_code_t pdb_write_buf_release(pm_peer_id_t peer_id, pm_peer_data_id_t data_id { NRF_PM_DEBUG_CHECK(m_module_initialized); - ret_code_t err_code = NRF_SUCCESS; pdb_buffer_record_t * p_write_buffer_record; p_write_buffer_record = write_buffer_record_find(peer_id, data_id); @@ -703,59 +691,9 @@ ret_code_t pdb_write_buf_release(pm_peer_id_t peer_id, pm_peer_data_id_t data_id return NRF_ERROR_NOT_FOUND; } - if (p_write_buffer_record->prepare_token != PDS_PREPARE_TOKEN_INVALID) - { - err_code = pds_space_reserve_cancel(p_write_buffer_record->prepare_token); - if (err_code != NRF_SUCCESS) - { - err_code = NRF_ERROR_INTERNAL; - } - } - write_buffer_record_release(p_write_buffer_record); - return err_code; -} - - -ret_code_t pdb_write_buf_store_prepare(pm_peer_id_t peer_id, pm_peer_data_id_t data_id) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - - VERIFY_DATA_ID_WRITE_BUF(data_id); - - ret_code_t err_code = NRF_SUCCESS; - pdb_buffer_record_t * p_write_buffer_record; - p_write_buffer_record = write_buffer_record_find(peer_id, data_id); - - if (p_write_buffer_record == NULL) - { - return NRF_ERROR_NOT_FOUND; - } - - if (p_write_buffer_record->prepare_token == PDS_PREPARE_TOKEN_INVALID) - { - uint8_t * p_buffer_memory = pm_buffer_ptr_get(&m_write_buffer, - p_write_buffer_record->buffer_block_id); - pm_peer_data_const_t peer_data = {.data_id = data_id}; - - if (p_buffer_memory == NULL) - { - return NRF_ERROR_INTERNAL; - } - - peer_data_const_point_to_buffer(&peer_data, data_id, p_buffer_memory, p_write_buffer_record->n_bufs); - - write_buf_length_words_set(&peer_data); - - err_code = pds_space_reserve(&peer_data, &p_write_buffer_record->prepare_token); - if (err_code == NRF_ERROR_INVALID_LENGTH) - { - return NRF_ERROR_INTERNAL; - } - } - - return err_code; + return NRF_SUCCESS; } @@ -767,6 +705,11 @@ ret_code_t pdb_write_buf_store(pm_peer_id_t peer_id, VERIFY_DATA_ID_WRITE_BUF(data_id); + if (!pds_peer_id_is_allocated(new_peer_id)) + { + return NRF_ERROR_INVALID_PARAM; + } + pdb_buffer_record_t * p_write_buffer_record = write_buffer_record_find(peer_id, data_id); if (p_write_buffer_record == NULL) @@ -780,52 +723,4 @@ ret_code_t pdb_write_buf_store(pm_peer_id_t peer_id, } -ret_code_t pdb_clear(pm_peer_id_t peer_id, pm_peer_data_id_t data_id) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - return pds_peer_data_delete(peer_id, data_id); -} - - -uint32_t pdb_n_peers(void) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - return pds_peer_count_get(); -} - - -pm_peer_id_t pdb_next_peer_id_get(pm_peer_id_t prev_peer_id) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - return pds_next_peer_id_get(prev_peer_id); -} - - -pm_peer_id_t pdb_next_deleted_peer_id_get(pm_peer_id_t prev_peer_id) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - return pds_next_deleted_peer_id_get(prev_peer_id); -} - - -ret_code_t pdb_peer_data_load(pm_peer_id_t peer_id, - pm_peer_data_id_t data_id, - pm_peer_data_t * const p_peer_data) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - NRF_PM_DEBUG_CHECK(p_peer_data != NULL); - - // Provide the buffer length in bytes. - uint32_t const data_len_bytes = (p_peer_data->length_words * sizeof(uint32_t)); - return pds_peer_data_read(peer_id, data_id, p_peer_data, &data_len_bytes); -} - - -ret_code_t pdb_raw_store(pm_peer_id_t peer_id, - pm_peer_data_const_t * p_peer_data, - pm_store_token_t * p_store_token) -{ - NRF_PM_DEBUG_CHECK(m_module_initialized); - return pds_peer_data_store(peer_id, p_peer_data, PDS_PREPARE_TOKEN_INVALID, p_store_token); -} #endif // NRF_MODULE_ENABLED(PEER_MANAGER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_database.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_database.h similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_database.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_database.h index 5e1e0fb..982b2bd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_database.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_database.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 PEER_DATABASE_H__ #define PEER_DATABASE_H__ @@ -61,6 +61,15 @@ extern "C" { #define PDB_WRITE_BUF_SIZE (sizeof(pm_peer_data_bonding_t)) //!< The size (in bytes) of each block in the internal buffer accessible via @ref pdb_write_buf_get. +/**@brief Macro for creating a peer ID value from a connection handle. + * + * Use this macro with pdb_write_buf_get() or pdb_write_buf_store(). It allows to create a write buffer + * even if you do not yet know the proper peer ID the data will be stored for. + * + * @return @p conn_handle + @ref PM_PEER_ID_N_AVAILABLE_IDS. + */ +#define PDB_TEMP_PEER_ID(conn_handle) (PM_PEER_ID_N_AVAILABLE_IDS + conn_handle) + /**@brief Function for initializing the module. * @@ -69,15 +78,6 @@ extern "C" { */ ret_code_t pdb_init(void); - -/**@brief Function for allocating persistent bond storage for a peer. - * - * @return The ID of the newly allocated storage. - * @retval PM_PEER_ID_INVALID If no peer ID is available. - */ -pm_peer_id_t pdb_peer_allocate(void); - - /**@brief Function for freeing a peer's persistent bond storage. * * @note This function will call @ref pdb_write_buf_release on the data for this peer. @@ -89,7 +89,6 @@ pm_peer_id_t pdb_peer_allocate(void); */ ret_code_t pdb_peer_free(pm_peer_id_t peer_id); - /**@brief Function for retrieving a pointer to peer data in flash (read-only). * * @note Dereferencing this pointer is not the safest thing to do if interrupts are enabled, @@ -108,7 +107,6 @@ ret_code_t pdb_peer_data_ptr_get(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, pm_peer_data_flash_t * const p_peer_data); - /**@brief Function for retrieving pointers to a write buffer for peer data. * * @details This function will provide pointers to a buffer of the data. The data buffer will not be @@ -125,14 +123,20 @@ ret_code_t pdb_peer_data_ptr_get(pm_peer_id_t peer_id, * will be copied. If n_bufs was increased since last time, this function might return @ref * NRF_ERROR_BUSY. In that case, the buffer is automatically released. * - * @param[in] peer_id ID of peer to get a write buffer for. - * @param[in] data_id Which piece of data to get. - * @param[in] n_bufs The number of contiguous buffers needed. + * @param[in] peer_id ID of the peer to get a write buffer for. If @p peer_id is larger than + * @ref PM_PEER_ID_N_AVAILABLE_IDS, it is interpreted as pertaining to + * the connection with connection handle peer_id - PM_PEER_ID_N_AVAILABLE_IDS. + * See @ref PDB_TEMP_PEER_ID. + * @param[in] data_id The piece of data to get. + * @param[in] n_bufs Number of contiguous buffers needed. * @param[out] p_peer_data Pointers to mutable peer data. * * @retval NRF_SUCCESS Data retrieved successfully. - * @retval NRF_ERROR_INVALID_PARAM Data ID or Peer ID was invalid or unallocated, or n_bufs was 0 - * or more than the total available buffers. + * @retval NRF_ERROR_INVALID_PARAM @p data_id was invalid, or @p n_bufs was 0 or more than the total + * available buffers. + * @retval NRF_ERROR_FORBIDDEN n_bufs was higher or lower than the existing buffer. If needed, + * release the existing buffer with @ref pdb_write_buf_release, and + * call this function again. * @retval NRF_ERROR_NULL p_peer_data was NULL. * @retval NRF_ERROR_BUSY Not enough buffer(s) available. * @retval NRF_ERROR_INTERNAL Unexpected internal error. @@ -142,57 +146,33 @@ ret_code_t pdb_write_buf_get(pm_peer_id_t peer_id, uint32_t n_bufs, pm_peer_data_t * p_peer_data); - /**@brief Function for freeing a write buffer allocated with @ref pdb_write_buf_get. * * @note This function will not write peer data to persistent memory. Data in released buffer will * be lost. * - * @note This function will undo any previous call to @ref pdb_write_buf_store_prepare for this - * piece of data. - * * @param[in] peer_id ID of peer to release buffer for. * @param[in] data_id Which piece of data to release buffer for. * * @retval NRF_SUCCESS Successfully released buffer. * @retval NRF_ERROR_NOT_FOUND No buffer was allocated for this peer ID/data ID pair. - * @retval NRF_ERROR_INTERNAL Unexpected internal error. */ ret_code_t pdb_write_buf_release(pm_peer_id_t peer_id, pm_peer_data_id_t data_id); - -/**@brief Function for reserving space in persistent storage for data in a buffer. - * - * @note This function only works for data which has a write buffer allocated. If the write buffer - * is released, this prepare is undone. - * - * @note If space has already been reserved for this data, nothing is done. - * - * @param[in] peer_id The peer whose data to reserve space for. - * @param[in] data_id The type of data to reserve space for. - * - * @retval NRF_SUCCESS Successfully reserved space in persistent storage. - * @retval NRF_ERROR_STORAGE_FULL Not enough room in persistent storage. - * @retval NRF_ERROR_NOT_FOUND No buffer has been allocated for this peer ID/data ID pair. - * @retval NRF_ERROR_INVALID_PARAM Data ID or Peer ID was invalid or unallocated. - */ -ret_code_t pdb_write_buf_store_prepare(pm_peer_id_t peer_id, pm_peer_data_id_t data_id); - - /**@brief Function for writing data into persistent storage. Writing happens asynchronously. * * @note This will unlock the data after it has been written. * * @param[in] peer_id The ID used to address the write buffer. - * @param[in] data_id Which piece of data to store. - * @param[in] new_peer_id The ID to put in flash. This will usually be the same as peer_id. + * @param[in] data_id The piece of data to store. + * @param[in] new_peer_id The ID to put in flash. This is usually the same as peer_id, but + * must be valid, i.e. allocated (and smaller than @ref PM_PEER_ID_N_AVAILABLE_IDS). * * @retval NRF_SUCCESS Data storing was successfully started. * @retval NRF_ERROR_STORAGE_FULL No space available in persistent storage. Please clear some * space, the operation will be reattempted after the next compress - * procedure. This error will not happen if - * @ref pdb_write_buf_store_prepare is called beforehand. - * @retval NRF_ERROR_INVALID_PARAM Data ID was invalid. + * procedure. + * @retval NRF_ERROR_INVALID_PARAM @p data_id or @p new_peer_id was invalid. * @retval NRF_ERROR_NOT_FOUND No buffer has been allocated for this peer ID/data ID pair. * @retval NRF_ERROR_INTERNAL Unexpected internal error. */ @@ -200,98 +180,6 @@ ret_code_t pdb_write_buf_store(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, pm_peer_id_t new_peer_id); - -/**@brief Function for clearing data from persistent storage. - * - * @param[in] peer_id ID of peer to clear data for. - * @param[in] data_id Which piece of data to clear. - * - * @retval NRF_SUCCESS The clear was initiated successfully. - * @retval NRF_ERROR_INVALID_PARAM Data ID or peer ID was invalid. - * @retval NRF_ERROR_NOT_FOUND Nothing to clear for this peer ID/data ID combination. - * @retval NRF_ERROR_BUSY Underlying modules are busy and can't take any more requests at - * this moment. - * @retval NRF_ERROR_INTERNAL Internal error. - */ -ret_code_t pdb_clear(pm_peer_id_t peer_id, pm_peer_data_id_t data_id); - - -/**@brief Function for querying the number of valid peer IDs available. I.E the number of peers - * in persistent storage. - * - * @return The number of valid peer IDs. - */ -uint32_t pdb_n_peers(void); - - -/**@brief Function for getting the next peer ID in the sequence of all used peer IDs. Can be - * used to loop through all used peer IDs. - * - * @note @ref PM_PEER_ID_INVALID is considered to be before the first and after the last ordinary - * peer ID. - * - * @param[in] prev_peer_id The previous peer ID. - * - * @return The next peer ID. - * @return The first ordinary peer ID if prev_peer_id was @ref PM_PEER_ID_INVALID. - * @retval PM_PEER_ID_INVALID if prev_peer_id was the last ordinary peer ID. - */ -pm_peer_id_t pdb_next_peer_id_get(pm_peer_id_t prev_peer_id); - - -/**@brief Function for getting the next peer ID in the sequence of all peer IDs pending deletion. - * Can be used to loop through all used peer IDs. - * - * @note @ref PM_PEER_ID_INVALID is considered to be before the first and after the last ordinary - * peer ID. - * - * @param[in] prev_peer_id The previous peer ID. - * - * @return The next peer ID pending deletion. - * @return The first ordinary peer ID if prev_peer_id was @ref PM_PEER_ID_INVALID. - * @retval PM_PEER_ID_INVALID if prev_peer_id was the last ordinary peer ID. - */ -pm_peer_id_t pdb_next_deleted_peer_id_get(pm_peer_id_t prev_peer_id); - - -/**@brief Function for copy peer data from flash into a provided buffer. - * - * @param[in] peer_id The peer the data belongs to. - * @param[in] data_id The data to read. - * @param[inout] p_peer_data The buffer where to copy data into. The field @c length_words in this - * parameter must represent the buffer length in words. - * - * @note Actually, it represents the buffer length in bytes upon entering the function, - * and upon exit it represents the length of the data in words.. not good. Fix this. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_PARAM If @p peer_id or @p data_id are invalid. - * @retval NRF_ERROR_NOT_FOUND If the data was not found in flash. - * @retval NRF_ERROR_NO_MEM If the provided buffer is too small. - */ -ret_code_t pdb_peer_data_load(pm_peer_id_t peer_id, - pm_peer_data_id_t data_id, - pm_peer_data_t * const p_peer_data); - - -/**@brief Function for writing data directly to persistent storage from external memory. - * - * @param[in] peer_id ID of peer to write data for. - * @param[in] p_peer_data Data to store. - * @param[out] p_store_token A token identifying this particular store operation. The token can be - * used to identify events pertaining to this operation. - * - * @retval NRF_SUCCESS Data successfully written. - * @retval NRF_ERROR_INVALID_PARAM Data ID or Peer ID was invalid or unallocated. - * @retval NRF_ERROR_NULL p_peer_data contained a NULL pointer. - * @retval NRF_ERROR_STORAGE_FULL No space available in persistent storage. - * @retval NRF_ERROR_INVALID_LENGTH Data length above the maximum allowed. - * @retval NRF_ERROR_BUSY Unable to perform operation at this time. - */ -ret_code_t pdb_raw_store(pm_peer_id_t peer_id, - pm_peer_data_const_t * p_peer_data, - pm_store_token_t * p_store_token); - /** @} * @endcond */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_id.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_id.c similarity index 78% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_id.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_id.c index 06b0594..9149c21 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_id.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_id.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -45,13 +45,13 @@ #include #include "sdk_errors.h" #include "peer_manager_types.h" -#include "pm_mutex.h" +#include "nrf_atflags.h" typedef struct { - uint8_t used_peer_ids[MUTEX_STORAGE_SIZE(PM_PEER_ID_N_AVAILABLE_IDS)]; /**< Bitmap designating which peer IDs are in use. */ - uint8_t deleted_peer_ids[MUTEX_STORAGE_SIZE(PM_PEER_ID_N_AVAILABLE_IDS)]; /**< Bitmap designating which peer IDs are marked for deletion. */ + NRF_ATFLAGS_DEF_MEMBER(used_peer_ids, PM_PEER_ID_N_AVAILABLE_IDS); /**< Bitmap designating which peer IDs are in use. */ + NRF_ATFLAGS_DEF_MEMBER(deleted_peer_ids, PM_PEER_ID_N_AVAILABLE_IDS); /**< Bitmap designating which peer IDs are marked for deletion. */ } pi_t; @@ -67,17 +67,15 @@ static void internal_state_reset(pi_t * p_pi) void peer_id_init(void) { internal_state_reset(&m_pi); - pm_mutex_init(m_pi.used_peer_ids, PM_PEER_ID_N_AVAILABLE_IDS); - pm_mutex_init(m_pi.deleted_peer_ids, PM_PEER_ID_N_AVAILABLE_IDS); } -static pm_peer_id_t claim(pm_peer_id_t peer_id, uint8_t * mutex_group) +static pm_peer_id_t claim(pm_peer_id_t peer_id, nrf_atflags_t * p_peer_id_flags) { pm_peer_id_t allocated_peer_id = PM_PEER_ID_INVALID; if (peer_id == PM_PEER_ID_INVALID) { - allocated_peer_id = pm_mutex_lock_first_available(mutex_group, PM_PEER_ID_N_AVAILABLE_IDS); + allocated_peer_id = nrf_atflags_find_and_set_flag(p_peer_id_flags, PM_PEER_ID_N_AVAILABLE_IDS); if (allocated_peer_id == PM_PEER_ID_N_AVAILABLE_IDS) { allocated_peer_id = PM_PEER_ID_INVALID; @@ -85,18 +83,18 @@ static pm_peer_id_t claim(pm_peer_id_t peer_id, uint8_t * mutex_group) } else if (peer_id < PM_PEER_ID_N_AVAILABLE_IDS) { - bool lock_success = pm_mutex_lock(mutex_group, peer_id); + bool lock_success = !nrf_atflags_fetch_set(p_peer_id_flags, peer_id); allocated_peer_id = lock_success ? peer_id : PM_PEER_ID_INVALID; } return allocated_peer_id; } -static void release(pm_peer_id_t peer_id, uint8_t * mutex_group) +static void release(pm_peer_id_t peer_id, nrf_atflags_t * p_peer_id_flags) { if (peer_id < PM_PEER_ID_N_AVAILABLE_IDS) { - pm_mutex_unlock(mutex_group, peer_id); + nrf_atflags_clear(p_peer_id_flags, peer_id); } } @@ -133,7 +131,7 @@ bool peer_id_is_allocated(pm_peer_id_t peer_id) { if (peer_id < PM_PEER_ID_N_AVAILABLE_IDS) { - return pm_mutex_lock_status_get(m_pi.used_peer_ids, peer_id); + return nrf_atflags_get(m_pi.used_peer_ids, peer_id); } return false; } @@ -143,18 +141,18 @@ bool peer_id_is_deleted(pm_peer_id_t peer_id) { if (peer_id < PM_PEER_ID_N_AVAILABLE_IDS) { - return pm_mutex_lock_status_get(m_pi.deleted_peer_ids, peer_id); + return nrf_atflags_get(m_pi.deleted_peer_ids, peer_id); } return false; } -pm_peer_id_t next_id_get(pm_peer_id_t prev_peer_id, uint8_t * mutex_group) +pm_peer_id_t next_id_get(pm_peer_id_t prev_peer_id, nrf_atflags_t * p_peer_id_flags) { pm_peer_id_t i = (prev_peer_id == PM_PEER_ID_INVALID) ? 0 : (prev_peer_id + 1); for (; i < PM_PEER_ID_N_AVAILABLE_IDS; i++) { - if (pm_mutex_lock_status_get(mutex_group, i)) + if (nrf_atflags_get(p_peer_id_flags, i)) { return i; } @@ -194,7 +192,7 @@ uint32_t peer_id_n_ids(void) for (pm_peer_id_t i = 0; i < PM_PEER_ID_N_AVAILABLE_IDS; i++) { - n_ids += pm_mutex_lock_status_get(m_pi.used_peer_ids, i); + n_ids += nrf_atflags_get(m_pi.used_peer_ids, i); } return n_ids; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_id.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_id.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_id.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_id.h index 5664ccc..c4d7481 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_id.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_id.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 PEER_ID_H__ #define PEER_ID_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager.c similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager.c index 9d31a46..ca0a600 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -53,6 +53,23 @@ #include "peer_manager_internal.h" #include "nrf_sdh_ble.h" +#define NRF_LOG_MODULE_NAME peer_manager +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" + + +#ifndef PM_PEER_RANKS_ENABLED + #define PM_PEER_RANKS_ENABLED 1 +#endif #define MODULE_INITIALIZED (m_module_initialized) /**< Macro indicating whether the module has been initialized properly. */ @@ -65,7 +82,6 @@ static uint32_t m_current_highest_peer_rank; /**< The static pm_peer_id_t m_highest_ranked_peer; /**< The peer with the highest peer rank. Used by @ref pm_peer_rank_highest. */ static pm_evt_handler_t m_evt_handlers[PM_MAX_REGISTRANTS];/**< The subscribers to Peer Manager events, as registered through @ref pm_register. */ static uint8_t m_n_registrants; /**< The number of event handlers registered through @ref pm_register. */ -static ble_conn_state_user_flag_id_t m_bonded_flag_id; /**< The flag ID for which connections are with a peer with which we are bonded. */ /**@brief Function for sending a Peer Manager event to all subscribers. @@ -81,6 +97,7 @@ static void evt_send(pm_evt_t const * p_pm_evt) } +#if PM_PEER_RANKS_ENABLED == 1 /**@brief Function for initializing peer rank static variables. */ static void rank_vars_update(void) @@ -90,8 +107,15 @@ static void rank_vars_update(void) NULL, NULL); + if (err_code == NRF_ERROR_NOT_FOUND) + { + m_highest_ranked_peer = PM_PEER_ID_INVALID; + m_current_highest_peer_rank = 0; + } + m_peer_rank_initialized = ((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_NOT_FOUND)); } +#endif /**@brief Event handler for events from the Peer Database module. @@ -107,6 +131,7 @@ void pm_pdb_evt_handler(pm_evt_t * p_pdb_evt) switch (p_pdb_evt->evt_id) { +#if PM_PEER_RANKS_ENABLED == 1 case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED: if (p_pdb_evt->params.peer_data_update_succeeded.action == PM_PEER_DATA_OP_UPDATE) { @@ -152,12 +177,13 @@ void pm_pdb_evt_handler(pm_evt_t * p_pdb_evt) } } break; +#endif case PM_EVT_PEER_DELETE_SUCCEEDED: // Check that no peers marked for deletion are left. if (m_deleting_all - && (pdb_next_peer_id_get(PM_PEER_ID_INVALID) == PM_PEER_ID_INVALID) - && (pdb_next_deleted_peer_id_get(PM_PEER_ID_INVALID) == PM_PEER_ID_INVALID)) + && (pds_next_peer_id_get(PM_PEER_ID_INVALID) == PM_PEER_ID_INVALID) + && (pds_next_deleted_peer_id_get(PM_PEER_ID_INVALID) == PM_PEER_ID_INVALID)) { // pm_peers_delete() has been called and this is the last peer to be deleted. m_deleting_all = false; @@ -175,11 +201,13 @@ void pm_pdb_evt_handler(pm_evt_t * p_pdb_evt) evt_send(&pm_delete_all_evt); } +#if PM_PEER_RANKS_ENABLED == 1 if (m_peer_rank_initialized && (p_pdb_evt->peer_id == m_highest_ranked_peer)) { // Update peer rank variable if highest ranked peer has been deleted. rank_vars_update(); } +#endif break; case PM_EVT_PEER_DELETE_FAILED: @@ -227,21 +255,6 @@ void pm_sm_evt_handler(pm_evt_t * p_sm_evt) { VERIFY_PARAM_NOT_NULL_VOID(p_sm_evt); - switch (p_sm_evt->evt_id) - { - case PM_EVT_CONN_SEC_SUCCEEDED: - { - bool bonded = p_sm_evt->params.conn_sec_succeeded.procedure - == PM_LINK_SECURED_PROCEDURE_BONDING; - ble_conn_state_user_flag_set(p_sm_evt->conn_handle, m_bonded_flag_id, bonded); - break; - } - - default: - /* No action */ - break; - } - // Forward the event to all registered Peer Manager event handlers. evt_send(p_sm_evt); } @@ -259,6 +272,18 @@ void pm_gcm_evt_handler(pm_evt_t * p_gcm_evt) } +/**@brief Event handler for events from the GATTS Cache Manager module. + * This handler is extern in GATTS Cache Manager. + * + * @param[in] p_gscm_evt The incoming GATTS Cache Manager event. + */ +void pm_gscm_evt_handler(pm_evt_t * p_gscm_evt) +{ + // Forward the event to all registered Peer Manager event handlers. + evt_send(p_gscm_evt); +} + + /**@brief Event handler for events from the ID Manager module. * This function is registered in the ID Manager. * @@ -266,16 +291,6 @@ void pm_gcm_evt_handler(pm_evt_t * p_gcm_evt) */ void pm_im_evt_handler(pm_evt_t * p_im_evt) { - switch (p_im_evt->evt_id) - { - case PM_EVT_BONDED_PEER_CONNECTED: - ble_conn_state_user_flag_set(p_im_evt->conn_handle, m_bonded_flag_id, true); - break; - default: - /* No action. */ - break; - } - // Forward the event to all registered Peer Manager event handlers. evt_send(p_im_evt); } @@ -304,7 +319,6 @@ static void internal_state_reset() { m_highest_ranked_peer = PM_PEER_ID_INVALID; m_peer_rank_token = PM_STORE_TOKEN_INVALID; - m_bonded_flag_id = BLE_CONN_STATE_USER_FLAG_INVALID; } @@ -315,56 +329,56 @@ ret_code_t pm_init(void) err_code = pds_init(); if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("%s failed because pds_init() returned %s.", __func__, nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } err_code = pdb_init(); if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("%s failed because pdb_init() returned %s.", __func__, nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } err_code = sm_init(); if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("%s failed because sm_init() returned %s.", __func__, nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } err_code = smd_init(); if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("%s failed because smd_init() returned %s.", __func__, nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } err_code = gcm_init(); if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("%s failed because gcm_init() returned %s.", __func__, nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } err_code = gscm_init(); if (err_code != NRF_SUCCESS) { - return NRF_ERROR_INTERNAL; - } - - err_code = im_init(); - if (err_code != NRF_SUCCESS) - { + NRF_LOG_ERROR("%s failed because gscm_init() returned %s.", __func__, nrf_strerror_get(err_code)); return NRF_ERROR_INTERNAL; } internal_state_reset(); - m_bonded_flag_id = ble_conn_state_user_flag_acquire(); - if (m_bonded_flag_id == BLE_CONN_STATE_USER_FLAG_INVALID) - { - return NRF_ERROR_INTERNAL; - } - m_peer_rank_initialized = false; m_module_initialized = true; + // If PM_PEER_RANKS_ENABLED is 0, these variables are unused. + UNUSED_VARIABLE(m_peer_rank_initialized); + UNUSED_VARIABLE(m_peer_rank_token); + UNUSED_VARIABLE(m_current_highest_peer_rank); + UNUSED_VARIABLE(m_highest_ranked_peer); + return NRF_SUCCESS; } @@ -407,6 +421,11 @@ ret_code_t pm_conn_secure(uint16_t conn_handle, bool force_repairing) err_code = sm_link_secure(conn_handle, force_repairing); + if (err_code == NRF_ERROR_INVALID_STATE) + { + err_code = NRF_ERROR_BUSY; + } + return err_code; } @@ -432,8 +451,11 @@ ret_code_t pm_conn_sec_params_reply(uint16_t conn_handle, void pm_local_database_has_changed(void) { +#if !defined(PM_SERVICE_CHANGED_ENABLED) || (PM_SERVICE_CHANGED_ENABLED == 1) VERIFY_MODULE_INITIALIZED_VOID(); + gcm_local_database_has_changed(); +#endif } @@ -522,20 +544,14 @@ ret_code_t pm_device_identities_list_set(pm_peer_id_t const * p_peers, ret_code_t pm_conn_sec_status_get(uint16_t conn_handle, pm_conn_sec_status_t * p_conn_sec_status) { VERIFY_MODULE_INITIALIZED(); - VERIFY_PARAM_NOT_NULL(p_conn_sec_status); - - ble_conn_state_status_t status = ble_conn_state_status(conn_handle); + return sm_conn_sec_status_get(conn_handle, p_conn_sec_status); +} - if (status == BLE_CONN_STATUS_INVALID) - { - return BLE_ERROR_INVALID_CONN_HANDLE; - } - p_conn_sec_status->connected = (status == BLE_CONN_STATUS_CONNECTED); - p_conn_sec_status->bonded = ble_conn_state_user_flag_get(conn_handle, m_bonded_flag_id); - p_conn_sec_status->encrypted = ble_conn_state_encrypted(conn_handle); - p_conn_sec_status->mitm_protected = ble_conn_state_mitm_protected(conn_handle); - return NRF_SUCCESS; +bool pm_sec_is_sufficient(uint16_t conn_handle, pm_conn_sec_status_t * p_sec_status_req) +{ + VERIFY_MODULE_INITIALIZED_BOOL(); + return sm_sec_is_sufficient(conn_handle, p_sec_status_req); } @@ -570,51 +586,198 @@ uint32_t pm_peer_count(void) { return 0; } - return pdb_n_peers(); + return pds_peer_count_get(); } pm_peer_id_t pm_next_peer_id_get(pm_peer_id_t prev_peer_id) { + pm_peer_id_t next_peer_id = prev_peer_id; + if (!MODULE_INITIALIZED) { return PM_PEER_ID_INVALID; } - return pdb_next_peer_id_get(prev_peer_id); + + do + { + next_peer_id = pds_next_peer_id_get(next_peer_id); + } while (pds_peer_id_is_deleted(next_peer_id)); + + return next_peer_id; +} + + +/**@brief Function for checking if the peer has a valid Identity Resolving Key. + * + * @param[in] p_irk Pointer to the Identity Resolving Key. + */ +static bool peer_is_irk(ble_gap_irk_t const * const p_irk) +{ + for (uint32_t i = 0; i < ARRAY_SIZE(p_irk->irk); i++) + { + if (p_irk->irk[i] != 0) + { + return true; + } + } + + return false; +} + + +ret_code_t pm_peer_id_list(pm_peer_id_t * p_peer_list, + uint32_t * const p_list_size, + pm_peer_id_t first_peer_id, + pm_peer_id_list_skip_t skip_id) +{ + VERIFY_MODULE_INITIALIZED(); + VERIFY_PARAM_NOT_NULL(p_list_size); + VERIFY_PARAM_NOT_NULL(p_peer_list); + + ret_code_t err_code; + uint32_t size = *p_list_size; + uint32_t current_size = 0; + pm_peer_data_t pm_car_data; + pm_peer_data_t pm_bond_data; + pm_peer_id_t current_peer_id = first_peer_id; + ble_gap_addr_t const * p_gap_addr; + bool skip_no_addr = skip_id & PM_PEER_ID_LIST_SKIP_NO_ID_ADDR; + bool skip_no_irk = skip_id & PM_PEER_ID_LIST_SKIP_NO_IRK; + bool skip_no_car = skip_id & PM_PEER_ID_LIST_SKIP_NO_CAR; + + //lint -save -e685 + if ((*p_list_size < 1) || + (skip_id > (PM_PEER_ID_LIST_SKIP_NO_ID_ADDR | PM_PEER_ID_LIST_SKIP_ALL))) + { + return NRF_ERROR_INVALID_PARAM; + } + //lint -restore + + *p_list_size = 0; + + if (current_peer_id == PM_PEER_ID_INVALID) + { + current_peer_id = pm_next_peer_id_get(current_peer_id); + + if (current_peer_id == PM_PEER_ID_INVALID) + { + return NRF_SUCCESS; + } + } + + memset(&pm_car_data, 0, sizeof(pm_peer_data_t)); + memset(&pm_bond_data, 0, sizeof(pm_peer_data_t)); + + while (current_peer_id != PM_PEER_ID_INVALID) + { + bool skip = false; + + if (skip_no_addr || skip_no_irk) + { + // Get data + pm_bond_data.p_bonding_data = NULL; + + err_code = pds_peer_data_read(current_peer_id, + PM_PEER_DATA_ID_BONDING, + &pm_bond_data, + NULL); + + if (err_code == NRF_ERROR_NOT_FOUND) + { + skip = true; + } + else + { + VERIFY_SUCCESS(err_code); + } + + // Check data + if (skip_no_addr) + { + p_gap_addr = &pm_bond_data.p_bonding_data->peer_ble_id.id_addr_info; + + if ((p_gap_addr->addr_type != BLE_GAP_ADDR_TYPE_PUBLIC) && + (p_gap_addr->addr_type != BLE_GAP_ADDR_TYPE_RANDOM_STATIC)) + { + skip = true; + } + } + if (skip_no_irk) + { + if (!peer_is_irk(&pm_bond_data.p_bonding_data->peer_ble_id.id_info)) + { + skip = true; + } + } + } + + if (skip_no_car) + { + // Get data + pm_car_data.p_central_addr_res = NULL; + + err_code = pds_peer_data_read(current_peer_id, + PM_PEER_DATA_ID_CENTRAL_ADDR_RES, + &pm_car_data, + NULL); + + if (err_code == NRF_ERROR_NOT_FOUND) + { + skip = true; + } + else + { + VERIFY_SUCCESS(err_code); + } + + // Check data + if (*pm_car_data.p_central_addr_res == 0) + { + skip = true; + } + } + + if (!skip) + { + p_peer_list[current_size++] = current_peer_id; + + if (current_size >= size) + { + break; + } + } + + current_peer_id = pm_next_peer_id_get(current_peer_id); + } + + *p_list_size = current_size; + + return NRF_SUCCESS; } ret_code_t pm_peer_data_load(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, void * p_data, - uint16_t * p_length) + uint32_t * p_length) { VERIFY_MODULE_INITIALIZED(); VERIFY_PARAM_NOT_NULL(p_data); VERIFY_PARAM_NOT_NULL(p_length); - if (ALIGN_NUM(4, *p_length) != *p_length) - { - return NRF_ERROR_INVALID_PARAM; - } pm_peer_data_t peer_data; memset(&peer_data, 0, sizeof(peer_data)); - peer_data.length_words = BYTES_TO_WORDS(*p_length); - peer_data.data_id = data_id; peer_data.p_all_data = p_data; - ret_code_t err_code = pdb_peer_data_load(peer_id, data_id, &peer_data); - - *p_length = peer_data.length_words * BYTES_PER_WORD; - - return err_code; + return pds_peer_data_read(peer_id, data_id, &peer_data, p_length); } ret_code_t pm_peer_data_bonding_load(pm_peer_id_t peer_id, pm_peer_data_bonding_t * p_data) { - uint16_t length = sizeof(pm_peer_data_bonding_t); + uint32_t length = sizeof(pm_peer_data_bonding_t); return pm_peer_data_load(peer_id, PM_PEER_DATA_ID_BONDING, p_data, @@ -624,7 +787,7 @@ ret_code_t pm_peer_data_bonding_load(pm_peer_id_t peer_id, ret_code_t pm_peer_data_remote_db_load(pm_peer_id_t peer_id, ble_gatt_db_srv_t * p_data, - uint16_t * p_length) + uint32_t * p_length) { return pm_peer_data_load(peer_id, PM_PEER_DATA_ID_GATT_REMOTE, @@ -635,7 +798,7 @@ ret_code_t pm_peer_data_remote_db_load(pm_peer_id_t peer_id, ret_code_t pm_peer_data_app_data_load(pm_peer_id_t peer_id, void * p_data, - uint16_t * p_length) + uint32_t * p_length) { return pm_peer_data_load(peer_id, PM_PEER_DATA_ID_APPLICATION, @@ -647,7 +810,7 @@ ret_code_t pm_peer_data_app_data_load(pm_peer_id_t peer_id, ret_code_t pm_peer_data_store(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, void const * p_data, - uint16_t length, + uint32_t length, pm_store_token_t * p_token) { VERIFY_MODULE_INITIALIZED(); @@ -657,13 +820,24 @@ ret_code_t pm_peer_data_store(pm_peer_id_t peer_id, return NRF_ERROR_INVALID_PARAM; } + if (data_id == PM_PEER_DATA_ID_BONDING) + { + pm_peer_id_t dupl_peer_id; + dupl_peer_id = im_find_duplicate_bonding_data((pm_peer_data_bonding_t *) p_data, peer_id); + + if (dupl_peer_id != PM_PEER_ID_INVALID) + { + return NRF_ERROR_FORBIDDEN; + } + } + pm_peer_data_flash_t peer_data; memset(&peer_data, 0, sizeof(peer_data)); peer_data.length_words = BYTES_TO_WORDS(length); peer_data.data_id = data_id; peer_data.p_all_data = p_data; - return pdb_raw_store(peer_id, &peer_data, p_token); + return pds_peer_data_store(peer_id, &peer_data, p_token); } @@ -681,7 +855,7 @@ ret_code_t pm_peer_data_bonding_store(pm_peer_id_t peer_id, ret_code_t pm_peer_data_remote_db_store(pm_peer_id_t peer_id, ble_gatt_db_srv_t const * p_data, - uint16_t length, + uint32_t length, pm_store_token_t * p_token) { return pm_peer_data_store(peer_id, @@ -694,7 +868,7 @@ ret_code_t pm_peer_data_remote_db_store(pm_peer_id_t peer_id, ret_code_t pm_peer_data_app_data_store(pm_peer_id_t peer_id, void const * p_data, - uint16_t length, + uint32_t length, pm_store_token_t * p_token) { return pm_peer_data_store(peer_id, @@ -714,7 +888,7 @@ ret_code_t pm_peer_data_delete(pm_peer_id_t peer_id, pm_peer_data_id_t data_id) return NRF_ERROR_INVALID_PARAM; } - return pdb_clear(peer_id, data_id); + return pds_peer_data_delete(peer_id, data_id); } @@ -735,7 +909,7 @@ ret_code_t pm_peer_new(pm_peer_id_t * p_new_peer_id, // Search through existing bonds to look for a duplicate. pds_peer_data_iterate_prepare(); - // @note emdi: should maybe use a critical section, since data is not copied while iterating. + // @note This check is not thread safe since data is not copied while iterating. while (pds_peer_data_iterate(PM_PEER_DATA_ID_BONDING, &peer_id, &peer_data)) { if (im_is_duplicate_bonding_data(p_bonding_data, peer_data.p_bonding_data)) @@ -747,7 +921,7 @@ ret_code_t pm_peer_new(pm_peer_id_t * p_new_peer_id, // If no duplicate data is found, prepare to write a new bond to flash. - *p_new_peer_id = pdb_peer_allocate(); + *p_new_peer_id = pds_peer_id_allocate(); if (*p_new_peer_id == PM_PEER_ID_INVALID) { @@ -760,12 +934,18 @@ ret_code_t pm_peer_new(pm_peer_id_t * p_new_peer_id, peer_data.p_bonding_data = p_bonding_data; peer_data.length_words = BYTES_TO_WORDS(sizeof(pm_peer_data_bonding_t)); - err_code = pdb_raw_store(*p_new_peer_id, &peer_data, p_token); + err_code = pds_peer_data_store(*p_new_peer_id, &peer_data, p_token); if (err_code != NRF_SUCCESS) { - if (im_peer_free(*p_new_peer_id) != NRF_SUCCESS) + ret_code_t err_code_free = im_peer_free(*p_new_peer_id); + if (err_code_free != NRF_SUCCESS) { + NRF_LOG_ERROR("Fatal error during cleanup of a failed call to %s. im_peer_free() "\ + "returned %s. peer_id: %d", + __func__, + nrf_strerror_get(err_code_free), + *p_new_peer_id); return NRF_ERROR_INTERNAL; } @@ -793,7 +973,7 @@ ret_code_t pm_peers_delete(void) m_deleting_all = true; - pm_peer_id_t current_peer_id = pdb_next_peer_id_get(PM_PEER_ID_INVALID); + pm_peer_id_t current_peer_id = pds_next_peer_id_get(PM_PEER_ID_INVALID); if (current_peer_id == PM_PEER_ID_INVALID) { @@ -814,10 +994,14 @@ ret_code_t pm_peers_delete(void) ret_code_t err_code = pm_peer_delete(current_peer_id); if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("%s() failed because a call to pm_peer_delete() returned %s. peer_id: %d", + __func__, + nrf_strerror_get(err_code), + current_peer_id); return NRF_ERROR_INTERNAL; } - current_peer_id = pdb_next_peer_id_get(current_peer_id); + current_peer_id = pds_next_peer_id_get(current_peer_id); } return NRF_SUCCESS; @@ -829,15 +1013,21 @@ ret_code_t pm_peer_ranks_get(pm_peer_id_t * p_highest_ranked_peer, pm_peer_id_t * p_lowest_ranked_peer, uint32_t * p_lowest_rank) { +#if PM_PEER_RANKS_ENABLED == 0 + return NRF_ERROR_NOT_SUPPORTED; +#else VERIFY_MODULE_INITIALIZED(); - pm_peer_id_t peer_id = pdb_next_peer_id_get(PM_PEER_ID_INVALID); + pm_peer_id_t peer_id = pds_next_peer_id_get(PM_PEER_ID_INVALID); uint32_t peer_rank = 0; //lint -save -e65 -e64 - pm_peer_data_t peer_data = {.length_words = BYTES_TO_WORDS(sizeof(peer_rank)), - .p_peer_rank = &peer_rank}; + uint32_t length = sizeof(peer_rank); + pm_peer_data_t peer_data = {.p_peer_rank = &peer_rank}; //lint -restore - ret_code_t err_code = pdb_peer_data_load(peer_id, PM_PEER_DATA_ID_PEER_RANK, &peer_data); + ret_code_t err_code = pds_peer_data_read(peer_id, + PM_PEER_DATA_ID_PEER_RANK, + &peer_data, + &length); uint32_t highest_rank = 0; uint32_t lowest_rank = 0xFFFFFFFF; pm_peer_id_t highest_ranked_peer = PM_PEER_ID_INVALID; @@ -851,26 +1041,33 @@ ret_code_t pm_peer_ranks_get(pm_peer_id_t * p_highest_ranked_peer, while ((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_NOT_FOUND)) { - if (err_code == NRF_ERROR_NOT_FOUND) + if (err_code == NRF_SUCCESS) { - peer_rank = 0; + if (peer_rank >= highest_rank) + { + highest_rank = peer_rank; + highest_ranked_peer = peer_id; + } + if (peer_rank < lowest_rank) + { + lowest_rank = peer_rank; + lowest_ranked_peer = peer_id; + } } - if (peer_rank >= highest_rank) + peer_id = pds_next_peer_id_get(peer_id); + err_code = pds_peer_data_read(peer_id, PM_PEER_DATA_ID_PEER_RANK, &peer_data, &length); + } + if (peer_id == PM_PEER_ID_INVALID) + { + if ((highest_ranked_peer == PM_PEER_ID_INVALID) || (lowest_ranked_peer == PM_PEER_ID_INVALID)) { - highest_rank = peer_rank; - highest_ranked_peer = peer_id; + err_code = NRF_ERROR_NOT_FOUND; } - if (peer_rank < lowest_rank) + else { - lowest_rank = peer_rank; - lowest_ranked_peer = peer_id; + err_code = NRF_SUCCESS; } - peer_id = pdb_next_peer_id_get(peer_id); - err_code = pdb_peer_data_load(peer_id, PM_PEER_DATA_ID_PEER_RANK, &peer_data); - } - if (peer_id == PM_PEER_ID_INVALID) - { - err_code = NRF_SUCCESS; + if (p_highest_ranked_peer != NULL) { *p_highest_ranked_peer = highest_ranked_peer; @@ -890,22 +1087,31 @@ ret_code_t pm_peer_ranks_get(pm_peer_id_t * p_highest_ranked_peer, } else { + NRF_LOG_ERROR("Could not retreive ranks. pdb_peer_data_load() returned %s. peer_id: %d", + nrf_strerror_get(err_code), + peer_id); err_code = NRF_ERROR_INTERNAL; } return err_code; +#endif } +#if PM_PEER_RANKS_ENABLED == 1 /**@brief Function for initializing peer rank functionality. */ static void rank_init(void) { rank_vars_update(); } +#endif ret_code_t pm_peer_rank_highest(pm_peer_id_t peer_id) { +#if PM_PEER_RANKS_ENABLED == 0 + return NRF_ERROR_NOT_SUPPORTED; +#else VERIFY_MODULE_INITIALIZED(); ret_code_t err_code; @@ -947,19 +1153,33 @@ ret_code_t pm_peer_rank_highest(pm_peer_id_t peer_id) } else { - m_current_highest_peer_rank += 1; - err_code = pdb_raw_store(peer_id, &peer_data, &m_peer_rank_token); - if (err_code != NRF_SUCCESS) + if (m_current_highest_peer_rank == UINT32_MAX) { - m_peer_rank_token = PM_STORE_TOKEN_INVALID; - m_current_highest_peer_rank -= 1; + err_code = NRF_ERROR_RESOURCES; + } + else + { + m_current_highest_peer_rank += 1; + err_code = pds_peer_data_store(peer_id, &peer_data, &m_peer_rank_token); + if (err_code != NRF_SUCCESS) { - if ((err_code != NRF_ERROR_BUSY) && (err_code != NRF_ERROR_STORAGE_FULL)) - err_code = NRF_ERROR_INTERNAL; + m_peer_rank_token = PM_STORE_TOKEN_INVALID; + m_current_highest_peer_rank -= 1; + if ((err_code != NRF_ERROR_BUSY) && + (err_code != NRF_ERROR_STORAGE_FULL) && + (err_code != NRF_ERROR_INVALID_PARAM)) // Assume INVALID_PARAM refers to peer_id, not data_id. + { + NRF_LOG_ERROR("Could not update rank. pdb_raw_store() returned %s. "\ + "peer_id: %d", + nrf_strerror_get(err_code), + peer_id); + err_code = NRF_ERROR_INTERNAL; + } } } } } return err_code; +#endif } #endif // NRF_MODULE_ENABLED(PEER_MANAGER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager.h similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager.h index 3913ab5..63eacda 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 peer_manager.h @@ -72,17 +72,17 @@ extern "C" { #endif - -/**@brief Security status of a connection. +/**@brief Peer list filtrations. They determine which peer ID will be added to list. */ -typedef struct +typedef enum { - uint8_t connected : 1; /**< @brief The connection is active (not disconnected). */ - uint8_t encrypted : 1; /**< @brief Communication on this link is encrypted. */ - uint8_t mitm_protected : 1; /**< @brief The encrypted communication is also protected against man-in-the-middle attacks. */ - uint8_t bonded : 1; /**< @brief The peer is bonded with us. */ -} pm_conn_sec_status_t; - + PM_PEER_ID_LIST_ALL_ID, /**< Add all peers. */ + PM_PEER_ID_LIST_SKIP_NO_ID_ADDR = BIT_0, /**< Add only peers with an ID address (static address). */ + PM_PEER_ID_LIST_SKIP_NO_IRK = BIT_1, /**< Add only peers with a valid IRK. This implies @ref PM_PEER_ID_LIST_SKIP_NO_ID_ADDR, since all peers with IRKs have ID addresses. */ + PM_PEER_ID_LIST_SKIP_NO_CAR = BIT_2, /**< Add only peers with Central Address Resolution characteristic set to 0. */ + PM_PEER_ID_LIST_SKIP_ALL = PM_PEER_ID_LIST_SKIP_NO_IRK | /**< All above filters applied. */ + PM_PEER_ID_LIST_SKIP_NO_CAR +} pm_peer_id_list_skip_t; /**@brief Function for initializing the Peer Manager. * @@ -145,8 +145,8 @@ ret_code_t pm_sec_params_set(ble_gap_sec_params_t * p_sec_params); * * If the connection is a slave connection, the function sends a security request to * the peer (master). It is up to the peer then to initiate pairing or encryption. - * If the peer ignores the request, a @ref BLE_GAP_EVT_TIMEOUT event occurs - * with the source @ref BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST. Otherwise, the peer initiates + * If the peer ignores the request, a @ref BLE_GAP_EVT_AUTH_STATUS event occurs + * with the status @ref BLE_GAP_SEC_STATUS_TIMEOUT. Otherwise, the peer initiates * security, in which case things happen as if the peer had initiated security itself. * See @ref PM_EVT_CONN_SEC_START for information about peer-initiated security. * @@ -156,16 +156,16 @@ ret_code_t pm_sec_params_set(ble_gap_sec_params_t * p_sec_params); * the central role. Recommended value: false. * * @retval NRF_SUCCESS If the operation completed successfully. + * @retval NRF_ERROR_BUSY If a security procedure is already in progress on the link, + * or if the link is disconnecting or disconnected. * @retval NRF_ERROR_TIMEOUT If there was an SMP time-out, so that no more security * operations can be performed on this link. * @retval BLE_ERROR_INVALID_CONN_HANDLE If the connection handle is invalid. * @retval NRF_ERROR_NOT_FOUND If the security parameters have not been set, either by * @ref pm_sec_params_set or by @ref pm_conn_sec_params_reply. - * @retval NRF_ERROR_STORAGE_FULL If there is no more space in persistent storage. - * @retval NRF_ERROR_NO_MEM If no more authentication procedures can run in parallel - * for the given role. See @ref sd_ble_gap_authenticate. - * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized, or the peer is - * disconnected or in the process of disconnecting. + * @retval NRF_ERROR_INVALID_DATA If the peer is bonded, but no LTK was found in the stored + * bonding data. Repairing was not requested. + * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. * @retval NRF_ERROR_INTERNAL If an internal error occurred. */ ret_code_t pm_conn_secure(uint16_t conn_handle, bool force_repairing); @@ -188,8 +188,7 @@ void pm_conn_sec_config_reply(uint16_t conn_handle, pm_conn_sec_config_t * p_con * * @details This function is optional, and must be called in reply to a @ref * PM_EVT_CONN_SEC_PARAMS_REQ event, before the Peer Manager event handler returns. If it - * is not called in time, the parameters given in @ref pm_sec_params_set are used. See @ref - * pm_conn_sec_config_t for the value of the default. + * is not called in time, the parameters given in @ref pm_sec_params_set are used. * * @param[in] conn_handle The connection to set the parameters for. * @param[in] p_sec_params The parameters. If NULL, the security procedure is rejected. @@ -214,8 +213,9 @@ ret_code_t pm_conn_sec_params_reply(uint16_t conn_handle, * PM_EVT_SERVICE_CHANGED_IND_CONFIRMED when the peer sends its confirmation. Peers that * are not subscribed to the service changed indication when this function is called do not * receive an indication, and no events are sent to the user. Likewise, if the service - * changed characteristic is not present in the local database, this no indications are - * sent peers, and no events are sent to the user. + * changed characteristic is not present in the local database, or if the @ref + * PM_SERVICE_CHANGED_ENABLED is set to 0, no indications are sent peers, and no events are + * sent to the user. */ void pm_local_database_has_changed(void); @@ -233,6 +233,19 @@ void pm_local_database_has_changed(void); ret_code_t pm_conn_sec_status_get(uint16_t conn_handle, pm_conn_sec_status_t * p_conn_sec_status); +/**@brief Function for comparing the security status of a connection against a baseline. + * + * @param[in] conn_handle Connection handle of the link as provided by the SoftDevice. + * @param[out] p_sec_status_req Target baseline security status to compare against. + * + * @retval true If the security status of the connection matches or exceeds the baseline on all + * points. + * @retval false If the security status of the connection does not fulfil the baseline, or could + * not be retrieved. + */ +bool pm_sec_is_sufficient(uint16_t conn_handle, pm_conn_sec_status_t * p_sec_status_req); + + /**@brief Experimental function for specifying the public key to use for LESC operations. * * @details This function can be called multiple times. The specified public key will be used for @@ -241,10 +254,14 @@ ret_code_t pm_conn_sec_status_get(uint16_t conn_handle, pm_conn_sec_status_t * p * * @note The key must continue to reside in application memory as it is not copied by Peer Manager. * + * @note This function is deprecated. LESC keys are now handled internally if @ref PM_LESC_ENABLED + * is true. If @ref PM_LESC_ENABLED is false, this function works as before. + * * @param[in] p_public_key The public key to use for all subsequent LESC operations. * * @retval NRF_SUCCESS If pairing was initiated successfully. * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. + * @retval NRF_ERROR_FORBIDDEN If LESC module support is enabled (see @ref PM_LESC_ENABLED). */ ret_code_t pm_lesc_public_key_set(ble_gap_lesc_p256_pk_t * p_public_key); @@ -313,6 +330,10 @@ ret_code_t pm_whitelist_get(ble_gap_addr_t * p_addrs, /**@brief Function for setting and clearing the device identities list. + * + * @note When entering directed advertising, make sure the active identities list does not contain + * peers that have no Central Address Resolution. See @ref pm_peer_id_list with skip_id + * @ref PM_PEER_ID_LIST_SKIP_NO_CAR. * * @param[in] p_peers The peers to add to the device identities list. Pass NULL to clear * the device identities list. @@ -348,6 +369,8 @@ ret_code_t pm_device_identities_list_set(pm_peer_id_t const * p_peers, * The identity address is distributed to the peer during bonding. Changing the identity address * means bonded devices might not recognize us. * + * @note The SoftDevice functions @ref sd_ble_gap_addr_set and @ref sd_ble_gap_privacy_set must not + * be called when using the Peer Manager. Use the Peer Manager equivalents instead. * * @param[in] p_addr The GAP address to be set. * @@ -453,6 +476,34 @@ ret_code_t pm_conn_handle_get(pm_peer_id_t peer_id, uint16_t * p_conn_handle); ret_code_t pm_peer_id_get(uint16_t conn_handle, pm_peer_id_t * p_peer_id); +/**@brief Function for retrieving a filtered list of peer IDs. + * + * @details This function starts searching from @p first_peer_id. IDs ordering + * is the same as for @ref pm_next_peer_id_get(). If the first_peer_id + * is @ref PM_PEER_ID_INVALID, the function starts searching from the first ID. + * The function looks for the ID's number specified by @p p_list_size. Only those IDs that + * match @p skip_id are added to the list. The number of returned elements is determined + * by @p p_list_size. + * + * @warning The size of the @p p_peer_list buffer must be equal or greater than @p p_list_size. + * + * @param[out] p_peer_list Pointer to peer IDs list buffer. + * @param[in,out] p_list_size The amount of IDs to return / The number of returned IDs. + * @param[in] first_peer_id The first ID from which the search begins. IDs ordering + * is the same as for @ref pm_next_peer_id_get() + * @param[in] skip_id It determines which peer ID will be added to list. + * + * @retval NRF_SUCCESS If the ID list has been filled out. + * @retval NRF_ERROR_INVALID_PARAM If @p skip_id was invalid. + * @retval NRF_ERROR_NULL If peer_list or list_size was NULL. + * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. + */ +ret_code_t pm_peer_id_list(pm_peer_id_t * p_peer_list, + uint32_t * const p_list_size, + pm_peer_id_t first_peer_id, + pm_peer_id_list_skip_t skip_id); + + /**@brief Function for getting the next peer ID in the sequence of all used peer IDs. * * @details This function can be used to loop through all used peer IDs. The order in which @@ -469,6 +520,8 @@ ret_code_t pm_peer_id_get(uint16_t conn_handle, pm_peer_id_t * p_peer_id); * } * @endcode * + * @note This function does not report peer IDs that are pending deletion. + * * @param[in] prev_peer_id The previous peer ID. * * @return The next peer ID. If @p prev_peer_id was @ref PM_PEER_ID_INVALID, the @@ -507,21 +560,24 @@ uint32_t pm_peer_count(void); * @param[in] data_id Which type of data to read. * @param[out] p_data Where to put the retrieved data. The documentation for * @ref pm_peer_data_id_t specifies what data type each data ID is stored as. - * @param[inout] p_len In: The length in bytes of @p p_data. + * @param[in,out] p_len In: The length in bytes of @p p_data. * Out: The length in bytes of the read data, if the read was successful. * * @retval NRF_SUCCESS If the data was read successfully. - * @retval NRF_ERROR_INVALID_PARAM If the the data type or the peer ID was invalid or unallocated, - * or if the length in @p p_length was not a multiple of 4. + * @retval NRF_ERROR_INVALID_PARAM If the data type or the peer ID was invalid or unallocated. * @retval NRF_ERROR_NULL If a pointer parameter was NULL. * @retval NRF_ERROR_NOT_FOUND If no stored data was found for this peer ID/data ID combination. - * @retval NRF_ERROR_DATA_SIZE If the provided buffer was not large enough. + * @retval NRF_ERROR_DATA_SIZE If the provided buffer was not large enough. The data is still + * copied, filling the provided buffer. Note that this error can + * occur even if loading the same size as was stored, because the + * underlying layers round the length up to the nearest word (4 bytes) + * when storing. * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. */ ret_code_t pm_peer_data_load(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, void * p_data, - uint16_t * p_len); + uint32_t * p_len); /**@brief Function for reading a peer's bonding data (@ref PM_PEER_DATA_ID_BONDING). * @details See @ref pm_peer_data_load for parameters and return values. */ @@ -532,13 +588,13 @@ ret_code_t pm_peer_data_bonding_load(pm_peer_id_t peer_id, * @details See @ref pm_peer_data_load for parameters and return values. */ ret_code_t pm_peer_data_remote_db_load(pm_peer_id_t peer_id, ble_gatt_db_srv_t * p_data, - uint16_t * p_len); + uint32_t * p_len); /**@brief Function for reading a peer's application data. (@ref PM_PEER_DATA_ID_APPLICATION). * @details See @ref pm_peer_data_load for parameters and return values. */ ret_code_t pm_peer_data_app_data_load(pm_peer_id_t peer_id, void * p_data, - uint16_t * p_len); + uint32_t * p_len); /** @}*/ @@ -554,6 +610,8 @@ ret_code_t pm_peer_data_app_data_load(pm_peer_id_t peer_id, * @note The data written using this function might later be overwritten as a result of internal * operations in the Peer Manager. A Peer Manager event is sent each time data is updated, * regardless of whether the operation originated internally or from action by the user. + * Data with @p data_id @ref PM_PEER_DATA_ID_GATT_REMOTE @ref PM_PEER_DATA_ID_APPLICATION is + * never (over)written internally. * * @param[in] peer_id Peer ID to set data for. * @param[in] data_id Which type of data to set. @@ -569,12 +627,16 @@ ret_code_t pm_peer_data_app_data_load(pm_peer_id_t peer_id, * @retval NRF_ERROR_NOT_FOUND If no peer was found for the peer ID. * @retval NRF_ERROR_BUSY If the underlying flash handler is busy with other flash * operations. Try again after receiving a Peer Manager event. + * @retval NRF_ERROR_STORAGE_FULL If there is not enough space in persistent storage. + * @retval NRF_ERROR_FORBIDDEN If data ID is @ref PM_PEER_DATA_ID_BONDING and the new bonding + * data also corresponds to another bonded peer. No data is written + * so duplicate entries are avoided. * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. */ ret_code_t pm_peer_data_store(pm_peer_id_t peer_id, pm_peer_data_id_t data_id, void const * p_data, - uint16_t len, + uint32_t len, pm_store_token_t * p_token); /**@brief Function for setting or updating a peer's bonding data (@ref PM_PEER_DATA_ID_BONDING). @@ -587,14 +649,14 @@ ret_code_t pm_peer_data_bonding_store(pm_peer_id_t peer_id, * @details See @ref pm_peer_data_store for parameters and return values. */ ret_code_t pm_peer_data_remote_db_store(pm_peer_id_t peer_id, ble_gatt_db_srv_t const * p_data, - uint16_t len, + uint32_t len, pm_store_token_t * p_token); /**@brief Function for setting or updating a peer's application data. (@ref PM_PEER_DATA_ID_APPLICATION). * @details See @ref pm_peer_data_store for parameters and return values. */ ret_code_t pm_peer_data_app_data_store(pm_peer_id_t peer_id, void const * p_data, - uint16_t len, + uint32_t len, pm_store_token_t * p_token); /** @}*/ @@ -641,7 +703,7 @@ ret_code_t pm_peer_data_delete(pm_peer_id_t peer_id, pm_peer_data_id_t data_id); * * @retval NRF_SUCCESS If the store operation for bonding data was initiated successfully. * @retval NRF_ERROR_NULL If @p p_bonding_data or @p p_new_peer_id is NULL. - * @retval NRF_ERROR_STORAGE_FULL If there is no more space in persistent storage. + * @retval NRF_ERROR_STORAGE_FULL If there is not enough space in persistent storage. * @retval NRF_ERROR_NO_MEM If there are no more available peer IDs. * @retval NRF_ERROR_BUSY If the underlying flash filesystem is busy with other flash * operations. Try again after receiving a Peer Manager event. @@ -706,6 +768,7 @@ ret_code_t pm_peers_delete(void); * calling @ref pm_peer_rank_highest or by manipulating the value using a @ref * PM_PEER_DATA_FUNCTIONS function. * + * @note Peers with no stored rank are not considered. * @note Any argument that is NULL is ignored. * * @param[out] p_highest_ranked_peer The peer ID with the highest rank of all peers, for example, @@ -716,9 +779,11 @@ ret_code_t pm_peers_delete(void); * @param[out] p_lowest_rank The lowest rank. * * @retval NRF_SUCCESS If the operation completed successfully. - * @retval NRF_ERROR_NOT_FOUND If no peers were found. + * @retval NRF_ERROR_NOT_FOUND If no peer with stored peer rank was found. * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. * @retval NRF_ERROR_INTERNAL If an internal error occurred. + * @retval NRF_ERROR_NOT_SUPPORTED If peer rank functionality has been disabled via the @ref + * PM_PEER_RANKS_ENABLED configuration option. */ ret_code_t pm_peer_ranks_get(pm_peer_id_t * p_highest_ranked_peer, uint32_t * p_highest_rank, @@ -743,11 +808,18 @@ ret_code_t pm_peer_ranks_get(pm_peer_id_t * p_highest_ranked_peer, * @param[in] peer_id The peer to rank highest. * * @retval NRF_SUCCESS If the peer's rank is, or will be updated to be highest. + * @retval NRF_ERROR_INVALID_PARAM If @p peer_id is invalid, or doesn't exist in flash. + * @retval NRF_ERROR_STORAGE_FULL If there is not enough space in persistent storage. * @retval NRF_ERROR_BUSY If the underlying flash handler is busy with other flash * operations, or if a previous call to this function has not * completed. Try again after receiving a Peer Manager event. * @retval NRF_ERROR_INVALID_STATE If the Peer Manager is not initialized. + * @retval NRF_ERROR_RESOURCES If the highest rank is UINT32_MAX, so the new rank would wrap + * around to 0. To fix this, manually update all ranks to smaller + * values, while still keeping their order. * @retval NRF_ERROR_INTERNAL If an internal error occurred. + * @retval NRF_ERROR_NOT_SUPPORTED If peer rank functionality has been disabled via the @ref + * PM_PEER_RANKS_ENABLED configuration option. */ ret_code_t pm_peer_rank_highest(pm_peer_id_t peer_id); diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.c new file mode 100644 index 0000000..3d8afc8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.c @@ -0,0 +1,686 @@ +/** + * Copyright (c) 2018 - 2019, 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 "peer_manager_handler.h" +#include +#include +#include "sdk_errors.h" +#include "app_error.h" +#include "peer_manager.h" +#include "ble_gap.h" +#include "ble_gattc.h" +#include "ble_conn_state.h" +#include "fds.h" +#include "nrf_strerror.h" +#include "sdk_config.h" + +#if PM_HANDLER_SEC_DELAY_MS > 0 +#include "app_timer.h" +#endif + +#define NRF_LOG_MODULE_NAME peer_manager_handler +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" + +static const char * m_roles_str[] = +{ + "Invalid Role", + "Peripheral", + "Central", +}; + +static const char * m_sec_procedure_str[] = +{ + "Encryption", + "Bonding", + "Pairing", +}; + +#define PM_EVT_STR(_name) [_name] = STRINGIFY(_name) + +static const char * m_event_str[] = +{ + PM_EVT_STR(PM_EVT_BONDED_PEER_CONNECTED), + PM_EVT_STR(PM_EVT_CONN_SEC_START), + PM_EVT_STR(PM_EVT_CONN_SEC_SUCCEEDED), + PM_EVT_STR(PM_EVT_CONN_SEC_FAILED), + PM_EVT_STR(PM_EVT_CONN_SEC_CONFIG_REQ), + PM_EVT_STR(PM_EVT_CONN_SEC_PARAMS_REQ), + PM_EVT_STR(PM_EVT_STORAGE_FULL), + PM_EVT_STR(PM_EVT_ERROR_UNEXPECTED), + PM_EVT_STR(PM_EVT_PEER_DATA_UPDATE_SUCCEEDED), + PM_EVT_STR(PM_EVT_PEER_DATA_UPDATE_FAILED), + PM_EVT_STR(PM_EVT_PEER_DELETE_SUCCEEDED), + PM_EVT_STR(PM_EVT_PEER_DELETE_FAILED), + PM_EVT_STR(PM_EVT_PEERS_DELETE_SUCCEEDED), + PM_EVT_STR(PM_EVT_PEERS_DELETE_FAILED), + PM_EVT_STR(PM_EVT_LOCAL_DB_CACHE_APPLIED), + PM_EVT_STR(PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED), + PM_EVT_STR(PM_EVT_SERVICE_CHANGED_IND_SENT), + PM_EVT_STR(PM_EVT_SERVICE_CHANGED_IND_CONFIRMED), + PM_EVT_STR(PM_EVT_SLAVE_SECURITY_REQ), + PM_EVT_STR(PM_EVT_FLASH_GARBAGE_COLLECTED), + PM_EVT_STR(PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED), +}; + +static const char * m_data_id_str[] = +{ + "Outdated (0)", + "Service changed pending flag", + "Outdated (2)", + "Outdated (3)", + "Application data", + "Remote database", + "Peer rank", + "Bonding data", + "Local database", + "Central address resolution", +}; + +static const char * m_data_action_str[] = +{ + "Update", + "Delete" +}; + +#define PM_SEC_ERR_STR(_name) {.error = _name, .error_str = #_name} + +typedef struct +{ + pm_sec_error_code_t error; + const char * error_str; +} sec_err_str_t; + +static const sec_err_str_t m_pm_sec_error_str[] = +{ + PM_SEC_ERR_STR(PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING), + PM_SEC_ERR_STR(PM_CONN_SEC_ERROR_MIC_FAILURE), + PM_SEC_ERR_STR(PM_CONN_SEC_ERROR_DISCONNECT), + PM_SEC_ERR_STR(PM_CONN_SEC_ERROR_SMP_TIMEOUT), +}; + +static const char * sec_err_string_get(pm_sec_error_code_t error) +{ + static char errstr[30]; + + for (uint32_t i = 0; i < (sizeof(m_pm_sec_error_str)/sizeof(sec_err_str_t)); i++) + { + if (m_pm_sec_error_str[i].error == error) + { + return m_pm_sec_error_str[i].error_str; + } + } + + int len = snprintf(errstr, sizeof(errstr), "%s 0x%hx", (error < PM_CONN_SEC_ERROR_BASE) + ? "BLE_GAP_SEC_STATUS" + :"PM_CONN_SEC_ERROR", error); + UNUSED_VARIABLE(len); + return errstr; +} + + +static void _conn_secure(uint16_t conn_handle, bool force) +{ + ret_code_t err_code; + + if (!force) + { + pm_conn_sec_status_t status; + err_code = pm_conn_sec_status_get(conn_handle, &status); + if (err_code != BLE_ERROR_INVALID_CONN_HANDLE) + { + APP_ERROR_CHECK(err_code); + } + + // If the link is already secured, don't initiate security procedure. + if (status.encrypted) + { + NRF_LOG_DEBUG("Already encrypted, skipping security."); + return; + } + } + + err_code = pm_conn_secure(conn_handle, false); + + if ((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_BUSY)) + { + // Success. + } + else if (err_code == NRF_ERROR_TIMEOUT) + { + NRF_LOG_WARNING("pm_conn_secure() failed because an SMP timeout is preventing security on "\ + "the link. Disconnecting conn_handle %d.", + conn_handle); + + err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("sd_ble_gap_disconnect() returned %s on conn_handle %d.", + nrf_strerror_get(err_code), + conn_handle); + } + } + else if (err_code == NRF_ERROR_INVALID_DATA) + { + NRF_LOG_WARNING("pm_conn_secure() failed because the stored data for conn_handle %d does "\ + "not have a valid key.", + conn_handle); + } + else if (err_code == BLE_ERROR_INVALID_CONN_HANDLE) + { + NRF_LOG_WARNING("pm_conn_secure() failed because conn_handle %d is not a valid connection.", + conn_handle); + } + else + { + NRF_LOG_ERROR("Asserting. pm_conn_secure() returned %s on conn_handle %d.", + nrf_strerror_get(err_code), + conn_handle); + APP_ERROR_CHECK(err_code); + } +} + +#if PM_HANDLER_SEC_DELAY_MS > 0 +APP_TIMER_DEF(secure_delay_timer); + +typedef union +{ + struct + { + uint16_t conn_handle; + bool force; + } values; + void * p_void; +} conn_secure_context_t; + +STATIC_ASSERT(sizeof(conn_secure_context_t) <= sizeof(void *), "conn_secure_context_t is too large."); + +static void _conn_secure(uint16_t conn_handle, bool force); + +static void delayed_conn_secure(void * context) +{ + conn_secure_context_t sec_context = {.p_void = context}; + _conn_secure(sec_context.values.conn_handle, sec_context.values.force); +} + +static void conn_secure(uint16_t conn_handle, bool force) +{ + ret_code_t err_code; + static bool created = false; + if (!created) + { + err_code = app_timer_create(&secure_delay_timer, + APP_TIMER_MODE_SINGLE_SHOT, + delayed_conn_secure); + APP_ERROR_CHECK(err_code); + created = true; + } + + conn_secure_context_t sec_context = {0}; + sec_context.values.conn_handle = conn_handle; + sec_context.values.force = force; + + err_code = app_timer_start(secure_delay_timer, + APP_TIMER_TICKS(PM_HANDLER_SEC_DELAY_MS), + sec_context.p_void); + APP_ERROR_CHECK(err_code); +} + + +#else +static void conn_secure(uint16_t conn_handle, bool force) +{ + _conn_secure(conn_handle, force); +} +#endif + + +void pm_handler_on_pm_evt(pm_evt_t const * p_pm_evt) +{ + pm_handler_pm_evt_log(p_pm_evt); + + if (p_pm_evt->evt_id == PM_EVT_BONDED_PEER_CONNECTED) + { + conn_secure(p_pm_evt->conn_handle, false); + } + else if (p_pm_evt->evt_id == PM_EVT_ERROR_UNEXPECTED) + { + NRF_LOG_ERROR("Asserting."); + APP_ERROR_CHECK(p_pm_evt->params.error_unexpected.error); + } +} + + +void pm_handler_flash_clean_on_return(void) +{ + // Trigger the mechanism to make more room in flash. + pm_evt_t storage_full_evt = {.evt_id = PM_EVT_STORAGE_FULL}; + pm_handler_flash_clean(&storage_full_evt); +} + + +static void rank_highest(pm_peer_id_t peer_id) +{ + // Trigger a pm_peer_rank_highest() with internal bookkeeping. + pm_evt_t connected_evt = {.evt_id = PM_EVT_BONDED_PEER_CONNECTED, .peer_id = peer_id}; + pm_handler_flash_clean(&connected_evt); +} + + +void pm_handler_flash_clean(pm_evt_t const * p_pm_evt) +{ + ret_code_t err_code; + static bool flash_cleaning = false; // Indicates whether garbage collection is currently being run. + static bool flash_write_after_gc = true; // Indicates whether a successful write happened after the last garbage + // collection. If this is false when flash is full, it means just a + // garbage collection won't work, so some data should be deleted. + #define RANK_QUEUE_SIZE 8 // Size of rank_queue. + #define RANK_QUEUE_INIT() PM_PEER_ID_INVALID, // Initial value of rank_queue. + + //lint -save -e40 -e26 -esym(628,MACRO_REPEAT_8) + static pm_peer_id_t rank_queue[8] = {MACRO_REPEAT(RANK_QUEUE_SIZE, RANK_QUEUE_INIT)}; // Queue of rank_highest calls that + // failed because of full flash. + //lint -restore + static int rank_queue_wr = 0; // Write pointer for rank_queue. + + switch (p_pm_evt->evt_id) + { + case PM_EVT_BONDED_PEER_CONNECTED: + err_code = pm_peer_rank_highest(p_pm_evt->peer_id); + if ((err_code == NRF_ERROR_STORAGE_FULL) || + (err_code == NRF_ERROR_BUSY)) + { + // Queue pm_peer_rank_highest() call and attempt to clean flash. + rank_queue[rank_queue_wr] = p_pm_evt->peer_id; + rank_queue_wr = (rank_queue_wr + 1) % RANK_QUEUE_SIZE; + pm_handler_flash_clean_on_return(); + } + else if ((err_code != NRF_ERROR_NOT_SUPPORTED) && + (err_code != NRF_ERROR_INVALID_PARAM) && + (err_code != NRF_ERROR_RESOURCES)) + { + APP_ERROR_CHECK(err_code); + } + else + { + NRF_LOG_DEBUG("pm_peer_rank_highest() returned %s for peer id %d", + nrf_strerror_get(err_code), + p_pm_evt->peer_id); + } + break; + + case PM_EVT_CONN_SEC_START: + break; + + case PM_EVT_CONN_SEC_SUCCEEDED: + if ( (p_pm_evt->params.conn_sec_succeeded.procedure == PM_CONN_SEC_PROCEDURE_BONDING) + || (p_pm_evt->params.conn_sec_succeeded.procedure == PM_CONN_SEC_PROCEDURE_ENCRYPTION)) + // PM_CONN_SEC_PROCEDURE_ENCRYPTION in case peer was not recognized at connection time. + { + rank_highest(p_pm_evt->peer_id); + } + break; + + case PM_EVT_CONN_SEC_FAILED: + case PM_EVT_CONN_SEC_CONFIG_REQ: + case PM_EVT_CONN_SEC_PARAMS_REQ: + break; + + case PM_EVT_STORAGE_FULL: + if (!flash_cleaning) + { + err_code = NRF_SUCCESS; + NRF_LOG_INFO("Attempting to clean flash."); + if (!flash_write_after_gc) + { + // Check whether another user of FDS has deleted a record that can be GCed. + fds_stat_t fds_stats; + err_code = fds_stat(&fds_stats); + APP_ERROR_CHECK(err_code); + flash_write_after_gc = (fds_stats.dirty_records > 0); + } + if (!flash_write_after_gc) + { + pm_peer_id_t peer_id_to_delete; + err_code = pm_peer_ranks_get(NULL, NULL, &peer_id_to_delete, NULL); + if (err_code == NRF_SUCCESS) + { + NRF_LOG_INFO("Deleting lowest ranked peer (peer_id: %d)", peer_id_to_delete); + err_code = pm_peer_delete(peer_id_to_delete); + APP_ERROR_CHECK(err_code); + flash_write_after_gc = true; + } + if (err_code == NRF_ERROR_NOT_FOUND) + { + NRF_LOG_ERROR("There are no peers to delete."); + } + else if (err_code == NRF_ERROR_NOT_SUPPORTED) + { + NRF_LOG_WARNING("Peer ranks functionality is disabled, so no peers are deleted."); + } + else + { + APP_ERROR_CHECK(err_code); + } + } + if (err_code == NRF_SUCCESS) + { + err_code = fds_gc(); + if (err_code == NRF_SUCCESS) + { + NRF_LOG_DEBUG("Running flash garbage collection."); + flash_cleaning = true; + } + else if (err_code != FDS_ERR_NO_SPACE_IN_QUEUES) + { + APP_ERROR_CHECK(err_code); + } + } + } + break; + + case PM_EVT_ERROR_UNEXPECTED: + break; + + case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED: + flash_write_after_gc = true; + break; + + case PM_EVT_PEER_DATA_UPDATE_FAILED: + break; + + case PM_EVT_PEER_DELETE_SUCCEEDED: + flash_write_after_gc = true; + break; + + case PM_EVT_PEER_DELETE_FAILED: + case PM_EVT_PEERS_DELETE_SUCCEEDED: + case PM_EVT_PEERS_DELETE_FAILED: + case PM_EVT_LOCAL_DB_CACHE_APPLIED: + case PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED: + case PM_EVT_SERVICE_CHANGED_IND_SENT: + case PM_EVT_SERVICE_CHANGED_IND_CONFIRMED: + case PM_EVT_SLAVE_SECURITY_REQ: + break; + + case PM_EVT_FLASH_GARBAGE_COLLECTED: + flash_cleaning = false; + flash_write_after_gc = false; + { + // Reattempt queued pm_peer_rank_highest() calls. + int rank_queue_rd = rank_queue_wr; + for (int i = 0; i < RANK_QUEUE_SIZE; i++) + { + pm_peer_id_t peer_id = rank_queue[(i + rank_queue_rd) % RANK_QUEUE_SIZE]; + if (peer_id != PM_PEER_ID_INVALID) + { + rank_queue[(i + rank_queue_rd) % RANK_QUEUE_SIZE] = PM_PEER_ID_INVALID; + rank_highest(peer_id); + } + } + } + break; + + case PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED: + flash_cleaning = false; + + if (p_pm_evt->params.garbage_collection_failed.error == FDS_ERR_BUSY + || p_pm_evt->params.garbage_collection_failed.error == FDS_ERR_OPERATION_TIMEOUT) + { + // Retry immediately if error is transient. + pm_handler_flash_clean_on_return(); + } + break; + + default: + break; + } +} + + +void pm_handler_pm_evt_log(pm_evt_t const * p_pm_evt) +{ + NRF_LOG_DEBUG("Event %s", m_event_str[p_pm_evt->evt_id]); + + switch (p_pm_evt->evt_id) + { + case PM_EVT_BONDED_PEER_CONNECTED: + NRF_LOG_DEBUG("Previously bonded peer connected: role: %s, conn_handle: %d, peer_id: %d", + m_roles_str[ble_conn_state_role(p_pm_evt->conn_handle)], + p_pm_evt->conn_handle, + p_pm_evt->peer_id); + break; + + case PM_EVT_CONN_SEC_START: + NRF_LOG_DEBUG("Connection security procedure started: role: %s, conn_handle: %d, procedure: %s", + m_roles_str[ble_conn_state_role(p_pm_evt->conn_handle)], + p_pm_evt->conn_handle, + m_sec_procedure_str[p_pm_evt->params.conn_sec_start.procedure]); + break; + + case PM_EVT_CONN_SEC_SUCCEEDED: + NRF_LOG_INFO("Connection secured: role: %s, conn_handle: %d, procedure: %s", + m_roles_str[ble_conn_state_role(p_pm_evt->conn_handle)], + p_pm_evt->conn_handle, + m_sec_procedure_str[p_pm_evt->params.conn_sec_start.procedure]); + break; + + case PM_EVT_CONN_SEC_FAILED: + NRF_LOG_INFO("Connection security failed: role: %s, conn_handle: 0x%x, procedure: %s, error: %d", + m_roles_str[ble_conn_state_role(p_pm_evt->conn_handle)], + p_pm_evt->conn_handle, + m_sec_procedure_str[p_pm_evt->params.conn_sec_start.procedure], + p_pm_evt->params.conn_sec_failed.error); + NRF_LOG_DEBUG("Error (decoded): %s", + sec_err_string_get(p_pm_evt->params.conn_sec_failed.error)); + break; + + case PM_EVT_CONN_SEC_CONFIG_REQ: + NRF_LOG_DEBUG("Security configuration request"); + break; + + case PM_EVT_CONN_SEC_PARAMS_REQ: + NRF_LOG_DEBUG("Security parameter request"); + break; + + case PM_EVT_STORAGE_FULL: + NRF_LOG_WARNING("Flash storage is full"); + break; + + case PM_EVT_ERROR_UNEXPECTED: + NRF_LOG_ERROR("Unexpected fatal error occurred: error: %s", + nrf_strerror_get(p_pm_evt->params.error_unexpected.error)); + break; + + case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED: + NRF_LOG_INFO("Peer data updated in flash: peer_id: %d, data_id: %s, action: %s%s", + p_pm_evt->peer_id, + m_data_id_str[p_pm_evt->params.peer_data_update_succeeded.data_id], + m_data_action_str[p_pm_evt->params.peer_data_update_succeeded.action], + p_pm_evt->params.peer_data_update_succeeded.flash_changed ? "" : ", no change"); + break; + + case PM_EVT_PEER_DATA_UPDATE_FAILED: + // This can happen if the SoftDevice is too busy with BLE operations. + NRF_LOG_WARNING("Peer data updated failed: peer_id: %d, data_id: %s, action: %s, error: %s", + p_pm_evt->peer_id, + m_data_id_str[p_pm_evt->params.peer_data_update_failed.data_id], + m_data_action_str[p_pm_evt->params.peer_data_update_succeeded.action], + nrf_strerror_get(p_pm_evt->params.peer_data_update_failed.error)); + break; + + case PM_EVT_PEER_DELETE_SUCCEEDED: + NRF_LOG_ERROR("Peer deleted successfully: peer_id: %d", p_pm_evt->peer_id); + break; + + case PM_EVT_PEER_DELETE_FAILED: + NRF_LOG_ERROR("Peer deletion failed: peer_id: %d, error: %s", + p_pm_evt->peer_id, + nrf_strerror_get(p_pm_evt->params.peer_delete_failed.error)); + break; + + case PM_EVT_PEERS_DELETE_SUCCEEDED: + NRF_LOG_INFO("All peers deleted."); + break; + + case PM_EVT_PEERS_DELETE_FAILED: + NRF_LOG_ERROR("All peer deletion failed: error: %s", + nrf_strerror_get(p_pm_evt->params.peers_delete_failed_evt.error)); + break; + + case PM_EVT_LOCAL_DB_CACHE_APPLIED: + NRF_LOG_DEBUG("Previously stored local DB applied: conn_handle: %d, peer_id: %d", + p_pm_evt->conn_handle, + p_pm_evt->peer_id); + break; + + case PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED: + // This can happen when the local DB has changed. + NRF_LOG_WARNING("Local DB could not be applied: conn_handle: %d, peer_id: %d", + p_pm_evt->conn_handle, + p_pm_evt->peer_id); + break; + + case PM_EVT_SERVICE_CHANGED_IND_SENT: + NRF_LOG_DEBUG("Sending Service Changed indication."); + break; + + case PM_EVT_SERVICE_CHANGED_IND_CONFIRMED: + NRF_LOG_DEBUG("Service Changed indication confirmed."); + break; + + case PM_EVT_SLAVE_SECURITY_REQ: + NRF_LOG_DEBUG("Security Request received from peer."); + break; + + case PM_EVT_FLASH_GARBAGE_COLLECTED: + NRF_LOG_DEBUG("Flash garbage collection complete."); + break; + + case PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED: + NRF_LOG_WARNING("Flash garbage collection failed with error %s.", + nrf_strerror_get(p_pm_evt->params.garbage_collection_failed.error)); + break; + + default: + NRF_LOG_WARNING("Unexpected PM event ID: 0x%x.", p_pm_evt->evt_id); + break; + } +} + + +void pm_handler_disconnect_on_sec_failure(pm_evt_t const * p_pm_evt) +{ + ret_code_t err_code; + + if (p_pm_evt->evt_id == PM_EVT_CONN_SEC_FAILED) + { + NRF_LOG_WARNING("Disconnecting conn_handle %d.", p_pm_evt->conn_handle); + err_code = sd_ble_gap_disconnect(p_pm_evt->conn_handle, + BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != BLE_ERROR_INVALID_CONN_HANDLE)) + { + APP_ERROR_CHECK(err_code); + } + } +} + + +void pm_handler_disconnect_on_insufficient_sec(pm_evt_t const * p_pm_evt, + pm_conn_sec_status_t * p_min_conn_sec) +{ + if (p_pm_evt->evt_id == PM_EVT_CONN_SEC_SUCCEEDED) + { + if (!pm_sec_is_sufficient(p_pm_evt->conn_handle, p_min_conn_sec)) + { + NRF_LOG_WARNING("Connection security is insufficient, disconnecting."); + ret_code_t err_code = sd_ble_gap_disconnect(p_pm_evt->conn_handle, + BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + APP_ERROR_CHECK(err_code); + } + } +} + + +void pm_handler_secure_on_connection(ble_evt_t const * p_ble_evt) +{ + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + NRF_LOG_DEBUG("Connected, securing connection. conn_handle: %d", p_ble_evt->evt.gap_evt.conn_handle); + conn_secure(p_ble_evt->evt.gap_evt.conn_handle, false); + break; + +#if PM_HANDLER_SEC_DELAY_MS > 0 + case BLE_GAP_EVT_DISCONNECTED: + { + ret_code_t err_code = app_timer_stop(secure_delay_timer); + APP_ERROR_CHECK(err_code); + } break; +#endif + + default: + break; + } +} + + +void pm_handler_secure_on_error(ble_evt_t const * p_ble_evt) +{ + if ((p_ble_evt->header.evt_id >= BLE_GATTC_EVT_BASE) && (p_ble_evt->header.evt_id <= BLE_GATTC_EVT_LAST)) + { + if ((p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION) || + (p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION)) + { + NRF_LOG_INFO("GATTC procedure (evt id 0x%x) failed because it needs encryption. Bonding: conn_handle=%d", + p_ble_evt->header.evt_id, + p_ble_evt->evt.gattc_evt.conn_handle); + conn_secure(p_ble_evt->evt.gattc_evt.conn_handle, true); + } + } +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.h new file mode 100644 index 0000000..216409c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_handler.h @@ -0,0 +1,166 @@ +/** + * Copyright (c) 2018 - 2019, 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 peer_manager_handler.h + * + * @defgroup pm_handler Peer Manager Standard Event Handlers + * @ingroup peer_manager + * @{ + * @brief Standard event handlers implementing some best practices for BLE security. + */ + + +#ifndef PEER_MANAGER_HANDLER_H__ +#define PEER_MANAGER_HANDLER_H__ + +#include "ble.h" +#include "peer_manager.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Standard function for making Peer Manager calls based on Peer Manager events. + * + * This function does the following: + * - Logs all PM events using @ref nrf_log, at different severity levels. + * - Starts encryption if connected to an already bonded peer. This is affected by @ref + * PM_HANDLER_SEC_DELAY_MS. + * - Calls @ref app_error on fatal errors. + * + * @note In normal circumstances, this function should be called for every Peer Manager event. + * + * @param[in] p_pm_evt Peer Manager event to handle. + */ +void pm_handler_on_pm_evt(pm_evt_t const * p_pm_evt); + +/**@brief Auxiliary standard function for logging Peer Manager events. + * + * This function logs all PM events using @ref nrf_log, at different severity levels. The + * @ref PM_LOG_ENABLED and other @c PM_LOG_* configs control these log messages. + * + * @note This function is called internally by @ref pm_handler_on_pm_evt. + * + * @param[in] p_pm_evt Peer Manager event to log. + */ +void pm_handler_pm_evt_log(pm_evt_t const * p_pm_evt); + +/**@brief Auxiliary standard function for maintaining room in flash based on Peer Manager events. + * + * This function does the following: + * - Ranks peers by when they last connected. + * - Garbage collects the flash when needed. + * - Deletes the lowest ranked peer(s) when garbage collection is insufficient. + * + * @note See also @ref pm_handler_flash_clean_on_return. + * @note In normal circumstances, this function should be called for every Peer Manager event. + * @note This function is a supplement to @ref pm_handler_on_pm_evt, not its replacement. + * + * @param[in] p_pm_evt Peer Manager event to handle. + */ +void pm_handler_flash_clean(pm_evt_t const * p_pm_evt); + +/**@brief Function to call when a Peer Manager function returns @ref NRF_ERROR_STORAGE_FULL. + * + * @note This should only be used if @ref pm_handler_flash_clean is also used. + */ +void pm_handler_flash_clean_on_return(void); + +/**@brief Auxiliary standard function for disconnecting when the connection could not be secured. + * + * This function disconnects whenever connection security fails, i.e. whenever it receives a + * @ref PM_EVT_CONN_SEC_FAILED. + * + * @note In normal circumstances, this function should be called for every Peer Manager event. + * @note This function is a supplement to @ref pm_handler_on_pm_evt, not its replacement. + * + * @param[in] p_pm_evt Peer Manager event to handle. + */ +void pm_handler_disconnect_on_sec_failure(pm_evt_t const * p_pm_evt); + +/**@brief Auxiliary standard function for disconnecting on insufficient connection security. + * + * This function disconnects whenever the connection security succeeds, that is whenever it + * receives a @ref PM_EVT_CONN_SEC_SUCCEEDED, but the established security does not fulfill the + * provided criteria. + * + * @note In normal circumstances, this function should be called for every Peer Manager event. + * @note This function is a supplement to @ref pm_handler_on_pm_evt, not its replacement. + * + * @param[in] p_pm_evt Peer Manager event to handle. + * @param[in] p_min_conn_sec Minumum security status below which to disconnect the link. + */ +void pm_handler_disconnect_on_insufficient_sec(pm_evt_t const * p_pm_evt, + pm_conn_sec_status_t * p_min_conn_sec); + +/**@brief Function for securing a connection when it is established. + * + * This function starts security when receiving a @ref BLE_GAP_EVT_CONNECTED event. This is + * affected by @ref PM_HANDLER_SEC_DELAY_MS. + * + * @note In normal circumstances, this function should be called for every BLE event. + * + * @param[in] p_ble_evt BLE event to handle. + */ +void pm_handler_secure_on_connection(ble_evt_t const * p_ble_evt); + +/**@brief Function for securing a connection if a GATT read or write operation lacks security. + * + * This function starts pairing if a GATTC procedure fails with insufficient encryption + * or insufficient authentication. This is meant to delay performing pairing/bonding until + * it is actually needed to access resources. This is affected by @ref PM_HANDLER_SEC_DELAY_MS. + * + * @note When using this handler, the failed GATTC operation must be retried by the user. + * @note This does not work when using Write Without Response (@ref BLE_GATT_OP_WRITE_CMD) because + * the server does not send any response, even on error. Instead, the write will be + * silently dropped by the server. + * @note In normal circumstances, this function should be called for every BLE event. + * + * @param[in] p_ble_evt BLE event to handle. + */ +void pm_handler_secure_on_error(ble_evt_t const * p_ble_evt); + +#ifdef __cplusplus +} +#endif + +/** @}*/ + +#endif // PEER_MANAGER_HANDLER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_internal.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_internal.h index 1e6dae4..f308f04 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 PEER_MANAGER_INTERNAL_H__ #define PEER_MANAGER_INTERNAL_H__ @@ -60,7 +60,7 @@ extern "C" { * @{ */ -ANON_UNIONS_ENABLE +ANON_UNIONS_ENABLE; /**@brief One piece of data associated with a peer, together with its type. * @@ -74,6 +74,7 @@ typedef struct { pm_peer_data_bonding_t * p_bonding_data; /**< @brief The exchanged bond information in addition to metadata of the bonding. */ uint32_t * p_peer_rank; /**< @brief A value locally assigned to this peer. Its interpretation is up to the user. The rank is not set automatically by the Peer Manager, but it is assigned by the user using either @ref pm_peer_rank_highest or a @ref PM_PEER_DATA_FUNCTIONS function. */ + uint32_t * p_central_addr_res; /**< @brief Value of peer's Central Address Resolution characteristic. */ bool * p_service_changed_pending; /**< @brief Whether a service changed indication should be sent to the peer. */ pm_peer_data_local_gatt_db_t * p_local_gatt_db; /**< @brief Persistent information pertaining to a peer GATT client. */ ble_gatt_db_srv_t * p_remote_gatt_db; /**< @brief Persistent information pertaining to a peer GATT server. */ @@ -95,6 +96,7 @@ typedef struct { pm_peer_data_bonding_t const * p_bonding_data; /**< @brief Immutable @ref pm_peer_data_t::p_bonding_data. */ uint32_t const * p_peer_rank; /**< @brief Immutable @ref pm_peer_data_t::p_peer_rank. */ + uint32_t const * p_central_addr_res; /**< @brief Immutable @ref pm_peer_data_t::p_central_addr_res. */ bool const * p_service_changed_pending; /**< @brief Immutable @ref pm_peer_data_t::p_service_changed_pending. */ pm_peer_data_local_gatt_db_t const * p_local_gatt_db; /**< @brief Immutable @ref pm_peer_data_t::p_local_gatt_db. */ ble_gatt_db_srv_t const * p_remote_gatt_db; /**< @brief Immutable @ref pm_peer_data_t::p_remote_gatt_db. */ @@ -103,7 +105,7 @@ typedef struct }; /**< @brief The data. */ } pm_peer_data_const_t; -ANON_UNIONS_DISABLE +ANON_UNIONS_DISABLE; /**@brief Version of @ref pm_peer_data_t that reflects the structure of peer data in flash. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_types.h similarity index 86% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_types.h index 8c69983..92d0173 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/peer_manager_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/peer_manager_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 peer_manager_types.h @@ -67,10 +67,6 @@ extern "C" { */ typedef uint16_t pm_peer_id_t; -/**@brief Type that is used for write prepares (used to reserve space in flash). - */ -typedef uint32_t pm_prepare_token_t; - /**@brief Type that is used to hold a reference to a stored item in flash. */ typedef uint32_t pm_store_token_t; @@ -95,8 +91,8 @@ typedef uint16_t pm_sec_error_code_t; /**@defgroup PM_SEC_ERRORS Peer Manager defined security errors * - * @details The first 256 numbers in this range correspond to the status codes in - * @ref BLE_HCI_STATUS_CODES. + * @details The first 256 numbers, from PM_CONN_SEC_ERROR_BASE to (PM_CONN_SEC_ERROR_BASE + 0xFF), + * correspond to the status codes in @ref BLE_HCI_STATUS_CODES. * @{ */ #define PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING (PM_CONN_SEC_ERROR_BASE + 0x06) /**< @brief Encryption failed because the peripheral has lost the LTK for this bond. See also @ref BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING and Table 3.7 ("Pairing Failed Reason Codes") in the Bluetooth Core Specification 4.2, section 3.H.3.5.5 (@linkBLEcore). */ #define PM_CONN_SEC_ERROR_MIC_FAILURE (PM_CONN_SEC_ERROR_BASE + 0x3D) /**< @brief Encryption ended with disconnection because of mismatching keys or a stray packet during a procedure. See the SoftDevice GAP Message Sequence Charts on encryption (@linkBLEMSCgap), the Bluetooth Core Specification 4.2, sections 6.B.5.1.3.1 and 3.H.3.5.5 (@linkBLEcore), and @ref BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE. */ @@ -122,7 +118,8 @@ typedef uint16_t pm_sec_error_code_t; #define PM_PEER_DATA_ID_APPLICATION_V1 4 /**< @brief The data ID of the first version of application data. */ #define PM_PEER_DATA_ID_GATT_REMOTE_V2 5 /**< @brief The data ID of the second version of remote GATT data. */ #define PM_PEER_DATA_ID_PEER_RANK_V1 6 /**< @brief The data ID of the first version of the rank. */ -#define PM_PEER_DATA_ID_LAST_VX 9 /**< @brief The data ID after the last valid one. */ +#define PM_PEER_DATA_ID_CENTRAL_ADDR_RES_V1 9 /**< @brief The data ID of the first version of central address resolution. */ +#define PM_PEER_DATA_ID_LAST_VX 10 /**< @brief The data ID after the last valid one. */ #define PM_PEER_DATA_ID_INVALID_VX 0xFF /**< @brief A data ID guaranteed to be invalid. */ /**@}*/ @@ -137,6 +134,7 @@ typedef enum PM_PEER_DATA_ID_GATT_LOCAL = PM_PEER_DATA_ID_GATT_LOCAL_V2, /**< @brief The data ID for local GATT data (sys attributes). Type: @ref pm_peer_data_local_gatt_db_t. */ PM_PEER_DATA_ID_GATT_REMOTE = PM_PEER_DATA_ID_GATT_REMOTE_V2, /**< @brief The data ID for remote GATT data. Type: uint8_t array. */ PM_PEER_DATA_ID_PEER_RANK = PM_PEER_DATA_ID_PEER_RANK_V1, /**< @brief The data ID for peer rank. See @ref pm_peer_rank_highest. Type: uint32_t. */ + PM_PEER_DATA_ID_CENTRAL_ADDR_RES = PM_PEER_DATA_ID_CENTRAL_ADDR_RES_V1, /**< @brief The data ID for central address resolution. See @ref pm_peer_id_list. Type: uint32_t. */ PM_PEER_DATA_ID_APPLICATION = PM_PEER_DATA_ID_APPLICATION_V1, /**< @brief The data ID for application data. Type: uint8_t array. */ PM_PEER_DATA_ID_LAST = PM_PEER_DATA_ID_LAST_VX, /**< @brief One more than the highest data ID. */ PM_PEER_DATA_ID_INVALID = PM_PEER_DATA_ID_INVALID_VX, /**< @brief A data ID guaranteed to be invalid. */ @@ -147,9 +145,9 @@ typedef enum */ typedef enum { - PM_LINK_SECURED_PROCEDURE_ENCRYPTION, /**< @brief Using an LTK that was shared during a previous bonding procedure to encrypt the link. */ - PM_LINK_SECURED_PROCEDURE_BONDING, /**< @brief A pairing procedure, followed by a bonding procedure. */ - PM_LINK_SECURED_PROCEDURE_PAIRING, /**< @brief A pairing procedure with no bonding. */ + PM_CONN_SEC_PROCEDURE_ENCRYPTION, /**< @brief Using an LTK that was shared during a previous bonding procedure to encrypt the link. */ + PM_CONN_SEC_PROCEDURE_BONDING, /**< @brief A pairing procedure, followed by a bonding procedure. */ + PM_CONN_SEC_PROCEDURE_PAIRING, /**< @brief A pairing procedure with no bonding. */ } pm_conn_sec_procedure_t; @@ -198,30 +196,20 @@ typedef struct * The IRK distributed during bonding procedure is the device IRK that is active when @ref * sd_ble_gap_sec_params_reply is called. */ -#if (NRF_SD_BLE_API_VERSION < 3) +typedef ble_gap_privacy_params_t pm_privacy_params_t; + +/**@brief Security status of a connection. + */ typedef struct { - uint8_t privacy_mode; /**< Privacy mode, see @ref BLE_GAP_PRIVACY_MODES. Default is @ref BLE_GAP_PRIVACY_MODE_OFF. */ - uint8_t private_addr_type; /**< The private address type must be either @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. */ - uint16_t private_addr_cycle_s; /**< Private address cycle interval in seconds. Providing an address cycle value of 0 will use the default value defined by @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S. */ - ble_gap_irk_t * p_device_irk; /**< When used as input, pointer to IRK structure that will be used as the default IRK. If NULL, the device default IRK will be used. - When used as output, pointer to IRK structure where the current default IRK will be written to. If NULL, this argument is ignored. - By default, the default IRK is used to generate random private resolvable addresses for the local device unless instructed otherwise. */ -} pm_privacy_params_t; - - -/**@defgroup BLE_GAP_PRIVACY_MODES Privacy modes - * @{ */ -#define BLE_GAP_PRIVACY_MODE_OFF 0x00 /**< Device will send and accept its identity address for its own address. */ -#define BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY 0x01 /**< Device will send and accept only private addresses for its own address. */ -/**@} */ - -#else - -typedef ble_gap_privacy_params_t pm_privacy_params_t; - -#endif + uint8_t connected : 1; /**< @brief The connection is active (not disconnected). */ + uint8_t encrypted : 1; /**< @brief The communication on this link is encrypted. */ + uint8_t mitm_protected : 1; /**< @brief The encrypted communication is also protected against man-in-the-middle attacks. */ + uint8_t bonded : 1; /**< @brief The peer is bonded. */ + uint8_t lesc : 1; /**< @brief The peer is paired using LESC. */ + uint8_t reserved : 3; /**< @brief Reserved for future use. */ +} pm_conn_sec_status_t; /**@brief Types of events that can come from the @ref peer_manager module. @@ -248,6 +236,7 @@ typedef enum PM_EVT_SERVICE_CHANGED_IND_CONFIRMED, /**< @brief A service changed indication that was sent has been confirmed by a peer. The peer can now be considered aware that the local database has changed. */ PM_EVT_SLAVE_SECURITY_REQ, /**< @brief The peer (peripheral) has requested link encryption, which has been enabled. */ PM_EVT_FLASH_GARBAGE_COLLECTED, /**< @brief The flash has been garbage collected (By FDS), possibly freeing up space. */ + PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED, /**< @brief Garbage collection was attempted but failed. */ } pm_evt_id_t; @@ -311,10 +300,10 @@ typedef struct */ typedef struct { - pm_peer_data_id_t data_id; /**< @brief The type of the data that was supposed to be changed. */ - pm_peer_data_op_t action; /**< @brief The action that failed. */ - pm_store_token_t token; /**< @brief Token that identifies the operation. For @ref PM_PEER_DATA_OP_DELETE actions, this token can be disregarded. For @ref PM_PEER_DATA_OP_UPDATE actions, compare this token with the token that is received from a call to a @ref PM_PEER_DATA_FUNCTIONS function. */ - ret_code_t error; /**< @brief An error code that describes the failure. */ + pm_peer_data_id_t data_id; /**< @brief The type of the data that was supposed to be changed. */ + pm_peer_data_op_t action; /**< @brief The action that failed. */ + pm_store_token_t token; /**< @brief Token that identifies the operation. For @ref PM_PEER_DATA_OP_DELETE actions, this token can be disregarded. For @ref PM_PEER_DATA_OP_UPDATE actions, compare this token with the token that is received from a call to a @ref PM_PEER_DATA_FUNCTIONS function. */ + ret_code_t error; /**< @brief An error code that describes the failure. */ } pm_peer_data_update_failed_t; @@ -322,19 +311,10 @@ typedef struct */ typedef struct { - ret_code_t error; /**< @brief The error that occurred. */ + ret_code_t error; /**< @brief The error that occurred. */ } pm_failure_evt_t; -/**@brief Events parameters specific to the @ref PM_EVT_SLAVE_SECURITY_REQ event. - */ -typedef struct -{ - bool bond; /**< @brief Whether the peripheral requested bonding. */ - bool mitm; /**< @brief Whether the peripheral requested man-in-the-middle protection. */ -} pm_evt_slave_security_req_t; - - /**@brief An event from the @ref peer_manager module. * * @details The structure contains both standard parameters and parameters that are specific to some events. @@ -355,7 +335,8 @@ typedef struct pm_failure_evt_t peer_delete_failed; /**< @brief Parameters specific to the @ref PM_EVT_PEER_DELETE_FAILED event. */ pm_failure_evt_t peers_delete_failed_evt; /**< @brief Parameters specific to the @ref PM_EVT_PEERS_DELETE_FAILED event. */ pm_failure_evt_t error_unexpected; /**< @brief Parameters specific to the @ref PM_EVT_ERROR_UNEXPECTED event. */ - pm_evt_slave_security_req_t slave_security_req; /**< @brief Parameters specific to the @ref PM_EVT_SLAVE_SECURITY_REQ event. */ + ble_gap_evt_sec_request_t slave_security_req; /**< @brief Parameters specific to the @ref PM_EVT_SLAVE_SECURITY_REQ event. */ + pm_failure_evt_t garbage_collection_failed; /**< @brief Parameters specific to the @ref PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED event. */ } params; } pm_evt_t; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_buffer.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/pm_buffer.c similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_buffer.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/pm_buffer.c index 83fdf77..07318b9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_buffer.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/pm_buffer.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -44,7 +44,7 @@ #include #include #include "nrf_error.h" -#include "pm_mutex.h" +#include "nrf_atflags.h" #define BUFFER_IS_VALID(p_buffer) ((p_buffer != NULL) \ @@ -53,19 +53,39 @@ -ret_code_t pm_buffer_init(pm_buffer_t * p_buffer, - uint8_t * p_buffer_memory, - uint32_t buffer_memory_size, - uint8_t * p_mutex_memory, - uint32_t mutex_memory_size, - uint32_t n_blocks, - uint32_t block_size) +static bool mutex_lock(nrf_atflags_t * p_mutex, uint32_t mutex_id) +{ + bool locked = !nrf_atflags_fetch_set(p_mutex, mutex_id); + __DMB(); + return locked; +} + + +static void mutex_unlock(nrf_atflags_t * p_mutex, uint32_t mutex_id) +{ + __DMB(); + nrf_atflags_clear(p_mutex, mutex_id); +} + + +static bool mutex_lock_status_get(nrf_atflags_t * p_mutex, uint32_t mutex_id) +{ + __DMB(); + return nrf_atflags_get(p_mutex, mutex_id); +} + + +ret_code_t pm_buffer_init(pm_buffer_t * p_buffer, + uint8_t * p_buffer_memory, + uint32_t buffer_memory_size, + nrf_atflags_t * p_mutex_memory, + uint32_t n_blocks, + uint32_t block_size) { if ( (p_buffer != NULL) && (p_buffer_memory != NULL) && (p_mutex_memory != NULL) && (buffer_memory_size >= (n_blocks * block_size)) - && (mutex_memory_size >= MUTEX_STORAGE_SIZE(n_blocks)) && (n_blocks != 0) && (block_size != 0)) { @@ -73,7 +93,6 @@ ret_code_t pm_buffer_init(pm_buffer_t * p_buffer, p_buffer->p_mutex = p_mutex_memory; p_buffer->n_blocks = n_blocks; p_buffer->block_size = block_size; - pm_mutex_init(p_buffer->p_mutex, n_blocks); return NRF_SUCCESS; } @@ -95,7 +114,7 @@ uint8_t pm_buffer_block_acquire(pm_buffer_t * p_buffer, uint32_t n_blocks) for (uint8_t i = 0; i < p_buffer->n_blocks; i++) { - if (pm_mutex_lock(p_buffer->p_mutex, i)) + if (mutex_lock(p_buffer->p_mutex, i)) { if (first_locked_mutex == PM_BUFFER_INVALID_ID) { @@ -128,7 +147,7 @@ uint8_t * pm_buffer_ptr_get(pm_buffer_t * p_buffer, uint8_t id) } if ( (id != PM_BUFFER_INVALID_ID) - && pm_mutex_lock_status_get(p_buffer->p_mutex, id) ) + && mutex_lock_status_get(p_buffer->p_mutex, id) ) { return ( &p_buffer->p_memory[id * p_buffer->block_size] ); } @@ -143,9 +162,9 @@ void pm_buffer_release(pm_buffer_t * p_buffer, uint8_t id) { if ( BUFFER_IS_VALID(p_buffer) && (id != PM_BUFFER_INVALID_ID) - && pm_mutex_lock_status_get(p_buffer->p_mutex, id)) + && mutex_lock_status_get(p_buffer->p_mutex, id)) { - pm_mutex_unlock(p_buffer->p_mutex, id); + mutex_unlock(p_buffer->p_mutex, id); } } #endif // NRF_MODULE_ENABLED(PEER_MANAGER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_buffer.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/pm_buffer.h similarity index 82% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_buffer.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/pm_buffer.h index 3697441..f84e499 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/pm_buffer.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/pm_buffer.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 BUFFER_H__ #define BUFFER_H__ @@ -43,7 +43,7 @@ #include #include "compiler_abstraction.h" #include "sdk_errors.h" -#include "pm_mutex.h" +#include "nrf_atflags.h" #ifdef __cplusplus extern "C" { @@ -73,12 +73,11 @@ extern "C" { do \ { \ __ALIGN(4) static uint8_t buffer_memory[(n_blocks) * (block_size)]; \ - static uint8_t mutex_memory[MUTEX_STORAGE_SIZE(n_blocks)]; \ + static NRF_ATFLAGS_DEF(mutex_memory, n_blocks); \ err_code = pm_buffer_init((p_buffer), \ buffer_memory, \ (n_blocks) * (block_size), \ mutex_memory, \ - MUTEX_STORAGE_SIZE(n_blocks), \ (n_blocks), \ (block_size)); \ } while (0) @@ -86,10 +85,10 @@ do \ typedef struct { - uint8_t * p_memory; /**< The storage for all buffer entries. The size of the buffer must be n_blocks*block_size. */ - uint8_t * p_mutex; /**< A mutex group with one mutex for each buffer entry. */ - uint32_t n_blocks; /**< The number of allocatable blocks in the buffer. */ - uint32_t block_size; /**< The size of each block in the buffer. */ + uint8_t * p_memory; /**< The storage for all buffer entries. The size of the buffer must be n_blocks*block_size. */ + nrf_atflags_t * p_mutex; /**< A mutex group with one mutex for each buffer entry. */ + uint32_t n_blocks; /**< The number of allocatable blocks in the buffer. */ + uint32_t block_size; /**< The size of each block in the buffer. */ } pm_buffer_t; /**@brief Function for initializing a buffer instance. @@ -99,21 +98,19 @@ typedef struct * @param[in] buffer_memory_size The size of p_buffer_memory. This must be at least * n_blocks*block_size. * @param[in] p_mutex_memory The memory for the mutexes. This must be at least - * @ref MUTEX_STORAGE_SIZE(n_blocks). - * @param[in] mutex_memory_size The size of p_mutex_memory. + * @ref NRF_ATFLAGS_ARRAY_LEN(n_blocks). * @param[in] n_blocks The number of blocks in the buffer. * @param[in] block_size The size of each block. * * @retval NRF_SUCCESS Successfully initialized buffer instance. * @retval NRF_ERROR_INVALID_PARAM A parameter was 0 or NULL or a size was too small. */ -ret_code_t pm_buffer_init(pm_buffer_t * p_buffer, - uint8_t * p_buffer_memory, - uint32_t buffer_memory_size, - uint8_t * p_mutex_memory, - uint32_t mutex_memory_size, - uint32_t n_blocks, - uint32_t block_size); +ret_code_t pm_buffer_init(pm_buffer_t * p_buffer, + uint8_t * p_buffer_memory, + uint32_t buffer_memory_size, + nrf_atflags_t * p_mutex_memory, + uint32_t n_blocks, + uint32_t block_size); /**@brief Function for acquiring a buffer block in a buffer. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_dispatcher.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_dispatcher.c similarity index 72% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_dispatcher.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_dispatcher.c index 84cf206..0cd3e72 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_dispatcher.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_dispatcher.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -47,8 +47,25 @@ #include "ble_err.h" #include "ble_conn_state.h" #include "peer_manager_types.h" +#include "peer_data_storage.h" #include "peer_database.h" #include "id_manager.h" +#if PM_RA_PROTECTION_ENABLED +#include "auth_status_tracker.h" +#endif // PM_RA_PROTECTION_ENABLED + +#define NRF_LOG_MODULE_NAME peer_manager_smd +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" #ifndef PM_CENTRAL_ENABLED #define PM_CENTRAL_ENABLED 1 @@ -75,7 +92,6 @@ static bool m_module_initialized; static ble_conn_state_user_flag_id_t m_flag_sec_proc = BLE_CONN_STATE_USER_FLAG_INVALID; static ble_conn_state_user_flag_id_t m_flag_sec_proc_pairing = BLE_CONN_STATE_USER_FLAG_INVALID; static ble_conn_state_user_flag_id_t m_flag_sec_proc_bonding = BLE_CONN_STATE_USER_FLAG_INVALID; -static ble_conn_state_user_flag_id_t m_flag_sec_proc_new_peer = BLE_CONN_STATE_USER_FLAG_INVALID; static ble_conn_state_user_flag_id_t m_flag_allow_repairing = BLE_CONN_STATE_USER_FLAG_INVALID; static ble_gap_lesc_p256_pk_t m_peer_pk; @@ -96,11 +112,6 @@ static __INLINE bool bonding(uint16_t conn_handle) return ble_conn_state_user_flag_get(conn_handle, m_flag_sec_proc_bonding); } -static __INLINE bool peer_created(uint16_t conn_handle) -{ - return ble_conn_state_user_flag_get(conn_handle, m_flag_sec_proc_new_peer); -} - static __INLINE bool allow_repairing(uint16_t conn_handle) { return ble_conn_state_user_flag_get(conn_handle, m_flag_allow_repairing); @@ -163,6 +174,21 @@ static void send_unexpected_error(uint16_t conn_handle, ret_code_t err_code) } +/**@brief Function for sending a PM_EVT_STORAGE_FULL event. + * + * @param[in] conn_handle The connection handle the event pertains to. + */ +static void send_storage_full_evt(uint16_t conn_handle) +{ + pm_evt_t evt = + { + .evt_id = PM_EVT_STORAGE_FULL, + .conn_handle = conn_handle + }; + evt_send(&evt); +} + + /**@brief Function for cleaning up after a failed security procedure. * * @param[in] conn_handle The handle of the connection the security procedure happens on. @@ -209,24 +235,17 @@ static void pairing_failure(uint16_t conn_handle, uint8_t error_src) { ret_code_t err_code = NRF_SUCCESS; - pm_peer_id_t peer_id = im_peer_id_get_by_conn_handle(conn_handle); - pm_conn_sec_procedure_t procedure = bonding(conn_handle) ? PM_LINK_SECURED_PROCEDURE_BONDING - : PM_LINK_SECURED_PROCEDURE_PAIRING; + pm_conn_sec_procedure_t procedure = bonding(conn_handle) ? PM_CONN_SEC_PROCEDURE_BONDING + : PM_CONN_SEC_PROCEDURE_PAIRING; - if (peer_created(conn_handle)) + err_code = pdb_write_buf_release(PDB_TEMP_PEER_ID(conn_handle), PM_PEER_DATA_ID_BONDING); + if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_NOT_FOUND /* No buffer was allocated */)) { - // The peer_id was created during the procedure, and should be freed, because no data is - // stored under it. - err_code = im_peer_free(peer_id); // Attempt to free allocated peer. - UNUSED_VARIABLE(err_code); - } - else if(peer_id != PM_PEER_ID_INVALID) - { - err_code = pdb_write_buf_release(peer_id, PM_PEER_DATA_ID_BONDING); - if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_NOT_FOUND /* No buffer was allocated */)) - { - send_unexpected_error(conn_handle, err_code); - } + NRF_LOG_ERROR("Could not clean up after failed bonding procedure. "\ + "pdb_write_buf_release() returned %s. conn_handle: %d.", + nrf_strerror_get(err_code), + conn_handle); + send_unexpected_error(conn_handle, err_code); } conn_sec_failure(conn_handle, procedure, error, error_src); @@ -245,7 +264,7 @@ static __INLINE void encryption_failure(uint16_t conn_handle, pm_sec_error_code_t error, uint8_t error_src) { - conn_sec_failure(conn_handle, PM_LINK_SECURED_PROCEDURE_ENCRYPTION, error, error_src); + conn_sec_failure(conn_handle, PM_CONN_SEC_PROCEDURE_ENCRYPTION, error, error_src); return; } @@ -290,49 +309,15 @@ static void sec_proc_start(uint16_t conn_handle, { ble_conn_state_user_flag_set(conn_handle, m_flag_sec_proc_pairing, - (procedure != PM_LINK_SECURED_PROCEDURE_ENCRYPTION)); + (procedure != PM_CONN_SEC_PROCEDURE_ENCRYPTION)); ble_conn_state_user_flag_set(conn_handle, m_flag_sec_proc_bonding, - (procedure == PM_LINK_SECURED_PROCEDURE_BONDING)); - ble_conn_state_user_flag_set(conn_handle, m_flag_sec_proc_new_peer, false); + (procedure == PM_CONN_SEC_PROCEDURE_BONDING)); sec_start_send(conn_handle, procedure); } } - -/**@brief Function for administrative actions to be taken during the course of a security process. - * - * @param[in] conn_handle The connection the security process was attempted on. - * @param[in] peer_id The peer ID given to the connected peer. - * @param[in] success Whether the process was started successfully. - * @param[in] new_peer_created Whether a new peer was created during the process attempt. - */ -static void sec_proc_housekeeping(uint16_t conn_handle, - pm_peer_id_t peer_id, - bool success, - bool new_peer_created) -{ - if (success) - { - if (new_peer_created) - { - ble_conn_state_user_flag_set(conn_handle, m_flag_sec_proc_new_peer, true); - im_new_peer_id(conn_handle, peer_id); - } - } - else - { - if (new_peer_created) - { - ret_code_t err_code = im_peer_free(peer_id); // Attempt to free allocated peer. - UNUSED_VARIABLE(err_code); - } - } -} - - - /**@brief Function for processing the @ref BLE_GAP_EVT_SEC_INFO_REQUEST event from the SoftDevice. * * @param[in] p_gap_evt The event from the SoftDevice. @@ -356,7 +341,7 @@ static void sec_info_request_process(ble_gap_evt_t const * p_gap_evt) im_new_peer_id(p_gap_evt->conn_handle, peer_id); } - sec_proc_start(p_gap_evt->conn_handle, true, PM_LINK_SECURED_PROCEDURE_ENCRYPTION); + sec_proc_start(p_gap_evt->conn_handle, true, PM_CONN_SEC_PROCEDURE_ENCRYPTION); if (peer_id != PM_PEER_ID_INVALID) { @@ -367,9 +352,10 @@ static void sec_info_request_process(ble_gap_evt_t const * p_gap_evt) // There is stored bonding data for this peer. ble_gap_enc_key_t const * p_existing_key = &peer_data.p_bonding_data->own_ltk; - if ( p_existing_key->enc_info.lesc - || (im_master_ids_compare(&p_existing_key->master_id, - &p_gap_evt->params.sec_info_request.master_id))) + if (p_gap_evt->params.sec_info_request.enc_info + && (p_existing_key->enc_info.lesc + || im_master_ids_compare(&p_existing_key->master_id, + &p_gap_evt->params.sec_info_request.master_id))) { p_enc_info = &p_existing_key->enc_info; } @@ -378,14 +364,26 @@ static void sec_info_request_process(ble_gap_evt_t const * p_gap_evt) err_code = sd_ble_gap_sec_info_reply(p_gap_evt->conn_handle, p_enc_info, NULL, NULL); - if (err_code != NRF_SUCCESS) + if (err_code == NRF_ERROR_INVALID_STATE) + { + // Do nothing. If disconnecting, it will be caught later by the handling of the DISCONNECTED + // event. If there is no SEC_INFO_REQ pending, there is either a logic error, or the user + // is also calling sd_ble_gap_sec_info_reply(), but there is no way for the present code to + // detect which one is the case. + NRF_LOG_WARNING("sd_ble_gap_sec_info_reply() returned NRF_EROR_INVALID_STATE, which is an"\ + "error unless the link is disconnecting."); + } + else if (err_code != NRF_SUCCESS) { - sec_proc_housekeeping(p_gap_evt->conn_handle, peer_id, false, false); + NRF_LOG_ERROR("Could not complete encryption procedure. sd_ble_gap_sec_info_reply() "\ + "returned %s. conn_handle: %d, peer_id: %d.", + nrf_strerror_get(err_code), + p_gap_evt->conn_handle, + peer_id); send_unexpected_error(p_gap_evt->conn_handle, err_code); } - else if (p_enc_info == NULL) + else if (p_gap_evt->params.sec_info_request.enc_info && (p_enc_info == NULL)) { - sec_proc_housekeeping(p_gap_evt->conn_handle, peer_id, false, false); encryption_failure(p_gap_evt->conn_handle, PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING, BLE_GAP_SEC_STATUS_SOURCE_LOCAL); @@ -395,7 +393,6 @@ static void sec_info_request_process(ble_gap_evt_t const * p_gap_evt) } - /**@brief Function for sending a CONFIG_REQ event. * * @param[in] conn_handle The connection the sec parameters are needed for. @@ -473,8 +470,8 @@ static void sec_params_request_process(ble_gap_evt_t const * p_gap_evt) sec_proc_start(p_gap_evt->conn_handle, true, p_gap_evt->params.sec_params_request.peer_params.bond - ? PM_LINK_SECURED_PROCEDURE_BONDING - : PM_LINK_SECURED_PROCEDURE_PAIRING); + ? PM_CONN_SEC_PROCEDURE_BONDING + : PM_CONN_SEC_PROCEDURE_PAIRING); } send_params_req(p_gap_evt->conn_handle, &p_gap_evt->params.sec_params_request.peer_params); @@ -482,6 +479,26 @@ static void sec_params_request_process(ble_gap_evt_t const * p_gap_evt) } +/**@brief Function for sending a Peer Manager event indicating that pairing has succeeded. + * + * @param[in] p_gap_evt The AUTH_STATUS event from the SoftDevice that triggered this. + * @param[in] data_stored Whether bonding data was stored. + */ +static void pairing_success_evt_send(ble_gap_evt_t const * p_gap_evt, bool data_stored) +{ + pm_evt_t pairing_success_evt; + + pairing_success_evt.evt_id = PM_EVT_CONN_SEC_SUCCEEDED; + pairing_success_evt.conn_handle = p_gap_evt->conn_handle; + pairing_success_evt.params.conn_sec_succeeded.procedure = p_gap_evt->params.auth_status.bonded + ? PM_CONN_SEC_PROCEDURE_BONDING + : PM_CONN_SEC_PROCEDURE_PAIRING; + pairing_success_evt.params.conn_sec_succeeded.data_stored = data_stored; + + evt_send(&pairing_success_evt); +} + + /**@brief Function for processing the @ref BLE_GAP_EVT_AUTH_STATUS event from the SoftDevice, when * the auth_status is success. * @@ -489,44 +506,41 @@ static void sec_params_request_process(ble_gap_evt_t const * p_gap_evt) */ static void auth_status_success_process(ble_gap_evt_t const * p_gap_evt) { - ret_code_t err_code = NRF_SUCCESS; - uint16_t conn_handle = p_gap_evt->conn_handle; - uint8_t role = ble_conn_state_role(conn_handle); - pm_peer_id_t peer_id = im_peer_id_get_by_conn_handle(conn_handle); - pm_peer_id_t new_peer_id = peer_id; - pm_peer_data_t peer_data; - bool data_stored = false; + ret_code_t err_code; + uint16_t conn_handle = p_gap_evt->conn_handle; + pm_peer_id_t peer_id; + pm_peer_data_t peer_data; + bool new_peer_id = false; ble_conn_state_user_flag_set(conn_handle, m_flag_sec_proc, false); - if (role == BLE_GAP_ROLE_INVALID) + if (!p_gap_evt->params.auth_status.bonded) { - /* Unlikely, but maybe possible? */ + pairing_success_evt_send(p_gap_evt, false); return; } - if (p_gap_evt->params.auth_status.bonded) + err_code = pdb_write_buf_get(PDB_TEMP_PEER_ID(conn_handle), PM_PEER_DATA_ID_BONDING, 1, &peer_data); + if (err_code != NRF_SUCCESS) { - pm_peer_id_t duplicate_peer_id = PM_PEER_ID_INVALID; - data_stored = true; + NRF_LOG_ERROR("RAM buffer for new bond was unavailable. pdb_write_buf_get() returned %s. conn_handle: %d.", + nrf_strerror_get(err_code), + conn_handle); + send_unexpected_error(conn_handle, err_code); + pairing_success_evt_send(p_gap_evt, false); + return; + } - err_code = pdb_write_buf_get(peer_id, PM_PEER_DATA_ID_BONDING, 1, &peer_data); - if (err_code != NRF_SUCCESS) - { - send_unexpected_error(conn_handle, err_code); - data_stored = false; - } - else - { - duplicate_peer_id = im_find_duplicate_bonding_data(peer_data.p_bonding_data, - PM_PEER_ID_INVALID); - } + peer_id = im_peer_id_get_by_conn_handle(conn_handle); + + if (peer_id == PM_PEER_ID_INVALID) + { + peer_id = im_find_duplicate_bonding_data(peer_data.p_bonding_data, PM_PEER_ID_INVALID); - if (duplicate_peer_id != PM_PEER_ID_INVALID) + if (peer_id != PM_PEER_ID_INVALID) { // The peer has been identified as someone we have already bonded with. - new_peer_id = duplicate_peer_id; - im_new_peer_id(conn_handle, new_peer_id); + im_new_peer_id(conn_handle, peer_id); // If the flag is true, the configuration has been requested before. if (!allow_repairing(conn_handle)) @@ -534,51 +548,54 @@ static void auth_status_success_process(ble_gap_evt_t const * p_gap_evt) send_config_req(conn_handle); if (!allow_repairing(conn_handle)) { - data_stored = false; + pairing_success_evt_send(p_gap_evt, false); + return; } } } + } - if (data_stored) + if (peer_id == PM_PEER_ID_INVALID) + { + peer_id = pds_peer_id_allocate(); + if (peer_id == PM_PEER_ID_INVALID) { - err_code = pdb_write_buf_store(peer_id, PM_PEER_DATA_ID_BONDING, new_peer_id); - if (err_code != NRF_SUCCESS) - { - /* Unexpected */ - send_unexpected_error(conn_handle, err_code); - data_stored = false; - } + NRF_LOG_ERROR("Could not allocate new peer_id for incoming bond."); + send_unexpected_error(conn_handle, NRF_ERROR_NO_MEM); + pairing_success_evt_send(p_gap_evt, false); + return; } + im_new_peer_id(conn_handle, peer_id); + new_peer_id = true; + } - if ((duplicate_peer_id != PM_PEER_ID_INVALID) && peer_created(conn_handle)) - { - // We already have a bond with the peer. Now that the data has been stored for the - // existing peer, the peer created for this bonding procedure can be freed. - ret_code_t err_code_free = im_peer_free(peer_id); - UNUSED_VARIABLE(err_code_free); // Errors can be safely ignored. - } + err_code = pdb_write_buf_store(PDB_TEMP_PEER_ID(conn_handle), PM_PEER_DATA_ID_BONDING, peer_id); + + if (err_code == NRF_SUCCESS) + { + pairing_success_evt_send(p_gap_evt, true); } - else if (peer_created(conn_handle)) + else if (err_code == NRF_ERROR_STORAGE_FULL) { - ret_code_t err_code_free = im_peer_free(peer_id); - UNUSED_VARIABLE(err_code_free); // Errors can be safely ignored. + send_storage_full_evt(conn_handle); + pairing_success_evt_send(p_gap_evt, true); } else { - // No action. + /* Unexpected error */ + NRF_LOG_ERROR("Could not store bond. pdb_write_buf_store() returned %s. "\ + "conn_handle: %d, peer_id: %d", + nrf_strerror_get(err_code), + conn_handle, + peer_id); + send_unexpected_error(conn_handle, err_code); + pairing_success_evt_send(p_gap_evt, false); + if (new_peer_id) + { + UNUSED_RETURN_VALUE(im_peer_free(peer_id)); // We are already in a bad state. + } } - pm_evt_t pairing_success_evt; - - pairing_success_evt.evt_id = PM_EVT_CONN_SEC_SUCCEEDED; - pairing_success_evt.conn_handle = conn_handle; - pairing_success_evt.params.conn_sec_succeeded.procedure = p_gap_evt->params.auth_status.bonded - ? PM_LINK_SECURED_PROCEDURE_BONDING - : PM_LINK_SECURED_PROCEDURE_PAIRING; - pairing_success_evt.params.conn_sec_succeeded.data_stored = data_stored; - - evt_send(&pairing_success_evt); - return; } @@ -610,6 +627,9 @@ static void auth_status_process(ble_gap_evt_t const * p_gap_evt) default: auth_status_failure_process(p_gap_evt); +#if PM_RA_PROTECTION_ENABLED + ast_auth_error_notify(p_gap_evt->conn_handle); +#endif // PM_RA_PROTECTION_ENABLED break; } } @@ -639,7 +659,7 @@ static void conn_sec_update_process(ble_gap_evt_t const * p_gap_evt) evt.evt_id = PM_EVT_CONN_SEC_SUCCEEDED; evt.conn_handle = p_gap_evt->conn_handle; - evt.params.conn_sec_succeeded.procedure = PM_LINK_SECURED_PROCEDURE_ENCRYPTION; + evt.params.conn_sec_succeeded.procedure = PM_CONN_SEC_PROCEDURE_ENCRYPTION; evt.params.conn_sec_succeeded.data_stored = false; evt_send(&evt); @@ -668,18 +688,26 @@ ret_code_t smd_init(void) flag_id_init(&m_flag_sec_proc); flag_id_init(&m_flag_sec_proc_pairing); flag_id_init(&m_flag_sec_proc_bonding); - flag_id_init(&m_flag_sec_proc_new_peer); flag_id_init(&m_flag_allow_repairing); if ((m_flag_sec_proc == BLE_CONN_STATE_USER_FLAG_INVALID) || (m_flag_sec_proc_pairing == BLE_CONN_STATE_USER_FLAG_INVALID) || (m_flag_sec_proc_bonding == BLE_CONN_STATE_USER_FLAG_INVALID) || - (m_flag_sec_proc_new_peer == BLE_CONN_STATE_USER_FLAG_INVALID) || (m_flag_allow_repairing == BLE_CONN_STATE_USER_FLAG_INVALID)) { + NRF_LOG_ERROR("Could not acquire conn_state user flags. Increase "\ + "BLE_CONN_STATE_USER_FLAG_COUNT in the ble_conn_state module."); return NRF_ERROR_INTERNAL; } +#if PM_RA_PROTECTION_ENABLED + ret_code_t err_code = ast_init(); + if (err_code != NRF_SUCCESS) + { + return err_code; + } +#endif // PM_RA_PROTECTION_ENABLED + m_module_initialized = true; return NRF_SUCCESS; @@ -689,19 +717,17 @@ ret_code_t smd_init(void) /**@brief Function for putting retrieving a buffer and putting pointers into a @ref ble_gap_sec_keyset_t. * * @param[in] conn_handle The connection the security procedure is happening on. - * @param[in] peer_id The peer the security procedure is happening with. * @param[in] role Our role in the connection. * @param[in] p_public_key Pointer to a buffer holding the public key, or NULL. * @param[out] p_sec_keyset Pointer to the keyset to be filled. * * @retval NRF_SUCCESS Success. - * @retval NRF_ERROR_STORAGE_FULL Not enough room in persistent storage. * @retval NRF_ERROR_BUSY Could not process request at this time. Reattempt later. * @retval NRF_ERROR_INVALID_PARAM Data ID or Peer ID was invalid or unallocated. + * @retval NRF_ERROR_INVALID_STATE The link is disconnected. * @retval NRF_ERROR_INTERNAL Fatal error. */ static ret_code_t sec_keyset_fill(uint16_t conn_handle, - pm_peer_id_t peer_id, uint8_t role, ble_gap_lesc_p256_pk_t * p_public_key, ble_gap_sec_keyset_t * p_sec_keyset) @@ -711,11 +737,12 @@ static ret_code_t sec_keyset_fill(uint16_t conn_handle, if (p_sec_keyset == NULL) { + NRF_LOG_ERROR("Internal error: %s received NULL for p_sec_keyset.", __func__); return NRF_ERROR_INTERNAL; } // Acquire a memory buffer to receive bonding data into. - err_code = pdb_write_buf_get(peer_id, PM_PEER_DATA_ID_BONDING, 1, &peer_data); + err_code = pdb_write_buf_get(PDB_TEMP_PEER_ID(conn_handle), PM_PEER_DATA_ID_BONDING, 1, &peer_data); if (err_code == NRF_ERROR_BUSY) { @@ -723,6 +750,10 @@ static ret_code_t sec_keyset_fill(uint16_t conn_handle, } else if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("Could not retrieve RAM buffer for incoming bond. pdb_write_buf_get() "\ + "returned %s. conn_handle: %d", + nrf_strerror_get(err_code), + conn_handle); err_code = NRF_ERROR_INTERNAL; } else /* if (err_code == NRF_SUCCESS) */ @@ -742,14 +773,10 @@ static ret_code_t sec_keyset_fill(uint16_t conn_handle, err_code = im_ble_addr_get(conn_handle, &peer_data.p_bonding_data->peer_ble_id.id_addr_info); if (err_code != NRF_SUCCESS) { - return NRF_ERROR_INTERNAL; - } - - // Buffer is OK, reserve room in flash for the data. - err_code = pdb_write_buf_store_prepare(peer_id, PM_PEER_DATA_ID_BONDING); - if (err_code == NRF_ERROR_NOT_FOUND) - { - return NRF_ERROR_INTERNAL; + NRF_LOG_WARNING("im_ble_addr_get() returned %s. conn_handle: %d. Link was likely disconnected.", + nrf_strerror_get(err_code), + conn_handle); + return NRF_ERROR_INVALID_STATE; } } @@ -763,11 +790,9 @@ ret_code_t smd_params_reply(uint16_t conn_handle, { NRF_PM_DEBUG_CHECK(m_module_initialized); - uint8_t role = ble_conn_state_role(conn_handle); - pm_peer_id_t peer_id = PM_PEER_ID_INVALID; - ret_code_t err_code = NRF_SUCCESS; - uint8_t sec_status = BLE_GAP_SEC_STATUS_SUCCESS; - bool new_peer_created = peer_created(conn_handle); + uint8_t role = ble_conn_state_role(conn_handle); + ret_code_t err_code = NRF_SUCCESS; + uint8_t sec_status = BLE_GAP_SEC_STATUS_SUCCESS; ble_gap_sec_keyset_t sec_keyset; memset(&sec_keyset, 0, sizeof(ble_gap_sec_keyset_t)); @@ -782,41 +807,25 @@ ret_code_t smd_params_reply(uint16_t conn_handle, return BLE_ERROR_INVALID_CONN_HANDLE; } +#if PM_RA_PROTECTION_ENABLED + if (ast_peer_blacklisted(conn_handle)) //Check for repeated attempts here. + { + sec_status = BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS; + } + else +#endif // PM_RA_PROTECTION_ENABLED if (p_sec_params == NULL) { // NULL params means reject pairing. sec_status = BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP; } - else if (!p_sec_params->bond) - { - // Pairing, no bonding. - - sec_keyset.keys_own.p_pk = p_public_key; - sec_keyset.keys_peer.p_pk = &m_peer_pk; - } else { - // Bonding is to be performed, prepare to receive bonding data. - - peer_id = im_peer_id_get_by_conn_handle(conn_handle); - - if (peer_id == PM_PEER_ID_INVALID) - { - // Peer is unknown to us, allocate a new peer ID for it. - peer_id = pdb_peer_allocate(); - if (peer_id != PM_PEER_ID_INVALID) - { - new_peer_created = true; - } - else - { - err_code = NRF_ERROR_INTERNAL; - } - } - else if (role == BLE_GAP_ROLE_PERIPH && !allow_repairing(conn_handle)) + if ((im_peer_id_get_by_conn_handle(conn_handle) != PM_PEER_ID_INVALID) && + (role == BLE_GAP_ROLE_PERIPH) && + !allow_repairing(conn_handle)) { // Bond already exists. Reject the pairing request if the user doesn't intervene. - // send_config_req(conn_handle, peer_id); send_config_req(conn_handle); if (!allow_repairing(conn_handle)) { @@ -825,9 +834,16 @@ ret_code_t smd_params_reply(uint16_t conn_handle, } } - if ((sec_status != BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP) && (err_code == NRF_SUCCESS)) + if (!p_sec_params->bond) { - err_code = sec_keyset_fill(conn_handle, peer_id, role, p_public_key, &sec_keyset); + // Pairing, no bonding. + sec_keyset.keys_own.p_pk = p_public_key; + sec_keyset.keys_peer.p_pk = &m_peer_pk; + } + else if (sec_status != BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP) + { + // Bonding is to be performed, prepare to receive bonding data. + err_code = sec_keyset_fill(conn_handle, role, p_public_key, &sec_keyset); } } @@ -845,10 +861,24 @@ ret_code_t smd_params_reply(uint16_t conn_handle, } } - sec_proc_housekeeping(conn_handle, - peer_id, - (err_code == NRF_SUCCESS) && (sec_status == BLE_GAP_SEC_STATUS_SUCCESS), - new_peer_created); + return err_code; +} + + +/**@brief Function for initiating pairing as a central, or all security as a periheral. + * + * See @ref smd_link_secure and @ref sd_ble_gap_authenticate for more information. + */ +static ret_code_t link_secure_authenticate(uint16_t conn_handle, + ble_gap_sec_params_t * p_sec_params) +{ + ret_code_t err_code = sd_ble_gap_authenticate(conn_handle, p_sec_params); + + if (err_code == NRF_ERROR_NO_MEM) + { + // sd_ble_gap_authenticate() returned NRF_ERROR_NO_MEM. Too many other sec procedures running. + err_code = NRF_ERROR_BUSY; + } return err_code; } @@ -884,7 +914,10 @@ static ret_code_t link_secure_central_encryption(uint16_t conn_handle, { if (err_code != NRF_ERROR_BUSY) { - // Unexpected error code. + NRF_LOG_ERROR("Could not retrieve stored bond. pdb_peer_data_ptr_get() returned %s. "\ + "peer_id: %d", + nrf_strerror_get(err_code), + peer_id); err_code = NRF_ERROR_INTERNAL; } } @@ -907,96 +940,24 @@ static ret_code_t link_secure_central_encryption(uint16_t conn_handle, &(p_existing_key->enc_info)); } - sec_proc_start(conn_handle, err_code == NRF_SUCCESS, PM_LINK_SECURED_PROCEDURE_ENCRYPTION); - sec_proc_housekeeping(conn_handle, peer_id, (err_code == NRF_SUCCESS), false); - - return err_code; -} - - -/**@brief Function for intiating pairing as a central. See @ref smd_link_secure for more info. - */ -static ret_code_t link_secure_central_pairing(uint16_t conn_handle, - pm_peer_id_t peer_id, - ble_gap_sec_params_t * p_sec_params) -{ - pm_conn_sec_procedure_t procedure = PM_LINK_SECURED_PROCEDURE_PAIRING; - bool new_peer_created = false; - ret_code_t err_code = NRF_SUCCESS; - pm_peer_data_t dummy_peer_data; - - if (p_sec_params == NULL) - { - err_code = sd_ble_gap_authenticate(conn_handle, NULL); - } - else - { - if (p_sec_params->bond) - { - procedure = PM_LINK_SECURED_PROCEDURE_BONDING; - - if (peer_id == PM_PEER_ID_INVALID) - { - // New peer is required. - peer_id = pdb_peer_allocate(); - new_peer_created = true; - } - - if (peer_id == PM_PEER_ID_INVALID) - { - err_code = NRF_ERROR_INTERNAL; - } - else - { - err_code = pdb_write_buf_get(peer_id, PM_PEER_DATA_ID_BONDING, 1, &dummy_peer_data); - if (err_code == NRF_SUCCESS) - { - err_code = pdb_write_buf_store_prepare(peer_id, PM_PEER_DATA_ID_BONDING); - } - } - } - - if (err_code == NRF_SUCCESS) - { - err_code = sd_ble_gap_authenticate(conn_handle, p_sec_params); - } - - if (err_code != NRF_SUCCESS) - { - ret_code_t err_code_free = pdb_write_buf_release(peer_id, PM_PEER_DATA_ID_BONDING); - if ((err_code_free != NRF_SUCCESS) && (err_code_free != NRF_ERROR_NOT_FOUND)) - { - err_code = NRF_ERROR_INTERNAL; - } - } - } - - if (err_code == NRF_ERROR_NO_MEM) - { - // sd_ble_gap_authenticate() returned NRF_ERROR_NO_MEM. Too many other sec procedures running. - err_code = NRF_ERROR_BUSY; - } - - sec_proc_start(conn_handle, err_code == NRF_SUCCESS, procedure); - sec_proc_housekeeping(conn_handle, peer_id, (err_code == NRF_SUCCESS), new_peer_created); + sec_proc_start(conn_handle, err_code == NRF_SUCCESS, PM_CONN_SEC_PROCEDURE_ENCRYPTION); return err_code; } - /**@brief Function for intiating security as a central. See @ref smd_link_secure for more info. */ -static ret_code_t link_secure_central(uint16_t conn_handle, +static ret_code_t link_secure_central(uint16_t conn_handle, ble_gap_sec_params_t * p_sec_params, - bool force_repairing) + bool force_repairing) { ret_code_t err_code; pm_peer_id_t peer_id; if (p_sec_params == NULL) { - return sd_ble_gap_authenticate(conn_handle, NULL); + return link_secure_authenticate(conn_handle, NULL); } // Set the default value for allowing repairing at the start of the sec proc. (for central) @@ -1007,39 +968,42 @@ static ret_code_t link_secure_central(uint16_t conn_handle, if ((peer_id != PM_PEER_ID_INVALID) && !force_repairing) { // There is already data in flash for this peer, and repairing has not been requested, so - // link will be encrypted with the existing keys. + // the link will be encrypted with the existing keys. err_code = link_secure_central_encryption(conn_handle, peer_id); } else { // There are no existing keys, or repairing has been explicitly requested, so pairing // (possibly including bonding) will be performed to encrypt the link. - err_code = link_secure_central_pairing(conn_handle, peer_id, p_sec_params); + err_code = link_secure_authenticate(conn_handle, p_sec_params); + pm_conn_sec_procedure_t procedure = (p_sec_params && p_sec_params->bond) ? + PM_CONN_SEC_PROCEDURE_BONDING : + PM_CONN_SEC_PROCEDURE_PAIRING; + sec_proc_start(conn_handle, err_code == NRF_SUCCESS, procedure); } return err_code; } - /**@brief Function for processing the @ref BLE_GAP_EVT_SEC_REQUEST event from the SoftDevice. * * @param[in] p_gap_evt The event from the SoftDevice. */ static void sec_request_process(ble_gap_evt_t const * p_gap_evt) { + if (sec_procedure(p_gap_evt->conn_handle)) + { + // Ignore request as per spec. + return; + } + pm_evt_t evt = { .evt_id = PM_EVT_SLAVE_SECURITY_REQ, - .conn_handle = p_gap_evt->conn_handle, - .params = - { - .slave_security_req = - { - .bond = p_gap_evt->params.sec_request.bond, - .mitm = p_gap_evt->params.sec_request.mitm, - } - } + .conn_handle = p_gap_evt->conn_handle }; + memcpy(&evt.params.slave_security_req, &p_gap_evt->params.sec_request, sizeof(ble_gap_evt_sec_request_t)); + evt_send(&evt); return; } @@ -1054,7 +1018,7 @@ static ret_code_t link_secure_peripheral(uint16_t conn_handle, ble_gap_sec_param if (p_sec_params != NULL) { - err_code = sd_ble_gap_authenticate(conn_handle, p_sec_params); + err_code = link_secure_authenticate(conn_handle, p_sec_params); } return err_code; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_dispatcher.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_dispatcher.h similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_dispatcher.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_dispatcher.h index 1ddd086..f8528ad 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_dispatcher.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_dispatcher.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SECURITY_DISPATCHER_H__ #define SECURITY_DISPATCHER_H__ @@ -110,8 +110,6 @@ void smd_conn_sec_config_reply(uint16_t conn_handle, pm_conn_sec_config_t * p_co * @retval NRF_ERROR_TIMEOUT There has been an SMP timeout, so no more SMP operations * can be performed on this link. * @retval BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. - * @retval NRF_ERROR_STORAGE_FULL No more room in flash. Fix and reattempt after the next - * FDS garbage collection procedure. * @retval NRF_ERROR_BUSY No write buffer. Reattempt later. * @retval NRF_ERROR_INTERNAL A fatal error occurred. */ @@ -140,12 +138,12 @@ ret_code_t smd_params_reply(uint16_t conn_handle, * @retval NRF_ERROR_INVALID_STATE A security procedure is already in progress on the link, * or the link is disconnecting. * @retval NRF_ERROR_INVALID_PARAM Invalid combination of parameters (not including conn_handle). + * @retval NRF_ERROR_INVALID_DATA Peer is bonded, but no LTK was found, and repairing was + * not requested. * @retval NRF_ERROR_BUSY Unable to initiate procedure at this time. * @retval NRF_ERROR_TIMEOUT There has been an SMP timeout, so no more SMP operations * can be performed on this link. * @retval BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. - * @retval NRF_ERROR_STORAGE_FULL No more room in flash. Fix and reattempt after the next - * FDS garbage collection procedure. * @retval NRF_ERROR_INTERNAL No more available peer IDs. */ ret_code_t smd_link_secure(uint16_t conn_handle, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_manager.c similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_manager.c index c2c8ad7..afef4a0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(PEER_MANAGER) @@ -47,6 +47,23 @@ #include "peer_database.h" #include "ble_conn_state.h" #include "id_manager.h" +#include "sdk_common.h" + +#if PM_LESC_ENABLED +#include "nrf_ble_lesc.h" +#endif +#define NRF_LOG_MODULE_NAME peer_manager_sm +#if PM_LOG_ENABLED + #define NRF_LOG_LEVEL PM_LOG_LEVEL + #define NRF_LOG_INFO_COLOR PM_LOG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR PM_LOG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // PM_LOG_ENABLED +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); +#include "nrf_strerror.h" // The number of registered event handlers. @@ -78,14 +95,14 @@ static ble_gap_sec_params_t m_sec_params; //!< The buffe static ble_gap_sec_params_t * mp_sec_params = NULL; //!< The default security parameters set by @ref sm_sec_params_set. static bool m_sec_params_set = false; //!< Whether @ref sm_sec_params_set has been called. +#if PM_LESC_ENABLED == 0 static ble_gap_lesc_p256_pk_t * m_p_public_key; //!< Pointer, provided by the user, to the public key to use for LESC procedures. +#endif static ble_conn_state_user_flag_id_t m_flag_link_secure_pending_busy = BLE_CONN_STATE_USER_FLAG_INVALID; //!< User flag indicating whether a connection has a pending call to @ref sm_link_secure because it returned @ref NRF_ERROR_BUSY. -static ble_conn_state_user_flag_id_t m_flag_link_secure_pending_flash_full = BLE_CONN_STATE_USER_FLAG_INVALID; //!< User flag indicating whether a connection has a pending call to @ref sm_link_secure because it returned @ref NRF_ERROR_STORAGE_FULL. static ble_conn_state_user_flag_id_t m_flag_link_secure_force_repairing = BLE_CONN_STATE_USER_FLAG_INVALID; //!< User flag indicating whether a pending call to @ref sm_link_secure should be called with true for the force_repairing parameter. static ble_conn_state_user_flag_id_t m_flag_link_secure_null_params = BLE_CONN_STATE_USER_FLAG_INVALID; //!< User flag indicating whether a pending call to @ref sm_link_secure should be called with NULL security parameters. static ble_conn_state_user_flag_id_t m_flag_params_reply_pending_busy = BLE_CONN_STATE_USER_FLAG_INVALID; //!< User flag indicating whether a connection has a pending call to @ref sm_sec_params_reply because it returned @ref NRF_ERROR_BUSY. -static ble_conn_state_user_flag_id_t m_flag_params_reply_pending_flash_full = BLE_CONN_STATE_USER_FLAG_INVALID; //!< User flag indicating whether a connection has a pending call to @ref sm_sec_params_reply because it returned @ref NRF_ERROR_STORAGE_FULL. /**@brief Function for sending an SM event to all registered event handlers. @@ -111,45 +128,28 @@ static void evt_send(pm_evt_t * p_event) */ static void flags_set_from_err_code(uint16_t conn_handle, ret_code_t err_code, bool params_reply) { - bool flag_value_flash_full = false; bool flag_value_busy = false; - if ((err_code == NRF_ERROR_STORAGE_FULL)) - { - flag_value_busy = false; - flag_value_flash_full = true; - } - else if (err_code == NRF_ERROR_BUSY) + if (err_code == NRF_ERROR_BUSY) { flag_value_busy = true; - flag_value_flash_full = false; } else { flag_value_busy = false; - flag_value_flash_full = false; } if (params_reply) { - ble_conn_state_user_flag_set(conn_handle, - m_flag_params_reply_pending_flash_full, - flag_value_flash_full); ble_conn_state_user_flag_set(conn_handle, m_flag_params_reply_pending_busy, flag_value_busy); - ble_conn_state_user_flag_set(conn_handle, - m_flag_link_secure_pending_flash_full, - false); ble_conn_state_user_flag_set(conn_handle, m_flag_link_secure_pending_busy, false); } else { - ble_conn_state_user_flag_set(conn_handle, - m_flag_link_secure_pending_flash_full, - flag_value_flash_full); ble_conn_state_user_flag_set(conn_handle, m_flag_link_secure_pending_busy, flag_value_busy); @@ -157,6 +157,48 @@ static void flags_set_from_err_code(uint16_t conn_handle, ret_code_t err_code, b } +static inline pm_evt_t new_evt(pm_evt_id_t evt_id, uint16_t conn_handle) +{ + pm_evt_t evt = + { + .evt_id = evt_id, + .conn_handle = conn_handle, + .peer_id = im_peer_id_get_by_conn_handle(conn_handle) + }; + return evt; +} + + +/**@brief Function for sending a PM_EVT_ERROR_UNEXPECTED event. + * + * @param[in] conn_handle The connection handle the event pertains to. + * @param[in] err_code The unexpected error that occurred. + */ +static void send_unexpected_error(uint16_t conn_handle, ret_code_t err_code) +{ + pm_evt_t error_evt = new_evt(PM_EVT_ERROR_UNEXPECTED, conn_handle); + error_evt.params.error_unexpected.error = err_code; + evt_send(&error_evt); +} + + +/**@brief Returns whether the LTK came from LESC bonding. + * + * @param[in] peer_id The peer to check. + * + * @return Whether the key is LESC or not. + */ +static bool key_is_lesc(pm_peer_id_t peer_id) +{ + pm_peer_data_flash_t peer_data; + ret_code_t err_code; + + err_code = pdb_peer_data_ptr_get(peer_id, PM_PEER_DATA_ID_BONDING, &peer_data); + + return (err_code == NRF_SUCCESS) && (peer_data.p_bonding_data->own_ltk.enc_info.lesc); +} + + /**@brief Function for sending an event based on error codes returned from @ref smd_link_secure or * @ref smd_params_reply. * @@ -172,30 +214,29 @@ static void events_send_from_err_code(uint16_t conn_handle, { if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY) && (err_code != NRF_ERROR_INVALID_STATE)) { - pm_evt_t evt = - { - .conn_handle = conn_handle, - .peer_id = im_peer_id_get_by_conn_handle(conn_handle), - }; if (err_code == NRF_ERROR_TIMEOUT) { - evt.evt_id = PM_EVT_CONN_SEC_FAILED; + NRF_LOG_WARNING("Cannot secure link because a previous security procedure ended in timeout. "\ + "Disconnect and retry. smd_params_reply() or smd_link_secure() returned "\ + "NRF_ERROR_TIMEOUT. conn_handle: %d", + conn_handle); + + pm_evt_t evt = new_evt(PM_EVT_CONN_SEC_FAILED, conn_handle); evt.params.conn_sec_failed.procedure = ((p_sec_params != NULL) && p_sec_params->bond) - ? PM_LINK_SECURED_PROCEDURE_BONDING - : PM_LINK_SECURED_PROCEDURE_PAIRING; + ? PM_CONN_SEC_PROCEDURE_BONDING + : PM_CONN_SEC_PROCEDURE_PAIRING; evt.params.conn_sec_failed.error_src = BLE_GAP_SEC_STATUS_SOURCE_LOCAL; evt.params.conn_sec_failed.error = PM_CONN_SEC_ERROR_SMP_TIMEOUT; - } - else if (err_code == NRF_ERROR_STORAGE_FULL) - { - evt.evt_id = PM_EVT_STORAGE_FULL; + evt_send(&evt); } else { - evt.evt_id = PM_EVT_ERROR_UNEXPECTED; - evt.params.error_unexpected.error = err_code; + NRF_LOG_ERROR("Could not perform security procedure. smd_params_reply() or "\ + "smd_link_secure() returned %s. conn_handle: %d", + nrf_strerror_get(err_code), + conn_handle); + send_unexpected_error(conn_handle, err_code); } - evt_send(&evt); } } @@ -211,10 +252,7 @@ static void params_req_send(uint16_t conn_handle, ble_gap_sec_params_t const * p_peer_params, sec_params_reply_context_t * p_context) { - pm_evt_t evt; - evt.evt_id = PM_EVT_CONN_SEC_PARAMS_REQ; - evt.conn_handle = conn_handle; - evt.peer_id = im_peer_id_get_by_conn_handle(conn_handle); + pm_evt_t evt = new_evt(PM_EVT_CONN_SEC_PARAMS_REQ, conn_handle); evt.params.conn_sec_params_req.p_peer_params = p_peer_params; evt.params.conn_sec_params_req.p_context = p_context; @@ -284,17 +322,18 @@ static ret_code_t link_secure(uint16_t conn_handle, ble_conn_state_user_flag_set(conn_handle, m_flag_link_secure_force_repairing, force_repairing); return_err_code = NRF_SUCCESS; break; - case NRF_ERROR_STORAGE_FULL: - ble_conn_state_user_flag_set(conn_handle, m_flag_link_secure_null_params, null_params); - ble_conn_state_user_flag_set(conn_handle, m_flag_link_secure_force_repairing, force_repairing); - /* fallthrough */ case NRF_SUCCESS: case NRF_ERROR_TIMEOUT: case BLE_ERROR_INVALID_CONN_HANDLE: case NRF_ERROR_INVALID_STATE: + case NRF_ERROR_INVALID_DATA: return_err_code = err_code; break; default: + NRF_LOG_ERROR("Could not perform security procedure. smd_link_secure() returned %s. "\ + "conn_handle: %d", + nrf_strerror_get(err_code), + conn_handle); return_err_code = NRF_ERROR_INTERNAL; break; } @@ -316,11 +355,17 @@ static ret_code_t link_secure(uint16_t conn_handle, static void smd_params_reply_perform(uint16_t conn_handle, ble_gap_sec_params_t const * p_peer_params) { ret_code_t err_code; + ble_gap_lesc_p256_pk_t * p_public_key; sec_params_reply_context_t context = new_context_get(); params_req_send(conn_handle, p_peer_params, &context); - err_code = smd_params_reply(conn_handle, context.p_sec_params, m_p_public_key); +#if PM_LESC_ENABLED + p_public_key = nrf_ble_lesc_public_key_get(); +#else + p_public_key = m_p_public_key; +#endif // PM_LESC_ENABLED + err_code = smd_params_reply(conn_handle, context.p_sec_params, p_public_key); flags_set_from_err_code(conn_handle, err_code, true); events_send_from_err_code(conn_handle, err_code, context.p_sec_params); @@ -337,32 +382,72 @@ static __INLINE void params_req_process(pm_evt_t const * p_event) } +ret_code_t sm_conn_sec_status_get(uint16_t conn_handle, pm_conn_sec_status_t * p_conn_sec_status) +{ + VERIFY_PARAM_NOT_NULL(p_conn_sec_status); + + ble_conn_state_status_t status = ble_conn_state_status(conn_handle); + + if (status == BLE_CONN_STATUS_INVALID) + { + return BLE_ERROR_INVALID_CONN_HANDLE; + } + + pm_peer_id_t peer_id = im_peer_id_get_by_conn_handle(conn_handle); + + p_conn_sec_status->connected = (status == BLE_CONN_STATUS_CONNECTED); + p_conn_sec_status->bonded = (peer_id != PM_PEER_ID_INVALID); + p_conn_sec_status->encrypted = ble_conn_state_encrypted(conn_handle); + p_conn_sec_status->mitm_protected = ble_conn_state_mitm_protected(conn_handle); + p_conn_sec_status->lesc = ble_conn_state_lesc(conn_handle) + || (ble_conn_state_encrypted(conn_handle) + && key_is_lesc(peer_id)); + return NRF_SUCCESS; +} + + +bool sm_sec_is_sufficient(uint16_t conn_handle, pm_conn_sec_status_t * p_sec_status_req) +{ + pm_conn_sec_status_t sec_status = {.reserved = ~0}; // Set all bits in reserved to 1 so they are + // ignored in subsequent logic. + ret_code_t err_code = sm_conn_sec_status_get(conn_handle, &sec_status); + + STATIC_ASSERT(sizeof(pm_conn_sec_status_t) == sizeof(uint8_t)); + + uint8_t unmet_reqs = (~(*((uint8_t *) &sec_status)) & *((uint8_t *) p_sec_status_req)); + + return (err_code == NRF_SUCCESS) && !unmet_reqs; +} + + /**@brief Function for handling @ref PM_EVT_SLAVE_SECURITY_REQ events. * * @param[in] p_event The @ref PM_EVT_SLAVE_SECURITY_REQ event. */ static void sec_req_process(pm_evt_t const * p_event) { + ret_code_t err_code; bool null_params = false; + bool force_repairing = false; + if (mp_sec_params == NULL) { null_params = true; } - else if ((bool)m_sec_params.bond < (bool)p_event->params.slave_security_req.bond) + else if (ble_conn_state_encrypted(p_event->conn_handle)) { - null_params = true; - } - else if ((bool)m_sec_params.mitm < (bool)p_event->params.slave_security_req.mitm) - { - null_params = true; - } - else - { - // No action. + pm_conn_sec_status_t sec_status_req = + { + .bonded = p_event->params.slave_security_req.bond, + .mitm_protected = p_event->params.slave_security_req.mitm, + .lesc = p_event->params.slave_security_req.lesc, + }; + + force_repairing = !sm_sec_is_sufficient(p_event->conn_handle, &sec_status_req); } - ret_code_t err_code = link_secure(p_event->conn_handle, null_params, false, true); - UNUSED_VARIABLE(err_code); // It is acceptable to ignore the return code because it is - // acceptable to ignore a security request. + + err_code = link_secure(p_event->conn_handle, null_params, force_repairing, true); + UNUSED_VARIABLE(err_code); // The error code has been properly handled inside link_secure(). } @@ -399,59 +484,27 @@ void sm_smd_evt_handler(pm_evt_t * p_event) } -/**@brief Function for checking our user flags for pending calls to @ref smd_link_secure. - * - * @details This function will attempt to perform any pending calls. - * - * @param[in] flag_id The user flag to check. Must be either @ref m_flag_link_secure_pending_busy - * or @ref m_flag_link_secure_pending_flash_full. +/**@brief Function handling a pending params_reply. See @ref ble_conn_state_user_function_t. */ -static void link_secure_pending_process(ble_conn_state_user_flag_id_t flag_id) +static void params_reply_pending_handle(uint16_t conn_handle, void * p_context) { - sdk_mapped_flags_t flag_collection = ble_conn_state_user_flag_collection(flag_id); - if (sdk_mapped_flags_any_set(flag_collection)) - { - sdk_mapped_flags_key_list_t conn_handle_list = ble_conn_state_conn_handles(); - - for (uint32_t i = 0; i < conn_handle_list.len; i++) - { - bool pending = ble_conn_state_user_flag_get(conn_handle_list.flag_keys[i], flag_id); - if (pending) - { - bool force_repairing = ble_conn_state_user_flag_get(conn_handle_list.flag_keys[i], m_flag_link_secure_force_repairing); - bool null_params = ble_conn_state_user_flag_get(conn_handle_list.flag_keys[i], m_flag_link_secure_null_params); - - ret_code_t err_code = link_secure(conn_handle_list.flag_keys[i], null_params, force_repairing, true); // If this fails, it will be automatically retried. - UNUSED_VARIABLE(err_code); - } - } - } + UNUSED_PARAMETER(p_context); + smd_params_reply_perform(conn_handle, NULL); } -/**@brief Function for checking our user flags for pending calls to @ref smd_params_reply. - * - * @details This function will attempt to perform any pending calls. - * - * @param[in] flag_id The user flag to check. Must be either @ref m_flag_params_reply_pending_busy - * or @ref m_flag_params_reply_pending_flash_full. +/**@brief Function handling a pending link_secure. See @ref ble_conn_state_user_function_t. */ -static void params_reply_pending_process(ble_conn_state_user_flag_id_t flag_id) +static void link_secure_pending_handle(uint16_t conn_handle, void * p_context) { - sdk_mapped_flags_t flag_collection = ble_conn_state_user_flag_collection(flag_id); - if (sdk_mapped_flags_any_set(flag_collection)) - { - sdk_mapped_flags_key_list_t conn_handle_list = ble_conn_state_conn_handles(); + UNUSED_PARAMETER(p_context); - for (uint32_t i = 0; i < conn_handle_list.len; i++) - { - bool pending = ble_conn_state_user_flag_get(conn_handle_list.flag_keys[i], flag_id); - if (pending) - { - smd_params_reply_perform(conn_handle_list.flag_keys[i], NULL); - } - } - } + bool force_repairing = ble_conn_state_user_flag_get(conn_handle, m_flag_link_secure_force_repairing); + bool null_params = ble_conn_state_user_flag_get(conn_handle, m_flag_link_secure_null_params); + + // If this fails, it will be automatically retried. + ret_code_t err_code = link_secure(conn_handle, null_params, force_repairing, true); + UNUSED_VARIABLE(err_code); } @@ -465,15 +518,16 @@ void sm_pdb_evt_handler(pm_evt_t * p_event) switch (p_event->evt_id) { case PM_EVT_FLASH_GARBAGE_COLLECTED: - params_reply_pending_process(m_flag_params_reply_pending_flash_full); - link_secure_pending_process(m_flag_link_secure_pending_flash_full); - /* fallthrough */ case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED: case PM_EVT_PEER_DATA_UPDATE_FAILED: case PM_EVT_PEER_DELETE_SUCCEEDED: case PM_EVT_PEER_DELETE_FAILED: - params_reply_pending_process(m_flag_params_reply_pending_busy); - link_secure_pending_process(m_flag_link_secure_pending_busy); + (void) ble_conn_state_for_each_set_user_flag(m_flag_params_reply_pending_busy, + params_reply_pending_handle, + NULL); + (void) ble_conn_state_for_each_set_user_flag(m_flag_link_secure_pending_busy, + link_secure_pending_handle, + NULL); break; default: // Do nothing. @@ -499,15 +553,23 @@ ret_code_t sm_init(void) { NRF_PM_DEBUG_CHECK(!m_module_initialized); +#if PM_LESC_ENABLED + ret_code_t err_code = nrf_ble_lesc_init(); + if (err_code != NRF_SUCCESS) + { + return err_code; + } +#endif + flag_id_init(&m_flag_link_secure_pending_busy); - flag_id_init(&m_flag_link_secure_pending_flash_full); flag_id_init(&m_flag_link_secure_force_repairing); flag_id_init(&m_flag_link_secure_null_params); flag_id_init(&m_flag_params_reply_pending_busy); - flag_id_init(&m_flag_params_reply_pending_flash_full); - if (m_flag_params_reply_pending_flash_full == BLE_CONN_STATE_USER_FLAG_INVALID) + if (m_flag_params_reply_pending_busy == BLE_CONN_STATE_USER_FLAG_INVALID) { + NRF_LOG_ERROR("Could not acquire conn_state user flags. Increase "\ + "BLE_CONN_STATE_USER_FLAG_COUNT in the ble_conn_state module."); return NRF_ERROR_INTERNAL; } @@ -522,7 +584,15 @@ void sm_ble_evt_handler(ble_evt_t const * p_ble_evt) NRF_PM_DEBUG_CHECK(p_ble_evt != NULL); smd_ble_evt_handler(p_ble_evt); - link_secure_pending_process(m_flag_link_secure_pending_busy); +#if PM_LESC_ENABLED + nrf_ble_lesc_on_ble_evt(p_ble_evt); +#endif + (void) ble_conn_state_for_each_set_user_flag(m_flag_params_reply_pending_busy, + params_reply_pending_handle, + NULL); + (void) ble_conn_state_for_each_set_user_flag(m_flag_link_secure_pending_busy, + link_secure_pending_handle, + NULL); } @@ -677,9 +747,13 @@ ret_code_t sm_lesc_public_key_set(ble_gap_lesc_p256_pk_t * p_public_key) { NRF_PM_DEBUG_CHECK(m_module_initialized); +#if PM_LESC_ENABLED + return NRF_ERROR_FORBIDDEN; +#else m_p_public_key = p_public_key; return NRF_SUCCESS; +#endif // PM_LESC_ENABLED } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_manager.h similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_manager.h index 79cab52..279e3e5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/peer_manager/security_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/ble/peer_manager/security_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SECURITY_MANAGER_H__ #define SECURITY_MANAGER_H__ @@ -142,6 +142,30 @@ ret_code_t sm_sec_params_reply(uint16_t conn_handle, ret_code_t sm_lesc_public_key_set(ble_gap_lesc_p256_pk_t * p_public_key); +/**@brief Function for getting the security status of a connection. + * + * @param[in] conn_handle Connection handle of the link as provided by the SoftDevice. + * @param[out] p_conn_sec_status Security status of the link. + * + * @retval NRF_SUCCESS If pairing was initiated successfully. + * @retval BLE_ERROR_INVALID_CONN_HANDLE If the connection handle is invalid. + * @retval NRF_ERROR_NULL If @p p_conn_sec_status was NULL. + */ +ret_code_t sm_conn_sec_status_get(uint16_t conn_handle, pm_conn_sec_status_t * p_conn_sec_status); + + +/**@brief Function for comparing the security status of a connection against a baseline. + * + * @param[in] conn_handle Connection handle of the link as provided by the SoftDevice. + * @param[out] p_sec_status_req Target baseline security status to compare against. + * + * @retval true If the security status of the connection matches or exceeds the baseline on all + * points. + * @retval false If the security status of the connection does not fulfill the baseline, or could + * not be retrieved. + */ +bool sm_sec_is_sufficient(uint16_t conn_handle, pm_conn_sec_status_t * p_sec_status_req); + /**@brief Function for initiating security on the link, with the specified parameters. * @@ -160,6 +184,8 @@ ret_code_t sm_lesc_public_key_set(ble_gap_lesc_p256_pk_t * p_public_key); * @retval NRF_ERROR_TIMEOUT There has been an SMP timeout, so no more SMP operations * can be performed on this link. * @retval BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. + * @retval NRF_ERROR_INVALID_DATA Peer is bonded, but no LTK was found, and repairing was + * not requested. * @retval NRF_ERROR_NOT_FOUND Security parameters have not been set. * @retval NRF_ERROR_INVALID_STATE A security procedure is already in progress on the link, * or the link is disconnecting. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_error.h similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_error.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_error.h index 6ae2c9b..8a682e7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_error.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_error.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,9 +35,19 @@ * 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. - * + * */ /* Header guard */ + +#ifndef SOFTDEVICE_PRESENT + +/** + @defgroup nrf_error Global Error Codes + @{ + + @brief Global Error definitions +*/ + #ifndef NRF_ERROR_H__ #define NRF_ERROR_H__ @@ -45,8 +55,6 @@ extern "C" { #endif -/// @cond Make doxygen skip this file - /** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions * @{ */ #define NRF_ERROR_BASE_NUM (0x0) ///< Global error base @@ -74,14 +82,14 @@ extern "C" { #define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address #define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy - #ifdef __cplusplus } #endif #endif // NRF_ERROR_H__ -/// @endcond /** @} */ + +#endif // SOFTDEVICE_PRESENT diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c index 45803bf..f59eda8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include "nrf_soc.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h index 3ab15d6..197aece 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_NVIC_H__ #define NRF_NVIC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_sdm.h similarity index 82% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_sdm.h index 41eb43c..e5d12bd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_sdm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,18 +35,22 @@ * 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 - -/** * - * @defgroup nfc_ble_pair_common Common data for Connection Handover and Connection Handover Parser modules - * @{ - * @ingroup nfc_ble_pair_msg */ +#ifndef NRF_SDM_H__ +#define NRF_SDM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */ +#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_SDM_H__ -/* Record Payload Type for Bluetooth Carrier Configuration LE record */ -extern const uint8_t le_oob_rec_type_field[32]; -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c index 8b273d7..f89e556 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include "nrf_soc.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h index 3119ada..aaa6803 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SOC_H__ #define NRF_SOC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/radio_config/radio_config.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/radio_config/radio_config.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/radio_config/radio_config.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/radio_config/radio_config.c index 5f529a7..1746df3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/radio_config/radio_config.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/radio_config/radio_config.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @addtogroup nrf_dev_radio_rx_example_main nrf_dev_radio_tx_example_main diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/radio_config/radio_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/radio_config/radio_config.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/radio_config/radio_config.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/radio_config/radio_config.h index 2b4cacd..37c308d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/radio_config/radio_config.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/radio_config/radio_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 RADIO_CONFIG_H #define RADIO_CONFIG_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/config/sdio_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/config/sdio_config.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/config/sdio_config.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/config/sdio_config.h index f59e553..db7cae8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/config/sdio_config.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/config/sdio_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SDIO_CONFIG_H #define SDIO_CONFIG_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/sdio.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/sdio.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/sdio.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/sdio.c index 381c77d..869e69b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/sdio.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/sdio.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/sdio.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/sdio.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/sdio.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/sdio.h index e52e7e9..740605b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/sdio/sdio.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/sdio/sdio.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SDIO_H #define SDIO_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/spi_5W_master.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/spi_master/spi_5W_master.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/spi_5W_master.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/spi_master/spi_5W_master.c index c8ac416..c51b98c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/spi_5W_master.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/spi_master/spi_5W_master.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/spi_5W_master.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/spi_master/spi_5W_master.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/spi_5W_master.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/spi_master/spi_5W_master.h index 7b827bf..f5b65b4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/spi_5W_master.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/spi_master/spi_5W_master.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_SPI_MASTER_H #define APP_SPI_MASTER_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h index 8a161cc..325bc5a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/config/twi_master_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 TWI_MASTER_CONFIG #define TWI_MASTER_CONFIG diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c index 767abf0..eca4475 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_hw_master.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "twi_master.h" #include "twi_master_config.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_master.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_master.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_master.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_master.h index 4bceb87..35d487f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_master.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_master.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 TWI_MASTER_H #define TWI_MASTER_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c index 44f03da..74acc60 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/drivers_nrf/twi_master/deprecated/twi_sw_master.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2009 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2009 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.c similarity index 60% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.c index 32ae346..cf46812 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,24 +35,9 @@ * 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 nrf_atomic Atomic operations API - * @ingroup nrf_atfifo - * @{ * - * @brief @tagAPI52 This module implements C11 stdatomic.h simplified API. - At this point only Cortex-M3/M4 cores are supported (LDREX/STREX instructions). - * Atomic types are limited to @ref nrf_atomic_u32_t and @ref nrf_atomic_flag_t. */ - -#ifndef NRF_ATOMIC_H__ -#define NRF_ATOMIC_H__ - -#include "sdk_common.h" - +#include "nrf_atomic.h" #ifndef NRF_ATOMIC_USE_BUILD_IN #if (defined(__GNUC__) && defined(WIN32)) @@ -68,33 +53,12 @@ #include "app_util_platform.h" #endif -/** - * @brief Atomic 32 bit unsigned type - * */ -typedef volatile uint32_t nrf_atomic_u32_t; - -/** - * @brief Atomic 1 bit flag type (technically 32 bit) - * */ -typedef volatile uint32_t nrf_atomic_flag_t; #if (NRF_ATOMIC_USE_BUILD_IN == 0) && defined(STREX_LDREX_PRESENT) #include "nrf_atomic_internal.h" #endif -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Stores value to an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value to store - * - * @return Old value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_exchange_n(p_data, value, __ATOMIC_SEQ_CST); @@ -116,15 +80,7 @@ static inline uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uin #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Stores value to an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value to store - * - * @return New value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN __atomic_store_n(p_data, value, __ATOMIC_SEQ_CST); @@ -146,15 +102,7 @@ static inline uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Logical OR operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand OR operation - * - * @return Old value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_fetch_or(p_data, value, __ATOMIC_SEQ_CST); @@ -175,15 +123,7 @@ static inline uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32 #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Logical OR operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand OR operation - * - * @return New value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_or_fetch(p_data, value, __ATOMIC_SEQ_CST); @@ -204,15 +144,7 @@ static inline uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t val #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Logical AND operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand AND operation - * - * @return Old value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_fetch_and(p_data, value, __ATOMIC_SEQ_CST); @@ -233,15 +165,7 @@ static inline uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint3 #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Logical AND operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand AND operation - * - * @return New value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_and_fetch(p_data, value, __ATOMIC_SEQ_CST); @@ -262,15 +186,7 @@ static inline uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t va #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Logical XOR operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand XOR operation - * - * @return Old value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_fetch_xor(p_data, value, __ATOMIC_SEQ_CST); @@ -291,15 +207,7 @@ static inline uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint3 #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Logical XOR operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand XOR operation - * - * @return New value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_xor_fetch(p_data, value, __ATOMIC_SEQ_CST); @@ -320,15 +228,7 @@ static inline uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t va #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Arithmetic ADD operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand ADD operation - * - * @return Old value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_fetch_add(p_data, value, __ATOMIC_SEQ_CST); @@ -349,15 +249,7 @@ static inline uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint3 #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Arithmetic ADD operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand ADD operation - * - * @return New value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_add_fetch(p_data, value, __ATOMIC_SEQ_CST); @@ -378,15 +270,7 @@ static inline uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t va #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Arithmetic SUB operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand SUB operation - * - * @return Old value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_fetch_sub(p_data, value, __ATOMIC_SEQ_CST); @@ -407,15 +291,7 @@ static inline uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint3 #endif //NRF_ATOMIC_USE_BUILD_IN } -/** - * @brief Arithmetic SUB operation on an atomic object - * - * @param[in] p_data Atomic memory pointer - * @param[in] value Value of second operand SUB operation - * - * @return New value stored into atomic object - * */ -static inline uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value) +uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value) { #if NRF_ATOMIC_USE_BUILD_IN return __atomic_sub_fetch(p_data, value, __ATOMIC_SEQ_CST); @@ -436,60 +312,138 @@ static inline uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t va #endif //NRF_ATOMIC_USE_BUILD_IN } -/**************************************************************************************************/ +bool nrf_atomic_u32_cmp_exch(nrf_atomic_u32_t * p_data, + uint32_t * p_expected, + uint32_t desired) +{ +#if NRF_ATOMIC_USE_BUILD_IN + return __atomic_compare_exchange(p_data, + p_expected, + &desired, + 1, + __ATOMIC_SEQ_CST, + __ATOMIC_SEQ_CST); +#elif defined(STREX_LDREX_PRESENT) + return nrf_atomic_internal_cmp_exch(p_data, p_expected, desired); +#else + bool ret; + CRITICAL_REGION_ENTER(); + if (*p_data == *p_expected) + { + *p_data = desired; + ret = true; + } + else + { + *p_expected = *p_data; + ret = false; + } + CRITICAL_REGION_EXIT(); + return ret; +#endif +} -/** - * @brief Logic one bit flag set operation on an atomic object - * - * @param[in] p_data Atomic flag memory pointer - * - * @return Old flag value - * */ -static inline uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data) +uint32_t nrf_atomic_u32_fetch_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value) +{ +#if NRF_ATOMIC_USE_BUILD_IN + uint32_t expected = *p_data; + uint32_t new_val; + bool success; + + do + { + if (expected >= value) + { + new_val = expected - value; + } + else + { + new_val = expected; + } + success = __atomic_compare_exchange(p_data, + &expected, + &new_val, + 1, + __ATOMIC_SEQ_CST, + __ATOMIC_SEQ_CST); + } while(!success); + return expected; +#elif defined(STREX_LDREX_PRESENT) + uint32_t old_val; + uint32_t new_val; + + NRF_ATOMIC_OP(sub_hs, old_val, new_val, p_data, value); + UNUSED_PARAMETER(old_val); + UNUSED_PARAMETER(new_val); + return old_val; +#else + CRITICAL_REGION_ENTER(); + uint32_t old_val = *p_data; + *p_data -= value; + CRITICAL_REGION_EXIT(); + return old_val; +#endif //NRF_ATOMIC_USE_BUILD_IN +} + +uint32_t nrf_atomic_u32_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value) +{ +#if NRF_ATOMIC_USE_BUILD_IN + uint32_t expected = *p_data; + uint32_t new_val; + bool success; + + do + { + if (expected >= value) + { + new_val = expected - value; + } + else + { + new_val = expected; + } + success = __atomic_compare_exchange(p_data, + &expected, + &new_val, + 1, + __ATOMIC_SEQ_CST, + __ATOMIC_SEQ_CST); + } while(!success); + return new_val; +#elif defined(STREX_LDREX_PRESENT) + uint32_t old_val; + uint32_t new_val; + + NRF_ATOMIC_OP(sub_hs, old_val, new_val, p_data, value); + UNUSED_PARAMETER(old_val); + UNUSED_PARAMETER(new_val); + return new_val; +#else + CRITICAL_REGION_ENTER(); + *p_data -= value; + uint32_t new_value = *p_data; + CRITICAL_REGION_EXIT(); + return new_value; +#endif //NRF_ATOMIC_USE_BUILD_IN +} + +uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data) { return nrf_atomic_u32_fetch_or(p_data, 1); } -/** - * @brief Logic one bit flag set operation on an atomic object - * - * @param[in] p_data Atomic flag memory pointer - * - * @return New flag value - * */ -static inline uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data) +uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data) { return nrf_atomic_u32_or(p_data, 1); } -/** - * @brief Logic one bit flag clear operation on an atomic object - * - * @param[in] p_data Atomic flag memory pointer - * - * @return Old flag value - * */ -static inline uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data) +uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data) { return nrf_atomic_u32_fetch_and(p_data, 0); } -/** - * @brief Logic one bit flag clear operation on an atomic object - * - * @param[in] p_data Atomic flag memory pointer - * - * @return New flag value - * */ -static inline uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data) +uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data) { return nrf_atomic_u32_and(p_data, 0); } -#ifdef __cplusplus -} -#endif - -#endif /* NRF_ATOMIC_H__ */ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.h new file mode 100644 index 0000000..137aadc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic.h @@ -0,0 +1,274 @@ +/** + * Copyright (c) 2016 - 2019, 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 nrf_atomic Atomic operations API + * @ingroup app_common + * @{ + * + * @brief @tagAPI52 This module implements C11 stdatomic.h simplified API. + At this point only Cortex-M3/M4 cores are supported (LDREX/STREX instructions). + * Atomic types are limited to @ref nrf_atomic_u32_t and @ref nrf_atomic_flag_t. + */ + +#ifndef NRF_ATOMIC_H__ +#define NRF_ATOMIC_H__ + +#include "sdk_common.h" + +/** + * @brief Atomic 32 bit unsigned type + * */ +typedef volatile uint32_t nrf_atomic_u32_t; + +/** + * @brief Atomic 1 bit flag type (technically 32 bit) + * */ +typedef volatile uint32_t nrf_atomic_flag_t; + + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Stores value to an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value to store + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Stores value to an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value to store + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Logical OR operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand OR operation + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Logical OR operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand OR operation + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Logical AND operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand AND operation + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Logical AND operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand AND operation + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Logical XOR operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand XOR operation + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Logical XOR operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand XOR operation + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Arithmetic ADD operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand ADD operation + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Arithmetic ADD operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand ADD operation + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Arithmetic SUB operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand SUB operation + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Arithmetic SUB operation on an atomic object + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand SUB operation + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief If value at pointer is equal to expected value, changes value at pointer to desired + * + * Atomically compares the value pointed to by p_data with the value pointed to by p_expected, + * and if those are equal, replaces the former with desired. Otherwise, loads the actual value + * pointed to by p_data into *p_expected. + * + * @param p_data Atomic memory pointer to test and modify. + * @param p_expected Pointer to test value. + * @param desired Value to be stored to atomic memory. + * + * @retval true *p_data was equal to *p_expected + * @retval false *p_data was not equal to *p_expected + */ +bool nrf_atomic_u32_cmp_exch(nrf_atomic_u32_t * p_data, + uint32_t * p_expected, + uint32_t desired); + +/** + * @brief Arithmetic SUB operation on an atomic object performed if object >= value. + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand SUB operation + * + * @return Old value stored into atomic object + * */ +uint32_t nrf_atomic_u32_fetch_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value); + +/** + * @brief Arithmetic SUB operation on an atomic object performed if object >= value. + * + * @param[in] p_data Atomic memory pointer + * @param[in] value Value of second operand SUB operation + * + * @return New value stored into atomic object + * */ +uint32_t nrf_atomic_u32_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value); + +/**************************************************************************************************/ + +/** + * @brief Logic one bit flag set operation on an atomic object + * + * @param[in] p_data Atomic flag memory pointer + * + * @return Old flag value + * */ +uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data); + +/** + * @brief Logic one bit flag set operation on an atomic object + * + * @param[in] p_data Atomic flag memory pointer + * + * @return New flag value + * */ +uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data); + +/** + * @brief Logic one bit flag clear operation on an atomic object + * + * @param[in] p_data Atomic flag memory pointer + * + * @return Old flag value + * */ +uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data); + +/** + * @brief Logic one bit flag clear operation on an atomic object + * + * @param[in] p_data Atomic flag memory pointer + * + * @return New flag value + * */ +uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data); + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_ATOMIC_H__ */ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic_internal.h similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic_internal.h index ada00c6..ab114f6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_ATOMIC_INTERNAL_H__ #define NRF_ATOMIC_INTERNAL_H__ @@ -181,6 +181,70 @@ loop_sub bx lr } +static __asm bool nrf_atomic_internal_cmp_exch(nrf_atomic_u32_t * p_data, + uint32_t * p_expected, + uint32_t value) +{ +#define RET_REG r0 +#define P_EXPC r1 +#define VALUE r2 +#define STR_RES r3 +#define P_DATA r4 +#define EXPC_VAL r5 +#define ACT_VAL r6 + + push {r4-r6} + mov P_DATA, r0 + mov RET_REG, #0 + +loop_cmp_exch + ldrex ACT_VAL, [P_DATA] + ldr EXPC_VAL, [P_EXPC] + cmp ACT_VAL, EXPC_VAL + ittee eq + strexeq STR_RES, VALUE, [P_DATA] + moveq RET_REG, #1 + strexne STR_RES, ACT_VAL, [P_DATA] + strne ACT_VAL, [P_EXPC] + cmp STR_RES, #0 + itt ne + movne RET_REG, #0 + bne loop_cmp_exch + + pop {r4-r6} + bx lr + +#undef RET_REG +#undef P_EXPC +#undef VALUE +#undef STR_RES +#undef P_DATA +#undef EXPC_VAL +#undef ACT_VAL +} + +static __asm uint32_t nrf_atomic_internal_sub_hs(nrf_atomic_u32_t * p_ptr, + uint32_t value, + uint32_t * p_new) +{ + push {r4, r5} + mov r4, r0 + +loop_sub_ge + ldrex r0, [r4] + cmp r0, r1 + ite hs + subhs r5, r0, r1 + movlo r5, r0 + strex r3, r5, [r4] + cmp r3, #0 + bne loop_sub_ge + + str r5, [r2] + pop {r4, r5} + bx lr +} + #define NRF_ATOMIC_OP(asm_op, old_val, new_val, ptr, value) \ old_val = nrf_atomic_internal_##asm_op(ptr, value, &new_val) @@ -220,6 +284,51 @@ loop_sub #define NRF_ATOMIC_OP_eor(new_val, old_val, value) "eor %["#new_val"], %["#old_val"], %["#value"]\n" #define NRF_ATOMIC_OP_add(new_val, old_val, value) "add %["#new_val"], %["#old_val"], %["#value"]\n" #define NRF_ATOMIC_OP_sub(new_val, old_val, value) "sub %["#new_val"], %["#old_val"], %["#value"]\n" +#define NRF_ATOMIC_OP_sub_hs(new_val, old_val, value) \ + "cmp %["#old_val"], %["#value"]\n " \ + "ite hs\n" \ + "subhs %["#new_val"], %["#old_val"], %["#value"]\n" \ + "movlo %["#new_val"], %["#old_val"]\n" + +static inline bool nrf_atomic_internal_cmp_exch(nrf_atomic_u32_t * p_data, + uint32_t * p_expected, + uint32_t value) +{ + bool res = false; + uint32_t str_res = 0; + uint32_t act_val = 0; + uint32_t exp_val = 0; + UNUSED_VARIABLE(str_res); + UNUSED_VARIABLE(act_val); + UNUSED_VARIABLE(exp_val); + __ASM volatile( + "1: ldrex %[act_val], [%[ptr]]\n" + " ldr %[exp_val], [%[expc]]\n" + " cmp %[act_val], %[exp_val]\n" + " ittee eq\n" + " strexeq %[str_res], %[value], [%[ptr]]\n" + " moveq %[res], #1\n" + " strexne %[str_res], %[act_val], [%[ptr]]\n" + " strne %[act_val], [%[expc]]\n" + " cmp %[str_res], #0\n" + " itt ne\n" + " movne %[res], #0\n" + " bne.n 1b" + : + [res] "=&r" (res), + [exp_val] "=&r" (exp_val), + [act_val] "=&r" (act_val), + [str_res] "=&r" (str_res) + : + "0" (res), + "1" (exp_val), + "2" (act_val), + [expc] "r" (p_expected), + [ptr] "r" (p_data), + [value] "r" (value) + : "cc"); + return res; +} #else #error "Unsupported compiler" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic_sanity_check.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic_sanity_check.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic_sanity_check.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic_sanity_check.h index f07006c..996658c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic/nrf_atomic_sanity_check.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic/nrf_atomic_sanity_check.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_ATOMIC_SANITY_CHECK_H__ #define NRF_ATOMIC_SANITY_CHECK_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo.c similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo.c index 179fbfc..836e3b9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2011 - 2019, 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 @@ -35,14 +35,25 @@ * 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 +#include +#include #include "app_util.h" #include "nrf_atfifo.h" #include "nrf_atfifo_internal.h" +#if NRF_ATFIFO_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_ATFIFO_CONFIG_LOG_LEVEL + #define NRF_LOG_INIT_FILTER_LEVEL NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL + #define NRF_LOG_INFO_COLOR NRF_ATFIFO_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_ATFIFO_CONFIG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // NRF_ATFIFO_CONFIG_LOG_ENABLED +#include "nrf_log.h" /* Unions testing */ STATIC_ASSERT(sizeof(nrf_atfifo_postag_t) == sizeof(uint32_t)); @@ -52,10 +63,12 @@ ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t b { if (NULL == p_buf) { + NRF_LOG_INST_ERROR(p_fifo->p_log, "Initialization failed. p_buf == NULL"); return NRF_ERROR_NULL; } if (0 != (buf_size % item_size)) { + NRF_LOG_INST_ERROR(p_fifo->p_log, "Initialization failed. Buf_size not multiple of item_size"); return NRF_ERROR_INVALID_LENGTH; } @@ -65,6 +78,7 @@ ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t b p_fifo->buf_size = buf_size; p_fifo->item_size = item_size; + NRF_LOG_INST_INFO(p_fifo->p_log, "Initialized."); return NRF_SUCCESS; } @@ -72,6 +86,7 @@ ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t b ret_code_t nrf_atfifo_clear(nrf_atfifo_t * const p_fifo) { bool released = nrf_atfifo_space_clear(p_fifo); + NRF_LOG_INST_INFO(p_fifo->p_log, "Cleared result:%s", released ? "success" : "busy"); return released ? NRF_SUCCESS : NRF_ERROR_BUSY; } @@ -83,6 +98,7 @@ ret_code_t nrf_atfifo_alloc_put(nrf_atfifo_t * const p_fifo, void const * p_var, void * p_data = nrf_atfifo_item_alloc(p_fifo, &context); if (NULL == p_data) { + NRF_LOG_INST_WARNING(p_fifo->p_log, "Copying in element (0x%08X) failed - no space.", p_var); return NRF_ERROR_NO_MEM; } @@ -93,6 +109,7 @@ ret_code_t nrf_atfifo_alloc_put(nrf_atfifo_t * const p_fifo, void const * p_var, { *p_visible = visible; } + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Element (0x%08X) copied in.", p_var); return NRF_SUCCESS; } @@ -101,8 +118,11 @@ void * nrf_atfifo_item_alloc(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t { if (nrf_atfifo_wspace_req(p_fifo, &(p_context->last_tail))) { - return ((uint8_t*)(p_fifo->p_buf)) + p_context->last_tail.pos.wr; + void * p_item = ((uint8_t*)(p_fifo->p_buf)) + p_context->last_tail.pos.wr; + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Allocated element (0x%08X).", p_item); + return p_item; } + NRF_LOG_INST_WARNING(p_fifo->p_log, "Allocation failed - no space."); return NULL; } @@ -111,9 +131,11 @@ bool nrf_atfifo_item_put(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_ { if ((p_context->last_tail.pos.wr) == (p_context->last_tail.pos.rd)) { + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Put (uninterrupted)"); nrf_atfifo_wspace_close(p_fifo); return true; } + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Put (interrupted!)"); return false; } @@ -125,6 +147,7 @@ ret_code_t nrf_atfifo_get_free(nrf_atfifo_t * const p_fifo, void * const p_var, void const * p_s = nrf_atfifo_item_get(p_fifo, &context); if (NULL == p_s) { + NRF_LOG_INST_WARNING(p_fifo->p_log, "Copying out failed - no item in the FIFO."); return NRF_ERROR_NOT_FOUND; } @@ -135,6 +158,7 @@ ret_code_t nrf_atfifo_get_free(nrf_atfifo_t * const p_fifo, void * const p_var, { *p_released = released; } + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Element (0x%08X) copied out.", p_var); return NRF_SUCCESS; } @@ -143,8 +167,11 @@ void * nrf_atfifo_item_get(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * { if (nrf_atfifo_rspace_req(p_fifo, &(p_context->last_head))) { - return ((uint8_t*)(p_fifo->p_buf)) + p_context->last_head.pos.rd; + void * p_item = ((uint8_t*)(p_fifo->p_buf)) + p_context->last_head.pos.rd; + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Get element: 0x%08X", p_item); + return p_item; } + NRF_LOG_INST_WARNING(p_fifo->p_log, "Get failed - no item in the FIFO."); return NULL; } @@ -153,8 +180,10 @@ bool nrf_atfifo_item_free(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p { if ((p_context->last_head.pos.wr) == (p_context->last_head.pos.rd)) { + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Free (uninterrupted)"); nrf_atfifo_rspace_close(p_fifo); return true; } + NRF_LOG_INST_DEBUG(p_fifo->p_log, "Free (interrupted)"); return false; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo.h similarity index 89% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo.h index 2472d45..e8c2ad0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2011 - 2019, 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 @@ -35,15 +35,18 @@ * 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 NRF_ATFIFO_H__ #define NRF_ATFIFO_H__ #include +#include +#include "sdk_config.h" #include "nordic_common.h" #include "nrf_assert.h" - +#include "sdk_errors.h" +#include "nrf_log_instance.h" #ifdef __cplusplus extern "C" { #endif @@ -133,11 +136,12 @@ typedef union nrf_atfifo_postag_u */ typedef struct nrf_atfifo_s { - void * p_buf; //!< Pointer to the data buffer - nrf_atfifo_postag_t tail; //!< Read and write tail position tag - nrf_atfifo_postag_t head; //!< Read and write head position tag - uint16_t buf_size; //!< FIFO size in number of bytes (has to be divisible by @c item_size) - uint16_t item_size; //!< Size of a single FIFO item + void * p_buf; //!< Pointer to the data buffer + nrf_atfifo_postag_t tail; //!< Read and write tail position tag + nrf_atfifo_postag_t head; //!< Read and write head position tag + uint16_t buf_size; //!< FIFO size in number of bytes (has to be divisible by @c item_size) + uint16_t item_size; //!< Size of a single FIFO item + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). }nrf_atfifo_t; /** @@ -163,6 +167,10 @@ typedef struct nrf_atfifo_rcontext_s }nrf_atfifo_item_get_t; +/** @brief Name of the module used for logger messaging. + */ +#define NRF_ATFIFO_LOG_NAME atfifo + /** * @defgroup nrf_atfifo_instmacros FIFO instance macros * @@ -227,9 +235,18 @@ typedef struct nrf_atfifo_rcontext_s * @param[in] item_cnt Capacity of the created FIFO in maximum number of items that may be stored. * The phisical size of the buffer will be 1 element bigger. */ - #define NRF_ATFIFO_DEF(fifo_id, storage_type, item_cnt) \ - static storage_type NRF_ATFIFO_BUF_NAME(fifo_id)[(item_cnt)+1]; \ - static nrf_atfifo_t NRF_ATFIFO_INST_NAME(fifo_id); \ + #define NRF_ATFIFO_DEF(fifo_id, storage_type, item_cnt) \ + static storage_type NRF_ATFIFO_BUF_NAME(fifo_id)[(item_cnt)+1]; \ + NRF_LOG_INSTANCE_REGISTER(NRF_ATFIFO_LOG_NAME, fifo_id, \ + NRF_ATFIFO_CONFIG_INFO_COLOR, \ + NRF_ATFIFO_CONFIG_DEBUG_COLOR, \ + NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL, \ + NRF_ATFIFO_CONFIG_LOG_ENABLED ? \ + NRF_ATFIFO_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + static nrf_atfifo_t NRF_ATFIFO_INST_NAME(fifo_id) = { \ + .p_buf = NULL, \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_ATFIFO_LOG_NAME, fifo_id) \ + }; \ static nrf_atfifo_t * const fifo_id = &NRF_ATFIFO_INST_NAME(fifo_id) /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo_internal.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo_internal.h index 477b91f..8e87eb5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/atomic_fifo/nrf_atfifo_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_fifo/nrf_atfifo_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2011 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.c new file mode 100644 index 0000000..fce8a6b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.c @@ -0,0 +1,160 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf.h" +#include "nrf_atomic.h" +#include "nrf_atflags.h" +#include "sdk_common.h" + + + +/**@brief Macro for getting the index inside the flag array where a flag can be found. + * + * @param flag_index Index of the flag. + * + * @return Index of the @ref nrf_atflags_t the flag can be found in. + */ +#define FLAG_BASE(flag_index) ((flag_index) / NRF_ATFLAGS_FLAGS_PER_ELEMENT) + +/**@brief Macro for getting the mask representing the flag within the flag array member. + * + * @param flag_index ID of the flag. + * + * @return Mask representing the flag within a single @ref nrf_atflags_t. + */ +#define FLAG_MASK(flag_index) (1UL << ((flag_index) % NRF_ATFLAGS_FLAGS_PER_ELEMENT)) + + +void nrf_atflags_set(nrf_atflags_t * p_flags, uint32_t flag_index) +{ + uint32_t new_value = nrf_atomic_u32_or(&p_flags[FLAG_BASE(flag_index)], FLAG_MASK(flag_index)); + UNUSED_RETURN_VALUE(new_value); +} + + +bool nrf_atflags_fetch_set(nrf_atflags_t * p_flags, uint32_t flag_index) +{ + return (nrf_atomic_u32_fetch_or(&p_flags[FLAG_BASE(flag_index)], FLAG_MASK(flag_index)) + & FLAG_MASK(flag_index)) != 0; +} + + +void nrf_atflags_clear(nrf_atflags_t * p_flags, uint32_t flag_index) +{ + uint32_t new_value = nrf_atomic_u32_and(&p_flags[FLAG_BASE(flag_index)], ~FLAG_MASK(flag_index)); + UNUSED_RETURN_VALUE(new_value); +} + + +bool nrf_atflags_fetch_clear(nrf_atflags_t * p_flags, uint32_t flag_index) +{ + return (nrf_atomic_u32_fetch_and(&p_flags[FLAG_BASE(flag_index)], ~FLAG_MASK(flag_index)) + & FLAG_MASK(flag_index)) != 0; +} + + +bool nrf_atflags_get(nrf_atflags_t const * p_flags, uint32_t flag_index) +{ + return (p_flags[FLAG_BASE(flag_index)] & FLAG_MASK(flag_index)) != 0; +} + + +uint32_t nrf_atflags_init(nrf_atflags_t * p_flags, uint32_t flags_array_len, uint32_t flag_count) +{ + uint32_t required_flags_array_len = NRF_ATFLAGS_ARRAY_LEN(flag_count); + + if (required_flags_array_len <= flags_array_len) + { + for (uint32_t i = 0; i < required_flags_array_len; i++) + { + p_flags[i] = 0; + } + return required_flags_array_len; + } + return 0; +} + +uint32_t nrf_atflags_find_and_set_flag(nrf_atflags_t * p_flags, uint32_t flag_count) +{ + for (uint32_t i = 0; i < NRF_ATFLAGS_ARRAY_LEN(flag_count); i++) + { + // Using __RBIT to make the order of flags more traditional. + uint32_t first_zero = __CLZ(__RBIT(~p_flags[i])); + while (first_zero < 32) + { + uint32_t first_zero_global = first_zero + (i * 32); + if (first_zero_global >= flag_count) + { + break; + } + if (!nrf_atflags_fetch_set(p_flags, first_zero_global)) + { + return first_zero_global; + } + first_zero = __CLZ(__RBIT(~p_flags[i])); + } + } + + return flag_count; +} + +uint32_t nrf_atflags_find_and_clear_flag(nrf_atflags_t * p_flags, uint32_t flag_count) +{ + for (uint32_t i = 0; i < NRF_ATFLAGS_ARRAY_LEN(flag_count); i++) + { + // Using __RBIT to make the order of flags more traditional. + uint32_t first_one = __CLZ(__RBIT(p_flags[i])); + while (first_one < 32) + { + uint32_t first_one_global = first_one + (i * 32); + if (first_one_global >= flag_count) + { + break; + } + if (nrf_atflags_fetch_clear(p_flags, first_one_global)) + { + return first_one_global; + } + first_one = __CLZ(__RBIT(p_flags[i])); + } + } + + return flag_count; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.h new file mode 100644 index 0000000..1e2dd2e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/atomic_flags/nrf_atflags.h @@ -0,0 +1,184 @@ +/** + * Copyright (c) 2017 - 2019, 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 nrf_atflags Atomic flags (bitmaps) + * @ingroup app_common + * @{ + * + * @brief @tagAPI52 This module implements atomic flags as bitmaps. + * + * Operations on the individual flags are atomic, meaning that you are always sure that the flag is + * set to the desired value, and you always know what value was there before. You also know that no + * other flags were affected by the operation. + * + * Operations on the entire flag collection are NOT atomic. This essentially means that you can't + * know the order in which operations on different flags happened, and you can't know the state of + * the entire flag collection at any instant. These limitations can be overcome by protecting + * operations with a mutex. + */ + +#ifndef NRF_ATFLAGS_H__ +#define NRF_ATFLAGS_H__ + +#include +#include + +/** + * @brief Array of atomic flags. + * */ +typedef volatile uint32_t nrf_atflags_t; + + +/** + * @brief Number of flags per @ref nrf_atflags_t. + * */ +#define NRF_ATFLAGS_FLAGS_PER_ELEMENT (sizeof(nrf_atflags_t) * 8) + +/**@brief Macro for the length of an array of @ref nrf_atflags_t needed to keep \p flag_count flags. + * + * @param flag_count Number of flags to keep in a flag array. + * + * @return Length of the array needed to house flag_count flags. + */ +#define NRF_ATFLAGS_ARRAY_LEN(flag_count) ((flag_count - 1) / NRF_ATFLAGS_FLAGS_PER_ELEMENT) + 1 + +/**@brief Macro for declaring a flag array with the right size and initial value. + * + * @note When using this macro, no call to @ref nrf_atflags_init is necessary for this array. + * + * @param _name Name to be given to the array. + * @param flag_count Number of flags to be kept in the flag array. + * + * @return Flag array definition. + */ +#define NRF_ATFLAGS_DEF(_name, flag_count) \ + nrf_atflags_t _name[NRF_ATFLAGS_ARRAY_LEN((flag_count))] = {0} + +/**@brief Macro for defining a flag array inside a struct. + * + * @note When using this macro, make sure to set the array to 0 or use @ref nrf_atflags_init + * + * @param _name Name to be given to the array. + * @param flag_count Number of flags to be kept in the flag array. + * + * @return The flag array definition. + */ +#define NRF_ATFLAGS_DEF_MEMBER(_name, flag_count) \ + nrf_atflags_t _name[NRF_ATFLAGS_ARRAY_LEN((flag_count))] + +/**@brief Function for safely initializing a flag array to 0. + * + * @param p_flags Flag array to initialize. + * @param flags_array_len Length of \p p_flags. + * @param flag_count Number of flags to be kept in the flag array. + * + * @retval 0 if the given length is not sufficient to house \p flag_count flags in the array. + * @return If successful: The actual length required. + */ +uint32_t nrf_atflags_init(nrf_atflags_t * p_flags, uint32_t flags_array_len, uint32_t flag_count); + +/**@brief Function for atomically setting a flag to 1. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_index Index of the flag in the array. + */ +void nrf_atflags_set(nrf_atflags_t * p_flags, uint32_t flag_index); + +/**@brief Function for atomically setting a flag to 1, returning the previous value of the flag. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_index Index of the flag in the array. + * + * @return Old flag value. + */ +bool nrf_atflags_fetch_set(nrf_atflags_t * p_flags, uint32_t flag_index); + +/**@brief Function for atomically setting a flag to 0. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_index Index of the flag in the array. + */ +void nrf_atflags_clear(nrf_atflags_t * p_flags, uint32_t flag_index); + +/**@brief Function for atomically setting a flag to 0, returning the previous value of the flag. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_index Index of the flag in the array. + * + * @return Old flag value. + */ +bool nrf_atflags_fetch_clear(nrf_atflags_t * p_flags, uint32_t flag_index); + +/**@brief Function for getting the value of a flag in a flag array. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_index Index of the flag in the array. + * + * @return Flag value. + */ +bool nrf_atflags_get(nrf_atflags_t const * p_flags, uint32_t flag_index); + +/**@brief Function for finding a flag with value 0, and atomically setting it to one. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_count Number of flags in the array. + * + * @return Index of the cleared flag that has been set. + */ +uint32_t nrf_atflags_find_and_set_flag(nrf_atflags_t * p_flags, uint32_t flag_count); + +/**@brief Function for finding a flag with value 1, and atomically clearing it to 0. + * + * @param[in] p_flags Atomic flag array. + * @param[in] flag_count The number of flags in the array. + * + * @return The index of the set flag that has been cleared. + */ +uint32_t nrf_atflags_find_and_clear_flag(nrf_atflags_t * p_flags, uint32_t flag_count); + + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_ATFLAGS_H__ */ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/balloc/nrf_balloc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/balloc/nrf_balloc.c similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/balloc/nrf_balloc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/balloc/nrf_balloc.c index b2eb43d..70a2efe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/balloc/nrf_balloc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/balloc/nrf_balloc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,24 +35,25 @@ * 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(NRF_BALLOC) +#include "nrf_section.h" #include "nrf_balloc.h" #include "app_util_platform.h" -#define NRF_LOG_MODULE_NAME balloc + #if NRF_BALLOC_CONFIG_LOG_ENABLED - #define NRF_LOG_LEVEL NRF_BALLOC_CONFIG_LOG_LEVEL - #define NRF_LOG_INFO_COLOR NRF_BALLOC_CONFIG_INFO_COLOR - #define NRF_LOG_DEBUG_COLOR NRF_BALLOC_CONFIG_DEBUG_COLOR + #define NRF_LOG_LEVEL NRF_BALLOC_CONFIG_LOG_LEVEL + #define NRF_LOG_INITIAL_LEVEL NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL + #define NRF_LOG_INFO_COLOR NRF_BALLOC_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_BALLOC_CONFIG_DEBUG_COLOR #else #define NRF_LOG_LEVEL 0 #endif // NRF_BALLOC_CONFIG_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); #define HEAD_GUARD_FILL 0xBAADF00D /**< Magic number used to mark head guard.*/ #define TAIL_GUARD_FILL 0xBAADCAFE /**< Magic number used to mark tail guard.*/ @@ -66,8 +67,61 @@ NRF_LOG_MODULE_REGISTER(); #define POOL_MARKER "0x%08X" #endif -#if NRF_BALLOC_CONFIG_DEBUG_ENABLED +NRF_SECTION_DEF(nrf_balloc, nrf_balloc_t); + +#if NRF_BALLOC_CLI_CMDS && NRF_CLI_ENABLED +#include "nrf_cli.h" +static void nrf_balloc_status(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + if (argc > 1) + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Bad argument count"); + return; + } + + uint32_t num_of_instances = NRF_SECTION_ITEM_COUNT(nrf_balloc, nrf_balloc_t); + uint32_t i; + + for (i = 0; i < num_of_instances; i++) + { + const nrf_balloc_t * p_instance = NRF_SECTION_ITEM_GET(nrf_balloc, nrf_balloc_t, i); + + uint32_t element_size = NRF_BALLOC_ELEMENT_SIZE(p_instance); + uint32_t dbg_addon = p_instance->block_size - element_size; + uint32_t pool_size = p_instance->p_stack_limit - p_instance->p_stack_base; + uint32_t max_util = nrf_balloc_max_utilization_get(p_instance); + uint32_t util = nrf_balloc_utilization_get(p_instance); + const char * p_name = p_instance->p_name; + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, + "%s\r\n\t- Element size:\t%d + %d bytes of debug information\r\n" + "\t- Usage:\t%u%% (%u out of %u elements)\r\n" + "\t- Maximum:\t%u%% (%u out of %u elements)\r\n\r\n", + p_name, element_size, dbg_addon, + 100ul * util/pool_size, util,pool_size, + 100ul * max_util/pool_size, max_util,pool_size); + + } +} +// Register "balloc" command and its subcommands in CLI. +NRF_CLI_CREATE_STATIC_SUBCMD_SET(nrf_balloc_commands) +{ + NRF_CLI_CMD(status, NULL, "Print status of balloc instances.", nrf_balloc_status), + NRF_CLI_SUBCMD_SET_END +}; + +NRF_CLI_CMD_REGISTER(balloc, &nrf_balloc_commands, "Commands for BALLOC management", nrf_balloc_status); +#endif //NRF_BALLOC_CLI_CMDS + +#if NRF_BALLOC_CONFIG_DEBUG_ENABLED /**@brief Validate block memory, prepare block guards, and calculate pointer to the element. * * @param[in] p_pool Pointer to the memory pool. @@ -92,8 +146,9 @@ __STATIC_INLINE void * nrf_balloc_block_unwrap(nrf_balloc_t const * p_pool, void { if (*ptr != FREE_MEM_FILL) { - NRF_LOG_ERROR("Detected free memory corruption at 0x%08X (0x%08X != 0x%08X, pool: '" POOL_MARKER "')", - ptr, *ptr, FREE_MEM_FILL, POOL_ID(p_pool)); + NRF_LOG_INST_ERROR(p_pool->p_log, + "Detected free memory corruption at 0x%08X (0x%08X != 0x%08X)", + ptr, *ptr, FREE_MEM_FILL); APP_ERROR_CHECK_BOOL(false); } } @@ -134,8 +189,9 @@ __STATIC_INLINE void * nrf_balloc_element_wrap(nrf_balloc_t const * p_pool, void { if (*ptr != HEAD_GUARD_FILL) { - NRF_LOG_ERROR("Detected Head Guard corruption at 0x%08X (0x%08X != 0x%08X, pool: '" POOL_MARKER "')", - ptr, *ptr, HEAD_GUARD_FILL, POOL_ID(p_pool)); + NRF_LOG_INST_ERROR(p_pool->p_log, + "Detected Head Guard corruption at 0x%08X (0x%08X != 0x%08X)", + ptr, *ptr, HEAD_GUARD_FILL); APP_ERROR_CHECK_BOOL(false); } } @@ -144,8 +200,9 @@ __STATIC_INLINE void * nrf_balloc_element_wrap(nrf_balloc_t const * p_pool, void { if (*ptr != TAIL_GUARD_FILL) { - NRF_LOG_ERROR("Detected Tail Guard corruption at 0x%08X (0x%08X != 0x%08X, pool: '" POOL_MARKER "')", - ptr, *ptr, TAIL_GUARD_FILL, POOL_ID(p_pool)); + NRF_LOG_INST_ERROR(p_pool->p_log, + "Detected Tail Guard corruption at 0x%08X (0x%08X != 0x%08X)", + ptr, *ptr, TAIL_GUARD_FILL); APP_ERROR_CHECK_BOOL(false); } } @@ -214,11 +271,10 @@ ret_code_t nrf_balloc_init(nrf_balloc_t const * p_pool) } #endif - NRF_LOG_INFO("Pool '" POOL_MARKER "' initialized (size: %u x %u = %u bytes)", - POOL_ID(p_pool), - pool_size, - p_pool->block_size, - pool_size * p_pool->block_size); + NRF_LOG_INST_INFO(p_pool->p_log, "Initialized (size: %u x %u = %u bytes)", + pool_size, + p_pool->block_size, + pool_size * p_pool->block_size); p_pool->p_cb->p_stack_pointer = p_pool->p_stack_base; while (pool_size--) @@ -261,8 +317,7 @@ void * nrf_balloc_alloc(nrf_balloc_t const * p_pool) } #endif - NRF_LOG_DEBUG("nrf_balloc_alloc(pool: '" POOL_MARKER "', element: 0x%08X)", - POOL_ID(p_pool), p_block); + NRF_LOG_INST_DEBUG(p_pool->p_log, "Allocating element: 0x%08X", p_block); return p_block; } @@ -272,8 +327,7 @@ void nrf_balloc_free(nrf_balloc_t const * p_pool, void * p_element) ASSERT(p_pool != NULL); ASSERT(p_element != NULL) - NRF_LOG_DEBUG("nrf_balloc_free(pool: '" POOL_MARKER "', element: 0x%08X)", - POOL_ID(p_pool), p_element); + NRF_LOG_INST_DEBUG(p_pool->p_log, "Freeing element: 0x%08X", p_element); #if NRF_BALLOC_CONFIG_DEBUG_ENABLED void * p_block = nrf_balloc_element_wrap(p_pool, p_element); @@ -287,16 +341,17 @@ void nrf_balloc_free(nrf_balloc_t const * p_pool, void * p_element) // Check if the element belongs to this pool. if ((p_block < p_pool->p_memory_begin) || (p_block >= p_memory_end)) { - NRF_LOG_ERROR("Attempted to free element that does belong to the pool (pool: '" POOL_MARKER "', element: 0x%08X)", - POOL_ID(p_pool), p_element); + NRF_LOG_INST_ERROR(p_pool->p_log, + "Attempted to free element (0x%08X) that does not belong to the pool.", + p_element); APP_ERROR_CHECK_BOOL(false); } // Check if the pointer is valid. if ((((size_t)(p_block) - (size_t)(p_pool->p_memory_begin)) % p_pool->block_size) != 0) { - NRF_LOG_ERROR("Atempted to free corrupted element address (pool: '" POOL_MARKER "', element: 0x%08X)", - POOL_ID(p_pool), p_element); + NRF_LOG_INST_ERROR(p_pool->p_log, + "Attempted to free corrupted element address (0x%08X).", p_element); APP_ERROR_CHECK_BOOL(false); } } @@ -313,8 +368,9 @@ void nrf_balloc_free(nrf_balloc_t const * p_pool, void * p_element) // Check for allocated/free ballance. if (p_pool->p_cb->p_stack_pointer >= p_pool->p_stack_limit) { - NRF_LOG_ERROR("Attempted to free an element while the pool is full (pool: '" POOL_MARKER "', element: 0x%08X)", - POOL_ID(p_pool), p_element); + NRF_LOG_INST_ERROR(p_pool->p_log, + "Attempted to free an element (0x%08X) while the pool is full.", + p_element); APP_ERROR_CHECK_BOOL(false); } } @@ -326,8 +382,8 @@ void nrf_balloc_free(nrf_balloc_t const * p_pool, void * p_element) { if (nrf_balloc_idx2block(p_pool, *p_idx) == p_block) { - NRF_LOG_ERROR("Attempted to double-free an element (pool: '" POOL_MARKER "', element: 0x%08X)", - POOL_ID(p_pool), p_element); + NRF_LOG_INST_ERROR(p_pool->p_log, "Attempted to double-free an element (0x%08X).", + p_element); APP_ERROR_CHECK_BOOL(false); } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/balloc/nrf_balloc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/balloc/nrf_balloc.h similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/balloc/nrf_balloc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/balloc/nrf_balloc.h index 20c2c35..68d5491 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/balloc/nrf_balloc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/balloc/nrf_balloc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** * @defgroup nrf_balloc Block memory allocator @@ -56,6 +56,19 @@ extern "C" { #include "sdk_config.h" #include "app_util_platform.h" #include "app_util.h" +#include "nrf_log_instance.h" +#include "nrf_section.h" + +/** @brief Name of the module used for logger messaging. + */ +#define NRF_BALLOC_LOG_NAME balloc + +#if NRF_BALLOC_CONFIG_DEBUG_ENABLED || NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_HAS_NAME 1 +#else +#define NRF_BALLOC_HAS_NAME 0 +#endif + /**@defgroup NRF_BALLOC_DEBUG Macros for preparing debug flags for block allocator module. * @{ */ #define NRF_BALLOC_DEBUG_HEAD_GUARD_WORDS_SET(words) (((words) & 0xFF) << 0) @@ -107,9 +120,11 @@ typedef struct /**< * Memory is used as a heap for blocks. */ - -#if NRF_BALLOC_CONFIG_DEBUG_ENABLED + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). +#if NRF_BALLOC_HAS_NAME const char * p_name; //!< Pointer to string with pool name. +#endif +#if NRF_BALLOC_CONFIG_DEBUG_ENABLED uint32_t debug_flags; //!< Debugging settings. /**< * Debug flag should be created by @ref NRF_BALLOC_DEBUG. @@ -157,10 +172,14 @@ typedef struct #endif // NRF_BALLOC_CONFIG_DEBUG_ENABLED #if NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define __NRF_BALLOC_ASSIGN_POOL_NAME(_name) .p_name = STRINGIFY(_name), #define __NRF_BALLOC_ASSIGN_DEBUG_FLAGS(_debug_flags) .debug_flags = (_debug_flags), #else #define __NRF_BALLOC_ASSIGN_DEBUG_FLAGS(_debug_flags) +#endif + +#if NRF_BALLOC_HAS_NAME +#define __NRF_BALLOC_ASSIGN_POOL_NAME(_name) .p_name = STRINGIFY(_name), +#else #define __NRF_BALLOC_ASSIGN_POOL_NAME(_name) #endif @@ -180,7 +199,13 @@ typedef struct static uint32_t CONCAT_2(_name,_nrf_balloc_pool_mem) \ [NRF_BALLOC_BLOCK_SIZE(_element_size, _debug_flags) * (_pool_size) / sizeof(uint32_t)]; \ static nrf_balloc_cb_t CONCAT_2(_name,_nrf_balloc_cb); \ - static const nrf_balloc_t _name = \ + NRF_LOG_INSTANCE_REGISTER(NRF_BALLOC_LOG_NAME, _name, \ + NRF_BALLOC_CONFIG_INFO_COLOR, \ + NRF_BALLOC_CONFIG_DEBUG_COLOR, \ + NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL, \ + NRF_BALLOC_CONFIG_LOG_ENABLED ? \ + NRF_BALLOC_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + NRF_SECTION_ITEM_REGISTER(nrf_balloc, const nrf_balloc_t _name) = \ { \ .p_cb = &CONCAT_2(_name,_nrf_balloc_cb), \ .p_stack_base = CONCAT_2(_name,_nrf_balloc_pool_stack), \ @@ -188,6 +213,7 @@ typedef struct .p_memory_begin = CONCAT_2(_name,_nrf_balloc_pool_mem), \ .block_size = NRF_BALLOC_BLOCK_SIZE(_element_size, _debug_flags), \ \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_BALLOC_LOG_NAME, _name) \ __NRF_BALLOC_ASSIGN_POOL_NAME(_name) \ __NRF_BALLOC_ASSIGN_DEBUG_FLAGS(_debug_flags) \ } @@ -200,7 +226,7 @@ typedef struct * @param[in] _element_size Size of one element. * @param[in] _pool_size Size of the pool. */ -#define NRF_BALLOC_DEF(_name, _element_size, _pool_size) \ +#define NRF_BALLOC_DEF(_name, _element_size, _pool_size) \ NRF_BALLOC_DBG_DEF(_name, _element_size, _pool_size, NRF_BALLOC_DEFAULT_DEBUG_FLAGS) /**@brief Create a block allocator interface. @@ -301,6 +327,22 @@ __STATIC_INLINE uint8_t nrf_balloc_max_utilization_get(nrf_balloc_t const * p_po } #endif //SUPPRESS_INLINE_IMPLEMENTATION +/**@brief Function for getting current memory pool utilization. + * + * @param[in] p_pool Pointer to the memory pool instance. + * + * @return Maximum number of elements allocated from the pool. + */ +__STATIC_INLINE uint8_t nrf_balloc_utilization_get(nrf_balloc_t const * p_pool); + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION +__STATIC_INLINE uint8_t nrf_balloc_utilization_get(nrf_balloc_t const * p_pool) +{ + ASSERT(p_pool != NULL); + return (p_pool->p_stack_limit - p_pool->p_cb->p_stack_pointer); +} +#endif //SUPPRESS_INLINE_IMPLEMENTATION + #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/empty/nrf_block_dev_empty.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/empty/nrf_block_dev_empty.c similarity index 78% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/empty/nrf_block_dev_empty.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/empty/nrf_block_dev_empty.c index 129ad63..111408c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/empty/nrf_block_dev_empty.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/empty/nrf_block_dev_empty.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,9 +35,12 @@ * 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(NRF_BLOCK_DEV_EMPTY) #include "nrf_block_dev_empty.h" +#include /**@file * @@ -49,6 +52,16 @@ * - /dev/zero for read operations */ +#if NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#else +#define NRF_LOG_LEVEL 0 +#endif +#include "nrf_log.h" + + static ret_code_t block_dev_empty_init(nrf_block_dev_t const * p_blk_dev, nrf_block_dev_ev_handler ev_handler, void const * p_context) @@ -58,6 +71,8 @@ static ret_code_t block_dev_empty_init(nrf_block_dev_t const * p_blk_dev, CONTAINER_OF(p_blk_dev, nrf_block_dev_empty_t, block_dev); nrf_block_dev_empty_work_t * p_work = p_empty_dev->p_work; + NRF_LOG_INST_DEBUG(p_empty_dev->p_log, "Init."); + /* Calculate block device geometry.... */ p_work->geometry.blk_size = p_empty_dev->empty_config.block_size; p_work->geometry.blk_count = p_empty_dev->empty_config.block_count; @@ -87,6 +102,8 @@ static ret_code_t block_dev_empty_uninit(nrf_block_dev_t const * p_blk_dev) CONTAINER_OF(p_blk_dev, nrf_block_dev_empty_t, block_dev); nrf_block_dev_empty_work_t * p_work = p_empty_dev->p_work; + NRF_LOG_INST_DEBUG(p_empty_dev->p_log, "Uninit."); + if (p_work->ev_handler) { /*Asynchronous operation (simulation)*/ @@ -113,6 +130,25 @@ static ret_code_t block_dev_empty_read_req(nrf_block_dev_t const * p_blk_dev, CONTAINER_OF(p_blk_dev, nrf_block_dev_empty_t, block_dev); nrf_block_dev_empty_work_t * p_work = p_empty_dev->p_work; + NRF_LOG_INST_DEBUG( + p_empty_dev->p_log, + "Read req from block %"PRIu32" size %"PRIu32"(x%"PRIu32") to %"PRIXPTR, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_size, + p_blk->p_buff); + + if ((p_blk->blk_id + p_blk->blk_count) > p_work->geometry.blk_count) + { + NRF_LOG_INST_ERROR( + p_empty_dev->p_log, + "Out of range read req block %"PRIu32" count %"PRIu32" while max is %"PRIu32, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count); + return NRF_ERROR_INVALID_ADDR; + } + memset(p_blk->p_buff, 0, p_empty_dev->p_work->geometry.blk_size * p_blk->blk_count); if (p_work->ev_handler) { @@ -139,6 +175,26 @@ static ret_code_t block_dev_empty_write_req(nrf_block_dev_t const * p_blk_dev, CONTAINER_OF(p_blk_dev, nrf_block_dev_empty_t, block_dev); nrf_block_dev_empty_work_t * p_work = p_empty_dev->p_work; + NRF_LOG_INST_DEBUG( + p_empty_dev->p_log, + "Write req to block %"PRIu32" size %"PRIu32"(x%"PRIu32") from %"PRIXPTR, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_size, + p_blk->p_buff); + + if ((p_blk->blk_id + p_blk->blk_count) > p_work->geometry.blk_count) + { + NRF_LOG_INST_ERROR( + p_empty_dev->p_log, + "Out of range write req block %"PRIu32" count %"PRIu32" while max is %"PRIu32, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count); + + return NRF_ERROR_INVALID_ADDR; + } + if (p_work->ev_handler) { /*Asynchronous operation (simulation)*/ @@ -165,6 +221,7 @@ static ret_code_t block_dev_empty_ioctl(nrf_block_dev_t const * p_blk_dev, case NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH: { bool * p_flushing = p_data; + NRF_LOG_INST_DEBUG(p_empty_dev, "IOCtl: Cache flush"); if (p_flushing) { *p_flushing = false; @@ -208,3 +265,5 @@ const nrf_block_dev_ops_t nrf_block_device_empty_ops = { .geometry = block_dev_empty_geometry, }; +/** @} */ +#endif // NRF_MODULE_ENABLED(NRF_BLOCK_DEV_EMPTY) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/empty/nrf_block_dev_empty.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/empty/nrf_block_dev_empty.h similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/empty/nrf_block_dev_empty.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/empty/nrf_block_dev_empty.h index b8b38e8..0ce22c4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/empty/nrf_block_dev_empty.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/empty/nrf_block_dev_empty.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_BLOCK_DEV_EMPTY_H__ #define NRF_BLOCK_DEV_EMPTY_H__ @@ -45,7 +45,7 @@ extern "C" { #endif #include "nrf_block_dev.h" - +#include "nrf_log_instance.h" /**@file * @@ -68,9 +68,9 @@ extern const nrf_block_dev_ops_t nrf_block_device_empty_ops; * @brief Work structure of EMPTY block device. */ typedef struct { - nrf_block_dev_geometry_t geometry; //!< Block device geometry - nrf_block_dev_ev_handler ev_handler; //!< Block device event handler - void const * p_context; //!< Context handle passed to event handler + nrf_block_dev_geometry_t geometry; //!< Block device geometry + nrf_block_dev_ev_handler ev_handler; //!< Block device event handler + void const * p_context; //!< Context handle passed to event handler } nrf_block_dev_empty_work_t; @@ -97,12 +97,17 @@ typedef struct { * @brief EMPTY block device * */ typedef struct { - nrf_block_dev_t block_dev; //!< Block device - nrf_block_dev_info_strings_t info_strings; //!< Block device information strings - nrf_block_dev_empty_config_t empty_config; //!< EMPTY block device config - nrf_block_dev_empty_work_t * p_work; //!< EMPTY block device work structure + nrf_block_dev_t block_dev; //!< Block device + nrf_block_dev_info_strings_t info_strings; //!< Block device information strings + nrf_block_dev_empty_config_t empty_config; //!< EMPTY block device config + nrf_block_dev_empty_work_t * p_work; //!< EMPTY block device work structure + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). } nrf_block_dev_empty_t; +/** @brief Name of the module used for logger messaging. + */ +#define NRF_BLOCK_DEV_EMPTY_LOG_NAME block_dev_empty + /** * @brief Defines a EMPTY block device. * @@ -110,13 +115,20 @@ typedef struct { * @param config Configuration @ref nrf_block_dev_empty_config_t * @param info Info strings @ref NFR_BLOCK_DEV_INFO_CONFIG * */ -#define NRF_BLOCK_DEV_EMPTY_DEFINE(name, config, info) \ - static nrf_block_dev_empty_work_t CONCAT_2(name, _work); \ - static const nrf_block_dev_empty_t name = { \ - .block_dev = { .p_ops = &nrf_block_device_empty_ops }, \ - .info_strings = BRACKET_EXTRACT(info), \ - .empty_config = config, \ - .p_work = &CONCAT_2(name, _work), \ +#define NRF_BLOCK_DEV_EMPTY_DEFINE(name, config, info) \ + static nrf_block_dev_empty_work_t CONCAT_2(name, _work); \ + NRF_LOG_INSTANCE_REGISTER(NRF_BLOCK_DEV_EMPTY_LOG_NAME, name, \ + NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR, \ + NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR, \ + NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL, \ + NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED ? \ + NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + static const nrf_block_dev_empty_t name = { \ + .block_dev = { .p_ops = &nrf_block_device_empty_ops }, \ + .info_strings = BRACKET_EXTRACT(info), \ + .empty_config = config, \ + .p_work = &CONCAT_2(name, _work), \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_BLOCK_DEV_EMPTY_LOG_NAME, name) \ } /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/nrf_block_dev.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/nrf_block_dev.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/nrf_block_dev.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/nrf_block_dev.h index 7955932..0f57d92 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/nrf_block_dev.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/nrf_block_dev.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_BLOCK_DEV_H__ #define NRF_BLOCK_DEV_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c similarity index 87% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c index 5ca286a..860c925 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_block_dev_qspi.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,10 +35,13 @@ * 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(NRF_BLOCK_DEV_QSPI) #include "nrf_serial_flash_params.h" #include "nrf_block_dev_qspi.h" +#include /**@file * @@ -48,6 +51,15 @@ * @brief This module implements block device API. It should be used as a reference block device. */ +#if NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#else +#define NRF_LOG_LEVEL 0 +#endif +#include "nrf_log.h" + #define QSPI_STD_CMD_WRSR 0x01 /**< Write status register command*/ #define QSPI_STD_CMD_RSTEN 0x66 /**< Reset enable command*/ #define QSPI_STD_CMD_RST 0x99 /**< Reset command*/ @@ -292,27 +304,33 @@ static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev, ret_code_t ret = NRF_SUCCESS; + NRF_LOG_INST_DEBUG(p_qspi_dev->p_log, "Init"); + if (p_qspi_dev->qspi_bdev_config.block_size % BD_PAGE_PROGRAM_SIZE) { /*Unsupported block size*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Unsupported block size because of program page size"); return NRF_ERROR_NOT_SUPPORTED; } if (NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE % p_qspi_dev->qspi_bdev_config.block_size) { /*Unsupported block size*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Unsupported block size because of erase unit size"); return NRF_ERROR_NOT_SUPPORTED; } if (m_active_qspi_dev) { /* QSPI instance is BUSY*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Cannot init because QSPI is busy"); return NRF_ERROR_BUSY; } ret = nrf_drv_qspi_init(p_qspi_cfg, qspi_handler, (void *)p_blk_dev); if (ret != NRF_SUCCESS) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI init error: %"PRIu32"", ret); return ret; } @@ -329,6 +347,7 @@ static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev, ret = nrf_drv_qspi_cinstr_xfer(&cinstr_cfg, NULL, NULL); if (ret != NRF_SUCCESS) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI reset enable command error: %"PRIu32"", ret); return ret; } @@ -337,6 +356,7 @@ static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev, ret = nrf_drv_qspi_cinstr_xfer(&cinstr_cfg, NULL, NULL); if (ret != NRF_SUCCESS) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI reset command error: %"PRIu32"", ret); return ret; } @@ -347,6 +367,7 @@ static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev, ret = nrf_drv_qspi_cinstr_xfer(&cinstr_cfg, NULL, rdid_buf); if (ret != NRF_SUCCESS) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI get 3 byte id error: %"PRIu32"", ret); return ret; } @@ -354,11 +375,13 @@ static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev, if (!serial_flash_id) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI FLASH not supported"); return NRF_ERROR_NOT_SUPPORTED; } if (serial_flash_id->erase_size != NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI FLASH erase unit size not supported"); return NRF_ERROR_NOT_SUPPORTED; } @@ -368,6 +391,7 @@ static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev, if (!blk_count || (blk_count % BD_BLOCKS_PER_ERASEUNIT(blk_size))) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI FLASH block size not supported"); return NRF_ERROR_NOT_SUPPORTED; } @@ -405,6 +429,8 @@ static ret_code_t block_dev_qspi_uninit(nrf_block_dev_t const * p_blk_dev) CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev); nrf_block_dev_qspi_work_t * p_work = p_qspi_dev->p_work; + NRF_LOG_INST_DEBUG(p_qspi_dev->p_log, "Uninit"); + if (m_active_qspi_dev != p_qspi_dev) { /* QSPI instance is BUSY*/ @@ -414,6 +440,7 @@ static ret_code_t block_dev_qspi_uninit(nrf_block_dev_t const * p_blk_dev) if (p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE) { /* Previous asynchronous operation in progress*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Cannot uninit because QSPI is busy"); return NRF_ERROR_BUSY; } @@ -449,15 +476,36 @@ static ret_code_t block_dev_qspi_read_req(nrf_block_dev_t const * p_blk_dev, ret_code_t ret = NRF_SUCCESS; + NRF_LOG_INST_DEBUG( + p_qspi_dev->p_log, + "Read req from block %"PRIu32" size %"PRIu32"(x%"PRIu32") to %"PRIXPTR, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_size, + p_blk->p_buff); + + if ((p_blk->blk_id + p_blk->blk_count) > p_work->geometry.blk_count) + { + NRF_LOG_INST_ERROR( + p_qspi_dev->p_log, + "Out of range read req block %"PRIu32" count %"PRIu32" while max is %"PRIu32, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count); + return NRF_ERROR_INVALID_ADDR; + } + if (m_active_qspi_dev != p_qspi_dev) { /* QSPI instance is BUSY*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Cannot read because QSPI is busy"); return NRF_ERROR_BUSY; } if (p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE) { /* Previous asynchronous operation in progress*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Cannot read because of ongoing previous operation"); return NRF_ERROR_BUSY; } @@ -472,6 +520,7 @@ static ret_code_t block_dev_qspi_read_req(nrf_block_dev_t const * p_blk_dev, if (ret != NRF_SUCCESS) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI read error: %"PRIu32"", ret); p_work->state = NRF_BLOCK_DEV_QSPI_STATE_IDLE; return ret; } @@ -618,15 +667,36 @@ static ret_code_t block_dev_qspi_write_req(nrf_block_dev_t const * p_blk_dev, ret_code_t ret = NRF_SUCCESS; + NRF_LOG_INST_DEBUG( + p_qspi_dev->p_log, + "Write req to block %"PRIu32" size %"PRIu32"(x%"PRIu32") from %"PRIXPTR, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_size, + p_blk->p_buff); + + if ((p_blk->blk_id + p_blk->blk_count) > p_work->geometry.blk_count) + { + NRF_LOG_INST_ERROR( + p_qspi_dev->p_log, + "Out of range write req block %"PRIu32" count %"PRIu32" while max is %"PRIu32, + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count); + return NRF_ERROR_INVALID_ADDR; + } + if (m_active_qspi_dev != p_qspi_dev) { /* QSPI instance is BUSY*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Cannot write because QSPI is busy"); return NRF_ERROR_BUSY; } if (p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE) { /* Previous asynchronous operation in progress*/ + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "Cannot write because of ongoing previous operation"); return NRF_ERROR_BUSY; } @@ -662,6 +732,7 @@ static ret_code_t block_dev_qspi_write_req(nrf_block_dev_t const * p_blk_dev, if (ret != NRF_SUCCESS) { + NRF_LOG_INST_ERROR(p_qspi_dev->p_log, "QSPI write error: %"PRIu32"", ret); p_work->state = NRF_BLOCK_DEV_QSPI_STATE_IDLE; return ret; } @@ -689,6 +760,7 @@ static ret_code_t block_dev_qspi_ioctl(nrf_block_dev_t const * p_blk_dev, case NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH: { bool * p_flushing = p_data; + NRF_LOG_INST_DEBUG(p_qspi_dev->p_log, "IOCtl: Cache flush"); if (p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE) { return NRF_ERROR_BUSY; @@ -753,5 +825,5 @@ const nrf_block_dev_ops_t nrf_block_device_qspi_ops = { .geometry = block_dev_qspi_geometry, }; - /** @} */ +#endif // NRF_MODULE_ENABLED(NRF_BLOCK_DEV_QSPI) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h index e3f9bbf..65ce56c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_block_dev_qspi.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_BLOCK_DEV_QSPI_H__ #define NRF_BLOCK_DEV_QSPI_H__ @@ -46,6 +46,7 @@ extern "C" { #include "nrf_block_dev.h" #include "nrf_drv_qspi.h" +#include "nrf_log_instance.h" /**@file * @@ -103,6 +104,10 @@ typedef enum { NRF_BLOCK_DEV_QSPI_FLAG_CACHE_WRITEBACK = (1u << 0) //!< Cache write-back mode enable flag } nrf_block_dev_qspi_flag_t; +/** @brief Name of the module used for logger messaging. + */ +#define NRF_BLOCK_DEV_QSPI_LOG_NAME block_dev_qspi + /** * @brief QSPI block device config initializer (@ref nrf_block_dev_qspi_config_t) * @@ -129,10 +134,11 @@ typedef struct { * @brief QSPI block device * */ typedef struct { - nrf_block_dev_t block_dev; //!< Block device - nrf_block_dev_info_strings_t info_strings; //!< Block device information strings - nrf_block_dev_qspi_config_t qspi_bdev_config; //!< QSPI block device config - nrf_block_dev_qspi_work_t * p_work; //!< QSPI block device work structure + nrf_block_dev_t block_dev; //!< Block device + nrf_block_dev_info_strings_t info_strings; //!< Block device information strings + nrf_block_dev_qspi_config_t qspi_bdev_config; //!< QSPI block device config + nrf_block_dev_qspi_work_t * p_work; //!< QSPI block device work structure + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). } nrf_block_dev_qspi_t; /** @@ -142,13 +148,20 @@ typedef struct { * @param config Configuration @ref nrf_block_dev_qspi_config_t * @param info Info strings @ref NFR_BLOCK_DEV_INFO_CONFIG * */ -#define NRF_BLOCK_DEV_QSPI_DEFINE(name, config, info) \ - static nrf_block_dev_qspi_work_t CONCAT_2(name, _work); \ - static const nrf_block_dev_qspi_t name = { \ - .block_dev = { .p_ops = &nrf_block_device_qspi_ops }, \ - .info_strings = BRACKET_EXTRACT(info), \ - .qspi_bdev_config = config, \ - .p_work = &CONCAT_2(name, _work), \ +#define NRF_BLOCK_DEV_QSPI_DEFINE(name, config, info) \ + static nrf_block_dev_qspi_work_t CONCAT_2(name, _work); \ + NRF_LOG_INSTANCE_REGISTER(NRF_BLOCK_DEV_QSPI_LOG_NAME, name, \ + NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR, \ + NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR, \ + NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL, \ + NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED ? \ + NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + static const nrf_block_dev_qspi_t name = { \ + .block_dev = { .p_ops = &nrf_block_device_qspi_ops }, \ + .info_strings = BRACKET_EXTRACT(info), \ + .qspi_bdev_config = config, \ + .p_work = &CONCAT_2(name, _work), \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_BLOCK_DEV_QSPI_LOG_NAME, name) \ } /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_serial_flash_params.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_serial_flash_params.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_serial_flash_params.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_serial_flash_params.c index 28bbdd2..7ed9f16 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_serial_flash_params.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_serial_flash_params.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_serial_flash_params.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_serial_flash_params.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_serial_flash_params.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_serial_flash_params.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_serial_flash_params.h index eec6d6c..519d279 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/qspi/nrf_serial_flash_params.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/qspi/nrf_serial_flash_params.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SERIAL_FLASH_PARAMS_H__ #define NRF_SERIAL_FLASH_PARAMS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/ram/nrf_block_dev_ram.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/ram/nrf_block_dev_ram.c similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/ram/nrf_block_dev_ram.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/ram/nrf_block_dev_ram.c index ba834a1..19b883b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/ram/nrf_block_dev_ram.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/ram/nrf_block_dev_ram.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,9 +35,12 @@ * 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(NRF_BLOCK_DEV_RAM) #include "nrf_block_dev_ram.h" +#include /**@file * @@ -47,6 +50,15 @@ * @brief This module implements block device API. It should be used as a reference block device. */ +#if NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_LOG_INST_DEBUG_COLOR NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#else +#define NRF_LOG_LEVEL 0 +#endif +#include "nrf_log.h" + static ret_code_t block_dev_ram_init(nrf_block_dev_t const * p_blk_dev, nrf_block_dev_ev_handler ev_handler, void const * p_context) @@ -55,6 +67,7 @@ static ret_code_t block_dev_ram_init(nrf_block_dev_t const * p_blk_dev, nrf_block_dev_ram_t const * p_ram_dev = CONTAINER_OF(p_blk_dev, nrf_block_dev_ram_t, block_dev); nrf_block_dev_ram_work_t * p_work = p_ram_dev->p_work; + NRF_LOG_INST_DEBUG(p_ram_dev->p_log, "Init"); /* Calculate block device geometry.... */ p_work->geometry.blk_size = p_ram_dev->ram_config.block_size; p_work->geometry.blk_count = p_ram_dev->ram_config.size / @@ -84,6 +97,7 @@ static ret_code_t block_dev_ram_uninit(nrf_block_dev_t const * p_blk_dev) nrf_block_dev_ram_t const * p_ram_dev = CONTAINER_OF(p_blk_dev, nrf_block_dev_ram_t, block_dev); nrf_block_dev_ram_work_t * p_work = p_ram_dev->p_work; + NRF_LOG_INST_DEBUG(p_ram_dev->p_log, "Uninit"); if (p_work->ev_handler) { /*Asynchronous operation (simulation)*/ @@ -111,6 +125,30 @@ static ret_code_t block_dev_ram_req(nrf_block_dev_t const * p_blk_dev, nrf_block_dev_ram_config_t const * p_ram_config = &p_ram_dev->ram_config; nrf_block_dev_ram_work_t const * p_work = p_ram_dev->p_work; + NRF_LOG_INST_DEBUG(p_ram_dev->p_log, + ((event == NRF_BLOCK_DEV_EVT_BLK_READ_DONE) ? + "Read req from block %"PRIu32" size %"PRIu32"(x%"PRIu32") to %"PRIXPTR + : + "Write req to block %"PRIu32" size %"PRIu32"(x%"PRIu32") from %"PRIXPTR), + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_size, + p_blk->p_buff); + + if ((p_blk->blk_id + p_blk->blk_count) > p_work->geometry.blk_count) + { + NRF_LOG_INST_ERROR(p_ram_dev->p_log, + ((event == NRF_BLOCK_DEV_EVT_BLK_READ_DONE) ? + "Out of range read req block %"PRIu32" count %"PRIu32" while max is %"PRIu32 + : + "Out of range write req block %"PRIu32" count %"PRIu32", while max is %"PRIu32), + p_blk->blk_id, + p_blk->blk_count, + p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count); + return NRF_ERROR_INVALID_ADDR; + + } + /*Synchronous operation*/ uint8_t * p_buff = p_ram_config->p_work_buffer; p_buff += p_blk->blk_id * p_work->geometry.blk_size; @@ -158,6 +196,7 @@ static ret_code_t block_dev_ram_ioctl(nrf_block_dev_t const * p_blk_dev, case NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH: { bool * p_flushing = p_data; + NRF_LOG_INST_DEBUG(p_ram_dev->p_log, "IOCtl: Cache flush"); if (p_flushing) { *p_flushing = false; @@ -201,5 +240,5 @@ const nrf_block_dev_ops_t nrf_block_device_ram_ops = { .geometry = block_dev_ram_geometry, }; - /** @} */ +#endif // NRF_MODULE_ENABLED(NRF_BLOCK_DEV_RAM) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/ram/nrf_block_dev_ram.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/ram/nrf_block_dev_ram.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/ram/nrf_block_dev_ram.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/ram/nrf_block_dev_ram.h index c860f9a..7ac1c23 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/ram/nrf_block_dev_ram.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/ram/nrf_block_dev_ram.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_BLOCK_DEV_RAM_H__ #define NRF_BLOCK_DEV_RAM_H__ @@ -45,6 +45,7 @@ extern "C" { #endif #include "nrf_block_dev.h" +#include "nrf_log_instance.h" /**@file * @@ -70,6 +71,9 @@ typedef struct { void const * p_context; //!< Context handle passed to event handler } nrf_block_dev_ram_work_t; +/** @brief Name of the module used for logger messaging. + */ +#define NRF_BLOCK_DEV_RAM_LOG_NAME block_dev_ram /** * @brief RAM block device config initializer (@ref nrf_block_dev_ram_config_t) @@ -101,6 +105,7 @@ typedef struct { nrf_block_dev_info_strings_t info_strings; //!< Block device information strings nrf_block_dev_ram_config_t ram_config; //!< Ram block device config nrf_block_dev_ram_work_t * p_work; //!< Ram block device work structure + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). } nrf_block_dev_ram_t; /** @@ -110,13 +115,20 @@ typedef struct { * @param config Configuration @ref nrf_block_dev_ram_config_t * @param info Info strings @ref NFR_BLOCK_DEV_INFO_CONFIG * */ -#define NRF_BLOCK_DEV_RAM_DEFINE(name, config, info) \ - static nrf_block_dev_ram_work_t CONCAT_2(name, _work); \ - static const nrf_block_dev_ram_t name = { \ - .block_dev = { .p_ops = &nrf_block_device_ram_ops }, \ - .info_strings = BRACKET_EXTRACT(info), \ - .ram_config = config, \ - .p_work = &CONCAT_2(name, _work), \ +#define NRF_BLOCK_DEV_RAM_DEFINE(name, config, info) \ + static nrf_block_dev_ram_work_t CONCAT_2(name, _work); \ + NRF_LOG_INSTANCE_REGISTER(NRF_BLOCK_DEV_RAM_LOG_NAME, name, \ + NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR, \ + NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR, \ + NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL, \ + NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED ? \ + NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + static const nrf_block_dev_ram_t name = { \ + .block_dev = { .p_ops = &nrf_block_device_ram_ops }, \ + .info_strings = BRACKET_EXTRACT(info), \ + .ram_config = config, \ + .p_work = &CONCAT_2(name, _work), \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_BLOCK_DEV_RAM_LOG_NAME, name) \ } /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c index 3b02bc6..1a40ebe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_block_dev_sdc.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h index 8233bd9..1d2add4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/block_dev/sdc/nrf_block_dev_sdc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ant_dfu/nrf_dfu_ant.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ant_dfu/nrf_dfu_ant.c new file mode 100644 index 0000000..5c53638 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ant_dfu/nrf_dfu_ant.c @@ -0,0 +1,772 @@ +/** + * This software is subject to the ANT+ Shared Source License + * www.thisisant.com/swlicenses + * Copyright (c) Garmin Canada Inc. 2018 + * 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 Garmin 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 +#include +#include "sdk_common.h" + +#include "ant_channel_config.h" +#include "ant_interface.h" +#include "ant_parameters.h" +#include "nrf_assert.h" +#include "nrf_balloc.h" +#include "nrf_bootloader_info.h" +#include "nrf_dfu_handling_error.h" +#include "nrf_dfu_req_handler.h" +#include "nrf_dfu_transport.h" +#include "nrf_dfu_mbr.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ant.h" +#include "nrf_soc.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_ant +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/**@file + * + * @defgroup nrf_dfu_ant ANT transport for reference DFU. + * @ingroup nrf_dfu + * @brief Device Firmware Update (DFU) transport layer using ANT. + * + * Transport documentation: + * + * The ANT transport uses all of the same opcodes and payload formats as the + * UART serial transport. The only differences are the packet header format and + * some extra details to deal with retransmissions. + * + * The device receiving the update is the ANT master. The format of the + * broadcast buffer is as follows; + * Byte 0: Current Slave -> Master sequence number. + * Byte 1: Current Master -> Slave sequence number. + * Bytes 2-7: Reserved, set to 0. + * + * The sequence numbers are used to detect retransmissions, any messages sent + * with a sequence number equivalent to the current sequence will be ignored. + * + * When the slave first connects to the master it should inspect the broadcast + * data in order to synchronize its sequence counters. + * + * All commands/responses are padded out to the nearest 8-byte boundary after + * framing, and then sent using either a burst or acknowledged data depending on + * length (ack data is used for 8-byte messages). The message transmission is + * retried until an EVENT_TRANSFER_TX_COMPLETE event is received. + * All messages are framed using the following format: + * Bytes 0-1: Message length before padding, little endian, includes header. + * Byte 2: Sequence number. Increment for every new message. + * Byte 3: Op code. Always 0x60 for responses. + * Bytes 4-N: Command/Response payload. This follows the same format as the + * UART serial transport, without any SLIP encoding. + * + * As a final note, the MTU for this protocol is the maximum size of a burst + * that can be received. + */ + +/** Packet header is always 2 byte length + seq num + op code */ +#define PKT_HEADER_SIZE 4 + +/** Maximum size of the payload in a write command. */ +#define MAX_WRITE_PAYLOAD (NRF_DFU_ANT_MTU - PKT_HEADER_SIZE) + +/** Bursts are always a multiple of the standard data size. */ +STATIC_ASSERT_MSG( + ALIGN_NUM(ANT_STANDARD_DATA_PAYLOAD_SIZE, NRF_DFU_ANT_MTU) == NRF_DFU_ANT_MTU, + "ANT MTU must be a multiple of " STRINGIFY(ANT_STANDARD_DATA_PAYLOAD_SIZE)); + +/** Number of buffers to reserve space for with balloc. */ +#if (NRF_DFU_ANT_BUFFERS_OVERRIDE) +#define NUM_BUFFERS NRF_DFU_ANT_BUFFERS +#else +#define NUM_BUFFERS CEIL_DIV(CODE_PAGE_SIZE, MAX_WRITE_PAYLOAD) +#endif + +static uint32_t ant_dfu_init(nrf_dfu_observer_t observer); +static uint32_t ant_dfu_close(nrf_dfu_transport_t const * p_exception); + +static ant_channel_config_t m_channel_config = { + .channel_number = 0, + .channel_type = CHANNEL_TYPE_MASTER, + .rf_freq = NRF_DFU_ANT_RF_FREQ, + .transmission_type = 1, // Non-shared, no global pages. + .device_type = NRF_DFU_ANT_DEV_TYPE, + .channel_period = NRF_DFU_ANT_CHANNEL_PERIOD, +}; + +static nrf_dfu_observer_t m_observer; +/** Has transport been initialized by DFU core */ +static bool m_initialized = false; +/** Has the channel started broadcasting */ +static bool m_started = false; +/** Has some data been received on the transport. */ +static bool m_active = false; + +/** State tracking for rx transfers. */ +static struct +{ + /** Buffer for holding the command. */ + uint8_t * buff; + /** Amount of data written */ + size_t offset; + /** Sequence of last processed command. */ + uint8_t seq; +} m_rx; + +/** State tracking for tx transfers. */ +static struct +{ + /** Raw data to send. */ + uint8_t resp[ALIGN_NUM(ANT_STANDARD_DATA_PAYLOAD_SIZE, + PKT_HEADER_SIZE + sizeof(nrf_dfu_response_t))]; + /** Length of data to send. 0 Indicates no response queued. */ + size_t len; + /** Sequence number of last queued response. */ + uint8_t seq; + /** + * Used as burst flag for softdevice, allows to busy loop until all data is + * accepted by softdevice. + */ + volatile bool buffering; + /** + * Indicate that a new response was generated before the last one was + * confirmed. + */ + bool response_overwritten; + /** Data buffer used for broadcast messages. */ + uint8_t bcast_data[ANT_STANDARD_DATA_PAYLOAD_SIZE]; +} m_tx; + +/** State tracking for progress notifications. */ +static struct +{ + /** Requested PRN */ + uint16_t limit; + /** How many more write commands until a CRC should be sent back. */ + uint16_t remaining; +} m_pkt_notify; + +DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const ant_dfu_transport) = { + .init_func = ant_dfu_init, + .close_func = ant_dfu_close, +}; + +NRF_BALLOC_DEF(m_buffer_pool, NRF_DFU_ANT_MTU, NUM_BUFFERS); + +static void release_rx_buff(void) +{ + if (m_rx.buff != NULL) + { + nrf_balloc_free(&m_buffer_pool, m_rx.buff); + m_rx.buff = NULL; + } +} + +static void transmit_response(void) +{ + uint32_t err_code = NRF_SUCCESS; + + size_t full_len = ALIGN_NUM(ANT_STANDARD_DATA_PAYLOAD_SIZE, m_tx.len); + + // Pad out with 0's. + memset(&m_tx.resp[m_tx.len], 0, full_len - m_tx.len); + + if (full_len > ANT_STANDARD_DATA_PAYLOAD_SIZE) + { + err_code = sd_ant_burst_handler_request( + m_channel_config.channel_number, + full_len, m_tx.resp, + BURST_SEGMENT_START | BURST_SEGMENT_END); + } else + { + err_code = sd_ant_acknowledge_message_tx( + m_channel_config.channel_number, + full_len, m_tx.resp); + } + + // Wait for buffer to be consumed. + // TODO: wait flag management needs to be improved if this will coexist with + // other channels. + while (err_code == NRF_SUCCESS && m_tx.buffering) + { + err_code = sd_app_evt_wait(); + } + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Sending response failed with error %d", err_code); + } +} + +static void update_bcast_data(void) +{ + memset(m_tx.bcast_data, 0, sizeof(m_tx.bcast_data)); + m_tx.bcast_data[0] = m_rx.seq; + m_tx.bcast_data[1] = m_tx.seq; + + if (NRF_SUCCESS != sd_ant_broadcast_message_tx( + m_channel_config.channel_number, + sizeof(m_tx.bcast_data), m_tx.bcast_data)) + { + NRF_LOG_WARNING("Unable to update broadcast data."); + } +} + +static void handle_write_complete(void * p_buf) +{ + nrf_balloc_free(&m_buffer_pool, p_buf); +} + +static void prepare_response(nrf_dfu_response_t * p_res) +{ + if (m_tx.len) + { + NRF_LOG_WARNING("Overwriting previous response."); + m_tx.response_overwritten = true; + } + + // reserve first 2 bytes for length. + m_tx.len = 2; + + m_tx.resp[m_tx.len++] = ++(m_tx.seq); + m_tx.resp[m_tx.len++] = NRF_DFU_OP_RESPONSE; + m_tx.resp[m_tx.len++] = p_res->request; + m_tx.resp[m_tx.len++] = p_res->result; + + if (p_res->result == NRF_DFU_RES_CODE_SUCCESS) + { + switch(p_res->request) + { + case NRF_DFU_OP_PROTOCOL_VERSION: + { + m_tx.resp[m_tx.len++] = p_res->protocol.version; + } break; + + case NRF_DFU_OP_CRC_GET: + { + m_tx.len += uint32_encode( + p_res->crc.offset, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->crc.crc, &m_tx.resp[m_tx.len]); + } break; + + case NRF_DFU_OP_OBJECT_SELECT: + { + m_tx.len += uint32_encode( + p_res->select.max_size, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->select.offset, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->select.crc, &m_tx.resp[m_tx.len]); + } break; + + case NRF_DFU_OP_MTU_GET: + { + m_tx.len += uint16_encode( + p_res->mtu.size, &m_tx.resp[m_tx.len]); + } break; + + case NRF_DFU_OP_PING: + { + m_tx.resp[m_tx.len++] = p_res->ping.id; + } break; + + case NRF_DFU_OP_HARDWARE_VERSION: + { + m_tx.len += uint32_encode( + p_res->hardware.part, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->hardware.variant, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->hardware.memory.rom_size, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->hardware.memory.rom_page_size, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->hardware.memory.ram_size, &m_tx.resp[m_tx.len]); + } break; + + case NRF_DFU_OP_FIRMWARE_VERSION: + { + m_tx.resp[m_tx.len++] = p_res->firmware.type; + m_tx.len += uint32_encode( + p_res->firmware.version, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->firmware.addr, &m_tx.resp[m_tx.len]); + m_tx.len += uint32_encode( + p_res->firmware.len, &m_tx.resp[m_tx.len]); + } break; + + default: + break; + } + } + else if (p_res->result == NRF_DFU_RES_CODE_EXT_ERROR) + { + m_tx.resp[m_tx.len++] = ext_error_get(); + UNUSED_RETURN_VALUE(ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR)); + } + + // Finally fill in the length. + UNUSED_RETURN_VALUE(uint16_encode(m_tx.len, m_tx.resp)); + + // Safety check buffer overflow. + ASSERT(m_tx.len <= sizeof(m_tx.resp)); + + if (!m_tx.response_overwritten) + { + // Can send out the response immediately if there wasn't a previous one + // queued. + transmit_response(); + } +} + +static void handle_response(nrf_dfu_response_t * p_res, void * p_context) +{ + UNUSED_PARAMETER(p_context); + + if (p_res->result != NRF_DFU_RES_CODE_SUCCESS) + { + NRF_LOG_WARNING("Operation %d had result %d", + p_res->request, p_res->result); + } + + if (p_res->request == NRF_DFU_OP_OBJECT_WRITE) + { + if (m_pkt_notify.limit == 0 || + --m_pkt_notify.remaining != 0) + { + // No packet notification needed, filter out response. + return; + } + + // Packet Notification time, send a CRC response. + m_pkt_notify.remaining = m_pkt_notify.limit; + p_res->request = NRF_DFU_OP_CRC_GET; + uint32_t offset = p_res->write.offset; + uint32_t crc = p_res->write.crc; + p_res->crc.offset = offset; + p_res->crc.crc = crc; + } + + prepare_response(p_res); +} + +static uint32_t handle_request(void) +{ + uint16_t len = uint16_decode(m_rx.buff); + uint16_t offset = sizeof(uint16_t); + + if (len < PKT_HEADER_SIZE || len > m_rx.offset) + { + NRF_LOG_WARNING("Ignoring command with invalid length."); + return NRF_ERROR_DATA_SIZE; + } + + uint8_t seq = m_rx.buff[offset++]; + if (!m_active) + { + m_active = true; + // Close all other transports. + UNUSED_RETURN_VALUE(nrf_dfu_transports_close(&ant_dfu_transport)); + } + else if (seq == m_rx.seq) + { + NRF_LOG_DEBUG("Ignoring repeated command"); + return NRF_SUCCESS; + } + + m_rx.seq = seq; + + nrf_dfu_request_t request = { + .request = (nrf_dfu_op_t)m_rx.buff[offset++], + .callback.response = handle_response, + }; + + switch(request.request) + { + case NRF_DFU_OP_OBJECT_CREATE: + { + request.create.object_type = m_rx.buff[offset++]; + request.create.object_size = uint32_decode(&m_rx.buff[offset]); + offset += sizeof(uint32_t); + } break; + + case NRF_DFU_OP_RECEIPT_NOTIF_SET: + { + request.prn.target = uint16_decode(&m_rx.buff[offset]); + offset += sizeof(uint16_t); + } break; + + case NRF_DFU_OP_OBJECT_SELECT: + { + request.select.object_type = m_rx.buff[offset++]; + } break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + request.write.p_data = &m_rx.buff[offset]; + request.write.len = len - offset; + offset = len; + } break; + + case NRF_DFU_OP_PING: + { + request.ping.id = m_rx.buff[offset++]; + } break; + + case NRF_DFU_OP_FIRMWARE_VERSION: + { + request.firmware.image_number = m_rx.buff[offset++]; + } break; + + case NRF_DFU_OP_MTU_GET: + { + NRF_LOG_DEBUG("ANT DFU: Responding to MTU request with %d", + NRF_DFU_ANT_MTU); + request.mtu.size = NRF_DFU_ANT_MTU; + } break; + + default: + // Do nothing. + break; + } + + if (offset > len) + { + NRF_LOG_WARNING("Ignoring command with invalid length"); + return NRF_ERROR_DATA_SIZE; + } + + // Some processing that is only safe to do if accepting the command. + + switch (request.request) + { + case NRF_DFU_OP_RECEIPT_NOTIF_SET: + { + m_pkt_notify.limit = request.prn.target; + m_pkt_notify.remaining = m_pkt_notify.limit; + } break; + + case NRF_DFU_OP_OBJECT_CREATE: + case NRF_DFU_OP_OBJECT_SELECT: + { + m_pkt_notify.remaining = m_pkt_notify.limit; + } break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + // Ownership of buffer is transferred to the write command. + request.callback.write = handle_write_complete; + m_rx.buff = NULL; + } break; + + default: + break; + } + + return nrf_dfu_req_handler_on_req(&request); +} + +static void handle_tx_transfer_complete(bool success) +{ + if (m_tx.response_overwritten) + { + // By treating the result as a failure the retransmission will send out + // the new response. + success = false; + m_tx.response_overwritten = false; + } + + if (success) + { + m_tx.len = 0; + update_bcast_data(); + } + else + { + transmit_response(); + } +} + +static void handle_rx_transfer_start() +{ + if (m_rx.buff == NULL) + { + m_rx.buff = nrf_balloc_alloc(&m_buffer_pool); + if (m_rx.buff != NULL) + { + NRF_LOG_INFO("Allocated buffer %x", m_rx.buff); + } + else + { + NRF_LOG_ERROR("Unable to allocate buffer for incoming packet."); + return; + } + } + + NRF_LOG_DEBUG("Resetting rx pointer."); + m_rx.offset = 0; +} + +static void handle_rx_transfer_complete(bool success) +{ + if (success) + { + uint32_t err_code = handle_request(); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Error %d handling request.", err_code); + } + } + + release_rx_buff(); +} + +static void handle_rx_transfer_data(uint8_t * data, size_t len) +{ + if (m_rx.buff == NULL) + { + NRF_LOG_DEBUG("Ignoring transfer data."); + return; + } + + if (m_rx.offset + len > NRF_DFU_ANT_MTU) + { + NRF_LOG_ERROR("Received packet overflows MTU."); + handle_rx_transfer_complete(false); + return; + } + + memcpy(&m_rx.buff[m_rx.offset], data, len); + m_rx.offset += len; +} + +static void handle_data_mesg(ANT_MESSAGE * p_msg) +{ + bool is_first = false; + bool is_last = false; + uint8_t len = ANT_STANDARD_DATA_PAYLOAD_SIZE; + + switch(p_msg->ANT_MESSAGE_ucMesgID) + { + case MESG_BROADCAST_DATA_ID: + { + // Broadcast data is ignored. + len = 0; + } break; + + case MESG_ACKNOWLEDGED_DATA_ID: + { + is_first = true; + is_last = true; + } break; + + case MESG_ADV_BURST_DATA_ID: + { + len = p_msg->ANT_MESSAGE_ucSize - MESG_CHANNEL_NUM_SIZE; + } // FALL-THROUGH : both burst types act the same other than len. + case MESG_BURST_DATA_ID: + { + uint8_t seq = p_msg->ANT_MESSAGE_ucChannel & SEQUENCE_NUMBER_MASK; + is_first = seq == SEQUENCE_FIRST_MESSAGE; + is_last = !!(seq & SEQUENCE_LAST_MESSAGE); + } break; + } + + if (len != 0) + { + if (is_first) + { + handle_rx_transfer_start(); + } + + handle_rx_transfer_data(p_msg->ANT_MESSAGE_aucPayload, len); + + if (is_last) + { + handle_rx_transfer_complete(true); + } + } +} + +static void ant_dfu_evt_handler(ant_evt_t * p_ant_evt, void * p_context) +{ + // Ignore messages meant for other channels. + if (p_ant_evt->channel != m_channel_config.channel_number) + { + return; + } + + switch(p_ant_evt->event) + { + case EVENT_TX: + { + if (!m_started) + { + m_started = true; + m_observer(NRF_DFU_EVT_TRANSPORT_ACTIVATED); + } + } break; + + case EVENT_TRANSFER_TX_COMPLETED: + handle_tx_transfer_complete(true); + break; + case EVENT_TRANSFER_TX_FAILED: + handle_tx_transfer_complete(false); + break; + + case EVENT_RX: + handle_data_mesg(&p_ant_evt->message); + break; + + case EVENT_TRANSFER_RX_FAILED: + handle_rx_transfer_complete(false); + break; + } +} + +static uint32_t ant_dfu_init(nrf_dfu_observer_t observer) +{ + uint32_t err_code = NRF_SUCCESS; + if (m_initialized) + { + return err_code; + } + + NRF_SDH_ANT_OBSERVER(ant_dfu_observer, NRF_DFU_ANT_EVT_HANDLER_PRIO, + ant_dfu_evt_handler, NULL); + + m_observer = observer; + m_tx.seq = m_rx.seq = 0; + m_active = false; + m_started = false; + + NRF_LOG_DEBUG("Initializing ANT DFU transport"); + + err_code = nrf_balloc_init(&m_buffer_pool); + VERIFY_SUCCESS(err_code); + + err_code = nrf_dfu_mbr_init_sd(); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("Setting up vector table: 0x%08x", BOOTLOADER_START_ADDR); + err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_START_ADDR); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("Enabling softdevice"); + err_code = nrf_sdh_enable_request(); + VERIFY_SUCCESS(err_code); + + err_code = nrf_sdh_ant_enable(); + VERIFY_SUCCESS(err_code); + + static uint8_t adv_burst_conf[] = { + ADV_BURST_MODE_ENABLE, + ADV_BURST_MODES_SIZE_24_BYTES, + 0, // No required modes. + 0, 0, // Reserved + ADV_BURST_MODES_FREQ_HOP, // Optional Modes + 0, 0, // Reserved + // No optional configs. + }; + err_code = sd_ant_adv_burst_config_set(adv_burst_conf, sizeof(adv_burst_conf)); + VERIFY_SUCCESS(err_code); + + m_channel_config.device_number = NRF_FICR->DEVICEID[0]; + m_channel_config.transmission_type |= (NRF_FICR->DEVICEID[1] & 0xF) << 4; + + err_code = ant_channel_init(&m_channel_config); + VERIFY_SUCCESS(err_code); + + update_bcast_data(); + + err_code = sd_ant_channel_open(m_channel_config.channel_number); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("ANT transport intialized"); + + m_initialized = true; + return err_code; +} + +static uint32_t ant_dfu_close(nrf_dfu_transport_t const * p_exception) +{ + uint32_t err_code = NRF_SUCCESS; + + if (p_exception != &ant_dfu_transport && m_initialized) + { + NRF_LOG_DEBUG("Shutting down ANT DFU transport"); + + m_initialized = false; + + err_code = sd_ant_channel_close(m_channel_config.channel_number); + VERIFY_SUCCESS(err_code); + + uint8_t status; + do + { + // The initial wait is safe because the close command above would + // have generated at least 1 app event. + err_code = sd_app_evt_wait(); + VERIFY_SUCCESS(err_code); + err_code = sd_ant_channel_status_get( + m_channel_config.channel_number, &status); + VERIFY_SUCCESS(err_code); + } while ((status & STATUS_CHANNEL_STATE_MASK) != STATUS_ASSIGNED_CHANNEL); + + err_code = nrf_sdh_disable_request(); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("ANT transport disabled."); + } + + return err_code; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c new file mode 100644 index 0000000..e86a82c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c @@ -0,0 +1,1261 @@ +/** + * Copyright (c) 2016 - 2019, 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 "nrf_dfu_ble.h" + +#include +#include "sdk_common.h" +#include "nrf_dfu_transport.h" +#include "nrf_dfu_types.h" +#include "nrf_dfu_req_handler.h" +#include "nrf_dfu_handling_error.h" +#include "nrf_sdm.h" +#include "nrf_dfu_mbr.h" +#include "nrf_bootloader_info.h" +#include "ble.h" +#include "ble_srv_common.h" +#include "ble_hci.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include "nrf_balloc.h" +#include "nrf_delay.h" +#include "nrf_dfu_settings.h" +#include "nrf_dfu_ble.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_ble +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#ifndef NRF_DFU_BLE_ADV_INTERVAL +#define NRF_DFU_BLE_ADV_INTERVAL 40 /* 40 * 0,625ms = 25ms */ +#warning "sdk_config.h is not up to date." +#endif + +#define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */ + +#define APP_ADV_DATA_HEADER_SIZE 9 /**< Size of encoded advertisement data header (not including device name). */ +#define APP_ADV_DURATION BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising duration in units of 10 milliseconds. This is set to @ref BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED so that the advertisement is done as long as there there is a call to @ref dfu_transport_close function.*/ + +#define GATT_HEADER_LEN 3 /**< GATT header length. */ +#define GATT_PAYLOAD(mtu) ((mtu) - GATT_HEADER_LEN) /**< Length of the ATT payload for a given ATT MTU. */ +#define MAX_DFU_PKT_LEN (NRF_SDH_BLE_GATT_MAX_MTU_SIZE - GATT_HEADER_LEN) /**< Maximum length (in bytes) of the DFU Packet characteristic (3 bytes are used for the GATT opcode and handle). */ +#define MAX_RESPONSE_LEN 17 /**< Maximum length (in bytes) of the response to a Control Point command. */ +#define RESPONSE_HEADER_LEN 3 /**< The length of the header of a response. I.E. the index of the opcode-specific payload. */ + +#define DFU_BLE_FLAG_INITIALIZED (1 << 0) /**< Flag to check if the DFU service was initialized by the application.*/ +#define DFU_BLE_FLAG_USE_ADV_NAME (1 << 1) /**< Flag to indicate that advertisement name is to be used. */ +#define DFU_BLE_RESETTING_SOON (1 << 2) /**< Flag to indicate that the device will reset soon. */ + +#define BLE_OBSERVER_PRIO 2 /**< BLE observer priority. Controls the priority for BLE event handler. */ + +#if (NRF_DFU_BLE_BUFFERS_OVERRIDE) +/* If selected, use the override value. */ +#define MAX_DFU_BUFFERS NRF_DFU_BLE_BUFFERS +#else +#define MAX_DFU_BUFFERS ((CODE_PAGE_SIZE / MAX_DFU_PKT_LEN) + 1) +#endif + +#if (NRF_DFU_BLE_REQUIRES_BONDS) && (!NRF_SDH_BLE_SERVICE_CHANGED) +#error NRF_DFU_BLE_REQUIRES_BONDS requires NRF_SDH_BLE_SERVICE_CHANGED. \ + Please update the SoftDevice BLE stack configuration in sdk_config.h +#endif + +#if (MAX_DFU_PKT_LEN % 4) +#error Payload length should be a multiple of four. \ + Payload length is set to NRF_SDH_BLE_GATT_MAX_MTU_SIZE - 3. +#endif + + +DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const ble_dfu_transport) = +{ + .init_func = ble_dfu_transport_init, + .close_func = ble_dfu_transport_close, +}; + +#if (NRF_DFU_BLE_REQUIRES_BONDS) +static nrf_dfu_peer_data_t m_peer_data; +#else +static nrf_dfu_adv_name_t m_adv_name; +#endif + +static uint32_t m_flags; +static ble_dfu_t m_dfu; /**< Structure used to identify the Device Firmware Update service. */ +static uint16_t m_pkt_notif_target; /**< Number of packets of firmware data to be received before transmitting the next Packet Receipt Notification to the DFU Controller. */ +static uint16_t m_pkt_notif_target_cnt; /**< Number of packets of firmware data received after sending last Packet Receipt Notification or since the receipt of a @ref BLE_DFU_PKT_RCPT_NOTIF_ENABLED event from the DFU service, which ever occurs later.*/ +static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< Handle of the current connection. */ +static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; /**< Advertising handle used to identify an advertising set. */ +static nrf_dfu_observer_t m_observer; /**< Observer function called on certain events. */ + +static ble_gap_conn_params_t const m_gap_conn_params = +{ + .min_conn_interval = NRF_DFU_BLE_MIN_CONN_INTERVAL, + .max_conn_interval = NRF_DFU_BLE_MAX_CONN_INTERVAL, + /* This value is expressed in units of 10 ms, rather than 1 ms. */ + .conn_sup_timeout = NRF_DFU_BLE_CONN_SUP_TIMEOUT_MS / 10, + .slave_latency = 0, +}; + +NRF_BALLOC_DEF(m_buffer_pool, MAX_DFU_PKT_LEN, MAX_DFU_BUFFERS); + + +/**@brief Function for the Advertising functionality initialization. + * + * @details Encodes the required advertising data and passes it to the stack. + * The advertising data encoded here is specific for DFU. + */ +static uint32_t advertising_init(uint8_t adv_flags, ble_gap_adv_params_t const * const p_adv_params) +{ + uint32_t err_code; + uint16_t actual_device_name_length = BLE_GAP_ADV_SET_DATA_SIZE_MAX - APP_ADV_DATA_HEADER_SIZE; + + /* This needs to be static because of SoftDevice API requirements. */ + static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; + + ble_gap_adv_data_t m_adv_data = + { + .adv_data = + { + .p_data = m_enc_advdata, + .len = APP_ADV_DATA_HEADER_SIZE, + } + }; + + /* Encode flags. */ + m_enc_advdata[0] = 0x2; + m_enc_advdata[1] = BLE_GAP_AD_TYPE_FLAGS; + m_enc_advdata[2] = adv_flags; + + /* Encode 'more available' UUID list. */ + m_enc_advdata[3] = 0x3; + m_enc_advdata[4] = BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE; + m_enc_advdata[5] = LSB_16(BLE_DFU_SERVICE_UUID); + m_enc_advdata[6] = MSB_16(BLE_DFU_SERVICE_UUID); + + /* Get GAP device name and length. */ + err_code = sd_ble_gap_device_name_get(&m_enc_advdata[9], &actual_device_name_length); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Set GAP device in advertising data. + m_enc_advdata[7] = actual_device_name_length + 1; // (actual_length + ADV_AD_TYPE_FIELD_SIZE(1)) + m_enc_advdata[8] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME; + + m_adv_data.adv_data.len += actual_device_name_length; + + return sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, p_adv_params); +} + + +/**@brief Function for starting advertising. + */ +static uint32_t advertising_start(void) +{ + uint32_t err_code; + uint8_t adv_flag = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; + + ble_gap_adv_params_t adv_params = + { + .properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED, + .p_peer_addr = NULL, + .filter_policy = BLE_GAP_ADV_FP_ANY, + .interval = NRF_DFU_BLE_ADV_INTERVAL, + .duration = APP_ADV_DURATION, + .primary_phy = BLE_GAP_PHY_1MBPS, + }; + + NRF_LOG_DEBUG("Advertising..."); + +#if (NRF_DFU_BLE_REQUIRES_BONDS) + ble_gap_irk_t empty_irk = {{0}}; + + if (memcmp(m_peer_data.ble_id.id_info.irk, empty_irk.irk, sizeof(ble_gap_irk_t)) != 0) + { + adv_flag = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; + adv_params.filter_policy = BLE_GAP_ADV_FP_FILTER_CONNREQ; + + ble_gap_addr_t const * const p_gap_addr = &m_peer_data.ble_id.id_addr_info; + ble_gap_id_key_t const * const p_gap_id_key = &m_peer_data.ble_id; + + err_code = sd_ble_gap_whitelist_set(&p_gap_addr, 1); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("sd_ble_gap_whitelist_set() returned %s", + NRF_LOG_ERROR_STRING_GET(err_code)); + } + + err_code = sd_ble_gap_device_identities_set(&p_gap_id_key, NULL, 1); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("sd_ble_gap_device_identities_set() returned %s", + NRF_LOG_ERROR_STRING_GET(err_code)); + } + } +#endif /* NRF_DFU_BLE_REQUIRES_BONDS */ + + err_code = advertising_init(adv_flag, &adv_params); + VERIFY_SUCCESS(err_code); + + err_code = sd_ble_gap_adv_stop(m_adv_handle); + UNUSED_RETURN_VALUE(err_code); + + return sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG); +} + + +static bool is_cccd_configured(ble_dfu_t * p_dfu) +{ + uint8_t cccd_val_buf[BLE_CCCD_VALUE_LEN]; + + ble_gatts_value_t gatts_value = + { + .len = BLE_CCCD_VALUE_LEN, + .p_value = cccd_val_buf + }; + + /* Check the CCCD Value of DFU Control Point. */ + uint32_t err_code = sd_ble_gatts_value_get(m_conn_handle, + p_dfu->dfu_ctrl_pt_handles.cccd_handle, + &gatts_value); + VERIFY_SUCCESS(err_code); + + return ble_srv_is_notification_enabled(cccd_val_buf); +} + + +static ret_code_t response_send(uint8_t * p_buf, uint16_t len) +{ + ble_gatts_hvx_params_t hvx_params = + { + .handle = m_dfu.dfu_ctrl_pt_handles.value_handle, + .type = BLE_GATT_HVX_NOTIFICATION, + .p_data = (uint8_t *)(p_buf), + .p_len = &len, + }; + + return sd_ble_gatts_hvx(m_conn_handle, &hvx_params); +} + + +#if (NRF_DFU_BLE_REQUIRES_BONDS) +static uint32_t service_changed_send(void) +{ + uint32_t err_code; + + NRF_LOG_DEBUG("Sending Service Changed indication"); + + err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, + m_peer_data.sys_serv_attr, + sizeof(m_peer_data.sys_serv_attr), + BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS); + VERIFY_SUCCESS(err_code); + + err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, + NULL, + 0, + BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS); + VERIFY_SUCCESS(err_code); + + err_code = sd_ble_gatts_service_changed(m_conn_handle, m_dfu.service_handle, 0xFFFF); + + if ( (err_code == BLE_ERROR_INVALID_CONN_HANDLE) + || (err_code == NRF_ERROR_INVALID_STATE) + || (err_code == NRF_ERROR_BUSY)) + { + /* These errors can be expected when trying to send a Service Changed indication */ + /* if the CCCD is not set to indicate. Thus, set the returning error code to success. */ + NRF_LOG_WARNING("Client did not have the Service Changed indication set to enabled." + "Error: 0x%08x", err_code); + err_code = NRF_SUCCESS; + } + + return err_code; +} +#endif + + +/**@brief Function for encoding the beginning of a response. + * + * @param[inout] p_buffer The buffer to encode into. + * @param[in] op_code The opcode of the response. + * @param[in] result The result of the operation. + * + * @return The length added to the buffer. + */ +static uint32_t response_prepare(uint8_t * p_buffer, uint8_t op_code, uint8_t result) +{ + ASSERT(p_buffer); + p_buffer[0] = NRF_DFU_OP_RESPONSE; + p_buffer[1] = op_code; + p_buffer[2] = result; + return RESPONSE_HEADER_LEN; +} + + +/**@brief Function for encoding a select object response into a buffer. + * + * The select object response consists of a maximum object size, a firmware offset, and a CRC value. + * + * @param[inout] p_buffer The buffer to encode the response into. + * @param[in] max_size The maximum object size value to encode. + * @param[in] fw_offset The firmware offset value to encode. + * @param[in] crc The CRC value to encode. + * + * @return The length added to the buffer. + */ +static uint32_t response_select_obj_add(uint8_t * p_buffer, + uint32_t max_size, + uint32_t fw_offset, + uint32_t crc) +{ + uint16_t offset = uint32_encode(max_size, &p_buffer[RESPONSE_HEADER_LEN]); + offset += uint32_encode(fw_offset, &p_buffer[RESPONSE_HEADER_LEN + offset]); + offset += uint32_encode(crc, &p_buffer[RESPONSE_HEADER_LEN + offset]); + return offset; +} + + +/**@brief Function for encoding a CRC response into a buffer. + * + * The CRC response consists of a firmware offset and a CRC value. + * + * @param[inout] p_buffer The buffer to encode the response into. + * @param[in] fw_offset The firmware offset value to encode. + * @param[in] crc The CRC value to encode. + * + * @return The length added to the buffer. + */ +static uint32_t response_crc_add(uint8_t * p_buffer, uint32_t fw_offset, uint32_t crc) +{ + uint16_t offset = uint32_encode(fw_offset, &p_buffer[RESPONSE_HEADER_LEN]); + offset += uint32_encode(crc, &p_buffer[RESPONSE_HEADER_LEN + offset]); + return offset; +} + + +/**@brief Function for appending an extended error code to the response buffer. + * + * @param[inout] p_buffer The buffer to append the extended error code to. + * @param[in] result The error code to append. + * @param[in] buf_offset The current length of the buffer. + * + * @return The length added to the buffer. + */ +static uint32_t response_ext_err_payload_add(uint8_t * p_buffer, uint8_t result, uint32_t buf_offset) +{ + p_buffer[buf_offset] = ext_error_get(); + (void) ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR); + return 1; +} + + +static void ble_dfu_req_handler_callback(nrf_dfu_response_t * p_res, void * p_context) +{ + ASSERT(p_res); + ASSERT(p_context); + + uint8_t len = 0; + uint8_t buffer[MAX_RESPONSE_LEN] = {0}; + + if (p_res->request == NRF_DFU_OP_OBJECT_WRITE) + { + --m_pkt_notif_target_cnt; + if ((m_pkt_notif_target == 0) || (m_pkt_notif_target_cnt && m_pkt_notif_target > 0)) + { + return; + } + + /* Reply with a CRC message and reset the packet counter. */ + m_pkt_notif_target_cnt = m_pkt_notif_target; + + p_res->request = NRF_DFU_OP_CRC_GET; + } + + len += response_prepare(buffer, p_res->request, p_res->result); + + if (p_res->result != NRF_DFU_RES_CODE_SUCCESS) + { + NRF_LOG_WARNING("DFU request %d failed with error: 0x%x", p_res->request, p_res->result); + + if (p_res->result == NRF_DFU_RES_CODE_EXT_ERROR) + { + len += response_ext_err_payload_add(buffer, p_res->result, len); + } + + (void) response_send(buffer, len); + return; + } + + switch (p_res->request) + { + case NRF_DFU_OP_OBJECT_CREATE: + case NRF_DFU_OP_OBJECT_EXECUTE: + break; + + case NRF_DFU_OP_OBJECT_SELECT: + { + len += response_select_obj_add(buffer, + p_res->select.max_size, + p_res->select.offset, + p_res->select.crc); + } break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + len += response_crc_add(buffer, p_res->write.offset, p_res->write.crc); + } break; + + case NRF_DFU_OP_CRC_GET: + { + len += response_crc_add(buffer, p_res->crc.offset, p_res->crc.crc); + } break; + + default: + { + // No action. + } break; + } + + (void) response_send(buffer, len); +} + + +/**@brief Function for handling a Write event on the Control Point characteristic. + * + * @param[in] p_dfu DFU Service Structure. + * @param[in] p_ble_write_evt Pointer to the write event received from BLE stack. + * + * @return NRF_SUCCESS on successful processing of control point write. Otherwise an error code. + */ +static uint32_t on_ctrl_pt_write(ble_dfu_t * p_dfu, ble_gatts_evt_write_t const * p_ble_write_evt) +{ + //lint -save -e415 -e416 : Out-of-bounds access on p_ble_write_evt->data + nrf_dfu_request_t request = + { + .request = (nrf_dfu_op_t)(p_ble_write_evt->data[0]), + .p_context = p_dfu, + .callback.response = ble_dfu_req_handler_callback, + }; + + switch (request.request) + { + case NRF_DFU_OP_OBJECT_SELECT: + { + /* Set object type to read info about */ + request.select.object_type = p_ble_write_evt->data[1]; + } break; + + case NRF_DFU_OP_OBJECT_CREATE: + { + /* Reset the packet receipt notification on create object */ + m_pkt_notif_target_cnt = m_pkt_notif_target; + + request.create.object_type = p_ble_write_evt->data[1]; + request.create.object_size = uint32_decode(&(p_ble_write_evt->data[2])); + + if (request.create.object_type == NRF_DFU_OBJ_TYPE_COMMAND) + { + /* Activity on the current transport. Close all except the current one. */ + (void) nrf_dfu_transports_close(&ble_dfu_transport); + } + } break; + + case NRF_DFU_OP_RECEIPT_NOTIF_SET: + { + NRF_LOG_DEBUG("Set receipt notif"); + + m_pkt_notif_target = uint16_decode(&(p_ble_write_evt->data[1])); + m_pkt_notif_target_cnt = m_pkt_notif_target; + } break; + + default: + break; + } + //lint -restore : Out-of-bounds access + + return nrf_dfu_req_handler_on_req(&request); +} + + +/**@brief Function for handling the @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event from the + * SoftDevice. + * + * @param[in] p_dfu DFU Service Structure. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static bool on_rw_authorize_req(ble_dfu_t * p_dfu, ble_evt_t const * p_ble_evt) +{ + uint32_t err_code; + + ble_gatts_evt_rw_authorize_request_t const * p_authorize_request; + ble_gatts_evt_write_t const * p_ble_write_evt; + + p_authorize_request = &(p_ble_evt->evt.gatts_evt.params.authorize_request); + p_ble_write_evt = &(p_ble_evt->evt.gatts_evt.params.authorize_request.request.write); + + if ( (p_authorize_request->type != BLE_GATTS_AUTHORIZE_TYPE_WRITE) + || (p_authorize_request->request.write.handle != p_dfu->dfu_ctrl_pt_handles.value_handle) + || (p_authorize_request->request.write.op != BLE_GATTS_OP_WRITE_REQ)) + { + return false; + } + + ble_gatts_rw_authorize_reply_params_t auth_reply = + { + .type = BLE_GATTS_AUTHORIZE_TYPE_WRITE, + .params.write.update = 1, + .params.write.offset = p_ble_write_evt->offset, + .params.write.len = p_ble_write_evt->len, + .params.write.p_data = p_ble_write_evt->data, + }; + + if (!is_cccd_configured(p_dfu)) + { + /* Send an error response to the peer indicating that the CCCD is improperly configured. */ + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR; + + /* Ignore response of auth reply */ + (void) sd_ble_gatts_rw_authorize_reply(m_conn_handle, &auth_reply); + return false; + } + else + { + auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; + + err_code = sd_ble_gatts_rw_authorize_reply(m_conn_handle, &auth_reply); + return err_code == NRF_SUCCESS ? true : false; + } +} + + +static void on_flash_write(void * p_buf) +{ + NRF_LOG_DEBUG("Freeing buffer %p", p_buf); + nrf_balloc_free(&m_buffer_pool, p_buf); +} + + +/**@brief Function for handling the @ref BLE_GATTS_EVT_WRITE event from the SoftDevice. + * + * @param[in] p_dfu DFU Service Structure. + * @param[in] p_ble_evt Pointer to the event received from BLE stack. + */ +static void on_write(ble_dfu_t * p_dfu, ble_evt_t const * p_ble_evt) +{ + ble_gatts_evt_write_t const * const p_write_evt = &p_ble_evt->evt.gatts_evt.params.write; + + if (p_write_evt->handle != p_dfu->dfu_pkt_handles.value_handle) + { + return; + } + + /* Allocate a buffer to receive data. */ + uint8_t * p_balloc_buf = nrf_balloc_alloc(&m_buffer_pool); + if (p_balloc_buf == NULL) + { + /* Operations are retried by the host; do not give up here. */ + NRF_LOG_WARNING("cannot allocate memory buffer!"); + return; + } + + NRF_LOG_DEBUG("Buffer %p acquired, len %d (%d)", + p_balloc_buf, p_write_evt->len, MAX_DFU_PKT_LEN); + + /* Copy payload into buffer. */ + memcpy(p_balloc_buf, p_write_evt->data, p_write_evt->len); + + /* Set up the request. */ + nrf_dfu_request_t request = + { + .request = NRF_DFU_OP_OBJECT_WRITE, + .p_context = p_dfu, + .callback = + { + .response = ble_dfu_req_handler_callback, + .write = on_flash_write, + } + }; + + /* Set up the request buffer. */ + request.write.p_data = p_balloc_buf; + request.write.len = p_write_evt->len; + + /* Schedule handling of the request. */ + ret_code_t rc = nrf_dfu_req_handler_on_req(&request); + if (rc != NRF_SUCCESS) + { + /* The error is logged in nrf_dfu_req_handler_on_req(). + * Free the buffer. + */ + (void) nrf_balloc_free(&m_buffer_pool, p_balloc_buf); + } +} + + +/**@brief Function for the Application's SoftDevice event handler. + * + * @param[in] p_ble_evt SoftDevice event. + */ +static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) +{ + uint32_t err_code; + ble_gap_evt_t const * const p_gap = &p_ble_evt->evt.gap_evt; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + { + NRF_LOG_DEBUG("Connected"); + + m_conn_handle = p_gap->conn_handle; + + if (m_observer) + { + m_observer(NRF_DFU_EVT_TRANSPORT_ACTIVATED); + } + + err_code = sd_ble_gap_conn_param_update(m_conn_handle, &m_gap_conn_params); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failure to update connection parameters: 0x%x", err_code); + } + } break; + + case BLE_GAP_EVT_DISCONNECTED: + { + m_conn_handle = BLE_CONN_HANDLE_INVALID; + + /* Restart advertising so that the DFU Controller can reconnect if possible. */ + if (!(m_flags & DFU_BLE_RESETTING_SOON)) + { + err_code = advertising_start(); + APP_ERROR_CHECK(err_code); + } + + if (m_observer) + { + m_observer(NRF_DFU_EVT_TRANSPORT_DEACTIVATED); + } + } break; + + case BLE_GATTS_EVT_WRITE: + { + on_write(&m_dfu, p_ble_evt); + } break; + + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: + { + uint16_t const mtu_requested = + p_ble_evt->evt.gatts_evt.params.exchange_mtu_request.client_rx_mtu; + + /* If the requested MTU is smaller than the maximum, we can accept with the given + * stack configuration, and the payload is not word-aligned, reply with a smaller MTU + * that has a word-aligned payload. This ensures that the length of data we write to + * flash is a multiple of the word size. + */ + uint16_t mtu_reply; + + if (mtu_requested < NRF_SDH_BLE_GATT_MAX_MTU_SIZE) + { + /* Round the payload size down to a multiple of 4 so it is word-aligned. */ + if (GATT_PAYLOAD(mtu_requested) % 4) + { + mtu_reply = GATT_PAYLOAD(mtu_requested) - 4; + mtu_reply = ALIGN_NUM(4, mtu_reply); + /* Add the header len to the MTU. */ + mtu_reply += GATT_HEADER_LEN; + } + else + { + mtu_reply = mtu_requested; + } + } + else + { + mtu_reply = NRF_SDH_BLE_GATT_MAX_MTU_SIZE; + } + + NRF_LOG_DEBUG("Received BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST (request: %d, reply: %d).", + mtu_requested, mtu_reply); + + err_code = sd_ble_gatts_exchange_mtu_reply(m_conn_handle, mtu_reply); + APP_ERROR_CHECK(err_code); + } break; +#ifndef S112 + case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST."); + + ble_gap_data_length_params_t const dlp = + { + .max_rx_octets = BLE_GAP_DATA_LENGTH_AUTO, + .max_tx_octets = BLE_GAP_DATA_LENGTH_AUTO, + }; + + err_code = sd_ble_gap_data_length_update(p_ble_evt->evt.gatts_evt.conn_handle, + &dlp, NULL); + APP_ERROR_CHECK(err_code); + } break; + + case BLE_GAP_EVT_DATA_LENGTH_UPDATE: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_DATA_LENGTH_UPDATE (%u, max_rx_time %u).", + p_gap->params.data_length_update.effective_params.max_rx_octets, + p_gap->params.data_length_update.effective_params.max_rx_time_us); + } break; +#endif + + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_SEC_PARAMS_REQUEST"); + + uint16_t cccd; + ble_gatts_value_t gatts_value = + { + .len = BLE_CCCD_VALUE_LEN, + .p_value = (uint8_t*)&cccd + }; + + err_code = sd_ble_gatts_value_get(m_conn_handle, + BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED, + &gatts_value); + APP_ERROR_CHECK(err_code); + + NRF_LOG_DEBUG("CCCD for service changed is 0x%04x", cccd); + + 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; + + case BLE_GAP_EVT_CONN_PARAM_UPDATE: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_CONN_PARAM_UPDATE"); + + ble_gap_conn_params_t const * p_conn = + &p_gap->params.conn_param_update.conn_params; + + NRF_LOG_DEBUG("max_conn_interval: %d", p_conn->max_conn_interval); + NRF_LOG_DEBUG("min_conn_interval: %d", p_conn->min_conn_interval); + NRF_LOG_DEBUG("slave_latency: %d", p_conn->slave_latency); + NRF_LOG_DEBUG("conn_sup_timeout: %d", p_conn->conn_sup_timeout); + } break; + +#if !defined(S112) && !defined(S113) + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST"); + + err_code = sd_ble_gap_conn_param_update(m_conn_handle, + &p_gap->params.conn_param_update_request.conn_params); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failure to update connection parameter request: 0x%x", err_code); + } + + APP_ERROR_CHECK(err_code); + } break; +#endif + + case BLE_GAP_EVT_PHY_UPDATE: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_PHY_UPDATE (RX:%d, TX:%d, status:%d)", + p_gap->params.phy_update.rx_phy, + p_gap->params.phy_update.tx_phy, + p_gap->params.phy_update.status); + break; + } + + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_PHY_UPDATE_REQUEST."); + + ble_gap_phys_t const phys = + { + .rx_phys = BLE_GAP_PHY_AUTO, + .tx_phys = BLE_GAP_PHY_AUTO, + }; + + err_code = sd_ble_gap_phy_update(p_gap->conn_handle, &phys); + APP_ERROR_CHECK(err_code); + } break; + + case BLE_GATTS_EVT_TIMEOUT: + { + if (p_ble_evt->evt.gatts_evt.params.timeout.src == BLE_GATT_TIMEOUT_SRC_PROTOCOL) + { + err_code = sd_ble_gap_disconnect(m_conn_handle, + BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + APP_ERROR_CHECK(err_code); + } + } break; + + case BLE_EVT_USER_MEM_REQUEST: + { + err_code = sd_ble_user_mem_reply(m_conn_handle, NULL); + APP_ERROR_CHECK(err_code); + } break; + + case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: + { + if (p_ble_evt->evt.gatts_evt.params.authorize_request.type + != BLE_GATTS_AUTHORIZE_TYPE_INVALID) + { + if (on_rw_authorize_req(&m_dfu, p_ble_evt)) + { + err_code = on_ctrl_pt_write(&m_dfu, + &(p_ble_evt->evt.gatts_evt.params.authorize_request.request.write)); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not handle on_ctrl_pt_write. err_code: 0x%04x", err_code); + } + } + } + } break; + + case BLE_GAP_EVT_SEC_INFO_REQUEST: + { + NRF_LOG_DEBUG("Received BLE_GAP_EVT_SEC_INFO_REQUEST"); + + ble_gap_enc_info_t * p_enc_info = NULL; + ble_gap_irk_t * p_id_info = NULL; + + #if (NRF_DFU_BLE_REQUIRES_BONDS) + /* If there is a match in diversifier, then set the correct keys. */ + if (p_gap->params.sec_info_request.master_id.ediv == + m_peer_data.enc_key.master_id.ediv) + { + p_enc_info = &m_peer_data.enc_key.enc_info; + } + p_id_info = &m_peer_data.ble_id.id_info; + #endif + + err_code = sd_ble_gap_sec_info_reply(p_gap->conn_handle, p_enc_info, p_id_info, NULL); + APP_ERROR_CHECK(err_code); + } break; + + case BLE_GAP_EVT_CONN_SEC_UPDATE: + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + { + #if (NRF_DFU_BLE_REQUIRES_BONDS) + err_code = service_changed_send(); + #else + err_code = sd_ble_gatts_sys_attr_set(p_gap->conn_handle, NULL, 0, 0); + #endif + APP_ERROR_CHECK(err_code); + NRF_LOG_DEBUG("Finished handling conn sec update"); + } break; + + default: + /* No implementation needed. */ + break; + } +} + + +#if (!NRF_DFU_BLE_REQUIRES_BONDS) +static uint32_t gap_address_change(void) +{ + uint32_t err_code; + ble_gap_addr_t addr; + + err_code = sd_ble_gap_addr_get(&addr); + VERIFY_SUCCESS(err_code); + + /* Increase the BLE address by one when advertising openly. */ + addr.addr[0] += 1; + + err_code = sd_ble_gap_addr_set(&addr); + VERIFY_SUCCESS(err_code); + + return NRF_SUCCESS; +} +#endif + + +/**@brief Function for initializing GAP. + * + * @details This function sets up all necessary GAP (Generic Access Profile) parameters of + * the device. It also sets the permissions and appearance. + */ +static uint32_t gap_params_init(void) +{ + uint32_t err_code; + ble_gap_conn_sec_mode_t sec_mode; + uint8_t const * device_name; + uint32_t name_len; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); + +#if (!NRF_DFU_BLE_REQUIRES_BONDS) + + err_code = gap_address_change(); + VERIFY_SUCCESS(err_code); + + if ((m_flags & DFU_BLE_FLAG_USE_ADV_NAME) != 0) + { + NRF_LOG_DEBUG("Setting adv name: %s, length: %d", m_adv_name.name, m_adv_name.len); + device_name = m_adv_name.name; + name_len = m_adv_name.len; + } + else +#endif + { + NRF_LOG_DEBUG("Using default advertising name"); + device_name = (uint8_t const *)(NRF_DFU_BLE_ADV_NAME); + name_len = strlen(NRF_DFU_BLE_ADV_NAME); + } + + err_code = sd_ble_gap_device_name_set(&sec_mode, device_name, name_len); + VERIFY_SUCCESS(err_code); + + err_code = sd_ble_gap_ppcp_set(&m_gap_conn_params); + return err_code; +} + + +static uint32_t ble_stack_init() +{ + ret_code_t err_code; + uint32_t ram_start = 0; + + /* Register as a BLE event observer to receive BLE events. */ + NRF_SDH_BLE_OBSERVER(m_ble_evt_observer, BLE_OBSERVER_PRIO, ble_evt_handler, NULL); + +#if (!defined(NRF_DFU_BLE_SKIP_SD_INIT)) || (NRF_DFU_BLE_SKIP_SD_INIT == 0) + err_code = nrf_dfu_mbr_init_sd(); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("Setting up vector table: 0x%08x", BOOTLOADER_START_ADDR); + err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_START_ADDR); + VERIFY_SUCCESS(err_code); +#endif + + NRF_LOG_DEBUG("Enabling SoftDevice."); + err_code = nrf_sdh_enable_request(); + VERIFY_SUCCESS(err_code); + + /* Fetch the start address of the application RAM. */ + err_code = nrf_sdh_ble_app_ram_start_get(&ram_start); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("Configuring BLE stack."); + err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start); + VERIFY_SUCCESS(err_code); + + /* Enable the BLE stack. */ + NRF_LOG_DEBUG("Enabling the BLE stack."); + return nrf_sdh_ble_enable(&ram_start); +} + + +/**@brief Function for adding DFU Packet characteristic to the BLE Stack. + * + * @param[in] p_dfu DFU Service structure. + * + * @return NRF_SUCCESS on success. Otherwise an error code. + */ +static uint32_t dfu_pkt_char_add(ble_dfu_t * const p_dfu) +{ + ble_gatts_char_md_t char_md = + { + .char_props.write_wo_resp = 1, + }; + + ble_uuid_t char_uuid = + { + .type = p_dfu->uuid_type, + .uuid = BLE_DFU_PKT_CHAR_UUID, + }; + + ble_gatts_attr_md_t attr_md = + { + .vloc = BLE_GATTS_VLOC_STACK, + .vlen = 1, + .write_perm = + { + .sm = 1, + #if NRF_DFU_BLE_REQUIRES_BONDS + .lv = 2, + #else + .lv = 1, + #endif + } + }; + + ble_gatts_attr_t attr_char_value = + { + .p_uuid = &char_uuid, + .p_attr_md = &attr_md, + .max_len = MAX_DFU_PKT_LEN, + }; + + return sd_ble_gatts_characteristic_add(p_dfu->service_handle, + &char_md, + &attr_char_value, + &p_dfu->dfu_pkt_handles); +} + + +/**@brief Function for adding DFU Control Point characteristic to the BLE Stack. + * + * @param[in] p_dfu DFU Service structure. + * + * @return NRF_SUCCESS on success. Otherwise an error code. + */ +static uint32_t dfu_ctrl_pt_add(ble_dfu_t * const p_dfu) +{ + ble_gatts_char_md_t char_md = + { + .char_props.write = 1, + .char_props.notify = 1, + }; + + ble_uuid_t char_uuid = + { + .type = p_dfu->uuid_type, + .uuid = BLE_DFU_CTRL_PT_UUID, + }; + + ble_gatts_attr_md_t attr_md = + { + .vloc = BLE_GATTS_VLOC_STACK, + .wr_auth = 1, + .vlen = 1, + .write_perm = + { + .sm = 1, + #if NRF_DFU_BLE_REQUIRES_BONDS + .lv = 2, + #else + .lv = 1, + #endif + }, + }; + + ble_gatts_attr_t attr_char_value = + { + .p_uuid = &char_uuid, + .p_attr_md = &attr_md, + .max_len = BLE_GATT_ATT_MTU_DEFAULT, + }; + + return sd_ble_gatts_characteristic_add(p_dfu->service_handle, + &char_md, + &attr_char_value, + &p_dfu->dfu_ctrl_pt_handles); +} + + +/**@brief Function for checking if the CCCD of DFU Control point is configured for Notification. + * + * @details This function checks if the CCCD of DFU Control Point characteristic is configured + * for Notification by the DFU Controller. + * + * @param[in] p_dfu DFU Service structure. + * + * @return True if the CCCD of DFU Control Point characteristic is configured for Notification. + * False otherwise. + */ +uint32_t ble_dfu_init(ble_dfu_t * p_dfu) +{ + ASSERT(p_dfu != NULL); + + ble_uuid_t service_uuid; + uint32_t err_code; + + m_conn_handle = BLE_CONN_HANDLE_INVALID; + + BLE_UUID_BLE_ASSIGN(service_uuid, BLE_DFU_SERVICE_UUID); + + err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, + &service_uuid, + &(p_dfu->service_handle)); + VERIFY_SUCCESS(err_code); + + ble_uuid128_t const base_uuid128 = + { + { + 0x50, 0xEA, 0xDA, 0x30, 0x88, 0x83, 0xB8, 0x9F, + 0x60, 0x4F, 0x15, 0xF3, 0x00, 0x00, 0xC9, 0x8E + } + }; + + err_code = sd_ble_uuid_vs_add(&base_uuid128, &p_dfu->uuid_type); + VERIFY_SUCCESS(err_code); + + err_code = dfu_pkt_char_add(p_dfu); + VERIFY_SUCCESS(err_code); + + err_code = dfu_ctrl_pt_add(p_dfu); + VERIFY_SUCCESS(err_code); + + return NRF_SUCCESS; +} + + +uint32_t ble_dfu_transport_init(nrf_dfu_observer_t observer) +{ + uint32_t err_code = NRF_SUCCESS; + + if (m_flags & DFU_BLE_FLAG_INITIALIZED) + { + return err_code; + } + + NRF_LOG_DEBUG("Initializing BLE DFU transport"); + + m_observer = observer; + + err_code = nrf_balloc_init(&m_buffer_pool); + UNUSED_RETURN_VALUE(err_code); + + err_code = ble_stack_init(); + VERIFY_SUCCESS(err_code); + +#if (NRF_DFU_BLE_REQUIRES_BONDS) + /* Copy out the peer data if bonds are required */ + if (nrf_dfu_settings_peer_data_is_valid()) + { + NRF_LOG_DEBUG("Copying peer data"); + + err_code = nrf_dfu_settings_peer_data_copy(&m_peer_data); + UNUSED_RETURN_VALUE(err_code); + } + else + { + APP_ERROR_HANDLER(NRF_ERROR_INTERNAL); + } +#else + /* Copy out the new advertisement name when bonds are not required and the name is set. */ + if (nrf_dfu_settings_adv_name_is_valid()) + { + err_code = nrf_dfu_settings_adv_name_copy(&m_adv_name); + UNUSED_RETURN_VALUE(err_code); + + /* Set flags for advertisement name that is to be used */ + m_flags |= DFU_BLE_FLAG_USE_ADV_NAME; + } + else + { + NRF_LOG_DEBUG("No advertising name found"); + } +#endif + + err_code = gap_params_init(); + VERIFY_SUCCESS(err_code); + + /* Initialize the Device Firmware Update Service. */ + err_code = ble_dfu_init(&m_dfu); + VERIFY_SUCCESS(err_code); + + err_code = advertising_start(); + VERIFY_SUCCESS(err_code); + + m_flags |= DFU_BLE_FLAG_INITIALIZED; + + NRF_LOG_DEBUG("BLE DFU transport initialized."); + + return NRF_SUCCESS; +} + + +uint32_t ble_dfu_transport_close(nrf_dfu_transport_t const * p_exception) +{ + uint32_t err_code = NRF_SUCCESS; + + if ((m_flags & DFU_BLE_FLAG_INITIALIZED) && (p_exception != &ble_dfu_transport)) + { + NRF_LOG_DEBUG("Shutting down BLE transport."); + + if (m_conn_handle != BLE_CONN_HANDLE_INVALID) + { + NRF_LOG_DEBUG("Disconnecting."); + + /* Set flag to prevent advertisement from starting */ + m_flags |= DFU_BLE_RESETTING_SOON; + + /* Disconnect from the peer. */ + err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + VERIFY_SUCCESS(err_code); + + /* Wait a bit for the disconnect event to be sent on air. */ + nrf_delay_ms(200); + } + else + { + err_code = sd_ble_gap_adv_stop(m_adv_handle); + UNUSED_RETURN_VALUE(err_code); + } + + err_code = nrf_sdh_disable_request(); + if (err_code == NRF_SUCCESS) + { + NRF_LOG_DEBUG("BLE transport shut down."); + } + } + + return err_code; +} + +uint32_t ble_dfu_transport_disconnect(void) +{ + uint32_t err_code = NRF_SUCCESS; + + if (m_flags & DFU_BLE_FLAG_INITIALIZED) + { + NRF_LOG_DEBUG("Disconnect from BLE peer."); + + if (m_conn_handle != BLE_CONN_HANDLE_INVALID) + { + NRF_LOG_DEBUG("Disconnecting."); + + /* Disconnect from the peer. */ + err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + VERIFY_SUCCESS(err_code); + } + } + + return err_code; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.h similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.h index 78ca4dc..a7f0871 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,13 +35,13 @@ * 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 nrf_ble_dfu DFU BLE Service + * @defgroup nrf_dfu_ble DFU BLE Service * @{ - * @ingroup sdk_nrf_bootloader + * @ingroup nrf_dfu * @brief Device Firmware Update (DFU) transport layer for Bluetooth low energy. * * @details The Device Firmware Update (DFU) Service is a GATT-based service that can be used for @@ -50,12 +50,13 @@ * firmware updates over BLE. See @ref lib_dfu_transport_ble "DFU Transport: BLE" for more information on the service and the profile. */ -#ifndef NRF_BLE_DFU_H__ -#define NRF_BLE_DFU_H__ +#ifndef NRF_DFU_BLE_H__ +#define NRF_DFU_BLE_H__ #include #include "ble_gatts.h" #include "ble.h" +#include "nrf_dfu_transport.h" #ifdef __cplusplus @@ -70,21 +71,6 @@ extern "C" { #define BLE_DFU_PKT_CHAR_UUID 0x0002 //!< UUID of the DFU Packet Characteristic. -/**@brief BLE DFU opcodes. - * - * @details These types of opcodes are used in control point access. - */ -typedef enum -{ - BLE_DFU_OP_CODE_CREATE_OBJECT = 0x01, /**< Value of the opcode field for a 'Create object' request. */ - BLE_DFU_OP_CODE_SET_RECEIPT_NOTIF = 0x02, /**< Value of the opcode field for a 'Set Packet Receipt Notification' request. */ - BLE_DFU_OP_CODE_CALCULATE_CRC = 0x03, /**< Value of the opcode field for a 'Calculating checksum' request. */ - BLE_DFU_OP_CODE_EXECUTE_OBJECT = 0x04, /**< Value of the opcode field for an 'Initialize DFU parameters' request. */ - BLE_DFU_OP_CODE_SELECT_OBJECT = 0x06, /**< Value of the opcode field for a 'Select object' request. */ - BLE_DFU_OP_CODE_RESPONSE = 0x60 /**< Value of the opcode field for a response.*/ -} ble_dfu_op_code_t; - - /**@brief DFU Service. * * @details This structure contains status information related to the service. @@ -98,25 +84,38 @@ typedef struct } ble_dfu_t; -/**@brief Function for initializing the DFU Service. +/**@brief Function for initializing the BLE transport. + * + * @param[in] observer Callback function for receiving notifications from the BLE transport. * - * @retval NRF_SUCCESS If the DFU Service and its characteristics were successfully added to the - * SoftDevice. Otherwise, an error code is returned. + * @retval NRF_SUCCESS If successful. + * @return Error code from sub-call on error. */ -uint32_t ble_dfu_transport_init(void); +uint32_t ble_dfu_transport_init(nrf_dfu_observer_t observer); - -/**@brief Function for closing down the DFU Service and disconnecting from the host. +/**@brief Function for closing the BLE transport. + * + * This function disconnects and disables the SoftDevice. + * + * @param[in] p_exception Optional exception. If the exception refers to this transport, + * this function will do nothing. Can be NULL to signify no exception. * - * @retval NRF_SUCCESS If the DFU Service was correctly closed down. + * @retval NRF_SUCCESS If successful. + * @return Error code from sub-call on error. */ -uint32_t ble_dfu_transport_close(void); +uint32_t ble_dfu_transport_close(nrf_dfu_transport_t const * p_exception); +/**@brief Function for disconnecting from the BLE peer and starting advertising. + * + * @retval NRF_SUCCESS If successful. + * @return Error code from sub-call on error. + */ +uint32_t ble_dfu_transport_disconnect(void); #ifdef __cplusplus } #endif -#endif // NRF_BLE_DFU_H__ +#endif // NRF_DFU_BLE_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble_svci_bond_sharing.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble_svci_bond_sharing.h index f01bc15..8324cfa 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/ble_dfu/nrf_dfu_ble_svci_bond_sharing.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,77 +35,36 @@ * 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 nrf_dfu_svci Supervisor call interface + * @defgroup nrf_dfu_svci_bond_sharing Supervisor call interface for bond sharing * @{ - * @ingroup sdk_nrf_bootloader + * @ingroup nrf_dfu * @brief The Supervisor call interface is a thread-safe method to call into the current application or into an external application using a Supervisor instruction. * */ -#ifndef NRF_DFU_SVCI_H__ -#define NRF_DFU_SVCI_H__ +#ifndef NRF_DFU_BLE_SVCI_BOND_SHARING_H__ +#define NRF_DFU_BLE_SVCI_BOND_SHARING_H__ #include #include "nrf_svci.h" #include "nrf_svci_async_function.h" -#include "ble_gap.h" +#include "sdk_config.h" +#include "nrf_dfu_types.h" #ifdef __cplusplus extern "C" { #endif -#define SYSTEM_SERVICE_ATT_SIZE 8 /**< Size of the system service attribute length including CRC-16 at the end. */ - -typedef enum -{ - NRF_DFU_SVCI_EXECUTE_COMMAND_INIT, - NRF_DFU_SVCI_EXECUTE_DATA_INIT, - NRF_DFU_SVCI_SET_PEER_DATA, - NRF_DFU_SVCI_SET_ADV_NAME, -} nrf_dfu_svci_numbers; +#define NRF_DFU_SVCI_SET_PEER_DATA 2 +#define NRF_DFU_SVCI_SET_ADV_NAME 3 -typedef struct -{ - uint32_t crc; /**< CRC of the rest of the parameters in this struct. */ - ble_gap_id_key_t ble_id; /**< BLE GAP identity key of the device that initiated the DFU process. */ - ble_gap_enc_key_t enc_key; /**< Encryption key structure containing encrypted diversifier and LTK for reestablishing the bond. */ - uint8_t sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE]; /**< System service attributes for restoring of Service Changed Indication setting in DFU mode. */ -} nrf_dfu_peer_data_t; - - -typedef enum -{ - DFU_PEER_DATA_STATE_INVALID = 0, - DFU_PEER_DATA_STATE_INITIALIZED = 1, - DFU_PEER_DATA_STATE_WRITE_REQUESTED = 2, - DFU_PEER_DATA_STATE_WRITE_FINISHED = 3, - DFU_PEER_DATA_STATE_WRITE_FAILED = 4, -} nrf_dfu_peer_data_state_t; - - -typedef struct -{ - uint32_t crc; /**< CRC of the rest of the parameters in this struct. Calculated by the bootloader. */ - uint8_t name[20]; /**< New advertisement name to set. */ - uint32_t len; /**< Length of the advertisement name. */ -} nrf_dfu_adv_name_t; - - -typedef enum -{ - DFU_ADV_NAME_STATE_INVALID = 0, - DFU_ADV_NAME_STATE_INITIALIZED = 1, - DFU_ADV_NAME_STATE_WRITE_REQUESTED = 2, - DFU_ADV_NAME_STATE_WRITE_FINISHED = 3, - DFU_ADV_NAME_STATE_WRITE_FAILED = 4, -} nrf_dfu_set_adv_name_state_t; - +#if defined(NRF_DFU_TRANSPORT_BLE) && NRF_DFU_TRANSPORT_BLE /**@brief Sets up the async SVCI interface for exchanging peer data like bonding and the system attribute table. * @@ -116,7 +75,6 @@ typedef enum */ NRF_SVCI_ASYNC_FUNC_DECLARE(NRF_DFU_SVCI_SET_PEER_DATA, nrf_dfu_set_peer_data, nrf_dfu_peer_data_t, nrf_dfu_peer_data_state_t); - /**@brief Sets up the async SVCI interface for exchanging advertisement name to use when entering DFU mode. * * @details The advertisement name will be stored in flash by the bootloader. This requires memory management @@ -126,10 +84,12 @@ NRF_SVCI_ASYNC_FUNC_DECLARE(NRF_DFU_SVCI_SET_PEER_DATA, nrf_dfu_set_peer_data, n */ NRF_SVCI_ASYNC_FUNC_DECLARE(NRF_DFU_SVCI_SET_ADV_NAME, nrf_dfu_set_adv_name, nrf_dfu_adv_name_t, nrf_dfu_set_adv_name_state_t); +#endif // NRF_DFU_TRANSPORT_BLE + #ifdef __cplusplus } #endif -#endif // NRF_DFU_SVCI_H__ +#endif // NRF_DFU_BLE_SVCI_BOND_SHARING_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.options b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.options new file mode 100644 index 0000000..de4fcdb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.options @@ -0,0 +1,5 @@ +dfu.Hash.hash max_size:32 +dfu.SignedCommand.signature max_size:64 +dfu.InitCommand.sd_req max_count:16 +dfu.InitCommand.boot_validation max_count:3 +dfu.BootValidation.bytes max_size:64 \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.c new file mode 100644 index 0000000..5613b65 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.c @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2017 - 2019, 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. + * + */ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.3.6-dev at Tue Sep 11 14:37:18 2018. */ + +#include "dfu-cc.pb.h" + +/* @@protoc_insertion_point(includes) */ +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + +const bool dfu_init_command_is_debug_default = false; + + +const pb_field_t dfu_hash_fields[3] = { + PB_FIELD( 1, UENUM , REQUIRED, STATIC , FIRST, dfu_hash_t, hash_type, hash_type, 0), + PB_FIELD( 2, BYTES , REQUIRED, STATIC , OTHER, dfu_hash_t, hash, hash_type, 0), + PB_LAST_FIELD +}; + +const pb_field_t dfu_boot_validation_fields[3] = { + PB_FIELD( 1, UENUM , REQUIRED, STATIC , FIRST, dfu_boot_validation_t, type, type, 0), + PB_FIELD( 2, BYTES , REQUIRED, STATIC , OTHER, dfu_boot_validation_t, bytes, type, 0), + PB_LAST_FIELD +}; + +const pb_field_t dfu_init_command_fields[11] = { + PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, dfu_init_command_t, fw_version, fw_version, 0), + PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, dfu_init_command_t, hw_version, fw_version, 0), + PB_FIELD( 3, UINT32 , REPEATED, STATIC , OTHER, dfu_init_command_t, sd_req, hw_version, 0), + PB_FIELD( 4, UENUM , OPTIONAL, STATIC , OTHER, dfu_init_command_t, type, sd_req, 0), + PB_FIELD( 5, UINT32 , OPTIONAL, STATIC , OTHER, dfu_init_command_t, sd_size, type, 0), + PB_FIELD( 6, UINT32 , OPTIONAL, STATIC , OTHER, dfu_init_command_t, bl_size, sd_size, 0), + PB_FIELD( 7, UINT32 , OPTIONAL, STATIC , OTHER, dfu_init_command_t, app_size, bl_size, 0), + PB_FIELD( 8, MESSAGE , OPTIONAL, STATIC , OTHER, dfu_init_command_t, hash, app_size, &dfu_hash_fields), + PB_FIELD( 9, BOOL , OPTIONAL, STATIC , OTHER, dfu_init_command_t, is_debug, hash, &dfu_init_command_is_debug_default), + PB_FIELD( 10, MESSAGE , REPEATED, STATIC , OTHER, dfu_init_command_t, boot_validation, is_debug, &dfu_boot_validation_fields), + PB_LAST_FIELD +}; + +const pb_field_t dfu_command_fields[3] = { + PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, dfu_command_t, op_code, op_code, 0), + PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, dfu_command_t, init, op_code, &dfu_init_command_fields), + PB_LAST_FIELD +}; + +const pb_field_t dfu_signed_command_fields[4] = { + PB_FIELD( 1, MESSAGE , REQUIRED, STATIC , FIRST, dfu_signed_command_t, command, command, &dfu_command_fields), + PB_FIELD( 2, UENUM , REQUIRED, STATIC , OTHER, dfu_signed_command_t, signature_type, command, 0), + PB_FIELD( 3, BYTES , REQUIRED, STATIC , OTHER, dfu_signed_command_t, signature, signature_type, 0), + PB_LAST_FIELD +}; + +const pb_field_t dfu_packet_fields[3] = { + PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, dfu_packet_t, command, command, &dfu_command_fields), + PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, dfu_packet_t, signed_command, command, &dfu_signed_command_fields), + PB_LAST_FIELD +}; + + +/* Check that field information fits in pb_field_t */ +#if !defined(PB_FIELD_32BIT) +/* If you get an error here, it means that you need to define PB_FIELD_32BIT + * compile-time option. You can do that in pb.h or on compiler command line. + * + * The reason you need to do this is that some of your messages contain tag + * numbers or field sizes that are larger than what can fit in 8 or 16 bit + * field descriptors. + */ +PB_STATIC_ASSERT((pb_membersize(dfu_init_command_t, hash) < 65536 && pb_membersize(dfu_init_command_t, boot_validation[0]) < 65536 && pb_membersize(dfu_command_t, init) < 65536 && pb_membersize(dfu_signed_command_t, command) < 65536 && pb_membersize(dfu_packet_t, command) < 65536 && pb_membersize(dfu_packet_t, signed_command) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_dfu_hash_dfu_boot_validation_dfu_init_command_dfu_command_dfu_signed_command_dfu_packet) +#endif + +#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) +/* If you get an error here, it means that you need to define PB_FIELD_16BIT + * compile-time option. You can do that in pb.h or on compiler command line. + * + * The reason you need to do this is that some of your messages contain tag + * numbers or field sizes that are larger than what can fit in the default + * 8 bit descriptors. + */ +PB_STATIC_ASSERT((pb_membersize(dfu_init_command_t, hash) < 256 && pb_membersize(dfu_init_command_t, boot_validation[0]) < 256 && pb_membersize(dfu_command_t, init) < 256 && pb_membersize(dfu_signed_command_t, command) < 256 && pb_membersize(dfu_packet_t, command) < 256 && pb_membersize(dfu_packet_t, signed_command) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_dfu_hash_dfu_boot_validation_dfu_init_command_dfu_command_dfu_signed_command_dfu_packet) +#endif + + +/* @@protoc_insertion_point(eof) */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.h new file mode 100644 index 0000000..00fc2bb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.pb.h @@ -0,0 +1,241 @@ +/** + * Copyright (c) 2017 - 2019, 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. + * + */ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.3.6-dev at Tue Sep 11 14:37:18 2018. */ + +#ifndef PB_DFU_CC_PB_H_INCLUDED +#define PB_DFU_CC_PB_H_INCLUDED +#include + +/* @@protoc_insertion_point(includes) */ +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Enum definitions */ +typedef enum +{ + DFU_FW_TYPE_APPLICATION = 0, + DFU_FW_TYPE_SOFTDEVICE = 1, + DFU_FW_TYPE_BOOTLOADER = 2, + DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER = 3, + DFU_FW_TYPE_EXTERNAL_APPLICATION = 4 +} dfu_fw_type_t; +#define DFU_FW_TYPE_MIN DFU_FW_TYPE_APPLICATION +#define DFU_FW_TYPE_MAX DFU_FW_TYPE_EXTERNAL_APPLICATION +#define DFU_FW_TYPE_ARRAYSIZE ((dfu_fw_type_t)(DFU_FW_TYPE_EXTERNAL_APPLICATION+1)) + +typedef enum +{ + DFU_HASH_TYPE_NO_HASH = 0, + DFU_HASH_TYPE_CRC = 1, + DFU_HASH_TYPE_SHA128 = 2, + DFU_HASH_TYPE_SHA256 = 3, + DFU_HASH_TYPE_SHA512 = 4 +} dfu_hash_type_t; +#define DFU_HASH_TYPE_MIN DFU_HASH_TYPE_NO_HASH +#define DFU_HASH_TYPE_MAX DFU_HASH_TYPE_SHA512 +#define DFU_HASH_TYPE_ARRAYSIZE ((dfu_hash_type_t)(DFU_HASH_TYPE_SHA512+1)) + +typedef enum +{ + DFU_OP_CODE_INIT = 1 +} dfu_op_code_t; +#define DFU_OP_CODE_MIN DFU_OP_CODE_INIT +#define DFU_OP_CODE_MAX DFU_OP_CODE_INIT +#define DFU_OP_CODE_ARRAYSIZE ((dfu_op_code_t)(DFU_OP_CODE_INIT+1)) + +typedef enum +{ + DFU_VALIDATION_TYPE_NO_VALIDATION = 0, + DFU_VALIDATION_TYPE_VALIDATE_GENERATED_CRC = 1, + DFU_VALIDATION_TYPE_VALIDATE_SHA256 = 2, + DFU_VALIDATION_TYPE_VALIDATE_ECDSA_P256_SHA256 = 3 +} dfu_validation_type_t; +#define DFU_VALIDATION_TYPE_MIN DFU_VALIDATION_TYPE_NO_VALIDATION +#define DFU_VALIDATION_TYPE_MAX DFU_VALIDATION_TYPE_VALIDATE_ECDSA_P256_SHA256 +#define DFU_VALIDATION_TYPE_ARRAYSIZE ((dfu_validation_type_t)(DFU_VALIDATION_TYPE_VALIDATE_ECDSA_P256_SHA256+1)) + +typedef enum +{ + DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256 = 0, + DFU_SIGNATURE_TYPE_ED25519 = 1 +} dfu_signature_type_t; +#define DFU_SIGNATURE_TYPE_MIN DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256 +#define DFU_SIGNATURE_TYPE_MAX DFU_SIGNATURE_TYPE_ED25519 +#define DFU_SIGNATURE_TYPE_ARRAYSIZE ((dfu_signature_type_t)(DFU_SIGNATURE_TYPE_ED25519+1)) + +/* Struct definitions */ +typedef PB_BYTES_ARRAY_T(64) dfu_boot_validation_bytes_t; +typedef struct { + dfu_validation_type_t type; + dfu_boot_validation_bytes_t bytes; +/* @@protoc_insertion_point(struct:dfu_boot_validation_t) */ +} dfu_boot_validation_t; + +typedef PB_BYTES_ARRAY_T(32) dfu_hash_hash_t; +typedef struct { + dfu_hash_type_t hash_type; + dfu_hash_hash_t hash; +/* @@protoc_insertion_point(struct:dfu_hash_t) */ +} dfu_hash_t; + +typedef struct { + bool has_fw_version; + uint32_t fw_version; + bool has_hw_version; + uint32_t hw_version; + pb_size_t sd_req_count; + uint32_t sd_req[16]; + bool has_type; + dfu_fw_type_t type; + bool has_sd_size; + uint32_t sd_size; + bool has_bl_size; + uint32_t bl_size; + bool has_app_size; + uint32_t app_size; + bool has_hash; + dfu_hash_t hash; + bool has_is_debug; + bool is_debug; + pb_size_t boot_validation_count; + dfu_boot_validation_t boot_validation[3]; +/* @@protoc_insertion_point(struct:dfu_init_command_t) */ +} dfu_init_command_t; + +typedef struct { + bool has_op_code; + dfu_op_code_t op_code; + bool has_init; + dfu_init_command_t init; +/* @@protoc_insertion_point(struct:dfu_command_t) */ +} dfu_command_t; + +typedef PB_BYTES_ARRAY_T(64) dfu_signed_command_signature_t; +typedef struct { + dfu_command_t command; + dfu_signature_type_t signature_type; + dfu_signed_command_signature_t signature; +/* @@protoc_insertion_point(struct:dfu_signed_command_t) */ +} dfu_signed_command_t; + +typedef struct { + bool has_command; + dfu_command_t command; + bool has_signed_command; + dfu_signed_command_t signed_command; +/* @@protoc_insertion_point(struct:dfu_packet_t) */ +} dfu_packet_t; + +/* Default values for struct fields */ +extern const bool dfu_init_command_is_debug_default; + +/* Initializer values for message structs */ +#define DFU_HASH_INIT_DEFAULT {(dfu_hash_type_t)0, {0, {0}}} +#define DFU_BOOT_VALIDATION_INIT_DEFAULT {(dfu_validation_type_t)0, {0, {0}}} +#define DFU_INIT_COMMAND_INIT_DEFAULT {false, 0, false, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, false, (dfu_fw_type_t)0, false, 0, false, 0, false, 0, false, DFU_HASH_INIT_DEFAULT, false, false, 0, {DFU_BOOT_VALIDATION_INIT_DEFAULT, DFU_BOOT_VALIDATION_INIT_DEFAULT, DFU_BOOT_VALIDATION_INIT_DEFAULT}} +#define DFU_COMMAND_INIT_DEFAULT {false, (dfu_op_code_t)0, false, DFU_INIT_COMMAND_INIT_DEFAULT} +#define DFU_SIGNED_COMMAND_INIT_DEFAULT {DFU_COMMAND_INIT_DEFAULT, (dfu_signature_type_t)0, {0, {0}}} +#define DFU_PACKET_INIT_DEFAULT {false, DFU_COMMAND_INIT_DEFAULT, false, DFU_SIGNED_COMMAND_INIT_DEFAULT} +#define DFU_HASH_INIT_ZERO {(dfu_hash_type_t)0, {0, {0}}} +#define DFU_BOOT_VALIDATION_INIT_ZERO {(dfu_validation_type_t)0, {0, {0}}} +#define DFU_INIT_COMMAND_INIT_ZERO {false, 0, false, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, false, (dfu_fw_type_t)0, false, 0, false, 0, false, 0, false, DFU_HASH_INIT_ZERO, false, 0, 0, {DFU_BOOT_VALIDATION_INIT_ZERO, DFU_BOOT_VALIDATION_INIT_ZERO, DFU_BOOT_VALIDATION_INIT_ZERO}} +#define DFU_COMMAND_INIT_ZERO {false, (dfu_op_code_t)0, false, DFU_INIT_COMMAND_INIT_ZERO} +#define DFU_SIGNED_COMMAND_INIT_ZERO {DFU_COMMAND_INIT_ZERO, (dfu_signature_type_t)0, {0, {0}}} +#define DFU_PACKET_INIT_ZERO {false, DFU_COMMAND_INIT_ZERO, false, DFU_SIGNED_COMMAND_INIT_ZERO} + +/* Field tags (for use in manual encoding/decoding) */ +#define DFU_BOOT_VALIDATION_TYPE_TAG 1 +#define DFU_BOOT_VALIDATION_BYTES_TAG 2 +#define DFU_HASH_HASH_TYPE_TAG 1 +#define DFU_HASH_HASH_TAG 2 +#define DFU_INIT_COMMAND_FW_VERSION_TAG 1 +#define DFU_INIT_COMMAND_HW_VERSION_TAG 2 +#define DFU_INIT_COMMAND_SD_REQ_TAG 3 +#define DFU_INIT_COMMAND_TYPE_TAG 4 +#define DFU_INIT_COMMAND_SD_SIZE_TAG 5 +#define DFU_INIT_COMMAND_BL_SIZE_TAG 6 +#define DFU_INIT_COMMAND_APP_SIZE_TAG 7 +#define DFU_INIT_COMMAND_HASH_TAG 8 +#define DFU_INIT_COMMAND_IS_DEBUG_TAG 9 +#define DFU_INIT_COMMAND_BOOT_VALIDATION_TAG 10 +#define DFU_COMMAND_OP_CODE_TAG 1 +#define DFU_COMMAND_INIT_TAG 2 +#define DFU_SIGNED_COMMAND_COMMAND_TAG 1 +#define DFU_SIGNED_COMMAND_SIGNATURE_TYPE_TAG 2 +#define DFU_SIGNED_COMMAND_SIGNATURE_TAG 3 +#define DFU_PACKET_COMMAND_TAG 1 +#define DFU_PACKET_SIGNED_COMMAND_TAG 2 + +/* Struct field encoding specification for nanopb */ +extern const pb_field_t dfu_hash_fields[3]; +extern const pb_field_t dfu_boot_validation_fields[3]; +extern const pb_field_t dfu_init_command_fields[11]; +extern const pb_field_t dfu_command_fields[3]; +extern const pb_field_t dfu_signed_command_fields[4]; +extern const pb_field_t dfu_packet_fields[3]; + +/* Maximum encoded size of messages (where known) */ +#define DFU_HASH_SIZE 36 +#define DFU_BOOT_VALIDATION_SIZE 68 +#define DFU_INIT_COMMAND_SIZE 378 +#define DFU_COMMAND_SIZE 383 +#define DFU_SIGNED_COMMAND_SIZE 454 +#define DFU_PACKET_SIZE 843 + +/* Message IDs (where set with "msgid" option) */ +#ifdef PB_MSGID + +#define DFU_CC_MESSAGES \ + + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif +/* @@protoc_insertion_point(eof) */ + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.proto b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.proto new file mode 100644 index 0000000..341b4e8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/dfu-cc.proto @@ -0,0 +1,82 @@ +package dfu; + +// Version 0.1 + +enum FwType { + APPLICATION = 0; + SOFTDEVICE = 1; + BOOTLOADER = 2; + SOFTDEVICE_BOOTLOADER = 3; + EXTERNAL_APPLICATION = 4; +} + +enum HashType { + NO_HASH = 0; + CRC = 1; + SHA128 = 2; + SHA256 = 3; + SHA512 = 4; +} + +enum OpCode { + INIT = 1; +} + +enum ValidationType { + NO_VALIDATION = 0; + VALIDATE_GENERATED_CRC = 1; + VALIDATE_SHA256 = 2; + VALIDATE_ECDSA_P256_SHA256 = 3; +} + +message Hash { + required HashType hash_type = 1; + required bytes hash = 2; +} + +message BootValidation { + + required ValidationType type = 1; + required bytes bytes = 2; +} + +// Commands data +message InitCommand { + optional uint32 fw_version = 1; + optional uint32 hw_version = 2; + repeated uint32 sd_req = 3 [packed = true]; + optional FwType type = 4; + + optional uint32 sd_size = 5; + optional uint32 bl_size = 6; + optional uint32 app_size = 7; + + optional Hash hash = 8; + + optional bool is_debug = 9 [default = false]; + repeated BootValidation boot_validation = 10; +} + +// Command type +message Command { + optional OpCode op_code = 1; + optional InitCommand init = 2; +} + +// Signed command types +enum SignatureType { + ECDSA_P256_SHA256 = 0; + ED25519 = 1; +} + +message SignedCommand { + required Command command = 1; + required SignatureType signature_type = 2; + required bytes signature = 3; +} + +// Parent packet type +message Packet { + optional Command command = 1; + optional SignedCommand signed_command = 2; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu.c index a1c416e..d8e16e8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,64 +35,64 @@ * 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 "nrf_bootloader.h" +#include "nrf_dfu.h" -#include "compiler_abstraction.h" -#include "nrf.h" -#include "nrf_bootloader_app_start.h" +#include "nrf_dfu_utils.h" +#include "nrf_dfu_transport.h" +#include "nrf_dfu_req_handler.h" #include "nrf_log.h" -#include "nrf_dfu.h" -#include "nrf_error.h" +static nrf_dfu_observer_t m_user_observer; // +#include +#include "nrf_dfu_types.h" +#include "nrf_dfu_req_handler.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define NRF_DFU_SCHED_EVENT_DATA_SIZE (sizeof(nrf_dfu_request_t)) + + +/** @brief Function for initializing a DFU operation. + * + * This function initializes a DFU operation and any transports that are registered + * in the system. + * + * @param[in] observer Callback function for receiving DFU notifications. + * + * @retval NRF_SUCCESS If the DFU operation was successfully initialized. + */ +uint32_t nrf_dfu_init(nrf_dfu_observer_t observer); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DFU_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_flash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_flash.c similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_flash.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_flash.c index 5ea4a8c..52e0fb5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_flash.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_flash.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_dfu_flash.h" @@ -56,17 +56,16 @@ void dfu_fstorage_evt_handler(nrf_fstorage_evt_t * p_evt); NRF_FSTORAGE_DEF(nrf_fstorage_t m_fs) = { - .evt_handler = dfu_fstorage_evt_handler, - .start_addr = MBR_SIZE, - .end_addr = BOOTLOADER_SETTINGS_ADDRESS + CODE_PAGE_SIZE + .evt_handler = dfu_fstorage_evt_handler, + .start_addr = MBR_SIZE, + .end_addr = BOOTLOADER_SETTINGS_ADDRESS + BOOTLOADER_SETTINGS_PAGE_SIZE }; -static uint32_t volatile m_flash_operations_pending; - +static uint32_t m_flash_operations_pending; void dfu_fstorage_evt_handler(nrf_fstorage_evt_t * p_evt) { - if (m_flash_operations_pending > 0) + if (NRF_LOG_ENABLED && (m_flash_operations_pending > 0)) { m_flash_operations_pending--; } @@ -86,9 +85,9 @@ void dfu_fstorage_evt_handler(nrf_fstorage_evt_t * p_evt) if (p_evt->p_param) { - NRF_LOG_DEBUG("This operation had a callback, calling back to %p.", p_evt->p_param); - //lint -e611 (Suspicious cast) - ((dfu_flash_callback_t)(p_evt->p_param))(p_evt); + //lint -save -e611 (Suspicious cast) + ((nrf_dfu_flash_callback_t)(p_evt->p_param))((void*)p_evt->p_src); + //lint -restore } } @@ -97,11 +96,8 @@ ret_code_t nrf_dfu_flash_init(bool sd_irq_initialized) { nrf_fstorage_api_t * p_api_impl; - NRF_LOG_DEBUG("Calling nrf_dfu_flash_init(sd_irq_initialized=%s)...", - sd_irq_initialized ? "true" : "false"); - /* Setup the desired API implementation. */ -#ifdef BLE_STACK_SUPPORT_REQD +#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD) if (sd_irq_initialized) { NRF_LOG_DEBUG("Initializing nrf_fstorage_sd backend."); @@ -118,20 +114,25 @@ ret_code_t nrf_dfu_flash_init(bool sd_irq_initialized) } -ret_code_t nrf_dfu_flash_store(uint32_t dest, - void const * p_src, - uint32_t len, - dfu_flash_callback_t callback) +ret_code_t nrf_dfu_flash_store(uint32_t dest, + void const * p_src, + uint32_t len, + nrf_dfu_flash_callback_t callback) { ret_code_t rc; - m_flash_operations_pending++; - NRF_LOG_DEBUG("nrf_fstorage_write(addr=%p, len=0x%x bytes), queue usage: %d", - dest, len, m_flash_operations_pending); + NRF_LOG_DEBUG("nrf_fstorage_write(addr=%p, src=%p, len=%d bytes), queue usage: %d", + dest, p_src, len, m_flash_operations_pending); - rc = nrf_fstorage_write(&m_fs, dest, p_src, len, (void*)callback); + //lint -save -e611 (Suspicious cast) + rc = nrf_fstorage_write(&m_fs, dest, p_src, len, (void *)callback); + //lint -restore - if (rc != NRF_SUCCESS) + if ((NRF_LOG_ENABLED) && (rc == NRF_SUCCESS)) + { + m_flash_operations_pending++; + } + else { NRF_LOG_WARNING("nrf_fstorage_write() failed with error 0x%x.", rc); } @@ -140,23 +141,27 @@ ret_code_t nrf_dfu_flash_store(uint32_t dest, } -ret_code_t nrf_dfu_flash_erase(uint32_t page_addr, - uint32_t num_pages, - dfu_flash_callback_t callback) +ret_code_t nrf_dfu_flash_erase(uint32_t page_addr, + uint32_t num_pages, + nrf_dfu_flash_callback_t callback) { ret_code_t rc; - m_flash_operations_pending++; NRF_LOG_DEBUG("nrf_fstorage_erase(addr=0x%p, len=%d pages), queue usage: %d", page_addr, num_pages, m_flash_operations_pending); - rc = nrf_fstorage_erase(&m_fs, page_addr, num_pages, (void*)callback); + //lint -save -e611 (Suspicious cast) + rc = nrf_fstorage_erase(&m_fs, page_addr, num_pages, (void *)callback); + //lint -restore - if (rc != NRF_SUCCESS) + if ((NRF_LOG_ENABLED) && (rc == NRF_SUCCESS)) + { + m_flash_operations_pending++; + } + else { NRF_LOG_WARNING("nrf_fstorage_erase() failed with error 0x%x.", rc); } return rc; } - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_flash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_flash.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_flash.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_flash.h index 0f9ec58..2d01ee9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_flash.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_flash.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -49,7 +49,7 @@ #include #include -#include "nrf_fstorage.h" +#include "sdk_errors.h" #ifdef __cplusplus extern "C" { @@ -60,7 +60,7 @@ extern "C" { * * This function will be called after a flash operation has completed. */ -typedef nrf_fstorage_evt_handler_t dfu_flash_callback_t; +typedef void (*nrf_dfu_flash_callback_t)(void * p_buf); /**@brief Function for initializing the flash module. @@ -99,7 +99,7 @@ ret_code_t nrf_dfu_flash_init(bool sd_irq_initialized); ret_code_t nrf_dfu_flash_store(uint32_t dest, void const * p_src, uint32_t len, - dfu_flash_callback_t callback); + nrf_dfu_flash_callback_t callback); /**@brief Function for erasing data from flash. @@ -120,7 +120,7 @@ ret_code_t nrf_dfu_flash_store(uint32_t dest, * @retval NRF_ERROR_NULL If @p page_addr is NULL. * @retval NRF_ERROR_NO_MEM If the queue of nrf_fstorage is full. */ -ret_code_t nrf_dfu_flash_erase(uint32_t page_addr, uint32_t num_pages, dfu_flash_callback_t callback); +ret_code_t nrf_dfu_flash_erase(uint32_t page_addr, uint32_t num_pages, nrf_dfu_flash_callback_t callback); #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c index b78d885..a594a59 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_dfu_handling_error.h" @@ -45,7 +45,7 @@ static nrf_dfu_ext_error_code_t m_last_error = NRF_DFU_EXT_ERROR_NO_ERROR; -nrf_dfu_res_code_t ext_error_set(nrf_dfu_ext_error_code_t error_code) +nrf_dfu_result_t ext_error_set(nrf_dfu_ext_error_code_t error_code) { m_last_error = error_code; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h similarity index 78% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h index a13a71b..acbebcc 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_handling_error.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -52,29 +52,13 @@ #define DFU_HANDLING_ERROR_H__ #include "nrf_dfu_types.h" +#include "nrf_dfu_req_handler.h" #ifdef __cplusplus extern "C" { #endif -/**@brief DFU request result codes. - * - * @details The DFU transport layer creates request events of type @ref nrf_dfu_req_op_t. Such events return one of these result codes. - */ -typedef enum -{ - NRF_DFU_RES_CODE_INVALID = 0x00, /**< Invalid opcode. */ - NRF_DFU_RES_CODE_SUCCESS = 0x01, /**< Operation successful. */ - NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED = 0x02, /**< Opcode not supported. */ - NRF_DFU_RES_CODE_INVALID_PARAMETER = 0x03, /**< Missing or invalid parameter value. */ - NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES = 0x04, /**< Not enough memory for the data object. */ - NRF_DFU_RES_CODE_INVALID_OBJECT = 0x05, /**< Data object does not match the firmware and hardware requirements, the signature is wrong, or parsing the command failed. */ - NRF_DFU_RES_CODE_UNSUPPORTED_TYPE = 0x07, /**< Not a valid object type for a Create request. */ - NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED = 0x08, /**< The state of the DFU process does not allow this operation. */ - NRF_DFU_RES_CODE_OPERATION_FAILED = 0x0A, /**< Operation failed. */ - NRF_DFU_RES_CODE_EXT_ERROR = 0x0B, /**< Extended error. The next byte of the response contains the error code of the extended error (see @ref nrf_dfu_ext_error_code_t). */ -} nrf_dfu_res_code_t; /**@brief DFU request extended result codes. * @@ -94,13 +78,14 @@ typedef enum NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID = 0x04, /**< The init command is invalid. The init packet either has an invalid update type or it is missing required fields for the update type (for example, the init packet for a SoftDevice update is missing the SoftDevice size field). */ - NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE = 0x05, /**< The firmware version is too low. For an application, the version must be greater than - the current application. For a bootloader, it must be greater than or equal + NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE = 0x05, /**< The firmware version is too low. For an application or SoftDevice, the version must be greater than + or equal to the current version. For a bootloader, it must be greater than the current version. to the current version. This requirement prevents downgrade attacks.*/ NRF_DFU_EXT_ERROR_HW_VERSION_FAILURE = 0x06, /**< The hardware version of the device does not match the required hardware version for the update. */ NRF_DFU_EXT_ERROR_SD_VERSION_FAILURE = 0x07, /**< The array of supported SoftDevices for the update does not contain - the FWID of the current SoftDevice. */ + the FWID of the current SoftDevice or the first FWID is '0' on a + bootloader which requires the SoftDevice to be present. */ NRF_DFU_EXT_ERROR_SIGNATURE_MISSING = 0x08, /**< The init packet does not contain a signature. This error code is not used in the current implementation, because init packets without a signature are regarded as invalid. */ @@ -120,7 +105,7 @@ typedef enum * * @retval NRF_DFU_RES_CODE_EXT_ERROR */ -nrf_dfu_res_code_t ext_error_set(nrf_dfu_ext_error_code_t error_code); +nrf_dfu_result_t ext_error_set(nrf_dfu_ext_error_code_t error_code); /**@brief Function for getting the most recent extended error code. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.c index bb75141..37dbb6b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_mbr.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,12 +35,15 @@ * 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 "nrf_dfu_mbr.h" #include "nrf_mbr.h" #include "nrf_dfu_types.h" #include "nrf_log.h" +#include "nrf_bootloader_info.h" + +#define MBR_IRQ_FORWARD_ADDRESS_ADDRESS (0x20000000) //!< The address of the variable that decides where the MBR forwards interrupts uint32_t nrf_dfu_mbr_copy_bl(uint32_t * p_src, uint32_t len) { @@ -60,28 +63,6 @@ uint32_t nrf_dfu_mbr_copy_bl(uint32_t * p_src, uint32_t len) } -uint32_t nrf_dfu_mbr_copy_sd(uint32_t * p_dst, uint32_t * p_src, uint32_t len) -{ - uint32_t ret_val; - uint32_t const len_words = len / sizeof(uint32_t); - - if ((len_words & (CODE_PAGE_SIZE / sizeof(uint32_t) - 1)) != 0) - return NRF_ERROR_INVALID_LENGTH; - - sd_mbr_command_t command = - { - .command = SD_MBR_COMMAND_COPY_SD, - .params.copy_sd.src = p_src, - .params.copy_sd.dst = p_dst, - .params.copy_sd.len = len_words - }; - - ret_val = sd_mbr_command(&command); - - return ret_val; -} - - uint32_t nrf_dfu_mbr_init_sd(void) { uint32_t ret_val; @@ -97,58 +78,28 @@ uint32_t nrf_dfu_mbr_init_sd(void) } -uint32_t nrf_dfu_mbr_compare(uint32_t * p_ptr1, uint32_t * p_ptr2, uint32_t len) +uint32_t nrf_dfu_mbr_irq_forward_address_set(void) { - uint32_t ret_val; - uint32_t const len_words = len / sizeof(uint32_t); + uint32_t ret_val = NRF_ERROR_INVALID_PARAM; + uint32_t address = MBR_SIZE; +#if !defined(BLE_STACK_SUPPORT_REQD) && !defined(ANT_STACK_SUPPORT_REQD) sd_mbr_command_t command = { - .command = SD_MBR_COMMAND_COMPARE, - .params.compare.ptr1 = p_ptr1, - .params.compare.ptr2 = p_ptr2, - .params.compare.len = len_words - }; - - ret_val = sd_mbr_command(&command); - - return ret_val; -} - - -uint32_t nrf_dfu_mbr_vector_table_set(uint32_t address) -{ - uint32_t ret_val; - - NRF_LOG_DEBUG("running vector table set"); - sd_mbr_command_t command = - { - .command = SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, - .params.base_set.address = address, + .command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, + .params.irq_forward_address_set.address = address, }; ret_val = sd_mbr_command(&command); - NRF_LOG_DEBUG("After running vector table set"); - - return ret_val; -} - - -#ifndef SOFTDEVICE_PRESENT -uint32_t nrf_dfu_mbr_irq_forward_address_set(uint32_t address) -{ - uint32_t ret_val; +#endif - NRF_LOG_DEBUG("running irq table set"); - sd_mbr_command_t command = + if (ret_val == NRF_ERROR_INVALID_PARAM) { - .command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, - .params.irq_forward_address_set.address = address, - }; + // Manually set the forward address if this MBR doesn't have the command. + *(uint32_t *)(MBR_IRQ_FORWARD_ADDRESS_ADDRESS) = address; - ret_val = sd_mbr_command(&command); - NRF_LOG_DEBUG("After running irq table set"); + ret_val = NRF_SUCCESS; + } return ret_val; } -#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.h new file mode 100644 index 0000000..94cf835 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_mbr.h @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2016 - 2019, 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 sdk_nrf_dfu_mbr MBR functions + * @{ + * @ingroup nrf_dfu + */ + +#ifndef NRF_DFU_MBR_H__ +#define NRF_DFU_MBR_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Function for copying the bootloader using an MBR command. + * + * @param[in] p_src Source address of the bootloader data to copy. + * @param[in] len Length of the data to copy in bytes. + * + * @return This function will return only if the command request could not be run. + * See @ref sd_mbr_command_copy_bl_t for possible return values. + */ +uint32_t nrf_dfu_mbr_copy_bl(uint32_t * p_src, uint32_t len); + + +/** @brief Function for initializing the SoftDevice using an MBR command. + * + * @retval NRF_SUCCESS If the SoftDevice was initialized successfully. + * Any other return value indicates that the SoftDevice + * could not be initialized. + */ +uint32_t nrf_dfu_mbr_init_sd(void); + + +/** @brief Function for setting the address of the IRQ table to the app's using an MBR command. + * + * @retval NRF_SUCCESS If the address of the new irq table was set. Any other + * return value indicates that the address could not be set. + */ +uint32_t nrf_dfu_mbr_irq_forward_address_set(void); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DFU_MBR_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c new file mode 100644 index 0000000..972f017 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c @@ -0,0 +1,865 @@ +/** + * Copyright (c) 2016 - 2019, 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 +#include +#include "sdk_config.h" +#include "nrf_dfu.h" +#include "nrf_dfu_types.h" +#include "nrf_dfu_req_handler.h" +#include "nrf_dfu_handling_error.h" +#include "nrf_dfu_settings.h" +#include "nrf_dfu_utils.h" +#include "nrf_dfu_flash.h" +#include "nrf_fstorage.h" +#include "nrf_bootloader_info.h" +#include "app_util.h" +#include "pb.h" +#include "pb_common.h" +#include "pb_decode.h" +#include "dfu-cc.pb.h" +#include "crc32.h" +#include "app_scheduler.h" +#include "sdk_macros.h" +#include "nrf_crypto.h" +#include "nrf_assert.h" +#include "nrf_dfu_validation.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_req_handler +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define NRF_DFU_PROTOCOL_VERSION (0x01) + +#ifndef NRF_DFU_PROTOCOL_REDUCED +#define NRF_DFU_PROTOCOL_REDUCED 0 +#endif + +STATIC_ASSERT(DFU_SIGNED_COMMAND_SIZE <= INIT_COMMAND_MAX_SIZE); + +static uint32_t m_firmware_start_addr; /**< Start address of the current firmware image. */ +static uint32_t m_firmware_size_req; /**< The size of the entire firmware image. Defined by the init command. */ + +static nrf_dfu_observer_t m_observer; + + +static void on_dfu_complete(nrf_fstorage_evt_t * p_evt) +{ + UNUSED_PARAMETER(p_evt); + + NRF_LOG_DEBUG("All flash operations have completed. DFU completed."); + + m_observer(NRF_DFU_EVT_DFU_COMPLETED); +} + + +static nrf_dfu_result_t ext_err_code_handle(nrf_dfu_result_t ret_val) +{ + if (ret_val < NRF_DFU_RES_CODE_EXT_ERROR) + { + return ret_val; + } + else + { + nrf_dfu_ext_error_code_t ext_err = + (nrf_dfu_ext_error_code_t)((uint8_t)ret_val - (uint8_t)NRF_DFU_RES_CODE_EXT_ERROR); + return ext_error_set(ext_err); + } +} + + +#if !NRF_DFU_PROTOCOL_REDUCED +static void on_protocol_version_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res) +{ + UNUSED_PARAMETER(p_req); + NRF_LOG_DEBUG("Handle NRF_DFU_OP_PROTOCOL_VERSION"); + + if (NRF_DFU_PROTOCOL_VERSION_MSG) + { + p_res->protocol.version = NRF_DFU_PROTOCOL_VERSION; + } + else + { + NRF_LOG_DEBUG("NRF_DFU_OP_PROTOCOL_VERSION disabled."); + p_res->result = NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED; + } +} + + +static void on_hw_version_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_HARDWARE_VERSION"); + + p_res->hardware.part = NRF_FICR->INFO.PART; + p_res->hardware.variant = NRF_FICR->INFO.VARIANT; + + /* FICR values are in Kilobytes, we report them in bytes. */ + p_res->hardware.memory.ram_size = NRF_FICR->INFO.RAM * 1024; + p_res->hardware.memory.rom_size = NRF_FICR->INFO.FLASH * 1024; + p_res->hardware.memory.rom_page_size = NRF_FICR->CODEPAGESIZE; +} + + +static void on_fw_version_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_FIRMWARE_VERSION"); + NRF_LOG_DEBUG("Firmware image requested: %d", p_req->firmware.image_number); + + if (NRF_DFU_PROTOCOL_FW_VERSION_MSG) + { + uint8_t fw_count = 1; + + if (SD_PRESENT) + { + fw_count++; + } + + if (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_VALID_APP) + { + fw_count++; + } + + p_res->result = NRF_DFU_RES_CODE_SUCCESS; + + if (p_req->firmware.image_number == 0) + { + /* Bootloader is always present and it is always image zero. */ + p_res->firmware.type = NRF_DFU_FIRMWARE_TYPE_BOOTLOADER; + p_res->firmware.version = s_dfu_settings.bootloader_version; + p_res->firmware.addr = BOOTLOADER_START_ADDR; + p_res->firmware.len = BOOTLOADER_SIZE; + } + else if ((p_req->firmware.image_number == 1) && SD_PRESENT) + { + /* If a SoftDevice is present, it will be firmware image one. */ + p_res->firmware.type = NRF_DFU_FIRMWARE_TYPE_SOFTDEVICE; + p_res->firmware.version = SD_VERSION_GET(MBR_SIZE); + p_res->firmware.addr = MBR_SIZE; + p_res->firmware.len = SD_SIZE_GET(MBR_SIZE); + } + else if ((p_req->firmware.image_number < fw_count)) + { + /* Either there is no SoftDevice and the firmware image requested is one, + * or there is a SoftDevice and the firmware image requested is two. + */ + p_res->firmware.type = NRF_DFU_FIRMWARE_TYPE_APPLICATION; + p_res->firmware.version = s_dfu_settings.app_version; + p_res->firmware.addr = nrf_dfu_app_start_address(); + p_res->firmware.len = s_dfu_settings.bank_0.image_size; + } + else + { + NRF_LOG_DEBUG("No such firmware image"); + p_res->firmware.type = NRF_DFU_FIRMWARE_TYPE_UNKNOWN; + p_res->firmware.version = 0x00; + p_res->firmware.addr = 0x00; + p_res->firmware.len = 0x00; + } + } + else + { + NRF_LOG_DEBUG("NRF_DFU_OP_FIRMWARE_VERSION disabled."); + p_res->result = NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED; + p_res->firmware.type = NRF_DFU_FIRMWARE_TYPE_UNKNOWN; + } +} + + +static void on_ping_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_PING"); + p_res->ping.id = p_req->ping.id; +} + + +static void on_mtu_get_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_MTU_GET"); + p_res->mtu.size = p_req->mtu.size; +} +#endif // !NRF_DFU_PROTOCOL_REDUCED + + +static void on_prn_set_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + UNUSED_PARAMETER(p_req); + UNUSED_PARAMETER(p_res); + NRF_LOG_DEBUG("Handle NRF_DFU_OP_RECEIPT_NOTIF_SET"); +} + + +static void on_abort_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + UNUSED_PARAMETER(p_req); + UNUSED_PARAMETER(p_res); + NRF_LOG_DEBUG("Handle NRF_DFU_OP_ABORT"); + + m_observer(NRF_DFU_EVT_DFU_ABORTED); +} + + +/* Set offset and CRC fields in the response for a 'command' message. */ +static void cmd_response_offset_and_crc_set(nrf_dfu_response_t * const p_res) +{ + ASSERT(p_res); + + /* Copy the CRC and offset of the init packet. */ + p_res->crc.offset = s_dfu_settings.progress.command_offset; + p_res->crc.crc = s_dfu_settings.progress.command_crc; +} + + +static void on_cmd_obj_select_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res) +{ + UNUSED_PARAMETER(p_req); + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_SELECT (command)"); + + p_res->select.max_size = INIT_COMMAND_MAX_SIZE; + cmd_response_offset_and_crc_set(p_res); +} + + +static void on_cmd_obj_create_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + ASSERT(p_req); + ASSERT(p_res); + + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_CREATE (command)"); + + m_observer(NRF_DFU_EVT_DFU_STARTED); + + nrf_dfu_result_t ret_val = nrf_dfu_validation_init_cmd_create(p_req->create.object_size); + p_res->result = ext_err_code_handle(ret_val); +} + + +static void on_cmd_obj_write_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + ASSERT(p_req); + ASSERT(p_req->write.p_data); + ASSERT(p_req->write.len); + ASSERT(p_res); + + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_WRITE (command)"); + + nrf_dfu_result_t ret_val; + + ret_val = nrf_dfu_validation_init_cmd_append(p_req->write.p_data, p_req->write.len); + p_res->result = ext_err_code_handle(ret_val); + + /* Update response. This is only used when the PRN is triggered and the 'write' message + * is answered with a CRC message and these field are copied into the response. */ + cmd_response_offset_and_crc_set(p_res); + + /* If a callback to free the request payload buffer was provided, invoke it now. */ + if (p_req->callback.write) + { + p_req->callback.write((void*)p_req->write.p_data); + } +} + + +static void on_cmd_obj_execute_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res) +{ + ASSERT(p_req); + ASSERT(p_res); + + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_EXECUTE (command)"); + + nrf_dfu_result_t ret_val; + ret_val = nrf_dfu_validation_init_cmd_execute(&m_firmware_start_addr, &m_firmware_size_req); + p_res->result = ext_err_code_handle(ret_val); + + if (p_res->result == NRF_DFU_RES_CODE_SUCCESS) + { + if (nrf_dfu_settings_write_and_backup(NULL) == NRF_SUCCESS) + { + /* Setting DFU to initialized */ + NRF_LOG_DEBUG("Writing valid init command to flash."); + } + else + { + p_res->result = NRF_DFU_RES_CODE_OPERATION_FAILED; + } + } +} + + +static void on_cmd_obj_crc_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res) +{ + UNUSED_PARAMETER(p_req); + NRF_LOG_DEBUG("Handle NRF_DFU_OP_CRC_GET (command)"); + + cmd_response_offset_and_crc_set(p_res); +} + + +/** @brief Function handling command requests from the transport layer. + * + * @param p_req[in] Pointer to the structure holding the DFU request. + * @param p_res[out] Pointer to the structure holding the DFU response. + * + * @retval NRF_SUCCESS If the command request was executed successfully. + * Any other error code indicates that the data request + * could not be handled. + */ +static void nrf_dfu_command_req(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + ASSERT(p_req); + ASSERT(p_res); + + switch (p_req->request) + { + case NRF_DFU_OP_OBJECT_CREATE: + { + on_cmd_obj_create_request(p_req, p_res); + } break; + + case NRF_DFU_OP_CRC_GET: + { + on_cmd_obj_crc_request(p_req, p_res); + } break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + on_cmd_obj_write_request(p_req, p_res); + } break; + + case NRF_DFU_OP_OBJECT_EXECUTE: + { + on_cmd_obj_execute_request(p_req, p_res); + } break; + + case NRF_DFU_OP_OBJECT_SELECT: + { + on_cmd_obj_select_request(p_req, p_res); + } break; + + default: + { + ASSERT(false); + } break; + } +} + + +static void on_data_obj_select_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_SELECT (data)"); + + p_res->select.crc = s_dfu_settings.progress.firmware_image_crc; + p_res->select.offset = s_dfu_settings.progress.firmware_image_offset; + + p_res->select.max_size = DATA_OBJECT_MAX_SIZE; + + NRF_LOG_DEBUG("crc = 0x%x, offset = 0x%x, max_size = 0x%x", + p_res->select.crc, + p_res->select.offset, + p_res->select.max_size); +} + + +static void on_data_obj_create_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_CREATE (data)"); + + if (!nrf_dfu_validation_init_cmd_present()) + { + /* Can't accept data because DFU isn't initialized by init command. */ + NRF_LOG_ERROR("Cannot create data object without valid init command"); + p_res->result = NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED; + return; + } + + if (p_req->create.object_size == 0) + { + NRF_LOG_ERROR("Object size cannot be 0.") + p_res->result = NRF_DFU_RES_CODE_INVALID_PARAMETER; + return; + } + + if ( ((p_req->create.object_size & (CODE_PAGE_SIZE - 1)) != 0) + && (s_dfu_settings.progress.firmware_image_offset_last + p_req->create.object_size != m_firmware_size_req)) + { + NRF_LOG_ERROR("Object size must be page aligned"); + p_res->result = NRF_DFU_RES_CODE_INVALID_PARAMETER; + return; + } + + if (p_req->create.object_size > DATA_OBJECT_MAX_SIZE) + { + /* It is impossible to handle the command because the size is too large */ + NRF_LOG_ERROR("Invalid size for object (too large)"); + p_res->result = NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES; + return; + } + + if ((s_dfu_settings.progress.firmware_image_offset_last + p_req->create.object_size) > + m_firmware_size_req) + { + NRF_LOG_ERROR("Creating the object with size 0x%08x would overflow firmware size. " + "Offset is 0x%08x and firmware size is 0x%08x.", + p_req->create.object_size, + s_dfu_settings.progress.firmware_image_offset_last, + m_firmware_size_req); + + p_res->result = NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED; + return; + } + + s_dfu_settings.progress.data_object_size = p_req->create.object_size; + s_dfu_settings.progress.firmware_image_crc = s_dfu_settings.progress.firmware_image_crc_last; + s_dfu_settings.progress.firmware_image_offset = s_dfu_settings.progress.firmware_image_offset_last; + s_dfu_settings.write_offset = s_dfu_settings.progress.firmware_image_offset_last; + + /* Erase the page we're at. */ + if (nrf_dfu_flash_erase((m_firmware_start_addr + s_dfu_settings.progress.firmware_image_offset), + CEIL_DIV(p_req->create.object_size, CODE_PAGE_SIZE), NULL) != NRF_SUCCESS) + { + NRF_LOG_ERROR("Erase operation failed"); + p_res->result = NRF_DFU_RES_CODE_INVALID_OBJECT; + return; + } + + NRF_LOG_DEBUG("Creating object with size: %d. Offset: 0x%08x, CRC: 0x%08x", + s_dfu_settings.progress.data_object_size, + s_dfu_settings.progress.firmware_image_offset, + s_dfu_settings.progress.firmware_image_crc); +} + + +static void on_data_obj_write_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_WRITE (data)"); + + if (!nrf_dfu_validation_init_cmd_present()) + { + /* Can't accept data because DFU isn't initialized by init command. */ + p_res->result = NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED; + return; + } + + uint32_t const data_object_offset = s_dfu_settings.progress.firmware_image_offset - + s_dfu_settings.progress.firmware_image_offset_last; + + if ((p_req->write.len + data_object_offset) > s_dfu_settings.progress.data_object_size) + { + /* Can't accept data because too much data has been received. */ + NRF_LOG_ERROR("Write request too long"); + p_res->result = NRF_DFU_RES_CODE_INVALID_PARAMETER; + return; + } + + uint32_t const write_addr = m_firmware_start_addr + s_dfu_settings.write_offset; + /* CRC must be calculated before handing off the data to fstorage because the data is + * freed on write completion. + */ + uint32_t const next_crc = + crc32_compute(p_req->write.p_data, p_req->write.len, &s_dfu_settings.progress.firmware_image_crc); + + ASSERT(p_req->callback.write); + + ret_code_t ret = + nrf_dfu_flash_store(write_addr, p_req->write.p_data, p_req->write.len, p_req->callback.write); + + if (ret != NRF_SUCCESS) + { + /* When nrf_dfu_flash_store() fails because there is no space in the queue, + * stop processing the request so that the peer can detect a CRC error + * and retransmit this object. Remember to manually free the buffer ! + */ + p_req->callback.write((void*)p_req->write.p_data); + return; + } + + /* Update the CRC of the firmware image. */ + s_dfu_settings.write_offset += p_req->write.len; + s_dfu_settings.progress.firmware_image_offset += p_req->write.len; + s_dfu_settings.progress.firmware_image_crc = next_crc; + + /* This is only used when the PRN is triggered and the 'write' message + * is answered with a CRC message and these field are copied into the response. + */ + p_res->write.crc = s_dfu_settings.progress.firmware_image_crc; + p_res->write.offset = s_dfu_settings.progress.firmware_image_offset; +} + + +static void on_data_obj_crc_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_CRC_GET (data)"); + NRF_LOG_DEBUG("Offset:%d, CRC:0x%08x", + s_dfu_settings.progress.firmware_image_offset, + s_dfu_settings.progress.firmware_image_crc); + + p_res->crc.crc = s_dfu_settings.progress.firmware_image_crc; + p_res->crc.offset = s_dfu_settings.progress.firmware_image_offset; +} + + +static void on_data_obj_execute_request_sched(void * p_evt, uint16_t event_length) +{ + UNUSED_PARAMETER(event_length); + + ret_code_t ret; + nrf_dfu_request_t * p_req = (nrf_dfu_request_t *)(p_evt); + + /* Wait for all buffers to be written in flash. */ + if (nrf_fstorage_is_busy(NULL)) + { + ret = app_sched_event_put(p_req, sizeof(nrf_dfu_request_t), on_data_obj_execute_request_sched); + if (ret != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed to schedule object execute: 0x%x.", ret); + } + return; + } + + nrf_dfu_response_t res = + { + .request = NRF_DFU_OP_OBJECT_EXECUTE, + }; + + if (s_dfu_settings.progress.firmware_image_offset == m_firmware_size_req) + { + NRF_LOG_DEBUG("Whole firmware image received. Postvalidating."); + + #if NRF_DFU_IN_APP + res.result = nrf_dfu_validation_post_data_execute(m_firmware_start_addr, m_firmware_size_req); + #else + res.result = nrf_dfu_validation_activation_prepare(m_firmware_start_addr, m_firmware_size_req); + #endif + + res.result = ext_err_code_handle(res.result); + + /* Provide response to transport */ + p_req->callback.response(&res, p_req->p_context); + + ret = nrf_dfu_settings_write_and_backup((nrf_dfu_flash_callback_t)on_dfu_complete); + UNUSED_RETURN_VALUE(ret); + } + else + { + res.result = NRF_DFU_RES_CODE_SUCCESS; + + /* Provide response to transport */ + p_req->callback.response(&res, p_req->p_context); + + if (NRF_DFU_SAVE_PROGRESS_IN_FLASH) + { + /* Allowing skipping settings backup to save time and flash wear. */ + ret = nrf_dfu_settings_write_and_backup(NULL); + UNUSED_RETURN_VALUE(ret); + } + } + + NRF_LOG_DEBUG("Request handling complete. Result: 0x%x", res.result); +} + + +static bool on_data_obj_execute_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_EXECUTE (data)"); + + uint32_t const data_object_size = s_dfu_settings.progress.firmware_image_offset - + s_dfu_settings.progress.firmware_image_offset_last; + + if (s_dfu_settings.progress.data_object_size != data_object_size) + { + /* The size of the written object was not as expected. */ + NRF_LOG_ERROR("Invalid data. expected: %d, got: %d", + s_dfu_settings.progress.data_object_size, + data_object_size); + + p_res->result = NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED; + return true; + } + + /* Update the offset and crc values for the last object written. */ + s_dfu_settings.progress.data_object_size = 0; + s_dfu_settings.progress.firmware_image_crc_last = s_dfu_settings.progress.firmware_image_crc; + s_dfu_settings.progress.firmware_image_offset_last = s_dfu_settings.progress.firmware_image_offset; + + on_data_obj_execute_request_sched(p_req, 0); + + m_observer(NRF_DFU_EVT_OBJECT_RECEIVED); + + return false; +} + + +static bool nrf_dfu_data_req(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + ASSERT(p_req); + ASSERT(p_res); + + bool response_ready = true; + + switch (p_req->request) + { + case NRF_DFU_OP_OBJECT_CREATE: + { + on_data_obj_create_request(p_req, p_res); + } break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + on_data_obj_write_request(p_req, p_res); + } break; + + case NRF_DFU_OP_CRC_GET: + { + on_data_obj_crc_request(p_req, p_res); + } break; + + case NRF_DFU_OP_OBJECT_EXECUTE: + { + response_ready = on_data_obj_execute_request(p_req, p_res); + } break; + + case NRF_DFU_OP_OBJECT_SELECT: + { + on_data_obj_select_request(p_req, p_res); + } break; + + default: + { + ASSERT(false); + } break; + } + + return response_ready; +} + + +/**@brief Function for handling requests to manipulate data or command objects. + * + * @param[in] p_req Request. + * @param[out] p_res Response. + * + * @return Whether response is ready to be sent. + */ +static bool nrf_dfu_obj_op(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res) +{ + /* Keep track of the current object type since write and execute requests don't contain it. */ + static nrf_dfu_obj_type_t current_object = NRF_DFU_OBJ_TYPE_COMMAND; + + if ( (p_req->request == NRF_DFU_OP_OBJECT_SELECT) + || (p_req->request == NRF_DFU_OP_OBJECT_CREATE)) + { + STATIC_ASSERT(offsetof(nrf_dfu_request_select_t, object_type) == + offsetof(nrf_dfu_request_create_t, object_type), + "Wrong object_type offset!"); + + current_object = (nrf_dfu_obj_type_t)(p_req->select.object_type); + } + + bool response_ready = true; + + switch (current_object) + { + case NRF_DFU_OBJ_TYPE_COMMAND: + nrf_dfu_command_req(p_req, p_res); + break; + + case NRF_DFU_OBJ_TYPE_DATA: + response_ready = nrf_dfu_data_req(p_req, p_res); + break; + + default: + /* The select request had an invalid object type. */ + NRF_LOG_ERROR("Invalid object type in request."); + current_object = NRF_DFU_OBJ_TYPE_INVALID; + p_res->result = NRF_DFU_RES_CODE_INVALID_OBJECT; + break; + } + + return response_ready; +} + + +static void nrf_dfu_req_handler_req_process(nrf_dfu_request_t * p_req) +{ + ASSERT(p_req->callback.response); + + bool response_ready = true; + + /* The request handlers assume these values to be set. */ + nrf_dfu_response_t response = + { + .request = p_req->request, + .result = NRF_DFU_RES_CODE_SUCCESS, + }; + + + switch (p_req->request) + { +#if !NRF_DFU_PROTOCOL_REDUCED + case NRF_DFU_OP_PROTOCOL_VERSION: + { + on_protocol_version_request(p_req, &response); + } break; + + case NRF_DFU_OP_HARDWARE_VERSION: + { + on_hw_version_request(p_req, &response); + } break; + + case NRF_DFU_OP_FIRMWARE_VERSION: + { + on_fw_version_request(p_req, &response); + } break; + + case NRF_DFU_OP_PING: + { + on_ping_request(p_req, &response); + } break; + + case NRF_DFU_OP_MTU_GET: + { + on_mtu_get_request(p_req, &response); + } break; +#endif + case NRF_DFU_OP_RECEIPT_NOTIF_SET: + { + on_prn_set_request(p_req, &response); + } break; + + case NRF_DFU_OP_ABORT: + { + on_abort_request(p_req, &response); + } break; + + case NRF_DFU_OP_OBJECT_CREATE: + /* Restart the inactivity timer on CREATE messages. */ + /* Fallthrough. */ + case NRF_DFU_OP_OBJECT_SELECT: + case NRF_DFU_OP_OBJECT_WRITE: + case NRF_DFU_OP_OBJECT_EXECUTE: + case NRF_DFU_OP_CRC_GET: + { + response_ready = nrf_dfu_obj_op(p_req, &response); + } break; + + default: + NRF_LOG_INFO("Invalid opcode received: 0x%x.", p_req->request); + response.result = NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED; + break; + } + + if (response_ready) + { + NRF_LOG_DEBUG("Request handling complete. Result: 0x%x", response.result); + + p_req->callback.response(&response, p_req->p_context); + + if (response.result != NRF_DFU_RES_CODE_SUCCESS) + { + m_observer(NRF_DFU_EVT_DFU_FAILED); + } + } +} + + +static void nrf_dfu_req_handler_req(void * p_evt, uint16_t event_length) +{ + nrf_dfu_request_t * p_req = (nrf_dfu_request_t *)(p_evt); + nrf_dfu_req_handler_req_process(p_req); +} + + +ret_code_t nrf_dfu_req_handler_on_req(nrf_dfu_request_t * p_req) +{ + ret_code_t ret; + + if (p_req->callback.response == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + ret = app_sched_event_put(p_req, sizeof(nrf_dfu_request_t), nrf_dfu_req_handler_req); + if (ret != NRF_SUCCESS) + { + NRF_LOG_WARNING("Scheduler ran out of space!"); + } + + return ret; +} + + +ret_code_t nrf_dfu_req_handler_init(nrf_dfu_observer_t observer) +{ + ret_code_t ret_val; + nrf_dfu_result_t result; + + if (observer == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + +#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD) + ret_val = nrf_dfu_flash_init(true); +#else + ret_val = nrf_dfu_flash_init(false); +#endif + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + nrf_dfu_validation_init(); + if (nrf_dfu_validation_init_cmd_present()) + { + /* Execute a previously received init packed. Subsequent executes will have no effect. */ + result = nrf_dfu_validation_init_cmd_execute(&m_firmware_start_addr, &m_firmware_size_req); + if (result != NRF_DFU_RES_CODE_SUCCESS) + { + /* Init packet in flash is not valid! */ + return NRF_ERROR_INTERNAL; + } + } + + m_observer = observer; + + /* Initialize extended error handling with "No error" as the most recent error. */ + result = ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR); + UNUSED_RETURN_VALUE(result); + + return NRF_SUCCESS; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h new file mode 100644 index 0000000..5bbb4a8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_req_handler.h @@ -0,0 +1,345 @@ +/** + * Copyright (c) 2016 - 2019, 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 sdk_nrf_dfu_req_handler Request handling + * @{ + * @ingroup nrf_dfu + */ + +#ifndef NRF_DFU_REQ_HANDLER_H__ +#define NRF_DFU_REQ_HANDLER_H__ + +#include +#include +#include "app_util_platform.h" +#include "nrf_dfu_flash.h" +#include "nrf_dfu_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +ANON_UNIONS_ENABLE; + +/** + * @brief DFU object types. + */ +typedef enum +{ + NRF_DFU_OBJ_TYPE_INVALID, //!< Invalid object type. + NRF_DFU_OBJ_TYPE_COMMAND, //!< Command object. + NRF_DFU_OBJ_TYPE_DATA, //!< Data object. +} nrf_dfu_obj_type_t; + +/** + * @brief DFU protocol operation. + */ +typedef enum +{ + NRF_DFU_OP_PROTOCOL_VERSION = 0x00, //!< Retrieve protocol version. + NRF_DFU_OP_OBJECT_CREATE = 0x01, //!< Create selected object. + NRF_DFU_OP_RECEIPT_NOTIF_SET = 0x02, //!< Set receipt notification. + NRF_DFU_OP_CRC_GET = 0x03, //!< Request CRC of selected object. + NRF_DFU_OP_OBJECT_EXECUTE = 0x04, //!< Execute selected object. + NRF_DFU_OP_OBJECT_SELECT = 0x06, //!< Select object. + NRF_DFU_OP_MTU_GET = 0x07, //!< Retrieve MTU size. + NRF_DFU_OP_OBJECT_WRITE = 0x08, //!< Write selected object. + NRF_DFU_OP_PING = 0x09, //!< Ping. + NRF_DFU_OP_HARDWARE_VERSION = 0x0A, //!< Retrieve hardware version. + NRF_DFU_OP_FIRMWARE_VERSION = 0x0B, //!< Retrieve firmware version. + NRF_DFU_OP_ABORT = 0x0C, //!< Abort the DFU procedure. + NRF_DFU_OP_RESPONSE = 0x60, //!< Response. + NRF_DFU_OP_INVALID = 0xFF, +} nrf_dfu_op_t; + +/** + * @brief DFU operation result code. + */ +typedef enum +{ + NRF_DFU_RES_CODE_INVALID = 0x00, //!< Invalid opcode. + NRF_DFU_RES_CODE_SUCCESS = 0x01, //!< Operation successful. + NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED = 0x02, //!< Opcode not supported. + NRF_DFU_RES_CODE_INVALID_PARAMETER = 0x03, //!< Missing or invalid parameter value. + NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES = 0x04, //!< Not enough memory for the data object. + NRF_DFU_RES_CODE_INVALID_OBJECT = 0x05, //!< Data object does not match the firmware and hardware requirements, the signature is wrong, or parsing the command failed. + NRF_DFU_RES_CODE_UNSUPPORTED_TYPE = 0x07, //!< Not a valid object type for a Create request. + NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED = 0x08, //!< The state of the DFU process does not allow this operation. + NRF_DFU_RES_CODE_OPERATION_FAILED = 0x0A, //!< Operation failed. + NRF_DFU_RES_CODE_EXT_ERROR = 0x0B, //!< Extended error. The next byte of the response contains the error code of the extended error (see @ref nrf_dfu_ext_error_code_t. +} nrf_dfu_result_t; + +typedef enum +{ + NRF_DFU_FIRMWARE_TYPE_SOFTDEVICE = 0x00, + NRF_DFU_FIRMWARE_TYPE_APPLICATION = 0x01, + NRF_DFU_FIRMWARE_TYPE_BOOTLOADER = 0x02, + NRF_DFU_FIRMWARE_TYPE_UNKNOWN = 0xFF, +} nrf_dfu_firmware_type_t; + +/** + * @brief @ref NRF_DFU_OP_PROTOCOL_VERSION response details. + */ +typedef struct +{ + uint8_t version; //!< Protocol version. +} nrf_dfu_response_protocol_t; + +/** + * @brief @ref NRF_DFU_OP_HARDWARE_VERSION response details. + */ +typedef struct +{ + uint32_t part; //!< Hardware part, from FICR register. + uint32_t variant; //!< Hardware variant, from FICR register. + struct + { + uint32_t rom_size; //!< ROM size, in bytes. + uint32_t ram_size; //!< RAM size, in bytes. + uint32_t rom_page_size; //!< ROM flash page size, in bytes. + } memory; +} nrf_dfu_response_hardware_t; + +/** + * @brief @ref NRF_DFU_OP_FIRMWARE_VERSION response details. + */ +typedef struct +{ + nrf_dfu_firmware_type_t type; //!< Firmware type. + uint32_t version; //!< Firmware version. + uint32_t addr; //!< Firmware address in flash. + uint32_t len; //!< Firmware length in bytes. +} nrf_dfu_response_firmware_t; + +/** + * @brief @ref NRF_DFU_OP_OBJECT_SELECT response details. + */ +typedef struct +{ + uint32_t offset; //!< Current offset. + uint32_t crc; //!< Current CRC. + uint32_t max_size; //!< Maximum size of selected object. +} nrf_dfu_response_select_t; + +/** + * @brief @ref NRF_DFU_OP_OBJECT_CREATE response details. + */ +typedef struct +{ + uint32_t offset; //!< Current offset + uint32_t crc; //!< Current CRC. +} nrf_dfu_response_create_t; + +/** + * @brief @ref NRF_DFU_OP_OBJECT_WRITE response details. + */ +typedef struct +{ + uint32_t offset; //!< Used only when packet receipt notification is used. + uint32_t crc; //!< Used only when packet receipt notification is used. +} nrf_dfu_response_write_t; + +/** + * @brief @ref NRF_DFU_OP_CRC_GET response details. + */ +typedef struct +{ + uint32_t offset; //!< Current offset. + uint32_t crc; //!< Current CRC. +} nrf_dfu_response_crc_t; + +/** + * @brief @ref NRF_DFU_OP_PING response details. + */ +typedef struct +{ + uint8_t id; //!< The received ID which is echoed back. +} nrf_dfu_response_ping_t; + +/** + * @brief @ref NRF_DFU_OP_MTU_GET response details. + */ +typedef struct +{ + uint16_t size; //!< The MTU size as specified by the local transport. +} nrf_dfu_response_mtu_t; + +/** + * @brief DFU response message. + */ +typedef struct +{ + nrf_dfu_op_t request; //!< Requested operation. + nrf_dfu_result_t result; //!< Result of the operation. + union + { + nrf_dfu_response_protocol_t protocol; //!< Protocol version response. + nrf_dfu_response_hardware_t hardware; //!< Hardware version response. + nrf_dfu_response_firmware_t firmware; //!< Firmware version response. + nrf_dfu_response_select_t select; //!< Select object response.. + nrf_dfu_response_create_t create; //!< Create object response.. + nrf_dfu_response_write_t write; //!< Write object response. + nrf_dfu_response_crc_t crc; //!< CRC response. + nrf_dfu_response_ping_t ping; //!< Ping response. + nrf_dfu_response_mtu_t mtu; //!< MTU response. + }; +} nrf_dfu_response_t; + +/** + * @brief @ref NRF_DFU_OP_FIRMWARE_VERSION request details. + */ +typedef struct +{ + uint8_t image_number; //!< Index of the firmware. +} nrf_dfu_request_firmware_t; + +/** + * @brief @ref NRF_DFU_OP_OBJECT_SELECT request details. + */ +typedef struct +{ + uint32_t object_type; //!< Object type. See @ref nrf_dfu_obj_type_t. +} nrf_dfu_request_select_t; + +/** + * @brief @ref NRF_DFU_OP_OBJECT_CREATE request details. + */ +typedef struct +{ + uint32_t object_type; //!< Object type. See @ref nrf_dfu_obj_type_t. + uint32_t object_size; //!< Object size in bytes. +} nrf_dfu_request_create_t; + +/** + * @brief @ref NRF_DFU_OP_OBJECT_WRITE request details. + */ +typedef struct +{ + uint8_t const * p_data; //!< Data. + uint16_t len; //!< Length of data in @ref nrf_dfu_request_write_t::p_data. +} nrf_dfu_request_write_t; + +/** + * @brief @ref NRF_DFU_OP_PING request details. + */ +typedef struct +{ + uint8_t id; //!< Ping ID that will be returned in response. +} nrf_dfu_request_ping_t; + +/** + * @brief @ref NRF_DFU_OP_MTU_GET request details. + */ +typedef struct +{ + uint16_t size; //!< Transport MTU size in bytes. +} nrf_dfu_request_mtu_t; + +/** + * @brief @ref NRF_DFU_OP_RECEIPT_NOTIF_SET request details. + */ +typedef struct +{ + uint32_t target; //!< Target PRN. +} nrf_dfu_request_prn_t; + + +typedef void (*nrf_dfu_response_callback_t)(nrf_dfu_response_t * p_res, void * p_context); + +/** + *@brief DFU request. + */ +typedef struct +{ + nrf_dfu_op_t request; //!< Requested operation. + void * p_context; + struct + { + nrf_dfu_response_callback_t response; //!< Callback to call to send the response. + nrf_dfu_flash_callback_t write; + } callback; + union + { + nrf_dfu_request_firmware_t firmware; //!< Firmware version request. + nrf_dfu_request_select_t select; //!< Select object request. + nrf_dfu_request_create_t create; //!< Create object request. + nrf_dfu_request_write_t write; //!< Write object request. + nrf_dfu_request_ping_t ping; //!< Ping. + nrf_dfu_request_mtu_t mtu; //!< MTU size request. + nrf_dfu_request_prn_t prn; //!< Set receipt notification request. + }; +} nrf_dfu_request_t; + + +/**@brief Function for initializing the request handling module. + * + * @param observer Callback function for receiving notifications. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_INTERNAL If the init packet in flash is not valid. + * @retval NRF_ERROR_INVALID_PARAM If observer is not provided. + */ +ret_code_t nrf_dfu_req_handler_init(nrf_dfu_observer_t observer); + + +/**@brief Function for scheduling processing of a DFU request. + * + * Requests are processed asynchronously by the scheduler. + * + * @param[in] p_req Request to be handled. The response callback must be non-null. + * + * @retval NRF_SUCCESS If the command request was executed successfully. + * @retval NRF_ERROR_NO_MEM If the scheduler ran out of memory. + * @retval NRF_ERROR_INVALID_PARAM If the response callback is NULL. + */ +ret_code_t nrf_dfu_req_handler_on_req(nrf_dfu_request_t * p_req); + + +ANON_UNIONS_DISABLE; + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DFU_REQ_HANDLER_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.c new file mode 100644 index 0000000..adec2ac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.c @@ -0,0 +1,425 @@ +/** + * Copyright (c) 2016 - 2019, 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 "nrf_dfu_settings.h" +#include +#include +#include "nrf_dfu_flash.h" +#include "nrf_soc.h" +#include "crc32.h" +#include "nrf_nvmc.h" +#include "sdk_config.h" + + +#define DFU_SETTINGS_VERSION_OFFSET (offsetof(nrf_dfu_settings_t, settings_version)) //crc != 0xFFFFFFFF) + { + // CRC is set. Content must be valid + uint32_t crc = settings_crc_get(p_settings); + if (crc == p_settings->crc) + { + return true; + } + } + return false; +} + + +static uint32_t boot_validation_crc(nrf_dfu_settings_t const * p_settings) +{ + return crc32_compute((const uint8_t *)&p_settings->boot_validation_softdevice, + DFU_SETTINGS_BOOT_VALIDATION_SIZE - 4, + NULL); +} + + +static bool boot_validation_crc_ok(nrf_dfu_settings_t const * p_settings) +{ + return (boot_validation_crc(p_settings) == p_settings->boot_validation_crc); +} + + +static bool settings_crc_ok(void) +{ + nrf_dfu_settings_t const * p_settings = (nrf_dfu_settings_t const *)m_dfu_settings_buffer; + return crc_ok(p_settings); +} + + +static bool settings_backup_crc_ok(void) +{ + nrf_dfu_settings_t const * p_settings = (nrf_dfu_settings_t const *)mp_dfu_settings_backup_buffer; + return crc_ok(p_settings) && ((p_settings->settings_version == 1) || boot_validation_crc_ok(p_settings)); +} + +#define REGION_COPY_BY_MEMBER(start_member, end_member, p_dst_addr) \ + memcpy(p_dst_addr + offsetof(nrf_dfu_settings_t, start_member), \ + mp_dfu_settings_backup_buffer + offsetof(nrf_dfu_settings_t, start_member), \ + offsetof(nrf_dfu_settings_t, end_member) - offsetof(nrf_dfu_settings_t, start_member)) + + +static void settings_forbidden_parts_copy_from_backup(uint8_t * p_dst_addr) +{ +#if NRF_DFU_IN_APP || NRF_BL_DFU_ALLOW_UPDATE_FROM_APP + REGION_COPY_BY_MEMBER(settings_version, bank_current, p_dst_addr); + REGION_COPY_BY_MEMBER(bank_0, write_offset, p_dst_addr); + REGION_COPY_BY_MEMBER(sd_size, progress, p_dst_addr); + REGION_COPY_BY_MEMBER(boot_validation_crc, peer_data, p_dst_addr); +#else + REGION_COPY_BY_MEMBER(settings_version, enter_buttonless_dfu, p_dst_addr); + REGION_COPY_BY_MEMBER(init_command, peer_data, p_dst_addr); +#endif +} + +void nrf_dfu_settings_reinit(void) +{ + bool settings_valid = settings_crc_ok(); + bool settings_backup_valid = settings_backup_crc_ok(); + + if (settings_valid) + { + NRF_LOG_DEBUG("Using settings page."); + memcpy(&s_dfu_settings, m_dfu_settings_buffer, sizeof(nrf_dfu_settings_t)); + if (settings_backup_valid) + { + NRF_LOG_DEBUG("Copying forbidden parts from backup page."); + settings_forbidden_parts_copy_from_backup((uint8_t *)&s_dfu_settings); + } + } + else if (settings_backup_valid) + { + NRF_LOG_INFO("Restoring settings from backup since the settings page contents are " + "invalid (CRC error)."); + memcpy(&s_dfu_settings, + mp_dfu_settings_backup_buffer, + sizeof(nrf_dfu_settings_t)); + } + else + { + NRF_LOG_WARNING("Resetting bootloader settings since neither the settings page nor the " + "backup are valid (CRC error)."); + memset(&s_dfu_settings, 0x00, sizeof(nrf_dfu_settings_t)); + s_dfu_settings.settings_version = NRF_DFU_SETTINGS_VERSION; + } + + if (NRF_DFU_SETTINGS_COMPATIBILITY_MODE && !NRF_DFU_IN_APP && (s_dfu_settings.settings_version == 1)) + { + NRF_LOG_INFO("Old settings page detected. Upgrading info."); + + // Old version. Translate. + memcpy(&s_dfu_settings.peer_data, (uint8_t *)&s_dfu_settings + DFU_SETTINGS_BOND_DATA_OFFSET_V1, NRF_DFU_PEER_DATA_LEN); + memcpy(&s_dfu_settings.adv_name, (uint8_t *)&s_dfu_settings + DFU_SETTINGS_ADV_NAME_OFFSET_V1, NRF_DFU_ADV_NAME_LEN); + + // Initialize with defaults. + s_dfu_settings.boot_validation_softdevice.type = NO_VALIDATION; + s_dfu_settings.boot_validation_app.type = VALIDATE_CRC; + s_dfu_settings.boot_validation_bootloader.type = NO_VALIDATION; + memcpy(s_dfu_settings.boot_validation_app.bytes, &s_dfu_settings.bank_0.image_crc, sizeof(uint32_t)); + + s_dfu_settings.settings_version = NRF_DFU_SETTINGS_VERSION; + } + + return; +} + +ret_code_t nrf_dfu_settings_init(bool sd_irq_initialized) +{ + NRF_LOG_DEBUG("Calling nrf_dfu_settings_init()..."); + + ret_code_t err_code = nrf_dfu_flash_init(sd_irq_initialized); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_dfu_flash_init() failed with error: %x", err_code); + return NRF_ERROR_INTERNAL; + } + + nrf_dfu_settings_reinit(); + + err_code = nrf_dfu_settings_write_and_backup(NULL); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_dfu_settings_write_and_backup() failed with error: %x", err_code); + return NRF_ERROR_INTERNAL; + } + + return NRF_SUCCESS; +} + + +static bool settings_forbidden_parts_equal_to_backup(uint8_t * p_compare_addr) +{ + nrf_dfu_settings_t temp_settings; + memcpy(&temp_settings, p_compare_addr, sizeof(nrf_dfu_settings_t)); + settings_forbidden_parts_copy_from_backup((uint8_t *)&temp_settings); + return memcmp(&temp_settings, p_compare_addr, sizeof(nrf_dfu_settings_t)) == 0; +} + + +static ret_code_t settings_write(void * p_dst, + void const * p_src, + nrf_dfu_flash_callback_t callback, + nrf_dfu_settings_t * p_dfu_settings_buffer) +{ + ret_code_t err_code; + + if (memcmp(p_dst, p_src, sizeof(nrf_dfu_settings_t)) == 0) + { + NRF_LOG_DEBUG("Destination settings are identical to source, write not needed. Skipping."); + if (callback != NULL) + { + callback(NULL); + } + return NRF_SUCCESS; + } + + if (NRF_DFU_IN_APP && !settings_forbidden_parts_equal_to_backup((uint8_t *)&s_dfu_settings)) + { + NRF_LOG_WARNING("Settings write aborted since it tries writing to forbidden settings."); + return NRF_ERROR_FORBIDDEN; + } + + NRF_LOG_DEBUG("Writing settings..."); + NRF_LOG_DEBUG("Erasing old settings at: 0x%08x", p_dst); + + // Not setting the callback function because ERASE is required before STORE + // Only report completion on successful STORE. + err_code = nrf_dfu_flash_erase((uint32_t)p_dst, 1, NULL); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not erase the settings page!"); + return NRF_ERROR_INTERNAL; + } + + ASSERT(p_dfu_settings_buffer != NULL); + memcpy(p_dfu_settings_buffer, p_src, sizeof(nrf_dfu_settings_t)); + + err_code = nrf_dfu_flash_store((uint32_t)p_dst, + p_dfu_settings_buffer, + sizeof(nrf_dfu_settings_t), + callback); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not write the DFU settings page!"); + return NRF_ERROR_INTERNAL; + } + + return NRF_SUCCESS; +} + + +ret_code_t nrf_dfu_settings_write(nrf_dfu_flash_callback_t callback) +{ + static nrf_dfu_settings_t dfu_settings_buffer; + s_dfu_settings.crc = settings_crc_get(&s_dfu_settings); + s_dfu_settings.boot_validation_crc = boot_validation_crc(&s_dfu_settings); + return settings_write(m_dfu_settings_buffer, + &s_dfu_settings, + callback, + &dfu_settings_buffer); +} + + +void settings_backup(nrf_dfu_flash_callback_t callback, void * p_src) +{ +#if NRF_DFU_IN_APP + NRF_LOG_INFO("Settings backup not available from app."); +#else + static nrf_dfu_settings_t dfu_settings_buffer; + NRF_LOG_INFO("Backing up settings page to address 0x%x.", mp_dfu_settings_backup_buffer); + ASSERT(crc_ok(p_src)); + ret_code_t err_code = settings_write(mp_dfu_settings_backup_buffer, + p_src, + callback, + &dfu_settings_buffer); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not perform backup of bootloader settings! Error: 0x%x", err_code); + } +#endif +} + + +void nrf_dfu_settings_backup(nrf_dfu_flash_callback_t callback) +{ + settings_backup(callback, m_dfu_settings_buffer); +} + + +ret_code_t nrf_dfu_settings_write_and_backup(nrf_dfu_flash_callback_t callback) +{ +#if NRF_DFU_IN_APP + ret_code_t err_code = nrf_dfu_settings_write(callback); +#else + ret_code_t err_code = nrf_dfu_settings_write(NULL); + if (err_code == NRF_SUCCESS) + { + settings_backup(callback, &s_dfu_settings); + } +#endif + return err_code; +} + + +__WEAK ret_code_t nrf_dfu_settings_additional_erase(void) +{ + NRF_LOG_WARNING("No additional data erased"); + return NRF_SUCCESS; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.h index 4bacf8e..a629c1d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -50,10 +50,8 @@ #include #include "nrf_dfu_types.h" #include "nrf_dfu_flash.h" - -#if defined(NRF_DFU_SVCI_ENABLED) && defined(SOFTDEVICE_PRESENT) -#include "nrf_dfu_svci.h" -#endif +#include "sdk_config.h" +#include "sdk_errors.h" #ifdef __cplusplus extern "C" { @@ -75,14 +73,51 @@ extern nrf_dfu_settings_t s_dfu_settings; * @retval NRF_SUCCESS If the write process was successfully initiated. * @retval NRF_ERROR_INTERNAL If a flash error occurred. */ -ret_code_t nrf_dfu_settings_write(dfu_flash_callback_t callback); +ret_code_t nrf_dfu_settings_write(nrf_dfu_flash_callback_t callback); + + +/**@brief Function for backing up the settings. + * + * This function copies the contents of the settings page (in flash) to a separate page (in flash). + * During @ref nrf_dfu_settings_init, the backup is restored if the original is invalid. + * + * @param[in] callback Pointer to a function that is called after completing the write operation. + */ +void nrf_dfu_settings_backup(nrf_dfu_flash_callback_t callback); + + +/**@brief Function for writing DFU settings to flash and to backup. + * + * This function first calls @ref nrf_dfu_settings_write and then @ref nrf_dfu_settings_backup. + * + * @param[in] callback Pointer to a function that is called after completing the write and backup operation. + * + * @retval NRF_SUCCESS If the write process was successfully initiated. + * @retval NRF_ERROR_INTERNAL If a flash error occurred during the first write. + */ +ret_code_t nrf_dfu_settings_write_and_backup(nrf_dfu_flash_callback_t callback); + + +/**@brief Function for initializing the DFU settings structure. + * + * Initializes the RAM structure from the flash contents. + * This function is called as part of @ref nrf_dfu_settings_init. + * + * @retval NRF_SUCCESS If the initialization was successful. + * @retval NRF_ERROR_INTERNAL If a flash error occurred. + */ +void nrf_dfu_settings_reinit(void); /**@brief Function for initializing the DFU settings module. + * + * @retval NRF_SUCCESS If the initialization was successful. + * @retval NRF_ERROR_INTERNAL If a flash error occurred. */ -void nrf_dfu_settings_init(bool sd_irq_initialized); +ret_code_t nrf_dfu_settings_init(bool sd_irq_initialized); +#if defined(NRF_DFU_TRANSPORT_BLE) && NRF_DFU_TRANSPORT_BLE /** @brief Function for storing peer data received through an SVCI call in DFU settings. * * @note The content of the type can be verified by a CRC value stored inside the struct @@ -149,6 +184,7 @@ ret_code_t nrf_dfu_settings_adv_name_copy(nrf_dfu_adv_name_t * p_adv_name); */ bool nrf_dfu_settings_adv_name_is_valid(void); +#endif // NRF_DFU_TRANSPORT_BLE /** @brief Function for erasing additional data in DFU settings. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c index 288d159..a0c3bcd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_nosd.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci.c similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_nosd.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci.c index 0f370cc..0a29c9c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start_nosd.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,37 +35,53 @@ * 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 -#include "nrf_bootloader_app_start.h" +#include #include "nrf_log.h" -#include "nrf_dfu_mbr.h" +#include "nrf_sdm.h" +#include "app_util.h" + +#define APP_START_ADDR CODE_START -extern void nrf_bootloader_app_start_impl(uint32_t start_addr); -void nrf_bootloader_app_start(uint32_t start_addr) +uint32_t nrf_dfu_svci_vector_table_set(void) { - NRF_LOG_DEBUG("Running nrf_bootloader_app_start with address: 0x%08x", start_addr); uint32_t err_code; + uint32_t bootloader_addr = BOOTLOADER_ADDRESS; + + if (bootloader_addr != 0xFFFFFFFF) + { + NRF_LOG_INFO("Setting vector table to bootloader: 0x%08x", bootloader_addr); + err_code = sd_softdevice_vector_table_base_set(bootloader_addr); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed running sd_softdevice_vector_table_base_set"); + return err_code; + } + + return NRF_SUCCESS; + } + + NRF_LOG_ERROR("No bootloader was found"); + return NRF_ERROR_NO_MEM; +} - // Disable interrupts - NRF_LOG_DEBUG("Disabling interrupts"); - NVIC->ICER[0]=0xFFFFFFFF; -#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2 - NVIC->ICER[1]=0xFFFFFFFF; -#endif +uint32_t nrf_dfu_svci_vector_table_unset(void) +{ + uint32_t err_code; - NRF_LOG_DEBUG("Setting MBR irq forward address: 0x%08x", start_addr); - err_code = nrf_dfu_mbr_irq_forward_address_set(start_addr); + NRF_LOG_INFO("Setting vector table to main app: 0x%08x", APP_START_ADDR); + err_code = sd_softdevice_vector_table_base_set(APP_START_ADDR); if (err_code != NRF_SUCCESS) { - NRF_LOG_ERROR("Failed running nrf_dfu_mbr_irq_forward_address_set"); - return; + NRF_LOG_ERROR("Failed running sd_softdevice_vector_table_base_set"); + return err_code; } - // Run application - nrf_bootloader_app_start_impl(start_addr); + return NRF_SUCCESS; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c index 1a8fb05..af6b5f7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -43,33 +43,35 @@ #include "app_error.h" #include "nrf_nvmc.h" #include "nrf_dfu_types.h" -#include "nrf_dfu_svci.h" +#include "nrf_dfu_ble_svci_bond_sharing.h" #include "nrf_log.h" #include "nrf_dfu_settings.h" +#include "sdk_config.h" -#if defined(NRF_DFU_BLE_REQUIRES_BONDS) && (NRF_DFU_BLE_REQUIRES_BONDS == 1) +#if (NRF_DFU_TRANSPORT_BLE && NRF_DFU_BLE_REQUIRES_BONDS) -//lint -save -e545 -esym(526, nrf_dfu_set_peer_data_handler) -esym(528, nrf_dfu_set_peer_data_handler) -NRF_SVCI_ASYNC_HANDLER_CREATE(NRF_DFU_SVCI_SET_PEER_DATA, nrf_dfu_set_peer_data, nrf_dfu_peer_data_t, nrf_dfu_peer_data_state_t); -//lint -restore + +NRF_SVCI_ASYNC_HANDLER_CREATE(NRF_DFU_SVCI_SET_PEER_DATA, + nrf_dfu_set_peer_data, nrf_dfu_peer_data_t, nrf_dfu_peer_data_state_t); static uint32_t nrf_dfu_set_peer_data_handler(nrf_dfu_set_peer_data_svci_async_t * p_async) { VERIFY_PARAM_NOT_NULL(p_async); - p_async->async_func = &nrf_dfu_set_peer_data_on_call; - p_async->sys_evt_handler = &nrf_dfu_set_peer_data_on_sys_evt; - p_async->state = DFU_PEER_DATA_STATE_INITIALIZED; + p_async->async_func = nrf_dfu_set_peer_data_on_call; + p_async->sys_evt_handler = nrf_dfu_set_peer_data_on_sys_evt; + p_async->state = DFU_PEER_DATA_STATE_INITIALIZED; return NRF_SUCCESS; } -static uint32_t nrf_dfu_set_peer_data_on_call(nrf_dfu_peer_data_t * p_data, nrf_dfu_peer_data_state_t * p_state) +static uint32_t nrf_dfu_set_peer_data_on_call(nrf_dfu_peer_data_t * p_data, + nrf_dfu_peer_data_state_t * p_state) { - uint32_t ret_val; + uint32_t ret_val = NRF_ERROR_BUSY; VERIFY_PARAM_NOT_NULL(p_state); @@ -79,8 +81,11 @@ static uint32_t nrf_dfu_set_peer_data_on_call(nrf_dfu_peer_data_t * p_data, nrf_ return NRF_ERROR_INVALID_STATE; case DFU_PEER_DATA_STATE_INITIALIZED: - *p_state = DFU_PEER_DATA_STATE_WRITE_REQUESTED; ret_val = nrf_dfu_settings_peer_data_write(p_data); + if (ret_val == NRF_SUCCESS) + { + *p_state = DFU_PEER_DATA_STATE_WRITE_REQUESTED; + } break; case DFU_PEER_DATA_STATE_WRITE_REQUESTED: @@ -99,7 +104,7 @@ static uint32_t nrf_dfu_set_peer_data_on_call(nrf_dfu_peer_data_t * p_data, nrf_ static uint32_t nrf_dfu_set_peer_data_on_sys_evt(uint32_t sys_event, nrf_dfu_peer_data_state_t * p_state) { - uint32_t ret_val = NRF_ERROR_BUSY; + uint32_t ret_val = NRF_ERROR_INVALID_STATE; VERIFY_PARAM_NOT_NULL(p_state); @@ -108,7 +113,7 @@ static uint32_t nrf_dfu_set_peer_data_on_sys_evt(uint32_t sys_event, nrf_dfu_pee switch (sys_event) { case NRF_EVT_FLASH_OPERATION_ERROR: - return NRF_ERROR_INVALID_STATE; + return NRF_ERROR_BUSY; case NRF_EVT_FLASH_OPERATION_SUCCESS: ret_val = NRF_SUCCESS; @@ -124,26 +129,27 @@ static uint32_t nrf_dfu_set_peer_data_on_sys_evt(uint32_t sys_event, nrf_dfu_pee return ret_val; } -#else // not NRF_DFU_BLE_REQUIRES_BONDS +#elif (NRF_DFU_TRANSPORT_BLE && !NRF_DFU_BLE_REQUIRES_BONDS) -/*lint -save -e545 -esym(526, nrf_dfu_set_transport_data_handler_reg) -esym(528, nrf_dfu_set_transport_data_handler_reg) -esym(528, nrf_dfu_set_adv_name_var)*/ -NRF_SVCI_ASYNC_HANDLER_CREATE(NRF_DFU_SVCI_SET_ADV_NAME, nrf_dfu_set_adv_name, nrf_dfu_adv_name_t, nrf_dfu_set_adv_name_state_t); -/*lint -restore*/ + +NRF_SVCI_ASYNC_HANDLER_CREATE(NRF_DFU_SVCI_SET_ADV_NAME, + nrf_dfu_set_adv_name, nrf_dfu_adv_name_t, nrf_dfu_set_adv_name_state_t); static uint32_t nrf_dfu_set_adv_name_handler(nrf_dfu_set_adv_name_svci_async_t * p_async) { VERIFY_PARAM_NOT_NULL(p_async); - p_async->async_func = nrf_dfu_set_adv_name_on_call; + p_async->async_func = nrf_dfu_set_adv_name_on_call; p_async->sys_evt_handler = nrf_dfu_set_adv_name_on_sys_evt; - p_async->state = DFU_ADV_NAME_STATE_INITIALIZED; + p_async->state = DFU_ADV_NAME_STATE_INITIALIZED; return NRF_SUCCESS; } -static uint32_t nrf_dfu_set_adv_name_on_call(nrf_dfu_adv_name_t * p_adv_name, nrf_dfu_set_adv_name_state_t * p_state) +static uint32_t nrf_dfu_set_adv_name_on_call(nrf_dfu_adv_name_t * p_adv_name, + nrf_dfu_set_adv_name_state_t * p_state) { uint32_t ret_val = NRF_ERROR_BUSY; @@ -155,8 +161,11 @@ static uint32_t nrf_dfu_set_adv_name_on_call(nrf_dfu_adv_name_t * p_adv_name, nr return NRF_ERROR_INVALID_STATE; case DFU_ADV_NAME_STATE_INITIALIZED: - *p_state = DFU_ADV_NAME_STATE_WRITE_REQUESTED; ret_val = nrf_dfu_settings_adv_name_write(p_adv_name); + if (ret_val == NRF_SUCCESS) + { + *p_state = DFU_ADV_NAME_STATE_WRITE_REQUESTED; + } break; case DFU_ADV_NAME_STATE_WRITE_REQUESTED: @@ -175,7 +184,7 @@ static uint32_t nrf_dfu_set_adv_name_on_call(nrf_dfu_adv_name_t * p_adv_name, nr static uint32_t nrf_dfu_set_adv_name_on_sys_evt(uint32_t sys_event, nrf_dfu_set_adv_name_state_t * p_state) { - uint32_t ret_val = NRF_ERROR_BUSY; + uint32_t ret_val = NRF_ERROR_INVALID_STATE; VERIFY_PARAM_NOT_NULL(p_state); @@ -184,7 +193,7 @@ static uint32_t nrf_dfu_set_adv_name_on_sys_evt(uint32_t sys_event, nrf_dfu_set_ switch (sys_event) { case NRF_EVT_FLASH_OPERATION_ERROR: - return NRF_ERROR_INVALID_STATE; + return NRF_ERROR_BUSY; case NRF_EVT_FLASH_OPERATION_SUCCESS: ret_val = NRF_SUCCESS; @@ -200,4 +209,4 @@ static uint32_t nrf_dfu_set_adv_name_on_sys_evt(uint32_t sys_event, nrf_dfu_set_ return ret_val; } -#endif // NRF_DFU_BLE_REQUIRES_BONDS +#endif // NRF_DFU_TRANSPORT_BLE && !NRF_DFU_BLE_REQUIRES_BONDS diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_transport.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_transport.c similarity index 82% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_transport.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_transport.c index a3deb4f..9e0e29c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_transport.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_transport.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_dfu_transport.h" #include "nrf_log.h" @@ -47,51 +47,45 @@ NRF_SECTION_DEF(dfu_trans, const nrf_dfu_transport_t); -uint32_t nrf_dfu_transports_init(void) +uint32_t nrf_dfu_transports_init(nrf_dfu_observer_t observer) { uint32_t const num_transports = DFU_TRANS_SECTION_ITEM_COUNT; uint32_t ret_val = NRF_SUCCESS; - NRF_LOG_DEBUG("In nrf_dfu_transports_init"); - - NRF_LOG_DEBUG("num transports: %d", num_transports); + NRF_LOG_DEBUG("Initializing transports (found: %d)", num_transports); for (uint32_t i = 0; i < num_transports; i++) { nrf_dfu_transport_t * const trans = DFU_TRANS_SECTION_ITEM_GET(i); - ret_val = trans->init_func(); + ret_val = trans->init_func(observer); if (ret_val != NRF_SUCCESS) { + NRF_LOG_DEBUG("Failed to initialize transport %d, error %d", i, ret_val); break; } } - NRF_LOG_DEBUG("After nrf_dfu_transports_init"); - return ret_val; } -uint32_t nrf_dfu_transports_close(void) +uint32_t nrf_dfu_transports_close(nrf_dfu_transport_t const * p_exception) { uint32_t const num_transports = DFU_TRANS_SECTION_ITEM_COUNT; uint32_t ret_val = NRF_SUCCESS; - NRF_LOG_DEBUG("In nrf_dfu_transports_close"); - - NRF_LOG_DEBUG("num transports: %d", num_transports); + NRF_LOG_DEBUG("Shutting down transports (found: %d)", num_transports); for (uint32_t i = 0; i < num_transports; i++) { nrf_dfu_transport_t * const trans = DFU_TRANS_SECTION_ITEM_GET(i); - ret_val = trans->close_func(); + ret_val = trans->close_func(p_exception); if (ret_val != NRF_SUCCESS) { + NRF_LOG_DEBUG("Failed to shutdown transport %d, error %d", i, ret_val); break; } } - NRF_LOG_DEBUG("After nrf_dfu_transports_init"); - return ret_val; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_transport.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_transport.h similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_transport.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_transport.h index 258f442..abaf443 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_transport.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_transport.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,13 +35,13 @@ * 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 sdk_nrf_dfu_transport DFU transport * @{ - * @ingroup sdk_nrf_bootloader + * @ingroup nrf_dfu * @brief Generic Device Firmware Update (DFU) transport interface. * * @details The DFU transport module defines a generic interface that must @@ -53,11 +53,14 @@ #include #include "nrf_section.h" +#include "nrf_dfu_types.h" #ifdef __cplusplus extern "C" { #endif +/** @brief Forward declaration of nrf_dfu_transport_t */ +typedef struct nrf_dfu_transport_s nrf_dfu_transport_t; /** @brief Function type for initializing a DFU transport. * @@ -66,29 +69,34 @@ extern "C" { * until either the device is reset or the DFU operation is finalized. * When the DFU transport receives requests, it should call @ref nrf_dfu_req_handler_on_req for handling the requests. * + * @param observer Callback function for receiving DFU transport notifications. + * * @retval NRF_SUCCESS If initialization was successful for the transport. Any other return code indicates that the DFU transport could not be initialized. */ -typedef uint32_t (*nrf_dfu_init_fn_t)(void); +typedef uint32_t (*nrf_dfu_init_fn_t)(nrf_dfu_observer_t observer); /** @brief Function type for closing down a DFU transport. * * @details This function closes down a DFU transport in a gentle way. * - * @retval NRF_SUCCESS If closing was successful for the transport. Any other return code indicates that the DFU transport could not be closed closed down. + * @param[in] p_exception If exception matches current transport closing should be omitted. + * + * @retval NRF_SUCCESS If closing was successful for the transport. Any other return code indicates that the DFU transport could not be closed closed down. */ -typedef uint32_t (*nrf_dfu_disconnect_fn_t)(void); +typedef uint32_t (*nrf_dfu_close_fn_t)(nrf_dfu_transport_t const * p_exception); + /** @brief DFU transport registration. * * @details Every DFU transport must provide a registration of the initialization function. */ -typedef struct +struct nrf_dfu_transport_s { - nrf_dfu_init_fn_t init_func; /**< Registration of the init function to run to initialize a DFU transport. */ - nrf_dfu_disconnect_fn_t close_func; /**< Registration of the close function to close down a DFU transport. */ -} nrf_dfu_transport_t; + nrf_dfu_init_fn_t init_func; /**< Registration of the init function to run to initialize a DFU transport. */ + nrf_dfu_close_fn_t close_func; /**< Registration of the close function to close down a DFU transport. */ +}; /** @brief Function for initializing all the registered DFU transports. @@ -97,15 +105,16 @@ typedef struct * Any other error code indicates that at least one DFU * transport could not be initialized. */ -uint32_t nrf_dfu_transports_init(void); +uint32_t nrf_dfu_transports_init(nrf_dfu_observer_t observer); -/** @brief Function for closing down all the registered DFU transports. +/** @brief Function for closing down all (with optional exception) the registered DFU transports. * - * @retval NRF_SUCCESS If all DFU transport were closed down successfully. + * @param[in] p_exception Transport which should not be closed. NULL if all transports should be closed. + * @retval NRF_SUCCESS If all DFU transport were closed down successfully. * Any other error code indicates that at least one DFU * transport could not be closed down. */ -uint32_t nrf_dfu_transports_close(void); +uint32_t nrf_dfu_transports_close(nrf_dfu_transport_t const * p_exception); /** @brief Macro for registering a DFU transport by using section variables. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.c new file mode 100644 index 0000000..beafa23 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.c @@ -0,0 +1,244 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf_dfu_trigger_usb.h" +#include "app_usbd.h" +#include "app_usbd_nrf_dfu_trigger.h" +#include "nrf_drv_clock.h" +#include "nrf_log_ctrl.h" +#include "nrf_gpio.h" +#include "boards.h" +#include "app_util.h" +#include "app_usbd_serial_num.h" +#define NRF_LOG_MODULE_NAME nrf_dfu_trigger_usb +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#ifndef BSP_SELF_PINRESET_PIN +#error "This module is intended to be used with boards that have the GP pin shortened with the RESET pin." +#endif + +/** + * @brief Enable power USB detection. + * + * Configure if the example supports USB port connection. + */ +#ifndef USBD_POWER_DETECTION +#define USBD_POWER_DETECTION true +#endif + +#define DFU_FLASH_PAGE_SIZE (NRF_FICR->CODEPAGESIZE) +#define DFU_FLASH_PAGE_COUNT (NRF_FICR->CODESIZE) + +// Semantic versioning string. +#define VERSION_STRING STRINGIFY(APP_VERSION_MAJOR) "." STRINGIFY(APP_VERSION_MINOR) "." STRINGIFY(APP_VERSION_PATCH) APP_VERSION_PRERELEASE APP_VERSION_METADATA + +static uint8_t m_version_string[] = APP_NAME " " VERSION_STRING; ///< Human-readable version string. +static app_usbd_nrf_dfu_trigger_nordic_info_t m_dfu_info; ///< Struct with various information about the current firmware. + +static void dfu_trigger_evt_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_nrf_dfu_trigger_user_event_t event) +{ + UNUSED_PARAMETER(p_inst); + + switch (event) + { + case APP_USBD_NRF_DFU_TRIGGER_USER_EVT_DETACH: + NRF_LOG_INFO("DFU Detach request received. Triggering a pin reset."); + NRF_LOG_FINAL_FLUSH(); + nrf_gpio_cfg_output(BSP_SELF_PINRESET_PIN); + nrf_gpio_pin_clear(BSP_SELF_PINRESET_PIN); + break; + default: + break; + } +} + + +APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF(m_app_dfu, + NRF_DFU_TRIGGER_USB_INTERFACE_NUM, + &m_dfu_info, + m_version_string, + dfu_trigger_evt_handler); + + +static void usbd_user_evt_handler(app_usbd_event_type_t event) +{ + switch (event) + { + case APP_USBD_EVT_DRV_SUSPEND: + break; + case APP_USBD_EVT_DRV_RESUME: + break; + case APP_USBD_EVT_STARTED: + break; + case APP_USBD_EVT_STOPPED: + app_usbd_disable(); + break; + case APP_USBD_EVT_POWER_DETECTED: + NRF_LOG_INFO("USB power detected"); + + if (!nrf_drv_usbd_is_enabled()) + { + app_usbd_enable(); + } + break; + case APP_USBD_EVT_POWER_REMOVED: + NRF_LOG_INFO("USB power removed"); + app_usbd_stop(); + break; + case APP_USBD_EVT_POWER_READY: + NRF_LOG_INFO("USB ready"); + app_usbd_start(); + break; + default: + break; + } +} + + +static void strings_create(void) +{ + uint8_t prev_char = 'a'; // Arbitrary valid char, not '-'. + + // Remove characters that are not supported in semantic version strings. + for (size_t i = strlen(APP_NAME) + 1; i < strlen((char*)m_version_string); i++) + { + if (((m_version_string[i] >= 'a') && (m_version_string[i] <= 'z')) + || ((m_version_string[i] >= 'A') && (m_version_string[i] <= 'Z')) + || ((m_version_string[i] >= '0') && (m_version_string[i] <= '9')) + || (m_version_string[i] == '+') + || (m_version_string[i] == '.') + || (m_version_string[i] == '-')) + { + // Valid semantic version character. + } + else if (prev_char == '-') + { + m_version_string[i] = '0'; + } + else + { + m_version_string[i] = '-'; + } + + prev_char = m_version_string[i]; + } + +#if !NRF_DFU_TRIGGER_USB_USB_SHARED + app_usbd_serial_num_generate(); +#endif +} + +#if !(APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) +static void usbd_evt_handler(app_usbd_internal_evt_t const * const p_event) +{ + app_usbd_event_execute(p_event); +} +#endif + +ret_code_t nrf_dfu_trigger_usb_init(void) +{ + ret_code_t ret; + static bool initialized = false; + + if (initialized) + { + return NRF_SUCCESS; + } + + m_dfu_info.wAddress = CODE_START; + m_dfu_info.wFirmwareSize = CODE_SIZE; + m_dfu_info.wVersionMajor = APP_VERSION_MAJOR; + m_dfu_info.wVersionMinor = APP_VERSION_MINOR; + m_dfu_info.wFirmwareID = APP_ID; + m_dfu_info.wFlashPageSize = DFU_FLASH_PAGE_SIZE; + m_dfu_info.wFlashSize = m_dfu_info.wFlashPageSize * DFU_FLASH_PAGE_COUNT; + + strings_create(); + + if (!NRF_DFU_TRIGGER_USB_USB_SHARED) + { + static const app_usbd_config_t usbd_config = { + +#if !(APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) + .ev_handler = usbd_evt_handler, +#endif + .ev_state_proc = usbd_user_evt_handler + }; + + ret = nrf_drv_clock_init(); + if ((ret != NRF_SUCCESS) && (ret != NRF_ERROR_MODULE_ALREADY_INITIALIZED)) + { + return ret; + } + + ret = app_usbd_init(&usbd_config); + if (ret != NRF_SUCCESS) + { + return ret; + } + } + + app_usbd_class_inst_t const * class_dfu = app_usbd_nrf_dfu_trigger_class_inst_get(&m_app_dfu); + ret = app_usbd_class_append(class_dfu); + + if (!NRF_DFU_TRIGGER_USB_USB_SHARED) + { + if (USBD_POWER_DETECTION) + { + ret = app_usbd_power_events_enable(); + APP_ERROR_CHECK(ret); + } + else + { + NRF_LOG_INFO("No USB power detection enabled\r\nStarting USB now"); + + app_usbd_enable(); + app_usbd_start(); + } + } + + if (ret == NRF_SUCCESS) + { + initialized = true; + } + + return ret; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.h new file mode 100644 index 0000000..895b59a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.h @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRF_DFU_TRIGGER_USB_H +#define NRF_DFU_TRIGGER_USB_H + +#include "sdk_errors.h" + +/** + * @defgroup nrf_dfu_trigger_usb USB DFU trigger library + * @ingroup app_common + * + * @brief @tagAPI52840 USB DFU trigger library is used to enter the bootloader and read the firmware version. + * + * @details See @ref lib_dfu_trigger_usb for additional documentation. + * @{ + */ + +/** + * @brief Function for initializing the USB DFU trigger library. + * + * @note If the USB is also used for other purposes, then this function must be called after USB is + * initialized but before it is enabled. In this case, the configuration flag @ref + * NRF_DFU_TRIGGER_USB_USB_SHARED must be set to 1. + * + * @note Calling this again after the first success has no effect and returns @ref NRF_SUCCESS. + * + * @note If @ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE is on (1), USB events must be handled manually. + * See @ref app_usbd_event_queue_process. + * + * @retval NRF_SUCCESS On successful initialization. + * @return An error code on failure, for example if called at a wrong time. + */ +ret_code_t nrf_dfu_trigger_usb_init(void); + +/** @} */ + +#endif //NRF_DFU_TRIGGER_USB_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_types.h new file mode 100644 index 0000000..790399a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_types.h @@ -0,0 +1,338 @@ +/** + * Copyright (c) 2016 - 2019, 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 sdk_nrf_dfu_types DFU types + * @{ + * @ingroup nrf_dfu + */ + +#ifndef NRF_DFU_TYPES_H__ +#define NRF_DFU_TYPES_H__ + +#include +#include + +#include "sdk_common.h" +#include "nrf.h" +#include "nrf_mbr.h" +#include "app_util_platform.h" +#include "sdk_config.h" + +#if defined(NRF_DFU_TRANSPORT_BLE) && NRF_DFU_TRANSPORT_BLE +#include "ble_gap.h" +#define SYSTEM_SERVICE_ATT_SIZE 8 /**< Size of the system service attribute length including CRC-16 at the end. */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +#define INIT_COMMAND_MAX_SIZE 512 /**< Maximum size of the init command stored in dfu_settings. */ +#define INIT_COMMAND_MAX_SIZE_v1 256 /**< Maximum size of the init command in settings version 1. */ + +/** @brief Size of a flash page. This value is used for calculating the size of the reserved + * flash space in the bootloader region. + */ +#if defined(NRF51) + #define CODE_PAGE_SIZE (PAGE_SIZE_IN_WORDS * sizeof(uint32_t)) +#elif defined(NRF52_SERIES) + #define CODE_PAGE_SIZE (MBR_PAGE_SIZE_IN_WORDS * sizeof(uint32_t)) +#else + #error "Architecture not set." +#endif + +/** @brief Maximum size of a data object.*/ +#if defined(NRF51) + #define DATA_OBJECT_MAX_SIZE (CODE_PAGE_SIZE * 4) +#elif defined(NRF52_SERIES) || defined (__SDK_DOXYGEN__) + #define DATA_OBJECT_MAX_SIZE (CODE_PAGE_SIZE) +#else + #error "Architecture not set." +#endif + +/** @brief Page location of the bootloader settings address. + */ +#if defined (NRF51) + #define BOOTLOADER_SETTINGS_ADDRESS (0x0003FC00UL) +#elif defined( NRF52810_XXAA ) + #define BOOTLOADER_SETTINGS_ADDRESS (0x0002F000UL) +#elif defined( NRF52811_XXAA ) + #define BOOTLOADER_SETTINGS_ADDRESS (0x0002F000UL) +#elif defined( NRF52832_XXAA ) + #define BOOTLOADER_SETTINGS_ADDRESS (0x0007F000UL) +#elif defined( NRF52833_XXAA ) + #define BOOTLOADER_SETTINGS_ADDRESS (0x0007F000UL) +#elif defined(NRF52840_XXAA) + #define BOOTLOADER_SETTINGS_ADDRESS (0x000FF000UL) +#else + #error No valid target set for BOOTLOADER_SETTINGS_ADDRESS. +#endif + +#define BOOTLOADER_SETTINGS_PAGE_SIZE (CODE_PAGE_SIZE) +#define NRF_MBR_PARAMS_PAGE_SIZE (CODE_PAGE_SIZE) + +/** @brief Page location of the MBR parameters page address. + */ +#if defined(NRF52840_XXAA) || defined(NRF52840_XXAA_ENGA) + #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x000FE000UL) +#elif defined(NRF52832_XXAA) + #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0007E000UL) +#elif defined(NRF52833_XXAA) + #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0007E000UL) +#elif defined(NRF52810_XXAA) + #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0002E000UL) +#elif defined(NRF52811_XXAA) + #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0002E000UL) +#endif + +#define BOOTLOADER_SETTINGS_BACKUP_ADDRESS NRF_MBR_PARAMS_PAGE_ADDRESS + + +#ifndef NRF_DFU_APP_DATA_AREA_SIZE +#define NRF_DFU_APP_DATA_AREA_SIZE (CODE_PAGE_SIZE * 3) +#endif + +STATIC_ASSERT((NRF_DFU_APP_DATA_AREA_SIZE % CODE_PAGE_SIZE) == 0, "NRF_DFU_APP_DATA_AREA_SIZE must be a multiple of the flash page size."); + +#define DFU_APP_DATA_RESERVED NRF_DFU_APP_DATA_AREA_SIZE // For backward compatibility with 15.0.0. + +/** @brief Total size of the region between the SoftDevice and the bootloader. + */ +#define DFU_REGION_END(bootloader_start_addr) ((bootloader_start_addr) - (NRF_DFU_APP_DATA_AREA_SIZE)) + +#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD) +#define DFU_REGION_START (nrf_dfu_bank0_start_addr()) +#else +#define DFU_REGION_START (MBR_SIZE) +#endif + +#define DFU_REGION_TOTAL_SIZE ((DFU_REGION_END) - (DFU_REGION_START)) + +#define NRF_DFU_CURRENT_BANK_0 0x00 +#define NRF_DFU_CURRENT_BANK_1 0x01 + +#define NRF_DFU_BANK_LAYOUT_DUAL 0x00 +#define NRF_DFU_BANK_LAYOUT_SINGLE 0x01 + +/** @brief DFU bank state codes. + * + * @details The DFU bank state indicates the content of a bank: + * A valid image of a certain type or an invalid image. + */ + +#define NRF_DFU_BANK_INVALID 0x00 /**< Invalid image. */ +#define NRF_DFU_BANK_VALID_APP 0x01 /**< Valid application. */ +#define NRF_DFU_BANK_VALID_SD 0xA5 /**< Valid SoftDevice. */ +#define NRF_DFU_BANK_VALID_BL 0xAA /**< Valid bootloader. */ +#define NRF_DFU_BANK_VALID_SD_BL 0xAC /**< Valid SoftDevice and bootloader. */ +#define NRF_DFU_BANK_VALID_EXT_APP 0xB1 /**< Valid application designated for a remote node. */ + +/** @brief Description of a single bank. */ +#pragma pack(4) +typedef struct +{ + uint32_t image_size; /**< Size of the image in the bank. */ + uint32_t image_crc; /**< CRC of the image. If set to 0, the CRC is ignored. */ + uint32_t bank_code; /**< Identifier code for the bank. */ +} nrf_dfu_bank_t; + +/**@brief DFU progress. + * + * Be aware of the difference between objects and firmware images. A firmware image consists of multiple objects, each of a maximum size @ref DATA_OBJECT_MAX_SIZE. + * + * @note The union inside this struct is cleared when CREATE_OBJECT of command type is executed, and when there is a valid post-validation. + * In DFU activation (after reset) the @ref dfu_progress_t::update_start_address will be used in case of a SD/SD+BL update. + */ +ANON_UNIONS_ENABLE; +typedef struct +{ + uint32_t command_size; /**< The size of the current init command stored in the DFU settings. */ + uint32_t command_offset; /**< The offset of the currently received init command data. The offset will increase as the init command is received. */ + uint32_t command_crc; /**< The calculated CRC of the init command (calculated after the transfer is completed). */ + uint32_t data_object_size; /**< The size of the last object created. Note that this size is not the size of the whole firmware image.*/ + union + { + struct + { + uint32_t firmware_image_crc; /**< CRC value of the current firmware (continuously calculated as data is received). */ + uint32_t firmware_image_crc_last; /**< The CRC of the last executed object. */ + uint32_t firmware_image_offset; /**< The offset of the current firmware image being transferred. Note that this offset is the offset in the entire firmware image and not only the current object. */ + uint32_t firmware_image_offset_last;/**< The offset of the last executed object from the start of the firmware image. */ + }; + struct + { + uint32_t update_start_address; /**< Value indicating the start address of the new firmware (before copy). It's always used, but it's most important for an SD/SD+BL update where the SD changes size or if the DFU process had a power loss when updating a SD with changed size. */ + }; + }; +} dfu_progress_t; +ANON_UNIONS_DISABLE; + +/** @brief Event types in the bootloader and DFU process. */ +typedef enum +{ + NRF_DFU_EVT_DFU_INITIALIZED, /**< Starting DFU. */ + NRF_DFU_EVT_TRANSPORT_ACTIVATED, /**< Transport activated (e.g. BLE connected, USB plugged in). */ + NRF_DFU_EVT_TRANSPORT_DEACTIVATED, /**< Transport deactivated (e.g. BLE disconnected, USB plugged out). */ + NRF_DFU_EVT_DFU_STARTED, /**< DFU process started. */ + NRF_DFU_EVT_OBJECT_RECEIVED, /**< A DFU data object has been received. */ + NRF_DFU_EVT_DFU_FAILED, /**< DFU process has failed, been interrupted, or hung. */ + NRF_DFU_EVT_DFU_COMPLETED, /**< DFU process completed. */ + NRF_DFU_EVT_DFU_ABORTED, /**< DFU process aborted. */ +} nrf_dfu_evt_type_t; + +/** + * @brief Function for notifying DFU state. + */ +typedef void (*nrf_dfu_observer_t)(nrf_dfu_evt_type_t notification); + +#define NRF_DFU_PEER_DATA_LEN 64 /**< The length in bytes of nrf_dfu_peer_data_t expected by tools manipulating the settings page. Do not change without changing the settings page version. */ +#define NRF_DFU_ADV_NAME_LEN 28 /**< The length in bytes of nrf_dfu_adv_name_t expected by tools manipulating the settings page. Do not change without changing the settings page version. */ + +#if defined(NRF_DFU_TRANSPORT_BLE) && NRF_DFU_TRANSPORT_BLE + +typedef struct +{ + uint32_t crc; /**< CRC of the rest of the parameters in this struct. */ + ble_gap_id_key_t ble_id; /**< BLE GAP identity key of the device that initiated the DFU process. */ + ble_gap_enc_key_t enc_key; /**< Encryption key structure containing encrypted diversifier and LTK for reestablishing the bond. */ + uint8_t sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE]; /**< System service attributes for restoring of Service Changed Indication setting in DFU mode. */ +} nrf_dfu_peer_data_t; + +typedef enum +{ + DFU_PEER_DATA_STATE_INVALID = 0, + DFU_PEER_DATA_STATE_INITIALIZED = 1, + DFU_PEER_DATA_STATE_WRITE_REQUESTED = 2, + DFU_PEER_DATA_STATE_WRITE_FINISHED = 3, + DFU_PEER_DATA_STATE_WRITE_FAILED = 4, +} nrf_dfu_peer_data_state_t; + +typedef struct +{ + uint32_t crc; /**< CRC of the rest of the parameters in this struct. Calculated by the bootloader. */ + uint8_t name[20]; /**< New advertisement name to set. */ + uint32_t len; /**< Length of the advertisement name. */ +} nrf_dfu_adv_name_t; + +typedef enum +{ + DFU_ADV_NAME_STATE_INVALID = 0, + DFU_ADV_NAME_STATE_INITIALIZED = 1, + DFU_ADV_NAME_STATE_WRITE_REQUESTED = 2, + DFU_ADV_NAME_STATE_WRITE_FINISHED = 3, + DFU_ADV_NAME_STATE_WRITE_FAILED = 4, +} nrf_dfu_set_adv_name_state_t; + +#else +typedef struct +{ + uint8_t dummy_data[NRF_DFU_PEER_DATA_LEN]; +} nrf_dfu_peer_data_t; + +typedef struct +{ + uint8_t dummy_data[NRF_DFU_ADV_NAME_LEN]; +} nrf_dfu_adv_name_t; +#endif // NRF_DFU_TRANSPORT_BLE + +STATIC_ASSERT(sizeof(nrf_dfu_peer_data_t) == NRF_DFU_PEER_DATA_LEN, "nrf_dfu_peer_data_t has unexpected length. This can cause incompatibility with tools."); +STATIC_ASSERT(sizeof(nrf_dfu_adv_name_t) == NRF_DFU_ADV_NAME_LEN, "nrf_dfu_adv_name_t has unexpected length. This can cause incompatibility with tools."); + +#define SETTINGS_RESERVED_AREA_SIZE 16 /**< The number of words in the reserved area of the DFU settings. */ +#define SETTINGS_BOOT_VALIDATION_SIZE 64 /**< The number of bytes reserved for boot_validation value. */ + + +typedef enum +{ + NO_VALIDATION, + VALIDATE_CRC, + VALIDATE_SHA256, + VALIDATE_ECDSA_P256_SHA256, +} boot_validation_type_t; + +typedef struct +{ + boot_validation_type_t type; + uint8_t bytes[SETTINGS_BOOT_VALIDATION_SIZE]; +} boot_validation_t; + +/**@brief DFU settings for application and bank data. + */ +typedef struct +{ + uint32_t crc; /**< CRC for the stored DFU settings, not including the CRC itself. If 0xFFFFFFF, the CRC has never been calculated. */ + uint32_t settings_version; /**< Version of the current DFU settings struct layout. */ + uint32_t app_version; /**< Version of the last stored application. */ + uint32_t bootloader_version; /**< Version of the last stored bootloader. */ + + uint32_t bank_layout; /**< Bank layout: single bank or dual bank. This value can change. */ + uint32_t bank_current; /**< The bank that is currently used. */ + + nrf_dfu_bank_t bank_0; /**< Bank 0. */ + nrf_dfu_bank_t bank_1; /**< Bank 1. */ + + uint32_t write_offset; /**< Write offset for the current operation. */ + uint32_t sd_size; /**< Size of the SoftDevice. */ + + dfu_progress_t progress; /**< Current DFU progress. */ + + uint32_t enter_buttonless_dfu; + uint8_t init_command[INIT_COMMAND_MAX_SIZE]; /**< Buffer for storing the init command. */ + + uint32_t boot_validation_crc; + boot_validation_t boot_validation_softdevice; + boot_validation_t boot_validation_app; + boot_validation_t boot_validation_bootloader; + + nrf_dfu_peer_data_t peer_data; /**< Not included in calculated CRC. */ + nrf_dfu_adv_name_t adv_name; /**< Not included in calculated CRC. */ +} nrf_dfu_settings_t; + +#pragma pack() // revert pack settings + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DFU_TYPES_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.c new file mode 100644 index 0000000..22b5234 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.c @@ -0,0 +1,220 @@ +/** + * Copyright (c) 2016 - 2019, 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 "nrf_dfu_utils.h" + +#include "nrf_dfu_settings.h" +#include "nrf_bootloader_info.h" +#include "crc32.h" +#include "nrf_log.h" +#include "nrf_dfu_validation.h" + +void nrf_dfu_bank_invalidate(nrf_dfu_bank_t * const p_bank) +{ + // Set the bank-code to invalid, and reset size/CRC + memset(p_bank, 0, sizeof(nrf_dfu_bank_t)); + + // Reset write pointer after completed operation + s_dfu_settings.write_offset = 0; +} + + +#if !defined(BLE_STACK_SUPPORT_REQD) && !defined(ANT_STACK_SUPPORT_REQD) +void nrf_dfu_softdevice_invalidate(void) +{ + static const uint32_t all_zero = 0UL; + + if (SD_PRESENT && !NRF_DFU_IN_APP) + { + ret_code_t err_code = nrf_dfu_flash_store(SD_MAGIC_NUMBER_ABS_OFFSET_GET(MBR_SIZE), &all_zero, 4, NULL); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not invalidate SoftDevice.") + } + else + { + // If there is an app it must be invalidated since its start address can no longer be resolved. + if (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_VALID_APP) + { + s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_INVALID; + } + // Since the start of bank 0 has now implicitly been moved to the start + // of the invalidated SoftDevice, its image size must be increased by the + // same amount so the start of bank 1 will be correctly calculated. + s_dfu_settings.bank_0.image_size += SD_SIZE_GET(MBR_SIZE) - MBR_SIZE; + } + } +} +#endif + + +uint32_t nrf_dfu_bank0_start_addr(void) +{ + if (SD_PRESENT) + { + return ALIGN_TO_PAGE(SD_SIZE_GET(MBR_SIZE)); + } + else + { + return MBR_SIZE; + } +} + + +uint32_t nrf_dfu_bank1_start_addr(void) +{ + uint32_t bank0_addr = nrf_dfu_bank0_start_addr(); + return ALIGN_TO_PAGE(bank0_addr + s_dfu_settings.bank_0.image_size); +} + + +uint32_t nrf_dfu_app_start_address(void) +{ + return nrf_dfu_bank0_start_addr(); +} + + +uint32_t nrf_dfu_softdevice_start_address(void) +{ + return MBR_SIZE; +} + + +uint32_t nrf_dfu_cache_prepare(const uint32_t required_size, bool single_bank, bool keep_app, bool keep_softdevice) +{ + ret_code_t err_code; + bool cache_too_small; + enum + { + INITIAL_DELETE_APP = 0, + APP_DELETED_DELETE_SOFTDEVICE = 1, + SOFTDEVICE_DELETED = 2 + } pass; + + NRF_LOG_DEBUG("Enter nrf_dfu_cache_prepare()"); + NRF_LOG_DEBUG("required_size: 0x%x.", required_size); + NRF_LOG_DEBUG("single_bank: %s.", single_bank ? "true" : "false"); + NRF_LOG_DEBUG("keep_app: %s.", keep_app ? "true" : "false"); + NRF_LOG_DEBUG("keep_softdevice: %s.", keep_softdevice ? "true" : "false"); + NRF_LOG_DEBUG("SD_PRESENT: %s.", SD_PRESENT ? "true" : "false"); + NRF_LOG_DEBUG("Bank contents:"); + NRF_LOG_DEBUG("Bank 0 code: 0x%02x: Size: 0x%x", s_dfu_settings.bank_0.bank_code, s_dfu_settings.bank_0.image_size); + NRF_LOG_DEBUG("Bank 1 code: 0x%02x: Size: 0x%x", s_dfu_settings.bank_1.bank_code, s_dfu_settings.bank_1.image_size); + + // Pass 0 deletes the app if necessary or requested, and if so, proceeds to pass 1. + // Pass 1 deletes the SoftDevice if necessary or requested, and if so, proceeds to pass 2. + // Pass 2 does a last size check. + for (pass = INITIAL_DELETE_APP; pass <= SOFTDEVICE_DELETED; pass++) + { + uint32_t cache_address; + const uint32_t bootloader_start_addr = BOOTLOADER_START_ADDR; // Assign to a variable to prevent warning in Keil 4. + bool keep_firmware = true; + bool delete_more; + + switch (pass) + { + case INITIAL_DELETE_APP: + cache_address = nrf_dfu_bank1_start_addr(); + + // If there is no app, keep_app should be assumed false, so we can free up more space. + keep_firmware = keep_app && (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_VALID_APP); + break; + + case APP_DELETED_DELETE_SOFTDEVICE: + cache_address = nrf_dfu_bank0_start_addr(); + + // If there is no SoftDevice, keep_SoftDevice should be assumed true, because there is + // no point to continuing since the SoftDevice is the last firmware that can be deleted. + keep_firmware = keep_softdevice || !SD_PRESENT; + break; + + case SOFTDEVICE_DELETED: + cache_address = nrf_dfu_softdevice_start_address(); + break; + + default: + ASSERT(false); + cache_address = 0; + break; + } + + ASSERT(cache_address <= DFU_REGION_END(bootloader_start_addr)); + cache_too_small = required_size > (DFU_REGION_END(bootloader_start_addr) - cache_address); + delete_more = cache_too_small || single_bank; // Delete app or SoftDevice only if we need more room, or if single bank is requested. + + NRF_LOG_DEBUG("pass: %d.", pass); + NRF_LOG_DEBUG("cache_address: 0x%x.", cache_address); + NRF_LOG_DEBUG("cache_too_small: %s.", cache_too_small ? "true" : "false"); + NRF_LOG_DEBUG("keep_firmware: %s.", keep_firmware ? "true" : "false"); + NRF_LOG_DEBUG("delete_more: %s.", delete_more ? "true" : "false"); + + if (!delete_more || keep_firmware || (pass >= SOFTDEVICE_DELETED)) + { + // Stop, done. + break; + } + } + + if (cache_too_small) + { + NRF_LOG_WARNING("Aborting. Cannot fit new firmware on device"); + err_code = NRF_ERROR_NO_MEM; + } + else + { + // Room was found. Make the necessary preparations for receiving update. + +#if !defined(BLE_STACK_SUPPORT_REQD) && !defined(ANT_STACK_SUPPORT_REQD) + if (pass >= SOFTDEVICE_DELETED) + { + NRF_LOG_DEBUG("Invalidating SoftDevice."); + nrf_dfu_softdevice_invalidate(); + } +#endif + if (pass >= APP_DELETED_DELETE_SOFTDEVICE) + { + NRF_LOG_DEBUG("Invalidating app."); + nrf_dfu_bank_invalidate(&s_dfu_settings.bank_0); + } + + err_code = NRF_SUCCESS; + } + + return err_code; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.h new file mode 100644 index 0000000..5e8d7e8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_utils.h @@ -0,0 +1,154 @@ +/** + * Copyright (c) 2016 - 2019, 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 sdk_nrf_dfu_utils DFU utilities + * @{ + * @ingroup nrf_dfu + */ + +#ifndef NRF_DFU_UTILS_H__ +#define NRF_DFU_UTILS_H__ + +#include +#include +#include "nrf_dfu_types.h" +#include "app_util.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * Round up val to the next page boundary + */ +#define ALIGN_TO_PAGE(val) ALIGN_NUM((CODE_PAGE_SIZE), (val)) + + +/** @brief Function for getting the start address of bank 0. + * + * @note Bank 0 starts after the SoftDevice if a SoftDevice is present. + * + * @return The start address of bank 0. + */ +uint32_t nrf_dfu_bank0_start_addr(void); + + +/** @brief Function for getting the start address of bank 1. + * + * @return The start address of bank 1. + */ +uint32_t nrf_dfu_bank1_start_addr(void); + + +/** @brief Function for getting the start address of the app. + * + * @return The start address of the bootable app. + */ +uint32_t nrf_dfu_app_start_address(void); + + +/** @brief Function for getting the start address of the SoftDevice. + * + * @return The start address of the SoftDevivce. + */ +uint32_t nrf_dfu_softdevice_start_address(void); + + +/** @brief Function for finding and preparing a place in flash in which to store a DFU update. + * + * @details This function checks the size requirements and selects a location for + * placing the cache of the DFU images. + * The function tries to find enough space after the existing firmwares. If there is not + * enough space, the present application is deleted. If there is still not enough space, + * the SoftDevice is deleted. + * If @p single_bank is true, the default behavior is to immediately delete the app and + * SoftDevice as necessary to place the new firmware at its intended location. If the + * intended location cannot be made available, or if the update is a bootloader update, + * the update will be a dual bank update, and nothing will be deleted by this function + * except when needed for size. + * If @p keep_app is true, the app is never deleted by this function. Likewise if @p + * keep_softdevice is true, the SoftDevice is never deleted by this function. + * If the new firmware cannot fit within the constraints, nothing is deleted and the + * function fails. + * + * @param[in] required_size Requirements for the size of the new image. + * @param[in] single_bank Whether to put the firmware directly where it's meant to go. + * @p keep_app and @p keep_softdevice take precedence over this. + * @param[in] keep_app True to ensure the app is not deleted by this function. This + * effectively enforces dual bank update. + * @param[out] keep_softdevice True to ensure the SoftDevice is not deleted by this function. + * + * @retval NRF_SUCCESS If a cache location was found for the DFU process. + * @retval NRF_ERROR_NO_MEM If there is not enough space available to receive the update. + * Nothing has been deleted. + */ +uint32_t nrf_dfu_cache_prepare(uint32_t required_size, bool single_bank, bool keep_app, bool keep_softdevice); + + +/**@brief Function for making sure a SoftDevice is not recognized as such anymore. + * + * @details It works by overwriting the magic number of the SoftDevice with 0s. The + * magic number is used throughout the bootloader to detect whether a SoftDevice + * is present. + * + * @warning This function should only be called when both banks are already invalid. + * because the (implicit) position of the banks will shift when the SoftDevice + * is invalidated. + */ +void nrf_dfu_softdevice_invalidate(void); + + +/**@brief Function for making sure a bank is not copied or booted. + * + * @details This also sets the size of the bank to 0. + * + * @param[in] p_bank Pointer to the bank to be invalidated. + */ +void nrf_dfu_bank_invalidate(nrf_dfu_bank_t * const p_bank); + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DFU_UTILS_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.c new file mode 100644 index 0000000..a72ebf2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.c @@ -0,0 +1,1095 @@ +/** + * Copyright (c) 2017 - 2019, 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 +#include "nrf_dfu_types.h" +#include "nrf_dfu_settings.h" +#include "nrf_dfu_utils.h" +#include "nrf_dfu_flash.h" +#include "nrf_bootloader_info.h" +#include "pb.h" +#include "pb_common.h" +#include "pb_decode.h" +#include "dfu-cc.pb.h" +#include "crc32.h" +#include "nrf_crypto.h" +#include "nrf_crypto_shared.h" +#include "nrf_assert.h" +#include "nrf_dfu_validation.h" +#include "nrf_dfu_ver_validation.h" +#include "nrf_strerror.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_validation +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +NRF_LOG_MODULE_REGISTER(); + +#ifndef DFU_REQUIRES_SOFTDEVICE +#if !defined(BLE_STACK_SUPPORT_REQD) && !defined(ANT_STACK_SUPPORT_REQD) +#define DFU_REQUIRES_SOFTDEVICE 0 +#else +#define DFU_REQUIRES_SOFTDEVICE 1 +#endif +#endif + +#define EXT_ERR(err) (nrf_dfu_result_t)((uint32_t)NRF_DFU_RES_CODE_EXT_ERROR + (uint32_t)err) + +/* Whether a complete init command has been received and prevalidated, but the firmware + * is not yet fully transferred. This value will also be correct after reset. + */ +static bool m_valid_init_cmd_present = false; +static dfu_packet_t m_packet = DFU_PACKET_INIT_DEFAULT; +static uint8_t* m_init_packet_data_ptr = 0; +static uint32_t m_init_packet_data_len = 0; +static pb_istream_t m_pb_stream; + +static dfu_init_command_t const * mp_init = NULL; + +__ALIGN(4) extern const uint8_t pk[64]; + +/** @brief Value length structure holding the public key. + * + * @details The pk value pointed to is the public key present in dfu_public_key.c + */ +static nrf_crypto_ecc_public_key_t m_public_key; + +/** @brief Structure to hold a signature + */ +static nrf_crypto_ecdsa_secp256r1_signature_t m_signature; + +/** @brief Structure to hold the hash for signature verification + */ +static nrf_crypto_hash_sha256_digest_t m_sig_hash; + +/** @brief Structure to hold the hash for the firmware image + */ +static nrf_crypto_hash_sha256_digest_t m_fw_hash; + +/** @brief Whether nrf_crypto and local keys have been initialized. + */ +static bool m_crypto_initialized = false; + +/** @brief Flag used by parser code to indicate that the init command has been found to be invalid. + */ +static bool m_init_packet_valid = false; + +static void pb_decoding_callback(pb_istream_t *str, + uint32_t tag, + pb_wire_type_t wire_type, + void *iter) +{ + pb_field_iter_t* p_iter = (pb_field_iter_t *) iter; + + // Match the beginning of the init command. + if (p_iter->pos->ptr == &dfu_init_command_fields[0]) + { + uint8_t * ptr = (uint8_t *)str->state; + uint32_t size = str->bytes_left; + + if (m_init_packet_data_ptr != NULL || m_init_packet_data_len != 0) + { + m_init_packet_valid = false; + return; + } + + // Remove tag. + while (*ptr & 0x80) + { + ptr++; + size--; + } + ptr++; + size--; + + // Store the info in init_packet_data. + m_init_packet_data_ptr = ptr; + m_init_packet_data_len = size; + m_init_packet_valid = true; + + NRF_LOG_DEBUG("PB: Init packet data len: %d", size); + } +} + +/** @brief Function for decoding byte stream into variable. + * + * @retval true If the stored init command was successfully decoded. + * @retval false If there was no stored init command, or the decoding failed. + */ +static bool stored_init_cmd_decode(void) +{ + m_pb_stream = pb_istream_from_buffer(s_dfu_settings.init_command, + s_dfu_settings.progress.command_size); + + dfu_init_command_t * p_init; + + // Attach our callback to follow the field decoding. + m_pb_stream.decoding_callback = pb_decoding_callback; + + m_init_packet_valid = false; + m_init_packet_data_ptr = NULL; + m_init_packet_data_len = 0; + memset(&m_packet, 0, sizeof(m_packet)); + + if (!pb_decode(&m_pb_stream, dfu_packet_fields, &m_packet)) + { + NRF_LOG_ERROR("Handler: Invalid protocol buffer m_pb_stream"); + return false; + } + + if (!m_init_packet_valid || (m_packet.has_signed_command && m_packet.has_command)) + { + NRF_LOG_ERROR("Handler: Invalid init command."); + return false; + } + else if (m_packet.has_signed_command && m_packet.signed_command.command.has_init) + { + p_init = &m_packet.signed_command.command.init; + + m_pb_stream = pb_istream_from_buffer(m_init_packet_data_ptr, m_init_packet_data_len); + memset(p_init, 0, sizeof(dfu_init_command_t)); + + if (!pb_decode(&m_pb_stream, dfu_init_command_fields, p_init)) + { + NRF_LOG_ERROR("Handler: Invalid protocol buffer m_pb_stream (init command)"); + return false; + } + } + else if (m_packet.has_command && m_packet.command.has_init) + { + p_init = &m_packet.command.init; + } + else + { + return false; + } + + mp_init = p_init; + + return true; +} + + +static void crypto_init(void) +{ + ret_code_t err_code; + uint8_t pk_copy[sizeof(pk)]; + + if (m_crypto_initialized) + { + return; + } + + err_code = nrf_crypto_init(); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_PARAMETER(err_code); + + // Convert public key to big-endian format for use in nrf_crypto. + nrf_crypto_internal_double_swap_endian(pk_copy, pk, sizeof(pk) / 2); + + err_code = nrf_crypto_ecc_public_key_from_raw(&g_nrf_crypto_ecc_secp256r1_curve_info, + &m_public_key, + pk_copy, + sizeof(pk)); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_PARAMETER(err_code); + + m_crypto_initialized = true; +} + + +void nrf_dfu_validation_init(void) +{ + // If the command is stored to flash, init command was valid. + if ((s_dfu_settings.progress.command_size != 0) && + stored_init_cmd_decode()) + { + m_valid_init_cmd_present = true; + } + else + { + m_valid_init_cmd_present = false; + } +} + + +static void dfu_progress_reset(void) +{ + memset(s_dfu_settings.init_command, 0xFF, INIT_COMMAND_MAX_SIZE); // Remove the last init command + memset(&s_dfu_settings.progress, 0, sizeof(dfu_progress_t)); + s_dfu_settings.write_offset = 0; +} + + +nrf_dfu_result_t nrf_dfu_validation_init_cmd_create(uint32_t size) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + if (size == 0) + { + ret_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; + } + else if (size > INIT_COMMAND_MAX_SIZE) + { + ret_val = NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES; + } + else + { + // Set DFU to uninitialized. + m_valid_init_cmd_present = false; + + // Reset all progress. + dfu_progress_reset(); + + // Set the init command size. + s_dfu_settings.progress.command_size = size; + } + return ret_val; +} + + +nrf_dfu_result_t nrf_dfu_validation_init_cmd_append(uint8_t const * p_data, uint32_t length) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + if ((length + s_dfu_settings.progress.command_offset) > s_dfu_settings.progress.command_size) + { + NRF_LOG_ERROR("Init command larger than expected."); + ret_val = NRF_DFU_RES_CODE_INVALID_PARAMETER; + } + else + { + // Copy the received data to RAM, update offset and calculate CRC. + memcpy(&s_dfu_settings.init_command[s_dfu_settings.progress.command_offset], + p_data, + length); + + s_dfu_settings.progress.command_offset += length; + s_dfu_settings.progress.command_crc = crc32_compute(p_data, + length, + &s_dfu_settings.progress.command_crc); + } + return ret_val; +} + + +void nrf_dfu_validation_init_cmd_status_get(uint32_t * p_offset, + uint32_t * p_crc, + uint32_t * p_max_size) +{ + *p_offset = s_dfu_settings.progress.command_offset; + *p_crc = s_dfu_settings.progress.command_crc; + *p_max_size = INIT_COMMAND_MAX_SIZE; +} + + +bool nrf_dfu_validation_init_cmd_present(void) +{ + return m_valid_init_cmd_present; +} + + +// Function determines if init command signature is obligatory. +static bool signature_required(dfu_fw_type_t fw_type_to_be_updated) +{ + bool result = true; + + // DFU_FW_TYPE_EXTERNAL_APPLICATION and bootloader updates always require + // signature check + if ((!DFU_REQUIRES_SOFTDEVICE && (fw_type_to_be_updated == DFU_FW_TYPE_SOFTDEVICE)) || + (fw_type_to_be_updated == DFU_FW_TYPE_APPLICATION)) + { + result = NRF_DFU_REQUIRE_SIGNED_APP_UPDATE; + } + return result; +} + + +// Function to perform signature check if required. +static nrf_dfu_result_t nrf_dfu_validation_signature_check(dfu_signature_type_t signature_type, + uint8_t const * p_signature, + uint32_t signature_len, + uint8_t const * p_data, + uint32_t data_len) +{ + ret_code_t err_code; + size_t hash_len = NRF_CRYPTO_HASH_SIZE_SHA256; + + nrf_crypto_hash_context_t hash_context = {0}; + nrf_crypto_ecdsa_verify_context_t verify_context = {0}; + + crypto_init(); + + NRF_LOG_INFO("Signature required. Checking signature.") + if (p_signature == NULL) + { + NRF_LOG_WARNING("No signature found."); + return EXT_ERR(NRF_DFU_EXT_ERROR_SIGNATURE_MISSING); + } + + if (signature_type != DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256) + { + NRF_LOG_INFO("Invalid signature type"); + return EXT_ERR(NRF_DFU_EXT_ERROR_WRONG_SIGNATURE_TYPE); + } + + NRF_LOG_INFO("Calculating hash (len: %d)", data_len); + err_code = nrf_crypto_hash_calculate(&hash_context, + &g_nrf_crypto_hash_sha256_info, + p_data, + data_len, + m_sig_hash, + &hash_len); + if (err_code != NRF_SUCCESS) + { + return NRF_DFU_RES_CODE_OPERATION_FAILED; + } + + if (sizeof(m_signature) != signature_len) + { + return NRF_DFU_RES_CODE_OPERATION_FAILED; + } + + // Prepare the signature received over the air. + memcpy(m_signature, p_signature, signature_len); + + // Calculate the signature. + NRF_LOG_INFO("Verify signature"); + + // The signature is in little-endian format. Change it to big-endian format for nrf_crypto use. + nrf_crypto_internal_double_swap_endian_in_place(m_signature, sizeof(m_signature) / 2); + + err_code = nrf_crypto_ecdsa_verify(&verify_context, + &m_public_key, + m_sig_hash, + hash_len, + m_signature, + sizeof(m_signature)); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Signature failed (err_code: 0x%x)", err_code); + NRF_LOG_DEBUG("Signature:"); + NRF_LOG_HEXDUMP_DEBUG(m_signature, sizeof(m_signature)); + NRF_LOG_DEBUG("Hash:"); + NRF_LOG_HEXDUMP_DEBUG(m_sig_hash, hash_len); + NRF_LOG_DEBUG("Public Key:"); + NRF_LOG_HEXDUMP_DEBUG(pk, sizeof(pk)); + NRF_LOG_FLUSH(); + + return NRF_DFU_RES_CODE_INVALID_OBJECT; + } + + NRF_LOG_INFO("Image verified"); + return NRF_DFU_RES_CODE_SUCCESS; +} + + +// Function to calculate the total size of the firmware(s) in the update. +static nrf_dfu_result_t update_data_size_get(dfu_init_command_t const * p_init, uint32_t * p_size) +{ + nrf_dfu_result_t ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID); + uint32_t fw_sz = 0; + + if ((p_init->type == DFU_FW_TYPE_APPLICATION || + p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION) && + (p_init->has_app_size == true)) + { + fw_sz = p_init->app_size; + } + else + { + if ((p_init->type & DFU_FW_TYPE_SOFTDEVICE) && (p_init->has_sd_size == true)) + { + fw_sz = p_init->sd_size; + } + + if ((p_init->type & DFU_FW_TYPE_BOOTLOADER) && (p_init->has_bl_size == true)) + { + if (p_init->bl_size <= BOOTLOADER_SIZE) + { + fw_sz += p_init->bl_size; + } + else + { + NRF_LOG_ERROR("BL size (%d) over limit (%d)", p_init->bl_size, BOOTLOADER_SIZE); + fw_sz = 0; + ret_val = NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES; + } + } + } + + if (fw_sz) + { + *p_size = fw_sz; + ret_val = NRF_DFU_RES_CODE_SUCCESS; + } + else + { + NRF_LOG_ERROR("Init packet does not contain valid firmware size"); + } + + return ret_val; +} + + +/** + * @brief Function to check if single bank update should be used. + * + * @param new_fw_type Firmware type. + */ +static bool use_single_bank(dfu_fw_type_t new_fw_type) +{ + bool result = false; + + // DFU_FW_TYPE_EXTERNAL_APPLICATION never uses single bank + if (((new_fw_type == DFU_FW_TYPE_APPLICATION) || + (new_fw_type == DFU_FW_TYPE_SOFTDEVICE)) && + NRF_DFU_SINGLE_BANK_APP_UPDATES) + { + result = true; + } + + return result; +} + + +// Function to determine whether the new firmware needs a SoftDevice to be present. +static bool update_requires_softdevice(dfu_init_command_t const * p_init) +{ + return ((p_init->sd_req_count > 0) && (p_init->sd_req[0] != SD_REQ_APP_OVERWRITES_SD)); +} + + +// Function to determine whether the SoftDevice can be removed during the update or not. +static bool keep_softdevice(dfu_init_command_t const * p_init) +{ + UNUSED_PARAMETER(p_init); // It's unused when DFU_REQUIRES_SOFTDEVICE is true. + return DFU_REQUIRES_SOFTDEVICE || update_requires_softdevice(p_init); +} + + +/**@brief Function to determine where to temporarily store the incoming firmware. + * This also checks whether the update will fit, and deletes existing + * firmware to make room for the new firmware. + * + * @param[in] p_init Init command. + * @param[in] fw_size The size of the incoming firmware. + * @param[out] p_addr The address at which to initially store the firmware. + * + * @retval NRF_DFU_RES_CODE_SUCCESS If the size check passed and + * an address was found. + * @retval NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES If the size check failed. + */ +static nrf_dfu_result_t update_data_addr_get(dfu_init_command_t const * p_init, + uint32_t fw_size, + uint32_t * p_addr) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + ret_code_t err_code = nrf_dfu_cache_prepare(fw_size, + use_single_bank(p_init->type), + NRF_DFU_FORCE_DUAL_BANK_APP_UPDATES, + keep_softdevice(p_init)); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Can't find room for update"); + ret_val = NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES; + } + else + { + *p_addr = nrf_dfu_bank1_start_addr(); + NRF_LOG_DEBUG("Write address set to 0x%08x", *p_addr); + } + return ret_val; +} + + +nrf_dfu_result_t nrf_dfu_validation_prevalidate(void) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + dfu_command_t const * p_command = &m_packet.command; + dfu_signature_type_t signature_type = DFU_SIGNATURE_TYPE_MIN; + uint8_t const * p_signature = NULL; + uint32_t signature_len = 0; + + if (m_packet.has_signed_command) + { + p_command = &m_packet.signed_command.command; + signature_type = m_packet.signed_command.signature_type; + p_signature = m_packet.signed_command.signature.bytes; + signature_len = m_packet.signed_command.signature.size; + } + + // Validate signature. + if (signature_required(p_command->init.type)) + { + ret_val = nrf_dfu_validation_signature_check(signature_type, + p_signature, + signature_len, + m_init_packet_data_ptr, + m_init_packet_data_len); + } + + // Validate versions. + if (ret_val == NRF_DFU_RES_CODE_SUCCESS) + { + ret_val = nrf_dfu_ver_validation_check(&p_command->init); + } + + if (ret_val != NRF_DFU_RES_CODE_SUCCESS) + { + NRF_LOG_WARNING("Prevalidation failed."); + NRF_LOG_DEBUG("Init command:"); + NRF_LOG_HEXDUMP_DEBUG(m_init_packet_data_ptr, m_init_packet_data_len); + } + + return ret_val; +} + + +nrf_dfu_result_t nrf_dfu_validation_init_cmd_execute(uint32_t * p_dst_data_addr, + uint32_t * p_data_len) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + + if (s_dfu_settings.progress.command_offset != s_dfu_settings.progress.command_size) + { + // The object wasn't the right (requested) size. + NRF_LOG_ERROR("Execute with faulty offset"); + ret_val = NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED; + } + else if (m_valid_init_cmd_present) + { + *p_dst_data_addr = nrf_dfu_bank1_start_addr(); + ret_val = update_data_size_get(mp_init, p_data_len); + } + else if (stored_init_cmd_decode()) + { + // Will only get here if init command was received since last reset. + // An init command should not be written to flash until after it's been checked here. + ret_val = nrf_dfu_validation_prevalidate(); + + *p_dst_data_addr = 0; + *p_data_len = 0; + + // Get size of binary. + if (ret_val == NRF_DFU_RES_CODE_SUCCESS) + { + ret_val = update_data_size_get(mp_init, p_data_len); + } + + // Get address where to flash the binary. + if (ret_val == NRF_DFU_RES_CODE_SUCCESS) + { + ret_val = update_data_addr_get(mp_init, *p_data_len, p_dst_data_addr); + } + + // Set flag validating the init command. + if (ret_val == NRF_DFU_RES_CODE_SUCCESS) + { + m_valid_init_cmd_present = true; + } + else + { + dfu_progress_reset(); + } + } + else + { + NRF_LOG_ERROR("Failed to decode init packet"); + ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT; + } + + return ret_val; +} + + +// Function to check the hash received in the init command against the received firmware. +// little_endian specifies the endianness of @p p_hash. +static bool nrf_dfu_validation_hash_ok(uint8_t const * p_hash, uint32_t src_addr, uint32_t data_len, bool little_endian) +{ + ret_code_t err_code; + bool result = true; + uint8_t hash_be[NRF_CRYPTO_HASH_SIZE_SHA256]; + size_t hash_len = NRF_CRYPTO_HASH_SIZE_SHA256; + + nrf_crypto_hash_context_t hash_context = {0}; + + crypto_init(); + + if (little_endian) + { + // Convert to hash to big-endian format for use in nrf_crypto. + nrf_crypto_internal_swap_endian(hash_be, + p_hash, + NRF_CRYPTO_HASH_SIZE_SHA256); + p_hash = hash_be; + } + + NRF_LOG_DEBUG("Hash verification. start address: 0x%x, size: 0x%x", + src_addr, + data_len); + + err_code = nrf_crypto_hash_calculate(&hash_context, + &g_nrf_crypto_hash_sha256_info, + (uint8_t*)src_addr, + data_len, + m_fw_hash, + &hash_len); + + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not run hash verification (err_code 0x%x).", err_code); + result = false; + } + else if (memcmp(m_fw_hash, p_hash, NRF_CRYPTO_HASH_SIZE_SHA256) != 0) + { + NRF_LOG_WARNING("Hash verification failed."); + NRF_LOG_DEBUG("Expected FW hash:") + NRF_LOG_HEXDUMP_DEBUG(p_hash, NRF_CRYPTO_HASH_SIZE_SHA256); + NRF_LOG_DEBUG("Actual FW hash:") + NRF_LOG_HEXDUMP_DEBUG(m_fw_hash, NRF_CRYPTO_HASH_SIZE_SHA256); + NRF_LOG_FLUSH(); + + result = false; + } + + return result; +} + + +// Function to check the hash received in the init command against the received firmware. +bool fw_hash_ok(dfu_init_command_t const * p_init, uint32_t fw_start_addr, uint32_t fw_size) +{ + ASSERT(p_init != NULL); + return nrf_dfu_validation_hash_ok((uint8_t *)p_init->hash.hash.bytes, fw_start_addr, fw_size, true); +} + + +// Function to check whether the update contains a SoftDevice and, if so, if it is of a different +// major version than the existing SoftDevice. +static bool is_major_softdevice_update(uint32_t new_sd_addr) +{ + // True if there is no SD right now, but there is a new one coming. This counts as a major update. + bool result = !SD_PRESENT && (SD_MAGIC_NUMBER_GET(new_sd_addr) == SD_MAGIC_NUMBER); + + if (SD_PRESENT && (SD_MAGIC_NUMBER_GET(new_sd_addr) == SD_MAGIC_NUMBER)) + { + // Both SoftDevices are present. + uint32_t current_SD_major = SD_MAJOR_VERSION_EXTRACT(SD_VERSION_GET(MBR_SIZE)); + uint32_t new_SD_major = SD_MAJOR_VERSION_EXTRACT(SD_VERSION_GET(new_sd_addr)); + + result = (current_SD_major != new_SD_major); + + NRF_LOG_INFO("SoftDevice update is a %s version update. Current: %d. New: %d.", + result ? "major" : "minor", + current_SD_major, + new_SD_major); + } + + return result; +} + + +/**@brief Validate the SoftDevice size and magic number in structure found at 0x2000 in received SoftDevice. + * + * @param[in] sd_start_addr Start address of received SoftDevice. + * @param[in] sd_size Size of received SoftDevice in bytes. + */ +static bool softdevice_info_ok(uint32_t sd_start_addr, uint32_t sd_size) +{ + bool result = true; + + if (SD_MAGIC_NUMBER_GET(sd_start_addr) != SD_MAGIC_NUMBER) + { + NRF_LOG_ERROR("The SoftDevice does not contain the magic number identifying it as a SoftDevice."); + result = false; + } + else if (SD_SIZE_GET(sd_start_addr) < ALIGN_TO_PAGE(sd_size + MBR_SIZE)) + { + // The size in the info struct should be rounded up to a page boundary + // and be larger than the actual size + the size of the MBR. + NRF_LOG_ERROR("The SoftDevice size in the info struct is too small compared with the size reported in the init command."); + result = false; + } + else if (SD_PRESENT && (SD_ID_GET(MBR_SIZE) != SD_ID_GET(sd_start_addr))) + { + NRF_LOG_ERROR("The new SoftDevice is of a different family than the present SoftDevice. Compatibility cannot be guaranteed."); + result = false; + } + + return result; +} + + +static bool boot_validation_extract(boot_validation_t * p_boot_validation, + dfu_init_command_t const * p_init, + uint32_t index, + uint32_t start_addr, + uint32_t data_len, + boot_validation_type_t default_type) +{ + ret_code_t err_code; + size_t hash_len = NRF_CRYPTO_HASH_SIZE_SHA256; + + nrf_crypto_hash_context_t hash_context = {0}; + + memset(p_boot_validation, 0, sizeof(boot_validation_t)); + p_boot_validation->type = (p_init->boot_validation_count > index) + ? (boot_validation_type_t)p_init->boot_validation[index].type + : default_type; // default + + switch(p_boot_validation->type) + { + case NO_VALIDATION: + break; + + case VALIDATE_CRC: + *(uint32_t *)&p_boot_validation->bytes[0] = crc32_compute((uint8_t *)start_addr, data_len, NULL); + break; + + case VALIDATE_SHA256: + err_code = nrf_crypto_hash_calculate(&hash_context, + &g_nrf_crypto_hash_sha256_info, + (uint8_t*)start_addr, + data_len, + p_boot_validation->bytes, + &hash_len); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("nrf_crypto_hash_calculate() failed with error %s", nrf_strerror_get(err_code)); + return false; + } + break; + + case VALIDATE_ECDSA_P256_SHA256: + memcpy(p_boot_validation->bytes, p_init->boot_validation[index].bytes.bytes, p_init->boot_validation[index].bytes.size); + break; + + default: + NRF_LOG_ERROR("Invalid boot validation type: %d", p_boot_validation->type); + return false; + } + + return nrf_dfu_validation_boot_validate(p_boot_validation, start_addr, data_len); +} + + +// The is_trusted argument specifies whether the function should have side effects. +static bool postvalidate_app(dfu_init_command_t const * p_init, uint32_t src_addr, uint32_t data_len, bool is_trusted) +{ + boot_validation_t boot_validation; + + ASSERT(p_init->type == DFU_FW_TYPE_APPLICATION); + + if (!boot_validation_extract(&boot_validation, p_init, 0, src_addr, data_len, VALIDATE_CRC)) + { + return false; + } +#if !NRF_DFU_IN_APP + else if (NRF_BL_APP_SIGNATURE_CHECK_REQUIRED && + (boot_validation.type != VALIDATE_ECDSA_P256_SHA256)) + { + NRF_LOG_WARNING("The boot validation of the app must be a signature check."); + return false; + } +#endif + + if (!is_trusted) + { + return true; + } + + memcpy(&s_dfu_settings.boot_validation_app, &boot_validation, sizeof(boot_validation)); + + s_dfu_settings.bank_1.bank_code = NRF_DFU_BANK_VALID_APP; + + NRF_LOG_DEBUG("Invalidating old application in bank 0."); + s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_INVALID; + + if (!DFU_REQUIRES_SOFTDEVICE && !update_requires_softdevice(p_init)) + { + // App does not need SD, so it should be placed where SD is. + nrf_dfu_softdevice_invalidate(); + } + + if (!NRF_DFU_DEBUG || + (NRF_DFU_DEBUG && (p_init->has_is_debug == false || p_init->is_debug == false))) + { + s_dfu_settings.app_version = p_init->fw_version; + } + + return true; +} + + +// Function to check a received SoftDevice or Bootloader firmware, or both, +// before it is copied into place. +// The is_trusted argument specifies whether the function should have side effects. +static bool postvalidate_sd_bl(dfu_init_command_t const * p_init, + bool with_sd, + bool with_bl, + uint32_t start_addr, + uint32_t data_len, + bool is_trusted) +{ + boot_validation_t boot_validation_sd = {NO_VALIDATION}; + boot_validation_t boot_validation_bl = {NO_VALIDATION}; + uint32_t bl_start = start_addr; + uint32_t bl_size = data_len; + + ASSERT(with_sd || with_bl); + + if (with_sd) + { + if (!softdevice_info_ok(start_addr, p_init->sd_size)) + { + return false; + } + + if (is_major_softdevice_update(start_addr)) + { + NRF_LOG_WARNING("Invalidating app because it is incompatible with the SoftDevice."); + if (DFU_REQUIRES_SOFTDEVICE && !with_bl) + { + NRF_LOG_ERROR("Major SD update but no BL. Abort to avoid incapacitating the BL."); + return false; + } + } + + if (!boot_validation_extract(&boot_validation_sd, p_init, 0, start_addr, p_init->sd_size, VALIDATE_CRC)) + { + return false; + } + + bl_start += p_init->sd_size; + bl_size -= p_init->sd_size; + } + if (with_bl) + { + if (!boot_validation_extract(&boot_validation_bl, p_init, 0, bl_start, bl_size, NO_VALIDATION)) + { + return false; + } + else if (boot_validation_bl.type != NO_VALIDATION) + { + NRF_LOG_WARNING("Boot validation of bootloader is not supported and will be ignored."); + } + } + + if (!is_trusted) + { + return true; + } + + if (with_sd) + { + if (is_major_softdevice_update(start_addr)) + { + // Invalidate app since it may not be compatible with new SD. + nrf_dfu_bank_invalidate(&s_dfu_settings.bank_0); + } + + memcpy(&s_dfu_settings.boot_validation_softdevice, &boot_validation_sd, sizeof(boot_validation_sd)); + + // Mark the update as valid. + s_dfu_settings.bank_1.bank_code = with_bl ? NRF_DFU_BANK_VALID_SD_BL + : NRF_DFU_BANK_VALID_SD; + + s_dfu_settings.sd_size = p_init->sd_size; + } + else + { + s_dfu_settings.bank_1.bank_code = NRF_DFU_BANK_VALID_BL; + } + + + if (with_bl) + { + memcpy(&s_dfu_settings.boot_validation_bootloader, &boot_validation_bl, sizeof(boot_validation_bl)); + + if (!NRF_DFU_DEBUG || + (NRF_DFU_DEBUG && (p_init->has_is_debug == false || p_init->is_debug == false))) + { + // If the update contains a bootloader, update the version. + // Unless the update is a debug packet. + s_dfu_settings.bootloader_version = p_init->fw_version; + } + } + + return true; +} + + +bool nrf_dfu_validation_boot_validate(boot_validation_t const * p_validation, uint32_t data_addr, uint32_t data_len) +{ + uint8_t const * p_data = (uint8_t*) data_addr; + switch(p_validation->type) + { + case NO_VALIDATION: + return true; + + case VALIDATE_CRC: + { + uint32_t current_crc = *(uint32_t *)p_validation->bytes; + uint32_t crc = crc32_compute(p_data, data_len, NULL); + + if (crc != current_crc) + { + // CRC does not match with what is stored. + NRF_LOG_DEBUG("CRC check of app failed. Return %d", NRF_DFU_DEBUG); + return NRF_DFU_DEBUG; + } + return true; + } + + case VALIDATE_SHA256: + return nrf_dfu_validation_hash_ok(p_validation->bytes, data_addr, data_len, false); + + case VALIDATE_ECDSA_P256_SHA256: + { + nrf_dfu_result_t res_code = nrf_dfu_validation_signature_check( + DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256, + p_validation->bytes, + NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE, + p_data, + data_len); + return (res_code == NRF_DFU_RES_CODE_SUCCESS); + } + + default: + ASSERT(false); + return false; + } +} + + +nrf_dfu_result_t postvalidate(uint32_t data_addr, uint32_t data_len, bool is_trusted) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + dfu_init_command_t const * p_init = mp_init; + + if (!fw_hash_ok(p_init, data_addr, data_len)) + { + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_VERIFICATION_FAILED); + } + else + { + if (p_init->type == DFU_FW_TYPE_APPLICATION) + { + if (!postvalidate_app(p_init, data_addr, data_len, is_trusted)) + { + ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT; + } + } +#if NRF_DFU_SUPPORTS_EXTERNAL_APP + else if (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION) + { + if (!is_trusted) + { + // This function must be implemented externally + ret_val = nrf_dfu_validation_post_external_app_execute(p_init, is_trusted); + } + else + { + s_dfu_settings.bank_1.bank_code = NRF_DFU_BANK_VALID_EXT_APP; + } + } +#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP + else + { + bool with_sd = p_init->type & DFU_FW_TYPE_SOFTDEVICE; + bool with_bl = p_init->type & DFU_FW_TYPE_BOOTLOADER; + + if (!postvalidate_sd_bl(p_init, with_sd, with_bl, data_addr, data_len, is_trusted)) + { + ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT; + if (is_trusted && with_sd && !DFU_REQUIRES_SOFTDEVICE && + (data_addr == nrf_dfu_softdevice_start_address())) + { + nrf_dfu_softdevice_invalidate(); + } + } + } + } + + if (!is_trusted) + { + if (ret_val == NRF_DFU_RES_CODE_SUCCESS) + { + s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_1; + } + else + { + dfu_progress_reset(); + } + } + else + { + if (ret_val == NRF_DFU_RES_CODE_SUCCESS) + { + // Mark the update as complete and valid. + s_dfu_settings.bank_1.image_crc = crc32_compute((uint8_t *)data_addr, data_len, NULL); + s_dfu_settings.bank_1.image_size = data_len; + } + else + { + nrf_dfu_bank_invalidate(&s_dfu_settings.bank_1); + } + + dfu_progress_reset(); + s_dfu_settings.progress.update_start_address = data_addr; + } + + return ret_val; +} + + +nrf_dfu_result_t nrf_dfu_validation_post_data_execute(uint32_t data_addr, uint32_t data_len) +{ + return postvalidate(data_addr, data_len, false); +} + + +nrf_dfu_result_t nrf_dfu_validation_activation_prepare(uint32_t data_addr, uint32_t data_len) +{ + return postvalidate(data_addr, data_len, true); +} + + +bool nrf_dfu_validation_valid_external_app(void) +{ + return s_dfu_settings.bank_1.bank_code == NRF_DFU_BANK_VALID_EXT_APP; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.h new file mode 100644 index 0000000..dd861ad --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_validation.h @@ -0,0 +1,199 @@ +/** + * Copyright (c) 2017 - 2019, 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 nrf_dfu_validation Validation + * @{ + * @ingroup nrf_dfu + */ + +#ifndef __NRF_DFU_VALIDATION_H +#define __NRF_DFU_VALIDATION_H + +#include "stdint.h" +#include "sdk_errors.h" +#include "dfu-cc.pb.h" +#include "nrf_dfu_handling_error.h" + +/** + * @brief Function for module initialization. + * + * Function checks if there is a valid init packet in DFU settings written in flash. + */ +void nrf_dfu_validation_init(void); + +/** + * @brief Function called on reception of init command creation request. + * + * @param[in] size Size of incoming init packet. + * + * @return Operation result. See @ref nrf_dfu_result_t + */ +nrf_dfu_result_t nrf_dfu_validation_init_cmd_create(uint32_t size); + +/** + * @brief Function called on reception of fragment of init command. + * + * @param[in] p_data Init command fragment. + * @param[in] length Init command fragment size. + * + * @return Operation result. See @ref nrf_dfu_result_t + */ +nrf_dfu_result_t nrf_dfu_validation_init_cmd_append(uint8_t const * p_data, uint32_t length); + +/** + * @brief Function for getting init command status. + * + * @param[out] p_offset Current offset. + * @param[out] p_crc Current CRC. + * @param[out] p_max_size Maximum size of init command. + */ +void nrf_dfu_validation_init_cmd_status_get(uint32_t * p_offset, + uint32_t * p_crc, + uint32_t * p_max_size); + +/** + * @brief Function for inquiring whether a valid init command has been received. + * + * @return true if there is a valid init command. This can be true at boot time + * if the device was reset during a DFU operation. + */ +bool nrf_dfu_validation_init_cmd_present(void); + +/** + * @brief Function for validating init command and retrieving the address and length of the firmware. + * + * If init command is successfully validated Bank 1 details are written to out parameters. + * + * Until @ref nrf_dfu_validation_init_cmd_create is called, this function can be called + * again after the first time without side effects to retrieve address and length. + * + * @param[out] p_dst_data_addr Start address of received data, if validation is successful. + * @param[out] p_data_len Expected length of received data, if validation is successful. + * + * @return Operation result. See @ref nrf_dfu_result_t + */ +nrf_dfu_result_t nrf_dfu_validation_init_cmd_execute(uint32_t * p_dst_data_addr, + uint32_t * p_data_len); + +/** + * @brief Function for validating the init command. + * + * @return Operation result. See @ref nrf_dfu_result_t. + */ +nrf_dfu_result_t nrf_dfu_validation_prevalidate(void); + +/** + * @brief Function for validating the firmware for booting. + * + * @param[in] p_validation Validation parameters. + * @param[in] data_addr Start address of the firmware. + * @param[in] data_len Length of the firmware. + * + * @return Whether the firmware is valid for booting. + */ +bool nrf_dfu_validation_boot_validate(boot_validation_t const * p_validation, uint32_t data_addr, uint32_t data_len); + +/** + * @brief Function for postvalidating the update after all data is received. + * + * @param[in] data_addr Start address of the received data. + * @param[in] data_len Length of the received data. + * + * @return Operation result. See @ref nrf_dfu_result_t. + */ +nrf_dfu_result_t nrf_dfu_validation_post_data_execute(uint32_t data_addr, uint32_t data_len); + +/** + * @brief Function for preparing the update for activation. + * + * This function is called after a reset, after all data is received. This function also runs + * @ref nrf_dfu_validation_post_data_execute internally. If this succeeds, the update is + * activated by the activation machinery in the bootloader the next time it runs. + * + * @note The caller must have permissions to edit the relevant entries in the settings. + * + * @param[in] data_addr Start address of the received data. + * @param[in] data_len Length of the received data. + * + * @return Operation result. See @ref nrf_dfu_result_t + */ +nrf_dfu_result_t nrf_dfu_validation_activation_prepare(uint32_t data_addr, uint32_t data_len); + +/** + * @brief Function to execute on a validated external app. + * + * @details This function is called once all data is received with the parameter + * @p is_boot set to false. The function is called during bootup with the parameter + * set to true. + * + * + * + * @note This function requires that @ref NRF_DFU_SUPPORTS_EXTERNAL_APP is set to 1. + * It is up to the user to implement this function. + * + * @warning Parameter @p is_trusted must be used to ensure that no loss of security of process can happen. + * This parameter should only be set if the function is called after a root-of-trust + * reset on the device. + * + * Parameter @p is_trusted can be used for the following: + * - Ensuring that an external application is run only once (after root-of-trust). + * - Ensuring that a bank flag or any other flash access can only happen after root-of-trust. + * - Ensuring that the device reaches the correct state after a power failure on the device. + * + * @param[in] p_init Init command for the firmware upgrade. + * @param[in] is_trusted Must be set to true if this is called after root-of-trust boot. + * Must be set to false if this is called from DFU mode or background + * DFU operation. + * + * @return Operation result. see @ref nrf_dfu_result_t. + */ +nrf_dfu_result_t nrf_dfu_validation_post_external_app_execute(dfu_init_command_t const * p_init, bool is_trusted); + +/** +* @brief Function to check if there is a valid external app in Bank 1. +* +* @returns True if valid external app, otherwise false. +*/ +bool nrf_dfu_validation_valid_external_app(void); + +#endif //__NRF_DFU_VALIDATION_H + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c new file mode 100644 index 0000000..b5b8424 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c @@ -0,0 +1,312 @@ +/** + * Copyright (c) 2017 - 2019, 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 +#include "nrf_dfu_types.h" +#include "nrf_dfu_settings.h" +#include "nrf_dfu_utils.h" +#include "nrf_bootloader_info.h" +#include "nrf_crypto.h" +#include "nrf_assert.h" +#include "dfu-cc.pb.h" +#include "nrf_dfu_ver_validation.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_ver_validation +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +/** @brief Macro for reading the Firmware ID of a SoftDevice at a given base address. + */ +#ifndef _SD_FWID_GET +#define _SD_FWID_GET(baseaddr) SD_OFFSET_GET_UINT16(baseaddr, 0x0C) +#endif + +#define EXT_ERR(err) (nrf_dfu_result_t)((uint32_t)NRF_DFU_RES_CODE_EXT_ERROR + (uint32_t)err) + +static bool sd_req_check(uint32_t const * p_sd_req, uint8_t sd_req_cnt, bool accept_any) +{ + bool result = false; + for (uint8_t i = 0; i < sd_req_cnt; i++) + { + if ((SD_PRESENT && (p_sd_req[i] == _SD_FWID_GET(MBR_SIZE))) || + (accept_any && (p_sd_req[i] == SD_REQ_ANY_VERSION)) + ) + { + // Found a matching sd_req field. sd_req is ok. + result = true; + break; + } + } + return result; +} + + +static bool sd_req_ok(dfu_init_command_t const * p_init) +{ + ASSERT(p_init != NULL); + bool result; +#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD) + // The bootloader needs the SoftDevice, so disabling NRF_DFU_APP_DOWNGRADE_PREVENTION + // should not be applied to SoftDevice updates. + const bool prevent_downgrade = NRF_DFU_APP_DOWNGRADE_PREVENTION || (p_init->type == DFU_FW_TYPE_SOFTDEVICE); +#else + const bool prevent_downgrade = NRF_DFU_APP_DOWNGRADE_PREVENTION; +#endif + + if (SD_PRESENT) + { + if (p_init->sd_req_count == 0) + { + result = false; + } + else if (p_init->sd_req[0] != SD_REQ_APP_OVERWRITES_SD) + { + result = sd_req_check(p_init->sd_req, + p_init->sd_req_count, + (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION)); + } + else if (p_init->type == DFU_FW_TYPE_APPLICATION) + { + // The application wants to overwrite the SoftDevice. + if (prevent_downgrade && (p_init->sd_req_count > 1) && (p_init->sd_req[0] == SD_REQ_APP_OVERWRITES_SD)) + { + // The application can overwrite the SD if sd_req[0] == 0 and table has the FWID of the current SD. + result = sd_req_check(p_init->sd_req, p_init->sd_req_count, false); + + // Prevent BLE bootloaders from allowing applications overwriting the SoftDevice. +#ifdef BLE_STACK_SUPPORT_REQD + result = false; +#endif // BLE_STACK_SUPPORT_REQD + } + else + { + result = true; + } + } +#if NRF_DFU_SUPPORTS_EXTERNAL_APP + else if(p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION) + { + // Won't accept FW upgrade using external application to + // enforce replacing SoftDevice (SD_REQ_APP_OVERWRITES_SD) + result = false; + } +#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP + else + { + // Don't allow SoftDevice updates which assume no SD is present already. + result = !prevent_downgrade || (p_init->type != DFU_FW_TYPE_SOFTDEVICE); + } + } + + else + { + if (p_init->sd_req_count && (p_init->sd_req[0] != SD_REQ_APP_OVERWRITES_SD)) + { + // Fail if there is no SD and the update requires SD. The special "any" FWID is valid + // for external apps only. + result = false; +#if NRF_DFU_SUPPORTS_EXTERNAL_APP + result = sd_req_check(p_init->sd_req, + p_init->sd_req_count, + (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION)); +#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP + } + else + { + // If there is no SD and update has SD it is accepted only if it has a fw_version. + result = !prevent_downgrade || p_init->has_fw_version; + } + } + return result; +} + + +static bool fw_hash_type_ok(dfu_init_command_t const * p_init) +{ + ASSERT(p_init != NULL); + + return (p_init->hash.hash_type == DFU_HASH_TYPE_SHA256); +} + + +static bool fw_version_required(dfu_fw_type_t new_fw_type) +{ + bool result = true; + + if (new_fw_type == DFU_FW_TYPE_SOFTDEVICE) + { + result = false; // fw_version is optional in SoftDevice updates. If present, it will be checked against the app version. + } + else if (new_fw_type == DFU_FW_TYPE_APPLICATION) + { + result = NRF_DFU_APP_DOWNGRADE_PREVENTION; // fw_version is configurable in app updates. + } +#if NRF_DFU_SUPPORTS_EXTERNAL_APP +#if !NRF_DFU_EXTERNAL_APP_VERSIONING + else if (new_fw_type == DFU_FW_TYPE_EXTERNAL_APPLICATION) + { + return false; + } +#endif //!NRF_DFU_EXTERNAL_APP_VERSIONING +#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP + + return result; +} + + +static bool fw_type_ok(dfu_init_command_t const * p_init) +{ + ASSERT(p_init != NULL); + + return ((p_init->has_type) + && ( (p_init->type == DFU_FW_TYPE_APPLICATION) + || (p_init->type == DFU_FW_TYPE_SOFTDEVICE) + || (p_init->type == DFU_FW_TYPE_BOOTLOADER) + || (p_init->type == DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER) +#if NRF_DFU_SUPPORTS_EXTERNAL_APP + || (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION) +#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP + )); + +} + + +#ifndef NRF_DFU_APP_ACCEPT_SAME_VERSION +#define NRF_DFU_APP_ACCEPT_SAME_VERSION 1 +#endif + + +// This function assumes p_init->has_fw_version. +static bool fw_version_ok(dfu_init_command_t const * p_init) +{ + ASSERT(p_init != NULL); + ASSERT(p_init->has_fw_version); + + if ((p_init->type == DFU_FW_TYPE_APPLICATION) || + (p_init->type == DFU_FW_TYPE_SOFTDEVICE)) + { + if (!NRF_DFU_APP_DOWNGRADE_PREVENTION) + { + return true; + } + else if ((p_init->fw_version > s_dfu_settings.app_version)) + { + return true; + } + else if ((p_init->fw_version == s_dfu_settings.app_version)) + { + return NRF_DFU_APP_ACCEPT_SAME_VERSION; + } + else + { + return false; + } + } +#if NRF_DFU_SUPPORTS_EXTERNAL_APP +#if NRF_DFU_EXTERNAL_APP_VERSIONING + else if (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION) + { + return (p_init->fw_version >= s_dfu_settings.app_version); + } +#else + else if(p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION) + { + return true; + } +#endif // NRF_DFU_EXTERNAL_APP_VERSIONING +#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP + else + { + return (p_init->fw_version > s_dfu_settings.bootloader_version); + } +} + + +nrf_dfu_result_t nrf_dfu_ver_validation_check(dfu_init_command_t const * p_init) +{ + nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS; + if (!fw_type_ok(p_init)) + { + NRF_LOG_ERROR("Invalid firmware type."); + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID); + } + else if (!fw_hash_type_ok(p_init)) + { + NRF_LOG_ERROR("Invalid hash type."); + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_WRONG_HASH_TYPE); + } + else if (!NRF_DFU_DEBUG || + (NRF_DFU_DEBUG && ((p_init->has_is_debug == false) || (p_init->is_debug == false)))) + { + if (p_init->has_hw_version == false) + { + NRF_LOG_ERROR("No HW version."); + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID); + } + else if (p_init->hw_version != NRF_DFU_HW_VERSION) + { + NRF_LOG_WARNING("Faulty HW version."); + ret_val = EXT_ERR( NRF_DFU_EXT_ERROR_HW_VERSION_FAILURE); + } + + else if (!sd_req_ok(p_init)) + { + NRF_LOG_WARNING("SD req not met."); + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_SD_VERSION_FAILURE); + } + else if (p_init->has_fw_version) + { + if (!fw_version_ok(p_init)) + { + NRF_LOG_WARNING("FW version too low."); + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE); + } + } + else + { + if (fw_version_required(p_init->type)) + { + NRF_LOG_ERROR("FW version missing."); + ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID); + } + } + } + return ret_val; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.h new file mode 100644 index 0000000..2b5c8a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.h @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2017 - 2019, 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 __NRF_DFU_VER_VALIDATION_H +#define __NRF_DFU_VER_VALIDATION_H + +#include "stdint.h" +#include "sdk_errors.h" +#include "nrf_dfu_handling_error.h" +#include "dfu-cc.pb.h" + +/** @brief SD_REQ field value which indicates that Softdevice can be overwritten by the application. */ +#define SD_REQ_APP_OVERWRITES_SD 0 + +/** @brief SD_REQ_ANY_VERSION field value which indicates that any SoftDevice version is valid. + * + * @note This is used by external application in case SoftDevice version compatibility isn't needed. + */ +#define SD_REQ_ANY_VERSION (0xFFFE) + +/** + * @brief Function for validating version of new firmware. + * + * @return NRF_DFU_RES_CODE_SUCCESS if successful or error code otherwise + */ +nrf_dfu_result_t nrf_dfu_ver_validation_check(dfu_init_command_t const * p_init); + +#endif //__NRF_DFU_VER_VALIDATION_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.c new file mode 100644 index 0000000..19bdc9c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.c @@ -0,0 +1,524 @@ +/** + * Copyright (c) 2016 - 2019, 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 "nrf_bootloader.h" + +#include "compiler_abstraction.h" +#include "nrf.h" +#include "boards.h" +#include "sdk_config.h" +#include "nrf_power.h" +#include "nrf_delay.h" +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_dfu.h" +#include "nrf_error.h" +#include "nrf_dfu_settings.h" +#include "nrf_dfu_utils.h" +#include "nrf_bootloader_wdt.h" +#include "nrf_bootloader_info.h" +#include "nrf_bootloader_app_start.h" +#include "nrf_bootloader_fw_activation.h" +#include "nrf_bootloader_dfu_timers.h" +#include "app_scheduler.h" +#include "nrf_dfu_validation.h" + +static nrf_dfu_observer_t m_user_observer; //= 100) || (NRF_BL_DFU_INACTIVITY_TIMEOUT_MS == 0), + "NRF_BL_DFU_INACTIVITY_TIMEOUT_MS must be 100 ms or more, or 0 to indicate that it is disabled."); + +#if defined(NRF_LOG_BACKEND_FLASH_START_PAGE) +STATIC_ASSERT(NRF_LOG_BACKEND_FLASH_START_PAGE != 0, + "If nrf_log flash backend is used it cannot use space after code because it would collide with settings page."); +#endif + +/**@brief Weak implemenation of nrf_dfu_init + * + * @note This function will be overridden if nrf_dfu.c is + * compiled and linked with the project + */ + #if (__LINT__ != 1) +__WEAK uint32_t nrf_dfu_init(nrf_dfu_observer_t observer) +{ + NRF_LOG_DEBUG("in weak nrf_dfu_init"); + return NRF_SUCCESS; +} +#endif + + +/**@brief Weak implementation of nrf_dfu_init + * + * @note This function must be overridden in application if + * user-specific initialization is needed. + */ +__WEAK uint32_t nrf_dfu_init_user(void) +{ + NRF_LOG_DEBUG("in weak nrf_dfu_init_user"); + return NRF_SUCCESS; +} + + +static void flash_write_callback(void * p_context) +{ + UNUSED_PARAMETER(p_context); + m_flash_write_done = true; +} + + +static void do_reset(void * p_context) +{ + UNUSED_PARAMETER(p_context); + + NRF_LOG_FINAL_FLUSH(); + + nrf_delay_ms(NRF_BL_RESET_DELAY_MS); + + NVIC_SystemReset(); +} + + +static void bootloader_reset(bool do_backup) +{ + NRF_LOG_DEBUG("Resetting bootloader."); + + if (do_backup) + { + m_flash_write_done = false; + nrf_dfu_settings_backup(do_reset); + } + else + { + do_reset(NULL); + } +} + + +static void inactivity_timeout(void) +{ + NRF_LOG_INFO("Inactivity timeout."); + bootloader_reset(true); +} + + +/**@brief Function for handling DFU events. + */ +static void dfu_observer(nrf_dfu_evt_type_t evt_type) +{ + switch (evt_type) + { + case NRF_DFU_EVT_DFU_STARTED: + case NRF_DFU_EVT_OBJECT_RECEIVED: + nrf_bootloader_dfu_inactivity_timer_restart( + NRF_BOOTLOADER_MS_TO_TICKS(NRF_BL_DFU_INACTIVITY_TIMEOUT_MS), + inactivity_timeout); + break; + case NRF_DFU_EVT_DFU_COMPLETED: + case NRF_DFU_EVT_DFU_ABORTED: + bootloader_reset(true); + break; + case NRF_DFU_EVT_TRANSPORT_DEACTIVATED: + // Reset the internal state of the DFU settings to the last stored state. + nrf_dfu_settings_reinit(); + break; + default: + break; + } + + if (m_user_observer) + { + m_user_observer(evt_type); + } +} + + +/**@brief Function for initializing the event scheduler. + */ +static void scheduler_init(void) +{ + APP_SCHED_INIT(SCHED_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); +} + + +/**@brief Suspend the CPU until an interrupt occurs. + */ +static void wait_for_event(void) +{ +#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD) + (void)sd_app_evt_wait(); +#else + // Wait for an event. + __WFE(); + // Clear the internal event register. + __SEV(); + __WFE(); +#endif +} + + +/**@brief Continually sleep and process tasks whenever woken. + */ +static void loop_forever(void) +{ + while (true) + { + //feed the watchdog if enabled. + nrf_bootloader_wdt_feed(); + + app_sched_execute(); + + if (!NRF_LOG_PROCESS()) + { + wait_for_event(); + } + } +} + +/**@brief Function for initializing button used to enter DFU mode. + */ +static void dfu_enter_button_init(void) +{ + nrf_gpio_cfg_sense_input(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN, + BUTTON_PULL, + NRF_GPIO_PIN_SENSE_LOW); +} + + +static bool crc_on_valid_app_required(void) +{ + bool ret = true; + if (NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET && + (nrf_power_resetreas_get() & NRF_POWER_RESETREAS_OFF_MASK)) + { + nrf_power_resetreas_clear(NRF_POWER_RESETREAS_OFF_MASK); + ret = false; + } + else if (NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2 && + ((nrf_power_gpregret2_get() & BOOTLOADER_DFU_GPREGRET2_MASK) == BOOTLOADER_DFU_GPREGRET2) + && (nrf_power_gpregret2_get() & BOOTLOADER_DFU_SKIP_CRC_BIT_MASK)) + { + nrf_power_gpregret2_set(nrf_power_gpregret2_get() & ~BOOTLOADER_DFU_SKIP_CRC); + ret = false; + } + else + { + } + + return ret; +} + + + +static bool boot_validate(boot_validation_t const * p_validation, uint32_t data_addr, uint32_t data_len, bool do_crc) +{ + if (!do_crc && (p_validation->type == VALIDATE_CRC)) + { + return true; + } + return nrf_dfu_validation_boot_validate(p_validation, data_addr, data_len); +} + + +/** @brief Function for checking if the main application is valid. + * + * @details This function checks if there is a valid application + * located at Bank 0. + * + * @param[in] do_crc Perform CRC check on application. Only CRC checks + can be skipped. For other boot validation types, + this parameter is ignored. + * + * @retval true If a valid application has been detected. + * @retval false If there is no valid application. + */ +static bool app_is_valid(bool do_crc) +{ + if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP) + { + NRF_LOG_INFO("Boot validation failed. No valid app to boot."); + return false; + } + else if (NRF_BL_APP_SIGNATURE_CHECK_REQUIRED && + (s_dfu_settings.boot_validation_app.type != VALIDATE_ECDSA_P256_SHA256)) + { + NRF_LOG_WARNING("Boot validation failed. The boot validation of the app must be a signature check."); + return false; + } + else if (SD_PRESENT && !boot_validate(&s_dfu_settings.boot_validation_softdevice, MBR_SIZE, s_dfu_settings.sd_size, do_crc)) + { + NRF_LOG_WARNING("Boot validation failed. SoftDevice is present but invalid."); + return false; + } + else if (!boot_validate(&s_dfu_settings.boot_validation_app, nrf_dfu_bank0_start_addr(), s_dfu_settings.bank_0.image_size, do_crc)) + { + NRF_LOG_WARNING("Boot validation failed. App is invalid."); + return false; + } + // The bootloader itself is not checked, since a self-check of this kind gives little to no benefit + // compared to the cost incurred on each bootup. + + NRF_LOG_DEBUG("App is valid"); + return true; +} + + + +/**@brief Function for clearing all DFU enter flags that + * preserve state during reset. + * + * @details This is used to make sure that each of these flags + * is checked only once after reset. + */ +static void dfu_enter_flags_clear(void) +{ + if (NRF_BL_DFU_ENTER_METHOD_PINRESET && + (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk)) + { + // Clear RESETPIN flag. + NRF_POWER->RESETREAS |= POWER_RESETREAS_RESETPIN_Msk; + } + + if (NRF_BL_DFU_ENTER_METHOD_GPREGRET && + ((nrf_power_gpregret_get() & BOOTLOADER_DFU_GPREGRET_MASK) == BOOTLOADER_DFU_GPREGRET) + && (nrf_power_gpregret_get() & BOOTLOADER_DFU_START_BIT_MASK)) + { + // Clear DFU mark in GPREGRET register. + nrf_power_gpregret_set(nrf_power_gpregret_get() & ~BOOTLOADER_DFU_START); + } + + if (NRF_BL_DFU_ENTER_METHOD_BUTTONLESS && + (s_dfu_settings.enter_buttonless_dfu == 1)) + { + // Clear DFU flag in flash settings. + s_dfu_settings.enter_buttonless_dfu = 0; + APP_ERROR_CHECK(nrf_dfu_settings_write(NULL)); + } +} + + +/**@brief Function for checking whether to enter DFU mode or not. + */ +static bool dfu_enter_check(void) +{ + if (!app_is_valid(crc_on_valid_app_required())) + { + NRF_LOG_DEBUG("DFU mode because app is not valid."); + return true; + } + + if (NRF_BL_DFU_ENTER_METHOD_BUTTON && + (nrf_gpio_pin_read(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN) == 0)) + { + NRF_LOG_DEBUG("DFU mode requested via button."); + return true; + } + + if (NRF_BL_DFU_ENTER_METHOD_PINRESET && + (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk)) + { + NRF_LOG_DEBUG("DFU mode requested via pin-reset."); + return true; + } + + if (NRF_BL_DFU_ENTER_METHOD_GPREGRET && + (nrf_power_gpregret_get() & BOOTLOADER_DFU_START)) + { + NRF_LOG_DEBUG("DFU mode requested via GPREGRET."); + return true; + } + + if (NRF_BL_DFU_ENTER_METHOD_BUTTONLESS && + (s_dfu_settings.enter_buttonless_dfu == 1)) + { + NRF_LOG_DEBUG("DFU mode requested via bootloader settings."); + return true; + } + + return false; +} + + +#if NRF_BL_DFU_ALLOW_UPDATE_FROM_APP +static void postvalidate(void) +{ + NRF_LOG_INFO("Postvalidating update after reset."); + nrf_dfu_validation_init(); + + if (nrf_dfu_validation_init_cmd_present()) + { + uint32_t firmware_start_addr; + uint32_t firmware_size; + + // Execute a previously received init packed. Subsequent executes will have no effect. + if (nrf_dfu_validation_init_cmd_execute(&firmware_start_addr, &firmware_size) == NRF_DFU_RES_CODE_SUCCESS) + { + if (nrf_dfu_validation_prevalidate() == NRF_DFU_RES_CODE_SUCCESS) + { + if (nrf_dfu_validation_activation_prepare(firmware_start_addr, firmware_size) == NRF_DFU_RES_CODE_SUCCESS) + { + NRF_LOG_INFO("Postvalidation successful."); + } + } + } + } + + s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_0; + UNUSED_RETURN_VALUE(nrf_dfu_settings_write_and_backup(flash_write_callback)); +} +#endif + + +ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer) +{ + NRF_LOG_DEBUG("In nrf_bootloader_init"); + + ret_code_t ret_val; + nrf_bootloader_fw_activation_result_t activation_result; + uint32_t initial_timeout; + bool dfu_enter = false; + + m_user_observer = observer; + + if (NRF_BL_DEBUG_PORT_DISABLE) + { + nrf_bootloader_debug_port_disable(); + } + + if (NRF_BL_DFU_ENTER_METHOD_BUTTON) + { + dfu_enter_button_init(); + } + + ret_val = nrf_dfu_settings_init(false); + if (ret_val != NRF_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + #if NRF_BL_DFU_ALLOW_UPDATE_FROM_APP + // Postvalidate if DFU has signaled that update is ready. + if (s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_1) + { + postvalidate(); + } + #endif + + // Check if an update needs to be activated and activate it. + activation_result = nrf_bootloader_fw_activate(); + + switch (activation_result) + { + case ACTIVATION_NONE: + initial_timeout = NRF_BOOTLOADER_MS_TO_TICKS(NRF_BL_DFU_INACTIVITY_TIMEOUT_MS); + dfu_enter = dfu_enter_check(); + break; + + case ACTIVATION_SUCCESS_EXPECT_ADDITIONAL_UPDATE: + initial_timeout = NRF_BOOTLOADER_MS_TO_TICKS(NRF_BL_DFU_CONTINUATION_TIMEOUT_MS); + dfu_enter = true; + break; + + case ACTIVATION_SUCCESS: + bootloader_reset(true); + NRF_LOG_ERROR("Unreachable"); + return NRF_ERROR_INTERNAL; // Should not reach this. + + case ACTIVATION_ERROR: + default: + return NRF_ERROR_INTERNAL; + } + + if (dfu_enter) + { + nrf_bootloader_wdt_init(); + scheduler_init(); + dfu_enter_flags_clear(); + + // Call user-defined init function if implemented + ret_val = nrf_dfu_init_user(); + if (ret_val != NRF_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + nrf_bootloader_dfu_inactivity_timer_restart(initial_timeout, inactivity_timeout); + + ret_val = nrf_dfu_init(dfu_observer); + if (ret_val != NRF_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + NRF_LOG_DEBUG("Enter main loop"); + loop_forever(); // This function will never return. + NRF_LOG_ERROR("Unreachable"); + } + else + { + // Erase additional data like peer data or advertisement name + ret_val = nrf_dfu_settings_additional_erase(); + if (ret_val != NRF_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + m_flash_write_done = false; + nrf_dfu_settings_backup(flash_write_callback); + ASSERT(m_flash_write_done); + + nrf_bootloader_app_start(); + NRF_LOG_ERROR("Unreachable"); + } + + // Should not be reached. + return NRF_ERROR_INTERNAL; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.h index f0f05b3..39cf8bf 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,18 +35,15 @@ * 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 sdk_nrf_bootloader Bootloader modules - * @ingroup app_common - * @brief Modules for creating a bootloader. * - * @defgroup sdk_bootloader Bootloader + * @defgroup nrf_bootloader Bootloader modules * @{ - * @ingroup sdk_nrf_bootloader - * @brief Basic bootloader. + * @ingroup app_common + * @brief Bootloader and DFU modules * * The bootloader module can be used to implement a basic bootloader that * can be extended with, for example, Device Firmware Update (DFU) support @@ -57,7 +54,7 @@ #define NRF_BOOTLOADER_H__ #include - +#include "nrf_dfu.h" #ifdef __cplusplus extern "C" { #endif @@ -68,21 +65,11 @@ extern "C" { * If DFU functionality is compiled in, the DFU process is initialized * when running this function. * - * @retval NRF_SUCCESS If the bootloader was successfully initialized. - * Any other return code indicates that the operation failed. - */ -uint32_t nrf_bootloader_init(void); - - -/** @brief Function for customizing the bootloader initialization. - * - * @details This function is called during the initialization of the bootloader. - * It is implemented as weak function that can be overridden in the main file of the application. + * @note This function does not return unless an error occurred. * - * @retval NRF_SUCCESS If the user initialization was run successfully. + * @retval NRF_ERROR_INTERNAL Something went wrong. */ -uint32_t nrf_bootloader_user_init(void); - +ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer); #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start.c similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start.c index d1be81e..58222ef 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,34 +35,29 @@ * 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 +#include "nrf.h" #include "nrf_bootloader_app_start.h" +#include "nrf_bootloader_info.h" #include "nrf_log.h" #include "nrf_dfu_mbr.h" +#include "nrf_log_ctrl.h" +#include "nrf_bootloader_info.h" -#if defined(SOFTDEVICE_PRESENT) -#include "nrf_sdm.h" -#endif - -extern void nrf_bootloader_app_start_impl(uint32_t start_addr); +// Do the final stages of app_start. Protect flash and run app. See nrf_bootloader_app_start_final.c +void nrf_bootloader_app_start_final(uint32_t start_addr); -void nrf_bootloader_app_start(uint32_t start_addr) +void nrf_bootloader_app_start(void) { + uint32_t start_addr = MBR_SIZE; // Always boot from end of MBR. If a SoftDevice is present, it will boot the app. NRF_LOG_DEBUG("Running nrf_bootloader_app_start with address: 0x%08x", start_addr); uint32_t err_code; - //NRF_LOG_INFO("Initializing SD in mbr"); - err_code = nrf_dfu_mbr_init_sd(); - if (err_code != NRF_SUCCESS) - { - NRF_LOG_ERROR("Failed running nrf_dfu_mbr_init_sd"); - return; - } - // Disable and clear interrupts - NRF_LOG_DEBUG("Disabling interrupts"); + // Notice that this disables only 'external' interrupts (positive IRQn). + NRF_LOG_DEBUG("Disabling interrupts. NVIC->ICER[0]: 0x%x", NVIC->ICER[0]); NVIC->ICER[0]=0xFFFFFFFF; NVIC->ICPR[0]=0xFFFFFFFF; @@ -71,16 +66,12 @@ void nrf_bootloader_app_start(uint32_t start_addr) NVIC->ICPR[1]=0xFFFFFFFF; #endif - // Set the sd softdevice vector table base address - NRF_LOG_DEBUG("Setting SD vector table base: 0x%08x", start_addr); - err_code = sd_softdevice_vector_table_base_set(start_addr); + err_code = nrf_dfu_mbr_irq_forward_address_set(); if (err_code != NRF_SUCCESS) { - NRF_LOG_ERROR("Failed running sd_softdevice_vector_table_base_set"); - return; + NRF_LOG_ERROR("Failed running nrf_dfu_mbr_irq_forward_address_set()"); } - // Run application - nrf_bootloader_app_start_impl(start_addr); + NRF_LOG_FLUSH(); + nrf_bootloader_app_start_final(start_addr); } - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start.h similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start.h index 8d5c7a3..cfe09d2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_app_start.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,19 +35,43 @@ * 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 sdk_bootloader_app Application start + * @defgroup nrf_bootloader_app Application start * @{ - * @ingroup sdk_bootloader + * @ingroup nrf_bootloader */ #ifndef NRF_BOOTLOADER_APP_START_H__ #define NRF_BOOTLOADER_APP_START_H__ #include +#include +#include "sdk_errors.h" + + +/**@brief Function for using hardware to protect flash from writing and reading. + * + * @details This function will apply write/erase protection to a specific area. Read + * protection is optional, decided by \p read_protect. This function uses + * the BPROT or ACL peripheral, depending on which is available. + * + * @param[in] address The start address of the area to protect. Must be a flash page + * boundary. + * @param[in] size The size of the area to protect, in bytes. Must be a multiple + * of flash page size. + * @param[in] read_protect Whether to protect the area from reading/executing as well. + * This is not available on chips with the BPROT peripheral + * (e.g. nrf52832, nrf52810). + * + * @retval NRF_SUCCESS Flash protection applied successfully. + * @retval NRF_ERROR_NO_MEM No more ACL instances to use for flash protection. + * @retval NRF_ERROR_INVALID_PARAM Address was out of range or size was not a multiple + * of flash page size. + */ +ret_code_t nrf_bootloader_flash_protect(uint32_t address, uint32_t size, bool read_protect); /**@brief Function for starting another application (and aborting the current one). * @@ -57,13 +81,11 @@ * If in handler mode, isr_abort is executed to ensure that handler mode is left correctly. * It then jumps into the reset handler of the other application. * - * @note This function will never return, but issues a reset into the provided application. - * - * @param[in] start_addr Start address of the other application. This address must point to the - initial stack pointer of the application. + * @note This function assumes the SoftDevice has not previously been initialized. * + * @note This function will never return, but issues a reset into the provided application. */ -void nrf_bootloader_app_start(uint32_t start_addr); +void nrf_bootloader_app_start(void); #endif // NRF_BOOTLOADER_APP_START_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start_final.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start_final.c new file mode 100644 index 0000000..9b882c4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_app_start_final.c @@ -0,0 +1,244 @@ +/** + * Copyright (c) 2016 - 2019, 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_config.h" +#include "nrf_bootloader_app_start.h" +#include +#include "nrf.h" +#include "nrf_peripherals.h" +#include "nrf_bootloader_info.h" +#include "nrf_dfu_types.h" +#include "nrf_dfu_utils.h" +#include "nrf_dfu_settings.h" +#include "nrf_assert.h" +#include "nrf_log.h" +#include "sdk_config.h" + + +// Enabling the NRF_BOOTLOADER_READ_PROTECT define is untested. +// Read-protecting the bootloader requires certain functions to run from RAM. +// In GCC and SES this is done automatically when the define is enabled. You will +// get warnings which can be ignored. +// In Keil you must change project settings to run the entire file from RAM. +#ifndef NRF_BOOTLOADER_READ_PROTECT +#define NRF_BOOTLOADER_READ_PROTECT 0 +#endif + + +#define HANDLER_MODE_EXIT 0xFFFFFFF9 // When this is jumped to, the CPU will exit interrupt context + // (handler mode), and pop values from the stack into registers. + // See ARM's documentation for "Exception entry and return". +#define EXCEPTION_STACK_WORD_COUNT 8 // The number of words popped from the stack when + // HANDLER_MODE_EXIT is branched to. + + +/**@brief Function that sets the stack pointer and link register, and starts executing a particular address. + * + * @param[in] new_msp The new value to set in the main stack pointer. + * @param[in] new_lr The new value to set in the link register. + * @param[in] addr The address to execute. + */ +#if defined ( __CC_ARM ) +__ASM __STATIC_INLINE void jump_to_addr(uint32_t new_msp, uint32_t new_lr, uint32_t addr) +{ + MSR MSP, R0; + MOV LR, R1; + BX R2; +} +#else +__STATIC_INLINE void jump_to_addr(uint32_t new_msp, uint32_t new_lr, uint32_t addr) +{ + __ASM volatile ("MSR MSP, %[arg]" : : [arg] "r" (new_msp)); + __ASM volatile ("MOV LR, %[arg]" : : [arg] "r" (new_lr) : "lr"); + __ASM volatile ("BX %[arg]" : : [arg] "r" (addr)); +} +#endif + + +/**@brief Function for booting an app as if the chip was reset. + * + * @param[in] vector_table_addr The address of the app's vector table. + */ +__STATIC_INLINE void app_start(uint32_t vector_table_addr) +{ + const uint32_t current_isr_num = (__get_IPSR() & IPSR_ISR_Msk); + const uint32_t new_msp = *((uint32_t *)(vector_table_addr)); // The app's Stack Pointer is found as the first word of the vector table. + const uint32_t reset_handler = *((uint32_t *)(vector_table_addr + sizeof(uint32_t))); // The app's Reset Handler is found as the second word of the vector table. + const uint32_t new_lr = 0xFFFFFFFF; + + __set_CONTROL(0x00000000); // Set CONTROL to its reset value 0. + __set_PRIMASK(0x00000000); // Set PRIMASK to its reset value 0. + __set_BASEPRI(0x00000000); // Set BASEPRI to its reset value 0. + __set_FAULTMASK(0x00000000); // Set FAULTMASK to its reset value 0. + + ASSERT(current_isr_num == 0); // If this is triggered, the CPU is currently in an interrupt. + + // The CPU is in Thread mode (main context). + jump_to_addr(new_msp, new_lr, reset_handler); // Jump directly to the App's Reset Handler. +} + +#if NRF_BOOTLOADER_READ_PROTECT +#ifdef __ICCARM__ +__ramfunc +#elif defined ( __GNUC__ ) || defined ( __SES_ARM ) +__attribute__((noinline, long_call, section(".data"))) +#elif defined ( __CC_ARM ) +#warning "Keil requires changes to project settings to run this file from RAM. Ignore this warning if configuration has been made." +#endif +#endif +ret_code_t nrf_bootloader_flash_protect(uint32_t address, uint32_t size, bool read_protect) +{ + if ((size & (CODE_PAGE_SIZE - 1)) || (address > BOOTLOADER_SETTINGS_ADDRESS)) + { + return NRF_ERROR_INVALID_PARAM; + } + +#if defined(ACL_PRESENT) + + // Protect using ACL. + static uint32_t acl_instance = 0; + + uint32_t const wmask = (ACL_ACL_PERM_WRITE_Disable << ACL_ACL_PERM_WRITE_Pos); + uint32_t const rwmask = wmask | (ACL_ACL_PERM_READ_Disable << ACL_ACL_PERM_READ_Pos); + uint32_t const mask = read_protect ? rwmask: wmask; + + do + { + if (acl_instance >= ACL_REGIONS_COUNT) + { + return NRF_ERROR_NO_MEM; + } + + NRF_ACL->ACL[acl_instance].ADDR = address; + NRF_ACL->ACL[acl_instance].SIZE = size; + NRF_ACL->ACL[acl_instance].PERM = mask; + + acl_instance++; + + } while (NRF_ACL->ACL[acl_instance - 1].ADDR != address + || NRF_ACL->ACL[acl_instance - 1].SIZE != size + || NRF_ACL->ACL[acl_instance - 1].PERM != mask); // Check whether the acl_instance has been used before. + +#elif defined (BPROT_PRESENT) + + // Protect using BPROT. BPROT does not support read protection. + uint32_t pagenum_start = address / CODE_PAGE_SIZE; + uint32_t pagenum_end = pagenum_start + ((size - 1) / CODE_PAGE_SIZE); + + for (uint32_t i = pagenum_start; i <= pagenum_end; i++) + { + uint32_t config_index = i / 32; + uint32_t mask = (1 << (i - config_index * 32)); + + switch (config_index) + { + case 0: + NRF_BPROT->CONFIG0 = mask; + break; + case 1: + NRF_BPROT->CONFIG1 = mask; + break; +#if BPROT_REGIONS_NUM > 64 + case 2: + NRF_BPROT->CONFIG2 = mask; + break; + case 3: + NRF_BPROT->CONFIG3 = mask; + break; +#endif + } + } + +#endif + + return NRF_SUCCESS; +} + + +#if NRF_BOOTLOADER_READ_PROTECT +#ifdef __ICCARM__ +__ramfunc +#elif defined ( __GNUC__ ) || defined ( __SES_ARM ) +__attribute__((noinline, long_call, section(".data"))) +#elif defined ( __CC_ARM ) +#warning "Keil requires changes to project settings to run this file from RAM. Ignore this warning if configuration has been made." +#endif +#endif +void nrf_bootloader_app_start_final(uint32_t vector_table_addr) +{ + ret_code_t ret_val; + + // Protect MBR & bootloader code and params pages. + if (NRF_BOOTLOADER_READ_PROTECT) + { + ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE, NRF_BOOTLOADER_READ_PROTECT); + } + + // Size of the flash area to protect. + uint32_t area_size; + + area_size = BOOTLOADER_SIZE + NRF_MBR_PARAMS_PAGE_SIZE; + if (!NRF_BL_DFU_ALLOW_UPDATE_FROM_APP && !NRF_BL_DFU_ENTER_METHOD_BUTTONLESS && !NRF_DFU_TRANSPORT_BLE) + { + area_size += BOOTLOADER_SETTINGS_PAGE_SIZE; + } + + ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, + area_size, + NRF_BOOTLOADER_READ_PROTECT); + + if (!NRF_BOOTLOADER_READ_PROTECT && (ret_val != NRF_SUCCESS)) + { + NRF_LOG_ERROR("Could not protect bootloader and settings pages, 0x%x.", ret_val); + } + APP_ERROR_CHECK(ret_val); + + ret_val = nrf_bootloader_flash_protect(0, + nrf_dfu_bank0_start_addr() + ALIGN_TO_PAGE(s_dfu_settings.bank_0.image_size), + false); + + if (!NRF_BOOTLOADER_READ_PROTECT && (ret_val != NRF_SUCCESS)) + { + NRF_LOG_ERROR("Could not protect SoftDevice and application, 0x%x.", ret_val); + } + APP_ERROR_CHECK(ret_val); + + // Run application + app_start(vector_table_addr); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.c new file mode 100644 index 0000000..c5c02ae --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.c @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2018 - 2019, 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 "nrf_bootloader_dfu_timers.h" + +#include +#include +#include +#include "nrf_clock.h" +#include "nrf_rtc.h" +#include "nrf_delay.h" +#include "nrf_log.h" + + +#define RTC_PRESCALER (0) //!< The value provided to the RTC as the prescaler. 0 corresponds to one tick per clock cycle of the LFCLK (32768 ticks/s). +#define RTC_WRAP_TICKS ((1 << 24) - 1) //!< The largest possible value in the RTC counter register. +#define MAX_TIMEOUT_TICKS (RTC_WRAP_TICKS) //!< The longest fire timeout allowed. Longer timeouts are handled by multiple firings. + +typedef struct +{ + nrf_bootloader_dfu_timeout_callback_t callback; //!< Callback that is called when this timer times out. + uint32_t timeout; //!< The number of ticks from the next firing until the actual timeout. This value will be different from 0 if the original timeout was longer than MAX_TIMEOUT_TICKS, so multiple firings were needed. + uint32_t repeated_timeout; //!< If different from 0, this timer will be reactivated with this value after timing out. + uint8_t cc_channel; //!< Which CC register this timer uses. +} dfu_timer_t; + + +dfu_timer_t m_timers[2] = {{.cc_channel = 0}, {.cc_channel = 1}}; //!< The timers used by this module. +dfu_timer_t * mp_inactivity = &m_timers[0]; //!< Direct pointer to the inactivity timer, for convenience and readability. +dfu_timer_t * mp_wdt_feed = &m_timers[1]; //!< Direct pointer to the wdt feed timer, for convenience and readability. +uint32_t m_counter_loops = 0; //!< The number of times the RTC counter register has overflowed (wrapped around) since the RTC was started. + +#if RTC_COUNT > 2 +#define RTC_INSTANCE 2 +#define RTC_STRUCT NRF_RTC2 +#define RTC_IRQHandler RTC2_IRQHandler +#define RTC_IRQn RTC2_IRQn +#define RTC_CC_COUNT NRF_RTC_CC_CHANNEL_COUNT(2)) +#elif RTC_COUNT > 1 +#define RTC_INSTANCE 1 +#define RTC_STRUCT NRF_RTC1 +#define RTC_IRQHandler RTC1_IRQHandler +#define RTC_IRQn RTC1_IRQn +#define RTC_CC_COUNT NRF_RTC_CC_CHANNEL_COUNT(1)) +#else +#error Not enough RTC instances. +#endif + +/**@brief Function for initializing the timer if it is not already initialized. + */ +static void timer_init(void) +{ + static bool m_timer_initialized; + + if (!m_timer_initialized) + { + if (!nrf_clock_lf_is_running()) + { + nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); + } + + nrf_rtc_event_clear(RTC_STRUCT, NRF_RTC_EVENT_TICK); + nrf_rtc_event_clear(RTC_STRUCT, NRF_RTC_EVENT_COMPARE_0); + nrf_rtc_event_clear(RTC_STRUCT, NRF_RTC_EVENT_COMPARE_1); + NRFX_IRQ_PRIORITY_SET(RTC_IRQn, 5); + NRFX_IRQ_ENABLE(RTC_IRQn); + nrf_rtc_prescaler_set(RTC_STRUCT, RTC_PRESCALER); + nrf_rtc_task_trigger(RTC_STRUCT, NRF_RTC_TASK_CLEAR); + nrf_rtc_task_trigger(RTC_STRUCT, NRF_RTC_TASK_START); + nrf_rtc_int_enable(RTC_STRUCT, RTC_INTENSET_OVRFLW_Msk); + + m_timer_initialized = true; + } +} + +/**@brief Function for scheduling an RTC compare event. + * + * @param[in] cc_channel Which of the RTC compare registers to use. + * @param[in] cc_value The ticks value at which to receive the event. + */ +static void rtc_update(uint32_t cc_channel, uint32_t cc_value) +{ + ASSERT(cc_channel < NRF_RTC_CC_CHANNEL_COUNT(RTC_INSTANCE)); + + nrf_rtc_cc_set(RTC_STRUCT, cc_channel, cc_value); + nrf_delay_us(31); + nrf_rtc_event_clear(RTC_STRUCT, RTC_CHANNEL_EVENT_ADDR(cc_channel)); + nrf_rtc_int_enable(RTC_STRUCT, RTC_CHANNEL_INT_MASK(cc_channel)); +} + + +/**@brief Function for activating a timer, so that it will be fired. + * + * This can happen multiple times before the actual timeout happens if the timeout is longer than + * @ref MAX_TIMEOUT_TICKS. + * + * @param[in] p_timer The timer to activate. + * @param[in] timeout_ticks The number of ticks until the timeout. + * + * @retval true If the timer was activated. + * @retval false If the timer is already active. + */ +static void timer_activate(dfu_timer_t * p_timer, uint32_t timeout_ticks) +{ + NRF_LOG_DEBUG("timer_activate (0x%x)", p_timer); + + ASSERT(timeout_ticks <= MAX_TIMEOUT_TICKS); + ASSERT(timeout_ticks >= NRF_BOOTLOADER_MIN_TIMEOUT_TICKS); + uint32_t next_timeout_ticks = MIN(timeout_ticks, MAX_TIMEOUT_TICKS); + uint32_t cc_value = RTC_WRAP(next_timeout_ticks + nrf_rtc_counter_get(RTC_STRUCT)); + p_timer->timeout = timeout_ticks - next_timeout_ticks; + + if ((p_timer->timeout > 0) && (p_timer->timeout < NRF_BOOTLOADER_MIN_TIMEOUT_TICKS)) + { + p_timer->timeout += NRF_BOOTLOADER_MIN_TIMEOUT_TICKS; + cc_value -= NRF_BOOTLOADER_MIN_TIMEOUT_TICKS; + } + + rtc_update(p_timer->cc_channel, cc_value); +} + + +/**@brief Function for deactivating a timer, so that it will not fire. + * + * @param[in] p_timer The timer to deactivate. + * + * @retval true If the timer was deactivated. + * @retval false If the timer is already inactive. + */ +static void timer_stop(dfu_timer_t * p_timer) +{ + NRF_LOG_DEBUG("timer_stop (0x%x)", p_timer); + nrf_rtc_int_disable(RTC_STRUCT, RTC_CHANNEL_INT_MASK(p_timer->cc_channel)); +} + + +/**@brief Function for firing a timer. + * + * This can happen multiple times before the actual timeout happens if the timeout is longer than + * @ref MAX_TIMEOUT_TICKS. + * This function reactivates the timer if the timer is repeating, or if the timer has not yet + * timed out. It then calls the callback if the timer (repeating or not) has timed out. + * + * @param[in] p_timer The timer to fire. + */ +static void timer_fire(dfu_timer_t * p_timer) +{ + NRF_LOG_DEBUG("timer_fire (0x%x)", p_timer); + + if (p_timer->timeout != 0) + { + // The timer has not yet timed out. + timer_activate(p_timer, p_timer->timeout); + return; + } + + if (p_timer->repeated_timeout != 0) + { + timer_activate(p_timer, p_timer->repeated_timeout); + } + + if (p_timer->callback != NULL) + { + p_timer->callback(); + } +} + + +/**@brief Function for requesting a timeout. + * + * The timer will time out @p timeout_ticks ticks from now. When it times out, @p callback + * will be called, and if @p p_timer->repeated_timeout is not 0, a new timeout will be scheduled. + * + * @param[in] p_timer The timer to start. + * @param[in] timeout_ticks The number of ticks until the timeout. + * @param[in] callback The callback to call when the timer times out. + */ +static void timer_start(dfu_timer_t * p_timer, + uint32_t timeout_ticks, + nrf_bootloader_dfu_timeout_callback_t callback) +{ + timer_init(); // Initialize if needed. + p_timer->callback = callback; + timer_activate(p_timer, timeout_ticks); +} + + +/**@brief Interrupt handler for the RTC (Real Time Clock) used for the DFU timers. + */ +void RTC_IRQHandler(void) +{ + if (nrf_rtc_event_pending(RTC_STRUCT, NRF_RTC_EVENT_OVERFLOW)) + { + m_counter_loops++; + nrf_rtc_event_clear(RTC_STRUCT, NRF_RTC_EVENT_OVERFLOW); + } + + for (uint32_t channel = 0; channel < 2; channel++) + { + if (nrf_rtc_event_pending(RTC_STRUCT, RTC_CHANNEL_EVENT_ADDR(channel))) + { + nrf_rtc_event_clear(RTC_STRUCT, RTC_CHANNEL_EVENT_ADDR(channel)); + timer_stop(&m_timers[channel]); + timer_fire(&m_timers[channel]); + } + } +} + + +void nrf_bootloader_dfu_inactivity_timer_restart(uint32_t timeout_ticks, + nrf_bootloader_dfu_timeout_callback_t callback) +{ + timer_stop(mp_inactivity); + if (timeout_ticks != 0) + { + timer_start(mp_inactivity, timeout_ticks, callback); + } +} + + +void nrf_bootloader_wdt_feed_timer_start(uint32_t timeout_ticks, + nrf_bootloader_dfu_timeout_callback_t callback) +{ + mp_wdt_feed->repeated_timeout = timeout_ticks; + timer_start(mp_wdt_feed, timeout_ticks, callback); +} + + +uint32_t nrf_bootloader_dfu_timer_counter_get(void) +{ + return nrf_rtc_counter_get(RTC_STRUCT) + (m_counter_loops << 24); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.h new file mode 100644 index 0000000..1fd9709 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_dfu_timers.h @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2018 - 2019, 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 nrf_bootloader_dfu_timers Timers for DFU in the bootloader + * @{ + * @ingroup nrf_bootloader + */ + +#ifndef NRF_BOOTLOADER_DFU_TIMERS_H__ +#define NRF_BOOTLOADER_DFU_TIMERS_H__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define NRF_BOOTLOADER_MIN_TIMEOUT_TICKS (150) //!< The shortest timeout allowed. To avoid the timeout not being activated before the time has passed. + +/**@brief Macro for converting milliseconds to timer ticks. + * + * @param[in] ms The milliseconds to convert. + * + * @return @p ms converted to ticks. + */ +#define NRF_BOOTLOADER_MS_TO_TICKS(ms) ((((uint64_t)(ms) * 32768)) / 1000) + +/**@brief Handler called on timeout of a timer requested by the watchdog. + */ +typedef void (*nrf_bootloader_dfu_timeout_callback_t)(void); + + +/**@brief Function for restarting the inactivity timer. + * + * @note Calling this function cancels any previous calls to this function. + * + * @param[in] timeout_ticks The number of ticks until reset. There are 32768 ticks per second. + * If 0 is passed, the timer will be stopped and not restarted. + * @param[in] callback Function to be called on timeout. + */ +void nrf_bootloader_dfu_inactivity_timer_restart(uint32_t timeout_ticks, + nrf_bootloader_dfu_timeout_callback_t callback); + + +/**@brief Function for initializing and starting a repeated timer for feeding the watchdog. + * + * @param[in] timeout_ticks The number of ticks between each feeding of the watchdog. There are + * 32768 ticks per second. + * @param[in] callback Function called on every timeout. + */ +void nrf_bootloader_wdt_feed_timer_start(uint32_t timeout_ticks, + nrf_bootloader_dfu_timeout_callback_t callback); + + +/**@brief Function for retrieving the number of ticks since the RTC was started. + * + * There are 32768 ticks per second. This value does not wrap, even when the RTC counter wraps. + * + * @note The value can be 2^24 ticks too small if sampled immediately after the RTC counter wraps, + * but before the internal loop counter has been incremented. + * + * @return The number of ticks since the RTC was started. + */ +uint32_t nrf_bootloader_dfu_timer_counter_get(void); + +#ifdef __cplusplus +} +#endif + +#endif // NRF_BOOTLOADER_DFU_TIMERS_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.c new file mode 100644 index 0000000..70d304d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.c @@ -0,0 +1,438 @@ +/** + * Copyright (c) 2016 - 2019, 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 "nrf_bootloader_fw_activation.h" +#include "nrf_dfu_settings.h" +#include "nrf_dfu_mbr.h" +#include "nrf_bootloader_info.h" +#include "crc32.h" +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_dfu_utils.h" +#include "nrf_bootloader_wdt.h" + + +static volatile bool m_flash_write_done; + + +/** + * @brief Function for copying image. Image is copied in chunks. Frequency of storing progress + * in flash is configured by input parameter. + * + * @param[in] dst_addr Destination address. Must be page aligned. + * @param[in] src_addr Source address. Must be higher value than dst_addr. + * @param[in] size Image size. + * @param[in] progress_update_step Number of copied pages that triggers saving progress to non-volatile memory. + * Note that step can be decreased if there is a risk of corruption caused by source + * and destination overlapping. + * + * @return NRF_SUCCESS or error code in case of failure. + */ +static uint32_t image_copy(uint32_t dst_addr, + uint32_t src_addr, + uint32_t size, + uint32_t progress_update_step) +{ + if (src_addr == dst_addr) + { + NRF_LOG_DEBUG("No copy needed"); + return NRF_SUCCESS; + } + + ASSERT(src_addr >= dst_addr); + ASSERT(progress_update_step > 0); + ASSERT((dst_addr % CODE_PAGE_SIZE) == 0); + + uint32_t max_safe_progress_upd_step = (src_addr - dst_addr)/CODE_PAGE_SIZE; + ASSERT(max_safe_progress_upd_step > 0); + + uint32_t ret_val = NRF_SUCCESS; + uint32_t pages_left = CEIL_DIV(size, CODE_PAGE_SIZE); + + //Firmware copying is time consuming operation thus watchdog handling is started + nrf_bootloader_wdt_init(); + + progress_update_step = MIN(progress_update_step, max_safe_progress_upd_step); + + while (size > 0) + { + uint32_t pages; + uint32_t bytes; + if (pages_left <= progress_update_step) + { + pages = pages_left; + bytes = size; + } + else + { + pages = progress_update_step; + bytes = progress_update_step * CODE_PAGE_SIZE; + } + // Erase the target pages + ret_val = nrf_dfu_flash_erase(dst_addr, pages, NULL); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + // Flash one page + NRF_LOG_DEBUG("Copying 0x%x to 0x%x, size: 0x%x", src_addr, dst_addr, bytes); + ret_val = nrf_dfu_flash_store(dst_addr, + (uint32_t *)src_addr, + ALIGN_NUM(sizeof(uint32_t), bytes), + NULL); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + pages_left -= pages; + size -= bytes; + dst_addr += bytes; + src_addr += bytes; + s_dfu_settings.write_offset += bytes; + + //store progress in flash on every successful chunk write + ret_val = nrf_dfu_settings_write_and_backup(NULL); + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed to write image copying progress to settings page."); + return ret_val; + } + } + + return ret_val; +} + +/** @brief Function to continue application update. + * + * @details This function will be called after reset if there is a valid application in Bank1 + * required to be copied down to Bank 0. + * + * @return NRF_SUCCESS if continuation was successful, NRF_ERROR_INTERNAL if new firmware does not + * contain softdevice or other error coming from modules used by this function. + */ +static uint32_t app_activate(void) +{ + // This function is only in use when new app is present in Bank 1 + uint32_t const image_size = s_dfu_settings.bank_1.image_size; + + uint32_t src_addr = s_dfu_settings.progress.update_start_address; + uint32_t ret_val = NRF_SUCCESS; + uint32_t target_addr = nrf_dfu_bank0_start_addr() + s_dfu_settings.write_offset; + uint32_t length_left = (image_size - s_dfu_settings.write_offset); + uint32_t crc; + + NRF_LOG_DEBUG("Enter nrf_dfu_app_continue"); + + src_addr += s_dfu_settings.write_offset; + + if (src_addr == target_addr) + { + length_left = 0; + } + + ret_val = image_copy(target_addr, src_addr, length_left, NRF_BL_FW_COPY_PROGRESS_STORE_STEP); + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed to copy firmware."); + return ret_val; + } + + // Check the CRC of the copied data. Enable if so. + crc = crc32_compute((uint8_t*)nrf_dfu_bank0_start_addr(), image_size, NULL); + + if (crc == s_dfu_settings.bank_1.image_crc) + { + NRF_LOG_DEBUG("Setting app as valid"); + s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_VALID_APP; + s_dfu_settings.bank_0.image_crc = crc; + s_dfu_settings.bank_0.image_size = image_size; + } + else + { + NRF_LOG_ERROR("CRC computation failed for copied app: " + "src crc: 0x%08x, res crc: 0x%08x", + s_dfu_settings.bank_1.image_crc, + crc); + } + + return ret_val; +} + + +/** @brief Function to execute the continuation of a SoftDevice update. + * + * @return NRF_SUCCESS if continuation was successful, NRF_ERROR_INTERNAL if new firmware does not + * contain softdevice or other error coming from modules used by this function. + */ +static uint32_t sd_activate(void) +{ + uint32_t ret_val = NRF_SUCCESS; + uint32_t target_addr = nrf_dfu_softdevice_start_address() + s_dfu_settings.write_offset; + uint32_t src_addr = s_dfu_settings.progress.update_start_address; + uint32_t sd_size = s_dfu_settings.sd_size; + uint32_t length_left = ALIGN_TO_PAGE(sd_size - s_dfu_settings.write_offset); + + NRF_LOG_DEBUG("Enter nrf_bootloader_dfu_sd_continue"); + + if (SD_MAGIC_NUMBER_GET(src_addr) != SD_MAGIC_NUMBER) + { + NRF_LOG_ERROR("Source address does not contain a valid SoftDevice.") + return NRF_ERROR_INTERNAL; + } + + // This can be a continuation due to a power failure + src_addr += s_dfu_settings.write_offset; + + if (s_dfu_settings.write_offset == sd_size) + { + NRF_LOG_DEBUG("SD already copied"); + return NRF_SUCCESS; + } + + if (s_dfu_settings.write_offset == 0) + { + NRF_LOG_DEBUG("Updating SD. Old SD ver: %d, New ver: %d", + SD_VERSION_GET(MBR_SIZE) / 1000000, SD_VERSION_GET(src_addr) / 1000000); + } + + ret_val = image_copy(target_addr, src_addr, length_left, NRF_BL_FW_COPY_PROGRESS_STORE_STEP); + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed to copy firmware."); + return ret_val; + } + + ret_val = nrf_dfu_settings_write_and_backup(NULL); + + return ret_val; +} + + +/** @brief Function to continue bootloader update. + * + * @details This function will be called after reset if there is a valid bootloader in Bank 0 or Bank 1 + * required to be relocated and activated through MBR commands. + * + * @return This function will not return if the bootloader is copied successfully. + * After the copy is verified, the device will reset and start the new bootloader. + * + * @retval NRF_SUCCESS Continuation was successful. + * @retval NRF_ERROR_INVALID_LENGTH Invalid length of flash operation. + * @retval NRF_ERROR_NO_MEM If no parameter page is provided (see sds for more info). + * @retval NRF_ERROR_INVALID_PARAM If an invalid command is given. + * @retval NRF_ERROR_INTERNAL Internal error that should not happen. + * @retval NRF_ERROR_FORBIDDEN If NRF_UICR->BOOTADDR is not set. + */ +static uint32_t bl_activate(void) +{ + uint32_t ret_val = NRF_ERROR_INVALID_DATA; + nrf_dfu_bank_t * p_bank = &s_dfu_settings.bank_1; + uint32_t len = p_bank->image_size; + uint32_t src_addr = s_dfu_settings.progress.update_start_address; + + if (p_bank->bank_code == NRF_DFU_BANK_VALID_SD_BL) + { + src_addr += s_dfu_settings.sd_size; + len -= s_dfu_settings.sd_size; + } + else if (src_addr == 0) + { + src_addr = nrf_dfu_bank1_start_addr(); + } + + NRF_LOG_DEBUG("Verifying BL: Addr: 0x%08x, Src: 0x%08x, Len: 0x%08x", BOOTLOADER_START_ADDR, src_addr, len); + + // This code is a configurable workaround for updating SD+BL from SDK 12.x.y - 14.1.0 + // SoftDevice size increase would lead to unaligned source address when comparing new BL in SD+BL updates. + // This workaround is not required once BL is successfully installed with a version that is compiled SDK 14.1.0 +#if defined(NRF52832_XXAA) && defined(BLE_STACK_SUPPORT_REQD) + if ((p_bank->bank_code == NRF_DFU_BANK_VALID_SD_BL) && + (memcmp((void *)BOOTLOADER_START_ADDR, (void *)(src_addr - 0x4000), len) == 0)) + { + ret_val = NRF_SUCCESS; + } +#endif // defined(NRF52832_XXAA) + + // Check if the BL has already been copied. + if ((ret_val != NRF_SUCCESS) && + (memcmp((void *)BOOTLOADER_START_ADDR, (void *)src_addr, len) == 0)) + { + ret_val = NRF_SUCCESS; + } + + // If the bootloader is the same as the banked version, the copy is finished + if (ret_val == NRF_SUCCESS) + { + NRF_LOG_DEBUG("No bootloader copy needed, bootloader update complete."); + } + else + { + NRF_LOG_DEBUG("Copying bootloader: Src: 0x%08x, Len: 0x%08x", src_addr, len); + NRF_LOG_FLUSH(); + + nrf_bootloader_wdt_feed(); + + // Bootloader is different than the banked version. Continue copy + // Note that if the SD and BL was combined, then the split point between them is in s_dfu_settings.sd_size + // On success this function won't return. + ret_val = nrf_dfu_mbr_copy_bl((uint32_t*)src_addr, len); + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("Request to copy BL failed"); + } + } + + return ret_val; +} + + +/** @brief Function to continue combined bootloader and SoftDevice update. + * + * @details This function will be called after reset if there is a valid bootloader and SoftDevice in Bank 0 or Bank 1 + * required to be relocated and activated through MBR commands. + * + * @retval NRF_SUCCESS Continuation was successful. + * @retval NRF_ERROR_INVALID_LENGTH Invalid length. + * @retval NRF_ERROR_NO_MEM If UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF). + * @retval NRF_ERROR_INVALID_PARAM If an invalid command is given. + * @retval NRF_ERROR_INTERNAL Indicates that the contents of the memory blocks where not verified correctly after copying. + * @retval NRF_ERROR_NULL If the content of the memory blocks differs after copying. + * @retval NRF_ERROR_FORBIDDEN If NRF_UICR->BOOTADDR is not set. + */ +static uint32_t sd_bl_activate() +{ + uint32_t ret_val = NRF_SUCCESS; + + NRF_LOG_DEBUG("Enter nrf_dfu_sd_bl_continue"); + + ret_val = sd_activate(); + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("SD+BL: SD copy failed"); + return ret_val; + } + + ret_val = bl_activate(); + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("SD+BL: BL copy failed"); + return ret_val; + } + + return ret_val; +} + + +static void flash_write_callback(void * p_context) +{ + UNUSED_PARAMETER(p_context); + m_flash_write_done = true; +} + + +nrf_bootloader_fw_activation_result_t nrf_bootloader_fw_activate(void) +{ + nrf_bootloader_fw_activation_result_t result; + uint32_t ret_val = NRF_SUCCESS; + nrf_dfu_bank_t * p_bank = &s_dfu_settings.bank_1; + bool sd_update = false; + + NRF_LOG_DEBUG("Enter nrf_bootloader_fw_activate"); + + switch (p_bank->bank_code) + { + case NRF_DFU_BANK_VALID_APP: + NRF_LOG_DEBUG("Valid App"); + ret_val = app_activate(); + break; + case NRF_DFU_BANK_VALID_SD: + NRF_LOG_DEBUG("Valid SD"); + ret_val = sd_activate(); + sd_update = true; + break; + case NRF_DFU_BANK_VALID_BL: + NRF_LOG_DEBUG("Valid BL"); + ret_val = bl_activate(); + break; + case NRF_DFU_BANK_VALID_SD_BL: + NRF_LOG_DEBUG("Valid SD + BL"); + ret_val = sd_bl_activate(); + sd_update = true; + break; + case NRF_DFU_BANK_INVALID: + default: + NRF_LOG_INFO("No firmware to activate."); + return ACTIVATION_NONE; + } + + if (ret_val != NRF_SUCCESS) + { + NRF_LOG_ERROR("Activation failed with error %d (bank code: 0x%x)", ret_val, p_bank->bank_code); + result = ACTIVATION_ERROR; + } + + // Invalidate bank, marking completion. + nrf_dfu_bank_invalidate(p_bank); + + m_flash_write_done = false; + ret_val = nrf_dfu_settings_write_and_backup(flash_write_callback); + ASSERT(m_flash_write_done); /* At this point flash module is performing blocking operation. It is expected that operation is already performed. */ + + if (ret_val == NRF_SUCCESS) + { + result = ACTIVATION_SUCCESS; + if (sd_update && (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_VALID_APP)) + { + //If SD was updated and application is valid we want to stay in DFU to receive application. + NRF_LOG_DEBUG("A SoftDevice has just been activated. It's likely that an application will come immediately"); + result = ACTIVATION_SUCCESS_EXPECT_ADDITIONAL_UPDATE; + } + } + else + { + NRF_LOG_ERROR("Could not write settings."); + result = ACTIVATION_ERROR; + } + + return result; +} + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.h index 0428d8d..635454f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu_utils.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_fw_activation.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,39 +35,35 @@ * 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 sdk_nrf_dfu_utils DFU utilities + * @defgroup nrf_bootloader_fw_activation Firmware activation * @{ - * @ingroup nrf_dfu + * @ingroup nrf_bootloader */ -#ifndef NRF_DFU_UTILS_H__ -#define NRF_DFU_UTILS_H__ +#ifndef NRF_BOOTLOADER_FW_ACTIVATION_H__ +#define NRF_BOOTLOADER_FW_ACTIVATION_H__ #include #include -#include "nrf_dfu_types.h" -#include "app_timer.h" #ifdef __cplusplus extern "C" { #endif +typedef enum +{ + ACTIVATION_NONE, //!< No new update was found. + ACTIVATION_SUCCESS, //!< Update was successfully activated. + ACTIVATION_SUCCESS_EXPECT_ADDITIONAL_UPDATE, //!< Update was successfully activated, but there might be additional update(s) to be transferred. + ACTIVATION_ERROR, //!< Activation of an update failed. +} nrf_bootloader_fw_activation_result_t; -/** @brief Function to handle timeout resets in the DFU. - * - * @warning This function will not return. - * - * param[in] p_context Unused param to comply with app timer API. - */ -void nrf_dfu_reset_timeout_handler(void * p_context); - - -/** @brief Function for continuing an ongoing DFU operation. +/** @brief Function for activating a firmware received during DFU. * * @details This function initiates or continues the DFU copy-back * routines. These routines are fail-safe operations to activate @@ -81,49 +77,20 @@ void nrf_dfu_reset_timeout_handler(void * p_context); * this function does not return, but rather initiates a reboot to activate * the new bootloader. * - * @param[in,out] p_enter_dfu_mode True if the continuation failed or the update requires DFU mode. - * - * @retval NRF_SUCCESS If the DFU operation was continued successfully. - * Any other error code indicates that the DFU operation could - * not be continued. + * @retval ACTIVATION_NONE If no update was found. + * @retval ACTIVATION_SUCCESS If the firmware update was successfully activated. + * @retval ACTIVATION_SUCCESS_EXPECT_ADDITIONAL_UPDATE If the firmware update was successfully activated, + * but there are likely more updates to be transferred. + * @retval ACTIVATION_ERROR If the firmware update could not be activated. */ -uint32_t nrf_dfu_continue(uint32_t * p_enter_dfu_mode); - +nrf_bootloader_fw_activation_result_t nrf_bootloader_fw_activate(void); -/** @brief Function for checking if the main application is valid. - * - * @details This function checks if there is a valid application - * located at Bank 0. - * - * @retval true If a valid application has been detected. - * @retval false If there is no valid application. - */ -bool nrf_dfu_app_is_valid(void); - - -/** @brief Function for finding a cache write location for the DFU process. - * - * @details This function checks the size requirements and selects a location for - * placing the cache of the DFU images. - * The function tries to find enough space in Bank 1. If there is not enough space, - * the present application is erased. - * - * @param[in] size_req Requirements for the size of the new image. - * @param[in] dual_bank_only True to enforce dual-bank updates. In this case, if there - * is not enough space for caching the DFU image, the existing - * application is retained and the function returns an error. - * @param[out] p_address Updated to the cache address if a cache location is found. - * - * @retval NRF_SUCCESS If a cache location was found for the DFU process. - * @retval NRF_ERROR_NO_MEM If there is no space available on the device to continue the DFU process. - */ -uint32_t nrf_dfu_find_cache(uint32_t size_req, bool dual_bank_only, uint32_t * p_address); #ifdef __cplusplus } #endif -#endif // NRF_DFU_UTILS_H__ +#endif // NRF_BOOTLOADER_FW_ACTIVATION_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.c similarity index 72% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.c index f3ad27f..c94830b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/nrf_bootloader_info.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,10 +35,13 @@ * 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 "nrf_bootloader_info.h" +#include "nrf_dfu_types.h" +#include "nrf_nvmc.h" +#define UICR_BOOTLOADER_ADDR 0x10001014 /** @brief This variable ensures that the linker script will write the bootloader start address * to the UICR register. This value will be written in the HEX file and thus written to @@ -47,13 +50,42 @@ #if defined (__CC_ARM ) #pragma push #pragma diag_suppress 1296 - uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOTLOADER_START_ADDRESS))) + uint32_t m_uicr_bootloader_start_address __attribute__((at(UICR_BOOTLOADER_ADDR))) = BOOTLOADER_START_ADDR; #pragma pop #elif defined ( __GNUC__ ) || defined ( __SES_ARM ) volatile uint32_t m_uicr_bootloader_start_address __attribute__ ((section(".uicr_bootloader_start_address"))) = BOOTLOADER_START_ADDR; #elif defined ( __ICCARM__ ) - __root const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOTLOADER_START_ADDRESS + __root const uint32_t m_uicr_bootloader_start_address @ UICR_BOOTLOADER_ADDR = BOOTLOADER_START_ADDR; #endif + +void nrf_bootloader_mbr_addrs_populate(void) +{ + if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF) + { + nrf_nvmc_write_word(MBR_BOOTLOADER_ADDR, BOOTLOADER_START_ADDR); + } + if (*(const uint32_t *)MBR_PARAM_PAGE_ADDR == 0xFFFFFFFF) + { + nrf_nvmc_write_word(MBR_PARAM_PAGE_ADDR, NRF_MBR_PARAMS_PAGE_ADDRESS); + } +} + + +void nrf_bootloader_debug_port_disable(void) +{ + if (NRF_UICR->APPROTECT != 0x0) + { + nrf_nvmc_write_word((uint32_t)&NRF_UICR->APPROTECT, 0x0); + NVIC_SystemReset(); + } +#if (!defined (NRF52810_XXAA) && !defined (NRF52811_XXAA) && !defined (NRF52832_XXAA) && !defined (NRF52832_XXAB)) + if (NRF_UICR->DEBUGCTRL != 0x0) + { + nrf_nvmc_write_word((uint32_t)&NRF_UICR->DEBUGCTRL, 0x0); + NVIC_SystemReset(); + } +#endif +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.h new file mode 100644 index 0000000..abb39d7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_info.h @@ -0,0 +1,210 @@ +/** + * Copyright (c) 2016 - 2019, 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 nrf_bootloader_info Bootloader Information + * @{ + * @ingroup nrf_bootloader + */ + +#ifndef NRF_BOOTLOADER_INFO_H__ +#define NRF_BOOTLOADER_INFO_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "app_util.h" +#include "nrf.h" +#include "nrf_mbr.h" + +/** @brief Macro for getting the start address of the bootloader image. + * + * The macro is not a compile time symbol. It cannot be used as a + * constant expression, for example, inside a static assert or linker script + * at-placement. + */ +#ifndef BOOTLOADER_START_ADDR +#if (__LINT__ == 1) + #define BOOTLOADER_START_ADDR (0x3AC00) +#elif defined(CODE_START) + #define BOOTLOADER_START_ADDR (CODE_START) +#else + #error Not a valid compiler/linker for BOOTLOADER_START_ADDR. +#endif +#endif + + +/** @brief Macro for getting the size of the bootloader image. + */ +#ifndef BOOTLOADER_SIZE +#if (__LINT__ == 1) + #define BOOTLOADER_SIZE (0x6000) +#elif defined ( NRF51 ) + #define BOOTLOADER_SIZE (BOOTLOADER_SETTINGS_ADDRESS - BOOTLOADER_START_ADDR) +#elif defined( NRF52_SERIES ) + #define BOOTLOADER_SIZE (NRF_MBR_PARAMS_PAGE_ADDRESS - BOOTLOADER_START_ADDR) +#endif +#endif + +// The following macros are for accessing the SoftDevice information structure, +// which is found inside the SoftDevice binary. + +/** @brief Macro for converting an offset inside the SoftDevice information struct to an absolute address. + */ +#define SD_INFO_ABS_OFFSET_GET(baseaddr, offset) ((baseaddr) + (SOFTDEVICE_INFO_STRUCT_OFFSET) + (offset)) + +/** @brief Macros for reading a byte or a word at a particular offset inside a SoftDevice information struct. + * Use MBR_SIZE as baseaddr when the SoftDevice is installed just above the MBR (the usual case). + */ +#define SD_OFFSET_GET_UINT32(baseaddr, offset) (*((uint32_t *) SD_INFO_ABS_OFFSET_GET(baseaddr, offset))) +#define SD_OFFSET_GET_UINT16(baseaddr, offset) (*((uint16_t *) SD_INFO_ABS_OFFSET_GET(baseaddr, offset))) +#define SD_OFFSET_GET_UINT8(baseaddr, offset) (*((uint8_t *) SD_INFO_ABS_OFFSET_GET(baseaddr, offset))) + + +#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD) +#include "nrf_sdm.h" +#else +/** @brief The offset inside the SoftDevice at which the information struct is placed. + * To see the layout of the information struct, see the SoftDevice specification. + */ +#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000) + +#define SD_INFO_STRUCT_SIZE(baseaddr) SD_OFFSET_GET_UINT8(baseaddr, 0x00) + +/** @brief Macro for reading the size of a SoftDevice at a given base address. + */ +#ifndef SD_SIZE_GET +#define SD_SIZE_GET(baseaddr) SD_OFFSET_GET_UINT32(baseaddr, 0x08) +#endif + +/** @brief Macro for reading the version of a SoftDevice at a given base address. + * This expression checks the length of the information struct to see if the version is present. + * The version number is constructed like this: + * major_version * 1000000 + minor_version * 1000 + bugfix_version + */ +#ifndef SD_VERSION_GET +#define SD_VERSION_GET(baseaddr) ((SD_INFO_STRUCT_SIZE(baseaddr) > (0x14)) \ + ? SD_OFFSET_GET_UINT32(baseaddr, 0x14) \ + : 0) +#endif + +/** @brief Defines a macro for retrieving the actual SoftDevice ID from a given base address. Use + * @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the + * usual case). */ +#ifndef SD_ID_GET +#define SD_ID_GET(baseaddr) ((SD_INFO_STRUCT_SIZE(baseaddr) > 0x10) \ + ? SD_OFFSET_GET_UINT32(baseaddr, 0x10) : 0) +#endif +#endif + + +/** @brief Macro for reading the magic number of a SoftDevice at a given base address. + */ +#ifndef SD_MAGIC_NUMBER_GET +#define SD_MAGIC_NUMBER_GET(baseaddr) SD_OFFSET_GET_UINT32(baseaddr, 0x04) +#endif + +/** @brief Macro for getting the absolute address of the magic number. + */ +#define SD_MAGIC_NUMBER_ABS_OFFSET_GET(baseaddr) SD_INFO_ABS_OFFSET_GET(baseaddr, 0x04) + +/** @brief The number present at a specific location in all SoftDevices. + */ +#define SD_MAGIC_NUMBER ((uint32_t)0x51B1E5DB) + +/** @brief Whether a SoftDevice is at its regular location. + */ +#ifndef SD_PRESENT +#define SD_PRESENT ((SD_MAGIC_NUMBER_GET(MBR_SIZE)) == (SD_MAGIC_NUMBER)) +#endif + +/** @brief The multiplier for the major version of the SoftDevice. See \ref SD_VERSION_GET + */ +#define SD_MAJOR_VERSION_MULTIPLIER (1000000) + +/** @brief Read the major version of the SoftDevice from the raw version number. See \ref SD_VERSION_GET. + */ +#define SD_MAJOR_VERSION_EXTRACT(raw_version) ((raw_version)/SD_MAJOR_VERSION_MULTIPLIER) + + +#define BOOTLOADER_DFU_GPREGRET_MASK (0xF8) /**< Mask for GPGPREGRET bits used for the magic pattern written to GPREGRET register to signal between main app and DFU. */ +#define BOOTLOADER_DFU_GPREGRET (0xB0) /**< Magic pattern written to GPREGRET register to signal between main app and DFU. The 3 lower bits are assumed to be used for signalling purposes.*/ +#define BOOTLOADER_DFU_START_BIT_MASK (0x01) /**< Bit mask to signal from main application to enter DFU mode using a buttonless service. */ + +#define BOOTLOADER_DFU_GPREGRET2_MASK (0xF8) /**< Mask for GPGPREGRET2 bits used for the magic pattern written to GPREGRET2 register to signal between main app and DFU. */ +#define BOOTLOADER_DFU_GPREGRET2 (0xA8) /**< Magic pattern written to GPREGRET2 register to signal between main app and DFU. The 3 lower bits are assumed to be used for signalling purposes.*/ +#define BOOTLOADER_DFU_SKIP_CRC_BIT_MASK (0x01) /**< Bit mask to signal from main application that CRC-check is not needed for image verification. */ + + +#define BOOTLOADER_DFU_START (BOOTLOADER_DFU_GPREGRET | BOOTLOADER_DFU_START_BIT_MASK) /**< Magic number to signal that bootloader should enter DFU mode because of signal from Buttonless DFU in main app.*/ +#define BOOTLOADER_DFU_SKIP_CRC (BOOTLOADER_DFU_GPREGRET2 | BOOTLOADER_DFU_SKIP_CRC_BIT_MASK) /**< Magic number to signal that CRC can be skipped due to low power modes.*/ + + +/** @brief Macro based on @c NRF_DFU_DEBUG_VERSION that can be checked for true/false instead of defined/not defined. + */ +#ifndef NRF_DFU_DEBUG +#ifdef NRF_DFU_DEBUG_VERSION +#define NRF_DFU_DEBUG 1 +#else +#define NRF_DFU_DEBUG 0 +#endif +#endif + +/** @brief Function for populating addresses in the MBR code page. + * + * This function writes two words to flash if the flash is 0xFFFFFFFF. This is done in code because + * doing this through the hex file interferes with flashing algorithms. See nrf_mbr.h. + */ +void nrf_bootloader_mbr_addrs_populate(void); + +/** @brief Function for checking if the debug port access is disabled. + * + * If the debug port access is enabled, disable it. This function checks and writes to the UICR + * registers APPROTECT and DEBUGCTRL. + */ +void nrf_bootloader_debug_port_disable(void); + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef NRF_BOOTLOADER_INFO_H__ +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.c similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.c index 3e96cff..493ff24 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/ble/ble_services/experimental_ble_ots/ble_hvx_buffering.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,68 +35,87 @@ * 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 "nrf_bootloader_wdt.h" +#include "nrf_wdt.h" +#include "nrf_bootloader_dfu_timers.h" +#include "nrf_log_ctrl.h" -#include "ble_hvx_buffering.h" -#include +#define NRF_LOG_MODULE_NAME nrf_bootloader_wdt +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); -uint32_t ble_hvx_init(ble_hvx_buf_t * p_ble_hvx_buf) + +static void wdt_feed(void) { - if (p_ble_hvx_buf == NULL) + if (nrf_wdt_started()) { - return NRF_ERROR_NULL; + for (nrf_wdt_rr_register_t i = NRF_WDT_RR0; i < NRF_WDT_RR7; i++) + { + if (nrf_wdt_reload_request_is_enabled(i)) + { + nrf_wdt_reload_request_set(i); + } + } } - - p_ble_hvx_buf->insert_index = 0; - p_ble_hvx_buf->read_index = 0; +} + - return NRF_SUCCESS; +static void wdt_feed_timer_handler(void) +{ + NRF_LOG_INFO("Internal feed"); + wdt_feed(); } -ble_hvx_t * ble_hvx_get_p_to_next_hvx(ble_hvx_buf_t * p_ble_hvx_buf) + +void WDT_IRQHandler(void) { - ble_hvx_t * p_hvx; - p_hvx = &p_ble_hvx_buf->buf[p_ble_hvx_buf->insert_index++]; - - p_hvx->params.p_data = p_hvx->data; - p_hvx->params.p_len = &p_hvx->data_len; - - p_ble_hvx_buf->insert_index &= BLE_HVX_BUF_MASK; - return p_hvx; + nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT); + NRF_LOG_FINAL_FLUSH(); } +#define MAX_FLASH_OP_TIME_TICKS 3200 // ~100 ms -uint32_t ble_hvx_buffer_process(ble_hvx_buf_t * p_ble_hvx_buf) +void nrf_bootloader_wdt_init(void) { - uint32_t err_code; - while (p_ble_hvx_buf->read_index != p_ble_hvx_buf->insert_index) + static bool initialized = false; + + if (initialized) { - - ble_gatts_hvx_params_t * p_hvx_params; - - p_hvx_params = &p_ble_hvx_buf->buf[p_ble_hvx_buf->read_index].params; - err_code = sd_ble_gatts_hvx(p_ble_hvx_buf->buf[p_ble_hvx_buf->read_index].conn_handle, p_hvx_params); + return; + } - if (err_code == NRF_SUCCESS) - { - p_ble_hvx_buf->read_index++; - p_ble_hvx_buf->read_index &= BLE_HVX_BUF_MASK; - } - else - { - if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) - { - return NRF_SUCCESS; // not a critical error. - } - else - { - // remove element from buffer - p_ble_hvx_buf->insert_index--; - p_ble_hvx_buf->insert_index &= BLE_HVX_BUF_MASK; - return err_code; - } - } + if (nrf_wdt_started()) + { + uint32_t wdt_ticks = nrf_wdt_reload_value_get(); + + NRF_LOG_INFO("WDT enabled CRV:%d ticks", wdt_ticks); + + //wdt_ticks must be reduced to feed the watchdog before the timeout. + uint32_t reduced_timeout_ticks = MAX((int32_t)wdt_ticks - MAX_FLASH_OP_TIME_TICKS, + NRF_BOOTLOADER_MIN_TIMEOUT_TICKS); + + /* initial watchdog feed */ + wdt_feed(); + + NRF_LOG_INFO("Starting a timer (%d ticks) for feeding watchdog.", reduced_timeout_ticks); + nrf_bootloader_wdt_feed_timer_start(reduced_timeout_ticks, wdt_feed_timer_handler); + + NVIC_EnableIRQ(WDT_IRQn); + } + else + { + NRF_LOG_INFO("WDT is not enabled"); + } + + initialized = true; +} + +void nrf_bootloader_wdt_feed(void) +{ + if (nrf_wdt_started()) + { + wdt_feed(); } - return NRF_SUCCESS; } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.h new file mode 100644 index 0000000..2656202 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/nrf_bootloader_wdt.h @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRF_BOOTLOADER_WDT_H +#define NRF_BOOTLOADER_WDT_H + +/**@file + * + * @defgroup nrf_bootloader_wdt Automated feeding of the watchdog + * @{ + * @ingroup nrf_bootloader + * @brief Module that keeps the WDT from timing out if the WDT has been started in the application. + */ + +#include "sdk_errors.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Function for checking whether the WDT peripheral is started and for getting its configuration. + * + * The module uses a timer to start regular feeding of the watchdog. Timer interval + * is chosen based on watchdog settings. When @ref nrf_bootloader_wdt_feed is called, internal + * feeding is stopped assuming that the application takes responsibity of watchdog feeding. + * However, if @ref NRF_BL_WDT_MAX_SCHEDULER_LATENCY_MS or the watchdog is configured to + * run during sleep, then internal feeding (from timeout handler context) is kept active. + */ +void nrf_bootloader_wdt_init(void); + + +/** + * @brief Function for feeding the watchdog (if active). + */ +void nrf_bootloader_wdt_feed(void); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif //NRF_BOOTLOADER_WDT_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.c new file mode 100644 index 0000000..f826ead --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.c @@ -0,0 +1,273 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf_dfu_serial.h" +#include "nrf_dfu_req_handler.h" +#include "nrf_dfu_handling_error.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_serial +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define NRF_SERIAL_OPCODE_SIZE (sizeof(uint8_t)) + +#if defined(NRF_DFU_PROTOCOL_REDUCED) && NRF_DFU_PROTOCOL_REDUCED + #error Serial DFU (UART and USB) cannot function with the reduced protocol set. +#endif + +static uint32_t response_ext_err_payload_add(uint8_t * p_buffer, uint32_t buf_offset) +{ + p_buffer[buf_offset] = ext_error_get(); + (void) ext_error_set(NRF_DFU_EXT_ERROR_NO_ERROR); + + return 1; +} + + +static void response_send(nrf_dfu_serial_t * p_transport, + nrf_dfu_response_t const * p_response) +{ + uint8_t index = 0; + uint8_t * p_serialized_rsp = p_transport->p_rsp_buf; + + NRF_LOG_DEBUG("Sending Response: [0x%01x, 0x%01x]", p_response->request, p_response->result); + + p_serialized_rsp[index++] = NRF_DFU_OP_RESPONSE; + p_serialized_rsp[index++] = p_response->request; + p_serialized_rsp[index++] = (uint8_t)(p_response->result); + + if (p_response->result == NRF_DFU_RES_CODE_SUCCESS) + { + switch (p_response->request) + { + case NRF_DFU_OP_PROTOCOL_VERSION: + { + p_serialized_rsp[index] = p_response->protocol.version; + index += sizeof(uint8_t); + } break; + + case NRF_DFU_OP_HARDWARE_VERSION: + { + index += uint32_encode(p_response->hardware.part, &p_serialized_rsp[index]); + index += uint32_encode(p_response->hardware.variant, &p_serialized_rsp[index]); + index += uint32_encode(p_response->hardware.memory.rom_size, &p_serialized_rsp[index]); + index += uint32_encode(p_response->hardware.memory.ram_size, &p_serialized_rsp[index]); + index += uint32_encode(p_response->hardware.memory.rom_page_size, &p_serialized_rsp[index]); + } break; + + case NRF_DFU_OP_FIRMWARE_VERSION: + { + p_serialized_rsp[index++] = p_response->firmware.type; + index += uint32_encode(p_response->firmware.version, &p_serialized_rsp[index]); + index += uint32_encode(p_response->firmware.addr, &p_serialized_rsp[index]); + index += uint32_encode(p_response->firmware.len, &p_serialized_rsp[index]); + } break; + + case NRF_DFU_OP_CRC_GET: + index += uint32_encode(p_response->crc.offset, &p_serialized_rsp[index]); + index += uint32_encode(p_response->crc.crc, &p_serialized_rsp[index]); + break; + + case NRF_DFU_OP_OBJECT_SELECT: + index += uint32_encode(p_response->select.max_size, &p_serialized_rsp[index]); + index += uint32_encode(p_response->select.offset, &p_serialized_rsp[index]); + index += uint32_encode(p_response->select.crc, &p_serialized_rsp[index]); + break; + + case NRF_DFU_OP_MTU_GET: + index += uint16_encode(p_response->mtu.size, &p_serialized_rsp[index]); + break; + + case NRF_DFU_OP_PING: + p_serialized_rsp[index] = p_response->ping.id; + index += sizeof(uint8_t); + break; + + default: + // no implementation + break; + } + } + else if (p_response->result == NRF_DFU_RES_CODE_EXT_ERROR) + { + index += response_ext_err_payload_add(p_serialized_rsp, index); + } + + if (index > NRF_SERIAL_MAX_RESPONSE_SIZE) + { + NRF_LOG_ERROR("Message is larger than expected."); + } + + // Send response. + if (p_transport->rsp_func((uint8_t const *)(p_serialized_rsp), index) != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed to send data over serial interface!"); + } +} + + +void dfu_req_handler_rsp_clbk(nrf_dfu_response_t * p_res, void * p_context) +{ + nrf_dfu_serial_t * p_transport = (nrf_dfu_serial_t *)(p_context); + + if (p_res->result != NRF_DFU_RES_CODE_SUCCESS) + { + NRF_LOG_WARNING("DFU request completed with result: 0x%x", p_res->result); + } + + switch (p_res->request) + { + default: + /* Reply normally. + * Make sure to reply to NRF_DFU_OP_OBJECT_CREATE when running DFU over serial, + * otherwise the transfer might run very slow, without an apparent reason. + */ + break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + p_transport->pkt_notif_target_count--; + + if ( (p_transport->pkt_notif_target == 0) + || (p_transport->pkt_notif_target_count != 0)) + { + /* Do not reply to _OBJECT_WRITE messages. */ + return; + } + + /* Reply with a CRC message and reset the packet counter. */ + p_transport->pkt_notif_target_count = p_transport->pkt_notif_target; + + p_res->request = NRF_DFU_OP_CRC_GET; + p_res->crc.offset = p_res->write.offset; + p_res->crc.crc = p_res->write.crc; + } break; + } + + response_send(p_transport, p_res); +} + + +void nrf_dfu_serial_on_packet_received(nrf_dfu_serial_t * p_transport, + uint8_t const * p_data, + uint32_t length) +{ + uint8_t const * p_payload = &p_data[NRF_SERIAL_OPCODE_SIZE]; + uint16_t const payload_len = (length - NRF_SERIAL_OPCODE_SIZE); + + nrf_dfu_request_t request = + { + .request = (nrf_dfu_op_t)(p_data[0]), + .callback.response = dfu_req_handler_rsp_clbk, + .p_context = p_transport + }; + + bool buf_free = true; + + switch (request.request) + { + case NRF_DFU_OP_FIRMWARE_VERSION: + { + request.firmware.image_number = p_payload[0]; + } break; + + case NRF_DFU_OP_RECEIPT_NOTIF_SET: + { + NRF_LOG_DEBUG("Set receipt notif target: %d", p_transport->pkt_notif_target); + + p_transport->pkt_notif_target = uint16_decode(&p_payload[0]); + p_transport->pkt_notif_target_count = p_transport->pkt_notif_target; + } break; + + case NRF_DFU_OP_OBJECT_SELECT: + { + request.select.object_type = p_payload[0]; + } break; + + case NRF_DFU_OP_OBJECT_CREATE: + { + // Reset the packet receipt notification on create object + p_transport->pkt_notif_target_count = p_transport->pkt_notif_target; + + request.create.object_type = p_payload[0]; + request.create.object_size = uint32_decode(&p_payload[1]); + + if (request.create.object_type == NRF_DFU_OBJ_TYPE_COMMAND) + { + /* Activity on the current transport. Close all except the current one. */ + (void) nrf_dfu_transports_close(p_transport->p_low_level_transport); + } + } break; + + case NRF_DFU_OP_OBJECT_WRITE: + { + // Buffer will be freed asynchronously + buf_free = false; + + request.write.p_data = p_payload; + request.write.len = payload_len; + request.callback.write = p_transport->payload_free_func; + } break; + + case NRF_DFU_OP_MTU_GET: + { + NRF_LOG_DEBUG("Received serial mtu"); + request.mtu.size = p_transport->mtu; + } break; + + case NRF_DFU_OP_PING: + { + NRF_LOG_DEBUG("Received ping %d", p_payload[0]); + request.ping.id = p_payload[0]; + } break; + + default: + /* Do nothing. */ + break; + } + + if (buf_free) + { + p_transport->payload_free_func((void *)(p_payload)); + } + + ret_code_t ret_code = nrf_dfu_req_handler_on_req(&request); + ASSERT(ret_code == NRF_SUCCESS); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.h new file mode 100644 index 0000000..7e85147 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial.h @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRF_DFU_SERIAL_H__ +#define NRF_DFU_SERIAL_H__ + +#include +#include "sdk_errors.h" +#include "nrf_dfu_req_handler.h" +#include "nrf_dfu_transport.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/**@file + * + * @defgroup nrf_dfu_serial DFU Serial transports shared part + * @{ + * @ingroup nrf_dfu + * @brief Shared part of Device Firmware Update (DFU) transport layers using serial interface (UART, USB CDC ACM). + * + * @defgroup nrf_dfu_serial_uart DFU Serial UART transport + * @ingroup nrf_dfu_serial + * @brief Configuration for Device Firmware Update (DFU) transport layer using UART. + * + * @defgroup nrf_dfu_serial_usb DFU Serial USB CDC ACM transport + * @ingroup nrf_dfu_serial + * @brief Configuration for Device Firmware Update (DFU) transport layer using USB CDC ACM. + * + */ + +#define NRF_SERIAL_MAX_RESPONSE_SIZE (sizeof(nrf_dfu_response_t)) + +/** + * Prototype for function for sending response over serial DFU transport. + */ +typedef ret_code_t (*nrf_serial_rsp_func_t)(uint8_t const * p_data, uint32_t length); + +/** + * Prototype for function for freeing RX buffer. + * + * Function is called when input data is processed. + */ +typedef void (*nrf_serial_rx_buf_free_func_t)(void * p_buf); + + +/**@brief DFU serial transport layer state. + * + * @details This structure contains status information related to the serial transport layer type. + */ +typedef struct +{ + uint16_t pkt_notif_target; + uint16_t pkt_notif_target_count; + nrf_serial_rsp_func_t rsp_func; + nrf_serial_rx_buf_free_func_t payload_free_func; + uint32_t mtu; + uint8_t * p_rsp_buf; + nrf_dfu_transport_t const * p_low_level_transport; +} nrf_dfu_serial_t; + +void nrf_dfu_serial_on_packet_received(nrf_dfu_serial_t * p_transport, + uint8_t const * p_data, + uint32_t length); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DFU_SERIAL_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_uart.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_uart.c new file mode 100644 index 0000000..90763eb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_uart.c @@ -0,0 +1,238 @@ +/** + * Copyright (c) 2016 - 2019, 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 "nrf_dfu_serial.h" + +#include +#include "boards.h" +#include "app_util_platform.h" +#include "nrf_dfu_transport.h" +#include "nrf_dfu_req_handler.h" +#include "slip.h" +#include "nrf_balloc.h" +#include "nrf_drv_uart.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_serial_uart +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/**@file + * + * @defgroup nrf_dfu_serial_uart DFU Serial UART transport + * @ingroup nrf_dfu + * @brief Device Firmware Update (DFU) transport layer using UART. + */ + +#define NRF_SERIAL_OPCODE_SIZE (sizeof(uint8_t)) +#define NRF_UART_MAX_RESPONSE_SIZE_SLIP (2 * NRF_SERIAL_MAX_RESPONSE_SIZE + 1) +#define RX_BUF_SIZE (64) //to get 64bytes payload +#define OPCODE_OFFSET (sizeof(uint32_t) - NRF_SERIAL_OPCODE_SIZE) +#define DATA_OFFSET (OPCODE_OFFSET + NRF_SERIAL_OPCODE_SIZE) +#define UART_SLIP_MTU (2 * (RX_BUF_SIZE + 1) + 1) +#define BALLOC_BUF_SIZE ((CEIL_DIV((RX_BUF_SIZE+OPCODE_SIZE),sizeof(uint32_t))*sizeof(uint32_t))) + +NRF_BALLOC_DEF(m_payload_pool, (UART_SLIP_MTU + 1), NRF_DFU_SERIAL_UART_RX_BUFFERS); + +static nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(0); +static uint8_t m_rx_byte; + +static nrf_dfu_serial_t m_serial; +static slip_t m_slip; +static uint8_t m_rsp_buf[NRF_UART_MAX_RESPONSE_SIZE_SLIP]; +static bool m_active; + +static nrf_dfu_observer_t m_observer; + +static uint32_t uart_dfu_transport_init(nrf_dfu_observer_t observer); +static uint32_t uart_dfu_transport_close(nrf_dfu_transport_t const * p_exception); + +DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const uart_dfu_transport) = +{ + .init_func = uart_dfu_transport_init, + .close_func = uart_dfu_transport_close, +}; + +static void payload_free(void * p_buf) +{ + uint8_t * p_buf_root = (uint8_t *)p_buf - DATA_OFFSET; //pointer is shifted to point to data + nrf_balloc_free(&m_payload_pool, p_buf_root); +} + +static ret_code_t rsp_send(uint8_t const * p_data, uint32_t length) +{ + uint32_t slip_len; + (void) slip_encode(m_rsp_buf, (uint8_t *)p_data, length, &slip_len); + + return nrf_drv_uart_tx(&m_uart, m_rsp_buf, slip_len); +} + +static __INLINE void on_rx_complete(nrf_dfu_serial_t * p_transport, uint8_t * p_data, uint8_t len) +{ + ret_code_t ret_code = NRF_ERROR_TIMEOUT; + + // Check if there is byte to process. Zero length transfer means that RXTO occured. + if (len) + { + ret_code = slip_decode_add_byte(&m_slip, p_data[0]); + } + + (void) nrf_drv_uart_rx(&m_uart, &m_rx_byte, 1); + + if (ret_code == NRF_SUCCESS) + { + nrf_dfu_serial_on_packet_received(p_transport, + (uint8_t const *)m_slip.p_buffer, + m_slip.current_index); + + uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool); + if (p_rx_buf == NULL) + { + NRF_LOG_ERROR("Failed to allocate buffer"); + return; + } + NRF_LOG_INFO("Allocated buffer %x", p_rx_buf); + // reset the slip decoding + m_slip.p_buffer = &p_rx_buf[OPCODE_OFFSET]; + m_slip.current_index = 0; + m_slip.state = SLIP_STATE_DECODING; + } + +} + +static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) +{ + switch (p_event->type) + { + case NRF_DRV_UART_EVT_RX_DONE: + on_rx_complete((nrf_dfu_serial_t*)p_context, + p_event->data.rxtx.p_data, + p_event->data.rxtx.bytes); + break; + + case NRF_DRV_UART_EVT_ERROR: + APP_ERROR_HANDLER(p_event->data.error.error_mask); + break; + + default: + // No action. + break; + } +} + +static uint32_t uart_dfu_transport_init(nrf_dfu_observer_t observer) +{ + uint32_t err_code = NRF_SUCCESS; + + if (m_active) + { + return err_code; + } + + NRF_LOG_DEBUG("serial_dfu_transport_init()"); + + m_observer = observer; + + err_code = nrf_balloc_init(&m_payload_pool); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool); + + m_slip.p_buffer = &p_rx_buf[OPCODE_OFFSET]; + m_slip.current_index = 0; + m_slip.buffer_len = UART_SLIP_MTU; + m_slip.state = SLIP_STATE_DECODING; + + m_serial.rsp_func = rsp_send; + m_serial.payload_free_func = payload_free; + m_serial.mtu = UART_SLIP_MTU; + m_serial.p_rsp_buf = &m_rsp_buf[NRF_UART_MAX_RESPONSE_SIZE_SLIP - + NRF_SERIAL_MAX_RESPONSE_SIZE]; + m_serial.p_low_level_transport = &uart_dfu_transport; + + nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG; + + uart_config.pseltxd = TX_PIN_NUMBER; + uart_config.pselrxd = RX_PIN_NUMBER; + uart_config.pselcts = CTS_PIN_NUMBER; + uart_config.pselrts = RTS_PIN_NUMBER; + uart_config.hwfc = NRF_DFU_SERIAL_UART_USES_HWFC ? + NRF_UART_HWFC_ENABLED : NRF_UART_HWFC_DISABLED; + uart_config.p_context = &m_serial; + + err_code = nrf_drv_uart_init(&m_uart, &uart_config, uart_event_handler); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed initializing uart"); + return err_code; + } + + err_code = nrf_drv_uart_rx(&m_uart, &m_rx_byte, 1); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Failed initializing rx"); + } + + NRF_LOG_DEBUG("serial_dfu_transport_init() completed"); + + m_active = true; + + if (m_observer) + { + m_observer(NRF_DFU_EVT_TRANSPORT_ACTIVATED); + } + + return err_code; +} + + +static uint32_t uart_dfu_transport_close(nrf_dfu_transport_t const * p_exception) +{ + if ((m_active == true) && (p_exception != &uart_dfu_transport)) + { + nrf_drv_uart_uninit(&m_uart); + m_active = false; + } + + return NRF_SUCCESS; +} + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_usb.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_usb.c new file mode 100644 index 0000000..6d5ffd2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bootloader/serial_dfu/nrf_dfu_serial_usb.c @@ -0,0 +1,368 @@ +/** + * Copyright (c) 2016 - 2019, 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 +#include "nrf_dfu_req_handler.h" +#include "nrf_dfu_transport.h" +#include "slip.h" +#include "nrf_balloc.h" +#include "nrf_drv_power.h" +#include "nrf_drv_clock.h" +#include "nrf_drv_usbd.h" +#include "nrf_dfu_serial.h" +#include "app_scheduler.h" +#include "app_usbd.h" +#include "app_usbd_cdc_acm.h" +#include "app_usbd_core.h" +#include "app_usbd_string_desc.h" +#include "app_util_platform.h" +#include "app_usbd_serial_num.h" + +#define NRF_LOG_MODULE_NAME nrf_dfu_serial_usb +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/**@file + * + * @defgroup nrf_dfu_serial_usb DFU Serial USB CDC ACM transport + * @ingroup nrf_dfu + * @brief Device Firmware Update (DFU) transport layer using USB CDC ACM. + */ + +#define NRF_SERIAL_OPCODE_SIZE (sizeof(uint8_t)) + +#define NRF_USB_MAX_RESPONSE_SIZE_SLIP (2 * NRF_SERIAL_MAX_RESPONSE_SIZE + 1) + +#define RX_BUF_SIZE (1024) +#define SLIP_MTU (2 * (RX_BUF_SIZE + 1) + 1) +#define OPCODE_OFFSET (sizeof(uint32_t) - NRF_SERIAL_OPCODE_SIZE) +#define DATA_OFFSET (OPCODE_OFFSET + NRF_SERIAL_OPCODE_SIZE) + +#define CDC_ACM_COMM_INTERFACE 0 +#define CDC_ACM_COMM_EPIN NRF_DRV_USBD_EPIN2 +#define CDC_ACM_DATA_INTERFACE 1 +#define CDC_ACM_DATA_EPIN NRF_DRV_USBD_EPIN1 +#define CDC_ACM_DATA_EPOUT NRF_DRV_USBD_EPOUT1 + +/** + * @brief Enable power USB detection + * + * Configure if example supports USB port connection + */ +#ifndef USBD_POWER_DETECTION +#define USBD_POWER_DETECTION true +#endif + +/** + * @brief Interfaces list passed to @ref APP_USBD_CDC_ACM_GLOBAL_DEF + * */ +#define CDC_ACM_INTERFACES_CONFIG() \ + APP_USBD_CDC_ACM_CONFIG(CDC_ACM_COMM_INTERFACE, \ + CDC_ACM_COMM_EPIN, \ + CDC_ACM_DATA_INTERFACE, \ + CDC_ACM_DATA_EPIN, \ + CDC_ACM_DATA_EPOUT) + +/*lint -save -e26 -e64 -e505 -e651 */ +static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_cdc_acm_user_event_t event); + +/**@brief CDC_ACM class instance. */ +APP_USBD_CDC_ACM_GLOBAL_DEF(m_app_cdc_acm, + cdc_acm_user_ev_handler, + CDC_ACM_COMM_INTERFACE, + CDC_ACM_DATA_INTERFACE, + CDC_ACM_COMM_EPIN, + CDC_ACM_DATA_EPIN, + CDC_ACM_DATA_EPOUT, + APP_USBD_CDC_COMM_PROTOCOL_NONE); +/*lint -restore */ + +NRF_BALLOC_DEF(m_payload_pool, (SLIP_MTU+1), NRF_DFU_SERIAL_USB_RX_BUFFERS); + +static nrf_dfu_serial_t m_serial; +static slip_t m_slip; +static uint8_t m_rsp_buf[NRF_USB_MAX_RESPONSE_SIZE_SLIP]; +static uint8_t m_rx_buf[NRF_DRV_USBD_EPSIZE]; + +static nrf_dfu_observer_t m_observer; + +static uint32_t usb_dfu_transport_init(nrf_dfu_observer_t observer); +static uint32_t usb_dfu_transport_close(nrf_dfu_transport_t const * p_exception); + + +DFU_TRANSPORT_REGISTER(nrf_dfu_transport_t const usb_dfu_transport) = +{ + .init_func = usb_dfu_transport_init, + .close_func = usb_dfu_transport_close, +}; + + +static void payload_free(void * p_buf) +{ + uint8_t * p_buf_root = ((uint8_t *)(p_buf)) - DATA_OFFSET; //pointer is shifted to point to data + nrf_balloc_free(&m_payload_pool, p_buf_root); +} + + +static ret_code_t rsp_send(uint8_t const * p_data, uint32_t length) +{ + ASSERT(p_data); + ASSERT(length != 0); + + uint32_t slip_len; + + // Cannot fail if inputs are non-NULL. + (void) slip_encode(m_rsp_buf, (uint8_t *)(p_data), length, &slip_len); + + return app_usbd_cdc_acm_write(&m_app_cdc_acm, m_rsp_buf, slip_len); +} + + +static void on_rx_complete(nrf_dfu_serial_t * p_transport, uint8_t * p_data, uint8_t len) +{ + ret_code_t ret_code; + + for (uint32_t i = 0; i < len; i++) + { + ret_code = slip_decode_add_byte(&m_slip, p_data[i]); + if (ret_code != NRF_SUCCESS) + { + continue; + } + + nrf_dfu_serial_on_packet_received(p_transport, + (uint8_t const *)(m_slip.p_buffer), + m_slip.current_index); + + uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool); + if (p_rx_buf == NULL) + { + NRF_LOG_ERROR("Failed to allocate buffer!"); + return; + } + + NRF_LOG_DEBUG("Allocated buffer %x", p_rx_buf); + // reset the slip decoding + m_slip.p_buffer = &p_rx_buf[OPCODE_OFFSET]; + m_slip.current_index = 0; + m_slip.state = SLIP_STATE_DECODING; + } +} + +/** + * @brief User event handler @ref app_usbd_cdc_acm_user_ev_handler_t (headphones) + * */ +static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_cdc_acm_user_event_t event) +{ + ret_code_t ret_code; + + switch (event) + { + case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN: + { + ret_code = app_usbd_cdc_acm_read(&m_app_cdc_acm, m_rx_buf, 1); + NRF_LOG_WARNING("Could not read from CDC. Error: 0x%x.", ret_code); + } break; + + case APP_USBD_CDC_ACM_USER_EVT_RX_DONE: + { + do + { + on_rx_complete(&m_serial, m_rx_buf, 1); + ret_code = app_usbd_cdc_acm_read(&m_app_cdc_acm, m_rx_buf, 1); + } while (ret_code == NRF_SUCCESS); + } break; + + default: + break; + } +} + + +static void usbd_dfu_transport_ev_handler(app_usbd_event_type_t event) +{ + switch (event) + { + case APP_USBD_EVT_STOPPED: + app_usbd_disable(); + break; + + case APP_USBD_EVT_POWER_DETECTED: + NRF_LOG_INFO("USB power detected"); + if (!nrf_drv_usbd_is_enabled()) + { + app_usbd_enable(); + } + + if (m_observer) + { + m_observer(NRF_DFU_EVT_TRANSPORT_ACTIVATED); + } + break; + + case APP_USBD_EVT_POWER_REMOVED: + NRF_LOG_INFO("USB power removed"); + app_usbd_stop(); + if (m_observer) + { + m_observer(NRF_DFU_EVT_TRANSPORT_DEACTIVATED); + } + break; + + case APP_USBD_EVT_POWER_READY: + NRF_LOG_INFO("USB ready"); + app_usbd_start(); + break; + + default: + break; + } +} + + +static void usbd_sched_event_handler(void * p_event_data, uint16_t event_size) +{ + app_usbd_event_execute(p_event_data); +} + + +static void usbd_event_handler(app_usbd_internal_evt_t const * const p_event) +{ + ret_code_t ret_code; + if (p_event->type == APP_USBD_EVT_DRV_SOF) + { + app_usbd_event_execute(p_event); + } + else + { + ret_code = app_sched_event_put(p_event, + sizeof(app_usbd_internal_evt_t), + usbd_sched_event_handler); + + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("Could not schedule USB event!"); + } + } +} + + +static uint32_t usb_dfu_transport_init(nrf_dfu_observer_t observer) +{ + uint32_t err_code; + + /* Execute event directly in interrupt handler */ + static const app_usbd_config_t usbd_config = + { + .ev_handler = usbd_event_handler, + .ev_state_proc = usbd_dfu_transport_ev_handler + }; + + (void) nrf_balloc_init(&m_payload_pool); //Result is checked by checking result of _alloc(). + + m_observer = observer; + + uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool); + if (p_rx_buf == NULL) + { + NRF_LOG_ERROR("Could not allocate payload pool."); + return NRF_ERROR_INTERNAL; + } + + m_slip.p_buffer = &p_rx_buf[OPCODE_OFFSET]; + m_slip.current_index = 0; + m_slip.buffer_len = SLIP_MTU; + m_slip.state = SLIP_STATE_DECODING; + + m_serial.rsp_func = rsp_send; + m_serial.payload_free_func = payload_free; + m_serial.mtu = SLIP_MTU; + m_serial.p_rsp_buf = &m_rsp_buf[NRF_USB_MAX_RESPONSE_SIZE_SLIP - + NRF_SERIAL_MAX_RESPONSE_SIZE]; + m_serial.p_low_level_transport = &usb_dfu_transport; + + + NRF_LOG_DEBUG("Initializing drivers."); + + err_code = nrf_drv_clock_init(); + if (err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED) + { + VERIFY_SUCCESS(err_code); + } + + err_code = nrf_drv_power_init(NULL); + VERIFY_SUCCESS(err_code); + + app_usbd_serial_num_generate(); + + err_code = app_usbd_init(&usbd_config); + VERIFY_SUCCESS(err_code); + + app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm); + err_code = app_usbd_class_append(class_cdc_acm); + VERIFY_SUCCESS(err_code); + + NRF_LOG_DEBUG("Starting USB"); + + if (USBD_POWER_DETECTION) + { + err_code = app_usbd_power_events_enable(); + VERIFY_SUCCESS(err_code); + } + else + { + NRF_LOG_DEBUG("No USB power detection enabled, starting USB now"); + + app_usbd_enable(); + app_usbd_start(); + } + + NRF_LOG_DEBUG("USB Transport initialized"); + + return err_code; +} + + +static uint32_t usb_dfu_transport_close(nrf_dfu_transport_t const * p_exception) +{ + return NRF_SUCCESS; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp.c similarity index 86% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp.c index 4efa394..d4f0a5c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "bsp.h" #include @@ -57,15 +57,15 @@ static bsp_indication_t m_stable_state = BSP_INDICATE_IDLE; static bool m_leds_clear = false; static uint32_t m_indication_type = 0; static bool m_alert_on = false; -APP_TIMER_DEF(m_leds_timer_id); -APP_TIMER_DEF(m_alert_timer_id); +APP_TIMER_DEF(m_bsp_leds_tmr); +APP_TIMER_DEF(m_bsp_alert_tmr); #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) #if BUTTONS_NUMBER > 0 #ifndef BSP_SIMPLE static bsp_event_callback_t m_registered_callback = NULL; static bsp_button_event_cfg_t m_events_list[BUTTONS_NUMBER] = {{BSP_EVENT_NOTHING, BSP_EVENT_NOTHING}}; -APP_TIMER_DEF(m_button_timer_id); +APP_TIMER_DEF(m_bsp_button_tmr); static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action); #endif // BSP_SIMPLE @@ -111,7 +111,15 @@ static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] = #if (BUTTONS_NUMBER > 0) bool bsp_button_is_pressed(uint32_t button) { - return bsp_board_button_state_get(button); + if (button < BUTTONS_NUMBER) + { + return bsp_board_button_state_get(button); + } + else + { + //If button is not present always return false + return false; + } } #endif @@ -139,7 +147,7 @@ static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action) event = m_events_list[button].push_event; if (m_events_list[button].long_push_event != BSP_EVENT_NOTHING) { - err_code = app_timer_start(m_button_timer_id, APP_TIMER_TICKS(BSP_LONG_PUSH_TIMEOUT_MS), (void*)¤t_long_push_pin_no); + err_code = app_timer_start(m_bsp_button_tmr, APP_TIMER_TICKS(BSP_LONG_PUSH_TIMEOUT_MS), (void*)¤t_long_push_pin_no); if (err_code == NRF_SUCCESS) { current_long_push_pin_no = pin_no; @@ -148,7 +156,7 @@ static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action) release_event_at_push[button] = m_events_list[button].release_event; break; case APP_BUTTON_RELEASE: - (void)app_timer_stop(m_button_timer_id); + (void)app_timer_stop(m_bsp_button_tmr); if (release_event_at_push[button] == m_events_list[button].release_event) { event = m_events_list[button].release_event; @@ -217,6 +225,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) { case BSP_INDICATE_IDLE: leds_off(); + err_code = app_timer_stop(m_bsp_leds_tmr); m_stable_state = indicate; break; @@ -239,7 +248,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) } m_stable_state = indicate; - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(next_delay), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL); break; case BSP_INDICATE_ADVERTISING_WHITELIST: @@ -261,7 +270,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) ADVERTISING_SLOW_LED_ON_INTERVAL; } m_stable_state = indicate; - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(next_delay), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL); break; case BSP_INDICATE_ADVERTISING_SLOW: @@ -281,7 +290,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) ADVERTISING_SLOW_LED_ON_INTERVAL; } m_stable_state = indicate; - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(next_delay), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL); break; case BSP_INDICATE_ADVERTISING_DIRECTED: @@ -303,7 +312,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) ADVERTISING_SLOW_LED_ON_INTERVAL; } m_stable_state = indicate; - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(next_delay), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL); break; case BSP_INDICATE_BONDING: @@ -312,7 +321,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) m_stable_state = indicate; err_code = - app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(BONDING_INTERVAL), NULL); + app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(BONDING_INTERVAL), NULL); break; case BSP_INDICATE_CONNECTED: @@ -324,28 +333,28 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) // when sending shortly invert LED_1 m_leds_clear = true; bsp_board_led_invert(BSP_LED_INDICATE_SENT_OK); - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(SENT_OK_INTERVAL), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(SENT_OK_INTERVAL), NULL); break; case BSP_INDICATE_SEND_ERROR: // on receving error invert LED_1 for long time m_leds_clear = true; bsp_board_led_invert(BSP_LED_INDICATE_SEND_ERROR); - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(SEND_ERROR_INTERVAL), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(SEND_ERROR_INTERVAL), NULL); break; case BSP_INDICATE_RCV_OK: // when receving shortly invert LED_1 m_leds_clear = true; bsp_board_led_invert(BSP_LED_INDICATE_RCV_OK); - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(RCV_OK_INTERVAL), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(RCV_OK_INTERVAL), NULL); break; case BSP_INDICATE_RCV_ERROR: // on receving error invert LED_1 for long time m_leds_clear = true; bsp_board_led_invert(BSP_LED_INDICATE_RCV_ERROR); - err_code = app_timer_start(m_leds_timer_id, APP_TIMER_TICKS(RCV_ERROR_INTERVAL), NULL); + err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(RCV_ERROR_INTERVAL), NULL); break; case BSP_INDICATE_FATAL_ERROR: @@ -359,7 +368,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) case BSP_INDICATE_ALERT_2: case BSP_INDICATE_ALERT_3: case BSP_INDICATE_ALERT_OFF: - err_code = app_timer_stop(m_alert_timer_id); + err_code = app_timer_stop(m_bsp_alert_tmr); next_delay = (uint32_t)BSP_INDICATE_ALERT_OFF - (uint32_t)indicate; // a little trick to find out that if it did not fall through ALERT_OFF @@ -367,7 +376,7 @@ static uint32_t bsp_led_indication(bsp_indication_t indicate) { if (next_delay > 1) { - err_code = app_timer_start(m_alert_timer_id, + err_code = app_timer_start(m_bsp_alert_tmr, APP_TIMER_TICKS(((uint16_t)next_delay * ALERT_INTERVAL)), NULL); } @@ -432,7 +441,7 @@ static void leds_timer_handler(void * p_context) { UNUSED_PARAMETER(p_context); - if (m_indication_type & BSP_INIT_LED) + if (m_indication_type & BSP_INIT_LEDS) { UNUSED_VARIABLE(bsp_led_indication(m_stable_state)); } @@ -459,7 +468,7 @@ uint32_t bsp_indication_set(bsp_indication_t indicate) #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) - if (m_indication_type & BSP_INIT_LED) + if (m_indication_type & BSP_INIT_LEDS) { err_code = bsp_led_indication(indicate); } @@ -504,37 +513,33 @@ uint32_t bsp_init(uint32_t type, bsp_event_callback_t callback) if (err_code == NRF_SUCCESS) { - err_code = app_timer_create(&m_button_timer_id, + err_code = app_timer_create(&m_bsp_button_tmr, APP_TIMER_MODE_SINGLE_SHOT, button_timer_handler); } } #elif (BUTTONS_NUMBER > 0) && (defined BSP_SIMPLE) - - if (type & BSP_INIT_BUTTONS) - { - bsp_board_buttons_init(); - } + bsp_board_init(type); #endif // (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) - - if (type & BSP_INIT_LED) - { - bsp_board_leds_init(); - } - - // timers module must be already initialized! - if (err_code == NRF_SUCCESS) - { - err_code = - app_timer_create(&m_leds_timer_id, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler); - } - - if (err_code == NRF_SUCCESS) + if (type & BSP_INIT_LEDS) { - err_code = - app_timer_create(&m_alert_timer_id, APP_TIMER_MODE_REPEATED, alert_timer_handler); + //handle LEDs only. Buttons are already handled. + bsp_board_init(BSP_INIT_LEDS); + + // timers module must be already initialized! + if (err_code == NRF_SUCCESS) + { + err_code = + app_timer_create(&m_bsp_leds_tmr, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler); + } + + if (err_code == NRF_SUCCESS) + { + err_code = + app_timer_create(&m_bsp_alert_tmr, APP_TIMER_MODE_REPEATED, alert_timer_handler); + } } #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) @@ -604,27 +609,30 @@ uint32_t bsp_buttons_disable() return NRF_ERROR_NOT_SUPPORTED; #endif } - -uint32_t bsp_wakeup_button_enable(uint32_t button_idx) +static uint32_t wakeup_button_cfg(uint32_t button_idx, bool enable) { -#if (BUTTONS_NUMBER > 0) && !defined(BSP_SIMPLE) - nrf_gpio_cfg_sense_set(bsp_board_button_idx_to_pin(button_idx), - BUTTONS_ACTIVE_STATE ? NRF_GPIO_PIN_SENSE_HIGH :NRF_GPIO_PIN_SENSE_LOW); - return NRF_SUCCESS; +#if !defined(BSP_SIMPLE) + if (button_idx < BUTTONS_NUMBER) + { + nrf_gpio_pin_sense_t sense = enable ? + (BUTTONS_ACTIVE_STATE ? NRF_GPIO_PIN_SENSE_HIGH : NRF_GPIO_PIN_SENSE_LOW) : + NRF_GPIO_PIN_NOSENSE; + nrf_gpio_cfg_sense_set(bsp_board_button_idx_to_pin(button_idx), sense); + return NRF_SUCCESS; + } #else UNUSED_PARAMETER(button_idx); - return NRF_ERROR_NOT_SUPPORTED; + UNUSED_PARAMETER(enable); #endif + return NRF_ERROR_NOT_SUPPORTED; + +} +uint32_t bsp_wakeup_button_enable(uint32_t button_idx) +{ + return wakeup_button_cfg(button_idx, true); } uint32_t bsp_wakeup_button_disable(uint32_t button_idx) { -#if (BUTTONS_NUMBER > 0) && !defined(BSP_SIMPLE) - nrf_gpio_cfg_sense_set(bsp_board_button_idx_to_pin(button_idx), - NRF_GPIO_PIN_NOSENSE); - return NRF_SUCCESS; -#else - UNUSED_PARAMETER(button_idx); - return NRF_ERROR_NOT_SUPPORTED; -#endif + return wakeup_button_cfg(button_idx, false); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp.h index 92d3b1d..124352f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -57,10 +57,6 @@ #include #include "boards.h" -#define BSP_INIT_NONE 0 /**< This define specifies the type of initialization without support for LEDs and buttons (@ref bsp_init).*/ -#define BSP_INIT_LED (1 << 0) /**< This bit enables LEDs during initialization (@ref bsp_init).*/ -#define BSP_INIT_BUTTONS (1 << 1) /**< This bit enables buttons during initialization (@ref bsp_init).*/ - #if !defined(BSP_DEFINES_ONLY) && !defined(BSP_SIMPLE) #include "app_button.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ant.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ant.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ant.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ant.c index 00ca0ed..da2a3fb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ant.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ant.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(BSP_BTN_ANT) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ant.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ant.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ant.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ant.h index fbac6b6..105d13f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ant.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ant.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ble.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ble.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ble.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ble.c index 807e071..a67e0fe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ble.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ble.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "bsp_btn_ble.h" #include "nrf_sdh_ble.h" @@ -116,6 +116,7 @@ static uint32_t connection_buttons_configure() BSP_EVENT_WHITELIST_OFF); RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code); + err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT, BTN_ACTION_DISCONNECT, BSP_EVENT_DISCONNECT); @@ -181,7 +182,9 @@ static void startup_event_extract(bsp_event_t * p_startup_event) uint32_t bsp_btn_ble_sleep_mode_prepare(void) { - uint32_t err_code = bsp_wakeup_button_enable(BTN_ID_WAKEUP); + uint32_t err_code; + + err_code = bsp_wakeup_button_enable(BTN_ID_WAKEUP); RETURN_ON_ERROR_NOT_NOT_SUPPORTED(err_code); err_code = bsp_wakeup_button_enable(BTN_ID_WAKEUP_BOND_DELETE); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ble.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ble.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ble.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ble.h index 5981bfe..190c760 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_btn_ble.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_btn_ble.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.c similarity index 67% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.c index 43eae7f..fa7cf03 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,59 +35,43 @@ * 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(NRF_CRYPTO) +#include "bsp_cli.h" -#include "nrf_crypto_mem.h" -#include "mem_manager.h" +static bsp_event_callback_t m_bsp_cli_callback = NULL; -uint32_t nrf_crypto_mem_init(void) +static void cmd_btn(nrf_cli_t const * p_cli, size_t argc, char **argv) { - uint32_t ret_val; + uint32_t id; + ASSERT(m_bsp_cli_callback != NULL); - ret_val = nrf_mem_init(); - return ret_val; + sscanf(argv[1], "%"SCNu32, &id); + bsp_event_t ev = (bsp_event_t)(BSP_EVENT_KEY_0 + id); + m_bsp_cli_callback(ev); } -uint32_t nrf_crypto_mem_allocate(uint32_t size, nrf_value_length_t * p_result) +static void cmd_evt(nrf_cli_t const * p_cli, size_t argc, char **argv) { - uint32_t ret_val; - uint32_t allocated_size; + uint32_t id; + ASSERT(m_bsp_cli_callback != NULL); - if (p_result == NULL) - { - return NRF_ERROR_NULL; - } - - ret_val = nrf_mem_reserve(&p_result->p_value, &allocated_size); - if (ret_val == NRF_SUCCESS) - { - p_result->length = size; - } - else - { - p_result->length = 0; - } - - return ret_val; + sscanf(argv[1], "%"SCNu32, &id); + bsp_event_t ev = (bsp_event_t)id; + m_bsp_cli_callback(ev); } -uint32_t nrf_crypto_mem_free(nrf_value_length_t * p_mem) +ret_code_t bsp_cli_init(bsp_event_callback_t callback) { - if (p_mem == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_mem->length != 0) - { - nrf_free(p_mem->p_value); - } + m_bsp_cli_callback = callback; return NRF_SUCCESS; } - -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_bsp) +{ + NRF_CLI_CMD(btn, NULL, "BSP button event key", cmd_btn), + NRF_CLI_CMD(evt, NULL, "BSP event id", cmd_evt), + NRF_CLI_SUBCMD_SET_END +}; +NRF_CLI_CMD_REGISTER(bsp, &m_sub_bsp, "bsp", NULL); diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.h new file mode 100644 index 0000000..7b9a790 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_cli.h @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2017 - 2019, 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 bsp_cli BSP over CLI Module + * @{ + * @ingroup bsp + * + * @brief Module for sending BSP events over CLI. + * + * @details The module uses Command Line Interface and enables user to send events + * to BSP. They are later handled by the event handler provided. + * Available commands: + * - bsp btn X (where X is button number) - sends BSP_EVENT_KEY_X + * - bsp evt X (where X is event number) - sends BSP event with X id + */ + +#ifndef BSP_CLI_H__ +#define BSP_CLI_H__ + +#include +#include "nrf_cli.h" +#include "bsp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Function for initializing the BSP over CLI Module. + * + * Before calling this function, the BSP module must be initialized. + * + * @param[in] callback Function to be called when event is recevied. + * + * @retval NRF_SUCCESS If initialization was successful. + */ + +ret_code_t bsp_cli_init(bsp_event_callback_t callback); + +#ifdef __cplusplus +} +#endif + +#endif /* BSP_CLI_H__ */ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_config.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_config.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_config.h index 47b264a..7b6af95 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_config.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_nfc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_nfc.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_nfc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_nfc.c index d42e1ab..1bf6557 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_nfc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_nfc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "bsp_nfc.h" #include "bsp.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_nfc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_nfc.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_nfc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_nfc.h index 9e0380a..67e46df 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bsp/bsp_nfc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/bsp/bsp_nfc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.c new file mode 100644 index 0000000..b0484dd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.c @@ -0,0 +1,349 @@ +/** + * Copyright (c) 2012 - 2019, 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(BUTTON) +#include "app_button.h" +#include "app_timer.h" +#include "app_error.h" +#include "nrf_drv_gpiote.h" +#include "nrf_assert.h" + +#define NRF_LOG_MODULE_NAME app_button +#if APP_BUTTON_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_BUTTON_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_BUTTON_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_BUTTON_CONFIG_DEBUG_COLOR +#else //APP_BUTTON_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //APP_BUTTON_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/* + * For each pin state machine is used. Since GPIOTE PORT event is common for all pin is might be + * missed. Module relies on interrupt from GPIOTE only to active periodic app_timer in which pin + * is sampled. Timer is stopped when there is no active buttons (all buttons are in idle state). + * + * Transition to the new state is based on currently sampled button value. State machine has + * following transitions: + * + * ----------------------------------------------------- + * | value | current state | new state | + * |---------------------------------------------------| + * | 0 | IDLE | IDLE | + * | 1 | IDLE | PRESS_ARMED | + * | 0 | PRESS_ARMED | IDLE | + * | 1 | PRESS_ARMED | PRESS_DETECTED | + * | 1 | PRESS_DETECTED | PRESSED (push event) | + * | 0 | PRESS_DETECTED | PRESS_ARMED | + * | 0 | PRESSED | RELEASE_DETECTED | + * | 1 | PRESSED | PRESSED | + * | 0 | RELEASE_DETECTED | IDLE (release event) | + * | 1 | RELEASE_DETECTED | PRESSED | + * ----------------------------------------------------- + * + */ +static app_button_cfg_t const * mp_buttons = NULL; /**< Button configuration. */ +static uint8_t m_button_count; /**< Number of configured buttons. */ +static uint32_t m_detection_delay; /**< Delay before a button is reported as pushed. */ +APP_TIMER_DEF(m_detection_delay_timer_id); /**< Polling timer id. */ + +static uint64_t m_pin_active; + +#define BIT_PER_PIN 4 +#define PINS 32*GPIO_COUNT + +STATIC_ASSERT(BIT_PER_PIN == 4); + +static uint8_t m_pin_states[PINS*BIT_PER_PIN/8]; + +typedef enum { + BTN_IDLE, + BTN_PRESS_ARMED, + BTN_PRESS_DETECTED, + BTN_PRESSED, + BTN_RELEASE_DETECTED +} btn_state_t; + +/* Retrieve given pin state. States are stored in pairs (4 bit per pin) in byte array. */ +static btn_state_t state_get(uint8_t pin) +{ + uint8_t pair_state = m_pin_states[pin >> 1]; + uint8_t state = (pin & 0x1) ? (pair_state >> BIT_PER_PIN) : (pair_state & 0x0F); + + return (btn_state_t)state; +} + +/* Set pin state. */ +static void state_set(uint8_t pin, btn_state_t state) +{ + uint8_t mask = (pin & 1) ? 0x0F : 0xF0; + uint8_t state_mask = (pin & 1) ? + ((uint8_t)state << BIT_PER_PIN) : (uint8_t)state; + m_pin_states[pin >> 1] &= mask; + m_pin_states[pin >> 1] |= state_mask; +} + +/* Find configuration structure for given pin. */ +static app_button_cfg_t const * button_get(uint8_t pin) +{ + for (int i = 0; i < m_button_count; i++) + { + app_button_cfg_t const * p_btn = &mp_buttons[i]; + if (pin == p_btn->pin_no) { + return p_btn; + } + } + + /* If button is not found then configuration is wrong. */ + ASSERT(false); + return NULL; +} + +static void usr_event(uint8_t pin, uint8_t type) +{ + app_button_cfg_t const * p_btn = button_get(pin); + + if (p_btn && p_btn->button_handler) + { + NRF_LOG_DEBUG("Pin %d %s", pin, (type == APP_BUTTON_PUSH) ? "pressed" : "released"); + p_btn->button_handler(pin, type); + } +} + +/* State machine processing. */ +void evt_handle(uint8_t pin, uint8_t value) +{ + switch(state_get(pin)) + { + case BTN_IDLE: + if (value) + { + NRF_LOG_DEBUG("Pin %d idle->armed", pin); + state_set(pin, BTN_PRESS_ARMED); + CRITICAL_REGION_ENTER(); + m_pin_active |= 1ULL << pin; + CRITICAL_REGION_EXIT(); + } + else + { + /* stay in IDLE */ + } + break; + case BTN_PRESS_ARMED: + state_set(pin, value ? BTN_PRESS_DETECTED : BTN_IDLE); + NRF_LOG_DEBUG("Pin %d armed->%s", pin, value ? "detected" : "idle"); + break; + case BTN_PRESS_DETECTED: + if (value) + { + state_set(pin, BTN_PRESSED); + usr_event(pin, APP_BUTTON_PUSH); + } + else + { + state_set(pin, BTN_PRESS_ARMED); + } + NRF_LOG_DEBUG("Pin %d detected->%s", pin, value ? "pressed" : "armed"); + break; + case BTN_PRESSED: + if (value == 0) + { + NRF_LOG_DEBUG("Pin %d pressed->release_detected", pin); + state_set(pin, BTN_RELEASE_DETECTED); + } + else + { + /* stay in pressed */ + } + break; + case BTN_RELEASE_DETECTED: + if (value) + { + state_set(pin, BTN_PRESSED); + } + else + { + state_set(pin, BTN_IDLE); + usr_event(pin, APP_BUTTON_RELEASE); + CRITICAL_REGION_ENTER(); + m_pin_active &= ~(1ULL << pin); + CRITICAL_REGION_EXIT(); + } + NRF_LOG_DEBUG("Pin %d release_detected->%s", pin, value ? "pressed" : "idle"); + break; + } +} + +static void timer_start(void) +{ + uint32_t err_code = app_timer_start(m_detection_delay_timer_id, m_detection_delay/2, NULL); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("Failed to start app_timer (err:%d)", err_code); + } +} + +static void detection_delay_timeout_handler(void * p_context) +{ + for (int i = 0; i < m_button_count; i++) + { + app_button_cfg_t const * p_btn = &mp_buttons[i]; + bool is_set = nrf_drv_gpiote_in_is_set(p_btn->pin_no); + bool is_active = !((p_btn->active_state == APP_BUTTON_ACTIVE_HIGH) ^ is_set); + evt_handle(p_btn->pin_no, is_active); + } + + if (m_pin_active) + { + timer_start(); + } + else + { + NRF_LOG_DEBUG("No active buttons, stopping timer"); + } +} + +/* GPIOTE event is used only to start periodic timer when first button is activated. */ +static void gpiote_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) +{ + app_button_cfg_t const * p_btn = button_get(pin); + bool is_set = nrf_drv_gpiote_in_is_set(p_btn->pin_no); + bool is_active = !((p_btn->active_state == APP_BUTTON_ACTIVE_HIGH) ^ is_set); + + /* If event indicates that pin is active and no other pin is active start the timer. All + * action happens in timeout event. + */ + if (is_active && (m_pin_active == 0)) + { + NRF_LOG_DEBUG("First active button, starting periodic timer"); + timer_start(); + } +} + +uint32_t app_button_init(app_button_cfg_t const * p_buttons, + uint8_t button_count, + uint32_t detection_delay) +{ + uint32_t err_code; + + if (detection_delay < 2*APP_TIMER_MIN_TIMEOUT_TICKS) + { + return NRF_ERROR_INVALID_PARAM; + } + + if (!nrf_drv_gpiote_is_init()) + { + err_code = nrf_drv_gpiote_init(); + VERIFY_SUCCESS(err_code); + } + + /* Save configuration. */ + mp_buttons = p_buttons; + m_button_count = button_count; + m_detection_delay = detection_delay; + + memset(m_pin_states, 0, sizeof(m_pin_states)); + m_pin_active = 0; + + while (button_count--) + { + app_button_cfg_t const * p_btn = &p_buttons[button_count]; + +#if defined(BUTTON_HIGH_ACCURACY_ENABLED) && (BUTTON_HIGH_ACCURACY_ENABLED == 1) + nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(p_btn->hi_accuracy); +#else + nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); +#endif + config.pull = p_btn->pull_cfg; + + err_code = nrf_drv_gpiote_in_init(p_btn->pin_no, &config, gpiote_event_handler); + VERIFY_SUCCESS(err_code); + } + + /* Create polling timer. */ + return app_timer_create(&m_detection_delay_timer_id, + APP_TIMER_MODE_SINGLE_SHOT, + detection_delay_timeout_handler); +} + +uint32_t app_button_enable(void) +{ + ASSERT(mp_buttons); + + uint32_t i; + for (i = 0; i < m_button_count; i++) + { + nrf_drv_gpiote_in_event_enable(mp_buttons[i].pin_no, true); + } + + return NRF_SUCCESS; +} + + +uint32_t app_button_disable(void) +{ + ASSERT(mp_buttons); + + uint32_t i; + for (i = 0; i < m_button_count; i++) + { + nrf_drv_gpiote_in_event_disable(mp_buttons[i].pin_no); + } + CRITICAL_REGION_ENTER(); + m_pin_active = 0; + CRITICAL_REGION_EXIT(); + + /* Make sure polling timer is not running. */ + return app_timer_stop(m_detection_delay_timer_id); +} + + +bool app_button_is_pushed(uint8_t button_id) +{ + ASSERT(button_id <= m_button_count); + ASSERT(mp_buttons != NULL); + + app_button_cfg_t const * p_btn = &mp_buttons[button_id]; + bool is_set = nrf_drv_gpiote_in_is_set(p_btn->pin_no); + + return !(is_set ^ (p_btn->active_state == APP_BUTTON_ACTIVE_HIGH)); +} +#endif //NRF_MODULE_ENABLED(BUTTON) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.h index 9b2e479..8189abb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/button/app_button.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/button/app_button.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -86,24 +86,18 @@ typedef struct { uint8_t pin_no; /**< Pin to be used as a button. */ uint8_t active_state; /**< APP_BUTTON_ACTIVE_HIGH or APP_BUTTON_ACTIVE_LOW. */ +#if defined(BUTTON_HIGH_ACCURACY_ENABLED) && (BUTTON_HIGH_ACCURACY_ENABLED == 1) + bool hi_accuracy; /**< True if GPIOTE high accuracy (IN_EVENT) is used. */ +#endif nrf_gpio_pin_pull_t pull_cfg; /**< Pull-up or -down configuration. */ app_button_handler_t button_handler; /**< Handler to be called when button is pushed. */ } app_button_cfg_t; -/**@brief Pin transition direction struct. */ -typedef struct -{ - uint32_t high_to_low; /**Pin went from high to low */ - uint32_t low_to_high; /**Pin went from low to high */ -} pin_transition_t; - /**@brief Function for initializing the Buttons. * * @details This function will initialize the specified pins as buttons, and configure the Button * Handler module as a GPIOTE user (but it will not enable button detection). * - * @note Normally initialization should be done using the APP_BUTTON_INIT() macro - * * @note app_button_enable() function must be called in order to enable the button detection. * * @param[in] p_buttons Array of buttons to be used (NOTE: Must be static!). diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c similarity index 82% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c index a3476d7..8ab7c50 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/ble_uart/nrf_cli_ble_uart.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -59,20 +59,18 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); +#if NRF_CLI_BLE_UART_MAX_CLIENTS > NRF_SDH_BLE_TOTAL_LINK_COUNT + #error "Too few BLE peripheral links are supported by the BLE SDH module for the maximal number \ + of BLE transport instances" +#endif #define NRF_CLI_BLE_UART_TIMEOUT_MS 50 #define OVERHEAD_LENGTH (OPCODE_LENGTH + HANDLE_LENGTH) -static nrf_cli_ble_uart_internal_t * mp_instance; - -static ble_nus_t m_nus; -NRF_SDH_BLE_OBSERVER(m_nus_ble_obs, BLE_NUS_BLE_OBSERVER_PRIO, ble_nus_on_ble_evt, &m_nus); - - -void nrf_cli_ble_uart_on_ble_evt(ble_evt_t *p_ble_evt) -{ - ble_nus_on_ble_evt(p_ble_evt, &m_nus); -} +BLE_NUS_DEF(m_nus, NRF_CLI_BLE_UART_MAX_CLIENTS); +BLE_LINK_CTX_MANAGER_DEF(m_link_ctx_storage, + NRF_CLI_BLE_UART_MAX_CLIENTS, + sizeof(nrf_cli_ble_uart_internal_t *)); static void tx_try(nrf_cli_ble_uart_internal_t * p_instance, uint32_t threshold) { @@ -91,9 +89,10 @@ static void tx_try(nrf_cli_ble_uart_internal_t * p_instance, uint32_t threshold) if (out_data_len >= threshold) { size_t req_data_len = out_data_len; - err_code = ble_nus_string_send(&m_nus, - p_out_data, - (uint16_t*)&out_data_len); + err_code = ble_nus_data_send(&m_nus, + p_out_data, + (uint16_t*)&out_data_len, + p_instance->p_cb->conn_handle); if ((err_code == NRF_ERROR_BUSY) || (err_code == NRF_ERROR_RESOURCES)) { @@ -112,22 +111,28 @@ static void tx_try(nrf_cli_ble_uart_internal_t * p_instance, uint32_t threshold) } } } -static void nus_data_handler(ble_nus_evt_t * p_evt) + +static void nus_data_handler(ble_nus_evt_t * p_nus_evt) { - nrf_cli_ble_uart_internal_t * p_instance = mp_instance; - ret_code_t err_code = NRF_SUCCESS; - UNUSED_VARIABLE(err_code); + ret_code_t err_code = NRF_SUCCESS; + nrf_cli_ble_uart_internal_t * p_instance; + nrf_cli_ble_uart_internal_t ** pp_instance; - switch (p_evt->type) + err_code = blcm_link_ctx_get(&m_link_ctx_storage, p_nus_evt->conn_handle, (void *) &pp_instance); + ASSERT(err_code == NRF_SUCCESS); + + p_instance = *pp_instance; + + switch (p_nus_evt->type) { case BLE_NUS_EVT_RX_DATA: { NRF_LOG_INFO("Conn_handle:%d, Received: %d", - p_instance->p_cb->conn_handle, p_evt->params.rx_data.length); - NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length); - size_t len = (size_t)p_evt->params.rx_data.length; + p_instance->p_cb->conn_handle, p_nus_evt->params.rx_data.length); + NRF_LOG_HEXDUMP_DEBUG(p_nus_evt->params.rx_data.p_data, p_nus_evt->params.rx_data.length); + size_t len = ((size_t) p_nus_evt->params.rx_data.length) & 0x0000FFFF; err_code = nrf_ringbuf_cpy_put(p_instance->p_rx_ringbuf, - p_evt->params.rx_data.p_data, + p_nus_evt->params.rx_data.p_data, (size_t *)&len); ASSERT(err_code == NRF_SUCCESS); @@ -150,12 +155,12 @@ static void nus_data_handler(ble_nus_evt_t * p_evt) APP_TIMER_TICKS(NRF_CLI_BLE_UART_TIMEOUT_MS), p_instance); ASSERT(err_code == NRF_SUCCESS); - NRF_LOG_INFO("BLE UART service started"); + NRF_LOG_INFO("Conn_handle:%d, communication started", p_instance->p_cb->conn_handle); break; case BLE_NUS_EVT_COMM_STOPPED: (void)app_timer_stop(*p_instance->p_timer); p_instance->p_cb->service_started = false; - NRF_LOG_INFO("BLE UART service stopped"); + NRF_LOG_INFO("Conn_handle:%d, communication stopped", p_instance->p_cb->conn_handle); break; default: break; @@ -164,7 +169,7 @@ static void nus_data_handler(ble_nus_evt_t * p_evt) static void timer_handler(void * p_context) { - nrf_cli_ble_uart_internal_t * p_instance = mp_instance; + nrf_cli_ble_uart_internal_t * p_instance = (nrf_cli_ble_uart_internal_t *) p_context; tx_try(p_instance, 1); ret_code_t err_code = app_timer_start(*p_instance->p_timer, @@ -189,7 +194,9 @@ static ret_code_t cli_ble_uart_init(nrf_cli_transport_t const * p_transport, nrf_cli_transport_handler_t evt_handler, void * p_context) { - nrf_cli_ble_uart_internal_t * p_instance = + ret_code_t err_code; + nrf_cli_ble_uart_internal_t ** pp_instance; + nrf_cli_ble_uart_internal_t * p_instance = CONTAINER_OF(p_transport, nrf_cli_ble_uart_internal_t, transport); nrf_cli_ble_uart_config_t * p_ble_uart_config = (nrf_cli_ble_uart_config_t *)p_config; @@ -202,7 +209,13 @@ static ret_code_t cli_ble_uart_init(nrf_cli_transport_t const * p_transport, nrf_ringbuf_init(p_instance->p_rx_ringbuf); nrf_ringbuf_init(p_instance->p_tx_ringbuf); - mp_instance = p_instance; + err_code = blcm_link_ctx_get(&m_link_ctx_storage, + p_ble_uart_config->conn_handle, + (void *) &pp_instance); + VERIFY_SUCCESS(err_code); + + *pp_instance = p_instance; + return NRF_SUCCESS; } @@ -217,7 +230,6 @@ static ret_code_t cli_ble_uart_uninit(nrf_cli_transport_t const * p_transport) return ret; } - static ret_code_t cli_ble_uart_enable(nrf_cli_transport_t const * p_transport, bool blocking) { nrf_cli_ble_uart_internal_t * p_instance = diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h index 8029213..3bb5fd2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/ble_uart/nrf_cli_ble_uart.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_BLE_UART_H__ #define NRF_CLI_BLE_UART_H__ @@ -61,7 +61,7 @@ extern "C" { /** * @brief Command line interface transport. - * */ + */ ret_code_t nrf_cli_ble_uart_service_init(void); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c similarity index 78% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c index cdd56d8..f32c2ad 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_CLI_CDC_ACM) @@ -45,41 +45,26 @@ #include "nrf_assert.h" -#if APP_USBD_EVENT_QUEUE_ENABLE -#error "Current CLI CDC implementation supports only USB with event queue disabled (see APP_USBD_EVENT_QUEUE_ENABLE)" +#if APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#error "Current CLI CDC implementation supports only USB with event queue disabled (see APP_USBD_CONFIG_EVENT_QUEUE_ENABLE)" #endif static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, app_usbd_cdc_acm_user_event_t event); - -/** - * @brief Interfaces list passed to @ref APP_USBD_CDC_ACM_GLOBAL_DEF - * */ -#define NRF_CLI_CDC_ACM_INTERFACES_CONFIG() \ - APP_USBD_CDC_ACM_CONFIG(NRF_CLI_CDC_ACM_COMM_INTERFACE, \ - NRF_CLI_CDC_ACM_COMM_EPIN, \ - NRF_CLI_CDC_ACM_DATA_INTERFACE, \ - NRF_CLI_CDC_ACM_DATA_EPIN, \ - NRF_CLI_CDC_ACM_DATA_EPOUT) - -static const uint8_t m_cdc_acm_class_descriptors[] = { - APP_USBD_CDC_ACM_DEFAULT_DESC(NRF_CLI_CDC_ACM_COMM_INTERFACE, - NRF_CLI_CDC_ACM_COMM_EPIN, - NRF_CLI_CDC_ACM_DATA_INTERFACE, - NRF_CLI_CDC_ACM_DATA_EPIN, - NRF_CLI_CDC_ACM_DATA_EPOUT) -}; - /*lint -save -e26 -e40 -e64 -e123 -e505 -e651*/ /** * @brief CDC_ACM class instance. * */ APP_USBD_CDC_ACM_GLOBAL_DEF(nrf_cli_cdc_acm, - NRF_CLI_CDC_ACM_INTERFACES_CONFIG(), cdc_acm_user_ev_handler, - m_cdc_acm_class_descriptors + NRF_CLI_CDC_ACM_COMM_INTERFACE, + NRF_CLI_CDC_ACM_DATA_INTERFACE, + NRF_CLI_CDC_ACM_COMM_EPIN, + NRF_CLI_CDC_ACM_DATA_EPIN, + NRF_CLI_CDC_ACM_DATA_EPOUT, + APP_USBD_CDC_COMM_PROTOCOL_AT_V250 ); /*lint -restore*/ @@ -89,10 +74,48 @@ NRF_QUEUE_DEF(uint8_t, 2*NRF_DRV_USBD_EPSIZE, NRF_QUEUE_MODE_OVERFLOW); -static bool m_port_is_open; static char m_rx_buffer[NRF_DRV_USBD_EPSIZE]; static nrf_cli_cdc_acm_internal_t * mp_internal; + +/** + * @brief Set new buffer and process any data if already present + * + * This is internal function. + * The result of its execution is the library waiting for the event of the new data. + * If there is already any data that was returned from the CDC internal buffer + * it would be processed here. + */ +static void cdc_acm_process_and_prepare_buffer(app_usbd_cdc_acm_t const * p_cdc_acm) +{ + for (;;) + { + if (!nrf_queue_is_empty(&m_rx_queue)) + { + mp_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_RX_RDY, mp_internal->p_cb->p_context); + } + ret_code_t ret = app_usbd_cdc_acm_read_any(&nrf_cli_cdc_acm, + m_rx_buffer, + sizeof(m_rx_buffer)); + if (ret == NRF_SUCCESS) + { + size_t size = app_usbd_cdc_acm_rx_size(p_cdc_acm); + size_t qsize = nrf_queue_in(&m_rx_queue, m_rx_buffer, size); + ASSERT(size == qsize); + UNUSED_VARIABLE(qsize); + } + else if (ret == NRF_ERROR_IO_PENDING) + { + break; + } + else + { + APP_ERROR_CHECK(ret); + break; + } + } +} + /** * @brief User event handler. * */ @@ -106,16 +129,11 @@ static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, { case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN: { - m_port_is_open = true; /*Setup first transfer*/ - ret_code_t ret = app_usbd_cdc_acm_read(&nrf_cli_cdc_acm, - m_rx_buffer, - sizeof(m_rx_buffer)); - APP_ERROR_CHECK(ret); + cdc_acm_process_and_prepare_buffer(p_cdc_acm); break; } case APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE: - m_port_is_open = false; break; case APP_USBD_CDC_ACM_USER_EVT_TX_DONE: mp_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_TX_RDY, mp_internal->p_cb->p_context); @@ -129,13 +147,7 @@ static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst, UNUSED_VARIABLE(qsize); /*Setup next transfer*/ - ret_code_t ret = app_usbd_cdc_acm_read(&nrf_cli_cdc_acm, - m_rx_buffer, - sizeof(m_rx_buffer)); - - ASSERT(ret == NRF_SUCCESS); /*Should not happen*/ - UNUSED_VARIABLE(ret); - mp_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_RX_RDY, mp_internal->p_cb->p_context); + cdc_acm_process_and_prepare_buffer(p_cdc_acm); break; } default: @@ -200,16 +212,11 @@ static ret_code_t cli_cdc_acm_write(nrf_cli_transport_t const * p_transport, UNUSED_PARAMETER(p_transport); ret_code_t ret; - if (!m_port_is_open) - { - *p_cnt = length; - return NRF_SUCCESS; - } - ret = app_usbd_cdc_acm_write(&nrf_cli_cdc_acm, p_data, length); - if (ret == NRF_SUCCESS) + if (ret == NRF_SUCCESS || ret == NRF_ERROR_INVALID_STATE) { *p_cnt = length; + ret = NRF_SUCCESS; } else if (ret == NRF_ERROR_BUSY) { @@ -232,9 +239,4 @@ const nrf_cli_transport_api_t nrf_cli_cdc_acm_transport_api = { .write = cli_cdc_acm_write, }; -bool nrf_cli_cdc_acm_port_is_open(void) -{ - return m_port_is_open; -} - #endif // NRF_MODULE_ENABLED(NRF_CLI_CDC_ACM) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h index 6601f44..8faaa5f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cdc_acm/nrf_cli_cdc_acm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_CDC_ACM_H__ #define NRF_CLI_CDC_ACM_H__ @@ -60,12 +60,12 @@ extern "C" { /** * @brief Command line interface transport. - * */ + */ extern const nrf_cli_transport_api_t nrf_cli_cdc_acm_transport_api; /** * @brief Command line interface class instance. - * */ + */ extern const app_usbd_cdc_acm_t nrf_cli_cdc_acm; typedef struct { @@ -86,11 +86,6 @@ typedef struct { .p_cb = &CONCAT_2(_name_, _cb), \ } -/** - * @brief Get CDC ACM port status. - * */ -bool nrf_cli_cdc_acm_port_is_open(void); - /** @} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cli_utils_cmds.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cli_utils_cmds.c new file mode 100644 index 0000000..2bf8276 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/cli_utils_cmds.c @@ -0,0 +1,164 @@ +/** + * Copyright (c) 2018 - 2019, 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 "nrf_cli.h" +#include "nrf_log.h" + +static void cmd_reset(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + NVIC_SystemReset(); +} + + +static void cmd_error(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + APP_ERROR_CHECK(NRF_ERROR_INTERNAL); +} + + +static void cmd_app_size(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + nrf_cli_fprintf(p_cli, + NRF_CLI_NORMAL, + "Application address:%d (0x%08X), size: %d (0x%08X)\r\n", + CODE_START, + CODE_START, + CODE_SIZE, + CODE_SIZE); +} + + +static void cmd_log_msg_error(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + switch (argc-1) + { + case 0: + NRF_LOG_ERROR("test error message"); + break; + case 1: + NRF_LOG_ERROR("test error message: %d", strtol(argv[1], NULL, 10)); + break; + case 2: + NRF_LOG_ERROR("test error message: %d %d", strtol(argv[1], NULL, 10), + strtol(argv[2], NULL, 10)); + break; + default: + NRF_LOG_ERROR("test error message with more than 3 arguments"); + break; + } +} + + +static void cmd_log_msg_warning(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + switch (argc-1) + { + case 0: + NRF_LOG_WARNING("test warning message"); + break; + case 1: + NRF_LOG_WARNING("test warning message: %d", strtol(argv[1], NULL, 10)); + break; + case 2: + NRF_LOG_WARNING("test warning message: %d %d", strtol(argv[1], NULL, 10), + strtol(argv[2], NULL, 10)); + break; + default: + NRF_LOG_WARNING("test warning message with more than 3 arguments"); + break; + } +} + +/** + * @brief Command set array + * */ + +NRF_CLI_CMD_REGISTER(reset, NULL, "System reset.", cmd_reset); + +NRF_CLI_CMD_REGISTER(error, NULL, "Trigger error.", cmd_error); + +NRF_CLI_CMD_REGISTER(app_size, NULL, "Print application size.", cmd_app_size); + +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_log_msg) +{ + NRF_CLI_CMD(error, NULL, "Error log message with parameters", cmd_log_msg_error), + NRF_CLI_CMD(warning, NULL, "Warning log message with parameters", cmd_log_msg_warning), + NRF_CLI_SUBCMD_SET_END +}; + +NRF_CLI_CMD_REGISTER(log_msg, &m_sub_log_msg, "Trigger log message with decimal arguments", NULL); diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.c new file mode 100644 index 0000000..8eeb029 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.c @@ -0,0 +1,252 @@ +/** + * Copyright (c) 2018 - 2019, 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" +#include "nrf_cli_libuarte.h" +#include "nrf_libuarte_async.h" +#include "nrf_assert.h" +#include "nrf_atomic.h" +#define NRF_LOG_MODULE_NAME cli_libuarte +#if NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#else //NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +static cli_libuarte_internal_t * mp_internal; +static nrf_atomic_flag_t m_uart_busy; + +NRF_LIBUARTE_ASYNC_DEFINE(libuarte, + NRF_CLI_LIBUARTE_UARTE_INSTANCE, + NRF_CLI_LIBUARTE_TIMER_INSTANCE, + NRF_CLI_LIBUARTE_TIMEOUT_RTC_INSTANCE, + NRF_CLI_LIBUARTE_TIMEOUT_TIMER_INSTANCE, + 3, 255); + +static void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_event) +{ + cli_libuarte_internal_t * p_internal = mp_internal; + ret_code_t err_code = NRF_SUCCESS; + size_t len; + UNUSED_VARIABLE(err_code); + switch (p_event->type) + { + case NRF_LIBUARTE_ASYNC_EVT_ERROR: + NRF_LOG_WARNING("(evt) ERROR"); + + break; + + case NRF_LIBUARTE_ASYNC_EVT_RX_DATA: + { + len = (size_t)((uint32_t)p_event->data.rxtx.length & 0x0000FFFF); + err_code = nrf_ringbuf_cpy_put(p_internal->p_rx_ringbuf, + p_event->data.rxtx.p_data, + &len); + ASSERT(err_code == NRF_SUCCESS); + + if (len != p_event->data.rxtx.length) + { + NRF_LOG_WARNING("Data lost, no room in RX ringbuf"); + } + nrf_libuarte_async_rx_free(&libuarte, p_event->data.rxtx.p_data, p_event->data.rxtx.length); + + if (p_event->data.rxtx.length) + { + NRF_LOG_DEBUG("(evt) RXRDY length:%d", p_event->data.rxtx.length); + NRF_LOG_HEXDUMP_DEBUG(p_event->data.rxtx.p_data, p_event->data.rxtx.length); + p_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_RX_RDY, + p_internal->p_cb->p_context); + } + + break; + } + + case NRF_LIBUARTE_ASYNC_EVT_TX_DONE: + err_code = nrf_ringbuf_free(p_internal->p_tx_ringbuf, p_event->data.rxtx.length); + ASSERT(err_code == NRF_SUCCESS); + uint8_t * p_data; + len = 255; + err_code = nrf_ringbuf_get(p_internal->p_tx_ringbuf, &p_data, &len, true); + ASSERT(err_code == NRF_SUCCESS); + if (len) + { + NRF_LOG_DEBUG("(evt) Started TX (%d).", len); + err_code = nrf_libuarte_async_tx(&libuarte, p_data, len); + ASSERT(err_code == NRF_SUCCESS); + } + else + { + m_uart_busy = false; + } + p_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_TX_RDY, p_internal->p_cb->p_context); + NRF_LOG_DEBUG("(evt) TX completed (%d)", p_event->data.rxtx.length); + break; + + default: + NRF_LOG_ERROR("(evt) Unknown event"); + ASSERT(false); + break; + } +} + +static ret_code_t cli_libuarte_init(nrf_cli_transport_t const * p_transport, + void const * p_config, + nrf_cli_transport_handler_t evt_handler, + void * p_context) +{ + cli_libuarte_internal_t * p_internal = CONTAINER_OF(p_transport, + cli_libuarte_internal_t, + transport); + mp_internal = p_internal; + m_uart_busy = false; + + p_internal->p_cb->handler = evt_handler; + p_internal->p_cb->p_context = p_context; + p_internal->p_cb->blocking = false; + + cli_libuarte_config_t const * p_cli_libuarte_config = (cli_libuarte_config_t *)p_config; + nrf_libuarte_async_config_t uart_async_config = { + .tx_pin = p_cli_libuarte_config->tx_pin, + .rx_pin = p_cli_libuarte_config->rx_pin, + .baudrate = p_cli_libuarte_config->baudrate, + .parity = p_cli_libuarte_config->parity, + .hwfc = p_cli_libuarte_config->hwfc, + .timeout_us = 100, + .int_prio = APP_IRQ_PRIORITY_LOW + }; + ret_code_t err_code = nrf_libuarte_async_init(&libuarte, &uart_async_config, uart_event_handler, NULL); + if (err_code == NRF_SUCCESS) + { + nrf_ringbuf_init(p_internal->p_rx_ringbuf); + nrf_ringbuf_init(p_internal->p_tx_ringbuf); + } + return err_code; +} + +static ret_code_t cli_libuarte_uninit(nrf_cli_transport_t const * p_transport) +{ + UNUSED_PARAMETER(p_transport); + nrf_libuarte_async_uninit(&libuarte); + return NRF_SUCCESS; +} + +static ret_code_t cli_libuarte_enable(nrf_cli_transport_t const * p_transport, + bool blocking) +{ + UNUSED_PARAMETER(p_transport); + if (blocking) + { + return NRF_ERROR_NOT_SUPPORTED; + } + else + { + nrf_libuarte_async_enable(&libuarte); + } + return NRF_SUCCESS; +} + +static ret_code_t cli_libuarte_read(nrf_cli_transport_t const * p_transport, + void * p_data, + size_t length, + size_t * p_cnt) +{ + ASSERT(p_cnt); + cli_libuarte_internal_t * p_instance = + CONTAINER_OF(p_transport, cli_libuarte_internal_t, transport); + + *p_cnt = length; + ret_code_t err_code = nrf_ringbuf_cpy_get(p_instance->p_rx_ringbuf, p_data, p_cnt); + + if (*p_cnt) + { + NRF_LOG_DEBUG("Read %d bytes (requested %d)", *p_cnt, length); + } + + return err_code; +} + +static ret_code_t cli_libuarte_write(nrf_cli_transport_t const * p_transport, + void const * p_data, + size_t length, + size_t * p_cnt) +{ + ASSERT(p_cnt); + cli_libuarte_internal_t * p_instance = CONTAINER_OF(p_transport, + cli_libuarte_internal_t, + transport); + *p_cnt = length; + ret_code_t err_code = nrf_ringbuf_cpy_put(p_instance->p_tx_ringbuf, p_data, p_cnt); + if (err_code == NRF_SUCCESS) + { + NRF_LOG_DEBUG("Requested write: %d, copied to ringbuf: %d.", length, *p_cnt); + + if (nrf_atomic_flag_set_fetch(&m_uart_busy)) + { + return err_code; + } + + uint8_t * p_buf; + size_t len = 255; + if (nrf_ringbuf_get(p_instance->p_tx_ringbuf, &p_buf, &len, true) == NRF_SUCCESS) + { + NRF_LOG_DEBUG("Started TX (%d).", len); + + err_code = nrf_libuarte_async_tx(&libuarte, p_buf, len); + if (p_instance->p_cb->blocking && (err_code == NRF_SUCCESS)) + { + (void)nrf_ringbuf_free(p_instance->p_tx_ringbuf, len); + m_uart_busy = false; + } + } + } + return err_code; +} + +const nrf_cli_transport_api_t cli_libuarte_transport_api = { + .init = cli_libuarte_init, + .uninit = cli_libuarte_uninit, + .enable = cli_libuarte_enable, + .read = cli_libuarte_read, + .write = cli_libuarte_write, +}; + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.h new file mode 100644 index 0000000..df3d98a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/libuarte/nrf_cli_libuarte.h @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_LOG_BACKEND_LIBUARTE_H__ +#define NRF_LOG_BACKEND_LIBUARTE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "nrf_cli.h" +#include "nrf_ringbuf.h" +#include "app_timer.h" +#include "nrf_uarte.h" + +/**@file + * + * @defgroup nrf_cli_libuarte libUARTE command line interface transport layer. + * @ingroup nrf_cli + * + * @{ + * + */ + +/** + * @brief Command line interface transport. + * */ +extern const nrf_cli_transport_api_t cli_libuarte_transport_api; + +typedef struct cli_libuarte_internal_s cli_libuarte_internal_t; + +typedef struct { + nrf_cli_transport_handler_t handler; + void * p_context; + bool blocking; +} cli_libuarte_internal_cb_t; + +struct cli_libuarte_internal_s { + nrf_cli_transport_t transport; + cli_libuarte_internal_cb_t * p_cb; + nrf_ringbuf_t const * p_rx_ringbuf; + nrf_ringbuf_t const * p_tx_ringbuf; +}; + +typedef struct +{ + uint32_t tx_pin; + uint32_t rx_pin; + nrf_uarte_hwfc_t hwfc; ///< Flow control configuration. + nrf_uarte_parity_t parity; ///< Parity configuration. + nrf_uarte_baudrate_t baudrate; ///< Baudrate. +} cli_libuarte_config_t; + +/**@brief CLI libUARTE transport definition. + * + * @param _name Name of instance. + * @param _tx_buf_sz Size of TX ring buffer. + * @param _rx_buf_sz Size of RX ring buffer. + */ +#define NRF_CLI_LIBUARTE_DEF(_name, _tx_buf_sz, _rx_buf_sz) \ + NRF_RINGBUF_DEF(CONCAT_2(_name,_tx_ringbuf), _tx_buf_sz); \ + NRF_RINGBUF_DEF(CONCAT_2(_name,_rx_ringbuf), _rx_buf_sz); \ + static cli_libuarte_internal_cb_t CONCAT_2(_name, _cb); \ + static const cli_libuarte_internal_t _name = { \ + .transport = {.p_api = &cli_libuarte_transport_api}, \ + .p_cb = &CONCAT_2(_name, _cb), \ + .p_rx_ringbuf = &CONCAT_2(_name,_rx_ringbuf), \ + .p_tx_ringbuf = &CONCAT_2(_name,_tx_ringbuf), \ + } +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_LOG_BACKEND_LIBUARTE_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli.c similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli.c index 54a5c42..eca1298 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_CLI) @@ -48,6 +48,11 @@ #include "nrf_assert.h" #include "nrf_delay.h" #include "nrf_pwr_mgmt.h" +#include "nrf_atomic.h" + +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) +#include "fnmatch.h" +#endif #if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) #if NRF_CLI_HISTORY_ELEMENT_SIZE * NRF_CLI_HISTORY_ELEMENT_COUNT == 0 @@ -64,6 +69,30 @@ #error too small NRF_CLI_PRINTF_BUFF_SIZE #endif +#define NRF_CLI_HELP_CLEAR "Clear screen." +#define NRF_CLI_HELP_COLORS "Toggle colored syntax." +#define NRF_CLI_HELP_COLORS_OFF "Disable colored syntax." +#define NRF_CLI_HELP_COLORS_ON "Enable colored syntax." +#define NRF_CLI_HELP_STATISTICS "CLI statistics." +#define NRF_CLI_HELP_STATISTICS_SHOW "Get CLI statistics for the Logger module." +#define NRF_CLI_HELP_STATISTICS_RESET "Reset CLI statistics for the Logger module." +#define NRF_CLI_HELP_RESIZE "Console gets terminal screen size or assumes 80 in case " \ + "the readout fails. It must be executed after each terminal " \ + "width change to ensure correct text display." +#define NRF_CLI_HELP_RESIZE_DEFAULT "Assume 80 chars screen width and send this setting " \ + "to the terminal." +#define NRF_CLI_HELP_HISTORY "Command history." +#define NRF_CLI_HELP_ECHO "Toggle CLI echo." +#define NRF_CLI_HELP_ECHO_ON "Enable CLI echo." +#define NRF_CLI_HELP_ECHO_OFF "Disable CLI echo. Arrows and buttons: Backspace, " \ + "Delete, End, Home, Insert are not handled." +#define NRF_CLI_HELP_CLI "Useful, not Unix-like CLI commands." + +#define NRF_CLI_MSG_SPECIFY_SUBCOMMAND "Please specify a subcommand." +#define NRF_CLI_MSG_UNKNOWN_PARAMETER " unknown parameter: " +#define NRF_CLI_MSG_COMMAND_NOT_FOUND ": command not found" +#define NRF_CLI_MSG_TAB_OVERFLOWED "Tab function: commands counter overflowed." + /*lint -save -esym(526,cli_command*) -esym(526,cli_sorted_cmd_ptrs*)*/ NRF_SECTION_DEF(cli_command, nrf_cli_cmd_entry_t); #define CLI_DATA_SECTION_ITEM_GET(i) NRF_SECTION_ITEM_GET(cli_command, nrf_cli_cmd_entry_t, (i)) @@ -79,16 +108,6 @@ NRF_SECTION_DEF(cli_sorted_cmd_ptrs, const char *); #include "nrf_log_internal.h" #endif -#define NRF_CLI_IO_BUFFER_AUTO_FLUSH_ENABLE(_p_cli) (_p_cli->p_fprintf_ctx->auto_flush = true) -#define NRF_CLI_IO_BUFFER_AUTO_FLUSH_DISABLE(_p_cli) (_p_cli->p_fprintf_ctx->auto_flush = false) -#define NRF_CLI_IO_BUFFER_FLUSH(_p_cli) nrf_fprintf_buffer_flush(_p_cli->p_fprintf_ctx) - -#define NRF_CLI_HELP_FLAG_SET(_p_cli) (_p_cli->p_ctx->show_help = true) -#define NRF_CLI_HELP_FLAG_CLEAR(_p_cli) (_p_cli->p_ctx->show_help = false) - -#define NRF_CLI_ECHO_ON_MODE(_p_cli) (_p_cli->p_ctx->echo != false) - -#define NRF_CLI_RECIEVE_STATE_NEXT(_p_cli, _state) (_p_cli->p_ctx->receive_state = _state) #define NRF_CLI_INIT_OPTION_PRINTER (NULL) #define NRF_CLI_MAX_TERMINAL_SIZE (250u) @@ -107,19 +126,83 @@ NRF_SECTION_DEF(cli_sorted_cmd_ptrs, const char *); nrf_fprintf(_p_cli_->p_fprintf_ctx, "%s", cmd); \ } -#if NRF_MODULE_ENABLED(NRF_CLI_BUILD_IN_CMDS) -static char const m_nrf_cli_uknown_parameter[] = " unknown parameter: "; +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) +typedef enum +{ + WILDCARD_CMD_ADDED, + WILDCARD_CMD_ADDED_MISSING_SPACE, + WILDCARD_CMD_NO_MATCH_FOUND +} wildcard_cmd_status_t; #endif -static char const m_nrf_cli_command_not_found[] = ": command not found"; + static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip); static void cli_execute(nrf_cli_t const * p_cli); + +static inline void transport_buffer_flush(nrf_cli_t const * p_cli) +{ + nrf_fprintf_buffer_flush(p_cli->p_fprintf_ctx); +} + +static inline void cli_flag_help_set(nrf_cli_t const * p_cli) +{ + p_cli->p_ctx->internal.flag.show_help = 1; +} +static inline void cli_flag_help_clear(nrf_cli_t const * p_cli) +{ + p_cli->p_ctx->internal.flag.show_help = 0; +} + +#if NRF_MODULE_ENABLED(NRF_CLI_BUILD_IN_CMDS) +static inline void cli_flag_echo_set(nrf_cli_t const * p_cli) +{ + p_cli->p_ctx->internal.flag.echo = 1; +} + +static inline void cli_flag_echo_clear(nrf_cli_t const * p_cli) +{ + p_cli->p_ctx->internal.flag.echo = 0; +} +#endif /* NRF_MODULE_ENABLED(NRF_CLI_BUILD_IN_CMDS) */ + +static inline bool cli_flag_echo_is_set(nrf_cli_t const * p_cli) +{ + return p_cli->p_ctx->internal.flag.echo == 1 ? true : false; +} + +static inline bool cli_flag_processing_is_set(nrf_cli_t const * p_cli) +{ + return p_cli->p_ctx->internal.flag.processing == 1 ? true : false; +} + +static inline uint8_t cli_flag_last_nl_get(nrf_cli_t const * p_cli) +{ + return p_cli->p_ctx->internal.flag.last_nl; +} + +static inline void cli_flag_last_nl_set(nrf_cli_t const * p_cli, uint8_t val) +{ + p_cli->p_ctx->internal.flag.last_nl = val; +} + +static inline void receive_state_change(nrf_cli_t const * p_cli, nrf_cli_receive_t state) +{ + p_cli->p_ctx->receive_state = state; +} + static inline size_t cli_strlen(char const * str) { return str == NULL ? 0 : strlen(str); } +static void cli_cmd_buffer_clear(nrf_cli_t const * p_cli) +{ + p_cli->p_ctx->cmd_buff[0] = '\0'; /* clear command buffer */ + p_cli->p_ctx->cmd_buff_pos = 0; + p_cli->p_ctx->cmd_buff_len = 0; +} + /* Function returns true if cursor is at beginning of an empty line. */ static inline bool cursor_in_empty_line(nrf_cli_t const * p_cli) { @@ -134,9 +217,25 @@ static inline bool full_line_cmd(nrf_cli_t const * p_cli) p_cli->p_ctx->vt100_ctx.cons.terminal_wid == 0); } -/* Function sends data stream to cli instance. Each time before cli_write function is called +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) +/* Function returns true if string contains wildcard character: '?' or '*'. */ +static bool wildcard_character_exist(char * p_str) +{ + size_t str_len = cli_strlen(p_str); + for (size_t i = 0; i < str_len; i++) + { + if ((p_str[i] == '?') || (p_str[i] == '*')) + { + return true; + } + } + return false; +} +#endif + +/* Function sends data stream to the CLI instance. Each time before the cli_write function is called, * it must be ensured that IO buffer of fprintf is flushed to avoid synchronization issues. - * For that purpose macro: NRF_CLI_IO_BUFFER_FLUSH(p_cli) shall be used */ + * For that purpose, use function transport_buffer_flush(p_cli) */ static void cli_write(nrf_cli_t const * p_cli, void const * p_data, size_t length, @@ -162,11 +261,11 @@ static void cli_write(nrf_cli_t const * p_cli, #if NRF_MODULE_ENABLED(NRF_CLI_USES_TASK_MANAGER) (void)task_events_wait(NRF_CLI_TRANSPORT_TX_RDY_TASK_EVT); #else - while (p_cli->p_ctx->tx_rdy == false) + while (p_cli->p_ctx->internal.flag.tx_rdy == 0) { ; } - p_cli->p_ctx->tx_rdy = false; + p_cli->p_ctx->internal.flag.tx_rdy = 0; #endif } } @@ -177,13 +276,13 @@ static void cli_write(nrf_cli_t const * p_cli, } } -/* Function sends 1 character to cli instance. */ +/* Function sends 1 character to the CLI instance. */ static inline void cli_putc(nrf_cli_t const * p_cli, char ch) { nrf_fprintf(p_cli->p_fprintf_ctx, "%c", ch); } -/* Function reads data from cli instance. */ +/* Function reads data from the CLI instance. */ static void cli_read(nrf_cli_t const * p_cli, void * p_data, size_t length, @@ -196,13 +295,13 @@ static void cli_read(nrf_cli_t const * p_cli, UNUSED_VARIABLE(ret); } -/* Function cmd_get shall be used to search commands. It moves pointer pp_entry to command - * of static command structure. If command cannot be found function will set pp_entry to NULL. - * p_command - pointer to command which will be processed (no matter for root command) - * lvl - level of requested command - * idx - index of requested command - * pp_entry - pointer which will point to subcommand[idx] after function execution - * p_st_entry - pointer to structure where dynamic entry data can be stored +/* Function cmd_get shall be used to search commands. It moves the pointer pp_entry to command + * of static command structure. If the command cannot be found, the function will set pp_entry to NULL. + * p_command Pointer to command which will be processed (no matter the root command). + * lvl Level of the requested command. + * idx Index of the requested command. + * pp_entry Pointer which points to subcommand[idx] after function execution. + * p_st_entry Pointer to the structure where dynamic entry data can be stored. */ static void cmd_get(nrf_cli_cmd_entry_t const * p_command, size_t lvl, @@ -264,8 +363,8 @@ static void cmd_get(nrf_cli_cmd_entry_t const * p_command, } } -/* Function multiline_console_data_check checks current cursor position (x, y) on terminal screen - * basing on: command length, console name length and terminal width. +/* Function multiline_console_data_check checks the current cursor position (x, y) on terminal screen + * based on: command length, console name length, and terminal width. * Example 1: * || - cursor * ---------------------------- @@ -301,13 +400,68 @@ static nrf_cli_multiline_cons_t const * multiline_console_data_check(nrf_cli_t c p_cons->cur_x = (p_ctx->cmd_buff_pos + p_cons->name_len) % p_cons->terminal_wid + 1; p_cons->cur_y = (p_ctx->cmd_buff_pos + p_cons->name_len) / p_cons->terminal_wid + 1; - /* Extreme postion when cursor is at the end of command. */ + /* Extreme position when cursor is at the end of command. */ p_cons->cur_y_end = (p_ctx->cmd_buff_len + p_cons->name_len) / p_cons->terminal_wid + 1; p_cons->cur_x_end = (p_ctx->cmd_buff_len + p_cons->name_len) % p_cons->terminal_wid + 1; return p_cons; } + +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/* Calculates relative line number of given position in buffer */ +static uint32_t cli_line_num_with_buffer_offset_get(nrf_cli_t const * p_cli, + nrf_cli_cmd_len_t buffer_pos) +{ + uint32_t name_len; + nrf_cli_multiline_cons_t *p_cons = &p_cli->p_ctx->vt100_ctx.cons; + + name_len = cli_strlen(p_cli->p_name); + + return ((buffer_pos + name_len) / p_cons->terminal_wid); +} +#endif + + +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/* Calculates column number of given position in buffer */ +static uint32_t cli_col_num_with_buffer_offset_get(nrf_cli_t const * p_cli, + nrf_cli_cmd_len_t buffer_pos) +{ + uint32_t name_len; + nrf_cli_multiline_cons_t *p_cons = &p_cli->p_ctx->vt100_ctx.cons; + + name_len = cli_strlen(p_cli->p_name); + + /* columns are counted from 1 */ + return (1 + ((buffer_pos + name_len) % p_cons->terminal_wid)); +} +#endif + + +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/* For the given buffer, calculates row span between position2 and position1 */ +static int32_t cli_row_span_with_buffer_offsets_get(nrf_cli_t const * p_cli, + nrf_cli_cmd_len_t offset1, + nrf_cli_cmd_len_t offset2) +{ + return cli_line_num_with_buffer_offset_get(p_cli, offset2) + - cli_line_num_with_buffer_offset_get(p_cli, offset1); +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/* For the given buffer, calculates column span between position2 and position 1 */ +static int32_t cli_column_span_with_buffer_offsets_get(nrf_cli_t const * p_cli, + nrf_cli_cmd_len_t offset1, + nrf_cli_cmd_len_t offset2) +{ + return cli_col_num_with_buffer_offset_get(p_cli, offset2) + - cli_col_num_with_buffer_offset_get(p_cli, offset1); +} +#endif + + /* Function sends VT100 command to clear the screen from cursor position to end of the screen. */ static inline void cli_clear_eos(nrf_cli_t const * p_cli) { @@ -329,7 +483,7 @@ static inline void cli_cursor_restore(nrf_cli_t const * p_cli) /* Function forcing new line - cannot be replaced with function cursor_down_move. */ static inline void cursor_next_line_move(nrf_cli_t const * p_cli) { - NRF_CLI_VT100_CMD(p_cli, NRF_CLI_VT100_NEXTLINE); + nrf_fprintf(p_cli->p_fprintf_ctx, "\n"); } /* Function moves cursor left by n positions. */ @@ -350,6 +504,22 @@ static inline void cursor_right_move(nrf_cli_t const * p_cli, nrf_cli_cmd_len_t } } +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/* Moves cursor horizontally by a number. Positive is right */ +static void cursor_horiz_move(nrf_cli_t const * p_cli, int32_t delta) +{ + if (delta > 0) + { + cursor_right_move(p_cli, delta); + } + else if (delta < 0) + { + cursor_left_move(p_cli, -delta); + } + else { } +} +#endif + /* Function moves cursor up by n positions. */ static inline void cursor_up_move(nrf_cli_t const * p_cli, nrf_cli_cmd_len_t n) { @@ -360,7 +530,7 @@ static inline void cursor_up_move(nrf_cli_t const * p_cli, nrf_cli_cmd_len_t n) } /* Function moves cursor down by n positions but it will bring no effect if cursor is in the last - * line of terminal screen. In such case cursor_next_line_move function shall be invoked. */ + * line of terminal screen. In such case, the cursor_next_line_move function shall be invoked. */ static inline void cursor_down_move(nrf_cli_t const * p_cli, nrf_cli_cmd_len_t n) { if (n > 0) @@ -369,6 +539,22 @@ static inline void cursor_down_move(nrf_cli_t const * p_cli, nrf_cli_cmd_len_t n } } +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/* Moves cursor vertically by a number. Positive is down */ +static void cursor_vert_move(nrf_cli_t const * p_cli, int32_t delta) +{ + if (delta > 0) + { + cursor_down_move(p_cli, delta); + } + else if (delta < 0) + { + cursor_up_move(p_cli, -delta); + } + else { } +} +#endif + /* Function increments cursor position (if possible) and moves cursor to new line if necessary. */ static void cursor_position_increment(nrf_cli_t const * p_cli) { @@ -400,7 +586,7 @@ static void cursor_position_synchronize(nrf_cli_t const * p_cli) nrf_cli_multiline_cons_t const * p_cons = multiline_console_data_check(p_cli); bool last_line = p_cons->cur_y == p_cons->cur_y_end ? true : false; - /* In case cursor reaches bottom line of a terminal it will be moved to next line. */ + /* In case cursor reaches the bottom line of a terminal, it will be moved to the next line. */ if (cursor_in_empty_line(p_cli) || full_line_cmd(p_cli)) { cursor_next_line_move(p_cli); @@ -424,6 +610,68 @@ static void cursor_position_synchronize(nrf_cli_t const * p_cli) } } +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) +/** + * Removes the "word" to the left of the cursor: + * - if there are spaces at the cursor position, remove all spaces to the left + * - remove the non-spaces (word) until a space is found or a beginning of buffer + */ +static void cli_cmd_word_remove(nrf_cli_t const * p_cli) +{ + nrf_cli_cmd_len_t new_pos; + nrf_cli_cmd_len_t chars_to_delete; + int32_t row_span; + int32_t col_span; + + /* Line must not be empty and cursor must not be at 0 to continue */ + if ((p_cli->p_ctx->cmd_buff_len == 0) || (p_cli->p_ctx->cmd_buff_pos == 0)) + { + return; + } + + /* start at the current position */ + new_pos = p_cli->p_ctx->cmd_buff_pos; + chars_to_delete = 0; + + /* look back for all spaces then for non-spaces */ + while ((new_pos >= 1) && (p_cli->p_ctx->cmd_buff[new_pos - 1] == ' ')) + { + ++chars_to_delete; + --new_pos; + } + + while ((new_pos >= 1) && (p_cli->p_ctx->cmd_buff[new_pos - 1] != ' ')) + { + --new_pos; + ++chars_to_delete; + } + + /* calculate the new cursor */ + row_span = cli_row_span_with_buffer_offsets_get(p_cli, p_cli->p_ctx->cmd_buff_pos, new_pos); + col_span = cli_column_span_with_buffer_offsets_get(p_cli, p_cli->p_ctx->cmd_buff_pos, new_pos); + + /* manage the buffer */ + memmove(&p_cli->p_ctx->cmd_buff[new_pos], + &p_cli->p_ctx->cmd_buff[new_pos + chars_to_delete], + p_cli->p_ctx->cmd_buff_len - chars_to_delete); + p_cli->p_ctx->cmd_buff_len -= chars_to_delete; + p_cli->p_ctx->cmd_buff_pos = new_pos; + p_cli->p_ctx->cmd_buff[p_cli->p_ctx->cmd_buff_len] = '\0'; + + /* update display */ + cursor_horiz_move(p_cli, col_span); + cursor_vert_move(p_cli, row_span); + cli_cursor_save(p_cli); + nrf_cli_fprintf(p_cli, + NRF_CLI_NORMAL, + "%s", + &p_cli->p_ctx->cmd_buff[p_cli->p_ctx->cmd_buff_pos]); + cli_clear_eos(p_cli); + cli_cursor_restore(p_cli); +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) || NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) /* Function moves cursor to begin of command position, just after console name. */ static void cursor_home_position_move(nrf_cli_t const * p_cli) { @@ -451,6 +699,7 @@ static void cursor_home_position_move(nrf_cli_t const * p_cli) /* align data buffer pointer with cursor position */ p_cli->p_ctx->cmd_buff_pos = 0; } +#endif /* Function moves cursor to end of command. */ static void cursor_end_position_move(nrf_cli_t const * p_cli) @@ -483,11 +732,12 @@ static void cursor_end_position_move(nrf_cli_t const * p_cli) /* Function reads cursor position from terminal. */ static ret_code_t cursor_position_get(nrf_cli_t const * p_cli) { - size_t cnt; + size_t cnt; uint16_t x = 0; /* horizontal position */ uint16_t y = 0; /* vertical position */ - uint8_t buff_idx = 0; - char c = 0; + char c = 0; + + nrf_cli_cmd_len_t buff_idx = 0; /* clear temp buffer */ memset(p_cli->p_ctx->temp_buff, 0, sizeof(p_cli->p_ctx->temp_buff)); @@ -497,7 +747,7 @@ static ret_code_t cursor_position_get(nrf_cli_t const * p_cli) nrf_fprintf(p_cli->p_fprintf_ctx, cmd_get_terminal_size); /* fprintf buffer needs to be flushed to start sending prepared escape code to the terminal */ - NRF_CLI_IO_BUFFER_FLUSH(p_cli); + transport_buffer_flush(p_cli); /* timeout for terminal response = ~1s */ for (uint16_t i = 0; i < 1000; i++) @@ -735,7 +985,7 @@ static inline void char_insert_echo_off(nrf_cli_t const * p_cli, char data) static void char_insert(nrf_cli_t const * p_cli, char data) { nrf_cli_cmd_len_t diff; - bool ins_mode = p_cli->p_ctx->insert_mode; + bool ins_mode = (bool)p_cli->p_ctx->internal.flag.insert_mode; diff = p_cli->p_ctx->cmd_buff_len - p_cli->p_ctx->cmd_buff_pos; @@ -757,7 +1007,7 @@ static void char_insert(nrf_cli_t const * p_cli, char data) if ((p_cli->p_ctx->cmd_buff_len >= (NRF_CLI_CMD_BUFF_SIZE - 1)) && (diff == 0)) { - /* If cmd buffer is full it is possible to replace chars but adding new + /* If cmd buffer is full, it is possible to replace chars but adding new is not allowed. */ return; } @@ -783,18 +1033,18 @@ static void char_insert(nrf_cli_t const * p_cli, char data) "%s", &p_cli->p_ctx->cmd_buff[p_cli->p_ctx->cmd_buff_pos]); /* Move cursor one position left less in case of insert mode. */ - cursor_left_move(p_cli, diff - ins_mode); + cursor_left_move(p_cli, diff - ins_mode); } else { - /* Save current cursor position in order to get back after fprintf function. */ + /* Save the current cursor position in order to get back after fprintf function. */ cli_cursor_save(p_cli); nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%s", &p_cli->p_ctx->cmd_buff[p_cli->p_ctx->cmd_buff_pos]); cli_cursor_restore(p_cli); - /* Move cursor right by one position to edit next character. */ + /* Move cursor right by one position to edit the next character. */ cursor_right_move(p_cli, 1); } } @@ -811,7 +1061,7 @@ static void char_insert(nrf_cli_t const * p_cli, char data) /* Incrementation needs to be executed before invoking function: cursor_in_empty_line. */ ++p_cli->p_ctx->cmd_buff_pos; - /* Forcing terminal to switch to new line if command is too long. */ + /* Forcing terminal to switch to a new line if the command is too long. */ if (cursor_in_empty_line(p_cli)) { cursor_next_line_move(p_cli); @@ -822,8 +1072,8 @@ static void char_insert(nrf_cli_t const * p_cli, char data) { nrf_cli_multiline_cons_t const * p_cons = multiline_console_data_check(p_cli); - /* Below code will force terminal to scroll one line down when currently entered command - * reaches lower right corner of terminal screen. */ + /* The code below will force the terminal to scroll one line down when the currently entered command + * reaches lower right corner of the terminal screen. */ cursor_down_move(p_cli, p_cons->cur_y_end - p_cons->cur_y - 1); cursor_next_line_move(p_cli); cursor_up_move(p_cli, p_cons->cur_y_end - p_cons->cur_y); @@ -868,7 +1118,7 @@ static void char_backspace(nrf_cli_t const * p_cli) } else { - /* If cursor is not in last cmd line its position needs to be saved by + /* If cursor is not in last cmd line, its position needs to be saved by * VT100 command. */ cli_cursor_save(p_cli); cli_clear_eos(p_cli); @@ -1081,9 +1331,7 @@ static void cli_state_set(nrf_cli_t const * p_cli, nrf_cli_state_t state) if (state == NRF_CLI_STATE_ACTIVE) { - p_cli->p_ctx->cmd_buff[0] = '\0'; /* clear command buffer */ - p_cli->p_ctx->cmd_buff_pos = 0; - p_cli->p_ctx->cmd_buff_len = 0; + cli_cmd_buffer_clear(p_cli); nrf_cli_fprintf(p_cli, NRF_CLI_INFO, "%s", p_cli->p_name); } } @@ -1115,7 +1363,7 @@ static void history_handle(nrf_cli_t const * p_cli, bool up) nrf_memobj_read(p_cli->p_ctx->p_cmd_list_element, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); p_cli->p_ctx->p_cmd_list_element = header.p_next; current_cmd_len = p_cli->p_ctx->cmd_buff_len; @@ -1149,7 +1397,7 @@ static void history_handle(nrf_cli_t const * p_cli, bool up) current_cmd_len = cli_strlen(p_cli->p_ctx->cmd_buff); p_cli->p_ctx->p_cmd_list_element = p_cli->p_ctx->p_cmd_list_head; - /* Save currently entered and not executed command. */ + /* Save the currently entered and not executed command. */ if (current_cmd_len > 0) { strcpy(p_cli->p_ctx->temp_buff, p_cli->p_ctx->cmd_buff); @@ -1164,7 +1412,7 @@ static void history_handle(nrf_cli_t const * p_cli, bool up) nrf_memobj_read(p_cli->p_ctx->p_cmd_list_element, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); current_cmd_len = header.cmd_len; p_cli->p_ctx->p_cmd_list_element = header.p_prev; } @@ -1174,12 +1422,12 @@ static void history_handle(nrf_cli_t const * p_cli, bool up) nrf_memobj_read(p_cli->p_ctx->p_cmd_list_element, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); nrf_memobj_read(p_cli->p_ctx->p_cmd_list_element, p_cli->p_ctx->cmd_buff, header.cmd_len + 1, /* +1 for '\0' */ - (uint32_t)NRF_CLI_HISTORY_HEADER_SIZE); + NRF_CLI_HISTORY_HEADER_SIZE); } p_cli->p_ctx->cmd_buff_pos = header.cmd_len; @@ -1216,14 +1464,14 @@ static void history_list_element_add(nrf_cli_t const * p_cli, nrf_memobj_t * p_m nrf_memobj_read(p_cli->p_ctx->p_cmd_list_head, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); header.p_next = p_memobj; nrf_memobj_write(p_cli->p_ctx->p_cmd_list_head, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); header.p_next = NULL; header.p_prev = p_cli->p_ctx->p_cmd_list_head; @@ -1235,12 +1483,12 @@ static void history_list_element_add(nrf_cli_t const * p_cli, nrf_memobj_t * p_m nrf_memobj_write(p_memobj, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); nrf_memobj_write(p_memobj, p_cli->p_ctx->cmd_buff, p_cli->p_ctx->cmd_buff_len + 1, /* +1 for '\0' */ - (uint32_t)NRF_CLI_HISTORY_HEADER_SIZE); + NRF_CLI_HISTORY_HEADER_SIZE); } static void history_list_element_oldest_remove(nrf_cli_t const * p_cli) @@ -1256,7 +1504,7 @@ static void history_list_element_oldest_remove(nrf_cli_t const * p_cli) nrf_memobj_read(p_memobj, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); p_cli->p_ctx->p_cmd_list_tail = header.p_next; memset(&header, 0, sizeof(nrf_cli_memobj_header_t)); @@ -1273,7 +1521,7 @@ static void history_list_element_oldest_remove(nrf_cli_t const * p_cli) nrf_memobj_read(p_cli->p_ctx->p_cmd_list_tail, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); header.p_prev = NULL; nrf_memobj_write(p_cli->p_ctx->p_cmd_list_tail, &header, NRF_CLI_HISTORY_HEADER_SIZE, 0); @@ -1306,13 +1554,13 @@ static void history_save(nrf_cli_t const * p_cli) nrf_memobj_read(p_cli->p_ctx->p_cmd_list_head, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); if (cmd_new_len == header.cmd_len) { nrf_memobj_read(p_cli->p_ctx->p_cmd_list_head, p_cli->p_ctx->temp_buff, header.cmd_len + 1, /* +1 for '\0' */ - (uint32_t)NRF_CLI_HISTORY_HEADER_SIZE); + NRF_CLI_HISTORY_HEADER_SIZE); if (strcmp(p_cli->p_ctx->cmd_buff, p_cli->p_ctx->temp_buff) == 0) { @@ -1344,7 +1592,7 @@ static void history_save(nrf_cli_t const * p_cli) } #endif // NRF_MODULE_ENABLED(NRF_CLI_HISTORY) -/* Function checks how many identical characters have two strings starting from first character. */ +/* Function checks how many identical characters have two strings starting from the first character. */ static nrf_cli_cmd_len_t str_similarity_check(char const * str_a, char const * str_b) { nrf_cli_cmd_len_t cnt = 0; @@ -1426,7 +1674,7 @@ static void option_print(nrf_cli_t const * p_cli, if (p_cli->p_ctx->vt100_ctx.printed_cmd++ % columns == 0) { - nrf_cli_fprintf(p_cli, NRF_CLI_OPTION, "\r\n%s%s", tab, p_option); + nrf_cli_fprintf(p_cli, NRF_CLI_OPTION, "\n%s%s", tab, p_option); } else { @@ -1435,11 +1683,19 @@ static void option_print(nrf_cli_t const * p_cli, cursor_right_move(p_cli, diff); } +static inline bool is_completion_candidate(const char *candidate, + const char *str, + size_t len) +{ + return (strncmp(candidate, str, len) == 0) ? true : false; +} + static void cli_tab_handle(nrf_cli_t const * p_cli) { size_t cmd_idx; size_t cmd_last = 0; size_t cmd_first = 0; + size_t cmd_cnt = 0; size_t argc; char * argv[NRF_CLI_ARGC_MAX + 1]; /* +1 reserved for NULL in function make_argv */ @@ -1447,7 +1703,7 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) nrf_cli_cmd_len_t cmd_lvl = NRF_CLI_CMD_ROOT_LVL; nrf_cli_cmd_len_t cmd_longest = 0; /* longest matching command */ - /* Calculating longest possible completion length. -1 for '\0'. */ + /* Calculating the longest possible completion length. -1 for '\0'. */ nrf_cli_cmd_len_t compl_len = (NRF_CLI_CMD_BUFF_SIZE - 1) - p_cli->p_ctx->cmd_buff_len; if (compl_len == 0) @@ -1462,11 +1718,11 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) p_cli->p_ctx->temp_buff[p_cli->p_ctx->cmd_buff_pos] = '\0'; - /* Check if current cursor position points to 'space' character. */ + /* Check if the current cursor position points to the 'space' character. */ bool space = isspace((int)p_cli->p_ctx->cmd_buff[p_cli->p_ctx->cmd_buff_pos - 1]); #if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) - /* If the Tab key is pressed "history mode" must be terminated because tab and history handlers + /* If the Tab key is pressed, "history mode" must be terminated because tab and history handlers are sharing the same array: temp_buff. */ history_mode_exit(p_cli); #endif @@ -1512,15 +1768,15 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) break; } - if (strncmp(argv[cmd_lvl], p_st_cmd->p_syntax, arg_len) != 0) + if (!is_completion_candidate(argv[cmd_lvl], + p_st_cmd->p_syntax, + arg_len)) { - if (p_st_cmd_last != NULL) - { - /* No more match will be found as commands are sorted alphabetically. */ - break; - } continue; } + + cmd_cnt++; + if (p_st_cmd_last == NULL) { cmd_first = cmd_idx - 1; @@ -1538,7 +1794,7 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) cmd_longest = len; } - if (compl_len > 0) /* checking if partial completion possible */ + if (compl_len > 0) /* Checking if partial completion is possible */ { nrf_cli_static_entry_t last_entry; cmd_get(p_cmd, cmd_lvl, cmd_last, &p_st_cmd_last, &last_entry); @@ -1547,7 +1803,7 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) p_st_cmd_last->p_syntax + arg_len); if (compl_len > len) { - /* Determining longest possible completion. */ + /* Determining the longest possible completion. */ compl_len = len; } } @@ -1555,11 +1811,9 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) cmd_last = cmd_idx - 1; p_st_cmd_last = p_st_cmd; - if (cmd_idx == 0) /* too many possibilities */ + if (cmd_idx == 0) /* Too many possibilities */ { - nrf_cli_fprintf(p_cli, - NRF_CLI_WARNING, - "Tab function: commands counter overflowed.\r\n"); + nrf_cli_warn(p_cli, NRF_CLI_MSG_TAB_OVERFLOWED); break; } } @@ -1575,18 +1829,26 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) if (cmd_idx == 0) { /* No match found and commands counter overflowed. */ - nrf_cli_fprintf(p_cli, - NRF_CLI_WARNING, - "Tab function: commands counter overflowed.\r\n"); + nrf_cli_warn(p_cli, NRF_CLI_MSG_TAB_OVERFLOWED); return; } - if (p_st_cmd == NULL) /* no more commands available */ + if (p_st_cmd == NULL) /* No more commands available */ { return; } - /* Fuction "strcmp" is used because exact match is required. */ +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) + /* Ignore wildcard character arguments if they are "standalone". Example: + 1. log enable info b* -> "b*" is treated as a command so no match found + 2. log enable info b* -> "b* " is ignored, will prompt all available + commands. */ + if (wildcard_character_exist(argv[cmd_lvl])) + { + break; + } +#endif + /* Fuction "strcmp" is used because an exact match is required. */ if (strcmp(argv[cmd_lvl], p_st_cmd->p_syntax) == 0) { p_cmd = p_st_cmd->p_subcmd; @@ -1602,13 +1864,13 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) } while (++cmd_lvl < argc + space); - if (p_st_cmd_last == NULL) + if (cmd_cnt == 0) { /* No match found. */ return; } - if (cmd_first == cmd_last) /* only 1 match found */ + if (cmd_cnt == 1) /* only one match found */ { if (p_cmd->is_dynamic) { @@ -1618,7 +1880,7 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) */ cmd_get(p_cmd, cmd_lvl, cmd_last, &p_st_cmd_last, &static_entry); } - if (cli_strlen(p_st_cmd_last->p_syntax) != arg_len) /* not excact match found */ + if (cli_strlen(p_st_cmd_last->p_syntax) != arg_len) /* no exact match found */ { completion_insert(p_cli, p_st_cmd_last->p_syntax + arg_len, compl_len); } @@ -1626,11 +1888,11 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) /* Next character in the buffer is not 'space'. */ if (!isspace((int)p_cli->p_ctx->cmd_buff[p_cli->p_ctx->cmd_buff_pos])) { - if (p_cli->p_ctx->insert_mode) + if (p_cli->p_ctx->internal.flag.insert_mode) { - p_cli->p_ctx->insert_mode = false; + p_cli->p_ctx->internal.flag.insert_mode = 0; char_insert(p_cli, ' '); - p_cli->p_ctx->insert_mode = true; + p_cli->p_ctx->internal.flag.insert_mode = 1; } else { @@ -1653,19 +1915,46 @@ static void cli_tab_handle(nrf_cli_t const * p_cli) /* Printing all matching commands (options). */ option_print(p_cli, NRF_CLI_INIT_OPTION_PRINTER, cmd_longest); - for (cmd_idx = cmd_first; cmd_idx <= cmd_last; cmd_idx++) + cmd_idx = cmd_first; + while (cmd_cnt) { - cmd_get(p_cmd, cmd_lvl, cmd_idx, &p_st_cmd, &static_entry); + cmd_get(p_cmd, cmd_lvl, cmd_idx++, &p_st_cmd, &static_entry); + if (!is_completion_candidate(argv[cmd_lvl], + p_st_cmd->p_syntax, + arg_len)) + { + continue; + } + cmd_cnt--; option_print(p_cli, p_st_cmd->p_syntax, cmd_longest); } - nrf_cli_fprintf(p_cli, NRF_CLI_INFO, "\r\n%s", p_cli->p_name); + nrf_cli_fprintf(p_cli, NRF_CLI_INFO, "\n%s", p_cli->p_name); nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%s", p_cli->p_ctx->cmd_buff); cursor_position_synchronize(p_cli); completion_insert(p_cli, p_st_cmd_last->p_syntax + arg_len, compl_len); } +/* Functions returns true if new line character shall be processed */ +static bool process_nl(nrf_cli_t const * p_cli, uint8_t data) +{ + if ((data != '\r') && (data != '\n')) + { + cli_flag_last_nl_set(p_cli, 0); + return false; + } + + if ((cli_flag_last_nl_get(p_cli) == 0) || + (data == cli_flag_last_nl_get(p_cli))) + { + cli_flag_last_nl_set(p_cli, data); + return true; + } + + return false; +} + #define NRF_CLI_ASCII_MAX_CHAR (127u) static inline ret_code_t ascii_filter(char const data) { @@ -1697,10 +1986,11 @@ static void cli_state_collect(nrf_cli_t const * p_cli) switch (p_cli->p_ctx->receive_state) { case NRF_CLI_RECEIVE_DEFAULT: - if (data == p_cli->newline_char) + if (process_nl(p_cli, data)) { if (p_cli->p_ctx->cmd_buff_len == 0) { + history_mode_exit(p_cli); cursor_next_line_move(p_cli); } else @@ -1708,30 +1998,65 @@ static void cli_state_collect(nrf_cli_t const * p_cli) /* Command execution */ cli_execute(p_cli); } + cli_state_set(p_cli, NRF_CLI_STATE_ACTIVE); return; } switch (data) { case NRF_CLI_VT100_ASCII_ESC: /* ESCAPE */ - NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_ESC); + receive_state_change(p_cli, NRF_CLI_RECEIVE_ESC); break; case '\0': break; +#if NRF_MODULE_ENABLED(NRF_CLI_METAKEYS) + case NRF_CLI_VT100_ASCII_CTRL_A: /* CTRL + A */ + cursor_home_position_move(p_cli); + break; + case NRF_CLI_VT100_ASCII_CTRL_C: /* CTRL + C */ + cursor_end_position_move(p_cli); + if (!cursor_in_empty_line(p_cli)) + { + cursor_next_line_move(p_cli); + } + cli_state_set(p_cli, NRF_CLI_STATE_ACTIVE); + break; + case NRF_CLI_VT100_ASCII_CTRL_E: /* CTRL + E */ + cursor_end_position_move(p_cli); + break; + case NRF_CLI_VT100_ASCII_CTRL_L: /* CTRL + L */ + NRF_CLI_VT100_CMD(p_cli, NRF_CLI_VT100_CURSORHOME); + NRF_CLI_VT100_CMD(p_cli, NRF_CLI_VT100_CLEARSCREEN); + nrf_cli_fprintf(p_cli, NRF_CLI_INFO, "%s", p_cli->p_name); + if (cli_flag_echo_is_set(p_cli)) + { + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%s", p_cli->p_ctx->cmd_buff); + cursor_position_synchronize(p_cli); + } + break; + case NRF_CLI_VT100_ASCII_CTRL_U: /* CTRL + U */ + cursor_home_position_move(p_cli); + cli_cmd_buffer_clear(p_cli); + cli_clear_eos(p_cli); + break; + case NRF_CLI_VT100_ASCII_CTRL_W: /* CTRL + W */ + cli_cmd_word_remove(p_cli); + break; +#endif case '\t': /* TAB */ - if (NRF_CLI_ECHO_ON_MODE(p_cli)) + if (cli_flag_echo_is_set(p_cli)) { cli_tab_handle(p_cli); } break; case NRF_CLI_VT100_ASCII_BSPACE: /* BACKSPACE */ - if (NRF_CLI_ECHO_ON_MODE(p_cli)) + if (cli_flag_echo_is_set(p_cli)) { char_backspace(p_cli); } break; case NRF_CLI_VT100_ASCII_DEL: /* DELETE */ - if (NRF_CLI_ECHO_ON_MODE(p_cli)) + if (cli_flag_echo_is_set(p_cli)) { char_delete(p_cli); } @@ -1739,7 +2064,7 @@ static void cli_state_collect(nrf_cli_t const * p_cli) default: if (isprint((int)data)) { - if (NRF_CLI_ECHO_ON_MODE(p_cli)) + if (cli_flag_echo_is_set(p_cli)) { char_insert(p_cli, data); } @@ -1754,17 +2079,17 @@ static void cli_state_collect(nrf_cli_t const * p_cli) case NRF_CLI_RECEIVE_ESC: if (data == '[') { - NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_ESC_SEQ); + receive_state_change(p_cli, NRF_CLI_RECEIVE_ESC_SEQ); } else { - NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_DEFAULT); + receive_state_change(p_cli, NRF_CLI_RECEIVE_DEFAULT); } break; case NRF_CLI_RECEIVE_ESC_SEQ: - NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_DEFAULT); + receive_state_change(p_cli, NRF_CLI_RECEIVE_DEFAULT); - if (!NRF_CLI_ECHO_ON_MODE(p_cli)) + if (!cli_flag_echo_is_set(p_cli)) { return; } @@ -1785,21 +2110,40 @@ static void cli_state_collect(nrf_cli_t const * p_cli) case 'D': /* LEFT arrow */ left_arrow_handle(p_cli); break; - case 'F': /* END Button */ + case '4': /* END Button in ESC[n~ mode */ + receive_state_change(p_cli, NRF_CLI_RECEIVE_TILDE_EXP); + /* fall through */ + case 'F': /* END Button in VT100 mode */ cursor_end_position_move(p_cli); break; - case 'H': /* HOME Button */ + case '1': /* HOME Button in ESC[n~ mode */ + receive_state_change(p_cli, NRF_CLI_RECEIVE_TILDE_EXP); + /* fall through */ + case 'H': /* HOME Button in VT100 mode */ cursor_home_position_move(p_cli); break; - case 'L': /* INSERT Button */ - p_cli->p_ctx->insert_mode = !p_cli->p_ctx->insert_mode; + case '2': /* INSERT Button in ESC[n~ mode */ + receive_state_change(p_cli, NRF_CLI_RECEIVE_TILDE_EXP); + /* fall through */ + case 'L': /* INSERT Button in VT100 mode */ + p_cli->p_ctx->internal.flag.insert_mode ^= 1; + break; + case '3':/* DELETE Button in ESC[n~ mode */ + receive_state_change(p_cli, NRF_CLI_RECEIVE_TILDE_EXP); + if (cli_flag_echo_is_set(p_cli)) + { + char_delete(p_cli); + } break; default: break; } break; + case NRF_CLI_RECEIVE_TILDE_EXP: + receive_state_change(p_cli, NRF_CLI_RECEIVE_DEFAULT); + break; default: - NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_DEFAULT); + receive_state_change(p_cli, NRF_CLI_RECEIVE_DEFAULT); break; } } @@ -1815,7 +2159,7 @@ static void cmd_trim(nrf_cli_t const * p_cli) return; } - /* Counting white characters starting from beginning of command. */ + /* Counting white characters starting from beginning of the command. */ while (isspace((int)p_cli->p_ctx->cmd_buff[i++])) { if (i == 0) @@ -1853,8 +2197,184 @@ static void cmd_trim(nrf_cli_t const * p_cli) } } -/* Function is analyzing command buffer to find matching commands. Next it invokes last recognized - * command which has handler and passes rest of command buffer as arguments. */ +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) +static void spaces_trim(char * p_char) +{ + nrf_cli_cmd_len_t shift = 0; + nrf_cli_cmd_len_t len = cli_strlen(p_char); + + if (p_char == NULL) + { + return; + } + + for (nrf_cli_cmd_len_t i = 0; i < len - 1; i++) + { + if (isspace((int)p_char[i])) + { + for (nrf_cli_cmd_len_t j = i + 1; j < len; j++) + { + if (isspace((int)p_char[j])) + { + shift++; + continue; + } + if (shift > 0) + { + memmove(&p_char[i + 1], &p_char[j], len - shift - i); + len -= shift; + shift = 0; + } + break; + } + } + } +} + +/* Adds new command and one space just before pattern */ +static bool command_to_tmp_buffer_add(nrf_cli_t const * p_cli, + char const * p_new_cmd, + char const * p_pattern) +{ + nrf_cli_cmd_len_t cmd_len = cli_strlen(p_new_cmd); + nrf_cli_cmd_len_t shift; + char * p_cmd_source_addr; + + /* +1 for space */ + if (((size_t)p_cli->p_ctx->cmd_tmp_buff_len + cmd_len + 1) > NRF_CLI_CMD_BUFF_SIZE) + { + nrf_cli_warn(p_cli, + "Command buffer is too short to expand all commands matching " + "wildcard pattern"); + return false; + } + + p_cmd_source_addr = strstr(p_cli->p_ctx->temp_buff, p_pattern); + + if (p_cmd_source_addr == NULL) + { + return false; + } + + shift = cli_strlen(p_cmd_source_addr); + + /* make place for new command: + 1 for space + 1 for EOS */ + memmove(p_cmd_source_addr + cmd_len + 1, p_cmd_source_addr, shift + 1); + memcpy(p_cmd_source_addr, p_new_cmd, cmd_len); + p_cmd_source_addr[cmd_len] = ' '; + + p_cli->p_ctx->cmd_tmp_buff_len += cmd_len + 1; // + 1 for space + + return true; +} + +/* removes pattern and following space */ +static void pattern_from_tmp_buffer_remove(nrf_cli_t const * p_cli, + char const * p_pattern) +{ + size_t shift; + char * p_pattern_addr = strstr(p_cli->p_ctx->temp_buff, p_pattern); + + nrf_cli_cmd_len_t pattern_len = cli_strlen(p_pattern); + + if (p_pattern_addr == NULL) + { + return; + } + + if (p_pattern_addr > p_cli->p_ctx->temp_buff) + { + if (*(p_pattern_addr - 1) == ' ') + { + pattern_len++; /* space needs to be removed as well */ + p_pattern_addr--; /* set pointer to space */ + } + } + + shift = cli_strlen(p_pattern_addr) - pattern_len + 1; /* +1 for EOS */ + p_cli->p_ctx->cmd_tmp_buff_len -= pattern_len; + + memmove(p_pattern_addr, p_pattern_addr + pattern_len, shift); +} + +/** + * @internal @brief Function for searching and adding commands matching to wildcard pattern. + * + * This function is internal to nrf_cli module and shall be not called directly. + * + * @param[in/out] p_cli Pointer to the CLI instance. + * @param[in] p_cmd Pointer to command which will be processed + * @param[in] cmd_lvl Command level in the command tree. + * @param[in] p_pattern Pointer to wildcard pattern. + * @param[out] p_counter Number of found and added commands. + * + * @retval WILDCARD_CMD_ADDED All matching commands added to the buffer. + * @retval WILDCARD_CMD_ADDED_MISSING_SPACE Not all matching commands added because + * NRF_CLI_CMD_BUFF_SIZE is too small. + * @retval WILDCARD_CMD_NO_MATCH_FOUND No matching command found. + */ +static wildcard_cmd_status_t commands_expand(nrf_cli_t const * p_cli, + nrf_cli_cmd_entry_t const * p_cmd, + size_t cmd_lvl, + char * p_pattern, + size_t * p_counter) +{ + size_t cmd_idx = 0; + size_t counter = 0; + bool success = false; + + nrf_cli_static_entry_t static_entry; + nrf_cli_static_entry_t const * p_static_entry = NULL; + wildcard_cmd_status_t ret_val = WILDCARD_CMD_NO_MATCH_FOUND; + + do + { + cmd_get(p_cmd, + cmd_lvl, + cmd_idx++, + &p_static_entry, + &static_entry); + + if (p_static_entry == NULL) + { + break; + } + + if (0 == fnmatch(p_pattern, p_static_entry->p_syntax, 0)) + { + success = command_to_tmp_buffer_add(p_cli, + p_static_entry->p_syntax, + p_pattern); + if (!success) + { + break; + } + counter++; + } + + } while(cmd_idx != 0); + + if (counter > 0) + { + *p_counter = counter; + pattern_from_tmp_buffer_remove(p_cli, p_pattern); + + if (success) + { + ret_val = WILDCARD_CMD_ADDED; + } + else + { + ret_val = WILDCARD_CMD_ADDED_MISSING_SPACE; + } + } + + return ret_val; +} +#endif // NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) + +/* Function is analyzing the command buffer to find matching commands. Next, it invokes the last recognized + * command which has a handler and passes the rest of command buffer as arguments. */ static void cli_execute(nrf_cli_t const * p_cli) { char quote; @@ -1863,16 +2383,51 @@ static void cli_execute(nrf_cli_t const * p_cli) size_t cmd_idx; /* currently analyzed command in cmd_level */ size_t cmd_lvl = NRF_CLI_CMD_ROOT_LVL; /* currently analyzed command level */ - size_t cmd_handler_lvl = 0; /* last command level for witch handler has been found */ - size_t cmd_handler_idx = 0; /* last command index for witch handler has been found */ + size_t cmd_handler_lvl = 0; /* last command level for which a handler has been found */ nrf_cli_cmd_entry_t const * p_cmd = NULL; cmd_trim(p_cli); + #if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) history_save(p_cli); #endif +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) +/* Wildcard can be correctly handled under following conditions: + - wildcard command does not have a handler + - wildcard command is on the deepest commands level + - other commands on the same level as wildcard command shall also not have a handler + + Algorithm: + 1. Command buffer is copied to Temp buffer. + 2. Algorithm goes through Command buffer to find handlers and subcommands. + 3. If algorithm will find a wildcard character it switches to Temp buffer. + 4. In the Temp buffer command with found wildcard character is changed into matching command(s). + 5. Algorithm switch back to Command buffer and analyzes next command. + 6. When all arguments are analyzed from Command buffer, Temp buffer is copied to Command buffer. + 7. Last found handler is executed with all arguments in the Command buffer. +*/ + size_t commands_expanded = 0; + + memset(p_cli->p_ctx->temp_buff, 0, sizeof(p_cli->p_ctx->temp_buff)); + memcpy(p_cli->p_ctx->temp_buff, + p_cli->p_ctx->cmd_buff, + p_cli->p_ctx->cmd_buff_len); + + /* Function spaces_trim must be used instead of make_argv. At this point it is important to keep + temp_buff as a one string. It will allow to find wildcard commands easly with strstr + function. */ + spaces_trim(p_cli->p_ctx->temp_buff); + p_cli->p_ctx->cmd_tmp_buff_len = cli_strlen(p_cli->p_ctx->temp_buff) + 1; // +1 for EOS +#endif + + cursor_end_position_move(p_cli); + if (!cursor_in_empty_line(p_cli)) + { + cursor_next_line_move(p_cli); + } + /* create argument list */ quote = make_argv(&argc, &argv[0], @@ -1887,31 +2442,16 @@ static void cli_execute(nrf_cli_t const * p_cli) if (quote != 0) { - nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "\r\nnot terminated: %c\r\n", quote); + nrf_cli_error(p_cli, "not terminated: %c", quote); return; } - /* Searching for matching root command. */ + /* Searching for a matching root command. */ for (cmd_idx = 0; cmd_idx <= CLI_DATA_SECTION_ITEM_COUNT; ++cmd_idx) { if (cmd_idx >= CLI_DATA_SECTION_ITEM_COUNT) { - if (cursor_in_empty_line(p_cli)) - { - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "%s%s\r\n", - argv[0], - m_nrf_cli_command_not_found); - } - else - { - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "\r\n%s%s\r\n", - argv[0], - m_nrf_cli_command_not_found); - } + nrf_cli_error(p_cli, "%s%s", argv[0], NRF_CLI_MSG_COMMAND_NOT_FOUND); return; } @@ -1926,17 +2466,14 @@ static void cli_execute(nrf_cli_t const * p_cli) /* Root command shall be always static. */ ASSERT(p_cmd->is_dynamic == false); - /* Pointer to deepest command level with a handler. */ - nrf_cli_cmd_entry_t const * p_cmd_low_level_entry = NULL; - /* Memory reserved for dynamic commands. */ nrf_cli_static_entry_t static_entry; nrf_cli_static_entry_t const * p_static_entry = NULL; - nrf_cli_cmd_handler handler_cmd_lvl_0 = p_cmd->u.p_static->handler; - if (handler_cmd_lvl_0 != NULL) + memset(&p_cli->p_ctx->active_cmd, 0, sizeof(p_cli->p_ctx->active_cmd)); + if (p_cmd->u.p_static->handler != NULL) { - p_cli->p_ctx->p_current_stcmd = p_cmd->u.p_static; + p_cli->p_ctx->active_cmd = *p_cmd->u.p_static; } p_cmd = p_cmd->u.p_static->p_subcmd; @@ -1953,10 +2490,33 @@ static void cli_execute(nrf_cli_t const * p_cli) if (!strcmp(argv[cmd_lvl], "-h") || !strcmp(argv[cmd_lvl], "--help")) { /* Command called with help option so it makes no sense to search deeper commands. */ - NRF_CLI_HELP_FLAG_SET(p_cli); + cli_flag_help_set(p_cli); break; } +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) + /* Wildcard character is found */ + if (wildcard_character_exist(argv[cmd_lvl])) + { + size_t counter = 0; + wildcard_cmd_status_t status; + + /* Function will search commands tree for commands matching wildcard pattern stored in + argv[cmd_lvl]. If match is found wildcard pattern will be replaced by matching + commands in temp_buffer. If there is no space to add all matching commands function + will add as many as possible. Next it will continue to search for next wildcard + pattern and it will try to add matching commands. */ + status = commands_expand(p_cli, p_cmd, cmd_lvl, argv[cmd_lvl], &counter); + if (WILDCARD_CMD_NO_MATCH_FOUND == status) + { + break; + } + commands_expanded += counter; + cmd_lvl++; + continue; + } +#endif + cmd_get(p_cmd, cmd_lvl, cmd_idx++, @@ -1970,50 +2530,63 @@ static void cli_execute(nrf_cli_t const * p_cli) if (strcmp(argv[cmd_lvl], p_static_entry->p_syntax) == 0) { + /* checking if command has a handler */ if (p_static_entry->handler != NULL) { +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) + if (commands_expanded > 0) + { + cursor_end_position_move(p_cli); + if (!cursor_in_empty_line(p_cli)) + { + cursor_next_line_move(p_cli); + } + /* An error occured, fnmatch argument cannot be followed by argument + * with a handler to avoid multiple function calls. */ + nrf_cli_error(p_cli, "Error: requested multiple function executions"); + cli_flag_help_clear(p_cli); + return; + } +#endif /* Storing p_st_cmd->handler is not feasible for dynamic commands. Data will be - * invalid with next loop iteration. */ + * invalid with the next loop iteration. */ cmd_handler_lvl = cmd_lvl; - cmd_handler_idx = cmd_idx - 1; - p_cmd_low_level_entry = p_cmd; + p_cli->p_ctx->active_cmd = *p_static_entry; } + cmd_lvl++; cmd_idx = 0; p_cmd = p_static_entry->p_subcmd; } } - - cursor_end_position_move(p_cli); - if (!cursor_in_empty_line(p_cli)) +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) + if (commands_expanded > 0) { - cursor_next_line_move(p_cli); - } + /* Copy temp_buff to cmd_buff */ + memcpy(p_cli->p_ctx->cmd_buff, + p_cli->p_ctx->temp_buff, + p_cli->p_ctx->cmd_tmp_buff_len); + p_cli->p_ctx->cmd_buff_len = p_cli->p_ctx->cmd_tmp_buff_len; - /* Executing deepest found handler. */ - if (p_cmd_low_level_entry != NULL) - { - cmd_get(p_cmd_low_level_entry, - cmd_handler_lvl, - cmd_handler_idx, - &p_static_entry, - &static_entry); - - p_cli->p_ctx->p_current_stcmd = p_static_entry; - - p_cli->p_ctx->p_current_stcmd->handler(p_cli, - argc - cmd_handler_lvl, - &argv[cmd_handler_lvl]); + /* calling make_arg function again because cmd_buffer has additional commads */ + (void)make_argv(&argc, + &argv[0], + p_cli->p_ctx->cmd_buff, + NRF_CLI_ARGC_MAX); } - else if (handler_cmd_lvl_0 != NULL) + #endif + + if (p_cli->p_ctx->active_cmd.handler != NULL) { - handler_cmd_lvl_0(p_cli, argc, &argv[0]); + p_cli->p_ctx->active_cmd.handler(p_cli, + argc - cmd_handler_lvl, + &argv[cmd_handler_lvl]); } else { - nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Please specify subcommand.\r\n"); + nrf_cli_error(p_cli, NRF_CLI_MSG_SPECIFY_SUBCOMMAND); } - NRF_CLI_HELP_FLAG_CLEAR(p_cli); + cli_flag_help_clear(p_cli); } /* Function required by qsort. */ @@ -2044,7 +2617,7 @@ static void cli_transport_evt_handler(nrf_cli_transport_evt_t evt_type, void * p else { /* wr done evt */ - p_cli->p_ctx->tx_rdy = true; + p_cli->p_ctx->internal.flag.tx_rdy = 1; } #endif } @@ -2055,10 +2628,9 @@ static ret_code_t nrf_cli_instance_init(nrf_cli_t const * p_cli, { ASSERT(p_cli); ASSERT(p_cli->p_ctx && p_cli->p_iface && p_cli->p_name); - ASSERT((p_cli->newline_char == '\n') || (p_cli->newline_char == '\r')); #if defined(NRF_CLI_LOG_BACKEND) && NRF_CLI_LOG_BACKEND - p_cli->p_log_backend->p_cli = p_cli; + ((nrf_cli_log_backend_t *)p_cli->p_log_backend->p_ctx)->p_cli = p_cli; #endif ret_code_t ret = p_cli->p_iface->p_api->init(p_cli->p_iface, p_config, @@ -2081,12 +2653,12 @@ static ret_code_t nrf_cli_instance_init(nrf_cli_t const * p_cli, #endif memset(p_cli->p_ctx, 0, sizeof(nrf_cli_ctx_t)); - p_cli->p_ctx->tx_rdy = true; + p_cli->p_ctx->internal.flag.tx_rdy = 1; #if NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS) - p_cli->p_ctx->use_colors = use_colors; + p_cli->p_ctx->internal.flag.use_colors = use_colors; #endif - p_cli->p_ctx->echo = NRF_CLI_ECHO_STATUS; + p_cli->p_ctx->internal.flag.echo = NRF_CLI_ECHO_STATUS; p_cli->p_ctx->state = NRF_CLI_STATE_INITIALIZED; p_cli->p_ctx->vt100_ctx.cons.terminal_wid = NRF_CLI_DEFAULT_TERMINAL_WIDTH; p_cli->p_ctx->vt100_ctx.cons.terminal_hei = NRF_CLI_DEFAULT_TERMINAL_HEIGHT; @@ -2154,13 +2726,13 @@ ret_code_t nrf_cli_init(nrf_cli_t const * p_cli, #if NRF_CLI_LOG_BACKEND && NRF_MODULE_ENABLED(NRF_LOG) if ((err_code == NRF_SUCCESS) && log_backend && NRF_CLI_LOG_BACKEND) { - int32_t id = nrf_log_backend_add(&p_cli->p_log_backend->backend, init_lvl); + int32_t id = nrf_log_backend_add(p_cli->p_log_backend, init_lvl); if (id < 0) { return NRF_ERROR_NO_MEM; } - nrf_log_backend_enable(&p_cli->p_log_backend->backend); + nrf_log_backend_enable(p_cli->p_log_backend); } #endif return err_code; @@ -2188,11 +2760,16 @@ static ret_code_t nrf_cli_instance_uninit(nrf_cli_t const * p_cli) ASSERT(p_cli); ASSERT(p_cli->p_ctx && p_cli->p_iface && p_cli->p_name); + if (cli_flag_processing_is_set(p_cli)) + { + return NRF_ERROR_BUSY; + } + #if NRF_CLI_LOG_BACKEND && NRF_MODULE_ENABLED(NRF_LOG) if (p_cli->p_log_backend != NULL) { - nrf_log_backend_disable(&p_cli->p_log_backend->backend); - nrf_log_backend_remove(&p_cli->p_log_backend->backend); + nrf_log_backend_disable(p_cli->p_log_backend); + nrf_log_backend_remove(p_cli->p_log_backend); } #endif @@ -2215,6 +2792,10 @@ static ret_code_t nrf_cli_instance_uninit(nrf_cli_t const * p_cli) ret_code_t nrf_cli_uninit(nrf_cli_t const * p_cli) { #if NRF_MODULE_ENABLED(NRF_CLI_USES_TASK_MANAGER) + if (cli_flag_processing_is_set(p_cli)) + { + return NRF_ERROR_BUSY; + } task_events_set(p_cli->p_ctx->task_id, NRF_CLI_KILL_TASK_EVT); return NRF_SUCCESS; #else @@ -2234,7 +2815,7 @@ ret_code_t nrf_cli_start(nrf_cli_t const * p_cli) #if NRF_MODULE_ENABLED(NRF_CLI_USES_TASK_MANAGER) void * p_context = (void *)((uint32_t)task_id_get()); - p_cli->p_log_backend->p_context = p_context; + ((nrf_cli_log_backend_t *)p_cli->p_log_backend->p_ctx)->p_context = p_context; #endif ret_code_t err_code = p_cli->p_iface->p_api->enable(p_cli->p_iface, false); @@ -2249,7 +2830,7 @@ ret_code_t nrf_cli_start(nrf_cli_t const * p_cli) vt100_color_set(p_cli, NRF_CLI_NORMAL); vt100_bgcolor_set(p_cli, NRF_CLI_VT100_COLOR_BLACK); #endif - nrf_fprintf(p_cli->p_fprintf_ctx, "\r\n\n"); + nrf_fprintf(p_cli->p_fprintf_ctx, "\n\n"); cli_state_set(p_cli, NRF_CLI_STATE_ACTIVE); } @@ -2276,6 +2857,12 @@ void nrf_cli_process(nrf_cli_t const * p_cli) ASSERT(p_cli); ASSERT(p_cli->p_ctx && p_cli->p_iface && p_cli->p_name); + nrf_cli_internal_t internal; + internal.value = 0; + internal.flag.processing = 1; + (void)nrf_atomic_u32_or((nrf_atomic_u32_t *)&p_cli->p_ctx->internal.value, + internal.value); + switch (p_cli->p_ctx->state) { case NRF_CLI_STATE_UNINITIALIZED: @@ -2288,19 +2875,26 @@ void nrf_cli_process(nrf_cli_t const * p_cli) bool log_processed = cli_log_entry_process(p_cli, false); if (log_processed) { - nrf_cli_fprintf(p_cli, NRF_CLI_INFO, "%s", p_cli->p_name); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%s", p_cli->p_ctx->cmd_buff); - cursor_position_synchronize(p_cli); + nrf_cli_fprintf(p_cli, NRF_CLI_INFO, "%s", p_cli->p_name); + if (cli_flag_echo_is_set(p_cli)) + { + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%s", p_cli->p_ctx->cmd_buff); + cursor_position_synchronize(p_cli); + } } break; } default: break; } - NRF_CLI_IO_BUFFER_FLUSH(p_cli); + transport_buffer_flush(p_cli); + internal.value = (uint32_t)0xFFFFFFFF; + internal.flag.processing = 0; + (void)nrf_atomic_u32_and((nrf_atomic_u32_t *)&p_cli->p_ctx->internal.value, + internal.value); } -/* Function shall be only used by nrf_fprintf module. */ +/* Function shall be only used by the nrf_fprintf module. */ void nrf_cli_print_stream(void const * p_user_ctx, char const * p_data, size_t data_len) { cli_write((nrf_cli_t const *)p_user_ctx, @@ -2322,7 +2916,8 @@ void nrf_cli_fprintf(nrf_cli_t const * p_cli, va_start(args, p_fmt); #if NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS) - if ((p_cli->p_ctx->use_colors) && (color != p_cli->p_ctx->vt100_ctx.col.col)) + if ((p_cli->p_ctx->internal.flag.use_colors) && + (color != p_cli->p_ctx->vt100_ctx.col.col)) { nrf_cli_vt100_colors_t col; @@ -2342,12 +2937,12 @@ void nrf_cli_fprintf(nrf_cli_t const * p_cli, va_end(args); } -/* Function prints string on terminal screen with requested margin. +/* Function prints a string on terminal screen with requested margin. * It takes care to not divide words. - * p_cli: Pointer to CLI instance. - * p_str: Pointer to string to be printed. - * terminal_offset: Requested left margin. - * offset_first_line: Add margin to first printed line. + * p_cli Pointer to CLI instance. + * p_str Pointer to string to be printed. + * terminal_offset Requested left margin. + * offset_first_line Add margin to the first printed line. */ static void format_offset_string_print(nrf_cli_t const * p_cli, char const * p_str, @@ -2384,7 +2979,7 @@ static void format_offset_string_print(nrf_cli_t const * p_cli, { if (*(p_str + offset + idx) == '\n') { - NRF_CLI_IO_BUFFER_FLUSH(p_cli); + transport_buffer_flush(p_cli); cli_write(p_cli, p_str + offset, idx, NULL); offset += idx + 1; cursor_next_line_move(p_cli); @@ -2398,7 +2993,7 @@ static void format_offset_string_print(nrf_cli_t const * p_cli, } else { - /* String is longer than terminal line so text needs to divide in the way + /* String is longer than terminal line so text needs to divide in the way to not divide words. */ length = p_cli->p_ctx->vt100_ctx.cons.terminal_wid - terminal_offset; @@ -2422,7 +3017,7 @@ static void format_offset_string_print(nrf_cli_t const * p_cli, } /* Writing one line, fprintf IO buffer must be flushed before calling cli_write. */ - NRF_CLI_IO_BUFFER_FLUSH(p_cli); + transport_buffer_flush(p_cli); cli_write(p_cli, p_str + offset, length, NULL); offset += length; @@ -2456,13 +3051,13 @@ void nrf_cli_help_print(nrf_cli_t const * p_cli, nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%s%s", - p_cli->p_ctx->p_current_stcmd->p_syntax, + p_cli->p_ctx->active_cmd.p_syntax, cmd_sep); - field_width = cli_strlen(p_cli->p_ctx->p_current_stcmd->p_syntax) + cli_strlen(cmd_sep); - format_offset_string_print(p_cli, p_cli->p_ctx->p_current_stcmd->p_help, field_width, false); + field_width = cli_strlen(p_cli->p_ctx->active_cmd.p_syntax) + cli_strlen(cmd_sep); + format_offset_string_print(p_cli, p_cli->p_ctx->active_cmd.p_help, field_width, false); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Options:\r\n"); + nrf_cli_print(p_cli, "Options:"); /* Looking for the longest option string. */ if ((opt_len > 0) && (p_opt != NULL)) @@ -2548,14 +3143,14 @@ void nrf_cli_help_print(nrf_cli_t const * p_cli, } /* Checking if there are any subcommands avilable. */ - if (p_cli->p_ctx->p_current_stcmd->p_subcmd == NULL) + if (p_cli->p_ctx->active_cmd.p_subcmd == NULL) { return; } /* Printing formatted help of one level deeper subcommands. */ nrf_cli_static_entry_t static_entry; - nrf_cli_cmd_entry_t const * p_cmd = p_cli->p_ctx->p_current_stcmd->p_subcmd; + nrf_cli_cmd_entry_t const * p_cmd = p_cli->p_ctx->active_cmd.p_subcmd; nrf_cli_static_entry_t const * p_st_cmd = NULL; field_width = 0; @@ -2581,11 +3176,11 @@ void nrf_cli_help_print(nrf_cli_t const * p_cli, /* Checking if there are dynamic subcommands. */ if (cmd_idx == 1) { - /* No dynamic subcommands available */ + /* No dynamic subcommands available. */ return; } - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Subcommands:\r\n"); + nrf_cli_print(p_cli, "Subcommands:"); /* Printing subcommands and help string (if exists). */ cmd_idx = 0; @@ -2624,7 +3219,8 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) bool print_msg = false; #endif - if (nrf_queue_pop(p_cli->p_log_backend->p_queue, &entry) != NRF_SUCCESS) + if (nrf_queue_pop(((nrf_cli_log_backend_t *)p_cli->p_log_backend->p_ctx)->p_queue, &entry) != + NRF_SUCCESS) { return false; } @@ -2636,7 +3232,7 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) ++p_cli->p_ctx->statistics.log_lost_cnt; if ((p_cli->p_ctx->statistics.log_lost_cnt & NRF_CLI_LOG_MSG_OVERFLOW_MSK) == 1) { - /* Set flag to print message after clearing currently entered command. */ + /* Set flag to print a message after clearing the currently entered command. */ print_msg = true; } else @@ -2646,7 +3242,7 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) } } { - /* Erasing currently displayed command and console name. */ + /* Erasing the currently displayed command and console name. */ nrf_cli_multiline_cons_t const * p_cons = multiline_console_data_check(p_cli); if (p_cons->cur_y > NRF_CLI_INITIAL_CURS_POS) @@ -2664,18 +3260,18 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) #if NRF_MODULE_ENABLED(NRF_CLI_STATISTICS) if (print_msg) { - /* Print requested string and exit function. */ - nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Lost LOGs - increase LOG backend queue size.\r\n"); + /* Print the requested string and exit function. */ + nrf_cli_error(p_cli, "Lost logs - increase log backend queue size."); return true; } #endif - /* Printing logs from queue. */ + /* Printing logs from the queue. */ do { nrf_log_header_t header; - uint32_t memobj_offset = 0; + size_t memobj_offset = 0; nrf_log_str_formatter_entry_params_t params; nrf_memobj_read(entry, &header, HEADER_SIZE*sizeof(uint32_t), memobj_offset); @@ -2683,13 +3279,13 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) params.timestamp = header.timestamp; params.module_id = header.module_id; - params.use_colors = NRF_LOG_USES_COLORS; /* color will be provided by console application */ + params.dropped = header.dropped; + params.use_colors = NRF_LOG_USES_COLORS; /* Color will be provided by the console application. */ if (header.base.generic.type == HEADER_TYPE_STD) { char const * p_log_str = (char const *)((uint32_t)header.base.std.addr); params.severity = (nrf_log_severity_t)header.base.std.severity; - params.raw = header.base.std.raw; uint32_t nargs = header.base.std.nargs; uint32_t args[6]; @@ -2708,7 +3304,6 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) data_len = header.base.hexdump.len; params.severity = (nrf_log_severity_t)header.base.hexdump.severity; - params.raw = header.base.hexdump.raw; do { @@ -2721,20 +3316,21 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) } nrf_memobj_put(entry); - } while (nrf_queue_pop(p_cli->p_log_backend->p_queue, &entry) == NRF_SUCCESS); + } while (nrf_queue_pop(((nrf_cli_log_backend_t *)p_cli->p_log_backend->p_ctx)->p_queue, &entry) + == NRF_SUCCESS); return true; } static void nrf_log_backend_cli_put(nrf_log_backend_t const * p_backend, nrf_log_entry_t * p_msg) { - nrf_cli_log_backend_t * p_backend_cli = CONTAINER_OF(p_backend, nrf_cli_log_backend_t, backend); + nrf_cli_log_backend_t * p_backend_cli = (nrf_cli_log_backend_t *)p_backend->p_ctx; nrf_cli_t const * p_cli = p_backend_cli->p_cli; - //If panic mode cannot be handled stop handling new requests. + //If panic mode cannot be handled, stop handling new requests. if (p_cli->p_ctx->state != NRF_CLI_STATE_PANIC_MODE_INACTIVE) { bool panic_mode = (p_cli->p_ctx->state == NRF_CLI_STATE_PANIC_MODE_ACTIVE); - //If there is no place for new log entry remove the oldest one + //If there is no place for a new log entry, remove the oldest one. ret_code_t err_code = nrf_queue_push(p_backend_cli->p_queue, &p_msg); while (err_code != NRF_SUCCESS) { @@ -2760,12 +3356,17 @@ static void nrf_log_backend_cli_put(nrf_log_backend_t const * p_backend, nrf_log static void nrf_log_backend_cli_flush(nrf_log_backend_t const * p_backend) { + nrf_cli_log_backend_t * p_backend_cli = (nrf_cli_log_backend_t *)p_backend->p_ctx; + nrf_cli_t const * p_cli = p_backend_cli->p_cli; + + (void)cli_log_entry_process(p_cli, true); + UNUSED_PARAMETER(p_backend); } static void nrf_log_backend_cli_panic_set(nrf_log_backend_t const * p_backend) { - nrf_cli_log_backend_t * p_backend_cli = CONTAINER_OF(p_backend, nrf_cli_log_backend_t, backend); + nrf_cli_log_backend_t * p_backend_cli = (nrf_cli_log_backend_t *)p_backend->p_ctx; nrf_cli_t const * p_cli = p_backend_cli->p_cli; if (p_cli->p_iface->p_api->enable(p_cli->p_iface, true) == NRF_SUCCESS) @@ -2792,7 +3393,7 @@ static bool cli_log_entry_process(nrf_cli_t const * p_cli, bool skip) } #endif // NRF_CLI_LOG_BACKEND -/* ============ build-in commands ============ */ +/* ============ built-in commands ============ */ #if NRF_MODULE_ENABLED(NRF_CLI_BUILD_IN_CMDS) static bool nrf_cli_build_in_cmd_common_executed(nrf_cli_t const * p_cli, @@ -2808,10 +3409,7 @@ static bool nrf_cli_build_in_cmd_common_executed(nrf_cli_t const * if (arg_cnt_nok) { - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "%s: bad parameter count\r\n", - p_cli->p_ctx->p_current_stcmd->p_syntax); + nrf_cli_error(p_cli, "%s: wrong parameter count", p_cli->p_ctx->active_cmd.p_syntax); return true; } @@ -2833,6 +3431,20 @@ static void nrf_cli_cmd_clear(nrf_cli_t const * p_cli, size_t argc, char **argv) NRF_CLI_VT100_CMD(p_cli, NRF_CLI_VT100_CLEARSCREEN); } +static void nrf_cli_cmd_cli(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + ASSERT(p_cli); + ASSERT(p_cli->p_ctx && p_cli->p_iface && p_cli->p_name); + UNUSED_PARAMETER(argv); + + if ((argc == 1) || ((argc == 2) && nrf_cli_help_requested(p_cli)) ) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + nrf_cli_error(p_cli, NRF_CLI_MSG_SPECIFY_SUBCOMMAND); +} + #if NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS) static void nrf_cli_cmd_colors_off(nrf_cli_t const * p_cli, size_t argc, char **argv) { @@ -2840,7 +3452,7 @@ static void nrf_cli_cmd_colors_off(nrf_cli_t const * p_cli, size_t argc, char ** { return; } - p_cli->p_ctx->use_colors = false; + p_cli->p_ctx->internal.flag.use_colors = 0; } static void nrf_cli_cmd_colors_on(nrf_cli_t const * p_cli, size_t argc, char **argv) @@ -2849,7 +3461,7 @@ static void nrf_cli_cmd_colors_on(nrf_cli_t const * p_cli, size_t argc, char **a { return; } - p_cli->p_ctx->use_colors = true; + p_cli->p_ctx->internal.flag.use_colors = 1; } static void nrf_cli_cmd_colors(nrf_cli_t const * p_cli, size_t argc, char **argv) @@ -2862,18 +3474,13 @@ static void nrf_cli_cmd_colors(nrf_cli_t const * p_cli, size_t argc, char **argv nrf_cli_help_print(p_cli, NULL, 0); return; } - + if (nrf_cli_build_in_cmd_common_executed(p_cli, (argc != 2), NULL, 0)) { return; } - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "%s:%s%s\r\n", - argv[0], - m_nrf_cli_uknown_parameter, - argv[1]); + nrf_cli_error(p_cli, "%s:%s%s", argv[0], NRF_CLI_MSG_UNKNOWN_PARAMETER, argv[1]); } #endif // NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS) @@ -2886,19 +3493,10 @@ static void nrf_cli_cmd_echo(nrf_cli_t const * p_cli, size_t argc, char **argv) if (argc == 2) { - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "%s:%s%s\r\n", - argv[0], - m_nrf_cli_uknown_parameter, - argv[1]); + nrf_cli_error(p_cli, "%s:%s%s", argv[0], NRF_CLI_MSG_UNKNOWN_PARAMETER, argv[1]); return; } - - nrf_cli_fprintf(p_cli, - NRF_CLI_NORMAL, - "Echo status: %s\r\n", - NRF_CLI_ECHO_ON_MODE(p_cli) ? "on" : "off"); + nrf_cli_print(p_cli, "Echo status: %s", cli_flag_echo_is_set(p_cli) ? "on" : "off"); } static void nrf_cli_cmd_echo_off(nrf_cli_t const * p_cli, size_t argc, char **argv) @@ -2908,7 +3506,7 @@ static void nrf_cli_cmd_echo_off(nrf_cli_t const * p_cli, size_t argc, char **ar return; } - p_cli->p_ctx->echo = false; + cli_flag_echo_clear(p_cli); } static void nrf_cli_cmd_echo_on(nrf_cli_t const * p_cli, size_t argc, char **argv) @@ -2918,7 +3516,7 @@ static void nrf_cli_cmd_echo_on(nrf_cli_t const * p_cli, size_t argc, char **arg return; } - p_cli->p_ctx->echo = true; + cli_flag_echo_set(p_cli); } #if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) @@ -2945,13 +3543,13 @@ static void nrf_cli_cmd_history(nrf_cli_t const * p_cli, size_t argc, char **arg nrf_memobj_read((nrf_memobj_t * )p_cmd_list, &header, NRF_CLI_HISTORY_HEADER_SIZE, - (uint32_t)0); + 0); nrf_memobj_read((nrf_memobj_t * )p_cmd_list, p_cli->p_ctx->temp_buff, header.cmd_len + 1, - (uint32_t)NRF_CLI_HISTORY_HEADER_SIZE); + NRF_CLI_HISTORY_HEADER_SIZE); p_cmd_list = header.p_next; - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "[%3d] %s\r\n", i++, p_cli->p_ctx->temp_buff); + nrf_cli_print(p_cli, "[%3d] %s", i++, p_cli->p_ctx->temp_buff); } p_cli->p_ctx->temp_buff[0] = '\0'; } @@ -2968,36 +3566,30 @@ void nrf_cli_cmd_cli_stats(nrf_cli_t const * p_cli, size_t argc, char **argv) if (argc == 2) { - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "%s:%s%s\r\n", - argv[0], - m_nrf_cli_uknown_parameter, - argv[1]); + nrf_cli_error(p_cli, "%s:%s%s", argv[0], NRF_CLI_MSG_UNKNOWN_PARAMETER, argv[1]); return; } UNUSED_RETURN_VALUE(nrf_cli_build_in_cmd_common_executed(p_cli, (argc > 2), NULL, 0)); } -void nrf_cli_cmd_cli_stats_get(nrf_cli_t const * p_cli, size_t argc, char **argv) +void nrf_cli_cmd_cli_stats_show(nrf_cli_t const * p_cli, size_t argc, char **argv) { if (nrf_cli_build_in_cmd_common_executed(p_cli, (argc != 1), NULL, 0)) { return; } - uint8_t max_util = nrf_queue_max_utilization_get(p_cli->p_log_backend->p_queue); - uint8_t utilization = (uint8_t)(max_util * 100ul / p_cli->p_log_backend->p_queue->size); + nrf_queue_t const * p_queue = ((nrf_cli_log_backend_t *)p_cli->p_log_backend->p_ctx)->p_queue; + uint8_t max_util = nrf_queue_max_utilization_get(p_queue); + uint8_t utilization = (uint8_t)(max_util * 100ul / p_queue->size); - nrf_cli_fprintf(p_cli, - NRF_CLI_NORMAL, - "Lost LOGs: %u\r\n" - "Max LOG queue utilization: %u%% [%u/%u]\r\n", - p_cli->p_ctx->statistics.log_lost_cnt, - utilization, - max_util, - p_cli->p_log_backend->p_queue->size); + nrf_cli_print(p_cli, + "Lost logs: %u\nMax log queue utilization: %u%% [%u/%u]", + p_cli->p_ctx->statistics.log_lost_cnt, + utilization, + max_util, + p_queue->size); } void nrf_cli_cmd_cli_stats_reset(nrf_cli_t const * p_cli, size_t argc, char **argv) @@ -3008,7 +3600,8 @@ void nrf_cli_cmd_cli_stats_reset(nrf_cli_t const * p_cli, size_t argc, char **ar } p_cli->p_ctx->statistics.log_lost_cnt = 0; - nrf_queue_max_utilization_reset(p_cli->p_log_backend->p_queue); + nrf_queue_max_utilization_reset( + ((nrf_cli_log_backend_t *)p_cli->p_log_backend->p_ctx)->p_queue); } #endif // NRF_MODULE_ENABLED(NRF_CLI_STATISTICS) @@ -3037,9 +3630,7 @@ static void nrf_cli_cmd_resize(nrf_cli_t const * p_cli, size_t argc, char **argv { p_cli->p_ctx->vt100_ctx.cons.terminal_wid = NRF_CLI_DEFAULT_TERMINAL_WIDTH; p_cli->p_ctx->vt100_ctx.cons.terminal_hei = NRF_CLI_DEFAULT_TERMINAL_HEIGHT; - nrf_cli_fprintf(p_cli, - NRF_CLI_WARNING, - "no response from terminal, assumed 80x24 chars screen size\r\n"); + nrf_cli_warn(p_cli, "No response from the terminal, assumed 80x24 screen size"); } return; } @@ -3048,67 +3639,60 @@ static void nrf_cli_cmd_resize(nrf_cli_t const * p_cli, size_t argc, char **argv { return; } - - nrf_cli_fprintf(p_cli, - NRF_CLI_ERROR, - "%s:%s%s\r\n", - argv[0], - m_nrf_cli_uknown_parameter, - argv[1]); + nrf_cli_error(p_cli, "%s:%s%s", argv[0], NRF_CLI_MSG_UNKNOWN_PARAMETER, argv[1]); } -NRF_CLI_CMD_REGISTER(clear, NULL, "Clear screen.", nrf_cli_cmd_clear); - #if NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS) NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_colors) { - NRF_CLI_CMD(off, NULL, "Disable colored syntax.", nrf_cli_cmd_colors_off), - NRF_CLI_CMD(on, NULL, "Enable colored syntax.", nrf_cli_cmd_colors_on), + NRF_CLI_CMD(off, NULL, NRF_CLI_HELP_COLORS_OFF, nrf_cli_cmd_colors_off), + NRF_CLI_CMD(on, NULL, NRF_CLI_HELP_COLORS_ON, nrf_cli_cmd_colors_on), NRF_CLI_SUBCMD_SET_END }; -NRF_CLI_CMD_REGISTER(colors, &m_sub_colors, "Toggle colored syntax.", nrf_cli_cmd_colors); #endif NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_echo) { - NRF_CLI_CMD(off, NULL, "Disable CLI echo. Escape codes are not handled.", nrf_cli_cmd_echo_off), - NRF_CLI_CMD(on, NULL, "Enable CLI echo. Escape codes are handled.", nrf_cli_cmd_echo_on), + NRF_CLI_CMD(off, NULL, NRF_CLI_HELP_ECHO_OFF, nrf_cli_cmd_echo_off), + NRF_CLI_CMD(on, NULL, NRF_CLI_HELP_ECHO_ON, nrf_cli_cmd_echo_on), NRF_CLI_SUBCMD_SET_END }; -NRF_CLI_CMD_REGISTER(echo, &m_sub_echo, "Toggle CLI echo.", nrf_cli_cmd_echo); - -#if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) -NRF_CLI_CMD_REGISTER(history, NULL, "Command history.", nrf_cli_cmd_history); -#endif -NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_resize) +#if NRF_MODULE_ENABLED(NRF_CLI_STATISTICS) +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_cli_stats) { - NRF_CLI_CMD(default, - NULL, - "Assume 80 chars screen width and send this settings to the terminal.", - nrf_cli_cmd_resize_default), + NRF_CLI_CMD(reset, NULL, NRF_CLI_HELP_STATISTICS_RESET, nrf_cli_cmd_cli_stats_reset), + NRF_CLI_CMD(show, NULL, NRF_CLI_HELP_STATISTICS_SHOW, nrf_cli_cmd_cli_stats_show), NRF_CLI_SUBCMD_SET_END }; -NRF_CLI_CMD_REGISTER(resize, - &m_sub_resize, - "Console gets terminal screen size or assumes 80 in case readout fails. " - "It must be executed after each terminal width change to ensure correct " - "text display.", - nrf_cli_cmd_resize); +#endif // NRF_MODULE_ENABLED(NRF_CLI_STATISTICS) +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_cli) +{ +#if NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS) + NRF_CLI_CMD(colors, &m_sub_colors, NRF_CLI_HELP_COLORS, nrf_cli_cmd_colors), +#endif + NRF_CLI_CMD(echo, &m_sub_echo, NRF_CLI_HELP_ECHO, nrf_cli_cmd_echo), #if NRF_MODULE_ENABLED(NRF_CLI_STATISTICS) -NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_cli_stats) + NRF_CLI_CMD(stats, &m_sub_cli_stats, NRF_CLI_HELP_STATISTICS, nrf_cli_cmd_cli_stats), +#endif + NRF_CLI_SUBCMD_SET_END +}; + +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_resize) { - NRF_CLI_CMD(get, NULL, "Get CLI statistics for LOG module.", nrf_cli_cmd_cli_stats_get), - NRF_CLI_CMD(reset, NULL, "Reset CLI statistics for LOG module.", nrf_cli_cmd_cli_stats_reset), + NRF_CLI_CMD(default, NULL, NRF_CLI_HELP_RESIZE_DEFAULT, nrf_cli_cmd_resize_default), NRF_CLI_SUBCMD_SET_END }; -NRF_CLI_CMD_REGISTER(cli_stats, - &m_sub_cli_stats, - "CLI statistics.", - nrf_cli_cmd_cli_stats); -#endif // NRF_MODULE_ENABLED(NRF_CLI_STATISTICS) + +NRF_CLI_CMD_REGISTER(clear, NULL, NRF_CLI_HELP_CLEAR, nrf_cli_cmd_clear); +NRF_CLI_CMD_REGISTER(cli, &m_sub_cli, NRF_CLI_HELP_CLI, nrf_cli_cmd_cli); +#if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) +NRF_CLI_CMD_REGISTER(history, NULL, NRF_CLI_HELP_HISTORY, nrf_cli_cmd_history); +#endif +NRF_CLI_CMD_REGISTER(resize, &m_sub_resize, NRF_CLI_HELP_RESIZE, nrf_cli_cmd_resize); #endif // NRF_MODULE_ENABLED(NRF_CLI_BUILD_IN_CMDS) #endif // NRF_MODULE_ENABLED(NRF_CLI) + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli.h similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli.h index 7862b5d..38fd3a2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_H__ #define NRF_CLI_H__ @@ -47,6 +47,7 @@ #include "nrf_queue.h" #include "nrf_log_ctrl.h" #include "app_util_platform.h" +#include "nrf_memobj.h" #if NRF_MODULE_ENABLED(NRF_CLI_USES_TASK_MANAGER) #include "task_manager.h" @@ -99,12 +100,12 @@ typedef struct nrf_cli_static_entry nrf_cli_static_entry_t; * alphabetical order. If idx exceeds the available dynamic subcommands, the function must write * to p_static->p_syntax NULL value. This will indicate to the CLI module that * there are no more dynamic commands to read. - **/ + */ typedef void (*nrf_cli_dynamic_get)(size_t idx, nrf_cli_static_entry_t * p_static); /** * @brief CLI command descriptor. - **/ + */ struct nrf_cli_cmd_entry { bool is_dynamic; @@ -117,12 +118,12 @@ struct nrf_cli_cmd_entry /** * @brief CLI command handler prototype. - **/ + */ typedef void (*nrf_cli_cmd_handler)(nrf_cli_t const * p_cli, size_t argc, char **argv); /** * @brief CLI static command descriptor. - **/ + */ struct nrf_cli_static_entry { char const * p_syntax; //!< Command syntax strings. @@ -142,14 +143,14 @@ struct nrf_cli_static_entry * @param[in] p_subcmd Pointer to a subcommands array. * @param[in] p_help Pointer to a command help string. * @param[in] p_handler Pointer to a function handler. - * */ + */ #define NRF_CLI_CMD_REGISTER(p_syntax, p_subcmd, p_help, p_handler) \ nrf_cli_static_entry_t const CONCAT_3(nrf_cli_, p_syntax, _raw) = \ NRF_CLI_CMD(p_syntax, p_subcmd, p_help, p_handler); \ NRF_SECTION_ITEM_REGISTER(cli_command, \ nrf_cli_cmd_entry_t const CONCAT_3(nrf_cli_, p_syntax, _const)) = { \ .is_dynamic = false, \ - .u.p_static = &CONCAT_3(nrf_cli_, p_syntax, _raw) \ + .u = {.p_static = &CONCAT_3(nrf_cli_, p_syntax, _raw)} \ }; \ NRF_SECTION_ITEM_REGISTER(cli_sorted_cmd_ptrs, char const * CONCAT_2(p_syntax, _str_ptr)) @@ -157,20 +158,20 @@ struct nrf_cli_static_entry * @brief Macro for creating a subcommand set. It must be used outside of any function body. * * @param[in] name Name of the subcommand set. - * */ + */ #define NRF_CLI_CREATE_STATIC_SUBCMD_SET(name) \ /*lint -save -e85 -e31*/ \ static nrf_cli_static_entry_t const CONCAT_2(name, _raw)[]; \ static nrf_cli_cmd_entry_t const name = { \ .is_dynamic = false, \ - .u.p_static = CONCAT_2(name, _raw) \ + .u = {.p_static = CONCAT_2(name, _raw) } \ }; \ static nrf_cli_static_entry_t const CONCAT_2(name, _raw)[] = /*lint -restore*/ /** * @brief Define ending subcommands set. * - * */ + */ #define NRF_CLI_SUBCMD_SET_END {NULL} /** @@ -183,9 +184,28 @@ struct nrf_cli_static_entry /*lint -save -e19*/ \ static nrf_cli_cmd_entry_t const name = { \ .is_dynamic = true, \ - .u.p_dynamic_get = p_get \ + .u = { .p_dynamic_get = p_get } \ }; /*lint -restore*/ +/** @brief Macro for creating subcommands when C++ compiler is used. + * + * Example usage: + * @code + * NRF_CLI_CPP_CREATE_STATIC_SUBCMD_SET(cmd_syntax, + * NRF_CLI_CMD(abc, ...), + * NRF_CLI_CMD(def, ...), + * NRF_CLI_SUBCMD_SET_END + * ); + * @endcode + */ +#define NRF_CLI_CPP_CREATE_STATIC_SUBCMD_SET(name, ...) \ + static nrf_cli_static_entry_t const CONCAT_2(name, _raw)[] = { \ + __VA_ARGS__ \ + }; \ + static nrf_cli_cmd_entry_t const name = { \ + .is_dynamic = false, \ + .u = { .p_static = CONCAT_2(name, _raw) } \ + } /** * @brief Initializes a CLI command (@ref nrf_cli_static_entry). @@ -194,28 +214,29 @@ struct nrf_cli_static_entry * @param[in] _p_subcmd Pointer to a subcommands array. * @param[in] _p_help Pointer to a command help string. * @param[in] _p_handler Pointer to a function handler. - **/ + */ #define NRF_CLI_CMD(_p_syntax, _p_subcmd, _p_help, _p_handler) { \ .p_syntax = (const char *) STRINGIFY(_p_syntax), \ - .p_subcmd = _p_subcmd, \ .p_help = (const char *) _p_help, \ + .p_subcmd = _p_subcmd, \ .handler = _p_handler \ } /** - * @brief Internal CLI state in response to data received from the terminal. - * */ + * @internal @brief Internal CLI state in response to data received from the terminal. + */ typedef enum { NRF_CLI_RECEIVE_DEFAULT, NRF_CLI_RECEIVE_ESC, - NRF_CLI_RECEIVE_ESC_SEQ + NRF_CLI_RECEIVE_ESC_SEQ, + NRF_CLI_RECEIVE_TILDE_EXP } nrf_cli_receive_t; /** - * @brief Internal CLI state. - * */ + * @internal @brief Internal CLI state. + */ typedef enum { NRF_CLI_STATE_UNINITIALIZED, //!< State uninitialized. @@ -227,7 +248,7 @@ typedef enum /** * @brief Event type from CLI transport. - * */ + */ typedef enum { NRF_CLI_TRANSPORT_EVT_RX_RDY, @@ -240,7 +261,7 @@ typedef struct nrf_cli_transport_s nrf_cli_transport_t; /** * @brief Unified CLI transport interface. - * */ + */ typedef struct { /** @@ -252,7 +273,7 @@ typedef struct * @param[in] p_context Pointer to the context passed to event handler. * * @return Standard error code. - * */ + */ ret_code_t (*init)(nrf_cli_transport_t const * p_transport, void const * p_config, nrf_cli_transport_handler_t evt_handler, @@ -264,7 +285,7 @@ typedef struct * @param[in] p_transport Pointer to the transfer instance. * * @return Standard error code. - * */ + */ ret_code_t (*uninit)(nrf_cli_transport_t const * p_transport); /** @@ -287,7 +308,7 @@ typedef struct * @param[in] p_cnt Pointer to the sent bytes counter. * * @return Standard error code. - * */ + */ ret_code_t (*write)(nrf_cli_transport_t const * p_transport, const void * p_data, size_t length, @@ -302,7 +323,7 @@ typedef struct * @param[in] p_cnt Pointer to the received bytes counter. * * @return Standard error code. - * */ + */ ret_code_t (*read)(nrf_cli_transport_t const * p_transport, void * p_data, size_t length, @@ -318,7 +339,7 @@ struct nrf_cli_transport_s #if NRF_MODULE_ENABLED(NRF_CLI_HISTORY) /** * @brief CLI history object header. - * */ + */ typedef PACKED_STRUCT { nrf_memobj_t * p_prev; //!< Pointer to the next object. @@ -334,21 +355,49 @@ typedef struct } nrf_cli_statistics_t; #endif +/** + * @internal @brief Flags for internal CLI usage. + */ +typedef struct +{ + uint32_t insert_mode : 1; //!< Enables or disables console insert mode for text introduction. + uint32_t show_help : 1; //!< Shows help if the command was called with -h or --help parameter. + uint32_t use_colors : 1; //!< Enables or disables colored syntax. + uint32_t echo : 1; //!< Enables or disables CLI echo. + uint32_t processing : 1; //!< CLI is executing process function. + uint32_t tx_rdy : 1; + uint32_t last_nl : 8; //!< The last received newline character. +} nrf_cli_flag_t; +STATIC_ASSERT(sizeof(nrf_cli_flag_t) == sizeof(uint32_t)); + +/** + * @internal @brief Union for internal CLI usage. + */ +typedef union +{ + uint32_t value; + nrf_cli_flag_t flag; +} nrf_cli_internal_t; + /** * @brief CLI instance context. - * */ + */ typedef struct { nrf_cli_state_t state; //!< Internal module state. nrf_cli_receive_t receive_state; //!< Escape sequence indicator. - nrf_cli_static_entry_t const * p_current_stcmd; //!< Currently executed command. + nrf_cli_static_entry_t active_cmd; //!< Currently executed command nrf_cli_vt100_ctx_t vt100_ctx; //!< VT100 color and cursor position, terminal width. nrf_cli_cmd_len_t cmd_buff_len; //!< Command length. nrf_cli_cmd_len_t cmd_buff_pos; //!< Command buffer cursor position. +#if NRF_MODULE_ENABLED(NRF_CLI_WILDCARD) + nrf_cli_cmd_len_t cmd_tmp_buff_len; //!< Command length in tmp buffer +#endif + char cmd_buff[NRF_CLI_CMD_BUFF_SIZE]; //!< Command input buffer. char temp_buff[NRF_CLI_CMD_BUFF_SIZE]; //!< Temporary buffer used by various functions. char printf_buff[NRF_CLI_PRINTF_BUFF_SIZE]; //!< Printf buffer size. @@ -366,34 +415,26 @@ typedef struct nrf_memobj_t * p_cmd_list_tail; //!< Pointer to the tail of history list. nrf_memobj_t * p_cmd_list_element; //!< Pointer to an element of history list. #endif - - volatile bool tx_rdy; - - uint8_t insert_mode : 1; //!< Enables / disables console insert mode for text introduction. - uint8_t show_help : 1; //!< Shows help if command was called with -h or --help parameter. - uint8_t use_colors : 1; //!< Enables / disables colored syntax. - uint8_t echo : 1; //!< Enables / disables CLI echo. - uint8_t unused : 4; + volatile nrf_cli_internal_t internal; //!< Internal CLI data } nrf_cli_ctx_t; extern const nrf_log_backend_api_t nrf_log_backend_cli_api; typedef struct { - nrf_log_backend_t backend; nrf_queue_t const * p_queue; void * p_context; nrf_cli_t const * p_cli; } nrf_cli_log_backend_t; #if NRF_CLI_LOG_BACKEND && NRF_MODULE_ENABLED(NRF_LOG) -#define NRF_LOG_BACKEND_CLI_DEF(_name_, _queue_size_) \ - NRF_QUEUE_DEF(nrf_log_entry_t, \ - CONCAT_2(_name_, _queue),_queue_size_, NRF_QUEUE_MODE_NO_OVERFLOW); \ - static nrf_cli_log_backend_t _name_ = { \ - .backend = {.p_api = &nrf_log_backend_cli_api}, \ - .p_queue = &CONCAT_2(_name_, _queue), \ - } +#define NRF_LOG_BACKEND_CLI_DEF(_name_, _queue_size_) \ + NRF_QUEUE_DEF(nrf_log_entry_t, \ + CONCAT_2(_name_, _queue),_queue_size_, NRF_QUEUE_MODE_NO_OVERFLOW); \ + static nrf_cli_log_backend_t CONCAT_2(cli_log_backend,_name_) = { \ + .p_queue = &CONCAT_2(_name_, _queue), \ + }; \ + NRF_LOG_BACKEND_DEF(_name_, nrf_log_backend_cli_api, &CONCAT_2(cli_log_backend,_name_)) #define NRF_CLI_BACKEND_PTR(_name_) &CONCAT_2(_name_, _log_backend) #else @@ -421,17 +462,16 @@ typedef struct * @brief CLI instance internals. * * @ref nrf_cli_t - * */ + */ struct nrf_cli { char const * const p_name; //!< Terminal name. nrf_cli_transport_t const * p_iface; //!< Transport interface. nrf_cli_ctx_t * p_ctx; //!< Internal context. - nrf_cli_log_backend_t * p_log_backend; //!< Logger backend. + nrf_log_backend_t const * p_log_backend; //!< Logger backend. nrf_fprintf_ctx_t * p_fprintf_ctx; //!< fprintf context. nrf_memobj_pool_t const * p_cmd_hist_mempool; //!< Memory reserved for commands history. - char const newline_char; //!< New line character, only allowed values: \\n and \\r. }; /** @@ -440,9 +480,9 @@ struct nrf_cli * @param[in] name Instance name. * @param[in] cli_prefix CLI prefix string. * @param[in] p_transport_iface Pointer to the transport interface. - * @param[in] newline_ch New line character - only allowed values are '\\n' or '\\r'. + * @param[in] newline_ch Deprecated parameter, not used any more. Any uint8_t value can be used. * @param[in] log_queue_size Logger processing queue size. - * */ + */ #define NRF_CLI_DEF(name, cli_prefix, p_transport_iface, newline_ch, log_queue_size) \ static nrf_cli_t const name; \ static nrf_cli_ctx_t CONCAT_2(name, _ctx); \ @@ -462,7 +502,6 @@ struct nrf_cli .p_log_backend = NRF_CLI_BACKEND_PTR(name), \ .p_fprintf_ctx = &CONCAT_2(name, _fprintf_ctx), \ .p_cmd_hist_mempool = NRF_CLI_MEMOBJ_PTR(name), \ - .newline_char = newline_ch \ } /*lint -restore*/ /** @@ -475,7 +514,7 @@ struct nrf_cli * @param[in] init_lvl Default severity level for the logger. * * @return Standard error code. - * */ + */ ret_code_t nrf_cli_init(nrf_cli_t const * p_cli, void const * p_transport_config, bool use_colors, @@ -486,11 +525,13 @@ ret_code_t nrf_cli_task_create(nrf_cli_t const * p_cli); /** * @brief Function for uninitializing a transport layer and internal CLI state. + * If function returns NRF_ERROR_BUSY, you must call @ref nrf_cli_process before calling + * nrf_cli_uninit again. * * @param p_cli Pointer to CLI instance. * * @return Standard error code. - * */ + */ ret_code_t nrf_cli_uninit(nrf_cli_t const * p_cli); /** @@ -499,7 +540,7 @@ ret_code_t nrf_cli_uninit(nrf_cli_t const * p_cli); * @param p_cli Pointer to the CLI instance. * * @return Standard error code. - * */ + */ ret_code_t nrf_cli_start(nrf_cli_t const * p_cli); /** @@ -508,9 +549,12 @@ ret_code_t nrf_cli_start(nrf_cli_t const * p_cli); * @param p_cli Pointer to CLI instance. * * @return Standard error code. - * */ + */ ret_code_t nrf_cli_stop(nrf_cli_t const * p_cli); +/** + * @brief CLI colors for @ref nrf_cli_fprintf function. + */ #define NRF_CLI_DEFAULT NRF_CLI_VT100_COLOR_DEFAULT /**< Turn off character attributes. */ #define NRF_CLI_NORMAL NRF_CLI_VT100_COLOR_WHITE /**< Normal color printf. */ #define NRF_CLI_INFO NRF_CLI_VT100_COLOR_GREEN /**< Info color printf. */ @@ -526,23 +570,71 @@ ret_code_t nrf_cli_stop(nrf_cli_t const * p_cli); * @param[in] color Printf color. * @param[in] p_fmt Format string. * @param[in] ... List of parameters to print. - * */ + */ void nrf_cli_fprintf(nrf_cli_t const * p_cli, nrf_cli_vt100_color_t color, char const * p_fmt, ...); +/** + * @brief Print an info message to the CLI. + * + * See @ref nrf_cli_fprintf. + * + * @param[in] _p_cli Pointer to the CLI instance. + * @param[in] _ft Format string. + * @param[in] ... List of parameters to print. + */ +#define nrf_cli_info(_p_cli, _ft, ...) \ + nrf_cli_fprintf(_p_cli, NRF_CLI_INFO, _ft "\n", ##__VA_ARGS__) + +/** + * @brief Print a normal message to the CLI. + * + * See @ref nrf_cli_fprintf. + * + * @param[in] _p_cli Pointer to the CLI instance. + * @param[in] _ft Format string. + * @param[in] ... List of parameters to print. + */ +#define nrf_cli_print(_p_cli, _ft, ...) \ + nrf_cli_fprintf(_p_cli, NRF_CLI_DEFAULT, _ft "\n", ##__VA_ARGS__) + +/** + * @brief Print a warning message to the CLI. + * + * See @ref nrf_cli_fprintf. + * + * @param[in] _p_cli Pointer to the CLI instance. + * @param[in] _ft Format string. + * @param[in] ... List of parameters to print. + */ +#define nrf_cli_warn(_p_cli, _ft, ...) \ + nrf_cli_fprintf(_p_cli, NRF_CLI_WARNING, _ft "\n", ##__VA_ARGS__) + +/** + * @brief Print an error message to the CLI. + * + * See @ref nrf_cli_fprintf. + * + * @param[in] _p_cli Pointer to the CLI instance. + * @param[in] _ft Format string. + * @param[in] ... List of parameters to print. + */ +#define nrf_cli_error(_p_cli, _ft, ...) \ + nrf_cli_fprintf(_p_cli, NRF_CLI_ERROR, _ft "\n", ##__VA_ARGS__) + /** * @brief Process function, which should be executed when data is ready in the transport interface. * * @param[in] p_cli Pointer to the CLI instance. - * */ + */ void nrf_cli_process(nrf_cli_t const * p_cli); /** * @brief Option descriptor. - * */ + */ typedef struct nrf_cli_getopt_option { char const * p_optname; //!< Option long name. @@ -557,7 +649,7 @@ typedef struct nrf_cli_getopt_option * @param[in] _p_optname Option name long. * @param[in] _p_shortname Option name short. * @param[in] _p_help Option help string. - * */ + */ #define NRF_CLI_OPT(_p_optname, _p_shortname, _p_help) { \ .p_optname = _p_optname, \ .p_optname_short = _p_shortname, \ @@ -570,36 +662,37 @@ typedef struct nrf_cli_getopt_option * @param[in] p_cli Pointer to the CLI instance. * * @return True if help has been requested. - * */ + */ __STATIC_INLINE bool nrf_cli_help_requested(nrf_cli_t const * p_cli); #ifndef SUPPRESS_INLINE_IMPLEMENTATION __STATIC_INLINE bool nrf_cli_help_requested(nrf_cli_t const * p_cli) { - return p_cli->p_ctx->show_help; + return p_cli->p_ctx->internal.flag.show_help; } #endif /** - * @brief Prints actual command help if user called it with -h or --help option. + * @brief Prints the current command help. * @details Function will print a help string with: the currently entered command, its options, * and subcommands (if they exist). * * @param[in] p_cli Pointer to the CLI instance. * @param[in] p_opt Pointer to the optional option array. * @param[in] opt_len Option array size. - * */ + */ void nrf_cli_help_print(nrf_cli_t const * p_cli, nrf_cli_getopt_option_t const * p_opt, size_t opt_len); /** - * @brief This function shall not be used directly, it is required by the nrf_fprintf module. + * @internal @brief This function shall not be used directly, it is required by the + * nrf_fprintf module. * * @param[in] p_user_ctx Pointer to the context for the CLI instance. * @param[in] p_data Pointer to the data buffer. * @param[in] data_len Data buffer size. - * */ + */ void nrf_cli_print_stream(void const * p_user_ctx, char const * p_data, size_t data_len); /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli_types.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli_types.h index d16850c..b4a2f94 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_TYPES_H__ #define NRF_CLI_TYPES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli_vt100.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli_vt100.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli_vt100.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli_vt100.h index f00135e..a60cb25 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/nrf_cli_vt100.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/nrf_cli_vt100.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_VT100_H__ #define NRF_CLI_VT100_H__ @@ -47,6 +47,13 @@ extern "C" { #define NRF_CLI_VT100_ASCII_ESC (0x1b) #define NRF_CLI_VT100_ASCII_DEL (0x7F) #define NRF_CLI_VT100_ASCII_BSPACE (0x08) +#define NRF_CLI_VT100_ASCII_CTRL_A (0x1) +#define NRF_CLI_VT100_ASCII_CTRL_C (0x03) +#define NRF_CLI_VT100_ASCII_CTRL_E (0x5) +#define NRF_CLI_VT100_ASCII_CTRL_L (0x0C) +#define NRF_CLI_VT100_ASCII_CTRL_U (0x15) +#define NRF_CLI_VT100_ASCII_CTRL_W (0x17) + #define NRF_CLI_VT100_SETNL \ { \ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/rtt/nrf_cli_rtt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/rtt/nrf_cli_rtt.c similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/rtt/nrf_cli_rtt.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/rtt/nrf_cli_rtt.c index cc59a7c..0beda0c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/rtt/nrf_cli_rtt.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/rtt/nrf_cli_rtt.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -44,6 +44,11 @@ #include #include "nrf_cli_rtt.h" #include "nrf_assert.h" +#include "nrf_delay.h" + +#define RTT_RX_TIMEOUT 100 + +static bool m_host_present; static void timer_handler(void * p_context) { @@ -54,7 +59,9 @@ static void timer_handler(void * p_context) } p_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_TX_RDY, p_internal->p_cb->p_context); - ret_code_t err_code = app_timer_start(*p_internal->p_timer, APP_TIMER_TICKS(10), p_context); + ret_code_t err_code = app_timer_start(*p_internal->p_timer, + APP_TIMER_TICKS(RTT_RX_TIMEOUT), + p_context); ASSERT(err_code == NRF_SUCCESS); UNUSED_VARIABLE(err_code); } @@ -74,6 +81,8 @@ static ret_code_t cli_rtt_init(nrf_cli_transport_t const * p_transport, SEGGER_RTT_Init(); + m_host_present = true; + return NRF_SUCCESS; } @@ -115,7 +124,9 @@ static ret_code_t cli_rtt_enable(nrf_cli_transport_t const * p_transport, } if (err_code == NRF_SUCCESS) { - err_code = app_timer_start(*p_internal->p_timer, APP_TIMER_TICKS(10), p_internal); + err_code = app_timer_start(*p_internal->p_timer, + APP_TIMER_TICKS(RTT_RX_TIMEOUT), + p_internal); SEGGER_RTT_Init(); } } @@ -145,25 +156,58 @@ static ret_code_t cli_rtt_write(nrf_cli_transport_t const * p_transport, if (!(CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)) { - /* If RTT session is not active but RTT console is processed program may stuck. - * Workaround: If debugger is not connected always return NRF_SUCCESS + /* If an RTT session is not active, but the RTT console is processed, the program may hang. + * Workaround: If the debugger is not connected, always return NRF_SUCCESS. */ *p_cnt = length; return NRF_SUCCESS; } - size_t wcnt; - size_t acc = 0; + size_t idx = 0; + uint32_t processed; + uint32_t watchdog_counter = NRF_CLI_RTT_TX_RETRY_CNT; + const uint8_t * p_buffer = (const uint8_t *)p_data; do { - wcnt = SEGGER_RTT_Write(NRF_CLI_RTT_TERMINAL_ID, p_data, length); - - acc += wcnt; - length -= wcnt; + processed = SEGGER_RTT_Write(NRF_CLI_RTT_TERMINAL_ID, &p_buffer[idx], length); + if (processed == 0) + { + /* There are two possible reasons for not writing any data to RTT: + * - The host is not connected and not reading the data. + * - The buffer got full and will be read by the host. + * These two situations are distinguished using the following algorithm. + * At the begining, the module assumes that the host is active, + * so when no data is read, it busy waits and retries. + * If, after retrying, the host reads the data, the module assumes that the host is active. + * If it fails, the module assumes that the host is inactive and stores that information. On next + * call, only one attempt takes place. The host is marked as active if the attempt is successful. + */ + if (!m_host_present) + { + break; + } + else + { + nrf_delay_ms(NRF_CLI_RTT_TX_RETRY_DELAY_MS); + watchdog_counter--; + if (watchdog_counter == 0) + { + m_host_present = false; + break; + } + } + } + m_host_present = true; + idx += processed; + length -= processed; } while (length); - if (p_cnt) + if (idx > 0) + { + *p_cnt = idx; + } + else { - *p_cnt = acc; + *p_cnt = length; } return NRF_SUCCESS; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/rtt/nrf_cli_rtt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/rtt/nrf_cli_rtt.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/rtt/nrf_cli_rtt.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/rtt/nrf_cli_rtt.h index 12c412d..8a87eb4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/rtt/nrf_cli_rtt.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/rtt/nrf_cli_rtt.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_RTT_H__ #define NRF_CLI_RTT_H__ @@ -59,7 +59,7 @@ extern "C" { /** * @brief Command line interface transport. - * */ + */ extern const nrf_cli_transport_api_t nrf_cli_rtt_transport_api; /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/uart/nrf_cli_uart.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/uart/nrf_cli_uart.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/uart/nrf_cli_uart.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/uart/nrf_cli_uart.c index 4993c5b..236cab3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/uart/nrf_cli_uart.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/uart/nrf_cli_uart.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_CLI_UART) @@ -89,10 +89,10 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) { case NRF_DRV_UART_EVT_ERROR: NRF_LOG_WARNING("id:%d, evt: ERROR:%d", - p_internal->p_uart->drv_inst_idx, + p_internal->p_uart->inst_idx, p_event->data.error.error_mask); err_code = nrf_ringbuf_put(p_internal->p_rx_ringbuf, p_event->data.error.rxtx.bytes); - ASSERT(err_code == NRF_SUCCESS); + ASSERT((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_NO_MEM)); err_code = rx_try(p_internal); ASSERT(err_code == NRF_SUCCESS); @@ -100,12 +100,12 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) case NRF_DRV_UART_EVT_RX_DONE: err_code = nrf_ringbuf_put(p_internal->p_rx_ringbuf, p_event->data.rxtx.bytes); - ASSERT(err_code == NRF_SUCCESS); + ASSERT((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_NO_MEM)); if (p_event->data.rxtx.bytes) { NRF_LOG_INFO("id:%d, evt: RXRDY len:%d", - p_internal->p_uart->drv_inst_idx, + p_internal->p_uart->inst_idx, p_event->data.rxtx.bytes); NRF_LOG_HEXDUMP_DEBUG(p_event->data.rxtx.p_data, p_event->data.rxtx.bytes); p_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_RX_RDY, @@ -124,13 +124,13 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) ASSERT(err_code == NRF_SUCCESS); if (len) { - NRF_LOG_INFO("id:%d, evt uart_tx, len:%d", p_internal->p_uart->drv_inst_idx, len); + NRF_LOG_INFO("id:%d, evt uart_tx, len:%d", p_internal->p_uart->inst_idx, len); err_code = nrf_drv_uart_tx(p_internal->p_uart, p_data, len); ASSERT(err_code == NRF_SUCCESS); } p_internal->p_cb->handler(NRF_CLI_TRANSPORT_EVT_TX_RDY, p_internal->p_cb->p_context); NRF_LOG_INFO("id:%d, evt: TXRDY, len:%d", - p_internal->p_uart->drv_inst_idx, + p_internal->p_uart->inst_idx, p_event->data.rxtx.bytes); break; @@ -143,7 +143,7 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) static void timer_handler(void * p_context) { nrf_cli_uart_internal_t * p_internal = (nrf_cli_uart_internal_t *)p_context; - NRF_LOG_DEBUG("id:%d, evt: Timeout", p_internal->p_uart->drv_inst_idx); + NRF_LOG_DEBUG("id:%d, evt: Timeout", p_internal->p_uart->inst_idx); nrf_drv_uart_rx_abort(p_internal->p_uart); } @@ -254,7 +254,7 @@ static ret_code_t cli_uart_read(nrf_cli_transport_t const * p_transport, if (*p_cnt) { - NRF_LOG_INFO("id:%d, read:%d", p_instance->p_uart->drv_inst_idx, *p_cnt); + NRF_LOG_INFO("id:%d, read:%d", p_instance->p_uart->inst_idx, *p_cnt); } return err_code; @@ -274,7 +274,7 @@ static ret_code_t cli_uart_write(nrf_cli_transport_t const * p_transport, if (err_code == NRF_SUCCESS) { NRF_LOG_INFO("id:%d, write, req:%d, done:%d", - p_instance->p_uart->drv_inst_idx, + p_instance->p_uart->inst_idx, length, *p_cnt); @@ -284,7 +284,7 @@ static ret_code_t cli_uart_write(nrf_cli_transport_t const * p_transport, size_t len = 255; if (nrf_ringbuf_get(p_instance->p_tx_ringbuf, &p_buf, &len, true) == NRF_SUCCESS) { - NRF_LOG_INFO("id:%d, uart_tx, len:%d", p_instance->p_uart->drv_inst_idx, len); + NRF_LOG_INFO("id:%d, uart_tx, len:%d", p_instance->p_uart->inst_idx, len); err_code = nrf_drv_uart_tx(p_instance->p_uart, p_buf, len); if (p_instance->p_cb->blocking && (err_code == NRF_SUCCESS)) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/uart/nrf_cli_uart.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/uart/nrf_cli_uart.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/uart/nrf_cli_uart.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/uart/nrf_cli_uart.h index 072836e..b310ce6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/cli/uart/nrf_cli_uart.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/cli/uart/nrf_cli_uart.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CLI_UART_H__ #define NRF_CLI_UART_H__ @@ -60,7 +60,7 @@ extern "C" { /** * @brief Command line interface transport. - * */ + */ extern const nrf_cli_transport_api_t nrf_cli_uart_transport_api; typedef struct nrf_cli_uart_internal_s nrf_cli_uart_internal_t; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc16/crc16.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc16/crc16.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc16/crc16.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc16/crc16.c index 59fcc2e..c2f31ec 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc16/crc16.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc16/crc16.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(CRC16) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc16/crc16.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc16/crc16.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc16/crc16.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc16/crc16.h index f80e8a1..bc84e32 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc16/crc16.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc16/crc16.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc32/crc32.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc32/crc32.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc32/crc32.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc32/crc32.c index 5bc7a71..d3bd5b8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc32/crc32.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc32/crc32.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(CRC32) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc32/crc32.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc32/crc32.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc32/crc32.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc32/crc32.h index 6961cb0..f585d74 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crc32/crc32.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crc32/crc32.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.c new file mode 100644 index 0000000..bf25feb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.c @@ -0,0 +1,887 @@ +/** + * Copyright (c) 2018 - 2019, 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" +#include +#if NRF_MODULE_ENABLED(NRF_CRYPTO) + +#include +#include "ssi_aes_error.h" +#include "cc310_backend_aes.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CC310_AES) + +/**@internal @brief Type declarations of templates matching all possible context sizes + * for this backend. + */ +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + SaSiAesUserContext_t context; /**< AES context internal to mbed TLS. */ + nrf_crypto_backend_aes_ctx_t backend; /**< Backend-specific internal context. */ +} nrf_crypto_backend_cc310_aes_any_context_t; + +/**@internal @brief Type declarations of templates matching all possible context sizes + * for this backend. + */ +typedef union +{ + nrf_crypto_backend_cc310_aes_any_context_t any; /**< Common for all contexts. */ + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_ECB) + nrf_crypto_backend_aes_ecb_context_t ecb; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC) + nrf_crypto_backend_aes_cbc_context_t cbc; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CTR) + nrf_crypto_backend_aes_ctr_context_t ctr; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) + nrf_crypto_backend_aes_cbc_mac_context_t cbc_mac; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CMAC) + nrf_crypto_backend_aes_cmac_context_t cmac; +#endif +} nrf_crypto_backend_cc310_aes_context_t; + + +static ret_code_t result_get(SaSiError_t error) +{ + ret_code_t ret_val; + switch (error) + { + case SASI_SUCCESS: + ret_val = NRF_SUCCESS; + break; + + case SASI_AES_INVALID_USER_CONTEXT_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NULL; + break; + + case SASI_AES_ILLEGAL_KEY_SIZE_ERROR: + case SASI_AES_DATA_IN_SIZE_ILLEGAL: + case SASI_AES_DATA_IN_BUFFER_SIZE_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case SASI_AES_INVALID_IV_OR_TWEAK_PTR_ERROR: + case SASI_AES_INVALID_KEY_POINTER_ERROR: + case SASI_AES_DATA_IN_POINTER_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_NULL; + break; + + case SASI_AES_ILLEGAL_OPERATION_MODE_ERROR: + case SASI_AES_KEY_TYPE_NOT_SUPPORTED_ERROR: + case SASI_AES_INVALID_ENCRYPT_MODE_ERROR: + case SASI_AES_ILLEGAL_PADDING_TYPE_ERROR: + case SASI_AES_INCORRECT_PADDING_ERROR: + case SASI_AES_DECRYPTION_NOT_ALLOWED_ON_THIS_MODE: + case SASI_AES_ADDITIONAL_BLOCK_NOT_PERMITTED_ERROR: + case SASI_AES_IS_NOT_SUPPORTED: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + case SASI_AES_DATA_OUT_BUFFER_SIZE_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + break; + + case SASI_AES_DATA_OUT_POINTER_INVALID_ERROR: + case SASI_AES_DATA_OUT_SIZE_POINTER_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_NULL; + break; + + case SASI_AES_CTX_SIZES_ERROR: + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + return ret_val; +} + +static ret_code_t params_validate(nrf_crypto_backend_cc310_aes_context_t const * const p_ctx, + SaSiAesOperationMode_t * p_mode, + nrf_crypto_operation_t operation) +{ + ret_code_t ret_val = NRF_SUCCESS; + + switch (p_ctx->any.header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_ECB) + case NRF_CRYPTO_AES_MODE_ECB: + case NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7: + *p_mode = SASI_AES_MODE_ECB; + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC) + case NRF_CRYPTO_AES_MODE_CBC: + case NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7: + *p_mode = SASI_AES_MODE_CBC; + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CTR) + case NRF_CRYPTO_AES_MODE_CTR: + *p_mode = SASI_AES_MODE_CTR; + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) + case NRF_CRYPTO_AES_MODE_CBC_MAC: + case NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7: + *p_mode = SASI_AES_MODE_CBC_MAC; + VERIFY_TRUE((operation == NRF_CRYPTO_MAC_CALCULATE), NRF_ERROR_CRYPTO_INVALID_PARAM); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CMAC) + case NRF_CRYPTO_AES_MODE_CMAC: + *p_mode = SASI_AES_MODE_CMAC; + VERIFY_TRUE((operation == NRF_CRYPTO_MAC_CALCULATE), NRF_ERROR_CRYPTO_INVALID_PARAM); + break; +#endif + + default: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + } + + return ret_val; +} + +static ret_code_t backend_cc310_init(void * const p_context, nrf_crypto_operation_t operation) +{ + SaSiError_t result; + ret_code_t ret_val; + bool mutex_locked; + + SaSiAesOperationMode_t mode; + SaSiAesEncryptMode_t operation_cc310; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (!nrfx_is_in_ram(&p_ctx->any.context)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + if (p_ctx->any.header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_128) + { + ret_val = NRF_ERROR_CRYPTO_KEY_SIZE; + goto exit; + } + + ret_val = params_validate(p_ctx, &mode, operation); + + if (ret_val != NRF_SUCCESS) + { + goto exit; + } + + if (operation == NRF_CRYPTO_DECRYPT) + { + operation_cc310 = SASI_AES_DECRYPT; + } + else if ((operation == NRF_CRYPTO_ENCRYPT) || (operation == NRF_CRYPTO_MAC_CALCULATE)) + { + operation_cc310 = SASI_AES_ENCRYPT; + } + else + { + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + goto exit; + } + p_ctx->any.backend.operation = operation; + + result = SaSi_AesInit(&p_ctx->any.context, + operation_cc310, + mode, + SASI_AES_PADDING_NONE); /* CC310 does not support padding */ + ret_val = result_get(result); + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +static ret_code_t backend_cc310_uninit(void * const p_context) +{ + SaSiError_t result; + ret_code_t ret_val; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + bool mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + result = SaSi_AesFree(&p_ctx->any.context); + ret_val = result_get(result); + + cc310_backend_mutex_unlock(); + return ret_val; +} + +static ret_code_t backend_cc310_key_set(void * const p_context, uint8_t * p_key) +{ + SaSiError_t result; + ret_code_t ret_val; + bool mutex_locked; + + SaSiAesUserKeyData_t key_data; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (!nrfx_is_in_ram(p_key)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + key_data.pKey = p_key; + key_data.keySize = (p_ctx->any.header.p_info->key_size) >> 3; // change bits to bytes + + result = SaSi_AesSetKey(&p_ctx->any.context, + SASI_AES_USER_KEY, + &key_data, + sizeof(key_data)); + ret_val = result_get(result); + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CTR) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) +static ret_code_t backend_cc310_iv_set(void * const p_context, uint8_t * p_iv) +{ + SaSiError_t result; + ret_code_t ret_val; + bool mutex_locked; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (!nrfx_is_in_ram(p_iv)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + result = SaSi_AesSetIv(&p_ctx->any.context, p_iv); + ret_val = result_get(result); + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +static ret_code_t backend_cc310_iv_get(void * const p_context, uint8_t * p_iv) +{ + SaSiError_t result; + ret_code_t ret_val = NRF_ERROR_CRYPTO_INTERNAL; + bool mutex_locked; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (!nrfx_is_in_ram(p_iv)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + result = SaSi_AesGetIv(&p_ctx->any.context, p_iv); + + /* Below code allows to read IV after calling nrf_crypto_aes_finalize */ + if (result == SASI_AES_ILLEGAL_OPERATION_MODE_ERROR) + { + if (p_ctx->any.header.init_value == NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE) + { + memcpy(p_iv, p_ctx->any.backend.iv, NRF_CRYPTO_MBEDTLS_AES_IV_SIZE); + ret_val = NRF_SUCCESS; + } + } + else + { + ret_val = result_get(result); + } + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} +#endif + +static ret_code_t backend_cc310_update(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out) +{ + SaSiError_t result; + ret_code_t ret_val; + bool mutex_locked; + size_t size; + size_t offset = 0; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (!nrfx_is_in_ram(p_data_in) || !nrfx_is_in_ram(p_data_out)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + do + { + /* CC310 allows only 64kB blocks, operation must be devided */ + if (data_size > CC310_MAX_LENGTH_DMA_AES_OPERATIONS) + { + size = CC310_MAX_LENGTH_DMA_AES_OPERATIONS; + data_size -= CC310_MAX_LENGTH_DMA_AES_OPERATIONS; + } + else + { + size = data_size; + data_size = 0; + } + + cc310_backend_enable(); + + if (p_ctx->any.backend.operation == NRF_CRYPTO_MAC_CALCULATE) + { + result = SaSi_AesBlock(&p_ctx->any.context, + p_data_in + offset, + size, + p_data_out); + } + else + { + result = SaSi_AesBlock(&p_ctx->any.context, + p_data_in + offset, + size, + p_data_out + offset); + } + + cc310_backend_disable(); + + offset += size; + ret_val = result_get(result); + + } while ((data_size > 0) && (ret_val == NRF_SUCCESS)); + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +static ret_code_t backend_cc310_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + SaSiError_t result; + ret_code_t ret_val; + bool mutex_locked; + size_t size; + size_t offset = 0; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (*p_data_out_size < data_size) + { + ret_val = NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + goto exit; + } + + /* This function does not support padding */ + if (((data_size & 0xF) != 0) && + (p_ctx->any.header.p_info->mode != NRF_CRYPTO_AES_MODE_CTR)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + goto exit; + } + + if (!nrfx_is_in_ram(p_data_in) || !nrfx_is_in_ram(p_data_out)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + /* CC310 allows only 64kB blocks, operation must be devided */ + while (data_size > CC310_MAX_LENGTH_DMA_AES_OPERATIONS) + { + size = CC310_MAX_LENGTH_DMA_AES_OPERATIONS; + data_size -= CC310_MAX_LENGTH_DMA_AES_OPERATIONS; + + cc310_backend_enable(); + + result = SaSi_AesBlock(&p_ctx->any.context, + p_data_in + offset, + size, + p_data_out + offset); + + cc310_backend_disable(); + + offset += size; + ret_val = result_get(result); + + if (ret_val != NRF_SUCCESS) + { + goto exit; + } + } + + /* Calculate space in the output buffer */ + *p_data_out_size -= offset; + + cc310_backend_enable(); + + result = SaSi_AesFinish(&p_ctx->any.context, + data_size, + p_data_in + offset, + data_size, + p_data_out + offset, + p_data_out_size); + + cc310_backend_disable(); + + ret_val = result_get(result); + + if (ret_val == NRF_SUCCESS) + { + /* update information about size of encrypted data */ + *p_data_out_size += offset; + } + + /* Store IV value in case it will be needed after finalize operation */ + if ((p_ctx->any.header.p_info->mode == NRF_CRYPTO_AES_MODE_CBC) || + (p_ctx->any.header.p_info->mode == NRF_CRYPTO_AES_MODE_CTR)) + { + result = SaSi_AesGetIv(&p_ctx->any.context, &p_ctx->any.backend.iv[0]); + ret_val = result_get(result); + } + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CMAC) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) +static ret_code_t backend_cc310_mac_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + SaSiError_t result; + ret_code_t ret_val; + bool mutex_locked; + size_t size; + size_t offset = 0; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (*p_data_out_size < NRF_CRYPTO_AES_BLOCK_SIZE) + { + ret_val = NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + goto exit; + } + + if (!nrfx_is_in_ram(p_data_in) || !nrfx_is_in_ram(p_data_out)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + /* This function does not support padding for CBC-MAC */ + if (((data_size & 0xF) != 0) && + (NRF_CRYPTO_AES_MODE_CBC_MAC == p_ctx->any.header.p_info->mode)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + goto exit; + } + + /* CC310 allows only 64kB blocks, operation must be devided */ + while (data_size > CC310_MAX_LENGTH_DMA_AES_OPERATIONS) + { + size = CC310_MAX_LENGTH_DMA_AES_OPERATIONS; + data_size -= CC310_MAX_LENGTH_DMA_AES_OPERATIONS; + + cc310_backend_enable(); + + result = SaSi_AesBlock(&p_ctx->any.context, + p_data_in + offset, + size, + p_data_out); + + cc310_backend_disable(); + + offset += size; + ret_val = result_get(result); + + if (ret_val != NRF_SUCCESS) + { + goto exit; + } + } + + cc310_backend_enable(); + + result = SaSi_AesFinish(&p_ctx->any.context, + data_size, + p_data_in + offset, + data_size, + p_data_out, + p_data_out_size); + + cc310_backend_disable(); + + ret_val = result_get(result); + + if (ret_val == NRF_SUCCESS) + { + /* update information about size of encrypted data */ + *p_data_out_size = NRF_CRYPTO_AES_BLOCK_SIZE; + } + + /* Store IV value in case it will be needed after finalize operation */ + if (p_ctx->any.header.p_info->mode == NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7) + { + result = SaSi_AesGetIv(&p_ctx->any.context, &p_ctx->any.backend.iv[0]); + ret_val = result_get(result); + } + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) +static ret_code_t backend_cc310_cbc_mac_padding_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + ret_code_t ret_val; + uint8_t padding_buffer[NRF_CRYPTO_AES_BLOCK_SIZE] = {0}; + uint8_t msg_ending = (uint8_t)(data_size & (size_t)0x0F); + + if (*p_data_out_size < NRF_CRYPTO_AES_BLOCK_SIZE) + { + /* output buffer too small */ + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + data_size -= msg_ending; + + if (data_size > 0) + { + ret_val = backend_cc310_update(p_context, + p_data_in, + data_size, + p_data_out); + VERIFY_SUCCESS(ret_val); + } + + ret_val = padding_pkcs7_add(&padding_buffer[0], + p_data_in + data_size, + msg_ending); + VERIFY_SUCCESS(ret_val); + + ret_val = backend_cc310_mac_finalize(p_context, + &padding_buffer[0], + NRF_CRYPTO_AES_BLOCK_SIZE, + p_data_out, + p_data_out_size); + VERIFY_SUCCESS(ret_val); + + return ret_val; +} +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_ECB) +static ret_code_t backend_cc310_padding_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + SaSiError_t result; + ret_code_t ret_val; + uint8_t padding_buffer[NRF_CRYPTO_AES_BLOCK_SIZE] = {0}; + uint8_t msg_ending = (uint8_t)(data_size & (size_t)0x0F); + size_t buff_out_size; + + nrf_crypto_backend_cc310_aes_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_context_t *)p_context; + + if (p_ctx->any.backend.operation == NRF_CRYPTO_DECRYPT) + { + ret_val = backend_cc310_finalize(p_context, + p_data_in, + data_size, + p_data_out, + p_data_out_size); + VERIFY_SUCCESS(ret_val); + + + ret_val = padding_pkcs7_remove(p_data_out, + p_data_out_size); + return ret_val; + } + + /* -------------- ENCRYPTION --------------*/ + data_size -= msg_ending; + + if (*p_data_out_size < (data_size + NRF_CRYPTO_AES_BLOCK_SIZE)) + { + /* no space for padding */ + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + if (data_size > 0) + { + ret_val = backend_cc310_update(p_context, + p_data_in, + data_size, + p_data_out); + VERIFY_SUCCESS(ret_val); + } + + ret_val = padding_pkcs7_add(&padding_buffer[0], + p_data_in + data_size, + msg_ending); + VERIFY_SUCCESS(ret_val); + + buff_out_size = *p_data_out_size - data_size; + + ret_val = backend_cc310_finalize(p_context, + &padding_buffer[0], + NRF_CRYPTO_AES_BLOCK_SIZE, + p_data_out + data_size, + &buff_out_size); + VERIFY_SUCCESS(ret_val); + + *p_data_out_size = buff_out_size + data_size; + + /* Store IV value in case it will be needed after finalize operation */ + if (p_ctx->any.header.p_info->mode == NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7) + { + result = SaSi_AesGetIv(&p_ctx->any.context, &p_ctx->any.backend.iv[0]); + ret_val = result_get(result); + } + + return ret_val; +} +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = backend_cc310_iv_set, + .iv_get_fn = backend_cc310_iv_get, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_128_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = backend_cc310_iv_set, + .iv_get_fn = backend_cc310_iv_get, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_padding_finalize +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CTR) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ctr_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CTR, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_ctr_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = backend_cc310_iv_set, + .iv_get_fn = backend_cc310_iv_get, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_finalize +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_ECB) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_128_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_padding_finalize +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = backend_cc310_iv_set, + .iv_get_fn = backend_cc310_iv_get, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_mac_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_128_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = backend_cc310_iv_set, + .iv_get_fn = backend_cc310_iv_get, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_cbc_mac_padding_finalize +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CMAC) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cmac_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CMAC, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cmac_context_t), + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .key_set_fn = backend_cc310_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_cc310_update, + .finalize_fn = backend_cc310_mac_finalize +}; +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_AES_BACKEND_CC310) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.h new file mode 100644 index 0000000..120ca27 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes.h @@ -0,0 +1,187 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_AES_H__ +#define CC310_BACKEND_AES_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_aes nrf_crypto CC310 backend AES + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief AES functionality provided by the nrf_crypto CC310 backend. + */ + +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) || defined(__SDK_DOXYGEN__) + +#include "ssi_aes.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_aes_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* AES CBC */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CBC) +#error "Duplicate definition of AES CBC mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CBC_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_ENABLED +#define NRF_CRYPTO_CC310_AES_ENABLED 1 + +/* define for test purposes */ +#define NRF_CRYPTO_AES_CBC_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + SaSiAesUserContext_t context; /**< AES context internal to CC310. */ + nrf_crypto_backend_aes_ctx_t backend; +} nrf_crypto_backend_aes_cbc_context_t; +#endif + +/* AES CTR */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CTR) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CTR) +#error "Duplicate definition of AES CTR mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CTR_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_ENABLED +#define NRF_CRYPTO_CC310_AES_ENABLED 1 + +/* define for test purposes */ +#define NRF_CRYPTO_AES_CTR_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + SaSiAesUserContext_t context; /**< AES context internal to CC310. */ + nrf_crypto_backend_aes_ctx_t backend; +} nrf_crypto_backend_aes_ctr_context_t; +#endif + +/* AES ECB */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_ECB) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_ECB) +#error "Duplicate definition of AES ECB mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_ECB_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_ENABLED +#define NRF_CRYPTO_CC310_AES_ENABLED 1 + +/* define for test purposes */ +#define NRF_CRYPTO_AES_ECB_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + SaSiAesUserContext_t context; /**< AES context internal to CC310. */ + nrf_crypto_backend_no_iv_aes_ctx_t backend; +} nrf_crypto_backend_aes_ecb_context_t; +#endif + + +/* AES CBC_MAC */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CBC_MAC) +#error "Duplicate definition of AES CBC_MAC mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CBC_MAC_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_ENABLED +#define NRF_CRYPTO_CC310_AES_ENABLED 1 + +/* define for test purposes */ +#define NRF_CRYPTO_AES_CBC_MAC_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + SaSiAesUserContext_t context; /**< AES context internal to CC310. */ + nrf_crypto_backend_aes_ctx_t backend; +} nrf_crypto_backend_aes_cbc_mac_context_t; +#endif + +/* AES CMAC */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CMAC) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CMAC) +#error "Duplicate definition of AES CMAC mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CMAC_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_ENABLED +#define NRF_CRYPTO_CC310_AES_ENABLED 1 + +/* define for test purposes */ +#define NRF_CRYPTO_AES_CMAC_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + SaSiAesUserContext_t context; /**< AES context internal to CC310. */ + nrf_crypto_backend_no_iv_aes_ctx_t backend; +} nrf_crypto_backend_aes_cmac_context_t; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +/** @} */ + +#endif // CC310_BACKEND_AES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.c new file mode 100644 index 0000000..166c68c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.c @@ -0,0 +1,366 @@ +/** + * Copyright (c) 2018 - 2019, 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" +#include +#if NRF_MODULE_ENABLED(NRF_CRYPTO) + +#include +#include "crys_aesccm_error.h" +#include "cc310_backend_aes_aead.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CC310_AES_AEAD) + +/**@internal @brief Type declaration of a template suiting all possible context sizes + * for this backend. + */ +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + CRYS_AESCCM_UserContext_t context; + uint8_t key[16]; /**< Only supported key size by CC310 is 128 bit */ +} nrf_crypto_backend_cc310_aes_aead_context_t; + +static ret_code_t result_get(CRYSError_t error) +{ + ret_code_t ret_val; + + switch (error) + { + case CRYS_OK: + ret_val = NRF_SUCCESS; + break; + + case CRYS_AESCCM_INVALID_USER_CONTEXT_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NULL; + break; + + case CRYS_AESCCM_ILLEGAL_KEY_SIZE_ERROR: + ret_val = NRF_ERROR_CRYPTO_KEY_SIZE; + break; + + case CRYS_AESCCM_ILLEGAL_TAG_SIZE_ERROR: + ret_val = NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + break; + + case CRYS_AESCCM_ILLEGAL_NONCE_SIZE_ERROR: + ret_val = NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE; + break; + + case CRYS_AESCCM_ILLEGAL_PARAMETER_SIZE_ERROR: + case CRYS_AESCCM_DATA_IN_SIZE_ILLEGAL: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case CRYS_AESCCM_INVALID_KEY_POINTER_ERROR: + case CRYS_AESCCM_ILLEGAL_PARAMETER_PTR_ERROR: + case CRYS_AESCCM_DATA_IN_POINTER_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_NULL; + break; + + case CRYS_AESCCM_IS_NOT_SUPPORTED: + case CRYS_AESCCM_INVALID_ENCRYPT_MODE_ERROR: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + case CRYS_AESCCM_DATA_OUT_SIZE_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + break; + + case CRYS_AESCCM_DATA_OUT_POINTER_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_NULL; + break; + + case CRYS_AESCCM_ILLEGAL_PARAMETER_ERROR: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + case CRYS_AESCCM_CCM_MAC_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_AEAD_INVALID_MAC; + break; + + case CRYS_AESCCM_CTX_SIZES_ERROR: + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + return ret_val; +} + +static ret_code_t backend_cc310_init(void * const p_context, uint8_t * p_key) +{ + ret_code_t ret_val; + + nrf_crypto_backend_cc310_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_aead_context_t *)p_context; + + if (!nrfx_is_in_ram(p_ctx)) + { + return NRF_ERROR_CRYPTO_INPUT_LOCATION; + } + if (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_128) + { + return NRF_ERROR_CRYPTO_KEY_SIZE; + } + + switch (p_ctx->header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CCM) + case NRF_CRYPTO_AEAD_MODE_AES_CCM: + ret_val = NRF_SUCCESS; + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR) + case NRF_CRYPTO_AEAD_MODE_AES_CCM_STAR: + ret_val = NRF_SUCCESS; + break; +#endif + + default: + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + } + + memcpy(p_ctx->key, p_key, sizeof(p_ctx->key)); + + return ret_val; +} + +static ret_code_t backend_cc310_uninit(void * const p_context) +{ + nrf_crypto_backend_cc310_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_aead_context_t *)p_context; + + memset(&p_ctx->context, 0, sizeof(CRYS_AESCCM_UserContext_t)); + + return NRF_SUCCESS; +} + +static ret_code_t backend_cc310_crypt(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) + +{ + uint32_t mode; + CRYSError_t result; + ret_code_t ret_val; + bool mutex_locked; + + SaSiAesEncryptMode_t operation_cc310; + CRYS_AESCCM_Mac_Res_t mac_buffer; + + nrf_crypto_backend_cc310_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_cc310_aes_aead_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if (!nrfx_is_in_ram(p_adata) && (adata_size > 0)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + /* CC310 supports: CCM & CCM*, where nonce_size must be > 0, so p_nonce must always + point to RAM. */ + if (!nrfx_is_in_ram(p_nonce) || + !nrfx_is_in_ram(p_data_in) || + !nrfx_is_in_ram(p_data_out) || + !nrfx_is_in_ram(p_mac)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + if (operation == NRF_CRYPTO_DECRYPT) + { + operation_cc310 = SASI_AES_DECRYPT; + } + else if (operation == NRF_CRYPTO_ENCRYPT) + { + operation_cc310 = SASI_AES_ENCRYPT; + } + else + { + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + goto exit; + } + + if (p_ctx->header.p_info->mode == NRF_CRYPTO_AEAD_MODE_AES_CCM) + { + mode = CRYS_AESCCM_MODE_CCM; + + /* Allowed MAC size in CCM mode: [4, 6, 8, 10, 12, 14, 16] */ + if ((mac_size < NRF_CRYPTO_AES_CCM_MAC_MIN) || + (mac_size > NRF_CRYPTO_AES_CCM_MAC_MAX) || + ((mac_size & 0x01) != 0)) + { + ret_val = NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + goto exit; + } + + if ((nonce_size < NRF_CRYPTO_AES_CCM_NONCE_SIZE_MIN) || + (nonce_size > NRF_CRYPTO_AES_CCM_NONCE_SIZE_MAX)) + { + ret_val = NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE; + goto exit; + } + } + else + { + mode = CRYS_AESCCM_MODE_STAR; + + /* Allowed MAC size in CCM* mode: [0, 4, 8, 16] */ + if ((mac_size | NRF_CRYPTO_AES_CCM_STAR_MAC_BITMASK) != NRF_CRYPTO_AES_CCM_STAR_MAC_BITMASK) + { + ret_val = NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + goto exit; + } + + /* Allowed nonce size in CCM* mode: [13] */ + if (nonce_size != NRF_CRYPTO_AES_CCM_STAR_NONCE_SIZE) + { + ret_val = NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE; + goto exit; + } + } + + cc310_backend_enable(); + + result = CC_AESCCM_Init(&p_ctx->context, + operation_cc310, + p_ctx->key, + CRYS_AES_Key128BitSize, // the only allowed key size for CC310 + (uint32_t)adata_size, + (uint32_t)data_in_size, + p_nonce, + nonce_size, + mac_size, + mode); + + cc310_backend_disable(); + + ret_val = result_get(result); + + if (ret_val != NRF_SUCCESS) + { + goto exit; + } + + if ((adata_size > 0) && (p_adata != NULL)) + { + cc310_backend_enable(); + + result = CRYS_AESCCM_BlockAdata(&p_ctx->context, + p_adata, + (uint32_t)adata_size); + + cc310_backend_disable(); + + ret_val = result_get(result); + + if (ret_val != NRF_SUCCESS) + { + goto exit; + } + } + + /* CC310 backend always needs 16 bytes buffer for MAC calculation. */ + memcpy(mac_buffer, p_mac, mac_size); + + cc310_backend_enable(); + + result = CRYS_AESCCM_Finish(&p_ctx->context, + p_data_in, + (uint32_t)data_in_size, + p_data_out, + mac_buffer, + &mac_size); + + cc310_backend_disable(); + + ret_val = result_get(result); + if (ret_val == NRF_SUCCESS) + { + memcpy(p_mac, mac_buffer, mac_size); + } + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CCM) +nrf_crypto_aead_info_t const g_nrf_crypto_aes_ccm_128_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .mode = NRF_CRYPTO_AEAD_MODE_AES_CCM, + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .crypt_fn = backend_cc310_crypt +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR) +nrf_crypto_aead_info_t const g_nrf_crypto_aes_ccm_star_128_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .mode = NRF_CRYPTO_AEAD_MODE_AES_CCM_STAR, + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .crypt_fn = backend_cc310_crypt +}; +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_CC310_AES_AEAD) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.h new file mode 100644 index 0000000..74723ce --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_aes_aead.h @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_AES_AEAD_H__ +#define CC310_BACKEND_AES_AEAD_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_aes_aead nrf_crypto CC310 backend AES AEAD + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief AES AEAD functionality provided by the nrf_crypto CC310 backend. + */ + +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "crys_aesccm.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_aead_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_CC310_AES_BACKEND_KEY_SIZE (16) + + +/* AES CCM */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CCM) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CCM) +#error "Duplicate definition of AES CCM mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CCM_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 // Flag that nrf_crypto_aead frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_AEAD_ENABLED +#define NRF_CRYPTO_CC310_AES_AEAD_ENABLED 1 // aead backend for cc310 can be compiled + +/* define for test purposes */ +#define NRF_CRYPTO_AES_CCM_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + CRYS_AESCCM_UserContext_t context; /**< AES CCM context internal to CC310. */ + + uint8_t key[NRF_CRYPTO_CC310_AES_BACKEND_KEY_SIZE]; +} nrf_crypto_backend_aes_ccm_context_t; +#endif + +/* AES CCM* (CCM STAR) */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CCM_STAR) +#error "Duplicate definition of AES CCM* (star) mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CCM_STAR_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 // Flag that nrf_crypto_aes_aead frontend can be compiled +#undef NRF_CRYPTO_CC310_AES_AEAD_ENABLED +#define NRF_CRYPTO_CC310_AES_AEAD_ENABLED 1 // aead backend for cc310 can be compiled + +/* define for test purposes */ +#define NRF_CRYPTO_AES_CCM_STAR_128_ENABLED 1 + +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + CRYS_AESCCM_UserContext_t context; /**< AES CCM context internal to CC310. */ + + uint8_t key[NRF_CRYPTO_CC310_AES_BACKEND_KEY_SIZE]; +} nrf_crypto_backend_aes_ccm_star_context_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +/** @} */ + +#endif // CC310_BACKEND_AES_AEAD_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.c new file mode 100644 index 0000000..3747ab6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.c @@ -0,0 +1,214 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include +#include +#include "cc310_backend_mutex.h" +#include "crys_chacha_poly_error.h" +#include "cc310_backend_chacha_poly_aead.h" +#include "cc310_backend_shared.h" +#include "cc310_backend_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CC310_CHACHA_POLY_AEAD) + +static ret_code_t result_get(CRYSError_t error) +{ + ret_code_t ret_val; + + switch (error) + { + case CRYS_OK: + ret_val = NRF_SUCCESS; + break; + + /*! Invalid Additional data. */ + case CRYS_CHACHA_POLY_DATA_INVALID_ERROR: + case CRYS_CHACHA_POLY_ADATA_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_NULL; + break; + + /*! Illegal encryption mode. */ + case CRYS_CHACHA_POLY_ENC_MODE_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + /*! Illegal data size. */ + case CRYS_CHACHA_POLY_DATA_SIZE_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + /*! MAC comparison error. */ + case CRYS_CHACHA_POLY_MAC_ERROR: + ret_val = NRF_ERROR_CRYPTO_AEAD_INVALID_MAC; + break; + + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + return ret_val; +} + +static ret_code_t backend_cc310_init(void * const p_context, uint8_t * p_key) +{ + nrf_crypto_backend_chacha_poly_context_t * p_ctx = + (nrf_crypto_backend_chacha_poly_context_t *)p_context; + + if (!nrfx_is_in_ram(p_ctx)) + { + return NRF_ERROR_CRYPTO_INPUT_LOCATION; + } + + if (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_256) + { + return NRF_ERROR_CRYPTO_KEY_SIZE; + } + + memcpy(p_ctx->key, p_key, sizeof(p_ctx->key)); + return NRF_SUCCESS; +} + +static inline ret_code_t backend_cc310_uninit(void * const p_context) +{ + return NRF_SUCCESS; +} + +static ret_code_t backend_cc310_crypt(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) + +{ + CRYSError_t result; + ret_code_t ret_val; + bool mutex_locked; + + CRYS_CHACHA_EncryptMode_t operation_cc310; + + nrf_crypto_backend_chacha_poly_context_t * p_ctx = + (nrf_crypto_backend_chacha_poly_context_t *)p_context; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + if ((adata_size == 0) || (data_in_size == 0)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + goto exit; + } + + if (mac_size != NRF_CRYPTO_CHACHA_POLY_MAC_SIZE) + { + ret_val = NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + goto exit; + } + + if (nonce_size != NRF_CRYPTO_CHACHA_POLY_NONCE_SIZE) + { + ret_val = NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE; + goto exit; + } + + if (!nrfx_is_in_ram(p_data_in) || !nrfx_is_in_ram(p_data_out) || + !nrfx_is_in_ram(p_mac) || !nrfx_is_in_ram(p_adata) || + !nrfx_is_in_ram(p_nonce)) + { + ret_val = NRF_ERROR_CRYPTO_INPUT_LOCATION; + goto exit; + } + + if (operation == NRF_CRYPTO_DECRYPT) + { + operation_cc310 = CRYS_CHACHA_Decrypt; + } + else if (operation == NRF_CRYPTO_ENCRYPT) + { + operation_cc310 = CRYS_CHACHA_Encrypt; + } + else + { + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + goto exit; + } + + cc310_backend_enable(); + + result = CRYS_CHACHA_POLY(p_nonce, + p_ctx->key, + operation_cc310, + p_adata, + adata_size, + p_data_in, + data_in_size, + p_data_out, + (uint32_t *)p_mac); + cc310_backend_disable(); + + ret_val = result_get(result); + +exit: + cc310_backend_mutex_unlock(); + return ret_val; +} + +nrf_crypto_aead_info_t const g_nrf_crypto_chacha_poly_256_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .mode = NRF_CRYPTO_AEAD_MODE_CHACHA_POLY, + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .crypt_fn = backend_cc310_crypt +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_CC310_CHACHA_POLY_AEAD) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.h new file mode 100644 index 0000000..98381dd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_chacha_poly_aead.h @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_CHACHA_POLY_AEAD_H__ +#define CC310_BACKEND_CHACHA_POLY_AEAD_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_chacha_poly_aead nrf_crypto CC310 backend CHACHA_POLY AEAD + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief CHACHA_POLY AEAD functionality provided by the nrf_crypto CC310 backend. + */ + +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "crys_chacha_poly.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_aead_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_CC310_CHACHA_POLY_BACKEND_KEY_SIZE (32) + +/* CHACHA-POLY */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CHACHA_POLY) +#error "Duplicate definition of CHACHA-POLY mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_CHACHA_POLY_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 // Flag that nrf_crypto_aead frontend can be compiled +#undef NRF_CRYPTO_CC310_CHACHA_POLY_AEAD_ENABLED +#define NRF_CRYPTO_CC310_CHACHA_POLY_AEAD_ENABLED 1 // aead backend for cc310 can be compiled + +/* defines for test purposes */ +#define NRF_CRYPTO_CHACHA_POLY_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + + uint8_t key[NRF_CRYPTO_CC310_CHACHA_POLY_BACKEND_KEY_SIZE]; +} nrf_crypto_backend_chacha_poly_context_t; +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +/** @} */ + +#endif // CC310_BACKEND_CHACHA_POLY_AEAD_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.c new file mode 100644 index 0000000..cc2a11f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.c @@ -0,0 +1,727 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include + +#include "nrf_crypto_mem.h" +#include "nrf_crypto_ecc.h" +#include "cc310_backend_ecc.h" +#include "cc310_backend_shared.h" +#include "cc310_backend_mutex.h" +#include "crys_ecpki_kg.h" +#include "crys_ecpki_domain.h" +#include "crys_ecpki_build.h" +#include "crys_ecpki_error.h" +#include "crys_rnd_error.h" +#include "crys_ec_mont_api.h" +#include "crys_ec_edw_api.h" +#include "crys_ec_mont_edw_error.h" +#include "nrf_crypto_shared.h" + + +#define CC310_UNCOMPRESSED_PUBLIC_KEY_ID_BYTE 0x04 /**< @brief @internal Byte value used by CC310 library to prefix uncompressed public key. */ + + +ret_code_t nrf_crypto_backend_cc310_ecc_error_convert(uint32_t crys_error) +{ + switch (crys_error) + { + case CRYS_OK: + return NRF_SUCCESS; + + case CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR: + case CRYS_ECEDW_SIGN_VERIFY_FAILED_ERROR: + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + + case CRYS_RND_INSTANTIATION_NOT_DONE_ERROR: + return NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + + default: + return NRF_ERROR_CRYPTO_INTERNAL; + } +} + + +/** @internal @brief Returns domain value from @ref CRYS_ECPKI_DomainID_t enum based on + * value from info structure. + * + * @param[in] p_info Curve info. + * @returns Pointer to CC310 domain. + */ +static CRYS_ECPKI_Domain_t const * get_domain(nrf_crypto_ecc_curve_info_t const * p_info) +{ + CRYS_ECPKI_DomainID_t domain_id = (CRYS_ECPKI_DomainID_t)(intptr_t)p_info->p_backend_data; + const CRYS_ECPKI_Domain_t * domain = CRYS_ECPKI_GetEcDomain(domain_id); + return domain; +} + + +ret_code_t nrf_crypto_backend_cc310_ecc_public_key_convert( + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub, + CRYS_ECPKI_BUILD_TempData_t * p_temp_data) +{ + ret_code_t result; + CRYSError_t crys_error; + CRYS_ECPKI_Domain_t const * p_domain; + uint8_t ucompressed_key[NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE + 1]; + bool mutex_locked; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if (p_pub->key_converted) + { + return NRF_SUCCESS; + } + + p_domain = get_domain(p_info); + + // Tell CC310 library that this is raw public key in uncompressed format. + ucompressed_key[0] = CC310_UNCOMPRESSED_PUBLIC_KEY_ID_BYTE; + memcpy(&ucompressed_key[1], p_pub->key.raw_public_key, p_info->raw_public_key_size); + + mutex_locked = cc310_backend_mutex_trylock(); + if (!mutex_locked) + { + return NRF_ERROR_CRYPTO_BUSY; + } + + cc310_backend_enable(); + + crys_error = CRYS_ECPKI_BuildPublKeyPartlyCheck(p_domain, + ucompressed_key, + p_info->raw_public_key_size + 1, + &p_pub->key.cc310_public_key, + p_temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + if (result == NRF_SUCCESS) + { + p_pub->key_converted = true; + } + else + { + memcpy(p_pub->key.raw_public_key, &ucompressed_key[1], p_info->raw_public_key_size); + } + + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + ret_code_t result; + CRYSError_t crys_error; + CRYS_ECPKI_Domain_t const * p_domain; + bool mutex_locked; + + nrf_crypto_backend_cc310_key_pair_generate_context_t * p_ctx = + (nrf_crypto_backend_cc310_key_pair_generate_context_t *)p_context; + + nrf_crypto_backend_cc310_ecc_private_key_t * p_prv = + (nrf_crypto_backend_cc310_ecc_private_key_t *)p_private_key; + + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub = + (nrf_crypto_backend_cc310_ecc_public_key_t *)p_public_key; + + p_domain = get_domain(p_prv->header.p_info); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECPKI_GenKeyPair(p_context, + nrf_crypto_backend_cc310_rng, + p_domain, + &p_prv->private_key, + &p_pub->key.cc310_public_key, + &p_ctx->temp_data, + NULL); + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + p_pub->key_converted = true; + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data) +{ + ret_code_t result; + CRYSError_t crys_error; + CRYS_ECPKI_Domain_t const * p_domain; + bool mutex_locked; + + nrf_crypto_backend_cc310_ecc_private_key_t * p_prv = + (nrf_crypto_backend_cc310_ecc_private_key_t *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + p_domain = get_domain(p_info); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + crys_error = CRYS_ECPKI_BuildPrivKey(p_domain, + p_raw_data, + p_info->raw_private_key_size, + &p_prv->private_key); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data) +{ + ret_code_t result; + CRYSError_t crys_error; + uint32_t key_size; + + nrf_crypto_backend_cc310_ecc_private_key_t * p_prv = + (nrf_crypto_backend_cc310_ecc_private_key_t *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + key_size = p_info->raw_private_key_size; + + crys_error = CRYS_ECPKI_ExportPrivKey(&p_prv->private_key, + p_raw_data, + &key_size); + + if (key_size != p_info->raw_private_key_size) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub = + (nrf_crypto_backend_cc310_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + memcpy(p_pub->key.raw_public_key, p_raw_data, p_info->raw_public_key_size); + p_pub->key_converted = false; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_cc310_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + ret_code_t result; + CRYSError_t crys_error; + uint8_t ucompressed_key[NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE + 1]; + uint32_t key_size; + bool mutex_locked; + + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub = + (nrf_crypto_backend_cc310_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if (!p_pub->key_converted) + { + memcpy(p_raw_data, p_pub->key.raw_public_key, p_info->raw_public_key_size); + return NRF_SUCCESS; + } + + mutex_locked = cc310_backend_mutex_trylock(); + if (!mutex_locked) + { + return NRF_ERROR_CRYPTO_BUSY; + } + + key_size = p_info->raw_public_key_size + 1; + + crys_error = CRYS_ECPKI_ExportPublKey(&p_pub->key.cc310_public_key, + CRYS_EC_PointUncompressed, + ucompressed_key, + &key_size); + + cc310_backend_mutex_unlock(); + + if ((key_size != p_info->raw_public_key_size + 1) + || (ucompressed_key[0] != CC310_UNCOMPRESSED_PUBLIC_KEY_ID_BYTE)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + memcpy(p_raw_data, &ucompressed_key[1], p_info->raw_public_key_size); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + +ret_code_t nrf_crypto_backend_cc310_curve25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + + nrf_crypto_backend_cc310_curve25519_context_t * p_ctx = + (nrf_crypto_backend_cc310_curve25519_context_t *)p_context; + + nrf_crypto_backend_curve25519_private_key_t * p_prv = + (nrf_crypto_backend_curve25519_private_key_t *)p_private_key; + + nrf_crypto_backend_curve25519_public_key_t * p_pub = + (nrf_crypto_backend_curve25519_public_key_t *)p_public_key; + + size_t pub_key_size = sizeof(p_pub->key); + size_t prv_key_size = sizeof(p_prv->key); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECMONT_KeyPair(p_pub->key, + &pub_key_size, + p_prv->key, + &prv_key_size, + p_context, + nrf_crypto_backend_cc310_rng, + &p_ctx->temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_curve25519_key_from_raw( + void * p_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_curve25519_key_t * p_internal_key = + (nrf_crypto_backend_curve25519_key_t *)p_key; + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + nrf_crypto_internal_swap_endian(p_internal_key->key, p_raw_data, sizeof(p_internal_key->key)); +#else + memcpy(p_internal_key->key, p_raw_data, sizeof(p_internal_key->key)); +#endif + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_cc310_curve25519_key_to_raw( + void const * p_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_curve25519_key_t * p_internal_key = + (nrf_crypto_backend_curve25519_key_t *)p_key; + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + nrf_crypto_internal_swap_endian(p_raw_data, p_internal_key->key, sizeof(p_internal_key->key)); +#else + memcpy(p_raw_data, p_internal_key->key, sizeof(p_internal_key->key)); +#endif + + return NRF_SUCCESS; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + +ret_code_t nrf_crypto_backend_cc310_ed25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + + nrf_crypto_backend_cc310_ed25519_context_t * p_ctx = + (nrf_crypto_backend_cc310_ed25519_context_t *)p_context; + + nrf_crypto_backend_ed25519_private_key_t * p_prv = + (nrf_crypto_backend_ed25519_private_key_t *)p_private_key; + + nrf_crypto_backend_ed25519_public_key_t * p_pub = + (nrf_crypto_backend_ed25519_public_key_t *)p_public_key; + + size_t pub_key_size = sizeof(p_pub->key); + size_t prv_key_size = sizeof(p_prv->key); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECEDW_KeyPair(p_prv->key, + &prv_key_size, + p_pub->key, + &pub_key_size, + p_context, + nrf_crypto_backend_cc310_rng, + &p_ctx->temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_ed25519_private_key_from_raw( + void * p_key, + uint8_t const * p_raw_data) +{ + uint8_t pub_key_dummy[CRYS_ECEDW_ORD_SIZE_IN_BYTES]; // Throw away buffer + CRYSError_t crys_error; + bool mutex_locked; + ret_code_t result; + CRYS_ECEDW_TempBuff_t * p_temp_data = NULL; + + nrf_crypto_backend_ed25519_private_key_t * p_internal_prv_key = + (nrf_crypto_backend_ed25519_private_key_t *)p_key; + + size_t prv_key_size = sizeof(p_internal_prv_key->key); + size_t pub_key_size = sizeof(pub_key_dummy); + + // Generate public key using CRYS_ECEDW_SeedKeyPair + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + // Use memory allocation (instead of stack) for the temporary data, as it is ~700 bytes. + p_temp_data = NRF_CRYPTO_ALLOC(sizeof(CRYS_ECEDW_TempBuff_t)); + if (p_temp_data == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + + cc310_backend_enable(); + + crys_error = CRYS_ECEDW_SeedKeyPair(p_raw_data, + CRYS_ECEDW_ORD_SIZE_IN_BYTES, + p_internal_prv_key->key, + &prv_key_size, + pub_key_dummy, + &pub_key_size, + p_temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + NRF_CRYPTO_FREE(p_temp_data); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_ed25519_private_key_to_raw( + void const * p_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_ed25519_private_key_t * p_internal_key = + (nrf_crypto_backend_ed25519_private_key_t *)p_key; + + memcpy(p_raw_data, p_internal_key->key, CRYS_ECEDW_ORD_SIZE_IN_BYTES); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_cc310_ed25519_public_key_from_raw( + void * p_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_ed25519_public_key_t * p_internal_key = + (nrf_crypto_backend_ed25519_public_key_t *)p_key; + + memcpy(p_internal_key->key, p_raw_data, sizeof(p_internal_key->key)); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_cc310_ed25519_public_key_to_raw( + void const * p_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_ed25519_public_key_t * p_internal_key = + (nrf_crypto_backend_ed25519_public_key_t *)p_key; + + memcpy(p_raw_data, p_internal_key->key, sizeof(p_internal_key->key)); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_ed25519_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + nrf_crypto_backend_ed25519_private_key_t * p_prv = + (nrf_crypto_backend_ed25519_private_key_t *)p_private_key; + + nrf_crypto_backend_ed25519_public_key_t * p_pub = + (nrf_crypto_backend_ed25519_public_key_t *)p_public_key; + + memcpy(p_pub->key, p_prv->key+CRYS_ECEDW_ORD_SIZE_IN_BYTES, CRYS_ECEDW_ORD_SIZE_IN_BYTES); + + return NRF_SUCCESS; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP160R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP160R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP160R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp160r1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160r2_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP160R2_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP160R2_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP160R2_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp160r2, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp192r1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp224r1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp256r1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp384r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP384R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP384R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP384R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp384r1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp521r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP521R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP521R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP521R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp521r1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP160K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP160K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP160K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp160k1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP192K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP192K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP192K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp192k1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP224K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP224K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP224K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp224k1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_cc310_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_cc310_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECPKI_DomainID_secp256k1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_curve25519_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_curve25519_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_curve25519_private_key_t), + .curve_type = NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)CRYS_ECMONT_DOMAIN_CURVE_25519, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_ed25519_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_ed25519_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_ed25519_private_key_t), + .curve_type = NRF_CRYPTO_ECC_ED25519_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = NULL, +}; +#endif + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.h new file mode 100644 index 0000000..e6a734a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecc.h @@ -0,0 +1,734 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_ECC_H__ +#define CC310_BACKEND_ECC_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include +#include "nrf_crypto_ecc_shared.h" +#include "crys_ecpki_kg.h" +#include "crys_ec_mont_api.h" +#include "crys_ec_edw_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @internal @brief Common structure holding private key for CC310. + * + * @details Used for most curves (except Curve25519 and Ed25519). + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + CRYS_ECPKI_UserPrivKey_t private_key; /**< @internal @brief CC310 specific key representation */ +} nrf_crypto_backend_cc310_ecc_private_key_t; + + +/** @internal @brief Common structure holding public key for CC310. + * + * @details Used for most curves (except Curve25519 and Ed25519). + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + bool key_converted; /**< @internal @brief True if key was already converted from raw_public_key to cc310_public_key */ + union + { + CRYS_ECPKI_UserPublKey_t cc310_public_key; /**< @internal @brief CC310 specific key representation */ + uint8_t raw_public_key[132]; /**< @internal @brief raw key representation */ + } key; +} nrf_crypto_backend_cc310_ecc_public_key_t; + + +/** @internal @brief Common structure holding context for key pair generation. + * + * @details Used for most curves (except Curve25519 and Ed25519). + */ +typedef struct +{ + CRYS_ECPKI_KG_TempData_t temp_data; /**< @internal @brief Temporary buffer for CC310 internal storage */ +} nrf_crypto_backend_cc310_key_pair_generate_context_t; + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + * + * @details Used for most curves (except Curve25519 and Ed25519). + */ +ret_code_t nrf_crypto_backend_cc310_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_from_raw_fn_t. + * + * @details Used for most curves (except Curve25519 and Ed25519). +*/ +ret_code_t nrf_crypto_backend_cc310_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_to_raw_fn_t. + * + * @details Used for most curves (except Curve25519 and Ed25519). +*/ +ret_code_t nrf_crypto_backend_cc310_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. + * + * @details Used for most curves (except Curve25519 and Ed25519). +*/ +ret_code_t nrf_crypto_backend_cc310_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. + * + * @details Used for most curves (except Curve25519 and Ed25519). +*/ +ret_code_t nrf_crypto_backend_cc310_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + + +/** @internal @brief Convert error code from CC310 to nrf_crypto error code. + * + * @param[in] crys_error CC310 error code. + * @return nrf_crypto error code. + */ +ret_code_t nrf_crypto_backend_cc310_ecc_error_convert(uint32_t crys_error); + + +/** @internal @brief Converts public key from raw to CC310 representation if not converted already. + * + * Data are read from p_pub->key.raw_public_key to stored into p_pub->cc310_public_key. + * + * @param[in] p_pub Public key to convert. + * @param[in] p_temp_data Buffer for temporary data used by CC310 lib. + * @return nrf_crypto error code. + */ +ret_code_t nrf_crypto_backend_cc310_ecc_public_key_convert( + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub, + CRYS_ECPKI_BUILD_TempData_t * p_temp_data); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP160R1) +#error "More than one backend enabled for secp160r1 (NIST 160-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP160R1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp160r1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp160r1_public_key_calculate NULL +#define nrf_crypto_backend_secp160r1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp160r1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp160r1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp160r1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp160r1_private_key_free NULL +#define nrf_crypto_backend_secp160r1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP160R1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP160R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp160r1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp160r1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp160r1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp160r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP160R2) +#error "More than one backend enabled for secp160r2 (NIST 160-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP160R2_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp160r2_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp160r2_public_key_calculate NULL +#define nrf_crypto_backend_secp160r2_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp160r2_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp160r2_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp160r2_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp160r2_private_key_free NULL +#define nrf_crypto_backend_secp160r2_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP160R2_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP160R2_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp160r2_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp160r2_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp160r2_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp160r2_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP192R1) +#error "More than one backend enabled for secp192r1 (NIST 192-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP192R1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp192r1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp192r1_public_key_calculate NULL +#define nrf_crypto_backend_secp192r1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp192r1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp192r1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp192r1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp192r1_private_key_free NULL +#define nrf_crypto_backend_secp192r1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP192R1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP192R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp192r1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp192r1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp192r1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp192r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP224R1) +#error "More than one backend enabled for secp224r1 (NIST 224-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP224R1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp224r1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp224r1_public_key_calculate NULL +#define nrf_crypto_backend_secp224r1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp224r1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp224r1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp224r1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp224r1_private_key_free NULL +#define nrf_crypto_backend_secp224r1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP224R1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP224R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp224r1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp224r1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp224r1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp224r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256R1) +#error "More than one backend enabled for secp256r1 (NIST 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp256r1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp256r1_public_key_calculate NULL +#define nrf_crypto_backend_secp256r1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp256r1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp256r1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp256r1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp256r1_private_key_free NULL +#define nrf_crypto_backend_secp256r1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp256r1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp256r1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp256r1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP384R1) +#error "More than one backend enabled for secp384r1 (NIST 384-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP384R1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp384r1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp384r1_public_key_calculate NULL +#define nrf_crypto_backend_secp384r1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp384r1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp384r1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp384r1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp384r1_private_key_free NULL +#define nrf_crypto_backend_secp384r1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp384r1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp384r1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp384r1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp384r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP521R1) +#error "More than one backend enabled for secp521r1 (NIST 521-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP521R1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp521r1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp521r1_public_key_calculate NULL +#define nrf_crypto_backend_secp521r1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp521r1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp521r1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp521r1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp521r1_private_key_free NULL +#define nrf_crypto_backend_secp521r1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP521R1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP521R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp521r1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp521r1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp521r1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp521r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP160K1) +#error "More than one backend enabled for secp160k1 (Koblitz 160-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP160K1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp160k1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp160k1_public_key_calculate NULL +#define nrf_crypto_backend_secp160k1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp160k1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp160k1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp160k1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp160k1_private_key_free NULL +#define nrf_crypto_backend_secp160k1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP160K1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP160K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp160k1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp160k1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp160k1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp160k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP192K1) +#error "More than one backend enabled for secp192k1 (Koblitz 192-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP192K1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp192k1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp192k1_public_key_calculate NULL +#define nrf_crypto_backend_secp192k1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp192k1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp192k1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp192k1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp192k1_private_key_free NULL +#define nrf_crypto_backend_secp192k1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP192K1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP192K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp192k1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp192k1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp192k1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp192k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP224K1) +#error "More than one backend enabled for secp224k1 (Koblitz 224-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP224K1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp224k1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp224k1_public_key_calculate NULL +#define nrf_crypto_backend_secp224k1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp224k1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp224k1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp224k1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp224k1_private_key_free NULL +#define nrf_crypto_backend_secp224k1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP224K1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP224K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp224k1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp224k1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp224k1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp224k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256K1) +#error "More than one backend enabled for secp256k1 (Koblitz 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256K1_ENABLED 1 + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp256k1_key_pair_generate nrf_crypto_backend_cc310_key_pair_generate +#define nrf_crypto_backend_secp256k1_public_key_calculate NULL +#define nrf_crypto_backend_secp256k1_private_key_from_raw nrf_crypto_backend_cc310_private_key_from_raw +#define nrf_crypto_backend_secp256k1_private_key_to_raw nrf_crypto_backend_cc310_private_key_to_raw +#define nrf_crypto_backend_secp256k1_public_key_from_raw nrf_crypto_backend_cc310_public_key_from_raw +#define nrf_crypto_backend_secp256k1_public_key_to_raw nrf_crypto_backend_cc310_public_key_to_raw +#define nrf_crypto_backend_secp256k1_private_key_free NULL +#define nrf_crypto_backend_secp256k1_public_key_free NULL + +// Context sizes required by CC310 +#define NRF_CRYPTO_BACKEND_SECP256K1_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_key_pair_generate_context_t) +#define NRF_CRYPTO_BACKEND_SECP256K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_cc310_ecc_private_key_t nrf_crypto_backend_secp256k1_private_key_t; +typedef nrf_crypto_backend_cc310_ecc_public_key_t nrf_crypto_backend_secp256k1_public_key_t; + +// Most CC310 curve types share the same data structures for context +typedef nrf_crypto_backend_cc310_key_pair_generate_context_t + nrf_crypto_backend_secp256k1_key_pair_generate_context_t; + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_CURVE25519) +#error "More than one backend enabled for Curve25519."); +#endif +#define NRF_CRYPTO_ECC_CURVE25519_ENABLED 1 + +/** @internal @brief Common structure holding context for Curve25519 (all operations). + */ +typedef struct +{ + CRYS_ECMONT_TempBuff_t temp_data; /**< @internal @brief Temporary buffer for CC310 internal storage */ +} nrf_crypto_backend_cc310_curve25519_context_t; + +/** @internal @brief Structure holding keys for Curve25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[32]; /**< @internal @brief Raw key in little-endian order. */ +} nrf_crypto_backend_curve25519_key_t; + +// Most CC310 curve types share the same data structures for keys +typedef nrf_crypto_backend_curve25519_key_t nrf_crypto_backend_curve25519_private_key_t; +typedef nrf_crypto_backend_curve25519_key_t nrf_crypto_backend_curve25519_public_key_t; + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_cc310_curve25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + +ret_code_t nrf_crypto_backend_cc310_curve25519_key_from_raw( + void * p_key, + uint8_t const * p_raw_data); + +ret_code_t nrf_crypto_backend_cc310_curve25519_key_to_raw( + void const * p_key, + uint8_t * p_raw_data); + +// Aliases for Curve25519-specific CC310 implementation. +#define nrf_crypto_backend_curve25519_key_pair_generate \ + nrf_crypto_backend_cc310_curve25519_key_pair_generate +#define nrf_crypto_backend_curve25519_private_key_from_raw \ + nrf_crypto_backend_cc310_curve25519_key_from_raw +#define nrf_crypto_backend_curve25519_private_key_to_raw \ + nrf_crypto_backend_cc310_curve25519_key_to_raw +#define nrf_crypto_backend_curve25519_public_key_from_raw \ + nrf_crypto_backend_cc310_curve25519_key_from_raw +#define nrf_crypto_backend_curve25519_public_key_to_raw \ + nrf_crypto_backend_cc310_curve25519_key_to_raw + +// Aliases for unused or unimplemented functions. +#define nrf_crypto_backend_curve25519_public_key_calculate NULL +#define nrf_crypto_backend_curve25519_private_key_free NULL +#define nrf_crypto_backend_curve25519_public_key_free NULL + +// Context sizes required by CC310 Curve25519. +#define NRF_CRYPTO_BACKEND_CURVE25519_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_curve25519_context_t) +#define NRF_CRYPTO_BACKEND_CURVE25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// All CC310 Curve25519 operations share the same data structures for context. +typedef nrf_crypto_backend_cc310_curve25519_context_t + nrf_crypto_backend_curve25519_key_pair_generate_context_t; + +// Dummy typedef for unused context. +typedef nrf_crypto_backend_cc310_curve25519_context_t + nrf_crypto_backend_curve25519_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_ED25519) +#error "More than one backend enabled for Ed25519."); +#endif +#define NRF_CRYPTO_ECC_ED25519_ENABLED 1 + +/** @internal @brief Common structure holding context for Ed25519 (all operations). + */ +typedef struct +{ + CRYS_ECEDW_TempBuff_t temp_data; /**< @internal @brief Temporary buffer for CC310 internal storage. */ +} nrf_crypto_backend_cc310_ed25519_context_t; + + +/** @internal @brief Structure holding private key for Ed25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[2 * CRYS_ECEDW_ORD_SIZE_IN_BYTES]; /**< @internal @brief Raw private key (seed || pubKey) in little-endian order. */ +} nrf_crypto_backend_ed25519_private_key_t; + + +/** @internal @brief Structure holding public key for Ed25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[CRYS_ECEDW_ORD_SIZE_IN_BYTES]; /**< @internal @brief Raw public key in little-endian order. */ +} nrf_crypto_backend_ed25519_public_key_t; + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_cc310_ed25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + +ret_code_t nrf_crypto_backend_cc310_ed25519_private_key_from_raw( + void * p_key, + uint8_t const * p_raw_data); + +ret_code_t nrf_crypto_backend_cc310_ed25519_private_key_to_raw( + void const * p_key, + uint8_t * p_raw_data); + +ret_code_t nrf_crypto_backend_cc310_ed25519_public_key_from_raw( + void * p_key, + uint8_t const * p_raw_data); + +ret_code_t nrf_crypto_backend_cc310_ed25519_public_key_to_raw( + void const * p_key, + uint8_t * p_raw_data); + +ret_code_t nrf_crypto_backend_cc310_ed25519_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + +// Aliases for Ed25519-specific CC310 implementation. +#define nrf_crypto_backend_ed25519_key_pair_generate \ + nrf_crypto_backend_cc310_ed25519_key_pair_generate +#define nrf_crypto_backend_ed25519_private_key_from_raw \ + nrf_crypto_backend_cc310_ed25519_private_key_from_raw +#define nrf_crypto_backend_ed25519_private_key_to_raw \ + nrf_crypto_backend_cc310_ed25519_private_key_to_raw +#define nrf_crypto_backend_ed25519_public_key_from_raw \ + nrf_crypto_backend_cc310_ed25519_public_key_from_raw +#define nrf_crypto_backend_ed25519_public_key_to_raw \ + nrf_crypto_backend_cc310_ed25519_public_key_to_raw +#define nrf_crypto_backend_ed25519_public_key_calculate \ + nrf_crypto_backend_cc310_ed25519_public_key_calculate + +// Aliases for unused or unimplemented functions. +#define nrf_crypto_backend_ed25519_private_key_free NULL +#define nrf_crypto_backend_ed25519_public_key_free NULL + +// Context sizes required by CC310 Ed25519 +#define NRF_CRYPTO_BACKEND_ED25519_KEY_PAIR_GENERATE_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ed25519_context_t) +#define NRF_CRYPTO_BACKEND_ED25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// All CC310 Ed25519 operations share the same data structures for context. +typedef nrf_crypto_backend_cc310_ed25519_context_t + nrf_crypto_backend_ed25519_key_pair_generate_context_t; + +// Dummy typedef for unused context. +typedef nrf_crypto_backend_cc310_ed25519_context_t + nrf_crypto_backend_ed25519_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#endif // CC310_BACKEND_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.c new file mode 100644 index 0000000..c756f31 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.c @@ -0,0 +1,191 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdh_shared.h" +#include "nrf_crypto_ecdh.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_shared.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_shared.h" +#include "cc310_backend_ecdh.h" + + +ret_code_t nrf_crypto_backend_cc310_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + ret_code_t result; + CRYSError_t crys_error; + uint32_t shared_secret_size; + uint8_t aligned_buffer[(NRF_CRYPTO_ECDH_SHARED_SECRET_MAX_SIZE + 3) & ~3]; + uint8_t * p_output_buffer; + bool mutex_locked; + + nrf_crypto_backend_cc310_ecdh_compute_context_t * p_ctx = + (nrf_crypto_backend_cc310_ecdh_compute_context_t *)p_context; + + nrf_crypto_backend_cc310_ecc_private_key_t * p_prv = + (nrf_crypto_backend_cc310_ecc_private_key_t *)p_private_key; + + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub = + (nrf_crypto_backend_cc310_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + result = nrf_crypto_backend_cc310_ecc_public_key_convert(p_pub, &p_ctx->key_build_temp_data); + if (result != NRF_SUCCESS) + { + return result; + } + + shared_secret_size = p_info->raw_private_key_size; + + if ((shared_secret_size & 3) != 0) // Check if shared_secret_size is word aligned + { + shared_secret_size = (shared_secret_size + 3) & ~3; + p_output_buffer = &aligned_buffer[0]; + } + else + { + p_output_buffer = p_shared_secret; + } + + mutex_locked = cc310_backend_mutex_trylock(); + if (!mutex_locked) + { + return NRF_ERROR_CRYPTO_BUSY; + } + + cc310_backend_enable(); + + crys_error = CRYS_ECDH_SVDP_DH(&p_pub->key.cc310_public_key, + &p_prv->private_key, + p_output_buffer, + &shared_secret_size, + &p_ctx->temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + if (p_output_buffer != p_shared_secret) + { + //lint -save -e645 (Symbol 'aligned_buffer' may not have been initialized) + memcpy(p_shared_secret, + &aligned_buffer[3 - ((p_info->raw_private_key_size + 3) & 3)], // Bytes at the beginning that were added during padding are now skipped + p_info->raw_private_key_size); + //lint -restore + } + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + +ret_code_t nrf_crypto_backend_cc310_curve25519_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + + nrf_crypto_backend_cc310_curve25519_context_t * p_ctx = + (nrf_crypto_backend_cc310_curve25519_context_t *)p_context; + + nrf_crypto_backend_curve25519_private_key_t * p_prv = + (nrf_crypto_backend_curve25519_private_key_t *)p_private_key; + + nrf_crypto_backend_curve25519_public_key_t * p_pub = + (nrf_crypto_backend_curve25519_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + size_t shared_secret_size = p_info->raw_private_key_size; + size_t pub_key_size = sizeof(p_pub->key); + size_t prv_key_size = sizeof(p_prv->key); + + mutex_locked = cc310_backend_mutex_trylock(); + if (!mutex_locked) + { + return NRF_ERROR_CRYPTO_BUSY; + } + + cc310_backend_enable(); + + crys_error = CRYS_ECMONT_Scalarmult(p_shared_secret, + &shared_secret_size, + p_prv->key, + prv_key_size, + p_pub->key, + pub_key_size, + &p_ctx->temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + // Swap endianess (only for Curve25519) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + nrf_crypto_internal_swap_endian_in_place(p_shared_secret, + NRF_CRYPTO_ECDH_CURVE25519_SHARED_SECRET_SIZE); +#endif + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.h new file mode 100644 index 0000000..5703e98 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdh.h @@ -0,0 +1,199 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_ECDH_H__ +#define CC310_BACKEND_ECDH_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" +#include "crys_ecpki_dh.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal @brief Common structure holding context for ECDH. + */ +typedef union +{ + CRYS_ECDH_TempData_t temp_data; /**< @internal @brief Temporary buffer for CC310 internal storage */ + CRYS_ECPKI_BUILD_TempData_t key_build_temp_data; /**< @internal @brief Temporary buffer for CC310 public key build */ +} nrf_crypto_backend_cc310_ecdh_compute_context_t; + + +/** @internal See @ref nrf_crypto_backend_ecdh_compute_fn_t. + */ +ret_code_t nrf_crypto_backend_cc310_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp160r1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP160R1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp160r1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp160r2_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP160R2_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp160r2_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp192r1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP192R1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp192r1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp224r1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP224R1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp224r1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp256r1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp256r1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp384r1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP384R1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp384r1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp521r1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP521R1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp521r1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp160k1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP160K1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp160k1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp192k1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP192K1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp192k1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp224k1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP224K1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp224k1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1) +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_secp256k1_ecdh_compute nrf_crypto_backend_cc310_ecdh_compute +#define NRF_CRYPTO_BACKEND_SECP256K1_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_secp256k1_ecdh_context_t; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + +ret_code_t nrf_crypto_backend_cc310_curve25519_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + +// Aliases for one common CC310 implementation +#define nrf_crypto_backend_curve25519_ecdh_compute nrf_crypto_backend_cc310_curve25519_ecdh_compute +#define NRF_CRYPTO_BACKEND_CURVE25519_ECDH_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_ecdh_compute_context_t) +typedef nrf_crypto_backend_cc310_ecdh_compute_context_t nrf_crypto_backend_curve25519_ecdh_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#endif // CC310_BACKEND_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.c new file mode 100644 index 0000000..9a315f8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.c @@ -0,0 +1,223 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include +#include "ssi_pal_types.h" +#include "ssi_pal_mem.h" +#include "sns_silib.h" +#include "crys_rnd.h" +#include "crys_ecpki_ecdsa.h" +#include "crys_ecpki_error.h" +#include "crys_kdf_error.h" +#include "crys_hash_error.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" +#include "nrf_crypto_ecdsa.h" +#include "cc310_backend_ecdsa.h" +#include "cc310_backend_shared.h" +#include "cc310_backend_mutex.h" + + +#define CC310_SHA1_DIGEST_SIZE (160 / 8) /**< @internal @brief Digest size of SHA-1 */ +#define CC310_SHA224_DIGEST_SIZE (224 / 8) /**< @internal @brief Digest size of SHA-224 */ +#define CC310_SHA256_DIGEST_SIZE (256 / 8) /**< @internal @brief Digest size of SHA-256 */ +#define CC310_SHA384_DIGEST_SIZE (384 / 8) /**< @internal @brief Digest size of SHA-384 */ +#define CC310_SHA512_DIGEST_SIZE (512 / 8) /**< @internal @brief Digest size of SHA-512 */ + + +/** @internal @brief Returns enum value of @ref CRYS_ECPKI_HASH_OpMode_t based on provided hash size. + * + * @param[in] data_size Hash size + * @return Value from @ref CRYS_ECPKI_HASH_OpMode_t or CRYS_ECPKI_HASH_OpModeLast if + * cannot find implemented hash with provided size. + */ +static CRYS_ECPKI_HASH_OpMode_t hash_mode_from_size(uint32_t data_size) +{ + CRYS_ECPKI_HASH_OpMode_t hash_mode; + + switch (data_size) + { + case CC310_SHA1_DIGEST_SIZE: + hash_mode = CRYS_ECPKI_AFTER_HASH_SHA1_mode; + break; + + case CC310_SHA224_DIGEST_SIZE: + hash_mode = CRYS_ECPKI_AFTER_HASH_SHA224_mode; + break; + + case CC310_SHA256_DIGEST_SIZE: + hash_mode = CRYS_ECPKI_AFTER_HASH_SHA256_mode; + break; + + case CC310_SHA384_DIGEST_SIZE: + hash_mode = CRYS_ECPKI_AFTER_HASH_SHA384_mode; + break; + + case CC310_SHA512_DIGEST_SIZE: + hash_mode = CRYS_ECPKI_AFTER_HASH_SHA512_mode; + break; + + default: + hash_mode = CRYS_ECPKI_HASH_OpModeLast; + break; + } + + return hash_mode; +} + + +ret_code_t nrf_crypto_backend_cc310_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature) +{ + ret_code_t result; + CRYSError_t crys_error; + uint32_t signature_size; + CRYS_ECPKI_HASH_OpMode_t hash_mode = hash_mode_from_size(data_size); + bool mutex_locked; + + nrf_crypto_backend_cc310_sign_context_t * p_ctx = + (nrf_crypto_backend_cc310_sign_context_t *)p_context; + + nrf_crypto_backend_cc310_ecc_private_key_t * p_prv = + (nrf_crypto_backend_cc310_ecc_private_key_t *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + if (hash_mode == CRYS_ECPKI_HASH_OpModeLast) + { + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + signature_size = p_info->raw_public_key_size; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECDSA_Sign(p_context, + nrf_crypto_backend_cc310_rng, + &p_ctx->user_context, + &p_prv->private_key, + hash_mode, + (uint8_t *)p_data, + data_size, + p_signature, + &signature_size); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + + if (result == NRF_SUCCESS && signature_size != p_info->raw_public_key_size) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return result; +} + + +ret_code_t nrf_crypto_backend_cc310_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + ret_code_t result; + CRYSError_t crys_error; + CRYS_ECPKI_HASH_OpMode_t hash_mode = hash_mode_from_size(data_size); + bool mutex_locked; + + nrf_crypto_backend_cc310_verify_context_t * p_ctx = + (nrf_crypto_backend_cc310_verify_context_t *)p_context; + + nrf_crypto_backend_cc310_ecc_public_key_t * p_pub = + (nrf_crypto_backend_cc310_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + result = nrf_crypto_backend_cc310_ecc_public_key_convert(p_pub, &p_ctx->key_build_temp_data); + if (result != NRF_SUCCESS) + { + return result; + } + + if (hash_mode == CRYS_ECPKI_HASH_OpModeLast) + { + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECDSA_Verify(&p_ctx->user_context, + &p_pub->key.cc310_public_key, + hash_mode, + (uint8_t *)p_signature, + p_info->raw_public_key_size, + (uint8_t *)p_data, + data_size); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + return result; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.h new file mode 100644 index 0000000..d06e576 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_ecdsa.h @@ -0,0 +1,245 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_ECDSA_H__ +#define CC310_BACKEND_ECDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" +#include "crys_ecpki_types.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal @brief Common structure holding context for ECDSA sign. + */ +typedef struct +{ + CRYS_ECDSA_SignUserContext_t user_context; /**< @internal @brief Temporary buffer for CC310 internal storage */ +} nrf_crypto_backend_cc310_sign_context_t; + + +/** @internal @brief Common structure holding context for ECDSA verify. + */ +typedef union +{ + CRYS_ECDSA_VerifyUserContext_t user_context; /**< @internal @brief Temporary buffer for CC310 internal storage */ + CRYS_ECPKI_BUILD_TempData_t key_build_temp_data; /**< @internal @brief Temporary buffer for CC310 public key build */ +} nrf_crypto_backend_cc310_verify_context_t; + + +/** @internal See @ref nrf_crypto_backend_ecdsa_sign_fn_t. + */ +ret_code_t nrf_crypto_backend_cc310_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature); + + +/** @internal See @ref nrf_crypto_backend_ecdsa_verify_fn_t. + */ +ret_code_t nrf_crypto_backend_cc310_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1) +#define NRF_CRYPTO_BACKEND_SECP160R1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP160R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp160r1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp160r1_verify_context_t; +#define nrf_crypto_backend_secp160r1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp160r1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2) +#define NRF_CRYPTO_BACKEND_SECP160R2_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP160R2_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp160r2_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp160r2_verify_context_t; +#define nrf_crypto_backend_secp160r2_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp160r2_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1) +#define NRF_CRYPTO_BACKEND_SECP192R1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP192R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp192r1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp192r1_verify_context_t; +#define nrf_crypto_backend_secp192r1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp192r1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1) +#define NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp224r1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp224r1_verify_context_t; +#define nrf_crypto_backend_secp224r1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp224r1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1) +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp256r1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp256r1_verify_context_t; +#define nrf_crypto_backend_secp256r1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp256r1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1) +#define NRF_CRYPTO_BACKEND_SECP384R1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP384R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp384r1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp384r1_verify_context_t; +#define nrf_crypto_backend_secp384r1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp384r1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1) +#define NRF_CRYPTO_BACKEND_SECP521R1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP521R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp521r1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp521r1_verify_context_t; +#define nrf_crypto_backend_secp521r1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp521r1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1) +#define NRF_CRYPTO_BACKEND_SECP160K1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP160K1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp160k1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp160k1_verify_context_t; +#define nrf_crypto_backend_secp160k1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp160k1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1) +#define NRF_CRYPTO_BACKEND_SECP192K1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP192K1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp192k1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp192k1_verify_context_t; +#define nrf_crypto_backend_secp192k1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp192k1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1) +#define NRF_CRYPTO_BACKEND_SECP224K1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP224K1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp224k1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp224k1_verify_context_t; +#define nrf_crypto_backend_secp224k1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp224k1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1) +#define NRF_CRYPTO_BACKEND_SECP256K1_SIGN_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_sign_context_t) +#define NRF_CRYPTO_BACKEND_SECP256K1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_cc310_verify_context_t) +typedef nrf_crypto_backend_cc310_sign_context_t nrf_crypto_backend_secp256k1_sign_context_t; +typedef nrf_crypto_backend_cc310_verify_context_t nrf_crypto_backend_secp256k1_verify_context_t; +#define nrf_crypto_backend_secp256k1_sign nrf_crypto_backend_cc310_sign +#define nrf_crypto_backend_secp256k1_verify nrf_crypto_backend_cc310_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519) +// Curve25519 is not designed for ECDSA +#define NRF_CRYPTO_BACKEND_CURVE25519_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_curve25519_sign_context_t; +typedef uint32_t nrf_crypto_backend_curve25519_verify_context_t; +#define nrf_crypto_backend_curve25519_sign NULL +#define nrf_crypto_backend_curve25519_verify NULL +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#endif // CC310_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.c new file mode 100644 index 0000000..0b37903 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.c @@ -0,0 +1,142 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + +#include +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_eddsa.h" +#include "cc310_backend_ecc.h" +#include "cc310_backend_shared.h" +#include "cc310_backend_mutex.h" +#include "crys_ec_edw_api.h" +#include "crys_ec_mont_edw_error.h" + + +ret_code_t nrf_crypto_backend_ed25519_sign( + void * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_message, + size_t message_size, + uint8_t * p_signature) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + size_t signature_size = 2 * CRYS_ECEDW_ORD_SIZE_IN_BYTES; + + nrf_crypto_backend_cc310_ed25519_context_t * p_ctx = + (nrf_crypto_backend_cc310_ed25519_context_t *)p_context; + + nrf_crypto_backend_ed25519_private_key_t * p_prv = + (nrf_crypto_backend_ed25519_private_key_t *)p_private_key; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECEDW_Sign(p_signature, + &signature_size, + p_message, + message_size, + p_prv->key, + sizeof(p_prv->key), + &p_ctx->temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + + return result; +} + +ret_code_t nrf_crypto_backend_ed25519_verify( + void * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_message, + size_t message_size, + uint8_t const * p_signature) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + + nrf_crypto_backend_cc310_ed25519_context_t * p_ctx = + (nrf_crypto_backend_cc310_ed25519_context_t *)p_context; + + nrf_crypto_backend_ed25519_public_key_t * p_pub = + (nrf_crypto_backend_ed25519_public_key_t *)p_public_key; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + crys_error = CRYS_ECEDW_Verify(p_signature, + 2 * CRYS_ECEDW_ORD_SIZE_IN_BYTES, + p_pub->key, + CRYS_ECEDW_ORD_SIZE_IN_BYTES, + (uint8_t *)p_message, + message_size, + &p_ctx->temp_data); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = nrf_crypto_backend_cc310_ecc_error_convert(crys_error); + + return result; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.h new file mode 100644 index 0000000..8378daf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_eddsa.h @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_EDDSA_H__ +#define CC310_BACKEND_EDDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + +#include +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_eddsa_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_BACKEND_ED25519_SIGN_CONTEXT_SIZE sizeof(nrf_crypto_backend_cc310_ed25519_context_t) +#define NRF_CRYPTO_BACKEND_ED25519_VERIFY_CONTEXT_SIZE sizeof(nrf_crypto_backend_cc310_ed25519_context_t) +typedef nrf_crypto_backend_cc310_ed25519_context_t nrf_crypto_backend_ed25519_sign_context_t; +typedef nrf_crypto_backend_cc310_ed25519_context_t nrf_crypto_backend_ed25519_verify_context_t; + +#ifdef __cplusplus +} +#endif + + +#endif // #if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_ECC_ED25519) + +#endif // CC310_BACKEND_EDDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.c new file mode 100644 index 0000000..cb218ce --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.c @@ -0,0 +1,311 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "nrf.h" +#include "cc310_backend_hash.h" +#include "crys_hash.h" +#include "crys_hash_error.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_hash_shared.h" +#include "sdk_macros.h" +#include "nrf_log.h" +#include "nrf_assert.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_shared.h" +#include + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA256) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA512) + +static ret_code_t hash_result_get(CRYSError_t error) +{ + ret_code_t ret_val; + + switch (error) + { + case CRYS_OK: + ret_val = NRF_SUCCESS; + break; + + case CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NULL; + break; + + case CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + case CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + break; + + // May be added to specialized errors for hash. + case CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + + case CRYS_HASH_IS_NOT_SUPPORTED: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA256) + +static ret_code_t cc310_backend_hash_sha256_init(void * const p_context) +{ + uint32_t ret_val; + CRYSError_t crys_error; + CRYS_HASH_OperationMode_t hash_mode = CRYS_HASH_SHA256_mode; + + // No parameter testing on this level. + // This has been done on upper level. + + CRYS_HASHUserContext_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + crys_error = CRYS_HASH_Init(p_backend_context, hash_mode); + + ret_val = hash_result_get(crys_error); + + return ret_val; +} + + +static ret_code_t cc310_backend_hash_sha256_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + ret_code_t ret_val; + CRYSError_t crys_error; + bool mutex_locked; + size_t cur_len; + size_t len_left = size; + uint8_t const * p_cur = p_data; + + // Limited parameter testing on this level. + // This has been done on upper level. + + CRYS_HASHUserContext_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + // Data in flash could lead to silently calculating wrong Hash. + VERIFY_TRUE(nrfx_is_in_ram(p_data), NRF_ERROR_CRYPTO_INPUT_LOCATION); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + // If the input is larger than CC310_MAX_LENGTH_DMA_OPERATIONS, split into smaller + do + { + cur_len = (len_left > CC310_MAX_LENGTH_DMA_OPERATIONS) ? + CC310_MAX_LENGTH_DMA_OPERATIONS : len_left; + + crys_error = CRYS_HASH_Update(p_backend_context, (uint8_t *)p_cur, cur_len); + + len_left -= cur_len; + p_cur += cur_len; + + } while (crys_error == CRYS_OK && len_left > 0); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = hash_result_get(crys_error); + + + return ret_val; +} + + +static ret_code_t cc310_backend_hash_sha256_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + ret_code_t ret_val; + CRYSError_t crys_error; + bool mutex_locked; + CRYS_HASH_Result_t * p_int_digest = (CRYS_HASH_Result_t *)p_digest; + + // Limited parameter testing on this level. + // This has been done on upper level. + + CRYS_HASHUserContext_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t * )p_context)->context); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + // Do the hash finalize calculation + cc310_backend_enable(); + + crys_error = CRYS_HASH_Finish(p_backend_context, *p_int_digest); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = hash_result_get(crys_error); + if (ret_val == NRF_SUCCESS) + { + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA256; + } + + return ret_val; +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info = +{ + .init_fn = cc310_backend_hash_sha256_init, + .update_fn = cc310_backend_hash_sha256_update, + .finalize_fn = cc310_backend_hash_sha256_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_hash_sha256_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA256 +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA256) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA512) + +// SHA-512 does not use CC310 hardware and therefore will not use a mutex lock + +static ret_code_t cc310_backend_hash_sha512_init(void * p_context) +{ + uint32_t ret_val; + CRYSError_t crys_error; + CRYS_HASH_OperationMode_t hash_mode = CRYS_HASH_SHA512_mode; + + // No parameter testing on this level. + // This has been done on upper level. + + CRYS_HASHUserContext_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t * ) p_context)->context); + + crys_error = CRYS_HASH_Init(p_backend_context, hash_mode); + ret_val = hash_result_get(crys_error); + + return ret_val; +} + + +static ret_code_t cc310_backend_hash_sha512_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + ret_code_t ret_val; + CRYSError_t crys_error; + + // Limited parameter testing on this level. + // This has been done on upper level. + + CRYS_HASHUserContext_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + // Data in flash could lead to silently calculating wrong Hash. + VERIFY_TRUE(nrfx_is_in_ram(p_data), NRF_ERROR_CRYPTO_INPUT_LOCATION); + + crys_error = CRYS_HASH_Update(p_backend_context, (uint8_t *)p_data, size); + + ret_val = hash_result_get(crys_error); + + return ret_val; +} + + +static ret_code_t cc310_backend_hash_sha512_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + ret_code_t ret_val; + CRYSError_t crys_error; + CRYS_HASH_Result_t * p_int_digest = (CRYS_HASH_Result_t *)p_digest; + + // Limited parameter testing on this level. + // This has been done on upper level. + + CRYS_HASHUserContext_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *) p_context)->context); + + crys_error = CRYS_HASH_Finish(p_backend_context, *p_int_digest); + ret_val = hash_result_get(crys_error); + + if (ret_val == NRF_SUCCESS) + { + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA512; + } + + return ret_val; +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha512_info = +{ + .init_fn = cc310_backend_hash_sha512_init, + .update_fn = cc310_backend_hash_sha512_update, + .finalize_fn = cc310_backend_hash_sha512_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA512, + .context_size = sizeof(nrf_crypto_backend_hash_sha512_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA512 +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA512) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA256) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA512) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && #if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.h new file mode 100644 index 0000000..f6b274f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hash.h @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_HASH_H__ +#define CC310_BACKEND_HASH_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_hash nrf_crypto CC310 backend hash + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief Hash functionality provided by the nrf_crypto CC310 backend. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "sdk_errors.h" +#include "nrf_crypto_hash_shared.h" +#include "crys_hash.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA256) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Flag that SHA-256 is enabled in backend +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA256) +#error "Duplicate definition of SHA-256. More than one backend enabled"); +#endif +#define NRF_CRYPTO_HASH_SHA256_ENABLED 1 + + +/**@internal @brief nrf_crypto_hash context for SHA-256 in nrf_crypto CC310 backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + CRYS_HASHUserContext_t context; /**< Hash context internal to CC310. */ +} nrf_crypto_backend_hash_sha256_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA512) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Duplicate backend enabled test for SHA-512 +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA512) +#error "Duplicate definition of SHA-512. More than one backend enabled"); +#endif + +// Flag that SHA-512 is enabled in backend +#define NRF_CRYPTO_HASH_SHA512_ENABLED 1 + + +/**@internal @brief nrf_crypto_hash context for SHA-512 in nrf_crypto CC310 backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + CRYS_HASHUserContext_t context; /**< Hash context internal to CC310. */ +} nrf_crypto_backend_hash_sha512_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HASH_SHA512) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +/**@} */ + +#endif // CC310_BACKEND_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.c new file mode 100644 index 0000000..fa1a261 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.c @@ -0,0 +1,272 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "sdk_common.h" +#include "nrf_log.h" +#include "nrf_crypto_hmac_shared.h" +#include "cc310_backend_hmac.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include +#include "crys_hmac.h" +#include "crys_hmac_defs.h" +#include "crys_hmac_error.h" +#include "crys_hash.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) + +static ret_code_t result_get(CRYSError_t err_code) +{ + ret_code_t ret_val; + + switch (err_code) + { + case CRYS_OK: + ret_val = NRF_SUCCESS; + break; + + case CRYS_HMAC_INVALID_USER_CONTEXT_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NULL; + break; + + case CRYS_HMAC_USER_CONTEXT_CORRUPTED_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + break; + + case CRYS_HMAC_DATA_IN_POINTER_INVALID_ERROR: + case CRYS_HMAC_INVALID_KEY_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_NULL; + break; + + case CRYS_HMAC_INVALID_RESULT_BUFFER_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_NULL; + break; + + case CRYS_HMAC_ILLEGAL_PARAMS_ERROR: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + case CRYS_HMAC_UNVALID_KEY_SIZE_ERROR: + case CRYS_HMAC_DATA_SIZE_ILLEGAL: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case CRYS_HMAC_ILLEGAL_OPERATION_MODE_ERROR: + case CRYS_HMAC_LAST_BLOCK_ALREADY_PROCESSED_ERROR: + case CRYS_HMAC_IS_NOT_SUPPORTED: + case CRYS_HMAC_CTX_SIZES_ERROR: + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + return ret_val; +} + + +static ret_code_t cc310_backend_hmac_init(void * const p_context, + uint8_t const * p_key, + size_t key_size) +{ + CRYSError_t err_code; + CRYS_HASH_OperationMode_t hash_mode; + ret_code_t ret_val; + bool mutex_locked; + + + nrf_crypto_backend_cc310_hmac_context_t * p_ctx = + (nrf_crypto_backend_cc310_hmac_context_t *)p_context; + + switch (p_ctx->header.p_info->type) + { + case NRF_CRYPTO_HMAC_SHA256_TYPE: + { + hash_mode = CRYS_HASH_SHA256_mode; + } break; + case NRF_CRYPTO_HMAC_SHA512_TYPE: + { + hash_mode = CRYS_HASH_SHA512_mode; + } break; + default: + { + NRF_LOG_ERROR("Hash algorithm not supported by CC310 backend wrapper"); + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + } + } + + // Key in flash could lead to silently calculating wrong HMAC. + VERIFY_TRUE(nrfx_is_in_ram(p_key), NRF_ERROR_CRYPTO_INPUT_LOCATION); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + err_code = CRYS_HMAC_Init(&p_ctx->crys_context, hash_mode, (uint8_t *)p_key, key_size); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = result_get(err_code); + + return ret_val; +} + + +static ret_code_t cc310_backend_hmac_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + CRYSError_t err_code; + ret_code_t ret_val; + bool mutex_locked; + size_t cur_len; + size_t len_left = size; + uint8_t const * p_cur = p_data; + + nrf_crypto_backend_cc310_hmac_context_t * p_ctx = + (nrf_crypto_backend_cc310_hmac_context_t *)p_context; + + // Data in flash could lead to silently calculating wrong HMAC. + VERIFY_TRUE(nrfx_is_in_ram(p_data), NRF_ERROR_CRYPTO_INPUT_LOCATION); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + // If the input is larger than CC310_MAX_LENGTH_DMA_OPERATIONS, split into smaller + do + { + cur_len = (len_left > CC310_MAX_LENGTH_DMA_OPERATIONS) ? + CC310_MAX_LENGTH_DMA_OPERATIONS : len_left; + + err_code = CRYS_HMAC_Update(&p_ctx->crys_context, (uint8_t *)p_cur, cur_len); + + len_left -= cur_len; + p_cur += cur_len; + + } while (err_code == CRYS_OK && len_left > 0); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = result_get(err_code); + + return ret_val; +} + + +static ret_code_t cc310_backend_hmac_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_size) +{ + CRYSError_t err_code; + ret_code_t ret_val; + bool mutex_locked; + CRYS_HASH_Result_t * p_int_digest = (CRYS_HASH_Result_t *)p_digest; + + nrf_crypto_backend_cc310_hmac_context_t * p_ctx = + (nrf_crypto_backend_cc310_hmac_context_t *)p_context; + + // Set the digest length to 0 so that this is used in case of any error. + *p_size = 0; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + err_code = CRYS_HMAC_Finish(&p_ctx->crys_context, *p_int_digest); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = result_get(err_code); + if (err_code != NRF_SUCCESS) + { + return ret_val; + } + + *p_size = p_ctx->header.p_info->digest_size; + + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) + +// Information structure for HMAC SHA256 using CC310 backend. +const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha256_info = +{ + .init_fn = cc310_backend_hmac_init, + .update_fn = cc310_backend_hmac_update, + .finalize_fn = cc310_backend_hmac_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_hmac_sha256_context_t), + .type = NRF_CRYPTO_HMAC_SHA256_TYPE, +}; + +#endif // NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) + +// Information structure for HMAC SHA512 using CC310 backend. +const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha512_info = +{ + .init_fn = cc310_backend_hmac_init, + .update_fn = cc310_backend_hmac_update, + .finalize_fn = cc310_backend_hmac_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA512, + .context_size = sizeof(nrf_crypto_backend_hmac_sha512_context_t), + .type = NRF_CRYPTO_HMAC_SHA512_TYPE, +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.h new file mode 100644 index 0000000..b6b0d90 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_hmac.h @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_HMAC_H__ +#define CC310_BACKEND_HMAC_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_hmac CC310 backend for HMAC + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief Backend wrapper for CryptoCell (CC310). None of these types should be used directly by the + * application. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) && \ + ( NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) ) + +#include "nrf_crypto_hmac_shared.h" +#include "crys_hmac.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#undef NRF_CRYPTO_HMAC_ENABLED +#define NRF_CRYPTO_HMAC_ENABLED 1 + + +/** + * @internal @brief Internal context object used by the CC310 backend wrapper. + * + * @details The same type is used for all variants (hash types). + * + * @note This should never be used directly. Use @ref nrf_crypto_backend_hmac_sha256_context_t or + * @ref nrf_crypto_backend_hmac_sha512_context_t instead. + */ +typedef struct +{ + nrf_crypto_hmac_internal_context_t header; //!< Internal nrf_crypto_hmac context header. + CRYS_HMACUserContext_t crys_context; //!< CC310 context object. +} nrf_crypto_backend_cc310_hmac_context_t; + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC_SHA256) +#error "Duplicate definition of HMAC SHA-256. More than one backend enabled" +#endif // NRF_CRYPTO_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_HMAC_SHA256_ENABLED 1 + +/** + * @internal @brief Context for HMAC SHA256 using CC310 backend. + */ +typedef nrf_crypto_backend_cc310_hmac_context_t nrf_crypto_backend_hmac_sha256_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC_SHA512) +#error "Duplicate definition of HMAC SHA-512. More than one backend enabled" +#endif // NRF_CRYPTO_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_HMAC_SHA512_ENABLED 1 + +/** + * @internal @brief Context for HMAC SHA512 using CC310 backend. + */ +typedef nrf_crypto_backend_cc310_hmac_context_t nrf_crypto_backend_hmac_sha512_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) && ( NRF_MODULE_ENABLED((NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512) ) + +/**@} */ + +#endif // CC310_BACKEND_HMAC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_init.c similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_init.c index 0251b61..8a87e49 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_init.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,38 +35,27 @@ * 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(NRF_CRYPTO) -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) +#include "nrf.h" #include "nrf_crypto_init.h" -#include "cc310_lib_init.h" -#include "cc310_lib_shared.h" -#include "crys_rnd.h" +#include "cc310_backend_shared.h" #include "sns_silib.h" +#include "cc310_backend_mutex.h" +#include "nrf_crypto_rng.h" -// Temporary setting this before real handling of memory management -CRYS_RND_Context_t g_rnd_context; - -// Temporary setting this before real handling of memory management -CRYS_RND_WorkBuff_t g_rnd_work_buffer; - - -/**@brief Pointer to contigious memory holding random number context data - * - * @note The data pointed to must be available in the duration of the usage of Cryptocell api functions. +/**@internal @brief Function to enable CC310 (in HW) */ -CRYS_RND_Context_t * gp_rnd_context = &g_rnd_context; +void cc310_backend_enable(void); -/**@brief Pointer to contigious memory for the rnd initialization workspace - * - * @note The Data pointed to must be available in the duration of the initialization of the Cryptocell - * or during reseeding of rng. + +/**@internal @brief Function to disable CC310 (in HW) */ -CRYS_RND_WorkBuff_t * gp_rnd_work_buffer = &g_rnd_work_buffer; +void cc310_backend_disable(void); static uint32_t init_result_get(uint32_t crys_error) { @@ -85,65 +74,78 @@ static uint32_t init_result_get(uint32_t crys_error) return ret_val; } - -static uint32_t uninit_result_get(uint32_t crys_error) +static ret_code_t cc310_backend_init(void) { - uint32_t ret_val; + uint32_t ret_val; + CRYSError_t crys_error; - switch (crys_error) - { - default: - ret_val = NRF_ERROR_INTERNAL; - } - - return ret_val; -} + cc310_backend_mutex_init(); - -uint32_t nrf_crypto_init(void) -{ - //nrf_crypto_init_info_h * p_init_info - uint32_t ret_val; - CRYSError_t crys_error; - - // Initialize the cryptocell by setting hardware register + // Enable the CC310 HW. NRF_CRYPTOCELL->ENABLE = 1; // Initialize the CC310 run-time library - crys_error = SaSi_LibInit(gp_rnd_context, gp_rnd_work_buffer); + crys_error = SaSi_LibInit(); + + // Shut down CC310 after initialization. + NRF_CRYPTOCELL->ENABLE = 0; + ret_val = init_result_get(crys_error); - return ret_val; -} + VERIFY_SUCCESS(ret_val); +#if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) -uint32_t nrf_crypto_uninit(void) -{ - uint32_t ret_val; - CRYSError_t crys_error; + ret_val = nrf_crypto_rng_init(NULL, NULL); + VERIFY_SUCCESS(ret_val); - // Check that the library has been initialized. If not, exit. - if (gp_rnd_context == NULL) - { - return NRF_SUCCESS; - } +#elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0) - crys_error = SaSi_LibFini(gp_rnd_context); + // Do nothing - // Set rnd context to zero to signal that the library is uninitialized - gp_rnd_context = NULL; +#else + + #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_CRYPTO_RNG_AUTO_INIT_ENABLED - ret_val = uninit_result_get(crys_error); return ret_val; } -bool nrf_crypto_is_initialized(void) +static ret_code_t cc310_backend_uninit(void) { - return (gp_rnd_context != NULL); -} +#if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) + uint32_t ret_val; + ret_val = nrf_crypto_rng_init(NULL, NULL); + VERIFY_SUCCESS(ret_val); + +#elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0) + + // Do nothing + +#else -#endif // NRF_CRYPTO_BACKEND_CC310_LIB + #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_CRYPTO_RNG_AUTO_INIT_ENABLED + + // Initialize the CC310 HW to do shutdown. + NRF_CRYPTOCELL->ENABLE = 1; -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + SaSi_LibFini(); + + // Shut down CC310 after shutdown. + NRF_CRYPTOCELL->ENABLE = 0; + + return NRF_SUCCESS; +} + + +CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const cc310_backend) = +{ + .init_fn = cc310_backend_init, + .uninit_fn = cc310_backend_uninit, +}; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.c similarity index 87% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.c index 4df4bbd..aba244c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,20 +35,19 @@ * 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" +#include #if NRF_MODULE_ENABLED(NRF_CRYPTO) -#include "nrf_crypto_init.h" - -#if NRF_CRYPTO_BACKEND_CC310_LIB -#include "cc310_lib_init.h" -#endif +#include +#include "cc310_backend_mutex.h" -#if NRF_CRYPTO_BACKEND_MICRO_ECC -#include "micro_ecc_lib_init.h" -#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) +nrf_mtx_t g_cc310_mutex; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) #endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.h new file mode 100644 index 0000000..ed5a244 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_mutex.h @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_MUTEX_H__ +#define CC310_BACKEND_MUTEX_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_mutex nrf_crypto CC310 backend mutex. + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief Mutex control for the nrf_crypto CC310 backend. + */ + +#include "sdk_config.h" +#include "nrf_mtx.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#ifdef __cplusplus +extern "C" { +#endif + +extern nrf_mtx_t g_cc310_mutex; + +__STATIC_INLINE void cc310_backend_mutex_init(void); +__STATIC_INLINE bool cc310_backend_mutex_trylock(void); +__STATIC_INLINE void cc310_backend_mutex_unlock(void); + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION +/**@internal @brief Function initializing CC310 mutex. + * + * This function _must_ be called before other mutex operations. + */ +__STATIC_INLINE void cc310_backend_mutex_init(void) +{ + nrf_mtx_init(&g_cc310_mutex); +} + +/**@internal @brief Function try to lock a CC310 mutex. + * + * @return true if lock was acquired, false if not. + */ +__STATIC_INLINE bool cc310_backend_mutex_trylock(void) +{ + return nrf_mtx_trylock(&g_cc310_mutex); +} + + +/**@internal @brief Unlock a CC310 mutex. + * + * This function _must_ only be called when holding the lock. Unlocking a mutex which you do not + * hold will give undefined behavior. + * + */ +__STATIC_INLINE void cc310_backend_mutex_unlock(void) +{ + nrf_mtx_unlock(&g_cc310_mutex); +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +/** @} */ + +#endif // CC310_BACKEND_MUTEX_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.c new file mode 100644 index 0000000..7ce4827 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.c @@ -0,0 +1,272 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_RNG) + +#include "nrf_crypto_error.h" +#include "nrf_log.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_rng.h" +#include "crys_rnd.h" +#include "crys_rnd_error.h" +#include "cc310_backend_shared.h" + +static ret_code_t result_get(CRYSError_t err_code) +{ + ret_code_t ret_val; + + switch (err_code) + { + case CRYS_OK: + ret_val = NRF_SUCCESS; + break; + + case CRYS_RND_ILLEGAL_PARAMETER_ERROR: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + case CRYS_RND_INIT_FAILED: + case CRYS_RND_STARTUP_FAILED: + case CRYS_RND_INSTANTIATION_ERROR: + ret_val = NRF_ERROR_CRYPTO_RNG_INIT_FAILED; + break; + + case CRYS_RND_IS_NOT_SUPPORTED: + case CRYS_RND_CAN_NOT_GENERATE_RAND_IN_RANGE: + case CRYS_RND_TRNG_KAT_NOT_SUPPORTED_ERROR: + case CRYS_RND_SRAM_NOT_SUPPORTED_ERROR: + case CRYS_RND_OPERATION_IS_NOT_SUPPORTED_ERROR: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + case CRYS_RND_DATA_OUT_POINTER_INVALID_ERROR: + case CRYS_RND_VECTOR_OUT_PTR_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_NULL; + break; + + case CRYS_RND_ADDITIONAL_INPUT_BUFFER_NULL: + case CRYS_RND_WORK_BUFFER_PTR_INVALID_ERROR: + case CRYS_RND_ILLEGAL_DATA_PTR_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_NULL; + break; + + case CRYS_RND_DATA_SIZE_OVERFLOW_ERROR: + case CRYS_RND_ADDITIONAL_INPUT_SIZE_ERROR: + case CRYS_RND_ILLEGAL_DATA_SIZE_ERROR: + case CRYS_RND_MAX_VECTOR_IS_TOO_SMALL_ERROR: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case CRYS_RND_ILLEGAL_AES_KEY_SIZE_ERROR: + case CRYS_RND_VECTOR_OUT_SIZE_ERROR: + case CRYS_RND_VECTOR_SIZE_ERROR: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + break; + + case CRYS_RND_CONTEXT_PTR_INVALID_ERROR: + case CRYS_RND_STATE_PTR_INVALID_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NULL; + break; + + case CRYS_RND_INSTANTIATION_NOT_DONE_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + break; + + case CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR: + ret_val = NRF_ERROR_CRYPTO_RNG_RESEED_REQUIRED; + break; + + case CRYS_RND_CPRNG_TEST_FAIL_ERROR: + case CRYS_RND_TRNG_LOSS_SAMPLES_ERROR: + case CRYS_RND_TRNG_TIME_EXCEED_ERROR: + case CRYS_RND_TRNG_LOSS_SAMPLES_AND_TIME_EXCEED_ERROR: + case CRYS_RND_IS_KAT_MODE_ERROR: + case CRYS_RND_STATE_VALIDATION_TAG_ERROR: + case CRYS_RND_GEN_VECTOR_FUNC_ERROR: + case CRYS_RND_TRNG_ERRORS_ERROR: + case CRYS_RND_KAT_DATA_PARAMS_ERROR: + case CRYS_RND_AES_ERROR: + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + return ret_val; +} + + +ret_code_t nrf_crypto_rng_backend_init(void * const p_context, + void * const p_temp_buffer) +{ + bool mutex_locked; + CRYSError_t err_code; + ret_code_t ret_val; + CRYS_RND_WorkBuff_t * p_work_buffer = (CRYS_RND_WorkBuff_t *)p_temp_buffer; + nrf_crypto_backend_rng_context_t * p_ctx = (nrf_crypto_backend_rng_context_t *)p_context; + + // Save time by not reinitializing an already valid CC310 RNG context. + // (Useful for example in case the context was stored in retained memory during system OFF.) + if (p_ctx->header.init_value == NRF_CRYPTO_RNG_CONTEXT_INIT_MAGIC_VALUE) + { + return NRF_SUCCESS; + } + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + err_code = CRYS_RndInit(&p_ctx->crys_rnd_state, p_work_buffer); + ret_val = result_get(err_code); + + cc310_backend_disable(); + + cc310_backend_mutex_unlock(); + + return ret_val; +} + + +ret_code_t nrf_crypto_rng_backend_uninit(void * const p_context) +{ + bool mutex_locked; + CRYSError_t err_code; + ret_code_t ret_val; + CRYS_RND_State_t * p_crys_rnd_state = + &((nrf_crypto_backend_rng_context_t *)p_context)->crys_rnd_state; + + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + err_code = CRYS_RND_UnInstantiation(p_crys_rnd_state); + + cc310_backend_disable(); + + ret_val = result_get(err_code); + + cc310_backend_mutex_unlock(); + + return ret_val; +} + + +ret_code_t nrf_crypto_rng_backend_vector_generate(void * const p_context, + uint8_t * const p_target, + size_t size, + bool use_mutex) +{ + bool mutex_locked; + CRYSError_t err_code; + ret_code_t ret_val; + CRYS_RND_State_t * p_crys_rnd_state = + &((nrf_crypto_backend_rng_context_t *)p_context)->crys_rnd_state; + + if (use_mutex) + { + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + } + + cc310_backend_enable(); + + err_code = CRYS_RND_GenerateVector(p_crys_rnd_state, size, p_target); + + cc310_backend_disable(); + + ret_val = result_get(err_code); + + if (use_mutex) + { + cc310_backend_mutex_unlock(); + } + + return ret_val; +} + + +ret_code_t nrf_crypto_rng_backend_reseed(void * const p_context, + void * p_temp_buffer, + uint8_t * p_input_data, + size_t size) +{ + bool mutex_locked; + CRYSError_t err_code; + ret_code_t ret_val = NRF_SUCCESS; + CRYS_RND_WorkBuff_t * p_work_buffer = (CRYS_RND_WorkBuff_t *)p_temp_buffer; + CRYS_RND_State_t * p_crys_rnd_state = + &((nrf_crypto_backend_rng_context_t *)p_context)->crys_rnd_state; + + VERIFY_TRUE(size <= CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS, NRF_ERROR_CRYPTO_INPUT_LENGTH); + VERIFY_TRUE((size & 0x3) == 0, NRF_ERROR_CRYPTO_INTERNAL); + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_backend_enable(); + + if (size > 0) + { + err_code = CRYS_RND_AddAdditionalInput(p_crys_rnd_state, p_input_data, size); + ret_val = result_get(err_code); + if (ret_val != NRF_SUCCESS) + { + goto exit; + } + } + + err_code = CRYS_RND_Reseeding(p_crys_rnd_state, p_work_buffer); + ret_val = result_get(err_code); + +exit: + cc310_backend_disable(); + cc310_backend_mutex_unlock(); + return ret_val; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_RNG) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.h new file mode 100644 index 0000000..3fdd4cc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_rng.h @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BACKEND_RNG_H__ +#define CC310_BACKEND_RNG_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_backend_rng nRF Crypto CC310 RNG backend + * @{ + * @ingroup nrf_crypto_cc310_backend + * + * @brief RNG functionality provided by the nrf_crypto CC310 backend. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_RNG) + +#include "nrf_crypto_rng_shared.h" +#include "crys_rnd.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#error "More than one RNG backend enabled." +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#define NRF_CRYPTO_RNG_ENABLED 1 + + +/** + * @internal @brief Internal context for CC310 RNG. + */ +typedef struct +{ + nrf_crypto_rng_internal_context_t header; //!< Internal common context header. + CRYS_RND_State_t crys_rnd_state; //!< CC310 RNG context +} nrf_crypto_backend_rng_context_t; + + +/** + * @internal @brief Temporary work buffer needed during initialization of the CC310 backend. + */ +typedef CRYS_RND_WorkBuff_t nrf_crypto_backend_rng_temp_buffer_t; + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_RNG) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +/**@} */ + +#endif // CC310_BACKEND_RNG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.c new file mode 100644 index 0000000..50fd10f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.c @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2017 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) + +#include "nrf.h" +#include "cc310_backend_shared.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_rng.h" +#include "crys_rnd_error.h" +#include "nrf_crypto_shared.h" +#include "cc310_backend_shared.h" + + +static uint32_t m_use_count = 0; + +void cc310_backend_enable(void) +{ + m_use_count++; + + if (m_use_count == 1) + { + // Enable the CryptoCell hardware + NRF_CRYPTOCELL->ENABLE = 1; + +#if defined(NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED == 1) + + // Enable the CryptoCell IRQ + NVIC_EnableIRQ(CRYPTOCELL_IRQn); + +#elif defined(NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED == 0) + + // Do nothing + +#else + + #warning NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif + + } +} + +void cc310_backend_disable(void) +{ + m_use_count--; + + // If no more users. Disable HW/IRQ + if (m_use_count == 0) + { + // Disable the CryptoCell hardware + NRF_CRYPTOCELL->ENABLE = 0; + +#if defined(NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED == 1) + + // Disable the CryptoCell IRQ + NVIC_DisableIRQ(CRYPTOCELL_IRQn); + +#elif defined(NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED == 0) + + // Do nothing + +#else + + #warning NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif + + } +} + + +uint32_t nrf_crypto_backend_cc310_rng(void * p_state, uint16_t size, uint8_t * p_data) +{ +#if defined(NRF_CRYPTO_RNG_ENABLED) && (NRF_CRYPTO_RNG_ENABLED == 1) + + ret_code_t result = nrf_crypto_rng_vector_generate_no_mutex(p_data, (size_t)size); + if (result == NRF_SUCCESS) + { + return CRYS_OK; + } + else if (result == NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED) + { + return CRYS_RND_INSTANTIATION_NOT_DONE_ERROR; + } + else + { + return CRYS_RND_IS_NOT_SUPPORTED; + } + +#elif defined(NRF_CRYPTO_RNG_ENABLED) && (NRF_CRYPTO_RNG_ENABLED == 0) + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + +#else + + #warning NRF_CRYPTO_RNG_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_CRYPTO_RNG_ENABLED +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.h similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.h index 001e5ce..69b8ed6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_init.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310/cc310_backend_shared.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,52 +35,47 @@ * 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 NRF_CRYPTO_INIT_H__ -#define NRF_CRYPTO_INIT_H__ + +#ifndef CC310_BACKEND_SHARED_H__ +#define CC310_BACKEND_SHARED_H__ /** @file * - * @defgroup nrf_crypto_initialization Initialization. + * @defgroup nrf_crypto_cc310_backend_shared nrf_crypto CC310 backend shared * @{ - * @ingroup nrf_crypto + * @ingroup nrf_crypto_cc310_backend * - * @brief Provides nrf_crypto initialization related functions. + * @brief Shared functionality for the nrf_crypto CC310 backend. */ -#include -#include - #ifdef __cplusplus extern "C" { #endif -#include -#include "nrf_crypto_types.h" +/**@internal @brief Macro definition for largest possible input data on CC310 DMA. */ +#define CC310_MAX_LENGTH_DMA_OPERATIONS (0xFFFF) +#define CC310_MAX_LENGTH_DMA_AES_OPERATIONS (0xFFF0) -/**@brief Function for initializing the cryptography library. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypt backend. + +/**@internal @brief Function to enable CC310 (in HW) */ -uint32_t nrf_crypto_init(void); +void cc310_backend_enable(void); -/**@brief Function for uninitializing the cryptography library. - * - * @retval NRF_SUCCESS If unititialization was successful. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypt backend. +/**@internal @brief Function to disable CC310 (in HW) */ -uint32_t nrf_crypto_uninit(void); +void cc310_backend_disable(void); -/**@brief Function reporting if nrf_crypto has been initialized. - * - * @retval True If cryptographic library is initialized. - * @retval False If cryptographic library isn't initialized. +/**@internal @brief Function to pass to CC310 library API as random number generator. It uses + * nrf_crypto libary frontend API to generate random number. + * @param[in,out] p_state Unused. Required by CC310 library API. + * @param[in] size Number of bytes in generated vector. + * @param[out] p_data Place where generated bytes will be written. */ -bool nrf_crypto_is_initialized(void); +uint32_t nrf_crypto_backend_cc310_rng(void * p_state, uint16_t size, uint8_t * p_data); #ifdef __cplusplus @@ -89,4 +84,4 @@ bool nrf_crypto_is_initialized(void); /**@} */ -#endif // NRF_CRYPTO_INIT_H__ +#endif // CC310_BACKEND_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.c new file mode 100644 index 0000000..d99fecf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.c @@ -0,0 +1,165 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include + +#include "nrf_crypto_mem.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_shared.h" +#include "cc310_bl_backend_ecc.h" + + +#if defined(NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED) + +#error The configuration NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED was removed in SDK 15.1.0. Please see release notes for details on removing this error message. + +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + + +ret_code_t nrf_crypto_backend_secp224r1_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_secp224r1_public_key_t * p_pub = + (nrf_crypto_backend_secp224r1_public_key_t *)p_public_key; + + memcpy(&p_pub->public_key.x[0], + &p_raw_data[0], + NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE); + memcpy(&p_pub->public_key.y[0], + &p_raw_data[NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE], + NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_secp224r1_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_secp224r1_public_key_t const * p_pub = + (nrf_crypto_backend_secp224r1_public_key_t const *)p_public_key; + + memcpy(&p_raw_data[0], + &p_pub->public_key.x[0], + NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE); + memcpy(&p_raw_data[NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE], + &p_pub->public_key.y[0], + NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE); + + return NRF_SUCCESS; +} + + +nrf_crypto_ecc_curve_info_t const g_nrf_crypto_ecc_secp224r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp224r1_public_key_t), + .private_key_size = 0, + .curve_type = NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE, +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + + +ret_code_t nrf_crypto_backend_secp256r1_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + memcpy(&p_pub->public_key.x[0], + &p_raw_data[0], + NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE); + memcpy(&p_pub->public_key.y[0], + &p_raw_data[NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE], + NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_secp256r1_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_secp256r1_public_key_t const * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t const *)p_public_key; + + memcpy(&p_raw_data[0], + &p_pub->public_key.x[0], + NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE); + memcpy(&p_raw_data[NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE], + &p_pub->public_key.y[0], + NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE); + + return NRF_SUCCESS; +} + + +nrf_crypto_ecc_curve_info_t const g_nrf_crypto_ecc_secp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp256r1_public_key_t), + .private_key_size = 0, + .curve_type = NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE, +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.h new file mode 100644 index 0000000..c591dd8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.h @@ -0,0 +1,155 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BL_BACKEND_ECC_H__ +#define CC310_BL_BACKEND_ECC_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "nrf_crypto_ecc_shared.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) +#include "nrf_cc310_bl_ecdsa_verify_secp224r1.h" +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) +#include "nrf_cc310_bl_ecdsa_verify_secp256r1.h" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP224R1) +#error "More than one backend enabled for secp224r1 (NIST 224-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP224R1_ENABLED 1 + +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + nrf_cc310_bl_ecc_public_key_secp224r1_t public_key; /**< @internal @brief CC310_BL specific key representation */ +} nrf_crypto_backend_secp224r1_public_key_t; + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_secp224r1_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_secp224r1_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + +// Dummy and empty definitions for unused symbols +#define nrf_crypto_backend_secp224r1_key_pair_generate NULL +#define nrf_crypto_backend_secp224r1_public_key_calculate NULL +#define nrf_crypto_backend_secp224r1_private_key_from_raw NULL +#define nrf_crypto_backend_secp224r1_private_key_to_raw NULL +#define nrf_crypto_backend_secp224r1_private_key_free NULL +#define nrf_crypto_backend_secp224r1_public_key_free NULL + +#define NRF_CRYPTO_BACKEND_SECP224R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +typedef uint32_t nrf_crypto_backend_secp224r1_private_key_t; +typedef uint32_t nrf_crypto_backend_secp224r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp224r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256R1) +#error "More than one backend enabled for secp256r1 (NIST 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 + +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + nrf_cc310_bl_ecc_public_key_secp256r1_t public_key; /**< @internal @brief CC310_BL specific key representation */ +} nrf_crypto_backend_secp256r1_public_key_t; + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_secp256r1_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_secp256r1_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + +// Dummy and empty definitions for unused symbols +#define nrf_crypto_backend_secp256r1_key_pair_generate NULL +#define nrf_crypto_backend_secp256r1_public_key_calculate NULL +#define nrf_crypto_backend_secp256r1_private_key_from_raw NULL +#define nrf_crypto_backend_secp256r1_private_key_to_raw NULL +#define nrf_crypto_backend_secp256r1_private_key_free NULL +#define nrf_crypto_backend_secp256r1_public_key_free NULL + +#define NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +typedef uint32_t nrf_crypto_backend_secp256r1_private_key_t; +typedef uint32_t nrf_crypto_backend_secp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#endif // CC310_BL_BACKEND_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdh.h new file mode 100644 index 0000000..0d9c2f3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdh.h @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BL_BACKEND_ECDH_H__ +#define CC310_BL_BACKEND_ECDH_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) +#define nrf_crypto_backend_secp224r1_ecdh_compute NULL +typedef uint32_t nrf_crypto_backend_secp224r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP224R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) +#define nrf_crypto_backend_secp256r1_ecdh_compute NULL +typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#endif // CC310_BL_BACKEND_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.c new file mode 100644 index 0000000..84dd8ed --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.c @@ -0,0 +1,197 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + + +#if defined(NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED) + +#error The configuration NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED was removed in SDK 15.1.0. Please see release notes for details on removing this error message. + +#endif // defined(NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED) + + + +#include +#include "app_util.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_shared.h" +#include "cc310_bl_backend_ecdsa.h" +#include "cc310_bl_backend_shared.h" +#include "cc310_backend_mutex.h" +#include "crys_ecpki_error.h" + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + +static ret_code_t crys_error_to_ret_code(CRYSError_t crys_error) +{ + switch (crys_error) + { + case CRYS_OK: + return NRF_SUCCESS; + + case CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR: + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + + default: + break; + } + + return NRF_ERROR_CRYPTO_INTERNAL; +} + +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + +STATIC_ASSERT(offsetof(nrf_cc310_bl_ecc_signature_secp224r1_t, r) == 0, + "Offset of r in nrf_cc310_bl_ecc_signature_secp224r1_t is unexpected"); +STATIC_ASSERT(offsetof(nrf_cc310_bl_ecc_signature_secp224r1_t, s) == + NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE, + "Offset of s in nrf_cc310_bl_ecc_signature_secp224r1_t is unexpected"); + + +ret_code_t nrf_crypto_backend_secp224r1_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + + nrf_crypto_backend_secp224r1_verify_context_t * p_ctx = + (nrf_crypto_backend_secp224r1_verify_context_t *)p_context; + + nrf_crypto_backend_secp224r1_public_key_t * p_pub = + (nrf_crypto_backend_secp224r1_public_key_t *)p_public_key; + + p_ctx->user_context.init_val = NRF_CC310_BL_ECDSA_CONTEXT_INITIALIZED; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_bl_backend_enable(); + + crys_error = nrf_cc310_bl_ecdsa_verify_secp224r1( + &p_ctx->user_context, + &p_pub->public_key, + (nrf_cc310_bl_ecc_signature_secp224r1_t const *)p_signature, + p_data, + data_size); + + cc310_bl_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = crys_error_to_ret_code(crys_error); + + return result; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + + +STATIC_ASSERT(offsetof(nrf_cc310_bl_ecc_signature_secp256r1_t, r) == 0, + "Offset of r in nrf_cc310_bl_ecc_signature_secp256r1_t is unexpected"); + +STATIC_ASSERT(offsetof(nrf_cc310_bl_ecc_signature_secp256r1_t, s) == + NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + "Offset of s in nrf_cc310_bl_ecc_signature_secp256r1_t is unexpected"); + + +ret_code_t nrf_crypto_backend_secp256r1_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + ret_code_t result; + CRYSError_t crys_error; + bool mutex_locked; + + + nrf_crypto_backend_secp256r1_verify_context_t * p_ctx = + (nrf_crypto_backend_secp256r1_verify_context_t *)p_context; + + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + p_ctx->user_context.init_val = NRF_CC310_BL_ECDSA_CONTEXT_INITIALIZED; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_bl_backend_enable(); + + crys_error = nrf_cc310_bl_ecdsa_verify_secp256r1( + &p_ctx->user_context, + &p_pub->public_key, + (nrf_cc310_bl_ecc_signature_secp256r1_t const *)p_signature, + p_data, + data_size); + + cc310_bl_backend_disable(); + + cc310_backend_mutex_unlock(); + + result = crys_error_to_ret_code(crys_error); + + return result; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.h new file mode 100644 index 0000000..8b9c2a5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.h @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BL_BACKEND_ECDSA_H__ +#define CC310_BL_BACKEND_ECDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) +#include "nrf_cc310_bl_ecdsa_verify_secp224r1.h" +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) +#include "nrf_cc310_bl_ecdsa_verify_secp256r1.h" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + +/** @internal @brief Common structure holding context for ECDSA verify. + */ +typedef struct +{ + nrf_cc310_bl_ecdsa_verify_context_secp224r1_t user_context; /**< @internal @brief Temporary buffer for CC310_BL internal storage */ +} nrf_crypto_backend_secp224r1_verify_context_t; + +#define NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_secp224r1_verify_context_t) + +ret_code_t nrf_crypto_backend_secp224r1_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + +// Dummy and empty definitions for unused symbols +#define NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp224r1_sign_context_t; +#define nrf_crypto_backend_secp224r1_sign NULL + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + +/** @internal @brief Common structure holding context for ECDSA verify. + */ +typedef struct +{ + nrf_cc310_bl_ecdsa_verify_context_secp256r1_t user_context; /**< @internal @brief Temporary buffer for CC310_BL internal storage */ +} nrf_crypto_backend_secp256r1_verify_context_t; + +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE \ + sizeof(nrf_crypto_backend_secp256r1_verify_context_t) + +ret_code_t nrf_crypto_backend_secp256r1_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + +// Dummy and empty definitions for unused symbols +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp256r1_sign_context_t; +#define nrf_crypto_backend_secp256r1_sign NULL + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#endif // CC310_BL_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.c new file mode 100644 index 0000000..df19668 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.c @@ -0,0 +1,276 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "nrf.h" +#include "cc310_bl_backend_hash.h" +#include "cc310_bl_backend_shared.h" +#include "cc310_backend_mutex.h" +#include "cc310_backend_shared.h" +#include "nrf_cc310_bl_hash_sha256.h" +#include "crys_hash_error.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_shared.h" +#include "nrf_crypto_hash_shared.h" +#include "sdk_macros.h" +#include "nrf_log.h" +#include "nrf_assert.h" +#include + + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256) + + +#if defined(NRF_CRYPTO_BACKEND_CC310_BL_HASH_LITTLE_ENDIAN_DIGEST_ENABLED) + +#error The configuration NRF_CRYPTO_BACKEND_CC310_BL_HASH_LITTLE_ENDIAN_DIGEST_ENABLED was removed in SDK 15.1.0. Please see release notes for details on removing this error message. + +#endif // defined(NRF_CRYPTO_BACKEND_CC310_BL_HASH_LITTLE_ENDIAN_DIGEST_ENABLED) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER) + +__ALIGN(4) static uint8_t m_hash_buffer[NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE]; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER) + + +static ret_code_t hash_result_get(CRYSError_t error) +{ + ret_code_t ret_val; + + switch (error) + { + case CRYS_OK: + ret_val = NRF_SUCCESS; + break; + + case CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NULL; + break; + + case CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + case CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR: + ret_val = NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + break; + + // May be added to specialized errors for hash. + case CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + + case CRYS_HASH_IS_NOT_SUPPORTED: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + + return ret_val; +} + + +static ret_code_t cc310_bl_backend_hash_sha256_init(void * const p_context) +{ + uint32_t ret_val; + CRYSError_t crys_error; + + // Limited parameter testing on this level. + // This has been done on upper level. + + nrf_cc310_bl_hash_context_sha256_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + crys_error = nrf_cc310_bl_hash_sha256_init(p_backend_context); + + ret_val = hash_result_get(crys_error); + + return ret_val; +} + + +static uint32_t cc310_bl_backend_hash_sha256_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + ret_code_t ret_val; + CRYSError_t crys_error; + uint32_t cur_size; + uint32_t size_left; + uint8_t * p_cur; + bool mutex_locked; + + // Limited parameter testing on this level. + // This has been done on upper level. + + nrf_cc310_bl_hash_context_sha256_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + p_cur = (uint8_t *)p_data; + size_left = size; + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_bl_backend_enable(); + +#if defined (NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED == 1) + + do + { + // Copy a block from FLASH to RAM for use in CC310 + cur_size = (size_left > NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE) ? + NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE : size_left; + + // Copy from FLASH to ram + memcpy(m_hash_buffer, p_cur, cur_size); + + // Update the hash with current input. + crys_error = nrf_cc310_bl_hash_sha256_update(p_backend_context, m_hash_buffer, cur_size); + + size_left -= cur_size; + p_cur += cur_size; + + } while(crys_error == SASI_OK && size_left > 0); + +#elif defined(NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED == 0) + + // Verify that the data is in RAM (required for CC310 hashing) + VERIFY_TRUE(nrfx_is_in_ram(p_data), NRF_ERROR_CRYPTO_INPUT_LOCATION); + + do + { + // Get the largest block that can sent to the CC310 through DMA + cur_size = (size_left > CC310_MAX_LENGTH_DMA_OPERATIONS) ? + CC310_MAX_LENGTH_DMA_OPERATIONS : size_left; + + crys_error = nrf_cc310_bl_hash_sha256_update(p_backend_context, p_cur, cur_size); + + size_left -= cur_size; + p_cur += cur_size; + } while(crys_error == SASI_OK && size_left > 0); + +#else + + UNUSED_PARAMETER(p_backend_context); + UNUSED_PARAMETER(cur_size); + UNUSED_PARAMETER(size_left); + UNUSED_PARAMETER(p_cur); + + #warning NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif + + cc310_bl_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = hash_result_get(crys_error); + + return ret_val; +} + + +static uint32_t cc310_bl_backend_hash_sha256_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + ret_code_t ret_val; + CRYSError_t crys_error; + bool mutex_locked; + + // Limited parameter testing on this level. + // This has been done on upper level. + + nrf_cc310_bl_hash_context_sha256_t * const p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t * )p_context)->context); + + nrf_cc310_bl_hash_digest_sha256_t * p_int_digest + = (nrf_cc310_bl_hash_digest_sha256_t *)p_digest; + + if (NRF_CRYPTO_HASH_SIZE_SHA256 > *p_digest_size) + { + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + mutex_locked = cc310_backend_mutex_trylock(); + VERIFY_TRUE(mutex_locked, NRF_ERROR_CRYPTO_BUSY); + + cc310_bl_backend_enable(); + + // Do the hash finalize calculation + crys_error = nrf_cc310_bl_hash_sha256_finalize(p_backend_context, p_int_digest); + + cc310_bl_backend_disable(); + + cc310_backend_mutex_unlock(); + + ret_val = hash_result_get(crys_error); + + if (ret_val == NRF_SUCCESS) + { + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA256; + } + + return ret_val; +} + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info = +{ + .init_fn = cc310_bl_backend_hash_sha256_init, + .update_fn = cc310_bl_backend_hash_sha256_update, + .finalize_fn = cc310_bl_backend_hash_sha256_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA256 +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && #if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.h new file mode 100644 index 0000000..1289529 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.h @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2018 - 2019, 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 CC310_BL_BACKEND_HASH_H__ +#define CC310_BL_BACKEND_HASH_H__ + +/** @file + * + * @defgroup nrf_crypto_cc310_bl_backend_hash nrf_crypto CC310_BL backend hash + * @{ + * @ingroup nrf_crypto_cc310_bl_backend + * + * @brief Hash functionality provided by the nrf_crypto CC310_BL backend. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "sdk_errors.h" +#include "nrf_crypto_hash_shared.h" +#include "nrf_cc310_bl_hash_sha256.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Flag that SHA-256 is enabled in backend +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA256) +#error "Duplicate definition of SHA-256. More than one backend enabled"); +#endif +#define NRF_CRYPTO_HASH_SHA256_ENABLED 1 + + +/**@internal @brief nrf_crypto_hash context for SHA-256 in nrf_crypto CC310_BL backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + nrf_cc310_bl_hash_context_sha256_t context; /**< Hash context internal to CC310_BL. */ +} nrf_crypto_backend_hash_sha256_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +/**@} */ + +#endif // CC310_BL_BACKEND_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_init.c similarity index 55% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_init.c index af38c72..bca4596 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_init.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,66 +35,81 @@ * 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(NRF_CRYPTO) +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "nrf.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_error.h" -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) +#include "cc310_bl_backend_shared.h" +#include "cc310_backend_mutex.h" +#include "sns_silib.h" +#include "nrf_cc310_bl_init.h" -#include "nrf_crypto.h" -#include "cc310_lib_shared.h" -#include "crys_ecpki_domain.h" +/**@brief Mutex to ensure single access to nrf_cc310_bl resources */ +nrf_mtx_t g_cc310_mutex; -bool cc310_curve_domain_get(nrf_ecc_curve_type_t curve_type, CRYS_ECPKI_Domain_t ** p_domain) +static uint32_t init_result_get(uint32_t crys_error) { - CRYS_ECPKI_DomainID_t domain_id; - switch (curve_type) + uint32_t ret_val = NRF_ERROR_INTERNAL; + switch (crys_error) { - case NRF_CRYPTO_CURVE_SECP160R1: - domain_id = CRYS_ECPKI_DomainID_secp160r1; + case SA_SILIB_RET_OK: + ret_val = NRF_SUCCESS; break; - case NRF_CRYPTO_CURVE_SECP192R1: - domain_id = CRYS_ECPKI_DomainID_secp192r1; + case SA_SILIB_RET_EINVAL_HW_VERSION: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; break; - case NRF_CRYPTO_CURVE_SECP224R1: - domain_id = CRYS_ECPKI_DomainID_secp224r1; + default: + ret_val = NRF_ERROR_INTERNAL; break; + } - case NRF_CRYPTO_CURVE_SECP256R1: - domain_id = CRYS_ECPKI_DomainID_secp256r1; - break; + return ret_val; +} - case NRF_CRYPTO_CURVE_SECP384R1: - domain_id = CRYS_ECPKI_DomainID_secp384r1; - break; - case NRF_CRYPTO_CURVE_SECP521R1: - domain_id = CRYS_ECPKI_DomainID_secp521r1; - break; +static ret_code_t cc310_bl_backend_init(void) +{ + uint32_t ret_val; + CRYSError_t crys_error; - case NRF_CRYPTO_CURVE_SECP192K1: - domain_id = CRYS_ECPKI_DomainID_secp160k1; - break; + cc310_backend_mutex_init(); - case NRF_CRYPTO_CURVE_SECP224K1: - domain_id = CRYS_ECPKI_DomainID_secp224k1; - break; + // Enable the CC310 HW. + NRF_CRYPTOCELL->ENABLE = 1; - case NRF_CRYPTO_CURVE_SECP256K1: - domain_id = CRYS_ECPKI_DomainID_secp256k1; - break; + // Initialize the CC310_BL run-time library + crys_error = nrf_cc310_bl_init(); - default: - return false; - } + // Disable the CC310 HW after initialization. + NRF_CRYPTOCELL->ENABLE = 0; - (*p_domain) = (CRYS_ECPKI_Domain_t*)CRYS_ECPKI_GetEcDomain(domain_id); - return true; + ret_val = init_result_get(crys_error); + + return ret_val; } -#endif // NRF_CRYPTO_BACKEND_CC310_LIB -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) +static ret_code_t cc310_bl_backend_uninit(void) +{ + // Disable the CC310 HW. + NRF_CRYPTOCELL->ENABLE = 0; + + return NRF_SUCCESS; +} + + +CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const cc310_bl_backend) = +{ + .init_fn = cc310_bl_backend_init, + .uninit_fn = cc310_bl_backend_uninit +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.c new file mode 100644 index 0000000..b6c04a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.c @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "nrf.h" +#include "cc310_bl_backend_shared.h" +#include "nrf_crypto_error.h" + + +void cc310_bl_backend_enable(void) +{ + // Enable the cryptocell hardware + NRF_CRYPTOCELL->ENABLE = 1; + +#if defined(NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED == 1) + + // Enable the CryptoCell IRQ + NVIC_EnableIRQ(CRYPTOCELL_IRQn); + +#elif defined(NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED == 0) + + // Do nothing + +#else + + #warning NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif + +} + + +void cc310_bl_backend_disable(void) +{ + // Enable the cryptocell hardware + NRF_CRYPTOCELL->ENABLE = 0; + +#if defined(NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED == 1) + + // Disable the CryptoCell IRQ + NVIC_DisableIRQ(CRYPTOCELL_IRQn); + +#elif defined(NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED == 0) + + // Do nothing + +#else + + #warning NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif + +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.h similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.h index 432bea9..c4f27ff 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_shared.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,41 +35,49 @@ * 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 CC310_LIB_HASH_H__ -#define CC310_LIB_HASH_H__ + +#ifndef CC310_BL_BACKEND_SHARED_H__ +#define CC310_BL_BACKEND_SHARED_H__ /** @file * - * @defgroup nrf_crypto_backend_cc310_lib_shared CC310 backend shared functions. + * @defgroup nrf_crypto_cc310_bl_backend_shared nrf_crypto CC310_BL backend shared * @{ - * @ingroup nrf_crypto_backend_cryptocell + * @ingroup nrf_crypto_cc310_bl_backend * - * @brief Provides shared functions required for CC310 backend. + * @brief Shared functionality for the nrf_crypto CC310_BL backend. */ -#include -#include "nrf_crypto_types.h" -#include "crys_ecpki_types.h" +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + +#include "sdk_errors.h" +#include "nrf_crypto_hash_shared.h" #ifdef __cplusplus extern "C" { #endif -/** @brief Function to get micro_ecc curve domain from curve_type - * - * @param[in] curve_type Curve type get domain for. - * @param[out] pp_domain Double pointer to curve domain structure. - * - * @retval True True if curve domain was successfully located. + +/**@internal @brief Function to enable CC310 (in HW) */ -bool cc310_curve_domain_get(nrf_ecc_curve_type_t curve_type, CRYS_ECPKI_Domain_t ** pp_domain); +void cc310_bl_backend_enable(void); + + +/**@internal @brief Function to disable CC310 (in HW) + */ +void cc310_bl_backend_disable(void); + #ifdef __cplusplus } #endif +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL) + /**@} */ -#endif // #ifndef CC310_LIB_HASH_H__ +#endif // CC310_BL_BACKEND_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.c new file mode 100644 index 0000000..6642285 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.c @@ -0,0 +1,205 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include +#include "cifra_backend_aes_aead.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CIFRA_AES_AEAD) + +/**@internal @brief Type declaration of a template matching all possible context sizes + * for this backend. + */ +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + cf_aes_context context; +} nrf_crypto_backend_cifra_aes_aead_context_t; + + +static ret_code_t result_get(int error) +{ + switch (error) + { + case 0: + return NRF_SUCCESS; + + case 1: + return NRF_ERROR_CRYPTO_AEAD_INVALID_MAC; + + default: + return NRF_ERROR_CRYPTO_INTERNAL; + } +} + +static ret_code_t backend_cifra_init(void * const p_context, uint8_t * p_key) +{ + nrf_crypto_backend_cifra_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_cifra_aes_aead_context_t *)p_context; + + if ((p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_128) && + (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_192) && + (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_256)) + { + return NRF_ERROR_CRYPTO_KEY_SIZE; + } + + VERIFY_TRUE((p_ctx->header.p_info->mode == NRF_CRYPTO_AEAD_MODE_AES_EAX), + NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + cf_aes_init(&p_ctx->context, + p_key, + (p_ctx->header.p_info->key_size)>>3); // >>3: changes bits to bytes + + return NRF_SUCCESS; +} + + +static ret_code_t backend_cifra_uninit(void * const p_context) +{ + nrf_crypto_backend_cifra_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_cifra_aes_aead_context_t *)p_context; + + cf_aes_finish(&p_ctx->context); + + return NRF_SUCCESS; +} + +static ret_code_t backend_cifra_crypt(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) +{ + + int result; + ret_code_t ret_val; + + nrf_crypto_backend_cifra_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_cifra_aes_aead_context_t *)p_context; + + ret_val = NRF_SUCCESS; + + /* EAX mode allows following mac size: [1 ... 16] */ + if ((mac_size < 1) || (mac_size > NRF_CRYPTO_AES_BLOCK_SIZE)) + { + return NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + } + + if (operation == NRF_CRYPTO_ENCRYPT) + { + cf_eax_encrypt(&cf_aes, + &p_ctx->context, + p_data_in, + data_in_size, + p_adata, + adata_size, + p_nonce, + (size_t)nonce_size, + p_data_out, + p_mac, + mac_size); + } + else if (operation == NRF_CRYPTO_DECRYPT) + { + result = cf_eax_decrypt(&cf_aes, + &p_ctx->context, + p_data_in, + data_in_size, + p_adata, + adata_size, + p_nonce, + (size_t)nonce_size, + p_mac, + mac_size, + p_data_out); + ret_val = result_get(result); + } + else + { + return NRF_ERROR_CRYPTO_INVALID_PARAM; + } + + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CIFRA_AES_EAX) +nrf_crypto_aead_info_t const g_nrf_crypto_aes_eax_128_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .mode = NRF_CRYPTO_AEAD_MODE_AES_EAX, + + .init_fn = backend_cifra_init, + .uninit_fn = backend_cifra_uninit, + .crypt_fn = backend_cifra_crypt +}; + +nrf_crypto_aead_info_t const g_nrf_crypto_aes_eax_192_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .mode = NRF_CRYPTO_AEAD_MODE_AES_EAX, + + .init_fn = backend_cifra_init, + .uninit_fn = backend_cifra_uninit, + .crypt_fn = backend_cifra_crypt +}; + +nrf_crypto_aead_info_t const g_nrf_crypto_aes_eax_256_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .mode = NRF_CRYPTO_AEAD_MODE_AES_EAX, + + .init_fn = backend_cifra_init, + .uninit_fn = backend_cifra_uninit, + .crypt_fn = backend_cifra_crypt +}; +#endif + +#endif // MODULE_ENABLED(NRF_CRYPTO_AES_CCM_BACKEND_MBEDTLS) +#endif // MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.h similarity index 57% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.h index 58d0ee7..a9f21d9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_mem.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/cifra/cifra_backend_aes_aead.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,62 +35,64 @@ * 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 NRF_CRYPTO_MEM_H__ - #define NRF_CRYPTO_MEM_H__ + +#ifndef CIFRA_BACKEND_AES_AEAD_H__ +#define CIFRA_BACKEND_AES_AEAD_H__ /** @file * - * @defgroup nrf_crypto_mem Dynamic memory management module + * @defgroup nrf_crypto_cifra_backend_aes_aead nrf_crypto Cifra backend AES AEAD * @{ - * @ingroup nrf_crypto + * @ingroup nrf_crypto_cifra_backend * - * @brief Module to manage dynamically allocated memory used by nrf_crypto APIs + * @brief AES AEAD functionality provided by the nrf_crypto Cifra backend. */ -#include +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CIFRA) + +#include "modes.h" +#include "cifra_eax_aes.h" +#include "nrf_crypto_error.h" #include "nrf_crypto_types.h" +#include "nrf_crypto_aead_shared.h" - #ifdef __cplusplus +#ifdef __cplusplus extern "C" { -#if 0 -} #endif -#endif - -/** @brief Function to initialize the nrf_crypto memory module. - * - * @retval NRF_SUCCESS The nrf_crypto memory manager initialized successfully. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_mem_init(void); +/* AES EAX */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CIFRA_AES_EAX) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_EAX) +#error "Duplicate definition of AES EAX mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_EAX_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 // Flag that nrf_crypto_aes_aead frontend can be compiled +#undef NRF_CRYPTO_CIFRA_AES_AEAD_ENABLED +#define NRF_CRYPTO_CIFRA_AES_AEAD_ENABLED 1 // aes_aead backend cifra can be compiled -/**@brief Function to allocate memory for use by the nrf_crypto API. - * - * @param[in] size Length in bytes to allocate - * @param[in,out] p_result Pointer to value length structure to hold information about the allocated memory. - * - * @retval NRF_SUCCESS The memory was allocated successfully. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_mem_allocate(uint32_t size, nrf_value_length_t * p_result); - +/* defines for test purposes */ +#define NRF_CRYPTO_AES_EAX_128_ENABLED 1 +#define NRF_CRYPTO_AES_EAX_192_ENABLED 1 +#define NRF_CRYPTO_AES_EAX_256_ENABLED 1 -/**@brief Function to free memory to use by nrf_crypto API. - * - * @param[in] p_mem Pointer to value length structure holding information about allocated memory to free - * - * @retval NRF_SUCCESS The memory was freed successfully. - * @retval Any other error code reported by the memory manager. - */ -uint32_t nrf_crypto_mem_free(nrf_value_length_t * p_mem); +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + cf_aes_context context; /**< AES EAX context internal to Cifra. */ +} nrf_crypto_backend_aes_eax_context_t; +#endif #ifdef __cplusplus } #endif +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CIFRA) + +/** @} */ -/**@} */ +#endif // CIFRA_BACKEND_AES_AEAD_H__ - #endif // NRF_CRYPTO_MEM_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.c new file mode 100644 index 0000000..953061a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.c @@ -0,0 +1,1213 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +/*lint -save -e????*/ +#include "mbedtls/md.h" +#include "mbedtls/aes.h" +#include "mbedtls/cipher.h" +/*lint -restore*/ +#include "nrf_crypto_error.h" +#include "mbedtls_backend_aes.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_MBEDTLS_AES) + +/* macro changing bits to bytes */ +#define BITS_TO_BYTES(bits) ((bits)>>3) +#define BACKEND_ERROR_CHECK(error) \ + do { \ + if ((error) != 0) \ + { \ + return result_get((error)); \ + } \ + } while (0); + +/**@internal @brief Type declarations of templates matching all possible context sizes + * for this backend. + */ +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_aes_ctx_t backend; /**< Backend-specific internal context. */ + uint32_t context[1]; /**< AES context internal to mbed TLS. */ +} nrf_crypto_backend_mbedtls_aes_any_context_t; + +/**@internal @brief Type declarations of templates matching all possible context sizes + * for this backend. + */ +typedef union +{ + nrf_crypto_backend_mbedtls_aes_any_context_t any; /**< Common for all contexts. */ + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) + nrf_crypto_backend_aes_ecb_context_t ecb; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) + nrf_crypto_backend_aes_cbc_context_t cbc; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) + nrf_crypto_backend_aes_ctr_context_t ctr; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) + nrf_crypto_backend_aes_cfb_context_t cfb; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) + nrf_crypto_backend_aes_cbc_mac_context_t cbc_mac; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) + nrf_crypto_backend_aes_cmac_context_t cmac; +#endif +} nrf_crypto_backend_mbedtls_aes_context_t; + + +static ret_code_t result_get(int error) +{ + ret_code_t ret_val; + switch (error) + { + case 0: + ret_val = NRF_SUCCESS; + break; + + case MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case MBEDTLS_ERR_CIPHER_ALLOC_FAILED: + ret_val = NRF_ERROR_CRYPTO_ALLOC_FAILED; + break; + + case MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + + case MBEDTLS_ERR_MD_BAD_INPUT_DATA: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) +static ret_code_t backend_cmac_init(nrf_crypto_backend_aes_cmac_context_t * const p_cmac_ctx) +{ + int error; + + mbedtls_cipher_type_t cipher_type; + mbedtls_cipher_info_t const * p_cipher_info; + + mbedtls_cipher_init(&p_cmac_ctx->context); + + switch (p_cmac_ctx->header.p_info->key_size) + { + case NRF_CRYPTO_KEY_SIZE_128: + cipher_type = MBEDTLS_CIPHER_AES_128_ECB; + break; + + case NRF_CRYPTO_KEY_SIZE_192: + cipher_type = MBEDTLS_CIPHER_AES_192_ECB; + break; + + case NRF_CRYPTO_KEY_SIZE_256: + cipher_type = MBEDTLS_CIPHER_AES_256_ECB; + break; + + default: + return NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + } + + p_cipher_info = mbedtls_cipher_info_from_type(cipher_type); + + if (p_cipher_info == NULL) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + error = mbedtls_cipher_setup(&p_cmac_ctx->context, p_cipher_info); + BACKEND_ERROR_CHECK(error); + + return NRF_SUCCESS; +} +#endif + +static ret_code_t backend_mbedtls_init(void * const p_context, nrf_crypto_operation_t operation) +{ + ret_code_t ret_val = NRF_SUCCESS; + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + switch (p_ctx->any.header.p_info->key_size) + { + case NRF_CRYPTO_KEY_SIZE_128: + case NRF_CRYPTO_KEY_SIZE_192: + case NRF_CRYPTO_KEY_SIZE_256: + break; + + default: + return NRF_ERROR_CRYPTO_KEY_SIZE; + } + + switch (p_ctx->any.header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) + case NRF_CRYPTO_AES_MODE_CBC: + case NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7: + VERIFY_FALSE(((operation != NRF_CRYPTO_ENCRYPT) && (operation != NRF_CRYPTO_DECRYPT)), + NRF_ERROR_CRYPTO_INVALID_PARAM); + memset(&p_ctx->cbc.backend, 0, sizeof(p_ctx->cbc.backend)); + + mbedtls_aes_init(&p_ctx->cbc.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) + case NRF_CRYPTO_AES_MODE_CTR: + VERIFY_FALSE(((operation != NRF_CRYPTO_ENCRYPT) && (operation != NRF_CRYPTO_DECRYPT)), + NRF_ERROR_CRYPTO_INVALID_PARAM); + memset(&p_ctx->ctr.backend, 0, sizeof(p_ctx->ctr.backend)); + + mbedtls_aes_init(&p_ctx->ctr.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) + case NRF_CRYPTO_AES_MODE_CFB: + VERIFY_FALSE(((operation != NRF_CRYPTO_ENCRYPT) && (operation != NRF_CRYPTO_DECRYPT)), + NRF_ERROR_CRYPTO_INVALID_PARAM); + memset(&p_ctx->cfb.backend, 0, sizeof(p_ctx->cfb.backend)); + + mbedtls_aes_init(&p_ctx->cfb.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) + case NRF_CRYPTO_AES_MODE_ECB: + case NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7: + VERIFY_FALSE(((operation != NRF_CRYPTO_ENCRYPT) && (operation != NRF_CRYPTO_DECRYPT)), + NRF_ERROR_CRYPTO_INVALID_PARAM); + memset(&p_ctx->ecb.backend, 0, sizeof(p_ctx->ecb.backend)); + + mbedtls_aes_init(&p_ctx->ecb.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) + case NRF_CRYPTO_AES_MODE_CBC_MAC: + case NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7: + VERIFY_TRUE((operation == NRF_CRYPTO_MAC_CALCULATE), NRF_ERROR_CRYPTO_INVALID_PARAM); + memset(&p_ctx->cbc_mac.backend, 0, sizeof(p_ctx->cbc_mac.backend)); + + mbedtls_aes_init(&p_ctx->cbc_mac.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) + case NRF_CRYPTO_AES_MODE_CMAC: + VERIFY_TRUE((operation == NRF_CRYPTO_MAC_CALCULATE), NRF_ERROR_CRYPTO_INVALID_PARAM); + + ret_val = backend_cmac_init(&p_ctx->cmac); + break; +#endif + default: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + } + + p_ctx->any.backend.operation = operation; + + return ret_val; +} + +static ret_code_t backend_mbedtls_uninit(void * const p_context) +{ + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + switch (p_ctx->any.header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) + case NRF_CRYPTO_AES_MODE_CBC: + case NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7: + mbedtls_aes_free(&p_ctx->cbc.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) + case NRF_CRYPTO_AES_MODE_CTR: + mbedtls_aes_free(&p_ctx->ctr.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) + case NRF_CRYPTO_AES_MODE_CFB: + mbedtls_aes_free(&p_ctx->cfb.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) + case NRF_CRYPTO_AES_MODE_ECB: + case NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7: + mbedtls_aes_free(&p_ctx->ecb.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) + case NRF_CRYPTO_AES_MODE_CBC_MAC: + case NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7: + mbedtls_aes_free(&p_ctx->cbc_mac.context); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) + case NRF_CRYPTO_AES_MODE_CMAC: + mbedtls_cipher_free(&p_ctx->cmac.context); + break; +#endif + + default: + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + } + + return NRF_SUCCESS; +} + +static ret_code_t backend_mbedtls_key_set(void * const p_context, uint8_t * p_key) +{ + int error; + ret_code_t ret_val; + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + switch (p_ctx->any.header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) + case NRF_CRYPTO_AES_MODE_CBC: + case NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7: + if (p_ctx->cbc.backend.operation == NRF_CRYPTO_ENCRYPT) + { + error = mbedtls_aes_setkey_enc(&p_ctx->cbc.context, + (uint8_t const *)p_key, + p_ctx->cbc.header.p_info->key_size); + } + else + { + error = mbedtls_aes_setkey_dec(&p_ctx->cbc.context, + (uint8_t const *)p_key, + p_ctx->cbc.header.p_info->key_size); + } + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) + case NRF_CRYPTO_AES_MODE_CTR: + /* Due to the nature of CFB / CTR, you should use the same key schedule for both + encryption and decryption.*/ + error = mbedtls_aes_setkey_enc(&p_ctx->ctr.context, + (uint8_t const *)p_key, + p_ctx->ctr.header.p_info->key_size); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) + case NRF_CRYPTO_AES_MODE_CFB: + /* Due to the nature of CFB / CTR, you should use the same key schedule for both + encryption and decryption.*/ + error = mbedtls_aes_setkey_enc(&p_ctx->cfb.context, + (uint8_t const *)p_key, + p_ctx->cfb.header.p_info->key_size); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) + case NRF_CRYPTO_AES_MODE_ECB: + case NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7: + if (p_ctx->ecb.backend.operation == NRF_CRYPTO_ENCRYPT) + { + error = mbedtls_aes_setkey_enc(&p_ctx->ecb.context, + (uint8_t const *)p_key, + p_ctx->ecb.header.p_info->key_size); + } + else + { + error = mbedtls_aes_setkey_dec(&p_ctx->ecb.context, + (uint8_t const *)p_key, + p_ctx->ecb.header.p_info->key_size); + } + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) + case NRF_CRYPTO_AES_MODE_CBC_MAC: + case NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7: + error = mbedtls_aes_setkey_enc(&p_ctx->cbc_mac.context, + (uint8_t const *)p_key, + p_ctx->cbc_mac.header.p_info->key_size); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) + case NRF_CRYPTO_AES_MODE_CMAC: + error = mbedtls_cipher_cmac_starts(&p_ctx->cmac.context, + p_key, + p_ctx->cmac.header.p_info->key_size); + break; +#endif + + default: + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + } + + ret_val = result_get(error); + + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) +static ret_code_t backend_mbedtls_iv_set(void * const p_context, uint8_t * p_iv) +{ + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + memcpy(&p_ctx->any.backend.iv[0], p_iv, sizeof(p_ctx->any.backend.iv)); + + return NRF_SUCCESS; +} + +static ret_code_t backend_mbedtls_iv_get(void * const p_context, uint8_t * p_iv) +{ + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + memcpy(p_iv, p_ctx->any.backend.iv, sizeof(p_ctx->any.backend.iv)); + + return NRF_SUCCESS; +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) +/* Function extending mbedtls_aes_crypt_ecb functionality. It allows to process more than 1 + data block. It is returning MBEDTLS error type. */ +static int backend_mbedtls_ecb_crypt(nrf_crypto_backend_aes_ecb_context_t * const p_ctx, + uint8_t * p_text_in, + uint8_t * p_text_out, + size_t text_size) +{ + int error = 0; + size_t crypted_text = 0; + + if ((text_size & 0x0F) != 0) + { + return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH; + } + + while (crypted_text < text_size) + { + error = mbedtls_aes_crypt_ecb(&p_ctx->context, + (int)p_ctx->backend.operation, + p_text_in + crypted_text, + p_text_out + crypted_text); + if (error != 0) + { + break; + } + crypted_text += NRF_CRYPTO_AES_BLOCK_SIZE; + } + + return error; +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) +static int backend_mbedtls_cbc_mac_update(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out) +{ + int error = 0; + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + for (size_t i = 0; i < data_size; i += NRF_CRYPTO_AES_BLOCK_SIZE) + { + error = mbedtls_aes_crypt_cbc(&p_ctx->cbc_mac.context, + MBEDTLS_AES_ENCRYPT, + NRF_CRYPTO_AES_BLOCK_SIZE, + p_ctx->cbc_mac.backend.iv, + (uint8_t const *)p_data_in + i, + p_data_out); + if (error != 0) + { + return error; + } + } + + return error; +} + +static ret_code_t backend_mbedtls_cbc_mac_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + int error; + + if (*p_data_out_size < NRF_CRYPTO_AES_BLOCK_SIZE) + { + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + /* this function does not support padding */ + if ((data_size & 0xF) != 0) + { + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + error = backend_mbedtls_cbc_mac_update(p_context, p_data_in, data_size, p_data_out); + BACKEND_ERROR_CHECK(error); + + *p_data_out_size = NRF_CRYPTO_AES_BLOCK_SIZE; + + return NRF_SUCCESS; +} + +static ret_code_t backend_mbedtls_cbc_mac_padding_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + ret_code_t ret_val; + uint8_t padding_buffer[NRF_CRYPTO_AES_BLOCK_SIZE] = {0}; + uint8_t msg_ending = (uint8_t)(data_size & (size_t)0x0F); + + if (*p_data_out_size < NRF_CRYPTO_AES_BLOCK_SIZE) + { + /* output buffer too small */ + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + data_size -= msg_ending; + + if (data_size > 0) + { + ret_val = backend_mbedtls_cbc_mac_update(p_context, + p_data_in, + data_size, + p_data_out); + VERIFY_SUCCESS(ret_val); + } + + ret_val = padding_pkcs7_add(&padding_buffer[0], + p_data_in + data_size, + msg_ending); + VERIFY_SUCCESS(ret_val); + + ret_val = backend_mbedtls_cbc_mac_finalize(p_context, + &padding_buffer[0], + NRF_CRYPTO_AES_BLOCK_SIZE, + p_data_out, + p_data_out_size); + VERIFY_SUCCESS(ret_val); + + return ret_val; +} +#endif + +static ret_code_t backend_mbedtls_update(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out) +{ + int error; + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + switch (p_ctx->any.header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) + case NRF_CRYPTO_AES_MODE_CBC: + case NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7: + error = mbedtls_aes_crypt_cbc(&p_ctx->cbc.context, + (int)p_ctx->cbc.backend.operation, + data_size, + p_ctx->cbc.backend.iv, + (uint8_t const *)p_data_in, + p_data_out); + break; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) + case NRF_CRYPTO_AES_MODE_CTR: + { + size_t nc_off = 0; + uint8_t stream_block[NRF_CRYPTO_AES_BLOCK_SIZE]; + + error = mbedtls_aes_crypt_ctr(&p_ctx->ctr.context, + data_size, + &nc_off, + p_ctx->ctr.backend.iv, + stream_block, + (uint8_t const *)p_data_in, + p_data_out); + break; + } +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) + case NRF_CRYPTO_AES_MODE_CFB: + error = mbedtls_aes_crypt_cfb8(&p_ctx->cfb.context, + (int)p_ctx->cfb.backend.operation, + data_size, + p_ctx->cfb.backend.iv, + (uint8_t const *)p_data_in, + p_data_out); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) + case NRF_CRYPTO_AES_MODE_ECB: + case NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7: + error = backend_mbedtls_ecb_crypt(&p_ctx->ecb, p_data_in, p_data_out, data_size); + break; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) + case NRF_CRYPTO_AES_MODE_CBC_MAC: + case NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7: + error = backend_mbedtls_cbc_mac_update(p_context, p_data_in, data_size, p_data_out); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) + case NRF_CRYPTO_AES_MODE_CMAC: + error = mbedtls_cipher_cmac_update(&p_ctx->cmac.context, + p_data_in, + data_size); + break; +#endif + + default: + return NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + } + BACKEND_ERROR_CHECK(error); + + return NRF_SUCCESS; +} + +static ret_code_t backend_mbedtls_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + ret_code_t ret_val; + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + if (*p_data_out_size < data_size) + { + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + /* data is not multiple of 16 bytes */ + if ((data_size & 0x0F) != 0) + { + if ((p_ctx->any.header.p_info->mode != NRF_CRYPTO_AES_MODE_CTR) && + (p_ctx->any.header.p_info->mode != NRF_CRYPTO_AES_MODE_CFB)) + { + /* There are separate handlers for AES modes with padding and for MAC modes. */ + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + } + + ret_val = backend_mbedtls_update(p_context, p_data_in, data_size, p_data_out); + VERIFY_SUCCESS(ret_val); + + *p_data_out_size = data_size; + + return ret_val; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) +static ret_code_t backend_mbedtls_cmac_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + int error; + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + if (*p_data_out_size < NRF_CRYPTO_AES_BLOCK_SIZE) + { + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + error = mbedtls_cipher_cmac_update(&p_ctx->cmac.context, p_data_in, data_size); + BACKEND_ERROR_CHECK(error); + + error = mbedtls_cipher_cmac_finish(&p_ctx->cmac.context, p_data_out); + BACKEND_ERROR_CHECK(error); + + *p_data_out_size = NRF_CRYPTO_AES_BLOCK_SIZE; + + return NRF_SUCCESS; +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) +static ret_code_t backend_mbedtls_padding_finalize(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + ret_code_t ret_val; + size_t buff_out_size; + uint8_t padding_buffer[NRF_CRYPTO_AES_BLOCK_SIZE] = {0}; + uint8_t msg_ending = (uint8_t)(data_size & (size_t)0x0F); + + nrf_crypto_backend_mbedtls_aes_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_context_t *)p_context; + + if (p_ctx->any.backend.operation == NRF_CRYPTO_DECRYPT) + { + ret_val = backend_mbedtls_finalize(p_context, + p_data_in, + data_size, + p_data_out, + p_data_out_size); + VERIFY_SUCCESS(ret_val); + + ret_val = padding_pkcs7_remove(p_data_out, + p_data_out_size); + return ret_val; + } + + /* -------------- ENCRYPTION --------------*/ + data_size -= msg_ending; + + if (*p_data_out_size < (data_size + NRF_CRYPTO_AES_BLOCK_SIZE)) + { + /* no space for padding */ + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + if (data_size > 0) + { + /* Encrypt 16 byte blocks */ + ret_val = backend_mbedtls_update(p_context, + p_data_in, + data_size, + p_data_out); + VERIFY_SUCCESS(ret_val); + } + + ret_val = padding_pkcs7_add(&padding_buffer[0], + p_data_in + data_size, + msg_ending); + VERIFY_SUCCESS(ret_val); + + buff_out_size = *p_data_out_size - data_size; + + ret_val = backend_mbedtls_finalize(p_context, + &padding_buffer[0], + NRF_CRYPTO_AES_BLOCK_SIZE, + p_data_out + data_size, + &buff_out_size); + VERIFY_SUCCESS(ret_val); + + *p_data_out_size = buff_out_size + data_size; + + return ret_val; +} +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_192_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_256_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_128_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_padding_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_192_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_padding_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_256_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_padding_finalize +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ctr_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CTR, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_ctr_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ctr_192_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CTR, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_ctr_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ctr_256_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CTR, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_ctr_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; +#endif + +// CFB +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cfb_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CFB, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cfb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cfb_192_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CFB, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_cfb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cfb_256_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CFB, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_cfb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_192_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_256_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_128_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_padding_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_192_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_padding_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_ecb_256_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_ecb_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_padding_finalize +}; +#endif + + +// CBC MAC +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cbc_mac_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_192_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cbc_mac_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_256_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cbc_mac_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_128_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cbc_mac_padding_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_192_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cbc_mac_padding_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cbc_mac_256_pad_pkcs7_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_cbc_mac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = backend_mbedtls_iv_set, + .iv_get_fn = backend_mbedtls_iv_get, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cbc_mac_padding_finalize +}; + +#endif + +// CMAC +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cmac_128_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CMAC, + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .context_size = sizeof(nrf_crypto_backend_aes_cmac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cmac_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cmac_192_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CMAC, + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .context_size = sizeof(nrf_crypto_backend_aes_cmac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cmac_finalize +}; + +nrf_crypto_aes_info_t const g_nrf_crypto_aes_cmac_256_info = +{ + .mode = NRF_CRYPTO_AES_MODE_CMAC, + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .context_size = sizeof(nrf_crypto_backend_aes_cmac_context_t), + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .key_set_fn = backend_mbedtls_key_set, + .iv_set_fn = NULL, + .iv_get_fn = NULL, + .update_fn = backend_mbedtls_update, + .finalize_fn = backend_mbedtls_cmac_finalize +}; +#endif + +#endif // #if NRF_MODULE_ENABLED(NRF_CRYPTO_MBEDTLS_AES) +#endif // MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.h new file mode 100644 index 0000000..f29bae4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes.h @@ -0,0 +1,227 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_AES_H__ +#define MBEDTLS_BACKEND_AES_H__ + +/** @file + * + * @defgroup nrf_crypto_mbedtls_backend_aes nrf_crypto mbed TLS backend AES + * @{ + * @ingroup nrf_crypto_mbedtls_backend + * + * @brief AES functionality provided by the nrf_crypto mbed TLS backend. + */ + +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +/*lint -save -e????*/ +#include "mbedtls/aes.h" +#include "mbedtls/cmac.h" +#include "mbedtls/platform.h" +/*lint -restore*/ +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_aes_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* AES CBC */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CBC) +#error "Duplicate definition of AES CBC mode. More than one backend enabled"); +#endif +/* Flag that AES CBC is enabled in backend */ +#define NRF_CRYPTO_AES_CBC_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_MBEDTLS_AES_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CBC_128_ENABLED 1 +#define NRF_CRYPTO_AES_CBC_192_ENABLED 1 +#define NRF_CRYPTO_AES_CBC_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_aes_ctx_t backend; /**< Backend-specific internal context. */ + mbedtls_aes_context context; /**< AES context internal to mbed TLS. */ +} nrf_crypto_backend_aes_cbc_context_t; +#endif + + +/* AES CTR */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CTR) +#error "Duplicate definition of AES CTR mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CTR_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_MBEDTLS_AES_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CTR_128_ENABLED 1 +#define NRF_CRYPTO_AES_CTR_192_ENABLED 1 +#define NRF_CRYPTO_AES_CTR_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_aes_ctx_t backend; /**< Backend-specific internal context. */ + mbedtls_aes_context context; /**< AES context internal to mbed TLS. */ +} nrf_crypto_backend_aes_ctr_context_t; +#endif + +/* AES CFB */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CFB) +#error "Duplicate definition of AES CFB mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CFB_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_MBEDTLS_AES_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CFB_128_ENABLED 1 +#define NRF_CRYPTO_AES_CFB_192_ENABLED 1 +#define NRF_CRYPTO_AES_CFB_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_aes_ctx_t backend; /**< Backend-specific internal context. */ + mbedtls_aes_context context; /**< AES context internal to mbed TLS. */ +} nrf_crypto_backend_aes_cfb_context_t; +#endif + +/* AES ECB */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_ECB) +#error "Duplicate definition of AES ECB mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_ECB_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 +#undef NRF_CRYPTO_MBEDTLS_AES_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_ECB_128_ENABLED 1 +#define NRF_CRYPTO_AES_ECB_192_ENABLED 1 +#define NRF_CRYPTO_AES_ECB_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_no_iv_aes_ctx_t backend; /**< Backend-specific internal context. */ + mbedtls_aes_context context; /**< AES context internal to mbed TLS. */ +} nrf_crypto_backend_aes_ecb_context_t; +#endif + + +/* AES CBC MAC */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CBC_MAC) +#error "Duplicate definition of AES CBC MAC mode. More than one backend enabled"); +#endif +/* Flag that AES CBC MAC is enabled in backend */ +#define NRF_CRYPTO_AES_CBC_MAC_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_MBEDTLS_AES_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CBC_MAC_128_ENABLED 1 +#define NRF_CRYPTO_AES_CBC_MAC_192_ENABLED 1 +#define NRF_CRYPTO_AES_CBC_MAC_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_aes_ctx_t backend; /**< Backend-specific internal context. */ + mbedtls_aes_context context; /**< AES context internal to mbed TLS. */ +} nrf_crypto_backend_aes_cbc_mac_context_t; +#endif + + +/* AES CMAC */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CMAC) +#error "Duplicate definition of AES CMAC mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CMAC_ENABLED 1 +#undef NRF_CRYPTO_AES_ENABLED +#define NRF_CRYPTO_AES_ENABLED 1 // Flag that nrf_crypto_aes frontend can be compiled +#undef NRF_CRYPTO_MBEDTLS_AES_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CMAC_128_ENABLED 1 +#define NRF_CRYPTO_AES_CMAC_192_ENABLED 1 +#define NRF_CRYPTO_AES_CMAC_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aes_internal_context_t header; /**< Common header for context. */ + nrf_crypto_backend_no_iv_aes_ctx_t backend; /**< Backend-specific internal context. */ + mbedtls_cipher_context_t context; /**< AES context internal to mbedtls. */ +} nrf_crypto_backend_aes_cmac_context_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +/** @} */ + +#endif // MBEDTLS_BACKEND_AES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.c new file mode 100644 index 0000000..ff202b2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.c @@ -0,0 +1,384 @@ +/** + * Copyright (c) 2018 - 2019, 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" +#include +#if NRF_MODULE_ENABLED(NRF_CRYPTO) + +#include "nrf_crypto_error.h" +#include "mbedtls_backend_aes_aead.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_MBEDTLS_AES_AEAD) + +/**@internal @brief Type declaration of a template suiting all possible context sizes + * for this backend. + */ +typedef union +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) + nrf_crypto_backend_aes_ccm_context_t ccm; +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) + nrf_crypto_backend_aes_gcm_context_t gcm; +#endif +} nrf_crypto_backend_mbedtls_aes_aead_context_t; + + +static ret_code_t result_get(int error) +{ + ret_code_t ret_val; + + switch (error) + { + case 0: + ret_val = NRF_SUCCESS; + break; + + case MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case MBEDTLS_ERR_CIPHER_ALLOC_FAILED: + ret_val = NRF_ERROR_CRYPTO_ALLOC_FAILED; + break; + + case MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE: + ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + break; + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) + case MBEDTLS_ERR_CCM_BAD_INPUT: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + case MBEDTLS_ERR_CCM_AUTH_FAILED: + ret_val = NRF_ERROR_CRYPTO_AEAD_INVALID_MAC; + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) + case MBEDTLS_ERR_GCM_BAD_INPUT: + ret_val = NRF_ERROR_CRYPTO_INVALID_PARAM; + break; + + case MBEDTLS_ERR_GCM_AUTH_FAILED: + ret_val = NRF_ERROR_CRYPTO_AEAD_INVALID_MAC; + break; +#endif + + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + return ret_val; +} + +static ret_code_t backend_mbedtls_init(void * const p_context, uint8_t * p_key) +{ + int result; + ret_code_t ret_val; + + nrf_crypto_backend_mbedtls_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_aead_context_t *)p_context; + + if ((p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_128) && + (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_192) && + (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_256)) + { + return NRF_ERROR_CRYPTO_KEY_SIZE; + } + + switch (p_ctx->header.p_info->mode) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) + case NRF_CRYPTO_AEAD_MODE_AES_CCM: + mbedtls_ccm_init(&p_ctx->ccm.context); + + result = mbedtls_ccm_setkey(&p_ctx->ccm.context, + MBEDTLS_CIPHER_ID_AES, + p_key, + p_ctx->header.p_info->key_size); + break; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) + case NRF_CRYPTO_AEAD_MODE_AES_GCM: + mbedtls_gcm_init(&p_ctx->gcm.context); + + result = mbedtls_gcm_setkey(&p_ctx->gcm.context, + MBEDTLS_CIPHER_ID_AES, + p_key, + p_ctx->header.p_info->key_size); + break; +#endif + + default: + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + } + + if (result != 0) + { + ret_val = result_get(result); + return ret_val; + } + + return NRF_SUCCESS; +} + +static ret_code_t backend_mbedtls_uninit(void * const p_context) +{ + nrf_crypto_backend_mbedtls_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_aead_context_t *)p_context; + + if (p_ctx->header.p_info->mode == NRF_CRYPTO_AEAD_MODE_AES_CCM) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) + mbedtls_ccm_free(&p_ctx->ccm.context); +#endif + } + else + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) + mbedtls_gcm_free(&p_ctx->gcm.context); +#endif + } + + return NRF_SUCCESS; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) +static ret_code_t backend_mbedtls_ccm_crypt(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) +{ + int result; + ret_code_t ret_val; + + nrf_crypto_backend_mbedtls_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_aead_context_t *)p_context; + + /* CCM mode allows following MAC sizes: [4, 6, 8, 10, 12, 14, 16] */ + if ((mac_size < NRF_CRYPTO_AES_CCM_MAC_MIN) || (mac_size > NRF_CRYPTO_AES_CCM_MAC_MAX) || + ((mac_size & 0x01) != 0)) + { + return NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + } + + if ((nonce_size < NRF_CRYPTO_AES_CCM_NONCE_SIZE_MIN) || + (nonce_size > NRF_CRYPTO_AES_CCM_NONCE_SIZE_MAX)) + { + return NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE; + } + + if (operation == NRF_CRYPTO_ENCRYPT) + { + result = mbedtls_ccm_encrypt_and_tag(&p_ctx->ccm.context, + data_in_size, + p_nonce, + nonce_size, + p_adata, + adata_size, + p_data_in, + p_data_out, + p_mac, + (size_t)mac_size); + } + else if (operation == NRF_CRYPTO_DECRYPT) + { + result = mbedtls_ccm_auth_decrypt(&p_ctx->ccm.context, + data_in_size, + p_nonce, + nonce_size, + p_adata, + adata_size, + p_data_in, + p_data_out, + p_mac, + (size_t)mac_size); + } + else + { + return NRF_ERROR_CRYPTO_INVALID_PARAM; + } + + ret_val = result_get(result); + + return ret_val; +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) +static ret_code_t backend_mbedtls_gcm_crypt(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) +{ + int result; + ret_code_t ret_val; + + nrf_crypto_backend_mbedtls_aes_aead_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_aes_aead_context_t *)p_context; + + /* GCM allows following MAC size: [4 ... 16] */ + if ((mac_size < NRF_CRYPTO_AES_GCM_MAC_MIN) || (mac_size > NRF_CRYPTO_AES_GCM_MAC_MAX)) + { + return NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + } + + if (operation == NRF_CRYPTO_ENCRYPT) + { + result = mbedtls_gcm_crypt_and_tag(&p_ctx->gcm.context, + MBEDTLS_GCM_ENCRYPT, + data_in_size, + p_nonce, + nonce_size, + p_adata, + adata_size, + p_data_in, + p_data_out, + (size_t)mac_size, + p_mac); + ret_val = result_get(result); + } + else if (operation == NRF_CRYPTO_DECRYPT) + { + result = mbedtls_gcm_auth_decrypt(&p_ctx->gcm.context, + data_in_size, + p_nonce, + nonce_size, + p_adata, + adata_size, + p_mac, + (size_t)mac_size, + p_data_in, + p_data_out); + ret_val = result_get(result); + } + else + { + return NRF_ERROR_CRYPTO_INVALID_PARAM; + } + + return ret_val; +} +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) +nrf_crypto_aead_info_t const g_nrf_crypto_aes_ccm_128_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .mode = NRF_CRYPTO_AEAD_MODE_AES_CCM, + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .crypt_fn = backend_mbedtls_ccm_crypt +}; + +nrf_crypto_aead_info_t const g_nrf_crypto_aes_ccm_192_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .mode = NRF_CRYPTO_AEAD_MODE_AES_CCM, + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .crypt_fn = backend_mbedtls_ccm_crypt +}; + +nrf_crypto_aead_info_t const g_nrf_crypto_aes_ccm_256_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .mode = NRF_CRYPTO_AEAD_MODE_AES_CCM, + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .crypt_fn = backend_mbedtls_ccm_crypt +}; +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) +nrf_crypto_aead_info_t const g_nrf_crypto_aes_gcm_128_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_128, + .mode = NRF_CRYPTO_AEAD_MODE_AES_GCM, + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .crypt_fn = backend_mbedtls_gcm_crypt +}; + +nrf_crypto_aead_info_t const g_nrf_crypto_aes_gcm_192_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_192, + .mode = NRF_CRYPTO_AEAD_MODE_AES_GCM, + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .crypt_fn = backend_mbedtls_gcm_crypt +}; + +nrf_crypto_aead_info_t const g_nrf_crypto_aes_gcm_256_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .mode = NRF_CRYPTO_AEAD_MODE_AES_GCM, + + .init_fn = backend_mbedtls_init, + .uninit_fn = backend_mbedtls_uninit, + .crypt_fn = backend_mbedtls_gcm_crypt +}; +#endif + +#endif // MODULE_ENABLED(NRF_CRYPTO_MBEDTLS_AES_AEAD) +#endif // MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.h new file mode 100644 index 0000000..788ca1a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_aes_aead.h @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_AES_AEAD_H__ +#define MBEDTLS_BACKEND_AES_AEAD_H__ + +/** @file + * + * @defgroup nrf_crypto_mbedtls_backend_aes_aead nrf_crypto mbed TLS backend AES AEAD + * @{ + * @ingroup nrf_crypto_mbedtls_backend + * + * @brief AES AEAD functionality provided by the nrf_crypto mbed TLS backend. + */ + +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) +/*lint -save -e????*/ +#include "mbedtls/ccm.h" +#include "mbedtls/gcm.h" +#include "mbedtls/platform.h" +/*lint -restore*/ +#include "nrf_crypto_error.h" +#include "nrf_crypto_aead_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* AES CCM */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CCM) +#error "Duplicate definition of AES CCM mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_CCM_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 +#undef NRF_CRYPTO_MBEDTLS_AES_AEAD_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_AEAD_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CCM_128_ENABLED 1 +#define NRF_CRYPTO_AES_CCM_192_ENABLED 1 +#define NRF_CRYPTO_AES_CCM_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + mbedtls_ccm_context context; /**< AES CCM context internal to mbed TLS. */ +} nrf_crypto_backend_aes_ccm_context_t; +#endif + +/* AES GCM */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES_GCM) +#error "Duplicate definition of AES GCM mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_AES_GCM_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 +#undef NRF_CRYPTO_MBEDTLS_AES_AEAD_ENABLED +#define NRF_CRYPTO_MBEDTLS_AES_AEAD_ENABLED 1 + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_GCM_128_ENABLED 1 +#define NRF_CRYPTO_AES_GCM_192_ENABLED 1 +#define NRF_CRYPTO_AES_GCM_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + mbedtls_gcm_context context; /**< AES GCM context internal to mbed TLS. */ +} nrf_crypto_backend_aes_gcm_context_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +/** @} */ + +#endif // MBEDTLS_BACKEND_AES_AEAD_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.c new file mode 100644 index 0000000..ae508ac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.c @@ -0,0 +1,585 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_shared.h" +#include "nrf_assert.h" +#include "mbedtls_backend_ecc.h" + +/*lint -save -e????*/ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif +#include "mbedtls/ecp.h" +#include "mbedtls/bignum.h" +/*lint -restore*/ + + +bool nrf_crypto_backend_mbedtls_ecc_group_load( + mbedtls_ecp_group * p_group, + struct nrf_crypto_ecc_curve_info_s const * p_info) +{ + int result; + + mbedtls_ecp_group_init(p_group); + result = mbedtls_ecp_group_load(p_group, + (mbedtls_ecp_group_id)(intptr_t)p_info->p_backend_data); + + if (result != 0) + { + return false; + } + return true; +} + + +int nrf_crypto_backend_mbedtls_ecc_mbedtls_rng(void * p_param, unsigned char * p_data, size_t size) +{ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + + ret_code_t result; + + result = nrf_crypto_rng_vector_generate(p_data, size); + + if (result != NRF_SUCCESS) + { + return MBEDTLS_ERR_ECP_RANDOM_FAILED; + } + return 0; + +#else + return MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; +#endif +} + + +ret_code_t nrf_crypto_backend_mbedtls_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + int result; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_private_key_t * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t *)p_private_key; + + nrf_crypto_backend_mbedtls_ecc_public_key_t * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + mbedtls_ecp_point_init(&p_pub->key); + mbedtls_mpi_init(&p_prv->key); + result = mbedtls_ecp_gen_keypair(&group, + &p_prv->key, + &p_pub->key, + nrf_crypto_backend_mbedtls_ecc_mbedtls_rng, + NULL); + + mbedtls_ecp_group_free(&group); + + if (result != 0) + { + mbedtls_mpi_free(&p_prv->key); + mbedtls_ecp_point_free(&p_pub->key); + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_mbedtls_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + int result; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_private_key_t const * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t const *)p_private_key; + + nrf_crypto_backend_mbedtls_ecc_public_key_t * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + mbedtls_ecp_point_init(&p_pub->key); + result = mbedtls_ecp_mul(&group, + &p_pub->key, + &p_prv->key, + &group.G, + nrf_crypto_backend_mbedtls_ecc_mbedtls_rng, + NULL); + + mbedtls_ecp_group_free(&group); + + if (result != 0) + { + mbedtls_ecp_point_free(&p_pub->key); + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_mbedtls_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data) +{ + int result; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_private_key_t * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + uint8_t const * p_input = p_raw_data; + +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED && !NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + + uint8_t temp[NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE]; + + if (p_info == &g_nrf_crypto_ecc_curve25519_curve_info) + { + nrf_crypto_internal_swap_endian(temp, + p_raw_data, + NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE); + p_input = temp; + } + +#endif + + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + mbedtls_mpi_init(&p_prv->key); + result = mbedtls_mpi_read_binary(&p_prv->key, p_input, p_info->raw_private_key_size); + + if (result == 0) + { +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) + // Update bits in Curve25519 private key + if (p_prv->header.p_info->curve_type == NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE) + { + result = mbedtls_mpi_set_bit(&p_prv->key, 0, 0); + ASSERT(result == 0); + result = mbedtls_mpi_set_bit(&p_prv->key, 1, 0); + ASSERT(result == 0); + result = mbedtls_mpi_set_bit(&p_prv->key, 2, 0); + ASSERT(result == 0); + result = mbedtls_mpi_set_bit(&p_prv->key, 254, 1); + ASSERT(result == 0); + result = mbedtls_mpi_set_bit(&p_prv->key, 255, 0); + ASSERT(result == 0); + } +#endif + if (mbedtls_ecp_check_privkey(&group, &p_prv->key) != 0) + { + result = MBEDTLS_ERR_ECP_INVALID_KEY; + } + } + + mbedtls_ecp_group_free(&group); + + if (result != 0) + { + mbedtls_mpi_free(&p_prv->key); + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_mbedtls_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data) +{ + int result; + + nrf_crypto_backend_mbedtls_ecc_private_key_t const * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t const *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + result = mbedtls_mpi_write_binary(&p_prv->key, p_raw_data, p_info->raw_private_key_size); + +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED && !NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + + if (p_info == &g_nrf_crypto_ecc_curve25519_curve_info) + { + nrf_crypto_internal_swap_endian_in_place(p_raw_data, + NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE); + } + +#endif + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_mbedtls_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + int result; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_public_key_t * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + uint8_t const * p_input = p_raw_data; + +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED && !NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + + uint8_t temp[NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE]; + + if (p_info == &g_nrf_crypto_ecc_curve25519_curve_info) + { + nrf_crypto_internal_swap_endian(temp, + p_raw_data, + NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE); + p_input = temp; + } + +#endif + + mbedtls_ecp_point_init(&p_pub->key); + + result = mbedtls_mpi_read_binary(&p_pub->key.X, + p_input, + p_info->raw_private_key_size); + + if (result != 0) + { + goto error_exit; + } + + if (p_info->raw_public_key_size > p_info->raw_private_key_size) + { + result = mbedtls_mpi_read_binary(&p_pub->key.Y, + &p_raw_data[p_info->raw_private_key_size], + p_info->raw_private_key_size); + } + + if (result != 0) + { + goto error_exit; + } + + result = mbedtls_mpi_lset(&p_pub->key.Z, 1); + + if (result == 0) + { + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + goto error_exit; + } + result = mbedtls_ecp_check_pubkey(&group, &p_pub->key); + mbedtls_ecp_group_free(&group); + } + + if (result != 0) + { + goto error_exit; + } + return NRF_SUCCESS; + +error_exit: + mbedtls_ecp_point_free(&p_pub->key); + return NRF_ERROR_CRYPTO_INTERNAL; +} + + +ret_code_t nrf_crypto_backend_mbedtls_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + int result; + + nrf_crypto_backend_mbedtls_ecc_public_key_t const * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t const *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + result = mbedtls_mpi_write_binary(&p_pub->key.X, + p_raw_data, + p_info->raw_private_key_size); + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if (p_info->raw_public_key_size > p_info->raw_private_key_size) + { + result = mbedtls_mpi_write_binary(&p_pub->key.Y, + &p_raw_data[p_info->raw_private_key_size], + p_info->raw_private_key_size); + } + +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED && !NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + + if (p_info == &g_nrf_crypto_ecc_curve25519_curve_info) + { + nrf_crypto_internal_swap_endian_in_place(p_raw_data, + NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE); + } + +#endif + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_mbedtls_private_key_free( + void * p_private_key) +{ + nrf_crypto_backend_mbedtls_ecc_private_key_t * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t *)p_private_key; + + mbedtls_mpi_free(&p_prv->key); + return NRF_SUCCESS; +} + +ret_code_t nrf_crypto_backend_mbedtls_public_key_free( + void * p_public_key) +{ + nrf_crypto_backend_mbedtls_ecc_public_key_t * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t *)p_public_key; + + mbedtls_ecp_point_free(&p_pub->key); + return NRF_SUCCESS; +} + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP192R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP224R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP256R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp384r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP384R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP384R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP384R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP384R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp521r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP521R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP521R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP521R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP521R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP192K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP192K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP192K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP192K1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP224K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP224K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP224K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP224K1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_SECP256K1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_BP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_BP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_BP256R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_BP256R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp384r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_BP384R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_BP384R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_BP384R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_BP384R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp512r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_BP512R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_BP512R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_BP512R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_BP512R1, +}; +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_curve25519_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_mbedtls_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)MBEDTLS_ECP_DP_CURVE25519, +}; +#endif + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.h new file mode 100644 index 0000000..b511ba1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecc.h @@ -0,0 +1,519 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_ECC_H__ +#define MBEDTLS_BACKEND_ECC_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include +#include +#include "nrf_crypto_ecc_shared.h" + +/*lint -save -e????*/ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif +#include "mbedtls/ecp.h" +/*lint -restore*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal @brief Common structure holding private key for mbed TLS. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + mbedtls_mpi key; /**< @internal @brief mbed TLS specific key representation */ +} nrf_crypto_backend_mbedtls_ecc_private_key_t; + + +/** @internal @brief Common structure holding public key for mbed TLS. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + mbedtls_ecp_point key; /**< @internal @brief mbed TLS specific key representation */ +} nrf_crypto_backend_mbedtls_ecc_public_key_t; + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_mbedtls_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_calculate_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_key_free_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_private_key_free( + void * p_private_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_key_free_fn_t. +*/ +ret_code_t nrf_crypto_backend_mbedtls_public_key_free( + void * p_public_key); + + +/** @internal @brief Loads mbed TLS ECC group of specified curve type. + * + * @param[out] p_group Pointer to place where to load a group. Data have to be later deallocated. + * @param[in] curve_type ECC curve type from enum @ref nrf_crypto_ecc_curve_type_t. + * @returns true on success, false if curve is not supported or no found in mbed TLS. + */ +bool nrf_crypto_backend_mbedtls_ecc_group_load( + mbedtls_ecp_group * p_group, + struct nrf_crypto_ecc_curve_info_s const * p_info); + + +/** @internal @brief Function that can be used as a parameter to mbed TLS functions requiring random + * number generator. + * + * It uses RNG from libary front end to generate random numbers. + * + * @param[in] p_param Opaque pointer passed by mbed TLS. Unused by this implementation. + * @param[out] p_data Pointer where to put random number. + * @returns 0 on success, mbed TLS error code on error. + */ +int nrf_crypto_backend_mbedtls_ecc_mbedtls_rng(void * p_param, unsigned char * p_data, size_t size); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP192R1) +#error "More than one backend enabled for secp192r1 (NIST 192-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP192R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp192r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp192r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp192r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp192r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp192r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp192r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp192r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp192r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP192R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp192r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp192r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp192r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp192r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP224R1) +#error "More than one backend enabled for secp224r1 (NIST 224-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP224R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp224r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp224r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp224r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp224r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp224r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp224r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp224r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp224r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP224R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp224r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp224r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp224r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp224r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256R1) +#error "More than one backend enabled for secp256r1 (NIST 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp256r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp256r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp256r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp256r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp256r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp256r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp256r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp256r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp256r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp256r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP384R1) +#error "More than one backend enabled for secp384r1 (NIST 384-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP384R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp384r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp384r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp384r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp384r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp384r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp384r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp384r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp384r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp384r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp384r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp384r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp384r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP521R1) +#error "More than one backend enabled for secp521r1 (NIST 521-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP521R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp521r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp521r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp521r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp521r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp521r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp521r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp521r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp521r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP521R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP521R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp521r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp521r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp521r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp521r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP192K1) +#error "More than one backend enabled for secp192k1 (Koblitz 192-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP192K1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp192k1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp192k1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp192k1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp192k1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp192k1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp192k1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp192k1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp192k1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP192K1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp192k1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp192k1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp192k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp192k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP224K1) +#error "More than one backend enabled for secp224k1 (Koblitz 224-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP224K1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp224k1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp224k1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp224k1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp224k1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp224k1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp224k1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp224k1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp224k1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP224K1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp224k1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp224k1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp224k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp224k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256K1) +#error "More than one backend enabled for secp256k1 (Koblitz 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256K1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp256k1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_secp256k1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_secp256k1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_secp256k1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_secp256k1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_secp256k1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_secp256k1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_secp256k1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP256K1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_secp256k1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_secp256k1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_BP256R1) +#error "More than one backend enabled for bp256r1 (Brainpool 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_BP256R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_bp256r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_bp256r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_bp256r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_bp256r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_bp256r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_bp256r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_bp256r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_bp256r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_BP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_bp256r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_bp256r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_bp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_bp256r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_BP384R1) +#error "More than one backend enabled for bp384r1 (Brainpool 384-bit)."); +#endif +#define NRF_CRYPTO_ECC_BP384R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_bp384r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_bp384r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_bp384r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_bp384r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_bp384r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_bp384r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_bp384r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_bp384r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_BP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_bp384r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_bp384r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_bp384r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_bp384r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_BP512R1) +#error "More than one backend enabled for bp512r1 (Brainpool 512-bit)."); +#endif +#define NRF_CRYPTO_ECC_BP512R1_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_bp512r1_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_bp512r1_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_bp512r1_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_bp512r1_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_bp512r1_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_bp512r1_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_bp512r1_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_bp512r1_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_BP512R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP512R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_bp512r1_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_bp512r1_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_bp512r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_bp512r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_CURVE25519) +#error "More than one backend enabled for Curve25519."); +#endif +#define NRF_CRYPTO_ECC_CURVE25519_ENABLED 1 + +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_curve25519_key_pair_generate nrf_crypto_backend_mbedtls_key_pair_generate +#define nrf_crypto_backend_curve25519_public_key_calculate nrf_crypto_backend_mbedtls_public_key_calculate +#define nrf_crypto_backend_curve25519_private_key_from_raw nrf_crypto_backend_mbedtls_private_key_from_raw +#define nrf_crypto_backend_curve25519_private_key_to_raw nrf_crypto_backend_mbedtls_private_key_to_raw +#define nrf_crypto_backend_curve25519_public_key_from_raw nrf_crypto_backend_mbedtls_public_key_from_raw +#define nrf_crypto_backend_curve25519_public_key_to_raw nrf_crypto_backend_mbedtls_public_key_to_raw +#define nrf_crypto_backend_curve25519_private_key_free nrf_crypto_backend_mbedtls_private_key_free +#define nrf_crypto_backend_curve25519_public_key_free nrf_crypto_backend_mbedtls_public_key_free +// mbed TLS does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_CURVE25519_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All MBEDTLS curve types share the same data structures +typedef nrf_crypto_backend_mbedtls_ecc_private_key_t nrf_crypto_backend_curve25519_private_key_t; +typedef nrf_crypto_backend_mbedtls_ecc_public_key_t nrf_crypto_backend_curve25519_public_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_curve25519_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_curve25519_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#endif // MBEDTLS_BACKEND_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.c new file mode 100644 index 0000000..9dc1a69 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.c @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdh_shared.h" +#include "nrf_crypto_shared.h" +#include "nrf_crypto_ecdh.h" + +/*lint -save -e????*/ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif +#include "mbedtls/ecp.h" +#include "mbedtls/ecdh.h" +/*lint -restore*/ + + +ret_code_t nrf_crypto_backend_mbedtls_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + int result; + mbedtls_mpi shared_secret_mpi; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_private_key_t const * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t const *)p_private_key; + + nrf_crypto_backend_mbedtls_ecc_public_key_t const * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t const *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + mbedtls_mpi_init(&shared_secret_mpi); + result = mbedtls_ecdh_compute_shared(&group, + &shared_secret_mpi, + &p_pub->key, + &p_prv->key, + nrf_crypto_backend_mbedtls_ecc_mbedtls_rng, + NULL); + + if (result == 0) + { + result = mbedtls_mpi_write_binary(&shared_secret_mpi, + p_shared_secret, + p_info->raw_private_key_size); + } + +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED && !NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + + if (p_info == &g_nrf_crypto_ecc_curve25519_curve_info) + { + nrf_crypto_internal_swap_endian_in_place(p_shared_secret, + NRF_CRYPTO_ECDH_CURVE25519_SHARED_SECRET_SIZE); + } + +#endif + + mbedtls_mpi_free(&shared_secret_mpi); + mbedtls_ecp_group_free(&group); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.h new file mode 100644 index 0000000..1ddb206 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdh.h @@ -0,0 +1,169 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_ECDH_H__ +#define MBEDTLS_BACKEND_ECDH_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal See @ref nrf_crypto_backend_ecdh_compute_fn_t. + */ +ret_code_t nrf_crypto_backend_mbedtls_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp192r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp192r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP192R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp224r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp224r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP224R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp256r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp384r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp384r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP384R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp521r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp521r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP521R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp192k1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp192k1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP192K1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp224k1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp224k1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP224K1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_secp256k1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp256k1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256K1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_bp256r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_bp256r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_BP256R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_bp384r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_bp384r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_BP384R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_bp512r1_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_bp512r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_BP512R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) +// Aliases for one common MBEDTLS implementation +#define nrf_crypto_backend_curve25519_ecdh_compute nrf_crypto_backend_mbedtls_ecdh_compute +typedef uint32_t nrf_crypto_backend_curve25519_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_CURVE25519_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#endif // MBEDTLS_BACKEND_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.c new file mode 100644 index 0000000..4ffbd04 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.c @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdsa.h" + +/*lint -save -e????*/ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif +#include "mbedtls/ecp.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +/*lint -restore*/ + + +ret_code_t nrf_crypto_backend_mbedtls_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature) +{ + int result; + mbedtls_mpi r_mpi; + mbedtls_mpi s_mpi; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_private_key_t const * p_prv = + (nrf_crypto_backend_mbedtls_ecc_private_key_t const *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + mbedtls_mpi_init(&r_mpi); + mbedtls_mpi_init(&s_mpi); + result = mbedtls_ecdsa_sign(&group, + &r_mpi, + &s_mpi, + &p_prv->key, + p_data, + data_size, + nrf_crypto_backend_mbedtls_ecc_mbedtls_rng, + NULL); + + mbedtls_ecp_group_free(&group); + + if (result == 0) + { + result = mbedtls_mpi_write_binary(&r_mpi, p_signature, p_info->raw_private_key_size); + if (result == 0) + { + result = mbedtls_mpi_write_binary(&s_mpi, + &p_signature[p_info->raw_private_key_size], + p_info->raw_private_key_size); + } + } + + mbedtls_mpi_free(&r_mpi); + mbedtls_mpi_free(&s_mpi); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_mbedtls_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + int result; + mbedtls_mpi r_mpi; + mbedtls_mpi s_mpi; + mbedtls_ecp_group group; + + nrf_crypto_backend_mbedtls_ecc_public_key_t const * p_pub = + (nrf_crypto_backend_mbedtls_ecc_public_key_t const *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if (!nrf_crypto_backend_mbedtls_ecc_group_load(&group, p_info)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + mbedtls_mpi_init(&r_mpi); + mbedtls_mpi_init(&s_mpi); + + result = mbedtls_mpi_read_binary(&r_mpi, p_signature, p_info->raw_private_key_size); + if (result == 0) + { + result = mbedtls_mpi_read_binary(&s_mpi, + &p_signature[p_info->raw_private_key_size], + p_info->raw_private_key_size); + if (result == 0) + { + result = mbedtls_ecdsa_verify(&group, p_data, data_size, &p_pub->key, &r_mpi, &s_mpi); + } + } + + mbedtls_ecp_group_free(&group); + mbedtls_mpi_free(&r_mpi); + mbedtls_mpi_free(&s_mpi); + + if (result == MBEDTLS_ERR_ECP_VERIFY_FAILED) + { + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + } + else if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.h new file mode 100644 index 0000000..fc29724 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_ecdsa.h @@ -0,0 +1,240 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_ECDSA_H__ +#define MBEDTLS_BACKEND_ECDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal See @ref nrf_crypto_backend_ecdsa_sign_fn_t. + */ +ret_code_t nrf_crypto_backend_mbedtls_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature); + + +/** @internal See @ref nrf_crypto_backend_ecdsa_verify_fn_t. + */ +ret_code_t nrf_crypto_backend_mbedtls_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP192R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp192r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp192r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp192r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp192r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp224r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp224r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp224r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp224r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp256r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp256r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp256r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP384R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP384R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp384r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp384r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp384r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp384r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP521R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP521R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp521r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp521r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp521r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp521r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP192K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp192k1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp192k1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp192k1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp192k1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP224K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp224k1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp224k1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp224k1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp224k1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP256K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp256k1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp256k1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_secp256k1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_secp256k1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_BP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP256R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_bp256r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_bp256r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_bp256r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_bp256r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_BP384R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP384R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_bp384r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_bp384r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_bp384r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_bp384r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_BP512R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP512R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_bp512r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_bp512r1_verify_context_t; +// Alias for common mbed TLS +#define nrf_crypto_backend_bp512r1_sign nrf_crypto_backend_mbedtls_sign +#define nrf_crypto_backend_bp512r1_verify nrf_crypto_backend_mbedtls_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519) +// Context is not used by mbed TLS, so its size is 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_curve25519_sign_context_t; +typedef uint32_t nrf_crypto_backend_curve25519_verify_context_t; +// No ECDSA implementation for Curve25519 +#define nrf_crypto_backend_curve25519_sign NULL +#define nrf_crypto_backend_curve25519_verify NULL +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#endif // MBEDTLS_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.c new file mode 100644 index 0000000..63e8e8f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.c @@ -0,0 +1,196 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include "mbedtls_backend_hash.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_hash_shared.h" +#include "sdk_macros.h" +#include "nrf_log.h" +#include "nrf_assert.h" + +/*lint -save -e????*/ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "mbedtls/md.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +/*lint -restore*/ + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256) + +static ret_code_t mbedtls_backend_hash_sha256_init(void * const p_context) +{ + // No parameter testing on this level. + // This has been done on upper level. + + mbedtls_sha256_context * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + mbedtls_sha256_init(p_backend_context); + + mbedtls_sha256_starts(p_backend_context, 0); + + return NRF_SUCCESS; +} + +static uint32_t mbedtls_backend_hash_sha256_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + mbedtls_sha256_context * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + mbedtls_sha256_update(p_backend_context, p_data, size); + + return NRF_SUCCESS; +} + + +static uint32_t mbedtls_backend_hash_sha256_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + mbedtls_sha256_context * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + mbedtls_sha256_finish(p_backend_context, p_digest); + + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA256; + + return NRF_SUCCESS; +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info = +{ + .init_fn = mbedtls_backend_hash_sha256_init, + .update_fn = mbedtls_backend_hash_sha256_update, + .finalize_fn = mbedtls_backend_hash_sha256_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_hash_sha256_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA256 +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512) + + +static ret_code_t mbedtls_backend_hash_sha512_init(void * p_context) +{ + // No parameter testing on this level. + // This has been done on upper level. + + mbedtls_sha512_context * p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + mbedtls_sha512_init(p_backend_context); + + mbedtls_sha512_starts(p_backend_context, 0); + + return NRF_SUCCESS; +} + + +static ret_code_t mbedtls_backend_hash_sha512_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + mbedtls_sha512_context * p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + mbedtls_sha512_update(p_backend_context, p_data, size); + + return NRF_SUCCESS; +} + + +static ret_code_t mbedtls_backend_hash_sha512_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + mbedtls_sha512_context * p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + mbedtls_sha512_finish(p_backend_context, p_digest); + + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA512; + + return NRF_SUCCESS; +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha512_info = +{ + .init_fn = mbedtls_backend_hash_sha512_init, + .update_fn = mbedtls_backend_hash_sha512_update, + .finalize_fn = mbedtls_backend_hash_sha512_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA512, + .context_size = sizeof(nrf_crypto_backend_hash_sha512_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA512 +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.h new file mode 100644 index 0000000..dd741ce --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hash.h @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_HASH_H__ +#define MBEDTLS_BACKEND_HASH_H__ + +/** @file + * + * @defgroup nrf_crypto_mbedtls_backend_hash nrf_crypto mbedtls backend hash + * @{ + * @ingroup nrf_crypto_mbedtls_backend + * + * @brief Hash functionality provided by the nrf_crypto mbedtls backend. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include "sdk_errors.h" +#include "nrf_crypto_hash_shared.h" + +/*lint -save -e????*/ +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +/*lint -restore*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Duplicate backend enabled test for SHA-256 +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA256) +#error "Duplicate definition of SHA-256. More than one backend enabled"); +#endif + +// Flag that SHA-256 is enabled in backend +#define NRF_CRYPTO_HASH_SHA256_ENABLED 1 + + +/**brief nrf_crypto_hash context for SHA-256 in nrf_crypto mbedtls backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + mbedtls_sha256_context context; /**< Hash context internal to mbedtls. */ +} nrf_crypto_backend_hash_sha256_context_t; + + +#endif // NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Duplicate backend enabled test for SHA-512 +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA512) +#error "Duplicate definition of SHA-512. More than one backend enabled"); +#endif + +// Flag that SHA-512 is enabled in backend +#define NRF_CRYPTO_HASH_SHA512_ENABLED 1 + + +/**brief nrf_crypto_hash context for SHA-512 in nrf_crypto mbedtls backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + mbedtls_sha512_context context; /**< Hash context internal to mbedtls. */ +} nrf_crypto_backend_hash_sha512_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +/**@} */ + +#endif //MBEDTLS_BACKEND_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.c new file mode 100644 index 0000000..81d553c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.c @@ -0,0 +1,230 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include "nrf_log.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include "mbedtls_backend_hmac.h" + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256) + +static ret_code_t mbedtls_backend_hmac_init_sha256(void * const p_context, + uint8_t const * p_key, + size_t key_size) +{ + int err_code; + nrf_crypto_backend_mbedtls_hmac_sha256_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_hmac_sha256_context_t *)p_context; + + // Memset context to 0. This is equevalend with a call to mbedtls_md_init(). + memset(p_ctx->md_ctx_buffer, 0, sizeof(p_ctx->md_ctx_buffer)); + memset(p_ctx->hmac_ctx_buffer, 0, sizeof(p_ctx->hmac_ctx_buffer)); + + // Set info and context pointers to buffer allocated by user. + // This is Normally handled by mbedtls_md_setup(), but has to be done here in order + // to avoid dynamic allocation of memory inside mbed TLS. + p_ctx->mbedtls_ctx.md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + p_ctx->mbedtls_ctx.md_ctx = p_ctx->md_ctx_buffer; + p_ctx->mbedtls_ctx.hmac_ctx = p_ctx->hmac_ctx_buffer; + + // Enter key to start + err_code = mbedtls_md_hmac_starts(&p_ctx->mbedtls_ctx, + p_key, + key_size); + + if (err_code != 0) + { + NRF_LOG_ERROR("Error in mbedtls_md_hmac_starts: %u", err_code); + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return NRF_SUCCESS; +} + + +static ret_code_t mbedtls_backend_hmac_update_sha256(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + int err_code; + nrf_crypto_backend_mbedtls_hmac_sha256_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_hmac_sha256_context_t *)p_context; + + err_code = mbedtls_md_hmac_update(&p_ctx->mbedtls_ctx, p_data, size); + if (err_code != 0) + { + NRF_LOG_ERROR("Error in mbedtls_md_hmac_update: %u", err_code); + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return NRF_SUCCESS; +} + + +static ret_code_t mbedtls_backend_hmac_finalize_sha256(void * const p_context, + uint8_t * p_digest, + size_t * const p_size) +{ + int err_code; + nrf_crypto_backend_mbedtls_hmac_sha256_context_t * const p_ctx = + (nrf_crypto_backend_mbedtls_hmac_sha256_context_t *)p_context; + + // Set the digest length to 0 so that this is used in case of any error. + *p_size = 0; + + err_code = mbedtls_md_hmac_finish(&p_ctx->mbedtls_ctx, p_digest); + if (err_code != 0) + { + NRF_LOG_ERROR("Error in mbedtls_md_hmac_finish: %u", err_code); + return NRF_ERROR_CRYPTO_INTERNAL; + } + + *p_size = p_ctx->header.p_info->digest_size; + + return NRF_SUCCESS; +} + + +// Information structure for HMAC SHA256 using mbed TLS backend. +const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha256_info = +{ + .init_fn = mbedtls_backend_hmac_init_sha256, + .update_fn = mbedtls_backend_hmac_update_sha256, + .finalize_fn = mbedtls_backend_hmac_finalize_sha256, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_hmac_sha256_context_t), + .type = NRF_CRYPTO_HMAC_SHA256_TYPE +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256) + + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512) + +static ret_code_t mbedtls_backend_hmac_init_sha512(void * const p_context, + uint8_t const * p_key, + size_t key_size) +{ + int err_code; + nrf_crypto_backend_mbedtls_hmac_sha512_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_hmac_sha512_context_t *)p_context; + + // Memset context to 0. This is equevalend with a call to mbedtls_md_init(). + memset(p_ctx->md_ctx_buffer, 0, sizeof(p_ctx->md_ctx_buffer)); + memset(p_ctx->hmac_ctx_buffer, 0, sizeof(p_ctx->hmac_ctx_buffer)); + + // Set info and context pointers to buffer allocated by user. + // (Normally handled by mbedtls_md_setup()) + p_ctx->mbedtls_ctx.md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA512); + p_ctx->mbedtls_ctx.md_ctx = p_ctx->md_ctx_buffer; + p_ctx->mbedtls_ctx.hmac_ctx = p_ctx->hmac_ctx_buffer; + + // Enter key to start + err_code = mbedtls_md_hmac_starts(&p_ctx->mbedtls_ctx, p_key, key_size); + if (err_code != 0) + { + NRF_LOG_ERROR("Error in mbedtls_md_hmac_starts: %u", err_code); + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return NRF_SUCCESS; +} + + +static ret_code_t mbedtls_backend_hmac_update_sha512(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + int err_code; + nrf_crypto_backend_mbedtls_hmac_sha512_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_hmac_sha512_context_t *)p_context; + + err_code = mbedtls_md_hmac_update(&p_ctx->mbedtls_ctx, p_data, size); + if (err_code != 0) + { + NRF_LOG_ERROR("Error in mbedtls_md_hmac_update: %u", err_code); + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return NRF_SUCCESS; +} + + +static ret_code_t mbedtls_backend_hmac_finalize_sha512(void * const p_context, + uint8_t * p_digest, + size_t * const p_size) +{ + int err_code; + nrf_crypto_backend_mbedtls_hmac_sha512_context_t * p_ctx = + (nrf_crypto_backend_mbedtls_hmac_sha512_context_t *)p_context; + + // Set the digest length to 0 so that this is used in case of any error. + *p_size = 0; + + err_code = mbedtls_md_hmac_finish(&p_ctx->mbedtls_ctx, p_digest); + if (err_code != 0) + { + NRF_LOG_ERROR("Error in mbedtls_md_hmac_finish: %u", err_code); + return NRF_ERROR_CRYPTO_INTERNAL; } + + *p_size = p_ctx->header.p_info->digest_size; + + return NRF_SUCCESS; +} + + +// Information structure for HMAC SHA512 using mbed TLS backend. +const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha512_info = +{ + .init_fn = mbedtls_backend_hmac_init_sha512, + .update_fn = mbedtls_backend_hmac_update_sha512, + .finalize_fn = mbedtls_backend_hmac_finalize_sha512, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA512, + .context_size = sizeof(nrf_crypto_backend_hmac_sha512_context_t), + .type = NRF_CRYPTO_HMAC_SHA512_TYPE +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.h new file mode 100644 index 0000000..3ab1367 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_hmac.h @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2018 - 2019, 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 MBEDTLS_BACKEND_HMAC_H__ +#define MBEDTLS_BACKEND_HMAC_H__ + +/** @file + * + * @defgroup nrf_crypto_mbedtls_backend_hmac mbed TLS backend for HMAC + * @{ + * @ingroup nrf_crypto_mbedtls_backend + * + * @brief Backend wrapper for mbed TLS. None of these types should be used directly by the + * application. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) && \ + ( NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512) ) + +#include "nrf_crypto_hmac_shared.h" +/*lint -save -e????*/ +#include "mbedtls/md.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +/*lint -restore*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#undef NRF_CRYPTO_HMAC_ENABLED +#define NRF_CRYPTO_HMAC_ENABLED 1 + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC_SHA256) +#error "Duplicate definition of HMAC SHA-256. More than one backend enabled" +#endif // NRF_CRYPTO_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_HMAC_SHA256_ENABLED 1 + +/** + * @internal @brief Internal context object used by the mbed TLS backend wrapper for HMAC SHA256. + * + * @note This should never be used directly. Use @ref nrf_crypto_backend_hmac_sha256_context_t + * instead. + */ +typedef struct +{ + nrf_crypto_hmac_internal_context_t header; //!< Internal nrf_crypto_hmac context. + mbedtls_md_context_t mbedtls_ctx; //!< Mbed TLS context object. + uint8_t md_ctx_buffer[sizeof(mbedtls_sha256_context)]; //!< Message digest buffer for mbed TLS. + uint16_t hmac_ctx_buffer[64]; //!< Hash buffer for mbed TLS of size defined in mbedtls_sha256_info in md_internal.h. +} nrf_crypto_backend_mbedtls_hmac_sha256_context_t; + +/** + * @internal @brief Context for HMAC SHA256 using mbed TLS backend. + */ +typedef nrf_crypto_backend_mbedtls_hmac_sha256_context_t nrf_crypto_backend_hmac_sha256_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256) + + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC_SHA512) +#error "Duplicate definition of HMAC SHA-512. More than one backend enabled" +#endif // NRF_CRYPTO_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_HMAC_SHA512_ENABLED 1 + +/** + * @internal @brief Internal context object used by the mbed TLS backend wrapper for HMAC SHA512. + * + * @note This should never be used directly. Use @ref nrf_crypto_backend_hmac_sha512_context_t + * instead. + */ +typedef struct +{ + nrf_crypto_hmac_internal_context_t header; //!< Internal nrf_crypto_hmac context header. + mbedtls_md_context_t mbedtls_ctx; //!< Mbed TLS context object. + uint8_t md_ctx_buffer[sizeof(mbedtls_sha512_context)]; //!< Message digest buffer for mbed TLS. + uint16_t hmac_ctx_buffer[128]; //!< Hash buffer for mbed TLS of size defined in mbedtls_sha512_info in md_internal.h. +} nrf_crypto_backend_mbedtls_hmac_sha512_context_t; + +/** + * @internal @brief Context for HMAC SHA512 using mbed TLS backend. + */ +typedef nrf_crypto_backend_mbedtls_hmac_sha512_context_t nrf_crypto_backend_hmac_sha512_context_t; + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) && ( NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512) ) + +/**@} */ + +#endif // MBEDTLS_BACKEND_HMAC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_init.c new file mode 100644 index 0000000..bf8ed55 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/mbedtls/mbedtls_backend_init.c @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2018 - 2019, 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" +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) + +#include +#include +#include "nrf_crypto_init.h" +#include "nrf_crypto_mem.h" +/*lint -save -e????*/ +#include "mbedtls/platform.h" +/*lint -restore*/ + + +#if NRF_CRYPTO_ALLOC_ON_STACK +#error "MBED TLS backend does not support memory allocation on stack. Use different allocator." +#endif + + +/** @internal @brief Function to use NRF_CRYPTO_ALLOC for MBED TLS memory allocation. + */ +static void * mbedtls_backend_calloc(size_t count, size_t size) +{ + size_t total_size = count * size; + void * p_data = NRF_CRYPTO_ALLOC(total_size); + if (p_data != NULL) + { + memset(p_data, 0, total_size); + } + return p_data; +} + + +/** @internal @brief Function to use NRF_CRYPTO_FREE for MBED TLS memory deallocation. + */ +static void mbedtls_backend_free(void * p_data) +{ + NRF_CRYPTO_FREE(p_data); +} + + +/** @internal @brief Function to initialize MBED TLS backend - setup memory management for. + */ +static ret_code_t mbedtls_backend_init(void) +{ + (void)mbedtls_platform_set_calloc_free(mbedtls_backend_calloc, mbedtls_backend_free); + return NRF_SUCCESS; +} + + +/** @internal @brief Function to uninitialize MBED TLS backend - currently no implementation is required. + */ +static ret_code_t mbedtls_backend_uninit(void) +{ + // Empty implementation + return NRF_SUCCESS; +} + + +CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const mbedtls_backend) = +{ + .init_fn = mbedtls_backend_init, + .uninit_fn = mbedtls_backend_uninit, +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c new file mode 100644 index 0000000..161adb4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c @@ -0,0 +1,341 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#include +#include +#include + +#include "app_util.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_shared.h" +#include "micro_ecc_backend_ecc.h" +#include "micro_ecc_backend_shared.h" +#include "uECC.h" + + +typedef uECC_Curve (*micro_ecc_curve_fn_t)(void); + + +int nrf_crypto_backend_micro_ecc_rng_callback(uint8_t * dest, unsigned size) +{ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + + ret_code_t result; + + result = nrf_crypto_rng_vector_generate(dest, size); + + // Return values compatible with mbed TLS + if (result != NRF_SUCCESS) + { + return 0; + } + return 1; + +#else + UNUSED_PARAMETER(dest); + UNUSED_PARAMETER(size); + return 0; +#endif +} + + +uECC_Curve nrf_crypto_backend_micro_ecc_curve_get( + nrf_crypto_backend_micro_ecc_common_key_t const * p_key) +{ + nrf_crypto_internal_ecc_key_header_t const * p_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_key; + + //lint -save -e611 (Suspicious cast) + micro_ecc_curve_fn_t micro_ecc_curve_fn = + (micro_ecc_curve_fn_t)p_key_header->p_info->p_backend_data; + //lint -restore + + uECC_Curve p_micro_ecc_curve = micro_ecc_curve_fn(); + + return p_micro_ecc_curve; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + int result; + + nrf_crypto_backend_micro_ecc_common_key_t * p_prv = + (nrf_crypto_backend_micro_ecc_common_key_t *)p_private_key; + nrf_crypto_backend_micro_ecc_common_key_t * p_pub = + (nrf_crypto_backend_micro_ecc_common_key_t *)p_public_key; + + uECC_Curve p_micro_ecc_curve = nrf_crypto_backend_micro_ecc_curve_get(p_prv); + + uECC_set_rng(nrf_crypto_backend_micro_ecc_rng_callback); + + result = uECC_make_key((uint8_t *)(&p_pub->key[0]), + (uint8_t *)(&p_prv->key[0]), + p_micro_ecc_curve); + + if (result == 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + int result; + + nrf_crypto_backend_micro_ecc_common_key_t const * p_prv = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_private_key; + nrf_crypto_backend_micro_ecc_common_key_t * p_pub = + (nrf_crypto_backend_micro_ecc_common_key_t *)p_public_key; + + uECC_Curve p_micro_ecc_curve = nrf_crypto_backend_micro_ecc_curve_get(p_prv); + + result = uECC_compute_public_key((uint8_t *)(&p_prv->key[0]), + (uint8_t *)(&p_pub->key[0]), + p_micro_ecc_curve); + + if (result == 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_micro_ecc_common_key_t * p_prv = + (nrf_crypto_backend_micro_ecc_common_key_t *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + +#if ECC_BACKEND_SWAP_BYTES + nrf_crypto_internal_swap_endian((uint8_t *)(&p_prv->key[0]), + p_raw_data, + p_info->raw_private_key_size); +#else + memcpy(&p_prv->key[0], p_raw_data, p_info->raw_private_key_size); +#endif + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_micro_ecc_common_key_t const * p_prv = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + +#if ECC_BACKEND_SWAP_BYTES + nrf_crypto_internal_swap_endian(p_raw_data, + (uint8_t *)(&p_prv->key[0]), + p_info->raw_private_key_size); +#else + memcpy(p_raw_data, &p_prv->key[0], p_info->raw_private_key_size); +#endif + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_micro_ecc_common_key_t * p_pub = + (nrf_crypto_backend_micro_ecc_common_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + +#if ECC_BACKEND_SWAP_BYTES + nrf_crypto_internal_double_swap_endian((uint8_t *)(&p_pub->key[0]), + p_raw_data, + p_info->raw_private_key_size); +#else + memcpy(&p_pub->key[0], p_raw_data, p_info->raw_public_key_size); +#endif + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_micro_ecc_common_key_t const * p_pub = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + +#if ECC_BACKEND_SWAP_BYTES + nrf_crypto_internal_double_swap_endian(p_raw_data, + (uint8_t *)(&p_pub->key[0]), + p_info->raw_private_key_size); +#else + memcpy(p_raw_data, &p_pub->key[0], p_info->raw_public_key_size); +#endif + + return NRF_SUCCESS; +} + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1) + +// Make sure that common key structure match secp192r1 (NIST 192-bit) key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp192r1_private_key_t, key), + "Common uECC private key structure does not match secp192r1 (NIST 192-bit) one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp192r1_public_key_t, key), + "Common ECC public key structure does not match secp192r1 (NIST 192-bit) one."); + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp192r1_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_secp192r1_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE, + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&uECC_secp192r1, + //lint -restore +}; + +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1) + +// Make sure that common key structure match secp224r1 (NIST 224-bit) key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp224r1_private_key_t, key), + "Common uECC private key structure does not match secp224r1 (NIST 224-bit) one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp224r1_public_key_t, key), + "Common ECC public key structure does not match secp224r1 (NIST 224-bit) one."); + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp224r1_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_secp224r1_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE, + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&uECC_secp224r1, + //lint -restore +}; + +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1) + +// Make sure that common key structure match secp256r1 (NIST 256-bit) key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp256r1_private_key_t, key), + "Common uECC private key structure does not match secp256r1 (NIST 256-bit) one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp256r1_public_key_t, key), + "Common ECC public key structure does not match secp256r1 (NIST 256-bit) one."); + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp256r1_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_secp256r1_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE, + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&uECC_secp256r1, + //lint -restore +}; + +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1) + +// Make sure that common key structure match secp256k1 (Koblitz 256-bit) key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp256k1_private_key_t, key), + "Common uECC private key structure does not match secp256k1 (Koblitz 256-bit) one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_micro_ecc_common_key_t, key) == + offsetof(nrf_crypto_backend_secp256k1_public_key_t, key), + "Common ECC public key structure does not match secp256k1 (Koblitz 256-bit) one."); + + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256k1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp256k1_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_secp256k1_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE, + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&uECC_secp256k1, + //lint -restore +}; + +#endif + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.h new file mode 100644 index 0000000..1688e5c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.h @@ -0,0 +1,303 @@ +/** + * Copyright (c) 2018 - 2019, 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 MICRO_ECC_BACKEND_ECC_H__ +#define MICRO_ECC_BACKEND_ECC_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#include +#include +#include "nrf_crypto_ecc_shared.h" +#include "uECC.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_micro_ecc_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_calculate_fn_t. +*/ +ret_code_t nrf_crypto_backend_micro_ecc_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_micro_ecc_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_micro_ecc_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_micro_ecc_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_micro_ecc_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + + +/** @internal @brief Represents common uECC backend key structure. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[1]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_micro_ecc_common_key_t; + + +/** @internal @brief Callback RNG function that can be provided to uECC API. + * @param dest Destination buffer. + * @param size Size of the buffer. + * @return 1 on success, 0 on error. + */ +int nrf_crypto_backend_micro_ecc_rng_callback(uint8_t * dest, unsigned size); + + +/** @internal @brief Gets uECC type based on provided key. + * @param p_key uECC backend key (public or private). + * @return uECC specific value representing a curve. + */ +uECC_Curve nrf_crypto_backend_micro_ecc_curve_get( + nrf_crypto_backend_micro_ecc_common_key_t const * p_key); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP192R1) +#error "More than one backend enabled for secp192r1 (NIST 192-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP192R1_ENABLED 1 + +/** @internal @brief Structure holding private key for secp192r1 (NIST 192-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[192 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp192r1_private_key_t; + +/** @internal @brief Structure holding public key for secp192r1 (NIST 192-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[2 * 192 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp192r1_public_key_t; + +// Aliases for one common micro-ecc implementation +#define nrf_crypto_backend_secp192r1_key_pair_generate nrf_crypto_backend_micro_ecc_key_pair_generate +#define nrf_crypto_backend_secp192r1_public_key_calculate nrf_crypto_backend_micro_ecc_public_key_calculate +#define nrf_crypto_backend_secp192r1_private_key_from_raw nrf_crypto_backend_micro_ecc_private_key_from_raw +#define nrf_crypto_backend_secp192r1_private_key_to_raw nrf_crypto_backend_micro_ecc_private_key_to_raw +#define nrf_crypto_backend_secp192r1_public_key_from_raw nrf_crypto_backend_micro_ecc_public_key_from_raw +#define nrf_crypto_backend_secp192r1_public_key_to_raw nrf_crypto_backend_micro_ecc_public_key_to_raw +#define nrf_crypto_backend_secp192r1_private_key_free NULL +#define nrf_crypto_backend_secp192r1_public_key_free NULL +#define NRF_CRYPTO_BACKEND_SECP192R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp192r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp192r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP224R1) +#error "More than one backend enabled for secp224r1 (NIST 224-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP224R1_ENABLED 1 + +/** @internal @brief Structure holding private key for secp224r1 (NIST 224-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[224 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp224r1_private_key_t; + +/** @internal @brief Structure holding public key for secp224r1 (NIST 224-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[2 * 224 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp224r1_public_key_t; + +// Aliases for one common micro-ecc implementation +#define nrf_crypto_backend_secp224r1_key_pair_generate nrf_crypto_backend_micro_ecc_key_pair_generate +#define nrf_crypto_backend_secp224r1_public_key_calculate nrf_crypto_backend_micro_ecc_public_key_calculate +#define nrf_crypto_backend_secp224r1_private_key_from_raw nrf_crypto_backend_micro_ecc_private_key_from_raw +#define nrf_crypto_backend_secp224r1_private_key_to_raw nrf_crypto_backend_micro_ecc_private_key_to_raw +#define nrf_crypto_backend_secp224r1_public_key_from_raw nrf_crypto_backend_micro_ecc_public_key_from_raw +#define nrf_crypto_backend_secp224r1_public_key_to_raw nrf_crypto_backend_micro_ecc_public_key_to_raw +#define nrf_crypto_backend_secp224r1_private_key_free NULL +#define nrf_crypto_backend_secp224r1_public_key_free NULL +#define NRF_CRYPTO_BACKEND_SECP224R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp224r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp224r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256R1) +#error "More than one backend enabled for secp256r1 (NIST 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 + +/** @internal @brief Structure holding private key for secp256r1 (NIST 256-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[256 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp256r1_private_key_t; + +/** @internal @brief Structure holding public key for secp256r1 (NIST 256-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[2 * 256 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp256r1_public_key_t; + +// Aliases for one common micro-ecc implementation +#define nrf_crypto_backend_secp256r1_key_pair_generate nrf_crypto_backend_micro_ecc_key_pair_generate +#define nrf_crypto_backend_secp256r1_public_key_calculate nrf_crypto_backend_micro_ecc_public_key_calculate +#define nrf_crypto_backend_secp256r1_private_key_from_raw nrf_crypto_backend_micro_ecc_private_key_from_raw +#define nrf_crypto_backend_secp256r1_private_key_to_raw nrf_crypto_backend_micro_ecc_private_key_to_raw +#define nrf_crypto_backend_secp256r1_public_key_from_raw nrf_crypto_backend_micro_ecc_public_key_from_raw +#define nrf_crypto_backend_secp256r1_public_key_to_raw nrf_crypto_backend_micro_ecc_public_key_to_raw +#define nrf_crypto_backend_secp256r1_private_key_free NULL +#define nrf_crypto_backend_secp256r1_public_key_free NULL +#define NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256K1) +#error "More than one backend enabled for secp256k1 (Koblitz 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256K1_ENABLED 1 + +/** @internal @brief Structure holding private key for secp256k1 (Koblitz 256-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[256 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp256k1_private_key_t; + +/** @internal @brief Structure holding public key for secp256k1 (Koblitz 256-bit) in micro-ecc. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + uint32_t key[2 * 256 / 32]; /**< @internal @brief micro-ecc specific key representation */ +} nrf_crypto_backend_secp256k1_public_key_t; + +// Aliases for one common micro-ecc implementation +#define nrf_crypto_backend_secp256k1_key_pair_generate nrf_crypto_backend_micro_ecc_key_pair_generate +#define nrf_crypto_backend_secp256k1_public_key_calculate nrf_crypto_backend_micro_ecc_public_key_calculate +#define nrf_crypto_backend_secp256k1_private_key_from_raw nrf_crypto_backend_micro_ecc_private_key_from_raw +#define nrf_crypto_backend_secp256k1_private_key_to_raw nrf_crypto_backend_micro_ecc_private_key_to_raw +#define nrf_crypto_backend_secp256k1_public_key_from_raw nrf_crypto_backend_micro_ecc_public_key_from_raw +#define nrf_crypto_backend_secp256k1_public_key_to_raw nrf_crypto_backend_micro_ecc_public_key_to_raw +#define nrf_crypto_backend_secp256k1_private_key_free NULL +#define nrf_crypto_backend_secp256k1_public_key_free NULL +#define NRF_CRYPTO_BACKEND_SECP256K1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256k1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#endif // MICRO_ECC_BACKEND_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c new file mode 100644 index 0000000..df691ae --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#include + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdh_shared.h" +#include "nrf_crypto_ecdh.h" +#include "nrf_crypto_shared.h" +#include "micro_ecc_backend_ecc.h" +#include "micro_ecc_backend_shared.h" +#include "uECC.h" + + +ret_code_t nrf_crypto_backend_micro_ecc_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + int result; + + nrf_crypto_backend_micro_ecc_common_key_t const * p_prv = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_private_key; + nrf_crypto_backend_micro_ecc_common_key_t const * p_pub = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + uECC_Curve p_micro_ecc_curve = nrf_crypto_backend_micro_ecc_curve_get(p_prv); + + // Check that the public key is valid + if (!uECC_valid_public_key((uint8_t *)(&p_pub->key[0]), p_micro_ecc_curve)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + result = uECC_shared_secret((uint8_t const *)(&p_pub->key[0]), + (uint8_t const *)(&p_prv->key[0]), + p_shared_secret, + p_micro_ecc_curve); + +#if ECC_BACKEND_SWAP_BYTES + nrf_crypto_internal_swap_endian_in_place(p_shared_secret, p_info->raw_private_key_size); +#else + UNUSED_PARAMETER(p_info); +#endif + + if (result == 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + + + + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.h new file mode 100644 index 0000000..468a6bf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.h @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2018 - 2019, 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 MICRO_ECC_BACKEND_ECDH_H__ +#define MICRO_ECC_BACKEND_ECDH_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal See @ref nrf_crypto_backend_ecdh_compute_fn_t. + */ +ret_code_t nrf_crypto_backend_micro_ecc_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1) +// Aliases for one common MICRO_ECC implementation +#define nrf_crypto_backend_secp192r1_ecdh_compute nrf_crypto_backend_micro_ecc_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp192r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP192R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1) +// Aliases for one common MICRO_ECC implementation +#define nrf_crypto_backend_secp224r1_ecdh_compute nrf_crypto_backend_micro_ecc_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp224r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP224R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1) +// Aliases for one common MICRO_ECC implementation +#define nrf_crypto_backend_secp256r1_ecdh_compute nrf_crypto_backend_micro_ecc_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1) +// Aliases for one common MICRO_ECC implementation +#define nrf_crypto_backend_secp256k1_ecdh_compute nrf_crypto_backend_micro_ecc_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp256k1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256K1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#endif // MICRO_ECC_BACKEND_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c new file mode 100644 index 0000000..0141cfc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c @@ -0,0 +1,166 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#include +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdsa.h" +#include "nrf_crypto_shared.h" +#include "nrf_crypto_mem.h" +#include "micro_ecc_backend_ecc.h" +#include "micro_ecc_backend_shared.h" +#include "uECC.h" + + +ret_code_t nrf_crypto_backend_micro_ecc_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature) +{ + int result; + + nrf_crypto_backend_micro_ecc_common_key_t const * p_prv = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_private_key; + + uECC_Curve p_micro_ecc_curve = nrf_crypto_backend_micro_ecc_curve_get(p_prv); + +#if ECC_BACKEND_SWAP_BYTES + + nrf_crypto_ecc_curve_info_t const * p_info = p_prv->header.p_info; + + size_t hash_size = MIN(data_size, p_info->raw_private_key_size); + uint8_t hash_le[NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE]; + + nrf_crypto_internal_swap_endian(hash_le, p_data, hash_size); + + uECC_set_rng(nrf_crypto_backend_micro_ecc_rng_callback); + + result = uECC_sign((uint8_t const *)(&p_prv->key[0]), + hash_le, + hash_size, + p_signature, + p_micro_ecc_curve); + + nrf_crypto_internal_double_swap_endian_in_place(p_signature, p_info->raw_private_key_size); + +#else + + uECC_set_rng(nrf_crypto_backend_micro_ecc_rng_callback); + + result = uECC_sign((uint8_t const *)(&p_prv->key[0]), + p_data, + data_size, + p_signature, + p_micro_ecc_curve); + +#endif + + if (result == 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_micro_ecc_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + int result; + + nrf_crypto_backend_micro_ecc_common_key_t const * p_pub = + (nrf_crypto_backend_micro_ecc_common_key_t const *)p_public_key; + + uECC_Curve p_micro_ecc_curve = nrf_crypto_backend_micro_ecc_curve_get(p_pub); + +#if ECC_BACKEND_SWAP_BYTES + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + size_t hash_size = MIN(data_size, p_info->raw_private_key_size); + uint8_t hash_le [NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE]; + uint8_t signature_le[NRF_CRYPTO_ECDSA_SIGNATURE_MAX_SIZE]; + + nrf_crypto_internal_swap_endian(hash_le, p_data, hash_size); + + nrf_crypto_internal_double_swap_endian(signature_le, + p_signature, + p_info->raw_private_key_size); + + result = uECC_verify((uint8_t const *)(&p_pub->key[0]), + hash_le, + hash_size, + signature_le, + p_micro_ecc_curve); + +#else + + result = uECC_verify((uint8_t const *)(&p_pub->key[0]), + p_data, + data_size, + p_signature, + p_micro_ecc_curve); + +#endif + + if (result == 0) + { + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + } + + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.h new file mode 100644 index 0000000..8b0f093 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.h @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2018 - 2019, 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 MICRO_ECC_BACKEND_ECDSA_H__ +#define MICRO_ECC_BACKEND_ECDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal See @ref nrf_crypto_backend_ecdsa_sign_fn_t. + */ +ret_code_t nrf_crypto_backend_micro_ecc_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature); + + +/** @internal See @ref nrf_crypto_backend_ecdsa_verify_fn_t. + */ +ret_code_t nrf_crypto_backend_micro_ecc_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1) +#define NRF_CRYPTO_BACKEND_SECP192R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192R1_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp192r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp192r1_verify_context_t; +#define nrf_crypto_backend_secp192r1_sign nrf_crypto_backend_micro_ecc_sign +#define nrf_crypto_backend_secp192r1_verify nrf_crypto_backend_micro_ecc_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1) +#define NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp224r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp224r1_verify_context_t; +#define nrf_crypto_backend_secp224r1_sign nrf_crypto_backend_micro_ecc_sign +#define nrf_crypto_backend_secp224r1_verify nrf_crypto_backend_micro_ecc_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1) +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp256r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_verify_context_t; +#define nrf_crypto_backend_secp256r1_sign nrf_crypto_backend_micro_ecc_sign +#define nrf_crypto_backend_secp256r1_verify nrf_crypto_backend_micro_ecc_verify +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1) +#define NRF_CRYPTO_BACKEND_SECP256K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256K1_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp256k1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp256k1_verify_context_t; +#define nrf_crypto_backend_secp256k1_sign nrf_crypto_backend_micro_ecc_sign +#define nrf_crypto_backend_secp256k1_verify nrf_crypto_backend_micro_ecc_verify +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) + +#endif // MICRO_ECC_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_shared.h similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_shared.h index 0cb83dc..8624e7f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_ecdsa.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_shared.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,41 +35,35 @@ * 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 CC310_LIB_ECDSA_H__ -#define CC310_LIB_ECDSA_H__ - -/** @file - * - * @defgroup nrf_crypto_backend_cc310_lib_ecdsa CC310 backend ECDSA types. - * @{ - * @ingroup nrf_crypto_backend_cryptocell * - * @brief Provides types required for CC310 backend ECDSA. */ +#ifndef MICRO_ECC_BACKEND_SHARED_H__ +#define MICRO_ECC_BACKEND_SHARED_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) -#include "nrf_crypto_ecdsa.h" +#include "uECC.h" #ifdef __cplusplus extern "C" { #endif -/** @brief Size of ECDSA signing context. - */ -#define NRF_CRYPTO_ECDSA_SIGN_CONTEXT_SIZE sizeof(ECDSA_SignUserContext_t) - +#if defined(NRF_CRYPTO_BACKEND_MICRO_ECC_LITTLE_ENDIAN_ENABLED) -/** @brief Size of ECDSA verification context. - */ -#define NRF_CRYPTO_ECDSA_VERIFY_CONTEXT_SIZE sizeof(ECDSA_VerifyUserContext_t) +#error The configuration NRF_CRYPTO_BACKEND_MICRO_ECC_LITTLE_ENDIAN_ENABLED was removed in SDK 15.1.0. Please see release notes for details on removing this error message. + +#endif +#define ECC_BACKEND_SWAP_BYTES uECC_VLI_NATIVE_LITTLE_ENDIAN #ifdef __cplusplus } #endif -/**@} */ +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MICRO_ECC) -#endif // #ifndef CC310_LIB_ECDSA_H__ +#endif // MICRO_ECC_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_init.c new file mode 100644 index 0000000..6a107b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_init.c @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) + +#include "nrf.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_rng.h" + + +static ret_code_t nrf_hw_backend_init(void) +{ +#if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) + + uint32_t ret_val; + ret_val = nrf_crypto_rng_init(NULL, NULL); + return ret_val; + +#elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0) + + return NRF_SUCCESS; + +#else + + #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_CRYPTO_RNG_AUTO_INIT_ENABLED +} + + +static ret_code_t nrf_hw_backend_uninit(void) +{ +#if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) + + uint32_t ret_val; + ret_val = nrf_crypto_rng_uninit(); + return ret_val; + +#elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0) + + return NRF_SUCCESS; + +#else + + #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_AUTO_INIT) +} + + +CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const nrf_hw_backend) = +{ + .init_fn = nrf_hw_backend_init, + .uninit_fn = nrf_hw_backend_uninit +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.c similarity index 55% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.c index d634799..2780ea3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,80 +35,67 @@ * 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(NRF_CRYPTO) +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && \ + !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) -#include "nrf_drv_rng.h" #include "nrf_crypto_rng.h" - -#if (NRF_CRYPTO_BACKEND_MICRO_ECC && NRF_CRYPTO_BACKEND_MICRO_ECC_RNG) - -#include "uECC.h" - -/** @brief Function to greate random data conformant to the format of the - * micro_ecc API. - */ -static int rng_func(uint8_t * p_target, unsigned size) -{ - uint32_t err_code; - err_code = nrf_crypto_rng_vector_generate(p_target, size); - if (err_code == NRF_SUCCESS) - { - return 1; - } - else - { - return 0; - } -} +#include "nrf_drv_rng.h" -uint32_t nrf_crypto_rng_init(void) +ret_code_t nrf_crypto_rng_backend_init(void * const p_context, + void * const p_temp_buffer) { - uint32_t ret_val; + ret_code_t ret_val; + + UNUSED_PARAMETER(p_context); + UNUSED_PARAMETER(p_temp_buffer); ret_val = nrf_drv_rng_init(NULL); - if (ret_val == NRF_SUCCESS) - { - uECC_set_rng(rng_func); - } return ret_val; } -uint32_t nrf_crypto_rng_vector_generate(uint8_t * p_target, uint32_t length) +ret_code_t nrf_crypto_rng_backend_uninit(void * const p_context) { - uint32_t err_code; - uint8_t available; - uint8_t cur_len; - uint8_t left = length; + UNUSED_PARAMETER(p_context); + + nrf_drv_rng_uninit(); - if (p_target == NULL) - { - return NRF_ERROR_NULL; - } - - do - { - nrf_drv_rng_bytes_available(&available); - cur_len = MIN(left, available); + return NRF_SUCCESS; +} - err_code = nrf_drv_rng_rand(p_target + (length - left), cur_len); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - // Remove current length of generated data - left -= cur_len; +ret_code_t nrf_crypto_rng_backend_vector_generate(void * const p_context, + uint8_t * const p_target, + size_t size, + bool use_mutex) +{ + UNUSED_PARAMETER(use_mutex); + UNUSED_PARAMETER(p_context); - } while (left > 0); + nrf_drv_rng_block_rand(p_target, size); return NRF_SUCCESS; } -#endif // NRF_CRYPTO_BACKEND_MICRO_ECC && NRF_CRYPTO_BACKEND_MICRO_ECC_RNG -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + +ret_code_t nrf_crypto_rng_backend_reseed(void * const p_context, + void * p_temp_buffer, + uint8_t * p_input_data, + size_t size) +{ + UNUSED_PARAMETER(p_context); + UNUSED_PARAMETER(p_temp_buffer); + UNUSED_PARAMETER(p_input_data); + UNUSED_PARAMETER(size); + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + +#endif //NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.h new file mode 100644 index 0000000..f9d5484 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng.h @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_HW_BACKEND_RNG_H__ +#define NRF_HW_BACKEND_RNG_H__ + +/** @file + * + * @defgroup nrf_crypto_nrf_hw_backend_rng nrf_crypto HW RNG backend + * @{ + * @ingroup nrf_crypto_backends + * + * @brief RNG functionality provided by the nrf_crypto nRF HW RNG backend. + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && \ + !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) + +#if !NRF_MODULE_ENABLED(RNG) +#error Enable RNG_ENABLED in sdk_config.h. +#endif + +#if !NRFX_RNG_CONFIG_ERROR_CORRECTION +#error Enable NRFX_RNG_CONFIG_ERROR_CORRECTION and RNG_CONFIG_ERROR_CORRECTION in sdk_config.h. +#endif + +#include "nrf_crypto_rng_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#error "More than one RNG backend enabled." +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#define NRF_CRYPTO_RNG_ENABLED 1 + + +/** + * @internal @brief Context for nRF RNG peripheral. + */ +typedef struct +{ + nrf_crypto_rng_internal_context_t header; //!< Internal common context header. +} nrf_crypto_backend_rng_context_t; + +/** + * @internal @brief Dummy temp buffer for nRF RNG peripheral. + */ +typedef struct +{ + uint32_t reserved; +} nrf_crypto_backend_rng_temp_buffer_t; + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) + +/**@} */ + +#endif // NRF_HW_BACKEND_RNG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.c new file mode 100644 index 0000000..98e3aaf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.c @@ -0,0 +1,168 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) + +#include "nrf_crypto_rng.h" +#include "nrf_drv_rng.h" +#include "nrf_hw_backend_rng_mbedtls.h" + + +// Function to convert mbedtls error codes to ret_code_t. +static ret_code_t result_get(int mbedtls_ret_val) +{ + ret_code_t ret_val; + switch (mbedtls_ret_val) + { + case 0: + ret_val = NRF_SUCCESS; + break; + + case MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG: + ret_val = NRF_ERROR_CRYPTO_INPUT_LENGTH; + break; + + case MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG: + ret_val = NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + break; + + case MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED: + default: + ret_val = NRF_ERROR_CRYPTO_INTERNAL; + break; + } + + return ret_val; +} + + +// Callback function used by mbed TLS to seed and reseed. +static int entropy_callback(void * p_entropy, unsigned char * p_buffer, size_t size) +{ + UNUSED_PARAMETER(p_entropy); + + nrf_drv_rng_block_rand(p_buffer, size); + + return 0; +} + + +ret_code_t nrf_crypto_rng_backend_init(void * const p_context, void * const p_temp_buffer) +{ + ret_code_t ret_val; + int mbedtls_ret_val; + mbedtls_ctr_drbg_context * p_mbedtls_context = + &((nrf_crypto_backend_rng_context_t *)p_context)->mbedtls_context; + + UNUSED_PARAMETER(p_temp_buffer); + + ret_val = nrf_drv_rng_init(NULL); + + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + mbedtls_ctr_drbg_init(p_mbedtls_context); + + // Initial seeding. The nrf_crypto_rng API does not support additional entropy in the initial + // seeding. Additional entropy can be provided using nrf_crypto_rng_backend_reseed(), + // which calls mbedtls_ctr_drbg_reseed(). + mbedtls_ret_val = mbedtls_ctr_drbg_seed(p_mbedtls_context, + entropy_callback, + NULL, + NULL, + 0); + + ret_val = result_get(mbedtls_ret_val); + + return ret_val; +} + + +ret_code_t nrf_crypto_rng_backend_uninit(void * const p_context) +{ + mbedtls_ctr_drbg_context * p_mbedtls_context = + &((nrf_crypto_backend_rng_context_t *)p_context)->mbedtls_context; + + mbedtls_ctr_drbg_free(p_mbedtls_context); + nrf_drv_rng_uninit(); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_rng_backend_vector_generate(void * const p_context, + uint8_t * const p_target, + size_t size, + bool use_mutex) +{ + int mbedtls_ret_val; + mbedtls_ctr_drbg_context * p_mbedtls_context = + &((nrf_crypto_backend_rng_context_t *)p_context)->mbedtls_context; + + UNUSED_PARAMETER(use_mutex); + + mbedtls_ret_val = mbedtls_ctr_drbg_random(p_mbedtls_context, p_target, size); + + return result_get(mbedtls_ret_val); +} + + +ret_code_t nrf_crypto_rng_backend_reseed(void * const p_context, + void * p_temp_buffer, + uint8_t * p_input_data, + size_t size) +{ + int mbedtls_ret_val; + mbedtls_ctr_drbg_context * p_mbedtls_context = + &((nrf_crypto_backend_rng_context_t *)p_context)->mbedtls_context; + + UNUSED_PARAMETER(p_temp_buffer); + + mbedtls_ret_val = mbedtls_ctr_drbg_reseed(p_mbedtls_context, p_input_data, size); + + return result_get(mbedtls_ret_val); +} + +#endif //NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.h new file mode 100644 index 0000000..6b268f6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.h @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_HW_BACKEND_RNG_MBEDTLS_H__ +#define NRF_HW_BACKEND_RNG_MBEDTLS_H__ + +/** @file + * + * @defgroup nrf_crypto_nrf_hw_backend_rng_mbedtls nrf_crypto HW RNG backend using mbedtls CTR-DRBG + * @{ + * @ingroup nrf_crypto_nrf_hw_backend_rng + * + * @brief RNG functionality provided by the nrf_crypto nRF HW RNG backend and mbedtls CTR-DRBG. + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) + +#if !NRF_MODULE_ENABLED(RNG) +#error Enable RNG_ENABLED in sdk_config.h. +#endif + +#if !NRFX_RNG_CONFIG_ERROR_CORRECTION +#error Enable NRFX_RNG_CONFIG_ERROR_CORRECTION and RNG_CONFIG_ERROR_CORRECTION in sdk_config.h. +#endif + +/*lint -save -e????*/ +#include "mbedtls/ctr_drbg.h" +/*lint -restore*/ +#include "nrf_crypto_rng_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#error "More than one RNG backend enabled." +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#define NRF_CRYPTO_RNG_ENABLED 1 + + +/** + * @internal @brief Context for nRF RNG peripheral with mbed tls CTR-DRBG. + */ +typedef struct +{ + nrf_crypto_rng_internal_context_t header; //!< Internal common context header. + mbedtls_ctr_drbg_context mbedtls_context; //!< mbed TLS CTR-DRBG context. +} nrf_crypto_backend_rng_context_t; + +/** + * @internal @brief Dummy temp buffer for nRF RNG peripheral with mbed tls CTR-DRBG. + */ +typedef struct +{ + uint32_t reserved; +} nrf_crypto_backend_rng_temp_buffer_t; + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG) + +/**@} */ + +#endif // NRF_HW_BACKEND_RNG_MBEDTLS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c new file mode 100644 index 0000000..c22ce91 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c @@ -0,0 +1,139 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_SW) + +#include "nrf_sw_backend_hash.h" +#include "sha256.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_hash_shared.h" +#include "sdk_macros.h" +#include "nrf_log.h" +#include "nrf_assert.h" + + + +#if defined(NRF_CRYPTO_BACKEND_NRF_SW_HASH_LITTLE_ENDIAN_DIGEST_ENABLED) + +#error The configuration NRF_CRYPTO_BACKEND_NRF_SW_HASH_LITTLE_ENDIAN_DIGEST_ENABLED was removed in SDK 15.1.0. Please see release notes for details on removing this error message. + +#endif + +static ret_code_t nrf_sw_backend_hash_sha256_init(void * const p_context) +{ + ret_code_t ret_val; + + // No parameter testing on this level. + // This has been done on upper level. + + sha256_context_t * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *) p_context)->context); + + ret_val = sha256_init(p_backend_context); + + return ret_val; +} + +static uint32_t nrf_sw_backend_hash_sha256_update(void * const p_context, + uint8_t const * p_data, + size_t len) +{ + ret_code_t ret_val; + + // Limited parameter testing on this level. + // This has been done on upper level. + + sha256_context_t * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t * ) p_context)->context); + + ret_val = sha256_update(p_backend_context, p_data, len); + + return ret_val; +} + + +static uint32_t nrf_sw_backend_hash_sha256_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_len) +{ + ret_code_t ret_val; + + // Limited parameter testing on this level. + // This has been done on upper level. + + sha256_context_t * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t * )p_context)->context); + + if (NRF_CRYPTO_HASH_SIZE_SHA256 > *p_digest_len) + { + return NRF_ERROR_CRYPTO_OUTPUT_LENGTH; + } + + + ret_val = sha256_final(p_backend_context, p_digest, false); + + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + *p_digest_len = NRF_CRYPTO_HASH_SIZE_SHA256; + + return NRF_SUCCESS; + +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info = +{ + .init_fn = nrf_sw_backend_hash_sha256_init, + .update_fn = nrf_sw_backend_hash_sha256_update, + .finalize_fn = nrf_sw_backend_hash_sha256_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_hash_sha256_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA256 +}; + + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_SW) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.h similarity index 60% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.h index 5ef7f25..e44484b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,55 +35,65 @@ * 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 NRF_CRYPTO_RNG_H__ -#define NRF_CRYPTO_RNG_H__ + +#ifndef NRF_SW_BACKEND_HASH_H__ +#define NRF_SW_BACKEND_HASH_H__ /** @file * - * @defgroup nrf_crypto_rng Random number generation related functions. + * @defgroup nrf_crypto_nrf_sw_backend_hash nrf_crypto nRF SW backend hash * @{ - * @ingroup nrf_crypto + * @ingroup nrf_crypto_nrf_sw_backend * - * @brief Provides functions to initialize rng subsystem and generate random data. + * @brief Legacy hash functionality for bootloader use in nRFx devices */ -#include +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_SW) + +#include "sha256.h" +#include "nrf_crypto_error.h" #include "nrf_crypto_types.h" +#include "nrf_crypto_hash_shared.h" #ifdef __cplusplus extern "C" { -#if 0 -} #endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Duplicate backend enabled test for SHA-256 +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA256) +#error "Duplicate definition of SHA-256. More than one backend enabled"); #endif -/**@brief Initialize the random number generator - * - * @note This function is called by @ref nrf_crypto_init. - * - * @retval NRF_SUCCESS If random number generator was initialized successfully. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_rng_init(void); +// Flag that SHA-256 is enabled in backend +#define NRF_CRYPTO_HASH_SHA256_ENABLED 1 + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256) + + +/**@brief nrf_crypto_hash context for SHA-256 in nrf_crypto nrf_sw backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + sha256_context_t context; /**< Hash context internal to nrf_sw. */ +} nrf_crypto_backend_hash_sha256_context_t; -/**@brief Generate random data into a buffer, given length as an input. - * - * @param[in,out] p_target Pointer to a buffer to accept the random generated data. - * This buffer must be the same length as the length input. - * @param[in] length Length (in bytes) to generate random data for. - * - * @retval NRF_SUCCESS Data was generated successfully. - * @retval NRF_ERROR_NULL p_target was NULL. - * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend. - */ -uint32_t nrf_crypto_rng_vector_generate(uint8_t * p_target, uint32_t length); #ifdef __cplusplus } #endif +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_NRF_SW) + /**@} */ -#endif // #ifndef NRF_CRYPTO_RNG_H__ +#endif // NRF_SW_BACKEND_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.c new file mode 100644 index 0000000..488cb0f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.c @@ -0,0 +1,153 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include +#include "oberon_backend_chacha_poly_aead.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_OBERON_CHACHA_POLY_AEAD) + +static ret_code_t backend_cc310_init(void * const p_context, uint8_t * p_key) +{ + nrf_crypto_backend_chacha_poly_context_t * p_ctx = + (nrf_crypto_backend_chacha_poly_context_t *)p_context; + + + if (p_ctx->header.p_info->key_size != NRF_CRYPTO_KEY_SIZE_256) + { + return NRF_ERROR_CRYPTO_KEY_SIZE; + } + + memcpy(p_ctx->key, p_key, sizeof(p_ctx->key)); + + return NRF_SUCCESS; +} + +static inline ret_code_t backend_cc310_uninit(void * const p_context) +{ + return NRF_SUCCESS; +} + +static ret_code_t backend_cc310_crypt(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) + +{ + int result; + + nrf_crypto_backend_chacha_poly_context_t * p_ctx = + (nrf_crypto_backend_chacha_poly_context_t *)p_context; + + if ((adata_size == 0) || (data_in_size == 0)) + { + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + if (mac_size != NRF_CRYPTO_CHACHA_POLY_MAC_SIZE) + { + return NRF_ERROR_CRYPTO_AEAD_MAC_SIZE; + } + + if (nonce_size != NRF_CRYPTO_CHACHA_POLY_NONCE_SIZE) + { + return NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE; + } + + if (operation == NRF_CRYPTO_ENCRYPT) + { + ocrypto_chacha20_poly1305_encrypt_aad(p_mac, + p_data_out, + p_data_in, + data_in_size, + p_adata, + adata_size, + p_nonce, + (size_t)nonce_size, + p_ctx->key); + } + else if (operation == NRF_CRYPTO_DECRYPT) + { + result = ocrypto_chacha20_poly1305_decrypt_aad(p_mac, + p_data_out, + p_data_in, + data_in_size, + p_adata, + adata_size, + p_nonce, + (size_t)nonce_size, + p_ctx->key); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_AEAD_INVALID_MAC; + } + } + else + { + return NRF_ERROR_CRYPTO_INVALID_PARAM; + } + + return NRF_SUCCESS; +} + +nrf_crypto_aead_info_t const g_nrf_crypto_chacha_poly_256_info = +{ + .key_size = NRF_CRYPTO_KEY_SIZE_256, + .mode = NRF_CRYPTO_AEAD_MODE_CHACHA_POLY, + + .init_fn = backend_cc310_init, + .uninit_fn = backend_cc310_uninit, + .crypt_fn = backend_cc310_crypt +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_CC310_CHACHA_POLY_AEAD) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.h new file mode 100644 index 0000000..5e20bd4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.h @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2018 - 2019, 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 OBERON_BACKEND_CHACHA_POLY_AEAD_H__ +#define OBERON_BACKEND_CHACHA_POLY_AEAD_H__ + +/** @file + * + * @defgroup nrf_crypto_oberon_backend_chacha_poly_aead nrf_crypto Oberon backend CHACHA_POLY AEAD + * @{ + * @ingroup nrf_crypto_oberon_backend + * + * @brief AES AEAD functionality provided by the nrf_crypto Oberon backend. + */ + +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include "nrf_crypto_aead_shared.h" +#include "ocrypto_chacha20_poly1305.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_OBERON_CHACHA_POLY_BACKEND_KEY_SIZE (32) + +/* CHACHA-POLY */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CHACHA_POLY) +#error "Duplicate definition of CHACHA-POLY mode. More than one backend enabled"); +#endif +#define NRF_CRYPTO_CHACHA_POLY_ENABLED 1 +#undef NRF_CRYPTO_AEAD_ENABLED +#define NRF_CRYPTO_AEAD_ENABLED 1 // Flag that nrf_crypto_aead frontend can be compiled +#undef NRF_CRYPTO_OBERON_CHACHA_POLY_AEAD_ENABLED +#define NRF_CRYPTO_OBERON_CHACHA_POLY_AEAD_ENABLED 1 // aead backend for Oberon can be compiled + +/* defines for test purposes */ +#define NRF_CRYPTO_AES_CHACHA_POLY_256_ENABLED 1 + +typedef struct +{ + nrf_crypto_aead_internal_context_t header; /**< Common header for context. */ + + uint8_t key[NRF_CRYPTO_OBERON_CHACHA_POLY_BACKEND_KEY_SIZE]; +} nrf_crypto_backend_chacha_poly_context_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +/** @} */ + +#endif // OBERON_BACKEND_CHACHA_POLY_AEAD_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.c new file mode 100644 index 0000000..f7e8393 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.c @@ -0,0 +1,464 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include +#include +#include + +#include "app_util.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_shared.h" +#include "oberon_backend_ecc.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) +#include "ocrypto_ecdh_p256.h" +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) +#include "ocrypto_curve25519.h" +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) +#include "ocrypto_ed25519.h" +#endif + + +/** @internal @brief Structure holding private key common to all curves implemented by the Oberon. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[32]; /**< @internal @brief Raw key. */ +} nrf_crypto_backend_oberon_private_key_t; + + +/** @internal @brief Structure holding public key common to all curves implemented by the Oberon. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[64]; /**< @internal @brief Raw key. */ +} nrf_crypto_backend_oberon_public_key_t; + + +/** @internal @brief Function to hold copy function (can be simple mem copy or copy with endian swap). + */ +typedef void (*copy_fn_t)(void * p_dest, void const * p_src, size_t size); + + +ret_code_t nrf_crypto_backend_oberon_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_oberon_private_key_t const * p_prv = + (nrf_crypto_backend_oberon_private_key_t const *)p_private_key; + + //lint -save -e611 (Suspicious cast) + copy_fn_t copy_fn = (copy_fn_t)p_prv->header.p_info->p_backend_data; + //lint -restore + + copy_fn(p_raw_data, p_prv->key, p_prv->header.p_info->raw_private_key_size); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_oberon_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_oberon_public_key_t * p_pub = + (nrf_crypto_backend_oberon_public_key_t *)p_public_key; + + //lint -save -e611 (Suspicious cast) + copy_fn_t copy_fn = (copy_fn_t)p_pub->header.p_info->p_backend_data; + //lint -restore + + copy_fn(p_pub->key, p_raw_data, p_pub->header.p_info->raw_public_key_size); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_oberon_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_oberon_public_key_t const * p_pub = + (nrf_crypto_backend_oberon_public_key_t const *)p_public_key; + + //lint -save -e611 (Suspicious cast) + copy_fn_t copy_fn = (copy_fn_t)p_pub->header.p_info->p_backend_data; + //lint -restore + + copy_fn(p_raw_data, p_pub->key, p_pub->header.p_info->raw_public_key_size); + + return NRF_SUCCESS; +} + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) \ + || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + + +ret_code_t nrf_crypto_backend_oberon_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_oberon_private_key_t * p_prv = + (nrf_crypto_backend_oberon_private_key_t *)p_private_key; + + //lint -save -e611 (Suspicious cast) + copy_fn_t copy_fn = (copy_fn_t)p_prv->header.p_info->p_backend_data; + //lint -restore + + copy_fn(p_prv->key, p_raw_data, p_prv->header.p_info->raw_private_key_size); + + return NRF_SUCCESS; +} + + +#endif //NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) \ + || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + + +static ret_code_t oberon_vector_generate(uint8_t * p_data, size_t size) +{ +#if defined(NRF_CRYPTO_RNG_ENABLED) && (NRF_CRYPTO_RNG_ENABLED == 1) + + return nrf_crypto_rng_vector_generate(p_data, size); + +#elif defined(NRF_CRYPTO_RNG_ENABLED) && (NRF_CRYPTO_RNG_ENABLED == 0) + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; + +#else + + #warning NRF_CRYPTO_RNG_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif +} + + +#endif //NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + + +// Make sure that common key structure match secp256r1 key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_oberon_private_key_t, key) == + offsetof(nrf_crypto_backend_secp256r1_private_key_t, key), + "Common Oberon private key structure does not match secp256r1 one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_oberon_public_key_t, key) == + offsetof(nrf_crypto_backend_secp256r1_public_key_t, key), + "Common Oberon public key structure does not match secp256r1 one."); + + +ret_code_t nrf_crypto_backend_oberon_ecc_secp256r1_rng(uint8_t data[32]) +{ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + + static const uint8_t min_value[32] = + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }; + static const uint8_t max_value[32] = + { + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x50, + }; + return nrf_crypto_rng_vector_generate_in_range(data, min_value, max_value, 32); + +#else + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +#endif +} + + +ret_code_t nrf_crypto_backend_secp256r1_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + int result; + + nrf_crypto_backend_secp256r1_private_key_t * p_prv = + (nrf_crypto_backend_secp256r1_private_key_t *)p_private_key; + + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + result = nrf_crypto_backend_oberon_ecc_secp256r1_rng(p_prv->key); + + if (result != NRF_SUCCESS) + { + return result; + } + + result = ocrypto_ecdh_p256_public_key(p_pub->key, p_prv->key); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_secp256r1_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + int result; + + nrf_crypto_backend_secp256r1_private_key_t const * p_prv = + (nrf_crypto_backend_secp256r1_private_key_t const *)p_private_key; + + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + result = ocrypto_ecdh_p256_public_key(p_pub->key, p_prv->key); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp256r1_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_secp256r1_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE, + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&memcpy, + //lint -restore +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + + +// Make sure that common key structure match Curve25519 key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_oberon_private_key_t, key) == + offsetof(nrf_crypto_backend_curve25519_private_key_t, key), + "Common Oberon private key structure does not match Curve25519 one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_oberon_public_key_t, key) == + offsetof(nrf_crypto_backend_curve25519_public_key_t, key), + "Common Oberon public key structure does not match Curve25519 one."); + + +ret_code_t nrf_crypto_backend_curve25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + ret_code_t result; + + nrf_crypto_backend_curve25519_private_key_t * p_prv = + (nrf_crypto_backend_curve25519_private_key_t *)p_private_key; + + nrf_crypto_backend_curve25519_public_key_t * p_pub = + (nrf_crypto_backend_curve25519_public_key_t *)p_public_key; + + result = oberon_vector_generate(p_prv->key, sizeof(p_prv->key)); + + if (result != NRF_SUCCESS) + { + return result; + } + + p_prv->key[0] &= 0xF8; // Private key is multiply of 8 (by definition), so lower 3 bits are 0. + p_prv->key[31] &= 0x7F; // Highest bit has to be 0, because private key is 255-bit long. + p_prv->key[31] |= 0x40; // Bit 254 has to be 1 (by definition) + + ocrypto_curve25519_scalarmult_base(p_pub->key, p_prv->key); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_curve25519_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + nrf_crypto_backend_curve25519_private_key_t * p_prv = + (nrf_crypto_backend_curve25519_private_key_t *)p_private_key; + + nrf_crypto_backend_curve25519_public_key_t * p_pub = + (nrf_crypto_backend_curve25519_public_key_t *)p_public_key; + + // Private key bit fixing is done inside Oberon library. + ocrypto_curve25519_scalarmult_base(p_pub->key, p_prv->key); + + return NRF_SUCCESS; +} + + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_curve25519_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_curve25519_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_curve25519_private_key_t), + .curve_type = NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE, +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&nrf_crypto_internal_swap_endian, + //lint -restore +#else + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&memcpy, + //lint -restore +#endif +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + + +// Make sure that common key structure match Ed25519 key structure to safely cast types. +STATIC_ASSERT(offsetof(nrf_crypto_backend_oberon_private_key_t, key) == + offsetof(nrf_crypto_backend_ed25519_private_key_t, private_part), + "Common Oberon private key structure does not match Ed25519 one."); +STATIC_ASSERT(offsetof(nrf_crypto_backend_oberon_public_key_t, key) == + offsetof(nrf_crypto_backend_ed25519_public_key_t, key), + "Common Oberon public key structure does not match Ed25519 one."); + + +ret_code_t nrf_crypto_backend_ed25519_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_ed25519_private_key_t * p_prv = + (nrf_crypto_backend_ed25519_private_key_t *)p_private_key; + + memcpy(p_prv->private_part, p_raw_data, sizeof(p_prv->private_part)); + + ocrypto_ed25519_public_key(p_prv->public_part, p_prv->private_part); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_ed25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + ret_code_t result; + + nrf_crypto_backend_ed25519_private_key_t * p_prv = + (nrf_crypto_backend_ed25519_private_key_t *)p_private_key; + + nrf_crypto_backend_ed25519_public_key_t * p_pub = + (nrf_crypto_backend_ed25519_public_key_t *)p_public_key; + + result = oberon_vector_generate(p_prv->private_part, sizeof(p_prv->private_part)); + + if (result != NRF_SUCCESS) + { + return result; + } + + ocrypto_ed25519_public_key(p_prv->public_part, p_prv->private_part); + + memcpy(p_pub->key, p_prv->public_part, sizeof(p_pub->key)); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_ed25519_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + nrf_crypto_backend_ed25519_private_key_t * p_prv = + (nrf_crypto_backend_ed25519_private_key_t *)p_private_key; + + nrf_crypto_backend_ed25519_public_key_t * p_pub = + (nrf_crypto_backend_ed25519_public_key_t *)p_public_key; + + memcpy(p_pub->key, p_prv->public_part, sizeof(p_pub->key)); + + return NRF_SUCCESS; +} + + +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_ed25519_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_ed25519_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_ed25519_private_key_t), + .curve_type = NRF_CRYPTO_ECC_ED25519_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE, + //lint -save -e611 -e546 (Suspicious cast, Suspicious use of &) + .p_backend_data = (void *)&memcpy, + //lint -restore +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.h new file mode 100644 index 0000000..71dc958 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecc.h @@ -0,0 +1,314 @@ +/** + * Copyright (c) 2018 - 2019, 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 OBERON_BACKEND_ECC_H__ +#define OBERON_BACKEND_ECC_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include +#include +#include "nrf_crypto_ecc_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_oberon_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_oberon_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_oberon_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_oberon_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256R1) +#error "More than one backend enabled for secp256r1 (NIST 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 + + +/** @internal @brief Generates random number that can be used as a private key for secp256r1. + * + * It uses RNG from libary frontend to generate random numbers. + * + * @param[out] data Array where generated random number will be placed. + * @returns NRF_SUCCESS or error code passed from RNG frontend. + */ +ret_code_t nrf_crypto_backend_oberon_ecc_secp256r1_rng(uint8_t data[32]); + + +/** @internal @brief Structure holding private key for Oberon's secp256r1. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[32]; /**< @internal @brief Raw key. */ +} nrf_crypto_backend_secp256r1_private_key_t; + + +/** @internal @brief Structure holding public key for Oberon's secp256r1. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[64]; /**< @internal @brief Raw key. */ +} nrf_crypto_backend_secp256r1_public_key_t; + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_secp256r1_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_calculate_fn_t. +*/ +ret_code_t nrf_crypto_backend_secp256r1_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +// Common key conversion functions +#define nrf_crypto_backend_secp256r1_private_key_from_raw \ + nrf_crypto_backend_oberon_private_key_from_raw +#define nrf_crypto_backend_secp256r1_private_key_to_raw \ + nrf_crypto_backend_oberon_private_key_to_raw +#define nrf_crypto_backend_secp256r1_public_key_from_raw \ + nrf_crypto_backend_oberon_public_key_from_raw +#define nrf_crypto_backend_secp256r1_public_key_to_raw \ + nrf_crypto_backend_oberon_public_key_to_raw + +// Free is not required for oberon keys +#define nrf_crypto_backend_secp256r1_private_key_free NULL +#define nrf_crypto_backend_secp256r1_public_key_free NULL + +// Context is not used in oberon functions +#define NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_CURVE25519) +#error "More than one backend enabled for Curve25519."); +#endif +#define NRF_CRYPTO_ECC_CURVE25519_ENABLED 1 + + +/** @internal @brief Structure holding private key for Oberon's Curve25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[32]; /**< @internal @brief Raw key in little endian order. */ +} nrf_crypto_backend_curve25519_private_key_t; + + +/** @internal @brief Structure holding public key for Oberon's Curve25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[32]; /**< @internal @brief Raw key in little endian order. */ +} nrf_crypto_backend_curve25519_public_key_t; + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_curve25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_calculate_fn_t. +*/ +ret_code_t nrf_crypto_backend_curve25519_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +// Common key conversion functions +#define nrf_crypto_backend_curve25519_private_key_from_raw \ + nrf_crypto_backend_oberon_private_key_from_raw +#define nrf_crypto_backend_curve25519_private_key_to_raw \ + nrf_crypto_backend_oberon_private_key_to_raw +#define nrf_crypto_backend_curve25519_public_key_from_raw \ + nrf_crypto_backend_oberon_public_key_from_raw +#define nrf_crypto_backend_curve25519_public_key_to_raw \ + nrf_crypto_backend_oberon_public_key_to_raw + +// Free is not required for oberon keys +#define nrf_crypto_backend_curve25519_private_key_free NULL +#define nrf_crypto_backend_curve25519_public_key_free NULL + +// Context is not used in oberon functions +#define NRF_CRYPTO_BACKEND_CURVE25519_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_curve25519_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_curve25519_public_key_calculate_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_ED25519) +#error "More than one backend enabled for Ed25519."); +#endif +#define NRF_CRYPTO_ECC_ED25519_ENABLED 1 + + + +/** @internal @brief Structure holding private key for Oberon's Ed25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t private_part[32]; /**< @internal @brief Raw private key. */ + uint8_t public_part[32]; /**< @internal @brief Raw public key. It is also required for Ed25519 signing. */ +} nrf_crypto_backend_ed25519_private_key_t; + + +/** @internal @brief Structure holding private key for Oberon's Ed25519. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header. */ + uint8_t key[32]; /**< @internal @brief Raw key. */ +} nrf_crypto_backend_ed25519_public_key_t; + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_ed25519_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_ed25519_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_calculate_fn_t. +*/ +ret_code_t nrf_crypto_backend_ed25519_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +// Common key conversion functions +#define nrf_crypto_backend_ed25519_private_key_to_raw \ + nrf_crypto_backend_oberon_private_key_to_raw +#define nrf_crypto_backend_ed25519_public_key_from_raw \ + nrf_crypto_backend_oberon_public_key_from_raw +#define nrf_crypto_backend_ed25519_public_key_to_raw \ + nrf_crypto_backend_oberon_public_key_to_raw + +// Free is not required for oberon keys +#define nrf_crypto_backend_ed25519_private_key_free NULL +#define nrf_crypto_backend_ed25519_public_key_free NULL + +// Context is not used in oberon functions +#define NRF_CRYPTO_BACKEND_ED25519_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_ED25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 + +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_ed25519_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_ed25519_public_key_calculate_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#endif // OBERON_BACKEND_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.c new file mode 100644 index 0000000..b388c59 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.c @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh.h" +#include "nrf_crypto_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) +#include "ocrypto_ecdh_p256.h" +#endif +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) +#include "ocrypto_curve25519.h" +#endif + + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + +ret_code_t nrf_crypto_backend_secp256r1_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + int result; + + nrf_crypto_backend_secp256r1_private_key_t const * p_prv = + (nrf_crypto_backend_secp256r1_private_key_t const *)p_private_key; + + nrf_crypto_backend_secp256r1_public_key_t const * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t const *)p_public_key; + + result = ocrypto_ecdh_p256_common_secret(p_shared_secret, p_prv->key, p_pub->key); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + return NRF_SUCCESS; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + +ret_code_t nrf_crypto_backend_curve25519_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + nrf_crypto_backend_curve25519_private_key_t const * p_prv = + (nrf_crypto_backend_curve25519_private_key_t const *)p_private_key; + + nrf_crypto_backend_curve25519_public_key_t const * p_pub = + (nrf_crypto_backend_curve25519_public_key_t const *)p_public_key; + + // Private key can be completely random at this point. + // Oberon library updates bits in the key according to Curve25519 specification before use. + ocrypto_curve25519_scalarmult(p_shared_secret, p_prv->key, p_pub->key); + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_CURVE25519_BIG_ENDIAN) + nrf_crypto_internal_swap_endian_in_place(p_shared_secret, + NRF_CRYPTO_ECDH_CURVE25519_SHARED_SECRET_SIZE); +#endif + + return NRF_SUCCESS; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.h new file mode 100644 index 0000000..0a5851f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.h @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2018 - 2019, 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 OBERON_BACKEND_ECDH_H__ +#define OBERON_BACKEND_ECDH_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + + +/** @internal See @ref nrf_crypto_backend_ecdh_compute_fn_t. + */ +ret_code_t nrf_crypto_backend_secp256r1_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + +// Context in not used in OBERON backend +typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE 0 + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + +/** @internal See @ref nrf_crypto_backend_ecdh_compute_fn_t. + */ +ret_code_t nrf_crypto_backend_curve25519_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + +// Context in not used in OBERON backend +typedef uint32_t nrf_crypto_backend_curve25519_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_CURVE25519_ECDH_CONTEXT_SIZE 0 + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + +// ECDH is not possible for Ed25519 +#define nrf_crypto_backend_ed25519_ecdh_compute NULL +typedef uint32_t nrf_crypto_backend_ed25519_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_ED25519_ECDH_CONTEXT_SIZE 0 + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#endif // OBERON_BACKEND_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.c new file mode 100644 index 0000000..f0f214d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.c @@ -0,0 +1,120 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) + +#include +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_ecdsa.h" +#include "oberon_backend_eddsa.h" +#include "nrf_crypto_eddsa_shared.h" +#include "ocrypto_ecdsa_p256.h" + + +#define OBERON_HASH_SIZE_FOR_SECP256R1 (256 / 8) + + +ret_code_t nrf_crypto_backend_secp256r1_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature) +{ + int result; + uint8_t session_key[32]; + + nrf_crypto_backend_secp256r1_private_key_t const * p_prv = + (nrf_crypto_backend_secp256r1_private_key_t const *)p_private_key; + + if (data_size < OBERON_HASH_SIZE_FOR_SECP256R1) + { + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + result = nrf_crypto_backend_oberon_ecc_secp256r1_rng(session_key); + if (result != NRF_SUCCESS) + { + return result; + } + + result = ocrypto_ecdsa_p256_sign_hash(p_signature, p_data, p_prv->key, session_key); + + return result == 0 ? NRF_SUCCESS : NRF_ERROR_CRYPTO_INTERNAL; +} + + +ret_code_t nrf_crypto_backend_secp256r1_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + int result; + + nrf_crypto_backend_secp256r1_public_key_t const * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t const *)p_public_key; + + if (data_size < OBERON_HASH_SIZE_FOR_SECP256R1) + { + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + result = ocrypto_ecdsa_p256_verify_hash(p_signature, p_data, p_pub->key); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + } + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_nvmc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_nvmc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.h index b31c5b1..b63ae02 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal/nrf_nvmc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,91 +35,75 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/** - * @file - * @brief NMVC driver API. + * */ -#ifndef NRF_NVMC_H__ -#define NRF_NVMC_H__ +#ifndef OBERON_BACKEND_ECDSA_H__ +#define OBERON_BACKEND_ECDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) #include +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" + #ifdef __cplusplus extern "C" { #endif -/** - * @defgroup nrf_nvmc Non-volatile memory controller - * @{ - * @ingroup nrf_drivers - * @brief Driver for the NVMC peripheral. - * - * This driver allows writing to the non-volatile memory (NVM) regions - * of the chip. In order to write to NVM the controller must be powered - * on and the relevant page must be erased. - * - */ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1) -/** - * @brief Erase a page in flash. This is required before writing to any - * address in the page. - * - * @param address Start address of the page. +/** @internal See @ref nrf_crypto_backend_ecdsa_sign_fn_t. */ -void nrf_nvmc_page_erase(uint32_t address); +ret_code_t nrf_crypto_backend_secp256r1_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature); -/** - * @brief Write a single byte to flash. - * - * The function reads the word containing the byte, and then - * rewrites the entire word. - * - * @param address Address to write to. - * @param value Value to write. +/** @internal See @ref nrf_crypto_backend_ecdsa_verify_fn_t. */ -void nrf_nvmc_write_byte(uint32_t address , uint8_t value); +ret_code_t nrf_crypto_backend_secp256r1_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); -/** - * @brief Write a 32-bit word to flash. - * @param address Address to write to. - * @param value Value to write. - */ -void nrf_nvmc_write_word(uint32_t address, uint32_t value); +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_secp256r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_verify_context_t; +#endif -/** - * @brief Write consecutive bytes to flash. - * - * @param address Address to write to. - * @param src Pointer to data to copy from. - * @param num_bytes Number of bytes in src to write. - */ -void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes); +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519) -/** - * @brief Write consecutive words to flash. - * - * @param address Address to write to. - * @param src Pointer to data to copy from. - * @param num_words Number of words in src to write. - */ -void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words); +// Curve25519 is not designed for ECDSA +#define NRF_CRYPTO_BACKEND_CURVE25519_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_curve25519_sign_context_t; +typedef uint32_t nrf_crypto_backend_curve25519_verify_context_t; +#define nrf_crypto_backend_curve25519_sign NULL +#define nrf_crypto_backend_curve25519_verify NULL +#endif #ifdef __cplusplus } #endif -#endif // NRF_NVMC_H__ -/** @} */ - +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) +#endif // OBERON_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.c new file mode 100644 index 0000000..1da7952 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.c @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + +#include +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_eddsa.h" +#include "ocrypto_ed25519.h" + + +ret_code_t nrf_crypto_backend_ed25519_sign( + void * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_message, + size_t message_size, + uint8_t * p_signature) +{ + ocrypto_ed25519_sign(p_signature, + p_message, + message_size, + p_private_key->key_ed25519.private_part, + p_private_key->key_ed25519.public_part); + + return NRF_SUCCESS; +} + +ret_code_t nrf_crypto_backend_ed25519_verify( + void * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_message, + size_t message_size, + uint8_t const * p_signature) +{ + int result; + + result = ocrypto_ed25519_verify(p_signature, + p_message, + message_size, + p_public_key->key_ed25519.key); + + if (result != 0) + { + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + } + + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.h new file mode 100644 index 0000000..ac810ab --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.h @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2018 - 2019, 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 OBERON_BACKEND_EDDSA_H__ +#define OBERON_BACKEND_EDDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + +#include +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_eddsa_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_BACKEND_ED25519_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_ED25519_VERIFY_CONTEXT_SIZE 0 +typedef uint32_t nrf_crypto_backend_ed25519_sign_context_t; +typedef uint32_t nrf_crypto_backend_ed25519_verify_context_t; + +#ifdef __cplusplus +} +#endif + + +#endif // #if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519) + +#endif // OBERON_BACKEND_EDDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.c new file mode 100644 index 0000000..b10cd64 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.c @@ -0,0 +1,182 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include "oberon_backend_hash.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_hash_shared.h" +#include "sdk_macros.h" +#include "ocrypto_sha256.h" +#include "ocrypto_sha512.h" +#include "nrf_log.h" +#include "nrf_assert.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256) + +static ret_code_t oberon_backend_hash_sha256_init(void * const p_context) +{ + // No parameter testing on this level. + // This has been done on upper level. + + ocrypto_sha256_ctx * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + ocrypto_sha256_init(p_backend_context); + + return NRF_SUCCESS; +} + + +static uint32_t oberon_backend_hash_sha256_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + ocrypto_sha256_ctx * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + ocrypto_sha256_update(p_backend_context, p_data, size); + + return NRF_SUCCESS; +} + + +static uint32_t oberon_backend_hash_sha256_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + ocrypto_sha256_ctx * p_backend_context + = &(((nrf_crypto_backend_hash_sha256_context_t *)p_context)->context); + + ocrypto_sha256_final(p_backend_context, p_digest); + + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA256; + + return NRF_SUCCESS; +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info = +{ + .init_fn = oberon_backend_hash_sha256_init, + .update_fn = oberon_backend_hash_sha256_update, + .finalize_fn = oberon_backend_hash_sha256_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_hash_sha256_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA256 +}; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512) + + +static ret_code_t oberon_backend_hash_sha512_init(void * p_context) +{ + // No parameter testing on this level. + // This has been done on upper level. + + ocrypto_sha512_ctx * p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + ocrypto_sha512_init(p_backend_context); + + return NRF_SUCCESS; +} + + +static ret_code_t oberon_backend_hash_sha512_update(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + ocrypto_sha512_ctx * p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + ocrypto_sha512_update(p_backend_context, p_data, size); + + return NRF_SUCCESS; +} + + +static ret_code_t oberon_backend_hash_sha512_finalize(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + // Limited parameter testing on this level. + // This has been done on upper level. + + ocrypto_sha512_ctx * p_backend_context + = &(((nrf_crypto_backend_hash_sha512_context_t *)p_context)->context); + + ocrypto_sha512_final(p_backend_context, p_digest); + + *p_digest_size = NRF_CRYPTO_HASH_SIZE_SHA512; + + return NRF_SUCCESS; +} + + +const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha512_info = +{ + .init_fn = oberon_backend_hash_sha512_init, + .update_fn = oberon_backend_hash_sha512_update, + .finalize_fn = oberon_backend_hash_sha512_finalize, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA512, + .context_size = sizeof(nrf_crypto_backend_hash_sha512_context_t), + .hash_mode = NRF_CRYPTO_HASH_MODE_SHA512 +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.h new file mode 100644 index 0000000..059d16c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hash.h @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2018 - 2019, 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 OBERON_BACKEND_HASH_H__ +#define OBERON_BACKEND_HASH_H__ + +/** @file + * + * @defgroup nrf_crypto_oberon_backend_hash Oberon backend hash + * @{ + * @ingroup nrf_crypto_oberon_backend + * + * @brief Hash functionality provided by the Oberon nrf_crypto backend. + */ +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include "sdk_errors.h" +#include "nrf_crypto_hash_shared.h" +#include "ocrypto_sha256.h" +#include "ocrypto_sha512.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Duplicate backend enabled test for SHA-256 +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA256) +#error "Duplicate definition of SHA-256. More than one backend enabled"); +#endif + +// Flag that SHA-256 is enabled in backend +#define NRF_CRYPTO_HASH_SHA256_ENABLED 1 + + +/**@brief nrf_crypto_hash context for SHA-256 in nrf_crypto Oberon backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + ocrypto_sha256_ctx context; /**< Hash context internal to Oberon. */ +} nrf_crypto_backend_hash_sha256_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512) + +// Flag that nrf_crypto_hash frontend can be compiled +#undef NRF_CRYPTO_HASH_ENABLED +#define NRF_CRYPTO_HASH_ENABLED 1 + +// Duplicate backend enabled test for SHA-512 +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA512) +#error "Duplicate definition of SHA-512. More than one backend enabled"); +#endif + +// Flag that SHA-512 is enabled in backend +#define NRF_CRYPTO_HASH_SHA512_ENABLED 1 + + +/**@brief nrf_crypto_hash context for SHA-512 in nrf_crypto Oberon backend. */ +typedef struct +{ + nrf_crypto_hash_internal_context_t header; /**< Common header for context. */ + ocrypto_sha512_ctx context; /**< Hash context internal to Oberon. */ +} nrf_crypto_backend_hash_sha512_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +/**@} */ + +#endif // OBERON_BACKEND_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.c new file mode 100644 index 0000000..a09d9bc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.c @@ -0,0 +1,169 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) + +#include "nrf_log.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_types.h" +#include "oberon_backend_hmac.h" + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256) + +#define HMAC_SHA256_BLOCK_SIZE 64 + +static ret_code_t oberon_backend_hmac_init_sha256(void * const p_context, + uint8_t const * p_key, + size_t key_size) +{ + nrf_crypto_backend_oberon_hmac_sha256_context_t * p_ctx = + (nrf_crypto_backend_oberon_hmac_sha256_context_t *)p_context; + + ocrypto_hmac_sha256_init(&p_ctx->oberon_ctx, p_key, key_size); + + return NRF_SUCCESS; +} + + +static ret_code_t oberon_backend_hmac_update_sha256(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + nrf_crypto_backend_oberon_hmac_sha256_context_t * p_ctx = + (nrf_crypto_backend_oberon_hmac_sha256_context_t *)p_context; + + ocrypto_hmac_sha256_update(&p_ctx->oberon_ctx, p_data, size); + + return NRF_SUCCESS; +} + + +static ret_code_t oberon_backend_hmac_finalize_sha256(void * const p_context, + uint8_t * p_digest, + size_t * const p_size) +{ + nrf_crypto_backend_oberon_hmac_sha256_context_t * const p_ctx = + (nrf_crypto_backend_oberon_hmac_sha256_context_t *)p_context; + + ocrypto_hmac_sha256_final(&p_ctx->oberon_ctx, p_digest); + + // Assume operation was successful and update the digest size accordingly. + *p_size = p_ctx->header.p_info->digest_size; + + return NRF_SUCCESS; +} + + +// Information structure for HMAC SHA256 using Oberon backend. +const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha256_info = +{ + .init_fn = oberon_backend_hmac_init_sha256, + .update_fn = oberon_backend_hmac_update_sha256, + .finalize_fn = oberon_backend_hmac_finalize_sha256, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA256, + .context_size = sizeof(nrf_crypto_backend_oberon_hmac_sha256_context_t), + .type = NRF_CRYPTO_HMAC_SHA256_TYPE +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256) + + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512) + +#define HMAC_SHA512_BLOCK_SIZE 128 + +static ret_code_t oberon_backend_hmac_init_sha512(void * const p_context, + uint8_t const * p_key, + size_t key_size) +{ + nrf_crypto_backend_oberon_hmac_sha512_context_t * p_ctx = + (nrf_crypto_backend_oberon_hmac_sha512_context_t *)p_context; + + ocrypto_hmac_sha512_init(&p_ctx->oberon_ctx, p_key, key_size); + + return NRF_SUCCESS; +} + + +static ret_code_t oberon_backend_hmac_update_sha512(void * const p_context, + uint8_t const * p_data, + size_t size) +{ + nrf_crypto_backend_oberon_hmac_sha512_context_t * p_ctx = + (nrf_crypto_backend_oberon_hmac_sha512_context_t *)p_context; + + ocrypto_hmac_sha512_update(&p_ctx->oberon_ctx, p_data, size); + + return NRF_SUCCESS; +} + + +static ret_code_t oberon_backend_hmac_finalize_sha512(void * const p_context, + uint8_t * p_digest, + size_t * const p_size) +{ + nrf_crypto_backend_oberon_hmac_sha512_context_t * const p_ctx = + (nrf_crypto_backend_oberon_hmac_sha512_context_t *)p_context; + + ocrypto_hmac_sha512_final(&p_ctx->oberon_ctx, p_digest); + + // Assume operation was successful and update the digest size accordingly. + *p_size = p_ctx->header.p_info->digest_size; + + return NRF_SUCCESS; +} + + +// Information structure for HMAC SHA512 using Oberon backend. +const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha512_info = +{ + .init_fn = oberon_backend_hmac_init_sha512, + .update_fn = oberon_backend_hmac_update_sha512, + .finalize_fn = oberon_backend_hmac_finalize_sha512, + .digest_size = NRF_CRYPTO_HASH_SIZE_SHA512, + .context_size = sizeof(nrf_crypto_backend_oberon_hmac_sha512_context_t), + .type = NRF_CRYPTO_HMAC_SHA512_TYPE +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.h new file mode 100644 index 0000000..5a845dd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/oberon/oberon_backend_hmac.h @@ -0,0 +1,136 @@ +/** + * Copyright (c) 2018 - 2019, 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 OBERON_BACKEND_HMAC_H__ +#define OBERON_BACKEND_HMAC_H__ + +/** @file + * + * @defgroup nrf_crypto_oberon_backend_hmac Oberon backend for HMAC + * @{ + * @ingroup nrf_crypto_oberon_backend + * + * @brief Backend wrapper for Oberon. None of these types should be used directly by the + * application. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON) && \ + ( NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256) || \ + NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512) ) + +#include "nrf_crypto_hmac_shared.h" +#include "ocrypto_hmac_sha256.h" +#include "ocrypto_hmac_sha512.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#undef NRF_CRYPTO_HMAC_ENABLED +#define NRF_CRYPTO_HMAC_ENABLED 1 + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC_SHA256) +#error "Duplicate definition of HMAC SHA-256. More than one backend enabled" +#endif // NRF_CRYPTO_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_HMAC_SHA256_ENABLED 1 + +/** + * @internal @brief Internal context object used by the Oberon backend wrapper for HMAC SHA256. + * + * @note This should never be used directly. Use @ref nrf_crypto_backend_hmac_sha256_context_t + * instead. + */ +typedef struct +{ + nrf_crypto_hmac_internal_context_t header; //!< Internal nrf_crypto_hmac context. + ocrypto_hmac_sha256_ctx oberon_ctx; //!< Oberon context object. +} nrf_crypto_backend_oberon_hmac_sha256_context_t; + + +/** + * @internal @brief Context for HMAC SHA256 using Oberon backend. + */ +typedef nrf_crypto_backend_oberon_hmac_sha256_context_t nrf_crypto_backend_hmac_sha256_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256) + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC_SHA512) +#error "Duplicate definition of HMAC SHA-512. More than one backend enabled" +#endif // NRF_CRYPTO_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_HMAC_SHA512_ENABLED 1 + +/** + * @internal @brief Internal context object used by the Oberon backend wrapper for HMAC SHA512. + * + * @note This should never be used directly. Use @ref nrf_crypto_backend_hmac_sha512_context_t + * instead. + */ +typedef struct +{ + nrf_crypto_hmac_internal_context_t header; //!< Internal nrf_crypto_hmac context header. + ocrypto_hmac_sha512_ctx oberon_ctx; //!< Oberon context object. +} nrf_crypto_backend_oberon_hmac_sha512_context_t; + +/** + * @internal @brief Context for HMAC SHA512 using Oberon backend. + */ +typedef nrf_crypto_backend_oberon_hmac_sha512_context_t nrf_crypto_backend_hmac_sha512_context_t; + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON && ( NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256 || NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512) ) + +/**@} */ + +#endif // OBERON_BACKEND_HMAC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.c new file mode 100644 index 0000000..acd3cd3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.c @@ -0,0 +1,305 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_shared.h" +#include "nrf_assert.h" +#include "optiga_backend_ecc.h" + +/*lint -save -e????*/ +#include "optiga/optiga_crypt.h" +/*lint -restore*/ + +int nrf_crypto_backend_optiga_ecc_optiga_rng(void * p_param, unsigned char * p_data, size_t size) +{ +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + return NRF_SUCCESS; + +#else + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +#endif +} + +static const uint8_t der_pub_key_header[] = { + 0x03, // ASN.1 BITSTRING + 0x42, // bytes following + 0x00, // no unused bits + 0x04 // uncompressed key, see https://tools.ietf.org/html/rfc5480#section-2.2 +}; + +#define DER_PUB_KEY_HEADER_LEN (sizeof(der_pub_key_header)/sizeof(der_pub_key_header[0])) + +// for our purposes we always have 1 byte tag + 1 byte length +#define DER_OCTET_STRING_HEADER_LEN 2 + +// lengths for the ASN.1 DER encoded keys imported and exported by OPTIGA +#define OPTIGA_SECP256R1_PRIV_KEY_LEN (DER_OCTET_STRING_HEADER_LEN + NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE) +#define OPTIGA_SECP256R1_PUBL_KEY_LEN (DER_PUB_KEY_HEADER_LEN + NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE) + +ret_code_t nrf_crypto_backend_optiga_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key) +{ + optiga_lib_status_t res = OPTIGA_LIB_ERROR; + + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *) p_public_key; + + nrf_crypto_backend_secp256r1_private_key_t * p_priv = + (nrf_crypto_backend_secp256r1_private_key_t *) p_private_key; + + bool export_private_key; + if (p_priv->oid == 0) + { + // OID=0 was implicitly specified when initializising, mostly due to Nordic internal code calling our API + p_priv->oid = (optiga_key_id_t)0xE100; + export_private_key = false; + } + else if (p_priv->oid == NRF_CRYPTO_INFINEON_PRIVKEY_HOST_OID) + { + export_private_key = true; + } + else // any other value for OID, we assume the OID was purposefully specified by caller + { + export_private_key = false; + } + + void * priv_key; + if (export_private_key) + { + //lint -save -e611 -e545 (Suspicious cast, Suspicious use of &) + priv_key = (void*) &p_priv->raw_privkey; + //lint -restore + p_priv->oid = (optiga_key_id_t)NRF_CRYPTO_INFINEON_PRIVKEY_HOST_OID; + } + else + { + //lint -save -e611 -e545 (Suspicious cast, Suspicious use of &) + priv_key = (void*) &p_priv->oid; + + memset(p_priv->raw_privkey, 0, OPTIGA_SECP256R1_PRIV_KEY_LEN); + //lint -restore + } + + // Set all flags because the nrf_crypto API does not allow to specify key use + const optiga_key_usage_t key_usage = (optiga_key_usage_t)(OPTIGA_KEY_USAGE_AUTHENTICATION | + OPTIGA_KEY_USAGE_SIGN | + OPTIGA_KEY_USAGE_KEY_AGREEMENT); + + uint16_t publ_key_len = OPTIGA_SECP256R1_PUBL_KEY_LEN; + res = optiga_crypt_ecc_generate_keypair(OPTIGA_ECC_NIST_P_256, + key_usage, + export_private_key, + priv_key, + p_pub->raw_pubkey, + &publ_key_len); + + if(res != OPTIGA_LIB_SUCCESS) + { + // error in the optiga library + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if(publ_key_len != OPTIGA_SECP256R1_PUBL_KEY_LEN) + { + // unexpected length + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // mark the public key as stored in host memory + p_pub->oid = (optiga_key_id_t)NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID; + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_backend_optiga_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key) +{ + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + + +ret_code_t nrf_crypto_backend_optiga_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data) +{ + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + +#define DER_TAG_OCTET_STRING 0x04 + +ret_code_t nrf_crypto_backend_optiga_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_secp256r1_private_key_t * p_priv = + (nrf_crypto_backend_secp256r1_private_key_t *)p_private_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_priv->header.p_info; + + if(p_priv->oid != NRF_CRYPTO_INFINEON_PRIVKEY_HOST_OID) + { + // must use magic OID for private key exported to host + return NRF_ERROR_CRYPTO_INTERNAL; + } + + uint8_t* p_key = p_priv->raw_privkey; + if(*p_key != DER_TAG_OCTET_STRING) + { + // private key must be encoded as DER OCTET STRING + return NRF_ERROR_CRYPTO_INTERNAL; + } + + p_key++; + + if(p_info == &g_nrf_crypto_ecc_secp256r1_curve_info) + { + if(*p_key != NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE) + { + // wrong length + return NRF_ERROR_CRYPTO_INTERNAL; + } + p_key++; + + memcpy(p_raw_data, p_key, NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE); + + return NRF_SUCCESS; + } + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + +ret_code_t nrf_crypto_backend_optiga_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data) +{ + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if (p_info == &g_nrf_crypto_ecc_secp256r1_curve_info) + { + // copy header + memcpy(p_pub->raw_pubkey, der_pub_key_header, DER_PUB_KEY_HEADER_LEN); + // copy public key data + memcpy(p_pub->raw_pubkey + DER_PUB_KEY_HEADER_LEN, p_raw_data, NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE); + // Set OID to magic number for host-supplied public key + p_pub->oid = (optiga_key_id_t)NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID; + + return NRF_SUCCESS; + } + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + + +ret_code_t nrf_crypto_backend_optiga_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data) +{ + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + nrf_crypto_ecc_curve_info_t const * p_info = p_pub->header.p_info; + + if(p_pub->oid != NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID) + { + // must use magic OID for host supplied public key + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if (p_info == &g_nrf_crypto_ecc_secp256r1_curve_info) + { + if(memcmp(p_pub->raw_pubkey, der_pub_key_header, DER_PUB_KEY_HEADER_LEN) != 0) { + // public key not correctly encoded + return NRF_ERROR_CRYPTO_INTERNAL; + } + + memcpy(p_raw_data, + p_pub->raw_pubkey + DER_PUB_KEY_HEADER_LEN, + NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE); + + return NRF_SUCCESS; + } + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + + +ret_code_t nrf_crypto_backend_optiga_private_key_free( + void * p_private_key) +{ + return NRF_ERROR_CRYPTO_INTERNAL; +} + +ret_code_t nrf_crypto_backend_optiga_public_key_free( + void * p_public_key) +{ + return NRF_ERROR_CRYPTO_INTERNAL; +} + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1) +const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info = +{ + .public_key_size = sizeof(nrf_crypto_backend_secp256r1_public_key_t), + .private_key_size = sizeof(nrf_crypto_backend_optiga_ecc_private_key_t), + .curve_type = NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, + .raw_private_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE, + .raw_public_key_size = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE, + .p_backend_data = (void *)OPTIGA_ECC_NIST_P_256, +}; +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.h new file mode 100644 index 0000000..4c28d35 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecc.h @@ -0,0 +1,200 @@ +/** + * Copyright (c) 2018 - 2019, 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 OPTIGA_BACKEND_ECC_H__ +#define OPTIGA_BACKEND_ECC_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include +#include +#include "nrf_crypto_ecc.h" + +/*lint -save -e????*/ +#include "optiga/optiga_crypt.h" +/*lint -restore*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** @internal Magic OID that indicates a host supplied public key +*/ +#define NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID 0xFFFF + +/** @internal Magic OID that indicates to export the private key +*/ +#define NRF_CRYPTO_INFINEON_PRIVKEY_HOST_OID 0xFFFE + +/** @internal @brief Common structure holding private key for the OPTIGA backend. + */ +typedef struct nrf_crypto_backend_optiga_ecc_private_key_t +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + optiga_key_id_t oid; // OID where the private key is stored + uint8_t raw_privkey[64+2]; // Private Key encoded as DER OCTET STRING +} nrf_crypto_backend_optiga_ecc_private_key_t; + +#define NRF_CRYPTO_INFINEON_SECP256R1_PRIVATE_KEY_FROM_OID(oid_value) { \ + .key_secp256r1 = { \ + .header = { \ + .init_value = NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE, \ + .p_info = &g_nrf_crypto_ecc_secp256r1_curve_info \ + }, \ + .oid = (optiga_key_id_t)(oid_value) \ + } \ +} + +/** @internal @brief Common structure holding public key for the OPTIGA backend. + */ +typedef struct +{ + nrf_crypto_internal_ecc_key_header_t header; /**< @internal @brief Common ECC key header */ + optiga_key_id_t oid; // OID where the public key is stored + uint8_t raw_pubkey[64+4]; // Public Key encoded as DER BITSTRING with header +} nrf_crypto_backend_secp256r1_public_key_t; + +#define NRF_CRYPTO_INFINEON_SECP256R1_PUBLIC_KEY_FROM_OID(oid_value) { \ + .key_secp256r1 = { \ + .header = { \ + .init_value = NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE, \ + .p_info = &g_nrf_crypto_ecc_secp256r1_curve_info \ + }, \ + .oid = (optiga_key_id_t)(oid_value) \ + } \ +} + +#define NRF_CRYPTO_INFINEON_SECP256R1_PUBLIC_KEY_RAW \ + NRF_CRYPTO_INFINEON_SECP256R1_PUBLIC_KEY_FROM_OID(NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID) + + +/** @internal See @ref nrf_crypto_backend_ecc_key_pair_generate_fn_t. + */ +ret_code_t nrf_crypto_backend_optiga_key_pair_generate( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_calculate_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_public_key_calculate( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_private_key_from_raw( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_private_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_private_key_to_raw( + void const * p_private_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_from_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_public_key_from_raw( + void * p_public_key, + uint8_t const * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_public_key_to_raw_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_public_key_to_raw( + void const * p_public_key, + uint8_t * p_raw_data); + + +/** @internal See @ref nrf_crypto_backend_ecc_key_free_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_private_key_free( + void * p_private_key); + + +/** @internal See @ref nrf_crypto_backend_ecc_key_free_fn_t. +*/ +ret_code_t nrf_crypto_backend_optiga_public_key_free( + void * p_public_key); + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1) + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_ECC_SECP256R1) +#error "More than one backend enabled for secp256r1 (NIST 256-bit)."); +#endif +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 + +// Aliases for one common OPTIGA implementation +#define nrf_crypto_backend_secp256r1_key_pair_generate nrf_crypto_backend_optiga_key_pair_generate +#define nrf_crypto_backend_secp256r1_public_key_calculate nrf_crypto_backend_optiga_public_key_calculate +#define nrf_crypto_backend_secp256r1_private_key_from_raw nrf_crypto_backend_optiga_private_key_from_raw +#define nrf_crypto_backend_secp256r1_private_key_to_raw nrf_crypto_backend_optiga_private_key_to_raw +#define nrf_crypto_backend_secp256r1_public_key_from_raw nrf_crypto_backend_optiga_public_key_from_raw +#define nrf_crypto_backend_secp256r1_public_key_to_raw nrf_crypto_backend_optiga_public_key_to_raw +#define nrf_crypto_backend_secp256r1_private_key_free nrf_crypto_backend_optiga_private_key_free +#define nrf_crypto_backend_secp256r1_public_key_free nrf_crypto_backend_optiga_public_key_free +// OPTIGA does not require context, so its size is 0. +#define NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE 0 +// All OPTIGA curve types share the same private key data structures +typedef nrf_crypto_backend_optiga_ecc_private_key_t nrf_crypto_backend_secp256r1_private_key_t; +// Dummy typedef for unused context +typedef uint32_t nrf_crypto_backend_secp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1) + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#endif // OPTIGA_BACKEND_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.c new file mode 100644 index 0000000..2713777 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.c @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include + +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdh_shared.h" +#include "nrf_crypto_shared.h" +#include "nrf_crypto_ecdh.h" +#include "optiga_backend_ecc.h" + +/*lint -save -e????*/ +#include "optiga/optiga_crypt.h" +/*lint -restore*/ + + +ret_code_t nrf_crypto_backend_optiga_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret) +{ + optiga_lib_status_t res = OPTIGA_LIB_ERROR; + + // Prepare public key + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *) p_public_key; + if (p_pub->oid != NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID) + { + // OPTIGA requires the peer' public key to be host-supplied + return NRF_ERROR_CRYPTO_INTERNAL; + } + // magic OID for pubkey from host + public_key_from_host_t pub_key = { + .public_key = p_pub->raw_pubkey, + .length = 64+4, // public key + DER BITSTRING header + .curve = OPTIGA_ECC_NIST_P_256 + }; + + // Prepare private key + nrf_crypto_backend_secp256r1_private_key_t * p_priv = + (nrf_crypto_backend_secp256r1_private_key_t *) p_private_key; + optiga_key_id_t priv_oid = p_priv->oid; + if (priv_oid == NRF_CRYPTO_INFINEON_PRIVKEY_HOST_OID) + { + // OPTIGA Trust X can only compute ECDH with private key from inside OPTIGA + return NRF_ERROR_CRYPTO_INTERNAL; + } + + res = optiga_crypt_ecdh( + priv_oid, // private key OID + &pub_key, // peer public key details + true, // true: export shared secret to host + p_shared_secret // resulting shared secret + ); + + if (res != OPTIGA_LIB_SUCCESS) + { + // error in the optiga library + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.h new file mode 100644 index 0000000..9142967 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdh.h @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2018 - 2019, 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 OPTIGA_BACKEND_ECDH_H__ +#define OPTIGA_BACKEND_ECDH_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// This file is only needed to satisfy the nrf_crypto interface + + +/** @internal See @ref nrf_crypto_backend_ecdh_compute_fn_t. + */ +ret_code_t nrf_crypto_backend_optiga_ecdh_compute( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1) +// Aliases for one common OPTIGA implementation +#define nrf_crypto_backend_secp256r1_ecdh_compute nrf_crypto_backend_optiga_ecdh_compute +typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t; +#define NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE 0 +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1) + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#endif // OPTIGA_BACKEND_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.c new file mode 100644 index 0000000..44ba162 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.c @@ -0,0 +1,155 @@ +/** + * Copyright (c) 2018 - 2019, 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_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include +#include +#include + +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdsa.h" + +/*lint -save -e????*/ +#include "optiga/optiga_crypt.h" +#include "ecdsa_utils.h" +/*lint -restore*/ + +ret_code_t nrf_crypto_backend_optiga_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature) +{ + optiga_lib_status_t res = OPTIGA_LIB_ERROR; + nrf_crypto_backend_optiga_ecc_private_key_t * p_prv = + (nrf_crypto_backend_optiga_ecc_private_key_t *)p_private_key; + + optiga_key_id_t oid = p_prv->oid; + + uint16_t der_sig_len = NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE + ECDSA_RS_MAX_ASN1_OVERHEAD; + uint8_t der_sig[NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE + ECDSA_RS_MAX_ASN1_OVERHEAD] = {0}; + + res = optiga_crypt_ecdsa_sign((uint8_t *)p_data, data_size, oid, der_sig, &der_sig_len); + if(res != OPTIGA_LIB_SUCCESS) { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // convert signature to format suitable for nrf_crypto + if (!asn1_to_ecdsa_rs(der_sig, der_sig_len, + p_signature, NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + return NRF_SUCCESS; +} + +ret_code_t nrf_crypto_backend_optiga_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature) +{ + nrf_crypto_backend_secp256r1_public_key_t * p_pub = + (nrf_crypto_backend_secp256r1_public_key_t *)p_public_key; + + optiga_key_id_t oid = p_pub->oid; + + size_t der_sig_len = NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE + ECDSA_RS_MAX_ASN1_OVERHEAD; + uint8_t der_sig[NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE + ECDSA_RS_MAX_ASN1_OVERHEAD] = {0}; + + const size_t rs_size = NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE/2; + + optiga_lib_status_t res = OPTIGA_LIB_ERROR; + + // Convert signature to DER format needed by OPTIGA + if (!ecdsa_rs_to_asn1_integers(p_signature, + p_signature + rs_size, + rs_size, + der_sig, + &der_sig_len)) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if (oid == NRF_CRYPTO_INFINEON_PUBKEY_HOST_OID) + { + // Create magic OID for pubkey from host + public_key_from_host_t pub_key = { + .public_key = p_pub->raw_pubkey, + .length = NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE + 4, // public key + DER BITSTRING header + .curve = OPTIGA_ECC_NIST_P_256 + }; + + res = optiga_crypt_ecdsa_verify((uint8_t *)p_data, + data_size, + der_sig, + der_sig_len, + OPTIGA_CRYPT_HOST_DATA, + &pub_key); + } + else + { + // Public key is in OPTIGA, referenced by OID + res = optiga_crypt_ecdsa_verify((uint8_t *)p_data, + data_size, + der_sig, + der_sig_len, + OPTIGA_CRYPT_OID_DATA, + &oid); + } + + // consider everything that is not success a signature failure + if (res != OPTIGA_LIB_SUCCESS) + { + return NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE; + } + + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.h new file mode 100644 index 0000000..ed2470b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_ecdsa.h @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2018 - 2019, 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 OPTIGA_BACKEND_ECDSA_H__ +#define OPTIGA_BACKEND_ECDSA_H__ + +#include "sdk_config.h" +#include "nordic_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecdsa_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1) + + +/** @internal See @ref nrf_crypto_backend_ecdsa_sign_fn_t. + */ +ret_code_t nrf_crypto_backend_optiga_sign( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature); + + +/** @internal See @ref nrf_crypto_backend_ecdsa_verify_fn_t. + */ +ret_code_t nrf_crypto_backend_optiga_verify( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + + +// Context is not used by OPTIGA, so its size is 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for unused contexts +typedef uint32_t nrf_crypto_backend_secp256r1_sign_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_verify_context_t; +// Alias for common OPTIGA types +#define nrf_crypto_backend_secp256r1_sign nrf_crypto_backend_optiga_sign +#define nrf_crypto_backend_secp256r1_verify nrf_crypto_backend_optiga_verify +#endif + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#endif // OPTIGA_BACKEND_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_init.c new file mode 100644 index 0000000..c15aae3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_init.c @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2018 - 2019, 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" +#include "sdk_config.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) + +#include "nrf_crypto_init.h" +#include "nrf_crypto_rng.h" +#include "nrf_log.h" + +/*lint -save -e????*/ +#include "optiga/optiga_util.h" +#include "optiga/ifx_i2c/ifx_i2c.h" +/*lint -restore*/ + +optiga_comms_t optiga_comms = {(void*)&ifx_i2c_context_0, NULL, NULL}; + +// need to forward declare these, because they are not exported through the PAL API +void pal_gpio_init(void); +void pal_os_event_init(void); + +/************************************************************************* +* functions +*************************************************************************/ + +static int32_t optiga_init(void) +{ + int32_t status = (int32_t) OPTIGA_LIB_ERROR; + + // Initialize PAL + pal_gpio_init(); + pal_os_event_init(); + + status = optiga_util_open_application(&optiga_comms); + if (OPTIGA_LIB_SUCCESS != status) + { + NRF_LOG_INFO("Failure: CmdLib_OpenApplication(): 0x%04X", status); + return status; + } + + NRF_LOG_INFO("Success: CmdLib_OpenApplication(): 0x%04X", status); + + return OPTIGA_LIB_SUCCESS; +} + +/** @internal @brief Function to initialize OPTIGA backend - open the application. + */ +static ret_code_t optiga_backend_init(void) +{ + if(optiga_init() != OPTIGA_LIB_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + +#if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1) + + ret_code_t ret_val; + ret_val = nrf_crypto_rng_init(NULL, NULL); + return ret_val; + +#elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0) + + return NRF_SUCCESS; + +#else + + #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_CRYPTO_RNG_AUTO_INIT_ENABLED + +} + + +/** @internal @brief Function to uninitialize OPTIGA backend - currently no implementation is required. + */ +static ret_code_t optiga_backend_uninit(void) +{ + // Empty implementation + return NRF_SUCCESS; +} + + +CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const optiga_backend) = +{ + .init_fn = optiga_backend_init, + .uninit_fn = optiga_backend_uninit, +}; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.c new file mode 100644 index 0000000..cd6693e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.c @@ -0,0 +1,147 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_RNG) + +#include "nrf_crypto_rng.h" +#include "optiga_backend_rng.h" +#include "optiga/optiga_crypt.h" + + +/** @brief Minimal size output of random data in OPTIGA Trust X + * + * @details See Solution Reference Manual v1.35, section 4.4.3.4 + */ +#define OPTIGA_RNG_MIN_SIZE (0x8) + + +/** @brief Maximum size output of random data in OPTIGA Trust X + * + * @details See Solution Reference Manual v1.35, section 4.4.3.4 + */ +#define OPTIGA_RNG_MAX_SIZE (0x100) + + +ret_code_t nrf_crypto_rng_backend_init(void * const p_context, + void * const p_temp_buffer) +{ + UNUSED_PARAMETER(p_context); + UNUSED_PARAMETER(p_temp_buffer); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_rng_backend_uninit(void * const p_context) +{ + UNUSED_PARAMETER(p_context); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_rng_backend_vector_generate(void * const p_context, + uint8_t * const p_target, + size_t size, + bool use_mutex) +{ + UNUSED_PARAMETER(use_mutex); + UNUSED_PARAMETER(p_context); + + uint8_t backup[OPTIGA_RNG_MIN_SIZE] = {0}; + optiga_lib_status_t err; + + uint8_t * out_cur = p_target; + + size_t size_left = size; + size_t cur_len = size_left; + + do + { + cur_len = size_left > OPTIGA_RNG_MAX_SIZE ? OPTIGA_RNG_MAX_SIZE : size_left; + + if (cur_len < OPTIGA_RNG_MIN_SIZE) + { + err = optiga_crypt_random(OPTIGA_RNG_TYPE_TRNG, backup, OPTIGA_RNG_MIN_SIZE); + if(err != OPTIGA_LIB_SUCCESS) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + memcpy(out_cur, backup, cur_len); + } + else + { + err = optiga_crypt_random(OPTIGA_RNG_TYPE_TRNG, out_cur, cur_len); + if (err != OPTIGA_LIB_SUCCESS) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + } + + out_cur += cur_len; + size_left -= cur_len; + + } while(size_left > 0); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_rng_backend_reseed(void * const p_context, + void * p_temp_buffer, + uint8_t * p_input_data, + size_t size) +{ + UNUSED_PARAMETER(p_context); + UNUSED_PARAMETER(p_temp_buffer); + UNUSED_PARAMETER(p_input_data); + UNUSED_PARAMETER(size); + + return NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_RNG) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.h new file mode 100644 index 0000000..64be007 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_rng.h @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2018 - 2019, 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 OPTIGA_BACKEND_RNG_H__ +#define OPTIGA_BACKEND_RNG_H__ + +/** @file + * + * @defgroup nrf_crypto_optiga_backend_rng nrf_crypto OPTIGA RNG backend + * @{ + * @ingroup nrf_crypto_backends + * + * @brief RNG functionality provided by the nrf_crypto OPTIGA RNG backend. + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) +#if NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_RNG) + + +#include "nrf_crypto_rng_shared.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#error "More than one RNG backend enabled." +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#define NRF_CRYPTO_RNG_ENABLED 1 + +/** + * @internal @brief Context for nRF RNG peripheral. + */ +typedef struct +{ + nrf_crypto_rng_internal_context_t header; //!< Internal common context header. +} nrf_crypto_backend_rng_context_t; + +/** + * @internal @brief Dummy temp buffer for nRF RNG peripheral. + */ +typedef struct +{ + uint32_t reserved; +} nrf_crypto_backend_rng_temp_buffer_t; + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA_RNG) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_OPTIGA) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + +/**@} */ + +#endif // OPTIGA_BACKEND_RNG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.c new file mode 100644 index 0000000..573b304 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.c @@ -0,0 +1,265 @@ +/** + * Copyright (c) 2018 - 2019, 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 +#include "optiga_backend_utils.h" +#include "nrf_crypto_error.h" + +/** + * @brief Decodes two ASN.1 integers to the R and S components of a ECC signature. + * + * @param[in] p_asn1 Pointer to buffer containing the ASN.1 encoded R and S values. + * @param[in] asn1_len Length of the asn1 buffer. + * @param[out] p_rs Pointer to buffer where to write the R and S values + * @param[in,out] p_rs_len pointer to variable containing length of the rs buffer, + * updated to actual length after the call. + * + * @returns NRF_SUCCESS on success, otherwise NRF_ERROR_CRYPTO_INTERNAL. + */ +ret_code_t asn1_to_ecdsa_rs(uint8_t const * p_asn1, + size_t asn1_len, + uint8_t * p_rs, + size_t * p_rs_len) +{ + + uint8_t const * p_cur = p_asn1; + uint8_t const * p_end = p_asn1 + asn1_len; // Points to first invalid mem-location + uint8_t r_len; + uint8_t s_len; + + if (p_asn1 == NULL || p_rs == NULL || p_rs_len == NULL) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if (asn1_len == 0 || *p_rs_len == 0) + { + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if (*p_cur != DER_TAG_INTEGER) + { + // Wrong tag type + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if ((p_cur + 2) >= p_end) + { + // Prevented out-of-bounds read + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // Move to length value + p_cur++; + r_len = *p_cur; + + if (r_len > DER_INTEGER_MAX_LEN) + { + // Unsupported length + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // Move to first data value + p_cur++; + + // Check for stuffing bits + if (*p_cur == 0x00) + { + p_cur++; + r_len--; + } + + // Check for out-of-bounds read + if ((p_cur + r_len) >= p_end) + { + // prevented out-of-bounds read + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // Check for out-of-bounds write + if ((p_rs + r_len) > (p_rs + *p_rs_len)) + { + // prevented out-of-bounds write + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // Copy R component to output + memcpy(p_rs, p_cur, r_len); + + // Move to next tag + p_cur += r_len; + + if (*p_cur != DER_TAG_INTEGER) + { + // Wrong tag type + return NRF_ERROR_CRYPTO_INTERNAL; + } + + if ((p_cur + 2) >= p_end) + { + // Prevented out-of-bounds read + return NRF_ERROR_CRYPTO_INTERNAL; + } + p_cur++; + s_len = *p_cur; + + if (s_len > DER_INTEGER_MAX_LEN) + { + // Unsupported length + return NRF_ERROR_CRYPTO_INTERNAL; + } + p_cur++; + + if (*p_cur == 0x00) + { + p_cur++; + s_len--; + } + + // Check for out-of-bounds read + if ((p_cur + s_len) > p_end) + { + // prevented out-of-bounds read + return NRF_ERROR_CRYPTO_INTERNAL; + } + + // Check for out-of-bounds write + if ((p_rs + r_len + s_len) > (p_rs + *p_rs_len)) + { + // Prevented out-of-bounds write + return NRF_ERROR_CRYPTO_INTERNAL; + } + + memcpy(p_rs + r_len, p_cur, s_len); + + *p_rs_len = r_len + s_len; + + return NRF_SUCCESS; +} + + +/** + * @brief Encodes the ECDSA signature components (r, s) in ASN.1 format. + * + * @param[in] p_r Pointer to buffer containing component r of the ECDSA signature. + * @param[in] r_len Length of the r component of the ECDSA signature. + * @param[in] p_s Pointer to buffer containing component s of the ECDSA signature. + * @param[in] s_len Length of the s component of the ECDSA signature. + * @param[out] p_asn_sig Pointer to buffer to hold the resulting ASN.1-encoded ECDSA signature. + * @param[out] p_asn_sig_len Pointer to variable holding the length of the buffer for ASN.1-encoded + * ECDSA signature. This will be updated to the actual size when the + * function is called. + * + * @returns True on success, otherwise false. + */ +bool ecdsa_rs_to_asn1(uint8_t const * p_r, + size_t r_len, + uint8_t const * p_s, + size_t s_len, + uint8_t * p_asn_sig, + size_t * p_asn_sig_len) +{ + size_t index = 0; + // NULL checks + if (p_r == NULL || p_s == NULL || p_asn_sig_len == NULL) + { + return false; + } + + if (r_len == 0 || r_len > DER_INTEGER_MAX_LEN || s_len == 0 || s_len > DER_INTEGER_MAX_LEN) + { + return false; + } + + if (*p_asn_sig_len < (r_len + s_len + DER_OVERHEAD)) + { + // Not enough space in output buffer + return false; + } + + // R component + // DER TAG INTEGER + p_asn_sig[index] = DER_TAG_INTEGER; + index++; + + // Set length + p_asn_sig[index] = r_len; + + // check if extra byte needed + if (p_r[0] & 0x80) + { + // Update length value + p_asn_sig[index] += 1; + index++; + // Insert zero byte for padding + p_asn_sig[index] = 0; + } + + index++; + + memcpy(&p_asn_sig[index], p_r, r_len); + index += r_len; + + // S component + // DER TAG INTEGER + p_asn_sig[index] = DER_TAG_INTEGER; + index++; + // Set length + p_asn_sig[index] = s_len; + + if (p_s[0] & 0x80) + { + // Update length value + p_asn_sig[index] += 1; + index++; + // Insert zero byte for padding + p_asn_sig[index] = 0; + } + + index++; + + memcpy(&p_asn_sig[index], p_s, s_len); + index += s_len; + + // Return total length of ASN.1-encoded data structure + *p_asn_sig_len = index; + return true; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.h new file mode 100644 index 0000000..998c2e1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/backend/optiga/optiga_backend_utils.h @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2018 - 2019, 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 OPTIGA_BACKEND_UTILS_H__ +#define OPTIGA_BACKEND_UTILS_H__ + +#include +#include +#include +#include "sdk_config.h" +#include "nordic_common.h" +#include "sdk_errors.h" + +/** @brief Define for a integer tag in DER encoding. */ +#define DER_TAG_INTEGER 0x02 + + +/** @brief Max size of integer in DER encoding. + * + * @note This limit is for this implementation only, ASN.1 DER supports more + */ +#define DER_INTEGER_MAX_LEN 0x7F + + +/** @brief Define for overhead to encode a DER of two integers + * + * @details TAG + LENGTH needs 2 bytes if the highest bit of the integer is set + * we need an extra byte + */ +#define DER_OVERHEAD ((2 + 1) * 2) + + +/** + * @brief Decodes two ASN.1 integers to the R and S components of a ECC signature. + * + * @param[in] p_asn1 Pointer to buffer containing the ASN.1 encoded R and S values. + * @param[in] asn1_len Length of the asn1 buffer. + * @param[out] p_rs Pointer to buffer where to write the R and S values + * @param[in,out] p_rs_len pointer to variable containing length of the rs buffer, + * updated to actual length after the call. + * + * @returns NRF_SUCCESS on success, otherwise NRF_ERROR_CRYPTO_INTERNAL. + */ + +ret_code_t asn1_to_ecdsa_rs(uint8_t const * p_asn1, + size_t asn1_len, + uint8_t * p_rs, + size_t * p_rs_len); + + + +/** + * @brief Encodes the ECDSA signature components (r, s) in ASN.1 format. + * + * @param[in] p_r Pointer to buffer containing component r of the ECDSA signature. + * @param[in] r_len Length of the r component of the ECDSA signature. + * @param[in] p_s Pointer to buffer containing component s of the ECDSA signature. + * @param[in] s_len Length of the s component of the ECDSA signature. + * @param[out] p_asn_sig Pointer to buffer to hold the resulting ASN.1-encoded ECDSA signature. + * @param[out] p_asn_sig_len Pointer to variable holding the length of the buffer for ASN.1-encoded + * ECDSA signature. This will be updated to the actual size when the + * function is called. + * + * @returns True on success, otherwise false. + */ +bool ecdsa_rs_to_asn1(uint8_t const * p_r, + size_t r_len, + uint8_t const * p_s, + size_t s_len, + uint8_t * p_asn_sig, + size_t * p_asn_sig_len); + + +#endif // OPTIGA_BACKEND_UTILS_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto.h new file mode 100644 index 0000000..251055f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto.h @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2016 - 2019, 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 NRF_CRYPTO_H__ +#define NRF_CRYPTO_H__ + +/** + * @defgroup nrf_crypto Cryptography library + * @ingroup app_common + * @{ + * + * @brief Cryptography library (nrf_crypto). + * + * @details The cryptography library provides cryptographic functionality in a portable way. + * + * @note The functions in this API can run in software or hardware, depending on the supported features of your SoC and the configuration of nrf_crypto backend in the application. + * See @ref lib_crypto_config for details on changing the nrf_crypto backend. + * + * @} + * + */ + + + +#include +#include "nrf_crypto_init.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_hash.h" +#include "nrf_crypto_ecdsa.h" +#include "nrf_crypto_ecdh.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_aes.h" +#include "nrf_crypto_aead.h" +#include "nrf_crypto_hmac.h" +#include "nrf_crypto_hkdf.h" +#include "nrf_crypto_eddsa.h" + + +#endif // NRF_CRYPTO_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.c new file mode 100644 index 0000000..4208b61 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.c @@ -0,0 +1,159 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "nrf_crypto_error.h" +#include "nrf_crypto_aead.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AEAD) + +static ret_code_t context_verify(nrf_crypto_aead_internal_context_t const * p_context) +{ + VERIFY_TRUE((p_context != NULL), NRF_ERROR_CRYPTO_CONTEXT_NULL); + + VERIFY_TRUE((p_context->init_value == NRF_CRYPTO_AEAD_INIT_MAGIC_VALUE), + NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_aead_init(nrf_crypto_aead_context_t * const p_context, + nrf_crypto_aead_info_t const * const p_info, + uint8_t * p_key) +{ + ret_code_t ret_val; + + nrf_crypto_aead_internal_context_t * p_int_context = + (nrf_crypto_aead_internal_context_t *)p_context; + + VERIFY_TRUE((p_info != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_TRUE((p_key != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + ret_val = context_verify(p_int_context); + VERIFY_TRUE((ret_val == NRF_SUCCESS) || (ret_val == NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED), + ret_val); + + p_int_context->init_value = NRF_CRYPTO_AEAD_INIT_MAGIC_VALUE; + p_int_context->p_info = p_info; + + ret_val = p_info->init_fn(p_context, p_key); + + if (ret_val != NRF_SUCCESS) + { + p_int_context->init_value = 0; + } + + return ret_val; +} + +ret_code_t nrf_crypto_aead_uninit(void * const p_context) +{ + ret_code_t ret_val; + + nrf_crypto_aead_internal_context_t * p_int_context = + (nrf_crypto_aead_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_SUCCESS(ret_val); + + ret_val = p_int_context->p_info->uninit_fn(p_context); + + p_int_context->init_value = 0; + + return ret_val; +} + +ret_code_t nrf_crypto_aead_crypt(nrf_crypto_aead_context_t * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size) +{ + ret_code_t ret_val; + + nrf_crypto_aead_internal_context_t * p_int_context = + (nrf_crypto_aead_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_SUCCESS(ret_val); + + VERIFY_FALSE(((p_nonce == NULL) && (nonce_size != 0)), + NRF_ERROR_CRYPTO_INPUT_NULL); + + /* If mac_size == 0 MAC is updated and not stored under p_mac */ + VERIFY_FALSE(((p_mac == NULL) && (mac_size != 0)), + NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_FALSE(((p_adata == NULL) && (adata_size != 0)), + NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_FALSE(((p_data_in == NULL) && (data_in_size != 0)), + NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_FALSE(((p_data_out == NULL) && (data_in_size != 0)), + NRF_ERROR_CRYPTO_OUTPUT_NULL); + + ret_val = p_int_context->p_info->crypt_fn(p_context, + operation, + p_nonce, + nonce_size, + p_adata, + adata_size, + p_data_in, + data_in_size, + p_data_out, + p_mac, + mac_size); + return ret_val; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_AEAD) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.h new file mode 100644 index 0000000..8b5bd56 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead.h @@ -0,0 +1,235 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_AEAD_H__ +#define NRF_CRYPTO_AEAD_H__ + +/** @file + * + * @defgroup nrf_crypto_aead AEAD (Authenticated Encryption with Associated Data) related + * functions. + * @{ + * @ingroup nrf_crypto + * + * @brief Provides AEAD related functionality through nrf_crypto. + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO) || defined(__SDK_DOXYGEN__) + +#include +#include "nrf_crypto_types.h" +#include "nrf_crypto_aead_shared.h" +#include "nrf_crypto_aead_backend.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief External variable declaration to the info structure for AES CCM mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_ccm_128_info; + +/**@brief External variable declaration to the info structure for AES CCM mode with a 192-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_ccm_192_info; + +/**@brief External variable declaration to the info structure for AES CCM mode with a 256-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_ccm_256_info; + +/**@brief External variable declaration to the info structure for AES CCM* mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_ccm_star_128_info; + +/**@brief External variable declaration to the info structure for AES EAX mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_eax_128_info; + +/**@brief External variable declaration to the info structure for AES EAX mode with a 192-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_eax_192_info; + +/**@brief External variable declaration to the info structure for AES EAX mode with a 256-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_eax_256_info; + +/**@brief External variable declaration to the info structure for AES GCM mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @ref sdk_config. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_gcm_128_info; + +/**@brief External variable declaration to the info structure for AES GCM mode with a 192-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @ref sdk_config. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_gcm_192_info; + +/**@brief External variable declaration to the info structure for AES GCM mode with a 256-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @ref sdk_config. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_aes_gcm_256_info; + +/**@brief External variable declaration to the info structure for CHACHA-POLY mode with a 256-bit +* key. +* +* @note The variable is defined in the nrf_crypto backend that is enabled in the @ref sdk_config. +* +*/ +extern const nrf_crypto_aead_info_t g_nrf_crypto_chacha_poly_256_info; + + +/** + * @brief Context type for AEAD. + * + * @note The size of this type is scaled for the largest AEAD backend context that is + * enabled in @ref sdk_config. + */ +typedef nrf_crypto_backend_aead_context_t nrf_crypto_aead_context_t; + + +/**@brief Function for initializing the AEAD calculation context. + * + * @param[in] p_context Pointer to the context object. It must be a context type associated with + * the object provided in the p_info parameter or other memory that can + * hold that context type. + * @param[in] p_info Pointer to structure holding information about: selected AES AEAD mode, + * and key size. + * @param[in] p_key Pointer to AEAD mode key. + * + * @retval NRF_SUCCESS Context was successfully initialized. + */ +ret_code_t nrf_crypto_aead_init(nrf_crypto_aead_context_t * const p_context, + nrf_crypto_aead_info_t const * const p_info, + uint8_t * p_key); + +/**@brief Function for uninitializing the AEAD calculation context. + * + * @param[in] p_context Pointer to the context object. It must be initialized before function call. + * + * @retval NRF_SUCCESS Context was successfully uninitialized. + */ +ret_code_t nrf_crypto_aead_uninit(void * const p_context); + +/**@brief Integrated encryption / decryption function. + * + * @param[in] p_context Context object. Must be initialized before the call. + * @param[in] operation Parameter indicating whether an encrypt (NRF_CRYPTO_ENCRYPT) or + * a decrypt (NRF_CRYPTO_DECRYPT) operation shall be performed. + * @param[in] p_nonce Pointer to nonce. For nonce_size == 0 p_nonce can be NULL. + * @param[in] nonce_size Nonce byte size. Valid values for supported modes: + * - CCM [7 ... 13] + * - CCM* [13] + * - EAX nonce size can be any length + * - GCM nonce size can be any length + * - CHACHA-POLY [12] + * @param[in] p_adata Pointer to additional authenticated data (adata). + * @param[in] adata_size Length of additional authenticated data in bytes. + * For CHACHA-POLY mode must be > 0. + * @param[in] p_data_in Pointer to the input data buffer for encryption or decryption. + * @param[in] data_in_size Length of the data in p_data_in buffer in bytes. Size of the + * p_data_out buffer must not be smaller than this value. + * When selecting CC310 backend data_in_size value shall be limited + * to 65535 bytes. Data out buffer must be at least the same length. + * @param[out] p_data_out Pointer to the output buffer where encrypted or decrypted data + * will be stored. Must be at least 'data_in_size' bytes wide. + * - GCM: On encryption, the p_data_out buffer can be the same as + * the p_data_in buffer. + * On decryption, the p_data_out buffer cannot be the same + * as p_data_in buffer. If buffers overlap, the p_data_out + * buffer must trail at least 8 bytes behind the p_data_in + * buffer. + * @param[out] p_mac Pointer to the MAC result buffer. Fo mac_size == 0 p_mac can be NULL. + * @param[in] mac_size MAC byte size. Valid values for supported modes: + * -CCM [4, 6, 8, 10, 12, 14, 16] + * -CCM* [0, 4, 8, 16] + * -EAX [1 ... 16] + * -GCM [4 ... 16] + * -CHACHA-POLY [16] + * + * @retval NRF_SUCCESS Message was successfully encrypted. + */ +ret_code_t nrf_crypto_aead_crypt(nrf_crypto_aead_context_t * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size); + +#ifdef __cplusplus +} +#endif + +#endif // #if NRF_MODULE_ENABLED(NRF_CRYPTO) || defined(__SDK_DOXYGEN__) + +/** @} */ + +#endif // NRF_CRYPTO_AEAD_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_backend.h new file mode 100644 index 0000000..66d4efc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_backend.h @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_AEAD_BACKEND_H__ +#define NRF_CRYPTO_AEAD_BACKEND_H__ + +#include "cc310_backend_aes_aead.h" +#include "cc310_backend_chacha_poly_aead.h" +#include "cifra_backend_aes_aead.h" +#include "mbedtls_backend_aes_aead.h" +#include "oberon_backend_chacha_poly_aead.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@internal @brief Fallback type for AES CCM context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CCM) +typedef nrf_crypto_aead_internal_context_t nrf_crypto_backend_aes_ccm_context_t; +#endif + +/**@internal @brief Fallback type for AES CCM* context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CCM_STAR) +typedef nrf_crypto_aead_internal_context_t nrf_crypto_backend_aes_ccm_star_context_t; +#endif + +/**@internal @brief Fallback type for AES EAX context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_EAX) +typedef nrf_crypto_aead_internal_context_t nrf_crypto_backend_aes_eax_context_t; +#endif + +/**@internal @brief Fallback type for AES GCM context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_GCM) +typedef nrf_crypto_aead_internal_context_t nrf_crypto_backend_aes_gcm_context_t; +#endif + +/**@internal @brief Fallback type for CHACHA-POLY context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_CHACHA_POLY) +typedef nrf_crypto_aead_internal_context_t nrf_crypto_backend_chacha_poly_context_t; +#endif + +/** @internal @brief Union holding a AEAD context. */ +typedef union +{ + nrf_crypto_backend_aes_ccm_context_t ccm_context; /**< @brief Holds context for AES CCM. */ + nrf_crypto_backend_aes_ccm_star_context_t ccm_star_context; /**< @brief Holds context for AES CCM*. */ + nrf_crypto_backend_aes_eax_context_t eax_context; /**< @brief Holds context for AES EAX. */ + nrf_crypto_backend_aes_gcm_context_t gcm_context; /**< @brief Holds context for AES GCM. */ + + nrf_crypto_backend_chacha_poly_context_t chacha_poly_context; /**< @brief Holds context for ChaCha-Poly. */ +} nrf_crypto_backend_aead_context_t; + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_CRYPTO_AEAD_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_shared.h new file mode 100644 index 0000000..4c0ed81 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aead_shared.h @@ -0,0 +1,147 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_AEAD_SHARED_H__ +#define NRF_CRYPTO_AEAD_SHARED_H__ + +/** @file + * + * @defgroup nrf_crypto_aead_shared AEAD related functions + * @{ + * @ingroup nrf_crypto + * + * @brief Provides AEAD related functionality through nrf_crypto. + */ + +#include +#include "nrf_crypto_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@internal @brief Magic value to signal that the nrf_crypto_hash context structure is initialized. + */ +#define NRF_CRYPTO_AEAD_INIT_MAGIC_VALUE (0x44414541) // ASCII "AEAD" + +#define NRF_CRYPTO_AES_CCM_STAR_MAC_BITMASK (0x1C) /* [0, 4, 8, 16] allowed MAC size in CCM mode */ +#define NRF_CRYPTO_AES_CCM_MAC_MIN (4u) /* MAC min value in CCM mode */ +#define NRF_CRYPTO_AES_CCM_MAC_MAX (16u) /* MAC max value in CCM mode */ +#define NRF_CRYPTO_AES_GCM_MAC_MIN (4u) /* MAC min value in GCM mode */ +#define NRF_CRYPTO_AES_GCM_MAC_MAX (16u) /* MAC max value in GCM mode */ +#define NRF_CRYPTO_AES_CCM_NONCE_SIZE_MIN (7u) /* [7...13] allowed nonce size in CCM mode */ +#define NRF_CRYPTO_AES_CCM_NONCE_SIZE_MAX (13u) /* [7...13] allowed nonce size in CCM mode */ +#define NRF_CRYPTO_AES_CCM_STAR_NONCE_SIZE (13u) /* [13] allowed nonce size in CCM* mode */ +#define NRF_CRYPTO_CHACHA_POLY_NONCE_SIZE (12u) /* [12] allowed nonce size in chacha-poly mode */ +#define NRF_CRYPTO_CHACHA_POLY_MAC_SIZE (16u) /* [16] allowed MAC size in chacha-poly mode */ + +/**@internal @brief Enumeration of supported modes of operation in nrf_crypto_aead. + */ +typedef enum +{ + NRF_CRYPTO_AEAD_MODE_AES_CCM, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AEAD_MODE_AES_CCM_STAR, // supported by: CC310 + NRF_CRYPTO_AEAD_MODE_AES_EAX, // supported by: CIFRA + NRF_CRYPTO_AEAD_MODE_AES_GCM, // supported by: MBEDTLS + NRF_CRYPTO_AEAD_MODE_CHACHA_POLY // supported by: CC310 & OBERON +} nrf_crypto_aead_mode_t; + + +/**@internal @brief Type declaration to perform AEAD initialization in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aead_init for documentation. + */ +typedef ret_code_t (*aead_init_fn_t)(void * const p_context, uint8_t * p_key); + +/**@internal @brief Type declaration to perform AEAD uninitialization in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aead_uninit for documentation. + */ +typedef ret_code_t (*aead_uninit_fn_t)(void * const p_context); + +/**@internal @brief Type declaration to perform AEAD encryption in nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aead_crypt for documentation. + */ +typedef ret_code_t (*aead_crypt_fn_t)(void * const p_context, + nrf_crypto_operation_t operation, + uint8_t * p_nonce, + uint8_t nonce_size, + uint8_t * p_adata, + size_t adata_size, + uint8_t * p_data_in, + size_t data_in_size, + uint8_t * p_data_out, + uint8_t * p_mac, + uint8_t mac_size); + +/**@internal @brief Type declaration for the nrf_crypto_aead info structure. + * + * @details This structure contains the calling interface and any metadata required + * to call the nrf_crypto_aead API functions. + */ +typedef struct +{ + nrf_crypto_aead_mode_t const mode; + nrf_crypto_key_size_id_t const key_size; + + aead_init_fn_t const init_fn; + aead_uninit_fn_t const uninit_fn; + aead_crypt_fn_t const crypt_fn; +} nrf_crypto_aead_info_t; + +/**@internal @brief Type declaration of internal representation of an AEAD context structure. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + uint32_t init_value; + nrf_crypto_aead_info_t const * p_info; +} nrf_crypto_aead_internal_context_t; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef NRF_CRYPTO_AEAD_SHARED_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.c new file mode 100644 index 0000000..47098ac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.c @@ -0,0 +1,319 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "nrf_crypto_aes.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_shared.h" +#include "nrf_crypto_aes_shared.h" +#include "nrf_crypto_aes_backend.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_AES) + +static ret_code_t context_verify(nrf_crypto_aes_internal_context_t const * p_context) +{ + if (p_context == NULL) + { + return NRF_ERROR_CRYPTO_CONTEXT_NULL; + } + + if (p_context->init_value != NRF_CRYPTO_AES_INIT_MAGIC_VALUE) + { + return NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + } + + return NRF_SUCCESS; +} + +ret_code_t nrf_crypto_aes_init(nrf_crypto_aes_context_t * const p_context, + nrf_crypto_aes_info_t const * const p_info, + nrf_crypto_operation_t operation) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_TRUE((ret_val == NRF_SUCCESS) || (ret_val == NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED), + ret_val); + + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + p_int_context->p_info = p_info; + + ret_val = p_info->init_fn(p_context, operation); + + if (ret_val == NRF_SUCCESS) + { + p_int_context->init_value = NRF_CRYPTO_AES_INIT_MAGIC_VALUE; + } + + return ret_val; +} + +ret_code_t nrf_crypto_aes_uninit(nrf_crypto_aes_context_t * const p_context) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + + if (ret_val == NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED) + { + /* If context was uninitialized with function nrf_crypto_aes_finalize it shall be still + possible to clear init_value */ + if (p_int_context->init_value == NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE) + { + ret_val = NRF_SUCCESS; + } + } + VERIFY_SUCCESS(ret_val); + + ret_val = p_int_context->p_info->uninit_fn(p_context); + + p_int_context->init_value = 0; + + return ret_val; +} + +ret_code_t nrf_crypto_aes_key_set(nrf_crypto_aes_context_t * const p_context, uint8_t * p_key) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_SUCCESS(ret_val); + + VERIFY_TRUE((p_key != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + ret_val = p_int_context->p_info->key_set_fn(p_context, p_key); + + return ret_val; +} + +ret_code_t nrf_crypto_aes_iv_set(nrf_crypto_aes_context_t * const p_context, uint8_t * p_iv) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_SUCCESS(ret_val); + + VERIFY_TRUE((p_int_context->p_info->iv_set_fn != NULL), NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + VERIFY_TRUE((p_iv != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + ret_val = p_int_context->p_info->iv_set_fn(p_context, p_iv); + + return ret_val; +} + +ret_code_t nrf_crypto_aes_iv_get(nrf_crypto_aes_context_t * const p_context, uint8_t * p_iv) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + if (ret_val == NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED) + { + /* If context was uninitialized with function nrf_crypto_aes_finalize it shall be still + possible to read IV value */ + if (p_int_context->init_value == NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE) + { + ret_val = NRF_SUCCESS; + } + } + VERIFY_SUCCESS(ret_val); + + VERIFY_TRUE((p_iv != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_TRUE((p_int_context->p_info->iv_get_fn != NULL), NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + ret_val = p_int_context->p_info->iv_get_fn(p_context, p_iv); + + return ret_val; +} + +ret_code_t nrf_crypto_aes_update(nrf_crypto_aes_context_t * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_SUCCESS(ret_val); + + VERIFY_TRUE((data_size != 0), NRF_ERROR_CRYPTO_INPUT_LENGTH); + + VERIFY_TRUE((p_data_in != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_TRUE((p_data_out != NULL), NRF_ERROR_CRYPTO_OUTPUT_NULL); + + if ((data_size & 0xF) != 0) + { + VERIFY_TRUE((p_int_context->p_info->mode == NRF_CRYPTO_AES_MODE_CFB), + NRF_ERROR_CRYPTO_INPUT_LENGTH); + } + + ret_val = p_int_context->p_info->update_fn(p_context, + p_data_in, + data_size, + p_data_out); + + return ret_val; +} + +ret_code_t nrf_crypto_aes_finalize(nrf_crypto_aes_context_t * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + ret_code_t ret_val; + + nrf_crypto_aes_internal_context_t * p_int_context = + (nrf_crypto_aes_internal_context_t *)p_context; + + ret_val = context_verify(p_int_context); + VERIFY_SUCCESS(ret_val); + + VERIFY_TRUE((p_data_in != NULL), NRF_ERROR_CRYPTO_INPUT_NULL); + + VERIFY_TRUE((p_data_out != NULL), NRF_ERROR_CRYPTO_OUTPUT_NULL); + + VERIFY_TRUE((p_data_out_size != NULL), NRF_ERROR_CRYPTO_OUTPUT_NULL); + + ret_val = p_int_context->p_info->finalize_fn(p_context, + p_data_in, + data_size, + p_data_out, + p_data_out_size); + + VERIFY_TRUE((ret_val == NRF_SUCCESS), ret_val); + + ret_val = nrf_crypto_aes_uninit(p_context); + + if (ret_val == NRF_SUCCESS) + { + /* This line will allow to read IV for AES supporting IV get function. */ + p_int_context->init_value = NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE; + } + + return ret_val; +} + +ret_code_t nrf_crypto_aes_crypt(nrf_crypto_aes_context_t * const p_context, + nrf_crypto_aes_info_t const * const p_info, + nrf_crypto_operation_t operation, + uint8_t * p_key, + uint8_t * p_iv, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size) +{ + ret_code_t ret_val; + void * p_allocated_context = NULL; + + nrf_crypto_aes_context_t * p_ctx = p_context; + + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + if (p_ctx == NULL) + { + p_allocated_context = NRF_CRYPTO_ALLOC(p_info->context_size); + if (p_allocated_context == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + p_ctx = (nrf_crypto_aes_context_t *)p_allocated_context; + } + + ret_val = nrf_crypto_aes_init(p_ctx, p_info, operation); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(ret_val, p_allocated_context); + + ret_val = nrf_crypto_aes_key_set(p_ctx, p_key); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(ret_val, p_allocated_context); + + ret_val = nrf_crypto_aes_iv_set(p_ctx, p_iv); + /* not all AES modes support IV */ + if (ret_val != NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE) + { + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(ret_val, p_allocated_context); + } + + ret_val = nrf_crypto_aes_finalize(p_ctx, + p_data_in, + data_size, + p_data_out, + p_data_out_size); + if (ret_val != NRF_SUCCESS) + { + /* Context was not successfully deinitialized in nrf_crypto_aes_finalize */ + UNUSED_RETURN_VALUE(nrf_crypto_aes_uninit(p_ctx)); + } + + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return ret_val; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_AES) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.h new file mode 100644 index 0000000..756289b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes.h @@ -0,0 +1,481 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_AES_H__ +#define NRF_CRYPTO_AES_H__ + +/** @file + * + * @defgroup nrf_crypto_aes AES related functions + * @{ + * @ingroup nrf_crypto + * + * @brief Provides AES related functionality through nrf_crypto. + */ +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO) || defined(__SDK_DOXYGEN__) + +#include +#include "nrf_crypto_types.h" +#include "nrf_crypto_aes_shared.h" +#include "nrf_crypto_aes_backend.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief External variable declaration to the info structure for AES CBC mode with a 128-bit key. +* No padding. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_128_info; + +/**@brief External variable declaration to the info structure for AES CBC mode with a 192-bit key. +* No padding. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_192_info; + +/**@brief External variable declaration to the info structure for AES CBC mode with a 256-bit key. +* No padding. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_256_info; + +/**@brief External variable declaration to the info structure for AES CBC mode with a 128-bit key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_128_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES CBC mode with a 192-bit key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_192_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES CBC mode with a 256-bit key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_256_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES CTR mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ctr_128_info; + +/**@brief External variable declaration to the info structure for AES CTR mode with a 192-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ctr_192_info; + +/**@brief External variable declaration to the info structure for AES CTR mode with a 256-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ctr_256_info; + +/**@brief External variable declaration to the info structure for AES CFB mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cfb_128_info; + +/**@brief External variable declaration to the info structure for AES CFB mode with a 192-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cfb_192_info; + +/**@brief External variable declaration to the info structure for AES CFB mode with a 256-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cfb_256_info; + +/**@brief External variable declaration to the info structure for AES ECB mode with a 128-bit key. +* No padding. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_128_info; + +/**@brief External variable declaration to the info structure for AES ECB mode with a 192-bit key. +* No padding. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_192_info; + +/**@brief External variable declaration to the info structure for AES ECB mode with a 256-bit key. +* No padding. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_256_info; + +/**@brief External variable declaration to the info structure for AES ECB mode with a 128-bit key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_128_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES ECB mode with a 192-bit key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_192_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES ECB mode with a 256-bit key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_256_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES CBC MAC mode with a 128-bit +* key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_128_info; + +/**@brief External variable declaration to the info structure for AES CBC MAC mode with a 192-bit +* key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_192_info; + +/**@brief External variable declaration to the info structure for AES CBC MAC mode with a 256-bit +* key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_256_info; + +/**@brief External variable declaration to the info structure for AES CBC MAC mode with a 128-bit +* key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_128_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES CBC MAC mode with a 192-bit +* key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_192_pad_pkcs7_info; + +/**@brief External variable declaration to the info structure for AES CBC MAC mode with a 256-bit +* key. +* Padding pkcs7 enabled. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_256_pad_pkcs7_info; + + +/**@brief External variable declaration to the info structure for AES CMAC mode with a 128-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cmac_128_info; + +/**@brief External variable declaration to the info structure for AES CMAC mode with a 192-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cmac_192_info; + +/**@brief External variable declaration to the info structure for AES CMAC mode with a 256-bit key. +* +* @note The variable is defined in the nrf_crypto backend that is +* enabled in the @c sdk_config file. +* +*/ +extern const nrf_crypto_aes_info_t g_nrf_crypto_aes_cmac_256_info; + +/** + * @brief Context type for AES. + * + * @note The size of this type is scaled for the largest AES backend context that is + * enabled in @ref sdk_config. + */ +typedef nrf_crypto_backend_aes_context_t nrf_crypto_aes_context_t; + +/**@brief Function for initializing the AES context. + * + * @param[in] p_context Pointer to the context object. It must be a context type associated + * with the object provided in the p_info parameter or other memory + * that can hold that context type. + * @param[in] p_info Pointer to structure holding information about: selected AES mode, + * key size, and padding. + * @param[in] operation Parameter indicating whether an encrypt (NRF_CRYPTO_ENCRYPT), + * a decrypt (NRF_CRYPTO_DECRYPT) or MAC calculation + * (NRF_CRYPTO_MAC_CALCULATE) operation shall be performed. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_init(nrf_crypto_aes_context_t * const p_context, + nrf_crypto_aes_info_t const * const p_info, + nrf_crypto_operation_t operation); + +/**@brief Internal function for uninitializing the AES context. + * + * @param[in] p_context Context object. Must be initialized before the call. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_uninit(nrf_crypto_aes_context_t * const p_context); + +/**@brief Function for setting the AES key. + * + * @param[in] p_context Context object. Must be initialized before the call. + * @param[in] p_key Pointer to the AES key. This buffer will be copied and there is no need + * to keep it by the user. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_key_set(nrf_crypto_aes_context_t * const p_context, uint8_t * p_key); + +/**@brief Function for setting an AES IV or a counter for AES modes which are using it. + * + * @param[in] p_context Context object. Must be initialized before the call. + * @param[in] p_iv Pointer to a buffer of the IV or a counter. This buffer will be copied + * and there is no need to keep it by the user. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_iv_set(nrf_crypto_aes_context_t * const p_context, uint8_t * p_iv); + +/**@brief Function for getting an AES IV or a counter for mode which is supporting it. + * + * @param[in] p_context Context object. Must be initialized before the call. + * @param[out] p_iv Pointer to a buffer of the IV or a counter. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_iv_get(nrf_crypto_aes_context_t * const p_context, uint8_t * p_iv); + +/**@brief AES update function for encryption, decryption and MAC calculation. It can be called once + * on the whole data block, or as many times as needed, until all the input data is processed. + * Functions: @ref nrf_crypto_aes_init, @ref nrf_crypto_aes_key_set, and, for some ciphers, + * @ref nrf_crypto_aes_iv_set, must be called before call to this API with the same context. + + * + * @param[in] p_context Context object. Must be initialized before the call. + * @param[in] p_data_in Pointer to the input buffer to the AES. + * @param[in] data_size Size of the data to be processed in bytes. + * For all modes except CFB it must be multiple of 16 bytes. + * @param[out] p_data_out Pointer to the output buffer. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_update(nrf_crypto_aes_context_t * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out); + + +/**@brief Function processes the last data block if needed and finalizes the AES operation (ie. adds + * padding) and produces operation results (for MAC operations). + * Functions: @ref nrf_crypto_aes_init, @ref nrf_crypto_aes_key_set, and, for some ciphers, + * @ref nrf_crypto_aes_iv_set, must be called before call to this API with the same context. + * + * Upon successful operation function will deinitialize the context but for some ciphers it will be + * possible to read IV. In order to fully deinitialize context you must call + * @ref nrf_crypto_aes_uninit. + * + * @param[in] p_context Context object. Must be initialized before the call. + * @param[in] p_data_in Pointer to the input buffer to the AES. + * @param[in] data_size Size of the data to be processed in bytes. + * @param[out] p_data_out Pointer to the output buffer. + * When padding is set: + * - The size of p_data_out buffer must have extra space for + * padding. Otherwise, the function will return an error: + * NRF_ERROR_CRYPTO_OUTPUT_LENGTH. + * - When text_size is multiple of 16 bytes, p_text_out must be + * allocated with size equal to text_size + an additional block + * (i.e 16 bytes for padding). + * - When text_size is not a multiple of 16 bytes, p_text_out + * must be allocated with size aligned to the next full 16 + * bytes block (i.e. 1 - 15 bytes for padding). + * @param[in,out] p_data_out_size IN: + * Size of the p_data_out buffer. + * OUT: + * Upon successfull function execution value will be updated + * with number of signifacnt bytes in p_data_out buffer. + * On decryption with padding function will result in a value + * without padded bytes. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_finalize(nrf_crypto_aes_context_t * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size); + + + + +/**@brief AES integrated function for encryption, decryption and MAC calculation. + * It should be called once on the whole data block. + * + * @param[in] p_context Context object. If NULL, memory will be dynamically allocated. + * @param[in] p_info Pointer to structure holding information about: selected AES + * mode, key size, and padding. + * @param[in] operation Parameter indicating whether an encrypt (NRF_CRYPTO_ENCRYPT), + * a decrypt (NRF_CRYPTO_DECRYPT) or MAC calculation + * (NRF_CRYPTO_MAC_CALCULATE) operation shall be performed. + * @param[in] p_key Pointer to the AES key. This buffer will be copied and there is + * no need to keep it by the user. + * @param[in] p_iv Pointer to a buffer of the IV or a counter. This buffer will be + * copied and there is no need to keep it by the user. + * Can be NULL for ECB and CMAC. + * @param[in] p_data_in Pointer to the input buffer to the AES. + * @param[in] data_size Size of the data to be processed in bytes. + * @param[out] p_data_out Pointer to the output buffer. + * When padding is set: + * - The size of p_data_out buffer must have extra space for + * padding. Otherwise, the function will return an error: + * NRF_ERROR_CRYPTO_OUTPUT_LENGTH. + * - When text_size is multiple of 16 bytes, p_text_out must be + * allocated with size equal to text_size + an additional block + * (i.e 16 bytes for padding). + * - When text_size is not a multiple of 16 bytes, p_text_out + * must be allocated with size aligned to the next full 16 + * bytes block (i.e. 1 - 15 bytes for padding). + * @param[in,out] p_data_out_size IN: + * Size of the p_data_out buffer. + * OUT: + * Upon successfull function execution value will be updated + * with number of signifacnt bytes in p_data_out buffer. + * On decryption function will result in a value without padded + * bytes. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_aes_crypt(nrf_crypto_aes_context_t * const p_context, + nrf_crypto_aes_info_t const * const p_info, + nrf_crypto_operation_t operation, + uint8_t * p_key, + uint8_t * p_iv, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size); +#ifdef __cplusplus +} +#endif + +#endif // #if NRF_MODULE_ENABLED(NRF_CRYPTO) || defined(__SDK_DOXYGEN__) + +/** @} */ + +#endif // #ifndef NRF_CRYPTO_AES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_backend.h new file mode 100644 index 0000000..6d082dd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_backend.h @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_AES_BACKEND_H__ +#define NRF_CRYPTO_AES_BACKEND_H__ + +#include "cc310_backend_aes.h" +#include "mbedtls_backend_aes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@internal @brief Fallback type for AES CBC context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CBC) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_cbc_context_t; +#endif + +/**@internal @brief Fallback type for AES CFB context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CFB) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_cfb_context_t; +#endif + +/**@internal @brief Fallback type for AES CTR context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CTR) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_ctr_context_t; +#endif + +/**@internal @brief Fallback type for AES ECB context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_ECB) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_ecb_context_t; +#endif + + +/**@internal @brief Fallback type for AES CBC_MAC context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CBC_MAC) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_cbc_mac_context_t; +#endif + +/**@internal @brief Fallback type for AES CMAC context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CMAC) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_cmac_context_t; +#endif + +/**@internal @brief Fallback type for AES CMAC_PRF128 context (if no backend is enabled). + */ +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_AES_CMAC_PRF128) +typedef nrf_crypto_aes_internal_context_t nrf_crypto_backend_aes_cmac_prf128_context_t; +#endif + + +/** @internal @brief Union holding a AES context. */ +typedef union +{ + nrf_crypto_backend_aes_cbc_context_t cbc_context; /**< @brief Holds context for AES CBC. */ + nrf_crypto_backend_aes_cfb_context_t cfb_context; /**< @brief Holds context for AES CFB. */ + nrf_crypto_backend_aes_ctr_context_t ctr_context; /**< @brief Holds context for AES CFB. */ + nrf_crypto_backend_aes_ecb_context_t ecb_context; /**< @brief Holds context for AES ECB. */ + + nrf_crypto_backend_aes_cbc_mac_context_t cbc_mac_context; /**< @brief Holds context for CBC-MAC. */ + nrf_crypto_backend_aes_cmac_context_t cmac_context; /**< @brief Holds context for CMAC. */ + nrf_crypto_backend_aes_cmac_prf128_context_t cmac_prf128_context; /**< @brief Holds context for CMAC_PRF128. */ +} nrf_crypto_backend_aes_context_t; + +#ifdef __cplusplus +} +#endif + +#endif // NRF_CRYPTO_AES_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.c new file mode 100644 index 0000000..11339e0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.c @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "nrf_crypto_error.h" +#include "sdk_config.h" +#include "nrf_crypto_types.h" + + +ret_code_t padding_pkcs7_add(uint8_t * p_padding_buff, + uint8_t * p_message_buff, + uint8_t msg_ending_len) +{ + uint8_t padding_count; + + if ((p_padding_buff == NULL) || (p_message_buff == NULL)) + { + return NRF_ERROR_CRYPTO_INPUT_NULL; + } + + if (msg_ending_len >= NRF_CRYPTO_AES_BLOCK_SIZE) + { + return NRF_ERROR_CRYPTO_INVALID_PARAM; + } + + /* Creating padding buffer in two steps */ + /* step 1 add remaining message */ + memcpy(p_padding_buff, p_message_buff, msg_ending_len); + + /* step 2: add padding */ + padding_count = NRF_CRYPTO_AES_BLOCK_SIZE - msg_ending_len; + p_padding_buff += msg_ending_len; + + for (size_t i = 0; i < padding_count; i++) + { + p_padding_buff[i] = padding_count; + } + + return NRF_SUCCESS; +} + +ret_code_t padding_pkcs7_remove(uint8_t * p_padded_message, + size_t * p_message_len) +{ + if (p_padded_message == NULL) + { + return NRF_ERROR_CRYPTO_INPUT_NULL; + } + if (p_message_len == NULL) + { + return NRF_ERROR_CRYPTO_OUTPUT_NULL; + } + + /* padded_msg_len must be multiple of 16 */ + if ((*p_message_len == 0) || ((*p_message_len & 0x0F) != 0)) + { + return NRF_ERROR_CRYPTO_INVALID_PARAM; + } + + size_t padded_bytes = p_padded_message[*p_message_len - 1]; + + if ((padded_bytes == 0) || (padded_bytes > NRF_CRYPTO_AES_BLOCK_SIZE)) + { + return NRF_ERROR_CRYPTO_AES_INVALID_PADDING; + } + + /* i = 2: 1 for valid string and 1 for already checked *p_message_len - 1 */ + for (size_t i = 2; i < padded_bytes; i++) + { + if (p_padded_message[*p_message_len - i] != padded_bytes) + { + return NRF_ERROR_CRYPTO_AES_INVALID_PADDING; + } + } + + *p_message_len -= padded_bytes; + + return NRF_SUCCESS; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.h new file mode 100644 index 0000000..bb1c86c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_aes_shared.h @@ -0,0 +1,218 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_AES_SHARED_H__ +#define NRF_CRYPTO_AES_SHARED_H__ + +/** @file + * + * @defgroup nrf_crypto_aes AES related functions + * @{ + * @ingroup nrf_crypto + * + * @brief Provides AES related functionality through nrf_crypto. + */ + +#include +#include "nrf_crypto_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/**@internal @brief Magic value to signal that the nrf_crypto_hash context structure is initialized. + */ +#define NRF_CRYPTO_AES_INIT_MAGIC_VALUE (0x53454163) // ASCII "cAES" +#define NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE (0x63414553) // ASCII "SEAc" + +#define NRF_CRYPTO_MBEDTLS_AES_IV_SIZE (16) + + +/** @internal @brief Enumeration of supported modes of operation in nrf_crypto_aes. + */ +typedef enum +{ + NRF_CRYPTO_AES_MODE_CBC, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AES_MODE_CFB, // supported by: MBEDTLS + NRF_CRYPTO_AES_MODE_CTR, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AES_MODE_ECB, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7, // supported by: MBEDTLS & CC310 + + // Authentication modes + NRF_CRYPTO_AES_MODE_CBC_MAC, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7, // supported by: MBEDTLS & CC310 + NRF_CRYPTO_AES_MODE_CMAC, // supported by: MBEDTLS & CC310 +} nrf_crypto_aes_mode_t; + +/**@internal @brief Type declaration to perform AES initialization in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_init for documentation. + */ +typedef ret_code_t (*aes_init_fn_t)(void * const p_context, nrf_crypto_operation_t operation); + +/**@internal @brief Type declaration to perform AES uninitialization in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_uninit for documentation. + */ +typedef ret_code_t (*aes_uninit_fn_t)(void * const p_context); + +/**@internal @brief Type declaration to set an AES key in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_key_set for documentation. + */ +typedef ret_code_t (*aes_key_set_fn_t)(void * const p_context, uint8_t * p_key); + +/**@internal @brief Type declaration to set an AES IV in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_iv_set for documentation. + */ +typedef ret_code_t (*aes_iv_set_fn_t)(void * const p_context, uint8_t * p_iv); + +/**@internal @brief Type declaration to get an AES IV in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_iv_get for documentation. + */ +typedef ret_code_t (*aes_iv_get_fn_t)(void * const p_context, uint8_t * p_iv); + +/**@internal @brief Type declaration to perform AES block operation in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_update for documentation. + */ +typedef ret_code_t (*aes_update_fn_t)(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out); + +/**@internal @brief Type declaration to finalize AES operation in the nrf_crypto backend. + * + * This is internal API. See @ref nrf_crypto_aes_finalize for documentation. + */ +typedef ret_code_t (*aes_finalize_fn_t)(void * const p_context, + uint8_t * p_data_in, + size_t data_size, + uint8_t * p_data_out, + size_t * p_data_out_size); + +/**@internal @brief Type declaration for an nrf_crypto_aes info structure. + * + * @details This structure contains the calling interface and any metadata required + * to call the nrf_crypto_aes API functions. + */ +typedef struct +{ + nrf_crypto_aes_mode_t const mode; + nrf_crypto_key_size_id_t const key_size; + size_t const context_size; + + aes_init_fn_t const init_fn; + aes_uninit_fn_t const uninit_fn; + aes_key_set_fn_t const key_set_fn; + aes_iv_set_fn_t const iv_set_fn; + aes_iv_get_fn_t const iv_get_fn; + aes_update_fn_t const update_fn; + aes_finalize_fn_t const finalize_fn; +} nrf_crypto_aes_info_t; + +/**@internal @brief Type declaration of internal representation of an AES context structure. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + uint32_t init_value; + nrf_crypto_aes_info_t const * p_info; +} nrf_crypto_aes_internal_context_t; + + +/**@internal @brief Type declaration of internal representation of an AES backend context structure. + * with initialization vector. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + nrf_crypto_operation_t operation; + + uint8_t iv[NRF_CRYPTO_MBEDTLS_AES_IV_SIZE]; // space for 128-bit initialization vector +} nrf_crypto_backend_aes_ctx_t; + +/**@internal @brief Type declaration of internal representation of an AES backend context structure + * without initialization vector. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + nrf_crypto_operation_t operation; +} nrf_crypto_backend_no_iv_aes_ctx_t; + + +/**@internal @brief Function copies remainders (msg_ending_len) from p_message_buff to the + * p_padding_buff. Next it adds pkcs7-padding to have a 16 bytes p_padding_buff. + * + * @param[in] p_padding_buff Pointer the buffer with padded message. + * @param[in] p_message_buff Pointer to the buffer with message that must be padded. + * @param[in] msg_ending_len Message remainders length. + * + */ +ret_code_t padding_pkcs7_add(uint8_t * p_padding_buff, + uint8_t * p_message_buff, + uint8_t msg_ending_len); + + +/**@internal @brief Function calculate message length without padding. + * + * @param[in] p_padded_message Pointer the buffer with padded message. + * @param[in/out] p_message_len IN: padded message length + * OUT: message length without padding + */ +ret_code_t padding_pkcs7_remove(uint8_t * p_padded_message, + size_t * p_message_len); + + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // #ifndef NRF_CRYPTO_AES_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.c new file mode 100644 index 0000000..0ad571a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.c @@ -0,0 +1,1314 @@ +/** + * Copyright (c) 2018 - 2019, 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 +#include + +#include "nordic_common.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_ecc.h" +#include "app_util.h" +#include "sdk_macros.h" + + +#if NRF_CRYPTO_ECC_ENABLED + + +#if NRF_CRYPTO_ECC_IMPLEMENTED_CURVES_COUNT > 1 + + +static const nrf_crypto_backend_ecc_key_pair_generate_fn_t key_pair_generate_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_key_pair_generate, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_key_pair_generate, +#endif +}; + + +static const uint16_t key_pair_generate_context_size[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_BACKEND_SECP160R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_BACKEND_SECP160R2_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_BACKEND_SECP192R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_BACKEND_SECP224R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_BACKEND_SECP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_BACKEND_SECP521R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_BACKEND_SECP160K1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_BACKEND_SECP192K1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_BACKEND_SECP224K1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_BACKEND_SECP256K1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_BACKEND_BP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_BACKEND_BP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_BACKEND_BP512R1_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_BACKEND_CURVE25519_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + NRF_CRYPTO_BACKEND_ED25519_KEY_PAIR_GENERATE_CONTEXT_SIZE, +#endif +}; + + +static const nrf_crypto_backend_ecc_public_key_calculate_fn_t public_key_calculate_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_public_key_calculate, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_public_key_calculate, +#endif +}; + + +static const uint16_t public_key_calculate_context_size[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_BACKEND_SECP160R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_BACKEND_SECP160R2_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_BACKEND_SECP192R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_BACKEND_SECP224R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_BACKEND_SECP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_BACKEND_SECP521R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_BACKEND_SECP160K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_BACKEND_SECP192K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_BACKEND_SECP224K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_BACKEND_SECP256K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_BACKEND_BP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_BACKEND_BP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_BACKEND_BP512R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_BACKEND_CURVE25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + NRF_CRYPTO_BACKEND_ED25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE, +#endif +}; + + +static const nrf_crypto_backend_ecc_private_key_from_raw_fn_t private_key_from_raw_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_private_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_private_key_from_raw, +#endif +}; + + +static const nrf_crypto_backend_ecc_private_key_to_raw_fn_t private_key_to_raw_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_private_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_private_key_to_raw, +#endif +}; + + +static const nrf_crypto_backend_ecc_public_key_from_raw_fn_t public_key_from_raw_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_public_key_from_raw, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_public_key_from_raw, +#endif +}; + + +static const nrf_crypto_backend_ecc_public_key_to_raw_fn_t public_key_to_raw_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_public_key_to_raw, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_public_key_to_raw, +#endif +}; + + +static const nrf_crypto_backend_ecc_key_free_fn_t private_key_free_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_private_key_free, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_private_key_free, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_private_key_free, +#endif +}; + + +static const nrf_crypto_backend_ecc_key_free_fn_t public_key_free_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_public_key_free, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_public_key_free, +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + nrf_crypto_backend_ed25519_public_key_free, +#endif +}; + + +#define BACKEND_IMPL_GET(table, curve_type) (table)[(uint32_t)(curve_type)] + + +#else + + +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp160r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp160r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp160r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp160r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp160r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp160r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp160r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp160r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP160R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP160R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP160R2_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp160r2_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp160r2_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp160r2_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp160r2_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp160r2_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp160r2_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp160r2_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp160r2_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP160R2_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP160R2_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP192R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp192r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp192r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp192r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp192r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp192r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp192r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp192r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp192r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP192R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP192R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP224R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp224r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp224r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp224r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp224r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp224r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp224r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp224r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp224r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP224R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP224R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP256R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp256r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp256r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp256r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp256r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp256r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp256r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp256r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp256r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP384R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp384r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp384r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp384r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp384r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp384r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp384r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp384r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp384r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP521R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp521r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp521r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp521r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp521r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp521r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp521r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp521r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp521r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP521R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP521R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP160K1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp160k1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp160k1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp160k1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp160k1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp160k1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp160k1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp160k1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp160k1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP160K1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP160K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP192K1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp192k1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp192k1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp192k1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp192k1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp192k1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp192k1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp192k1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp192k1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP192K1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP192K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP224K1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp224k1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp224k1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp224k1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp224k1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp224k1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp224k1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp224k1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp224k1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP224K1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP224K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP256K1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_secp256k1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_secp256k1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_secp256k1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_secp256k1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_secp256k1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_secp256k1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_secp256k1_private_key_free +#define public_key_free_impl nrf_crypto_backend_secp256k1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_SECP256K1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_SECP256K1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP256R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_bp256r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_bp256r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_bp256r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_bp256r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_bp256r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_bp256r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_bp256r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_bp256r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_BP256R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_BP256R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP384R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_bp384r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_bp384r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_bp384r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_bp384r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_bp384r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_bp384r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_bp384r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_bp384r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_BP384R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_BP384R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP512R1_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_bp512r1_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_bp512r1_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_bp512r1_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_bp512r1_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_bp512r1_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_bp512r1_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_bp512r1_private_key_free +#define public_key_free_impl nrf_crypto_backend_bp512r1_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_BP512R1_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_BP512R1_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_CURVE25519_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_curve25519_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_curve25519_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_curve25519_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_curve25519_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_curve25519_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_curve25519_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_curve25519_private_key_free +#define public_key_free_impl nrf_crypto_backend_curve25519_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_CURVE25519_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_CURVE25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_ED25519_ENABLED +#define key_pair_generate_impl nrf_crypto_backend_ed25519_key_pair_generate +#define public_key_calculate_impl nrf_crypto_backend_ed25519_public_key_calculate +#define private_key_from_raw_impl nrf_crypto_backend_ed25519_private_key_from_raw +#define private_key_to_raw_impl nrf_crypto_backend_ed25519_private_key_to_raw +#define public_key_from_raw_impl nrf_crypto_backend_ed25519_public_key_from_raw +#define public_key_to_raw_impl nrf_crypto_backend_ed25519_public_key_to_raw +#define private_key_free_impl nrf_crypto_backend_ed25519_private_key_free +#define public_key_free_impl nrf_crypto_backend_ed25519_public_key_free +#define key_pair_generate_context_size \ + NRF_CRYPTO_BACKEND_ED25519_KEY_PAIR_GENERATE_CONTEXT_SIZE +#define public_key_calculate_context_size \ + NRF_CRYPTO_BACKEND_ED25519_PUBLIC_KEY_CALCULATE_CONTEXT_SIZE +#else +#define key_pair_generate_impl NULL +#define public_key_calculate_impl NULL +#define private_key_from_raw_impl NULL +#define private_key_to_raw_impl NULL +#define public_key_from_raw_impl NULL +#define public_key_to_raw_impl NULL +#define private_key_free_impl NULL +#define public_key_free_impl NULL +#define key_pair_generate_context_size 0 +#define public_key_calculate_context_size 0 +#endif + + +#define BACKEND_IMPL_GET(function, curve_type) (function) + + +#endif + + +ret_code_t nrf_crypto_internal_ecc_key_output_prepare( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_internal_ecc_key_header_t * p_key_header) +{ + // Check NULL pointers + VERIFY_TRUE(p_curve_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(p_key_header != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + + // Clear init value to indicate that this key is not valid yet. + p_key_header->init_value = 0; + // Save curve info inside the header + p_key_header->p_info = p_curve_info; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_internal_ecc_key_input_check( + nrf_crypto_internal_ecc_key_header_t const * p_key_header, + uint32_t init_value) +{ + // Check NULL pointer + VERIFY_TRUE(p_key_header != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + // Check init value + VERIFY_TRUE(p_key_header->init_value == init_value, NRF_ERROR_CRYPTO_ECC_KEY_NOT_INITIALIZED); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_internal_ecc_raw_output_prepare( + uint8_t * p_raw_data, + size_t * p_raw_data_size, + size_t expected_size) +{ + // Check NULL pointer + VERIFY_TRUE(p_raw_data != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + + if (p_raw_data_size != NULL) // User can provide NULL as p_raw_data_size to skip size checking + { + // Check if data fits into buffer + VERIFY_TRUE(*p_raw_data_size >= expected_size, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + // Provide actual data size + *p_raw_data_size = expected_size; + } + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_internal_ecc_raw_input_check( + uint8_t const * p_raw_data, + size_t raw_data_size, + size_t expected_size) +{ + VERIFY_TRUE(p_raw_data != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(raw_data_size == expected_size, NRF_ERROR_CRYPTO_INPUT_LENGTH); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_ecc_key_pair_generate( + nrf_crypto_ecc_key_pair_generate_context_t * p_context, + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_ecc_private_key_t * p_private_key, + nrf_crypto_ecc_public_key_t * p_public_key) +{ + ret_code_t result; + void * p_allocated_context = NULL; + nrf_crypto_backend_ecc_key_pair_generate_fn_t backend_implementation; + size_t context_size; + + // Get pointer to header for each key + nrf_crypto_internal_ecc_key_header_t * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_private_key; + nrf_crypto_internal_ecc_key_header_t * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_output_prepare(p_curve_info, p_private_key_header); + VERIFY_SUCCESS(result); + result = nrf_crypto_internal_ecc_key_output_prepare(p_curve_info, p_public_key_header); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(key_pair_generate_impl, p_curve_info->curve_type); + context_size = BACKEND_IMPL_GET(key_pair_generate_context_size, p_curve_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Allocate context if not provided + if (p_context == NULL && context_size > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(context_size); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = backend_implementation(p_context, p_private_key, p_public_key); + + // Set init values to indicate valid key + if (result == NRF_SUCCESS) + { + p_private_key_header->init_value = NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE; + p_public_key_header->init_value = NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE; + } + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + + +ret_code_t nrf_crypto_ecc_public_key_calculate( + nrf_crypto_ecc_public_key_calculate_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + nrf_crypto_ecc_public_key_t * p_public_key) +{ + ret_code_t result; + void * p_allocated_context = NULL; + nrf_crypto_backend_ecc_public_key_calculate_fn_t backend_implementation; + size_t context_size; + nrf_crypto_ecc_curve_info_t const * p_info; + + // Get pointer to header for each key + nrf_crypto_internal_ecc_key_header_t const * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_private_key; + nrf_crypto_internal_ecc_key_header_t * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_private_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_private_key_header->p_info; + result = nrf_crypto_internal_ecc_key_output_prepare(p_info, p_public_key_header); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(public_key_calculate_impl, p_info->curve_type); + context_size = BACKEND_IMPL_GET(public_key_calculate_context_size, p_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Allocate context if not provided + if (p_context == NULL && context_size > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(context_size); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = backend_implementation(p_context, p_private_key, p_public_key); + + // Set init values to indicate valid key + if (result == NRF_SUCCESS) + { + p_public_key_header->init_value = NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE; + } + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + + +ret_code_t nrf_crypto_ecc_private_key_from_raw( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_ecc_private_key_t * p_private_key, + uint8_t const * p_raw_data, + size_t raw_data_size) +{ + ret_code_t result; + nrf_crypto_backend_ecc_private_key_from_raw_fn_t backend_implementation; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_private_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_output_prepare(p_curve_info, + p_private_key_header); + VERIFY_SUCCESS(result); + result = nrf_crypto_internal_ecc_raw_input_check(p_raw_data, + raw_data_size, + p_curve_info->raw_private_key_size); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(private_key_from_raw_impl, p_curve_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Execute backend implementation + result = backend_implementation(p_private_key, p_raw_data); + + // Set init value to indicate valid key + if (result == NRF_SUCCESS) + { + p_private_key_header->init_value = NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE; + } + + return result; +} + + +ret_code_t nrf_crypto_ecc_private_key_to_raw( + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t * p_raw_data, + size_t * p_raw_data_size) +{ + ret_code_t result; + nrf_crypto_ecc_curve_info_t const * p_info; + nrf_crypto_backend_ecc_private_key_to_raw_fn_t backend_implementation; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_private_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_private_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_private_key_header->p_info; + result = nrf_crypto_internal_ecc_raw_output_prepare(p_raw_data, + p_raw_data_size, + p_info->raw_private_key_size); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(private_key_to_raw_impl, p_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Execute backend implementation + result = backend_implementation(p_private_key, p_raw_data); + + return result; +} + + +ret_code_t nrf_crypto_ecc_public_key_from_raw( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_ecc_public_key_t * p_public_key, + uint8_t const * p_raw_data, + size_t raw_data_size) +{ + ret_code_t result; + nrf_crypto_backend_ecc_private_key_from_raw_fn_t backend_implementation; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_output_prepare(p_curve_info, + p_public_key_header); + VERIFY_SUCCESS(result); + result = nrf_crypto_internal_ecc_raw_input_check(p_raw_data, + raw_data_size, + p_curve_info->raw_public_key_size); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(public_key_from_raw_impl, p_curve_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Execute backend implementation + result = backend_implementation(p_public_key, p_raw_data); + + // Set init value to indicate valid key + if (result == NRF_SUCCESS) + { + p_public_key_header->init_value = NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE; + } + + return result; +} + + +ret_code_t nrf_crypto_ecc_public_key_to_raw( + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t * p_raw_data, + size_t * p_raw_data_size) +{ + ret_code_t result; + nrf_crypto_ecc_curve_info_t const * p_info; + nrf_crypto_backend_ecc_public_key_to_raw_fn_t backend_implementation; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_public_key_header, + NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_public_key_header->p_info; + result = nrf_crypto_internal_ecc_raw_output_prepare(p_raw_data, + p_raw_data_size, + p_info->raw_public_key_size); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(public_key_to_raw_impl, p_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Execute backend implementation + result = backend_implementation(p_public_key, p_raw_data); + + return result; +} + + +ret_code_t nrf_crypto_ecc_private_key_free( + nrf_crypto_ecc_private_key_t * p_private_key) +{ + ret_code_t result; + nrf_crypto_ecc_curve_info_t const * p_info; + nrf_crypto_backend_ecc_key_free_fn_t backend_implementation; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_private_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_private_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_private_key_header->p_info; + + UNUSED_PARAMETER(p_info); // Is some situations BACKEND_IMPL_GET() macro may not use second parameter + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(private_key_free_impl, p_info->curve_type); + + if (backend_implementation != NULL) + { + // Execute backend implementation + result = backend_implementation(p_private_key); + } + else + { + // Free is not implemented by the backend, so nothing have to deallocated. + result = NRF_SUCCESS; + } + + // Clear init value to indicate invalid key + p_private_key_header->init_value = 0; + + return result; +} + + +ret_code_t nrf_crypto_ecc_public_key_free( + nrf_crypto_ecc_public_key_t * p_public_key) +{ + ret_code_t result; + nrf_crypto_ecc_curve_info_t const * p_info; + nrf_crypto_backend_ecc_key_free_fn_t backend_implementation; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_public_key_header, + NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_public_key_header->p_info; + + UNUSED_PARAMETER(p_info); // Is some situations BACKEND_IMPL_GET() macro may not use second parameter + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(public_key_free_impl, p_info->curve_type); + + if (backend_implementation != NULL) + { + // Execute backend implementation + result = backend_implementation(p_public_key); + } + else + { + // Free is not implemented by the backend, so nothing have to deallocated. + result = NRF_SUCCESS; + } + + // Clear init value to indicate invalid key + p_public_key_header->init_value = 0; + + return result; +} + + +ret_code_t nrf_crypto_ecc_curve_info_get( + void const * p_key, + nrf_crypto_ecc_curve_info_t const ** pp_curve_info) +{ + ret_code_t result; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_key; + + // Check and prepare parameters + VERIFY_TRUE(pp_curve_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + result = nrf_crypto_internal_ecc_key_input_check( + p_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + if (result != NRF_SUCCESS) + { + // p_key can be private or public key, so check second case here + result = nrf_crypto_internal_ecc_key_input_check( + p_key_header, + NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE); + } + VERIFY_SUCCESS(result); + + // Write output parameter + *pp_curve_info = p_key_header->p_info; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_ecc_byte_order_invert( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + uint8_t const * p_raw_input, + uint8_t * p_raw_output, + size_t raw_data_size) +{ + uint8_t temp; + size_t from_index; + size_t to_index; + size_t integer_size; + + if (p_curve_info == NULL) + { + integer_size = raw_data_size; + } + else + { + integer_size = p_curve_info->raw_private_key_size; + } + + VERIFY_TRUE(p_raw_input != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(p_raw_output != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + + // Loop over each big integer of the input + while (raw_data_size >= integer_size) + { + // Swap byte by byte in current integer + from_index = 0; + to_index = integer_size - 1; + while (from_index <= to_index) + { + // Swap bytes from source to destination, this may be the same buffer, so use temporary variable + temp = p_raw_input[from_index]; + p_raw_output[from_index] = p_raw_input[to_index]; + p_raw_output[to_index] = temp; + // Go to next pair of bytes + from_index++; + to_index--; + } + // Go to next integer + raw_data_size -= integer_size; + p_raw_input += integer_size; + p_raw_output += integer_size; + } + + if (raw_data_size != 0) + { + // Input size is not a multiple of big integer size, so it is invalid + return NRF_ERROR_CRYPTO_INPUT_LENGTH; + } + + return NRF_SUCCESS; +} + + +#endif // NRF_CRYPTO_ECC_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.h new file mode 100644 index 0000000..37ef359 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc.h @@ -0,0 +1,969 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECC_H__ +#define NRF_CRYPTO_ECC_H__ + +/** @addtogroup nrf_crypto + * @{ + * @addtogroup nrf_crypto_ecc Elliptic Curve Cryptography Key Management + * @{ + * @brief Provides elliptic curve cryptography API for public and private key management. + * + * @addtogroup nrf_crypto_ecc_secp160r1 Definitions specific to secp160r1 (NIST 160-bit) + * @addtogroup nrf_crypto_ecc_secp160r2 Definitions specific to secp160r2 (NIST 160-bit) + * @addtogroup nrf_crypto_ecc_secp192r1 Definitions specific to secp192r1 (NIST 192-bit) + * @addtogroup nrf_crypto_ecc_secp224r1 Definitions specific to secp224r1 (NIST 224-bit) + * @addtogroup nrf_crypto_ecc_secp256r1 Definitions specific to secp256r1 (NIST 256-bit) + * @addtogroup nrf_crypto_ecc_secp384r1 Definitions specific to secp384r1 (NIST 384-bit) + * @addtogroup nrf_crypto_ecc_secp521r1 Definitions specific to secp521r1 (NIST 521-bit) + * @addtogroup nrf_crypto_ecc_secp160k1 Definitions specific to secp160k1 (Koblitz 160-bit) + * @addtogroup nrf_crypto_ecc_secp192k1 Definitions specific to secp192k1 (Koblitz 192-bit) + * @addtogroup nrf_crypto_ecc_secp224k1 Definitions specific to secp224k1 (Koblitz 224-bit) + * @addtogroup nrf_crypto_ecc_secp256k1 Definitions specific to secp256k1 (Koblitz 256-bit) + * @addtogroup nrf_crypto_ecc_bp256r1 Definitions specific to bp256r1 (Brainpool 256-bit) + * @addtogroup nrf_crypto_ecc_bp384r1 Definitions specific to bp384r1 (Brainpool 384-bit) + * @addtogroup nrf_crypto_ecc_bp512r1 Definitions specific to bp512r1 (Brainpool 512-bit) + * @addtogroup nrf_crypto_ecc_curve25519 Definitions specific to Curve25519 + * @addtogroup nrf_crypto_ecc_ed25519 Definitions specific to Ed25519 + */ + +#include +#include + +#include "nrf_crypto_error.h" +#include "nrf_crypto_ecc_shared.h" +#include "nrf_crypto_ecc_backend.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined(__SDK_DOXYGEN__) +#define NRF_CRYPTO_ECC_SECP160R1_ENABLED 1 /**< @brief Defined as 1 if secp160r1 (NIST 160-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp160r1 */ +#define NRF_CRYPTO_ECC_SECP160R2_ENABLED 1 /**< @brief Defined as 1 if secp160r2 (NIST 160-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp160r2 */ +#define NRF_CRYPTO_ECC_SECP192R1_ENABLED 1 /**< @brief Defined as 1 if secp192r1 (NIST 192-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp192r1 */ +#define NRF_CRYPTO_ECC_SECP224R1_ENABLED 1 /**< @brief Defined as 1 if secp224r1 (NIST 224-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp224r1 */ +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 /**< @brief Defined as 1 if secp256r1 (NIST 256-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp256r1 */ +#define NRF_CRYPTO_ECC_SECP384R1_ENABLED 1 /**< @brief Defined as 1 if secp384r1 (NIST 384-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp384r1 */ +#define NRF_CRYPTO_ECC_SECP521R1_ENABLED 1 /**< @brief Defined as 1 if secp521r1 (NIST 521-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp521r1 */ +#define NRF_CRYPTO_ECC_SECP160K1_ENABLED 1 /**< @brief Defined as 1 if secp160k1 (Koblitz 160-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp160k1 */ +#define NRF_CRYPTO_ECC_SECP192K1_ENABLED 1 /**< @brief Defined as 1 if secp192k1 (Koblitz 192-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp192k1 */ +#define NRF_CRYPTO_ECC_SECP224K1_ENABLED 1 /**< @brief Defined as 1 if secp224k1 (Koblitz 224-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp224k1 */ +#define NRF_CRYPTO_ECC_SECP256K1_ENABLED 1 /**< @brief Defined as 1 if secp256k1 (Koblitz 256-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp256k1 */ +#define NRF_CRYPTO_ECC_BP256R1_ENABLED 1 /**< @brief Defined as 1 if bp256r1 (Brainpool 256-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_bp256r1 */ +#define NRF_CRYPTO_ECC_BP384R1_ENABLED 1 /**< @brief Defined as 1 if bp384r1 (Brainpool 384-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_bp384r1 */ +#define NRF_CRYPTO_ECC_BP512R1_ENABLED 1 /**< @brief Defined as 1 if bp512r1 (Brainpool 512-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_bp512r1 */ +#define NRF_CRYPTO_ECC_CURVE25519_ENABLED 1 /**< @brief Defined as 1 if Curve25519 is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_curve25519 */ +#define NRF_CRYPTO_ECC_ED25519_ENABLED 1 /**< @brief Defined as 1 if Ed25519 is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_ed25519 */ +#endif + + +#define NRF_CRYPTO_ECC_SECP160R1_RAW_PRIVATE_KEY_SIZE (160 / 8) /**< @brief Raw private key size for secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r1 */ +#define NRF_CRYPTO_ECC_SECP160R2_RAW_PRIVATE_KEY_SIZE (160 / 8) /**< @brief Raw private key size for secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r2 */ +#define NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE (192 / 8) /**< @brief Raw private key size for secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecc_secp192r1 */ +#define NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE (224 / 8) /**< @brief Raw private key size for secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecc_secp224r1 */ +#define NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecc_secp256r1 */ +#define NRF_CRYPTO_ECC_SECP384R1_RAW_PRIVATE_KEY_SIZE (384 / 8) /**< @brief Raw private key size for secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecc_secp384r1 */ +#define NRF_CRYPTO_ECC_SECP521R1_RAW_PRIVATE_KEY_SIZE (528 / 8) /**< @brief Raw private key size for secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecc_secp521r1 */ +#define NRF_CRYPTO_ECC_SECP160K1_RAW_PRIVATE_KEY_SIZE (160 / 8) /**< @brief Raw private key size for secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecc_secp160k1 */ +#define NRF_CRYPTO_ECC_SECP192K1_RAW_PRIVATE_KEY_SIZE (192 / 8) /**< @brief Raw private key size for secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecc_secp192k1 */ +#define NRF_CRYPTO_ECC_SECP224K1_RAW_PRIVATE_KEY_SIZE (224 / 8) /**< @brief Raw private key size for secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecc_secp224k1 */ +#define NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecc_secp256k1 */ +#define NRF_CRYPTO_ECC_BP256R1_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecc_bp256r1 */ +#define NRF_CRYPTO_ECC_BP384R1_RAW_PRIVATE_KEY_SIZE (384 / 8) /**< @brief Raw private key size for bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecc_bp384r1 */ +#define NRF_CRYPTO_ECC_BP512R1_RAW_PRIVATE_KEY_SIZE (512 / 8) /**< @brief Raw private key size for bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecc_bp512r1 */ +#define NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for Curve25519. @ingroup nrf_crypto_ecc_curve25519 */ +#define NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for Ed25519. @ingroup nrf_crypto_ecc_ed25519 */ + + +#define NRF_CRYPTO_ECC_SECP160R1_RAW_PUBLIC_KEY_SIZE (2 * 160 / 8) /**< @brief Raw public key size for curve secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r1 */ +#define NRF_CRYPTO_ECC_SECP160R2_RAW_PUBLIC_KEY_SIZE (2 * 160 / 8) /**< @brief Raw public key size for curve secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r2 */ +#define NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE (2 * 192 / 8) /**< @brief Raw public key size for curve secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecc_secp192r1 */ +#define NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE (2 * 224 / 8) /**< @brief Raw public key size for curve secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecc_secp224r1 */ +#define NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE (2 * 256 / 8) /**< @brief Raw public key size for curve secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecc_secp256r1 */ +#define NRF_CRYPTO_ECC_SECP384R1_RAW_PUBLIC_KEY_SIZE (2 * 384 / 8) /**< @brief Raw public key size for curve secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecc_secp384r1 */ +#define NRF_CRYPTO_ECC_SECP521R1_RAW_PUBLIC_KEY_SIZE (2 * 528 / 8) /**< @brief Raw public key size for curve secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecc_secp521r1 */ +#define NRF_CRYPTO_ECC_SECP160K1_RAW_PUBLIC_KEY_SIZE (2 * 160 / 8) /**< @brief Raw public key size for curve secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecc_secp160k1 */ +#define NRF_CRYPTO_ECC_SECP192K1_RAW_PUBLIC_KEY_SIZE (2 * 192 / 8) /**< @brief Raw public key size for curve secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecc_secp192k1 */ +#define NRF_CRYPTO_ECC_SECP224K1_RAW_PUBLIC_KEY_SIZE (2 * 224 / 8) /**< @brief Raw public key size for curve secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecc_secp224k1 */ +#define NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE (2 * 256 / 8) /**< @brief Raw public key size for curve secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecc_secp256k1 */ +#define NRF_CRYPTO_ECC_BP256R1_RAW_PUBLIC_KEY_SIZE (2 * 256 / 8) /**< @brief Raw public key size for curve bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecc_bp256r1 */ +#define NRF_CRYPTO_ECC_BP384R1_RAW_PUBLIC_KEY_SIZE (2 * 384 / 8) /**< @brief Raw public key size for curve bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecc_bp384r1 */ +#define NRF_CRYPTO_ECC_BP512R1_RAW_PUBLIC_KEY_SIZE (2 * 512 / 8) /**< @brief Raw public key size for curve bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecc_bp512r1 */ +#define NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE (256 / 8) /**< @brief Raw public key size for curve Curve25519. @ingroup nrf_crypto_ecc_curve25519 */ +#define NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE (256 / 8) /**< @brief Raw public key size for curve Ed25519. @ingroup nrf_crypto_ecc_ed25519 */ + + +#define NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE /**< @brief Maximum size of a raw private key for all enabled curves. */ +#define NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE /**< @brief Maximum size of a raw public key for all enabled curves. */ + + +/** @brief Defines type of ECC curve. + */ +typedef enum +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_ECC_SECP160R1_CURVE_TYPE, /**< secp160r1 (NIST 160-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_ECC_SECP160R2_CURVE_TYPE, /**< secp160r2 (NIST 160-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, /**< secp192r1 (NIST 192-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, /**< secp224r1 (NIST 224-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, /**< secp256r1 (NIST 256-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_ECC_SECP384R1_CURVE_TYPE, /**< secp384r1 (NIST 384-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_ECC_SECP521R1_CURVE_TYPE, /**< secp521r1 (NIST 521-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_ECC_SECP160K1_CURVE_TYPE, /**< secp160k1 (Koblitz 160-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_ECC_SECP192K1_CURVE_TYPE, /**< secp192k1 (Koblitz 192-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_ECC_SECP224K1_CURVE_TYPE, /**< secp224k1 (Koblitz 224-bit) */ +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, /**< secp256k1 (Koblitz 256-bit) */ +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_ECC_BP256R1_CURVE_TYPE, /**< bp256r1 (Brainpool 256-bit) */ +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_ECC_BP384R1_CURVE_TYPE, /**< bp384r1 (Brainpool 384-bit) */ +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_ECC_BP512R1_CURVE_TYPE, /**< bp512r1 (Brainpool 512-bit) */ +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, /**< Curve25519 */ +#endif +#if NRF_CRYPTO_ECC_ED25519_ENABLED + NRF_CRYPTO_ECC_ED25519_CURVE_TYPE, /**< Ed25519 */ +#endif +#if !NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_ECC_SECP160R1_CURVE_TYPE, /**< secp160r1 (NIST 160-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_ECC_SECP160R2_CURVE_TYPE, /**< secp160r2 (NIST 160-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, /**< secp192r1 (NIST 192-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, /**< secp224r1 (NIST 224-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, /**< secp256r1 (NIST 256-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_ECC_SECP384R1_CURVE_TYPE, /**< secp384r1 (NIST 384-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_ECC_SECP521R1_CURVE_TYPE, /**< secp521r1 (NIST 521-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_ECC_SECP160K1_CURVE_TYPE, /**< secp160k1 (Koblitz 160-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_ECC_SECP192K1_CURVE_TYPE, /**< secp192k1 (Koblitz 192-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_ECC_SECP224K1_CURVE_TYPE, /**< secp224k1 (Koblitz 224-bit) */ +#endif +#if !NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, /**< secp256k1 (Koblitz 256-bit) */ +#endif +#if !NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_ECC_BP256R1_CURVE_TYPE, /**< bp256r1 (Brainpool 256-bit) */ +#endif +#if !NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_ECC_BP384R1_CURVE_TYPE, /**< bp384r1 (Brainpool 384-bit) */ +#endif +#if !NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_ECC_BP512R1_CURVE_TYPE, /**< bp512r1 (Brainpool 512-bit) */ +#endif +#if !NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, /**< Curve25519 */ +#endif +#if !NRF_CRYPTO_ECC_ED25519_ENABLED + NRF_CRYPTO_ECC_ED25519_CURVE_TYPE, /**< Ed25519 */ +#endif +} nrf_crypto_ecc_curve_type_t; + + +/** @brief Structure holding information on a specific curve. + * + * @note This structure cannot be used to create a new variable. Only the variables defined by this + * library can be used, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info. + */ +typedef struct nrf_crypto_ecc_curve_info_s +{ + uint16_t public_key_size; /**< @brief Size of a structure holding internal public key. */ + uint16_t private_key_size; /**< @brief Size of a structure holding internal private key. */ + nrf_crypto_ecc_curve_type_t curve_type; /**< @brief Type of the curve. */ + uint8_t raw_private_key_size; /**< @brief Size of a buffer containing raw private key. */ + uint8_t raw_public_key_size; /**< @brief Size of a buffer containing raw public key. */ + void * p_backend_data; /**< @brief Field to hold backend specific internal data. */ +} nrf_crypto_ecc_curve_info_t; + + +/** @addtogroup nrf_crypto_ecc_secp160r1 + * @{ */ + +typedef nrf_crypto_backend_secp160r1_key_pair_generate_context_t + nrf_crypto_ecc_secp160r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp160r1 (NIST 160-bit). */ +typedef nrf_crypto_backend_secp160r1_public_key_calculate_context_t + nrf_crypto_ecc_secp160r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp160r1 (NIST 160-bit). */ +typedef nrf_crypto_backend_secp160r1_private_key_t + nrf_crypto_ecc_secp160r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp160r1 (NIST 160-bit) */ +typedef nrf_crypto_backend_secp160r1_public_key_t + nrf_crypto_ecc_secp160r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp160r1 (NIST 160-bit) */ +typedef uint8_t nrf_crypto_ecc_secp160r1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP160R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp160r1 (NIST 160-bit) */ +typedef uint8_t nrf_crypto_ecc_secp160r1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP160R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp160r1 (NIST 160-bit) */ + + + +/** @brief Variable containing information on secp160r1 (NIST 160-bit). + * + * It can be used as a parameter for the functions creating secp160r1 (NIST 160-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp160r2 + * @{ */ + +typedef nrf_crypto_backend_secp160r2_key_pair_generate_context_t + nrf_crypto_ecc_secp160r2_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp160r2 (NIST 160-bit). */ +typedef nrf_crypto_backend_secp160r2_public_key_calculate_context_t + nrf_crypto_ecc_secp160r2_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp160r2 (NIST 160-bit). */ +typedef nrf_crypto_backend_secp160r2_private_key_t + nrf_crypto_ecc_secp160r2_private_key_t; /**< @brief Structure holding internal representation of a private key for secp160r2 (NIST 160-bit) */ +typedef nrf_crypto_backend_secp160r2_public_key_t + nrf_crypto_ecc_secp160r2_public_key_t; /**< @brief Structure holding internal representation of a public key for secp160r2 (NIST 160-bit) */ +typedef uint8_t nrf_crypto_ecc_secp160r2_raw_private_key_t + [NRF_CRYPTO_ECC_SECP160R2_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp160r2 (NIST 160-bit) */ +typedef uint8_t nrf_crypto_ecc_secp160r2_raw_public_key_t + [NRF_CRYPTO_ECC_SECP160R2_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp160r2 (NIST 160-bit) */ + + + +/** @brief Variable containing information on secp160r2 (NIST 160-bit). + * + * It can be used as a parameter for the functions creating secp160r2 (NIST 160-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160r2_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp192r1 + * @{ */ + +typedef nrf_crypto_backend_secp192r1_key_pair_generate_context_t + nrf_crypto_ecc_secp192r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp192r1 (NIST 192-bit). */ +typedef nrf_crypto_backend_secp192r1_public_key_calculate_context_t + nrf_crypto_ecc_secp192r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp192r1 (NIST 192-bit). */ +typedef nrf_crypto_backend_secp192r1_private_key_t + nrf_crypto_ecc_secp192r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp192r1 (NIST 192-bit) */ +typedef nrf_crypto_backend_secp192r1_public_key_t + nrf_crypto_ecc_secp192r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp192r1 (NIST 192-bit) */ +typedef uint8_t nrf_crypto_ecc_secp192r1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp192r1 (NIST 192-bit) */ +typedef uint8_t nrf_crypto_ecc_secp192r1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp192r1 (NIST 192-bit) */ + + + +/** @brief Variable containing information on secp192r1 (NIST 192-bit). + * + * It can be used as a parameter for the functions creating secp192r1 (NIST 192-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp224r1 + * @{ */ + +typedef nrf_crypto_backend_secp224r1_key_pair_generate_context_t + nrf_crypto_ecc_secp224r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp224r1 (NIST 224-bit). */ +typedef nrf_crypto_backend_secp224r1_public_key_calculate_context_t + nrf_crypto_ecc_secp224r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp224r1 (NIST 224-bit). */ +typedef nrf_crypto_backend_secp224r1_private_key_t + nrf_crypto_ecc_secp224r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp224r1 (NIST 224-bit) */ +typedef nrf_crypto_backend_secp224r1_public_key_t + nrf_crypto_ecc_secp224r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp224r1 (NIST 224-bit) */ +typedef uint8_t nrf_crypto_ecc_secp224r1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp224r1 (NIST 224-bit) */ +typedef uint8_t nrf_crypto_ecc_secp224r1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp224r1 (NIST 224-bit) */ + + + +/** @brief Variable containing information on secp224r1 (NIST 224-bit). + * + * It can be used as a parameter for the functions creating secp224r1 (NIST 224-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp256r1 + * @{ */ + +typedef nrf_crypto_backend_secp256r1_key_pair_generate_context_t + nrf_crypto_ecc_secp256r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp256r1 (NIST 256-bit). */ +typedef nrf_crypto_backend_secp256r1_public_key_calculate_context_t + nrf_crypto_ecc_secp256r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp256r1 (NIST 256-bit). */ +typedef nrf_crypto_backend_secp256r1_private_key_t + nrf_crypto_ecc_secp256r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp256r1 (NIST 256-bit) */ +typedef nrf_crypto_backend_secp256r1_public_key_t + nrf_crypto_ecc_secp256r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp256r1 (NIST 256-bit) */ +typedef uint8_t nrf_crypto_ecc_secp256r1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp256r1 (NIST 256-bit) */ +typedef uint8_t nrf_crypto_ecc_secp256r1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp256r1 (NIST 256-bit) */ + + + +/** @brief Variable containing information on secp256r1 (NIST 256-bit). + * + * It can be used as a parameter for the functions creating secp256r1 (NIST 256-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp384r1 + * @{ */ + +typedef nrf_crypto_backend_secp384r1_key_pair_generate_context_t + nrf_crypto_ecc_secp384r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp384r1 (NIST 384-bit). */ +typedef nrf_crypto_backend_secp384r1_public_key_calculate_context_t + nrf_crypto_ecc_secp384r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp384r1 (NIST 384-bit). */ +typedef nrf_crypto_backend_secp384r1_private_key_t + nrf_crypto_ecc_secp384r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp384r1 (NIST 384-bit) */ +typedef nrf_crypto_backend_secp384r1_public_key_t + nrf_crypto_ecc_secp384r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp384r1 (NIST 384-bit) */ +typedef uint8_t nrf_crypto_ecc_secp384r1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP384R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp384r1 (NIST 384-bit) */ +typedef uint8_t nrf_crypto_ecc_secp384r1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP384R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp384r1 (NIST 384-bit) */ + + + +/** @brief Variable containing information on secp384r1 (NIST 384-bit). + * + * It can be used as a parameter for the functions creating secp384r1 (NIST 384-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp384r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp521r1 + * @{ */ + +typedef nrf_crypto_backend_secp521r1_key_pair_generate_context_t + nrf_crypto_ecc_secp521r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp521r1 (NIST 521-bit). */ +typedef nrf_crypto_backend_secp521r1_public_key_calculate_context_t + nrf_crypto_ecc_secp521r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp521r1 (NIST 521-bit). */ +typedef nrf_crypto_backend_secp521r1_private_key_t + nrf_crypto_ecc_secp521r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp521r1 (NIST 521-bit) */ +typedef nrf_crypto_backend_secp521r1_public_key_t + nrf_crypto_ecc_secp521r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp521r1 (NIST 521-bit) */ +typedef uint8_t nrf_crypto_ecc_secp521r1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP521R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp521r1 (NIST 521-bit) */ +typedef uint8_t nrf_crypto_ecc_secp521r1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP521R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp521r1 (NIST 521-bit) */ + + + +/** @brief Variable containing information on secp521r1 (NIST 521-bit). + * + * It can be used as a parameter for the functions creating secp521r1 (NIST 521-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp521r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp160k1 + * @{ */ + +typedef nrf_crypto_backend_secp160k1_key_pair_generate_context_t + nrf_crypto_ecc_secp160k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp160k1 (Koblitz 160-bit). */ +typedef nrf_crypto_backend_secp160k1_public_key_calculate_context_t + nrf_crypto_ecc_secp160k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp160k1 (Koblitz 160-bit). */ +typedef nrf_crypto_backend_secp160k1_private_key_t + nrf_crypto_ecc_secp160k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp160k1 (Koblitz 160-bit) */ +typedef nrf_crypto_backend_secp160k1_public_key_t + nrf_crypto_ecc_secp160k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp160k1 (Koblitz 160-bit) */ +typedef uint8_t nrf_crypto_ecc_secp160k1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP160K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp160k1 (Koblitz 160-bit) */ +typedef uint8_t nrf_crypto_ecc_secp160k1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP160K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp160k1 (Koblitz 160-bit) */ + + + +/** @brief Variable containing information on secp160k1 (Koblitz 160-bit). + * + * It can be used as a parameter for the functions creating secp160k1 (Koblitz 160-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160k1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp192k1 + * @{ */ + +typedef nrf_crypto_backend_secp192k1_key_pair_generate_context_t + nrf_crypto_ecc_secp192k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp192k1 (Koblitz 192-bit). */ +typedef nrf_crypto_backend_secp192k1_public_key_calculate_context_t + nrf_crypto_ecc_secp192k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp192k1 (Koblitz 192-bit). */ +typedef nrf_crypto_backend_secp192k1_private_key_t + nrf_crypto_ecc_secp192k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp192k1 (Koblitz 192-bit) */ +typedef nrf_crypto_backend_secp192k1_public_key_t + nrf_crypto_ecc_secp192k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp192k1 (Koblitz 192-bit) */ +typedef uint8_t nrf_crypto_ecc_secp192k1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP192K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp192k1 (Koblitz 192-bit) */ +typedef uint8_t nrf_crypto_ecc_secp192k1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP192K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp192k1 (Koblitz 192-bit) */ + + + +/** @brief Variable containing information on secp192k1 (Koblitz 192-bit). + * + * It can be used as a parameter for the functions creating secp192k1 (Koblitz 192-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192k1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp224k1 + * @{ */ + +typedef nrf_crypto_backend_secp224k1_key_pair_generate_context_t + nrf_crypto_ecc_secp224k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp224k1 (Koblitz 224-bit). */ +typedef nrf_crypto_backend_secp224k1_public_key_calculate_context_t + nrf_crypto_ecc_secp224k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp224k1 (Koblitz 224-bit). */ +typedef nrf_crypto_backend_secp224k1_private_key_t + nrf_crypto_ecc_secp224k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp224k1 (Koblitz 224-bit) */ +typedef nrf_crypto_backend_secp224k1_public_key_t + nrf_crypto_ecc_secp224k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp224k1 (Koblitz 224-bit) */ +typedef uint8_t nrf_crypto_ecc_secp224k1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP224K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp224k1 (Koblitz 224-bit) */ +typedef uint8_t nrf_crypto_ecc_secp224k1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP224K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp224k1 (Koblitz 224-bit) */ + + + +/** @brief Variable containing information on secp224k1 (Koblitz 224-bit). + * + * It can be used as a parameter for the functions creating secp224k1 (Koblitz 224-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224k1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_secp256k1 + * @{ */ + +typedef nrf_crypto_backend_secp256k1_key_pair_generate_context_t + nrf_crypto_ecc_secp256k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp256k1 (Koblitz 256-bit). */ +typedef nrf_crypto_backend_secp256k1_public_key_calculate_context_t + nrf_crypto_ecc_secp256k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp256k1 (Koblitz 256-bit). */ +typedef nrf_crypto_backend_secp256k1_private_key_t + nrf_crypto_ecc_secp256k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp256k1 (Koblitz 256-bit) */ +typedef nrf_crypto_backend_secp256k1_public_key_t + nrf_crypto_ecc_secp256k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp256k1 (Koblitz 256-bit) */ +typedef uint8_t nrf_crypto_ecc_secp256k1_raw_private_key_t + [NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp256k1 (Koblitz 256-bit) */ +typedef uint8_t nrf_crypto_ecc_secp256k1_raw_public_key_t + [NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp256k1 (Koblitz 256-bit) */ + + + +/** @brief Variable containing information on secp256k1 (Koblitz 256-bit). + * + * It can be used as a parameter for the functions creating secp256k1 (Koblitz 256-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256k1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_bp256r1 + * @{ */ + +typedef nrf_crypto_backend_bp256r1_key_pair_generate_context_t + nrf_crypto_ecc_bp256r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using bp256r1 (Brainpool 256-bit). */ +typedef nrf_crypto_backend_bp256r1_public_key_calculate_context_t + nrf_crypto_ecc_bp256r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using bp256r1 (Brainpool 256-bit). */ +typedef nrf_crypto_backend_bp256r1_private_key_t + nrf_crypto_ecc_bp256r1_private_key_t; /**< @brief Structure holding internal representation of a private key for bp256r1 (Brainpool 256-bit) */ +typedef nrf_crypto_backend_bp256r1_public_key_t + nrf_crypto_ecc_bp256r1_public_key_t; /**< @brief Structure holding internal representation of a public key for bp256r1 (Brainpool 256-bit) */ +typedef uint8_t nrf_crypto_ecc_bp256r1_raw_private_key_t + [NRF_CRYPTO_ECC_BP256R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for bp256r1 (Brainpool 256-bit) */ +typedef uint8_t nrf_crypto_ecc_bp256r1_raw_public_key_t + [NRF_CRYPTO_ECC_BP256R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for bp256r1 (Brainpool 256-bit) */ + + + +/** @brief Variable containing information on bp256r1 (Brainpool 256-bit). + * + * It can be used as a parameter for the functions creating bp256r1 (Brainpool 256-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp256r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_bp384r1 + * @{ */ + +typedef nrf_crypto_backend_bp384r1_key_pair_generate_context_t + nrf_crypto_ecc_bp384r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using bp384r1 (Brainpool 384-bit). */ +typedef nrf_crypto_backend_bp384r1_public_key_calculate_context_t + nrf_crypto_ecc_bp384r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using bp384r1 (Brainpool 384-bit). */ +typedef nrf_crypto_backend_bp384r1_private_key_t + nrf_crypto_ecc_bp384r1_private_key_t; /**< @brief Structure holding internal representation of a private key for bp384r1 (Brainpool 384-bit) */ +typedef nrf_crypto_backend_bp384r1_public_key_t + nrf_crypto_ecc_bp384r1_public_key_t; /**< @brief Structure holding internal representation of a public key for bp384r1 (Brainpool 384-bit) */ +typedef uint8_t nrf_crypto_ecc_bp384r1_raw_private_key_t + [NRF_CRYPTO_ECC_BP384R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for bp384r1 (Brainpool 384-bit) */ +typedef uint8_t nrf_crypto_ecc_bp384r1_raw_public_key_t + [NRF_CRYPTO_ECC_BP384R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for bp384r1 (Brainpool 384-bit) */ + + + +/** @brief Variable containing information on bp384r1 (Brainpool 384-bit). + * + * It can be used as a parameter for the functions creating bp384r1 (Brainpool 384-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp384r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_bp512r1 + * @{ */ + +typedef nrf_crypto_backend_bp512r1_key_pair_generate_context_t + nrf_crypto_ecc_bp512r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using bp512r1 (Brainpool 512-bit). */ +typedef nrf_crypto_backend_bp512r1_public_key_calculate_context_t + nrf_crypto_ecc_bp512r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using bp512r1 (Brainpool 512-bit). */ +typedef nrf_crypto_backend_bp512r1_private_key_t + nrf_crypto_ecc_bp512r1_private_key_t; /**< @brief Structure holding internal representation of a private key for bp512r1 (Brainpool 512-bit) */ +typedef nrf_crypto_backend_bp512r1_public_key_t + nrf_crypto_ecc_bp512r1_public_key_t; /**< @brief Structure holding internal representation of a public key for bp512r1 (Brainpool 512-bit) */ +typedef uint8_t nrf_crypto_ecc_bp512r1_raw_private_key_t + [NRF_CRYPTO_ECC_BP512R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for bp512r1 (Brainpool 512-bit) */ +typedef uint8_t nrf_crypto_ecc_bp512r1_raw_public_key_t + [NRF_CRYPTO_ECC_BP512R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for bp512r1 (Brainpool 512-bit) */ + + + +/** @brief Variable containing information on bp512r1 (Brainpool 512-bit). + * + * It can be used as a parameter for the functions creating bp512r1 (Brainpool 512-bit) keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp512r1_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_curve25519 + * @{ */ + +typedef nrf_crypto_backend_curve25519_key_pair_generate_context_t + nrf_crypto_ecc_curve25519_key_pair_generate_context_t; /**< @brief Context structure for key generation using Curve25519. */ +typedef nrf_crypto_backend_curve25519_public_key_calculate_context_t + nrf_crypto_ecc_curve25519_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using Curve25519. */ +typedef nrf_crypto_backend_curve25519_private_key_t + nrf_crypto_ecc_curve25519_private_key_t; /**< @brief Structure holding internal representation of a private key for Curve25519 */ +typedef nrf_crypto_backend_curve25519_public_key_t + nrf_crypto_ecc_curve25519_public_key_t; /**< @brief Structure holding internal representation of a public key for Curve25519 */ +typedef uint8_t nrf_crypto_ecc_curve25519_raw_private_key_t + [NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for Curve25519 */ +typedef uint8_t nrf_crypto_ecc_curve25519_raw_public_key_t + [NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for Curve25519 */ + + +/** @brief Variable containing information on Curve25519. + * + * It can be used as a parameter for the functions creating Curve25519 keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_curve25519_curve_info; + + +/** @} */ + + +/** @addtogroup nrf_crypto_ecc_ed25519 + * @{ */ + +typedef nrf_crypto_backend_ed25519_key_pair_generate_context_t + nrf_crypto_ecc_ed25519_key_pair_generate_context_t; /**< @brief Context structure for key generation using Ed25519. */ +typedef nrf_crypto_backend_ed25519_public_key_calculate_context_t + nrf_crypto_ecc_ed25519_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using Ed25519. */ +typedef nrf_crypto_backend_ed25519_private_key_t + nrf_crypto_ecc_ed25519_private_key_t; /**< @brief Structure holding internal representation of a private key for Ed25519 */ +typedef nrf_crypto_backend_ed25519_public_key_t + nrf_crypto_ecc_ed25519_public_key_t; /**< @brief Structure holding internal representation of a public key for Ed25519 */ +typedef uint8_t nrf_crypto_ecc_ed25519_raw_private_key_t + [NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for Ed25519 */ +typedef uint8_t nrf_crypto_ecc_ed25519_raw_public_key_t + [NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for Ed25519 */ + + + +/** @brief Variable containing information on Ed25519. + * + * It can be used as a parameter for the functions creating Ed25519 keys. + */ +extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_ed25519_curve_info; + + +/** @} */ + + +typedef uint8_t nrf_crypto_ecc_raw_private_key_t[NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE]; /**< @brief Type big enough to hold a raw private key for any the enabled curves. */ +typedef uint8_t nrf_crypto_ecc_raw_public_key_t [NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE]; /**< @brief Type big enough to hold a raw public key for any the enabled curves. */ + + +/** @brief Union holding a context for a key pair generation. + */ +typedef union +{ + nrf_crypto_ecc_secp160r1_key_pair_generate_context_t context_secp160r1; /**< @brief Holds context for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecc_secp160r2_key_pair_generate_context_t context_secp160r2; /**< @brief Holds context for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecc_secp192r1_key_pair_generate_context_t context_secp192r1; /**< @brief Holds context for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecc_secp224r1_key_pair_generate_context_t context_secp224r1; /**< @brief Holds context for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecc_secp256r1_key_pair_generate_context_t context_secp256r1; /**< @brief Holds context for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecc_secp384r1_key_pair_generate_context_t context_secp384r1; /**< @brief Holds context for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecc_secp521r1_key_pair_generate_context_t context_secp521r1; /**< @brief Holds context for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecc_secp160k1_key_pair_generate_context_t context_secp160k1; /**< @brief Holds context for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecc_secp192k1_key_pair_generate_context_t context_secp192k1; /**< @brief Holds context for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecc_secp224k1_key_pair_generate_context_t context_secp224k1; /**< @brief Holds context for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecc_secp256k1_key_pair_generate_context_t context_secp256k1; /**< @brief Holds context for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecc_bp256r1_key_pair_generate_context_t context_bp256r1; /**< @brief Holds context for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecc_bp384r1_key_pair_generate_context_t context_bp384r1; /**< @brief Holds context for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecc_bp512r1_key_pair_generate_context_t context_bp512r1; /**< @brief Holds context for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecc_curve25519_key_pair_generate_context_t context_curve25519; /**< @brief Holds context for Curve25519. */ + nrf_crypto_ecc_ed25519_key_pair_generate_context_t context_ed25519; /**< @brief Holds context for Ed25519. */ +} nrf_crypto_ecc_key_pair_generate_context_t; + + +/** @brief Union holding a context for a public key calculation. + */ +typedef union +{ + nrf_crypto_ecc_secp160r1_public_key_calculate_context_t context_secp160r1; /**< @brief Holds context for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecc_secp160r2_public_key_calculate_context_t context_secp160r2; /**< @brief Holds context for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecc_secp192r1_public_key_calculate_context_t context_secp192r1; /**< @brief Holds context for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecc_secp224r1_public_key_calculate_context_t context_secp224r1; /**< @brief Holds context for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecc_secp256r1_public_key_calculate_context_t context_secp256r1; /**< @brief Holds context for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecc_secp384r1_public_key_calculate_context_t context_secp384r1; /**< @brief Holds context for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecc_secp521r1_public_key_calculate_context_t context_secp521r1; /**< @brief Holds context for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecc_secp160k1_public_key_calculate_context_t context_secp160k1; /**< @brief Holds context for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecc_secp192k1_public_key_calculate_context_t context_secp192k1; /**< @brief Holds context for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecc_secp224k1_public_key_calculate_context_t context_secp224k1; /**< @brief Holds context for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecc_secp256k1_public_key_calculate_context_t context_secp256k1; /**< @brief Holds context for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecc_bp256r1_public_key_calculate_context_t context_bp256r1; /**< @brief Holds context for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecc_bp384r1_public_key_calculate_context_t context_bp384r1; /**< @brief Holds context for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecc_bp512r1_public_key_calculate_context_t context_bp512r1; /**< @brief Holds context for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecc_curve25519_public_key_calculate_context_t context_curve25519; /**< @brief Holds context for Curve25519. */ + nrf_crypto_ecc_ed25519_public_key_calculate_context_t context_ed25519; /**< @brief Holds context for Ed25519. */ +} nrf_crypto_ecc_public_key_calculate_context_t; + + +/** @brief Union holding representation of a private key for any curve type. + */ +typedef union +{ + nrf_crypto_ecc_secp160r1_private_key_t key_secp160r1; /**< @brief Holds internal representation of a private key for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecc_secp160r2_private_key_t key_secp160r2; /**< @brief Holds internal representation of a private key for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecc_secp192r1_private_key_t key_secp192r1; /**< @brief Holds internal representation of a private key for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecc_secp224r1_private_key_t key_secp224r1; /**< @brief Holds internal representation of a private key for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecc_secp256r1_private_key_t key_secp256r1; /**< @brief Holds internal representation of a private key for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecc_secp384r1_private_key_t key_secp384r1; /**< @brief Holds internal representation of a private key for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecc_secp521r1_private_key_t key_secp521r1; /**< @brief Holds internal representation of a private key for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecc_secp160k1_private_key_t key_secp160k1; /**< @brief Holds internal representation of a private key for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecc_secp192k1_private_key_t key_secp192k1; /**< @brief Holds internal representation of a private key for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecc_secp224k1_private_key_t key_secp224k1; /**< @brief Holds internal representation of a private key for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecc_secp256k1_private_key_t key_secp256k1; /**< @brief Holds internal representation of a private key for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecc_bp256r1_private_key_t key_bp256r1; /**< @brief Holds internal representation of a private key for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecc_bp384r1_private_key_t key_bp384r1; /**< @brief Holds internal representation of a private key for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecc_bp512r1_private_key_t key_bp512r1; /**< @brief Holds internal representation of a private key for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecc_curve25519_private_key_t key_curve25519; /**< @brief Holds internal representation of a private key for Curve25519. */ + nrf_crypto_ecc_ed25519_private_key_t key_ed25519; /**< @brief Holds internal representation of a private key for Ed25519. */ +} nrf_crypto_ecc_private_key_t; + + +/** @brief Union holding representation of a public key for any curve type. + */ +typedef union +{ + nrf_crypto_ecc_secp160r1_public_key_t key_secp160r1; /**< @brief Holds internal representation of a public key for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecc_secp160r2_public_key_t key_secp160r2; /**< @brief Holds internal representation of a public key for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecc_secp192r1_public_key_t key_secp192r1; /**< @brief Holds internal representation of a public key for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecc_secp224r1_public_key_t key_secp224r1; /**< @brief Holds internal representation of a public key for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecc_secp256r1_public_key_t key_secp256r1; /**< @brief Holds internal representation of a public key for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecc_secp384r1_public_key_t key_secp384r1; /**< @brief Holds internal representation of a public key for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecc_secp521r1_public_key_t key_secp521r1; /**< @brief Holds internal representation of a public key for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecc_secp160k1_public_key_t key_secp160k1; /**< @brief Holds internal representation of a public key for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecc_secp192k1_public_key_t key_secp192k1; /**< @brief Holds internal representation of a public key for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecc_secp224k1_public_key_t key_secp224k1; /**< @brief Holds internal representation of a public key for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecc_secp256k1_public_key_t key_secp256k1; /**< @brief Holds internal representation of a public key for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecc_bp256r1_public_key_t key_bp256r1; /**< @brief Holds internal representation of a public key for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecc_bp384r1_public_key_t key_bp384r1; /**< @brief Holds internal representation of a public key for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecc_bp512r1_public_key_t key_bp512r1; /**< @brief Holds internal representation of a public key for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecc_curve25519_public_key_t key_curve25519; /**< @brief Holds internal representation of a public key for Curve25519. */ + nrf_crypto_ecc_ed25519_public_key_t key_ed25519; /**< @brief Holds internal representation of a public key for Ed25519. */ +} nrf_crypto_ecc_public_key_t; + + +/** @brief Generate a new pair of a public key and a private key. + * + * Generated keys have to deallocated using @ref nrf_crypto_ecc_private_key_free and + * @ref nrf_crypto_ecc_public_key_free. + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables + * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info. + * @param[out] p_private_key Pointer to structure where newly generated private key will be put. + * @param[out] p_public_key Pointer to structure where newly generated public key will be put. + */ +ret_code_t nrf_crypto_ecc_key_pair_generate( + nrf_crypto_ecc_key_pair_generate_context_t * p_context, + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_ecc_private_key_t * p_private_key, + nrf_crypto_ecc_public_key_t * p_public_key); + + +/** @brief Calculate public key associated with provided private key. + * + * Calculated public key has to be deallocated using @ref nrf_crypto_ecc_public_key_free. + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_private_key Pointer to structure holding a private key that will be used for computation. + * @param[out] p_public_key Pointer to structure where newly generated public key will be put. + */ +ret_code_t nrf_crypto_ecc_public_key_calculate( + nrf_crypto_ecc_public_key_calculate_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + nrf_crypto_ecc_public_key_t * p_public_key); + + +/** @brief Create a private key from a raw data. + * + * Generated private key has to be deallocated using @ref nrf_crypto_ecc_private_key_free. + * + * @note Ed25519 only: Memory is allocated internally using @ref nrf_crypto_mem. + * + * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables + * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info. + * @param[out] p_private_key Pointer to structure where newly converted private key will be put. + * @param[in] p_raw_data Pointer to buffer containing a big endian raw data. + * @param[in] raw_data_size Number of bytes of a raw data. Correct size for selected curve can be found in + * @p p_curve_info and it is also defined by the preprocessor definitions, e.g. + * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE. + */ +ret_code_t nrf_crypto_ecc_private_key_from_raw( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_ecc_private_key_t * p_private_key, + uint8_t const * p_raw_data, + size_t raw_data_size); + + +/** @brief Convert a private key to a raw data. + * + * @param[in] p_private_key Pointer to structure holding private key that will be convert. + * @param[out] p_raw_data Pointer to buffer containing a big endian raw data. + * @param[in,out] p_raw_data_size Maximum number of bytes that @p p_raw_data buffer can hold on input + * and the actual number of bytes used by the raw data on output. + * Actual size for selected curve can be found in + * @ref nrf_crypto_ecc_curve_info_t and it is also defined by + * the preprocessor definitions, e.g. + * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE. + */ +ret_code_t nrf_crypto_ecc_private_key_to_raw( + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t * p_raw_data, + size_t * p_raw_data_size); + + +/** @brief Create a public key from a raw data. + * + * Generated public key has to be deallocated using @ref nrf_crypto_ecc_public_key_free. + * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables + * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info. + * @param[out] p_public_key Pointer to structure where newly converted public key will be put. + * @param[in] p_raw_data Pointer to buffer containing a big endian raw data. + * @param[in] raw_data_size Number of bytes of a raw data. Correct size for selected curve can be found in + * @p p_curve_info and it is also defined by the preprocessor definitions, e.g. + * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE. + */ +ret_code_t nrf_crypto_ecc_public_key_from_raw( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + nrf_crypto_ecc_public_key_t * p_public_key, + uint8_t const * p_raw_data, + size_t raw_data_size); + + +/** @brief Convert a public key to a raw data. + * + * @param[in] p_public_key Pointer to structure holding public key that will be convert. + * @param[out] p_raw_data Pointer to buffer containing a big endian raw data. + * @param[in,out] p_raw_data_size Maximum number of bytes that @p p_raw_data buffer can hold on input + * and the actual number of bytes used by the raw data on output. + * Actual size for selected curve can be found in + * @ref nrf_crypto_ecc_curve_info_t and it is also defined by + * the preprocessor definitions, e.g. + * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE. + */ +ret_code_t nrf_crypto_ecc_public_key_to_raw( + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t * p_raw_data, + size_t * p_raw_data_size); + + +/** @brief Release resources taken by a private key. + * + * @param[in] p_private_key Pointer to structure holding private key to release. + */ +ret_code_t nrf_crypto_ecc_private_key_free( + nrf_crypto_ecc_private_key_t * p_private_key); + + +/** @brief Release resources taken by a public key. + * + * @param[in] p_public_key Pointer to structure holding public key to release. + */ +ret_code_t nrf_crypto_ecc_public_key_free( + nrf_crypto_ecc_public_key_t * p_public_key); + + +/** @brief Gets curve information structure from provided key (private or public). + * + * @param[in] p_key Pointer to structure holding private or public key. + * @param[out] pp_curve_info Pointer to location where put retrieved pointer to curve information structure. + */ +ret_code_t nrf_crypto_ecc_curve_info_get( + void const * p_key, + nrf_crypto_ecc_curve_info_t const ** pp_curve_info); + + +/** @brief Inverts byte order of a big integers contained in a raw data. + * + * All the ECC API accepts only data with big endian integers, so this function have to be used + * if little endian is required. If input is in little endian byte order it will be converted + * to big endian. If input is in big endian byte order it will be converted to little endian. + * It works for ECC raw private key, raw public key, signature and shared secret. If raw data + * contains two big integers (e.g. R, S, or X, Y) each integer is inverted separately. + * If @p p_curve_info is NULL then all bytes in buffer will be inverted regardless what is the + * content of the buffer. + * + * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables + * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info. + * @param[in] p_raw_input Pointer to buffer holding source data. + * @param[out] p_raw_output Pointer to buffer that will be filled with inverted byte order. + * This parameter can be the same as @p p_raw_input, otherwise the + * buffers cannot overlap. + * @param[in] raw_data_size Size of input and output buffer. + */ +ret_code_t nrf_crypto_ecc_byte_order_invert( + nrf_crypto_ecc_curve_info_t const * p_curve_info, + uint8_t const * p_raw_input, + uint8_t * p_raw_output, + size_t raw_data_size); + + +#ifdef __cplusplus +} +#endif + +/** @} + * @} + */ + +#endif // NRF_CRYPTO_ECC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_backend.h new file mode 100644 index 0000000..7250f93 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_backend.h @@ -0,0 +1,356 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECC_BACKEND_H__ +#define NRF_CRYPTO_ECC_BACKEND_H__ +#if !defined(__SDK_DOXYGEN__) + +#include +#include + +#include "sdk_config.h" +#include "nordic_common.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_ecc_shared.h" + +// Include all backends +#include "cc310_backend_ecc.h" +#include "cc310_bl_backend_ecc.h" +#include "mbedtls_backend_ecc.h" +#include "oberon_backend_ecc.h" +#include "micro_ecc_backend_ecc.h" +#include "optiga_backend_ecc.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +// Make sure that all required defines are defined +#if !defined(NRF_CRYPTO_ECC_SECP160R1_ENABLED) +#define NRF_CRYPTO_ECC_SECP160R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP160R2_ENABLED) +#define NRF_CRYPTO_ECC_SECP160R2_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP192R1_ENABLED) +#define NRF_CRYPTO_ECC_SECP192R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP224R1_ENABLED) +#define NRF_CRYPTO_ECC_SECP224R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP256R1_ENABLED) +#define NRF_CRYPTO_ECC_SECP256R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP384R1_ENABLED) +#define NRF_CRYPTO_ECC_SECP384R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP521R1_ENABLED) +#define NRF_CRYPTO_ECC_SECP521R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP160K1_ENABLED) +#define NRF_CRYPTO_ECC_SECP160K1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP192K1_ENABLED) +#define NRF_CRYPTO_ECC_SECP192K1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP224K1_ENABLED) +#define NRF_CRYPTO_ECC_SECP224K1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_SECP256K1_ENABLED) +#define NRF_CRYPTO_ECC_SECP256K1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_BP256R1_ENABLED) +#define NRF_CRYPTO_ECC_BP256R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_BP384R1_ENABLED) +#define NRF_CRYPTO_ECC_BP384R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_BP512R1_ENABLED) +#define NRF_CRYPTO_ECC_BP512R1_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_CURVE25519_ENABLED) +#define NRF_CRYPTO_ECC_CURVE25519_ENABLED 0 +#endif +#if !defined(NRF_CRYPTO_ECC_ED25519_ENABLED) +#define NRF_CRYPTO_ECC_ED25519_ENABLED 0 +#endif + + +/** @internal @brief Definition to detect if ECC submodule is enabled. It will be enabled if any + * curve of any of the backends is enabled. + */ +#define NRF_CRYPTO_ECC_ENABLED ( \ + NRF_MODULE_ENABLED(NRF_CRYPTO) && ( \ + NRF_CRYPTO_ECC_SECP160R1_ENABLED | \ + NRF_CRYPTO_ECC_SECP160R2_ENABLED | \ + NRF_CRYPTO_ECC_SECP192R1_ENABLED | \ + NRF_CRYPTO_ECC_SECP224R1_ENABLED | \ + NRF_CRYPTO_ECC_SECP256R1_ENABLED | \ + NRF_CRYPTO_ECC_SECP384R1_ENABLED | \ + NRF_CRYPTO_ECC_SECP521R1_ENABLED | \ + NRF_CRYPTO_ECC_SECP160K1_ENABLED | \ + NRF_CRYPTO_ECC_SECP192K1_ENABLED | \ + NRF_CRYPTO_ECC_SECP224K1_ENABLED | \ + NRF_CRYPTO_ECC_SECP256K1_ENABLED | \ + NRF_CRYPTO_ECC_BP256R1_ENABLED | \ + NRF_CRYPTO_ECC_BP384R1_ENABLED | \ + NRF_CRYPTO_ECC_BP512R1_ENABLED | \ + NRF_CRYPTO_ECC_CURVE25519_ENABLED | \ + NRF_CRYPTO_ECC_ED25519_ENABLED)) + + +/** @internal @brief Definition containing number of enabled curves. + */ +#define NRF_CRYPTO_ECC_IMPLEMENTED_CURVES_COUNT ( \ + NRF_CRYPTO_ECC_SECP160R1_ENABLED + \ + NRF_CRYPTO_ECC_SECP160R2_ENABLED + \ + NRF_CRYPTO_ECC_SECP192R1_ENABLED + \ + NRF_CRYPTO_ECC_SECP224R1_ENABLED + \ + NRF_CRYPTO_ECC_SECP256R1_ENABLED + \ + NRF_CRYPTO_ECC_SECP384R1_ENABLED + \ + NRF_CRYPTO_ECC_SECP521R1_ENABLED + \ + NRF_CRYPTO_ECC_SECP160K1_ENABLED + \ + NRF_CRYPTO_ECC_SECP192K1_ENABLED + \ + NRF_CRYPTO_ECC_SECP224K1_ENABLED + \ + NRF_CRYPTO_ECC_SECP256K1_ENABLED + \ + NRF_CRYPTO_ECC_BP256R1_ENABLED + \ + NRF_CRYPTO_ECC_BP384R1_ENABLED + \ + NRF_CRYPTO_ECC_BP512R1_ENABLED + \ + NRF_CRYPTO_ECC_CURVE25519_ENABLED + \ + NRF_CRYPTO_ECC_ED25519_ENABLED) + + +#if !NRF_CRYPTO_ECC_SECP160R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp160r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp160r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp160r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp160r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP160R2_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp160r2_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp160r2_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp160r2_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp160r2_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP192R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp192r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp192r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp192r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp192r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP224R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp224r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp224r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp224r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp224r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP256R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp256r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp256r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP384R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp384r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp384r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp384r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp384r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP521R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp521r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp521r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp521r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp521r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP160K1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp160k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp160k1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp160k1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp160k1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP192K1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp192k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp192k1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp192k1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp192k1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP224K1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp224k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp224k1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp224k1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp224k1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_SECP256K1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_secp256k1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_secp256k1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp256k1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_secp256k1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_BP256R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_bp256r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_bp256r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_bp256r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_bp256r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_BP384R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_bp384r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_bp384r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_bp384r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_bp384r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_BP512R1_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_bp512r1_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_bp512r1_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_bp512r1_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_bp512r1_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_CURVE25519_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_curve25519_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_curve25519_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_curve25519_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_curve25519_public_key_t; +#endif + +#if !NRF_CRYPTO_ECC_ED25519_ENABLED +// Dummy typedefs for disabled contexts +typedef uint32_t nrf_crypto_backend_ed25519_key_pair_generate_context_t; +typedef uint32_t nrf_crypto_backend_ed25519_public_key_calculate_context_t; +// Dummy typedefs for disabled keys +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_ed25519_private_key_t; +typedef nrf_crypto_internal_ecc_key_header_t nrf_crypto_backend_ed25519_public_key_t; +#endif + + +// Find biggest raw private and public key size that is currently enabled +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (66) +#elif NRF_CRYPTO_ECC_BP512R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (64) +#elif NRF_CRYPTO_ECC_BP384R1_ENABLED || NRF_CRYPTO_ECC_SECP384R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (48) +#elif NRF_CRYPTO_ECC_BP256R1_ENABLED || NRF_CRYPTO_ECC_SECP256K1_ENABLED || NRF_CRYPTO_ECC_CURVE25519_ENABLED || NRF_CRYPTO_ECC_ED25519_ENABLED || NRF_CRYPTO_ECC_SECP256R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (32) +#elif NRF_CRYPTO_ECC_SECP224K1_ENABLED || NRF_CRYPTO_ECC_SECP224R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (28) +#elif NRF_CRYPTO_ECC_SECP192K1_ENABLED || NRF_CRYPTO_ECC_SECP192R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (24) +#elif NRF_CRYPTO_ECC_SECP160K1_ENABLED || NRF_CRYPTO_ECC_SECP160R1_ENABLED || NRF_CRYPTO_ECC_SECP160R2_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (20) +#else +# define NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE (1) +#endif + +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 66) +#elif NRF_CRYPTO_ECC_BP512R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 64) +#elif NRF_CRYPTO_ECC_BP384R1_ENABLED || NRF_CRYPTO_ECC_SECP384R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 48) +#elif NRF_CRYPTO_ECC_BP256R1_ENABLED || NRF_CRYPTO_ECC_SECP256K1_ENABLED || NRF_CRYPTO_ECC_SECP256R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 32) +#elif NRF_CRYPTO_ECC_SECP224K1_ENABLED || NRF_CRYPTO_ECC_SECP224R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 28) +#elif NRF_CRYPTO_ECC_SECP192K1_ENABLED || NRF_CRYPTO_ECC_SECP192R1_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 24) +#elif NRF_CRYPTO_ECC_SECP160K1_ENABLED || NRF_CRYPTO_ECC_SECP160R1_ENABLED || NRF_CRYPTO_ECC_SECP160R2_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (2 * 20) +#elif NRF_CRYPTO_ECC_CURVE25519_ENABLED || NRF_CRYPTO_ECC_ED25519_ENABLED +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (32) +#else +# define NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE (1) +#endif + +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED && !defined(NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED) +#warning "NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED not defined. Please define it to choose the endianness of Curve25519 parameters." +#endif + +#ifdef __cplusplus +} +#endif + + +#endif // !defined(__SDK_DOXYGEN__) +#endif // NRF_CRYPTO_ECC_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_shared.h new file mode 100644 index 0000000..ac240b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecc_shared.h @@ -0,0 +1,229 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECC_SHARED_H__ +#define NRF_CRYPTO_ECC_SHARED_H__ +#if !defined(__SDK_DOXYGEN__) + +#include +#include +#include + +#include "sdk_errors.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#define NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE (0x4D465276) /**< @internal @brief Init value for all ECC private keys. ASCII "nRFv". */ +#define NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE (0x4D465270) /**< @internal @brief Init value for all ECC public keys. ASCII "nRFp". */ + + +// Forward declaration only +struct nrf_crypto_ecc_curve_info_s; + + +/** @brief Header structure at the beginning of each key structure. + */ +typedef struct +{ + uint32_t init_value; /**< @internal @brief Init value to check if key was correctly initialized. */ + struct nrf_crypto_ecc_curve_info_s const * p_info; /**< @internal @brief Points to information structure of an associated curve type. */ +} nrf_crypto_internal_ecc_key_header_t; + + +/** @internal @brief Function pointer for backend implementation of a key pair garatarion. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to context. + * @param[out] p_private_key Pointer where to put new private key. + * @param[out] p_public_key Pointer where to put new public key. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_key_pair_generate_fn_t)( + void * p_context, + void * p_private_key, + void * p_public_key); + + +/** @internal @brief Function pointer for backend implementation of a public key calculation. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to context. + * @param[in] p_private_key Pointer to private key. + * @param[out] p_public_key Pointer where to put new public key. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_public_key_calculate_fn_t)( + void * p_context, + void const * p_private_key, + void * p_public_key); + + +/** @internal @brief Function pointer for backend implementation of raw to private key conversion. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[out] p_private_key Pointer where to put new private key. + * @param[in] p_raw_data Pointer to raw data. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_private_key_from_raw_fn_t)( + void * p_private_key, + uint8_t const * p_raw_data); + + +/** @internal @brief Function pointer for backend implementation of private key to raw conversion. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_private_key Pointer to private key. + * @param[out] p_raw_data Pointer where to put raw data. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_private_key_to_raw_fn_t)( + void const * p_private_key, + uint8_t * p_raw_data); + + +/** @internal @brief Function pointer for backend implementation of raw to public key conversion. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[out] p_public_key Pointer where to put new public key. + * @param[in] p_raw_data Pointer to raw data. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_public_key_from_raw_fn_t)( + void * p_public_key, + uint8_t const * p_raw_data); + + +/** @internal @brief Function pointer for backend implementation of public key to raw conversion. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_public_key Pointer to public key. + * @param[out] p_raw_data Pointer where to put raw data. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_public_key_to_raw_fn_t)( + void const * p_public_key, + uint8_t * p_raw_data); + + +/** @internal @brief Function pointer for backend implementation of key (public or private) deallocation. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_key Pointer to public or private key. + */ +typedef ret_code_t (*nrf_crypto_backend_ecc_key_free_fn_t)( + void * p_key); + + +/** @internal @brief Function for checking and preparing ECC key output parameter. + * + * @param[in] p_curve_info Curve info provided by user that will be used to create a new key. + * @param[out] p_key_header Key header that have to be prepared. + * @return NRF_SUCCESS if parameters are valid, error otherwise. + */ +ret_code_t nrf_crypto_internal_ecc_key_output_prepare( + struct nrf_crypto_ecc_curve_info_s const * p_curve_info, + nrf_crypto_internal_ecc_key_header_t * p_key_header); + + +/** @internal @brief Function for checking ECC key input parameter. + * + * @param[in] p_key_header Key header that have to be checked. + * @param[in] init_value Expected init value in this key. + * @return NRF_SUCCESS if parameter is valid, error otherwise. + */ +ret_code_t nrf_crypto_internal_ecc_key_input_check( + nrf_crypto_internal_ecc_key_header_t const * p_key_header, + uint32_t init_value); + + +/** @internal @brief Function for checking and preparing raw data output parameter. + * + * @param[out] p_raw_data Buffer where output will be written. + * @param[in,out] p_raw_data_size Pointer to size of the data. On input this is size of provided by + * the user buffer. On output is equal @p expected_size. This pointer + * can be NULL if used does not want to do size checking. + * @param[in] expected_size Size of output data that will be written to the buffer. + * @return NRF_SUCCESS if parameters are valid, error otherwise. + */ +ret_code_t nrf_crypto_internal_ecc_raw_output_prepare( + uint8_t * p_raw_data, + size_t * p_raw_data_size, + size_t expected_size); + + +/** @internal @brief Function for checking raw data input parameter. + * + * @param[in] p_raw_data Buffer where data is located. + * @param[in] raw_data_size Size of the data.Function will fail if it is different than @p expected_size. + * @param[in] expected_size Expected size of the data. + * @return NRF_SUCCESS if parameters are valid, error otherwise. + */ +ret_code_t nrf_crypto_internal_ecc_raw_input_check( + uint8_t const * p_raw_data, + size_t raw_data_size, + size_t expected_size); + + +#ifdef __cplusplus +} +#endif + +#endif // !defined(__SDK_DOXYGEN__) +#endif // NRF_CRYPTO_ECC_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.c new file mode 100644 index 0000000..af8d74d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.c @@ -0,0 +1,277 @@ +/** + * Copyright (c) 2018 - 2019, 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 "nrf_crypto_error.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh.h" +#include "app_util.h" +#include "sdk_macros.h" + + +#if NRF_CRYPTO_ECC_ENABLED + + +#if NRF_CRYPTO_ECC_IMPLEMENTED_CURVES_COUNT > 1 + + +static const nrf_crypto_backend_ecdh_compute_fn_t compute_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_ecdh_compute, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_ecdh_compute, +#endif +}; + + +static const uint16_t compute_impl_context_size[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_BACKEND_SECP160R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_BACKEND_SECP160R2_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_BACKEND_SECP192R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_BACKEND_SECP224R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_BACKEND_SECP384R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_BACKEND_SECP521R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_BACKEND_SECP160K1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_BACKEND_SECP192K1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_BACKEND_SECP224K1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_BACKEND_SECP256K1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_BACKEND_BP256R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_BACKEND_BP384R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_BACKEND_BP512R1_ECDH_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_BACKEND_CURVE25519_ECDH_CONTEXT_SIZE, +#endif +}; + +#define BACKEND_IMPL_GET(table, curve_type) (table)[(uint32_t)(curve_type)] + +#else + + +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED +#define compute_impl nrf_crypto_backend_secp160r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP160R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP160R2_ENABLED +#define compute_impl nrf_crypto_backend_secp160r2_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP160R2_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP192R1_ENABLED +#define compute_impl nrf_crypto_backend_secp192r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP192R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP224R1_ENABLED +#define compute_impl nrf_crypto_backend_secp224r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP224R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP256R1_ENABLED +#define compute_impl nrf_crypto_backend_secp256r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP256R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP384R1_ENABLED +#define compute_impl nrf_crypto_backend_secp384r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP384R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP521R1_ENABLED +#define compute_impl nrf_crypto_backend_secp521r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP521R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP160K1_ENABLED +#define compute_impl nrf_crypto_backend_secp160k1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP160K1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP192K1_ENABLED +#define compute_impl nrf_crypto_backend_secp192k1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP192K1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP224K1_ENABLED +#define compute_impl nrf_crypto_backend_secp224k1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP224K1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP256K1_ENABLED +#define compute_impl nrf_crypto_backend_secp256k1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_SECP256K1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP256R1_ENABLED +#define compute_impl nrf_crypto_backend_bp256r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_BP256R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP384R1_ENABLED +#define compute_impl nrf_crypto_backend_bp384r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_BP384R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP512R1_ENABLED +#define compute_impl nrf_crypto_backend_bp512r1_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_BP512R1_ECDH_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_CURVE25519_ENABLED +#define compute_impl nrf_crypto_backend_curve25519_ecdh_compute +#define compute_impl_context_size NRF_CRYPTO_BACKEND_CURVE25519_ECDH_CONTEXT_SIZE +#else +#define compute_impl NULL +#define compute_impl_context_size 0 +#endif + +#define BACKEND_IMPL_GET(function, curve_type) (function) + +#endif + + +ret_code_t nrf_crypto_ecdh_compute( + nrf_crypto_ecdh_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t * p_shared_secret, + size_t * p_shared_secret_size) +{ + ret_code_t result; + void * p_allocated_context = NULL; + nrf_crypto_backend_ecdh_compute_fn_t backend_implementation; + size_t context_size; + nrf_crypto_ecc_curve_info_t const * p_info; + + // Get pointer to header for each key + nrf_crypto_internal_ecc_key_header_t const * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_private_key; + nrf_crypto_internal_ecc_key_header_t const * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_private_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + result = nrf_crypto_internal_ecc_key_input_check( + p_public_key_header, + NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + VERIFY_TRUE(p_private_key_header->p_info == p_public_key_header->p_info, + NRF_ERROR_CRYPTO_ECDH_CURVE_MISMATCH); + p_info = p_private_key_header->p_info; + result = nrf_crypto_internal_ecc_raw_output_prepare( + p_shared_secret, + p_shared_secret_size, + p_info->raw_private_key_size); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(compute_impl, p_info->curve_type); + context_size = BACKEND_IMPL_GET(compute_impl_context_size, p_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Allocate context if not provided + if (p_context == NULL && context_size > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(context_size); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = backend_implementation(p_context, p_private_key, p_public_key, p_shared_secret); + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + + +#endif // NRF_CRYPTO_ECC_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.h new file mode 100644 index 0000000..231800a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh.h @@ -0,0 +1,201 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECDH_H__ +#define NRF_CRYPTO_ECDH_H__ + +/** @addtogroup nrf_crypto + * @{ + * @addtogroup nrf_crypto_ecdh Elliptic Curve Diffie-Hellman (ECDH) + * @{ + * @brief Provides elliptic curve cryptography functions for Diffie-Hellman shared secret exchange. + * + * @addtogroup nrf_crypto_ecdh_secp160r1 Definitions specific to secp160r1 (NIST 160-bit) + * @addtogroup nrf_crypto_ecdh_secp160r2 Definitions specific to secp160r2 (NIST 160-bit) + * @addtogroup nrf_crypto_ecdh_secp192r1 Definitions specific to secp192r1 (NIST 192-bit) + * @addtogroup nrf_crypto_ecdh_secp224r1 Definitions specific to secp224r1 (NIST 224-bit) + * @addtogroup nrf_crypto_ecdh_secp256r1 Definitions specific to secp256r1 (NIST 256-bit) + * @addtogroup nrf_crypto_ecdh_secp384r1 Definitions specific to secp384r1 (NIST 384-bit) + * @addtogroup nrf_crypto_ecdh_secp521r1 Definitions specific to secp521r1 (NIST 521-bit) + * @addtogroup nrf_crypto_ecdh_secp160k1 Definitions specific to secp160k1 (Koblitz 160-bit) + * @addtogroup nrf_crypto_ecdh_secp192k1 Definitions specific to secp192k1 (Koblitz 192-bit) + * @addtogroup nrf_crypto_ecdh_secp224k1 Definitions specific to secp224k1 (Koblitz 224-bit) + * @addtogroup nrf_crypto_ecdh_secp256k1 Definitions specific to secp256k1 (Koblitz 256-bit) + * @addtogroup nrf_crypto_ecdh_bp256r1 Definitions specific to bp256r1 (Brainpool 256-bit) + * @addtogroup nrf_crypto_ecdh_bp384r1 Definitions specific to bp384r1 (Brainpool 384-bit) + * @addtogroup nrf_crypto_ecdh_bp512r1 Definitions specific to bp512r1 (Brainpool 512-bit) + * @addtogroup nrf_crypto_ecdh_curve25519 Definitions specific to Curve25519 + */ + +#include +#include + +#include "nrf_crypto_error.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" +#include "nrf_crypto_ecdh_backend.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define NRF_CRYPTO_ECDH_SECP160R1_SHARED_SECRET_SIZE (160 / 8) /**< @brief Number of bytes in a shared secret using secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecdh_secp160r1 */ +#define NRF_CRYPTO_ECDH_SECP160R2_SHARED_SECRET_SIZE (160 / 8) /**< @brief Number of bytes in a shared secret using secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecdh_secp160r2 */ +#define NRF_CRYPTO_ECDH_SECP192R1_SHARED_SECRET_SIZE (192 / 8) /**< @brief Number of bytes in a shared secret using secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecdh_secp192r1 */ +#define NRF_CRYPTO_ECDH_SECP224R1_SHARED_SECRET_SIZE (224 / 8) /**< @brief Number of bytes in a shared secret using secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecdh_secp224r1 */ +#define NRF_CRYPTO_ECDH_SECP256R1_SHARED_SECRET_SIZE (256 / 8) /**< @brief Number of bytes in a shared secret using secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecdh_secp256r1 */ +#define NRF_CRYPTO_ECDH_SECP384R1_SHARED_SECRET_SIZE (384 / 8) /**< @brief Number of bytes in a shared secret using secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecdh_secp384r1 */ +#define NRF_CRYPTO_ECDH_SECP521R1_SHARED_SECRET_SIZE (528 / 8) /**< @brief Number of bytes in a shared secret using secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecdh_secp521r1 */ +#define NRF_CRYPTO_ECDH_SECP160K1_SHARED_SECRET_SIZE (160 / 8) /**< @brief Number of bytes in a shared secret using secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecdh_secp160k1 */ +#define NRF_CRYPTO_ECDH_SECP192K1_SHARED_SECRET_SIZE (192 / 8) /**< @brief Number of bytes in a shared secret using secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecdh_secp192k1 */ +#define NRF_CRYPTO_ECDH_SECP224K1_SHARED_SECRET_SIZE (224 / 8) /**< @brief Number of bytes in a shared secret using secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecdh_secp224k1 */ +#define NRF_CRYPTO_ECDH_SECP256K1_SHARED_SECRET_SIZE (256 / 8) /**< @brief Number of bytes in a shared secret using secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecdh_secp256k1 */ +#define NRF_CRYPTO_ECDH_BP256R1_SHARED_SECRET_SIZE (256 / 8) /**< @brief Number of bytes in a shared secret using bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecdh_bp256r1 */ +#define NRF_CRYPTO_ECDH_BP384R1_SHARED_SECRET_SIZE (384 / 8) /**< @brief Number of bytes in a shared secret using bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecdh_bp384r1 */ +#define NRF_CRYPTO_ECDH_BP512R1_SHARED_SECRET_SIZE (512 / 8) /**< @brief Number of bytes in a shared secret using bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecdh_bp512r1 */ +#define NRF_CRYPTO_ECDH_CURVE25519_SHARED_SECRET_SIZE (256 / 8) /**< @brief Number of bytes in a shared secret using Curve25519. @ingroup nrf_crypto_ecdh_curve25519 */ +#define NRF_CRYPTO_ECDH_SHARED_SECRET_MAX_SIZE NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE /**< @brief Maximum size of a shared secret in bytes for all enabled curves. */ + + +typedef nrf_crypto_backend_secp160r1_ecdh_context_t nrf_crypto_ecdh_secp160r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecdh_secp160r1 */ +typedef nrf_crypto_backend_secp160r2_ecdh_context_t nrf_crypto_ecdh_secp160r2_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecdh_secp160r2 */ +typedef nrf_crypto_backend_secp192r1_ecdh_context_t nrf_crypto_ecdh_secp192r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecdh_secp192r1 */ +typedef nrf_crypto_backend_secp224r1_ecdh_context_t nrf_crypto_ecdh_secp224r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecdh_secp224r1 */ +typedef nrf_crypto_backend_secp256r1_ecdh_context_t nrf_crypto_ecdh_secp256r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecdh_secp256r1 */ +typedef nrf_crypto_backend_secp384r1_ecdh_context_t nrf_crypto_ecdh_secp384r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecdh_secp384r1 */ +typedef nrf_crypto_backend_secp521r1_ecdh_context_t nrf_crypto_ecdh_secp521r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecdh_secp521r1 */ +typedef nrf_crypto_backend_secp160k1_ecdh_context_t nrf_crypto_ecdh_secp160k1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecdh_secp160k1 */ +typedef nrf_crypto_backend_secp192k1_ecdh_context_t nrf_crypto_ecdh_secp192k1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecdh_secp192k1 */ +typedef nrf_crypto_backend_secp224k1_ecdh_context_t nrf_crypto_ecdh_secp224k1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecdh_secp224k1 */ +typedef nrf_crypto_backend_secp256k1_ecdh_context_t nrf_crypto_ecdh_secp256k1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecdh_secp256k1 */ +typedef nrf_crypto_backend_bp256r1_ecdh_context_t nrf_crypto_ecdh_bp256r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecdh_bp256r1 */ +typedef nrf_crypto_backend_bp384r1_ecdh_context_t nrf_crypto_ecdh_bp384r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecdh_bp384r1 */ +typedef nrf_crypto_backend_bp512r1_ecdh_context_t nrf_crypto_ecdh_bp512r1_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecdh_bp512r1 */ +typedef nrf_crypto_backend_curve25519_ecdh_context_t nrf_crypto_ecdh_curve25519_context_t; /**< @brief Context used to store temporary data during computing ECDH for curve Curve25519. @ingroup nrf_crypto_ecdh_curve25519 */ + + +typedef uint8_t nrf_crypto_ecdh_secp160r1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP160R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecdh_secp160r1 */ +typedef uint8_t nrf_crypto_ecdh_secp160r2_shared_secret_t + [NRF_CRYPTO_ECDH_SECP160R2_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecdh_secp160r2 */ +typedef uint8_t nrf_crypto_ecdh_secp192r1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP192R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecdh_secp192r1 */ +typedef uint8_t nrf_crypto_ecdh_secp224r1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP224R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecdh_secp224r1 */ +typedef uint8_t nrf_crypto_ecdh_secp256r1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP256R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecdh_secp256r1 */ +typedef uint8_t nrf_crypto_ecdh_secp384r1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP384R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecdh_secp384r1 */ +typedef uint8_t nrf_crypto_ecdh_secp521r1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP521R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecdh_secp521r1 */ +typedef uint8_t nrf_crypto_ecdh_secp160k1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP160K1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecdh_secp160k1 */ +typedef uint8_t nrf_crypto_ecdh_secp192k1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP192K1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecdh_secp192k1 */ +typedef uint8_t nrf_crypto_ecdh_secp224k1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP224K1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecdh_secp224k1 */ +typedef uint8_t nrf_crypto_ecdh_secp256k1_shared_secret_t + [NRF_CRYPTO_ECDH_SECP256K1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecdh_secp256k1 */ +typedef uint8_t nrf_crypto_ecdh_bp256r1_shared_secret_t + [NRF_CRYPTO_ECDH_BP256R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecdh_bp256r1 */ +typedef uint8_t nrf_crypto_ecdh_bp384r1_shared_secret_t + [NRF_CRYPTO_ECDH_BP384R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecdh_bp384r1 */ +typedef uint8_t nrf_crypto_ecdh_bp512r1_shared_secret_t + [NRF_CRYPTO_ECDH_BP512R1_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecdh_bp512r1 */ +typedef uint8_t nrf_crypto_ecdh_curve25519_shared_secret_t + [NRF_CRYPTO_ECDH_CURVE25519_SHARED_SECRET_SIZE]; /**< @brief Array type of a shared secret for curve Curve25519. @ingroup nrf_crypto_ecdh_curve25519 */ +typedef uint8_t nrf_crypto_ecdh_shared_secret_t + [NRF_CRYPTO_ECDH_SHARED_SECRET_MAX_SIZE]; /**< @brief Array type of a shared secret for any of the enabled curves. */ + + +/** @brief Union holding a context for ECDH computation. + */ +typedef union +{ + nrf_crypto_ecdh_secp160r1_context_t context_secp160r1; /**< @brief Occupies space for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecdh_secp160r2_context_t context_secp160r2; /**< @brief Occupies space for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecdh_secp192r1_context_t context_secp192r1; /**< @brief Occupies space for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecdh_secp224r1_context_t context_secp224r1; /**< @brief Occupies space for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecdh_secp256r1_context_t context_secp256r1; /**< @brief Occupies space for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecdh_secp384r1_context_t context_secp384r1; /**< @brief Occupies space for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecdh_secp521r1_context_t context_secp521r1; /**< @brief Occupies space for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecdh_secp160k1_context_t context_secp160k1; /**< @brief Occupies space for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecdh_secp192k1_context_t context_secp192k1; /**< @brief Occupies space for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecdh_secp224k1_context_t context_secp224k1; /**< @brief Occupies space for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecdh_secp256k1_context_t context_secp256k1; /**< @brief Occupies space for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecdh_bp256r1_context_t context_bp256r1; /**< @brief Occupies space for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecdh_bp384r1_context_t context_bp384r1; /**< @brief Occupies space for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecdh_bp512r1_context_t context_bp512r1; /**< @brief Occupies space for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecdh_curve25519_context_t context_curve25519; /**< @brief Occupies space for Curve25519. */ +} nrf_crypto_ecdh_context_t; + + +/** @brief Computes shared secret using ECC Diffie-Hellman. + * + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_private_key Pointer to structure holding a private key. + * @param[in] p_public_key Pointer to structure holding a public key received from the other party. + * @param[out] p_shared_secret Pointer to buffer where shared secret will be put. + * @param[in,out] p_shared_secret_size Maximum number of bytes that @p p_shared_secret buffer can hold on input + * and the actual number of bytes used by the data on output. + * Actual size for selected curve is defined by + * the preprocessor definitions, e.g. + * @ref NRF_CRYPTO_ECDH_SECP256R1_SHARED_SECRET_SIZE. + */ +ret_code_t nrf_crypto_ecdh_compute( + nrf_crypto_ecdh_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t * p_shared_secret, + size_t * p_shared_secret_size); + + +#ifdef __cplusplus +} +#endif + +/** @} + * @} + */ + +#endif // NRF_CRYPTO_ECDH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_backend.h new file mode 100644 index 0000000..a544909 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_backend.h @@ -0,0 +1,185 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECDH_BACKEND_H__ +#define NRF_CRYPTO_ECDH_BACKEND_H__ +#if !defined(__SDK_DOXYGEN__) + +#include +#include + +#include "sdk_errors.h" +#include "sdk_config.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdh_shared.h" + +// Include all backends +#include "cc310_backend_ecdh.h" +#include "cc310_bl_backend_ecdh.h" +#include "mbedtls_backend_ecdh.h" +#include "oberon_backend_ecdh.h" +#include "micro_ecc_backend_ecdh.h" +#include "optiga_backend_ecdh.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if !NRF_CRYPTO_ECC_SECP160R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp160r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp160r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP160R2_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp160r2_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp160r2_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP192R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp192r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp192r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP224R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp224r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp224r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP256R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp256r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP384R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp384r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp384r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP521R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp521r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp521r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP160K1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp160k1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp160k1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP192K1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp192k1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp192k1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP224K1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp224k1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp224k1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP256K1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_secp256k1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp256k1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_BP256R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_bp256r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_bp256r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_BP384R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_bp384r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_bp384r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_BP512R1_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_bp512r1_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_bp512r1_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_CURVE25519_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_curve25519_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_curve25519_ecdh_compute NULL +#endif + +#if !NRF_CRYPTO_ECC_ED25519_ENABLED +// Dummy typedef for disabled context +typedef uint32_t nrf_crypto_backend_ed25519_ecdh_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_ed25519_ecdh_compute NULL +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // !defined(__SDK_DOXYGEN__) +#endif // NRF_CRYPTO_ECDH_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_shared.h new file mode 100644 index 0000000..7ac51f0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdh_shared.h @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECDH_SHARED_H__ +#define NRF_CRYPTO_ECDH_SHARED_H__ +#if !defined(__SDK_DOXYGEN__) + +#include +#include + +#include "sdk_errors.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal @brief Function pointer for backend implementation of ECDH. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to context. + * @param[in] p_private_key Pointer to private key. + * @param[in] p_public_key Pointer to public key. + * @param[out] p_shared_secret Pointer where to put generated shared secret. + */ +typedef ret_code_t (*nrf_crypto_backend_ecdh_compute_fn_t)( + void * p_context, + void const * p_private_key, + void const * p_public_key, + uint8_t * p_shared_secret); + + +#ifdef __cplusplus +} +#endif + +#endif // !defined(__SDK_DOXYGEN__) +#endif // NRF_CRYPTO_ECDH_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.c new file mode 100644 index 0000000..e5fe1d9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.c @@ -0,0 +1,454 @@ +/** + * Copyright (c) 2018 - 2019, 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 "nrf_crypto_error.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdsa.h" +#include "nrf_crypto_mem.h" +#include "app_util.h" +#include "sdk_macros.h" + + +#if NRF_CRYPTO_ECC_ENABLED + + +#if NRF_CRYPTO_ECC_IMPLEMENTED_CURVES_COUNT > 1 + + +static const nrf_crypto_backend_ecdsa_sign_fn_t sign_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_sign, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_sign, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_sign, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_sign, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_sign, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_sign, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_sign, +#endif +}; + +static const uint16_t sign_impl_context_size[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_BACKEND_SECP160R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_BACKEND_SECP160R2_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_BACKEND_SECP192R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_BACKEND_SECP384R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_BACKEND_SECP521R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_BACKEND_SECP160K1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_BACKEND_SECP192K1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_BACKEND_SECP224K1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_BACKEND_SECP256K1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_BACKEND_BP256R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_BACKEND_BP384R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_BACKEND_BP512R1_SIGN_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_BACKEND_CURVE25519_SIGN_CONTEXT_SIZE, +#endif +}; + +static const nrf_crypto_backend_ecdsa_verify_fn_t verify_impl[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + nrf_crypto_backend_secp160r1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + nrf_crypto_backend_secp160r2_verify, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + nrf_crypto_backend_secp192r1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + nrf_crypto_backend_secp224r1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + nrf_crypto_backend_secp256r1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + nrf_crypto_backend_secp384r1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + nrf_crypto_backend_secp521r1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + nrf_crypto_backend_secp160k1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + nrf_crypto_backend_secp192k1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + nrf_crypto_backend_secp224k1_verify, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + nrf_crypto_backend_secp256k1_verify, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + nrf_crypto_backend_bp256r1_verify, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + nrf_crypto_backend_bp384r1_verify, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + nrf_crypto_backend_bp512r1_verify, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + nrf_crypto_backend_curve25519_verify, +#endif +}; + +static const uint16_t verify_impl_context_size[] = +{ +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED + NRF_CRYPTO_BACKEND_SECP160R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160R2_ENABLED + NRF_CRYPTO_BACKEND_SECP160R2_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192R1_ENABLED + NRF_CRYPTO_BACKEND_SECP192R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224R1_ENABLED + NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256R1_ENABLED + NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP384R1_ENABLED + NRF_CRYPTO_BACKEND_SECP384R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP521R1_ENABLED + NRF_CRYPTO_BACKEND_SECP521R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP160K1_ENABLED + NRF_CRYPTO_BACKEND_SECP160K1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP192K1_ENABLED + NRF_CRYPTO_BACKEND_SECP192K1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP224K1_ENABLED + NRF_CRYPTO_BACKEND_SECP224K1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_SECP256K1_ENABLED + NRF_CRYPTO_BACKEND_SECP256K1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP256R1_ENABLED + NRF_CRYPTO_BACKEND_BP256R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP384R1_ENABLED + NRF_CRYPTO_BACKEND_BP384R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_BP512R1_ENABLED + NRF_CRYPTO_BACKEND_BP512R1_VERIFY_CONTEXT_SIZE, +#endif +#if NRF_CRYPTO_ECC_CURVE25519_ENABLED + NRF_CRYPTO_BACKEND_CURVE25519_VERIFY_CONTEXT_SIZE, +#endif +}; + +#define BACKEND_IMPL_GET(table, curve_type) (table)[(uint32_t)(curve_type)] + +#else + +#if NRF_CRYPTO_ECC_SECP160R1_ENABLED +#define sign_impl nrf_crypto_backend_secp160r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP160R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp160r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP160R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP160R2_ENABLED +#define sign_impl nrf_crypto_backend_secp160r2_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP160R2_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp160r2_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP160R2_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP192R1_ENABLED +#define sign_impl nrf_crypto_backend_secp192r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP192R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp192r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP192R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP224R1_ENABLED +#define sign_impl nrf_crypto_backend_secp224r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp224r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP256R1_ENABLED +#define sign_impl nrf_crypto_backend_secp256r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp256r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP384R1_ENABLED +#define sign_impl nrf_crypto_backend_secp384r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP384R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp384r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP384R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP521R1_ENABLED +#define sign_impl nrf_crypto_backend_secp521r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP521R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp521r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP521R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP160K1_ENABLED +#define sign_impl nrf_crypto_backend_secp160k1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP160K1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp160k1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP160K1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP192K1_ENABLED +#define sign_impl nrf_crypto_backend_secp192k1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP192K1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp192k1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP192K1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP224K1_ENABLED +#define sign_impl nrf_crypto_backend_secp224k1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP224K1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp224k1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP224K1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_SECP256K1_ENABLED +#define sign_impl nrf_crypto_backend_secp256k1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_SECP256K1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_secp256k1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_SECP256K1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP256R1_ENABLED +#define sign_impl nrf_crypto_backend_bp256r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_BP256R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_bp256r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_BP256R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP384R1_ENABLED +#define sign_impl nrf_crypto_backend_bp384r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_BP384R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_bp384r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_BP384R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_BP512R1_ENABLED +#define sign_impl nrf_crypto_backend_bp512r1_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_BP512R1_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_bp512r1_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_BP512R1_VERIFY_CONTEXT_SIZE +#elif NRF_CRYPTO_ECC_CURVE25519_ENABLED +#define sign_impl nrf_crypto_backend_curve25519_sign +#define sign_impl_context_size NRF_CRYPTO_BACKEND_CURVE25519_SIGN_CONTEXT_SIZE +#define verify_impl nrf_crypto_backend_curve25519_verify +#define verify_impl_context_size NRF_CRYPTO_BACKEND_CURVE25519_VERIFY_CONTEXT_SIZE +#else +#define sign_impl NULL +#define sign_impl_context_size 0 +#define verify_impl NULL +#define verify_impl_context_size 0 +#endif + +#define BACKEND_IMPL_GET(function, curve_type) (function) + +#endif + + +ret_code_t nrf_crypto_ecdsa_sign( + nrf_crypto_ecdsa_sign_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_hash, + size_t hash_size, + uint8_t * p_signature, + size_t * p_signature_size) +{ + ret_code_t result; + void * p_allocated_context = NULL; + nrf_crypto_backend_ecdsa_sign_fn_t backend_implementation; + size_t context_size; + nrf_crypto_ecc_curve_info_t const * p_info; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_private_key; + + // Check and prepare parameters + VERIFY_TRUE(p_hash != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + result = nrf_crypto_internal_ecc_key_input_check( + p_private_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_private_key_header->p_info; + result = nrf_crypto_internal_ecc_raw_output_prepare(p_signature, + p_signature_size, + 2 * p_info->raw_private_key_size); + VERIFY_SUCCESS(result); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(sign_impl, p_info->curve_type); + context_size = BACKEND_IMPL_GET(sign_impl_context_size, p_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Allocate context if not provided + if (p_context == NULL && context_size > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(context_size); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = backend_implementation(p_context, p_private_key, p_hash, hash_size, p_signature); + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + + +ret_code_t nrf_crypto_ecdsa_verify( + nrf_crypto_ecdsa_verify_context_t * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_hash, + size_t hash_size, + uint8_t const * p_signature, + size_t signature_size) +{ + ret_code_t result; + void * p_allocated_context = NULL; + nrf_crypto_backend_ecdsa_verify_fn_t backend_implementation; + size_t context_size; + nrf_crypto_ecc_curve_info_t const * p_info; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_public_key; + + // Check and prepare parameters + result = nrf_crypto_internal_ecc_key_input_check( + p_public_key_header, + NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + p_info = p_public_key_header->p_info; + result = nrf_crypto_internal_ecc_raw_input_check(p_signature, + signature_size, + 2 * p_info->raw_private_key_size); + VERIFY_SUCCESS(result); + VERIFY_TRUE(p_hash != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + // Get backend specific information + backend_implementation = BACKEND_IMPL_GET(verify_impl, p_info->curve_type); + context_size = BACKEND_IMPL_GET(verify_impl_context_size, p_info->curve_type); + VERIFY_TRUE(backend_implementation != NULL, NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE); + + // Allocate context if not provided + if (p_context == NULL && context_size > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(context_size); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = backend_implementation(p_context, p_public_key, p_hash, hash_size, p_signature); + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + + +#endif // NRF_CRYPTO_ECC_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.h new file mode 100644 index 0000000..826fd44 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa.h @@ -0,0 +1,245 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECDSA_H__ +#define NRF_CRYPTO_ECDSA_H__ + +/** @addtogroup nrf_crypto + * @{ + * @addtogroup nrf_crypto_ecdsa Elliptic Curve Digital Signature (ECDSA) + * @{ + * @brief Provides elliptic curve cryptography functions for digital signature. + * + * @addtogroup nrf_crypto_ecdsa_secp160r1 Definitions specific to secp160r1 (NIST 160-bit) + * @addtogroup nrf_crypto_ecdsa_secp160r2 Definitions specific to secp160r2 (NIST 160-bit) + * @addtogroup nrf_crypto_ecdsa_secp192r1 Definitions specific to secp192r1 (NIST 192-bit) + * @addtogroup nrf_crypto_ecdsa_secp224r1 Definitions specific to secp224r1 (NIST 224-bit) + * @addtogroup nrf_crypto_ecdsa_secp256r1 Definitions specific to secp256r1 (NIST 256-bit) + * @addtogroup nrf_crypto_ecdsa_secp384r1 Definitions specific to secp384r1 (NIST 384-bit) + * @addtogroup nrf_crypto_ecdsa_secp521r1 Definitions specific to secp521r1 (NIST 521-bit) + * @addtogroup nrf_crypto_ecdsa_secp160k1 Definitions specific to secp160k1 (Koblitz 160-bit) + * @addtogroup nrf_crypto_ecdsa_secp192k1 Definitions specific to secp192k1 (Koblitz 192-bit) + * @addtogroup nrf_crypto_ecdsa_secp224k1 Definitions specific to secp224k1 (Koblitz 224-bit) + * @addtogroup nrf_crypto_ecdsa_secp256k1 Definitions specific to secp256k1 (Koblitz 256-bit) + * @addtogroup nrf_crypto_ecdsa_bp256r1 Definitions specific to bp256r1 (Brainpool 256-bit) + * @addtogroup nrf_crypto_ecdsa_bp384r1 Definitions specific to bp384r1 (Brainpool 384-bit) + * @addtogroup nrf_crypto_ecdsa_bp512r1 Definitions specific to bp512r1 (Brainpool 512-bit) + * @addtogroup nrf_crypto_ecdsa_curve25519 Definitions specific to Curve25519 + */ + +#include +#include + +#include "nrf_crypto_error.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_ecdsa_shared.h" +#include "nrf_crypto_ecdsa_backend.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_ECDSA_SECP160R1_SIGNATURE_SIZE (2 * 160 / 8) /**< @brief Size of a signature for secp160r1 (NIST 160-bit) curve. @ingroup nrf_crypto_ecdsa_secp160r1 */ +#define NRF_CRYPTO_ECDSA_SECP160R2_SIGNATURE_SIZE (2 * 160 / 8) /**< @brief Size of a signature for secp160r2 (NIST 160-bit) curve. @ingroup nrf_crypto_ecdsa_secp160r2 */ +#define NRF_CRYPTO_ECDSA_SECP192R1_SIGNATURE_SIZE (2 * 192 / 8) /**< @brief Size of a signature for secp192r1 (NIST 192-bit) curve. @ingroup nrf_crypto_ecdsa_secp192r1 */ +#define NRF_CRYPTO_ECDSA_SECP224R1_SIGNATURE_SIZE (2 * 224 / 8) /**< @brief Size of a signature for secp224r1 (NIST 224-bit) curve. @ingroup nrf_crypto_ecdsa_secp224r1 */ +#define NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE (2 * 256 / 8) /**< @brief Size of a signature for secp256r1 (NIST 256-bit) curve. @ingroup nrf_crypto_ecdsa_secp256r1 */ +#define NRF_CRYPTO_ECDSA_SECP384R1_SIGNATURE_SIZE (2 * 384 / 8) /**< @brief Size of a signature for secp384r1 (NIST 384-bit) curve. @ingroup nrf_crypto_ecdsa_secp384r1 */ +#define NRF_CRYPTO_ECDSA_SECP521R1_SIGNATURE_SIZE (2 * 528 / 8) /**< @brief Size of a signature for secp521r1 (NIST 521-bit) curve. @ingroup nrf_crypto_ecdsa_secp521r1 */ +#define NRF_CRYPTO_ECDSA_SECP160K1_SIGNATURE_SIZE (2 * 160 / 8) /**< @brief Size of a signature for secp160k1 (Koblitz 160-bit) curve. @ingroup nrf_crypto_ecdsa_secp160k1 */ +#define NRF_CRYPTO_ECDSA_SECP192K1_SIGNATURE_SIZE (2 * 192 / 8) /**< @brief Size of a signature for secp192k1 (Koblitz 192-bit) curve. @ingroup nrf_crypto_ecdsa_secp192k1 */ +#define NRF_CRYPTO_ECDSA_SECP224K1_SIGNATURE_SIZE (2 * 224 / 8) /**< @brief Size of a signature for secp224k1 (Koblitz 224-bit) curve. @ingroup nrf_crypto_ecdsa_secp224k1 */ +#define NRF_CRYPTO_ECDSA_SECP256K1_SIGNATURE_SIZE (2 * 256 / 8) /**< @brief Size of a signature for secp256k1 (Koblitz 256-bit) curve. @ingroup nrf_crypto_ecdsa_secp256k1 */ +#define NRF_CRYPTO_ECDSA_BP256R1_SIGNATURE_SIZE (2 * 256 / 8) /**< @brief Size of a signature for bp256r1 (Brainpool 256-bit) curve. @ingroup nrf_crypto_ecdsa_bp256r1 */ +#define NRF_CRYPTO_ECDSA_BP384R1_SIGNATURE_SIZE (2 * 384 / 8) /**< @brief Size of a signature for bp384r1 (Brainpool 384-bit) curve. @ingroup nrf_crypto_ecdsa_bp384r1 */ +#define NRF_CRYPTO_ECDSA_BP512R1_SIGNATURE_SIZE (2 * 512 / 8) /**< @brief Size of a signature for bp512r1 (Brainpool 512-bit) curve. @ingroup nrf_crypto_ecdsa_bp512r1 */ +#define NRF_CRYPTO_ECDSA_CURVE25519_SIGNATURE_SIZE (2 * 256 / 8) /**< @brief Size of a signature for Curve25519 curve. @ingroup nrf_crypto_ecdsa_curve25519 */ +#define NRF_CRYPTO_ECDSA_SIGNATURE_MAX_SIZE (2 * NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE) /**< @brief Maximum size of a signature for all enabled curves. */ + + +typedef uint8_t nrf_crypto_ecdsa_secp160r1_signature_t [NRF_CRYPTO_ECDSA_SECP160R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp160r1 (NIST 160-bit) curve. @ingroup nrf_crypto_ecdsa_secp160r1 */ +typedef uint8_t nrf_crypto_ecdsa_secp160r2_signature_t [NRF_CRYPTO_ECDSA_SECP160R2_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp160r2 (NIST 160-bit) curve. @ingroup nrf_crypto_ecdsa_secp160r2 */ +typedef uint8_t nrf_crypto_ecdsa_secp192r1_signature_t [NRF_CRYPTO_ECDSA_SECP192R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp192r1 (NIST 192-bit) curve. @ingroup nrf_crypto_ecdsa_secp192r1 */ +typedef uint8_t nrf_crypto_ecdsa_secp224r1_signature_t [NRF_CRYPTO_ECDSA_SECP224R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp224r1 (NIST 224-bit) curve. @ingroup nrf_crypto_ecdsa_secp224r1 */ +typedef uint8_t nrf_crypto_ecdsa_secp256r1_signature_t [NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp256r1 (NIST 256-bit) curve. @ingroup nrf_crypto_ecdsa_secp256r1 */ +typedef uint8_t nrf_crypto_ecdsa_secp384r1_signature_t [NRF_CRYPTO_ECDSA_SECP384R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp384r1 (NIST 384-bit) curve. @ingroup nrf_crypto_ecdsa_secp384r1 */ +typedef uint8_t nrf_crypto_ecdsa_secp521r1_signature_t [NRF_CRYPTO_ECDSA_SECP521R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp521r1 (NIST 521-bit) curve. @ingroup nrf_crypto_ecdsa_secp521r1 */ +typedef uint8_t nrf_crypto_ecdsa_secp160k1_signature_t [NRF_CRYPTO_ECDSA_SECP160K1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp160k1 (Koblitz 160-bit) curve. @ingroup nrf_crypto_ecdsa_secp160k1 */ +typedef uint8_t nrf_crypto_ecdsa_secp192k1_signature_t [NRF_CRYPTO_ECDSA_SECP192K1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp192k1 (Koblitz 192-bit) curve. @ingroup nrf_crypto_ecdsa_secp192k1 */ +typedef uint8_t nrf_crypto_ecdsa_secp224k1_signature_t [NRF_CRYPTO_ECDSA_SECP224K1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp224k1 (Koblitz 224-bit) curve. @ingroup nrf_crypto_ecdsa_secp224k1 */ +typedef uint8_t nrf_crypto_ecdsa_secp256k1_signature_t [NRF_CRYPTO_ECDSA_SECP256K1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for secp256k1 (Koblitz 256-bit) curve. @ingroup nrf_crypto_ecdsa_secp256k1 */ +typedef uint8_t nrf_crypto_ecdsa_bp256r1_signature_t [NRF_CRYPTO_ECDSA_BP256R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for bp256r1 (Brainpool 256-bit) curve. @ingroup nrf_crypto_ecdsa_bp256r1 */ +typedef uint8_t nrf_crypto_ecdsa_bp384r1_signature_t [NRF_CRYPTO_ECDSA_BP384R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for bp384r1 (Brainpool 384-bit) curve. @ingroup nrf_crypto_ecdsa_bp384r1 */ +typedef uint8_t nrf_crypto_ecdsa_bp512r1_signature_t [NRF_CRYPTO_ECDSA_BP512R1_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for bp512r1 (Brainpool 512-bit) curve. @ingroup nrf_crypto_ecdsa_bp512r1 */ +typedef uint8_t nrf_crypto_ecdsa_curve25519_signature_t [NRF_CRYPTO_ECDSA_CURVE25519_SIGNATURE_SIZE]; /**< @brief Type to hold signature output for Curve25519 curve. @ingroup nrf_crypto_ecdsa_curve25519 */ +typedef uint8_t nrf_crypto_ecdsa_signature_t [NRF_CRYPTO_ECDSA_SIGNATURE_MAX_SIZE]; /**< @brief Type big enough to hold signature output for any curve type. */ + + +typedef nrf_crypto_backend_secp160r1_sign_context_t nrf_crypto_ecdsa_secp160r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecdsa_secp160r1 */ +typedef nrf_crypto_backend_secp160r2_sign_context_t nrf_crypto_ecdsa_secp160r2_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecdsa_secp160r2 */ +typedef nrf_crypto_backend_secp192r1_sign_context_t nrf_crypto_ecdsa_secp192r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecdsa_secp192r1 */ +typedef nrf_crypto_backend_secp224r1_sign_context_t nrf_crypto_ecdsa_secp224r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecdsa_secp224r1 */ +typedef nrf_crypto_backend_secp256r1_sign_context_t nrf_crypto_ecdsa_secp256r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecdsa_secp256r1 */ +typedef nrf_crypto_backend_secp384r1_sign_context_t nrf_crypto_ecdsa_secp384r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecdsa_secp384r1 */ +typedef nrf_crypto_backend_secp521r1_sign_context_t nrf_crypto_ecdsa_secp521r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecdsa_secp521r1 */ +typedef nrf_crypto_backend_secp160k1_sign_context_t nrf_crypto_ecdsa_secp160k1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecdsa_secp160k1 */ +typedef nrf_crypto_backend_secp192k1_sign_context_t nrf_crypto_ecdsa_secp192k1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecdsa_secp192k1 */ +typedef nrf_crypto_backend_secp224k1_sign_context_t nrf_crypto_ecdsa_secp224k1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecdsa_secp224k1 */ +typedef nrf_crypto_backend_secp256k1_sign_context_t nrf_crypto_ecdsa_secp256k1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecdsa_secp256k1 */ +typedef nrf_crypto_backend_bp256r1_sign_context_t nrf_crypto_ecdsa_bp256r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecdsa_bp256r1 */ +typedef nrf_crypto_backend_bp384r1_sign_context_t nrf_crypto_ecdsa_bp384r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecdsa_bp384r1 */ +typedef nrf_crypto_backend_bp512r1_sign_context_t nrf_crypto_ecdsa_bp512r1_sign_context_t; /**< @brief Context used to store temporary data during signing with curve bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecdsa_bp512r1 */ +typedef nrf_crypto_backend_curve25519_sign_context_t nrf_crypto_ecdsa_curve25519_sign_context_t; /**< @brief Context used to store temporary data during signing with curve Curve25519. @ingroup nrf_crypto_ecdsa_curve25519 */ + + +typedef nrf_crypto_backend_secp160r1_verify_context_t nrf_crypto_ecdsa_secp160r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecdsa_secp160r1 */ +typedef nrf_crypto_backend_secp160r2_verify_context_t nrf_crypto_ecdsa_secp160r2_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecdsa_secp160r2 */ +typedef nrf_crypto_backend_secp192r1_verify_context_t nrf_crypto_ecdsa_secp192r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecdsa_secp192r1 */ +typedef nrf_crypto_backend_secp224r1_verify_context_t nrf_crypto_ecdsa_secp224r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecdsa_secp224r1 */ +typedef nrf_crypto_backend_secp256r1_verify_context_t nrf_crypto_ecdsa_secp256r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecdsa_secp256r1 */ +typedef nrf_crypto_backend_secp384r1_verify_context_t nrf_crypto_ecdsa_secp384r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecdsa_secp384r1 */ +typedef nrf_crypto_backend_secp521r1_verify_context_t nrf_crypto_ecdsa_secp521r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecdsa_secp521r1 */ +typedef nrf_crypto_backend_secp160k1_verify_context_t nrf_crypto_ecdsa_secp160k1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecdsa_secp160k1 */ +typedef nrf_crypto_backend_secp192k1_verify_context_t nrf_crypto_ecdsa_secp192k1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecdsa_secp192k1 */ +typedef nrf_crypto_backend_secp224k1_verify_context_t nrf_crypto_ecdsa_secp224k1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecdsa_secp224k1 */ +typedef nrf_crypto_backend_secp256k1_verify_context_t nrf_crypto_ecdsa_secp256k1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecdsa_secp256k1 */ +typedef nrf_crypto_backend_bp256r1_verify_context_t nrf_crypto_ecdsa_bp256r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecdsa_bp256r1 */ +typedef nrf_crypto_backend_bp384r1_verify_context_t nrf_crypto_ecdsa_bp384r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecdsa_bp384r1 */ +typedef nrf_crypto_backend_bp512r1_verify_context_t nrf_crypto_ecdsa_bp512r1_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecdsa_bp512r1 */ +typedef nrf_crypto_backend_curve25519_verify_context_t nrf_crypto_ecdsa_curve25519_verify_context_t; /**< @brief Context used to store temporary data during verifying with curve Curve25519. @ingroup nrf_crypto_ecdsa_curve25519 */ + + +/** @brief Union holding a context for ECDSA hash sign. + */ +typedef union +{ + nrf_crypto_ecdsa_secp160r1_sign_context_t context_secp160r1; /**< @brief Occupies space for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecdsa_secp160r2_sign_context_t context_secp160r2; /**< @brief Occupies space for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecdsa_secp192r1_sign_context_t context_secp192r1; /**< @brief Occupies space for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecdsa_secp224r1_sign_context_t context_secp224r1; /**< @brief Occupies space for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecdsa_secp256r1_sign_context_t context_secp256r1; /**< @brief Occupies space for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecdsa_secp384r1_sign_context_t context_secp384r1; /**< @brief Occupies space for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecdsa_secp521r1_sign_context_t context_secp521r1; /**< @brief Occupies space for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecdsa_secp160k1_sign_context_t context_secp160k1; /**< @brief Occupies space for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecdsa_secp192k1_sign_context_t context_secp192k1; /**< @brief Occupies space for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecdsa_secp224k1_sign_context_t context_secp224k1; /**< @brief Occupies space for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecdsa_secp256k1_sign_context_t context_secp256k1; /**< @brief Occupies space for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecdsa_bp256r1_sign_context_t context_bp256r1; /**< @brief Occupies space for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecdsa_bp384r1_sign_context_t context_bp384r1; /**< @brief Occupies space for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecdsa_bp512r1_sign_context_t context_bp512r1; /**< @brief Occupies space for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecdsa_curve25519_sign_context_t context_curve25519; /**< @brief Occupies space for Curve25519. */ +} nrf_crypto_ecdsa_sign_context_t; + + +/** @brief Union holding a context for ECDSA hash verify. + */ +typedef union +{ + nrf_crypto_ecdsa_secp160r1_verify_context_t context_secp160r1; /**< @brief Occupies spece for secp160r1 (NIST 160-bit). */ + nrf_crypto_ecdsa_secp160r2_verify_context_t context_secp160r2; /**< @brief Occupies spece for secp160r2 (NIST 160-bit). */ + nrf_crypto_ecdsa_secp192r1_verify_context_t context_secp192r1; /**< @brief Occupies spece for secp192r1 (NIST 192-bit). */ + nrf_crypto_ecdsa_secp224r1_verify_context_t context_secp224r1; /**< @brief Occupies spece for secp224r1 (NIST 224-bit). */ + nrf_crypto_ecdsa_secp256r1_verify_context_t context_secp256r1; /**< @brief Occupies spece for secp256r1 (NIST 256-bit). */ + nrf_crypto_ecdsa_secp384r1_verify_context_t context_secp384r1; /**< @brief Occupies spece for secp384r1 (NIST 384-bit). */ + nrf_crypto_ecdsa_secp521r1_verify_context_t context_secp521r1; /**< @brief Occupies spece for secp521r1 (NIST 521-bit). */ + nrf_crypto_ecdsa_secp160k1_verify_context_t context_secp160k1; /**< @brief Occupies spece for secp160k1 (Koblitz 160-bit). */ + nrf_crypto_ecdsa_secp192k1_verify_context_t context_secp192k1; /**< @brief Occupies spece for secp192k1 (Koblitz 192-bit). */ + nrf_crypto_ecdsa_secp224k1_verify_context_t context_secp224k1; /**< @brief Occupies spece for secp224k1 (Koblitz 224-bit). */ + nrf_crypto_ecdsa_secp256k1_verify_context_t context_secp256k1; /**< @brief Occupies spece for secp256k1 (Koblitz 256-bit). */ + nrf_crypto_ecdsa_bp256r1_verify_context_t context_bp256r1; /**< @brief Occupies spece for bp256r1 (Brainpool 256-bit). */ + nrf_crypto_ecdsa_bp384r1_verify_context_t context_bp384r1; /**< @brief Occupies spece for bp384r1 (Brainpool 384-bit). */ + nrf_crypto_ecdsa_bp512r1_verify_context_t context_bp512r1; /**< @brief Occupies spece for bp512r1 (Brainpool 512-bit). */ + nrf_crypto_ecdsa_curve25519_verify_context_t context_curve25519; /**< @brief Occupies spece for Curve25519. */ +} nrf_crypto_ecdsa_verify_context_t; + + +/** @brief Sign a hash of a message. + * + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_private_key Pointer to structure holding a private key. + * @param[in] p_hash Pointer to hash to sign. + * @param[in] hash_size Number of bytes in p_hash. + * @param[out] p_signature Pointer to buffer where digital signature will be put. + * @param[in,out] p_signature_size Maximum number of bytes that @p p_signature buffer can hold on input + * and the actual number of bytes used by the data on output. + * Actual size for selected curve is defined by + * the preprocessor definitions, e.g. + * @ref NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE. + */ +ret_code_t nrf_crypto_ecdsa_sign( + nrf_crypto_ecdsa_sign_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_hash, + size_t hash_size, + uint8_t * p_signature, + size_t * p_signature_size); + + +/** @brief Verify a signature using a hash of a message. + * + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_public_key Pointer to structure holding a public key. + * @param[in] p_hash Pointer to hash to verify. + * @param[in] hash_size Number of bytes in p_hash. + * @param[in] p_signature Pointer to buffer containing digital signature. + * @param[in,out] signature_size Number of bytes in p_signature. + */ +ret_code_t nrf_crypto_ecdsa_verify( + nrf_crypto_ecdsa_verify_context_t * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_hash, + size_t hash_size, + uint8_t const * p_signature, + size_t signature_size); + +#ifdef __cplusplus +} +#endif + +/** @} + * @} + */ + +#endif // NRF_CRYPTO_ECDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_backend.h new file mode 100644 index 0000000..65c6976 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_backend.h @@ -0,0 +1,251 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECDSA_BACKEND_H__ +#define NRF_CRYPTO_ECDSA_BACKEND_H__ +#if !defined(__SDK_DOXYGEN__) + +#include +#include + +#include "sdk_config.h" +#include "nrf_crypto_ecdsa_shared.h" + +// Include all backends +#include "cc310_backend_ecdsa.h" +#include "cc310_bl_backend_ecdsa.h" +#include "mbedtls_backend_ecdsa.h" +#include "oberon_backend_ecdsa.h" +#include "micro_ecc_backend_ecdsa.h" +#include "optiga_backend_ecdsa.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if !NRF_CRYPTO_ECC_SECP160R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP160R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP160R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp160r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp160r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp160r1_sign NULL +#define nrf_crypto_backend_secp160r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP160R2_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP160R2_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP160R2_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp160r2_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp160r2_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp160r2_sign NULL +#define nrf_crypto_backend_secp160r2_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP192R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP192R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp192r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp192r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp192r1_sign NULL +#define nrf_crypto_backend_secp192r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP224R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP224R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp224r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp224r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp224r1_sign NULL +#define nrf_crypto_backend_secp224r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP256R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp256r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp256r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp256r1_sign NULL +#define nrf_crypto_backend_secp256r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP384R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP384R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP384R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp384r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp384r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp384r1_sign NULL +#define nrf_crypto_backend_secp384r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP521R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP521R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP521R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp521r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp521r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp521r1_sign NULL +#define nrf_crypto_backend_secp521r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP160K1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP160K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP160K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp160k1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp160k1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp160k1_sign NULL +#define nrf_crypto_backend_secp160k1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP192K1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP192K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP192K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp192k1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp192k1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp192k1_sign NULL +#define nrf_crypto_backend_secp192k1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP224K1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP224K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP224K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp224k1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp224k1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp224k1_sign NULL +#define nrf_crypto_backend_secp224k1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_SECP256K1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_SECP256K1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_SECP256K1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_secp256k1_sign_context_t; +typedef uint8_t nrf_crypto_backend_secp256k1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_secp256k1_sign NULL +#define nrf_crypto_backend_secp256k1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_BP256R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_BP256R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP256R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_bp256r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_bp256r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_bp256r1_sign NULL +#define nrf_crypto_backend_bp256r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_BP384R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_BP384R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP384R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_bp384r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_bp384r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_bp384r1_sign NULL +#define nrf_crypto_backend_bp384r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_BP512R1_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_BP512R1_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_BP512R1_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_bp512r1_sign_context_t; +typedef uint8_t nrf_crypto_backend_bp512r1_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_bp512r1_sign NULL +#define nrf_crypto_backend_bp512r1_verify NULL +#endif + +#if !NRF_CRYPTO_ECC_CURVE25519_ENABLED +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_CURVE25519_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_CURVE25519_VERIFY_CONTEXT_SIZE 0 +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_curve25519_sign_context_t; +typedef uint8_t nrf_crypto_backend_curve25519_verify_context_t; +// Backend implementation is NULL to indicate feature not supported +#define nrf_crypto_backend_curve25519_sign NULL +#define nrf_crypto_backend_curve25519_verify NULL +#endif + + +#ifdef __cplusplus +} +#endif + +#endif // !defined(__SDK_DOXYGEN__) +#endif // NRF_CRYPTO_ECDSA_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_shared.h new file mode 100644 index 0000000..c5fbc34 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_ecdsa_shared.h @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_ECDSA_SHARED_H__ +#define NRF_CRYPTO_ECDSA_SHARED_H__ + +#include + +#include "nordic_common.h" +#include "nrf_crypto_ecc.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal @brief Function pointer for backend implementation of ECDSA sign. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to context. + * @param[in] p_private_key Pointer to private key. + * @param[in] p_data Pointer to data to sign. Data can be a message or a hash. It depends + * on which version of signing functions is pointed by this function + * pointer. + * @param[in] data_size Size of @p p_data. + * @param[out] p_signature Pointer where to put generated signature. + */ +typedef ret_code_t (*nrf_crypto_backend_ecdsa_sign_fn_t)( + void * p_context, + void const * p_private_key, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_signature); + + +/** @internal @brief Function pointer for backend implementation of ECDSA verify. + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to context. + * @param[in] p_public_key Pointer to public key. + * @param[in] p_data Pointer to data to verify. Data can be a message or a hash. It depends + * on which version of signing functions is pointed by this function + * pointer. + * @param[in] data_size Size of @p p_data. + * @param[in] p_signature Pointer to signature to verify. + */ +typedef ret_code_t (*nrf_crypto_backend_ecdsa_verify_fn_t)( + void * p_context, + void const * p_public_key, + uint8_t const * p_data, + size_t data_size, + uint8_t const * p_signature); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_CRYPTO_ECDSA_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.c new file mode 100644 index 0000000..58cd81d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.c @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2018 - 2019, 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 "nrf_crypto_error.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_eddsa.h" +#include "nrf_crypto_mem.h" +#include "app_util.h" +#include "sdk_macros.h" + + +#if NRF_CRYPTO_ECC_ENABLED && NRF_CRYPTO_ECC_ED25519_ENABLED + + + +ret_code_t nrf_crypto_eddsa_sign(nrf_crypto_eddsa_sign_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_message, + size_t message_size, + uint8_t * p_signature, + size_t * p_signature_size) +{ + ret_code_t result = NRF_SUCCESS; + void * p_allocated_context = NULL; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_private_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_private_key; + + // Verify parameters (zero-length message is valid per RFC 8032) + if (message_size > 0) + { + VERIFY_TRUE(p_message != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + } + + result = nrf_crypto_internal_ecc_key_input_check( + p_private_key_header, + NRF_CRYPTO_INTERNAL_ECC_PRIVATE_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + + result = nrf_crypto_internal_ecc_raw_output_prepare(p_signature, + p_signature_size, + NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE); + VERIFY_SUCCESS(result); + + // Allocate context if not provided + if (p_context == NULL && NRF_CRYPTO_BACKEND_ED25519_SIGN_CONTEXT_SIZE > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(NRF_CRYPTO_BACKEND_ED25519_SIGN_CONTEXT_SIZE); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = nrf_crypto_backend_ed25519_sign(p_context, + p_private_key, + p_message, + message_size, + p_signature); + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + + +ret_code_t nrf_crypto_eddsa_verify(nrf_crypto_eddsa_verify_context_t * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_message, + size_t message_size, + uint8_t const * p_signature, + size_t signature_size) +{ + ret_code_t result = NRF_SUCCESS; + void * p_allocated_context = NULL; + + // Get pointer to header + nrf_crypto_internal_ecc_key_header_t const * p_public_key_header = + (nrf_crypto_internal_ecc_key_header_t const *)p_public_key; + + // Verify parameters (zero-length message is valid per RFC 8032) + if (message_size > 0) + { + VERIFY_TRUE(p_message != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + } + + result = nrf_crypto_internal_ecc_key_input_check( + p_public_key_header, + NRF_CRYPTO_INTERNAL_ECC_PUBLIC_KEY_INIT_VALUE); + VERIFY_SUCCESS(result); + + result = nrf_crypto_internal_ecc_raw_input_check(p_signature, + signature_size, + NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE); + VERIFY_SUCCESS(result); + + // Allocate context if not provided + if (p_context == NULL && NRF_CRYPTO_BACKEND_ED25519_VERIFY_CONTEXT_SIZE > 0) + { + p_allocated_context = NRF_CRYPTO_ALLOC(NRF_CRYPTO_BACKEND_ED25519_VERIFY_CONTEXT_SIZE); + VERIFY_TRUE(p_allocated_context != NULL, NRF_ERROR_CRYPTO_ALLOC_FAILED); + p_context = p_allocated_context; + } + + // Execute backend implementation + result = nrf_crypto_backend_ed25519_verify(p_context, + p_public_key, + p_message, + message_size, + p_signature); + + // Deallocate context if allocated + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return result; +} + +#endif // NRF_CRYPTO_ECC_ENABLED && NRF_CRYPTO_ECC_ED25519_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.h new file mode 100644 index 0000000..733a5af --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa.h @@ -0,0 +1,127 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_EDDSA_H__ +#define NRF_CRYPTO_EDDSA_H__ + +/** @file + * + * @defgroup nrf_crypto_eddsa Edwards-curve Digital Signature Algorithm (EdDSA) + * @{ + * @ingroup nrf_crypto + * + * @brief Provides functionality related to Edwards-curve Digital Signature Algorithm (EdDSA). + */ + +#include +#include + +#include "nrf_crypto_error.h" +#include "nrf_crypto_ecc.h" +#include "nrf_crypto_eddsa_shared.h" +#include "nrf_crypto_eddsa_backend.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/**< @brief Size of the EdDSA Ed25519 signature. */ +#define NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE (2 * 256 / 8) + +/**< @brief Context used to store temporary data during the signing with EdDSA Ed25519. */ +typedef nrf_crypto_backend_ed25519_sign_context_t nrf_crypto_eddsa_sign_context_t; + +/**< @brief Context used to store temporary data during the verification with EdDSA Ed25519. */ +typedef nrf_crypto_backend_ed25519_verify_context_t nrf_crypto_eddsa_verify_context_t; + + +/** @brief Sign a message using Edwards-curve Digital Signature Algorithm (EdDSA). + * + * @param[in] p_context Pointer to the temporary structure that holds context information. + * If it is NULL, the required data is allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_private_key Pointer to the structure that holds a private key. + * @param[in] p_message Pointer to the message to sign. + * @param[in] message_size Number of bytes in p_message. + * @param[out] p_signature Pointer to the array where EdDSA signature is to be put. Minimum bytes required: @ref NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE. + * @param[in,out] p_signature_size Pointer to the maximum number of bytes that @p p_signature buffer + * can hold on input, and to the actual number of bytes used by the + * data on output (@ref NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE). + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_eddsa_sign(nrf_crypto_eddsa_sign_context_t * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_message, + size_t message_size, + uint8_t * p_signature, + size_t * p_signature_size); + + +/** @brief Verify a message using Edwards-curve Digital Signature Algorithm (EdDSA). + * + * @param[in] p_context Pointer to the temporary structure that holds context information. + * If it is NULL, necessary data is allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_public_key Pointer to the structure that holds a public key. + * @param[in] p_message Pointer to the message to verify. + * @param[in] message_size Number of bytes in p_message. + * @param[in] p_signature Pointer to the array that contains EdDSA signature. + * @param[in] signature_size Number of bytes in p_signature. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_eddsa_verify(nrf_crypto_eddsa_verify_context_t * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_message, + size_t message_size, + uint8_t const * p_signature, + size_t signature_size); + + +#ifdef __cplusplus +} +#endif + +/** @} + */ + +#endif // NRF_CRYPTO_EDDSA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_backend.h new file mode 100644 index 0000000..7216dbe --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_backend.h @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_EDDSA_BACKEND_H__ +#define NRF_CRYPTO_EDDSA_BACKEND_H__ +#if !defined(__SDK_DOXYGEN__) + +#include +#include + +#include "sdk_config.h" +#include "nrf_crypto_ecdsa_shared.h" + +// Include all backends +#include "cc310_backend_eddsa.h" +#include "oberon_backend_eddsa.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#if !NRF_CRYPTO_ECC_ED25519_ENABLED + +// Context sizes are zero for disabled functionality +#define NRF_CRYPTO_BACKEND_ED25519_SIGN_CONTEXT_SIZE 0 +#define NRF_CRYPTO_BACKEND_ED25519_VERIFY_CONTEXT_SIZE 0 + +// Dummy typedefs for disabled contexts +typedef uint8_t nrf_crypto_backend_ed25519_sign_context_t; +typedef uint8_t nrf_crypto_backend_ed25519_verify_context_t; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // !defined(__SDK_DOXYGEN__) +#endif // NRF_CRYPTO_EDDSA_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_shared.h new file mode 100644 index 0000000..811c9d1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_eddsa_shared.h @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_EDDSA_SHARED_H__ +#define NRF_CRYPTO_EDDSA_SHARED_H__ + +#include + +#include "nordic_common.h" +#include "nrf_crypto_ecc.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @internal @brief Sign a message using Edwards-curve Digital Signature Algorithm (EdDSA). + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_private_key Pointer to structure holding a private Ed25519 key. + * (Buffer size @ref NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE). + * @param[in] p_message Pointer to message to sign. + * @param[in] message_size Number of bytes in p_message. + * @param[out] p_signature Pointer to buffer where EdDSA signature will be put. Must be + * @ref NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE bytes. + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_backend_ed25519_sign( + void * p_context, + nrf_crypto_ecc_private_key_t const * p_private_key, + uint8_t const * p_message, + size_t message_size, + uint8_t * p_signature); + + +/** @internal @brief Verify a message using Edwards-curve Digital Signature Algorithm (EdDSA). + * + * @note All parameters provided to the backend are vefified in frontend. Verification includes + * checking of NULL pointers, buffer size, initialization values. Front end also take full care of + * common ECC key hearder @ref nrf_crypto_internal_ecc_key_header_t. + * + * @param[in] p_context Pointer to temporary structure holding context information. + * If it is NULL, necessary data will be allocated with + * @ref NRF_CRYPTO_ALLOC and freed at the end of the function. + * @param[in] p_public_key Pointer to structure holding a public Ed25519 key. + * (Buffer size @ref NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE). + * @param[in] p_message Pointer to message to verify. + * @param[in] message_size Number of bytes in p_message. + * @param[in] p_signature Pointer to buffer containing EdDSA signature + * (@ref NRF_CRYPTO_EDDSA_ED25519_SIGNATURE_SIZE bytes). + * + * @return NRF_SUCCESS on success. + */ +ret_code_t nrf_crypto_backend_ed25519_verify( + void * p_context, + nrf_crypto_ecc_public_key_t const * p_public_key, + uint8_t const * p_message, + size_t message_size, + uint8_t const * p_signature); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_CRYPTO_EDDSA_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.c new file mode 100644 index 0000000..24ba322 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.c @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2017 - 2019, 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(NRF_CRYPTO) + +#include "nordic_common.h" +#include "nrf_crypto_error.h" + +typedef struct +{ + ret_code_t error; + const char * p_text; +} error_code_pair; + +static const error_code_pair m_crypto_error[] = +{ + { NRF_ERROR_CRYPTO_NOT_INITIALIZED, "nrf_crypto_init was not called prior to this crypto function" }, + { NRF_ERROR_CRYPTO_CONTEXT_NULL, "A null pointer was provided for the context structure" }, + { NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED, "The context was not initialized prior to this call or it was corrupted. Please call the corresponding init function for the algorithm to initialize it" }, + { NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE, "The function was called with a feature that is unavailable" }, + { NRF_ERROR_CRYPTO_BUSY, "The function could not be called because the crypto backend was busy. Please rerun the cryptographic routine at a later time" }, + { NRF_ERROR_CRYPTO_INPUT_NULL, "One or more of the input arguments for this function was NULL" }, + { NRF_ERROR_CRYPTO_INPUT_LENGTH, "The length of one or more of the input arguments was invalid" }, + { NRF_ERROR_CRYPTO_INPUT_LOCATION, "Input data not in RAM" }, + { NRF_ERROR_CRYPTO_OUTPUT_NULL, "One or more of the output arguments for this function was NULL" }, + { NRF_ERROR_CRYPTO_OUTPUT_LENGTH, "The length of the one or more output arguments was too small" }, + { NRF_ERROR_CRYPTO_ALLOC_FAILED, "A required memory allocation failed" }, + { NRF_ERROR_CRYPTO_INTERNAL, "An internal error occurred when calling this function" }, + { NRF_ERROR_CRYPTO_INVALID_PARAM, "Invalid combination of input parameters" }, + { NRF_ERROR_CRYPTO_KEY_SIZE, "Size of the key is not supported by choosen backend" }, + { NRF_ERROR_CRYPTO_STACK_OVERFLOW, "Stack overflow detected" }, + { NRF_ERROR_CRYPTO_ECC_KEY_NOT_INITIALIZED, "ECC key was not initialized" }, + { NRF_ERROR_CRYPTO_ECDH_CURVE_MISMATCH, "Public and private key provided to ECDH have different types of curves" }, + { NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE, "Signature verification check reported invalid signature" }, + { NRF_ERROR_CRYPTO_ECC_INVALID_KEY, "Provided key is invalid" }, + { NRF_ERROR_CRYPTO_AES_INVALID_PADDING, "Message padding is corrupted." }, + { NRF_ERROR_CRYPTO_AEAD_INVALID_MAC, "MAC not matching encrypted text" }, + { NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE, "Size of the nonce is not supported in this AEAD mode" }, + { NRF_ERROR_CRYPTO_AEAD_MAC_SIZE, "Size of the MAC (tag) is not supported in this AEAD mode" }, + { NRF_ERROR_CRYPTO_RNG_INIT_FAILED, "Initialization or startup of RNG failed" }, + { NRF_ERROR_CRYPTO_RNG_RESEED_REQUIRED, "Reseed required (reseed counter overflowed)" }, +}; + +char const * nrf_crypto_error_string_get(ret_code_t error) +{ + if (error == NRF_SUCCESS) + { + return "No error"; + } + else + { + uint32_t i; + for (i = 0; i < ARRAY_SIZE(m_crypto_error); i++) + { + if (m_crypto_error[i].error == error) + { + return m_crypto_error[i].p_text; + } + } + } + return "Error not related to nrf_crypto library"; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.h new file mode 100644 index 0000000..0d53e31 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_error.h @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRF_CRYPTO_ERROR_H__ +#define NRF_CRYPTO_ERROR_H__ + +/**@file + * + * @defgroup nrf_crypto_error nrf_crypto error codes + * @{ + * @ingroup nrf_crypto + * + * @details This is the standardized error codes provided when calling nrf_crypto APIs. + * The error codes provided here are enumerated based on @ref NRF_ERROR_CRYPTO_ERR_BASE. + * + * @note Success code, NRF_SUCCESS, is used if the nrf_crypto operation was successful. + * + */ + +#include "sdk_errors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_ERROR_CRYPTO_NOT_INITIALIZED (NRF_ERROR_CRYPTO_ERR_BASE + 0x00) /**< @ref nrf_crypto_init was not called prior to this crypto function. */ +#define NRF_ERROR_CRYPTO_CONTEXT_NULL (NRF_ERROR_CRYPTO_ERR_BASE + 0x01) /**< A null pointer was provided for the context structure. */ +#define NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED (NRF_ERROR_CRYPTO_ERR_BASE + 0x02) /**< The context was not initialized prior to this call or it was corrupted. Call the corresponding init function for the algorithm to initialize it. */ +#define NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE (NRF_ERROR_CRYPTO_ERR_BASE + 0x03) /**< The function was called with a feature that is unavailable. */ +#define NRF_ERROR_CRYPTO_BUSY (NRF_ERROR_CRYPTO_ERR_BASE + 0x04) /**< The function could not be called because the crypto backend was busy. Rerun the cryptographic routine at a later time. */ + +#define NRF_ERROR_CRYPTO_INPUT_NULL (NRF_ERROR_CRYPTO_ERR_BASE + 0x10) /**< One or more of the input arguments for this function were NULL. */ +#define NRF_ERROR_CRYPTO_INPUT_LENGTH (NRF_ERROR_CRYPTO_ERR_BASE + 0x11) /**< The length of one or more of the input arguments was invalid. */ +#define NRF_ERROR_CRYPTO_INPUT_LOCATION (NRF_ERROR_CRYPTO_ERR_BASE + 0x12) /**< Input data not in RAM. */ +#define NRF_ERROR_CRYPTO_OUTPUT_NULL (NRF_ERROR_CRYPTO_ERR_BASE + 0x13) /**< One or more of the output arguments for this function were NULL. */ +#define NRF_ERROR_CRYPTO_OUTPUT_LENGTH (NRF_ERROR_CRYPTO_ERR_BASE + 0x14) /**< The length of one or more output arguments was too small. */ +#define NRF_ERROR_CRYPTO_ALLOC_FAILED (NRF_ERROR_CRYPTO_ERR_BASE + 0x15) /**< A required memory allocation failed. */ +#define NRF_ERROR_CRYPTO_INTERNAL (NRF_ERROR_CRYPTO_ERR_BASE + 0x16) /**< An internal error occurred when calling this function. */ +#define NRF_ERROR_CRYPTO_INVALID_PARAM (NRF_ERROR_CRYPTO_ERR_BASE + 0x17) /**< Invalid combination of input parameters. */ +#define NRF_ERROR_CRYPTO_KEY_SIZE (NRF_ERROR_CRYPTO_ERR_BASE + 0x18) /**< Size of the key is not supported by choosen backend. */ +#define NRF_ERROR_CRYPTO_STACK_OVERFLOW (NRF_ERROR_CRYPTO_ERR_BASE + 0x19) /**< Stack overflow detected. */ + +#define NRF_ERROR_CRYPTO_ECC_ERR_BASE (NRF_ERROR_CRYPTO_ERR_BASE + 0x40) /**< Base error code for ECC. */ +#define NRF_ERROR_CRYPTO_ECC_KEY_NOT_INITIALIZED (NRF_ERROR_CRYPTO_ECC_ERR_BASE + 0x00) /**< The key was not initialized. */ +#define NRF_ERROR_CRYPTO_ECDH_CURVE_MISMATCH (NRF_ERROR_CRYPTO_ECC_ERR_BASE + 0x01) /**< Public and private key provided to ECDH have different types of curves. */ +#define NRF_ERROR_CRYPTO_ECDSA_INVALID_SIGNATURE (NRF_ERROR_CRYPTO_ECC_ERR_BASE + 0x02) /**< Signature verification check reported invalid signature. */ +#define NRF_ERROR_CRYPTO_ECC_INVALID_KEY (NRF_ERROR_CRYPTO_ECC_ERR_BASE + 0x03) /**< Provided key is invalid. */ + +#define NRF_ERROR_CRYPTO_AES_ERR_BASE (NRF_ERROR_CRYPTO_ERR_BASE + 0x50) /**< Base error code for all AES modes. */ +#define NRF_ERROR_CRYPTO_AES_INVALID_PADDING (NRF_ERROR_CRYPTO_AES_ERR_BASE + 0x00) /**< Message padding is corrupted. */ + +#define NRF_ERROR_CRYPTO_AEAD_ERR_BASE (NRF_ERROR_CRYPTO_ERR_BASE + 0x60) /**< Base error code for all AEAD modes. */ +#define NRF_ERROR_CRYPTO_AEAD_INVALID_MAC (NRF_ERROR_CRYPTO_AEAD_ERR_BASE + 0x00) /**< MAC not matching encrypted text. */ +#define NRF_ERROR_CRYPTO_AEAD_NONCE_SIZE (NRF_ERROR_CRYPTO_AEAD_ERR_BASE + 0x01) /**< Size of the nonce is not supported in this AEAD mode. */ +#define NRF_ERROR_CRYPTO_AEAD_MAC_SIZE (NRF_ERROR_CRYPTO_AEAD_ERR_BASE + 0x02) /**< Size of the MAC (tag) is not supported in this AEAD mode. */ + +#define NRF_ERROR_CRYPTO_RNG_ERR_BASE (NRF_ERROR_CRYPTO_ERR_BASE + 0x70) /**< Base error code for all RNG modes. */ +#define NRF_ERROR_CRYPTO_RNG_INIT_FAILED (NRF_ERROR_CRYPTO_RNG_ERR_BASE + 0x00) /**< Initialization or startup of RNG failed. */ +#define NRF_ERROR_CRYPTO_RNG_RESEED_REQUIRED (NRF_ERROR_CRYPTO_RNG_ERR_BASE + 0x01) /**< Reseed required (reseed counter overflowed). */ + +/** + * @brief Function for converting an nrf_crypto error to a printable string pointer. + * + * @param[in] error Error code. + * + * @return Pointer to string explaining nrf_crypto error. + * */ +char const * nrf_crypto_error_string_get(ret_code_t error); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // NRF_CRYPTO_ERROR_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.c new file mode 100644 index 0000000..7e49611 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.c @@ -0,0 +1,205 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "nrf_crypto_error.h" +#include "nrf_crypto_hash.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_hash_backend.h" +#include "nrf_crypto_hash_shared.h" +#include "nrf_crypto_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HASH) + +static ret_code_t verify_context(nrf_crypto_hash_internal_context_t * const p_context) +{ + if (p_context == NULL) + { + return NRF_ERROR_CRYPTO_CONTEXT_NULL; + } + + if (p_context->init_val != NRF_CRYPTO_HASH_INIT_VALUE) + { + return NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + } + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_hash_init(nrf_crypto_hash_context_t * const p_context, + nrf_crypto_hash_info_t const * p_info) +{ + ret_code_t ret_val; + nrf_crypto_hash_internal_context_t * p_int_context; + + VERIFY_TRUE(p_context != NULL, NRF_ERROR_CRYPTO_CONTEXT_NULL); + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + p_int_context = (nrf_crypto_hash_internal_context_t *) p_context; + p_int_context->p_info = p_info; + + ret_val = p_info->init_fn(p_context); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + p_int_context->init_val = NRF_CRYPTO_HASH_INIT_VALUE; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_hash_update(nrf_crypto_hash_context_t * const p_context, + uint8_t const * p_data, + size_t data_size) +{ + ret_code_t ret_val; + nrf_crypto_hash_internal_context_t * p_int_context + = (nrf_crypto_hash_internal_context_t *) p_context; + + ret_val = verify_context(p_int_context); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + VERIFY_TRUE(p_data != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + // Allow zero size input + if (data_size == 0) + { + return NRF_SUCCESS; + } + + ret_val = p_int_context->p_info->update_fn(p_context, p_data, data_size); + + return ret_val; +} + + +ret_code_t nrf_crypto_hash_finalize(nrf_crypto_hash_context_t * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + ret_code_t ret_val; + nrf_crypto_hash_internal_context_t * p_int_context + = (nrf_crypto_hash_internal_context_t *) p_context; + + ret_val = verify_context(p_int_context); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + + VERIFY_TRUE(p_digest != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + VERIFY_TRUE(*p_digest_size >= p_int_context->p_info->digest_size, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + + ret_val = p_int_context->p_info->finalize_fn(p_context, p_digest, p_digest_size); + + return ret_val; +} + + +ret_code_t nrf_crypto_hash_calculate(nrf_crypto_hash_context_t * const p_context, + nrf_crypto_hash_info_t const * p_info, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + ret_code_t ret_val; + nrf_crypto_hash_context_t * p_ctx = (nrf_crypto_hash_context_t *)p_context; + void * p_allocated_context = NULL; + +// Internal allocation of context not available for CC310_BL in order to save code size. +#if defined(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED == 1) + + // Do nothing + +#elif defined(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED) && (NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED == 0) + + // Validate input. Only validate input parameters that are used locally, others are validated + // in the init, update and/or finalize functions. + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + // Allocate context if needed (not provided by the user). + if (p_context == NULL) + { + p_allocated_context = NRF_CRYPTO_ALLOC(p_info->context_size); + if (p_allocated_context == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + p_ctx = (nrf_crypto_hash_context_t *)p_allocated_context; + } + +#else + + #warning NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). + +#endif // NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED + + ret_val = nrf_crypto_hash_init(p_ctx, p_info); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(ret_val, p_allocated_context); + + ret_val = nrf_crypto_hash_update(p_ctx, p_data, data_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(ret_val, p_allocated_context); + + ret_val = nrf_crypto_hash_finalize(p_ctx, p_digest, p_digest_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(ret_val, p_allocated_context); + +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256) + // Free context if allocated internally + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } +#endif // !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256) + + return NRF_SUCCESS; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_HASH) + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.h new file mode 100644 index 0000000..ffaaec4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash.h @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_HASH_H__ +#define NRF_CRYPTO_HASH_H__ + +/** @file + * + * @defgroup nrf_crypto_hash Cryptographic hash related functions + * @{ + * @ingroup nrf_crypto + * + * @brief Provides cryptographic hash related functionality through nrf_crypto. + */ + +#include +#include "nrf_crypto_types.h" +#include "nrf_crypto_hash_shared.h" +#include "nrf_crypto_hash_backend.h" +#include "app_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief External variable declaration to info structure for SHA-256 + * + * @note The variable is defined in the nrf_crypto backend that is + * enabled in the @ref sdk_config. + * + */ +extern const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info; + + + /**@brief External variable declaration to info structure for SHA-512 + * + * @note The variable is defined in the nrf_crypto backend that is + * enabled in the @ref sdk_config. + * + */ +extern const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha512_info; + + +/** + * @brief Context type for Hash. + * + * @note The size of this type is scaled for the largest Hash backend context that is + * enabled in @ref sdk_config. + */ +typedef nrf_crypto_backend_hash_context_t nrf_crypto_hash_context_t; + + +/** @brief Type definition for an array holding a SHA-256 hash digest. */ +typedef uint8_t nrf_crypto_hash_sha256_digest_t[NRF_CRYPTO_HASH_SIZE_SHA256]; + + +/** @brief Type definition for an array holding a SHA-512 hash digest. */ +typedef uint8_t nrf_crypto_hash_sha512_digest_t[NRF_CRYPTO_HASH_SIZE_SHA512]; + + +/**@brief Function for initializing the context structure required to compute a hash digest from + * arbitrary input data. + * + * @note The context structure is assumed to be an opaque type defined by the + * nrf_crypto backend. + * + * @note The return codes @ref NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE and + * NRF_ERROR_CRYPTO_INTERNAL only happens in cc310 backend. + * + * @param[in,out] p_context Pointer to structure holding context information for + * the hash calculation. + * @param[in] p_info Pointer to structure holding info about the hash algorithm + * used to do the computed hash. + * + * @retval NRF_SUCCESS The hash initialization was successful. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this crypto function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL A NULL pointer was provided for the context + * structure. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL The pointer to the info structure was NULL. + * @retval NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE The function was called with a hash mode that + * is unavailable. + * @retval NRF_ERROR_CRYPTO_INTERNAL An internal error occurred when initializing + * the constext in the nrf_crypto backend. + */ +ret_code_t nrf_crypto_hash_init(nrf_crypto_hash_context_t * const p_context, + nrf_crypto_hash_info_t const * p_info); + + +/**@brief Function for updating the hash calculation with partial arbitrary data. + * + * @details This function should be called one or more times until all arbituary input data + * required for the hash calcuation is provided. + * + * @note @ref nrf_crypto_hash_init must be called prior to this function to configure the + * context structure used as input parameter to this function. + * + * @note @ref nrf_crypto_hash_finalize must be called after all arbitruary input data + * has been provided to get the calculated hash digest. + * + * @note The context object is assumed to be an opaque type defined by the + * nrf_crypto backend. + * + * @note The return values @ref NRF_ERROR_CRYPTO_BUSY, @ref NRF_ERROR_CRYPTO_INPUT_LOCATION + * and @ref NRF_ERROR_CRYPTO_INPUT_LOCATION can only occur in CC310 backend. + * + * @param[in,out] p_context Pointer to structure holding context information for + * the hash calculation. + * @param[in] p_data Pointer to data to be hashed. + * @param[in] data_size Length of the data to be hashed. + * + * @retval NRF_SUCCESS The hash digest was computed successfully. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this crypto function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED The context was not initialized prior to + * this call or it was corrupted. Please call + * @ref nrf_crypto_hash_init to initialize it. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL A NULL pointer was provided for the context + * structure. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL p_data was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_LOCATION Input data not in RAM. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun the + * cryptographic routine at a later time. + * @retval NRF_ERROR_CRYPTO_INTERNAL An internal error occurred in the nrf_crypto + * backend. + */ +ret_code_t nrf_crypto_hash_update(nrf_crypto_hash_context_t * const p_context, + uint8_t const * p_data, + size_t data_size); + +/**@brief Function for finalizing computation of a hash digest from arbitrary data. + * + * @details This function is called to get the calculated + * + * @note @ref nrf_crypto_hash_init must be called prior to this function to configure the + * context structure used as input parameter to this function. + * + * @note The input data for the calculated hash digest must be provided by calling + * @ref nrf_crypto_hash_update one or more times. + * + * @note The context object is assumed to be an opaque type defined by the + * nrf_crypto backend. + * + * @note The return values @ref NRF_ERROR_CRYPTO_BUSY and @ref NRF_ERROR_CRYPTO_INPUT_LOCATION + * can only occur in CC310 backend. + * + * + * @param[in] p_context Pointer to structure holding context information for + * the hash calculation. + * @param[out] p_digest Pointer to buffer holding the calculated hash digest. + * @param[in,out] p_digest_size Pointer to a variable holding the length of the calculated hash. + * Set this to the length of buffer that p_digest is pointing to. + * + * @retval NRF_SUCCESS The hash digest was computed successfully. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this crypto function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED The context was not initialized prior to + * this call or it was corrupted. Please call + * @ref nrf_crypto_hash_init to initialize it. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL A NULL pointer was provided for the context + * structure. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL p_digest or p_digest_size was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH The length of p_digest was too small for + * the hash digest result. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun the + * cryptographic routine at a later time. + * @retval NRF_ERROR_CRYPTO_INTERNAL An internal error occurred in the nrf_crypto + * backend. + */ +ret_code_t nrf_crypto_hash_finalize(nrf_crypto_hash_context_t * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size); + + +/**@brief Function for computing a hash from arbitrary data in a single integrated step. + * + * @details This function calculates the hash digest from arbitruary data in a single integrated step. + * This means calling init, update and finalize in one step. + * + * @note The context object is assumed to be an opaque type defined by the + * nrf_crypto backend. + * + * @note The return values @ref NRF_ERROR_CRYPTO_BUSY, @ref NRF_ERROR_CRYPTO_INPUT_LOCATION + * and @ref NRF_ERROR_CRYPTO_INPUT_LOCATION can only occur in CC310 backend. + * + * @param[in,out] p_context Pointer to structure holding context information for + * the hash calculation. If this + * is set to NULL, it will be allocated by the user configurable + * allocate/free function @ref NRF_CRYPTO_ALLOC and + * @ref NRF_CRYPTO_FREE. + * @param[in] p_info Pointer to structure holding info about hash algorithm + * for the computed hash. + * @param[in] p_data Pointer to data to be hashed. + * @param[in] data_size Length of the data to be hashed. + * @param[out] p_digest Pointer to buffer holding the calculated hash digest. + * @param[in,out] p_digest_size Pointer to a variable holding the length of the calculated hash. + * Set this to the length of buffer that p_digest is pointing to. + * + * @retval NRF_SUCCESS The hash initialization was successful. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this crypto function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL A NULL pointer was provided for the context + * structure. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL p_info or p_data was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_LOCATION Input data not in RAM. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL p_digest or p_digest_size was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH The length of p_digest was too small for + * the hash digest result. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun the + * cryptographic routine at a later time. + * @retval NRF_ERROR_CRYPTO_ALLOC_FAILED Unable to allocate memory for the context. + * @retval NRF_ERROR_CRYPTO_INTERNAL An internal error occurred in the nrf_crypto + * backend. + */ +ret_code_t nrf_crypto_hash_calculate(nrf_crypto_hash_context_t * const p_context, + nrf_crypto_hash_info_t const * p_info, + uint8_t const * p_data, + size_t data_size, + uint8_t * p_digest, + size_t * const p_digest_size); + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_backend.h similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_backend.h index 9d791c6..10d3914 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_keys.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_backend.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,44 +35,50 @@ * 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 CC310_LIB_KEYS_H__ -#define CC310_LIB_KEYS_H__ - -/** @file - * - * @defgroup nrf_crypto_backend_cc310_lib_ecc_keys CC310 backend ECC key types. - * @{ - * @ingroup nrf_crypto_backend_cryptocell * - * @brief Provides types required for CC310 backend ECC keys. */ -#include "nrf_crypto_ecdsa.h" -#include "crys_ecpki_types.h" +#ifndef NRF_CRYPTO_HASH_BACKEND_H__ +#define NRF_CRYPTO_HASH_BACKEND_H__ + +#include "sdk_common.h" +#include "cc310_backend_hash.h" +#include "mbedtls_backend_hash.h" +#include "oberon_backend_hash.h" +#include "cc310_bl_backend_hash.h" +#include "nrf_sw_backend_hash.h" #ifdef __cplusplus extern "C" { -#if 0 -} -#endif #endif -/**@brief Macro to get the size of the internal represenation of a private key - * in the CryptoCell API. +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA256) + +/**@internal @brief Fallback type for SHA-256 hash context (if no backend is enabled). */ -#define NRF_CRYPTO_ECC_PRIVATE_KEY_MAX_SIZE (sizeof(CRYS_ECPKI_UserPrivKey_t)) +typedef nrf_crypto_hash_internal_context_t nrf_crypto_backend_hash_sha256_context_t; + +#endif + +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_HASH_SHA512) -/**@brief Macro to get the size of the internal represenation of a public key - * in the CryptoCell API. +/**@internal @brief Fallback type for SHA-512 hash context (if no backend is enabled). */ -#define NRF_CRYPTO_ECC_PUBLIC_KEY_MAX_SIZE (sizeof(CRYS_ECPKI_UserPublKey_t)) +typedef nrf_crypto_hash_internal_context_t nrf_crypto_backend_hash_sha512_context_t; + +#endif + + +/** @internal @brief Union holding a hash context. */ +typedef union +{ + nrf_crypto_backend_hash_sha256_context_t hash_sha256_context; /**< @brief Holds context for SHA-256. */ + nrf_crypto_backend_hash_sha512_context_t hash_sha512_context; /**< @brief Holds context for SHA-512. */ +} nrf_crypto_backend_hash_context_t; + #ifdef __cplusplus } #endif -/**@} */ - -#endif // #ifndef CC310_LIB_KEYS_H__ +#endif // NRF_CRYPTO_HASH_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_shared.h new file mode 100644 index 0000000..708bf9b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hash_shared.h @@ -0,0 +1,120 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_HASH_SHARED_H__ +#define NRF_CRYPTO_HASH_SHARED_H__ + +#include "stdint.h" +#include "stddef.h" +#include "sdk_errors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CRYPTO_HASH_INIT_VALUE (0x4846526E) //!< Magic value to signal that the nrf_crypto_hash context structure is initialized. + +/**@brief Enumeration of supported modes of operation in nrf_crypto_hash + */ +typedef enum +{ + NRF_CRYPTO_HASH_MODE_SHA256, + NRF_CRYPTO_HASH_MODE_SHA512 +} nrf_crypto_hash_mode_t; + + +/**@internal @brief Type declaration to do hash initialization in nrf_crypto backend. + * + * This is an internal API. See @ref nrf_crypto_hash_init for documentation. + */ +typedef ret_code_t (*nrf_crypto_hash_init_fn_t)(void * const p_context); + + +/**@internal @brief Type declaration to do hash update in nrf_crypto backend. + * + * This is an internal API. See @ref nrf_crypto_hash_init for documentation. + */ +typedef ret_code_t (*nrf_crypto_hash_update_fn_t)(void * const p_context, + uint8_t const * p_data, + size_t size); + + +/**@internal @brief Type declaration to do hash finalize in nrf_crypto backend. + * + * This is an internal API. See @ref nrf_crypto_hash_finalize for documentation. + */ +typedef ret_code_t (*nrf_crypto_hash_finalize_fn_t)(void * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size); + + +/**@internal @brief Type declaration to for a nrf_crypto_hash info strucure + * + * @details This structure contains the calling interface and any meta data required + * to call the nrf_crypto_hash API functions. + */ +typedef struct +{ + nrf_crypto_hash_init_fn_t const init_fn; /**< Function pointer to call to initialize nrf_crypto_hash context in backend. */ + nrf_crypto_hash_update_fn_t const update_fn; /**< Function pointer to call to add data in the hash calculation. */ + nrf_crypto_hash_finalize_fn_t const finalize_fn; /**< Function pointer to call to finalize the hash calculation and return the result. */ + size_t const digest_size; /**< Size of the digest. */ + size_t const context_size; /**< Size of the context type. */ + nrf_crypto_hash_mode_t const hash_mode; /**< Mode of hash operation. */ +} nrf_crypto_hash_info_t; + + +/**@internal @brief Type declaration of internal representation of a hash context structure. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + uint32_t init_val; /**< Value that is set to NRF_CRYPTO_HASH_INIT_VALUE when context has been initialized. */ + nrf_crypto_hash_info_t const * p_info; /**< Pointer to an nrf_crypto_hash info structure. */ + +} nrf_crypto_hash_internal_context_t; + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_CRYPTO_HASH_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.c new file mode 100644 index 0000000..d395e05 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.c @@ -0,0 +1,225 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "stddef.h" +#include "nrf_assert.h" +#include "nrf_crypto_hmac.h" +#include "nrf_crypto_hkdf.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_shared.h" +#include "nrf_crypto_hmac_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC) + +static ret_code_t hkdf_expand(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t * const p_output_key, + size_t output_key_size, + uint8_t const * const p_ainfo, + size_t ainfo_size, + uint8_t * const p_temp, + uint8_t const * const p_prk, + size_t prk_size) +{ + size_t const hash_digest_size = p_info->digest_size; + uint32_t const n_iterations = (output_key_size + hash_digest_size - 1) / hash_digest_size; + ret_code_t err_code = NRF_SUCCESS; + size_t temp_size; + uint8_t n_current; + int write_offset; + + VERIFY_TRUE(n_iterations <= 255, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + + write_offset = 0; + for (uint32_t i = 0; i < n_iterations; i++) + { + n_current = i + 1; + + err_code = nrf_crypto_hmac_init(p_context, p_info, p_prk, prk_size); + VERIFY_SUCCESS(err_code); + + if (i != 0) + { + err_code = nrf_crypto_hmac_update(p_context, p_temp, hash_digest_size); + VERIFY_SUCCESS(err_code); + } + + if (p_ainfo != NULL) + { + err_code = nrf_crypto_hmac_update(p_context, p_ainfo, ainfo_size); + VERIFY_SUCCESS(err_code); + } + + err_code = nrf_crypto_hmac_update(p_context, &n_current, 1); + VERIFY_SUCCESS(err_code); + + temp_size = hash_digest_size; + err_code = nrf_crypto_hmac_finalize(p_context, p_temp, &temp_size); + VERIFY_SUCCESS(err_code); + + memcpy(p_output_key + write_offset, + p_temp, + (n_current != n_iterations) ? hash_digest_size : (output_key_size - write_offset)); + + write_offset += hash_digest_size; + } + + return err_code; +} + + +ret_code_t nrf_crypto_hkdf_calculate(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t * const p_output_key, + size_t * const p_output_key_size, + uint8_t const * const p_input_key, + size_t input_key_size, + uint8_t const * p_salt, + size_t salt_size, + uint8_t const * const p_ainfo, + size_t ainfo_size, + nrf_crypto_hkdf_mode_t mode) +{ + uint8_t prk[NRF_CRYPTO_HASH_SIZE_SHA512]; // Scaled for the largest supported hash size. + uint8_t temp[NRF_CRYPTO_HASH_SIZE_SHA512]; // Scaled for the largest supported hash size. + void * p_ctx = NULL; + void * p_allocated_context = NULL; + size_t prk_size = sizeof(prk); + size_t output_key_size = *p_output_key_size; + ret_code_t err_code; + + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(p_output_key != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + VERIFY_TRUE(*p_output_key_size > 0, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + VERIFY_TRUE(p_input_key != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(input_key_size > 0, NRF_ERROR_CRYPTO_INPUT_LENGTH); + + if (p_salt != NULL) + { + VERIFY_TRUE(salt_size > 0, NRF_ERROR_CRYPTO_INPUT_LENGTH); + } + + if (p_ainfo != NULL) + { + VERIFY_TRUE(ainfo_size > 0, NRF_ERROR_CRYPTO_INPUT_LENGTH); + } + + *p_output_key_size = 0; // Set output length to 0 as default value (in case of error). + + // Allocate context internally if p_context is NULL + if (p_context == NULL) + { + p_allocated_context = NRF_CRYPTO_ALLOC(p_info->context_size); + if (p_allocated_context == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + p_ctx = p_allocated_context; + } + else + { + p_ctx = p_context; + } + + if (mode == NRF_CRYPTO_HKDF_EXTRACT_AND_EXPAND) + { + if (p_salt == NULL) + { + // Use default salt defined in RFC 5869: String of zeros of hash length. + salt_size = p_info->digest_size; + ASSERT(sizeof(temp) >= salt_size); + memset(temp, 0, salt_size); + p_salt = temp; + } + + // Step 1: Extract + err_code = nrf_crypto_hmac_calculate(p_context, + p_info, + prk, + &prk_size, + p_salt, + salt_size, + p_input_key, + input_key_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_allocated_context); + + // Step 2: Expand + err_code = hkdf_expand(p_ctx, + p_info, + p_output_key, + output_key_size, + p_ainfo, + ainfo_size, + temp, + prk, + prk_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_allocated_context); + } + else // NRF_CRYPTO_HKDF_EXPAND_ONLY + { + err_code = hkdf_expand(p_ctx, + p_info, + p_output_key, + output_key_size, + p_ainfo, + ainfo_size, + temp, + p_input_key, + input_key_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_allocated_context); + } + + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + *p_output_key_size = output_key_size; + + return NRF_SUCCESS; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.h new file mode 100644 index 0000000..386b19c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hkdf.h @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_HKDF_H__ +#define NRF_CRYPTO_HKDF_H__ + +/** @file + * + * @defgroup nrf_crypto_hkdf HMAC based Key Derivation Function (HKDF) related functions + * @{ + * @ingroup nrf_crypto + * + * @brief Provides functions to generate HMAC based Key Derivation Function (HKDF). + * + * @details Provides functions to generate HMAC based Key Derivation Function (HKDF) using + * one of the supported hash algorithms. This layer is independent of backend crypto library. + * The HKDF module does not have a backend configuration, as it uses the nrf_crypto_hmac API, + * including the backend configured for HMAC in @ref sdk_config. + */ + + +#include +#include "sdk_common.h" +#include "nrf_crypto_hmac.h" +#include "nrf_crypto_hkdf.h" +#include "nrf_crypto_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Enumeration of HKDF modes. + */ +typedef enum +{ + NRF_CRYPTO_HKDF_EXTRACT_AND_EXPAND, //!< HKDF Extract and expand mode (normal). + NRF_CRYPTO_HKDF_EXPAND_ONLY //!< HKDF Expand only mode. +} nrf_crypto_hkdf_mode_t; + + +/** + * @brief Integrated HKDF calculation function + * + * @details This HKDF calculation function uses the nrf_crypto HMAC frontend directly. + * The backend is selected by configuring the HMAC backend in @ref sdk_config. + * + * @param[in,out] p_context Pointer to context structure. Context memory will be + * allocated internally if the context pointer is NULL. + * @param[in] p_info Pointer to static info structure. This defines the algorithm. + * This should be either @ref g_nrf_crypto_hmac_sha256_info or + * @ref g_nrf_crypto_hmac_sha512_info. + * @param[out] p_output_key Pointer to buffer to hold the output key material. + * @param[in,out] p_output_key_size Pointer to the length of the wanted output key material as input + * and actual length of the output material as output. Can be any + * number between 1 and the hash digest size multiplied by 255 + * (65280 for SHA-256 or 130560 for SHA-512). The p_output_key + * buffer must be large enough to hold this value. + * @param[in] p_input_key Pointer to buffer holding the input key material. + * @param[in] input_key_size Length of the input key material. + * @param[in] p_salt Pointer to buffer of nonsecret random salt data. Set to NULL in + * order to use the default salt defined by RFC 5869 (all zero + * array of hash digest size) or if salt is not used (expand only). + * @param[in] salt_size Length of the salt. Must be > 0 unless default salt is used, or + * in case mode is set to @ref NRF_CRYPTO_HKDF_EXPAND_ONLY. + * @param[in] p_ainfo Pointer to optional application specific information. + * (set to NULL and set ainfo_size to 0 if unused). + * @param[in] ainfo_size Length of the additional information. + * @param[in] mode Set to @ref NRF_CRYPTO_HKDF_EXTRACT_AND_EXPAND for normal mode. + * Alternatively, set to @ref NRF_CRYPTO_HKDF_EXPAND_ONLY to skip + * the extraction step. + * + * @retval NRF_SUCCESS Output key material hash was successfully calculated. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL If p_input_key was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_LENGTH If input_key_size or salt_size was invalid. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL If p_output_key_sizen was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH If *p_output_key_size is 0. + * @retval NRF_ERROR_CRYPTO_ALLOC_FAILED Unable to allocate memory for the context. + * @retval NRF_ERROR_CRYPTO_INTERNAL An error occurred in the crypto backend. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun the + * cryptographic routine at a later time. CC310 only. + */ +ret_code_t nrf_crypto_hkdf_calculate(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t * const p_output_key, + size_t * const p_output_key_size, + uint8_t const * const p_input_key, + size_t input_key_size, + uint8_t const * p_salt, + size_t salt_size, + uint8_t const * const p_ainfo, + size_t ainfo_size, + nrf_crypto_hkdf_mode_t mode); + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // #ifndef NRF_CRYPTO_HKDF_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.c new file mode 100644 index 0000000..e70d576 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.c @@ -0,0 +1,203 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "stddef.h" +#include "nrf_log.h" +#include "nrf_crypto_hmac.h" +#include "nrf_crypto_hmac_shared.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_init.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_shared.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC) + +// Magic word that is set when initializing the context and checked by functions that use it. +#define NRF_CRYPTO_HMAC_INIT_MAGIC_VALUE 0xBADEBA11 + + +static ret_code_t verify_context_valid(nrf_crypto_hmac_internal_context_t * const p_context) +{ + if (p_context == NULL) + { + return NRF_ERROR_CRYPTO_CONTEXT_NULL; + } + else if (p_context->init_value != NRF_CRYPTO_HMAC_INIT_MAGIC_VALUE) + { + return NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED; + } + else + { + return NRF_SUCCESS; + } +} + + +ret_code_t nrf_crypto_hmac_init(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t const * p_key, + size_t key_size) +{ + ret_code_t err_code; + nrf_crypto_hmac_internal_context_t * p_ctx = (nrf_crypto_hmac_internal_context_t *)p_context; + + VERIFY_TRUE(nrf_crypto_is_initialized(), NRF_ERROR_CRYPTO_NOT_INITIALIZED); + + // Validate input + VERIFY_TRUE(p_ctx != NULL, NRF_ERROR_CRYPTO_CONTEXT_NULL); + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(p_key != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(key_size > 0, NRF_ERROR_CRYPTO_INPUT_LENGTH); + + // Initialize generic part of the context + p_ctx->p_info = p_info; + + // Do backend specific initialization by calling the backend init function pointed + // to in the configuration struct in the context (nrf_crypto_hmac_config_t) + err_code = p_ctx->p_info->init_fn(p_context, p_key, key_size); + if (err_code == NRF_SUCCESS) + { + p_ctx->init_value = NRF_CRYPTO_HMAC_INIT_MAGIC_VALUE; + } + + return err_code; +} + + +ret_code_t nrf_crypto_hmac_update(nrf_crypto_hmac_context_t * const p_context, + uint8_t const * p_data, + size_t data_size) +{ + ret_code_t err_code; + + // The context header by definition has to be the first element of the context struct. + nrf_crypto_hmac_internal_context_t * p_ctx = (nrf_crypto_hmac_internal_context_t *)p_context; + + // Validate input + err_code = verify_context_valid(p_ctx); + VERIFY_SUCCESS(err_code); + VERIFY_TRUE(p_data != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(data_size > 0, NRF_ERROR_CRYPTO_INPUT_LENGTH); + + // Call backend specific update function (pointed to by config struct in context) + err_code = p_ctx->p_info->update_fn(p_context, p_data, data_size); + + return err_code; +} + + +ret_code_t nrf_crypto_hmac_finalize(nrf_crypto_hmac_context_t * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size) +{ + ret_code_t err_code; + + // The context header by definition has to be the first element of the context struct. + nrf_crypto_hmac_internal_context_t * p_ctx = (nrf_crypto_hmac_internal_context_t *)p_context; + + // Validate input + err_code = verify_context_valid(p_ctx); + VERIFY_SUCCESS(err_code); + VERIFY_TRUE(p_digest != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + VERIFY_TRUE(*p_digest_size >= p_ctx->p_info->digest_size, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + + // Call backend specific finish function (pointed to by config struct in context) + err_code = p_ctx->p_info->finalize_fn(p_context, p_digest, p_digest_size); + + return err_code; +} + + +ret_code_t nrf_crypto_hmac_calculate(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t * p_digest, + size_t * const p_digest_size, + uint8_t const * p_key, + size_t key_size, + uint8_t const * p_data, + size_t data_size) +{ + ret_code_t err_code; + nrf_crypto_hmac_context_t * p_ctx; + void * p_allocated_context = NULL; + + // Validate input. Only validate input parameters that are used locally, others are validated + // in the init, update and/or finalize functions. + VERIFY_TRUE(p_info != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + + // Allocate context if needed (not provided by the user). + if (p_context == NULL) + { + p_allocated_context = NRF_CRYPTO_ALLOC(p_info->context_size); + if (p_allocated_context == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + p_ctx = (nrf_crypto_hmac_context_t *)p_allocated_context; + } + else + { + p_ctx = (nrf_crypto_hmac_context_t *)p_context; + } + + // Perform integrated HMAC calculation by caling the frontend functions defined in this file + err_code = nrf_crypto_hmac_init(p_ctx, p_info, p_key, key_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_allocated_context); + + err_code = nrf_crypto_hmac_update(p_ctx, p_data, data_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_allocated_context); + + err_code = nrf_crypto_hmac_finalize(p_ctx, p_digest, p_digest_size); + NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_allocated_context); + + // Free context if allocated internally + if (p_allocated_context != NULL) + { + NRF_CRYPTO_FREE(p_allocated_context); + } + + return err_code; +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_HMAC) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.h new file mode 100644 index 0000000..9196cba --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac.h @@ -0,0 +1,226 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_HMAC_H__ +#define NRF_CRYPTO_HMAC_H__ + +/** @file + * + * @defgroup nrf_crypto_hmac Hash-based message authentication code (HMAC) related functions + * @{ + * @ingroup nrf_crypto + * + * @brief Provides functions to generate Hash-based message authentication code (HMAC). + * + * @details Provides functions to generate Hash-based message authentication code (HMAC) using + * one of the supported hash algorithms. This layer is independent of backend crypto library. + */ + +#include +#include "sdk_common.h" +#include "nrf_crypto_types.h" +#include "nrf_crypto_hmac_backend.h" +#include "nrf_crypto_hmac_shared.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Information structures used to select the specific algorithm (SHA-256) + * + * @details The information structure is used in a generic way but is populated by the backend, + * and contains backend specific data. */ +extern const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha256_info; + + +/** + * @brief Information structures used to select the specific algorithm (SHA-512) + * + * @details The information structure is used in a generic way but is populated by the backend, + * and contains backend specific data. + */ +extern const nrf_crypto_hmac_info_t g_nrf_crypto_hmac_sha512_info; + + +/** + * @brief Context type for HMAC. + * + * @note The size of this type is scaled for the largest HMAC backend context that is + * enabled in @ref sdk_config. + */ +typedef nrf_crypto_backend_hmac_context_t nrf_crypto_hmac_context_t; + +/** + * @brief Initialize context object for HMAC + * + * @details Use to initialize a context once it has been allocated. + * + * @note Must be called before @ref nrf_crypto_hmac_update. Can also be called after + * @ref nrf_crypto_hmac_finalize order to start a new HMAC calculation re-using an + * existing context object. + * + * @param[in,out] p_context Pointer to context structure. + * @param[in] p_info Pointer to static info structure. This defines the algorithm. + * This should be either @ref g_nrf_crypto_hmac_sha256_info or + * @ref g_nrf_crypto_hmac_sha512_info. + * @param[in] p_key HMAC key. + * @param[in] key_size Length of the HMAC key in bytes. + * + * @retval NRF_SUCCESS Data successfully consumed. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL If p_context has not been initialized. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL If p_info or p_key was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_LENGTH If key_size was invalid. + * @retval NRF_ERROR_CRYPTO_INPUT_LOCATION Input data not in RAM (CC310 only). + * @retval NRF_ERROR_CRYPTO_INTERNAL An error occurred in the crypto backend. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun + * the cryptographic routine at a later time. + * CC310 only. + */ +ret_code_t nrf_crypto_hmac_init(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t const * p_key, + size_t key_size); + + +/** + * @brief Feed data to HMAC algorithm. + * + * @note Must be called after @ref nrf_crypto_hmac_init and before @ref nrf_crypto_hmac_finalize. + * Can be called repeatedly to consume data as it arrives. + * + * @param[in,out] p_context Context pointer. + * @param[in] p_data Pointer to input data buffer. + * @param[in] data_size Length of input data. + * + * @retval NRF_SUCCESS Data successfully consumed. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL If p_context has not been initialized. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED If p_data was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL If p_data was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_LENGTH If size was invalid. + * @retval NRF_ERROR_CRYPTO_INPUT_LOCATION Input data not in RAM (CC310 only). + * @retval NRF_ERROR_CRYPTO_INTERNAL An error occurred in the crypto backend. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun + * the cryptographic routine at a later time. + * CC310 only. + */ +ret_code_t nrf_crypto_hmac_update(nrf_crypto_hmac_context_t * const p_context, + uint8_t const * p_data, + size_t data_size); + + +/** + * @brief Calculate HMAC + * + * @note @ref nrf_crypto_hmac_update must be called at least once before calling this. + * + * @param[in,out] p_context Context pointer. + * @param[out] p_digest Pointer to HMAC digest (result) buffer. Must be large enough to + * hold the digest (32 byte for SHA-256 and 64 byte for SHA-512). + * @param[in,out] p_digest_size Length of buffer as input. Length of digest as output. + * + * @retval NRF_SUCCESS HMAC hash was successfully calculated. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL If p_context was NULL. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED If p_context has not been initialized. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL If p_digest was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH If p_size is not enough to hold the digest. + * @retval NRF_ERROR_CRYPTO_INTERNAL An error occurred in the crypto backend. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun + * the cryptographic routine at a later time. + * CC310 only. + */ +ret_code_t nrf_crypto_hmac_finalize(nrf_crypto_hmac_context_t * const p_context, + uint8_t * p_digest, + size_t * const p_digest_size); + + +/** + * @brief Integrated HMAC wrapper function + * + * @note This is an integrated wrapper functions that can be used instead of calling other HMAC + * functions individually. + * + * @param[in,out] p_context Optional pointer to context structure. + * Context memory will be allocated internally if the pointer is NULL. + * @param[in] p_info Pointer to static info structure. This defines the algorithm. + * This should be either @ref g_nrf_crypto_hmac_sha256_info or + * @ref g_nrf_crypto_hmac_sha512_info. + * @param[out] p_digest Pointer to HMAC digest. + * Buffer must be large enough to hold the digest. + * @param[in,out] p_digest_size Length of digest (result) buffer as input. + * Length of digest as output. + * @param[in] p_key Pointer to HMAC key. + * @param[in] key_size Lenth of the HMAC key in bytes. + * @param[in] p_data Pointer to input data. + * @param[in] data_size Length of input data. + * + * @retval NRF_SUCCESS HMAC hash was successfully calculated. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL If p_key or p_data was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_LOCATION Input data not in RAM (CC310 only). + * @retval NRF_ERROR_CRYPTO_INPUT_LENGTH If key_size or data_size was invalid. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL If data_size was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH If data_size is not enough to hold the digest. + * @retval NRF_ERROR_CRYPTO_ALLOC_FAILED Unable to allocate memory for the context. + * @retval NRF_ERROR_CRYPTO_INTERNAL An error occurred in the crypto backend. + * @retval NRF_ERROR_CRYPTO_BUSY The function could not be called because the + * nrf_crypto backend was busy. Please rerun the + * cryptographic routine at a later time. CC310 only. + */ +ret_code_t nrf_crypto_hmac_calculate(nrf_crypto_hmac_context_t * const p_context, + nrf_crypto_hmac_info_t const * p_info, + uint8_t * p_digest, + size_t * const p_digest_size, + uint8_t const * p_key, + size_t key_size, + uint8_t const * p_data, + size_t data_size); + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // #ifndef NRF_CRYPTO_HMAC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_backend.h new file mode 100644 index 0000000..5ab14f5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_backend.h @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_HMAC_BACKEND_H__ +#define NRF_CRYPTO_HMAC_BACKEND_H__ + +/** @file + * + * @defgroup nrf_crypto_hmac_backend Meta backend. + * @{ + * @ingroup nrf_crypto_hmac + * + * @brief Includes all backends definitions. + * + * @details This file includes all backend definitions, and provide a dummy context in case no + * backend is enabled. This is needed so that any project including HMAC headers will still + * compile when HMAC is not used/enabled. + */ + +#include "sdk_common.h" +#include "nrf_crypto_hmac_shared.h" +#include "mbedtls_backend_hmac.h" +#include "cc310_backend_hmac.h" +#include "oberon_backend_hmac.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef NRF_CRYPTO_HMAC_SHA256_ENABLED +// /** @internal @brief Fallback context type for HMAC SHA256 in case no backend is selected. */ +typedef nrf_crypto_hmac_internal_context_t nrf_crypto_backend_hmac_sha256_context_t; +#endif // #ifndef NRF_CRYPTO_HMAC_SHA256_ENABLED + +#ifndef NRF_CRYPTO_HMAC_SHA512_ENABLED +/** @internal @brief Fallback context type for HMAC SHA512 in case no backend is selected. */ +typedef nrf_crypto_hmac_internal_context_t nrf_crypto_backend_hmac_sha512_context_t; +#endif // #ifndef NRF_CRYPTO_HMAC_SHA512_ENABLED + + +/** @internal @brief Union holding a HMAC context. */ +typedef union +{ + nrf_crypto_backend_hmac_sha256_context_t hmac_sha256_context; /**< @brief Holds context for HMAC SHA-256. */ + nrf_crypto_backend_hmac_sha512_context_t hmac_sha512_context; /**< @brief Holds context for HMAC SHA-512. */ +} nrf_crypto_backend_hmac_context_t; + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_HMAC_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_shared.h new file mode 100644 index 0000000..a0ee55a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_hmac_shared.h @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_HMAC_SHARED_H__ +#define NRF_CRYPTO_HMAC_SHARED_H__ + +/** @file + * + * @defgroup nrf_crypto_hmac_shared Types shared between all @ref nrf_crypto_hmac backends. + * @{ + * @ingroup nrf_crypto_hmac + * + * @brief Types shared between all @ref nrf_crypto_hmac backends. + * + * @details These types should not be used directly by the application. + */ + +#include +#include "sdk_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @internal @brief HMAC algorithm type. + */ +typedef enum { + NRF_CRYPTO_HMAC_SHA256_TYPE, //!< HMAC using hash algorithm SHA256 + NRF_CRYPTO_HMAC_SHA512_TYPE, //!< HMAC using hash algorithm SHA512 +} nrf_crypto_hmac_type_t; + + +/** + * @internal @brief Function pointer type for HMAC backend init function. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_hmac_init instead. + * + * @param[in,out] p_context Context pointer. + * @param[in] p_key HMAC key. + * @param[in] key_size Length of the HMAC key in bytes. +*/ +typedef ret_code_t (*nrf_crypto_hmac_init_fn_t)(void * const p_context, + uint8_t const * p_key, + size_t key_size); + + +/** + * @internal @brief Function pointer type for HMAC backend update function. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_hmac_update instead. + * + * @param[in,out] p_context Context pointer. + * @param[in] p_data Pointer to input data buffer. + * @param[in] size Length of input data. +*/ +typedef ret_code_t (*nrf_crypto_hmac_update_fn_t)(void * const p_context, + uint8_t const * p_data, + size_t size); + + +/** + * @internal @brief Function pointer type for HMAC backend finalize function. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_hmac_finalize instead. + * + * @param[in,out] p_context Context pointer. + * @param[out] p_digest HMAC digest (result) buffer. + * @param[in,out] p_size Length of buffer as input. Length of digest as output. +*/ +typedef ret_code_t (*nrf_crypto_hmac_finalize_fn_t)(void * const p_context, + uint8_t * const p_digest, + size_t * p_size); + + +/** + * @internal @brief structure holding the configuration of each particular algorithm. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + nrf_crypto_hmac_init_fn_t const init_fn; //!< Pointer to update function for specific backend. + nrf_crypto_hmac_update_fn_t const update_fn; //!< Pointer to update function for specific backend. + nrf_crypto_hmac_finalize_fn_t const finalize_fn; //!< Pointer to finalize function for specific backend. + size_t const digest_size; //!< Size of the digest of the HMAC operation. + size_t const context_size; //!< Size of the context type. + nrf_crypto_hmac_type_t const type; //!< HMAC algorithm type. +} nrf_crypto_hmac_info_t; + + +/** + * @internal @brief Common header for each HMAC context structures + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + uint32_t init_value; //!< Contains NRF_CRYPTO_HMAC_INIT_MAGIC_VALUE if it is correctly initialized. + nrf_crypto_hmac_info_t const * p_info; //!< Points to information object related to selected algorithm. +} nrf_crypto_hmac_internal_context_t; + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_HMAC_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.c new file mode 100644 index 0000000..7c1f115 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.c @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2016 - 2019, 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(NRF_CRYPTO) + +#include "nrf_crypto_init.h" +#include "nrf_section.h" + + +// Create a named section for crypto backend data +NRF_SECTION_DEF(crypto_data, const nrf_crypto_backend_info_t); + + +#define NRF_CRYPTO_BACKEND_SECTION_ITEM_GET(i) NRF_SECTION_ITEM_GET(crypto_data, nrf_crypto_backend_info_t, (i)) +#define NRF_CRYPTO_BACKEND_SECTION_ITEM_COUNT NRF_SECTION_ITEM_COUNT(crypto_data, nrf_crypto_backend_info_t) + +typedef enum +{ + UNINITIALIZED, + INITIALIZING, + INITIALIZED, +} nrf_crypto_state_t; + +static volatile nrf_crypto_state_t m_state = UNINITIALIZED; + + +ret_code_t nrf_crypto_init(void) +{ + ret_code_t ret_val; + size_t const num_backends = NRF_CRYPTO_BACKEND_SECTION_ITEM_COUNT; + + m_state = INITIALIZING; + + // Iterate through each backends to call the init function + for (size_t i = 0; i < num_backends; i++) + { + nrf_crypto_backend_info_t const * p_backend = NRF_CRYPTO_BACKEND_SECTION_ITEM_GET(i); + ret_val = p_backend->init_fn(); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + } + + // Set nrf_crypto to initialized + m_state = INITIALIZED; + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_uninit(void) +{ + ret_code_t ret_val; + size_t const num_backends = NRF_CRYPTO_BACKEND_SECTION_ITEM_COUNT; + + // Iterate through each backends to call the uninit function + for (size_t i = 0; i < num_backends; i++) + { + nrf_crypto_backend_info_t const * p_backend = NRF_CRYPTO_BACKEND_SECTION_ITEM_GET(i); + ret_val = p_backend->uninit_fn(); + if (ret_val != NRF_SUCCESS) + { + return ret_val; + } + } + + // Set nrf_crypto to uninitialized + m_state = UNINITIALIZED; + return NRF_SUCCESS; +} + + +bool nrf_crypto_is_initialized(void) +{ + return (m_state == INITIALIZED); +} + + +bool nrf_crypto_is_initializing(void) +{ + return ((m_state == INITIALIZED) || m_state == INITIALIZING); +} + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.h new file mode 100644 index 0000000..e6abcc2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_init.h @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_INIT_H__ +#define NRF_CRYPTO_INIT_H__ + +/** @file + * + * @defgroup nrf_crypto_initialization Initialization + * @{ + * @ingroup nrf_crypto + * + * @brief Initialization related functions for nrf_crypto . + * + * @details @ref lib_crypto is responsible for global initialization of the nrf_crypto + * frontend and backends that are enabled in @ref sdk_config. + */ + +#include +#include +#include "nrf_section.h" +#include "sdk_errors.h" +#include "nrf_crypto_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/**@internal @brief Macro for registering a nrf_crypto backend for initialization by using + * nrf_section. + * + * @details This macro places a variable in a section named "crypto_data", which + * is initialized by @ref nrf_crypto_init. + * + * @note This macro is used internally based on sdk_config.h configurations for nrf_crypto + */ +#define CRYPTO_BACKEND_REGISTER(crypto_var) NRF_SECTION_ITEM_REGISTER(crypto_data, crypto_var) + +/**@internal @brief Type definition of function pointer to initialize the nrf_crypto backend. + * + * This function type is used internally. See @nrf_crypto_init for documentation. + */ +typedef ret_code_t (*nrf_crypto_backend_init_fn_t)(void); + + +/**@internal @brief Type definition of function pointer to uninitialize the nrf_crypto backend. + * + * This function type is used internally. Please see @nrf_crypto_uninit for documentation. + */ +typedef ret_code_t (*nrf_crypto_backend_uninit_fn_t)(void); + + + +/**@internal @brief Type definition for structure holding the calling interface to + * init, uninit, enable, or disable an nrf_crypto_backend + * + * @note Some backends require no expressive init, uninit, enable, or disable. + * In this case, the backend will not use this structure type or only select + * to implement + */ +typedef struct +{ + nrf_crypto_backend_init_fn_t const init_fn; + nrf_crypto_backend_uninit_fn_t const uninit_fn; +} nrf_crypto_backend_info_t; + + +/**@brief Function for initializing nrf_crypto and all registered backends. + * + * @details Must always be called before any other @ref nrf_crypto function. + * + * @retval NRF_SUCCESS The initialization was successful. + * @retval NRF_ERROR_INTERNAL An internal error occured in the nrf_crypt backend init. + */ +ret_code_t nrf_crypto_init(void); + + +/**@brief Function for uninitializing nrf_crypto and all registered backends. + * + * @retval NRF_SUCCESS If unititialization was successful. + * @retval NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypt backend init. + */ +ret_code_t nrf_crypto_uninit(void); + + +/**@brief Function reporting if nrf_crypto has been initialized. + * + * @retval True If cryptographic library is initialized. + * @retval False If cryptographic library is not initialized. + */ +bool nrf_crypto_is_initialized(void); + + +/**@brief Function reporting if nrf_crypto is initialized or is in the process of being initialized. + * + * @retval True If cryptographic library is initializing or already initialized. + * @retval False If cryptographic library is not initialized. + */ +bool nrf_crypto_is_initializing(void); + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_INIT_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_mem.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_mem.h new file mode 100644 index 0000000..ceca486 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_mem.h @@ -0,0 +1,185 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_MEM_H__ +#define NRF_CRYPTO_MEM_H__ + +/** @file + * + * @defgroup nrf_crypto_mem Dynamic memory management module + * @{ + * @ingroup nrf_crypto + * + * @brief Module to manage dynamically allocated memory used by nrf_crypto APIs. + * + * @ref NRF_CRYPTO_ALLOCATOR definition is used to configure this module. + */ + +#include +#include "sdk_common.h" +#include "sdk_config.h" +#include "nrf_crypto_types.h" +#include "sdk_alloca.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef __SDK_DOXYGEN__ + + +#define NRF_CRYPTO_ALLOCATOR_DEFAULT 0 /**< @internal @brief Value for NRF_CRYPTO_ALLOCATOR to select default memory allocation. */ +#define NRF_CRYPTO_ALLOCATOR_USER 1 /**< @internal @brief Value for NRF_CRYPTO_ALLOCATOR to select user defined memory allocation. */ +#define NRF_CRYPTO_ALLOCATOR_ALLOCA 2 /**< @internal @brief Value for NRF_CRYPTO_ALLOCATOR to select stack based memory allocation. */ +#define NRF_CRYPTO_ALLOCATOR_MALLOC 3 /**< @internal @brief Value for NRF_CRYPTO_ALLOCATOR to select stdlib's dynamic memory allocation. */ +#define NRF_CRYPTO_ALLOCATOR_NRF_MALLOC 4 /**< @internal @brief Value for NRF_CRYPTO_ALLOCATOR to select mem_manager for memory allocation. */ + + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR NRF_CRYPTO_ALLOCATOR_DEFAULT +#endif + + +#if NRF_CRYPTO_ALLOCATOR == NRF_CRYPTO_ALLOCATOR_DEFAULT +#undef NRF_CRYPTO_ALLOCATOR +#if SDK_ALLOCA_DEFINED && !NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_MBEDTLS) +#define NRF_CRYPTO_ALLOCATOR NRF_CRYPTO_ALLOCATOR_ALLOCA +#else +#define NRF_CRYPTO_ALLOCATOR NRF_CRYPTO_ALLOCATOR_NRF_MALLOC +#endif +#endif + + +#if NRF_CRYPTO_ALLOCATOR == NRF_CRYPTO_ALLOCATOR_USER + +#include "nrf_crypto_allocator.h" +#ifndef NRF_CRYPTO_ALLOC +#error "User defined allocator for nrf_crypto does not define NRF_CRYPTO_ALLOC" +#endif +#ifndef NRF_CRYPTO_FREE +#error "User defined allocator for nrf_crypto does not define NRF_CRYPTO_FREE" +#endif +#ifndef NRF_CRYPTO_ALLOC_ON_STACK +#error "User defined allocator for nrf_crypto does not define NRF_CRYPTO_ALLOC_ON_STACK" +#endif + +#elif NRF_CRYPTO_ALLOCATOR == NRF_CRYPTO_ALLOCATOR_ALLOCA + +#if !SDK_ALLOCA_DEFINED +#warning "Stack based allocation is selected, but alloca() is not supported on this platform" +#endif +#define NRF_CRYPTO_ALLOC(size) (alloca((size_t)(size))) +#define NRF_CRYPTO_FREE(p_buffer) // Empty +#define NRF_CRYPTO_ALLOC_ON_STACK 1 + +#elif NRF_CRYPTO_ALLOCATOR == NRF_CRYPTO_ALLOCATOR_MALLOC + +#include "stdlib.h" +#define NRF_CRYPTO_ALLOC(size) (malloc((size_t)(size))) +#define NRF_CRYPTO_FREE(p_buffer) (free((void *)(p_buffer))) +#define NRF_CRYPTO_ALLOC_ON_STACK 0 + +#elif NRF_CRYPTO_ALLOCATOR == NRF_CRYPTO_ALLOCATOR_NRF_MALLOC + +#include "mem_manager.h" +#define NRF_CRYPTO_ALLOC(size) (nrf_malloc((uint32_t)(size))) +#define NRF_CRYPTO_FREE(p_buffer) (nrf_free((void *)(p_buffer))) +#define NRF_CRYPTO_ALLOC_ON_STACK 0 + +#else + +#error "Invalid NRF_CRYPTO_ALLOCATOR configuration value" + +#endif + + +#else // __SDK_DOXYGEN__ + + +/** @brief Defines memory allocation function for nrf_crypto. + * + * This macro is used internally by nrf_crypto library to allocate temporary memory. It is not + * intended to be used outside nrf_crypto library. How memory is actually allocated is configured + * by @ref NRF_CRYPTO_ALLOCATOR definition. + * + * If user macros are selected by @ref NRF_CRYPTO_ALLOCATOR then this macro have to be defined by + * the user in "nrf_crypto_allocator.h" file. The file will be included into "nrf_crypto_mem.h". + * + * If @ref NRF_CRYPTO_ALLOC_ON_STACK is 1 then this function will allocate data on stack, + * so make sure that returned pointer is not used outside the caller function. + * + * @param size Number of bytes to allocate. + * @returns Pointer to newly allocated memory or NULL on error. + */ +#define NRF_CRYPTO_ALLOC(size) + +/** @brief Defines memory deallocation function for nrf_crypto. + * + * This macro is used internally by nrf_crypto library to deallocate temporary memory. It is not + * intended to be used outside nrf_crypto library. + * + * If user macros are selected by @ref NRF_CRYPTO_ALLOCATOR then this macro have to be defined by + * the user in "nrf_crypto_allocator.h" file. The file will be included into "nrf_crypto_mem.h". + * + * @param p_buffer Pointer to memory buffer for deallocation. + */ +#define NRF_CRYPTO_FREE(p_buffer) + +/** @brief Contains 1 if memory allocated by @ref NRF_CRYPTO_ALLOC is on stack or 0 otherwise. + * + * This definition is used internally by nrf_crypto library. It is not intended to be used outside + * nrf_crypto library. + * + * If user macros are selected by @ref NRF_CRYPTO_ALLOCATOR then this macro have to be defined by + * the user in "nrf_crypto_allocator.h" file. The file will be included into "nrf_crypto_mem.h". + */ +#define NRF_CRYPTO_ALLOC_ON_STACK + + +#endif // __SDK_DOXYGEN__ + +#ifdef __cplusplus +} +#endif + +/**@} */ + + #endif // NRF_CRYPTO_MEM_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.c new file mode 100644 index 0000000..2fbb49d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.c @@ -0,0 +1,430 @@ +/** + * Copyright (c) 2018 - 2019, 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(NRF_CRYPTO) + +#include "nrf_crypto_init.h" +#include "nrf_log.h" +#include "nrf_crypto_mem.h" +#include "nrf_crypto_rng.h" +#include "nrf_crypto_rng_shared.h" +#include "nrf_crypto_rng_backend.h" +#include "nrf_stack_info.h" + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + +#define NRF_CRYPTO_RNG_MODULE_INIT_MAGIC_VALUE (0x4be57265) + +static nrf_crypto_backend_rng_context_t * mp_allocated_context = NULL; +static nrf_crypto_backend_rng_context_t * mp_context = NULL; +static uint32_t m_initialized = 0; + + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) +static nrf_crypto_backend_rng_context_t m_context; +static nrf_crypto_rng_temp_buffer_t m_temp_buffer; +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) + + +static bool is_vector_greater_or_equal(uint8_t const * const p_vector, + uint8_t const * const p_min, + size_t size) +{ + for (size_t i = 0; i < size; i++) + { + if (p_vector[i] != p_min[i]) + { + if (p_vector[i] > p_min[i]) + { + return true; + } + else + { + return false; + } + } + } + + return true; +} + + +// Return true if value p_vector is between (including) p_min and p_max. +static bool is_vector_in_range(uint8_t const * const p_vector, + uint8_t const * const p_min, + uint8_t const * const p_max, + size_t size) +{ + if (!is_vector_greater_or_equal(p_vector, p_min, size)) + { + return false; + } + + if (!is_vector_greater_or_equal(p_max, p_vector, size)) + { + return false; + } + + return true; +} + + +static uint32_t count_leading_zeros(uint8_t const * const p_vector, size_t size) +{ + uint32_t leading_zeros = 0; + uint32_t nonzero_byte = 0xFF; + + // Find leading all-zero elements. + for (uint32_t i = 0; i < size; i++) + { + if (p_vector[i] == 0) + { + leading_zeros += 8; + } + else + { + nonzero_byte = p_vector[i]; + break; + } + } + + // Find leading zeros in non-zero element. + for (uint32_t i = 0; i < 8; i++) + { + nonzero_byte <<= 1; + + if ((nonzero_byte & ~0xff) > 0) + { + break; + } + + leading_zeros ++; + } + + return leading_zeros; +} + + +static ret_code_t generate(uint8_t * const p_target, size_t size, bool use_mutex) +{ + ret_code_t ret_code; + + VERIFY_TRUE(p_target != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + VERIFY_TRUE(size > 0, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + + VERIFY_TRUE(m_initialized == NRF_CRYPTO_RNG_MODULE_INIT_MAGIC_VALUE, + NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED); + + ret_code = nrf_crypto_rng_backend_vector_generate(mp_context, p_target, size, use_mutex); + + // Reseed internally and try again if reseed is required by the backend. + // (CC310 only as mbed TLS handles reseeding internally.) + if (ret_code == NRF_ERROR_CRYPTO_RNG_RESEED_REQUIRED) + { + ret_code = nrf_crypto_rng_reseed(NULL, NULL, 0); + + if (ret_code != NRF_SUCCESS) + { + return ret_code; + } + + ret_code = nrf_crypto_rng_backend_vector_generate(mp_context, p_target, size, use_mutex); + } + + return ret_code; +} + + +static ret_code_t generate_in_range(uint8_t * const p_target, + uint8_t const * const p_min, + uint8_t const * const p_max, + size_t size, + bool use_mutex) +{ + uint32_t const max_leading_zeros = count_leading_zeros(p_max, size); + ret_code_t ret_code; + + VERIFY_TRUE(p_target != NULL, NRF_ERROR_CRYPTO_OUTPUT_NULL); + VERIFY_TRUE(size > 0, NRF_ERROR_CRYPTO_OUTPUT_LENGTH); + VERIFY_TRUE(p_min != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(p_max != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + VERIFY_TRUE(is_vector_greater_or_equal(p_max, p_min, size), NRF_ERROR_CRYPTO_INVALID_PARAM); + + do + { + ret_code = nrf_crypto_rng_backend_vector_generate(mp_context, p_target, size, use_mutex); + + if (ret_code != NRF_SUCCESS) + { + return ret_code; + } + + // Mask leading zeros in generated vector instead of always discarding a too large vectors. + memset(p_target, 0, max_leading_zeros / 8); + if ((max_leading_zeros & 0x07) > 0) + { + p_target[max_leading_zeros / 8] = + p_target[max_leading_zeros / 8] & (0xff >> (max_leading_zeros & 0x07)); + } + } while (!is_vector_in_range(p_target, p_min, p_max, size)); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_crypto_rng_vector_generate(uint8_t * const p_target, size_t size) +{ + ret_code_t ret_code; + + ret_code = generate(p_target, size, true); + + return ret_code; +} + + +ret_code_t nrf_crypto_rng_vector_generate_in_range(uint8_t * const p_target, + uint8_t const * const p_min, + uint8_t const * const p_max, + size_t size) +{ + ret_code_t ret_code; + + ret_code = generate_in_range(p_target, p_min, p_max, size, true); + + return ret_code; +} + + +ret_code_t nrf_crypto_rng_vector_generate_no_mutex(uint8_t * const p_target, size_t size) +{ + ret_code_t ret_code; + + ret_code = generate(p_target, size, false); + + return ret_code; +} + + +ret_code_t nrf_crypto_rng_vector_generate_in_range_no_mutex(uint8_t * const p_target, + uint8_t const * const p_min, + uint8_t const * const p_max, + size_t size) +{ + ret_code_t ret_code; + + ret_code = generate_in_range(p_target, p_min, p_max, size, false); + + return ret_code; +} + + +ret_code_t nrf_crypto_rng_init(nrf_crypto_rng_context_t * p_context, + nrf_crypto_rng_temp_buffer_t * p_temp_buffer) +{ + ret_code_t ret_code; + nrf_crypto_rng_temp_buffer_t * p_allocated_temp_buffer = NULL; + + // Check if the stack has overflowed. This can typically happen if the application has put the + // ~6 kB large temp buffer for CC310 on the stack. + if (nrf_stack_info_overflowed()) + { + NRF_LOG_ERROR("Stack overflow detected."); + return NRF_ERROR_CRYPTO_STACK_OVERFLOW; + } + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_AUTO_INIT) + VERIFY_TRUE(nrf_crypto_is_initializing(), NRF_ERROR_CRYPTO_NOT_INITIALIZED); +#else + VERIFY_TRUE(nrf_crypto_is_initialized(), NRF_ERROR_CRYPTO_NOT_INITIALIZED); +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_AUTO_INIT) + + // Do nothing if RNG module is already initialized. + if (mp_context != 0 && (m_initialized == NRF_CRYPTO_RNG_MODULE_INIT_MAGIC_VALUE)) + { + return NRF_SUCCESS; + } + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) + + VERIFY_TRUE(p_context == NULL, NRF_ERROR_CRYPTO_INVALID_PARAM); + VERIFY_TRUE(p_temp_buffer == NULL, NRF_ERROR_CRYPTO_INVALID_PARAM); + + mp_context = &m_context; + p_temp_buffer = &m_temp_buffer; + +#else // !NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) + + if (p_context == NULL) + { + if (NRF_CRYPTO_ALLOC_ON_STACK) + { + NRF_LOG_ERROR("RNG context cannot be allocated on the stack."); + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + else + { + mp_allocated_context = NRF_CRYPTO_ALLOC(sizeof(nrf_crypto_backend_rng_context_t)); + if (mp_allocated_context == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + mp_context = mp_allocated_context; + } + } + else + { + mp_context = p_context; + } + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) + + // Allocate temporary buffer internally if not statically allocated or provided by the user. + if (p_temp_buffer == NULL) + { + p_allocated_temp_buffer = NRF_CRYPTO_ALLOC(sizeof(nrf_crypto_rng_temp_buffer_t)); + + if (p_allocated_temp_buffer == NULL) + { + if (mp_allocated_context != NULL) + { + NRF_CRYPTO_FREE(mp_allocated_context); + } + + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + + p_temp_buffer = p_allocated_temp_buffer; + } + + ret_code = nrf_crypto_rng_backend_init(mp_context, p_temp_buffer); + if (ret_code == NRF_SUCCESS) + { + m_initialized = NRF_CRYPTO_RNG_MODULE_INIT_MAGIC_VALUE; + mp_context->header.init_value = NRF_CRYPTO_RNG_CONTEXT_INIT_MAGIC_VALUE; + } + + if (p_allocated_temp_buffer != NULL) + { + NRF_CRYPTO_FREE(p_allocated_temp_buffer); + } + + return ret_code; +} + + +ret_code_t nrf_crypto_rng_uninit(void) +{ + ret_code_t ret_code; + + VERIFY_TRUE(m_initialized == NRF_CRYPTO_RNG_MODULE_INIT_MAGIC_VALUE, + NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED); + + VERIFY_TRUE(mp_context->header.init_value == NRF_CRYPTO_RNG_CONTEXT_INIT_MAGIC_VALUE, + NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED); + + mp_context->header.init_value = 0; + m_initialized = 0; + + ret_code = nrf_crypto_rng_backend_uninit(mp_context); + + if (mp_allocated_context != NULL) + { + NRF_CRYPTO_FREE(mp_allocated_context); + } + + return ret_code; +} + + +ret_code_t nrf_crypto_rng_reseed(nrf_crypto_rng_temp_buffer_t * p_temp_buffer, + uint8_t * p_input_data, + size_t size) +{ + ret_code_t ret_code; + void * p_allocated_temp_buffer = NULL; + + // Check if the stack has overflowed. This can typically happen if the application has put the + // ~6 kB large temp buffer for CC310 on the stack. + if (nrf_stack_info_overflowed()) + { + NRF_LOG_ERROR("Stack overflow detected."); + return NRF_ERROR_CRYPTO_STACK_OVERFLOW; + } + + if (size > 0) + { + VERIFY_TRUE(p_input_data != NULL, NRF_ERROR_CRYPTO_INPUT_NULL); + } + + VERIFY_TRUE(m_initialized == NRF_CRYPTO_RNG_MODULE_INIT_MAGIC_VALUE, + NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED); + +#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) + + VERIFY_TRUE(p_temp_buffer == NULL, NRF_ERROR_CRYPTO_INVALID_PARAM); + p_temp_buffer = &m_temp_buffer; + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS) + + // Allocate temporary buffer internally if not statically allocated or provided by the user. + if (p_temp_buffer == NULL) + { + p_allocated_temp_buffer = NRF_CRYPTO_ALLOC(sizeof(nrf_crypto_rng_temp_buffer_t)); + if (p_allocated_temp_buffer == NULL) + { + return NRF_ERROR_CRYPTO_ALLOC_FAILED; + } + p_temp_buffer = (nrf_crypto_rng_temp_buffer_t *)p_allocated_temp_buffer; + } + + ret_code = nrf_crypto_rng_backend_reseed(mp_context, p_temp_buffer, p_input_data, size); + + if (p_allocated_temp_buffer != NULL) + { + NRF_CRYPTO_FREE(p_allocated_temp_buffer); + } + + return ret_code; +} + + +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) +#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.h new file mode 100644 index 0000000..336ed07 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng.h @@ -0,0 +1,285 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_RNG_H__ +#define NRF_CRYPTO_RNG_H__ + +/** @file + * + * @defgroup nrf_crypto_rng RNG related functions + * @{ + * @ingroup nrf_crypto + * + * @brief RNG related functions + * + * @details There are two available RNG backends: + * - ARM CryptoCell CC310 (default for devices with CC310). + * - nRF HW RNG peripheral. + * * CTR-DRBG mode - nRF HW RNG used for seeding mbed TLS CTR-DRBG (default for + * devices without CC310). + * * Raw mode - all data is generated by the nRF HW RNG. + * + * The CC310 backend meets the standards NIST 800-90B3 and AIS-31 (Class “P2 Highâ€), and + * should be preferred in most cases on devices that includes the CC310 core. Devices that + * do not include CC310 should normally use the nRF HW RNG with mbed TLS CTR-DRBG. The + * mbed TLS CTR-DRBG code is standardized by NIST (SP 800-90A Rev. 1). + */ + +#include "sdk_common.h" +#include "nrf_crypto_error.h" +#include "nrf_crypto_rng_shared.h" +#include "nrf_crypto_rng_backend.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Context type for RNG. + * + * @note The actual type depend on the backend in use. + */ +typedef nrf_crypto_backend_rng_context_t nrf_crypto_rng_context_t; + + +/** + * @brief Temporary work buffer type for RNG. + * + * @details Only needed during initializing. Can be freed when @ref nrf_crypto_rng_init has + * returned. Not needed if @ref NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED is enabled + * in @ref sdk_config. + * + * @note The actual type depend on the backend in use. + */ +typedef nrf_crypto_backend_rng_temp_buffer_t nrf_crypto_rng_temp_buffer_t; + + +/**@brief Initialize the random number generator. + * + * @details This function has no effect when @ref NRF_CRYPTO_RNG_AUTO_INIT_ENABLED is enabled. + * + * @warning The p_temp_buffer is 6112 bytes when using the CC310 backend. Ensure that stack size + * is sufficient if allocated on stack. Applications that use nRF HW RNG as backend or are + * not RAM constrained can use internal static allocation of context and temporary buffers + * (@ref NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED). + * + * @note The context object can be reused without the need for a full reinitialization of the + * backend in case of for example wakeup from system OFF, provided that the context is + * located in a memory block that is retained. This only apply to the CC310 backend, and when + * the context is allocated manually (NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED disabled). + * + * @param[in] p_context Pointer to context memory. The context will be managed + * internally, and the pointer is not used for subsequent calls to + * the nrf_crypto_rng API. The context memory is needed until + * @ref nrf_crypto_rng_uninit is called, so it should normally not + * be on the stack. Use NULL if + * @ref NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED is enabled + * in @ref sdk_config (recommended for most applications). + * + * @param[in,out] p_temp_buffer Temporary buffer needed during initialization of the backend. It + * is not used after the return of this function, and can be freed + * at that point. Buffer is allocated internally if the pointer is + * NULL, using the allocated defined by @ref NRF_CRYPTO_ALLOCATOR + * in @c sdk_config.h. Use NULL if + * @ref NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED is enabled + * in @ref sdk_config (recommended for most applications). + * + * @retval NRF_SUCCESS If random number generator was initialized + * successfully. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to this + * function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NULL p_context was NULL. + * @retval NRF_ERROR_CRYPTO_INTERNAL If an internal error occurred in the nrf_crypto + * backend. + * @retval NRF_ERROR_CRYPTO_ALLOC_FAILED Unable to allocate memory for the context or work + * buffer. + * @retval NRF_ERROR_CRYPTO_STACK_OVERFLOW Stack overflow detected. Typically caused by + * allocating an instance of + * @ref nrf_crypto_rng_temp_buffer_t + * on the stack when using CC310 backend. + * @retval NRF_ERROR_CRYPTO_BUSY RNG is busy. Rerun at a later time. + */ +ret_code_t nrf_crypto_rng_init(nrf_crypto_rng_context_t * p_context, + nrf_crypto_rng_temp_buffer_t * p_temp_buffer); + + +/**@brief Uninitialize the random number generator. + * + * @retval NRF_SUCCESS If RNG was uninitialized successfully. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED RNG has not been initialized. + * @retval NRF_ERROR_CRYPTO_INTERNAL If an internal error occurred in the + * nrf_crypto backend. + * @retval NRF_ERROR_CRYPTO_BUSY RNG is busy. Rerun at a later time. + */ +ret_code_t nrf_crypto_rng_uninit(void); + + +/**@brief Generate random data of given size. + * + * @details @ref nrf_crypto_rng_init must be called prior to this function unless + * @ref NRF_CRYPTO_RNG_AUTO_INIT_ENABLED is enabled in @ref sdk_config. + * + * @param[in,out] p_target Buffer to hold the random generated data. + * This buffer must be at least as large as the size parameter. + * @param[in] size Length (in bytes) to generate random data for. + * + * @retval NRF_SUCCESS Data was generated successfully. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED @ref nrf_crypto_rng_init was not called + * prior to this function and + * @ref NRF_CRYPTO_RNG_AUTO_INIT_ENABLED is + * disabled. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL p_target was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH Size was 0 or larger than the backend + * supports. + * @retval NRF_ERROR_CRYPTO_INTERNAL If an internal error occurred in the + * backend. + * @retval NRF_ERROR_CRYPTO_STACK_OVERFLOW Stack overflow detected in + * @ref nrf_crypto_rng_init when using auto + * initialization. Typically caused by + * allocating an instance of + * @ref nrf_crypto_rng_temp_buffer_t + * on the stack when using CC310 backend. + * @retval NRF_ERROR_CRYPTO_BUSY RNG is busy. Rerun at a later time. + */ +ret_code_t nrf_crypto_rng_vector_generate(uint8_t * const p_target, size_t size); + + +/**@brief Generate a vector of constrained random data of given size, between the specified min + * and max values. + * + * @details @ref nrf_crypto_rng_init must be called prior to this function unless + * @ref NRF_CRYPTO_RNG_AUTO_INIT_ENABLED is enabled in @ref sdk_config. + * + * All vectors are in big-endian format, with the most significant byte as the first + * element / lowest address. + * + * @note This function may execute for a long time if the window between p_min and p_max is small. + * + * @param[in,out] p_target Buffer to hold the random generated data. + * This buffer must be at least as large as the size parameter. + * @param[in] p_min Byte array defining the lower limit of the random vector. + * @param[in] p_max Byte array defining the upper limit of the random vector. + * @param[in] size Length (in bytes) to generate random data for. Note that all three + * buffers (p_target, p_min and p_max) must be of this size. + * + * @retval NRF_SUCCESS Data was generated successfully. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED @ref nrf_crypto_rng_init was not called + * prior to this function and + * @ref NRF_CRYPTO_RNG_AUTO_INIT_ENABLED is + * disabled. + * @retval NRF_ERROR_CRYPTO_OUTPUT_NULL p_target was NULL. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL p_min or p_max was NULL. + * @retval NRF_ERROR_CRYPTO_OUTPUT_LENGTH Size was 0 or larger than the backend + * supports. + * @retval NRF_ERROR_CRYPTO_INTERNAL If an internal error occurred in the + * backend. + * @retval NRF_ERROR_CRYPTO_STACK_OVERFLOW Stack overflow detected in + * @ref nrf_crypto_rng_init when using auto + * initialization. Typically caused by + * allocating an instance of + * @ref nrf_crypto_rng_temp_buffer_t + * on the stack when using CC310 backend. + * @retval NRF_ERROR_CRYPTO_BUSY RNG is busy. Rerun at a later time. + */ +ret_code_t nrf_crypto_rng_vector_generate_in_range(uint8_t * const p_target, + uint8_t const * const p_min, + uint8_t const * const p_max, + size_t size); + + +/** + * @brief This function is used for reseeding the RNG with additional entropy. + * + * @details The backends will reseed automatically when required. This function can be used to + * reseed at specific times and to provide additional data that is used to add personalized + * randomness. + * + * @note Reseeding is not supported if using the nRF HW RNG backend without mbed TLS CTR-DRBG + * (NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED disabled in sdk_config.h). + * + * @warning The p_temp_buffer is 6112 bytes when the CC310 backend is used. Ensure that stack size + * is sufficient if allocated on stack. + * + * @param[in,out] p_temp_buffer Temporary buffer needed during reseeding. It + * is not used after the return of this function, and can be freed + * at that point. Buffer is allocated internally if the pointer is + * NULL, using the allocated defined by @ref NRF_CRYPTO_ALLOCATOR + * in @c sdk_config.h. Use NULL if + * @ref NRF_CRYPTO_RNG_STATIC_MEMORY_BUFFERS_ENABLED is enabled + * in @ref sdk_config (recommended for most applications). + * @param[in] p_input_data Optional input data used to increase the entropy. + * @param[in] size Length of input data. Must be 0, 4, 8 or 12 for CC310. + * + * @retval NRF_SUCCESS Data was generated successfully. + * @retval NRF_ERROR_CRYPTO_NOT_INITIALIZED @ref nrf_crypto_init was not called prior to + * this function. + * @retval NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED @ref nrf_crypto_rng_init was not called + * prior to this function and + * @ref NRF_CRYPTO_RNG_AUTO_INIT_ENABLED is + * disabled. + * @retval NRF_ERROR_CRYPTO_INPUT_NULL p_temp_buffer was NULL or p_input_data was + * NULL and size > 0 . + * @retval NRF_ERROR_CRYPTO_INPUT_LENGTH Invalid input data size. + * @retval NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE Reseeding not supported by backend. + * @retval NRF_ERROR_CRYPTO_INTERNAL If an internal error occurred in the + * backend. + * @retval NRF_ERROR_CRYPTO_STACK_OVERFLOW Stack overflow detected. Typically caused by + * allocating an instance of + * @ref nrf_crypto_rng_temp_buffer_t + * on the stack when using CC310 backend. + * @retval NRF_ERROR_CRYPTO_BUSY RNG is busy. Rerun at a later time. + */ +ret_code_t nrf_crypto_rng_reseed(nrf_crypto_rng_temp_buffer_t * p_temp_buffer, + uint8_t * p_input_data, + size_t size); + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_RNG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_backend.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_backend.h new file mode 100644 index 0000000..90e3cc1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_backend.h @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_RNG_BACKEND_H__ +#define NRF_CRYPTO_RNG_BACKEND_H__ + +/** @file + * + * @defgroup nrf_crypto_rng_backend Meta RNG backend. + * @{ + * @ingroup nrf_crypto_rng + * + * @brief Includes all backends definitions. + * + * @details This file includes all backend definitions. + */ + +#include "cc310_backend_rng.h" +#include "nrf_hw_backend_rng.h" +#include "nrf_hw_backend_rng_mbedtls.h" +#include "optiga_backend_rng.h" + +#if !NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + +#ifdef __cplusplus +extern "C" { +#endif + +/** @internal @brief Fallback dummy context type in case no backend is selected */ +typedef nrf_crypto_rng_internal_context_t nrf_crypto_backend_rng_context_t; + +/** @internal @brief Fallback dummy temp buffer type in case no backend is selected . */ +typedef struct +{ + uint32_t reserved; +} nrf_crypto_backend_rng_temp_buffer_t; + +#ifdef __cplusplus +} +#endif + +#endif // !NRF_MODULE_ENABLED(NRF_CRYPTO_RNG) + +/**@} */ + +#endif // NRF_CRYPTO_RNG_BACKEND_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_shared.h new file mode 100644 index 0000000..56f01ee --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_rng_shared.h @@ -0,0 +1,142 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_RNG_SHARED_H__ +#define NRF_CRYPTO_RNG_SHARED_H__ + +/** @file + * + * @defgroup nrf_crypto_rng_shared Types shared between all @ref nrf_crypto_rng backends. + * @{ + * @ingroup nrf_crypto_rng + * + * @brief Types shared between all @ref nrf_crypto_rng backends. + * + * @details These types should not be used directly by the application. + */ + +#include "sdk_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define NRF_CRYPTO_RNG_CONTEXT_INIT_MAGIC_VALUE (0x4d616961) + + +/** + * @internal @brief Common header for each RNG backend context. + * + * @details This is an internal type that should not be used directly. + */ +typedef struct +{ + uint32_t init_value; //!< Contains NRF_CRYPTO_RNG_CONTEXT_INIT_MAGIC_VALUE if initialized. +} nrf_crypto_rng_internal_context_t; + + +/** + * @internal @brief Function for initializing the RNG backend. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_rng_init instead. + * + * @param[in,out] p_context Pointer to context structure. + * @param[in,out] p_temp_buffer Temporary buffer needed during initialization of the backend. + * @param[in] use_mutex Use mutex to prevent simultanious usage of backend resources. + */ +ret_code_t nrf_crypto_rng_backend_init(void * const p_context, + void * const p_temp_buffer); + + +/** + * @internal @brief Function for uninitializing the RNG backend. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_rng_uninit instead. + * + * @param[in,out] p_context Pointer to context structure. + * @param[in] use_mutex Use mutex to prevent simultanious usage of backend resources. + */ +ret_code_t nrf_crypto_rng_backend_uninit(void * const p_context); + + +/** + * @internal @brief Function for retrieving a random vector from the RNG backend. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_rng_vector_generate instead. + * + * @param[in,out] p_context Pointer to context structure. + * @param[out] p_target Buffer to hold the random generated data. + * @param[in] size Length (in bytes) to generate random data for. + * @param[in] use_mutex Use mutex to prevent simultanious usage of backend resources. + */ +ret_code_t nrf_crypto_rng_backend_vector_generate(void * const p_context, + uint8_t * const p_target, + size_t size, + bool use_mutex); + + +/** + * @internal @brief This function is used for reseeding the RNG with additional entropy. + * + * @note The backend function should never be called directly. + * Use @ref nrf_crypto_rng_reseed instead. + * + * @param[in,out] p_context Pointer to context structure. + * @param[in,out] p_temp_buffer Temporary buffer needed during initialization of the backend. + * @param[in] p_input_data Input data used to increase the entropy. + * @param[in] size Length of input data. + */ +ret_code_t nrf_crypto_rng_backend_reseed(void * const p_context, + void * p_temp_buffer, + uint8_t * p_input_data, + size_t size); + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_RNG_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.c similarity index 60% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_rng.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.c index 6e5be79..b3200d7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_rng.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,59 +35,63 @@ * 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(NRF_CRYPTO) -#if defined(NRF_CRYPTO_BACKEND_CC310_LIB) && (NRF_CRYPTO_BACKEND_CC310_LIB == 1) +#include "sdk_config.h" +#include "nordic_common.h" +#include "nrf_crypto_shared.h" + -#include "nrf_crypto.h" -#include "nrf_crypto_rng.h" -#include "cc310_lib_init.h" -#include "crys_rnd.h" +#if NRF_MODULE_ENABLED(NRF_CRYPTO) -extern CRYS_RND_Context_t * gp_rnd_context; -static uint32_t rng_result_get(CRYSError_t crys_error) +void nrf_crypto_internal_swap_endian_in_place(uint8_t * p_buffer, size_t size) { - uint32_t ret_val; + ASSERT(p_buffer != NULL); - switch (crys_error) + uint8_t temp; + uint8_t * p_first = p_buffer; + uint8_t * p_last = p_buffer + size - 1; + while (p_last >= p_first) { - case CRYS_OK: - ret_val = NRF_SUCCESS; - break; - - default: - ret_val = NRF_ERROR_INTERNAL; - break; + temp = *p_first; + *p_first = *p_last; + *p_last = temp; + p_first++; + p_last--; } - - return ret_val; } -uint32_t nrf_crypto_rng_init(void) -{ - // No need to do anything as library init takes care of initialization of rng. - return NRF_SUCCESS; -} -uint32_t nrf_crypto_rng_vector_generate(uint8_t * p_target, uint32_t length) +void nrf_crypto_internal_swap_endian(uint8_t * p_out, uint8_t const * p_in, size_t size) { - uint32_t ret_val; - CRYSError_t crys_error; + ASSERT(p_out != NULL); + ASSERT(p_in != NULL); - if (p_target == NULL) + uint8_t const * p_first = p_in; + uint8_t * p_last = p_out + size - 1; + while (p_last >= p_out) { - return NRF_ERROR_NULL; + *p_last = *p_first; + p_first++; + p_last--; } +} + - crys_error = CRYS_RND_GenerateVector(&gp_rnd_context->rndState, length, p_target); - ret_val = rng_result_get(crys_error); - return ret_val; +void nrf_crypto_internal_double_swap_endian(uint8_t * p_out, uint8_t const * p_in, size_t part_size) +{ + nrf_crypto_internal_swap_endian(p_out, p_in, part_size); + nrf_crypto_internal_swap_endian(&p_out[part_size], &p_in[part_size], part_size); +} + + +void nrf_crypto_internal_double_swap_endian_in_place(uint8_t * p_buffer, size_t part_size) +{ + nrf_crypto_internal_swap_endian_in_place(p_buffer, part_size); + nrf_crypto_internal_swap_endian_in_place(&p_buffer[part_size], part_size); } -#endif // NRF_CRYPTO_BACKEND_CC310_LIB -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.h new file mode 100644 index 0000000..95ac813 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_shared.h @@ -0,0 +1,189 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_CRYPTO_SHARED_H__ +#define NRF_CRYPTO_SHARED_H__ + +/** @internal @file + * + * @defgroup nrf_crypto_shared Shared macros for nrf_crypto + * @{ + * @ingroup nrf_crypto + * + * @brief Module containing shared macros for nrf_crypto. + */ + +#include "sdk_macros.h" +#include "nrf_crypto_mem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @internal @brief Macro for verifying statement to be true. It will cause the exterior function + * to return err_code if the statement is not true, but only after freeing the + * memory pointed to by p_memory if p_memory is not NULL. + * + * @param[in] statement Statement to test. + * @param[in] err_code Error value to return if test was invalid. + * @param[in] p_memory The memory block to be freed in case of error. + * + * @retval nothing, but will cause the exterior function to return @p err_code if @p statement + * is false. + */ +#define NRF_CRYPTO_VERIFY_TRUE_DEALLOCATE(statement, err_code, p_memory) \ +do \ +{ \ + if (!(statement)) \ + { \ + if (p_memory != NULL) \ + { \ + NRF_CRYPTO_FREE(p_memory); \ + } \ + return err_code; \ + } \ +} while (0) + + +/** + * @internal @brief Macro for verifying that a function returned NRF_SUCCESS. It will cause the + * exterior function to return err_code if the err_code is not @ref NRF_SUCCESS, + * but only after freeing the memory pointed to by p_memory if p_memory is not + * NULL. + * + * @param[in] err_code The error code to check. + * @param[in] p_memory The memory block to be freed in case of error. + */ +#ifdef DISABLE_PARAM_CHECK +#define NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE() +#else +#define NRF_CRYPTO_VERIFY_SUCCESS_DEALLOCATE(err_code, p_memory) \ + NRF_CRYPTO_VERIFY_TRUE_DEALLOCATE((err_code) == NRF_SUCCESS, (err_code), p_memory) +#endif /* DISABLE_PARAM_CHECK */ + + +/** + * @internal @brief Generate a vector with random data of given size. + * + * @details This function does not check or lock the CC310 mutex, and should only be used + * + * @note Only for internal use in nrf_crypto. + * + * @param[in,out] p_target Buffer to hold the random generated data. + * This buffer must be at least as large as the size parameter. + * @param[in] size Length (in bytes) to generate random data for. + * + * @retval See return values for @ref nrf_crypto_rng_vector_generate. + */ +ret_code_t nrf_crypto_rng_vector_generate_no_mutex(uint8_t * const p_target, size_t size); + + +/** + * @internal @brief Generate a vector of constrained random data of given size, between the + * specified min and max values. + * + * @details This function does not check or lock the CC310 mutex, and should only be used + * + * @note Only for internal use in nrf_crypto. + * + * @param[in,out] p_target Buffer to hold the random generated data. + * This buffer must be at least as large as the size parameter. + * @param[in] p_min Byte array defining the lower limit of the random vector. + * @param[in] p_max Byte array defining the upper limit of the random vector. + * @param[in] size Length (in bytes) to generate random data for. Note that all three + * buffers (p_target, p_min and p_max) must be of this size. + * + * @retval See return values for @ref nrf_crypto_rng_vector_generate_in_range. + */ +ret_code_t nrf_crypto_rng_vector_generate_in_range_no_mutex(uint8_t * const p_target, + uint8_t const * const p_min, + uint8_t const * const p_max, + size_t size); + + +/** @internal @brief Swap bytes order inside provided buffer (in place). + * + * @note Only for internal use in nrf_crypto. + * + * @param[in,out] p_buffer Buffer with data to swap. + * @param[in] size Number of bytes in @p p_buffer. + */ +void nrf_crypto_internal_swap_endian_in_place(uint8_t * p_buffer, size_t size); + + +/** @internal @brief Copy from one buffer to another and swap byte order. + * + * @note Only for internal use in nrf_crypto. + * + * @param[out] p_out Buffer with source data. + * @param[in] p_in Destination buffer with swapped bytes. + * @param[in] size Number of bytes in @p p_out and @p p_in. + */ +void nrf_crypto_internal_swap_endian(uint8_t * p_out, uint8_t const * p_in, size_t size); + + +/** @internal @brief Swap bytes order inside buffer containing two integers (in place). + * + * @note Only for internal use in nrf_crypto. + * + * @param[in,out] p_buffer Buffer with data to swap. + * @param[in] part_size Number of bytes in single integer which is half of size of @p p_buffer. + */ +void nrf_crypto_internal_double_swap_endian_in_place(uint8_t * p_buffer, size_t part_size); + + +/** @internal @brief Copy from one buffer containing two integers to another and swap byte order of each integer. + * + * @note Only for internal use in nrf_crypto. + * + * @param[out] p_out Buffer with source data. + * @param[in] p_in Destination buffer with swapped bytes. + * @param[in] part_size Number of bytes in single integer which is half of size of @p p_out and @p p_in. + */ +void nrf_crypto_internal_double_swap_endian(uint8_t * p_out, uint8_t const * p_in, size_t part_size); + + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // NRF_CRYPTO_SHARED_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_svc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_svc.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_svc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_svc.c index 940fc9f..326413a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_svc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_svc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,8 +35,9 @@ * 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 "nrf_svc_function.h" #include "nrf_error.h" #include "sdk_common.h" @@ -75,7 +76,7 @@ SVC_REGISTER_FUNCTION(const nrf_svc_func_reg_t nrf_crypto_svci_sign) = .func_ptr = (nrf_svc_func_t)&nrf_crypto_sign }; -#endif +#endif // #ifndef NRF51 SVC_REGISTER_FUNCTION(const nrf_svc_func_reg_t nrf_crypto_svci_verify) = { diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_types.h new file mode 100644 index 0000000..da0f7c5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/crypto/nrf_crypto_types.h @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2016 - 2019, 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 NRF_CRYPTO_TYPES_H__ +#define NRF_CRYPTO_TYPES_H__ + +/** @file + * + * @defgroup nrf_crypto_types Commonly shared types + * @{ + * @ingroup nrf_crypto + * + * @brief Provides definitions of commonly shared cryptographic types like hashes and curves used in the nrf_crypto APIs. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Hashing algorithms that are available through nrf_crypto. + * + * @note All cryptographic hash types may not be available through the nrf_crypto backend. + */ +typedef enum +{ + NRF_CRYPTO_HASH_TYPE_INVALID = 0x00, //!< Invalid hashing algorithm. + NRF_CRYPTO_HASH_TYPE_MD5 = 0x01, //!< MD5. + NRF_CRYPTO_HASH_TYPE_SHA1 = 0x03, //!< SHA-1. + NRF_CRYPTO_HASH_TYPE_SHA224 = 0x04, //!< SHA-224 (SHA-2). + NRF_CRYPTO_HASH_TYPE_SHA256 = 0x05, //!< SHA-256 (SHA-2). + NRF_CRYPTO_HASH_TYPE_SHA384 = 0x06, //!< SHA-384 (SHA-2). + NRF_CRYPTO_HASH_TYPE_SHA512 = 0x07, //!< SHA-512 (SHA-2). + +} nrf_hash_type_t; + +/**@defgroup NRF_CRYPTO_HASH_SIZES Cryptographic hash sizes + * @brief Sizes of different cryptographic hashes. + * @{ */ +#define NRF_CRYPTO_HASH_SIZE_MD5 (20) +#define NRF_CRYPTO_HASH_SIZE_SHA1 (20) +#define NRF_CRYPTO_HASH_SIZE_SHA224 (28) +#define NRF_CRYPTO_HASH_SIZE_SHA256 (32) +#define NRF_CRYPTO_HASH_SIZE_SHA384 (48) +#define NRF_CRYPTO_HASH_SIZE_SHA512 (64) +/** @} */ + + +/**@brief Type definition for key size. + */ +typedef enum +{ + NRF_CRYPTO_KEY_SIZE_128 = 128, + NRF_CRYPTO_KEY_SIZE_192 = 192, + NRF_CRYPTO_KEY_SIZE_256 = 256 +} nrf_crypto_key_size_id_t; + +/**@brief Type specifying whether decrypt or encrypt operation shall be performed. + */ +typedef enum +{ + NRF_CRYPTO_DECRYPT = 0, + NRF_CRYPTO_ENCRYPT = 1, + NRF_CRYPTO_MAC_CALCULATE = 2 +} nrf_crypto_operation_t; + +#define NRF_CRYPTO_AES_BLOCK_SIZE (16u) // 16 bytes + +#ifdef __cplusplus +} +#endif + +/**@} */ + +#endif // #ifndef NRF_CRYPTO_TYPES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense.c index 44429b8..09bf119 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -43,6 +43,7 @@ #include +#include #include "nrf_csense.h" #include "nrf_peripherals.h" #include "nrf_assert.h" @@ -60,7 +61,7 @@ APP_TIMER_DEF(nrf_csense_timer); typedef struct { nrf_csense_event_handler_t event_handler; //!< Event handler for module. - nrf_drv_state_t state; //!< State of module. + nrfx_drv_state_t state; //!< State of module. uint32_t ticks; //!< Timeout ticks of app_timer instance controlling csense module. uint16_t raw_analog_values[MAX_ANALOG_INPUTS]; //!< Raw values of measurements. uint8_t enabled_analog_channels_mask; //!< Mask of enabled channels. @@ -83,7 +84,7 @@ static uint16_t m_values_buffer[NRF_CSENSE_MAX_PADS_NUMBER]; */ static void csense_timer_handler(void * p_context) { - if (m_nrf_csense.state != NRF_DRV_STATE_POWERED_ON) + if (m_nrf_csense.state != NRFX_DRV_STATE_POWERED_ON) { return; } @@ -441,7 +442,7 @@ ret_code_t nrf_csense_init(nrf_csense_event_handler_t event_handler, uint32_t ticks) { ASSERT(event_handler != NULL); - ASSERT(m_nrf_csense.state == NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_nrf_csense.state == NRFX_DRV_STATE_UNINITIALIZED); ret_code_t err_code; @@ -466,7 +467,7 @@ ret_code_t nrf_csense_init(nrf_csense_event_handler_t event_handler, return err_code; } - m_nrf_csense.state = NRF_DRV_STATE_INITIALIZED; + m_nrf_csense.state = NRFX_DRV_STATE_INITIALIZED; return NRF_SUCCESS; } @@ -474,7 +475,7 @@ ret_code_t nrf_csense_init(nrf_csense_event_handler_t event_handler, ret_code_t nrf_csense_uninit(void) { - ASSERT(m_nrf_csense.state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_nrf_csense.state != NRFX_DRV_STATE_UNINITIALIZED); ret_code_t err_code; nrf_csense_instance_t ** pp_instance = &mp_nrf_csense_instance_head; @@ -503,7 +504,7 @@ ret_code_t nrf_csense_uninit(void) memset((void *)&m_nrf_csense, 0, sizeof(nrf_csense_t)); - m_nrf_csense.state = NRF_DRV_STATE_UNINITIALIZED; + m_nrf_csense.state = NRFX_DRV_STATE_UNINITIALIZED; return NRF_SUCCESS; @@ -511,7 +512,7 @@ ret_code_t nrf_csense_uninit(void) ret_code_t nrf_csense_add(nrf_csense_instance_t * const p_instance) { - ASSERT(m_nrf_csense.state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_nrf_csense.state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_instance->p_next_instance == NULL); ASSERT(p_instance != NULL); @@ -533,7 +534,7 @@ ret_code_t nrf_csense_add(nrf_csense_instance_t * const p_instance) ret_code_t nrf_csense_enable(nrf_csense_instance_t * const p_instance) { - ASSERT(m_nrf_csense.state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_nrf_csense.state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_instance != NULL); ret_code_t err_code; @@ -563,7 +564,7 @@ ret_code_t nrf_csense_enable(nrf_csense_instance_t * const p_instance) } } - m_nrf_csense.state = NRF_DRV_STATE_POWERED_ON; + m_nrf_csense.state = NRFX_DRV_STATE_POWERED_ON; nrf_drv_csense_channels_enable(analog_channels_mask); return NRF_SUCCESS; @@ -572,7 +573,7 @@ ret_code_t nrf_csense_enable(nrf_csense_instance_t * const p_instance) ret_code_t nrf_csense_disable(nrf_csense_instance_t * const p_instance) { - ASSERT(m_nrf_csense.state == NRF_DRV_STATE_POWERED_ON); + ASSERT(m_nrf_csense.state == NRFX_DRV_STATE_POWERED_ON); ret_code_t err_code; nrf_csense_instance_t * p_instance_temp = mp_nrf_csense_instance_head; @@ -608,7 +609,7 @@ ret_code_t nrf_csense_disable(nrf_csense_instance_t * const p_instance) { return err_code; } - m_nrf_csense.state = NRF_DRV_STATE_INITIALIZED; + m_nrf_csense.state = NRFX_DRV_STATE_INITIALIZED; } return NRF_SUCCESS; @@ -617,7 +618,7 @@ ret_code_t nrf_csense_disable(nrf_csense_instance_t * const p_instance) ret_code_t nrf_csense_ticks_set(uint32_t ticks) { - ASSERT(m_nrf_csense.state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_nrf_csense.state != NRFX_DRV_STATE_UNINITIALIZED); ret_code_t err_code; @@ -628,7 +629,7 @@ ret_code_t nrf_csense_ticks_set(uint32_t ticks) m_nrf_csense.ticks = ticks; - if (m_nrf_csense.state == NRF_DRV_STATE_POWERED_ON) + if (m_nrf_csense.state == NRFX_DRV_STATE_POWERED_ON) { err_code = app_timer_stop(nrf_csense_timer); if (err_code != NRF_SUCCESS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense.h index c511683..b9e671d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CSENSE_H__ #define NRF_CSENSE_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense_macros.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense_macros.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense_macros.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense_macros.h index 72b9338..c6c913e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense/nrf_csense_macros.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense/nrf_csense_macros.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_CSENSE_MACROS_H__ #define NRF_CSENSE_MACROS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense_drv/nrf_drv_csense.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense_drv/nrf_drv_csense.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense_drv/nrf_drv_csense.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense_drv/nrf_drv_csense.c index 52d4c03..7be66fa 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/csense_drv/nrf_drv_csense.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/csense_drv/nrf_drv_csense.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_DRV_CSENSE) @@ -65,7 +65,7 @@ #if USE_COMP == 0 #ifdef ADC_PRESENT -#include "nrf_drv_adc.h" +#include "nrfx_adc.h" /** * @defgroup adc_defines ADC defines to count input voltage. @@ -77,7 +77,7 @@ /* @} */ /* ADC channel used to call conversion. */ -static nrf_drv_adc_channel_t adc_channel = NRF_DRV_ADC_DEFAULT_CHANNEL(0); +static nrfx_adc_channel_t adc_channel = NRFX_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_0); #elif defined(SAADC_PRESENT) #include "nrf_drv_saadc.h" @@ -115,7 +115,7 @@ static const nrf_drv_timer_t m_timer1 = NRF_DRV_TIMER_INSTANCE(TIMER1_FOR_CSENSE /* Configuration of the capacitive sensor module. */ typedef struct { - volatile nrf_drv_state_t module_state; /**< State of the module. */ + volatile nrfx_drv_state_t module_state; /**< State of the module. */ nrf_drv_csense_event_handler_t event_handler; /**< Event handler for capacitor sensor events. */ uint16_t analog_values[MAX_ANALOG_INPUTS]; /**< Array containing analog values measured on the corresponding COMP/ADC channel. */ volatile bool busy; /**< Indicates state of module - busy if there are ongoing conversions. */ @@ -351,7 +351,7 @@ static ret_code_t comp_init(void) * * @param[in] p_event Pointer to analog-to-digital converter driver event. */ -void adc_handler(nrf_drv_adc_evt_t const * p_event) +void adc_handler(nrfx_adc_evt_t const * p_event) { nrf_gpio_pin_set(m_csense.output_pin); uint16_t val; @@ -370,8 +370,8 @@ static ret_code_t adc_init(void) adc_channel.config.config.input = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD; - nrf_drv_adc_config_t adc_config = NRF_DRV_ADC_DEFAULT_CONFIG; - err_code = nrf_drv_adc_init(&adc_config, adc_handler); + nrfx_adc_config_t const adc_config = NRFX_ADC_DEFAULT_CONFIG; + err_code = nrfx_adc_init(&adc_config, adc_handler); if (err_code != NRF_SUCCESS) { return NRF_ERROR_INTERNAL; @@ -437,7 +437,7 @@ static ret_code_t saadc_init(void) ret_code_t nrf_drv_csense_init(nrf_drv_csense_config_t const * p_config, nrf_drv_csense_event_handler_t event_handler) { - ASSERT(m_csense.module_state == NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_csense.module_state == NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_config->output_pin <= NUMBER_OF_PINS); ret_code_t err_code; @@ -494,14 +494,14 @@ ret_code_t nrf_drv_csense_init(nrf_drv_csense_config_t const * p_config, nrf_drv #endif //ADC_PRESENT #endif //USE_COMP - m_csense.module_state = NRF_DRV_STATE_INITIALIZED; + m_csense.module_state = NRFX_DRV_STATE_INITIALIZED; return NRF_SUCCESS; } ret_code_t nrf_drv_csense_uninit(void) { - ASSERT(m_csense.module_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_csense.module_state != NRFX_DRV_STATE_UNINITIALIZED); nrf_drv_csense_channels_disable(0xFF); @@ -527,13 +527,13 @@ ret_code_t nrf_drv_csense_uninit(void) } #else #ifdef ADC_PRESENT - nrf_drv_adc_uninit(); + nrfx_adc_uninit(); #elif defined(SAADC_PRESENT) nrf_drv_saadc_uninit(); #endif //ADC_PRESENT #endif //USE_COMP - m_csense.module_state = NRF_DRV_STATE_UNINITIALIZED; + m_csense.module_state = NRFX_DRV_STATE_UNINITIALIZED; memset((void*)&m_csense, 0, sizeof(m_csense)); @@ -542,11 +542,11 @@ ret_code_t nrf_drv_csense_uninit(void) void nrf_drv_csense_channels_enable(uint8_t channels_mask) { - ASSERT(m_csense.module_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_csense.module_state != NRFX_DRV_STATE_UNINITIALIZED); m_csense.busy = true; - m_csense.module_state = NRF_DRV_STATE_POWERED_ON; + m_csense.module_state = NRFX_DRV_STATE_POWERED_ON; m_csense.adc_channels_input_mask |= channels_mask; @@ -555,13 +555,13 @@ void nrf_drv_csense_channels_enable(uint8_t channels_mask) void nrf_drv_csense_channels_disable(uint8_t channels_mask) { - ASSERT(m_csense.module_state == NRF_DRV_STATE_POWERED_ON); + ASSERT(m_csense.module_state == NRFX_DRV_STATE_POWERED_ON); m_csense.adc_channels_input_mask &= ~channels_mask; if (m_csense.adc_channels_input_mask == 0) { - m_csense.module_state = NRF_DRV_STATE_INITIALIZED; + m_csense.module_state = NRFX_DRV_STATE_INITIALIZED; } } @@ -572,7 +572,7 @@ uint16_t nrf_drv_csense_channel_read(uint8_t csense_channel) ret_code_t nrf_drv_csense_sample(void) { - ASSERT(m_csense.module_state == NRF_DRV_STATE_POWERED_ON); + ASSERT(m_csense.module_state == NRFX_DRV_STATE_POWERED_ON); if (m_csense.adc_channels_input_mask != 0) { @@ -609,7 +609,7 @@ ret_code_t nrf_drv_csense_sample(void) #ifdef ADC_PRESENT adc_channel.config.config.ain = (nrf_adc_config_input_t)(1< #include "sdk_errors.h" #include "app_timer.h" -#include "nrf_drv_common.h" /** @file * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/delay/nrf_delay.h similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/delay/nrf_delay.h index 7de66b6..3719683 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_ecdsa.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/delay/nrf_delay.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2011 - 2019, 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 @@ -35,39 +35,46 @@ * 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 MICRO_ECC_ECDSA_H__ -#define MICRO_ECC_ECDSA_H__ - -/** @file - * - * @defgroup nrf_crypto_backend_micro_ecc_lib_ecdsa micro-ecc backend ECDSA types. - * @{ - * @ingroup nrf_crypto_backend_microecc * - * @brief Provides types required for micro_ecc backend ECDSA. */ +#ifndef _NRF_DELAY_H +#define _NRF_DELAY_H + +#include + #ifdef __cplusplus extern "C" { #endif - -/** @brief Size of ECDSA signing context. +/** + * @brief Function for delaying execution for a number of microseconds. + * + * @param us_time Number of microseconds to wait. */ -#define NRF_CRYPTO_ECDSA_SIGN_CONTEXT_SIZE (0) +#define nrf_delay_us(us_time) NRFX_DELAY_US(us_time) -/** @brief Size of ECDSA verification context. +/** + * @brief Function for delaying execution for a number of milliseconds. + * + * @param ms_time Number of milliseconds to wait. */ -#define NRF_CRYPTO_ECDSA_VERIFY_CONTEXT_SIZE (0) +__STATIC_INLINE void nrf_delay_ms(uint32_t ms_time) +{ + if (ms_time == 0) + { + return; + } + + do { + nrf_delay_us(1000); + } while (--ms_time); +} #ifdef __cplusplus } #endif -/**@} */ - -#endif // MICRO_ECC_ECDSA_H__ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/ecc/ecc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ecc/ecc.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/ecc/ecc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ecc/ecc.c index 397cf65..1400941 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/ecc/ecc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ecc/ecc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /** * @brief Elliptic Curve Cryptography Interface @@ -123,6 +123,7 @@ ret_code_t ecc_p256_public_key_compute(uint8_t const *p_le_sk, uint8_t *p_le_pk) ret_code_t ecc_p256_shared_secret_compute(uint8_t const *p_le_sk, uint8_t const *p_le_pk, uint8_t *p_le_ss) { + int ret; const struct uECC_Curve_t * p_curve; if (!p_le_sk || !p_le_pk || !p_le_ss) @@ -136,9 +137,17 @@ ret_code_t ecc_p256_shared_secret_compute(uint8_t const *p_le_sk, uint8_t const } p_curve = uECC_secp256r1(); - + + + // Validate the remote public key + ret = uECC_valid_public_key((uint8_t*) p_le_pk, p_curve); + if (!ret) + { + return NRF_ERROR_INTERNAL; + } + //NRF_LOG_INFO("uECC_shared_secret"); - int ret = uECC_shared_secret((uint8_t *) p_le_pk, (uint8_t *) p_le_sk, p_le_ss, p_curve); + ret = uECC_shared_secret((uint8_t *) p_le_pk, (uint8_t *) p_le_sk, p_le_ss, p_curve); if (!ret) { return NRF_ERROR_INTERNAL; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/ecc/ecc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ecc/ecc.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/ecc/ecc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ecc/ecc.h index d8adbf4..9f2321c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/ecc/ecc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ecc/ecc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** * @defgroup ecc Elliptic Curve Cryptography interface diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section.h index 4ac2b3a..a482be0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SECTION_H__ #define NRF_SECTION_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section_iter.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section_iter.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section_iter.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section_iter.c index a1c827e..3adedec 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section_iter.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section_iter.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section_iter.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section_iter.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section_iter.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section_iter.h index 104dc4b..3bf72c1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_section_vars/nrf_section_iter.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_section_vars/nrf_section_iter.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SECTION_ITER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager.c index 5eabdb3..a53a2e2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,11 +35,11 @@ * 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(TASK_MANAGER) -#include "nrf_mpu.h" +#include "nrf_mpu_lib.h" #include "nrf_atomic.h" #include "app_util_platform.h" #include "task_manager.h" @@ -149,7 +149,7 @@ typedef struct /**@brief Stack space for tasks */ #if TASK_MANAGER_CONFIG_STACK_GUARD /**@brief Handle to MPU region used as a guard */ -static nrf_mpu_region_t s_guard_region; +static nrf_mpu_lib_region_t s_guard_region; __ALIGN(STACK_GUARD_SIZE) #else __ALIGN(8) @@ -207,13 +207,14 @@ static void task_stack_poison(task_id_t task_id) static void task_stack_protect(task_id_t task_id) { #if TASK_MANAGER_CONFIG_STACK_GUARD - APP_ERROR_CHECK(nrf_mpu_region_create(&s_guard_region, - TASK_STACK_GUARD_BASE(task_id), - STACK_GUARD_SIZE, - TASK_GUARD_ATTRIBUTES)); + APP_ERROR_CHECK(nrf_mpu_lib_region_create(&s_guard_region, + TASK_STACK_GUARD_BASE(task_id), + STACK_GUARD_SIZE, + TASK_GUARD_ATTRIBUTES)); #endif } +PRAGMA_OPTIMIZATION_FORCE_START void task_manager_start(task_main_t idle_task, void *p_idle_task_context) { unsigned long control; @@ -265,6 +266,7 @@ void task_manager_start(task_main_t idle_task, void *p_idle_task_context) // This should be never reached. APP_ERROR_CHECK_BOOL(false); } +PRAGMA_OPTIMIZATION_FORCE_END task_id_t task_create(task_main_t task, char const * p_task_name, void *p_context) { @@ -333,7 +335,7 @@ void *task_schedule(void *p_stack) #if TASK_MANAGER_CONFIG_STACK_GUARD // Destroy stack guard allocated for current task. - APP_ERROR_CHECK(nrf_mpu_region_destroy(s_guard_region)); + APP_ERROR_CHECK(nrf_mpu_lib_region_destroy(s_guard_region)); #endif // Save current task state if task if switching from valid task. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager.h index 7c2288a..3ca680c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 __TASK_MANAGER_H__ #define __TASK_MANAGER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager_core_armgcc.S b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager_core_armgcc.S similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager_core_armgcc.S rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager_core_armgcc.S diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager_core_iar.s b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager_core_iar.s similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager_core_iar.s rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager_core_iar.s diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager_core_keil.s b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager_core_keil.s similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_task_manager/task_manager_core_keil.s rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/experimental_task_manager/task_manager_core_keil.s diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds.c similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds.c index 995af78..e73b7f8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(FDS) @@ -185,8 +185,14 @@ static fds_header_status_t header_check(fds_header_t const * p_hdr, uint32_t con return FDS_HEADER_CORRUPT; } + // It is important to also check for the record ID to be non-erased. + // It might happen that during GC, when records are copied in one operation, + // the device powers off after writing the first two words of the header. + // In that case the record would be considered valid, but its ID would + // corrupt the file system. if ( (p_hdr->file_id == FDS_FILE_ID_INVALID) - || (p_hdr->record_key == FDS_RECORD_KEY_DIRTY)) + || (p_hdr->record_key == FDS_RECORD_KEY_DIRTY) + || (p_hdr->record_id == FDS_ERASED_WORD)) { return FDS_HEADER_DIRTY; } @@ -226,10 +232,26 @@ static fds_page_type_t page_identify(uint32_t const * const p_page_addr) } } - -static bool page_is_erased(uint32_t const * const p_page_addr) +// A page can be tagged if it is entirely erased, or +// of the first word is fds magic word and the rest of it is erased. +static bool page_can_tag(uint32_t const * const p_page_addr) { - for (uint32_t i = 0; i < FDS_PAGE_SIZE; i++) + // This function should consider pages that have only the first half + // of the fds page tag written as erased (taggable). + // That is because the tag is two words long, and if the device + // has rebooted after writing the first word, that would cause + // the page to be unusable (since undefined and not fully erased). + // By considering the first word as erased if it contains fds page tag, + // the page can be re-tagged as necessary. + + if ((p_page_addr[FDS_PAGE_TAG_WORD_0] != FDS_ERASED_WORD) && + (p_page_addr[FDS_PAGE_TAG_WORD_0] != FDS_PAGE_TAG_MAGIC)) + { + return false; + } + + // Ignore the first word of the tag, we already checked that it is either erased or fds's. + for (uint32_t i = FDS_PAGE_TAG_WORD_1; i < FDS_PAGE_SIZE; i++) { if (*(p_page_addr + i) != FDS_ERASED_WORD) { @@ -246,12 +268,12 @@ static bool page_has_space(uint16_t page, uint16_t length_words) { length_words += m_pages[page].write_offset; length_words += m_pages[page].words_reserved; - return (length_words < FDS_PAGE_SIZE); + return (length_words <= FDS_PAGE_SIZE); } // Given a pointer to a record, find the index of the page on which it is stored. -// Returns FDS_SUCCESS if the page is found, FDS_ERR_NOT_FOUND otherwise. +// Returns NRF_SUCCESS if the page is found, FDS_ERR_NOT_FOUND otherwise. static ret_code_t page_from_record(uint16_t * const p_page, uint32_t const * const p_rec) { ret_code_t ret = FDS_ERR_NOT_FOUND; @@ -262,7 +284,7 @@ static ret_code_t page_from_record(uint16_t * const p_page, uint32_t const * con if ((p_rec > m_pages[i].p_addr) && (p_rec < m_pages[i].p_addr + FDS_PAGE_SIZE)) { - ret = FDS_SUCCESS; + ret = NRF_SUCCESS; *p_page = i; break; } @@ -326,10 +348,19 @@ static void page_scan(uint32_t const * p_addr, } -static void page_offsets_update(fds_page_t * const p_page, uint16_t length_words) +static void page_offsets_update(fds_page_t * const p_page, fds_op_t const * p_op) { - p_page->write_offset += (FDS_HEADER_SIZE + length_words); - p_page->words_reserved -= (FDS_HEADER_SIZE + length_words); + // If the first part of the header has been written correctly, update the offset as normal. + // Even if the record has not been written completely, fds is still able to continue normal + // operation. Incomplete records will be deleted the next time garbage collection is run. + // If we failed at the very beginning of the write operation, restore the offset + // to the previous value so that no holes will be left in the flash. + if (p_op->write.step > FDS_OP_WRITE_RECORD_ID) + { + p_page->write_offset += (FDS_HEADER_SIZE + p_op->write.header.length_words); + } + + p_page->words_reserved -= (FDS_HEADER_SIZE + p_op->write.header.length_words); } @@ -358,7 +389,7 @@ static ret_code_t write_space_reserve(uint16_t length_words, uint16_t * p_page) bool space_reserved = false; uint16_t const total_len_words = length_words + FDS_HEADER_SIZE; - if (total_len_words >= FDS_PAGE_SIZE - FDS_PAGE_TAG_SIZE) + if (total_len_words > FDS_PAGE_SIZE - FDS_PAGE_TAG_SIZE) { return FDS_ERR_RECORD_TOO_LARGE; } @@ -378,7 +409,7 @@ static ret_code_t write_space_reserve(uint16_t length_words, uint16_t * p_page) } CRITICAL_SECTION_EXIT(); - return (space_reserved) ? FDS_SUCCESS : FDS_ERR_NO_SPACE_IN_FLASH; + return (space_reserved) ? NRF_SUCCESS : FDS_ERR_NO_SPACE_IN_FLASH; } @@ -458,7 +489,7 @@ static bool record_find_by_desc(fds_record_desc_t * const p_desc, uint16_t * con (p_desc->gc_run_count == m_gc.run_count) && (p_desc->record_id == ((fds_header_t*)p_desc->p_record)->record_id)) { - return (page_from_record(p_page, p_desc->p_record) == FDS_SUCCESS); + return (page_from_record(p_page, p_desc->p_record) == NRF_SUCCESS); } // Otherwise, find the record in flash. @@ -534,7 +565,7 @@ static ret_code_t record_find(uint16_t const * p_file_id, p_desc->p_record = p_token->p_addr; p_desc->gc_run_count = m_gc.run_count; - return FDS_SUCCESS; + return NRF_SUCCESS; } // We have scanned an entire page. Set the address in the token to NULL @@ -645,7 +676,7 @@ static fds_init_opts_t pages_init(void) { case FDS_PAGE_UNDEFINED: { - if (page_is_erased(p_page_addr)) + if (page_can_tag(p_page_addr)) { if (m_swap_page.p_addr != NULL) { @@ -702,6 +733,9 @@ static fds_init_opts_t pages_init(void) m_pages[page].p_addr = m_swap_page.p_addr; m_pages[page].write_offset = FDS_PAGE_TAG_SIZE; + // This is a candidate for a potential new swap page, in case the + // current swap is going to be promoted to complete a GC instance. + m_gc.cur_page = page; page++; } @@ -740,7 +774,7 @@ static ret_code_t record_header_write_begin(fds_op_t * const p_op, uint32_t * co ret = nrf_fstorage_write(&m_fs, (uint32_t)(p_addr + FDS_OFFSET_TL), &p_op->write.header.record_key, FDS_HEADER_SIZE_TL * sizeof(uint32_t), NULL); - return (ret == NRF_SUCCESS) ? FDS_SUCCESS : FDS_ERR_BUSY; + return (ret == NRF_SUCCESS) ? NRF_SUCCESS : FDS_ERR_BUSY; } @@ -756,7 +790,7 @@ static ret_code_t record_header_write_id(fds_op_t * const p_op, uint32_t * const ret = nrf_fstorage_write(&m_fs, (uint32_t)(p_addr + FDS_OFFSET_ID), &p_op->write.header.record_id, FDS_HEADER_SIZE_ID * sizeof(uint32_t), NULL); - return (ret == NRF_SUCCESS) ? FDS_SUCCESS : FDS_ERR_BUSY; + return (ret == NRF_SUCCESS) ? NRF_SUCCESS : FDS_ERR_BUSY; } @@ -772,7 +806,7 @@ static ret_code_t record_header_write_finalize(fds_op_t * const p_op, uint32_t * ret = nrf_fstorage_write(&m_fs, (uint32_t)(p_addr + FDS_OFFSET_IC), &p_op->write.header.file_id, FDS_HEADER_SIZE_IC * sizeof(uint32_t), NULL); - return (ret == NRF_SUCCESS) ? FDS_SUCCESS : FDS_ERR_BUSY; + return (ret == NRF_SUCCESS) ? NRF_SUCCESS : FDS_ERR_BUSY; } @@ -795,7 +829,7 @@ static ret_code_t record_header_flag_dirty(uint32_t * const p_record, uint16_t p m_pages[page_to_gc].can_gc = true; - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -844,7 +878,7 @@ static ret_code_t file_find_and_delete(fds_op_t * const p_op) // Pass NULL to ignore the record key. ret = record_find(&p_op->del.file_id, NULL, &desc, &tok); - if (ret == FDS_SUCCESS) + if (ret == NRF_SUCCESS) { // A record was found: flag it as dirty. ret = record_header_flag_dirty((uint32_t*)desc.p_record, tok.page); @@ -869,7 +903,7 @@ static ret_code_t record_write_data(fds_op_t * const p_op, uint32_t * const p_ad ret = nrf_fstorage_write(&m_fs, (uint32_t)(p_addr + FDS_OFFSET_DATA), p_op->write.p_data, p_op->write.header.length_words * sizeof(uint32_t), NULL); - return (ret == NRF_SUCCESS) ? FDS_SUCCESS : FDS_ERR_BUSY; + return (ret == NRF_SUCCESS) ? NRF_SUCCESS : FDS_ERR_BUSY; } @@ -1179,7 +1213,7 @@ static ret_code_t init_execute(uint32_t prev_ret, fds_op_t * const p_op) break; } - if (ret != FDS_SUCCESS) + if (ret != NRF_SUCCESS) { // fstorage queue was full. m_flags.initializing = false; @@ -1207,7 +1241,7 @@ static ret_code_t write_execute(uint32_t prev_ret, fds_op_t * const p_op) if (prev_ret != NRF_SUCCESS) { // The previous operation has timed out, update offsets. - page_offsets_update(p_page, p_op->write.header.length_words); + page_offsets_update(p_page, p_op); return FDS_ERR_OPERATION_TIMEOUT; } @@ -1277,7 +1311,7 @@ static ret_code_t write_execute(uint32_t prev_ret, fds_op_t * const p_op) if (ret != FDS_OP_EXECUTING) { // There won't be another callback for this operation, so update the page offset now. - page_offsets_update(p_page, p_op->write.header.length_words); + page_offsets_update(p_page, p_op); } return ret; @@ -1436,23 +1470,15 @@ static void queue_process(ret_code_t result) // - free the operation buffer // - execute any other queued operations - fds_evt_t evt; - memset(&evt, 0x00, sizeof(evt)); - - if (result == FDS_OP_COMPLETED) - { - evt.result = FDS_SUCCESS; - result = NRF_SUCCESS; - } - else + fds_evt_t evt = { - // The operation failed for one of the following reasons: + // The operation might have failed for one of the following reasons: // FDS_ERR_BUSY - flash subsystem can't accept the operation // FDS_ERR_OPERATION_TIMEOUT - flash subsystem timed out // FDS_ERR_CRC_CHECK_FAILED - a CRC check failed // FDS_ERR_NOT_FOUND - no record found (delete/update) - evt.result = result; - } + .result = (result == FDS_OP_COMPLETED) ? NRF_SUCCESS : result, + }; event_prepare(m_p_cur_op, &evt); event_send(&evt); @@ -1461,6 +1487,10 @@ static void queue_process(ret_code_t result) // will fetch a new one from the queue next time it is run. m_p_cur_op = NULL; + // The result of the operation must be reset upon re-entering the loop to ensure + // the next operation won't be affected by eventual errors in previous operations. + result = NRF_SUCCESS; + // Free the queue element used by the current operation. queue_free(&m_iget_ctx); @@ -1529,7 +1559,7 @@ static ret_code_t write_enqueue(fds_record_desc_t * const p_desc, length_words = p_record->data.length_words; ret = write_space_reserve(length_words, &page); - if (ret != FDS_SUCCESS) + if (ret != NRF_SUCCESS) { // There is either not enough space in flash (FDS_ERR_NO_SPACE_IN_FLASH) or // the record exceeds the size of virtual page (FDS_ERR_RECORD_TOO_LARGE). @@ -1597,7 +1627,7 @@ static ret_code_t write_enqueue(fds_record_desc_t * const p_desc, // Start processing the queue, if necessary. queue_start(); - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -1614,7 +1644,7 @@ ret_code_t fds_register(fds_cb_t cb) m_cb_table[m_users] = cb; (void) nrf_atomic_u32_add(&m_users, 1); - ret = FDS_SUCCESS; + ret = NRF_SUCCESS; } return ret; @@ -1623,16 +1653,21 @@ ret_code_t fds_register(fds_cb_t cb) static uint32_t flash_end_addr(void) { - uint32_t const bootloader_addr = NRF_UICR->NRFFW[0]; + uint32_t const bootloader_addr = BOOTLOADER_ADDRESS; uint32_t const page_sz = NRF_FICR->CODEPAGESIZE; -#ifndef NRF52810_XXAA - uint32_t const code_sz = NRF_FICR->CODESIZE; + +#if defined(NRF52810_XXAA) || defined(NRF52811_XXAA) + // Hardcode the number of flash pages, necessary for SoC emulation. + // nRF52810 on nRF52832 and + // nRF52811 on nRF52840 + uint32_t const code_sz = 48; #else - // Number of flash pages, necessary to emulate the NRF52810 on NRF52832. - uint32_t const code_sz = 48; + uint32_t const code_sz = NRF_FICR->CODESIZE; #endif - return (bootloader_addr != 0xFFFFFFFF) ? bootloader_addr : (code_sz * page_sz); + uint32_t end_addr = (bootloader_addr != 0xFFFFFFFF) ? bootloader_addr : (code_sz * page_sz); + + return end_addr - (FDS_PHY_PAGES_RESERVED * FDS_PHY_PAGE_SIZE * sizeof(uint32_t)); } @@ -1670,20 +1705,20 @@ ret_code_t fds_init(void) fds_evt_t const evt_success = { .id = FDS_EVT_INIT, - .result = FDS_SUCCESS, + .result = NRF_SUCCESS, }; if (m_flags.initialized) { // No initialization is necessary. Notify the application immediately. event_send(&evt_success); - return FDS_SUCCESS; + return NRF_SUCCESS; } if (nrf_atomic_flag_set_fetch(&m_flags.initializing)) { // If we were already initializing, return. - return FDS_SUCCESS; + return NRF_SUCCESS; } // Otherwise, the flag is set and we proceed to initialization. @@ -1713,7 +1748,7 @@ ret_code_t fds_init(void) m_flags.initialized = true; m_flags.initializing = false; event_send(&evt_success); - return FDS_SUCCESS; + return NRF_SUCCESS; } default: @@ -1761,7 +1796,7 @@ ret_code_t fds_init(void) queue_buf_store(&iput_ctx); queue_start(); - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -1798,7 +1833,7 @@ ret_code_t fds_record_open(fds_record_desc_t * const p_desc, // Set the record as open in the descriptor. p_desc->record_is_open = true; - return FDS_SUCCESS; + return NRF_SUCCESS; } // The record could not be found. @@ -1826,7 +1861,7 @@ ret_code_t fds_record_close(fds_record_desc_t * const p_desc) m_pages[page].records_open--; p_desc->record_is_open = false; - ret = FDS_SUCCESS; + ret = NRF_SUCCESS; } else { @@ -1860,7 +1895,7 @@ ret_code_t fds_reserve(fds_reserve_token_t * const p_tok, uint16_t length_words) ret = write_space_reserve(length_words, &page); - if (ret == FDS_SUCCESS) + if (ret == NRF_SUCCESS) { p_tok->page = page; p_tok->length_words = length_words; @@ -1901,7 +1936,7 @@ ret_code_t fds_reserve_cancel(fds_reserve_token_t * const p_tok) // Clean the token. p_tok->page = 0; p_tok->length_words = 0; - ret = FDS_SUCCESS; + ret = NRF_SUCCESS; } else { @@ -1977,7 +2012,7 @@ ret_code_t fds_record_delete(fds_record_desc_t * const p_desc) queue_buf_store(&iput_ctx); queue_start(); - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -2009,7 +2044,7 @@ ret_code_t fds_file_delete(uint16_t file_id) queue_buf_store(&iput_ctx); queue_start(); - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -2041,7 +2076,7 @@ ret_code_t fds_gc(void) queue_start(); - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -2089,7 +2124,7 @@ ret_code_t fds_descriptor_from_rec_id(fds_record_desc_t * const p_desc, memset(p_desc, 0x00, sizeof(fds_record_desc_t)); p_desc->record_id = record_id; - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -2103,7 +2138,7 @@ ret_code_t fds_record_id_from_desc(fds_record_desc_t const * const p_desc, *p_record_id = p_desc->record_id; - return FDS_SUCCESS; + return NRF_SUCCESS; } @@ -2153,7 +2188,7 @@ ret_code_t fds_stat(fds_stat_t * const p_stat) &p_stat->corruption); } - return FDS_SUCCESS; + return NRF_SUCCESS; } #endif //NRF_MODULE_ENABLED(FDS) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds.h similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds.h index 3d5986b..13c5f67 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 FDS_H__ #define FDS_H__ @@ -82,22 +82,21 @@ extern "C" { */ enum { - FDS_SUCCESS = NRF_SUCCESS, //!< The operation completed successfully. - FDS_ERR_OPERATION_TIMEOUT, //!< Error. The operation timed out. - FDS_ERR_NOT_INITIALIZED, //!< Error. The module has not been initialized. - FDS_ERR_UNALIGNED_ADDR, //!< Error. The input data is not aligned to a word boundary. - FDS_ERR_INVALID_ARG, //!< Error. The parameter contains invalid data. - FDS_ERR_NULL_ARG, //!< Error. The parameter is NULL. - FDS_ERR_NO_OPEN_RECORDS, //!< Error. The record is not open, so it cannot be closed. - FDS_ERR_NO_SPACE_IN_FLASH, //!< Error. There is no space in flash memory. - FDS_ERR_NO_SPACE_IN_QUEUES, //!< Error. There is no space in the internal queues. - FDS_ERR_RECORD_TOO_LARGE, //!< Error. The record exceeds the maximum allowed size. - FDS_ERR_NOT_FOUND, //!< Error. The record was not found. - FDS_ERR_NO_PAGES, //!< Error. No flash pages are available. - FDS_ERR_USER_LIMIT_REACHED, //!< Error. The maximum number of users has been reached. - FDS_ERR_CRC_CHECK_FAILED, //!< Error. The CRC check failed. - FDS_ERR_BUSY, //!< Error. The underlying flash subsystem was busy. - FDS_ERR_INTERNAL, //!< Error. An internal error occurred. + FDS_ERR_OPERATION_TIMEOUT = NRF_ERROR_FDS_ERR_BASE, //!< Error. The operation timed out. + FDS_ERR_NOT_INITIALIZED, //!< Error. The module has not been initialized. + FDS_ERR_UNALIGNED_ADDR, //!< Error. The input data is not aligned to a word boundary. + FDS_ERR_INVALID_ARG, //!< Error. The parameter contains invalid data. + FDS_ERR_NULL_ARG, //!< Error. The parameter is NULL. + FDS_ERR_NO_OPEN_RECORDS, //!< Error. The record is not open, so it cannot be closed. + FDS_ERR_NO_SPACE_IN_FLASH, //!< Error. There is no space in flash memory. + FDS_ERR_NO_SPACE_IN_QUEUES, //!< Error. There is no space in the internal queues. + FDS_ERR_RECORD_TOO_LARGE, //!< Error. The record exceeds the maximum allowed size. + FDS_ERR_NOT_FOUND, //!< Error. The record was not found. + FDS_ERR_NO_PAGES, //!< Error. No flash pages are available. + FDS_ERR_USER_LIMIT_REACHED, //!< Error. The maximum number of users has been reached. + FDS_ERR_CRC_CHECK_FAILED, //!< Error. The CRC check failed. + FDS_ERR_BUSY, //!< Error. The underlying flash subsystem was busy. + FDS_ERR_INTERNAL, //!< Error. An internal error occurred. }; @@ -196,7 +195,7 @@ typedef enum } fds_evt_id_t; -ANON_UNIONS_ENABLE +ANON_UNIONS_ENABLE; /**@brief An FDS event. */ typedef struct @@ -221,7 +220,7 @@ typedef struct }; } fds_evt_t; -ANON_UNIONS_DISABLE +ANON_UNIONS_DISABLE; /**@brief File system statistics. */ @@ -275,7 +274,7 @@ typedef void (*fds_cb_t)(fds_evt_t const * p_evt); * * @param[in] cb The event handler function. * - * @retval FDS_SUCCESS If the event handler was registered successfully. + * @retval NRF_SUCCESS If the event handler was registered successfully. * @retval FDS_ERR_USER_LIMIT_REACHED If the maximum number of registered callbacks is reached. */ ret_code_t fds_register(fds_cb_t cb); @@ -286,10 +285,11 @@ ret_code_t fds_register(fds_cb_t cb); * This function initializes the module and installs the file system (unless it is installed * already). * - * This function is asynchronous. Completion is reported through an event. Make sure to call - * @ref fds_register before calling @ref fds_init so that you receive the completion event. + * This function is asynchronous. Completion is reported through the @ref FDS_EVT_INIT event. + * Make sure to call @ref fds_register before calling @ref fds_init so that you receive + * @ref FDS_EVT_INIT. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NO_PAGES If there is no space available in flash memory to install the * file system. */ @@ -313,14 +313,15 @@ ret_code_t fds_init(void); * operation has been received. The length of the data must not exceed @ref FDS_VIRTUAL_PAGE_SIZE * words minus 14 bytes. * - * This function is asynchronous. Completion is reported through an event that is sent to - * the registered event handler function. + * This function is asynchronous. Completion is reported through @ref FDS_EVT_WRITE event that is + * sent to the registered event handler function. * * @param[out] p_desc The descriptor of the record that was written. Pass NULL if you do not * need the descriptor. - * @param[in] p_record The record to be written to flash. + * @param[in] p_record The record to be written to flash. The record is required to be word + * aligned. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_record is NULL. * @retval FDS_ERR_INVALID_ARG If the file ID or the record key is invalid. @@ -347,7 +348,7 @@ ret_code_t fds_record_write(fds_record_desc_t * p_desc, * cancel the reservation. * @param[in] length_words The length of the record data (in 4-byte words). * - * @retval FDS_SUCCESS If the flash space was reserved successfully. + * @retval NRF_SUCCESS If the flash space was reserved successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_token is NULL instead of a valid token address. * @retval FDS_ERR_RECORD_TOO_LARGE If the record length exceeds the maximum length. @@ -361,7 +362,7 @@ ret_code_t fds_reserve(fds_reserve_token_t * p_token, uint16_t length_words); * * @param[in] p_token The token that identifies the reservation, produced by @ref fds_reserve. * - * @retval FDS_SUCCESS If the reservation was canceled. + * @retval NRF_SUCCESS If the reservation was canceled. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_token is NULL instead of a valid token address. * @retval FDS_ERR_INVALID_ARG If @p p_token contains invalid data. @@ -393,10 +394,11 @@ ret_code_t fds_reserve_cancel(fds_reserve_token_t * p_token); * * @param[out] p_desc The descriptor of the record that was written. Pass NULL if you do not * need the descriptor. - * @param[in] p_record The record to be written to flash. + * @param[in] p_record The record to be written to flash. The record is required + * to be word aligned. * @param[in] p_token The token that identifies the space reserved in flash. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_token is NULL instead of a valid token address. * @retval FDS_ERR_INVALID_ARG If the file ID or the record key is invalid. @@ -419,12 +421,12 @@ ret_code_t fds_record_write_reserved(fds_record_desc_t * p_desc, * Note that deleting a record does not free the space it occupies in flash memory. * To reclaim flash space used by deleted records, call @ref fds_gc to run garbage collection. * - * This function is asynchronous. Completion is reported through an event that is sent to the - * registered event handler function. + * This function is asynchronous. Completion is reported through the @ref FDS_EVT_DEL_RECORD event + * that is sent to the registered event handler function. * * @param[in] p_desc The descriptor of the record that should be deleted. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If the specified record descriptor @p p_desc is NULL. * @retval FDS_ERR_NO_SPACE_IN_QUEUES If the operation queue is full. @@ -441,12 +443,12 @@ ret_code_t fds_record_delete(fds_record_desc_t * p_desc); * Note that deleting records does not free the space they occupy in flash memory. * To reclaim flash space used by deleted records, call @ref fds_gc to run garbage collection. * - * This function is asynchronous. Completion is reported through an event that is sent to the - * registered event handler function. + * This function is asynchronous. Completion is reported through the @ref FDS_EVT_DEL_FILE event + * that is sent to the registered event handler function. * * @param[in] file_id The ID of the file to be deleted. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_INVALID_ARG If the specified @p file_id is invalid. * @retval FDS_ERR_NO_SPACE_IN_QUEUES If the operation queue is full. @@ -471,15 +473,16 @@ ret_code_t fds_file_delete(uint16_t file_id); * operation has been received. The length of the data must not exceed @ref FDS_VIRTUAL_PAGE_SIZE * words minus 14 bytes. * - * This function is asynchronous. Completion is reported through an event that is sent to the - * registered event handler function. + * This function is asynchronous. Completion is reported through the @ref FDS_EVT_UPDATE event + * that is sent to the registered event handler function. * * @param[in, out] p_desc The descriptor of the record to update. When the function - * returns with FDS_SUCCESS, this parameter contains the + * returns with NRF_SUCCESS, this parameter contains the * descriptor of the newly written record. - * @param[in] p_record The updated record to be written to flash. + * @param[in] p_record The updated record to be written to flash. The record is required + * to be word aligned. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_INVALID_ARG If the file ID or the record key is invalid. * @retval FDS_ERR_UNALIGNED_ADDR If the record data is not aligned to a 4 byte boundary. @@ -503,7 +506,7 @@ ret_code_t fds_record_update(fds_record_desc_t * p_desc, * @param[out] p_desc The descriptor of the record that was found. * @param[out] p_token A token containing information about the progress of the operation. * - * @retval FDS_SUCCESS If a record was found. + * @retval NRF_SUCCESS If a record was found. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_desc or @p p_token is NULL. * @retval FDS_ERR_NOT_FOUND If no matching record was found. @@ -523,7 +526,7 @@ ret_code_t fds_record_iterate(fds_record_desc_t * p_desc, * @param[out] p_desc The descriptor of the record that was found. * @param[out] p_token A token containing information about the progress of the operation. * - * @retval FDS_SUCCESS If a record was found. + * @retval NRF_SUCCESS If a record was found. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_desc or @p p_token is NULL. * @retval FDS_ERR_NOT_FOUND If no matching record was found. @@ -544,7 +547,7 @@ ret_code_t fds_record_find(uint16_t file_id, * @param[out] p_desc The descriptor of the record that was found. * @param[out] p_token A token containing information about the progress of the operation. * - * @retval FDS_SUCCESS If a record was found. + * @retval NRF_SUCCESS If a record was found. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_desc or @p p_token is NULL. * @retval FDS_ERR_NOT_FOUND If no record with the given key was found. @@ -564,7 +567,7 @@ ret_code_t fds_record_find_by_key(uint16_t record_key, * @param[out] p_desc The descriptor of the record that was found. * @param[out] p_token A token containing information about the progress of the operation. * - * @retval FDS_SUCCESS If a record was found. + * @retval NRF_SUCCESS If a record was found. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_desc or @p p_token is NULL. * @retval FDS_ERR_NOT_FOUND If no matching record was found. @@ -592,7 +595,7 @@ ret_code_t fds_record_find_in_file(uint16_t file_id, * @param[in] p_desc The descriptor of the record to open. * @param[out] p_flash_record The record, as stored in flash. * - * @retval FDS_SUCCESS If the record was opened successfully. + * @retval NRF_SUCCESS If the record was opened successfully. * @retval FDS_ERR_NULL_ARG If @p p_desc or @p p_flash_record is NULL. * @retval FDS_ERR_NOT_FOUND If the record was not found. It might have been deleted, or * it might not have been written yet. @@ -613,7 +616,7 @@ ret_code_t fds_record_open(fds_record_desc_t * p_desc, * * @param[in] p_desc The descriptor of the record to close. * - * @retval FDS_SUCCESS If the record was closed successfully. + * @retval NRF_SUCCESS If the record was closed successfully. * @retval FDS_ERR_NULL_ARG If @p p_desc is NULL. * @retval FDS_ERR_NO_OPEN_RECORDS If the record is not open. * @retval FDS_ERR_NOT_FOUND If the record could not be found. @@ -626,10 +629,10 @@ ret_code_t fds_record_close(fds_record_desc_t * p_desc); * Garbage collection reclaims the flash space that is occupied by records that have been deleted, * or that failed to be completely written due to, for example, a power loss. * - * This function is asynchronous. Completion is reported through an event that is sent to the - * registered event handler function. + * This function is asynchronous. Completion is reported through the @ref FDS_EVT_GC event that + * is sent to the registered event handler function. * - * @retval FDS_SUCCESS If the operation was queued successfully. + * @retval NRF_SUCCESS If the operation was queued successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NO_SPACE_IN_QUEUES If the operation queue is full. */ @@ -649,7 +652,7 @@ ret_code_t fds_gc(void); * @param[out] p_desc The descriptor of the record with the given record ID. * @param[in] record_id The record ID for which a descriptor should be returned. * - * @retval FDS_SUCCESS If a descriptor was returned. + * @retval NRF_SUCCESS If a descriptor was returned. * @retval FDS_ERR_NULL_ARG If @p p_desc is NULL. */ ret_code_t fds_descriptor_from_rec_id(fds_record_desc_t * p_desc, @@ -669,7 +672,7 @@ ret_code_t fds_descriptor_from_rec_id(fds_record_desc_t * p_desc, * @param[in] p_desc The descriptor from which the record ID should be extracted. * @param[out] p_record_id The record ID that is contained in the given descriptor. * - * @retval FDS_SUCCESS If a record ID was returned. + * @retval NRF_SUCCESS If a record ID was returned. * @retval FDS_ERR_NULL_ARG If @p p_desc or @p p_record_id is NULL. */ ret_code_t fds_record_id_from_desc(fds_record_desc_t const * p_desc, @@ -683,7 +686,7 @@ ret_code_t fds_record_id_from_desc(fds_record_desc_t const * p_desc, * * @param[out] p_stat File system statistics. * - * @retval FDS_SUCCESS If the statistics were returned successfully. + * @retval NRF_SUCCESS If the statistics were returned successfully. * @retval FDS_ERR_NOT_INITIALIZED If the module is not initialized. * @retval FDS_ERR_NULL_ARG If @p p_stat is NULL. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds_internal_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds_internal_defs.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds_internal_defs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds_internal_defs.h index 0d490ca..9862429 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fds/fds_internal_defs.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fds/fds_internal_defs.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 FDS_INTERNAL_DEFS_H__ #define FDS_INTERNAL_DEFS_H__ @@ -80,15 +80,18 @@ extern "C" { #define NRF_FSTORAGE_SD 2 // The size of a physical page, in 4-byte words. -#if defined(NRF51) +#if defined(NRF51) #define FDS_PHY_PAGE_SIZE (256) - #elif defined(NRF52_SERIES) +#else #define FDS_PHY_PAGE_SIZE (1024) #endif // The number of physical pages to be used. This value is configured indirectly. #define FDS_PHY_PAGES ((FDS_VIRTUAL_PAGES * FDS_VIRTUAL_PAGE_SIZE) / FDS_PHY_PAGE_SIZE) +// The number of physical pages at the end of the flash that are reserved by other modules. +#define FDS_PHY_PAGES_RESERVED ((FDS_VIRTUAL_PAGES_RESERVED * FDS_VIRTUAL_PAGE_SIZE) / FDS_PHY_PAGE_SIZE) + // The size of a virtual page, in number of physical pages. #define FDS_PHY_PAGES_IN_VPAGE (FDS_VIRTUAL_PAGE_SIZE / FDS_PHY_PAGE_SIZE) @@ -98,7 +101,6 @@ extern "C" { // Just a shorter name for the size, in words, of a virtual page. #define FDS_PAGE_SIZE (FDS_VIRTUAL_PAGE_SIZE) - #if (FDS_VIRTUAL_PAGE_SIZE % FDS_PHY_PAGE_SIZE != 0) #error "FDS_VIRTUAL_PAGE_SIZE must be a multiple of the size of a physical page." #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fifo/app_fifo.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fifo/app_fifo.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fifo/app_fifo.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fifo/app_fifo.c index 26c49bc..99e0af4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fifo/app_fifo.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fifo/app_fifo.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(APP_FIFO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fifo/app_fifo.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fifo/app_fifo.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fifo/app_fifo.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fifo/app_fifo.h index bf512fb..88fa56b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fifo/app_fifo.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fifo/app_fifo.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage.c similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage.c index b0d013a..70c6c7e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" @@ -45,24 +45,45 @@ #include #include #include "sdk_errors.h" +#include "sdk_macros.h" #include "nrf_section.h" +#define NRF_LOG_MODULE_NAME nrf_fstorage +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + /* Create the section "fs_data". */ NRF_SECTION_DEF(fs_data, nrf_fstorage_t); -static bool addr_within_bounds(nrf_fstorage_t const * p_fs, uint32_t addr, uint32_t len); + +/**@brief Macro to handle user input validation. + * + * If @p _cond evaluates to true, does nothing. Otherwise, + * if the NRF_FSTORAGE_PARAM_CHECK_DISABLED is not set, logs an error message and returns @p _err. + * If the NRF_FSTORAGE_PARAM_CHECK_DISABLED is set, behaves like the @ref ASSERT macro. + * + * Parameter checking implemented using this macro can be optionally turned off for release code. + * Only disable runtime parameter checks if size if a major concern. + * + * @param _cond The condition to be evaluated. + * @param _err The error code to be returned. + */ +#define NRF_FSTORAGE_PARAM_CHECK(_cond, _err) \ + NRF_PARAM_CHECK(NRF_FSTORAGE, _cond, _err, NRF_LOG_ERROR) + + static bool addr_is_aligned32(uint32_t addr); +static bool addr_is_page_aligned(nrf_fstorage_t const * p_fs, uint32_t addr); +static bool addr_is_within_bounds(nrf_fstorage_t const * p_fs, uint32_t addr, uint32_t len); ret_code_t nrf_fstorage_init(nrf_fstorage_t * p_fs, nrf_fstorage_api_t * p_api, void * p_param) { - if ((p_fs == NULL) || (p_api == NULL)) - { - return NRF_ERROR_NULL; - } + NRF_FSTORAGE_PARAM_CHECK(p_fs, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_api, NRF_ERROR_NULL); p_fs->p_api = p_api; @@ -75,15 +96,8 @@ ret_code_t nrf_fstorage_uninit(nrf_fstorage_t * p_fs, { ret_code_t rc; - if (p_fs == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_fs->p_api == NULL) - { - return NRF_ERROR_INVALID_STATE; - } + NRF_FSTORAGE_PARAM_CHECK(p_fs, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_fs->p_api, NRF_ERROR_INVALID_STATE); rc = (p_fs->p_api)->uninit(p_fs, p_param); @@ -100,27 +114,14 @@ ret_code_t nrf_fstorage_read(nrf_fstorage_t const * p_fs, void * p_dest, uint32_t len) { - if ((p_fs == NULL) || (p_dest == NULL)) - { - return NRF_ERROR_NULL; - } - - if (p_fs->p_api == NULL) - { - return NRF_ERROR_INVALID_STATE; - } - - if (len == 0) - { - return NRF_ERROR_INVALID_LENGTH; - } + NRF_FSTORAGE_PARAM_CHECK(p_fs, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_dest, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_fs->p_api, NRF_ERROR_INVALID_STATE); + NRF_FSTORAGE_PARAM_CHECK(len, NRF_ERROR_INVALID_LENGTH); /* Source addres must be word-aligned. */ - if ( !addr_is_aligned32(src) - || !addr_within_bounds(p_fs, src, len)) - { - return NRF_ERROR_INVALID_ADDR; - } + NRF_FSTORAGE_PARAM_CHECK(addr_is_aligned32(src), NRF_ERROR_INVALID_ADDR); + NRF_FSTORAGE_PARAM_CHECK(addr_is_within_bounds(p_fs, src, len), NRF_ERROR_INVALID_ADDR); return (p_fs->p_api)->read(p_fs, src, p_dest, len); } @@ -132,29 +133,18 @@ ret_code_t nrf_fstorage_write(nrf_fstorage_t const * p_fs, uint32_t len, void * p_context) { - if ((p_fs == NULL) || (p_src == NULL)) - { - return NRF_ERROR_NULL; - } - - if (p_fs->p_api == NULL) - { - return NRF_ERROR_INVALID_STATE; - } + NRF_FSTORAGE_PARAM_CHECK(p_fs, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_src, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_fs->p_api, NRF_ERROR_INVALID_STATE); + NRF_FSTORAGE_PARAM_CHECK(len, NRF_ERROR_INVALID_LENGTH); /* Length must be a multiple of the program unit. */ - if ((len == 0) || ((len % p_fs->p_flash_info->program_unit) != 0)) - { - return NRF_ERROR_INVALID_LENGTH; - } + NRF_FSTORAGE_PARAM_CHECK(!(len % p_fs->p_flash_info->program_unit), NRF_ERROR_INVALID_LENGTH); /* Source and destination addresses must be word-aligned. */ - if ( !addr_is_aligned32(dest) - || !addr_is_aligned32((uint32_t)p_src) - || !addr_within_bounds(p_fs, dest, len)) - { - return NRF_ERROR_INVALID_ADDR; - } + NRF_FSTORAGE_PARAM_CHECK(addr_is_aligned32(dest), NRF_ERROR_INVALID_ADDR); + NRF_FSTORAGE_PARAM_CHECK(addr_is_aligned32((uint32_t)p_src), NRF_ERROR_INVALID_ADDR); + NRF_FSTORAGE_PARAM_CHECK(addr_is_within_bounds(p_fs, dest, len), NRF_ERROR_INVALID_ADDR); return (p_fs->p_api)->write(p_fs, dest, p_src, len, p_context); } @@ -165,27 +155,17 @@ ret_code_t nrf_fstorage_erase(nrf_fstorage_t const * p_fs, uint32_t len, void * p_context) { - if (p_fs == NULL) - { - return NRF_ERROR_NULL; - } - - if (p_fs->p_api == NULL) - { - return NRF_ERROR_INVALID_STATE; - } - - if (len == 0) - { - return NRF_ERROR_INVALID_LENGTH; - } + NRF_FSTORAGE_PARAM_CHECK(p_fs, NRF_ERROR_NULL); + NRF_FSTORAGE_PARAM_CHECK(p_fs->p_api, NRF_ERROR_INVALID_STATE); + NRF_FSTORAGE_PARAM_CHECK(len, NRF_ERROR_INVALID_LENGTH); /* Address must be aligned to a page boundary. */ - if ( ((page_addr & (p_fs->p_flash_info->erase_unit - 1)) != 0) - || !addr_within_bounds(p_fs, page_addr, (len * p_fs->p_flash_info->erase_unit))) - { - return NRF_ERROR_INVALID_ADDR; - } + NRF_FSTORAGE_PARAM_CHECK(addr_is_page_aligned(p_fs, page_addr), NRF_ERROR_INVALID_ADDR); + + NRF_FSTORAGE_PARAM_CHECK( + addr_is_within_bounds(p_fs, page_addr, (len * p_fs->p_flash_info->erase_unit)), + NRF_ERROR_INVALID_ADDR + ); return (p_fs->p_api)->erase(p_fs, page_addr, len, p_context); } @@ -193,7 +173,7 @@ ret_code_t nrf_fstorage_erase(nrf_fstorage_t const * p_fs, uint8_t const * nrf_fstorage_rmap(nrf_fstorage_t const * p_fs, uint32_t addr) { - if (p_fs == NULL) + if ((p_fs == NULL) || (p_fs->p_api == NULL)) { return NULL; } @@ -204,7 +184,7 @@ uint8_t const * nrf_fstorage_rmap(nrf_fstorage_t const * p_fs, uint32_t addr) uint8_t * nrf_fstorage_wmap(nrf_fstorage_t const * p_fs, uint32_t addr) { - if (p_fs == NULL) + if ((p_fs == NULL) || (p_fs->p_api == NULL)) { return NULL; } @@ -221,7 +201,7 @@ bool nrf_fstorage_is_busy(nrf_fstorage_t const * p_fs) { for (uint32_t i = 0; i < NRF_FSTORAGE_INSTANCE_CNT; i++) { - p_fs = NRF_FSTORAGE_INSTANCE_GET(i); /* cannot be NULL. */ + p_fs = NRF_FSTORAGE_INSTANCE_GET(i); /* cannot be NULL. */ if (p_fs->p_api != NULL) { /* p_api->is_busy() cannot be NULL. */ @@ -239,12 +219,12 @@ bool nrf_fstorage_is_busy(nrf_fstorage_t const * p_fs) } -static bool addr_within_bounds(nrf_fstorage_t const * p_fs, - uint32_t addr, - uint32_t len) +static bool addr_is_within_bounds(nrf_fstorage_t const * p_fs, + uint32_t addr, + uint32_t len) { - return ((addr >= p_fs->start_addr) && - (addr + len - 1 <= p_fs->end_addr)); + return ( (addr >= p_fs->start_addr) + && (addr + len - 1 <= p_fs->end_addr)); } @@ -254,4 +234,11 @@ static bool addr_is_aligned32(uint32_t addr) } +static bool addr_is_page_aligned(nrf_fstorage_t const * p_fs, + uint32_t addr) +{ + return (addr & (p_fs->p_flash_info->erase_unit - 1)) == 0; +} + + #endif // NRF_FSTORAGE_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage.h index 118753f..6425753 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_FSTORAGE_H__ #define NRF_FSTORAGE_H__ @@ -87,7 +87,7 @@ extern "C" { /**@brief Event IDs. */ typedef enum { - NRF_FSTORAGE_EVT_READ_RESULT, + NRF_FSTORAGE_EVT_READ_RESULT, //!< Unused event reserved for a possible future feature. NRF_FSTORAGE_EVT_WRITE_RESULT, //!< Event for @ref nrf_fstorage_write. NRF_FSTORAGE_EVT_ERASE_RESULT //!< Event for @ref nrf_fstorage_erase. } nrf_fstorage_evt_id_t; @@ -99,6 +99,7 @@ typedef struct nrf_fstorage_evt_id_t id; //!< The event ID. ret_code_t result; //!< Result of the operation. uint32_t addr; //!< Address at which the operation was performed. + void const * p_src; //!< Buffer written to flash. uint32_t len; //!< Length of the operation. void * p_param; //!< User-defined parameter passed to the event handler. } nrf_fstorage_evt_t; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_nvmc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_nvmc.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_nvmc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_nvmc.c index b7c1ac0..b19b383 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_nvmc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_nvmc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -69,6 +69,7 @@ static nrf_atomic_flag_t m_flash_operation_ongoing; /* Send event to the event handler. */ static void event_send(nrf_fstorage_t const * p_fs, nrf_fstorage_evt_id_t evt_id, + void const * p_src, uint32_t addr, uint32_t len, void * p_param) @@ -84,6 +85,7 @@ static void event_send(nrf_fstorage_t const * p_fs, .result = NRF_SUCCESS, .id = evt_id, .addr = addr, + .p_src = p_src, .len = len, .p_param = p_param, }; @@ -139,7 +141,7 @@ static ret_code_t write(nrf_fstorage_t const * p_fs, /* Clear the flag before sending the event, to allow API calls in the event context. */ (void) nrf_atomic_flag_clear(&m_flash_operation_ongoing); - event_send(p_fs, NRF_FSTORAGE_EVT_WRITE_RESULT, dest, len, p_param); + event_send(p_fs, NRF_FSTORAGE_EVT_WRITE_RESULT, p_src, dest, len, p_param); return NRF_SUCCESS; } @@ -166,7 +168,7 @@ static ret_code_t erase(nrf_fstorage_t const * p_fs, /* Clear the flag before sending the event, to allow API calls in the event context. */ (void) nrf_atomic_flag_clear(&m_flash_operation_ongoing); - event_send(p_fs, NRF_FSTORAGE_EVT_ERASE_RESULT, page_addr, len, p_param); + event_send(p_fs, NRF_FSTORAGE_EVT_ERASE_RESULT, NULL, page_addr, len, p_param); return NRF_SUCCESS; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_nvmc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_nvmc.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_nvmc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_nvmc.h index be34775..2e97b38 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_nvmc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_nvmc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_sd.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_sd.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_sd.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_sd.c index 6b75b36..743cf00 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_sd.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_sd.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -67,7 +67,7 @@ typedef enum NRF_FSTORAGE_OP_ERASE //!< Erase flash pages. } nrf_fstorage_sd_opcode_t; -ANON_UNIONS_ENABLE +ANON_UNIONS_ENABLE; /**@brief fstorage operation queue element. */ typedef struct { @@ -91,7 +91,7 @@ typedef struct } erase; }; } nrf_fstorage_sd_op_t; -ANON_UNIONS_DISABLE +ANON_UNIONS_DISABLE; typedef enum { @@ -173,9 +173,10 @@ static void event_send(nrf_fstorage_sd_op_t const * p_op, ret_code_t result) switch (p_op->op_code) { case NRF_FSTORAGE_OP_WRITE: - evt.id = NRF_FSTORAGE_EVT_WRITE_RESULT; - evt.addr = p_op->write.dest; - evt.len = p_op->write.len; + evt.id = NRF_FSTORAGE_EVT_WRITE_RESULT; + evt.addr = p_op->write.dest; + evt.p_src = p_op->write.p_src; + evt.len = p_op->write.len; break; case NRF_FSTORAGE_OP_ERASE: @@ -235,6 +236,8 @@ static bool queue_load_next(void) /* Execute an operation in the queue. */ static void queue_process(void) { + uint32_t rc; + if (m_flags.state == NRF_FSTORAGE_STATE_IDLE) { if (!queue_load_next()) @@ -247,7 +250,6 @@ static void queue_process(void) m_flags.state = NRF_FSTORAGE_STATE_OP_EXECUTING; - uint32_t rc; switch (m_p_cur_op->op_code) { case NRF_FSTORAGE_OP_WRITE: @@ -285,11 +287,13 @@ static void queue_process(void) default: { - /* An error has occurred. We cannot proceed further with this operation. - * Reset the internal state so we can accept other operations. */ + /* An error has occurred. We cannot proceed further with this operation. */ event_send(m_p_cur_op, NRF_ERROR_INTERNAL); + /* Reset the internal state so we can accept other operations. */ m_flags.state = NRF_FSTORAGE_STATE_IDLE; m_flags.queue_running = false; + /* Free the current queue element. */ + queue_free(); } break; } } @@ -298,9 +302,7 @@ static void queue_process(void) /* Start processing the queue if it is not running and fstorage is not paused. */ static void queue_start(void) { - nrf_atomic_flag_t queue_running = nrf_atomic_u32_fetch_store(&m_flags.queue_running, true); - - if ( (!queue_running) + if ( (!nrf_atomic_flag_set_fetch(&m_flags.queue_running)) && (!m_flags.paused)) { queue_process(); @@ -372,14 +374,13 @@ static ret_code_t init(nrf_fstorage_t * p_fs, void * p_param) { UNUSED_PARAMETER(p_param); + p_fs->p_flash_info = &m_flash_info; + if (!nrf_atomic_flag_set_fetch(&m_flags.initialized)) { - p_fs->p_flash_info = &m_flash_info; - #if NRF_SDH_ENABLED m_flags.sd_enabled = nrf_sdh_is_enabled(); #endif - (void) NRF_ATFIFO_INIT(m_fifo); } @@ -511,8 +512,25 @@ void nrf_fstorage_sys_evt_handler(uint32_t sys_evt, void * p_context) { UNUSED_PARAMETER(p_context); + if ( (sys_evt != NRF_EVT_FLASH_OPERATION_SUCCESS) + && (sys_evt != NRF_EVT_FLASH_OPERATION_ERROR)) + { + /* Ignore any non-flash events. */ + return; + } + switch (m_flags.state) { + case NRF_FSTORAGE_STATE_IDLE: + /* Ignore flash events if no flash operation was requested. */ + return; + + case NRF_FSTORAGE_STATE_OP_PENDING: + /* The SoftDevice has completed a flash operation that was not requested by fstorage. + * It should be possible to request an operation now. + * Process the queue at the end of this function. */ + break; + case NRF_FSTORAGE_STATE_OP_EXECUTING: { /* Handle the result of a flash operation initiated by this module. */ @@ -547,16 +565,6 @@ void nrf_fstorage_sys_evt_handler(uint32_t sys_evt, void * p_context) queue_free(); } } break; - - case NRF_FSTORAGE_STATE_OP_PENDING: - /* The SoftDevice has completed a flash operation that was not requested by fstorage. - * It should be possible to request an operation now. - * Process the queue at the end of this function. */ - break; - - default: - /* If idle, return. */ - return; } if (!m_flags.paused) @@ -565,7 +573,7 @@ void nrf_fstorage_sys_evt_handler(uint32_t sys_evt, void * p_context) } else { - /* A flash operation has completed. Let the SoftDevice to change state. */ + /* A flash operation has completed. Let the SoftDevice change state. */ (void) nrf_sdh_request_continue(); } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_sd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_sd.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_sd.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_sd.h index 27f2789..e280408 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/fstorage/nrf_fstorage_sd.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/fstorage/nrf_fstorage_sd.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_gfx.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_gfx.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_gfx.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_gfx.c index bcf4e8e..bd7aefe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_gfx.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_gfx.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -191,7 +191,7 @@ static void write_character(nrf_lcd_t const * p_instance, ret_code_t nrf_gfx_init(nrf_lcd_t const * p_instance) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state == NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state == NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_instance->lcd_init != NULL); ASSERT(p_instance->lcd_uninit != NULL); ASSERT(p_instance->lcd_pixel_draw != NULL); @@ -207,7 +207,7 @@ ret_code_t nrf_gfx_init(nrf_lcd_t const * p_instance) if (err_code == NRF_SUCCESS) { - p_instance->p_lcd_cb->state = NRF_DRV_STATE_INITIALIZED; + p_instance->p_lcd_cb->state = NRFX_DRV_STATE_INITIALIZED; } return err_code; @@ -216,9 +216,9 @@ ret_code_t nrf_gfx_init(nrf_lcd_t const * p_instance) void nrf_gfx_uninit(nrf_lcd_t const * p_instance) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); - p_instance->p_lcd_cb->state = NRF_DRV_STATE_UNINITIALIZED; + p_instance->p_lcd_cb->state = NRFX_DRV_STATE_UNINITIALIZED; p_instance->lcd_uninit(); } @@ -228,7 +228,7 @@ void nrf_gfx_point_draw(nrf_lcd_t const * p_instance, uint32_t color) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_point != NULL); pixel_draw(p_instance, p_point->x, p_point->y, color); @@ -239,7 +239,7 @@ ret_code_t nrf_gfx_line_draw(nrf_lcd_t const * p_instance, uint32_t color) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_line != NULL); uint16_t x_thick = 0; @@ -317,7 +317,7 @@ ret_code_t nrf_gfx_circle_draw(nrf_lcd_t const * p_instance, bool fill) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_circle != NULL); int16_t y = 0; @@ -383,7 +383,7 @@ ret_code_t nrf_gfx_rect_draw(nrf_lcd_t const * p_instance, bool fill) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_rect != NULL); uint16_t rect_width = p_rect->width - thickness; @@ -453,7 +453,7 @@ ret_code_t nrf_gfx_bmp565_draw(nrf_lcd_t const * p_instance, uint16_t const * img_buf) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_rect != NULL); ASSERT(img_buf != NULL); @@ -484,7 +484,7 @@ ret_code_t nrf_gfx_bmp565_draw(nrf_lcd_t const * p_instance, void nrf_gfx_background_set(nrf_lcd_t const * p_instance, uint16_t const * img_buf) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(img_buf != NULL); const nrf_gfx_rect_t rectangle = @@ -508,7 +508,7 @@ void nrf_gfx_display(nrf_lcd_t const * p_instance) void nrf_gfx_rotation_set(nrf_lcd_t const * p_instance, nrf_lcd_rotation_t rotation) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); bool rotated = (bool)(p_instance->p_lcd_cb->rotation % 2); @@ -558,7 +558,7 @@ ret_code_t nrf_gfx_print(nrf_lcd_t const * p_instance, bool wrap) { ASSERT(p_instance != NULL); - ASSERT(p_instance->p_lcd_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_instance->p_lcd_cb->state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_point != NULL); ASSERT(string != NULL); ASSERT(p_font != NULL); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_gfx.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_gfx.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_gfx.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_gfx.h index caf42ef..ccf22cb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_gfx.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_gfx.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_GFX_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_lcd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_lcd.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_lcd.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_lcd.h index 8e37cae..df9d50d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gfx/nrf_lcd.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gfx/nrf_lcd.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,13 +35,13 @@ * 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 NRF_LCD_H__ #define NRF_LCD_H__ -#include "nrf_drv_common.h" +#include /** @file * @@ -67,7 +67,7 @@ typedef enum{ */ typedef struct { - nrf_drv_state_t state; /**< State of LCD instance. */ + nrfx_drv_state_t state; /**< State of LCD instance. */ uint16_t height; /**< LCD height. */ uint16_t width; /**< LCD width. */ nrf_lcd_rotation_t rotation; /**< LCD rotation. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gpiote/app_gpiote.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gpiote/app_gpiote.c similarity index 77% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gpiote/app_gpiote.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gpiote/app_gpiote.c index 6544e66..61865f7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gpiote/app_gpiote.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gpiote/app_gpiote.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,12 +35,11 @@ * 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(APP_GPIOTE) #include "app_gpiote.h" -#include "nrf_drv_gpiote.h" #include "nrf_bitmask.h" #define MODULE_INITIALIZED (mp_users != NULL) /**< Macro designating whether the module has been initialized properly. */ @@ -130,15 +129,11 @@ uint32_t app_gpiote_user_register(app_gpiote_user_id_t * p_user_id, app_gpiote_event_handler_t event_handler) { uint32_t user_pin_mask[GPIO_COUNT]; - uint32_t ret_val = NRF_SUCCESS; + ASSERT(event_handler != NULL); // Check state and parameters. VERIFY_MODULE_INITIALIZED(); - if (event_handler == NULL) - { - return NRF_ERROR_INVALID_PARAM; - } if (m_user_count >= m_user_array_size) { return NRF_ERROR_NO_MEM; @@ -147,16 +142,18 @@ uint32_t app_gpiote_user_register(app_gpiote_user_id_t * p_user_id, nrf_bitmask_masks_or(p_pins_low_to_high_mask, p_pins_high_to_low_mask, user_pin_mask, sizeof(user_pin_mask)); // Allocate new user. + mp_users[m_user_count].enabled = false; + mp_users[m_user_count].event_handler = event_handler; + memcpy(mp_users[m_user_count].pins_mask, - user_pin_mask, sizeof(mp_users[m_user_count].pins_mask)); + user_pin_mask, + sizeof(mp_users[m_user_count].pins_mask)); memcpy(mp_users[m_user_count].pins_low_to_high_mask, - p_pins_low_to_high_mask, sizeof(mp_users[m_user_count].pins_low_to_high_mask)); + p_pins_low_to_high_mask, + sizeof(mp_users[m_user_count].pins_low_to_high_mask)); memcpy(mp_users[m_user_count].pins_high_to_low_mask, - p_pins_high_to_low_mask, sizeof(mp_users[m_user_count].pins_high_to_low_mask)); - mp_users[m_user_count].event_handler = event_handler; - mp_users[m_user_count].enabled = false; - - *p_user_id = m_user_count++; + p_pins_high_to_low_mask, + sizeof(mp_users[m_user_count].pins_high_to_low_mask)); uint32_t i; const nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); @@ -167,12 +164,71 @@ uint32_t app_gpiote_user_register(app_gpiote_user_id_t * p_user_id, if (nrf_bitmask_bit_is_set(i, user_pin_mask) && !nrf_bitmask_bit_is_set(i, m_pins)) { - ret_val = nrf_drv_gpiote_in_init(i, &config, gpiote_handler); + uint32_t ret_val = nrf_drv_gpiote_in_init(i, &config, gpiote_handler); VERIFY_SUCCESS(ret_val); nrf_bitmask_bit_set(i, m_pins); } } - return ret_val; + + /* Success - return user id and increment counter */ + *p_user_id = m_user_count++; + return NRF_SUCCESS; +} + +uint32_t app_gpiote_user_register_ex(app_gpiote_user_id_t * p_user_id, + app_gpiote_user_pin_config_t const * p_pins_config, + size_t pin_count, + app_gpiote_event_handler_t event_handler) +{ + ASSERT(event_handler != NULL); + + // Check state and parameters. + VERIFY_MODULE_INITIALIZED(); + if (m_user_count >= m_user_array_size) + { + return NRF_ERROR_NO_MEM; + } + /* Prepare user structure */ + gpiote_user_t * p_user = &mp_users[m_user_count]; + + p_user->enabled = false; + memset(p_user, 0, sizeof(gpiote_user_t)); + mp_users[m_user_count].event_handler = event_handler; + + for (; pin_count != 0; --pin_count, ++p_pins_config) + { + nrfx_gpiote_pin_t pin = (nrfx_gpiote_pin_t)p_pins_config->pin_number; + const nrf_drv_gpiote_in_config_t config = GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE(false); + if (!nrf_bitmask_bit_is_set(pin, m_pins)) + { + uint32_t ret_val = nrf_drv_gpiote_in_init(pin, &config, gpiote_handler); + VERIFY_SUCCESS(ret_val); + nrf_bitmask_bit_set(pin, m_pins); + } + + //lint -save -e650 Lint seems not properly support bitfields that uses enum as a base type + if ((p_pins_config->sense == NRF_GPIOTE_POLARITY_LOTOHI) || + (p_pins_config->sense == NRF_GPIOTE_POLARITY_TOGGLE)) + { + nrf_bitmask_bit_set(pin, p_user->pins_low_to_high_mask); + } + if ((p_pins_config->sense == NRF_GPIOTE_POLARITY_HITOLO) || + (p_pins_config->sense == NRF_GPIOTE_POLARITY_TOGGLE)) + { + nrf_bitmask_bit_set(pin, p_user->pins_high_to_low_mask); + } + //lint -restore + } + /* Mark all pins used by the selected user */ + nrf_bitmask_masks_or( + p_user->pins_low_to_high_mask, + p_user->pins_high_to_low_mask, + p_user->pins_mask, + sizeof(p_user->pins_mask)); + /* Success - return user id and increment counter */ + *p_user_id = m_user_count++; + + return NRF_SUCCESS; } __STATIC_INLINE uint32_t error_check(app_gpiote_user_id_t user_id) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gpiote/app_gpiote.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gpiote/app_gpiote.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gpiote/app_gpiote.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gpiote/app_gpiote.h index 5c70da2..22e5a5e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/gpiote/app_gpiote.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/gpiote/app_gpiote.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -70,6 +70,7 @@ #include #include #include "nrf.h" +#include "nrf_drv_gpiote.h" #include "app_error.h" #include "app_util.h" @@ -96,6 +97,32 @@ typedef void (*app_gpiote_event_handler_t)(uint32_t const * p_event_pins_low_to_ /**@brief GPIOTE input event handler type. */ typedef void (*app_gpiote_input_event_handler_t)(void); + +/* Make the pin config descriptor packed */ +#pragma pack(push, 1) + +/** + * @brief Single pin configuration + * + * Structure used to describe single pin configuration + * when registering user. + * @sa app_gpiote_user_register_ex + */ +typedef struct +{ + /** Pin number to observe */ + uint32_t pin_number : VBITS(NRF_GPIO_PIN_MAP(GPIO_COUNT - 1, 31)); + /** Transition to observe */ + nrf_gpiote_polarity_t sense : 2; +} app_gpiote_user_pin_config_t; + +// Check if we can fitt all the nrf_gpiote_polarity_t values into 2 bits field +STATIC_ASSERT(NRF_GPIOTE_POLARITY_LOTOHI <= 3); +STATIC_ASSERT(NRF_GPIOTE_POLARITY_HITOLO <= 3); +STATIC_ASSERT(NRF_GPIOTE_POLARITY_TOGGLE <= 3); + +#pragma pack(pop) + /**@brief Macro for initializing the GPIOTE module. * * @details It will handle dimensioning and allocation of the memory buffer required by the module, @@ -144,20 +171,54 @@ uint32_t app_gpiote_init(uint8_t max_users, void * p_buffer); * from high->low. Size of array depends on number of ports * in the device. * @param[in] event_handler Pointer to function to be executed when an event occurs. + * Cannot be NULL. * * @retval NRF_SUCCESS Successful initialization. - * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte boundary). * @retval NRF_ERROR_INALID_STATE If @ref app_gpiote_init has not been called on the GPIOTE * module. * @retval NRF_ERROR_NO_MEM Returned if the application tries to register more users * than defined when the GPIOTE module was initialized in * @ref app_gpiote_init. + * + * @note The function can also return error codes from internally + * called @ref nrf_drv_gpiote_in_init + * + * @sa app_gpiote_user_register_ex */ uint32_t app_gpiote_user_register(app_gpiote_user_id_t * p_user_id, uint32_t const * p_pins_low_to_high_mask, uint32_t const * p_pins_high_to_low_mask, app_gpiote_event_handler_t event_handler); +/**@brief Function for registering GPIOTE user using pins configuration list. + * + * Function for registering GPIOTE user that uses array of pins configuration. + * This function do not change pins configuration. + * Pins must be configured before calling this function. + * + * @param[out] p_user_id Id for the new GPIOTE user. + * @param[in] p_pins_config Pointer to the array of pins configuration for the user. + * @param[in] pin_count Number of pins to configure for the user. + * @param[in] event_handler Pointer to function to be executed when an event occurs. + * Cannot be NULL. + * + * @retval NRF_SUCCESS Successful user registration. + * @retval NRF_ERROR_INVALID_STATE If @ref app_gpiote_init has not been called before calling + * this function. + * @retval NRF_ERROR_NO_MEM Returned if the application tries to register more users + * than defined when the GPIOTE module was initialized in + * @ref app_gpiote_init. + * + * @note The function can also return error codes from internally + * called @ref nrf_drv_gpiote_in_init + * + * @sa app_gpiote_user_register + */ +uint32_t app_gpiote_user_register_ex(app_gpiote_user_id_t * p_user_id, + app_gpiote_user_pin_config_t const * p_pins_config, + size_t pin_count, + app_gpiote_event_handler_t event_handler); + /**@brief Function for informing the GPIOTE module that the specified user wants to use the GPIOTE module. * * @param[in] user_id Id of user to enable. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault.h index 9a081ac..52edd36 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 HARDFAULT_H__ #define HARDFAULT_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault_genhf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault_genhf.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault_genhf.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault_genhf.h index 57ba61a..c772cdb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault_genhf.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault_genhf.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 HARDFAULT_GENHF_H__ #define HARDFAULT_GENHF_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault_implementation.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault_implementation.c similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault_implementation.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault_implementation.c index 8958d8c..dfb3787 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/hardfault_implementation.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/hardfault_implementation.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) @@ -51,15 +51,6 @@ #include "nrf_log_ctrl.h" NRF_LOG_MODULE_REGISTER(); -#if defined(DEBUG_NRF) -/** - * @brief Pointer to the last received stack pointer. - * - * This pointer is set in the debug version of the HardFault handler. - * It helps to debug HardFault reasons. - */ -volatile HardFault_stack_t * HardFault_p_stack; -#endif /*lint -save -e14 */ __WEAK void HardFault_process(HardFault_stack_t * p_stack) @@ -83,8 +74,6 @@ void HardFault_c_handler(uint32_t * p_stack_address) #define CFSR_BFARVALID (1 << (8 + 7)) #endif - #if defined(DEBUG) - HardFault_stack_t * p_stack = (HardFault_stack_t *)p_stack_address; static const char *cfsr_msgs[] = { [0] = "The processor has attempted to execute an undefined instruction", @@ -117,12 +106,19 @@ void HardFault_c_handler(uint32_t * p_stack_address) uint32_t cfsr = SCB->CFSR; - // Print information about error. - NRF_LOG_ERROR("HARD FAULT at 0x%08X", p_stack->pc); - NRF_LOG_ERROR(" R0: 0x%08X R1: 0x%08X R2: 0x%08X R3: 0x%08X", - p_stack->r0, p_stack->r1, p_stack->r2, p_stack->r3); - NRF_LOG_ERROR(" R12: 0x%08X LR: 0x%08X PSR: 0x%08X", - p_stack->r12, p_stack->lr, p_stack->psr); + if (p_stack != NULL) + { + // Print information about error. + NRF_LOG_ERROR("HARD FAULT at 0x%08X", p_stack->pc); + NRF_LOG_ERROR(" R0: 0x%08X R1: 0x%08X R2: 0x%08X R3: 0x%08X", + p_stack->r0, p_stack->r1, p_stack->r2, p_stack->r3); + NRF_LOG_ERROR(" R12: 0x%08X LR: 0x%08X PSR: 0x%08X", + p_stack->r12, p_stack->lr, p_stack->psr); + } + else + { + NRF_LOG_ERROR("Stack violation: stack pointer outside stack area."); + } if (SCB->HFSR & SCB_HFSR_VECTTBL_Msk) { @@ -147,6 +143,8 @@ void HardFault_c_handler(uint32_t * p_stack_address) NRF_LOG_ERROR("Bus Fault Address: 0x%08X", SCB->BFAR); } +#if defined(DEBUG) + NRF_BREAKPOINT_COND; #endif // defined (DEBUG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c index 5655828..501d50d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_gcc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c index 8ac8f47..db26bdc 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_iar.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c index 721e8af..47e2229 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf51/handler/hardfault_handler_keil.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c index 7626540..10d10dd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) @@ -74,25 +74,8 @@ void HardFault_Handler(void) " mov r0, #0 \n" "HardFault_Handler_Continue: \n" -#if HARDFAULT_HANDLER_GDB_PSP_BACKTRACE - " mov r3, sp \n" /* Remember old SP */ - " mov sp, r0 \n" /* SP changed the pointer when hardfault was generated - we cannot just switch to PSP in exception */ - " push {r3,lr} \n" /* Save old SP and LR on the task stack */ -#if !defined(__SES_ARM) - " .cfi_def_cfa_offset 8 \n" - " .cfi_offset 14, -4 \n" -#endif - /* No information about saved SP above (no .cfi_offset 13, -8). - * In other case this would direct us back to using always MSP while backtracking */ - " ldr r3, =%0 \n" - " blx r3 \n" - " pop {r3,lr} \n" - " mov sp, r3 \n" - " bx lr \n" -#else // HARDFAULT_HANDLER_GDB_PSP_BACKTRACE " ldr r3, =%0 \n" " bx r3 \n" -#endif " .ltorg \n" : : "X"(HardFault_c_handler) ); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c index a0547fd..dad26ab 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_iar.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c index c9437ce..10b4ec2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hardfault/nrf52/handler/hardfault_handler_keil.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HARDFAULT_HANDLER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_mem_pool.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_mem_pool.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_mem_pool.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_mem_pool.c index 8c686e7..15c6b95 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_mem_pool.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_mem_pool.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HCI_MEM_POOL) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_mem_pool.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_mem_pool.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_mem_pool.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_mem_pool.h index 9576236..1b89626 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_mem_pool.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_mem_pool.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_slip.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_slip.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_slip.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_slip.c index ca32633..bd49de3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_slip.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_slip.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HCI_SLIP) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_slip.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_slip.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_slip.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_slip.h index 88ce05f..7f52dd1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_slip.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_slip.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_transport.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_transport.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_transport.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_transport.c index 7e1b8bf..f33952e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_transport.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_transport.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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(HCI_TRANSPORT) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_transport.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_transport.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_transport.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_transport.h index ce490c5..b15a87d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/hci/hci_transport.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/hci/hci_transport.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/led_softblink/led_softblink.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/led_softblink/led_softblink.c similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/led_softblink/led_softblink.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/led_softblink/led_softblink.c index 1a43f48..6cf303a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/led_softblink/led_softblink.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/led_softblink/led_softblink.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(LED_SOFTBLINK) @@ -56,7 +56,7 @@ typedef struct { bool leds_is_on; /**< Flag for indicating if LEDs are on. */ bool is_counting_up; /**< Flag for indicating if counter is incrementing or decrementing. */ - nrf_drv_state_t led_sb_state; /**< Indicates current state of instance. */ + nrfx_drv_state_t led_sb_state; /**< Indicates current state of instance. */ uint16_t duty_cycle; /**< Current pulse width. */ uint32_t bit_mask; /**< Mask of used pins. */ led_sb_init_params_t params; /**< Structure holding initialization parameters. */ @@ -64,6 +64,8 @@ typedef struct low_power_pwm_t pwm_instance; /**< Structure holding low-power PWM instance parameters. */ }led_sb_context_t; +APP_TIMER_DEF(m_led_softblink_timer); + static led_sb_context_t m_led_sb = {0}; /**@brief Timer event handler for softblink. @@ -75,7 +77,7 @@ static led_sb_context_t m_led_sb = {0}; static void led_softblink_on_timeout(void * p_context) { static int32_t pause_ticks; - ASSERT(m_led_sb.led_sb_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_led_sb.led_sb_state != NRFX_DRV_STATE_UNINITIALIZED); ret_code_t err_code; if (pause_ticks <= 0) @@ -124,7 +126,7 @@ ret_code_t led_softblink_init(led_sb_init_params_t const * p_init_params) { ret_code_t err_code; - ASSERT(m_led_sb.led_sb_state == NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_led_sb.led_sb_state == NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_init_params); if ( (p_init_params->duty_cycle_max == 0) || @@ -145,19 +147,17 @@ ret_code_t led_softblink_init(led_sb_init_params_t const * p_init_params) m_led_sb.leds_is_on = false; m_led_sb.bit_mask = p_init_params->leds_pin_bm; - APP_TIMER_DEF(led_softblink_timer); - m_led_sb.pwm_config.active_high = m_led_sb.params.active_high; m_led_sb.pwm_config.bit_mask = p_init_params->leds_pin_bm; m_led_sb.pwm_config.p_port = p_init_params->p_leds_port; m_led_sb.pwm_config.period = PWM_PERIOD; - m_led_sb.pwm_config.p_timer_id = &led_softblink_timer; + m_led_sb.pwm_config.p_timer_id = &m_led_softblink_timer; err_code = low_power_pwm_init( &m_led_sb.pwm_instance, &m_led_sb.pwm_config, led_softblink_on_timeout); if (err_code == NRF_SUCCESS) { - m_led_sb.led_sb_state = NRF_DRV_STATE_INITIALIZED; + m_led_sb.led_sb_state = NRFX_DRV_STATE_INITIALIZED; } else { @@ -174,7 +174,7 @@ ret_code_t led_softblink_start(uint32_t leds_pin_bit_mask) { ret_code_t err_code; - ASSERT(m_led_sb.led_sb_state == NRF_DRV_STATE_INITIALIZED); + ASSERT(m_led_sb.led_sb_state == NRFX_DRV_STATE_INITIALIZED); err_code = low_power_pwm_start(&m_led_sb.pwm_instance, leds_pin_bit_mask); @@ -194,7 +194,7 @@ ret_code_t led_softblink_stop(void) void led_softblink_off_time_set(uint32_t off_time_ticks) { - ASSERT(m_led_sb.led_sb_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_led_sb.led_sb_state != NRFX_DRV_STATE_UNINITIALIZED); m_led_sb.params.off_time_ticks = off_time_ticks; } @@ -202,7 +202,7 @@ void led_softblink_off_time_set(uint32_t off_time_ticks) void led_softblink_on_time_set(uint32_t on_time_ticks) { - ASSERT(m_led_sb.led_sb_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_led_sb.led_sb_state != NRFX_DRV_STATE_UNINITIALIZED); m_led_sb.params.on_time_ticks = on_time_ticks; } @@ -210,7 +210,7 @@ void led_softblink_on_time_set(uint32_t on_time_ticks) ret_code_t led_softblink_uninit(void) { - ASSERT(m_led_sb.led_sb_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(m_led_sb.led_sb_state != NRFX_DRV_STATE_UNINITIALIZED); ret_code_t err_code; @@ -218,7 +218,7 @@ ret_code_t led_softblink_uninit(void) if (err_code == NRF_SUCCESS) { - m_led_sb.led_sb_state = NRF_DRV_STATE_UNINITIALIZED; + m_led_sb.led_sb_state = NRFX_DRV_STATE_UNINITIALIZED; } else { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/led_softblink/led_softblink.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/led_softblink/led_softblink.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/led_softblink/led_softblink.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/led_softblink/led_softblink.h index 5277b9c..7fe3b91 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/led_softblink/led_softblink.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/led_softblink/led_softblink.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.c new file mode 100644 index 0000000..277236f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.c @@ -0,0 +1,658 @@ +/** + * Copyright (c) 2019, 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_config.h" +#include "nrf_libuarte_async.h" +#include "app_error.h" +#include "nrf_balloc.h" +#include "nrfx_timer.h" +#include "nrfx_rtc.h" +#include "nrfx_ppi.h" +#include "nrf_uart.h" +#include "nrf_queue.h" +#define NRF_LOG_MODULE_NAME libUARTE_async +#if NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#else // NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // NRF_LIBUARTE_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#if defined(NRFX_RTC_ENABLED) && NRFX_RTC_ENABLED +#define RTC_IN_USE 1 +#else +#define RTC_IN_USE 0 +#endif + +#if defined(NRFX_TIMER_ENABLED) && NRFX_TIMER_ENABLED +#define TIMER_IN_USE 1 +#else +#define TIMER_IN_USE 0 +#endif + +#define FAULT_IRQ_LEVEL 0xFF + +/** Macro is setting up PPI channel set which consist of event, task and optional fork. + * + * @param _ch Channel. + * @param _evt Event. + * @param _tsk Task. + * @param _fork Fork. If NULL fork is not configured. + */ +#define PPI_CH_SETUP(_ch, _evt, _tsk, _fork) \ + ret = nrfx_ppi_channel_assign(_ch, _evt, _tsk); \ + if (ret != NRF_SUCCESS) \ + { \ + return NRF_ERROR_INTERNAL; \ + } \ + if (_fork) \ + { \ + ret = nrfx_ppi_channel_fork_assign(_ch, _fork); \ + if (ret != NRF_SUCCESS) \ + { \ + return NRF_ERROR_INTERNAL; \ + } \ + } + +/* @brief Function returns interrupt level which is the next,lower priority. + * + * If SoftDevice is present then it takes into account which priorities are used + * by the SoftDevice. + * + * @note Caller of this function does not check if error is returned. Error is returned if input + * priority belongs to SoftDevice. In that case SoftDevice will detect attempt to interrupt level + * misuse. + * + * @param prio Interrupt priority. + * + * @return Priority which is one level lower or fault indicator (0xFF). + */ +static uint8_t irq_prio_inc(uint8_t prio) +{ +#ifdef SOFTDEVICE_PRESENT + static const uint8_t sd_next_irq_lut[] = { + FAULT_IRQ_LEVEL, /* 0 used by softdevice */ + FAULT_IRQ_LEVEL, /* 1 used by softdevice */ + APP_IRQ_PRIORITY_MID, /* 2 + 1 = 3 */ + APP_IRQ_PRIORITY_LOW_MID, /* 3 + 1 = 5 as 4 is used by softdevice */ + FAULT_IRQ_LEVEL, /* 4 used by softdevice */ + APP_IRQ_PRIORITY_LOW /* 5 + 1 = 6 */, + APP_IRQ_PRIORITY_LOWEST, /* 6 + 1 = 7 */ + }; + return sd_next_irq_lut[prio]; +#else + return prio + 1; +#endif +} + +#if NRF_LIBUARTE_ASYNC_WITH_APP_TIMER +static void app_timer_handler(void * p_context); +#define local_app_timer_cnt_get() app_timer_cnt_get() +#define local_app_timer_start(p_timer, ticks, p_context) app_timer_start(p_timer, ticks, p_context) +#define local_app_timer_stop(p_timer) app_timer_stop(p_timer) +#define local_app_timer_create(p_timer) app_timer_create(p_timer, APP_TIMER_MODE_SINGLE_SHOT, app_timer_handler) +#define local_app_timer_cnt_diff_compute(to, from) app_timer_cnt_diff_compute(to, from) +#else +#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY +#define APP_TIMER_CONFIG_RTC_FREQUENCY 0 +#endif + +#ifndef APP_TIMER_CLOCK_FREQ +#define APP_TIMER_CLOCK_FREQ 1 +#endif + +#ifndef APP_TIMER_MIN_TIMEOUT_TICKS +#define APP_TIMER_MIN_TIMEOUT_TICKS 0 +#endif + +#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY +#define APP_TIMER_CONFIG_IRQ_PRIORITY 1 +#endif +static void app_timer_handler(void * p_context) __attribute__((unused)); +#define local_app_timer_cnt_get() 0 +#define local_app_timer_start(p_timer, ticks, p_context) NRF_SUCCESS +#define local_app_timer_stop(p_timer) NRF_SUCCESS +#define local_app_timer_create(p_timer) NRF_SUCCESS +#define local_app_timer_cnt_diff_compute(to, from) 0 +#endif + +static uint32_t app_timer_ticks_to_us(uint32_t ticks) +{ + return (uint32_t)(((uint64_t)ticks * 1000000 * (APP_TIMER_CONFIG_RTC_FREQUENCY + 1)) / + APP_TIMER_CLOCK_FREQ); +} + +static uint32_t app_timer_us_to_ticks(uint32_t us) +{ + return (uint32_t)((((uint64_t)APP_TIMER_CLOCK_FREQ/(APP_TIMER_CONFIG_RTC_FREQUENCY + 1)) * us) / + 1000000); +} + +static bool rx_buffer_schedule(const nrf_libuarte_async_t * p_libuarte) +{ + uint8_t * p_data = nrf_balloc_alloc(p_libuarte->p_rx_pool); + + if (p_data == NULL) + { + return false; + } + + ret_code_t ret = nrf_queue_push(p_libuarte->p_rx_queue, &p_data); + if (ret != NRF_SUCCESS) + { + NRF_LOG_ERROR("RX buffer queue full."); + return false; + } + + p_libuarte->p_ctrl_blk->alloc_cnt++; + nrf_libuarte_drv_rx_buf_rsp(p_libuarte->p_libuarte, p_data, p_libuarte->rx_buf_size); + + return true; +} + +static void uart_evt_handler(void * context, nrf_libuarte_drv_evt_t * p_evt) +{ + ret_code_t ret; + const nrf_libuarte_async_t * p_libuarte = (const nrf_libuarte_async_t *)context; + + switch (p_evt->type) + { + case NRF_LIBUARTE_DRV_EVT_TX_DONE: + { + NRF_LOG_DEBUG("(evt) TX completed (%d)", p_evt->data.rxtx.length); + nrf_libuarte_async_evt_t evt = { + .type = NRF_LIBUARTE_ASYNC_EVT_TX_DONE, + .data = { + .rxtx = { + .p_data = p_evt->data.rxtx.p_data, + .length = p_evt->data.rxtx.length, + } + } + }; + p_libuarte->p_ctrl_blk->evt_handler(p_libuarte->p_ctrl_blk->context, &evt); + break; + } + case NRF_LIBUARTE_DRV_EVT_RX_BUF_REQ: + { + if (p_libuarte->p_ctrl_blk->rx_halted) + { + break; + } + + if (rx_buffer_schedule(p_libuarte) == false) + { + if (p_libuarte->p_ctrl_blk->hwfc) + { + p_libuarte->p_ctrl_blk->rx_halted = true; + } + else + { + NRF_LOG_ERROR("(evt) Failed to allocate buffer for RX."); + APP_ERROR_CHECK_BOOL(false); + } + } + break; + } + case NRF_LIBUARTE_DRV_EVT_RX_DATA: + { + + uint32_t rx_amount = p_evt->data.rxtx.length - p_libuarte->p_ctrl_blk->sub_rx_count; + if (rx_amount) + { + p_libuarte->p_ctrl_blk->rx_count += rx_amount; + nrf_libuarte_async_evt_t evt = { + .type = NRF_LIBUARTE_ASYNC_EVT_RX_DATA, + .data = { + .rxtx = { + .p_data = &p_evt->data.rxtx.p_data[p_libuarte->p_ctrl_blk->sub_rx_count], + .length = rx_amount, + } + } + }; + NRF_LOG_DEBUG("(evt) RX: %d (addr:0x%08X, internal index: %d)", + rx_amount, + p_evt->data.rxtx.p_data, + p_libuarte->p_ctrl_blk->sub_rx_count); + + p_libuarte->p_ctrl_blk->sub_rx_count = 0; + + if(p_evt->data.rxtx.p_data != p_libuarte->p_ctrl_blk->p_curr_rx_buf) + { + NRF_LOG_ERROR("(evt) RX buffer address mismatch"); + } + + ret = nrf_queue_pop(p_libuarte->p_rx_queue, &p_libuarte->p_ctrl_blk->p_curr_rx_buf); + if (ret != NRF_SUCCESS) + { + NRF_LOG_ERROR("RX buffer queue empty."); + APP_ERROR_CHECK_BOOL(false); + } + + p_libuarte->p_ctrl_blk->evt_handler(p_libuarte->p_ctrl_blk->context, &evt); + } + else + { + NRF_LOG_ERROR("(evt) RX with 0 length: 0x%08X", p_evt->data.rxtx.p_data); + //zero length packet is freed immediately and not forwarded to the application. + APP_ERROR_CHECK_BOOL(false); + } + break; + } + case NRF_LIBUARTE_DRV_EVT_ERROR: + { + nrf_libuarte_async_evt_t evt = { + .type = NRF_LIBUARTE_ASYNC_EVT_ERROR + }; + p_libuarte->p_ctrl_blk->evt_handler(p_libuarte->p_ctrl_blk->context, &evt); + break; + } + case NRF_LIBUARTE_DRV_EVT_OVERRUN_ERROR: + { + NRF_LOG_WARNING("Overrun error - data loss due to UARTE interrupt not handled on time."); + uint32_t rx_amount = p_evt->data.overrun_err.overrun_length - p_libuarte->p_ctrl_blk->sub_rx_count; + p_libuarte->p_ctrl_blk->rx_count += rx_amount; + nrf_libuarte_async_evt_t evt = { + .type = NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR, + .data = { + .overrun_err = { .overrun_length = p_evt->data.overrun_err.overrun_length} + } + }; + p_libuarte->p_ctrl_blk->evt_handler(p_libuarte->p_ctrl_blk->context, &evt); + break; + } + default: + APP_ERROR_CHECK_BOOL(false); + break; + } +} + +void nrf_libuarte_async_timeout_handler(const nrf_libuarte_async_t * p_libuarte) +{ + NRFX_IRQ_DISABLE((IRQn_Type)NRFX_IRQ_NUMBER_GET(p_libuarte->p_libuarte->uarte)); + + uint32_t capt_rx_count = p_libuarte->p_libuarte->timer.p_reg->CC[3]; + + if (capt_rx_count > p_libuarte->p_ctrl_blk->rx_count) + { + uint32_t rx_amount = capt_rx_count - p_libuarte->p_ctrl_blk->rx_count; + nrf_libuarte_async_evt_t evt = { + .type = NRF_LIBUARTE_ASYNC_EVT_RX_DATA, + .data = { + .rxtx = { + .p_data = &p_libuarte->p_ctrl_blk->p_curr_rx_buf[p_libuarte->p_ctrl_blk->sub_rx_count], + .length = rx_amount, + } + } + }; + NRF_LOG_DEBUG("(tmr evt) RX: %d (addr:0x%08X, internal index: %d)", + rx_amount, + evt.data.rxtx.p_data, + p_libuarte->p_ctrl_blk->sub_rx_count); + + p_libuarte->p_ctrl_blk->sub_rx_count += rx_amount; + p_libuarte->p_ctrl_blk->rx_count = capt_rx_count; + p_libuarte->p_ctrl_blk->evt_handler(p_libuarte->p_ctrl_blk->context, &evt); + } + + NRFX_IRQ_ENABLE((IRQn_Type)NRFX_IRQ_NUMBER_GET(p_libuarte->p_libuarte->uarte)); +} + +static void tmr_evt_handler(nrf_timer_event_t event_type, void * p_context) +{ + nrf_libuarte_async_timeout_handler((const nrf_libuarte_async_t *)p_context); +} + +static void app_timer_handler(void * p_context) +{ + const nrf_libuarte_async_t * p_libuarte = p_context; + uint32_t current_rx_count; + uint32_t counter = local_app_timer_cnt_get(); + uint32_t ticks = app_timer_us_to_ticks(p_libuarte->p_ctrl_blk->timeout_us)/2; + ticks = MAX(APP_TIMER_MIN_TIMEOUT_TICKS, ticks); + + nrf_timer_task_trigger( p_libuarte->p_libuarte->timer.p_reg, NRF_TIMER_TASK_CAPTURE3); + current_rx_count = p_libuarte->p_libuarte->timer.p_reg->CC[3]; + UNUSED_RETURN_VALUE(local_app_timer_start(*p_libuarte->p_app_timer, ticks, (void *)p_libuarte)); + + if (p_libuarte->p_app_timer_ctrl_blk->rx_count != current_rx_count) { + p_libuarte->p_app_timer_ctrl_blk->rx_count = current_rx_count; + /* if number of bytes received changed reset timestamp and activate waiting + * for silent period. + */ + p_libuarte->p_app_timer_ctrl_blk->timestamp = counter; + p_libuarte->p_app_timer_ctrl_blk->activate = true; + } else { + uint32_t diff; + + /* In case of detected silent period check if its length exceeds configured + * timeout. If yes trigger timeout handler. + */ + diff = local_app_timer_cnt_diff_compute(counter, + p_libuarte->p_app_timer_ctrl_blk->timestamp); + if (p_libuarte->p_app_timer_ctrl_blk->activate && + (app_timer_ticks_to_us(diff) > p_libuarte->p_ctrl_blk->timeout_us)) { + p_libuarte->p_app_timer_ctrl_blk->activate = false; + nrf_libuarte_async_timeout_handler(p_libuarte); + } + } +} + +ret_code_t nrf_libuarte_async_init(const nrf_libuarte_async_t * const p_libuarte, + nrf_libuarte_async_config_t const * p_config, + nrf_libuarte_async_evt_handler_t evt_handler, + void * context) +{ + ret_code_t ret; + + if (p_config->int_prio == APP_IRQ_PRIORITY_LOWEST || + ((p_libuarte->p_app_timer && NRF_LIBUARTE_ASYNC_WITH_APP_TIMER) && + (p_config->int_prio >= APP_TIMER_CONFIG_IRQ_PRIORITY))) { + NRF_LOG_ERROR("Too low priority. Lowest possible priority is %d", APP_IRQ_PRIORITY_LOW); + return NRF_ERROR_INVALID_PARAM; + } + + p_libuarte->p_ctrl_blk->evt_handler = evt_handler; + p_libuarte->p_ctrl_blk->rx_count = 0; + p_libuarte->p_ctrl_blk->p_curr_rx_buf = NULL; + p_libuarte->p_ctrl_blk->rx_free_cnt = 0; + p_libuarte->p_ctrl_blk->sub_rx_count = 0; + p_libuarte->p_ctrl_blk->alloc_cnt = 0; + p_libuarte->p_ctrl_blk->context = context; + p_libuarte->p_ctrl_blk->timeout_us = p_config->timeout_us; + p_libuarte->p_ctrl_blk->rx_halted = false; + p_libuarte->p_ctrl_blk->hwfc = (p_config->hwfc == NRF_UARTE_HWFC_ENABLED); + + uint32_t i; + + uint32_t tmr_start_tsk = 0; + uint32_t tmr_clear_tsk = 0; + uint32_t tmr_stop_tsk = 0; + uint32_t tmr_compare_evt = 0; + + if (p_libuarte->p_rtc && RTC_IN_USE) + { + nrfx_rtc_config_t rtc_config = NRFX_RTC_DEFAULT_CONFIG; + rtc_config.interrupt_priority = irq_prio_inc(p_config->int_prio); + + rtc_config.prescaler = 0; + ret = nrfx_rtc_init(p_libuarte->p_rtc, &rtc_config, p_libuarte->rtc_handler); + if (ret != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + ret = nrfx_rtc_cc_set(p_libuarte->p_rtc, 0, p_config->timeout_us/32, true); + if (ret != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + tmr_start_tsk = nrfx_rtc_task_address_get(p_libuarte->p_rtc, NRF_RTC_TASK_START); + tmr_clear_tsk = nrfx_rtc_task_address_get(p_libuarte->p_rtc, NRF_RTC_TASK_CLEAR); + tmr_stop_tsk = nrfx_rtc_task_address_get(p_libuarte->p_rtc, NRF_RTC_TASK_STOP); + tmr_compare_evt = nrfx_rtc_event_address_get(p_libuarte->p_rtc, NRF_RTC_EVENT_COMPARE_0); + } + else if (p_libuarte->p_timer && TIMER_IN_USE) + { + nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG; + tmr_config.frequency = NRF_TIMER_FREQ_1MHz; + tmr_config.p_context = (void *)p_libuarte; + tmr_config.interrupt_priority = irq_prio_inc(p_config->int_prio); + + ret = nrfx_timer_init(p_libuarte->p_timer, &tmr_config, tmr_evt_handler); + if (ret != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + nrfx_timer_compare(p_libuarte->p_timer, NRF_TIMER_CC_CHANNEL0, p_config->timeout_us, true); + + tmr_start_tsk = nrfx_timer_task_address_get(p_libuarte->p_timer, NRF_TIMER_TASK_START); + tmr_clear_tsk = nrfx_timer_task_address_get(p_libuarte->p_timer, NRF_TIMER_TASK_CLEAR); + tmr_stop_tsk = nrfx_timer_task_address_get(p_libuarte->p_timer, NRF_TIMER_TASK_SHUTDOWN); + tmr_compare_evt = nrfx_timer_compare_event_address_get(p_libuarte->p_timer, 0); + } + else if (p_libuarte->p_app_timer && NRF_LIBUARTE_ASYNC_WITH_APP_TIMER) { + /* app_timer in use */ + if(!p_libuarte->p_ctrl_blk->app_timer_created) + { + ret = local_app_timer_create(p_libuarte->p_app_timer); + if (ret != NRF_SUCCESS) + { + return ret; + } + p_libuarte->p_ctrl_blk->app_timer_created = true; + } + p_libuarte->p_app_timer_ctrl_blk->activate = false; + p_libuarte->p_app_timer_ctrl_blk->rx_count = 0; + p_libuarte->p_app_timer_ctrl_blk->timestamp = 0; + } + else + { + NRF_LOG_ERROR("No timer or rtc defined"); + APP_ERROR_CHECK_BOOL(false); + return NRF_ERROR_INTERNAL; + } + + /* if RTC or TIMER is used then PPI channels are allocated. */ + if (p_libuarte->p_app_timer == NULL || !NRF_LIBUARTE_ASYNC_WITH_APP_TIMER) + { + for (i = 0; i < NRF_LIBUARTE_ASYNC_PPI_CH_MAX; i++) + { + ret = nrfx_ppi_channel_alloc(&p_libuarte->p_ctrl_blk->ppi_channels[i]); + if (ret != NRFX_SUCCESS) + { + //we don't free already allocated channels, system is wrongly configured. + return NRF_ERROR_INTERNAL; + } + } + + /*lint -save -e666 */ + PPI_CH_SETUP(p_libuarte->p_ctrl_blk->ppi_channels[NRF_LIBUARTE_ASYNC_PPI_CH_RXRDY_CLEAR], + nrf_uarte_event_address_get(p_libuarte->p_libuarte->uarte, NRF_UARTE_EVENT_RXDRDY), + tmr_start_tsk, + tmr_clear_tsk); + + PPI_CH_SETUP(p_libuarte->p_ctrl_blk->ppi_channels[NRF_LIBUARTE_ASYNC_PPI_CH_COMPARE_SHUTDOWN], + tmr_compare_evt, + tmr_stop_tsk, + (uint32_t)&p_libuarte->p_libuarte->timer.p_reg->TASKS_CAPTURE[3]); + /*lint -restore */ + } + + nrf_libuarte_drv_config_t uart_config = { + .tx_pin = p_config->tx_pin, + .rx_pin = p_config->rx_pin, + .cts_pin = p_config->cts_pin, + .rts_pin = p_config->rts_pin, + .startrx_evt = nrf_uarte_event_address_get(p_libuarte->p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX), + .endrx_evt = 0, + .rxstarted_tsk = 0, + .rxdone_tsk = 0, + .hwfc = p_config->hwfc, + .parity = p_config->parity, + .baudrate = p_config->baudrate, + .irq_priority = p_config->int_prio, + .pullup_rx = p_config->pullup_rx, + }; + + ret = nrf_libuarte_drv_init(p_libuarte->p_libuarte, &uart_config, uart_evt_handler, (void *)p_libuarte); + if (ret != NRF_SUCCESS) + { + return ret; + } + + ret = nrf_balloc_init(p_libuarte->p_rx_pool); + if (ret != NRF_SUCCESS) + { + return ret; + } + + nrf_queue_reset(p_libuarte->p_rx_queue); + + return ret; +} + +void nrf_libuarte_async_uninit(const nrf_libuarte_async_t * const p_libuarte) +{ + nrf_libuarte_drv_uninit(p_libuarte->p_libuarte); + + if (p_libuarte->p_rtc && RTC_IN_USE) + { + nrfx_rtc_disable(p_libuarte->p_rtc); + nrfx_rtc_uninit(p_libuarte->p_rtc); + } + else if (p_libuarte->p_timer && TIMER_IN_USE) + { + nrfx_timer_disable(p_libuarte->p_timer); + nrfx_timer_uninit(p_libuarte->p_timer); + } + else if (p_libuarte->p_app_timer && NRF_LIBUARTE_ASYNC_WITH_APP_TIMER) + { + UNUSED_RETURN_VALUE(local_app_timer_stop(*p_libuarte->p_app_timer)); + } + + /* if HW timeout was used */ + if (p_libuarte->p_app_timer == NULL || !NRF_LIBUARTE_ASYNC_WITH_APP_TIMER) + { + uint32_t i; + ret_code_t ret; + for (i = 0; i < NRF_LIBUARTE_ASYNC_PPI_CH_MAX; i++) + { + ret = nrfx_ppi_channel_disable(p_libuarte->p_ctrl_blk->ppi_channels[i]); + ASSERT(ret == NRF_SUCCESS) + ret = nrfx_ppi_channel_free(p_libuarte->p_ctrl_blk->ppi_channels[i]); + ASSERT(ret == NRF_SUCCESS) + } + } +} + +void nrf_libuarte_async_enable(const nrf_libuarte_async_t * const p_libuarte) +{ + uint8_t * p_data; + p_data = nrf_balloc_alloc(p_libuarte->p_rx_pool); + p_libuarte->p_ctrl_blk->alloc_cnt++; + if (p_data == NULL) + { + APP_ERROR_CHECK_BOOL(false); + } + + if (p_libuarte->p_rtc && RTC_IN_USE) + { + nrfx_rtc_counter_clear(p_libuarte->p_rtc); + } + else if (p_libuarte->p_timer && TIMER_IN_USE) + { + nrfx_timer_clear(p_libuarte->p_timer); + } + + if (p_libuarte->p_app_timer && NRF_LIBUARTE_ASYNC_WITH_APP_TIMER) + { + uint32_t ticks = app_timer_us_to_ticks(p_libuarte->p_ctrl_blk->timeout_us)/2; + ticks = MAX(APP_TIMER_MIN_TIMEOUT_TICKS, ticks); + UNUSED_RETURN_VALUE(local_app_timer_start(*p_libuarte->p_app_timer, ticks, (void *)p_libuarte)); + } + else + { + nrfx_err_t err; + + err = nrfx_ppi_channel_enable(p_libuarte->p_ctrl_blk->ppi_channels[NRF_LIBUARTE_ASYNC_PPI_CH_RXRDY_CLEAR]); + APP_ERROR_CHECK_BOOL(err == NRFX_SUCCESS); + err = nrfx_ppi_channel_enable(p_libuarte->p_ctrl_blk->ppi_channels[NRF_LIBUARTE_ASYNC_PPI_CH_COMPARE_SHUTDOWN]); + APP_ERROR_CHECK_BOOL(err == NRFX_SUCCESS); + } + + + p_libuarte->p_ctrl_blk->p_curr_rx_buf = p_data; + ret_code_t ret = nrf_libuarte_drv_rx_start(p_libuarte->p_libuarte, p_data, p_libuarte->rx_buf_size, false); + APP_ERROR_CHECK_BOOL(ret == NRF_SUCCESS); +} + +ret_code_t nrf_libuarte_async_tx(const nrf_libuarte_async_t * const p_libuarte, uint8_t * p_data, size_t length) +{ + return nrf_libuarte_drv_tx(p_libuarte->p_libuarte, p_data, length); +} + +void nrf_libuarte_async_rx_free(const nrf_libuarte_async_t * const p_libuarte, uint8_t * p_data, size_t length) +{ + p_libuarte->p_ctrl_blk->rx_free_cnt += length; + if (p_libuarte->p_ctrl_blk->rx_free_cnt == p_libuarte->rx_buf_size) + { + p_data -= (p_libuarte->p_ctrl_blk->rx_free_cnt - length); + p_libuarte->p_ctrl_blk->rx_free_cnt = 0; + nrf_balloc_free(p_libuarte->p_rx_pool, p_data); + + p_libuarte->p_ctrl_blk->alloc_cnt--; + if (p_libuarte->p_ctrl_blk->alloc_cnt<0) + { + NRF_LOG_ERROR("Freeing more RX buffers than allocated."); + APP_ERROR_CHECK_BOOL(false); + } + NRF_LOG_INFO("Freeing full buffer 0x%08X, %d, (currently allocated:%d).",p_data, length, p_libuarte->p_ctrl_blk->alloc_cnt); + + if (p_libuarte->p_ctrl_blk->rx_halted) + { + bool ret = rx_buffer_schedule(p_libuarte); + ASSERT(ret); + p_libuarte->p_ctrl_blk->rx_halted = false; + } + } + else if (p_libuarte->p_ctrl_blk->rx_free_cnt > p_libuarte->rx_buf_size) + { + NRF_LOG_ERROR("Unexpected RX free input parameter."); + APP_ERROR_CHECK_BOOL(false); + } + else + { + NRF_LOG_INFO("Freeing partial buffer: 0x%08X, length:%d", p_data, length); + } + +} + +void nrf_libuarte_async_rts_clear(const nrf_libuarte_async_t * const p_libuarte) +{ + nrf_libuarte_drv_rts_clear(p_libuarte->p_libuarte); +} + +void nrf_libuarte_async_rts_set(const nrf_libuarte_async_t * const p_libuarte) +{ + nrf_libuarte_drv_rts_set(p_libuarte->p_libuarte); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.h new file mode 100644 index 0000000..b6ddd54 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_async.h @@ -0,0 +1,383 @@ +/** + * Copyright (c) 2019, 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 UART_ASYNC_H +#define UART_ASYNC_H +#include +#include "sdk_errors.h" +#include "nrf_balloc.h" +#include "nrf_queue.h" +#include "nrfx_ppi.h" +#include "nrfx_timer.h" +#include "nrfx_rtc.h" +#include "nrf_libuarte_drv.h" +#include + +/** + * @defgroup nrf_libuarte_async libUARTE asynchronous library + * @ingroup app_common + * + * @brief Module for reliable communication over UARTE. + * + * @{ + */ + +/* Safe guard for sdk_config.h now up to date. */ +#ifndef NRF_LIBUARTE_ASYNC_WITH_APP_TIMER +#warning "sdk_config.h is missing NRF_LIBUARTE_ASYNC_WITH_APP_TIMER option" +#define NRF_LIBUARTE_ASYNC_WITH_APP_TIMER 0 +#endif + +#if NRF_LIBUARTE_ASYNC_WITH_APP_TIMER +#include "app_timer.h" +#endif + +/** @brief Types of libuarte driver events. */ +typedef enum +{ + NRF_LIBUARTE_ASYNC_EVT_RX_DATA, ///< Requested TX transfer completed. + NRF_LIBUARTE_ASYNC_EVT_TX_DONE, ///< Requested RX transfer completed. + NRF_LIBUARTE_ASYNC_EVT_ERROR, ///< Error reported by UARTE peripheral. + NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR ///< Error reported by the driver. +} nrf_libuarte_async_evt_type_t; + +typedef enum +{ + NRF_LIBUARTE_ASYNC_PPI_CH_RXRDY_CLEAR, + NRF_LIBUARTE_ASYNC_PPI_CH_COMPARE_SHUTDOWN, + NRF_LIBUARTE_ASYNC_PPI_CH_MAX +} nrf_libuarte_async_ppi_channel_t; + +/** @brief Structure for libuarte async transfer completion event. */ +typedef struct +{ + uint8_t * p_data; ///< Pointer to memory used for transfer. + size_t length; ///< Number of bytes transfered. +} nrf_libuarte_async_data_t; + +/** @brief Structu for software error event. */ +typedef struct +{ + uint32_t overrun_length; ///< Number of bytes lost due to overrun. +} nrf_libuarte_async_overrun_err_evt_t; + +/** @brief Structure for libuarte error event. */ +typedef struct +{ + nrf_libuarte_async_evt_type_t type; ///< Event type. + union { + nrf_libuarte_async_data_t rxtx; ///< RXD/TXD data. + uint8_t errorsrc; ///< Error source. + nrf_libuarte_async_overrun_err_evt_t overrun_err; ///< Overrun error data. + } data; ///< Union with data. +} nrf_libuarte_async_evt_t; + +/** + * @brief Interrupt event handler. + * + * @param[in] p_evt Pointer to event structure. Event is allocated on the stack so it is available + * only within the context of the event handler. + */ +typedef void (*nrf_libuarte_async_evt_handler_t)(void * context, nrf_libuarte_async_evt_t * p_evt); + +/** @brief Structure for libuarte async configuration. */ +typedef struct +{ + uint32_t rx_pin; ///< RXD pin number. + uint32_t tx_pin; ///< TXD pin number. + uint32_t cts_pin; ///< CTS pin number. + uint32_t rts_pin; ///< RTS pin number. + uint32_t timeout_us; ///< Receiver timeout in us unit. + nrf_uarte_hwfc_t hwfc; ///< Flow control configuration. + nrf_uarte_parity_t parity; ///< Parity configuration. + nrf_uarte_baudrate_t baudrate; ///< Baudrate. + bool pullup_rx; ///< Pull up on RX pin. + uint8_t int_prio; ///< Interrupt priority of UARTE (RTC, TIMER have int_prio - 1) +} nrf_libuarte_async_config_t; + +/** + * @brief nrf_libuarte_async control block (placed in RAM). + */ +typedef struct { + nrf_libuarte_async_evt_handler_t evt_handler; + void * context; + nrf_ppi_channel_t ppi_channels[NRF_LIBUARTE_ASYNC_PPI_CH_MAX]; + int32_t alloc_cnt; + uint32_t rx_count; + uint32_t sub_rx_count; + uint8_t * p_curr_rx_buf; + uint32_t rx_free_cnt; + uint32_t timeout_us; + bool app_timer_created; + bool hwfc; + bool rx_halted; +} nrf_libuarte_async_ctrl_blk_t; + +typedef struct { + uint32_t rx_count; + uint32_t timestamp; + bool activate; +} nrf_libuarte_app_timer_ctrl_blk_t; +/** + * @brief nrf_libuarte_async instance structure (placed in ROM). + */ +typedef struct { + const nrf_balloc_t * p_rx_pool; + const nrf_queue_t * p_rx_queue; + const nrfx_rtc_t * p_rtc; + const nrfx_timer_t * p_timer; +#if NRF_LIBUARTE_ASYNC_WITH_APP_TIMER + const app_timer_id_t * p_app_timer; +#else + void ** p_app_timer; +#endif + nrf_libuarte_app_timer_ctrl_blk_t * p_app_timer_ctrl_blk; + const nrf_libuarte_drv_t * p_libuarte; + nrf_libuarte_async_ctrl_blk_t * p_ctrl_blk; + nrfx_rtc_handler_t rtc_handler; + uint32_t rx_buf_size; +} nrf_libuarte_async_t; + +void nrf_libuarte_async_timeout_handler(const nrf_libuarte_async_t * p_libuarte); + +#define NRF_LIBUARTE_PERIPHERAL_NOT_USED 255 + +#define LIBUARTE_ASYNC_DEBRACKET(...) __VA_ARGS__ + +#define __LIBUARTE_ASYNC_ARG_2(ignore_this, val, ...) val +#define __LIBUARTE_ASYNC_ARG_2_DEBRACKET(ignore_this, val, ...) LIBUARTE_ASYNC_DEBRACKET val + +/* Macro for injecting code based on flag evaluation. If flag exists and equals 1 + * then first code is compiled in, else second option. Note that code must be + * in the brackets. Example usage: + * _LIBUARTE_ASYNC_EVAL(MY_FLAG, (foo();), () ) + * If MY_FLAG exists and equals 1 then macros resolves to foo(); call, else it resolves to + * empty line. + * + * @param _eval_level Flag to be evaluated. It's positively evaluated if exists and equals 1. + * @param _iftrue Macro is resolved to that code on positive flag evaluation. Code must be + * in the brackets. + * @param _iffalse Macro is resolved to that code on negative flag evaluation. Code must be + * in the brackets. + */ +#define _LIBUARTE_ASYNC_EVAL(_eval_flag, _iftrue, _iffalse) \ + _LIBUARTE_ASYNC_EVAL1(_eval_flag, _iftrue, _iffalse) + +#define _LIBUARTE_ASYNC_EVAL1(_eval_flag, _iftrue, _iffalse) \ + _LIBUARTE_ASYNC_EVAL2(_LIBUARTE_ASYNC_ZZZZ##_eval_flag, _iftrue, _iffalse) + +#define _LIBUARTE_ASYNC_ZZZZ1 _LIBUARTE_ASYNC_YYYY, + +#define _LIBUARTE_ASYNC_EVAL2(one_or_two_args, _iftrue, _iffalse) \ + __LIBUARTE_ASYNC_ARG_2_DEBRACKET(one_or_two_args _iftrue, _iffalse) + +/** + * @brief Macro for creating instance of libuarte_async. + * + * Libuarte_async requires one timer-like peripheral (RTC or TIMER) for triggering RX timeout. + * Macro will create instance only for peripheral which is used. + * + * @param _name Instance name. + * @param _uarte_idx UARTE instance used. + * @param _timer0_idx TIMER instance used by libuarte for bytes counting. + * @param _rtc1_idx RTC instance used for timeout. If set to NRF_LIBUARTE_PERIPHERAL_NOT_USED + * then TIMER instance is used or app_timer instance if _timer1_idx is also set + * to NRF_LIBUARTE_PERIPHERAL_NOT_USED. + * @param _timer1_idx TIMER instance used for timeout. If set to NRF_LIBUARTE_PERIPHERAL_NOT_USED + * then RTC instance is used or app_timer instance if _rtc1_idx is also set + * to NRF_LIBUARTE_PERIPHERAL_NOT_USED. + * @param _rx_buf_size Size of single RX buffer. Size impacts accepted latency between buffer + * request and providing next buffer. Next must be provided within before + * _rx_buf_size bytes is received. + * @param _rx_buf_cnt Number of buffers in the RX buffer pool. Size impacts accepted latency + * between NRF_LIBUARTE_ASYNC_EVT_RX_DATA event and + * @ref nrf_libuarte_async_rx_free. + */ +#define NRF_LIBUARTE_ASYNC_DEFINE(_name, _uarte_idx, _timer0_idx,\ + _rtc1_idx, _timer1_idx,\ + _rx_buf_size, _rx_buf_cnt) \ + STATIC_ASSERT(_rx_buf_cnt >= 3, "Wrong number of RX buffers");\ + STATIC_ASSERT(!((NRF_LIBUARTE_ASYNC_WITH_APP_TIMER == 0) && \ + (_rtc1_idx == NRF_LIBUARTE_PERIPHERAL_NOT_USED) && \ + (_timer1_idx == NRF_LIBUARTE_PERIPHERAL_NOT_USED)), \ + "App timer support disabled");\ + NRF_LIBUARTE_DRV_DEFINE(CONCAT_2(_name, _libuarte), _uarte_idx, _timer0_idx);\ + NRF_QUEUE_DEF(uint8_t *, CONCAT_2(_name,_rxdata_queue), _rx_buf_cnt, NRF_QUEUE_MODE_NO_OVERFLOW);\ + NRF_BALLOC_DEF(CONCAT_2(_name,_rx_pool), _rx_buf_size, _rx_buf_cnt);\ + /* Create TIMER instance only if _timer1_idx != NRF_LIBUARTE_PERIPHERAL_NOT_USED */ \ + _LIBUARTE_ASYNC_EVAL(\ + NRFX_CONCAT_3(NRFX_TIMER, _timer1_idx, _ENABLED),\ + (STATIC_ASSERT((_timer1_idx == NRF_LIBUARTE_PERIPHERAL_NOT_USED) || (CONCAT_3(NRFX_TIMER,_timer1_idx, _ENABLED) == 1), "TIMER instance not enabled");\ + static const nrfx_timer_t CONCAT_2(_name, _timer) = NRFX_TIMER_INSTANCE(_timer1_idx);),\ + (/* empty */))\ + /* Create RTC instance only if _timer1_idx != NRF_LIBUARTE_PERIPHERAL_NOT_USED */ \ + _LIBUARTE_ASYNC_EVAL(\ + NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED),\ + (STATIC_ASSERT((_rtc1_idx == NRF_LIBUARTE_PERIPHERAL_NOT_USED) || (CONCAT_3(NRFX_RTC,_rtc1_idx, _ENABLED) == 1), "RTC instance not enabled");\ + static const nrfx_rtc_t CONCAT_2(_name, _rtc) = NRFX_RTC_INSTANCE(_rtc1_idx);),\ + (/* empty */))\ + _LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_TIMER, _timer1_idx, _ENABLED),\ + (/* empty */),\ + (_LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED),(/* empty */), \ + (APP_TIMER_DEF(CONCAT_2(_name,_app_timer)); \ + nrf_libuarte_app_timer_ctrl_blk_t CONCAT_2(_name,_app_timer_ctrl_blk);))) \ + )\ + static nrf_libuarte_async_ctrl_blk_t CONCAT_2(_name, ctrl_blk);\ + _LIBUARTE_ASYNC_EVAL(\ + NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED), \ + (static void CONCAT_2(_name, _rtc_handler)(nrfx_rtc_int_type_t int_type);),\ + (/* empty */)) \ + \ + static const nrf_libuarte_async_t _name = {\ + .p_rx_pool = &CONCAT_2(_name,_rx_pool),\ + .p_rx_queue = &CONCAT_2(_name,_rxdata_queue),\ + /* If p_rtc is not NULL it means that RTC is used for RX timeout */ \ + .p_rtc = _LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED), (&CONCAT_2(_name, _rtc)), (NULL)),\ + /* If p_timer is not NULL it means that RTC is used for RX timeout */ \ + .p_timer = _LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_TIMER, _timer1_idx, _ENABLED), (&CONCAT_2(_name, _timer)), (NULL)),\ + /* If p_time and p_rtc is NULL it means that app_timer is used for RX timeout */ \ + .p_app_timer = _LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_TIMER, _timer1_idx, _ENABLED),\ + (NULL),\ + (_LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED),(NULL), \ + (&CONCAT_2(_name,_app_timer)))) \ + ),\ + .p_app_timer_ctrl_blk = _LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_TIMER, _timer1_idx, _ENABLED),\ + (NULL),\ + (_LIBUARTE_ASYNC_EVAL(NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED),(NULL), \ + (&CONCAT_2(_name,_app_timer_ctrl_blk)))) \ + ),\ + .p_libuarte = &CONCAT_2(_name, _libuarte),\ + .p_ctrl_blk = &CONCAT_2(_name, ctrl_blk),\ + .rx_buf_size = _rx_buf_size,\ + _LIBUARTE_ASYNC_EVAL(\ + NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED),\ + (.rtc_handler =CONCAT_2(_name, _rtc_handler)),\ + ()\ + )\ + };\ + /* RTC compare event is not periodic but need to be enabled again in the callback. */ \ + _LIBUARTE_ASYNC_EVAL(\ + NRFX_CONCAT_3(NRFX_RTC, _rtc1_idx, _ENABLED),\ + (\ + static void CONCAT_2(_name, _rtc_handler)(nrfx_rtc_int_type_t int_type)\ + { \ + (void)nrfx_rtc_cc_set(_name.p_rtc, 0, _name.p_ctrl_blk->timeout_us/32, true);\ + nrf_libuarte_async_timeout_handler(&_name);\ + }\ + ),\ + ()\ + ) + + +/** + * @brief Function for initializing the libuarte async library. + * + * @param[in] p_libuarte Libuarte_async instance. + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] evt_handler Event handler provided by the user. Must not be NULL. + * @param[in] context User context passed to the event handler. + * + * @return NRF_SUCCESS when properly initialized. NRF_ERROR_INTERNAL otherwise. + */ +ret_code_t nrf_libuarte_async_init(const nrf_libuarte_async_t * const p_libuarte, + nrf_libuarte_async_config_t const * p_config, + nrf_libuarte_async_evt_handler_t evt_handler, + void * context); + +/** @brief Function for uninitializing the libuarte async library. + * + * @param[in] p_libuarte Libuarte_async instance. + */ +void nrf_libuarte_async_uninit(const nrf_libuarte_async_t * const p_libuarte); + +/** + * @brief Function for enabling receiver. + * + * @param p_libuarte Libuarte_async instance. + */ +void nrf_libuarte_async_enable(const nrf_libuarte_async_t * const p_libuarte); + +/** + * @brief Function for deasserting RTS to pause the transmission. + * + * Flow control must be enabled. + * + * @param p_libuarte Libuarte_async instance. + */ +void nrf_libuarte_async_rts_clear(const nrf_libuarte_async_t * const p_libuarte); + +/** + * @brief Function for asserting RTS to restart the transmission. + * + * Flow control must be enabled. + * + * @param p_libuarte Libuarte_async instance. + */ +void nrf_libuarte_async_rts_set(const nrf_libuarte_async_t * const p_libuarte); + +/** + * @brief Function for sending data asynchronously over UARTE. + * + * @param[in] p_libuarte Libuarte_async instance. + * @param[in] p_data Pointer to data. + * @param[in] length Number of bytes to send. Maximum possible length is + * dependent on the used SoC (see the MAXCNT register + * description in the Product Specification). The library + * checks it with assertion. + * + * @retval NRF_ERROR_BUSY Data is transferring. + * @retval NRF_ERROR_INTERNAL Error during configuration. + * @retval NRF_SUCCESS Buffer set for sending. + */ +ret_code_t nrf_libuarte_async_tx(const nrf_libuarte_async_t * const p_libuarte, + uint8_t * p_data, size_t length); + +/** + * @brief Function for deallocating received buffer data. + * + * @param[in] p_libuarte Libuarte_async instance. + * @param[in] p_data Pointer to data. + * @param[in] length Number of bytes to free. + */ +void nrf_libuarte_async_rx_free(const nrf_libuarte_async_t * const p_libuarte, + uint8_t * p_data, size_t length); + +/** @} */ + +#endif //UART_ASYNC_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.c new file mode 100644 index 0000000..64606fa --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.c @@ -0,0 +1,835 @@ +/** + * Copyright (c) 2019, 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_config.h" +#include "nrf_libuarte_drv.h" +#include "nrf_uarte.h" +#include "nrf_gpio.h" +#include +#include <../src/prs/nrfx_prs.h> + +#define NRF_LOG_MODULE_NAME libUARTE +#if NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#else // NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // NRF_LIBUARTE_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define MAX_DMA_XFER_LEN ((1UL << UARTE0_EASYDMA_MAXCNT_SIZE) - 1) + +#define INTERRUPTS_MASK \ + (NRF_UARTE_INT_ENDRX_MASK | NRF_UARTE_INT_RXSTARTED_MASK | NRF_UARTE_INT_ERROR_MASK | \ + NRF_UARTE_INT_ENDTX_MASK | NRF_UARTE_INT_TXSTOPPED_MASK) + +static const nrf_libuarte_drv_t * m_libuarte_instance[2]; + +/* if it is defined it means that PRS for uart is not used. */ +#ifdef nrfx_uarte_0_irq_handler +#define libuarte_0_irq_handler UARTE0_UART0_IRQHandler +#endif + +#if NRFX_CHECK(NRF_LIBUARTE_DRV_UARTE0) +void libuarte_0_irq_handler(void); +#endif + +#if NRFX_CHECK(NRF_LIBUARTE_DRV_UARTE1) +void libuarte_1_irq_handler(void); +#endif + +#if defined(NRF_LIBUARTE_DRV_HWFC_ENABLED) +#define LIBUARTE_DRV_WITH_HWFC NRF_LIBUARTE_DRV_HWFC_ENABLED +#else +#define LIBUARTE_DRV_WITH_HWFC 1 +#endif + +#define RTS_PIN_DISABLED 0xff + +/** @brief Macro executes given function on every allocated channel in the list between provided + * indexes. + */ +#define PPI_CHANNEL_FOR_M_N(p_libuarte, m, n, func) \ + for (int i = m; i < n; i++) \ + { \ + if (p_libuarte->ctrl_blk->ppi_channels[i] < PPI_CH_NUM) \ + { func(&p_libuarte->ctrl_blk->ppi_channels[i]); } \ + } + +/** @brief Macro executes provided function on every allocated PPI channel. */ +#define PPI_CHANNEL_FOR_ALL(p_libuarte, func) \ + PPI_CHANNEL_FOR_M_N(p_libuarte, 0, NRF_LIBUARTE_DRV_PPI_CH_MAX, func) + +/** @brief Macro executes provided function on every allocated group in the list. */ +#define PPI_GROUP_FOR_ALL(p_libuarte, func) \ + for (int i = 0; i < NRF_LIBUARTE_DRV_PPI_GROUP_MAX; i++) \ + { \ + if (p_libuarte->ctrl_blk->ppi_groups[i] < PPI_GROUP_NUM) \ + { func(&p_libuarte->ctrl_blk->ppi_groups[i]); } \ + } + +/** @brief Allocate and configure PPI channel. Fork is optional and it's not set if NULL. + * Channel parameter is field by the function. + */ +static ret_code_t ppi_channel_configure(nrf_ppi_channel_t * p_ch, uint32_t evt, + uint32_t task, uint32_t fork) +{ + nrfx_err_t err; + + err = nrfx_ppi_channel_alloc(p_ch); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_NO_MEM; + } + + err = nrfx_ppi_channel_assign(*p_ch, evt, task); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + if (fork) + { + err = nrfx_ppi_channel_fork_assign(*p_ch, fork); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + } + + return NRF_SUCCESS; +} + +/** @brief Allocate and configure group with one channel. Fetch addresses of enable/disable tasks.*/ +static ret_code_t ppi_group_configure(nrf_ppi_channel_group_t * p_ppi_group, nrf_ppi_channel_t ch, + uint32_t * p_en_task, uint32_t * p_dis_task, bool en) +{ + nrfx_err_t err; + + err = nrfx_ppi_group_alloc(p_ppi_group); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_NO_MEM; + } + + err = nrfx_ppi_channel_include_in_group(ch, *p_ppi_group); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + if (en) + { + err = nrfx_ppi_group_enable(*p_ppi_group); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + } + + *p_en_task = nrfx_ppi_task_addr_group_enable_get(*p_ppi_group); + *p_dis_task = nrfx_ppi_task_addr_group_disable_get(*p_ppi_group); + + return NRF_SUCCESS; +} + +/** @brief Disable and free PPI channel. */ +static void ppi_ch_free(nrf_ppi_channel_t * p_ch) +{ + nrfx_err_t err; + err = nrfx_ppi_channel_disable(*p_ch); + ASSERT(err == NRFX_SUCCESS); + err = nrfx_ppi_channel_free(*p_ch); + ASSERT(err == NRFX_SUCCESS); + *p_ch = (nrf_ppi_channel_t)PPI_CH_NUM; +} + +/** @brief Disable and free PPI group. */ +static void ppi_group_free(nrf_ppi_channel_group_t * p_group) +{ + nrfx_err_t err; + err = nrfx_ppi_group_free(*p_group); + ASSERT(err == NRFX_SUCCESS); + *p_group = (nrf_ppi_channel_group_t)PPI_GROUP_NUM; + +} + +/** @brief Free all channels. */ +static void ppi_free(const nrf_libuarte_drv_t * const p_libuarte) +{ + PPI_CHANNEL_FOR_ALL(p_libuarte, ppi_ch_free); + PPI_GROUP_FOR_ALL(p_libuarte, ppi_group_free); +} + +/** @brief Enable PPI channel. */ +static void ppi_ch_enable(nrf_ppi_channel_t * p_ch) +{ + nrfx_err_t err; + err = nrfx_ppi_channel_enable(*p_ch); + ASSERT(err == NRFX_SUCCESS); +} + +/** @brief Disable PPI channel. */ +static void ppi_ch_disable(nrf_ppi_channel_t * p_ch) +{ + nrfx_err_t err; + err = nrfx_ppi_channel_disable(*p_ch); + ASSERT(err == NRFX_SUCCESS); +} + +/** @brief Enable PPI channels for RX. */ +static void rx_ppi_enable(const nrf_libuarte_drv_t * const p_libuarte) +{ + PPI_CHANNEL_FOR_M_N(p_libuarte, 0, NRF_LIBUARTE_DRV_PPI_CH_RX_GROUP_MAX, ppi_ch_enable); +} + +/** @brief Disable PPI channels for RX. */ +static void rx_ppi_disable(const nrf_libuarte_drv_t * const p_libuarte) +{ + PPI_CHANNEL_FOR_M_N(p_libuarte, 0, NRF_LIBUARTE_DRV_PPI_CH_RX_GROUP_MAX, ppi_ch_disable); +} + +/** @brief Enable PPI channels for TX. */ +static void tx_ppi_enable(const nrf_libuarte_drv_t * const p_libuarte) +{ + PPI_CHANNEL_FOR_M_N(p_libuarte, NRF_LIBUARTE_DRV_PPI_CH_RX_GROUP_MAX, + NRF_LIBUARTE_DRV_PPI_CH_MAX, ppi_ch_enable); +} + +/** @brief Disable PPI channels for TX. */ +static void tx_ppi_disable(const nrf_libuarte_drv_t * const p_libuarte) +{ + PPI_CHANNEL_FOR_M_N(p_libuarte, NRF_LIBUARTE_DRV_PPI_CH_RX_GROUP_MAX, + NRF_LIBUARTE_DRV_PPI_CH_MAX, ppi_ch_disable); +} + +static ret_code_t ppi_configure(const nrf_libuarte_drv_t * const p_libuarte, + nrf_libuarte_drv_config_t * p_config) +{ + ret_code_t ret; + uint32_t gr0_en_task = 0; + uint32_t gr0_dis_task = 0; + uint32_t gr1_en_task = 0; + uint32_t gr1_dis_task = 0; + + for (int i = 0; i < NRF_LIBUARTE_DRV_PPI_CH_MAX; i++) + { + /* set to invalid value */ + p_libuarte->ctrl_blk->ppi_channels[i] = (nrf_ppi_channel_t)PPI_CH_NUM; + } + + for (int i = 0; i < NRF_LIBUARTE_DRV_PPI_GROUP_MAX; i++) + { + /* set to invalid value */ + p_libuarte->ctrl_blk->ppi_groups[i] = (nrf_ppi_channel_group_t)PPI_GROUP_NUM; + } + + if (MAX_DMA_XFER_LEN < UINT16_MAX) + { + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_ENDTX_STARTTX], + nrf_uarte_event_address_get(p_libuarte->uarte, NRF_UARTE_EVENT_ENDTX), + nrf_uarte_task_address_get(p_libuarte->uarte, NRF_UARTE_TASK_STARTTX), + 0); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + } + + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_RXRDY_TIMER_COUNT], + nrf_uarte_event_address_get(p_libuarte->uarte, NRF_UARTE_EVENT_RXDRDY), + nrfx_timer_task_address_get(&p_libuarte->timer, NRF_TIMER_TASK_COUNT), + 0); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_ENDRX_STARTRX], + nrf_uarte_event_address_get(p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX), + nrf_uarte_task_address_get(p_libuarte->uarte, NRF_UARTE_TASK_STARTRX), + nrfx_timer_capture_task_address_get(&p_libuarte->timer, 0)); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + + if (p_config->endrx_evt && p_config->rxdone_tsk) + { + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_ENDRX_EXT_TSK], + nrf_uarte_event_address_get(p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX), + nrfx_timer_capture_task_address_get(&p_libuarte->timer, 0), + p_config->rxdone_tsk); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + + ret = ppi_group_configure(&p_libuarte->ctrl_blk->ppi_groups[NRF_LIBUARTE_DRV_PPI_GROUP_ENDRX_STARTRX], + p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_ENDRX_STARTRX], + &gr0_en_task, &gr0_dis_task, true); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + + ret = ppi_group_configure(&p_libuarte->ctrl_blk->ppi_groups[NRF_LIBUARTE_DRV_PPI_GROUP_ENDRX_EXT_RXDONE_TSK], + p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_ENDRX_EXT_TSK], + &gr1_en_task, &gr1_dis_task, false); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_EXT_STOP_STOPRX], + p_config->endrx_evt, + nrf_uarte_task_address_get(p_libuarte->uarte, NRF_UARTE_TASK_STOPRX), + nrfx_timer_capture_task_address_get(&p_libuarte->timer, 1)); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_EXT_STOP_GROUPS_EN], + p_config->endrx_evt, + gr0_dis_task, + gr1_en_task); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + } + + if (p_config->rxstarted_tsk || gr1_dis_task) + { + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_RXSTARTED_EXT_TSK], + nrf_uarte_event_address_get(p_libuarte->uarte, NRF_UARTE_EVENT_RXSTARTED), + gr1_dis_task ? gr1_dis_task : p_config->rxstarted_tsk, + gr1_dis_task ? p_config->rxstarted_tsk : 0); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + } + + if (p_config->startrx_evt) + { + ret = ppi_channel_configure( + &p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_EXT_TRIGGER_STARTRX_EN_ENDRX_STARTX], + p_config->startrx_evt, + nrf_uarte_task_address_get(p_libuarte->uarte, NRF_UARTE_TASK_STARTRX), + gr0_en_task); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + } + + if (p_config->endrx_evt) + { + + } + + if (LIBUARTE_DRV_WITH_HWFC && (p_config->rts_pin != NRF_UARTE_PSEL_DISCONNECTED)) + { + ret = ppi_channel_configure(&p_libuarte->ctrl_blk->ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_RTS_PIN], + nrfx_timer_compare_event_address_get(&p_libuarte->timer, 2), + nrfx_gpiote_set_task_addr_get(p_config->rts_pin), + 0); + if (ret != NRF_SUCCESS) + { + goto complete_config; + } + } + +complete_config: + if (ret == NRF_SUCCESS) + { + return ret; + } + + ppi_free(p_libuarte); + + return ret; +} + +void tmr_evt_handler(nrf_timer_event_t event_type, void * p_context) +{ + UNUSED_PARAMETER(event_type); + UNUSED_PARAMETER(p_context); +} + +ret_code_t nrf_libuarte_drv_init(const nrf_libuarte_drv_t * const p_libuarte, + nrf_libuarte_drv_config_t * p_config, + nrf_libuarte_drv_evt_handler_t evt_handler, + void * context) +{ + ret_code_t ret; + IRQn_Type irqn = nrfx_get_irq_number(p_libuarte->uarte); + + p_libuarte->ctrl_blk->evt_handler = evt_handler; + p_libuarte->ctrl_blk->p_cur_rx = NULL; + p_libuarte->ctrl_blk->p_next_rx = NULL; + p_libuarte->ctrl_blk->p_next_next_rx = NULL; + p_libuarte->ctrl_blk->p_tx = NULL; + p_libuarte->ctrl_blk->context = context; + + m_libuarte_instance[p_libuarte->uarte == NRF_UARTE0 ? 0 : 1] = p_libuarte; + + //UART init + nrf_gpio_pin_set(p_config->tx_pin); + nrf_gpio_cfg_output(p_config->tx_pin); + nrf_gpio_cfg_input(p_config->rx_pin, p_config->pullup_rx ? + NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL); + nrf_uarte_baudrate_set(p_libuarte->uarte, p_config->baudrate); + nrf_uarte_configure(p_libuarte->uarte, p_config->parity, p_config->hwfc); + nrf_uarte_txrx_pins_set(p_libuarte->uarte, p_config->tx_pin, p_config->rx_pin); + + if (LIBUARTE_DRV_WITH_HWFC && (p_config->hwfc == NRF_UARTE_HWFC_ENABLED)) + { + if (p_config->cts_pin != NRF_UARTE_PSEL_DISCONNECTED) + { + nrf_gpio_cfg_input(p_config->cts_pin, NRF_GPIO_PIN_PULLUP); + } + if (p_config->rts_pin != NRF_UARTE_PSEL_DISCONNECTED) + { + nrfx_gpiote_out_config_t out_config = NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(true); + + nrfx_err_t err = nrfx_gpiote_init(); + if ((err != NRFX_SUCCESS) && (err != NRFX_ERROR_INVALID_STATE)) + { + return err; + } + + err = nrfx_gpiote_out_init(p_config->rts_pin, &out_config); + if (err != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + nrfx_gpiote_out_task_enable(p_config->rts_pin); + nrf_gpio_cfg_output(p_config->rts_pin); + p_libuarte->ctrl_blk->rts_pin = p_config->rts_pin; + } + else + { + p_libuarte->ctrl_blk->rts_pin = RTS_PIN_DISABLED; + } + + nrf_uarte_hwfc_pins_set(p_libuarte->uarte, NRF_UARTE_PSEL_DISCONNECTED, p_config->cts_pin); + } + else if ((p_config->hwfc == NRF_UARTE_HWFC_ENABLED) && !LIBUARTE_DRV_WITH_HWFC) + { + return NRFX_ERROR_INVALID_PARAM; + } + +#if NRFX_CHECK(NRFX_PRS_ENABLED) && NRFX_CHECK(NRF_LIBUARTE_DRV_UARTE0) + if (irqn == UARTE0_UART0_IRQn) + { + if (nrfx_prs_acquire(p_libuarte->uarte, libuarte_0_irq_handler) != NRFX_SUCCESS) + { + return NRF_ERROR_BUSY; + } + } +#endif // NRFX_CHECK(NRFX_PRS_ENABLED) && NRFX_CHECK(NRF_LIBUARTE_DRV_UARTE0) + + nrf_uarte_int_enable(p_libuarte->uarte, INTERRUPTS_MASK); + + NVIC_SetPriority(irqn, p_config->irq_priority); + NVIC_ClearPendingIRQ(irqn); + NVIC_EnableIRQ(irqn); + + nrf_uarte_enable(p_libuarte->uarte); + + nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG; + tmr_config.mode = NRF_TIMER_MODE_COUNTER; + tmr_config.bit_width = NRF_TIMER_BIT_WIDTH_32; + ret = nrfx_timer_init(&p_libuarte->timer, &tmr_config, tmr_evt_handler); + if (ret != NRFX_SUCCESS) + { + return NRF_ERROR_INTERNAL; + } + + return ppi_configure(p_libuarte, p_config); +} + +void nrf_libuarte_drv_uninit(const nrf_libuarte_drv_t * const p_libuarte) +{ + IRQn_Type irqn = nrfx_get_irq_number(p_libuarte->uarte); + + NVIC_DisableIRQ(irqn); + nrf_uarte_int_disable(p_libuarte->uarte, 0xFFFFFFFF); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTOPPED); + nrf_uarte_task_trigger(p_libuarte->uarte, NRF_UARTE_TASK_STOPTX); + nrf_uarte_task_trigger(p_libuarte->uarte, NRF_UARTE_TASK_STOPRX); + + nrf_uarte_int_disable(p_libuarte->uarte, 0xFFFFFFFF); + nrf_uarte_disable(p_libuarte->uarte); + + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTARTED); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTOPPED); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_ENDTX); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_RXSTARTED); + +#if NRFX_CHECK(NRFX_PRS_ENABLED) && NRFX_CHECK(NRF_LIBUARTE_DRV_UARTE0) + if (irqn == UARTE0_UART0_IRQn) + { + nrfx_prs_release(p_libuarte->uarte); + } +#endif // NRFX_CHECK(NRFX_PRS_ENABLED) && NRFX_CHECK(NRF_LIBUARTE_DRV_UARTE0) + + nrfx_timer_disable(&p_libuarte->timer); + nrfx_timer_uninit(&p_libuarte->timer); + + if (LIBUARTE_DRV_WITH_HWFC && (p_libuarte->ctrl_blk->rts_pin != RTS_PIN_DISABLED)) + { + nrfx_gpiote_out_uninit(p_libuarte->ctrl_blk->rts_pin); + } + ppi_free(p_libuarte); +} + +ret_code_t nrf_libuarte_drv_tx(const nrf_libuarte_drv_t * const p_libuarte, + uint8_t * p_data, size_t len) +{ + if (p_libuarte->ctrl_blk->p_tx) + { + return NRF_ERROR_BUSY; + } + p_libuarte->ctrl_blk->p_tx = p_data; + p_libuarte->ctrl_blk->tx_len = len; + p_libuarte->ctrl_blk->tx_cur_idx = 0; + uint16_t first_chunk; + + if ((MAX_DMA_XFER_LEN <= UINT16_MAX) && (len <= MAX_DMA_XFER_LEN)) + { + first_chunk = len; + p_libuarte->ctrl_blk->tx_chunk8 = 0; + } + else + { + uint32_t num_of_chunks = CEIL_DIV(len, MAX_DMA_XFER_LEN); + p_libuarte->ctrl_blk->tx_chunk8 = len/num_of_chunks; + first_chunk = p_libuarte->ctrl_blk->tx_chunk8 + len%p_libuarte->ctrl_blk->tx_chunk8; + } + + NRF_LOG_WARNING("Started TX total length:%d, first chunk:%d", len, first_chunk); + nrf_uarte_tx_buffer_set(p_libuarte->uarte, p_data, first_chunk); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTARTED); + nrf_uarte_task_trigger(p_libuarte->uarte, NRF_UARTE_TASK_STARTTX); + + if ((MAX_DMA_XFER_LEN <= UINT16_MAX) && (len > MAX_DMA_XFER_LEN)) + { + while(nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTARTED) == 0) + { + } + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTARTED); + tx_ppi_enable(p_libuarte); + + nrf_uarte_tx_buffer_set(p_libuarte->uarte, &p_libuarte->ctrl_blk->p_tx[first_chunk], p_libuarte->ctrl_blk->tx_chunk8); + } + return NRF_SUCCESS; +} + +ret_code_t nrf_libuarte_drv_rx_start(const nrf_libuarte_drv_t * const p_libuarte, + uint8_t * p_data, size_t len, bool ext_trigger_en) +{ + + p_libuarte->ctrl_blk->chunk_size = len; + + ASSERT(len <= MAX_DMA_XFER_LEN); + + if (p_data) + { + p_libuarte->ctrl_blk->p_cur_rx = p_data; + nrf_uarte_rx_buffer_set(p_libuarte->uarte, p_data, len); + } + + /* Reset byte counting */ + nrfx_timer_enable(&p_libuarte->timer); + nrfx_timer_clear(&p_libuarte->timer); + p_libuarte->ctrl_blk->last_rx_byte_cnt = 0; + p_libuarte->ctrl_blk->last_pin_rx_byte_cnt = 0; + + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX); + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_RXSTARTED); + + rx_ppi_enable(p_libuarte); + + if (LIBUARTE_DRV_WITH_HWFC && (p_libuarte->ctrl_blk->rts_pin != RTS_PIN_DISABLED)) + { + uint32_t rx_limit = len - NRF_LIBUARTE_DRV_HWFC_BYTE_LIMIT; + *(uint32_t *)nrfx_gpiote_clr_task_addr_get(p_libuarte->ctrl_blk->rts_pin) = 1; + nrfx_timer_compare(&p_libuarte->timer, NRF_TIMER_CC_CHANNEL2, rx_limit, false); + } + + if (!ext_trigger_en) + { + nrf_uarte_task_trigger(p_libuarte->uarte, NRF_UARTE_TASK_STARTRX); + } + NRF_LOG_DEBUG("Start continues RX. Provided buffer:0x%08X", p_data); + return NRF_SUCCESS; +} + +void nrf_libuarte_drv_rx_buf_rsp(const nrf_libuarte_drv_t * const p_libuarte, + uint8_t * p_data, size_t len) +{ + if (p_libuarte->ctrl_blk->p_next_rx == NULL) + { + p_libuarte->ctrl_blk->p_next_rx = p_data; + NRF_LOG_DEBUG("RX buf response (next). Provided buffer:0x%08X", p_data); + nrf_uarte_rx_buffer_set(p_libuarte->uarte, p_data, len); + } + else + { + NRF_LOG_DEBUG("RX buf response (mp_next_rx not NULL:0x%08X), Provided buffer:0x%08X", + p_libuarte->ctrl_blk->p_next_rx, p_data); + p_libuarte->ctrl_blk->p_next_next_rx = p_data; + } + + if (LIBUARTE_DRV_WITH_HWFC && (p_libuarte->ctrl_blk->rts_pin != RTS_PIN_DISABLED)) + { + uint32_t rx_limit = nrfx_timer_capture_get(&p_libuarte->timer, NRF_TIMER_CC_CHANNEL0) + + 2*len - NRF_LIBUARTE_DRV_HWFC_BYTE_LIMIT; + nrfx_timer_compare(&p_libuarte->timer, NRF_TIMER_CC_CHANNEL2, rx_limit, false); + if (p_libuarte->ctrl_blk->rts_manual == false) + { + *(uint32_t *)nrfx_gpiote_clr_task_addr_get(p_libuarte->ctrl_blk->rts_pin) = 1; + } + } +} + +void nrf_libuarte_drv_rx_stop(const nrf_libuarte_drv_t * const p_libuarte) +{ + rx_ppi_disable(p_libuarte); + + NRF_LOG_DEBUG("RX stopped."); + if (LIBUARTE_DRV_WITH_HWFC && (p_libuarte->ctrl_blk->rts_pin != RTS_PIN_DISABLED)) + { + *(uint32_t *)nrfx_gpiote_set_task_addr_get(p_libuarte->ctrl_blk->rts_pin) = 1; + } + nrf_uarte_task_trigger(p_libuarte->uarte, NRF_UARTE_TASK_STOPRX); +} + +void nrf_libuarte_drv_rts_clear(const nrf_libuarte_drv_t * const p_libuarte) +{ + if (LIBUARTE_DRV_WITH_HWFC && (p_libuarte->ctrl_blk->rts_pin != RTS_PIN_DISABLED)) + { + *(uint32_t *)nrfx_gpiote_clr_task_addr_get(p_libuarte->ctrl_blk->rts_pin) = 1; + p_libuarte->ctrl_blk->rts_manual = false; + } +} + +void nrf_libuarte_drv_rts_set(const nrf_libuarte_drv_t * const p_libuarte) +{ + if (LIBUARTE_DRV_WITH_HWFC && (p_libuarte->ctrl_blk->rts_pin != RTS_PIN_DISABLED)) + { + p_libuarte->ctrl_blk->rts_manual = true; + *(uint32_t *)nrfx_gpiote_set_task_addr_get(p_libuarte->ctrl_blk->rts_pin) = 1; + } +} + +static void irq_handler(const nrf_libuarte_drv_t * const p_libuarte) +{ + if (nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_ERROR)) + { + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_ERROR); + nrf_libuarte_drv_evt_t evt = { + .type = NRF_LIBUARTE_DRV_EVT_ERROR, + .data = { .errorsrc = nrf_uarte_errorsrc_get_and_clear(p_libuarte->uarte) } + }; + p_libuarte->ctrl_blk->evt_handler(p_libuarte->ctrl_blk->context, &evt); + } + + if (nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_RXSTARTED)) + { + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_RXSTARTED); + + nrf_libuarte_drv_evt_t evt = { + .type = NRF_LIBUARTE_DRV_EVT_RX_BUF_REQ, + }; + p_libuarte->ctrl_blk->evt_handler(p_libuarte->ctrl_blk->context, &evt); + } + + if (nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX)) + { + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_ENDRX); + + uint32_t endrx_byte_cnt = nrfx_timer_capture_get(&p_libuarte->timer, NRF_TIMER_CC_CHANNEL0); + uint32_t stop_byte_cnt = nrfx_timer_capture_get(&p_libuarte->timer, NRF_TIMER_CC_CHANNEL1); + + uint32_t dma_amount = endrx_byte_cnt - p_libuarte->ctrl_blk->last_rx_byte_cnt; + uint32_t pin_amount = stop_byte_cnt - p_libuarte->ctrl_blk->last_pin_rx_byte_cnt; + NRF_LOG_DEBUG("(evt) RX dma_cnt:%d, endrx_cnt:%d, stop_cnt:%d", + dma_amount, + endrx_byte_cnt, + stop_byte_cnt); + p_libuarte->ctrl_blk->last_rx_byte_cnt = endrx_byte_cnt; + p_libuarte->ctrl_blk->last_pin_rx_byte_cnt = stop_byte_cnt; + + if (dma_amount || pin_amount) + { + uint32_t chunk0 = (dma_amount > p_libuarte->ctrl_blk->chunk_size) ? + p_libuarte->ctrl_blk->chunk_size : dma_amount; + uint32_t chunk1 = dma_amount - chunk0; + + NRF_LOG_DEBUG("RX END chunk0:%d, chunk1:%d, data[0]=%d %d", + chunk0, + chunk1, + p_libuarte->ctrl_blk->p_cur_rx[0], + p_libuarte->ctrl_blk->p_cur_rx[1]); + nrf_libuarte_drv_evt_t evt = { + .type = NRF_LIBUARTE_DRV_EVT_RX_DATA, + .data = { + .rxtx = { + .p_data = p_libuarte->ctrl_blk->p_cur_rx, + .length = chunk0 + } + } + }; + p_libuarte->ctrl_blk->p_cur_rx = p_libuarte->ctrl_blk->p_next_rx; + p_libuarte->ctrl_blk->p_next_rx = NULL; + if (p_libuarte->ctrl_blk->p_next_next_rx) + { + p_libuarte->ctrl_blk->p_next_rx = p_libuarte->ctrl_blk->p_next_next_rx; + p_libuarte->ctrl_blk->p_next_next_rx = NULL; + nrf_uarte_rx_buffer_set(p_libuarte->uarte, + p_libuarte->ctrl_blk->p_next_rx, + p_libuarte->ctrl_blk->chunk_size); + } + p_libuarte->ctrl_blk->evt_handler(p_libuarte->ctrl_blk->context, &evt); + + if ( chunk1 || + ((dma_amount == p_libuarte->ctrl_blk->chunk_size) && (endrx_byte_cnt == stop_byte_cnt))) + { + NRF_LOG_WARNING("RX END Chunk1:%d", chunk1); + + nrf_libuarte_drv_evt_t err_evt = { + .type = NRF_LIBUARTE_DRV_EVT_OVERRUN_ERROR, + .data = { + .overrun_err = { + .overrun_length = chunk1 + } + } + }; + p_libuarte->ctrl_blk->evt_handler(p_libuarte->ctrl_blk->context, &err_evt); + + p_libuarte->ctrl_blk->p_cur_rx = p_libuarte->ctrl_blk->p_next_rx; + p_libuarte->ctrl_blk->p_next_rx = NULL; + } + } + } + + if (nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTOPPED)) + { + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTOPPED); + nrf_libuarte_drv_evt_t evt = { + .type = NRF_LIBUARTE_DRV_EVT_TX_DONE, + .data = { + .rxtx = { + .p_data = p_libuarte->ctrl_blk->p_tx, + .length = p_libuarte->ctrl_blk->tx_len + } + } + }; + p_libuarte->ctrl_blk->p_tx = NULL; + p_libuarte->ctrl_blk->evt_handler(p_libuarte->ctrl_blk->context, &evt); + } + + if (nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_ENDTX)) + { + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_ENDTX); + size_t amount = nrf_uarte_tx_amount_get(p_libuarte->uarte); + + NRF_LOG_DEBUG("(evt) TX completed (%d)", amount); + p_libuarte->ctrl_blk->tx_cur_idx += amount; + if (p_libuarte->ctrl_blk->tx_cur_idx == p_libuarte->ctrl_blk->tx_len) + { + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTOPPED); + nrf_uarte_task_trigger(p_libuarte->uarte, NRF_UARTE_TASK_STOPTX); + } + else + { + size_t rem_len = (p_libuarte->ctrl_blk->tx_len - p_libuarte->ctrl_blk->tx_cur_idx); + if ( rem_len <= MAX_DMA_XFER_LEN) + { + tx_ppi_disable(p_libuarte); + } + else + { + uint8_t * p_buffer = &p_libuarte->ctrl_blk->p_tx[ + p_libuarte->ctrl_blk->tx_cur_idx + + p_libuarte->ctrl_blk->tx_chunk8]; + if (nrf_uarte_event_check(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTARTED) == 0) + { + NRF_LOG_ERROR("Tx not started yet!"); + ASSERT(false); + } + nrf_uarte_event_clear(p_libuarte->uarte, NRF_UARTE_EVENT_TXSTARTED); + nrf_uarte_tx_buffer_set(p_libuarte->uarte, + p_buffer, + p_libuarte->ctrl_blk->tx_chunk8); + } + } + + } +} + + +#if NRF_LIBUARTE_DRV_UARTE0 +void libuarte_0_irq_handler(void) +{ + irq_handler(m_libuarte_instance[0]); +} +#endif + +#if NRF_LIBUARTE_DRV_UARTE1 +void UARTE1_IRQHandler(void) +{ + irq_handler(m_libuarte_instance[1]); +} +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.h new file mode 100644 index 0000000..e902150 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/libuarte/nrf_libuarte_drv.h @@ -0,0 +1,278 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_LIBUARTE_DRV_H +#define NRF_LIBUARTE_DRV_H + +#include "sdk_errors.h" +#include "nrf_uarte.h" +#include "nrfx_ppi.h" +#include "nrfx_timer.h" +#include +#include + +/** + * @defgroup nrf_libuarte_drv libUARTE driver + * @ingroup app_common + * + * @brief Module for reliable communication over UARTE. + * + * @{ + */ + +/* Number of bytes available in the buffer when RTS line is set. */ +#define NRF_LIBUARTE_DRV_HWFC_BYTE_LIMIT 4 + +typedef enum +{ + NRF_LIBUARTE_DRV_EVT_RX_DATA, ///< Data received. + NRF_LIBUARTE_DRV_EVT_RX_BUF_REQ, ///< Requesting new buffer for receiving data. + NRF_LIBUARTE_DRV_EVT_TX_DONE, ///< Requested TX transfer completed. + NRF_LIBUARTE_DRV_EVT_ERROR, ///< Error reported by the UARTE peripheral. + NRF_LIBUARTE_DRV_EVT_OVERRUN_ERROR ///< Error reported by the driver. +} nrf_libuarte_drv_evt_type_t; + +/** + * @brief PPI channels used by libuarte + */ +typedef enum +{ + NRF_LIBUARTE_DRV_PPI_CH_EXT_TRIGGER_STARTRX_EN_ENDRX_STARTX, + NRF_LIBUARTE_DRV_PPI_CH_RXSTARTED_EXT_TSK, + NRF_LIBUARTE_DRV_PPI_CH_EXT_STOP_STOPRX, + NRF_LIBUARTE_DRV_PPI_CH_EXT_STOP_GROUPS_EN, + NRF_LIBUARTE_DRV_PPI_CH_RXRDY_TIMER_COUNT, + + NRF_LIBUARTE_DRV_PPI_CH_ENDRX_STARTRX, + NRF_LIBUARTE_DRV_PPI_CH_ENDRX_EXT_TSK, + + NRF_LIBUARTE_DRV_PPI_CH_RTS_PIN, + NRF_LIBUARTE_DRV_PPI_CH_RX_MAX, + NRF_LIBUARTE_DRV_PPI_CH_RX_GROUP_MAX = NRF_LIBUARTE_DRV_PPI_CH_RX_MAX, + + NRF_LIBUARTE_DRV_PPI_CH_ENDTX_STARTTX = NRF_LIBUARTE_DRV_PPI_CH_RX_GROUP_MAX, + + NRF_LIBUARTE_DRV_PPI_CH_MAX +} nrf_libuarte_drv_ppi_channel_t; + +/** + * @brief PPI groups used by libuarte + */ +typedef enum +{ + NRF_LIBUARTE_DRV_PPI_GROUP_ENDRX_STARTRX, ///< Group used for controlling PPI connection between ENDRX and STARTRX + NRF_LIBUARTE_DRV_PPI_GROUP_ENDRX_EXT_RXDONE_TSK, ///< Group used for controlling PPI connection between ENDRX and RXDONE + NRF_LIBUARTE_DRV_PPI_GROUP_MAX +} nrf_libuarte_drv_ppi_group_t; + +typedef struct +{ + uint8_t * p_data; ///< Pointer to the data to be sent or received. + size_t length; ///< Length of the data. +} nrf_libuarte_drv_data_t; + +typedef struct +{ + uint32_t overrun_length; +} nrf_libuarte_drv_overrun_err_evt_t; + +typedef struct +{ + nrf_libuarte_drv_evt_type_t type; ///< Event type. + union { + nrf_libuarte_drv_data_t rxtx; ///< Data provided for transfer completion events. + uint8_t errorsrc; ///< Error source flags. + nrf_libuarte_drv_overrun_err_evt_t overrun_err; ///< SW Error structure. + } data; +} nrf_libuarte_drv_evt_t; + +typedef struct { + uint32_t tx_pin; ///< TXD pin number. + uint32_t rx_pin; ///< RXD pin number. + uint32_t cts_pin; ///< CTS pin number. + uint32_t rts_pin; ///< RTS pin number. + uint32_t startrx_evt; ///< Event to trigger STARTRX task in UARTE. + uint32_t endrx_evt; ///< Event to trigger STOPRX task in UARTE. + uint32_t rxstarted_tsk; ///< Task to be triggered when RXSTARTED UARTE event occurs. + uint32_t rxdone_tsk; ///< Task to be triggered when ENDRX UARTE event occurs. + nrf_uarte_hwfc_t hwfc; ///< Flow control configuration. + nrf_uarte_parity_t parity; ///< Parity configuration. + nrf_uarte_baudrate_t baudrate; ///< Baud rate. + uint8_t irq_priority; ///< Interrupt priority. + bool pullup_rx; ///< Pull up on RX pin. +} nrf_libuarte_drv_config_t; + +typedef void (*nrf_libuarte_drv_evt_handler_t)(void * context, + nrf_libuarte_drv_evt_t * p_evt); + +extern const IRQn_Type libuarte_irqn[]; + +typedef struct { + nrf_ppi_channel_t ppi_channels[NRF_LIBUARTE_DRV_PPI_CH_MAX]; + nrf_ppi_channel_group_t ppi_groups[NRF_LIBUARTE_DRV_PPI_GROUP_MAX]; + + uint8_t * p_tx; + size_t tx_len; + size_t tx_cur_idx; + + uint8_t * p_cur_rx; + uint8_t * p_next_rx; + uint8_t * p_next_next_rx; + nrf_libuarte_drv_evt_handler_t evt_handler; + uint32_t last_rx_byte_cnt; + uint32_t last_pin_rx_byte_cnt; + uint32_t chunk_size; + void * context; + uint16_t tx_chunk8; + uint8_t rts_pin; + bool rts_manual; +} nrf_libuarte_drv_ctrl_blk_t; + +typedef struct { + nrf_libuarte_drv_ctrl_blk_t * ctrl_blk; + nrfx_timer_t timer; + NRF_UARTE_Type * uarte; +} nrf_libuarte_drv_t; + +#define NRF_LIBUARTE_DRV_DEFINE(_name, _uarte_idx, _timer_idx) \ + STATIC_ASSERT(_uarte_idx < UARTE_COUNT, "UARTE instance not present");\ + STATIC_ASSERT(CONCAT_2(NRF_LIBUARTE_DRV_UARTE,_uarte_idx) == 1, "UARTE instance not enabled");\ + STATIC_ASSERT(CONCAT_3(NRFX_TIMER,_timer_idx, _ENABLED) == 1, "Timer instance not enabled");\ + static nrf_libuarte_drv_ctrl_blk_t CONCAT_2(_name, ctrl_blk); \ + static const nrf_libuarte_drv_t _name = { \ + .ctrl_blk = &CONCAT_2(_name, ctrl_blk), \ + .timer = NRFX_TIMER_INSTANCE(_timer_idx), \ + .uarte = CONCAT_2(NRF_UARTE, _uarte_idx),\ + } + +/** + * @brief Function for initializing the libUARTE library. + * + * @param[in] p_libuarte Pointer to libuarte instance. + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] evt_handler Event handler provided by the user. Must not be NULL. + * @param[in] context User context passed in the callback. + * + * @return NRF_SUCCESS when properly initialized. NRF_ERROR_INTERNAL otherwise. + */ +ret_code_t nrf_libuarte_drv_init(const nrf_libuarte_drv_t * const p_libuarte, + nrf_libuarte_drv_config_t * p_config, + nrf_libuarte_drv_evt_handler_t evt_handler, void * context); + +/** + * @brief Function for uninitializing the libUARTE library. + * + * @param[in] p_libuarte Pointer to libuarte instance. + */ +void nrf_libuarte_drv_uninit(const nrf_libuarte_drv_t * const p_libuarte); + +/** + * @brief Function for sending data over UARTE using EasyDMA. + * + * @param[in] p_libuarte Pointer to libuarte instance. + * @param[in] p_data Pointer to data. + * @param[in] len Number of bytes to send. + * + * @retval NRF_ERROR_BUSY Data is transferring. + * @retval NRF_ERROR_INTERNAL Error during PPI channel configuration. + * @retval NRF_SUCCESS Buffer set for sending. + */ +ret_code_t nrf_libuarte_drv_tx(const nrf_libuarte_drv_t * const p_libuarte, + uint8_t * p_data, size_t len); + +/** + * @brief Function for starting receiving data with additional configuration of external + * trigger to start receiving. + * + * @param p_libuarte Pointer to libuarte instance. + * @param p_data Pointer to data. + * @param len Number of bytes to receive. Maximum possible length is + * dependent on the used SoC (see the MAXCNT register + * description in the Product Specification). The library + * checks it with an assertion. + * @param ext_trigger_en True to disable immediate start. + * + * @retval NRF_ERROR_INTERNAL Error during PPI channel configuration. + * @retval NRF_SUCCESS Buffer set for receiving. + */ +ret_code_t nrf_libuarte_drv_rx_start(const nrf_libuarte_drv_t * const p_libuarte, + uint8_t * p_data, size_t len, bool ext_trigger_en); + +/** + * @brief Function for setting a buffer for data that will be later received in UARTE. + * + * @param p_libuarte Pointer to libuarte instance. + * @param p_data Pointer to data. + * @param len Number of bytes to receive. Maximum possible length is + * dependent on the used SoC (see the MAXCNT register + * description in the Product Specification). The library + * checks it with an assertion. + */ +void nrf_libuarte_drv_rx_buf_rsp(const nrf_libuarte_drv_t * const p_libuarte, + uint8_t * p_data, size_t len); + +/** + * @brief Function for stopping receiving data over UARTE. + * + * @param p_libuarte Pointer to libuarte instance. + */ +void nrf_libuarte_drv_rx_stop(const nrf_libuarte_drv_t * const p_libuarte); + +/** + * @brief Function for deasserting RTS to pause the transmission. + * + * Flow control must be enabled. + * + * @param p_libuarte Pointer to libuarte instance. + */ +void nrf_libuarte_drv_rts_clear(const nrf_libuarte_drv_t * const p_libuarte); + +/** + * @brief Function for asserting RTS to restart the transmission. + * + * Flow control must be enabled. + * + * @param p_libuarte Pointer to libuarte instance. + */ +void nrf_libuarte_drv_rts_set(const nrf_libuarte_drv_t * const p_libuarte); + + +/** @} */ + +#endif //NRF_LIBUARTE_DRV_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log.h similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log.h index 967bc1a..2298417 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -71,6 +71,12 @@ extern "C" { #define NRF_LOG_LEVEL NRF_LOG_DEFAULT_LEVEL #endif +/** @brief Initial severity if filtering is enabled. + */ +#ifndef NRF_LOG_INITIAL_LEVEL + #define NRF_LOG_INITIAL_LEVEL NRF_LOG_LEVEL +#endif + #include "nrf_log_internal.h" @@ -107,14 +113,54 @@ extern "C" { #define NRF_LOG_INFO(...) NRF_LOG_INTERNAL_INFO( __VA_ARGS__) #define NRF_LOG_DEBUG(...) NRF_LOG_INTERNAL_DEBUG( __VA_ARGS__) +/** @def NRF_LOG_INST_ERROR + * @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_INST_WARNING + * @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_INST_INFO + * @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_INST_DEBUG + * @brief Macro for logging error messages for given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ +#define NRF_LOG_INST_ERROR(p_inst,...) NRF_LOG_INTERNAL_INST_ERROR(p_inst,__VA_ARGS__) +#define NRF_LOG_INST_WARNING(p_inst,...) NRF_LOG_INTERNAL_INST_WARNING(p_inst,__VA_ARGS__) +#define NRF_LOG_INST_INFO(p_inst,...) NRF_LOG_INTERNAL_INST_INFO(p_inst, __VA_ARGS__) +#define NRF_LOG_INST_DEBUG(p_inst,...) NRF_LOG_INTERNAL_INST_DEBUG(p_inst, __VA_ARGS__) + /** - * @brief A macro for logging a formatted string without any prefix or timestamp. + * @brief Macro for logging a formatted string without any prefix or timestamp. */ #define NRF_LOG_RAW_INFO(...) NRF_LOG_INTERNAL_RAW_INFO( __VA_ARGS__) /** @def NRF_LOG_HEXDUMP_ERROR * @brief Macro for logging raw bytes. - * @details It is compiled in only if @ref NRF_LOG_LEVEL includes error logs. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. * * @param p_data Pointer to data. * @param len Data length in bytes. @@ -145,20 +191,51 @@ extern "C" { #define NRF_LOG_HEXDUMP_INFO(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len) #define NRF_LOG_HEXDUMP_DEBUG(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len) +/** @def NRF_LOG_HEXDUMP_INST_ERROR + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INST_WARNING + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INST_INFO + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INST_DEBUG + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +#define NRF_LOG_HEXDUMP_INST_ERROR(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len) +#define NRF_LOG_HEXDUMP_INST_WARNING(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len) +#define NRF_LOG_HEXDUMP_INST_INFO(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len) +#define NRF_LOG_HEXDUMP_INST_DEBUG(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len) + /** * @brief Macro for logging hexdump without any prefix or timestamp. */ #define NRF_LOG_RAW_HEXDUMP_INFO(p_data, len) NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len) -/** - * @brief A macro for blocking reading from bidirectional backend used for logging. - * - * Macro call is blocking and returns when single byte is received. - */ -#define NRF_LOG_GETCHAR() NRF_LOG_INTERNAL_GETCHAR() /** - * @brief A macro for copying a string to internal logger buffer if logs are deferred. + * @brief Macro for copying a string to internal logger buffer if logs are deferred. * * @param _str String. */ @@ -169,7 +246,12 @@ extern "C" { * * Use this function to store a string that is volatile (for example allocated * on stack) or that may change before the deferred logs are processed. Such string is copied - * into the internal logger buffer and is persistent until the log is processed. + * into the internal logger buffer (see @ref NRF_LOG_STR_PUSH_BUFFER_SIZE). + * + * @note String storing is not reliable. It means that string is copied to the buffer but there is + * no indication when it was used and could be freed. String may be overwritten by another + * @ref nrf_log_push call before being processed. For reliable data dumping use + * hexdump macros (e.g. @ref NRF_LOG_HEXDUMP_INFO). * * @note If the logs are not deferred, then this function returns the input parameter. * @@ -177,12 +259,12 @@ extern "C" { * * @return Address to the location where the string is stored in the internal logger buffer. */ -uint32_t nrf_log_push(char * const p_str); +char const * nrf_log_push(char * const p_str); /** * @brief Macro to be used in a formatted string to a pass float number to the log. * - * Macro should be used in formatted string instead of the %f specifier together with + * Use this macro in a formatted string instead of the %f specifier together with * @ref NRF_LOG_FLOAT macro. * Example: NRF_LOG_INFO("My float number" NRF_LOG_FLOAT_MARKER "\r\n", NRF_LOG_FLOAT(f))) */ @@ -197,33 +279,13 @@ uint32_t nrf_log_push(char * const p_str); : (int32_t)(val) - (val))*100) - /** - * @def NRF_LOG_MODULE_REGISTER * @brief Macro for registering an independent module. + * + * Registration creates set of dynamic (RAM) and constant variables associated with the module. */ -#if NRF_LOG_ENABLED +#define NRF_LOG_MODULE_REGISTER() NRF_LOG_INTERNAL_MODULE_REGISTER() -#ifdef UNIT_TEST -#define _CONST -#define COMPILED_LOG_LEVEL 4 -#else -#define _CONST const -#define COMPILED_LOG_LEVEL NRF_LOG_LEVEL -#endif -#define NRF_LOG_MODULE_REGISTER() \ - NRF_SECTION_ITEM_REGISTER(NRF_LOG_CONST_SECTION_NAME(NRF_LOG_MODULE_NAME), \ - _CONST nrf_log_module_const_data_t NRF_LOG_MODULE_DATA_CONST) = { \ - .p_module_name = STRINGIFY(NRF_LOG_MODULE_NAME), \ - .info_color_id = NRF_LOG_INFO_COLOR, \ - .debug_color_id = NRF_LOG_DEBUG_COLOR, \ - .compiled_lvl = COMPILED_LOG_LEVEL, \ - }; \ - NRF_SECTION_ITEM_REGISTER(NRF_LOG_DYNAMIC_SECTION_NAME(NRF_LOG_MODULE_NAME), \ - nrf_log_module_dynamic_data_t NRF_LOG_MODULE_DATA_DYNAMIC) -#else -#define NRF_LOG_MODULE_REGISTER() /*lint -save -e19*/ /*lint -restore*/ -#endif #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_flash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_flash.h new file mode 100644 index 0000000..d4d689a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_flash.h @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2018 - 2019, 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 nrf_log_backend_flash Flash logger backend + * @{ + * @ingroup nrf_log + * @brief Flash logger backend. + */ + +#ifndef NRF_LOG_BACKEND_FLASH_H +#define NRF_LOG_BACKEND_FLASH_H + +#include "nrf_log_backend_interface.h" +#include "nrf_fstorage.h" +#include "nrf_log_internal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Flashlog logger backend API. */ +extern const nrf_log_backend_api_t nrf_log_backend_flashlog_api; + +/** @brief Crashlog logger backend API. */ +extern const nrf_log_backend_api_t nrf_log_backend_crashlog_api; + +/** @brief Flashlog logger backend structure. */ +typedef struct { + nrf_log_backend_t backend; +} nrf_log_backend_flashlog_t; + +/** @brief Crashlog logger backend structure. */ +typedef struct { + nrf_log_backend_t backend; +} nrf_log_backend_crashlog_t; + +/** @brief Macro for creating an instance of the flashlog logger backend. */ +#define NRF_LOG_BACKEND_FLASHLOG_DEF(_name) \ + NRF_LOG_BACKEND_DEF(_name, nrf_log_backend_flashlog_api, NULL) + +/** @brief Macro for creating an instance of the crashlog logger backend. */ +#define NRF_LOG_BACKEND_CRASHLOG_DEF(_name) \ + NRF_LOG_BACKEND_DEF(_name, nrf_log_backend_crashlog_api, NULL) + +/** + * @brief Function for initializing the flash logger backend. + * + * Flash logger backend consists of two logical backends: flashlog and crashlog. Since both + * backends write to the same flash area, the initialization is common. + * + * @param p_fs_api fstorage API to be used. + * + * @return NRF_SUCCESS or error code returned by @ref nrf_fstorage_init. + */ +ret_code_t nrf_log_backend_flash_init(nrf_fstorage_api_t const * p_fs_api); + +/** + * @brief Function for getting a log entry stored in flash. + * + * Log messages stored in flash can be read one by one starting from the oldest one. + * + * @param[in, out] p_token Token reused between consecutive readings of log entries. + * Token must be set to 0 to read the first entry. + * @param[out] pp_header Pointer to the entry header. + * @param[out] pp_data Pointer to the data part of the entry (arguments or data in case of hexdump). + * + * @retval NRF_SUCCESS Entry was successfully read. + * @retval NRF_ERROR_NOT_SUPPORTED fstorage API does not support direct reading. + * @retval NRF_ERROR_NOT_FOUND Entry not found. Last entry was already reached or area is empty. + */ +ret_code_t nrf_log_backend_flash_next_entry_get(uint32_t * p_token, + nrf_log_header_t * * pp_header, + uint8_t * * pp_data); + +/** + * @brief Function for erasing flash area dedicated for the flash logger backend. + */ +ret_code_t nrf_log_backend_flash_erase(void); + +#ifdef __cplusplus +} +#endif + +#endif //NRF_LOG_BACKEND_UART_H + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_interface.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_interface.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_interface.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_interface.h index e5b965f..57548e5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_interface.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_interface.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_LOG_BACKEND_INTERFACE_H #define NRF_LOG_BACKEND_INTERFACE_H @@ -50,18 +50,26 @@ * @brief The nrf_log backend interface. */ +#if NRF_MODULE_ENABLED(NRF_LOG) #include "nrf_memobj.h" +#endif + +#include "nrf_section.h" +#include "nordic_common.h" #include #ifdef __cplusplus extern "C" { #endif - /** * @brief nrf_log entry. */ +#if NRF_LOG_ENABLED typedef nrf_memobj_t nrf_log_entry_t; +#else +typedef void nrf_log_entry_t; +#endif /* Forward declaration of the nrf_log_backend_t type. */ typedef struct nrf_log_backend_s nrf_log_backend_t; @@ -87,24 +95,67 @@ typedef struct void (*flush)(nrf_log_backend_t const * p_backend); } nrf_log_backend_api_t; +/** + * @brief Logger backend control block. + */ +typedef struct +{ + nrf_log_backend_t const * p_next; //!< Pointer to the next backend in the logger. + uint8_t id; //!< ID of the backend. + bool enabled; //!< Enable flag. +} nrf_log_backend_cb_t; + /** * @brief Logger backend structure. */ struct nrf_log_backend_s { nrf_log_backend_api_t const * p_api; //!< Pointer to interface. - nrf_log_backend_t * p_next; //!< Pointer to next backend added to the logger. - uint8_t id; //!< Backend id. - bool enabled;//!< Flag indicating backend status. + void * p_ctx; //!< User context. + char * p_name; //!< Name of the backend. + nrf_log_backend_cb_t * p_cb; //!< Pointer to the backend control block. }; + +#define NRF_LOG_BACKEND_SECTION_NAME log_backends + +#define NRF_LOG_BACKEND_SUBSECTION_NAME(_name) NRF_LOG_BACKEND_SECTION_NAME + +/** @brief Invalid ID value indicating that logger backend is not attached to the logger frontend.*/ +#define NRF_LOG_BACKEND_INVALID_ID 0xFF + +/** @brief Memory section where backends are located. */ +NRF_SECTION_DEF(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t); + +/** + * @brief Macro for creating a logger backend instance. + * + * @param _name Name of the backend instance. + * @param _api Logger backend API. + * @param _p_ctx Pointer to the user context. + */ +#define NRF_LOG_BACKEND_DEF(_name, _api, _p_ctx) \ + static nrf_log_backend_cb_t CONCAT_2(log_backend_cb_, _name) = { \ + .enabled = false, \ + .id = NRF_LOG_BACKEND_INVALID_ID, \ + .p_next = NULL \ + }; \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_BACKEND_SUBSECTION_NAME(_name), \ + static const nrf_log_backend_t _name) = { \ + .p_api = &_api, \ + .p_ctx = _p_ctx, \ + .p_cb = &CONCAT_2(log_backend_cb_, _name), \ + .p_name = (char *)STRINGIFY(_name) \ + } + + /** * @brief Function for putting message with log entry to the backend. * * @param[in] p_backend Pointer to the backend instance. * @param[in] p_msg Pointer to message with log entry. */ -__STATIC_INLINE void nrf_log_backend_put(nrf_log_backend_t const * p_backend, +__STATIC_INLINE void nrf_log_backend_put(nrf_log_backend_t const * const p_backend, nrf_log_entry_t * p_msg); /** @@ -112,14 +163,16 @@ __STATIC_INLINE void nrf_log_backend_put(nrf_log_backend_t const * p_backend, * * @param[in] p_backend Pointer to the backend instance. */ -__STATIC_INLINE void nrf_log_backend_panic_set(nrf_log_backend_t const * p_backend); +__STATIC_INLINE void nrf_log_backend_panic_set(nrf_log_backend_t const * const p_backend); /** * @brief Function for flushing backend. * + * On flushing request backend should release log message(s). + * * @param[in] p_backend Pointer to the backend instance. */ -__STATIC_INLINE void nrf_log_backend_flush(nrf_log_backend_t const * p_backend); +__STATIC_INLINE void nrf_log_backend_flush(nrf_log_backend_t const * const p_backend); /** @@ -130,7 +183,7 @@ __STATIC_INLINE void nrf_log_backend_flush(nrf_log_backend_t const * p_backend); * @param[in] p_backend Pointer to the backend instance. * @param[in] id Id. */ -__STATIC_INLINE void nrf_log_backend_id_set(nrf_log_backend_t * p_backend, uint8_t id); +__STATIC_INLINE void nrf_log_backend_id_set(nrf_log_backend_t const * const p_backend, uint8_t id); /** * @brief Function for getting backend id. @@ -140,21 +193,21 @@ __STATIC_INLINE void nrf_log_backend_id_set(nrf_log_backend_t * p_backend, uint8 * @param[in] p_backend Pointer to the backend instance. * @return Id. */ -__STATIC_INLINE uint8_t nrf_log_backend_id_get(nrf_log_backend_t const * p_backend); +__STATIC_INLINE uint8_t nrf_log_backend_id_get(nrf_log_backend_t const * const p_backend); /** * @brief Function for enabling backend. * * @param[in] p_backend Pointer to the backend instance. */ -__STATIC_INLINE void nrf_log_backend_enable(nrf_log_backend_t * p_backend); +__STATIC_INLINE void nrf_log_backend_enable(nrf_log_backend_t const * const p_backend); /** * @brief Function for disabling backend. * * @param[in] p_backend Pointer to the backend instance. */ -__STATIC_INLINE void nrf_log_backend_disable(nrf_log_backend_t * p_backend); +__STATIC_INLINE void nrf_log_backend_disable(nrf_log_backend_t const * const p_backend); /** * @brief Function for checking state of the backend. @@ -163,48 +216,48 @@ __STATIC_INLINE void nrf_log_backend_disable(nrf_log_backend_t * p_backend); * * @return True if backend is enabled, false otherwise. */ -__STATIC_INLINE bool nrf_log_backend_is_enabled(nrf_log_backend_t const * p_backend); +__STATIC_INLINE bool nrf_log_backend_is_enabled(nrf_log_backend_t const * const p_backend); #ifndef SUPPRESS_INLINE_IMPLEMENTATION -__STATIC_INLINE void nrf_log_backend_put(nrf_log_backend_t const * p_backend, +__STATIC_INLINE void nrf_log_backend_put(nrf_log_backend_t const * const p_backend, nrf_log_entry_t * p_msg) { p_backend->p_api->put(p_backend, p_msg); } -__STATIC_INLINE void nrf_log_backend_panic_set(nrf_log_backend_t const * p_backend) +__STATIC_INLINE void nrf_log_backend_panic_set(nrf_log_backend_t const * const p_backend) { p_backend->p_api->panic_set(p_backend); } -__STATIC_INLINE void nrf_log_backend_flush(nrf_log_backend_t const * p_backend) +__STATIC_INLINE void nrf_log_backend_flush(nrf_log_backend_t const * const p_backend) { - p_backend->p_api->panic_set(p_backend); + p_backend->p_api->flush(p_backend); } -__STATIC_INLINE void nrf_log_backend_id_set(nrf_log_backend_t * p_backend, uint8_t id) +__STATIC_INLINE void nrf_log_backend_id_set(nrf_log_backend_t const * const p_backend, uint8_t id) { - p_backend->id = id; + p_backend->p_cb->id = id; } -__STATIC_INLINE uint8_t nrf_log_backend_id_get(nrf_log_backend_t const * p_backend) +__STATIC_INLINE uint8_t nrf_log_backend_id_get(nrf_log_backend_t const * const p_backend) { - return p_backend->id; + return p_backend->p_cb->id; } -__STATIC_INLINE void nrf_log_backend_enable(nrf_log_backend_t * p_backend) +__STATIC_INLINE void nrf_log_backend_enable(nrf_log_backend_t const * const p_backend) { - p_backend->enabled = true; + p_backend->p_cb->enabled = true; } -__STATIC_INLINE void nrf_log_backend_disable(nrf_log_backend_t * p_backend) +__STATIC_INLINE void nrf_log_backend_disable(nrf_log_backend_t const * const p_backend) { - p_backend->enabled = false; + p_backend->p_cb->enabled = false; } -__STATIC_INLINE bool nrf_log_backend_is_enabled(nrf_log_backend_t const * p_backend) +__STATIC_INLINE bool nrf_log_backend_is_enabled(nrf_log_backend_t const * const p_backend) { - return p_backend->enabled; + return p_backend->p_cb->enabled; } #endif // SUPPRESS_INLINE_IMPLEMENTATION diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_rtt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_rtt.h similarity index 89% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_rtt.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_rtt.h index 66eeeb6..2cc1cd2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_rtt.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_rtt.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -51,6 +51,10 @@ #include "nrf_log_backend_interface.h" +#ifdef __cplusplus +extern "C" { +#endif + extern const nrf_log_backend_api_t nrf_log_backend_rtt_api; typedef struct { @@ -62,12 +66,15 @@ typedef struct { * * @param _name Name of the instance. */ -#define NRF_LOG_BACKEND_RTT_DEF(_name) \ - static nrf_log_backend_rtt_t _name = { \ - .backend = {.p_api = &nrf_log_backend_rtt_api}, \ - } +#define NRF_LOG_BACKEND_RTT_DEF(_name) \ + NRF_LOG_BACKEND_DEF(_name, nrf_log_backend_rtt_api, NULL) void nrf_log_backend_rtt_init(void); + +#ifdef __cplusplus +} +#endif + #endif //NRF_LOG_BACKEND_RTT_H /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_uart.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_uart.h similarity index 89% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_uart.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_uart.h index 4f9ce12..0a837f2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_backend_uart.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_backend_uart.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -51,18 +51,25 @@ #include "nrf_log_backend_interface.h" +#ifdef __cplusplus +extern "C" { +#endif + extern const nrf_log_backend_api_t nrf_log_backend_uart_api; typedef struct { nrf_log_backend_t backend; } nrf_log_backend_uart_t; -#define NRF_LOG_BACKEND_UART_DEF(name) \ - static nrf_log_backend_uart_t name = { \ - .backend = {.p_api = &nrf_log_backend_uart_api}, \ - } +#define NRF_LOG_BACKEND_UART_DEF(_name) \ + NRF_LOG_BACKEND_DEF(_name, nrf_log_backend_uart_api, NULL) void nrf_log_backend_uart_init(void); + +#ifdef __cplusplus +} +#endif + #endif //NRF_LOG_BACKEND_UART_H /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_ctrl.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_ctrl.h similarity index 83% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_ctrl.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_ctrl.h index 0fbce41..48a509b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_ctrl.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_ctrl.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_LOG_CTRL_H #define NRF_LOG_CTRL_H @@ -54,21 +54,13 @@ #include "sdk_errors.h" #include #include +#include "nrf_log_types.h" #include "nrf_log_ctrl_internal.h" #include "nrf_log_backend_interface.h" #ifdef __cplusplus extern "C" { #endif -typedef enum -{ - NRF_LOG_SEVERITY_NONE, - NRF_LOG_SEVERITY_ERROR, - NRF_LOG_SEVERITY_WARNING, - NRF_LOG_SEVERITY_INFO, - NRF_LOG_SEVERITY_DEBUG, -} nrf_log_severity_t; - /** * @brief Timestamp function prototype. * @@ -76,16 +68,17 @@ typedef enum */ typedef uint32_t (*nrf_log_timestamp_func_t)(void); + /**@brief Macro for initializing the logs. * - * @note If timestamps are disabled in the configuration, then the provided pointer - * can be NULL. Otherwise, it is expected that timestamp_getter is not NULL. - * - * @param timestamp_func Function that returns the timestamp. + * Macro has one or two parameters. First parameter (obligatory) is the timestamp function (@ref nrf_log_timestamp_func_t). + * Additionally, as the second parameter timestamp frequency in Hz can be provided. If not provided then default + * frequency is used (@ref NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY). Frequency is used to format timestamp prefix if + * @ref NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED is set. * * @return NRF_SUCCESS after successful initialization, otherwise an error code. */ -#define NRF_LOG_INIT(timestamp_func) NRF_LOG_INTERNAL_INIT(timestamp_func) +#define NRF_LOG_INIT(...) NRF_LOG_INTERNAL_INIT(__VA_ARGS__) /**@brief Macro for processing a single log entry from a queue of deferred logs. @@ -123,11 +116,12 @@ typedef uint32_t (*nrf_log_timestamp_func_t)(void); * Instead, frontend and user backend should be verbosely initialized. * * @param timestamp_func Function for getting a 32-bit timestamp. + * @param timestamp_freq Frequency of the timestamp. * * @return Error status. * */ -ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func); +ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func, uint32_t timestamp_freq); /** * @brief Function for adding new backend interface to the logger. @@ -137,7 +131,7 @@ ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func); * option is only applicable if @ref NRF_LOG_FILTERS_ENABLED is set. * @return -1 if backend cannot be added or positive number (backend ID). */ -int32_t nrf_log_backend_add(nrf_log_backend_t * p_backend, nrf_log_severity_t severity); +int32_t nrf_log_backend_add(nrf_log_backend_t const * p_backend, nrf_log_severity_t severity); /** * @brief Function for removing backend from the logger. @@ -145,7 +139,7 @@ int32_t nrf_log_backend_add(nrf_log_backend_t * p_backend, nrf_log_severity_t se * @param p_backend Pointer to the backend interface. * */ -void nrf_log_backend_remove(nrf_log_backend_t * p_backend); +void nrf_log_backend_remove(nrf_log_backend_t const * p_backend); /** * @brief Function for setting logger backends into panic mode. @@ -222,6 +216,22 @@ nrf_log_severity_t nrf_log_module_filter_get(uint32_t backend_id, bool is_ordered_idx, bool dynamic); +/** + * @brief Function stores current filtering configuration into non-volatile memory using @ref fds module. + * + * @return NRF_SUCCESS or @ref fds error code. + */ +ret_code_t nrf_log_config_store(void); + +/** + * @brief Function loads configuration from non-volatile memory using @ref fds module. + * + * @retval NRF_SUCCESS On successful loading. + * @retval NRF_ERROR_NOT_FOUND Configuration file not found. + * @retval NRF_ERROR_INTERNAL Other @ref fds error on reading configuration file. + */ +ret_code_t nrf_log_config_load(void); + #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_default_backends.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_default_backends.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_default_backends.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_default_backends.h index 982f3b1..5dfeec0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_default_backends.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_default_backends.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_LOG_DEFAULT_BACKENDS_H__ #define NRF_LOG_DEFAULT_BACKENDS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_instance.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_instance.h new file mode 100644 index 0000000..11bfcba --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_instance.h @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_LOG_INSTANCE_H +#define NRF_LOG_INSTANCE_H + +#include "sdk_config.h" +#include "nrf_section.h" +#include "nrf_log_types.h" +#include + + +/* + * For GCC, sections are sorted in the group by the linker. For IAR and KEIL, it is assumed that linker will sort + * dynamic and const section in the same order (but in different locations). Proper message formatting + * is based on that assumption. + */ +#if defined(__GNUC__) +#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) CONCAT_2(log_dynamic_data_,_module_name) +#define NRF_LOG_FILTER_SECTION_NAME(_module_name) CONCAT_2(log_filter_data_,_module_name) +#define NRF_LOG_CONST_SECTION_NAME(_module_name) CONCAT_2(log_const_data_,_module_name) +#else +#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) log_dynamic_data +#define NRF_LOG_FILTER_SECTION_NAME(_module_name) log_filter_data +#define NRF_LOG_CONST_SECTION_NAME(_module_name) log_const_data +#endif + +#define NRF_LOG_ITEM_DATA(_name) CONCAT_3(m_nrf_log_,_name,_logs_data) +#define NRF_LOG_ITEM_DATA_DYNAMIC(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_dynamic) +#define NRF_LOG_ITEM_DATA_FILTER(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_filter) +#define NRF_LOG_ITEM_DATA_CONST(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_const) + +#ifdef UNIT_TEST +#define _CONST +#else +#define _CONST const +#endif + +/*lint -save -esym(526,log_const_data*) -esym(526,log_dynamic_data*)*/ +NRF_SECTION_DEF(log_dynamic_data, nrf_log_module_dynamic_data_t); +NRF_SECTION_DEF(log_filter_data, nrf_log_module_filter_data_t); +NRF_SECTION_DEF(log_const_data, nrf_log_module_const_data_t); +/*lint -restore*/ + +#define NRF_LOG_INTERNAL_CONST_ITEM_REGISTER( \ + _name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_CONST_SECTION_NAME(_name), \ + _CONST nrf_log_module_const_data_t NRF_LOG_ITEM_DATA_CONST(_name)) = { \ + .p_module_name = _str_name, \ + .info_color_id = (_info_color), \ + .debug_color_id = (_debug_color), \ + .compiled_lvl = (nrf_log_severity_t)(_compiled_lvl), \ + .initial_lvl = (nrf_log_severity_t)(_initial_lvl), \ + } + +#if NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_INTERNAL_ITEM_REGISTER( \ + _name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_LOG_INTERNAL_CONST_ITEM_REGISTER(_name, \ + _str_name, \ + _info_color, \ + _debug_color, \ + _initial_lvl, \ + _compiled_lvl); \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_DYNAMIC_SECTION_NAME(_name), \ + nrf_log_module_dynamic_data_t NRF_LOG_ITEM_DATA_DYNAMIC(_name)); \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_FILTER_SECTION_NAME(_name), \ + nrf_log_module_filter_data_t NRF_LOG_ITEM_DATA_FILTER(_name)) + +#else +#define NRF_LOG_INTERNAL_ITEM_REGISTER( \ + _name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_LOG_INTERNAL_CONST_ITEM_REGISTER(_name, \ + _str_name, \ + _info_color, \ + _debug_color, \ + _initial_lvl, \ + _compiled_lvl) + +#endif +/**@file + * + * @defgroup nrf_log_instance Macros for logging on instance level + * @{ + * @ingroup nrf_log + * + * @brief Macros for logging on instance level + */ + +/** @def NRF_LOG_INSTANCE_PTR_DECLARE + * @brief Macro for declaring a logger instance pointer in the module stucture. + */ + +/** @def NRF_LOG_INSTANCE_REGISTER + * @brief Macro for creating an independent module instance. + * + * Module instance provides filtering of logs on instance level instead of module level. + */ + +/** @def NRF_LOG_INSTANCE_PTR_INIT + * @brief Macro for initializing a pointer to the logger instance. + */ + + + /** @} */ +#if NRF_LOG_ENABLED && NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_INSTANCE_PTR_DECLARE(_p_name) nrf_log_module_dynamic_data_t * _p_name; + +#define NRF_LOG_INSTANCE_REGISTER( \ + _module_name, _inst_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_LOG_INTERNAL_ITEM_REGISTER(CONCAT_3(_module_name,_,_inst_name), \ + STRINGIFY(_module_name._inst_name), \ + _info_color, \ + _debug_color, \ + _initial_lvl, \ + _compiled_lvl) + +#define NRF_LOG_INSTANCE_PTR_INIT(_p_name, _module_name, _inst_name) \ + ._p_name = &NRF_LOG_ITEM_DATA_DYNAMIC(CONCAT_3(_module_name,_,_inst_name)), + +#else +#define NRF_LOG_INSTANCE_PTR_DECLARE(_p_name) +#define NRF_LOG_INSTANCE_REGISTER(_module_name, _inst_name, info_color, debug_color, _initial_lvl, compiled_lvl) +#define NRF_LOG_INSTANCE_PTR_INIT(_p_name, _module_name, _inst_name) +#endif + +#endif //NRF_LOG_INSTANCE_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_str_formatter.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_str_formatter.h similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_str_formatter.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_str_formatter.h index 134812d..ae51eaf 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/nrf_log_str_formatter.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_str_formatter.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,8 +35,16 @@ * 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 nrf_log_str_formatter String formatter for the logger messages + * @{ + * @ingroup nrf_log + */ + #ifndef NRF_LOG_STR_FORMATTER_H #define NRF_LOG_STR_FORMATTER_H @@ -44,15 +52,20 @@ #include "nrf_fprintf.h" #include "nrf_log_ctrl.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { uint32_t timestamp; uint16_t module_id; + uint16_t dropped; nrf_log_severity_t severity; - bool raw; uint8_t use_colors; } nrf_log_str_formatter_entry_params_t; + void nrf_log_std_entry_process(char const * p_str, uint32_t const * p_args, uint32_t nargs, @@ -64,4 +77,10 @@ void nrf_log_hexdump_entry_process(uint8_t * p_data, nrf_log_str_formatter_entry_params_t * p_params, nrf_fprintf_ctx_t * p_ctx); +void nrf_log_str_formatter_timestamp_freq_set(uint32_t freq); +#ifdef __cplusplus +} +#endif + #endif //NRF_LOG_STR_FORMATTER_H +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_types.h new file mode 100644 index 0000000..77a3d88 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/nrf_log_types.h @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2018 - 2019, 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 NRF_LOG_TYPES_H +#define NRF_LOG_TYPES_H + +#include + +/** + * @brief Logger severity levels. + */ +typedef enum +{ + NRF_LOG_SEVERITY_NONE, + NRF_LOG_SEVERITY_ERROR, + NRF_LOG_SEVERITY_WARNING, + NRF_LOG_SEVERITY_INFO, + NRF_LOG_SEVERITY_DEBUG, + NRF_LOG_SEVERITY_INFO_RAW, /* Artificial level to pass information about skipping string postprocessing.*/ +} nrf_log_severity_t; + +/** + * @brief Structure holding dynamic data associated with a module. + * + * See @ref NRF_LOG_MODULE_REGISTER and @ref NRF_LOG_INSTANCE_REGISTER. + */ +typedef struct +{ + uint16_t order_idx; ///< Ordered index of the module (used for auto-completion). + uint16_t filter; ///< Current highest severity level accepted (redundant to @ref nrf_log_module_filter_data_t::filter_lvls, used for optimization) +} nrf_log_module_dynamic_data_t; + +/** + * @brief Structure holding dynamic filters associated with a module or instance if filtering is enabled (@ref NRF_LOG_FILTERS_ENABLED). + * + * @note Backend filters logically are part of @ref nrf_log_module_dynamic_data_t but they are kept separated to enable storing them in non-volatile memory. + */ +typedef struct +{ + uint32_t filter_lvls; ///< Current severity levels for each backend (3 bits per backend). +} nrf_log_module_filter_data_t; + +/** + * @brief Structure holding constant data associated with a module or instance. + * + * See @ref NRF_LOG_MODULE_REGISTER and @ref NRF_LOG_INSTANCE_REGISTER. + */ +typedef struct +{ + const char * p_module_name; ///< Module or instance name. + uint8_t info_color_id; ///< Color code of info messages. + uint8_t debug_color_id; ///< Color code of debug messages. + nrf_log_severity_t compiled_lvl; ///< Compiled highest severity level. + nrf_log_severity_t initial_lvl; ///< Severity level for given module or instance set on backend initialization. +} nrf_log_module_const_data_t; + +#endif //NRF_LOG_TYPES_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_flash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_flash.c new file mode 100644 index 0000000..2038a5d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_flash.c @@ -0,0 +1,740 @@ +/** + * Copyright (c) 2016 - 2019, 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(NRF_LOG) && NRF_MODULE_ENABLED(NRF_LOG_BACKEND_FLASH) +#include "nrf_log_backend_flash.h" +#include "nrf_log_str_formatter.h" +#include "nrf_fstorage_nvmc.h" +#include "nrf_log.h" +#include "nrf_atomic.h" +#include "nrf_queue.h" +#include "app_error.h" +#include + +#if (NRF_LOG_BACKEND_FLASHLOG_ENABLED == 0) && (NRF_LOG_BACKEND_CRASHLOG_ENABLED == 0) +#error "No flash backend enabled." +#endif + +/** @brief Maximum logger message payload (arguments or data in hexdump) which can be stored. */ +#define FLASH_LOG_MAX_PAYLOAD_SIZE (NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE - sizeof(nrf_log_header_t)) + +/** @brief Size of serialization buffer in words. */ +#define FLASH_LOG_SER_BUFFER_WORDS (NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE/sizeof(uint32_t)) + +/** @brief Length of logger header. */ +#define LOG_HEADER_LEN (sizeof(nrf_log_header_t)) + +/** @brief Length of logger header given in 32 bit words. */ +#define LOG_HEADER_LEN_WORDS (LOG_HEADER_LEN/sizeof(uint32_t)) + +/** @brief Maximum possible length of standard log message. */ +#define STD_LOG_MSG_MAX_LEN (LOG_HEADER_LEN + NRF_LOG_MAX_NUM_OF_ARGS*sizeof(uint32_t)) + +/* Buffer must be multiple of 4. */ +STATIC_ASSERT((NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE % sizeof(uint32_t)) == 0); + +/* Buffer must fit standard log message. */ +STATIC_ASSERT(NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE >= STD_LOG_MSG_MAX_LEN); + +/** @brief Flash page size in bytes. */ +#define CODE_PAGE_SIZE 4096 + +/** @brief Start address of the area dedicated for flash log. */ +#define FLASH_LOG_START_ADDR (NRF_LOG_BACKEND_FLASH_START_PAGE * CODE_PAGE_SIZE) + +/** @brief End address of the area dedicated for flash log. */ +#define FLASH_LOG_END_ADDR (FLASH_LOG_START_ADDR + (NRF_LOG_BACKEND_PAGES * CODE_PAGE_SIZE) - 1) + +/** @brief Size of the area dedicated for flash log. */ +#define FLASH_LOG_SIZE (NRF_LOG_BACKEND_PAGES * CODE_PAGE_SIZE) + +/** @brief Start address determined in runtime. + * + * If configuration indicates that flash log should be placed after application. + * */ +#if defined ( __CC_ARM ) +#define RUNTIME_START_ADDR \ + _Pragma("diag_suppress 170") \ + ((NRF_LOG_BACKEND_FLASH_START_PAGE == 0) ? \ + (CODE_PAGE_SIZE*CEIL_DIV((uint32_t)CODE_END, CODE_PAGE_SIZE)) : FLASH_LOG_START_ADDR) \ + _Pragma("diag_default 170") +#else +#define RUNTIME_START_ADDR ((NRF_LOG_BACKEND_FLASH_START_PAGE == 0) ? \ + (CODE_PAGE_SIZE*CEIL_DIV((uint32_t)CODE_END, CODE_PAGE_SIZE)) : FLASH_LOG_START_ADDR) +#endif +static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt); + +/** @brief Message queue for run time flash log. */ +#if NRF_LOG_BACKEND_FLASHLOG_ENABLED +NRF_QUEUE_DEF(nrf_log_entry_t *, + m_flashlog_queue, + NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE, + NRF_QUEUE_MODE_NO_OVERFLOW); +static const nrf_queue_t * mp_flashlog_queue = &m_flashlog_queue; +#else +static const nrf_queue_t * mp_flashlog_queue = NULL; +#endif + + +/** @brief Message FIFO for crash log. */ +#if NRF_LOG_BACKEND_CRASHLOG_ENABLED +NRF_QUEUE_DEF(nrf_log_entry_t *, + m_crashlog_queue, + NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE, + NRF_QUEUE_MODE_NO_OVERFLOW); +static const nrf_queue_t * mp_crashlog_queue = &m_crashlog_queue; +#else +static const nrf_queue_t * mp_crashlog_queue = NULL; +#endif + + +/** @brief Fstorage instance used for flash log. */ +NRF_FSTORAGE_DEF(nrf_fstorage_t m_log_flash_fstorage) = +{ + /* Set a handler for fstorage events. */ + .evt_handler = fstorage_evt_handler, + .start_addr = FLASH_LOG_START_ADDR, + .end_addr = FLASH_LOG_END_ADDR, +}; + +/** @brief Flash log state. */ +typedef enum +{ + LOG_BACKEND_FLASH_ACTIVE, /**< Flash backend is active. */ + LOG_BACKEND_FLASH_INACTIVE, /**< Flash backend is inactive. All incoming requests are skipped. */ + LOG_BACKEND_FLASH_IN_PANIC, /**< Flash backend is in panic mode. Incoming messages are written to flash in synchronous mode. */ +} log_backend_flash_state_t; + +static log_backend_flash_state_t m_state; /**< Flash logger backend state. */ +static nrf_atomic_flag_t m_busy_flag; /**< Flag indicating if module performs flash writing. */ +static uint32_t m_flash_buf[FLASH_LOG_SER_BUFFER_WORDS]; /**< Buffer used for serializing messages. */ +static uint32_t m_curr_addr; /**< Address of free spot in the storage area. */ +static size_t m_curr_len; /**< Length of current message being written. */ +static uint32_t m_dropped; /**< Number of dropped messages. */ + +/** @brief Log message string injected when entering panic mode. */ +static const char crashlog_str[] = "-----------CRASHLOG------------\r\n"; + +/** @brief Function saturates input to maximum possible length and rounds up value to be multiple + * of word size. + * + * @param length Length value. + * + * @return Modified input length. + */ +static uint32_t saturate_align_length(uint32_t length) +{ + length = (length > FLASH_LOG_MAX_PAYLOAD_SIZE) ? FLASH_LOG_MAX_PAYLOAD_SIZE : length; //saturate + length = CEIL_DIV(length, sizeof(uint32_t))*sizeof(uint32_t); + return length; +} + + +/** + * @brief Function for copying logger message to the buffer. + * + * @param[in] p_msg Logger message. + * @param[out] p_buf Output buffer where serialized message is placed. + * @param[in,out] p_len Buffer size as input, length of prepared data as output. + * + * @return True if message fits into the buffer, false otherwise + */ +static bool msg_to_buf(nrf_log_entry_t * p_msg, uint8_t * p_buf, size_t * p_len) +{ + uint32_t data_len; + nrf_log_header_t header = {0}; + size_t memobj_offset = HEADER_SIZE*sizeof(uint32_t); + + nrf_memobj_read(p_msg, &header, HEADER_SIZE*sizeof(uint32_t), 0); + + memcpy(p_buf, &header, sizeof(nrf_log_header_t)); + p_buf += sizeof(nrf_log_header_t); + + switch (header.base.generic.type) + { + case HEADER_TYPE_STD: + { + data_len = header.base.std.nargs * sizeof(uint32_t); + break; + } + case HEADER_TYPE_HEXDUMP: + { + data_len = saturate_align_length(header.base.hexdump.len); + break; + } + default: + *p_len = 0; + return false; + } + nrf_memobj_read(p_msg, p_buf, data_len, memobj_offset); + + if (*p_len >= sizeof(nrf_log_header_t) + data_len) + { + *p_len = sizeof(nrf_log_header_t) + data_len; + return true; + } + else + { + return false; + } +} + +/** + * @brief Function for getting logger message stored in flash. + * + * @param[in] p_buf Pointer to the location where message is stored. + * @param[out] pp_header Pointer to the log message header. + * @param[out] pp_data Pointer to the log message data (arguments or data in case of hexdump). + * + * @return True if message was successfully fetched, false otherwise. + */ +static bool msg_from_buf(uint32_t * p_buf, + nrf_log_header_t * * pp_header, + uint8_t * * pp_data, + uint32_t * p_len) +{ + *pp_header = (nrf_log_header_t *)p_buf; + *pp_data = (uint8_t *)&p_buf[LOG_HEADER_LEN_WORDS]; + + uint32_t data_len; + + switch ((*pp_header)->base.generic.type) + { + case HEADER_TYPE_STD: + { + data_len = ((*pp_header)->base.std.nargs)*sizeof(uint32_t); + break; + } + case HEADER_TYPE_HEXDUMP: + { + + data_len = saturate_align_length((*pp_header)->base.hexdump.len); + break; + } + default: + return false; + } + + *p_len = LOG_HEADER_LEN + data_len; + return true; +} + +/** + * @brief Function for processing log message queue. + * + * If writing to flash is synchronous then function drains the queue and writes all messages to flash. + * If writing to flash is asynchronous then function starts single write operation. In asynchronous mode + * function is called when new message is put into the queue from from flash operation callback. + * + * Function detects the situation that flash module reports attempt to write outside dedicated area. + * In that case flash backend stops writing any new messages. + * + * @param p_queue Queue will log messages + * @param fstorage_blocking If true it indicates that flash operations are blocking, event handler is not used. + */ +static void log_msg_queue_process(nrf_queue_t const * p_queue, bool fstorage_blocking) +{ + nrf_log_entry_t * p_msg; + bool busy = false; + while (nrf_queue_pop(p_queue, &p_msg) == NRF_SUCCESS) + { + ret_code_t err_code; + + m_curr_len = sizeof(m_flash_buf); + if (!msg_to_buf(p_msg, (uint8_t *)m_flash_buf, &m_curr_len)) + { + nrf_memobj_put(p_msg); + continue; + } + + err_code = nrf_fstorage_write(&m_log_flash_fstorage, m_curr_addr, m_flash_buf, m_curr_len, p_msg); + + if (err_code == NRF_SUCCESS) + { + if (fstorage_blocking) + { + m_curr_addr += m_curr_len; + + nrf_memobj_put(p_msg); + } + else + { + busy = true; + break; + } + } + else if (!fstorage_blocking && (err_code == NRF_ERROR_NO_MEM)) + { + // fstorage queue got full. Drop entry. + nrf_memobj_put(p_msg); + m_dropped++; + break; + } + else if (err_code == NRF_ERROR_INVALID_ADDR) + { + // Trying to write outside the area, flash log is full. Skip any new writes. + nrf_memobj_put(p_msg); + m_state = LOG_BACKEND_FLASH_INACTIVE; + } + else + { + ASSERT(false); + } + } + + if (!busy) + { + UNUSED_RETURN_VALUE(nrf_atomic_flag_clear(&m_busy_flag)); + } +} + +static void queue_element_drop(nrf_queue_t const * p_queue) +{ + nrf_log_entry_t * p_msg; + if (nrf_queue_pop(p_queue, &p_msg) == NRF_SUCCESS) + { + m_dropped++; + nrf_memobj_put(p_msg); + } +} + +static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt) +{ + if (m_state == LOG_BACKEND_FLASH_ACTIVE) + { + switch (p_evt->id) + { + case NRF_FSTORAGE_EVT_WRITE_RESULT: + { + if (p_evt->result == NRF_SUCCESS) + { + m_curr_addr += m_curr_len; + m_curr_len = 0; + log_msg_queue_process(mp_flashlog_queue, false); + } + else + { + m_dropped++; + } + + if (p_evt->p_param) + { + nrf_memobj_put((nrf_log_entry_t *)p_evt->p_param); + } + break; + } + default: + break; + } + } + else if ((m_state == LOG_BACKEND_FLASH_INACTIVE) && + (p_evt->id == NRF_FSTORAGE_EVT_ERASE_RESULT) && + (p_evt->addr == RUNTIME_START_ADDR)) + { + m_state = LOG_BACKEND_FLASH_ACTIVE; + } +} + +/** + * @brief Function for enqueueing new message. + * + * If queue is full then the oldest message is freed. + * + * @param p_queue Queue. + * @param p_msg Message. + * + * @return Number of dropped messages + */ +static uint32_t message_enqueue(nrf_queue_t const * p_queue, nrf_log_entry_t * p_msg) +{ + uint32_t dropped = 0; + + //flag was set, busy so enqueue message + while (nrf_queue_push(p_queue, &p_msg) != NRF_SUCCESS) + { + + nrf_log_entry_t * p_old_msg; + if (nrf_queue_pop(p_queue, &p_old_msg) == NRF_SUCCESS) + { + nrf_memobj_put(p_old_msg); + dropped++; + } + } + + return dropped; +} + + +void nrf_log_backend_flashlog_put(nrf_log_backend_t const * p_backend, + nrf_log_entry_t * p_msg) +{ + if (m_state == LOG_BACKEND_FLASH_ACTIVE) + { + nrf_memobj_get(p_msg); + + m_dropped += message_enqueue(mp_flashlog_queue, p_msg); + + if (nrf_atomic_flag_set_fetch(&m_busy_flag) == 0) + { + log_msg_queue_process(mp_flashlog_queue, false); + } + } +} + + +void nrf_log_backend_crashlog_put(nrf_log_backend_t const * p_backend, + nrf_log_entry_t * p_msg) +{ + if (m_state != LOG_BACKEND_FLASH_INACTIVE) + { + nrf_memobj_get(p_msg); + + UNUSED_RETURN_VALUE(message_enqueue(mp_crashlog_queue, p_msg)); + } + + if (m_state == LOG_BACKEND_FLASH_IN_PANIC) + { + log_msg_queue_process(mp_crashlog_queue, true); + } +} + +void nrf_log_backend_flashlog_flush(nrf_log_backend_t const * p_backend) +{ + queue_element_drop(mp_flashlog_queue); +} + +void nrf_log_backend_crashlog_flush(nrf_log_backend_t const * p_backend) +{ + queue_element_drop(mp_crashlog_queue); +} + +void nrf_log_backend_flashlog_panic_set(nrf_log_backend_t const * p_backend) +{ + /* Empty */ +} + +/** + * @brief Function for injecting log message which will indicate start of crash log. + */ +static void crashlog_marker_inject(void) +{ + nrf_log_header_t crashlog_marker_hdr = { + .base = { + .std = { + .type = HEADER_TYPE_STD, + .severity = NRF_LOG_SEVERITY_INFO_RAW, + .nargs = 0, + .addr = (uint32_t)crashlog_str & STD_ADDR_MASK + } + }, + .module_id = 0, + .timestamp = 0, + }; + m_flash_buf[0] = crashlog_marker_hdr.base.raw; + m_flash_buf[1] = crashlog_marker_hdr.module_id; + m_flash_buf[2] = crashlog_marker_hdr.timestamp; + (void)nrf_fstorage_write(&m_log_flash_fstorage, m_curr_addr, m_flash_buf, LOG_HEADER_LEN, NULL); + m_curr_addr += LOG_HEADER_LEN; +} + + +void nrf_log_backend_crashlog_panic_set(nrf_log_backend_t const * p_backend) +{ + if (nrf_fstorage_init(&m_log_flash_fstorage, &nrf_fstorage_nvmc, NULL) == NRF_SUCCESS) + { + m_state = LOG_BACKEND_FLASH_IN_PANIC; + + /* In case of Softdevice MWU may protect access to NVMC. */ + NVIC_DisableIRQ(MWU_IRQn); + + log_msg_queue_process(mp_flashlog_queue, true); + + crashlog_marker_inject(); + + log_msg_queue_process(mp_crashlog_queue, true); + } + else + { + m_state = LOG_BACKEND_FLASH_INACTIVE; + } +} + +/** + * @brief Function for determining first empty location in area dedicated for flash logger backend. + */ +static uint32_t empty_addr_get(void) +{ + uint32_t token = 0; + nrf_log_header_t * p_dummy_header; + uint8_t * p_dummy_data; + + while(nrf_log_backend_flash_next_entry_get(&token, &p_dummy_header, &p_dummy_data) == NRF_SUCCESS) + { + + } + + return token; +} + + +ret_code_t nrf_log_backend_flash_init(nrf_fstorage_api_t const * p_fs_api) +{ + ret_code_t err_code; + + + uint32_t start_addr = RUNTIME_START_ADDR; + uint32_t end_addr = start_addr + FLASH_LOG_SIZE - 1; + + m_log_flash_fstorage.start_addr = start_addr; + m_log_flash_fstorage.end_addr = end_addr; + + err_code = nrf_fstorage_init(&m_log_flash_fstorage, p_fs_api, NULL); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_curr_addr = empty_addr_get(); + m_state = LOG_BACKEND_FLASH_ACTIVE; + + return err_code; +} + + +ret_code_t nrf_log_backend_flash_next_entry_get(uint32_t * p_token, + nrf_log_header_t * * pp_header, + uint8_t * * pp_data) +{ + uint32_t * p_addr = p_token; + uint32_t len; + + *p_addr = (*p_addr == 0) ? RUNTIME_START_ADDR : *p_addr; + + if (nrf_fstorage_rmap(&m_log_flash_fstorage, *p_addr) == NULL) + { + //Supports only memories which can be mapped for reading. + return NRF_ERROR_NOT_SUPPORTED; + } + + if (msg_from_buf((uint32_t *)*p_addr, pp_header, pp_data, &len)) + { + *p_addr += len; + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_NOT_FOUND; + } +} + + +ret_code_t nrf_log_backend_flash_erase(void) +{ + ret_code_t err_code; + + m_state = LOG_BACKEND_FLASH_INACTIVE; + err_code = nrf_fstorage_erase(&m_log_flash_fstorage, RUNTIME_START_ADDR, NRF_LOG_BACKEND_PAGES, NULL); + + m_curr_addr = RUNTIME_START_ADDR; + + return err_code; +} + +#if NRF_LOG_BACKEND_FLASHLOG_ENABLED +const nrf_log_backend_api_t nrf_log_backend_flashlog_api = { + .put = nrf_log_backend_flashlog_put, + .flush = nrf_log_backend_flashlog_flush, + .panic_set = nrf_log_backend_flashlog_panic_set, +}; +#endif + +#if NRF_LOG_BACKEND_CRASHLOG_ENABLED +const nrf_log_backend_api_t nrf_log_backend_crashlog_api = { + .put = nrf_log_backend_crashlog_put, + .flush = nrf_log_backend_crashlog_flush, + .panic_set = nrf_log_backend_crashlog_panic_set, +}; +#endif + +#if NRF_LOG_BACKEND_FLASH_CLI_CMDS +#include "nrf_cli.h" + +static uint8_t m_buffer[64]; +static nrf_cli_t const * mp_cli; + +static void cli_tx(void const * p_context, char const * p_buffer, size_t len); + +static nrf_fprintf_ctx_t m_fprintf_ctx = +{ + .p_io_buffer = (char *)m_buffer, + .io_buffer_size = sizeof(m_buffer)-1, + .io_buffer_cnt = 0, + .auto_flush = true, + .p_user_ctx = &mp_cli, + .fwrite = cli_tx +}; + + +static void flashlog_clear_cmd(nrf_cli_t const * p_cli, size_t argc, char ** argv) +{ + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + } + + UNUSED_RETURN_VALUE(nrf_log_backend_flash_erase()); +} + +#include "nrf_delay.h" +static void cli_tx(void const * p_context, char const * p_buffer, size_t len) +{ + nrf_cli_t * * pp_cli = (nrf_cli_t * *)p_context; + char * p_strbuf = (char *)&p_buffer[len]; + *p_strbuf = '\0'; + nrf_cli_fprintf((nrf_cli_t const *)*pp_cli, NRF_CLI_DEFAULT, p_buffer); + // nrf_delay_ms(10); +} + + +static void entry_process(nrf_cli_t const * p_cli, nrf_log_header_t * p_header, uint8_t * p_data) +{ + mp_cli = p_cli; + + nrf_log_str_formatter_entry_params_t params = + { + .timestamp = p_header->timestamp, + .module_id = p_header->module_id, + .use_colors = 0, + }; + + switch (p_header->base.generic.type) + { + case HEADER_TYPE_STD: + { + params.severity = (nrf_log_severity_t)p_header->base.std.severity; + nrf_log_std_entry_process((const char *)((uint32_t)p_header->base.std.addr), + (uint32_t *)p_data, + p_header->base.std.nargs, + ¶ms, + &m_fprintf_ctx); + break; + } + case HEADER_TYPE_HEXDUMP: + { + params.severity = (nrf_log_severity_t)p_header->base.hexdump.severity; + + nrf_log_hexdump_entry_process(p_data, + p_header->base.hexdump.len, + ¶ms, + &m_fprintf_ctx); + break; + } + default: + ASSERT(0); + } + +} + + +static void flashlog_read_cmd(nrf_cli_t const * p_cli, size_t argc, char ** argv) +{ + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + } + + uint32_t token = 0; + uint8_t * p_data = NULL; + bool empty = true; + nrf_log_header_t * p_header; + + while (1) + { + if (nrf_log_backend_flash_next_entry_get(&token, &p_header, &p_data) == NRF_SUCCESS) + { + entry_process(p_cli, p_header, p_data); + empty = false; + } + else + { + break; + } + } + + if (empty) + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Flash log empty\r\n"); + } +} + + +static void flashlog_status_cmd(nrf_cli_t const * p_cli, size_t argc, char ** argv) +{ + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + } + + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Flash log status:\r\n"); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t\t- Location (address: 0x%08X, length: %d)\r\n", + RUNTIME_START_ADDR, FLASH_LOG_SIZE); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t\t- Current usage:%d%% (%d of %d bytes used)\r\n", + 100ul * (m_curr_addr - RUNTIME_START_ADDR)/FLASH_LOG_SIZE, + m_curr_addr - RUNTIME_START_ADDR, + FLASH_LOG_SIZE); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t\t- Dropped logs: %d\r\n", m_dropped); + + +} + + +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_flashlog_cmd) +{ + NRF_CLI_CMD(clear, NULL, "Remove logs", flashlog_clear_cmd), + NRF_CLI_CMD(read, NULL, "Read stored logs", flashlog_read_cmd), + NRF_CLI_CMD(status, NULL, "Flash log status", flashlog_status_cmd), + NRF_CLI_SUBCMD_SET_END +}; + +NRF_CLI_CMD_REGISTER(flashlog, &m_flashlog_cmd, "Commands for reading logs stored in non-volatile memory", NULL); + +#endif //NRF_LOG_BACKEND_FLASH_CLI_CMDS + +#endif //NRF_MODULE_ENABLED(NRF_LOG) && NRF_MODULE_ENABLED(NRF_LOG_BACKEND_FLASH) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_rtt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_rtt.c similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_rtt.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_rtt.c index 03c32ca..05a79b0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_rtt.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_rtt.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_LOG) && NRF_MODULE_ENABLED(NRF_LOG_BACKEND_RTT) @@ -43,9 +43,12 @@ #include "nrf_log_backend_serial.h" #include "nrf_log_str_formatter.h" #include "nrf_log_internal.h" +#include "nrf_delay.h" #include #include +static bool m_host_present; + static uint8_t m_string_buff[NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE]; void nrf_log_backend_rtt_init(void) @@ -59,7 +62,7 @@ static void serial_tx(void const * p_context, char const * buffer, size_t len) { uint32_t idx = 0; uint32_t processed; - uint32_t watchdog_counter = 10; + uint32_t watchdog_counter = NRF_LOG_BACKEND_RTT_TX_RETRY_CNT; do { processed = SEGGER_RTT_WriteNoLock(0, &buffer[idx], len); @@ -67,13 +70,32 @@ static void serial_tx(void const * p_context, char const * buffer, size_t len) len -= processed; if (processed == 0) { - // If RTT is not connected then ensure that logger does not block - watchdog_counter--; - if (watchdog_counter == 0) + /* There are two possible reasons for not writing any data to RTT: + * - The host is not connected and not reading the data. + * - The buffer got full and will be read by the host. + * These two situations are distinguished using the following algorithm. + * At the begining, the module assumes that the host is active, + * so when no data is read, it busy waits and retries. + * If, after retrying, the host reads the data, the module assumes that the host is active. + * If it fails, the module assumes that the host is inactive and stores that information. On next + * call, only one attempt takes place. The host is marked as active if the attempt is successful. + */ + if (!m_host_present) { break; } + else + { + nrf_delay_ms(NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS); + watchdog_counter--; + if (watchdog_counter == 0) + { + m_host_present = false; + break; + } + } } + m_host_present = true; } while (len); } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_serial.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_serial.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_serial.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_serial.c index 194b9a7..245b80f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_serial.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_serial.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_LOG) @@ -63,12 +63,14 @@ void nrf_log_backend_serial_put(nrf_log_backend_t const * p_backend, nrf_log_str_formatter_entry_params_t params; nrf_log_header_t header; - uint32_t memobj_offset = 0; + size_t memobj_offset = 0; + nrf_memobj_read(p_msg, &header, HEADER_SIZE*sizeof(uint32_t), memobj_offset); memobj_offset = HEADER_SIZE*sizeof(uint32_t); params.timestamp = header.timestamp; params.module_id = header.module_id; + params.dropped = header.dropped; params.use_colors = NRF_LOG_USES_COLORS; /*lint -save -e438*/ @@ -76,7 +78,6 @@ void nrf_log_backend_serial_put(nrf_log_backend_t const * p_backend, { char const * p_log_str = (char const *)((uint32_t)header.base.std.addr); params.severity = (nrf_log_severity_t)header.base.std.severity; - params.raw = header.base.std.raw; uint32_t nargs = header.base.std.nargs; uint32_t args[NRF_LOG_MAX_NUM_OF_ARGS]; @@ -94,7 +95,6 @@ void nrf_log_backend_serial_put(nrf_log_backend_t const * p_backend, { uint32_t data_len = header.base.hexdump.len; params.severity = (nrf_log_severity_t)header.base.hexdump.severity; - params.raw = header.base.hexdump.raw; uint8_t data_buf[8]; uint32_t chunk_len; do diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_serial.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_serial.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_serial.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_serial.h index 583bc72..16e86ae 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_serial.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_serial.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_LOG_BACKEND_SERIAL_H #define NRF_LOG_BACKEND_SERIAL_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_uart.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_uart.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_uart.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_uart.c index f81018c..8b09a8a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_backend_uart.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_backend_uart.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_LOG) && NRF_MODULE_ENABLED(NRF_LOG_BACKEND_UART) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_ctrl_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_ctrl_internal.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_ctrl_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_ctrl_internal.h index fbe36cb..04c852c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_ctrl_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_ctrl_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_LOG_CTRL_INTERNAL_H #define NRF_LOG_CTRL_INTERNAL_H @@ -49,8 +49,19 @@ #include "sdk_common.h" #if NRF_MODULE_ENABLED(NRF_LOG) -#define NRF_LOG_INTERNAL_INIT(timestamp_func) \ - nrf_log_init(timestamp_func) +#define NRF_LOG_LFCLK_FREQ 32768 + +#ifdef APP_TIMER_CONFIG_RTC_FREQUENCY +#define LOG_TIMESTAMP_DEFAULT_FREQUENCY ((NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY == 0) ? \ + (NRF_LOG_LFCLK_FREQ/(APP_TIMER_CONFIG_RTC_FREQUENCY + 1)) : \ + NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY) +#else +#define LOG_TIMESTAMP_DEFAULT_FREQUENCY NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#endif + +#define NRF_LOG_INTERNAL_INIT(...) \ + nrf_log_init(GET_VA_ARG_1(__VA_ARGS__), \ + GET_VA_ARG_1(GET_ARGS_AFTER_1(__VA_ARGS__, LOG_TIMESTAMP_DEFAULT_FREQUENCY))) #define NRF_LOG_INTERNAL_PROCESS() nrf_log_frontend_dequeue() #define NRF_LOG_INTERNAL_FLUSH() \ @@ -68,7 +79,7 @@ #else // NRF_MODULE_ENABLED(NRF_LOG) #define NRF_LOG_INTERNAL_PROCESS() false #define NRF_LOG_INTERNAL_FLUSH() -#define NRF_LOG_INTERNAL_INIT(timestamp_func) NRF_SUCCESS +#define NRF_LOG_INTERNAL_INIT(...) NRF_SUCCESS #define NRF_LOG_INTERNAL_HANDLERS_SET(default_handler, bytes_handler) \ UNUSED_PARAMETER(default_handler); UNUSED_PARAMETER(bytes_handler) #define NRF_LOG_INTERNAL_FINAL_FLUSH() diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_default_backends.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_default_backends.c similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_default_backends.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_default_backends.c index 039bf64..d7259ad 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_default_backends.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_default_backends.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -61,16 +61,16 @@ void nrf_log_default_backends_init(void) (void)backend_id; #if defined(NRF_LOG_BACKEND_RTT_ENABLED) && NRF_LOG_BACKEND_RTT_ENABLED nrf_log_backend_rtt_init(); - backend_id = nrf_log_backend_add(&rtt_log_backend.backend, NRF_LOG_SEVERITY_DEBUG); + backend_id = nrf_log_backend_add(&rtt_log_backend, NRF_LOG_SEVERITY_DEBUG); ASSERT(backend_id >= 0); - nrf_log_backend_enable(&rtt_log_backend.backend); + nrf_log_backend_enable(&rtt_log_backend); #endif #if defined(NRF_LOG_BACKEND_UART_ENABLED) && NRF_LOG_BACKEND_UART_ENABLED nrf_log_backend_uart_init(); - backend_id = nrf_log_backend_add(&uart_log_backend.backend, NRF_LOG_SEVERITY_DEBUG); + backend_id = nrf_log_backend_add(&uart_log_backend, NRF_LOG_SEVERITY_DEBUG); ASSERT(backend_id >= 0); - nrf_log_backend_enable(&uart_log_backend.backend); + nrf_log_backend_enable(&uart_log_backend); #endif } #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_frontend.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_frontend.c similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_frontend.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_frontend.c index 459dc3e..7ec714c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_frontend.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_frontend.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_LOG) @@ -44,7 +44,10 @@ #include "nrf_log.h" #include "nrf_log_internal.h" #include "nrf_log_ctrl.h" +#include "nrf_log_backend_interface.h" +#include "nrf_log_str_formatter.h" #include "nrf_section.h" +#include "nrf_ringbuf.h" #include "nrf_memobj.h" #include "nrf_atomic.h" #include @@ -54,17 +57,24 @@ STATIC_ASSERT(IS_POWER_OF_TWO(NRF_LOG_BUFSIZE)); #define NRF_LOG_BUF_WORDS (NRF_LOG_BUFSIZE/4) +#if NRF_MODULE_ENABLED(FDS) && NRF_LOG_FILTERS_ENABLED +#define LOG_CONFIG_LOAD_STORE_ENABLED 1 +#else +#define LOG_CONFIG_LOAD_STORE_ENABLED 0 +#endif + #if NRF_LOG_BUF_WORDS < 32 #warning "NRF_LOG_BUFSIZE too small, significant number of logs may be lost." #endif -NRF_MEMOBJ_POOL_DEF(mempool, NRF_LOG_MSGPOOL_ELEMENT_SIZE, NRF_LOG_MSGPOOL_ELEMENT_COUNT); +NRF_MEMOBJ_POOL_DEF(log_mempool, NRF_LOG_MSGPOOL_ELEMENT_SIZE, NRF_LOG_MSGPOOL_ELEMENT_COUNT); +NRF_RINGBUF_DEF(m_log_push_ringbuf, NRF_LOG_STR_PUSH_BUFFER_SIZE); #define NRF_LOG_BACKENDS_FULL 0xFF #define NRF_LOG_FILTER_BITS_PER_BACKEND 3 #define NRF_LOG_MAX_BACKENDS (32/NRF_LOG_FILTER_BITS_PER_BACKEND) #define NRF_LOG_MAX_HEXDUMP (NRF_LOG_MSGPOOL_ELEMENT_SIZE*NRF_LOG_MSGPOOL_ELEMENT_COUNT/2) - +#define NRF_LOG_INVALID_BACKEND_U32 0xFFFFFFFF /** * brief An internal control block of the logger * @@ -80,33 +90,29 @@ typedef struct uint32_t mask; // Size of buffer (must be power of 2) presented as mask uint32_t buffer[NRF_LOG_BUF_WORDS]; nrf_log_timestamp_func_t timestamp_func; // A pointer to function that returns timestamp - nrf_log_backend_t * p_backend_head; + nrf_log_backend_t const * p_backend_head; nrf_atomic_flag_t log_skipping; nrf_atomic_flag_t log_skipped; + nrf_atomic_u32_t log_dropped_cnt; bool autoflush; } log_data_t; static log_data_t m_log_data; -static const char * m_overflow_info = "Overflow"; -/*lint -save -esym(526,log_const_data*) -esym(526,log_dynamic_data*)*/ -NRF_SECTION_DEF(log_dynamic_data, nrf_log_module_dynamic_data_t); -NRF_SECTION_DEF(log_const_data, nrf_log_module_const_data_t); -/*lint -restore*/ + + NRF_LOG_MODULE_REGISTER(); + // Helper macros for section variables. -#define NRF_LOG_DYNAMIC_SECTION_VARS_GET(i) NRF_SECTION_ITEM_GET(log_dynamic_data, nrf_log_module_dynamic_data_t, (i)) +#define NRF_LOG_DYNAMIC_SECTION_VARS_GET(i) NRF_SECTION_ITEM_GET(log_dynamic_data, nrf_log_module_dynamic_data_t, (i)) +#define NRF_LOG_FILTER_SECTION_VARS_GET(i) NRF_SECTION_ITEM_GET(log_filter_data, nrf_log_module_filter_data_t, (i)) #define NRF_LOG_CONST_SECTION_VARS_GET(i) NRF_SECTION_ITEM_GET(log_const_data, nrf_log_module_const_data_t, (i)) #define NRF_LOG_CONST_SECTION_VARS_COUNT NRF_SECTION_ITEM_COUNT(log_const_data, nrf_log_module_const_data_t) -#define PUSHED_HEADER_FILL(P_HDR, OFFSET, LENGTH) \ - (P_HDR)->base.pushed.type = HEADER_TYPE_PUSHED; \ - (P_HDR)->base.pushed.offset = OFFSET; \ - (P_HDR)->base.pushed.len = LENGTH - - -ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func) +ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func, uint32_t timestamp_freq) { + (void)NRF_LOG_ITEM_DATA_CONST(app); + if (NRF_LOG_USES_TIMESTAMP && (timestamp_func == NULL)) { return NRF_ERROR_INVALID_PARAM; @@ -120,15 +126,18 @@ ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func) m_log_data.autoflush = NRF_LOG_DEFERRED ? false : true; if (NRF_LOG_USES_TIMESTAMP) { + nrf_log_str_formatter_timestamp_freq_set(timestamp_freq); m_log_data.timestamp_func = timestamp_func; } - ret_code_t err_code = nrf_memobj_pool_init(&mempool); + ret_code_t err_code = nrf_memobj_pool_init(&log_mempool); if (err_code != NRF_SUCCESS) { return err_code; } + nrf_ringbuf_init(&m_log_push_ringbuf); + uint32_t modules_cnt = NRF_LOG_CONST_SECTION_VARS_COUNT; uint32_t i; if (NRF_LOG_FILTERS_ENABLED) @@ -153,17 +162,16 @@ ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func) } nrf_log_module_dynamic_data_t * p_module_ddata = NRF_LOG_DYNAMIC_SECTION_VARS_GET(i); - p_module_ddata->filter = 0; - p_module_ddata->module_id = i; p_module_ddata->order_idx = idx; } - } - else - { - for(i = 0; i < modules_cnt; i++) + + /* Initialize filters */ + for (i = 0; i < modules_cnt; i++) { nrf_log_module_dynamic_data_t * p_module_ddata = NRF_LOG_DYNAMIC_SECTION_VARS_GET(i); - p_module_ddata->module_id = i; + nrf_log_module_filter_data_t * p_module_filter = NRF_LOG_FILTER_SECTION_VARS_GET(i); + p_module_ddata->filter = 0; + p_module_filter->filter_lvls = 0; } } @@ -235,16 +243,16 @@ uint8_t nrf_log_color_id_get(uint32_t module_id, nrf_log_severity_t severity) return color_id; } -static uint32_t higher_lvl_get(uint32_t lvls) +static uint16_t higher_lvl_get(uint32_t lvls) { - uint32_t top_lvl = 0; - uint32_t tmp_lvl; + uint16_t top_lvl = 0; + uint16_t tmp_lvl; uint32_t i; //Find highest level enabled by backends for (i = 0; i < (32/NRF_LOG_LEVEL_BITS); i+=NRF_LOG_LEVEL_BITS) { - tmp_lvl = BF_GET(lvls,NRF_LOG_LEVEL_BITS, i); + tmp_lvl = (uint16_t)BF_GET(lvls,NRF_LOG_LEVEL_BITS, i); if (tmp_lvl > top_lvl) { top_lvl = tmp_lvl; @@ -257,13 +265,23 @@ void nrf_log_module_filter_set(uint32_t backend_id, uint32_t module_id, nrf_log_ { if (NRF_LOG_FILTERS_ENABLED) { - nrf_log_module_dynamic_data_t * p_module_filter = NRF_LOG_DYNAMIC_SECTION_VARS_GET(module_id); - p_module_filter->filter_lvls &= ~(NRF_LOG_LEVEL_MASK << (NRF_LOG_LEVEL_BITS * backend_id)); - p_module_filter->filter_lvls |= (severity & NRF_LOG_LEVEL_MASK) << (NRF_LOG_LEVEL_BITS * backend_id); - p_module_filter->filter = higher_lvl_get(p_module_filter->filter_lvls); + nrf_log_module_dynamic_data_t * p_module_data = NRF_LOG_DYNAMIC_SECTION_VARS_GET(module_id); + nrf_log_module_filter_data_t * p_filter = NRF_LOG_FILTER_SECTION_VARS_GET(module_id); + + p_filter->filter_lvls &= ~BF_MASK(NRF_LOG_LEVEL_BITS, (NRF_LOG_LEVEL_BITS * backend_id)); + p_filter->filter_lvls |= BF_VAL(severity, NRF_LOG_LEVEL_BITS, (NRF_LOG_LEVEL_BITS * backend_id)); + + p_module_data->filter = higher_lvl_get(p_filter->filter_lvls); } } +static nrf_log_severity_t nrf_log_module_init_filter_get(uint32_t module_id) +{ + nrf_log_module_const_data_t * p_module_data = + NRF_LOG_CONST_SECTION_VARS_GET(module_id); + return NRF_LOG_FILTERS_ENABLED ? p_module_data->initial_lvl : p_module_data->compiled_lvl; +} + nrf_log_severity_t nrf_log_module_filter_get(uint32_t backend_id, uint32_t module_id, bool ordered_idx, @@ -274,10 +292,10 @@ nrf_log_severity_t nrf_log_module_filter_get(uint32_t backend_id, { if (module_idx_get(&module_id, ordered_idx) == NRF_SUCCESS) { - nrf_log_module_dynamic_data_t * p_module_filter = - NRF_LOG_DYNAMIC_SECTION_VARS_GET(module_id); - severity = (nrf_log_severity_t)((p_module_filter->filter_lvls >> (NRF_LOG_LEVEL_BITS * backend_id)) & - NRF_LOG_LEVEL_MASK); + nrf_log_module_filter_data_t * p_filter = NRF_LOG_FILTER_SECTION_VARS_GET(module_id); + severity = (nrf_log_severity_t)BF_GET(p_filter->filter_lvls, + NRF_LOG_LEVEL_BITS, + (backend_id*NRF_LOG_LEVEL_BITS)); } } else if (!dynamic) @@ -291,14 +309,38 @@ nrf_log_severity_t nrf_log_module_filter_get(uint32_t backend_id, } return severity; } - /** - * @brief Skips the oldest, not pushed logs to make space for new logs. + * Function examines current header and omits packets which are in progress. + */ +static bool invalid_packets_omit(nrf_log_header_t const * p_header, uint32_t * p_rd_idx) +{ + bool ret = false; + if (p_header->base.generic.in_progress == 1) + { + switch (p_header->base.generic.type) + { + case HEADER_TYPE_STD: + *p_rd_idx += (HEADER_SIZE + p_header->base.std.nargs); + break; + case HEADER_TYPE_HEXDUMP: + *p_rd_idx += (HEADER_SIZE + p_header->base.hexdump.len); + break; + default: + break; + } + ret = true; + } + return ret; +} +/** + * @brief Skips the oldest, not processed logs to make space for new logs. * @details This function moves forward read index to prepare space for new logs. */ -static void log_skip(void) +static uint32_t log_skip(void) { + uint16_t dropped = 0; + (void)nrf_atomic_flag_set(&m_log_data.log_skipped); (void)nrf_atomic_flag_set(&m_log_data.log_skipping); @@ -307,13 +349,18 @@ static void log_skip(void) nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask]; nrf_log_header_t header; - // Skip any string that is pushed to the circular buffer. - while (p_header->base.generic.type == HEADER_TYPE_PUSHED) - { - rd_idx += PUSHED_HEADER_SIZE; - rd_idx += (p_header->base.pushed.len + p_header->base.pushed.offset); - p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask]; - } + // Skip packets that may be invalid (interrupted while being in progress) + do { + if (invalid_packets_omit(p_header, &rd_idx)) + { + //something was omitted. Point to new header and try again. + p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask]; + } + else + { + break; + } + } while (true); uint32_t i; for (i = 0; i < HEADER_SIZE; i++) @@ -324,9 +371,11 @@ static void log_skip(void) switch (header.base.generic.type) { case HEADER_TYPE_HEXDUMP: + dropped = header.dropped; rd_idx += CEIL_DIV(header.base.hexdump.len, sizeof(uint32_t)); break; case HEADER_TYPE_STD: + dropped = header.dropped; rd_idx += header.base.std.nargs; break; default: @@ -340,6 +389,19 @@ static void log_skip(void) { m_log_data.rd_idx = rd_idx; } + + return (uint32_t)dropped; +} + +/** + * @brief Function for getting number of dropped logs. Dropped counter is reset after reading. + * + * @return Number of dropped logs saturated to 16 bits. + */ +static inline uint32_t dropped_sat16_get(void) +{ + uint32_t dropped = nrf_atomic_u32_fetch_store(&m_log_data.log_dropped_cnt, 0); + return __USAT(dropped, 16); //Saturate to 16 bits } @@ -352,21 +414,22 @@ static inline void std_header_set(uint32_t severity_mid, //Prepare header - in reverse order to ensure that packet type is validated (set to STD as last action) - uint16_t module_id = severity_mid >> NRF_LOG_MODULE_ID_POS; + uint32_t module_id = severity_mid >> NRF_LOG_MODULE_ID_POS; + uint32_t dropped = dropped_sat16_get(); ASSERT(module_id < nrf_log_module_cnt_get()); - m_log_data.buffer[(wr_idx + 1) & mask] = module_id; + m_log_data.buffer[(wr_idx + 1) & mask] = module_id | (dropped << 16); if (NRF_LOG_USES_TIMESTAMP) { m_log_data.buffer[(wr_idx + 2) & mask] = m_log_data.timestamp_func(); } - nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[wr_idx & mask]; - p_header->base.std.raw = (severity_mid & NRF_LOG_RAW) ? 1 : 0; - p_header->base.std.severity = severity_mid & NRF_LOG_LEVEL_MASK; - p_header->base.std.nargs = nargs; - p_header->base.std.addr = ((uint32_t)(p_str) & STD_ADDR_MASK); - p_header->base.std.type = HEADER_TYPE_STD; + nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[wr_idx & mask]; + p_header->base.std.severity = severity_mid & NRF_LOG_LEVEL_MASK; + p_header->base.std.nargs = nargs; + p_header->base.std.addr = ((uint32_t)(p_str) & STD_ADDR_MASK); + p_header->base.std.type = HEADER_TYPE_STD; + p_header->base.std.in_progress = 0; } /** @@ -380,131 +443,105 @@ static inline void std_header_set(uint32_t severity_mid, * @return True if successful allocation, false otherwise. * */ -static inline bool buf_prealloc(uint32_t content_len, uint32_t * p_wr_idx) +static inline bool buf_prealloc(uint32_t content_len, uint32_t * p_wr_idx, bool std) { uint32_t req_len = content_len + HEADER_SIZE; - uint32_t ovflw_tag_size = HEADER_SIZE; bool ret = true; CRITICAL_REGION_ENTER(); *p_wr_idx = m_log_data.wr_idx; uint32_t available_words = (m_log_data.mask + 1) - (m_log_data.wr_idx - m_log_data.rd_idx); - uint32_t required_words = req_len + ovflw_tag_size; // room for current entry and overflow - while (required_words > available_words) + while (req_len > available_words) { + UNUSED_RETURN_VALUE(nrf_atomic_u32_add(&m_log_data.log_dropped_cnt, 1)); if (NRF_LOG_ALLOW_OVERFLOW) { - log_skip(); + uint32_t dropped_in_skip = log_skip(); + UNUSED_RETURN_VALUE(nrf_atomic_u32_add(&m_log_data.log_dropped_cnt, dropped_in_skip)); available_words = (m_log_data.mask + 1) - (m_log_data.wr_idx - m_log_data.rd_idx); } else { - if (available_words >= HEADER_SIZE) - { - // Overflow entry is injected - std_header_set(NRF_LOG_LEVEL_WARNING, m_overflow_info, 0, m_log_data.wr_idx, m_log_data.mask); - req_len = HEADER_SIZE; - } - else - { - // No more room for any logs. - req_len = 0; - } ret = false; break; } - } - /* Mark header as invalid.*/ - nrf_log_generic_header_t * p_header = (nrf_log_generic_header_t *)&m_log_data.buffer[m_log_data.wr_idx & m_log_data.mask]; - p_header->type = HEADER_TYPE_INVALID; - m_log_data.wr_idx += req_len; + if (ret) + { + nrf_log_main_header_t invalid_header; + invalid_header.raw = 0; - CRITICAL_REGION_EXIT(); - return ret; -} + if (std) + { + invalid_header.std.type = HEADER_TYPE_STD; + invalid_header.std.in_progress = 1; + invalid_header.std.nargs = content_len; + } + else + { + invalid_header.hexdump.type = HEADER_TYPE_HEXDUMP; + invalid_header.hexdump.in_progress = 1; + invalid_header.hexdump.len = content_len; + } + nrf_log_main_header_t * p_header = + (nrf_log_main_header_t *)&m_log_data.buffer[m_log_data.wr_idx & m_log_data.mask]; -/** - * @brief Function for preallocating a continuous chunk of memory from circular buffer. - * - * If buffer does not fit starting from current position it will be allocated at - * the beginning of the circular buffer and offset will be returned indicating - * how much memory has been ommited at the end of the buffer. Function is - * using critical section. - * - * @param len32 Length of buffer to allocate. Given in words. - * @param p_offset Offset of the buffer. - * @param p_wr_idx Pointer to write index. - * - * @return A pointer to the allocated buffer. NULL if allocation failed. - */ -static inline uint32_t * cont_buf_prealloc(uint32_t len32, - uint32_t * p_offset, - uint32_t * p_wr_idx) -{ - uint32_t * p_buf = NULL; + p_header->raw = invalid_header.raw; - len32 += PUSHED_HEADER_SIZE; // Increment because 32bit header is needed to be stored. - - CRITICAL_REGION_ENTER(); - *p_wr_idx = m_log_data.wr_idx; - uint32_t available_words = (m_log_data.mask + 1) - - (m_log_data.wr_idx - m_log_data.rd_idx); - if (len32 <= available_words) - { - // buffer will fit as is - p_buf = &m_log_data.buffer[(m_log_data.wr_idx + 1) & m_log_data.mask]; - m_log_data.wr_idx += len32; - *p_offset = 0; - } - else if (len32 < (m_log_data.rd_idx & m_log_data.mask)) - { - // wraping to the begining of the buffer - m_log_data.wr_idx += (len32 + available_words - 1); - *p_offset = available_words - 1; - p_buf = m_log_data.buffer; - } - available_words = (m_log_data.mask + 1) - (m_log_data.wr_idx - m_log_data.rd_idx); - // If there is no more room for even overflow tag indicate failed allocation. - if (available_words < HEADER_SIZE) - { - p_buf = NULL; + m_log_data.wr_idx += req_len; } - CRITICAL_REGION_EXIT(); - return p_buf; + CRITICAL_REGION_EXIT(); + return ret; } - -uint32_t nrf_log_push(char * const p_str) +char const * nrf_log_push(char * const p_str) { if ((m_log_data.autoflush) || (p_str == NULL)) { - return (uint32_t)p_str; + return p_str; } - uint32_t mask = m_log_data.mask; - uint32_t slen = strlen(p_str) + 1; - uint32_t buflen = CEIL_DIV(slen, sizeof(uint32_t)); - uint32_t offset = 0; - uint32_t wr_idx; - char * p_dst_str = (char *)cont_buf_prealloc(buflen, &offset, &wr_idx); - if (p_dst_str) + size_t ssize = strlen(p_str) + 1; // + 1 for null termination + uint8_t * p_dst; + // Allocate space in the ring buffer. It may be smaller than the requested string in case of buffer wrapping or when the ring buffer size is too small. + // Once the string is copied into the buffer, the space is immediately freed. The string is kept in the buffer but can be overwritten. + // It is done that way because there is no other place where space could be freed since string processing happens in + // the logger backends, often by modules which are generic and not aware of internals of the logger. + if (nrf_ringbuf_alloc(&m_log_push_ringbuf, &p_dst, &ssize, true) == NRF_SUCCESS) { - nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[wr_idx & mask]; - PUSHED_HEADER_FILL(p_header, offset, buflen); - memcpy(p_dst_str, p_str, slen); + ret_code_t err; + + memcpy(p_dst, p_str, ssize); + + //Terminate in case string was partial. + p_dst[ssize - 1] = '\0'; + + err = nrf_ringbuf_put(&m_log_push_ringbuf, ssize); + ASSERT(err == NRF_SUCCESS); + + //Immediately free the space where string was put. + err = nrf_ringbuf_free(&m_log_push_ringbuf, ssize); + ASSERT(err == NRF_SUCCESS); + + return (char const *)p_dst; + } + else + { + return NULL; } - return (uint32_t)p_dst_str; } -static inline void std_n(uint32_t severity_mid, char const * const p_str, uint32_t const * args, uint32_t nargs) +static inline void std_n(uint32_t severity_mid, + char const * const p_str, + uint32_t const * args, + uint32_t nargs) { uint32_t mask = m_log_data.mask; uint32_t wr_idx; - if (buf_prealloc(nargs, &wr_idx)) + if (buf_prealloc(nargs, &wr_idx, true)) { // Proceed only if buffer was successfully preallocated. @@ -518,7 +555,15 @@ static inline void std_n(uint32_t severity_mid, char const * const p_str, uint32 } if (m_log_data.autoflush) { +#if NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED + CRITICAL_REGION_ENTER(); +#endif // NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED + NRF_LOG_FLUSH(); + +#if NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED + CRITICAL_REGION_EXIT(); +#endif // NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED } } @@ -605,7 +650,7 @@ void nrf_log_frontend_hexdump(uint32_t severity_mid, uint32_t mask = m_log_data.mask; uint32_t wr_idx; - if (buf_prealloc(CEIL_DIV(length, sizeof(uint32_t)), &wr_idx)) + if (buf_prealloc(CEIL_DIV(length, sizeof(uint32_t)), &wr_idx, false)) { uint32_t header_wr_idx = wr_idx; wr_idx += HEADER_SIZE; @@ -618,8 +663,7 @@ void nrf_log_frontend_hexdump(uint32_t severity_mid, else { memcpy(&m_log_data.buffer[wr_idx & mask], p_data, space0); - length -= space0; - memcpy(&m_log_data.buffer[0], &((uint8_t *)p_data)[space0], length); + memcpy(&m_log_data.buffer[0], &((uint8_t *)p_data)[space0], length - space0); } //Prepare header - in reverse order to ensure that packet type is validated (set to HEXDUMP as last action) @@ -628,14 +672,16 @@ void nrf_log_frontend_hexdump(uint32_t severity_mid, m_log_data.buffer[(header_wr_idx + 2) & mask] = m_log_data.timestamp_func(); } - m_log_data.buffer[(header_wr_idx + 1) & mask] = severity_mid >> NRF_LOG_MODULE_ID_POS; + uint32_t module_id = severity_mid >> NRF_LOG_MODULE_ID_POS; + uint32_t dropped = dropped_sat16_get(); + m_log_data.buffer[(header_wr_idx + 1) & mask] = module_id | (dropped << 16); //Header prepare nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[header_wr_idx & mask]; - p_header->base.hexdump.raw = (severity_mid & NRF_LOG_RAW) ? 1 : 0; - p_header->base.hexdump.severity = severity_mid & NRF_LOG_LEVEL_MASK; - p_header->base.hexdump.offset = 0; - p_header->base.hexdump.len = length; - p_header->base.hexdump.type = HEADER_TYPE_HEXDUMP; + p_header->base.hexdump.severity = severity_mid & NRF_LOG_LEVEL_MASK; + p_header->base.hexdump.offset = 0; + p_header->base.hexdump.len = length; + p_header->base.hexdump.type = HEADER_TYPE_HEXDUMP; + p_header->base.hexdump.in_progress = 0; @@ -643,7 +689,15 @@ void nrf_log_frontend_hexdump(uint32_t severity_mid, if (m_log_data.autoflush) { +#if NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED + CRITICAL_REGION_ENTER(); +#endif // NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED + NRF_LOG_FLUSH(); + +#if NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED + CRITICAL_REGION_EXIT(); +#endif // NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED } } @@ -653,9 +707,9 @@ bool buffer_is_empty(void) return (m_log_data.rd_idx == m_log_data.wr_idx); } - bool nrf_log_frontend_dequeue(void) { + if (buffer_is_empty()) { return false; @@ -668,16 +722,27 @@ bool nrf_log_frontend_dequeue(void) nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask]; nrf_log_header_t header; nrf_memobj_t * p_msg_buf = NULL; - uint32_t memobj_offset = 0; + size_t memobj_offset = 0; uint32_t severity = 0; - // Skip any string that is pushed to the circular buffer. - while (p_header->base.generic.type == HEADER_TYPE_PUSHED) - { - rd_idx += PUSHED_HEADER_SIZE; - rd_idx += (p_header->base.pushed.len + p_header->base.pushed.offset); - p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask]; - } + // Skip any in progress packets. + do { + if (invalid_packets_omit(p_header, &rd_idx) && (m_log_data.log_skipped == 0)) + { + //Check if end of data is not reached. + if (rd_idx >= m_log_data.wr_idx) + { + m_log_data.rd_idx = m_log_data.wr_idx; + return false; + } + //something was omitted. Point to new header and try again. + p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask]; + } + else + { + break; + } + } while (true); uint32_t i; for (i = 0; i < HEADER_SIZE; i++) @@ -692,7 +757,7 @@ bool nrf_log_frontend_dequeue(void) header.base.hexdump.len = data_len; uint32_t msg_buf_size8 = sizeof(uint32_t)*HEADER_SIZE + data_len; severity = header.base.hexdump.severity; - p_msg_buf = nrf_memobj_alloc(&mempool, msg_buf_size8); + p_msg_buf = nrf_memobj_alloc(&log_mempool, msg_buf_size8); if (p_msg_buf) { @@ -732,7 +797,7 @@ bool nrf_log_frontend_dequeue(void) uint32_t msg_buf_size32 = HEADER_SIZE + header.base.std.nargs; severity = header.base.std.severity; - p_msg_buf = nrf_memobj_alloc(&mempool, msg_buf_size32*sizeof(uint32_t)); + p_msg_buf = nrf_memobj_alloc(&log_mempool, msg_buf_size32*sizeof(uint32_t)); if (p_msg_buf) { @@ -748,13 +813,6 @@ bool nrf_log_frontend_dequeue(void) } } } - else if (header.base.generic.type == HEADER_TYPE_INVALID && (m_log_data.log_skipped == 0)) - { - //invalid type can only occur if log entry was interrupted by log_process. It is likly final flush - // and finding invalid type means that last entry in the buffer was reached (the one that was interrupted). - // Stop processing immediately. - return false; - } else { //Do nothing. In case of log overflow buffer can contain corrupted data. @@ -762,7 +820,7 @@ bool nrf_log_frontend_dequeue(void) if (p_msg_buf) { - nrf_log_backend_t * p_backend = m_log_data.p_backend_head; + nrf_log_backend_t const * p_backend = m_log_data.p_backend_head; if (NRF_LOG_ALLOW_OVERFLOW && m_log_data.log_skipped) { // Check if any log was skipped during log processing. Do not forward log if skipping @@ -779,9 +837,15 @@ bool nrf_log_frontend_dequeue(void) if (NRF_LOG_FILTERS_ENABLED) { uint8_t backend_id = nrf_log_backend_id_get(p_backend); - uint32_t filter_lvls = NRF_LOG_DYNAMIC_SECTION_VARS_GET(header.module_id)->filter_lvls; - uint32_t backend_lvl = (filter_lvls >> (backend_id*NRF_LOG_LEVEL_BITS)) - & NRF_LOG_LEVEL_MASK; + nrf_log_module_filter_data_t * p_module_filter = + NRF_LOG_FILTER_SECTION_VARS_GET(header.module_id); + uint32_t backend_lvl = BF_GET(p_module_filter->filter_lvls, + NRF_LOG_LEVEL_BITS, + (backend_id*NRF_LOG_LEVEL_BITS)); + + //Degrade INFO_RAW level to INFO. + severity = (severity == NRF_LOG_SEVERITY_INFO_RAW) ? + NRF_LOG_SEVERITY_INFO : severity; if (backend_lvl >= severity) { entry_accepted = true; @@ -795,9 +859,9 @@ bool nrf_log_frontend_dequeue(void) } if (entry_accepted) { - nrf_log_backend_put(p_backend, p_msg_buf); + nrf_log_backend_put(p_backend, p_msg_buf); } - p_backend = p_backend->p_next; + p_backend = p_backend->p_cb->p_next; } nrf_memobj_put(p_msg_buf); @@ -821,6 +885,18 @@ bool nrf_log_frontend_dequeue(void) } } } + else + { + //Could not allocate memobj - backends are not freeing them on time. + nrf_log_backend_t const * p_backend = m_log_data.p_backend_head; + //Flush all backends + while (p_backend) + { + nrf_log_backend_flush(p_backend); + p_backend = p_backend->p_cb->p_next; + } + NRF_LOG_WARNING("Backends flushed"); + } return buffer_is_empty() ? false : true; } @@ -828,7 +904,7 @@ bool nrf_log_frontend_dequeue(void) static int32_t backend_id_assign(void) { int32_t candidate_id; - nrf_log_backend_t * p_backend; + nrf_log_backend_t const * p_backend; bool id_available; for (candidate_id = 0; candidate_id < NRF_LOG_MAX_BACKENDS; candidate_id++) { @@ -841,7 +917,7 @@ static int32_t backend_id_assign(void) id_available = false; break; } - p_backend = p_backend->p_next; + p_backend = p_backend->p_cb->p_next; } if (id_available) { @@ -851,7 +927,7 @@ static int32_t backend_id_assign(void) return -1; } -int32_t nrf_log_backend_add(nrf_log_backend_t * p_backend, nrf_log_severity_t severity) +int32_t nrf_log_backend_add(nrf_log_backend_t const * p_backend, nrf_log_severity_t severity) { int32_t id = backend_id_assign(); if (id == -1) @@ -864,12 +940,12 @@ int32_t nrf_log_backend_add(nrf_log_backend_t * p_backend, nrf_log_severity_t se if (m_log_data.p_backend_head == NULL) { m_log_data.p_backend_head = p_backend; - p_backend->p_next = NULL; + p_backend->p_cb->p_next = NULL; } else { - p_backend->p_next = m_log_data.p_backend_head->p_next; - m_log_data.p_backend_head->p_next = p_backend; + p_backend->p_cb->p_next = m_log_data.p_backend_head->p_cb->p_next; + m_log_data.p_backend_head->p_cb->p_next = p_backend; } if (NRF_LOG_FILTERS_ENABLED) @@ -877,7 +953,7 @@ int32_t nrf_log_backend_add(nrf_log_backend_t * p_backend, nrf_log_severity_t se uint32_t i; for (i = 0; i < nrf_log_module_cnt_get(); i++) { - nrf_log_severity_t buildin_lvl = nrf_log_module_filter_get(id, i, false, false); + nrf_log_severity_t buildin_lvl = nrf_log_module_init_filter_get(i); nrf_log_severity_t actual_severity = MIN(buildin_lvl, severity); nrf_log_module_filter_set(nrf_log_backend_id_get(p_backend), i, actual_severity); } @@ -886,41 +962,115 @@ int32_t nrf_log_backend_add(nrf_log_backend_t * p_backend, nrf_log_severity_t se return id; } -void nrf_log_backend_remove(nrf_log_backend_t * p_backend) +void nrf_log_backend_remove(nrf_log_backend_t const * p_backend) { - nrf_log_backend_t * p_curr = m_log_data.p_backend_head; - nrf_log_backend_t * p_prev = NULL; + nrf_log_backend_t const * p_curr = m_log_data.p_backend_head; + nrf_log_backend_t const * p_prev = NULL; while (p_curr != p_backend) { p_prev = p_curr; - p_curr = p_curr->p_next; + p_curr = p_curr->p_cb->p_next; } if (p_prev) { - p_prev->p_next = p_backend->p_next; + p_prev->p_cb->p_next = p_backend->p_cb->p_next; } else { m_log_data.p_backend_head = NULL; } + + p_backend->p_cb->id = NRF_LOG_BACKEND_INVALID_ID; } void nrf_log_panic(void) { - nrf_log_backend_t * p_backend = m_log_data.p_backend_head; + nrf_log_backend_t const * p_backend = m_log_data.p_backend_head; m_log_data.autoflush = true; while (p_backend) { nrf_log_backend_enable(p_backend); nrf_log_backend_panic_set(p_backend); - p_backend = p_backend->p_next; + p_backend = p_backend->p_cb->p_next; } } -#if NRF_LOG_CLI_CMDS +#if NRF_MODULE_ENABLED(LOG_CONFIG_LOAD_STORE) +#include "fds.h" +#define LOG_CONFIG_FILE_ID 0x106E +#define LOG_CONFIG_RECORD_ID 0x3427 + +ret_code_t nrf_log_config_store(void) +{ + fds_record_desc_t desc = {0}; + fds_find_token_t token = {0}; + fds_record_t record = { + .file_id = LOG_CONFIG_FILE_ID, + .key = LOG_CONFIG_RECORD_ID, + .data = { + .p_data = NRF_LOG_FILTER_SECTION_VARS_GET(0), + .length_words = NRF_SECTION_LENGTH(log_filter_data)/sizeof(uint32_t) + } + }; + ret_code_t ret = fds_record_find(LOG_CONFIG_FILE_ID, LOG_CONFIG_RECORD_ID, &desc, &token); + if (ret == NRF_SUCCESS) + { + ret = fds_record_update(&desc, &record); + NRF_LOG_INFO("Logger configuration file updated with result:%d", ret); + } + else if (ret == FDS_ERR_NOT_FOUND) + { + ret = fds_record_write(&desc, &record); + NRF_LOG_INFO("Logger configuration file written with result:%d", ret); + } + else + { + ret = NRF_ERROR_INTERNAL; + } + return ret; +} + +ret_code_t nrf_log_config_load(void) +{ + fds_record_desc_t desc = {0}; + fds_find_token_t token = {0}; + + ret_code_t ret = fds_record_find(LOG_CONFIG_FILE_ID, LOG_CONFIG_RECORD_ID, &desc, &token); + if (ret == NRF_SUCCESS) + { + fds_flash_record_t record = {0}; + ret = fds_record_open(&desc, &record); + if (ret == NRF_SUCCESS) + { + void * p_dest = (void *)NRF_LOG_FILTER_SECTION_VARS_GET(0); + uint32_t length = NRF_SECTION_LENGTH(log_filter_data); + memcpy(p_dest, record.p_data, length); + ret = fds_record_close(&desc); + } + } + else if (ret == FDS_ERR_NOT_FOUND) + { + NRF_LOG_WARNING("Logger configuration file not found."); + ret = NRF_ERROR_NOT_FOUND; + } + else + { + ret = NRF_ERROR_INTERNAL; + } + + return ret; +} +#endif //LOG_CONFIG_LOAD_STORE_ENABLED + +#if NRF_LOG_CLI_CMDS && NRF_CLI_ENABLED #include "nrf_cli.h" +typedef void (*nrf_log_cli_backend_cmd_t)(nrf_cli_t const * p_cli, + nrf_log_backend_t const * p_backend, + size_t argc, + char * * argv); + static const char * m_severity_lvls[] = { "none", "error", @@ -937,24 +1087,84 @@ static const char * m_severity_lvls_sorted[] = { "warning", }; -static void log_status(nrf_cli_t const * p_cli, size_t argc, char **argv) +/** + * @brief Function for finding backend instance with given name. + * + * @param p_name Name of the backend instance. + * + * @return Pointer to the instance or NULL. + * + */ +static nrf_log_backend_t const * backend_find(char const * p_name) +{ + size_t num_of_backends; + nrf_log_backend_t const * p_backend; + + num_of_backends = NRF_SECTION_ITEM_COUNT(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t); + for (size_t i = 0; i < num_of_backends; i++) + { + p_backend = NRF_SECTION_ITEM_GET(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t, i); + if (strcmp(p_name, p_backend->p_name) == 0) + { + return p_backend; + } + } + return NULL; +} + +/** + * @brief Function for executing command on given backend. + */ +static void nrf_cli_backend_cmd_execute(nrf_cli_t const * p_cli, + size_t argc, + char * * argv, + nrf_log_cli_backend_cmd_t func) { + //Based on the structure of backend commands, name of the backend can be found at -1 (log backend command). + char const * p_backend_name = argv[-1]; + + nrf_log_backend_t const * p_backend = backend_find(p_backend_name); + + if (p_backend) + { + func(p_cli, p_backend, argc, argv); + } + else + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Invalid backend: %s\r\n", p_backend_name); + } +} + + +static void log_status(nrf_cli_t const * p_cli, + nrf_log_backend_t const * p_backend, + size_t argc, + char * * argv) +{ + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + uint32_t modules_cnt = nrf_log_module_cnt_get(); - uint32_t backend_id = p_cli->p_log_backend->backend.id; uint32_t i; - if (!nrf_log_backend_is_enabled(&p_cli->p_log_backend->backend)) + + if (!nrf_log_backend_is_enabled(p_backend)) { nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Logs are halted!\r\n"); } - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%-24s | current | buildin \r\n", "module_name"); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "------------------------------------------\r\n"); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%-40s | current | built-in \r\n", "module_name"); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "----------------------------------------------------------\r\n"); for (i = 0; i < modules_cnt; i++) { - nrf_log_severity_t module_dynamic_lvl = nrf_log_module_filter_get(backend_id, i, true, true); - nrf_log_severity_t module_compiled_lvl = nrf_log_module_filter_get(backend_id, i, true, false); - nrf_log_severity_t actual_compiled_lvl = MIN(module_compiled_lvl, (nrf_log_severity_t)NRF_LOG_DEFAULT_LEVEL); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%-24s | %-7s | %s%s\r\n", + uint32_t backend_id = p_backend->p_cb->id; + nrf_log_severity_t module_dynamic_lvl = + nrf_log_module_filter_get(backend_id, i, true, true); + nrf_log_severity_t module_compiled_lvl = + nrf_log_module_filter_get(backend_id, i, true, false); + nrf_log_severity_t actual_compiled_lvl = + MIN(module_compiled_lvl, (nrf_log_severity_t)NRF_LOG_DEFAULT_LEVEL); + + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%-40s | %-7s | %s%s\r\n", nrf_log_module_name_get(i, true), m_severity_lvls[module_dynamic_lvl], m_severity_lvls[actual_compiled_lvl], @@ -962,6 +1172,19 @@ static void log_status(nrf_cli_t const * p_cli, size_t argc, char **argv) } } + +static void log_self_status(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + log_status(p_cli, p_cli->p_log_backend, argc, argv); +} + + +static void log_backend_status(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + nrf_cli_backend_cmd_execute(p_cli, argc, argv, log_status); +} + + static bool module_id_get(const char * p_name, uint32_t * p_id) { uint32_t modules_cnt = nrf_log_module_cnt_get(); @@ -979,6 +1202,7 @@ static bool module_id_get(const char * p_name, uint32_t * p_id) return (j != modules_cnt); } + static bool module_id_filter_set(uint32_t backend_id, uint32_t module_id, nrf_log_severity_t lvl) @@ -995,13 +1219,17 @@ static bool module_id_filter_set(uint32_t backend_id, } } -static void log_ctrl(nrf_cli_t const * p_cli, size_t argc, char **argv) + +static void log_ctrl(nrf_cli_t const * p_cli, + nrf_log_backend_t const * p_backend, + size_t argc, + char * * argv) { - uint32_t backend_id = p_cli->p_log_backend->backend.id; nrf_log_severity_t lvl; uint32_t first_m_name_idx; uint32_t i; - bool all_modules = false; + bool all_modules = false; + uint32_t backend_id = p_backend->p_cb->id; if (argc > 0) { @@ -1057,7 +1285,9 @@ static void log_ctrl(nrf_cli_t const * p_cli, size_t argc, char **argv) { if (module_id_filter_set(backend_id, i, lvl) == false) { - nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Level unavailable for module: %s\r\n", nrf_log_module_name_get(i, false)); + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, + "Level unavailable for module: %s\r\n", + nrf_log_module_name_get(i, false)); } } } @@ -1070,15 +1300,33 @@ static void log_ctrl(nrf_cli_t const * p_cli, size_t argc, char **argv) { nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Unknown module:%s\r\n", argv[i]); } - - if (module_id_filter_set(backend_id, module_id, lvl) == false) + else if (module_id_filter_set(backend_id, module_id, lvl) == false) { - nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Level unavailable for module: %s\r\n", nrf_log_module_name_get(module_id, false)); + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, + "Level unavailable for module: %s\r\n", + nrf_log_module_name_get(module_id, false)); + } + else + { + /* empty */ } } } } } + + +static void log_self_ctrl(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + log_ctrl(p_cli, p_cli->p_log_backend, argc, argv); +} + + +static void log_backend_ctrl(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + nrf_cli_backend_cmd_execute(p_cli, argc, argv, log_ctrl); +} + static void module_name_get(size_t idx, nrf_cli_static_entry_t * p_static); NRF_CLI_CREATE_DYNAMIC_CMD(m_module_name, module_name_get); @@ -1091,6 +1339,7 @@ static void module_name_get(size_t idx, nrf_cli_static_entry_t * p_static) p_static->p_syntax = nrf_log_module_name_get(idx, true); } + static void severity_lvl_get(size_t idx, nrf_cli_static_entry_t * p_static) { p_static->handler = NULL; @@ -1102,29 +1351,211 @@ static void severity_lvl_get(size_t idx, nrf_cli_static_entry_t * p_static) NRF_CLI_CREATE_DYNAMIC_CMD(m_severity_lvl, severity_lvl_get); -static void log_halt(nrf_cli_t const * p_cli, size_t argc, char **argv) + +static void log_halt(nrf_cli_t const * p_cli, + nrf_log_backend_t const * p_backend, + size_t argc, + char * * argv) +{ + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + nrf_log_backend_disable(p_backend); +} + + +static void log_backend_halt(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + nrf_cli_backend_cmd_execute(p_cli, argc, argv, log_halt); +} + + +static void log_self_halt(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + log_halt(p_cli, p_cli->p_log_backend, argc, argv); +} + + +static void log_go(nrf_cli_t const * p_cli, + nrf_log_backend_t const * p_backend, + size_t argc, + char * * argv) +{ + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + nrf_log_backend_enable(p_backend); +} + + +static void log_backend_go(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + nrf_cli_backend_cmd_execute(p_cli, argc, argv, log_go); +} + + +static void log_self_go(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + log_go(p_cli, p_cli->p_log_backend, argc, argv); +} + + +static void log_cmd_backends_list(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + size_t num_of_backends; + + num_of_backends = NRF_SECTION_ITEM_COUNT(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t); + for (size_t i = 0; i < num_of_backends; i++) + { + nrf_log_backend_t const * p_backend = + NRF_SECTION_ITEM_GET(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t, i); + + if (p_backend->p_cb->id == NRF_LOG_BACKEND_INVALID_ID) + { + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, + "%s\r\n" + "\t- Status: deactivated\r\n\r\n", + p_backend->p_name); + } + else + { + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, + "%s\r\n" + "\t- Status: %s\r\n" + "\t- ID: %d\r\n\r\n", + p_backend->p_name, + p_backend->p_cb->enabled ? "enabled" : "disabled", + p_backend->p_cb->id); + } + } +} + + +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_log_backend) +{ + NRF_CLI_CMD(disable, &m_module_name, + "'log disable .. ' disables logs in specified " + "modules (all if no modules specified).", + log_backend_ctrl), + NRF_CLI_CMD(enable, &m_severity_lvl, + "'log enable ... ' enables logs up to given level in " + "specified modules (all if no modules specified).", + log_backend_ctrl), + NRF_CLI_CMD(go, NULL, "Resume logging", log_backend_go), + NRF_CLI_CMD(halt, NULL, "Halt logging", log_backend_halt), + NRF_CLI_CMD(status, NULL, "Logger status", log_backend_status), + NRF_CLI_SUBCMD_SET_END +}; + +static void backend_name_get(size_t idx, nrf_cli_static_entry_t * p_static) +{ + p_static->handler = NULL; + p_static->p_help = NULL; + p_static->p_subcmd = &m_sub_log_backend; + p_static->p_syntax = NULL; + + nrf_log_backend_t const * p_backend; + size_t active_idx = 0; + uint32_t i; + + for (i = 0; i < NRF_SECTION_ITEM_COUNT(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t); i++) + { + p_backend = NRF_SECTION_ITEM_GET(NRF_LOG_BACKEND_SECTION_NAME, nrf_log_backend_t, i); + if (p_backend->p_cb->id != NRF_LOG_BACKEND_INVALID_ID) + { + if (idx == active_idx) + { + p_static->p_syntax = p_backend->p_name; + break; + } + else + { + active_idx++; + } + } + } +} + +NRF_CLI_CREATE_DYNAMIC_CMD(m_backend_name_dynamic, backend_name_get); + +static void log_config_load_cmd(nrf_cli_t const * p_cli, size_t argc, char **argv) { - nrf_log_backend_disable(&p_cli->p_log_backend->backend); + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + +#if LOG_CONFIG_LOAD_STORE_ENABLED + if (nrf_log_config_load() == NRF_SUCCESS) + { + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Configuration loaded.\r\n"); + } + else + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Failed to load the configuration.\r\n"); + } +#else + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Not supported.\r\n"); +#endif } -static void log_go(nrf_cli_t const * p_cli, size_t argc, char **argv) +static void log_config_store_cmd(nrf_cli_t const * p_cli, size_t argc, char **argv) { - nrf_log_backend_enable(&p_cli->p_log_backend->backend); + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + +#if LOG_CONFIG_LOAD_STORE_ENABLED + if (nrf_log_config_store() == NRF_SUCCESS) + { + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Configuration stored.\r\n"); + } + else + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Failed to store the configuration.\r\n"); + } +#else + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Not supported.\r\n"); +#endif } +NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_log_config) +{ + NRF_CLI_CMD(load, NULL, "Load configuration stored in non-volatile memory.", log_config_load_cmd), + NRF_CLI_CMD(store, NULL, "Store current configuration in non-volatile memory.", log_config_store_cmd), + NRF_CLI_SUBCMD_SET_END +}; + NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_log_stat) { + NRF_CLI_CMD(backend, &m_backend_name_dynamic, "Logger backends commands.", NULL), + NRF_CLI_CMD(config, &m_sub_log_config, "Manage logger configuration", NULL), NRF_CLI_CMD(disable, &m_module_name, "'log disable .. ' disables logs in specified " "modules (all if no modules specified).", - log_ctrl), + log_self_ctrl), NRF_CLI_CMD(enable, &m_severity_lvl, "'log enable ... ' enables logs up to given level in " "specified modules (all if no modules specified).", - log_ctrl), - NRF_CLI_CMD(go, NULL, "Resume logging", log_go), - NRF_CLI_CMD(halt, NULL, "Halt logging", log_halt), - NRF_CLI_CMD(status, NULL, "Logger status", log_status), + log_self_ctrl), + NRF_CLI_CMD(go, NULL, "Resume logging", log_self_go), + NRF_CLI_CMD(halt, NULL, "Halt logging", log_self_halt), + NRF_CLI_CMD(list_backends, NULL, "Lists logger backends.", log_cmd_backends_list), + NRF_CLI_CMD(status, NULL, "Logger status", log_self_status), NRF_CLI_SUBCMD_SET_END }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_internal.h similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_internal.h index 3cf7b06..2914e14 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_LOG_INTERNAL_H__ #define NRF_LOG_INTERNAL_H__ @@ -45,6 +45,8 @@ #include "app_util.h" #include #include +#include "nrf_log_instance.h" +#include "nrf_log_types.h" #ifndef NRF_LOG_ERROR_COLOR #define NRF_LOG_ERROR_COLOR NRF_LOG_COLOR_DEFAULT @@ -87,49 +89,48 @@ #define NRF_LOG_MODULE_NAME app #endif -#define NRF_LOG_LEVEL_ERROR 1UL -#define NRF_LOG_LEVEL_WARNING 2UL -#define NRF_LOG_LEVEL_INFO 3UL -#define NRF_LOG_LEVEL_DEBUG 4UL -#define NRF_LOG_LEVEL_INTERNAL 5UL #define NRF_LOG_LEVEL_BITS 3 #define NRF_LOG_LEVEL_MASK ((1UL << NRF_LOG_LEVEL_BITS) - 1) -#define NRF_LOG_RAW_POS 4U -#define NRF_LOG_RAW (1UL << NRF_LOG_RAW_POS) #define NRF_LOG_MODULE_ID_BITS 16 #define NRF_LOG_MODULE_ID_POS 16 -#define NRF_LOG_LEVEL_INFO_RAW (NRF_LOG_RAW | NRF_LOG_LEVEL_INFO) -#define NRF_LOG_MAX_NUM_OF_ARGS 6 -/* - * For GCC sections are sorted in the group by the linker. For IAR and KEIL it is assumed that linker will sort - * dynamic and const section in the same order (but in different locations). Proper message formatting - * is based on that assumption. - */ -#if defined(__GNUC__) -#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) CONCAT_2(log_dynamic_data_,_module_name) -#define NRF_LOG_CONST_SECTION_NAME(_module_name) CONCAT_2(log_const_data_,_module_name) -#else -#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) log_dynamic_data -#define NRF_LOG_CONST_SECTION_NAME(_module_name) log_const_data -#endif +#define NRF_LOG_MAX_NUM_OF_ARGS 6 -#define NRF_LOG_MODULE_DATA CONCAT_3(m_nrf_log_,NRF_LOG_MODULE_NAME,_logs_data) -#define NRF_LOG_MODULE_DATA_DYNAMIC CONCAT_2(NRF_LOG_MODULE_DATA,_dynamic) -#define NRF_LOG_MODULE_DATA_CONST CONCAT_2(NRF_LOG_MODULE_DATA,_const) #if NRF_LOG_FILTERS_ENABLED && NRF_LOG_ENABLED - #define NRF_LOG_FILTER NRF_LOG_MODULE_DATA_DYNAMIC.filter + #define NRF_LOG_FILTER NRF_LOG_ITEM_DATA_DYNAMIC(NRF_LOG_MODULE_NAME).filter + #define NRF_LOG_INST_FILTER(p_inst) (p_inst)->filter #else #undef NRF_LOG_FILTER - #define NRF_LOG_FILTER NRF_LOG_LEVEL_DEBUG + #define NRF_LOG_FILTER NRF_LOG_SEVERITY_DEBUG + #define NRF_LOG_INST_FILTER(p_inst) NRF_LOG_SEVERITY_DEBUG #endif +/** + * @brief Macro for calculating module id based on address and section start address + */ +#define NRF_LOG_MODULE_ID_GET_CONST(addr) (((uint32_t)(addr) - \ + (uint32_t)NRF_SECTION_START_ADDR(log_const_data)) / \ + sizeof(nrf_log_module_const_data_t)) +/** + * @brief Macro for calculating module id based on address and section start address + */ +#define NRF_LOG_MODULE_ID_GET_DYNAMIC(addr) (((uint32_t)(addr) - \ + (uint32_t)NRF_SECTION_START_ADDR(log_dynamic_data)) / \ + sizeof(nrf_log_module_dynamic_data_t)) + + #if NRF_LOG_ENABLED -#define NRF_LOG_MODULE_ID NRF_LOG_MODULE_DATA_DYNAMIC.module_id +#define NRF_LOG_MODULE_ID NRF_LOG_MODULE_ID_GET_CONST(&NRF_LOG_ITEM_DATA_CONST(NRF_LOG_MODULE_NAME)) +#if NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_INST_ID(p_inst) NRF_LOG_MODULE_ID_GET_DYNAMIC(p_inst) #else -#define NRF_LOG_MODULE_ID 0 +#define NRF_LOG_INST_ID(p_inst) NRF_LOG_MODULE_ID +#endif +#else +#define NRF_LOG_MODULE_ID 0 +#define NRF_LOG_INST_ID(p_inst) 0 #endif @@ -175,9 +176,10 @@ (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1); (void)(_arg2); (void)(_arg3); (void)(_arg4) #define LOG_INTERNAL_6(_type, _str, _arg0, _arg1, _arg2, _arg3, _arg4, _arg5) \ (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1); (void)(_arg2); (void)(_arg3); (void)(_arg4); (void)(_arg5) -#endif //NRF_LOG_ENABLED && (NRF_LOG_DEFAULT_LEVEL >= NRF_LOG_LEVEL_ERROR) +#endif //NRF_LOG_ENABLED #define LOG_SEVERITY_MOD_ID(severity) ((severity) | NRF_LOG_MODULE_ID << NRF_LOG_MODULE_ID_POS) +#define LOG_SEVERITY_INST_ID(severity,p_inst) ((severity) | NRF_LOG_INST_ID(p_inst) << NRF_LOG_MODULE_ID_POS) #if NRF_LOG_ENABLED #define LOG_HEXDUMP(_severity, _p_data, _length) \ @@ -187,136 +189,130 @@ (void)(_severity); (void)(_p_data); (void)_length #endif -#define NRF_LOG_INTERNAL_ERROR(...) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_ERROR) && \ - (NRF_LOG_LEVEL_ERROR <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_ERROR) \ - { \ - LOG_INTERNAL(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_ERROR), __VA_ARGS__); \ - } \ - } -#define NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_ERROR) && \ - (NRF_LOG_LEVEL_ERROR <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_ERROR) \ - { \ - LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_ERROR), \ - (p_data), (len)); \ - } \ +#define NRF_LOG_INTERNAL_INST(level, level_id, p_inst, ...) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ + { \ + if (NRF_LOG_INST_FILTER(p_inst) >= level) \ + { \ + LOG_INTERNAL(LOG_SEVERITY_INST_ID(level_id, p_inst), __VA_ARGS__); \ + } \ } -#define NRF_LOG_INTERNAL_WARNING(...) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_WARNING) && \ - (NRF_LOG_LEVEL_WARNING <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_WARNING) \ - { \ - LOG_INTERNAL(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_WARNING), __VA_ARGS__); \ - } \ +#define NRF_LOG_INTERNAL_MODULE(level, level_id, ...) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ + { \ + if (NRF_LOG_FILTER >= level) \ + { \ + LOG_INTERNAL(LOG_SEVERITY_MOD_ID(level_id), __VA_ARGS__); \ + } \ } -#define NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_WARNING) && \ - (NRF_LOG_LEVEL_WARNING <= NRF_LOG_DEFAULT_LEVEL)) \ + +#define NRF_LOG_INTERNAL_HEXDUMP_INST(level, level_id, p_inst, p_data, len) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_WARNING) \ + if (NRF_LOG_INST_FILTER(p_inst) >= level) \ { \ - LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_WARNING, \ + LOG_HEXDUMP(LOG_SEVERITY_INST_ID(level_id, p_inst), \ (p_data), (len)); \ } \ } -#define NRF_LOG_INTERNAL_INFO(...) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_INFO) && \ - (NRF_LOG_LEVEL_INFO <= NRF_LOG_DEFAULT_LEVEL)) \ +#define NRF_LOG_INTERNAL_HEXDUMP_MODULE(level, level_id, p_data, len) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_INFO) \ + if (NRF_LOG_FILTER >= level) \ { \ - LOG_INTERNAL(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_INFO), __VA_ARGS__); \ + LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(level_id), \ + (p_data), (len)); \ } \ } -#define NRF_LOG_INTERNAL_RAW_INFO(...) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_INFO) && \ - (NRF_LOG_LEVEL_INFO <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_INFO) \ - { \ - LOG_INTERNAL(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_INFO | NRF_LOG_RAW), \ - __VA_ARGS__); \ - } \ - } +#define NRF_LOG_INTERNAL_INST_ERROR(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR, p_inst, __VA_ARGS__) -#define NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_INFO) && \ - (NRF_LOG_LEVEL_INFO <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_INFO) \ - { \ - LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_INFO), \ - (p_data), (len)); \ - } \ - } +#define NRF_LOG_INTERNAL_ERROR(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR,__VA_ARGS__) -#define NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_INFO) && \ - (NRF_LOG_LEVEL_INFO <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_INFO) \ - { \ - LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_INFO_RAW), \ - (p_data), (len)); \ - } \ - } +#define NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR, p_inst, p_data, len) -#define NRF_LOG_INTERNAL_DEBUG(...) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_DEBUG) && \ - (NRF_LOG_LEVEL_DEBUG <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_DEBUG) \ - { \ - LOG_INTERNAL(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_DEBUG), __VA_ARGS__); \ - } \ - } -#define NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len) \ - if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= NRF_LOG_LEVEL_DEBUG) && \ - (NRF_LOG_LEVEL_DEBUG <= NRF_LOG_DEFAULT_LEVEL)) \ - { \ - if (NRF_LOG_FILTER >= NRF_LOG_LEVEL_DEBUG) \ - { \ - LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(NRF_LOG_LEVEL_DEBUG), \ - (p_data), (len)); \ - } \ - } +#define NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR, p_data, len) + +#define NRF_LOG_INTERNAL_INST_WARNING(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_WARNING(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING,__VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING, p_inst, p_data, len) + +#define NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING, p_data, len) + +#define NRF_LOG_INTERNAL_INST_INFO(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_INFO(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, p_inst, p_data, len) + +#define NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, p_data, len) + +#define NRF_LOG_INTERNAL_RAW_INFO(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO_RAW, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO_RAW, p_data, len) + +#define NRF_LOG_INTERNAL_INST_DEBUG(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_DEBUG(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, p_inst, p_data, len) -#if NRF_MODULE_ENABLED(NRF_LOG) -#define NRF_LOG_INTERNAL_GETCHAR() nrf_log_getchar() +#define NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, p_data, len) + + +#if NRF_LOG_ENABLED + +#ifdef UNIT_TEST +#define COMPILED_LOG_LEVEL 4 #else -#define NRF_LOG_INTERNAL_GETCHAR() (void) +#define COMPILED_LOG_LEVEL NRF_LOG_LEVEL #endif -typedef struct -{ - uint16_t module_id; - uint16_t order_idx; - uint32_t filter; - uint32_t filter_lvls; -} nrf_log_module_dynamic_data_t; -typedef struct -{ - const char * p_module_name; - uint8_t info_color_id; - uint8_t debug_color_id; - uint8_t compiled_lvl; -} nrf_log_module_const_data_t; +#define NRF_LOG_INTERNAL_MODULE_REGISTER() \ + NRF_LOG_INTERNAL_ITEM_REGISTER(NRF_LOG_MODULE_NAME, \ + STRINGIFY(NRF_LOG_MODULE_NAME), \ + NRF_LOG_INFO_COLOR, \ + NRF_LOG_DEBUG_COLOR, \ + NRF_LOG_INITIAL_LEVEL, \ + COMPILED_LOG_LEVEL) + +#else +#define NRF_LOG_INTERNAL_MODULE_REGISTER() /*lint -save -e19*/ /*lint -restore*/ +#endif -extern nrf_log_module_dynamic_data_t NRF_LOG_MODULE_DATA_DYNAMIC; +extern nrf_log_module_dynamic_data_t NRF_LOG_ITEM_DATA_DYNAMIC(NRF_LOG_MODULE_NAME); +extern _CONST nrf_log_module_const_data_t NRF_LOG_ITEM_DATA_CONST(NRF_LOG_MODULE_NAME); /** * Set of macros for encoding and decoding header for log entries. - * There are 3 types of entries: + * There are 2 types of entries: * 1. Standard entry (STD) * An entry consists of header, pointer to string and values. Header contains * severity leveland determines number of arguments and thus size of the entry. @@ -357,42 +353,24 @@ extern nrf_log_module_dynamic_data_t NRF_LOG_MODULE_DATA_DYNAMIC; * | data | dummy | * -------------------------------- * - * 3. Pushed string. If string is pushed into the logger internal buffer it is - * stored as PUSHED entry. It consists of header, unused data (optional) and - * string. Unused data is present if string does not not fit into a buffer - * without wrapping (and string cannot be wrapped). In that case header - * contains information about offset. - * - * -------------------------------- - * |TYPE| OFFSET | LEN | - * |------------------------------| - * | OFFSET | - * |------------------------------| - * end| OFFSET | - * 0|------------------------------| - * | STRING | - * |------------------------------| - * | STRING | dummy | - * -------------------------------- */ #define STD_ADDR_MASK ((uint32_t)(1U << 22) - 1U) #define HEADER_TYPE_STD 1U #define HEADER_TYPE_HEXDUMP 2U -#define HEADER_TYPE_PUSHED 0U #define HEADER_TYPE_INVALID 3U typedef struct { uint32_t type : 2; - uint32_t raw : 1; + uint32_t in_progress: 1; uint32_t data : 29; } nrf_log_generic_header_t; typedef struct { uint32_t type : 2; - uint32_t raw : 1; + uint32_t in_progress: 1; uint32_t severity : 3; uint32_t nargs : 4; uint32_t addr : 22; @@ -401,42 +379,32 @@ typedef struct typedef struct { uint32_t type : 2; - uint32_t raw : 1; + uint32_t in_progress: 1; uint32_t severity : 3; uint32_t offset : 10; uint32_t reserved : 6; uint32_t len : 10; } nrf_log_hexdump_header_t; -typedef struct +typedef union { - uint32_t type : 2; - uint32_t reserved0 : 4; - uint32_t offset : 10; - uint32_t reserved1 : 6; - uint32_t len : 10; -} nrf_log_pushed_header_t; + nrf_log_generic_header_t generic; + nrf_log_std_header_t std; + nrf_log_hexdump_header_t hexdump; + uint32_t raw; +} nrf_log_main_header_t; typedef struct { - union { - nrf_log_generic_header_t generic; - nrf_log_std_header_t std; - nrf_log_hexdump_header_t hexdump; - nrf_log_pushed_header_t pushed; - uint32_t raw; - } base; - uint32_t module_id; + nrf_log_main_header_t base; + uint16_t module_id; + uint16_t dropped; uint32_t timestamp; } nrf_log_header_t; #define HEADER_SIZE (sizeof(nrf_log_header_t)/sizeof(uint32_t) - \ (NRF_LOG_USES_TIMESTAMP ? 0 : 1)) -#define PUSHED_HEADER_SIZE (sizeof(nrf_log_pushed_header_t)/sizeof(uint32_t)) - -//Implementation assumes that pushed header has one word. -STATIC_ASSERT(PUSHED_HEADER_SIZE == 1); /** * @brief A function for logging raw string. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_str_formatter.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_str_formatter.c similarity index 77% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_str_formatter.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_str_formatter.c index accdf22..5d48fe7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_log/src/nrf_log_str_formatter.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/log/src/nrf_log_str_formatter.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_LOG) @@ -55,6 +55,8 @@ #define NRF_LOG_COLOR_CODE_CYAN "\x1B[1;36m" #define NRF_LOG_COLOR_CODE_WHITE "\x1B[1;37m" +#define NRF_LOG_CHAR_CODE_MAX 0x7E + static const char * severity_names[] = { NULL, "error", @@ -75,21 +77,54 @@ static const char * m_colors[] = { NRF_LOG_COLOR_CODE_WHITE, }; +static uint32_t m_freq; +static uint32_t m_timestamp_div; + +static void timestamp_print(nrf_fprintf_ctx_t * p_ctx, uint32_t timestamp) +{ + if (NRF_LOG_USES_TIMESTAMP) + { + if (NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED) + { + timestamp /= m_timestamp_div; + uint32_t seconds = timestamp/m_freq; + uint32_t hours = seconds/3600; + seconds -= hours * 3600; + uint32_t mins = seconds/60; + seconds -= mins * 60; + + uint32_t reminder = timestamp % m_freq; + uint32_t ms = (reminder * 1000)/m_freq; + uint32_t us = (1000*(1000*reminder - (ms * m_freq)))/m_freq; + + nrf_fprintf(p_ctx, "[%02d:%02d:%02d.%03d,%03d] ", hours, mins, seconds, ms, us); + } + else + { + nrf_fprintf(p_ctx, "[%08lu] ", timestamp); + } + } +} static void prefix_process(nrf_log_str_formatter_entry_params_t * p_params, nrf_fprintf_ctx_t * p_ctx) { - if (!(p_params->raw)) + if (p_params->dropped) + { + nrf_fprintf(p_ctx, + "%sLogs dropped (%d)%s\r\n", + NRF_LOG_COLOR_CODE_RED, + p_params->dropped, + NRF_LOG_COLOR_CODE_DEFAULT); + } + + if (!(p_params->severity == NRF_LOG_SEVERITY_INFO_RAW)) { if (p_params->use_colors) { nrf_fprintf(p_ctx, "%s", m_colors[nrf_log_color_id_get( p_params->module_id, p_params->severity)]); } - - if (NRF_LOG_USES_TIMESTAMP) - { - nrf_fprintf(p_ctx, "[%08lu] ", p_params->timestamp); - } + timestamp_print(p_ctx, p_params->timestamp); nrf_fprintf(p_ctx, "<%s> %s: ", severity_names[p_params->severity], nrf_log_module_name_get(p_params->module_id, false)); @@ -100,7 +135,7 @@ static void postfix_process(nrf_log_str_formatter_entry_params_t * p_params, nrf_fprintf_ctx_t * p_ctx, bool newline) { - if (!p_params->raw) + if (!(p_params->severity == NRF_LOG_SEVERITY_INFO_RAW)) { if (p_params->use_colors) { @@ -194,7 +229,7 @@ void nrf_log_hexdump_entry_process(uint8_t * p_data, if (i < data_len) { char c = (char)p_data[i]; - nrf_fprintf(p_ctx, "%c", isprint((int)c) ? c :'.'); + nrf_fprintf(p_ctx, "%c", ((c <= NRF_LOG_CHAR_CODE_MAX) && isprint((int)c)) ? c :'.'); } else { @@ -206,4 +241,18 @@ void nrf_log_hexdump_entry_process(uint8_t * p_data, p_ctx->auto_flush = auto_flush; } + +void nrf_log_str_formatter_timestamp_freq_set(uint32_t freq) +{ + m_timestamp_div = 1; + /* There is no point to have frequency higher than 1MHz (ns are not printed) and too high + * frequency leads to overflows in calculations. + */ + while (freq > 1000000) + { + freq /= 2; + m_timestamp_div *= 2; + } + m_freq = freq; +} #endif //NRF_LOG_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/low_power_pwm/low_power_pwm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/low_power_pwm/low_power_pwm.c similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/low_power_pwm/low_power_pwm.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/low_power_pwm/low_power_pwm.c index 220f1ec..42fc552 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/low_power_pwm/low_power_pwm.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/low_power_pwm/low_power_pwm.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(LOW_POWER_PWM) @@ -107,7 +107,7 @@ static void pwm_timeout_handler(void * p_context) { p_pwm_instance->handler(p_pwm_instance); - if (p_pwm_instance->pwm_state != NRF_DRV_STATE_POWERED_ON) + if (p_pwm_instance->pwm_state != NRFX_DRV_STATE_POWERED_ON) { return; } @@ -142,7 +142,7 @@ static void pwm_timeout_handler(void * p_context) p_pwm_instance->period)>>8) + APP_TIMER_MIN_TIMEOUT_TICKS; } - if (p_pwm_instance->pwm_state == NRF_DRV_STATE_POWERED_ON) + if (p_pwm_instance->pwm_state == NRFX_DRV_STATE_POWERED_ON) { err_code = app_timer_start(*p_pwm_instance->p_timer_id, p_pwm_instance->timeout_ticks, p_pwm_instance); APP_ERROR_CHECK(err_code); @@ -154,7 +154,7 @@ ret_code_t low_power_pwm_init(low_power_pwm_t * p_pwm_instance, low_power_pwm_config_t const * p_pwm_config, app_timer_timeout_handler_t handler) { - ASSERT(p_pwm_instance->pwm_state == NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_pwm_instance->pwm_state == NRFX_DRV_STATE_UNINITIALIZED); ASSERT(p_pwm_config->bit_mask != 0); ASSERT(p_pwm_config->p_port != NULL); ASSERT(p_pwm_config->period != 0); @@ -193,7 +193,7 @@ ret_code_t low_power_pwm_init(low_power_pwm_t * p_pwm_instance, } pin_off(p_pwm_instance); - p_pwm_instance->pwm_state = NRF_DRV_STATE_INITIALIZED; + p_pwm_instance->pwm_state = NRFX_DRV_STATE_INITIALIZED; return NRF_SUCCESS; } @@ -202,10 +202,10 @@ ret_code_t low_power_pwm_init(low_power_pwm_t * p_pwm_instance, ret_code_t low_power_pwm_start(low_power_pwm_t * p_pwm_instance, uint32_t pin_bit_mask) { - ASSERT(p_pwm_instance->pwm_state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_pwm_instance->pwm_state != NRFX_DRV_STATE_UNINITIALIZED); ASSERT(((p_pwm_instance->bit_mask) & pin_bit_mask) != 0x00); - p_pwm_instance->pwm_state = NRF_DRV_STATE_POWERED_ON; + p_pwm_instance->pwm_state = NRFX_DRV_STATE_POWERED_ON; p_pwm_instance->bit_mask_toggle = pin_bit_mask; pin_off(p_pwm_instance); @@ -224,7 +224,7 @@ ret_code_t low_power_pwm_start(low_power_pwm_t * p_pwm_instance, ret_code_t low_power_pwm_stop(low_power_pwm_t * p_pwm_instance) { - ASSERT(p_pwm_instance->pwm_state == NRF_DRV_STATE_POWERED_ON); + ASSERT(p_pwm_instance->pwm_state == NRFX_DRV_STATE_POWERED_ON); ret_code_t err_code; @@ -237,7 +237,7 @@ ret_code_t low_power_pwm_stop(low_power_pwm_t * p_pwm_instance) return err_code; } - p_pwm_instance->pwm_state = NRF_DRV_STATE_INITIALIZED; + p_pwm_instance->pwm_state = NRFX_DRV_STATE_INITIALIZED; return NRF_SUCCESS; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/low_power_pwm/low_power_pwm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/low_power_pwm/low_power_pwm.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/low_power_pwm/low_power_pwm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/low_power_pwm/low_power_pwm.h index 22ee0e6..79b512a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/low_power_pwm/low_power_pwm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/low_power_pwm/low_power_pwm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -55,10 +55,8 @@ #ifndef LOW_POWER_PWM_H__ #define LOW_POWER_PWM_H__ -#include -#include +#include #include "app_timer.h" -#include "nrf_drv_common.h" #include "sdk_errors.h" #ifdef __cplusplus @@ -132,7 +130,7 @@ typedef struct bool pin_is_on; /**< Indicates the current state of the pin. */ uint8_t period; /**< Width of the low_power_pwm period. */ uint8_t duty_cycle; /**< Width of high pulse. */ - nrf_drv_state_t pwm_state; /**< Indicates the current state of the PWM instance. */ + nrfx_drv_state_t pwm_state; /**< Indicates the current state of the PWM instance. */ uint32_t bit_mask; /**< Pins to be initialized. */ uint32_t bit_mask_toggle; /**< Pins to be toggled. */ uint32_t timeout_ticks; /**< Value to start the next app_timer. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mem_manager/mem_manager.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mem_manager/mem_manager.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mem_manager/mem_manager.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mem_manager/mem_manager.c index 2c29f97..d0edb42 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mem_manager/mem_manager.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mem_manager/mem_manager.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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(MEM_MANAGER) @@ -406,7 +406,7 @@ NRF_LOG_MODULE_REGISTER(); MEMORY_MANAGER_MEDIUM_BLOCK_COUNT + \ MEMORY_MANAGER_LARGE_BLOCK_COUNT + \ MEMORY_MANAGER_XLARGE_BLOCK_COUNT + \ - MEMORY_MANAGER_XLARGE_BLOCK_COUNT) + MEMORY_MANAGER_XXLARGE_BLOCK_COUNT) /**@brief Total memory managed by the module. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mem_manager/mem_manager.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mem_manager/mem_manager.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mem_manager/mem_manager.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mem_manager/mem_manager.h index 1e90ff5..194719d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mem_manager/mem_manager.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mem_manager/mem_manager.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj/nrf_memobj.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj/nrf_memobj.c similarity index 66% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj/nrf_memobj.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj/nrf_memobj.c index 4d7deef..5665dd9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj/nrf_memobj.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj/nrf_memobj.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_memobj.h" @@ -44,18 +44,21 @@ typedef struct memobj_elem_s memobj_elem_t; +/** @brief Standard chunk header. */ typedef struct { - memobj_elem_t * p_next; + memobj_elem_t * p_next; ///< Pointer to the next element. } memobj_header_t; +/** @brief Head header extension fields. */ typedef struct { - uint8_t user_cnt; - uint8_t chunk_cnt; - uint16_t chunk_size; + uint8_t user_cnt; ///< User counter (see @ref nrf_memobj_get and @ref nrf_memobj_put). + uint8_t chunk_cnt; ///< Number of chunks in the object. + uint16_t chunk_size; ///< Single chunk size } memobj_head_header_fields_t; +/** @brief Head header extension. */ typedef struct { union @@ -65,19 +68,21 @@ typedef struct } data; } memobj_head_header_t; +/** @brief Head chunk structure. */ typedef struct { - memobj_header_t header; - memobj_head_header_t head_header; - uint8_t data[1]; + memobj_header_t header; ///< Standard header. + memobj_head_header_t head_header; ///< Head-specific header part. + uint8_t data[1]; ///< Data. } memobj_head_t; STATIC_ASSERT(sizeof(memobj_header_t) == NRF_MEMOBJ_STD_HEADER_SIZE); +/** @brief Standard chunk structure. */ struct memobj_elem_s { - memobj_header_t header; - uint8_t data[1]; + memobj_header_t header; ///< Standard header. + uint8_t data[1]; ///< Data. }; ret_code_t nrf_memobj_pool_init(nrf_memobj_pool_t const * p_pool) @@ -118,7 +123,7 @@ nrf_memobj_t * nrf_memobj_alloc(nrf_memobj_pool_t const * p_pool, } else { - //Couldn't allocate all requested buffers + //Could not allocate all requested buffers nrf_memobj_free((nrf_memobj_t *)p_head); return NULL; } @@ -168,64 +173,86 @@ void nrf_memobj_put(nrf_memobj_t * p_obj) } static void memobj_op(nrf_memobj_t * p_obj, - void * p_data, - uint32_t len, - uint32_t offset, + void * p_data, + size_t * p_len, + size_t offset, bool read) { - memobj_head_t * p_head = (memobj_head_t *)p_obj; - uint32_t space_in_chunk = p_head->head_header.data.fields.chunk_size; + ASSERT(p_obj); + + memobj_head_t * p_head = (memobj_head_t *)p_obj; memobj_elem_t * p_curr_chunk = (memobj_elem_t *)p_obj; - uint32_t chunk_idx = (offset + sizeof(memobj_head_header_fields_t))/space_in_chunk; - uint32_t chunk_offset = (offset + sizeof(memobj_head_header_fields_t)) % space_in_chunk; + size_t obj_capacity; + size_t chunk_size; + size_t chunk_idx; + size_t chunk_offset; + size_t len; + + obj_capacity = (p_head->head_header.data.fields.chunk_size * + p_head->head_header.data.fields.chunk_cnt) - + sizeof(memobj_head_header_fields_t); + + ASSERT(offset < obj_capacity); + + chunk_size = p_head->head_header.data.fields.chunk_size; + chunk_idx = (offset + sizeof(memobj_head_header_fields_t)) / chunk_size; + chunk_offset = (offset + sizeof(memobj_head_header_fields_t)) % chunk_size; + len = ((*p_len + offset) > obj_capacity) ? obj_capacity - offset : *p_len; - uint8_t chunks_expected = CEIL_DIV((offset + sizeof(memobj_head_header_fields_t) + len), - space_in_chunk); - UNUSED_VARIABLE(chunks_expected); - ASSERT(p_head->head_header.data.fields.chunk_cnt >= chunks_expected); + //Return number of available bytes + *p_len = len; + //Move to the first chunk to be used while (chunk_idx > 0) { p_curr_chunk = p_curr_chunk->header.p_next; chunk_idx--; } - uint32_t src_offset = 0; - uint32_t curr_cpy_size = space_in_chunk-chunk_offset; + size_t user_mem_offset = 0; + size_t curr_cpy_size = chunk_size - chunk_offset; curr_cpy_size = curr_cpy_size > len ? len : curr_cpy_size; while (len) { + void * p_user_mem = &((uint8_t *)p_data)[user_mem_offset]; + void * p_obj_mem = &p_curr_chunk->data[chunk_offset]; if (read) { - memcpy(&((uint8_t *)p_data)[src_offset], &p_curr_chunk->data[chunk_offset], curr_cpy_size); + memcpy(p_user_mem, p_obj_mem, curr_cpy_size); } else { - memcpy(&p_curr_chunk->data[chunk_offset], &((uint8_t *)p_data)[src_offset], curr_cpy_size); + memcpy(p_obj_mem, p_user_mem, curr_cpy_size); } - chunk_offset = 0; - p_curr_chunk = p_curr_chunk->header.p_next; - len -= curr_cpy_size; - src_offset += curr_cpy_size; - curr_cpy_size = (space_in_chunk > len) ? len : space_in_chunk; + + chunk_offset = 0; + p_curr_chunk = p_curr_chunk->header.p_next; + len -= curr_cpy_size; + user_mem_offset += curr_cpy_size; + curr_cpy_size = (chunk_size > len) ? len : chunk_size; } } void nrf_memobj_write(nrf_memobj_t * p_obj, - void * p_data, - uint32_t len, - uint32_t offset) + void * p_data, + size_t len, + size_t offset) { - memobj_op(p_obj, p_data, len, offset, false); + size_t op_len = len; + memobj_op(p_obj, p_data, &op_len, offset, false); + ASSERT(op_len == len); } void nrf_memobj_read(nrf_memobj_t * p_obj, - void * p_data, - uint32_t len, - uint32_t offset) + void * p_data, + size_t len, + size_t offset) { - memobj_op(p_obj, p_data, len, offset, true); + size_t op_len = len; + memobj_op(p_obj, p_data, &op_len, offset, true); + ASSERT(op_len == len); + } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj/nrf_memobj.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj/nrf_memobj.h similarity index 56% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj/nrf_memobj.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj/nrf_memobj.h index d3188d3..05b5a81 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_memobj/nrf_memobj.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/memobj/nrf_memobj.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_MEMOBJ_H @@ -45,7 +45,7 @@ * @defgroup nrf_memobj Memory Object module * @{ * @ingroup app_common -* @brief Functions for controlling memory object +* @brief Functions for controlling a memory object. */ #include #include @@ -57,43 +57,50 @@ extern "C" { #endif /** - * Memory object can consist of multiple object with the same size. Each object has header and data - * part. First element in memory object is memory object head which has special header, remaining objects - * has the same header. Model of memory object is presented below. - * - * |---------------------| |---------------------| |---------------------| - * | head header (u32): | --->| std header - p_next |------->| p_memobj_pool | - * | num_of_chunks, | | |---------------------| |---------------------| - * | ref counter | | | | | | - * |---------------------| | | | | | - * | std header - p_next |-| | | .... | | - * |---------------------| | data | | data | - * | | | | | | - * | data | | | | | - * | | | | | | - * |---------------------| |---------------------| |---------------------| - * head mid_element last_element - * + * A memory object can consist of multiple chunks with the same size. Each object has a header part + * and a data part. The first element in a memory object is memory object head which has a special header. + * The remaining objects have a header of the same size. + * +@verbatim + _____________________ _____________________ _____________________ +| | | | | | +|4 B head header | --> |4 B p_next |------->|4 B p_memobj_pool | +|_____________________| | |_____________________| |_____________________| +| | | | | | | +|4 B p_next |--| | | | | +|_____________________| | | .... | | +| | | data | | data | +| | | | | | +| data | | | | | +| | | | | | +|_____________________| |_____________________| |_____________________| + head mid_element last_element +@endverbatim * */ #define NRF_MEMOBJ_STD_HEADER_SIZE sizeof(uint32_t) /** - * @brief Macro for creating a nrf_memobj pool. + * @brief Macro for creating an nrf_memobj pool. + * + * This macro declares an nrf_balloc object. The element in the pool contains a user-defined data part and + * a memory object header. * - * Macro declares nrf_balloc object. Element in the pool contains user defined data part and - * memobj header. + * @param _name Name of the instance. + * @param _chunk_size Size of a single chunk. + * @param _pool_size Number of chunks in the pool. */ -#define NRF_MEMOBJ_POOL_DEF(_name, _element_size, _pool_size) \ - NRF_BALLOC_DEF(_name, ((_element_size)+NRF_MEMOBJ_STD_HEADER_SIZE), (_pool_size)) +#define NRF_MEMOBJ_POOL_DEF(_name, _chunk_size, _pool_size) \ + STATIC_ASSERT((_chunk_size) > sizeof(uint32_t)); \ + NRF_BALLOC_DEF(_name, ((_chunk_size)+NRF_MEMOBJ_STD_HEADER_SIZE), (_pool_size)) /** - * @brief Pool of memobj. + * @brief Pool of memory objects. */ typedef nrf_balloc_t nrf_memobj_pool_t; /** - * @brief Memobj handle. + * @brief Memory object handle. */ typedef void * nrf_memobj_t; @@ -104,30 +111,28 @@ typedef void * nrf_memobj_t; * * @param[in] p_pool Pointer to the memobj pool instance structure. * - * @return NRF_SUCCESS on success, otherwise error code. + * @return NRF_SUCCESS on success, otherwise an error code. */ ret_code_t nrf_memobj_pool_init(nrf_memobj_pool_t const * p_pool); /** - * @brief Function for allocating memobj with requested size. - * - * Fixed length elements in the pool are linked together to provide amount of memory requested by - * the user. If memory object is successfully allocated then user can use memory however it is - * fragmented into multiple object so it has to be access through the API: @ref nrf_memobj_write, - * @ref nrf_memobj_read. - * - * This function initializes the pool. + * @brief Function for allocating a memobj with a requested size. * + * Fixed length elements in the pool are linked together to provide the amount of memory requested by + * the user. If a memory object is successfully allocated, then the users can use the memory. + * However, it is fragmented into multiple objects so it must be accessed through the API: + * @ref nrf_memobj_write and @ref nrf_memobj_read. + * * @param[in] p_pool Pointer to the memobj pool instance structure. * @param[in] size Data size of requested object. * - * @return Pointer to memory object or NULL if requested size cannot be allocated. + * @return Pointer to a memory object or NULL if the requested size cannot be allocated. */ nrf_memobj_t * nrf_memobj_alloc(nrf_memobj_pool_t const * p_pool, size_t size); /** - * @brief Function for indicating that memory object is used and cannot be freed. + * @brief Function for indicating that a memory object is used and cannot be freed. * * Memory object can be shared and reused between multiple modules and this mechanism ensures that * object is freed when no longer used by any module. Memory object has a counter which is incremented @@ -166,28 +171,28 @@ void nrf_memobj_free(nrf_memobj_t * p_obj); /** * @brief Function for writing data to the memory object. * - * @param[in] p_obj Pointer to memory object. - * @param[in] p_data Pointer to data to be written to the memory object. - * @param[in] len Amount of data to be written to the memory object. - * @param[in] offset Offset. + * @param[in] p_obj Pointer to memory object. + * @param[in] p_data Pointer to data to be written to the memory object. + * @param[in] len Amount of data to be written to the memory object. + * @param[in] offset Offset. */ void nrf_memobj_write(nrf_memobj_t * p_obj, - void * p_data, - uint32_t len, - uint32_t offset); + void * p_data, + size_t len, + size_t offset); /** * @brief Function for reading data from the memory object. * - * @param[in] p_obj Pointer to memory object. - * @param[in] p_data Pointer to the destination buffer. - * @param[in] len Amount of data to be read from the memory object. - * @param[in] offset Offset. + * @param[in] p_obj Pointer to memory object. + * @param[in] p_data Pointer to the destination buffer. + * @param[in] len Amount of data to be read from the memory object. + * @param[in] offset Offset. */ void nrf_memobj_read(nrf_memobj_t * p_obj, - void * p_data, - uint32_t len, - uint32_t offset); + void * p_data, + size_t len, + size_t offset); #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.c similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.c index d7ac04f..fe8167c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,24 +35,25 @@ * 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 #include "nrf.h" -#include "nrf_mpu.h" +#include "nrf_mpu_lib.h" #include "app_util_platform.h" +#include "sdk_config.h" -#if NRF_MPU_CLI_CMDS +#if NRF_MPU_LIB_CLI_CMDS #include "nrf_cli.h" #endif -#define NRF_LOG_MODULE_NAME nrf_mpu +#define NRF_LOG_MODULE_NAME nrf_mpu_lib -#if NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR NRF_MPU_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR NRF_MPU_CONFIG_DEBUG_COLOR +#if NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NRF_MPU_LIB_CONFIG_DEBUG_COLOR #else #define NRF_LOG_LEVEL 0 #endif @@ -63,14 +64,14 @@ NRF_LOG_MODULE_REGISTER(); STATIC_ASSERT(__MPU_PRESENT); STATIC_ASSERT(__CORTEX_M == 4); -/**@brief Return number of unified regions avaiable in MPU. */ -__STATIC_INLINE unsigned int nrf_mpu_get_number_of_regions(void) +/**@brief Return the number of unified regions avaiable in MPU. */ +__STATIC_INLINE unsigned int nrf_mpu_lib_get_number_of_regions(void) { return (MPU->TYPE & MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos; } /**@brief Extract human-readable memory type from attributes. */ -static const char *nrf_mpu_mem_type(uint32_t attributes) +static const char *nrf_mpu_lib_mem_type(uint32_t attributes) { attributes &= MPU_RASR_TEX_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk | MPU_RASR_S_Msk; @@ -115,7 +116,7 @@ static const char *nrf_mpu_mem_type(uint32_t attributes) } /**@brief Extract human-readable access level from attributes. */ -static const char *nrf_mpu_mem_access(uint32_t attributes) +static const char *nrf_mpu_lib_mem_access(uint32_t attributes) { switch ((attributes & MPU_RASR_AP_Msk) >> MPU_RASR_AP_Pos) { @@ -148,7 +149,7 @@ static const char *nrf_mpu_mem_access(uint32_t attributes) // Not reached. } -ret_code_t nrf_mpu_init(void) +ret_code_t nrf_mpu_lib_init(void) { unsigned int i, regions; @@ -160,8 +161,8 @@ ret_code_t nrf_mpu_init(void) } // Make sure that we can handle all avaiable regions. - regions = nrf_mpu_get_number_of_regions(); - if (regions > ((1 << (8 * sizeof(nrf_mpu_region_t))) - 1)) + regions = nrf_mpu_lib_get_number_of_regions(); + if (regions > ((1 << (8 * sizeof(nrf_mpu_lib_region_t))) - 1)) { NRF_LOG_ERROR("MPU with %u regions is not supported!", regions); return NRF_ERROR_NOT_SUPPORTED; @@ -190,15 +191,15 @@ ret_code_t nrf_mpu_init(void) return NRF_SUCCESS; } -ret_code_t nrf_mpu_region_create(nrf_mpu_region_t *p_region, - void *address, - size_t size, - uint32_t attributes) +ret_code_t nrf_mpu_lib_region_create(nrf_mpu_lib_region_t *p_region, + void *address, + size_t size, + uint32_t attributes) { unsigned long addr = (unsigned long)(address); - unsigned int i, regions = nrf_mpu_get_number_of_regions(); + unsigned int i, regions = nrf_mpu_lib_get_number_of_regions(); - // Size must be power of 2 greather than or equal to 32 + // Size must be power of 2, greater than or equal to 32 if ((size & (size - 1)) || (size < 32)) { NRF_LOG_ERROR("Cannot create MPU region 0x%08X-0x%08X: Region size is not valid!", addr, addr + size - 1); @@ -257,16 +258,16 @@ ret_code_t nrf_mpu_region_create(nrf_mpu_region_t *p_region, i, addr, addr + size - 1, - (uint32_t)nrf_mpu_mem_access(attributes), - (uint32_t)nrf_mpu_mem_type(attributes), + (uint32_t)nrf_mpu_lib_mem_access(attributes), + (uint32_t)nrf_mpu_lib_mem_type(attributes), (uint32_t)((attributes & MPU_RASR_XN_Msk) ? "XN" : "--")); return NRF_SUCCESS; } -ret_code_t nrf_mpu_region_destroy(nrf_mpu_region_t region) +ret_code_t nrf_mpu_lib_region_destroy(nrf_mpu_lib_region_t region) { - if (region >= nrf_mpu_get_number_of_regions()) + if (region >= nrf_mpu_lib_get_number_of_regions()) { NRF_LOG_ERROR("Cannot destroy MPU region %u: Invaid region!", region); return NRF_ERROR_INVALID_PARAM; @@ -286,10 +287,10 @@ ret_code_t nrf_mpu_region_destroy(nrf_mpu_region_t region) return NRF_SUCCESS; } -#if NRF_MPU_CLI_CMDS +#if NRF_MPU_LIB_CLI_CMDS /**@brief Extract human-readable caching policy from attributes. */ -static const char *nrf_mpu_mem_caching(uint32_t attributes) +static const char *nrf_mpu_lib_mem_caching(uint32_t attributes) { static const char *caching[] = { @@ -340,7 +341,7 @@ static const char *nrf_mpu_mem_caching(uint32_t attributes) return "Unknown"; } /**@brief Implementation of "mpu info" command. */ -static void nrf_mpu_cmd_info(nrf_cli_t const *p_cli, size_t argc, char **argv) +static void nrf_mpu_lib_cmd_info(nrf_cli_t const *p_cli, size_t argc, char **argv) { if (nrf_cli_help_requested(p_cli)) { @@ -348,7 +349,7 @@ static void nrf_mpu_cmd_info(nrf_cli_t const *p_cli, size_t argc, char **argv) return; } - unsigned int i, regions = nrf_mpu_get_number_of_regions(); + unsigned int i, regions = nrf_mpu_lib_get_number_of_regions(); nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "MPU State: %s, %u unified regions aviable.\r\n\r\n", (MPU->CTRL & MPU_CTRL_ENABLE_Msk) ? "Enabled" : "Disabled", @@ -380,17 +381,17 @@ static void nrf_mpu_cmd_info(nrf_cli_t const *p_cli, size_t argc, char **argv) rbar + size - 1, size); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Access:\t%s\r\n", nrf_mpu_mem_access(rasr)); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Type:\t\t%s\r\n", nrf_mpu_mem_type(rasr)); - nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Caching:\t%s\r\n", nrf_mpu_mem_caching(rasr)); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Access:\t%s\r\n", nrf_mpu_lib_mem_access(rasr)); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Type:\t\t%s\r\n", nrf_mpu_lib_mem_type(rasr)); + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Caching:\t%s\r\n", nrf_mpu_lib_mem_caching(rasr)); nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "\t- Flags:\t%s\r\n\r\n", (rasr & MPU_RASR_XN_Msk) ? "XN" : "--"); } } /**@brief Implementation of "mpu dump" command. */ -static void nrf_mpu_cmd_dump(nrf_cli_t const *p_cli, size_t argc, char **argv) +static void nrf_mpu_lib_cmd_dump(nrf_cli_t const *p_cli, size_t argc, char **argv) { - unsigned int i, regions = nrf_mpu_get_number_of_regions(); + unsigned int i, regions = nrf_mpu_lib_get_number_of_regions(); if (nrf_cli_help_requested(p_cli)) { @@ -417,7 +418,7 @@ static void nrf_mpu_cmd_dump(nrf_cli_t const *p_cli, size_t argc, char **argv) } /**@brief Implementation of "mpu" command. */ -static void nrf_mpu_cmd_unknown(nrf_cli_t const * p_cli, size_t argc, char **argv) +static void nrf_mpu_lib_cmd_unknown(nrf_cli_t const * p_cli, size_t argc, char **argv) { if ((argc == 1) || nrf_cli_help_requested(p_cli)) { @@ -429,13 +430,13 @@ static void nrf_mpu_cmd_unknown(nrf_cli_t const * p_cli, size_t argc, char **arg } // Register "mpu" command and it's subcommands in CLI. -NRF_CLI_CREATE_STATIC_SUBCMD_SET(nrf_mpu_commands) +NRF_CLI_CREATE_STATIC_SUBCMD_SET(nrf_mpu_lib_commands) { - NRF_CLI_CMD(dump, NULL, "Dump MPU registers.", nrf_mpu_cmd_dump), - NRF_CLI_CMD(info, NULL, "Print information about MPU state.", nrf_mpu_cmd_info), + NRF_CLI_CMD(dump, NULL, "Dump MPU registers.", nrf_mpu_lib_cmd_dump), + NRF_CLI_CMD(info, NULL, "Print information about MPU state.", nrf_mpu_lib_cmd_info), NRF_CLI_SUBCMD_SET_END }; -NRF_CLI_CMD_REGISTER(mpu, &nrf_mpu_commands, "Commands for MPU management", nrf_mpu_cmd_unknown); +NRF_CLI_CMD_REGISTER(mpu, &nrf_mpu_lib_commands, "Commands for MPU management", nrf_mpu_lib_cmd_unknown); -#endif //NRF_MPU_CLI_CMDS +#endif //NRF_MPU_LIB_CLI_CMDS diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.h index 32ff5af..87d3885 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_mpu/nrf_mpu.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mpu/nrf_mpu_lib.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,17 +35,17 @@ * 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 __NRF_MPU_H -#define __NRF_MPU_H +#ifndef __NRF_MPU_LIB_H +#define __NRF_MPU_LIB_H /** -* @defgroup nrf_mpu MPU (Memory Protection Unit) driver +* @defgroup nrf_mpu_lib MPU (Memory Protection Unit) driver * @{ * @ingroup app_common -* @brief Functions for controlling MPU +* @brief Functions for controlling MPU. */ #include #include @@ -56,39 +56,39 @@ extern "C" { #endif /**@brief MPU region handle. */ -typedef uint8_t nrf_mpu_region_t; +typedef uint8_t nrf_mpu_lib_region_t; /**@brief Initialize MPU and driver. * * @return NRF_SUCCESS on success, otherwise error code. */ -ret_code_t nrf_mpu_init(void); +ret_code_t nrf_mpu_lib_init(void); -/**@brief Create new MPU region. +/**@brief Create a new MPU region. * * @param[out] p_region Region handle. * @param[in] address Region base address. - * @param[in] size Region size, - * @param[in] attributes Region attributes. + * @param[in] size Region size. + * @param[in] attributes Region attributes. See ARM Cortex-M MPU documentation. * * @return NRF_SUCCESS on success, otherwise error code. */ -ret_code_t nrf_mpu_region_create(nrf_mpu_region_t *p_region, - void *address, - size_t size, - uint32_t attributes); +ret_code_t nrf_mpu_lib_region_create(nrf_mpu_lib_region_t *p_region, + void *address, + size_t size, + uint32_t attributes); -/**@brief Destroy MPU region. +/**@brief Destroy an MPU region. * * @param[in] region Region handle. * * @return NRF_SUCCESS on success, otherwise error code. */ -ret_code_t nrf_mpu_region_destroy(nrf_mpu_region_t region); +ret_code_t nrf_mpu_lib_region_destroy(nrf_mpu_lib_region_t region); #ifdef __cplusplus } #endif -#endif /* __NRF_MPU_H */ +#endif /* __NRF_MPU_LIB_H */ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mutex/nrf_mtx.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mutex/nrf_mtx.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mutex/nrf_mtx.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mutex/nrf_mtx.h index b60c4de..0eae876 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/mutex/nrf_mtx.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/mutex/nrf_mtx.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 nrf_mtx nRF Mutex diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwm/app_pwm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwm/app_pwm.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwm/app_pwm.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwm/app_pwm.c index a496920..5960f80 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwm/app_pwm.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwm/app_pwm.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,14 +35,13 @@ * 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(APP_PWM) #include "app_pwm.h" #include "nrf_drv_timer.h" #include "nrf_drv_ppi.h" -#include "nrf_drv_common.h" #include "nrf_drv_gpiote.h" #include "nrf_gpiote.h" #include "nrf_gpio.h" @@ -604,7 +603,7 @@ ret_code_t app_pwm_channel_duty_ticks_set(app_pwm_t const * const p_instance, ASSERT(channel < APP_PWM_CHANNELS_PER_INSTANCE); ASSERT(p_ch_cb->initialized == APP_PWM_CHANNEL_INITIALIZED); - if (p_cb->state != NRF_DRV_STATE_POWERED_ON) + if (p_cb->state != NRFX_DRV_STATE_POWERED_ON) { return NRF_ERROR_INVALID_STATE; } @@ -686,7 +685,7 @@ static ret_code_t app_pwm_channel_init(app_pwm_t const * const p_instance, uint8 app_pwm_cb_t * p_cb = p_instance->p_cb; app_pwm_channel_cb_t * p_channel_cb = &p_cb->channels_cb[channel]; - if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED) + if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED) { return NRF_ERROR_INVALID_STATE; } @@ -792,7 +791,7 @@ ret_code_t app_pwm_init(app_pwm_t const * const p_instance, app_pwm_config_t con app_pwm_cb_t * p_cb = p_instance->p_cb; - if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED) + if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED) { return NRF_ERROR_INVALID_STATE; } @@ -907,7 +906,7 @@ ret_code_t app_pwm_init(app_pwm_t const * const p_instance, app_pwm_config_t con p_cb->p_ready_callback = p_ready_callback; m_instances[p_instance->p_timer->instance_id] = p_instance; m_pwm_busy[p_instance->p_timer->instance_id] = BUSY_STATE_IDLE; - p_cb->state = NRF_DRV_STATE_INITIALIZED; + p_cb->state = NRFX_DRV_STATE_INITIALIZED; return NRF_SUCCESS; } @@ -917,7 +916,7 @@ void app_pwm_enable(app_pwm_t const * const p_instance) { app_pwm_cb_t * p_cb = p_instance->p_cb; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED); for (uint32_t channel = 0; channel < APP_PWM_CHANNELS_PER_INSTANCE; ++channel) { @@ -937,7 +936,7 @@ void app_pwm_enable(app_pwm_t const * const p_instance) nrf_drv_timer_clear(p_instance->p_timer); nrf_drv_timer_enable(p_instance->p_timer); - p_cb->state = NRF_DRV_STATE_POWERED_ON; + p_cb->state = NRFX_DRV_STATE_POWERED_ON; return; } @@ -946,7 +945,7 @@ void app_pwm_disable(app_pwm_t const * const p_instance) { app_pwm_cb_t * p_cb = p_instance->p_cb; - ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); + ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED); nrf_drv_timer_disable(p_instance->p_timer); pwm_irq_disable(p_instance); @@ -982,7 +981,7 @@ void app_pwm_disable(app_pwm_t const * const p_instance) pan73_workaround(p_instance->p_timer->p_reg, false); - p_cb->state = NRF_DRV_STATE_INITIALIZED; + p_cb->state = NRFX_DRV_STATE_INITIALIZED; return; } @@ -991,17 +990,17 @@ ret_code_t app_pwm_uninit(app_pwm_t const * const p_instance) { app_pwm_cb_t * p_cb = p_instance->p_cb; - if (p_cb->state == NRF_DRV_STATE_POWERED_ON) + if (p_cb->state == NRFX_DRV_STATE_POWERED_ON) { app_pwm_disable(p_instance); } - else if (p_cb->state == NRF_DRV_STATE_UNINITIALIZED) + else if (p_cb->state == NRFX_DRV_STATE_UNINITIALIZED) { return NRF_ERROR_INVALID_STATE; } pwm_dealloc(p_instance); - p_cb->state = NRF_DRV_STATE_UNINITIALIZED; + p_cb->state = NRFX_DRV_STATE_UNINITIALIZED; return NRF_SUCCESS; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwm/app_pwm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwm/app_pwm.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwm/app_pwm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwm/app_pwm.h index 73487c6..9ee0b62 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwm/app_pwm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwm/app_pwm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -63,7 +63,6 @@ #include #include "sdk_errors.h" #include "nrf_drv_timer.h" -#include "nrf_drv_common.h" #include "nrf_drv_ppi.h" #include "nrf_peripherals.h" @@ -181,7 +180,7 @@ typedef struct nrf_ppi_channel_t ppi_channels[2]; //!< PPI channels used temporary while changing duty nrf_ppi_channel_group_t ppi_group; //!< PPI group used to synchronize changes on channels #endif - nrf_drv_state_t state; //!< Current driver status + nrfx_drv_state_t state; //!< Current driver status } app_pwm_cb_t; /** @} * @endcond diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c index cacfe14..e602366 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_PWR_MGMT) @@ -90,9 +90,10 @@ static nrf_section_iter_t m_handlers_iter; /**< Shutdown handlers iterator. __STATIC_INLINE void pwr_mgmt_fpu_sleep_prepare(void) { - uint32_t fpscr; + uint32_t original_fpscr; + CRITICAL_REGION_ENTER(); - fpscr = __get_FPSCR(); + original_fpscr = __get_FPSCR(); /* * Clear FPU exceptions. * Without this step, the FPU interrupt is marked as pending, @@ -104,18 +105,24 @@ static nrf_section_iter_t m_handlers_iter; /**< Shutdown handlers iterator. * - IXC - Inexact cumulative exception bit. * - IDC - Input Denormal cumulative exception bit. */ - __set_FPSCR(fpscr & ~0x9Fu); + __set_FPSCR(original_fpscr & ~0x9Fu); __DMB(); NVIC_ClearPendingIRQ(FPU_IRQn); CRITICAL_REGION_EXIT(); /* - * Assert no critical FPU exception is signaled: + * The last chance to indicate an error in FPU to the user + * as the FPSCR is now cleared + * + * This assert is related to previous FPU operations + * and not power management. + * + * Critical FPU exceptions signaled: * - IOC - Invalid Operation cumulative exception bit. * - DZC - Division by Zero cumulative exception bit. * - OFC - Overflow cumulative exception bit. */ - ASSERT((fpscr & 0x07) == 0); + ASSERT((original_fpscr & 0x7) == 0); } #else #define PWR_MGMT_FPU_SLEEP_PREPARE() @@ -410,6 +417,16 @@ static void shutdown_process(void) ret_code_t ret_code = sd_power_system_off(); ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)); UNUSED_VARIABLE(ret_code); +#ifdef DEBUG + while (true) + { + /* Since the CPU is kept on in an emulated System OFF mode, it is recommended + * to add an infinite loop directly after entering System OFF, to prevent + * the CPU from executing code that normally should not be executed. */ + __WFE(); + + } +#endif } #endif // SOFTDEVICE_PRESENT nrf_power_system_off(); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h index 723ab86..b8ab382 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/pwr_mgmt/nrf_pwr_mgmt.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** * @defgroup nrf_pwr_mgmt Power management @@ -52,6 +52,10 @@ #include #include "nrf_section_iter.h" +#ifdef __cplusplus +extern "C" { +#endif + /**@brief Power management shutdown types. */ typedef enum { @@ -146,5 +150,9 @@ void nrf_pwr_mgmt_feed(void); */ void nrf_pwr_mgmt_shutdown(nrf_pwr_mgmt_shutdown_t shutdown_type); +#ifdef __cplusplus +} +#endif + #endif // NRF_PWR_MGMT_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/queue/nrf_queue.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/queue/nrf_queue.c similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/queue/nrf_queue.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/queue/nrf_queue.c index 62b7a8b..5b49183 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/queue/nrf_queue.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/queue/nrf_queue.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,13 +35,90 @@ * 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(NRF_QUEUE) #include "nrf_queue.h" #include "app_util_platform.h" +#if NRF_QUEUE_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_QUEUE_CONFIG_LOG_LEVEL + #define NRF_LOG_INIT_FILTER_LEVEL NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL + #define NRF_LOG_INFO_COLOR NRF_QUEUE_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_QUEUE_CONFIG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // NRF_QUEUE_CONFIG_LOG_ENABLED +#include "nrf_log.h" + +NRF_SECTION_DEF(nrf_queue, nrf_queue_t); + +#if NRF_QUEUE_CLI_CMDS && NRF_CLI_ENABLED +#include "nrf_cli.h" + +static void nrf_queue_status(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + if (argc > 1) + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Bad argument count"); + return; + } + + uint32_t num_of_instances = NRF_SECTION_ITEM_COUNT(nrf_queue, nrf_queue_t); + uint32_t i; + + for (i = 0; i < num_of_instances; i++) + { + const nrf_queue_t * p_instance = NRF_SECTION_ITEM_GET(nrf_queue, nrf_queue_t, i); + + uint32_t element_size = p_instance->element_size; + uint32_t size = p_instance->size; + uint32_t max_util = nrf_queue_max_utilization_get(p_instance); + uint32_t util = nrf_queue_utilization_get(p_instance); + const char * p_name = p_instance->p_name; + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, + "%s\r\n\t- Element size:\t%d\r\n" + "\t- Usage:\t%u%% (%u out of %u elements)\r\n" + "\t- Maximum:\t%u%% (%u out of %u elements)\r\n" + "\t- Mode:\t\t%s\r\n\r\n", + p_name, element_size, + 100ul * util/size, util,size, + 100ul * max_util/size, max_util,size, + (p_instance->mode == NRF_QUEUE_MODE_OVERFLOW) ? "Overflow" : "No overflow"); + + } +} +// Register "queue" command and its subcommands in CLI. +NRF_CLI_CREATE_STATIC_SUBCMD_SET(nrf_queue_commands) +{ + NRF_CLI_CMD(status, NULL, "Print status of queue instances.", nrf_queue_status), + NRF_CLI_SUBCMD_SET_END +}; + +NRF_CLI_CMD_REGISTER(queue, &nrf_queue_commands, "Commands for BALLOC management", nrf_queue_status); +#endif //NRF_QUEUE_CLI_CMDS + +__STATIC_INLINE size_t circullar_buffer_size_get(nrf_queue_t const * p_queue) +{ + static const uint8_t full_queue_indicator = 1; + + /* When a queue is implemented as a cyclic buffer, it is not possible to + * distinguish a full queue from an empty queue. In order to solve this + * problem, the cyclic buffer has been implemented one element larger than + * the queue size. + */ + return p_queue->size + full_queue_indicator; +} + /**@brief Get next element index. * * @param[in] p_queue Pointer to the queue instance. @@ -65,7 +142,9 @@ __STATIC_INLINE size_t queue_utilization_get(nrf_queue_t const * p_queue) { size_t front = p_queue->p_cb->front; size_t back = p_queue->p_cb->back; - return (back >= front) ? (back - front) : (p_queue->size + 1 - front + back); + + return (back >= front) ? (back - front) : + (circullar_buffer_size_get(p_queue) - front + back); } bool nrf_queue_is_full(nrf_queue_t const * p_queue) @@ -95,6 +174,7 @@ ret_code_t nrf_queue_push(nrf_queue_t const * p_queue, void const * p_element) if (is_full) { // Overwrite the oldest element. + NRF_LOG_INST_WARNING(p_queue->p_log, "Queue full. Overwriting oldest element."); p_queue->p_cb->front = nrf_queue_next_idx(p_queue, p_queue->p_cb->front); } @@ -138,6 +218,7 @@ ret_code_t nrf_queue_push(nrf_queue_t const * p_queue, void const * p_element) CRITICAL_REGION_EXIT(); + NRF_LOG_INST_DEBUG(p_queue->p_log, "pushed element 0x%08X, status:%d", p_element, status); return status; } @@ -195,10 +276,30 @@ ret_code_t nrf_queue_generic_pop(nrf_queue_t const * p_queue, } CRITICAL_REGION_EXIT(); - + NRF_LOG_INST_DEBUG(p_queue->p_log, "%s element 0x%08X, status:%d", + just_peek ? "peeked" : "popped", p_element, status); return status; } +/* Purpose of this function is to provide number of continous bytes in the queue's + * array before circullar buffer needs to wrapp. + */ +static size_t continous_items_get(nrf_queue_t const * p_queue, bool write) +{ + size_t front = p_queue->p_cb->front; + size_t back = p_queue->p_cb->back; + + /* Number of continous items for queue write operation */ + if (write) + { + return (back >= front) ? circullar_buffer_size_get(p_queue) - back : front - back; + } + else + { + return (back >= front) ? back - front : circullar_buffer_size_get(p_queue) - front; + } +} + /**@brief Write elements to the queue. This function assumes that there is enough room in the queue * to write the requested number of elements and that this process will not be interrupted. * @@ -209,9 +310,10 @@ ret_code_t nrf_queue_generic_pop(nrf_queue_t const * p_queue, static void queue_write(nrf_queue_t const * p_queue, void const * p_data, uint32_t element_count) { size_t prev_available = nrf_queue_available_get(p_queue); - size_t continuous = p_queue->size + 1 - p_queue->p_cb->back; + size_t continuous = continous_items_get(p_queue, true); void * p_write_ptr = (void *)((size_t)p_queue->p_buffer + p_queue->p_cb->back * p_queue->element_size); + if (element_count <= continuous) { memcpy(p_write_ptr, @@ -279,6 +381,8 @@ ret_code_t nrf_queue_write(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); + NRF_LOG_INST_DEBUG(p_queue->p_log, "Write %d elements (start address: 0x%08X), status:%d", + element_count, p_data, status); return status; } @@ -290,6 +394,8 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue, ASSERT(p_queue != NULL); ASSERT(p_data != NULL); + size_t req_element_count = element_count; + if (element_count == 0) { return 0; @@ -311,6 +417,9 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); + NRF_LOG_INST_DEBUG(p_queue->p_log, "Put in %d elements (start address: 0x%08X), requested :%d", + element_count, p_data, req_element_count); + return element_count; } @@ -324,8 +433,7 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue, static void queue_read(nrf_queue_t const * p_queue, void * p_data, uint32_t element_count) { size_t front = p_queue->p_cb->front; - size_t back = p_queue->p_cb->back; - size_t continuous = (front <= back) ? (back - front) : (p_queue->size + 1 - front); + size_t continuous = continous_items_get(p_queue, false); void const * p_read_ptr = (void const *)((size_t)p_queue->p_buffer + front * p_queue->element_size); @@ -382,6 +490,8 @@ ret_code_t nrf_queue_read(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); + NRF_LOG_INST_DEBUG(p_queue->p_log, "Read %d elements (start address: 0x%08X), status :%d", + element_count, p_data, status); return status; } @@ -392,6 +502,8 @@ size_t nrf_queue_out(nrf_queue_t const * p_queue, ASSERT(p_queue != NULL); ASSERT(p_data != NULL); + size_t req_element_count = element_count; + if (element_count == 0) { return 0; @@ -406,6 +518,8 @@ size_t nrf_queue_out(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); + NRF_LOG_INST_DEBUG(p_queue->p_log, "Out %d elements (start address: 0x%08X), requested :%d", + element_count, p_data, req_element_count); return element_count; } @@ -418,6 +532,8 @@ void nrf_queue_reset(nrf_queue_t const * p_queue) memset(p_queue->p_cb, 0, sizeof(nrf_queue_cb_t)); CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "Reset"); } size_t nrf_queue_utilization_get(nrf_queue_t const * p_queue) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/queue/nrf_queue.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/queue/nrf_queue.h similarity index 82% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/queue/nrf_queue.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/queue/nrf_queue.h index c5884f8..7e772c0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/queue/nrf_queue.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/queue/nrf_queue.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** * @defgroup nrf_queue Queue module @@ -54,11 +54,17 @@ #include "sdk_errors.h" #include "app_util.h" #include "app_util_platform.h" +#include "nrf_log_instance.h" +#include "nrf_section.h" #ifdef __cplusplus extern "C" { #endif +/** @brief Name of the module used for logger messaging. + */ +#define NRF_QUEUE_LOG_NAME queue + /**@brief Queue control block. */ typedef struct { @@ -77,13 +83,22 @@ typedef enum /**@brief Instance of the queue. */ typedef struct { - nrf_queue_cb_t * p_cb; //!< Pointer to the instance control block. - void * p_buffer; //!< Pointer to the memory that is used as storage. - size_t size; //!< Size of the queue. - size_t element_size; //!< Size of one element. - nrf_queue_mode_t mode; //!< Mode of the queue. + nrf_queue_cb_t * p_cb; //!< Pointer to the instance control block. + void * p_buffer; //!< Pointer to the memory that is used as storage. + size_t size; //!< Size of the queue. + size_t element_size; //!< Size of one element. + nrf_queue_mode_t mode; //!< Mode of the queue. +#if NRF_QUEUE_CLI_CMDS + const char * p_name; //!< Pointer to string with queue name. +#endif + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). } nrf_queue_t; +#if NRF_QUEUE_CLI_CMDS +#define __NRF_QUEUE_ASSIGN_POOL_NAME(_name) .p_name = STRINGIFY(_name), +#else +#define __NRF_QUEUE_ASSIGN_POOL_NAME(_name) +#endif /**@brief Create a queue instance. * * @note This macro reserves memory for the given queue instance. @@ -93,18 +108,68 @@ typedef struct * @param[in] _size Size of the queue. * @param[in] _mode Mode of the queue. */ -#define NRF_QUEUE_DEF(_type, _name, _size, _mode) \ - static _type CONCAT_2(_name, _nrf_queue_buffer[(_size) + 1]); \ - static nrf_queue_cb_t CONCAT_2(_name, _nrf_queue_cb); \ - static const nrf_queue_t _name = \ - { \ - .p_cb = &CONCAT_2(_name, _nrf_queue_cb), \ - .p_buffer = CONCAT_2(_name,_nrf_queue_buffer), \ - .size = (_size), \ - .element_size = sizeof(_type), \ - .mode = _mode, \ +#define NRF_QUEUE_DEF(_type, _name, _size, _mode) \ + static _type CONCAT_2(_name, _nrf_queue_buffer[(_size) + 1]); \ + static nrf_queue_cb_t CONCAT_2(_name, _nrf_queue_cb); \ + NRF_LOG_INSTANCE_REGISTER(NRF_QUEUE_LOG_NAME, _name, \ + NRF_QUEUE_CONFIG_INFO_COLOR, \ + NRF_QUEUE_CONFIG_DEBUG_COLOR, \ + NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL, \ + NRF_QUEUE_CONFIG_LOG_ENABLED ? \ + NRF_QUEUE_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + NRF_SECTION_ITEM_REGISTER(nrf_queue, const nrf_queue_t _name) = \ + { \ + .p_cb = &CONCAT_2(_name, _nrf_queue_cb), \ + .p_buffer = CONCAT_2(_name,_nrf_queue_buffer), \ + .size = (_size), \ + .element_size = sizeof(_type), \ + .mode = _mode, \ + __NRF_QUEUE_ASSIGN_POOL_NAME(_name) \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_QUEUE_LOG_NAME, _name) \ } +#if !(defined(__LINT__)) +/**@brief Create multiple queue instances. + * + * @note This macro reserves memory for array of queue instances. + * + * @param[in] _type Type which is stored. + * @param[in] _name Name of the array with queue instances. + * @param[in] _size Size of single queue instance. + * @param[in] _mode Mode of single queue instance. + * @param[in] _num Number of queue instances within array. + */ +#define NRF_QUEUE_ARRAY_DEF(_type, _name, _size, _mode, _num) \ + MACRO_REPEAT_FOR(_num, NRF_QUEUE_ARRAY_INSTANCE_ELEMS_DEC, _type, _name, _size, _mode) \ + static const nrf_queue_t _name[] = \ + { \ + MACRO_REPEAT_FOR(_num, NRF_QUEUE_ARRAY_INSTANCE_INIT, _type, _name, _size, _mode) \ + }; \ + STATIC_ASSERT(ARRAY_SIZE(_name) == _num) +#else +#define NRF_QUEUE_ARRAY_DEF(_type, _name, _size, _mode, _num) \ + static const nrf_queue_t _name[_num]; +#endif // !(defined(__LINT__)) + +/**@brief Helping macro used to declare elements for nrf_queue_t instance. + * Used in @ref NRF_QUEUE_ARRAY_DEF. + */ +#define NRF_QUEUE_ARRAY_INSTANCE_ELEMS_DEC(_num, _type, _name, _size, _mode) \ + static _type CONCAT_3(_name, _num, _nrf_queue_buffer[(_size) + 1]); \ + static nrf_queue_cb_t CONCAT_3(_name, _num, _nrf_queue_cb); + +/**@brief Helping macro used to initialize nrf_queue_t instance in an array fashion. + * Used in @ref NRF_QUEUE_ARRAY_DEF. + */ +#define NRF_QUEUE_ARRAY_INSTANCE_INIT(_num, _type, _name, _size, _mode) \ + { \ + .p_cb = &CONCAT_3(_name, _num, _nrf_queue_cb), \ + .p_buffer = CONCAT_3(_name, _num, _nrf_queue_buffer), \ + .size = (_size), \ + .element_size = sizeof(_type), \ + .mode = _mode, \ + }, + /**@brief Declare a queue interface. * * @param[in] _type Type which is stored. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf/nrf_ringbuf.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf/nrf_ringbuf.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf/nrf_ringbuf.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf/nrf_ringbuf.c index 28696f0..c080ebe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf/nrf_ringbuf.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf/nrf_ringbuf.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_ringbuf.h" #include "app_util_platform.h" @@ -80,9 +80,8 @@ ret_code_t nrf_ringbuf_alloc(nrf_ringbuf_t const * p_ringbuf, uint8_t * * pp_dat uint32_t wr_idx = p_ringbuf->p_cb->tmp_wr_idx & p_ringbuf->bufsize_mask; uint32_t rd_idx = p_ringbuf->p_cb->rd_idx & p_ringbuf->bufsize_mask; uint32_t available = (wr_idx >= rd_idx) ? p_ringbuf->bufsize_mask + 1 - wr_idx : - p_ringbuf->p_cb->rd_idx - p_ringbuf->p_cb->tmp_wr_idx; + p_ringbuf->p_cb->rd_idx - (p_ringbuf->p_cb->tmp_wr_idx - (p_ringbuf->bufsize_mask + 1)); *p_length = *p_length < available ? *p_length : available; - *pp_data = &p_ringbuf->p_buffer[wr_idx]; p_ringbuf->p_cb->tmp_wr_idx += *p_length; @@ -209,7 +208,7 @@ ret_code_t nrf_ringbuf_cpy_get(nrf_ringbuf_t const * p_ringbuf, if (length > trail) { - memcpy(&p_ringbuf->p_buffer[masked_rd_idx], p_data, trail); + memcpy(p_data, &p_ringbuf->p_buffer[masked_rd_idx], trail); length -= trail; masked_rd_idx = 0; p_data += trail; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf/nrf_ringbuf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf/nrf_ringbuf.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf/nrf_ringbuf.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf/nrf_ringbuf.h index 4664a46..42bd1c9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_ringbuf/nrf_ringbuf.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/ringbuf/nrf_ringbuf.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_RINGBUF_H #define NRF_RINGBUF_H @@ -44,7 +44,7 @@ * @defgroup nrf_ringbuf Ring buffer * @{ * @ingroup app_common -* @brief Functions for controlling ring buffer. +* @brief Functions for controlling the ring buffer. */ #include @@ -55,7 +55,7 @@ extern "C" { #endif /** - * @brief ring buffer instance control block. + * @brief Ring buffer instance control block. * */ typedef struct { @@ -68,20 +68,20 @@ typedef struct } nrf_ringbuf_cb_t; /** - * @brief ring buffer instance structure. + * @brief Ring buffer instance structure. * */ typedef struct { - uint8_t * p_buffer; //!< Pointer to memory used by the ring buffer. - uint32_t bufsize_mask; //!< Buffer size mask (buffer size must be power of 2). - nrf_ringbuf_cb_t * p_cb; //!< Pointer to instance control block. + uint8_t * p_buffer; //!< Pointer to the memory used by the ring buffer. + uint32_t bufsize_mask; //!< Buffer size mask (buffer size must be a power of 2). + nrf_ringbuf_cb_t * p_cb; //!< Pointer to the instance control block. } nrf_ringbuf_t; /** * @brief Macro for defining a ring buffer instance. * * @param _name Instance name. - * @param _size Size of ring buffer (must be power of 2). + * @param _size Size of the ring buffer (must be a power of 2). * */ #define NRF_RINGBUF_DEF(_name, _size) \ STATIC_ASSERT(IS_POWER_OF_TWO(_size)); \ @@ -94,9 +94,9 @@ typedef struct } /** - * @brief Initializes a ring buffer instance. + * @brief Function for initializing a ring buffer instance. * - * @param p_ringbuf Pointer to Ring buffer instance. + * @param p_ringbuf Pointer to the ring buffer instance. * * */ void nrf_ringbuf_init(nrf_ringbuf_t const * p_ringbuf); @@ -104,14 +104,14 @@ void nrf_ringbuf_init(nrf_ringbuf_t const * p_ringbuf); /** * @brief Function for allocating memory from a ring buffer. * - * Function attempts to allocate amount of memory requested by the user, or smaller amount if - * requested amount is not available. If start flag is set then exclusive access to allocation - * is established. @ref nrf_ringbuf_put frees access to allocation. If start flag is not set then + * This function attempts to allocate the amount of memory requested by the user, or a smaller amount if + * the requested amount is not available. If a start flag is set, then exclusive access to allocation + * is established. @ref nrf_ringbuf_put frees access to allocation. If a start flag is not set, then * exclusive access check is omitted. * - * @param[in] p_ringbuf Pointer to Ring buffer instance. - * @param[in] pp_data Pointer to pointer to the allocated buffer. - * @param[in, out] p_length Pointer to length. Length is set to requested amount and filled + * @param[in] p_ringbuf Pointer to the ring buffer instance. + * @param[in] pp_data Pointer to the pointer to the allocated buffer. + * @param[in, out] p_length Pointer to length. Length is set to the requested amount and filled * by the function with actually allocated amount. * @param[in] start Set to true if exclusive access should be controlled. * @@ -124,11 +124,11 @@ ret_code_t nrf_ringbuf_alloc(nrf_ringbuf_t const * p_ringbuf, uint8_t * * pp_dat /** * @brief Function for commiting data to a ring buffer. * - * When allocated buffer (see @ref nrf_ringbuf_alloc) has been filled with data it must be committed + * When an allocated buffer (see @ref nrf_ringbuf_alloc) has been filled with data, it must be committed * to make it available for @ref nrf_ringbuf_get and @ref nrf_ringbuf_cpy_get. This function commits * the data (can be smaller amount than allocated). * - * @param[in] p_ringbuf Pointer to Ring buffer instance. + * @param[in] p_ringbuf Pointer to the ring buffer instance. * @param[in] length Amount of bytes to put. * @return NRF_SUCCESS on successful put or error. @@ -138,9 +138,9 @@ ret_code_t nrf_ringbuf_put(nrf_ringbuf_t const * p_ringbuf, size_t length); /** * @brief Function for copying data directly into the ring buffer. * - * This function is copying user buffer to the ring buffer. + * This function copies a user buffer to the ring buffer. * - * @param[in] p_ringbuf Pointer to Ring buffer instance. + * @param[in] p_ringbuf Pointer to the ring buffer instance. * @param[in] p_data Pointer to the input buffer. * @param[in, out] p_length Amount of bytes to copy. Amount of bytes copied. @@ -154,15 +154,15 @@ ret_code_t nrf_ringbuf_cpy_put(nrf_ringbuf_t const * p_ringbuf, /** * Function for getting data from the ring buffer. * - * Function attempts to get requested amount of data from the ring buffer. If start flag is set then + * This function attempts to get the requested amount of data from the ring buffer. If a start flag is set, then * exclusive access to getting data from the ring buffer is established. @ref nrf_ringbuf_free frees - * access to getting data from the ring buffer. If start flag is not set then + * access to getting data from the ring buffer. If a start flag is not set, then * exclusive access check is omitted. * - * @param[in] p_ringbuf Pointer to Ring buffer instance. - * @param[in] pp_data Pointer to pointer to the buffer with data. - * @param[in, out] p_length Pointer to length. Length is set to requested amount and filled - * by the function with actual amount. + * @param[in] p_ringbuf Pointer to the ring buffer instance. + * @param[in] pp_data Pointer to the pointer to the buffer with data. + * @param[in, out] p_length Pointer to length. Length is set to the requested amount and filled + * by the function with the actual amount. * @param[in] start Set to true if exclusive access should be controlled. * * @retval NRF_SUCCESS Successful getting (can be smaller amount than requested). @@ -171,13 +171,13 @@ ret_code_t nrf_ringbuf_cpy_put(nrf_ringbuf_t const * p_ringbuf, ret_code_t nrf_ringbuf_get(nrf_ringbuf_t const * p_ringbuf, uint8_t * * pp_data, size_t * p_length, bool start); /** - * @brief Function for freeing buffer back to a ring buffer. + * @brief Function for freeing a buffer back to the ring buffer. * - * When buffer with data taken from the ring buffer (see @ref nrf_ringbuf_get) has been processed it + * When a buffer with data taken from the ring buffer (see @ref nrf_ringbuf_get) has been processed, it * must be freed to make it available for further use. This function frees the buffer (can be smaller * amount than get). * - * @param[in] p_ringbuf Pointer to Ring buffer instance. + * @param[in] p_ringbuf Pointer to the ring buffer instance. * @param[in] length Amount of bytes to free. * @return NRF_SUCCESS on successful put or error. @@ -187,9 +187,9 @@ ret_code_t nrf_ringbuf_free(nrf_ringbuf_t const * p_ringbuf, size_t length); /** * @brief Function for copying data directly out of the ring buffer. * - * This function is copying available data from the ring buffer to user buffer. + * This function copies available data from the ring buffer to a user buffer. * - * @param[in] p_ringbuf Pointer to Ring buffer instance. + * @param[in] p_ringbuf Pointer to the ring buffer instance. * @param[in] p_data Pointer to the input buffer. * @param[in, out] p_length Amount of bytes to copy. Amount of bytes copied. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler.c index 30de2da..81ddafe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(APP_SCHEDULER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler.h index cce68d3..ad1dd77 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler_serconn.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler_serconn.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler_serconn.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler_serconn.c index 3f66b72..fa573b4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/scheduler/app_scheduler_serconn.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/scheduler/app_scheduler_serconn.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "app_scheduler.h" #include diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sdcard/app_sdcard.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sdcard/app_sdcard.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sdcard/app_sdcard.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sdcard/app_sdcard.c index 153f9f5..4b5fc91 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sdcard/app_sdcard.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sdcard/app_sdcard.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" #if APP_SDCARD_ENABLED @@ -247,10 +247,10 @@ __STATIC_INLINE void sdc_spi_transfer(uint8_t const * const p_txb, __STATIC_INLINE void sdc_spi_hispeed(void) { #ifdef SPI_PRESENT - nrf_spi_frequency_set((NRF_SPI_Type *)m_spi.p_registers, + nrf_spi_frequency_set(m_spi.u.spi.p_reg, (nrf_spi_frequency_t) APP_SDCARD_FREQ_DATA); #else - nrf_spim_frequency_set((NRF_SPIM_Type *)m_spi.p_registers, + nrf_spim_frequency_set(m_spi.u.spim.p_reg, (nrf_spi_frequency_t) APP_SDCARD_FREQ_DATA); #endif } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sdcard/app_sdcard.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sdcard/app_sdcard.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sdcard/app_sdcard.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sdcard/app_sdcard.h index ed8fbf4..ccdfb94 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sdcard/app_sdcard.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sdcard/app_sdcard.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sensorsim/sensorsim.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sensorsim/sensorsim.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sensorsim/sensorsim.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sensorsim/sensorsim.c index be331cb..56c1215 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sensorsim/sensorsim.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sensorsim/sensorsim.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "sensorsim.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sensorsim/sensorsim.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sensorsim/sensorsim.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sensorsim/sensorsim.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sensorsim/sensorsim.h index 3f87160..7245573 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sensorsim/sensorsim.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sensorsim/sensorsim.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/serial/nrf_serial.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/serial/nrf_serial.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/serial/nrf_serial.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/serial/nrf_serial.c index ea303ff..ce8d9e9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/serial/nrf_serial.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/serial/nrf_serial.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,12 +35,11 @@ * 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(NRF_SERIAL) #include "nrf_serial.h" -#include "nrf_drv_common.h" #if defined (UART_PRESENT) @@ -146,7 +145,10 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) break; } - event_handler(p_serial, NRF_SERIAL_EVENT_RX_DATA); + if (p_event->data.rxtx.bytes) + { + event_handler(p_serial, NRF_SERIAL_EVENT_RX_DATA); + } nrf_serial_buffers_t const * p_buffs = p_serial->p_ctx->p_config->p_buffers; @@ -205,7 +207,7 @@ ret_code_t nrf_serial_init(nrf_serial_t const * p_serial, nrf_drv_uart_config_t drv_config; memcpy(&drv_config, p_drv_uart_config, sizeof(nrf_drv_uart_config_t)); drv_config.p_context = (void *)p_serial; -#ifdef UARTE_PRESENT +#if defined(UARTE_PRESENT) && defined(UART_PRESENT) drv_config.use_easy_dma = (p_config->mode == NRF_SERIAL_MODE_DMA); #endif ret = nrf_drv_uart_init(&p_serial->instance, @@ -263,7 +265,7 @@ ret_code_t nrf_serial_uninit(nrf_serial_t const * p_serial) if (!p_serial->p_ctx->p_config) { /*Already uninitialized.*/ - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } if (!nrf_mtx_trylock(&p_serial->p_ctx->write_lock)) @@ -333,7 +335,7 @@ ret_code_t nrf_serial_write(nrf_serial_t const * p_serial, ASSERT(p_serial); if (!p_serial->p_ctx->p_config) { - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } if (!(p_serial->p_ctx->flags & NRF_SERIAL_TX_ENABLED_FLAG)) @@ -346,7 +348,7 @@ ret_code_t nrf_serial_write(nrf_serial_t const * p_serial, return NRF_SUCCESS; } - if (!nrf_drv_is_in_RAM(p_data) && + if (!nrfx_is_in_ram(p_data) && p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_DMA) { return NRF_ERROR_INVALID_ADDR; @@ -420,7 +422,7 @@ ret_code_t nrf_serial_read(nrf_serial_t const * p_serial, ASSERT(p_serial); if (!p_serial->p_ctx->p_config) { - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } if (!(p_serial->p_ctx->flags & NRF_SERIAL_RX_ENABLED_FLAG)) @@ -507,7 +509,7 @@ ret_code_t nrf_serial_flush(nrf_serial_t const * p_serial, uint32_t timeout_ms) ASSERT(p_serial); if (!p_serial->p_ctx->p_config) { - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } if (!(p_serial->p_ctx->flags & NRF_SERIAL_TX_ENABLED_FLAG)) @@ -574,7 +576,7 @@ ret_code_t nrf_serial_tx_abort(nrf_serial_t const * p_serial) ASSERT(p_serial); if (!p_serial->p_ctx->p_config) { - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } if (!(p_serial->p_ctx->flags & NRF_SERIAL_TX_ENABLED_FLAG)) @@ -602,7 +604,7 @@ ret_code_t nrf_serial_rx_drain(nrf_serial_t const * p_serial) ASSERT(p_serial); if (!p_serial->p_ctx->p_config) { - return NRF_ERROR_MODULE_NOT_INITIALZED; + return NRF_ERROR_MODULE_NOT_INITIALIZED; } if (!(p_serial->p_ctx->flags & NRF_SERIAL_RX_ENABLED_FLAG)) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/serial/nrf_serial.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/serial/nrf_serial.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/serial/nrf_serial.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/serial/nrf_serial.h index 260e8df..193d403 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/serial/nrf_serial.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/serial/nrf_serial.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SERIAL_H__ #define NRF_SERIAL_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sha256/sha256.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sha256/sha256.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sha256/sha256.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sha256/sha256.c index b04ad4e..18a2814 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sha256/sha256.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sha256/sha256.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 #include "sha256.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sha256/sha256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sha256/sha256.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sha256/sha256.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sha256/sha256.h index da18891..8bc4c54 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sha256/sha256.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sha256/sha256.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/simple_timer/app_simple_timer.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/simple_timer/app_simple_timer.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/simple_timer/app_simple_timer.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/simple_timer/app_simple_timer.c index 69d845f..9ab1eb0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/simple_timer/app_simple_timer.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/simple_timer/app_simple_timer.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(SIMPLE_TIMER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/simple_timer/app_simple_timer.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/simple_timer/app_simple_timer.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/simple_timer/app_simple_timer.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/simple_timer/app_simple_timer.h index cfc8d8e..de13935 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/simple_timer/app_simple_timer.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/simple_timer/app_simple_timer.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/slip/slip.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/slip/slip.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/slip/slip.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/slip/slip.c index c55e8d7..6c75746 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/slip/slip.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/slip/slip.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(SLIP) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/slip/slip.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/slip/slip.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/slip/slip.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/slip/slip.h index cfe805e..819ebea 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/slip/slip.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/slip/slip.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SLIP_H__ #define SLIP_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sortlist/nrf_sortlist.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sortlist/nrf_sortlist.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sortlist/nrf_sortlist.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sortlist/nrf_sortlist.c index 56b44dd..72edcf5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sortlist/nrf_sortlist.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sortlist/nrf_sortlist.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_SORTLIST) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sortlist/nrf_sortlist.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sortlist/nrf_sortlist.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sortlist/nrf_sortlist.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sortlist/nrf_sortlist.h index 25286a8..69a5920 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/sortlist/nrf_sortlist.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/sortlist/nrf_sortlist.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SORTLIST_H #define NRF_SORTLIST_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/spi_mngr/nrf_spi_mngr.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/spi_mngr/nrf_spi_mngr.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/spi_mngr/nrf_spi_mngr.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/spi_mngr/nrf_spi_mngr.c index c5b898a..136b9d9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/spi_mngr/nrf_spi_mngr.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/spi_mngr/nrf_spi_mngr.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -44,6 +44,11 @@ #include "nrf_assert.h" #include "app_util_platform.h" +typedef volatile struct +{ + bool transaction_in_progress; + uint8_t transaction_result; +} nrf_spi_mngr_cb_data_t; static ret_code_t start_transfer(nrf_spi_mngr_t const * p_nrf_spi_mngr) { @@ -132,52 +137,49 @@ static void start_pending_transaction(nrf_spi_mngr_t const * p_nrf_spi_mngr, { return; } + + nrf_drv_spi_config_t const * p_instance_cfg; + if (p_cb->p_current_transaction->p_required_spi_cfg == NULL) + { + p_instance_cfg = &p_cb->default_configuration; + } else { - ret_code_t result; + p_instance_cfg = p_cb->p_current_transaction->p_required_spi_cfg; + } - nrf_drv_spi_config_t const * p_instance_cfg; - if (p_cb->p_current_transaction->p_required_spi_cfg == NULL) - { - p_instance_cfg = &p_cb->default_configuration ; - } - else - { - p_instance_cfg = p_cb->p_current_transaction->p_required_spi_cfg; - } + ret_code_t result; - if (memcmp(p_cb->p_current_configuration, p_instance_cfg, sizeof(*p_instance_cfg)) != 0) - { - ret_code_t err_code; - nrf_drv_spi_uninit(&p_nrf_spi_mngr->spi); - err_code = nrf_drv_spi_init(&p_nrf_spi_mngr->spi, - p_instance_cfg, - spi_event_handler, - (void *)p_nrf_spi_mngr); - ASSERT(err_code == NRF_SUCCESS); - p_cb->p_current_configuration = p_instance_cfg; - } + if (memcmp(p_cb->p_current_configuration, p_instance_cfg, sizeof(*p_instance_cfg)) != 0) + { + nrf_drv_spi_uninit(&p_nrf_spi_mngr->spi); + result = nrf_drv_spi_init(&p_nrf_spi_mngr->spi, + p_instance_cfg, + spi_event_handler, + (void *)p_nrf_spi_mngr); + ASSERT(result == NRF_SUCCESS); + p_cb->p_current_configuration = p_instance_cfg; + } - // Try to start first transfer for this new transaction. - p_cb->current_transfer_idx = 0; + // Try to start first transfer for this new transaction. + p_cb->current_transfer_idx = 0; - // Execute user code if available before starting transaction - transaction_begin_signal(p_nrf_spi_mngr); - result = start_transfer(p_nrf_spi_mngr); + // Execute user code if available before starting transaction + transaction_begin_signal(p_nrf_spi_mngr); + result = start_transfer(p_nrf_spi_mngr); - // If transaction started successfully there is nothing more to do here now. - if (result == NRF_SUCCESS) - { - return; - } + // If transaction started successfully there is nothing more to do here now. + if (result == NRF_SUCCESS) + { + return; + } - // Transfer failed to start - notify user that this transaction - // cannot be started and try with next one (in next iteration of - // the loop). - transaction_end_signal(p_nrf_spi_mngr, result); + // Transfer failed to start - notify user that this transaction + // cannot be started and try with next one (in next iteration of + // the loop). + transaction_end_signal(p_nrf_spi_mngr, result); - switch_transaction = true; - } + switch_transaction = true; } } @@ -256,7 +258,6 @@ ret_code_t nrf_spi_mngr_init(nrf_spi_mngr_t const * p_nrf_spi_mngr, { nrf_spi_mngr_cb_t * p_cb = p_nrf_spi_mngr->p_nrf_spi_mngr_cb; - p_cb->internal_transaction_in_progress = false; p_cb->p_current_transaction = NULL; p_cb->default_configuration = *p_default_spi_config; p_cb->p_current_configuration = &p_cb->default_configuration; @@ -298,62 +299,49 @@ ret_code_t nrf_spi_mngr_schedule(nrf_spi_mngr_t const * p_nrf_spi_mn static void spi_internal_transaction_cb(ret_code_t result, void * p_user_data) { - nrf_spi_mngr_cb_t * p_cb = ((nrf_spi_mngr_t const *)p_user_data)->p_nrf_spi_mngr_cb; + nrf_spi_mngr_cb_data_t * p_cb_data = (nrf_spi_mngr_cb_data_t *)p_user_data; - p_cb->internal_transaction_result = result; - p_cb->internal_transaction_in_progress = false; + p_cb_data->transaction_result = result; + p_cb_data->transaction_in_progress = false; } ret_code_t nrf_spi_mngr_perform(nrf_spi_mngr_t const * p_nrf_spi_mngr, + nrf_drv_spi_config_t const * p_config, nrf_spi_mngr_transfer_t const * p_transfers, uint8_t number_of_transfers, - void (* user_function)(void)) + void (* user_function)(void)) { ASSERT(p_nrf_spi_mngr != NULL); ASSERT(p_transfers != NULL); ASSERT(number_of_transfers != 0); - ret_code_t err_code = NRF_SUCCESS; - nrf_spi_mngr_cb_t * p_cb = p_nrf_spi_mngr->p_nrf_spi_mngr_cb; - - CRITICAL_REGION_ENTER(); - if (p_cb->internal_transaction_in_progress) - { - err_code = NRF_ERROR_BUSY; - } - else + nrf_spi_mngr_cb_data_t cb_data = { - p_cb->internal_transaction_in_progress = true; - } - CRITICAL_REGION_EXIT(); + .transaction_in_progress = true + }; - if (err_code != NRF_ERROR_BUSY) + nrf_spi_mngr_transaction_t internal_transaction = { - nrf_spi_mngr_transaction_t internal_transaction = - { - .begin_callback = NULL, - .end_callback = spi_internal_transaction_cb, - .p_user_data = (void *)p_nrf_spi_mngr, - .p_transfers = p_transfers, - .number_of_transfers = number_of_transfers, - }; - - err_code = nrf_spi_mngr_schedule(p_nrf_spi_mngr, &internal_transaction); - - if (err_code == NRF_SUCCESS) + .begin_callback = NULL, + .end_callback = spi_internal_transaction_cb, + .p_user_data = (void *)&cb_data, + .p_transfers = p_transfers, + .number_of_transfers = number_of_transfers, + .p_required_spi_cfg = p_config + }; + + ret_code_t result = nrf_spi_mngr_schedule(p_nrf_spi_mngr, &internal_transaction); + VERIFY_SUCCESS(result); + + while (cb_data.transaction_in_progress) + { + if (user_function) { - while (p_cb->internal_transaction_in_progress) - { - if (user_function) - { - user_function(); - } - } - err_code = p_cb->internal_transaction_result; + user_function(); } } - return err_code; + return cb_data.transaction_result; } #endif //NRF_MODULE_ENABLED(NRF_SPI_MNGR) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/spi_mngr/nrf_spi_mngr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/spi_mngr/nrf_spi_mngr.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/spi_mngr/nrf_spi_mngr.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/spi_mngr/nrf_spi_mngr.h index 9728fd3..be70b7d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/spi_mngr/nrf_spi_mngr.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/spi_mngr/nrf_spi_mngr.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SPI_MNGR_H__ #define NRF_SPI_MNGR_H__ @@ -159,12 +159,6 @@ typedef struct uint8_t volatile current_transfer_idx; ///< Index of currently performed transfer (within current transaction). - - bool volatile internal_transaction_in_progress; - ///< Informs that an internal transaction is being performed (by nrf_spi_mngr_perform()). - - uint8_t volatile internal_transaction_result; - ///< Used to pass the result of the internal transaction realized by nrf_spi_mngr_perform(). } nrf_spi_mngr_cb_t; @@ -271,6 +265,7 @@ ret_code_t nrf_spi_mngr_schedule(nrf_spi_mngr_t const * p_nrf_spi_mn * and waits until it is finished. * * @param[in] p_nrf_spi_mngr Pointer to the SPI transaction manager instance. + * @param[in] p_config Required SPI configuration. * @param[in] p_transfers Pointer to an array of transfers to be performed. * @param number_of_transfers Number of transfers to be performed. * @param user_function User-specified function to be called while @@ -283,9 +278,10 @@ ret_code_t nrf_spi_mngr_schedule(nrf_spi_mngr_t const * p_nrf_spi_mn * with the error reported by @ref nrf_drv_spi_transfer(). */ ret_code_t nrf_spi_mngr_perform(nrf_spi_mngr_t const * p_nrf_spi_mngr, + nrf_drv_spi_config_t const * p_config, nrf_spi_mngr_transfer_t const * p_transfers, uint8_t number_of_transfers, - void (* user_function)(void)); + void (* user_function)(void)); /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard/nrf_stack_guard.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard/nrf_stack_guard.c similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard/nrf_stack_guard.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard/nrf_stack_guard.c index 4ec7b54..b880ae4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard/nrf_stack_guard.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard/nrf_stack_guard.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,14 +35,14 @@ * 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 #include "nrf.h" #include "nrf_assert.h" #include "nrf_strerror.h" -#include "nrf_mpu.h" +#include "nrf_mpu_lib.h" #include "nrf_stack_guard.h" #define NRF_LOG_MODULE_NAME stack_guard @@ -60,7 +60,7 @@ STATIC_ASSERT(STACK_GUARD_SIZE >= 32); ret_code_t nrf_stack_guard_init(void) { - nrf_mpu_region_t region; + nrf_mpu_lib_region_t region; uint32_t attributes; ret_code_t status; @@ -69,16 +69,18 @@ ret_code_t nrf_stack_guard_init(void) attributes = (0x05 << MPU_RASR_TEX_Pos) | (1 << MPU_RASR_B_Pos) | /* Normal memory, WBWA/WBWA */ (0x07 << MPU_RASR_AP_Pos) | (1 << MPU_RASR_XN_Pos); /* Access: RO/RO, XN */ - status = nrf_mpu_region_create(®ion, - (void *)(STACK_GUARD_BASE), - STACK_GUARD_SIZE, - attributes); + status = nrf_mpu_lib_region_create(®ion, + (void *)(STACK_GUARD_BASE), + STACK_GUARD_SIZE, + attributes); if (status == NRF_SUCCESS) { - NRF_LOG_INFO("Stack Guard: 0x%08X-0x%08X (usable stack area: %u bytes)", + NRF_LOG_INFO("Stack Guard (%u bytes): 0x%08X-0x%08X (total stack size: %u bytes, usable stack area: %u bytes)", + STACK_GUARD_SIZE, STACK_GUARD_BASE, STACK_GUARD_BASE + STACK_GUARD_SIZE - 1, + STACK_SIZE, REAL_STACK_SIZE); } else diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard/nrf_stack_guard.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard/nrf_stack_guard.h similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard/nrf_stack_guard.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard/nrf_stack_guard.h index 18ccdfc..5d2d8b5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/experimental_stack_guard/nrf_stack_guard.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_guard/nrf_stack_guard.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 __NRF_STACK_GUARD_H__ @@ -45,7 +45,7 @@ * @defgroup nrf_stack_guard Stack guard * @{ * @ingroup app_common -* @brief Functions for enabling stack violation control +* @brief Functions for enabling stack violation control. */ #include "sdk_config.h" #include "app_util.h" @@ -54,16 +54,20 @@ extern "C" { #endif +#define STACK_SIZE (((int32_t)(STACK_TOP)) - (int32_t)((void *)(STACK_BASE))) #if NRF_STACK_GUARD_ENABLED #define STACK_GUARD_SIZE (1ul << NRF_STACK_GUARD_CONFIG_SIZE) #define STACK_GUARD_BASE (((uint32_t)((void *)(STACK_BASE)) + STACK_GUARD_SIZE - 1) \ & ~(STACK_GUARD_SIZE - 1)) -#define REAL_STACK_SIZE (((int32_t)(STACK_TOP)) - (int32_t)(STACK_GUARD_BASE + STACK_GUARD_SIZE)) +#define REAL_STACK_SIZE (STACK_SIZE - STACK_GUARD_SIZE) #else /* !NRF_STACK_GUARD_ENABLED */ -#define REAL_STACK_SIZE (((int32_t)(STACK_TOP)) - (int32_t)((void *)(STACK_BASE))) +#define REAL_STACK_SIZE STACK_SIZE #endif /* NRF_STACK_GUARD_ENABLED */ -/**@brief Initialize Stack Guard Page */ +/**@brief Function for initializing the Stack Guard Page. + * + * @note When this module is enabled, the usable stack size is reduced by @ref NRF_STACK_GUARD_CONFIG_SIZE. + * */ ret_code_t nrf_stack_guard_init(void); #if NRF_STACK_GUARD_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_info/nrf_stack_info.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_info/nrf_stack_info.h new file mode 100644 index 0000000..8990ba6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/stack_info/nrf_stack_info.h @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2018 - 2019, 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 nrf_stack_info Stack info functions and definitions + * @{ + * @ingroup app_common + * + * @brief Functions and definitions used to obtain information about the state of the stack. + */ + +#ifndef NRF_STACK_INFO_H__ +#define NRF_STACK_INFO_H__ + +#include +#include +#include "compiler_abstraction.h" +#include "app_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Top (highest) stack address. + */ +#define NRF_STACK_INFO_TOP ((uint32_t)STACK_TOP) + + +/** + * @brief Base (lowest) stack address. + */ +#define NRF_STACK_INFO_BASE ((uint32_t)STACK_BASE) + + +/** + * @brief Function to get the current stack pointer value. + * + * @return Current stack pointer value. + */ +#define NRF_STACK_INFO_GET_SP() ((uint32_t)GET_SP()) + + +__STATIC_INLINE size_t nrf_stack_info_get_available(void); +__STATIC_INLINE size_t nrf_stack_info_get_depth(void); +__STATIC_INLINE bool nrf_stack_info_overflowed(void); +__STATIC_INLINE bool nrf_stack_info_is_on_stack(void const * const p_address); + + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +/** + * @brief Calculate the available (free) space on the stack. + * + * @return Number of available bytes on the stack. + */ + __STATIC_INLINE size_t nrf_stack_info_get_available(void) +{ + uint32_t sp = NRF_STACK_INFO_GET_SP(); + if (sp > NRF_STACK_INFO_BASE) + { + return (size_t)(sp - NRF_STACK_INFO_BASE); + } + + // Stack overflow + return 0; +} + + +/** + * @brief Calculate the current stack depth (occupied space). + * + * @return Current stack depth in bytes. + */ +__STATIC_INLINE size_t nrf_stack_info_get_depth(void) +{ + return (size_t)(NRF_STACK_INFO_TOP - NRF_STACK_INFO_GET_SP()); +} + + +/** + * @brief Function for checking if the stack is currently overflowed. + * + * @details This function checks if the stack is currently in an overflowed by comparing the stack + * pointer with the stack base address. Intended to be used to be used to ease debugging. + * + * @return true if stack is currently overflowed, false otherwise. + */ + __STATIC_INLINE bool nrf_stack_info_overflowed(void) + { + if (NRF_STACK_INFO_GET_SP() < NRF_STACK_INFO_BASE) + { + return true; + } + + return false; + } + + +/** + * @brief Function for checking if provided address is located in stack space. + * + * @param[in] p_address Address to be checked. + * + * @return true if address is in stack space, false otherwise. + */ +__STATIC_INLINE bool nrf_stack_info_is_on_stack(void const * const p_address) +{ + if (((uint32_t)p_address >= NRF_STACK_INFO_BASE) && ((uint32_t)p_address < NRF_STACK_INFO_TOP)) + { + return true; + } + + return false; +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +#ifdef __cplusplus +} +#endif + +#endif // NRF_STACK_INFO_H__ + +/**@} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/strerror/nrf_strerror.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/strerror/nrf_strerror.c similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/strerror/nrf_strerror.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/strerror/nrf_strerror.c index 09e3fb0..0cae508 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/strerror/nrf_strerror.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/strerror/nrf_strerror.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2011 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -93,9 +93,15 @@ static nrf_strerror_desc_t const nrf_strerror_array[] = NRF_STRERROR_ENTITY(NRF_ERROR_FORBIDDEN), NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_ADDR), NRF_STRERROR_ENTITY(NRF_ERROR_BUSY), +#ifdef NRF_ERROR_CONN_COUNT + NRF_STRERROR_ENTITY(NRF_ERROR_CONN_COUNT), +#endif +#ifdef NRF_ERROR_RESOURCES + NRF_STRERROR_ENTITY(NRF_ERROR_RESOURCES), +#endif /* SDK Common errors */ - NRF_STRERROR_ENTITY(NRF_ERROR_MODULE_NOT_INITIALZED), + NRF_STRERROR_ENTITY(NRF_ERROR_MODULE_NOT_INITIALIZED), NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_INIT_FAILED), NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_LOCK_FAILED), NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_UNLOCK_FAILED), @@ -104,11 +110,18 @@ static nrf_strerror_desc_t const nrf_strerror_array[] = NRF_STRERROR_ENTITY(NRF_ERROR_STORAGE_FULL), NRF_STRERROR_ENTITY(NRF_ERROR_API_NOT_IMPLEMENTED), NRF_STRERROR_ENTITY(NRF_ERROR_FEATURE_NOT_ENABLED), + NRF_STRERROR_ENTITY(NRF_ERROR_IO_PENDING), /* TWI error codes */ NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_OVERRUN), NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_ANACK), - NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_DNACK) + NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_DNACK), + + /* IPSP error codes */ + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_RX_PKT_TRUNCATED), + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_CHANNEL_ALREADY_EXISTS), + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_LINK_DISCONNECTED), + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_PEER_REJECTED) }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/strerror/nrf_strerror.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/strerror/nrf_strerror.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/strerror/nrf_strerror.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/strerror/nrf_strerror.h index f0de77d..e4807a9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/strerror/nrf_strerror.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/strerror/nrf_strerror.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svc_function.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svc_function.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svc_function.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svc_function.h index cf8643f..0443212 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svc_function.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svc_function.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svc_handler.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svc_handler.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svc_handler.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svc_handler.c index e0241d6..daaa8a7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svc_handler.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svc_handler.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,15 +35,13 @@ * 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 #include #include "nrf_svc_function.h" #include "nrf_error.h" -#include "nrf_log.h" - //lint -esym(526, svc_dataBase) -esym(526, svc_dataLimit) NRF_SECTION_DEF(svc_data, const nrf_svc_func_t); #define SVC_DATA_SECTION_ITEM_GET(i) NRF_SECTION_ITEM_GET(svc_data, nrf_svc_func_reg_t, (i)) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci.h index 742198d..fd2bed7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -64,7 +64,7 @@ extern "C" { #define NRF_SVCI_SVC_NUM_INVALID (0xFFFFFFFF) /**< Invalid SVCI number. */ #ifdef __cplusplus - #define GCC_CAST_CPP (uint8_t) + #define GCC_CAST_CPP (uint16_t) #else #define GCC_CAST_CPP #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci_async_function.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci_async_function.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci_async_function.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci_async_function.h index 1a7d816..3fd95d1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci_async_function.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci_async_function.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci_async_handler.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci_async_handler.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci_async_handler.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci_async_handler.h index 5c2ea4e..5e62147 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/svc/nrf_svci_async_handler.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/svc/nrf_svci_async_handler.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer.c index 826d192..053d1a6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,13 +35,14 @@ * 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(APP_TIMER) #include "app_timer.h" #include #include "nrf.h" +#include "nrf_peripherals.h" #include "nrf_soc.h" #include "app_error.h" #include "nrf_delay.h" @@ -64,16 +65,20 @@ STATIC_ASSERT(RTC1_IRQ_PRI == SWI_IRQ_PRI); #define MAX_RTC_TASKS_DELAY 47 /**< Maximum delay until an RTC task is executed. */ -#if (APP_TIMER_CONFIG_SWI_NUMBER == 0) -#define SWI_IRQn SWI0_IRQn -#define SWI_IRQHandler SWI0_IRQHandler -#elif (APP_TIMER_CONFIG_SWI_NUMBER == 1) -#define SWI_IRQn SWI1_IRQn -#define SWI_IRQHandler SWI1_IRQHandler -#else -#error "Unsupported SWI number." +#ifdef EGU_PRESENT +#define SWI_PART(_id) CONCAT_2(SWI,_id) +#define EGU_PART(_id) CONCAT_2(_EGU,_id) +#define SWI_IRQ_n(_id) CONCAT_3(SWI_PART(_id), EGU_PART(_id),_IRQn) +#define SWI_IRQ_Handler_n(_id) CONCAT_3(SWI_PART(_id), EGU_PART(_id),_IRQHandler) +#else //EGU_PRESENT +#define SWI_IRQ_n(_id) CONCAT_3(SWI,_id,_IRQn) +#define SWI_IRQ_Handler_n(_id) CONCAT_3(SWI,_id,_IRQHandler) #endif +#define SWI_IRQn SWI_IRQ_n(APP_TIMER_CONFIG_SWI_NUMBER) +#define SWI_IRQHandler SWI_IRQ_Handler_n(APP_TIMER_CONFIG_SWI_NUMBER) + + #define MODULE_INITIALIZED (m_op_queue.size != 0) /**< Macro designating whether the module has been initialized properly. */ /**@brief Timer node type. The nodes will be used form a linked list of running timers. */ @@ -992,7 +997,7 @@ ret_code_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void { return NRF_ERROR_INVALID_STATE; } - if (timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS) + if ((timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS) || (timeout_ticks > MAX_RTC_COUNTER_VAL)) { return NRF_ERROR_INVALID_PARAM; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer.h similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer.h index d856f95..6b0cc75 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -71,6 +71,10 @@ #include "app_util.h" #include "compiler_abstraction.h" #include "nordic_common.h" +#ifdef APP_TIMER_V2 +#include "nrf_log_instance.h" +#include "nrf_sortlist.h" +#endif #include #include #include @@ -79,6 +83,10 @@ extern "C" { #endif +/** @brief Name of the module used for logger messaging. + */ +#define APP_TIMER_LOG_NAME app_timer + #define APP_TIMER_CLOCK_FREQ 32768 /**< Clock frequency of the RTC timer used to implement the app timer module. */ #define APP_TIMER_MIN_TIMEOUT_TICKS 5 /**< Minimum value of the timeout_ticks parameter of app_timer_start(). */ @@ -90,6 +98,8 @@ extern "C" { #define APP_TIMER_SCHED_EVENT_DATA_SIZE sizeof(app_timer_event_t) /**< Size of event data when scheduler is used. */ +#define APP_TIMER_MAX_CNT_VAL RTC_COUNTER_COUNTER_Msk /**< Maximum counter value that can be returned by @ref app_timer_cnt_get. */ + /**@brief Convert milliseconds to timer ticks. * * This macro uses 64-bit integer arithmetic, but as long as the macro parameters are @@ -108,24 +118,63 @@ extern "C" { #include "FreeRTOSConfig.h" #define APP_TIMER_TICKS(MS) (uint32_t)ROUNDED_DIV((MS)*configTICK_RATE_HZ,1000) #endif -typedef struct app_timer_t { uint32_t data[CEIL_DIV(APP_TIMER_NODE_SIZE, sizeof(uint32_t))]; } app_timer_t; -/**@brief Timer ID type. - * Never declare a variable of this type, but use the macro @ref APP_TIMER_DEF instead.*/ -typedef app_timer_t * app_timer_id_t; /** * @brief Create a timer identifier and statically allocate memory for the timer. * * @param timer_id Name of the timer identifier variable that will be used to control the timer. */ -#define APP_TIMER_DEF(timer_id) \ +#define APP_TIMER_DEF(timer_id) _APP_TIMER_DEF(timer_id) + +/**@brief Application time-out handler type. */ +typedef void (*app_timer_timeout_handler_t)(void * p_context); + +#ifdef APP_TIMER_V2 +/** + * @brief app_timer control block + */ +typedef struct +{ + nrf_sortlist_item_t list_item; /**< Token used by sortlist. */ + uint64_t end_val; /**< RTC counter value when timer expires. */ + uint32_t repeat_period; /**< Repeat period (0 if single shot mode). */ + app_timer_timeout_handler_t handler; /**< User handler. */ + void * p_context; /**< User context. */ + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) /**< Pointer to instance of the logger object (Conditionally compiled). */ + volatile bool active; /**< Flag indicating that timer is active. */ +} app_timer_t; + +/**@brief Timer ID type. + * Never declare a variable of this type, but use the macro @ref APP_TIMER_DEF instead.*/ +typedef app_timer_t * app_timer_id_t; + +#define _APP_TIMER_DEF(timer_id) \ + NRF_LOG_INSTANCE_REGISTER(APP_TIMER_LOG_NAME, timer_id, \ + APP_TIMER_CONFIG_INFO_COLOR, \ + APP_TIMER_CONFIG_DEBUG_COLOR, \ + APP_TIMER_CONFIG_INITIAL_LOG_LEVEL, \ + APP_TIMER_CONFIG_LOG_ENABLED ? \ + APP_TIMER_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + static app_timer_t CONCAT_2(timer_id,_data) = { \ + .active = false, \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, APP_TIMER_LOG_NAME, timer_id) \ + }; \ + static const app_timer_id_t timer_id = &CONCAT_2(timer_id,_data) + +#else //APP_TIMER_V2 +typedef struct app_timer_t { uint32_t data[CEIL_DIV(APP_TIMER_NODE_SIZE, sizeof(uint32_t))]; } app_timer_t; + +/**@brief Timer ID type. + * Never declare a variable of this type, but use the macro @ref APP_TIMER_DEF instead.*/ +typedef app_timer_t * app_timer_id_t; + +#define _APP_TIMER_DEF(timer_id) \ static app_timer_t CONCAT_2(timer_id,_data) = { {0} }; \ static const app_timer_id_t timer_id = &CONCAT_2(timer_id,_data) +#endif -/**@brief Application time-out handler type. */ -typedef void (*app_timer_timeout_handler_t)(void * p_context); /**@brief Structure passed to app_scheduler. */ typedef struct diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer2.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer2.c new file mode 100644 index 0000000..a7c5a23 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer2.c @@ -0,0 +1,637 @@ +/** + * Copyright (c) 2018 - 2019, 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 "app_timer.h" +#include "nrf_atfifo.h" +#include "nrf_sortlist.h" +#include "nrf_delay.h" +#if APP_TIMER_WITH_PROFILER +#include "app_util_platform.h" +#endif +#if APP_TIMER_CONFIG_USE_SCHEDULER +#include "app_scheduler.h" +#endif +#include +#define NRF_LOG_MODULE_NAME APP_TIMER_LOG_NAME +#if APP_TIMER_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_TIMER_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_TIMER_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_TIMER_CONFIG_DEBUG_COLOR +#else //APP_TIMER_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //APP_TIMER_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#include "drv_rtc.h" + +/** + * Maximum possible relative value is limited by safe window to detect cases when requested + * compare event has already occured. + */ +#define APP_TIMER_SAFE_WINDOW APP_TIMER_TICKS(APP_TIMER_SAFE_WINDOW_MS) + +#define APP_TIMER_RTC_MAX_VALUE (DRV_RTC_MAX_CNT - APP_TIMER_SAFE_WINDOW) + +static drv_rtc_t m_rtc_inst = DRV_RTC_INSTANCE(1); + +#if APP_TIMER_WITH_PROFILER +static uint8_t m_max_user_op_queue_utilization; /**< Maximum observed timer user operations queue utilization. */ +static uint8_t m_current_user_op_queue_utilization; /**< Currently observed timer user operations queue utilization. */ +#endif /* APP_TIMER_WITH_PROFILER */ + +/** + * @brief Timer requests types. + */ +typedef enum +{ + TIMER_REQ_START, + TIMER_REQ_STOP, + TIMER_REQ_STOP_ALL +} app_timer_req_type_t; + +/** + * @brief Operation request structure. + */ +typedef struct +{ + app_timer_req_type_t type; /**< Request type. */ + app_timer_t * p_timer; /**< Timer instance. */ +} timer_req_t; + +static app_timer_t * volatile mp_active_timer; /**< Timer currently handled by RTC driver. */ +static bool m_global_active; /**< Flag used to globally disable all timers. */ +static uint64_t m_base_counter; +static uint64_t m_stamp64; + +/* Request FIFO instance. */ +NRF_ATFIFO_DEF(m_req_fifo, timer_req_t, APP_TIMER_CONFIG_OP_QUEUE_SIZE); + +/* Sortlist instance. */ +static bool compare_func(nrf_sortlist_item_t * p_item0, nrf_sortlist_item_t *p_item1); +NRF_SORTLIST_DEF(m_app_timer_sortlist, compare_func); /**< Sortlist used for storing queued timers. */ + +/** + * @brief Return current 64 bit timestamp + */ +static uint64_t get_now(void) +{ + uint64_t now = m_base_counter + drv_rtc_counter_get(&m_rtc_inst); + + /* it is possible that base was not updated and overflow occured, in that case 'now' will be + * 24bit value behind. Additional timestamp updated on every 24 bit period is used to detect + * that case. Apart from that 'now' should never be behind previously read timestamp. + */ + if (now < m_stamp64) { + now += (DRV_RTC_MAX_CNT + 1); + } + + return now; +} +/** + * @brief Function used for comparing items in sorted list. + */ +static inline bool compare_func(nrf_sortlist_item_t * p_item0, nrf_sortlist_item_t *p_item1) +{ + app_timer_t * p0 = CONTAINER_OF(p_item0, app_timer_t, list_item); + app_timer_t * p1 = CONTAINER_OF(p_item1, app_timer_t, list_item); + + uint64_t p0_end = p0->end_val; + uint64_t p1_end = p1->end_val; + return (p0_end <= p1_end) ? true : false; +} + +#if APP_TIMER_CONFIG_USE_SCHEDULER +static void scheduled_timeout_handler(void * p_event_data, uint16_t event_size) +{ + ASSERT(event_size == sizeof(app_timer_event_t)); + app_timer_event_t const * p_timer_event = (app_timer_event_t *)p_event_data; + + p_timer_event->timeout_handler(p_timer_event->p_context); +} +#endif + +/** + * @brief Function called on timer expiration + * If end value is not reached it is assumed that it was partial expiration and time is put back + * into the list. Otherwise function calls user handler if timer was not stopped before. If timer + * is in repeated mode then timer is rescheduled. + * + * @param p_timer Timer instance. + * + * @return True if reevaluation of sortlist needed (becasue it was updated). + */ +static bool timer_expire(app_timer_t * p_timer) +{ + ASSERT(p_timer->handler); + bool ret = false; + + if ((m_global_active == true) && (p_timer != NULL) && (p_timer->active)) + { + if (get_now() >= p_timer->end_val) { + /* timer expired */ + if (p_timer->repeat_period == 0) + { + p_timer->active = false; + } + #if APP_TIMER_CONFIG_USE_SCHEDULER + app_timer_event_t timer_event; + + timer_event.timeout_handler = p_timer->handler; + timer_event.p_context = p_timer->p_context; + uint32_t err_code = app_sched_event_put(&timer_event, + sizeof(timer_event), + scheduled_timeout_handler); + APP_ERROR_CHECK(err_code); + #else + NRF_LOG_DEBUG("Timer expired (context: %d)", (uint32_t)p_timer->p_context) + p_timer->handler(p_timer->p_context); + #endif + /* check active flag as it may have been stopped in the user handler */ + if ((p_timer->repeat_period) && (p_timer->active)) + { + p_timer->end_val += p_timer->repeat_period; + nrf_sortlist_add(&m_app_timer_sortlist, &p_timer->list_item); + ret = true; + } + } + else + { + nrf_sortlist_add(&m_app_timer_sortlist, &p_timer->list_item); + ret = true; + } + } + return ret; +} + +/** + * @brief Function is configuring RTC driver to trigger timeout interrupt for given timer. + * + * It is possible that RTC driver will indicate that timeout already occured. In that case timer + * expires and function indicates that RTC was not configured. + * + * @param p_timer Timer instance. + * @param [in,out] p_rerun Flag indicating that sortlist reevaluation is required. + * + * @return True if RTC was successfully configured, false if timer already expired and RTC was not + * configured. + * + */ +static bool rtc_schedule(app_timer_t * p_timer, bool * p_rerun) +{ + ret_code_t ret = NRF_ERROR_TIMEOUT; + *p_rerun = false; + int64_t remaining = (int64_t)(p_timer->end_val - get_now()); + + if (remaining > 0) { + uint32_t cc_val = ((uint32_t)remaining > APP_TIMER_RTC_MAX_VALUE) ? + (app_timer_cnt_get() + APP_TIMER_RTC_MAX_VALUE) : p_timer->end_val; + + ret = drv_rtc_windowed_compare_set(&m_rtc_inst, 0, cc_val, APP_TIMER_SAFE_WINDOW); + NRF_LOG_DEBUG("Setting CC to 0x%08x (err: %d)", cc_val & DRV_RTC_MAX_CNT, ret); + if (ret == NRF_SUCCESS) + { + return true; + } + } + else + { + drv_rtc_compare_disable(&m_rtc_inst, 0); + } + + if (ret == NRF_ERROR_TIMEOUT) + { + *p_rerun = timer_expire(p_timer); + } + else + { + NRF_LOG_ERROR("Unexpected error: %d", ret); + ASSERT(0); + } + + return false; +} + +static inline app_timer_t * sortlist_pop(void) +{ + nrf_sortlist_item_t * p_next_item = nrf_sortlist_pop(&m_app_timer_sortlist); + return p_next_item ? CONTAINER_OF(p_next_item, app_timer_t, list_item) : NULL; +} + +static inline app_timer_t * sortlist_peek(void) +{ + nrf_sortlist_item_t const * p_next_item = nrf_sortlist_peek(&m_app_timer_sortlist); + return p_next_item ? CONTAINER_OF(p_next_item, app_timer_t, list_item) : NULL; +} + +/** + * @brief Function for deactivating all timers which are in the sorted list (active timers). + */ +static void sorted_list_stop_all(void) +{ + app_timer_t * p_next; + do + { + p_next = sortlist_pop(); + if (p_next) + { + p_next->active = false; + } + } while (p_next); +} + +/** + * @brief Function for handling RTC counter overflow. + * + * Increment base counter used to calculate 64 bit timestamp. + */ +static void on_overflow_evt(void) +{ + NRF_LOG_DEBUG("Overflow EVT"); + m_base_counter += (DRV_RTC_MAX_CNT + 1); +} + +/** + * #brief Function for handling RTC compare event - active timer expiration. + */ +static void on_compare_evt(drv_rtc_t const * const p_instance) +{ + if (mp_active_timer) + { + /* If assert fails it suggests that safe window should be increased. */ + ASSERT(app_timer_cnt_diff_compute(drv_rtc_counter_get(p_instance), + mp_active_timer->end_val & RTC_COUNTER_COUNTER_Msk) < APP_TIMER_SAFE_WINDOW); + + NRF_LOG_INST_DEBUG(mp_active_timer->p_log, "Compare EVT"); + UNUSED_RETURN_VALUE(timer_expire(mp_active_timer)); + mp_active_timer = NULL; + } + else + { + NRF_LOG_WARNING("Compare event but no active timer (already stopped?)"); + } +} + +/** + * @brief Channel 1 is triggered in the middle of 24 bit period to updated control timestamp in + * place where there is no risk of overflow. + */ +static void on_compare1_evt(drv_rtc_t const * const p_instance) +{ + m_stamp64 = get_now(); +} + +/** + * @brief Function updates RTC. + * + * Function is called at the end of RTC interrupt when all new user request and/or timer expiration + * occured. It configures RTC if there is any pending timer, reconfigures if the are timers with + * shorted timeout than active one or stops RTC if there is no active timers. + */ +static void rtc_update(drv_rtc_t const * const p_instance) +{ + while(1) + { + app_timer_t * p_next = sortlist_peek(); + bool rtc_reconf = false; + if (p_next) //Candidate for active timer + { + if (mp_active_timer == NULL) + { + //There is no active timer so candidate will become active timer. + rtc_reconf = true; + } + else if (p_next->end_val < mp_active_timer->end_val) + { + //Candidate has shorter timeout than current active timer. Candidate will replace active timer. + //Active timer is put back into sorted list. + rtc_reconf = true; + if (mp_active_timer->active) + { + NRF_LOG_INST_DEBUG(mp_active_timer->p_log, "Timer preempted."); + nrf_sortlist_add(&m_app_timer_sortlist, &mp_active_timer->list_item); + } + } + + if (rtc_reconf) + { + bool rerun; + p_next = sortlist_pop(); + NRF_LOG_INST_DEBUG(p_next->p_log, "Activating timer (CC:%d/%08x).", p_next->end_val, p_next->end_val); + if (rtc_schedule(p_next, &rerun)) + { + if (!APP_TIMER_KEEPS_RTC_ACTIVE && (mp_active_timer == NULL)) + { + drv_rtc_start(p_instance); + } + mp_active_timer = p_next; + + if (rerun == false) + { + //RTC was successfully updated and sortlist was not updated. Function can be terminated. + break; + } + } + else + { + //If RTC driver indicated that timeout already occured a new candidate will be taken from sorted list. + NRF_LOG_INST_DEBUG(p_next->p_log,"Timer expired before scheduled to RTC."); + mp_active_timer = NULL; + } + } + else + { + //RTC will not be updated. Function can terminate. + break; + } + } + else //No candidate for active timer. + { + if (!APP_TIMER_KEEPS_RTC_ACTIVE && (mp_active_timer == NULL)) + { + drv_rtc_stop(p_instance); + } + break; + } + } +} + +/** + * @brief Function for processing user requests. + * + * Function is called only in the context of RTC interrupt. + */ +static void timer_req_process(drv_rtc_t const * const p_instance) +{ + nrf_atfifo_item_get_t fifo_ctx; + timer_req_t * p_req = nrf_atfifo_item_get(m_req_fifo, &fifo_ctx); + + while (p_req) + { + switch (p_req->type) + { + case TIMER_REQ_START: + if (!p_req->p_timer->active) + { + p_req->p_timer->active = true; + nrf_sortlist_add(&m_app_timer_sortlist, &(p_req->p_timer->list_item)); + NRF_LOG_INST_DEBUG(p_req->p_timer->p_log,"Start request (expiring at %d/0x%08x).", + p_req->p_timer->end_val, p_req->p_timer->end_val); + } + break; + case TIMER_REQ_STOP: + if (p_req->p_timer == mp_active_timer) + { + mp_active_timer = NULL; + } + else + { + bool found = nrf_sortlist_remove(&m_app_timer_sortlist, &(p_req->p_timer->list_item)); + if (!found) + { + NRF_LOG_INFO("Timer not found on sortlist (stopping expired timer)."); + } + } + NRF_LOG_INST_DEBUG(p_req->p_timer->p_log,"Stop request."); + break; + case TIMER_REQ_STOP_ALL: + sorted_list_stop_all(); + m_global_active = true; + NRF_LOG_INFO("Stop all request."); + break; + default: + break; + } +#if APP_TIMER_WITH_PROFILER + CRITICAL_REGION_ENTER(); +#endif + UNUSED_RETURN_VALUE(nrf_atfifo_item_free(m_req_fifo, &fifo_ctx)); +#if APP_TIMER_WITH_PROFILER + if (m_max_user_op_queue_utilization < m_current_user_op_queue_utilization) + { + m_max_user_op_queue_utilization = m_current_user_op_queue_utilization; + } + --m_current_user_op_queue_utilization; + CRITICAL_REGION_EXIT(); +#endif /* APP_TIMER_WITH_PROFILER */ + p_req = nrf_atfifo_item_get(m_req_fifo, &fifo_ctx); + } +} + +static void rtc_irq(drv_rtc_t const * const p_instance) +{ + if (drv_rtc_overflow_pending(p_instance)) + { + on_overflow_evt(); + } + if (drv_rtc_compare_pending(p_instance, 0)) + { + on_compare_evt(p_instance); + } + if (drv_rtc_compare_pending(p_instance, 1)) + { + on_compare1_evt(p_instance); + } + + timer_req_process(p_instance); + rtc_update(p_instance); +} + +/** + * @brief Function for triggering processing user requests. + * + * @note All user requests are processed in a single context - RTC interrupt. + */ +static inline void timer_request_proc_trigger(void) +{ + drv_rtc_irq_trigger(&m_rtc_inst); +} + +/** + * @brief Function for putting user request into the request queue + */ +static ret_code_t timer_req_schedule(app_timer_req_type_t type, app_timer_t * p_timer) +{ + nrf_atfifo_item_put_t fifo_ctx; + timer_req_t * p_req; +#if APP_TIMER_WITH_PROFILER + CRITICAL_REGION_ENTER(); +#endif + p_req = nrf_atfifo_item_alloc(m_req_fifo, &fifo_ctx); +#if APP_TIMER_WITH_PROFILER + if (p_req) + { + ++m_current_user_op_queue_utilization; + } + CRITICAL_REGION_EXIT(); +#endif /* APP_TIMER_WITH_PROFILER */ + if (p_req) + { + p_req->type = type; + p_req->p_timer = p_timer; + if (nrf_atfifo_item_put(m_req_fifo, &fifo_ctx)) + { + timer_request_proc_trigger(); + } + else + { + NRF_LOG_WARNING("Scheduling interrupted another scheduling."); + } + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_NO_MEM; + } +} + +ret_code_t app_timer_init(void) +{ + ret_code_t err_code; + drv_rtc_config_t config = { + .prescaler = APP_TIMER_CONFIG_RTC_FREQUENCY, + .interrupt_priority = APP_TIMER_CONFIG_IRQ_PRIORITY + }; + + err_code = NRF_ATFIFO_INIT(m_req_fifo); + if (err_code != NRFX_SUCCESS) + { + return err_code; + } + + err_code = drv_rtc_init(&m_rtc_inst, &config, rtc_irq); + if (err_code != NRFX_SUCCESS) + { + return err_code; + } + drv_rtc_overflow_enable(&m_rtc_inst, true); + drv_rtc_compare_set(&m_rtc_inst, 1, DRV_RTC_MAX_CNT >> 1, true); + if (APP_TIMER_KEEPS_RTC_ACTIVE) + { + drv_rtc_start(&m_rtc_inst); + } + + m_global_active = true; + return err_code; +} + +ret_code_t app_timer_create(app_timer_id_t const * p_timer_id, + app_timer_mode_t mode, + app_timer_timeout_handler_t timeout_handler) +{ + ASSERT(p_timer_id); + ASSERT(timeout_handler); + + if (timeout_handler == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + app_timer_t * p_t = (app_timer_t *) *p_timer_id; + p_t->handler = timeout_handler; + p_t->repeat_period = (mode == APP_TIMER_MODE_REPEATED) ? 1 : 0; + return NRF_SUCCESS; +} + +ret_code_t app_timer_start(app_timer_t * p_timer, uint32_t timeout_ticks, void * p_context) +{ + ASSERT(p_timer); + app_timer_t * p_t = (app_timer_t *) p_timer; + + if (p_t->active) + { + return NRF_SUCCESS; + } + + p_t->p_context = p_context; + p_t->end_val = get_now() + timeout_ticks; + + if (p_t->repeat_period) + { + p_t->repeat_period = timeout_ticks; + } + + return timer_req_schedule(TIMER_REQ_START, p_t); +} + + +ret_code_t app_timer_stop(app_timer_t * p_timer) +{ + ASSERT(p_timer); + app_timer_t * p_t = (app_timer_t *) p_timer; + p_t->active = false; + + return timer_req_schedule(TIMER_REQ_STOP, p_t); +} + +ret_code_t app_timer_stop_all(void) +{ + //block timer globally + m_global_active = false; + + return timer_req_schedule(TIMER_REQ_STOP_ALL, NULL); +} + +#if APP_TIMER_WITH_PROFILER +uint8_t app_timer_op_queue_utilization_get(void) +{ + return m_max_user_op_queue_utilization; +} +#endif /* APP_TIMER_WITH_PROFILER */ + +uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to, + uint32_t ticks_from) +{ + return ((ticks_to - ticks_from) & RTC_COUNTER_COUNTER_Msk); +} + +uint32_t app_timer_cnt_get(void) +{ + return drv_rtc_counter_get(&m_rtc_inst); +} + +void app_timer_pause(void) +{ + drv_rtc_stop(&m_rtc_inst); +} + +void app_timer_resume(void) +{ + drv_rtc_start(&m_rtc_inst); +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer_freertos.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer_freertos.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer_freertos.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer_freertos.c index 9d5c840..ec861d7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer_freertos.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer_freertos.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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(APP_TIMER) @@ -80,6 +80,7 @@ typedef struct * FreeRTOS may have timer running even after stop function is called, * because it processes commands in Timer task and stopping function only puts command into the queue. */ bool active; + bool single_shot; }app_timer_info_t; @@ -106,7 +107,10 @@ static void app_timer_callback(TimerHandle_t xTimer) ASSERT(pinfo->func != NULL); if (pinfo->active) + { + pinfo->active = (pinfo->single_shot) ? false : true; pinfo->func(pinfo->argument); + } } @@ -138,11 +142,8 @@ uint32_t app_timer_create(app_timer_id_t const * p_timer_id, /* New timer is created */ memset(pinfo, 0, sizeof(app_timer_info_t)); - if (mode == APP_TIMER_MODE_SINGLE_SHOT) - timer_mode = pdFALSE; - else - timer_mode = pdTRUE; - + timer_mode = (mode == APP_TIMER_MODE_SINGLE_SHOT) ? pdFALSE : pdTRUE; + pinfo->single_shot = (mode == APP_TIMER_MODE_SINGLE_SHOT); pinfo->func = timeout_handler; pinfo->osHandle = xTimerCreate(" ", 1000, timer_mode, pinfo, app_timer_callback); @@ -168,7 +169,7 @@ uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * { return NRF_ERROR_INVALID_STATE; } - if (pinfo->active && (xTimerIsTimerActive(hTimer) != pdFALSE)) + if (pinfo->active) { // Timer already running - exit silently return NRF_SUCCESS; @@ -179,6 +180,7 @@ uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * if (__get_IPSR() != 0) { BaseType_t yieldReq = pdFALSE; + if (xTimerChangePeriodFromISR(hTimer, timeout_ticks, &yieldReq) != pdPASS) { return NRF_ERROR_NO_MEM; @@ -193,6 +195,12 @@ uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * } else { + if (xTimerIsTimerActive(hTimer) != pdFALSE) + { + // Timer already running - exit silently + return NRF_SUCCESS; + } + if (xTimerChangePeriod(hTimer, timeout_ticks, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS) { return NRF_ERROR_NO_MEM; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer_rtx.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer_rtx.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer_rtx.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer_rtx.c index ae16e75..e73c5e2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/timer/app_timer_rtx.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/app_timer_rtx.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(APP_TIMER) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.c new file mode 100644 index 0000000..b355bb0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.c @@ -0,0 +1,358 @@ +/** + * Copyright (c) 2018 - 2019, 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 +#include +#include + +/* Module is integral part of app_timer implementation. */ +#define NRF_LOG_MODULE_NAME app_timer +#include + +#define EVT_TO_STR(event) \ + (event == NRF_RTC_EVENT_TICK ? "NRF_RTC_EVENT_TICK" : \ + (event == NRF_RTC_EVENT_OVERFLOW ? "NRF_RTC_EVENT_OVERFLOW" : \ + (event == NRF_RTC_EVENT_COMPARE_0 ? "NRF_RTC_EVENT_COMPARE_0" : \ + (event == NRF_RTC_EVENT_COMPARE_1 ? "NRF_RTC_EVENT_COMPARE_1" : \ + (event == NRF_RTC_EVENT_COMPARE_2 ? "NRF_RTC_EVENT_COMPARE_2" : \ + (event == NRF_RTC_EVENT_COMPARE_3 ? "NRF_RTC_EVENT_COMPARE_3" : \ + "UNKNOWN EVENT")))))) +#if defined ( __ICCARM__ ) +/* IAR gives warning for offsetof with non-constant expression.*/ +#define CC_IDX_TO_CC_EVENT(_cc) \ + ((nrf_rtc_event_t)(offsetof(NRF_RTC_Type, EVENTS_COMPARE[0]) + sizeof(uint32_t)*_cc)) +#else +#define CC_IDX_TO_CC_EVENT(_cc) \ + ((nrf_rtc_event_t)(offsetof(NRF_RTC_Type, EVENTS_COMPARE[_cc]))) +#endif + +/**@brief RTC driver instance control block structure. */ +typedef struct +{ + drv_rtc_t const * p_instance; + nrfx_drv_state_t state; /**< Instance state. */ +} drv_rtc_cb_t; + +// User callbacks local storage. +static drv_rtc_handler_t m_handlers[DRV_RTC_ENABLED_COUNT]; +static drv_rtc_cb_t m_cb[DRV_RTC_ENABLED_COUNT]; + +// According to Produce Specification RTC may not trigger COMPARE event if CC value set is equal to +// COUNTER value or COUNTER+1. +#define COUNTER_TO_CC_MIN_DISTANCE 2 + +ret_code_t drv_rtc_init(drv_rtc_t const * const p_instance, + drv_rtc_config_t const * p_config, + drv_rtc_handler_t handler) +{ + ASSERT(p_instance); + ASSERT(p_config); + ASSERT(handler); + + ret_code_t err_code; + + m_handlers[p_instance->instance_id] = handler; + + if (m_cb[p_instance->instance_id].state != NRFX_DRV_STATE_UNINITIALIZED) + { + err_code = NRF_ERROR_INVALID_STATE; + NRF_LOG_WARNING("RTC instance already initialized."); + return err_code; + } + + nrf_rtc_prescaler_set(p_instance->p_reg, p_config->prescaler); + NRFX_IRQ_PRIORITY_SET(p_instance->irq, p_config->interrupt_priority); + NRFX_IRQ_ENABLE(p_instance->irq); + + m_cb[p_instance->instance_id].state = NRFX_DRV_STATE_INITIALIZED; + m_cb[p_instance->instance_id].p_instance = p_instance; + + err_code = NRF_SUCCESS; + NRF_LOG_INFO("RTC: initialized."); + return err_code; +} + +void drv_rtc_uninit(drv_rtc_t const * const p_instance) +{ + ASSERT(p_instance); + uint32_t mask = NRF_RTC_INT_TICK_MASK | + NRF_RTC_INT_OVERFLOW_MASK | + NRF_RTC_INT_COMPARE0_MASK | + NRF_RTC_INT_COMPARE1_MASK | + NRF_RTC_INT_COMPARE2_MASK | + NRF_RTC_INT_COMPARE3_MASK; + ASSERT(m_cb[p_instance->instance_id].state != NRFX_DRV_STATE_UNINITIALIZED); + + NRFX_IRQ_DISABLE(p_instance->irq); + + drv_rtc_stop(p_instance); + nrf_rtc_event_disable(p_instance->p_reg, mask); + nrf_rtc_int_disable(p_instance->p_reg, mask); + + m_cb[p_instance->instance_id].state = NRFX_DRV_STATE_UNINITIALIZED; + NRF_LOG_INFO("RTC: Uninitialized."); +} + +void drv_rtc_start(drv_rtc_t const * const p_instance) +{ + ASSERT(p_instance); + nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_START); +} + +void drv_rtc_stop(drv_rtc_t const * const p_instance) +{ + ASSERT(p_instance); + nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_STOP); +} + +void drv_rtc_compare_set(drv_rtc_t const * const p_instance, + uint32_t cc, + uint32_t abs_value, + bool irq_enable) +{ + ASSERT(p_instance); + nrf_rtc_int_t cc_int_mask = (nrf_rtc_int_t)(NRF_RTC_INT_COMPARE0_MASK << cc); + nrf_rtc_event_t cc_evt = CC_IDX_TO_CC_EVENT(cc); + abs_value &= RTC_COUNTER_COUNTER_Msk; + + nrf_rtc_int_disable(p_instance->p_reg, cc_int_mask); + nrf_rtc_event_disable(p_instance->p_reg, cc_int_mask); + nrf_rtc_event_clear(p_instance->p_reg, cc_evt); + nrf_rtc_cc_set(p_instance->p_reg, cc,abs_value); + nrf_rtc_event_enable(p_instance->p_reg, cc_int_mask); + + if (irq_enable) + { + nrf_rtc_int_enable(p_instance->p_reg, cc_int_mask); + } +} + +static void evt_enable(drv_rtc_t const * const p_instance, uint32_t mask, bool irq_enable) +{ + ASSERT(p_instance); + nrf_rtc_event_enable(p_instance->p_reg, mask); + if (irq_enable) + { + nrf_rtc_int_enable(p_instance->p_reg, mask); + } +} + +static void evt_disable(drv_rtc_t const * const p_instance, uint32_t mask) +{ + ASSERT(p_instance); + nrf_rtc_event_disable(p_instance->p_reg, mask); + nrf_rtc_int_disable(p_instance->p_reg, mask); +} + +static bool evt_pending(drv_rtc_t const * const p_instance, nrf_rtc_event_t event) +{ + ASSERT(p_instance); + if (nrf_rtc_event_pending(p_instance->p_reg, event)) + { + nrf_rtc_event_clear(p_instance->p_reg, event); + return true; + } + return false; +} + +static uint32_t ticks_sub(uint32_t a, uint32_t b) +{ + return (a - b) & RTC_COUNTER_COUNTER_Msk; +} + +ret_code_t drv_rtc_windowed_compare_set(drv_rtc_t const * const p_instance, + uint32_t cc, + uint32_t abs_value, + uint32_t safe_window) +{ + ASSERT(p_instance); + uint32_t prev_cc_set; + uint32_t now; + uint32_t diff; + nrf_rtc_int_t cc_int_mask = (nrf_rtc_int_t)(NRF_RTC_INT_COMPARE0_MASK << cc); + nrf_rtc_event_t cc_evt = CC_IDX_TO_CC_EVENT(cc);; + abs_value &=RTC_COUNTER_COUNTER_Msk; + + evt_disable(p_instance, cc_int_mask); + + /* First handle potential prefiring caused by CC being set to next tick. Even if CC is + * overwritten it may happen that event will be generated for previous CC in next tick. + * Following algorith is applied: + * - read previous CC + * - write current counter value to CC (furtherest in future) + * - if previous CC was in one tick from now wait half of the 32k tick and clear event which + * may be set. Half tick delay is used because CC is latched in the middle of the 32k tick. + */ + now = nrf_rtc_counter_get(p_instance->p_reg); + prev_cc_set = nrf_rtc_cc_get(p_instance->p_reg, cc); + nrf_rtc_cc_set(p_instance->p_reg, cc, now); + nrf_rtc_event_clear(p_instance->p_reg, cc_evt); + + if (ticks_sub(prev_cc_set, now) == 1) + { + nrf_delay_us(16); + nrf_rtc_event_clear(p_instance->p_reg, cc_evt); + } + + now = nrf_rtc_counter_get(p_instance->p_reg); + diff = ticks_sub(abs_value, now); + + nrf_rtc_event_enable(p_instance->p_reg, cc_int_mask); + + /* Setting CC for +1 from now may not generate event. In that case set CC+2 and check if counter + * changed during that process. If changed it means that 1 tick expired. */ + if (diff == 1) + { + nrf_rtc_cc_set(p_instance->p_reg, cc, abs_value + 1); + nrf_delay_us(16); + if (now != nrf_rtc_counter_get(p_instance->p_reg)) + { + /* one tick elapsed already. */ + return NRF_ERROR_TIMEOUT; + } + } else { + nrf_rtc_cc_set(p_instance->p_reg, cc, abs_value); + now = nrf_rtc_counter_get(p_instance->p_reg); + diff = ticks_sub(abs_value - 1, now); + /* Check if counter equals cc value or is behind in the safe window. If yes it means that + * CC expired. */ + if (diff > (RTC_COUNTER_COUNTER_Msk - safe_window)) + { + return NRF_ERROR_TIMEOUT; + } + else if (diff == 0) + { + /* If cc value == counter + 1, it may hit +1 case. */ + nrf_rtc_cc_set(p_instance->p_reg, cc, abs_value + 1); + if (now != nrf_rtc_counter_get(p_instance->p_reg)) + { + /* one tick elapsed already. */ + return NRF_ERROR_TIMEOUT; + } + } + } + + evt_enable(p_instance, cc_int_mask, true); + + return NRF_SUCCESS; +} + +void drv_rtc_overflow_enable(drv_rtc_t const * const p_instance, bool irq_enable) +{ + evt_enable(p_instance, NRF_RTC_INT_OVERFLOW_MASK, irq_enable); +} + +void drv_rtc_overflow_disable(drv_rtc_t const * const p_instance) +{ + evt_disable(p_instance, NRF_RTC_INT_OVERFLOW_MASK); +} + +bool drv_rtc_overflow_pending(drv_rtc_t const * const p_instance) +{ + return evt_pending(p_instance, NRF_RTC_EVENT_OVERFLOW); +} + +void drv_rtc_tick_enable(drv_rtc_t const * const p_instance, bool irq_enable) +{ + evt_enable(p_instance, NRF_RTC_INT_TICK_MASK, irq_enable); +} + +void drv_rtc_tick_disable(drv_rtc_t const * const p_instance) +{ + evt_disable(p_instance, NRF_RTC_INT_TICK_MASK); +} + +bool drv_rtc_tick_pending(drv_rtc_t const * const p_instance) +{ + return evt_pending(p_instance, NRF_RTC_EVENT_TICK); +} + +void drv_rtc_compare_enable(drv_rtc_t const * const p_instance, + uint32_t cc, + bool irq_enable) +{ + evt_enable(p_instance, (uint32_t)NRF_RTC_INT_COMPARE0_MASK << cc, irq_enable); +} + +void drv_rtc_compare_disable(drv_rtc_t const * const p_instance, uint32_t cc) +{ + evt_disable(p_instance, (uint32_t)NRF_RTC_INT_COMPARE0_MASK << cc); +} + +bool drv_rtc_compare_pending(drv_rtc_t const * const p_instance, uint32_t cc) +{ + nrf_rtc_event_t cc_evt = CC_IDX_TO_CC_EVENT(cc); + return evt_pending(p_instance, cc_evt); +} + +uint32_t drv_rtc_counter_get(drv_rtc_t const * const p_instance) +{ + return nrf_rtc_counter_get(p_instance->p_reg); +} + +void drv_rtc_irq_trigger(drv_rtc_t const * const p_instance) +{ + NVIC_SetPendingIRQ(p_instance->irq); +} + +#define drv_rtc_rtc_0_irq_handler RTC0_IRQHandler +#define drv_rtc_rtc_1_irq_handler RTC1_IRQHandler +#define drv_rtc_rtc_2_irq_handler RTC2_IRQHandler + +#if defined(APP_TIMER_V2_RTC0_ENABLED) +void drv_rtc_rtc_0_irq_handler(void) +{ + m_handlers[DRV_RTC_RTC0_INST_IDX](m_cb[DRV_RTC_RTC0_INST_IDX].p_instance); +} +#endif + +#if defined(APP_TIMER_V2_RTC1_ENABLED) +void drv_rtc_rtc_1_irq_handler(void) +{ + m_handlers[DRV_RTC_RTC1_INST_IDX](m_cb[DRV_RTC_RTC1_INST_IDX].p_instance); +} +#endif + +#if defined(APP_TIMER_V2_RTC2_ENABLED) +void drv_rtc_rtc_2_irq_handler(void) +{ + m_handlers[DRV_RTC_RTC2_INST_IDX](m_cb[DRV_RTC_RTC2_INST_IDX].p_instance); +} +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.h new file mode 100644 index 0000000..e674408 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/timer/drv_rtc.h @@ -0,0 +1,305 @@ +/** + * Copyright (c) 2018 - 2019, 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 DRV_RTC_H__ +#define DRV_RTC_H__ + +#include +#include +#include "sdk_errors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup drv_rtc RTC driver + * @{ + * @ingroup app_timer + * @brief Real Timer Counter (RTC) peripheral driver for app_timer. + */ + +/** @brief Maximum RTC counter value. */ +#define DRV_RTC_MAX_CNT RTC_COUNTER_COUNTER_Msk + +/** @brief Time requires to update registers between RTC and MCU domains. */ +#define DRV_RTC_CONFIG_APPLY_TIME_US 33 + +/** + * @brief Minimum delta value between set value and counter value. + * + * RTC peripheral requires two ticks to be sure that value it properly set in RTC value. Compare + * channel function requires additional one tick to avoid problematic situations (lack or additional + * unspecified event) when Compare Channel register is reseting or setting to N+2 value. + */ +#define DRV_RTC_MIN_TICK_HANDLED 3 + +/** @brief Macro to convert microseconds into ticks. */ +#define DRV_RTC_US_TO_TICKS(us,freq) (us >= 2^17 ? \ + ((((us)/1000)*(freq))/1000U) : (((us)*(freq))/1000000U) ) + + +/** @brief RTC driver instance structure. */ +typedef struct +{ + NRF_RTC_Type * p_reg; /**< Pointer to instance register set. */ + IRQn_Type irq; /**< Instance IRQ ID. */ + uint8_t instance_id; /**< Instance index. */ + uint8_t cc_channel_count; /**< Number of capture/compare channels. */ +} drv_rtc_t; + +/** @brief Macro for creating RTC driver instance.*/ +#define DRV_RTC_INSTANCE(id) \ +{ \ + .p_reg = NRFX_CONCAT_2(NRF_RTC, id), \ + .irq = NRFX_CONCAT_3(RTC, id, _IRQn), \ + .instance_id = NRFX_CONCAT_3(DRV_RTC_RTC, id, _INST_IDX), \ + .cc_channel_count = NRF_RTC_CC_CHANNEL_COUNT(id), \ +} + +enum { +#if defined(APP_TIMER_V2_RTC0_ENABLED) + DRV_RTC_RTC0_INST_IDX, +#endif +#if defined(APP_TIMER_V2_RTC1_ENABLED) + DRV_RTC_RTC1_INST_IDX, +#endif +#if defined(APP_TIMER_V2_RTC2_ENABLED) + DRV_RTC_RTC2_INST_IDX, +#endif + DRV_RTC_ENABLED_COUNT +}; + +/** @brief RTC driver instance configuration structure. */ +typedef struct +{ + uint16_t prescaler; /**< Prescaler. */ + uint8_t interrupt_priority; /**< Interrupt priority. */ +} drv_rtc_config_t; + +/** @brief RTC instance default configuration. */ +#define DRV_RTC_DEFAULT_CONFIG \ +{ \ + .prescaler = RTC_FREQ_TO_PRESCALER(DRV_RTC_DEFAULT_CONFIG_FREQUENCY), \ + .interrupt_priority = DRV_RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \ +} + +/** @brief RTC driver instance handler type. */ +typedef void (*drv_rtc_handler_t)(drv_rtc_t const * const p_instance); + +/** + * @brief Function for initializing the RTC driver instance. + * + * After initialization, the instance is in power off state. The LFCLK (@ref nrfx_clock) + * has to be started before using @ref drv_rtc. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] handler Event handler provided by the user. Must not be NULL. + * + * @retval NRF_SUCCESS If successfully initialized. + * @retval NRF_ERROR_INVALID_STATE If the instance is already initialized. + */ +ret_code_t drv_rtc_init(drv_rtc_t const * const p_instance, + drv_rtc_config_t const * p_config, + drv_rtc_handler_t handler); + +/** + * @brief Function for uninitializing the RTC driver instance. + * + * After uninitialization, the instance is in idle state. The hardware should return to the state + * before initialization. The function asserts if the instance is in idle state. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +void drv_rtc_uninit(drv_rtc_t const * const p_instance); + +/** + * @brief Function for starting RTC clock. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +void drv_rtc_start(drv_rtc_t const * const p_instance); + +/** + * @brief Function for stopping RTC clock. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +void drv_rtc_stop(drv_rtc_t const * const p_instance); + +/** + * @brief Function for configuring compare channel. + * + * @note Function disables interrupts and only enable compare events. Remember to enable interrupt + * using @ref drv_rtc_compare_enable in case of using it. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] cc Compare channel index. + * @param[in] abs_value Absolute value to be set in the compare register. + * @param[in] irq_enable True to enable interrupt. + */ +void drv_rtc_compare_set(drv_rtc_t const * const p_instance, + uint32_t cc, + uint32_t abs_value, + bool irq_enable); + +/** + * @brief Function for configuring compare channel with safe window. + * + * Maximum possible relative value is limited by safe window to detect + * cases when requested compare event has already occured. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] cc Compare channel index. + * @param[in] abs_value Absolute value to be set in the compare register. + * @param[in] safe_window Width of the safe window. + * + * @retval NRF_ERROR_TIMEOUT If @par abs_value is in safe window of event occured before + * enabling compare channel intterupt. + * @retval NRF_SUCCESS If successfully set. + */ +ret_code_t drv_rtc_windowed_compare_set(drv_rtc_t const * const p_instance, + uint32_t cc, + uint32_t abs_value, + uint32_t safe_window); + +/** + * @brief Function for enabling overflow event and interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] irq_enable True to enable interrupt. + */ +void drv_rtc_overflow_enable(drv_rtc_t const * const p_instance, bool irq_enable); + +/** + * @brief Function for diabling overflow event and interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +void drv_rtc_overflow_disable(drv_rtc_t const * const p_instance); + +/** + * @brief Function for checking if overflow event has occured. + * + * @note Event is cleared after reading. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return True if interrupt pending, false otherwise. + */ +bool drv_rtc_overflow_pending(drv_rtc_t const * const p_instance); + +/** + * @brief Function for enabling tick event and interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] irq_enable True to enable interrupt. + */ +void drv_rtc_tick_enable(drv_rtc_t const * const p_instance, bool irq_enable); + +/** + * @brief Function for disabling tick event and interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +void drv_rtc_tick_disable(drv_rtc_t const * const p_instance); + +/** + * @brief Function for checking if tick event has occured. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return True if interrupt pending, false otherwise. + */ +bool drv_rtc_tick_pending(drv_rtc_t const * const p_instance); + +/** + * @brief Function for enabling compare channel event and interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] cc Compare channel index. + * @param[in] irq_enable True to enable interrupt. + */ +void drv_rtc_compare_enable(drv_rtc_t const * const p_instance, + uint32_t cc, + bool irq_enable); + +/** + * @brief Function for disabling compare channel event and interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] cc Compare channel index. + */ +void drv_rtc_compare_disable(drv_rtc_t const * const p_instance, uint32_t cc); + +/** + * @brief Function for checking if compare channel event has occured. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] cc Compare channel index. + * + * @return True if interrupt pending, false otherwise. + */ +bool drv_rtc_compare_pending(drv_rtc_t const * const p_instance, uint32_t cc); + +/** + * @brief Function for getting current value of RTC counter. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return Counter value. + */ +uint32_t drv_rtc_counter_get(drv_rtc_t const * const p_instance); + +/** + * @brief Function for triggering RTC interrupt. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +void drv_rtc_irq_trigger(drv_rtc_t const * const p_instance); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // DRV_RTC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi_mngr/nrf_twi_mngr.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_mngr/nrf_twi_mngr.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi_mngr/nrf_twi_mngr.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_mngr/nrf_twi_mngr.c index dce41cf..aa91f58 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi_mngr/nrf_twi_mngr.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_mngr/nrf_twi_mngr.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_TWI_MNGR) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi_mngr/nrf_twi_mngr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_mngr/nrf_twi_mngr.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi_mngr/nrf_twi_mngr.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_mngr/nrf_twi_mngr.h index ac4e55d..4efcb3e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi_mngr/nrf_twi_mngr.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_mngr/nrf_twi_mngr.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_TWI_MNGR_H__ #define NRF_TWI_MNGR_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.c new file mode 100644 index 0000000..4f7fdf4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.c @@ -0,0 +1,220 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf_twi_sensor.h" +#include + +#define NRF_LOG_MODULE_NAME twi_sensor +#if NRF_TWI_SENSOR_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_TWI_SENSOR_CONFIG_LOG_LEVEL + #define NRF_LOG_INFO_COLOR NRF_TWI_SENSOR_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +ret_code_t nrf_twi_sensor_init(nrf_twi_sensor_t * p_twi_sensor) +{ + return nrf_balloc_init(p_twi_sensor->p_pool); +} + +static void sensor_read_reg_cb(ret_code_t result, void * p_user_data) +{ + nrf_twi_sensor_read_cmd_t * p_cmd = &((nrf_twi_sensor_cmd_t *) p_user_data)->read; + NRF_LOG_INFO("Read cb reg addr: 0x%02X, result %d", p_cmd->reg_address, result); + NRF_LOG_DEBUG("\r\nCallback pointer: %p\r\nData:", p_cmd->user_cb); + NRF_LOG_HEXDUMP_DEBUG(p_cmd->transfers[1].p_data, p_cmd->transfers[1].length); + + if (p_cmd->user_cb != NULL) + { + p_cmd->user_cb(result, (void*)p_cmd->transfers[1].p_data); + } + nrf_balloc_free(p_cmd->p_instance->p_pool, p_user_data); +} + +ret_code_t nrf_twi_sensor_reg_read(nrf_twi_sensor_t const * p_instance, + uint8_t sensor_addr, + uint8_t reg_address, + nrf_twi_sensor_reg_cb_t user_cb, + uint8_t * p_data, + uint8_t length) +{ + ASSERT(p_instance != NULL); + ASSERT(p_data != NULL); + NRF_LOG_INFO("Sensor addr: 0x%02X" + "\r\nRead reg addr: 0x%02X, bytes %d", + sensor_addr, + reg_address, + length); + + nrf_twi_sensor_read_cmd_t * p_cmd = + (nrf_twi_sensor_read_cmd_t *) nrf_balloc_alloc(p_instance->p_pool); + if (p_cmd == NULL) + { + NRF_LOG_WARNING("Memory not allocated."); + return NRF_ERROR_NO_MEM; + } + + p_cmd->p_instance = p_instance; + p_cmd->user_cb = user_cb; + p_cmd->reg_address = reg_address; + + p_cmd->transfers[0] = (nrf_twi_mngr_transfer_t) NRF_TWI_MNGR_WRITE(sensor_addr, + &p_cmd->reg_address, + 1, + NRF_TWI_MNGR_NO_STOP); + + p_cmd->transfers[1] = (nrf_twi_mngr_transfer_t) NRF_TWI_MNGR_READ(sensor_addr, + p_data, + length, + NRF_TWI_MNGR_NO_STOP); + + p_cmd->transaction = (nrf_twi_mngr_transaction_t) { + .callback = sensor_read_reg_cb, + .p_user_data = p_cmd, + .p_transfers = p_cmd->transfers, + .number_of_transfers = ARRAY_SIZE(p_cmd->transfers) + }; + + ret_code_t err_code = nrf_twi_mngr_schedule(p_instance->p_twi_mngr, &p_cmd->transaction); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("Transaction not scheduled.\r\nSensor addr: 0x%02X Error code: %d", + sensor_addr, + err_code); + nrf_balloc_free(p_instance->p_pool, p_cmd); + } + return err_code; +} + +static void sensor_write_reg_cb(ret_code_t result, void * p_user_data) +{ + nrf_twi_sensor_write_cmd_t * p_cmd = &((nrf_twi_sensor_cmd_t *) p_user_data)->write; + NRF_LOG_INFO("Write cb reg addr: 0x%02X, result %d", p_cmd->send_msg[0], result); + nrf_balloc_free(p_cmd->p_instance->p_pool, p_user_data); +} + +ret_code_t nrf_twi_sensor_write(nrf_twi_sensor_t const * p_instance, + uint8_t sensor_addr, + uint8_t const * p_data, + uint8_t length, + bool copy_flag) +{ + ASSERT(p_instance != NULL); + ASSERT(p_data != NULL); + NRF_LOG_INFO("Sensor addr: 0x%02X Write length %d", sensor_addr, length); + NRF_LOG_DEBUG("Data: "); + NRF_LOG_HEXDUMP_DEBUG(p_data, length); + nrf_twi_sensor_write_cmd_t * p_cmd = + (nrf_twi_sensor_write_cmd_t *) nrf_balloc_alloc(p_instance->p_pool); + if (p_cmd == NULL) + { + NRF_LOG_WARNING("Memory not allocated. Sensor addr: 0x%02X", + sensor_addr); + return NRF_ERROR_NO_MEM; + } + + p_cmd->p_instance = p_instance; + + p_cmd->transfer = (nrf_twi_mngr_transfer_t) NRF_TWI_MNGR_WRITE(sensor_addr, + p_data, + length, + 0); + + if (copy_flag == true) + { + if (length > NRF_TWI_SENSOR_SEND_BUF_SIZE) + { + NRF_LOG_ERROR("Data too long to copy. Sensor addr: 0x%02X" + "\r\nRequested write length: %d, max length: %d", + sensor_addr, + length, + NRF_TWI_SENSOR_SEND_BUF_SIZE); + nrf_balloc_free(p_instance->p_pool, p_cmd); + return NRF_ERROR_INVALID_LENGTH; + } + memcpy(p_cmd->send_msg, p_data, length); + p_cmd->transfer.p_data = p_cmd->send_msg; + } + + p_cmd->transaction = (nrf_twi_mngr_transaction_t) { + .callback = sensor_write_reg_cb, + .p_user_data = p_cmd, + .p_transfers = &p_cmd->transfer, + .number_of_transfers = 1 + }; + + ret_code_t err_code = nrf_twi_mngr_schedule(p_instance->p_twi_mngr, &p_cmd->transaction); + if (err_code != NRF_SUCCESS) + { + NRF_LOG_WARNING("Transaction not scheduled.\r\nSensor addr: 0x%02X Error code: %d", + sensor_addr, + err_code); + nrf_balloc_free(p_instance->p_pool, p_cmd); + } + return err_code; +} + +ret_code_t nrf_twi_sensor_reg_write(nrf_twi_sensor_t const * p_instance, + uint8_t sensor_addr, + uint8_t reg_address, + uint8_t * p_data, + uint8_t length) +{ + ASSERT(p_instance != NULL); + ASSERT(p_data != NULL); + NRF_LOG_INFO("Write register: 0x%02X", reg_address); + if (length > NRF_TWI_SENSOR_SEND_BUF_SIZE - 1) // Subtracting one byte for address + { + NRF_LOG_ERROR("Data too long to copy. Sensor addr: 0x%02X" + "\r\nRequested write length: %d, max length: %d", + sensor_addr, + length, + NRF_TWI_SENSOR_SEND_BUF_SIZE - 1); + return NRF_ERROR_INVALID_LENGTH; + } + uint8_t buf[NRF_TWI_SENSOR_SEND_BUF_SIZE]; + + buf[0] = reg_address; + memcpy(&buf[1], p_data, length); + return nrf_twi_sensor_write(p_instance, sensor_addr, buf, length + 1, true); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.h new file mode 100644 index 0000000..6d05cd2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/twi_sensor/nrf_twi_sensor.h @@ -0,0 +1,314 @@ +/** + * Copyright (c) 2017 - 2019, 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 nrf_twi_sensor TWI Sensor module. + * @{ + * @ingroup app_common + */ + +#ifndef NRF_TWI_SENSOR_H +#define NRF_TWI_SENSOR_H + +#include "nrf_twi_mngr.h" +#include "nrf_balloc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Internal write operation buffer length. + * + * Defines how many bytes can be stored internally. + * 16 bytes were selected so that nrf_twi_sensor_write_cmd_t size + * matches nrf_twi_sensor_read_cmd_t size. + */ +#define NRF_TWI_SENSOR_SEND_BUF_SIZE 16 + +/** + * @brief Register read callback prototype. + * + * @param[in] result Return error code from TWI manager and underlying drivers. + * @param[in] p_register_data Pointer to register value. + */ +typedef void (* nrf_twi_sensor_reg_cb_t)(ret_code_t result, void * p_register_data); + + +/** + * @brief Structure holding sensor instance + */ +typedef struct +{ + nrf_twi_mngr_t const * const p_twi_mngr; + nrf_balloc_t const * const p_pool; + + +} nrf_twi_sensor_t; + +/** + * @brief Struct describing sensor read command. + * + * @note For internal use only. + */ +typedef struct +{ + uint8_t reg_address; + nrf_twi_mngr_transfer_t transfers[2]; + nrf_twi_mngr_transaction_t transaction; + nrf_twi_sensor_reg_cb_t user_cb; + nrf_twi_sensor_t const * p_instance; +} nrf_twi_sensor_read_cmd_t; + +/** + * @brief Struct describing sensor write command. + * + * @note For internal use only. + */ +typedef struct +{ + uint8_t send_msg[NRF_TWI_SENSOR_SEND_BUF_SIZE]; + nrf_twi_mngr_transfer_t transfer; + nrf_twi_mngr_transaction_t transaction; + nrf_twi_sensor_t const * p_instance; +} nrf_twi_sensor_write_cmd_t; + +/** + * @brief Union for sensor commands. Needed in buffer definition. + * + * @note For internal use only. + */ +typedef union +{ + nrf_twi_sensor_read_cmd_t read; + nrf_twi_sensor_write_cmd_t write; +} nrf_twi_sensor_cmd_t; + + +/** + * @brief Macro creating common twi sensor instance. + * + * Data in structure is used for basic communication with sensors. + * THere should be one instance per TWI bus. + * + * @param[in] twi_sensor_name TWI common sensor instance name. + * @param[in] p_nrf_twi_mngr Pointer to TWI Manager instance. @ref NRF_TWI_MNGR_DEF + * @param[in] msg_buff_size Size of buffer used in communication + * + * @note Buffer size should be less or equal to TWI manager queue size. + * Minimum buffer size can be found after checking utilization of sensor buffer. + */ +#define NRF_TWI_SENSOR_DEF(twi_sensor_name, p_nrf_twi_mngr, msg_buff_size) \ + NRF_BALLOC_DEF(CONCAT_2(twi_sensor_name,_pool), sizeof(nrf_twi_sensor_cmd_t), msg_buff_size);\ + static nrf_twi_sensor_t twi_sensor_name = \ + { \ + .p_twi_mngr = p_nrf_twi_mngr, \ + .p_pool = &CONCAT_2(twi_sensor_name,_pool) \ + } + +/** + * @brief Macro for defining TWI manager read transfer. + * + * @note For internal use only. + */ +#define NRF_TWI_SENSOR_READ(p_reg_addr, p_buffer, byte_cnt) \ + NRF_TWI_MNGR_WRITE(0x00, p_reg_addr, 1, NRF_TWI_MNGR_NO_STOP), \ + NRF_TWI_MNGR_READ (0x00, p_buffer, byte_cnt, 0) + +/** + * @brief Macro for defining TWI manager write transfer. + * + * @note For internal use only. + */ +#define NRF_TWI_SENSOR_WRITE(p_buffer, byte_cnt) \ + NRF_TWI_MNGR_WRITE(0x00, p_buffer, byte_cnt, 0) + + +/** + * @brief Macro for assigning sensor address to transfers. + * + * @param[in] _transfers Transfers array. + * @param[in] _sensor_addr Desired sensor address. + * + * @note For internal use only. + */ +#define NRF_TWI_SENSOR_ADDRESS_SET(_transfers, _sensor_addr) \ + for (uint8_t i = 0; i < ARRAY_SIZE(_transfers); i++) \ + { \ + if (i % 2 == 0) \ + { \ + transfers[i].operation = NRF_TWI_MNGR_WRITE_OP(_sensor_addr); \ + } \ + else \ + { \ + transfers[i].operation = NRF_TWI_MNGR_READ_OP(_sensor_addr); \ + } \ + } + +/** + * @brief Macro for setting parameters in sensor register. + * + * @param[in,out] _register Register to be altered. + * @param[in] _msk Parameter mask. + * @param[in] _pos Parameter position. + * @param[in] _val Parameter value to be set. + */ +#define NRF_TWI_SENSOR_REG_SET(_register, _msk, _pos, _val) \ + _register &= ~(_msk); \ + _register |= ((_msk) & ((_val) << (_pos))) + + +/** + * @brief Macro for getting parameters from sensor register. + * + * @param[in] _register Register to be processed. + * @param[in] _msk Parameter mask. + * @param[in] _pos Parameter position. + * + * @note For usage with registers read using nrf_twi_sensor_register_read function. + * + * @return Parameter value + */ +#define NRF_TWI_SENSOR_REG_VAL_GET(_register, _msk, _pos) \ + (((_register) & (_msk)) >> (_pos)) + +/** + * @brief Function for initialization of sensor common instance. + * + * @note TWI Manager should be initialized before @ref nrf_twi_mngr_init + * @param[in] p_twi_sensor Pointer to sensor common instance. + * + * @return Error code from nrf_balloc @ref nrf_balloc_init + */ +ret_code_t nrf_twi_sensor_init(nrf_twi_sensor_t * p_twi_sensor); + +/** + * @brief Function for reading sensor register. + * + * @param[in] p_instance Pointer to sensor instance. + * @param[in] sensor_addr Sensor address. + * @param[in] reg_address Register address. + * @param[in] user_cb User callback. + * @param[out] p_data Pointer to data save location. + * @param[in] length Number of bytes to read. + * + * @retval NRF_ERROR_NO_MEM If there is no memory in sensor buffer + * @retval NRF_SUCCESS If the operation was successful. + * @retval other Error code from TWI manager @ref nrf_twi_mngr_schedule. + */ +ret_code_t nrf_twi_sensor_reg_read(nrf_twi_sensor_t const * p_instance, + uint8_t sensor_addr, + uint8_t reg_address, + nrf_twi_sensor_reg_cb_t user_cb, + uint8_t * p_data, + uint8_t length); + +/** + * @brief Function for writing to sensor. + * + * @param[in] p_instance Pointer to sensor instance. + * @param[in] sensor_addr Sensor address. + * @param[in] p_data Pointer to data to be written. + * @param[in] length Number of bytes to write. + * @param[in] copy_flag If true, p_data is copied into internal static buffer. + * + * @note Most of the time, to write to sensors register, first byte in p_data has to be + * register address. + * + * @retval NRF_ERROR_NO_MEM If there is no memory in sensor buffer + * @retval NRF_ERROR_INVALID_LENGTH If trying to copy more bytes than + * NRF_TWI_SENSOR_SEND_BUF_SIZE. + * @retval NRF_SUCCESS If the operation was successful. + * @retval other Error code from TWI manager @ref nrf_twi_mngr_schedule. + */ +ret_code_t nrf_twi_sensor_write(nrf_twi_sensor_t const * p_instance, + uint8_t sensor_addr, + uint8_t const * p_data, + uint8_t length, + bool copy_flag); + +/** + * @brief Function for writing to sensor register. + * + * @param[in] p_instance Pointer to sensor instance. + * @param[in] sensor_addr Sensor address. + * @param[in] reg_address Register address. + * @param[in] p_data Pointer to data to be written. + * @param[in] length Number of bytes to write. + * + * @note Data is copied into internal buffer. + * Length has to be less than NRF_TWI_SENSOR_SEND_BUF_SIZE. + * + * @retval NRF_ERROR_NO_MEM If there is no memory in sensor buffer + * @retval NRF_ERROR_INVALID_LENGTH If trying to copy more bytes than + * NRF_TWI_SENSOR_SEND_BUF_SIZE - 1. + * One byte reserved for register address. + * @retval NRF_SUCCESS If the operation was successful. + * @retval other Error code from TWI manager @ref nrf_twi_mngr_schedule. + */ +ret_code_t nrf_twi_sensor_reg_write(nrf_twi_sensor_t const * p_instance, + uint8_t sensor_addr, + uint8_t reg_address, + uint8_t * p_data, + uint8_t length); + +/** + * @brief Function for getting maximum utilization of sensor buffer. + * + * @param[in] p_twi_sensor Pointer to sensor buffer. + * + * @return Maximum utilization. + */ +__STATIC_INLINE uint8_t nrf_twi_sensor_max_util_get(nrf_twi_sensor_t const * p_twi_sensor); +#ifndef SUPPRESS_INLINE_IMPLEMENTATION +__STATIC_INLINE uint8_t nrf_twi_sensor_max_util_get(nrf_twi_sensor_t const * p_twi_sensor) +{ + return nrf_balloc_max_utilization_get(p_twi_sensor->p_pool); +} +#endif //SUPPRESS_INLINE_IMPLEMENTATION + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SENSOR_COMMON_H + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart.c similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart.c index d987412..90874bd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(APP_UART) @@ -53,12 +53,16 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context) { if (p_event->type == NRF_DRV_UART_EVT_RX_DONE) { - app_uart_evt_t app_uart_event; - app_uart_event.evt_type = APP_UART_DATA; - app_uart_event.data.value = p_event->data.rxtx.p_data[0]; + // Received bytes counter has to be checked, because there could be event from RXTO interrupt + if (p_event->data.rxtx.bytes) + { + app_uart_evt_t app_uart_event; + app_uart_event.evt_type = APP_UART_DATA; + app_uart_event.data.value = p_event->data.rxtx.p_data[0]; + rx_done = true; + m_event_handler(&app_uart_event); + } (void)nrf_drv_uart_rx(&app_uart_inst, rx_buffer, 1); - rx_done = true; - m_event_handler(&app_uart_event); } else if (p_event->type == NRF_DRV_UART_EVT_ERROR) { @@ -104,13 +108,6 @@ uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params, // Turn on receiver if RX pin is connected if (p_comm_params->rx_pin_no != UART_PIN_DISCONNECTED) { -#ifdef UARTE_PRESENT - if (!config.use_easy_dma) -#endif - { - nrf_drv_uart_rx_enable(&app_uart_inst); - } - return nrf_drv_uart_rx(&app_uart_inst, rx_buffer,1); } else diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart.h index 2614faf..dd906cd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart_fifo.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart_fifo.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart_fifo.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart_fifo.c index 503b52c..52239cd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/app_uart_fifo.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/app_uart_fifo.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(APP_UART) @@ -71,6 +71,14 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context) switch (p_event->type) { case NRF_DRV_UART_EVT_RX_DONE: + // If 0, then this is a RXTO event with no new bytes. + if(p_event->data.rxtx.bytes == 0) + { + // A new start RX is needed to continue to receive data + (void)nrf_drv_uart_rx(&app_uart_inst, rx_buffer, 1); + break; + } + // Write received byte to FIFO. err_code = app_fifo_put(&m_rx_fifo, p_event->data.rxtx.p_data[0]); if (err_code != NRF_SUCCESS) @@ -166,13 +174,6 @@ uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params, // Turn on receiver if RX pin is connected if (p_comm_params->rx_pin_no != UART_PIN_DISCONNECTED) { -#ifdef UARTE_PRESENT - if (!config.use_easy_dma) -#endif - { - nrf_drv_uart_rx_enable(&app_uart_inst); - } - return nrf_drv_uart_rx(&app_uart_inst, rx_buffer,1); } else diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/retarget.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/retarget.c similarity index 94% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/retarget.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/retarget.c index 11a8eb1..23b2012 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/uart/retarget.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/uart/retarget.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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" /** @file @@ -97,6 +97,15 @@ int __getchar(FILE * p_file) return input; } +#if defined(__SES_VERSION) && (__SES_VERSION >= 34000) +int __putchar(int ch, __printf_tag_ptr tag_ptr) +{ + UNUSED_PARAMETER(tag_ptr); + + UNUSED_VARIABLE(app_uart_put((uint8_t)ch)); + return ch; +} +#else int __putchar(int ch, FILE * p_file) { UNUSED_PARAMETER(p_file); @@ -104,6 +113,7 @@ int __putchar(int ch, FILE * p_file) UNUSED_VARIABLE(app_uart_put((uint8_t)ch)); return ch; } +#endif #elif defined(__GNUC__) && !defined(__SES_ARM) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd.c index 860b090..23a8c4b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,18 +35,20 @@ * 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_config.h" -#if APP_USBD_ENABLED #include "sdk_common.h" +#if NRF_MODULE_ENABLED(APP_USBD) + #include "app_usbd.h" #include "app_usbd_core.h" +#include "app_usbd_request.h" #include "nrf_power.h" #include "nrf_drv_clock.h" -#if APP_USBD_EVENT_QUEUE_ENABLE +#include "nrf_drv_power.h" +#if APP_USBD_CONFIG_EVENT_QUEUE_ENABLE #include "nrf_atfifo.h" +#include "nrf_atomic.h" #endif #define NRF_LOG_MODULE_NAME app_usbd @@ -65,7 +67,7 @@ NRF_LOG_MODULE_REGISTER(); /* Base variables tests */ /* Check event of app_usbd_event_type_t enumerator */ -STATIC_ASSERT((int32_t)APP_USBD_EVT_FIRST_APP == (int32_t)NRF_DRV_USBD_EVT_CNT); +STATIC_ASSERT((int32_t)APP_USBD_EVT_FIRST_POWER == (int32_t)NRF_DRV_USBD_EVT_CNT); STATIC_ASSERT(sizeof(app_usbd_event_type_t) == sizeof(nrf_drv_usbd_event_type_t)); STATIC_ASSERT(sizeof(app_usbd_descriptor_header_t) == 2); @@ -94,14 +96,14 @@ static uint16_t m_last_frame; #endif /** - * @brief Variable type for endpoint configuration + * @brief Variable type for endpoint configuration. * * Each endpoint would have assigned this type of configuration structure. */ typedef struct { /** - * @brief The class instance + * @brief The class instance. * * The pointer to the class instance that is connected to the endpoint. */ @@ -118,17 +120,48 @@ typedef struct app_usbd_ep_event_handler_t event_handler; }app_usbd_ep_conf_t; -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) + /** - * @brief Event queue + * @brief Internal event with SOF counter. + */ +typedef struct +{ + app_usbd_internal_evt_t evt; //!< Internal event type + +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) \ + || defined(__SDK_DOXYGEN__) + uint16_t sof_cnt; //!< Number of the SOF events that appears before current event + uint16_t start_frame; //!< Number of the SOF frame that starts this event +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + +} app_usbd_internal_queue_evt_t; + +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +/** + * @brief Event queue. * - * The queue with events to be processed + * The queue with events to be processed. */ -NRF_ATFIFO_DEF(m_event_queue, app_usbd_internal_evt_t, APP_USBD_EVENT_QUEUE_SIZE); +NRF_ATFIFO_DEF(m_event_queue, app_usbd_internal_queue_evt_t, APP_USBD_CONFIG_EVENT_QUEUE_SIZE); + +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) \ + || defined(__SDK_DOXYGEN__) + +/** @brief SOF events counter */ +static nrf_atomic_u32_t m_sof_events_cnt; + +/** @brief SOF Frame counter */ +static uint16_t m_event_frame; + +/* Limit of SOF events stacked until warning message. */ +#define APP_USBD_SOF_WARNING_LIMIT 500 +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + // || defined(__SDK_DOXYGEN__) + #endif /** - * @brief Instances connected with IN endpoints + * @brief Instances connected with IN endpoints. * * Array of instance pointers connected with every IN endpoint. * @sa m_epout_instances @@ -136,7 +169,7 @@ NRF_ATFIFO_DEF(m_event_queue, app_usbd_internal_evt_t, APP_USBD_EVENT_QUEUE_SIZE static app_usbd_ep_conf_t m_epin_conf[NRF_USBD_EPIN_CNT]; /** - * @brief Instances connected with OUT endpoints + * @brief Instances connected with OUT endpoints. * * Array of instance pointers connected with every OUT endpoint. * @sa m_epin_instances @@ -144,7 +177,7 @@ static app_usbd_ep_conf_t m_epin_conf[NRF_USBD_EPIN_CNT]; static app_usbd_ep_conf_t m_epout_conf[NRF_USBD_EPIN_CNT]; /** - * @brief Beginning of classes list + * @brief Beginning of classes list. * * All enabled in current configuration instances are connected into * a single linked list chain. @@ -154,20 +187,27 @@ static app_usbd_ep_conf_t m_epout_conf[NRF_USBD_EPIN_CNT]; static app_usbd_class_inst_t const * m_p_first_cinst; /** - * @brief Classes list that requires SOF events + * @brief Classes list that requires SOF events. * - * @todo RK Implement and documentation + * Pointer to first class that requires SOF events. */ static app_usbd_class_inst_t const * m_p_first_sof_cinst; +/** + * @brief Classes list that require SOF events in interrupt. + * + * Pointer to first class that requires SOF events in interrupt. + */ +static app_usbd_class_inst_t const * m_p_first_sof_interrupt_cinst; + /** * @brief Default configuration (when NULL is passed to @ref app_usbd_init). */ static const app_usbd_config_t m_default_conf = { -#if (!(APP_USBD_EVENT_QUEUE_ENABLE)) || defined(__SDK_DOXYGEN__) +#if (!(APP_USBD_CONFIG_EVENT_QUEUE_ENABLE)) || defined(__SDK_DOXYGEN__) .ev_handler = app_usbd_event_execute, #endif -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) .ev_isr_handler = NULL, #endif .ev_state_proc = NULL, @@ -175,7 +215,7 @@ static const app_usbd_config_t m_default_conf = { }; /** - * @brief SUSPEND state machine states + * @brief SUSPEND state machine states. * * The enumeration of internal SUSPEND state machine states. */ @@ -193,14 +233,14 @@ typedef enum }app_usbd_sustate_t; /** - * @brief Current suspend state + * @brief Current suspend state. * - * The state of the suspend state machine + * The state of the suspend state machine. */ static app_usbd_sustate_t m_sustate; /** - * @brief Remote wake-up register/unregister + * @brief Remote wake-up register/unregister. * * Counter incremented when appended instance required remote wake-up functionality. * It should be decremented when the class is removed. @@ -218,12 +258,12 @@ static app_usbd_config_t m_current_conf; * * @ref app_usbd_class_interface_t::event_handler * - * @param[in] p_cinst Class instance - * @param[in] p_event Event passed to class instance + * @param[in] p_cinst Class instance. + * @param[in] p_event Event passed to class instance. * * @return Standard error code @ref ret_code_t - * @retval NRF_SUCCESS event handled successfully - * @retval NRF_ERROR_NOT_SUPPORTED unsupported event + * @retval NRF_SUCCESS event handled successfully. + * @retval NRF_ERROR_NOT_SUPPORTED unsupported event. * */ static inline ret_code_t class_event_handler(app_usbd_class_inst_t const * const p_cinst, app_usbd_complex_evt_t const * const p_event) @@ -234,7 +274,16 @@ static inline ret_code_t class_event_handler(app_usbd_class_inst_t const * cons return p_cinst->p_class_methods->event_handler(p_cinst, p_event); } -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +static inline void class_sof_interrupt_handler(app_usbd_class_inst_t const * const p_cinst, + app_usbd_complex_evt_t const * const p_event) +{ + ASSERT(p_cinst != NULL); + ASSERT(p_cinst->p_data != NULL); + ASSERT(p_cinst->p_data->sof_handler != NULL); + p_cinst->p_data->sof_handler(p_event->drv_evt.data.sof.framecnt); +} + /** * @brief User event handler call (passed via configuration). * @@ -251,7 +300,7 @@ static inline void user_event_handler(app_usbd_internal_evt_t const * const p_ev #endif /** - * @brief User event processor call (passed via configuration) + * @brief User event processor call (passed via configuration). * * @param event Event type. */ @@ -264,63 +313,90 @@ static inline void user_event_state_proc(app_usbd_event_type_t event) } /** - * @brief Class interface call: get descriptors - * - * @ref app_usbd_class_interface_t::get_descriptors + * @brief Find a specified descriptor. * - * @param[in] p_inst Class instance - * @param[out] p_size Descriptors size + * @param[in] p_cinst Class instance. + * @param[in] desc_type Descriptor type @ref app_usbd_descriptor_t + * @param[in] desc_index Descriptor index. + * @param[out] p_desc Pointer to escriptor. + * @param[out] p_desc_len Length of descriptor. * - * @return Class descriptors start address + * @return Standard error code @ref ret_code_t + * @retval NRF_SUCCESS Descriptor successfully found. + * @retval NRF_ERROR_NOT_FOUND Descriptor not found. * */ -static inline const void * class_get_descriptors(app_usbd_class_inst_t const * const p_cinst, - size_t * p_size) +ret_code_t app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_cinst, + uint8_t desc_type, + uint8_t desc_index, + uint8_t * p_desc, + size_t * p_desc_len) { - ASSERT(p_cinst != NULL); - ASSERT(p_cinst->p_class_methods != NULL); - ASSERT(p_cinst->p_class_methods->get_descriptors != NULL); - return p_cinst->p_class_methods->get_descriptors(p_cinst, p_size); -} - -const void * app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_cinst, - uint8_t desc_type, - uint8_t desc_index, - size_t * p_desc_len) -{ - app_usbd_descriptor_header_t const * p_header; - uint8_t const * p_raw = class_get_descriptors(p_cinst, p_desc_len); - if (p_raw == NULL) + app_usbd_class_descriptor_ctx_t siz; + APP_USBD_CLASS_DESCRIPTOR_INIT(&siz); + uint32_t total_size = 0; + while(p_cinst->p_class_methods->feed_descriptors(&siz, p_cinst, NULL, sizeof(uint8_t))) { - return NULL; + total_size++; } - size_t pos = 0; + uint8_t cur_len = 0; + uint32_t cur_size = 0; + uint8_t index = 0; - while (pos < *p_desc_len) + app_usbd_class_descriptor_ctx_t descr; + APP_USBD_CLASS_DESCRIPTOR_INIT(&descr); + + while(cur_size < total_size) { - p_header = (app_usbd_descriptor_header_t const *)(p_raw + pos); - if (p_header->bDescriptorType == desc_type) + /* First byte of a descriptor is its size */ + UNUSED_RETURN_VALUE(p_cinst->p_class_methods->feed_descriptors(&descr, + p_cinst, + &cur_len, + sizeof(uint8_t))); + + /* Second byte is type of the descriptor */ + uint8_t type; + UNUSED_RETURN_VALUE(p_cinst->p_class_methods->feed_descriptors(&descr, + p_cinst, + &type, + sizeof(uint8_t))); + + if(type == desc_type) { - if (desc_index == index) + if(index == desc_index) { - *p_desc_len = p_header->bLength; - return p_header; + /* Copy the length of descriptor to *p_desc_len */ + *p_desc_len = cur_len; + /* Two first bytes of descriptor have already been fed - copy them to *p_desc */ + *p_desc++ = cur_len; + *p_desc++ = desc_type; + /* Copy the rest of descriptor to *p_desc */ + UNUSED_RETURN_VALUE(p_cinst->p_class_methods->feed_descriptors(&descr, + p_cinst, + p_desc, + cur_len-2)); + return NRF_SUCCESS; + } + else + { + index++; } - - index++; } - - pos += p_header->bLength; + /* Fast-forward through unmatched descriptor */ + UNUSED_RETURN_VALUE(p_cinst->p_class_methods->feed_descriptors(&descr, + p_cinst, + NULL, + cur_len-2)); + cur_size += cur_len; } - - return NULL; + return NRF_ERROR_NOT_FOUND; } /** - * @brief Access into selected endpoint configuration structure + * @brief Access into selected endpoint configuration structure. * - * @param ep Endpoint address - * @return A pointer to the endpoint configuration structure + * @param ep Endpoint address. + * @return A pointer to the endpoint configuration structure. * * @note This function would assert when endpoint number is not correct and debugging is enabled. */ @@ -341,11 +417,11 @@ static app_usbd_ep_conf_t * app_usbd_ep_conf_access(nrf_drv_usbd_ep_t ep) } /** - * @brief Accessing instance connected with selected endpoint + * @brief Accessing instance connected with selected endpoint. * - * @param ep Endpoint number + * @param ep Endpoint number. * - * @return The pointer to the instance connected with endpoint + * @return The pointer to the instance connected with endpoint. */ static inline app_usbd_class_inst_t const * app_usbd_ep_instance_get(nrf_drv_usbd_ep_t ep) { @@ -353,12 +429,12 @@ static inline app_usbd_class_inst_t const * app_usbd_ep_instance_get(nrf_drv_usb } /** - * @brief Connect instance with selected endpoint + * @brief Connect instance with selected endpoint. * * This function configures instance connected to endpoint but also sets * default event handler function pointer. * - * @param ep Endpoint number + * @param ep Endpoint number. * @param p_cinst The instance to connect into the selected endpoint. * NULL if endpoint is going to be disconnected. * @@ -381,7 +457,7 @@ static void app_usbd_ep_instance_set(nrf_drv_usbd_ep_t ep, app_usbd_class_inst_t } /** - * @brief Call the core handler + * @brief Call the core handler. * * Core instance is special kind of instance that is connected only to endpoint 0. * It is not present in instance list. @@ -398,28 +474,97 @@ static inline ret_code_t app_usbd_core_handler_call(app_usbd_internal_evt_t cons /** - * @brief Add event for execution + * @brief Add event for execution. * * Dependent on configuration event would be executed in place or would be added into queue * to be executed later. * - * @param p_event Event to be executed + * @param p_event_input Event to be executed. */ -static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_event) +static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_event_input) { -#if (APP_USBD_EVENT_QUEUE_ENABLE) + app_usbd_internal_evt_t const * p_event = p_event_input; + + + if (p_event->type == APP_USBD_EVT_DRV_SETUP) + { + uint8_t bRequest = nrf_usbd_setup_brequest_get(); + uint8_t bmRequestType = nrf_usbd_setup_bmrequesttype_get(); + + if ((bmRequestType == app_usbd_setup_req_val( + APP_USBD_SETUP_REQREC_DEVICE, + APP_USBD_SETUP_REQTYPE_STD, + APP_USBD_SETUP_REQDIR_OUT)) + && (bRequest == APP_USBD_SETUP_STDREQ_SET_ADDRESS)) + { + static const app_usbd_internal_evt_t event_setaddress = + { + .type = APP_USBD_EVT_SETUP_SETADDRESS, + }; + p_event = &event_setaddress; + } + } + +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) + + if (p_event->app_evt.type == APP_USBD_EVT_DRV_SOF) + { + /* Propagate SOF event to classes that need it in interrupt */ + app_usbd_class_inst_t const * p_inst = app_usbd_class_sof_interrupt_first_get(); + while (NULL != p_inst) + { + class_sof_interrupt_handler(p_inst, (app_usbd_complex_evt_t const *)p_event); + p_inst = app_usbd_class_sof_interrupt_next_get(p_inst); + } + +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + CRITICAL_REGION_ENTER(); + if (m_sof_events_cnt == 0) + { + m_event_frame = p_event->drv_evt.data.sof.framecnt; + } + UNUSED_RETURN_VALUE(nrf_atomic_u32_add(&m_sof_events_cnt, 1)); + CRITICAL_REGION_EXIT(); + + user_event_handler(p_event, true); + if (m_sof_events_cnt == APP_USBD_SOF_WARNING_LIMIT) + { + NRF_LOG_WARNING("Stacked over %d SOF events.", APP_USBD_SOF_WARNING_LIMIT); + } + return; + +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_INTERRUPT) + + user_event_handler(p_event, false); + app_usbd_event_execute(p_event); + return; + +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_INTERRUPT) + } + nrf_atfifo_item_put_t cx; - app_usbd_internal_evt_t * p_event_item = nrf_atfifo_item_alloc(m_event_queue, &cx); + app_usbd_internal_queue_evt_t * p_event_item = nrf_atfifo_item_alloc(m_event_queue, &cx); + if (NULL != p_event_item) { - bool visible; - *p_event_item = *p_event; - visible = nrf_atfifo_item_put(m_event_queue, &cx); - user_event_handler(p_event, visible); + bool visible; + p_event_item->evt = *p_event; + +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + CRITICAL_REGION_ENTER(); + p_event_item->start_frame = m_event_frame - m_sof_events_cnt + 1; + p_event_item->sof_cnt = nrf_atomic_u32_fetch_store(&m_sof_events_cnt, 0); + CRITICAL_REGION_EXIT(); +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + + visible = nrf_atfifo_item_put(m_event_queue, &cx); + user_event_handler(p_event, visible); } else { - NRF_LOG_ERROR("Event queue full."); + NRF_LOG_ERROR("Event queue full."); } #else m_current_conf.ev_handler(p_event); @@ -427,10 +572,51 @@ static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_ev } /** - * @brief Event handler + * @brief Power event handler. * - * The function that pushes the event into the queue - * @param p_event + * The function that pushes power events into the queue. + * @param p_event Event from power driver to map into APP_USBD_EVT_POWER_ event. + */ +#if APP_USBD_CONFIG_POWER_EVENTS_PROCESS +static void app_usbd_power_event_handler(nrf_drv_power_usb_evt_t event) +{ + switch(event) + { + case NRF_DRV_POWER_USB_EVT_DETECTED: + { + static const app_usbd_internal_evt_t ev = { + .type = APP_USBD_EVT_POWER_DETECTED + }; + app_usbd_event_add(&ev); + break; + } + case NRF_DRV_POWER_USB_EVT_REMOVED: + { + static const app_usbd_internal_evt_t ev = { + .type = APP_USBD_EVT_POWER_REMOVED + }; + app_usbd_event_add(&ev); + break; + } + case NRF_DRV_POWER_USB_EVT_READY: + { + static const app_usbd_internal_evt_t ev = { + .type = APP_USBD_EVT_POWER_READY + }; + app_usbd_event_add(&ev); + break; + } + default: + ASSERT(false); + } +} +#endif + +/** + * @brief Event handler. + * + * The function that pushes the event into the queue. + * @param p_event Event to push. */ static void app_usbd_event_handler(nrf_drv_usbd_evt_t const * const p_event) { @@ -438,11 +624,11 @@ static void app_usbd_event_handler(nrf_drv_usbd_evt_t const * const p_event) } /** - * @brief HF clock ready event handler + * @brief HF clock ready event handler. * - * Function that is called when high frequency clock is started + * Function that is called when high frequency clock is started. * - * @param event Event type that comes from clock driver + * @param event Event type that comes from clock driver. */ static void app_usbd_hfclk_ready(nrf_drv_clock_evt_type_t event) { @@ -454,62 +640,62 @@ static void app_usbd_hfclk_ready(nrf_drv_clock_evt_type_t event) } /** - * @brief Check if the HFCLK was requested in selected suspend state machine state + * @brief Check if the HFCLK was requested in selected suspend state machine state. * * - * @param sustate State to be checked + * @param sustate State to be checked. * - * @retval true High frequency clock was requested in selected state - * @retval false High frequency clock was released in selected state + * @retval true High frequency clock was requested in selected state. + * @retval false High frequency clock was released in selected state. */ static inline bool app_usbd_sustate_with_requested_hfclk(app_usbd_sustate_t sustate) { switch(sustate) { - case SUSTATE_STOPPED: return false; - case SUSTATE_STARTED: return false; - case SUSTATE_ACTIVE: return true; - case SUSTATE_SUSPENDING: return false; - case SUSTATE_SUSPEND: return false; - case SUSTATE_RESUMING: return true; - case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return true; - case SUSTATE_WAKINGUP_WAITING_HFCLK: return true; - case SUSTATE_WAKINGUP_WAITING_WREQ: return true; + case SUSTATE_STOPPED: return false; + case SUSTATE_STARTED: return false; + case SUSTATE_ACTIVE: return true; + case SUSTATE_SUSPENDING: return false; + case SUSTATE_SUSPEND: return false; + case SUSTATE_RESUMING: return true; + case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return true; + case SUSTATE_WAKINGUP_WAITING_HFCLK: return true; + case SUSTATE_WAKINGUP_WAITING_WREQ: return true; default: return false; } } /** - * @brief Check it the HFCLK is running in selected suspend state machine state + * @brief Check it the HFCLK is running in selected suspend state machine state. * - * @param sustate State to be checked + * @param sustate State to be checked. * - * @retval true High frequency clock is running in selected state - * @retval false High frequency clock is released in selected state + * @retval true High frequency clock is running in selected state. + * @retval false High frequency clock is released in selected state. */ static inline bool app_usbd_sustate_with_running_hfclk(app_usbd_sustate_t sustate) { switch(sustate) { - case SUSTATE_STOPPED: return false; - case SUSTATE_STARTED: return false; - case SUSTATE_ACTIVE: return true; - case SUSTATE_SUSPENDING: return false; - case SUSTATE_SUSPEND: return false; - case SUSTATE_RESUMING: return false; - case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return false; - case SUSTATE_WAKINGUP_WAITING_HFCLK: return false; - case SUSTATE_WAKINGUP_WAITING_WREQ: return true; + case SUSTATE_STOPPED: return false; + case SUSTATE_STARTED: return false; + case SUSTATE_ACTIVE: return true; + case SUSTATE_SUSPENDING: return false; + case SUSTATE_SUSPEND: return false; + case SUSTATE_RESUMING: return false; + case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return false; + case SUSTATE_WAKINGUP_WAITING_HFCLK: return false; + case SUSTATE_WAKINGUP_WAITING_WREQ: return true; default: return false; } } /** - * @brief Get current suspend state machine state + * @brief Get current suspend state machine state. * - * @return The state of the suspend state machine + * @return The state of the suspend state machine. */ static inline app_usbd_sustate_t sustate_get(void) { @@ -517,9 +703,9 @@ static inline app_usbd_sustate_t sustate_get(void) } /** - * @brief Set current suspend state machine state + * @brief Set current suspend state machine state. * - * @param sustate The requested state of the state machine + * @param sustate The requested state of the state machine. */ static inline void sustate_set(app_usbd_sustate_t sustate) { @@ -553,14 +739,19 @@ static inline void sustate_set(app_usbd_sustate_t sustate) } /** - * @brief Default selection function for interface + * @brief Default selection function for interface. * - * This function just enables and clears interface endpoints + * This function just enables and clears interface endpoints. * - * @param p_inst See the documentation for @ref app_usbd_iface_select - * @param iface_idx See the documentation for @ref app_usbd_iface_select - * @param alternate See the documentation for @ref app_usbd_iface_select - * @return + * @param[in] p_inst Class instance. + * @param[in] iface_idx Interface index. + * @param[in] alternate Interface alternate setting. + * + * @note Currently only alternate setting 0 is supported. + * + * @return Standard error code @ref ret_code_t + * @retval NRF_SUCCESS Endpoints enabled and cleared. + * @retval NRF_ERROR_INVALID_PARAM Unsupported alternate selected. */ static inline ret_code_t default_iface_select( app_usbd_class_inst_t const * const p_inst, @@ -587,12 +778,12 @@ static inline ret_code_t default_iface_select( } /** - * @brief Default deselection function for interface + * @brief Default deselection function for interface. * * This function just disables all interface endpoints. * - * @param p_inst See the documentation for @ref app_usbd_iface_deselect - * @param iface_idx See the documentation for @ref app_usbd_iface_deselect + * @param[in] p_inst Class instance. + * @param[in] iface_idx Interface index. */ static inline void default_iface_deselect( app_usbd_class_inst_t const * const p_inst, @@ -623,9 +814,10 @@ uint32_t app_usbd_sof_timestamp_get(void) ret_code_t app_usbd_init(app_usbd_config_t const * p_config) { + ASSERT(nrf_drv_clock_init_check()); ret_code_t ret; -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) ret = NRF_ATFIFO_INIT(m_event_queue); if (NRF_SUCCESS != ret) { @@ -633,14 +825,20 @@ ret_code_t app_usbd_init(app_usbd_config_t const * p_config) } #endif - UNUSED_RETURN_VALUE(nrf_drv_clock_init()); - + /* This is called at the beginning to secure multiple calls to init function */ ret = nrf_drv_usbd_init(app_usbd_event_handler); if (NRF_SUCCESS != ret) { return ret; } + /* Clear the variables */ + m_sustate = SUSTATE_STOPPED; + m_p_first_cinst = NULL; + m_p_first_sof_cinst = NULL; + memset(m_epin_conf , 0, sizeof(m_epin_conf )); + memset(m_epout_conf, 0, sizeof(m_epout_conf)); + /* Save the new configuration */ if (p_config == NULL) { m_current_conf = m_default_conf; @@ -650,12 +848,21 @@ ret_code_t app_usbd_init(app_usbd_config_t const * p_config) m_current_conf = *p_config; } - /* Clear variables */ - m_sustate = SUSTATE_STOPPED; - m_p_first_cinst = NULL; - m_p_first_sof_cinst = NULL; - memset(m_epin_conf , 0, sizeof(m_epin_conf )); - memset(m_epout_conf, 0, sizeof(m_epout_conf)); +#if (!(APP_USBD_CONFIG_EVENT_QUEUE_ENABLE)) + if(m_current_conf.ev_handler == NULL) + { + m_current_conf.ev_handler = m_default_conf.ev_handler; + } +#endif + +#if APP_USBD_CONFIG_POWER_EVENTS_PROCESS + ret = nrf_drv_power_init(NULL); + if ((ret != NRF_SUCCESS) && (ret != NRF_ERROR_MODULE_ALREADY_INITIALIZED)) + { + /* This should never happen */ + APP_ERROR_HANDLER(ret); + } +#endif /*Pin core class to required endpoints*/ uint8_t iface_idx; @@ -677,17 +884,25 @@ ret_code_t app_usbd_init(app_usbd_config_t const * p_config) .type = APP_USBD_EVT_INST_APPEND }; - return class_event_handler(p_inst, (app_usbd_complex_evt_t const *)(&evt_data)); + ret = class_event_handler(p_inst, (app_usbd_complex_evt_t const *)(&evt_data)); + if (NRF_SUCCESS != ret) + { + UNUSED_RETURN_VALUE(nrf_drv_usbd_uninit()); + return ret; + } + + return NRF_SUCCESS; } ret_code_t app_usbd_uninit(void) { - ret_code_t ret; +#if APP_USBD_CONFIG_POWER_EVENTS_PROCESS + nrf_drv_power_usbevt_uninit(); +#endif - ret = nrf_drv_usbd_uninit(); - if (NRF_SUCCESS != ret) - return ret; + /* We get this error at very beginning but it would be used at the end of the function */ + const ret_code_t ret = nrf_drv_usbd_uninit(); /* Unchain instance list */ app_usbd_class_inst_t const * * pp_inst; @@ -707,6 +922,15 @@ ret_code_t app_usbd_uninit(void) (*pp_inst) = NULL; pp_inst = pp_next; } + + /* Unchain SOF interrupt list */ + pp_inst = &m_p_first_sof_interrupt_cinst; + while (NULL != (*pp_inst)) + { + app_usbd_class_inst_t const * * pp_next = &app_usbd_class_data_access(*pp_inst)->p_sof_next; + (*pp_inst) = NULL; + pp_inst = pp_next; + } /* Clear all endpoints configurations */ memset(m_epin_conf , 0, sizeof(m_epin_conf )); @@ -718,6 +942,30 @@ ret_code_t app_usbd_uninit(void) } +#if APP_USBD_CONFIG_POWER_EVENTS_PROCESS +ret_code_t app_usbd_power_events_enable(void) +{ + if (!nrf_drv_usbd_is_initialized() || nrf_drv_usbd_is_enabled()) + { + return NRF_ERROR_INVALID_STATE; + } + + ASSERT((!APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || (USBD_CONFIG_IRQ_PRIORITY == POWER_CONFIG_IRQ_PRIORITY)); + + ret_code_t ret; + static const nrf_drv_power_usbevt_config_t config = + { + .handler = app_usbd_power_event_handler + }; + + ret = nrf_drv_power_usbevt_init(&config); + APP_ERROR_CHECK(ret); + + return NRF_SUCCESS; +} +#endif /* APP_USBD_CONFIG_POWER_EVENTS_PROCESS */ + + void app_usbd_enable(void) { nrf_drv_usbd_enable(); @@ -735,6 +983,29 @@ void app_usbd_start(void) { ASSERT(nrf_drv_usbd_is_enabled()); + /* Check if interface numbers are in correct order */ + if (APP_USBD_CONFIG_LOG_ENABLED) + { + uint8_t next_iface = 0; + for (app_usbd_class_inst_t const * * pp_inst = &m_p_first_cinst; + (*pp_inst) != NULL; + pp_inst = &(app_usbd_class_data_access(*pp_inst)->p_next)) + { + uint8_t iface_idx = 0; + app_usbd_class_iface_conf_t const * p_iface; + while (NULL != (p_iface = app_usbd_class_iface_get(*pp_inst, iface_idx++))) + { + if (p_iface->number != next_iface) + { + NRF_LOG_WARNING("Unexpected interface number, expected %d, got %d", + next_iface, + p_iface->number); + } + ++next_iface; + } + } + } + /* Power should be already enabled - wait just in case if user calls * app_usbd_start just after app_usbd_enable without waiting for the event. */ while (!nrf_power_usbregstatus_outrdy_get()) @@ -810,8 +1081,9 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) app_usbd_all_call((app_usbd_complex_evt_t const *)&evt_data); user_event_state_proc(APP_USBD_EVT_STARTED); - nrf_drv_usbd_start((NULL != m_p_first_sof_cinst) || (m_current_conf.enable_sof) || (APP_USBD_PROVIDE_SOF_TIMESTAMP)); app_usbd_all_iface_deselect(); + app_usbd_core_ep0_disable(); + nrf_drv_usbd_start((NULL != m_p_first_sof_cinst) || (m_current_conf.enable_sof) || (APP_USBD_PROVIDE_SOF_TIMESTAMP)); sustate_set(SUSTATE_STARTED); break; } @@ -856,7 +1128,7 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) break; } default: - break; // Just ignore - it can happen in specyfic situation + break; // Just ignore - it can happen in specific situation } break; } @@ -892,9 +1164,18 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) case APP_USBD_EVT_DRV_SOF: { - #if (APP_USBD_PROVIDE_SOF_TIMESTAMP) || defined(__SDK_DOXYGEN__) - m_last_frame = p_event->drv_evt.data.sof.framecnt; - #endif +#if (APP_USBD_PROVIDE_SOF_TIMESTAMP) || defined(__SDK_DOXYGEN__) + m_last_frame = p_event->drv_evt.data.sof.framecnt; +#endif + /* Wake up if suspended */ + if ((sustate_get() == SUSTATE_SUSPENDING) || (sustate_get() == SUSTATE_WAKINGUP_WAITING_WREQ)) + { + static const app_usbd_evt_t evt_data = { + .type = APP_USBD_EVT_DRV_RESUME + }; + app_usbd_event_execute((app_usbd_internal_evt_t *)&evt_data); + } + user_event_state_proc(APP_USBD_EVT_DRV_SOF); app_usbd_class_inst_t const * p_inst = app_usbd_class_sof_first_get(); @@ -910,8 +1191,9 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) case APP_USBD_EVT_DRV_RESET: { app_usbd_all_iface_deselect(); + app_usbd_core_ep0_enable(); sustate_set(SUSTATE_ACTIVE); - user_event_state_proc(APP_USBD_EVT_DRV_RESUME); + user_event_state_proc(APP_USBD_EVT_DRV_RESET); /* Processing core interface (connected only to EP0) and then all instances from the list */ UNUSED_RETURN_VALUE(app_usbd_core_handler_call(p_event)); app_usbd_all_call((app_usbd_complex_evt_t const *)p_event); @@ -919,7 +1201,15 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) } case APP_USBD_EVT_DRV_RESUME: { - sustate_set(SUSTATE_RESUMING); + if (sustate_get() == SUSTATE_WAKINGUP_WAITING_WREQ) + { + sustate_set(SUSTATE_ACTIVE); + nrf_drv_usbd_force_bus_wakeup(); + } + else + { + sustate_set(SUSTATE_RESUMING); + } user_event_state_proc(APP_USBD_EVT_DRV_RESUME); /* Processing core interface (connected only to EP0) and then all instances from the list */ UNUSED_RETURN_VALUE(app_usbd_core_handler_call(p_event)); @@ -946,7 +1236,7 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) break; default: { - // This should not happen - but try to recover by setting directly active state + /* This should not happen - but try to recover by setting directly active state */ NRF_LOG_WARNING("Unexpected state on WUREQ event (%u)", sustate_get()); sustate_set(SUSTATE_ACTIVE); } @@ -979,6 +1269,12 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) break; } + case APP_USBD_EVT_SETUP_SETADDRESS: + { + UNUSED_RETURN_VALUE(app_usbd_core_handler_call(p_event)); + break; + } + case APP_USBD_EVT_DRV_EPTRANSFER: { app_usbd_ep_conf_t const * p_ep_conf = @@ -998,7 +1294,26 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) } break; } - +#if APP_USBD_CONFIG_POWER_EVENTS_PROCESS + case APP_USBD_EVT_POWER_DETECTED: + { + user_event_state_proc(APP_USBD_EVT_POWER_DETECTED); + app_usbd_all_call((app_usbd_complex_evt_t const *)p_event); + break; + } + case APP_USBD_EVT_POWER_REMOVED: + { + user_event_state_proc(APP_USBD_EVT_POWER_REMOVED); + app_usbd_all_call((app_usbd_complex_evt_t const *)p_event); + break; + } + case APP_USBD_EVT_POWER_READY: + { + user_event_state_proc(APP_USBD_EVT_POWER_READY); + app_usbd_all_call((app_usbd_complex_evt_t const *)p_event); + break; + } +#endif default: ASSERT(0); break; @@ -1006,17 +1321,58 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event) } -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) bool app_usbd_event_queue_process(void) { - nrf_atfifo_item_get_t cx; - app_usbd_internal_evt_t const * p_event_item = nrf_atfifo_item_get(m_event_queue, &cx); +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + app_usbd_internal_evt_t sof_event = { + .app_evt.type = APP_USBD_EVT_DRV_SOF + }; +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + static nrf_atfifo_item_get_t cx; + static app_usbd_internal_queue_evt_t * p_event_item = NULL; + if (NULL == p_event_item) + { + p_event_item = nrf_atfifo_item_get(m_event_queue, &cx); + } + if (NULL != p_event_item) { - app_usbd_event_execute(p_event_item); + +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + if (p_event_item->sof_cnt > 0) + { + if (p_event_item->start_frame > USBD_FRAMECNTR_FRAMECNTR_Msk) + { + p_event_item->start_frame = 0; + } + sof_event.drv_evt.data.sof.framecnt = (p_event_item->start_frame)++; + --(p_event_item->sof_cnt); + app_usbd_event_execute(&sof_event); + return true; + } +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + + app_usbd_event_execute(&(p_event_item->evt)); UNUSED_RETURN_VALUE(nrf_atfifo_item_free(m_event_queue, &cx)); + p_event_item = NULL; return true; } +#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) + else if (m_sof_events_cnt > 0) + { + CRITICAL_REGION_ENTER(); + if (m_event_frame > USBD_FRAMECNTR_FRAMECNTR_Msk) + { + m_event_frame = 0; + } + sof_event.drv_evt.data.sof.framecnt = m_event_frame++; + UNUSED_RETURN_VALUE(nrf_atomic_u32_sub_hs(&m_sof_events_cnt, 1)); + CRITICAL_REGION_EXIT(); + app_usbd_event_execute(&sof_event); + return true; + } +#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) else { return false; @@ -1088,7 +1444,7 @@ ret_code_t app_usbd_class_remove(app_usbd_class_inst_t const * p_cinst) ASSERT(NULL != p_cinst); ASSERT(NULL != p_cinst->p_class_methods); ASSERT(NULL != p_cinst->p_class_methods->event_handler); - /** This function should be only called if USBD is disabled */ + /* This function should be only called if USBD is disabled */ ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized()); ret_code_t ret; /* Remove this class from the chain */ @@ -1161,7 +1517,7 @@ ret_code_t app_usbd_ep_handler_set(app_usbd_class_inst_t const * const p_cinst, { ASSERT(NULL != p_cinst); ASSERT(NULL != handler); - /** This function should be only called if USBD is disabled */ + /* This function should be only called if USBD is disabled */ ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized()); if (p_cinst != app_usbd_ep_instance_get(ep)) @@ -1179,17 +1535,24 @@ ret_code_t app_usbd_class_sof_register(app_usbd_class_inst_t const * p_cinst) ASSERT(NULL != p_cinst); ASSERT(NULL != p_cinst->p_class_methods); ASSERT(NULL != p_cinst->p_class_methods->event_handler); - /** This function should be only called if USBD is disabled */ + /* This function should be only called if USBD is disabled */ ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized()); - /* Next SOF event requiring instance have to be null now */ + /* Make sure it's not in interrupt SOF list */ + app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_interrupt_cinst; + while (NULL != (*pp_last)) + { + ASSERT((*pp_last) != p_cinst); + pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next); + } + + /* Next SOF event requiring instance has to be NULL now */ ASSERT(NULL == (app_usbd_class_data_access(p_cinst)->p_sof_next)); /* Adding pointer to this instance to the end of the chain */ - app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_cinst; + pp_last = &m_p_first_sof_cinst; while (NULL != (*pp_last)) { - ASSERT((*pp_last) != p_cinst); pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next); } @@ -1221,6 +1584,62 @@ ret_code_t app_usbd_class_sof_unregister(app_usbd_class_inst_t const * p_cinst) return NRF_ERROR_NOT_FOUND; } +ret_code_t app_usbd_class_sof_interrupt_register(app_usbd_class_inst_t const * p_cinst, app_usbd_sof_interrupt_handler_t handler) +{ + ASSERT(NULL != p_cinst); + ASSERT(NULL != p_cinst->p_class_methods); + ASSERT(NULL != handler); + /* This function should be only called if USBD is disabled */ + ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized()); + + /* Next SOF event requiring instance has to be NULL now */ + ASSERT(NULL == (app_usbd_class_data_access(p_cinst)->p_sof_next)); + + app_usbd_class_data_access(p_cinst)->sof_handler = handler; + + /* Make sure it's not in normal SOF list */ + app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_cinst; + while (NULL != (*pp_last)) + { + ASSERT((*pp_last) != p_cinst); + pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next); + } + + /* Adding pointer to this instance to the end of the interrupt chain */ + pp_last = &m_p_first_sof_interrupt_cinst; + while (NULL != (*pp_last)) + { + + ASSERT((*pp_last) != p_cinst); + pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next); + } + (*pp_last) = p_cinst; + + return NRF_SUCCESS; +} + + +ret_code_t app_usbd_class_sof_interrupt_unregister(app_usbd_class_inst_t const * p_cinst) +{ + ASSERT(NULL != p_cinst); + /** This function should be only called if USBD is disabled */ + ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized()); + + app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_interrupt_cinst; + while (NULL != (*pp_last)) + { + if ((*pp_last) == p_cinst) + { + /* Breaking chain */ + (*pp_last) = (app_usbd_class_data_access(p_cinst)->p_sof_next); + app_usbd_class_data_access(p_cinst)->p_sof_next = NULL; + + return NRF_SUCCESS; + } + pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next); + } + return NRF_ERROR_NOT_FOUND; +} ret_code_t app_usbd_class_rwu_register(app_usbd_class_inst_t const * const p_inst) { @@ -1312,6 +1731,11 @@ app_usbd_class_inst_t const * app_usbd_class_sof_first_get(void) return m_p_first_sof_cinst; } +app_usbd_class_inst_t const * app_usbd_class_sof_interrupt_first_get(void) +{ + return m_p_first_sof_interrupt_cinst; +} + app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_iface_idx) { app_usbd_class_inst_t const * p_inst = app_usbd_class_first_get(); @@ -1492,4 +1916,4 @@ void app_usbd_all_iface_deselect(void) } } -#endif // APP_USBD_ENABLED +#endif //NRF_MODULE_ENABLED(APP_USBD) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd.h similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd.h index 5fedf0c..c5369fc 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_H__ @@ -60,22 +60,34 @@ extern "C" { * @{ */ +/** + * @brief Highest value of Frame Number in SOF packets. + */ +#define APP_USBD_SOF_MAX 2047 + /** * @brief True if SOF timestamping is really provided. * * SOF timestamping is really provided if it was requested and if the logger is enabled. */ -#if ((APP_USBD_CONFIG_PROVIDE_SOF_TIMESTAMP) && (NRF_LOG_ENABLED)) +#if ((APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE) && (NRF_LOG_ENABLED)) #define APP_USBD_PROVIDE_SOF_TIMESTAMP 1 #else #define APP_USBD_PROVIDE_SOF_TIMESTAMP 0 #endif +/** + * @brief SOF event handling modes. + */ +#define APP_USBD_SOF_HANDLING_NORMAL_QUEUE 0 //!< Push SOF events into event queue. +#define APP_USBD_SOF_HANDLING_COMPRESS_QUEUE 1 //!< Compress SOF events. +#define APP_USBD_SOF_HANDLING_INTERRUPT 2 //!< Handle SOF events in interrupt. + /** * @brief Configuration passed to @ref app_usbd_init. */ typedef struct { -#if (!(APP_USBD_EVENT_QUEUE_ENABLE)) || defined(__SDK_DOXYGEN__) +#if (!(APP_USBD_CONFIG_EVENT_QUEUE_ENABLE)) || defined(__SDK_DOXYGEN__) /** * @brief User defined event handler. * @@ -87,12 +99,12 @@ typedef struct { * @param p_event The event structure pointer. * * @note This field is available only when USB internal queue is disabled - * (see @ref APP_USBD_EVENT_QUEUE_ENABLE). + * (see @ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE). */ void (*ev_handler)(app_usbd_internal_evt_t const * const p_event); #endif -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) /** * @brief User defined event handler. * @@ -105,7 +117,7 @@ typedef struct { * See @ref nrf_atfifo for more details. * * @note This field is available only when USBD internal queue is configured - * (see @ref APP_USBD_EVENT_QUEUE_ENABLE). + * (see @ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE). * * @note If is set to NULL no event would be called from interrupt. * @note This function is called before event is processed. @@ -121,7 +133,7 @@ typedef struct { * This function is called while state event is processed. * * * @note This field is available only when USBD internal queue is configured - * (see @ref APP_USBD_EVENT_QUEUE_ENABLE). + * (see @ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE). * * @param event Event type. * Only following events are sent into this function: @@ -132,11 +144,14 @@ typedef struct { * - APP_USBD_EVT_START * - APP_USBD_EVT_STOP * - APP_USBD_EVT_STATE_CHANGED + * - APP_USBD_EVT_POWER_DETECTED + * - APP_USBD_EVT_POWER_REMOVED + * - APP_USBD_EVT_POWER_READY */ void (*ev_state_proc)(app_usbd_event_type_t event); /** - * @brief SOF processing required by the user event processing + * @brief SOF processing required by the user event processing. * * This flag would enable SOF processing for the user events regardless of the fact if any * of the implemented class requires SOF event. @@ -170,14 +185,28 @@ uint32_t app_usbd_sof_timestamp_get(void); ret_code_t app_usbd_init(app_usbd_config_t const * p_config); /** - * @brief USB library un-initialization + * @brief USB library un-initialization. * - * @note Currently not supported + * @note Currently not supported. */ ret_code_t app_usbd_uninit(void); +#if (APP_USBD_CONFIG_POWER_EVENTS_PROCESS) || defined(__SDK_DOXYGEN__) /** - * @brief Enable USBD + * @brief Function to start USB related power events processing. + * + * This function should be called after @ref app_usbd_init and after all the + * required classes were appended (@ref app_usbd_class_append). + * + * @retval NRF_SUCCESS Power events successfully initialized. + * @retval NRF_ERROR_INVALID_STATE The state of the driver does not allow to enable + * the power events processing. + */ +ret_code_t app_usbd_power_events_enable(void); +#endif + +/** + * @brief Enable USBD. * * USBD is enabled. * Since now the high frequency clock may be requested when USB RESET would be detected. @@ -185,7 +214,7 @@ ret_code_t app_usbd_uninit(void); void app_usbd_enable(void); /** - * @brief Disable USBD + * @brief Disable USBD. * * Disabled USDB peripheral cannot be accessed but also stops requesting * High Frequency clock and releases power regulator. @@ -195,10 +224,10 @@ void app_usbd_enable(void); void app_usbd_disable(void); /** - * @brief Request USBD to start + * @brief Request USBD to start. * * The function sends start request to the event queue. - * If the queue is enabled (@ref APP_USBD_EVENT_QUEUE_ENABLE) it would be processed + * If the queue is enabled (@ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) it would be processed * when the queue is processed. * If queue is disabled it would be processed immediately inside this function. * It means that if queue is disabled this function cannot be called from interrupt with priority @@ -224,10 +253,10 @@ void app_usbd_disable(void); void app_usbd_start(void); /** - * @brief Stop USB to work + * @brief Stop USB. * * The function sends stop request to the event queue. - * If the queue is enabled (@ref APP_USBD_EVENT_QUEUE_ENABLE) it would be processed + * If the queue is enabled (@ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) it would be processed * when the queue is processed. * If queue is disabled it would be processed immediately inside this function. * It means that if queue is disabled this function cannot be called from interrupt with priority @@ -244,7 +273,7 @@ void app_usbd_start(void); void app_usbd_stop(void); /** - * @brief Request library to suspend + * @brief Request library to suspend. * * This function send suspend request to the event queue. * @@ -254,7 +283,7 @@ void app_usbd_stop(void); void app_usbd_suspend_req(void); /** - * @brief Request library to wake-up + * @brief Request library to wake-up. * * This function send wakeup request to the event queue. * @@ -277,27 +306,27 @@ bool app_usbd_wakeup_req(void); bool app_usbd_active_check(void); /** - * @brief USBD event processor + * @brief USBD event processor. * * Function to be called on each event to be processed by the library. */ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event); -#if (APP_USBD_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__) /** - * @brief Function that process events from the queue + * @brief Function that process events from the queue. * * @note This function calls @ref app_usbd_event_execute internally. * - * @retval true Event was processed - * @retval false The event queue is empty + * @retval true Event was processed. + * @retval false The event queue is empty. */ bool app_usbd_event_queue_process(void); #endif /** - * @brief Add class instance + * @brief Add class instance. * * This function connects given instance into internal class instance chain and * into all required endpoints. @@ -310,11 +339,14 @@ bool app_usbd_event_queue_process(void); * Assertion would be generated otherwise. * * @param[in,out] p_cinst Instance to connect. Chain data would be written into writable instance data. + * + * @retval NRF_SUCCESS Instance successfully added. + * @retval NRF_ERROR_BUSY Endpoint(s) not available. */ ret_code_t app_usbd_class_append(app_usbd_class_inst_t const * p_cinst); /** - * @brief Remove class instance + * @brief Remove class instance. * * Instance is removed from instance chain. * Instance and event handlers are removed also from endpoints. @@ -331,7 +363,7 @@ ret_code_t app_usbd_class_append(app_usbd_class_inst_t const * p_cinst); ret_code_t app_usbd_class_remove(app_usbd_class_inst_t const * p_cinst); /** - * @brief Remove all class instances + * @brief Remove all class instances. * * This function basically calls @ref app_usbd_class_remove * on instances chain as long as there is any element left. @@ -347,7 +379,7 @@ ret_code_t app_usbd_class_remove(app_usbd_class_inst_t const * p_cinst); ret_code_t app_usbd_class_remove_all(void); /** - * @brief Change endpoint handler + * @brief Change endpoint handler. * * This function may be called for the endpoint only if the class instance is * already properly attached by the @ref app_usbd_class_append function. @@ -372,7 +404,7 @@ ret_code_t app_usbd_ep_handler_set(app_usbd_class_inst_t const * p_cinst, app_usbd_ep_event_handler_t handler); /** - * @brief Register class instance as the one that requires SOF events + * @brief Register class instance as the one that requires SOF events. * * This function should be called in reaction on APP_USBD_EVT_INST_APPEND event. * Connect the class instance to the list of instances that requires SOF processing. @@ -387,7 +419,7 @@ ret_code_t app_usbd_ep_handler_set(app_usbd_class_inst_t const * p_cinst, ret_code_t app_usbd_class_sof_register(app_usbd_class_inst_t const * p_cinst); /** - * @brief Unregister class instance from SOF processing instances list + * @brief Unregister class instance from SOF processing instances list. * * Every class that calls @ref app_usbd_class_sof_register have to call also unregistering function * in reaction to @ref APP_USBD_EVT_INST_REMOVE event. @@ -402,80 +434,116 @@ ret_code_t app_usbd_class_sof_register(app_usbd_class_inst_t const * p_cinst); ret_code_t app_usbd_class_sof_unregister(app_usbd_class_inst_t const * p_cinst); /** - * @brief Register class on remote wake-up feature + * @brief Register class instance as the one that requires SOF events in interrupt. + * + * This function should be called in reaction on APP_USBD_EVT_INST_APPEND event. + * Connect the class instance to the list of instances that requires SOF processing. + * If none of the appended instances requires SOF event - it is disabled. + * + * @param p_cinst Instance that requires SOF event. + * @param handler Handler to SOF event + * + * @retval NRF_SUCCESS Instance linked into SOF processing list. + * + * @sa app_usbd_class_sof_interrupt_unregister + */ +ret_code_t app_usbd_class_sof_interrupt_register(app_usbd_class_inst_t const * p_cinst, + app_usbd_sof_interrupt_handler_t handler); + +/** + * @brief Unregister class instance from SOF processing in interrupt instances list. + * + * Every class that calls @ref app_usbd_class_sof_interrupt_register have to call + * also unregistering function in reaction to @ref APP_USBD_EVT_INST_REMOVE event. + * + * @param p_cinst Instance to be unregistered from SOF processing in interrupt list. + * + * @retval NRF_SUCCESS Instance linked into SOF processing in interrupt list. + * @retval NRF_ERROR_NOT_FOUND Instance not found in the SOF processing in interrupt list. + * + * @sa app_usbd_class_sof_interrupt_register + */ +ret_code_t app_usbd_class_sof_interrupt_unregister(app_usbd_class_inst_t const * p_cinst); + + +/** + * @brief Register class on remote wake-up feature. * - * @param[in] p_inst Instance of the class + * @param[in] p_inst Instance of the class. * - * @retval NRF_SUCCESS Instance that requires remote wake-up registered + * @retval NRF_SUCCESS Instance that requires remote wake-up registered. */ ret_code_t app_usbd_class_rwu_register(app_usbd_class_inst_t const * const p_inst); /** - * @brief Unregister class from remote wake-up feature + * @brief Unregister class from remote wake-up feature. * - * @param[in] p_inst Instance of the class + * @param[in] p_inst Instance of the class. * - * @retval NRF_SUCCESS Instance that requires remote wake-up removed + * @retval NRF_SUCCESS Instance that requires remote wake-up removed. */ ret_code_t app_usbd_class_rwu_unregister(app_usbd_class_inst_t const * const p_inst); /** - * @brief Check if there is any class with remote wakeup + * @brief Check if there is any class with remote wakeup. * * The function checks internal registered class with remote wakeup counter. * * @sa app_usbd_class_rwu_register, app_usbd_class_rwu_unregister * - * @retval true The remote wakeup functionality is required by some class instance - * @retval false There is no class instance that requires wakeup functionality + * @retval true The remote wakeup functionality is required by some class instance. + * @retval false There is no class instance that requires wakeup functionality. */ bool app_usbd_class_rwu_enabled_check(void); /** - * @brief Function finds a given descriptor type in class descriptors payload + * @brief Find a specified descriptor. * - * @param[in] p_cinst Instance of a class - * @param[in] desc_type Descriptor type (@ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR) - * @param[in] desc_index Descriptor index (@ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR) - * @param[out] p_desc_len Descriptor length + * @param[in] p_cinst Class instance. + * @param[in] desc_type Descriptor type @ref app_usbd_descriptor_t + * @param[in] desc_index Descriptor index. + * @param[out] p_desc Pointer to escriptor. + * @param[out] p_desc_len Length of descriptor. * - * @return Address of the descriptor (NULL if not found) + * @return Standard error code @ref ret_code_t + * @retval NRF_SUCCESS Descriptor successfully found. + * @retval NRF_ERROR_NOT_FOUND Descriptor not found. * */ -const void * app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_cinst, - uint8_t desc_type, - uint8_t desc_index, - size_t * p_desc_len); +ret_code_t app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_cinst, + uint8_t desc_type, + uint8_t desc_index, + uint8_t * p_desc, + size_t * p_desc_len); /** - * @brief Standard set interface request handle + * @brief Standard set interface request handle. * * This function should be called when processing SET_INTERFACE request. * - * @param[in] p_cinst Instance of a class - * @param[in] iface Interface number + * @param[in] p_cinst Instance of a class. + * @param[in] iface Interface number. * - * @return Standard error code + * @return Standard error code. * * @note Selected interface to reset has to be part of given class. - * In other case * */ ret_code_t app_usbd_interface_ep_reset(app_usbd_class_inst_t const * const p_cinst, uint8_t iface); /** - * @brief Enable selected endpoint + * @brief Enable selected endpoint. * * Selected endpoint is enabled and cleared. * - * @param ep Endpoint number + * @param ep Endpoint number. */ void app_usbd_ep_enable(nrf_drv_usbd_ep_t ep); /** - * @brief Disable selected endpoint + * @brief Disable selected endpoint. * - * @param ep Endpoint number + * @param ep Endpoint number. */ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep); @@ -486,7 +554,7 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep); * @{ */ /** - * @brief Get first class instance in the list + * @brief Get first class instance in the list. * * Get first instance from the list of active class instances. * That instance may be used then in @ref app_usbd_class_next_get function. @@ -496,7 +564,7 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep); app_usbd_class_inst_t const * app_usbd_class_first_get(void); /** - * @brief Get next instance in the list + * @brief Get next instance in the list. * * Get the next instance from the list of active instances. * Used to iterate through all instances. @@ -513,18 +581,18 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep); } /** - * @brief Get first instance in SOF list + * @brief Get first instance in SOF list. * - * Start iteration through the list of instances that requires SOF event processing. + * Start iteration through the list of instances that require SOF event processing. * - * @return First instance in the list or NULL if the list is empty + * @return First instance in the list or NULL if the list is empty. * * @sa app_usbd_class_first_get */ app_usbd_class_inst_t const * app_usbd_class_sof_first_get(void); /** - * @brief Get next instance in the SOF list + * @brief Get next instance in the SOF list. * * Get the next instance from the list of instances requiring SOF event processing. * Used to iterate through all SOF instances. @@ -539,15 +607,43 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep); ASSERT(NULL != p_cinst); return app_usbd_class_data_access(p_cinst)->p_sof_next; } + + /** + * @brief Get first instance in SOF interrupt list. + * + * Start iteration through the list of instances that require SOF processing in interrupt. + * + * @return First instance in the list or NULL if the list is empty. + * + * @sa app_usbd_class_first_get + */ + app_usbd_class_inst_t const * app_usbd_class_sof_interrupt_first_get(void); + + /** + * @brief Get next instance in the SOF interrupt list. + * + * Get the next instance from the list of instances requiring SOF processing in interrupt. + * Used to iterate through all SOF instances that have SOF handlers. + * + * @param p_cinst The current instance from with next one is required. + * + * @return Next instance to the given one or NULL if there is no more instances in the list. + */ + static inline app_usbd_class_inst_t const * app_usbd_class_sof_interrupt_next_get( + app_usbd_class_inst_t const * const p_cinst) + { + ASSERT(NULL != p_cinst); + return app_usbd_class_data_access(p_cinst)->p_sof_next; + } /** @} */ /** - * @brief Search for selected interface + * @brief Search for selected interface. * * Function searches for the given interface number and returns the class that contains it. * Optionally it can return interface index inside class instance. * - * @param[in] iface Interface number + * @param[in] iface Interface number. * @param[out] p_iface_idx Pointer to a variable that would hold interface index inside returned * class instance. * @@ -563,14 +659,14 @@ app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_ifa */ /** - * @brief Call interface event handler + * @brief Call interface event handler. * * Call event handler for selected interface. - * @param[in,out] p_class_inst Class instance that holds selected interface - * @param[in] iface_idx Index of the interface in class structure - * @param[in] p_event Event structure to be processed + * @param[in,out] p_class_inst Class instance that holds selected interface. + * @param[in] iface_idx Index of the interface in class structure. + * @param[in] p_event Event structure to be processed. * - * @return Operation status + * @return Operation status. */ ret_code_t app_usbd_iface_call( app_usbd_class_inst_t const * const p_class_inst, @@ -578,30 +674,30 @@ app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_ifa app_usbd_complex_evt_t const * const p_event); /** - * @brief Call endpoint event handler + * @brief Call endpoint event handler. * * Call event handler for the selected endpoint. - * @param[in] ep Endpoint number - * @param[in] p_event Event structure to send + * @param[in] ep Endpoint number. + * @param[in] p_event Event structure to send. * - * @return Operation status + * @return Operation status. */ ret_code_t app_usbd_ep_call(nrf_drv_usbd_ep_t ep, app_usbd_complex_evt_t const * const p_event); /** - * @brief Auxiliary function that process event by every instance in the list + * @brief Auxiliary function that process event by every instance in the list. * * This function ignores the result of called handler. * - * @param p_event Event to pass to every instance + * @param p_event Event to pass to every instance. */ void app_usbd_all_call(app_usbd_complex_evt_t const * const p_event); /** - * @brief Call interface event handlers and stop when served + * @brief Call interface event handlers and stop when served. * * Call event handlers from instances as long as we get result different than @ref NRF_ERROR_NOT_SUPPORTED - * @param[in] p_event Event structure to send + * @param[in] p_event Event structure to send. * * @return Operation status or @ref NRF_ERROR_NOT_SUPPORTED if none of instances in the list can support given event. */ @@ -609,16 +705,16 @@ app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_ifa /** @} */ /** - * @brief Endpoint transfer + * @brief Endpoint transfer. * - * @param ep Endpoint number + * @param ep Endpoint number. * @param p_transfer Description of the transfer to be performed. * The direction of the transfer is determined by the * endpoint number. * * @retval NRF_ERROR_INVALID_STATE The state of the USB device does not allow * data transfer on the endpoint. - * @return Values returned by @ref nrf_drv_usbd_ep_transfer + * @return Values returned by @ref nrf_drv_usbd_ep_transfer. * * @sa app_usbd_ep_handled_transfer */ @@ -652,11 +748,11 @@ ret_code_t app_usbd_ep_handled_transfer( * * After calling this function interface should be functional. * - * @param[in,out] p_inst Instance of the class - * @param[in] iface_idx Index of the interface inside class structure - * @param[in] alternate Alternate setting that should be selected + * @param[in,out] p_inst Instance of the class. + * @param[in] iface_idx Index of the interface inside class structure. + * @param[in] alternate Alternate setting that should be selected. * - * @return Standard Error code + * @return Standard error code. */ ret_code_t app_usbd_iface_select( app_usbd_class_inst_t const * const p_inst, @@ -665,7 +761,7 @@ ret_code_t app_usbd_iface_select( /** - * @brief Deselect interface + * @brief Deselect interface. * * Disable the given interface. * This function calls class interface deselection function or @@ -674,38 +770,38 @@ ret_code_t app_usbd_iface_select( * After calling this function all the endpoints from the interface * have to be disabled. * - * @param[in,out] p_inst Instance of the class - * @param[in] iface_idx Index of the interface inside class structure + * @param[in,out] p_inst Instance of the class. + * @param[in] iface_idx Index of the interface inside class structure. */ void app_usbd_iface_deselect( app_usbd_class_inst_t const * const p_inst, uint8_t iface_idx); /** - * @brief Get selected interface + * @brief Get selected interface. * * Function retieves currently selected interface. * If the class contains @ref app_usbd_class_methods_t::iface_selection_get it is called. * It it does not contain this function this function would return default, 0 value. * - * @param[in] p_inst Instance of the class - * @param[in] iface_idx Index of the interface inside class structure + * @param[in] p_inst Instance of the class. + * @param[in] iface_idx Index of the interface inside class structure. * - * @return Selected alternate interface setting + * @return Selected alternate interface setting. */ uint8_t app_usbd_iface_selection_get( app_usbd_class_inst_t const * const p_inst, uint8_t iface_idx); /** - * @brief Select alternate configuration 0 for all interfaces + * @brief Select alternate configuration 0 for all interfaces. * * Auxiliary function that clears settings for all interfaces leaving them enabled. */ void app_usbd_all_iface_select_0(void); /** - * @brief Deselect all interfaces + * @brief Deselect all interfaces. * * Auxiliary function to disable all interfaces. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_class_base.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_class_base.h similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_class_base.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_class_base.h index f3a9a44..a770b57 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_class_base.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_class_base.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_CLASS_BASE_H__ @@ -66,7 +66,7 @@ extern "C" { */ /** - * @brief Endpoint configuration + * @brief Endpoint configuration. */ typedef struct { @@ -74,7 +74,7 @@ typedef struct } app_usbd_class_ep_conf_t; /** - * @brief Interface configuration + * @brief Interface configuration. */ typedef struct { @@ -87,27 +87,47 @@ typedef struct } app_usbd_class_iface_conf_t; /** - * @brief Instance variable data + * @brief Instance variable data. */ typedef struct { - app_usbd_class_inst_t const * p_next; //!< Pointer to the next instance - app_usbd_class_inst_t const * p_sof_next; //!< Pointer to the next SOF event requiring instance + app_usbd_class_inst_t const * p_next; //!< Pointer to the next instance + app_usbd_class_inst_t const * p_sof_next; //!< Pointer to the next SOF event requiring instance + app_usbd_sof_interrupt_handler_t sof_handler; //!< Instance specific SOF interrupt handler } app_usbd_class_data_t; +/** + * @brief Class descriptor context. + */ +typedef struct +{ + uint32_t line; //!< Number of line to resume writing descriptors from + uint8_t data_buffer; //!< Data from last call of feeder +} app_usbd_class_descriptor_ctx_t; + +/** + * @brief Class descriptor state. + */ +typedef struct +{ + uint8_t * p_buffer; //!< Pointer to buffer + uint32_t current_size; //!< Current size of descriptor + uint32_t maximum_size; //!< Maximum size of descriptor + app_usbd_class_descriptor_ctx_t * p_context; //!< Pointer to context +} app_usbd_class_descriptor_state_t; /** - * @brief Class interface function set + * @brief Class interface function set. * */ typedef struct { /** - * @brief Instance callback function + * @brief Instance callback function. * * The function used by every class instance. - * @param[in,out] p_inst Instance of the class - * @param[in] p_event Event to process + * @param[in,out] p_inst Instance of the class. + * @param[in] p_event Event to process. * - * @return Standard error code + * @return Standard error code. * * @note If given event is not supported by class, return @ref NRF_ERROR_NOT_SUPPORTED */ @@ -115,16 +135,21 @@ typedef struct { app_usbd_complex_evt_t const * const p_event); /** - * @brief Instance get descriptors + * @brief Instance feed descriptors. * - * The function used by every class instance. - * @param[in,out] p_inst Instance of the class - * @param[out] p_size Descriptor size + * Feeds whole descriptor of the instance. + * @param[in] p_ctx Class descriptor context. + * @param[in,out] p_inst Instance of the class. + * @param[out] p_buff Buffer for descriptor. + * @param[in] max_size Requested size of the descriptor. * - * @return Class descriptors start address + * @return True if not finished feeding the descriptor, false if done. */ - const void * (* get_descriptors)(app_usbd_class_inst_t const * const p_inst, - size_t * p_size); + bool (* feed_descriptors)(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size); + /** * @brief Select interface @@ -157,7 +182,7 @@ typedef struct { uint8_t alternate); /** - * @brief Deselect interface + * @brief Deselect interface. * * Function called when the class interface has to be deselected. * @@ -173,20 +198,20 @@ typedef struct { * @note If this function pointer is NULL default procedure would * just disable all the interface endpoints. * - * @param[in,out] p_inst Instance of the class - * @param[in] iface_idx Index of the interface inside class structure + * @param[in,out] p_inst Instance of the class. + * @param[in] iface_idx Index of the interface inside class structure. */ void (* iface_deselect)(app_usbd_class_inst_t const * const p_inst, uint8_t iface_idx); /** - * @brief Get current interface + * @brief Get current interface. * * Function called when class interface has to return its alternate settings * in reaction on GET_INTERFACE command. * It should be defined in a pair with @ref app_usbd_class_methods_t::iface_select. * - * @param[in] p_inst Instance of the class - * @param[in] iface_idx Index of the interface inside class structure + * @param[in] p_inst Instance of the class. + * @param[in] iface_idx Index of the interface inside class structure. * * @return Current alternate setting of the selected interface. * @@ -201,9 +226,9 @@ typedef struct { } app_usbd_class_methods_t; /** - * @brief The instance structure itself + * @brief The instance structure itself. * - * The structure of base class instance + * The structure of base class instance. */ struct app_usbd_class_inst_s { @@ -218,7 +243,7 @@ struct app_usbd_class_inst_s /** - * @brief Get total number of interfaces + * @brief Get total number of interfaces. * * */ @@ -228,11 +253,11 @@ static inline uint8_t app_usbd_class_iface_count_get(app_usbd_class_inst_t const } /** - * @brief Interface accessing function + * @brief Interface accessing function. * * Get interface pointer. - * Interfaces creates continuous array in the memory so it is possible to get - * interface with index 0 and the just iterate to the next one. + * Interfaces create continuous array in the memory so it is possible to get + * interface with index 0 and then just iterate to the next one. * * @param p_inst Pointer to the class instance * @param iface_idx Index of the instance to get. @@ -256,11 +281,11 @@ static inline app_usbd_class_iface_conf_t const * app_usbd_class_iface_get( } /** - * @brief Get interface number + * @brief Get interface number. * - * @param p_iface Pointer to interface structure + * @param p_iface Pointer to interface structure. * - * @return Interface number from interface configuration structure + * @return Interface number from interface configuration structure. */ static inline uint8_t app_usbd_class_iface_number_get( app_usbd_class_iface_conf_t const * const p_iface) @@ -269,11 +294,11 @@ static inline uint8_t app_usbd_class_iface_number_get( } /** - * @brief Get number of endpoints in interface + * @brief Get number of endpoints in interface. * - * @param p_iface Pointer to interface structure + * @param p_iface Pointer to interface structure. * - * @return Number of endpoints used by given interface + * @return Number of endpoints used by given interface. */ static inline uint8_t app_usbd_class_iface_ep_count_get( app_usbd_class_iface_conf_t const * const p_iface) @@ -282,10 +307,10 @@ static inline uint8_t app_usbd_class_iface_ep_count_get( } /** - * @brief Interface Endpoint accessing function + * @brief Interface Endpoint accessing function. * - * @param p_iface Interface configuration pointer - * @param ep_idx Endpoint index + * @param p_iface Interface configuration pointer. + * @param ep_idx Endpoint index. * * @return Endpoint information structure pointer or NULL if given index is outside of endpoints for selected interface. * @@ -307,12 +332,12 @@ static inline app_usbd_class_ep_conf_t const * app_usbd_class_iface_ep_get( } /** - * @brief Translate endpoint address to class index + * @brief Translate endpoint address to class index. * - * @param p_iface Interface configuration pointer - * @param ep_address Endpoint address + * @param p_iface Interface configuration pointer. + * @param ep_address Endpoint address. * - * @return Endpoint index or number of endpoints if not found + * @return Endpoint index or number of endpoints if not found. * */ static inline uint8_t app_usbd_class_iface_ep_idx_get( @@ -336,9 +361,9 @@ static inline uint8_t app_usbd_class_iface_ep_idx_get( } /** - * @brief Get the selected endpoint address + * @brief Get the selected endpoint address. * - * @param p_ep Endpoint configuration structure + * @param p_ep Endpoint configuration structure. * * @return Endpoint address */ @@ -348,10 +373,10 @@ static inline nrf_drv_usbd_ep_t app_usbd_class_ep_address_get(app_usbd_class_ep_ } /** - * @brief Get the pointer to the writable instance data + * @brief Get the pointer to the writable instance data. * - * @param p_inst Instance pointer - * @return Pointer to writable instance data + * @param p_inst Instance pointer. + * @return Pointer to writable instance data. */ static inline app_usbd_class_data_t * app_usbd_class_data_access( app_usbd_class_inst_t const * const p_inst) @@ -366,7 +391,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( * @{ */ /** - * @brief Count the number of endpoints in given configuration + * @brief Count the number of endpoints in given configuration. * * Config should be given as a interface configuration in a brackets: * @code @@ -375,7 +400,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( * Number of endpoints may vary from 0 to a few (technically up to 16, but it seems not to make sense to use more than 4). * Interface number is always present. * - * @param iface_config Single interface configuration (in brackets) + * @param iface_config Single interface configuration (in brackets). * * @return Number of endpoints in interface. This is computed value - can be used by compiler but not by preprocessor. */ @@ -383,7 +408,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( (NUM_VA_ARGS(BRACKET_EXTRACT(iface_config)) - 1) /** - * @brief Adds the number of endpoints in given config to the current value + * @brief Adds the number of endpoints in given config to the current value. * * This is basically @ref APP_USBD_CLASS_CONF_IFACE_EP_COUNT_ with plus sign added. * @@ -397,11 +422,11 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( + APP_USBD_CLASS_CONF_IFACE_EP_COUNT_(iface_config) /** - * @brief Create variable for endpoint + * @brief Create variable for endpoint. */ /** - * @brief Extract endpoints given interface configuration + * @brief Extract endpoints given interface configuration. * * This macro gets single endpoint configuration and extracts all the endpoints. * It also adds comma on the end of extracted endpoints. @@ -419,43 +444,51 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( /** * @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_EP_EXTRACT_ * - * This macro is called when interface has no endpoints + * This macro is called when interface has no endpoints. */ #define APP_USBD_CLASS_IFACE_EP_EXTRACT_0(iface_nr) /** * @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_EP_EXTRACT_ * - * This macro is called when interface has at least one endpoint + * This macro is called when interface has at least one endpoint. */ #define APP_USBD_CLASS_IFACE_EP_EXTRACT_1(...) \ APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(__VA_ARGS__) #define APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(iface_nr, ...) \ - MACRO_MAP_REC(PARAM_CBRACE, __VA_ARGS__) + MACRO_MAP_REC(APP_USBD_CLASS_IFACE_EP_EXTRACT_1__, __VA_ARGS__) + + #define APP_USBD_CLASS_IFACE_EP_EXTRACT_1__(ep) \ + {(nrf_drv_usbd_ep_t) (ep)}, /** - * @brief Generate configuration for single interface + * @brief Generate configuration for single interface. * * This macro extract configuration for single interface. * The configuration is inside curly brackets and comma is added on the end. * This mean it can be directly used to init array of interface configurations. * - * @param iface_config Single interface configuration - * @param N Currently processed configuration - * @param iface_configs All interfaces configuration in brackets + * @param iface_config Single interface configuration. + * @param N Currently processed configuration. + * @param iface_configs All interfaces configuration in brackets. */ #define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_(iface_config, N, iface_configs) \ CONCAT_2(APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_, \ NUM_VA_ARGS_IS_MORE_THAN_1(BRACKET_EXTRACT(iface_config))) \ (N, iface_configs, BRACKET_EXTRACT(iface_config)) + /** + * @brief Macro used when there was an error extracting number of configs. + * + * Throws a syntax error. + */ #define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_x(iface_config, N, iface_configs) \ [N] = !!!iface_config!!! /** * @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_ * - * This macro is called when interface has no endpoints + * This macro is called when interface has no endpoints. */ #define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0(N, iface_configs, iface_nr) \ APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0_(N, iface_configs, iface_nr) @@ -465,7 +498,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( /** * @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_ * - * This macro is called when interface has at last one endpoint + * This macro is called when interface has at last one endpoint. */ #define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1(N, iface_configs, ...) \ APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1_(N, iface_configs, __VA_ARGS__) @@ -489,7 +522,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( */ /** - * @brief Count total number of endpoints + * @brief Count total number of endpoints. * * @param iface_configs List of interface configurations like explained * in documentation for @ref APP_USBD_CLASS_INSTANCE_TYPEDEF @@ -500,12 +533,12 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( (0 MACRO_MAP(APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs))) /** - * @brief Count total number of endpoint up-to interface index + * @brief Count total number of endpoint up-to interface index. * * The version of @ref APP_USBD_CLASS_CONF_TOTAL_EP_COUNT macro which takes the * number of interfaces to analyze. * - * @param N Number of interfaces to analyze + * @param N Number of interfaces to analyze. * @param iface_configs List of interface configurations like explained * in documentation for @ref APP_USBD_CLASS_INSTANCE_TYPEDEF * @@ -515,7 +548,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( (0 MACRO_MAP_N(N, APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs))) /** - * @brief Extract configurations for interfaces + * @brief Extract configurations for interfaces. * * This macro extracts the configurations for every interface. * Basically uses the @ref APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_ macro on every @@ -536,14 +569,14 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( BRACKET_EXTRACT(iface_configs)) /** - * @brief Extract all endpoints + * @brief Extract all endpoints. * - * Macro that extracts all endpoints from every interface + * Macro that extracts all endpoints from every interface. * * @param iface_configs List of interface configurations like explained * in documentation for @ref APP_USBD_CLASS_INSTANCE_TYPEDEF * - * @return Comma separated list of endpoints + * @return Comma separated list of endpoints. */ /*lint -emacro( (40), APP_USBD_CLASS_IFACES_EP_EXTRACT) */ #define APP_USBD_CLASS_IFACES_EP_EXTRACT(iface_configs) \ @@ -554,29 +587,29 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( /** - * @brief USBD instance of class mnemonic + * @brief USBD instance of class mnemonic. * * Macro that generates mnemonic for the name of the structure that describes instance for selected class. * - * @param type_name The name of the instance without _t postfix + * @param type_name The name of the instance without _t postfix. * * @return The name with the right postfix to create the name for the type for the class. */ #define APP_USBD_CLASS_INSTANCE_TYPE(type_name) CONCAT_2(type_name, _t) /** - * @brief USBD data for instance class mnemonic + * @brief USBD data for instance class mnemonic. * * The mnemonic of the variable type that holds writable part of the class instance. * - * @param type_name The name of the instance without _t postfix + * @param type_name The name of the instance without _t postfix. * * @return The name with the right postfix to create the name for the data type for the class. */ #define APP_USBD_CLASS_DATA_TYPE(type_name) CONCAT_2(type_name, _data_t) /** - * @brief Declare class specific member of class instance + * @brief Declare class specific member of class instance. * * @param type Type of the attached class configuration. * @@ -585,16 +618,16 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( #define APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type) type class_part; /** - * @brief Used if there is no class specific configuration + * @brief Used if there is no class specific configuration. * - * This constant can be used if there is no specific configuration inside created instance + * This constant can be used if there is no specific configuration inside created instance. * * @sa APP_USBD_CLASS_INSTANCE_TYPEDEF */ #define APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE /** - * @brief Declare class specific member of class data + * @brief Declare class specific member of class data. * * @param type Type of the attached class data. * @@ -603,9 +636,9 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( #define APP_USBD_CLASS_DATA_SPECIFIC_DEC(type) APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type) /** - * @brief Used if there is no class specific data + * @brief Used if there is no class specific data. * - * This constant can be used if there is no specific writable data inside created instance + * This constant can be used if there is no specific writable data inside created instance. * * @sa APP_USBD_CLASS_DATA_TYPEDEF */ @@ -615,7 +648,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( /** - * @brief Instance structure declaration + * @brief Instance structure declaration. * * The macro that declares a variable type that would be used to store given class instance. * Class instance stores all the data from @ref app_usbd_class_inst_t and overlaid data for specified class. @@ -664,7 +697,28 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( } APP_USBD_CLASS_INSTANCE_TYPE(type_name) /** - * @brief Writable data structure declaration + * @brief Same as @ref APP_USBD_CLASS_INSTANCE_TYPEDEF but for class with EP0 only. + */ +#define APP_USBD_CLASS_INSTANCE_NO_EP_TYPEDEF(type_name, interfaces_configs, class_config_dec) \ + typedef union CONCAT_2(type_name, _u) \ + { \ + app_usbd_class_inst_t base; \ + struct \ + { \ + APP_USBD_CLASS_DATA_TYPE(type_name) * p_data; \ + app_usbd_class_methods_t const * p_class_methods; \ + struct \ + { \ + uint8_t cnt; \ + app_usbd_class_iface_conf_t \ + config[NUM_VA_ARGS(BRACKET_EXTRACT(interfaces_configs))]; \ + } iface; \ + class_config_dec \ + } specific; \ + } APP_USBD_CLASS_INSTANCE_TYPE(type_name) + +/** + * @brief Writable data structure declaration. * * The macro that declares a variable type that would be used to store given class writable data. * Writable data contains base part of the type @ref app_usbd_class_data_t followed by @@ -675,7 +729,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( * @ref APP_USBD_CLASS_DATA_SPECIFIC_DEC or * @ref APP_USBD_CLASS_DATA_SPECIFIC_DEC_NONE * - * @return The definition of the structure type that holds all the required writable data + * @return The definition of the structure type that holds all the required writable data. * * @note It should not be used directly in the final application. See @ref APP_USBD_CLASS_DATA_TYPEDEF instead. * @@ -690,7 +744,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( /** - * @brief Declare all data types required by the class instance + * @brief Declare all data types required by the class instance. * * Macro that declares data type first and then instance type. * @@ -712,6 +766,16 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( APP_USBD_CLASS_DATA_TYPEDEF(type_name, class_data_dec); \ APP_USBD_CLASS_INSTANCE_TYPEDEF(type_name, interface_configs, class_config_dec) +/** + * @brief Same as @ref APP_USBD_CLASS_TYPEDEF but for class with EP0 only. + */ +#define APP_USBD_CLASS_NO_EP_TYPEDEF(type_name, \ + interface_configs, \ + class_config_dec, \ + class_data_dec) \ + APP_USBD_CLASS_DATA_TYPEDEF(type_name, class_data_dec); \ + APP_USBD_CLASS_INSTANCE_NO_EP_TYPEDEF(type_name, interface_configs, class_config_dec) + /** * @brief Forward declaration of type defined by @ref APP_USBD_CLASS_TYPEDEF * @@ -720,12 +784,12 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( #define APP_USBD_CLASS_FORWARD(type_name) union CONCAT_2(type_name, _u) /** - * @brief Generate the initialization data for + * @brief Generate the initialization data for. * * Macro that generates the initialization data for instance. * - * @param p_ram_data Pointer to writable instance data structure - * @param class_methods Class methods + * @param p_ram_data Pointer to writable instance data structure. + * @param class_methods Class methods. * @param interfaces_configs Exactly the same interface config data that in @ref APP_USBD_CLASS_INSTANCE_TYPEDEF * @param class_config_part Configuration part. The data should be inside brackets. * Any data here would be removed from brackets and then put as an initialization @@ -750,9 +814,27 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( } \ } +/** + * @brief Same as @ref APP_USBD_CLASS_INSTANCE_INITVAL but for class with EP0 only. + */ +#define APP_USBD_CLASS_INSTANCE_NO_EP_INITVAL(p_ram_data, \ + class_methods, \ + interfaces_configs, \ + class_config_part) \ + { \ + .specific = { \ + .p_data = p_ram_data, \ + .p_class_methods = class_methods, \ + .iface = { \ + .cnt = NUM_VA_ARGS(BRACKET_EXTRACT(interfaces_configs)), \ + .config = { APP_USBD_CLASS_IFACES_CONFIG_EXTRACT(interfaces_configs) } \ + }, \ + BRACKET_EXTRACT(class_config_part) \ + } \ + } /** - * @brief Define the base class instance + * @brief Define the base class instance. * * Macro that defines whole instance variable and fill it with initialization data. * @@ -843,7 +925,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( /** - * @brief Define the base class instance in global scope + * @brief Define the base class instance in global scope. * * This is the same macro like @ref APP_USBD_CLASS_INST_DEF but it creates the instance * without static keyword. @@ -868,13 +950,28 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( class_config_part) /** - * @brief Access class specific configuration + * @brief Same as @ref APP_USBD_CLASS_INST_GLOBAL_DEF but for class with EP0 only. + */ +#define APP_USBD_CLASS_INST_NO_EP_GLOBAL_DEF(instance_name, \ + type_name, \ + class_methods, \ + interfaces_configs, \ + class_config_part) \ + static APP_USBD_CLASS_DATA_TYPE(type_name) CONCAT_2(instance_name, _data); \ + const APP_USBD_CLASS_INSTANCE_TYPE(type_name) instance_name = \ + APP_USBD_CLASS_INSTANCE_NO_EP_INITVAL( \ + &CONCAT_2(instance_name, _data), \ + class_methods, \ + interfaces_configs, \ + class_config_part) +/** + * @brief Access class specific configuration. * * Macro that returns class specific configuration. * - * @param[in] p_inst Instance pointer + * @param[in] p_inst Instance pointer. * - * @return A pointer for class specific part of the instance + * @return A pointer for class specific part of the instance. * * @note If macro is used on the instance that has no class specific configuration * an error would be generated during compilation. @@ -882,11 +979,11 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( #define APP_USBD_CLASS_GET_SPECIFIC_CONFIG(p_inst) (&((p_inst)->specific.class_part)) /** - * @brief Access class specific data + * @brief Access class specific data. * - * @param[in] p_inst Instance pointer + * @param[in] p_inst Instance pointer. * - * @return A pointer for class specific part of writable data + * @return A pointer for class specific part of writable data. * * @note If macro is used on the instance that has no class specific data * an error would be generated during compilation. @@ -894,7 +991,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( #define APP_USBD_CLASS_GET_SPECIFIC_DATA(p_inst) (&(((p_inst)->specific.p_data)->class_part)) /** - * @brief Macro to get base instance from class specific instance + * @brief Macro to get base instance from class specific instance. * * This macro may be used on class specific instance to get base instance that * can be processed by base instance access functions. @@ -907,6 +1004,96 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access( */ #define APP_USBD_CLASS_BASE_INSTANCE(p_inst) (&((p_inst)->base)) +/*lint -emacro(142 438 616 646, APP_USBD_CLASS_DESCRIPTOR_INIT, APP_USBD_CLASS_DESCRIPTOR_BEGIN, APP_USBD_CLASS_DESCRIPTOR_YIELD, APP_USBD_CLASS_DESCRIPTOR_END, APP_USBD_CLASS_DESCRIPTOR_WRITE)*/ + +/** + * @brief Initialize class descriptor. + * + * @param[in] p_ctx Class descriptor context. + */ + +#define APP_USBD_CLASS_DESCRIPTOR_INIT(p_ctx) \ + (p_ctx)->line = 0; + +/** + * @brief Begin class descriptor. + * + * @param[in] p_ctx Class descriptor context. + * @param[in] p_buff Buffer to write into. + * @param[in] max_size Size of the buffer. + */ + +#define APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size) \ + ASSERT((p_ctx) != NULL); \ + app_usbd_class_descriptor_state_t this_descriptor_feed; \ + this_descriptor_feed.p_buffer = (p_buff); \ + this_descriptor_feed.current_size = 0; \ + this_descriptor_feed.maximum_size = (max_size); \ + this_descriptor_feed.p_context = (p_ctx); \ + switch ((this_descriptor_feed.p_context)->line) \ + { \ + case 0: \ + ; + +/** + * @brief Yield class descriptor + * + */ + +#define APP_USBD_CLASS_DESCRIPTOR_YIELD() \ +do \ +{ \ + (this_descriptor_feed.p_context)->line = __LINE__; \ + return true; \ + case __LINE__: \ + ; \ +} while (0) + +/*lint -emacro(438 527, APP_USBD_CLASS_DESCRIPTOR_END)*/ + +/** + * @brief End class descriptor. + * + * This function has to be called at the end of class descriptor feeder function. + * No other operations in feeder function can be done after calling it. + */ + +#define APP_USBD_CLASS_DESCRIPTOR_END() \ + APP_USBD_CLASS_DESCRIPTOR_YIELD(); \ + } \ + (this_descriptor_feed.p_context)->line = 0; \ + return false; + + +/** + * @brief Write descriptor using protothreads. + * + * This function writes one byte to the buffer with offset. If buffer is full + * it yields. + * + * It is used by the class descriptor feeders internally. + * + * @ref APP_USBD_CLASS_DESCRIPTOR_BEGIN has to be called before using this function. + * @ref APP_USBD_CLASS_DESCRIPTOR_END has to be called after last use of this function. + * + * @param data Byte to be written to buffer. + */ +#define APP_USBD_CLASS_DESCRIPTOR_WRITE(data) \ +do \ +{ \ + (this_descriptor_feed.p_context)->data_buffer = (data); \ + if (this_descriptor_feed.current_size >= this_descriptor_feed.maximum_size) \ + { \ + APP_USBD_CLASS_DESCRIPTOR_YIELD(); \ + } \ + if(this_descriptor_feed.p_buffer != NULL) \ + { \ + *(this_descriptor_feed.p_buffer + this_descriptor_feed.current_size) = \ + (this_descriptor_feed.p_context)->data_buffer; \ + } \ + this_descriptor_feed.current_size++; \ +} while(0); + /** @} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_core.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_core.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_core.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_core.c index 31604ab..6200bfe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_core.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_core.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,11 +35,11 @@ * 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(APP_USBD) -#include "sdk_config.h" -#if APP_USBD_ENABLED #include "app_usbd_core.h" #include "app_usbd.h" #include "app_usbd_request.h" @@ -50,6 +50,18 @@ #include "app_usbd.h" #include "app_usbd_class_base.h" +#define NRF_LOG_MODULE_NAME app_usbd_core + +#if APP_USBD_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_USBD_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_USBD_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_USBD_CONFIG_DEBUG_COLOR +#else //APP_USBD_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //APP_USBD_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + /* Test if VID was configured */ #ifndef APP_USBD_VID #error APP_USBD_VID not properly defined. @@ -83,7 +95,7 @@ #define APP_USBD_CORE_DEVICE_DESCRIPTOR { \ .bLength = sizeof(app_usbd_descriptor_device_t), /* descriptor size */ \ .bDescriptorType = APP_USBD_DESCRIPTOR_DEVICE, /* descriptor type */ \ - .bcdUSB = APP_USBD_BCD_VER_MAKE(2,0), /* USB BCD version: 2.0 */ \ + .bcdUSB = APP_USBD_BCD_VER_MAKE(2,0,0), /* USB BCD version: 2.0 */ \ .bDeviceClass = 0, /* device class: 0 - specified by interface */ \ .bDeviceSubClass = 0, /* device subclass: 0 - specified by interface */ \ .bDeviceProtocol = 0, /* device protocol: 0 - specified by interface */ \ @@ -92,7 +104,8 @@ .idProduct = APP_USBD_PID, /* Product ID*/ \ .bcdDevice = APP_USBD_BCD_VER_MAKE( /* Device version BCD */ \ APP_USBD_DEVICE_VER_MAJOR, \ - APP_USBD_DEVICE_VER_MINOR), \ + APP_USBD_DEVICE_VER_MINOR, \ + APP_USBD_DEVICE_VER_SUB), \ .iManufacturer = APP_USBD_STRING_ID_MANUFACTURER, /* String ID: manufacturer */ \ .iProduct = APP_USBD_STRING_ID_PRODUCT, /* String ID: product */ \ .iSerialNumber = APP_USBD_STRING_ID_SERIAL, /* String ID: serial */ \ @@ -106,10 +119,13 @@ .wTotalLength = 0, /*Calculated dynamically*/ \ .bNumInterfaces = 0, /*Calculated dynamically*/ \ .bConfigurationValue = 1, /*Value passed to set configuration*/ \ - .iConfiguration = 0, /*Configuration ID: fixed to 0*/ \ + .iConfiguration = APP_USBD_STRING_ID_CONFIGURATION, /*Configuration ID*/ \ .bmAttributes = APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_ALWAYS_SET_MASK | \ - APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_SELF_POWERED_MASK, \ - .bMaxPower = APP_USBD_POWER_MAKE(500), \ + ((APP_USBD_CONFIG_SELF_POWERED) ? \ + APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_SELF_POWERED_MASK \ + : \ + 0), \ + .bMaxPower = APP_USBD_POWER_MAKE(APP_USBD_CONFIG_MAX_POWER), \ } /** @@ -139,27 +155,27 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons app_usbd_complex_evt_t const * const p_event); /** - * @brief Current USB device state + * @brief Current USB device state. * * This variable is updated automatically by core library. */ static app_usbd_state_t m_app_usbd_state = APP_USBD_STATE_Disabled; /** - * @brief Active device features + * @brief Active device features. * - * @note Only @ref APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP is supported for device + * @note Only @ref APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP is supported for device. */ static uint8_t m_device_features_state; /** - * @brief Remote wake-up pending flag + * @brief Remote wake-up pending flag. */ static nrf_atomic_flag_t m_rwu_pending; /** - * @brief Core class methods + * @brief Core class methods. * * Base methods interface for core class. * This is quite specific class - it would be only connected into endpoint 0. @@ -167,19 +183,18 @@ static nrf_atomic_flag_t m_rwu_pending; */ static const app_usbd_class_methods_t m_core_methods = { .event_handler = app_usbd_core_event_handler, - .get_descriptors = NULL, + .feed_descriptors = NULL, }; /** - * @brief Setup transfer buffer + * @brief Setup transfer buffer. */ static uint8_t m_setup_transfer_buff[NRF_DRV_USBD_EPSIZE]; /** - * @brief Handler for outgoing setup data + * @brief Handler for outgoing setup data. * - * @todo RK documentation */ static app_usbd_core_setup_data_handler_desc_t m_ep0_handler_desc; @@ -189,7 +204,7 @@ static app_usbd_core_setup_data_handler_desc_t m_ep0_handler_desc; /*lint -u -save -e26 -e40 -e64 -e123 -e505 -e651*/ /** - * @brief Core instance + * @brief Core instance. * * Create instance that would be connected into endpoints in USBD library. */ @@ -201,15 +216,14 @@ APP_USBD_CLASS_INST_GLOBAL_DEF( () ); /*lint -restore*/ - /** - * @brief Set the new USB state + * @brief Set the new USB state. * * Function changes the internal status of the bus. * If the bus status is different than the one configured, an event is passed to all * the instances. * - * @param state New state to be set + * @param state New state to be set. * * @sa usbd_core_state_get */ @@ -218,6 +232,10 @@ static void usbd_core_state_set(app_usbd_state_t state) if (m_app_usbd_state != state) { m_app_usbd_state = state; + if(state != APP_USBD_STATE_Configured) + { + CLR_BIT(m_device_features_state, APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP); + } static const app_usbd_evt_t evt_data = { .type = APP_USBD_EVT_STATE_CHANGED }; @@ -226,12 +244,12 @@ static void usbd_core_state_set(app_usbd_state_t state) } /** - * @brief Get the current USB state - internal function + * @brief Get the current USB state - internal function. * * This is just a wrapper for @ref app_usbd_core_state_get * to make symmetrical function to the internal @ref usbd_core_state_set. * - * @return Current USB state + * @return Current USB state. * * @sa usbd_core_state_set * @sa app_usbd_core_state_get @@ -242,7 +260,7 @@ static inline app_usbd_state_t usbd_core_state_get(void) } /** - * @brief Check current USBD power connection status + * @brief Check current USBD power connection status. * */ static inline bool usbd_core_power_is_detected(void) @@ -250,9 +268,18 @@ static inline bool usbd_core_power_is_detected(void) return 0 != ( (NRF_POWER->USBREGSTATUS) & POWER_USBREGSTATUS_VBUSDETECT_Msk); } +/** + * @brief Clear current EP0 handler. + * + * Function just clears the EP0 handler without calling it. + */ +static inline void usbd_core_ep0_handler_clear(void) +{ + m_ep0_handler_desc.handler = NULL; +} /** - * @brief Safely call EP0 handler + * @brief Safely call EP0 handler. * * Function calls EP0 handler only if its pointer is non-zero. * @@ -263,7 +290,7 @@ static inline ret_code_t usbd_core_ep0_handler_call_and_clear(nrf_drv_usbd_ep_st app_usbd_core_setup_data_handler_t handler = m_ep0_handler_desc.handler; if (NULL != handler) { - m_ep0_handler_desc.handler = NULL; + usbd_core_ep0_handler_clear(); return handler(status, m_ep0_handler_desc.p_context); } @@ -271,7 +298,7 @@ static inline ret_code_t usbd_core_ep0_handler_call_and_clear(nrf_drv_usbd_ep_st } /** - * @brief Check if EP0 handler is configured + * @brief Check if EP0 handler is configured. * * EP0 handler is configured is any instance that has processed SETUP command * expects some incoming / outgoing data. @@ -284,8 +311,8 @@ static inline ret_code_t usbd_core_ep0_handler_call_and_clear(nrf_drv_usbd_ep_st * This function adds small layer of abstraction for checking if EP0 handler * is already configured. * - * @retval true EP0 handler is set - * @retval false EP0 handler is cleared + * @retval true EP0 handler is set. + * @retval false EP0 handler is cleared. */ static inline bool usb_core_ep0_handler_check(void) { @@ -293,7 +320,7 @@ static inline bool usb_core_ep0_handler_check(void) } /** - * @brief Empty data handler + * @brief Empty data handler. * * Data handler used only to mark that there is requested data during SETUP. * @@ -310,7 +337,7 @@ static ret_code_t setup_data_handler_empty(nrf_drv_usbd_ep_status_t status, void /** * @brief * - * @todo RK Documentation + * Empty EP0 transfer transfer handler. */ static app_usbd_core_setup_data_handler_desc_t const m_setup_data_handler_empty_desc = { @@ -319,32 +346,33 @@ static app_usbd_core_setup_data_handler_desc_t const m_setup_data_handler_empty_ }; /** - * @brief Structure used as a context for descriptor feeder + * @brief Structure used as a context for descriptor feeder. * * Structure with all the data required to process instances to generate descriptor * data chunk. */ typedef struct { - app_usbd_class_inst_t const * p_cinst; //!< The class instance that is to be processed next. - const uint8_t * p_desc; //!< Pointer at current descriptor or NULL if finished. - /**< - * If we get NULL on transfer function enter it means that ZLP is required. - * Or it is time to finish the transfer (depending on @c total_left). - */ - size_t desc_left; //!< Number of bytes left in the current class descriptor to send - size_t total_left; //!< Number of bytes left that was requested by the host + app_usbd_class_inst_t const * p_cinst; //!< The class instance that is to be processed next. + const uint8_t * p_desc; //!< Pointer at current descriptor or NULL if finished. + /**< + * If the value passed by @ref p_desc is NULL on transfer function enter it means that ZLP is required. + * Or it is time to finish the transfer (depending on @c total_left). + */ + size_t desc_left; //!< Number of bytes left in the current class descriptor to send + size_t total_left; //!< Number of bytes left that was requested by the host + app_usbd_class_descriptor_ctx_t feed_thread; //!< Class descriptor context } app_usbd_core_descriptor_conf_feed_data_t; /** - * @brief Default data used by the feeder + * @brief Default data used by the feeder. * * */ static app_usbd_core_descriptor_conf_feed_data_t m_descriptor_conf_feed_data; /** - * @brief Descriptor feeder + * @brief Descriptor feeder. * * Descriptor feeder is used as an callback function when descriptors are * transfered and buffer is ready for next data. @@ -364,7 +392,10 @@ static bool usbd_descriptor_conf_feeder( bool continue_req = true; app_usbd_core_descriptor_conf_feed_data_t * p_data = p_context; - if (NULL == p_data->p_desc) + + + if ((p_data->p_desc == NULL) && (app_usbd_class_next_get(p_data->p_cinst) == NULL) + && (p_data->desc_left == 0)) { /* ZLP */ continue_req = false; @@ -374,26 +405,48 @@ static bool usbd_descriptor_conf_feeder( else { ASSERT(ep_size <= NRF_DRV_USBD_FEEDER_BUFFER_SIZE); - uint8_t * p_tx_buff = nrf_drv_usbd_feeder_buffer_get(); + uint8_t * p_tx_buff; size_t size = 0; /* Currently added number of bytes */ size_t tx_size; /* Number of bytes to send right now */ + bool feeding = false; /* Feeder function can use the USBD driver internal buffer */ p_tx_buff = nrf_drv_usbd_feeder_buffer_get(); tx_size = MIN(ep_size, p_data->total_left); + while (0 != tx_size) { - /* Process transfer */ - if (0 < p_data->desc_left) + size_t to_copy = MIN(tx_size, p_data->desc_left); + + /* First transfer */ + if (p_data->p_desc != NULL) { - size_t to_copy = MIN(tx_size, p_data->desc_left); memcpy(p_tx_buff + size, p_data->p_desc, to_copy); - p_data->desc_left -= to_copy; - p_data->total_left -= to_copy; - tx_size -= to_copy; - size += to_copy; - p_data->p_desc += to_copy; + p_data->p_desc = NULL; + } + /* Starting with second transfer */ + else if (0 < p_data->desc_left) + { + UNUSED_RETURN_VALUE(p_data->p_cinst->p_class_methods->feed_descriptors( + &p_data->feed_thread, p_data->p_cinst, + (uint8_t *)p_tx_buff + size, to_copy)); + feeding = true; + } + else + { + ; + } + + p_data->desc_left -= to_copy; + p_data->total_left -= to_copy; + tx_size -= to_copy; + size += to_copy; + + /* Switch to next class if no descriptor left and first feeding was done */ + if(p_data->desc_left == 0 && feeding) + { + p_data->p_cinst = app_usbd_class_next_get(p_data->p_cinst); } if (0 == p_data->total_left) @@ -417,13 +470,15 @@ static bool usbd_descriptor_conf_feeder( } else { - /* Prepare next descriptor */ - p_data->p_desc = - p_data->p_cinst->p_class_methods->get_descriptors( - p_data->p_cinst, - &p_data->desc_left); - /* Get next descriptor */ - p_data->p_cinst = app_usbd_class_next_get(p_data->p_cinst); + /* New class - count descriptor size and initialize feeding thread */ + app_usbd_class_descriptor_ctx_t desiz; + APP_USBD_CLASS_DESCRIPTOR_INIT(&desiz); + while(p_data->p_cinst->p_class_methods->feed_descriptors( + &desiz, p_data->p_cinst, NULL, sizeof(uint8_t))) + { + p_data->desc_left++; + } + APP_USBD_CLASS_DESCRIPTOR_INIT(&p_data->feed_thread); } } else @@ -438,11 +493,11 @@ static bool usbd_descriptor_conf_feeder( } /** - * @brief Standard endpoint request handle + * @brief Standard endpoint request handle. * - * @param[in] p_setup_ev Setup event + * @param[in] p_setup_ev Setup event. * - * @return Standard error code + * @return Standard error code. */ static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev) { @@ -452,23 +507,39 @@ static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev } nrf_drv_usbd_ep_t ep_addr = (nrf_drv_usbd_ep_t)(p_setup_ev->setup.wIndex.lb); - switch (p_setup_ev->setup.bmRequest) + app_usbd_state_t usb_state = usbd_core_state_get(); + + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_GET_STATUS: { - size_t tx_size; - uint16_t * p_tx_buff = app_usbd_core_setup_transfer_buff_get(&tx_size); + if ((usb_state == APP_USBD_STATE_Configured) || (NRF_USBD_EP_NR_GET(ep_addr) == 0)) + { + size_t tx_size; + uint16_t * p_tx_buff = app_usbd_core_setup_transfer_buff_get(&tx_size); - p_tx_buff[0] = nrf_drv_usbd_ep_stall_check(ep_addr) ? 1 : 0; - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_tx_buff, sizeof(uint16_t)); + p_tx_buff[0] = nrf_drv_usbd_ep_stall_check(ep_addr) ? 1 : 0; + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_tx_buff, sizeof(uint16_t)); + } + else + { + return NRF_ERROR_INVALID_STATE; + } } case APP_USBD_SETUP_STDREQ_SET_FEATURE: { if ((!NRF_USBD_EPISO_CHECK(ep_addr)) && (p_setup_ev->setup.wValue.w == APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT)) { - nrf_drv_usbd_ep_stall(ep_addr); - return NRF_SUCCESS; + if ((usb_state == APP_USBD_STATE_Configured) || (NRF_USBD_EP_NR_GET(ep_addr) == 0)) + { + nrf_drv_usbd_ep_stall(ep_addr); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_INVALID_STATE; + } } break; } @@ -477,9 +548,16 @@ static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev if ((!NRF_USBD_EPISO_CHECK(ep_addr)) && (p_setup_ev->setup.wValue.w == APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT)) { - nrf_drv_usbd_ep_dtoggle_clear(ep_addr); - nrf_drv_usbd_ep_stall_clear(ep_addr); - return NRF_SUCCESS; + if ((usb_state == APP_USBD_STATE_Configured) || (NRF_USBD_EP_NR_GET(ep_addr) == 0)) + { + nrf_drv_usbd_ep_dtoggle_clear(ep_addr); + nrf_drv_usbd_ep_stall_clear(ep_addr); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_INVALID_STATE; + } } break; } @@ -490,13 +568,13 @@ static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev } /** - * @brief Standard interface request handle + * @brief Standard interface request handle. * - * @param[in,out] p_class_inst Class instance that holds selected interface - * @param[in] iface_idx Index of the interface in class structure - * @param[in] p_event Event structure to be processed + * @param[in,out] p_class_inst Class instance that holds selected interface. + * @param[in] iface_idx Index of the interface in class structure. + * @param[in] p_event Event structure to be processed. * - * @return Operation status + * @return Operation status. */ static ret_code_t setup_interface_req_std_handle( app_usbd_class_inst_t const * const p_class_inst, @@ -512,7 +590,7 @@ static ret_code_t setup_interface_req_std_handle( if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_GET_STATUS: { @@ -540,7 +618,7 @@ static ret_code_t setup_interface_req_std_handle( } else /* APP_USBD_SETUP_REQDIR_OUT */ { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_SET_INTERFACE: { @@ -566,7 +644,7 @@ static ret_code_t setup_interface_req_std_handle( /** * @brief * - * @todo RK Documentation + * Descriptors feeder handle structure. */ static const nrf_drv_usbd_handler_desc_t usbd_descriptor_feeder_desc = { @@ -576,7 +654,7 @@ static const nrf_drv_usbd_handler_desc_t usbd_descriptor_feeder_desc = static ret_code_t setup_device_req_get_status( app_usbd_class_inst_t const * const p_inst, - app_usbd_setup_evt_t const * const p_setup_ev) + app_usbd_setup_evt_t const * const p_setup_ev) { size_t max_size; uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); @@ -596,18 +674,28 @@ static ret_code_t setup_device_req_get_status( } static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * const p_inst, - app_usbd_setup_evt_t const * const p_setup_ev) + app_usbd_setup_evt_t const * const p_setup_ev) { switch (p_setup_ev->setup.wValue.hb) { case APP_USBD_DESCRIPTOR_DEVICE: { + if(p_setup_ev->setup.wLength.w == 0) + { + return NRF_SUCCESS; + } + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), &m_device_dsc, sizeof(m_device_dsc)); } case APP_USBD_DESCRIPTOR_CONFIGURATION: { + if(p_setup_ev->setup.wLength.w == 0) + { + return NRF_SUCCESS; + } + /* The size equals the size of configuration descriptor and all classes descriptors */ const size_t size = MIN( sizeof(app_usbd_descriptor_configuration_t), @@ -621,17 +709,26 @@ static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * p_class = app_usbd_class_next_get(p_class)) { ASSERT(NULL != (p_class->p_class_methods)); - ASSERT(NULL != (p_class->p_class_methods->get_descriptors)); - size_t dsc_size; - const void * dsc = p_class->p_class_methods->get_descriptors(p_class, &dsc_size); - UNUSED_VARIABLE(dsc); + ASSERT(NULL != (p_class->p_class_methods->feed_descriptors)); + size_t dsc_size = 0; + app_usbd_class_descriptor_ctx_t siz_desc; + APP_USBD_CLASS_DESCRIPTOR_INIT(&siz_desc); + while(p_class->p_class_methods->feed_descriptors(&siz_desc, + p_class, + NULL, + sizeof(uint8_t)) + ) + { + dsc_size++; + } total_length += dsc_size; iface_count += app_usbd_class_iface_count_get(p_class); } /* Access transmission buffer */ size_t max_size; - app_usbd_descriptor_configuration_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); + app_usbd_descriptor_configuration_t * p_trans_buff = + app_usbd_core_setup_transfer_buff_get(&max_size); /* Copy the configuration descriptor and update the fields that require it */ ASSERT(size <= max_size); memcpy(p_trans_buff, &m_configuration_dsc, size); @@ -644,6 +741,7 @@ static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_REMOTE_WAKEUP_MASK; } + m_descriptor_conf_feed_data.p_cinst = app_usbd_class_first_get(); m_descriptor_conf_feed_data.p_desc = (void *)p_trans_buff; m_descriptor_conf_feed_data.desc_left = size; @@ -669,6 +767,11 @@ static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * } case APP_USBD_DESCRIPTOR_STRING: { + if(p_setup_ev->setup.wLength.w == 0) + { + return NRF_SUCCESS; + } + app_usbd_string_desc_idx_t id = (app_usbd_string_desc_idx_t)(p_setup_ev->setup.wValue.lb); uint16_t langid = p_setup_ev->setup.wIndex.w; @@ -691,8 +794,9 @@ static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * return NRF_ERROR_NOT_SUPPORTED; } -static ret_code_t setup_device_req_get_configuration(app_usbd_class_inst_t const * const p_inst, - app_usbd_setup_evt_t const * const p_setup_ev) +static ret_code_t setup_device_req_get_configuration( + app_usbd_class_inst_t const * const p_inst, + app_usbd_setup_evt_t const * const p_setup_ev) { size_t max_size; uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); @@ -713,8 +817,9 @@ static ret_code_t setup_device_req_get_configuration(app_usbd_class_inst_t const return app_usbd_core_setup_rsp(&p_setup_ev->setup, p_trans_buff, sizeof(p_trans_buff[0])); } -static ret_code_t setup_device_req_set_configuration(app_usbd_class_inst_t const * const p_inst, - app_usbd_setup_evt_t const * const p_setup_ev) +static ret_code_t setup_device_req_set_configuration( + app_usbd_class_inst_t const * const p_inst, + app_usbd_setup_evt_t const * const p_setup_ev) { app_usbd_state_t usb_state = usbd_core_state_get(); if (!((usb_state == APP_USBD_STATE_Configured) || @@ -744,15 +849,15 @@ static ret_code_t setup_device_req_set_configuration(app_usbd_class_inst_t const } /** - * @brief Internal SETUP event handler - * @param[in] p_inst Instance of the class - * @param[in] p_setup_ev Setup request - * @return Standard error code - * @retval NRF_SUCCESS if request handled correctly - * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported + * @brief Internal SETUP event handler. + * @param[in] p_inst Instance of the class. + * @param[in] p_setup_ev Setup request. + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. */ -static ret_code_t setup_device_req_std(app_usbd_class_inst_t const * const p_inst, - app_usbd_setup_evt_t const * const p_setup_ev) +static ret_code_t setup_device_req_std_handler(app_usbd_class_inst_t const * const p_inst, + app_usbd_setup_evt_t const * const p_setup_ev) { ASSERT(p_inst != NULL); ASSERT(p_setup_ev != NULL); @@ -764,7 +869,7 @@ static ret_code_t setup_device_req_std(app_usbd_class_inst_t const * const p_ins if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_GET_STATUS: { @@ -786,25 +891,21 @@ static ret_code_t setup_device_req_std(app_usbd_class_inst_t const * const p_ins } else /* APP_USBD_SETUP_REQDIR_OUT */ { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_SET_ADDRESS: { - app_usbd_state_t usb_state = usbd_core_state_get(); - if ((usb_state != APP_USBD_STATE_Default) && - (usb_state != APP_USBD_STATE_Addressed) && - (usb_state != APP_USBD_STATE_Configured)) - { - return NRF_ERROR_INVALID_STATE; - } - app_usbd_all_iface_deselect(); - usbd_core_state_set(APP_USBD_STATE_Addressed); - return NRF_SUCCESS; + ASSERT(0); /* should never reach this point */ + break; } case APP_USBD_SETUP_STDREQ_SET_FEATURE: { if (p_setup_ev->setup.wValue.w == APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP) { + if (!app_usbd_class_rwu_enabled_check()) + { + return NRF_ERROR_FORBIDDEN; + } SET_BIT(m_device_features_state, APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP); return NRF_SUCCESS; } @@ -814,6 +915,10 @@ static ret_code_t setup_device_req_std(app_usbd_class_inst_t const * const p_ins { if (p_setup_ev->setup.wValue.w == APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP) { + if (!app_usbd_class_rwu_enabled_check()) + { + return NRF_ERROR_FORBIDDEN; + } CLR_BIT(m_device_features_state, APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP); return NRF_SUCCESS; } @@ -837,27 +942,34 @@ static ret_code_t setup_device_req_std(app_usbd_class_inst_t const * const p_ins } /** - * @brief Process SETUP command + * @brief Process SETUP command. * - * Auxiliary function for SETUP command processing + * Auxiliary function for SETUP command processing. */ static inline ret_code_t app_usbd_core_setup_req_handler(app_usbd_class_inst_t const * const p_inst) { app_usbd_setup_evt_t setup_ev; ret_code_t ret = NRF_ERROR_NOT_SUPPORTED; /* Final result of request processing function */ - /* This handler have to be cleared when SETUP is entered */ - // ASSERT(!usb_core_ep0_handler_check()); - setup_ev.type = APP_USBD_EVT_DRV_SETUP; nrf_drv_usbd_setup_get((nrf_drv_usbd_setup_t *)&(setup_ev.setup)); + NRF_LOG_DEBUG("SETUP: t: 0x%.2x r: 0x%.2x", + setup_ev.setup.bmRequestType, + setup_ev.setup.bRequest); + if (usb_core_ep0_handler_check()) + { + NRF_LOG_WARNING("Previous setup not finished!"); + } + /* Clear EP0 handler if there is anything in progress */ + usbd_core_ep0_handler_clear(); + switch (app_usbd_setup_req_rec(setup_ev.setup.bmRequestType)) { case APP_USBD_SETUP_REQREC_DEVICE: { /* Endpoint 0 has core instance (that process device requests) connected */ - ret = setup_device_req_std(p_inst, &setup_ev); + ret = setup_device_req_std_handler(p_inst, &setup_ev); if (ret == NRF_ERROR_NOT_SUPPORTED) { ret = app_usbd_all_until_served_call((app_usbd_complex_evt_t const *)&setup_ev); @@ -916,8 +1028,11 @@ static inline ret_code_t app_usbd_core_setup_req_handler(app_usbd_class_inst_t c { if (usb_core_ep0_handler_check()) { - /* Request processed successfully and requires SETUP data */ - nrf_drv_usbd_setup_data_clear(); + if (NRF_DRV_USBD_EPOUT0 == nrf_drv_usbd_last_setup_dir_get()) + { + /* Request processed successfully and requires SETUP data */ + nrf_drv_usbd_setup_data_clear(); + } } else { @@ -934,7 +1049,7 @@ static inline ret_code_t app_usbd_core_setup_req_handler(app_usbd_class_inst_t c } /** - * @brief Event handler for core module + * @brief Event handler for core module. * * The event handler that would process all events directed to device. * @@ -966,6 +1081,15 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons ret = NRF_SUCCESS; break; } + case APP_USBD_EVT_SETUP_SETADDRESS: + { + app_usbd_state_t usb_state = usbd_core_state_get(); + if (usb_state == APP_USBD_STATE_Default) + { + usbd_core_state_set(APP_USBD_STATE_Addressed); + } + break; + } case APP_USBD_EVT_DRV_SETUP: { ret = app_usbd_core_setup_req_handler(p_inst); @@ -1007,6 +1131,11 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons /* Data transfer on endpoint 0 */ case APP_USBD_EVT_DRV_EPTRANSFER: { + if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_ABORTED) + { + /* Just ignore aborting */ + break; + } /* This EPTRANSFER event has to be called only for EP0 */ ASSERT((p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPOUT0) || (p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPIN0)); @@ -1016,20 +1145,17 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons { if (usb_core_ep0_handler_check()) { - /* Request processed successfully and requires SETUP data */ - nrf_drv_usbd_setup_data_clear(); + if (p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPOUT0) + { + /* Request processed successfully and requires SETUP data */ + nrf_drv_usbd_setup_data_clear(); + } } else { - /* Request processed successfully */ - /* Clear setup only for a write transfer - for a read transfer, - * it is cleared inside the driver */ - if (p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPOUT0) + if (!nrf_drv_usbd_errata_154()) { - if (!nrf_drv_usbd_errata_154()) - { - nrf_drv_usbd_setup_clear(); - } + nrf_drv_usbd_setup_clear(); } } } @@ -1047,6 +1173,21 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons return ret; } +/** @} */ + +void app_usbd_core_ep0_enable(void) +{ + app_usbd_ep_enable(NRF_DRV_USBD_EPOUT0); + app_usbd_ep_enable(NRF_DRV_USBD_EPIN0); +} + +void app_usbd_core_ep0_disable(void) +{ + app_usbd_ep_disable(NRF_DRV_USBD_EPOUT0); + app_usbd_ep_disable(NRF_DRV_USBD_EPIN0); +} + + ret_code_t app_usbd_core_setup_rsp(app_usbd_setup_t const * p_setup, void const * p_data, size_t size) @@ -1107,6 +1248,4 @@ bool app_usbd_core_feature_state_get(app_usbd_setup_stdfeature_t feature) return IS_SET(m_device_features_state, feature) ? true : false; } - -/** @} */ -#endif // APP_USBD_ENABLED +#endif //NRF_MODULE_ENABLED(APP_USBD) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_core.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_core.h similarity index 83% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_core.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_core.h index c9bf456..efa9d3e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_core.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_core.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_CORE_H__ @@ -62,7 +62,7 @@ extern "C" { */ /** - * @brief Core interface configuration + * @brief Core interface configuration. * * Core instance would have 2 endpoints (IN0 and OUT0). * The interface number does not matter because it is not used. @@ -70,7 +70,7 @@ extern "C" { #define APP_USBD_CORE_CLASS_CONFIGURATION ((0, NRF_DRV_USBD_EPOUT0, NRF_DRV_USBD_EPIN0)) /** - * @brief USB Device state + * @brief USB Device state. * * Possible USB Device states according to specification. */ @@ -85,7 +85,7 @@ typedef enum }app_usbd_state_t; /** - * @brief EP0 handler function pointer + * @brief EP0 handler function pointer. * * Type of the variable that would hold the pointer to the handler for * endpoint 0 messages processing. @@ -96,7 +96,7 @@ typedef ret_code_t (*app_usbd_core_setup_data_handler_t)(nrf_drv_usbd_ep_status_ void * p_context); /** - * @brief Variable type used to register EP0 transfer handler + * @brief Variable type used to register EP0 transfer handler. * * EP0 messages are processed by core instance. * Another class can register itself to receive messages from EP0 when requesting @@ -110,7 +110,7 @@ typedef struct /*lint -save -e10 -e26 -e93 -e123 -e505 */ /** - * @brief Declare Core instance type + * @brief Declare Core instance type. * * USBD core instance type definition. */ @@ -121,11 +121,11 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_core, /*lint -restore*/ /** - * @brief Access to core instance + * @brief Access to core instance. * * Function that returns pointer to the USBD core instance. * - * @return pointer to the core instance + * @return pointer to the core instance. */ static inline app_usbd_class_inst_t const * app_usbd_core_instance_access(void) { @@ -134,13 +134,29 @@ static inline app_usbd_class_inst_t const * app_usbd_core_instance_access(void) } /** - * @brief Default simple response to setup command + * @brief Enable endpoint 0 + * + * Function enables endpoint OUT0 and IN0. + * This makes the USB respond to SETUP transfers. + */ +void app_usbd_core_ep0_enable(void); + +/** + * @brief Disable endpoint 0 + * + * Function disables endpoint OUT0 and IN0. + * This makes the USB ignore SETUP transfers. + */ +void app_usbd_core_ep0_disable(void); + +/** + * @brief Default simple response to setup command. * * This function generates default simple response. * It sends ZLP when required and on takes care on allowing status stage when * transfer is finished. * - * @param p_setup Pointer to original setup message + * @param p_setup Pointer to original setup message. * @param p_data Pointer to the response. This has to be globaly aviable data. * @param size Total size of the answer - The function takes care about * limiting the size of transfered data to the size required @@ -151,16 +167,16 @@ ret_code_t app_usbd_core_setup_rsp(app_usbd_setup_t const * p_setup, size_t size); /** - * @brief Configure the handler for the nearest setup data endpoint transfer + * @brief Configure the handler for the nearest setup data endpoint transfer. * * This function would be called on incomming setup data. * The correct place to set the handler for a data is when SETUP command * was received. * - * @param ep Endpoint number (only IN0 and OUT0) are supported. + * @param ep Endpoint number (only IN0 and OUT0 are supported). * @param p_handler_desc Descriptor of the handler to be called. * - * @retval NRF_SUCCESS Successfully configured + * @retval NRF_SUCCESS Successfully configured. * @retval NRF_ERROR_INVALID_ADDR Last received setup direction does not match * configured endpoint. */ @@ -172,28 +188,28 @@ ret_code_t app_usbd_core_setup_data_handler_set( * @brief Set up a data transfer buffer. * * Returns special internal buffer that can be used in setup transfer. - * @return Internal buffer pointer + * @return Internal buffer pointer. */ void * app_usbd_core_setup_transfer_buff_get(size_t * p_size); -/**@brief Return internal USBD core state +/**@brief Return internal USBD core state. * - * @return Check @ref app_usbd_state_t to find possible USBD core states + * @return Check @ref app_usbd_state_t to find possible USBD core states. */ app_usbd_state_t app_usbd_core_state_get(void); /** - * @brief Check current feature state + * @brief Check current feature state. * * Function checks the state of the selected feature that was configured by the host. * - * @param feature Feature to check. + * @param feature Feature to check. @ref app_usbd_setup_stdfeature_t * Only features related to the device should be checked by this function. * - * @retval true Selected feature is set - * @retval false Selected feature is cleared + * @retval true Selected feature is set. + * @retval false Selected feature is cleared. */ bool app_usbd_core_feature_state_get(app_usbd_setup_stdfeature_t feature); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_descriptor.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_descriptor.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_descriptor.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_descriptor.h index ef6caf6..5c2e100 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_descriptor.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_descriptor.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_DESCRIPTOR_H__ @@ -51,7 +51,7 @@ extern "C" { #endif /* Compiler support for anonymous unions */ -ANON_UNIONS_ENABLE +ANON_UNIONS_ENABLE; /** * @defgroup app_usbd_descriptor USB standard descriptors @@ -62,30 +62,30 @@ ANON_UNIONS_ENABLE */ /** - * @brief Helper macro for translating unsigned 24 bit value to 2 byte raw descriptor + * @brief Helper macro for translating unsigned 24 bit value to 2 byte raw descriptor. * */ #define APP_USBD_U16_TO_RAW_DSC(val) (uint8_t)(val), \ (uint8_t)(((val) / (256))) /** - * @brief Helper macro for translating unsigned 24 bit value to 3 byte raw descriptor + * @brief Helper macro for translating unsigned 24 bit value to 3 byte raw descriptor. * */ #define APP_USBD_U24_TO_RAW_DSC(val) (uint8_t)(val), \ (uint8_t)(((val) / (256))), \ (uint8_t)(((val) / (256 * 256))) /** - * @brief Helper macro for translating unsigned 32 bit value to 4 byte raw descriptor + * @brief Helper macro for translating unsigned 32 bit value to 4 byte raw descriptor. * */ #define APP_USBD_U32_TO_RAW_DSC(val) (uint8_t)(val), \ (uint8_t)(((val) / (256))), \ (uint8_t)(((val) / (256 * 256))) \ (uint8_t)(((val) / (256 * 256 * 256))) /** - * @brief Descriptor types + * @brief Descriptor types. * * Descriptor types used in two situations: - * - when processing @ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR SETUP request, + * - When processing @ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR SETUP request, * the required descriptor type may be placed in wValue in HighByte. * - As a descriptor identifier itself inside descriptor stream. * @@ -118,16 +118,18 @@ typedef enum * Cannot be accessed by GetDescriptor or SetDescriptor */ APP_USBD_DESCRIPTOR_DEVICE_QUALIFIER = 6, /**< @note Not supported - used only in HighSpeed capable devices. */ - APP_USBD_DESCRIPTOR_OTHER_SPEED_CONFIGURATION = 7, /**< @note Not supported - our USB implementation supports only one speed. */ + APP_USBD_DESCRIPTOR_OTHER_SPEED_CONFIGURATION = 7, /**< @note Not supported - USB library supports only one speed. */ APP_USBD_DESCRIPTOR_INTERFACE_POWER = 8, /**< @note Not supported */ - APP_USBD_DESCRIPTOR_OTG = 9, /**< @note Not supported - Our USB have not OTG functionality */ + APP_USBD_DESCRIPTOR_OTG = 9, /**< @note Not supported - USB library does not have OTG functionality */ APP_USBD_DESCRIPTOR_DEBUG = 10, /**< Debug channel descriptor if available, can be only reached by GetDescriptor */ - APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION = 11 /**< + APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION = 11, /**< * Descriptor used to describe that two or more interfaces are associated to the same function. * * @note It is returned together with @ref APP_USBD_DESCRIPTOR_CONFIGURATION. * Cannot be accessed by GetDescriptor or SetDescriptor */ + APP_USBD_DESCRIPTOR_REPORT = 34, /**< HID Report descriptor. */ + APP_USBD_DESCRIPTOR_PHYSICAL = 35 /**< HID Physical descriptor. */ } app_usbd_descriptor_t; @@ -135,7 +137,7 @@ typedef enum #pragma pack(push, 1) /** - * @brief Common descriptor header + * @brief Common descriptor header. * * The header that we can find on the beginning of all descriptors that contains * the descriptor length and type. @@ -148,9 +150,9 @@ typedef struct } app_usbd_descriptor_header_t; /** - * @brief Device descriptor + * @brief Device descriptor. * - * Descriptor used for the whole device + * Descriptor used for the whole device. */ typedef struct { @@ -181,7 +183,7 @@ typedef struct } app_usbd_descriptor_device_t; /** - * @brief Attributes masks + * @brief Attributes masks. * * Masks used for attributes in configuration. */ @@ -196,7 +198,7 @@ typedef enum } app_usbd_descriptor_configuration_attributes_t; /** - * @brief Configuration descriptor + * @brief Configuration descriptor. * * Descriptor used at the beginning of configuration response. */ @@ -213,7 +215,7 @@ typedef struct } app_usbd_descriptor_configuration_t; /** - * @brief Raw descriptor - String descriptor zero + * @brief Raw descriptor - String descriptor zero. * * String descriptor sent only as a response for GetDescriptor. */ @@ -225,7 +227,7 @@ typedef struct } app_usbd_descriptor_string0_t; /** - * @brief Raw descriptor - Any normal string + * @brief Raw descriptor - Any normal string. * * String descriptor sent only as a response for GetDescriptor. */ @@ -238,7 +240,7 @@ typedef struct /** - * @brief Interface descriptor + * @brief Interface descriptor. * * Interface descriptor, returned as a part of configuration descriptor. */ @@ -271,7 +273,7 @@ typedef struct #define APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_MASK BF_MASK(2, APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET) /** - * @brief Endpoint attributes mnemonics + * @brief Endpoint attributes mnemonics. * * @sa APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_MASK * @sa APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_MASK @@ -295,7 +297,7 @@ typedef enum } app_usbd_descriptor_ep_attr_bitmap_t; /** - * @brief Endpoint descriptor + * @brief Endpoint descriptor. * * Endpoint descriptor, returned as a part of configuration descriptor. */ @@ -310,7 +312,7 @@ typedef struct } app_usbd_descriptor_ep_t; /** - * @brief Interface association descriptor + * @brief Interface association descriptor. */ typedef struct { @@ -325,7 +327,7 @@ typedef struct } app_usbd_descriptor_iad_t; #pragma pack(pop) -ANON_UNIONS_DISABLE +ANON_UNIONS_DISABLE; #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_langid.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_langid.h new file mode 100644 index 0000000..14a464d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_langid.h @@ -0,0 +1,300 @@ +/** + * Copyright (c) 2016 - 2019, 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 APP_USBD_LANGID_H__ +#define APP_USBD_LANGID_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * @brief This file contains LANGID variable type with all defined values. + * + * This file was created using Language Identifiers (LANGIDs) 3/29/00 Version 1.0, + * available on USB web page: + * http://www.usb.org/developers/docs/USB_LANGIDs.pdf + * + * @note + * Do not include this file directly to the project. + * It is included by @file app_usbd_request.h. + */ + +/** + * Offset of the lowest bit of primary language identifier. + * @sa app_usbd_langid_t + */ +#define APP_USB_LANG_OFFSET 0 + +/** + * Bitmask for a primary language identifier. + * @sa app_usbd_langid_t + */ +#define APP_USB_LANG_MASK BF_MASK(10, APP_USB_LANG_OFFSET) + +/** + * Macro for defining language identifier. + * + * @param x Language identifier value. + */ +#define APP_USB_LANG_DEF(x) ((x) << (APP_USB_LANG_OFFSET)) + +/** + * Offset of the lowest bit of sublanguage identifier. + * @sa app_usbd_langid_t + */ +#define APP_USB_SUBLANG_OFFSET 10 + +/** + * Bitmask for a sublanguage identifier. + * @sa app_usbd_langid_t + */ +#define APP_USB_SUBLANG_MASK BF_MASK(6, APP_USB_SUBLANG_OFFSET) + +/** + * Macro for defining language identifier. + * + * @param x Language identifier value. + */ +#define APP_USB_SUBLANG_DEF(x) ((x) << (APP_USB_SUBLANG_OFFSET)) + +/** + * @brief Primary language identifiers. + * + * Mnemonics for primary language identifiers. + * This mnemonics can be combined using the logical OR operator with @ref app_usbd_langid_sub_t. + */ +typedef enum +{ + APP_USBD_LANG_ARABIC = APP_USB_LANG_DEF(0x01U), /**< Arabic */ + APP_USBD_LANG_BULGARIAN = APP_USB_LANG_DEF(0x02U), /**< Bulgarian */ + APP_USBD_LANG_CATALAN = APP_USB_LANG_DEF(0x03U), /**< Catalan */ + APP_USBD_LANG_CHINESE = APP_USB_LANG_DEF(0x04U), /**< Chinese */ + APP_USBD_LANG_CZECH = APP_USB_LANG_DEF(0x05U), /**< Czech */ + APP_USBD_LANG_DANISH = APP_USB_LANG_DEF(0x06U), /**< Danish */ + APP_USBD_LANG_GERMAN = APP_USB_LANG_DEF(0x07U), /**< German */ + APP_USBD_LANG_GREEK = APP_USB_LANG_DEF(0x08U), /**< Greek */ + APP_USBD_LANG_ENGLISH = APP_USB_LANG_DEF(0x09U), /**< English */ + APP_USBD_LANG_SPANISH = APP_USB_LANG_DEF(0x0aU), /**< Spanish */ + APP_USBD_LANG_FINNISH = APP_USB_LANG_DEF(0x0bU), /**< Finnish */ + APP_USBD_LANG_FRENCH = APP_USB_LANG_DEF(0x0cU), /**< French */ + APP_USBD_LANG_HEBREW = APP_USB_LANG_DEF(0x0dU), /**< Hebrew */ + APP_USBD_LANG_HUNGARIAN = APP_USB_LANG_DEF(0x0eU), /**< Hungarian */ + APP_USBD_LANG_ICELANDIC = APP_USB_LANG_DEF(0x0fU), /**< Icelandic */ + APP_USBD_LANG_ITALIAN = APP_USB_LANG_DEF(0x10U), /**< Italian */ + APP_USBD_LANG_JAPANESE = APP_USB_LANG_DEF(0x11U), /**< Japanese */ + APP_USBD_LANG_KOREAN = APP_USB_LANG_DEF(0x12U), /**< Korean */ + APP_USBD_LANG_DUTCH = APP_USB_LANG_DEF(0x13U), /**< Dutch */ + APP_USBD_LANG_NORWEGIAN = APP_USB_LANG_DEF(0x14U), /**< Norwegian */ + APP_USBD_LANG_POLISH = APP_USB_LANG_DEF(0x15U), /**< Polish */ + APP_USBD_LANG_PORTUGUESE = APP_USB_LANG_DEF(0x16U), /**< Portuguese */ + APP_USBD_LANG_ROMANIAN = APP_USB_LANG_DEF(0x18U), /**< Romanian */ + APP_USBD_LANG_RUSSIAN = APP_USB_LANG_DEF(0x19U), /**< Russian */ + APP_USBD_LANG_CROATIAN = APP_USB_LANG_DEF(0x1aU), /**< Croatian */ + APP_USBD_LANG_SERBIAN = APP_USB_LANG_DEF(0x1aU), /**< Serbian */ + APP_USBD_LANG_SLOVAK = APP_USB_LANG_DEF(0x1bU), /**< Slovak */ + APP_USBD_LANG_ALBANIAN = APP_USB_LANG_DEF(0x1cU), /**< Albanian */ + APP_USBD_LANG_SWEDISH = APP_USB_LANG_DEF(0x1dU), /**< Swedish */ + APP_USBD_LANG_THAI = APP_USB_LANG_DEF(0x1eU), /**< Thai */ + APP_USBD_LANG_TURKISH = APP_USB_LANG_DEF(0x1fU), /**< Turkish */ + APP_USBD_LANG_URDU = APP_USB_LANG_DEF(0x20U), /**< Urdu */ + APP_USBD_LANG_INDONESIAN = APP_USB_LANG_DEF(0x21U), /**< Indonesian */ + APP_USBD_LANG_UKRANIAN = APP_USB_LANG_DEF(0x22U), /**< Ukrainian */ + APP_USBD_LANG_BELARUSIAN = APP_USB_LANG_DEF(0x23U), /**< Belarusian */ + APP_USBD_LANG_SLOVENIAN = APP_USB_LANG_DEF(0x24U), /**< Slovenian */ + APP_USBD_LANG_ESTONIAN = APP_USB_LANG_DEF(0x25U), /**< Estonian */ + APP_USBD_LANG_LATVIAN = APP_USB_LANG_DEF(0x26U), /**< Latvian */ + APP_USBD_LANG_LITHUANIAN = APP_USB_LANG_DEF(0x27U), /**< Lithuanian */ + APP_USBD_LANG_FARSI = APP_USB_LANG_DEF(0x29U), /**< Farsi */ + APP_USBD_LANG_VIETNAMESE = APP_USB_LANG_DEF(0x2aU), /**< Vietnamese */ + APP_USBD_LANG_ARMENIAN = APP_USB_LANG_DEF(0x2bU), /**< Armenian */ + APP_USBD_LANG_AZERI = APP_USB_LANG_DEF(0x2cU), /**< Azeri */ + APP_USBD_LANG_BASQUE = APP_USB_LANG_DEF(0x2dU), /**< Basque */ + APP_USBD_LANG_MACEDONIAN = APP_USB_LANG_DEF(0x2fU), /**< Macedonian */ + APP_USBD_LANG_AFRIKAANS = APP_USB_LANG_DEF(0x36U), /**< Afrikaans */ + APP_USBD_LANG_GEORGIAN = APP_USB_LANG_DEF(0x37U), /**< Georgian */ + APP_USBD_LANG_FAEROESE = APP_USB_LANG_DEF(0x38U), /**< Faeroese */ + APP_USBD_LANG_HINDI = APP_USB_LANG_DEF(0x39U), /**< Hindi */ + APP_USBD_LANG_MALAY = APP_USB_LANG_DEF(0x3eU), /**< Malay */ + APP_USBD_LANG_KAZAK = APP_USB_LANG_DEF(0x3fU), /**< Kazak */ + APP_USBD_LANG_SWAHILI = APP_USB_LANG_DEF(0x41U), /**< Swahili */ + APP_USBD_LANG_UZBEK = APP_USB_LANG_DEF(0x43U), /**< Uzbek */ + APP_USBD_LANG_TATAR = APP_USB_LANG_DEF(0x44U), /**< Tatar */ + APP_USBD_LANG_BENGALI = APP_USB_LANG_DEF(0x45U), /**< Bengali */ + APP_USBD_LANG_PUNJABI = APP_USB_LANG_DEF(0x46U), /**< Punjabi */ + APP_USBD_LANG_GUJARATI = APP_USB_LANG_DEF(0x47U), /**< Gujarati */ + APP_USBD_LANG_ORIYA = APP_USB_LANG_DEF(0x48U), /**< Oriya */ + APP_USBD_LANG_TAMIL = APP_USB_LANG_DEF(0x49U), /**< Tamil */ + APP_USBD_LANG_TELUGU = APP_USB_LANG_DEF(0x4aU), /**< Telugu */ + APP_USBD_LANG_KANNADA = APP_USB_LANG_DEF(0x4bU), /**< Kannada */ + APP_USBD_LANG_MALAYALAM = APP_USB_LANG_DEF(0x4cU), /**< Malayalam */ + APP_USBD_LANG_ASSAMESE = APP_USB_LANG_DEF(0x4dU), /**< Assamese */ + APP_USBD_LANG_MARATHI = APP_USB_LANG_DEF(0x4eU), /**< Marathi */ + APP_USBD_LANG_SANSKRIT = APP_USB_LANG_DEF(0x4fU), /**< Sanskrit */ + APP_USBD_LANG_KONKANI = APP_USB_LANG_DEF(0x57U), /**< Konkani */ + APP_USBD_LANG_MANIPURI = APP_USB_LANG_DEF(0x58U), /**< Manipuri */ + APP_USBD_LANG_SINDHI = APP_USB_LANG_DEF(0x59U), /**< Sindhi */ + APP_USBD_LANG_KASHMIRI = APP_USB_LANG_DEF(0x60U), /**< Kashmiri */ + APP_USBD_LANG_NEPALI = APP_USB_LANG_DEF(0x61U), /**< Nepali */ + APP_USBD_LANG_HID = APP_USB_LANG_DEF(0xffU), /**< Reserved for USB HID Class use. */ +} app_usbd_langid_primary_t; + +/** + * @brief Sublanguage identifiers. + * + * Mnemonics with sublanguage values. + * Use them in combination with @ref app_usbd_langid_primary_t. + */ +typedef enum +{ + APP_USBD_SUBLANG_ARABIC_SAUDI_ARABIA = APP_USB_SUBLANG_DEF(0x01U), /**< Arabic (Saudi Arabia) */ + APP_USBD_SUBLANG_ARABIC_IRAQ = APP_USB_SUBLANG_DEF(0x02U), /**< Arabic (Iraq) */ + APP_USBD_SUBLANG_ARABIC_EGYPT = APP_USB_SUBLANG_DEF(0x03U), /**< Arabic (Egypt) */ + APP_USBD_SUBLANG_ARABIC_LIBYA = APP_USB_SUBLANG_DEF(0x04U), /**< Arabic (Libya) */ + APP_USBD_SUBLANG_ARABIC_ALGERIA = APP_USB_SUBLANG_DEF(0x05U), /**< Arabic (Algeria) */ + APP_USBD_SUBLANG_ARABIC_MOROCCO = APP_USB_SUBLANG_DEF(0x06U), /**< Arabic (Morocco) */ + APP_USBD_SUBLANG_ARABIC_TUNISIA = APP_USB_SUBLANG_DEF(0x07U), /**< Arabic (Tunisia) */ + APP_USBD_SUBLANG_ARABIC_OMAN = APP_USB_SUBLANG_DEF(0x08U), /**< Arabic (Oman) */ + APP_USBD_SUBLANG_ARABIC_YEMEN = APP_USB_SUBLANG_DEF(0x09U), /**< Arabic (Yemen) */ + APP_USBD_SUBLANG_ARABIC_SYRIA = APP_USB_SUBLANG_DEF(0x10U), /**< Arabic (Syria) */ + APP_USBD_SUBLANG_ARABIC_JORDAN = APP_USB_SUBLANG_DEF(0x11U), /**< Arabic (Jordan) */ + APP_USBD_SUBLANG_ARABIC_LEBANON = APP_USB_SUBLANG_DEF(0x12U), /**< Arabic (Lebanon) */ + APP_USBD_SUBLANG_ARABIC_KUWAIT = APP_USB_SUBLANG_DEF(0x13U), /**< Arabic (Kuwait) */ + APP_USBD_SUBLANG_ARABIC_UAE = APP_USB_SUBLANG_DEF(0x14U), /**< Arabic (U.A.E.) */ + APP_USBD_SUBLANG_ARABIC_BAHRAIN = APP_USB_SUBLANG_DEF(0x15U), /**< Arabic (Bahrain) */ + APP_USBD_SUBLANG_ARABIC_QATAR = APP_USB_SUBLANG_DEF(0x16U), /**< Arabic (Qatar) */ + APP_USBD_SUBLANG_AZERI_CYRILLIC = APP_USB_SUBLANG_DEF(0x01U), /**< Azeri (Cyrillic) */ + APP_USBD_SUBLANG_AZERI_LATIN = APP_USB_SUBLANG_DEF(0x02U), /**< Azeri (Latin) */ + APP_USBD_SUBLANG_CHINESE_TRADITIONAL = APP_USB_SUBLANG_DEF(0x01U), /**< Chinese (Traditional) */ + APP_USBD_SUBLANG_CHINESE_SIMPLIFIED = APP_USB_SUBLANG_DEF(0x02U), /**< Chinese (Simplified) */ + APP_USBD_SUBLANG_CHINESE_HONGKONG = APP_USB_SUBLANG_DEF(0x03U), /**< Chinese (Hong Kong SAR, PRC) */ + APP_USBD_SUBLANG_CHINESE_SINGAPORE = APP_USB_SUBLANG_DEF(0x04U), /**< Chinese (Singapore) */ + APP_USBD_SUBLANG_CHINESE_MACAU = APP_USB_SUBLANG_DEF(0x05U), /**< Chinese (Macau SAR) */ + APP_USBD_SUBLANG_DUTCH = APP_USB_SUBLANG_DEF(0x01U), /**< Dutch */ + APP_USBD_SUBLANG_DUTCH_BELGIAN = APP_USB_SUBLANG_DEF(0x02U), /**< Dutch (Belgian) */ + APP_USBD_SUBLANG_ENGLISH_US = APP_USB_SUBLANG_DEF(0x01U), /**< English (US) */ + APP_USBD_SUBLANG_ENGLISH_UK = APP_USB_SUBLANG_DEF(0x02U), /**< English (UK) */ + APP_USBD_SUBLANG_ENGLISH_AUS = APP_USB_SUBLANG_DEF(0x03U), /**< English (Australian) */ + APP_USBD_SUBLANG_ENGLISH_CAN = APP_USB_SUBLANG_DEF(0x04U), /**< English (Canadian) */ + APP_USBD_SUBLANG_ENGLISH_NZ = APP_USB_SUBLANG_DEF(0x05U), /**< English (New Zealand) */ + APP_USBD_SUBLANG_ENGLISH_EIRE = APP_USB_SUBLANG_DEF(0x06U), /**< English (Ireland) */ + APP_USBD_SUBLANG_ENGLISH_SOUTH_AFRICA = APP_USB_SUBLANG_DEF(0x07U), /**< English (South Africa) */ + APP_USBD_SUBLANG_ENGLISH_JAMAICA = APP_USB_SUBLANG_DEF(0x08U), /**< English (Jamaica) */ + APP_USBD_SUBLANG_ENGLISH_CARIBBEAN = APP_USB_SUBLANG_DEF(0x09U), /**< English (Caribbean) */ + APP_USBD_SUBLANG_ENGLISH_BELIZE = APP_USB_SUBLANG_DEF(0x0aU), /**< English (Belize) */ + APP_USBD_SUBLANG_ENGLISH_TRINIDAD = APP_USB_SUBLANG_DEF(0x0bU), /**< English (Trinidad) */ + APP_USBD_SUBLANG_ENGLISH_PHILIPPINES = APP_USB_SUBLANG_DEF(0x0cU), /**< English (Zimbabwe) */ + APP_USBD_SUBLANG_ENGLISH_ZIMBABWE = APP_USB_SUBLANG_DEF(0x0dU), /**< English (Philippines) */ + APP_USBD_SUBLANG_FRENCH = APP_USB_SUBLANG_DEF(0x01U), /**< French */ + APP_USBD_SUBLANG_FRENCH_BELGIAN = APP_USB_SUBLANG_DEF(0x02U), /**< French (Belgian) */ + APP_USBD_SUBLANG_FRENCH_CANADIAN = APP_USB_SUBLANG_DEF(0x03U), /**< French (Canadian) */ + APP_USBD_SUBLANG_FRENCH_SWISS = APP_USB_SUBLANG_DEF(0x04U), /**< French (Switzerland) */ + APP_USBD_SUBLANG_FRENCH_LUXEMBOURG = APP_USB_SUBLANG_DEF(0x05U), /**< French (Luxembourg) */ + APP_USBD_SUBLANG_FRENCH_MONACO = APP_USB_SUBLANG_DEF(0x06U), /**< French (Monaco) */ + APP_USBD_SUBLANG_GERMAN = APP_USB_SUBLANG_DEF(0x01U), /**< German */ + APP_USBD_SUBLANG_GERMAN_SWISS = APP_USB_SUBLANG_DEF(0x02U), /**< German (Switzerland) */ + APP_USBD_SUBLANG_GERMAN_AUSTRIAN = APP_USB_SUBLANG_DEF(0x03U), /**< German (Austria) */ + APP_USBD_SUBLANG_GERMAN_LUXEMBOURG = APP_USB_SUBLANG_DEF(0x04U), /**< German (Luxembourg) */ + APP_USBD_SUBLANG_GERMAN_LIECHTENSTEIN = APP_USB_SUBLANG_DEF(0x05U), /**< German (Liechtenstein) */ + APP_USBD_SUBLANG_ITALIAN = APP_USB_SUBLANG_DEF(0x01U), /**< Italian */ + APP_USBD_SUBLANG_ITALIAN_SWISS = APP_USB_SUBLANG_DEF(0x02U), /**< Italian (Switzerland) */ + APP_USBD_SUBLANG_KASHMIRI_INDIA = APP_USB_SUBLANG_DEF(0x02U), /**< Kashmiri (India) */ + APP_USBD_SUBLANG_KOREAN = APP_USB_SUBLANG_DEF(0x01U), /**< Korean */ + APP_USBD_SUBLANG_LITHUANIAN = APP_USB_SUBLANG_DEF(0x01U), /**< Lithuanian */ + APP_USBD_SUBLANG_MALAY_MALAYSIA = APP_USB_SUBLANG_DEF(0x01U), /**< Malay (Malaysia) */ + APP_USBD_SUBLANG_MALAY_BRUNEI_DARUSSALAM = APP_USB_SUBLANG_DEF(0x02U), /**< Malay (Brunei Darassalam) */ + APP_USBD_SUBLANG_NEPALI_INDIA = APP_USB_SUBLANG_DEF(0x02U), /**< Nepali (India) */ + APP_USBD_SUBLANG_NORWEGIAN_BOKMAL = APP_USB_SUBLANG_DEF(0x01U), /**< Norwegian (Bokmal) */ + APP_USBD_SUBLANG_NORWEGIAN_NYNORSK = APP_USB_SUBLANG_DEF(0x02U), /**< Norwegian (Nynorsk) */ + APP_USBD_SUBLANG_PORTUGUESE = APP_USB_SUBLANG_DEF(0x01U), /**< Portuguese */ + APP_USBD_SUBLANG_PORTUGUESE_BRAZILIAN = APP_USB_SUBLANG_DEF(0x02U), /**< Portuguese (Brazil) */ + APP_USBD_SUBLANG_SERBIAN_LATIN = APP_USB_SUBLANG_DEF(0x02U), /**< Serbian (Latin) */ + APP_USBD_SUBLANG_SERBIAN_CYRILLIC = APP_USB_SUBLANG_DEF(0x03U), /**< Serbian (Cyrillic) */ + APP_USBD_SUBLANG_SPANISH = APP_USB_SUBLANG_DEF(0x01U), /**< Spanish (Traditional) */ + APP_USBD_SUBLANG_SPANISH_MEXICAN = APP_USB_SUBLANG_DEF(0x02U), /**< Spanish (Mexican) */ + APP_USBD_SUBLANG_SPANISH_MODERN = APP_USB_SUBLANG_DEF(0x03U), /**< Spanish (Modern) */ + APP_USBD_SUBLANG_SPANISH_GUATEMALA = APP_USB_SUBLANG_DEF(0x04U), /**< Spanish (Guatemala) */ + APP_USBD_SUBLANG_SPANISH_COSTA_RICA = APP_USB_SUBLANG_DEF(0x05U), /**< Spanish (Costa Rica) */ + APP_USBD_SUBLANG_SPANISH_PANAMA = APP_USB_SUBLANG_DEF(0x06U), /**< Spanish (Panama) */ + APP_USBD_SUBLANG_SPANISH_DOMINICAN_REPUBLIC = APP_USB_SUBLANG_DEF(0x07U), /**< Spanish (Dominican Republic) */ + APP_USBD_SUBLANG_SPANISH_VENEZUELA = APP_USB_SUBLANG_DEF(0x08U), /**< Spanish (Venezuela) */ + APP_USBD_SUBLANG_SPANISH_COLOMBIA = APP_USB_SUBLANG_DEF(0x09U), /**< Spanish (Colombia) */ + APP_USBD_SUBLANG_SPANISH_PERU = APP_USB_SUBLANG_DEF(0x0aU), /**< Spanish (Peru) */ + APP_USBD_SUBLANG_SPANISH_ARGENTINA = APP_USB_SUBLANG_DEF(0x0bU), /**< Spanish (Argentina) */ + APP_USBD_SUBLANG_SPANISH_ECUADOR = APP_USB_SUBLANG_DEF(0x0cU), /**< Spanish (Ecuador) */ + APP_USBD_SUBLANG_SPANISH_CHILE = APP_USB_SUBLANG_DEF(0x0dU), /**< Spanish (Chile) */ + APP_USBD_SUBLANG_SPANISH_URUGUAY = APP_USB_SUBLANG_DEF(0x0eU), /**< Spanish (Uruguay) */ + APP_USBD_SUBLANG_SPANISH_PARAGUAY = APP_USB_SUBLANG_DEF(0x0fU), /**< Spanish (Paraguay) */ + APP_USBD_SUBLANG_SPANISH_BOLIVIA = APP_USB_SUBLANG_DEF(0x10U), /**< Spanish (Bolivia) */ + APP_USBD_SUBLANG_SPANISH_EL_SALVADOR = APP_USB_SUBLANG_DEF(0x11U), /**< Spanish (El Salvador) */ + APP_USBD_SUBLANG_SPANISH_HONDURAS = APP_USB_SUBLANG_DEF(0x12U), /**< Spanish (Honduras) */ + APP_USBD_SUBLANG_SPANISH_NICARAGUA = APP_USB_SUBLANG_DEF(0x13U), /**< Spanish (Nicaragua) */ + APP_USBD_SUBLANG_SPANISH_PUERTO_RICO = APP_USB_SUBLANG_DEF(0x14U), /**< Spanish (Puerto Rico) */ + APP_USBD_SUBLANG_SWEDISH = APP_USB_SUBLANG_DEF(0x01U), /**< Swedish */ + APP_USBD_SUBLANG_SWEDISH_FINLAND = APP_USB_SUBLANG_DEF(0x02U), /**< Swedish (Finland) */ + APP_USBD_SUBLANG_URDU_PAKISTAN = APP_USB_SUBLANG_DEF(0x01U), /**< Urdu (Pakistan) */ + APP_USBD_SUBLANG_URDU_INDIA = APP_USB_SUBLANG_DEF(0x02U), /**< Urdu (India) */ + APP_USBD_SUBLANG_UZBEK_LATIN = APP_USB_SUBLANG_DEF(0x01U), /**< Uzbek (Latin) */ + APP_USBD_SUBLANG_UZBEK_CYRILLIC = APP_USB_SUBLANG_DEF(0x02U), /**< Uzbek (Cyrillic) */ + APP_USBD_SUBLANG_HID_USAGE_DATA_DESCRIPTOR = APP_USB_SUBLANG_DEF(0x01U), /**< HID (Usage Data Descriptor) */ + APP_USBD_SUBLANG_HID_VENDOR_DEFINED_1 = APP_USB_SUBLANG_DEF(0x3cU), /**< HID (Vendor Defined 1) */ + APP_USBD_SUBLANG_HID_VENDOR_DEFINED_2 = APP_USB_SUBLANG_DEF(0x3dU), /**< HID (Vendor Defined 2) */ + APP_USBD_SUBLANG_HID_VENDOR_DEFINED_3 = APP_USB_SUBLANG_DEF(0x3eU), /**< HID (Vendor Defined 3) */ + APP_USBD_SUBLANG_HID_VENDOR_DEFINED_4 = APP_USB_SUBLANG_DEF(0x3fU), /**< HID (Vendor Defined 4) */ +} app_usbd_langid_sub_t; + +/** + * @brief LANGID variable. + * + * The LANGID value is composed of: + * - 10 bits (9-0) of Primary Language Identifier, + * - 6 bits (15-10) of Sublanguage Identifier. + * + * @sa app_usbd_langid_primary_t + * @sa app_usbd_langid_sub_t + */ +typedef uint16_t app_usbd_langid_t; + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_LANGID_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_request.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_request.h similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_request.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_request.h index 15569cf..8ef5494 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_request.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_request.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_REQUEST_H__ @@ -52,7 +52,7 @@ extern "C" { #endif /* Compiler support for anonymous unions */ -ANON_UNIONS_ENABLE +ANON_UNIONS_ENABLE; #pragma pack(push, 1) @@ -65,21 +65,21 @@ ANON_UNIONS_ENABLE */ /** - * @brief Recipient bit-field in request type + * @brief Recipient bit-field in request type. * * Bits 4...0 */ #define APP_USBD_SETUP_REQ_BF_REC BF_CX(5, 0) /** - * @brief Type bit-field in request type + * @brief Type bit-field in request type. * * Bits 6...5 */ #define APP_USBD_SETUP_REQ_BF_TYP BF_CX(2, 5) /** - * @brief Direction bit-field in request type + * @brief Direction bit-field in request type. * * Bit 7 */ @@ -109,7 +109,7 @@ typedef enum { } app_usbd_setup_reqtype_t; /** - * @brief Direction of setup command + * @brief Direction of setup command. * * @note It is part of @ref app_usbd_setup_reqtype_t variable type. */ @@ -120,9 +120,9 @@ typedef enum { /** - * @brief Standard requests + * @brief Standard requests. * - * Enumerator for standard requests values + * Enumerator for standard requests values. */ typedef enum { APP_USBD_SETUP_STDREQ_GET_STATUS = 0x00, /**< @@ -226,21 +226,22 @@ typedef enum { } app_usbd_setup_stdrequest_t; /** - * @brief Standard feature selectors + * @brief Standard feature selectors. * * Standard features that may be disabled or enabled by * @ref APP_USBD_SETUP_STDREQ_CLEAR_FEATURE or @ref APP_USBD_SETUP_STDREQ_SET_FEATURE */ typedef enum { - APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP = 1, /**< Remote wakeup feature. - * + APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP = 1, /**< + * Remote wakeup feature. * Target: Device only */ - APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT = 0, /**< Stall or clear the endpoint. - * + APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT = 0, /**< + * Stall or clear the endpoint. * Target: Endpoint different than default (0) */ - APP_USBD_SETUP_STDFEATURE_TEST_MODE = 2 /**< Upstream port test mode. + APP_USBD_SETUP_STDFEATURE_TEST_MODE = 2 /**< + * Upstream port test mode. * Power has to be cycled to exit test mode. * This feature cannot be cleared. * @@ -254,7 +255,7 @@ typedef enum { /** - * @brief Universal way to access 16 bit values and its parts + * @brief Universal way to access 16 bit values and its parts. */ typedef union { uint16_t w; //!< 16 bit access @@ -266,7 +267,7 @@ typedef union { } app_usbd_setup_w_t; /** - * @brief Internal redefinition of setup structure + * @brief Internal redefinition of setup structure. * * Redefinition of the structure to simplify changes in the future * if required - app_usbd API would present setup data using app_usbd_setup_t. @@ -275,7 +276,7 @@ typedef union { */ typedef struct { uint8_t bmRequestType; //!< Setup type bitfield - uint8_t bmRequest; //!< One of @ref app_usbd_setup_stdrequest_t values or class dependent one. + uint8_t bRequest; //!< One of @ref app_usbd_setup_stdrequest_t values or class dependent one. app_usbd_setup_w_t wValue; //!< byte 2, 3 app_usbd_setup_w_t wIndex; //!< byte 4, 5 app_usbd_setup_w_t wLength; //!< byte 6, 7 @@ -285,11 +286,11 @@ typedef struct { /** - * @brief Extract recipient from request type + * @brief Extract recipient from request type. * * @param[in] bmRequestType * - * @return Extracted recipient field from request type value + * @return Extracted recipient field from request type value. */ static inline app_usbd_setup_reqrec_t app_usbd_setup_req_rec(uint8_t bmRequestType) { @@ -297,11 +298,11 @@ static inline app_usbd_setup_reqrec_t app_usbd_setup_req_rec(uint8_t bmRequestTy } /** - * @brief Extract type from request type + * @brief Extract type from request type. * * @param[in] bmRequestType * - * @return Extracted type field from request type value + * @return Extracted type field from request type value. */ static inline app_usbd_setup_reqtype_t app_usbd_setup_req_typ(uint8_t bmRequestType) { @@ -310,11 +311,11 @@ static inline app_usbd_setup_reqtype_t app_usbd_setup_req_typ(uint8_t bmRequestT /** - * @brief Extract direction from request type + * @brief Extract direction from request type. * * @param[in] bmRequestType * - * @return Extracted direction field from request type value + * @return Extracted direction field from request type value. */ static inline app_usbd_setup_reqdir_t app_usbd_setup_req_dir(uint8_t bmRequestType) { @@ -322,13 +323,13 @@ static inline app_usbd_setup_reqdir_t app_usbd_setup_req_dir(uint8_t bmRequestTy } /** - * @brief Make request type value + * @brief Make request type value. * - * @param[in] rec Recipient - * @param[in] typ Request type - * @param[in] dir Direction + * @param[in] rec Recipient. + * @param[in] typ Request type. + * @param[in] dir Direction. * - * @return Assembled request type value + * @return Assembled request type value. */ static inline uint8_t app_usbd_setup_req_val(app_usbd_setup_reqrec_t rec, app_usbd_setup_reqtype_t typ, @@ -345,7 +346,7 @@ static inline uint8_t app_usbd_setup_req_val(app_usbd_setup_reqrec_t rec, } -ANON_UNIONS_DISABLE +ANON_UNIONS_DISABLE; /** @} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.c new file mode 100644 index 0000000..1f0b46a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.c @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2018 - 2019, 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 "app_usbd_serial_num.h" + +#include +#include +#include +#include +#include "app_usbd.h" + +#define SERIAL_NUMBER_STRING_SIZE (12) + +/**@brief Serial number generated. + * + * Serial number generated by the @ref serial_number_string_create function. + */ +uint8_t g_extern_serial_number[SERIAL_NUMBER_STRING_SIZE + 1]; + + +/**@brief Function for creating the serial number string from a regular C string. + * + * @param[in] p_serial_number_string The serial number string. Must be terminated with \0. + */ +static void string_create(char * p_serial_number_string) +{ + + for (uint32_t i = 0; i < strlen(p_serial_number_string); i++) + { + g_extern_serial_number[i] = (uint8_t)p_serial_number_string[i]; + } +} + + +void app_usbd_serial_num_generate(void) +{ + char serial_number_string[SERIAL_NUMBER_STRING_SIZE + 1]; + const uint16_t serial_num_high_bytes = (uint16_t)NRF_FICR->DEVICEADDR[1] | 0xC000; // The masking makes the address match the Random Static BLE address. + const uint32_t serial_num_low_bytes = NRF_FICR->DEVICEADDR[0]; + + (void)snprintf(serial_number_string, + SERIAL_NUMBER_STRING_SIZE + 1, + "%04"PRIX16"%08"PRIX32, + serial_num_high_bytes, + serial_num_low_bytes); + + string_create(serial_number_string); +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_shared.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.h similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_shared.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.h index 94daa3c..59124bb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_shared.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_serial_num.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2018 - 2019, 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 @@ -35,43 +35,41 @@ * 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 MICRO_ECC_LIB_SHARED_H__ -#define MICRO_ECC_LIB_SHARED_H__ - -/** @file * - * @defgroup nrf_crypto_backend_micro_ecc_lib_shared micro-ecc backend shared functions. - * @{ - * @ingroup nrf_crypto_backend_microecc - * - * @brief Provides shared functions required for micro_ecc backend. */ +#ifndef APP_USBD_SERIAL_NUM_H__ +#define APP_USBD_SERIAL_NUM_H__ + #include -#include -#include "nrf_crypto_types.h" -#include "uECC.h" +#include #ifdef __cplusplus extern "C" { #endif -/** @brief Function to get micro_ecc curve domain from curve_type +/** + * @defgroup app_usbd_serial_num USBD serial number generator + * @ingroup app_usbd * - * @param[in] curve_type Curve type get domain for. - * @param[in] pp_domain Double pointer to curve domain structure. + * @brief @tagAPI52840 Generate a standard USB serial number that is unique for each device. + * @{ + */ + +/**@brief Function for generating a default serial number string based on FIRC->DEVICEADDR. * - * @retval True True if curve domain was successfully located. + * After calling this function, the serial number is ready for the USB driver. + * + * The generated serial number shows up as a 12-hexidecimal-digit string with no delimiters + * (e.g 123456ABCDEF). The byte string is also printed on the PCA10059 dongle. It is also used as + * the default advertising address in the SoftDevice. */ -bool micro_ecc_curve_domain_get(nrf_ecc_curve_type_t curve_type, struct uECC_Curve_t const ** pp_domain); +void app_usbd_serial_num_generate(void); +/** @} */ #ifdef __cplusplus } #endif -/**@} */ - -#endif // MICRO_ECC_LIB_SHARED_H__ +#endif // APP_USBD_SERIAL_NUM_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.c new file mode 100644 index 0000000..c808e81 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.c @@ -0,0 +1,295 @@ +/** + * Copyright (c) 2016 - 2019, 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_config.h" +#if APP_USBD_ENABLED +#include "app_usbd_string_desc.h" +#include "app_usbd_langid.h" +#include "app_usbd_core.h" +#include "nordic_common.h" +#include "utf.h" + +/** + * @defgroup app_usbd_string_desc + * @ingroup app_usbd + * + * USBD string descriptor management + * @{ + */ + +/** + * @brief Array with language identifiers. + * + * This array is used to search the proper string for the selected language. + */ +static uint16_t const m_langids[] = { APP_USBD_STRINGS_LANGIDS }; + +/** + * @brief Language ID descriptor. + * + * Language. + */ + + +/** + * @brief Mnemonics for the string positions in the array. + * + * The mnemonics for the indexes of the strings inside the string array. + */ +enum { + APP_USBD_STRING_ID_LANGIDS_ARRAY_POS = 0, /**< Supported language identifiers. */ + +#if (APP_USBD_STRING_ID_MANUFACTURER != 0) + APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS, /**< Manufacturer name. */ +#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0) + +#if (APP_USBD_STRING_ID_PRODUCT != 0) + APP_USBD_STRING_ID_PRODUCT_ARRAY_POS, /**< Product name. */ +#endif // (APP_USBD_STRING_ID_PRODUCT != 0) + +#if (APP_USBD_STRING_ID_SERIAL != 0) + APP_USBD_STRING_ID_SERIAL_ARRAY_POS, /**< Serial number. */ +#endif // (APP_USBD_STRING_ID_SERIAL != 0) + +#if (APP_USBD_STRING_ID_CONFIGURATION != 0) + APP_USBD_STRING_ID_CONFIGURATION_ARRAY_POS, /**< Configuration string. */ +#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0) + +#define X(mnemonic, str_idx, ...) CONCAT_2(mnemonic, _ARRAY_POS), + APP_USBD_STRINGS_USER +#undef X +}; + +/** + * @brief String index into internal array index conversion table. + * + * The array that transforms the USB string indexes into internal array position. + * @note Value 0 is used to mark non-existing string. + */ +static uint8_t const m_string_translation[APP_USBD_STRING_ID_CNT] = +{ + [APP_USBD_STRING_ID_LANGIDS] = APP_USBD_STRING_ID_LANGIDS_ARRAY_POS, + +#if (APP_USBD_STRING_ID_MANUFACTURER != 0) + [APP_USBD_STRING_ID_MANUFACTURER] = APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS, +#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0) + +#if (APP_USBD_STRING_ID_PRODUCT != 0) + [APP_USBD_STRING_ID_PRODUCT] = APP_USBD_STRING_ID_PRODUCT_ARRAY_POS, +#endif // (APP_USBD_STRING_ID_PRODUCT != 0) + +#if (APP_USBD_STRING_ID_SERIAL != 0) + [APP_USBD_STRING_ID_SERIAL] = APP_USBD_STRING_ID_SERIAL_ARRAY_POS, +#endif // (APP_USBD_STRING_ID_SERIAL != 0) + +#if (APP_USBD_STRING_ID_CONFIGURATION != 0) + [APP_USBD_STRING_ID_CONFIGURATION] = APP_USBD_STRING_ID_CONFIGURATION_ARRAY_POS, +#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0) + +#define X(mnemonic, str_idx, ...) [mnemonic] = CONCAT_2(mnemonic, _ARRAY_POS), + APP_USBD_STRINGS_USER +#undef X +}; + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +#if APP_USBD_STRINGS_MANUFACTURER_EXTERN +extern uint8_t APP_USBD_STRINGS_MANUFACTURER[]; +#endif + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +#if APP_USBD_STRINGS_PRODUCT_EXTERN +extern uint8_t APP_USBD_STRINGS_PRODUCT[]; +#endif + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +#if APP_USBD_STRING_SERIAL_EXTERN +extern uint8_t APP_USBD_STRING_SERIAL[]; +#endif + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +#if APP_USBD_STRING_CONFIGURATION_EXTERN +extern uint8_t APP_USBD_STRING_CONFIGURATION[]; +#endif + +/** + * @brief String descriptor table. + * */ +static uint8_t const * m_string_dsc[APP_USBD_STRING_ID_CNT][ARRAY_SIZE(m_langids)] = +{ + [APP_USBD_STRING_ID_LANGIDS_ARRAY_POS] = {APP_USBD_STRING_RAW16_DESC(APP_USBD_STRINGS_LANGIDS)}, + +#if (APP_USBD_STRING_ID_MANUFACTURER != 0) + [APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS] = { APP_USBD_STRINGS_MANUFACTURER }, +#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0) + +#if (APP_USBD_STRING_ID_PRODUCT != 0) + [APP_USBD_STRING_ID_PRODUCT_ARRAY_POS] = { APP_USBD_STRINGS_PRODUCT }, +#endif // (APP_USBD_STRING_ID_PRODUCT != 0) + +#if (APP_USBD_STRING_ID_SERIAL != 0) + [APP_USBD_STRING_ID_SERIAL_ARRAY_POS] = { APP_USBD_STRING_SERIAL }, +#endif // (APP_USBD_STRING_ID_SERIAL != 0) + +#if (APP_USBD_STRING_ID_CONFIGURATION != 0) + [APP_USBD_STRING_ID_CONFIGURATION_ARRAY_POS] = { APP_USBD_STRINGS_CONFIGURATION }, +#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0) + +#define X(mnemonic, str_idx, ...) [CONCAT_2(mnemonic, _ARRAY_POS)] = {__VA_ARGS__}, + APP_USBD_STRINGS_USER +#undef X +}; + +/** + * @brief Function for preparing UTF16 string descriptor. + * + * @param idx String descriptor ID. + * @param langid Language ID. + * + * @return Pointer to the string descriptor. + */ +static uint16_t * app_usbd_prepare_string(uint8_t idx, uint16_t langid) +{ + if (m_string_dsc[idx][langid][0] == 0x00) + { + return (uint16_t *) &(m_string_dsc[idx][langid][2]); + } + +#if ((APP_USBD_CONFIG_DESC_STRING_SIZE * 2) + 2) <= NRF_DRV_USBD_EPSIZE + uint16_t * string_buffer = app_usbd_core_setup_transfer_buff_get(NULL); +#else + static uint16_t string_buffer[APP_USBD_CONFIG_DESC_STRING_SIZE + 1]; + // + 1 element for string descriptor type and size +#endif + + uint8_t size = 0; + const uint8_t * p_pos = m_string_dsc[idx][langid]; + +#if APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED + size = utf8UTF16Count((char *) p_pos, 0); + ASSERT(size <= APP_USBD_CONFIG_DESC_STRING_SIZE); + + uint16_t * p_out = &(string_buffer[1]); + uint32_t rune; + + while (*p_pos != 0) + { + p_pos = (uint8_t *) utf8DecodeRune((char *) p_pos, 0, &rune); + p_out += utf16EncodeRune(rune, p_out); + } +#else + while(*p_pos != 0) + { + ASSERT(size < APP_USBD_CONFIG_DESC_STRING_SIZE); + ++size; + string_buffer[size] = *p_pos; + ++p_pos; + } +#endif + + // Descriptor size is length of the string times 2 bytes per character + 2 bytes for + // descriptor type and size. + string_buffer[0] = (0xff & (size * 2 + 2)) | ((uint16_t)APP_USBD_DESCRIPTOR_STRING) << 8; + + return string_buffer; +} + +uint16_t const * app_usbd_string_desc_get(uint8_t idx, uint16_t langid) +{ + /* LANGID string. */ + if (APP_USBD_STRING_ID_LANGIDS == idx) + { + return app_usbd_prepare_string(APP_USBD_STRING_ID_LANGIDS_ARRAY_POS, 0); + } + + /* Searching for the language. */ + uint8_t lang_idx = 0; + if (ARRAY_SIZE(m_langids) > 1) + { + while (m_langids[lang_idx] != langid) + { + ++lang_idx; + if (lang_idx >= ARRAY_SIZE(m_langids)) + { + return NULL; + } + } + } + + /* Get the string index in array. */ + if (idx >= ARRAY_SIZE(m_string_translation)) + { + return NULL; + } + + uint8_t str_pos = m_string_translation[idx]; + if (str_pos == 0) + { + return NULL; + } + + if ((ARRAY_SIZE(m_langids) > 1) && (lang_idx != 0)) + { + if (m_string_dsc[str_pos][lang_idx] == NULL) + { + lang_idx = 0; + } + } + + if (m_string_dsc[str_pos][lang_idx] == NULL) + { + return NULL; + } + + return app_usbd_prepare_string(str_pos, lang_idx); +} + +/** @} */ +#endif // APP_USBD_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.h new file mode 100644 index 0000000..21d75e8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_string_desc.h @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2016 - 2019, 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 APP_USBD_STRING_DESC_H__ +#define APP_USBD_STRING_DESC_H__ + +#include +#include "sdk_common.h" +#include "app_usbd.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_string_desc USBD string descriptors + * @ingroup app_usbd + * + * @brief @tagAPI52840 USBD string descriptor management. + * @{ + */ + +/** + * @brief USB Language identifier initialization. + * + * @param[in] lang Language identifier. + */ +#define APP_USBD_LANG(lang) \ + ((app_usbd_langid_t) lang) + +/** + * @brief USB Language identifier with sublanguage initialization. + * + * @param[in] lang Language identifier. + * @param[in] sublang Sublanguage identifier. + */ +#define APP_USBD_LANG_AND_SUBLANG(lang, sublang) \ + ((app_usbd_langid_t) lang | (app_usbd_langid_t) sublang) + +/** + * @brief USB string initialization. + * + * Macro that creates initialization values for the USB string. + * The string must be declared as a NULL-terminated string. + * + * @param[in] str NULL-terminated string. + * + * @return String descriptor initialization data. + */ +#define APP_USBD_STRING_DESC(str) (const uint8_t *)(const char[]){str} + +/** + * @brief USB raw 8-bit string initialization. + * + * Macro that creates header for raw values passed into descriptor. + * Values must be of the uint8_t type and separated by commas. + * + * @param[in] ... comma-separated values. + * + * @return String descriptor initialization data. + */ +#define APP_USBD_STRING_RAW8_DESC(...) (const uint8_t[]){ \ + 0x00, 0x00, /* NULL character at start to differentiate from normal string */ \ + (0xff & (sizeof((uint8_t[]){__VA_ARGS__}) + 2)), \ + (APP_USBD_DESCRIPTOR_STRING), \ + __VA_ARGS__ } + +/** + * @brief USB raw 16-bit string initialization. + * + * Macro that creates header for raw values passed into descriptor. + * Values must be of the uint16_t type and separated by commas. + * + * @param[in] ... comma-separated values. + * + * @return String descriptor initialization data. + */ +#define APP_USBD_STRING_RAW16_DESC(...) (const uint8_t *) ((const uint16_t[]){ \ + 0x00, /* NULL character at start to differentiate from normal string */ \ + (0xff & (sizeof((uint16_t[]){__VA_ARGS__}) + 2)) | \ + ((uint16_t)APP_USBD_DESCRIPTOR_STRING) << 8, \ + __VA_ARGS__ }) + +/** + * @brief USB string descriptors IDs + */ +typedef enum { + APP_USBD_STRING_ID_LANGIDS = 0, /**< Supported language identifiers */ + + /// Placeholders used only for alignement of user strings. Do not use or modify them. + +#if (APP_USBD_STRING_ID_MANUFACTURER != 0) + APP_USBD_STRING_ID_MANUFACTURER_PLACEHOLDER = APP_USBD_STRING_ID_MANUFACTURER, +#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0) + +#if (APP_USBD_STRING_ID_PRODUCT != 0) + APP_USBD_STRING_ID_PRODUCT_PLACEHOLDER = APP_USBD_STRING_ID_PRODUCT, +#endif // (APP_USBD_STRING_ID_PRODUCT != 0) + +#if (APP_USBD_STRING_ID_SERIAL != 0) + APP_USBD_STRING_ID_SERIAL_PLACEHOLDER = APP_USBD_STRING_ID_SERIAL, +#endif // (APP_USBD_STRING_ID_SERIAL != 0) + +#if (APP_USBD_STRING_ID_CONFIGURATION != 0) + APP_USBD_STRING_ID_CONFIGURATION_PLACEHOLDER = APP_USBD_STRING_ID_CONFIGURATION, +#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0) + +#define X(mnemonic, str_idx, ...) mnemonic str_idx, + APP_USBD_STRINGS_USER +#undef X + + APP_USBD_STRING_ID_CNT /**< Total number of identifiers. */ +} app_usbd_string_desc_idx_t; + +/** + * @brief Get string descriptor. + * + * @param[in] idx String descriptor index. + * @param[in] langid Selected language for the string. + * @return String descriptor, or NULL if it does not exist. + * */ +uint16_t const * app_usbd_string_desc_get(uint8_t idx, uint16_t langid); + +/** + * @brief Get string length. + * + * Function for getting string length from descriptor (descriptor returned by @ref app_usbd_string_desc_get). + * + * @param[in] p_str String descriptor pointer. + * @return Total descriptor length in bytes. + */ +static inline size_t app_usbd_string_desc_length(uint16_t const * p_str) +{ + return ((const app_usbd_descriptor_string_t *)p_str)->bLength; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_STRING_DESC_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_types.h similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_types.h index a50a616..0d4a0c2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/app_usbd_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/app_usbd_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_TYPES_H__ @@ -61,7 +61,7 @@ extern "C" { */ /** - * @brief Change given value to 2 digits in BCD notation + * @brief Change given value to 2 digits in BCD notation. * * @param[in] val The decimal value to be converted in the range from 0 to 99. * @return Calculated BCD value. @@ -72,24 +72,41 @@ extern "C" { ) /** - * @brief Change given decimal version values to 4 digits in BCD notation + * @brief Change given decimal version values to 4 digits in BCD notation. * * USB specification uses 4 digits BCD version notation in many descriptors. - * This macro changes 2 values to 4 BCD digits (one 16 bit value) + * This macro changes 3 values to 4 BCD digits (one 16 bit value) * that describes version in USB standard. * - * @param[in] major Major version - * @param[in] minor Minor version + * @param[in] major Major version. + * @param[in] minor Minor version. + * @param[in] sub Sub-minor version. + * + * @return Calculated 16 bit value with BCD representation of the version. + */ +#define APP_USBD_BCD_VER_MAKE(major, minor, sub) \ + ((APP_USBD_BCD_2_MAKE(major) << 8) | (minor) << 4 | (sub)) + +/** + * @brief Combine endpoint address and its interval. * - * @return Calculated 16 bit value with BCD representation of the version + * @param[in] address Endpoint address + * @param[in] interval Endpoint interval + * @return Combined address and interval. */ -#define APP_USBD_BCD_VER_MAKE(major, minor) \ - ((APP_USBD_BCD_2_MAKE(major) << 8) | APP_USBD_BCD_2_MAKE(minor)) +#define APP_USBD_EP_WITH_INTERVAL(address, interval) \ + ((1UL << 16) | ((interval) << 8) | (address)) + +#define APP_USBD_EXTRACT_INTERVAL_VALUE(combined) \ + (((combined) & 0xFF00) >> 8) + +#define APP_USBD_EXTRACT_INTERVAL_FLAG(combined) \ + (((combined) >> 16) & 0x01) /** - * @brief Events codes + * @brief Events codes. * - * Redefined application event codes + * Redefined application event codes. */ typedef enum { @@ -101,17 +118,27 @@ typedef enum APP_USBD_EVT_DRV_SETUP = NRF_DRV_USBD_EVT_SETUP, /**< This event type has special structure. See @ref app_usbd_setup_evt_t */ APP_USBD_EVT_DRV_EPTRANSFER = NRF_DRV_USBD_EVT_EPTRANSFER, /**< See documentation for @ref NRF_DRV_USBD_EVT_EPTRANSFER */ + APP_USBD_EVT_FIRST_POWER, /**< First power event code - for internal static assert checking */ + + APP_USBD_EVT_POWER_DETECTED, /**< See documentation for @ref NRF_DRV_POWER_USB_EVT_DETECTED */ + APP_USBD_EVT_POWER_REMOVED, /**< See documentation for @ref NRF_DRV_POWER_USB_EVT_REMOVED */ + APP_USBD_EVT_POWER_READY, /**< See documentation for @ref NRF_DRV_POWER_USB_EVT_READY */ + APP_USBD_EVT_FIRST_APP, /**< First application event code - for internal static assert checking */ APP_USBD_EVT_INST_APPEND = APP_USBD_EVT_FIRST_APP, /**< The instance was attached to the library, any configuration action can be done now */ - APP_USBD_EVT_INST_REMOVE, /**< The instance is going to be removed, this event is called just before removing the instance. - * This removing cannot be stopped. */ + APP_USBD_EVT_INST_REMOVE, /**< + * The instance is going to be removed, this event is called just before removing the instance. + * This removing cannot be stopped. + */ APP_USBD_EVT_STARTED, /**< USBD library has just been started and functional - event passed to all instances, before USBD interrupts have been enabled */ APP_USBD_EVT_STOPPED, /**< USBD library has just been stopped and is not functional - event passed to all instances, after USBD interrupts have been disabled*/ - APP_USBD_EVT_STATE_CHANGED, /**< Informs all the classes that base state has been changed. - * This event is processed before setup stage that caused the state change finishes (before acknowledging it). */ + APP_USBD_EVT_STATE_CHANGED, /**< + * Informs all the classes that base state has been changed. + * This event is processed before setup stage that caused the state change finishes (before acknowledging it). + */ APP_USBD_EVT_FIRST_INTERNAL = 0x80, /**< First internal event, used by the APP library internally. */ @@ -120,13 +147,21 @@ typedef enum APP_USBD_EVT_STOP_REQ, /**< Stop requested */ APP_USBD_EVT_SUSPEND_REQ, /**< Suspend request - HFCLK would be released and USBD peripheral clock would be disconnected */ APP_USBD_EVT_WAKEUP_REQ, /**< Wakeup request - start the whole wakeup generation. */ + APP_USBD_EVT_SETUP_SETADDRESS, /**< + * Setup request to set address, separated from + * regular EVT_SETUP because this request is + * fully handled by hardware and for the software + * it is only a notification about what happened + */ } app_usbd_event_type_t; + + /** - * @brief Specific application event structure + * @brief Specific application event structure. * - * All the data required by the events that comes from the application level + * All the data required by the events that comes from the application level. */ typedef struct { @@ -134,10 +169,10 @@ typedef struct } app_usbd_evt_t; /** - * @brief Specific application event structure with setup structure included + * @brief Specific application event structure with setup structure included. * * This event structure would be used when @ref APP_USBD_EVT_DRV_SETUP - * is passed to instance event handler + * is passed to instance event handler. */ typedef struct { @@ -147,7 +182,7 @@ typedef struct /** - * @brief Complex event variable type + * @brief Complex event variable type. * * A variable that can store any kind of event. */ @@ -168,8 +203,9 @@ typedef union */ } app_usbd_complex_evt_t; + /** - * @brief Internal event variable type + * @brief Internal event variable type. * * The variable type used for internal event processing. * This kind of event is the one that goes into the event queue. @@ -191,9 +227,10 @@ typedef union */ } app_usbd_internal_evt_t; + #ifdef DOXYGEN /** - * @brief Base instance of a USBD class + * @brief Base instance of a USBD class. * * Any USBD class instance have to begin with this instance. * This may then be followed by any implementation dependent data. @@ -211,11 +248,11 @@ typedef struct {} app_usbd_class_inst_t; typedef struct app_usbd_class_inst_s app_usbd_class_inst_t; #endif /** - * @brief Endpoint callback function + * @brief Endpoint callback function. * * The function used by every class instance. - * @param[in,out] p_inst Instance of the class - * @param[in] p_event Event to process + * @param[in,out] p_inst Instance of the class. + * @param[in] p_event Event to process. * * @note If given event is not supported by class, return @ref NRF_ERROR_NOT_SUPPORTED */ @@ -224,6 +261,14 @@ typedef ret_code_t (*app_usbd_ep_event_handler_t)( app_usbd_complex_evt_t const * const p_event ); +/** + * @brief SOF interrupt callback function. + * + * @param[in] framecnt Number of current SOF frame. + * + * @sa app_usbd_class_sof_register + */ +typedef void (*app_usbd_sof_interrupt_handler_t)(uint16_t framecnt); /** @} */ @@ -232,4 +277,3 @@ typedef ret_code_t (*app_usbd_ep_event_handler_t)( #endif #endif /* APP_USBD_TYPES_H__ */ - diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.c new file mode 100644 index 0000000..afd6c4f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.c @@ -0,0 +1,861 @@ +/** + * Copyright (c) 2016 - 2019, 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(APP_USBD_AUDIO) + +#include "app_usbd_audio.h" +#include "app_util_platform.h" + +/** + * @defgroup app_usbd_audio_internals USBD Audio internals + * @{ + * @ingroup app_usbd_audio + * @internal + */ + +STATIC_ASSERT(sizeof(app_usbd_audio_ac_iface_header_desc_t) == 8); +STATIC_ASSERT(sizeof(app_usbd_audio_input_terminal_desc_t) == 12); +STATIC_ASSERT(sizeof(app_usbd_audio_output_terminal_desc_t) == 9); +STATIC_ASSERT(sizeof(app_usbd_audio_feature_unit_desc_t) == 6); +STATIC_ASSERT(sizeof(app_usbd_audio_as_iface_desc_t) == 7); +STATIC_ASSERT(sizeof(app_usbd_audio_as_format_type_one_desc_t) == 8); +STATIC_ASSERT(sizeof(app_usbd_audio_as_format_type_two_desc_t) == 9); +STATIC_ASSERT(sizeof(app_usbd_audio_as_format_type_three_desc_t) == 8); +STATIC_ASSERT(sizeof(app_usbd_audio_as_endpoint_desc_t) == 7); + +#define APP_USBD_AUDIO_CONTROL_IFACE_IDX 0 /**< Audio class control interface index */ +#define APP_USBD_AUDIO_STREAMING_IFACE_IDX 1 /**< Audio class streaming interface index */ + +#define APP_USBD_CDC_AUDIO_STREAMING_EP_IDX 0 /**< Audio streaming isochronous endpoint index */ + +/** + * @brief Auxiliary function to access audio class instance data. + * + * @param[in] p_inst Class instance data. + * @return Audio class instance data @ref app_usbd_audio_t + */ +static inline app_usbd_audio_t const * audio_get(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + return (app_usbd_audio_t const *)p_inst; +} + + +/** + * @brief Auxiliary function to access audio class context data. + * + * @param[in] p_audio Audio class instance data. + * @return Audio class context data @ref app_usbd_audio_ctx_t + */ +static inline app_usbd_audio_ctx_t * audio_ctx_get(app_usbd_audio_t const * p_audio) +{ + ASSERT(p_audio != NULL); + ASSERT(p_audio->specific.p_data != NULL); + return &p_audio->specific.p_data->ctx; +} + + +/** + * @brief User event handler. + * + * @param[in] p_inst Class instance. + * @param[in] event user Event type @ref app_usbd_audio_user_event_t + */ +static inline void user_event_handler( + app_usbd_class_inst_t const * p_inst, + app_usbd_audio_user_event_t event) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + if (p_audio->specific.inst.user_ev_handler != NULL) + { + p_audio->specific.inst.user_ev_handler(p_inst, event); + } +} + + +/** + * @brief Select interface. + * + * @param[in,out] p_inst Instance of the class. + * @param[in] iface_idx Index of the interface inside class structure. + * @param[in] alternate Alternate setting that should be selected. + */ +static ret_code_t iface_select( + app_usbd_class_inst_t const * const p_inst, + uint8_t iface_idx, + uint8_t alternate) +{ + app_usbd_class_iface_conf_t const * p_iface = app_usbd_class_iface_get(p_inst, iface_idx); + /* Simple check if this is data interface */ + uint8_t const ep_count = app_usbd_class_iface_ep_count_get(p_iface); + + if (ep_count > 0) + { + if (alternate > 1) + { + return NRF_ERROR_INVALID_PARAM; + } + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + p_audio_ctx->streaming = (alternate != 0); + + uint8_t i; + + for (i = 0; i < ep_count; ++i) + { + nrf_drv_usbd_ep_t ep_addr = + app_usbd_class_ep_address_get(app_usbd_class_iface_ep_get(p_iface, i)); + if (alternate) + { + app_usbd_ep_enable(ep_addr); + } + else + { + app_usbd_ep_disable(ep_addr); + } + } + return NRF_SUCCESS; + } + return NRF_ERROR_NOT_SUPPORTED; +} + + +static void iface_deselect( + app_usbd_class_inst_t const * const p_inst, + uint8_t iface_idx) +{ + app_usbd_class_iface_conf_t const * p_iface = app_usbd_class_iface_get(p_inst, iface_idx); + + /* Simple check if this is data interface */ + if (p_iface->ep_cnt > 0) + { + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + p_audio_ctx->streaming = false; + } + /* Note that all the interface endpoints would be disabled automatically after this function */ +} + + +static uint8_t iface_selection_get( + app_usbd_class_inst_t const * const p_inst, + uint8_t iface_idx) +{ + app_usbd_class_iface_conf_t const * p_iface = app_usbd_class_iface_get(p_inst, iface_idx); + /* Simple check if this is data interface */ + uint8_t const ep_count = app_usbd_class_iface_ep_count_get(p_iface); + + if (ep_count > 0) + { + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + return (p_audio_ctx->streaming) ? 1 : 0; + } + return 0; +} + + +/** + * @brief Internal SETUP standard IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + /* Only Get Descriptor standard IN request is supported by Audio class */ + if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) + && + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + { + size_t dsc_len = 0; + size_t max_size; + + uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); + + /* Try to find descriptor in class internals*/ + ret_code_t ret = app_usbd_class_descriptor_find( + p_inst, + p_setup_ev->setup.wValue.hb, + p_setup_ev->setup.wValue.lb, + p_trans_buff, + &dsc_len); + + if (ret != NRF_ERROR_NOT_FOUND) + { + ASSERT(dsc_len < NRF_DRV_USBD_EPSIZE); + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_trans_buff, dsc_len); + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Internal SETUP class IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_req_class_in( + app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_AUDIO_REQ_GET_CUR: + case APP_USBD_AUDIO_REQ_GET_MIN: + case APP_USBD_AUDIO_REQ_GET_MAX: + case APP_USBD_AUDIO_REQ_SET_RES: + case APP_USBD_AUDIO_REQ_GET_MEM: + { + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + + + p_audio_ctx->request.req_type = (app_usbd_audio_req_type_t)p_setup_ev->setup.bRequest; + p_audio_ctx->request.control = p_setup_ev->setup.wValue.hb; + p_audio_ctx->request.channel = p_setup_ev->setup.wValue.lb; + p_audio_ctx->request.interface = p_setup_ev->setup.wIndex.hb; + p_audio_ctx->request.entity = p_setup_ev->setup.wIndex.lb; + + p_audio_ctx->request.length = p_setup_ev->setup.wLength.w; + + p_audio_ctx->request.req_target = APP_USBD_AUDIO_CLASS_REQ_IN; + + app_usbd_setup_reqrec_t rec = app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType); + if (rec == APP_USBD_SETUP_REQREC_ENDPOINT) + { + p_audio_ctx->request.req_target = APP_USBD_AUDIO_EP_REQ_IN; + } + + user_event_handler((app_usbd_class_inst_t const *)p_audio, + APP_USBD_AUDIO_USER_EVT_CLASS_REQ); + + return app_usbd_core_setup_rsp(&p_setup_ev->setup, + p_audio_ctx->request.payload, + p_audio_ctx->request.length); + } + + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +static ret_code_t audio_req_out_data_cb(nrf_drv_usbd_ep_status_t status, void * p_context) +{ + if (status == NRF_USBD_EP_OK) + { + app_usbd_audio_t const * p_audio = p_context; + + user_event_handler((app_usbd_class_inst_t const *)p_audio, + APP_USBD_AUDIO_USER_EVT_CLASS_REQ); + } + + return NRF_SUCCESS; +} + + +static ret_code_t audio_req_out( + app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + + + p_audio_ctx->request.req_type = (app_usbd_audio_req_type_t)p_setup_ev->setup.bRequest; + p_audio_ctx->request.control = p_setup_ev->setup.wValue.hb; + p_audio_ctx->request.channel = p_setup_ev->setup.wValue.lb; + p_audio_ctx->request.interface = p_setup_ev->setup.wIndex.hb; + p_audio_ctx->request.entity = p_setup_ev->setup.wIndex.lb; + + p_audio_ctx->request.length = p_setup_ev->setup.wLength.w; + + p_audio_ctx->request.req_target = APP_USBD_AUDIO_CLASS_REQ_OUT; + if (app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_ENDPOINT) + { + p_audio_ctx->request.req_target = APP_USBD_AUDIO_EP_REQ_OUT; + } + + /*Request setup data*/ + NRF_DRV_USBD_TRANSFER_OUT(transfer, p_audio_ctx->request.payload, p_audio_ctx->request.length); + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_core_setup_data_handler_desc_t desc = { + .handler = audio_req_out_data_cb, + .p_context = (void *)p_audio + }; + + ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + + +/** + * @brief Internal SETUP class OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_req_class_out( + app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_AUDIO_REQ_SET_CUR: + case APP_USBD_AUDIO_REQ_SET_MIN: + case APP_USBD_AUDIO_REQ_SET_MAX: + case APP_USBD_AUDIO_REQ_SET_RES: + case APP_USBD_AUDIO_REQ_SET_MEM: + return audio_req_out(p_inst, p_setup_ev); + + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Control endpoint handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_event_handler( + app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + ASSERT(p_inst != NULL); + ASSERT(p_setup_ev != NULL); + + if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_in(p_inst, p_setup_ev); + + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_in(p_inst, p_setup_ev); + + default: + break; + } + } + else /*APP_USBD_SETUP_REQDIR_OUT*/ + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_out(p_inst, p_setup_ev); + + default: + break; + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Endpoint IN event handler. + * + * @param[in] p_inst Generic class instance. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t endpoint_in_event_handler(app_usbd_class_inst_t const * p_inst) +{ + user_event_handler(p_inst, APP_USBD_AUDIO_USER_EVT_TX_DONE); + return NRF_SUCCESS; +} + + +/** + * @brief Endpoint OUT event handler. + * + * @param[in] p_inst Generic class instance. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t endpoint_out_event_handler(app_usbd_class_inst_t const * p_inst) +{ + user_event_handler(p_inst, APP_USBD_AUDIO_USER_EVT_RX_DONE); + return NRF_SUCCESS; +} + + +/** + * @brief Auxiliary function to access isochronous endpoint address. + * + * @param[in] p_inst Class instance data. + * + * @return ISO endpoint address. + */ +static inline nrf_drv_usbd_ep_t ep_iso_addr_get(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * class_iface; + + class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_AUDIO_STREAMING_IFACE_IDX); + + app_usbd_class_ep_conf_t const * ep_cfg; + ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_AUDIO_STREAMING_EP_IDX); + + return app_usbd_class_ep_address_get(ep_cfg); +} + + +/** + * @brief @ref app_usbd_class_methods_t::event_handler + */ +static ret_code_t audio_event_handler( + app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ASSERT(p_inst != NULL); + ASSERT(p_event != NULL); + + ret_code_t ret = NRF_SUCCESS; + + switch (p_event->app_evt.type) + { + case APP_USBD_EVT_DRV_RESET: + break; + + case APP_USBD_EVT_DRV_SETUP: + ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *)p_event); + break; + + case APP_USBD_EVT_DRV_EPTRANSFER: + if (NRF_USBD_EPIN_CHECK(p_event->drv_evt.data.eptransfer.ep)) + { + ret = endpoint_in_event_handler(p_inst); + } + else + { + ret = endpoint_out_event_handler(p_inst); + } + break; + + case APP_USBD_EVT_DRV_SUSPEND: + break; + + case APP_USBD_EVT_DRV_RESUME: + break; + + case APP_USBD_EVT_INST_APPEND: + { + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + if(p_audio_ctx->sof_handler != NULL) + { + ret = app_usbd_class_sof_interrupt_register(p_inst, p_audio_ctx->sof_handler); + APP_ERROR_CHECK(ret); + } + break; + } + + case APP_USBD_EVT_INST_REMOVE: + { + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + if(p_audio_ctx->sof_handler != NULL) + { + ret = app_usbd_class_sof_interrupt_unregister(p_inst); + APP_ERROR_CHECK(ret); + } + break; + } + + case APP_USBD_EVT_STARTED: + break; + + case APP_USBD_EVT_STOPPED: + break; + + default: + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + return ret; +} + + +static size_t audio_get_format_descriptor_size(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + if (p_audio->specific.inst.p_format_dsc == NULL) + { + return 0; + } + + return p_audio->specific.inst.p_format_dsc->size; +} + + +static size_t audio_get_format_descriptor_data(app_usbd_class_inst_t const * p_inst, + uint32_t cur_byte) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + return p_audio->specific.inst.p_format_dsc->p_data[cur_byte]; +} + + +static size_t audio_get_input_descriptor_size(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + if (p_audio->specific.inst.p_input_dsc == NULL) + { + return 0; + } + + return p_audio->specific.inst.p_input_dsc->size; +} + + +static size_t audio_get_input_descriptor_data(app_usbd_class_inst_t const * p_inst, + uint32_t cur_byte) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + return p_audio->specific.inst.p_input_dsc->p_data[cur_byte]; +} + + +static size_t audio_get_output_descriptor_size(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + if (p_audio->specific.inst.p_output_dsc == NULL) + { + return 0; + } + + return p_audio->specific.inst.p_output_dsc->size; +} + + +static size_t audio_get_output_descriptor_data(app_usbd_class_inst_t const * p_inst, + uint32_t cur_byte) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + return p_audio->specific.inst.p_output_dsc->p_data[cur_byte]; +} + + +static size_t audio_get_feature_descriptor_size(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + if (p_audio->specific.inst.p_feature_dsc == NULL) + { + return 0; + } + + return p_audio->specific.inst.p_feature_dsc->size; +} + + +static size_t audio_get_feature_descriptor_data(app_usbd_class_inst_t const * p_inst, + uint32_t cur_byte) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + return p_audio->specific.inst.p_feature_dsc->p_data[cur_byte]; +} + + +static uint8_t audio_get_control_interface_number(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * ifce = 0; + + ifce = app_usbd_class_iface_get(p_inst, 0); + return app_usbd_class_iface_number_get(ifce); +} + + +/** + * @brief @ref app_usbd_class_methods_t::feed_descriptors + */ + +static bool audio_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static uint8_t ifaces = 0; + ifaces = app_usbd_class_iface_count_get(p_inst); + ASSERT(ifaces == 2); + app_usbd_audio_t const * p_audio = audio_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size); + + /* CONTROL INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, 0); + + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_CLASS); // bInterfaceClass = Audio + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_SUBCLASS_AUDIOCONTROL); // bInterfaceSubclass (Audio Control) + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_CLASS_PROTOCOL_UNDEFINED); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* HEADER INTERFACE */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_DESCRIPTOR_INTERFACE); // bDescriptorType = Audio Interfaces + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_AC_IFACE_SUBTYPE_HEADER); // bDescriptorSubtype = Header + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(0x0100)); // bcdADC LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(0x0100)); // bcdADC MSB + + static uint16_t header_desc_len = 0; + header_desc_len = 9 + audio_get_feature_descriptor_size(p_inst) + + audio_get_input_descriptor_size(p_inst) + audio_get_output_descriptor_size( + p_inst); + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(header_desc_len)); // wTotalLength LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(header_desc_len)); // wTotalLength MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x01); // bInCollection + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_control_interface_number(p_inst) + 1); // baInterfaceNr(1) + + /* INPUT TERMINAL DESCRIPTOR */ + static uint32_t cur_byte = 0; + static size_t input_desc_size = 0; + input_desc_size = audio_get_input_descriptor_size(p_inst); + + for (cur_byte = 0; cur_byte < input_desc_size; cur_byte++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_input_descriptor_data(p_inst, cur_byte)); + } + + /* FEATURE UNIT DESCRIPTOR */ + static size_t feature_desc_size = 0; + feature_desc_size = audio_get_feature_descriptor_size(p_inst); + + for (cur_byte = 0; cur_byte < feature_desc_size; cur_byte++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_feature_descriptor_data(p_inst, cur_byte)); + } + + /* OUTPUT TERMINAL DESCRIPTOR */ + static size_t output_desc_size = 0; + output_desc_size = audio_get_output_descriptor_size(p_inst); + + for (cur_byte = 0; cur_byte < output_desc_size; cur_byte++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_output_descriptor_data(p_inst, cur_byte)); + } + + p_cur_iface++; + + /* STREAM INTERFACE DESCRIPTOR ALT 0 */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_control_interface_number(p_inst) + 1); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_CLASS); // bInterfaceClass = Audio + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_audio->specific.inst.type_streaming); // bInterfaceSubclass (Audio Control) + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_CLASS_PROTOCOL_UNDEFINED); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* STREAM INTERFACE DESCRIPTOR ALT 1 */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_control_interface_number(p_inst) + 1); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x01); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_CLASS); // bInterfaceClass = Audio + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_audio->specific.inst.type_streaming); // bInterfaceSubclass (Audio Control) + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_CLASS_PROTOCOL_UNDEFINED); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* AudioStreaming GENERAL DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_DESCRIPTOR_INTERFACE); // bDescriptorType = Audio Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_AS_IFACE_SUBTYPE_GENERAL); // bDescriptorSubtype = General + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_audio->specific.inst.terminal_link); // bTerminalLink + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_audio->specific.inst.delay); // bDelay + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(p_audio->specific.inst.format)); // wFormatTag LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(p_audio->specific.inst.format)); // wFormatTag MSB + + /* FORMAT DESCRIPTOR */ + static size_t format_desc_size = 0; + format_desc_size = audio_get_format_descriptor_size(p_inst); + + for (cur_byte = 0; cur_byte < format_desc_size; cur_byte++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(audio_get_format_descriptor_data(p_inst, cur_byte)); + } + + /* ENDPOINT GENERAL DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_DESCRIPTOR_ENDPOINT); // bDescriptorType = Audio Descriptor + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_AUDIO_EP_SUBTYPE_GENERAL); // bDescriptorSubtype = EP General + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bmAttributes + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bLockDelayUnits + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(0x0000)); // wLockDelay LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(0x0000)); // wLockDelay MSB + + /* ENDPOINT ISO DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint + + static app_usbd_class_ep_conf_t const * p_cur_ep = NULL; + p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, 0); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_ISOCHRONOUS); // bmAttributes + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(p_audio->specific.inst.ep_size)); // wMaxPacketSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(p_audio->specific.inst.ep_size)); // wMaxPacketSize MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x01); // bInterval + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bRefresh + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bSynchAddress + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + +/** @} */ + +const app_usbd_class_methods_t app_usbd_audio_class_methods = { + .event_handler = audio_event_handler, + .feed_descriptors = audio_feed_descriptors, + .iface_select = iface_select, + .iface_deselect = iface_deselect, + .iface_selection_get = iface_selection_get, +}; + + +size_t app_usbd_audio_class_rx_size_get(app_usbd_class_inst_t const * p_inst) +{ + nrf_drv_usbd_ep_t ep_addr; + + ep_addr = ep_iso_addr_get(p_inst); + ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); + + return (size_t)nrf_drv_usbd_epout_size_get(ep_addr); +} + + +ret_code_t app_usbd_audio_class_rx_start( + app_usbd_class_inst_t const * p_inst, + void * p_buff, + size_t size) +{ + nrf_drv_usbd_ep_t ep_addr; + + ep_addr = ep_iso_addr_get(p_inst); + ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); + + NRF_DRV_USBD_TRANSFER_OUT(transfer, p_buff, size); + return app_usbd_ep_transfer(ep_addr, &transfer); +} + + +ret_code_t app_usbd_audio_class_tx_start( + app_usbd_class_inst_t const * p_inst, + const void * p_buff, + size_t size) +{ + nrf_drv_usbd_ep_t ep_addr; + + ep_addr = ep_iso_addr_get(p_inst); + ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); + + NRF_DRV_USBD_TRANSFER_IN(transfer, p_buff, size); + return app_usbd_ep_transfer(ep_addr, &transfer); +} + +ret_code_t app_usbd_audio_sof_interrupt_register(app_usbd_class_inst_t const * p_inst, + app_usbd_sof_interrupt_handler_t handler) +{ + app_usbd_audio_t const * p_audio = audio_get(p_inst); + app_usbd_audio_ctx_t * p_audio_ctx = audio_ctx_get(p_audio); + + p_audio_ctx->sof_handler = handler; + + return NRF_SUCCESS; +} + +#endif //NRF_MODULE_ENABLED(APP_USBD_AUDIO) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.h similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.h index 01578b0..8087476 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_AUDIO_H__ #define APP_USBD_AUDIO_H__ @@ -113,14 +113,21 @@ typedef enum app_usbd_audio_user_event_e { /*lint -restore*/ - /** - * @brief Global definition of app_usbd_audio_t class instance + * @brief Global definition of app_usbd_audio_t class instance. * - * @param instance_name Name of global instance - * @param interfaces_configs Interfaces configurations - * @param user_ev_handler User event handler (optional) - * @param raw_descriptors Raw descriptor table + * @param instance_name Name of global instance. + * @param interfaces_configs Interfaces configurations. + * @param user_ev_handler User event handler. + * @param format_descriptor Audio class Format descriptor. + * @param input_descriptor Audio class Input Terminal descriptor. + * @param output_descriptor Audio class Output Terminal descriptor. + * @param feature_descriptor Audio class Feature Unit descriptor. + * @param delay Streaming delay. + * @param format FormatTag (@ref app_usbd_audio_as_iface_format_tag_t). + * @param ep_size Endpoint size. + * @param type_str Streaming type MIDISTREAMING/AUDIOSTREAMING. + * @param terminal_link Terminal link in AS Interface Descriptor. * * @note This macro is just simplified version of @ref APP_USBD_AUDIO_GLOBAL_DEF_INTERNAL * @@ -128,17 +135,110 @@ typedef enum app_usbd_audio_user_event_e { #define APP_USBD_AUDIO_GLOBAL_DEF(instance_name, \ interfaces_configs, \ user_ev_handler, \ - raw_descriptors) \ + format_descriptor, \ + input_descriptor, \ + output_descriptor, \ + feature_descriptor, \ + delay, \ + format, \ + ep_size, \ + type_str, \ + terminal_link) \ APP_USBD_AUDIO_GLOBAL_DEF_INTERNAL(instance_name, \ interfaces_configs, \ user_ev_handler, \ - raw_descriptors) + format_descriptor, \ + input_descriptor, \ + output_descriptor, \ + feature_descriptor, \ + delay, \ + format, \ + ep_size, \ + type_str, \ + terminal_link) + + +/** + * @brief Initializer of Audio Format descriptor. + * + * @param name Format descriptor name. + * @param ... Format descriptor data. +*/ + +#define APP_USBD_AUDIO_FORMAT_DESCRIPTOR(name, ...) \ + static uint8_t const CONCAT_2(name, _data)[] = \ + { \ + __VA_ARGS__ \ + }; \ + static const app_usbd_audio_subclass_desc_t name = \ + { \ + sizeof(CONCAT_2(name, _data)), \ + APP_USBD_AUDIO_AS_IFACE_SUBTYPE_FORMAT_TYPE, \ + CONCAT_2(name,_data) \ + } /** - * @@brief Helper function to get class instance from Audio class + * @brief Initializer of Audio Input descriptor. * - * @param[in] p_audio Audio class instance (declared by @ref APP_USBD_AUDIO_GLOBAL_DEF) - * @return Base class instance + * @param name Input descriptor name. + * @param ... Input descriptor data. +*/ + +#define APP_USBD_AUDIO_INPUT_DESCRIPTOR(name, ...) \ + static uint8_t const CONCAT_2(name, _data)[] = \ + { \ + __VA_ARGS__ \ + }; \ + static const app_usbd_audio_subclass_desc_t name = \ + { \ + sizeof(CONCAT_2(name, _data)), \ + APP_USBD_AUDIO_AC_IFACE_SUBTYPE_INPUT_TERMINAL, \ + CONCAT_2(name,_data) \ + } + +/** + * @brief Initializer of Audio Output descriptor. + * + * @param name Output descriptor name. + * @param ... Output descriptor data. +*/ + +#define APP_USBD_AUDIO_OUTPUT_DESCRIPTOR(name, ...) \ + static uint8_t const CONCAT_2(name, _data)[] = \ + { \ + __VA_ARGS__ \ + }; \ + static const app_usbd_audio_subclass_desc_t name = \ + { \ + sizeof(CONCAT_2(name, _data)), \ + APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERMINAL, \ + CONCAT_2(name,_data) \ + } + +/** + * @brief Initializer of Feture Output descriptor. + * + * @param name Feture descriptor name. + * @param ... Feture descriptor data. +*/ + +#define APP_USBD_AUDIO_FEATURE_DESCRIPTOR(name, ...) \ + static uint8_t const CONCAT_2(name, _data)[] = \ + { \ + __VA_ARGS__ \ + }; \ + static const app_usbd_audio_subclass_desc_t name = \ + { \ + sizeof(CONCAT_2(name, _data)), \ + APP_USBD_AUDIO_AC_IFACE_SUBTYPE_FEATURE_UNIT, \ + CONCAT_2(name,_data) \ + } + +/** + * @@brief Helper function to get class instance from Audio class. + * + * @param[in] p_audio Audio class instance (declared by @ref APP_USBD_AUDIO_GLOBAL_DEF). + * @return Base class instance. */ static inline app_usbd_class_inst_t const * app_usbd_audio_class_inst_get(app_usbd_audio_t const * p_audio) @@ -147,10 +247,10 @@ app_usbd_audio_class_inst_get(app_usbd_audio_t const * p_audio) } /** - * @brief Helper function to get audio specific request from audio class + * @brief Helper function to get audio specific request from audio class. * - * @param[in] p_audio Audio class instance (declared by @ref APP_USBD_AUDIO_GLOBAL_DEF) - * @return Audio class specific request + * @param[in] p_audio Audio class instance (declared by @ref APP_USBD_AUDIO_GLOBAL_DEF). + * @return Audio class specific request. */ static inline app_usbd_audio_req_t * app_usbd_audio_class_request_get(app_usbd_audio_t const * p_audio) @@ -159,10 +259,10 @@ app_usbd_audio_class_request_get(app_usbd_audio_t const * p_audio) } /** - * @brief Helper function to get audio from base class instance + * @brief Helper function to get audio from base class instance. * - * @param[in] p_inst Base class instance - * @return Audio class handle + * @param[in] p_inst Base class instance. + * @return Audio class handle. */ static inline app_usbd_audio_t const * app_usbd_audio_class_get(app_usbd_class_inst_t const * p_inst) @@ -223,6 +323,20 @@ ret_code_t app_usbd_audio_class_tx_start( const void * p_buff, size_t size); +/** + * @brief Register audio instance as the one that requires SOF events in interrupt. + * + * This function should be called before appending the instance. + * + * @param p_inst Audio instance that requires SOF event. + * @param handler Handler to SOF event + * + * @retval NRF_SUCCESS Instance linked into SOF processing list. + * + * @sa app_usbd_class_sof_interrupt_register + */ +ret_code_t app_usbd_audio_sof_interrupt_register(app_usbd_class_inst_t const * p_inst, + app_usbd_sof_interrupt_handler_t handler); /** @} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_desc.h similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_desc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_desc.h index 99e4e0b..f2fd3ea 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_desc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_desc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_AUDIO_DESC_H__ #define APP_USBD_AUDIO_DESC_H__ @@ -54,11 +54,11 @@ extern "C" { */ /** - * @brief Initializer of interface descriptor for AUDIO class + * @brief Initializer of interface descriptor for AUDIO class. * - * @param interface_number Interface number - * @param alt_setting Interface alternate setting - * @param ep_num Number of endpoints + * @param interface_number Interface number. + * @param alt_setting Interface alternate setting. + * @param ep_num Number of endpoints. * @param subclass Audio subclass @ref app_usbd_audio_subclass_t * */ #define APP_USBD_AUDIO_INTERFACE_DSC(interface_number, alt_setting, ep_num, subclass) \ @@ -73,13 +73,13 @@ extern "C" { /*.iInterface = 0, */ 0x00, \ /** - * @brief Initializer of isochronous endpoint descriptors for audio class + * @brief Initializer of isochronous endpoint descriptors for audio class. * * @param ep ISO endpoint id: @ref NRF_DRV_USBD_EPIN8, @ref NRF_DRV_USBD_EPOUT8 - * @param ep_size Endpoint size (bytes) - * @param interval Endpoint interval (milliseconds) - * @param refresh Refresh value (usually 0) - * @param synch_addr Synch address (usually 0) + * @param ep_size Endpoint size (bytes). + * @param interval Endpoint interval (milliseconds). + * @param refresh Refresh value (usually 0). + * @param synch_addr Synch address (usually 0). * */ #define APP_USBD_AUDIO_ISO_EP_DSC(ep, ep_size, interval, refresh, synch_addr) \ /*.bLength = */ sizeof(app_usbd_descriptor_ep_t) + 2, \ @@ -106,8 +106,8 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_ac_iface_header_desc_t * - * @param descriptor_list Descriptor list following audio interface header descriptor - * @param ... List of interfaces following audio control interface + * @param descriptor_list Descriptor list following audio interface header descriptor. + * @param ... List of interfaces following audio control interface. * */ #define APP_USBD_AUDIO_AC_IFACE_HEADER_DSC(descriptor_list, ...) \ /*.bLength = */ sizeof(app_usbd_audio_ac_iface_header_desc_t) + \ @@ -126,10 +126,10 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_input_terminal_desc_t * - * @param terminal_id Terminal ID + * @param terminal_id Terminal ID. * @param terminal_type Terminal type @ref app_usbd_audio_terminal_type_t - * @param nr_channels Number of channels - * @param ch_config CHannel config bitmask + * @param nr_channels Number of channels. + * @param ch_config Channel config bitmask. * */ #define APP_USBD_AUDIO_INPUT_TERMINAL_DSC(terminal_id, terminal_type, nr_channels, ch_config) \ /*.bLength = */ sizeof(app_usbd_audio_input_terminal_desc_t), \ @@ -147,14 +147,14 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_output_terminal_desc_t * - * @param terminal_id Terminal ID + * @param terminal_id Terminal ID. * @param terminal_type Terminal type @ref app_usbd_audio_terminal_type_t - * @param source_id Source ID + * @param source_id Source ID. * */ #define APP_USBD_AUDIO_OUTPUT_TERMINAL_DSC(terminal_id, terminal_type, source_id) \ /*.bLength = */ sizeof(app_usbd_audio_output_terminal_desc_t), \ /*.bDescriptorType = */ APP_USBD_AUDIO_DESCRIPTOR_INTERFACE, \ - /*.bDescriptorSubtype = */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERNINAL, \ + /*.bDescriptorSubtype = */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERMINAL, \ /*.bTerminalID = */ (terminal_id), \ /*.wTerminalType = */ APP_USBD_U16_TO_RAW_DSC(terminal_type), \ /*.bAssocTerminal = */ 0, \ @@ -165,9 +165,9 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_feature_unit_desc_t * - * @param unit_id Unit ID - * @param source_id Source ID - * @param ... List of controls + * @param unit_id Unit ID. + * @param source_id Source ID. + * @param ... List of controls. * */ #define APP_USBD_AUDIO_FEATURE_UNIT_DSC(unit_id, source_id, ...) \ /*.bLength = */ sizeof(app_usbd_audio_feature_unit_desc_t) + \ @@ -184,9 +184,9 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_as_iface_desc_t * - * @param terminal_link Terminal link - * @param delay Delay - * @param format_tag Format TAG + * @param terminal_link Terminal link. + * @param delay Delay. + * @param format_tag Format TAG. * */ #define APP_USBD_AUDIO_AS_IFACE_DSC(terminal_link, delay, format_tag) \ /*.bLength = */ sizeof(app_usbd_audio_as_iface_desc_t), \ @@ -199,11 +199,11 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_as_format_type_one_desc_t * - * @param nr_channels Number of channels - * @param subframe_size Subframe size - * @param resolution Bit resolution - * @param freq_type Frequency type - * @param ... List of frequencies + * @param nr_channels Number of channels. + * @param subframe_size Subframe size. + * @param resolution Bit resolution. + * @param freq_type Frequency type. + * @param ... List of frequencies. * */ #define APP_USBD_AUDIO_AS_FORMAT_I_DSC(nr_channels, subframe_size, resolution, freq_type, ...) \ /*.bLength = */ sizeof(app_usbd_audio_as_format_type_one_desc_t) + \ @@ -212,7 +212,7 @@ extern "C" { /*.bDescriptorSubtype = */ APP_USBD_AUDIO_AS_IFACE_SUBTYPE_FORMAT_TYPE, \ /*.bFormatType = */ (1), \ /*.bNrChannels = */ (nr_channels), \ - /*.bSubframeSize = */ (subframe_size), \ + /*.bSubFrameSize = */ (subframe_size), \ /*.bBitResolution = */ (resolution), \ /*.bSamFreqType = */ (freq_type), \ /*.tSamFreq = */ __VA_ARGS__, \ @@ -220,10 +220,10 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_as_format_type_two_desc_t * - * @param max_bitrate Maximum bitrate - * @param samples_per_frame Samples per frame - * @param freq_type Frequency type - * @param ... List of frequencies + * @param max_bitrate Maximum bitrate. + * @param samples_per_frame Samples per frame. + * @param freq_type Frequency type. + * @param ... List of frequencies. * */ #define APP_USBD_AUDIO_AS_FORMAT_II_DSC(max_bitrate, samples_per_frame, freq_type, ...) \ /*.bLength = */ sizeof(app_usbd_audio_as_format_type_two_desc_t) + \ @@ -239,11 +239,11 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_as_format_type_three_desc_t * - * @param nr_channels Number of channels - * @param subframe_size Subframe size - * @param resolution Bit resolution - * @param freq_type Frequency type - * @param ... List of frequencies + * @param nr_channels Number of channels. + * @param subframe_size Subframe size. + * @param resolution Bit resolution. + * @param freq_type Frequency type. + * @param ... List of frequencies. * */ #define APP_USBD_AUDIO_AS_FORMAT_III_DSC(nr_channels, subframe_size, resolution, freq_type, ...) \ /*.bLength = */ sizeof(app_usbd_audio_as_format_type_three_desc_t) + \ @@ -252,7 +252,7 @@ extern "C" { /*.bDescriptorSubtype = */ APP_USBD_AUDIO_AS_IFACE_SUBTYPE_FORMAT_TYPE, \ /*.bFormatType = */ (3), \ /*.bNrChannels = */ (nr_channels), \ - /*.bSubframeSize = */ (subframe_size), \ + /*.bSubFrameSize = */ (subframe_size), \ /*.bBitResolution = */ (resolution), \ /*.bSamFreqType = */ (freq_type), \ /*.tSamFreq = */ __VA_ARGS__, \ @@ -261,9 +261,9 @@ extern "C" { /** * @brief Initializer of @ref app_usbd_audio_as_endpoint_desc_t * - * @param attributes Endpoint attributes - * @param lock_delay_units Lock delay units - * @param lock_delay Lock delay + * @param attributes Endpoint attributes. + * @param lock_delay_units Lock delay units. + * @param lock_delay Lock delay. * */ #define APP_USBD_AUDIO_EP_GENERAL_DSC(attributes, lock_delay_units, lock_delay) \ /*.bLength = */ sizeof(app_usbd_audio_as_endpoint_desc_t), \ @@ -274,10 +274,10 @@ extern "C" { /*.wLockDelay = */ APP_USBD_U16_TO_RAW_DSC(lock_delay), \ /** - * @brief Macro to configure Audio Class control descriptor + * @brief Macro to configure Audio Class control descriptor. * - * @param interface_number Interface number - * @param descriptor_list List of descriptors after Audio interface header descriptor + * @param interface_number Interface number. + * @param descriptor_list List of descriptors after Audio interface header descriptor. * @param interface_list List of interfaces passed to @ref APP_USBD_AUDIO_AC_IFACE_HEADER_DSC * */ #define APP_USBD_AUDIO_CONTROL_DSC(interface_number, descriptor_list, interface_list) \ @@ -287,22 +287,22 @@ extern "C" { /** - * @brief Macro to configure Audio Class streaming descriptor + * @brief Macro to configure Audio Class streaming descriptor. * - * @param interface_number Interface number - * @param alt_setting Alternate interface setting - * @param ep_num Number of endpoints + * @param interface_number Interface number. + * @param alt_setting Alternate interface setting. + * @param ep_num Number of endpoints. */ #define APP_USBD_AUDIO_STREAMING_DSC(interface_number, alt_setting, ep_num) \ APP_USBD_AUDIO_INTERFACE_DSC(interface_number, alt_setting, ep_num, \ APP_USBD_AUDIO_SUBCLASS_AUDIOSTREAMING) /** - * @brief Macro to configure Audio Class MIDI streaming descriptor + * @brief Macro to configure Audio Class MIDI streaming descriptor. * - * @param interface_number Interface number - * @param alt_setting Alternate interface setting - * @param ep_num Number of endpoints + * @param interface_number Interface number. + * @param alt_setting Alternate interface setting. + * @param ep_num Number of endpoints. */ #define APP_USBD_AUDIO_MIDI_STREAMING_DSC(interface_number, alt_setting, ep_num) \ APP_USBD_AUDIO_INTERFACE_DSC(interface_number, alt_setting, ep_num, \ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_internal.h new file mode 100644 index 0000000..db84ac8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_internal.h @@ -0,0 +1,291 @@ +/** + * Copyright (c) 2017 - 2019, 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 APP_USBD_AUDIO_INTERNAL_H__ +#define APP_USBD_AUDIO_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_audio_internal USB Audio internals + * @brief @tagAPI52840 USB Audio class internals. + * @ingroup app_usbd_audio + * @{ + */ + +/** + * @brief Forward declaration of type defined by @ref APP_USBD_CLASS_TYPEDEF in audio class. + * + */ +APP_USBD_CLASS_FORWARD(app_usbd_audio); + +/*lint -save -e165*/ +/** + * @brief Forward declaration of @ref app_usbd_audio_user_event_e + * + */ +enum app_usbd_audio_user_event_e; + +/*lint -restore*/ + +/** + * @brief User event handler. + * + * @param[in] p_inst Class instance. + * @param[in] event User event. + * + */ +typedef void (*app_usbd_audio_user_ev_handler_t)(app_usbd_class_inst_t const * p_inst, + enum app_usbd_audio_user_event_e event); + + +/** + * @brief Audio subclass descriptor. + */ + +typedef struct { + size_t size; + uint8_t type; + uint8_t const * const p_data; +} app_usbd_audio_subclass_desc_t; + +/** + * @brief Audio class part of class instance data. + */ +typedef struct { + + app_usbd_audio_subclass_desc_t const * const p_format_dsc; //!< Audio class Format descriptor + app_usbd_audio_subclass_desc_t const * const p_input_dsc; //!< Audio class Input Terminal descriptor + app_usbd_audio_subclass_desc_t const * const p_output_dsc; //!< Audio class Output Terminal descriptor + app_usbd_audio_subclass_desc_t const * const p_feature_dsc; //!< Audio class Feature Unit descriptor + + uint8_t delay; //!< Streaming delay + uint16_t format; //!< FormatTag (@ref app_usbd_audio_as_iface_format_tag_t) + uint16_t ep_size; //!< Endpoint size + uint8_t terminal_link; //!< Terminal link in AS Interface Descriptor + + app_usbd_audio_subclass_t type_streaming; //!< Streaming type MIDISTREAMING/AUDIOSTREAMING (@ref app_usbd_audio_subclass_t) + + app_usbd_audio_user_ev_handler_t user_ev_handler; //!< User event handler +} app_usbd_audio_inst_t; + +/** + * @brief Audio class request target. + */ +typedef enum { + APP_USBD_AUDIO_CLASS_REQ_IN, /**< Audio class request IN */ + APP_USBD_AUDIO_CLASS_REQ_OUT, /**< Audio class request OUT */ + APP_USBD_AUDIO_EP_REQ_IN, /**< Audio class endpoint request IN */ + APP_USBD_AUDIO_EP_REQ_OUT, /**< Audio class endpoint request OUT */ +} app_usbd_audio_class_req_target_t; + +/** + * @brief Audio class specific request handled via control endpoint. + */ +typedef struct { + app_usbd_audio_class_req_target_t req_target; //!< Request target + app_usbd_audio_req_type_t req_type; //!< Request type + + uint8_t control; //!< Request control field + uint8_t channel; //!< Channel ID + uint8_t interface; //!< Interface ID + uint8_t entity; //!< Entity ID + uint16_t length; //!< Request payload length + + uint8_t payload[64]; //!< Request payload +} app_usbd_audio_req_t; + + +/** + * @brief Audio class context. + * + */ +typedef struct { + app_usbd_audio_req_t request; //!< Audio class request + bool streaming; //!< Streaming flag + app_usbd_sof_interrupt_handler_t sof_handler; //!< SOF event handler +} app_usbd_audio_ctx_t; + + +/** + * @brief Audio class configuration macro. + * + * Used by @ref APP_USBD_AUDIO_GLOBAL_DEF + * + * @param iface_control Interface number of audio control. + * @param iface_stream Interface number of audio stream. + */ +#define APP_USBD_AUDIO_CONFIG(iface_control, iface_stream) \ + ((iface_control), \ + (iface_stream, 0)) + +/** + * @brief Only IN audio stream configuration. + * + * @param iface_control Interface number of audio control. + * @param iface_stream_in Interface number of audio stream on IN endpoint. + */ +#define APP_USBD_AUDIO_CONFIG_IN(iface_control, iface_stream_in) \ + ((iface_control), (iface_stream_in, NRF_DRV_USBD_EPIN8)) + + +/** + * @brief Only OUT audio stream configuration. + * + * @param iface_control Interface number of audio control. + * @param iface_stream_out Interface number of audio stream on OUT endpoint. + */ +#define APP_USBD_AUDIO_CONFIG_OUT(iface_control, iface_stream_out) \ + ((iface_control), (iface_stream_out, NRF_DRV_USBD_EPOUT8)) + +/** + * @brief Specific class constant data for audio class. + * + * @ref app_usbd_audio_inst_t + */ +#define APP_USBD_AUDIO_INSTANCE_SPECIFIC_DEC app_usbd_audio_inst_t inst; + +/** + * @brief Configures audio class instance. + * + * @param user_event_handler User event handler. + * @param format_descriptor Audio class Format descriptor. + * @param input_descriptor Audio class Input Terminal descriptor. + * @param output_descriptor Audio class Output Terminal descriptor. + * @param feature_descriptor Audio class Feature Unit descriptor. + * @param dlay Streaming delay. + * @param frmat FormatTag (@ref app_usbd_audio_as_iface_format_tag_t). + * @param ep_siz Endpoint size. + * @param type_str Streaming type MIDISTREAMING/AUDIOSTREAMING. + * @param terminal Terminal link in AS Interface Descriptor. + */ + #define APP_USBD_AUDIO_INST_CONFIG(user_event_handler, \ + format_descriptor, \ + input_descriptor, \ + output_descriptor, \ + feature_descriptor, \ + dlay, \ + frmat, \ + ep_siz, \ + type_str, \ + terminal) \ + .inst = { \ + .user_ev_handler = user_event_handler, \ + .p_format_dsc = format_descriptor, \ + .p_input_dsc = input_descriptor, \ + .p_output_dsc = output_descriptor, \ + .p_feature_dsc = feature_descriptor, \ + .delay = dlay, \ + .format = frmat, \ + .ep_size = ep_siz, \ + .type_streaming = type_str, \ + .terminal_link = terminal \ + } + +/** + * @brief Specific class data for audio class. + * + * @ref app_usbd_audio_ctx_t + */ +#define APP_USBD_AUDIO_DATA_SPECIFIC_DEC app_usbd_audio_ctx_t ctx; + + +/** + * @brief Audio class descriptors config macro. + * + * @param interface_number Interface number. + * @param ... Extracted endpoint list. + */ +#define APP_USBD_AUDIO_DSC_CONFIG(interface_number, ...) { \ + APP_USBD_AUDIO_INTERFACE_DSC(interface_number, \ + 0, \ + 0, \ + APP_USBD_AUDIO_SUBCLASS_AUDIOCONTROL) \ + } + +/** + * @brief Public audio class interface. + * + */ +extern const app_usbd_class_methods_t app_usbd_audio_class_methods; + +/** + * @brief Global definition of @ref app_usbd_audio_t class + * + */ + #define APP_USBD_AUDIO_GLOBAL_DEF_INTERNAL(instance_name, \ + interfaces_configs, \ + user_ev_handler, \ + format_descriptor, \ + input_descriptor, \ + output_descriptor, \ + feature_descriptor, \ + delay, \ + format, \ + ep_size, \ + type_str, \ + terminal_link) \ + APP_USBD_CLASS_INST_GLOBAL_DEF( \ + instance_name, \ + app_usbd_audio, \ + &app_usbd_audio_class_methods, \ + interfaces_configs, \ + (APP_USBD_AUDIO_INST_CONFIG(user_ev_handler, \ + format_descriptor, \ + input_descriptor, \ + output_descriptor, \ + feature_descriptor, \ + delay, \ + format, \ + ep_size, \ + type_str, \ + terminal_link)) \ + ) + + +/** @} */ + + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_AUDIO_INTERNAL_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_types.h similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_types.h index 54bd7cf..07e75ed 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/audio/app_usbd_audio_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/audio/app_usbd_audio_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_AUDIO_TYPES_H__ #define APP_USBD_AUDIO_TYPES_H__ @@ -53,20 +53,20 @@ extern "C" { * @{ */ -/** @brief Audio class definition in interface descriptor +/** @brief Audio class definition in interface descriptor. * * Fixed value, @ref app_usbd_descriptor_iface_t::bInterfaceClass * */ #define APP_USBD_AUDIO_CLASS 0x01 -/** @brief Audio class protocol definition in interface descriptor +/** @brief Audio class protocol definition in interface descriptor. * * Fixed value, @ref app_usbd_descriptor_iface_t::bInterfaceProtocol * */ #define APP_USBD_AUDIO_CLASS_PROTOCOL_UNDEFINED 0x00 /** - * @brief Audio subclass possible values + * @brief Audio subclass possible values. * * @ref app_usbd_descriptor_iface_t::bInterfaceSubClass */ @@ -98,7 +98,7 @@ typedef enum { APP_USBD_AUDIO_AC_IFACE_SUBTYPE_UNDEFINED = 0x00, /**< Audio control interface subtype UNDEFINED */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_HEADER, /**< Audio control interface subtype HEADER */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_INPUT_TERMINAL, /**< Audio control interface subtype INPUT_TERMINAL */ - APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERNINAL, /**< Audio control interface subtype OUTPUT_TERNINAL */ + APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERMINAL, /**< Audio control interface subtype OUTPUT_TERMINAL */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_MIXER_UNIT, /**< Audio control interface subtype MIXER_UNIT */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_SELECTOR_UNIT, /**< Audio control interface subtype SELECTOR_UNIT */ APP_USBD_AUDIO_AC_IFACE_SUBTYPE_FEATURE_UNIT, /**< Audio control interface subtype FEATURE_UNIT */ @@ -126,7 +126,7 @@ typedef enum { } app_usbd_audio_ep_subtype_t; /** - * @brief Audio class specific requests + * @brief Audio class specific requests. * * @ref nrf_drv_usbd_setup_t::bmRequestType */ @@ -149,7 +149,7 @@ typedef enum { } app_usbd_audio_req_type_t; /** - * @brief Audio class terminal types + * @brief Audio class terminal types. * */ typedef enum { /*USB terminals*/ @@ -186,12 +186,12 @@ typedef enum { } app_usbd_audio_terminal_type_t; /** - * @brief Audio class control interface header descriptor + * @brief Audio class control interface header descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_HEADER + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_HEADER uint8_t bcdADC[2]; //!< BCD ADC uint8_t wTotalLength[2]; //!< Total interfaces length uint8_t bInCollection; //!< Input collection @@ -200,7 +200,7 @@ typedef struct { /** - * @brief Possible values of input terminal channel config + * @brief Possible values of input terminal channel config. * * @ref app_usbd_audio_input_terminal_desc_t::wChannelConfig * */ @@ -220,12 +220,12 @@ typedef enum { } app_usbd_audio_in_term_ch_config_t; /** - * @brief Audio class input terminal descriptor + * @brief Audio class input terminal descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_INPUT_TERMINAL + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_INPUT_TERMINAL uint8_t bTerminalID; //!< Terminal ID uint8_t wTerminalType[2]; //!< Terminal type uint8_t bAssocTerminal; //!< Association terminal @@ -236,12 +236,12 @@ typedef struct { } app_usbd_audio_input_terminal_desc_t; /** - * @brief Audio class output terminal descriptor + * @brief Audio class output terminal descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERNINAL + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERMINAL uint8_t bTerminalID; //!< Terminal ID uint8_t wTerminalType[2]; //!< Terminal type uint8_t bAssocTerminal; //!< Association terminal @@ -250,7 +250,8 @@ typedef struct { } app_usbd_audio_output_terminal_desc_t; /** - * @brief Possible values of feature unit control field*/ + * @brief Possible values of feature unit control field. + */ typedef enum { APP_USBD_AUDIO_FEATURE_UNIT_CONTROL_MUTE = (1u << 0), /**< Feature unit control bit MUTE */ APP_USBD_AUDIO_FEATURE_UNIT_CONTROL_VOLUME = (1u << 1), /**< Feature unit control bit VOLUME */ @@ -265,12 +266,12 @@ typedef enum { } app_usbd_audio_feature_unit_control_t; /** - * @brief Audio class feature unit descriptor + * @brief Audio class feature unit descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_FEATURE_UNIT + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref APP_USBD_AUDIO_AC_IFACE_SUBTYPE_FEATURE_UNIT uint8_t bUnitID; //!< Unit ID uint8_t bSourceID; //!< Source ID uint8_t bControlSize; //!< Control size @@ -278,7 +279,7 @@ typedef struct { } app_usbd_audio_feature_unit_desc_t; /** - * @brief Format tag in audio streaming interface descriptor + * @brief Format tag in audio streaming interface descriptor. * * @ref app_usbd_audio_as_iface_desc_t::wFormatTag * */ @@ -304,24 +305,24 @@ typedef enum { } app_usbd_audio_as_iface_format_tag_t; /** - * @brief Audio class audio streaming interface descriptor + * @brief Audio class audio streaming interface descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref app_usbd_audio_ac_iface_subtype_t + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref app_usbd_audio_ac_iface_subtype_t uint8_t bTerminalLink; //!< Terminal link uint8_t bDelay; //!< Delay uint8_t wFormatTag[2]; //!< Format TAG } app_usbd_audio_as_iface_desc_t; /** - * @brief Audio class audio streaming format type I descriptor + * @brief Audio class audio streaming format type I descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref app_usbd_audio_as_iface_subtype_t + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref app_usbd_audio_as_iface_subtype_t uint8_t bFormatType; //!< Format type: fixed value 1 uint8_t bNrChannels; //!< Number of channels uint8_t bSubframeSize; //!< Subframe size @@ -332,12 +333,12 @@ typedef struct { /** - * @brief Audio class audio streaming format type II descriptor + * @brief Audio class audio streaming format type II descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref app_usbd_audio_as_iface_subtype_t + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref app_usbd_audio_as_iface_subtype_t uint8_t bFormatType; //!< Format type: fixed value 2 uint8_t wMaxBitRate[2]; //!< Maximum bitrate uint8_t wSamplesPerFrame[2]; //!< Samples per frame @@ -346,12 +347,12 @@ typedef struct { } app_usbd_audio_as_format_type_two_desc_t; /** - * @brief Audio class audio streaming format type III descriptor + * @brief Audio class audio streaming format type III descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_INTERFACE - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref app_usbd_audio_as_iface_subtype_t + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref app_usbd_audio_as_iface_subtype_t uint8_t bFormatType; //!< Format type: fixed value 1 uint8_t bNrChannels; //!< Number of channels uint8_t bSubframeSize; //!< Subframe size @@ -361,12 +362,12 @@ typedef struct { } app_usbd_audio_as_format_type_three_desc_t; /** - * @brief Audio class audio endpoint descriptor + * @brief Audio class audio endpoint descriptor. */ typedef struct { uint8_t bLength; //!< Length of the descriptor uint8_t bDescriptorType; //!< Descriptor type @ref APP_USBD_AUDIO_DESCRIPTOR_ENDPOINT - uint8_t bDescriptorSubType; //!< Descriptor subtype @ref APP_USBD_AUDIO_EP_SUBTYPE_GENERAL + uint8_t bDescriptorSubtype; //!< Descriptor subtype @ref APP_USBD_AUDIO_EP_SUBTYPE_GENERAL uint8_t bmAttributes; //!< Audio endpoint attributes uint8_t bLockDelayUnits; //!< Lock delay units uint8_t wLockDelay[2]; //!< Lock delay value @@ -379,4 +380,3 @@ typedef struct { #endif #endif /* APP_USBD_AUDIO_TYPES_H__ */ - diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c new file mode 100644 index 0000000..249a909 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c @@ -0,0 +1,1199 @@ +/** + * Copyright (c) 2016 - 2019, 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(APP_USBD_CDC_ACM) + +#include "app_usbd_cdc_acm.h" +#include + +/** + * @defgroup app_usbd_cdc_acm_internal CDC ACM internals + * @{ + * @ingroup app_usbd_cdc + * @internal + */ + + +#define NRF_LOG_MODULE_NAME cdc_acm + +#if APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#else //APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define APP_USBD_CDC_ACM_COMM_IFACE_IDX 0 /**< CDC ACM class comm interface index. */ +#define APP_USBD_CDC_ACM_DATA_IFACE_IDX 1 /**< CDC ACM class data interface index. */ + +#define APP_USBD_CDC_ACM_COMM_EPIN_IDX 0 /**< CDC ACM comm class endpoint IN index. */ +#define APP_USBD_CDC_ACM_DATA_EPIN_IDX 0 /**< CDC ACM data class endpoint IN index. */ +#define APP_USBD_CDC_ACM_DATA_EPOUT_IDX 1 /**< CDC ACM data class endpoint OUT index. */ + +/** + * @brief Auxiliary function to access cdc_acm class instance data. + * + * @param[in] p_inst Class instance data. + * + * @return CDC ACM class instance. + */ +static inline app_usbd_cdc_acm_t const * cdc_acm_get(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + return (app_usbd_cdc_acm_t const *)p_inst; +} + +/** + * @brief Auxiliary function to access cdc_acm class context data. + * + * @param[in] p_cdc_acm CDC ACM class instance data. + * + * @return CDC ACM class instance context. + */ +static inline app_usbd_cdc_acm_ctx_t * cdc_acm_ctx_get(app_usbd_cdc_acm_t const * p_cdc_acm) +{ + ASSERT(p_cdc_acm != NULL); + ASSERT(p_cdc_acm->specific.p_data != NULL); + return &p_cdc_acm->specific.p_data->ctx; +} + +/** + * @brief User event handler. + * + * @param[in] p_inst Class instance. + * @param[in] event user Event type. + */ +static inline void user_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_cdc_acm_user_event_t event) +{ + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + if (p_cdc_acm->specific.inst.user_ev_handler != NULL) + { + p_cdc_acm->specific.inst.user_ev_handler(p_inst, event); + } +} + +/** + * @brief Auxiliary function to access CDC ACM COMM IN endpoint address. + * + * @param[in] p_inst Class instance data. + * + * @return IN endpoint address. + */ +static inline nrf_drv_usbd_ep_t comm_ep_in_addr_get(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * class_iface; + class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_CDC_ACM_COMM_IFACE_IDX); + + app_usbd_class_ep_conf_t const * ep_cfg; + ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_ACM_COMM_EPIN_IDX); + + return app_usbd_class_ep_address_get(ep_cfg); +} + +/** + * @brief Auxiliary function to access CDC ACM DATA IN endpoint address. + * + * @param[in] p_inst Class instance data. + * + * @return IN endpoint address. + */ +static inline nrf_drv_usbd_ep_t data_ep_in_addr_get(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * class_iface; + class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_CDC_ACM_DATA_IFACE_IDX); + + app_usbd_class_ep_conf_t const * ep_cfg; + ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_ACM_DATA_EPIN_IDX); + + return app_usbd_class_ep_address_get(ep_cfg); +} + +/** + * @brief Auxiliary function to access CDC ACM DATA OUT endpoint address. + * + * @param[in] p_inst Class instance data. + * + * @return OUT endpoint address. + */ +static inline nrf_drv_usbd_ep_t data_ep_out_addr_get(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * class_iface; + class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_CDC_ACM_DATA_IFACE_IDX); + + app_usbd_class_ep_conf_t const * ep_cfg; + ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_CDC_ACM_DATA_EPOUT_IDX); + + return app_usbd_class_ep_address_get(ep_cfg); +} + +/** + * @brief Internal SETUP standard IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + /* Only Get Descriptor standard IN request is supported by CDC class */ + if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) + && + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + { + size_t dsc_len = 0; + size_t max_size; + + uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); + + /* Try to find descriptor in class internals*/ + ret_code_t ret = app_usbd_class_descriptor_find( + p_inst, + p_setup_ev->setup.wValue.hb, + p_setup_ev->setup.wValue.lb, + p_trans_buff, + &dsc_len); + + if (ret != NRF_ERROR_NOT_FOUND) + { + ASSERT(dsc_len < NRF_DRV_USBD_EPSIZE); + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_trans_buff, dsc_len); + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Internal SETUP standard OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + + switch (p_setup_ev->setup.bRequest) + { + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Internal SETUP class IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_CDC_REQ_GET_LINE_CODING: + { + if (p_setup_ev->setup.wLength.w != sizeof(app_usbd_cdc_line_coding_t)) + { + return NRF_ERROR_NOT_SUPPORTED; + } + + return app_usbd_core_setup_rsp(&p_setup_ev->setup, + &p_cdc_acm_ctx->line_coding, + sizeof(app_usbd_cdc_line_coding_t)); + } + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Class specific OUT request data callback. + * + * @param status Endpoint status. + * @param p_context Context of transfer (set by @ref app_usbd_core_setup_data_handler_set). + * + * @return Standard error code. + */ +static ret_code_t cdc_acm_req_out_data_cb(nrf_drv_usbd_ep_status_t status, void * p_context) +{ + if (status != NRF_USBD_EP_OK) + { + return NRF_ERROR_INTERNAL; + } + + app_usbd_cdc_acm_t const * p_cdc_acm = p_context; + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + switch (p_cdc_acm_ctx->request.type) + { + case APP_USBD_CDC_REQ_SET_LINE_CODING: + { + memcpy(&p_cdc_acm_ctx->line_coding, + &p_cdc_acm_ctx->request.payload.line_coding, + sizeof(app_usbd_cdc_line_coding_t)); + + NRF_LOG_INFO("REQ_SET_LINE_CODING: baudrate: %"PRIu32", databits: %u, " + "format: %u, parity: %u", + uint32_decode(p_cdc_acm_ctx->line_coding.dwDTERate), + p_cdc_acm_ctx->line_coding.bDataBits, + p_cdc_acm_ctx->line_coding.bCharFormat, + p_cdc_acm_ctx->line_coding.bParityType); + break; + } + default: + return NRF_ERROR_NOT_SUPPORTED; + } + + return NRF_SUCCESS; +} + + +/** + * @brief Class specific request data stage setup. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t cdc_acm_req_out_datastage(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + p_cdc_acm_ctx->request.type = p_setup_ev->setup.bRequest; + p_cdc_acm_ctx->request.len = p_setup_ev->setup.wLength.w; + + /*Request setup data*/ + NRF_DRV_USBD_TRANSFER_OUT(transfer, + &p_cdc_acm_ctx->request.payload, + p_cdc_acm_ctx->request.len); + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); + if (ret == NRF_SUCCESS) + { + const app_usbd_core_setup_data_handler_desc_t desc = { + .handler = cdc_acm_req_out_data_cb, + .p_context = (void*)p_cdc_acm + }; + + ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + +/** + * @brief Reset port to default state. + * + * @param p_inst Generic class instance. + */ +static void cdc_acm_reset_port(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + p_cdc_acm_ctx->line_state = 0; + + // Set rx transfers configuration to default state. + p_cdc_acm_ctx->rx_transfer[0].p_buf = NULL; + p_cdc_acm_ctx->rx_transfer[1].p_buf = NULL; + p_cdc_acm_ctx->bytes_left = 0; + p_cdc_acm_ctx->bytes_read = 0; + p_cdc_acm_ctx->last_read = 0; + p_cdc_acm_ctx->cur_read = 0; + p_cdc_acm_ctx->p_copy_pos = p_cdc_acm_ctx->internal_rx_buf; +} + +/** + * @brief Internal SETUP class OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_CDC_REQ_SET_LINE_CODING: + { + if (p_setup_ev->setup.wLength.w != sizeof(app_usbd_cdc_line_coding_t)) + { + return NRF_ERROR_NOT_SUPPORTED; + } + + return cdc_acm_req_out_datastage(p_inst, p_setup_ev); + } + case APP_USBD_CDC_REQ_SET_CONTROL_LINE_STATE: + { + if (p_setup_ev->setup.wLength.w != 0) + { + return NRF_ERROR_NOT_SUPPORTED; + } + + NRF_LOG_INFO("REQ_SET_CONTROL_LINE_STATE: 0x%x", p_setup_ev->setup.wValue.w); + + bool old_dtr = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? + true : false; + p_cdc_acm_ctx->line_state = p_setup_ev->setup.wValue.w; + + bool new_dtr = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? + true : false; + + if (old_dtr == new_dtr) + { + return NRF_SUCCESS; + } + + const app_usbd_cdc_acm_user_event_t ev = new_dtr ? + APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN : APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE; + + user_event_handler(p_inst, ev); + + if (!new_dtr) + { + /*Abort DATA endpoints on port close */ + nrf_drv_usbd_ep_t ep; + ep = data_ep_in_addr_get(p_inst); + nrf_drv_usbd_ep_abort(ep); + ep = data_ep_out_addr_get(p_inst); + nrf_drv_usbd_ep_abort(ep); + + // Set rx transfers configuration to default state. + p_cdc_acm_ctx->rx_transfer[0].p_buf = NULL; + p_cdc_acm_ctx->rx_transfer[1].p_buf = NULL; + p_cdc_acm_ctx->bytes_left = 0; + p_cdc_acm_ctx->bytes_read = 0; + p_cdc_acm_ctx->last_read = 0; + p_cdc_acm_ctx->cur_read = 0; + p_cdc_acm_ctx->p_copy_pos = p_cdc_acm_ctx->internal_rx_buf; + } + + return NRF_SUCCESS; + } + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Control endpoint handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + ASSERT(p_inst != NULL); + ASSERT(p_setup_ev != NULL); + + if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_in(p_inst, p_setup_ev); + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_in(p_inst, p_setup_ev); + default: + break; + } + } + else /*APP_USBD_SETUP_REQDIR_OUT*/ + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_out(p_inst, p_setup_ev); + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_out(p_inst, p_setup_ev); + default: + break; + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief CDC ACM consumer. + * + * @note See @ref nrf_drv_usbd_consumer_t + */ +static bool cdc_acm_consumer(nrf_drv_usbd_ep_transfer_t * p_next, + void * p_context, + size_t ep_size, + size_t data_size) +{ + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = (app_usbd_cdc_acm_ctx_t *) p_context; + p_next->size = data_size; + + if (data_size <= p_cdc_acm_ctx->rx_transfer[0].read_left) + { + p_next->p_data.rx = p_cdc_acm_ctx->rx_transfer[0].p_buf; + + p_cdc_acm_ctx->rx_transfer[0].p_buf += data_size; + p_cdc_acm_ctx->bytes_read += data_size; + p_cdc_acm_ctx->rx_transfer[0].read_left -= data_size; + NRF_LOG_DEBUG("Received %d bytes. Space left in user buffer: %d bytes.", + data_size, + p_cdc_acm_ctx->rx_transfer[0].read_left); + return (p_cdc_acm_ctx->rx_transfer[0].read_left) != 0; + } + else + { + p_next->p_data.rx = p_cdc_acm_ctx->internal_rx_buf; + + p_cdc_acm_ctx->cur_read = data_size; + NRF_LOG_DEBUG("Received %d bytes. Stored in internal buffer.", data_size); + return false; + } +} + +/** + * @brief CDC ACM single transfer consumer. + * + * This function finalizes transfer after any received block. + * + * @note See @ref nrf_drv_usbd_consumer_t + */ +static bool cdc_acm_single_shoot_consumer(nrf_drv_usbd_ep_transfer_t * p_next, + void * p_context, + size_t ep_size, + size_t data_size) +{ + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = (app_usbd_cdc_acm_ctx_t *) p_context; + p_next->size = data_size; + + if (data_size <= p_cdc_acm_ctx->rx_transfer[0].read_left) + { + p_next->p_data.rx = p_cdc_acm_ctx->rx_transfer[0].p_buf; + + p_cdc_acm_ctx->bytes_read = data_size; + p_cdc_acm_ctx->rx_transfer[0].read_left = data_size; + NRF_LOG_DEBUG("Received %d bytes. Space left in user buffer: %d bytes.", + data_size, + p_cdc_acm_ctx->rx_transfer[0].read_left); + } + else + { + p_next->p_data.rx = p_cdc_acm_ctx->internal_rx_buf; + p_cdc_acm_ctx->cur_read = data_size; + NRF_LOG_DEBUG("Received %d bytes. Stored in internal buffer.", data_size); + } + + return false; +} + +/** + * @brief Manage switching between user buffers and copying data from internal buffer. + * + * @param p_inst Generic USB class instance. + * + * @return Standard error code. + */ +static ret_code_t cdc_acm_rx_block_finished(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + nrf_drv_usbd_ep_t ep = data_ep_out_addr_get(p_inst); + + nrf_drv_usbd_handler_desc_t handler_desc = { + .handler.consumer = cdc_acm_consumer, + .p_context = p_cdc_acm_ctx + }; + + if (p_cdc_acm_ctx->rx_transfer[0].read_left == 0) // Buffer completely filled by consumer + { + p_cdc_acm_ctx->last_read = p_cdc_acm_ctx->bytes_read; + p_cdc_acm_ctx->bytes_read = 0; + p_cdc_acm_ctx->bytes_left = 0; + + if (p_cdc_acm_ctx->rx_transfer[1].p_buf != NULL) + { + p_cdc_acm_ctx->rx_transfer[0] = p_cdc_acm_ctx->rx_transfer[1]; + p_cdc_acm_ctx->rx_transfer[1].p_buf = NULL; + return app_usbd_ep_handled_transfer(ep, &handler_desc); + } + else + { + p_cdc_acm_ctx->rx_transfer[0].p_buf = NULL; + return NRF_SUCCESS; + } + } + + size_t bytes_read = p_cdc_acm_ctx->cur_read; + size_t bytes_to_cpy = bytes_read; + + if (bytes_read > p_cdc_acm_ctx->rx_transfer[0].read_left) + { + bytes_to_cpy = p_cdc_acm_ctx->rx_transfer[0].read_left; + } + memcpy(p_cdc_acm_ctx->rx_transfer[0].p_buf, + p_cdc_acm_ctx->internal_rx_buf, + bytes_to_cpy); + + // First buffer is full + p_cdc_acm_ctx->last_read = p_cdc_acm_ctx->bytes_read + bytes_to_cpy; + p_cdc_acm_ctx->bytes_read = 0; + p_cdc_acm_ctx->bytes_left = bytes_read - bytes_to_cpy; + p_cdc_acm_ctx->p_copy_pos = p_cdc_acm_ctx->internal_rx_buf + bytes_to_cpy; + + if (p_cdc_acm_ctx->rx_transfer[1].p_buf != NULL) + { + // If there is second transfer, copy it to first + p_cdc_acm_ctx->rx_transfer[0] = p_cdc_acm_ctx->rx_transfer[1]; + p_cdc_acm_ctx->rx_transfer[1].p_buf = NULL; + + while (p_cdc_acm_ctx->bytes_left > 0) + { + + if (p_cdc_acm_ctx->bytes_left >= p_cdc_acm_ctx->rx_transfer[0].read_left) + { + // If there are enough bytes left in internal buffer to completely fill next transfer, + // we call user event handler to obtain next buffer and continue double buffering. + memcpy(p_cdc_acm_ctx->rx_transfer[0].p_buf, + p_cdc_acm_ctx->p_copy_pos, + p_cdc_acm_ctx->rx_transfer[0].read_left); + + p_cdc_acm_ctx->bytes_left -= p_cdc_acm_ctx->rx_transfer[0].read_left; + p_cdc_acm_ctx->p_copy_pos += p_cdc_acm_ctx->rx_transfer[0].read_left; + p_cdc_acm_ctx->last_read = p_cdc_acm_ctx->rx_transfer[0].read_left; + user_event_handler(p_inst, APP_USBD_CDC_ACM_USER_EVT_RX_DONE); + + if (p_cdc_acm_ctx->rx_transfer[1].p_buf != NULL) + { + p_cdc_acm_ctx->rx_transfer[0] = p_cdc_acm_ctx->rx_transfer[1]; + p_cdc_acm_ctx->rx_transfer[1].p_buf = NULL; + } + else + { + // If user does not specify a second buffer, all data transfers are done + // and data left in internal buffer is lost. + p_cdc_acm_ctx->rx_transfer[0].p_buf = NULL; + break; + } + } + else + { + memcpy(p_cdc_acm_ctx->rx_transfer[0].p_buf, + p_cdc_acm_ctx->p_copy_pos, + p_cdc_acm_ctx->bytes_left); + p_cdc_acm_ctx->bytes_read = p_cdc_acm_ctx->bytes_left; + + p_cdc_acm_ctx->rx_transfer[0].read_left -= p_cdc_acm_ctx->bytes_left; + p_cdc_acm_ctx->rx_transfer[0].p_buf += p_cdc_acm_ctx->bytes_left; + break; + } + } + + + } + else + { + p_cdc_acm_ctx->rx_transfer[0].p_buf = NULL; + } + + if (p_cdc_acm_ctx->rx_transfer[0].p_buf != NULL) + { + return app_usbd_ep_handled_transfer(ep, &handler_desc); + } + return NRF_SUCCESS; +} + +/** + * @brief Class specific endpoint transfer handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t cdc_acm_endpoint_ev(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + if (comm_ep_in_addr_get(p_inst) == p_event->drv_evt.data.eptransfer.ep) + { + NRF_LOG_INFO("EPIN_COMM: notify"); + return NRF_SUCCESS; + } + ret_code_t ret; + if (NRF_USBD_EPIN_CHECK(p_event->drv_evt.data.eptransfer.ep)) + { + switch (p_event->drv_evt.data.eptransfer.status) + { + case NRF_USBD_EP_OK: + NRF_LOG_INFO("EPIN_DATA: %02x done", p_event->drv_evt.data.eptransfer.ep); + user_event_handler(p_inst, APP_USBD_CDC_ACM_USER_EVT_TX_DONE); + return NRF_SUCCESS; + case NRF_USBD_EP_ABORTED: + return NRF_SUCCESS; + default: + return NRF_ERROR_INTERNAL; + } + } + + if (NRF_USBD_EPOUT_CHECK(p_event->drv_evt.data.eptransfer.ep)) + { + switch (p_event->drv_evt.data.eptransfer.status) + { + case NRF_USBD_EP_OK: + ret = cdc_acm_rx_block_finished(p_inst); + NRF_LOG_INFO("EPOUT_DATA: %02x done", p_event->drv_evt.data.eptransfer.ep); + user_event_handler(p_inst, APP_USBD_CDC_ACM_USER_EVT_RX_DONE); + return ret; + case NRF_USBD_EP_WAITING: + case NRF_USBD_EP_ABORTED: + return NRF_SUCCESS; + default: + return NRF_ERROR_INTERNAL; + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief @ref app_usbd_class_methods_t::event_handler + */ +static ret_code_t cdc_acm_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ASSERT(p_inst != NULL); + ASSERT(p_event != NULL); + + ret_code_t ret = NRF_SUCCESS; + switch (p_event->app_evt.type) + { + case APP_USBD_EVT_DRV_SOF: + break; + case APP_USBD_EVT_DRV_RESET: + cdc_acm_reset_port(p_inst); + break; + case APP_USBD_EVT_DRV_SETUP: + ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *)p_event); + break; + case APP_USBD_EVT_DRV_EPTRANSFER: + ret = cdc_acm_endpoint_ev(p_inst, p_event); + break; + case APP_USBD_EVT_DRV_SUSPEND: + break; + case APP_USBD_EVT_DRV_RESUME: + break; + case APP_USBD_EVT_INST_APPEND: + break; + case APP_USBD_EVT_INST_REMOVE: + break; + case APP_USBD_EVT_STARTED: + break; + case APP_USBD_EVT_STOPPED: + break; + case APP_USBD_EVT_POWER_REMOVED: + cdc_acm_reset_port(p_inst); + break; + default: + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + return ret; +} + + +static bool cdc_acm_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static uint8_t ifaces = 0; + ifaces = app_usbd_class_iface_count_get(p_inst); + app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size); + + /* INTERFACE ASSOCIATION DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x08); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION); // bDescriptorType = Interface Association + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.comm_interface); // bFirstInterface + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x02); // bInterfaceCount + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_COMM_CLASS); // bFunctionClass + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SUBCLASS_ACM); // bFunctionSubClass + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.protocol); // bFunctionProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iFunction + + static uint8_t i = 0; + + for (i = 0; i < ifaces; i++) + { + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, i); + + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + + if (p_cdc_acm->specific.inst.comm_interface == app_usbd_class_iface_number_get(p_cur_iface)) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_COMM_CLASS); // bInterfaceClass = CDC COMM + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SUBCLASS_ACM); // bInterfaceSubclass + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.protocol); // bInterfaceProtocol + } + else if (p_cdc_acm->specific.inst.data_interface == + app_usbd_class_iface_number_get(p_cur_iface)) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_DATA_CLASS); // bInterfaceClass = CDC DATA + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterfaceSubclass + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterfaceProtocol + } + else + { + ASSERT(0); + } + + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + if (p_cdc_acm->specific.inst.comm_interface == app_usbd_class_iface_number_get(p_cur_iface)) + { + /* HEADER DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_HEADER); // bDescriptorSubtype = Header Functional Descriptor + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x10); // bcdCDC LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x01); // bcdCDC MSB + + /* CALL MANAGEMENT DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_CALL_MGMT); // bDescriptorSubtype = Call Management Functional Descriptor + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x03); // bmCapabilities + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.data_interface); // bDataInterface + + /* ABSTRACT CONTROL MANAGEMENT DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x04); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_ACM); // bDescriptorSubtype = Abstract Control Management Functional Descriptor + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x02); // bmCapabilities + + /* UNION DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05); + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_UNION); // bDescriptorSubtype = Union Functional Descriptor + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.comm_interface); // bControlInterface + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.data_interface); // bSubordinateInterface + } + else if (p_cdc_acm->specific.inst.data_interface == + app_usbd_class_iface_number_get(p_cur_iface)) + { + ; + } + else + { + ASSERT(0); + } + + /* ENDPOINT DESCRIPTORS */ + static uint8_t endpoints = 0; + endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface); + + static uint8_t j = 0; + + for (j = 0; j < endpoints; j++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint + + static app_usbd_class_ep_conf_t const * p_cur_ep = NULL; + p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress + + if (p_cdc_acm->specific.inst.comm_interface == + app_usbd_class_iface_number_get(p_cur_iface)) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT); // bmAttributes + } + else if (p_cdc_acm->specific.inst.data_interface == + app_usbd_class_iface_number_get(p_cur_iface)) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_BULK); // bmAttributes + } + else + { + ASSERT(0); + } + + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize MSB + + if (p_cdc_acm->specific.inst.comm_interface == + app_usbd_class_iface_number_get(p_cur_iface)) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.p_ep_interval[0]); // bInterval + } + else if (p_cdc_acm->specific.inst.data_interface == + app_usbd_class_iface_number_get(p_cur_iface)) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterval + } + else + { + ASSERT(0); + } + + } + + } + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + +/** + * @brief Public cdc_acm class interface. + * + */ +const app_usbd_class_methods_t app_usbd_cdc_acm_class_methods = { + .event_handler = cdc_acm_event_handler, + .feed_descriptors = cdc_acm_feed_descriptors, +}; + +/** @} */ + +ret_code_t app_usbd_cdc_acm_write(app_usbd_cdc_acm_t const * p_cdc_acm, + const void * p_buf, + size_t length) +{ + app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + bool dtr_state = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? + true : false; + if (!dtr_state) + { + /*Port is not opened*/ + return NRF_ERROR_INVALID_STATE; + } + + nrf_drv_usbd_ep_t ep = data_ep_in_addr_get(p_inst); + + if (APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE && ((length % NRF_DRV_USBD_EPSIZE) == 0)) + { + NRF_DRV_USBD_TRANSFER_IN_ZLP(transfer, p_buf, length); + return app_usbd_ep_transfer(ep, &transfer); + } + else + { + NRF_DRV_USBD_TRANSFER_IN(transfer, p_buf, length); + return app_usbd_ep_transfer(ep, &transfer); + } +} + +size_t app_usbd_cdc_acm_rx_size(app_usbd_cdc_acm_t const * p_cdc_acm) +{ + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + return p_cdc_acm_ctx->last_read; +} + +size_t app_usbd_cdc_acm_bytes_stored(app_usbd_cdc_acm_t const * p_cdc_acm) +{ + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + return p_cdc_acm_ctx->bytes_left; +} + +ret_code_t app_usbd_cdc_acm_read(app_usbd_cdc_acm_t const * p_cdc_acm, + void * p_buf, + size_t length) +{ + ASSERT(p_buf != NULL); + ret_code_t ret; + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + if (0U == (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR)) + { + /*Port is not opened*/ + return NRF_ERROR_INVALID_STATE; + } + +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + CRITICAL_REGION_ENTER(); +#endif // (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + + if (p_cdc_acm_ctx->rx_transfer[0].p_buf == NULL) + { + if (p_cdc_acm_ctx->bytes_left >= length) + { + memcpy(p_buf, p_cdc_acm_ctx->p_copy_pos, length); + p_cdc_acm_ctx->bytes_left -= length; + p_cdc_acm_ctx->p_copy_pos += length; + p_cdc_acm_ctx->last_read = length; + ret = NRF_SUCCESS; + } + else + { + p_cdc_acm_ctx->rx_transfer[0].p_buf = p_buf; + p_cdc_acm_ctx->rx_transfer[0].read_left = length; + nrf_drv_usbd_ep_t ep = data_ep_out_addr_get(app_usbd_cdc_acm_class_inst_get(p_cdc_acm)); + nrf_drv_usbd_handler_desc_t const handler_desc = { + .handler.consumer = cdc_acm_consumer, + .p_context = p_cdc_acm_ctx + }; + + if (p_cdc_acm_ctx->bytes_left > 0) + { + memcpy(p_cdc_acm_ctx->rx_transfer[0].p_buf, + p_cdc_acm_ctx->p_copy_pos, + p_cdc_acm_ctx->bytes_left); + p_cdc_acm_ctx->rx_transfer[0].read_left -= p_cdc_acm_ctx->bytes_left; + p_cdc_acm_ctx->rx_transfer[0].p_buf += p_cdc_acm_ctx->bytes_left; + p_cdc_acm_ctx->bytes_read = p_cdc_acm_ctx->bytes_left; + p_cdc_acm_ctx->bytes_left = 0; + + } + ret = app_usbd_ep_handled_transfer(ep, &handler_desc); + if (ret == NRF_SUCCESS) + { + ret = NRF_ERROR_IO_PENDING; + } + } + } + else if (p_cdc_acm_ctx->rx_transfer[1].p_buf == NULL) + { + p_cdc_acm_ctx->rx_transfer[1].p_buf = p_buf; + p_cdc_acm_ctx->rx_transfer[1].read_left = length; + ret = NRF_ERROR_IO_PENDING; + } + else + { + ret = NRF_ERROR_BUSY; + } +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + CRITICAL_REGION_EXIT(); +#endif // (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + + return ret; +} + +ret_code_t app_usbd_cdc_acm_read_any(app_usbd_cdc_acm_t const * p_cdc_acm, + void * p_buf, + size_t length) +{ + ASSERT(p_buf != NULL); + ret_code_t ret; + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + if (0U == (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR)) + { + /*Port is not opened*/ + return NRF_ERROR_INVALID_STATE; + } + +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + CRITICAL_REGION_ENTER(); +#endif // (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + if (p_cdc_acm_ctx->bytes_left > 0) + { + size_t to_copy = MIN(length, p_cdc_acm_ctx->bytes_left); + memcpy(p_buf, p_cdc_acm_ctx->p_copy_pos, to_copy); + p_cdc_acm_ctx->bytes_left -= to_copy; + p_cdc_acm_ctx->p_copy_pos += to_copy; + p_cdc_acm_ctx->last_read = to_copy; + ret = NRF_SUCCESS; + } + else + { + if (p_cdc_acm_ctx->rx_transfer[0].p_buf == NULL) + { + p_cdc_acm_ctx->rx_transfer[0].p_buf = p_buf; + p_cdc_acm_ctx->rx_transfer[0].read_left = length; + nrf_drv_usbd_ep_t ep = data_ep_out_addr_get(app_usbd_cdc_acm_class_inst_get(p_cdc_acm)); + nrf_drv_usbd_handler_desc_t const handler_desc = { + .handler.consumer = cdc_acm_single_shoot_consumer, + .p_context = p_cdc_acm_ctx + }; + + ret = app_usbd_ep_handled_transfer(ep, &handler_desc); + if (ret == NRF_SUCCESS) + { + ret = NRF_ERROR_IO_PENDING; + } + } + else + { + ret = NRF_ERROR_BUSY; + } + } + +#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + CRITICAL_REGION_EXIT(); +#endif // (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE == 0) + + return ret; +} + +static ret_code_t cdc_acm_serial_state_notify(app_usbd_cdc_acm_t const * p_cdc_acm) +{ + app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + nrf_drv_usbd_ep_t ep = comm_ep_in_addr_get(p_inst); + + NRF_DRV_USBD_TRANSFER_OUT(transfer, + &p_cdc_acm_ctx->request.payload, + sizeof(app_usbd_cdc_acm_notify_t)); + return app_usbd_ep_transfer(ep, &transfer); +} + +ret_code_t app_usbd_cdc_acm_serial_state_notify(app_usbd_cdc_acm_t const * p_cdc_acm, + app_usbd_cdc_acm_serial_state_t serial_state, + bool value) +{ + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = NRF_SUCCESS; + switch (serial_state) + { + case APP_USBD_CDC_ACM_SERIAL_STATE_DCD: + case APP_USBD_CDC_ACM_SERIAL_STATE_DSR: + case APP_USBD_CDC_ACM_SERIAL_STATE_BREAK: + case APP_USBD_CDC_ACM_SERIAL_STATE_RING: + case APP_USBD_CDC_ACM_SERIAL_STATE_FRAMING: + case APP_USBD_CDC_ACM_SERIAL_STATE_PARITY: + case APP_USBD_CDC_ACM_SERIAL_STATE_OVERRUN: + + if (value) + { + p_cdc_acm_ctx->serial_state |= serial_state; + } + else + { + p_cdc_acm_ctx->serial_state &= ~serial_state; + } + + break; + default: + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + if (ret == NRF_SUCCESS) + { + app_usbd_cdc_acm_notify_t * notify = &p_cdc_acm_ctx->request.payload.notify; + notify->cdc_notify.bmRequestType = app_usbd_setup_req_val(APP_USBD_SETUP_REQREC_INTERFACE, + APP_USBD_SETUP_REQTYPE_CLASS, + APP_USBD_SETUP_REQDIR_IN); + notify->cdc_notify.bRequest = APP_USBD_CDC_NOTIF_SERIAL_STATE; + notify->cdc_notify.wValue = 0; + notify->cdc_notify.wIndex = 0; + notify->cdc_notify.wLength = sizeof(notify->serial_state); + + notify->serial_state = p_cdc_acm_ctx->serial_state; + + ret = cdc_acm_serial_state_notify(p_cdc_acm); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + +ret_code_t app_usbd_cdc_acm_line_state_get(app_usbd_cdc_acm_t const * p_cdc_acm, + app_usbd_cdc_acm_line_state_t line_state, + uint32_t * value) +{ + app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = NRF_SUCCESS; + switch (line_state) + { + case APP_USBD_CDC_ACM_LINE_STATE_DTR: + case APP_USBD_CDC_ACM_LINE_STATE_RTS: + *value = (p_cdc_acm_ctx->line_state & line_state) != 0; + break; + default: + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + CRITICAL_REGION_EXIT(); + + return ret; +} + +#endif //NRF_MODULE_ENABLED(APP_USBD_CDC_ACM) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h index b90e814..af81dc4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_CDC_ACM_H__ #define APP_USBD_CDC_ACM_H__ @@ -74,7 +74,7 @@ extern "C" { #ifdef DOXYGEN /** - * @brief CDC ACM class instance type + * @brief CDC ACM class instance type. * * @ref APP_USBD_CLASS_TYPEDEF */ @@ -144,21 +144,33 @@ typedef enum app_usbd_cdc_acm_user_event_e { * @brief Global definition of app_usbd_cdc_acm_t class instance. * * @param instance_name Name of global instance. - * @param interfaces_configs Interfaces configurations. * @param user_ev_handler User event handler (optional). - * @param raw_descriptors Raw descriptor table. + * @param comm_ifc Interface number of cdc_acm control. + * @param data_ifc Interface number of cdc_acm DATA. + * @param comm_ein COMM subclass IN endpoint. + * @param data_ein DATA subclass IN endpoint. + * @param data_eout DATA subclass OUT endpoint. + * @param cdc_protocol CDC protocol @ref app_usbd_cdc_comm_protocol_t * * @note This macro is just simplified version of @ref APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL. * */ -#define APP_USBD_CDC_ACM_GLOBAL_DEF(instance_name, \ - interfaces_configs, \ - user_ev_handler, \ - raw_descriptors) \ - APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL(instance_name, \ - interfaces_configs, \ - user_ev_handler, \ - raw_descriptors) +#define APP_USBD_CDC_ACM_GLOBAL_DEF(instance_name, \ + user_ev_handler, \ + comm_ifc, \ + data_ifc, \ + comm_ein, \ + data_ein, \ + data_eout, \ + cdc_protocol) \ + APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL(instance_name, \ + user_ev_handler, \ + comm_ifc, \ + data_ifc, \ + comm_ein, \ + data_ein, \ + data_eout, \ + cdc_protocol) \ /** * @brief Helper function to get class instance from CDC ACM class. @@ -217,10 +229,10 @@ ret_code_t app_usbd_cdc_acm_write(app_usbd_cdc_acm_t const * p_cdc_acm, size_t length); /** - * @brief Returns the amount of data to be read. + * @brief Returns the amount of data that was read. * * This function should be used on @ref APP_USBD_CDC_ACM_USER_EVT_RX_DONE event to get - * information how many bytes have been transfered. + * information how many bytes have been transfered into user buffer. * * @param[in] p_cdc_acm CDC ACM class instance (defined by @ref APP_USBD_CDC_ACM_GLOBAL_DEF). * @@ -228,18 +240,73 @@ ret_code_t app_usbd_cdc_acm_write(app_usbd_cdc_acm_t const * p_cdc_acm, */ size_t app_usbd_cdc_acm_rx_size(app_usbd_cdc_acm_t const * p_cdc_acm); +/** + * @brief Returns the amount of data that was stored into internal buffer + * + * This function should be used on @ref APP_USBD_CDC_ACM_USER_EVT_RX_DONE event to get + * information how many bytes are waiting in internal buffer. + * + * @param[in] p_cdc_acm CDC ACM class instance (defined by @ref APP_USBD_CDC_ACM_GLOBAL_DEF). + * + * @return Amount of data waiting. + */ +size_t app_usbd_cdc_acm_bytes_stored(app_usbd_cdc_acm_t const * p_cdc_acm); + /** * @brief Reads data from CDC ACM serial port. * + * This function uses internal buffer and double buffering for continuous transmission. + * + * If there is enough data in internal buffer to fill user buffer, NRF_SUCCESS is + * returned and data is immediately available in the user buffer. + * + * If not, up to two user buffers can be scheduled, function returns NRF_ERROR_IO_PENDING + * when first buffer is filled and @ref APP_USBD_CDC_ACM_USER_EVT_RX_DONE event is generated. + * + * @sa app_usbd_cdc_acm_read_any + * @sa app_usbd_cdc_acm_rx_size + * * @param[in] p_cdc_acm CDC ACM class instance (defined by @ref APP_USBD_CDC_ACM_GLOBAL_DEF). * @param[out] p_buf Output buffer. - * @param[in] length Output buffer length (must by multiple of @ref NRF_DRV_USBD_EPSIZE). + * @param[in] length Number of bytes to read. * - * @return Standard error code. + * @retval NRF_SUCCESS Data is stored into user buffer. + * @retval NRF_ERROR_IO_PENDING Awaiting transmission, when data is stored into user buffer, + * @ref APP_USBD_CDC_ACM_USER_EVT_RX_DONE event will be raised. + * @retval NRF_ERROR_BUSY There are already 2 buffers queued for transfers. + * @retval other Standard error code. */ ret_code_t app_usbd_cdc_acm_read(app_usbd_cdc_acm_t const * p_cdc_acm, void * p_buf, size_t length); + +/** + * @brief Read any data from CDC ACM port up to given buffer size + * + * This function is very similar to the @ref app_usbd_cdc_acm_read but it returns + * data as quick as any data is available, even if the given buffer was not totally full. + * + * @note This function cannot use double buffering. + * @note To check the number of bytes really read use @ref app_usbd_cdc_acm_rx_size + * function. + * + * @sa app_usbd_cdc_acm_read + * @sa app_usbd_cdc_acm_rx_size + * + * @param p_cdc_acm CDC ACM class instance (defined by @ref APP_USBD_CDC_ACM_GLOBAL_DEF). + * @param[out] p_buf Output buffer. + * @param[in] length Maximum number of bytes to read. + * + * @retval NRF_SUCCESS Data is stored into user buffer. + * @retval NRF_ERROR_IO_PENDING Awaiting transmission, when data is stored into user buffer, + * @ref APP_USBD_CDC_ACM_USER_EVT_RX_DONE event will be raised. + * @retval NRF_ERROR_BUSY There is already buffer set for a transfer. + * @retval other Standard error code. + */ +ret_code_t app_usbd_cdc_acm_read_any(app_usbd_cdc_acm_t const * p_cdc_acm, + void * p_buf, + size_t length); + /** * @brief Serial state notifications. * */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h new file mode 100644 index 0000000..8b7844d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm_internal.h @@ -0,0 +1,287 @@ +/** + * Copyright (c) 2016 - 2019, 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 APP_USBD_CDC_ACM_INTERNAL_H__ +#define APP_USBD_CDC_ACM_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "app_util.h" + +/** + * @defgroup app_usbd_cdc_acm_internal USB CDC ACM internals + * @ingroup app_usbd_cdc_acm + * @brief @tagAPI52840 Internals of the USB ACM class implementation. + * @{ + */ + +/** + * @brief Forward declaration of type defined by @ref APP_USBD_CLASS_TYPEDEF in cdc_acm class. + * + */ +APP_USBD_CLASS_FORWARD(app_usbd_cdc_acm); + +/*lint -save -e165*/ +/** + * @brief Forward declaration of @ref app_usbd_cdc_acm_user_event_e. + * + */ +enum app_usbd_cdc_acm_user_event_e; + +/*lint -restore*/ + +/** + * @brief User event handler. + * + * @param[in] p_inst Class instance. + * @param[in] event User event. + * + */ +typedef void (*app_usbd_cdc_acm_user_ev_handler_t)(app_usbd_class_inst_t const * p_inst, + enum app_usbd_cdc_acm_user_event_e event); + +/** + * @brief CDC ACM class part of class instance data. + */ +typedef struct { + uint8_t comm_interface; //!< Interface number of cdc_acm control. + uint8_t comm_epin; //!< COMM subclass IN endpoint. + uint8_t data_interface; //!< Interface number of cdc_acm DATA. + uint8_t data_epout; //!< DATA subclass OUT endpoint. + uint8_t data_epin; //!< DATA subclass IN endpoint. + + app_usbd_cdc_comm_protocol_t protocol; //!< User specified CDC protocol. + + app_usbd_cdc_acm_user_ev_handler_t user_ev_handler; //!< User event handler. + + uint8_t * p_ep_interval; //!< Endpoint intervals. +} app_usbd_cdc_acm_inst_t; + + +/** + * @brief CDC ACM serial state class notify. + */ +typedef struct { + app_usbd_cdc_notify_t cdc_notify; //!< CDC notify. + uint16_t serial_state; //!< Serial port state. +} app_usbd_cdc_acm_notify_t; + +/** + * @brief CDC ACM class specific request handled via control endpoint. + */ +typedef struct { + uint8_t type; //!< Request type. + uint8_t len; //!< Request length. + + union { + app_usbd_cdc_line_coding_t line_coding; //!< CDC ACM current line coding. + app_usbd_cdc_acm_notify_t notify; //!< CDC ACM class notify. + } payload; +} app_usbd_cdc_acm_req_t; + +/** + * @brief CDC ACM rx transfer buffer. + */ +typedef struct { + uint8_t * p_buf; //!< User buffer pointer. + size_t read_left; //!< Bytes left to read into buffer. +} cdc_rx_buffer_t; + +/** + * @brief CDC ACM class context. + */ +typedef struct { + app_usbd_cdc_acm_req_t request; //!< CDC ACM class request. + app_usbd_cdc_line_coding_t line_coding; //!< CDC ACM current line coding. + + uint16_t line_state; //!< CDC ACM line state bitmap, DTE side. + uint16_t serial_state; //!< CDC ACM serial state bitmap, DCE side. + + cdc_rx_buffer_t rx_transfer[2]; //!< User receive transfers. + + uint8_t internal_rx_buf[NRF_DRV_USBD_EPSIZE]; //!< Internal receive buffer. + uint8_t * p_copy_pos; //!< Current copy position from internal buffer. + + size_t bytes_left; //!< Bytes left in internal buffer to copy. + size_t bytes_read; //!< Bytes currently written to user buffer. + size_t last_read; //!< Bytes read in last transfer. + size_t cur_read; //!< Bytes currently read to internal buffer. +} app_usbd_cdc_acm_ctx_t; + +/** + * @brief Default interval value for comm endpoint IN + * + */ +#define APP_USBD_CDC_ACM_DEFAULT_INTERVAL 0x10 + +/** + * @brief CDC ACM class configuration macro. + * + * Used by @ref APP_USBD_CDC_ACM_GLOBAL_DEF + * + * @param iface_comm Interface number of cdc_acm control. + * @param epin_comm COMM subclass IN endpoint. + * @param iface_data Interface number of cdc_acm DATA. + * @param epin_data DATA subclass IN endpoint. + * @param epout_data DATA subclass OUT endpoint. + * + */ +#define APP_USBD_CDC_ACM_CONFIG(iface_comm, epin_comm, iface_data, epin_data, epout_data) \ + ((iface_comm, epin_comm), \ + (iface_data, epin_data, epout_data)) + + +/** + * @brief Specific class constant data for cdc_acm class. + * + * @ref app_usbd_cdc_acm_inst_t + */ +#define APP_USBD_CDC_ACM_INSTANCE_SPECIFIC_DEC app_usbd_cdc_acm_inst_t inst; + + +/** + * @brief Configures cdc_acm class instance. + * + * @param user_event_handler User event handler. + * @param comm_ifc Interface number of cdc_acm control. + * @param comm_ein COMM subclass IN endpoint. + * @param data_ifc Interface number of cdc_acm DATA. + * @param data_ein DATA subclass IN endpoint. + * @param data_eout DATA subclass OUT endpoint. + * @param cdc_protocol CDC protocol. + * @param ep_list List of endpoints and intervals + */ +#define APP_USBD_CDC_ACM_INST_CONFIG(user_event_handler, \ + comm_ifc, \ + comm_ein, \ + data_ifc, \ + data_ein, \ + data_eout, \ + cdc_protocol, \ + ep_list) \ + .inst = { \ + .user_ev_handler = user_event_handler, \ + .comm_interface = comm_ifc, \ + .comm_epin = comm_ifc, \ + .data_interface = data_ifc, \ + .data_epin = data_ein, \ + .data_epout = data_eout, \ + .protocol = cdc_protocol, \ + .p_ep_interval = ep_list \ + } + +/** + * @brief Specific class data for cdc_acm class. + * + * @ref app_usbd_cdc_acm_ctx_t + */ +#define APP_USBD_CDC_ACM_DATA_SPECIFIC_DEC app_usbd_cdc_acm_ctx_t ctx; + + +/** + * @brief CDC ACM class descriptors config macro. + * + * @param interface_number Interface number. + * @param ... Extracted endpoint list. + */ +#define APP_USBD_CDC_ACM_DSC_CONFIG(interface_number, ...) { \ + APP_USBD_CDC_ACM_INTERFACE_DSC(interface_number, \ + 0, \ + 0, \ + APP_USBD_CDC_ACM_SUBCLASS_CDC_ACMCONTROL) \ +} + +/** + * @brief Public cdc_acm class interface. + * + */ +extern const app_usbd_class_methods_t app_usbd_cdc_acm_class_methods; + +/** + * @brief Global definition of @ref app_usbd_cdc_acm_t class. + * + * @param instance_name Name of global instance. + * @param user_ev_handler User event handler. + * @param comm_ifc Interface number of cdc_acm control. + * @param data_ifc Interface number of cdc_acm DATA. + * @param comm_ein COMM subclass IN endpoint. + * @param data_ein DATA subclass IN endpoint. + * @param data_eout DATA subclass OUT endpoint. + * @param cdc_protocol CDC protocol @ref app_usbd_cdc_comm_protocol_t + */ +/*lint -save -emacro(26 64 123 505 572 651, APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL)*/ +#define APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL(instance_name, \ + user_ev_handler, \ + comm_ifc, \ + data_ifc, \ + comm_ein, \ + data_ein, \ + data_eout, \ + cdc_protocol) \ + static uint8_t CONCAT_2(instance_name, _ep) = { \ + (APP_USBD_EXTRACT_INTERVAL_FLAG(comm_ein) ? APP_USBD_EXTRACT_INTERVAL_VALUE(comm_ein) \ + : APP_USBD_CDC_ACM_DEFAULT_INTERVAL)}; \ + APP_USBD_CLASS_INST_GLOBAL_DEF( \ + instance_name, \ + app_usbd_cdc_acm, \ + &app_usbd_cdc_acm_class_methods, \ + APP_USBD_CDC_ACM_CONFIG(comm_ifc, comm_ein, data_ifc, data_ein, data_eout), \ + (APP_USBD_CDC_ACM_INST_CONFIG(user_ev_handler, \ + comm_ifc, \ + comm_ein, \ + data_ifc, \ + data_ein, \ + data_eout, \ + cdc_protocol, \ + &CONCAT_2(instance_name, _ep))) \ + ) +/*lint -restore*/ + +/** @} */ + + + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_CDC_ACM_INTERNAL_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h index 597c83d..c6c8375 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/app_usbd_cdc_desc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_CDC_DESC_H__ #define APP_USBD_CDC_DESC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h index 2b95821..e880d82 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/cdc/app_usbd_cdc_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_CDC_TYPES_H__ #define APP_USBD_CDC_TYPES_H__ @@ -148,7 +148,7 @@ typedef enum { } app_usbd_cdc_func_type_t; /** - * @brief CDC Functional Descriptor subtypes + * @brief CDC Functional Descriptor subtypes. */ typedef enum { APP_USBD_CDC_SCS_HEADER = 0x00, /**< Header Functional Descriptor, which marks the beginning of the concatenated set of functional descriptors for the interface. */ @@ -184,7 +184,7 @@ typedef enum { #pragma pack(push, 1) /** - * @brief Header Functional Descriptor + * @brief Header Functional Descriptor. */ typedef struct { uint8_t bFunctionLength; //!< Size of this descriptor in bytes. @@ -196,7 +196,7 @@ typedef struct { /** * @brief Call management capabilities. * - * @ref app_usbd_cdc_desc_call_mgmt_t::bmCapabilities bit + * @ref app_usbd_cdc_desc_call_mgmt_t::bmCapabilities bit. * */ typedef enum { APP_USBD_CDC_CALL_MGMT_SUPPORTED = (1 << 0), /**< Call management capability bit 0.*/ @@ -217,7 +217,7 @@ typedef struct { /** * @brief ACM capabilities. * - * @ref app_usbd_cdc_desc_acm_t::bmCapabilities bit + * @ref app_usbd_cdc_desc_acm_t::bmCapabilities bit. * */ typedef enum { APP_USBD_CDC_ACM_FEATURE_REQUESTS = (1 << 0), /**< ACM capability bit FEATURE_REQUESTS. */ @@ -313,7 +313,7 @@ typedef enum { * */ typedef struct { uint8_t bmRequestType; //!< Request type. - uint8_t bmRequest; //!< Request ID @ref app_usbd_cdc_req_id_t. + uint8_t bRequest; //!< Request ID @ref app_usbd_cdc_req_id_t. uint16_t wValue; //!< Value field. uint16_t wIndex; //!< Index field. uint16_t wLength; //!< Length of payload following. @@ -342,11 +342,11 @@ typedef enum { * @brief Possible values of @ref app_usbd_cdc_line_coding_t::bParityType. */ typedef enum { - APP_USBD_CDC_LINE_PARITY_NONE = 0, /**< No parity. */ - APP_USBD_CDC_LINE_PARITY_ODD = 1, /**< Odd parity. */ - APP_USBD_CDC_LINE_PARITY_EVEN = 2, /**< Even parity. */ - APP_USBD_CDC_LINE_PARITY_MARK = 3, /**< Parity forced to 0 (space).*/ - APP_USBD_CDC_LINE_PARITY_SPACE = 4, /**< Parity forced to 1 (mark). */ + APP_USBD_CDC_LINE_PARITY_NONE = 0, /**< No parity. */ + APP_USBD_CDC_LINE_PARITY_ODD = 1, /**< Odd parity. */ + APP_USBD_CDC_LINE_PARITY_EVEN = 2, /**< Even parity. */ + APP_USBD_CDC_LINE_PARITY_MARK = 3, /**< Parity forced to 0 (mark). */ + APP_USBD_CDC_LINE_PARITY_SPACE = 4, /**< Parity forced to 1 (space). */ } app_usbd_cdc_line_parity_t; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.c new file mode 100644 index 0000000..66f98e7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.c @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2017 - 2019, 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(APP_USBD_DUMMY) + +#include +#include +#include "app_usbd.h" +#include "app_usbd_dummy.h" +#include "app_usbd_string_desc.h" +#include "nrf_gpio.h" + +/** + * @defgroup app_usbd_dummy_internal USBD Dummy internals + * @{ + * @ingroup app_usbd_dummy + * @internal + */ + +#define NRF_LOG_MODULE_NAME usbd_dummy + +#if APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#else //APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/** @brief @ref app_usbd_class_methods_t::event_handler */ +static ret_code_t dummy_class_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + if((p_event->app_evt.type == APP_USBD_EVT_INST_APPEND) || + (p_event->app_evt.type == APP_USBD_EVT_INST_REMOVE)) + { + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } +} + +/** @brief @ref app_usbd_class_methods_t::feed_descriptors */ +static bool dummy_class_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static app_usbd_class_iface_conf_t const * p_cur_iface = 0; + p_cur_iface = app_usbd_class_iface_get(p_inst, 0); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size) + + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(sizeof(app_usbd_descriptor_iface_t)); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(0); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DUMMY_CLASS); // bInterfaceClass + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DUMMY_SUBCLASS); // bInterfaceSubClass + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DUMMY_PROTOCOL); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + +const app_usbd_class_methods_t app_usbd_dummy_class_methods = { + .event_handler = dummy_class_event_handler, + .feed_descriptors = dummy_class_feed_descriptors, +}; + + +#endif //NRF_MODULE_ENABLED(APP_USBD_DUMMY) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.h new file mode 100644 index 0000000..ee85eaf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy.h @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2017 - 2019, 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 APP_USBD_DUMMY_H__ +#define APP_USBD_DUMMY_H__ + +#include +#include + +#include "nrf_drv_usbd.h" +#include "nrf_block_dev.h" +#include "app_usbd_class_base.h" +#include "app_usbd.h" +#include "app_usbd_core.h" +#include "app_usbd_descriptor.h" + +#include "app_usbd_dummy_types.h" +#include "app_usbd_dummy_internal.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_dummy USB Dummy class + * @ingroup app_usbd + * + * @brief @tagAPI52840 Module with types, definitions, + * and API used by the USB Dummy class. + * + * @note Class is used as a filler to provide correct alignement of interfaces. + * + * @{ + */ + +#ifdef DOXYGEN +/** + * @brief Dummy class instance type. + * + * @ref APP_USBD_CLASS_TYPEDEF + */ +typedef struct { } app_usbd_dummy_t; +#else +/*lint -save -e10 -e26 -e123 -e505 */ +APP_USBD_CLASS_NO_EP_TYPEDEF(app_usbd_dummy, \ + APP_USBD_DUMMY_CONFIG(0), \ + APP_USBD_DUMMY_INSTANCE_SPECIFIC_DEC, \ + APP_USBD_DUMMY_DATA_SPECIFIC_DEC \ +); +#endif + +/*lint -restore*/ + +/** + * @brief Global definition of app_usbd_dummy_t class. + * + * @param instance_name Name of global instance. + * @param interface_number Unique interface number. + * + * @note This macro is just simplified version of @ref APP_USBD_DUMMY_GLOBAL_DEF_INTERNAL + * + */ +/*lint -save -emacro(26 64 123 505 651, APP_USBD_DUMMY_GLOBAL_DEF)*/ +#define APP_USBD_DUMMY_GLOBAL_DEF(instance_name, interface_number) \ + APP_USBD_DUMMY_GLOBAL_DEF_INTERNAL(instance_name, interface_number) +/*lint -restore*/ + +/** + * @@brief Helper function to get class instance from dummy. + * + * @param[in] p_dummy Dummy instance + * (declared by @ref APP_USBD_DUMMY_GLOBAL_DEF). + * + * @return Base class instance. + */ +static inline app_usbd_class_inst_t const * +app_usbd_dummy_class_inst_get(app_usbd_dummy_t const * p_dummy) +{ + return &p_dummy->base; +} + +/** + * @brief Helper function to get dummy from base class instance. + * + * @param[in] p_inst Base class instance. + * + * @return Dummy class handle. + */ +static inline app_usbd_dummy_t const * +app_usbd_dummy_class_get( app_usbd_class_inst_t const * p_inst) +{ + return (app_usbd_dummy_t const *)p_inst; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_DUMMY_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_internal.h new file mode 100644 index 0000000..acef3de --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_internal.h @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2017 - 2019, 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 APP_USBD_DUMMY_INTERNAL_H__ +#define APP_USBD_DUMMY_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_dummy_internals USB Dummy internals + * @ingroup app_usbd_dummy + * + * @brief @tagAPI52840 Internals of the USB Dummy class. + * @{ + */ + +/** @brief Forward declaration of Dummy Class type */ +APP_USBD_CLASS_FORWARD(app_usbd_dummy); + +/** @brief Dummy part of class instance data */ +typedef struct { + uint8_t none; +} app_usbd_dummy_inst_t; + +/** @brief Dummy context */ +typedef struct { + uint8_t none; +} app_usbd_dummy_ctx_t; + + +/** + * @brief Dummy configuration macro. + * + * Used by @ref APP_USBD_DUMMY_GLOBAL_DEF + * + * @param iface Interface number. + * */ +#define APP_USBD_DUMMY_CONFIG(iface) (iface) + + +/** + * @brief Specific class constant data for Dummy. + * + * @ref app_usbd_dummy_inst_t + */ +#define APP_USBD_DUMMY_INSTANCE_SPECIFIC_DEC app_usbd_dummy_inst_t inst; + +/** + * @brief Specific class data for Dummy. + * + * @ref app_usbd_dummy_ctx_t + * */ +#define APP_USBD_DUMMY_DATA_SPECIFIC_DEC app_usbd_dummy_ctx_t ctx; + + +/** @brief Public Dummy class interface */ +extern const app_usbd_class_methods_t app_usbd_dummy_class_methods; + +/** @brief Global definition of Dummy instance */ +#define APP_USBD_DUMMY_GLOBAL_DEF_INTERNAL(instance_name, interface_number) \ + APP_USBD_CLASS_INST_NO_EP_GLOBAL_DEF( \ + instance_name, \ + app_usbd_dummy, \ + &app_usbd_dummy_class_methods, \ + APP_USBD_DUMMY_CONFIG((interface_number)), \ + () \ + ) + + +/** @} */ + + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_DUMMY_INTERNAL_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_types.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_types.h index 8bba379..427583a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_rng.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/dummy/app_usbd_dummy_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,37 +35,41 @@ * 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 NRF_CRYPTO_SW_RNG_H__ -#define NRF_CRYPTO_SW_RNG_H__ - -/** @file - * - * @defgroup nrf_crypto_sw_rng Random Number Generation using nrf_drv_rng - * @{ - * @ingroup nrf_crypto_backend_microecc * - * @brief Macros for type sizes for RNG in nrf_crypto backend. */ +#ifndef APP_USBD_DUMMY_TYPES_H__ +#define APP_USBD_DUMMY_TYPES_H__ + +#include "app_util.h" #ifdef __cplusplus extern "C" { #endif -/** @brief Size of buffer required for initializing RNG. +/** + * @defgroup app_usbd_dummy_types USB Dummy types + * @ingroup app_usbd_dummy + * + * @brief @tagAPI52840 Types used in the USB Dummy class. + * @{ */ -#define NRF_CRYPTO_RNG_INIT_SIZE (0) -/** @brief Size of buffer required for RNG context object. - */ -#define NRF_CRYPTO_RNG_CONTEXT_SIZE (0) +/** @brief Dummy class definition in interface descriptor. + * + * @ref app_usbd_descriptor_iface_t::bInterfaceClass + * */ +#define APP_USBD_DUMMY_CLASS 0xFF +/** @brief Dummy subclass value. */ +#define APP_USBD_DUMMY_SUBCLASS 0x00 + +/** @brief Dummy protocol value. */ +#define APP_USBD_DUMMY_PROTOCOL 0x00 + +/** @} */ #ifdef __cplusplus } #endif -/** @} */ - -#endif // #ifndef NRF_CRYPTO_SW_RNG_H__ +#endif /* APP_USBD_DUMMY_TYPES_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid.c similarity index 56% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid.c index e66dc6e..ff9647d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,14 +35,17 @@ * 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_config.h" -#if APP_USBD_CLASS_HID_ENABLED +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(APP_USBD_HID) + #include "app_usbd.h" #include "app_usbd_core.h" #include "app_usbd_hid.h" +#include "nrf_log.h" + /** * @ingroup app_usbd_hid_internals USBD HID internals * @{ @@ -50,49 +53,68 @@ * @internal */ +#define APP_USBD_HID_SOF_NOT_REQ_FLAG 0xFFFF + /** * @brief Test whether SOF HID transfer is required. * * This function handles idle period IN transfer. * - * @param[in,out] p_hid_ctx Internal HID context. - * @param framecnt SOF event frame counter. + * @param[in,out] p_hid_ctx Internal HID context. + * @param[in] framecnt SOF event frame counter. * - * @retval true Idle transfer is required. - * @retval false Idle transfer is not required. + * @retval report_id If transfer with ID required + * @retval APP_USBD_HID_SOF_NOT_REQ_FLAG If no transfer required */ -static bool hid_sof_required(app_usbd_hid_ctx_t * p_hid_ctx, uint16_t framecnt) +static uint16_t hid_sof_required(app_usbd_hid_ctx_t * p_hid_ctx, uint16_t framecnt) { - if (p_hid_ctx->idle_rate == 0) + if (!p_hid_ctx->idle_on) { /* Infinite idle rate */ - return false; + return APP_USBD_HID_SOF_NOT_REQ_FLAG; } - /*Idle rate has 4ms units. Every SOF event is generated with 1ms period.*/ - uint16_t rate_ms = p_hid_ctx->idle_rate * 4; - if ((framecnt % rate_ms) != 0) + uint8_t i = 0; + uint16_t rate_ms[APP_USBD_HID_REPORT_IDLE_TABLE_SIZE] = {0}; + + for(i = 0; i < APP_USBD_HID_REPORT_IDLE_TABLE_SIZE; i++) { - /* Idle transfer not required yet*/ - return false; - } + rate_ms[i] = p_hid_ctx->idle_rate[i] * 4; + + if((framecnt == APP_USBD_SOF_MAX) && (p_hid_ctx->first_idle[i] != (APP_USBD_SOF_MAX + 1))) + { + /* SOF has only 2047 frame count maximum - adjust m_first_idle */ + p_hid_ctx->first_idle[i] = ((p_hid_ctx->first_idle[i] + APP_USBD_SOF_MAX) % rate_ms[i]) + 1; + } + + if (p_hid_ctx->access_lock) + { + /* Access to internal data locked. Buffer is BUSY. + * Don't send anything. Clear transfer flag. Next transfer will be triggered + * from API context.*/ + app_usbd_hid_state_flag_clr(p_hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + return APP_USBD_HID_SOF_NOT_REQ_FLAG; + } - if (p_hid_ctx->access_lock) - { - /* Access to internal data locked. Buffer is BUSY. - * Don't send anything. Clear transfer flag. Next transfer will be triggered - * from API context.*/ - app_usbd_hid_state_flag_clr(p_hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); - return false; + /* Idle transfer required if SOF is correct with an accuracy of +/-10% + 2ms*/ + if (((framecnt + p_hid_ctx->first_idle[i]) % rate_ms[i]) < (2 + (rate_ms[i] / 10))) + { + return i; + } + + /* Only 0 id has set idle rate. No need to check whole table. */ + if(!p_hid_ctx->idle_id_report) + { + return APP_USBD_HID_SOF_NOT_REQ_FLAG; + } } - if (app_usbd_hid_trans_required(p_hid_ctx)) - { - /*New transfer need to be triggered*/ - return true; - } + return APP_USBD_HID_SOF_NOT_REQ_FLAG; +} - return false; +static bool hid_idle_on(app_usbd_class_inst_t const * p_inst, app_usbd_hid_ctx_t * p_hid_ctx) +{ + return p_hid_ctx->idle_on; } /** @@ -115,10 +137,10 @@ static inline void user_event_handler(app_usbd_class_inst_t const * p_inst, /** * @brief Internal SETUP standard IN request handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -130,37 +152,37 @@ static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, /* Only Get Descriptor standard IN request is supported by HID class */ if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) && - (p_setup_ev->setup.bmRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) { size_t dsc_len = 0; + size_t max_size; + + uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); /* Try to find descriptor in class internals*/ - void const * p_dsc = app_usbd_class_descriptor_find( + ret_code_t ret = app_usbd_class_descriptor_find( p_inst, p_setup_ev->setup.wValue.hb, p_setup_ev->setup.wValue.lb, + p_trans_buff, &dsc_len); - if (p_dsc != NULL) + + if (ret != NRF_ERROR_NOT_FOUND) { - return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_dsc, dsc_len); + ASSERT(dsc_len < NRF_DRV_USBD_EPSIZE); + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_trans_buff, dsc_len); } + /* HID specific descriptors*/ - switch (p_setup_ev->setup.wValue.hb) - { - case APP_USBD_HID_DESCRIPTOR_REPORT: - { - return app_usbd_core_setup_rsp( - &p_setup_ev->setup, - p_hinst->p_report_dsc, - p_hinst->report_dsc_size); - } - case APP_USBD_HID_DESCRIPTOR_PHYSICAL: - /*Not supported*/ - break; - default: - /*Not supported*/ - break; - } + uint32_t report_size = + p_hinst->p_hid_methods->subclass_length(p_inst, p_setup_ev->setup.wValue.lb); + const uint8_t * p_first_byte = + p_hinst->p_hid_methods->subclass_data(p_inst, p_setup_ev->setup.wValue.lb, 0); + + return app_usbd_core_setup_rsp( + &p_setup_ev->setup, + p_first_byte, + report_size); } return NRF_ERROR_NOT_SUPPORTED; @@ -169,10 +191,10 @@ static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, /** * @brief Internal SETUP standard OUT request handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -189,10 +211,10 @@ static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, /** * @brief Internal SETUP class IN request handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -201,29 +223,32 @@ static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, app_usbd_hid_ctx_t * p_hid_ctx, app_usbd_setup_evt_t const * p_setup_ev) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_HID_REQ_GET_REPORT: { - /*Only input report is supported. Same format as over IN pipe.*/ - if (p_setup_ev->setup.wValue.hb != APP_USBD_HID_REPORT_TYPE_INPUT) + if ((p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_INPUT) || + (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_OUTPUT) || + (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_FEATURE)) + { + return p_hinst->p_hid_methods->on_get_report(p_inst, p_setup_ev); + } + else { break; } - - return p_hinst->p_hid_methods->on_get_report(p_inst, p_setup_ev); } case APP_USBD_HID_REQ_GET_IDLE: { return app_usbd_core_setup_rsp(&p_setup_ev->setup, - &p_hid_ctx->idle_rate, - sizeof(p_hid_ctx->idle_rate)); + &p_hid_ctx->idle_rate[p_setup_ev->setup.wValue.lb], + sizeof(p_hid_ctx->idle_rate[p_setup_ev->setup.wValue.lb])); } case APP_USBD_HID_REQ_GET_PROTOCOL: { return app_usbd_core_setup_rsp(&p_setup_ev->setup, - &p_hid_ctx->protocol, - sizeof(p_hid_ctx->protocol)); + &p_hid_ctx->selected_protocol, + sizeof(p_hid_ctx->selected_protocol)); } default: break; @@ -236,10 +261,10 @@ static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, /** * @brief Internal SETUP class OUT request handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -248,30 +273,82 @@ static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, app_usbd_hid_ctx_t * p_hid_ctx, app_usbd_setup_evt_t const * p_setup_ev) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_HID_REQ_SET_REPORT: - if (p_setup_ev->setup.wValue.hb != APP_USBD_HID_REPORT_TYPE_OUTPUT) - { - break; - } - - if (p_hinst->p_hid_methods->on_get_report == NULL) + if (((p_setup_ev->setup.wValue.hb != APP_USBD_HID_REPORT_TYPE_OUTPUT) && + (p_setup_ev->setup.wValue.hb != APP_USBD_HID_REPORT_TYPE_FEATURE)) || + p_hinst->p_hid_methods->on_set_report == NULL) { break; } return p_hinst->p_hid_methods->on_set_report(p_inst, p_setup_ev); case APP_USBD_HID_REQ_SET_IDLE: - p_hid_ctx->idle_rate = p_setup_ev->setup.wValue.hb; - return NRF_SUCCESS; + { + p_hid_ctx->idle_rate[p_setup_ev->setup.wValue.lb] = p_setup_ev->setup.wValue.hb; + p_hid_ctx->first_idle[p_setup_ev->setup.wValue.lb] = APP_USBD_SOF_MAX + 1; + + /* Clear idle */ + if(p_setup_ev->setup.wValue.hb == 0) + { + /* If only idle rate with id 0 is non 0 set idle_id_report to false */ + bool clear = true; + uint8_t i = 0; + for(i=1; i < APP_USBD_HID_REPORT_IDLE_TABLE_SIZE; i++) + { + if(p_hid_ctx->idle_rate[i] != 0) + { + clear = false; + break; + } + } + + if(clear) + { + p_hid_ctx->idle_id_report = false; + + if(p_hid_ctx->idle_rate[0] == 0) + { + /* If all are 0 set m_idle_on to false */ + p_hid_ctx->idle_on = false; + } + } + } + /* Set idle */ + else + { + /* If any idle rate is not 0 set m_idle_on to true */ + p_hid_ctx->idle_on = true; + + /* If any idle rate with id != 0 is non 0 set idle_id_report to true */ + if(p_setup_ev->setup.wValue.lb != 0) + { + p_hid_ctx->idle_id_report = true; + } + } + + return NRF_SUCCESS; + } case APP_USBD_HID_REQ_SET_PROTOCOL: - p_hid_ctx->protocol = p_setup_ev->setup.wValue.w; { - app_usbd_hid_user_event_t ev = (p_hid_ctx->protocol == 0) ? + app_usbd_hid_user_event_t ev = (p_setup_ev->setup.wValue.w == APP_USBD_HID_PROTO_BOOT) ? APP_USBD_HID_USER_EVT_SET_BOOT_PROTO : APP_USBD_HID_USER_EVT_SET_REPORT_PROTO; + if (ev == APP_USBD_HID_USER_EVT_SET_BOOT_PROTO) + { + p_hid_ctx->selected_protocol = APP_USBD_HID_PROTO_BOOT; + } + else if (ev == APP_USBD_HID_USER_EVT_SET_REPORT_PROTO) + { + p_hid_ctx->selected_protocol = APP_USBD_HID_PROTO_REPORT; + } + else + { + return NRF_ERROR_INVALID_PARAM; + } + user_event_handler(p_inst, p_hinst, ev); } return NRF_SUCCESS; @@ -285,10 +362,10 @@ static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, /** * @brief Internal SETUP event handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -332,10 +409,10 @@ static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst, /** * @brief Endpoint IN event handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -355,21 +432,42 @@ static ret_code_t endpoint_in_event_handler(app_usbd_class_inst_t const * p_inst { /* Access to internal data locked. Buffer is BUSY. * Don't send anything. Clear transfer flag. Next transfer will be triggered - * from main loop context.*/ + * from main loop context. */ app_usbd_hid_state_flag_clr(p_hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); return NRF_SUCCESS; } - return p_hinst->p_hid_methods->ep_transfer_in(p_inst); + if (!hid_idle_on(p_inst, p_hid_ctx)) + { + return p_hinst->p_hid_methods->ep_transfer_in(p_inst); + } + else + { + uint8_t i = 0; + for(i=0; i < APP_USBD_HID_REPORT_IDLE_TABLE_SIZE; i++) + { + if (p_hid_ctx->first_idle[i] == (APP_USBD_SOF_MAX + 1)) + { + p_hid_ctx->lock_idle[i] = true; + } + + /* Only 0 id has set idle rate. No need to check whole table. */ + if(!p_hid_ctx->idle_id_report) + { + break; + } + } + return NRF_SUCCESS; + } } /** * @brief Endpoint OUT event handler. * - * @param[in] p_inst Generic class instance. - * @param[in] p_hinst HID class instance. - * @param[in,out] p_hid_ctx HID context. - * @param[in] p_setup_ev Setup event. + * @param[in] p_inst Generic class instance. + * @param[in] p_hinst HID class instance. + * @param[in,out] p_hid_ctx HID context. + * @param[in] p_setup_ev Setup event. * * @return Standard error code. */ @@ -389,9 +487,23 @@ static ret_code_t endpoint_out_event_handler(app_usbd_class_inst_t const * p_ins user_event_handler(p_inst, p_hinst, APP_USBD_HID_USER_EVT_OUT_REPORT_READY); } + ASSERT(p_hinst->p_rep_buffer_out->size <= NRF_DRV_USBD_EPSIZE); return p_hinst->p_hid_methods->ep_transfer_out(p_inst); } + +static void app_usbd_clear_idle_ctx(app_usbd_hid_ctx_t * p_hid_ctx) +{ + uint8_t i = 0; + for(i=0; i < APP_USBD_HID_REPORT_IDLE_TABLE_SIZE; i++) + { + p_hid_ctx->idle_rate[i] = APP_USBD_HID_DEFAULT_IDLE_RATE; + p_hid_ctx->first_idle[i] = APP_USBD_SOF_MAX + 1; + } + p_hid_ctx->idle_id_report = false; + p_hid_ctx->idle_on = false; +} + /** @} */ @@ -404,15 +516,35 @@ ret_code_t app_usbd_hid_event_handler(app_usbd_class_inst_t const * p_inst, switch (p_event->app_evt.type) { case APP_USBD_EVT_DRV_SOF: - if (!hid_sof_required(p_hid_ctx, p_event->drv_evt.data.sof.framecnt)) + { + uint16_t sof_req = hid_sof_required(p_hid_ctx, p_event->drv_evt.data.sof.framecnt); + if (sof_req != APP_USBD_HID_SOF_NOT_REQ_FLAG) { - break; + uint8_t i = 0; + for(i=0; i < APP_USBD_HID_REPORT_IDLE_TABLE_SIZE; i++) + { + if(p_hid_ctx->lock_idle[i]) + { + p_hid_ctx->first_idle[i] = p_event->drv_evt.data.sof.framecnt; + p_hid_ctx->lock_idle[i] = false; + } + /* Only 0 id has set idle rate. No need to check whole table. */ + if(!p_hid_ctx->idle_id_report) + { + break; + } + } + ret = p_hinst->p_hid_methods->on_idle(p_inst, sof_req); } - ret = p_hinst->p_hid_methods->ep_transfer_in(p_inst); break; + } case APP_USBD_EVT_DRV_RESET: + { app_usbd_hid_state_flag_clr(p_hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + p_hid_ctx->selected_protocol = APP_USBD_HID_PROTO_REPORT; + app_usbd_clear_idle_ctx(p_hid_ctx); break; + } case APP_USBD_EVT_DRV_SETUP: ret = setup_event_handler(p_inst, p_hinst, p_hid_ctx, &p_event->setup_evt); break; @@ -447,6 +579,7 @@ ret_code_t app_usbd_hid_event_handler(app_usbd_class_inst_t const * p_inst, { break; } + app_usbd_clear_idle_ctx(p_hid_ctx); app_usbd_hid_state_flag_set(p_hid_ctx, APP_USBD_HID_STATE_FLAG_APPENDED); break; case APP_USBD_EVT_INST_REMOVE: @@ -483,5 +616,10 @@ app_usbd_hid_report_buffer_t * app_usbd_hid_rep_buff_in_get(app_usbd_hid_inst_t return p_hinst->p_rep_buffer_in; } +app_usbd_hid_report_buffer_t const * app_usbd_hid_rep_buff_feature_get(app_usbd_hid_inst_t const * p_hinst) +{ + ASSERT(p_hinst); + return p_hinst->p_rep_buffer_feature; +} -#endif // APP_USBD_CLASS_HID_ENABLED +#endif //NRF_MODULE_ENABLED(APP_USBD_HID) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid.h similarity index 60% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid.h index c2f896b..87b8c67 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_H__ #define APP_USBD_HID_H__ @@ -60,9 +60,9 @@ extern "C" { * @{ */ -#define APP_USBD_HID_IFACE_IDX 0 /**< HID instance interface index. */ -#define APP_USBD_HID_EPIN_IDX 0 /**< HID instance endpoint IN index. */ -#define APP_USBD_HID_EPOUT_IDX 1 /**< HID instance endpoint OUT index.*/ +#define APP_USBD_HID_IFACE_IDX 0 /**< @brief HID instance interface index. */ +#define APP_USBD_HID_EPIN_IDX 0 /**< @brief HID instance endpoint IN index. */ +#define APP_USBD_HID_EPOUT_IDX 1 /**< @brief HID instance endpoint OUT index.*/ /** * @brief HID context state flags. @@ -76,23 +76,24 @@ typedef enum { APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS = 3, /**< State flag TRANS_IN_PROGRESS. */ } app_usbd_hid_state_flag_t; - /** * @brief Events passed to user event handler. * * @note Example prototype of user event handler: @code - void hid_user_ev_handler(app_usbd_class_inst_t const * p_inst, + void hid_user_ev_handler(app_usbd_class_inst_t const * p_inst, app_usbd_hid_mouse_user_event_t event); @endcode */ typedef enum { - APP_USBD_HID_USER_EVT_SET_BOOT_PROTO, /**< Event SET_BOOT_PROTOCOL. */ - APP_USBD_HID_USER_EVT_SET_REPORT_PROTO, /**< Event SET_REPORT_PROTOCOL.*/ - APP_USBD_HID_USER_EVT_OUT_REPORT_READY, /**< Event OUT_REPORT_READY. */ - APP_USBD_HID_USER_EVT_IN_REPORT_DONE, /**< Event IN_REPORT_DONE. */ + APP_USBD_HID_USER_EVT_SET_BOOT_PROTO, /**< Event SET_BOOT_PROTOCOL. */ + APP_USBD_HID_USER_EVT_SET_REPORT_PROTO, /**< Event SET_REPORT_PROTOCOL. */ + APP_USBD_HID_USER_EVT_OUT_REPORT_READY, /**< Event OUT_REPORT_READY. */ + APP_USBD_HID_USER_EVT_IN_REPORT_DONE, /**< Event IN_REPORT_DONE. */ + APP_USBD_HID_USER_EVT_FEATURE_REPORT_READY, /**< Event FEATURE_REPORT_READY. */ } app_usbd_hid_user_event_t; + /** * @brief User event handler. * @@ -102,7 +103,18 @@ typedef enum { typedef void (*app_usbd_hid_user_ev_handler_t)(app_usbd_class_inst_t const * p_inst, app_usbd_hid_user_event_t event); -/**@brief HID unified interface*/ +/** + * @brief Idle report handler. + * + * @param[in] p_inst Class instance. + * @param[in] report_id Number of report ID that needs idle transfer. + */ +typedef ret_code_t (*app_usbd_hid_idle_handler_t)(app_usbd_class_inst_t const * p_inst, + uint8_t report_id); + +/** + * @brief HID unified interface + * */ typedef struct { /** @@ -154,6 +166,45 @@ typedef struct { * @return Standard error code. */ ret_code_t (*ep_transfer_out)(app_usbd_class_inst_t const * p_inst); + + /** + * @brief Function returns subclass descriptor size. + * + * @param[in] p_inst Class instance. + * @param[in] desc_num Index of the subclass descriptor + * + * @return Size of descriptor + */ + size_t (*subclass_length)(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num); + + /** + * @brief Function returns pointer to subclass descriptor data. + * + * @param[in] p_inst Class instance. + * @param[in] desc_num Index of the subclass descriptor + * @param[in] cur_byte Index of required byte + * + * @return Pointer to requested byte in subclass descriptor + */ + const uint8_t * (*subclass_data)(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num, + uint32_t cur_byte); + + /** + * @brief Function called on idle transfer + * + * This function should trigger next idle transfer. + * + * @param[in,out] p_inst Instance of the class. + * @param[in] report_id Number of report ID that needs idle transfer. + * + * @return Standard error code. + */ + ret_code_t (*on_idle)(app_usbd_class_inst_t const * p_inst, uint8_t report_id); + + ret_code_t (*set_idle_handler)(app_usbd_class_inst_t const * p_inst, + app_usbd_hid_idle_handler_t handler); } app_usbd_hid_methods_t; /** @@ -166,7 +217,8 @@ typedef struct { -/**@brief Define OUT report buffer structure @ref app_usbd_hid_report_buffer_t. +/** + * @brief Define OUT report buffer structure @ref app_usbd_hid_report_buffer_t. * * @param name Instance name. * @param rep_size Output report size. @@ -178,58 +230,135 @@ typedef struct { .size = sizeof(CONCAT_2(name, _buf)), \ } +/** + * @brief Define FEATURE report buffer structure @ref app_usbd_hid_report_buffer_t. + * + * @param name Instance name. + * @param rep_size Feature report size. + */ +#define APP_USBD_HID_GENERIC_GLOBAL_FEATURE_REP_DEF(name, rep_size) \ + static uint8_t CONCAT_2(name, _feature_buf)[(rep_size)]; \ + const app_usbd_hid_report_buffer_t name = { \ + .p_buff = CONCAT_2(name, _feature_buf), \ + .size = sizeof(CONCAT_2(name, _feature_buf)), \ + } + + +/** + * @brief HID subclass descriptor. + */ + +typedef struct { + size_t size; + app_usbd_descriptor_t type; + uint8_t const * const p_data; +} app_usbd_hid_subclass_desc_t; + +/** + * @brief Initializer of HID report descriptor + * + * @param name Report descriptor name + * @param ... Report descriptor data + */ + +#define APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(name, ...) \ + static uint8_t const CONCAT_2(name, _data)[] = \ + __VA_ARGS__ \ + ; \ + static const app_usbd_hid_subclass_desc_t name = \ + { \ + sizeof(CONCAT_2(name, _data)), \ + APP_USBD_DESCRIPTOR_REPORT, \ + CONCAT_2(name,_data) \ + } + +/** + * @brief Initializer of HID physical descriptor + * + * @param name Physical descriptor name + * @param ... Physical descriptor data + */ + +#define APP_USBD_HID_GENERIC_SUBCLASS_PHYSICAL_DESC(name, ...) \ + static uint8_t const CONCAT_2(name, _data)[] = \ + __VA_ARGS__ \ + ; \ + static const app_usbd_hid_subclass_desc_t name = \ + { \ + sizeof(CONCAT_2(name, _data)), \ + APP_USBD_DESCRIPTOR_PHYSICAL, \ + CONCAT_2(name,_data) \ + } + /** * @brief USB HID instance. */ typedef struct { - uint8_t const * p_raw_desc; //!< HID class descriptors, raw array. - size_t raw_desc_size; //!< HID class descriptors size, raw array size. - uint8_t const * p_report_dsc; //!< Report descriptor, raw array. - size_t report_dsc_size; //!< Report descriptor, raw array size. + app_usbd_hid_subclass_desc_t const ** const p_subclass_desc; //!< HID subclass descriptors array. + size_t subclass_desc_count; //!< HID subclass descriptors count. - app_usbd_hid_report_buffer_t * p_rep_buffer_in; //!< Report buffer IN. + app_usbd_hid_subclass_t subclass_boot; //!< Boot device (see HID definition). + app_usbd_hid_protocol_t protocol; //!< HID protocol (see HID definition). + + app_usbd_hid_report_buffer_t * p_rep_buffer_in; //!< Report buffer IN. app_usbd_hid_report_buffer_t const * p_rep_buffer_out; //!< Report buffer OUT (only one instance). - app_usbd_hid_methods_t const * p_hid_methods; //!< Hid interface methods. + app_usbd_hid_report_buffer_t const * p_rep_buffer_feature; //!< Report buffer FEATURE. + app_usbd_hid_methods_t const * p_hid_methods; //!< Hid interface methods. app_usbd_hid_user_ev_handler_t user_event_handler; //!< User event handler. -} app_usbd_hid_inst_t; + uint8_t * p_ep_interval; //!< Endpoint intervals. +} app_usbd_hid_inst_t; /** * @brief USB HID instance initializer @ref app_usbd_hid_inst_t. * - * @param descriptors Interface, hid, endpoint packed descriptor structure. - * @param report_dsc Report descriptor (raw uint8_t array). - * @param report_buff_in Input report buffer list. - * @param report_buff_out Output report buffer. - * @param user_ev_handler @ref app_usbd_hid_user_ev_handler_t. - @param hid_methods @ref app_usbd_hid_methods_t. + * @param subclass_dsc HID subclass descriptors. + * @param sub_boot Subclass boot. (@ref app_usbd_hid_subclass_t) + * @param protocl HID protocol. (@ref app_usbd_hid_protocol_t) + * @param report_buff_in Input report buffer list. + * @param report_buff_out Output report buffer. + * @param report_buff_feature Feature report buffer. + * @param user_ev_handler @ref app_usbd_hid_user_ev_handler_t. + * @param hid_methods @ref app_usbd_hid_methods_t. + * @param ep_list List of endpoints and intervals * */ -#define APP_USBD_HID_INST_CONFIG(descriptors, \ - report_dsc, \ + +#define APP_USBD_HID_INST_CONFIG(subclass_dsc, \ + sub_boot, \ + protocl, \ report_buff_in, \ report_buff_out, \ + report_buff_feature, \ user_ev_handler, \ - hid_methods) \ + hid_methods, \ + ep_list) \ { \ - .p_raw_desc = descriptors, \ - .raw_desc_size = ARRAY_SIZE(descriptors), \ - .p_report_dsc = report_dsc, \ - .report_dsc_size = ARRAY_SIZE(report_dsc), \ + .p_subclass_desc = subclass_dsc, \ + .subclass_desc_count = ARRAY_SIZE(subclass_dsc), \ .p_rep_buffer_in = report_buff_in, \ .p_rep_buffer_out = report_buff_out, \ + .p_rep_buffer_feature = report_buff_feature, \ .user_event_handler = user_ev_handler, \ .p_hid_methods = hid_methods, \ + .subclass_boot = sub_boot, \ + .protocol = protocl, \ + .p_ep_interval = ep_list \ } /** * @brief HID internal context. * */ typedef struct { - nrf_atomic_u32_t state_flags; //!< HID state flags @ref app_usbd_hid_state_flag_t. - nrf_atomic_flag_t access_lock; //!< Lock flag to internal data. - uint8_t idle_rate; //!< HID idle rate (4ms units). - uint8_t protocol; //!< HID protocol type. + nrf_atomic_u32_t state_flags; //!< HID state flags @ref app_usbd_hid_state_flag_t. + nrf_atomic_flag_t access_lock; //!< Lock flag to internal data. + uint8_t idle_rate[APP_USBD_HID_REPORT_IDLE_TABLE_SIZE]; //!< HID idle rate (4ms units). + app_usbd_hid_protocol_select_t selected_protocol; //!< Currently selected HID protocol. + app_usbd_hid_idle_handler_t idle_handler; //!< Idle report handler. + uint32_t first_idle[APP_USBD_HID_REPORT_IDLE_TABLE_SIZE]; //!< Number of frame at first idle transaction. + bool lock_idle[APP_USBD_HID_REPORT_IDLE_TABLE_SIZE]; //!< Lock flag to idle transactions. + bool idle_on; //!< Idle transactions flag. + bool idle_id_report; //!< Idle transactions with nonzero report id flag. } app_usbd_hid_ctx_t; @@ -402,6 +531,28 @@ app_usbd_hid_rep_buff_out_get(app_usbd_hid_inst_t const * p_hinst) return p_hinst->p_rep_buffer_out; } +/** + * @brief Returns FEATURE report buffer. + * + * @param[in] p_hinst HID class instance. + * + * @return Report buffer handle or NULL if report doesn't exist. + */ +app_usbd_hid_report_buffer_t const * app_usbd_hid_rep_buff_feature_get(app_usbd_hid_inst_t const * p_hinst); + +/** + * @brief Returns HID selected protocol. + * + * @param[in] p_hid_ctx HID context. + * + * @return Currently selected protocol (@ref app_usbd_hid_protocol_select_t). + */ +static inline app_usbd_hid_protocol_select_t app_usbd_hid_selected_protocol_get(app_usbd_hid_ctx_t * p_hid_ctx) +{ + ASSERT(p_hid_ctx); + return p_hid_ctx->selected_protocol; +} + /** * @brief Auxiliary function to access to HID IN endpoint address. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid_types.h similarity index 86% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid_types.h index dedc423..4c61361 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/app_usbd_hid_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/app_usbd_hid_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_TYPES_H__ #define APP_USBD_HID_TYPES_H__ @@ -75,10 +75,27 @@ typedef enum { APP_USBD_HID_SUBCLASS_BOOT = 0x01, /**< Boot subclass. */ } app_usbd_hid_subclass_t; +/** + * @brief HID selected protocol. + * + * These values are used for Get_Protocol and Set_Protocol requests. + * Changing protocol is only allowed when protocol type (@ref app_usbd_hid_protocol_t) + * is set to @ref APP_USBD_HID_PROTO_KEYBOARD or @ref APP_USBD_HID_PROTO_MOUSE + * and interface uses boot subclass (@ref APP_USBD_HID_SUBCLASS_BOOT). + * + * @see HID 1.11 specification: Chapter 7.2.5 Get_Protocol Request + * and Chapter 7.2.6 Set_Protocol Request. + */ +typedef enum { + APP_USBD_HID_PROTO_BOOT = 0x00, /**< Boot protocol. */ + APP_USBD_HID_PROTO_REPORT = 0x01 /**< Report protocol. */ +} app_usbd_hid_protocol_select_t; + + /** * @brief HID protocol types defined by specification. * - * Value need to be filled in interface descriptor. + * Value needs to be filled in interface descriptor. * @ref app_usbd_descriptor_iface_t::bInterfaceProtocol */ typedef enum { @@ -188,33 +205,33 @@ typedef union { * @brief HID requests defined by specification. */ typedef enum { - APP_USBD_HID_REQ_GET_REPORT = 0x01, /**< REPORT: device -> host (required). */ - APP_USBD_HID_REQ_GET_IDLE = 0x02, /**< IDLE: device -> host (not required). */ - APP_USBD_HID_REQ_GET_PROTOCOL = 0x03, /**< PROTOCOL: device -> host (required for boot protocol). */ - APP_USBD_HID_REQ_SET_REPORT = 0x09, /**< REPORT: host -> device (not required). */ - APP_USBD_HID_REQ_SET_IDLE = 0x0A, /**< IDLE: no data stage (required for boot protocol). */ - APP_USBD_HID_REQ_SET_PROTOCOL = 0x0B, /**< PROTOCOL: no data stage(required for boot protocol). */ + APP_USBD_HID_REQ_GET_REPORT = 0x01, /**< REPORT: device -> host (required). */ + APP_USBD_HID_REQ_GET_IDLE = 0x02, /**< IDLE: device -> host (not required). */ + APP_USBD_HID_REQ_GET_PROTOCOL = 0x03, /**< PROTOCOL: device -> host (required for boot protocol). */ + APP_USBD_HID_REQ_SET_REPORT = 0x09, /**< REPORT: host -> device (not required). */ + APP_USBD_HID_REQ_SET_IDLE = 0x0A, /**< IDLE: no data stage (required for boot protocol). */ + APP_USBD_HID_REQ_SET_PROTOCOL = 0x0B, /**< PROTOCOL: no data stage (required for boot protocol). */ } app_usbd_hid_req_t; /** * @brief HID report type. */ typedef enum { - APP_USBD_HID_REPORT_TYPE_INPUT = 0x01,/**< INPUT report type */ - APP_USBD_HID_REPORT_TYPE_OUTPUT = 0x02,/**< OUTPUT report type */ - APP_USBD_HID_REPORT_TYPE_FEATURE = 0x03,/**< FEATURE report type */ + APP_USBD_HID_REPORT_TYPE_INPUT = 0x01, /**< INPUT report type */ + APP_USBD_HID_REPORT_TYPE_OUTPUT = 0x02, /**< OUTPUT report type */ + APP_USBD_HID_REPORT_TYPE_FEATURE = 0x03, /**< FEATURE report type */ } app_usbd_hid_report_type_t; /** - * @brief Hid version BCD value definition + * @brief Hid version BCD value definition. * * The version of the HID descriptors used. */ -#define APP_USBD_HID_BCD_VER APP_USBD_BCD_VER_MAKE(1, 11) +#define APP_USBD_HID_BCD_VER APP_USBD_BCD_VER_MAKE(1, 1, 1) /** - * @brief HID version BCD value definition distributed into bytes + * @brief HID version BCD value definition distributed into bytes. * * This is a value written directly into @ref app_usbd_hid_descriptor_t::bcdHID. * @sa APP_USBD_HID_BCD_VER diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c new file mode 100644 index 0000000..f3bca0a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c @@ -0,0 +1,658 @@ +/** + * Copyright (c) 2016 - 2019, 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(APP_USBD_HID_GENERIC) + +#include +#include "app_usbd_hid_generic.h" +#include "app_util_platform.h" + + +/** + * @ingroup app_usbd_hid_generic + * + * Module with types, definitions and API used by HID generic. + * @{ + */ + +/** + * @brief Auxiliary function to access HID generic context data. + * + * @param[in] p_generic HID generic instance. + * + * @return HID generic class instance data context. + */ +static inline app_usbd_hid_generic_ctx_t * +hid_generic_ctx_get(app_usbd_hid_generic_t const * p_generic) +{ + ASSERT(p_generic != NULL); + ASSERT(p_generic->specific.p_data != NULL); + return &p_generic->specific.p_data->ctx; +} + + +/** + * @brief Auxiliary function to access HID generic instance data. + * + * @param[in] p_inst Class instance data. + * + * @return HID generic class instance data. + */ +static inline app_usbd_hid_generic_t const * +hid_generic_get(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + return (app_usbd_hid_generic_t const *)p_inst; +} + + +/** + * @brief Returns report ID buffer descriptor. + * + * @param[in] p_generic Internal HID generic context. + * + * @return HID report buffer. + */ +static inline app_usbd_hid_report_buffer_t * +hid_generic_rep_buffer_get(app_usbd_hid_generic_t const * p_generic) +{ + ASSERT(p_generic != NULL); + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + return app_usbd_hid_rep_buff_in_get(p_hinst); +} + + +/** + * @brief Auxiliary function to prepare report transfer buffer to next transfer. + * + * @param[in] p_generic HID generic instance. + * + * @retval true Next transfer required. + * @retval false Next transfer not required. + */ +static inline bool hid_generic_transfer_next(app_usbd_hid_generic_t const * p_generic) +{ + nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; + + return !nrf_queue_is_empty(p_rep_in_queue); +} + + +/** + * @brief Triggers IN endpoint transfer. + * + * @param[in] p_generic HID generic instance. + * + * @return Standard error code. + */ +static inline ret_code_t hid_generic_transfer_set(app_usbd_hid_generic_t const * p_generic) +{ + app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_generic; + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + + app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, + APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + + if (!hid_generic_transfer_next(p_generic)) + { + return NRF_SUCCESS; + } + + app_usbd_hid_report_buffer_t * p_rep_buff = hid_generic_rep_buffer_get(p_generic); + nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; + + ret_code_t ret = nrf_queue_pop(p_rep_in_queue, p_rep_buff); + ASSERT(ret == NRF_SUCCESS); + + NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buff->p_buff, p_rep_buff->size); + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(ep_addr, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_hid_state_flag_set(&p_generic_ctx->hid_ctx, + APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + +ret_code_t hid_generic_clear_buffer(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + app_usbd_hid_report_buffer_t * p_rep_buffer = hid_generic_rep_buffer_get(p_generic); + nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; + ret_code_t ret = NRF_SUCCESS; + + /* Clear all queued reports */ + while(ret != NRF_ERROR_NOT_FOUND) + { + ret = nrf_queue_pop(p_rep_in_queue, p_rep_buffer); + } + + CRITICAL_REGION_ENTER(); + uint8_t iface_count = app_usbd_class_iface_count_get(p_inst); + + app_usbd_class_iface_conf_t const * p_iface = NULL; + for (uint8_t i = 0; i < iface_count; ++i) + { + p_iface = app_usbd_class_iface_get(p_inst, i); + + uint8_t ep_count = app_usbd_class_iface_ep_count_get(p_iface); + + for (uint8_t j = 0; j < ep_count; ++j) + { + /*Abort transfer on every IN endpoint*/ + app_usbd_class_ep_conf_t const * p_ep = app_usbd_class_iface_ep_get(p_iface, j); + + ASSERT(!NRF_USBD_EPISO_CHECK(p_ep->address)); + + if (NRF_USBD_EPIN_CHECK(p_ep->address)) + { + nrf_drv_usbd_ep_abort(p_ep->address); + } + + } + } + + app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + CRITICAL_REGION_EXIT(); + + return ret; +} + + +ret_code_t app_usbd_hid_generic_in_report_set(app_usbd_hid_generic_t const * p_generic, + const void * p_buff, + size_t size) +{ + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; + const app_usbd_hid_report_buffer_t rep_buff = { + .p_buff = (void *)p_buff, + .size = size, + }; + + if (nrf_queue_push(p_rep_in_queue, &rep_buff) != NRF_SUCCESS) + { + return NRF_ERROR_BUSY; + } + + ret_code_t ret = NRF_SUCCESS; + if (app_usbd_hid_trans_required(&p_generic_ctx->hid_ctx) && + !p_generic_ctx->hid_ctx.idle_on) + { + ret = hid_generic_transfer_set(p_generic); + } + + return ret; +} + +ret_code_t app_usbd_hid_generic_idle_report_set(app_usbd_hid_generic_t const * p_generic, + const void * p_buff, + size_t size) +{ + app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_generic; + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + ret_code_t ret; + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + + app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, + APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + + NRF_DRV_USBD_TRANSFER_IN(transfer, p_buff, size); + + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(ep_addr, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_hid_state_flag_set(&p_generic_ctx->hid_ctx, + APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + + +const void * app_usbd_hid_generic_in_report_get(app_usbd_hid_generic_t const * p_generic, + size_t * p_size) +{ + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + *p_size = p_hinst->p_rep_buffer_in->size; + return p_hinst->p_rep_buffer_in->p_buff; +} + + +const void * app_usbd_hid_generic_out_report_get(app_usbd_hid_generic_t const * p_generic, + size_t * p_size) +{ + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + *p_size = p_hinst->p_rep_buffer_out->size; + return p_hinst->p_rep_buffer_out->p_buff; +} + +const void * app_usbd_hid_generic_feature_report_get(app_usbd_hid_generic_t const * p_generic, + size_t * p_size) +{ + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + *p_size = p_hinst->p_rep_buffer_feature->size; + return p_hinst->p_rep_buffer_feature->p_buff; +} + +/** + * @brief @ref app_usbd_hid_interface_t::on_get_report + */ +static ret_code_t hid_generic_on_get_report(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_hid_generic_t const * p_hinst = hid_generic_get(p_inst); + uint8_t const * p_rep_buffer = NULL; + size_t buffer_size = 0; + + if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_INPUT) + { + p_rep_buffer = app_usbd_hid_generic_in_report_get(p_hinst, &buffer_size); + } + else if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_OUTPUT) + { + p_rep_buffer = app_usbd_hid_generic_out_report_get(p_hinst, &buffer_size); + } + else if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_FEATURE) + { + p_rep_buffer = app_usbd_hid_generic_feature_report_get(p_hinst, &buffer_size); + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } + + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_rep_buffer, buffer_size); +} + + +static ret_code_t hid_generic_on_set_report_data_cb(nrf_drv_usbd_ep_status_t status, + void * p_context) +{ + app_usbd_hid_user_ev_handler_t handler; + app_usbd_hid_generic_t const * p_generic = (app_usbd_hid_generic_t const *)p_context; + + if (status != NRF_USBD_EP_OK) + { + return NRF_ERROR_INTERNAL; + } + + handler = p_generic->specific.inst.hid_inst.user_event_handler; + handler((app_usbd_class_inst_t const *)p_generic, + APP_USBD_HID_USER_EVT_OUT_REPORT_READY); + return NRF_SUCCESS; +} + +static ret_code_t hid_generic_on_set_report_feature_data_cb(nrf_drv_usbd_ep_status_t status, + void * p_context) +{ + app_usbd_hid_user_ev_handler_t handler; + app_usbd_hid_generic_t const * p_generic = (app_usbd_hid_generic_t const *)p_context; + + if (status != NRF_USBD_EP_OK) + { + return NRF_ERROR_INTERNAL; + } + + handler = p_generic->specific.inst.hid_inst.user_event_handler; + handler((app_usbd_class_inst_t const *)p_generic, + APP_USBD_HID_USER_EVT_FEATURE_REPORT_READY); + return NRF_SUCCESS; +} + +/** + * @brief @ref app_usbd_hid_interface_t::on_set_report + */ +static ret_code_t hid_generic_on_set_report(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_OUTPUT) + { + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + + /*Request setup data*/ + app_usbd_hid_report_buffer_t const * p_rep_buff; + + p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_generic->specific.inst.hid_inst); + + p_rep_buff->p_buff[0] = p_setup_ev->setup.wValue.lb; + NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_core_setup_data_handler_desc_t desc = { + .handler = hid_generic_on_set_report_data_cb, + .p_context = (void *)p_generic + }; + + ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); + } + CRITICAL_REGION_EXIT(); + return ret; + + } + else if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_FEATURE) + { + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + + /*Request setup data*/ + app_usbd_hid_report_buffer_t const * p_rep_buff; + + p_rep_buff = app_usbd_hid_rep_buff_feature_get(&p_generic->specific.inst.hid_inst); + + NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff, p_rep_buff->size); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_core_setup_data_handler_desc_t desc = { + .handler = hid_generic_on_set_report_feature_data_cb, + .p_context = (void *)p_generic + }; + + ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); + } + CRITICAL_REGION_EXIT(); + return ret; + } + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief @ref app_usbd_hid_interface_t::ep_transfer_in + */ +static ret_code_t hid_generic_ep_transfer_in(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + + nrf_queue_t const * p_rep_in_queue = p_generic->specific.inst.p_rep_in_queue; + + if (nrf_queue_is_empty(p_rep_in_queue)) + { + app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, + APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + return NRF_SUCCESS; + } + + /* Get next report to send */ + return hid_generic_transfer_set((app_usbd_hid_generic_t const *)p_inst); +} + + +/** + * @brief @ref app_usbd_hid_interface_t::ep_transfer_out + */ +static ret_code_t hid_generic_ep_transfer_out(app_usbd_class_inst_t const * p_inst) +{ + + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epout_addr_get(p_inst); + + /*Request setup data*/ + app_usbd_hid_report_buffer_t const * p_rep_buff; + + p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_generic->specific.inst.hid_inst); + NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff, p_rep_buff->size); + + return app_usbd_ep_transfer(ep_addr, &transfer); +} + + +/** + * @brief @ref app_usbd_class_interface_t::event_handler + */ +static ret_code_t hid_generic_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ASSERT(p_inst != NULL); + ASSERT(p_event != NULL); + + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + app_usbd_hid_ctx_t * p_hid_ctx = &p_generic_ctx->hid_ctx; + + /*Try handle event by generic HID event handler*/ + return app_usbd_hid_event_handler(p_inst, p_hinst, p_hid_ctx, p_event); +} + + +static uint8_t hid_generic_get_class_descriptors_count(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + return p_hinst->subclass_desc_count; +} + + +static app_usbd_descriptor_t hid_generic_get_class_descriptors_type( + app_usbd_class_inst_t const * p_inst, + uint8_t desc_num) +{ + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + return p_hinst->p_subclass_desc[desc_num]->type; +} + +static size_t hid_generic_get_class_descriptors_length(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num) +{ + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + + return p_hinst->p_subclass_desc[desc_num]->size; +} + + +static const uint8_t * hid_generic_get_class_descriptors_data(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num, + uint32_t cur_byte) +{ + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_generic->specific.inst.hid_inst; + const uint8_t * p_byte = &p_hinst->p_subclass_desc[desc_num]->p_data[cur_byte]; + + return p_byte; +} + + +/** + * @brief @ref app_usbd_class_interface_t::feed_descriptors + */ +static bool hid_generic_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static uint8_t ifaces = 0; + ifaces = app_usbd_class_iface_count_get(p_inst); + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size); + + static uint8_t i = 0; + + for (i = 0; i < ifaces; i++) + { + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, i); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_CLASS); // bInterfaceClass = HID + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_generic->specific.inst.hid_inst.subclass_boot); // bInterfaceSubclass (Boot Interface) + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_generic->specific.inst.hid_inst.protocol); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* HID DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_DESCRIPTOR_HID); // bDescriptorType = HID + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(APP_USBD_HID_BCD_VER)); // bcdHID LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(APP_USBD_HID_BCD_VER)); // bcdHID MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_COUNTRY_NOT_SUPPORTED); // bCountryCode + APP_USBD_CLASS_DESCRIPTOR_WRITE(hid_generic_get_class_descriptors_count(p_inst)); // bNumDescriptors + + static uint8_t class_desc_cnt = 0; + class_desc_cnt = hid_generic_get_class_descriptors_count(p_inst); + static uint8_t j = 0; + static uint16_t class_desc_len = 0; + + for (j = 0; j < class_desc_cnt; j++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(hid_generic_get_class_descriptors_type(p_inst, j)); // bDescriptorType + + class_desc_len = hid_generic_get_class_descriptors_length(p_inst, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(class_desc_len)); // wDescriptorLength LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(class_desc_len)); // wDescriptorLength MSB + } + + static uint8_t endpoints = 0; + endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface); + + for (j = 0; j < endpoints; j++) + { + /* ENDPOINT DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint + + static app_usbd_class_ep_conf_t const * p_cur_ep = NULL; + p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT); // bmAttributes + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_generic->specific.inst.hid_inst.p_ep_interval[j]); // bInterval + } + } + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + +ret_code_t hid_generic_on_set_protocol(app_usbd_hid_generic_t const * p_generic, app_usbd_hid_user_event_t ev) +{ + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + if (ev == APP_USBD_HID_USER_EVT_SET_BOOT_PROTO) + { + p_generic_ctx->hid_ctx.selected_protocol = APP_USBD_HID_PROTO_BOOT; + } + else if (ev == APP_USBD_HID_USER_EVT_SET_REPORT_PROTO) + { + p_generic_ctx->hid_ctx.selected_protocol = APP_USBD_HID_PROTO_REPORT; + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } + return NRF_SUCCESS; +} + +ret_code_t hid_generic_idle_handler_set(app_usbd_class_inst_t const * p_inst, + app_usbd_hid_idle_handler_t handler) +{ + ASSERT(handler != NULL); + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + + p_generic_ctx->hid_ctx.idle_handler = handler; + return NRF_SUCCESS; +} + +static ret_code_t hid_generic_on_idle(app_usbd_class_inst_t const * p_inst, uint8_t report_id) +{ + app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst); + app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); + + if(p_generic_ctx->hid_ctx.idle_handler != NULL) + { + return p_generic_ctx->hid_ctx.idle_handler(p_inst, report_id); + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } +} + +/** @} */ + +const app_usbd_hid_methods_t app_usbd_hid_generic_methods = { + .on_get_report = hid_generic_on_get_report, + .on_set_report = hid_generic_on_set_report, + .ep_transfer_in = hid_generic_ep_transfer_in, + .ep_transfer_out = hid_generic_ep_transfer_out, + .subclass_length = hid_generic_get_class_descriptors_length, + .subclass_data = hid_generic_get_class_descriptors_data, + .on_idle = hid_generic_on_idle, + .set_idle_handler = hid_generic_idle_handler_set, +}; + +const app_usbd_class_methods_t app_usbd_generic_class_methods = { + .event_handler = hid_generic_event_handler, + .feed_descriptors = hid_generic_feed_descriptors, +}; + +#endif //NRF_MODULE_ENABLED(APP_USBD_HID_GENERIC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h index 09b5c53..4a2b99b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_GENERIC_H__ #define APP_USBD_HID_GENERIC_H__ @@ -70,7 +70,7 @@ extern "C" { #ifdef DOXYGEN /** - * @brief HID generic class instance type + * @brief HID generic class instance type. * * @ref APP_USBD_CLASS_TYPEDEF */ @@ -92,22 +92,21 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_hid_generic, * @param interface_number Unique interface index. * @param user_ev_handler User event handler (optional). * @param endpoint_list Input endpoint list (@ref nrf_drv_usbd_ep_t). - * @param class_descriptors HID class descriptors. - * @param report_descriptor Report descriptor. + * @param subclass_descriptors HID subclass descriptors. * @param report_in_queue_size IN report queue size. * @param report_out_maxsize Maximum output report size. + * @param report_feature_maxsize Maximum feature report size. + * @param subclass_boot Subclass boot (@ref app_usbd_hid_subclass_t). + * @param protocol HID protocol (@ref app_usbd_hid_protocol_t). * * @note This macro is just simplified version of @ref APP_USBD_HID_GENERIC_GLOBAL_DEF_INTERNAL. * * Example class definition: * @code - static uint8_t m_generic_rep_dsc[] = APP_USBD_HID_MOUSE_REPORT_DSC_BUTTON(2); + APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(mouse_desc,APP_USBD_HID_MOUSE_REPORT_DSC_BUTTON(2)); - #define HID_DESCRIPTOR_ITEM_LIST \ - ( \ - m_generic_rep_dsc, \ - ) + static const app_usbd_hid_subclass_desc_t * reps[] = {&mouse_desc}; #define ENDPOINT_LIST \ ( \ @@ -120,30 +119,37 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_hid_generic, APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid_generic, 0, hid_user_ev_handler, - ENDPOINT_LIST, - HID_DESCRIPTOR_ITEM_LIST, + ENDPOINT_LIST(), + reps, REPORT_IN_QUEUE_SIZE, - REPORT_OUT_MAXSIZE); + REPORT_OUT_MAXSIZE, + REPORT_FEATURE_MAXSIZE, + APP_USBD_HID_SUBCLASS_BOOT, + APP_USBD_HID_PROTO_MOUSE); @endcode * */ -#define APP_USBD_HID_GENERIC_GLOBAL_DEF(instance_name, \ - interface_number, \ - user_ev_handler, \ - endpoint_list, \ - class_descriptors, \ - report_descriptor, \ - report_in_queue_size, \ - report_out_maxsize) \ - APP_USBD_HID_GENERIC_GLOBAL_DEF_INTERNAL(instance_name, \ - interface_number, \ - user_ev_handler, \ - endpoint_list, \ - class_descriptors, \ - report_descriptor, \ - report_in_queue_size, \ - report_out_maxsize) - +/*lint -emacro( (40), APP_USBD_HID_GENERIC_GLOBAL_DEF) */ +#define APP_USBD_HID_GENERIC_GLOBAL_DEF(instance_name, \ + interface_number, \ + user_ev_handler, \ + endpoint_list, \ + subclass_descriptors, \ + report_in_queue_size, \ + report_out_maxsize, \ + report_feature_maxsize, \ + subclass_boot, \ + protocol) \ + APP_USBD_HID_GENERIC_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + user_ev_handler, \ + endpoint_list, \ + subclass_descriptors, \ + report_in_queue_size, \ + report_out_maxsize, \ + report_feature_maxsize, \ + subclass_boot, \ + protocol) /** * @brief Helper function to get class instance from HID generic class. @@ -172,7 +178,21 @@ app_usbd_hid_generic_class_get(app_usbd_class_inst_t const * p_inst) } /** - * @brief New IN report trigger + * @brief Changes default HID idle report. + * + * + * @param[in] p_generic HID generic class instance. + * @param[in] p_buff Report buffer. + * @param[in] size Report size. + * + * @return Standard error code. + */ +ret_code_t hid_generic_idle_set(app_usbd_hid_generic_t const * p_generic, + const void * p_buff, + size_t size); + +/** + * @brief New IN report trigger. * * * @param[in] p_generic HID generic class instance. @@ -211,7 +231,50 @@ const void * app_usbd_hid_generic_in_report_get(app_usbd_hid_generic_t const * p const void * app_usbd_hid_generic_out_report_get(app_usbd_hid_generic_t const * p_generic, size_t * p_size); +/** + * @brief Function handling SET_PROTOCOL command. + * + * + * @param[in] p_generic HID generic class instance. + * @param[in] ev User event. + * + * @return Standard error code. + */ +ret_code_t hid_generic_on_set_protocol(app_usbd_hid_generic_t const * p_generic, + app_usbd_hid_user_event_t ev); + +/** + * @brief Function that clears HID generic buffers and sends an empty report. + * + * @param[in] p_inst Base class instance. + * + * @return Standard error code. + */ +ret_code_t hid_generic_clear_buffer(app_usbd_class_inst_t const * p_inst); +/** + * @brief Sets handler for idle reports. + * + * @param[in] p_inst Base class instance. + * @param[in] handler Handler. + * + * @return Standard error code. + */ +ret_code_t hid_generic_idle_handler_set(app_usbd_class_inst_t const * p_inst, + app_usbd_hid_idle_handler_t handler); + +/** + * @brief Sends idle reoprt. + * + * @param[in] p_generic HID generic class instance. + * @param[in] p_buff Report buffer. + * @param[in] size Size of report. + * + * @return Standard error code. + */ +ret_code_t app_usbd_hid_generic_idle_report_set(app_usbd_hid_generic_t const * p_generic, + const void * p_buff, + size_t size); /** @} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h index c694348..b2629cb 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_desc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_GENERIC_DESC_H__ #define APP_USBD_HID_GENERIC_DESC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h index 70ba104..92e3664 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_GENERIC_INTERNAL_H__ #define APP_USBD_HID_GENERIC_INTERNAL_H__ @@ -101,30 +101,48 @@ typedef struct { */ #define APP_USBD_HID_GENERIC_DATA_SPECIFIC_DEC app_usbd_hid_generic_ctx_t ctx; +/** + * @brief Default interval value + * + */ +#define APP_USBD_HID_GENERIC_DEFAULT_INTERVAL 0x01 + +#define APP_USBD_HID_GENERIC_INTERVAL(ep) \ +(APP_USBD_EXTRACT_INTERVAL_FLAG(ep) ? APP_USBD_EXTRACT_INTERVAL_VALUE(ep) : APP_USBD_HID_GENERIC_DEFAULT_INTERVAL), + /** * @brief Configure internal part of HID generic instance. * - * @param descriptors Raw descriptors buffer. - * @param report_buff_in Input report buffers array. - * @param report_buff_out Output report buffer. - * @param user_ev_handler User event handler. - * @param in_report_queue IN report queue. - * @param ... Hid descriptors list. + * @param report_buff_in Input report buffers array. + * @param report_buff_out Output report buffer. + * @param report_buff_feature Feature report buffer. + * @param user_ev_handler User event handler. + * @param in_report_queue IN report queue. + * @param subclass_descriptors HID subclass descriptors. + * @param subclass_boot Subclass boot (@ref app_usbd_hid_subclass_t). + * @param protocol HID protocol (@ref app_usbd_hid_protocol_t). + * @param endpoint_list List of endpoints and intervals */ -#define APP_USBD_HID_GENERIC_INST_CONFIG(descriptors, \ - report_buff_in, \ +#define APP_USBD_HID_GENERIC_INST_CONFIG(report_buff_in, \ report_buff_out, \ + report_buff_feature, \ user_ev_handler, \ in_report_queue, \ - ...) \ + subclass_descriptors, \ + subclass_boot, \ + protocol, \ + endpoint_list) \ .inst = { \ - .hid_inst = APP_USBD_HID_INST_CONFIG(descriptors, \ - GET_VA_ARG_1(__VA_ARGS__), \ + .hid_inst = APP_USBD_HID_INST_CONFIG(subclass_descriptors, \ + subclass_boot, \ + protocol, \ report_buff_in, \ report_buff_out, \ + report_buff_feature, \ user_ev_handler, \ - &app_usbd_hid_generic_methods), \ + &app_usbd_hid_generic_methods, \ + endpoint_list), \ .p_rep_in_queue = in_report_queue, \ } @@ -143,17 +161,24 @@ extern const app_usbd_class_methods_t app_usbd_generic_class_methods; * * @ref APP_USBD_HID_GENERIC_GLOBAL_DEF */ +/*lint -esym( 40, APP_USBD_HID_GENERIC_INTERVAL) */ #define APP_USBD_HID_GENERIC_GLOBAL_DEF_INTERNAL(instance_name, \ interface_number, \ user_ev_handler, \ endpoint_list, \ - class_descriptors, \ - report_descriptor, \ + subclass_descriptors, \ report_in_queue_size, \ - report_out_maxsize) \ + report_out_maxsize, \ + report_feature_maxsize, \ + subclass_boot, \ + protocol) \ static app_usbd_hid_report_buffer_t CONCAT_2(instance_name, _in); \ APP_USBD_HID_GENERIC_GLOBAL_OUT_REP_DEF(CONCAT_2(instance_name, _out), \ report_out_maxsize + 1); \ + APP_USBD_HID_GENERIC_GLOBAL_FEATURE_REP_DEF(CONCAT_2(instance_name, _feature), \ + report_feature_maxsize + 1); \ + static uint8_t CONCAT_2(instance_name, _ep)[]= \ + {MACRO_MAP(APP_USBD_HID_GENERIC_INTERVAL,BRACKET_EXTRACT(endpoint_list))}; \ NRF_QUEUE_DEF(app_usbd_hid_report_buffer_t, \ instance_name##_queue, \ report_in_queue_size, \ @@ -163,12 +188,15 @@ extern const app_usbd_class_methods_t app_usbd_generic_class_methods; app_usbd_hid_generic, \ &app_usbd_generic_class_methods, \ APP_USBD_HID_GENERIC_CONFIG(interface_number, endpoint_list), \ - (APP_USBD_HID_GENERIC_INST_CONFIG(class_descriptors, \ - &CONCAT_2(instance_name, _in), \ + (APP_USBD_HID_GENERIC_INST_CONFIG(&CONCAT_2(instance_name, _in), \ &CONCAT_2(instance_name, _out), \ + &CONCAT_2(instance_name, _feature), \ user_ev_handler, \ &instance_name##_queue, \ - report_descriptor)) \ + subclass_descriptors, \ + subclass_boot, \ + protocol, \ + CONCAT_2(instance_name, _ep))) \ ) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c new file mode 100644 index 0000000..80c16eb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.c @@ -0,0 +1,611 @@ +/** + * Copyright (c) 2016 - 2019, 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(APP_USBD_HID_KBD) + +#include +#include "app_usbd_hid_kbd.h" +#include "app_util_platform.h" + +/** + * @defgroup app_usbd_hid_kbd_internals USB HID keyboard internals + * @{ + * @ingroup app_usbd_hid_kbd + * @internal + */ + +STATIC_ASSERT(sizeof(app_usbd_hid_descriptor_t) == 6); + +/** + * @brief Auxiliary function to access HID keyboard context data. + * + * @param[in] p_inst class instance data. + * + * @return HID keyboard instance data context. + */ +static inline app_usbd_hid_kbd_ctx_t * hid_kbd_ctx_get(app_usbd_hid_kbd_t const * p_kbd) +{ + ASSERT(p_kbd != NULL); + ASSERT(p_kbd->specific.p_data != NULL); + return &p_kbd->specific.p_data->ctx; +} + + +/** + * @brief Auxiliary function to access HID keyboard instance data. + * + * @param[in] p_inst class instance data. + * + * @return HID keyboard instance data. + */ +static inline app_usbd_hid_kbd_t const * hid_kbd_get(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + return (app_usbd_hid_kbd_t const *)p_inst; +} + + +/** + * @brief Returns keyboard report buffer handle. + * + * @param[in] p_kbd HID keyboard instance. + * + * @return HID report buffer. + */ +static inline +app_usbd_hid_report_buffer_t const * hid_kbd_rep_buffer_get(app_usbd_hid_kbd_t const * p_kbd) +{ + ASSERT(p_kbd != NULL); + app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + app_usbd_hid_report_buffer_t * p_rep_buff = app_usbd_hid_rep_buff_in_get(p_hinst); + + p_rep_buff->p_buff = p_kbd_ctx->report_buff; + p_rep_buff->size = sizeof(p_kbd_ctx->report_buff); + + /*Keyboard has only one report input/output report buffer */ + return app_usbd_hid_rep_buff_in_get(p_hinst); +} + + +/** + * @brief Auxiliary function to prepare report transfer buffer to next transfer. + * + * @param[in] p_kbd HID keyboard instance. + * + * @retval true Next transfer is required. + * @retval false Next transfer is not required. + */ +static inline bool hid_kbd_transfer_next(app_usbd_hid_kbd_t const * p_kbd) +{ + /*Send report only when state has changed*/ + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + + if (memcmp(p_rep_buffer->p_buff, &p_kbd_ctx->rep, p_rep_buffer->size)) + { + memcpy(p_rep_buffer->p_buff, &p_kbd_ctx->rep, p_rep_buffer->size); + return true; + } + + return false; +} + + +/** + * @brief Triggers IN endpoint transfer. + * + * @param[in] p_kbd HID keyboard instance. + * + * @return Standard error code. + */ +static inline ret_code_t hid_kbd_transfer_set(app_usbd_hid_kbd_t const * p_kbd) +{ + app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_kbd; + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + + app_usbd_hid_state_flag_clr(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + + if (!hid_kbd_transfer_next(p_kbd)) + { + /* Transfer buffer hasn't changed since last transfer. No need to setup + * next transfer. + * */ + return NRF_SUCCESS; + } + + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); + NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buffer->p_buff, p_rep_buffer->size); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(ep_addr, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_hid_state_flag_set(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + + +ret_code_t app_usbd_hid_kbd_modifier_state_set(app_usbd_hid_kbd_t const * p_kbd, + app_usbd_hid_kbd_modifier_t modifier, + bool state) +{ + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + bool actual_state = (p_kbd_ctx->rep.modifier & modifier) != 0; + + if (actual_state == state) + { + /*Modifier has already the same state*/ + return NRF_SUCCESS; + } + + app_usbd_hid_access_lock(&p_kbd_ctx->hid_ctx); + + if (state) + { + p_kbd_ctx->rep.modifier |= modifier; + } + else + { + p_kbd_ctx->rep.modifier &= ~modifier; + } + app_usbd_hid_access_unlock(&p_kbd_ctx->hid_ctx); + + if (app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx)) + { + /*New transfer need to be triggered*/ + return hid_kbd_transfer_set(p_kbd); + } + + return NRF_SUCCESS; +} + + +ret_code_t app_usbd_hid_kbd_key_control(app_usbd_hid_kbd_t const * p_kbd, + app_usbd_hid_kbd_codes_t key, + bool press) +{ + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + uint8_t * destination = NULL; + + if (press) + { + for (size_t i = 0; i < ARRAY_SIZE(p_kbd_ctx->rep.key_table); ++i) + { + if (p_kbd_ctx->rep.key_table[i] == key) + { + /*Already pressed*/ + return NRF_SUCCESS; + } + + if ((destination == NULL) && (p_kbd_ctx->rep.key_table[i] == 0)) + { + destination = &p_kbd_ctx->rep.key_table[i]; + } + } + + if (destination == NULL) + { + return NRF_ERROR_BUSY; + } + } + else + { + /*Find if key is pressed*/ + for (size_t i = 0; i < ARRAY_SIZE(p_kbd_ctx->rep.key_table); ++i) + { + if (p_kbd_ctx->rep.key_table[i] == key) + { + destination = &p_kbd_ctx->rep.key_table[i]; + break; + } + } + + if (destination == NULL) + { + /*Key hasn't been pressed*/ + return NRF_SUCCESS; + } + } + + /*Save destination*/ + app_usbd_hid_access_lock(&p_kbd_ctx->hid_ctx); + *destination = press ? key : 0; + app_usbd_hid_access_unlock(&p_kbd_ctx->hid_ctx); + + if (app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx)) + { + /*New transfer need to be triggered*/ + return hid_kbd_transfer_set(p_kbd); + } + + return NRF_SUCCESS; +} + + +bool app_usbd_hid_kbd_led_state_get(app_usbd_hid_kbd_t const * p_kbd, + app_usbd_hid_kbd_led_t led) +{ + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + + return (p_kbd_ctx->leds_state & led) != 0; +} + +const void * app_usbd_hid_kbd_in_report_get(app_usbd_hid_kbd_t const * p_kbd, + size_t * p_size) +{ + app_usbd_hid_inst_t const * p_kinst = &p_kbd->specific.inst.hid_inst; + *p_size = p_kinst->p_rep_buffer_in->size; + return p_kinst->p_rep_buffer_in->p_buff; +} + +const void * app_usbd_hid_kbd_out_report_get(app_usbd_hid_kbd_t const * p_kbd, + size_t * p_size) +{ + app_usbd_hid_inst_t const * p_kinst = &p_kbd->specific.inst.hid_inst; + *p_size = p_kinst->p_rep_buffer_out->size; + return p_kinst->p_rep_buffer_out->p_buff; +} + +/** + * @brief @ref app_usbd_hid_interface_t::on_get_report + */ +static ret_code_t hid_kbd_on_get_report(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_hid_kbd_t const * p_kinst = hid_kbd_get(p_inst); + uint8_t const * p_rep_buffer = NULL; + size_t buffer_size = 0; + + if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_INPUT) + { + p_rep_buffer = app_usbd_hid_kbd_in_report_get(p_kinst, &buffer_size); + } + else if (p_setup_ev->setup.wValue.hb == APP_USBD_HID_REPORT_TYPE_OUTPUT) + { + p_rep_buffer = app_usbd_hid_kbd_out_report_get(p_kinst, &buffer_size); + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } + + /* Return LEDs state (only the second byte) */ + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_rep_buffer + 1, buffer_size - 1); +} + + +static ret_code_t hid_kbd_on_set_report_data_cb(nrf_drv_usbd_ep_status_t status, void * p_context) +{ + if (status != NRF_USBD_EP_OK) + { + return NRF_ERROR_INTERNAL; + } + + app_usbd_hid_kbd_t const * p_kbd = p_context; + app_usbd_hid_report_buffer_t const * p_rep_buff; + p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_kbd->specific.inst.hid_inst); + + /*Update LEDs state*/ + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + p_kbd_ctx->leds_state = p_rep_buff->p_buff[1]; + + app_usbd_hid_user_ev_handler_t handler = p_kbd->specific.inst.hid_inst.user_event_handler; + handler((app_usbd_class_inst_t const *)(p_kbd), APP_USBD_HID_USER_EVT_OUT_REPORT_READY); + return NRF_SUCCESS; +} + + +/** + * @brief @ref app_usbd_hid_interface_t::hid_kbd_on_set_report + */ +static ret_code_t hid_kbd_on_set_report(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + + /*Request setup data*/ + app_usbd_hid_report_buffer_t const * p_rep_buff; + + p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_kbd->specific.inst.hid_inst); + + p_rep_buff->p_buff[0] = 0; + NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_core_setup_data_handler_desc_t desc = { + .handler = hid_kbd_on_set_report_data_cb, + .p_context = (app_usbd_hid_kbd_t *)p_kbd + }; + + ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc); + } + CRITICAL_REGION_EXIT(); + + return ret; +} + + +/** + * @brief @ref app_usbd_hid_interface_t::hid_kbd_ep_transfer_in + */ +static ret_code_t hid_kbd_ep_transfer_in(app_usbd_class_inst_t const * p_inst) +{ + return hid_kbd_transfer_set((app_usbd_hid_kbd_t const *)p_inst); +} + + +/** + * @brief @ref app_usbd_class_interface_t::event_handler + */ +static ret_code_t hid_kbd_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ASSERT(p_inst != NULL); + ASSERT(p_event != NULL); + + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; + + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + app_usbd_hid_ctx_t * p_hid_ctx = &p_kbd_ctx->hid_ctx; + + /*Try handle event by generic HID event handler*/ + return app_usbd_hid_event_handler(p_inst, p_hinst, p_hid_ctx, p_event); +} + +ret_code_t hid_kbd_clear_buffer(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); + + memset(p_rep_buffer->p_buff, 0, p_rep_buffer->size); + memset(p_kbd_ctx->report_buff, 0, p_rep_buffer->size); + memset(&p_kbd_ctx->rep, 0, p_rep_buffer->size); + + CRITICAL_REGION_ENTER(); + + + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + + ASSERT(!NRF_USBD_EPISO_CHECK(ep_addr)); + + if (NRF_USBD_EPIN_CHECK(ep_addr)) + { + nrf_drv_usbd_ep_abort(ep_addr); + } + + app_usbd_hid_state_flag_clr(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + CRITICAL_REGION_EXIT(); + + return NRF_SUCCESS; +} + + +static uint8_t hid_kbd_get_class_descriptors_count(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; + + return p_hinst->subclass_desc_count; +} + + +static app_usbd_descriptor_t hid_kbd_get_class_descriptors_type( + app_usbd_class_inst_t const * p_inst, + uint8_t desc_num) +{ + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; + + return p_hinst->p_subclass_desc[desc_num]->type; +} + + +static size_t hid_kbd_get_class_descriptors_length(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num) +{ + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; + + return p_hinst->p_subclass_desc[desc_num]->size; +} + + +static const uint8_t * hid_kbd_get_class_descriptors_data(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num, + uint32_t cur_byte) +{ + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_kbd->specific.inst.hid_inst; + const uint8_t * p_byte = &p_hinst->p_subclass_desc[desc_num]->p_data[cur_byte]; + + return p_byte; +} + + +static bool hid_kbd_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static uint8_t ifaces = 0; + ifaces = app_usbd_class_iface_count_get(p_inst); + app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size); + + static uint8_t i = 0; + + for (i = 0; i < ifaces; i++) + { + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, i); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_CLASS); // bInterfaceClass = HID + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_kbd->specific.inst.hid_inst.subclass_boot); // bInterfaceSubclass (Boot Interface) + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_kbd->specific.inst.hid_inst.protocol); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* HID DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_DESCRIPTOR_HID); // bDescriptorType = HID + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(APP_USBD_HID_BCD_VER)); // bcdHID LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(APP_USBD_HID_BCD_VER)); // bcdHID MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_COUNTRY_NOT_SUPPORTED); // bCountryCode + APP_USBD_CLASS_DESCRIPTOR_WRITE(hid_kbd_get_class_descriptors_count(p_inst)); // bNumDescriptors + + static uint8_t class_desc_cnt = 0; + class_desc_cnt = hid_kbd_get_class_descriptors_count(p_inst); + static uint8_t j = 0; + static uint16_t class_desc_len = 0; + + for (j = 0; j < class_desc_cnt; j++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(hid_kbd_get_class_descriptors_type(p_inst, j)); // bDescriptorType + + class_desc_len = hid_kbd_get_class_descriptors_length(p_inst, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(class_desc_len)); // wDescriptorLength LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(class_desc_len)); // wDescriptorLength MSB + } + + static uint8_t endpoints = 0; + endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface); + + for (j = 0; j < endpoints; j++) + { + /* ENDPOINT DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint + + static app_usbd_class_ep_conf_t const * p_cur_ep = NULL; + p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT); // bmAttributes + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_kbd->specific.inst.hid_inst.p_ep_interval[j]); // bInterval + } + } + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + + +ret_code_t hid_kbd_on_set_protocol(app_usbd_hid_kbd_t const * p_kbd, app_usbd_hid_user_event_t ev) +{ + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + if (ev == APP_USBD_HID_USER_EVT_SET_BOOT_PROTO) + { + p_kbd_ctx->hid_ctx.selected_protocol = APP_USBD_HID_PROTO_BOOT; + } + else if (ev == APP_USBD_HID_USER_EVT_SET_REPORT_PROTO) + { + p_kbd_ctx->hid_ctx.selected_protocol = APP_USBD_HID_PROTO_REPORT; + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } + return NRF_SUCCESS; +} + + +static ret_code_t hid_kbd_on_idle(app_usbd_class_inst_t const * p_inst, uint8_t report_id) +{ + UNUSED_PARAMETER(report_id); + app_usbd_hid_kbd_t const * p_kbd = (app_usbd_hid_kbd_t const *)p_inst; + app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + app_usbd_hid_state_flag_clr(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); + NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buffer->p_buff, p_rep_buffer->size); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(ep_addr, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_hid_state_flag_set(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + } + CRITICAL_REGION_EXIT(); + + return NRF_SUCCESS; +} + +/** @} */ + +const app_usbd_hid_methods_t app_usbd_hid_kbd_methods = { + .on_get_report = hid_kbd_on_get_report, + .on_set_report = hid_kbd_on_set_report, + .ep_transfer_in = hid_kbd_ep_transfer_in, + .ep_transfer_out = NULL, + .subclass_length = hid_kbd_get_class_descriptors_length, + .subclass_data = hid_kbd_get_class_descriptors_data, + .on_idle = hid_kbd_on_idle, +}; + +const app_usbd_class_methods_t app_usbd_hid_kbd_class_methods = { + .event_handler = hid_kbd_event_handler, + .feed_descriptors = hid_kbd_feed_descriptors, +}; + +#endif //NRF_MODULE_ENABLED(APP_USBD_HID_KBD) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h index e0cb469..2b435b8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_KBD_H__ #define APP_USBD_HID_KBD_H__ @@ -169,7 +169,7 @@ typedef enum { } app_usbd_hid_kbd_codes_t; /** - * @brief HID keyboard modifier + * @brief HID keyboard modifier. */ typedef enum { APP_USBD_HID_KBD_MODIFIER_NONE = 0x00, /**< MODIFIER_NONE bit*/ @@ -198,7 +198,7 @@ typedef enum { #ifdef DOXYGEN /** - * @brief HID keyboard class instance type + * @brief HID keyboard class instance type. * * @ref APP_USBD_CLASS_TYPEDEF */ @@ -220,17 +220,21 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_hid_kbd, \ * @param interface_number Unique interface index. * @param endpoint Input endpoint (@ref nrf_drv_usbd_ep_t). * @param user_ev_handler User event handler (optional parameter: NULL might be passed here). + * @param subclass_boot Subclass boot (@ref app_usbd_hid_subclass_t). * * Example class definition: * @code - APP_USBD_HID_KBD_GLOBAL_DEF(my_awesome_kbd, 0, NRF_DRV_USBD_EPIN1, NULL); + APP_USBD_HID_KBD_GLOBAL_DEF(my_awesome_kbd, 0, NRF_DRV_USBD_EPIN1, NULL, APP_USBD_HID_SUBCLASS_BOOT); * @endcode */ -#define APP_USBD_HID_KBD_GLOBAL_DEF(instance_name, interface_number, endpoint, user_ev_handler) \ - APP_USBD_HID_KBD_GLOBAL_DEF_INTERNAL(instance_name, \ - interface_number, \ - endpoint, \ - user_ev_handler) +#define APP_USBD_HID_KBD_GLOBAL_DEF(instance_name, interface_number, endpoint, user_ev_handler, subclass_boot) \ + APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(keyboard_desc, APP_USBD_HID_KBD_REPORT_DSC()); \ + static const app_usbd_hid_subclass_desc_t * keyboard_descs[] = {&keyboard_desc}; \ + APP_USBD_HID_KBD_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + endpoint, \ + user_ev_handler, \ + subclass_boot) /** * @brief Helper function to get class instance from HID keyboard internals. @@ -296,6 +300,27 @@ ret_code_t app_usbd_hid_kbd_key_control(app_usbd_hid_kbd_t const * p_kbd, bool app_usbd_hid_kbd_led_state_get(app_usbd_hid_kbd_t const * p_kbd, app_usbd_hid_kbd_led_t led); +/** + * @brief Function handling SET_PROTOCOL command. + * + * + * @param[in] p_kbd Keyboard instance. + * @param[in] ev User event. + * + * @return Standard error code. + */ +ret_code_t hid_kbd_on_set_protocol(app_usbd_hid_kbd_t const * p_kbd, + app_usbd_hid_user_event_t ev); + +/** + * @brief Function that clears HID keyboard buffers and sends an empty report. + * + * @param[in] p_inst Base class instance. + * + * @return Standard error code. + */ +ret_code_t hid_kbd_clear_buffer(app_usbd_class_inst_t const * p_inst); + /** @} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h index 05bf4ff..a4fbc27 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_desc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_KBD_DESC_H__ #define APP_USBD_HID_KBD_DESC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h similarity index 68% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h index 5a81b5d..e570a93 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/kbd/app_usbd_hid_kbd_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_KBD_INTERNAL_H__ #define APP_USBD_HID_KBD_INTERNAL_H__ @@ -69,7 +69,7 @@ typedef struct { } app_usbd_hid_kbd_inst_t; /** - * @brief HID keyboard context + * @brief HID keyboard context. * */ typedef struct { @@ -106,43 +106,39 @@ typedef struct { */ #define APP_USBD_HID_KBD_DATA_SPECIFIC_DEC app_usbd_hid_kbd_ctx_t ctx; - /** - * @brief HID keyboard descriptors config macro. + * @brief Default interval value * - * @ref app_usbd_hid_kbd_inst_t - * - * @param interface_number Interface number. - * @param endpoint Endpoint number. - * @param rep_descriptor Keyboard report descriptor. */ -#define APP_USBD_HID_KBD_DSC_CONFIG(interface_number, endpoint, rep_descriptor) { \ - APP_USBD_HID_KBD_INTERFACE_DSC(interface_number) \ - APP_USBD_HID_KBD_HID_DSC(rep_descriptor) \ - APP_USBD_HID_KBD_EP_DSC(endpoint) \ -} +#define APP_USBD_HID_KBD_DEFAULT_INTERVAL 0x01 + +#define APP_USBD_HID_KBD_INTERVAL(ep) \ +(APP_USBD_EXTRACT_INTERVAL_FLAG(ep) ? APP_USBD_EXTRACT_INTERVAL_VALUE(ep) : APP_USBD_HID_KBD_DEFAULT_INTERVAL) /** * @brief Configure internal part of HID keyboard instance. * - * @param descriptors Raw descriptors buffer. - * @param report_desc Report descriptor. * @param report_buff_in Input report buffers array. * @param report_buff_out Output report buffer. * @param user_ev_handler User event handler. + * @param subclass_boot Subclass boot (@ref app_usbd_hid_subclass_t). + * @param endpoint_list List of endpoints and intervals */ -#define APP_USBD_HID_KBD_INST_CONFIG(descriptors, \ - report_desc, \ - report_buff_in, \ - report_buff_out, \ - user_ev_handler) \ - .inst = { \ - .hid_inst = APP_USBD_HID_INST_CONFIG(descriptors, \ - report_desc, \ - report_buff_in, \ - report_buff_out, \ - user_ev_handler, \ - &app_usbd_hid_kbd_methods), \ +#define APP_USBD_HID_KBD_INST_CONFIG(report_buff_in, \ + report_buff_out, \ + user_ev_handler, \ + subclass_boot, \ + endpoint_list) \ + .inst = { \ + .hid_inst = APP_USBD_HID_INST_CONFIG(keyboard_descs, \ + subclass_boot, \ + APP_USBD_HID_PROTO_KEYBOARD, \ + report_buff_in, \ + report_buff_out, \ + NULL, \ + user_ev_handler, \ + &app_usbd_hid_kbd_methods, \ + endpoint_list), \ } @@ -161,28 +157,25 @@ extern const app_usbd_class_methods_t app_usbd_hid_kbd_class_methods; * * @ref APP_USBD_HID_KBD_GLOBAL_DEF */ -#define APP_USBD_HID_KBD_GLOBAL_DEF_INTERNAL(instance_name, \ - interface_number, \ - endpoint, \ - user_ev_handler) \ - static const uint8_t CONCAT_2(instance_name, _rep_dsc)[] = \ - APP_USBD_HID_KBD_REPORT_DSC(); \ - static const uint8_t CONCAT_2(instance_name, _dsc)[] = \ - APP_USBD_HID_KBD_DSC_CONFIG(interface_number, \ - endpoint, \ - CONCAT_2(instance_name, _rep_dsc)); \ - APP_USBD_HID_GENERIC_GLOBAL_OUT_REP_DEF(CONCAT_2(instance_name, _out), 1 + 1); \ - static app_usbd_hid_report_buffer_t CONCAT_2(instance_name, _in)[1]; \ - APP_USBD_CLASS_INST_GLOBAL_DEF( \ - instance_name, \ - app_usbd_hid_kbd, \ - &app_usbd_hid_kbd_class_methods, \ - APP_USBD_HID_KBD_CONFIG(interface_number, endpoint), \ - (APP_USBD_HID_KBD_INST_CONFIG(CONCAT_2(instance_name, _dsc), \ - CONCAT_2(instance_name, _rep_dsc), \ - CONCAT_2(instance_name, _in), \ - &CONCAT_2(instance_name, _out), \ - user_ev_handler)) \ +/*lint -esym( 40, APP_USBD_HID_KBD_INTERVAL) */ +#define APP_USBD_HID_KBD_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + endpoint, \ + user_ev_handler, \ + subclass_boot) \ + static app_usbd_hid_report_buffer_t CONCAT_2(instance_name, _in)[1]; \ + static uint8_t CONCAT_2(instance_name, _ep) = {MACRO_MAP(APP_USBD_HID_KBD_INTERVAL,endpoint)}; \ + APP_USBD_HID_GENERIC_GLOBAL_OUT_REP_DEF(CONCAT_2(instance_name, _out), 1 + 1); \ + APP_USBD_CLASS_INST_GLOBAL_DEF( \ + instance_name, \ + app_usbd_hid_kbd, \ + &app_usbd_hid_kbd_class_methods, \ + APP_USBD_HID_KBD_CONFIG(interface_number, endpoint), \ + (APP_USBD_HID_KBD_INST_CONFIG(CONCAT_2(instance_name, _in), \ + &CONCAT_2(instance_name, _out), \ + user_ev_handler, \ + subclass_boot, \ + &CONCAT_2(instance_name, _ep))) \ ) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c index 8db48cb..074b214 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,17 +35,15 @@ * 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_config.h" -#if APP_USBD_HID_MOUSE_ENABLED -#include - #include "sdk_common.h" +#if NRF_MODULE_ENABLED(APP_USBD_HID_MOUSE) + +#include #include "app_usbd_hid_mouse.h" #include "app_util_platform.h" - /** * @defgroup app_usbd_hid_mouse_internal USBD HID Mouse internals * @{ @@ -67,6 +65,7 @@ static inline app_usbd_hid_mouse_ctx_t * hid_mouse_ctx_get(app_usbd_hid_mouse_t return &p_mouse->specific.p_data->ctx; } + /** * @brief Auxiliary function to access HID mouse instance data. * @@ -80,6 +79,7 @@ static inline app_usbd_hid_mouse_t const * hid_mouse_get(app_usbd_class_inst_t c return (app_usbd_hid_mouse_t const *)p_inst; } + /** * @brief Returns mouse report buffer handle. * @@ -91,17 +91,18 @@ static inline app_usbd_hid_report_buffer_t const * hid_mouse_rep_buffer_get(app_usbd_hid_mouse_t const * p_mouse) { ASSERT(p_mouse != NULL); - app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; - app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); - app_usbd_hid_report_buffer_t * p_rep_buff = app_usbd_hid_rep_buff_in_get(p_hinst); + app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + app_usbd_hid_report_buffer_t * p_rep_buff = app_usbd_hid_rep_buff_in_get(p_hinst); p_rep_buff->p_buff = p_mouse_ctx->report_buff; - p_rep_buff->size = sizeof(p_mouse_ctx->report_buff); + p_rep_buff->size = sizeof(p_mouse_ctx->report_buff); /*Mouse has only one report input report buffer */ return app_usbd_hid_rep_buff_in_get(p_hinst); } + /**@brief Auxiliary function to get report value from internal accumulated value. * * @param[in] acc Accumulated XY axis or scroll. @@ -123,6 +124,7 @@ static inline int8_t hid_mouse_axis_acc_get(int16_t acc) return acc; } + /**@brief Auxiliary function to prepare report transfer buffer to next transfer. * * @param[in] p_mouse_ctx Mouse internal context. @@ -133,8 +135,8 @@ static inline int8_t hid_mouse_axis_acc_get(int16_t acc) static inline bool hid_mouse_transfer_next(app_usbd_hid_mouse_t const * p_mouse) { - app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); - app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_mouse_rep_buffer_get(p_mouse); + app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_mouse_rep_buffer_get(p_mouse); uint8_t * p_buff = p_rep_buffer->p_buff; @@ -147,17 +149,17 @@ static inline bool hid_mouse_transfer_next(app_usbd_hid_mouse_t const * p_mouse) /*Axis X*/ int8_t val_x = hid_mouse_axis_acc_get(p_mouse_ctx->acc_x_axis); p_mouse_ctx->acc_x_axis -= val_x; - p_buff[1] = val_x; + p_buff[1] = val_x; /*Axis Y*/ int8_t val_y = hid_mouse_axis_acc_get(p_mouse_ctx->acc_y_axis); p_mouse_ctx->acc_y_axis -= val_y; - p_buff[2] = val_y; + p_buff[2] = val_y; /*Scroll*/ int8_t val_scroll = hid_mouse_axis_acc_get(p_mouse_ctx->acc_scroll); p_mouse_ctx->acc_scroll -= val_scroll; - p_buff[3] = val_scroll; + p_buff[3] = val_scroll; if (val_x || val_y || val_scroll) { @@ -174,6 +176,7 @@ static inline bool hid_mouse_transfer_next(app_usbd_hid_mouse_t const * p_mouse) return false; } + /** * @brief Triggers IN endpoint transfer. * @@ -183,8 +186,8 @@ static inline bool hid_mouse_transfer_next(app_usbd_hid_mouse_t const * p_mouse) */ static inline ret_code_t hid_mouse_transfer_set(app_usbd_hid_mouse_t const * p_mouse) { - app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_mouse; - app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_mouse; + app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); @@ -214,6 +217,7 @@ static inline ret_code_t hid_mouse_transfer_set(app_usbd_hid_mouse_t const * p_m return ret; } + /** * @brief Checks if adding would cause 16 bit signed integer overflow. * @@ -238,9 +242,11 @@ static inline bool hid_mouse_acc_overflow_check(int16_t acc, int8_t val) return false; } + ret_code_t app_usbd_hid_mouse_x_move(app_usbd_hid_mouse_t const * p_mouse, int8_t offset) { app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + if (!app_usbd_hid_state_valid(&p_mouse_ctx->hid_ctx)) { return NRF_ERROR_INVALID_STATE; @@ -271,9 +277,11 @@ ret_code_t app_usbd_hid_mouse_x_move(app_usbd_hid_mouse_t const * p_mouse, int8_ return NRF_SUCCESS; } + ret_code_t app_usbd_hid_mouse_y_move(app_usbd_hid_mouse_t const * p_mouse, int8_t offset) { app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + if (!app_usbd_hid_state_valid(&p_mouse_ctx->hid_ctx)) { return NRF_ERROR_INVALID_STATE; @@ -304,9 +312,11 @@ ret_code_t app_usbd_hid_mouse_y_move(app_usbd_hid_mouse_t const * p_mouse, int8_ return NRF_SUCCESS; } + ret_code_t app_usbd_hid_mouse_scroll_move(app_usbd_hid_mouse_t const * p_mouse, int8_t offset) { app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + if (!app_usbd_hid_state_valid(&p_mouse_ctx->hid_ctx)) { return NRF_ERROR_INVALID_STATE; @@ -337,9 +347,10 @@ ret_code_t app_usbd_hid_mouse_scroll_move(app_usbd_hid_mouse_t const * p_mouse, return NRF_SUCCESS; } + ret_code_t app_usbd_hid_mouse_button_state(app_usbd_hid_mouse_t const * p_mouse, - uint8_t button_id, - bool state) + uint8_t button_id, + bool state) { ASSERT(button_id < 8); app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); @@ -379,27 +390,35 @@ ret_code_t app_usbd_hid_mouse_button_state(app_usbd_hid_mouse_t const * p_mouse, return NRF_SUCCESS; } + /** * @brief @ref app_usbd_hid_interface_t::on_get_report */ static ret_code_t hid_mouse_on_get_report(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) + app_usbd_setup_evt_t const * p_setup_ev) { + if (p_setup_ev->setup.wValue.hb != APP_USBD_HID_REPORT_TYPE_INPUT) + { + return NRF_ERROR_NOT_SUPPORTED; + } + app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_mouse_rep_buffer_get(p_mouse); return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_rep_buffer->p_buff, p_rep_buffer->size); } + /** * @brief @ref app_usbd_hid_interface_t::on_set_report */ static ret_code_t hid_mouse_on_set_report(app_usbd_class_inst_t const * p_inst, - app_usbd_setup_evt_t const * p_setup_ev) + app_usbd_setup_evt_t const * p_setup_ev) { return NRF_ERROR_NOT_SUPPORTED; } + /** * @brief @ref app_usbd_hid_interface_t::ep_transfer_set */ @@ -408,23 +427,25 @@ static ret_code_t hid_mouse_ep_transfer_in(app_usbd_class_inst_t const * p_inst) return hid_mouse_transfer_set((app_usbd_hid_mouse_t const *)p_inst); } + /** * @brief @ref app_usbd_class_interface_t::event_handler */ -static ret_code_t hid_mouse_event_handler(app_usbd_class_inst_t const * p_inst, +static ret_code_t hid_mouse_event_handler(app_usbd_class_inst_t const * p_inst, app_usbd_complex_evt_t const * p_event) { ASSERT(p_inst != NULL); ASSERT(p_event != NULL); app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); - app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); - app_usbd_hid_ctx_t * p_hid_ctx = &p_mouse_ctx->hid_ctx; + app_usbd_hid_ctx_t * p_hid_ctx = &p_mouse_ctx->hid_ctx; ret_code_t ret = NRF_SUCCESS; + switch (p_event->app_evt.type) { default: @@ -442,32 +463,227 @@ static ret_code_t hid_mouse_event_handler(app_usbd_class_inst_t const * p_inst, return app_usbd_hid_event_handler(p_inst, p_hinst, p_hid_ctx, p_event); } -/** - * @brief @ref app_usbd_class_interface_t::get_descriptors - */ -static const void * hid_mouse_get_descriptors(app_usbd_class_inst_t const * p_inst, - size_t * p_size) + +ret_code_t hid_mouse_clear_buffer(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + + app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); + app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_mouse_rep_buffer_get(p_mouse); + + memset(p_rep_buffer->p_buff, 0, p_rep_buffer->size); + memset(p_mouse_ctx->report_buff, 0, p_rep_buffer->size); + memset(&p_mouse_ctx->acc_x_axis, 0, sizeof(p_mouse_ctx->acc_x_axis)); + memset(&p_mouse_ctx->acc_y_axis, 0, sizeof(p_mouse_ctx->acc_y_axis)); + memset(&p_mouse_ctx->acc_scroll, 0, sizeof(p_mouse_ctx->acc_scroll)); + memset(&p_mouse_ctx->button_state, 0, sizeof(p_mouse_ctx->button_state)); + + CRITICAL_REGION_ENTER(); + + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + + ASSERT(!NRF_USBD_EPISO_CHECK(ep_addr)); + + if (NRF_USBD_EPIN_CHECK(ep_addr)) + { + nrf_drv_usbd_ep_abort(ep_addr); + } + + app_usbd_hid_state_flag_clr(&p_mouse_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + CRITICAL_REGION_EXIT(); + + return NRF_SUCCESS; +} + + +static uint8_t hid_mouse_get_class_descriptors_count(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + + return p_hinst->subclass_desc_count; +} + + +static app_usbd_descriptor_t hid_mouse_get_class_descriptors_type( + app_usbd_class_inst_t const * p_inst, + uint8_t desc_num) +{ + app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + + return p_hinst->p_subclass_desc[desc_num]->type; +} + + +static size_t hid_mouse_get_class_descriptors_length(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num) +{ + app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); + app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + + return p_hinst->p_subclass_desc[desc_num]->size; +} + + +static const uint8_t * hid_mouse_get_class_descriptors_data(app_usbd_class_inst_t const * p_inst, + uint8_t desc_num, + uint32_t cur_byte) { - ASSERT(p_size != NULL); app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); - app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + app_usbd_hid_inst_t const * p_hinst = &p_mouse->specific.inst.hid_inst; + const uint8_t * p_byte = &p_hinst->p_subclass_desc[desc_num]->p_data[cur_byte]; + + return p_byte; +} + + +static bool hid_mouse_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static uint8_t ifaces = 0; + + ifaces = app_usbd_class_iface_count_get(p_inst); + app_usbd_hid_mouse_t const * p_mouse = hid_mouse_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size); + + static uint8_t i = 0; + + for (i = 0; i < ifaces; i++) + { + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, i); + + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_CLASS); // bInterfaceClass = HID + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_mouse->specific.inst.hid_inst.subclass_boot); // bInterfaceSubclass (Boot Interface) + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_mouse->specific.inst.hid_inst.protocol); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* HID DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_DESCRIPTOR_HID); // bDescriptorType = HID + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(APP_USBD_HID_BCD_VER)); // bcdHID LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(APP_USBD_HID_BCD_VER)); // bcdHID MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_HID_COUNTRY_NOT_SUPPORTED); // bCountryCode + APP_USBD_CLASS_DESCRIPTOR_WRITE(hid_mouse_get_class_descriptors_count(p_inst)); // bNumDescriptors + + static uint8_t class_desc_cnt = 0; + class_desc_cnt = hid_mouse_get_class_descriptors_count(p_inst); + static uint8_t j = 0; + static uint16_t class_desc_len = 0; + + for (j = 0; j < class_desc_cnt; j++) + { + APP_USBD_CLASS_DESCRIPTOR_WRITE(hid_mouse_get_class_descriptors_type(p_inst, j)); // bDescriptorType + + class_desc_len = hid_mouse_get_class_descriptors_length(p_inst, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(class_desc_len)); // wDescriptorLength LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(class_desc_len)); // wDescriptorLength MSB + } + + static uint8_t endpoints = 0; + endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface); + + for (j = 0; j < endpoints; j++) + { + /* ENDPOINT DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint + + static app_usbd_class_ep_conf_t const * p_cur_ep = NULL; + p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT); // bmAttributes + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_mouse->specific.inst.hid_inst.p_ep_interval[j]); // bInterval + } + } + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + + +ret_code_t hid_mouse_on_set_protocol(app_usbd_hid_mouse_t const * p_mouse, app_usbd_hid_user_event_t ev) +{ + app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + if (ev == APP_USBD_HID_USER_EVT_SET_BOOT_PROTO) + { + p_mouse_ctx->hid_ctx.selected_protocol = APP_USBD_HID_PROTO_BOOT; + } + else if (ev == APP_USBD_HID_USER_EVT_SET_REPORT_PROTO) + { + p_mouse_ctx->hid_ctx.selected_protocol = APP_USBD_HID_PROTO_REPORT; + } + else + { + return NRF_ERROR_NOT_SUPPORTED; + } + return NRF_SUCCESS; +} + + +static ret_code_t hid_mouse_on_idle(app_usbd_class_inst_t const * p_inst, uint8_t report_id) +{ + UNUSED_PARAMETER(report_id); + app_usbd_hid_mouse_t const * p_mouse = (app_usbd_hid_mouse_t const *)p_inst; + nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); + app_usbd_hid_mouse_ctx_t * p_mouse_ctx = hid_mouse_ctx_get(p_mouse); + app_usbd_hid_state_flag_clr(&p_mouse_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + + app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_mouse_rep_buffer_get(p_mouse); + + uint8_t * p_buff = p_rep_buffer->p_buff; - *p_size = p_hinst->raw_desc_size; - return p_hinst->p_raw_desc; + /* Button state */ + p_buff[0] = p_mouse_ctx->button_state; + + /* Axis movement is skipped in idle report */ + p_buff[1] = 0; + p_buff[2] = 0; + p_buff[3] = 0; + + NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buffer->p_buff, p_rep_buffer->size); + + ret_code_t ret; + CRITICAL_REGION_ENTER(); + ret = app_usbd_ep_transfer(ep_addr, &transfer); + if (ret == NRF_SUCCESS) + { + app_usbd_hid_state_flag_set(&p_mouse_ctx->hid_ctx, + APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); + } + CRITICAL_REGION_EXIT(); + + return NRF_SUCCESS; } /** @} */ const app_usbd_hid_methods_t app_usbd_hid_mouse_methods = { - .on_get_report = hid_mouse_on_get_report, - .on_set_report = hid_mouse_on_set_report, - .ep_transfer_in = hid_mouse_ep_transfer_in, - .ep_transfer_out = NULL, + .on_get_report = hid_mouse_on_get_report, + .on_set_report = hid_mouse_on_set_report, + .ep_transfer_in = hid_mouse_ep_transfer_in, + .ep_transfer_out = NULL, + .subclass_length = hid_mouse_get_class_descriptors_length, + .subclass_data = hid_mouse_get_class_descriptors_data, + .on_idle = hid_mouse_on_idle, }; const app_usbd_class_methods_t app_usbd_hid_mouse_class_methods = { - .event_handler = hid_mouse_event_handler, - .get_descriptors = hid_mouse_get_descriptors, + .event_handler = hid_mouse_event_handler, + .feed_descriptors = hid_mouse_feed_descriptors, }; -#endif // APP_USBD_HID_MOUSE_ENABLED +#endif //NRF_MODULE_ENABLED(APP_USBD_HID_MOUSE) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h similarity index 72% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h index 06aa4f5..b2359c6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_MOUSE_H__ #define APP_USBD_HID_MOUSE_H__ @@ -63,7 +63,7 @@ #ifdef DOXYGEN /** - * @brief HID mouse class instance type + * @brief HID mouse class instance type. * * @ref APP_USBD_CLASS_TYPEDEF */ @@ -86,6 +86,7 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_hid_mouse, \ * @param endpoint Input endpoint (@ref nrf_drv_usbd_ep_t). * @param bcnt Mouse button count (from 1 to 8). * @param user_ev_handler User event handler (optional). + * @param subclass_boot Subclass boot (@ref app_usbd_hid_subclass_t). * * @note This macro is just simplified version of @ref APP_USBD_HID_MOUSE_GLOBAL_DEF_INTERNAL. * @@ -93,17 +94,20 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_hid_mouse, \ APP_USBD_HID_MOUSE_GLOBAL_DEF(my_awesome_mouse, 0, NRF_DRV_USBD_EPIN1, 3, NULL); * @endcode */ -#define APP_USBD_HID_MOUSE_GLOBAL_DEF(instance_name, \ - interface_number, \ - endpoint, \ - bcnt, \ - user_ev_handler) \ - APP_USBD_HID_MOUSE_GLOBAL_DEF_INTERNAL(instance_name, \ - interface_number, \ - endpoint, \ - bcnt, \ - user_ev_handler) - +#define APP_USBD_HID_MOUSE_GLOBAL_DEF(instance_name, \ + interface_number, \ + endpoint, \ + bcnt, \ + user_ev_handler, \ + subclass_boot) \ + APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(mouse_desc, APP_USBD_HID_MOUSE_REPORT_DSC_BUTTON(bcnt)); \ + static const app_usbd_hid_subclass_desc_t * mouse_descs[] = {&mouse_desc}; \ + APP_USBD_HID_MOUSE_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + endpoint, \ + bcnt, \ + user_ev_handler, \ + subclass_boot) /** * @brief Helper function to get class instance from HID mouse internals. @@ -174,6 +178,27 @@ ret_code_t app_usbd_hid_mouse_button_state(app_usbd_hid_mouse_t const * p_mouse, uint8_t button_id, bool state); +/** + * @brief Function handling SET_PROTOCOL command. + * + * + * @param[in] p_mouse Mouse instance. + * @param[in] ev User event. + * + * @return Standard error code. + */ +ret_code_t hid_mouse_on_set_protocol(app_usbd_hid_mouse_t const * p_mouse, + app_usbd_hid_user_event_t ev); + +/** + * @brief Function that clears HID mouse buffers and sends an empty report. + * + * @param[in] p_inst Base class instance. + * + * @return Standard error code. + */ +ret_code_t hid_mouse_clear_buffer(app_usbd_class_inst_t const * p_inst); + /** @} */ #endif /* APP_USBD_HID_MOUSE_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h index dc22f70..e21096b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_desc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_MOUSE_DESC_H__ #define APP_USBD_HID_MOUSE_DESC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h similarity index 71% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h index 1902382..f1bd31a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/hid/mouse/app_usbd_hid_mouse_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_HID_MOUSE_INTERNAL_H__ #define APP_USBD_HID_MOUSE_INTERNAL_H__ @@ -108,30 +108,42 @@ typedef struct { APP_USBD_HID_MOUSE_EP_DSC(endpoint) \ } +/** + * @brief Default interval value + * + */ +#define APP_USBD_HID_MOUSE_DEFAULT_INTERVAL 0x01 + +#define APP_USBD_HID_MOUSE_INTERVAL(ep) \ +(APP_USBD_EXTRACT_INTERVAL_FLAG(ep) ? APP_USBD_EXTRACT_INTERVAL_VALUE(ep) : APP_USBD_HID_MOUSE_DEFAULT_INTERVAL) + /** * @brief Configure internal part of HID mouse instance. * - * @param descriptors Raw descriptors buffer. - * @param report_desc Report descriptor. - * @param report_buff_in Input report buffers array. - * @param report_buff_out Output report buffer. - * @param user_ev_handler User event handler. - * @param bcnt Mouse button count. + * @param report_buff_in Input report buffers array. + * @param report_buff_out Output report buffer. + * @param user_ev_handler User event handler. + * @param bcnt Mouse button count. + * @param subclass_boot Subclass boot (@ref app_usbd_hid_subclass_t). + * @param endpoint_list List of endpoints and intervals */ -#define APP_USBD_HID_MOUSE_INST_CONFIG(descriptors, \ - report_desc, \ - report_buff_in, \ +#define APP_USBD_HID_MOUSE_INST_CONFIG(report_buff_in, \ report_buff_out, \ user_ev_handler, \ - bcnt) \ + bcnt, \ + subclass_boot, \ + endpoint_list) \ .inst = { \ - .hid_inst = APP_USBD_HID_INST_CONFIG(descriptors, \ - report_desc, \ + .hid_inst = APP_USBD_HID_INST_CONFIG(mouse_descs, \ + subclass_boot, \ + APP_USBD_HID_PROTO_MOUSE, \ report_buff_in, \ report_buff_out, \ + NULL, \ user_ev_handler, \ - &app_usbd_hid_mouse_methods), \ + &app_usbd_hid_mouse_methods, \ + endpoint_list), \ .button_count = bcnt, \ } @@ -150,30 +162,26 @@ extern const app_usbd_class_methods_t app_usbd_hid_mouse_class_methods; * * @ref APP_USBD_HID_MOUSE_GLOBAL_DEF */ -#define APP_USBD_HID_MOUSE_GLOBAL_DEF_INTERNAL(instance_name, \ - interface_number, \ - endpoint, \ - bcnt, \ - user_ev_handler) \ - static const uint8_t CONCAT_2(instance_name, _rep_dsc)[] = \ - APP_USBD_HID_MOUSE_REPORT_DSC_BUTTON(bcnt); \ - static const uint8_t CONCAT_2(instance_name, _dsc)[] = \ - APP_USBD_HID_MOUSE_DSC_CONFIG(interface_number, \ - endpoint, \ - CONCAT_2(instance_name, \ - _rep_dsc)); \ - static app_usbd_hid_report_buffer_t CONCAT_2(instance_name, _in)[1]; \ - APP_USBD_CLASS_INST_GLOBAL_DEF( \ - instance_name, \ - app_usbd_hid_mouse, \ - &app_usbd_hid_mouse_class_methods, \ - APP_USBD_HID_MOUSE_CONFIG(interface_number, endpoint), \ - (APP_USBD_HID_MOUSE_INST_CONFIG(CONCAT_2(instance_name, _dsc), \ - CONCAT_2(instance_name, _rep_dsc), \ - CONCAT_2(instance_name, _in), \ - NULL, \ - user_ev_handler, \ - bcnt)) \ +/*lint -esym( 40, APP_USBD_HID_MOUSE_INTERVAL) */ +#define APP_USBD_HID_MOUSE_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + endpoint, \ + bcnt, \ + user_ev_handler, \ + subclass_boot) \ + static app_usbd_hid_report_buffer_t CONCAT_2(instance_name, _in)[1]; \ + static uint8_t CONCAT_2(instance_name, _ep) = {MACRO_MAP(APP_USBD_HID_MOUSE_INTERVAL,endpoint)}; \ + APP_USBD_CLASS_INST_GLOBAL_DEF( \ + instance_name, \ + app_usbd_hid_mouse, \ + &app_usbd_hid_mouse_class_methods, \ + APP_USBD_HID_MOUSE_CONFIG(interface_number, endpoint), \ + (APP_USBD_HID_MOUSE_INST_CONFIG(CONCAT_2(instance_name, _in), \ + NULL, \ + user_ev_handler, \ + bcnt, \ + subclass_boot, \ + &CONCAT_2(instance_name, _ep))) \ ) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.c new file mode 100644 index 0000000..58aab13 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.c @@ -0,0 +1,2492 @@ +/** + * Copyright (c) 2016 - 2019, 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(APP_USBD_MSC) + +#include +#include +#include "app_usbd.h" +#include "app_usbd_msc.h" +#include "app_usbd_string_desc.h" + +/** + * @defgroup app_usbd_msc_internal USBD MSC internals + * @{ + * @ingroup app_usbd_msc + * @internal + */ + +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_requestsense_t) == 6); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_requestsense_resp_t) == 18); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_inquiry_t) == 6); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_inquiry_resp_t) == 36); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_read6_t) == 6); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_write6_t) == 6); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense6_t) == 6); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense6_resp_t) == 4); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_readcapacity10_t) == 10); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_readcapacity10_resp_t) == 8); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_read10_t) == 10); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_write10_t) == 10); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense10_t) == 10); +STATIC_ASSERT(sizeof(app_usbd_scsi_cmd_modesense10_resp_t) == 8); + +STATIC_ASSERT(sizeof(app_usbd_msc_cbw_t) == 31); +STATIC_ASSERT(sizeof(app_usbd_msc_csw_t) == 13); + +#define NRF_LOG_MODULE_NAME usbd_msc + +#if APP_USBD_MSC_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_USBD_MSC_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_USBD_MSC_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_USBD_MSC_CONFIG_DEBUG_COLOR +#else // APP_USBD_MSC_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // APP_USBD_MSC_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define APP_USBD_MSC_IFACE_IDX 0 /**< Mass storage class interface index */ +#define APP_USBD_MSC_EPIN_IDX 0 /**< Mass storage class endpoint IN index */ +#define APP_USBD_MSC_EPOUT_IDX 1 /**< Mass storage class endpoint OUT index */ + +/** + * @brief Set request buffer busy flag. + * + * @param[in] val Bitmask to set. + * @param[in] id Buffer id. + * */ +#define APP_USBD_MSC_REQ_BUSY_SET(val, id) SET_BIT(val, id) + +/** + * @brief Clear request buffer busy flag. + * + * @param[in] val Bitmask to set. + * @param[in] id Buffer id. + * */ +#define APP_USBD_MSC_REQ_BUSY_CLR(val, id) CLR_BIT(val, id) + +#define APP_USBD_MSC_REQ_BUSY_FULL_MASK (0x03) /**< Request busy mask */ + +static void msc_blockdev_ev_handler(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_event_t const * p_event); + +/** @brief Command Block Wrapper signature */ +static const uint8_t m_cbw_signature[] = APP_USBD_MSC_CBW_SIGNATURE; + +/** @brief Command Status Wrapper signature */ +static const uint8_t m_csw_signature[] = APP_USBD_MSC_CSW_SIGNATURE; + +STATIC_ASSERT(sizeof(m_cbw_signature) == sizeof(((app_usbd_msc_cbw_t*)0)->signature)); +STATIC_ASSERT(sizeof(m_csw_signature) == sizeof(((app_usbd_msc_csw_t*)0)->signature)); + +/** + * @brief Auxiliary function to access MSC instance data. + * + * @param[in] p_inst Class instance data. + * + * @return MSC instance data @ref app_usbd_msc_t + */ +static inline app_usbd_msc_t const * msc_get(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + return (app_usbd_msc_t const *)p_inst; +} + +/** + * @brief Auxiliary function to access MSC context data. + * + * @param[in] p_msc MSC instance data. + * @return MSC context data @ref app_usbd_msc_ctx_t + */ +static inline app_usbd_msc_ctx_t * msc_ctx_get(app_usbd_msc_t const * p_msc) +{ + ASSERT(p_msc != NULL); + ASSERT(p_msc->specific.p_data != NULL); + return &p_msc->specific.p_data->ctx; +} + + +/** + * @brief Auxiliary function to access MSC IN endpoint address. + * + * @param[in] p_inst Class instance data. + * + * @return IN endpoint address. + */ +static inline nrf_drv_usbd_ep_t ep_in_addr_get(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * class_iface; + + class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_MSC_IFACE_IDX); + + app_usbd_class_ep_conf_t const * ep_cfg; + ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_MSC_EPIN_IDX); + + return app_usbd_class_ep_address_get(ep_cfg); +} + + +/** + * @brief Auxiliary function to access MSC OUT endpoint address. + * + * @param[in] p_inst Class instance data. + * + * @return OUT endpoint address. + */ +static inline nrf_drv_usbd_ep_t ep_out_addr_get(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_class_iface_conf_t const * class_iface; + + class_iface = app_usbd_class_iface_get(p_inst, APP_USBD_MSC_IFACE_IDX); + + app_usbd_class_ep_conf_t const * ep_cfg; + ep_cfg = app_usbd_class_iface_ep_get(class_iface, APP_USBD_MSC_EPOUT_IDX); + + return app_usbd_class_ep_address_get(ep_cfg); +} + + +/** + * @brief Clear the data buffer. + * + * @param p_msc MSC instance data. + */ +static inline void msc_buff_clear(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + + p_ctx->current.buff.rd_idx = 0; + p_ctx->current.buff.d_count = 0; + p_ctx->current.buff.a_count = 0; +} + +/** + * @brief Check if there is any data block ready in the buffer. + * + * @param p_msc MSC instance data. + * + * @retval true There is data block ready. + * @retval false There is no data ready for processing. + */ +static inline bool msc_buff_data_check(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + return (p_ctx->current.buff.d_count > 0); +} + +/** + * @brief Check if there is any free space in the buffer. + * + * @param p_msc MSC instance data. + * + * @retval true There is free space. + * @retval false There is no free space. + */ +static inline bool msc_buff_space_check(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + return (p_ctx->current.buff.a_count < p_msc->specific.inst.block_buff_count); +} + +/** + * @brief Allocate buffer block. + * + * @param p_msc MSC instance data. + * + * @return Pointer to a data block or NULL if there is no free space available. + */ +static inline void * msc_buff_alloc(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + void * p_buff = NULL; + CRITICAL_REGION_ENTER(); + if (msc_buff_space_check(p_msc)) + { + uint8_t idx = (p_ctx->current.buff.rd_idx + p_ctx->current.buff.a_count) % + p_msc->specific.inst.block_buff_count; + size_t offset = idx * p_msc->specific.inst.block_buff_size; + p_buff = ((uint8_t*)(p_msc->specific.inst.p_block_buff)) + offset; + ++(p_ctx->current.buff.a_count); + } + NRF_LOG_DEBUG("buff_alloc, idx: %u, dc: %u, ac: %u", + p_ctx->current.buff.rd_idx, + p_ctx->current.buff.d_count, + p_ctx->current.buff.a_count); + CRITICAL_REGION_EXIT(); + + return p_buff; +} + +/** + * @brief Put the buffer block. + * + * Puts previously allocated buffer and marks it as ready to be processed. + * + * @param p_msc MSC instance data. + * + * @note This one may be called only if the previous call of + * @ref msc_buff_alloc succeed. + */ +static inline void msc_buff_put(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + CRITICAL_REGION_ENTER(); + /* Assert if there is any space - if it is not it means some coding error */ + ASSERT(p_ctx->current.buff.d_count < p_ctx->current.buff.a_count); + ASSERT(p_ctx->current.buff.d_count < p_msc->specific.inst.block_buff_count); + ++(p_ctx->current.buff.d_count); + NRF_LOG_DEBUG("buff_put, idx: %u, dc: %u, ac: %u", + p_ctx->current.buff.rd_idx, + p_ctx->current.buff.d_count, + p_ctx->current.buff.a_count); + CRITICAL_REGION_EXIT(); +} + +/** + * @brief Get the data block filled with data. + * + * @param p_msc MSC instance data. + * + * @return Pointer to the buffer or NULL if there is no data to be processed. + */ +static inline void * msc_buff_get(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + void * p_buff = NULL; + CRITICAL_REGION_ENTER(); + if (msc_buff_data_check(p_msc)) + { + uint8_t idx = p_ctx->current.buff.rd_idx; + size_t offset = idx * p_msc->specific.inst.block_buff_size; + p_buff = ((uint8_t*)(p_msc->specific.inst.p_block_buff)) + offset; + } + NRF_LOG_DEBUG("buff_get, idx: %u, dc: %u, ac: %u", + p_ctx->current.buff.rd_idx, + p_ctx->current.buff.d_count, + p_ctx->current.buff.a_count); + CRITICAL_REGION_EXIT(); + + return p_buff; +} + +/** + * @brief Free the last used data buffer block. + * + * Function frees the oldest data block. + * + * @param p_msc MSC instance data. + * + * @note This one may be called only if the previous call of + * @ref msc_buff_get succeed. + */ +static inline void msc_buff_free(app_usbd_msc_t const * p_msc) +{ + app_usbd_msc_ctx_t * p_ctx = msc_ctx_get(p_msc); + CRITICAL_REGION_ENTER(); + /* Assert if there is any data - in case there is none, a coding error exists */ + ASSERT(p_ctx->current.buff.d_count > 0); + ASSERT(p_ctx->current.buff.a_count > 0); + --(p_ctx->current.buff.d_count); + --(p_ctx->current.buff.a_count); + p_ctx->current.buff.rd_idx = (p_ctx->current.buff.rd_idx + 1) % + p_msc->specific.inst.block_buff_count; + NRF_LOG_DEBUG("buff_free, idx: %u, dc: %u, ac: %u", + p_ctx->current.buff.rd_idx, + p_ctx->current.buff.d_count, + p_ctx->current.buff.a_count); + CRITICAL_REGION_EXIT(); +} + +/** + * @brief Helpful macro to sub a value with zero saturation. + * + * @param[in] m The minuend. + * @param[in] s The subtrahend. + * + * @return The difference saturated at 0. + */ +#define SUB_SAT0(m, s) ((m) < (s)) ? 0 : ((m) - (s)) + +/** + * @brief Command Block Wrapper trigger. + * + * @param[in] p_inst Generic class instance. + * @param[in] state Next state transition. + * + * @return Standard error code. + * */ +static ret_code_t cbw_wait_start(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + nrf_drv_usbd_ep_t ep_addr_out = ep_out_addr_get(p_inst); + + NRF_LOG_DEBUG("cbw_wait_start"); + memset(&p_msc_ctx->cbw, 0, sizeof(app_usbd_msc_cbw_t)); + NRF_DRV_USBD_TRANSFER_OUT(cbw, &p_msc_ctx->cbw, sizeof(app_usbd_msc_cbw_t)); + ret_code_t ret = app_usbd_ep_transfer(ep_addr_out, &cbw); + if (ret == NRF_SUCCESS) + { + p_msc_ctx->state = APP_USBD_MSC_STATE_CBW; + } + + return ret; +} + + +/** + * @brief Command Status Wrapper trigger. + * + * @param[in] p_inst Generic class instance. + * @param[in] state Next state transition. + * + * @return Standard error code. + * */ +static ret_code_t csw_wait_start(app_usbd_class_inst_t const * p_inst, uint8_t status) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + nrf_drv_usbd_ep_t ep_addr_in = ep_in_addr_get(p_inst); + + NRF_LOG_DEBUG("csw_wait_start: %u", status); + + /* The maximum of this two is already the data that was not processed */ + size_t datalen_left = MAX( + p_msc_ctx->current.process.datalen_left, + p_msc_ctx->current.transfer.datalen_left); + + UNUSED_RETURN_VALUE(uint32_encode(datalen_left, p_msc_ctx->csw.residue)); + p_msc_ctx->csw.status = status; + + NRF_DRV_USBD_TRANSFER_IN(csw, &p_msc_ctx->csw, sizeof(app_usbd_msc_csw_t)); + ret_code_t ret = app_usbd_ep_transfer(ep_addr_in, &csw); + if (ret == NRF_SUCCESS) + { + p_msc_ctx->state = APP_USBD_MSC_STATE_CSW; + } + + return ret; +} + + +/** + * @brief IN transfer trigger. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_buff IN transfer data buffer. + * @param[in] size IN transfer size. + * @param[in] state Next state transition. + * + * @return Standard error code. + * */ +static ret_code_t transfer_in_start(app_usbd_class_inst_t const * p_inst, + void const * p_buff, + size_t size, + app_usbd_msc_state_t state) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + NRF_LOG_DEBUG("transfer_in_start: p_buff: %p, size: %u", (uint32_t)p_buff, size); + + nrf_drv_usbd_ep_t ep_addr_in = ep_in_addr_get(p_inst); + + NRF_DRV_USBD_TRANSFER_IN(resp, p_buff, size); + ret_code_t ret = app_usbd_ep_transfer(ep_addr_in, &resp); + if (ret == NRF_SUCCESS) + { + p_msc_ctx->state = state; + } + return ret; +} + + +/** + * @brief MSC reset request handler @ref APP_USBD_MSC_REQ_BULK_RESET + * + * @param[in] p_inst Generic class instance. + * + * */ +static void bulk_ep_reset(app_usbd_class_inst_t const * p_inst) +{ + nrf_drv_usbd_ep_t ep_addr_in = ep_in_addr_get(p_inst); + nrf_drv_usbd_ep_t ep_addr_out = ep_out_addr_get(p_inst); + + nrf_drv_usbd_ep_abort(ep_addr_in); + nrf_drv_usbd_ep_abort(ep_addr_out); +} + + +/** + * @brief OUT transfer trigger. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_buff OUT transfer data buffer. + * @param[in] size OUT transfer size. + * @param[in] state Next state transition. + * + * @return Standard error code. + * */ +static ret_code_t transfer_out_start(app_usbd_class_inst_t const * p_inst, + void * p_buff, + size_t size, + app_usbd_msc_state_t state) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + NRF_LOG_DEBUG("transfer_out_start: p_buff: %p, size: %u", (uint32_t)p_buff, size); + nrf_drv_usbd_ep_t ep_addr_out = ep_out_addr_get(p_inst); + + NRF_DRV_USBD_TRANSFER_OUT(resp, p_buff, size); + ret_code_t ret = app_usbd_ep_transfer(ep_addr_out, &resp); + if (ret == NRF_SUCCESS) + { + p_msc_ctx->state = state; + } + return ret; +} + + +/** + * @brief Generic function to stall communication endpoints and mark error state. + * + * Function used internally to stall all communication endpoints and mark current state. + * + * @param p_inst Generic class instance. + * @param state State to set. + */ +static void status_generic_error_stall(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_state_t state) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + nrf_drv_usbd_ep_t ep_in = ep_in_addr_get(p_inst); + nrf_drv_usbd_ep_t ep_out = ep_out_addr_get(p_inst); + + nrf_drv_usbd_ep_stall(ep_in); + nrf_drv_usbd_ep_stall(ep_out); + nrf_drv_usbd_ep_abort(ep_in); + nrf_drv_usbd_ep_abort(ep_out); + + p_msc_ctx->state = state; +} + + +/** + * @brief Start status stage of unsupported SCSI command. + * + * @param[in,out] p_inst Generic class instance. + * + * @return Standard error code. + * + * @sa status_generic_error_stall + */ +static ret_code_t status_unsupported_start(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + bool data_stage = uint32_decode(p_msc_ctx->cbw.datlen) != 0; + ret_code_t ret = NRF_SUCCESS; + if (!data_stage) + { + /* Try to transfer the response now */ + ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); + } + else + { + /* Cannot transfer failed response in current command - stall the endpoints and postpone the answer */ + status_generic_error_stall(p_inst, APP_USBD_MSC_STATE_UNSUPPORTED); + } + return ret; +} + + +/** + * @brief Start status stage of CBW invalid. + * + * @param[in,out] p_inst Generic class instance. + * + * @sa status_generic_error_stall + */ +static void status_cbwinvalid_start(app_usbd_class_inst_t const * p_inst) +{ + status_generic_error_stall(p_inst, APP_USBD_MSC_STATE_CBW_INVALID); +} + + +/** + * @brief Start status stage of internal device error. + * + * Kind of error that requires bulk reset but does not stall endpoint permanently - the correct + * answer is possible. + * + * @param[in] p_inst Generic class instance. + * + * @sa status_generic_error_stall + */ +static void status_deverror_start(app_usbd_class_inst_t const * p_inst) +{ + status_generic_error_stall(p_inst, APP_USBD_MSC_STATE_DEVICE_ERROR); +} + + +/** + * @brief Internal SETUP standard IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + /* Only Get Descriptor standard IN request is supported by MSC class */ + if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) + && + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + { + size_t dsc_len = 0; + size_t max_size; + + uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); + + /* Try to find descriptor in class internals*/ + ret_code_t ret = app_usbd_class_descriptor_find( + p_inst, + p_setup_ev->setup.wValue.hb, + p_setup_ev->setup.wValue.lb, + p_trans_buff, + &dsc_len); + + if (ret != NRF_ERROR_NOT_FOUND) + { + ASSERT(dsc_len < NRF_DRV_USBD_EPSIZE); + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_trans_buff, dsc_len); + } + } + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Internal SETUP standard OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + * @retval NRF_ERROR_FORBIDDEN Endpoint stall cannot be cleared because of internal state. + */ +static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + app_usbd_setup_reqrec_t req_rec = app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType); + + if ((req_rec == APP_USBD_SETUP_REQREC_ENDPOINT) && + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_CLEAR_FEATURE) && + (p_setup_ev->setup.wValue.w == APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT)) + { + if (p_msc_ctx->state == APP_USBD_MSC_STATE_CBW_INVALID) + { + return NRF_ERROR_FORBIDDEN; + } + ret_code_t ret = NRF_SUCCESS; + /* Clearing endpoint here. It is done normally inside app_usbd, but we are overwritting this functionality */ + nrf_drv_usbd_ep_t ep_addr = (nrf_drv_usbd_ep_t)(p_setup_ev->setup.wIndex.lb); + nrf_drv_usbd_ep_dtoggle_clear(ep_addr); + nrf_drv_usbd_ep_stall_clear(ep_addr); + if (NRF_USBD_EPIN_CHECK(ep_addr)) + { + switch (p_msc_ctx->state) + { + case APP_USBD_MSC_STATE_UNSUPPORTED: + { + nrf_drv_usbd_ep_stall_clear(ep_out_addr_get(p_inst)); + /*Unsupported command handle: status stage*/ + ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); + if (ret != NRF_SUCCESS) + { + NRF_LOG_ERROR("Unexpected csw_wait_start on ep clear: %d", ret); + } + break; + } + + case APP_USBD_MSC_STATE_DEVICE_ERROR: + { + nrf_drv_usbd_ep_stall_clear(ep_out_addr_get(p_inst)); + /*Unsupported command handle: status stage*/ + ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PE); + if (ret != NRF_SUCCESS) + { + NRF_LOG_ERROR("Unexpected csw_wait_start on ep clear: %d", ret); + } + break; + } + + default: + break; + } + } + return ret; + } + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Internal SETUP class IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_MSC_REQ_GET_MAX_LUN: + { + + if (p_setup_ev->setup.wValue.w != 0) + { + break; + } + + if (p_setup_ev->setup.wLength.w != 1) + { + break; + } + + size_t tx_size; + uint16_t * p_tx_buff = app_usbd_core_setup_transfer_buff_get(&tx_size); + ASSERT(p_msc->specific.inst.block_devs_count != 0); + p_tx_buff[0] = p_msc->specific.inst.block_devs_count - 1; + + ret_code_t ret = cbw_wait_start(p_inst); + UNUSED_VARIABLE(ret); + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_tx_buff, sizeof(uint8_t)); + } + + default: + break; + + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Internal SETUP class OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_MSC_REQ_BULK_RESET: + { + if (p_setup_ev->setup.wValue.w != 0) + { + break; + } + + if (p_setup_ev->setup.wLength.w != 0) + { + break; + } + + /* + * Reset internal state to be ready for next CBW + */ + NRF_LOG_DEBUG("bulk ep reset"); + bulk_ep_reset(p_inst); + + if (p_msc_ctx->state != APP_USBD_MSC_STATE_CBW) + { + ret_code_t ret = cbw_wait_start(p_inst); + UNUSED_VARIABLE(ret); + } + + return NRF_SUCCESS; + } + + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Control endpoint handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + ASSERT(p_inst != NULL); + ASSERT(p_setup_ev != NULL); + + if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_in(p_inst, p_setup_ev); + + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_in(p_inst, p_setup_ev); + + default: + break; + } + } + else /* APP_USBD_SETUP_REQDIR_OUT */ + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_out(p_inst, p_setup_ev); + + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_out(p_inst, p_setup_ev); + + default: + break; + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + + +/** + * @brief Get number of blocks that should be transfered into the selected LUN + * + * Function calculates number of blocks for the request. + * The number of block is calculated based on the work buffer size and the size left to transfer. + * + * @param p_msc MSC instance. + * @param size The size of the transfer left. + * + * @return Number of blocks required for the transfer. + */ +static uint32_t current_blkcnt_calc(app_usbd_msc_t const * p_msc, size_t size) +{ + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + if (size > p_msc->specific.inst.block_buff_size) + { + size = p_msc->specific.inst.block_buff_size; + } + return CEIL_DIV(size, p_msc_ctx->current.process.blk_size); +} + + +/** + * @brief Helper function to calculate next transfer size. + * + * @param[in] p_msc MSC instance. + * @param[in] size Total size of the transfer left. + * + * @return Blocks to transfer. + * */ +static uint32_t current_size_calc(app_usbd_msc_t const * p_msc, size_t size) +{ + return MIN(size, p_msc->specific.inst.block_buff_size); +} + + +static ret_code_t read_transfer_processor(app_usbd_class_inst_t const * p_inst) +{ + ret_code_t ret = NRF_SUCCESS; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + if ((!p_msc_ctx->current.transfer.pending)) + { + NRF_LOG_DEBUG("read_transfer_processor: left: %u, state: %u", + p_msc_ctx->current.transfer.size_left, + p_msc_ctx->state); + if (p_msc_ctx->current.transfer.abort) + { + NRF_LOG_ERROR("read_transfer_processor: aborted"); + ret = NRF_ERROR_NOT_SUPPORTED; + } + else if (p_msc_ctx->current.transfer.size_left > 0) + { + if (msc_buff_data_check(p_msc)) + { + void * p_buff = msc_buff_get(p_msc); + size_t req_size = current_size_calc(p_msc, p_msc_ctx->current.transfer.size_left); + ASSERT(p_buff != NULL); + /*Trigger new transfer.*/ + p_msc_ctx->current.transfer.pending = true; + ret = transfer_in_start(p_inst, p_buff, req_size, APP_USBD_MSC_STATE_DATA_IN); + if (ret != NRF_SUCCESS) + { + p_msc_ctx->current.transfer.pending = false; + } + } + } + else + { + if (p_msc_ctx->state == APP_USBD_MSC_STATE_DATA_IN) + { + if (p_msc_ctx->current.transfer.datalen_left == 0) + { + ret = csw_wait_start(p_inst, p_msc_ctx->csw.status); + ASSERT(ret == NRF_SUCCESS); + } + else + { + ret = NRF_ERROR_NOT_SUPPORTED; + } + } + } + } + return ret; +} + + +static ret_code_t read_blockmem_processor(app_usbd_class_inst_t const * p_inst) +{ + ret_code_t ret = NRF_SUCCESS; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + if (!(p_msc_ctx->current.process.pending)) + { + NRF_LOG_DEBUG("read_blockmem_processor: left: %u", p_msc_ctx->current.process.size_left); + if (p_msc_ctx->current.process.abort) + { + NRF_LOG_ERROR("read_blockmem_processor: aborted"); + ret = NRF_ERROR_NOT_SUPPORTED; + } + else if ((p_msc_ctx->current.process.size_left > 0) && msc_buff_space_check(p_msc)) + { + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + uint32_t blk_cnt = current_blkcnt_calc(p_msc, p_msc_ctx->current.process.size_left); + void * p_buff = msc_buff_alloc(p_msc); + ASSERT(p_buff != NULL); + NRF_BLOCK_DEV_REQUEST( + req, + p_msc_ctx->current.process.blk_idx, + blk_cnt, + p_buff); + + p_msc_ctx->current.process.pending = true; + ret = nrf_blk_dev_read_req(p_blkd, &req); + + if (ret != NRF_SUCCESS) + { + /* Mark process pending and move all pionters */ + p_msc_ctx->current.process.pending = false; + NRF_LOG_ERROR("read_blockmem_processor: block req failed: %u", ret); + } + } + } + return ret; +} + + +static ret_code_t write_transfer_processor(app_usbd_class_inst_t const * p_inst) +{ + ret_code_t ret = NRF_SUCCESS; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + if (!(p_msc_ctx->current.transfer.pending)) + { + NRF_LOG_DEBUG("write_transfer_processor: left: %u", p_msc_ctx->current.transfer.size_left); + if ((p_msc_ctx->current.transfer.size_left > 0) && msc_buff_space_check(p_msc)) + { + void * p_buff = msc_buff_alloc(p_msc); + size_t req_size = current_size_calc(p_msc, p_msc_ctx->current.transfer.size_left); + ASSERT(p_buff != NULL); + /*Trigger new transfer.*/ + p_msc_ctx->current.transfer.pending = true; + ret = transfer_out_start(p_inst, p_buff, req_size, APP_USBD_MSC_STATE_DATA_OUT); + if (ret != NRF_SUCCESS) + { + p_msc_ctx->current.transfer.pending = false; + } + } + } + return ret; +} + +static ret_code_t write_blockmem_processor(app_usbd_class_inst_t const * p_inst) +{ + ret_code_t ret = NRF_SUCCESS; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + if (!(p_msc_ctx->current.process.pending)) + { + NRF_LOG_DEBUG("write_blockmem_processor: left: %u, state: %u", + p_msc_ctx->current.process.size_left, + p_msc_ctx->state); + if (p_msc_ctx->current.process.abort) + { + NRF_LOG_ERROR("write_blockmem_processor: aborted"); + ret = NRF_ERROR_NOT_SUPPORTED; + } + else if (p_msc_ctx->current.process.size_left > 0) + { + if (msc_buff_data_check(p_msc)) + { + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + uint32_t blk_cnt = current_blkcnt_calc(p_msc, p_msc_ctx->current.process.size_left); + void * p_buff = msc_buff_get(p_msc); + ASSERT(p_buff != NULL); + NRF_BLOCK_DEV_REQUEST( + req, + p_msc_ctx->current.process.blk_idx, + blk_cnt, + p_buff); + + p_msc_ctx->current.process.pending = true; + ret = nrf_blk_dev_write_req(p_blkd, &req); + + if (ret != NRF_SUCCESS) + { + p_msc_ctx->current.process.pending = false; + NRF_LOG_ERROR("write_blockmem_processor: block req failed: %u", ret); + } + } + } + else + { + if (p_msc_ctx->state == APP_USBD_MSC_STATE_DATA_OUT) + { + if (p_msc_ctx->current.process.datalen_left == 0) + { + ret = csw_wait_start(p_inst, p_msc_ctx->csw.status); + ASSERT(ret == NRF_SUCCESS); + } + else + { + ret = NRF_ERROR_NOT_SUPPORTED; + } + } + } + } + return ret; +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_TESTUNITREADY handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_testunitready(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: TESTUNITREADY"); + if (uint32_decode(p_msc_ctx->cbw.datlen) != 0) + { + return status_unsupported_start(p_inst); + } + + if (p_msc_ctx->cbw.cdb_length != APP_USBD_SCSI_CMD_TESTUNITREADY_LEN) + { + return status_unsupported_start(p_inst); + } + + if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) + { + return status_unsupported_start(p_inst); + } + + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_REQUESTSENSE handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_requestsense(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: REQUESTSENSE"); + app_usbd_scsi_cmd_requestsense_t const * p_reqs = (const void *)p_msc_ctx->cbw.cdb; + UNUSED_VARIABLE(p_reqs); + + if ((p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_requestsense_t))) + { + return status_unsupported_start(p_inst); + } + + if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) + { + return status_unsupported_start(p_inst); + } + + if (uint32_decode(p_msc_ctx->cbw.datlen) > sizeof(app_usbd_scsi_cmd_requestsense_resp_t)) + { + return status_unsupported_start(p_inst); + } + + uint32_t resp_len = uint32_decode(p_msc_ctx->cbw.datlen); + + if (resp_len == 0) + { + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); + } + + memset(&p_msc_ctx->scsi_resp, 0, sizeof(app_usbd_scsi_cmd_requestsense_resp_t)); + p_msc_ctx->scsi_resp.requestsense.code = APP_USBD_SCSI_CMD_REQSENSE_CODE_VALID | + APP_USBD_SCSI_CMD_REQSENSE_CODE_CURRENT; + + p_msc_ctx->scsi_resp.requestsense.len = sizeof(app_usbd_scsi_cmd_requestsense_resp_t) - + offsetof(app_usbd_scsi_cmd_requestsense_resp_t, len); + + return transfer_in_start(p_inst, + &p_msc_ctx->scsi_resp, + resp_len, + APP_USBD_MSC_STATE_CMD_IN); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_FORMAT_UNIT handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_formatunit(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: FORMAT_UNIT"); + return status_unsupported_start(p_inst); +} + + +static ret_code_t cmd_read_start(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("cmd_read_start"); + ret_code_t ret; + + if (p_msc_ctx->current.process.datalen_left == 0) + { + NRF_LOG_WARNING("Transfer size 0 detected"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); + } + if (p_msc_ctx->current.process.size_left == 0) + { + NRF_LOG_WARNING("Read size 0 detected"); + return status_unsupported_start(p_inst); + } + if ((p_msc_ctx->cbw.flags & APP_USBD_MSC_CBW_DIRECTION_IN) == 0) + { + NRF_LOG_WARNING("Wrong transfer direction"); + return status_unsupported_start(p_inst); + } + + msc_buff_clear(p_msc); + if (p_msc_ctx->current.process.size_left > p_msc_ctx->current.process.datalen_left) + { + p_msc_ctx->current.process.size_left = p_msc_ctx->current.process.datalen_left; + /* After transmitting required number of bytes - set error information */ + p_msc_ctx->csw.status = APP_USBD_MSC_CSW_STATUS_PE; + } + p_msc_ctx->current.transfer.datalen_left = p_msc_ctx->current.process.datalen_left; + p_msc_ctx->current.transfer.size_left = p_msc_ctx->current.process.size_left; + p_msc_ctx->current.transfer.pending = false; + p_msc_ctx->current.process. pending = false; + + ret = read_blockmem_processor(p_inst); + NRF_LOG_DEBUG("read_blockmem: id: %u, left: %u, datalen: %u, ret: %u", + p_msc_ctx->current.process.blk_idx, + p_msc_ctx->current.process.size_left, + p_msc_ctx->current.process.datalen_left, + ret); + + if (ret != NRF_SUCCESS) + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } + return ret; +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_READ6 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_read6(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: READ6"); + app_usbd_scsi_cmd_read6_t const * p_read6 = (const void *)p_msc_ctx->cbw.cdb; + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_read6_t)) + { + return status_unsupported_start(p_inst); + } + + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + uint32_t blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; + uint8_t blocks = p_read6->xfrlen; + + p_msc_ctx->current.process.blk_idx = + ((p_read6->mslba & 0x1F) << 16) | uint16_big_decode(p_read6->lslba); + p_msc_ctx->current.process.blk_size = blk_size; + p_msc_ctx->current.process.size_left = blocks * blk_size; + + return cmd_read_start(p_inst, p_msc, p_msc_ctx); +} + + +static ret_code_t cmd_write_start(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("cmd_write_start"); + ret_code_t ret; + + if (p_msc_ctx->current.process.datalen_left == 0) + { + NRF_LOG_WARNING("Transfer size 0 detected"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); + } + if (p_msc_ctx->current.process.size_left == 0) + { + NRF_LOG_WARNING("Write size 0 detected"); + return status_unsupported_start(p_inst); + } + if ((p_msc_ctx->cbw.flags & APP_USBD_MSC_CBW_DIRECTION_IN) != 0) + { + NRF_LOG_WARNING("Wrong transfer direction"); + return status_unsupported_start(p_inst); + } + + msc_buff_clear(p_msc); + if (p_msc_ctx->current.process.size_left > p_msc_ctx->current.process.datalen_left) + { + p_msc_ctx->current.process.size_left = p_msc_ctx->current.process.datalen_left; + /* After transmitting required number of bytes - set error information */ + p_msc_ctx->csw.status = APP_USBD_MSC_CSW_STATUS_PE; + } + p_msc_ctx->current.transfer.datalen_left = p_msc_ctx->current.process.datalen_left; + p_msc_ctx->current.transfer.size_left = p_msc_ctx->current.process.size_left; + p_msc_ctx->current.transfer.pending = false; + p_msc_ctx->current.process. pending = false; + + ret = write_transfer_processor(p_inst); + NRF_LOG_DEBUG("write_blockrx: id: %u, left: %u, datalen: %u, ret: %u", + p_msc_ctx->current.process.blk_idx, + p_msc_ctx->current.process.size_left, + p_msc_ctx->current.process.datalen_left, + ret); + + if (ret != NRF_SUCCESS) + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } + return ret; +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_WRITE6 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_write6(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: WRITE6"); + app_usbd_scsi_cmd_write6_t const * p_write6 = (const void *)p_msc_ctx->cbw.cdb; + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_write6_t)) + { + return status_unsupported_start(p_inst); + } + + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + uint32_t blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; + uint8_t blocks = p_write6->xfrlen; + + p_msc_ctx->current.process.blk_idx = + ((p_write6->mslba & 0x1F) << 16) | uint16_big_decode(p_write6->lslba); + p_msc_ctx->current.process.blk_size = blk_size; + p_msc_ctx->current.process.size_left = blocks * blk_size; + + return cmd_write_start(p_inst, p_msc, p_msc_ctx); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_INQUIRY handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_inquiry(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: INQUIRY"); + app_usbd_scsi_cmd_inquiry_t const * p_inq = (const void *)p_msc_ctx->cbw.cdb; + if (p_inq->pagecode != 0) + { + NRF_LOG_WARNING("unsupported pagecode"); + return status_unsupported_start(p_inst); + } + + if (uint32_decode(p_msc_ctx->cbw.datlen) > sizeof(app_usbd_scsi_cmd_inquiry_resp_t)) + { + return status_unsupported_start(p_inst); + } + + uint32_t resp_len = uint32_decode(p_msc_ctx->cbw.datlen); + + if (resp_len == 0) + { + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); + } + + + p_msc_ctx->scsi_resp.inquiry.qualtype = APP_USBD_MSC_SCSI_INQ_QUAL_CONNECTED | + APP_USBD_MSC_SCSI_INQ_TYPE_DIR_ACCESS; + p_msc_ctx->scsi_resp.inquiry.flags1 = APP_USBD_MSC_SCSI_INQ_FLAG1_RMB; + p_msc_ctx->scsi_resp.inquiry.version = APP_USBD_SCSI_INQ_VER_SPC4; + p_msc_ctx->scsi_resp.inquiry.flags2 = APP_USBD_MSC_SCSI_INQ_FLAG2_RSP_SPC2 | + APP_USBD_MSC_SCSI_INQ_FLAG2_HISUP; + p_msc_ctx->scsi_resp.inquiry.len = sizeof(app_usbd_scsi_cmd_inquiry_resp_t) - + offsetof(app_usbd_scsi_cmd_inquiry_resp_t, len); + + nrf_block_dev_t const * p_blkd = + p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + nrf_block_dev_info_strings_t * p_strings = NULL; + UNUSED_RETURN_VALUE(nrf_blk_dev_ioctl(p_blkd, + NRF_BLOCK_DEV_IOCTL_REQ_INFO_STRINGS, + &p_strings)); + + if (p_strings) + { + UNUSED_RETURN_VALUE(strncpy((char *)p_msc_ctx->scsi_resp.inquiry.vendorid, + p_strings->p_vendor, + sizeof(p_msc_ctx->scsi_resp.inquiry.vendorid))); + + UNUSED_RETURN_VALUE(strncpy((char *)p_msc_ctx->scsi_resp.inquiry.productid, + p_strings->p_product, + sizeof(p_msc_ctx->scsi_resp.inquiry.productid))); + + UNUSED_RETURN_VALUE(strncpy((char *)p_msc_ctx->scsi_resp.inquiry.revision, + p_strings->p_revision, + sizeof(p_msc_ctx->scsi_resp.inquiry.revision))); + } + else + { + memset(p_msc_ctx->scsi_resp.inquiry.vendorid, + 0, + sizeof(p_msc_ctx->scsi_resp.inquiry.vendorid)); + memset(p_msc_ctx->scsi_resp.inquiry.productid, + 0, + sizeof(p_msc_ctx->scsi_resp.inquiry.productid)); + memset(p_msc_ctx->scsi_resp.inquiry.revision, + 0, + sizeof(p_msc_ctx->scsi_resp.inquiry.revision)); + } + + return transfer_in_start(p_inst, + &p_msc_ctx->scsi_resp, + resp_len, + APP_USBD_MSC_STATE_CMD_IN); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESELECT6 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_modeselect6(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: MODESELECT6"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESENSE6 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_modesense6(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: MODESENSE6"); + app_usbd_scsi_cmd_modesense6_t const * p_sense6 = (const void *)p_msc_ctx->cbw.cdb; + UNUSED_VARIABLE(p_sense6); + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_modesense6_t)) + { + return status_unsupported_start(p_inst); + } + + if (uint32_decode(p_msc_ctx->cbw.datlen) > sizeof(app_usbd_scsi_cmd_modesense6_resp_t)) + { + return status_unsupported_start(p_inst); + } + + uint32_t resp_len = uint32_decode(p_msc_ctx->cbw.datlen); + + app_usbd_scsi_cmd_modesense6_resp_t * p_resp = &p_msc_ctx->scsi_resp.modesense6; + p_resp->mdlen = sizeof(app_usbd_scsi_cmd_modesense6_resp_t) - 1; + p_resp->type = 0; + p_resp->param = 0; + p_resp->bdlen = 0; + + return transfer_in_start(p_inst, + &p_msc_ctx->scsi_resp, + resp_len, + APP_USBD_MSC_STATE_CMD_IN); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_STARTSTOPUNIT handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_startstopunit(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: STARTSTOPUNIT"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_SENDDIAGNOSTIC handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_senddiagnostic(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: SENDDIAGNOSTIC"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_PREVENTMEDIAREMOVAL handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_preventremoval(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: PREVENTMEDIAREMOVAL"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_READCAPACITY10 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_readcapacity10(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: READCAPACITY10"); + + app_usbd_scsi_cmd_readcapacity10_t const * p_cap10 = (const void *)p_msc_ctx->cbw.cdb; + UNUSED_VARIABLE(p_cap10); + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_readcapacity10_t)) + { + return status_unsupported_start(p_inst); + } + + if (uint32_decode(p_msc_ctx->cbw.datlen) > sizeof(app_usbd_scsi_cmd_readcapacity10_resp_t)) + { + return status_unsupported_start(p_inst); + } + + uint32_t resp_len = uint32_decode(p_msc_ctx->cbw.datlen); + + if (resp_len == 0) + { + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); + } + + nrf_block_dev_t const * p_blkd = + p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + nrf_block_dev_geometry_t const * p_geometry = nrf_blk_dev_geometry(p_blkd); + + UNUSED_RETURN_VALUE( + uint32_big_encode(p_geometry->blk_count - 1, p_msc_ctx->scsi_resp.readcapacity10.lba)); + UNUSED_RETURN_VALUE( + uint32_big_encode(p_geometry->blk_size, p_msc_ctx->scsi_resp.readcapacity10.blklen)); + + return transfer_in_start(p_inst, + &p_msc_ctx->scsi_resp, + resp_len, + APP_USBD_MSC_STATE_CMD_IN); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_READ10 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_read10(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: READ10"); + app_usbd_scsi_cmd_read10_t const * p_read10 = (const void *)p_msc_ctx->cbw.cdb; + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_read10_t)) + { + return status_unsupported_start(p_inst); + } + + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + uint32_t blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; + uint16_t blocks = uint16_big_decode(p_read10->xfrlen); + + p_msc_ctx->current.process.blk_idx = uint32_big_decode(p_read10->lba); + p_msc_ctx->current.process.blk_size = blk_size; + p_msc_ctx->current.process.size_left = blocks * blk_size; + + return cmd_read_start(p_inst, p_msc, p_msc_ctx); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_WRITE10 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_write10(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: WRITE10"); + app_usbd_scsi_cmd_write10_t const * p_write10 = (const void *)p_msc_ctx->cbw.cdb; + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_write10_t)) + { + return status_unsupported_start(p_inst); + } + + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[p_msc_ctx->cbw.lun]; + uint32_t blk_size = nrf_blk_dev_geometry(p_blkd)->blk_size; + uint16_t blocks = uint16_big_decode(p_write10->xfrlen); + + p_msc_ctx->current.process.blk_idx = uint32_big_decode(p_write10->lba); + p_msc_ctx->current.process.blk_size = blk_size; + p_msc_ctx->current.process.size_left = blocks * blk_size; + + return cmd_write_start(p_inst, p_msc, p_msc_ctx); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESELECT10 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_modeselect10(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: MODESELECT10"); + return csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); +} + + +/** + * @brief SCSI Command: @ref APP_USBD_SCSI_CMD_MODESENSE10 handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_msc MSC instance. + * @param[in] p_msc_ctx MSC context. + * @return Standard error code. + * */ +static ret_code_t cmd_modesense10(app_usbd_class_inst_t const * p_inst, + app_usbd_msc_t const * p_msc, + app_usbd_msc_ctx_t * p_msc_ctx) +{ + NRF_LOG_DEBUG("CMD: MODESENSE10"); + app_usbd_scsi_cmd_modesense10_t const * p_sense10 = (const void *)p_msc_ctx->cbw.cdb; + UNUSED_VARIABLE(p_sense10); + if (p_msc_ctx->cbw.cdb_length < sizeof(app_usbd_scsi_cmd_modesense10_t)) + { + return status_unsupported_start(p_inst); + } + + if (p_msc_ctx->cbw.lun >= p_msc->specific.inst.block_devs_count) + { + return status_unsupported_start(p_inst); + } + + if (uint32_decode(p_msc_ctx->cbw.datlen) > sizeof(app_usbd_scsi_cmd_modesense6_resp_t)) + { + return status_unsupported_start(p_inst); + } + + uint32_t resp_len = uint32_decode(p_msc_ctx->cbw.datlen); + + app_usbd_scsi_cmd_modesense10_resp_t * p_resp = &p_msc_ctx->scsi_resp.modesense10; + + memset(p_resp, 0, sizeof(app_usbd_scsi_cmd_modesense10_resp_t)); + uint16_t len = sizeof(app_usbd_scsi_cmd_modesense10_resp_t) - sizeof(p_resp->mdlen); + p_resp->mdlen[1] = len & 0xff; + p_resp->mdlen[0] = (len >> 8) & 0xff; + + return transfer_in_start(p_inst, + &p_msc_ctx->scsi_resp, + resp_len, + APP_USBD_MSC_STATE_CMD_IN); +} + + +/** + * @brief Get the size of the last OUT transfer. + * + * @param p_inst Generic class instance. + * + * @return Number of received bytes or 0 if none. + */ +static size_t get_last_out_size(app_usbd_class_inst_t const * p_inst) +{ + nrf_drv_usbd_ep_t ep = ep_out_addr_get(p_inst); + size_t size; + ret_code_t ret = nrf_drv_usbd_ep_status_get(ep, &size); + + if (ret != NRF_SUCCESS) + { + size = 0; + } + + return size; +} + + +/** + * @brief SCSI Command Block Wrapper handler. + * + * @param[in] p_inst Generic class instance. + * @return Standard error code. + * */ +static ret_code_t state_cbw(app_usbd_class_inst_t const * p_inst) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + memset(&p_msc_ctx->current, 0, sizeof(p_msc_ctx->current)); + memset( p_msc_ctx->csw.tag, 0, sizeof(p_msc_ctx->csw.tag)); + + /*Verify the transfer size*/ + if (get_last_out_size(p_inst) != sizeof(app_usbd_msc_cbw_t)) + { + NRF_LOG_DEBUG("CMD: size error: %u", get_last_out_size(p_inst)); + status_cbwinvalid_start(p_inst); + return NRF_SUCCESS; + } + + /*Verify CBW signature*/ + if (memcmp(p_msc_ctx->cbw.signature, + m_cbw_signature, + sizeof(m_cbw_signature)) != 0) + { + NRF_LOG_DEBUG("CMD: header error: 0x%02x%02x%02x%02x", + p_msc_ctx->cbw.signature[0], p_msc_ctx->cbw.signature[1], + p_msc_ctx->cbw.signature[2], p_msc_ctx->cbw.signature[3]); + + status_cbwinvalid_start(p_inst); + return NRF_SUCCESS; + } + + /*Prepare the response*/ + memcpy(p_msc_ctx->csw.tag, p_msc_ctx->cbw.tag, sizeof(p_msc_ctx->csw.tag)); + p_msc_ctx->csw.status = APP_USBD_MSC_CSW_STATUS_PASS; + p_msc_ctx->current.process.lun = p_msc_ctx->cbw.lun; + p_msc_ctx->current.process.datalen_left = uint32_decode(p_msc_ctx->cbw.datlen); + + if (p_msc_ctx->current.process.lun >= p_msc->specific.inst.block_devs_count) + { + NRF_LOG_WARNING("Unsupported LUN"); + return status_unsupported_start(p_inst); + } + + ret_code_t ret = NRF_SUCCESS; + + switch (p_msc_ctx->cbw.cdb[0]) + { + case APP_USBD_SCSI_CMD_TESTUNITREADY: + ret = cmd_testunitready(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_REQUESTSENSE: + ret = cmd_requestsense(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_FORMAT_UNIT: + ret = cmd_formatunit(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_READ6: + ret = cmd_read6(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_WRITE6: + ret = cmd_write6(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_INQUIRY: + ret = cmd_inquiry(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_MODESELECT6: + ret = cmd_modeselect6(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_MODESENSE6: + ret = cmd_modesense6(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_STARTSTOPUNIT: + ret = cmd_startstopunit(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_SENDDIAGNOSTIC: + ret = cmd_senddiagnostic(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_PREVENTMEDIAREMOVAL: + ret = cmd_preventremoval(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_READCAPACITY10: + ret = cmd_readcapacity10(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_READ10: + ret = cmd_read10(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_WRITE10: + ret = cmd_write10(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_MODESELECT10: + ret = cmd_modeselect10(p_inst, p_msc, p_msc_ctx); + break; + + case APP_USBD_SCSI_CMD_MODESENSE10: + ret = cmd_modesense10(p_inst, p_msc, p_msc_ctx); + break; + + default: + NRF_LOG_DEBUG("CMD: UNSUPPORTED"); + NRF_LOG_HEXDUMP_DEBUG(&(p_msc_ctx->cbw), sizeof(p_msc_ctx->cbw)); + if (uint32_decode(p_msc_ctx->cbw.datlen) != 0) + { + ret = status_unsupported_start(p_inst); + } + else + { + ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_FAIL); + } + break; + } + + return ret; +} + +/** + * @brief Mark transfer block process. + * + * Common part of the @ref state_data_in_handle and @ref state_data_out_handle + * that marks the current transfer state. + * + * @param p_msc_ctx MSC context. + * @param size Number of bytes transfered. + */ +static void state_data_in_out_process(app_usbd_msc_ctx_t * p_msc_ctx, size_t size) +{ + p_msc_ctx->current.transfer.pending = false; + p_msc_ctx->current.transfer.size_left = + SUB_SAT0(p_msc_ctx->current.transfer.size_left, size); + p_msc_ctx->current.transfer.datalen_left = + SUB_SAT0(p_msc_ctx->current.transfer.datalen_left, size); +} + +/** + * @brief Handle read6/read10 command data stage. + * + * @param[in] p_inst Generic class instance. + * @param[in] size Number of bytes sent. + * + * @return Standard error code. + */ +static ret_code_t state_data_in_handle(app_usbd_class_inst_t const * p_inst, size_t size) +{ + ret_code_t ret; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + NRF_LOG_DEBUG("APP_USBD_MSC_STATE_DATA_IN"); + /* For the in transfer direction, correctly transfered block have to match */ + ASSERT(current_size_calc(p_msc, p_msc_ctx->current.transfer.size_left) == size); + /* Mark the fact the transfer block has been transfered */ + state_data_in_out_process(p_msc_ctx, size); + msc_buff_free(p_msc); + + ret = read_transfer_processor(p_inst); + if(ret == NRF_SUCCESS) + { + ret = read_blockmem_processor(p_inst); + } + if (ret != NRF_SUCCESS) + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } + return ret; +} + + +/** + * @brief Endpoint IN event handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + */ +static ret_code_t endpoint_in_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + size_t size; + + NRF_LOG_DEBUG("state: %d, ep in event, status: %d", + p_msc_ctx->state, + p_event->drv_evt.data.eptransfer.status); + + if (NRF_SUCCESS != nrf_drv_usbd_ep_status_get(p_event->drv_evt.data.eptransfer.ep, &size)) + { + size = 0; + } + + if (p_event->drv_evt.data.eptransfer.status != NRF_USBD_EP_OK) + { + return NRF_SUCCESS; + } + + ret_code_t ret = NRF_SUCCESS; + + switch (p_msc_ctx->state) + { + case APP_USBD_MSC_STATE_CMD_IN: + { + p_msc_ctx->current.process.datalen_left -= size; + ret = csw_wait_start(p_inst, APP_USBD_MSC_CSW_STATUS_PASS); + break; + } + + case APP_USBD_MSC_STATE_DATA_IN: + { + ret = state_data_in_handle(p_inst, size); + break; + } + + case APP_USBD_MSC_STATE_CSW: + { + break; + } + + case APP_USBD_MSC_STATE_DATA_OUT: + { + break; + } + + case APP_USBD_MSC_STATE_UNSUPPORTED: + { + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + default: + { + ret = NRF_ERROR_INTERNAL; + break; + } + } + + return ret; +} + +/** + * @brief Handle write6/write10 command data stage. + * + * @param[in] p_inst Generic class instance. + * @param[in] size Number of bytes received. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t state_data_out_handle(app_usbd_class_inst_t const * p_inst, size_t size) +{ + ret_code_t ret = NRF_SUCCESS; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + NRF_LOG_DEBUG("APP_USBD_MSC_STATE_DATA_OUT"); + /* For the OUT transfer direction we may get less than we expected */ + if (current_size_calc(p_msc, p_msc_ctx->current.transfer.size_left) != size) + { + p_msc_ctx->current.process.abort = true; + } + /* Mark the fact the transfer block has been transfered */ + state_data_in_out_process(p_msc_ctx, size); + msc_buff_put(p_msc); + + ret = write_transfer_processor(p_inst); + if(ret == NRF_SUCCESS) + { + ret = write_blockmem_processor(p_inst); + } + if (ret != NRF_SUCCESS) + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } + return ret; +} + + +/** + * @brief Endpoint OUT event handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS Request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED Request is not supported. + */ +static ret_code_t endpoint_out_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ret_code_t ret = NRF_SUCCESS; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + size_t size; + + NRF_LOG_DEBUG("state: %d, ep out event, status: %d", + p_msc_ctx->state, + p_event->drv_evt.data.eptransfer.status); + + if (NRF_SUCCESS != nrf_drv_usbd_ep_status_get(p_event->drv_evt.data.eptransfer.ep, &size)) + { + size = 0; + } + + if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_WAITING) + { + if (p_msc_ctx->state == APP_USBD_MSC_STATE_DATA_OUT) + { + NRF_LOG_DEBUG("NRF_USBD_EP_WAITING"); + } + else if (p_msc_ctx->state == APP_USBD_MSC_STATE_CSW || + p_msc_ctx->state == APP_USBD_MSC_STATE_IDLE) + { + ret = cbw_wait_start(p_inst); + } + + return ret; + } + else if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_ABORTED) + { + p_msc_ctx->state = APP_USBD_MSC_STATE_IDLE; + return NRF_SUCCESS; + } + else if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_OVERLOAD) + { + NRF_LOG_ERROR("Data overload"); + + switch (p_msc_ctx->state) + { + case APP_USBD_MSC_STATE_DATA_OUT: + { + status_deverror_start(p_inst); + break; + } + + /* Default action is the same like CBW - stall totally until bulk reset */ + case APP_USBD_MSC_STATE_CBW: + default: + { + status_cbwinvalid_start(p_inst); + break; + } + } + return NRF_SUCCESS; + } + else /*NRF_USBD_EP_OK*/ + { + switch (p_msc_ctx->state) + { + case APP_USBD_MSC_STATE_CBW: + { + ret = state_cbw(p_inst); + break; + } + + case APP_USBD_MSC_STATE_DATA_OUT: + { + CRITICAL_REGION_ENTER(); + ret = state_data_out_handle(p_inst, size); + CRITICAL_REGION_EXIT(); + break; + } + + case APP_USBD_MSC_STATE_UNSUPPORTED: + { + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + case APP_USBD_MSC_STATE_CSW: + break; + + default: + { + ASSERT(0); + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + } + } + + NRF_LOG_DEBUG("Ep proc status: %d", ret); + return ret; +} + + +/** + * @brief @ref app_usbd_class_methods_t::event_handler + */ +static ret_code_t msc_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ASSERT(p_inst != NULL); + ASSERT(p_event != NULL); + + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + UNUSED_VARIABLE(p_msc); + UNUSED_VARIABLE(p_msc_ctx); + + ret_code_t ret = NRF_SUCCESS; + + switch (p_event->app_evt.type) + { + case APP_USBD_EVT_DRV_SOF: + break; + + case APP_USBD_EVT_DRV_RESET: + /* Initialize */ + memset(p_msc_ctx, 0, sizeof(app_usbd_msc_csw_t)); + /* Configure the CSW signature as it should never be changed when software works */ + memcpy(p_msc_ctx->csw.signature, m_csw_signature, sizeof(m_csw_signature)); + break; + + case APP_USBD_EVT_DRV_SETUP: + ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *)p_event); + break; + + case APP_USBD_EVT_DRV_EPTRANSFER: + if (NRF_USBD_EPIN_CHECK(p_event->drv_evt.data.eptransfer.ep)) + { + ret = endpoint_in_event_handler(p_inst, p_event); + } + else + { + ret = endpoint_out_event_handler(p_inst, p_event); + } + + break; + + case APP_USBD_EVT_DRV_SUSPEND: + { + /*Flush all block devices cache on suspend*/ + + for (size_t i = 0; i < p_msc->specific.inst.block_devs_count; ++i) + { + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[i]; + (void)nrf_blk_dev_ioctl(p_blkd, NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH, NULL); + } + + break; + } + + case APP_USBD_EVT_DRV_RESUME: + break; + + case APP_USBD_EVT_INST_APPEND: + { + /*Verify serial number string*/ + uint16_t const * p_serial_str = app_usbd_string_desc_get(APP_USBD_STRING_ID_SERIAL, 0); + if (p_serial_str == NULL) + { + return NRF_ERROR_NOT_SUPPORTED; + } + + size_t len = app_usbd_string_desc_length(p_serial_str) / sizeof(uint16_t); + if (len < APP_USBD_MSC_MINIMAL_SERIAL_STRING_SIZE) + { + return NRF_ERROR_NOT_SUPPORTED; + } + + for (size_t i = 1; i < len; ++i) + { + if (isxdigit(p_serial_str[i]) == 0) + { + return NRF_ERROR_NOT_SUPPORTED; + } + } + + break; + } + + case APP_USBD_EVT_INST_REMOVE: + { + break; + } + + case APP_USBD_EVT_STARTED: + { + /*Initialize all block devices*/ + ASSERT(p_msc->specific.inst.block_devs_count <= 16); + + for (size_t i = 0; i < p_msc->specific.inst.block_devs_count; ++i) + { + nrf_block_dev_t const * p_blk_dev = p_msc->specific.inst.pp_block_devs[i]; + ret = nrf_blk_dev_init(p_blk_dev, msc_blockdev_ev_handler, p_msc); + if (ret != NRF_SUCCESS) + { + continue; + } + + p_msc_ctx->blk_dev_init_mask |= 1u << i; + ASSERT(nrf_blk_dev_geometry(p_blk_dev)->blk_size <= + p_msc->specific.inst.block_buff_size); + } + + break; + } + + case APP_USBD_EVT_STOPPED: + { + /*Un-initialize all block devices*/ + ASSERT(p_msc->specific.inst.block_devs_count <= 16); + size_t i; + + for (i = 0; i < p_msc->specific.inst.block_devs_count; ++i) + { + nrf_block_dev_t const * p_blk_dev = p_msc->specific.inst.pp_block_devs[i]; + ret = nrf_blk_dev_uninit(p_blk_dev); + if (ret != NRF_SUCCESS) + { + continue; + } + + p_msc_ctx->blk_dev_init_mask &= ~(1u << i); + } + + break; + } + + default: + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + return ret; +} + + +/** + * @brief @ref app_usbd_class_methods_t::feed_descriptors + */ + +static bool msc_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static uint8_t ifaces = 0; + ifaces = app_usbd_class_iface_count_get(p_inst); + app_usbd_msc_t const * p_msc = msc_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size); + + static uint8_t i = 0; + + for (i = 0; i < ifaces; i++) + { + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface + + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, i); + + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_MSC_CLASS); // bInterfaceClass = MSC + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_msc->specific.inst.subclass); // bInterfaceSubclass (Industry Standard Command Block) + APP_USBD_CLASS_DESCRIPTOR_WRITE(p_msc->specific.inst.protocol); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + + static uint8_t endpoints = 0; + endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface); + + static uint8_t j = 0; + + for (j = 0; j < endpoints; j++) + { + // ENDPOINT DESCRIPTOR + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint + + static app_usbd_class_ep_conf_t const * p_cur_ep = NULL; + p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j); + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_BULK); // bmAttributes + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterval + } + + } + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + +const app_usbd_class_methods_t app_usbd_msc_class_methods = { + .event_handler = msc_event_handler, + .feed_descriptors = msc_feed_descriptors, +}; + +/** + * @brief Mark block device process. + * + * Common part of the @ref msc_blockdev_read_done_handler and @ref msc_blockdev_write_done_handler + * that marks the current processing state. + * + * @param p_blk_dev Block device handle. + * @param p_event Block device event. + */ +static void msc_blockdev_done_process(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_event_t const * p_event) +{ + app_usbd_class_inst_t const * p_inst = p_event->p_context; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + uint32_t blk_count = p_event->p_blk_req->blk_count; + uint32_t size = blk_count * p_msc_ctx->current.process.blk_size; + + p_msc_ctx->current.process.blk_idx += blk_count; + p_msc_ctx->current.process.size_left = + SUB_SAT0(p_msc_ctx->current.process.size_left, size); + p_msc_ctx->current.process.datalen_left = + SUB_SAT0(p_msc_ctx->current.process.datalen_left, size); + + p_msc_ctx->current.process.pending = false; +} + +/** + * @brief Block device read done event handler. + * + * @ref NRF_BLOCK_DEV_EVT_BLK_READ_DONE + * + * @param p_blk_dev Block device handle. + * @param p_event Block device event. + * + * */ +static void msc_blockdev_read_done_handler(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_event_t const * p_event) +{ + ret_code_t ret; + app_usbd_class_inst_t const * p_inst = p_event->p_context; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + app_usbd_msc_ctx_t * p_msc_ctx = msc_ctx_get(p_msc); + + NRF_LOG_DEBUG("read_done_handler: p_buff: %p, size: %u", + (uint32_t)p_event->p_blk_req->p_buff, + p_event->p_blk_req->blk_count); + + msc_buff_put(p_msc); + if (p_event->result == NRF_BLOCK_DEV_RESULT_SUCCESS) + { + msc_blockdev_done_process(p_blk_dev, p_event); + } + else + { + p_msc_ctx->current.transfer.abort = true; + } + + + ret = read_transfer_processor(p_inst); + if(ret == NRF_SUCCESS) + { + ret = read_blockmem_processor(p_inst); + } + if (ret != NRF_SUCCESS) + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } +} + + +/** + * @brief Block device write done event handler. + * + * @ref NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE + * + * @param p_blk_dev Block device handle. + * @param p_event Block device event. + * + * */ +static void msc_blockdev_write_done_handler(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_event_t const * p_event) +{ + ret_code_t ret; + app_usbd_class_inst_t const * p_inst = p_event->p_context; + app_usbd_msc_t const * p_msc = msc_get(p_inst); + + NRF_LOG_DEBUG("write_done_handler: p_buff: %p, size: %u", + (uint32_t)p_event->p_blk_req->p_buff, + p_event->p_blk_req->blk_count); + + msc_buff_free(p_msc); + if (p_event->result == NRF_BLOCK_DEV_RESULT_SUCCESS) + { + msc_blockdev_done_process(p_blk_dev, p_event); + } + else + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } + + ret = write_transfer_processor(p_inst); + if(ret == NRF_SUCCESS) + { + ret = write_blockmem_processor(p_inst); + } + if (ret != NRF_SUCCESS) + { + UNUSED_RETURN_VALUE(status_unsupported_start(p_inst)); + } +} + + +/** + * @brief Block device event handler. + * + * Mass storage block device event handler. Need to be pined to all block devices + * from initializer list. + * + * @param p_blk_dev Block device handle. + * @param p_event Block device event. + * + * */ +static void msc_blockdev_ev_handler(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_event_t const * p_event) +{ + switch (p_event->ev_type) + { + case NRF_BLOCK_DEV_EVT_INIT: + break; + + case NRF_BLOCK_DEV_EVT_UNINIT: + break; + + case NRF_BLOCK_DEV_EVT_BLK_READ_DONE: + CRITICAL_REGION_ENTER(); + msc_blockdev_read_done_handler(p_blk_dev, p_event); + CRITICAL_REGION_EXIT(); + break; + + case NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE: + CRITICAL_REGION_ENTER(); + msc_blockdev_write_done_handler(p_blk_dev, p_event); + CRITICAL_REGION_EXIT(); + break; + + default: + break; + } +} + +/** @} */ + +bool app_usbd_msc_sync(app_usbd_msc_t const * p_msc) +{ + bool rc = true; + ret_code_t ret = NRF_SUCCESS; + + for (size_t i = 0; i < p_msc->specific.inst.block_devs_count; ++i) + { + nrf_block_dev_t const * p_blkd = p_msc->specific.inst.pp_block_devs[i]; + bool flush_in_progress = true; + + ret = nrf_blk_dev_ioctl(p_blkd, + NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH, + &flush_in_progress); + + if ((ret != NRF_SUCCESS) || flush_in_progress) + { + rc = false; + } + } + + return rc; +} + + +#endif //NRF_MODULE_ENABLED(APP_USBD_MSC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.h similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.h index 7ca9c00..5a751a3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_MSC_H__ #define APP_USBD_MSC_H__ @@ -77,7 +77,7 @@ extern "C" { #ifdef DOXYGEN /** - * @brief Mass storage class instance type + * @brief Mass storage class instance type. * * @ref APP_USBD_CLASS_TYPEDEF */ @@ -97,7 +97,7 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_msc, /*lint -save -e407 */ /** - * @brief Events passed to user event handler + * @brief Events passed to user event handler. * * @note Example prototype of user event handler: * @@ -111,10 +111,10 @@ typedef enum app_usbd_msc_user_event_e { /*lint -restore*/ /** - * @brief Helper macro for defining MSC endpoints + * @brief Helper macro for defining MSC endpoints. * - * @param in_number Input endpoint number - * @param out_number Output endpoint number + * @param in_number Input endpoint number. + * @param out_number Output endpoint number. * */ #define APP_USBD_MSC_ENDPOINT_LIST(in_number, out_number) ( \ CONCAT_2(NRF_DRV_USBD_EPIN, in_number), \ @@ -122,15 +122,15 @@ typedef enum app_usbd_msc_user_event_e { ) /** - * @brief Global definition of app_usbd_msc_t class + * @brief Global definition of app_usbd_msc_t class. * - * @param instance_name Name of global instance - * @param interface_number Unique interface number - * @param user_ev_handler User event handler (optional) - * @param endpoint_list Input endpoint list (@ref nrf_drv_usbd_ep_t) - * @param blockdev_list Block device list + * @param instance_name Name of global instance. + * @param interface_number Unique interface number. + * @param user_ev_handler User event handler (optional). + * @param endpoint_list Input endpoint list (@ref nrf_drv_usbd_ep_t). + * @param blockdev_list Block device list. * @param workbuffer_size Work buffer size (need to fit into all block devices from - * block device list) + * block device list). * * @note This macro is just simplified version of @ref APP_USBD_MSC_GLOBAL_DEF_INTERNAL * @@ -150,11 +150,11 @@ typedef enum app_usbd_msc_user_event_e { /** - * @@brief Helper function to get class instance from MSC + * @@brief Helper function to get class instance from MSC. * - * @param[in] p_msc MSC instance (declared by @ref APP_USBD_MSC_GLOBAL_DEF) + * @param[in] p_msc MSC instance (declared by @ref APP_USBD_MSC_GLOBAL_DEF). * - * @return Base class instance + * @return Base class instance. */ static inline app_usbd_class_inst_t const * app_usbd_msc_class_inst_get(app_usbd_msc_t const * p_msc) @@ -163,11 +163,11 @@ app_usbd_msc_class_inst_get(app_usbd_msc_t const * p_msc) } /** - * @brief Helper function to get MSC from base class instance + * @brief Helper function to get MSC from base class instance. * - * @param[in] p_inst Base class instance + * @param[in] p_inst Base class instance. * - * @return MSC class handle + * @return MSC class handle. */ static inline app_usbd_msc_t const * app_usbd_msc_class_get(app_usbd_class_inst_t const * p_inst) { @@ -175,12 +175,12 @@ static inline app_usbd_msc_t const * app_usbd_msc_class_get(app_usbd_class_inst_ } /** - * @brief Synchronization of all block devices pined to MSC + * @brief Synchronization of all block devices pined to MSC. * - * @param[in] p_msc MSC instance (declared by @ref APP_USBD_MSC_GLOBAL_DEF) + * @param[in] p_msc MSC instance (declared by @ref APP_USBD_MSC_GLOBAL_DEF). * - * @retval true All block devices flushed data - * @retval false At least one block device has not flushed data + * @retval true All block devices flushed data. + * @retval false At least one block device has not flushed data. */ bool app_usbd_msc_sync(app_usbd_msc_t const * p_msc); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_desc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_desc.h similarity index 92% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_desc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_desc.h index 4c24a35..bb3c6ab 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_desc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_desc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_MSC_DESC_H__ #define APP_USBD_MSC_DESC_H__ @@ -55,9 +55,9 @@ extern "C" { */ /** - * @brief Initializer of interface descriptor for MSC class + * @brief Initializer of interface descriptor for MSC class. * - * @param interface_number Interface number + * @param interface_number Interface number. * @param subclass Subclass, @ref app_usbd_msc_subclass_t * @param protocol Protocol, @ref app_usbd_msc_protocol_t * */ @@ -74,11 +74,11 @@ extern "C" { /** - * @brief Initializer of endpoint descriptors for MSC class + * @brief Initializer of endpoint descriptors for MSC class. * - * @param endpoint_in IN endpoint - * @param endpoint_out OUT endpoint - * @param ep_size Endpoint size + * @param endpoint_in IN endpoint. + * @param endpoint_out OUT endpoint. + * @param ep_size Endpoint size. * */ #define APP_USBD_MSC_EP_DSC(endpoint_in, endpoint_out, ep_size) \ /*.bLength = */ sizeof(app_usbd_descriptor_ep_t), \ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_internal.h similarity index 50% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_internal.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_internal.h index 0f8977c..4d40057 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_internal.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_internal.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,11 +35,13 @@ * 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 APP_USBD_MSC_INTERNAL_H__ #define APP_USBD_MSC_INTERNAL_H__ +#include "app_util.h" + #ifdef __cplusplus extern "C" { #endif @@ -53,12 +55,39 @@ extern "C" { */ /** - * @brief Minimal serial string descriptor length + * @brief Minimal serial string descriptor length. * */ #define APP_USBD_MSC_MINIMAL_SERIAL_STRING_SIZE (12 + 1) /** - * @brief Forward declaration of Mass Storage Class type + * @brief Number of block buffers + * + * Number of buffers used for the transfer. + * The library is designed to work with double buffering. + * Not tested with other configuration. + */ +#define APP_USBD_MSC_BUFFER_CNT 2 + +/** + * @brief Create the name of the block buffer + * + * @param instance_name The name of the MSC instance + * + * @return The name of the block buffer used with the instance + */ +#define APP_USBD_MSC_BUFFER_NAME(instance_name) CONCAT_2(instance_name, _block) + +/** + * @brief Create the name of the block device list + * + * @param instance_name The name of the MSC instance + * + * @return The name of the block device list + */ +#define APP_USBD_MSC_BLKDEVS_NAME(instance_name) CONCAT_2(instance_name, _blkdevs) + +/** + * @brief Forward declaration of Mass Storage Class type. * */ APP_USBD_CLASS_FORWARD(app_usbd_msc); @@ -73,42 +102,42 @@ enum app_usbd_msc_user_event_e; /*lint -restore*/ /** - * @brief User event handler + * @brief User event handler. * - * @param[in] p_inst Class instance - * @param[in] event User event + * @param[in] p_inst Class instance. + * @param[in] event User event. * * */ typedef void (*app_usbd_msc_user_ev_handler_t)(app_usbd_class_inst_t const * p_inst, enum app_usbd_msc_user_event_e event); /** - * @brief MSC part of class instance data + * @brief MSC part of class instance data. */ typedef struct { - uint8_t const * p_raw_desc; //!< MSC descriptors - size_t raw_desc_size; //!< MSC descriptors size - void * p_block_buff; //!< Block buffer - size_t block_buff_size; //!< Block buffer size (typically 512 bytes) + void * p_block_buff; //!< Block buffer + size_t block_buff_size; //!< Block buffer size (typically 512 bytes) + size_t block_buff_count; //!< Number of buffers (typically 2) - nrf_block_dev_t const ** pp_block_devs; //!< Block devices list - size_t block_devs_count; //!< Block device list size + nrf_block_dev_t const ** pp_block_devs; //!< Block devices list + size_t block_devs_count; //!< Block device list size - app_usbd_msc_user_ev_handler_t user_ev_handler; //!< User event handler + app_usbd_msc_user_ev_handler_t user_ev_handler; //!< User event handler + + app_usbd_msc_subclass_t subclass; //!< MSC subclass + app_usbd_msc_protocol_t protocol; //!< MSC protocol } app_usbd_msc_inst_t; /** - * @brief Internal module state + * @brief Internal module state. */ typedef enum { APP_USBD_MSC_STATE_DISABLED, /**< Internal module state DISABLED */ APP_USBD_MSC_STATE_IDLE, /**< Internal module state IDLE */ APP_USBD_MSC_STATE_CBW, /**< Internal module state CBW */ APP_USBD_MSC_STATE_CMD_IN, /**< Internal module state CMD_IN */ - APP_USBD_MSC_STATE_CMD_OUT, /**< Internal module state CMD_OUT */ APP_USBD_MSC_STATE_DATA_IN, /**< Internal module state DATA_IN */ APP_USBD_MSC_STATE_DATA_OUT, /**< Internal module state DATA_OUT */ - APP_USBD_MSC_STATE_DATA_OUT_WAIT, /**< Internal module state DATA_OUT_WAIT */ APP_USBD_MSC_STATE_CSW, /**< Internal module state CSW */ APP_USBD_MSC_STATE_UNSUPPORTED, /**< Internal module state UNSUPPORTED */ APP_USBD_MSC_STATE_CBW_INVALID, /**< Endpoint is stalled until @@ -118,36 +147,49 @@ typedef enum { } app_usbd_msc_state_t; /** - * @brief MSC context + * @brief MSC context. * * */ typedef struct { + app_usbd_msc_state_t state; //!< Internal module state + app_usbd_msc_cbw_t cbw; //!< SCSI command block wrapper app_usbd_msc_csw_t csw; //!< SCSI Command status wrapper - app_usbd_msc_state_t state; //!< Internal module state - - struct { - uint8_t lun; //!< Current transfer blocks: logical unit - uint8_t csw_status; //!< Current CSW status - uint32_t blk_idx; //!< Current transfer: block index - uint32_t blk_datasize; //!< Current transfer: data size to transfer - uint32_t blk_size; //!< Current transfer: block size - uint32_t blk_count; //!< Current transfer: block count - uint32_t residue; //!< @ref app_usbd_msc_csw_t::residue - - bool trans_in_progress; //!< Transfer in progress flag - bool block_req_in_progress; //!< Block request in progress flag - size_t workbuff_pos; //!< Current buffer offset (double buffering mode) - uint8_t req_busy_mask; //!< Request bust mask (double buffering mode) - uint8_t trans_req_id; //!< Current transfered request (double buffering mode) - - nrf_block_req_t req; //!< Last processed block req (double buffering mode) + /** @brief Currently processed command with data */ + struct + { + /** @brief Buffer data */ + struct + { + uint8_t rd_idx; //!< Buffer read index + uint8_t d_count; //!< Number of blocks inside the buffer ready to process + uint8_t a_count; //!< Number of blocks allocated in the buffer + } buff; + /** @brief Currently transfered block */ + struct + { + size_t size_left; //!< Number of bytes left to transfer + size_t datalen_left; //!< Number of bytes left that was requested by the host + bool pending; //!< The flag marking the pending transfer + bool abort; //!< Something fails during reading - abort transfer and mark an error, + //!< Used for read access. + } transfer; + /** @brief The block currently processed by block device */ + struct + { + uint8_t lun; //!< The logical unit for current transfer block + size_t blk_size; //!< The size of the block of the selected lun + size_t size_left; //!< Number of bytes left to be processed by block device + size_t datalen_left; //!< Number of bytes left that was requested by the host + uint32_t blk_idx; //!< Current block index + bool pending; //!< The flag marking the pending transfer + bool abort; //!< Something fails during transfer - abort processing and mark an error, + //!< Used for write access. + } process; } current; - size_t resp_len; //!< Response length - - /*SCSI response container*/ + /** @brief SCSI response container*/ union { app_usbd_scsi_cmd_inquiry_resp_t inquiry; //!< @ref APP_USBD_SCSI_CMD_INQUIRY response app_usbd_scsi_cmd_requestsense_resp_t requestsense; //!< @ref APP_USBD_SCSI_CMD_REQUESTSENSE response @@ -161,45 +203,52 @@ typedef struct { /** - * @brief MSC configuration macro + * @brief MSC configuration macro. * * Used by @ref APP_USBD_MSC_GLOBAL_DEF * - * @param iface Interface number - * @param endpoints Endpoint list + * @param iface Interface number. + * @param endpoints Endpoint list. * */ #define APP_USBD_MSC_CONFIG(iface, endpoints) ((iface, BRACKET_EXTRACT(endpoints))) /** - * @brief Specific class constant data for MSC + * @brief Specific class constant data for MSC. * * @ref app_usbd_msc_inst_t */ #define APP_USBD_MSC_INSTANCE_SPECIFIC_DEC app_usbd_msc_inst_t inst; - /** - * @brief Configures MSC instance + * @brief Configures MSC instance. * - * @param descriptors Mass storage class descriptors (raw table) - * @param block_devs Block devices list - * @param block_buff Block buffer - * @param user_event_handler User event handler + * @param p_devs Block devices list that is array of pointers of @ref nrf_block_dev_t type. + * @param devs_cnt Number of block devices connected. + * @param p_buff Block buffer. + * @param block_size Total size of the single block in the buffer. + * @param block_cnt Number of available block buffers. + * @param user_event_handler User event handler. */ -#define APP_USBD_MSC_INST_CONFIG(descriptors, block_devs, block_buff, user_event_handler) \ - .inst = { \ - .p_raw_desc = descriptors, \ - .raw_desc_size = sizeof(descriptors), \ - .pp_block_devs = block_devs, \ - .block_devs_count = ARRAY_SIZE(block_devs), \ - .p_block_buff = block_buff, \ - .block_buff_size = sizeof(block_buff) / 2, \ - .user_ev_handler = user_event_handler, \ +#define APP_USBD_MSC_INST_CONFIG(p_devs, \ + devs_cnt, \ + p_buff, \ + block_size, \ + block_cnt, \ + user_event_handler) \ + .inst = { \ + .pp_block_devs = (p_devs), \ + .block_devs_count = (devs_cnt), \ + .p_block_buff = (p_buff), \ + .block_buff_size = (block_size), \ + .block_buff_count = (block_cnt), \ + .user_ev_handler = (user_event_handler), \ + .subclass = APP_USBD_MSC_SUBCLASS_TRANSPARENT, \ + .protocol = APP_USBD_MSC_PROTOCOL_BULK, \ } /** - * @brief Specific class data for MSC + * @brief Specific class data for MSC. * * @ref app_usbd_msc_ctx_t * */ @@ -207,10 +256,10 @@ typedef struct { /** - * @brief MSC descriptors config macro + * @brief MSC descriptors config macro. * - * @param interface_number Interface number - * @param ... Extracted endpoint list + * @param interface_number Interface number. + * @param ... Extracted endpoint list. * */ #define APP_USBD_MSC_DSC_CONFIG(interface_number, ...) { \ APP_USBD_MSC_INTERFACE_DSC(interface_number, \ @@ -222,34 +271,36 @@ typedef struct { } /** - * @brief Public MSC class interface + * @brief Public MSC class interface. * * */ extern const app_usbd_class_methods_t app_usbd_msc_class_methods; /** - * @brief Global definition of mass storage class instance + * @brief Global definition of mass storage class instance. */ -#define APP_USBD_MSC_GLOBAL_DEF_INTERNAL(instance_name, \ - interface_number, \ - user_ev_handler, \ - endpoint_list, \ - blockdev_list, \ - workbuffer_size) \ - static const uint8_t CONCAT_2(instance_name, _dsc)[] = \ - APP_USBD_MSC_DSC_CONFIG(interface_number, BRACKET_EXTRACT(endpoint_list)); \ - static const nrf_block_dev_t * CONCAT_2(instance_name, _blkdevs)[] = \ - { BRACKET_EXTRACT(blockdev_list) }; \ - static uint32_t CONCAT_2(instance_name, _block)[2 *(workbuffer_size) / sizeof(uint32_t)]; \ - APP_USBD_CLASS_INST_GLOBAL_DEF( \ - instance_name, \ - app_usbd_msc, \ - &app_usbd_msc_class_methods, \ - APP_USBD_MSC_CONFIG(interface_number, endpoint_list), \ - (APP_USBD_MSC_INST_CONFIG(CONCAT_2(instance_name, _dsc), \ - CONCAT_2(instance_name, _blkdevs), \ - CONCAT_2(instance_name, _block), \ - user_ev_handler)) \ +#define APP_USBD_MSC_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + user_ev_handler, \ + endpoint_list, \ + blockdev_list, \ + workbuffer_size) \ + static const nrf_block_dev_t * APP_USBD_MSC_BLKDEVS_NAME(instance_name)[] = \ + { BRACKET_EXTRACT(blockdev_list) }; \ + static uint32_t APP_USBD_MSC_BUFFER_NAME(instance_name) \ + [APP_USBD_MSC_BUFFER_CNT * CEIL_DIV(workbuffer_size, sizeof(uint32_t))]; \ + APP_USBD_CLASS_INST_GLOBAL_DEF( \ + instance_name, \ + app_usbd_msc, \ + &app_usbd_msc_class_methods, \ + APP_USBD_MSC_CONFIG(interface_number, endpoint_list), \ + (APP_USBD_MSC_INST_CONFIG(APP_USBD_MSC_BLKDEVS_NAME(instance_name), \ + ARRAY_SIZE(APP_USBD_MSC_BLKDEVS_NAME(instance_name)), \ + APP_USBD_MSC_BUFFER_NAME (instance_name), \ + sizeof(APP_USBD_MSC_BUFFER_NAME(instance_name)) \ + / APP_USBD_MSC_BUFFER_CNT, \ + APP_USBD_MSC_BUFFER_CNT, \ + user_ev_handler)) \ ) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h index 442d3ad..24013e9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_scsi.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_MSC_SCSI_H__ #define APP_USBD_MSC_SCSI_H__ @@ -66,35 +66,35 @@ extern "C" { */ /** - * @brief SCSI command set + * @brief SCSI command set. * * Mandatory (and some optional) commands required by SBC-2. * */ typedef enum { - APP_USBD_SCSI_CMD_TESTUNITREADY = 0x00, /**< TESTUNITREADY */ - APP_USBD_SCSI_CMD_REQUESTSENSE = 0x03, /**< REQUESTSENSE */ - APP_USBD_SCSI_CMD_FORMAT_UNIT = 0x04, /**< FORMAT_UNIT */ - APP_USBD_SCSI_CMD_READ6 = 0x08, /**< READ6 */ - APP_USBD_SCSI_CMD_WRITE6 = 0x0a, /**< WRITE6 */ - APP_USBD_SCSI_CMD_INQUIRY = 0x12, /**< INQUIRY */ - APP_USBD_SCSI_CMD_MODESELECT6 = 0x15, /**< MODESELECT6 */ - APP_USBD_SCSI_CMD_MODESENSE6 = 0x1a, /**< MODESENSE6 */ - APP_USBD_SCSI_CMD_STARTSTOPUNIT = 0x1b, /**< STARTSTOPUNIT */ - APP_USBD_SCSI_CMD_SENDDIAGNOSTIC = 0x1d, /**< SENDDIAGNOSTIC */ - APP_USBD_SCSI_CMD_PREVENTMEDIAREMOVAL = 0x1e, /**< PREVENTMEDIAREMOVAL */ - APP_USBD_SCSI_CMD_READCAPACITY10 = 0x25, /**< READCAPACITY10 */ - APP_USBD_SCSI_CMD_READ10 = 0x28, /**< READ10 */ - APP_USBD_SCSI_CMD_WRITE10 = 0x2a, /**< WRITE10 */ - APP_USBD_SCSI_CMD_MODESELECT10 = 0x55, /**< MODESELECT10 */ - APP_USBD_SCSI_CMD_MODESENSE10 = 0x5a, /**< MODESENSE10 */ + APP_USBD_SCSI_CMD_TESTUNITREADY = 0x00, /**< Test unit ready. */ + APP_USBD_SCSI_CMD_REQUESTSENSE = 0x03, /**< Request sense. */ + APP_USBD_SCSI_CMD_FORMAT_UNIT = 0x04, /**< Format unit. */ + APP_USBD_SCSI_CMD_READ6 = 0x08, /**< Read 6. */ + APP_USBD_SCSI_CMD_WRITE6 = 0x0A, /**< Write 6. */ + APP_USBD_SCSI_CMD_INQUIRY = 0x12, /**< Inquiry. */ + APP_USBD_SCSI_CMD_MODESELECT6 = 0x15, /**< Mode select 6. */ + APP_USBD_SCSI_CMD_MODESENSE6 = 0x1A, /**< Mode sense 6. */ + APP_USBD_SCSI_CMD_STARTSTOPUNIT = 0x1B, /**< Start/stop unit. */ + APP_USBD_SCSI_CMD_SENDDIAGNOSTIC = 0x1D, /**< Send diagnostic. */ + APP_USBD_SCSI_CMD_PREVENTMEDIAREMOVAL = 0x1E, /**< Prevent media removal. */ + APP_USBD_SCSI_CMD_READCAPACITY10 = 0x25, /**< Read capacity 10. */ + APP_USBD_SCSI_CMD_READ10 = 0x28, /**< Read 10. */ + APP_USBD_SCSI_CMD_WRITE10 = 0x2A, /**< Write 10. */ + APP_USBD_SCSI_CMD_MODESELECT10 = 0x55, /**< Mode select 10. */ + APP_USBD_SCSI_CMD_MODESENSE10 = 0x5A, /**< Mode sense 10. */ } app_usbd_scsi_cmd_t; #pragma pack(push, 1) /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_REQUESTSENSE command + * @brief Payload of @ref APP_USBD_SCSI_CMD_REQUESTSENSE command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_REQUESTSENSE @@ -125,13 +125,13 @@ typedef struct { #define APP_USBD_SCSI_CMD_REQSENSE_FLAG_DATAPROTECT 0x07 /**< Bits 3...0 @ref app_usbd_scsi_cmd_requestsense_resp_t::flags */ #define APP_USBD_SCSI_CMD_REQSENSE_FLAG_BLANKCHECK 0x08 /**< Bits 3...0 @ref app_usbd_scsi_cmd_requestsense_resp_t::flags */ #define APP_USBD_SCSI_CMD_REQSENSE_FLAG_VENDORSPECIFIC 0x09 /**< Bits 3...0 @ref app_usbd_scsi_cmd_requestsense_resp_t::flags */ -#define APP_USBD_SCSI_CMD_REQSENSE_FLAG_ABORTEDCOMMAND 0x0b /**< Bits 3...0 @ref app_usbd_scsi_cmd_requestsense_resp_t::flags */ +#define APP_USBD_SCSI_CMD_REQSENSE_FLAG_ABORTEDCOMMAND 0x0B /**< Bits 3...0 @ref app_usbd_scsi_cmd_requestsense_resp_t::flags */ #define APP_USBD_SCSI_CMD_TESTUNITREADY_LEN 6 /**< @ref APP_USBD_SCSI_CMD_TESTUNITREADY command length*/ /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_REQUESTSENSE response + * @brief Payload of @ref APP_USBD_SCSI_CMD_REQUESTSENSE response. */ typedef struct { uint8_t code; //!< Response code: APP_USBD_SCSI_CMD_REQSENSE_CODE_* @@ -147,7 +147,7 @@ typedef struct { } app_usbd_scsi_cmd_requestsense_resp_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_INQUIRY command + * @brief Payload of @ref APP_USBD_SCSI_CMD_INQUIRY command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_INQUIRY @@ -169,13 +169,13 @@ typedef struct { #define APP_USBD_MSC_SCSI_INQ_TYPE_CD_DVD 0x05 /**< CD/DVD device */ #define APP_USBD_MSC_SCSI_INQ_TYPE_OPTICAL 0x07 /**< Optical Memory */ #define APP_USBD_MSC_SCSI_INQ_TYPE_MC 0x08 /**< Medium Changer */ -#define APP_USBD_MSC_SCSI_INQ_TYPE_ARRAY 0x0c /**< Storage Array Controller */ -#define APP_USBD_MSC_SCSI_INQ_TYPE_ENCLOSURE 0x0d /**< Enclosure Services */ -#define APP_USBD_MSC_SCSI_INQ_TYPE_RBC 0x0e /**< Simplified Direct Access */ -#define APP_USBD_MSC_SCSI_INQ_TYPE_OCRW 0x0f /**< Optical card reader/writer */ +#define APP_USBD_MSC_SCSI_INQ_TYPE_ARRAY 0x0C /**< Storage Array Controller */ +#define APP_USBD_MSC_SCSI_INQ_TYPE_ENCLOSURE 0x0D /**< Enclosure Services */ +#define APP_USBD_MSC_SCSI_INQ_TYPE_RBC 0x0E /**< Simplified Direct Access */ +#define APP_USBD_MSC_SCSI_INQ_TYPE_OCRW 0x0F /**< Optical card reader/writer */ #define APP_USBD_MSC_SCSI_INQ_TYPE_BCC 0x10 /**< Bridge Controller Commands */ #define APP_USBD_MSC_SCSI_INQ_TYPE_OSD 0x11 /**< Object-based Storage */ -#define APP_USBD_MSC_SCSI_INQ_TYPE_NONE 0x1f /**< No Peripheral */ +#define APP_USBD_MSC_SCSI_INQ_TYPE_NONE 0x1F /**< No Peripheral */ #define APP_USBD_MSC_SCSI_INQ_FLAG1_RMB 0x80 /**< Removable Medium */ @@ -190,7 +190,7 @@ typedef struct { #define APP_USBD_MSC_SCSI_INQ_FLAG2_HISUP 0x10 /**< Hierarchal LUN addressing */ #define APP_USBD_MSC_SCSI_INQ_FLAG2_RSP_SPC2 0x02 /**< SPC-2 / SPC-3 response format*/ /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_INQUIRY response + * @brief Payload of @ref APP_USBD_SCSI_CMD_INQUIRY response. */ typedef struct { uint8_t qualtype; //!< Bits 5-7: Peripheral qualifier; Bits 0-4: Peripheral device type @@ -207,7 +207,7 @@ typedef struct { } app_usbd_scsi_cmd_inquiry_resp_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_READ6 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_READ6 command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_READ6 @@ -218,7 +218,7 @@ typedef struct { } app_usbd_scsi_cmd_read6_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_WRITE6 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_WRITE6 command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_WRITE6 @@ -229,7 +229,7 @@ typedef struct { } app_usbd_scsi_cmd_write6_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE6 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE6 command. */ typedef struct { uint8_t opcode; //!<* @ref APP_USBD_SCSI_CMD_MODESENSE6 @@ -241,7 +241,7 @@ typedef struct { } app_usbd_scsi_cmd_modesense6_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE6 response + * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE6 response. */ typedef struct { uint8_t mdlen; //!< Mode data length @@ -251,7 +251,7 @@ typedef struct { } app_usbd_scsi_cmd_modesense6_resp_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_READCAPACITY10 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_READCAPACITY10 command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_READCAPACITY10 @@ -263,7 +263,7 @@ typedef struct { } app_usbd_scsi_cmd_readcapacity10_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_READCAPACITY10 response + * @brief Payload of @ref APP_USBD_SCSI_CMD_READCAPACITY10 response. */ typedef struct { uint8_t lba[4]; //!< Returned logical block address (LBA) @@ -271,7 +271,7 @@ typedef struct { } app_usbd_scsi_cmd_readcapacity10_resp_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_READ10 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_READ10 command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_READ10 @@ -283,7 +283,7 @@ typedef struct { } app_usbd_scsi_cmd_read10_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_WRITE10 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_WRITE10 command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_WRITE10 @@ -295,7 +295,7 @@ typedef struct { } app_usbd_scsi_cmd_write10_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE10 command + * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE10 command. */ typedef struct { uint8_t opcode; //!< @ref APP_USBD_SCSI_CMD_MODESENSE10 @@ -308,7 +308,7 @@ typedef struct { } app_usbd_scsi_cmd_modesense10_t; /** - * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE10 response + * @brief Payload of @ref APP_USBD_SCSI_CMD_MODESENSE10 response. */ typedef struct { uint8_t mdlen[2]; //!< Mode data length diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_types.h similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_types.h index 6e63101..5e02299 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/usbd/class/msc/app_usbd_msc_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/msc/app_usbd_msc_types.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 APP_USBD_MSC_TYPES_H__ #define APP_USBD_MSC_TYPES_H__ @@ -61,19 +61,23 @@ extern "C" { #define APP_USBD_MSC_CLASS 0x08 /** - * @brief MSC subclass possible value + * @brief MSC subclass possible value. */ typedef enum { - APP_USBD_MSC_SUBCLASS_RBC = 0x01, /**< Reduced Block Commands */ - APP_USBD_MSC_SUBCLASS_ATAPI = 0x02, /**< CD/DVD devices */ - APP_USBD_MSC_SUBCLASS_QIC_157 = 0x03, /**< Tape devices */ - APP_USBD_MSC_SUBCLASS_UFI = 0x04, /**< Floppy disk drives */ - APP_USBD_MSC_SUBCLASS_SFF_8070I = 0x05, /**< Floppy disk drives */ - APP_USBD_MSC_SUBCLASS_TRANSPARENT = 0x06, /**< Determined by INQUIRY */ + APP_USBD_MSC_SUBCLASS_NOT_REPORTED = 0x00, /**< Command set not reported */ + APP_USBD_MSC_SUBCLASS_RBC = 0x01, /**< Reduced Block Commands */ + APP_USBD_MSC_SUBCLASS_ATAPI = 0x02, /**< CD/DVD devices */ + APP_USBD_MSC_SUBCLASS_QIC_157 = 0x03, /**< Tape devices */ + APP_USBD_MSC_SUBCLASS_UFI = 0x04, /**< Floppy disk drives */ + APP_USBD_MSC_SUBCLASS_SFF_8070I = 0x05, /**< Floppy disk drives */ + APP_USBD_MSC_SUBCLASS_TRANSPARENT = 0x06, /**< Determined by INQUIRY */ + APP_USBD_MSC_SUBCLASS_LSD_FS = 0x07, /**< LSD FS specified negitiation */ + APP_USBD_MSC_SUBCLASS_IEEE_1667 = 0x08, /**< IEEE 1607 */ + APP_USBD_MSC_SUBCLASS_VENDOR = 0xFF, /**< Vendor specific */ } app_usbd_msc_subclass_t; /** - * @brief MSC protocol possible value + * @brief MSC protocol possible value. * * @note The USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport specification is approved * for use only with full-speed floppy disk drives. CBI shall not be used in high-speed @@ -83,25 +87,28 @@ typedef enum { APP_USBD_MSC_PROTOCOL_CBI = 0x00, /**< Command/Bulk/Interrupt */ APP_USBD_MSC_PROTOCOL_CBI_ALT = 0x01, /**< W/o command completion */ APP_USBD_MSC_PROTOCOL_BULK = 0x50, /**< Bulk-only */ + APP_USBD_MSC_PROTOCOL_UAS = 0x62, /**< UAS */ + APP_USBD_MSC_PROTOCOL_VENDOR = 0xFF, /**< Vendor specific */ } app_usbd_msc_protocol_t; /** * @brief MSC USB requests @ref nrf_drv_usbd_setup_t::bmRequestType - * - * @note Requests are limited only to @ref APP_USBD_MSC_PROTOCOL_BULK protocol type. */ typedef enum { - APP_USBD_MSC_REQ_BULK_RESET = 0xFF, /**< Mass Storage Reset */ - APP_USBD_MSC_REQ_GET_MAX_LUN = 0xFE, /**< Get Max LUN */ + APP_USBD_MSC_REQ_ADSC = 0x00, /**< Accept Device-Specific Command */ + APP_USBD_MSC_REQ_GET_REQS = 0xFC, /**< Get Requests */ + APP_USBD_MSC_REQ_PUT_REQS = 0xFD, /**< Put Requests */ + APP_USBD_MSC_REQ_GET_MAX_LUN = 0xFE, /**< Get Max LUN */ + APP_USBD_MSC_REQ_BULK_RESET = 0xFF, /**< Mass Storage Reset */ } app_usbd_msc_req_t; #pragma pack(push, 1) -#define APP_USBD_MSC_CBW_SIGNATURE "USBC" /**< CBW signature */ -#define APP_USBD_MSC_CBW_DIRECTION_IN (1u <<7) /**< CBW direction flag */ +#define APP_USBD_MSC_CBW_SIGNATURE {'U', 'S', 'B', 'C'} /**< CBW signature */ +#define APP_USBD_MSC_CBW_DIRECTION_IN (1u << 7) /**< CBW direction flag */ /** - * @brief Command Block Wrapper (CBW) + * @brief Command Block Wrapper (CBW). */ typedef struct { uint8_t signature[4]; /**< "USBC" (hex: 0x43425355 little-endian) */ @@ -113,14 +120,14 @@ typedef struct { uint8_t cdb[16]; /**< Command Data Block payload */ } app_usbd_msc_cbw_t; -#define APP_USBD_MSC_CSW_SIGNATURE "USBS" /**< CSW signature */ +#define APP_USBD_MSC_CSW_SIGNATURE {'U', 'S', 'B', 'S'} /**< CSW signature */ -#define APP_USBD_MSC_CSW_STATUS_PASS 0x00 /**< CSW status: Command Passed */ -#define APP_USBD_MSC_CSW_STATUS_FAIL 0x01 /**< CSW status: Command Failed */ -#define APP_USBD_MSC_CSW_STATUS_PE 0x02 /**< CSW status: Phase Error */ +#define APP_USBD_MSC_CSW_STATUS_PASS 0x00 /**< CSW status: Command Passed */ +#define APP_USBD_MSC_CSW_STATUS_FAIL 0x01 /**< CSW status: Command Failed */ +#define APP_USBD_MSC_CSW_STATUS_PE 0x02 /**< CSW status: Phase Error */ /** - * @brief Command Status Wrapper (CSW) + * @brief Command Status Wrapper (CSW). */ typedef struct { uint8_t signature[4]; /**< "USBS" (hex: 0x53425355 little-endian) */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.c new file mode 100644 index 0000000..1f5c36f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.c @@ -0,0 +1,374 @@ +/** + * Copyright (c) 2017 - 2019, 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(APP_USBD_NRF_DFU_TRIGGER) + +#include +#include +#include "app_usbd.h" +#include "app_usbd_nrf_dfu_trigger.h" +#include "app_usbd_string_desc.h" +#include "nrf_gpio.h" + +/** + * @defgroup app_usbd_nrf_dfu_trigger_internal USBD Nordic DFU Trigger internals + * @{ + * @ingroup app_usbd_nrf_dfu_trigger + * @internal + */ + +#define NRF_LOG_MODULE_NAME usbd_nrf_dfu_trigger + +#if APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#else //APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif //APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/** + * @brief Auxiliary function to access DFU Trigger instance data. + * + * @param[in] p_inst Class instance data. + * + * @return DFU Trigger instance data @ref app_usbd_nrf_dfu_trigger_t + */ +static inline app_usbd_nrf_dfu_trigger_t const * nrf_dfu_trigger_get(app_usbd_class_inst_t const * p_inst) +{ + ASSERT(p_inst != NULL); + return (app_usbd_nrf_dfu_trigger_t const *)p_inst; +} + +/** + * @brief Auxiliary function to access DFU Trigger context data. + * + * @param[in] p_dfu DFU Trigger instance data. + * + * @return DFU Trigger context data @ref app_usbd_nrf_dfu_trigger_ctx_t + */ +static inline app_usbd_nrf_dfu_trigger_ctx_t * nrf_dfu_trigger_ctx_get( + app_usbd_nrf_dfu_trigger_t const * p_dfu) +{ + ASSERT(p_dfu != NULL); + ASSERT(p_dfu->specific.p_data != NULL); + return &p_dfu->specific.p_data->ctx; +} + +/** + * @brief Internal SETUP standard IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS if request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported. + */ +static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + /* Only Get Descriptor standard IN request is supported by DFU class */ + if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) + && + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + { + size_t dsc_len = 0; + size_t max_size; + + uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size); + /* Try to find descriptor in class internals*/ + ret_code_t ret = app_usbd_class_descriptor_find(p_inst, + p_setup_ev->setup.wValue.hb, + p_setup_ev->setup.wValue.lb, + p_trans_buff, + &dsc_len); + if (ret != NRF_ERROR_NOT_FOUND) + { + ASSERT(dsc_len < NRF_DRV_USBD_EPSIZE); + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_trans_buff, dsc_len); + } + } + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Internal SETUP standard OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS if request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported. + * @retval NRF_ERROR_FORBIDDEN if endpoint stall cannot be cleared because of internal state. + */ +static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + + switch (p_setup_ev->setup.bRequest) + { + default: + break; + } + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief User event handler. + * + * @param[in] p_inst Class instance. + * @param[in] event user Event type. + */ +static inline void user_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_nrf_dfu_trigger_user_event_t event) +{ + app_usbd_nrf_dfu_trigger_t const * p_dfu = nrf_dfu_trigger_get(p_inst); + if (p_dfu->specific.inst.user_ev_handler != NULL) + { + p_dfu->specific.inst.user_ev_handler(p_inst, event); + } +} + +/** + * @brief Internal SETUP class IN request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS if request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported. + */ +static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_nrf_dfu_trigger_t const * p_dfu = nrf_dfu_trigger_get(p_inst); + + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_NRF_DFU_TRIGGER_REQ_NORDIC_INFO: + if (p_setup_ev->setup.wLength.w != sizeof(app_usbd_nrf_dfu_trigger_nordic_info_t)) + { + return NRF_ERROR_NOT_SUPPORTED; + } + return app_usbd_core_setup_rsp(&p_setup_ev->setup, + p_dfu->specific.inst.p_dfu_info, + sizeof(app_usbd_nrf_dfu_trigger_nordic_info_t)); + + case APP_USBD_NRF_DFU_TRIGGER_REQ_SEM_VER: + return app_usbd_core_setup_rsp(&p_setup_ev->setup, + p_dfu->specific.inst.p_sem_ver, + p_dfu->specific.inst.sem_ver_size); + + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Internal SETUP class OUT request handler. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS if request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported. + */ +static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + app_usbd_nrf_dfu_trigger_t const * p_dfu = nrf_dfu_trigger_get(p_inst); + app_usbd_nrf_dfu_trigger_ctx_t * p_dfu_ctx = nrf_dfu_trigger_ctx_get(p_dfu); + + switch (p_setup_ev->setup.bRequest) + { + case APP_USBD_NRF_DFU_TRIGGER_REQ_DETACH: + { + NRF_LOG_DEBUG("Entering DFU Mode"); + p_dfu_ctx->state = APP_USBD_NRF_DFU_TRIGGER_STATE_DETACH; + user_event_handler(p_inst, APP_USBD_NRF_DFU_TRIGGER_USER_EVT_DETACH); + return NRF_SUCCESS; + } + default: + break; + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief Control endpoint handle. + * + * @param[in] p_inst Generic class instance. + * @param[in] p_setup_ev Setup event. + * + * @return Standard error code. + * @retval NRF_SUCCESS if request handled correctly. + * @retval NRF_ERROR_NOT_SUPPORTED if request is not supported. + */ +static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_setup_evt_t const * p_setup_ev) +{ + ASSERT(p_inst != NULL); + ASSERT(p_setup_ev != NULL); + + if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_in(p_inst, p_setup_ev); + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_in(p_inst, p_setup_ev); + default: + break; + } + } + else /* APP_USBD_SETUP_REQDIR_OUT */ + { + switch (app_usbd_setup_req_typ(p_setup_ev->setup.bmRequestType)) + { + case APP_USBD_SETUP_REQTYPE_STD: + return setup_req_std_out(p_inst, p_setup_ev); + case APP_USBD_SETUP_REQTYPE_CLASS: + return setup_req_class_out(p_inst, p_setup_ev); + default: + break; + } + } + + return NRF_ERROR_NOT_SUPPORTED; +} + +/** + * @brief @ref app_usbd_class_methods_t::event_handler + */ +static ret_code_t nrf_dfu_trigger_event_handler(app_usbd_class_inst_t const * p_inst, + app_usbd_complex_evt_t const * p_event) +{ + ASSERT(p_inst != NULL); + ASSERT(p_event != NULL); + + ret_code_t ret = NRF_SUCCESS; + switch (p_event->app_evt.type) + { + case APP_USBD_EVT_DRV_SOF: + break; + case APP_USBD_EVT_DRV_RESET: + break; + case APP_USBD_EVT_DRV_SETUP: + ret = setup_event_handler(p_inst, (app_usbd_setup_evt_t const *) p_event); + break; + case APP_USBD_EVT_DRV_EPTRANSFER: + break; + case APP_USBD_EVT_DRV_SUSPEND: + break; + case APP_USBD_EVT_DRV_RESUME: + break; + case APP_USBD_EVT_INST_APPEND: + break; + case APP_USBD_EVT_INST_REMOVE: + break; + case APP_USBD_EVT_STARTED: + break; + case APP_USBD_EVT_STOPPED: + break; + default: + ret = NRF_ERROR_NOT_SUPPORTED; + break; + } + + return ret; +} + +/** + * @brief @ref app_usbd_class_methods_t::feed_descriptors + */ +static bool nrf_dfu_trigger_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx, + app_usbd_class_inst_t const * p_inst, + uint8_t * p_buff, + size_t max_size) +{ + static app_usbd_class_iface_conf_t const * p_cur_iface = NULL; + p_cur_iface = app_usbd_class_iface_get(p_inst, 0); + app_usbd_nrf_dfu_trigger_t const * p_dfu = nrf_dfu_trigger_get(p_inst); + + APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size) + + /* INTERFACE DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(sizeof(app_usbd_descriptor_iface_t)); // bLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType + APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting + APP_USBD_CLASS_DESCRIPTOR_WRITE(0); // bNumEndpoints + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_NRF_DFU_TRIGGER_CLASS); // bInterfaceClass + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_NRF_DFU_TRIGGER_SUBCLASS); // bInterfaceSubClass + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_NRF_DFU_TRIGGER_PROTOCOL_RUNTIME); // bInterfaceProtocol + APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface + + /* FUNCTIONAL DESCRIPTOR */ + APP_USBD_CLASS_DESCRIPTOR_WRITE(sizeof(app_usbd_nrf_dfu_trigger_desc_func_t)); // bFunctionLength + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_NRF_DFU_TRIGGER_CS_FUNCTIONAL); // bDescriptorType + APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_NRF_DFU_TRIGGER_BIT_CAN_DNLOAD | + APP_USBD_NRF_DFU_TRIGGER_BIT_WILL_DETACH); // bmAttribute + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(p_dfu->specific.inst.detach_timeout)); // wDetachTimeOut LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(p_dfu->specific.inst.detach_timeout)); // wDetachTimeOut MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(p_dfu->specific.inst.transfer_size)); // wTransferSize LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(p_dfu->specific.inst.transfer_size)); // wTransferSize MSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(p_dfu->specific.inst.bcd_dfu)); // bcdDFUVersion LSB + APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(p_dfu->specific.inst.bcd_dfu)); // bcdDFUVersion MSB + + APP_USBD_CLASS_DESCRIPTOR_END(); +} + +const app_usbd_class_methods_t app_usbd_nrf_dfu_trigger_class_methods = { + .event_handler = nrf_dfu_trigger_event_handler, + .feed_descriptors = nrf_dfu_trigger_feed_descriptors, +}; + + +#endif //NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.h new file mode 100644 index 0000000..6345251 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.h @@ -0,0 +1,166 @@ +/** + * Copyright (c) 2017 - 2019, 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 APP_USBD_NRF_DFU_TRIGGER_H__ +#define APP_USBD_NRF_DFU_TRIGGER_H__ + +#include +#include + +#include "nrf_drv_usbd.h" +#include "nrf_block_dev.h" +#include "app_usbd_class_base.h" +#include "app_usbd.h" +#include "app_usbd_core.h" +#include "app_usbd_descriptor.h" + +#include "app_usbd_nrf_dfu_trigger_types.h" +#include "app_usbd_nrf_dfu_trigger_internal.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_nrf_dfu_trigger USB Nordic DFU Trigger class + * @ingroup app_usbd + * + * @brief @tagAPI52840 Module with types, definitions, + * and API used by the USB Nordic DFU Trigger class. + * + * @{ + */ + +#ifdef DOXYGEN +/** + * @brief Nordic DFU Trigger class instance type. + * + * @ref APP_USBD_CLASS_TYPEDEF + */ +typedef struct { } app_usbd_nrf_dfu_trigger_t; +#else +/*lint -save -e10 -e26 -e123 -e505 */ +APP_USBD_CLASS_NO_EP_TYPEDEF(app_usbd_nrf_dfu_trigger, \ + APP_USBD_NRF_DFU_TRIGGER_CONFIG(0), \ + APP_USBD_NRF_DFU_TRIGGER_INSTANCE_SPECIFIC_DEC, \ + APP_USBD_NRF_DFU_TRIGGER_DATA_SPECIFIC_DEC \ +); +#endif + +/*lint -restore*/ + + +/*lint -save -e407 */ + +/** + * @brief Events passed to user event handler. + * + * @note Example prototype of user event handler: + * + * void dfu_user_ev_handler(app_usbd_class_inst_t const * p_inst, + * app_usbd_nrf_dfu_trigger_user_event_t event); + */ +typedef enum app_usbd_nrf_dfu_trigger_user_event_e { + APP_USBD_NRF_DFU_TRIGGER_USER_EVT_DETACH, +} app_usbd_nrf_dfu_trigger_user_event_t; + +/*lint -restore*/ + +/** + * @brief Global definition of app_usbd_nrf_dfu_trigger_t class. + * + * @param instance_name Name of global instance. + * @param interface_number Unique interface number. + * @param p_nordic_dfu Pointer to @ref app_usbd_nrf_dfu_trigger_nordic_info_t structure. + * @param sem_ver_str Semantic version string. + * @param user_ev_handler User event handler (optional). + * + * @note This macro is just simplified version of @ref APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF_INTERNAL + * + */ +/*lint -save -emacro(26 64 123 505 651, APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF)*/ +#define APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF(instance_name, \ + interface_number, \ + p_nordic_dfu, \ + sem_ver_str, \ + user_ev_handler) \ + APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + 0, \ + 0, \ + p_nordic_dfu, \ + sem_ver_str, \ + user_ev_handler) +/*lint -restore*/ + +/** + * @brief Helper function to get class instance from Nordic DFU Trigger. + * + * @param[in] p_dfu Nordic DFU Trigger instance + * (declared by @ref APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF) + * + * @return Base class instance + */ +static inline app_usbd_class_inst_t const * +app_usbd_nrf_dfu_trigger_class_inst_get(app_usbd_nrf_dfu_trigger_t const * p_dfu) +{ + return &p_dfu->base; +} + +/** + * @brief Helper function to get DFU from base class instance. + * + * @param[in] p_inst Base class instance. + * + * @return DFU class handle. + */ +static inline app_usbd_nrf_dfu_trigger_t const * +app_usbd_nrf_dfu_trigger_class_get( app_usbd_class_inst_t const * p_inst) +{ + return (app_usbd_nrf_dfu_trigger_t const *)p_inst; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_NRF_DFU_TRIGGER_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_internal.h new file mode 100644 index 0000000..551d880 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_internal.h @@ -0,0 +1,203 @@ +/** + * Copyright (c) 2017 - 2019, 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 APP_USBD_NRF_DFU_TRIGGER_INTERNAL_H__ +#define APP_USBD_NRF_DFU_TRIGGER_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_nrf_dfu_trigger_internals USB Nordic DFU Trigger internals + * @ingroup app_usbd_nrf_dfu_trigger + * + * @brief @tagAPI52840 Internals of the USB Nordic DFU Trigger class. + * @{ + */ + +/** + * @brief Forward declaration of Nordic DFU Trigger Class type. + * + */ +APP_USBD_CLASS_FORWARD(app_usbd_nrf_dfu_trigger); + +/*lint -save -e165*/ +/** + * @brief Forward declaration of @ref app_usbd_nrf_dfu_trigger_user_event_e + * + */ +enum app_usbd_nrf_dfu_trigger_user_event_e; + +/*lint -restore*/ + +/** + * @brief User event handler. + * + * @param[in] p_inst Class instance. + * @param[in] event User event. + * + * */ +typedef void (*app_usbd_nrf_dfu_trigger_user_ev_handler_t)( + app_usbd_class_inst_t const * p_inst, + enum app_usbd_nrf_dfu_trigger_user_event_e event); + +/** + * @brief Nordic DFU Trigger part of class instance data. + */ +typedef struct { + size_t const sem_ver_size; //!< Semantic string size + uint16_t const detach_timeout; //!< Detach timeout in ms - for compatibility with DFU spec. + uint16_t const transfer_size; //!< Transfer size - for compatibility with DFU spec. + uint16_t const bcd_dfu; //!< DFU spec version. + uint8_t const * p_sem_ver; //!< Pointer to semantic version string + + app_usbd_nrf_dfu_trigger_nordic_info_t const * p_dfu_info; //!< Pointer to Nordic DFU Info + + app_usbd_nrf_dfu_trigger_user_ev_handler_t user_ev_handler; //!< User event handler +} app_usbd_nrf_dfu_trigger_inst_t; + +/** + * @brief Internal module state. + * + * @note For future compatibility with DFU class. + */ +typedef enum { + APP_USBD_NRF_DFU_TRIGGER_STATE_IDLE, /**< Internal module state IDLE */ + APP_USBD_NRF_DFU_TRIGGER_STATE_DETACH, /**< Internal module state DETACH */ +} app_usbd_nrf_dfu_trigger_state_t; + +/** + * @brief Nordic DFU Trigger context. + * + * */ +typedef struct { + app_usbd_nrf_dfu_trigger_state_t state; //!< Internal module state +} app_usbd_nrf_dfu_trigger_ctx_t; + + +/** + * @brief Nordic DFU Trigger configuration macro. + * + * Used by @ref APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF + * + * @param iface Interface number. + * */ +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG(iface) (iface) + + +/** + * @brief Specific class constant data for Nordic DFU Trigger. + * + * @ref app_usbd_nrf_dfu_trigger_inst_t + */ +#define APP_USBD_NRF_DFU_TRIGGER_INSTANCE_SPECIFIC_DEC app_usbd_nrf_dfu_trigger_inst_t inst; + + +/** + * @brief Configures Nordic DFU Trigger instance. + * + * @param user_event_handler User event handler. + * @param p_nordic_dfu Pointer to @ref app_usbd_nrf_dfu_trigger_nordic_info_t structure. + * @param sem_ver_str Semantic version string. + * @param timeout Detach timeout in ms - left for compatibility with USB DFU spec. + * @param size Transfer size in bytes - left for compatibility with USB DFU spec. + * @param bcd USB DFU specification version. + */ +#define APP_USBD_NRF_DFU_TRIGGER_INST_CONFIG(user_event_handler, \ + p_nordic_dfu, \ + sem_ver_str, \ + timeout, \ + size, \ + bcd) \ + .inst = { \ + .user_ev_handler = user_event_handler, \ + .p_dfu_info = p_nordic_dfu, \ + .p_sem_ver = sem_ver_str, \ + .sem_ver_size = sizeof(sem_ver_str), \ + .transfer_size = size, \ + .detach_timeout = timeout, \ + .bcd_dfu = bcd, \ + } + +/** + * @brief Specific class data for Nordic DFU Trigger. + * + * @ref app_usbd_nrf_dfu_trigger_ctx_t + * */ +#define APP_USBD_NRF_DFU_TRIGGER_DATA_SPECIFIC_DEC app_usbd_nrf_dfu_trigger_ctx_t ctx; + + +/** + * @brief Public Nordic DFU Trigger class interface. + */ +extern const app_usbd_class_methods_t app_usbd_nrf_dfu_trigger_class_methods; + +/** + * @brief Global definition of Nordic DFU Trigger instance. + */ +#define APP_USBD_NRF_DFU_TRIGGER_GLOBAL_DEF_INTERNAL(instance_name, \ + interface_number, \ + detach_timeout, \ + transfer_size, \ + p_nordic_dfu, \ + sem_ver_str, \ + user_ev_handler) \ + APP_USBD_CLASS_INST_NO_EP_GLOBAL_DEF( \ + instance_name, \ + app_usbd_nrf_dfu_trigger, \ + &app_usbd_nrf_dfu_trigger_class_methods, \ + APP_USBD_NRF_DFU_TRIGGER_CONFIG((interface_number)), \ + (APP_USBD_NRF_DFU_TRIGGER_INST_CONFIG(user_ev_handler, \ + p_nordic_dfu, \ + sem_ver_str, \ + detach_timeout, \ + transfer_size, \ + 0x0110)) \ + ) + + +/** @} */ + + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_NRF_DFU_TRIGGER_INTERNAL_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_types.h new file mode 100644 index 0000000..77b4b2b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger_types.h @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2017 - 2019, 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 APP_USBD_NRF_DFU_TRIGGER_TYPES_H__ +#define APP_USBD_NRF_DFU_TRIGGER_TYPES_H__ + +#include "app_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup app_usbd_nrf_dfu_trigger_types USB Nordic DFU Trigger types + * @ingroup app_usbd_nrf_dfu_trigger + * + * @brief @tagAPI52840 Types used in the USB Nordic DFU Trigger class. + * @{ + */ + +/** @brief Nordic DFU Trigger class definition in interface descriptor. + * + * @ref app_usbd_descriptor_iface_t::bInterfaceClass + * */ +#define APP_USBD_NRF_DFU_TRIGGER_CLASS 0xFF + +/** + * @brief Nordic DFU Trigger subclass possible value. + */ +typedef enum { + APP_USBD_NRF_DFU_TRIGGER_SUBCLASS = 0x01, /**< Device Firmware Upgrade Code */ +} app_usbd_nrf_dfu_trigger_subclass_t; + +/** + * @brief Nordic DFU Trigger protocol possible value. + * + * @note Only Run-time protocol is implemented, as DFU mode is covered by Nordic DFU. + */ +typedef enum { + APP_USBD_NRF_DFU_TRIGGER_PROTOCOL_RUNTIME = 0x01, /**< Run-time Protocol */ +} app_usbd_nrf_dfu_trigger_protocol_t; + +/** + * @brief Nordic DFU Trigger USB requests @ref nrf_drv_usbd_setup_t::bmRequestType + * + * @note Requests are limited only to @ref APP_USBD_NRF_DFU_TRIGGER_PROTOCOL_RUNTIME protocol type. + */ +typedef enum { + APP_USBD_NRF_DFU_TRIGGER_REQ_DETACH = 0x00, /**< Switch to DFU mode */ + APP_USBD_NRF_DFU_TRIGGER_REQ_NORDIC_INFO = 0x07, /**< Request Nordic DFU information */ + APP_USBD_NRF_DFU_TRIGGER_REQ_SEM_VER = 0x08, /**< Request semantic version information */ +} app_usbd_nrf_dfu_trigger_req_t; + +/** + * @brief Nordic DFU Trigger Functional Descriptor types. + */ +typedef enum { + APP_USBD_NRF_DFU_TRIGGER_CS_FUNCTIONAL = 0x21, /**< Functional descriptor type.*/ +} app_usbd_nrf_dfu_trigger_func_type_t; + +/** + * @brief Nordic DFU Trigger functional descriptor bmAttributes bit masks. + * + * @note For future compatibility with DFU class. + */ +typedef enum { + APP_USBD_NRF_DFU_TRIGGER_BIT_CAN_DNLOAD = 0x01, /**< bitCanDnload */ + APP_USBD_NRF_DFU_TRIGGER_BIT_CAB_UPLOAD = 0x02, /**< bitCanUpload */ + APP_USBD_NRF_DFU_TRIGGER_BIT_MANI_TOLERANT = 0x04, /**< bitManifestationTolerant */ + APP_USBD_NRF_DFU_TRIGGER_BIT_WILL_DETACH = 0x08, /**< bitWillDetach */ +} app_usbd_nrf_dfu_trigger_bm_attributes_t; + +#pragma pack(push, 1) + +/** + * @brief Nordic DFU Trigger Functional Descriptor. + */ +typedef struct { + uint8_t bFunctionLength; //!< Size of this descriptor in bytes. + uint8_t bDescriptorType; //!< Descriptor type. + uint8_t bmAttributes; //!< Attributes bits. + uint16_t wDetachTimeOut; //!< Device detach timeout - left for compatibility with USB DFU spec. + uint16_t wTransferSize; //!< Transfer size - left for compatibility with USB DFU spec. + uint16_t bcdDFUVersion; //!< DFU version. +} app_usbd_nrf_dfu_trigger_desc_func_t; + +/** + * @brief Nordic custom DFU information. + */ +typedef struct { + uint32_t wAddress; //!< Firmware start address. + uint32_t wFirmwareSize; //!< Firmware size. + uint16_t wVersionMajor; //!< Firmware version major. + uint16_t wVersionMinor; //!< Firmware version minor. + uint32_t wFirmwareID; //!< Firmware ID. + uint32_t wFlashSize; //!< Flash size. + uint32_t wFlashPageSize; //!< Flash page size. +} app_usbd_nrf_dfu_trigger_nordic_info_t; + +#pragma pack(pop) + + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* APP_USBD_NRF_DFU_TRIGGER_TYPES_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error.c similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error.c index e50e57d..c199ee4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -51,6 +51,7 @@ #include "app_error.h" #include "nordic_common.h" #include "sdk_errors.h" + /**@brief Function for error handling, which is called when an error has occurred. * * @warning This handler is an example only and does not fit a final product. You need to analyze @@ -60,22 +61,6 @@ * @param[in] line_num Line number where the handler is called. * @param[in] p_file_name Pointer to the file name. */ - -/*lint -save -e14 */ -void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) -{ - error_info_t error_info = - { - .line_num = line_num, - .p_file_name = p_file_name, - .err_code = error_code, - }; - app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info)); - - UNUSED_VARIABLE(error_info); -} - -/*lint -save -e14 */ void app_error_handler_bare(ret_code_t error_code) { error_info_t error_info = @@ -90,7 +75,6 @@ void app_error_handler_bare(ret_code_t error_code) UNUSED_VARIABLE(error_info); } - void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info) { /* static error variables - in order to prevent removal by optimizers */ @@ -139,5 +123,3 @@ void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info) __enable_irq(); } - -/*lint -restore */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error.h index c8c3758..59a32e5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -67,19 +67,19 @@ extern "C" { #endif -#define NRF_FAULT_ID_SDK_RANGE_START 0x00004000 /**< The start of the range of error IDs defined in the SDK. */ +#define NRF_FAULT_ID_SDK_RANGE_START (0x00004000) /**< The start of the range of error IDs defined in the SDK. */ /**@defgroup APP_ERROR_FAULT_IDS Fault ID types * @{ */ -#define NRF_FAULT_ID_SDK_ERROR NRF_FAULT_ID_SDK_RANGE_START + 1 /**< An error stemming from a call to @ref APP_ERROR_CHECK or @ref APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an @ref error_info_t variable. */ -#define NRF_FAULT_ID_SDK_ASSERT NRF_FAULT_ID_SDK_RANGE_START + 2 /**< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an @ref assert_info_t variable. */ +#define NRF_FAULT_ID_SDK_ERROR (NRF_FAULT_ID_SDK_RANGE_START + 1) /**< An error stemming from a call to @ref APP_ERROR_CHECK or @ref APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an @ref error_info_t variable. */ +#define NRF_FAULT_ID_SDK_ASSERT (NRF_FAULT_ID_SDK_RANGE_START + 2) /**< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an @ref assert_info_t variable. */ /**@} */ /**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ERROR. */ typedef struct { - uint16_t line_num; /**< The line number where the error occurred. */ + uint32_t line_num; /**< The line number where the error occurred. */ uint8_t const * p_file_name; /**< The file in which the error occurred. */ uint32_t err_code; /**< The error code representing the error that occurred. */ } error_info_t; @@ -92,6 +92,16 @@ typedef struct uint8_t const * p_file_name; /**< The file in which the error occurred. */ } assert_info_t; +/**@brief Defines required by app_error_handler assembler intructions. + */ +#define APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM (offsetof(error_info_t, line_num)) +#define APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME (offsetof(error_info_t, p_file_name)) +#define APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE (offsetof(error_info_t, err_code)) +#define APP_ERROR_ERROR_INFO_SIZE (sizeof(error_info_t)) +#define APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE \ + ALIGN_NUM(APP_ERROR_ERROR_INFO_SIZE, sizeof(uint64_t)) + + /**@brief Function for error handling, which is called when an error has occurred. * * @param[in] error_code Error code supplied to the handler. @@ -116,6 +126,16 @@ void app_error_handler_bare(ret_code_t error_code); */ void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info); +/**@brief Function for logging details of error and flushing logs. + * + * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. + * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if + * unavailable. + * @param[in] info Optional additional information regarding the fault. Refer to each fault + * identifier for details. + */ +void app_error_log_handle(uint32_t id, uint32_t pc, uint32_t info); + /**@brief Macro for calling error handler function. * diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_gcc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_gcc.c new file mode 100644 index 0000000..955e17b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_gcc.c @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2017 - 2019, 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" +#include "compiler_abstraction.h" +#include "app_error.h" + +#if defined (__CORTEX_M) && (__CORTEX_M == 0x04) +void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) __attribute__(( naked )); + +void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + __ASM volatile( + + "push {lr} \n" + + /* reserve space on stack for error_info_t struct - preserve 8byte stack aligment */ + "sub sp, sp, %0 \n" + + /* prepare error_info_t struct */ + "str r0, [sp, %1] \n" + "str r1, [sp, %3] \n" + "str r2, [sp, %2] \n" + + /* prepare arguments and call function: app_error_fault_handler */ + "ldr r0, =%4 \n" + "mov r1, lr \n" + "mov r2, sp \n" + "bl %5 \n" + + /* release stack */ + "add sp, sp, %0 \n" + + "pop {pc} \n" + ".ltorg \n" + + : /* Outputs */ + : /* Inputs */ + "I" (APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE), + "I" (APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE), + "I" (APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME), + "I" (APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM), + "X" (NRF_FAULT_ID_SDK_ERROR), + "X" (app_error_fault_handler) + : /* Clobbers */ + "r0", "r1", "r2" + ); +} +#elif defined(__CORTEX_M) && (__CORTEX_M == 0x00) +/* NRF51 implementation is currently not supporting PC readout */ +void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + error_info_t error_info = { + .line_num = line_num, + .p_file_name = p_file_name, + .err_code = error_code, + }; + app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info)); + + UNUSED_VARIABLE(error_info); +} +#else +#error Architecture not supported +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_iar.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_iar.c new file mode 100644 index 0000000..7eb9365 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_iar.c @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2017 - 2019, 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" +#include "compiler_abstraction.h" +#include "app_error.h" + +#if defined (__CORTEX_M) && (__CORTEX_M == 0x04) +void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + __ASM volatile( + "push {lr} \n" + /* reserve space on stack for error_info_t struct */ + "sub sp, sp, %0 \n" + + /* prepare error_info_t struct */ + "str r0, [sp, %1] \n" + "str r1, [sp, %3] \n" + "str r2, [sp, %2] \n" + + /* prepare arguments and call function: app_error_fault_handler */ + "ldr.n r0, 1f \n" + "mov r1, LR \n" + "mov r2, sp \n" + + /* call app_error_fault_handler */ + "bl %c5 \n" + + /* release stack */ + "add sp, sp, %0 \n" + "pop {pc} \n" + + "DATA \n" + "1: \n" + " DC32 %c4 \n" + + : /* Outputs */ + : /* Inputs */ + "i" (APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE), + "i" (APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE), + "i" (APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME), + "i" (APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM), + "i" (NRF_FAULT_ID_SDK_ERROR), + "i" (app_error_fault_handler) + : /* CLobbers */ + "r0", "r1", "r2" + ); +} +#elif defined(__CORTEX_M) && (__CORTEX_M == 0x00) +/* NRF51 implementation is currently not supporting PC readout */ +void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + error_info_t error_info = { + .line_num = line_num, + .p_file_name = p_file_name, + .err_code = error_code, + }; + app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info)); + + UNUSED_VARIABLE(error_info); +} +#else +#error Architecture not supported +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_keil.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_keil.c new file mode 100644 index 0000000..5dfa9af --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_handler_keil.c @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2017 - 2019, 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" +#include "compiler_abstraction.h" +#include "app_error.h" + +#if defined (__CORTEX_M) && (__CORTEX_M == 0x04) +__ASM void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + PRESERVE8 {TRUE} + THUMB + + push {lr} + + /* reserve space on stack for error_info_t struct - preserve 8byte stack aligment */ + sub sp, sp, #__cpp(APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE) + + /* prepare error_info_t struct */ + str r0, [sp, #__cpp(APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE)] + str r1, [sp, #__cpp(APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM)] + str r2, [sp, #__cpp(APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME)] + + /* prepare arguments and call function: app_error_fault_handler */ + mov r0, #__cpp(NRF_FAULT_ID_SDK_ERROR) + mov r1, lr + mov r2, sp + + /* call function */ + bl __cpp(app_error_fault_handler) + + /* release stack */ + add sp, sp, #__cpp(APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE) + + pop {pc} +} +#elif defined(__CORTEX_M) && (__CORTEX_M == 0x00) +/* NRF51 implementation is currently not supporting PC readout */ +void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + error_info_t error_info = { + .line_num = line_num, + .p_file_name = p_file_name, + .err_code = error_code, + }; + app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info)); + + UNUSED_VARIABLE(error_info); +} +#else +#error Architecture not supported +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error_weak.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_weak.c similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error_weak.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_weak.c index f00b36f..3f1cce4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error_weak.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_weak.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,12 +35,13 @@ * 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 "app_error.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" +#include "app_util_platform.h" #include "nrf_strerror.h" #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT @@ -48,13 +49,13 @@ #endif /*lint -save -e14 */ - /** * Function is implemented as weak so that it can be overwritten by custom application error handler * when needed. */ __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) { + __disable_irq(); NRF_LOG_FINAL_FLUSH(); #ifndef DEBUG @@ -81,11 +82,13 @@ __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) case NRF_FAULT_ID_SDK_ERROR: { error_info_t * p_info = (error_info_t *)info; - NRF_LOG_ERROR("ERROR %u [%s] at %s:%u", + NRF_LOG_ERROR("ERROR %u [%s] at %s:%u\r\nPC at: 0x%08x", p_info->err_code, nrf_strerror_get(p_info->err_code), p_info->p_file_name, - p_info->line_num); + p_info->line_num, + pc); + NRF_LOG_ERROR("End of error report"); break; } default: @@ -104,6 +107,4 @@ __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) app_error_save_and_stop(id, pc, info); #endif // DEBUG } - /*lint -restore */ - diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error_weak.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_weak.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error_weak.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_weak.h index fa49dc3..8eecc3e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_error_weak.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_error_weak.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,11 +35,13 @@ * 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 APP_ERROR_WEAK_H__ #define APP_ERROR_WEAK_H__ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util.h similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util.h index a8ffba2..b21e25d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -59,25 +59,84 @@ #ifdef __cplusplus extern "C" { #endif +/** + * @cond (NODOX) + */ +/*lint -save -e27 -e10 -e19 */ +#if defined (__LINT__) +#define STACK_BASE 0x1F000 // Arbitrary value. +#define STACK_TOP 0x20000 // Arbitrary value. -//lint -save -e27 -e10 -e19 -#if defined ( __CC_ARM ) && !defined (__LINT__) +#elif defined ( __CC_ARM ) extern char STACK$$Base; extern char STACK$$Length; #define STACK_BASE &STACK$$Base #define STACK_TOP ((void*)((uint32_t)STACK_BASE + (uint32_t)&STACK$$Length)) + #elif defined ( __ICCARM__ ) extern char CSTACK$$Base; extern char CSTACK$$Length; #define STACK_BASE &CSTACK$$Base #define STACK_TOP ((void*)((uint32_t)STACK_BASE + (uint32_t)&CSTACK$$Length)) + #elif defined ( __GNUC__ ) extern uint32_t __StackTop; extern uint32_t __StackLimit; #define STACK_BASE &__StackLimit #define STACK_TOP &__StackTop #endif -//lint -restore + +/* These macros are valid only when absolute placement is used for the application + * image. The macros are not compile time symbols. They cannot be used as a + * constant expression, for example, inside a static assert or linker script + * at-placement. */ +#if defined (__LINT__) +#define CODE_START (0) // Arbitrary value. +#define CODE_END (0x1000) // Arbitrary value. +#define CODE_SIZE (0x1000) // Arbitrary value. + +#elif defined ( __CC_ARM ) +extern char Load$$LR$$LR_IROM1$$Base; +extern char Load$$LR$$LR_IROM1$$Length; +extern char Load$$LR$$LR_IROM1$$Limit; +#define CODE_START ((uint32_t)&Load$$LR$$LR_IROM1$$Base) +#define CODE_END ((uint32_t)&Load$$LR$$LR_IROM1$$Limit) +#define CODE_SIZE ((uint32_t)&Load$$LR$$LR_IROM1$$Length) + +#elif defined ( __ICCARM__ ) +extern void * __vector_table; +extern char RO_END$$Base; +#define CODE_START ((uint32_t)&__vector_table) +#define CODE_END ((uint32_t)&RO_END$$Base) +#define CODE_SIZE (CODE_END - CODE_START) + +#elif defined(__SES_ARM) +extern uint32_t * _vectors; +extern uint32_t __FLASH_segment_used_end__; +#define CODE_START ((uint32_t)&_vectors) +#define CODE_END ((uint32_t)&__FLASH_segment_used_end__) +#define CODE_SIZE (CODE_END - CODE_START) + +#elif defined ( __GNUC__ ) +extern uint32_t __isr_vector; +extern uint32_t __etext; +#define CODE_START ((uint32_t)&__isr_vector) +#define CODE_END ((uint32_t)&__etext) +#define CODE_SIZE (CODE_END - CODE_START) +#endif +/** @} + * @endcond + */ +/* lint -restore */ + +#if defined(MBR_PRESENT) || defined(SOFTDEVICE_PRESENT) +#include "nrf_mbr.h" +#define BOOTLOADER_ADDRESS ((*(uint32_t *)MBR_BOOTLOADER_ADDR) == 0xFFFFFFFF ? *MBR_UICR_BOOTLOADER_ADDR : *(uint32_t *)MBR_BOOTLOADER_ADDR) /**< The currently configured start address of the bootloader. If 0xFFFFFFFF, no bootloader start address is configured. */ +#define MBR_PARAMS_PAGE_ADDRESS ((*(uint32_t *)MBR_PARAM_PAGE_ADDR) == 0xFFFFFFFF ? *MBR_UICR_PARAM_PAGE_ADDR : *(uint32_t *)MBR_PARAM_PAGE_ADDR) /**< The currently configured address of the MBR params page. If 0xFFFFFFFF, no MBR params page address is configured. */ +#else +#define BOOTLOADER_ADDRESS (NRF_UICR->NRFFW[0]) /**< Check UICR, just in case. */ +#define MBR_PARAMS_PAGE_ADDRESS (NRF_UICR->NRFFW[1]) /**< Check UICR, just in case. */ +#endif enum { @@ -86,6 +145,44 @@ enum UNIT_10_MS = 10000 /**< Number of microseconds in 10 milliseconds. */ }; +/** + * @brief Counts number of bits required for the given value + * + * The macro technically searches for the highest bit set. + * For value 0 it returns 0. + * + * @param val Value to be processed + * + * @return Number of bits required for the given value + */ +//lint -emacro(572,VBITS) +#define VBITS(val) VBITS_32(val) + +/** + * @def VBITS_1 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_2 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_4 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_8 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_16 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_32 + * @brief Internal macro used by @ref VBITS */ +#define VBITS_1( v) ((((v) & (0x0001U << 0)) != 0) ? 1U : 0U) +#define VBITS_2( v) ((((v) & (0x0001U << 1)) != 0) ? VBITS_1 ((v) >> 1) + 1 : VBITS_1 (v)) +#define VBITS_4( v) ((((v) & (0x0003U << 2)) != 0) ? VBITS_2 ((v) >> 2) + 2 : VBITS_2 (v)) +#define VBITS_8( v) ((((v) & (0x000fU << 4)) != 0) ? VBITS_4 ((v) >> 4) + 4 : VBITS_4 (v)) +#define VBITS_16(v) ((((v) & (0x00ffU << 8)) != 0) ? VBITS_8 ((v) >> 8) + 8 : VBITS_8 (v)) +#define VBITS_32(v) ((((v) & (0xffffU << 16)) != 0) ? VBITS_16((v) >> 16) + 16 : VBITS_16(v)) + /*Segger embedded studio originally has offsetof macro which cannot be used in macros (like STATIC_ASSERT). This redefinition is to allow using that. */ @@ -115,9 +212,14 @@ enum #ifndef __LINT__ #ifdef __GNUC__ +#ifdef __cplusplus +#define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#define STATIC_ASSERT_MSG(EXPR, MSG) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#else #define STATIC_ASSERT_SIMPLE(EXPR) _Static_assert(EXPR, "unspecified message") #define STATIC_ASSERT_MSG(EXPR, MSG) _Static_assert(EXPR, MSG) #endif +#endif #ifdef __CC_ARM #define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] @@ -297,7 +399,7 @@ typedef struct * * @return The aligned (increased) @p number. */ -#define ALIGN_NUM(alignment, number) ((number - 1) + alignment - ((number - 1) % alignment)) +#define ALIGN_NUM(alignment, number) (((number) - 1) + (alignment) - (((number) - 1) % (alignment))) /**@brief Macro for getting first of 2 parameters. * @@ -344,7 +446,7 @@ typedef struct * * Macro that extracts selected bit-field from provided value * - * @param[in] val Value from witch selected bit-field would be extracted + * @param[in] val Value from which selected bit-field would be extracted * @param[in] bcnt Number of bits in the bit-field * @param[in] boff Lowest bit number * @@ -438,7 +540,7 @@ typedef struct * @sa BF_CX * @sa BF_GET * - * @param[in] val Value from witch selected bit-field would be extracted + * @param[in] val Value from which selected bit-field would be extracted * @param[in] bf_cx Complex bit-field * * @return Value of the selected bits. @@ -622,6 +724,24 @@ typedef struct #define MACRO_MAP_13(macro, a, ...) macro(a) MACRO_MAP_12(macro, __VA_ARGS__, ) #define MACRO_MAP_14(macro, a, ...) macro(a) MACRO_MAP_13(macro, __VA_ARGS__, ) #define MACRO_MAP_15(macro, a, ...) macro(a) MACRO_MAP_14(macro, __VA_ARGS__, ) +#define MACRO_MAP_16(macro, a, ...) macro(a) MACRO_MAP_15(macro, __VA_ARGS__, ) +#define MACRO_MAP_17(macro, a, ...) macro(a) MACRO_MAP_16(macro, __VA_ARGS__, ) +#define MACRO_MAP_18(macro, a, ...) macro(a) MACRO_MAP_17(macro, __VA_ARGS__, ) +#define MACRO_MAP_19(macro, a, ...) macro(a) MACRO_MAP_18(macro, __VA_ARGS__, ) +#define MACRO_MAP_20(macro, a, ...) macro(a) MACRO_MAP_19(macro, __VA_ARGS__, ) +#define MACRO_MAP_21(macro, a, ...) macro(a) MACRO_MAP_20(macro, __VA_ARGS__, ) +#define MACRO_MAP_22(macro, a, ...) macro(a) MACRO_MAP_21(macro, __VA_ARGS__, ) +#define MACRO_MAP_23(macro, a, ...) macro(a) MACRO_MAP_22(macro, __VA_ARGS__, ) +#define MACRO_MAP_24(macro, a, ...) macro(a) MACRO_MAP_23(macro, __VA_ARGS__, ) +#define MACRO_MAP_25(macro, a, ...) macro(a) MACRO_MAP_24(macro, __VA_ARGS__, ) +#define MACRO_MAP_26(macro, a, ...) macro(a) MACRO_MAP_25(macro, __VA_ARGS__, ) +#define MACRO_MAP_27(macro, a, ...) macro(a) MACRO_MAP_26(macro, __VA_ARGS__, ) +#define MACRO_MAP_28(macro, a, ...) macro(a) MACRO_MAP_27(macro, __VA_ARGS__, ) +#define MACRO_MAP_29(macro, a, ...) macro(a) MACRO_MAP_28(macro, __VA_ARGS__, ) +#define MACRO_MAP_30(macro, a, ...) macro(a) MACRO_MAP_29(macro, __VA_ARGS__, ) +#define MACRO_MAP_31(macro, a, ...) macro(a) MACRO_MAP_30(macro, __VA_ARGS__, ) +#define MACRO_MAP_32(macro, a, ...) macro(a) MACRO_MAP_31(macro, __VA_ARGS__, ) + #define MACRO_MAP_REC_0( ...) #define MACRO_MAP_REC_1( macro, a, ...) macro(a) @@ -639,6 +759,24 @@ typedef struct #define MACRO_MAP_REC_13(macro, a, ...) macro(a) MACRO_MAP_REC_12(macro, __VA_ARGS__, ) #define MACRO_MAP_REC_14(macro, a, ...) macro(a) MACRO_MAP_REC_13(macro, __VA_ARGS__, ) #define MACRO_MAP_REC_15(macro, a, ...) macro(a) MACRO_MAP_REC_14(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_16(macro, a, ...) macro(a) MACRO_MAP_REC_15(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_17(macro, a, ...) macro(a) MACRO_MAP_REC_16(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_18(macro, a, ...) macro(a) MACRO_MAP_REC_17(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_19(macro, a, ...) macro(a) MACRO_MAP_REC_18(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_20(macro, a, ...) macro(a) MACRO_MAP_REC_19(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_21(macro, a, ...) macro(a) MACRO_MAP_REC_20(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_22(macro, a, ...) macro(a) MACRO_MAP_REC_21(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_23(macro, a, ...) macro(a) MACRO_MAP_REC_22(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_24(macro, a, ...) macro(a) MACRO_MAP_REC_23(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_25(macro, a, ...) macro(a) MACRO_MAP_REC_24(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_26(macro, a, ...) macro(a) MACRO_MAP_REC_25(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_27(macro, a, ...) macro(a) MACRO_MAP_REC_26(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_28(macro, a, ...) macro(a) MACRO_MAP_REC_27(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_29(macro, a, ...) macro(a) MACRO_MAP_REC_28(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_30(macro, a, ...) macro(a) MACRO_MAP_REC_29(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_31(macro, a, ...) macro(a) MACRO_MAP_REC_30(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_32(macro, a, ...) macro(a) MACRO_MAP_REC_31(macro, __VA_ARGS__, ) + /** * @brief Mapping macro with current index @@ -651,7 +789,8 @@ typedef struct * @return All arguments processed by given macro */ #define MACRO_MAP_FOR(...) MACRO_MAP_FOR_(__VA_ARGS__) -#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 +#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, \ + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 #define MACRO_MAP_FOR_(...) MACRO_MAP_FOR_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), __VA_ARGS__) /** @@ -685,6 +824,23 @@ typedef struct #define MACRO_MAP_FOR_13(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) #define MACRO_MAP_FOR_14(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) #define MACRO_MAP_FOR_15(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_16(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_17(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_18(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_19(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_20(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_21(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_22(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_23(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_24(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_25(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_26(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_27(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_28(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_29(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_30(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_31(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_32(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) /** @@ -731,6 +887,24 @@ typedef struct #define MACRO_MAP_FOR_PARAM_13(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) #define MACRO_MAP_FOR_PARAM_14(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) #define MACRO_MAP_FOR_PARAM_15(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_16(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_17(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_18(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_19(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_20(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_21(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_22(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_23(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_24(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_25(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_26(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_27(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_28(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_29(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_30(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_31(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_32(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) + /** @@ -761,6 +935,23 @@ typedef struct #define MACRO_REPEAT_13(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_12(macro, __VA_ARGS__) #define MACRO_REPEAT_14(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_13(macro, __VA_ARGS__) #define MACRO_REPEAT_15(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_14(macro, __VA_ARGS__) +#define MACRO_REPEAT_16(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_15(macro, __VA_ARGS__) +#define MACRO_REPEAT_17(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_16(macro, __VA_ARGS__) +#define MACRO_REPEAT_18(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_17(macro, __VA_ARGS__) +#define MACRO_REPEAT_19(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_18(macro, __VA_ARGS__) +#define MACRO_REPEAT_20(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_19(macro, __VA_ARGS__) +#define MACRO_REPEAT_21(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_20(macro, __VA_ARGS__) +#define MACRO_REPEAT_22(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_21(macro, __VA_ARGS__) +#define MACRO_REPEAT_23(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_22(macro, __VA_ARGS__) +#define MACRO_REPEAT_24(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_23(macro, __VA_ARGS__) +#define MACRO_REPEAT_25(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_24(macro, __VA_ARGS__) +#define MACRO_REPEAT_26(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_25(macro, __VA_ARGS__) +#define MACRO_REPEAT_27(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_26(macro, __VA_ARGS__) +#define MACRO_REPEAT_28(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_27(macro, __VA_ARGS__) +#define MACRO_REPEAT_29(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_28(macro, __VA_ARGS__) +#define MACRO_REPEAT_30(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_29(macro, __VA_ARGS__) +#define MACRO_REPEAT_31(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_30(macro, __VA_ARGS__) +#define MACRO_REPEAT_32(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_31(macro, __VA_ARGS__) /** @@ -794,6 +985,24 @@ typedef struct #define MACRO_REPEAT_FOR_13(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) #define MACRO_REPEAT_FOR_14(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) #define MACRO_REPEAT_FOR_15(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_16(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_17(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_18(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_19(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_20(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_21(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_22(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_23(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_24(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_25(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_26(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_27(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_28(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_29(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_30(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_31(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_32(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) + /**@brief Adding curly brace to the macro parameter. * @@ -861,6 +1070,23 @@ static __INLINE uint8_t uint32_encode(uint32_t value, uint8_t * p_encoded_data) return sizeof(uint32_t); } +/**@brief Function for encoding a uint40 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint40_encode(uint64_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x00000000FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0x000000FF00) >> 8); + p_encoded_data[2] = (uint8_t) ((value & 0x0000FF0000) >> 16); + p_encoded_data[3] = (uint8_t) ((value & 0x00FF000000) >> 24); + p_encoded_data[4] = (uint8_t) ((value & 0xFF00000000) >> 32); + return 5; +} + /**@brief Function for encoding a uint48 value. * * @param[in] value Value to be encoded. @@ -960,10 +1186,13 @@ static __INLINE uint8_t uint16_big_encode(uint16_t value, uint8_t * p_encoded_da return sizeof(uint16_t); } +/*lint -esym(526, __rev) */ +/*lint -esym(628, __rev) */ /**@brief Function for encoding a uint32 value in big-endian format. * * @param[in] value Value to be encoded. * @param[out] p_encoded_data Buffer where the encoded data will be written. + * The address pointed to must be word alligned. * * @return Number of bytes written. */ @@ -973,6 +1202,21 @@ static __INLINE uint8_t uint32_big_encode(uint32_t value, uint8_t * p_encoded_da return sizeof(uint32_t); } +/**@brief Function for decoding a uint40 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. (uint64_t) + */ +static __INLINE uint64_t uint40_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint64_t)((uint8_t *)p_encoded_data)[0]) << 0) | + (((uint64_t)((uint8_t *)p_encoded_data)[1]) << 8) | + (((uint64_t)((uint8_t *)p_encoded_data)[2]) << 16) | + (((uint64_t)((uint8_t *)p_encoded_data)[3]) << 24) | + (((uint64_t)((uint8_t *)p_encoded_data)[4]) << 32 )); +} + /**@brief Function for decoding a uint48 value. * * @param[in] p_encoded_data Buffer where the encoded data is stored. @@ -1052,6 +1296,7 @@ static __INLINE bool is_word_aligned(void const* p) return (((uintptr_t)p & 0x03) == 0); } +/*lint -e{568, 685} */ /** * @brief Function for checking if provided address is located in stack space. * @@ -1072,7 +1317,6 @@ static __INLINE bool is_address_from_stack(void * ptr) } } - #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_bds.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_bds.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_bds.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_bds.h index e880693..b454bce 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_bds.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_bds.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_platform.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_platform.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_platform.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_platform.c index 740d422..08374ae 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_platform.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_platform.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "app_util_platform.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_platform.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_platform.h similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_platform.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_platform.h index 141c339..dd41339 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/app_util_platform.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/app_util_platform.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2014 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -68,6 +68,7 @@ extern "C" { #define _PRIO_APP_HIGH 1 #define _PRIO_APP_MID 1 #define _PRIO_SD_LOW 2 +#define _PRIO_APP_LOW_MID 3 #define _PRIO_APP_LOW 3 #define _PRIO_APP_LOWEST 3 #define _PRIO_THREAD 4 @@ -77,7 +78,7 @@ extern "C" { #define _PRIO_APP_HIGH 2 #define _PRIO_APP_MID 3 #define _PRIO_SD_LOW 4 -#define _PRIO_SD_LOWEST 5 +#define _PRIO_APP_LOW_MID 5 #define _PRIO_APP_LOW 6 #define _PRIO_APP_LOWEST 7 #define _PRIO_THREAD 15 @@ -101,6 +102,7 @@ typedef enum #else APP_IRQ_PRIORITY_MID = _PRIO_APP_MID, #endif + APP_IRQ_PRIORITY_LOW_MID = _PRIO_APP_LOW_MID, APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW, APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST, APP_IRQ_PRIORITY_THREAD = _PRIO_THREAD /**< "Interrupt level" when running in Thread Mode. */ @@ -122,7 +124,7 @@ typedef enum /**@brief Macro for setting a breakpoint. */ #if defined(__GNUC__) -#define NRF_BREAKPOINT __builtin_trap() +#define NRF_BREAKPOINT __asm__("BKPT 0"); #else #define NRF_BREAKPOINT __BKPT(0) #endif @@ -155,6 +157,20 @@ typedef enum #define PACKED_STRUCT __packed struct #endif +#if defined ( __CC_ARM ) +#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("push") \ + _Pragma ("O3") +#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("pop") +#elif defined ( __GNUC__ ) +#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma("GCC push_options") \ + _Pragma ("GCC optimize (\"Os\")") +#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("GCC pop_options") +#elif defined (__ICCARM__) +#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("optimize=high z") +#define PRAGMA_OPTIMIZATION_FORCE_END +#endif + + void app_util_critical_region_enter (uint8_t *p_nested); void app_util_critical_region_exit (uint8_t nested); @@ -197,12 +213,14 @@ void app_util_critical_region_exit (uint8_t nested); /**@brief Macro to enable anonymous unions from a certain point in the code. */ #if defined(__CC_ARM) - #define ANON_UNIONS_ENABLE _Pragma("push") \ - _Pragma("anon_unions") + #define ANON_UNIONS_ENABLE _Pragma("push") \ + _Pragma("anon_unions") \ + struct semicolon_swallower #elif defined(__ICCARM__) - #define ANON_UNIONS_ENABLE _Pragma("language=extended") + #define ANON_UNIONS_ENABLE _Pragma("language=extended") \ + struct semicolon_swallower #else - #define ANON_UNIONS_ENABLE + #define ANON_UNIONS_ENABLE struct semicolon_swallower // No action will be taken. // For GCC anonymous unions are enabled by default. #endif @@ -211,12 +229,13 @@ void app_util_critical_region_exit (uint8_t nested); * @note Call only after first calling @ref ANON_UNIONS_ENABLE. */ #if defined(__CC_ARM) - #define ANON_UNIONS_DISABLE _Pragma("pop") + #define ANON_UNIONS_DISABLE _Pragma("pop") \ + struct semicolon_swallower #elif defined(__ICCARM__) - #define ANON_UNIONS_DISABLE + #define ANON_UNIONS_DISABLE struct semicolon_swallower // for IAR leave anonymous unions enabled #else - #define ANON_UNIONS_DISABLE + #define ANON_UNIONS_DISABLE struct semicolon_swallower // No action will be taken. // For GCC anonymous unions are enabled by default. #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nordic_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nordic_common.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nordic_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nordic_common.h index e7f63b1..8fcaf5d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nordic_common.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nordic_common.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2008 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2008 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** @file * @brief Common defines and macros for firmware developed by Nordic Semiconductor. @@ -73,9 +73,13 @@ extern "C" { * without evaluating its value. */ //lint -emacro(491,NRF_MODULE_ENABLED) // Suppers warning 491 "non-standard use of 'defined' preprocessor operator" +#ifdef NRF_MODULE_ENABLE_ALL +#warning "Do not use NRF_MODULE_ENABLE_ALL for real builds." +#define NRF_MODULE_ENABLED(module) 1 +#else #define NRF_MODULE_ENABLED(module) \ ((defined(module ## _ENABLED) && (module ## _ENABLED)) ? 1 : 0) - +#endif /** The upper 8 bits of a 32 bit value */ //lint -emacro(572,MSB_32) // Suppress warning 572 "Excessive shift value" #define MSB_32(a) (((a) & 0xFF000000) >> 24) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_assert.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_assert.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_assert.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_assert.c index 6255ba9..cad3da4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_assert.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_assert.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2006 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2006 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_assert.h" #include "app_error.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_assert.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_assert.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_assert.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_assert.h index 2ec647c..8685362 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_assert.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_assert.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2006 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2006 - 2019, 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 @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** @file * @brief Utilities for verifying program logic @@ -46,7 +46,6 @@ #include #include "nrf.h" -#include "app_error.h" #ifdef __cplusplus extern "C" { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_bitmask.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_bitmask.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_bitmask.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_bitmask.h index 72f531f..7f369c2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/nrf_bitmask.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/nrf_bitmask.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2006 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2006 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_BITMASK_H #define NRF_BITMASK_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_alloca.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_alloca.h new file mode 100644 index 0000000..97af4cc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_alloca.h @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2017 - 2019, 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 sdk_alloca.h + * + * @brief Defines alloca() function. + * + * @details This file defines alloca() function. This can be done directly or by including system + * header files. Not all platforms support alloca(). In this case no error will be shown, but + * SDK_ALLOCA_DEFINED will be set to 0. + */ + +#ifndef SDK_ALLOCA_H__ +#define SDK_ALLOCA_H__ + + +#if defined(__SDK_DOXYGEN__) + /** @brief Set to one it alloca() function is available on this platform and it is correctly defined + * by this header file. + */ + #define SDK_ALLOCA_DEFINED 1 +#elif defined(__GNUC__) + #if defined(__SES_ARM) + // SES does not have definition of alloca(), but it have working GCC's __builtin_alloca(). + #if !defined(alloca) + #define alloca(size) __builtin_alloca((size)) + #endif + #else + // alloca() can be defined in on some platforms, but if not then try standard header file. + #include + #if !defined(alloca) + #include + #endif + #endif + #define SDK_ALLOCA_DEFINED 1 +#elif defined(__IAR_SYSTEMS_ICC__) + // IAR does not support alloca() function. + #define SDK_ALLOCA_DEFINED 0 +#else + // All other supported compilers have alloca() definition in header file. + #include + #define SDK_ALLOCA_DEFINED 1 +#endif + + +/*lint -"d__builtin_alloca=(void*)" */ + + +#endif // NRF_ALLOCA_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_common.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_common.h index 54ef51c..29b200b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_common.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_common.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /** @cond */ /**@file diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_errors.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_errors.h similarity index 83% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_errors.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_errors.h index 96920fc..7d3a96b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_errors.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_errors.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -71,7 +71,6 @@ #include #include "nrf_error.h" -#include "sdk_config.h" #ifdef __cplusplus extern "C" { @@ -89,10 +88,12 @@ extern "C" { * @defgroup sdk_module_codes Codes reserved as identification for module where the error occurred. * @{ */ -#define NRF_ERROR_MEMORY_MANAGER_ERR_BASE (0x8100) -#define NRF_ERROR_PERIPH_DRIVERS_ERR_BASE (0x8200) -#define NRF_ERROR_GAZELLE_ERR_BASE (0x8300) -#define NRF_ERROR_BLE_IPSP_ERR_BASE (0x8400) +#define NRF_ERROR_MEMORY_MANAGER_ERR_BASE (0x8100) /**< Base address for Memory Manager related errors. */ +#define NRF_ERROR_PERIPH_DRIVERS_ERR_BASE (0x8200) /**< Base address for Peripheral drivers related errors. */ +#define NRF_ERROR_GAZELLE_ERR_BASE (0x8300) /**< Base address for Gazelle related errors. */ +#define NRF_ERROR_BLE_IPSP_ERR_BASE (0x8400) /**< Base address for BLE IPSP related errors. */ +#define NRF_ERROR_CRYPTO_ERR_BASE (0x8500) /**< Base address for crypto related errors. */ +#define NRF_ERROR_FDS_ERR_BASE (0x8600) /**< Base address for FDS related errors. */ /** @} */ @@ -109,15 +110,16 @@ extern "C" { * @defgroup sdk_common_errors Codes reserved as identification for common errors. * @{ */ -#define NRF_ERROR_MODULE_NOT_INITIALZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0000) -#define NRF_ERROR_MUTEX_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0001) -#define NRF_ERROR_MUTEX_LOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0002) -#define NRF_ERROR_MUTEX_UNLOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0003) -#define NRF_ERROR_MUTEX_COND_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0004) -#define NRF_ERROR_MODULE_ALREADY_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0005) -#define NRF_ERROR_STORAGE_FULL (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0006) -#define NRF_ERROR_API_NOT_IMPLEMENTED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0010) -#define NRF_ERROR_FEATURE_NOT_ENABLED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0011) +#define NRF_ERROR_MODULE_NOT_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0000) ///< Module not initialized +#define NRF_ERROR_MUTEX_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0001) ///< Mutex initialization failed +#define NRF_ERROR_MUTEX_LOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0002) ///< Mutex lock failed +#define NRF_ERROR_MUTEX_UNLOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0003) ///< Mutex unlock failed +#define NRF_ERROR_MUTEX_COND_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0004) ///< Mutex conditional initialization failed +#define NRF_ERROR_MODULE_ALREADY_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0005) ///< Module already initialized +#define NRF_ERROR_STORAGE_FULL (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0006) ///< Storage full +#define NRF_ERROR_API_NOT_IMPLEMENTED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0010) ///< API not implemented +#define NRF_ERROR_FEATURE_NOT_ENABLED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0011) ///< Feature not enabled +#define NRF_ERROR_IO_PENDING (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0012) ///< Input/Output pending /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_macros.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_macros.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_macros.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_macros.h index 01dcdf5..4a0b2e9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_macros.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_macros.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -49,11 +49,51 @@ #ifndef SDK_MACROS_H__ #define SDK_MACROS_H__ +#include "nrf_assert.h" + #ifdef __cplusplus extern "C" { #endif +/**@brief Macro for parameter checking. + * + * If @p _cond evaluates to true, does nothing. Otherwise, + * if @p _module ## _PARAM_CHECK_DISABLED is @e not set (default), prints an error message + * if @p _printfn is provided, and returns from the calling function context with code @p _err. + * If @p _module ## _PARAM_CHECK_DISABLED is set, behaves like the ASSERT macro. + * + * Parameter checking implemented using this macro can be optionally turned off for release code. + * Only disable runtime parameter checks if size if a major concern. + * + * @param _module The module name. + * @param _cond The condition to be evaluated. + * @param _err The error to be returned. + * @param _printfn A printf-compatible function used to log the error. + * Leave empty if no logging is needed. + * + * @hideinitializer + */ +/*lint -esym(666, NRF_PARAM_CHECK*) : Expression with side effects passed to macro */ +#define NRF_PARAM_CHECK(_module, _cond, _err, _printfn) \ + do \ + { \ + if ((_cond)) \ + { \ + /* Do nothing. */ \ + } \ + else if (!(_module ## _PARAM_CHECK_DISABLED)) \ + { \ + _printfn("%s check failed in %s() with value 0x%x.", #_cond, __func__, _err); \ + return (_err); \ + } \ + else \ + { \ + ASSERT((_cond)); \ + } \ + } while (0); + + /**@brief Macro for verifying statement to be true. It will cause the exterior function to return * err_code if the statement is not true. * @@ -109,15 +149,19 @@ do \ /**@brief Macro for verifying that a function returned NRF_SUCCESS. It will cause the exterior - * function to return err_code if the err_code is not @ref NRF_SUCCESS. + * function to return error code of statement if it is not @ref NRF_SUCCESS. * - * @param[in] err_code The error code to check. + * @param[in] statement Statement to check against NRF_SUCCESS. */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_SUCCESS() -#else -#define VERIFY_SUCCESS(err_code) VERIFY_TRUE((err_code) == NRF_SUCCESS, (err_code)) -#endif /* DISABLE_PARAM_CHECK */ +#define VERIFY_SUCCESS(statement) \ +do \ +{ \ + uint32_t _err_code = (uint32_t) (statement); \ + if (_err_code != NRF_SUCCESS) \ + { \ + return _err_code; \ + } \ +} while(0) /**@brief Macro for verifying that a function returned NRF_SUCCESS. It will cause the exterior @@ -125,11 +169,7 @@ do \ * * @param[in] err_code The error code to check. */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_SUCCESS_VOID() -#else #define VERIFY_SUCCESS_VOID(err_code) VERIFY_TRUE_VOID((err_code) == NRF_SUCCESS) -#endif /* DISABLE_PARAM_CHECK */ /**@brief Macro for verifying that the module is initialized. It will cause the exterior function to @@ -138,11 +178,7 @@ do \ * @note MODULE_INITIALIZED must be defined in each module using this macro. MODULE_INITIALIZED * should be true if the module is initialized, false if not. */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_MODULE_INITIALIZED() -#else #define VERIFY_MODULE_INITIALIZED() VERIFY_TRUE((MODULE_INITIALIZED), NRF_ERROR_INVALID_STATE) -#endif /* DISABLE_PARAM_CHECK */ /**@brief Macro for verifying that the module is initialized. It will cause the exterior function to @@ -151,11 +187,16 @@ do \ * @note MODULE_INITIALIZED must be defined in each module using this macro. MODULE_INITIALIZED * should be true if the module is initialized, false if not. */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_MODULE_INITIALIZED_VOID() -#else #define VERIFY_MODULE_INITIALIZED_VOID() VERIFY_TRUE_VOID((MODULE_INITIALIZED)) -#endif /* DISABLE_PARAM_CHECK */ + + +/**@brief Macro for verifying that the module is initialized. It will cause the exterior function to + * return false if not. + * + * @note MODULE_INITIALIZED must be defined in each module using this macro. MODULE_INITIALIZED + * should be true if the module is initialized, false if not. + */ +#define VERIFY_MODULE_INITIALIZED_BOOL() VERIFY_TRUE((MODULE_INITIALIZED), false) /**@brief Macro for verifying that the module is initialized. It will cause the exterior function to @@ -163,11 +204,7 @@ do \ * * @param[in] param The variable to check if is NULL. */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_PARAM_NOT_NULL() -#else #define VERIFY_PARAM_NOT_NULL(param) VERIFY_FALSE(((param) == NULL), NRF_ERROR_NULL) -#endif /* DISABLE_PARAM_CHECK */ /**@brief Macro for verifying that the module is initialized. It will cause the exterior function to @@ -175,11 +212,7 @@ do \ * * @param[in] param The variable to check if is NULL. */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_PARAM_NOT_NULL_VOID() -#else #define VERIFY_PARAM_NOT_NULL_VOID(param) VERIFY_FALSE_VOID(((param) == NULL)) -#endif /* DISABLE_PARAM_CHECK */ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_mapped_flags.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_mapped_flags.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_mapped_flags.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_mapped_flags.c index 1a99ac3..661c8ea 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_mapped_flags.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_mapped_flags.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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_mapped_flags.h" #include diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_mapped_flags.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_mapped_flags.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_mapped_flags.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_mapped_flags.h index 1f90339..9f9d221 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_mapped_flags.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_mapped_flags.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SDK_MAPPED_FLAGS_H__ #define SDK_MAPPED_FLAGS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_os.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_os.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_os.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_os.h index c166007..b75954c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_os.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_os.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /** @cond */ /**@file diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_resources.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_resources.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_resources.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_resources.h index 91d2af1..c066b17 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/util/sdk_resources.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/libraries/util/sdk_resources.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,20 +35,20 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** @file * @brief Definition file for resource usage by SoftDevice, ESB and Gazell. */ -#ifndef APP_RESOURCES_H__ -#define APP_RESOURCES_H__ +#ifndef SDK_RESOURCES_H__ +#define SDK_RESOURCES_H__ #ifdef __cplusplus extern "C" { #endif -#ifdef SOFTDEVICE_PRESENT +#if defined(SOFTDEVICE_PRESENT) || defined (BLE_STACK_SUPPORT_REQD) || defined (ANT_STACK_SUPPORT_REQD) #include "nrf_sd_def.h" #else #define SD_PPI_RESTRICTED 0uL /**< 1 if PPI peripheral is restricted, 0 otherwise. */ @@ -83,4 +83,4 @@ extern "C" { } #endif -#endif // APP_RESOURCES_H__ +#endif // SDK_RESOURCES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c index 0ae94cb..12098e2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,8 +35,10 @@ * 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(NFC_AC_REC_PARSER) #include "nfc_ac_rec_parser.h" #include "sdk_macros.h" @@ -199,3 +201,5 @@ ret_code_t nfc_ac_rec_parse(nfc_ndef_record_desc_t const * const p_rec_desc, return err_code; } + +#endif // NRF_MODULE_ENABLED(NFC_AC_REC_PARSER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h index a92c119..9a036c2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ac_rec_parser/nfc_ac_rec_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -51,6 +51,10 @@ #include "nfc_ndef_record.h" #include "nfc_ac_rec.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Function for parsing general record description as Alternative Carrier record. * @@ -75,6 +79,10 @@ ret_code_t nfc_ac_rec_parse(nfc_ndef_record_desc_t const * const p_rec_desc, nfc_ac_rec_payload_desc_t * const p_ac_rec_payload_data); +#ifdef __cplusplus +} +#endif + #endif // __NFC_AC_REC_PARSER_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c index 466b19a..75743e6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,15 +35,24 @@ * 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(NFC_BLE_OOB_ADVDATA_PARSER) #include "nfc_ble_oob_advdata_parser.h" #include "app_util.h" -#include "sdk_common.h" +#include "nfc_ble_pair_common.h" + +#define NRF_LOG_MODULE_NAME ble_oob_ad_parser #include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); -#define BLE_GAP_AD_TYPE_LESC_CONFIRM_VALUE 0x22 -#define BLE_GAP_AD_TYPE_LESC_RANDOM_VALUE 0x23 +/* Workaround for using NRF_LOG_RAW_INFO() macro only when logging level is "DEBUG" */ +#if (NRF_LOG_LEVEL > 3) +#define NRF_BLE_OOB_AD_PARSER_LOG_DEBUG(...) NRF_LOG_RAW_INFO(__VA_ARGS__) +#else // (NRF_LOG_LEVEL > 3) +#define NRF_BLE_OOB_AD_PARSER_LOG_DEBUG(...) +#endif // (NRF_LOG_LEVEL > 3) #define EARLY_TERMINATOR 0 /* Value of AD Structure Length field indicating an early termination of Advertising or Scan Response Data. */ @@ -53,7 +62,7 @@ typedef enum { AD_TYPE_NOT_PRESENT = 0, /* Value indicating that AD type is not present. */ - AD_TYPE_OCCUR_THRES = 1 /* Maximal occurance number of any AD type within the buffer */ + AD_TYPE_OCCUR_THRES = 1 /* Maximal occurrence number of any AD type within the buffer */ } ad_type_counter_values_t; /**@brief Internal module structure indicating how many BLE AD fields of the same type are in the buffer. */ @@ -89,7 +98,7 @@ void nfc_oob_data_printout(nfc_ble_oob_pairing_data_t const * const p_pairing_da { NRF_LOG_RAW_INFO("\r\n"); NRF_LOG_INFO("BLE Advertising data contents"); - NRF_LOG_INFO("Device name: %s", NRF_LOG_PUSH((char *)p_pairing_data->device_name.p_name)); + NRF_LOG_INFO("Device name: \"%s\"", NRF_LOG_PUSH((char *)p_pairing_data->device_name.p_name)); NRF_LOG_INFO("Device Address: "); for (int i=0; i < BLE_GAP_ADDR_LEN; ++i) @@ -100,12 +109,12 @@ void nfc_oob_data_printout(nfc_ble_oob_pairing_data_t const * const p_pairing_da if (p_pairing_data->p_tk_value != NULL) { - NRF_LOG_INFO("Device Temporary Key: "); + NRF_LOG_INFO("Device Temporary Key present."); for (int i=0; i < BLE_GAP_SEC_KEY_LEN; ++i) { - NRF_LOG_RAW_INFO("%02X ", p_pairing_data->p_tk_value->tk[i]); + NRF_BLE_OOB_AD_PARSER_LOG_DEBUG("%02X ", p_pairing_data->p_tk_value->tk[i]); } - NRF_LOG_RAW_INFO("\r\n"); + NRF_BLE_OOB_AD_PARSER_LOG_DEBUG("\r\n"); } else { @@ -114,19 +123,19 @@ void nfc_oob_data_printout(nfc_ble_oob_pairing_data_t const * const p_pairing_da if (p_pairing_data->p_lesc_confirm_value != NULL && p_pairing_data->p_lesc_random_value) { - NRF_LOG_INFO("LESC Confirmation Value: "); + NRF_LOG_INFO("LESC Confirmation Value present."); for (int i=0; i < BLE_GAP_SEC_KEY_LEN; ++i) { - NRF_LOG_RAW_INFO("%02X ", p_pairing_data->p_lesc_confirm_value[i]); + NRF_BLE_OOB_AD_PARSER_LOG_DEBUG("%02X ", p_pairing_data->p_lesc_confirm_value[i]); } - NRF_LOG_RAW_INFO("\r\n"); + NRF_BLE_OOB_AD_PARSER_LOG_DEBUG("\r\n"); - NRF_LOG_INFO("LESC Random Value: "); + NRF_LOG_INFO("LESC Random Value present."); for (int i=0; i < BLE_GAP_SEC_KEY_LEN; ++i) { - NRF_LOG_RAW_INFO("%02X ", p_pairing_data->p_lesc_random_value[i]); + NRF_BLE_OOB_AD_PARSER_LOG_DEBUG("%02X ", p_pairing_data->p_lesc_random_value[i]); } - NRF_LOG_RAW_INFO("\r\n"); + NRF_BLE_OOB_AD_PARSER_LOG_DEBUG("\r\n"); } else { @@ -456,7 +465,7 @@ ret_code_t nfc_ble_oob_advdata_parse(uint8_t const * p_advdata, p_nfc_ble_pairing_data); break; - case BLE_GAP_AD_TYPE_LESC_CONFIRM_VALUE: + case BLE_GAP_AD_TYPE_LESC_CONFIRMATION_VALUE: ++ad_type_counter.lesc_confirm_type; err_code = lesc_confirm_value_decode(p_field_data, field_data_len, @@ -512,37 +521,4 @@ ret_code_t nfc_ble_oob_advdata_parse(uint8_t const * p_advdata, return err_code; } -ret_code_t nfc_ble_oob_advdata_parser_field_find(uint8_t type, - uint8_t * p_advdata, - uint8_t * p_len, - uint8_t ** pp_field_data) -{ - uint8_t index = 0; - ret_code_t err_code = NRF_SUCCESS; - - if ( (pp_field_data == NULL) || (p_len == NULL) || (p_advdata == NULL) ) - { - return NRF_ERROR_NULL; - } - - while (index < *p_len) - { - uint8_t field_length = p_advdata[index]; - if (field_length == EARLY_TERMINATOR) - { - return NRF_ERROR_NOT_FOUND; - } - err_code = field_length_validate(field_length, index, *p_len); - VERIFY_SUCCESS(err_code); - - uint8_t field_type = p_advdata[index + AD_LENGTH_FIELD_SIZE]; - if (field_type == type) - { - *pp_field_data = &p_advdata[index + AD_DATA_OFFSET]; - *p_len = field_length - AD_TYPE_FIELD_SIZE; - return NRF_SUCCESS; - } - index += field_length + AD_LENGTH_FIELD_SIZE; - } - return NRF_ERROR_NOT_FOUND; -} +#endif // NRF_MODULE_ENABLED(NFC_BLE_OOB_ADVDATA_PARSER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h index 0071829..c566992 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser/nfc_ble_oob_advdata_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -49,8 +49,12 @@ #ifndef NFC_BLE_OOB_ADVDATA_PARSER_H_ #define NFC_BLE_OOB_ADVDATA_PARSER_H_ -#include "nfc_ble_oob_advdata.h" #include "sdk_errors.h" +#include "ble_advdata.h" + +#ifdef __cplusplus +extern "C" { +#endif #define BLE_ADVDATA_APPEARANCE_NOT_PRESENT 0 /**< Appearance AD structure not present. */ @@ -117,29 +121,6 @@ ret_code_t nfc_ble_oob_advdata_parse(uint8_t const * p_advdata, uint8_t len, nfc_ble_oob_pairing_data_t * p_nfc_ble_pairing_data); -/**@brief Function for finding BLE AD Type data within buffer encoded in AD Type format. - * - * @details This function finds BLE AD Type data within buffer encoded in AD Type format - * The AD Data to be found can be specified by its AD Type - \p type. - * - * @param[in] type AD Type of AD Structure to be found - * within \p p_advdata. - * @param[in] p_advdata Pointer to the data to be parsed. - * @param[in,out] p_len As input: size of the data to be parsed. - * As output: size of the AD Data within - * found AD structure. - * @param[out] pp_field_data Pointer to AD Data within found AD Structure. - * - * @retval NRF_SUCCESS If chosen AD Type was found successfully. - * @retval NRF_ERROR_INVALID_LENGTH If any AD Structure Length field value indicates - * that AD Structure exceeds provided buffer. - * @retval NRF_ERROR_NULL If any function pointer parameter is NULL. - * @retval NRF_ERROR_NOT_FOUND If chosen AD Type - \p type was not found. - */ -ret_code_t nfc_ble_oob_advdata_parser_field_find(uint8_t type, - uint8_t * p_advdata, - uint8_t * p_len, - uint8_t ** pp_field_data); /**@brief Function for displaying values of basic BLE OOB Advertising data types. * @@ -147,6 +128,10 @@ ret_code_t nfc_ble_oob_advdata_parser_field_find(uint8_t type, */ void nfc_oob_data_printout(nfc_ble_oob_pairing_data_t const * const p_pairing_data); +#ifdef __cplusplus +} +#endif + #endif //NFC_BLE_OOB_ADVDATA_PARSER_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c index 74b45cb..5fae019 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,8 +35,10 @@ * 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(NFC_LE_OOB_REC_PARSER) #include "nfc_le_oob_rec_parser.h" #include "sdk_errors.h" @@ -98,3 +100,5 @@ ret_code_t nfc_le_oob_rec_parse(nfc_ndef_record_desc_t const * const p_rec_d return err_code; } + +#endif // NRF_MODULE_ENABLED(NFC_LE_OOB_REC_PARSER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h index 188a407..953f027 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser/nfc_le_oob_rec_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 * @@ -52,6 +52,10 @@ #include "nfc_ble_oob_advdata_parser.h" #include "nfc_ble_pair_common.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Function for parsing general record description as LE OOB record. * @@ -72,6 +76,10 @@ ret_code_t nfc_le_oob_rec_parse(nfc_ndef_record_desc_t const * const p_rec_desc, nfc_ble_oob_pairing_data_t * const p_nfc_ble_oob_pairing_data); +#ifdef __cplusplus +} +#endif + #endif // __NFC_LE_OOB_REC_PARSER_H__ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c index 2f01814..2b1bd43 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_AC_REC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h index f1567f6..057e65a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ac_rec/nfc_ac_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_AC_REC_H__ #define NFC_AC_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c index 3d263f5..a7261da 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2012 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_BLE_OOB_ADVDATA) @@ -43,10 +43,8 @@ #include "nfc_ble_oob_advdata.h" #include "sdk_common.h" #include "nfc_ble_pair_msg.h" +#include "nfc_ble_pair_common.h" -// LESC OOB data AD_TYPE values. -#define BLE_GAP_AD_TYPE_LESC_CONFIRM_VALUE 0x22 -#define BLE_GAP_AD_TYPE_LESC_RANDOM_VALUE 0x23 /** * @brief Macro for verifying basic parameters used for encoding single BLE AD Type. @@ -158,7 +156,7 @@ static ret_code_t lesc_value_encode(ble_gap_lesc_oob_data_t * p_lesc_value, // Encode LESC Confirm Value. p_encoded_data[*p_offset] = (uint8_t)(AD_TYPE_FIELD_SIZE + AD_TYPE_CONFIRM_VALUE_DATA_SIZE); *p_offset += AD_LENGTH_FIELD_SIZE; - p_encoded_data[*p_offset] = BLE_GAP_AD_TYPE_LESC_CONFIRM_VALUE; + p_encoded_data[*p_offset] = BLE_GAP_AD_TYPE_LESC_CONFIRMATION_VALUE; *p_offset += AD_TYPE_FIELD_SIZE; memcpy(&p_encoded_data[*p_offset], p_lesc_value->c, sizeof(p_lesc_value->c)); diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h new file mode 100644 index 0000000..ffec27a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2012 - 2019, 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 nfc_ble_oob_advdata Advertising and Scan Response Data Encoder for NFC OOB pairing + * @{ + * @ingroup nfc_ble_pair_msg + * @brief Function for encoding data in the Advertising and Scan Response Data format, which + * can be used to create payload of NFC message intended for initiating the Out-of-Band + * pairing. + */ + +#ifndef NFC_BLE_OOB_ADVDATA_H__ +#define NFC_BLE_OOB_ADVDATA_H__ + +#include +#include "ble_advdata.h" +#include "app_util.h" +#include "sdk_errors.h" + + +/**@brief Function for encoding data in the Advertising and Scan Response data format, which + * is used for NFC OOB pairing. + * + * + * @details This function encodes data into the Advertising and Scan Response data format (AD structures). + * Encoding is based on the selections in the supplied structures. This function uses + * @ref ble_advdata_encode to encode regular data and adds additional AD Structures which are specific + * for NFC OOB pairing: Security Manager TK Value, LESC OOB values, OOB Flags, and LE Role. + * + * @param[in] p_advdata Pointer to the structure for specifying the content of encoded data. + * @param[out] p_encoded_data Pointer to the buffer where encoded data will be returned. + * @param[in,out] p_len \c in: Size of \p p_encoded_data buffer. + * \c out: Length of encoded data. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in \p p_advdata. + * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could fit into the + * provided buffer or some encoded AD structure is too long and its + * length cannot be encoded with one octet. + */ +ret_code_t nfc_ble_oob_adv_data_encode(ble_advdata_t const * const p_advdata, + uint8_t * const p_encoded_data, + uint16_t * const p_len); + +/**@brief Function for encoding payload field of Security Manager TK Value AD Type. + * + * @param[in] p_tk_value Security Manager TK Value AD Type payload. + * @param[out] p_tk_payload_data Pointer to the buffer where TK payload data will be stored. + * + */ +void nfc_tk_value_payload_encode(ble_advdata_tk_value_t * p_tk_value, + uint8_t * p_tk_payload_data); + +#endif // NFC_BLE_OOB_ADVDATA_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c index f0c5f0b..f395795 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_BLE_PAIR_LIB) @@ -46,8 +46,8 @@ #include "nrf_drv_rng.h" #include "nfc_t2t_lib.h" #include "nfc_ble_pair_msg.h" -#include "ecc.h" #include "nrf_sdh_ble.h" +#include "nrf_ble_lesc.h" #define NRF_LOG_MODULE_NAME nfc_ble_pair #if NFC_BLE_PAIR_LIB_LOG_ENABLED @@ -76,36 +76,21 @@ NRF_LOG_MODULE_REGISTER(); return NRF_ERROR_INVALID_PARAM; \ } -#define BLE_GAP_LESC_P256_SK_LEN 32 /**< GAP LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Secret Key Length. */ #define TK_MAX_NUM 1 /**< Maximal number of TK locations in NDEF message buffer. */ #define NDEF_MSG_BUFF_SIZE 256 /**< Size of buffer for the NDEF pairing message. */ #define BLE_NFC_SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */ #define BLE_NFC_SEC_PARAM_IO_CAPS BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */ -typedef struct -{ - uint8_t sk[BLE_GAP_LESC_P256_SK_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Secret Key. */ -} ble_gap_lesc_p256_sk_t; - static ble_advertising_t * m_p_advertising = NULL; /**< Pointer to the advertising module instance. */ static uint8_t m_ndef_msg_buf[NDEF_MSG_BUFF_SIZE]; /**< NFC tag NDEF message buffer. */ static ble_advdata_tk_value_t m_oob_auth_key; /**< Temporary Key buffer used in OOB legacy pairing mode. */ static uint8_t * m_tk_group[TK_MAX_NUM]; /**< Locations of TK in NDEF message. */ static nfc_pairing_mode_t m_pairing_mode; /**< Current pairing mode. */ -static ble_gap_lesc_oob_data_t m_ble_lesc_oob_data; /**< LESC OOB data used in LESC OOB pairing mode. */ static ble_gap_sec_params_t m_sec_param; /**< Current Peer Manager secure parameters configuration. */ -static volatile bool m_connected = false; /**< Indicates if device is connected. */ -static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< Handle of the current connection. */ -static bool m_pending_advertise = false; /**< Flag used to indicate pending advertising that will be started after disconnection. */ - -__ALIGN(4) static ble_gap_lesc_p256_pk_t m_lesc_pk; /**< LESC ECC Public Key. */ -__ALIGN(4) static ble_gap_lesc_p256_sk_t m_lesc_sk; /**< LESC ECC Secret Key. */ -__ALIGN(4) static ble_gap_lesc_dhkey_t m_lesc_dhkey; /**< LESC ECC DH Key. */ -__ALIGN(4) static ble_gap_lesc_p256_pk_t m_lesc_peer_pk; /**< LESC Peer ECC Public Key. */ - +static uint8_t m_connections = 0; /**< Number of active connections. */ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context); @@ -186,20 +171,9 @@ static void nfc_callback(void * p_context, APP_ERROR_CHECK(err_code); } - // If device is connected, terminate connection and start advertising on BLE_GAP_EVT_DISCONNECTED event. - if (m_connected) + // Start advertising when NFC field is sensed and there is a place for another connection. + if (m_connections < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT) { - m_pending_advertise = true; - - err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); - if (err_code != NRF_ERROR_INVALID_STATE) - { - APP_ERROR_CHECK(err_code); - } - } - else - { - // Start advertising when NFC field is sensed. err_code = ble_advertising_start(m_p_advertising, BLE_ADV_MODE_FAST); if (err_code != NRF_ERROR_INVALID_STATE) { @@ -306,6 +280,7 @@ static ret_code_t pm_secure_mode_set(nfc_pairing_mode_t mode) * * @retval NRF_SUCCESS If new tag pairing data has been set correctly. * @retval NRF_ERROR_INVALID_PARAM If pairing mode is invalid. + * @retval NRF_ERROR_NULL If LESC oob data is missing. * @retval Other Other error codes might be returned depending on used modules. */ ret_code_t nfc_ble_pair_data_set(nfc_pairing_mode_t mode) @@ -341,19 +316,21 @@ ret_code_t nfc_ble_pair_data_set(nfc_pairing_mode_t mode) break; case NFC_PAIRING_MODE_LESC_OOB: + { // Generate LESC OOB data - err_code = sd_ble_gap_lesc_oob_data_get(BLE_CONN_HANDLE_INVALID, - &m_lesc_pk, - &m_ble_lesc_oob_data); + err_code = nrf_ble_lesc_own_oob_data_generate(); VERIFY_SUCCESS(err_code); + ble_gap_lesc_oob_data_t * p_lesc_oob_data = nrf_ble_lesc_own_oob_data_get(); + VERIFY_PARAM_NOT_NULL(p_lesc_oob_data); + // Encode NDEF message with BLE LESC OOB pairing data - LESC random and confirmation values. err_code = nfc_ble_pair_default_msg_encode(NFC_BLE_PAIR_MSG_BLUETOOTH_LE_SHORT, NULL, - &m_ble_lesc_oob_data, + p_lesc_oob_data, m_ndef_msg_buf, &ndef_msg_len); - break; + } break; case NFC_PAIRING_MODE_LESC_JUST_WORKS: err_code = nfc_ble_pair_default_msg_encode(NFC_BLE_PAIR_MSG_BLUETOOTH_LE_SHORT, @@ -364,21 +341,23 @@ ret_code_t nfc_ble_pair_data_set(nfc_pairing_mode_t mode) break; case NFC_PAIRING_MODE_GENERIC_OOB: + { // Generate LESC OOB data - err_code = sd_ble_gap_lesc_oob_data_get(BLE_CONN_HANDLE_INVALID, - &m_lesc_pk, - &m_ble_lesc_oob_data); + err_code = nrf_ble_lesc_own_oob_data_generate(); VERIFY_SUCCESS(err_code); + ble_gap_lesc_oob_data_t * p_lesc_oob_data = nrf_ble_lesc_own_oob_data_get(); + VERIFY_PARAM_NOT_NULL(p_lesc_oob_data); + // Encode NDEF message with Secure Simple Pairing OOB data - TK value and LESC Random and Confirmation Keys. err_code = nfc_ble_pair_msg_updatable_tk_encode(NFC_BLE_PAIR_MSG_BLUETOOTH_LE_SHORT, &m_oob_auth_key, - &m_ble_lesc_oob_data, + p_lesc_oob_data, m_ndef_msg_buf, &ndef_msg_len, m_tk_group, TK_MAX_NUM); - break; + } break; default: return NRF_ERROR_INVALID_PARAM; @@ -401,20 +380,18 @@ ret_code_t nfc_ble_pair_init(ble_advertising_t * const p_advertising, nfc_pairin // Check if pointer to the advertising module instance is not NULL VERIFY_PARAM_NOT_NULL(p_advertising); - + m_p_advertising = p_advertising; m_pairing_mode = mode; // Initialize RNG peripheral for authentication OOB data generation err_code = nrf_drv_rng_init(NULL); - if (err_code != NRF_ERROR_INVALID_STATE) + if (err_code != NRF_ERROR_INVALID_STATE && + err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED) { VERIFY_SUCCESS(err_code); } - // Initialize encryption module with random number generator use - ecc_init(true); - // Start NFC err_code = nfc_t2t_setup(nfc_callback, NULL); VERIFY_SUCCESS(err_code); @@ -423,18 +400,9 @@ ret_code_t nfc_ble_pair_init(ble_advertising_t * const p_advertising, nfc_pairin err_code = pm_secure_mode_set(mode); VERIFY_SUCCESS(err_code); - if ((mode == NFC_PAIRING_MODE_LESC_OOB) || - (mode == NFC_PAIRING_MODE_LESC_JUST_WORKS) || - (mode == NFC_PAIRING_MODE_GENERIC_OOB)) - { - // Generate new LESC keys - err_code = ecc_p256_keypair_gen(m_lesc_sk.sk, m_lesc_pk.pk); - VERIFY_SUCCESS(err_code); - - // Update Peer Manager with new LESC Public Key - err_code = pm_lesc_public_key_set(&m_lesc_pk); - VERIFY_SUCCESS(err_code); - } + // Generate LESC OOB data + err_code = nrf_ble_lesc_own_oob_data_generate(); + APP_ERROR_CHECK(err_code); // Set proper NFC data according to the pairing mode err_code = nfc_ble_pair_data_set(mode); @@ -457,19 +425,6 @@ ret_code_t nfc_ble_pair_mode_set(nfc_pairing_mode_t mode) { m_pairing_mode = mode; - if ((mode == NFC_PAIRING_MODE_LESC_OOB) || - (mode == NFC_PAIRING_MODE_LESC_JUST_WORKS) || - (mode == NFC_PAIRING_MODE_GENERIC_OOB)) - { - // Generate new LESC keys - err_code = ecc_p256_keypair_gen(m_lesc_sk.sk, m_lesc_pk.pk); - VERIFY_SUCCESS(err_code); - - // Update Peer Manager with new LESC Public Key - err_code = pm_lesc_public_key_set(&m_lesc_pk); - VERIFY_SUCCESS(err_code); - } - // Update Peer Manager settings according to the new pairing mode err_code = pm_secure_mode_set(mode); VERIFY_SUCCESS(err_code); @@ -510,24 +465,18 @@ static ret_code_t generate_lesc_keys(void) ret_code_t err_code = NRF_SUCCESS; // Generate new LESC keys - err_code = ecc_p256_keypair_gen(m_lesc_sk.sk, m_lesc_pk.pk); - VERIFY_SUCCESS(err_code); - - // Update Peer Manager with new LESC Public Key - err_code = pm_lesc_public_key_set(&m_lesc_pk); + err_code = nrf_ble_lesc_keypair_generate(); VERIFY_SUCCESS(err_code); if ((m_pairing_mode == NFC_PAIRING_MODE_LESC_OOB) || (m_pairing_mode == NFC_PAIRING_MODE_GENERIC_OOB)) { // Generate LESC OOB data. - err_code = sd_ble_gap_lesc_oob_data_get(BLE_CONN_HANDLE_INVALID, - &m_lesc_pk, - &m_ble_lesc_oob_data); + err_code = nrf_ble_lesc_own_oob_data_generate(); VERIFY_SUCCESS(err_code); // Update NDEF message with new LESC OOB data. - err_code = nfc_lesc_data_update(&m_ble_lesc_oob_data); + err_code = nfc_lesc_data_update(nrf_ble_lesc_own_oob_data_get()); VERIFY_SUCCESS(err_code); } @@ -556,41 +505,14 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) APP_ERROR_CHECK(err_code); break; - // Upon LESC Diffie_Hellman key request, reply with key computed from device secret key and peer public key - case BLE_GAP_EVT_LESC_DHKEY_REQUEST: - NRF_LOG_DEBUG("BLE_GAP_EVT_LESC_DHKEY_REQUEST"); - - // If LESC OOB pairing is on, perform authentication with OOB data - if (p_ble_evt->evt.gap_evt.params.lesc_dhkey_request.oobd_req) - { - err_code = sd_ble_gap_lesc_oob_data_set(p_ble_evt->evt.gap_evt.conn_handle, - &m_ble_lesc_oob_data, - NULL); - APP_ERROR_CHECK(err_code); - } - - // Buffer peer Public Key because ECC module arguments must be word aligned - memcpy(&m_lesc_peer_pk.pk[0], - &p_ble_evt->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer->pk[0], - BLE_GAP_LESC_P256_PK_LEN); - - // Compute D-H key - err_code = ecc_p256_shared_secret_compute(&m_lesc_sk.sk[0], - &m_lesc_peer_pk.pk[0], - &m_lesc_dhkey.key[0]); - APP_ERROR_CHECK(err_code); - - // Reply with obtained result - err_code = sd_ble_gap_lesc_dhkey_reply(p_ble_evt->evt.gap_evt.conn_handle, - &m_lesc_dhkey); - APP_ERROR_CHECK(err_code); - break; - case BLE_GAP_EVT_CONNECTED: - m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; - m_connected = true; + m_connections++; break; + case BLE_GAP_EVT_DISCONNECTED: + m_connections--; + // Intentional fallthrough. + case BLE_GAP_EVT_AUTH_STATUS: // Generate new LESC key pair and OOB data if ((m_pairing_mode == NFC_PAIRING_MODE_LESC_OOB) || @@ -598,40 +520,8 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) (m_pairing_mode == NFC_PAIRING_MODE_GENERIC_OOB)) { err_code = generate_lesc_keys(); - APP_ERROR_CHECK(err_code); - } - break; - - case BLE_GAP_EVT_DISCONNECTED: - // Start directed advertising if connection timeout occured - if (p_ble_evt->evt.gap_evt.params.disconnected.reason == BLE_HCI_CONNECTION_TIMEOUT) - { - err_code = ble_advertising_start(m_p_advertising, BLE_ADV_MODE_DIRECTED); - APP_ERROR_CHECK(err_code); - } - - m_connected = false; - m_conn_handle = BLE_CONN_HANDLE_INVALID; - - if (m_pending_advertise) - { - m_pending_advertise = false; - - // Start advertising when NFC field is sensed. - err_code = ble_advertising_start(m_p_advertising, BLE_ADV_MODE_FAST); - if (err_code != NRF_ERROR_INVALID_STATE) - { - APP_ERROR_CHECK(err_code); - } - } - else - { - // Generate new LESC key pair and OOB data only when connection is not terminated because of reading a new tag - if ((m_pairing_mode == NFC_PAIRING_MODE_LESC_OOB) || - (m_pairing_mode == NFC_PAIRING_MODE_LESC_JUST_WORKS) || - (m_pairing_mode == NFC_PAIRING_MODE_GENERIC_OOB)) + if (err_code != NRF_ERROR_BUSY) { - err_code = generate_lesc_keys(); APP_ERROR_CHECK(err_code); } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h index d76c5aa..2cf9d3b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_lib/nfc_ble_pair_lib.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_BLE_PAIR_LIB_H__ #define NFC_BLE_PAIR_LIB_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c index 25be55c..6cee35a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_BLE_PAIR_MSG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h index 92b8152..dfcdc1a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ble_pair_msg/nfc_ble_pair_msg.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_BLE_PAIR_MSG_H__ #define NFC_BLE_PAIR_MSG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c index 3d22a0e..0373ddd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,10 +35,11 @@ * 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(NFC_CH_COMMON) +#include "nfc_ble_pair_common.h" #include diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h similarity index 67% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h index 2bc9ce4..36b5387 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ble_oob_advdata/nfc_ble_oob_advdata.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/common/nfc_ble_pair_common.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,30 +35,28 @@ * 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 nfc_ble_oob_advdata Advertising and Scan Response Data Encoder for NFC OOB pairing - * @{ - * @ingroup nfc_ble_pair_msg - * @brief Function for encoding data in the Advertising and Scan Response Data format, which - * can be used to create payload of NFC message intended for initiating the Out-of-Band - * pairing. */ - -#ifndef NFC_BLE_OOB_ADVDATA_H__ -#define NFC_BLE_OOB_ADVDATA_H__ +#ifndef NFC_BLE_PAIR_COMMON_H__ +#define NFC_BLE_PAIR_COMMON_H__ #include #include "ble_advdata.h" -#include "app_util.h" -#include "sdk_errors.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * + * @defgroup nfc_ble_pair_common Common data for Connection Handover and Connection Handover Parser modules + * @{ + * @ingroup nfc_ble_pair_msg + */ -#define AD_TYPE_LE_ROLE_DATA_SIZE 1UL /**< Data size (in octets) of the LE Bluetooth Device Address AD type. */ +#define AD_TYPE_LE_ROLE_DATA_SIZE 1UL /**< Data size (in octets) of the LE Role AD type. */ #define AD_TYPE_LE_ROLE_SIZE (AD_DATA_OFFSET + \ - AD_TYPE_LE_ROLE_DATA_SIZE) /**< Size (in octets) of the LE Bluetooth Device Address AD type. */ + AD_TYPE_LE_ROLE_DATA_SIZE) /**< Size (in octets) of the LE Role AD type. */ #define AD_TYPE_TK_VALUE_DATA_SIZE (sizeof(ble_advdata_tk_value_t)) /**< Data size (in octets) of the Security Manager TK value AD type. */ #define AD_TYPE_TK_VALUE_SIZE (AD_DATA_OFFSET + \ AD_TYPE_TK_VALUE_DATA_SIZE) /**< Size (in octets) of the Security Manager TK value AD type. */ @@ -73,7 +71,7 @@ #define AD_TYPE_RANDOM_VALUE_SIZE (AD_DATA_OFFSET + \ AD_TYPE_RANDOM_VALUE_DATA_SIZE) /**< Size (in octets) of the LESC Random value AD type. */ #define AD_TYPE_LESC_SIZE (AD_TYPE_RANDOM_VALUE_SIZE + \ - AD_TYPE_CONFIRM_VALUE_SIZE) /**< Size (in octets) of the LESC OOB AD data field in NDEF message. */ + AD_TYPE_CONFIRM_VALUE_SIZE) /**< Total size (in octets) of the LESC OOB AD data fields in NDEF message. */ #define AD_TYPE_SEC_MGR_OOB_FLAG_SET 1U /**< Security Manager OOB Flag set. Flag selection is done using _POS defines */ #define AD_TYPE_SEC_MGR_OOB_FLAG_CLEAR 0U /**< Security Manager OOB Flag clear. Flag selection is done using _POS defines */ @@ -93,39 +91,16 @@ typedef enum NFC_BLE_ADVDATA_ROLE_ENCODED_BOTH_CENTRAL_PREFERRED /**< Peripheral and Central Role supported. Central Role preferred for connection establishment */ } nfc_ble_advdata_le_role_encoded_t; -/**@brief Function for encoding data in the Advertising and Scan Response data format, which - * is used for NFC OOB pairing. - * - * - * @details This function encodes data into the Advertising and Scan Response data format (AD structures). - * Encoding is based on the selections in the supplied structures. This function uses - * @ref ble_advdata_encode to encode regular data and adds additional AD Structures which are specific - * for NFC OOB pairing: Security Manager TK Value, LESC OOB values, OOB Flags, and LE Role. - * - * @param[in] p_advdata Pointer to the structure for specifying the content of encoded data. - * @param[out] p_encoded_data Pointer to the buffer where encoded data will be returned. - * @param[in,out] p_len \c in: Size of \p p_encoded_data buffer. - * \c out: Length of encoded data. - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in \p p_advdata. - * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could fit into the - * provided buffer or some encoded AD structure is too long and its - * length cannot be encoded with one octet. +/** + * @brief External reference to the type field of the Bluetooth LE Carrier Configuration NDEF record, defined + * in the file @c nfc_ble_pair_common.c */ -ret_code_t nfc_ble_oob_adv_data_encode(ble_advdata_t const * const p_advdata, - uint8_t * const p_encoded_data, - uint16_t * const p_len); +extern const uint8_t le_oob_rec_type_field[32]; -/**@brief Function for encoding payload field of Security Manager TK Value AD Type. - * - * @param[in] p_tk_value Security Manager TK Value AD Type payload. - * @param[out] p_tk_payload_data Pointer to the buffer where TK payload data will be stored. - * - */ -void nfc_tk_value_payload_encode(ble_advdata_tk_value_t * p_tk_value, - uint8_t * p_tk_payload_data); +/** @} */ -#endif // NFC_BLE_OOB_ADVDATA_H__ +#ifdef __cplusplus +} +#endif -/** @} */ +#endif // NFC_BLE_PAIR_COMMON_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c index 0baa992..e1b2a55 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_EP_OOB_REC) @@ -114,21 +114,11 @@ static ret_code_t nfc_ep_oob_bluetooth_device_address_encode(uint8_t * const p_ } /* Get BLE address */ - #if (NRF_SD_BLE_API_VERSION <= 2) - err_code = sd_ble_gap_address_get(&device_address); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - #endif - - #if (NRF_SD_BLE_API_VERSION >= 3) - err_code = sd_ble_gap_addr_get(&device_address); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - #endif + err_code = sd_ble_gap_addr_get(&device_address); + if (err_code != NRF_SUCCESS) + { + return err_code; + } /* Encode Bluetooth EP device address */ memcpy(p_encoded_data, device_address.addr, NFC_EP_OOB_REC_GAP_ADDR_LEN); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h index 7c4d067..b01046c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/ep_oob_rec/nfc_ep_oob_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_EP_OOB_REC_H__ #define NFC_EP_OOB_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c index e292bc2..0d06b44 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_HS_REC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h index 73b12b4..18f7f24 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/hs_rec/nfc_hs_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_HS_REC_H__ #define NFC_HS_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c index e98e75d..4df2498 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_LE_OOB_REC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h index 429700f..c6960c4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/connection_handover/le_oob_rec/nfc_le_oob_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_LE_OOB_REC_H__ #define NFC_LE_OOB_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/message/nfc_ndef_msg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/message/nfc_ndef_msg.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/message/nfc_ndef_msg.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/message/nfc_ndef_msg.c index c940e02..8942bf9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/message/nfc_ndef_msg.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/message/nfc_ndef_msg.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_MSG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/message/nfc_ndef_msg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/message/nfc_ndef_msg.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/message/nfc_ndef_msg.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/message/nfc_ndef_msg.h index 077d9bf..5cf1942 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/message/nfc_ndef_msg.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/message/nfc_ndef_msg.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_NDEF_MSG_H__ #define NFC_NDEF_MSG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/record/nfc_ndef_record.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/record/nfc_ndef_record.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/record/nfc_ndef_record.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/record/nfc_ndef_record.c index ccca4d4..1d01e7c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/record/nfc_ndef_record.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/record/nfc_ndef_record.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" #include "nordic_common.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/record/nfc_ndef_record.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/record/nfc_ndef_record.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/record/nfc_ndef_record.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/record/nfc_ndef_record.h index bc869f7..81c111b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/generic/record/nfc_ndef_record.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/generic/record/nfc_ndef_record.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_NDEF_RECORD_H__ #define NFC_NDEF_RECORD_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_msg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_msg.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_msg.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_msg.c index 59ba8b8..b61c0fa 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_msg.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_msg.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_LAUNCHAPP_MSG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_msg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_msg.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_msg.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_msg.h index 47199ea..57c4f53 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_msg.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_msg.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_LAUNCHAPP_MSG_H__ #define NFC_LAUNCHAPP_MSG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_rec.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_rec.c index 7b982df..807d12f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_LAUNCHAPP_REC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_rec.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_rec.h index 4564b7a..86fda76 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/launchapp/nfc_launchapp_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/launchapp/nfc_launchapp_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_LAUNCHAPP_REC_H__ #define NFC_LAUNCHAPP_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c index 5ac0650..6c08172 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_MSG_PARSER) @@ -47,11 +47,12 @@ #if NFC_NDEF_MSG_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL NFC_NDEF_MSG_PARSER_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_NDEF_MSG_PARSER_INFO_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_NDEF_MSG_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_NDEF_MSG_PARSER_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_NDEF_MSG_PARSER_LOG_ENABLED ret_code_t ndef_msg_parser(uint8_t * const p_result_buf, uint32_t * const p_result_buf_len, @@ -82,7 +83,6 @@ void ndef_msg_printout(nfc_ndef_msg_desc_t * const p_msg_desc) { uint32_t i; - nrf_delay_ms(100); NRF_LOG_INFO("NDEF message contains %d record(s)", p_msg_desc->record_count); for (i = 0; i < p_msg_desc->record_count; i++) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h index 6b1f8eb..a920a74 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_NDEF_MSG_PARSER_H__ #define NFC_NDEF_MSG_PARSER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c index 8817fb6..7e2e4d7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_MSG_PARSER) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h index c8c575f..ec2a71a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/message/nfc_ndef_msg_parser_local.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_NDEF_MSG_PARSER_LOCAL_H__ #define NFC_NDEF_MSG_PARSER_LOCAL_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c index 7840b7c..3a249b2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/record/nfc_ndef_record_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_RECORD_PARSER) @@ -51,11 +51,12 @@ #if NFC_NDEF_RECORD_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL NFC_NDEF_RECORD_PARSER_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_NDEF_RECORD_PARSER_INFO_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_NDEF_RECORD_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_NDEF_RECORD_PARSER_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_NDEF_RECORD_PARSER_LOG_ENABLED /* Sum of sizes of fields: TNF-flags, Type Length, Payload Length in short NDEF record. */ #define NDEF_RECORD_BASE_LONG_SHORT (2 + NDEF_RECORD_PAYLOAD_LEN_SHORT_SIZE) @@ -205,8 +206,8 @@ void ndef_record_printout(uint32_t num, nfc_ndef_record_desc_t * const p_rec_des if (p_bin_pay_desc->p_payload != NULL) { - NRF_LOG_INFO("Payload data (%d bytes):", p_bin_pay_desc->payload_length); - NRF_LOG_HEXDUMP_INFO((uint8_t *)p_bin_pay_desc->p_payload, p_bin_pay_desc->payload_length); + NRF_LOG_INFO("Payload length: %d bytes", p_bin_pay_desc->payload_length); + NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_bin_pay_desc->p_payload, p_bin_pay_desc->payload_length); } else { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h index 3403c9c..23cc0d5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/parser/record/nfc_ndef_record_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_NDEF_RECORD_PARSER_H__ #define NFC_NDEF_RECORD_PARSER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/text/nfc_text_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/text/nfc_text_rec.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/text/nfc_text_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/text/nfc_text_rec.c index a2f4b7c..0cadf16 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/text/nfc_text_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/text/nfc_text_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_TEXT_RECORD) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/text/nfc_text_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/text/nfc_text_rec.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/text/nfc_text_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/text/nfc_text_rec.h index 3f282eb..92ee9af 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/text/nfc_text_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/text/nfc_text_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_TEXT_REC_H__ #define NFC_TEXT_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_msg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_msg.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_msg.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_msg.c index 357b7e2..9237368 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_msg.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_msg.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_URI_MSG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_msg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_msg.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_msg.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_msg.h index 95da4b6..0816062 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_msg.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_msg.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_URI_MSG_H__ #define NFC_URI_MSG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_rec.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_rec.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_rec.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_rec.c index 431f119..272d38d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_rec.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_rec.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_NDEF_URI_REC) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_rec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_rec.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_rec.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_rec.h index 1a37149..3201630 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/ndef/uri/nfc_uri_rec.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/ndef/uri/nfc_uri_rec.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_URI_REC_H__ #define NFC_URI_REC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.c new file mode 100644 index 0000000..d428494 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.c @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2018 - 2019, 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(NFC_PLATFORM) + +#include "nfc_platform.h" +#include "nrf_drv_clock.h" + +#define NRF_LOG_MODULE_NAME nfc_platform +#if NFC_PLATFORM_LOG_ENABLED +#define NRF_LOG_LEVEL NFC_PLATFORM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR NFC_PLATFORM_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR NFC_PLATFORM_DEBUG_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); +#else // NFC_PLATFORM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#include "nrf_log.h" +#endif // NFC_PLATFORM_LOG_ENABLED + +/* Static data */ +static nrf_drv_clock_handler_item_t m_clock_handler_item; /**< Clock event handler item structure. */ + +/**@brief Function for handling events from the Clock module. + * + * @param[in] event Clock event. + * + */ +static inline void clock_event_handler(nrf_drv_clock_evt_type_t event) +{ + switch(event) + { + case NRF_DRV_CLOCK_EVT_HFCLK_STARTED: + /* Activate NFCT only when HFXO is running */ + nrfx_nfct_state_force(NRFX_NFCT_STATE_ACTIVATED); + break; + + default: + /* No implementation required */ + break; + } +} + + +nrfx_err_t nfc_platform_setup(void) +{ + nrfx_err_t err_code; + + /* Initialize the Clock module for handling high precision clock requests */ + m_clock_handler_item.event_handler = clock_event_handler; + m_clock_handler_item.p_next = NULL; + + err_code = nrf_drv_clock_init(); + if (err_code == NRF_ERROR_MODULE_ALREADY_INITIALIZED) + { + err_code = NRFX_SUCCESS; + } + else if (err_code != NRF_SUCCESS) + { + return NRFX_ERROR_INTERNAL; + } + + NRF_LOG_DEBUG("Utils init"); + return err_code; +} + + +void nfc_platform_event_handler(nrfx_nfct_evt_t const * p_event) +{ + switch (p_event->evt_id) + { + case NRFX_NFCT_EVT_FIELD_DETECTED: + NRF_LOG_DEBUG("Field detected"); + nrf_drv_clock_hfclk_request(&m_clock_handler_item); + break; + + case NRFX_NFCT_EVT_FIELD_LOST: + NRF_LOG_DEBUG("Field lost"); + nrf_drv_clock_hfclk_release(); + break; + + default: + /* No implementation required */ + break; + } +} + +#endif // NRF_MODULE_ENABLED(NFC_PLATFORM) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.h new file mode 100644 index 0000000..3972898 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/platform/nfc_platform.h @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2018 - 2019, 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 NFC_PLATFORM_H__ +#define NFC_PLATFORM_H__ + +/** @file + * + * @addtogroup nfc_api + * + * @defgroup nfc_platform Platform-specific module for NFC + * @{ + * @ingroup nfc_api + * @brief @tagAPI52 Platform-specific module for Near Field Communication Tag (NFCT). + * + * This module is used to set up platform-specific components that are required for NFC, and to + * activate NFCT peripheral when all necessary conditions are fulfilled. + * + * @note Before the NFCT peripheral enters the ACTIVATED state, the HFXO must be running. To fulfill + * this requirement, this module uses the clock management module. + * + */ + +#include "nrfx_nfct.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Function for initializing platform-specific modules required by NFC. + * + * This function sets up clock managing interface and other platform specific components + * that are required for NFC. + * + * @retval NRFX_SUCCESS If the NFC module is initialized successfully. If one + * of the arguments is invalid, an error code is returned. + */ +nrfx_err_t nfc_platform_setup(void); + + +/** + * @brief Function for handling NFCT events that require platform-specific actions. + * + * This function is used by the NFC platform module to observe NFC events. This event flow is + * necessary to track in order to determine when HFXO must be running and when the NFCT peripheral must + * be activated. + * + * @param[in] p_event NFCT driver event. + */ +void nfc_platform_event_handler(nrfx_nfct_evt_t const * p_event); + + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif /* NFC_PLATFORM_H__ */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_lib/license.txt similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/license.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_lib/license.txt index fb8b852..af2c100 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/license.txt +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_lib/license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2015 - 2017, Telit Communications Cyprus Ltd +Copyright (c) 2015 - 2019, Telit Communications Cyprus Ltd All rights reserved. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/nfc_t2t_lib.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_lib/nfc_t2t_lib.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/nfc_t2t_lib.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_lib/nfc_t2t_lib.h index b70e9f7..99a4c27 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_lib/nfc_t2t_lib.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_lib/nfc_t2t_lib.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Telit Communications Cyprus Ltd - * + * Copyright (c) 2015 - 2019, Telit Communications Cyprus Ltd + * * 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 @@ -35,7 +35,7 @@ * 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 NFC_T2T_LIB_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_t2t_parser.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_t2t_parser.c similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_t2t_parser.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_t2t_parser.c index 1d04378..9d8a267 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_t2t_parser.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_t2t_parser.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NFC_T2T_PARSER) @@ -49,11 +49,12 @@ #if NFC_T2T_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL NFC_T2T_PARSER_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_T2T_PARSER_INFO_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_T2T_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_T2T_PARSER_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_T2T_PARSER_LOG_ENABLED /// Gets least significant nibble (a 4-bit value) from a byte. #define LSN_GET(val) (val & 0x0F) @@ -620,21 +621,21 @@ void type_2_tag_printout(type_2_tag_t * p_type_2_tag) NRF_LOG_INFO("Type 2 Tag contents:"); NRF_LOG_INFO("Number of TLV blocks: %d", p_type_2_tag->tlv_count); - NRF_LOG_INFO("Internal data:"); - NRF_LOG_INFO(" Manufacturer ID: 0x%02x", p_type_2_tag->sn.manufacturer_id); - NRF_LOG_INFO(" Serial number part 1: 0x%04x", p_type_2_tag->sn.serial_number_part_1); - NRF_LOG_INFO(" Check byte 0: 0x%02x", p_type_2_tag->sn.check_byte_0); - NRF_LOG_INFO(" Serial number part 2: 0x%08lx", p_type_2_tag->sn.serial_number_part_2); - NRF_LOG_INFO(" Check byte 1: 0x%02x", p_type_2_tag->sn.check_byte_1); - NRF_LOG_INFO(" Internal byte: 0x%02x", p_type_2_tag->sn.internal); - NRF_LOG_INFO(" Lock bytes: 0x%04x", p_type_2_tag->lock_bytes); - - NRF_LOG_INFO("Capability Container data:"); - NRF_LOG_INFO(" Major version number: %d", p_type_2_tag->cc.major_version); - NRF_LOG_INFO(" Minor version number: %d", p_type_2_tag->cc.minor_version); - NRF_LOG_INFO(" Data area size: %d", p_type_2_tag->cc.data_area_size); - NRF_LOG_INFO(" Read access: 0x%02X", p_type_2_tag->cc.read_access); - NRF_LOG_INFO(" Write access: 0x%02X", p_type_2_tag->cc.write_access); + NRF_LOG_DEBUG("Internal data:"); + NRF_LOG_DEBUG(" Manufacturer ID: 0x%02x", p_type_2_tag->sn.manufacturer_id); + NRF_LOG_DEBUG(" Serial number part 1: 0x%04x", p_type_2_tag->sn.serial_number_part_1); + NRF_LOG_DEBUG(" Check byte 0: 0x%02x", p_type_2_tag->sn.check_byte_0); + NRF_LOG_DEBUG(" Serial number part 2: 0x%08lx", p_type_2_tag->sn.serial_number_part_2); + NRF_LOG_DEBUG(" Check byte 1: 0x%02x", p_type_2_tag->sn.check_byte_1); + NRF_LOG_DEBUG(" Internal byte: 0x%02x", p_type_2_tag->sn.internal); + NRF_LOG_DEBUG(" Lock bytes: 0x%04x", p_type_2_tag->lock_bytes); + + NRF_LOG_DEBUG("Capability Container data:"); + NRF_LOG_DEBUG(" Major version number: %d", p_type_2_tag->cc.major_version); + NRF_LOG_DEBUG(" Minor version number: %d", p_type_2_tag->cc.minor_version); + NRF_LOG_DEBUG(" Data area size: %d", p_type_2_tag->cc.data_area_size); + NRF_LOG_DEBUG(" Read access: 0x%02X", p_type_2_tag->cc.read_access); + NRF_LOG_DEBUG(" Write access: 0x%02X", p_type_2_tag->cc.write_access); for (i = 0; i < p_type_2_tag->tlv_count; i++) { @@ -664,13 +665,13 @@ void type_2_tag_printout(type_2_tag_t * p_type_2_tag) break; } - NRF_LOG_INFO(" Length: %d", p_type_2_tag->p_tlv_block_array[i].length); + NRF_LOG_INFO(" Data length: %d", p_type_2_tag->p_tlv_block_array[i].length); if (p_type_2_tag->p_tlv_block_array[i].length > 0) { - NRF_LOG_INFO(" Data:"); - NRF_LOG_HEXDUMP_INFO(p_type_2_tag->p_tlv_block_array[i].p_value, - p_type_2_tag->p_tlv_block_array[i].length); + NRF_LOG_DEBUG(" Data:"); + NRF_LOG_HEXDUMP_DEBUG(p_type_2_tag->p_tlv_block_array[i].p_value, + p_type_2_tag->p_tlv_block_array[i].length); } } } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_t2t_parser.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_t2t_parser.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_t2t_parser.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_t2t_parser.h index 5502aeb..1f307f4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_t2t_parser.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_t2t_parser.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_TYPE_2_TAG_PARSER_H__ #define NFC_TYPE_2_TAG_PARSER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_tlv_block.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_tlv_block.h similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_tlv_block.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_tlv_block.h index 308789b..3333f11 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t2t_parser/nfc_tlv_block.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t2t_parser/nfc_tlv_block.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_TLV_BLOCK_H__ #define NFC_TLV_BLOCK_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_lib/license.txt similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/license.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_lib/license.txt index d629f64..2d8ddbe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/license.txt +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_lib/license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016 - 2017, Telit Communications Cyprus Ltd +Copyright (c) 2016 - 2019, Telit Communications Cyprus Ltd All rights reserved. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_t4t_lib.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_lib/nfc_t4t_lib.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_t4t_lib.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_lib/nfc_t4t_lib.h index 9778d79..9032607 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_lib/nfc_t4t_lib.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_lib/nfc_t4t_lib.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Telit Communications Cyprus Ltd - * + * Copyright (c) 2016 - 2019, Telit Communications Cyprus Ltd + * * 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 @@ -35,7 +35,7 @@ * 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 NFC_T4T_LIB_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c index a4769d9..0909d2b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" #if NFC_T4T_APDU_ENABLED @@ -49,11 +49,13 @@ #if NFC_T4T_APDU_LOG_ENABLED #define NRF_LOG_LEVEL NFC_T4T_APDU_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_T4T_APDU_LOG_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_T4T_APDU_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_T4T_APDU_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_T4T_APDU_LOG_ENABLED + /** * @brief Field sizes that can be present in CAPDU. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h index d597661..3b10914 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/apdu/nfc_t4t_apdu.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_T4T_APDU_H__ #define NFC_T4T_APDU_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c index c7db5f2..9ac9002 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" #if NFC_T4T_CC_FILE_PARSER_ENABLED @@ -50,11 +50,12 @@ #if NFC_T4T_CC_FILE_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL NFC_T4T_CC_FILE_PARSER_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_T4T_CC_FILE_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_T4T_CC_FILE_PARSER_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_T4T_CC_FILE_PARSER_LOG_ENABLED /** * @brief Valid value range for CCLEN field. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h index 8403b0a..db506a5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/cc_file/nfc_t4t_cc_file.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_T4T_CC_FILE_H__ #define NFC_T4T_CC_FILE_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c index a3c13d4..a6b9c9b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" #if NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED @@ -50,11 +50,12 @@ #if NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED #define NRF_LOG_LEVEL NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED #define CC_FILE_ID 0xE103 ///< File Identifier of Capability Container. #define FILE_ID_SIZE 2 ///< Size of File Identifier field in CC file. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h index 1dc56e8..50dc77b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/hl_detection_procedure/nfc_t4t_hl_detection_procedures.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_T4T_HL_DETECTION_PROCEDURES_H__ #define NFC_T4T_HL_DETECTION_PROCEDURES_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c index 3932337..6bb1ef3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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_config.h" #if NFC_T4T_TLV_BLOCK_PARSER_ENABLED @@ -50,11 +50,12 @@ #if NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL #define NRF_LOG_INFO_COLOR NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #else // NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED #define NRF_LOG_LEVEL 0 -#endif // NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED #include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); +#endif // NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED #define TLV_TYPE_FIELD_LEN 1U ///< Length of a type field. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h index 9e62bd9..e827b92 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/nfc/t4t_parser/tlv/nfc_t4t_tlv_block.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NFC_T4T_TLV_BLOCK_H__ #define NFC_T4T_TLV_BLOCK_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/sdk_validation.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/sdk_validation.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/sdk_validation.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/sdk_validation.h index 617f0e7..c59fd27 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/sdk_validation.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/sdk_validation.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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 SDK_VALIDATION_H #define SDK_VALIDATION_H @@ -104,7 +104,7 @@ extern "C" { #endif // Validate peripheral sharing feature -#if ((defined(PERIPHERAL_RESOURCE_SHARING_ENABLED)) && (!PERIPHERAL_RESOURCE_SHARING_ENABLED)) +#if !NRFX_CHECK(NRFX_PRS_ENABLED) #if ((defined(TWIM0_ENABLED) && defined(TWIS0_ENABLED)) &&\ ((TWIM0_ENABLED + TWIS0_ENABLED) > 1)) @@ -271,12 +271,12 @@ extern "C" { #error "Peripherals overlap. SPIM2, SPI2 - only one of these can be enabled." #endif -#endif +#endif // !NRFX_CHECK(NRFX_PRS_ENABLED) #ifdef NFCT_PRESENT -#if ((defined(NFC_HAL_ENABLED) && defined(CLOCK_ENABLED)) &&\ - ((NFC_HAL_ENABLED) && (!CLOCK_ENABLED))) +#if ((defined(NFC_HAL_ENABLED) && defined(NRF_CLOCK_ENABLED)) &&\ + ((NFC_HAL_ENABLED) && (!NRF_CLOCK_ENABLED))) #error "NFC_HAL requires CLOCK to work. NFC_HAL can not be enabled without CLOCK." #endif @@ -289,10 +289,10 @@ extern "C" { // Complex driver validation #ifdef LPCOMP_PRESENT -#if ((defined(COMP_ENABLED) && defined(LPCOMP_ENABLED)) &&\ - (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ - ((COMP_ENABLED + LPCOMP_ENABLED) > 1)) -#error "Peripherals overlap. SPIM2, SPI2 - only one of these can be enabled." +#if ((defined(COMP_ENABLED) && defined(LPCOMP_ENABLED)) && \ + (!NRFX_CHECK(NRFX_PRS_ENABLED)) && \ + ((COMP_ENABLED + LPCOMP_ENABLED) > 1)) +#error "Peripherals overlap. COMP, LPCOMP - only one of these can be enabled." #endif #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh.c similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh.c index ae7ebb3..2fff70a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -63,12 +63,20 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); + +// Validate configuration options. + #if (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH) - #if !APP_SCHEDULER_ENABLED - #error "APP_SCHEDULER is required." + #if (!APP_SCHEDULER_ENABLED) + #error app_scheduler is required when NRF_SDH_DISPATCH_MODEL is set to NRF_SDH_DISPATCH_MODEL_APPSH #endif #include "app_scheduler.h" -#endif // (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH) +#endif + +#if ( (NRF_SDH_CLOCK_LF_SRC == NRF_CLOCK_LF_SRC_RC) \ + && (NRF_SDH_CLOCK_LF_ACCURACY != NRF_CLOCK_LF_ACCURACY_500_PPM)) + #warning Please select NRF_CLOCK_LF_ACCURACY_500_PPM when using NRF_CLOCK_LF_SRC_RC +#endif // Create section "sdh_req_observers". @@ -170,29 +178,6 @@ static void softdevice_evt_irq_disable(void) } -#ifndef S140 -static void swi_interrupt_priority_workaround(void) -{ - // The priorities of SoftDevice SWI SD_EVT_IRQn and RADIO_NOTIFICATION_IRQn - // in version S132 v5.0.0, S112 v5.0.0, S212 v5.0.0 and S332 v5.0.0 are set to 6. - // Set their priority to APP_IRQ_PRIORITY_LOWEST (7) so that they don't preempt - // peripheral interrupts and vice-versa. - -#ifdef SOFTDEVICE_PRESENT - ret_code_t ret_code; - ret_code = sd_nvic_SetPriority(SD_EVT_IRQn, APP_IRQ_PRIORITY_LOWEST); - APP_ERROR_CHECK(ret_code); - ret_code = sd_nvic_SetPriority(RADIO_NOTIFICATION_IRQn, APP_IRQ_PRIORITY_LOWEST); - APP_ERROR_CHECK(ret_code); -#else - // In case of serialization, NVIC must be accessed directly. - NVIC_SetPriority(SD_EVT_IRQn, APP_IRQ_PRIORITY_LOWEST); - NVIC_SetPriority(RADIO_NOTIFICATION_IRQn, APP_IRQ_PRIORITY_LOWEST); -#endif -} -#endif - - ret_code_t nrf_sdh_enable_request(void) { ret_code_t ret_code; @@ -216,37 +201,29 @@ ret_code_t nrf_sdh_enable_request(void) nrf_clock_lf_cfg_t const clock_lf_cfg = { - .source = NRF_SDH_CLOCK_LF_SRC, - .rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV, - .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV, - #ifdef S140 - .xtal_accuracy = NRF_SDH_CLOCK_LF_XTAL_ACCURACY - #else - .accuracy = NRF_SDH_CLOCK_LF_XTAL_ACCURACY - #endif + .source = NRF_SDH_CLOCK_LF_SRC, + .rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV, + .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV, + .accuracy = NRF_SDH_CLOCK_LF_ACCURACY }; - #ifdef ANT_LICENSE_KEY - ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY); - #else - ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler); - #endif + CRITICAL_REGION_ENTER(); +#ifdef ANT_LICENSE_KEY + ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY); +#else + ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler); +#endif + m_nrf_sdh_enabled = (ret_code == NRF_SUCCESS); + CRITICAL_REGION_EXIT(); if (ret_code != NRF_SUCCESS) { return ret_code; } - m_nrf_sdh_enabled = true; m_nrf_sdh_continue = false; m_nrf_sdh_suspended = false; -#ifndef S140 - // Set the interrupt priority after enabling the SoftDevice, since - // sd_softdevice_enable() sets the SoftDevice interrupt priority. - swi_interrupt_priority_workaround(); -#endif - // Enable event interrupt. // Interrupt priority has already been set by the stack. softdevices_evt_irq_enable(); @@ -279,13 +256,16 @@ ret_code_t nrf_sdh_disable_request(void) // Notify observers about starting SoftDevice disable process. sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLE_PREPARE); - ret_code = sd_softdevice_disable(); + CRITICAL_REGION_ENTER(); + ret_code = sd_softdevice_disable(); + m_nrf_sdh_enabled = false; + CRITICAL_REGION_EXIT(); + if (ret_code != NRF_SUCCESS) { return ret_code; } - m_nrf_sdh_enabled = false; m_nrf_sdh_continue = false; softdevice_evt_irq_disable(); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh.h index 2fbd0dd..6c3293e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -49,6 +49,7 @@ #ifndef NRF_SDH_H__ #define NRF_SDH_H__ +#include #include "sdk_config.h" #include "sdk_errors.h" #include "nrf_section_iter.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ant.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ant.c similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ant.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ant.c index 1aa6a19..129314d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ant.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ant.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -45,6 +45,7 @@ #include "nrf_sdh.h" #include "app_error.h" +#include "nrf_strerror.h" #include "ant_interface.h" @@ -70,6 +71,9 @@ NRF_SECTION_SET_DEF(sdh_ant_observers, nrf_sdh_ant_evt_observer_t, NRF_SDH_ANT_O __ALIGN(4) static uint8_t m_ant_stack_buffer[NRF_SDH_ANT_BUF_SIZE]; +static bool m_stack_is_enabled; + + ret_code_t nrf_sdh_ant_enable(void) { ANT_ENABLE ant_enable_cfg = @@ -82,6 +86,15 @@ ret_code_t nrf_sdh_ant_enable(void) }; ret_code_t ret_code = sd_ant_enable(&ant_enable_cfg); + if (ret_code == NRF_SUCCESS) + { + m_stack_is_enabled = true; + } + else + { + NRF_LOG_ERROR("sd_ant_enable() returned %s.", nrf_strerror_get(ret_code)); + } + return ret_code; } @@ -92,9 +105,18 @@ ret_code_t nrf_sdh_ant_enable(void) */ static void nrf_sdh_ant_evts_poll(void * p_context) { + UNUSED_VARIABLE(p_context); + ret_code_t ret_code; - UNUSED_VARIABLE(p_context); +#ifndef SER_CONNECTIVITY + if (!m_stack_is_enabled) + { + return; + } +#else + UNUSED_VARIABLE(m_stack_is_enabled); +#endif // SER_CONNECTIVITY while (true) { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ant.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ant.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ant.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ant.h index da3bd7d..5e56c0a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ant.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ant.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ble.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ble.c similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ble.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ble.c index 990ba0a..023c3d2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ble.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ble.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" @@ -84,6 +84,9 @@ NRF_SECTION_SET_DEF(sdh_ble_observers, nrf_sdh_ble_evt_observer_t, NRF_SDH_BLE_O #define APP_RAM_START (uint32_t)m_ram_start +static bool m_stack_is_enabled; + + ret_code_t nrf_sdh_ble_app_ram_start_get(uint32_t * p_app_ram_start) { if (p_app_ram_start == NULL) @@ -107,7 +110,7 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st return ret_code; } -#ifdef S112 +#if defined (S112) || defined(S312) STATIC_ASSERT(NRF_SDH_BLE_CENTRAL_LINK_COUNT == 0, "When using s112, NRF_SDH_BLE_CENTRAL_LINK_COUNT must be 0."); #endif @@ -134,10 +137,10 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st // Configure the connection roles. memset(&ble_cfg, 0, sizeof(ble_cfg)); ble_cfg.gap_cfg.role_count_cfg.periph_role_count = NRF_SDH_BLE_PERIPHERAL_LINK_COUNT; -#ifndef S112 +#if !defined (S112) && !defined(S312) && !defined(S113) ble_cfg.gap_cfg.role_count_cfg.central_role_count = NRF_SDH_BLE_CENTRAL_LINK_COUNT; - ble_cfg.gap_cfg.role_count_cfg.central_sec_count = NRF_SDH_BLE_CENTRAL_LINK_COUNT ? - BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT : 0; + ble_cfg.gap_cfg.role_count_cfg.central_sec_count = MIN(NRF_SDH_BLE_CENTRAL_LINK_COUNT, + BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT); #endif ret_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, *p_ram_start); @@ -159,7 +162,7 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATT.", nrf_strerror_get(ret_code)); } -#endif +#endif // NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23 #endif // NRF_SDH_BLE_TOTAL_LINK_COUNT != 0 // Configure number of custom UUIDS. @@ -220,19 +223,33 @@ ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start) // Start of RAM, obtained from linker symbol. uint32_t const app_ram_start_link = *p_app_ram_start; - NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link); - ret_code_t ret_code = sd_ble_enable(p_app_ram_start); - if (*p_app_ram_start != app_ram_start_link) + if (*p_app_ram_start > app_ram_start_link) { - NRF_LOG_WARNING("RAM starts at 0x%x, can be adjusted to 0x%x.", - app_ram_start_link, *p_app_ram_start); + NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice."); - NRF_LOG_WARNING("RAM size can be adjusted to 0x%x.", + NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.", + app_ram_start_link, *p_app_ram_start); + NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.", ram_end_address_get() - (*p_app_ram_start)); } + else + { + NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link); + if (*p_app_ram_start != app_ram_start_link) + { + NRF_LOG_DEBUG("RAM start location can be adjusted to 0x%x.", *p_app_ram_start); - if (ret_code != NRF_SUCCESS) + NRF_LOG_DEBUG("RAM size for application can be adjusted to 0x%x.", + ram_end_address_get() - (*p_app_ram_start)); + } + } + + if (ret_code == NRF_SUCCESS) + { + m_stack_is_enabled = true; + } + else { NRF_LOG_ERROR("sd_ble_enable() returned %s.", nrf_strerror_get(ret_code)); } @@ -247,13 +264,20 @@ ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start) */ static void nrf_sdh_ble_evts_poll(void * p_context) { + UNUSED_VARIABLE(p_context); + ret_code_t ret_code; - UNUSED_VARIABLE(p_context); + if (!m_stack_is_enabled) + { + return; + } while (true) { + /*lint -save -e(587) */ __ALIGN(4) uint8_t evt_buffer[NRF_SDH_BLE_EVT_BUF_SIZE]; + /*lint -restore */ ble_evt_t * p_ble_evt; uint16_t evt_len = (uint16_t)sizeof(evt_buffer); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ble.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ble.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ble.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ble.h index 0c253b8..b76d74d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_ble.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_ble.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -63,11 +63,8 @@ extern "C" { #endif /** @brief Size of the buffer for a BLE event. */ -#if (defined(NRF_SD_BLE_API_VERSION) && (NRF_SD_BLE_API_VERSION < 3)) -#define NRF_SDH_BLE_EVT_BUF_SIZE (sizeof(ble_evt_t) + (NRF_SDH_BLE_GATT_MAX_MTU_SIZE)) -#else #define NRF_SDH_BLE_EVT_BUF_SIZE BLE_EVT_LEN_MAX(NRF_SDH_BLE_GATT_MAX_MTU_SIZE) -#endif + #if !(defined(__LINT__)) /**@brief Macro for registering @ref nrf_sdh_soc_evt_observer_t. Modules that want to be diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_freertos.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_freertos.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_freertos.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_freertos.c index 5c23ca5..eb3bf69 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_freertos.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_freertos.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 "nrf_sdh_freertos.h" @@ -81,7 +81,6 @@ static void softdevice_task(void * pvParameter) while (true) { - nrf_sdh_evts_poll(); /* let the handlers run first, incase the EVENT occured before creating this task */ (void) ulTaskNotifyTake(pdTRUE, /* Clear the notification value before exiting (equivalent to the binary semaphore). */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_freertos.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_freertos.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_freertos.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_freertos.h index d0f3e32..c40855e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_freertos.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_freertos.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SDH_FREERTOS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_soc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_soc.c similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_soc.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_soc.c index cf03702..252a043 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_soc.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_soc.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_soc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_soc.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_soc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_soc.h index 42eb541..00b41c6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/common/nrf_sdh_soc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/common/nrf_sdh_soc.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 @@ -50,7 +50,7 @@ #ifndef NRF_SDH_SOC_H__ #define NRF_SDH_SOC_H__ -#include "app_util.h" +#include "sdk_common.h" #include "nrf_section_iter.h" #include "nrf_soc.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf52/nrf_mbr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers/nrf_mbr.h similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf52/nrf_mbr.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers/nrf_mbr.h index c95bb8d..42e09fc 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf52/nrf_mbr.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers/nrf_mbr.h @@ -64,9 +64,22 @@ extern "C" { #define MBR_PAGE_SIZE_IN_WORDS (1024) /** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash. -This is the offset where the first byte of the SoftDevice hex file is written.*/ +This is the offset where the first byte of the SoftDevice hex file is written. */ #define MBR_SIZE (0x1000) +/** @brief Location (in the flash memory) of the bootloader address. */ +#define MBR_BOOTLOADER_ADDR (0xFF8) + +/** @brief Location (in UICR) of the bootloader address. */ +#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0])) + +/** @brief Location (in the flash memory) of the address of the MBR parameter page. */ +#define MBR_PARAM_PAGE_ADDR (0xFFC) + +/** @brief Location (in UICR) of the address of the MBR parameter page. */ +#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1])) + + /** @} */ /** @addtogroup NRF_MBR_ENUMS Enumerations @@ -81,13 +94,13 @@ enum NRF_MBR_SVCS /**@brief Possible values for ::sd_mbr_command_t.command */ enum NRF_MBR_COMMANDS { - SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see sd_mbr_command_copy_bl_t*/ + SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/ SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/ - SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD*/ + SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/ SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/ - SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset @see ::sd_mbr_command_vector_table_base_set_t*/ + SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/ SD_MBR_COMMAND_RESERVED, - SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address @see ::sd_mbr_command_irq_forward_address_set_t*/ + SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/ }; /** @} */ @@ -96,6 +109,7 @@ enum NRF_MBR_COMMANDS * @{ */ /**@brief This command copies part of a new SoftDevice + * * The destination area is erased before copying. * If dst is in the middle of a flash page, that whole flash page will be erased. * If (dst+len) is in the middle of a flash page, that whole flash page will be erased. @@ -127,38 +141,54 @@ typedef struct /**@brief This command copies a new BootLoader. - * With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR. * - * Destination is erased by this function. - * If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased. + * The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to + * the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * The bootloader destination is erased by this function. + * If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased. * - * This function will use PROTENSET to protect the flash that is not intended to be written. + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. * - * On success, this function will not return. It will start the new BootLoader from reset-vector as normal. + * This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is + * not intended to be written. + * + * On success, this function will not return. It will start the new bootloader from reset-vector as normal. * * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. - * @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set. + * @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set. * @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area. - * @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info) + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. */ typedef struct { - uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/ + uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/ uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */ } sd_mbr_command_copy_bl_t; /**@brief Change the address the MBR starts after a reset * - * Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset. + * Once this function has been called, this address is where the MBR will start to forward + * interrupts to after a reset. + * + * To restore default forwarding, this function should be called with @ref address set to 0. If a + * bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will + * be forwarded to the SoftDevice. + * + * The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or + * @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. * - * To restore default forwarding this function should be called with @param address set to 0. - * The MBR will then start forwarding to interrupts to the address in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set. + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. * * On success, this function will not return. It will reset the device. * * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. * @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size. - * @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info) + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. */ typedef struct { @@ -166,6 +196,7 @@ typedef struct } sd_mbr_command_vector_table_base_set_t; /**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR + * * Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not * change where the MBR starts after reset. * @@ -176,9 +207,15 @@ typedef struct uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ } sd_mbr_command_irq_forward_address_set_t; +/**@brief Input structure containing data used when calling ::sd_mbr_command + * + * Depending on what command value that is set, the corresponding params value type must also be + * set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command + * @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params. + */ typedef struct { - uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */ + uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */ union { sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/ @@ -186,7 +223,7 @@ typedef struct sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */ sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/ sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/ - } params; + } params; /**< Command parameters. */ } sd_mbr_command_t; /** @} */ @@ -198,21 +235,24 @@ typedef struct * * Commands used when updating a SoftDevice and bootloader. * - * The SD_MBR_COMMAND_COPY_BL and SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires parameters to be - * retained by the MBR when resetting the IC. This is done in a separate flash page - * provided by the application. The UICR register UICR.NRFFW[1] must be set - * to an address corresponding to a page in the application flash space. This page will be cleared - * by the MBR and used to store the command before reset. When the UICR.NRFFW[1] field is set - * the page it refers to must not be used by the application. If the UICR.NRFFW[1] is set to - * 0xFFFFFFFF (the default) MBR commands which use flash will be unavailable and return - * NRF_ERROR_NO_MEM. + * The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires + * parameters to be retained by the MBR when resetting the IC. This is done in a separate flash + * page. The location of the flash page should be provided by the application in either + * @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR + * will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to + * store the command before reset. When an address is specified, the page it refers to must not be + * used by the application. If no address is provided by the application, i.e. both + * @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use + * flash will be unavailable and return @ref NRF_ERROR_NO_MEM. * * @param[in] param Pointer to a struct describing the command. * - * @note For return values, see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t ::sd_mbr_command_vector_table_base_set_t ::sd_mbr_command_irq_forward_address_set_t + * @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t, + * ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t, + * ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t * - * @retval NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF). - * @retval NRF_ERROR_INVALID_PARAM if an invalid command is given. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided + * @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given. */ SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param)); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_svc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers/nrf_svc.h similarity index 86% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_svc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers/nrf_svc.h index 292c692..231a54f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_svc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/headers/nrf_svc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,6 +45,16 @@ extern "C" { #endif +/** @brief Supervisor call declaration. + * + * A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception. + * The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice. + * + * @param[in] number The SVC number to be used. + * @param[in] return_type The return type of the SVC function. + * @param[in] signature Function signature. The function can have at most four arguments. + */ + #ifdef SVCALL_AS_NORMAL_FUNCTION #define SVCALL(number, return_type, signature) return_type signature #else diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_licence-agreement.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/hex/mbr_nrf52_2.4.1_licence-agreement.txt similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_licence-agreement.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/hex/mbr_nrf52_2.4.1_licence-agreement.txt index 00c2e54..9225328 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/doc/s132_nrf52_5.0.0_licence-agreement.txt +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/mbr/hex/mbr_nrf52_2.4.1_licence-agreement.txt @@ -1,4 +1,4 @@ -Copyright (c) 2007 - 2017, Nordic Semiconductor ASA +Copyright (c) 2007 - 2019, Nordic Semiconductor ASA All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_licence-agreement.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_licence-agreement.txt similarity index 97% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_licence-agreement.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_licence-agreement.txt index 00c2e54..9225328 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/hex/s132_nrf52_5.0.0_licence-agreement.txt +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_licence-agreement.txt @@ -1,4 +1,4 @@ -Copyright (c) 2007 - 2017, Nordic Semiconductor ASA +Copyright (c) 2007 - 2019, Nordic Semiconductor ASA All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_migration-document.pdf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/doc/s112_nrf52_7.0.1_migration-document.pdf new file mode 100644 index 0000000000000000000000000000000000000000..56e873d78fdc30d215a70ebf593b85ca519f4d00 GIT binary patch literal 22006 zcmdSAWpE@-bR{ZmX~ZLDW^OSvGqW^eW~LD{vovC6W@ct)95FM)y!mX$+8cI+H{M2U zg!@lrS7p}CYB=ZS$$Q8YM8xQT^eixBzxQVrU|0zm3GECmVR(2L#4N0xO&l4-tPPw^ zL`;nAj7=D1Ol-}Z%?W{wjEsDIPR@=d1~xG6naOIhu^VhiUFYg>Pe~xKYKtxF3(c~A zs3-ZS*e7{ZFk1Pv^u}}2imsn_AIjXMWSZk#R#4sM65S&s?941bI&;*s5gqUo2?JG6 ze`xI}u8bNFSV}ovL`k-xDNM7lXvQe?oQ3lB_X(@6qy*X!#&L;s zoN^)=NqkTMOPwH+@L6J9jNl#_XLxZN#N1jKHuyvsY$zkew`oq53mk5M7zXNg?FJ+J zNo{HHFj%m9!89Xm4N8a-|y=OU)YaD#P@0@wI3VTL#3PNF$G z^JrsSut3S0DHlk3qWd_@5eJh)lCm{?#_yQ<-5oVm2N3N#MH$#NA*x8932j~m?80_| zAaQA(DsRiCgkmZ<|CC%SgdJggz4=opQdcg5<@%MB2W0##3XksIf-Ee&xe6_36eOu_ zG^t7ts3soFDmh&C96J8q>)4$cdtr(2f#lARB!!qJiU6fN~-_ep78x9SUSYvQ~bUgcdYOn`V0 zV0At$!oFDjKx>hbp6<246`}b>ondC8(!d=BBtfBoO|b2!i;(t5=HDICzXPe(^Qd>M zg#kEqBlTD)`jNvg^~xtb7bS~v3nefy^-#qxm7^iBr6)l25f4zOV8ZC^Z{NF{otO&C1>DhANLQ zCz`XWYwN)jnCFYHz3A*kWL7UiMNC}eL`}{3T6b7gCyR%;v1Sb%Wotx^DDM^tc_&8Q zgLDVqXb2hH`b^xJP-W)5l(_hRZ6h`A$f9?W3xAz2;gUYFn#KHV@8;-liKqGead1^S zSiF35sC#?JtK%u#Kd=DK$*Zq)IgViGA5+20Ag+0&`o8u~;57vP24iAt{BM8xzpZ~T z0{HJ(A#7*sY+~!|MEDPWC^4vb*qbmY7?_zbD496fxi}h`IQ<0_1xGt0WfNyYZHB*? zL&%_F;_ghyAZhcro6x@mb z{tZjW_AggtO^huJgzVh48UMcJU;)x|a1gR`veGkg=<@OXGyQ)i&GGlze-Ci%K;VA> zxFU@$+X4>M?qe$NH7ODXz&*R$FH)NZZrNYtS(+9dLa3QRX#Q|K#O&x zDzPPdOW%>4nVxs$ccv9*V-IvT9hTUpTb=jf&qe3TjF@28bbp`FM_-ow0s85(~p`QX%GMxqP0;7R6+Ym3!Y8 z3j%6~QhyhD#e-1k5Kkf-JY``)>`w*MjN$;H*Zds^grW8dkZ^i~MNxF3&33D)TbYYy z$MsQqeX6j=`?V`A3;sqKCumnX<23qaN_8?(s11BD|5Y75~&ZsMsY#wuT{j#Y<@ zsc1sfK6)z8)u1M9Ar~L4vI=x!S$yJ^gIlnrJao_V6kG|* zu*c(48jEyb=}g+lCG8bLf5>VYclr08$xaJ5De|DURh+k1?Y*Fi|I9sO7763#-O7lL;?H|3= zjfm%OMVOdp(MHxv)stzVzG`h58?~~C-J@}fPXkDhl6Nx-)C|J&RnzD+X0wsh4kRQEz3dObVKA*IAzo-edn1Z|Ry}`X_%eJqnj%hNqng>Ca_$1a zekqI; z1v5EeKJ?oLhJGJ2Yy_{>UAcCJbSLGM0eV6-p|87^N4P(47J>`+z-Jx{`$U`J1YyP& z^7ZhX1CwuahhHWT$`>C_Y$tH-#+C;rguR72yrtdR(y(hF9~^=F`D=gR`BuX6beg$@ z_b3e0f~OgwfSBJ5X5&y+K+s3X0R7r)9h{n1wQpf0L;r~p4$w{T@6hRm#!I>W(R7F|NX>{XG&g&v#RFe&#scD8+*wtBfg zkoYHiXghEJgfZB|tnrD3%ikefzCpp@Q43>Hh*HHWJCI2;)>2Rz)Ke7qQRgDP{HqJu z;X0%&^xLIhuHUc%LjIe1&WcT`HI}sWBC~}1I4-JG0Zm=)H5MFs-79Y4iDf0?+w{mf zw-#OXBY06Lhllv#DK;oxqEw41Pz(Ll6+G*dRc8K%%%qb}RTps||K~8N;UGHgD|GGD zU@lUz*;u}__8n%Rq~U0NIkYlMn2~uAnWwQywyh`x z-w$}G*qN2hPf<)k8u@XUY=;j|KIjazeSsc*ShX7fbf~do+%0IGDG1e^M>?ao$7AKK z_u;$npV#(CP6L|(CYP4S{a1S)DRv-72;LRbx>nD_}m_>QWV zi%-Le%vwewA=sFlv#pTa^mbnaAdkySa)tL^fhWKHWWlB>hkwZalZ7H4&7AxH|j6p%@uz9rfSlu`53lj**Pk!H_e}ova&+G!a z>RE2e(lfYfn4~nD^S(a5-%t<6V?l-WbW8D2UnR0RbtlSd$kTc5k6+Fv;+2JIpxSru zpbc~{G;x5DFL)~&go?&xL*;gdzLAKY6AJQD!q4((6W=Yf(b*Iw%G z8KlzJUKf0Rj412SxF(brx8KL`ZdUy+eQYBxBV^KQY-WWFgqP_YSmRXbVv=UVQR|yP zmm&jev6DVoU)n>2lub4q0fJe{o_hNuAx#N6+v^GQQ>TAi_wF?Q0nz_u+xVY(n)BZ& z?|h-+O>)^-guADr9&IPyQ5f}q%M;-|JMnXFy(@-g4@Ff$%C z+zzvIXk-t`V0^4%z7BKmH}qkp#y}#5eCzrBC?B$Wli_e5FC0bw^A1ZeRvv;Q3ihTX zB=>$2wb&#O#3C>WF7>OQqjmC*BYanjA%RkQ-$ljvHSbS&{?CQ*0-52ilmZ8ig;`h& zr{YO;r6*x3auZm{wZ%8|(>dD_hq0Mv-RmuPBmsiTjr%Q`36}LFEl#_-HS%{>Y`FI*8T#`$ zA=gVh8O$c~k!6-TRyzo%I#hg>tua(=HXq$qF0w!M{WR1d?G2VzwmR40@IXc~w!jr( z1!MK=pMVT%-@D^*DV|f?$@I;D@q8{I3Tz(}tb8gt%#UiGIxx4M@KV*U#Hm7?z3HK52ZOS%o#Ty9kJTc6}y3L`O)e0|J<@dCgTkYm5` zoso_60&7gkI`n1#*1ps2am>Q*wWxn@|1!?EEh@$4vnTX}T#lh7^keWO_{}L%Q>_BT zB5Y2|0f?l7VelYsHzm`Od6d=Za%%6``*v*nTX_VzDFX+>=K`vMqay9&QyzYGL%1i( zI)HJ*0IeQUFt(#Sa7SrJ5OYK_-k8eOSdI1crBg0++nko3r{hp%4=47xX)A?90I2v) zb3$S(^^8H(@7m2G_u8UP4mJyl*)rm2ZGB3E&%yS$7mlYbr2g&>8O=CyKBJ8-mJHvD zX!gmQTEVVBpNq%^$V`cIzD&T zcmuMtG5-gAOV-$M{HwV9Tv6Yp8;gP>b4U5bKH^GYfwK{wT%1)rkS8%JG_DOYAMquY zv##rxkQ*s#^+BAty0Ny^0Q-g6l@W!DJP7JS!Zaq%o;X)B7aK2(XNMa%G)mUf_kK-s z6c=0I`{g2m@aK1qx5(TN9}{C4JTdZy?*qq+Cbme(Vx4jB_`x}ejt_6mDQ%;p;0&T_ z>K>_0P2S9}G0Sq)Snu>MhSGCC-$utGNrgk-s>x1!WX4Of%_QSJpO~DCa=7BjMl%qW|2@GxTX9MZySo=R?=lLGBW z9G3isTtByf*$%1Zq=%@~E#-omN~|&Yx#Kg^B05=W1g!`+g@t18UU`bhT|h}h1+2}H z0No24nkscFX~hJ&o5NR0xULTJi*wz3c3~u9A^iJ9Nz^3PkpxC1;go`C_6m! z5O@N(QgLazAX0M|Z!kN-jJohHUV9B3%z?SS`mPtVjI~weJpPWd?Q#cWiBdAXJ9@re z4XR#Bc?7YiwlGgDV8kiyD3Z>2DnZz_jMOD!xom+7`;%1leE z?}7|n=sW3k$B<0n9=I+(^&X<6_IeZ|6`8|lrnk>-RVF5=(|tElzCrf+^(^!&e}v@y z#$bO@wT?v+Q*0qt2;03`nr4*Cl3qz*u5kgdju*fsG7$;3Xh`MtJR%z~KX!2K_2TmW zez~=>A(-w+lKPwF+yiDjM4c*ut2G6-$oDRXPKA==`4uLBeo)2I9x$;9j|GTow~MI| z@K%^w%<+m8z0Q5Zla2Q<>7qj5p`}vPiy8n@vPg zY?jGgo0P$J28jwYohCaGv*78p0-qMPIOpq69f*gbcbPhOK(kD#k{# zTqCr>jB|GsWyygk%s0lLZUXO&;GI*GBVX&qP(l?l+3)Zs9B8$jA!6r>i?xy3BHu74 z0dh5>y>=iLit4em*Xb5Hz2Q_d^N+-)?h0)If<^Zr(n(E&~k{j)Is+rS9 zY5n2)!SRM*zdP^UF+W+u(t!L%^J*H}2LtU3jqzC(Zs>s_K==koge~pEMvmQ_9ApXo zwGIP$d0TzruDvqLR{RO{sCB9kG}pwew3AEqME8pZt#-@;K6-0Anh^7}%T#9#(bc;z z%QM?8%k0zg1x-1gEhyBE|Zgfh3u}_;w6CQ(m4IVFi!1$A09SR-DMi@GJdzq%2ir1 zjm+emqu98!MKR!xQ(@2(dVOq7iI}%0)W5*`nh}zG4txUpVy>EQ^<*+D9%vWEPI>>m za2V-<*o8m3kZ%~-2!Wi9*`Lvs? zF3YZt5JJ9iD;CoG?eLzM$hwFy7LCuVEaJ_RySZFdJW=_)=9PTfI11kSkq%Uh3EX1H zZ0bc;+aNj5IrNOnL~8eVA6Lewy;$ZEs|Qk!C;2d5c{2btFW*llo(5@?&niIs9+nb! zG_2b8@-N;L&XZIUGAPixEWhc)nu2{wHrWThYkcHzv@O+ilhT}dP@;^N9 zP;7}#1Raq2v%zR)xC3Rwh*MH^S(`dNpVpL2Nmxnk)$XHgBN|6=%t&dyOr?AltixfJ z<0mN34*BsjN^F>j0zdil{n+8>!TG_)U;%zC#G0)4oqXCKtA3ul^Mjo~x1+csA2mKg zOF4YZ$cnM???XX**NbM|(BDXSNHdi&w`(W}sw+J8jE&Q4A}gtnH!7>nVxN8YEU&S{ z!E!vqjZWBpj*n4J%@+7yn@2ckfgWzo5ic2TIw}futtuL4tHBx)V+vnaQz-UZSRW?G z8_mKCzN*OyN13(~1fm zsQwv+?sTDO034Y&8-`M&yl z4GtOtD)NRZAtE(rG-V`(JVCtDg7bc%6M?n%;f~UsiGuA5LJEXqr_VD5Jmr4>IqnUP z6O@J(DOFqhm^n<;Hk~ zJm-W5OZI%x8P$PcIhBacHT?H5pD*J1lCHsQx0Zz&C0r)$^}Aq1ewvf zru`&{a$CIl48tDfc!Fnb)EBT)BvO_#rM<+O?aomUHX{h=WnY{P=(9dzfmS)&I~O$l z#x*8n8aE0S_)AoG)V$A7Egw+a7)40un#=2)xJDKD)$b_?gWiR zno}_f;LL%J-CxlNx=!Wf?C2skX(E|*YqU^gE1YyQ&N6jbifbkoZ7V%vwb+|*ZqP*2 zTt`=xoFB2=82^!K!MjuBB6rqV*6fnPZoF~eboWABQnHlaHJTGiTVk7IA10GREhuao zFNsuhZMBC*zPUs@&KUrK+3Ky>?4fJNPPeuws)}(5t9dx{Y6(rs2;QEG^o3|m@jQGc zkW?GG(L1y)?oRtHOOBCa)=VHQH`Ir%qx+qwqKW#58g2fL3ueWBpy>&{Gwm7 z8UG(g*PlOMO(O0NAJ<+}CnDEs7JQ?fk)DMrX=7d+GkZpMT4W%+rm^p;DKfgRsc_r< z0%2P*PXi+>PV402ba9gCO*S~|@`*gcC$kgF$?x+OjX3sYvzs7m{{$mgquW5mx7|dU z5t6zeS;mm>dd-zmy2E^O5e`3M#_;?3Vp@b-{ek!zn@BP;WNbHDd;clENB1R~6kaFC z5$}iVqcZ$FKa7ct;Dpri>srA+GviaFIV&pddpy6M-9h&sMesHh*|+(}gv` z6jo=n*VxOHeP>`8u!D2&A#gAiqIo#f@UyJCIio;oihIz{C;sxVYlR@`nUHaRx3v?4 zbk-kM{n4e6J>-77tf*z6p5W;ZLHJ={K!)(! zSl_7hv)MIuc>*v}?B^gusv=9UI|BwjMMv|imv3m;dthLmZSHOiT4?LZ<_Q=kHJi2t zJo}OwXx592$V{`9JYF~y(!bji?#wR!0NG9Y;v4nY!FU1rO7Yqy-yYSw`PNX>y(XR8 zB$HDEm7%0ves8w{_IqV2oe6>9RxTC*6Lz!5H(&-vz_c9z;F(m@<^asAoM+PBHEt~@ zBw0w`T;^74Id-of*{J%n_t-3`)=}y!-eD!c#j&hhBOz~6aIETF)lRE>tV=w0uE}#} z;@3wGWr~#_=^k^}ucjmr)#|)6r8TA9+zufn|M8QqEsRZMU}Mc4)%pdO69K56jAk1P zIRgy^`3*<(rIyO@Hu~gL0*srsW1kK7u5LTfEi6T-9G*cA zcrgkZ;0!+Q3#1%ITMwqpy71CHPmr17Y*=-zF~S`SA3?U045f!6#+x^-*|Mo_l@Cyk zQ!J2V)|6lL9H_NH&OGf6fLI6-5R`SO;`4EJU-WSsch4B5Gm5`{JY6067za7Y>$faZ z^~AuzU5T>5Jmc=)VQCvv?v8YEJGRa`>}h-g6=?}6+hEb}_%Nl8-+jsWL`aEGS_1iq z*9tLp5TdR{WBhRY@lfhJkI#~|Sa~vHXaaR0Fv@gtR1fpr*O$k4*jjMfcY6RYT(1OM zETdchMWXc|N`r zV~HaZlYF&%DhMiZl_MLIAi5@GOy+dm-U|A~@3{waGl)NG#y110K*D#3wXEB7qR)gp zbZl|=ffq$*6~R6ZL1OI2k%|3D?v7ZFxK-hvbiBbGOV#7n@GiKM*L<)Eg8ApvtfqUF zep0a!leBsIGzVRzWSNB^AKvkFQ`)IT#HRHUEu!@_Rfp5SBiX$t=cO^C3ms}z)5KTV zuiMo4B~=Gfjc)yv*ybB8u1v|Ci&p$Ktntf+EJ%chP?vWf<^}8!{Dcq>q$$Q#yWqY! zvy_=%R!#J6I;kxp{bA|kO3H++{7y#(RNm&RW3;HaAJ4lVcx$QAe8(!Fjb?6!mO4Dj zJg9-rv!$%WMLMoCKH@yGAjUH;=?{`MC^-z-mmeCD%y=obMUPu1*g=nzCR)ey-ZU!@ z>rofwBg?kELuQp*T7s@4&-R>6op~sod*RF0bW$uwENVcZHlmhTyUFYl>+XG zV{M{GkxHR=(1uS`iO;bpi$`mulqv6$F-IEWTZLT&81x2GeIK&xpiz5o)5mAr*fzbA zCgfRSzSRhX`y0KAL*gv%KxaIxteQ7D*nBljaLgqao1O#&C-t}@S%NAo)SH6GS!mva zzok#CT3G@BuR-LzRXoE}pur=+DsNn{t)P(}Q`OUj$=Ud#dim)=%-bzJp z336(RE6xjngtAesU&fnZ03lDq6^lC4M7cw!=eH6II4HC09|IHWZ)*28HtYGuRaFth z<3^A@0$5NBEVO2Q`J*&ws;OS=2JI?Ge2Y1qpQx85o!-FdRFP#D0r|zteZL4#2|ExQ zqH+$(MHeNta%kJgLZwtMe%-6A%pQ1znQ3_n{y(11o_9~5-1m2)uklV|p7}qv z-w#PXrF2${?p1p7pJ|5Qh9qe(OWu;ZcF;JpZJwHV#~jdpoJ-~)Xlt^w_wlR$NR`Yp z3^O%wt&-yPUPRAmFJ5cBCq@7&K=0$Isz{c>7+O|LuPBU0kM-iE4(Hf^#;`q~d+abt zHHHEg)XQM12Soj@z#)(UMg0gD3+7i~ehbsi&KV80K{Q46??O}eIB3jxv&EobLCT2h14p-T{5*bcfb1Y9#|5R-86;{Fn^rMOT{`>)cOGVI>M=`;KKHM_(%|51z z1ZQ|}B`{O#Y~w{oI3(ynkE~kU*Mwrfy%B}OQtS$g1fuBbMcPiuJ42D6;wfvoUipoA z^@8p!vQtl1syvUBZADs#Y^v6FaNGcPNg1~?Dz+#cx)S9|J{%crr-{tp_}yymi1${B zg4~uy%U0lS?&7-Rwi?G6Rtjhyol%Uw8Zp9|ld9Q9-1vvV0g=HG2^Pq~ixKul%!%;6 zD04cGJ>k2Bvzd728Vs%mWUA6k4Vt_$1LkZ|$+Z-9Lj5u*)Nfmi1RP8ID!{aZS$0k_ z?n<~{`He^Fs$ubVe6y=-tlPL7#biq0@Q1WNibcc^q|#mQ>4G5dFr0k;lxm8FX4#xR zi6b=FtvcP}B3rpzF_Tab)}hcuk#y-IWaOTerP?tB4bM1yM}bsB2pArZVHQhUWaX-k z2mK~fvwxoctolXSDg=Ebxz)dSJ<`_^*s!}hmD4wLOZsxTdjRj_;>bnhKvOH*Fz>Lc zRqU2CjT>6C0{7#g|EOk)g_YxflP+{@oHkm&|7BGFST|-WX%KHv-i7HG>*wjL$SmokW{a8vMbh!* zEYdd-YPm02A4|7egh*t{qA}6}wAM(dRg4R;+%L>eM*Jeun!BKHOxdxv!v#OYe52+` z4^8B<#iKs()_rm2k~;A}k9(+ofrtCHAdbEr_b4inQ<3cth5dg1RzS-DP1Z@6Npa)Q ziT~4W#rk*x%R{{;wZW8mXR6)w{qu$W;<7Z3$w*SmBVb#Gz>+DfK_W5ABlD24ns#q< zpLohp!_6e6u-~Y#%ya@`jB032H+DRNqJN%77|NZ@{nsJ}rgBckRLmdHcri%Slc7ggeTiEzA; zt$}Gh#55in?6dXr;u0cj%IL6tu&yd6C&V`4lD#r5(DzUWJHA2(g3Mq=jSjg@Q)2fZv`CDZ*R(4pg0p$U^HsaI zxhm{HW4P}jr3*5Ljwwfy!*pj!WJMW-qM8>Gi%4iWM1=~l{K1RH)Y#`Z5W{jzY`v5TS+gfUJMMeJf$2zyRVFY3d3>-(0!sLTk## zD(v{*a5o`FNFH(Mj1uX(TD=g@^I)=Vz!SA-B`0iZ#Cfp7zb8fZiXhV+jTo!Y^Q2)b zb$sE-4(h)!bA2c`F{QA;WquSPAOXT{mnd0F@(Oj>Ly!}+*h7@m7}Tl@H!)=@#0ojU zJAHbMMPr60)=8ABNyur8DHTBFP{<7}m4Zd54xx#xM~xwk8>29*kx{;p)TwBOoXR#? z;3m-YV!AV;TKhva@I3RR9sWA*OJ~Bblsqg-pFs+~?xSVMf+E@D(NJCvw5b3nd*WLc zz1`$3QhUEB*nEQ`pgh~98Shsw3@LqqQ>0{PHV)@AZw+#mCs8s#X2m;GgBN28Q4oGn zXf)>YrqqUkA~-7??^90-u91LOyv52_S+wpbD~F0$EnF4bnm9K#fX|3n{0 z-Fv5-ExXq)O>Di_7Uk?&s#<4eEhz}PZc(64p0+E?F|rzet@_trF*_!Bu;$$g2ux9e zHh7$)m0$72-w#E|f&-o`fYmPmtdo^c_LEgW(H5>)m886rwRik+GAsqnb83CAA2pE! zkejA^$7(VukvOixl0!s&n4XTRaQ16F1t#5Id(Cn@J>EuDAJqtY2{8*5d2YVw9(8^* z;%qh?qEeE2)}lX1PPY7}wCyiMrO!$dT?QYH+6(qJf!#KI%WM}7jH3nZwI3(KC<z2NSMtkXt?jD6<7hlxMn^dZ+21Rn~L# zEjGyPL(EW5k!QYH+fz&RDdL_rB$)UGNDCG!;@)UtqNwG-D{ST0DyU~*Ylf*@Z5nFG zJ9aopQ;rdi_WGiwP_>$PEm@;agl@UEc@QqVmUwQ^X@7jMY{{*-sM~4Rn>QP`f79A% zzh@5vg}uso*@8~!qvTA@>a6Ivl7Na`Nb#;bhu37!Ipfr{&S2%F$EVTRY;x3%s}8?0 z-nHTJOMZb{!w267Le@^`~o!sq7B1NL`TQ@NA{UN%4n_%UFpar zoRhZnf=rBj{$>IcR>Et7^_iL3VGZ%JB#p^j3IU=4*DSbHpI}^K6dVQ{G^E_-LbHd^ zPQ^ywkqD5}0a-5#!tYRKJ=g@X(V|a=*da(bS-6ej=v?5X6>8%1tBStl-a{o3HILag zs}E5}3F};UBVP6%ju?m;P~1FqwRd|S&w17d-9$kx>BbTsL=tuT>u0+!Uu@)VtwvHC z+FaHFzB>nTtXcmq=Ope;AqfL5GuApqb&~rg*mNC1J>tm}--nRXkD{ZaN5eKv*9p^w zgdaVT8b8waEG;0v-gtw8fO4+@sKXw zz!uuc-?p`)g4a3WDCJSLY;JuD*6ZZad?H;HKVcdkqmO{(%#D?lhwT09-JYnA>HOdL5gr-c0E1vI)hK;Tlr5af9JLM+ z+pT6Ywg_i|&@k}e)7j^Yixhy`BHf4p7@~_#j4;pGV;WZM>|emUh9$WctfYPnbMDcD zIE)4$PLawly*}=}f>^!uK#sz(yKr849SdsVgvZA0sqk`7>+zn~!K*Z(G?$!>wyN4Y zf0zNp?ePEB{d>F1E64ktym1=K&Ao=U(+>qcGksq|N-Y+$ZS#POERldf{aP?npURGk zjP&2ry9$P?)En#cA9uqCT6dnOK)%RV(A+4&!JApN1vq-$Emo$?1$~#F>bAK$z)QJ5 zLXc;~)cc8~0U>r=O|dqN!_4P9Z~Iz!jk@cWJO6bCpwHl{Jl_o|lw&cac?7s)Q=(CaP?g@M1(yX< zshoE*03YeXYvZOdL&vTloZuqus({e)U3oy-1F0Kwn-8njh5CASHFRdBGx2){i&1_I zc;tg@S9)d1<@Jd8NIgp#*q~+N$Xh}6bLfT4KD+^bgr(>6tsyMbh||HxEXy?hVe17C zLc=jna%z&7@zW?b{>$w)J49{cy!uwhTY!$MG34@6ys2`=h>JHeRMX(tW!k`sq2#=L}whySF`#s+YLC3ZYQNL>i z!!8n@g`2$mR5MN^#puG~rpxt?gTsc!9ATy-56m;^@HCHt2L-TqJ&1u6&a@Zy@?rO$ zcMq7%nmU36oGU=-S0*Y*Nqp*el9PsufMdV+s?Ca^nSj7|@=EBxY>3Q*fpS50Z=)G{ z+`XYU_np41dxU6qM^E2BG?SMATj-sTY|s#RlM5}TCA$iJirUo=fOLuZ^HHXXM{8UO z$Mpd#$=|T}fyLqPUR5zEpFS|~HlU4Yb~01@Dsf^zt`|C;EUdQ+9mHF}5CG2ft zdTHmIle>nm0#fR~ck4Oh`MiwXZT;H3H#?g-M|!0A+ii}Mr}3g(1*u8A%jmNCOU16F z;wG*snl${*rzjakTH31?RVtdZfyUUqk`hr;t(I~$7`7gqQpn_p9_K+(qRLh!F7%LM zcjIE2;GC{l`b+U!luKVor!i=N&BSpp*Vnw{^s&4Os$WO*p*-nX;M28j{SnpJ)c{>y4Lp`;JW)-Mda3 zo@)CAQg}=yk4i7#ATSr4X<$4CfrSRz{8hyb?a}Tw+2av&`|K$&<(aFe5EgOG2;EwW zDn;$>mPP4V4e#tmO*8LLN2wC=!Rd#a5C;10PJdjz?Q>d2{F&NtPRB6Y&HQnAqb8IW z3g$XyERwl!DO3jP0vP4T{r2PJTOP}^T@I$?3D!yY=Ao#ECb)P9IN2VrEOgamv+;Wd z`%60Ke1yb{B<}QYn#20HL#DYH4u`WT0D;+M00;j5B~zbWW*4nW%!Dt)S zM)T;gXrpcR%9GzQ;y%d?0}$vp5o3q%w?99ug>QsE9v%_xh}nr8Q_42>)p~aXs2-22 zxAj|hlqV`A5;w1&@16dwtpfALsZw0pH3tpSbX{X0*^q?Ii-+ z(UsEnZn{H%zF^C@3v-RMN4IO_Yx>ZOFoq~)_b~X) z1#Cip(d9n2uBLdbBjeWC`~KQUjg z9zEOQ-OoTb$9tI`VN1xK2xIhCB0ap!4L*RsovSe|)%i?9wJ!b{N6aLDm! zvg*R?>H*&u?q+5MqzjP3X;&8@G|3DZC5XR-i% z%@R&cbZhz3jnzJq$0o@OvOP}0o<*3Oi5-gdmA*>k$HBdlx-T6*pOL5WJAxl0Ni|!c zfawFY`G?paaQqZI(Emd4`mY=Z!2dax1E&8Y%K?xb_#a)+Q<~b!8yu)U&o#3~r?ur| z6D?Oae;sBMa^Fy8+&YT(9gKoo&sWPXd+TNXNc*1Qk3DZHz)aG{g~t>*O}p97$G;YL z-Lc^Pstzv;>{P(OE@v1*#Yw4uSq+jjser`jHP`Bcpu!5;lwq|0T>lfuy(h$gD zubZfP|7-Bs%_L**Wc5=Zypt3?Sz#^b2ob;+=`%~_l-tntb$9oe#x zST#mm^pRxrqBU5n4Es5E42dBqi7S~#Le-B#P-){PcM}4Sv{K3BEMD$+%{KBdU5Z9A z-ob?_1HcO&%CC0ap+;gl>wzmd#yZkG9B3J!glrV+#8Bn023%`yR&`m4@Y-5pyh;7) z-;O{Fh=^N_3YW28FhRzrpt#Z)DY0o*MlD0M5=us<)xnz4ZN!$7XqvyvTebRafXoATWiu%t=n_vs{{RVP%C7Y+g%_WSpA zi~#*M5D^Z6ZJA{P5-Iq-_@)v99f50r3hYUNS%8z|-!b+5s*X!RNvrzJy4Fo;f@*=9 zQQDJ^{~ADgQocEuN2+Pe6eg;-dV@vT&=(lapM7?(jP+l?F8+)rCk zVeom#%jH%z1G)dCb7I`EVD#Efp%lf zx-h(Wp_I57lHR*=9LoJ=Hls6nyrTtx0fOT@aL>&B(WZD@WMfLS!gjU&&2z8IJ6 z1Ax}zv>>66a*_*_81hrh|QT zVL2)tufm1A2|eP8JW|ev1a4C;q`{gzGl!Eu3A8|A*txNi-2n!4$f<3L24{KwiHkXW zxHez5^Dk(x&`tOdkoos_cA4cH46Q7xsSqZH(a*>AsA9aVP-B$Hd7y`sJPct3Kl+J! zv2u!5cq*ewcoom9tcN;1*&lWgAk zY4GzUQ>OI?78T-ug?veH?Fce zO%D*9tgV|WT#V#tEx$jMl$#vq%Xj;M0|F<`1e6dQp}VB%jR0ziNbbErjt6A8Ucc3+ z$+(O0x$t`PJ$wxKv)|0beqqD>@%d^ZsD!76FU90YV=twRWXj?9*Msszt*CHwi4=Q` z%LR81wSq~tkNe=%I8Xm{tTzeIQ!0P7yvc>EV4LN6OD##9Fgt(Hxw@J;yB5R)@ydH%AV-Dj`&VKdoS^eA-ez+H|4i#4m8zF1Z8Xj z4XG^kP`+e(9tWjcdu&e&T6nm)i`Q;UsmC_z}z1&5VfUJiqbN5NkdHnh!l%6|98M0{ltr-ven2zGjE^v;B2Rq9>K*b5X z4t{PwRcpBktdz_+eWt;go(&iu1&Ul0ZK6>pXGJ{AC>{?Au&f^udXtv%51O zHZ*i+sXjr&b3usukn|ck_8+ZWJf`CuS##mp?HaxtE~}rptLF{BXLQ-1q3d zL2iB*mi#(d_luc;k8ApL?$38VWO1ouT#!jY+zGE$o=8(c*GTFooyRD`q%i4vu5Qhn z*h%)*&I4WV_I!S4C~fZ23=tq{IKTY9xpxN|CzFx{wo{JzwqGy3>yv8|Cx=3mGOVG32JO8 zZAkoMqj^|BFRTv~E3j&Q^7k`n7(xbwm;umM!bRyuAYmpUhoQT(s-v0hX$?`hj2&O0}=e7?_J zLEc(NruhS$(Wf}0?wn-}wbRWQrzidv!|KJ&3iG57# zH8;n0v!y@n+B`4zzif;etLiKp?Ric7h4L8;j`JsMFv#2fc3yl_a*Goxi_DdJP5EYd zVOFGOB=ycPa~2ewseZ9{iSXEdK(1%>s(I_n@xUvvo(ztJBg`6>H$HbEU3&kw=BfeQ zh4)0iP{VgH#bv&YQyxBoWWQb~JS^$Lm9&}EnIlWYJL{>(l(l9St1=!Z3+%4<$HwA6 zqb{{JKbPMwvCa!bFkYHBju%#2-mQ$r+Dllo7{dz2NM$F6_X<_|;nwKht1WI-YJWAC zH;UmJ*O$dTpcmz+T$U)DJt-wEx%vJ6+J}%bu`rauna!#Kg6K z!LuGN;rNSfI1IvAcj?So(dDyntxt7@gg#)~rz#wjf$u(IEKFV=Y^C-bk76EgCV zKoi&0xU(}zSvjSRF5sGCe!&BMR9?)wwcerd=jPge-WksGMEI5oaJl~fsyXv`sQNvQ zOSY6Hl&u)yTB14U%q~l|5Fth(OJmG1nnq@c7Nk<-F_xM(lqePPC_-6M)*HIX@`x1E zrj)0h!qYu7S{U7XyMI3CpL5RV_4|F#@B90H&oXDe=Pl`SdFWlbZS}zG&%xrV9F^F3 z)t!%u{gNcM?e)^v5s&xd`;REvtcY~*P{QQNwK}jT(6`%yDm>-({400aZ|TFud`?2h zu#eew-}ZBeRue+tkpG=6X##x zdi0;D{nXH)*<-acx1%w6-OIRZIEF{SDk94z0#U{&PB0#8-7Wf&u?RSk0YVvEVmy~zcq%r2x21i=xS=$yiCb>7hj6)~%9d9W)@$y00 z>9H$%>yK`TNJeiQu^QRn?mkb-+e#%hv_%Gr=@=dpJG^&g*|Qh!5_vg_W6SN#RZ1qZ z+eec-N106%ysJkm>s)zZxgC@Jju!WGj%&Hn$xY)SgOBUbDr$o_w8zgi9jYq~s}s*e z&h05{`NSzStM)lhntaivn@{!R8xQ22R$^W+db?}$!VJqRo%q-uvEeso8{JM9anTpw z?_VZ8Y#*??>vgE-z+mbhx=9Zlx|3>R$8^k3Wma39Vr*ar#vJZm^&vgU!oBUb!{Yld z7UK%H`!zGKO=3SO$Jiq#9;$ztQ~ojh?N9D= zKl_YCc=Pz1+~9h*2D#UiZgGZaof7Fn^(}N%96^`z&n&Z<^y0;jD!=nNcsKlfYbvP8cc6p zZOh(gZV6GZ=S6=Rv}V|jwzH(8aXN}YDXSpc`skEs{yQ<5J7R_nACH-|-`jGQ#k&!5 zmFVO3w4jyv*?c=QOxnptgQTR8Fw)?6)5%e5ldH5NKTBf1TAr;Mv83a@&Hn14@Es=N zt_dZPi8qh&&!;4<;F=t{mzvC-+&KUJBA%fho?n|IHr~1Jl?|6Bfknj0smTY)ShzT; z1{)@T!>1${%IC^=Nt)(HN2vCS+YY(w$nQOQNe=3~u;tXNx1sBDm!LAn=))RUiW(yR z)WAanClAh`D`AJ;T2z@Q7R6_wJm(;Ck+agDX2~y|EyLKtqMTeIKIJarM0CyX9MaJPXF7K1Nxdxrf|W zufuIlmHjR1h}x*XOef{VS=?nfZckcAhQ#mhUWdF^RtQHWl9E^uqr z%at7uL@iL>oE^0&U$HyA`&QoCGk@MGFkFB6YH@N}F-s04nNn2OfhgWZ06*oVtSh(T} zF|0lFuH53m-3s0Vg;aVc{aqed*lQKJXJ@Pb+qrK%HQR?LBURN-_oPS@s`@2He}6P* zQi`LaU;dLb|7Ug0(BG%78Jbo_W=CPMHwvEEJ&@i$zVI3Yf-vR^0r(?{G&Y@L$O1tq zkin#4AjB402$RI7g)J@goyMTBkhb9* z7_$Y!Oh6`!jSvpS1L;EgzCF#xk6JfRP7qrF0uz`5r)tLqR4=3riA51^I8x}_C~O*; zWa<_~r$ulmNP7m%8Kf~nkQ-J|u1n*uw5JD^hyb?0g5TFpth5!ZQfW@gM!k>H| z2xzJaBy0lb&o^}2_n-qvC!#me5LyAQz#07rgdp9%RW%AwZ)*jBNG}%Ud(H?g*^<~K zdUy!(n~IpqIXDADD6A=N+ccBY-W$W_>|pSup`957fCK;!5kNFZfY8eU$N&HgjF7f4 zeNvFt|GgE=oD1fVDNI9}5H}}u0ui(w0TNN(#A)6{F)3780D%HzVYcPh1%bt2P#6Ri z@l^u>JUmx|1;O~LK>!8|zbqEfuoyTrA{q`2J2yjvcLZ^np+Nva5DyUzkAed?Ljynv z3n%ML4F#Y@`vNEkHA_Q7Fc?pyFB**(^#j171mD-rJO&m6%sMU}CrG84?eGLa>dnwV z0EY3+(r|cD-#`o+EqV+PgGGtXDTqVQnm?G60nD;T0B6MwB%pAjV}SrT(?rGx0ce8g z96$hyAnF?g!VN|Hf*@*IUpA9Oqf?jyvZ@n<8jgU3XCczb4zbZ3kH=ET00{-+$PkE! zNGJ@5B?MDR7yyf*LU_p197PER&=49&LPI1n2x3WS9FPGv;y!o-dsPj_Lo(00xkEGd99C1@B1{Tc zhQi8%*oN?$vobmQdn9*5<2ND)OFaX6b(K?kI@7Pl7lVu6Kg<}QN$F|2W|eMNyqm#L zN9DZJT6Tqwr|8sp1t3S0eTUc-CgiVUdjtc%(1lu2kg3@Htc|%n03_2&W8pO} zJ4r^cS=qaQ3MMg8Kv`#B6n#YC2Zg&#HLvvu)Yt6 zL&uFBqMhX^nvR#*=?*@LX)*W0PYYVslbxR*e*~7T zcOVkKs&5hrehJ!qCZ6SJHio5P8VdcM>zGtG?*BNO4{Gn*k;?6IJF^eE;KE}o1Gk^6 zG?VOd*}0CnD%Z*(8V=^ENshKyv*NAPri#+ANt}L>QO)Xc%T=kxT*}5e#yA3wh4=K+ z#8{>o7g%#;s3QGMLJ~^v_a4hfeg*8~++313u%wy;77BpXnbJCVb|< z72ZF;KYcj<=@y^$-|onm7+V+!+PQ1d|M|<#%s|V|j?couLd(dm!^``3_Xnn8tGg!ak8! zzM+K2ctO8EnT(NP~E0L;aHL#!DxpzXw)NI-+s9i;F zEU9c#yDrbUj<)*l+w!R-kRZTA%gy&riVedhNDJi%=NLPuDGwa3B^qA;s=ICo3T-DN zhoVY3l7{kM*#^--c-Y!!*~d0U@*6*z?{0?rLShymb*I(H65~!On-J_L2{Z#-nGwnX zPK+B3;72I}mD|$Hc%W_-e5`uv_d*@vHY5fmFc$xj z_5W&r2BTS62y2iIRY23XJp=c8C7y{gDG@0RfjL9iM9o0RMg-$Qi9tArjKUA*NWIjl zt_&JXs&8OmVZ{MdhP2ZtK5Akxi)oai5sj+izdc*6NvmluxYX*VeAc(cPVTO)?j;6_ zy{tLPo!AV^2-Zvp(!|N=s(jW)oR7{&V3p5w;0A8XK^BX@1t3gtR=!?7mE~FrK$slQA5PSGH1)FS>p_>TxlQti3Q7DhI`u zE)d%rm_~$1jGxNoF+V;$>I`^n6o%2fNUky^3N=eH8{{WYZR~vxKT0uN5Pkunsehz9 zu#Gwv1yI?X$WOv~0pg^BK=FJq+Jozi;{4*DA-raQ6e-aXl=$zCl8PYl+XLK4CV?%Ir6$4567%}|upQ)pf+Ab%|2Pjo2y_L&e#PbFvOe(}*RFzaKR$zyO`lsZh z7Mf|XK}gbuadF3L7|oAmtI{APWiDh1M@qXhz)?eh!cq$Y;b5v$+us}J!9o$S1Q=qg z2PJWr`iqPuO|Dri^?^p|G;%jB1syIO#DS!%sezpMS5k!ynG*zNjl(v%vN(biQMiKm zBP^rD8>cPGnwTQ)*qE!)V9>A^UufZwE}1iXf?>r?Gp(gd+vbcPfMFD3LOxhK$G6uT z#W&X*#Me(Vt#8zz(++rU-7`u*q2L1@c0vP0eMtZk2>?le&Ge7=q7io3breV4?AP=K z`+EDq&e`-h&mcky1;=;mEb|2RCfIbM)=Ic+*2z|@tW&X8P5AdeS&(0rm}PdP@8s`X zjO;_SdA(JttaDf7z|xp2xu@ zA*SJ}XgA?pZbl1&!n-IPczAU=d0V6owr{K^8=5rgPfrI&tsSpJT4g>lap~MH&9w|h zWH)CU>a|o!~%)>OF+l|dUsVg5FKgR8|=RDJYu4RnQzVxXtY&sl#lfI zbci>!V^up7c)Ina^^d=roO%`9&34RDyrMv}gtaY^86`J<>nKl($xs9IF$dVUjSF(% z740}R;YSD9ZbXw}l{S+_KuMSkw~b1R-e}6JQrdNODec=4npHj4#hcEt=wA=LcC|Si z0fDeyEhhm(=`kxt6F(BbShcx)syZ!D*XMX5?`~N?l9pG<^X)08aL7`~aSsU?s8iXN zuk_j3A|wH=o$jXV?63x7?liN@M&?}oC7-iKhR{LAKx%|52L8%5WpDb50H`)fU%;FE znaAl0MKNvLHzu!e6T_RmvxU=19iV___)ej1zl(3?%}D! zJA(>wgF5A5xZ_Ig)(jCwjM%)I_`%T)*(cP49cF!yDJi`3P_6$%ls6`eeg=x*-P035 z#Cna?!r8mTvdj1te0aKdcEkj1VN0F+s{sKE@Ga=E{evQTIZTj#X8NE981 zP;Tln0FC9vYVd}jo*!!IFo96Y(_syhPPJxpH;^1WQ;4`hL%_lzmSGv&;zm|id;)#n zXpekvTWC?68Z7H%XJO|dFg7XlM+$iH?8H;X6Rqg`qd-lY7j2U1?1SB8ZLc^34i#Nrunrdb||N z^^L=@PmT5nB&(tv$8!^gnM4+5F*io-wLtlP(JvW#T!?4?prL@Y*cRt>opY0#3PoKw69Dxw86=3MzIVGPSdO&K- zr{GcHm?I{6<)$Ndscd5I7_o6Bjbd|XCZ9+UIeQlue!z#dB8Dq%P7g&t%7&Gm>jMd4 zf@1h6HX-dzspNLoyuH`htt?OliWGUPR-UPz?|+^m+l4_*~`Yd0MM(JHt5 zP^)tULTjwwWO(}Y?_e0<(4ushmex2ZRc@bxfw`B;ZqHgzw!f8EEl-!HXV?u-n(Wa+ zDwD;~u+)K>)>?v4bT|+hKnTn0qlVjJWw3{M`eQ>IM69d^Xi%7fW++u%}?&_c( z&?V#segh-3jW_>Cn8@+(i0gmD#J?!)e+DMfi8AA}{q61lBVJ_q3nu?dz{teF^sj)i zSo0r%aaC>4Cb1$&=ttK~=AqOC*F8x?LV5LcN(3oEI8ubN_=N84>Z?*~rvrfnSBavQ z62;{oyx1>L*eNg_yB<0`Wg>vct~-VL`^uT&o%@}^2}eyBurt@=DwqCiHLCN<@cH(; zjT$`co5hOx^E#?=%z;Cz$`rfTjr#_a;7~e98Umb`wxy9R)g=)PqceV!u(I-Ju8Yfq z>pj}cb4B9V3pN`Ddxz|50**08N6alO^{|0z57AIx#B$|eN#xJbXz&p3c~hS$pc#ej zYih|LBrR=B?7(XHIXv$sIU7^onF@`eY<7KrtbG_QXd$wI_4Yv_pc?)7O9)$jR%oQr zRwIKe;re<;Kkk7*%#j#)qYX-jHkYv6#`N?^QD#U+41_5^7W1P8Hy=bUAa*Tu4xhds z{$zZBjQIIdjpj+yh=h3tf=f-=fM-ZKix6jhajcSAYqvaz6Q-`bJQeM6`(b4VH7SRY zeURRjt#m)hB%5|1qBt)a6|@LQ%2*lvwlM0w5jcGYq7;tq*4~Kpk64W|Ks2HuVxFD_ z#fE_UyZa!6P_`aIe~}x5s>xSYT*2U%syfg)a?g^(;qP}#33eZtDkl;QGAuKA!$lqg zzi~Tv%`KerQ?@u!7@t#>QBZOLkChk0(?h~~<8m3ybrLTvvK6LiBR2eff*tVAjH@q& z3!8iXvMBDjChr7X^cl&serUf=B!mrHF#hod;;C!8%+%l2C}NNw&EbkT9M(B#Yt^6D zkkg%#k%d0LCO^W=W;u|!zW&c8w?AKxp`l3(RJtmYVLGr%6kE(PlH8#{z!5g>ma zgE_HcUqnqFs;UNtA6)gxj}BdZX7ISz6#~G@cHBkgG0QP~>UOElEh)J9BNA0dh(ldm zAXR%oO(hd!0FNfm&ZgNBa)*I7H}SI7%_vP%iGdOBP*1NPvK5F{5Xn;J{XAhuV`qi_ z2--r$6)k@@0_HFegzk;SFv3uYpt(LWn^8n)1EvGE#Ek%cdtlO;0J%dZB2Spku4K`l zu?rPfwJh>;uv8F5$w)rp#{g#{vNTj|DoD}7t*2e2`Ha;YK0W4hKzmE^iDwn%N)bru z3CJj{WAMw;e9k!q*`0*~ZQ>j%=I8WaEE|v6OS?$pb;#R^?}nOrzV%!R^LPhSdxNrw zn3w@@G(UR#_ghxw(OsQW{awTi7>t2UI()?-vQ2%IKl26Q)Q+Vl?U#gun1+(AaABJgM5jm6j4ryq_TyH zpRFEjB*scp6a?W`2eBbxQ$Z#KW>gu)yCX>eY_!Ra*2EoWFfyvI^q$sLskQ^jL(SOH zJ=x24Sf@+kwTvet8|6EhLyAhZ=~}npJ=&W1lJ%~3O>)H)EB#i=-B5*%+N6@vhV80{ zf^&Qi8r02QCs}4gvc)da@{^r-kB?{%*et9BFqBm4O5AjW{92UPEQ`W=TTbGH;aKfZ%|}_X6tmYGV_fY7=0nfTHM+dOFMmHZqw_ zXRe;LZ)2~$fUL6cg_I<B42zu5nLCX6UTw)c>(C1}TCb23cPfsDs=Pq>X&~5*Sl0h>oPwMS!Nggg>4wTYGE)AFJc&0sx z$IbQSpZC13xf5@RE&(e&il_Mj8XE_8Y4ugN>riews_Vd$6P)ie8=kuWg9RdnRf#mT zz%5N>oEpb(#@7bjFCwKYPy34$R-Mf6J`nI@U)l&97pvuN`dg zzu=eR{RhR?qFL^^`_$dBI}7t2h*m+Xn){Q0#0>OQ;xOknYbY$&?!Z+ixHMXtDn!yE$^?Zd3YT3UYdrGaunlIqOHA8I)>i`p*vM4ITQZ<=^g} zaL}nOQ&{wz#qg}*D$ zM*@FyBQ3*f2MVMF?%wpIVzY;`#mm#|leGnBh0}_Xv(c40<|h3-*A#?uxSyRrH-jC~A zO|90(me;)<4->Ph$pS>GnA=0*v#;Do0_<4>n3$PJBHhj1)6vG>!R_C>`mO2n%1o0B z4o;#<3*(J%@AwRASTSR~Sz%Nwx_3lm5~dvWWY}$|{HylXxKJ`uvydhS+qNT7BZoH9 z-(&HUie)bFp|p)onN`n+yF)j}M~B)@Ha7J%)l6;j_xUMZDH}9tJu zj$9}z=yP{~`UoAgq9u|X z;`c71*(#k<1i(g20lSsS4BF`taAkm6?rR2gATbV%DmMAm!<)vl2aY~1+}X3WC-#)6 zr4N&Za!AqKZn>r|_MD&ScB<1(od=zmMZPu6{r*K-~=;83#3A60bODGF9Ujx$Qn<;18Lt)f= zez#g%y7GP>;uK3hLdgv4Ky9UX__2U!C3z9OB{+`>Wh9Q%pp3@EP3y9}w3%CJRmcca za?AO6GdaBbEdA~AL4~n-{7MxH*Io_{A?!mQ!pb>Duintn&rXH6Ri{!&TJ6~iaoV&+$F z=>WXpTY9OR`)hgH+Cv=Iy&O(vTe@r?_pduL70*DozU}Z(pk0|WHT&5ezhjTcTCaQC z*kteuGCL0%#u483)u z;u1FvrRl^-L|AtoyPU@+(5rmg{2d&8Q+)a@Xs;_f7Lr*T7q>3CNNG_p_qIJ!95+=lh5!QwYxVQQQ?eGHo0wG z_`55-M|ih@Shk_!N2~(n7wDz0C?i5{;rACE0+!$FtbOc~9-pMba5ysCruf0`p>l}` zMbVgKya@yM4t7D~?z_Pv>jAuzd1lXMRz^AAjNR8zZMS97#3K8=e}3iLP8b`*B=O9m zUwUtJ@~8%Cop7)B=4l1DtTKO6hIu<;aMIbfkn%aTD()=?)!qrf!*HRm71}4+MS|Mh@cUWws)nox18xqqsRRncGrDkfS( zam=Ddv$BI~ou$Tb@plNYZgXJKR6Tm003B!WjeMOsfXWOQ&Rv1U^tgSM{Jx-50Yh6T zfZ%>&w(#&5((}4hOPDdo1dKDUR0`xs$_vHe)@nGgE@O4P23q-C(=M_mTqg07@S{Mlt<1&gx> zluO2JH*s){ygi*nz8?8A0-!5re?pNKDzH_2caET%czY`Toc0OG+GUq0C$&|+!~PR8 zl*)PErC;Kf7fuHVF|F4&!L1AU_+<5 zarI+7v<_t;I)xMJGwTdYnvY=tu0FAzeNZpXy7utzH;6=iwJ!a~O6FTbJ{6x5ilo`c zOOg*oMJ54ElAaYISb=%cDng>DI>bwsb!Yv(dh(C{(G zI-Km7d|HWF6p996>A(*2jRKKB3tm+e1GO{NUsabC5Ae>nbD~U%CQx(x5fyJy?XQ>fq?z7BLA<2FYGeHC9(!(h#vZDfD zladG6$4TXA{21kx|qjd}Gx)6t%%X4GL zzg{G%cf#Y^%3t5_x^Oucq*f033K5il*eckTKNAjg`4#1DET^^ivpkSv9>b7Ms6Lsy zu8*cawcX1UZ874#$t0)%^=nvyQ~W~GNUab@?M@TnmBPfM6`OVBBbD~}f$&z2 zH~nZo^OG@a>*;>~%F?0*z59Kp>oqy<6n%>~ zS;m)r6?h|p5)l| zuC_I6AcmNO&4`b0#$EJg<7DLJrjvpjmV-&ia~sp^$+CWnDL+E0_iFk`kCzJkQ@=Dm zlDV2%s#>4cu6M>Eb4;h5t9~A!50|VB)5zskQ6G7S*QfD_TP+j4lF-cJ#HD+BU?hYH zSQlqncexmm>k~P@wOgzJz_*UJcLZqn{q<4+yofjVjn){z-DH@52UA^0yw!_oV*`^H zj*@%i3x@&R=Urem9=-O?@c)VyhT~plZ+5u~`Ct|D@tn10vU8V>C|amw8Az%i$$q@zixq zpG3QBZ_}DMSPAY$esw40<;2R)($00XyLD;ySq&d5{RG-~9$ES;nT6GeKef(%bvK45 z=r^xzo?DnRP42y{>WBranRyl(h0Z z?mRc0@8@?qMhX>2ubzZ5#{No`@WUoG0MYL8Ty~hZ1EI~_D=#XGO5`0R;CDG=w`!&} zEu^U*yx06gI-3IZ1?*9hdnLKaD=l~_G-w;uW%sx5-rsF2rd4Wr;zd*mvG1N+-C7hV zkZcg_^FSMm*BZZYPS%ML-1zb|ZD(_J!?c*P_l7h<+>K(u z761sj)*tOl3$It^;@;-@$4XJelI%SKG+wd;Q^CBN z4zol*vNutL^?im}=;w<}%ACGp+_5#e2%|c`nsy-;qit!+$=q+`UOJQ0^T!;qBY+R- z=cB0lDJkEv9QYeFv}Tr3A|qE9Tl@w|p=tWEFKnKIOOr0=XG#z2ZRMGcj?6>A*~VFT zn6WO8@WBkYau3f8e=%kNGC*8GpI~*E<>-I3dHYz04idHW$>Dv_W0C_W{gg|X{GbVC zS#h`^WyN-o%f`X6!d6x@kublAdEXpf?$|X^*}pA%<%KanJN$x^6TYmR`I%dH=i$l% zKZm{tUkW!X;R|J%-hGaoRLoQLs-;f%kkoxe$L*x2&DUOz31)I{{g@3}M(Ins_sy<4 zfUMjhak&t!eEBuhFVBmWwenIy)pfpk2(&?6a+_}(g4=n4is|46uk~hp+A(t_);ao~ z&xf;rpKtrJcKUjOSW>?0ShAp!dnhBf53fII-S=(qO7e#FjvGe*pTNPt9Eg9yss9~J zXZQz0;(vm4@!yW7|D|sHmvE4Ynf_miR@0i>wwt1;J*!GEb!eFYkg0=w@gjEEqi|hV zTrt(m>Pyi62o#w*@yZetHSf$GOP@38cnK{?6*5rN5qWRS+-5xwTxR6ooLqSELQhXZ&t~rEoFdM3AtF z(;o@RAf8ed@D4{^*^^Re7Z!vxzo@g(4a9>cq{#rn?&wg_?9_Yl8hh5rUWD|__e@=X zcf$}8?X?i6J(oQ`CHf9vi{KrI*Ds)#?zu6ajBlZ1w0j`8>0Zr>o%`$Ta!3{`Q|3-J z379`ul=5M=fm^(O0NqZQ=Sm4e<HqrNIB>dV-n=@C|XIbn#XOW@`9|}8+_$1eP%C?G_*&9nI(ymzmJyPUf5{0TZ z4JXXkFF2#%09L2KU7~jdshDZqbR zv)&N~K6HRhR%=cIESh8Ih7cNs4@QU}$A}UH8`(FNS=28l7>w@?1Ta#ad*_0nwgol)p>*CIHUr!fYwVxEBu2s%`-f;NF9i4lZu~ zt=()&7fkK-C(ul?8c2L|{%#(hlYdKe)}S_CR%)lpf`N*ygi{-uLxErnn{maS{5Hs-i#3qV?A)jG96efian~^y1lRmaT;;&AC%o4irgTp zCeM{JJY}Y8;T_X*h?RQil<)|J@kGm3nE^Q-Z2`w~BbHTC9E=_feC@#Z>x}Cd4>oF) zMOkB4>ng8fQ4EIH7X0~Az(8cE(7>|ai33p+vOi%O1Qak7(Jr`#-p=&+s_ zP)}Ra6(<7$L@0h8W&3 z))kj5G6BV+AfsO;LauWQ-q?-tHs`!>PepFAf-Cz_mbH|B_DcB^yR6G@le1n2B?gO| zX!q!J1?gabQH4;d*BIG)EC4Rz#47Gf+<5#F?Lyz{pQ)>p81pvr9y-ybK@$N!AXY~E zJG5ymBA*xz*&Nx#CYa8tb4x01szbE5)SDZ3Rp5d<3=^q3S%*zkzt=d-g|df%+FBpuh^ zY0w1UGRd0bX}e;mSVt`#`Xp@`E{`{;%`YfBhS4t$>5q%Oz!Qc)YG4ECd-< z9(_dUa;I+t(7Fk$-?jT^+KS*^0u~ZXaCYvd9+DLLMSxMDh-uzw8j`r7ejJZWu;+!T3KKy)gN)24UB|a?Dl}s+ zi%9>%k@-%>0v2GZZ3yqWpq&&NTRS^DAHrn^LS=_0+G=M>S&fK-ZRQ*6tZ>HmiHus4 z2T_J+Vx+4}qFE;_-(mzQ-8qF=T+XEDcK3{3qzY}to9xv_7Ya^KYX?|^X>AkLh2+l; zG>slvw@g`W9xw0vldEFqQv>^_EsP!@(G8<1EKDTgKEPttft9Weok*8^tsS^w+;_j) z^csW<3tycGZZwbt%Z#CzdiX7+e%NbTG&eSn#7G@A>xkWPe#Vc-LvX;$ipaycNQa`G z+WeXn$P_dK31_aeMQgxj`k!;&1D46jL% za+#h_dfc(2l*0F`IyMgxYdICFMAB7X3^NB>YLy-1!>sLz~=VP^r zp2ZsG#h9RoBeSbql4dSy)GzG^<~`FQ z=f*rJ86TKXgpQ*D$#8NN@!?k>%sEhNw-fHw1IH zi7Yj{Sm8|qxo3g^!bp``_Ood#k#-@&`4E$AluNG#E(K^@Qd&L?%8w}gyhK$mi1(bL z$W8gS@!H4~MAhW`nu<0$HN(xkY~*d8jA@%5i(yzv&{!9?u@4A;^x8;EwG-H@jj&DU zKvjO(mRLQWQgK(dyBnxihj+{cINZ&vVCGObb3NS8$D6B;|8MYg|KKq^ph3SH87^Puc4OOVeU@gL5J zXD+lU#=;4yXfzksORgUi<`h`c+U9+D<|2Q3o{KYn4`9oOBVFt)%FGFMTeUB$p&dr& z6om|lE59s$Ze-ShhrV!QPkiF@D(+WZTz7Lc>Jivxa!$v6v8WaE_H4&tM!ZE?IIUv( z*WQlXT^8==0F4-oB9f^*3r0h}2E0=Qhi^Ve!ARren(JiRtspCdOouoIcXZ9*U4OL& z0Zp~WW8e7v_6)yH3B8q-gP+ko{678G?b$d~em)x&;HaQ{3*MOn_w@b%99OUX)uQq# zSe<9`!=$JUK=J}DPPY1(JSFl_;a-={WcXoUfwZ2r!QOj(KK0^P{aAVp``2hj7LKG ziG5qj@?Kh$IX%rGqnK%BgxC1PXx9Raf^73|gxyFmL7NuiP}=ogq;$MHtc}tl3T!F3 zQRj_G;ykuB>e%%-L@%2`zlseZA?yV!W2e=Dt@@u%_C4Hh7WG}+oZ2~AIK5iB*xldu z&h0-qrX{?o%zxQzJ6}L08wAf>GEZVw(Cc_@W(9nkKW1c%7Y13G^<4v~1)lU$obVjM zdBQrIvLI?+I^f8q`Res({emywUo$>iSmc`C&TJ7)9Mft@97R^P=`Qpl9)a3Iqq+C4 zsdtQl*|(8glP$08Zn!Y>ToMVvigHD0zr4LRvfIFl#%qK3oc+UstS;o}E?n^lzW4OV zwoS!&$ukL-)@bo?d%C*#J;WVGG@B@7lRNo{yL09$!@>f$VAZZqtfh<&#*n>y3Av6R zlVwa@!5wN*qtjGlp~H^XlzLz1?*F}(8%7&u8XUq z-POsjK^;Ro1GgiK-0qCmR=aBdZ0q6a+#%*2;`Eju8T1fg$EDZuq10320q4ZnJ(%{Z z{wOu8`)!tW(ilJoG4|EdT@p{8 zHq5!?Jl$$n=k<(V;*6ydKKODLslSekdh20K)jE1urfoONap(cdQ=T7Y4W92Zx{BF1_q#*a@}Ud^3(q&!#NsSI9DM4F<#(6z>6h2dGjjqS|!UFn?V}R z%BMYmOE?E*+nF;oe6&{5E5w|wz;ea9F|eWh$vZfNXR6iXeNgy`6rnfbnuRtMIlM7f z7A`eSNse|$kG6Q_UaiY=xoas_uP}U8#TO4H^99~lNloV-SpXYXZPry>Wmn5pZMHUN z9R6Sw@BaFH6#h}1ME5{8BKVXQ_)G8m=1S{(<@WQ+7sJ~o?mzJ-|3&xm@BZY!@$3Ib zNc{h8fATN$|G)Gn85kH?|0TUpthQ;p#rjvcGi3xrTt(X@?%`z3X1@s%Q%wx-LNJEt zrdF=HCBDJJs<$Y29Y@%#sHFu4HCQKl#Np)5E;O;*?N)vYEQJnfBrbJJ`NZq7%ai*W zuYY$Id)!jlFBG2tWwDC+wm1t2aR44y)5YIQX7Ga%4p11oAZ*X5<4M8K9ClN?x*nMMLyDC`i#_$&w+Wp^V^F3V)| zE$tJ0Z*^D{X(ijyI7D3a&hjvEL=9i-J($-0y$X@`K6=j4^1Tt=NJOG+^lnx=8&4(= zQX5m|EP?nDrBt<=Uio~rapEjLL9`7 z)+(j>o?CFrBmos)5H8D4Wu?1$QKBq%K4Yr=PuI1z0=UM78g4c&W08d?X}C0U)$43z zOf~HaJY%ACP|d8xu9_nnG|I4;!4#Q_8MYAT}!kvoH^ZyY_4qi?zJPiOJysjW+uxGP|lDG6`OQ9^J z-I<5i2p5MH%T!l2yo0hgt}nIKw&Vq&tEi=&*<{sS2%cJa(fWWkX@4lyS(^QLyEO?_ zwi^TqKuN8B=%H(nZSmx5_`2Tw?4d+UBlPy0=KlGzsbboK-}#nc%GSDy*U-61hqiwF zv@PQ5<<`hQcISN5xa@4=su&vGJiS?{v~FUujG`WM{aN|m2x{qXMg{#P&@JESuJHgu z4*m3G)`MzaT94-v$ZK1-?$m}syq_8y50a`nkAN#n$LHJAvozObYod!Qz+$Dsa#=qU zIQCLMvtN0#q!WMZy0+w@R}RM7KH1(>+mR)wDc5pdw2^ri#BC6NRqDs z-mxnGG-tDf%XPvqYUX7~r|gal{n^hzfVpufK&XppH8%;0IP=r{Nlsk9U9KsYtgmP( zXEfMA`e1$H+e}R!6^Rw;`&W(nno~^cQ{qsK?G|9wx83W}CoG~moXdZ5!2ac){)d3w zKlDofe+2CQDUSMYpR508GAVivj(<5JApoKbpaQM}5n`|=_N?TqnxkJU%v|1fhGzSylHo@|e^e)u8r;Z;*4$waD= zRsTmO)n-u`DfcPQqV+7b&AQoB8M9fAw`1)yy6t05EQgH7N&ndXvua&qO8QP1bn1g! zb>NU)zy52#>-twvBq6?}OjD75c@p|I>x9b`bnFWpTAvI6X{6Zq3hf)qMS=D&LX zRz+qLgM5#XJq^L8$N(#OLU(GMHPQ5waJ@;W95mqqGb{KVB65$ZFyL8DE-zGTqK(KE zaij#)w-)@jek+g&IO4$mA&VIS$&2T@KC6~F3s!3IC=t32d35H}@&k{nLVZ8Aze(7- zze!k?eiQCVRgN4m3`Gn%Z*%Iq1{z|Elw-g8GZWyY_QdMG^(igpze!#?X!XBI-Uh$H zrwWsq{HSp_fc=-czRH%kB#jhc^SQ_r%-Pj&RBck-CcsAXPEke}D&@90YG<G#aQJ zb281NE_yNYp z<1shmWn|v39JdKGXN2>&P?s)D%X9)2)I)pRsqe~Vt#lK61-pmwcN8;SmqOHE!HA%7 zuxSX;>;p22uy$Y~IJAhDv~Dn?f+VGX1`-?*{mncR{LMU{o@AN*-Yb_wOV3FM5X+SYCF+*2b&jIQ>6&a`~EiN|!;B{cIe zamoH*y7paF*!)sCIK9?`VFo@@vbi!6iZ;)^inB#Cd*AYC@LBAewzFCa1_S&@faT~O zVBZqzXnFI(0%|i14Z53kKH$2pQdPZ)8wLB6YQ(f;vn@lknM`(w`CHlH`Nn>YZ4+@8 zS=OEY3-(EfZ|x;aCqK?B3eM8%xlcPDIdj&Je_=9>=4ZfT@NM@kBD<{ORgyS7(38g* z{1ZLPQyZ>rGCOc>5SO?a`xRstNUw&QQ*s4R&jLdj>X7BI4#hMt!-v9|6C%8wFnT`F zKn4DIDuUPa_WD*Yyb8y%bj?y^5(XSH;Jrzf?C~5wMs28O5qG2>%l;6c4m(DPRrE7D2L&HrN1_m%(4@;wK7Td zY@{CETx(|c8D|p{T>pL+{29m~0pa=$q5@QY|8Y1FR}Tfdw@tBzmueO!!}4VsQk3bo zTB*1gFbO&?-aTQKKc!RrXT8)|uj{k5s(5^VLdv>w;Y@xqqE)=f3ytVI(Wfu*FvpJe zH`$(@eyR((N>dRwE=ASlkCj_oCa(}0O;z|A_bjInNcR{Od-xZ+^J7(Vk@t3XQ0>QV zMsBj1WdUk~gg-wyEyG-^Rr$x>-h&UHzn9SVKsspLG1;P#>^nB#T;4uM=+T%$()f`- z)LhDnSEWsH`8V5nWu;e`n^U&>`kAS$m8O{eY@*q2vx$Da**k%M?&`nH^sb)%giTx{ zqK*0d0)bp{ezvhXql=SxC*x~idA}I;`Se$u95S^@2#^EBjy994_svDXO#5+l|5dI_ zSD$me)RLy(ViH<-I+tsmi9JzqzV2Z8JndVphTizxmW%0banbsjlbrAWPG-8$c#azl z$f#Q1z_~xiFtE+?XwQ1+s-`CPu)}D*XnPhL%Qe{Zu?qg22z%H$izj1|={d+$9*U%M zXVwPIg4{VjBh}x1iS!88HuvncRX0dbUC|0`Dil0}4bR@Oe=5f{qh?tZiDvM{$3mzQ zvrF1`e|(QHal6T(Ldf`mus^E`xuj~V1lZ~ycG%2=OOPoe>)X-ZvH7#>%brMGi#PrJ zaR5?oA1Htk*`%6VDCSHOaGZzh~fVpwGiX~ zky?n6iIweNa8vO=<>i0WLJZ}Sbs)D}Y+Nm+T}XPOs;te;JBstf#0JucP!j8xzcGC; zTn|MR9jH}o6#q>ubRKvky7-%cOJ|B3(FEa1se#<=G;$rU5sxX>QvfmkG+pis@X~iC zO{~WB`zuyV((koZr|^827G0ujbj*;&=#}Rw9d9@&9-mZzfB&!`$Ga`Xh62iQ)JkEj zWDBL+nveEtXnV&cA&B>>A--_)=k&NjO1+qnuW>rA8Oj1ax&}f!r)?*3kuE2raXJIE z5+Xy$#Y!VFwE2a-i33y%L7)Avd7kEU?_8F~pm}COf~!P&XA^w(Fh~GYsy@X8cV>N5 z9LcqQlgS#LQF7JT_+jj!^KJ=!NbplqC}MZOUb7?Xc4o1cflA$}HYU z3h0aMxXSQE8H|;j0I2HG%=Q&l=1I${sN}J-PxSc+jTNC3PuW5rSInzaAwi7kKe8lo ziJ7q}aEF*9vJM1-DD;o#$0%y@6;w7g{CKnX1R^N(qZKoP1I2>D`mZbY3t-5EOSe9g z8W=qI@_kOm-hWhYN&t%K5D3X(Y2`oPp=?)1gXu;yofP2&sMcSPYRUHL;gNi=OR1p%zkS&*0#OZPu3WU^$ zHpP+#$P8`iN7q-{=FgrPnK){BK2yZezrcjK3)2pq?<48daB5melV+DyhG&c&2tHPZ zUx?}m64>JkhG{7HL%m%#J!y2cV1Z{0DK{y2a^c0KKz2;%R2hsax5in-ro!ci3+~Tj zH?~RA945$KoT9ApSJD`n=Zb|=AHM#_DwResxr_xK#7P4> zB?wWD)_h|g5wFgjRa{fc%VwYSa9S9F;yd7?pcAuMg;Y0W{K~R_VM4Ls8JTkUQ&z8! z<4|S;CaI+=@pQQ2@qOELg{-?Fs|N8Lv~9DV}==7>qU{Ptg9p?Lr6kI5l(q+PwU- zYwEkFG9v?io=q$SVrzShv+*Gtb5&Rj6ZYbY^U8Jj6#XuzMm%Y612FcfpDg#@D9vXN zx??3+a#8e{d%+A1ib|+TtZJnX_l;k2vyAYkm?70Dx!)}`4>?HBFE4KT24OtD#^OD8 z?m|%Q-U!nfk65y@#aC46sa+%u3cJh?kq~gv@j7OBKtB4)s~$=|gl=Y1eUo%-YHDPw zW_J(IdXtN_xnmU*ov;Wv7RGWd)mI+#4~|F2kFGwA_*y#=*CDMQBIAH>=*~w*YN9u_ zUcO_7z?sPjmpG9!JAG1swvT;m{||NV7-U)3b%~~J+qP}nw(Uw=m9DgHSK4-FrES|b zZ`RWteV-fscEopob$oH+{Md2!inI5cYo9abnsbctk`PNPcahAOTOVmZQn9ToerpFo zV?X^FARIO!Rp~}sb4eN}-{E5idQ9^gtxhd<$)7pl*Zw)4nnU)4f3mapb19idY5!`! zoPSR~e_MP2rW)R{c$`k%Bs)bY-g+f6iNaYguHzt>{Y7|Cx}x0-3fzPNV%?EQ(AJn3 zYbFv$zHqC-sd|1q8?vRsH1t1)X45Pz(BZS*{P)>7_BzT<>j;b7OS>p9bN zMNn47**EN$a`^46|DD`BD7NZtTBX*f@o>iOPn0AYJV|mlS_Edwg*&*Fe!+<1BU#8C zbpTg{!}?hQTa7WLO15BiJO6jD6Vf9fIPs z!j%OD8&SQul8#luEdPLH z`>E=wO?H?Lk*SuTos<{Ek^|AltkvYF9Uz#x)KitW3zJ%o4#`-uXRt6Z=(5!S8*6Rg z5&}c`4JY9)iPG+NT6!JHcyc7gD`Y-!=?$`GQxUG{?vs%<^ym3Du9(POmYa^BTR{AwM&TB8c|IOTEn1>GI}imtI^osm@Fjmb_PPK0o_EhJlMP z%ioOmFB&KH1)hAD*g~n0hj$!|sIf|=DNtIu46utCVKkAIeb5EXMuZx7>@xa$4Waw5 zTueZS`}h4th;?D%m7RpLP2W<5r$P>^k~0&8S<^#2Z(V4rj?l;MUf#{RIy&?+r>f<< zx~>RKHnY8hLeDY|7G4$*|9~ZBSQ&4YMjkE2@n54ZqBT@PX>Ahz(uC>%9Qml|%;ilM z_0s%E=Hi2`ul@K+u)rwGDcky)7U}i1sgj}%j!x#Ro!y)SAkb8I24Z7XHUG2JLtRjJ zPc$0N^9>Z|9at~IeeX(l{dCsuC0SU%w+JqYrCpH!N)!}1>QQ9Bid`4#HOk4Nq@D|% z1G8`8b<6OL*l0*(sXwAicZhILbfc-=w%hMVXWBwOrB<|ZBrMLzDx#e{9yYGV!V9sS z1xN|u0QGyvX{#JvG;@S?Yl8o8_!O4BBYf80=Vji9#=2$hJv(AIRZFgVBj<+?Y{nvf zE~aguB`&#j&s8{YH_ScJby<5O_9?D%Ol;U(h5Uif`tIm2&>t8oeannnQ+cfR4m!cH z0-17Z@>GExG}<_6ww-jht`l#_2N{l!=}>b{q1ePTA{sRHRb2m&GgC zTLdR6#H5?r!8vr>MINNV;bf?;8VJ1u94i7aRk6rGrwf$7d7Dz)9zO-dE3wail#61_ zFwo}F^WAn8R9m43pwq;!^ev_i5iBF#eDm9WdOckTfNa{9mGo6_7iz!0zKW5S9|vHU zMk{0iWOoI3lGJx262!`L5wcxP+ zS3FBt34*vJQem7SHmRe+au|jIC-%sER1)ZFK@l#gCIY45Z>Lf6GeuzOwP;MdRjVOK zG43I_v2fQ+FphvBMHn_VHZYD=7+BVC_~hl>U|b_fYYQ+E^iUd5U^@f@Z_B#JQGk1* zv+kjwwTOszBGlhgYi5yZS#Z)SK{ks>TF}^=)AushvYfc5f3z3OC z8AyU2Jdz|8)B&*TfuR~1$jLyHinFGfo3$$n94TPhr-dpQCr8Ixj%FvsY&Bxh&$+^!L`eUKJqcJ*|H#r^wK;rXQ~<3X5S+mQ6B=oxr$Y0;knTRpsLU zToC!@z%sCS_qWQ;g8Uwh-TWx7=nLio!%PVcBDk;gGAkR}tMg7pslr2qwmL!#%nPUb`yFjz!qn3^nAH9>PIQ>Eh|L8dHQyKYKukABG6IF}nC6tWR0TnyeF{@U z$R4|ARY^0AXFG114rWPHsVXL0{2hAOHe6<&hJ~m-no}fk_8Y1=8D~az!Pxn@7Ace1 zUu^+6n#SelIT=wMZrkINFMorAp9ZxK}`F4L`SyO-y_eaq~ z9~Nq&+N5!>Y)Qsc6c%0Av_=V^TVlyNJeR|MH-gEh zH(TXi=_R=QbJnY_P3KNMEQl{xi&sxsW3is>|MKr~J`9-~4zQ>KO%i&_Y=n!tHM3?I%hpV^fu0EkK z5H_!YUBsL(O2vmxt?F%RW>sD8WZALM1E274PsbU;cxjPN{m3))EBfRm`az!!_yJHW z5Z*T58_$=IQ2Pjy(JK9H1|JmVC;K^!wQ!TZh;1!;lieRAX}dc5bv%CJ(V2a}Wzf2M zmu5qWxRngfsbu9M^41sf8|dd_{F2G0$W!i3vm(kKiqq(u4;-F0;!u@>z(pU&@v8NM zyT^!N`iC>H`f7S`<+v>k2f{~jR2IZB}kma9;-@To-dZ22acs`(@ z2c=~hntLBcRuf!OIZfVE?52M!wi#xw%~K|a6ZX)~F(eOd>mH`_dw+K2m|NZBv(mEA z_gjvM-7G%Co^_xFv3(*KeXCnhN~~?|OC%QbGKu1sJ%Y{Gk3 z9(+`Y!F_PDmIDxh(UuOy;TF4)-e_nR0zW*2Zr9#YE*g52uMMlemZZtf5pFXbnk})I z+_7!d?>&hq)(cpkLw*4V7e7S&a1w~tb7XgOrZ*|C{NwjSheS?uQgkPD@c{`(Cu{tY zAr)bw5#ZLn)Lj8}CGJ<0lH~6S_5%XE%iL&-7zH`E2J9lvEckg#p6!tZZ!$(eALiCK z<4E2Q5%s6}MX2Pvrqi-9Q&sUhXXQ;665d@1SsOE~7nUy{A)KE4FZ#fL&!QD>IBq=@5TqN%yigM-rvrJ)btNZqFZmySZePZ_hGb z?>uV?-Vf1x;Y_(Jd(jGZoPx&}2h=mLs`VSm#EU?{K26ec{%$GNn;)_;8+p~I^_oRP z+%=U7$#yaeWJepTlu&j!Y-x)DEzdxLD~X{O?vIIkz=w-ynkDV@g?h7?ohxF0a4WpKe*AJDb@L7SoB_s1SV4^3Gp-4gLC)pjYutl>eR7y(s^5@cbIVvOQ0YIPD8F z5PG?DwzjrpFdK1X`FZ2*@u_FOJlAJ(XY>5E%amm9vRb@jmFVR0EgMjbJd$I3S1n25 zIvoqz{{Hj_QOz^c%gxPmwZ={f89cKhbFZ!QKB& zQiT5+jfRQi->mASZ&9khtm>TVo&wzi1`xsP+tOvVeBIxL5(&}^p4Jg$jLcD-`@#DX zid{qewO`E}0>A{OlFZt^3^6@+I5=!=*s-5F?=?EXGKWlIOih(&_$iS&=zes41Sn-D z@R4C3z(Zde*RdbgH&b^Hwpi{y#{V_@1h2aKIAo#iB z(Sr;t)H}<7upa0Xw=Z};6i*|;Y;79w2tkiD9*8kCLIvOQBW&uRZ?Z@{ESN0~ktTrE z0_8MkP!lf0iIEA1VZ2t7fXfi z+{SgDfidJqc1XLX986>kbBP;F8%f}Ov|ud{nFoYMCnT2ap9udOi-+jmlrV`aj$aII zBL#qJj@)7me=(rWEl6OfJc)dd`7TL{z=*U-Eb@kc(&F-8G`oOokf^Z$C@@q*2YdT1 zfkadQd!%AsE-d1Bq8gg&lrMZvCPxIEc?=d`vpT|O?I(A~&>Sd?LEd^-9DtlT6c*@5 zq>tPP3L;0>u^QGtUQSEkBx+YgXtF?NfkMg+@3b?IhEQ%PWfhsZ=eJlSC}+!VHG=V- zD3IUx6G)QX&+&}36u^f;v!@6~cLj*dENi~5mKEgO2slaeM+S~S2lgbCFd7yAKIA!C z->Dc-J~bpLDuC1Hyko-LFU7Vfv*w1LE-{9~rjJkN1Xx~@iyE=%;j~8e3CF8mmnS&ZYh~*JGmcnS<;n3*<3L}B(Ce6 z3{IA*v3qs|h%ByX7A4U<^3Kk2s#f{&I>p7+4#>r9W~^xg1LujSEcMV5GjR@Sy1`5c zm_@FLLwuOXHDy`3f3{4%mzu?ocK-(a;&H7a!E}xotmS*V;jqxAbjQpxyaUNtc_k8~ zOC=MKk00kGL?)`_7Kwjjl0#I$v(O$`StsBb1Ce>?8kJhers?pgBJKL*V z-P&Br@?xM*VAuSdhJclJyyjku`naG&93-3j7b3DP>k;Qs_O=r50|_irigCUO{i0l= z1}iKiaCmlYeNU;SV)RKb6MXHL>pW|^Ly6*UKCHP&NgkdcKI$OdJaHLxCuEmIpAseA zL_Mr?kPJ;iIOuBDuR91V=A|J5|C~5}V4KV}Mx(OdW*|qN!_#;&QbVf0=NUyaxM*kz>p2D*zjG0Pa>@knSI2 zOP~xEvJ;d<`;OlP8>7pzW~0oE%*B-80$@&-$q|Q`b4j_ukp)crdLFl3lkN$D5ky8G z`n%lOOx!~Vt!$lmo;Ccimcwd|MSy;py_-ecsSF=a8gqQLIt>t-n#kb^sW}FUsn*r^ zJdS|4h~c*KnEojL@v1a@VizHtvdVb~PyfAe|9Lh%Vo8x-xfCw)Ya?9(QKZYf_jbn6!ztPZ3}G(M3@_!0zL)cSy!6?c`2+aa{;2Cu$V#a z_+@YCoKOfY>79hF2?&e(6IDkF%2@(S${L#snkY4XKNvPf`_pfbm%3K_jZFn2f3sVx z*VjcTxGBNxc5Uj8>b?xT0Q)`Dg&6a(gZpIa&qE))-J-|=YZw-c@`WR@-)w^%a2211 zsyIWoOG|zgs@0DZdnN2Sn{ppM-27_hd_P_qFYq*GST_25z!ub8+70*AYOkyBp3dho zwq89|&ec9V6#5~)zVb#DRdY7$e71g{i7_rb=}wJSDV-Z?r)WPaz*O1|cU8a@m2WGy zzvXe3)}9T~dTl*KY+R^nR-e^joK=~+g?@A?axX-myS!>etLT>zewR<&o+xAA9p3g9 z+;~vRp6}V*H-ftOC2O_>!BbMm$HB7#UUbke7|Qee+W(Z}jaJzT!c3oK>Fww?|lUmt1w|0h18qtSmzAR4Oerd11h#;6cZzmgPnDv(Q7$f<^JuBWzVFUX2Fw)Ock= z&KlL4{Eut$l!Qw22x0!en11@*SWXdAuL_7bj6Fl{57tW@L&0By60 zU#8t^(rf!;I8R~wU9FZLVzMppa>P)ukKbML`Ln)!C-7ME^47{~H_HI??M-q}2hFE_S0YAUKW>VaO1Kjjb_EI#Plz^-)|2zORw z0D)SZu!h}KwX$>jZ1ZR}erSnNFBb}0EP3?_<8S?FDZNWQ+4iqugw`aSS0)@WR0CvQvxf6y5#CpRgB)F+wy7($(nR4rxD0D`P!8yq5o5 zeEF629%8ScYCJh_v)Xh?7!WH%TwmDZm4%UaE^!~JTALi?lCP5QvrR{L{qsFRGPat# zry|Y5s+xc2^wiVC(f8)l#>3I)A+Q>~OSlmDW^lsK1MZ~?TZ&?AFl-}2-X{@!QFOx{ zk%&@Wnk&CiR^9uhI2WZq_jRTLK)Cg%=avC{?&Z#yfR$An;MlO3AyWE1 z`@1{cyt*SI-llAj#}98*MY`*TcdJvHaxVfMVC!-g4Sl#bs0vru#5@ZDT#V)CmQei4 z7*PkHtU>3^YH_!S@t1J` z>}B&O(HHmh5|I#h*+-;2ulu?{qV_8GX=ptA^M}xJkWJ)e79q`R4XAj?!-cZn&>YJU z!wCWN?e0cj&V;E+@;U&YY+ox9ndc>S96gu*aVKO#$HMa`Y7=iqJ~Qak1Z8+*-Itp# z3!zPB)n?ci10VQ;I3-iA=EKi?8_Eb1{mU0m+x_(t(NAHoTJpO&I+>oC;YJoyIkt&i zJ20FlWB#wtbJ5ggn%-K#*x~mN<4i1|Dqp&tE74qKEUYYov_Z(Ryx~G}l{=T6+uEX))S+oEi7dR`FzQC5e{Fz{Kx{!Bf8g?LPuEJY0KM;)i;ji zdSV5@UM--eOW2Q=n#Zo{82C@H??iU#85${KXgTmtyAAWfxDH%m*uiaI z!bE?+1A!+B!w*>f5WrmUKhGmFZk|=Ujw*qP;_bA580clBFF^><8It|vxEsS> z{?3@US6x&)eMP#5>x_&(U3<9Sq3{ibn=!?sYH@qluEHIw*)W!PvtHqCBWGYYb$%=g z+}MLP{rm+`-K%G#350LNH>qW@>8YXKPf&onoe56VzQo@-NYA;eSOv1atqIii2pFup zL>uN+NF7=D`75!+=jmqYtRf>u9X}dniGh_pWApms0#YBEDURjJPi<`%56zQj%`tA* z-ZrP5*UJzsdk?=ex3_LCDeuh96}iKc+GWZF;dBol26nCQl9;1$`=r@_k7wVmbH@3! zF!yo+3r4Hst#9uc&9(PPoQBb-Gh;b5Va23g4HtI}RcT)CZ08=B1^%wbB$X#~U*Nr> zF9-b#_+2)!=|3cP|B27S^xuci!t`I_vv6?yTOOfEZOv|t1L0dOYup&frZrzga{e1S zp<80RonbA97BgUkyDm%Q6aR6!V}F^)Rhl1!-Nw)Wk#J|>VKxsDSHb(EPmLsyImm)i zLp8Dx;Y}Drk}H@v8i)dj9V(7->jsPyGMMNkA7v=GAZmKj15g=~O8 ziXe)TQW2p;Bcptb(^W2YR805iVV*v=0Iz*v63>E^Xj(7wHS#;KKGjiZ&tk~roJOn9 zlBFbIB~zXLfCb^sGp)oCkkQz+168sQs=EEu& z&=iuOXNzZo;=4CM%m#o{^7;xx8bo%m2g`pf3|pLnVX02BSRQ=$+lhnVtpSmooDP&gnes%t}9*kN$z95H9g@O z8mS*Wu%KdkI(ZT8tX=7Mvr{u2j+gG3)Nk#D4ZU@}>?-`*>2!nSi`IDg=~BC``KglD zxCd(f-P5*OWXOa$4CchS90r-H~$F%C%g;$0US)p~b#Y0>f1FD*qbEI8df&Yi$yf_DG1AFX-r z=xS}_ts>?&P2O%IYhDa}FwYk^&l|Yv`wq|?H7K}la;i^>$&t`++@fl*x3)Rb>>?#8TF)+GLdBM5tl8T>lV(!)~IUn}Wm-Ti#nwpbgyf@Qwt zb&ZF3+I~Aux<|j_e`AsRmtUAK^lcroG=x`5@lmXmHgF=^pL+%Y;lPhAy7D+-9ZbK( z_O~BpW^bsT@vQ>F_x-VYgWq)p5>mEGXSAq;y-^rbvBvSlntlcH zvTnez@$p7h&F==;fbEXc$9xvkpKV;7TB1a(W%EB=l}EpO;C zzJ3%D-8eqve2E#sB78Y(vwRGvA+<&&wyaj7e9|?}T9PG(F(VEm;Z;9Yu;;AW>8kI} zUY?cPE)H8+v^T5!?b>X)#1H>eG21=vSl7Ct8e>VYlmgDaGZMIs=c-+Ss z0b4`)PJ+i^3y;fcKiKfcI2X2NB-ORhBt1j`0ixkUBUjbLXvk5Dn=LMQ7PbMJ7`8sd zd?N3LpvHB&o{U%z@WptxRxzG)SWMbh2nB+{9Pci3+G5CFjC0b|Ol;JVEHaoASOEte z9>^S=m+|ivfz9R;TlQ5NYgpp&AVE}qq#g;XF-J46rYkW`FSg1+7yk~Bh4=*=&=i!N zUT-9T2W$&#<5UdWW710;Ag~tWfoJl!l>M866xgEHXgG$4!>;oRC%?qenchh|TDe zggF6x0uz90%{;tNcLc1HI|~AHCdLvjS#;Qk^k}A1K`f?ZL0y#D8W_)>lifUNNc)3; zyOEQ8K^&uG6xcdM$5yW%$bRE&G|dT)NekglvH}<@h0q=@xgtZ%`@i$cOib)c<`=+X zAv~VBvy!?UBd~ow%mc}iev?5Ou{eJj6%Mot5K2Q1H8Rvvf%j9yahg1$-dI46Q<0?< z*crpd)C4bv4)Ui6WI;B}_Xfu#5nQ~17^etEEsoW6G)M4A0D=>^k51MC#5hGLmNTI_ z=X@>({=mg_wF49jZMez>|;eCa$wjjQ`$!I`MSVi^3+)XI# z_U*VHj34}mEAb1NN642ovvF;Kkh6(p)T!+w?nE)EZK2WG&Bmw4%nacAT&9NrGE87W z(<52pysS)_h*^&63cXfhe0|XYe+rC1EMsS#o-F@gjs6yOU2 z(in{IPU8uFrV(lwIaYo7;acE2nZ|mh~Ab3n?a49;9uRqgsJ6 z3&uSTc+PpDI60xJA@_FRti3&ju$Cac%F!tKW72^PIA{AjR5aH19~Lm|F?O~^ zuEAw2vmsItb*0w|_~G0rVcf?rahS^FDFIw~Co;I%cX4gP#4dObDeG<$yZ(iVFinmiImLu<--a27j5hhh}(z`-?Nf$WmT z>+FF7&~J4ry|$gOm32*$I493x^T_xQ@-~K4Xq4A5%siehM)+v5=hr?N8ISEOYraEW z&zF?0e&n5>Yr$OXacGntb0s0H4!5B%*sid+lAoH*xxP7-u7PC_0x0V&k1o0y_-NW^ zIFZwZPO`1-sCio~x*X_zydUn~-u53g=hufeVSBcAL~{()wAs@IU2OSm0rm4Wdg!?0 zR=J1pNYO}4wPCB1cC7&r!9u$g|l8G$J zBbAknjkz*+G`qR{JnO9QFyMsF@al&3OgN>c_?T`MLRB*$W(~quYt0(zc+b3wH8!J`fV042eGKS#b(+%0aUm8HYa+ysR z{!H_()}=!+CFle!=YrDDz};Ql&o6T^WWRot&YN=O!a5Y~cn6kumSJnqw4j;RXWx31 zF)+gQJ7W@5UdVeQ-1>-eE;oaov z5$mf%kI?Rglf&7@#0jS_88cy3X`$|lOo)k;nFHeIjA9eHr->P;ur$JETpeD1r=OWu zP+W0V8?9S4MWhh!5SweeeeG{Bbn2&gMqnO`$LiVizPW5RRw z)(8_$7ILq*#0l}VH!n-$VV24hS9}>L)z{xTKX0^^dOo|$n6gJ#)<#dG5i-kJ*!aY& zzw7r>xBj6CfZ`LGpYYE5S}2&~Bz}g>hBF+ZQnh5{y4- zQr_?66MDN`kZpYONT3G`q_K8WL#McX{RHex)&*`<7D}oxwy#~H7s2cRQD#^&`w?{f z`@y5(L9)iKf|!!v?7LAX|I&nP@Jb+olor1VD_DwqImS4-g^L z_46aY5A-t56FWg0hK|i?uGZ-1u@rF7YQs~02lW|lF-dmR9PagnewcLpurw#OIj2v1 zK<1QA`_PbP6U|{uNchQDBbYaIL`QAn)JI>{Hb0>yYnHPlVjK|*gXFss9x-Z8%m=g+ zu&CEVJ4eG)4c0MmZh=)-i#OPGBllR|WZgVZ_~O=ltrR6Zr_P$XGa8lL^1ff0UJ+9V z*2hFSH?(RqhF#WNIIH7B%gJiz@^c(QRF-dn%b3`3)U5oF+0vb=;GUpifQ$9*x-4C!p?kMqpNA1l2BJ2FWsQoVz{%?ZX zng7-4`hQ04%uMWz|6&{cEd%fU?G*iMW*J`|ERC>jyTyaYz4wb)-o&H6EQ=OZRtW7M zccSPg>-Vy?U);RR#Y$!K$A7&n3*K@CUt$K^ABadC@xT?u78iDnI-fmmhKXQ=l85#! z5##*&p6#Kr;&afxUhE~P{Gau|{EPj%3rS#wq!!me2d{#{#2kev3?U6^{A12Ob~8-B ztH6?WgI#~Cz{$o--wXs;bFVqc(K`Rb?1GrVAOdpDAxQ-0srb5taU?v3ttjWU?<%kd zg4w5cE88AsIOX8=CA#Hg;P~#)HjE9Y0N;y6&MK|1W`fMke3y|+ z#97fTIS9E9vU@@Bo@fUBqUZ(Y9o0vi)D@6bT)}eX$9TtrmK{SgZ(F4I9hVByBUv&L zRM!{Ou2G&W>=n^OYUNO~M|G9BD*_}@VO6;-sDV|WI1-1sl-<$5Alczi8Cs2oXv%oV z`1&n7kXw1_wiz_D*Zj#_1j)F<E0DNFO`0mi_5kU&wm+{BK|eEZ;JvV6No z7DB64rO*=~NgCafMg{ROuT}U@po6+7QBVUHif1t7B0JDvP-{5Y@JbmVi^W*t&06(2 zBDsLo0c3POF&>be!k~ym{K}LdMs|T!HEGNO-kul9>gBIl8=@MnA8bn;5&L#0VoEDv zTda`BKTUqQ7o;>2=a)|0ENw-pyGNZzNy-A8{q|XsLezW(a1z%i6yJ)nVrnJlSger7 z3PByWnPo_flp%)|Cj9e&W^E8JCY*$^Itp+yLjv2!vmn{8AQ@$2X%IgYrKx4Wy2J5{ zE7^Wm6xTt*c3x3hCk&-dQC&e?ZG|(IleRLACqdfTXKm_^%?^?(zSGqLIn z0K@8MoC`?auNWYRgz!S!~t6$ z<=U%}!p4ELX&{{iR22i0h+$iH4E~+Z1{BNrKO!`G>_pn*{?W5d|? zEY*=Zbp_?`wIWfH%;y|EKEh?JLt5ZU8CPI0#)@glQN&dwkD1-#h2Jhyg7|1>M)i-t zq_E{7-%%~GJm+OxQ~1J=RVWhY<+sJqPQV)Y-khl?h)3c9+X7;UPKhT7=J@zaUV!9x zJov1s!Ryu!JwY@xoU+ak_nFx*>cPmCCQ=Uxe}5aUBE}fC&Ul3iXUYx(C|VE~#zD4* zP*tr?0-Veb@B}s-P%^5Gp9!?#Ed6IA}JFip2lZm5Crr z>ov1?_%KPofl%QKK+-kW* zTsj!c9i#Km`R(~-Rd&FbhLB~#ts*?2+a%1}V_0zqPsPYuM#;aXlOj=4&&23o(H<1Q zNS4ePal^eQ50r8G9hF!$fw;jb1Fdac$RnsGZ%Lc|kFlOde z48b5wfGYebC~V&{vQnNs}cnm zZ$f8GYO)1c3Nczv9#X~MPEIe6;Bo-xTN7*e-d92PG8lZn=zV-Sw5vawMRWM&g}pU< z9dRvcHX)tXY=@tAYw18e$}>V5HjqyS-Otxjntepw=SFH@`)A{V{3!N;dp8Cx#2dA zjXTjd97%GzJThdV&?94CZ1{YzpUK|u2IpvUy9S+HT3a=K+o@$dEXbp?yPY*(V2(NL zbsukUY+O_`2e*1}9BFpzf7HD5#dvu4eVXg|LaQCg&Md8A^@TB3x81g&UuYO?e+e>h zV$JYHaRbG$pq6Pf^|^)S(?1%a@L~>qYD8ZTGWbW(U9NN-6rViApNXg3v8aIxGBLXpYS1Oga597XKd`{;6D7Ug{Og za@&4*B#>HOP@3?Yc^Y(IPv|bfsdN}>I)4=g--L^2A62%A7toOr0|^`A|3ZW#+a8a9H%o(hf-IA2d4NlCwFfo_f!Y6<~8+4 zdIdL+F9dEBh{T*jmfr&hT#@hQPNg4@DDAQKyWU-CXJ2h&RLGMy;g=pz^-5>^iqH1J zFrNX=*j43Euc8>C_|U;&+t$g=-`OE{zu_-DzO#(KB^pxb_Au41`yBP@P8QVfNH zI#v;UhJC7VIsdS7QWCPZ^-9$>V|za*ydVAUr=Vef((QeJyrJc=J$?TiRT2cMLI^UX zDlGc#up$g`wy}bq{Gh=pr1!5`UjWV|bJPGqV>Q<|pBXMqiT?LO(0nQjM_$o34EY`P1P&DSTk)sAupF@BR5Ds1x0sASkkE8)iyVH*O|A{DEtuv#^OJ#Y6%1X#1G` zDP1M8fJ7R@eQoucZBK8qSmW~i7z!2n_BKQ|DhzOL^8vXvZuXrMBjrqo1~E$K3aO~- zGoRmF2`_W35z5Ao>d{LONc`$VUX7#``Q_Yo=VI+o1Wq*=GiVM>g5Y(w5r!qI@Tl^J zGeNJ&iN3bV%?}#rb)+i~8#jheTsX^pqu4N+c)v5{8tI=k964CX?hLw7N+QK&be4<8 zG8SIn&Ori_DvXtaO%$@VW$Iu37!-kJ=hUoxwD}T{?8zNUao?0mlcB62o>hP+!i<1>S}~v;m^4E`N_JQh8a)utwUlsrS&-ZR z#0dZEp7wCRC5VR-klj5fq=T0bSm0f05XD*3=1fh6{>ezaN3IJlS& ziqfvId0<|Ne1~Giv>+vJ-v?3Z#de}V+DUq*arIPCp-qg=5%X#mr6S!ta z`!Mh5idV`tNON*hxl*&@m}ZnR!Z6u0k53LUL}{-a@iONBQok`H2Ls2y6HSdZ zrFF4?WEQn^p};1NC$TXSVxgAxns!5D^BYz*)xrzoTmTcQca-OTEYL)*xUA3>)4DvJ zWM9tFc6l8Am=ae+GfdBanSJAU>T=)W!G9A($|H}--`aWM$Ge$nd|KM#(+Z^cbcPpt z*pJTzc>|eH$3y&zq0Cc^f`BqY0l|pATjg%q*{GwLrmYwYWFM==aChVQ5_k7nl0Yg< zHHprfdI1*pvJ_*C1`XxbaNf`lwc=EfG1lqysV047? zID{YsTl{Tt_3e~ZPsjl)kDzEdCYX}8j~ikVWH#%S1BiqVE({The$v4rXOL1(>9@(` zEMABCAPgoh1X=xKp@RERil-T4tGT89#cvp~^j(?^f*=W@pfoa$@9kMqjd7{@p2S5G zlNFG3GY(kT(;js6YFet^{KY92xU$9oM_{%;4oEUJl2lbv*hF=7jmV@L%Tn{xiOGnC zgOF^wk}x(3YZ!e&15ng@s!T}9fMf`?|goKfg=?*C9sUWmtI$Iyl1glOZD@3+6 zN7M_+GbgA7lT`$3Rd(IL{-#147m>liUNaZ99V@eJc^G-gzC0(R(+OBj5~&vsmA}Xw z$YQlU7ZuUY&L~_Us?1ktva?o#6{WHse2NCe0F>3n1PESCiF|G2sgxxfM^74p$k-w zIu=@MOoaI2e;WctV4oz+(b<)awM|3NAc2Uwy%aN#)2Ccx4P*18v)^_l+3&x_4m=d%;P@QLph# zXAn>jS^@`Y4UlBsapca*#)NR62!aH<_%Oy{q9S^UiY!CQ$5h$suKdUXw)Y;VuW}5m zj;CqN+n*%Tgl-7DwB@RD3)doca83^NwdBeg;xi~4RwyIAiQ0qQ$UokZAbFyv&CUjV z)S!7t^0+gyRGBZfvx-1d9MRAm7P$qRs#6_ zoA~9_XoPDGmPD&rMEFT}(TEGMZG7c_(z`r(zLc>S6*9B2Bc|jJoqN^1OaNg#Hz}tu z-97zN_|NNxX8z0oc$)yObTcjWsH*0EJWO&2hBe}(vZks9Ao_c1it4wFIli9jdY*=r z(Na#hyj{XIeM7}Vlj}A)2b8Yu+@+C`FgOUyKw0YNVoV~ndPr8e)0Q9Y*c0tr7b=iD zxqZMjsW*PfRY)$b=EVa;LkT&#Y5guJvP&4YWEAf;5!fR~S|#@uuDw2SIBeseT`$?S zxnDp#a6L#7zEyX4>-j$>!C8z!-9wQ&_;LhEv7s60wq0cm#RPB58MZ?9hK=;n%L6sg zOo0mli%}!x+^x0~E-@_*)--^c1@JsMiNV-m1cyBAQ}6D{p+cXHk|Y>lNz%utu9m!t zlN2<6L_fmK5-Jj43@f^~a$k2R%s=@wxPvXOTAkYF)Jf zd2`tOSzNZFm21i#OEAYdzrH!rj8{ z%{tyBj`{Oaa-m~!{<>E;*VPUJ<*~>j{pm95%5aXNVrN9xCT|z4i6`Fq9`+VOSP%J!!oQu*(7#tK46sZh-x&TEq}yDrEz<+<*9fehsd~xVvQO| zBhJC=Y0rvzI3Z-x;h^1cHkf}} zGJC;P!3Bl7VH}uc;vO6}bUj1phH5DjFcI#)Vri293k7xmK$WRzDmoEqk3}#zCYm9T zHH~V>DAmB!UEH~;T52#NCPF5#^|hi&m-Hyne9uZBkIXCpqJ@+c0We+EI9=3X!7PG- z29^~KIe<&wk0^gQnpy=+wD38LX>XIKJ=H@a5O9(Ir@F5Ui)&dH#ezE_NRS~wfS@xl zFoV0h6I=#@JHdkmf)hM=a0?pT-7Q#vAi*7ihlKEk>?6tE=iGPh{qgSi=Etm=`f62G zud1%@RozwnrYXNXj8MsJtpY$Jq{nFC7 zhA<`COirifEDS^%OGzFRsJiUejIL%OoDq_@IEY|@@D3>PfXFP~6IJ*L1Q{V=6hU+p zK?gQS2L4;=hZ)_4KzGC1#H4S5VES)Wi9o9KahEQ3Wju@1NSTz_g z<0O2+j_McMifBn@Wg(1-vag8>L4Fp=RFzC>6wiwcB9-HriazgDd&fB7|+&;(g6AGk5tuY|%N@NSgaX=j> zS2F{OSS5G!Uc`~cBz6Ck+QmdDRHEEoxHMRXLdusA*-6I6&q8>e9vF_H+C>*-DimsZ zzyPGN@GAwSe^fG=*n60@YD_5h{32Fc;%^e<_nQR3Va#wm0DC9~6xl3c=NX(TJGrnA zG}L6!*dNpRbqW;8^7Krn7gdyttm2hla+Q2m@BRC4QL5F>=;Ir!h~EJ*Xu$voDTRwA zuH~9Tgc{{@C;cboW1O)A{xp$jEDV0MB1VM0jsR5|?I#5v0DQb3H6ELygsA%@StlFR zq)xvN_7FA)zpJi@(TVhjq|AuDas%FeU2Xh*%P<;>5HJW5#hjLJkm1>eH@F z@1x-`Pw-$pA)H{)#eFb;?Zs({M>v0sqT54Y_ynfrt|{&*>u* z9mOf*5+w59oG222pPC!vPtww$hBdtvo_wMstwI8ODeK8{^tfa=!gJrRfSMV|pY=X6 zfi#m5qG@6jKR5x3(KeR;(yodWAsI>>1RJeHvS&3;43$J8WUVr{^q=xuYu^C=7)To; zkdoD-%CUc6|LXP6mTXWkg7(fypCC7vy}CbzT|nS}-cSl8q6M!*SIRI=cY2MlOdDub z6ZvRAkH%b8rXgJ93rFrSt11K2BvBHZ{)W1qky8}qiF@@y|vqttKTt6V>4EIphEmcS?f6JogRbgo8CG90412wlRkQ%L}3Q;%Hc;y z5xk+!L3u8Z67q~SwS7>f(}q$u)Dt`WR>qet1MGJnQcKkm72OYObH=0Da|qbih;`0# zNSDsDOqOF%wG3vT*31(bU8@>2gHN+}+cz*i7N-rxp)42A;e|Fd7*P{cC^GbC&@&-Q z=A3)Rem;Gau*O&OjH}%W4Gu|o>3gXM(6VnW(1BmFLh>}J0 zc=#uZxnUg6=V39X>?Mh5Nfp`C1?5f@BNRRfG7OToPx2Jyy$Gt#FhCNq@C3%E*To#6 z9jf&7_e)rIE(YziWgE#r_wrJe61G$2c#}&wQa568%eRhA0BbU+yDT|y zt@vcW)uhpMV2E~8wlMbmTbch@xOv0;Dq8%r!<2(EJiFbd$5-=Q3t86O2m00Mt=`Xh zeS|#JdSPESrZ0!Ja1IUP`nthOJ-HvXUSHvDtzkyI>&-Nu9@r_c;%#kC9`#*0R*y#@2V&9xd{bbronii9eTAO)Au_DHHoS)9?Dh(Xh1u~qf zi#ZzgWoA+$noQ0Kbrz^y=@lnrzxL`c{a^c@+U!4n2h*~h&4=8;-n7VHLAF(`o12-t=^9v z<4wknyT`_8E?u}iD4Naf7mQ*TqxXm)7f5&asIw~AH2)HgYcxNrWi;%(b8pi;Y z^5MeU_oDzh#8ErpP2p!BC@ZAgKt5WL1(V^H;0C{olP`q2Q&++{uj8V;`l~$` z>k#9|D1Vqq^_5>;VG)a=JJhsXRBLd3;Mg{?n^q`$hpIKT_9KVNmw56_`6B*`qdR-(=b&@3&a zXzhvwtOAg{7$0Bq#GrNfw?6$K7ocYH=)x~&`_U(ol)7){0dmF_%WU&seUUkxouxH` z?Q=GSiF5CzeQ(w`iWMf<*J=_-XzfE4c#X`Vz11qnx4-Y^bMMw=+SR$cKljU~flx_* z{N5T@9xrB`f1SglJS$Ibf066`_q=aL@~5L2;wDeO5HR4L%FCtz4qNZtL^`%&KzRKF z?V{x()0ZdLi(>|(lJ&QffDD2*_(yDlR4IT68fE%Hcs1|p-Srcem}jeuew`m3Bl~RP zKsZW`PgCv>7?!#RBXt{U3M##|=OGO~J*Vn)tlTwv>h}YCnv8_!m=5H}QS%y+vcswW zB#>elM%o>+`Fv?^AAPjQW6^iQ)_^a2s?^I}AlSp0tet9HZL^JM-1F)lnIs1J!_hGh zjH<)2;L@Nk-WFjpB zA;qBnzB%Eg*67?_2St+COzw&lOBhR$O6JrBYgV4F9$9*wL-}BTDa4+b<4fTKB=;;M~)9&?guE&2N^?n$`QZ0_F z!N^K`nef0)eItLWx^m15s@sxl2RBz&ZjTq;GUG~Zg=Ohumz21|->bX@zmYj@P&|?3 zuwEHi-P&A8((2t(MI-r!dpkaUfja1Xc`y@ild&{Ya&W}Gs7@vTK1eaffLE{Z#>xg?FBdp?Uj7(W=eECFy`7vFQdh?!YLSl>X7#De9$BCCi zE0*XAltBfx=}G;^dzpbpBGRIXP7oA=?_q0($mE?z9fmJLlxfsotfgoFIEfOK6~%1g z&D!-MoOs0`>`&iL+R>*^(p*o`E1T#*%d3OyQ^USx?A`FKxax*OdJrUfs*zQ)s@N_g zpMgKBDW8%iE@#p?!$rC~d6EajsCI4r^kEenk~g@-ChaTMtOni z6QdgI_=>amhmugD8QloQ5F#Z3gJ<&RWMde?=T8z` zS=ct*e48*Bh7DIDBZV#I$a6^0y=hhm9h5QaB{MC7&IWmch+Tqp@mxOj_o$^3J9xLg2l|*Wf4Df$KB2{@a{wp zPxoZ$jA5k#Kb>k)VU{GSQ>{CJmLwJYd}VJ@Sa&jb!!K%kFWphYAgZUbSx@+U zzhp5&n;@l%puUEGHK>dt+Jw;Y$UWC9sJahuRPR5d(d8`Ma~4di`VuA+$|U_zC8x)M zXE$$yf?IUfm$NjB>lFSym!{K3{K~{S`rfELR%8ME;EAa1@8;SSGAL2RCE9G+sH2WN z=C03XB-eVKde0v`$Ldu}hm4UuaLRy&usCJtK8vW~M{`lO;9c`9p$w0UVW$C~MdHF=m|wtSr-WOtOy!5pU?(bWPHg7Tv&m~vXC#eB>*kJN^3$0ST!k=f=mnS`4V8K!TT@$#8YD zx>&HcxW_Ww)=bAx8nuTrmCt`c>K%J)liW+;0Tu~ zqL$PfWVy!7v_|pL+Y}i!hi*}`8>NJwEHH^q^{TS2+vqHzEc&KoMvZ^T7+iHlfr$1K zPAe!eh^v%6JypV2wV|FNhjjEbStt~<`zQC@~?52?W zc{RhA7dY*@s4sR(>v>3CcsDjT)_Z#mH^g_Rws>^Xx`b%BiE2u6p3}n8&qvOIw9vV! z(MiTbx|s{~5Xm!+!*2!`ytg-uX#BI$<6&qMisSuFs0AYm6Jh~q_I$WEtwgjlj#zjS zO(b!=>b}=WNxSQ#I2rkbj?9=ojY<#(7KR3u#y&NzAp>=#x@;yYj<2ts^V!d1==3I+ zGY{N&80aDxjT_AOQQMR5^KYi_iEq_cc#v*x?u_{9A8#7Ow*otnjRsm&PaU3FVa^U4 z5$@_2kWzoKoLa>+s?b*hTu&G!S}tAkd9Fv-ONop+G1C~ zd3<9tQtTFnK`C-+)j}JBYM=1{OM6+cs#8uRDfb%nAQ=UB*mG0eW&8EMP1j*qgN=F~ zi3S)m0!jc0?BeicJ`UJb@S07Ot&t|i4$tZyq|BsmC9ZjbDi1Dkw{j?1i@z5VlqxrC zXEaJC$V+d!%#ANG1k#$U|GZeF9x4qGOzx*Zu!4l@&3OP_T&0x7wvyB z_&|Z+-`5767T`y)ZD|>usCxB^UzfpU1*VRC7dXTS8d^He8Zf?s;hWTVBvow~(7W6bA``2G^sNBfE&Jw$>{ zXFskNESUYS%bTY2+gb@&KDQc$*D#!I@#Bl!=j<>W&RsvQFKmgsw5@xBbs;kio8T_d z2fkn2Sq+c6$c+=v*E1uMqCU~>iK>b)p&AIyla2y~i?J1$m+DiKuwyi2Dz3qLS>$!- zf)wo!=-;dtbtUvLeGEqEn#=LBUh}yiXD8r~OqQpQHa!?@_bb5HcOam}kEIt(>I~=% z=cH<^fo#ZFy<-uMKF;>1i8dP17SV@Bl#?2%v5N2X%GX(?JU*Svhv3SG) zBj1beF655}-5=>S zykgw2v>B8@ew{K2ZchyNS10TpL^^vmB+=bk=59(X)+0GXi>S-t7U>>ySGIER(TN9X zqz;L3ul@&#e)TU0Rso}kx zDaCL-Cg(jQByE@k_d7B?Ysg8zw>|Y551Ez7tq)OYJsDS=)~m^?KMP*)r__kfMlLoW=<@m7~X`s99c=nW1iwGn7yTBRL|fEXk(uEF>Jgn z@4M&d5C~1f&>KpLxZcq7VIh40Vdc$0t%(B=c%x~oatrHBquJKj);?PGt;gKep?ZnJpiPf#& zwFKJFmG2@aH8-2=~KkdiRY;oORP^DVH&u27Qu}5I&~V;OVNq@ zimpBwX({?GLHpo3mLnj32nCa;5^aeFM#gQH{BX zO1vYoG86&tu8h|&(4;UMs&qEh(3IhM)8Fo)6(>o=*M5<&)yK*M#uvXxL5@m!aLezI6)R+V69QNh`cvdr$1Np6f71ECF6GB;x6Z<_pm?xvAT05`l82g0TeI2 zqL6TzN`iLsI9nVqgNW13XZ4mAw0t>tVyt{~zQgb6MU~~pu<77fQNAUG|B{AXEW9Ks zDMV+r9Xbz?NyzI{MFFR3%dyHi#|kl_V}x1U@26Pkc@M^&$vq>oZX4g?g}x9T($~S! zCaDNT92C!Nn6}q9EI{GHfkrgWjDi9cszw!H*36v*~voJ4NIYP&7@0lch+4rJ!5>F5W{}D zq3qUI>#eaq_sY#H{VokLR#bhApxx#Pc|iD0%w&VG(>Ka}1LnB7CEx*ddtIQP?0O5* z%Xu)P{#O+#N|aD=?}%%$sz-V0c-c@HHPw~`)d&M_C$AoMVGm6JWRCPF*NpKSA8$+;Q4~>g2-gLrGJkk$K*ZTny@92 z;Q7t#b$E#Ga*UHKY;O`dGL#0^Dc0!AeqxgIkn3(Hvc2&*O`Y5K|DX zs+aB!qL>UCxT~>NwDCq+bK1aAjaI145&E(@zr&R>RuU;0vWPK@LV1BcU8l0KB;O&JhW{!M1c^=xdy4hBK zSillfbc4}R&&QW2i7zXVAT+R^KW?R~fG$v3Fg&{)Km}D*m=Lfj(ET99^y2IXGGfzH z!oN;HxPD0@`Nst0=b--o$=fg2FFU{f{RD&)%Jb_4Bwg3mc@2J6VVR-7{m6)(P5{DH zti7OaQoeH~rLH31RSw!R+m2L8n9s zphaBItF=p&PND?RsQ6&etCck~f$PtWbEA7?P31G^rE|lV)wOf2so$fjTZ-t2Ji5b$ zCv3lJSBk_wiHt|5^AMC~NqCLkqg_qPZTL6`g15yiEx#%67)^QWLJfmL-)LK+)_i;(EqiMFd~SEx6aD9@@&W+_O@Sw4<9Qfr*Zl z!>ag2j%`>EwL>q|STrY;Mke-wWy_Ur=L(d9e&ErQpxKfMn|1R%6%#W$K5ss5X$NeQ zB~%Q9z?Da~RR{(z)5Bw`JEF)FH9tIhH#_H7-`|V_3{J16;Rf#5WU2Jw)AM;Zaj#c= zw=_aF`WQYF%-{FU+Loh#K{%&7mQG-Bavb%Q?P%ILf9w(%J?)-b1mnX>+_@ucgh1pU zIs~x6FKGAq3<*xYTgH>d=59n=3EWUfGf4?4ogG%$$qXMlDdwoGTF{Br>LUY47^$=o zLIX7M6GU*CoOlvMmXOHlW9cjpCOlg(Vr0d4<@*Wc*+)6aJ&5)hfn2eat?6cTG&;ne z7-+kbehWU z>0aAdAiXlb>`PswdxX9f=}d(q(Wc6-akH= zN5Fu{7ZR#f$Q2T*Rwxw)HREu}vdDbM&W%&fyDuUtu}<`a#y*geUh%4u*?H8Dqcr%g|B4PZp9@U3J#TvwO9;j{CMNo*VmmpL#;z>c7*; z6VZqD5g>bHt=_s^E!w}M&we!GeN48O?|hKePHB40LMG;Le=3lmLV;3bvf*|7y$|X_ zSTt-P^St{H9+#-Rc>=TGH0>6XbA`BpiWtvS-w7nvmLutBkB3WGM#qfgqA1kT!J`6H z{6Y7h<$Yj0Cs$KD-*+(|1~NnTPWFQ$`#V&r!ARGKoe3u5p}P8_Y*zb)p;*k81jVi* zv`&Bx*~K;qI)1ei-*MKO5DM?uu^Cc zzjg441vMkO#iPSSIL+Yb(pMrzenCV9Ji@!_W)`u7Zpp!Dk%UsQ?-@B+^IwkJc_AZw zy;kgh2v>T{YwWpTO9sR^_rnj0NOnP#c7!5GTPsskH|QVVi;d?#h^-Q~eh){$>&2*6 zC3EZ3%t7To_y}Bmo5xGRXNiXUDIFEJ(td?7F90Pm>^@}`c#w;MYOWjVg+ z-kof3fR`Xe!F0WH6=2&({Al7FL63&++)aOp&WjLtgiTjY4#nDzw|Xns`IO1IvF6Fa z+^nK>j(BgH4?NQ+`c&`bMuJ$U+eX4xXOb4u%mzxNq0Ar>aiSJ(!+e4kN?9{ug<_p) zH|_bxv?X@)X!UzF11O!9A^gkH&;UcHoQNxf9*Xs$qWO^voY0_ROD_vcx!W-CbYr>* zyP?4HzTTBXKjBNKDMWhTM}ZWs@amYas{xVUeejfA)1JQ7n^i0U77SW#!8?BTJwEZK zPYF?~N>tpAPa!9RoLY#s8<5mY-7Ht=2U)2CVkVb1%LHN<$%@l)M#u30{or&!NWGE| zXscq5cWG$*YSlbXtbh1L9+mMN4cQ!@vVt=}@j{aF!iUs-i!*}VaZ zk_@MTGzPMz=%*xP>w0zokC}d*tOVY2u^M?Bkd$)0jYPlKVw95?ih}o)?z3X76Msn_a=$^5e;&)V;l(gPz46_Q{ZilJEg{Po5v=#@<30 zM{n?~LVQy9!@eV;7sG``VNJN(!!Fe(?sF-u*~bI!_-f%~N~ zscQ4nVtdHYm-F?*)kzW5RfIr_xS-kdAM|G()`WBE?8^5D%9?WOHZU#<0Y6%4e)Vr3#`aSGHr)qLItt29y@w#w|Cs~(fumxCbo zS-VQ6ZW^`p-_&iX7U&<|&S|FVFWP9gn5G85OBpe(fi>Mss#V*TK$&@*XV{o)pJ|qC zHZ1YC?$00i&K%ZF9}1*ug?p+UoRt@sPv)?7hd2Sdk z{y1~_#$9%MRaHj83toK22jyX7S{awm{8HwNtM7IzHL6dI>F8BQ6-sxR!;6~`sW(m(b&R(LDb%*RFZywPsxLG3PqELtb#%+nqD zH`u2Pk{S;%(>4_u9z0l^T{zbOA1=Pfe<$II%Z{i)FQ=5nJymo40NDG`EL}ZrD13o> zZh@ZQw1N?0zy>9A!+0kP?$UtqERYj2t`7~tFbvDwq*PDB6$XZi)4JNT4KxJQi#4gGg+V(%1v`wG@(l7Hb7GDpuX&w`{&&z@1m$8UMdNCRx=FDuEVMx}I zy?BPWqob1xs)@SXS?=VVQ)9{e&Ey36$$YA1>9W-}y%V78v&c*8*!_`6*_Cr+z+6)j zC&X%ftDf0EM>DZ?qtdpfcu-&ac{D7GKibJ7s>40{lYXsWAbsw{>WW^A4pKIO_!8)9 z%vTrY|Gd#6IZSDU(<7`1b5vlJLhcLfUeQw3`(Lp*q# zu|98G&HJ{a`r$oZWDm*2W0U1~x0eU)l|CttH+9-ecD_A#H_yO^3@lL^pnC_dV5@x@ zBT(9Bx6vYuXBmC30gmL=uGARl;Q3t9fqP5<3E4t!|JborNB7hoU2t7HpPTw`PL8* zgWeNVzkYo#$<6`E3dcUm4z536>$!z&6*{c(*tPB$^|a|r!IvIjIkhzQxVEW5pnL{)IG48!lCNg~NXK{ z@MfDe22xbvUO9{9b_bKU4x|D!+k-`IcT`P#)wXZ5d+_<+C+elb=wL4_S+dbZ&J99Yh zw;qz@v)~Hi%JuWe2$hIw8M?oA6|UfsOXjN089D`ZATD!c8(MC@vwM+z&#_o-JfXP*3*$f>$C=z`{H^rOE(<&HJnXk9{;=#1McYbTPz_}F51%$t-4 z)FmA6w;c)I7#m(hf99l0v;Sc_);e@vsh!gI_HrbRe@&i)yy?KG^3w-KFUvcgprHnwRf2D>P)=ZmmyTQQVl7lOCYtj)>&(yoX8%yRwd59! zs6){LOJ9h)+TNzt%KR4AWZrhqhkEOZ)drc zW}(bP$AJ7FccRAUM?G-db!Panb6K8qi;M#r$NLw- zh+mSR{uzw8d%^$zB^dD^WlDj#;b~pYE>7@LOPKCyk+B_$-2nXHqtpA&Q$zjt86ChA z;*k$|V%<5Y_iaRl(+ z--HiyX8Jp4cq$(J?tkXt{rrEIkOxl)RKH8_Q*w2&v9yCZvy0ig!nf-K*(EKVoLvAv zrBG#;H~z=(f719RTK4xO!8=mGKL|?N+qtld!X^3nLmFn|26M4AHD*;Zv9WY?g|SQ6 zncACK+F7t`S=x!%Ia~hy|3B&f(u4mS^hND$%>D!7zx1yEocMo0_ZO}GU+KahwUZ^x z=|74_V=z!=4O zK^#CR2L!|o1Owq~)yy0q1`ZAeCU!BnlXkJRxBIWLl%4F&Tuot4jF##!cX-;&T`K@4 z9sr;^r?&bp&2e{vnPc8L0!)s7d;r{FFkA=bfWN~acN)3-0POw-N&zN$IzHIXJoRifsQ5 z?(Z<3zskY^<%GhG<##+N82V@VfSerMaD)8~56B7ni_AbSt~(q49gmCq?sTW$ zVca}_<-rYw`~?rn1^lyoKqxox&+>sl;JYsR8xIh?^wyvC1|R!*{&Fuj=r3*KfUP7=7rW=;0slou zTs%A+f4LXJaaShbcUd5u9Dm^p0sV`91cm!?nZGL zcosk4r$bU@mk|f(@ +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_err.h" #include "ble_gap.h" -#include "ble_l2cap.h" #include "ble_gatt.h" #include "ble_gattc.h" #include "ble_gatts.h" @@ -71,7 +72,7 @@ enum BLE_COMMON_SVCS { SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */ SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */ - SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */ + SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific base UUID. */ SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */ SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */ SD_BLE_VERSION_GET, /**< Get the local version information (company ID, Link Layer Version, Link Layer Subversion). */ @@ -79,6 +80,7 @@ enum BLE_COMMON_SVCS SD_BLE_OPT_SET, /**< Set a BLE option. */ SD_BLE_OPT_GET, /**< Get a BLE option. */ SD_BLE_CFG_SET, /**< Add a configuration to the BLE stack. */ + SD_BLE_UUID_VS_REMOVE, /**< Remove a Vendor Specific base UUID. */ }; /** @@ -86,8 +88,8 @@ enum BLE_COMMON_SVCS */ enum BLE_COMMON_EVTS { - BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE, /**< User Memory request. @ref ble_evt_user_mem_request_t */ - BLE_EVT_USER_MEM_RELEASE, /**< User Memory release. @ref ble_evt_user_mem_release_t */ + BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE + 0, /**< User Memory request. @ref ble_evt_user_mem_request_t */ + BLE_EVT_USER_MEM_RELEASE = BLE_EVT_BASE + 1, /**< User Memory release. @ref ble_evt_user_mem_release_t */ }; /**@brief BLE Connection Configuration IDs. @@ -96,11 +98,10 @@ enum BLE_COMMON_EVTS */ enum BLE_CONN_CFGS { - BLE_CONN_CFG_GAP = BLE_CONN_CFG_BASE, /**< BLE GAP specific connection configuration. */ - BLE_CONN_CFG_GATTC, /**< BLE GATTC specific connection configuration. */ - BLE_CONN_CFG_GATTS, /**< BLE GATTS specific connection configuration. */ - BLE_CONN_CFG_GATT, /**< BLE GATT specific connection configuration. */ - BLE_CONN_CFG_L2CAP, /**< BLE L2CAP specific connection configuration. */ + BLE_CONN_CFG_GAP = BLE_CONN_CFG_BASE + 0, /**< BLE GAP specific connection configuration. */ + BLE_CONN_CFG_GATTC = BLE_CONN_CFG_BASE + 1, /**< BLE GATTC specific connection configuration. */ + BLE_CONN_CFG_GATTS = BLE_CONN_CFG_BASE + 2, /**< BLE GATTS specific connection configuration. */ + BLE_CONN_CFG_GATT = BLE_CONN_CFG_BASE + 3, /**< BLE GATT specific connection configuration. */ }; /**@brief BLE Common Configuration IDs. @@ -109,7 +110,7 @@ enum BLE_CONN_CFGS */ enum BLE_COMMON_CFGS { - BLE_COMMON_CFG_VS_UUID = BLE_CFG_BASE, /**< Vendor specific UUID configuration */ + BLE_COMMON_CFG_VS_UUID = BLE_CFG_BASE, /**< Vendor specific base UUID configuration */ }; /**@brief Common Option IDs. @@ -117,8 +118,9 @@ enum BLE_COMMON_CFGS */ enum BLE_COMMON_OPTS { - BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE, /**< PA and LNA options */ - BLE_COMMON_OPT_CONN_EVT_EXT, /**< Extended connection events option */ + BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE + 0, /**< PA and LNA options */ + BLE_COMMON_OPT_CONN_EVT_EXT = BLE_OPT_BASE + 1, /**< Extended connection events option */ + BLE_COMMON_OPT_EXTENDED_RC_CAL = BLE_OPT_BASE + 2, /**< Extended RC calibration option */ }; /** @} */ @@ -138,13 +140,9 @@ enum BLE_COMMON_OPTS * @note The highest value used for @ref ble_gatt_conn_cfg_t::att_mtu in any connection configuration shall be used as a parameter. * If that value has not been configured for any connections then @ref BLE_GATT_ATT_MTU_DEFAULT must be used instead. */ -#define BLE_EVT_LEN_MAX(ATT_MTU) (BLE_MAX( \ - sizeof(ble_evt_t), \ - BLE_MAX( \ - offsetof(ble_evt_t, evt.gattc_evt.params.rel_disc_rsp.includes) + ((ATT_MTU) - 2) / 6 * sizeof(ble_gattc_include_t), \ - offsetof(ble_evt_t, evt.gattc_evt.params.attr_info_disc_rsp.info.attr_info16) + ((ATT_MTU) - 2) / 4 * sizeof(ble_gattc_attr_info16_t) \ - ) \ -)) +#define BLE_EVT_LEN_MAX(ATT_MTU) ( \ + offsetof(ble_evt_t, evt.gattc_evt.params.prim_srvc_disc_rsp.services) + ((ATT_MTU) - 1) / 4 * sizeof(ble_gattc_service_t) \ +) /** @defgroup BLE_USER_MEM_TYPES User Memory Types * @{ */ @@ -152,7 +150,7 @@ enum BLE_COMMON_OPTS #define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */ /** @} */ -/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific UUID counts +/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific base UUID counts * @{ */ #define BLE_UUID_VS_COUNT_DEFAULT 10 /**< Default VS UUID count. */ @@ -219,7 +217,6 @@ typedef struct ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */ ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */ ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */ - ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */ } evt; /**< Event union. */ } ble_evt_t; @@ -283,11 +280,32 @@ typedef struct uint8_t enable : 1; /**< Enable extended BLE connection events, disabled by default. */ } ble_common_opt_conn_evt_ext_t; +/** + * @brief Enable/disable extended RC calibration. + * + * If extended RC calibration is enabled and the internal RC oscillator (@ref NRF_CLOCK_LF_SRC_RC) is used as the SoftDevice + * LFCLK source, the SoftDevice as a peripheral will by default try to increase the receive window if two consecutive packets + * are not received. If it turns out that the packets were not received due to clock drift, the RC calibration is started. + * This calibration comes in addition to the periodic calibration that is configured by @ref sd_softdevice_enable(). When + * using only peripheral connections, the periodic calibration can therefore be configured with a much longer interval as the + * peripheral will be able to detect and adjust automatically to clock drift, and calibrate on demand. + * + * If extended RC calibration is disabled and the internal RC oscillator is used as the SoftDevice LFCLK source, the + * RC oscillator is calibrated periodically as configured by @ref sd_softdevice_enable(). + * + * @note @ref sd_ble_opt_get is not supported for this option. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable extended RC calibration, enabled by default. */ +} ble_common_opt_extended_rc_cal_t; + /**@brief Option structure for common options. */ typedef union { - ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */ - ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */ + ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */ + ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */ + ble_common_opt_extended_rc_cal_t extended_rc_cal; /**< Parameters for enabling extended RC calibration. */ } ble_common_opt_t; /**@brief Common BLE Option type, wrapping the module specific options. */ @@ -304,7 +322,9 @@ typedef union * In the case that no configurations has been set, or fewer connection configurations has been set than enabled connections, * the default connection configuration will be automatically added for the remaining connections. * When creating connections with the default configuration, @ref BLE_CONN_CFG_TAG_DEFAULT should be used in - * place of @ref ble_conn_cfg_t::conn_cfg_tag. See @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect()" + * place of @ref ble_conn_cfg_t::conn_cfg_tag. + * + * @sa sd_ble_gap_adv_start() * * @mscs * @mmsc{@ref BLE_CONN_CFG} @@ -313,26 +333,26 @@ typedef union */ typedef struct { - uint8_t conn_cfg_tag; /**< The application chosen tag it can use with the @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect() - calls to select this configuration when creating a connection. + uint8_t conn_cfg_tag; /**< The application chosen tag it can use with the + @ref sd_ble_gap_adv_start() call + to select this configuration when creating a connection. Must be different for all connection configurations added and not @ref BLE_CONN_CFG_TAG_DEFAULT. */ union { ble_gap_conn_cfg_t gap_conn_cfg; /**< GAP connection configuration, cfg_id is @ref BLE_CONN_CFG_GAP. */ ble_gattc_conn_cfg_t gattc_conn_cfg; /**< GATTC connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTC. */ ble_gatts_conn_cfg_t gatts_conn_cfg; /**< GATTS connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTS. */ ble_gatt_conn_cfg_t gatt_conn_cfg; /**< GATT connection configuration, cfg_id is @ref BLE_CONN_CFG_GATT. */ - ble_l2cap_conn_cfg_t l2cap_conn_cfg; /**< L2CAP connection configuration, cfg_id is @ref BLE_CONN_CFG_L2CAP. */ } params; /**< Connection configuration union. */ } ble_conn_cfg_t; /** - * @brief Configuration of Vendor Specific UUIDs, set with @ref sd_ble_cfg_set. + * @brief Configuration of Vendor Specific base UUIDs, set with @ref sd_ble_cfg_set. * * @retval ::NRF_ERROR_INVALID_PARAM Too many UUIDs configured. */ typedef struct { - uint8_t vs_uuid_count; /**< Number of 128-bit Vendor Specific UUID bases to allocate memory for. + uint8_t vs_uuid_count; /**< Number of 128-bit Vendor Specific base UUID bases to allocate memory for. Default value is @ref BLE_UUID_VS_COUNT_DEFAULT. Maximum value is @ref BLE_UUID_VS_COUNT_MAX. */ } ble_common_cfg_vs_uuid_t; @@ -340,7 +360,7 @@ typedef struct /**@brief Common BLE Configuration type, wrapping the common configurations. */ typedef union { - ble_common_cfg_vs_uuid_t vs_uuid_cfg; /**< Vendor specific UUID configuration, cfg_id is @ref BLE_COMMON_CFG_VS_UUID. */ + ble_common_cfg_vs_uuid_t vs_uuid_cfg; /**< Vendor Specific base UUID configuration, cfg_id is @ref BLE_COMMON_CFG_VS_UUID. */ } ble_common_cfg_t; /**@brief BLE Configuration type, wrapping the module specific configurations. */ @@ -367,10 +387,6 @@ typedef union * @note The memory requirement for a specific configuration will not increase between SoftDevices * with the same major version number. * - * @note The value of *p_app_ram_base when the app has done no custom configuration of the - * SoftDevice, i.e. the app has not called @ref sd_ble_cfg_set before @ref sd_ble_enable, can - * be found in the release notes. - * * @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located * between 0x20000000 and APP_RAM_BASE-1 and the application's RAM region is located between * APP_RAM_BASE and the start of the call stack. @@ -385,9 +401,13 @@ typedef union * @retval ::NRF_SUCCESS The BLE stack has been initialized successfully. * @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. - * @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by *p_app_ram_base is not - * large enough to fit this configuration's memory requirement. Check *p_app_ram_base - * and set the start address of the application RAM region accordingly. + * @retval ::NRF_ERROR_NO_MEM One or more of the following is true: + * - The amount of memory assigned to the SoftDevice by *p_app_ram_base is not + * large enough to fit this configuration's memory requirement. Check *p_app_ram_base + * and set the start address of the application RAM region accordingly. + * - Dynamic part of the SoftDevice RAM region is larger then 64 kB which + * is currently not supported. + * @retval ::NRF_ERROR_RESOURCES The total number of L2CAP Channels configured using @ref sd_ble_cfg_set is too large. */ SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(uint32_t * p_app_ram_base)); @@ -468,7 +488,7 @@ SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len /**@brief Add a Vendor Specific base UUID. * - * @details This call enables the application to add a vendor specific base UUID to the BLE stack's table, for later + * @details This call enables the application to add a Vendor Specific base UUID to the BLE stack's table, for later * use with all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t * format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code * paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses @@ -482,23 +502,44 @@ SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len * the 16-bit uuid field in @ref ble_uuid_t. * * @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in - * p_uuid_type along with an NRF_SUCCESS error code. + * p_uuid_type along with an @ref NRF_SUCCESS error code. * - * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding + * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific base UUID disregarding * bytes 12 and 13. * @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored. * - * @retval ::NRF_SUCCESS Successfully added the Vendor Specific UUID. + * @retval ::NRF_SUCCESS Successfully added the Vendor Specific base UUID. * @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid. * @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs. */ SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type)); +/**@brief Remove a Vendor Specific base UUID. + * + * @details This call removes a Vendor Specific base UUID that has been added with @ref sd_ble_uuid_vs_add. This function allows + * the application to reuse memory allocated for Vendor Specific base UUIDs. + * + * @note Currently this function can only be called with a p_uuid_type set to @ref BLE_UUID_TYPE_UNKNOWN or the last added UUID type. + * + * @param[inout] p_uuid_type Pointer to a uint8_t where its value matches the UUID type in @ref ble_uuid_t::type to be removed. + * If the type is set to @ref BLE_UUID_TYPE_UNKNOWN, or the pointer is NULL, the last Vendor Specific + * base UUID will be removed. If the function returns successfully, the UUID type that was removed will + * be written back to @p p_uuid_type. If function returns with a failure, it contains the last type that + * is in use by the ATT Server. + * + * @retval ::NRF_SUCCESS Successfully removed the Vendor Specific base UUID. + * @retval ::NRF_ERROR_INVALID_ADDR If p_uuid_type is invalid. + * @retval ::NRF_ERROR_INVALID_PARAM If p_uuid_type points to a non-valid UUID type. + * @retval ::NRF_ERROR_FORBIDDEN If the Vendor Specific base UUID is in use by the ATT Server. + */ +SVCALL(SD_BLE_UUID_VS_REMOVE, uint32_t, sd_ble_uuid_vs_remove(uint8_t *p_uuid_type)); + + /** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure. * * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared - * to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add + * to the corresponding ones in each entry of the table of Vendor Specific base UUIDs populated with @ref sd_ble_uuid_vs_add * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type. * @@ -573,10 +614,6 @@ SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_hand * * @details This call allows the application to set the value of an option. * - * @mscs - * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC} - * @endmscs - * * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS. * @param[in] p_opt Pointer to a ble_opt_t structure containing the option value. * diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_err.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_err.h similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_err.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_err.h index 1b0b9d4..1b4820d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_err.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_err.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2012 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -65,7 +65,9 @@ extern "C" { #define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */ #define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */ #define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */ -#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid role. */ +#define BLE_ERROR_INVALID_ADV_HANDLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid advertising handle. */ +#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */ +#define BLE_ERROR_BLOCKED_BY_OTHER_LINKS (NRF_ERROR_STK_BASE_NUM+0x006) /**< The attempt to change link settings failed due to the scheduling of other links. */ /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gap.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gap.h similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gap.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gap.h index 13f7721..13985fc 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gap.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2019, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,10 +45,13 @@ #ifndef BLE_GAP_H__ #define BLE_GAP_H__ - -#include "ble_types.h" -#include "ble_ranges.h" +#include #include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" #ifdef __cplusplus extern "C" { @@ -61,43 +64,39 @@ extern "C" { */ enum BLE_GAP_SVCS { - SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */ - SD_BLE_GAP_ADDR_GET, /**< Get own Bluetooth Address. */ - SD_BLE_GAP_WHITELIST_SET, /**< Set active whitelist. */ - SD_BLE_GAP_DEVICE_IDENTITIES_SET, /**< Set device identity list. */ - SD_BLE_GAP_PRIVACY_SET, /**< Set Privacy settings*/ - SD_BLE_GAP_PRIVACY_GET, /**< Get Privacy settings*/ - SD_BLE_GAP_ADV_DATA_SET, /**< Set Advertising Data. */ - SD_BLE_GAP_ADV_START, /**< Start Advertising. */ - SD_BLE_GAP_ADV_STOP, /**< Stop Advertising. */ - SD_BLE_GAP_CONN_PARAM_UPDATE, /**< Connection Parameter Update. */ - SD_BLE_GAP_DISCONNECT, /**< Disconnect. */ - SD_BLE_GAP_TX_POWER_SET, /**< Set TX Power. */ - SD_BLE_GAP_APPEARANCE_SET, /**< Set Appearance. */ - SD_BLE_GAP_APPEARANCE_GET, /**< Get Appearance. */ - SD_BLE_GAP_PPCP_SET, /**< Set PPCP. */ - SD_BLE_GAP_PPCP_GET, /**< Get PPCP. */ - SD_BLE_GAP_DEVICE_NAME_SET, /**< Set Device Name. */ - SD_BLE_GAP_DEVICE_NAME_GET, /**< Get Device Name. */ - SD_BLE_GAP_AUTHENTICATE, /**< Initiate Pairing/Bonding. */ - SD_BLE_GAP_SEC_PARAMS_REPLY, /**< Reply with Security Parameters. */ - SD_BLE_GAP_AUTH_KEY_REPLY, /**< Reply with an authentication key. */ - SD_BLE_GAP_LESC_DHKEY_REPLY, /**< Reply with an LE Secure Connections DHKey. */ - SD_BLE_GAP_KEYPRESS_NOTIFY, /**< Notify of a keypress during an authentication procedure. */ - SD_BLE_GAP_LESC_OOB_DATA_GET, /**< Get the local LE Secure Connections OOB data. */ - SD_BLE_GAP_LESC_OOB_DATA_SET, /**< Set the remote LE Secure Connections OOB data. */ - SD_BLE_GAP_ENCRYPT, /**< Initiate encryption procedure. */ - SD_BLE_GAP_SEC_INFO_REPLY, /**< Reply with Security Information. */ - SD_BLE_GAP_CONN_SEC_GET, /**< Obtain connection security level. */ - SD_BLE_GAP_RSSI_START, /**< Start reporting of changes in RSSI. */ - SD_BLE_GAP_RSSI_STOP, /**< Stop reporting of changes in RSSI. */ - SD_BLE_GAP_SCAN_START, /**< Start Scanning. */ - SD_BLE_GAP_SCAN_STOP, /**< Stop Scanning. */ - SD_BLE_GAP_CONNECT, /**< Connect. */ - SD_BLE_GAP_CONNECT_CANCEL, /**< Cancel ongoing connection procedure. */ - SD_BLE_GAP_RSSI_GET, /**< Get the last RSSI sample. */ - SD_BLE_GAP_PHY_UPDATE, /**< Initiate or respond to a PHY Update Procedure. */ - SD_BLE_GAP_DATA_LENGTH_UPDATE, /**< Initiate or respond to a Data Length Update Procedure. */ + SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */ + SD_BLE_GAP_ADDR_GET = BLE_GAP_SVC_BASE + 1, /**< Get own Bluetooth Address. */ + SD_BLE_GAP_WHITELIST_SET = BLE_GAP_SVC_BASE + 2, /**< Set active whitelist. */ + SD_BLE_GAP_DEVICE_IDENTITIES_SET = BLE_GAP_SVC_BASE + 3, /**< Set device identity list. */ + SD_BLE_GAP_PRIVACY_SET = BLE_GAP_SVC_BASE + 4, /**< Set Privacy settings*/ + SD_BLE_GAP_PRIVACY_GET = BLE_GAP_SVC_BASE + 5, /**< Get Privacy settings*/ + SD_BLE_GAP_ADV_SET_CONFIGURE = BLE_GAP_SVC_BASE + 6, /**< Configure an advertising set. */ + SD_BLE_GAP_ADV_START = BLE_GAP_SVC_BASE + 7, /**< Start Advertising. */ + SD_BLE_GAP_ADV_STOP = BLE_GAP_SVC_BASE + 8, /**< Stop Advertising. */ + SD_BLE_GAP_CONN_PARAM_UPDATE = BLE_GAP_SVC_BASE + 9, /**< Connection Parameter Update. */ + SD_BLE_GAP_DISCONNECT = BLE_GAP_SVC_BASE + 10, /**< Disconnect. */ + SD_BLE_GAP_TX_POWER_SET = BLE_GAP_SVC_BASE + 11, /**< Set TX Power. */ + SD_BLE_GAP_APPEARANCE_SET = BLE_GAP_SVC_BASE + 12, /**< Set Appearance. */ + SD_BLE_GAP_APPEARANCE_GET = BLE_GAP_SVC_BASE + 13, /**< Get Appearance. */ + SD_BLE_GAP_PPCP_SET = BLE_GAP_SVC_BASE + 14, /**< Set PPCP. */ + SD_BLE_GAP_PPCP_GET = BLE_GAP_SVC_BASE + 15, /**< Get PPCP. */ + SD_BLE_GAP_DEVICE_NAME_SET = BLE_GAP_SVC_BASE + 16, /**< Set Device Name. */ + SD_BLE_GAP_DEVICE_NAME_GET = BLE_GAP_SVC_BASE + 17, /**< Get Device Name. */ + SD_BLE_GAP_AUTHENTICATE = BLE_GAP_SVC_BASE + 18, /**< Initiate Pairing/Bonding. */ + SD_BLE_GAP_SEC_PARAMS_REPLY = BLE_GAP_SVC_BASE + 19, /**< Reply with Security Parameters. */ + SD_BLE_GAP_AUTH_KEY_REPLY = BLE_GAP_SVC_BASE + 20, /**< Reply with an authentication key. */ + SD_BLE_GAP_LESC_DHKEY_REPLY = BLE_GAP_SVC_BASE + 21, /**< Reply with an LE Secure Connections DHKey. */ + SD_BLE_GAP_KEYPRESS_NOTIFY = BLE_GAP_SVC_BASE + 22, /**< Notify of a keypress during an authentication procedure. */ + SD_BLE_GAP_LESC_OOB_DATA_GET = BLE_GAP_SVC_BASE + 23, /**< Get the local LE Secure Connections OOB data. */ + SD_BLE_GAP_LESC_OOB_DATA_SET = BLE_GAP_SVC_BASE + 24, /**< Set the remote LE Secure Connections OOB data. */ + SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */ + SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */ + SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */ + SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */ + SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */ + SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */ + SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */ + SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET = BLE_GAP_SVC_BASE + 40, /**< Get the next connection event counter. */ }; /**@brief GAP Event IDs. @@ -105,27 +104,24 @@ enum BLE_GAP_SVCS */ enum BLE_GAP_EVTS { - BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connection established. \n See @ref ble_gap_evt_connected_t. */ - BLE_GAP_EVT_DISCONNECTED, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */ - BLE_GAP_EVT_CONN_PARAM_UPDATE, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */ - BLE_GAP_EVT_SEC_PARAMS_REQUEST, /**< Request to provide security parameters. \n Reply with @ref sd_ble_gap_sec_params_reply. \n See @ref ble_gap_evt_sec_params_request_t. */ - BLE_GAP_EVT_SEC_INFO_REQUEST, /**< Request to provide security information. \n Reply with @ref sd_ble_gap_sec_info_reply. \n See @ref ble_gap_evt_sec_info_request_t. */ - BLE_GAP_EVT_PASSKEY_DISPLAY, /**< Request to display a passkey to the user. \n In LESC Numeric Comparison, reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_passkey_display_t. */ - BLE_GAP_EVT_KEY_PRESSED, /**< Notification of a keypress on the remote device.\n See @ref ble_gap_evt_key_pressed_t */ - BLE_GAP_EVT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key. \n Reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_auth_key_request_t. */ - BLE_GAP_EVT_LESC_DHKEY_REQUEST, /**< Request to calculate an LE Secure Connections DHKey. \n Reply with @ref sd_ble_gap_lesc_dhkey_reply. \n See @ref ble_gap_evt_lesc_dhkey_request_t */ - BLE_GAP_EVT_AUTH_STATUS, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */ - BLE_GAP_EVT_CONN_SEC_UPDATE, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */ - BLE_GAP_EVT_TIMEOUT, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */ - BLE_GAP_EVT_RSSI_CHANGED, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */ - BLE_GAP_EVT_ADV_REPORT, /**< Advertising report. \n See @ref ble_gap_evt_adv_report_t. */ - BLE_GAP_EVT_SEC_REQUEST, /**< Security Request. \n See @ref ble_gap_evt_sec_request_t. */ - BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, /**< Connection Parameter Update Request. \n Reply with @ref sd_ble_gap_conn_param_update. \n See @ref ble_gap_evt_conn_param_update_request_t. */ - BLE_GAP_EVT_SCAN_REQ_REPORT, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */ - BLE_GAP_EVT_PHY_UPDATE_REQUEST, /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */ - BLE_GAP_EVT_PHY_UPDATE, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */ - BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST, /**< Data Length Update Request. \n Reply with @ref sd_ble_gap_data_length_update.\n See @ref ble_gap_evt_data_length_update_request_t. */ - BLE_GAP_EVT_DATA_LENGTH_UPDATE, /**< LL Data Channel PDU payload length updated. \n See @ref ble_gap_evt_data_length_update_t. */ + BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connected to peer. \n See @ref ble_gap_evt_connected_t */ + BLE_GAP_EVT_DISCONNECTED = BLE_GAP_EVT_BASE + 1, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */ + BLE_GAP_EVT_CONN_PARAM_UPDATE = BLE_GAP_EVT_BASE + 2, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */ + BLE_GAP_EVT_SEC_PARAMS_REQUEST = BLE_GAP_EVT_BASE + 3, /**< Request to provide security parameters. \n Reply with @ref sd_ble_gap_sec_params_reply. \n See @ref ble_gap_evt_sec_params_request_t. */ + BLE_GAP_EVT_SEC_INFO_REQUEST = BLE_GAP_EVT_BASE + 4, /**< Request to provide security information. \n Reply with @ref sd_ble_gap_sec_info_reply. \n See @ref ble_gap_evt_sec_info_request_t. */ + BLE_GAP_EVT_PASSKEY_DISPLAY = BLE_GAP_EVT_BASE + 5, /**< Request to display a passkey to the user. \n In LESC Numeric Comparison, reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_passkey_display_t. */ + BLE_GAP_EVT_KEY_PRESSED = BLE_GAP_EVT_BASE + 6, /**< Notification of a keypress on the remote device.\n See @ref ble_gap_evt_key_pressed_t */ + BLE_GAP_EVT_AUTH_KEY_REQUEST = BLE_GAP_EVT_BASE + 7, /**< Request to provide an authentication key. \n Reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_auth_key_request_t. */ + BLE_GAP_EVT_LESC_DHKEY_REQUEST = BLE_GAP_EVT_BASE + 8, /**< Request to calculate an LE Secure Connections DHKey. \n Reply with @ref sd_ble_gap_lesc_dhkey_reply. \n See @ref ble_gap_evt_lesc_dhkey_request_t */ + BLE_GAP_EVT_AUTH_STATUS = BLE_GAP_EVT_BASE + 9, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */ + BLE_GAP_EVT_CONN_SEC_UPDATE = BLE_GAP_EVT_BASE + 10, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */ + BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */ + BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */ + BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n See @ref ble_gap_evt_sec_request_t. */ + BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */ + BLE_GAP_EVT_PHY_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 17, /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */ + BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */ + BLE_GAP_EVT_ADV_SET_TERMINATED = BLE_GAP_EVT_BASE + 22, /**< Advertising set terminated. \n See @ref ble_gap_evt_adv_set_terminated_t. */ }; /**@brief GAP Option IDs. @@ -133,13 +129,11 @@ enum BLE_GAP_EVTS */ enum BLE_GAP_OPTS { - BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */ - BLE_GAP_OPT_LOCAL_CONN_LATENCY, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */ - BLE_GAP_OPT_PASSKEY, /**< Set passkey. @ref ble_gap_opt_passkey_t */ - BLE_GAP_OPT_SCAN_REQ_REPORT, /**< Scan request report. @ref ble_gap_opt_scan_req_report_t */ - BLE_GAP_OPT_COMPAT_MODE_1, /**< Compatibility mode. @ref ble_gap_opt_compat_mode_1_t */ - BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT, /**< Set Authenticated payload timeout. @ref ble_gap_opt_auth_payload_timeout_t */ - BLE_GAP_OPT_SLAVE_LATENCY_DISABLE, /**< Disable slave latency. @ref ble_gap_opt_slave_latency_disable_t */ + BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */ + BLE_GAP_OPT_LOCAL_CONN_LATENCY = BLE_GAP_OPT_BASE + 1, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */ + BLE_GAP_OPT_PASSKEY = BLE_GAP_OPT_BASE + 2, /**< Set passkey. @ref ble_gap_opt_passkey_t */ + BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT = BLE_GAP_OPT_BASE + 4, /**< Set Authenticated payload timeout. @ref ble_gap_opt_auth_payload_timeout_t */ + BLE_GAP_OPT_SLAVE_LATENCY_DISABLE = BLE_GAP_OPT_BASE + 5, /**< Disable slave latency. @ref ble_gap_opt_slave_latency_disable_t */ }; /**@brief GAP Configuration IDs. @@ -148,8 +142,20 @@ enum BLE_GAP_OPTS */ enum BLE_GAP_CFGS { - BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */ - BLE_GAP_CFG_DEVICE_NAME, /**< Device name configuration. */ + BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */ + BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */ + BLE_GAP_CFG_PPCP_INCL_CONFIG = BLE_GAP_CFG_BASE + 2, /**< Peripheral Preferred Connection Parameters characteristic + inclusion configuration. */ + BLE_GAP_CFG_CAR_INCL_CONFIG = BLE_GAP_CFG_BASE + 3, /**< Central Address Resolution characteristic + inclusion configuration. */ +}; + +/**@brief GAP TX Power roles. + */ +enum BLE_GAP_TX_POWER_ROLES +{ + BLE_GAP_TX_POWER_ROLE_ADV = 1, /**< Advertiser role. */ + BLE_GAP_TX_POWER_ROLE_CONN = 3, /**< Connection role. */ }; /** @} */ @@ -169,18 +175,14 @@ enum BLE_GAP_CFGS /**@defgroup BLE_GAP_ROLES GAP Roles - * @note Not explicitly used in peripheral API, but will be relevant for central API. * @{ */ #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */ #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */ -#define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */ /**@} */ /**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources * @{ */ -#define BLE_GAP_TIMEOUT_SRC_ADVERTISING 0x00 /**< Advertising timeout. */ -#define BLE_GAP_TIMEOUT_SRC_SCAN 0x01 /**< Scanning timeout. */ #define BLE_GAP_TIMEOUT_SRC_CONN 0x02 /**< Connection timeout. */ #define BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD 0x03 /**< Authenticated payload timeout. */ /**@} */ @@ -188,8 +190,8 @@ enum BLE_GAP_CFGS /**@defgroup BLE_GAP_ADDR_TYPES GAP Address types * @{ */ -#define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */ -#define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random static address. */ +#define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public (identity) address.*/ +#define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random static (identity) address. */ #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Random private resolvable address. */ #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Random private non-resolvable address. */ /**@} */ @@ -204,7 +206,6 @@ enum BLE_GAP_CFGS /** @brief BLE address length. */ #define BLE_GAP_ADDR_LEN (6) - /**@defgroup BLE_GAP_PRIVACY_MODES Privacy modes * @{ */ #define BLE_GAP_PRIVACY_MODE_OFF 0x00 /**< Device will send and accept its identity address for its own address. */ @@ -214,6 +215,32 @@ enum BLE_GAP_CFGS the peer IRK is exchanged, non-zero and added to the identity list. */ /**@} */ +/** @brief Invalid power level. */ +#define BLE_GAP_POWER_LEVEL_INVALID 127 + +/** @brief Advertising set handle not set. */ +#define BLE_GAP_ADV_SET_HANDLE_NOT_SET (0xFF) + +/** @brief The default number of advertising sets. */ +#define BLE_GAP_ADV_SET_COUNT_DEFAULT (1) + +/** @brief The maximum number of advertising sets supported by this SoftDevice. */ +#define BLE_GAP_ADV_SET_COUNT_MAX (1) + +/**@defgroup BLE_GAP_ADV_SET_DATA_SIZES Advertising data sizes. + * @{ */ +#define BLE_GAP_ADV_SET_DATA_SIZE_MAX (31) /**< Maximum data length for an advertising set. + If more advertising data is required, use extended advertising instead. */ +/**@}. */ + +/** @brief Set ID not available in advertising report. */ +#define BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE 0xFF + +/**@defgroup BLE_GAP_EVT_ADV_SET_TERMINATED_REASON GAP Advertising Set Terminated reasons + * @{ */ +#define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT 0x01 /**< Timeout value reached. */ +#define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_LIMIT_REACHED 0x02 /**< @ref ble_gap_adv_params_t::max_adv_evts was reached. */ +/**@} */ /**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm @@ -269,45 +296,37 @@ enum BLE_GAP_CFGS /**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min * @{ */ -#define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ -#define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ +#define BLE_GAP_ADV_INTERVAL_MIN 0x000020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ +#define BLE_GAP_ADV_INTERVAL_MAX 0x004000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ /**@} */ -/**@defgroup BLE_GAP_SCAN_INTERVALS GAP Scan interval max and min - * @{ */ -#define BLE_GAP_SCAN_INTERVAL_MIN 0x0004 /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */ -#define BLE_GAP_SCAN_INTERVAL_MAX 0x4000 /**< Maximum Scan interval in 625 us units, i.e. 10.24 s. */ - /** @} */ - - -/**@defgroup BLE_GAP_SCAN_WINDOW GAP Scan window max and min - * @{ */ -#define BLE_GAP_SCAN_WINDOW_MIN 0x0004 /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */ -#define BLE_GAP_SCAN_WINDOW_MAX 0x4000 /**< Maximum Scan window in 625 us units, i.e. 10.24 s. */ - /** @} */ - - -/**@defgroup BLE_GAP_SCAN_TIMEOUT GAP Scan timeout max and min - * @{ */ -#define BLE_GAP_SCAN_TIMEOUT_MIN 0x0001 /**< Minimum Scan timeout in seconds. */ -#define BLE_GAP_SCAN_TIMEOUT_MAX 0xFFFF /**< Maximum Scan timeout in seconds. */ - /** @} */ - - -/**@brief Maximum size of advertising data in octets. */ -#define BLE_GAP_ADV_MAX_SIZE (31) - /**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types + * + * Advertising types defined in Bluetooth Core Specification v5.0, Vol 6, Part B, Section 4.4.2. + * + * The maximum advertising data length is defined by @ref BLE_GAP_ADV_SET_DATA_SIZE_MAX. + * Note that some of the advertising types do not support advertising data. Non-scannable types do not support + * scan response data. + * + * @note Extended advertising is not supported in this SoftDevice. * @{ */ -#define BLE_GAP_ADV_TYPE_ADV_IND 0x00 /**< Connectable undirected. */ -#define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND 0x01 /**< Connectable directed. */ -#define BLE_GAP_ADV_TYPE_ADV_SCAN_IND 0x02 /**< Scannable undirected. */ -#define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND 0x03 /**< Non connectable undirected. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED 0x01 /**< Connectable and scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE 0x02 /**< Connectable non-scannable directed advertising + events. Advertising interval is less that 3.75 ms. + Use this type for fast reconnections. + @note Advertising data is not supported. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED 0x03 /**< Connectable non-scannable directed advertising + events. + @note Advertising data is not supported. */ +#define BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x04 /**< Non-connectable scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x05 /**< Non-connectable non-scannable undirected + advertising events. */ /**@} */ - /**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies * @{ */ #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */ @@ -317,10 +336,12 @@ enum BLE_GAP_CFGS /**@} */ -/**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values +/**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values in 10 ms units * @{ */ -#define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX (180) /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180 s). */ -#define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) /**< Unlimited advertising in general discoverable mode. */ +#define BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX (128) /**< Maximum high duty advertising time in 10 ms units. Corresponds to 1.28 s. */ +#define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX (18000) /**< Maximum advertising time in 10 ms units corresponding to TGAP(lim_adv_timeout) = 180 s in limited discoverable mode. */ +#define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) /**< Unlimited advertising in general discoverable mode. + For high duty cycle advertising, this corresponds to @ref BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX. */ /**@} */ @@ -425,6 +446,10 @@ enum BLE_GAP_CFGS #define BLE_GAP_PHY_1MBPS 0x01 /**< 1 Mbps PHY. */ #define BLE_GAP_PHY_2MBPS 0x02 /**< 2 Mbps PHY. */ #define BLE_GAP_PHY_CODED 0x04 /**< Coded PHY. */ +#define BLE_GAP_PHY_NOT_SET 0xFF /**< PHY is not configured. */ + +/**@brief Supported PHYs in connections and for advertising. */ +#define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS) /**< All PHYs except @ref BLE_GAP_PHY_CODED are supported. */ /**@} */ @@ -483,22 +508,18 @@ enum BLE_GAP_CFGS /**@defgroup BLE_GAP_EVENT_LENGTH GAP event length defines. * @{ */ -#define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */ -#define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */ +#define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */ +#define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */ /**@} */ /**@defgroup BLE_GAP_ROLE_COUNT GAP concurrent connection count defines. * @{ */ #define BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT (1) /**< Default maximum number of connections concurrently acting as peripherals. */ -#define BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT (3) /**< Default maximum number of connections concurrently acting as centrals. */ -#define BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT (1) /**< Default number of SMP instances shared between all connections acting as centrals. */ -#define BLE_GAP_ROLE_COUNT_COMBINED_MAX (20) /**< Maximum supported number of concurrent connections in the peripheral and central roles combined. */ -/**@} */ +#define BLE_GAP_ROLE_COUNT_COMBINED_MAX (20) /**< Maximum supported number of concurrent connections in the peripheral roles. */ +/**@} */ -/**@brief Automatic data length parameter. */ -#define BLE_GAP_DATA_LENGTH_AUTO 0 /**@defgroup BLE_GAP_AUTH_PAYLOAD_TIMEOUT Authenticated payload timeout defines. * @{ */ @@ -510,17 +531,53 @@ enum BLE_GAP_CFGS * @{ */ #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */ /**@} */ + /** @} */ +/** @defgroup BLE_GAP_CHAR_INCL_CONFIG GAP Characteristic inclusion configurations + * @{ + */ +#define BLE_GAP_CHAR_INCL_CONFIG_INCLUDE (0) /**< Include the characteristic in the Attribute Table */ +#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITH_SPACE (1) /**< Do not include the characteristic in the Attribute table. + The SoftDevice will reserve the attribute handles + which are otherwise used for this characteristic. + By reserving the attribute handles it will be possible + to upgrade the SoftDevice without changing handle of the + Service Changed characteristic. */ +#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE (2) /**< Do not include the characteristic in the Attribute table. + The SoftDevice will not reserve the attribute handles + which are otherwise used for this characteristic. */ +/**@} */ + + +/** @defgroup BLE_GAP_CHAR_INCL_CONFIG_DEFAULTS Characteristic inclusion default values + * @{ */ +#define BLE_GAP_PPCP_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */ +#define BLE_GAP_CAR_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */ +/**@} */ /**@addtogroup BLE_GAP_STRUCTURES Structures * @{ */ +/**@brief Advertising event properties. */ +typedef struct +{ + uint8_t type; /**< Advertising type. See @ref BLE_GAP_ADV_TYPES. */ + uint8_t anonymous : 1; /**< This feature is not supported on this SoftDevice. */ + uint8_t include_tx_power : 1; /**< This feature is not supported on this SoftDevice. */ +} ble_gap_adv_properties_t; + + + /**@brief Bluetooth Low Energy address. */ typedef struct { uint8_t addr_id_peer : 1; /**< Only valid for peer addresses. - Reference to peer in device identities list (as set with @ref sd_ble_gap_device_identities_set) when peer is using privacy. */ + This bit is set by the SoftDevice to indicate whether the address has been resolved from + a Resolvable Private Address (when the peer is using privacy). + If set to 1, @ref addr and @ref addr_type refer to the identity address of the resolved address. + + This bit is ignored when a variable of type @ref ble_gap_addr_t is used as input to API functions. */ uint8_t addr_type : 7; /**< See @ref BLE_GAP_ADDR_TYPES. */ uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */ } ble_gap_addr_t; @@ -578,45 +635,86 @@ typedef struct } ble_gap_irk_t; -/**@brief Channel mask for RF channels used in advertising. */ -typedef struct -{ - uint8_t ch_37_off : 1; /**< Setting this bit to 1 will turn off advertising on channel 37 */ - uint8_t ch_38_off : 1; /**< Setting this bit to 1 will turn off advertising on channel 38 */ - uint8_t ch_39_off : 1; /**< Setting this bit to 1 will turn off advertising on channel 39 */ -} ble_gap_adv_ch_mask_t; +/**@brief Channel mask (40 bits). + * Every channel is represented with a bit positioned as per channel index defined in Bluetooth Core Specification v5.0, + * Vol 6, Part B, Section 1.4.1. The LSB contained in array element 0 represents channel index 0, and bit 39 represents + * channel index 39. If a bit is set to 1, the channel is not used. + */ +typedef uint8_t ble_gap_ch_mask_t[5]; /**@brief GAP advertising parameters. */ typedef struct { - uint8_t type; /**< See @ref BLE_GAP_ADV_TYPES. */ - ble_gap_addr_t const *p_peer_addr; /**< Address of a known peer. - - When privacy is enabled and the local device use @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE addresses, the device identity list is searched for a matching - entry. If the local IRK for that device identity is set, the local IRK for that device will be used to generate the advertiser address field in the advertise packet. - - If type is @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this must be set to the targeted initiator. If the initiator is in the device identity list, - the peer IRK for that device will be used to generate the initiator address field in the ADV_DIRECT_IND packet. */ - uint8_t fp; /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */ - uint16_t interval; /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20 ms to 10.24 s), see @ref BLE_GAP_ADV_INTERVALS. - - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for high duty cycle directed advertising. - - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, set @ref BLE_GAP_ADV_INTERVAL_MIN <= interval <= @ref BLE_GAP_ADV_INTERVAL_MAX for low duty cycle advertising.*/ - uint16_t timeout; /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for High duty cycle directed advertising. */ - ble_gap_adv_ch_mask_t channel_mask; /**< Advertising channel mask. See @ref ble_gap_adv_ch_mask_t. */ + ble_gap_adv_properties_t properties; /**< The properties of the advertising events. */ + ble_gap_addr_t const *p_peer_addr; /**< Address of a known peer. + - When privacy is enabled and the local device uses + @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE addresses, + the device identity list is searched for a matching entry. If + the local IRK for that device identity is set, the local IRK + for that device will be used to generate the advertiser address + field in the advertising packet. + - If @ref ble_gap_adv_properties_t::type is directed, this must be + set to the targeted scanner or initiator. If the peer address is + in the device identity list, the peer IRK for that device will be + used to generate @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE + target addresses used in the advertising event PDUs. */ + uint32_t interval; /**< Advertising interval in 625 us units. @sa BLE_GAP_ADV_INTERVALS. + @note If @ref ble_gap_adv_properties_t::type is set to + @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE + advertising, this parameter is ignored. */ + uint16_t duration; /**< Advertising duration in 10 ms units. When timeout is reached, + an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised. + @sa BLE_GAP_ADV_TIMEOUT_VALUES. + @note The SoftDevice will always complete at least one advertising + event even if the duration is set too low. */ + uint8_t max_adv_evts; /**< Maximum advertising events that shall be sent prior to disabling + advertising. Setting the value to 0 disables the limitation. When + the count of advertising events specified by this parameter + (if not 0) is reached, advertising will be automatically stopped + and an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised + @note If @ref ble_gap_adv_properties_t::type is set to + @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE, + this parameter is ignored. */ + ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary channels. + At least one of the primary channels, that is channel index 37-39, must be used. */ + uint8_t filter_policy; /**< Filter Policy. @sa BLE_GAP_ADV_FILTER_POLICIES. */ + uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets + are transmitted. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS + will be used. + The only supported value by this SoftDevice is @ref BLE_GAP_PHY_1MBPS. */ + uint8_t secondary_phy; /**< This field is ignored on this SoftDevice. */ + uint8_t set_id:4; /**< This field is ignored on this SoftDevice. */ + uint8_t scan_req_notification:1; /**< Enable scan request notifications for this advertising set. When a + scan request is received and the scanner address is allowed + by the filter policy, @ref BLE_GAP_EVT_SCAN_REQ_REPORT is raised. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is a non-scannable + advertising type. */ } ble_gap_adv_params_t; -/**@brief GAP scanning parameters. */ +/**@brief GAP advertising data buffers. + * + * The application must provide the buffers for advertisement. The memory shall reside in application RAM, and + * shall never be modified while advertising. The data shall be kept alive until either: + * - @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised. + * - @ref BLE_GAP_EVT_CONNECTED is raised with @ref ble_gap_evt_connected_t::adv_handle set to the corresponding + * advertising handle. + * - Advertising is stopped. + * - Advertising data is changed. + * To update advertising data while advertising, provide new buffers to @ref sd_ble_gap_adv_set_configure. */ typedef struct { - uint8_t active : 1; /**< If 1, perform active scanning (scan requests). */ - uint8_t use_whitelist : 1; /**< If 1, filter advertisers using current active whitelist. */ - uint8_t adv_dir_report : 1; /**< If 1, also report directed advertisements where the initiator field is set to a private resolvable address, - even if the address did not resolve to an entry in the device identity list. A report will be generated - even if the peer is not in the whitelist. */ - uint16_t interval; /**< Scan interval between 0x0004 and 0x4000 in 0.625 ms units (2.5 ms to 10.24 s). */ - uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625 ms units (2.5 ms to 10.24 s). */ - uint16_t timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */ -} ble_gap_scan_params_t; + ble_data_t adv_data; /**< Advertising data. + @note + Advertising data can only be specified for a @ref ble_gap_adv_properties_t::type + that is allowed to contain advertising data. */ + ble_data_t scan_rsp_data; /**< Scan response data. + @note + Scan response data can only be specified for a @ref ble_gap_adv_properties_t::type + that is scannable. */ +} ble_gap_adv_data_t; /**@brief Privacy. @@ -746,6 +844,12 @@ typedef struct and the address is the device's identity address. */ uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */ ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ + uint8_t adv_handle; /**< Advertising handle in which advertising has ended. + This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */ + ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated + advertising set. The advertising buffers provided in + @ref sd_ble_gap_adv_set_configure are now released. + This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */ } ble_gap_evt_connected_t; @@ -872,25 +976,6 @@ typedef struct } ble_gap_sec_keyset_t; -/**@brief Data Length Update Procedure parameters. */ -typedef struct -{ - uint16_t max_tx_octets; /**< Maximum number of payload octets that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ - uint16_t max_rx_octets; /**< Maximum number of payload octets that a Controller supports for reception of a single Link Layer Data Channel PDU. */ - uint16_t max_tx_time_us; /**< Maximum time, in microseconds, that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ - uint16_t max_rx_time_us; /**< Maximum time, in microseconds, that a Controller supports for reception of a single Link Layer Data Channel PDU. */ -} ble_gap_data_length_params_t; - - -/**@brief Data Length Update Procedure local limitation. */ -typedef struct -{ - uint16_t tx_payload_limited_octets; /**< If > 0, the requested TX packet length is too long by this many octets. */ - uint16_t rx_payload_limited_octets; /**< If > 0, the requested RX packet length is too long by this many octets. */ - uint16_t tx_rx_time_limited_us; /**< If > 0, the requested combination of TX and RX packet lengths is too long by this many microseconds. */ -} ble_gap_data_length_limitation_t; - - /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */ typedef struct { @@ -922,24 +1007,22 @@ typedef struct /**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */ typedef struct { - int8_t rssi; /**< Received Signal Strength Indication in dBm. */ + int8_t rssi; /**< Received Signal Strength Indication in dBm. */ + uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */ } ble_gap_evt_rssi_changed_t; - -/**@brief Event structure for @ref BLE_GAP_EVT_ADV_REPORT. */ +/**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */ typedef struct { - ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1 - and the address is the device's identity address. */ - ble_gap_addr_t direct_addr; /**< Set when the scanner is unable to resolve the private resolvable address of the initiator - field of a directed advertisement packet and the scanner has been enabled to report this in @ref ble_gap_scan_params_t::adv_dir_report. */ - int8_t rssi; /**< Received Signal Strength Indication in dBm. */ - uint8_t scan_rsp : 1; /**< If 1, the report corresponds to a scan response and the type field may be ignored. */ - uint8_t type : 2; /**< See @ref BLE_GAP_ADV_TYPES. Only valid if the scan_rsp field is 0. */ - uint8_t dlen : 5; /**< Advertising or scan response data length. */ - uint8_t data[BLE_GAP_ADV_MAX_SIZE]; /**< Advertising or scan response data. */ -} ble_gap_evt_adv_report_t; - + uint8_t reason; /**< Reason for why the advertising set terminated. See + @ref BLE_GAP_EVT_ADV_SET_TERMINATED_REASON. */ + uint8_t adv_handle; /**< Advertising handle in which advertising has ended. */ + uint8_t num_completed_adv_events; /**< If @ref ble_gap_adv_params_t::max_adv_evts was not set to 0, + this field indicates the number of completed advertising events. */ + ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated + advertising set. The advertising buffers provided in + @ref sd_ble_gap_adv_set_configure are now released. */ +} ble_gap_evt_adv_set_terminated_t; /**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */ typedef struct @@ -951,32 +1034,15 @@ typedef struct } ble_gap_evt_sec_request_t; -/**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST. */ -typedef struct -{ - ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ -} ble_gap_evt_conn_param_update_request_t; - - /**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */ typedef struct { + uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */ int8_t rssi; /**< Received Signal Strength Indication in dBm. */ ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1 and the address is the device's identity address. */ } ble_gap_evt_scan_req_report_t; -/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST. */ -typedef struct -{ - ble_gap_data_length_params_t peer_params; /**< Peer data length parameters. */ -} ble_gap_evt_data_length_update_request_t; - -/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE. */ -typedef struct -{ - ble_gap_data_length_params_t effective_params; /**< The effective data length parameters. */ -} ble_gap_evt_data_length_update_t; /**@brief GAP event structure. */ @@ -998,14 +1064,11 @@ typedef struct ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */ ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */ ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event Parameters. */ - ble_gap_evt_adv_report_t adv_report; /**< Advertising Report Event Parameters. */ + ble_gap_evt_adv_set_terminated_t adv_set_terminated; /**< Advertising Set Terminated Event Parameters. */ ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */ - ble_gap_evt_conn_param_update_request_t conn_param_update_request; /**< Connection Parameter Update Parameters. */ ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report Parameters. */ ble_gap_evt_phy_update_request_t phy_update_request; /**< PHY Update Request Event Parameters. */ ble_gap_evt_phy_update_t phy_update; /**< PHY Update Parameters. */ - ble_gap_evt_data_length_update_request_t data_length_update_request; /**< Data Length Update Request Event Parameters. */ - ble_gap_evt_data_length_update_t data_length_update; /**< Data Length Update Event Parameters. */ } params; /**< Event Parameters. */ } ble_gap_evt_t; @@ -1031,28 +1094,29 @@ typedef struct /** - * @brief Configuration of maximum concurrent connections in the different connected roles, set with + * @brief Configuration of maximum concurrent connections in the peripheral role, set with * @ref sd_ble_cfg_set. * - * @retval ::NRF_ERROR_CONN_COUNT The sum of periph_role_count and central_role_count is too - * large. The maximum supported sum of concurrent connections is + * @retval ::NRF_ERROR_CONN_COUNT The periph_role_count is too large. The maximum + * supported sum of concurrent connections is * @ref BLE_GAP_ROLE_COUNT_COMBINED_MAX. - * @retval ::NRF_ERROR_INVALID_PARAM central_sec_count is larger than central_role_count. + * @retval ::NRF_ERROR_RESOURCES The adv_set_count is too large. The maximum + * supported advertising handles is + * @ref BLE_GAP_ADV_SET_COUNT_MAX. */ typedef struct { + uint8_t adv_set_count; /**< Maximum number of advertising sets. Default value is @ref BLE_GAP_ADV_SET_COUNT_DEFAULT. */ uint8_t periph_role_count; /**< Maximum number of connections concurrently acting as a peripheral. Default value is @ref BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT. */ - uint8_t central_role_count; /**< Maximum number of connections concurrently acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT. */ - uint8_t central_sec_count; /**< Number of SMP instances shared between all connections acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT. */ } ble_gap_cfg_role_count_t; /** * @brief Device name and its properties, set with @ref sd_ble_cfg_set. * - * @note If the device name is not configured, the default device name will be @ref - * BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be @ref - * BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name + * @note If the device name is not configured, the default device name will be + * @ref BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be + * @ref BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name * will have no write access. * * @note If @ref max_len is more than @ref BLE_GAP_DEVNAME_DEFAULT_LEN and vloc is set to @ref BLE_GATTS_VLOC_STACK, @@ -1085,33 +1149,56 @@ typedef struct } ble_gap_cfg_device_name_t; +/**@brief Peripheral Preferred Connection Parameters include configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t include_cfg; /**< Inclusion configuration of the Peripheral Preferred Connection Parameters characteristic. + See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_PPCP_INCL_CONFIG_DEFAULT. */ +} ble_gap_cfg_ppcp_incl_cfg_t; + + +/**@brief Central Address Resolution include configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t include_cfg; /**< Inclusion configuration of the Central Address Resolution characteristic. + See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_CAR_INCL_CONFIG_DEFAULT. */ +} ble_gap_cfg_car_incl_cfg_t; + + /**@brief Configuration structure for GAP configurations. */ typedef union { - ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */ - ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */ + ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */ + ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */ + ble_gap_cfg_ppcp_incl_cfg_t ppcp_include_cfg; /**< Peripheral Preferred Connection Parameters characteristic include + configuration, cfg_id is @ref BLE_GAP_CFG_PPCP_INCL_CONFIG. */ + ble_gap_cfg_car_incl_cfg_t car_include_cfg; /**< Central Address Resolution characteristic include configuration, + cfg_id is @ref BLE_GAP_CFG_CAR_INCL_CONFIG. */ } ble_gap_cfg_t; /**@brief Channel Map option. - * Used with @ref sd_ble_opt_get to get the current channel map - * or @ref sd_ble_opt_set to set a new channel map. When setting the - * channel map, it applies to all current and future connections. When getting the - * current channel map, it applies to a single connection and the connection handle - * must be supplied. * - * @note Setting the channel map may take some time, depending on connection parameters. - * The time taken may be different for each connection and the get operation will - * return the previous channel map until the new one has taken effect. + * @details Used with @ref sd_ble_opt_get to get the current channel map + * or @ref sd_ble_opt_set to set a new channel map. When setting the + * channel map, it applies to all current and future connections. When getting the + * current channel map, it applies to a single connection and the connection handle + * must be supplied. + * + * @note Setting the channel map may take some time, depending on connection parameters. + * The time taken may be different for each connection and the get operation will + * return the previous channel map until the new one has taken effect. * - * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed. - * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46. + * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed. + * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46. * * @retval ::NRF_SUCCESS Get or set successful. + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - Less then two bits in @ref ch_map are set. + * - Bits for primary advertising channels (37-39) are set. * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get. - * @retval ::NRF_ERROR_NOT_SUPPORTED Returned by sd_ble_opt_set in peripheral-only SoftDevices. + * @retval ::NRF_ERROR_NOT_SUPPORTED Returned by @ref sd_ble_opt_set in peripheral-only SoftDevices. * */ typedef struct @@ -1123,21 +1210,21 @@ typedef struct /**@brief Local connection latency option. * - * Local connection latency is a feature which enables the slave to improve - * current consumption by ignoring the slave latency set by the peer. The - * local connection latency can only be set to a multiple of the slave latency, - * and cannot be longer than half of the supervision timeout. + * @details Local connection latency is a feature which enables the slave to improve + * current consumption by ignoring the slave latency set by the peer. The + * local connection latency can only be set to a multiple of the slave latency, + * and cannot be longer than half of the supervision timeout. * - * Used with @ref sd_ble_opt_set to set the local connection latency. The - * @ref sd_ble_opt_get is not supported for this option, but the actual - * local connection latency (unless set to NULL) is set as a return parameter - * when setting the option. + * @details Used with @ref sd_ble_opt_set to set the local connection latency. The + * @ref sd_ble_opt_get is not supported for this option, but the actual + * local connection latency (unless set to NULL) is set as a return parameter + * when setting the option. * - * @note The latency set will be truncated down to the closest slave latency event - * multiple, or the nearest multiple before half of the supervision timeout. + * @note The latency set will be truncated down to the closest slave latency event + * multiple, or the nearest multiple before half of the supervision timeout. * - * @note The local connection latency is disabled by default, and needs to be enabled for new - * connections and whenever the connection is updated. + * @note The local connection latency is disabled by default, and needs to be enabled for new + * connections and whenever the connection is updated. * * @retval ::NRF_SUCCESS Set successfully. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported. @@ -1152,8 +1239,9 @@ typedef struct /**@brief Disable slave latency * - * Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. - * When disabled, the peripheral will ignore the slave_latency set by the central. + * @details Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection + * (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. When disabled, the + * peripheral will ignore the slave_latency set by the central. * * @note Shall only be called on peripheral links. * @@ -1169,13 +1257,17 @@ typedef struct /**@brief Passkey Option. * - * Structure containing the passkey to be used during pairing. This can be used with @ref - * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication - * instead of generating a random one. + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC} + * @endmscs + * + * @details Structure containing the passkey to be used during pairing. This can be used with @ref + * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication + * instead of generating a random one. * - * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks. + * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks. * - * @note @ref sd_ble_opt_get is not supported for this option. + * @note @ref sd_ble_opt_get is not supported for this option. * */ typedef struct @@ -1184,58 +1276,20 @@ typedef struct } ble_gap_opt_passkey_t; -/**@brief Scan request report option. - * - * This can be used with @ref sd_ble_opt_set to make the SoftDevice send - * @ref BLE_GAP_EVT_SCAN_REQ_REPORT events. - * - * @note Due to the limited space reserved for scan request report events, - * not all received scan requests will be reported. - * - * @note If whitelisting is used, only whitelisted requests are reported. - * - * @retval ::NRF_SUCCESS Set successfully. - * @retval ::NRF_ERROR_INVALID_STATE When advertising is ongoing while the option is set. - */ -typedef struct -{ - uint8_t enable : 1; /**< Enable scan request reports. */ -} ble_gap_opt_scan_req_report_t; - -/**@brief Compatibility mode 1 option. - * - * This can be used with @ref sd_ble_opt_set to enable and disable - * compatibility mode 1. Compatibility mode 1 is disabled by default. - * - * @note Compatibility mode 1 enables interoperability with devices that do not support a value of - * 0 for the WinOffset parameter in the Link Layer CONNECT_IND packet. This applies to a - * limited set of legacy peripheral devices from another vendor. Enabling this compatibility - * mode will only have an effect if the local device will act as a central device and - * initiate a connection to a peripheral device. In that case it may lead to the connection - * creation taking up to one connection interval longer to complete for all connections. - * - * @retval ::NRF_SUCCESS Set successfully. - * @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set. - */ -typedef struct -{ - uint8_t enable : 1; /**< Enable compatibility mode 1.*/ -} ble_gap_opt_compat_mode_1_t; - /**@brief Authenticated payload timeout option. * - * This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other - * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX. + * @details This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other + * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX. * - * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated - * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted - * link. + * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated + * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted + * link. * - * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance - * to reset the timer. In addition the stack will try to prioritize running of LE ping over other - * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects - * on other activities, it is recommended to use high timeout values. - * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)). + * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance + * to reset the timer. In addition the stack will try to prioritize running of LE ping over other + * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects + * on other activities, it is recommended to use high timeout values. + * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)). * * @retval ::NRF_SUCCESS Set successfully. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. auth_payload_timeout was outside of allowed range. @@ -1247,20 +1301,17 @@ typedef struct uint16_t auth_payload_timeout; /**< Requested timeout in 10 ms unit, see @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT. */ } ble_gap_opt_auth_payload_timeout_t; - /**@brief Option structure for GAP options. */ typedef union { ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */ ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */ ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/ - ble_gap_opt_scan_req_report_t scan_req_report; /**< Parameters for the scan request report option.*/ - ble_gap_opt_compat_mode_1_t compat_mode_1; /**< Parameters for the compatibility mode 1 option.*/ ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/ ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */ } ble_gap_opt_t; -/**@} */ +/**@} */ /**@addtogroup BLE_GAP_FUNCTIONS Functions * @{ */ @@ -1270,7 +1321,7 @@ typedef union * The local Bluetooth identity address is the address that identifies this device to other peers. * The address type must be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC. * - * @note The identity address cannot be changed while advertising, scanning or creating a connection. + * @note The identity address cannot be changed while advertising. * * @note This address will be distributed to the peer during bonding. * If the address changes, the address stored in the peer device will not be valid and the ability to @@ -1290,8 +1341,7 @@ typedef union * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. - * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising, - * scanning or creating a connection. + * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising. */ SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr)); @@ -1309,6 +1359,25 @@ SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const * SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr)); +/**@brief Get the Bluetooth device address used by the advertiser. + * + * @note This function will return the local Bluetooth address used in advertising PDUs. When + * using privacy, the SoftDevice will generate a new private address every + * @ref ble_gap_privacy_params_t::private_addr_cycle_s configured using + * @ref sd_ble_gap_privacy_set. Hence depending on when the application calls this API, the + * address returned may not be the latest address that is used in the advertising PDUs. + * + * @param[in] adv_handle The advertising handle to get the address from. + * @param[out] p_addr Pointer to address structure to be filled in. + * + * @retval ::NRF_SUCCESS Address successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. + * @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising. + */ +SVCALL(SD_BLE_GAP_ADV_ADDR_GET, uint32_t, sd_ble_gap_adv_addr_get(uint8_t adv_handle, ble_gap_addr_t *p_addr)); + + /**@brief Set the active whitelist in the SoftDevice. * * @note Only one whitelist can be used at a time and the whitelist is shared between the BLE roles. @@ -1317,11 +1386,6 @@ SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr * @note If an address is resolved using the information in the device identity list, then the whitelist * filter policy applies to the peer identity address and not the resolvable address sent on air. * - * @mscs - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} - * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC} - * @endmscs - * * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses, if NULL the whitelist will be cleared. * @param[in] len Length of the whitelist, maximum @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. * @@ -1347,11 +1411,8 @@ SVCALL(SD_BLE_GAP_WHITELIST_SET, uint32_t, sd_ble_gap_whitelist_set(ble_gap_addr * * @mscs * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC} - * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC} - * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC} * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC} * @endmscs * * @retval ::NRF_SUCCESS The device identity list successfully set/cleared. @@ -1368,13 +1429,12 @@ SVCALL(SD_BLE_GAP_DEVICE_IDENTITIES_SET, uint32_t, sd_ble_gap_device_identities_ /**@brief Set privacy settings. * - * @note Privacy settings cannot be changed while advertising, scanning or creating a connection. + * @note Privacy settings cannot be changed while advertising. * * @param[in] p_privacy_params Privacy settings. * * @mscs * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC} - * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC} * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} * @endmscs * @@ -1384,8 +1444,7 @@ SVCALL(SD_BLE_GAP_DEVICE_IDENTITIES_SET, uint32_t, sd_ble_gap_device_identities_ * @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer. * @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided. - * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising, scanning - * or creating a connection. + * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising. */ SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params)); @@ -1404,37 +1463,50 @@ SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_ SVCALL(SD_BLE_GAP_PRIVACY_GET, uint32_t, sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params)); -/**@brief Set, clear or update advertising and scan response data. +/**@brief Configure an advertising set. Set, clear or update advertising and scan response data. * * @note The format of the advertising data will be checked by this call to ensure interoperability. * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and * duplicating the local name in the advertising data and scan response data. * - * @note To clear the advertising data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding - * length (dlen/srdlen) set to 0. - * - * @note The call will fail if p_data and p_sr_data are both NULL since this would have no effect. + * @note In order to update advertising data while advertising, new advertising buffers must be provided. * * @mscs * @mmsc{@ref BLE_GAP_ADV_MSC} - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} * @endmscs * - * @param[in] p_data Raw data to be placed in advertising packet. If NULL, no changes are made to the current advertising packet data. - * @param[in] dlen Data length for p_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_data is NULL, can be 0 if p_data is not NULL. - * @param[in] p_sr_data Raw data to be placed in scan response packet. If NULL, no changes are made to the current scan response packet data. - * @param[in] srdlen Data length for p_sr_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL. - * - * @retval ::NRF_SUCCESS Advertising data successfully updated or cleared. - * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, both p_data and p_sr_data cannot be NULL. - * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. - * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied. - * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied, check the advertising data format specification. - * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied. - * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data type. + * @param[in,out] p_adv_handle Provide a pointer to a handle containing @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to configure + * a new advertising set. On success, a new handle is then returned through the pointer. + * Provide a pointer to an existing advertising handle to configure an existing advertising set. + * @param[in] p_adv_data Advertising data. If set to NULL, no advertising data will be used. See @ref ble_gap_adv_data_t. + * @param[in] p_adv_params Advertising parameters. When this function is used to update advertising data while advertising, + * this parameter must be NULL. See @ref ble_gap_adv_params_t. + * + * @retval ::NRF_SUCCESS Advertising set successfully configured. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied: + * - Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t. + * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t. + * - Use of whitelist requested but whitelist has not been set, + * see @ref sd_ble_gap_whitelist_set. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR ble_gap_adv_params_t::p_peer_addr is invalid. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - It is invalid to provide non-NULL advertising set parameters while advertising. + * - It is invalid to provide the same data buffers while advertising. To update + * advertising data, provide new advertising buffers. + * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. Use @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to + * configure a new advertising handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied. + * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied. Check the advertising data format specification + * given in Bluetooth Specification Version 5.0, Volume 3, Part C, Chapter 11. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data length or advertising parameter configuration. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to configure a new advertising handle. Update an + * existing advertising handle instead. * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied. */ -SVCALL(SD_BLE_GAP_ADV_DATA_SET, uint32_t, sd_ble_gap_adv_data_set(uint8_t const *p_data, uint8_t dlen, uint8_t const *p_sr_data, uint8_t srdlen)); +SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t const *p_adv_params)); /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). @@ -1443,79 +1515,84 @@ SVCALL(SD_BLE_GAP_ADV_DATA_SET, uint32_t, sd_ble_gap_adv_data_set(uint8_t const * * @events * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.} - * @event{@ref BLE_GAP_EVT_TIMEOUT, Advertisement has timed out.} + * @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.} + * @event{@ref BLE_GAP_EVT_SCAN_REQ_REPORT, A scan request was received.} * @endevents * * @mscs * @mmsc{@ref BLE_GAP_ADV_MSC} * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC} * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} * @endmscs * - * @param[in] p_adv_params Pointer to advertising parameters structure. - * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or @ref - * BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. If - * @ref ble_gap_adv_params_t::type is @ref BLE_GAP_ADV_TYPE_ADV_NONCONN_IND, - * this is ignored. - * - * @retval ::NRF_SUCCESS The BLE stack has started advertising. - * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. - * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached; connectable advertiser cannot be started. - * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits. - * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied. - * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible. - * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available. - * Stop one or more currently active roles (Central, Peripheral or Observer) and try again + * @param[in] adv_handle Advertising handle to advertise on, received from @ref sd_ble_gap_adv_set_configure. + * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or + * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. For non-connectable + * advertising, this is ignored. + * + * @retval ::NRF_SUCCESS The BLE stack has started advertising. + * @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising. + * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration + * tag has been reached; connectable advertiser cannot be started. + * To increase the number of available connections, + * use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure. + * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied: + * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t. + * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set. + * @retval ::NRF_ERROR_RESOURCES Either: + * - adv_handle is configured with connectable advertising, but the event_length parameter + * associated with conn_cfg_tag is too small to be able to establish a connection on + * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length. + * - Not enough BLE role slots available. + * Stop one or more currently active roles (Peripheral or Broadcaster) and try again + * - p_adv_params is configured with connectable advertising, but the event_length parameter + * associated with conn_cfg_tag is too small to be able to establish a connection on + * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. */ -SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(ble_gap_adv_params_t const *p_adv_params, uint8_t conn_cfg_tag)); +SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag)); /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). * * @mscs * @mmsc{@ref BLE_GAP_ADV_MSC} - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} * @endmscs * + * @param[in] adv_handle The advertising handle that should stop advertising. + * * @retval ::NRF_SUCCESS The BLE stack has stopped advertising. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in advertising state). + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle. + * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising. */ -SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void)); +SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle)); /**@brief Update connection parameters. * - * @details In the central role this will initiate a Link Layer connection parameter update procedure, - * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for - * the central to perform the procedure. In both cases, and regardless of success or failure, the application + * @details In the peripheral role, this will send the corresponding L2CAP request and wait for + * the central to perform the procedure. Regardless of success or failure, the application * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event. * - * @details This function can be used as a central both to reply to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST or to start the procedure unrequested. - * * @events * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.} * @endevents * * @mscs * @mmsc{@ref BLE_GAP_CPU_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} - * @mmsc{@ref BLE_GAP_MULTILINK_CPU_MSC} - * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_CPU_MSC} * @endmscs * * @param[in] conn_handle Connection handle. * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role, * the parameters in the PPCP characteristic of the GAP service will be used instead. - * If NULL is provided on a central role and in response to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected * * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established. * @retval ::NRF_ERROR_BUSY Procedure already in progress, wait for pending procedures to complete and retry. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. @@ -1542,19 +1619,34 @@ SVCALL(SD_BLE_GAP_CONN_PARAM_UPDATE, uint32_t, sd_ble_gap_conn_param_update(uint * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress). + * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established. */ SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code)); /**@brief Set the radio's transmit power. * - * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -20, -16, -12, -8, -4, 0, 3, and 4 dBm). + * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for + * possible roles. + * @param[in] handle The handle parameter is interpreted depending on role: + * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle. + * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle, + * will use the specified transmit power, and include it in the advertising packet headers if + * @ref ble_gap_adv_properties_t::include_tx_power set. + * - For all other roles handle is ignored. + * @param[in] tx_power Radio transmit power in dBm (see note for accepted values). + * + * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm. + * @note The initiator will have the same transmit power as the scanner. + * @note When a connection is created it will inherit the transmit power from the initiator or + * advertiser leading to the connection. * * @retval ::NRF_SUCCESS Successfully changed the transmit power. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ -SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power)); +SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power)); /**@brief Set GAP Appearance value. @@ -1584,6 +1676,8 @@ SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t * * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table, + see @ref ble_gap_cfg_ppcp_incl_cfg_t. */ SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params)); @@ -1594,6 +1688,8 @@ SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t * * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table, + see @ref ble_gap_cfg_ppcp_incl_cfg_t. */ SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params)); @@ -1635,8 +1731,7 @@ SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t /**@brief Initiate the GAP Authentication procedure. * - * @details In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected), - * otherwise in the peripheral role, an SMP Security Request will be sent. + * @details In the peripheral role, this function will send an SMP Security Request. * * @events * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:} @@ -1653,32 +1748,20 @@ SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t * * @mscs * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} * @endmscs * * @param[in] conn_handle Connection handle. * @param[in] p_sec_params Pointer to the @ref ble_gap_sec_params_t structure with the security parameters to be used during the pairing or bonding procedure. * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used. - * In the central role, this pointer may be NULL to reject a Security Request. * * @retval ::NRF_SUCCESS Successfully initiated authentication procedure. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - No link has been established. + * - An encryption is already executing or queued. * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. - * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported. - * @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited. */ SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params)); @@ -1689,7 +1772,7 @@ SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_ * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. * * @events - * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @event{This function is used during authentication procedures, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} * @endevents * * @mscs @@ -1708,21 +1791,11 @@ SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_ * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC} * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC} * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} * @endmscs * * @param[in] conn_handle Connection handle. * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS. - * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. In the central role this must be set to NULL, as the parameters have - * already been provided during a previous call to @ref sd_ble_gap_authenticate. + * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. * @param[in,out] p_sec_keyset Pointer to a @ref ble_gap_sec_keyset_t security keyset structure. Any keys generated and/or distributed as a result of the ongoing security procedure * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event. @@ -1735,7 +1808,7 @@ SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_ * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported. */ @@ -1755,9 +1828,6 @@ SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16 * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC} * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} * @endmscs * * @param[in] conn_handle Connection handle. @@ -1770,11 +1840,12 @@ SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16 * @retval ::NRF_SUCCESS Authentication key successfully set. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Authentication key has not been requested. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const *p_key)); + /**@brief Reply with an LE Secure connections DHKey. * * @details This function is only used to reply to a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. @@ -1790,11 +1861,6 @@ SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t c * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC} * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} * @endmscs * * @param[in] conn_handle Connection handle. @@ -1803,16 +1869,18 @@ SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t c * @retval ::NRF_SUCCESS DHKey successfully set. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - The peer is not authenticated. + * - The application has not pulled a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ SVCALL(SD_BLE_GAP_LESC_DHKEY_REPLY, uint32_t, sd_ble_gap_lesc_dhkey_reply(uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey)); + /**@brief Notify the peer of a local keypress. * * @mscs * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} * @endmscs * * @param[in] conn_handle Connection handle. @@ -1820,12 +1888,16 @@ SVCALL(SD_BLE_GAP_LESC_DHKEY_REPLY, uint32_t, sd_ble_gap_lesc_dhkey_reply(uint16 * * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either not entering a passkey or keypresses have not been enabled by both peers. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Authentication key not requested. + * - Passkey has not been entered. + * - Keypresses have not been enabled by both peers. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time. */ SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not)); + /**@brief Generate a set of OOB data to send to a peer out of band. * * @note The @ref ble_gap_addr_t included in the OOB data returned will be the currently active one (or, if a connection has already been established, @@ -1833,10 +1905,9 @@ SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t * * @mscs * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} * @endmscs * - * @param[in] conn_handle Connection handle. Can be BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet. + * @param[in] conn_handle Connection handle. Can be @ref BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet. * @param[in] p_pk_own LE Secure Connections local P-256 Public Key. * @param[out] p_oobd_own The OOB data to be sent out of band to a peer. * @@ -1857,51 +1928,25 @@ SVCALL(SD_BLE_GAP_LESC_OOB_DATA_GET, uint32_t, sd_ble_gap_lesc_oob_data_get(uint * * @mscs * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} * @endmscs * * @param[in] conn_handle Connection handle. * @param[in] p_oobd_own The OOB data sent out of band to a peer or NULL if the peer has not received OOB data. * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received. - * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref sd_ble_gap_authenticate in the central role - * or @ref sd_ble_gap_sec_params_reply in the peripheral role. + * Must correspond to @ref ble_gap_sec_params_t::oob flag + * in @ref sd_ble_gap_sec_params_reply in the peripheral role. * * @retval ::NRF_SUCCESS OOB data accepted. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Authentication key not requested + * - Not expecting LESC OOB data + * - Have not actually exchanged passkeys. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ SVCALL(SD_BLE_GAP_LESC_OOB_DATA_SET, uint32_t, sd_ble_gap_lesc_oob_data_set(uint16_t conn_handle, ble_gap_lesc_oob_data_t const *p_oobd_own, ble_gap_lesc_oob_data_t const *p_oobd_peer)); -/**@brief Initiate GAP Encryption procedure. - * - * @details In the central role, this function will initiate the encryption procedure using the encryption information provided. - * - * @events - * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE, The connection security has been updated.} - * @endevents - * - * @mscs - * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_ENC_MSC} - * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC} - * @endmscs - * - * @param[in] conn_handle Connection handle. - * @param[in] p_master_id Pointer to a @ref ble_gap_master_id_t master identification structure. - * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. - * - * @retval ::NRF_SUCCESS Successfully initiated authentication procedure. - * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. - * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. - * @retval ::BLE_ERROR_INVALID_ROLE Operation is not supported in the Peripheral role. - * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, wait for pending procedures to complete and retry. - */ -SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info)); - /**@brief Reply with GAP security information. * @@ -1920,7 +1965,10 @@ SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, bl * * @retval ::NRF_SUCCESS Successfully accepted security information. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - No link has been established. + * - No @ref BLE_GAP_EVT_SEC_REQUEST pending. + * - Encryption information provided by the app without being requested. See @ref ble_gap_evt_sec_info_request_t::enc_info. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info)); @@ -1958,7 +2006,7 @@ SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_ * @param[in] skip_count Number of RSSI samples with a change of threshold_dbm or more before sending a new @ref BLE_GAP_EVT_RSSI_CHANGED event. * * @retval ::NRF_SUCCESS Successfully activated RSSI reporting. - * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress. Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count)); @@ -1977,7 +2025,7 @@ SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_hand * @param[in] conn_handle Connection handle. * * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. */ SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle)); @@ -1987,124 +2035,56 @@ SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle * * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start. - * * @mscs * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} * @endmscs * * @param[in] conn_handle Connection handle. * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored. + * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored. * * @retval ::NRF_SUCCESS Successfully read the RSSI. * @retval ::NRF_ERROR_NOT_FOUND No sample is available. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. - * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing, or disconnection in progress. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing. */ -SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi)); - - -/**@brief Start scanning (GAP Discovery procedure, Observer Procedure). - * - * @events - * @event{@ref BLE_GAP_EVT_ADV_REPORT, An advertising or scan response packet has been received.} - * @event{@ref BLE_GAP_EVT_TIMEOUT, Scanner has timed out.} - * @endevents - * - * @mscs - * @mmsc{@ref BLE_GAP_SCAN_MSC} - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} - * @endmscs - * - * @param[in] p_scan_params Pointer to scan parameters structure. - * - * @retval ::NRF_SUCCESS Successfully initiated scanning procedure. - * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. - * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available. - * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again - */ -SVCALL(SD_BLE_GAP_SCAN_START, uint32_t, sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params)); - - -/**@brief Stop scanning (GAP Discovery procedure, Observer Procedure). - * - * @mscs - * @mmsc{@ref BLE_GAP_SCAN_MSC} - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} - * @endmscs - * - * @retval ::NRF_SUCCESS Successfully stopped scanning procedure. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in scanning state). - */ -SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void)); - - -/**@brief Create a connection (GAP Link Establishment). - * - * @note If a scanning procedure is currently in progress it will be automatically stopped when calling this function. - * The scanning procedure will be stopped even if the function returns an error. - * - * @mscs - * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC} - * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC} - * @endmscs - * - * @param[in] p_peer_addr Pointer to peer address. If the use_whitelist bit is set in @ref ble_gap_scan_params_t, then this is ignored. - * @param[in] p_scan_params Pointer to scan parameters structure. - * @param[in] p_conn_params Pointer to desired connection parameters. - * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or @ref - * BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. - * - * @retval ::NRF_SUCCESS Successfully initiated connection procedure. - * @retval ::NRF_ERROR_INVALID_ADDR Invalid parameter(s) pointer supplied. - * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. - * - Invalid parameter(s) in p_scan_params or p_conn_params. - * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set. - * - Peer address was not present in the device identity list, see @ref sd_ble_gap_device_identities_set. - * @retval ::NRF_ERROR_INVALID_STATE The SoftDevice is in an invalid state to perform this operation. This may be due to an - * existing locally initiated connect procedure, which must complete before initiating again. - * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address. - * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached. - * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available. - * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again - */ -SVCALL(SD_BLE_GAP_CONNECT, uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params, uint8_t conn_cfg_tag)); - - -/**@brief Cancel a connection establishment. - * - * @mscs - * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC} - * @endmscs - * - * @retval ::NRF_SUCCESS Successfully canceled an ongoing connection procedure. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. - */ -SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void)); +SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi, uint8_t *p_ch_index)); /**@brief Initiate or respond to a PHY Update Procedure * - * @details This function is used to initiate or respond to a PHY Update Procedure. It will always generate a - * @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed. If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys - * is @ref BLE_GAP_PHY_AUTO, then the stack will select a PHY for the respective direction based on the peer's PHY preferences - * and the local stack configuration. If the peer does not support the PHY Update Procedure, then the - * resulting @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to + * @details This function is used to initiate or respond to a PHY Update Procedure. It will always + * generate a @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed. + * If this function is used to initiate a PHY Update procedure and the only option + * provided in @ref ble_gap_phys_t::tx_phys and @ref ble_gap_phys_t::rx_phys is the + * currently active PHYs in the respective directions, the SoftDevice will generate a + * @ref BLE_GAP_EVT_PHY_UPDATE with the current PHYs set and will not initiate the + * procedure in the Link Layer. + * + * If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys is @ref BLE_GAP_PHY_AUTO, + * then the stack will select PHYs based on the peer's PHY preferences and the local link + * configuration. The PHY Update procedure will for this case result in a PHY combination + * that respects the time constraints configured with @ref sd_ble_cfg_set and the current + * link layer data length. + * + * If the peer does not support the PHY Update Procedure, then the resulting + * @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to * @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE. - * If the PHY procedure was rejected by the peer due to a procedure collision, the status will be - * @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION. - * If the peer responds to the PHY Update procedure with invalid parameters, the status will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS. - * If the PHY procedure was rejected by the peer for a different reason, the status will contain the reason as specified by the peer. + * + * If the PHY Update procedure was rejected by the peer due to a procedure collision, the status + * will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or + * @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION. + * If the peer responds to the PHY Update procedure with invalid parameters, the status + * will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS. + * If the PHY Update procedure was rejected by the peer for a different reason, the status will + * contain the reason as specified by the peer. * * @events * @event{@ref BLE_GAP_EVT_PHY_UPDATE, Result of the PHY Update Procedure.} * @endevents * * @mscs - * @mmsc{@ref BLE_GAP_CENTRAL_PHY_UPDATE} * @mmsc{@ref BLE_GAP_PERIPHERAL_PHY_UPDATE} * @endmscs * @@ -2114,48 +2094,39 @@ SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void)); * @retval ::NRF_SUCCESS Successfully requested a PHY Update. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. - * @retval ::NRF_ERROR_INVALID_PARAM Unsupported PHYs supplied to the call. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. * @retval ::NRF_ERROR_BUSY Procedure is already in progress or not allowed at this time. Process pending events and wait for the pending procedure to complete and retry. * */ SVCALL(SD_BLE_GAP_PHY_UPDATE, uint32_t, sd_ble_gap_phy_update(uint16_t conn_handle, ble_gap_phys_t const *p_gap_phys)); -/**@brief Initiate or respond to a Data Length Update Procedure. + + + +/**@brief Obtain the next connection event counter value. * - * @note Only symmetric input parameters for the Data Length Update is supported. Only @ref - * BLE_GAP_DATA_LENGTH_AUTO for max_tx_time_us and max_rx_time_us is supported. + * @details The connection event counter is initialized to zero on the first connection event. The value is incremented + * by one for each connection event. For more information see Bluetooth Core Specification v5.0, Vol 6, Part B, + * Section 4.5.1. * - * @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of - * p_dl_params, the SoftDevice will choose the highest value supported in current - * configuration and connection parameters. + * @note The connection event counter obtained through this API will be outdated if this API is called + * at the same time as the connection event counter is incremented. * - * @param[in] conn_handle Connection handle. - * @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update - * Procedure. Set any member to @ref BLE_GAP_DATA_LENGTH_AUTO to let - * the SoftDevice automatically decide the value for that member. - * Set to NULL to use automatic values for all members. - * @param[out] p_dl_limitation Pointer to limitation to be written when local device does not - * have enough resources to accommodate the requested Data Length - * Update parameters. Ignored if NULL. + * @note This API will always return the last connection event counter + 1. + * The actual connection event may be multiple connection events later if: + * - Slave latency is enabled and there is no data to transmit or receive. + * - Another role is scheduled with a higher priority at the same time as the next connection event. * - * @mscs - * @mmsc{@ref BLE_GAP_DATA_LENGTH_UPDATE_PROCEDURE_MSC} - * @endmscs + * @param[in] conn_handle Connection handle. + * @param[out] p_counter Pointer to the variable where the next connection event counter will be written. * - * @retval ::NRF_SUCCESS Successfully set Data Length Extension initiation/response parameters. - * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_SUCCESS The connection event counter was successfully retrieved. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. - * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. - * @retval ::NRF_ERROR_NOT_SUPPORTED The requested parameters are not supported by the SoftDevice. - * @retval ::NRF_ERROR_RESOURCES The requested parameters can not be accommodated. Inspect - * p_dl_limitation so see where the limitation is. - * @retval ::NRF_ERROR_BUSY Peer has already initiated a Data Length Update Procedure. Process the - * pending @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event to respond. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. */ -SVCALL(SD_BLE_GAP_DATA_LENGTH_UPDATE, uint32_t, sd_ble_gap_data_length_update(uint16_t conn_handle, ble_gap_data_length_params_t const *p_dl_params, ble_gap_data_length_limitation_t *p_dl_limitation)); - +SVCALL(SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET, uint32_t, sd_ble_gap_next_conn_evt_counter_get(uint16_t conn_handle, uint16_t * p_counter)); /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gatt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gatt.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gatt.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gatt.h index 4e054cf..c392884 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gatt.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gatt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2013 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,8 +45,13 @@ #ifndef BLE_GATT_H__ #define BLE_GATT_H__ -#include "ble_types.h" +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" #include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" #ifdef __cplusplus extern "C" { @@ -116,7 +121,7 @@ extern "C" { #define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */ #define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */ #define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */ -#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Insufficient resources. */ #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */ #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */ #define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */ @@ -125,6 +130,7 @@ extern "C" { #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */ #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */ #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */ +#define BLE_GATT_STATUS_ATTERR_CPS_WRITE_REQ_REJECTED 0x01FC /**< ATT Common Profile and Service Error: Write request rejected. */ #define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */ #define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */ #define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */ @@ -179,7 +185,7 @@ extern "C" { /** * @brief BLE GATT connection configuration parameters, set with @ref sd_ble_cfg_set. * - * @retval NRF_ERROR_INVALID_PARAM att_mtu is smaller than @ref BLE_GATT_ATT_MTU_DEFAULT. + * @retval ::NRF_ERROR_INVALID_PARAM att_mtu is smaller than @ref BLE_GATT_ATT_MTU_DEFAULT. */ typedef struct { diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gattc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gattc.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gattc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gattc.h index 191f3a8..7fb3920 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gattc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gattc.h @@ -45,12 +45,14 @@ #ifndef BLE_GATTC_H__ #define BLE_GATTC_H__ -#include "ble_gatt.h" -#include "ble_types.h" -#include "ble_ranges.h" +#include +#include "nrf.h" #include "nrf_svc.h" #include "nrf_error.h" -#include "nrf.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" +#include "ble_gatt.h" #ifdef __cplusplus extern "C" { @@ -372,6 +374,7 @@ typedef struct * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid)); @@ -398,6 +401,7 @@ SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_se * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); @@ -426,6 +430,7 @@ SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); @@ -451,6 +456,7 @@ SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteris * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); @@ -477,6 +483,7 @@ SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_dis * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range)); @@ -503,6 +510,7 @@ SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_b * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset)); @@ -528,6 +536,7 @@ SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count)); @@ -574,6 +583,7 @@ SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(ui * @retval ::NRF_ERROR_BUSY For write with response, procedure already in progress. Wait for a @ref BLE_GATTC_EVT_WRITE_RSP event and retry. * @retval ::NRF_ERROR_RESOURCES Too many writes without responses queued. * Wait for a @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event and retry. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params)); @@ -591,6 +601,7 @@ SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, bl * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed. * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle)); @@ -608,6 +619,7 @@ SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_ * @retval ::NRF_ERROR_INVALID_STATE Invalid connection state * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range)); @@ -640,6 +652,7 @@ SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discove * @retval ::NRF_ERROR_INVALID_STATE Invalid connection state or an ATT_MTU exchange was already requested once. * @retval ::NRF_ERROR_INVALID_PARAM Invalid Client RX MTU size supplied. * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, uint32_t, sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, uint16_t client_rx_mtu)); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gatts.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gatts.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gatts.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gatts.h index 5e8615c..394d8d1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_gatts.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_gatts.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,12 +45,15 @@ #ifndef BLE_GATTS_H__ #define BLE_GATTS_H__ -#include "ble_types.h" +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" #include "ble_ranges.h" -#include "ble_l2cap.h" -#include "ble_gap.h" +#include "ble_types.h" +#include "ble_err.h" #include "ble_gatt.h" -#include "nrf_svc.h" +#include "ble_gap.h" #ifdef __cplusplus extern "C" { @@ -286,7 +289,7 @@ typedef struct uint16_t handle; /**< Characteristic Value Handle. */ uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ uint16_t offset; /**< Offset within the attribute value. */ - uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after successful return. */ + uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after return. */ uint8_t const *p_data; /**< Actual data content, use NULL to use the current attribute value. */ } ble_gatts_hvx_params_t; @@ -460,7 +463,7 @@ SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type * @retval ::NRF_SUCCESS Successfully added an include declaration. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services. - * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. * @retval ::NRF_ERROR_NOT_SUPPORTED Feature is not supported, service_handle must be that of the last added service. * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed. * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. @@ -546,8 +549,8 @@ SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_ha /**@brief Get the value of a given attribute. * * @note If the attribute value is longer than the size of the supplied buffer, - * p_len will return the total attribute value length (excluding offset), - * and not the number of bytes actually returned in p_data. + * @ref ble_gatts_value_t::len will return the total attribute value length (excluding offset), + * and not the number of bytes actually returned in @ref ble_gatts_value_t::p_value. * The application may use this information to allocate a suitable buffer size. * * @note When retrieving system attribute values with this function, the connection handle @@ -576,7 +579,7 @@ SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_ha * @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. * The Attribute Table has been updated if one of the following error codes is returned: @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, * @ref NRF_ERROR_FORBIDDEN, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and @ref NRF_ERROR_RESOURCES. - * The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len). + * The caller can check whether the value has been updated by looking at the contents of *(@ref ble_gatts_hvx_params_t::p_len). * * @note Only one indication procedure can be ongoing per connection at a time. * If the application tries to indicate an attribute value while another indication procedure is ongoing, @@ -604,9 +607,12 @@ SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_ha * @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC} * @endmscs * - * @param[in] conn_handle Connection handle. - * @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with - * the contents pointed by it before sending the notification or indication. + * @param[in] conn_handle Connection handle. + * @param[in,out] p_hvx_params Pointer to an HVx parameters structure. If @ref ble_gatts_hvx_params_t::p_data + * contains a non-NULL pointer the attribute value will be updated with the contents + * pointed by it before sending the notification or indication. If the attribute value + * is updated, @ref ble_gatts_hvx_params_t::p_len is updated by the SoftDevice to + * contain the number of actual bytes written, else it will be set to 0. * * @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. @@ -625,6 +631,7 @@ SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_ha * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. * @retval ::NRF_ERROR_RESOURCES Too many notifications queued. * Wait for a @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event and retry. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)); @@ -660,6 +667,7 @@ SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_ga * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application. * @retval ::NRF_ERROR_BUSY Procedure already in progress. * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)); @@ -692,6 +700,7 @@ SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint * @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid, * handle supplied does not match requested handle, * or invalid data to be written provided by the application. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params)); @@ -813,7 +822,7 @@ SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, b * @param[in] server_rx_mtu Server RX MTU size. * - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. * - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration - used for this connection. + * used for this connection. * - The value must be equal to Client RX MTU size given in @ref sd_ble_gattc_exchange_mtu_request * if an ATT_MTU exchange has already been performed in the other direction. * @@ -821,6 +830,7 @@ SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, b * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no ATT_MTU exchange request pending. * @retval ::NRF_ERROR_INVALID_PARAM Invalid Server RX MTU size supplied. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. */ SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu)); /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_hci.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_hci.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_hci.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_hci.h diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_ranges.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_ranges.h new file mode 100644 index 0000000..493dd43 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_ranges.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2012 - 2018, 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. + */ + +/** + @addtogroup BLE_COMMON + @{ + @defgroup ble_ranges Module specific SVC, event and option number subranges + @{ + + @brief Definition of SVC, event and option number subranges for each API module. + + @note + SVCs, event and option numbers are split into subranges for each API module. + Each module receives its entire allocated range of SVC calls, whether implemented or not, + but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range. + + Note that the symbols BLE__SVC_LAST is the end of the allocated SVC range, + rather than the last SVC function call actually defined and implemented. + + Specific SVC, event and option values are defined in each module's ble_.h file, + which defines names of each individual SVC code based on the range start value. +*/ + +#ifndef BLE_RANGES_H__ +#define BLE_RANGES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_SVC_BASE 0x60 /**< Common BLE SVC base. */ +#define BLE_SVC_LAST 0x6B /**< Common BLE SVC last. */ + +#define BLE_GAP_SVC_BASE 0x6C /**< GAP BLE SVC base. */ +#define BLE_GAP_SVC_LAST 0x9A /**< GAP BLE SVC last. */ + +#define BLE_GATTC_SVC_BASE 0x9B /**< GATTC BLE SVC base. */ +#define BLE_GATTC_SVC_LAST 0xA7 /**< GATTC BLE SVC last. */ + +#define BLE_GATTS_SVC_BASE 0xA8 /**< GATTS BLE SVC base. */ +#define BLE_GATTS_SVC_LAST 0xB7 /**< GATTS BLE SVC last. */ + + + +#define BLE_EVT_INVALID 0x00 /**< Invalid BLE Event. */ + +#define BLE_EVT_BASE 0x01 /**< Common BLE Event base. */ +#define BLE_EVT_LAST 0x0F /**< Common BLE Event last. */ + +#define BLE_GAP_EVT_BASE 0x10 /**< GAP BLE Event base. */ +#define BLE_GAP_EVT_LAST 0x2F /**< GAP BLE Event last. */ + +#define BLE_GATTC_EVT_BASE 0x30 /**< GATTC BLE Event base. */ +#define BLE_GATTC_EVT_LAST 0x4F /**< GATTC BLE Event last. */ + +#define BLE_GATTS_EVT_BASE 0x50 /**< GATTS BLE Event base. */ +#define BLE_GATTS_EVT_LAST 0x6F /**< GATTS BLE Event last. */ + + + +#define BLE_OPT_INVALID 0x00 /**< Invalid BLE Option. */ + +#define BLE_OPT_BASE 0x01 /**< Common BLE Option base. */ +#define BLE_OPT_LAST 0x1F /**< Common BLE Option last. */ + +#define BLE_GAP_OPT_BASE 0x20 /**< GAP BLE Option base. */ +#define BLE_GAP_OPT_LAST 0x3F /**< GAP BLE Option last. */ + +#define BLE_GATT_OPT_BASE 0x40 /**< GATT BLE Option base. */ +#define BLE_GATT_OPT_LAST 0x5F /**< GATT BLE Option last. */ + +#define BLE_GATTC_OPT_BASE 0x60 /**< GATTC BLE Option base. */ +#define BLE_GATTC_OPT_LAST 0x7F /**< GATTC BLE Option last. */ + +#define BLE_GATTS_OPT_BASE 0x80 /**< GATTS BLE Option base. */ +#define BLE_GATTS_OPT_LAST 0x9F /**< GATTS BLE Option last. */ + + + +#define BLE_CFG_INVALID 0x00 /**< Invalid BLE configuration. */ + +#define BLE_CFG_BASE 0x01 /**< Common BLE configuration base. */ +#define BLE_CFG_LAST 0x1F /**< Common BLE configuration last. */ + +#define BLE_CONN_CFG_BASE 0x20 /**< BLE connection configuration base. */ +#define BLE_CONN_CFG_LAST 0x3F /**< BLE connection configuration last. */ + +#define BLE_GAP_CFG_BASE 0x40 /**< GAP BLE configuration base. */ +#define BLE_GAP_CFG_LAST 0x5F /**< GAP BLE configuration last. */ + +#define BLE_GATT_CFG_BASE 0x60 /**< GATT BLE configuration base. */ +#define BLE_GATT_CFG_LAST 0x7F /**< GATT BLE configuration last. */ + +#define BLE_GATTC_CFG_BASE 0x80 /**< GATTC BLE configuration base. */ +#define BLE_GATTC_CFG_LAST 0x9F /**< GATTC BLE configuration last. */ + +#define BLE_GATTS_CFG_BASE 0xA0 /**< GATTS BLE configuration base. */ +#define BLE_GATTS_CFG_LAST 0xBF /**< GATTS BLE configuration last. */ + + + + + + +#ifdef __cplusplus +} +#endif +#endif /* BLE_RANGES_H__ */ + +/** + @} + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_types.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/ble_types.h diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf52/nrf_mbr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf52/nrf_mbr.h new file mode 100644 index 0000000..42e09fc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf52/nrf_mbr.h @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2014 - 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. + */ + +/** + @defgroup nrf_mbr_api Master Boot Record API + @{ + + @brief APIs for updating SoftDevice and BootLoader + +*/ + +#ifndef NRF_MBR_H__ +#define NRF_MBR_H__ + +#include "nrf_svc.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup NRF_MBR_DEFINES Defines + * @{ */ + +/**@brief MBR SVC Base number. */ +#define MBR_SVC_BASE (0x18) + +/**@brief Page size in words. */ +#define MBR_PAGE_SIZE_IN_WORDS (1024) + +/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash. +This is the offset where the first byte of the SoftDevice hex file is written. */ +#define MBR_SIZE (0x1000) + +/** @brief Location (in the flash memory) of the bootloader address. */ +#define MBR_BOOTLOADER_ADDR (0xFF8) + +/** @brief Location (in UICR) of the bootloader address. */ +#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0])) + +/** @brief Location (in the flash memory) of the address of the MBR parameter page. */ +#define MBR_PARAM_PAGE_ADDR (0xFFC) + +/** @brief Location (in UICR) of the address of the MBR parameter page. */ +#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1])) + + +/** @} */ + +/** @addtogroup NRF_MBR_ENUMS Enumerations + * @{ */ + +/**@brief nRF Master Boot Record API SVC numbers. */ +enum NRF_MBR_SVCS +{ + SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */ +}; + +/**@brief Possible values for ::sd_mbr_command_t.command */ +enum NRF_MBR_COMMANDS +{ + SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/ + SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/ + SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/ + SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/ + SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/ + SD_MBR_COMMAND_RESERVED, + SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/ +}; + +/** @} */ + +/** @addtogroup NRF_MBR_TYPES Types + * @{ */ + +/**@brief This command copies part of a new SoftDevice + * + * The destination area is erased before copying. + * If dst is in the middle of a flash page, that whole flash page will be erased. + * If (dst+len) is in the middle of a flash page, that whole flash page will be erased. + * + * The user of this function is responsible for setting the BPROT registers. + * + * @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly. + * @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying. + */ +typedef struct +{ + uint32_t *src; /**< Pointer to the source of data to be copied.*/ + uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/ + uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/ +} sd_mbr_command_copy_sd_t; + + +/**@brief This command works like memcmp, but takes the length in words. + * + * @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal. + * @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal. + */ +typedef struct +{ + uint32_t *ptr1; /**< Pointer to block of memory. */ + uint32_t *ptr2; /**< Pointer to block of memory. */ + uint32_t len; /**< Number of 32 bit words to compare.*/ +} sd_mbr_command_compare_t; + + +/**@brief This command copies a new BootLoader. + * + * The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to + * the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * The bootloader destination is erased by this function. + * If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased. + * + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. + * + * This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is + * not intended to be written. + * + * On success, this function will not return. It will start the new bootloader from reset-vector as normal. + * + * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. + * @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set. + * @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. + */ +typedef struct +{ + uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/ + uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */ +} sd_mbr_command_copy_bl_t; + +/**@brief Change the address the MBR starts after a reset + * + * Once this function has been called, this address is where the MBR will start to forward + * interrupts to after a reset. + * + * To restore default forwarding, this function should be called with @ref address set to 0. If a + * bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will + * be forwarded to the SoftDevice. + * + * The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or + * @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. + * + * On success, this function will not return. It will reset the device. + * + * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. + * @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. + */ +typedef struct +{ + uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ +} sd_mbr_command_vector_table_base_set_t; + +/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR + * + * Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not + * change where the MBR starts after reset. + * + * @retval ::NRF_SUCCESS + */ +typedef struct +{ + uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ +} sd_mbr_command_irq_forward_address_set_t; + +/**@brief Input structure containing data used when calling ::sd_mbr_command + * + * Depending on what command value that is set, the corresponding params value type must also be + * set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command + * @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params. + */ +typedef struct +{ + uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */ + union + { + sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/ + sd_mbr_command_compare_t compare; /**< Parameters for verify.*/ + sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */ + sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/ + sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/ + } params; /**< Command parameters. */ +} sd_mbr_command_t; + +/** @} */ + +/** @addtogroup NRF_MBR_FUNCTIONS Functions + * @{ */ + +/**@brief Issue Master Boot Record commands + * + * Commands used when updating a SoftDevice and bootloader. + * + * The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires + * parameters to be retained by the MBR when resetting the IC. This is done in a separate flash + * page. The location of the flash page should be provided by the application in either + * @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR + * will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to + * store the command before reset. When an address is specified, the page it refers to must not be + * used by the application. If no address is provided by the application, i.e. both + * @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use + * flash will be unavailable and return @ref NRF_ERROR_NO_MEM. + * + * @param[in] param Pointer to a struct describing the command. + * + * @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t, + * ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t, + * ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t + * + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided + * @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given. +*/ +SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param)); + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_MBR_H__ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_error.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_error.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_error.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_error_sdm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_error_sdm.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_error_sdm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_error_sdm.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_error_soc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_error_soc.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_error_soc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_error_soc.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_nvic.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_nvic.h similarity index 95% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_nvic.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_nvic.h index 40537b4..1f79cc3 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_nvic.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_nvic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -57,7 +57,8 @@ #include #include "nrf.h" - +#include "nrf_svc.h" +#include "nrf_error.h" #include "nrf_error_soc.h" #ifdef __cplusplus @@ -74,6 +75,16 @@ extern "C" { #define __NRF_NVIC_ISER_COUNT (2) /**< The number of ISER/ICER registers in the NVIC that are used. */ +/**@brief Interrupt priority levels used by the SoftDevice. */ +#define __NRF_NVIC_SD_IRQ_PRIOS ((uint8_t)( \ + (1U << 0) /**< Priority level high .*/ \ + | (1U << 1) /**< Priority level medium. */ \ + | (1U << 4) /**< Priority level low. */ \ + )) + +/**@brief Interrupt priority levels available to the application. */ +#define __NRF_NVIC_APP_IRQ_PRIOS ((uint8_t)~__NRF_NVIC_SD_IRQ_PRIOS) + /**@brief Interrupts used by the SoftDevice, with IRQn in the range 0-31. */ #define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \ (1U << POWER_CLOCK_IRQn) \ @@ -85,7 +96,7 @@ extern "C" { | (1U << CCM_AAR_IRQn) \ | (1U << TEMP_IRQn) \ | (1U << __NRF_NVIC_NVMC_IRQn) \ - | (1U << (uint32_t)SWI5_EGU5_IRQn) \ + | (1U << (uint32_t)SWI5_IRQn) \ )) /**@brief Interrupts used by the SoftDevice, with IRQn in the range 32-63. */ @@ -304,14 +315,9 @@ __STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn) __STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority) { - if(priority >= (1 << __NVIC_PRIO_BITS)) - { - return 0; - } - if( priority == 0 - || priority == 1 - || priority == 4 - ) + if( (priority >= (1 << __NVIC_PRIO_BITS)) + || (((1 << priority) & __NRF_NVIC_APP_IRQ_PRIOS) == 0) + ) { return 0; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_sd_def.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_sd_def.h similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_sd_def.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_sd_def.h index 0b4d221..1bbe3e0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_sd_def.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_sd_def.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_SD_DEF_H__ #define NRF_SD_DEF_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_sdm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_sdm.h similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_sdm.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_sdm.h index c41d86d..aad168d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_sdm.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_sdm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -47,10 +47,12 @@ #ifndef NRF_SDM_H__ #define NRF_SDM_H__ -#include "nrf_svc.h" +#include #include "nrf.h" -#include "nrf_soc.h" +#include "nrf_svc.h" +#include "nrf_error.h" #include "nrf_error_sdm.h" +#include "nrf_soc.h" #ifdef __cplusplus extern "C" { @@ -65,13 +67,16 @@ extern "C" { #endif /** @brief The major version for the SoftDevice binary distributed with this header file. */ -#define SD_MAJOR_VERSION (5) +#define SD_MAJOR_VERSION (7) /** @brief The minor version for the SoftDevice binary distributed with this header file. */ #define SD_MINOR_VERSION (0) /** @brief The bugfix version for the SoftDevice binary distributed with this header file. */ -#define SD_BUGFIX_VERSION (0) +#define SD_BUGFIX_VERSION (1) + +/** @brief The SoftDevice variant of this firmware. */ +#define SD_VARIANT_ID 112 /** @brief The full version number for the SoftDevice binary this header file was distributed * with, as a decimal number in the form Mmmmbbb, where: @@ -132,8 +137,14 @@ the start of the SoftDevice (without MBR)*/ * the MBR (the usual case). */ #define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET))) -/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use @ref - * MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual +/** @brief Defines the amount of flash that is used by the SoftDevice. + * Add @ref MBR_SIZE to find the first available flash address when the SoftDevice is installed + * just above the MBR (the usual case). + */ +#define SD_FLASH_SIZE 0x18000 + +/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use + * @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual * case). */ #define SD_FWID_GET(baseaddr) (*((uint16_t *) ((baseaddr) + SD_FWID_OFFSET))) @@ -227,27 +238,27 @@ enum NRF_SD_SVCS typedef struct { uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */ - uint8_t rc_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second - units (nRF51: 1-64, nRF52: 1-32). + uint8_t rc_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second + units (nRF52: 1-32). @note To avoid excessive clock drift, 0.5 degrees Celsius is the maximum temperature change allowed in one calibration timer interval. The interval should be selected to ensure this. - @note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC. */ - uint8_t rc_temp_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: How often (in number of calibration + @note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. */ + uint8_t rc_temp_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: How often (in number of calibration intervals) the RC oscillator shall be calibrated if the temperature hasn't changed. 0: Always calibrate even if the temperature hasn't changed. - 1: Only calibrate if the temperature has changed (nRF51 only). + 1: Only calibrate if the temperature has changed (legacy - nRF51 only). 2-33: Check the temperature and only calibrate if it has changed, however calibration will take place every rc_temp_ctiv intervals in any case. - @note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC. + @note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. @note For nRF52, the application must ensure calibration at least once every 8 seconds to ensure +/-500 ppm clock stability. The - recommended configuration for NRF_CLOCK_LF_SRC_RC on nRF52 is + recommended configuration for ::NRF_CLOCK_LF_SRC_RC on nRF52 is rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at least once every 8 seconds and for temperature changes of 0.5 degrees Celsius every 4 seconds. See the Product Specification @@ -263,13 +274,17 @@ typedef struct * perform a reset, using e.g. CMSIS NVIC_SystemReset(). * If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset(). * + * @note It is recommended to either perform a reset in the fault handler or to let the SoftDevice reset the device. + * Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripherial may + * continously transmit packets. + * * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback. * * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. * @param[in] pc The program counter of the instruction that triggered the fault. * @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details. * - * @note When id is set to NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time when + * @note When id is set to @ref NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time when * the fault is detected by the CPU. The CPU program counter may have advanced up to 2 instructions (no branching) after the one that triggered the fault. */ typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info); @@ -306,6 +321,7 @@ typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info); * @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated. * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level. * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid clock source configuration supplied in p_clock_lf_cfg. */ SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler)); diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_soc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_soc.h similarity index 85% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_soc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_soc.h index d7d3c80..0d29293 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/nrf_soc.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_soc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -48,10 +48,9 @@ #define NRF_SOC_H__ #include -#include -#include "nrf_svc.h" #include "nrf.h" - +#include "nrf_svc.h" +#include "nrf_error.h" #include "nrf_error_soc.h" #ifdef __cplusplus @@ -63,7 +62,7 @@ extern "C" { /**@brief The number of the lowest SVC number reserved for the SoC library. */ #define SOC_SVC_BASE (0x20) /**< Base value for SVCs that are available when the SoftDevice is disabled. */ -#define SOC_SVC_BASE_NOT_AVAILABLE (0x2B) /**< Base value for SVCs that are not available when the SoftDevice is disabled. */ +#define SOC_SVC_BASE_NOT_AVAILABLE (0x2C) /**< Base value for SVCs that are not available when the SoftDevice is disabled. */ /**@brief Guaranteed time for application to process radio inactive notification. */ #define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62) @@ -72,21 +71,21 @@ extern "C" { #define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200) /**@brief The maximum processing time to handle a timeslot extension. */ -#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (17) +#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (20) /**@brief The latest time before the end of a timeslot the timeslot can be extended. */ -#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (79) +#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (82) #define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */ #define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */ #define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */ -#define SD_EVT_IRQn (SWI2_EGU2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ -#define SD_EVT_IRQHandler (SWI2_EGU2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. - The default interrupt priority for this handler is set to 4 */ -#define RADIO_NOTIFICATION_IRQn (SWI1_EGU1_IRQn) /**< The radio notification IRQ number. */ -#define RADIO_NOTIFICATION_IRQHandler (SWI1_EGU1_IRQHandler) /**< The radio notification IRQ handler. - The default interrupt priority for this handler is set to 4 */ +#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ +#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. + The default interrupt priority for this handler is set to 6 */ +#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */ +#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. + The default interrupt priority for this handler is set to 6 */ #define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */ #define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */ @@ -96,6 +95,37 @@ extern "C" { #define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */ +/**@brief Mask of PPI channels reserved by the SoftDevice when the SoftDevice is disabled. */ +#define NRF_SOC_SD_PPI_CHANNELS_SD_DISABLED_MSK ((uint32_t)(0)) + +/**@brief Mask of PPI channels reserved by the SoftDevice when the SoftDevice is enabled. */ +#define NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK ((uint32_t)( \ + (1U << 17) \ + | (1U << 18) \ + | (1U << 19) \ + | (1U << 20) \ + | (1U << 21) \ + | (1U << 22) \ + | (1U << 23) \ + | (1U << 24) \ + | (1U << 25) \ + | (1U << 26) \ + | (1U << 27) \ + | (1U << 28) \ + | (1U << 29) \ + | (1U << 30) \ + | (1U << 31) \ + )) + +/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is disabled. */ +#define NRF_SOC_SD_PPI_GROUPS_SD_DISABLED_MSK ((uint32_t)(0)) + +/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is enabled. */ +#define NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK ((uint32_t)( \ + (1U << 4) \ + | (1U << 5) \ + )) + /**@} */ /**@addtogroup NRF_SOC_ENUMS Enumerations @@ -104,49 +134,50 @@ extern "C" { /**@brief The SVC numbers used by the SVC functions in the SoC library. */ enum NRF_SOC_SVCS { - SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE, - SD_PPI_CHANNEL_ENABLE_SET, - SD_PPI_CHANNEL_ENABLE_CLR, - SD_PPI_CHANNEL_ASSIGN, - SD_PPI_GROUP_TASK_ENABLE, - SD_PPI_GROUP_TASK_DISABLE, - SD_PPI_GROUP_ASSIGN, - SD_PPI_GROUP_GET, - SD_FLASH_PAGE_ERASE, - SD_FLASH_WRITE, - SD_FLASH_PROTECT, - SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE, - SD_MUTEX_ACQUIRE, - SD_MUTEX_RELEASE, - SD_RAND_APPLICATION_POOL_CAPACITY_GET, - SD_RAND_APPLICATION_BYTES_AVAILABLE_GET, - SD_RAND_APPLICATION_VECTOR_GET, - SD_POWER_MODE_SET, - SD_POWER_SYSTEM_OFF, - SD_POWER_RESET_REASON_GET, - SD_POWER_RESET_REASON_CLR, - SD_POWER_POF_ENABLE, - SD_POWER_POF_THRESHOLD_SET, - SD_POWER_RAM_POWER_SET, - SD_POWER_RAM_POWER_CLR, - SD_POWER_RAM_POWER_GET, - SD_POWER_GPREGRET_SET, - SD_POWER_GPREGRET_CLR, - SD_POWER_GPREGRET_GET, - SD_POWER_DCDC_MODE_SET, - SD_APP_EVT_WAIT, - SD_CLOCK_HFCLK_REQUEST, - SD_CLOCK_HFCLK_RELEASE, - SD_CLOCK_HFCLK_IS_RUNNING, - SD_RADIO_NOTIFICATION_CFG_SET, - SD_ECB_BLOCK_ENCRYPT, - SD_ECB_BLOCKS_ENCRYPT, - SD_RADIO_SESSION_OPEN, - SD_RADIO_SESSION_CLOSE, - SD_RADIO_REQUEST, - SD_EVT_GET, - SD_TEMP_GET, - SVC_SOC_LAST + SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE, + SD_PPI_CHANNEL_ENABLE_SET = SOC_SVC_BASE + 1, + SD_PPI_CHANNEL_ENABLE_CLR = SOC_SVC_BASE + 2, + SD_PPI_CHANNEL_ASSIGN = SOC_SVC_BASE + 3, + SD_PPI_GROUP_TASK_ENABLE = SOC_SVC_BASE + 4, + SD_PPI_GROUP_TASK_DISABLE = SOC_SVC_BASE + 5, + SD_PPI_GROUP_ASSIGN = SOC_SVC_BASE + 6, + SD_PPI_GROUP_GET = SOC_SVC_BASE + 7, + SD_FLASH_PAGE_ERASE = SOC_SVC_BASE + 8, + SD_FLASH_WRITE = SOC_SVC_BASE + 9, + SD_FLASH_PROTECT = SOC_SVC_BASE + 10, + SD_PROTECTED_REGISTER_WRITE = SOC_SVC_BASE + 11, + SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE, + SD_MUTEX_ACQUIRE = SOC_SVC_BASE_NOT_AVAILABLE + 1, + SD_MUTEX_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 2, + SD_RAND_APPLICATION_POOL_CAPACITY_GET = SOC_SVC_BASE_NOT_AVAILABLE + 3, + SD_RAND_APPLICATION_BYTES_AVAILABLE_GET = SOC_SVC_BASE_NOT_AVAILABLE + 4, + SD_RAND_APPLICATION_VECTOR_GET = SOC_SVC_BASE_NOT_AVAILABLE + 5, + SD_POWER_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 6, + SD_POWER_SYSTEM_OFF = SOC_SVC_BASE_NOT_AVAILABLE + 7, + SD_POWER_RESET_REASON_GET = SOC_SVC_BASE_NOT_AVAILABLE + 8, + SD_POWER_RESET_REASON_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 9, + SD_POWER_POF_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 10, + SD_POWER_POF_THRESHOLD_SET = SOC_SVC_BASE_NOT_AVAILABLE + 11, + SD_POWER_RAM_POWER_SET = SOC_SVC_BASE_NOT_AVAILABLE + 13, + SD_POWER_RAM_POWER_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 14, + SD_POWER_RAM_POWER_GET = SOC_SVC_BASE_NOT_AVAILABLE + 15, + SD_POWER_GPREGRET_SET = SOC_SVC_BASE_NOT_AVAILABLE + 16, + SD_POWER_GPREGRET_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 17, + SD_POWER_GPREGRET_GET = SOC_SVC_BASE_NOT_AVAILABLE + 18, + SD_POWER_DCDC_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 19, + SD_APP_EVT_WAIT = SOC_SVC_BASE_NOT_AVAILABLE + 21, + SD_CLOCK_HFCLK_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 22, + SD_CLOCK_HFCLK_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 23, + SD_CLOCK_HFCLK_IS_RUNNING = SOC_SVC_BASE_NOT_AVAILABLE + 24, + SD_RADIO_NOTIFICATION_CFG_SET = SOC_SVC_BASE_NOT_AVAILABLE + 25, + SD_ECB_BLOCK_ENCRYPT = SOC_SVC_BASE_NOT_AVAILABLE + 26, + SD_ECB_BLOCKS_ENCRYPT = SOC_SVC_BASE_NOT_AVAILABLE + 27, + SD_RADIO_SESSION_OPEN = SOC_SVC_BASE_NOT_AVAILABLE + 28, + SD_RADIO_SESSION_CLOSE = SOC_SVC_BASE_NOT_AVAILABLE + 29, + SD_RADIO_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 30, + SD_EVT_GET = SOC_SVC_BASE_NOT_AVAILABLE + 31, + SD_TEMP_GET = SOC_SVC_BASE_NOT_AVAILABLE + 32, + SVC_SOC_LAST = SOC_SVC_BASE_NOT_AVAILABLE + 37 }; /**@brief Possible values of a ::nrf_mutex_t. */ @@ -182,6 +213,7 @@ enum NRF_POWER_THRESHOLDS }; + /**@brief DC/DC converter modes. */ enum NRF_POWER_DCDC_MODES { @@ -232,8 +264,8 @@ enum NRF_RADIO_SIGNAL_CALLBACK_ACTION NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current timeslot. Maximum execution time for this action: @ref NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US. - This action must be started at least @ref - NRF_RADIO_MIN_EXTENSION_MARGIN_US before + This action must be started at least + @ref NRF_RADIO_MIN_EXTENSION_MARGIN_US before the end of the timeslot. */ NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */ NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */ @@ -476,7 +508,9 @@ SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void)); */ SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable)); -/**@brief Sets the power-fail threshold value. + +/**@brief Sets the power failure comparator threshold value. + * * * @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS. * @@ -485,6 +519,7 @@ SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable)); */ SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold)); + /**@brief Writes the NRF_POWER->RAM[index].POWERSET register. * * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERSET register to write to. @@ -539,9 +574,7 @@ SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_ */ SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret)); -/**@brief Sets the DCDC mode. - * - * Enable or disable the DCDC peripheral. +/**@brief Enable or disable the DC/DC regulator. * * @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES. * @@ -550,6 +583,7 @@ SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_ */ SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode)); + /**@brief Request the high frequency crystal oscillator. * * Will start the high frequency crystal oscillator, the startup time of the crystal varies @@ -791,6 +825,8 @@ SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp)); * and the command parameters). * - The data in the p_src buffer should not be modified before the @ref NRF_EVT_FLASH_OPERATION_SUCCESS * or the @ref NRF_EVT_FLASH_OPERATION_ERROR have been received if the SoftDevice is enabled. +* - This call will make the SoftDevice trigger a hardfault when the page is written, if it is +* protected. * * * @param[in] p_dst Pointer to start of flash location to be written. @@ -801,7 +837,7 @@ SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp)); * @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned. * @retval ::NRF_ERROR_BUSY The previous command has not yet completed. * @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or higher than the maximum allowed size. -* @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location. +* @retval ::NRF_ERROR_FORBIDDEN Tried to write to an address outside the application flash area. * @retval ::NRF_SUCCESS The command was accepted. */ SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const * p_src, uint32_t size)); @@ -824,6 +860,8 @@ SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const * they will not interfere with the flash access. This means that all interrupts will be blocked * for a predictable time (depending on the NVMC specification in the device's Product Specification * and the command parameters). +* - This call will make the SoftDevice trigger a hardfault when the page is erased, if it is +* protected. * * * @param[in] page_number Page number of the page to erase @@ -831,7 +869,7 @@ SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error. * @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page. * @retval ::NRF_ERROR_BUSY The previous command has not yet completed. -* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page. +* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a page outside the application flash area. * @retval ::NRF_SUCCESS The command was accepted. */ SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number)); @@ -842,14 +880,19 @@ SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number)) * Commands to set the flash protection configuration registers. This sets the CONFIGx registers of the BPROT peripheral. * + * @note Not all parameters are valid for all products. Some bits in each parameter may not be + * valid for your product. Please refer your Product Specification for more details. + * * @note To read the values read them directly. They are only write-protected. * + * @note It is possible to use @ref sd_protected_register_write instead of this function. + * * @param[in] block_cfg0 Value to be written to the configuration register. * @param[in] block_cfg1 Value to be written to the configuration register. * @param[in] block_cfg2 Value to be written to the configuration register. * @param[in] block_cfg3 Value to be written to the configuration register. * - * @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice. + * @retval ::NRF_ERROR_NOT_SUPPORTED Non-zero value supplied to one or more of the unsupported parameters. * @retval ::NRF_SUCCESS Values successfully written to configuration registers. */ SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3)); @@ -914,13 +957,39 @@ SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_ * * @param[in] p_request Pointer to the request parameters. * - * @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE. + * @retval ::NRF_ERROR_FORBIDDEN Either: + * - The session is not open. + * - The session is not IDLE. + * - This is the first request and its type is not @ref NRF_RADIO_REQ_TYPE_EARLIEST. + * - The request type was set to @ref NRF_RADIO_REQ_TYPE_NORMAL after a + * @ref NRF_RADIO_REQ_TYPE_EARLIEST request was blocked. * @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid. * @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid. * @retval ::NRF_SUCCESS Otherwise. */ SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t const * p_request)); +/**@brief Write register protected by the SoftDevice + * + * This function writes to a register that is write-protected by the SoftDevice. Please refer to your + * SoftDevice Specification for more details about which registers that are protected by SoftDevice. + * This function can write to the following protected peripheral: + * - BPROT + * + * @note Protected registers may be read directly. + * @note Register that are write-once will return @ref NRF_SUCCESS on second set, even the value in + * the register has not changed. See the Product Specification for more details about register + * properties. + * + * @param[in] p_register Pointer to register to be written. + * @param[in] value Value to be written to the register. + * + * @retval ::NRF_ERROR_INVALID_ADDR This function can not write to the reguested register. + * @retval ::NRF_SUCCESS Value successfully written to register. + * + */ +SVCALL(SD_PROTECTED_REGISTER_WRITE, uint32_t, sd_protected_register_write(volatile uint32_t * p_register, uint32_t value)); + /**@} */ #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_svc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_svc.h new file mode 100644 index 0000000..231a54f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/headers/nrf_svc.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2012 - 2019, 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 NRF_SVC__ +#define NRF_SVC__ + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Supervisor call declaration. + * + * A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception. + * The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice. + * + * @param[in] number The SVC number to be used. + * @param[in] return_type The return type of the SVC function. + * @param[in] signature Function signature. The function can have at most four arguments. + */ + +#ifdef SVCALL_AS_NORMAL_FUNCTION +#define SVCALL(number, return_type, signature) return_type signature +#else + +#ifndef SVCALL +#if defined (__CC_ARM) +#define SVCALL(number, return_type, signature) return_type __svc(number) signature +#elif defined (__GNUC__) +#ifdef __cplusplus +#define GCC_CAST_CPP (uint16_t) +#else +#define GCC_CAST_CPP +#endif +#define SVCALL(number, return_type, signature) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ + __attribute__((naked)) \ + __attribute__((unused)) \ + static return_type signature \ + { \ + __asm( \ + "svc %0\n" \ + "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ + ); \ + } \ + _Pragma("GCC diagnostic pop") + +#elif defined (__ICCARM__) +#define PRAGMA(x) _Pragma(#x) +#define SVCALL(number, return_type, signature) \ +PRAGMA(swi_number = (number)) \ + __swi return_type signature; +#else +#define SVCALL(number, return_type, signature) return_type signature +#endif +#endif // SVCALL + +#endif // SVCALL_AS_NORMAL_FUNCTION + +#ifdef __cplusplus +} +#endif +#endif // NRF_SVC__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/hex/s112_nrf52_7.0.1_licence-agreement.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/hex/s112_nrf52_7.0.1_licence-agreement.txt new file mode 100644 index 0000000..9225328 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/hex/s112_nrf52_7.0.1_licence-agreement.txt @@ -0,0 +1,35 @@ +Copyright (c) 2007 - 2019, 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. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/armgcc/armgcc_s112_nrf52810_xxaa.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/armgcc/armgcc_s112_nrf52810_xxaa.ld new file mode 100644 index 0000000..3fe4161 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/armgcc/armgcc_s112_nrf52810_xxaa.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x19000, LENGTH = 0x17000 + RAM (rwx) : ORIGIN = 0x20000ed0, LENGTH = 0x5130 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/iar/iar_s112_nrf52810_xxaa.icf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/iar/iar_s112_nrf52810_xxaa.icf new file mode 100644 index 0000000..aa77655 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s112/toolchain/iar/iar_s112_nrf52810_xxaa.icf @@ -0,0 +1,37 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x19000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x19000; +define symbol __ICFEDIT_region_ROM_end__ = 0x2ffff; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000ed0; +define symbol __ICFEDIT_region_RAM_end__ = 0x20005fff; +export symbol __ICFEDIT_region_RAM_start__; +export symbol __ICFEDIT_region_RAM_end__; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = ; +define symbol __ICFEDIT_size_heap__ = ; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; +define block RO_END with alignment = 8, size = 0 { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +keep { section .intvec }; +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; +place in ROM_region { readonly, + block RO_END }; +place in RAM_region { readwrite, + block CSTACK, + block HEAP }; + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_licence-agreement.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_licence-agreement.txt new file mode 100644 index 0000000..9225328 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_licence-agreement.txt @@ -0,0 +1,35 @@ +Copyright (c) 2007 - 2019, 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. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_migration-document.pdf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_migration-document.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ef0b059cdf386dbb9e340900360c72bb78701561 GIT binary patch literal 161059 zcmdSBWpE_Tnx!dbE-|abtQ4lW#LUdh%q*3dnWYkzn31)$> zx2H3yabN7+B%R_x7jf;n;|oi0uq5;dpo$MJ=qIO&l3T ztqq(_giVa>j7=D&O>E7a&4~d_001AKle43VfeoDdk7QMu*mZW4&NDTH$0QJV)rID@ z`6ij~=qLH7xF;mkaGLpa492rk3Xd<_=W-WuNygM?D|k=&sLvsGTRbrj2k&jS-eGrX z5I7Z*SN&tJ=e!<#H~p+3fml66EgvTeL?8EEZ)ZZ`dC#TM{vY@8f|A~F zU6)6N?Z<&LerVdC3wv5cNHYbe8zU}SC~1F~;~`r`=P>#~!rsTE$s^ltc|}zHpeR{~ z-A6@gVXKH}AbAVJlpBs1fUTGlto2TtHAnmWAZdE4&^I&K8Obo_Qm@PMH+b02rYl zn79*Ot3+U>Hx`(2Xv#wRenghd70nwXjem$<9b)4k)_?q|sWLcSgMl~L5J#U>chcOk z=rpfi#u8rBFyL{hRG!S5+DA5n<~+G8mJoXE{sJ0KFx}pG-YDaV6g!s4qqn0l6%})$ zLf-}pLw*HEzSI$@Nr<2(7Lz%gLZm;f5-QE@WEaBhtpx?SltO`EjolMiaew8_2)Bi* zuCr0*-mfv7myC;iX}QWlUcuRAMjnP~U%>NNnRrF)98Eb5OgvkpAaNMHGPY4qq&W{36D(kV=BzFY5fV-b&O#kx*o+JRL@i`~f8d0SoI0-%_!P z=Y3{2;6{272)Ni8i%d=G6+NG2Hv+G)h+^Olei`?*MD%!8?p1i~LC;CI#+DPQPD+PX zo8Lfc9%6`Snjf2Nox;J5=BpVZvH#k3^wJZ5r~(_nLwe~dlQ>M#SWw9PduaovgP&BX z$w-n>J?qG-__?Z|+~l21b8;~ywT~%dj@0HYZ8xGr`vy8;{9G^YVwz?BGQ;X|#6Dr3 z)4D1=*}VcR6z)cbMV9ee3U(X~Zt|6PG*uNSaKm^Z{i2na`@U=3duE*W*_IhN;Cq%{ zr&nbcb3Hz)@yXH3O;cOS=Ix{A?Sp*W#kPC78`H62pmZ^XRQzptF*}u%{%-Ph^_8gp z4Y3Z+#Mb!VM*p9)zi6GlZ7Cp#BMBNL}T zY>{`gGg2~fCe~v7gCAl>WfOO2Vnzv@KVK94x1-R%9VK)aMgO$;7monM%>QUol$n_2 zf1I!ov;K9$_viDc563^<60`r~j*N-1g@K@*yB5=*OCT$N0SF{!<78uC2I}zf{q^{N zJv8voz5kqb96+|ev2Ie`#wk-2g2 zAUu&k{+nm4;4=Fv?>DVr6p@cnHSLFHHFWEIMRhuiF+WP&MQM1d6U-B?-s;Hc+w-rJ z{Z!vM*M$W#g4T1T?~WrGy_=z1AwwqzE{77DApnZn!oH zC>Ix+b1P2T_Y@?Fx&2(JlKmkXW3?)v11|FOu2G{=m5(ZXB%%nvR+WIy;&TJwHYl z_-d8lc5+6~_L;Za%&RT0!$SMQ%6TD@kF`G!y9=)&ugMV?Eayq~ih^4P#N(l<53PL* zA|I2Dg?iX;2LYmoE-I|6`*Tam;Wo|*ly0MdqV)l08n+;G z)OASo5^{+1du&6RZs>?ZN2X+B&H-1;WKEPK`z&+3Kik|v;%QOihC+oe(x(SRjll>OoXWAcwa`%IF+6Y{r z5x%rb6?UkLL88-9{bcoz!w?|!F@>y{$D>kO!9*Bi3k=%qNq9bFA2tI9-ZuwjvPtQG zsdVg)O2DAIbDq}?@*bEbpj)zrA&B8A+Y)W5UtVJ*R(~Ch2nO4@IY$U^PJHJ4BW#)tc>UIk=**plp5HQ2Bg2xxn4Z!{6O;&0q$9<$k-BnbVOi+mWbNY=hF? zL?=XP2`wVF%FUglqtlfmTaavvb2W|4A3i~0gvUQJpC_-5MDD3|2lGbOfro>v*1wxq z=&m_c%7K}71bk~^ zMq9hzGcay{L|i{Wz!h#{lrvo}=Bt@6A9t%4LgfY-R;@j32Uit?%G!ILxGKavyhrz; zJ&v~Qx01)Ss>WI%&_~}#z>1aYwE3(WYzbr?%|3Y(N9 z)tz~;*+i~Z#zlhVC$hJ@KCBxBkD%UlT3o-VOO1Hsj?gLA=XX6gzsR|1DZVHOUWh^8 zq5V3OhCR{NM;@J&FFYXuG`^bzGt$2BSnVn0GMTW$p(;V$R~2}K09M_{Mei>K>jlP~ zI7n@!sG2w5V|lLXW*9T`zIVR^RDNk9&*>t(b2*eRVC038{8sfnB0twUb>QG}o$Q7Y z--<}i$@cN&YkJV4VSHMGx}CrR$2A2BrL^Yu7VX~(A{ka6J-yXx#p~DA9^x(uPc`L* z#@jY7NXhhJHJ0US4H=7+JB;MRvpE?Z+Vc!>E$YOuMYqRR_apd6)S`} zqi+a|dG}$apr_SK-b+3~)*bEMUB-KiwAn6oUTizSWejCTyHg|0qVe%sHN8E=vfT-t z13``qrh%4hbr4zEpr?Lr)EQQ6}SptW!~!9;zJN+V8-| z7ck}qV||i#z&vj+LFey%UO@xN@{SKbn(;q%1)$BNJS@5S?fR{XyT>i?OF&nU`D z%<)%m{|`$);4fY9pVxjS7U17&znYHI8W7#*clC@?s55(n$!HVLx@ibIS)wf(Rm=J+ zEKW2QygfWSo9v?j$7dmbqZ%gEeo)oQAqf+x-mcf>FlU=%m&TRgxTx)pVdzh$Ca%1P z*%#B*m7=c5k2?H&P~T5OR6HH6W;gbTUgazAd~LZY*xOned0$oZ5@xSs5$ZRD3#Ryt3v#t*e({vMKLj-Qw_nwch6bjucUI*LldPQiY$yF)Ri82 z*4CI)W-CW*VmZ|t*kTMMW$jMm$W%vGUaG73-Z*L2XO2G03oq7%|qn2@tbH9d8MFpT>S_L z$REI8df%$jz>IsCNXk;5hRYIk=xBy0xLBOo zyYP%VRCbJ+ml^BvHI)OI2+H~F9;a2eCyl!q=@I=2Vp3JQcR6xwEHzeTWO#>_UCb)^ zQFO0M6#tRn6V(ssxTD@CsVsKc3&Bg zHrPJcA#~}`02vWvqIU5%FejWq{dSN@^JkS2R$XHWO^}oF%#YTV6CKz7sT+$G!Z&u5 zO}X7lA2aMINMLSzKxKyVx8}=vu%%Ryr1Fx1228ku#H`79kA%Um8mP4p`okz#OCB{t zIz#!rXCaHshX&=^IieOkiQTzs>){Bo6ZvyJYFYwfKCDjuHUqQ|qpOPf#!(@aBI%3; z9^PEZ3Up2timEgoky|=010wB|T-~92KEIDd@7LZR8=n@qtwOVQ<2BUN96Hbrw@n!s z@Bw(Mn}Ho+&|djVz@6e0ptt^_!-G!yXif6O;1681H2S6|mZC_mG_^f1)=bPK2z3_g zk?IQrJ@}jU_`sh~IWf8H*F2JQ24^HvhC-$UPq&S^6YefNdWhPa!HLT!J}EJYqdpAr z*|;YU;W#nl3j<5Q#TiaM-u823E)puEm9Hn0c)}&ryhx-g#fab72EW}Or(!YnNh){J z+~=RTRIj~{Un8TMCc;voeZ6eSOQo05`elD^7qW0y?WgR2pY9$wwa8Z+7U>fxzb;VK zZbpFGci@NH{Z<-fx8%|Xetr{;&t(C@jf|mG3Wbb|K6^qNV555J#YrPiN0boHssek% zd#-Y4+gNUbW4O|Xjb{cc2b8mJJ;W4!t6wjq4$5O0mmOMxa~NJJy@q&e66I|r|=Km+TY0MpiOX8@%yGt*Fb?G1#Wq>1ZQ2hfDfp{==+&ieO?aj17&>Du|ju6|_Pbr5W#~AlZT!iH1hGWD*<^#)z9P z4tCb}3BXba->9!Y1@z}>lMdncrluqglHu#uhYcX%1z*)P+OKHhvR>2)ia4*(k!%>$ zC&`Ca2KTcYg$T8ZMv+=?Q-=REwUC^fk(WXhHbo+(YmCpBXhA4~JIVDaV;2#6^mqRsph&WEIgkP3iILQ&KcqE8;-uS){-lNlo+o*TfPb$m!|{ zSg^;~$nXJ_Ed>Nldx`GDQI+Py6$3FE65vHTsw3ZHIALMjCSXYy09LzclWD#3RV2G% z=}rkV1gvIc(R8eEJZ+{(^!N=aA=2#?@~8xjJazGfDPru-sLA#VrW5v5%V7>dlY(d= z+}1-9)}=Q%UYY4a@M4vPBuW&o6?>fKJU<_?nR(<_I&65z@#}F|Q07?o=10m7p}v7H z+t)7MCh2b$$DjYGo0rY-)Y!6JJ1;_$U-D=?9V<$S_WJs(Ymx>?6QSx%@FTLSl)V$b zlP?WFOOHsfYiy0~N<_<*S65y`rw3uslf1xTDWcF^O94byF;ZK@?4;$3`Kc&J|6Q88 z(25e-(L=8_d%6x$3@<=pJ|4bZP#DlY=g6Abci1-KIg6GrH2oE4fJa$b$dbr;? z;?zH|Xjg6If7Wj4$b)^_^rGokV<5xtQOD7d;*L2{8pztC1>4VWAjgW^%EbiqS)Oh2 z3QX4HvS+z}E+JDKh)r=a zJSx;V%ug(#+wlp}^%^~mWyE%uvN2W_-N{8puFf7j@lO2K`Id2lHz9LJ*Iin?N3db- z*_eklS@%h0yxG%KLDOR!W>P@QaQ50XfCX7m^Qw{`cu_W?7T2i$<4Lfco|{A}_j_R( z=??>*@MvonX<=C%OlF$aeb!QJ1rZfhZhG!0~$Y^5qULQh4Lv@m|WW! zvC@=qW=aIT9+qvJrL&?%t%S_>QX3k#7GFU73ucd&k__L4$wu3$!KSkg^%YN)_D;kE z1N%B|(Xn4g-B%Zt{orvu7#d5L!m9OKzVT0zYF+Ip=4XPh;JU6)+!u>Kpq|PT>oy-* zS0LKkw5vssIl#Cn^=obIO>UurFf0okseOLfN?3E9B4Sppk+|fHr@Sa4CwIGbdwzns zkmiv56T1K9IQ<(h|EJys{0~3s|AfW$UlzQ78D;+|@BbICOLbj#{TqtUc6C}Y4ROP{ zXJ=Q*FClxO+<)A7N;qktD_M7 zmLUHI@v(Nl01QA`jZ1mvT?mQ71b+i`_m^9l zgA8tu05&nipq863ZgC=O6!?kgPheV9zek+R9KrAMvPWYyrDdvmsc^0jrT|UxKm{FI z5)B>(O1eF@wyHew7q=ld?t!m)T)jVS^BH z9b7Z3(YUX^UG*l(u1VQ_e6r4tftxnoZ1GyCm(l#$sFPY2$hrnJH?gwpQv9^kaY1Q5 z(H@NHp7&atNU&BH4zN8FS>su74$Od$kIQvO!5Swz=Vp{)r|Pt$EwYkke^$rb%U+{Z zeobyv<~?!QsqlWxE5;m092}C4&+)tg2F4S`dPT2G;6J*Ki5>5|<3l7KKjl1t%;g{L zxrg|odGzX^n0(*1JL_$giQaP$eb+JfK~C_%_Mhho72v`VXkYc$NZJ|_Xn=nAfU+p) zgQ+`%$*6)C`v6Mk;|%#ixj7{CKoAwW-OvU2LfmPf_j$v;6VXrxZ@zo_00MFAPT*H( z^7vIY%y)`)d8RUz0Ud#Xi7BBvo>K~U8{B*@vOLH0r@Id8Rz420eBE{)Si_g`%NML! zs=P7~Q%QMPjb?exNiLWsokL}72J22`kiT~j8P>riy|~$EC9-T$y5}9ZwAA#-E9tvu z95|XeM)g?ChV(~O;a50UpE4(4e)5J(1mLE*J9(P~4K z{bWUloc0DxPmq3}=JH>3v9I{j;&Q3@7h9FzPpKhe)6n}Ca&I{ek~kUUYqV?V0-6mB zHndVy5-JS_Bdv8J3UoM3T=?IpI(_ED%vcPeGVhg+ za8FYdRa1L@$WA`?<|*fEVe9In`Y|4Np8u?h&gX5}tX{+J#uHQ-Z2ayKwNn`P``vK* z&V_~Bp}B6kn3!L^@ro^>4CUUr!Cfpp>PsgBWB|SqVX_r>>H_YV*e!8F3dLLk3H|o2 zCY=xn0ZVvvK;$Q1hcCs2Ru-QV*^Bw~>EMR?rUai3i$3@Dy6AH7U0f@YLm(1jR8#5| zO_x>KrT~A^V~^gcH^<3-!zK0u30uU^g}i2)xb+lU;fnT(ja=g8qGBFRXT6@<4!vqn zF_V!A6Yl=3uy#5XQyJJ1^>fVMswiJF6@w>tBDlw6apc^*35@v;PUGu-)!c*XE=ocb zzVgCYGCof+iIV>oIF;-SFDFi#55h66OLauGy^8G7!^&Z8S<2Y3lfOZfmw!a1cB4zA_6Uz$eO-i-ge*c1f zdZ~6GH>3)6-!5TWHm^1=N&Wf>y z^t^y^%XK`Ui9tU&S}WY06!Bw*T>D#EJGv19H>;yQ`21A3kFJ1h*ZN2@kN zb`VSJy=lXWLW8uVwiu_k(mwa5?42H`*2^W^0|y5}Ac-qBT)*g+%|&E(;kY7?cmAx} zSh)*bP=e|HBcb!kIbO64k?3xwC0ULA!O2t+l-nX(L%R7}i9bzOSR8wN!-7v%qs3Uc zTeHb+s2CGH8ZHXsj8JdV&pUT73{miR`kqnY^03Bba+s&z%VgvcVx7mA$=~m7N1N_^ z9qDy8HNG<){+l@wz&?5}R+ZmgHHxXvpuCA^UQ5 z<-<^KT&8w(HB}UDuk`RSC$f4cXWH32k73~lW;Df{Lx22a{>+@TH&7w%efBFoSIG)b z%|YQx+qF;G^%>M*6WsBg5n8A8bL5&uUX`Tq-v_^;)m%pA;r zs}C3IGD_>>f35wPu!t;J5%@W4RtUtVQ!lQuuNet}w3J+7rn*rh1I?rQczqO4VMU{0 zd;Ha7;Gm$oK40Cg*L@oQro?%Tfq@g_&xZGGH29FrI3_1DNYjXLUt)g3;{B;ZLi39@ zb(sb?a8&Px-fffn>qsAsz=tr&n^OhqBonH@f^d>y%e~oHOmo=qEDU152CL@8@b90_ zsD9Vocjn!Ywa$p;F(9lkwnAiw7G>(o5OPveQo~7by5@j*c(YUW#zFhXF`4Fg0T?s4 zB6XxeR|`4#btpXo=}uRTsy3w$)guixX-$J(Ho$I%J^uI+P^R7g8;YO6c2j7&u|*g; zEGI{q1*TSVJUk2;`jLkL11m;Qk^c+>Y?Hq_^r2=y7dFM)`pG$V-Qa>~(Y}75BOi&t zPp0Crn&dyGC{<44P8u2ns%8bfM@ls%Z6rUrHw|b<_>HCHkeGh1c>ysMgZI??Q5mQ zjb1NBUlm%AdbzO<>1cV9<{IL__Z_lr#6qE}q>xt4R@?8kkaJT{6=KuwtPNbT`JF{E z(Qa%{N}X#Ut*c8_TOYuY`RBy7>vRpItUgKmtr-O3%^2w=1+*?x*4dF>@yp@LWhsj+@=Qgk@nP|g3n7bN_<8gR=eGy7BqvA*1 znDvX@K?f~Wz2#pSOA!m`)T-}$7K>orQ{}7#o!O?QSQd*NaB(!T6Qu?zBuj)+>w=Ag zbKISv?x}dkSvSglQH!VwgOuDTIE*m18p&HAj5Z(VmuYujG9-nB_s-57m#b^m`SjD>#0>TwR`mJ#*{2 z7#qx^a1FyY^Cp6}Xh{2Hh}k}CFFxkuK7H`&8HCz>qWkhQ`ZC~|=SQ7J+#AYI-g3r- zuP)`+yFwXZab@_#E_7Wk5IqvCkiS+P0nwszc1(^Cc3Z*55G#dE8rul7 zbYVFww^e;uqzE5v`UQSW*pg+TeZ3k8y@y7hzg!qw>&dUh@$*6!@Qhydpr43qiLW>@GLFm1W`AO(5+FdX^ED!#9I=@SteD|b|D_7q>*x@OU zzad!LY@w_4oASZxMgXsFv8!{^*Umgyg$~Uy^DG~|n9&bDB>SI%_&;}Hj!c@YxCFO} ze%>Q>AUNM8g}{EcCRYoY8PsV{B%(NsN;rta&=*m|kVK1~5Ka+f7E&P*YJla^$)=dt;XQt!$|?g1SFXL8fV_eIdoPJUV8Y5Uo!pZnsOIScrQcS` ziA)qrn#g0ej#W)=KM_kNNbj%?^-emJ{Qn93|5+Xe_&*Sc{nzFM%>QBz#>(sIS6mEHP7P)D}TP zh=YdDCs^(#_E!(vUD3?B>a^kU5Fq1^AlJMu+KY^`xG-Pxa8Bf&-pfUu7nU#i&ZxkY zI_gX9dAUeOdbtF8g-Q4L*uxA~!-y?OB>~z{PL=zNbyPS%4S3{+B3U(~BSl5X&0;-jg4B4`N<%p0@`K^9fn!=@>!DnnyU_B7O`Jq}fObsMl`8pqFgv;O z9_aIcimG~;G;}-;aUFL6PTa42NwXD*{t#rL<>NToB9w$)`mZfP5S42`Ec!n=+i3{q zs}jl`D=SjRY{a%f;0PC*8aH2jBy3Y}`tae4!j#9?w&W&W*-fR`8JE-9c2TyNG7Xm= zE1E#3T{tc*v@#pfL_iEA5Ry&%VUh%!Cw1gr{ovU&Xywory`>zc8)Dx`v(!d!%Oy)X zOEbbwZu!7F(Z_qGC|67tm&kO1M4{Bvx8$*XUk4VkxI{Ic0-JsJ^i&fieh@Ud)@LzM z7_BtA^-b)dGu<9ky901sTn(a;7HaU}+n1ouPAfA~PYqL3bR{%%J<>uK*q_CA4p(^C z&sn6>GX>;?NHNH#7+_A_u^F3y6evpn;u7p(>$Y4}jN?y)teLI|&e7TeZNf=UyUd@w(Me4-; zLeaGEJIgb_>*?Mzeh=mCamM4W3Sx(fFTRPI?tjaSdX(~0j5O~-aXEN9-knxlz7dKa zM|Bx=zdjtf{Xxc(o5hG#Z~WF07|Zf>Yli`9ErwvB@j1#fLHK;z1G5pnq zm9FoGoMEVekSH*XWiv`O?ho;{61oqpTa{Dwu(t!YPY|1%{d({=ML{2@cZ$5ZTlW)+~Ysu zkolj5VgG>5{};nB=6@*+W9MM{I|Nl_>@vThbY4}b8F{T<*1?|>?q>*>Wh{h;<5HK= z!2wAkNI(-xLO-xR7bXJuG0&S^_l1l#3=!_OIy~wL2}g;^5VS88#RSsgh{=u*;+e*R zuKM5|cHp_ZK!K@}7IMggWF zzdU|2%@-kPC8#*b$>^PHigJGg3R-Aku>}s<&*0-XSjl3rs|s;jDI4zWs`U=Ss!9ce zO{K{tvm*||ZK`<74MCS8YuG=MYyNWQZU~D!tS^_nswz>@zs41)>=AJX@~*#Mo@j@> z=dCXP$W9XSsyBan5r05fxuH6@lJ`46I+0(03<06lrPlnY;WW~+(c-s#fb-BUSCOG& z`{}z*txV0n$Nz58fnjY)KyQW1t=N=4$|335jp*m6;^Njg@cQ^7Xog{BZSuo%k*;cc z+~>EdfQ}_}i_zWJ4D^VX4iW->ULJH4#QFSzN|fSNr=Z@d`2PNmA)0n@?0UP z>6APCQeppnz{v?6Qx9mNa(DfUs_|qOodW#=SG% zd(b(&SZ1|PL|SfAi;Wg!pk>%we`Y949(5s}hFGt&`m99OO}y?TaO46)%86C3l5^W;8jz$}_Sbr2djt62*0 zAYo4cC5KQtYd(aqy%;mIx2S^#uG`QI|5)#gx-viNk+$Z9)5SFd zQKi`4^XA)J1Ie;I^H)@hQGtG`DLxj_#~v(dSojs;m1?Zu3q2ZN9fUAKxaJdybekVG zPQGy=seD*BIFm1I=hg_uTukVRg94T(l4d+#xy}>LYQa1{q&ko6xd-TVP{Um1QroR7 zy=12A6In&Ip_`;I#E*ge9j-GV4Mb61+^<&oA>yE{C2!akxQ2|rIxaYZS-CVqR!`QR zfYBYL@J`Buc|#{_Ym^iMsh!e)!p=}ukaT7oYG|WUqOKEgwvmycy`5@fyQv@h`Nom^ z^ZmwH3^_GT9R{*l64Sv~iKM|_%MSbFX2i?y2-=LYe}5KWjpivJJvrn$bW>d(($5v~*N{aG%=k3gC%4B+ybjZ; z@-z#25p`LWQ3G9qi2BCQB{8pCX@MG=K^_Tz<(i3kW7qD{Q*(R-B&3d7B7_hjUUyTY zOFoxRfK1G@C)K_8j`o30eU+HV5)?330%MBr3^TY5=}1Rqj4F;>SbJZlnQ3U=h8K5% z9bk5rL>!v0IbC7PoZl7kn4n>!Rv7fdwo}2ioZ!C5P1gKqjDABla?8_w+9a#ySUw4! zmm_h6w#(V;1gx`fp!BgpzlzCcjX^?}`Y;S!7(cC3!7 zEqw!<%~e8B~x0i80nGksYex|*s1xWhrz?xT-nULaGWL!fqprNjOX1I~J>wP1Sj zHQj^6rOi$E+k0-ZB77lA*O@9wM}pvn;eu0xV5hk0nEGoKI7Zuma2m)jlhC<*+gMJR z(q#iAFkIKP#r*z?6x{j*OOEewS`&1}3$}pzxS!x!lp`XMtv&c{C6r zyOqeeulbC%XPHVU2C@IXT1yS@Ie|3%HXnf> z=;t|`rz(XgBhd(7S{r!rP4otnoz8p7A}JE7$+y@+ycBc@)cP_v0*Sp@p;L8$6L(2; zAwRG(1vewX5=+qtIkiZuK2qcxDBiI2u*~RSr6j0}OuH5TZwzl_RCFz#c0GwZ~XSC@Knr zvQcile?Y>ZkZK}udc61rGQS9d36H4_Ongz*7pl4^ttk+(uMr!)wo8wTaY9f%uMS7` zjJ0iCq+!+A;$B_MvfuCH=~%9FEf6kirnn#F+#Dhn`xg=fYDP&lD=|RV#XZ^=_r`7V?gdmi{RKx>R&_0bWEIBJ0FxF#XmqHt| zgoAV!-6U|REf$3hlV$XGJ32^gfh=>S`Scbr4xR&Hh({GxK;o#5Yp8b z0p(o0!khg(#3#ZM`a2lCm@9lyI@ul%LsGRZK>V%0#*$y1;H_KK6ots>4n zdWUPGOBN|Yd30H@@pD3+w6e~Av1j+<>vNR!1=8Z_P@I!K=}V6gkOC{jc9}z4QjwoG zjwhUsWv7eU486? zp~|TukEl!=;bcQ!mqqh}p)%0H$^G~4X_p4w=aXoef^=t}ss?*qfA0TIwLOZTCh&N#}}Zm9&CV*O@uGYjok_vpFl|9l(2P zqDprGcl>?iIT6!gAD*9djoT4o>)IBw<1|_4-;k}3Hk1Q50n}>cbzwcc3U`+}<3S~o zU-iLw;x2(`WTE{{cA1#jy+8SDh&+e0bIoq@$cZe8=4bhg`oG(@o947)l~oQ=Hyl!w zlT2INmVCp!A zx+bL~tp|F$CDD3-8%)Pr$0XLFj_n7VAZpq-LDMp>)vWbwed0iEx*+QeOUESB3_fVc zAPa8SuMc1ztEL$lto#=@BuvvBY)ukHn7>umBMPx_78Ko#XoZ;E5Mmu8`rHA{xD1?StUZg0(BUH$VCEzF62oNVIeE5`A ztktO=YT@fHk`p{u7)Lq?Cu9-1DToY&tZVX07ai>C_nRW0gI;{2%kQbHW>_q5L!|MtSVA8{GmgzCTY6@Jt=ee&INHEOZg^6 zkK{bq&KrwGg((E09EO|B%`+2luK#xm$fNs{jXahQiFmM|=F zuRX^7;6GLn&gMlKp@xmkzVk&KadZpcZ8J{iuiu^A9w|BdIC;2u8ILBZEfPKyzsw9W z*oqUL^*;fo9N7?4+tJgP`hfVaKR{pN`&Qbju$Z*nJbm6Nwx9X7ijlq5Vi&!KO3u>q z-7T%mz@>B1X%w22h1)}nrE=#nPk6<#J9yUm`#xL^aI=6*hTw2q2al49uykT(-Pu#e zSVXoCJ^=pUyJ?U6o5yBS0%NVY#Sl;YN(zzHrXK`m(H_fi)W~`mEAxzt{yRXTA9`D| zE&*>Qkfz)Azj23v=)Xe;(2Y8V)*;1H=?PZpez}5o%x4dMo1$VNkEPhjyH`Q?hJW`Y zt~>(}bc6qKG6a?Qudn1gH;21X{zN{&i9E>rg@iO?Z|S!G!$2*V#RF- z1~t9mSfRmsP<@#~VGFohqXUBmj}m2M8QOR)+ofo-~{}Ab8e;jy5pZ0 z5%?Ud?Eunmav^%HwvyB(HYEtw73VC@5JD+P!s!{A86Dp_KK>|K2*}k4GB++9xt2dt zcISLgztrpOeWNZM%VPm{l&8MP>1?g7+1m21hZH$Q$k+eaPh*0jThq_CSptgU!z$(E zWnN4a%#wv!PaWY(DU>r?4ttkx_ebAhN5hu(l1xgmF~t~9WqE~Mdz%OMCwx5t0@`(4 z-3W|xG94u6==@#jFrwVikAtK3q)gia-5)88_N4^4F#^DrR+1ZRAx|mVFd(8>`;040 z7em_R)Zx?8*vn*D#rN46QrnZ6ID?X2W7b<(?1@w;AO!oNG+ybU*aAV$GYO*LMIj;% zsxH2?tdBdpJ1D^xwgPTxVST9?IMQijAOLa)KAL6c+ajjxjyzvq$mbhs6SL^b7=A7_ zqs>Sdsr7+h5TYnkpXv~dmpl7ToGv%E%nE+n$T6w)rAL|+q+owc2w7mB0di3QySs&u z=t4~^mOKaX8tp(2S3WDN^}BTsNvA8*WsfU3nPt#LpRPV`)7fm?8QB=N0j<;bqK*a< z(wLe}l+rm}5(1C7Wm5A8V-OM@SCEXf^b3V;0ssr%7&>CwtiBMGOC>6;ls~R^14+L{ z&%|RX9_j_UJZ8*IK_1DO892;oBlye!e&0u|=m;o;8}xuci_N!x{3K72@R#P`oV!6F zv)gz0WuxAOMksC`1@(f^a4C}HvO|=ks0>KULs9e>-U#!aLUo^0)qE0(ltUd|HTqLa zFt?F|UwsRF;vzpsqDVP(AuxJ~ovx`88%lGKxB)#K4`Z}IoCMhh=KTs?=VQaf;sEOe z3c0cvq+WSz-b{aMo9S$yTAKnlJYVR@*IOS<#pNIt?$~Y_TLy~MyQe+x%olw{<6bdQ zy~)0l#&JQ#C7;FJ*?Ou3R}o2trAg9Lt@!x%VKd=(j)0*FN;K9kWC))(p7eM8X@-xq zOLCZuNv~Dwi6L+>(uOE*hebLb%13Gh+)$5zz_?Jy)N#~yq4pc zu#39dcP*i@t+B%=gpCsTH99_Spi_8uirCZ$7Q`rQE@R8i9|W z{mGr(ZolO9ns=z8c`uJOw^T?BAMfl#n#pwv(?hDV8UI^^v90Y=^`J{G!aH6_@wV0$ zhP9R0qp>7YF@QTz627%h6#c73VY|5-ieSCNOWh`LLRPmR4GYJb8jW^OY}nFI>++E`D10pH*&bS$4OBhLL0;3Nb{D9U4Ps<+g~y%lwb8ldR3gm7xD`sM>{!Z8tye!x=F@x?SkziQa z%O$fSH!v41RhhC!IAbZicKPty64vn`bzOVyw%ydh5H-+{p%23(tm<` zZakzbez|?Q#B%o+8$vz5^g$xuY;9dx{^9y+j_soEVUGE7Mvl9F0q{@*R#GYy0>(ra zI(8jzy=KZ^1fe#e3*5P5G*dWK5)>b+*=|HozZkBY4Cm7@jKdSEz8tnCLi?AE)#vNK zn&gjg%nU@h(=k|+wHobI-8i&X!!g449IXe$guV<(q8TQWUT$^HBco^YvprAWS{lj8|eHX-eAX-gbJvK zv-J*5!w^yd@FzGVx20QF4~%qKboprj_z7@z+|zp*I#=r;w;6(?hO}H-G~WFE`Hi>hbe#0H8xIR zH0U6%uR>i!V?7jtF@>Br9{%Ap`Ti%j|K>*NX;RJLLNDvrr$Ytlu9%Y#=8_U zkt5gMpY&G=sah&;f`4xFUtf%1U^|TwZd?!FS)J)cqU^T+M*+g}w}l1&Ei<2? z*}oJx{NE8EEPqQd|2G1J9q@NE?Lx!G?vDWZsM2%D328c0S6F~wv<06dKI3YT#pA{a zDPmGicU@RbpdF`<$on+mcM*$7pcawEkb~sX2N<3KJcir7E@jc*dp)^ot*-@Rf%p_G zXU2w|O?>L?wHiCUV&neX_HUgcHtrUk9#;JbdESTc)GsGkaG}~6_v^Ar^rof`La zkE$Pi@2LL~U&M!Zy)$CX`K&(7x;h^W$qp3B4rN4X*(;qxmRqg@Fl6jz6i)1hkxK-H zvGO+Xl*UBYk9KQwHa*6xiI|X_aTaIJvOsf-HfB2MNi7ZMqx4bf>GJk>>&CbUV25S= zgYmCT8Pg5|#uSStl13Z>?Sjx|dvgl1RBCgKA5%GEPQ+_D$3wJ zkq!Da6|D0%ZP-^n=0Ij6LvNJvUfZF$zc|?&ZF9hne2QrNkfGKiiMv8eM1_gUj_@=V zWz)}RQ$@Reux*UIm_9V?3;%M#$_|%$nV22T7t<_%vvOCQO|j0K(7=so2gcIAyK-h- zhFrY(t5o18wV*Vgr&(8)T$_)CQZiyWT$+#nkMA@edyYi-;P1IZ9~#u?BrdoP4zeK1 zXUtQ;7^#Ba{1Mywm^v-qOIe1)7sVzo_<%Uvm?)`LvsB7wrCgC@xCTeESWB;Bzo5J7 z&oxmt*?dbLpkhMQ3vebZA(x>oV68!}3|LghvOY8{sgY*AFDO|hr?V`QLbL`!GDlb2 zn6`Gt$qGY~SAlaBj}a!9gq1J!M~u2a-YR$u2v*QIBe}v)AsopP9qgAy2R;0!M3G2c z5n83F<-T04xy8H}?%3b8wCP1aJ!2ktBh8s5N;#~W*ybAKa=$sX_2^&Eu}Q;fQeJ3q z!4~W1vug~v0`pUIPc;uOpRhK3J$hygjYc5zc1zWP$Y_(0e}0Z?2S4O|H|jXUyo<3_m5*kmWVXC|ly9W|m!COL?Zb z&WOI44NL1&qs>}flUs$UbrfVpJZdkW6 zE&#t_cvI}HGcl<23T*omZcT&V9vyES#2*VHF_i!4k@i4$B`y5W*c| zo4^ag&E366;RTkZ$^_`j71b3pQ}rN5S^kI+b<{bYMgs-XJ{eWKeX=>@kaRA^F64A@ zTsNdyT!Rk$71bTrlyNozegb_{tP$H`wW2qtn=Orp(}UUDn7Q>KBme@;~4KK zl18J7Idydep3e{~;k~9$bpe-#HAhFLnyEW~xven8-Czmp=(6XQW%L zy+raS_Zg2@U#!=hb&;Rw^Aa!M835})*-`(&r1HOZ)PLQj{=4j`|KLIR-|wglbS(cE zIiFPjUq9)qq=y54fz)K51{#uAafa>vm7tw>VS<5NwIWd}Fz@w@pWv0CdLX}!h_mp?>>4St*+7akpgtNV)`L0K=8*3< zx4P}$K{xXD``Vf9c0T?%N@SoWAoU+N4{G08h1Y^o2jZ5G^k}a0SvJ!H`R3chtudk5 zJPBR6cc)Ch)O!y0Z~oP;m0{%d$5lw6jzzmv8s6ewR>V+DSU|~L0gn&j+u-hsbYVKF zGX@gC*_v5yPh!MnrL#cH)QpOf zY(~C53bm_>IxW4ZO^G5BD^)+~#5z6}c!4Kf0{2ueNN4hkMp;0fl_tX9p%y=n+X|g~ zH|G1TtNJ?FtnIiKpB-(wZS0QkVFFG+{|PpH+~Z_TNbWHMAirP$^hYG14F?mxqaet~ zOAT~Gc}sHOLJ_ywel|jpv0(&LCW%<~p>&M~8~=sgVX5MzwlmXgQKSuc?u*|b2xoV_ zoB(6dAZZC?Xv7kUwi2blVP3L=dU#8Xv9kVV6>|9#bxRNBPeM>|pGw{5cB!-(UHq9L z{`#4H>&bYaRQpgCDoKfer89_AKx4pyY|wS+kphrZyB^XV1VwMSaIY=|B1`-0NuekM ze&_mS7(U4Lk(8z8$_`*+Mad3maPfJ0*nEgi6eMS4tQBh*Y{|fX-OCgS;T)PMa}t4uR>N(=6D=Z9!_{?R zSnK;`O|K}7wAbXi$d6+DD*L^}Z)PV#p^_n95vi=(2xi!@*yxD=b4GGZ{E>=tsM5dW zw-;bGED1C8L9HgqO3wwL(oD;ylci$iOenyz3;v!Z^r}Sa%**7?^!523*kBOmbC6CS-Ec=jvo-&d~!rck(7|A1QjFeZ4gCb#}&6y+f!5ba8+&x-Uj99b71MdwXeUUfN1M)fFpzY zlk$!`g~Kqv-2S$+cXMqz_q~J&)tN`jiSo^fCM~!%W7)`B55QitWQb+LLIg^yn&Z%B zX?XhZQdXsmlw>+SMprr3p03%1+*t{oi2l{#;0J{jzqI#Jm@ChYEyLZkt<#A)?bF_x ztsUu;CH>us>k6aQohCJuG7s%#cxU3^=uV#|cH_g)?g37@KRZC2N3gQ8TL6n=JtTQ> z+!i|Nch+4bI=DZ0M|dkHIGo|nsN$8MHe5Uc9XQZ*6I(?sDZ0>n9BNW3oeMdBNvI*u zS{@30(Npd!Xg|KxA}(pxJtOUE9W+0tyM=AY1&rHbJzr08owC@@&cJiD2TPlm%>k)3 zxu}#*JEsZs&6+>BH8f?EyZP}7=i-pPoNultK#jVhMVV^LwsYj%L`?p1;qlPj*9Ky- zW2;P)du}sl;Lq(w%PC|95=)vfXuc`0^Mcqp$MaXIPU`%9_3Y{k*=I)$jof3bb3`H4 zJU;q7=i9G#q@;sTkx`=pFB;c7UZZHWCqD@`w$WLGC7kB%W`ysaO5e?r|D85Q?^4QG zE`}?q7dS9%7#A1RGh_-*?8VLv9=tj$uAGPIdnYm7%{z~Fa0C0#f|>|w2hyxLXs`C` zXI{yc6NK2p#op(`q(3>NV>ZeA!Rk4h>b&6PXu|T`CKSzfB-|sbd!UKi;+AfIRIjc^ zmd;B0P7jv*YYXIEep7pbN_QpZJVT3Isw4~=7R?^8jN5$=y_?*Kpe z$G*_t(WUCGrNQ25q}1x2XrjQ6B}tXTh98mjqPP-IZ%2HS1KMO;=YFng{_yI0p4@Ep zN5D2<7v1T$rouiFb?^1*3+~A2yT7$7L1prs1EUmCe7@&gfSEm*>w&qqBj;GU0xDqr zDd!1?bvwtp7(9F@tV00F0r7N1Z5E8BC4C)pZsotK?(xF-1*rasH2Md3;J-_we~}yi zU8K=J_>BG!(uj%eKS(1DYuk-hgs<+NfSmAy9YZ1c8bFQSu!My{lH0+I;=#6G$keW? zu9oJq@t5~KKQvO9ZJ}!218FZ|1duJ$G7KIs6E^IzFYhM{9%!-5VWx=@FM3bLoKLQI zZ`2vT68g6E-~&9muk%RIgU^eUZxAEEU*FD@Oy0N2afx7&6Df=#+w-x(_5$d;kUwpY z;n&xT)zD_m1r&CaW9LPdhzJX_j^le>`)2U0LaqWTSM01rN`72p3{s|}Xp#s#<7A=4 z4wFJ{9-D5aeEuW!;xv{B21Le?yX@(?%=wAEs6LDp5dfm=0&ffMcLqx%HAERT+&Lz2 z-J4ae%;L0j5y8*GI#ZBu{*~^M7c_0cPVYfYeFVnMSKqm5zL%0L4hu-FuW zgG1U#lV2g3r3-}!ejs0_2lJc{(@EZc<-Bjuuv*iyct$-IZ2Ug)pNvaRf-qnkQG1p1 zO7>i23zIH*>hoh*wy9cs3Q3pNWy9||6GARKn4e(RWF)w?7drJeI@nTaC9F=ojB=cb z1IhL9_t(mT3J7aCx}hHjS}ca2+ceH9AC^u`_i=U|LDA73xhd9>U|vk=!}4Q~>NKK5 zUnVaxRrrBkOCBj5BM4F|-!;w&$ zym0bRV&vz{DbBA}MG|2$Em#8x{5yg(7N2)0-#b>7yQHKZg>PE0r7t!A7XtS;Q+Smq zWaW;B)P1Z9uBfg(Sj9o~UgSJiLp(5)XfSepJY}h~vJ044iHalYJTY^ALy!QPv9<(L zxQz%ihWUx&qZ0hit(Ow_A9HMs#XyLjc}#LWWmP%Kib|MR+^REviGh()IQ-+K0uU8v z?qYW_%9w%@j_KVFc_+9i3#0qYV}v0o%ECAVZ9$UCW<~&S%t`lb1ym%%#5pQVZV4mi zmV)#MriVZ6@%L0s$_o7;p6Vn((|qDpF>h8Ns$%Bl(lD`Cky{Y@^B6>IAq?lTKm{!r z4Vm?sZXn)W^NAvHL~c;tPBx&jh8780fRrsl8Vbfneh+4cA>q-U{8+{o@aCb2Q4SgM zlf;Ug6Njgc;Kpi4cCrdqM^P=rd86nW!Bn20%)-W|eohvrfjj=>5fBP2?TKcEw*Pke zb0o?3^{0p>OozX<4KT=YwpWM)2=j8Mpp1?EWI%v-UuTS@5amqZSYWM&PUt5EHQcei z7l|;69MKx&AH{}7#gNmqVO; z;{btHFgpdjl0^!rSb{cX&q?{J&{QqV;Mx^1c})#}R?n0+Vk}O~OqGwkfl(=>Kw>c)SI7~1lt1r#S1h;HQ*l`EIJ8kAHJ52=6MFeCDa8) zkbZRr-q)=WrwsuN4Q*<*-^Smd*9AFba5?T&w~?r|(zjc6ISF`R8)&{5bEN-MO}bv) zRT(!nBhxCY98ag$gfpQ@&+I z7sRGZgsMP!iiH0U%-W5s;%w1HGc~ zJKid|H#P-$>a4w|oIu89FDw%Xa0eN#6)EM> z$w-c%&GcK_9DVR^!*PS%yi~B!6t3SM`&2b|Zw#f(rqCsnbeLknm{g3EWv|{U1WRe@ zCwlsLe5f-w0<9I@^$1+=WU%fcD9@_w*}Vx+C!huQNt7}S)M;_J!m^9}lby2cz&UH~ z>#U-|AJ5QtlumcS{~Sa$4bX0SChP~W^}ZtXGX#XxHhZd#-u0jy!be*l9OSX|8vx9Y zX7r*b;Y$%wpv^Pe=vuzTP%|Z^kk|DY?_UsSudC$^xAr7y=T08jt&DWULF5mqwtBnw zz@LMcuO2Qxs1_?ZD8AS|t$%|>ZACp4&^Q%FbYlNbacQm`H1Q|2%FE@i6<_D;?33Qk zj(Gp!tSj6`8uEVCDjkAaD6^tU|4aS<42XBVJ(eksZqXvZ+UlYB|h&0VB@CES$U#0 z@SgSh^W(CIBK-2pMiQinIgzQRA^X!lx`uaQlzvXBCw985tRu&)BI%0Fk&d3Ni@24r zs_k+=jaoU)Ipbe^RqI^8*Y-e>*b(DS3%$fL(NkD>L>0rjkA6h zTe%&_im9O{;44+v*^msV;FgOf`)Gx<=BJ2EA{F|2gDH}DLXevxo+-QMm6W_(O3a@Q|y?enW$`-eco^4Ab0Y`tsYshm}nAYZLZSZ9clVbJc(cHy8vgeQe z=+*)(8wFa2?~YxDd}hc?@{}P+ORtZ$8#~k0I=g*{I!}8q*Q}}>p?4Z$R692znm&;P zuN|f4QbmLeq)o*8l)rsSgkJ{BtD|nURF&JEtFne7YO61Ez#vC#kJ#XoVpbll4?bSr zW1#e7{Krjy%!v1rxSmDmNqf0A#GR@GCtJ$lkpKv|(3jDhX{oORuhaAN53-p_h_`g} z+by490IjIy&sNT|FT3Z{?);HH7{C^tG`7ia#{(*e)e~_ewmG#MnQpfIx z!ao;WXGIkw*PYI%X}%3?yiO|AdS z@Ic;yWRz_3YtBzIohq{k^(}GTqEKh*9_@7@ih7XjYT+XlBvRjlRVL966U)8o5Z%f9 z*Js~cXOn}EJ%xI5>~pi;B{+{XVk6R^nJHBa6&Kj4shu; zIAGKV2Bd*jkL4W~FD?qe*?`Zg)2{R0_@HCwS|D2!Tk%9&5k~M`f6?jP=5>kum+4iY z<2mErI`on#3C^YC((wFf=m&=e!+moSsU4!4d3-*e`+}l+0K}{RhgQprilL;Xs=5%i zkV9qc1;AVm)A}~hD0Xq|5}V&WQ6I38;onpdyH>g}0rJ*NKA%2c(gT@Pxos}!-A6S` zbAF8=w4@W@f!(yZyS`c$vgNkPBMPtX*^^<6wADOm=pOW@EH<%60} z>AA2!!v4V9C-hVT`Zl=F`NXOK`GPUL`)v6<(C95^2i#>0pu_{BQrqUjw2oy6Hzf(; zYJXDK$;~??)PpxdS+7=MyzcMSZ1=pneSQtY zUyQq=9q?#ggH~RQzNz>4V9yhOsPtsto=-kvfigjMFVeF5wB5cNgoeQM63wsyVfEzf zB<{Vg=puZX-a6~DST_)@rZzgY*1r$rZ5_&&O5-;Qg1>i`< zT4PaNjoyHg=Vmrg+>QuX^MixM$4CFY`yzNqsSpMp`5lm{a({z6VzmgJ&n-v+Ep{Tf zS}oRrXrx}V{3xit8F$z{wq9Rd@4T99;JOMfu7BN!dLqazrJcDm)XWuK4<07Dd(}mC z{S?JU6nqB)SNobf%bEoml%Wi|O2jSKE5;-$w`C&Tj8Mz!@&gbq?-T50h;wB}?1klt z)3Ftbkf9OlMpY+Lb)J83mL@9IhWo;-TVGm~`BgXxV`~%1*!8A18!lPj>nBqI+AS++ zQXw-FK(Ab=(=-O8D!t zmB9>ZUSqo%L&)bPpq_D&SFlr`5sPWH>g*Hq6uMEP#u<2W1oZ`u-It?6ea{{9rTH^$ z^A5uk0o!Q{poWRDVX*%XILcEeM2#JT8b+d3#pA7j+D9fDy+W>QECnS}XzKCafz^IG zMlAR#ERyDZS=DsFxjXJuZ*uVRw^xc!>sz8u*Qcw;y-nPgo%1KEPy1IZ-z{0KU;|eW z(5gyFj4wP#ZVd;%oo+L`6W!jb(S-Bjv^kkKf=q0Vjo0j34YXzTul zpD1+r)cUFH&o6yOFMzPXo_rot z{utbcBa+F|U187!&i9_BuEukN`r?^T^_>NG=KuoRzbHfPRYF$oN~Wi=<3Hhlp2iPh&UbO zc2i=}zZrgqRvyE0FG~|vcR!$GrKDW$t4wgC-#{ZYEPC2Zb;Rz5=A{1KXph0jmu=EX z7E^eBb7StCj8dV4a?mji=H4SoW=B_RY5kl4^-PzC84lU%A9N2j+96=}c;x4XO?Apo zvP0KFZ<&~|Ia$%O{vM#b5+d;jaWg;MxPa*J9Ca93m;13GN)BCZRHu9Rws0_?`_Imru^lnKxIX4Y@L zi9GC&gySpx6qCDFpt4G1r7KN8-zc5qRR9gu=`*T@Xh_ms*~u)El%jRi+JSUn3!`y2 zHQ@ulF)Bx>gAsSiI>F>`%(kh=DH8h&-De#n{l5d|X^`j(t^}2VDm^tWDBXW1(A+AY z7uJ7@qr`<`5~IhE|1|`=eSuF?()-d#jg?~h1^S^H=E|FACw!46R1nyhSvI)y={oy2 z5)d79vTX$>9q+DECXp!wpfdSO=Vh(SDiT+5=_q>N!1Mb2!J8U)@NYe}!9g0)o>tD_ z?E^PAs>fcc#f)y!!j|oOqc?Xg`UBwBlzMqyrZ6A3Gv84jObSD{@J!?Yy%HVV0P6A& z6D*;GKD%X@OuYjvGscRJbp`+5OoT19P{g1!KJW>U zrujUO#A-^yPO#!A0)~ttu~OCCfbx77C;(;EEjl50P%BD7mP~{dHGiOf>R#PK@odfy z_bjC?m5@73JIX*K8Oc1g8vZ!_@Y+Z|{_J`K*hA*pDwq+w5Hmy2JF2)mu(n2u1hCY` zEFdwEm$E2?fBlGIc&AJ5SW2W)swA?Q?Pd-)XKI655kSWBrm1))*ECVf-o7wVOS-ZH zroJF)E~)ebgVYPg(FS+$Q4KZRV0n{61pWDFYsb`n(|9yK6^vpsa15u0HibZG3-Hxn zaP1CE#YSpED*EMWdp2;C44$-Cdl*^PdTVfk%84dmVsBPI2t z9J!FdjJ^ZoU6WchJ3H9j9S1C6zG4W?#N{R>^e0K#Kna#A%hWN6l%TYF^DOa%cGwK> z-*GGzmSsp83%6~RU3~dk8m?85Lhr=aMjjW(f=mwE_A~z@t7)5tCN#uBHmne=94ah|9aR3AII@XyEj>Bh&xfb%q!yU{FePUG!1~&|pAC9dH}t#0m2%Sxj1(qwd*YXFW_>pH7)E0>1z+vQtGF1_<`t44l|+}(2csFO8q@Cfmzo&}2QYS{ zoJREW5T^h!sA4{_WBcYtrvatdajYu%&Dp7yMI8a=eBeg(>JE+piht_#BEf^BUjkN; zJXjb$G-@-331my{B%OaNc@8<2h*Y|qKF{w+IV=$j6Esa=0(tf@p;r8Q>&VDfgG~Lc ziCpB#4;=xp#nSpm`w-)rO-a4}BkAALHbyj(u|gTFj78=-{%uTGS!!WIE1l-+=%Gj4 zurc&3>N=IU$-z)2p!7-MN0u~sSrrjUqdQgFg_owjZG>qk1o@>?fA*Z4#a zo3qS+QE_fj9Y>PW@*y$N7^!F}87z=swf3)3&T3-v1d^!(`my@u0m81-lr;>YZ02AU z7reT_WrF7jB2;xe!M>vf0i!+vqq!Z%?{}#?DkDha6x3w!dh?&R=o75}+hSx$=>L!8$t;B|erJmX# z4AlidjSbb0l46X1V;k8R{wj(v{(&~aI7h+Y3+fk88I=}5{X-?0GXj=uuk~{%xATMj z34vn?+VSff6Ks6vWIbNjqeu^j=`m~duIvjDOg7`#3{WV6$s#7)eB8$J7tgK_go;F# zMZAy`OxKVI;MaFwAxrz#`lk2vz-dY#*4 zNhNjINMBk2(9*r+Ex|}CM=BB&sVI#c>LVyolJ`X(@*cBtW$niDwq?EZ_Ys+v~{&=~IO4{;kO z)8_)MqsDrRP(M9b>bH|5z{3rr68l_jrr~<`&y$xJl}l3wl@jFv6Zoe@&>bo{KPvCK z^)|C=A8hfO-J-J)T2vZitd)3E7(ZJ0hF-FKA+rFd1zc#rRWcUSlC`SNr)cIR1$XoP z*khHxnIjG5{M3~6ymu0ZBjfMM3hhM17MM0%xX87C42MGA`H>p7b2={6IWqhgg_Cwn z9aSFK0>Z#W9nqum?m8aYN?|V37nb!h!hxtil2$3B zn9s*dS87kSn|Xeny@6+byyj7(&Dp0qX1%M7zqto&x~-OEafb4U%!VD@^*k`PTA5Oi zXT9d?vlZf12z7dw8}gx9(~3S=NN!H*X*819hUDi5H~b9W8Zq_*T1}01bK~PK?NMMN z1{UAcsWNV#AX6OfQ7WJRI#6coHFaG=G?jx0TK-YP2wj7meovu&?o63AX2QzP25tdR znKWp`w*B6$(_3_6B;P3#F1Oo{b48kf>NJFeXAB7!t{Q|>xphIxzs`&Tw-ff6h)e*V z8(*!{qnQ#l0y*looi9&1#}b>wZg*5q`79uDqceF4ZFkF3CL`hq5r}41r%@t z<-5S^^4aJQ)1m3*4_Jq^UNSuVXtFHj`A~d=n9Wtk2n=_X5u_NLf(;yo6IZ0LrotYW zmm8S=1%oLdgX`Tx!d?78BGNm9kWUI5a2(7K-^}VTMF|5HwcbL#GBsG_9Ne+vU+9)` zX{;L>$O+Y{LU`Ltz+|gB8TshayA;3DULn^GjtC*%3sa6=Wy)B(X}ld@^!IWJ6*d}G zt+p3(o7a^c97$b81m{bemf7W z#{-nx!Fe13aYFI#iX@$EHeA@d)zuFAU{UBxA~KbU1v9RIUadw}S}1B`Ixbv`YUpSYZ0LKxdRvYb zM)hD(WPt=8SnqHhD8TBZ1{RwaF~Tpn&IYx4Frs@X-%NxX%N}yFL9fhFPx=V{A_z)Z}ISQQ$*>F8a6g{3c>plmgpKmc2QNc zc+cf0DWv20Mu@+8@mfs#w?8$gn(%i~fRT_1kb%m)N;p@yF} zO(TH2FqSEShwDJ99R_sWCnDjMbq)7$vI0tVo34zY&q1qcXuqEZ4_x8sFx=41k*JRZ z9T`5m7`m(dTqaT!eLK#|+kM$;5@))$q3I0t1tVk5bDfS-{0`jGc|wMGv!(qA>o${* zf$YTv?<%4U76$#Fm|fqvIk`W=Gc#St^gb;Urh)l|p5pQ0B4 zq*2V#eD-|Rl2amft!VKC97Znf2$YxV9$ez;p9(!b?XIp}Yg^3~CzMpD&~}-<42OXX z)@4_`+-|RDD0s7)ZCKl_?TxR6mXGNZiWIbU#)S6gK%}O_H^mxi9j@exu-9G9Kx6vTSpo{H8V-g4%b_j$>A51in4t-K|D?Wh zWWm6w_pH49j)dR}p@AlxPSJQfBi7Zlr0xBEPB}t<1e%{7Cun8_%c#e0l zH`Qda`39O%Hjg~4VzoOr`ax>%M_w+4PS zBqkgxL~Jh+VqjHb(vj4|ImhEAhjE`IZk8ENNg}BtL6>IfJkSX`04P(ZXT=9Kd2tw z%$u%TmWGs+SL0zVF%o7hGC$M z<-{;-K(}+%?S$O9VLIJu+fN~HhX1Z-=M*jfv4=Ts>&&)!O)dRqLVCU1R9$B*;mZb4KkI$*y1AXMTWtIrWB7jrwvX-qiQPBIGf^7 zZy?h>;zADYgj|0OsTnX ztnk0>nY3l<*-qKETU+oj>6OF7lo_4Qrnra;%dpf`Ez^Ub$}lih&MnBE20zj;lg*`P zD?iMUPlIkArby-$=(R`nNfc)m`4(70DwLP!Y!wny2IZEU^|Yv2q%~L-!(qJxUeLy# zbfaF_gFM)nJEO$X{i_AZR)9Zlp_Eb^q`;ENd+Q|w$cYyPKxb>g0swuHv%CQ+)j$)% z1DGR@5dqGU&?O4KF|+}X(FiFwhC78cM?3mkid=SJ+MN|Gl6$Q4Gx9Fj=DBnWQKiXS z3Y^yOm_{1L&l1JK!GkIX$Pa7d`-u8N>L?Txb*gGepf*mLxDNL?Xnz%~A-6bxjZ3|f z09ziUv!*^vA&eri)v(Ohz%3k!R}c^`Pve%7C*21GAVeIM$fUPnU^kBAkCBbb?QPM! zdW;v_9M#uIZa*VByk3<~^Q@FiTzTskbPsqm8#c`D#PD!7`}Vvw`K(zxm&u1y8)l3< z?TJu{qw)6Dlo?9aynkYPSRK(U>6?^dA}$ESx5nE6f*l?>~RZS1hOjV25)TYBz+b`!T(HCSnNf0N4#wC8Ojpv zgBsv!awq_|jf+x<>7l<%_Yg-d0z}gb^7Bowy&CP2SQ5&ugLoeBy(M zut@7%9K@7dh3r#aF)^zcT8q-@Dd6a3vi&z`8nB{sl>4SN2?nqUNRYR4!y#iHUYqW}R1i)L>|hwqWoy-hzrLTKNCkEH$9!1Rp(3_u<#iy1V4vBB!zTQ^G=nBCiL!0Pc- zSgz;%4(-I=RfP0>hrWC!s1F@^>KbUE!Pm~<#!T=hmvW+YN^YCv(~TG>Yjfd6~D-Yk4{(`D+(?CWfoSy zB3CG(VDHfT`GbbeSY1^eW+`I=Zxoh~PGNk%=$uyYoyeXv<%zgofo5RQos>Cl_~HCa zcum94r*2LGJ;|zldk_7Xwx7;zc{BmTzFk;H-u5v}%Z?pcbf$pDd*|(8}5+9h@ZzDO8wpXkd&$Qng%o`lN7q=2W z2xh^uT%LcDB$}S48e&SYk{>ddlJ8nqPY=~8KGm4TxDnwKnJVzHWb|aU3{sDu83{P1 z`_oCq&u$*#a5eu-Y!~t!u-mOOq0w6#W2E2hn*JWjJd6(yghv6H5}JJ!SOU6Z-s3)ywp%(8vyqNunZr#BKZOWdMnpe@yPYb za8lcgT3R(-9qJe7UcL)KI4bay`Y>>MhOKHF^=|DSYDSlLxwxI$KFT8 zBMgyulTS=U3zfPTKD*s0#!qePA=pOI2O)x14$X@k%6yX-EeIq(Ct$DFq)HY;>;H?K z05ONKPyhwP&^EUfF_Ms4K@O~2BS{aW0D3Wa+VJCNcssKT?k=1KQ9hFkAqkJ(oGh6z z@NrlQ#Riw~_3|Ewv0a677|^TM9~vuN?D^g&L)y9CpRs#Q2{lgQbbk_GKr%d%)0K?Q z>_Ks|6@jzJfVHb6h)0h5opSG~im>y|%~+XTvcm?(s)&nfCF21kc!b5ADHsMA3R)Rx z;iJU(%^y6J0}vui^Vg99Vi4Tl@KzXZwtXG(kawO%F{<8&qGKdaDZk>ER-6E_Qv)~Bm~LRA7>5| zv|~rt#)Eg97#tcFoRuO^DVUXFCzf9u4omcr@(TYY&=e!;Cq{yX%Wp2#D3%`?Q=ts0 zM%ONP-G|1)a1)3PT@#NA!CBS?WX=p3BnBDxg6wq)9x}oF@ynvtUpCRdMuoYR%a}$9 z%?IDgc;|jY62^<>qUdRF&I1u54w3M-tU=6Ij`&#sme-HNY6r=9=jZq`KgZX8*%*#& zY%<^OeRiyf6q6VrRp>+W3K^k(nUN^MN#6N+#J?hbJf zjl05+L}G}zjx0cNPLcRwtSnp=Ki4?+Rw5``we2@Q1Pyp@6#Fr9Rs0?O5wQVYpgiFd zxeSQ`KLW*G>~v-|O` zsFRHCjt0D6z11Q4SZZ}|YA%9{s*|wqyQ1%eXY%|APe6Bf;g1!A&e}9K;hR80)E>xh zUz}bW$dlzXF)Ixb^Mm)xDJc=hrnG4H2`Le1C8ngdv`5!H-|vl=dMkb`e$DTT_nq6t zb^bQ^ClB`9S1N;Y9LK@D$QLe(i-)RZfF38Ay!jyxYEzbS!ym`<&Bvm%I@w#|1ReT- ztf2kWK`_^XV0g9@St!?$xjSgaLoUUuhi{@t%)W~+)Mxnt9;`N(oITg^c)Q|G^6W=Y z*yU0MBuV`%3{^*;N&bjyI#TxVwMJ;qqOAMSNAmf3;OIGu|Ab)_x9Xj>H?YZTdLtZ1 zTw{wO$9g~lU@4r=l1uOApm`mj;hss$iV5$8Vt_J;Jfq&?qbld?ibD* zUy(Cj)bfIrB~><=tidT#dr7l!z3(2KbzS`UUKA9UtTZor89AHJ%dKbIj+3q*U=l$z zN{Fo6U3?q#gKwaA(u&yo2`k_7 zqN5BC-}OdV&-%J?j3A2b`+Nm=9*W$YL0~=FF~L9V#o3F^K$<|a?R10t@~``Cfj5TM zM_G2$!}r2b=m9d#WHz?}f8#)+WY#H$nkwq){h?a0si^?VRi2!QPNm+9t!SejF;qQF ztur(Oa|}I)TfC_&tw33Ca&D>|)4|E$r0~Iq&I^wsmOBITh|jC6@Nruk+RG<(We)8U zUZie!SauoU$3-8~GZ9^DFYkLt+vCg02|?T~%A1VP-X2e2ji@*#O^Il@k9a+uj$o~! zoyy6{(UE@aQq#!Z zRjt&>h@^QMykTNLMS%VL>$JPTUh{5r{q;Of4o;EY=cwH7?@#``Uq&l28U|&y zC6)E9TQ$qZtjtuoMMIu+MCWG2B%yV!q4g}b1PO*1HhB#g5ivquNVOLXR^bSS#cq~q zY)j~t&4bUh5q(z@Vv-ZHbB1R8ayu7ZEt}84PYiftI8w*VCV#vcm6{R+dbjOE)}oqK z$s18HT3CChOoG4@bA;U5g05{Vir21M?$|18z7+SKj6vPn2RyK&p9!PwN+h^EJzc<* z_ZD9dg_fayKyNe2;B9sjPLSHR7}@Kv3kl!}#;bp<4scXNyyL`0;N0KFKOXJ|PocS} zGu*UpKk*d?UO9ujd+tWl1JaBN{R05dmY+4Y5GufaXTmd@t3JJ3n>X5jVt8D%4-F&4 zgv_RuH1E`1K+o5|l;>hxWB{evi(nF5@Z6jy#?dE(<(vr9YZ1ORrO!Kz%(@$Kq2^#S zwe-vRVB>O60dqVIE~3CA*>lqCi2Og)y<>2t?VI)+bZpx;SBy^5v2Av2tAmbh+qRvK zZQHhuo##KhW}eyav!~{*+PmJGs`cq!H`bSRALn&mzvDPTkKz#<^%)%~<9qGtR<@lM ztwl?*VVT?xhFTV*dE}_8&qJ&-cYmfQkd9$mdS`QM*)DKNrRDgK1V z8{zLR-3O<;940a7{He=-1M_YUe&ZkifY@8yw)lsY(mxqm|Fs_Z|7WH2|9N^A>wnA8 z%EZk4pBw?IR$QV?V0xo*S~7s;F%CiXKsk(gO3I@5h%VWC8cI{0*&dGy5I+cLPky3n+7L27qb ze*7#BO=BL4%4nE`aj`|VX}!*=w!=OG8IoCzBjc3Um~LrC<9I5YM2t-tE7cVOd3oE5 zRI^p!R9ADL7jJV!HIzz%zClAu0ZVDqzSEh%YEGzfu|ArPTu-zkM5rJsI5heP6Q=jp zfD?Im&L1^Q78<*p^bQG9;q#yOL0^@E?S?s*odh|eB~>SStMoG+rHv$DyP(IL{1;ui zDtVhc{PloFPDX3CMdbqZF`C2tNRO=0F1&P+%u1@-rS+BYGkc(Zf^oo8U$BIR6+@r> zZC%`sQK7LBpfT4HV<+$qK;;U3LdLTg2Yt_ z0&T!r7avb_fm+uh0JiNrdUA`Wn((Lp@tM7a)w}(xJbc83o=EX`ha?f;d{f|Uf0yTd z^bH7A&Uj+qRi6U2rNp{$uv5rh1p8OFJTz#aX;}KEM6~#(KjT9DkSslRghTJ1#r9MD zE*%@M4mN898IjuRriGXS0W{){f#PazmwiE?ZP#DRGJ-WX^=7HM&^*Dey>_!7zdyxF z1QNXt25D~cDN|^)%hFV3e7O9v07o5om?Tlr8wXvZ<|eWe(D-FiRTWx@f|dEG0564U zcvnCn@`C@bWOBFowZL44SjrY6LMV+oO9SqP3gsQBld133c>GSZT4Ca+MZt*F#K`kM$*j6Sb;t}VZ4*7|FDZE5mlZaMdt-vw+^;;^)f@%aeLPw zZCp>CM@{|$<(nXTp0+Yj*9MY0#58EWGVs0+0Cklk0E047J~9LOFaUn$@i#*6_i{!k zn2<ZB1VqH}pw&EM0_f;j}-)s|{B1o8wQTeqtJX0NLz zJn|9}MMs$|*lwHnI?Eu7`Y!8@*>M+iM6nOSI6xou4=?k7vUmOK1^GYaW&Yo?cQLWE z|EETnn)+8G4AJYbD!Hf!ehn^(eU^fvF%Gq2cgS3W5Iz{t5}PdcHCDu4=SBBTk-Ltk zJ|1CO)TfJ+mH05tCNd-C-evcGiLo0_+Zc>dCVaQ%diu#ad92=*&u~n}Dr@cc ze>~Bsw_)@(fer}49Z5-%!Ol4H9;~Dm_Cu7o!PhwfhA4W^p5a+QrKb_F0Te(<4$zl9 zS3+rE89X-oKu&n585@Ha6)D$EF(vh`58yET+=cyu?yHZWJ?hDY*s%ZxkpyFd0(CXBEKV54YNEOR0bEp`H=M2`x>_SP4ajK10F>vJ z2v+uqtNFSGH}QO<^~-Hs&AsHV#H%=@xy5w}%f}k8hU!=e};H28~*7 z8)K~78@PoPR|q`c5Ts@QEM+orI}JhM<0v1>kZhJ$YN9N3R0MqWQ8eP?kJQKk3WCBA z=Quao89OCeFpWmLa}{~zKfvKci{jwHbFDN?O;`2@YE;ZaL)YYu;~6{E%R_Sib<{c&z!R?$l_#?boe&i!(+7JS z$Od&}WR;Jku@a%CXi=|`17$$dI<`G!?iTLy`>us-oySa!G6BCE-{gXYd(HNsd6$FE zVAmvAr1JV$2Hh?Fxeeeag(#AH2+pHQ|sH)KE7Dml$NU!bIr%z;iSE=FBnudX+L_C4@AKy{MK^0qr^W zSa~-_$=LYsa%S(VD{hV8#k87TbnCP)0ThdH#T!Fsx}!gon0=<7pMP=i{Hm%OP%zYA znk_V1E0UmCzm{@#XG9^>l1LHYL0Lvc8pSP5DZV0rI(*LOialjb{N3`~D5h%mN2#bm zOL|dF@eGe&S$%2=0~AS|gIL{<4il=B zGQ}4dGtVRx^~lsC%n^miFh>TT9~`zkKQqgEzms)}=STa9#m2WIImn?=(x`X6+p?iY z?H}91%G`jwOOL`031F}TkMfK|HjT(9A6mT`*G4ye`(l0fBBBL2M^$gX-GY`ftP`u-_ww}q z79z3K+gj;UObcdsV~#S2Cr8hQxjCDI8BT@t6y)nlN)2q2`qZg<-Lb^t-Ov&C?p07~ znm6-4KjfLl6=8gFPcZmJQPv$j&2kWjAC0&5&NdB-B8)`f8F(LeH!9OFDr+B)3q+Kv zR^i71v}7%|3bT=&y|w1=*vwLSndZI3775`_uS=Y5DNn@Sr8Z;tY`KRWUw;w2#KbZcGUfVDz1@zUMs7nn4K^DQ?f@~>0NOvk_6?-iWbw77l$Oa+sBN#% zha$?s;r35j85hDVA^mpoAPQ}Jk%BpUk z#R(AH%w`S^M8|T(lFrg1lSW>$6zfuIsb1VOTRVYBoX}q?~21{?5RfZ->Wv&_aP8oi93D(^8GZxTGRk0INpHiDjE>|D9^rRW? zn%LY?-v;68m-klRufO4JTfS$ zmfkl*h&hqU+`x|a2HZm~<@XP=$L8BmDwPt#hy4nYB^t{zLE2SYxq#)y5eHQR5rwQ~ zE>~}rl}oi{eyM}`EvVI$4R2>G+&SVG<;5Mjvc52e%J7Bj{Nd-~;#<#v8Z3}5N`l%! z9~O)kn%ORt42Xb{>7*@a?<;>`%_ z*qikO)YeBH>K|19Zw8-#H+8fAA9g6Q{@Xz6|JDQsz~4BE|H9PG!ou;l?XQZIuee4I zW%_&_9o81thx1k~)(rbI>C<+2{T?%-owG!D(^7J>jOz%v_AT61XXNDkJ zfj<6wY-MlH$)R|z@V+vr-Ymt5W&%W!wcpM30a4e+H?zvh47cHHq0*Vk`}Ro<%I^+u zSgPFSh9`mX!ihO)j&wufsb1eb7iad~NE^EHDl0@v=gm%~c~ATkcUYCob;LXdraIDw zS?$eC_XJ0Yj@${|{h|&u5#s*Hjts|7PX&STU_YCV1Xpw9!LFYxAbbmIm4aC&4K6mx z1S84_lqmUxec1XXac3r0FY~=)XemyRZQ8Uk)z4iwbYGLkSexjqNL`-;+Vf~c5b3XF3nDLc^`pdvVF4k8&{dJd6671f+!jIFK0 z@!2&AOF2|@bYfxHIQ_v?mJ^)wbL%E>6`7cY!7;#Fzn8b;ABW)cDyw4fg20UfWEh7s zimSQk=&}Wb&YI`00ZfpJlbG?o`YMyCfpfJ`R>tVtA8aB9j-@H`wybr?UmtG9f`Whv zPYvIp#W7mnp~r9mDpTWkDSa`zG}|uRhwCvxnG_;;tjav}qi;fMA<$*BGlB$TS6CJ1 zXuip_xBIiOHe?vv|NWQ17DV9~AQB6$K?SPuDq<>( zlH)Q$ROe)JZmB89V<9%{UwrHRx^wyL3AG*00Rt@Hx zA%i?9hRXTlpyH!s>SOf7l|CtEa}d^y1p@gVgko`@np;P+J%<}Nqe3f`jbtTcmO7Q< zrCxzv0s)R~bT_mKd}|ByCbksn`vKXzsF|>+`L4S2d$KVYdPtFmBr~~vA9rB{E;F1X`A;9bI-5HU_Zp=w zs^#$5e^-zjHX@y4<5GDBbw|(0E_vwk>tQk{euUjdv__lJ=#&f5~hXXPHz0T8>RPFAgp*yn7`NTlw{Y=uSUa)Fkh)Au>k&^==<39q_s7&8jl-y zTSgq(83&mr$2iX_nwj+0M(xOAn?~UMP@xt@kBA8!_txD5D#w~bw%BU==w2sc2&LlF zWmVS4i`!TH7w10i}b#47_Z&d1I{A=SjyMAu%Hfw$d_|1(@RvsTrGR7{~1jAN5VVBm!-ZR>-(X3W0 z7pa@UALz7Yo!Mp|+_CaE=#2f&QDt<;Av)21uEDAzIQ9=0Kkc17ot!-r(slc9`v;eW z?cKbb43KtheQqI~AK`KQY3KFTm1IFim&k35+(%U!Jo*Nv^a{VXA>RMg7z#2{{s5uU z6%^=$Wz|K+k#FoPC$SpgVn!F9Dk);4;nhI`Ne%}6{3XM^RdJbx;aAYx*i6SEYbn-@uoiu#xUg%T^m$2$;)_=Eu9F&Vdy@PCpnc zntco(jJn=xD|I!TkwHsY4b(87QhwCV97k`=CZ45w+xZK*%tR%Fjj^4*+q-q<)$T{q zV`}it#L)bXC$lbXCC2b-+o~+Z0EJA=Si^Wb&%Q8lrBAibh4N43a^bcz$-CX#A*SZ& z(@LAPUo5%X-TCL=_;a^=^+1~NaIjtm)l7wWgTY6```CiK(3Uq<$E`E0QHEH`6`WpM z56{!=-XV*Md!6;%sbm3r-O6(=e;~d&p(x;Uuj>%-MK^NTdPIrOql}K^*j?Jv_P|j; z@%I_n9Dw1H*3H59P%Kdo&*Wm-gk7L2SnAoaHuEg3H~tDN#h->EmdWU*{#gU|DC51w z-~=R>cVbAwCQjGbe+xB@*6Qm28o0oS&My8=N|IN)o$FXCPH^!6&uxkfqGAXYo_1Wg z%;F;907p3g`oz)J%=gOD;+pkF5=hR(?YC{<>}+1XMbr9wnOyhoZLz6kmN@Cx?8Okm zEFKtlyX@xlJ7VRsxQfzpQvPp*GN+lyKI9iXN?H_Y&C9JGP7uBXD zTC=9;*aB}u#&(;oOZBOZl?LgQ+BR`4@8^_yGfxk@YhnecF~{3|+jO3`gmwPv{S^|XS&IR#`xCT)jJe=_n^dF()J46t8 zwpX#^*=)`dVJ!CRhK!R1be+_gg~%V!_q}`GueqQh|7)EH_#5r{?{(t8YOnu;-J$=j zI`MB**MCtbGX7^L`(J}H{)I^~WnH9xU$%XgA-Dh-Q}Lb5BmN*l>?};B};gvsUwj9n(wYPVXDu+1)wiGmYEQ zszo?HQSg0w_5ob^U(WflfBe-WBAH*b;pC9oWlV|W@SJq4)MT?|v}A-0B%lbJb|I)G z4i#!f3gZ}?F~w3*zc#qxK5xY6W6~Pvz@JiPM6r!8G-4S&GCLWNH*Xvc@5DBo-FGz?cMH-3|MM z7OXFXlL0dd7|v&l?K@~UP6L;SBhhxbh?EFBg#if_COS(5$(#7yNyFq;9%Oc>@%#pf zdxI+%AGgEL?<~u(T4i@{gjUg9R?*-g^-C!x?_Id6(z21OBKVo~)_$hAg-!g4yj9!e zPhEDXmUJ5FZVhqKIW=^PqfPD;pD=9as+zrye#4a<4|vn^+yV)^s#-27#!Ym^ zF|tc)F2Zfj?{emNo5wt>$7%I4XZQN%w9bX_-sV0$07skqQ$jRcm!Q-_?Fh=zU6u@O9hGwy9xtA-Ax?DtBrKx-zyMaO(o z=2>u54jmdtKW7o@W%lAfp)3xQZ=BHY%DD*0aplDS@-GNNqHo!5hB(%m23~}ctlHQ} z6Ml~5`5jpM@)>%b8q7H?hKdL3)I?~=YX?Y1s0S*PxnzPP->MD-gz3m-c0-xrQS8^b zjJ4R4l(nFrwULW-8Q0_dYuQ32_f3#u@F4Azn|?C3Rdxzrfw>K$DIf@|gZH;eKkyNd zMl;y;0xebmWn`+DKroM9X&JA+cVMO$Ii{ zgjz$^31g3PTdRa^& zuwk$ve|;@5<8(a1`+?)ahR=l##}nLueQK?46(E7Hlt7!`Ts+&-LpZ9)R9q$>fT=q2 zy*h$^-^vNAx9^v1$NuxY?8xfA4@%^K8n$bG;#gXmZnbgjp4^tx8r+}b`oY@Fi*Etk zq2@BudC^v!l4Zn_$n)r>614WqqsloWl``Pje+Fy!VI^3il^;sWI<&FoxsID@cfd^| zmv`kvKD3G7)T3XYJ)7?=bv|Z6nFf{( zWBlYODAl@PqJD=yLU_abFjYvO(e(a2I5CFR)O~-n>Fsf|WNC+8Ip9N3c)VqrkS89v z!eHLM4FiAGL?~e`cSr(%rXP+vvErJzT|1?@9I-3kb^Y=Z4mhgS7m=4Zm9(|tMM7Bt zqI#dvmkiWZteA$ds4GwM9?YI2U1Z}Pq44GbQFhe_GXQ_WTR|y1blK~CF2;Zy{6`*% z>mqRQ(}jlD5m`8?-+qS7=T0bR?4ox`)=3X*29qJ*CvVn~I9fMtaevZX#&|jGtnPh~ zcS+}~$QJAW7Ml8)%Bcce-xVS~>{*p4rfrSmdWj;aIna9R zhtO|Aq`EJ1RWk+Xf2B58>AZt_Gnrf8snTPSKko*b!LyvAFW(F6s`n3J{-MWB2RAI@ zgGaY9rH%sHBJ&ucW;)~XrqjQHszb9YaU1f%xYV?L7uQMK2iw6H2Zz<^2E;xf0Rmpl^_38N~OPH9slp85)&&MH>2g7;wVy!AZ^!>H2Fu~? zk+@UNXh_$gj>XoqOL9YnS>_JO#S&>UP_H%Qf_gg6eB-jBhWzm!qp# zoJd})y?ZVBcx%>vjF2!o#|Pr&9UFDP*&Z)}-UC zErM5LoS~tWww7XqSVyHTTQ2(;MAe@`JT5U^8~l^~)><@ikcJyFM8*tQ`mheaDk#k+ zYLV-aUi>k>0Zt0dK#>+nW$@Zss~}jv+BvyED`0-QG@R8ARf4z1xyA(!&-_G<@;x8s zlfp7B3%1}wu?$|xihq!(-%=S-qRDC}KFUk=@v@sTGH#Ml^5FUB2Ng8O9@Mu{(qRs% ztam7kw5iE!W@!+7Yeje*{(IFgD?RuJo2-f#KA0D-H<9h7*DL4E3lO5(VD#74dh#zA z?_H}zU1kP|YhZ-!)4U{<%VX0M{cjsbJ)WM>@7$aCunxxN9Kj=&byF74w~fN)NiOXD z+8uV~&#*9}j7hffVncZ>RCvfGitXE%n~it9x1Wz147pZeMOEFnTL9X7qFtbu7_ z=?EU>ssYn`E=^s>1~0CAGG185(3h(-3yT8KV>REZjAEy8EBk8*r9`m%#1mhi(NEv1 zgP)e4TG$;#FZ#!D{&?|R8)NKV8?v?WV4;IQq-f7zfr~`O&C^4dj>d73D@+zvojp{+XE{&A>Egm3rfZpSMUD#fO%W7J|XO zGs>aijk%UC#U89J?}7=1H5)7~$zjv&EP`j?GW3xr)W8i4$kte;VIzx_lO##af5v=G zBheauIdj4$^5F4jdU#D8#QI_3%IRY_(n}d6x}-(KgXDmmaKjq1%>%_5dsv!51*$b5 zGf4J9XC`ML;nk`ZzL2h+*J9bWOlp?dE!`a~xPgfX%tUFIxvQBD^~^k?H&L^# zfcvv2{LgY9M{NLu+Di&Y@-^-=G(*F+DYO7yXmh$~m=!gGO`U1S?=+SL0P%C!MrA9x z$m}8e_remTc4NzMpul9hxJipKSd_|CvG!C}rO>qUj@y@o;zE>z`tk%C!ej;>sh1mT zUZa;aJLeKV4?0~>9m5abq|nc90t__ISI=JCwKCUDwqR<|lxrRg;g|#qF;aS*C5Q$R zfR(|BS6@hQpbeu2Y!$Yyyh^XHeP7;~ zjM#o@a08Hws3*o^zj>S|#kZQEF#BJJvnehgZ}Wa65qqCm;DMdZu6b`TN^Q@I|Dard z!{Pozx&Bgv|0&A#H-_cEP%Z#~{qM@9t|_}Fg8G+o6@~tAymB32S9T-ZBc{&Ix150p zrX9>QV!t=4=>Wc8+$(wruVT?*aAlY27ZQLZxNPx0WPaE%t1?NAlv?Zy^fS(Ra4z(m zx?sgSonxEsFwWlGzOBNZo^Ek|R~IFU-eGS;%N4zZtgVrmvaCe1Bf#lnr2B!`fLMS@ zZ&KrI8)Ll9{9Tnt2iy#~(vNstXRH(2B8s}E#4m(~s`bu>6PwITV<|s2Uq2GL4zsWp zQ{r& zfmn#>Z=6Syk6Uzw@U_KIO}jJvb%n&|=E$2}AgFu*sK%w>JH(Z%Ms<7w>HR;^?Bz3w zkd@>`VJ4UsWD|jB7-N-PcY-PCDO~H?EcY|~wNTChqI8W=(#0@p{wV4+NnWyq9OPldNW zx1fQ;O!GpltWwVyNr4lUB<=wGV8g{u^qX=E-_&&HJ!AvDQM?!hL7a__Um8P-GZQ7L z>9%|D3qi;xb3v7HD>#KZYAC(=3kp1H7R+oUZRV?5vHm2t1Rub6Hr9Cz49w_@h;5`T%bC z=e-IPd7qsC1I9o70;!~#&1%mn1cw~VAl~~8E@2Q1I{T)plQefPXB95S>A1S?he@g% z&&T~XH*Mn;I*fzem4Jn?v+g#{TfpPZKED>TbtJ2C+7iG8@;NA6Jz<1W zoLN$2B@f+M+>8OCg8>P{y(1li9RegRj-Q^sJvm`5?;gA1^ z1>!4@M6lpJH(I+W!}Mw>kutz4}syd=?G*5&<)xSrjD#xy_bzysx%D7O3+ zUex6!CnK9=SCmQH{b85odwm^)1YK{STi70*!yU~)$H*I2`p+;eEl)uo0%6XZIK*ok z9x8i|ePOR|A*KAT+Og^M*M6>DNc!hq>YF4ekEa09V_uQVnesW5{A=nRFwtpd2LBu2 z{vgP&%ve7k&PnQfTs+;(Tt>JBrs}7DX6fk9aa|EIjnVuN1rI7{>XhKLn1c%8b=bW4D+jo;>6FdnvluAbY{% z`VppkCV@%ek70YE$HIH1fE|A<vT2_UlN~fEvKfFg1HEYLsI)-3FP#U~xxWaXl?FO>SN0~L z0E%l=Zz>gl?X0+Y8ZK`aeDPzl-$YKUe{D2@i-cQO)+!H*qN|JAjiT%G2No8^jGK`9 zl@$ZYk~ZGCu7+RP!EoAQc)qi{yetNa8cDrM(LFBUCgmdoNdiw1)Tq)=CFoSlEydI8 zcl|lZ`Z>-L5&fC{4zn^R1O5-v_&2!lKcw+5x%ri!Ljoy0hIkv5hu2V+TPRp{<%-; z8_@H+1e6>0T9uI_VxmKyuXl87KL)w)nK2Bw!XSOaW;l<-j$(Ie|xe z^k2R2hC%cBAFs-iH}y-FegTt#R!Hl}9Fa7(srI0Mt?T;E5m+Y7hUmr9aW+^p)|=&( z5El>`T#@9>xKvVo5}c(&!hG(tDcKBi^>)26D!qO*`V*1n`KJ(PicM*RDOPMkao774 zF!*L86O4=$D96utP#wWI#qAgRI}|Ksu%EXic4$eCyDtM6;AFWbB(cuNjZ42~7$Kac zW{6ZcC1)@nz@D$-xJbB_HEY~9=+J;cNvkP@+fUy)D)@g}|0!J~07E1#aa%q2VX*0n z^`y3jrUbgQ}7Yt)$U zcudFf=uS)T^-SU}@s?8w^rMK$rQGO+BhHaK-I#_&z(p&G^SDY!Z0m?B9bA;Vvms8O zvGM}8K|?F2eerI5bwKc;ji`BxrhSc;+tC>UL(}}oqq}G0o)Y|+;?E-1_VF@QJcXaf z(dRX@zn7|qoUjdyvYoEZVCI#>b@pS9(5zEb(ehqAH-Jh<*|qEv7HeQa6ya2=l60-B zTwA+-d8DrivIQZ^M8qLr*fK-K`O6aRFPrO>2HcT9TO-Y8C8KKq4jmAY^q-M?SX5uU%z`*giYN_W>nI;X$QAPm}U3n{dsHMD@m zF$UmFpu7?8T=NoiyK-g;ux(dwd5CYF*QBcVlFU($SMHGJIY;}v{5j@X`F~KGfS%}4$e03et_UxmokpbwNKXH z+X7h(m%G8eMT{`|(S6HThzB80oeM}%kmzrj6j(gt-S%|tw-Ts?GTVt19$3a=I|pCs zJr7?cF3KbwNrho%|L#thZB6okd~&~7E-UFqhXz+a(}U9QTZeje7Okp)LSNDT%=iWN zQO;kO_^=3B;7q)6m`Wnc*rp#gIQ*G(NT5;aU@~k_b;L@^MdlzCD8V_T%q*bT^?l<# z4*jRJz-(f@nmU!A2os!9ndEAjD4`MssvoI;IAn*MRPZU|8yNt22I$gaq?Y~#VW1NA zb(WEyr1H3)@hPYIA^Kyg#;7miXS3KW7#`K+Y1L?TEMaz&YY4%n96Jz4R`6n>_&&OceULDe!)NFIZuzC;m8IR^r}06P4} zKq0xiSJfUI2T9-09CAb388On%k>Qb8$7|ZRkDt?Ne5CD4q8D9wj+kbVI);~jpyq#S z9z7W}eyGuR$11#7HcyLSDM8jQ*?Z4LgZK0 zf1SIWb}SPev1Bru<8~~}Y_DV9+!Qe9=dA{Yo0@^YC^9A!&?0ob%$6##w!g690q_Ha z+k$KQiG{4?`Kv(cyLyOrR*8F5)wHO{U_)^GoJkU|+nMDH>SdBdlnI)mQK#PZx$kv$ zy2Z!Xy%@VVhmhP_s+-YSx+Bp1dvcWoW}dAyPiqG52UZ5w_75^GPkyt)TPu=g%p9)Ul_pL>X+G8@;uJX+ z4D>BP70jZfK|Rp(4Ps%#WEC~{@YhhgNnAN16rjr~@)r_S@F-fDN=bOg;!SlP54Qe7 zqn#x2a>~^l?50H%7|FFo`w^Dio|d^~#s-6~k6yIHneT>LC=lN_xgF%>ffMgmjjqna z`|h@+R4MK8inxgzs4YyTg(O%RM5WGm-J%fM)9^dVMi;_n`8mv``!p(U>rI;R`EHg` zXpM-k0)E)`0hSyFIH`*7du?DXWZhRSEs2EU>dZEV8>jg=vQmz?%?~Qj`Blxb+`t8k&DC zX@+v+{PA;(lH`W2ESqT83^*RXb3DECQ_99SzmEI^Gj^`ew2IqSmxr@VwHGD}iWlpc z$7e^)y=|UAF0V%J7FYr~8VD6;3&%oK8%Si=5ANxT22qGad=|ovwrp-b|E8#QR^UZ` z;6`NLChnYP{GiVLtr}`qrHp2w-{XtZ&OTrbcrU^}?!lB!T7-~siIoY~aJS01Jj<&9IF%0?en%5=6P)_)2*9_p5Pn}eo5A`q~ zVdd(VX_3`M6)p=1<-ux^2<-Z?fx#%GSmmgC28v%Mp$`%?`x|pK^lf|TP;TZK?Dx;a zw`mNp%ZN`Pt;hn5|5ZlV{t4yz*Q@z|$Wn&wzlHKJ0sa&6J^qFAq6H1a>lSFVuaPZ^C`%pO*PoU-Tx&t+st)X z53%SRaaD-}&IU25%i@1uwtiNR(;nhs1K_DXq^DAEw7H-3dF$cvu<_%y zpEL0@AJGGXe_pzvFpgm>C|;*jwm=dd5b-*H0!oc8G_K1(0pT>oy)P)%&PAKo;r&$p&D^V=2mjifYC*%f;cuk4}a-|uD;_G3{ z@&}D8{JMFKD-yyXI@;J{*1;|HxZ?!D#I-RzEj0{-%Goxjy|Sn!tU4p2tSH=Xioo^w zD;_D}S_zm+S_bvRcyXk9i8HB4XvN~5-hhOPNg#V6!Yjosh-YxK)W%bHkrvBZ%mu~z zBGAlG1_M$@iCl$C$)Jg6%&qJzYK3eYEW>{ol&PXtS%)sq#U9cVK~B=i{A?t}t|L=V zA^+=2%dtZEX`H$kTbw$w>16E+WoO9B#E6-*ECriCn5?U+hA_pII@mRpyxQp{jw91O zRbl=1I9isfSF14hjcyc0`ynWm%{e`c@QVimakv2@ewC@@tOJ=Bm&#N0z>>-7dTn=&q_KX2%<^=?=h@h%)2Ep89wa?^NrDisn^|9m z(SYAND&yCjau`JCv&&i5(Tutvemv;queIS0*IcRHc zgQulyrDq6k;`a*+J+O*7^0Q8#9;jf&*RoR(F-SQ`?eml&5nkSIJ+@6$w3R zJk;vOI!A4y&fb}g6S;)*&4CpMkA9$T*n^1^cB)|OZtr|>qw4{9xvTMTD9}yCKM5hJ zzS|_(QskBzTOF*$H-St=yIWh9nq$F&-OdfnEt%GhNJW3bC8mn{@-b+B6_Yik%lvYq zX!Cu1iLs9=UGsM!M3O$b5+69$fw$r}vU**@fsgr595x)-b+X8GI4h!ja<@UC>qqFo zxkJW|xuz$kNBRyj7}r4G8_faKj=a1)_39@MJczpK;pyX=xt8ztJp7)oUjDD(rH|G9 z)8>{C>&?WK6Wqob{NB%sg?bDJ#YRZIWSh_pXG2iHv3c-E zxA7ZFIy+HFMv~^8_XBs!(WKD{Q+q6lBRp!q$=etwY0;4_$0B2JU^cR@Wh`&(zLR`;@hW|%bZw7&peSs@pQYCl84Gl#?NKTm#!;yf?BhAtyPe% z&^B0{!L!cAR@CW%-d}nsuV_TFyiI&fdHm!~VUb@}Wa+|wU~anS0*c?W?F$|*)iSl#hAj1^1esL z9BjtkB)ue(lQu2#epLjwGka5GW2tK6wo|DbJgCdpXwCr4>?jzhz&G%KjqWQhzl$`n z(qXoqF9+JQ>M0=BTj3FI-PuhAAPs7NPXBFz%N<8u8oOB>SYsBh8eNs7&(`vUS}U!d z$1u;pyQ(^=ZvNA(+zWwpdE&P^5sA~JKaUP|yfF%)WAi?*pP(k_0pLC`m@872uI0dW z?jE}mu)W)vS}PY6I9!-W24+uu!WtCPfDL}AfF!b3b&q1oHwG|X%unn)!=6h>1|wpE zsRbu*#s&eC7^{?a3c-SuH9+_8)2fF(&*ox~1EH#sZ8ZgsbyzY^Fqm#kZK~c2ed_c&I zvpqtvu+>EW?f&9&ozj0@fd1D7>d9Z*pD-Zee|<$egq^%)4v9+1qzMloGal`iviN2% zXi&Lmj+rhgywqd4Vh#_|Fd;CjU@wRG^>7P4UkhnUPE#%k_|(c+zpp2rHed(l?dj1W zGTpXx`L}dE?rQ-#;aJ2LDvloReox9j^BG$vmRbJEi?#Izq}ergYB#bHyURT{qbxtG zW6O)({^tT>cA50(!98v(m*2ur!H@M%gjC#-Z8Y^PkXdFPv}ZdE%uPs5y#Fm{S{yS8 zC(Uj0I*Y;vlSgV@ZkHY8uvsJJuQR?#%#xWWhkh~Ov{_9F<7(GRjc_2|~CLUgVo@|!kR#bd! zwQ7!Z^oOm#?b;KsFxJk_G2n0`nca7}!BO1V&K!Blm4lDc6Q=P}pIQjlp+g&$WOvsS zt>spC1vfj%dC|%A;VTKJwg1vld*lPRCp36yNo0(Ck1mI+CI5n^{q+wiPRPLH*Bj+N z3o&|*V*hg3TCEW&erZMr=t31bkI{_<#%3Cy8L8$(dYI<@7`yIS@60Di9(Lpzb{a zLzj#W&K4dtiH&x5m!+2fi@J9VvP9X|MZ0X*(y*|u%lW|wVt*|w|8wr!)!wqLFN z;@-DToOL4h`E$>^^WV(K$eA%_MCQmbKG@x^IBT;-0$nh))eZ#)-J0H0Gm(~obw6FpyTUZ9aeW%zc z2P!g&j8nWShm9@zU17HMkZui|{S)Ao9+7AA#t1uB=1Z7Ku!5woS;St}Jg3k5^lbHw zXem=$HlW_VngEur+W*6dF$=U_+!b)1H37bdL<1KRK;=bpN|MyqWN+BR|El{BD zA%y6XC4S$bx=4y{Q6alDxW|ql=<`qzty9Oc(@d44-I3QI3;6NHluJW$PbxOaX8wYf z!>{qqilU=y%h#b#X-AkGO3-ahz^|@(KL*IP#&dV>IA#qJ?DAq61!(6e7-1D(*J<1! zY6t5+J-*VHVsLhahqqpGMY{=C_sEsPCS5@)V*}8>xfZnZ?nC4`VE!QV# zN8AA>RS1uw*U}yeBAI6_F4X7^H!G%crEjDEENz!74_LE9t9fPQ!vmI|_P_DX2<~@U zN|I~AadS*IAsxvn_`?>U?A|Jx0|b|NSRz1B|C0+nk|((EM#oSZE+duxQGt?t_zc4x4h5tjhesv?(Opm{9-#HhXBYUkY?U%(w5 z9$K}$U?kZXtkM$eqemzJLquMskc?bSB6UEjUBqG*pp^=d7f1heZ>_1!~2LT*!rvpWUufM^r1(r$9pAHs~ZIBITqRi zbK+hZZ9DqsaVTCuxdS&(e_@I_`3~3QFsw}~@rcBiQt3W&q)$=dsKzNXo>pXQ-*yEj zZkEf`2iiOyylUg)lJo)HH9^Z`<|mN$S%Seoqw>I>D-Nj{OWCi@K zf?k;R#da4#4!(Rwbv)iTKo4MYpco5R)wEQPGb^S({eddvkBST&3nf=}Hn%VT+mxQ^ z$efS3P^pXte)yyH_4DwX|8u8XmzEpNDDg$HRf~=m4MrDDCmq)Xn0S8{I?pRc`{%2G z+u7VM@8|uO*yv5yyGroKo@o#A1ys{IOZ3XIFD)%RA7+ApVM z73+GQiWis9z8lxnb73*$0xcs*Cv7W97X>5KTS~q-KUW1c+?#J9wJwetouvCZ;lK$> zAwg6Tfw4D>5u`9~7DJp&GDIwa`bX^z*{!;7t!9Zo#7Do>0Zrn;ss*!Qp2O(J-Ed`x z`b^<^_S7l2f4*Q;cyYSrL-$GN(Te#ryw@@$Ys!9|wS)O)96T*OUtZIftS8ri=)J(1 zE``s)A-_>@VIcM!Qn46_m0VcfQ8#i@-UEIPcw>8;;ZR60StOvBfTkj$NI9a$QgIL` z32fUzMtq2Q8_9%tD4D_~u{pm6!ah(;m_Yi2UG(*oIQ_I~$b?_S35YJ^gQH1k$)#L2sH0~Fb@P!BlT;MBXM*ksulFfJ4>}4(VhU8`2InLo`{L)3i#01xR<0DXGoHX#Fe`ajz*+P}VPQ2v zOiY_oA(Keql*l8ri6b&a$@x1c(5fUKNr<R4~tchwkm4=HJ3Q@2P|ZIA~8}gi~cJ>0y{}-@UMNI7kvLu z`vi&uM%tFeozu!Vl|u(#IXr-lq6>p71{7>43?0s64u=CeY}Kh#$QwY&-qcLR0R4V=K{~?AkCGCLt8{B`&z|+QS%#61#RjN zi<&8mNOL=#kwWg=ev_p_VtXCH{aQ2_+h0cFn@4CG;f@OXZ&t2I&BL{Sp721Q5`H8!&YC&;ylJvDvJ1UYC}RQJ=hvq0UyH({lV zX`EOiu(}cT+X2^t0?0POhR-%NXycWO#_Ts>FBvo5h#jSPC2kb`$X53tJp~1Pp!9Gl z@KIhGI2iPEz+t~XW(tpQNV|FZBm>t4f$6q8Upgy7co4t>{6h5!jkI>J`BHi;kW9H6 zE_+523&=-dQIU8`LhNi|E{{tPZLDDBI(2?X(cVYX3Iwr%Re|5nlkvj2n@K**@p-3W z(|e!X0v56Ex)Uox1l2i4VM(Wz&We#9Nlg5Svx3k|z>7?7vuFi{cc4Sk7WxFU!-jb{ zjQstqk={^l0ZLP_oJddZ^;<&T_zuHC1YG_gTw@tWi9zE1`9v=6y3Q5fRevt9SZTYI z|8!P$IqUps@N?|MqK)oFp|e2zWA$teTNiG-Y{=fG1ji{&1s~j@FK)$l^fJUkw`%32 z)2zu@H1FNKA|pd!V6!RxL-1LxQo_aYAq=n8KokF*YZx?!X@ea)amv!O**E7=xOhy% z@quwU1npn|bF%gIp+>X54f$!B0J6C>t#Q=8V3__-oSj;_%M|p3+}W#z^D>%elSR68 zBeyT}b{dI0Tjd0X0}fxiP3G45XuB2k)9v}jZvq`~P;=^P!tRxOXZX>B%PAYWXb$v# zo~gUNx0{h4nVH(U_`hjD$3jLtE`n+c^MQ`C{ngb(McP1G)J zhIwubk6_UzH590)_c1`O9g22hTmZTomycKlMOcH4!D(o*r~htkUp zI%2pG{srXcI=bEJTa>@h1)1XJ+8?@gQ#TM1akAukVz%uS(3CDQ&R_ z6s~P)Qs~XP;`_D+rRCDeoUWx( z`32qf{(bxUL7r~p^ue6t-QuduGQ$mPlu!p77~yfWDyJAG{iwtgHSManL{pQYh7oud zRsoUESB-R-lgG-MOV)cQQv_{qb|s6?W!!-Ga&lYDpc^PsiEnM*-XG6%#Z#)!&r<}q z)xV#U>5>U_RI3nAUK|g2_;RHawz%QITy4wT#u=2nnCD-w&tCcm&_^z3iNI@ZFTK4A znSd{7_ja;eHMypF#(v)0@d6?$-BT%j?7X9!{RKUA&tybKAtD*POod-rYXch+^-W?(CzMtUu8IjQ>Q_z9kXQISy)}aP^80cf4h9YRUsInYYTic#E zjnlK$YHgOO*wWb~VjX^RwY|7qw@yg7WxY*&wAAg)@`NO?T$X)ySieMi{Wf#6PoSIH zJp7&9l}bhW>6)mE{s{s3q_y}DdEVc^ZvPvt_pjXP|8QxKPK23|jvJ7RXa2sN=7%)F9dyyae=*#>lOO2 z5iSUPI2iA~LjpL9Ud_Fa04S=ooBB!PqX9Iqm=x6B@thl;+LD82KEIZ3%$_kj^NjT` zbhp^{FS>|=s#$5`lY8?gd6QRB#F*zmaF85V`$>I;f<5FAIAW|!)IY0%aD6$GMF+Q5 z1}_18Q?`9p1h^7p9g=-8nAe_dXI2D;)`0UFg)i475`70q~lK1jx&SE8PQ~J6h5C6{<7e23IX|a`M?@f@naDaRqI`vH!G64jl zFFIK*|4W+NZHy(`AG}vNUrQt%8=V;np z?SkTFh!^X|UU2mIgBa3SrhhI3ZI~cL6It<|v=tz%qeGu(?fj6X$zuyhKSh9tUQ^DP z2g!e<*1F!=yUDa2mf8}H{luPT0B;Tl`D%V%Qte{uM+JdCx7W!_E1t1I53CQQa}vLG zw+iNYWWODVxVvR5&-EK^851foM^lk7E=((Bu&HoNNo4;~-La`P9<_y%VV>HXtdaw& zz`{uAdK}@AtcW|gLEwmyh&$n=?Bt(fL|V5#AYI@(;;jlp`FUj!ajhPZkYE_KYvx4Z z`!HApZ5WZ}Ww3``#a_UTc7QFI;OAkXo@JAyy}ab-%92|PHG2hir?@2z`2pdHyhk%^ z-;uQ&M0!z)10oDOnh)+0T=J#&d#$wR-AW0M6`woYCQA*{mXc)L&Y!~cp?GYd^gQJG zC{R-4p6^JNT_TdTe%XE;AF_fL4}uEob7w!qOo)usRozixkapgwCF;14?P+t1f$G13 zNuym2q!PF6v6L^x&xBKGfD4BgVyO2hx;-^foUaTt6lBeZjz7ye;K4p|*BUI5x#Z*} zdxfD*$$EEhJJL_(Qhn??v-tRDW>3me^m0Vzz@zo4%d|EPqgQgiW~BhJYOnpw(nqV_ zGZwrdqK*q*92R3jVN%DhW$uy2b~d6c)9FYRuJ-9_3DeQl7F}XHb(}s!5+GMJ-qkS9 zG%-<*#F{4-vTH`OzcDXEq#;nn!b2ZLTYcO2b)Z=ymV(*E@8gkzF`(7=z7b$E;=2iBJs_5MZTy37OIr8Ebi3o4l{#R2^sll=SThIVTcJ}{pT54F@uCbxNU+DJ4%<-$D-K#t(t`?c2OQ)r}t%4Q7 z@W&ZxGBxc>I52MLc0JyZ#XA@jPkf8W3#}@2bh`-nst8xtFWsg}_5z&R1INd{up z&Q8ajwRqu2-p5Hk{a<~?OC)JcyFQ1=$WorFHHq&QI3)~*3XM8bOE5$Nk$H(b zFS`%Cm|l;|&PQ7bSr>|ESBuus1lKxJKK=5!C6Hgk1Qnx>ICNF^DUC4MbE}DdUQ()| zvUS3fobNVY?{?dxz+qAVqmz;rp!T(;4wPP!j_OEq0$F`C(bFm`R;iz=4=yCT5v6U0 z@9h>>+z&(9ueFZwLwVpfGn(1>f; zW&olMS0{sZYDwd8|5d(2q-R-QPZ74xtUg7?`8+ve(vwLP;W9NkSU2k;9XZs zKp!}~3^gZ~5fx`xQeyoG%f|6Z%|TP5Ne)^tBk zY#e_W2C9QlxvCg(|COlxylaBLHjgkVHDl{S=l$86vN3+OqEJ zX|<~`7!DQ5H11DWM$k`b%>#nfq~YI$H54)eyIXc28^%MLg*L?}?i zy5{x!S?BwT1BpaBP$QwQSYTbM|! zz>>j@o+_thp_D+|>w}j-?*zyHxPZcgH8z_!_T+~)1tr6gPKI95iQUHG;R&TLu+n!h z2WH0ZrZn~>Y8DEzLTF8k1nK&fH-Ja$F9_?`YI4%XR$5?k!oO+kE{7n3Msj6Ynxd(d z==-%V@t*nO=P@%<`xuFNBi{ZLd(o)Hs>_Y)1 zn|ISn(lG)nWknRQh3e~yX-ad7k@S&h>=f_}a!+2?{N_jpNY%{z| zc_(?ie!9`mMVJt`Bt7i zG7;+v!k#%*KlW@}@KUaJFi}U$+r<$L^Q#bGr1dj(qpI906+tjgJj;sdtgh;%wftpg zO!l-%-NcUf`)bk1wx5G`2kAg-RT|OhM{h`1`%^LI)5-(!I0yoVA1!b9F*;wquRq^? zHE%|oCZdyWa$mS_r*Ox*^RwLVD169a9`rVu#Mp1}=1|6fTV-MVT;eN+k>6|1+IF7l z7(OZ>JW5Jyeib)a>nh5EZg&zPTCNM)8y7G4zmtu=IpAqEv^k5vSS!y**pe=RpO@>G zq#sB+bd^P*wU{EfD0gWh6o8`{sc-dA#{SY4etGFa!vK%eR<(X@q5_hJ=eQ_7Q}d5@ z?4_kU{RMju4!LxS?v#h1dd@w^1HV*%ox*#=fY&y9NsS-Ux%vmsG<9wB5YF6J9lV*t zU5jpwp|v?NcatfWGuC;5CS*Y$SIRMYDrHKWTWP-&U*+7UJJx2cXi1w>3Vp|$pk=cj zijU{OvRkK7up_n;PcnoZ((CLt?};ybm^-k!eDEZoRJ=)9bkX^?*fC`u29FnYOToXZ zkD5TOhQXM6yD(KAv&tMoVNqKd_S6u?P?2XiK_+>gEc3s8xD;@ZTAKo zOAe`MJQA|#?!2*Id@w3kJQ++Y%WX~`UHzZ;5X4dGMSwx+7@Cm|K}lVrL8DC9>CE(v zKj`r*w29ao$H_DZ^z~OjdTV?g{`L`#K*DtWe;BQrEK2#u91ADV6&@qAzas(p?)at4 z9{2I|0rzX8pG48SlV$=e5TcRVd$M$NV>g-tdruHzP`*(oGLzyL57r?{+0~qelHf_$ zDVJks@ME#$OJ~DTPzblJG(%UGL-s zH+vR<_f1fgs1I`(!Dzg2&=E%c-iqE1cS~3w3bMYG^XU8LYR$2_E+*9)HKltS{jD}` zJNNx&E*ZlR6L0yfd-0(5P1ue++@ITPz#x_1b{>*IFSG;Fr!j|tuz@yaoE$xiV8q#8 z%4kY+Zg1z-3^J%{=ehN_nSN^f7elK?X0v+rHLF5M&_>_h$E>eM#Yw9`Vv*$Px~SDu z+i}KaoVHvz8V95ng3Dc@xiot_StHG0`NPPTM@QS(b~DrTuz1O{?~imSa&{8Xy|CpI zq)d+yFOlb=H5;0M;lsNxu^fkvPba%V07ANlEQUQ;?yNAEFO0sAuc=N@pYdTFz03jx zphxgvxcm2PUasCd|CGKqTl$51krR>7Tp{*GfaA8@7c-BGXAa=xKM!yDu(Nkaffj)g zwEShNTM~D6Hn+0C^=jwh%;S@-t)s;)jfbCnB(!lbuy(0nS|>fbfXIM3Q^fq{GL5R#;y4Dw!HIa@E_V&VD{MV#Z z+{5cbb84LxN?7yX3ZkmktDNhvx`21NgPPh@n}+ZzgVy3960`U-uZDoBX!WPwly@2F zWZ=qLn`mvey)S{tlD(J>M^H9RW z5!`sA9wCci4{~^lzKK8G&1oa@>Y~-rncLUn*|zG{%()OA1`OAGvR&=c6q`z-W$?<)skbjjm(irIvuVuTIn2@C)<;L=tH&E-_j#N?$>vNf zm{ALpmYtlWV3lf@d=(o<~rEpk(HMYb`V!pfBrj zR1IQ9Fk-hAE_gALyW6*gAI!0~;~zyifM(OrCTmeh0)K1wV4gMc83lL$(zo(C#sKM|8o zbdYneT%S?V4W0%L=A-{G`^&=uXK#-8FAs|?F0uvFYBsm=eR^!1jEgT1i)a|!Ko|k~ zcHD!(gb0T$BL=Neu81*W_5QL9f+(Ijb5DM*9VUDy-%XLyK>oDoG2EFMRD;+wOQsp+ z00*u!t|^nEE&01Qk%@<%os6RiI6A~}+k<0?2l*wDnG5YETj|K}`P2ILV9QP7=zp9# zJXUVsXr)M4Y^%Pc2?>JFYY7dl1(q_SJ8-hBI9kWRg2hcDeA&GnNilx9M-W8b%=Wi8 z(9`kS|1rb_E>TQap=^G-?0aSE#poP_!TmBv&PZZorbXD5)rM0;xXE2y`13}sh3>|T zWoAW!KiY~{TNQRG`QzL&Q&h2YXWozM@{0<=Z2KfwzL#siHe3cWScwsxxjEx!gVWwQ z-?_E}8Om>vDjGCT&c^5+vfX(W@a$B1nqq)08rguIcQ?o9^(6Hs&&A@%K z?*8Q&(N{Hz<=UtR&8G^g3st)VK5moU!gKqUv?wth`eZ=zGCpV;rPA#NBeqmq%OS~Y z9yv|T4Pq$0BP$*kP*WO0>M-D+gBK6L5BtXNJ#B?6O{(P`$d)GK*>_)+b-*U&q)b#^ zv+(DjQVKHzBPm|q0Tvo4f5j?oAZ~ONI1Yw#lx(|>VRCjrtCuFcODu>LJ*Z5N{E&Vk zoNlP5q>gyur4QDDJK`a{N_b348qn)4jo=DWE((Ip9OF&LIpPbvNQpOI)_&M}WVP}EWsVo-{suf~GXmv1kVwj{Trqu3<$MeN6aMl^%&7l72 zq=6hP-H~r|mw`S>IGl}(ffM3LU%nQQ)|ewThs@Hz1@QY z`dfH;_W7aJ&z?O*C^~;Y38<;^YT~GG`biDQhHH{u^b`i$lH(a@c;=#?u0UvNRN$ng zGi^k@amFAxO(e+1Hq!?u^W~gjUVQ))Cr#j&A;ad_-4X%a$wv{BV@;C3%YYz7vvEs< z?pr(P@8+Cr36~-5QVYE25o`YRC=-hLGd-DXt6(3j8I6!I?fN66`~^LH>Gn(bFqX*! z(f)K#57&$S*OT{WNWU))-p~@qhi3W??)Mx9`?7?RuPl5gTtUVQ;{$9HIjoY>k(C z`1m@Rd*pfEQGGmoLu1uE9Mh0nt!?(07VUhZW>$)IB>VJUFXD8^-`2Sx51Qw8fRgKR z$H@=B2z4`rjr3T{4?89TDvu){zB8L`4q>W}KR|?it&VGA-T*m9LQnC z&Xo%8I`$1d&z#=aJn~!DP$OQi4~C%h!HtRy?x1u_FpaE6CF7extB5VFO%}B=%HCkMW`n z88@f{=30YxyaKK<3dWP}(KDf{Z&7YYf3CG!{pQ|f((S32GOo$6=@h~MlDjuZXv}AO zG@|u17{4UZDZn-}oAtweD1>&C-@K6y5iKFLGOl*DE8jp&X2#Z;xD;XGkQ9fZSN`;j zY;$3L96$_#_#kG$PszOT`jMVTAq|wF2LVR*&b}t-|{yocW`(%5XyQ)ndIKj=qe0mk&0!ZZRV^-FFkR{~Jd+gV?(1`5e(iKo zBxGr7+ucHPb-Su*=eDEB@>0{<`yg)CXGy2{X5$1|38`jF*Hyshmkk`;CcMv9-gWon zM#J&p2azPb@TW~MIsPyN z?`P?-g~-e0Xq@lI9ly`*Fp-;9;)Ig&&i`!f7rOw_@YBZ&kDeQm&p| z+WxBd4Kx>X7x;BxRh#k7_3DT|&DT%lo@IYS;Px>T3AS(XaC!+u1$4qY(ZTY5O(9}{ zO<&iZ&hY-3$b>Hvh=hbhMCqkfWxA!kB(09NuToi_x0x6ttjW4X_c?9LDS;djST|47 zI&z7YYJ?>MK+P(Iq(~Kxhu(^ucb(hBki;g<($C0Al@c3Hak=zBFZL&guja_`tpufn zAlUegZ_+i+QlBzIN{S3R7z~}8Q%d+v&FEV)DSU|@9;J!AM4=}-*(!D=haTom1f(Fg z{j9ohTDc)0C&k&eeo8K+7Tb)5?@7Cu36|>CC}eO#3>6xieFdFu1w9X7xd7C6WYp&k zA;aRkJkr!XGH6=Trv?XrHyVo#&a#4najYv`q4o*`lW7W~oX~LYrsr5;%$ptg#b7Mc z^rd6LBZxO>ku#J0quWv^HZ=B;KhF;a88p)>Pz77VneU08SdT(07V;|nufekmtdrQE zv1}r;ENr7N$V9>fqyjfQVu=51BgYV7-&9)&XS%_lfGKdYbE9hzkcW;&&}R{lflPg2 zkm0mq3GM2B2$?UIfqab-_40@XhQ1K;ZyW6~%_BYV?_zSVXwA+iz{Rq!XvrNLX>J>7 zhR#+fBPhtSAeiqOIkLrMTES#kc?EMsF7WN~u>^$P7%`Pjxsw{$WpMn5fYgUNP~h;L z{I$f_+WHmX*bsFAcCqn(cM8aS+427?c79(&{QHGQh@MpDehE=ia-v^fhL*?vnC};p zhVb+hlFAxq$3t?gKvn`8PWZkCW%qc-l%|N_iq$3FnEG&bhBNRie>aNq^HNLy25!s6tfYCrC@RKmls2!&JEkk6sOFCyU`Ujvnz)Mt(2EQ|GyapU+In;Gt=H`s^d2CBEW{ z%h-p&jFNx>sHi(w^k$U(1({>^&57i(GmB@2wvMMyVou#Rz^5BKyBVpJ)~qQfvsnrc zE|=#yR(^@1a~dHNE#v5q6=dYsjkn-=&CF|v4#(~>`rWj+nHjH4Yzm??#}m!0PFAV@ z#Ann+BG#4HbmNDI_k{`E^_veb2IcrbBI_DVJVp{xDulbA{-%zrMd5@wT2g9)gXC2L z4mOj&-ha58Bj{I2-sMb~1&(btP8iPc2r#=jPu^K&t5Ua3{l)@SQJFur-ZVLFRZ{14 z{<5~e8*rI&GuY&N7we-6UpA7)9n8aIiD`?UZ?h^un@tvQ(0idKaBW+>&B)v#_JvV# z^D3fG#+bazwu$TP-v(i@Z2YK5+pB`S-?;2P>0cK&;2xJ%gRnYVS?T`K;|A$y7Prqs zM;`^7kwan7`MkfqEnlIDx8;P0t6K~X0nnts_29~4EedY_V2Hh9e|Ws>&gym_o>P65 z`E1ay`9L87hE>1mZPjJtM_^gtLiW&O;C;6^u~sZ)vF(hN{6MEJu&!UaPoNfkwW1A* zzOL%F;bxR}RAn_PW-)GTp?EF=T@_H4#pXB6Kyecepkubz+hkuga$F8L>L*{*ss`Ht zDlOb?XZ})dY-D(}m~^SoJMpLZ89*>TDjFT`d(25bMa`N&+D(){0UdHXc$l(TE(C}M zPopp;X5|htg%-?{2}7eJqzW$^Z(XCbmGQFQHELC76M1M(l_~a2CUH8~rI4y(3#e)6 zVo;E^n8OcUgW3oX&0ix*05So8qIZYYFa01276r_LrQ*oCa_6FKSLsxqm?lJ=RIO5a z;)F%8<8Y4Lb5q_@`CwYY@=<5}rce{&7g9gclya`^1V@0lJlTkJ>=z>~qR%1=f!fr` zFvVEP)(hv(ZdT`L%MIgcxT{SH1L(4x-Ffgu5;T!bE_Pbm%TH36!u|40-6q6p|#2;e!lYYq&a5raZ@Wnb@ZE^`@ze9 zdP4;}Zt5N$6|`3qa*NB`t`_MyKW+`_h>rZG5r&saFRQ$J)X>~GbDaqLh)u_N5jk&S z?mmQA@aZ7U?ovZ3Ory29zwCbFdc~3S*jM|9oa}FCx&JRG`yZA_`tM|7Z2z7_5*y>+ z6>R@1|IU4tfB%w5;($uP=g8DqI}Z6qZVe$o2z?H#4-nv3%d0b@VfXvM_O^J`A!CpJ zA((P()U6}_y8cxFKCgNk@j%vOxgkd2Bno%5MAodXl>HTDjqP@{=rEma_n9wjbvNtr zxGBP(@@C7tR~3_uf~uFE<7R>6jmO!4?InbGk5q{HRZ%@XYS%ds4yIkn8$O}dHMQ>G zh~~XnaPbEP^plnlojtS!f08Aa1RkG+1P|~3Anjo zs36MYVzEkpL;;i4UWx(IQ&FmTae_$3m<2$- zHT^3%_lLBww1>GMA@(Ye6Sp8vWcOc#l^0a_y_Vhfd}|@r_hzs7@UYhOR)U(?!A$@( z=Hss)F*ADw^3n11^M$oG$6P(h+9hfS$AxInt`!wryU&%N#8tIYsN6Zh9KA0rO@X3# z*A9|PCt}IifaHwpK?&ZexS&E_H}AIPTS1T4x|0$Bn5G*fpD-8bvq>rOS9a~@`Yf47U!p!3Ik zEbXHirnP&fTOO4G0_8Y}+9iT^E05-fBsaxv?Q%U-LA~ZiM}S~PD8dn*N&*Fe#INyL zV_?8+fzd)mCPn=G{mi{R#1=@WHGT@-ZWBm34FT%1v|2^a~t z^-quc$Ct&2rU|AHBS8XwSNU+;^>Y!N+o~9P(jpcE_uFsx$KD(HNF}=SK}Fkq_xRy3 zM)C{R4DbG{?yLSn51^Q7u*X1^%f-x=8UR_GJHJ}!x}@6O-~%^=Lf^plPiL_R=58;& zT`}Nl1lFBz7Md zB6i|8a3a*9-QRx54NwzK%MPRKaK<0-(;NBuTg1{P8^;w|%d1jmHd%q)fJl$RZX%(m znyaW<%U5D?4L?-;i4R4v+X(lxKx@pkxWn@HOhpZdHM4EK@Jo~HK*iZm1sg zLI22Q(sz(H8aHnbqQFD+HksT1R`1U4wg0Z?4al%i0j&15%McjKExc=5kc?OXO^z}r zp(3J;%zHMkf+nYkw0vqLPdk4rb`QJ@KFEcDv?O2}PVD5{7bLcx)OroHN>!XClgyd} z#EcOc(*%!QklQ;@W{=GsOP6TwyiV~_1`p2jZRCFk!*#ee> zP-|LPfH^Y80dl~$i<&Sw<7INu(O>Cu(g&zvyR1mwt8RlZAB2~ki5e>~!eulzEikXJxB3L&!P336L%^~ltMVQfFbgUD=LCZeK3!bAcl8z!v^d+Mb>Qk8%IPDu7^7Zt-V@b zf_ulhR(eel4r+q;t2+zBdvN~Yl1&o=d|~`%%MMuNlO?C-3eU@`*=l9-sWQ_Z9f_*3 z{R%jYu4bp87r8x`?yl20JTTaEP>?6vxKPlHR4I}pMY>I0I-tQ{PEcz|xL{UFDJ@9C zQ#355A3SG3#0sGGcD*xY82O8Sz2`0rON@ts&(zpt(2QzyvZeE}$od*T^WNA}&~OHv5e>TJ_cx1d?fosABl^e^O#@i)M+wTQtsv*P^q^ zr~=c*l$cgDsJIvm&AiW1q~qE5=7lNe=u)L%d1@;QScr4tHoq6Cw$^5j4Oc>>PM-b+|5CC^|1srE`-(V7OL@XLs<3 z_J8tHWQ2GA62VpWl0KVRvyWK6Won4_J_$MAwl55tk-Z;RNe0(GGnL&&ObyC4K%Ydb zw^Ko9ko`p#(wsuaNbBbC4ehW-?tVLY_qh5gVz_s>E6u)6n`D-b*aS&eGEkPB3;md^ zIvtx_7>Yd`omjY8$dzqSQ3W)M>oi0LWOwP~sGDHV&a<8$Dqqp#*Y) zB5L<7q$RX@bOAbyj>vs)IqE&)UI}$REV6g%U^_5F1n77^T{D+5nx7<%u*QCOwV_ov z6~vi9%9WVdeZ^KkIGS->j{#W)G?EfSeWWSq;3-=_Y(N4(es^6w`Q@DD@IbI1fsI_Xnt?`-E}(zpR>I*x9X#vm zI@1S;`?YEDwYfSs!d6e_RQhVwLg}R~=$_3G5Y)IJ(<$sR`g`#QSj>GZf|rh0*u3mt zUaaWhb+hsDgBHObWg7P&_=-elC?jaujVMdGK8Wub#f!&~oi+DeC9*t#u2Dz76E$XH zsMb)HQ7ijX6N-N?{6RILVWMowId2=dWpVZGfv+{ip6Zomf|ts^3egTT>Ft;{a>HQ* ze(9R)In)^C=BM&uYZI3&&bQy;Hf{0IRF~gzKAqd{5)&dIIGnM+A;=||?))sl5>k}P z&jenb@nK0QrWzOnwPu#>!c4SNsp{)l%eM;+xfqG)>g!X@2Lhkh9hxt?K`(b|*P;nm zC~>s>C1YArhUpwhjMM4G@CFi2EyFYq`_V@I%h>CYulN@gFZ&kFrEf4KMl2`R<) z*In{|%f0vS;-i@UcJFPdX@6-5qkgq2nvZl=bM%B12$X7)$E}x~%o8|t+H&z=h4T!Z z>%J%+?QiLC^V$-1(o`P`CqO+0pwo>bo^Dg@?SS`;WVDQ{)4?QnHCk{D7 zi)G)s-W5FWr->ZOCXVh0BT>IxM;#9H{SzEmatbOqNkG{nRQ|Y&FR-hxqkl|5*!7!W zT9EuVRR?4+bL2_?FOwJ8PO64VaV=WN`v#%pkEp;7lU4ZI7M6sFjv{vSofm+Z=<7}k zIztf4jP|xVu$2T_2TI>P8`2n?PCxLW2Bt>T&_PM<^@^B;I&SA^&=mUbP~|`NL8Eig znpl)27|@STfP4om5AoGB&4q>t?Id}2NN&<{XQTrFO6K6Sxh^G=SOrAVN@$Q@z$fra z*RBQBP~tjKuZq_$@VPK1jw*yYoXYhAkz?CiGuOHvy{-}P49o%?PEM?<Omi#PZ+f!mi!d4 z(*micKC_G9=T9x-jz`*XOIn{OJB@>og;qZv#+fTk|h*;I7{}^?~a6r{rW= zl(sayK@O;7$UJvju%3q)9b3VNw!uEIGE*VN9h;Z$bDPnQP?;ZZN+hRXox}&&tObd%^(kdY{};JIy5J#;}?ooT`Uf$^(u2v>+G2N zd6n+Io||LEOX2;ve_x*>Y86+|LeknwqLQVX(&PCBb?1qp$}LCYfHjuWP4rX|+<%NK zlKRGzAZ`c2p8@V8m^E3)hm5&>NSVVM5nh0ehE{+Cd#v-l0A~{$i)p!kq9?xYaN`YADu_wYa-K zCLZ`x(xdudS+s?T>_*`^Y1Um>E3My^v&3+n)F(ENvOmHa&*ePN#@HOjD;S7 zZPUz1(bAl2B(>$;deRr1#ISer!1QAy*I3jz<_l|K)DRkU3+!JHCKn~fjh`3!R zRLYrLu1!ZFH*MK3G|v)StoiOm_o!1=M&Lex?nNx$k!{rtw#KcFISIJd+8i9ikdDA! z#Vd3Sd1YUY7sSY2vgoly$FMrZS}1!_kd%y;t@{}4-}JtyYD+h%3&W>?R@!xg-KGfI zuaWMIx+{IK%M6R6j_kTgR(m-zdWDa+x+P-jHVuM1g-y`d?U}jVL3?$iziky{Y9i() zI!=2vKc$<#t#0bJ0Fq_z>|ztt#M!5*y>;!~)6~tCxt$4ng$!pZ(A4ef%xlT<39+I5 zp_|Ob@|kx{_fvxx{x4+buiz;5|Bv7(_J0nJVrKq_x~!_TZN}fQ+>~euWNWnziFvr> zC&ZS9-LZ8RWn@+GJ_oT;08rW}&HJt|hulP+y?Tm+%)Vf>cH-OAIMeO;8Ex`Pc)=e- zhsUqvMJgF>@G0hn8(6k4*%n2!XnvG%}2PLsUkAN5?1MOxJlQ4R`mWdzxAcq8V+*CB+&x zrtk+{iXnp|xIbZwF888AE8Dl$EI)PJr3@u^wzSjq@zeA2I-Y(FGmX5lkBWwewj?Qa zFQn#Ord2^*xAl&*){WnhjPvO@SwQc4sez=&Ltn3Kfm=^&Y3V2bq zB}JVwPT5%cYH6P4G_U74X+G4hQL_e^M|FJsDTX+KpNx+O7s~ z>-Wi@d8a*aK%8Q>Iv9?lnl;D*G5a-cWLI7{DZPOa8$_dbKNXU`n8PXL(T|pREI;N< zp3Hp8ElD)fYIe>vAe1YLO{6a39L`mWkZ2w+wjZMT-4i9B#bc$Sq`0AYG6vUkMeD*9 zXVlo{GN#gV<{U{xP*4;&ID-Si@G+yslu=0GAgjl!l8`(vuY5d71?r@-peu?YmDdS9 zec9(y4ijhpLVe2IjpiL;|I-K`FW+|GzQ23=1dfRP7iy)Y9)}y`^&Un3K_SAPvH_Ow z$dx=B_b9&g!7EWcSd#H@JibBlX?>7}u#CnYd^l(643t7&YqMYBPnp)zUeVwC6ZkRT z2Ta@+yW28g42f*_+|oIUkP;(!(UMo|5gCL}>2*V2Kv$XrS+ui_h|Y4w(}=DqzPh{B z)v5@_4O8S~^)+{&uk~Q0R}GU&EbxEHej++STU~h^K96yhqcowj{UA&~paP%gDTM;) ztsS2sPhg=g+aXFqiepAPqlbdBB#>yQq?tJ=6^zyANXOLb-7UFt2>V z4_5px6DC-iz^U>*k9dI3$q_?^YMLKO2OG8@#-zdd$8w<$Hy_u2wOMaz4x`sP&|`rc z7n!#4k(2f5nycu!4^&h~l;zI1Ph<3{4WQ~&TNr>B(+|nTd+jBG?v7D(=9JEU+-S?@ zikeD-IdV55N($y*Zt7{Dp`aiF%(X2*WkHO*Gl;2=p`u+2t4l6ohr9o+;aS z*NB6{HT`CrEH-zEFZ3XbRr|_mTZ4?jgc-bo7Y2P@ix&r2!%3zw)pIMo>!eNUz7c`Z zk%m(cr`Up%SY(T?QkQ?@dx~>vsMv#!V63$n8i1L@398uLB1G~X7J762IC{J8G48I$ zo=NT|Bcm^yk<)kbZjNf6O7m(ugRyWGaMaGTkhdMH?anGhcJ0KFuC-!6yr+?vKil6a z1=630+V9t{m=!gm=#+E)4y+-*SB^x8pkG%3?B60@9hy+(!b7{?>Zd`Jspu}6d)JE< zfGeBcc;W&XXHBd6LNAqm>a$$*olQjKI*oqfqz`Arn_EBKGx_S!@cN;gWUVi=6~&g4 zbN>8ZF#*^iZwbARW$EA!4&PS2MM)2nwv+G2ikIo@+MhnE?3X!{RRHt0>67N?VUcHRzrU|WZxFBA>0>MM(fPm#vl~w;NPJ$Nd$ku| z`p&OT4o)r@liOX_c#^c)f#s1lh)&n3V)80u7}Gkr0@R7;JcaJ$OWj;|4;N+_(k_~* ztSASbA8R6Sx<1VBN3JKD=enS$ZUBEFR(}O{{Y?P=59dh#b+C*5p8~rWSXusI|CH=%@@Rjtj-*o?xu-+E@)>>;;heBa$ZP|`g+OLEPX%SvakS+!5L-!VsmNm5YZU@}u{i4k2{f{%-pc zT?QbmYrlZr+echJ%Fs^~4FO@1frNPiUVvICLjQ?fL%1tbi>9a!g0l*>Ze)J(_;KXL z;@Rj8oK;8_ZT(;j3EOdu{&0nQo18>A z!S$<)sjq#|(Vt_9^c&KlAu8(JfD z7fF?I9o9egIhXqX3Z_IsL(N1LDpEMAhXZybxAOg7w++k>`pM4e2{LT}N*fMM7FtXO zoPx<7J?SqD#)kjOEZcMc@B&{Lyr6uM6$y(s-ZR!qT%^}*wbIg9S01}a$9217jF^O` zbnd~>GJn|&>S8i<+F*Bfl;;1*UN@uQme->3%xIWS2x69;Kg=*+F$Eb0VOx4^$kQmJ z@6ig8M}P5_s{%1Ms!_*kHDb6piFUzW)h66m9Y!3cQVk12G9Gche&5S0bDCJL&o5(f z4of!GBBo_Hmrg=g)=k|~QEzt2oSqs*Wubb|E(<-JAv3gac9CCOf)N@z%(~s;WTB_E zB|Hy)W0ia3Vwt^>{<(S<% zSjr}&qv31r;AuX+V#&&eqdGs?R=gSx(BcTboVB^`WHZblb)UMZ$F5YD8#@k@VbVyZ z8*{lmnY72LNte#bcy0iUVw{G?t|Wj@_*CC$gLhhEox3(GL$AB=qQw6u0q}g>Tlt2irwZr|FkOnjC*0FP+50hYfdyv zD=M!*is9tT+dBtZs>xj})+pgXN7e(poTk0N;Gfmt;sDmPS92=~=DCs~%?#Zz^UAlW zy!|H2$R0A!nXk|9ZoR94vLWKUjFrAY@)!rH<B$I5qTDZm=hzP{?Ajfg~E3^7pv2o>^HKiu`E=r292dlT- z5J5!-I$3R4^u@@F5H}~3IQ=feq@@oAcFY#v*EseNeIcN}s-Q3->jGaVvm@h-5Yw2I z5G84(U3mbZs+J=EI2D%w*0!%f#k{@oy8K}hStAoezrKUVmvW9EUFS6z2m=Y#1cixN z8~?O3BS$T!M~>%4BXio72NbGlQ3X@ZACCH6_yn-`!9Zj1$P)(a%dcUJ8o~oo83MMn zl{V@MnZ+k^7@*+PXBY7hBzE*F*$#Jo*YY0JixZ{ztmJ=nXRec&ynA}%!O?~x=aaO! zyYE&*xj5YM^Mn7h|FiSxC`*C^{z98>se53)9x$0s7j9J5v(LfJ<<7_B6Yg5plv<22#46kD!n%;EiZCCl}4YpWc)0}pnzt|Q)m){x~Gd~56N?tYaA zebL#cw;xD|;nPCnMMPWqG+IXsFB^TTXQ2r?mhcHxa|uCGVscL;MR&38UM|%4Vg9KwEopKd4cvrJONS;#B%Qen zIm6q_uWblHDE19DrjqzwcIv!q6O4TIeecfbY8-||%a*&_Wlp)A+{{KJK%Qz8@s@U8 zs2HW-#%)@uLKY6LZ4&4`mRBPbp93X&L&WKlcWPnYt8qqITUDIdxIsgiN{klpa#V9v z4AElLRjvo07^$n%Os?-T`=AaYO@*yaqT!@-O=8?`rI2%RM!y6baXM@r8}+I|9N{N? zr)Lx9$NkOy^am62cM>0OsTIVjDmu*1*}T+OUPMo%cd!x!S=_&n;lE;e{w8SuVi{(} z|Kk9l_`mARar|=#4 zh);Hi8xoubVm>>C6kVyP&MEle0~TW4Z8o3X#9yTB*kQ;OY5*%ooDi^O{2zOge*&V! z66ylU`V3t1fkni*_AHA@qLQa|%?B#1e+I^alM~I}{!D%B#!w~D7Y+~x?;bj4bh}=i zu!x-)F>f6|U|S4tbGNVa;CQ!ce=mv^H`B8p`)%YBi%2Jf;)h5hGtxdM2$5SMYBTx% zCW2UOLm}GwJwArPNpo?h7Rewa5^%!XAECSI3)BKd2IyI*d+Q(Av}^8a}0UFQ`N|b zWdsUv+8m~lRdxS2WfC2bqCDYXUHo%*aeK7Da5j^d3pq zxbl8pP1Xu2y7<^r#ol%5eB3u5D!tj0yJl7cXUXwtUPBqqg7(SE?J(s!tQ2$+x>AU; z1or@$v7P{qFqY>U+3U}V%qA7(@UTp)Ad8U&KTLBTy8(gbefcR@qvKGU9r@d}-hTFq zy4_X5Vl}kh#`dhfK`G3Mf!v%fq#=!&Ra;=%47`8{OJ4o@L~esy?BaT$POACpMM_Pf z4LJ*=ajteX*qI>fW_s3*>(+eCI*UvT?lc^aIrzna)6n~~hQd)2R~M-k-vQQ+EVW6W z@&X&{@^$%B>9&0AVgsxo`xSF+^Nuz~#>L}`&~$rLbs=-Ln3 zIrwAAGQ@I`47D&scCy5zfRuUE3VJw7+lw|v*s}Rhdm9C>T$m?}na5NdrPd}f33Tht zqH)F^wu9fk;~@=g{s<{Fs8lyd&%qxu%eXzUs|rgBD+EoF+$XfHF|S<cK?r_A0-^eAO5|=ra9utt%o(`5Ogodm$$=??V=@qQfC_!uFyv(z_g<(cU0uCF7@{ z-S6`Kg>SR>78_^k7I)s2bsJcGn1aZUOZM4olPYz_QQuhov~N01T8=v^Jy}tIDW}Vt zWU;aY4kK{r5}%vh8Z=V!wlA4$dAq5Dyg<8(Y|?~4>GO`Fx{d;qJpz(*q+rLlt-T>0 zOVP>_ZSAyq!rbbTP!Gn#c=~k&nFss`w_aTIGW#*j^5ESvp1{c07SXK0#4T5MMbW*> zK;JMRdTyB=*u7_Rv|W;{eC|}N+L4ZOJH|{#y23nlP0>cWOxQtNyMx7W-qRI2IEQ^7 zM7iG%d-aBatB|cfhPiw5$@_%H|1JM7oF$Gw0SW((Uj8i>{%gYZUqoq+KcJ3(a#9$_ zpNz2oyyb;~o`wBSKGMWjLGSOoD0}48Ezu*MWDSabPfwIf(U4U7vq!~e99{F zp@QBXaY|gtj*AC+Ap7cNXL#B@FScVpu(2ck;US3V=gqLe$ac4suQa!;boO!rO#J6L9T~p&f@D>I@hJqU)G6Zcqw1a1LXj$(#h3Sxm zJGE*Is?J(9xbuFPnZ8nn7+@mJe#4ZZMcUh^AVw|U9w|vq-%DXx|7~%=mc7G12P0Mh z#a0=M-#^m^o}jO$`p{m_^5j78ep>5sDs&}Q?PSbQKInIPV_e{bR7mgo22qPgzWM_s zwFN%yn0aS?#E5O0Gf<1?S2l4pq-J8^FGfhpHheXp63~6YK5S?R-N;E@{_+%a;>4ag zMTqOr-ZZeP&%>n~v+uGcFiOWABKQ0qTi$9p)|O3s+9TG))w(7$eEG3r`mRWJiw^Y# zwMAij!ctfSWk?if?&f{NPRdD*${m`sLV_tma{?%h+pOQ9AX{p*Z*%V7)vDEVT7!O} za#^$$dF{#aM;o`Um?9@=;3G1Id{>)L$zWWrM%tu^K6{t~Jt zrdW0y7Cv=kym68VTRxDg*3!K85kL&~ZmX+7eFyoy5 zQD*ev_{Z_g6;gFEGX&Obs}Oh)i1joFBB*J7IKwrrfMM<&=a9rRVpz&V>t$UOv0z$Z zkfAU>S?mO)@}>9?f5oMt5$}_yN1KB(SV>?N*Z%EHFYy{?80Y#s1WuS>**=2Pa=2WW zq}F)e5Tl23hbmr=0>K$0PXX;V5in)3C5Wa%RYP!S73N(F3|c79{Y-Y`E+PZvC%c{p)IicI^iN8Fw6R-ee^%z!?l z#%a-9lB`*m)o@QREKxgKh>mza3OXS_021JNDF6FIEXSYh>i>v}f5e{uH>2X8e4773 zRAl|f4ZRxb(O*&VZ)ewOPynK^xxim=60x8>v3>k_e%PI#^14J?SJLAMiZLK16o)3+kXdG*rvioZl~I@E-#^5hgE4AY8^920(JZ@&zM z^dB`Ht-qqr-S;_{I)rR7IS>dgCFxw2wjnh z39`gdKeSuA2Ie+j6}YU-REiD2ZJvBGY)GWo*y1xwDihPn4)RY%Xsu*ng&>okU=2T` zjCov2$1==GrL(W!p~?fq8N>XIPed3rmXRFQ*4M_9ipq-UkJcQQ zI9i!R5fOnR4NurXdV0OcIrTnKkr~D`9hI9pS^y>bJ4jlI(niX-g4iCyH8Y9EP(3=+ zV%RhdVj%|S6LF0By2fcgR9v>wxmvZb5jFw6kpODxtFt&i0M>A-(lRGIsnFe=K~E}c zFBt96B!jce*(FU>A4E2Os^FY>acyn9yfhw7DLWj%@sMQi;>kwtu%S>IL)oPvgV>HM zW4V$e>HaA_?S^N(MP^x;E6jv4l@?tfosoiE)~NvG)DuitPlI+GcvWQ4y8>53~@S}96eE0gHoK5vC^@KgevXODK2pEJ-iNGj54T7*xXsimtS|gJu3zeM?x{MfL z8@)@+HkX*Fk`Gp!qK3#|Su5wbxW&t@wuCs|)@cSpCp0Jn6dl!mY4MH`Nd{K;eDBW+ zR1`N2OZfZ&05uiH4CrRaobd<|3g}|k#XIi&BsMX$nXRdGxGNhfBa}pr$yAzL#`sWW zD^LQA6xwK+cX5fuU_}gI^T|0`^$@H@ff8gSj5CQIqC~WNNtoLY( z3bPAuP+q;;K3xI&ew0VI#MA!zF1dRwVc1;GMbJobb)I5liWp- zYT7C(O#rIPWPjS|y&7H$D&r;NY+knFzD?bM;xH(HC^s~io>!M@&_9l(m2>J1c+hxH z9s0zLBoo<8P=-{$S)3I7TEHm?I%ty`SaI@iVmMF7{B8ZxRXF_NMjH?j_Jb?t^>daF z=3wTeaz8hLXDBycIY!2lfNtVW(oi~VwLJ_SIAA->Wza+H*YrS`93Ovxc7r`urRjkSDFP@Y`$XF{t0yto*)S-CM)Dom;42VhYmnyjnG8 z58!NI@8}Ov1B6(xYcxc@pebRW8FaHK2I3E@7fweUVq%199oL6pTArP8t{WYtZ zO6%qpA|Ie?Qcp{rC79NB?&6`cPdvGgykv?;Z})r77chZgcBH=$*gqNb{~@q{$k@L| zU>WiMF5aU5)%@d6Ce!~wX;~Qm%(0z+EiwLk{$ZaT)(EbqkiWrs=D%vB9aQg(1ST{M z>qj^ns-fvX%wbM{*L5l0krJ0FYClH+1WFV(xyRFVc9EerSb>q#gP{|- zajB!rZ5AvuM{NmH?~uzBmKBTFna0yOG~oF)j}y%;{v6zH`KgoEC}dS=?yw;>u^n)1 z5i|Kxap+*+k(PU^Y_SHEu86S_xcw607Rg;@4Cl-d*6zGI-ugA%9WfC#yQ1bQOB44R zCv?{Xv53kQo_rXN)W$U>l~Kr5qON6EW^uUzi^M-hD7QXbyfAf`87lQ56cG;SR7irg zSHbRT%72&5j7A@qeU3O`#4Xp?g=R7`UZA`WAfLC%Yi9-*Ah$egwZEl{uK-9f+rA;m zsR}Xp*3`36(`UgTnekCZW+>5DNol}STQ2kIvE2Xlps242;8qEAox%IL>bfY7?YV)) zc;d`Cqd2r|$+C_z)e#IUsaFJVImk=1%Z+_ax{Nw9g2uLyB;E#{MP9@%9PuInMgN&p zA5**4fyGr5YaPKPg>^-zE23aIv|yPcqLJ*e%0^OJmkO8!cGZn08&T3TAfeXdVlt5C zdd<11v>yQLQpKnKEyGo*X<>y!2B!&BRw-R7yh3Z%akj4X;`6tay?ysu1ENFI4?fvL zQKf_Cl->#>lh*#}Ruk3AgUy8myl-rl)~@3oZL>EfnvC~)(2EJvtYdo)ukA692^#%6 zbp=E!Ol*F&RKxTzEgh|4d7+N?>?b#M;@$af4htmnnnW`Xi?{hiMA}rLG<8JC2p+?a z?j=?WQg0si2V{n@er_WxHAKj!`W_eF5)$?#`O71=q92#qe{enNvSWRZw?`E%G)vC^ zYgV!hqSn#vtZR{&nCF!+6E+ElhD3Ju{3&;@$LSdHSCL)`#UE{IJAe_Y5}iSxnKwY0 zHo7vq>j+KefHUBk1~g#SJg7t$GPdOPBh++%FpsdgH?+tXI8OK?RoA3!kqsxmSzYp@ zos$!MBVw?}?8hg2iWfE>@b0XtSa8)VAX75ECRkEd>gJId+_-I0E2H!NiA7l%(}|RH zP&A&(%!j8O3^8(B=BQj6@*7uxP2E&)WPlA*63)z`!i1WJm(#ahc8*0J<1NHZTZ-+d zXr>m!c*=MvfZ|4BmXy$HHDkaX?6^D3n|X&+lfabTWf)}kOX5tF*B#0zU|$5{9n3H{ zf*F*De5XW_b3D^Vnh2EM`+;r3@oni4VESBxu;N>efU$kS07G@8Q5L0qDAqW{?|vl z)34JX>(>c@a(8e)U6g?lsDwz$qvFFqu)tjcZ4H5`+iTV zNDv42xofTQ(#3yb2@eK&SyRcc9qbk z6ScK*`g%r`0srqzxahy@9TWcFalQYt@cqfw`Ok%qk^Uc2%!xmQj~(%=!&%@?scpC> zw|J3f>!;Pi>gs^a^q|e7-Ku|%xKnNgb;}p%{L1oN!X~81Y|NE3YvL>PJI&A`Xlk4r z8#Z2U5)NvJL;z9#3%glMrO9ZTBpWKAjRtf$blXEq`JC0KeV%yU<)a-D=+8dDRM!3I z7Z=tRMWqVfew;JZfkzZ|6K5}?*DB9EtU4v7V`M}-B`hmzpK5J&uX#dp<+32&VK5Fg zK9cdE8J0*B5C^g`f9a91$dPNQ5IvbUe-+_%Hk4urYe>V3|H%M-xe|&fYeh9QX2u4*C*ym%qG(> z_+w||87?Wf>CFrf+4Qz~R??oX+{r3)dPo^|4eAs(-FZ1-2<*d;Mjc*NJ6>fqiOvfV zMO<0fl6g2G6_%gD(;ukf2b@9Gg8=&W!s^Aj)B`aN%~|L^BRk)SpsoX}>SH+c1-+Tj z2F0Z-SiolpspkwL*tULwY-0GcPiE-TapVbzCn9u9A1MDo5plD|99Ix0^2Y#P)Kl^6 zDHo2EGKcZ2H=`HQ@$%=8+#-hswYQ=#!+;SijrbNtAB-SFJ&w=l&jDRxOHb9Kr;yq!$$3jox3=Q*OcxUcv~--izIzpqT=6HL4dBM8TSps7Ftwu&b!yk57X+ zE&zx#{Szag{~zujpXLL?!0e?*$9Fu=+3tgk08g7lHnh>4)= zlt+~UPQtMSR0z*sMD_48ajHeblD^;Ln7>XG+Hl6km(k?|b+~t&_#iilkdkwdB{mc7 zsC>ua==9za0J_kGAC_5(qavV;J7^j1QBjX`s-p;}J`ZcP7-_ZTQd8dlR@w%@Zjr65 zR7C>sDfGiu2)9)YqY>-l>eT8PG9#VN^b&1sxr_G0{o`dGT3cIZa-%bS0&Nx`K@2m} z+Mj=hx=-x8vrMbT4(E?srjgTfT_BBP$c`>#s%hxk7PGp-rLFP4o~pf>Mfi1PUE^j} zn(zxK^FZX`Qk&sco8KDAsK!!7JzzI3f_KR~O1jK3Gtj-BG%J@4H@bGACuj7FJ{bV` zM%>g7=nGo?cQ;&&rfWn^8Lf-~-r;himpW0iZ$AmL^puLvwZdG0qSYN#o!H>Bl~rsr-Y&Ww_(8Pz7 zH^kHFd`ZSm>rYqqe>%5ZyciR)?kB@du{r3hx%_wqdlS1CLDs$ZM<^3+S(b=W$(`k&i2{y7!21QgBC}Owu1A?*y;d_MnX*k z^Z`#SImzv<(o~K?h1zpeHFXXZDF$<~nK{cl(okIJ#wVBIhtbZMv-j=YvnPMH<0V(u zyPwb-NaWvF)*XEz;w?IbK|M_4XE@G5HDU3&#(+XW=TFn_J|5jS>*P_Q(HK#%t+jC1 z;aC23C-VzHcP(Eg%{iB1rE+-qwf@X^$(0SzOHKl6AAN!MwS$6Fpn5H|(bJ?QrtjL8 zEA}7+>Akb9L}A;S&Lbtkd$*{=fd(n>{g%vSou zfgk((0xOlrOykGP!u9MKzOf^9nOqBy>>okYb{NbCnv>_7In=Qo(Z&wNyix;I`=GVe zHp%M(hl|6lpxI4g3Z-&zG#17~4;%nQZiOH#)$M+h_YIFU$_Z)nPr<0-fo%@LV z9btiIQreC-!M6c=O^$+pzi!cxcZJrPQ+m)h{V6~^n0G_!HP(lC**U*yfz)<&b{D&^ zEo`|F59{z7VA2w3;SO{YGnP9M5KXHMe#g88Y@aBr>^TJkoR?R#wIQwN?U3ji)HR9i zGG~hzAIaA52=&5fCm&Z^~CBnd98+V{(=Hn~tDvSf%T0!n+&544Y` zCCQP&9Ny$sx4SC@!0Ry9=dF2c563$;L2LBLn|JoHo#{R{`-FA%wmW}->84O){`W^92Kqk{ z7XNVu`oFxU=zqq1WT5|3`}u!<2x4Gj{WF*OHRk2tv;UxaGmL3MlG*{#{EF8gR!c(~ ztl!9fl(V6n>JB6v5^QH(XGIs{3SoQfB{TWmdc+G7?T1;OB>Qxe@xSeTrDRC~ds~=b zG9M?=hDa*W?ARSiuQ0QJxD-R#X2RiVr{op$?boQRd&?5w(+1jY%X?=_9|gSf_uTf} zg6jlHnVNQyADRO)HAu%3W>>|xl3xa9H#ArZ0LsBrdh%cH7=q+6x5zaw&KiA?vt%Pw zRe=r|WOV#QP`yJ2(w|THCR+k~IRlX|CQN2pK`o!0GYp!%UW#<+O2%e>&7(Ig?-3HX zc)o)V?~P8il32kD^4?SLO*h;tf7CX++qOMYn5WvpUp-te9>^lmk<&f^mwP%h(3+vA z?ej}m50jX=Kmr|-_XC36E$6yJG}{r!yMMPLg`IY*^I1MHnWtt7wzSTkAlE4fBRYwIx+Rp{+-jD0<8ttj&FMZy=sag1Nf z38u|pz*#eX$TMw7tfv7%sF1|ga>X3wh0wCddFDq->yNUN~6M z(wUR5bY$m}U;?o>gpZ?Ec3i{i$e24WA%xE&Pr>mc)#$meXCLY-J5yq6@7#t8 zS~3MHsAC?pQ>|Jw=9M=|PQWO1hYz>F^&b81guUpDl9`c(caFW@hU@nVfbfxs{ZKgZ;#X zTg?aPGVRSS;Y4)Txkk6d7RKG7ND_)^asIt!d7N^=!YyE&L8YEANoIdy@2FD2ip7l| z{DM!rhOs%~qIoP|YZkC0*~@*d*q(0L6%c4p1;)w4CU;B#u10f;Jr6N6m^M9S^!*|w z?XEG(Jbla;|j`_vU()RrM)QNvY#A`IuceSZ`tnN)UcEPK;K^)0uc9BnPUc|zg(&5PrtAtmW?$!I737fjC z@KN?OxND2gfGJYd1sEn?r($^F_nX`%knQWk`^Ga|@=3PHUx~|KaV&oi*#DY}^8c>H znt}eGLt0qa|Di|ikJ(}D@E;etHF&ubT^06b=semA?WDGVA~aj+1(*kvSr zVELR>5UJP$8K%H%-RG6#JN zyyP?g9&C924u)fZJYZV`Un-}oXcr>eBgagch2)Q!1cRIc6M^t{QdKWT=8jN=F#b## zc|*M+YOKTkzz1RLifNxBRlLZ^426a*YOcXrqb4=$BwDges&CCQ9B==D9e-paHEmDD zG7A!}C~zt1$St}isQ^1q+$$nnaI9tyskmz++{$$6NH-AJt@4ThH-mLhU8C3T^I0uewf9rG;{vYhjRX92rHUB$5b- zvew_1V@)#Qcq~cvt)Qcf#4A{P#Z4MK{9GYg`^KRa zuo5vu2UzkPasoi>5UKPe%TNP)K$#?U{8Ll=ZRn|TdbBz$`Q1_L5h%y`Dpq}Jde3xx zWPW+Pa)xN1pWM_3*t=J@3iQsB+4WZG?Y#EX`~W=$t$l;+z4u7HK_A7|*``uMbMN1^ z?qQ4B14%$@hNT=R3ogBgnNU6z2&CRy&7ZQ zsovf%^o@3t^6HSRb867uet&wjhqdx|GdchD@hsEo5heU(y>TslgpTvuFniuODXy~U z5C!@Yzc+lA*bX?8I!j#G^Y)L~t%1A!y|ZCF2(0WjmWbHI z0dDsa3rP>10}xxg&^YZN5`$HnC$spaP8;R&O}DrZ#jZU8wWOZXwcczyFE@t|@F=p& zNjw-)&!2lC;~)d7IrblJ8JaAe9uh~N*!;v}wY5BxwSh&sSRxy*96#Q~jIC_jGK7u4 zv8=>YZy+F8&@11IDWw!F=iXExS;&teeD*q63wfnw*{oSWgVjy5K2)&I`gV5{WGw>t zaz%bk`y)*dE>kAQ-_{T9gC#8Ai`M!s1C3W@3^qK19_VnkUEf2Hk`GnG8ep8}orF}} zjEaZ0O~Ol~Khh@y;U3hBN@G+YFXn$r|1vJMrAuU$0uo$?JY*5%Vv)W*L=w!XeeI>$ zn}%kNi^MKX9KkYV5v5Ev$bqKR*6%T9fX$IT(36G^ljE+PirW!lsXvF3`5i%wZK3i*@2neV~^Bedl`sj6zraLl*i@= z)-_jYnPB$%bG5IrL0c2!aHOUmr+Tc7bn194Cc7hOa01ozL2&Kg%wSz6l+A?nujEUG9hJ#TmJ!F2+apj5I= z0|=^1+^YfMFXT5$u;H$9CMQeITss>q6W@1<3ec%+jF;jK*=Q`bi@$4rcnS^&+e-$i z$5XA@N`4J#rNy=DzNJ@xfVu42l6X$;==wb3lijfR1hP+m*!nBU{42=m?{f67k<9fj^UE=|HL!sEqxfxZSTt`z{dKIYnN6XX2t(# zl)IZnm0uRfYfD-I^Y8GbK?1aYPz-ROXgmWq8c}2P?OK*wzi1gI8X}c6C@n?~jAmK) zesPkUQp>J5BpL(ddq_ptl|q=`HJ>4! z{n0~U#2P$3zH`Up*t`qY-2>C@jNyY#Q!YlfZ;>XmMXhZVUz<`%=G@}J{UScyc}na= zG-%j2ZO$l{6JLNwzsW+~Q5>(n#jwci@326lbHu>K2rYy&72bWAv8S!3e^y)E(=v## z;sM^VFk~{Hc;BQPQVV=Bi00#h6D0?&|5k-{b;M>S z1}A_gK~g7zb7D}|v3hpH5jCfpVc5hF*YDe>$khem*j`ve zz0gUP7clL%8r*Zs<4ek- zM2(Eg%Hlr$GXxssF1~HJ;Xw66Q<1)B2{gqj8!>yGvan3NtJ4xHv_r=PElt?eUM_Mq8$=bW44$Sa^}Uc;=I4niPoM1`jrJZHt`s=2t6fmX*uYg`+|AmAb9h$~VD>tQi0}G6DD0w<8%1zS#&gybKb%7uThp z{8p(vpIlQAR|@HiSip0N;R#T@Gt{h`YQ4<(% zKTwCSp`THK6pwC}7qI$-Pe3`?0ba=iMv@XynnI@0pWk6e2%P8UplHgmR*D*p#hJZO z5Fj=)lPWfcqJjw+3S#YT&Y8eLWv(YNGb=NNsbCL46^myTJFHy%eIPL0t~Pxj@RNyu zFeaPDJd~KuIM>&%h~t)jK^S91lJW7-2>4v`@>e?JhWA&kbN)i&qQ2ncBkipXe~ z<8#}X<+%&39@a}VzymVZ&od2tS8HIGT;a1~{4@e8f6wg)S_>E~1IqY}m8shZC*%}5 zF6fyh`>naCYOY`!pD$ZfE#0|q%oxb2nNOuw5e`{d_X1gXOs#&%;w5q8JgQ+!{xAgL zjrvMBsjdMOU%fIZVLX>Lxi zVCf*2<+6*yJ{R0?nMFOcUu)8DS$-6Og2PG?Zs3)OJj)%p=_}7!Qm6Riv0RhhO1M3J z9n)$t89i~eah)Lst2!m!cTibFm)nCEJ0jY%XqT-h&;HWu&cSQt)%B@x5ieS&1Gk+6 z52uID;(cH@D)#D?95r@>X^_{6(Shiz?9Z|;RYHkE_wENX-QZNYw!UW^rw4Vk_nmgP z&XrC>;$vZgD(bg5E3lcvobmp+UW#%Ib@CU9_VDdtjghAC>1R(FCaHt~Oxi?v+zN_j z6S<|D>eKU0y7>^N>B%#7oHtN%8T0d=4F*!RnU#yYkXf23a9z}G2c zFgO&{AsQDqZ*U>h{)&O~2p7%g9eRQ?grvL1auajKDpj=?!j|z_$@(63jzirmly@ z>;ucCJ{R8MG}r-#+5X0-0sRp<_`XprCWyUj=XG7{>cD+;IcKEmYL89sL%f!$I>O!2 zQ02BYy&nbra$+@zx+IHAMi~V@{ZP(>P3}y!o~hy1>Pzen zTi3AkQE$Gw=28@1$C(fXrW-$iDA#D5SXo4(gIQR@>+ds63{TaE8Y^eqaFMq=LYp*zPZbN2eP7h`lD^#a`Ug`{;!a$zbokfH*)_^ z(N~P@O#hH7Ygj9-4x;{%Dra9Xv_FinI^sxrn148#Si9F+O`5D2zdH-_X~L zOwoTF2B`0?@AcuKN&xK0dHd%ES7AUD4-6Zy=s&qyFs*g)=2`A24`f zF$4R{hqVw~qYK?uk_qhnmfscJhBwmwY4gQHI&(ccD>^g@%N9Xp;kd!_%pnC7n_}6T z>jD4hw%4sP88A7Oc+--T0PLs-Azf0WGb!4vTV;FmBkxR4Y!EYm$73|$+jz(-JbIW5!_hfxieB6(t zJu0C;3P)iuu@^AY`l*2PS}w67!i&-Gx7IL{tPxkhM@hkb6w1}o6(Al(Im;bB;MUiY z_vIi98--ws>Wn7@=lc}A8TWt!+{uE+gK^`9|n;u(4 z5;`;K^yfLa1_tYc>EE#n!rfXe9uNsEB*>)kija1ZqZzDF#imFkC@vqd{L4y_61ZBW zLkj5MKSm(!x)$nb@MbkAYq?L%R{+gc03|I1B>^fGWQitzsAlmV9D= zHVq3Dk>3D7Bg1u9l4lO}%N&Zl1fm2s0Q4N5m-&y6H2||U2dTSV3GNWC^|-u0>t6AH zqwbx9EZhEU->kG%Y1_7K+qP}nwrx8rZQHJ7rETZU^Xu2|osKy7Mt8*PxY7UZ9eeE+ zGuE0h$HZrhZ>70mg2jJm4Q!s1#X5k%zqRIH?XMTbOu{4|d(V>;2j(Cqo^1k2S`118 z%ui2%{{6(Uu9BL7=+snALtLyBYZ%*tnod5}Stlue2%;?^@o#M)2O(f2MmS9}>Ru`? z0?uf`T4-{Tu!sh=W<4z~!o(my0Tq#e{P#->bR;}d;uCNf6%_t@9^xh6UnC0oH^M#0 zA--?R=Hg6F?pH#cS42|8p;uC5iB5jPKu8QS+w>>R$O4_boC%}Jx)ODRiopPr4|U_; zpEF>-{6b4Q!bXerU<<%^3lf{s5H`MVi}@(W*phBM*n*5+PyN?z3#`9CFnvFPj@980 z-31iBg%raK71V!Si^0R#LR}eYUG~M%G}K5y9d|%1grwKi+hRpnM?C^=^@GWjokV<9 zM2|9hyGVJD)CZM>KK6YTtB{auum2GteBpEV>43pA%V+;nVq+rKv?B> zQ!5yeZoE+=`K|H%p|UtmLW8x~?}QeD6?An~XOZ=dqVFBJk5v$+5LQSmj$c=7YZ; z;gaTgMI`z}(a5hRGg#VaZVywaDjOzKHX#hH&-p~LUf&Sy^e7>DI>d3l{nD%|4GJ>Tg|H5E)}UIFFA za+=H+4KA0F8FkOzCY=yv?*O6x=>+L!jQYyr(;jc^E04{J%!uTp;^9G+hc-`kdgHge z?OOj?xCl78CXZi9WqyUX!0POrTN?LAx_dgZh@`S3A=F6WfO@rd*Jo9%yfcZeW2Ukr zWYg3+kS6}Jy-MYR9-5l*HGNVtp~yU@9k#BM$u(12S+JbE5$qnW56wa>{tLv1hMu_h z%A!D7IgzOrpR+es9P+NoJ&=~q4^L*C7&?vr@&1(?j@3!)i-J~zEGQFlkN?;f&q-od zT$-6B+{GJ0o}$smgNM{LlWDC&v?K9uzo0temYnM4mb>Z~Sw`T@jO2PvBxW`K6zWH3 z98h)Fex?8z(T}G9uwEHCq57(V49sUHZb)C-K2R8Jy+59AM@9(&RZ@-0I*=c60bEBo z4pi%{=ufm&DK32y+)&e=BBSk`jdYy-+B0b-;`?U=k@a$t;{`dsUQ4xfoGL-yez=pl z3r>t8iANlZ7u4RGQzYey&OciT?-Fpwu$@xJC0EnHtpwA=f$H@I_jl6wjzc&!RiD%) zAWjwZS$1Ss{HNMQfd>rvMgwiiX%{wCT!kyTa#N)kHarV4|8)*xCs+5sE zW@(!Vind&>TJAiCF@d_Wf6QDDE%e8|59;;BwEB6~xM%NVvW8<^f$A9KGHU5?m0L**+PeXa7y`?HS-mmUa4*JNNsfu`@V62h>O`Os@NHC9ox z%msW6z&`t9wR4||Nq%dH`#?@3VGrLOsdDVPTM%~|(>~@Bc6i{!HS7ypU#hr4&%?_L z0r$fPIF7XcWbMRH@nUqn;DcCup>k*~(Z|c6HrR$%uVfxU^KoHU@67_U-3N=pdG^i_ z;Zo@M&Jr%)G;;E31e+s=WZdg+SuYmy!i|L%Jv#sadHv2?hk+wMJE3ppXL!6Iyfbl@ z%4K3#>{Ek>YhpPXdrnu5PWC9{wt>m;QyP}%^x}CdN<`YVKRURef?&dyajU+j}Cv`T%senkh~ z_DFq#shR=_{?qEQy8l6hDm~qQ3Q?tJW&OK1V@h4qHj53(=SWq}yDX#P%%Bd& zYAIBlLDP6iGGo$3nHjlYhp35>4#Z)h;>+0g6lWu?FL4Zdp=h4MqMttN%8Q2;_t@3c zb?;Z0FtjIrhS9X!UZ-m}CymR8Uq0oC;CE_PEv)?<=Fx&FsxjVp?x|D-&sSg`KnJk2 z3^u_^y(rf(0zZ#vckHeMgJVu7btRSTTz%Rfb9EzBb43--#M=3FjksPo`fv}v(6MyB zKqmB&$t!aP*Eo#Q)vL<WRy8 z$0OTPIsI@iA${fpKaiEfT|DqNy6ROP^LvN{Uig+=5O(E%)#1@zAG;N~S_cdvN+iIq z7T?>rjquh>Po+6126KObxa3D8C{p~X2+#HoH8)2Yer4&6A$|pf!??G|?i2TMY~kkt zztOPZ#wYqzGX;Wtv4vCg}Q}9VtP#e!CLUuc{g=1R7%H5orkZcgdR23G@q?87hgLL#P zrm=frUWo#QKeBPe80wPEQz}M;I!4r9EEA=V5^X-289TC=3!~D*W8v_-c2xxBva|d~-BvyxJGE88Fkc2%G6&1k3F?K4_g?1sv zcqC?v>BJK6RlY2hKa&~ewvKvP`l;$z2?QH?gMzq<6A;ha-NV+YV_FX??$l#6`|b+F zjqQ#b*zi>MMqe8K@}=VR@Iivxk!H9>(|a2TRV!D#0Zt-J1-IZ#`jxbYcM70o>E1paJE$Q8m12SeyV;(62XIx{LLoBa`HGC5i2R?B_|hd|g(1f=cSWGBVSvQyCD}v~z|Z*hTVVn;;t9cJJ1^!yzK4I9 zWF6)Ah3WOb3)$3COT&4fD!Ih^N!3x+?nz8eSU4NkxESU^7G8w*KwwI@|RbRnWk@v}K6lGnNx>l(`rJ!bIB@?U~ zKnL2R!u^3dhgjO9TW9V_>G4xJ!XEa)j+;&qJ>P*~H3#4cyybl2W7r*KCb*1+3B697 zI#Yo(1t7EIXBO+di~1PF5^{Te&CaNcI&P_|D#i9sr7+6uejp2yBwR-iGda^%&t!{B z<;HIHEvvN(f)H;@!r79%=KBvb(QQGOU6I?VBoBv(h1OP(}6FCEkIaB)1-t-qo5xVQ4gJdNPOJ`S5$ zmx-tD^!6+m5h~G)Oigv#x;FLrBFXaL#OxQ&ZG5=eHqAkV?eDwR@<#2n`9E^A83HxT z`FJD-^c1shp@Q$V(#j-8ng=d&WJFTXGCC#8mYUcN1R9?5!$GSchB4ZwmlA}yK!@NC zgcHz)+C&M)i%i^=)5}kYU)Nh-8<~ia~ok zi=4Dw%=T?C01J50dE$iwe}dCZE(PKT&-yV5_+mUHq7{RFv7vBr;$eG*?ojLM`sZrS z>_)Tp`~v1e*N%>EOVXza@@qr3^68`GFKVVTL45ijRGuWxyCaU^?NyZTArJN)6yoU<^wdCdfP97){Io|#R*b?=8hvl((bWBScba-**}25%3`&2+ih+(6 zu3Ut+#08a)0^jACDGJn02q&Y^VBusV~r%LMZgFm_g4qAe^Fet!kf+cZnub2 zJaskf3SoJ(Y0#*J_mU+Hcy&`KEd#>4jnvETafh#>o&WmBS~+|8wiyQjl(+e?2|CzH zIi$)iNpGe=Nx|tyVqvs`F#NDReQ+TIWTW0sl-+hA@hkJ9Ct2T1xYN+CHXKqO*55P` z_^O1>TDf{7OB#(3lgjmzk<42A)+A#pbm`GedvsQEVC^Q|rHsqJd{UKI?ObjU7px5;odFieLfz%pRb&VEzpoATx2fyo@;t=fxIo#%bMiWxI5e-jXW*9 z)$`Z^imyZU`InaR#B&CL8Y_4$zJ?8yU_@V}kp`{-le4Ddx5T$t=UZxG_TZ{(#Ml7c zPTZ$80gEfSyBp)-T#zxY`!_uR;5tQ2+sRRE(Y4c-T%TUNydWJPKkn#lKW++IF525E z%(jT+9)SdzLrz!+H-kx&4hRTxwL7JXYm^JH#>_z23`Nlf5Z0vUz(l%U!&1~&(Qe~ z&UJeFf3y2Z8ylJH3)s48{xzJlG11d}=Pfd`Gt)4zY4h;>)%L#-33~d!@gDyNSb~Y} zKdg`bPOrC&qWx8S4A$;v?Nl7<3PJ;nG=3T4MOh-TszMgX(5Ix&X-pB(f(s&oY!o83YP@`ydf zDG;YGRY)9q@*u{*h_}Illzl*uLqJ1d+JWGky{4*pDu2iB(S!!E+QgD7osit%X3=D~ zNm8a+B>KVA~Yl53iwu5Wo8^U)72UfwilWpb@y0+!j zz|fnJvNE$SW8AtS>r`qrf?BGPWnJ}}hEFBdU0zej%yV&#k5$RkNkBu$!(%Q7q3gq~ zm6_%nl9i*;c9)W5TlS}#;#Y9=aE`RAcl2LUbv-HdxrIXYU79+4Y5-_(gB`)sq#2qEqha0h3}4 z9Cvg20fvBY$dBf@bVQsHQRf(H_JpyS^Tc`20>=g@thY)1F(jDi!WWd2Oq7*wjMbU1 zF^=WDa|8iJPb3RrXwOJ$GA2-Y&0J`7VU;bx3JQYP;ez5~f#gvJx~cizYIn4?ir7OB zBY<>o3j9^yfSPwwYZr;^r*@}q*gQBhg!UupFtBxm7H$r#Fg}^2(4n~MF%Ry;WTNMh zo3OTx++po?Qm?}YvQRrCFmw8=ssI@Ke&XwCxGfnm>*@h8Z))8{z%@l~%-NQz@bjw} zNu%r+!8Ar4ksC2DcKVkDp`|Fd2y7gyX&+XiC5DA4CY^GNV;f}}UJs;8BKmTa{1#6pIrb z%q_d~%0tG0?_nhHS^j}5qdd4Uce1-C&XkU$9VLJ?a%4J!N~p!k=C(krGmHMhG0Q0F z#6Q*i;SJ7e(O8LEB~z_6pMQFTcE2g}!3)G+L(1U@wdc-l7pNYSMa~Hd8eqlMvPK8k zz5`~_a=lt88=cKDn3&c9dt-If$z;77Ub-<<6BC+8xxF8}7T7>mx7gU=SARY?(wWAp zO842ZD;(XbSt}(lrz+cN@K!_IebL*5!(_-F<94?Uz2zLivT6AI88c9Ri6;ZwveMNO zs+tyx9-Da<0hD7_rU^URC!sJf@4a;i*7#ou+iEsoiMhLw)JhKX6VWDUZ-Hq1Kv!3{$IOFLR%y34cCs z!#=2FA59`^*Ckbdw8CML3d=4w=86ds7_iOPhUD^u1Ex`v^~ijUqcy~g7{;U*KY@3J zv!YL!X3d5NC#tgpk&Jxz!Bn}F{M;&4SR7H6C~X(iZ*Q9I;5h<4Z8TVdX(BYh#m33b z&KW&Tg0GX4GrsW6WV+d6Ur-oFg}2EnwwK>^F5P`$ErWb^-O%#LMxXqXtnDnUGn3fjoN zAs(+GY71!E<2;-;Zp`A#nAf>-BemW%gbtpd8ouASLnga|LwoD6^09xxsZJ{r4XaZO z({tVPqViwF`=%La=fIIJQ^i2M%cFWIxb#b+uEa{<3KCX<;&ll|@>4iJ%mgUpB zjt8T)X~G|Qtp4(}A^j8)Wi^wRnkQkAH~g>xwtO47W1?S3b;+g1KO-Nws9TaVtr3@9 z1FhP%xkiXMuGl#`?HSqClE!bRnMRC*TwUhZvAm_3ruvMZmXjY#Qz}}1iB0V!^h)U{ zZV_aOV}(j)DR;QH3g_YZ*4e{_rc+>iBza`1HmFNKwlIN1Mx(>hpOX+73wjEY2w5nK zT4R(=F-owt^apF?3%#hW#y>|?!zLbSB_lV!=ztq7 zmEn8Ebbdgyts0pyY2*M^C#j6q^x*y_K2U_yCMt+O#R6HqokpFy=#AM*FgS9ynTPFK z`m}FCGa=#}6(CDiYmb?UAr-?J9!cK7+~MwPef!R}+0?q%Zl&6=wm9KKpK|gcHPqof z+t;G0=b$<6vYei>={K9lf3}70lF(u}fx*ldLkzVFTpk_cV$HH>QM>%TD`w54-BBE! zU0416KkSP`b zDX1hO+2Or>EvEw%1GHX(|F$v5LSFAKxiL7m+rn>ASg4%|)4X2EjAS6XF}Qou)Fh2m zw}nqpSh&Sy=|)!jV83s^84Zr@}%+1{l^77nVJ22dg;Bx!E zk7@3~GVw<<%cqgKX)z;SIS1coqzLbEz=G%{YNj6tVJtcv?B;BQyj!-n+f%Y76M6!C zU5O~1Wee?Qf|gh~XXk=!@2N8fx~m}7pKAyr607d*_hn9ff;q6OCljWhJuYE3-jlIjk`g7go#Td_y^t|xjA^WR3{b)= z#~V2=9(}q>V2>eMIe)pLRfH`lTYiqkM;n0|y5J`>Hz1cNzc?{L*pw|tQpfm!SF`B4yr`GeVKl_)aEuox%~0SeTXw~WvK%UAB{OCX^$!!&h^*9k6>|W;d0tZkP41;wbLCD;xeW zSob#EO0bVRNUB5Q?dzd#kbPb`gZgh{h4i1^+^=@WFQNMo=h#+bP^?z(0qx5CvyGRjb;c8odB8P$O$UNxUj-R5Gb%sX zFuW5Ecn$MNMWKG7ya*6SdFr86HZRb|4Z1f_W44tcr{h34WEp!62k~o77pjG za@@f0m&?F?dDUz<bEU9(V!0H$-$6dkgyP{QaZhGv8PHuf{J$_u3Dz845b0f6~vt z;bVW(&%YGuzh}wzp90?hi~9MubGrY7eljutb4)#(tl$E2m6&#$KHNzL3U)%1_NKL( zB3gtHCj}LG@`28y<)fl2SpowwXSgA_nm+Jcyj#uouB(u@L(UWyDj*I#$^ez4jLEd- zQQ|)0N+jU(9^ErcuCG%WlcACkv9aulr}o91j^1FhBfUHc1KY6So~I{LqKC=FkC!swqV7tl zqal$jn%u2y`cX$_0P8{rI+4OGl3}w|u_2e#wX*ZJM4X8AGAL3ZYoH`x!3%ITZ^jJQTt zoT;nxFy7b_T66S#A9!>_215!0LLN)BXG+AdYzR7g^=m( zyZMc|ErOT-G+_H^q$82HYHG@(+7qBI@boHalG_>9bIs;hPxUA;JXHeyQKF4diaoxq zzaSGvHAE5O6H7J3A)-Y{2~uG%w*sn4On%%HfxzJis&dM>=SU}!Q-oqz`xCnEFdepF z0Ry-!ZmE^)j-ynV0xoksF4XA&lT_lkP^AD?+8jN^gbfPjF4TEq-G@W%ek5O_qm6C` z!f7PLNlU1|5WSNK0$T!3OQxX8XA3|I%bjYLBZJHG;f0lb2_MIDer(goz#}?m@%r3B zF0-P0m{}EHKyzg9SM!zglXvSOnrn0WcOa)@#*sB8=k_|!>$wyJ5ltvrM0QT*X|!rv z?C;$dn}-D}??k5dPCQ$qT|`{_U)ItoY<Kqwk&S+Mdyy>X4 zYH0DaYlO3p-#y-f`y@5zUcf7^OAPU_Sd-z2>vmS*?{r+u@7~n zg>zvZH=K}D#4o>Mo(y45nwe>rT5xgB?T_1(8~x|Xt{qzQe7P#Uh<66hJ0|lSUyPA= z7RwNb+vasbls4A15q3LL)i+lxE_OS6nkM!!C<7m;!%Ltn9TSoD-8T=%_5-^x2=sZl z`gxyu{%3>L?;?X{2?_b?Oa$+}XA`Ed1FCRAlCL+c)|ZRI{LF~>ceCp_{{l!;^6`8J zdFu6}J;xkKH)WcN_Tynpt)>SK>y_r!>zWAmKwx!M2KR)L0&}E%)?eq1b=*vAe4X1vH7sRrb+M+ghrYMpX?Ke}o1)(6zkJ+<4mB)c=^H z61BO$%AsHeuy04Gz3N6NEFM3ZXm2YWcc4(mK&$&{P~CwRu1{OBk;U%^Qs1|6Q#5+j zr)9nN2)1PGt-de6z#TzFCj66X{S9mQn`-@~1OH=Gi{WqQO#ge;V*C%`VbKZFG6Qt* z!B0FxRQmomvRI@O1pdH?Wx--p@DT!B=333-XGPQ_C-U|ANk~LW?u?9&PrsusklV(= zfs!dG5J#cgrbmOSzzd};Kr{(fLbkNaqL;jTf=<3|fBj1lx4hrQ!)+$3| z8$~NB;+aG_IL~(;PPq<((rk%VPxU^VZdA8>Qx%#Bx^=>1qA39E8<* z#|O1`&d7}+lLXC^c~ndC+vC!@3OH7pKZu*@xf^W!HoF&I+f|Uv6umU0{^pT}d;HCY zWkgU0yn=wHshoe(ErJ$pn_m@a5`o>R-y>|L7g*D1y}&~>0$qmcmD6Cdj4y( zAcnuW{r~s2G?JMfID16F_R)=hDq`oYiBRk9dGCqVuk=PiKxMrr-t(JFE!m^P+# znw0rok&8TeIb=&}4DpG5Nxfoa;SQVD2~;dsZI-U@P^J;Z!>o#mj*r0ic@&MqIBTJ< zltb`~9R4?m)28ECi>1!^SYeVrq_6Qvlec3AE0$%e$ox}VyDrrSYeFemQn0NX%2Vbr zpI9w^fcmWzVG@p3>*m)WoFHX+372$X_`1cGII!YfRrRDYghDxS`ApTB{SJdLH7uv+ zTx29?S#WWyVjD=>_aqtQHr*G?73b2Y z+hy*F^5RJtWh9Ie+6w)``3nq}KOyG*uecQE9%qZ;0GACAVqy6;e1@>C=*G4X@IAm{MoFT)dYI z0X+XM@V9mWBf16$aq8Aut>^&qGB9+XRSyuQ)$hn#S6eJdxZA+3wUy@rS2u&gJc2Vu zJk%v8yPqgkow;AT6Y-=EzRX&B7Ep6?zu_%GX=8rqweeJ_U3^+QaFK1ow^{%kSNhGW zz<}IwL#P5n@~l5>knWt^I_PlexN+DnUp+mH8VHiV;lcd^&;(|?-K$~-4etE>GIh6x z@=Cw&C4p^PbWHkKNT$i2e)3FEIh)i%GS%-gR#GMt?!A%)P4Bk*BbcD)_X*RfRXLXD ze%kee%#9o0Nt0?cPyX+4(9?bMz_ySF{i=@&s-+l@C3uKCEsEUq51Q%mlc9~OkpJ<{{R$gvZO$7F$;JH2@W>pDttVIFlW?hDwJ!@zOj3)))Emr2K?2rM zdgm@XeHl3=ebK#nvCRi>sVX{*Frs5h3voqtMKG42M+jUAv)_L%`(n~ZXT|z_q>2#W z-L(D^S#~9jVpB3SYDc4g&pDN9wdxPk|2dF%%_c2k%VR1`B*3s64&KP55v;7znf)2E zo`bZ9Mq{iaI%{kstKE^q4{%sTF6#Co=aZXHAe1!GjpJWB1LCOe3d0L#l(YuSoxH2))c*&hUAv4PdLX}p9LLm-xM<^WNIZUE% z>$B+inN}uTI<0~GCSxV8#|mIs`Y4CXp=Pqw{F{L+$SUq(+M4=VS>SQmk8_Zq zyO@+$4f(B<_1CqLgA^>6z`ER&bsf@PpA~|X!`XFA@xCAC2zY5QLBiOXex#t5VRlBI zi&iUEsT?)~OYmgyk4s3;0Ful<^Jc9;BnYsW#}_rMLk>?#Z|A`;K3ZB;F~h}GmokDq^y)m@iTwep5Z zS(r~Ya;|8HQ9pD(eulF00wZg^aXBw^eOvrud^j>+OL0HOM8C`!*t;{9Rr@}t*4&69 z+CcYO2*2M04STv#cAChlyC znzhUXbdIt4XZ^>=699%o`H}N$o}YGGv*o|HY7?*y+^Gc63rEy-__6lSVZ(w*)o=I$ z=njmeyY1eyO%J&n^2d8z7|eMe!V}xn{oL}qp&4Z#U$0rmZDTD zo?ULouTf`E$v%v$EM$inBAS>Zhbe_nhZO(%dkaJHkW36yw5EztO@&MK@3@TB#5Y zr%IXbD#K@+EY@NDHFFOn8o22C1P2Q98Wmb008LaldMf~o{MbW9!uLA@9KfGk5n|wK zfEX_#;b$0V4_pG)da+uW@#q~)5gJ`wZH0nC9uf0<%!~{kmoQ-Z)+98jQYu=!$5je} z7NUFt)`k`KAK6@A0#VhY12jIQeEDi}GUS$>Pvv-1;!+?5Ye9F+hscczP^=7O=4;~`kK6x>NPOL0|n4Djb2DE37?5b07*J=cywv*>$iwfV!wi< zkcm3IELiZ;l_WVF+9WQFOojnEks;>~tL3<*H;I1t{8a>frFTIL%nQ@8_rcbu6(!GfiAW6 zWOaf123lTkv_tQ~=M9bVY8$6B?(p4%N}63FVA%Uljp~E8rj5;MYu_{GHL5-Z$Zbp$ zY6n}^XzhUzNoZ^ltB2f>G%$euCThPtO$Wf4BY?OH49$4r2Rs#mPt-n&VbZe6PQNy4 z&Ey-PaNs5Z`qa`=~O**l?s`7vmR>N^xG0kDuDEJO~ z`Y>%93eAz6Jy<7oiy6qKJmn2T-yvY2&dLL8v0rPjz=IEo&o*mh;5l1OjFHHy3M$ffzP+sbW%n4jHEm7jvvFdM$sRG0TO1hrD_H z^#B``?K>I{$_kGRB^_v7PeNy_9iLq#6^buJe7O4$PtW`Fi}MTDE}EVrP6OOE&bMS( z$3|nTrezqfTUyE=dOPMzQAX-m2w2f0rl|Y4?~RE!YjBB`^>DuJ#V@I;N1yl4@AIY^ zCE2p?H*;$zPpYB|3z6Sto6BGeql-O`Q{qtZdE(#>cmsp@_cHwRHb5Ot7fH;3Xb?9S(79J`Ny+=!|{dfVD?T=@M^f*S-qfd~LWBSWiPM%X z{TkwJHswzR83QEs3FFS08-L3_bEUand$zYo)AMA}2P}!VXJP)0nfqO(WwUvAS??O^ z^Q(|w+Rf7Ic_Ros_OvyP{CL6QUgyJR#Sg9s92S={m13a=Yi4FCN?ipC|*Wc_QGefIw&bf-DBReSN$?5_9J?`a#%Y z@Kms6nPz`~`#o>Ps|2ydybs+6A3=e`Zl|`avqIk%*z&HUmfMp&&-NEy9N9Lgd09tj zjBzqEVkl*^GMqbI9~Q&EdO6&zd^o&3``?-PRc}wGvk!mG)C59oXe|c>VOUX%Jj5%8 zrb&m*a(BD>lqq{v*QrsGM+Z}j!Wze4rr%SCylOU-a;H$|mGG3&W%gGonk(#uo3!l0 zk>4pJNId_bAvyXyp6ZyZ{mgXya$vaq%F5|xpEKPKWT3_mJ32S|R0Ju<4ce^$@9(HF zBVOjkj`qpSiut_N-oTCBhF#cOA8fRw{_^I9*8h&2V=jn#XNav7`%RR8Z;YZ*LJ_Jm#p&1HCmvAqDl*Dp^w!Os&IQtEM=5Ni^33T1pMoCa11(7j@TX4 zUZ=N0ssUZe5h4-cz&NeQ+^-UTlVk}?VjNwIo3=QpD(r(nBhEcK!U&nj-2K5Ijs3aH z>|EZUp9zll#k{KXo{~)9;fLex6`ua4BeFACoiPK(FmjACK2r@@V8sEbu)>j$HxSy; zoK{F~UP5H?;Bhr1#H|R5s~$i35}-P)V(^y4Dz&o2fe0>VxiW~kL$m}DFme$CS!FX# z{ao=hI+1-g>sE=ooXNH_Jb|tW1BOY0wrq*0U7Di^F!%5-N%08!d-GJqmR1_W^0M`i zz`)}HM+G&xqHL<98j83Mkurhi+TJfdPaUX8Ak0?hO7cZ=P<4~aV6D_Cd#VSlJ$Y>3 zSapBPaCFK8f}VJUHc`WQBCA3DYoiQ9NJ+ISx|K?WWq0WY36voVb?eD)L57_r#DbzY z{p8=f$qfnoLdz&~GCf<2(aVi;jM7V!CvNAlq_x}9Ig`R8zo5a#fS%#v$ zD*BIU*qeGYa?t)1-*LtoNC5)fr{Pq0X!;rJo<&M3kE$V~8-g7scwesphi`_`Sw&!}9H zEj~;%Zf|Qx&CvJ+u)&x(gC34qbVrXp+2DM%L#v*(t6lePAPu?3vP~tt-mQLFHdvULRkI#;wl+VNG{V*G;PC6 z?$$_*)w_HHVeH>w0J_4T9wfJ$jJT47xt0@_7h;uFYVMDmR&G*&{(S0oPc=b89jc;6(q9W2qlyf@DNp6uaYA#ass1eH+=e{QszyGr=-!@} z_-)Sts*%L~QOCy9q!tR$^#jNVB8Wb}YBl_V9R4)@w0iuqn*x5i1^;=yOz?Cd&CI0{|^c<|43)urfMUsGzevx>fG` z7)n17AX+f0q4`Ug*SX^eAf!Z!PqT($4$EnV)!S=J&|AAxorY>p7{^(lVG<>EV#qeK z7AjJM>Uz{?H_o^B^(fdn-Zhf<(>fkn=zXP1{$YeN6L_&F&|tvY79GIbX~Hi1_OF*sZf1m=!L2Yn2JL|` z*32y6sdN4G-teB2f{E(L8k^&2-ox4lGQPuR7Bvb1PsM1n0@0 zF$W8pVe4`EUAQfp5?YN6btU1$Q(a&XL)R6T<%v^MgGT~cjg;Et>2vs7IY z44viZbpzN45Q{CNcI#UxqfQkWz)?Vxla$9#)X?Ay1Tv${n_S4NhL4oOMCu37s3u1f zm=H2Ei1CW59)?E35Q1djI*USy#i)TNB6w-{KnY=5ChJY30NLTyp1V~CQl@mU%-0WK z&<_zi1e(NC@IcFuJBB#>{v|nKkdXPHv8gyd0O?c;+}eo8T$0DK$U@i<0?1%5LF^(h z2k^60o+*xM_S^GrtSDZsoH#OOgNiz};B4QaUVGkK_ z!9Uo|Utjsu8Q#bwxo@3)vxb*vs%L;52!F*HXBlU4c;nv^h6$|p^8DJt%34JIxmU7$ zL$kxQl6V2>l!7VKBEG(O(1fBwVN{YY&LS?UlBH^-xqTPqq)39b(nn*FmRHhWZ!0L) z8u+y9cXRR3LnB+cCLaW0a;z`cQW;`%_?*a&WP+u{xlOc`(dyO!ySZp$@2p#N19xz~ za%PUZ0b4N3W77!n1sDsUAqeG)@2*>{Ew4)L_Lh^Vgf}ksdr|Y+TfTbiLNtNIcrBqo zfz9@;vt!3EiO}IiWrG+yN~5sNpo8)yMHO3(k|H54;%Y2}6x~)#C+U4jh|XJYX+Tk- zVH2s^JkaW`1qh&yU*j=-y_`y1^9d$zz*WP6Bh5e1+1#qofG!0o*yBe7F4P1k!yZ3{ z8<+|m;p}W2qGEHnX)~U0uuH2r$F6gN5*(O)000p(mb14t5|1!o>y{IPk_V`sQouQb*kP- z5d0CdC7?lJYVm~9N&F1eYE5O-_drkkxn>QD|v$VB*!@hi+KOa+{-%pR8_ij(m zFE1P}^FaKatOtsAy3^I_=+4amXO==U?JP`et3s zh#B);SL1od_>Je0D4o}i7P~6Bo`ee}*4kv{IgtS+`*jmE|6l+~QP1=6^TCjPbOo?4 z(qbbWv@_UL#UPp?E9u{?qgk9=9eip48XS%laK=%XN$) z@zD4Wn~scgjM85ha8RnC1Cm;%K99}=^Y}p)FIQJ@;Azk*)r!#~)=SC=Gw`pg$f`tq zBd&I=LC?JUCqL|s8LYLN{%7qhP-2G2E&sL=?-`c<%WlhH$fNXe$L8bu?CJHncm4N%P2bK+hP@NZl1b;vm~g#4{#NT; ztb_;~dc3-CQM5Sr$(y4Kj;#2VYmgL_>mcDFv04ub>O95v;#i-{PdpoGkfF%5IJx^{1JWrSxdV{P4{#sa=Jbz2aZg#Q)&EzImm zpvDW5Nz26v-4SG6LAT)7cQ9{iFr-jQh@Ma#nl-X?=swlFbZO5LhKbsBUk`KbzBUFl z6CQ?rzgkIYu=aPZA@Xhc+(=8LVzsI<33N((PC}9Ipdz6R(Ry^2B2zJ~Td861gIA2_ z*eb0Vo3<(|Z85N~A)V6I`ZyHo z2#NAf@;xs^vY0Z`?2AXC^+2&85^ImkH->W~MT5X=-t)zH^9E`GxM9_V90bv;*J?Z! zcTyP;IjKl5s332RO_p>MSZ3Qh1672; zm-@y3#La_V{02c~@~r_XIGFF;ue{`K zw~Ssrg}$+WZY6o!FDicbC=N2(VJw0Q@xWdLvqU`GVb_7B)qQ9BP6l7plWh{ouj5xE zYz>+J>W20|IFbOPy-Pe1Yg?|p^AJs)E%}XsMG}qpS3AI)ybX-pr^m35?9MC$ zxKj>(bXQ%EAsVoURhJq8?J~}y0qk@Lrz3kjFzvQ@jfC|SqY-Mm&r!T1JmCCHijwk4 z)rW+Ii{_ucNY=y=g+3yGAm$sYmy1sCk1pbCF`)A!BG$uWC%HhoEW{AZ+AixiY27#E zG3bPtE+FL>-aAq`uGL1MxsDG~y{&L@E5lRzm?_`3of9-L&kr62whkeaN8t=@jbI(j zxcEA^L$+!fECmpqbCs@}D{+nC%?KjZ8bPC*D-44m^7qH=CoHlT-X}B8AwY|yEcS25 zBx8|fkwlC`%26aS%iT)>fga9~hl>c#k=|Bh0-I1#gSxwi0hQ_=3p3H9L6RhZIDxti z$P$8YGGk4eK$AoSD^!`D2h+5Q4zLVC>b0Cck3k_KMD<6V4!<%@QS&hgKQd(nB%n^t z!W2Wcf>k_Bv6mxDE+A!Ncx%z(ps52~lR(<-~D_RY%KirS+&M)8;W~ zJ40oJmSe)sk#VxFsyK-2?tqD6vIt+2bztgl{3qMZE6kZc1tivQ_O3n(kAy+~g3EkJ zE$H+7RJdI?H($nE~^z*%=6(qb`0uoi9cDl?{{`! zLL6SQ%J_;=ME*nN@HrAZ0))$5;2ddg&qg%>KMR|^(R0r`DsFz>+zWys2V?oBDw~@2 zpfF$eFNIMc)EAuP46ATEbaZR@=~XA9rvjd*j~Jovd2@U9cR;6fLIU z;0-X{+o>(3hwD9u@L&!8uqTfkcESiRO_zJajh$5FRE6+tP}BPN)=jPEggFC(O+shu z1o5vHlg57jm>_S3-vn(Qj+4S-y-@492j`e9^!qg)wR??9-|8vI96J<BywdrnHrL%6~dhb}3_#vnf`rxD;uIN*)72`1m_nmOsr-* z6@eGVrpsHFbq>>=vd@9;{0mUS&`I0jMYNd`J-a#_EkXBZzS-JdJl#{5OiU|-{WwzA zFxZHfjvEG=gWCz~><$5b;>;%emwX1CleHN(R8~ ziJf8-BZ_h{2QluSwRNnOONlz2w<>?>W?KTc7pZVT>wv+X_+rOW^ggbuL>2hNy?;31mz<%ZnIJi1`D8VOEcX7Gjd;Ghm zOfKg)U{^m~ihEbS)=fH;6`=IR!Rfwyi9tH4@)pN$%ZGF+!Y5-?ciaNY6U9Huwt<>~ zca~Er&)0IC1yDg{oEr{d+5DV;vU(0VDMlt+4Z$w@HUa!f^{CP=}M zac1uwhd3ITvLn-o_Hya^-7c%XXM{NT=lGUz?4#P7RuY9p5*@JKxJE@qcCh&HOJB-+vdL z{}ToCe+~a-=ll9xe;TBAV|C-+O0!&Uk9j@g$Vem(bMB)Lt3M6|LCZUkzKACWs%qc`{jfa$>zW z`sNbl;yyrIy=xQN1M(K;Ze7xx!udpjh2j)44PvWeNnJeu0wK~K%m=kK5z_OcUi#yD zDFu_4)YH%zNlpwhEEB1DwVbQ4h;&F2I(hJZg^O#LoJ|;W}jx`mQ_HYOxVw z{D084sA$m%SXpBcn%mY^UNsZc!H@~7mp(x^AGM#KT%=jo+m4=t)-1^=3T?hh4OrlJ zMOUhK_~4dktkh}zYEFPhAX`*t6LYe-eNgI7O3uM8zLMw*Sw8)14YTxvJcc7}g||XEB~`6>eE>o?h<8kvV{){wVUay5XdXgj zL%=Y>gJz$C;PM8h#C)uu*`l;FGD+qnt#EuspoQ>Me{eAXngks5!A8#k!hu+pkl!c0 z&z&K&mSO@sP+0x;L=B}{Nr;%JhlAl&D6=5c`Y1o!pLFICp$^c#_bVmx(!$rmKSygt z2ki9w&UdUg&Dq8voyY5;@1hW7OH-41IS!k(g`hgaB@&Vle!ZYuuZb8(zMIrry z6hf0i2GvclV2UE;dnMfam=egOyiSR>m%RNj>pK1wh7;=fh3VPM_CmNcwe4!grFTDg zM+~O?6WI)m0!pd1|q$`-4q)5$~1zE(9wp5=RHPoEtEnIoDS20;Cn66+##3pvEb7gpC zU`g6?B_^zi0@7;2xty*a1@%ycwbr?|<#*DYL+gBr$qH-vRJQ%pL9{d={uKw z$0~jk9Oy0J_rFDKJS4gKTqHC#E+EgKHsb@fqJ`FSE zWe$AZ*?PIka&+)@@SlYZ23h+QGj_T}naGM9=b6$4HGV#R_Ag+go!mu;-SNcyJ~~=6 zCvr^7U$K49{;74TM5N_EC|{63Yt4jNlQXR%d$8hC0cR*(QUcm3nQEEpt~ zc%*QSy>94rAKs2@GPT>&@tlUmW)qp)l$D-x3+CCSqf@%aq~J@e6+42*7#?~sQh8m7 zBKMOG08+uJ9c4vhfSI?7F9bOpyT-a5%fW*@Tdg6{y_<&MLk?x{*gya^;_(`F?2$Y< z#pcY%QYz-1*3>DV&MhUPFbDkNnOK85STBJb`2o-;E_mWWqMq0D3V;K@hr7p%|7vtyWRnE6s(Io|;di56C$B)Y*U0Mq~a5z5Kryf0+N5 zsnma~p~(M%`CD`5y$+f3g(B%KRUhpYL=KQKZir-TJ>uW8cP2r7Kg1 zpwLA^IG~KOnd!ghvWgR{g_k+!p+imHb?+5BDb@(b$-_br836~(t+un*jh*+V2g5^v zerP;{H$ZswLHOPBt5w>NQ4T20V8F`jS1bgpzR|xyKUlHvrD^7KfvRXc2EWosA(nDc zBQ;`R(b8a}kiEFou{=u~!WN+Dhlrz%2vp+}hCdGrTb{Ma2p*u}H6mu-r27aZzWuE% zB|4S~8CS@w=pdM|O=cUz&sxEFed$d8?8;Z{X=Ca1h50(pu$lfaw&q#SZe?#h9?=!m zDIGR$?YQkWP9Jh?CYW9Ect6R3fO&^Refe4Uo)8TKwzq;LB&bUy_OxNo&AC8o3k?0YM9tW= zTnMM?9XOi<_1xAAOVbG(n^rqP5?R=icQbuvR@@|jV2g84rRGOjL(y=B3Xu!(TC#Y@ z(Y##5v)u77SH6v()6YW#S??y<@`(w3wWdoe&q1Aveb3$~Ri*py&bMHnXd)R}ff6D)p% z`z^3*uNBr1)D+~-l^H1rn!X}GuC?p;p;a6lMil?f?`D}MHAMzotv%pOBVnqnph>Y4 z60Qliu~*}F>zoG40Jh>eCrE2#4`0bL`FjCe&av#iLfExbusXXq4(k(!tHa*}rsO%`IuccsPBj^I$XSA)O-R5Z<1Xik== z4!&4FX>VDQJqgO(i7MCdtVawqrh#N4hy@rzf`{uAUaxIdA?JhiZJ#??-dxl20v#Ku zKK(&jgg#16MM4f2tZ0Ke0#0W4oIa>|2x4bP_RiEfxCr1$2@Nss&OqOh3xV(cT$yp~ zFtvB&+GxMSIZir-uTaf~F9-E%Jrp9vccFmint%u^IwI)a{Nk#5r^`f%bw0f> z^!({+rn%m*z!oJm0*v!IWS!tfilSo-^POEiZ(a;0eV#zQ;0q?Kw#ba!YN-FZi35fo z%_qM}uNGKvEc3ye?O4^8PA);K%1Iim_2^-&+dGUm5YPhu5NVmQ<2vC0;@wI1Xzfw` zcu#o4j43bE8N)f+JBn8rLtjYexFygoG*g3Fm$E6*AfjUAMUS2&xO5dNq?9a4?=o1q zmP1XKxXZEha)&lP%p??JvLg3XPteq^B|u*%M&-Vc&0@{0GbMb7b}iR&VOy3s`Ozvf zuUTDuM~P7%Q&gX1alBKw-t_3oO82yiKVQ3~fL&oad%Hlazs8$voUWri(#nME=*+pdC}@J|CqUC3 z@MJQw_XeHRpdCzBvy0D7Wc<<^3f z%aZDf*Wewwxt_>K17#{Lm7x;jOB4ul2 zVfQJ(qg z56DMYW0ZeY6aPVu{-Y-TTW$GozA68Q_1OP+mGB?5(tlD3IaxUVF;Hq&w@%z>LH?Z4 z^_R0gSO*B)E@iur$1s?4RcEedG%?GHg2u-U;pw8G@EpBcepfTv2TaE+o8E$zx=}Z zw;+^teWt|)y+tuBWA_|!>IfsCNqES!6kprQy7{}UI}4`9J=Ig)H_(J?)~_RnXHTyb zNTB7YCh>%J!lOx5%|#ib+X}HCDi`|l&p-dQTv-Cu6e^ioq2r;ZaGs{ykDIMJ1fq$1p-4eFM3fB=5^HaYgjWx!?} z-jvuJ9^@Z+EVM9;ci^LP`|(#TK2&HCoAL(C9#0Z?z{JoNl$ zyuB-{>udIkMPl(;G)0+VLT0@b8w;FJj731?QRP2kiOi8>lsGW4j2WSbazv5fOjX9Z zISTh4>1E9mH0Wr|BJ1o>nB7d9P zO0Vkv?;3}>yyGH587_z}w#AJ@Zj&4N3cSd!1yw^83Ck6$ zR~1Z{X8W8}hq7!UYgXbLr>)wsG$M*|=pXB;!Rs>+zaJDzscfvHaCWOFr+=G2B+<4Q z%UMtXRmB{P^@{F@t3N{3Xj3V~P$Fb#qtOnybS4u}rKGhmAknm_LE1+)zTg3{ns&FBz;H0AgRvM5sgnhxDp%MZ% z6Fa}SqgqOpn^v5Yx_{4QpS11yuyKDFG+bO;je5k>P3{qA%24YFG)lndiibD++t=>)3rzhZZ5~hAbxFeBQaRTOkI5SgAl!JB zxfe`_=ch@W&0^;WS7&D7C66n&J7a$+rn_w62 z=cqrmW3bnlwHK2fv@DRAW#D-jIx2yW1HgK6HMT1hje^@4D5BYdvC69!GBpT+vmKU} z@|Jt7O_L}InnE|#q3cF<_=`6391apz<$q8l>(O03m^36jfii&MDAHRh_0gk#hLJ%I z*c!>5nEq9dsRx_qcetD^phV_tx~j0Ufu8bE7MMzNq`3k1sqJuJJ;hQjo`H_u6TOf*3Ww0ZBsYkiwd&-^@+wfE4c#2DCKG zI3psV#~20Mn5+3{CmSFw!D>&h+~{m~xxbilxQp+oaHT#7@-``KB2Ces8TWJzf3Fmi z9E_hOVfI}jik0GKMD9A}K;OcqrGqdXUQ#-klpON;uwPNGfHuJ>Tn+QaxUbU3jeN2? z1#_!=45+M~IJQiX-(0&Ma8$p9P^FxQXu)T9No(-;*J3u2r1iXDQbO?ZIXe3phGJuc zap`0rtsS_4tVYjG%>y%&?O3EFKh<0%nK{kmnV0=iI{M0E-UWxiKe1lvH-gaGwC(p^ zg7LPThh%`WVEWPVYwIB9Iv2G|VfA9>k4yFTSSJcp^b4yt#wGbe5hTfB(WgStBo-Ss zd)4S0ggKPyMg5TJnM;SJ8jd0#O~@ME&j_*x{dHQz)F01cR`@&PFmgXX2BjOzug^|0 zwR86?H*UJWKm{+IIscVP`3KAU50&!&LtM}Qm7DuNaGw9OUSR_Khb`)E^^JrLHWcp@ z)m=sxYqNk|@W+%NmqrO3cjSrn70>^qoBxWiKE(Y?OPmr-rFl0dB|>#sO2h|Hj1p3`7{59 zRA#fFFkjCPF*(uMkfj%4i`tCQPE)28VSv*&E{Qj%wdmlr5wxNi)+~X@3QERrC!i4f$TD!IA1`0xIuu$v?^_iJ+j*P!`~ShVAlGumefh0x1_wlEtyD(C{U8iMZpQ zE+BbN%11C%nxAs6-5qFS*pRtbat2&_|M(;FkOJ$$sh=dEfU@s{f#LY~ZITl0!WD{& zXH(h-eyW41wa+mHG(a&}FgmD9M`2v@DcCANmm8{FjSl5jay=7-gp*|JFm~3S;aOg@&Ozg{RJktj;yZlAIJZGc+NpTKWF5GXXRr zt+J#w>j5n5K}(vW{2<^>ASfWd9|J~60T9W0fJ{@Ikog8=1VH0hw2LtF*ewTR9yS|V zchLK$kV-_F`V*t~NVaWZX=M*6+@3HJDw~*DO zyvOFCU%}Q|3vux#PN9@N#W)3(6mf&JNm2DDm-RGchdRMm<|4os791I#jIWs22<3AA+LcVL8?ViNXHr+M+%qGoUx`k8mHQDW_~Us*gI zCqA7K^`kza!gb5(Wog%NGw+Ml1n5pQit%ahy^r=}NxC?9@VsffwO*{7A>!INW=8EO z)7OH%VL2tyT>P{&c9Ls@3Q-4!3@Ff;^4cA+qbJWm<(bhINksUWcDlc?E{{q|_-^!PwV|cVLfk!?-2Vjc~m`S8wY> zJ&`rtgs3xiP>E9C&dXB4UzP2na?+m)pmLDA1ZLW_cXkV+ZZ|TaAS(IR#toapz>H;e z`;Liw0NKHno!%aDXXP;ka;zM%&ZwL<_ zK|)AF3?A`787T|k$K{B*lJa@2vc;eq75ObBd{W&vXd-zfpO1?5lpneJAdd`-4$93A zFC!Wg?+1L)y_;RcUVMT)k+#jHUITzu)V*>vi=i#Sb^o-aKi4pC)=# zv_3rktbh!!-h~-&C_h8j3-s#=N^0SP;Ta@Vq*On9n~zc1JLKi9%)15FBA^Z~O(RpQ zrU%lIdZrm}w5&9V=I0)$kZJOT>@6dk?-oI+bdXYsuIHn%@jWNZl-xmvXzFg#0k0)=c#3W|xw|7ZVUZC`~wK zq1g1c!a)QV@>xx($*a9*;f$~V8f8Ie^wL6lW5VyeP%YlM*3y5c(hLGkwK|QX49yI% z=<4RYZ<$eXHvUa7A|+gp4uA@0`Tk4gM3EgDngLoP-}oUaQYc1KYg<% zA7XI&_EMX#L8!n0uO2rW2!m7LSzWk?10v^Dg)W=(DNKu@j7q3350UMz&Wyn+w%#{z zJ}up?uI|shgGO^v?9ch?s82>2f0y1bgRi+SmyP%h)kvDjq%Pve+=VEM-p{N@w&AE;cbA9vEhQcEs+O-aH2F>V0(+QyD=ttp*)<6_1n8(t?y$gN#=94l zFU=aK#NS8STH6&DLDxA3E3kE9MN$ge6AY>WsjuCSswZD!J`fZCLNl@a1GD{yX8Jen z@!#Cp`M;r=SpGqD{AZep{h!m0D-CPgtnV!Jo?Zh!WeIfTkiDg)zq=eZ8Ei6IH^-vN z-ob#WbrxDH|K`rG5&q^AIA%cAUBHV?v1c*0`TQfaV4#*g( z$Qusu3_$9)Q&zLLcHh|^l%}aEmdRj}w}@cZc8pT`A=e2e4>9bWGkixOz~Lc9BK%m+%vXQ5-L6oi-pKP=zFJ2h1G&c#H?Dn%f94@hJ;Qs# z6eX26L%uF>_kfJf%oOA8QgeHz3Hq%U^ z1k-4TX+|CVE`TbPPTkq0#l0AZi00T7Qgw!@Hs4pL4KI~VaC^9xjBxMONfQvlVg5XZ@5jSry`Maey_UESgLen~Cx`Q7zB<`QHe7)nYxDgx*uD{m&04G`piyE8XuU}P z{^qB!5T91scATc1D-SkI5yFr?j)Nxv_=ndjz84~Ue6r}TOdtVmLOnzmD2~B0;{9}* zsraG`+??7rE)dcIL5cS?_6V9j(9i_RFt?H>)}12!fJ#$CTDzp$p9Fdf8Sou_VpL;K za1`>AI0dYoM8)Rtsl-7;%T|P-a_P}`PRT8A!+gAJ{=Y< z&RfEax0FzFY%V8}YBb{h%2>8@4pLD}YN#opZ0^iR5VmajAivVnmT5+rv$8h}HGUPv zUx&t^w3mi;zpeT_N;x5wsO*rgWp~cliF<*by=dA_sP)o}H&Wc64Aa7N50JZP2;=NJ zsulO19JfxQ!0us43DChb*Li3lelhpXJbt|v=oQAQqwuTi=#T-cS{q_L1-e5I7Z`s(azBW5Zd)gK=^B{k(oOF!7c8C&!3M{BBcBk6MF)6O~v+W*U?5^^Z zh9Wbf(rhTRA;`=`6GSJ0eJx}~L}4d^QbJNk87x3-TlbUHr$wSK-Z^+*e#pnE{A`z} zK%FP(dK{WBc-Y&=p#fn5j6X_vI*6T@l+Wk$R-Z>Q$GUC$o%Q612ILxwq2P&2>Yz+E zvP*!D!Q$6_TB++TGC<3gv3I_Mn5Kt%;;M~$rN8j<0kz=36DW+t0n^yL;5;NuRh>vC znW|QECvAme4iUS&0DTA3$gPXMZ>JJ7*3nQSje7$T`T-CV6IhowMSQZfB&Bbgq|B5l zLNDs7kRg(%Xj~jJChiIhFD(sOrf-kCXY90_?Uw&@T47n&1oL#n) ziqaFZ7$HA^a*i=97gjXia>n(uIZrib0cc5!&diY z@Dq$1)@sl&pc}e5f8VMMkmwt43p8BUFZJEF%5eJO;_%+&B+MiIVC>IT^l<^UBbyZ4 zS&5`emY>sdQ5L15tak6*((M6k&4M^=1HrwKiFmTtxe#gR)5 zhvC!yfPs;K(9)FR?V3!~Vb)Ng*hPsHGOOD*{|l8|oi28$GQubCIef9j#kkQm^8Pm< z3Kp#42Q}%<-_iCX1ISl6MtX`VQo~F@Abc@!!gfu8+C7c!ia^!8=wgjWD$w~Pncz<# zJR0Wn&#n$DBUV=_?BVJw%3(yX#!c%Bzxe4OhT7>rCEFNm8~p{bIc@dx^vx_SG~vvs z4Mkgs?ISQS3%wuSwDGqM5%%M_ptk#_V6V0voZRQX1a2UYy(9PaD(^1ZTW5$lL=!Kr z27O|&vNZ43Ju6gSBi%=f{43XvdA==<_SxDKBlOd;RKV8Y-cNXqWuYZLX``^Wqs{hn z!Wq%O$OI1f!3=3`;c{hMEQp85h0HVL;rD&7;Y&Yr4pY~3b!$}${*_+(2W9!c_0qrV zj{k{z=^ws>|7X3#$jGaZUfDe5FIfKOohXL-?8_R==X?v5xG3He?$(m>$cG-wI9ZCoz~i$Y^H{MTiP?CTjCx#&e<7WWc?C?Lr zRE?q$h*uV=07En5#>*(2aVI2!pI3Ga%<9iD>yKBw!1|-m&qL!+L4MocNAkkm1e>5(Dg+a4SX{hv?;Y0A%4BF!ej0abXcRWpw+A zV(~HhWSW8TkW`>@W}O7LVe}%(1(?(^8?wBj)!iKF2dU@>wF#!~vSLD5pLl4=oO@aV zn?8T>h}Z<$$OI^YTJen0VT~<1a5<=&>j|{|VbP>@$%X>}%@2I3815f!5t0+`clIRr z)LSr6_VJCSG=_xf^oHD*mC931i(>LkOpCF(*zUfTw98P8F98Pc+ny zz^?g2(3}~l)=X{DW)GayRmPyo^?QBUdq12O>hXw4TlTNKgl%K!dGIy;>WrY%7s)9J??5EOUk7yue zc26tA3PyN$2ppJT_NQNmFzpu5!`#;IIT0|qC?1oI8c5z0$jVwJxQk+`NzjesZ`~Ks zPK>VjmS(4K&}ON|o+EN;2vUlhGm-dV&-t8=O|yAT}lh{}C+rzmSx#L4q!*~0g8 zh1%FuC$=%=#^rl8b|LzB;4vsmYR`1QR^?5@cGQ)~%@V}Olf4Hd_{}d*)osbJ8Bk+ z>;kIGO9=lv=i{FC7pV_E?;k_t>~4>GHy7TZ8*mmpa8-&k4+gbU1wFVTaj+AX{){82MfHarLG^rcaWs<-7%Xo-gb%YpEa8KDJ8 z8G+=lpwyFwUnZyzU#l%uSRmrzSBi7^7(PY6aPT*}a6fcjU<=<_cpkl4iZr&)ocrTB!z( zcA*@KgY#uT8ig*}RFPhlii!Xj63*2U#IAxqW2~IK1jZqE4){IR7?TiMyt(Bl9Bem6 zozF468)cm|duqz)5j<$Ns!XT+uMOIj{@T{8oBWY(E|EawMaX;nB%g0)QLS9(kt+@6 zvko5B7U{ZQqpo)?5#5=)L4w3tIC|@L*ARuTs9ncJ+eiM6vxoW0p*RIQx1?P4CfLp; z5Zy0f3eWiSwyU*@#Z7I>3Mb1y%iQl$ek3jP^F$JrcM757s^sUhozBmdVTI1(>A#^5 zN&52|&kDZEA%F=Mtwl~^rRBxsg%)aAR^u7DWAYKWC92D`9(U+pgWFtjVm2j-nCa#A zG4G3q6bW60LeLH<|O{a>=5EdL9* z{2#}Dviuj>PsV>{n{KII*k*|$ea-0B=T>lZSgCCnIgnAbx0Jt!dAF(HszMFs$P54< z+oxzA`QA){j1Im=;ZuurCwfm^&rI3oTxv%M#MzpQ&}E7*SW2$l8zw ze}Mh@K}MdaTZHI4P6~w5yGGW~^O1v`I1$BR8NSD*oK}DvguFypA-OlVCO+#U(?Iw* z9$_oUA09Z*kZ{@e7PkHj!>Am|)JbyM?K=M51KG;!Sl?rrlCTO9U82X8SYCKc$4Rb6 zC^TQP$`ElH`Q42>-lS}Cby}8Bx4Y!G=n>ngs5+mH7Fma7K?9q^x>0~5#90#T5c2pF zgyc22k5_w2qwh3hv7e{T#LUW4G+7`{sB1ukalvSe1^nCatq_A_nOwO+0UiqUlh)xL zG_RQ2OplGrlLY7-9$TVP{kK1Yxc77m6*D~w_Qs@I(Z%JZ0(WUEkDQC!PEq>bExCwkv-!Hwlo7)~Hu3Vef@Ro|?h$`Jp`G9w zxvLo$EeLA8!3N9xfF|P!CnA(8#ZV*fSJ|6aCWVU`DKAq)eq6DE73V&l>PJhSq z*98#m2*K}|A6prwwh<<KB`>;|T5_ur{v=Wec)tZ|E06vS{4)1ku%wF$vyoHCv zR9(%^;oC({0^{=vT^|LN0YQ91pZON1mfOxxd9lT_puhDg&OWI`;S?5{bImPx;58wM zb2NYWBAfxm0i2pxc3@SG&Fxw=PyAPo@&~LxQIy2FvB+s^{0brO-U``lq!!-o{G$jN zHQ^{3!=6|c$Y&-XLOg5JuYyi2nKR1$)^2Go;&^WvoWeZCY7pp^q!wsU|4zS?H83Ls zfL~mb;Cz>2E0n8vpHj+$AP=7A2~K$HxAI=v!e6`WIRi|{hd2?%pvOEFelr}#AZ{Q_ zZ)2H7iLLHv3;H_|AUXw@!qCBT++*K7(j>q%!oR0fivvR}YK1Qa;J>1P5bS2MjCWnC zyqa+=#%$DNp!xiEVK^W(hhOo(V48CK`NC|-H~^24Q8t#o?t%=z`y6@Ng4lbn^jwj` z<#`32hLa*~ngEfNqV?o$cBLHUjp*?9G%JN!X?jHO>$;i9{BpYZcGsHd>Px?scyxE> zaMX34;oGY{0X5>FzL57#9lo2j&Cqmm3vXQL>K zfXLmaAw2WrCiQx4oZHmh2LPX3qYrsi@NSAz2yxXoy5c1{#%R(8Zen`5Z0sw3&D!L6 zxnW*`9y#&svo-FK{a}#0?)i7)BLYH%MgY~H5&xvAyRUD;4ML63n3!BWzrmh?9F~w* zPJ0fw2M;|W9YV?i~ne?*tNcQqCWOtg`UEBssr8^@0Q>12Lp2 z!pP;og(OY1)dpQn9AvX>nH)l%^~J*aXbJwp--lI!X7l&u-TV&)EmP~{%u^6{hOUAs zZoSQ9$HT0e&84$U_Q@p+Vi>j7(TfivG-K-f`?xyuiZttex<{%C7rI+Ux~Tr<1%lei z&`0HHy0p!7tj)%&&Sr?CT>CEJ?e;5D%qL^hY_iN5Z+!!6=B9-q}R#amzEND}iYqr_r;mE2i#L-5dMmb{zYF^jHs!uL$>iWU}6FN+o-zTn*` zlQXT=GzZ(ICL1&VfSADUQUXmj+x`@fb0sEH``pp#!tIoz?Q5He-s37uyUh%y;Ik-I z<7pQ%!0QqPZ3eHPca-3+?I)OmKjp9;HvPBhkjfcLdLC-CICgp*=g zfmHu7oYW;n)tU0fsY&9~nUo$EZD|MYo~f&rqZ06dM@X0#H|9p3C=bczG|jc9#I0g| zEHJ!Zy z?d2^u!?%;f_AIWvC#lj>4ds`8y{4NFxQ~F~fhike?E5j7R4#)H;Qj*tBYQFz*P4KX zbx+QKk=;e)-C1b6rBQ`bXA|wfla}p5DX!d|qQdDp6?i9R|`eW4h#gD&<+m@Z1>kM7*sK^ zH0A$?y0?t2WNWiD&CHx;X8V|#nb~PdGc#kFnVFfHnb~P(N;5;6nPL3h>Y2VJ-D*{7 zrbgZ8===yNVuwPCvzOleK6|alz`<_XCMiLjz#|w*3z!rszvxPqR9Ms!CzA_w{e8`Q zC<=Gg9wb}HKIScC$}^~$f`jPX7EpK)4uqRUy~fGv@8&nI^_?OW*3FW|QZ?UJl7vpg z=$M_*0VR$}d;qpkK&%};h45e%fElUO={DLB4mNGr;|fiCO6_u&vpsB{)SF$+40JpL zL3I@Cz==^I& zX~@XNP%g8^M!g?PV_5J!yhdD6RVEElW3=Z_?)F^g0u0j9G$5K6*~n$q0z^|fG2SuV z1VII`(v}RIZA8Z*oz=6}=|;`H3>+vpzkV;qd3d)`<>-6rmk6iwxjx$M_Ma{-c%#^& zd0gLecyPiDB$&NvVd3S76}0Tc^x*frIO5{P#B4^(_aA+C;l+~elngL(>28V6`N0+uuH@XMngM6(Y8ixpXz6!O4D;#694!~48?<-p)luph z?Vh0GLbuyzwGH2O1KFIVex^AD)VZyi88ywftKEmHQ~wvZ%#psxYfpfTh@J3<~f zi=4IDTcW|(SJV^ZsXl7NPy9U7K0)FJRX+P~kcWZl|KtY6@{cgwU-RRC&usob@~Z%1 zEQEg%cmFRY@xPI8LdrZm0OhZ*8sXQJ4G{e6NL5J^@b#lKb8@od0szcyOl%E}ZJdl9 z=xuBrjLZ!kjjhe;4Q;IfR9}}UI~zE;+Zh97%xx?I!dn08cQa}OguYHRcKGXvK^vfC zZ0MxL%*sH|%tpw>#7zI?48X$1O3%(o$i&P<&&r|A$M-M6v^B7RVPySV$NWEDGi7FD z|GP2OWaeM{2!^*#mA6%grwUmJ1|gf~F{Ag$FGyW>l}{S&#S0QBBg!bLQ4S(*&EFI| z2y1&U;+L)+meXX;24m~^&wTve1L}+3n4S&zpjEk~16mbs@AscQZ{GJ)B(VY|v&%Ci zD?fmHK5t237F!Z>K2Xb9;qLi|UAgW?w@8v8^$QO(Bnx#BcPZtV(aT7cB~f|-NB8@) z--OCtz{d=v1&p+dJ<`bI1gDesSYsB5?=pB)-p0uF7r7JZv-@g_-u%B=EqR z#2xMj9gfryib#Ee;yk`GX3)b^hwalYNYv>Ba|+r8OC_k~%4k)bLC)RV z(`ZRfHVr{6F?DN6lfxY&aa^uKR>F6)wCeKW4||C@3+T9r;jl$)&Htn?ljLa0K4p4X`>TN`75)9%%lVAKpvT7#a#itH)$8dheC*z=&}C2W z0KRrgh&sEZ(z#F9wOih!&i@z)Q%fvb9JcEd5aAr*!AEI;1YP*x9_b$&rw zbGsdkfvSKgyDxEJ=rkei*^MHVQV$s)C`HH|~pgJ;rQ53hZxg5M&8VS278Pw%FtB@P=?%mZJi6 zOs=CW?!VU+B1+TNi4*0DYLQ~>4j74o-@0!G$>QGJYs~f5D3=(PD}-2 z%#o)qQHdfB2Neg_l5qnaf*Q1pg_rMRG!T9&$bm21s)PkLwk-f7@J+6)qKFQS1THid zs3-46$xz^eDGOqSt6uA%i?B1AQ2~PKtQXNITM*QH* zhIBzM5@wd8UhzP-mo^$z0i4)QHmneeVt@+1Y+Q2C7f#Twg9^ZaV1!|4#4)~`ObQOgM3N#P8APNq06G^P+Uk+os zePoQ6K-Lbu<%F%39&^J*Mdn#wj4GkE>({yQU(0MHHP?^>iMfWO0YPr96j2IH+6gQ^ zLsTWzmk1?nolHzg6@ZCgGQYJQEKUQq9Eq1iGjR)KVx6Nmsc(=Q8BTmx(SLGSZI+gD7ZME$ zXhp)_-ky*Zy+WWl;#gk)b7F}DSdeun&i5)_i#_z3N6b8)qEWfpiBi1e7z3igtYfM9Gj{Iy& zprHkC^1(sOShXCn-AT_zmPoeoYd!9pwp#^Vx@2k+MZjR^Pubz0O6t7#LV~^PbiMRc zcBJ_8;_k|y`q zWBJ)3Wd%X@3CI{Cjz_=<+nUW0EwBz)VZY84vuHBQV52UM=>12#!*D|TLv@caEoM>j zUn{kLBi~bDWTN*)ikLPKj=wUX*nrGbFsxUS=i48n9`&h{CR0%;<}kQN{Myx~sLb#{ zi}=-O%~4HmMv99nZmiC#g^JG~+Zj4chsq9LqL@>=(x8LHJKUAQg$C;~*I|~zX&9#` zgIm`1ssvcvkf{l@dr=h2>R+n`6K=xbk*K&4`Qf0aK6Q)%h zH|Q(6ELw^{CX~D$jBt%$maQBZYfKtAlj!yrWpityCYb+ppV^s*X}2A{v34@W<5TpV z5x>Ek~HODY2<^hc3G;v<4SudWYbd>%5*dr~!28yWJX|9)?oz#TW+A0e30+ zEcp}<3iuTR&1ZMbEz;2m#JQdFln8vAl4T!}B5268sxS8uHQn6-Dgr~rKWv-zvX7LT zd_o|Na^=qzFHC0k+*a9+HddW7Z3|9O0+Uy}^yIa?uBlqV)jormHJZ>&?rE9O}gh(r#A~l^JmhY8lQ5oT^?%>#~_7_eE7fFELw&S;mBuC zK3E+JJ2^tO6Jh9VabdZ=$pS2_an@aMds zCB_zT(fDdpcuuNRbK70zqEN@XPF8E%uG9->1Np1WyLzd&y8QKy-}c9clEem8c($)2eC20c>AxSX9Mx(uP z(3Gssu^heQkC{QRRj(hhh!Ng^K;{9CH4Sb5%Dg5xUmghfwKy={W6A5eU+VGn$M6JM zT#(~*5tM*%7-K-$hEq}lZ67(yhf|!^FGu%BHev{o{%w!@J%k1PC%$3?!_cQ6ggWU0 zG4?zr-*K~Jtn=KvryEf4!kgjM0m@UWkqY$N8+RfQ{(`U*gpXvWm(kYGNDi26JLz*7 zt*1Y(XW@0Hq-7rws{C3Q?}$&3j$9wFqn|(r9zx9ju$IgEHxT-NVoHCNuKzvN|9==L z`qwgmppA{KlcN?R%U@i%Hb6n&;j3OJWc)8};Aj0Cdi5U{-i#~^|Gu4REx#s#^l_of zm_seFUJvlrs5lAfx9=_MOcb*yatMcGBvr*Nk))KM_!xg*$hcoU)uzaW-yiscMs>}> zJw3t9%-!(H{QD9dEuV$>hmb82?t}ky-?T3Z^%tN5g5b0J$qyp7!}9cj83Y`D!rY-; z{?ms+0?K%%13uM5o?}lD4o(D42+8vdy>Cf_6DQJUTUsa5W^8o(!$fha`6qv36Q&>v z5wtX2Zp0ZqBw&(~Jg$}n^`rF-Vlo9SQw381bvc8ak-zg__5_+-{N>CIJLaK~p{CBso(%P`tDh@as zZfXc(8N+@pFtXxV7!g>Z3bZD9cwe@aMfUo+7Ic`Dx%hFs)-lgLrAc2$$=0A=cOfCz zeuiesRxXGFB1K`W25kx0{5*Z+gQ{8jerjU8K(;izo{renu+_R?@$l>LO7%jl4UGPo zW_J#1i2lHQAv5<@Ukm}^0fRBE1Uz3=QZAtHeA*=)p{tPR-zNn_)vf74iNIWVE5hMT zBZ4ao8L;tL1M60U8VTW$g_By?I)G@*T3^1?e_i6c8n9ZCE+SD^rFoB}6lo2s&!I*7 z107WV!8J%P(gldl_sgv%p@p0qs6xUCsM4ri&J`IwFx{$rcsn^i9E^|solUZEBh0c+ zXQfdO;v@k6v59aM{3o$GT@N!{dxKC%t&HDxCPI;lp>&2(f0Ei2p+%!I?m4dbtE(8P zTmssi({QUYEdwsV&b{zTwM4X2WD*b2F7i*&g?_&(2f!2hTj}fu4!4%Fszqw`zjmzgCMSA zNUMlw>Y^aXrZ#H^J+768-EdUq+i`xTb&sq%8#{`YYoR z1F57FIzApZ+-JbvJ*5=t5~Q~+B*cQ52g4NN!_isr6g3VcU}ER5NL<8a)lSYqmAETw zegj-fEeCL8k_e)FSR0r<+NKG817@{Y{Riy5rpI2&e^U3^Rq5+FjTk0P3;rJ)1?m<5`VGjjagBs|43l7@Ic zn~g1eX@0xglol?O$vSKd*-kO@bIxjB8Kp>jNi%7vR2a245>0w}K@lfiM8D9B&8Vjw z3$qNBd6ibZn)2E+XWb<=rm5UCo{t`F4{p*=pq6JQCM!!p@8Z`r4IKU=%S;kf19B~n z0=zS3Dym$gb=Bhndl#E?D0uoz)|MnVwe^e_0)Z^Ke($ zidVHaQj#_EOtp61zW$7c=d!;(Irq~5kEr>Mt7@GCEgzZhs7p+FY?^FOi#dS$Z`hg@>EEK8 zMbwKHBb#w&tA`7o83=j@proxBt)}^(s;j!PczdW#K&Ejl(d{>qJZVxHC3o+l$UN=b zmO9>^MmvHRXGdE?zeP#VvTF=dQP_97z<*9hKS+H#UIEsGvmgFRl>SDW{!Ntr`<&JO zzgv=K{TmqcztA35=D){8ZK!{x5s1P4Ycn>LA$K-w%J^xaS1Df0JWE`Hx-91JxTV1@<3*ckHz&$Rx(P};#pQq^;iT@8E$X;NVvYN4L6~#U~xcn6c_{90L8@cE5 zQW4{1U>eZ?wWqfRAyv16AD&7?0*anDK?=MtS^lCbF!OCfLtgoclMH?!%zljiDf313 z?2@;HH#?aC5`J0#F~Gd1&x?jz$9(9Jl@Q+OjFxSmeqymcN`PcK240cLN#LkO?9}jc zgH!%$J%5Mlyfp(Q`X6oTvT=j@D7wxi)(no~TEmt8 zDFuA>TtYte*5Qn_WrqD&(un}G;69svGps<|U3hxp)MDa!7Nb>gGB)xhzhEm7@xDPH zoXt-^Gw6oCJP7*}Phx=rRKo*LisKnbCEaCQgIQ$g{7S8ksoN*Fbf7@Kc}rd5&hP8m zJZlvj5e=vziSB0R5P4^8pO+4D3O1@Vq+H1wdma$7T6PQ5=DR%$;z$+3m*SQRVN zo!d>>>;>WK@zAb_9nBv632EFrxua@amtriV-oyTrCyIk)=c;;&zPGu3LA!7F#)LZ_ zHLJORo0a-vB7|_@;%*9go2RUKRP@+|KN7zwcdAP?kq;R7;0nF7<{ujx>R*~{mUh(ti(;s%|ZJ%5oN)rZ_%&(hK3-1{QIeJ zoYYX6LgyK}A9qAshDnju)s4gD(|y@bhlj(-l|kO0+(YA|gS;PZP}8fbDX)P2lrb&s zV;8U3q#v}M6GLjpfv?99P(%!?$rnf=i_Osp+l6(=MbKCIcP92KfjqvdD!~fDxHH2% znkt-|8Sav`;UJ!Nb_-pwpH`zUR7+qc!oiX1$aNMls(w!#a_@j%RQ}Iw=oyDWINeda zl9H&O(bl2e812e%rsQ`8MzcR8g16s5pLB3_x2zQ#=oFzwslj;mBo%;Gk)UC_c+}lF zQ>@vi7`zNbr;e!jbVThV0o}S4P(e&VNtj8#@<2Tbck{*=w7>WSlGs zhu0H}7Kg%+2o(V3O_#gk^$?F%FGAR8@K$(QjbMN&!5p zeraeYL5O0G7FhHaQqa>uMFGxS5fFf0$!Q#QQ0dTI;rX|9DA^vTkVb!f_&C(c3GE9EYox6eH-*>fjte_L5lOtseBE@Z?A_jVOdAV*jdwaoY-kM|w zM5NE1I=CKnGzv|fbUQ#yf5hs(`EhS$G{cpD*coG!K$P#8=+)uyejkyAc*~$@$65QO zb)_h*HIQuR!QO~z&vk3idUFFs!4{G)a~oX2fl(_e$NG8_EO!B*M`?n#IZd$4l52*oZk&qCBVqZDqZulHmbO` zi2jlI34H+*sSm&q3U15ivq=!xqNPfg&kA~&qX>g0pY)`9iF2--F?)YvHTlB$c+>u_wReiM$D7JF`}-U}AC8@EMbx+C%eyk_MO0D!(=`(W zf34I}Ed{>Z1L_o-G5Tj>df+N=Jzvw_pU;ao`nxTvPv9;9i1}t=` z`rS>3)jYe`xOpm}T&5m7@3pbZuJT8V0LB6VTt4b+&$gtO1jzgUGZJqz@ z)epKr^xddNUa*tFY74eL7EQ(xuKSU;&GuNC97%@BhIu#0LwfAj4T%dGeu{Nn+*VC=|JvGanbia)_PoS_S$;)=NRUQs$|FR zgGgc0+VI@=UDT8-x2M%y^gFLy_zuPV|?VfF20xl}9=-;>*qJn}5Y|0#dLMR;&AfU)o0>w!t;A zWH6%R)UIVAbQ>xIIb<8q+F?$L+ehas+0ijnL7km5SdnT@iFNli=B30$oneiWTGHwS z^t!Rh9T<^1*x-2wW-mZB6Wd9hWHpZ~j<0sl&USg)Qzr{n1Ouztt$#xGuPf|_1K%`_ zLMA4cN)rxO>s{d z7X3&Gl@H0DVJzPx*D=L=u?xjmKirVwn>SKhb`O{mN5n9X*c!sC+|vXTuB_Q5?}}0+ znOybM__*^-G)^hJkxpx7QXzIe?NqUkNT44s#axm7-WfTBx62&noaU_bSv#@|VbXvq z@!ej-1UwVB2>`mI9a_;b6S6Wo^!9tkyDgJJ99K2e>;9}W&+5h3J}-fNS%GKLN#~DP zF6hsVUHFBOWMW?=88CR}UQ{Da%n(RV}acu?(G?v3taA+%tcoKsp0@ zO8WF_TvU^RVr9!@AnmReU|E2KC=uot%b3^8^B^TK#z%qVu)+sB`l_Crq^8x|U8sUd&QIdo#k2uo(;=7f|1Q-mdkm$D)({|t}M z8C^I|FGn)wW@W@he5GS$>&cM74uPMK5h?MvCGx^O$i&?5FzV zN$Hekg9D4*9@w!q><W*LkN@ItZ2`7R8{KU2*h0hsRses92QZn|j%T z51_unr<k)5{Ca11?_Lh(SKau zF*E#oLDT$yVt`vXRL5u`*xyXXS4mH$5zI@Jt}$T2f{6`~eC;JFeD-qMHynXLV^Jhh z@PE*&a+dogE2vDi|O;Z zOiUH~RMRcE+j`Mu|h*FJdcmcx*S8?PwehF7%KPbYaFC+gOu_D<=^TS=;4`89J8j3Vy6@N2UEl-L`PIzipndX&mbKLB zat`_In{QiQ zZ*E#h2XVEztcr2K5$j$PNhC(Yt3-fs9x4ZV#UAtoJ{E7e#Lqu+Iytx!3SJ`)CB^9L zitOOC)@@diTakru4|o5W*n3wPFs7)hC_-VYCkUgpAdc?_+iCZ)WV6D_h5clycMY-2 z!p&YRzPr$NaC0|cv%=rEsF3*XNB(t_2kUu8tDO62{nw>!tniswbSisE@^`C@XnkQB zi{aj*O-8glqSH$>s1nymoowJ0)aWhY2dpR-BYC$kf_C1IEGFgO?h#HS%cU}$bKbUa zK_s0YQrWFc7;7GA3$}vp-NP<1zL=`L^Kt^GHk`zx8xNDZj}4W_FDrC0e__=@@0_KR zPw265!W|@R7sZfX`|TxvZNQ{in54>r^zPe@MnH1nV39ft(V+Q+y5w7^899MvOELvi zl!i}<08}-yK-lvzjp<%fs4Nz_LKlT^HkJ}>VRvtV4kZSdZS_bzh4$pAu?8BCc|*O~ zgeoW{?xK0P@BXR#!b701e5Z|Xh_C5xa{h+>4b!EYR`Pi?Elsx38f};&?Pz#2{XG2+ zRhVSom6?Jq9sYab*{U?H+OW4r^QWc(csdoB#TGy^**ZvaQ2rXiA5e zMB4?MdvfgZTlSBoM^&xO1^cFsOXJNeAp%fa_Lo4wTX&vO(>OMhkL@xlL4VgH5B=3s zE1A9O!AUf{H-Ij*4sOi(0A(G=hqD zFm(UXZ2o99v{7Fv=B^!fdxx4K-jD*a=3&v=*szNd%v4k3nO{;8oE#Ud;t9Q9J z*-w`OZ3+5Y2#ef;p)5DqXmh(??U1r9NN`w&Q>iXkNH~8ZNB=&I3cRqbpSiU{lf*%M zJHi^Z4+@4nysSl8U|VK2u3d?B&4*GeH#pC@#Zr=0Z2kfE0Z!dksSNdFf>FFmLZA#M zE`JVIeWAu3-UFKX=v2x>wZl~fU)4@yD;Tff0xeDkhlY)uF=&XmM!#B4Z)rc|Q4xR8 zo=4M!t!x)Km3ti@|6{j)aGv_xS z^QJ<-y%8lFPMPVOV{`7y=pIA}PTAX`Q%r0%I;S+IQi~!&rB5?nPcQ7v3=9nr22Y90 zeqL}GxpC8Hi^DKf19@DKYZH|9Y^QGz>D`LwUoyb1u_bgsnC+;rq$(f`IKSPDv#Xuz z>i(#y;j3D*txis{l%QAhsrqbvxw^J!<6;c8#yX`PM$2Hekn;PX*+`srQ!H8_6Mzz* zD(C*ju=Xd6EI|=G4>n0_f@XW3LL_mh)||;#JGSjfjNsu%g1C5I=lHgjBy4RI#}56&S|cm0xUn{nLzXo(&`hk9o78OQis!R*XrDIT$kzS2NIW?aUZ? z?&vl)XX0Clkx*Hxgx!Trj$Kx|;%dn9tWulA&fyad<4wU`X{pLxx@K5ZUoe=g1 zZ9ks%J8V_@C@DnNe9J~<|CVfaR`5LGjoGG*y9Hlhd`xlPIvixdjyKYqC3j(9n|O$C zUP^tVdRZ5}yTkEg1tYnNbpb#}-xHsRWtmqB<1v?e5{xi0*%h`UwZTfSo`BdgWUK+1 z2qbUKK}Nq>pm-+JsbemenemDy2MHXp`UgSs5M{5L-C76P_S`)f=h?YuRrZ52@$Trs zZdW^OrY+C1`*8NSEPLM^|K=~r$Dnx~rAy+QFaKA9pok>sov z+?JzcqOH0?y;MpV(}x;|1P2^-ej8ngL{xP_j7FGfaF+DCw!dG)j`(v@b6RnKA8~*Z zIvmuN{d7Kq^l-74!OqO%Cu_aDUp6yidW1}of0oOOoK{H7e#&CAcMoqnEkRb!%m`)( z$#=vRtD?`tlIFrVQGzoi&aF^ef&bn_7gK|@+2ga4p@NVpCO_+hQz|N&A$ZtDVOj=< z?6E0nVL7FQQw|qitI1fh;xcY|#@+1PhUu!hCeiu3YMo$uDw_?pM_NY7V~j}r(BZUw zCw7wyD^|r$uU&q;5U1EUGy5u|rPKUM{wX;%wN^q`XaHhw;mFiBB?Vqi-{InW9UpyL z0sgBWI5#Zl+oqH#g(I0ZT?&A-UvsQ~( z?Go&SZVsRgyEg`!^6D&IP6ohnNcqpM^BQAj9AQLQK0BNv?Vc5eDZyR?ME?dRs%uFW zLk&7L1>$2FW-|cFCC+lkBsNb;&w*WHcO(x}*48j%D66if!(z>7^aLspkyo#V4B2?n zZu7+L4T60sf(%Pqf|KK>kjUHjUrva|h2T-dF5NJg4i#eW-X6*4YwtfIABYj3pq{P5_5V;1 zvHfjdz~8!C|NA)U{g+nw*!~8P{Ko|mBP-|MVT(z1Yuow1V2e5e;J)2^k8@UvER|?q z4*_V&R@8io@!uJP+rRrpUT)zmzxrrsd=?|)buD+l6%+u8JSS8ap4={jt*BF&)h&d+;o}VI zVGxIEhAP1kVB(z5YQ#h2#T*)-zDVMpz41sA0J1mxzg5f!B~W-!VXy78DGHhKFdn$JV=;c3 z!v&xc^{MWx+ zeAJMy{Em;!rTDvT-Yq5>_z)O8EezPiKvag+J_#)bndAX{b@pegaxaqjpkkxhU-m6Vx zi$HpCCuv6s%&~p$^lbW)j{ha`!+#_^Z8zN{C?r+A5abY?XO4uhE+NVlGoQrU-;zA71Nr&1M zo`!9KUYep8M}5R4RpO!A$~j;jIl~$x&#DJiz6$?XsjR0r;<6sAasFCd*DVdK(Bl(2 zo$hJ|y0cz)c<+OAFZx}=NVVgR*41L-afQtN9j3c39+_PkFCx8*wOtSUy8s3{CH0>l zV6t5dNf0gOyAgURFpcAdnKj@%<4kse>06!bd$;dNBm5JXg zE6T;#T085kjo{tlGYNl~q3ijOAZd1f$|dA)x+VqwjU&rmx zsFnT4Q;Yr-e1*55vT%7TT)!%mPq05B8Z#Sys9K4w9OlKJ6+PVc=(Ok0=Mpgb5Zp5J{zp|R1blHr%oK8ftag-$tFs0I60hYB?hE`1>^YH#`vzN1Gu-L z!-vRFFd5Jz65SM&b8CbS8KFc7nSnRs$Ga$Z1gSldbwVu>u+7rQGsvR=(PNoBG)g-1 zVIItKADXQWpmL@OUmL$p^x7Y;QKrZ?!n^#rI2qnagIZf8?R8$FimO1HT}d#3RCTT!#VX;x4Qe8g$Qlz;)CUe}iBb}vG(Xier8Sj#_I2ON{$xkcM*!(d3@M;lNN#w&+!=d3 zR$Nmv$?OKxH-VrS|Dt8u{H6<^kluV5PcuO5(|$BX4#B-4}32%TUYGsbKm+}(_@yl zeWUo|Q^n;A^Op-!*6BPK-Ka#&`L|~T)`0FFfig~D`)|S?%fSSzEM^Bu$)GdN0!|Pq z=UUQx0g9oGZZ4*<)m03+z}@Gsz^f}suCxsPJ+Z9>?2bfwcfu$7n_(vGzvb!uoAK+gjnB|s2uVn~QqCkl!Sq52zaM_Qu7hp{`3n^bCGApIhZ z<2HQnn3dkKc+MGNG9k9dn@f+R!h=GMp_eC6m*JwZ5>{nk%XWem%yZmgVjQR2ClsW3g9LJc|W#=YVvn9m;JqX7=Wh~4E z)vW}z5SnnKumfjo=wR|htFozZg)DvTfxe6gPBGXT80p548W{G*!q7B-E2+#BCSwE+ zVX%ef)#x*)c<5LvLeW{>R|bJ=f<}V=E*1u@34kZ2B_4}4-&@Vkl*kLB69t#Ga2DEj zu9Z!Bkr`m)O$}Tn)M?2*Km`{ng#&tEWd2QKT{1Kw6vCC)KT%7Q2bXI>6i?5v=BJFPTn8kx^LPb7gt6YwRQ1wOD`(#&Rddo2|z4 ze6z+v(=9FRsz)YkA*X{kxy$}qa=kY1=8ZBmJ3O!9+1{hxndKF!OVG_3xjXQ@$%2?I zDr`#4>|VFRMoOgNoyLA|M4yR7@yoESmKVF8U}tx~#*FwILvMfC4@qgi+tu zzSacDSp5(_mz97K4vzHmo*c12ywGc=xG<-o1enxbwm9_o;aki9vB&M%U}D`Fgl`m(V^)3tDU6R>1oU*2?Nj5+q+JTP(0yoX)mSq_}xbNYI0Zo_MK z^vXux{kZw?OR+foF+-42E{HzUe4W9kdOhb=o}Zg{IP!)fDwt%y8|iLQC^~fSCW<^! z*5JGqiz0*SFL7TVu~LmybaeoSCo#^L4l}eJ)=+mG;-{r>y%;r7*Ys)+0TQUScIbTV z5rZBBd_f-l>tN;yQ-S&-8rwI&h=71xCfRUpdeL^x&DubzZGRA(Z2h4>FeL`Os9=qdvCQm zw+P72RID1CoD(0SC_iJ6hWGj}QT1s8(X03e#QKeh24YrR1OJ=>`wsQ_;GC)l7SeuS zehglLwR4(a*eb3MD~P8Z&tD(YU}mzIwkZNqaDo?G(!ydq!nN7?JxVG7bwTL?Tbxjw zv69lct?IwiKO0)%0utduUrktZWE{6+?CN4;nK-<1Y}V@9$b`suGn&giM%el60*~VZ zW3rr4ICfh9l$2RMl@T=On#;*a(9*`5ot_2ihXlswTcaQw`PqiX{f zB!ZmI>^@O6!_R(VHzXg9$dAyvV6oSuWU`R7WF5Fi*mxt2=z~DXF+FWF2gQb(1ahLu z`(W3^fs9t-DZ$`A+fNh$8CPRZ zSF?d=qAwLwlJ~Q~kTGev{b_xFewx^i+xrFB2|@+8?DV%jwpY&4`k}Us#MeuxNh*JT z9FT8Zbrs~ zf0r%v9aficOdo(pu;WmmhdgLtWGZ&>N_p=k=S!*igN z+vS-9fWdtmyyfJ&&SHb3;T&R*6SOCFY9=^*Sp2LdKPWDk65!HsKwoxc&;{tg2w&{bf%gyY`q`r1ARu!ED({ zXu2Jp+eAuoi>5Q1CEV}u3^LIJTOOMC$foj$rBlsKLT`vE##L9YITAL7d~5thUS7AtP4jB8Z4* znpuMdiCs1+s|p)hgOP@4@}#gcc5zvMn97B*AkuF921RaD80Cm_yQ8y`NQeHG zHY}r(*1}ARayp%ZW}CLU4we9*Nw>g~s(JvD-WFJtxLCt_cHhwdM4J+`yd-yA#^n7=tIyRN4(LdP35kiKD&S`$bT>w|FnFk*umk2t!t^-tC(M90qZWGD z*r*9UJ6DnUAz>9&1x*-LxStTXjF-(b;&eU4W*4`oVoSOC^Lct!ASAD9Ju72mo(%Mx z41xg-(KN$+@_|FrFuYvrL^`J@!J0GADiEj@#82=Mz_me|bUz-`(yzg1sHN3nE6oX< zK8yp({DYvz zXV&z7UtQOCUGMezXPMu1ulu>5`?*igGi&apq8Bq^jGNQF>ZPZ(6e=q89-dg<)37r5 z^`qDz?Ry+USC``#%hJJH=bW(KPU9DkokMTbH#Kz+XTEH*-t7#&H-D6EW%}lpx8j`*>z6vfw5@6a>3{n2;4|J>tk z;hbT5b=+1P@xpWT8FODe%(~un;5}zZ-mk`U&9vLTbsfpax5drgDZ4NHct%COa@!Xf zrPkE>R%@9->oU47Ydo7-3OBQkSTDmmH z9{hY5=XJMdiC+ZA$%Q z>+70#v~JnphP?6VSZR+_Z=uubyVY&SqI64&_r!)Lzwlp}x#WnVjCj79=96Jh*S=jU zhn^KE#Ln!I+hruTVUP3`$TVrP1w)LRCpAdRH&obAp)_Igr=i-sdskg}VF!3oinH1$ zH>Mo(Y={YwWQu)I@;|3PXHg~Z=%90|TCCp*Z^=6xZ@)7oYtXu)gg<)JL36Qs^Jw?h z(!$58N!;U~6Bqh<22VY$v+9?FfemvXYYk_s83s`>wU@tyVbmd&SKnkBq~|ni~s}6JNYdNljbrZ=91-S*3Z` zL8tj#cMqb))>)GYC!DuDeXA((@ye|FW!KswiWs-tMtSHmMQ`V-%kiBC z50O7M&x(s+t+3Wo`?W@;*6rBkB_>vqw}vEk>-kIhd{oaWx%Zme@wVdq#+5~Hmadp6 zzjm9=g!YEIVeV>;NnxLA()(Y%nKSUVc=92Yhx&UXOLgPD?d=OE_G|7`4y|0YCmA)b ze0{dqGIm|rr&j%euKZ7t{ZW}Z_uORf*k>l@$DVtu*yvlV)m%ID?qS30iQsXESySE^ zYDS$d-|By;>iRsZ96x)tv{*u~x!cFXr|JN`)=b0^N;?{TLgKIdY+k2e>+FabAE|IB+s%{B3vya;BYPH(a@5Y zt-P*s=M~R}AMWo+qu=r+o+Ku!XLPyLhMLZq+Lu<(wyDm@iI;mg-l|_yYTP-{8=@*T zlKxIN`{H3G_JMSb%U-!+(2kr^UU{ijVyytF0j&Q`l;PV9pXoP(K9JuH2nPX5@xU8i)>wyL(4D@LDka$RZ{V+MOvI!D=XsjU48PyFvBgPj%owRj4~sRL z^EbGD96OkH17&Vtwl!BJosHaY^-|peKi#L}&-2-IxuZIIT(w$n(?`=^_pzBNk`)}c ziHS3k}}-oI1Ves4$1y9 zXKUmzYv5tYWtp@^(`J-iV~jD58B@z%|MJXae}yOGif|AA=+<)Xr95rAB3^LN*2dc5X|E?s6yM89)! zaiQ{+p4sbPdU7)1uqUHPx-!x@wj{9QPGaKo z{@i!f<>#-(ZEb^AWz^^He0TqY=i|!FrfNRgl7F>+rYjY-;@xjgFf%sowJnf8+nJ}e zqcZc{Di?=O%T!*zAG6$VoZs5W_0vwidmrAM5ju97bD~D@k4aZvDfTBgPQSQAX7lgfyUJ9P z{_5&J=jrvCz4E+v#HFh8SIf-Imsd(9UQKMAA}-w)we#aE$jh?A`qoo}TOLV0hOuQ) z=XRe@ohF~+;g-dE#66+K*5rwY7s$)TihZ52H7tr39dls6slogKv&b^$#O^lr9!R3N zOfKRgLp=TLI{hw#MJEi$w7wcf5-e;Jv#L8oik5_W1~wusE=iX2HFRSiY*}PG<@3h7 z*M{mhKJe8z9jEZi8~^(U;?B!{><+m#;AyHcsZANNtc&5bEnRM1o02reRddghQ&T;H zt~a-{pL)6706!{z9(?-rz=Z4Jr^Iy_{bO`Ew_>i@Jx)q^kueJ#6f7x!iWUX$xuyCM z%C0*#5Vg6>R8vM$&fy3fYLbt!swiA*6eY1~d0W`_{!$0!XhpM1<-YOzc35xel`*T_ zdAm|urFLEFqlsubs<3oP_bV;c2VRx%!IQner5|%Kl59i+ET(HVmS2@QEt@{c#wBqf z_WYzwbT+r{=9KQDqqfb|Jy8LOUBNh=P`EFYF%=c;1Twxl0@ z_i=Ak=n*I7r%jV|=`CNR{g0R=z9C{mwU=@IR~W6(@E-$r+LXNvsZY|tUqO=!p6^3? zbZ4BbUa%}`?$HU=I*T>WpXg+Z_ovM_ax^dQDK#*k?w|PLm7CO~r&o-}_S&7-w6DoJ z9%DYvWMOph7xC4q_*f(93wM(fDuUNM(+cvg?>QN1=n@iONS9#ZN-mX~>Yk?}^?N$~ z^QS(wy83)xyHlLnj6>^EYL-@B?>%5Q<5`ozZb;oh<8JbMJ+DUVd0$*_2FlNI$$s@B zE4bN6NyEi7E%A2AdkOYXieEtu{5appPT~}Zs*Diz)#K?owN4vfe`5Xlbs#L%f4Kj7 zZcI#WLFl#c(AV`mwt6TA#=GrWWDH$2MdzE+v9%XX-ZF#?mduMzacyUKH zEucb9^S1@N;};qZUW)UT7@X~YSC%!5v6vb=`zd4mL-uDeo#ou-pt+Oh->_f@FIceQMh7-IFn0X0#od?RD&>5T zs9(F{iOFh>wTUZL4)*7q*e>h4d%as~!x44WSDVdKEiPT>Ouu})R?@WB71n2IK+kta zSnusF)qJT8TTOm)g4t*Da(rm>%IJL`>q_J^*Y#W8sEq%x;ezq34-uZ%jchhPn=ThK zuvJB}QDy8eHBoI*hlfpv4zBZ*g{i&~2*(KA9sTzX;bB;%DGF$6} zwd`GTLOUv9O54itl!KRw{7jZuAC0)w6hk}qSKjux3HLVzei;+DxBTlL?_@7+SrPc1 z@Q#1?=^^HS;privzO6rX)QOM!($IEcsf z;RMo6eS^uKGW5mVfIx8NOJhg3W`Fzejm;=Y|LzYiP@6X@(kNU#*C-|HA^4x!b`Ka^pA7}mp zd`E55|5v_1*#TTmzz=X`jylWuQMNiisEJXmmvY@fgCWx3Xnd!k!GaGk|9b-(%s)E; zR>7x$1tf@o1QC!Rd=g-vWVhhu?2X?{3i@V_e9~|0jEvG5Ujov^fd~xJoxz2)GjJhS z3|vTY!9_sAfAg*#4Hb}}0uq!@@^dnb?)1!;LC|FhcpQH?OfWlvC({H!(4t`i1qdFf zpz)tiu%ijimuO7Bd_O0{=VXi*M+is=0SO@>A^0Re zCj*P*Hxe26GOz@yWeHTv5@??#&^`=8weOi;j>#y2T29)CT-RnV^tO#eTH3Y?%@I;?Wg zM083^djUh&sk5RSkn zzORgCOA0c=7O*s92XQpb^biPUK?K5rQJ8_j3m`-Tf;6<~reGgMrrH0QYI%UKd$1cP zK$Gjh2??U{XF_ugrNIu2RSu)36cWJkkOsZfai%o%&mV{(7z3ku&_*yABE66NqxlFh zpgRl^#h3`NJPI97I?ZT|{GW87(HP*zA_EEqBOsu-(HOWBA;XX`#(>FyO~Dwj2!^7h zLkiQO7>hD41Ys=Fj)du$FzMtJj763w!Who?GGUCs5D_{85K`_1(Tp@np?g7OBfVM} z1NK1CGX%pT>j6}Skgg|uFM^WoDugixP`(I;lSVt54#t@Lcsd$`U?zi%G8Bxo9tuWa zBKm`Y4ygAc5Q9av7X-ox;NC)GfHMWE{Xq!u73w??3>C2#1Y?q+N0=W@kl9`sBY^TL z7z1IE`A>+B!GOs~BaERaS-Ma#(Rna%oXnuYbU2F)G{P7QA;TsG1I8UJ+!GBRnq7ghVhFOT<^1ApB8e z2J6NUi6u-B)~IXFgi&gogqXmksrqB0IQh;eA^Dh0gsg)o80fS~#c-S~P=x7l7Flfw zVK@YnWgi7&;8dA$(pjl=2zWII6+I)#Pf&?NgAHWc@Y91{!41q9C83SM}s$O7-0W5)f zFED$`JYWbzsQv*k5&s1kL0xmOfq_KwFN9;%S^x$HO^v&tT4RaSYoLxG_ew(Zg<%kk zsTim_DfSG5eFV9;6uuV)ZK0?bNas{NgJPE&H^3U<)YuM+E12BV36H@-sXhaCSP(Ua z0SqDcdqVeuH~vuT1F$PYsW~3(&@h6k7X-tpaTipbEbZ!6YK)k2k z3rYrRjRbauERmSQ0P~>Q70@WTuN4}X0c=uaToA^ocFMppYHbUHv@c>C3>K))C}Utu zmdN^|5Kd5K0VRWo{ejAx+;$1cj3PLLYC|YS;3E8(5JB~G6xcmgKHym*d6ld!sQN>J ze^BqmV3FDkY>!3i5|Fq>>J5N_$V-_U1{hM;1H(`e`N)kH)iy8?imCGjDUX^%VGKt` zj~f)g=JGfJlV+!bN4aW}A~U@{m?h=HQ61mxz1 zvN1yg2nF>OhsAMcco0m2$@Fl8SPT}z#u1q9hBHt@@PaL0U-C#6$OhQjbHg~~z7gzW Y1B2KBLHwO0kO>SVJ$J6T?PBSF1M%mWX#fBK literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_release-notes.pdf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/doc/s132_nrf52_7.0.1_release-notes.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5d6a4b523e25182e2df72b8c87fd41fc4c97f955 GIT binary patch literal 85685 zcmdSAbC70Fx98hs+qP}nwvDH3qsz9r zKRb71?wz?aS7v;2<#$mii%T-FFtWo^93IUr!Ez8Y6FZvP!1D7mNm|>v0bH0Q?M&PN z;s7&8a{!Y(z`@eZikOpyTTsx|%>`g$59^g1r#|Jd#f;o@Pxq9mudSkVd4|a_4@!e8 zE{vq0qD)G`mNXt(g8$<9QE4!lFdmeI4GPXUnzgZ`bCLDEP8wV%YrzX7jo66JMJ``P zytrh1KWyX{tX~Kja}eS6o(nX{#LEt=u%M5H+G?cG1_th(-NHE?EQCCQ9N19<>GHUw z4aDt839*UAG&_pxts@NH>?W7MU8=}M`8>=EjY;$tU-Ak!&j6}sle3{`KCyO^mM)k= z#!d;)8wmf}DY|{MMT6Wx|MUN%N<*ZfT(e_W&4)ypDHQu4FPlX}~^$EJ&q)|Ek+tR`(c0h0@|FX-(7 zHLw1=5JD|ZlIhywvk1LO%XGrPRUz+GISFqE!n4-qI*49qT0M)I;WMhP8A~B0ucbyg`y~ULY+c;Vg+9X4J^NNc9dI_`2E&Xc=Qe*2mWO`z1wCr9o(VCc7lO#2kG z@qu~6)`7aTvodV|wcc-{uaYzfSb&51e;D20)IUbb@}I^k=IG!CaBy=a{>Ok-nbf_V z08GjzmH;MIfUBdsiy6T6uSF}nIGU*e+=%s<{u(_olRCi5jhIQs{%RZE!KSlqO=VdgpM(d#yg3qIqH8z>O*JW z(l3c*?;$oEnaK2LcD{V>)Egj;#RQ`H=Yv$}7Vj3_5ueQ)L090&|FeW&i z6lM*E8_KQuRrZNx3FWeB8%?ONhIbpZgvCag_aqyDt8u`&EwMtU@|$pRao%Zk29B#L zk5=WHRbcVeDm@Yz#{oC67M*EPSPy`$qlxlOrBeagYZIJ-BiUuZ>Y)Xrfd=0mV>BBg zzs;bTKXy5kYylJIGySB(39I3-(>PLD3ld5JWI-}CJtkTjxh9fug2y;@CdIVn%_k)ueN`{AU3d-UD!$`!xISGTe*}>#R!Ljo~30K z$kl4l%pR*g?PO!EbK4V3&){lUw!0WeY?=pv_Lf6yStaLzidA*A)^VZ8D+NG2vQ)5B zuW!}rvPwG1y2}z>L@T5CRhS0#j?>s!(TU~@h)m5#c3KuMrbO^Np<-wf)Xx?UY}e`% zE)=g|Ero+pR!4fM-qPRqq~wa_xZ|Px?t#&DA^#buauFqlA@;0Y8NF?zfs5YJtsz%N zT0W+JB%A>ljoFs!qL(v-!8?a8p)7;*$gf6@oDc41cNLU&_2GpA zF=D-1yT{8$H4`viDQGPglr&JWl9sL_JEJl|pFN`AJt*7h(nC?QkaM&33u8h?Nsvl@ zV@8Y&%M4^kB(`&l*lHxZeslK;fjhFI1Lw(nFKMU7-mdkrNi#(&QoD|Fb|prN($vW3 zFU#AT_@=Z&ESC_9&x{M^eq`=xNWBJN4i^dP(rYzOsmSrEMZ1R4Qn3#efHlGeA>Wk- z$9ESMPcX-KEuLc=YjFjrkSD{T$eSn|Uu!Zjk#PffObjVgc8%0kE}14P0#TesU{Lsy zftIR2y)sDI{k#wb3IeIFRwI)lar>4cVrSgoB2@g_!YVmK&LaU~;u-tOe39zAEuXp* zc-SGGkyK{m+VJt(xRUGuSdd9W`|O~>eva-Nz7NoOH-^hc&9xAVqcXycCfl(tYp6Ec z%{t5W_au()_d23WOiV6!-*PBUkK3jnG`UoYxpVh{gZT7f1*DP!J${CuF=F(tncf7J zDq%#lXN8*u)uS`(Z8$?9;bjIkPk9t6S!9_9T0o*+8m8{Y7egWTLil<6rPWWgOeasH zgqbT%Ju!m5y))%@y0)cm#NF#hqW7{jzMXimt!1R}dWx>YUpt?lZ91!G)J}Q{hKs$1 zo&vp=rCJ?J41_pbj%~y|0#lwO5Nj)ou}5CXXUNDH&s{`#0@K-~Gcy@U1zCr{Ydm^#Q-Iiaj5@josl1ZSBL)$ zp_|bDSMqQoLVsWX%goUcF>G!_k>$=*gX2|q&sS}}xl{6Hm|4H0 z`uh2$*JYH%CeW-xw`;%FNgj}o@cPb=Rj5l}{ zPmgvd+_S4aNRqn==aWJy>12N}OQF;H)QH^SSImNkNZ7i$hss;WuEPfN>QucWlGi46!*j?F#kL2>Pf4uw@!0SK0D{ouzt3)Lk5^#rry6MW^QZaxOsD-X?#;l=s|y$IfHbS)t7BWPqb zH|H=>VP%vT%sML0?Xf`z)%%3XO&+zV2`vw#1qtk#D6?O|TH8E*z#z`$5zkpF8K0iv z_k$n6%+8+9(GiPQxvX}u>CoII5Rz(oEQ;ZTt9~J^i>I<3R;oXc48{=I*vUYs>(XPLgG?VKpLl$Wug!4`(sxXi z3n_9ztoAG1-*)e#@_m-O-un4CGHYqbEnzPK%)risVf%-1;5VvzfA653#sFmoo##h_ zHntm^q|!a8%RO@7fRMOyM?Qy>ahK5CSmbo>`k$0Y(9`(T-_LF{j29Y9ESXN<6X!?s zaEZCiv#A{xk^H->41@;jH zgg_0jeMw=U}gC?Jg?Q+a@pcW^;^^0w@;~p4<{bn z>NzIzjiod zgVMmA;GNm1(aEjD&`1BJ3(g<8n7P9!`lO`&$BYE@$@=cSA5=3qGN6l2{qwcgm<9=4 z&;B1g2SOi(!eCO+M|1PndBk8@+G}azc>q0D%IqhHEv&jTs)d}|E#pd9k43I=c$wFdIWQdfnk|y7YH1Whb~?xgeU8u4y(a;7=jl9!GW0^4#6z`K z+O4|eg(9T-poS=Hs*~Q7c_IwR2Q3yRRt!W3p^jN6*b?0;vmN76j#)t&;_)bv_GCDs zwWu(gq)Bn6>3U57!dq@v$hhM(k7`7n^k$k_m_4ANsgxJ?Jw3^gh!co4gj5F#L$zcK zxcveP;RPFIZEQqia|Og$he0!U%PRO$sta(=t3;oi-#IoW^Cu%=?J+l35rt;;LNn(% zHT=Fdu5iMDKVjUw3L@(ep~$VI105ZT2OVyprX%|A@t}nL zPj-q2V>wF1-XzI~7Mnq{k8%+f4V(zfFZ+#w~p-4$t9h=w`nafJ+2SyPMBLqbV2s_5VvEOg50x(nt-E2JWNCG>IR?2Cy>>7jy` z^fp0FsjKvewH$-o6nJmV=!6?8k=6?E;zQ!`8{^XPc4WGuafC3N6=ZzL*xyPhya^L1 zTiI0=t1)9A$RcWdY9dgl`pg7kJIDm!?;aQ=B%Mm|7Er6x&UCh1b0d}`_oJvfo6G+8 zxIr_rDd!+3Ku?+nlzm0M%QPlgoZV6t zL@`FWvR~UU{osP@Pw~ve(o()q7KXAu6NsX%=y0`aiQqQr@5PyNlDafXq?Rgh;ykrH z+MVWTv1qHq?1L?vajXwmT1YCe1_CXpjSdpSH7jHycoeI{=*TJp@IWWY2`g2(c=z^y zjfgs!QNr3jMH?e-Jq{*G?iJ~Gg0YJw2E00qOD>6}ig*oykoS?cE?&1P^Y#^|8Q5Ov zIfaegrmnNP{oVsye^B<`p-ZVhHm1jIRkoaN5f*CjleLLqz(@3rXRMoaqFH}b5%iHg zBbPrmx7gi;x5T(E2%p23D;KZN3tBKJU|h)R+O3NXQD`qQ8%`1H3+(A+Nd8f%89qVACL>$1(lgweolj;jIQR){bQu#d+pMT3y3 z49|hXzG{zrL`%AFP74kZp0ZoidH{Ip(26+C_yV$z&}O7*4H~3mD0NY)VA<>HaeQ-{ zQq7lEYezhf&1a~UxdLIUb$lQZ2x6PkjN#d1P6E{>QvKW-Re$X&7M0^#x#f*eeFl|L zU%q}#W|zv0vFZ4Hr(?HBfu_cgEXTJjz(!@?SU34spB8q~sd&t1UmMi;O#xK8Ff~MD z!WBoieYa3dod7!pA=Ns)9yhNoltX#!*P{Jr!UaEwcPiKX~>N`elhz z>Df|yePZC1F&f0tHR>c^hmNKn2wz%e5#9;{#8=Gu1hH%n>#!nIy4SG=TSXn;FBZGP zecvTTM zOetpc_bn=Xs})`9q2ctjI*KfgQ-jBR*mzKJ^;dp>xXz4!MB68JbL(sRJU~TEOK%WS zy5LN+Gw3g<*-}aau_y3=YFA!nZ0j;`w^`ezF2DwL53NScjy)gVs@wU@G{BOQ$@O(+ zU($YPg<~9!B50XS5Jn#|$d#1Md|KWMv5^&0&(CGNw9zsVPK!{qT%yz5I2BS)47~z* z*+rZjIcmEYpujERT;q0Fg@;`!uqni@hVu%08gZ~Xg<&dKG&`N94wdV2b3NT6gGL7J z&)kU3p@|{ct}#)4cDuGuHfgfkM7*!*Gkf<4sBouZy`IU86AOws&EdGt0nb}dBncRb za@pFMlLv89KnSfji@s;JTlJVXKFf)dw}VC*@kbc-2b)+I_(hU{Q0}$y-Oig*aQ~WWzvCbq zQ_qG4t1!frP+zQ;ZoL!X63(~W%aUa0+`%;9G$9iDxq4cN&)F_IKN8<62wdxZ@*$8jdsM6&g!?o z$fxZ==GshVW}|6NTP(-P#{xL!$yxVhe&Km%QYevQn)_zH^Gd<5?QThhTTr`v?4Qug zp3KYROP{g6j;#IB!lYn{{SadRP%jkFDRt(LjSWg5`YGp@DX9f#GmZhNg%)Qstp4lm{)8>AYy@fr`=(FshYsFU&J8cohV^eJo*RpPtyw$ zU3Zqs|H`&3|CPu2UX6T1D!mHod%w>g}_NIQn80?po#6>>WSQfYr zaWi2;kRLV@sE$H6$9X!wj6GGrQUR~KiHdq|Tr9tMc_l3&p(aMm?~Iw8ONE*y+8FuD zy7nBSdai!QKD$F|#b|i}``9<6*gw4sjc*;V_x0NLAcy@2gbIH?6{|_3Tf6$UtUd%- zH_ba2X(u$2#c#d*)^k5sk+#}Y0@lU09(JDAK3$d)zoqeX(51AE!eJtFSG4!r!#US#Jb#RM( zKNc%a2UM;fOU*06x?taL_>^uqsTwgV=S6yu^nk;3U&Hb&6+j2IUaV!H=EO_)EsVRwvYsb_ThY9UxFZ!m zJ-@v9FYwdQCgCSxdSgfK$7-ut9)nvX7&_j9J6}G;E0oC9a~112;3nh_qSq!o0mr|(*Iv3o9(CEcm;~{BBjpr@a*z@(c#1m8+1D@8YJG-2g?gc3uC(3= zQ6`mp9Jv2WUq4Zah=Rqw0S@h(#>H^x0zM_{MMcs<@L6#8j|!v22=V(-2{FXkZ5XeM z&`=&67~%v`0uzc+3A3-XX6#UYccF_cjWpfg`Yuc~{75A6DOr5-$+O2WGrwSXqwTmt znsU$0R&jtvl^bOd~FC@&1wmihZYvPE%KdtQY zlPXbkMQ4zvKw9Y_5WG8PJL=q}yQ zj)#$73_DK5au%dRtTb+cMy$;6cE*m}j@4FabDld^Y=KmtfB|o3Ex3O81@Isf zEnl=5j5}YHKrt1(UlZ>jE>m7n*Tw#&e&^49G4lN)ynFh4FdhIsB4hf-o`V`@Ov2c& zi^tcN2y$yVWoNesHtxV`AQ(jv;kiWKOf2TF@3tDzeXDX-u#!(tX>2gwX+}Vy+e1CU z1AD7aO(DRm0;*d>t)8+0`s@_t@4>?D&t_9wJ<5Y=<`98eYzi7fYOvzBww?B+c8q3v zKTa(q+q3IUUv0wL!mI4hq*X{QA9ELzZtIHYi|^eK5R&eIG5>(v+qj(OnEUD+t*Yy` zi$%n%;n~BSjF8@Duqu}Y&pi9HohhFRBoEM?)A7S zTmSvv311FAwnSTy8NaOn45BfD-)QV8kImK-au=Pkxdmoc2Q6EO>g(u>Mwk@UubkAD z2@gk6a95xgKKW&eZ=zw@^X6n#lL1LG{YF>A^Fr$;Hdh^eV2MqXdC!8kzqOIgXwM>@n^aXaPc3*Iz#=blKqMdg4u2lbwSEkLms3kG>NbsDzOvMRA=+y*MC#6 z%1Q)aL0-ogJL~onxHha;_sY}gNDA7R(fL?8cE+#Xazw_PTAJqfOw63uwUqSpZ|0;y z4bwkl?&bZ{G0PeiP2a#nB9}KT$dkNa9Y?tuz5$Yox!i+8n+k zes6bwk9tIJtI3LY5@vYvuqC1w|7L+N0ZA0DZVhyJC=T1n*K`{PN*==zlsy?^nPdsF zO-7T_4gq4floGKD?6ighxGZfyVXrV>oTOeQdiRckR=@lE4Yfj&_~GAytHcGEDSnd` z<(2vg7T)S}5#jt+Iw(8IIfnA5VxSVa!$^hlpf}rl_P(MVSQ>7;{W$iix#4ik2(DfK-ddXX_m|e5Vqjhd7}CR`rB~WSa%oRdB!2w z@(L~^xP&L-U)_$!nJ>oW!T)z0VcCG^kErid|FDF;I{ApAGt%Yr_j>3L$}C^B4YCa!^BuxMmXVX?Eva8zK+Osu zRFheA^VU)R?jWgX%;_7!h{l@G9gZ*-{~g9UWAXkI-h~Fyvq%GmPQ%(u#?2nrpKo|k zifR7^<^H2{_zz0_pDtXM|Dl5TzagynKlb7NBhUD6DVL3n``>-IGrD@N%aWM>1x5=R z?+wZjx-tybCAB@+%&A<)#{A?+cdMzH=Z$G+rsQ!1Ki6*6p83j|lI@1&K`S?9Q64(o z6$5^5mIDN5@)<1qBAeIY)Ec*^<1?C{o0Zu1?oaqJxtf(fpf3AoL5+H{K7Sh-*?l|j ze+m}=^T>+qI)^mk!UuQu(-1q@PyO&=S8`_Xmq!X@8gC%S2iDu6x{%-!CN@XW}$cV>lxxdRA}n zrx;#1Sv$jSKr?6aceOKG3eDNX%OcC7kh?O;6~>A{Bd3&k%VuAjd^WA1K))d+y< zlxQMbqC->1GSFLE?oE-mk;?bJk~mPnz3%iIC$fAylwOQCC| z0>7+t-s93;%B>=t?oD~cyOU;|1n6b^$hMbB+6H8;iLX!eo|dPJ*gNKEn@PYA=c|J_nD}E*lH5gj_xHn7K8sgc*yP zD$e{FWitRn!=e~zitNJ3I?lTze5FHX2}0LuNR>%BBnzAy36YhYy>wVfl0#!Dc`-WlBzBt~vHqUI%@;*&V@EWCh!h*+bLpY;5%i zRX~jQ8QWaIq423H2~YSGpAl_Vi7vE4DnwFp_P}Aq$z%{_f#x}r&5bxgki`>2b{wMu zGM<-AObJeB0GHrVyWN*8)mwy@+MHdvy*fOKPaiU0?HZ;0Y=A%mUv7**fQ(?fB+0BE z2&_1vH!h7A zO%fr!j2sNHU-*R4f??1`|iOlUB zIQ9ek@^I`$IQ#Ii&Cl^FXmEMpVwD)cskR7V%FJP>0YDYv-cPFeZqLwpl0l>PL z*0(P8{iRVwpX5?Q)10_*TNSq*#i%08&r;Nz9Ja>3=}Xhlp-dI28f-j}rTast7d%JEOQx!i{Jy_jgVM(M z;g;;bQdKuypH>kaGi7KO?XWWtbZLmLr*iUG+c9ZkxQ7$e6vX4*OCkeH9SokP;J1)C zGuKN0`qN3pBIoZD=lBSx?nRpS_5qhG6gpcPTL@`uf2U^%F}(pw->g2>{c*Azmt0? zlroyI#{bAoZo!@KGUd5q%aOE(h^B5@9D23v&m*B^HXmS=^n{ zx_ps+h=q<*8)!Pqm80oS@JX9*i6G(aUC(sG*PKFMbVEeuAcak^x#xlp$<2WbdbZ6D zUAQ3DZu~y>Wft*nbG}Ak!q0)zHNBu1;j+QOPULP*^~@|lJE;DUtLPs8^024zeX!L; zw7;m(j}}|WZ=nMqko!`xfgp*0MD}}4sQdjIpO*FaP07M%-Kejb2a+4y1t%STUv$j#2!n9;(x6XvCs_SvM!V;nOHnVf zU3ud9R5+12diMI@U$a z+3%THv!%VX@1ygj-d29d)0+ zTZoopFr~%T_@kP?$eou`i5q6+#@k)vnvU{KHYHX^nWBgP?bfH0*SnF|=Q+OW;OzBY z089tpTZDNrIJbJx2T)mSMQDGK_SVbIetDWzo^Uo3|L!z}72Y?~p2-_-MHM98GMa}r zOo;j2h2P6GG9|w_j0G^2A!A;+iT?Qo8rPgCw8$NNR#4>7Zr2zgIG>4A&K0)s>8r$7 zWUeR)t3?+*bgo1-r)Bx~d@knMvU;H6g-}NtS(qRPAtr|PLPbsDni=5d(BitXZfM!0co_)I^`JZxY!;*ke zv!$@A^W+#;c$h_w6OKm~&&jRyz7p>~A<@2ywYWe=WDF!^;{TbYK6y zd~i)XuD&~zgR*E;E>7Qsik!D|qAL55iNi4}{(~gVhp2b+;E}ma|nRz?|&zZr^_4MEkV^dBY ze^>URf)1B)_@BLmg}BAXBRn22e5az@^d{hq0TBKSioKZhN;zh=zP z1-$}3WPrj}{xh4(0bgk%^3);bCoK2*FVje5#>nEx;NV0lwVrp44zPK{s`l=NTB9V6 zm#3_+7MgrCsICRdJgB5{;+wPyv~vWk!K$y);g`eN7&1qJZzk#~MLzBCbK3eG$rJlm_--FhYBsdQtzGMlc}sCgv<-)MAHX^j z+ZLkPq0+cJ8}N1w@41sFPbxP;we+&a{vN&mrFd3jv(L|$`|PkqIq);;kqy=7`CY-L zSjn-E{QU6xNvx~q-6hR%kFkES`{c025Ic+U8WG; zr@YtpZV7*EXxQs z;JDL);JG*~B6{u4hKn z0bWW=FK&J|v5CFjW?Lp?XTo<{w6(P7yUq7Qzh_V(=p}7_AK4GIAAfGmi5YtW{!k%f z2!C+x7N76UmP&sLM_=+O9p3m+XyiiE42g#VkrLMOJb!y*SC^q1UDnY=^lfI`Gxv3W zfoZ*0rm(B}C-TKJ#=Ps|1G2#VOYo;2xU0vJ#KvUdJ;xX_B>fY4!f7p=snHr!v3F+W z?&s&|9S~**I6<*%39o8upL5oHD<7J*LwW4zB(=bsx0S&8Ct$5AKY~XIs!$t{#Mm0m z+{XN$7p%di)x`7$EzmAiz~pkq=ouPxo%I*evkEBS>;nt6Jjm75xtK%;7AeP<$8A7# znx3uNW+;T$;_Pcpr=^+cpF-nlVS#t;?Dhk;=`tLtvaDxHCbl&D? zmPHHZMfYO=RsI6j0HO<42PjqtC~F{2ENftHP^B8zrJ@7tm}Uu;k5MpDS^tO?`?O1) zB@+*p*92c9L27{Ah?I+zvxAG7X8Y-elNHHUQqe>Z!ClB}i9F8|1|i}A2Ukq7Z;@JQ zJ&dt{;hA-AcCC*en$FK5E+%+HZuuKLi+_VbI0FIfAUBO!6G${MS}K{|O8{WqbW&JJ ziwVuHPp@MFUPzT)%AIjkp1;Az>SHI9uTOrvS{RoQ4M{4yBpZ+YhJ!tr$#N*7Nf&=v zA=mT9s{*AVlT(8FfVV*oFfUe2B$M-iAFqt#9hfGs1Q!^KfrVjE;VMqoPmktU;qY@x z;jKkq9k;iKDim!-1sTpmULeD3M!1?|g_4S5p9ZUNmZL|e@9~b6v99JA#kkVPW2o6E z{bJbFykZ51w-ue#kQmpwOQker8I`pcG~@jp7#-NK#;LO zhnzm_0^;1Ay3Cxdw$nm_^|0U!x$iJW--WRJD7w1v2DY>V_PES;RzCTo?C%Pnf8V(wV!&9Ei9mz@T-C2+S%75FoZk$A)kXU5(=)`i3hEwMhiH6Ars;5IASDKCxWw-a4>>p17z4 z-mByyAkWc3?`ucpq{K8==Xf3h390mrUQwW*PmhOJm=F;W6g0Qfik{xj`gKJ2XG9lWwxg5L1WM9eLT0Cp*ANe_2a zEYq3Gf~rQA1;c;=mTk}??2DJ|Ruj;t-m4*_YA1o%{2bGIA9sl$hjFCWXZFfQ((fk^ z>l0jp>$;1%^z<1Nn$FT_FrDwH7)(S96D+(f7^E#iFn0;=b3&$G2Zlp;cl8UpYCa!z zGP8OqW>}o9=bc+JyFy;w!W(u;=oT6%!oJg|Hwg>#jcRZq{l3p?&9vge03mr0eMR-+ zCj0%fVhUrq!K6xr@E#;xrl!BOlm2I!p4MeMXk?R1tT5C<47Ox_jcEtt)H+8_6$1Hw z*)`mYv#ZPfb);CN>*rMx+F1`yx0HOa645Q)$wyZ*gi!E4{bK@kr7VTNBFE*;@)}|} z8#)N5j;25lOcYMamV)tbwX`KIm_8cx6Rvfg6V0keoEuLKmbDgp7t^T_>#oCBT)lL! z8uz*2%P|2&MX~p9pte5Q3h`f{vNi?31WK)|u`Ut#(lH-D$l74iD2j$|%ct5$K1yOH zs}M3I60jTc}?(s1lEX zwXVS)?1;#}Dz{fx4CnO5Om^dkzx=Cf=lnmZza*S_dOu2BHK>pwI|+$890?l@q+wCP zf6XxumR>@QyIZN)$6P*oEmT~%j4ahUF})KQ3f*qGaxo~dPB&wzdgQFL(V-t zCn^fXEBA(;5?TfrK8ggdc^O=o5JYl&99qv2U=P0nUaB5f)@n1Kko&2ewXp8}!QBOI zD2{53gbFV7!0}VO@Sp4@CjIb#IF^A#cUv64)4Ubo;o@7p&Ybme!mSrd$hf4k-!CJX zdg6KM1wZ`CG}URT$OcQ}N|g&i9Kd|y)( zwPJm_vvvmM=j^^(dT{NQ9-@mkgQV$tJ$Z0(eNEWox;Xsx`|<$oM;Asvjk@1JLH#V( zS^=Y=Aw&^f{zLZw1K!_9rb?kA(qWkxm>)7)LHD*4vDGE3u zA=k{ssK#1`21y-24Z}c>FsAX+$l}T8m=DJdcIwwPh(g|}l zuZ_(IYO*gR;WFig|^ws?Vh|WjWd9IR}@}}W~v|uh_}R8bZunyy^E$C zB!vrx&>ogz48XLgL-0vcZ zu~-!t)vKdnp1Pl0Ra9Su@`iu@V`yB)ERPYqM_oz_EQJxbDs^5JvOzM15jc0ismjdV zgo~3I%3_-hCHGfp*n90#dq- z*iXJl7Ni}DvwToN>$5yBh9HuF^M8qsisp z>mn#~RWhu6qezqJQipkIWTZ!sue7O{RFShDfK@1kR1P~{6pd1vD8-;Prd_GAR;A~# z?0E3}#iPP~&lSJJ-TW1AaEZ&Wt8}E(t=jAG?Xt-s-cON=0kwjCc@kS8p0heTq(0eg z*6G?>=xCo4v#3Nt>mg~R@jMzATg$fMqp}p06IGkK?_0vs942znQs# zc(*;;m{-zOoYU}tNtXi%0~2xZKZ&yyTyYh)XR1zzg5iqft{IU?XYji{!tV_9+3kdu z#*?*_+0b@~Z zw{6+7T)S*@mu=g&ZQHhOyLQ>OZS1mb*Dky3oY!&tMD*>B*U{0@@&2qIU(B_>HD_k7 z$T>5|7_*D`c`c_dj_&L|$lf2#$8%D!aK`Vi>t~Tv!dnp*=rIZ#*T%F%t*LwM>oK+m z+R8fvS8AySCz$Li(bz)d=kNZy?VX)%Ts^PGcjr^DuYsi+@sX@AX_1nvSHoS;`*KGG z$f4boM(#m-7Llwx@2}T2s#kaXPM6gcYuTfsDm(`;rFx>bw?ml^w5m0-bX3tN31T6D zB7GyN(+~pUQuZ4~dY0Gr{*njpCv3H9NWpl@93#=qdaUwdc zPm!!)A7wU4q3sQOxt*u!CjAEJl=`YNEG9?FEkp6vhwgeD28BLARP~;Otexvn&O0kP z>=&aKn<*Bm2|@*pGPjrNy@;Egc`k;$b$=$gYg$mfdBy$W+^I<@TeGNyze23O=-9XU zS|~EbqZ#y8UfxrQNck?8ar#j6Vq0`^W>vF)BmYrxKcDw5-yV*f&rC`{F^3}8IXMsW zga72eVqq}h2L*I{9wx-5DR&9>V8 zc}pzpurbg<1|fEUeMyMjQKiA=D#Q7{W}@X0zs|U}eEj9%`>^|dHWdpBY|#kiS>vmd z3s23Itk&gA`SgMV%}qRfLcwn&5&nj;$eYDy;(FP(Hu!y>E%kUSZLi1qW;S zA)0(A7yhg6T<>rOCu8J+AGJ9*jMJYmiF#nJc19X*cH{07P?nn&qScTIbajFnWKE#l z&>Sw&7H>z`NS`s$e$ZsqY+Qx{G~v5!X2JI12GPIZ6`t01YhJ~9V<1}8XKU@c9RbCm zo^!p$lfd-K|Mkhy5uTSj%=9CEMQ$rkeEZ_hfb`fLEA{kzCVvc`u9w$~lxkn^v8SVT zER4*%PRvNRcXiq91G(0y3bh8LMdvyXA(jA{W<>cMzm5}VEeyx~k7^1;eUt*Q zIY|f@E$1GzqU0C(h<%`Acxq+B@tP!Nc}0S;eUp!;W4BI^?zWbe_4Kl;X)5m$yvG&N zlQd@a)^;bS?~_;giy2-WVhVL``gY5^icMMlthJ@n`LS1&m(imO+i1i-@cu!JkES?O5glRZGcF`PGut_?zHHPbR zNIvX#{ZhSOISwpL*2^af!a48=pKsa?#wb&l%bO!^ z+AnmWed-50ttBcAOkeKw(at}Tu1LWs;3S{*=4M*$-#Vo|n>49d|CYogir&SSojC8sF}) zl)pG_tsb(wxIPG6A)sJ;&^@Jw)0Q1;>+bHBb3{yawJBl?Z+VcC5UY_6|AY!N*({(-8~dDgd8UJPy6rK_wG|05v(`;t;cdifh@i>m8l<# zE|=#$#@peM54JUIONA(HE~$pqp)p7SrycjnT&tDEAd7ZVfU__1zJb^tICyk>cAdiQ znZ%g9_fZq>Wgy@-I%hG0HW^2RY(_hte5$D?pHK)T7RxTLxE7r%(oa&y@vic$DqQ%) zU=ogQ7a)P$u_AkiS@Z}H*vs~-@0j^l*&`#iN)(!KHg=r+uz&5G=$JZHGivX?ljx`>_+(OYS_aDGbIc1Sn z6+Y;frRL+(!UG57H2wPoYUK};u<=F=Q9g@b-VeMh+Mt{N^NBCRzr+3fog@F(!2K}% z=Wsu)OsxM%=c6;WW7eAyL$5!OJEi=vapI95N?frD$sJ~q&D(|H>>O(4tlU+rsM``c zPrIjhEKEZf3mY>4zPt+*AAIh5zDg{>5x-zs%wDfsG*HCL7ax2IZl4Ct_8p3nr;?i>yt;U7blw-> zI$SDz%wsN_uU(EW7vN}Xd`GsrPYXw-5>yyP@y^yow2jhB#7#_67L8TZ4K61o9^NL} zDeH--O+!RpCnOFVhfi=>g^d##P6AI5tr+80_blDcZ0^3@1(}09d)z5Kj#NchfgM!f zm`JKRf~ihp&?Qk-9Chsv1Gz*UqCe~|yNYsxU?MBS4h2%Ejuq<$MhiWd`V>S9Ul-bV zql6Y}{yf7NrGH4CJ-9iB{Vpf)OQ>*M!4IgAeRC-jpVYZ;+p=R z6OGLQF~kH^LFq-JhLn9Iv4EVQx+1mwNgP3bLcK>U!vqze``GIybORg)rtUzLadnKT z2Z&gxfa{XOk17PC1$yh1Qgd42DDOuBqKE<1)|31yP{W|jMOs|bg{T&pr0GE+!g-Gg zW20m~HCjQvDdx7)<(oqt|>NwToFv`10miWc~w z;AtuyX$7k7H1#Mbn*g#Hu}XoJEB(ou7WjZc2@^3#3FJJ-R<ow?T<_3E$sGX#cfQ^4m5=+YsnHv*__s^LEuZQE8B#?uZ17F-4C=(A0 zrxpqn2dRYo9QdXL!Beq5GI^FGBIxqJ4WTkcIq5PIU`V_^VCWT$ukDB3uAtx`LRl?J z7N4~VZxdQhDnP)A6hd98^BJUbM_K7I;B9l#rM00evrIgL2BZ&>aV@^**~O%HIl@$6b+1!5`|+61ttY48{&3>oW^u8D^U=- zgMd&Z+G*yA4vNtLvyu1R2@!_T2;+MRiE)ILMM9UBV`i~h7$7ic*pE+tK?P<$(Thb( z4$0y}u2z4zilf$e@zjR@a3F2_1tlq}!x8``j`1EJrxni$JV419OgNu|KLJUxosq5;&zHinQDfkoe=Re^}jFaw($wc9;ak>Evsp%@6|+w z-!(Cz2PeV-(+;O-WI$DxuGB?>(%|=Kd!Mo?`PAoH#^Q##>IN!$f1ZZcF>zHLP!HPl zxXA;~Hs~9C!RCRjlf6H;6!nsp_?lt&;^xasyLIHh)~U(_%tgP^+A98=l3@2P1f%AD zp)jnebJhBmjV$d%D5piq`lEK??Sr9JzgIE3^Pyth7+0;3j8Ja6jD-F&8kpCLz4g!M zkZP_z;<7N>DrmtF$pzx>o;Fc0X;!@3;!P{Ge+}M-4WqKBjzHP+2@v&7hueH%At67e zRMR5h?4t0$ci9yV4_K$(kX1UOMC$&D(ZtNUS?hWP7NaB1;X4I{f=tNU5)#=k?>4}{ ze%>L1bKb0|eJ6aG>A?XPz4jF7ai(PbwqJ&uk)82sOo$Dk#90o(bvY9nh&fZD$SZYF z1m<1Yq0Rj;5cqoQ>D<&|8&Za|ex>65wY=bDxb9kT&qZ>6v1GvY(NSB5(eu^}iu&9( zwLiZ9%rLl{$pA4ui=E+Nr4*W7Cdesc;i>A{g0Ba^9y0vFgd1zs#DMJ)3V1lVB5i*JW$T-SXC`kBG>_nhi;W7?8LxCC&)yH zevo^da{R~`gW+ifcLO|`&A}p?#qD#l;xu1+b>?Y%7Fef=L7wB3Z!{H$n>%d9tx@BXo3;iQN;<}?|vW4a)ZR% zCMBzuQk&1EnTG13CmPq#_D*+CN@P9!Aa9a#*^>azXe2fQ@xwmZ8E>0IQNxk{hdtg{ z_nG&)D-tqLPu%wMj+b1`Plq!?qk&q*T%AtekK1`kP=paO%EVsY=ZC2gJfBz9L#x}< zL(q?X5xEfZAf`a%Pb*n=AUerzWbQomnL)rjl;Vb3&jUHa90NGECi1ba+f`9=oUH{j*0{V~VqXmI8O5==czTaNw_+!}ypH-a z+JM=*tGM7oQO{AmKW|?H#CprC-^)MU9(;_qZi4-CGM|Guo3%Z;@C=Fn%%_t{C3;lORmlZy&R7;yhOt>D6?uvA06<(yL2WF<$Mdn@G=&`n$w`20~bUoiYI3Hq? zb*r$HAKhAWV)yJ=csw1|ZNCY#Xm;k!^~~L$T@s_r^9?b*A5*ghcXGQb?dEC8!kuf$ z(X6sP_T)4S58usH{@7X;)O4MvY~t-j4Cc=3w$|a_i=MKB6Mxwq=(t5eDZf!%=g-HU zE`hLcT!*7xa-(3>{t{k%a`xv~40RkAtPw0u7v zHnH4%0?NDaUI|xcZIRmaXtLMp+l_4L&0{K{+k9GIYk6R`Uv+n1o~FVWt3*oaU~tcN zlo)S5Z{dCqkUs{dm@^c0komNe-Lm+9d@l9(frP?1b~o>$uvhP<-x3CWE;jJ(pMol0 zH>a0UUuA2UU0gXVK;lljO4ixlcx z-r~zdx2tO>Fiq;U#a2?vwy#?)`!JASv#&LP>b|Pg!L-}c0(a@%<^8N80m!72hkF3V zJVBkw4fDl&pL%+5o*Yf6;K)SuBksfr0Lt;oRrR!`Hgyq%&3uP){lUi^wR?;F`k`T^ zx2Y~2n&i0b`qj`E_oq=-dqa%z4`T}&tN?m9hWMXRwQ(G3fU?g| zAG-j5&X&If9ON%U-`QjhJN5&Kt9xjzTLMFY_|tVo{5lFeMf}*IN(#z`BpWeb1@ET% zgBmYyo$~U^HM~O>uAV$QIjk}_D|gNpkU0W&eN|rE?^q8jaZCSA{{HU}O@AlF|3&im z{~V%;jrE_r%te~ttW+Y1-p8twhFXXCX?@(bjaKYy$>hSn_LZty)Zl+ei1GOW^8FrP zJ|TVlYWDQ7i6chP)Lb3^W46K#&dpuo2{x(Q;5v~$^NZ?_(0I!EYUts`@~ZAPpec~Z zAT(X?%kP%gWWzMqjbY|vuZXG|Jm)Ny;J&jidBL!vZwrxnuBkGI<|+uOxw6^03ul z9l#zuN$w|@V4R$0q&KbM4mWI!m4e|B z>FF}j6eMP>#q7nnP_&cSXY@~dvv#rm@2w_H)M(zoBi)g%iyT7qKw6*sT7_T5G!u1XK&L^V&spzlrC&4K^KP7czDH!JL zq@1OA{ctci@9iV)1$hCWIMIFz=H~qpbHNlV3Gsm+LsnFYH&qk`lGKSNCqXc-nsA)V z7S+Mz*l<5FW;q8`KSM-6LL_%ED)hfM3%gs1WR%V#)rr#xMN~iYP@<0yG0Yj%zSPIN zXKdow7u7*D%LW8U&r|aE`;8GGAvr1meERz&D%UN4mSaC~+HqeVsDRNz>NZY=Fs2|5 z+&qH3qlxX70OuAzx@+MiN`T`CQbBJ_%2#HwSdQ)vWS#|sq|!c3{x#!tq0}J2#W2HW z5Exq6gaDT>jgOiPj6W+cM$QX)7C|-cS9vAVs2B{g(4Cwx7r;m!!8joxjy<;s*Qmvy zJ+}QU8v+|bEJL>038e)2Z!-b`k^>NBtuYxu2MYt(xl>Y(6M%%3RwARoYEcw+bGBlR zV!S``-5~kbCz9|+G2LWFCrC=j-xj$#lZ1z?p#5RRM^t;Tm}WqL?M+XkeT8qgk&nwa zpqI#fQ-?;sKwQ5-taLvr1AK3u2HX!+90f$-HC`Z;(t*poP#+c@7E`bNBS8d)JtAwI z7l4HM&@}NJvCN4C2?m5bEd-Dxg$0tnuCXW1NM2UhFe0cC69Ic96Pzdl3~GTD2cQ~~ zQd(#fB#U!Van&3?F2WrBSHF41kEWT{C^7V@APc4VZ=;kOzWRjOP9X-gQLp34i1V8)cioItS^KF2ghQYi&Mx)3N@`)5h~ zoYLVp5Hopga4H)kTv${xlG9>1mm?V1jKVY_+=(sH4q{Mlfj!Vz13eKbEz$oVTB8p<6FcOfF8%n-l z`XN@!4Be$>SpXk@>=wmUV!vP*5#ES-hwT`8xkCbV5xQbVn6=h9X;vT*!oe>bd%?t) z8^UhY!)ICG7cy?+6HMjGUEV6R;K(U7vY}7=qr?`u6-#QHOz(}@gaiWGIUJdrVUEv( zX(8Y7k909`Etc+2N$pq)k~zCc$HDA<9XlpOdRELa{kvciDM<52NJL>{Q+^ZXgn=u` zCXqi>_AcE5A>A0tMuod+XK6kOJ1GtKi7SkVV~JsZa=)W>1xX3IDE%{Qws?tdXiI0c z&-+l(8TS*;53wcOU=wye~=XC)Zwc6`d^(M>KxAjt8R5}c(o(X7>|)w%%vS)$s$^`C_4?G_1XaTj_2JdD z63rYorohM25n+-U%!40(Van9IypEi=b;OQq#&fokBeFQD=^O%v7oFBL=t z&T?2|#Hc%#*3($_b{kLWPo$L*(M=L7ypN6sOzy^1745_!9GTp|+U2_g7sxc{>BRE3W5L@6sX3_VU1b2{s&EOJmwiBmN8i>~rH< z%l%Tau=-{}g$YbdISdvowZi3u0q@Qz4ecitco@HGz4hXRXb`|?8#pv}Z79kT2HEb9?*_|72E$)KnqEn_=WuEZ8ms4VVOkiRC9_RwZs4^+jl7 z*WBgG>5g?oMda?AtM`Gk{dWgu-!Ckq%|8PuL|bR`@2+jVFqA#J45JIxtHqPxYUHsW zbGQ;Wk@=yZOOj%;YK?CmQ_U~Ahx5VdH-2stabw_V!Sre1ba=TbVB2xEr~NMPZnrLniDDM~$YWguI3M`aZqoEGF35A`s}) z)m}ESXw3utQO;TU=fiHUEw+uhp-VWdVt9qPw94O%F0VYt)w!GaaCJgtgd@lwEUnP!AyJHItzA|F)R=bNf zv>E4WMI4IKxr-92jnBcl=BYM;_$mit438+DMw4`T`6)cnbjdIQfJNWttu+W!HfExDWIDyW>{l)Ijs*Q%wgnNS50( zQ>vWe*+;t;%(e=r+@wu^LQoxz*lcjPT|y@a|F4Pu^=aM&zM=^t>LCCpA08o0%GjB+(X>!bAczJVgdVPwA zZWNj!pSgfVu*RjDRHpcBleKAO;nueFwAQAcVxxU~yuR96thF&^BY7L|>mYnP22S%i zsCu*wbn2y*1*TFEaMH##kT?eRswbDxpO4t;m>^@9p@~QsVn}6IrC2`z7Jk2u`V0fd-P`<3$yV7W$+E^rY5M);(28K^^=RI(&s9Gb_~{s{Tplzs zzDn!f!ZS3j)@0CP42<*YCn)W17m{lkpQrarw)xr1XWFI8D$1()W!|O3kI*rpYw~u? zLqlZNrRuz1aqu?o8G8))UYz*K#462b)#Q6azyaf&C9Nm}2);s=CY59+ZyGU})etE~ zq_k$A#oJ>6v^+ThgOj8%VU;vX1yB zur|l)R#;Xx#u$)pYiB)jj1)^*QA>r*i#F_&zF6RMe2n8`h8|I?+aTQvAB_U` z7E&sw(~~t}1UG%ezq6&`Q8wpg9E5?D(4;}SZLcp^1mp@t5tlTfN37ocX)|~>egyGZ z+J+C+G4$dwQ=d^`~qF22)$2HYmS_6xF2JS8%E)2Rk+Eh9>5B(fL z2;JFU_FuWVF*PL{6&MKt(mIPQKL|3GhHvnP(IRIiIX4amC|wE4(?)HIXs_~^%cKoq z&y-r+2p6|fN(HC=54djU2oK|~uH>@r7X>@;7WfS`H@C(N0^i)t zVvTLHM)9Ur#PO=`agcaA$uJRoxK7R`R{8gdW2k&br*T!^OS(Q8!8^tDBs6ATan0Nx zPX~sM56@oDjGP_n)H<(7{up{GIuFh~jCs-PYriAwp7ylUOpk?e093xcZDL~aa#;$} zhrVt!?COL2vZ3m}msy@nbMD5`Zab+1FQ9MA7?ju_uy6rrr_wS+fjg20iJm*R1QdFB zz}J?jh1Q^J>O0+!zu;cpJ!$ZeTl*QS zj$H2A@b#H1R|UA|`vDyBc`04^2R~}TfHCss13zYuNilvdeU8H~HS*)4W4&6JmC{-F zI#YSMI<}(jyhryPIQOwUK?{vv$s>YC39hMKjA1H3$umLTDPAoFWDQMm^Qiv#P#hjL zM^7t4O`()2Vz%>5UFR&X*3HxoupXk<=+B&w1?QXh()1rPGKJ(~P##lTecV9}z%T}Y z+GC+Z{X9Zom4-@a#EujcejRjjU@=0k*?tBUk#gwzQ46BljP#P*j3Q74q!>zkSQE&X zE;`YP3!LcyE`=~Tv^+WBJ#c!BDG8FkS|blCQvmW{I7q4hkR_pVXo3=iJ_{4P5zGFd z!eTDcjYOaY&NK1&eZ1enKR!nTK`_pM(sM>J{5W9l3dsVQP>#eQY?9TYqo`avD73`> zVrSqUsp7bDM;MIpl*we49gk*C2NV1`>Ht>Dj6*^FL;%e&k{!Qqqe9)pp!}D>$4*e$ z2o5%r<3q7&eb<+V?++1GUYpXgT_B* z&&9!vuR%AJ#ob)hvX@k0xm%jfX`{TuUT_`1NfE zJ%tW+BwV6z9Uf-)Qu$Cucl3SWD1;r^E2+Uz%L?5lC8oJ&LESX@2Oj1kg3>WCp4$CB)))vzD^NxuR31m%7zPwON{lERs{k|7>GkgkrJ~QcO2(_ zz{G^<(lNJ$COzky@>$RT3NX$-Ru}0dSpQpWru8(78k$}c5Y*&Jy zcY(xT%U5U|V9v}!Q7bMHvkbbT^S9Xd&kZD8Vix`O1`lkcXq%i_U`r?TM=+K@`G-${ zR%`z@hT$C>>nf;@y+4|BP-Wj``OWBJ(q58_2v7Tyy%~}xG=$*#AkF9>6S4!fY5#uW zM>axIW(B*0wKAf=T>GcsHy@4SEBQ-l0bDpiOE`}F$;CI9@&8!VJ+aDDeN<<`G5DJ}Qwot39>M(Y5KE)c#h0ETNOrR(2Nu;?3KAc~J-^Eu zG@m3)Pm(ht2X<>jC^Wx7_<8wI2xOHso^eA&p1ZrSMIYTb zy@g;zn7Oq7BUHmMOKjN0gij25TmZ-bBLgOCw9Kf+N04GPeZ3O0AxwMm_;j69;xz0D z7g|~;s@Jn=ED|WH542ucc-(*PaEPpkkwt+C1~VEYYG^9s2LCS-p|OIXX}9ZIb38d^ zf=giD(D=GGJ{GFT^yR|26)uUJEMYK{$x)F`d`pK83Mn}o2}cR;;%JVulj;-?s{C=; z2;*Y`!pFV%p-D^nB0lK?{E3s#N>0qSrMxT{CaneXLZPEY_5lpB^kWxXZeEoIb(`&PUquGV{&x7VfB|ti*#+A zvN>gZt4t5d@Aod@QL^4`3Uehe>rUaRA?wKx%aR;%S~=T>n$@0#1)(+fGPdu+PV7b$wQwY* zlhtm6yX)4|ZDW>oyEjH-bG=1%?CN@box<9JSF^RHMSG2=8u@Z=akK8{WngvPNw=0V zp!P5mbJ6w-I>GvtT6ml7`B=l@q=!U;Ogh^h^`_|uEFi78l$M#%x~P?X{wn&FYK@K^N2E8&7r4FRmg ziGInfzDFtlBudLYQ-4n%+Bk_(rf(qaPy}I=^g5kOXy7*G=|y9MTRzU9tvTeyL;T=+ z%Q3s9S#HC!WB*`6YcOC&KHA&r%!A@`bsJX2$e8HTNY1?9rfga=n!2)}gdhL;!vA=O%n?Yi zkakd>8-G)7+E-#6U(Eq5yCq28uv>z{50dA4zu)Rn1tUc$5brihs>^t(cRk;H2fB_> zGA;uA^G_8O+n?22wk#(BxJB;_5@o~jH_8&U=^=!I2AJi!mx~LqusA$?T0h}-nCy3y z_D4^lWa-6gIl6Q7UOm{ZM6fkoHtApla6|Ph*u!=2crp<&2{OFEAPv~IPro6n-WclH zJ0Hu!jG1hxLRW&{@)&i9Dv(&s#lc_K?EbaJmY9=jKHT<@8`y5Wh}(ixRX@6gfiE{d zz$I!u@fpWz4$DFZA;Fu(-A6p>afbP)Ay5U}iBtwwJFx}p^~jHZA4j7f({K6YtxSn* zDxViCwrs9g6;=c^Tv#GC@Rm+hV>ZW`Vlv^c_|u~!OUSsEddBb8#U1Z;bMjcp5?-DS zz_0EO4{f8Mo<#UKd`OslSVY_0KJS(f3ycB}+vs{eQ{xxOVDu@1b0KZtJs zHO~{E&k8fVoW8{_a|?wQ`}py`|F#Zyw|>41>YR4RDk^hx+yNy6HJ5iZ<6GT=0`2fY zY+9-Kej5@rcQ9<`wnU)P_@ic>nQg!N3@@tg7xWy#r=QESenvl?mIzxOiV1Cl0h1qd zc3!F@4O!CtW;l+AZ<_`c&5ET^Pp7ay=%T4qE{UISz#U!(tjmid_}D&fdHfXVnY@3p znQ1MP6=foDkmn+AUqwy=$RakxX!n*MK;z>qj?0?|l;-FAp!U#KBE*70hS`$#6r@F= zm;{z(F4Q9gEV5%X`M`YfCDtj{HHZP?OHK3JTsc;y`0<@<5(&Yh!>5lsbVRT6#DSB~ zKIN7%)WX#QR5-W)Wh>4y(+eUpUj!MWt7u{>l9|wZl(I$Rp9V1|p*QOLvXPehOeLEYh;G;Nl zrnCG%ohvi_GZFzBqtwlHUpi~k-slo zv(hh^Loc9Kw4b@c063q7CgPR4;@76!mwUg@K!J!ondc3pH{(+SzPPb*kn}iSg^n6 zAb0fKK=hhQqK~MMZ}O@DkH%_+@%TOYpk)rG=Rz9;I0(hbSj;zX$5o`LSoz zs}}L!95DQYhT&fvIe+ik|3CI3F#N5VMf;x;ux0oMw()2Z{^!Sz&vlhd5+&tv+U4Wd=T?{8(NJRY zJSAdnF*TQi`2?**Qia)oW#Y~_P_Lm^ZhcTMQeIz_*`Mt*oepzPxflzLdbJl2j@PFF z)Z>uoH;`;4&#l;_V~0$x#lcwIX)c%@+Lk3RPVUzxZ?=gUlH&{f-!+q>UFq@qU&Op} z^+TCP$$9T`V2WSOFBbez?)X}zWJrh-!&;rdWhf;KcO-Q}-@UD(vF-~Q8wv3XQR9db z>g_@yQ75VZKo#(8RT8C8|*5+OI)t^vk6R^rNVeR z&IfhE`{;@YTPRJECM%5P7;Fw*agZ^{B#;Y;C{iFweLAzmH`4ZcLgJuHza-?FuTS!b z-P`3NWjfDROmA>g2x~cK!l9HE<%b7@1z43QNd+Xh48)kr5nDsZ?fiYzA;b$yk=yb^ zk=@FLv2>hIZpdtZCa=fo&wLUM0R#;y7ux|9HUbCp6_EK~r}ev#DMM?P2Ba{sLMQD{ zFJ4GdusvdQz9EJ1l9wy-=u^SpCh1LY-;n@W<{MuRd0c72WEWbue;tH z8^J?My;l2Kes-0Fy9MRj@u*2@R@Qm?O^42geGM(P?G*m$IR!L>pd%vlSrlpl^09ta zC#Wg?RB3A2?D1$)QpZZEWd}|>T&-^iW{A+fxuM1wZK_A5!qUpcXqM)Jnz3~@@W4B5 zVs^BgHDDMx(PI9R2^Lz&u6^~Y9_xY!UUTM+eRaK`@eVkHZ~yW?hbiMf5U~FvO#gEI z|2JX!Z$zd4PlA&19|(p2bx<;}G5oW`KU-rxW`hmZyQXH=5Xh)2#cM{>G!fb(-pIjR z4{e1C$Thiqol)6k$i=zjtC+`GJR<2(MpjD=Wb`>n>MV=^j@Y!jMn}8KAX!=6NW!^E zy{k>bTfz>u@_3698U%qm2(WU72Y1Az7 zP@;lJRUENzf6?dRLU7qOqv_S)X{z0lb>v~?VW#G@ch%>#P;6XG)xRM2AzIl~-NZeK z*uO|-nqgv|3}Q;Dh1<59AbO91jtM2RsA#-#_~uGgI9aG@gtL!$r5Ip-wZQk><)KEo zgW@l74{7J5JW>(+B$ID#59JIc`S^-&eGh8AuJH=82SaxZlp-|@+gge#}Pz zuW(VI9OhVhxcUtHtlumovue9C6Sjd6bm|VGK3Z$H&I#G`J!G;Ep^eo?g(VhO(u-`!ZL<<;_DJ?uuM1 zO~;l)MI=K)oW_@sq7VShr4F7R*MR5;%e@@5M<`O;zrabfgK>vGk6#hD8^uTz4J#(N zmL?%)7%`4~e?g99pfN23&~}#usFExfVl*ZB{W2w!hB=DLWf*-JrqX+@aC%hr@q7U! zJT%|hB(Mz3rp*2h3DF>mN=AggYk#kK6787Zq2J+GV2Fxpj$E~%d;CDn8<|B$2693P zw6Wl`!3|xi7`L~pb+{On${8c>9D!eJLd>M1s2Ka1|1d5)QZNZ}dBkM8Ae}5?%plJ? zo69%8fX!xS4s06TDQA#ekmjBm#O295ZZv8q!z_gk+>{~BV890t z8IJ%`H~Iru96f}F{I8`-3Zl=0E*lLaj}-F^eWp6?CzK+{RT$}jViPQrF|g)CbwEH0 z#F2$e^e?%ZjxI5~Vz_vp;Z8#ZNX@Y(HGnSmXBrcF6sSS=DpF4Q;C!P~H zd;PQw-&qU*5IOe{#Yo7W_EEL@8-#n(Sln*bSyXq(nl!NVf?QWlmq^o1#;Di|qZ4#? zI#;6P&l-8kq?Lme^-e*7oDMwW?@qQ7_7YeWXxF%K4rKa9H2aVeSUeJuoQ^=L*;NSq zk{m8FFr{2I6!~~58VKnN<6cuqsZCW01juTf`bBoQRdm@2QC+KkubvM=$tJ2Re;8KvPv5)I7kU@ zj)lMom>7nc%1^V%UL^66b#p69=q*}vmp)i;Zt2bH=hDE2YB#vZzpuEmdUtKF>u5I@T(&R=zwPZGE+5Am zux`h~T$ymM!qj@6t@WeZn0{*q2d~VThB8Flk!xObpW_X_Z8h)TJQpm_*f^R0YNJ$} z6)=jTxuF!%yDM6!ky4Bg3MGjv%a3+9z+{sMCXsBEdI(#3UQ=k^UUF4oxrnO$mf%e; z9nWb=)3;cLCiKKaCL(9cm8h0#J)2G=td^@WN^rH6;os}9K&PXW(RzWL14A!W?I^(M zu=!SkkhjGe<(mydm_M6!edb3^j1xEPR!3hcI_3C4>j~X0aKfQ zKv+_3VM8<8x3~MuXBqmqNmL{^ce{>q9=Z3%TrVA&(ak8)mV80f_>9z z>%wUO*3rdjb8*^{8FP+90Zn0Yg8(R#N?jT7Yv7HpwFO^Ajw~yQHYG4wDT7BI7$R=8 z1W5>id!_u+zQq&XChq9WAc)-Zxngy|i1`5_D!8Te`piUh)y{Xl($?5J(2xQvDm|dM z^Fs-cPhV~NwlIj(;K^F4M1M#3ex^-9IPMeflZ;QMgT!+Wt zFtIgA^XIF-NPv1NjY%Ru_HeF5Mn69!|2Zs&0n;*Rbgn(F>l?`DG$jImI%a@#?^OMO zLlR&0pS%$eovX9%vV6AVCYUVyu14D2?S!+eIyB5_t}!O4!Z|u)TQ+jE6~3OH8vSaW zE}$X#+11>Xh3%-dC8x1w&)?x{` zXRgIXyGz4XXs*MB=Qo?>P1x;9;DOl1k^rkxA+zk9oHK7D#h zD@d)8<#h!*F{b!L7(qK^4=~)h?mry@@5Bhwc1lMJlfG4}nifNli=}dx7~55oTvP*} zf`D@CWds3ITfeO>ldrSj5K?QakWvL$rY!kR8-iRY>e?Q~RyKX|A#vJ)z4xr*U*Xe(yQ2Wxch-@eO|o$4j&uZ3ypB{9PJe`ml{2d_ zn_uBuA?OOnIG_$X?R=SAErcgOc2~(!QgTj}95~tGY6>sQ$R6M6xt9sBCGfS^;YTJ+ z1RY5wgGc`kb-R%9Ii}6nCRI5seO|DFQkCfVmFa8Y(O8*8_9&ig|@H)nMLA) zM3gRqC%98y(`z(F-9h&Y&~&v*6Vk|4 z+6G?J?&DB%DqIu)XYi;m`o!*M_s8q6X9H09uk$Op`w>NQg_%?Xd(On?HndTEnIL3+ zg8tdSks+7IP51SxGX*W>^>(Yw#cu4itG6LMw)ISjIl4QeE3$T~D+>EKqbxW36S46V z{5qmP0;*DtEumAXB00J20sPg2zoZ5gez~_aFu`?A?nDn`jEVph{4Q{}oK#D2H!lvlXFLsjLXPU>GfN+xa43l7 zW1n}tO(XCZAoL-Q14DXwPsj6Q0GS38ZKV?`9S6@m^mD@%Iixa$g?1zvalnjIaQofM zg`z=mn=n{Tq%=JlWU&wj+(*BN@bM#n(B(wb{eU>c2ShUs>lM=c6_Vkb#0HRj@xFlT zRzR9}yl(`tA|Wo{Rs;nD5nB;wUKYv8T#`4sYjh60N1EDOB!ov$IR20czbM2f!((n1 zJWl;Jiprb2d^Bz+jbh%^Hv&=Pa;X(uoSTjVv~L2oQAXTYPf}gQB873#@b=oePYkj>Rp@Q{RXg zu^w!>AOZ>^CM>2+6a%E;5Vr_@Mnm-gEJYxMQ&2eWkclrl#52jWdlweJX#?Z0USRv5 zeF(qfYl2!uhn4#mB%N)9b~3YJn!xEmL&kB`B!FE2qjw(EJS7f18Rj4{&~@bvBf!Ml zphq5I%{(jn0w*IK3~vBf#WYFfXnLW4kSEs1fsF$qLwj=xCd2zpQWzOcRf(dgBVylS zuWHV5ME8AcKsi|3ZHE)-rpJ@RE07o?fEL#O3XbDUhR^!z$^$mMVKHep?)W|H<`!AY zjrJ9|rmlev7~8DJ2a%-%52g5@e_M_&bVx#ychZ|y zn#vom0$wmTu1GeHoPr%jtgIOC2(Y`RNI-U2h4`o7b`%8z(O&?BTu`m<|3=+A09m$m z>w;<9c2?T9ZQHh8Y1_7KXI5rqrES}`Raw2yx!w1k?*8A6hj@LXW5?PNYsOkJV^8cD zbBqsIw0y~W{gWdkVhTf}4HgwxNf~|!9s9G4k1c0+TobkZ2{KqLxj1ToqO9zK+cRUq z@8xNN@y+B+=VwLb*G3QOf-OCvXDjkjAe+UnI7XS&pW%x2L)?C7vtM;1aC8X(P`(bH zaUUC}sID;`LSshu_qv2eP7yQpG?f5XoM@5HQ11M2<~|U08&gv`05yWGat1@hbrQej zklw@K#D5mukQL_|#_Afz`kKr_$iCC05BnM`I*o^P0syb4C*uS#jb#F+9b8NT_R3sH zLG;QWn%yzPFA=3hL6ysW$@>HsI+^;gCS&+P)-@h8NQ9J0gGhZKPoL%O;TR`n0bd}o zUTDk^7NhEFf9(sqJD>wuNXj5x?bHxJ^}2#YB*>(SG`YM%-AXPGLQ|TGr_Z3V5gF9P zHEg_zwiMWkRUHxvxUiH24yraWps@>wrR82UhBK}kSt z@JEPtOiy9)QmPk_m{W!h06Wn6RAC(GY!YR%&g5!Bf5rJoBEpOCV-dx|G=fF-Q&Ls{ z0Q}$!GnZ8fx7aABG_AZ)8Ui~SW|fFT5z{2K#UDMwv5pd^Uh%|%7*@ifwlJiEt+-lX z95$R)j=WMvV~i^rMng>cYYuor)VOnXk;J=nMf3tnT9HUioWsWJXaW10jU6#C@eY$R z%&xj9fvt-`4FH$`P&mog#-!>b=>omklKaOh%b%>nB&@G8!97rm!9|v8)}^ZECLIje`5 zl$ISGP*h$gu6uG%*Sd!o5bhbu(N0k*tAwg`WubLDx>S?9a<*e#=<_vC**l_2p$K_}4Uz1+3P;{{ZJ^Ds8v86|-oA zku8(pK;?3gn@zAEayGz%8!6!JcB1KQ=ndelc36&xVPj8Yu|%%WINj{CE`(9hO0icm zS)oCvGLRpPvHi^5vX~Z)m3=sPEzIBG;7s_2VEse?7Q!z zh-|UlTD@Eu*KD2-6N4E3eL25P9dpoJ9#jaj) z;3B<#Zf&%nK&A0IS^0i#r$*@0gWCgR# zI6m1kiUKW<^ufykcDGlI%a`Le)>lLYJ(g0v8b?mU))RAGp4atB@pr?;dSMX0)%9T8 zdfQep1;#}eCOK5$ryO~dv)%wk?cfwCZ@Svf!A6JE4Z{g0EbxZ%&2j?=u2S2Soo~Cw z#-f^s8=}tIz=U4+Po3!Y*t|nzcDU)F_a$ZI8g-dc`+gFpoe4pIK41Rak$!qre|1&%URz4-S5dz( z{wnUE9cNe~I#$!V8m33!fn-3a?PxJ?GuG2lulCh=DzdkfarDrz>)a8RoTKMGJCd;a zvVCJn7s5P$gh#5|FE1Y24=@u6MF>Bq`Fc@wV3)to7{^aI*xyupQRQgZ8Io>kM{P<} zfDfUO@q*O2rM+5gPtZDj$Ysw1^8dNk(f~@+xUOMoOYye466USb`eDSpRibG1%jv2i z^O2{T=J~LOLyNNP7O~3f4U#JYczCF88kE@&jmBktK zM5svc&XUv;3Mr2zHQ~HYt2U-gvwb@9gFFq;4fCMHiclv8+qW0sVM{RN+gPa)1x9uaZAQFka~fCIBn6=)?txO5a6dyk zo_}(&@|@?_up9AHfJZAR9w0hK7nf#1aUwv+Paj{0iK%iXV*GS@x`ttp4*D6G(!TlP zAXBXQD%|Cx_Wtx5&_-%J*4%u?hfuhj9?9h-?gin08;I-qcIV+FhafQh@Px6;w-iGS zU$S=CD48rwy^G}cb4^2JLzsZaUg!)x=P2P(I`69_c;DhDy1xu5Qa^Nd)0I1&TH8$l zEhSD}UX;)xXm3DbfZ3A$u1jw)PC*z{AjsvVt(WiD%tN%nO!`B$3}-fXN~m*@&mr|M z`YF%Y7z7;zSHju!eebL{D?C#ppcA&5GjjtGd-@GEa{2EDf<4Y8z5^}-eLyQFf{x?_ z>(?^Ct$NMpOrm8ZgChh(neWi@l#YvpC4>pwpr}f&8DtPjm+rW{N)669%XWw#a$Y}P zPDLBRZh7bKwE|*VPl1;M2=KJ^N*;~#D)B&iz9)3yl+_^8@gJ&57*^%=Wp9bbk(G@r zapDx7xR9-`El~PUyfQ_XR+A#3D34KA72*XCCK%UC+5h|*9Q2Z(_!y6Ky;B%Jxtt5w#?;GQI{w) zOd;fLX^A3PV4gBlegQkByiWQgNy7ROWU`DcsMJto_7H3F)k zJ^UZx8RQbx>)uYd@NoJVS?L^*)ZM4AvfjQ`0JG0LA$gxzCAYu_cx#>s)-I9n)@<$g_v4X{+aiSqH60LxFGI0>y+^nE+``EV3S$;Ex-+BOY9iRsd z;v!P{EFe>^LK!LjPBl|V@T2x-+3;>hGWp<*dSh=#tBpkc?=g{ zX{$W6qWU2(ZXCs*Fiy>GVkO7{ee{Lo`O{;jtcvNkFymIW@J+zcd!c=$!wcy3ZvypS zL%5bG>4bGdw;jRvQzhr1DuI)vTQ6TfD|fXn2i_V-SWuY<%b1Tvf`PYsX>qKf;bw?h zco7B28it_|1yH>H5Pzyy%_(|ee!$&_dN)^I@8$#~K_W;uUGBFN?p0X+f)3MXNWHm! z3p1id9z-ITC$FlHmh*~#Ykm{Ps15)V^$cN;qAJeIjo7t-@wA&O2b~E=vljVu9-QV? zb50gp7<8$>X%@k!l)4QE+S!CYhhj>*1?tNUAFteWfa%Rwl_OXO!T2o1f^iydH)mMa za_@oPPS{U1EAE+XX=C;jf5lbng(Ll}ie$!6+?V(6noci}jr^U;ZSao#4jkp%h5lfy z*1nHtjhsv3eg30we-uZ3*z9UYrw=E;)(w|T-_F3K?_fNgP zV#>QFZ0Z(Y4fRd!U1zsl_?;jN@L@jV{^{Z+g-Y!mISX3zJ8g%5pggj+5Sb| z;~z=`|B?6jx7@`44sVP9XWrvqnq2%36+-{P-}rAQK$uw=|0$J_sh#txjlzHnVnQl%ES>DSeMhR@2us# zzZao;oq}@%_qq&wtfSxJ z>>nhAE5*MMNo`gINrZwxLhj*{Qh7t|lkGQOpmGf&p4jzJmEIM)|3 z%xGR?%*{Qx6Kb)dOd1x#oQX^uz&1F#GV=*GFdxHNCMAeeNF&G(T9Q6jamzd5Tf=ns}b#4cfTf>2slU{+pZ zGmx+LG4GTm8ul?SsGQS@66wfREDrs+qxhnu#k&#+!2G(Mvs6hOsj!)>5b9AHrcb!A ztZ+nFZZ<=!Bxhe$gphNuVy#7?dC_aB;`TDheUWiFjit#OG}7yEfymAHgh+ZgW|eD{ z?N~e;LbDOK0^F_!ZkC{SmFx9hgw!3Zfc`)Ul*WU{+>)vqd!*Ccm~cjeWytSR6cxB| zu~d_k0tY^pxn&Eg$xu}eZ)s7-0Hy^T}I9b(Xm1ie^>vE^MZpt3~nLU%;}= zxFo^0i|~tyY<~?P`#BtfVM0a)spQrf$EX-!F!}-AJkh*UuaWw4A{Npl!OaxVBtdY! zU6>hv&1i zcnRdkcNz7ujV6;39)HDx3l+b1UsO~HV<~dERuW|4Cq`VI!FwAmKahsuJcq&dUbh6p zCajbwL`i2d)=n8N6ee}!vCat5Zc@o}xz@FFJDdg`m$=5`uu0$lmXj4G9G1`C)Caa8 z90s4kro0v9QZYNa6^HX}+;Q4vnordSzcZXTHWL8I+gfiG##NFN6%kR|&@u$ECT?*l zEF~0Q?cz#@iG94PAT9=!3E6y?AcU2Qw2s#WgThvW8FS*UcGdu-U@?BxrYouDoA85{ z=TJ!_^UBzflcLxEed#nrhi0n65^xIe+4AAi3iXt88>n{Q2J1+4G~*(`ODz zn$x0LjKl3qvg$cR4f|Q6S!_n&XHU-fqiw4^uljEy?)x9;bZ5_YI<3}kdKzPOI0z*e z3PsmrZQh&xEk@bxWZzzHjt@$Eo>?HpP-%(S5>1!R8VU}!4 zKvV>p;e=;f@YRWuTZ+1WC2D&^rIlA`2>&9?5BhCQGx~HCWZO^F|Lke3&epBXT7;kS z40Tyx4I7CFDRkdPCg(>~K-aX^9-0NhbLCM~!JbM<^~;Qdgz!06&}3~Ha{i{8*uTO^ z(7j~vb_}0h$o<2f!e`FEocEeLvfh2y#j2cE_()zeKUJX!w~D~U>+OYTo!|$p9pBRp@S5xGUjY1-< zYdgXSs<7B5dV^zxGk{|V>LE5c>*8E8*!CeY3OoTE=ldaOPLa^Kkq>WrK`sv+l^)0# zDsZk}_=91^&as;u0a!%XBfu@_5I+L0O&`6V90+|W5+181G(d1%-1dmYi!%X_Wlq+% z#ro#ZyaQ=mf-2OVD51z1hTvvL@B5eM!*A$~L+EXWj+x1DV@6o=O_@EPd0&4+p|=IG2)IHnetSJ{fa^D03KFkY#*}Y5 zGcC@+$XN0ljsCMHY2h^dGisZrTgrI6XvIA^&S&&}D*eKyDfv7_la5bATl&qE6di9^ znbu*k@iBQpa~PW4tG+ShK#@;)ZLmXzlI|){H~hq+{ZLo{j@ObF;oWn$Zto78#cLqFB0Y--G=Gb7l zx2LyQb}1vWxmS0fwE=@}8{y^VdM6)Al#+N;^TvZ`&4|_Z8}rwbmCq2g!krBU_Z$2M z5L|NYyvULu%%R`x+{F&pr_xa>u~#yLEvWmLgvd77;9L<01BfUW3jDlr-+G z;^>s}Npi)FEb0d0O8P~-Mf=6l5<_}^Z_Tnt{>;irzP&w$a-T5H9l3zViN!MFCjQ`8 zYrd^P0yG-$6SA zc3Zq=nLgCFXU`9QC{B0dGo-!tZcpp#QnPw{Tk$)?{m=*Z_n?3U&*A=@f|2j-(-TcP z!6-lZB^capn6|MQx|#IGt@1Q60vOAbGLgN78EiDx(te9sRk(hQL;TuF@YuQa7E?9~ z>#032^)N%YvSAa<45F+AabJaIu40WD?q~Xg7^RT|iR}mOb1}@->lC6dX@|4mdHy^o zNS|o-O71rN@~SJ8{1iXRWU2INd2T8V?;U~PH$uqNK;e9V{iCG`n?p}(kGpP& z^m%;YS-liaA-Cf8{!4-e?WlfQ78qes;{X{H?hO6PIf8HT)lqTaBAP zNIs(r{~{9n2a)tYBEi3+tN(8*VE^lp;6H5IgjINX8B_ot4I)Nhx@6?o~7yuWg zrK_tWHv@x}y}5&lnZ2u-Grhfov#FJdiP48nj1&7A+fW7K0%HZyV6VPRsS=U^vdVP&FcXD4E1VWDT|B4S}QT%wT3JSTMUc&C>ob0WPQa&R1yXW zB2^{F<-fk=uZPkIZ9wzMv1o&=4EG=R3caD^&<7=ui3u0y(5nA>BYDO94lRr`tR+kk z6!97M;@65D+0&DcI5Q4&lP09Bp8_ccIh7HaycC|wciqe2!p3d&JBfFQzvw!JwaFT6?5HD}ngVY-wJ>nG zS4!?lD{aj=$E-D?Nr}!^Td=cmI>j*YMj{M#+8=D|^L>$QHsbllawTupCI}i#p2dPCDy)?A?`YAouSl6o7<`Uxv$-qfvgm;*yD&wx#2T}wGfj5o zB}ca9uBnY>iB%f-_&z1BH8Ty5u}Kuxu4y(~v1;QtoK{Qx=%52YRA~3qNNhj>7j^+v_^wr;&Rf%O0sD&z54N1qvuTVaR zjpz)>E;`tzL%0>_IC*?h70thd#gj*?5J|D?rU?@f^iSxTtp}<0RjUY@YIgnnm{Szf z^J^l8KUw?4V*tyrj`6yFW63SC7XkD@xvzRYcwu#ZLM4;Tq(JWIWgYO) z6*kY@U~LTQoG zR7cm1;4!)yR;M1b5(_nZ`zy1SIXgRtFvhRMwqKH#khWgkq!b_@rUBFoWir)g8Sh$XM(rC zWp|-%LkC@U?CIF-zLC&3X~*n_w9_ACle4!8z3gyB{tqr;S)i!ctnWxcn=Kc6vYRWZ zL@N#g2__6TaGaVHj?|4LZlIws7tLx{Uy8dc>3R6U+wQ7q`sKi z<_{t(OJCaPEM2sof^83W*}NP=gcIfXsXZg$gSCuoqb}eci>xJ=;g8l`Lv{dJJ~uce zuFJ?<>32V$#qV@&f;2k$IJ^J8SYi+xOy1B)mJ~ERIDRB+G0`1CX-z&64>=KX6`_0g zs^n$=Y=`F}P%q^zwm3f~s`A#;D1~`e)4_k44@P{lm$(L_x|#6S*uJ{8%76yJZtWZ7Rs81kOi7uaUL0?& zf^X4TjVp>STdn)>csbO2)k_T7i+3SEI(j~a6Y6psA2?3hY`=Bwel?)mXmU>x##pMW z(f!ihw9}gzDa&Orx{G7ANm%oeV?a$edd8p8$*-(&B zPkjn|S5%Zl?zy`B^tVOfL1wN$Zy3kZNnH#0{@^St+2L}K<#kM}_DG5g3S1YuNHw#Usr-16LGUq1K|qDbD&mq8j&DsDN(V zwK6+3=lkyPmuG^>57+0IHL!LDU8(QQCVyxNyzZ=kBN-_qHp>n4>Fa0wdHmZo^8o3; z*YnF0h(pE%ftmcHZHe-c}9G5<5Rn$iZuR-7mR z^Riv0$}C6dfE9_MG*kz)HBzd~Ep3NNOOzzeM9I*SnmfN(0kSdS#DZurD zQ-L~4X#Dh~BX7|=pKzsP$Pg3)q-p%uj?MV($#Loll_sPQUb^VZ40f|8_cw~`XMm7} z1VSuNlznn6k%iQI;K4&28T{W4dFp!E&^zZo*I|50YpP z2nnJK;74!5E0v8o!eV1IWs3XAo3M_7?fyP!Baic0L6G$1SvO8LB7E@1gSA#7=l)Si zY$CS)U>xx{NE>Zx_X@R${Ds6dnL0}pkvy5qrEjhpysCf%er+rBnQMscwY|<%lmww)AE{Q>WMZVWcF&y(r@g*`i zX2?0q*JOdE^oeEVA#e#ebZ!Akww2v+gsqF@=ZY)UX{4@M7f&{Hc2pV|po1nZk zYt*yHs;p%5pD78z>lrvfHehKyoInnpG>gt0)lrcsmk+9&skmOf7lVmUE+Hv40x!I) zGYj^Wfp;$OsSGxi7=N|TKn}@%be^z`aKzOG-nllHc}Z3hjP#E2MHMb(ZMx)AHhhB= z)j_2KKoAPrYLZw4saw@wu);DD_YrLL6bqNn&DD|)xRPFc0fdWQleuz*tDkYhn8f#|d28C9M{E_>P4~&VZvR2}xG3D#h#KQW*qKYH9 zS$4KrkIw|G%045ZYGo3cow|Q}K|$b=Y4TYQ?r6&r){MjOS$T9`Ls3Q5nJywI&5yFW zHZcfi*;;fqX~iZhGUfc?a+rE#{w%b?s@O%0+InGAx>><;EOkVy^ZOqO$DVj7ifvH2%(YbJvXSr z^KbQ1(X?K@*2AKJ$I9n3iC)xq{P$Ulb#Wlz=Ct|ICV;65#lXIL zp(ve4b5&-6Zoc`-lopa0$`npHa>Y^gq-S$Qw!fP zQ9Em#1bMeJwk9UJ2CQ6-m&|n$?9} z<0FH?lvy}SXop3=y@L#rD=FEh(qzA^MU@U#%1gc#NnU#tTwYHdeGXjeVTtZ->71O! zi1g73I{iK()?W_5W_<3J7Uai8y3ZgO(Iz%amu4NQA{rr~SvVk=rVdjDKV5ZFNUf-9 z0tw9|@)AN(KABR&{xbsVC6ER7V60(~Tie%AEjQ2l1oKs;jyt#6)9LfkL_j+^3-Vif zPNaz^>Vfrb_TGojrYB!sJ^Ag^ytgaQ7hj>CLF3@ax%ZtjPfwo0Vw2OAvv7XVc8IjH zeg1XhQ0NpFiIS!KrC*YvxI~jys*bXUkw!s;1>)yhoKmhC)w=2%DCE`B5+sNkTG$8L;e>FT|p+d%l2NVIJl_XTbQap~dBN zak@j@)F3wxSpr>k*r5#xU3$q5*x{(2mTh0x6uZ(2YwkHY)aRc-epQVFHzWNjQR;ih z&H6;dl`#VLiI*!UuIOoQ`Z7iZ0z+=Tg9g@NEWa(Uz$ZmK=Y}pk%vx{f@m~}VAUOyK z8*paEZZ>*eCQv&7FJZh+=CRiOg|l;OW_`a*1@(uaE5Rr*hhzO2c9K9xRM@#3BV~?Z zrf0F_Wu8f^@vQkFGjg?WRierwa##%tc*Zi@Yp}9993*3TKWo3Ftbz^-?Yf(6j*2D} z43DWe>9wM)1&|(dyyRzjZbqUnmL89ddG&mMXwhm+jD0>l+5X7Ut)sU$Zyp=Ee>Z1W zRRO_+%RAGh-8;r8ICO66>dC7m!u8Mk^m%&oZtTeO>V^JrF0a64Gxy^JI zB?)o+)?fl{5+e2qbd+^5(vDdk8oEg1_%Yn&y~`vz)jjZ z#zD7hPmDqJPVbSBjN#J^%HZBvHxJ_OjZcPl`&dh#OABz}r%OL8^y>YYyBEmyyT!e~hV3G}n$Fn16iEkF>8OBzW-PMZt9DTF2iq zbu{E==Ikn?mq%vBUT^DeO{U+FaPZUQGD=dce~Sk{9X=)sKHd{uPJQ)56ML6bKC^K1 zstLgCfNyh-tw`i$b>@m86@$octR4tcNJB1xmc#O-Jq&j76osQuCS$f&fV8^T-WZ$x?7xL~y|K?D3S!TA2=h2%?XTI|dNSrW zmE1Xdn^qxb=X!N7-DXxDDe6ms{1}i`7S?nP%yx4kl8h#Uk$I^i4486?^usz@I?ME#*Q*R( z9*cW^{P|Bx(HQ23q6-zJJQ(L#vF{xyN|IgL*8{Ka8Mxpti#MEk_&B-cxql8hdqc;Y zK@roIC}s*MCG!UzoNa-!2*Y_Z8(*Z7?dO(~X_Fmxt;1uSy8fgI22!i~rL(Km!h8o} zko@IVZGj8GOH!3jlre1y=Z|1hAaL~t^r3G2iv9>jhxZ4*eNK83LUgTegor;xux`Tw8fn_2%s8Tl{BH?y$Q1Cq-BSH78*jh>zLANgk1|1Mq# zGZ*9kO|{|Q&qM{*21(T6#GV%0rYB8nZg}xmJxks)V#z6kAtdNYO$R?S6}A>SkYn%` z*jUU60=GChEnPV@A55IQn;o?>!s5~!vW@Td%og zUg__AFJ8-YL-~jtP??xBYol6=rX3iC_MJ$gU|^008EK!=?Dkvx?zGzxX?9vVPAjQ7 z$~D%lGgx^;2C;%e(Etw=JO2{tbSr1u-L9CKz7I+EW>?F2dIT0lEi<|z#= zWhyG9s*y{+BzgMs2D99E7YMJEfJAg+sR;T3>UzSsOsHa{cA}R3Y<4gj#j#*vZ6Q%v zE%Sn&tSwZ!ZZWU?Z5x~=79!ellqmhC!ivtvb)Qqk5u35IF8v9}Bnkw6qWX?Uv?xc> zswfGJsf#7K5QnHYRAl?gxJK>4bH##h{gdV5=$J;F#N2b)(S5AmE<1OwD0f_GRZGY- z;&y>41@oeyd(#n9V!GDFvymtV3P7aoI4n8yfH9MQ8m5ZvAm?Nj#>4&2WtD@!hD zC@QPE<3N>X@e7FtwnYKNYxQ7EPqURo?BNIx++wg0!3U-H^3t==uD!-G`T61O7vRg$4^TZ+&yi@%9f!_Roi4VNJ%X_uLr>|Vu140Z%vm7J9q;@s z<|}ij26!h(Fqb(W%qi!FM@}9=jHINcLWOiBN)p$01u1Kpl?#zP)Q3?WnVX>-UBpTN z#~gdhG9jz07Afj-)Ne2^^rPMwq_EFLoDywN*C2*VQ9~MR^nSlkMmg7kq zf@zpUl{YkD%ReFLW=^m@tBg--1F_DQ!ATh|Vn{+$$D$<=#I6QL$eD%g<7cu~&r-G% zuuTGH!b`sM0BMyf_W&z~Dt9(x9-aA;Tony44V&_3cq7v#u5rqoWv-#(?*JOiT}_Jp z5AD4m@6&j$#9}>;y?(v9U!zuJjC&-7QP4&u`Jn=+^s2^gExTMykoq8~bbz&fD+g)v z3E+y6w>XnX#Pg{Wzq6M_F$buR#tFixNR7p0^>!vsb?+CHeC(gW*oAO zzIkspl}}G4+-}L_P-mm@qv@i$&B&{J!$ME1p>W7?3?yqZ##r>z`#P77VNGj;)r{Y8 zcWR}MIvd#BVgpWK`FG^^8_sm>5|8YOfCwcla*x+TlA@^{pOJZ0vo&Z^s=}$7GB( zvuL7jLc0#E*?t`$B*ycMsgQ8Jfqz(yqj~7*16ud^uw^u`yfo9~u?jyH;Xk(5b^iV< z0Rt!fvP%!~rm-q#aRS2orG-C5WCKA5qUv&lxVqX+4P*L~IXD6#^-~;VZ=26Ss9mo` zwby~9kn(1tYwM=LAZw@o*U&rhg(b&OnPzb>R_T#LbKX{}*#NuUl5GKl$f~IuJRM;{ zp5w=-ESi=8ofXkxQ{BjGiPmm{+iKPa9DU3C1FSg1@wfxE*hY%z^;qWziqeJ&)k~@F zgx(4PyUwLTanT=1EE2JhCW3RypVp$H)i@VxS96iR17@sw4IFvjQMPM{$SJ>*@IULx z5cV9C8hoFY#K(TM_J$d|SISXGA(R(y^V$&F^4&mdaTpI^Lz8CtMPcrot4M*~uy~9H z@9YD^H0J!XzM2>Hk)hjt!K_g30ujkiihBuyiI@D<=a+TE3%4h-ICs7j z(pT6|Fhh{ipO_i-ts~2>$?>Ec+Tj&5r0riEdvtah^S8ywHdyf# zMsH|@w%I|WnrLwing|w}R8+y-LuapH@DdryH8@GuLDwmA5;in$>iPA4NF~j7`|@ef zIr_%ginCOPESy*#%G=K0yauDFG0c&}p@V0SJ(tTZ|+TeoKWi;7g?zis{;4@6$;v)(CY9ifk zguIl*TPJWFGulx&$@CsI>YX&wm|(a$c1O`r<7YwvAWhSG#~xP!Y*1}GL>8Ii8>;6I zVx|n8tPv5445VBsy~kYgT&&eC%=H#)k5z!+nCof=5ucbu)bY1J)8k>zX2jCu6ZgRQ ztE>Rfw*d)+jvjlqTPv3<^V{)8o5WAXY|8^iM`eDkZN;nc$md^)YAFRXS(ZDPGzofA z)9v;41~YAu`j>OLcan2EstgPfZbm-~Wcmw{dmy{!_ne-weDq6V3vXbJu^Y{nOfFJ5 zu7d67K03E`&H6JS@8&vvoMU;R-TDQRYY#8SIj_+q#C-h%bK3OEHqDfX;G&&lM^k=B zk7_T)buoac3Aj>%h%hifbc50(Rvd{uGOxR7NXwkkS^hz{GWob0!=PITGxE#=+sx1op%~%ofT@an!IA;;?=ttCaz-@15<3{Ov( zgA)8fx+?e~_D4mH=Xcp<+89#MhlzmPkdMX*NTWs1i1Pp6jO1fbrUDb+M}pe^TFsqdOTC9wLPMu~Bk7{)zrMRhfhg2eIO-LbkqKCrgErySV%p z30(vQ8j2B!QtX56eeo)fhfF8Hy1MPtunl6%<+#9M;V{2BKb<9CRO=9&N~_M|;pj4b zEgxW3r-hOjt|j<|aPf1dLV&YR%MrhFg3Pa8RT~KQOErphYCCdK=1V@yqFk~o% z31C+D0x+wS>!ycwo_H~vTf8utnr_dLosThQFpm2+^{sNK za734F-nQ&2JtQxmJ1TISK~_qXYQ8(49Q#3;R6|={hy#oX?>no)mHE%9b1mT>R+7a0 zT?8M}VSSKpmH1)dTWqQC@k(@P&72Ry%^2nSN!E09P|>#qC@KsgY^AAQi&%p*L$WvI z>S$1f%s`qz*1Mya{;^k(lCOe2b z2((nClQJSUN|Hm9m*wi{7=@fb)QuAdA%O+f4uhjICPN%BtZI*xLJzf~W0mvsK@Ame z2%x{xm!*4%m@z^Nuvctg!e?;|@s#DkHPT#gd>RXL#P!ADg_N07WR&ix7auK*<`v}= zX=;Sf(05CSrFoIas5gRvC@l-)vT?AG+ASUFN9;P zYA0nf8Y#gBI2 zS7GdSCC8EgonRGmhH!`E_dg)KlRc227Sl@21+sZlVLvLXLY3yBgvf#Nm!9@XLx)Tb zRwTiBHdhru4*|~-KW7-@Y;`xyz`d?Y7|iNOjRm9^2~$4RB$Q$J;(1CH%#FaYnONOn&&D#ZUz?=;dX~hm24La!`XPn4-mI;q$)moGh%@1Qiij18Iz2eKo_7 zeWY`wUWPcEy$|B+irTmRK5qttWa>c4zdKOOu|{S*YZ)MFRnCSjG2OdR0~e=6C`8zW zq~dj$gS4spp0`dXRlTCE!tBqFJ!N9k3!J6tpt`fVGSko{hO+3l*`1XGFj%H{^3RP8p8G z%*HBpx@0UNlj}qwub2L7I*xNdEXzz%KrDB_;*#Lb%+&&sqeLo1UX_l)8$ku6-FyKX zAxJN2TSgk97Y$vsvK-uKvHyinn(aH1vJ4aq#t&^3%g|+{6PC+fP+rz4e(j*y=HJOl zaE?^ej>-z4FLc%st*R#&FiKdVX;8#ko8D>zD1WpPKm{xcP_zXs9A_q5@*%O@$Ek)a z4vvJC<7m}dh$gWqEJ%)1P*is{DX7V@C^T#!RMHZG`-m5QH9(83u^X{EW;2pwH-VNz zt9YwBW-;P$%3;B8ev_3-yXmv*PuWMR3Sp>wLK^qv_N^U(<^g z<9)ir!0}f4hL*-7Z=WsaKYcS1lpNkvCApPQRoVW7JUngZp^IXquBQEP%fW8V#d-Pi z#jD3pA}cHB>Ykm!dpk|f0OK&nLrjO@z3ggqg-{<7Mc5w>di2-*lSDkNhnYl_9>NCd z=8r3$qzi$X?5t$Dg(L+1w<>!MrG}topsz$R(9w6j?c^Vnj!~eV9}r*6cmv--A)@cH zuKGBCzIAx!zge*cN>*GY=qp{EoR5B#op~r&$ie0icq-YClibJ@oaKq;A;x^Js}dMd z9CADO+#|2?0C|ADulAW3`12AY^5`c+7GU4~6u##9?ojT#ljb48`RcauC^x4n+FOYG zb&}}82TUE0ZvZ>)P1eS<-6PN<_iJS&?dQX&LwD0Ysw9dfz&Eax$^5> z=1ES1auCm{M+zZA>NnW0!3zYSD0I(EItFiJ!wVHJdQ&LuW3k{Dm=_+Du)^WZ!n=<|(Lc(>E`8qHfZWmCCq1#Wsd^9>;|`(35Xwa$V+#Ba=Ma ziOvr>u`3?&jz3U3f%1B#|Hv%>;f?#~<(e_I8P>gLX}po*?K##^KMHvUBDmf;QzSs~ zd1t@`r>7r$GUc4lue@!X;EPMo;Z?IGKmaENiyUE*x=qpCa|t9cgtL7i=lre-6u{`u zCR)7blhA9m#Xl4B^q23V{&{lKI>*-e^*ED`7`*bU8^mklzHWh)LJK8V7K#8Ok|f&J zTWWz8-bw&TS-xEI1_ z1DE?!@ubB(K6PF_lMN6Xb5#Q#Z^xox619yXD1mOe9`Q^xl$kc|M{z_O6$4n72+q&F z&7 zp)fA4dS$O4#osyFox57V?Z$B8{;?W{njMcy$udJ)6h`z$SVa6dgf|&@#|qBs`s*yk zgSjT=9-hmRaNG|v7o`RN+CV4I!|~8bBEIp=z3=pL)>a$=m@YIOewyk0t`P6VSBLm> z7$FjqQDg69;_ZB4ZRq@Se<1vA>U*Ouor64Pd%49#boJ2r<@x>nJ_dj6t|XS990$Hc zj_7^$7$)a*9Y*w$v){v;u~S!0e!aLpk304*g`=0Wa;iGxsH)d`dTs;=zn__*P)Pe@ zU}<9tyf2?FBYtY43M@sdLcV`yeVRt~45mdjVmW5If&Fp)4Q2`2&pt=G2#_?hv(dGH zW6n?dSqCaGPE$9uvJk>j&V>*AS2yry$SZ}aE)fT!YOLpb=2ZZ5@rRq!1EQCPQilX<5OfPwlu5Kj*Fm=U5#=N%m+En1M)Z>Idca6iA077?z4xCC@~9W= zkpw#S*^~HJ)0ABq#3rDho;kbPk{u6^_`>KZ0!dSi62toQYjU2Ez^<^e7>Bq{?GnYF zOvxNRldsRlgnL6@d=K~M4HF6}{&9~m30$Ne>4_)FtO>~;#Xx*3lJ7IjpY;7(B5h9L z5b+P*_P-eLR|T~!7ALBk7bcdqW&wc( z-B!WLzFqdq2%n(l_Vn1$+m0j-1^+VNX}z~?ulOw(HajH(0s7TfNTn)L_^Y&1HP`K& zj2zL|K4q*ooM{Ra#VTr4+-n-S-+(Q1!186Qk@ScUURoj>wNWJG30#GEtcGv5b86mDnT03;x9E|*mftE|c8K;(n_8I%nh>TMwrjHKDu z2sKVE5CgOvPYlq~A~s}tCVbfhI&P3VqMJYhe^4-(3%6y7U2UZykS zOc6di1)w{}z1AX#>3PWt?nc~fv)B~Dmy}%q(Xbp6Y9_!=c1Yixh(q}IoV|a9-2__g zj&d<5gQZlhNFG~9->(6`(>Y)8m+Ul6*>`yIws3cK$372pMYo|gCs=Razt9vKhFQ=S z2Yo-iwYR8uO1xRi77Aju2-n;;d6)IE^%#WlwN=@wI%W9c1)bz{9IZ?a!rJf_=($&S z2P;kXVmq`8H3$x#z)wL8F<;)9)n z5U$3q@UNuW4rDhl74`}&-AH87SC z@3AIv;gB_%ThY7Yd2&hg%TlBn$yvZ8IoXy!FL)y#UE&fSW$y;=_YN0ly@3~+P{~`$r^FJgg|DK7+%)#W~a zy{xv~$Vbs?$bNoJ2_|3>2~*HE65Bup(#AlXv0bd;90;?Ugm-sidBS0{hVXegJ$CbP zc4Vpk1Kue&QWQIQ$iUoIYD)(OTUL{!-R+g6pMq`9It^{q*+xwX5{>kU8xr3xH%TE4 ziHZsoq~noUBuX48N*K%&_h-K|8JVigJT+|i9dK(}NY^1PMZGarb6LeEW0DWbSYBj+ z<}xuM+V<+ac?b)%0f9b`*A*8nL_zU-5rVE6ilLWGJ?#o> zmPbUjMEl~zLWXbCSH0nc*ySJnFq+^AFk;Zc7P;gOLoc()8a-VlSSytzxmS!tQJ^se zm^{T(N8{?W@h-E3x9X<49v5$**`J)O*qb?9MmbPX%I0>28ldbJnzeRh$wYPw)wxhe z6WUX@*e0&ld(@_LQ0>3j4_X0A2qtV&e>MYmb<|h@O|N;KZU#bBT7uVhrbAe5)M)h1hpZgPYwp+WcAmk{Fe_S$}HeJ)jKbK(WyDt>MBii%5Hece6H zXKC^}T6VB^jl@UQa>z%i@t*cC+WbF+LH|_-|CDZ;@{Q zK_dS5O`Vb9|3kWM($KQqY)9~3so6Dx9&8lfx|i3t9#W$(AArh=n)~n!IP{-d3B=h>^)a z!{|^_iDPm09(^t5Y5T%4dn-y9jc6197T(W`4Mo>O3*x#VNl`>ILU~=uOsO~U*mRGc z*l=gjF_?N!0ujh>kB1?~i~!TpME5QKIGw=_sd1UMmAw@99|64AN%^s!6s#M6Gin4N zTndOTM*AEHnubKWi8tJzDpuD-sL$OW0tR^{C92v@)doLY0GKA!u*M)Hr8UKF%KwY& z2Km&m@G{?1h)dSaP$;99KO?uOs)~9Rm&Ted?sS4yb)Q-l9ERGO%hb*MTgi@Lz3Rh= zZsCdWO!JfOFfM7>*N;VDKpJb!?9vwhl0;j5`UaaMfDZ<2+H^9OzW{?TpIY04%qW|< z*WEv8=3CnjVFkp`43{@45enQFI2yMFj!0~5&~Jp!G^r!aavm>#ybAG`OdIAz*(@9? zMQpFMHRDEDeGE{1Mp9TmHZylFsS+ALCg3<$We>kS_Lp60&W|yRLA!ZUCV$7VJ+W7$ zF@^9!Nm_=DN^X#EXPC%hV`IN3_EVU)V^URHfSc(v8S}-BZ|V5@w{(11r@uO8a8ySy zerRuW>xd9{>?d>mN-Q}h7Zk`*KoH_Ye$$=Z3@k0rdfz~x>0<0$uw%L7Yu#rVsoO5@ zImU%>AlMZMOpn{0@KC>C*ewGpF6dJ0g88Af7z|XI5N{Ft){!D{D)JJ55$>>QiWGu@ z;%qT<@0A0v1sN6<6rv;-FiEP|_XiZMSeh{)7rZS-gMYhmTMitj>40&gC%1%A^{G>}~yEMkir23QlWIzt5DoiXMpp@gb!5fJzTrWavG! z&YerFq(+~?l}Ny>BRBx^1jnKewH~IJjuV;AZ0=iiJ?45 z^;FHpiP_^uffB}(Z9JMOGZ6OkX^J~T%dU?2`}9u_b3^V82AKG6>Q;@QRv_eT&RnoY zWqR|7cpu#~uUvmO;su7$6P4)ZhWNA265%~_4V5>RYE)&fsTO_YsjMnJb>thZV|glC zt1&-nC9^E?TB}UIf(@e-NRWK}W}+XQ%U@3^S9H#Kx=H^v?RlWq8ia7hus1@R-mZ$# z&i=88x(j>Uvs!dhe}R6}?L9;5t2Ebe-xyF=QSUBV&}}W*Y~#>GUr8TH4V@o;eDLkJE<1U=KO^0F8Vi zrJg!neGCz9w3f7r%-a^{h|b&^j{S<&o7AJSace!9NeXKQAR{0xEuBLj6i}ra``F+_ zxAjx`CDhUfJ#Q{;Fst9QpQuiphp$&1FrR8YYarf_3o z5Dl_iq3B$;>DgQU^VYC&S~)v{hm}7dithKOjxP21vWK&;c{8a81$L9<=C?4|a1Ysq zYbDR$X*xPKeeb7+N*+BPZyoOUp6-v&7A|coHYTRN;pEfD*4FXW2anYKd#PPVEMgzL zZR(Mf!T?wh1-dkw&cjbngN;UIhYQKP>00ESl-L=mG5?7~iNH$$#8%1$n`fK6#Zdfy zUUx&V@pd0^b4Q)0BQE1pxwG*UT5gUewC;)SY`i|^V)M=FWvKIb+)dDsYion5@b*&J zBoul!e~0GrS0T;mps6KYzxQ18ngK=Ih!G*FA;JxoETFPCyq;nN!2@%N_tOYTnoG{I z9q7&!AV61P2Ja{ZcwFXaR`7OO8j=2?h=9jEqpi%4ejfv*T@9w`?|?nJqV-bFpqvmk zI5II1#(6gR#%}S6cxSJ4FRziS6Atgw+SGchKZerLC;2DV^@nAXE&dbPF2~$#&s24w22uh;CDowpMjb7kHrX)_8; zxd#O*u=_}oiusWJ5Kcz+am-J{># zcpewsW4j-~Cd&h3a87rxlKSwkT%iC>XKZ-rHyqF_`9|Xa7n`vzS3x#Wml~m8aCd7j zNGw}_=Kue*DVBdpD*S7z@_(YT_CK^tEPv^f6#wVKmRSBlD*X4;s_!`GfAaQ{{?pHS zvOwnuA04{deU(xp-^heSl7ND1?GY6UOaKA`f*!zJBxBuYuEge9dImI{dN%3Df%z6C;VG9T$*GiVZnS7d;15W_whb~!q-pC5QRf5kap z(u8||MK=uIb7!^WhC3cjXpFQTCW;{LKv1MM0 zkc5fzWOIa9-*3d@kYEhy5@V0yvrAIL^6Z7znL2L%k~n=S=L=m)1S6^6Nt~JV z$NoTGEkkBJL?I5Alm#wZtd;YkgJph8ETFAYB$&|sri@A2i93t)J#|HLJpjJd<>8rR zi%)4oV!T2kijbHI4AXq1PRJ-K+UK&Wl_`(TuM`LeS5&!{!TuI=XiN4!JRsK8B1fw{ zfoxJhK>!WQk6-Y$DmU;Qf5->U98ni0l+ueq#Gqg=Vfjlqz;YQTf3qUrThB%21e+ofJQ7DYxsho3(t zEwz$#07+D|wgsfcA~UuF+@_X3B{YV%5e>^k##Y3c|M3G7?7_>KJ&D!sWOZI`bXHA% z;rX(Sq$rrTwbJ$!xHc{&wx~udEb_0t*&|~sSYUx^v3?H{2Wrz?*5(#1Tv3VJp?Z&>CCn6X0MuDL~G5+EuX^V^x<@qZJ;5CnEXNg2X?jYt=c6-L#y1?tP=7x>*+ zTk*%83=suRhrVxN97`)M%VK>fOepNdRNi9k@v$G8*!reCyK!A}G|=!SWV}RDB3S9H zdWH}Ivc=DP@Cw8#c_1TOOd?FhaTE5&7Cb}IMzCiBNR#1RUboD;XprGe#5jqhSTKSj zZU5fyUk1}(04Dfp!y_qOxEp)o>lr(Cxu!wgIcO(lY}f{r-XR!{2Vubvn`>|wloL=aY@f zlv%#alDSxb}9 zACr`cqv_iJardzm;gqDwlRdzjeww$2^o}ZH1VX!lhULaD;1?B&z+0*f;PO*ej!T1T zFcC!kzs-x$3XR&!YEYUMQaB%5cB&{guLfU1*#XnIoTQFk2HI-}qB#)zmDzH%=zGx! zXC97mQYYCvwp>xl0vK6ciNg4lN*p;U6AYt?R2a|Fw)(fwemy2h?V&~Fs$?0#4B4jF z%%gj@LF96~TX=}PTw!cpHU6BELwfr)hb&y1)M+L%|J9w)&q#hyS0hSH5=%upey7o` z6Pp4wU&W2nTWZH~7{PQd0m9Nl=3UtWG=4(*C|sb8Q-u1>M{;|JOi?*1=hk~^T4ytc zk&YiixM)9H6F9;+2}NQ8nemM@Q_ucP6CenesgTFz*@(h4FdGSF3td^zn=5iSg*8iv z7-uL826y=jD~wsdx5`k;1z9V)V{*z+ehc%y``;dOnP`QK9JZX__ZzHE`2rG9^}@HO zQ8suvvalkicoZj(J;A^ai9UO1ClA8hg#=tB?!-mkgV{4bzSApqTn;0rY|bql0wbrZ zK@<|v8OfqL4qSF?2e;<$jXxcDBquXtjhxyS+a8ocIL%pphrJ;?E-FJ}Ty-OVvptS>R1OelDzCB+RIbB zUj#K&5N@nIDIUwZvP9t#iFWQ3#dq~cx`HM1DOqk)VQ7Isdc$1PcyiTS9dkWB(_WqF zP<25g&oe)tTs+CYYk=3QhI*(=#gup5mX=R>R$T9B<#x+ENme>GUdKUJ4S-fBlmtX00I zVRck?>ah=oTyrY2oxQY{TY5vb2QYl-@YI*;+S|;mUqAtab|q6 zztPI%Uo8BbL4nCZlQHbn5t?g3TR>TLX8EYqrkVMs%&|#5sjZ;$(enuU=+GROR17^l zn0j}=JG10`{$kRh{(5Gdf}gfQZClvm+;Hfbf>J;50(EiI5CW2ohXHR$NkJQSLVLY{ zl(R{`R*N_qyEEL*>!UM{T)sv_*>>iKseYi`zADClXw^JeF4%KN^S* zvva4>XdB#*%3dOhy?`1>N4DXmW66oPC;dB;ncCY+L)~tzT652)>$Q_ct>wjAh1nTq z?|7kNPnXvbn_nWCx2BNl4)ddjM^KI!sPooS6)wA={)(Y7`5@hpovKeQIjN?HTke!f zmU6x?O-jf<5#3D^@pG%~T0_YeFZ$7X&6%?tH-jM!o^JCGzbI~K=A4Tm?dpkjHoWyqoQ$?B&-n}B!ux8;$;91>eh2u65!{b6GXs_+b?3kCbqa@ z?>w+|y^bXKgVEqagv0b#;5=8D_-jH_Lx#(09rX!8LXM|vpSh_*)~e523p&4sbG4h* zqaE0=lY<m05lWwFZC5hhYny&bHdsA8fZmNDMr)2}JXt@I z(BZ1K93h0rdy|je5bA1}wP|A;;DxTo{b~0qZ#Q=_&*Ukrtsj|`=Qr%_;cgkrsT)~4 zhCA}O03f}~NM-6`&`cCDl7jhw$Kn>#EN0)FjJu;jOf|*s6LT+T_}XLm0sPB5*5mHO zTgrNKv<#>RAcKptZg7}&*OVcvhPEW7Jqlwd3jcm?ME7Btj)OU4l~*#^YezK)F17c( zjvYhP?KO+S{I|%0VD%2$Bc>~gEIH-2vh_;CPjFz4$u|U##rUbbpVS@Mo4C!GByjZ* zRjhJRtf)i_y;!vBETp@Q^Dg%>^%3pqIbT0tVV(wd;>exnVYtR5M{H};5?CnGeF9d- z1Rif<_DIY_oci?36C%`J$~wQ9c|3>f-4;bUDz9s?n|> z2B)U!sY?NZ4Fy39^|vc7w$~3AO_lJ;$bE}P>7>jo$m0vl20CKVUYplAg(JY8_;X5bMI{Wx|OGv7cJ0~TC_>^;^s7&;WBRdwRHy4FMe7gGfe1Ti5*9hpNTclxU!@xcmTS?}E(!U|PK zD<@BzdRLDowc2p4S?%l^wCw52(x?u6b);EXH>lS>7$fE0w7zrU73s->l>2Qc1xP*g zVa&`1m00gFY~GX&;-B>0CyJe}S`URPa}A`TCLVSW7a-fa3b@o{VyZQ)MVj;&n@-3P{> z3FnT^7{IjZ6Tiossy#O$!6r-CWt_`yt}MIXX&-ZReSA!u?e+ze=+WR<$VXtkrgAgP zu-swK_We-YK=5^N*YlPAAYp%G!n+|DdZ-jM3^0MYT`(Gh31-^`YlN&wiouU5zIUPD zvDa0cuU^eQ8nH+d^08`x8sS0Dr+S;(ZN5E7`5o-Y5x(vX*p9G9Cb@00oLdrUMUTXVYk)i);34Wr^J!02mozjmWcXpVd)|Sc94Au_ z#BqSi{TAc$m|l2Eg&>-7P916Ptm2H6Vf1SWX-{_5a2ru)xm#F4?QwU$sBRC^FR|6< z?ZS+1c&!a^1Fveg^yTChJ9aK@a*#$qInG$uW{JduS&ddl;3>rhi8?>IqYcrlT_S_} znu*IH`}%=KKP3Av))@XFt^3c4&EL5F|CTj|f6$Nr{Tc%UJpAL!1kCY9FSQ1amwhLmHfPnGo(H&V`dp|x0_6~fX zwC>6!6-P~E839!iw3Wv~4z=Rr6O%YHM0t zo1{uF$uOqwfXHis(1}(n+Yi^0Fw&cYv9_9;erLRSFb>?GRp?xf;gcW*j;rMUbS~MW zHq(vGtjfgTnozatUuLE6xL>B?kQnmd`E9MuFIzUWK~iKaEbIlYnVV8@m|>dPB*#nU zrKm{gFuE{bJu9LSi>Ou-h$>qMJ)TI9DV&8If5WZ{t{A=x*)K8}rVH6`KiNT?$B=8i zBB4GJ^@ljqBtbt)gQ#Hf(VhZ)AhUoPVy2HWa*%{H09>ghT+NwK2S`^kCH)!Hz-XVl zh8_p|j#L6fkC0P^%$|qu%+Y>W=G%q$-i3W6qmRgTx{kN-WQv2RsD!Bn_)=qvzl#JM zjkfm~TTVof9;KOX(2;N#)`%D4WSzM6Xv%?b2$J1$oX~C&^L0U8=Em7bnP%G)*g{CBX-EwAy(+MJ@t0lM$G zn4IV_QlBt&ajqVXCmTaNV%=Vk2wy5?--4???*a4}#iB-Fgu1K#!Vp1h7_e6kym-F|+0E z?((2m*q?CxR=F>ecOReYIE1C6rG3<|T7Rx*D8XG1-|EK5-P^lnf$hXEU?^*d*1sg& z+5D)H**Ra24~Y1&C1+Rm#ueysds6r|=W-D3RAU3zZf~_$V5teLW*R=3rxb&F@8-h| z>w%4MP?asK`TR61=w>}2#%V$@?z8*yEMs~POGh`eim^}g@>P{08-SC?g~&eWkAaMt+vws)Xk8+la+B=`2TD|wxZ`!E6D=y#su^XAPc zX!AWGj-co+?zcvma!qDMw0>K665E8!M%31&wHFh9Us+H{vzt}*)AK#Us=RFO$$)BC z<-u;Wq?WXzPF@FlL zL-AtT-_o+Zv4ZF#)G9>C;|U>@X;sgMGM4sRhEhbnz2B2VL%!)!0grrWjL6q$U$3s@ z%K*1>J|X#hJxPR6f)uJ5L4()8Br5Tc6#2@+3IKR&9YYNf)p{#Qe@b1QmzvInSX@5t zmvYQ6LnQ0T;f(hv+NrM_*(Dey0*LR3Rer^*WB!PvBW<6uc&cXyciho67~0n+R?PQw zji?Ou-`oqfhplJmb$goQY0`P`Hb+Z?z7rlaFjv7qM-hP+1M&s&L358CB7_PMXDmgf z;NDwS{KIBO0i;UAZBB5i=wAqbIB(gQs~O9p+t3)f7-aHZ1AxlRckA8A3wev`<8XxDg&`5hsJA(l@g^oElOFl&mADv$^+TuM0^fNaQ0 z%oSKJB7hB!Iv9OOP0zW<5z(trYurM`(5g<9XW94Uwxr19|CiBuF3A+x9i-JELV_4^ z7DYsAXVBp6_^oWD;s|acN%&d_^4jB2~H2ZDtx<1;{mO9fHlgfg>^7)Mf174 zmG!>B+k%jmR71VyhrVi%f|SjGHG~&Tm2m(+xN9_UMJrR%So(2{z_67a$M!YllpxsBs(0}ATl~f zW=;{m2@>vsuG= z-!I9)AB0U8N?$7u?$2=qW(GI{Rl}huLij6~$!7xFdoZEL1Q$%C?^E<}Q^vPTCKTH; z2pv7@!YYjlNm-RVU%wF&#^K7PA~`Hy{?UE9&1|-}^Of8nC9NVRR8S3%#^C}&Gn{y& zm)!ZGfjqR0R}$U2FjE;Ni zBqO6o3CTtqDki4`&&(xg@Y|lks1zrqWWdNBOrhs|w;^{6uj$1A}!E(e5~@fEJcS zxPat6;Q;hPd{I5VE97lMMS7#51bQ4sU)zMq@rzcmpA%D2Vi<#QmeA-+M(!iU7{e&3 znGoKzdw$|wET!imbnAo#TVbZda$D%B&XG-dTXTG<#kqp)up5}^yR5#NbZOFg(LrP_gj z4EvIsAg*->7OhjsW1@{GkJ(_!K{|J3tDEc^0BXwsV9HSzeb&tfN45BZvx1zw> zMN82aCjhho#cfkB3a9F^HRP$fb<=8+GnM8CK5IKRTo>+5R)1^N4}--p&n-CTm2P;I zmW`Ay-H5sXXPVJ+=xlDVm{5lv+p}`)Jt+8}Bi%p6D^P1D>X1*`yRcgJ7rb?%Z=5<% zQ+hu8ZtAZoyF^Lp21jg|x|g4wixg&xySW|;A205*W__aCMG9_qZ*_!JhS-Qs+rFjO zj|HnvU9GbRLMuLC1&>}DJmJqtN>8%c{T@m!BM>X^@un8LivYPuYmlZ^j`Yv4OZ5r^3m>>*lbKC z&?aK*ezVOU^mb1>UtsSNGLL*d2Xbw;r#J1QKa9){r0Fp9u!)}valm&Z`) z_`R)pq&JTb>UStwOM^d;PYC`uukQ5En{1T1-rtCguZMG5*+4IEwu{sA>rPxERswf4 zEq0H>$c}TNa5u0Aow1|6$~6S%&DHt?C-mDpcr)t-XRCABbE_IqPz7KnW}}3qa@{2$ zm$_s*vAZie{f@{{cB=ndUhuK+=iRt~{$ZXf+<_d5Dsemq^q=vp z{$Iu2xY2GbWA*$)xN44{V;M(I@7{5qr$5Q91JIkd@-(2#xo7iw%{jvHa)f|__=~b} z!idHs0AZl_JfaxeFJWD^I!+Aq(qRNgVcL62qP3l4_xGEDXWV7)-cAn99o9FuvS%wj z`QjjD$vq%##4wgdp)#ppt1JRdlwxAUptAd^gg*-nvv;Y`_Y=xwJ>G0Oe%Q>}c|hNaTRr%u={B$SJip;AkIi4duFUA_eK_1I!4@4zz`WsQ+6l^G zmsAv;2AA8UI|SM}FH_NnV&^TvcnlU$Z-`wf{p?~8b1J0k^P}RbyaT1J{$3lN;iLZYcKm!gwrYEK za&CS<7?G@B?W})HtbL1CZV*nlWF714{bdyWRqO|s(UEa`1R*0Y$RRBO7}_>~+EWeRA>V9-#`LcH~FS;{}^E&=u*z!KJwD$5ViHKHap#Z^5_q^|q zkj(wkO9oOiC>oZ;{k)iMXwc1xKq8o0e(Uch8(ac$EOe_n3~==GxC2BF?8A|n6j~L# zD`1iK%4X)C^(bRTWxBwR)YcgHUz&mvt>#B%Qsk=ztw8`jr7Qfl+gc1)ADmz$_e{oU z+{(W{%%?9^2LK;EcKBJELJp6uOQ4(Gsd;ZM%@sig&!>1;--EB%I?u78hAA`!-&ugl zUvN62_7-tOEAQzA_)R_?W`BS;zw*&C*R#)LVaYKgN#Pp!fU@-=d;&)V`CIq{FXvuwO_VsC2H}0W#_phgftnxF`uz*6 z@DD2Ve_@5cCgT4+Sm9sB3H&dChJO%q|2=46Vq*R$XlVLR2c_M)vO5QG|CJG97t?wZ zGF&YQm!I54`4p?ik;0V3CNU>J-^(_(TIb_rOd7PxTAe^#4sz#Cp-O8S*zPq(zfnVe z=2S|;4Pmiw{c0sjyK#IBL3&Ojr>E2Yo>|7=-Ru-@a-G^ zzCt|XwD5Q!`0l|k9pHHY7)iWCc9ht8^l2HgpX>>6%1FWFwalIPlwx+u$ z(=~Nx%Vmo<>_mngWK@4NJZc`8(H8Qx5Y8~GJpHZ9t%JlX_kYx ze*4N+q@_iOGD9F@AXNIYtdbXA?-Rm-*frBb?FSM7$=CxL_XZM7msJ z7!e7*xq4C{wii?Rm~b~1MwPf8P9S?Ukiu#L<_NdAp_k$T`{4Cr-+XVTGR%_2q9RzV zsH5V6I*7t#WFk1E0Sh9%*;1qhE-}mgH*0;6{whZm!2q366rR7dmQ-<6Q%AsBgTxGg zqDl3Ky7BNCp{j0~3ZjE5TR}25cyw8GC9Z(5^DTmb`Mwdh2>NDI6mqSqn!J{(1V?Pg zA9OK>Az7Lvkh<@yUNyB8N{Vofe+eEfGi?x+J=6xyh=vCkH2q&*wES7iyWDyAxj~A~ z(T$>l)4Qh1juO(9&B9)u5kM<#&E&B0!Wmk~jfy5XFp+I6%A`w*VB}1giC_x-k@A?x zbt>Y$s~eFPn8Zg+-^tvEje|`C@}H}zv<}*Z|G}=HNU$UTZbZPLmX=0~1)txfAU2+| z7Ncp%*Eh=U?jjoPKxhGr!G9ElS78kmR4lqE@MCBV9xwkkOPx2T#=V8-k(2@)mCl^+ zRo{%Hz?HNdv^REuEt`lr3e}-LiS5*;UKvH#5i-%BIq^lCaPRxxC~`RD5LLN!SxP$4 zrEb&o`e0y^CWj}j$o}d}DE6POy8MzfUg9xjML7_WVyZ>*edDsFVl01$5HHACv_*T5 zM=j(vGb_uM97{(1#lrb+F=oEaWq!S5gHEu{jZm7Hf47(Kz;KnF6At3-(IF?;G&WX- zETR1=Y3Y^TKb^tjHBE_tg>!$n<@S9uQls%(z7fE!8&AGO>}crj>LDS3u7_rAj*!*0SRzfRh| z^mt)IgLI*{vGIN{he&Uand(!mZ9=zP+~vX=_k#WLE?tR#bkH}^qa*o=^{d`fUuA>2 z9@Fwqz75#gR#L@;S|ugca^v%bi77wIpIUH#_Io z%K%?J_ZXcXsOM~OIVfXD-epC(r;E}6qup8FPc^qkzXhBmp)uLTabD}>Bm6au6;%g_ zL!c*RDB3)mv%KMx;z5ly>NV@NhCGw33pSeGH?7~y)Klqfh>^Ky9V3(t$VkxDj4|O> zd=rHf!q3+XlWTNepSIBTQWqLRv+I{iy@z5n3C64P@h1Dy7iMYfB^v_H%<3I|&OF`J zXnnV%N_xmC!9M^w=#HG*bYP6bWyoqw$TB3KF4`~6-}Ae0qYrg-=Hj{9Y_9eDJmR?A zMt1IkH}OzE-)&{1(fECCZ>_r7x%j+Ye|dZVY6Jj7i-2~t) zcuaG1;VAICCZR4P&=un-9LiT*%PM{`iM@joUP;!^96@&fnT369%I^O|xG{icaNV$4 z@+LG5o+X$5XT5s|LttptdmMvIJMLsP57L~-F;C}KF z3|@8v402^$4FPR#86rcYQsJJG9vd6AVToGCr^&$}J(Ckl9TiOHAxPQ_?09>25>j^m zJ+$6~Tl(q*5KzSCH3GjL_53yB=x-NGTfpk-I37RI?S_aM_(atTh@Ik}8F5xU+S*lz z`^B5otSxX6G$_I;KT>LnFMvXf3&E*M_PR~PgJt!6*y}JP2J5UheU2n1^%$30CQvkj zQIv3{ldJHw=C_ z$%YpnAiFo*YT2?{x1k@R%H{#@Yo8SXnUTg5lBJWfnE4>|V4}plD($NNr-$*M^ER`PSF zE-Am))hN3h@0Ju{NWC_co;B(A;Jo44YE5;6B@@?>RY7Opl-+)#M*cX<5?WZeCX@T6 ztQM(QVBE{kOeh3G6wvd>Rg+DfktP0GjfFzUtoP_xkcfLY9feA5$Z>(TwT%=Q57!c0 z`~AJ5ugm53^{EM8qFP0Jk4Qj0%@HQ@L89$w)u>8cUxm%YF&JK~K5yANo=!cqll+av z7AnW}0399N_@_ZvvXGkExSkAR@sVyfr*K;Zs*8!o(k#7Mxo8Ksn+DbEd9zxTl`&f3 ztL~p!rKoTeKw9YOR4v}jA+9h|KpuL1)}QIv#*`lw;Yh?zioCvgxkeYbr6?*tnu9cw z-Bxm?24!AqEu}6nTd)qX`w%QE1Ymh8^DZu?0g>bdOy}PM&NjzicO`WERvP4}BFH6y zkC<&O);n9fb?StQ+7C6njp z0P@rnX*w@x3S*b2Xw6u(t%XSC>p@&C=kr}Ql|x_K=&3UA`3in0lTA#jjPh>#*)lj@ zN%43mfaitvW|vh`t|^Hs?_CvN{Rr(;BKZ*$;8xgU!w);%4Z9-M<~JLL;WNH7k8C@_ zt>Vc{y1nrB0veJIxpU3chQn3vHK6NZAH9-_Zo&mYA%iRH1~VBK)0)-8`*B&b6VMQ& z7d=z*UYN_o9RKlWkL>l$GzLBCcr{4T{OwM67e#kL(KlK7VGP#xz7}GHJHJDiPGA3h zXwp+{nQF9PUKi@>l-M!u%C&2PAndUG#WM!&YRd(fBfny!8W&eRUwqp$!IEr~#VlJ| zFLPfDP8ueRV)ZGPytOTZZ)n|QVZH*8&yDuTIjXH8lM@M{yDZ8p$&TDyfFD$d5t+5( zX}j3eHmUXoW^q!PS3wXIm8L^C>4WAT7S#>7qQ*}_&-KcI^$5tC38CorjtYkcJv`ET zbwC)QYraVMJcT6oa_>~Ue!2LU-Qfz2ZVwZ=PHk)# zH+z>`ga{&TM?yl1-Y$EDiuDfxRKp8`1Rt1sjeRoC@t>Wfw^!E<07sIyPyz!fag zI`zm9AFchNJpDk$zkJCaIuxi3IZ%VPBIrX?Uu?afI^R4%B&91X+l(BC`Lee6@OIK;i$Xxr9mD@S*=RQVFAfaF9*YXdxwoR1z>fcO4;e%&|`~+$>%`|Ncq`q$|)?vrQcSIYM z^Y@@H(xQWl`d0nr{lqo>BtsHJL8Jp3&b#ay#VN@+Q7{P-FX5f2o-Im>th9C3`V!6@ zK4I4_IXJIqqFLb1MkZpCKfl*BL^4_ourMd~T=ACRlW8RfiIbEjxd*3ie4vk=ro5NZ zCV5Xe&J?6)0fkC-!{%({j)78?RR0YR;Xp}8`3nJ%hb@h3+2huXrQKo|Ll1yL1JVpX zX;&0Xd|iF}bVEZqCglMU&jL}&lH|$M8F-TKa|K0FfeHjQC<1&kB?Tjp*zzJF|Hrgl z2KfZ=gW0dj^+73W+VsTm@RSKToZ1YK!ubJEb$woLVYGp4cWffnNY#SnnB&;Syehjx zB7f77tx=OJp$^pq6*>rSLIWSHiC)B>D#_hTqc@`)4ff%UVSwSBI4a)P$&e61Oa?;! z_SoQ1oC(?R`>W5KG83r7nIF&itHlWc3DZJ9&*CL$Z0aB)cmrkA0Ia;eSyta^g%UdWbL z0VFR~5buVY3k3fL0>jgior76*4M0huIEd8gle{A{;U}95~ry_sy z5+B&i8N;!0Tsw+Ax+>fMiMrN9Q+T@zka$}#GII_i+(2T|n>1&vJJFCF z-$&pq$nBSo3%%MG>Okr{4TYrq-G~|=B&Gw#O8`jc+`umL6GpGe0OfRt1H)kDs#P!? zViL$<0yy8tI#&jex9>o(9R&rW|Gpb;R^+=8@P$gerA&8=m!F5Df{jyofNExZ_FzDI|mLRou!jSBhKV_`^G^QQ-j%lo{ z9$qM>T*9s`4{Amtb*EI(lDIxIOs-y#ek;}rbR zShSFuysh^EzFdwfNWxb|UBTP>Bp+dImQeQ!G~JEIh2a3s5eThZgf6@ z5fFRw-M2CR>f3DrD?ut1U@;FWRD`a%=9i0DKZDpfYh zslRhAoi&B7+Hh5>IAa3JRm_rVG%>yppnhIetID6V9|=xA$R-n5q8xQ>DTq$1(ac(o z^(=0)a%Ml4R&O22cE`SnrcwB815H1dhC;G@3k%(I$s=ddZf|#wv?fIi3Csv17@()L z6pGkn2lt5-7HKC^gfIlMQbrz)lPjc#XVNs!r&dsga6T?;pwXh*K4S?L9l8(R)qTV1AlsAs^BR2weU zJrKF0icYWF&pIJOQ#gUy4ul(&+P*&wah^Z3Jey=)wtGR0aEFP}UO0Mm5s4Pcx++;Kv8YudZ%D@BUp8*0}?g>)ZC`r{z zvAs*e^Y(IUSE72EV(JEohvU~`#0+zInkHgURNb-kDRbYZ!@QF`4}UgaIoRuGXlsyP zRNhjK6D(AKdzI0hmdZ8;*_i-DBA4;1K-1pMcky&qtMn$DboOMw16|&I$;)Qxvs2o= zhWBdSkU5*(Kh3WV-UM7mQ+D$cq@8}xWoaA7WA|(J>RRB{XrYBmU7$#lXz`aS>5bN1}B&)IR}Ik9)7_4fEd|4mT( zhe|I{$#I8V3!W_7j@{AsgzAE8_T$g1)aEG)UpMPktRB^6kC>17SnebbcP|+UVdNgH zVA4J))0sv(t3Q{jc|4v|VMX#XK_)!1_gjMw68Ef#@XPZ$N4jr*XWHEd2kzhr$JGTl zlYL3bE7|dku0wT6HJ?)ia&@!ZT^&buvsH!Z{VMi!>(u5QbMieij}2?;eBLF^kc4^} zDiEx#RBH_$mycIpU9xtW@L=X;sVVqOOTOn2xZ}`h_M>X~VEuVmy!#X~cB4?u(Or4d z3%1s(I@3J=uE}_Q?dV|7m~>RwZl#`P-)zM37}=jEUCp54IgO`7W6dj8XKEs4IaYHl zWMM1EU1%}9$K-<5yBwmRNMH0Bo8jS1Gh?v3giWdC0iYklG&_A$*EbM}=TWMJZw2A& zSAKnkqe~?e;^T@j!_Ft=uv0|)iD*^)7$rQi>X4=CzwQmQAMrxL-P6A2)sI=#_&uJo zw6fxOX1uF@Cw}D7j!!It;T!ieLc)(2r!{xZg!oxvIGbts`$|OB5`C69N92TW_9>lw z8jXTeP)tRloq&hzq_VgzylAA0EtxL?ANPqOp3FwdwN`zehI^&6uGWRMKf1=!F8)g4 zXnUZhWZ7HffXSMlRO@c* zvAYbpClU~Q%i9j89?us^Lp-M*u;ild=sKh`ZPMVd+YF2eN*huu9b51F5R+ebs%t&P zNwn`Y08!g3ULX8)dSw$(BP{V+euK#2`EGk{RLM@)>du!J>LT)dSE|0$94x7QZ=q`M zr>bY)?c9&TGs5~f`APjbITICB*Cn^-*~v*xlqJCGWO>cbEm}L}?MyKid;1Z&5Q6K4 zT+p`)f+Oj|GU0@Ttda)wLeH_$Nd9*-I>6KCw&pyY2-$9Y>s~Gc9*g2vdzC7bx?HsN z6KfHTAIgvSQtt@t8wp!Pb!Ypg(GG`pT$%83uvO9z>C_AA=+io@GsvOGkunCNJ?f=8 zKn>cu>6PD5Q&eMp%`|O|2~IR&*=WOGP?g-IOnjghVDs(Q< z+6@(m#W)>rq#NEC4r3m|x)nj^lqmN7AqAB7`XGl)IX2i8L3p zG@3$zkjN{cxKXR_Fx3kiIkNk1Xgb2;KyTwook&KNNx7p{2+HK{;KzEOiPOGt7-j7= zL&D@-dG63hI6V2tdeTdcVEqjG&E>0nsJg+YsSk{D9KNY{8M5bY_^N5@K7*^!agXxF zA5v#nm3cE_?Xw-;X7&ubwOzf?>0uggc6Fcp=Ue`S?!n_P-CJvoO%n2tKXcKJ`a9r} zJ1lXrr|Ul?(|0H3+{2w?VJ_pTUlu83WSbr~e=>pN7S}t{V=2H@Fewvsn^_qTbDo_a z-`Mj*9Hu#W`xSD}+5{FaF04*78l{aO@CsZ7kNHJi3wU=^WvFqVD?D`^4JaG&;6pLnTit z*aDYnsgpECCuhDqKjG=&@r*qYY~VjL)Z5W>;rN-drua0(8zq^GgwzkgH1(n;BQ`aR=GdfTp z2MQ2UMMTmTeUR1Xp`fVBs#wpa+Mn=kdZ}uaUUSWidN8zkinWx=EjGz*Qb8pSCxvf< z&41_>BR2G?k6<*o?RL+Uy_Ldv-n z-D0rWk7ZBFeOfHkat7#WZ9_ zED1ek%|4_V{jrj?GS}O%J?8G2-Z{HGU^*-1Ptu5o^>{!M?6p$wCT+E%`Pt`e5O(Cj zFSJPcaj+U!ew!rWEvuuyoUgbW13wX&P*a(EBNOPcV21C^$J1wa{MbwUOB95)3Ig_q zUR@qc+gPPO-NW3g*5K0j!t;H)gG z;nRWkBHcvqv2M!4d`Nx75trPFb*zosf?=9;^_C+v^98nD&v%y|=?UvRN&@6vEw#+V zas^f)yAuY=BCXSYOCM5HSZ=;UFU=uNnm(nV_cZMjZsJP*Hw>hMfmRUZs9CaB>na~^ z+i{>PmwueZt^W7KY%bgE1rr3~PNMSZGA_%UeLjv47xLj zM__c@b}aJ19e*KqeRuA`55l?v^CZU!?ammdfuEc+MKg)kH7~kR2bSPZp-8=zTB~55 zOlG(aWts!EU~F=>)qbV@R! zcKpMV(cGycmbLV&8X2g?611-pAAPN)?%sQv_3n;)r*``r%?m#VmRq}jR16vUX~Pl} zTo=n^Nb{-uxhh?PO%tj2Cy|tUau%Xto@8FnJcfzc2;C&TXG<%l z8@d|Tx1OYbrsY)6?ssAN`8u(8rL-`iDGP7wt>X>~H;n9O0V_jz!!B;jl;G~e#F#e) zEvY;_`iJY*1)I`Wu3_&^9(KT)ySDcFbeXd0rv+`u^0*7W_VgCy-_z{&tgSjFD`Bv5 zIqU1QpGXe#vN!=^w>s7MJ{P&k&>78?Yy6NVF)K*2SOxC~p^v#AndI)h!}Upys9bB9 zfPlA8exuwom$l+mfQz(i&_Ssxk$cU@74wp&7R^MTpoX72eU0*2ABXhhBwMwEsC-Hl z0d%+wdJ!yf$kflrlDzdkdQlGUEuXi#!?)j;3Dp&r=NjDG;{`G{#dyT)u?d{Z&!l<3* zr7(omybK@hOfwsK$`R|$`RI<)ZFbjE?K$~LaNEAj9Jy! zC7j_AEP{mwUo?!ek_915-AA=QKq9Gv@$yf=ufy+zD1M#f43A%=N73~(sbY|(7Mx~v zudU`L8uE6Nya7I7cG+foi2EFIl~`FpD3C3bj?FkL?L+8$zHS?1D8|cPjTZK`8t^R@ z+)V`^n?)9|exzUdb*jilYRIck@``@NYdGzpfkTLr{1BprU0darb7_u0Yo-yYl6#Wf(!C9cM@a1QL9mM zqZ0p63MUj-&=GDFW0J$$%X=XBQH!B+sj%M5HSx3CG!p&Eo4jDWM%ylDz=w`-N9%}T zv&Ci)I9&b|ZJ3hRCP?5&BH@kCbc`V)MB;h{y#WKYHub`{!h{!NQqoW$w}k%_!E04Q0r$TSn3JqCz@)(oQH zm>T&KcD|VAUmLvhTwoBdN9cg<-7+9tB(csbGNs7&zQEq@J0)PDlOu{SAEBWe=^T#G)s})30(5azSP+@@V_$wK8p`U|S2hcY0<8&8EF4 zgEi>K(5DvC_T~B{7^>72_s*(kCeDL#HDB$SbT& zNd2;_sZ}=yacJ=h$}w1cAUMut1f{R2YcS_+6rNhqJsy6D%@ro$GlrJ%42!B*w*HZ9 zfn74uq`|#DW0xi*w^0=8C8Y^FwZOI9SiEz^a&aMtHvm9&zeJK z`It(NM@i2}IhfLt*HG-?;EBY>UM%PMmQ=>8`wsT4E66W<60RwIO!!{rPmdhQX9I3{ zv=872E{;z6;vi?LWP8;s>(#F<3Xcwt4`6tS62T|>!W(H`J{L8(>ZZNUQL?tNO!kdl z(7{NpyV^5#BU>rq9Zb{cyBg57f+eao+pJw;Ky5V}LK2?xSbXRzr^%joZiPg}?E}l9 zyH}j`i_8Kay*46BYD>?~spoJRt@Rjy`HvI0ae%fMd4%hj4u%|Lkfd3Ac83w7+`PYW{p9xm}wUK-FD&b3xr_C;x~+w$yT?qx$g_Q8ssI+5~I? z{u$~|9`KlM`*z(*nESv7C6~tq(*oG^e2t*ZoUfcqL&tnxmD~*pV%Rp%qNAvI{1@yE z9KRi9S@qcM5eUk@u)R^o$+Gy|8{5^Qco2s!_l8$4SeM)lQIS8vy6Q>l*|* z6d4AcMGV(v=^eVWpDjKJ;)%=SRD(K}C*xhMvnxSA0LaQd@<6``IRcG(Tiko5=b(EtNq^gZFUp8&_x^lFx}& znMGJ9hs8QPvEOid)2}U`G4NP4U`M=xdtltN4YTE)eBdYP?Sks6f{vPeAA-b0mRmi@ zl(c05CGX7^kNrwLjg@EDo2~b%v&oacEpFa&n_)mF zI~nZlrm+!NK5E~kx?b^d`IL%hx(Km{lVMXcku_Q6A)dwq7uFd%xWDM3L94UJReD`` z|FHd;SfpVa-5tbW9bsTfo*Q5mUYyNOqa>m)L??AaTk`5g2BC2~r)GkuNAYIVXhq^l zZGFk&;nywJ70$U^0yw3I*R5d^(rGSuKK(v~_hpTPq(1e}X}h*k5Qi9+G@DF{DW?OR z#?xN}wP{BP#b%=Xmiv<0v|@g-HJ;T$9BtQ2R7a0^?47r- zkaD_GK~jNn(jlZL!T0tY^k*2EXInfdVNFQd_-F4nd;Ig}-T?5}LOWo#+~qwyJ&qsW z=TlsrZu$jG&RZNU)jg`Q2cm)f8<%vd_}K72ZM){<&pM#1#}>X7b#W>n>X$)3^3iT?0iQCcu8K1anYkcWl$U zQgTX)LJiSWEAMW-SRg(P_Qn^vQs9T-6tDEM++@y>!YUatBVF4El0GZW*m-IY+`M9p zOkVIvE!M~p##kp(wC+Xni*(IVO61`Or}UQ?D?X4s)VXnMFfm4%Ue=Ax z)Ek8k%k#eSMfLOE+c~p3gi~}yV*5>mH^%ys*vJ;v8X%%Xm+M&);d!GQyU;za8iOO^XN`Makm+V((&;)OfLW5X}Nx%W$$w zxgt{ag00Fl>gxU$u=rj42idnnPORo1$S@5(fdrWeF+Fd6ZI-SM;vg>f5*{1)+)}1h zR=8!1qm-%|>_am8shq%s@*b(dtbZSm-Vl$=;&-h{x-0egY^76Z?U48?5!Yst)-QCsUW%CyLPw=jRDVReH9B{vJ1{aoZjnCtmU(ql zTKId?t*3CGHEE4qA5h$4O1&>dN{^H(En#uE{q^m4=Ghq|j!ld>Ej03H|HEx(k&E)kgOgv~?N+#wyr19N>%-Elv6P4} zuSSSD=c&^|2?8Ff${m<|>UuaV7Ai)N5+@4x^HAJgY&bP8Q3wj!I zeS(T^J|XZ8V-~J#!FXZib9gsf-*EX8XWeFilz%E)lps@HjD=x>msAKBFb`CpMbx@p zH1IlMQI4nSYV-AKVs91$lInMv^LS}9rDpb`E3Um#JKCApy3e~iR(8K2wL24Xul}5f zpRDEcvXOF1Cpo>Q7@5W(?sAZ55hZQAR`l()-A}#ibN+hmWXdH5=?~A|Ehk%~tAk5> ziayE&bM=FFh$jn}2vVN2%+TiAIN^p5&2KI(C=Rh5wnIg{TJP(-OcHr96+B(%Jy*0vBfy9pMCkI3OjCw|8 z5nJGlby=7Vx%xs^7s-~$$xOBNGlucYnfB+GpvR!?)wzzElW( z`MK-=D!HyDs24Q7vA8xj6skQXA=22Ca2JY!!p7SrR2EGtYSy-D4wI)tHSFU`&Z%2& z-}o?;P(58NJxM`jw4qF3apqKiTQ1P8AeiHx3J(hD#7yfplF`wih>Q4`GuNOXHJEp3 z=S!Uaq;fYgpSX!?RQPUfZr#M*Ah963TV?GiW=BmDe0*|oWpHfI0-Wn^}xa5X3?pV=S($X2Y>@i#>!a)7W#ql^T|60m!>cU#@eDYM5n-s~#Y~5_g`-KI8RovP zLRMefy8007b+kI&UM{q9W?3t&m>)&Ec#dk7ngcl)GTYLX{J3ABr^W8yvG5Y^uRN<| zdv#d0+^=le5(PI-@yzAmvy-^)m~w>Vqnojqiq0?fFsl@0sfLIyc?@yD1S#()4jBpQ zH)0XrHml_yU2V5>+iDhiGz6vgCJTSKdQTcLL^8xYTSXe$NHVcoE&2E!S(G7GoPi!O zHuY`-?etQS1vc!Zeqfk$qf|JdP2)0lhRhtI5tD^frcKBM$*+!@nMum%ZgD2SEVCX!mypWKl9HD3)g@bM>!w&8^p zx4I+yJwvjs`{}%{>UjGo$}@8^oVB@?P+=_9D=lZ$0%@nK?(ItSFD&Y`d=CXE-UX15 zgJOW}e1iE0IciasYN}UjhL5vN;JF=c&n%4G4ox8N9?&=N#K--V}~ z8EzuovJlZWwr;xf{w7gz)M6lr-2Zm9W5dI@^D!UGnyIXqp7*cyHLSJf5Q+M8vn@p(4}1`}NQpmtsGc7#*Hr+HCS|n74Gz^#T%ZD#soxUD*oy{z z+8Xwd74jM>SywDuRMk_pFFSK1b)R$Yq09R77mnc)&+5EXQ)c+?Kal)^DUWSyPS_uL zaP2nFROpi?@pu_`7UAg`6_0EnUqTsVu7hm~z%zCKZvR%i8)#+0_%>0k8^$u*RI*|{ zP1$S!BFbz&L)EhJ@i#D;ZrG^o+puS#l9z^FT`Kq_cN5f^6yEi!;FSa5oOj8hX@*lU zxz#44heUE?+Nwsv!&tw!tV%b6H|;QHzTNhz9Uv$TVUBfW3IDqEa++JskWr3b!{^0= zs2ar_@vZ1?!=Cpay=9=U>HP&mYWES143jE2&g(c&ywJj;+MCsveyOYR`A!5>+C*jZ zK^~>)XG;!ya^Ou))euY)JkB!*d?tmoiGAv6thW0!q<#w+8oQWS3h%jfQUX|CR!B8o z3!>X8ehwW#9Prb+bhIohZ4Ih9ihC7okUMA4n9!L!5hlxR+EOXbRHQ}w>wl$z98Cm2 z;d(7#TH6=Xb(Qv@|C`Ni=d}1P-|2f2%U=ZI!}hY?A?`2MHb?~ZuS)UK@Ac4QZlVN? zB#6yftTr}*ZL0cqPL$TXk*x}`(Qp!~c{*hBUiP_G>ONv}Xp_Iwl4?tXo9tH7?9E2# z*k&n51xA-UZ|b%ueEhCa>Ck*-$re9YpP)l1TxiMm<{Z5MA*X_~D|UR>WHgyqT1ZBpA}<1EA~>Qcs&9Bvhyaj9j~o+$D3fwdp-IsaZyZpj3(}mY_JU` z&g%huX_iS|U9S=IWHLi_ruIQL%3_Ya*xNIV%Urj%V%IN}_kbym+B|?NKyFH1OoooV zQ898B&zEj*e2#8h)pONjEY!z7e=rDVQs)igvrC3Rx6NUL>6bPQoyX07T0Z!NinZ;e@8kCojtU*>Z3%F~O9gXJ#8~tD(QbI}txoSGQvJIow z6)bZ;$jX|3maEUQcWx`U|GGIUrbbXWnqI2zSO^=YpDvhDk%OxINS0A|AEDoL*itJ| zq;TC?_7+mH?}mK?#uH9iE|>kZ%3NRL+{{bgah<#&RO7sN8kMsbs*#L*wzDuKU5OHv zeDKKGqR~nFgoq`3{95_?Zd5Arm89yR<@cDq^&%|YLbYUnf@;Y<%WE=JcFG@i$Qy4) z{!kz=;zJ3?mw2=X_GaLA+!FLsXpggY78++bo-y?z)FPW;Vj&;Bg8B7@iz~kfu5aF$ zBk^a-n!W)%^_sa&XKkgjA0beml>2gcg@H0i@9}wyoASryx#gjiRV6|%>m4v)q%#q& z?x$1Q+`Uv2a||&7c{k zi%T~%ITceY3mXZ|9X_bW;hv`-%4bAPSHy4c;AR!(QET0^+~sb#*2dnH#G>A08SI=m z8>TGuRNGCk;rjgt+HZlM{LBiDsc(H>e5}1@=lo&?Y?R23XMR9P8Xh-dyf$m&?&0iS zpDtU5!`o2UMq2osP}Tx+!wfW=@qD-K!}i9?QWwJjM2`F}z804fw`}mKl{c2&A=G9G z+lOC+Zo0PJe7LO4NMNh-(d#^7f7YW9yC_SN|t zd+aqgo8Cg1csH9Az1=5hkHEv`bCJ&|O1XqNu|b+OvsPwn*CJ745?2}1RtH}kJPln1 zf+A12$vm!ze(gowODI$qnc~jeD3%*pG<>bU%QHL?P=76CEhBy}441%y@YJjDODS!=wv#C~?XT+uf~SThg-R=jPm}SdC`McNYiJ3rZLXzrVatz4I3M83 z)6wlVb2Ci58(ZeGioG(?Cq}zDP5M>v3cjAF@QhV?A{^f^Cm1uhv)yC?ta`PBDm8tv_-sw}tExtEUOkwQqph52SIG?LW5|6sZ6Z9{XmzNuazE7dWqhe}jVaR673kGQ;ZH&Q95qy9`+VO~@YjW`-WoY4GXlJUg z%O$U8VQOt}$RmN&M;VwRjd|2eks?T2(|@P`L;o+!k^c?)q9_Z4e?a^%ONIZO_&=cg z7qk1n(nX8f#?;W}A5i_vr-O{Cf$c9_09@z>zGen*us@@ihhj zUwD52fPa+@`BgUL*ME>-|3NOY|F^1e;nU$?7JE^Jix?nE0O&8KpuhNr{^A?@tL%%T z6G{NsFBI4>6xapI-;~YwzvKQw8hR?|2Yi@Z~!5LcqM}HuXCm3=X<1 z16~*(FS@n;j>iXw{80uU-+5F04G#o@pEsyWFup(Xf?x=~%jJULXhC1fivUB<`-tD@ zfq8+5%XI;x1#?;FXib9t$P41-`y($D$ah)xU?>Rw2Ob~f4_gEC!Tzu{2nYzgoEHK@ zSLPBQ5VXqwz=J@~LxujvF9ZVr!>%B3_<1+>J06_xytDirhTsKW#)I+#;g|8CX!%{1 z6%@h;x!e|@P+ssK^q{ambP0tb5SQ~J{-(`95kUB5okJ0z^A7JfK456Wx?DdP2z{OM zG9DOuK2rRi7YzSHM=;C zXJ?~pYGG(|J`a>e8leCe1Bnukv^e0YAQWN<0wMT-U|mB!xSjzB4&v2Ccf1G$*uV$| z)-$*#2+`B$1w-@<;cyVh2nyBZBb!gg$y5Qy+0pi$@8CvIATUc}hIWrY?r) dfdV}g+S=*b*j +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_err.h" +#include "ble_gap.h" +#include "ble_l2cap.h" +#include "ble_gatt.h" +#include "ble_gattc.h" +#include "ble_gatts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations + * @{ */ + +/** + * @brief Common API SVC numbers. + */ +enum BLE_COMMON_SVCS +{ + SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */ + SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */ + SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific base UUID. */ + SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */ + SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */ + SD_BLE_VERSION_GET, /**< Get the local version information (company ID, Link Layer Version, Link Layer Subversion). */ + SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */ + SD_BLE_OPT_SET, /**< Set a BLE option. */ + SD_BLE_OPT_GET, /**< Get a BLE option. */ + SD_BLE_CFG_SET, /**< Add a configuration to the BLE stack. */ + SD_BLE_UUID_VS_REMOVE, /**< Remove a Vendor Specific base UUID. */ +}; + +/** + * @brief BLE Module Independent Event IDs. + */ +enum BLE_COMMON_EVTS +{ + BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE + 0, /**< User Memory request. @ref ble_evt_user_mem_request_t */ + BLE_EVT_USER_MEM_RELEASE = BLE_EVT_BASE + 1, /**< User Memory release. @ref ble_evt_user_mem_release_t */ +}; + +/**@brief BLE Connection Configuration IDs. + * + * IDs that uniquely identify a connection configuration. + */ +enum BLE_CONN_CFGS +{ + BLE_CONN_CFG_GAP = BLE_CONN_CFG_BASE + 0, /**< BLE GAP specific connection configuration. */ + BLE_CONN_CFG_GATTC = BLE_CONN_CFG_BASE + 1, /**< BLE GATTC specific connection configuration. */ + BLE_CONN_CFG_GATTS = BLE_CONN_CFG_BASE + 2, /**< BLE GATTS specific connection configuration. */ + BLE_CONN_CFG_GATT = BLE_CONN_CFG_BASE + 3, /**< BLE GATT specific connection configuration. */ + BLE_CONN_CFG_L2CAP = BLE_CONN_CFG_BASE + 4, /**< BLE L2CAP specific connection configuration. */ +}; + +/**@brief BLE Common Configuration IDs. + * + * IDs that uniquely identify a common configuration. + */ +enum BLE_COMMON_CFGS +{ + BLE_COMMON_CFG_VS_UUID = BLE_CFG_BASE, /**< Vendor specific base UUID configuration */ +}; + +/**@brief Common Option IDs. + * IDs that uniquely identify a common option. + */ +enum BLE_COMMON_OPTS +{ + BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE + 0, /**< PA and LNA options */ + BLE_COMMON_OPT_CONN_EVT_EXT = BLE_OPT_BASE + 1, /**< Extended connection events option */ + BLE_COMMON_OPT_EXTENDED_RC_CAL = BLE_OPT_BASE + 2, /**< Extended RC calibration option */ +}; + +/** @} */ + +/** @addtogroup BLE_COMMON_DEFINES Defines + * @{ */ + +/** @brief Required pointer alignment for BLE Events. +*/ +#define BLE_EVT_PTR_ALIGNMENT 4 + +/** @brief Leaves the maximum of the two arguments. +*/ +#define BLE_MAX(a, b) ((a) < (b) ? (b) : (a)) + +/** @brief Maximum possible length for BLE Events. + * @note The highest value used for @ref ble_gatt_conn_cfg_t::att_mtu in any connection configuration shall be used as a parameter. + * If that value has not been configured for any connections then @ref BLE_GATT_ATT_MTU_DEFAULT must be used instead. +*/ +#define BLE_EVT_LEN_MAX(ATT_MTU) ( \ + offsetof(ble_evt_t, evt.gattc_evt.params.prim_srvc_disc_rsp.services) + ((ATT_MTU) - 1) / 4 * sizeof(ble_gattc_service_t) \ +) + +/** @defgroup BLE_USER_MEM_TYPES User Memory Types + * @{ */ +#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */ +#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */ +/** @} */ + +/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific base UUID counts + * @{ + */ +#define BLE_UUID_VS_COUNT_DEFAULT 10 /**< Default VS UUID count. */ +#define BLE_UUID_VS_COUNT_MAX 254 /**< Maximum VS UUID count. */ +/** @} */ + +/** @defgroup BLE_COMMON_CFG_DEFAULTS Configuration defaults. + * @{ + */ +#define BLE_CONN_CFG_TAG_DEFAULT 0 /**< Default configuration tag, SoftDevice default connection configuration. */ + +/** @} */ + +/** @} */ + +/** @addtogroup BLE_COMMON_STRUCTURES Structures + * @{ */ + +/**@brief User Memory Block. */ +typedef struct +{ + uint8_t *p_mem; /**< Pointer to the start of the user memory block. */ + uint16_t len; /**< Length in bytes of the user memory block. */ +} ble_user_mem_block_t; + +/**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */ +typedef struct +{ + uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ +} ble_evt_user_mem_request_t; + +/**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */ +typedef struct +{ + uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ + ble_user_mem_block_t mem_block; /**< User memory block */ +} ble_evt_user_mem_release_t; + +/**@brief Event structure for events not associated with a specific function module. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which this event occurred. */ + union + { + ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */ + ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */ + } params; /**< Event parameter union. */ +} ble_common_evt_t; + +/**@brief BLE Event header. */ +typedef struct +{ + uint16_t evt_id; /**< Value from a BLE__EVT series. */ + uint16_t evt_len; /**< Length in octets including this header. */ +} ble_evt_hdr_t; + +/**@brief Common BLE Event type, wrapping the module specific event reports. */ +typedef struct +{ + ble_evt_hdr_t header; /**< Event header. */ + union + { + ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */ + ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */ + ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */ + ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */ + ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */ + } evt; /**< Event union. */ +} ble_evt_t; + + +/** + * @brief Version Information. + */ +typedef struct +{ + uint8_t version_number; /**< Link Layer Version number. See https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer for assigned values. */ + uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */ + uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */ +} ble_version_t; + +/** + * @brief Configuration parameters for the PA and LNA. + */ +typedef struct +{ + uint8_t enable :1; /**< Enable toggling for this amplifier */ + uint8_t active_high :1; /**< Set the pin to be active high */ + uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */ +} ble_pa_lna_cfg_t; + +/** + * @brief PA & LNA GPIO toggle configuration + * + * This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or + * a low noise amplifier. + * + * Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided + * by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled. + * + * @note @ref sd_ble_opt_get is not supported for this option. + * @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences + * and must be avoided by the application. + */ +typedef struct +{ + ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */ + ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */ + + uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */ + uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */ + uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */ +} ble_common_opt_pa_lna_t; + +/** + * @brief Configuration of extended BLE connection events. + * + * When enabled the SoftDevice will dynamically extend the connection event when possible. + * + * The connection event length is controlled by the connection configuration as set by @ref ble_gap_conn_cfg_t::event_length. + * The connection event can be extended if there is time to send another packet pair before the start of the next connection interval, + * and if there are no conflicts with other BLE roles requesting radio time. + * + * @note @ref sd_ble_opt_get is not supported for this option. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable extended BLE connection events, disabled by default. */ +} ble_common_opt_conn_evt_ext_t; + +/** + * @brief Enable/disable extended RC calibration. + * + * If extended RC calibration is enabled and the internal RC oscillator (@ref NRF_CLOCK_LF_SRC_RC) is used as the SoftDevice + * LFCLK source, the SoftDevice as a peripheral will by default try to increase the receive window if two consecutive packets + * are not received. If it turns out that the packets were not received due to clock drift, the RC calibration is started. + * This calibration comes in addition to the periodic calibration that is configured by @ref sd_softdevice_enable(). When + * using only peripheral connections, the periodic calibration can therefore be configured with a much longer interval as the + * peripheral will be able to detect and adjust automatically to clock drift, and calibrate on demand. + * + * If extended RC calibration is disabled and the internal RC oscillator is used as the SoftDevice LFCLK source, the + * RC oscillator is calibrated periodically as configured by @ref sd_softdevice_enable(). + * + * @note @ref sd_ble_opt_get is not supported for this option. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable extended RC calibration, enabled by default. */ +} ble_common_opt_extended_rc_cal_t; + +/**@brief Option structure for common options. */ +typedef union +{ + ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */ + ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */ + ble_common_opt_extended_rc_cal_t extended_rc_cal; /**< Parameters for enabling extended RC calibration. */ +} ble_common_opt_t; + +/**@brief Common BLE Option type, wrapping the module specific options. */ +typedef union +{ + ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */ + ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */ +} ble_opt_t; + +/**@brief BLE connection configuration type, wrapping the module specific configurations, set with + * @ref sd_ble_cfg_set. + * + * @note Connection configurations don't have to be set. + * In the case that no configurations has been set, or fewer connection configurations has been set than enabled connections, + * the default connection configuration will be automatically added for the remaining connections. + * When creating connections with the default configuration, @ref BLE_CONN_CFG_TAG_DEFAULT should be used in + * place of @ref ble_conn_cfg_t::conn_cfg_tag. + * + * @sa sd_ble_gap_adv_start() + * @sa sd_ble_gap_connect() + * + * @mscs + * @mmsc{@ref BLE_CONN_CFG} + * @endmscs + + */ +typedef struct +{ + uint8_t conn_cfg_tag; /**< The application chosen tag it can use with the + @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect() calls + to select this configuration when creating a connection. + Must be different for all connection configurations added and not @ref BLE_CONN_CFG_TAG_DEFAULT. */ + union { + ble_gap_conn_cfg_t gap_conn_cfg; /**< GAP connection configuration, cfg_id is @ref BLE_CONN_CFG_GAP. */ + ble_gattc_conn_cfg_t gattc_conn_cfg; /**< GATTC connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTC. */ + ble_gatts_conn_cfg_t gatts_conn_cfg; /**< GATTS connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTS. */ + ble_gatt_conn_cfg_t gatt_conn_cfg; /**< GATT connection configuration, cfg_id is @ref BLE_CONN_CFG_GATT. */ + ble_l2cap_conn_cfg_t l2cap_conn_cfg; /**< L2CAP connection configuration, cfg_id is @ref BLE_CONN_CFG_L2CAP. */ + } params; /**< Connection configuration union. */ +} ble_conn_cfg_t; + +/** + * @brief Configuration of Vendor Specific base UUIDs, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_INVALID_PARAM Too many UUIDs configured. + */ +typedef struct +{ + uint8_t vs_uuid_count; /**< Number of 128-bit Vendor Specific base UUID bases to allocate memory for. + Default value is @ref BLE_UUID_VS_COUNT_DEFAULT. Maximum value is + @ref BLE_UUID_VS_COUNT_MAX. */ +} ble_common_cfg_vs_uuid_t; + +/**@brief Common BLE Configuration type, wrapping the common configurations. */ +typedef union +{ + ble_common_cfg_vs_uuid_t vs_uuid_cfg; /**< Vendor Specific base UUID configuration, cfg_id is @ref BLE_COMMON_CFG_VS_UUID. */ +} ble_common_cfg_t; + +/**@brief BLE Configuration type, wrapping the module specific configurations. */ +typedef union +{ + ble_conn_cfg_t conn_cfg; /**< Connection specific configurations, cfg_id in @ref BLE_CONN_CFGS series. */ + ble_common_cfg_t common_cfg; /**< Global common configurations, cfg_id in @ref BLE_COMMON_CFGS series. */ + ble_gap_cfg_t gap_cfg; /**< Global GAP configurations, cfg_id in @ref BLE_GAP_CFGS series. */ + ble_gatts_cfg_t gatts_cfg; /**< Global GATTS configuration, cfg_id in @ref BLE_GATTS_CFGS series. */ +} ble_cfg_t; + +/** @} */ + +/** @addtogroup BLE_COMMON_FUNCTIONS Functions + * @{ */ + +/**@brief Enable the BLE stack + * + * @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the + * application RAM region (APP_RAM_BASE). On return, this will + * contain the minimum start address of the application RAM region + * required by the SoftDevice for this configuration. + * + * @note The memory requirement for a specific configuration will not increase between SoftDevices + * with the same major version number. + * + * @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located + * between 0x20000000 and APP_RAM_BASE-1 and the application's RAM region is located between + * APP_RAM_BASE and the start of the call stack. + * + * @details This call initializes the BLE stack, no BLE related function other than @ref + * sd_ble_cfg_set can be called before this one. + * + * @mscs + * @mmsc{@ref BLE_COMMON_ENABLE} + * @endmscs + * + * @retval ::NRF_SUCCESS The BLE stack has been initialized successfully. + * @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @retval ::NRF_ERROR_NO_MEM One or more of the following is true: + * - The amount of memory assigned to the SoftDevice by *p_app_ram_base is not + * large enough to fit this configuration's memory requirement. Check *p_app_ram_base + * and set the start address of the application RAM region accordingly. + * - Dynamic part of the SoftDevice RAM region is larger then 64 kB which + * is currently not supported. + * @retval ::NRF_ERROR_RESOURCES The total number of L2CAP Channels configured using @ref sd_ble_cfg_set is too large. + */ +SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(uint32_t * p_app_ram_base)); + +/**@brief Add configurations for the BLE stack + * + * @param[in] cfg_id Config ID, see @ref BLE_CONN_CFGS, @ref BLE_COMMON_CFGS, @ref + * BLE_GAP_CFGS or @ref BLE_GATTS_CFGS. + * @param[in] p_cfg Pointer to a ble_cfg_t structure containing the configuration value. + * @param[in] app_ram_base The start address of the application RAM region (APP_RAM_BASE). + * See @ref sd_ble_enable for details about APP_RAM_BASE. + * + * @note The memory requirement for a specific configuration will not increase between SoftDevices + * with the same major version number. + * + * @note If a configuration is set more than once, the last one set is the one that takes effect on + * @ref sd_ble_enable. + * + * @note Any part of the BLE stack that is NOT configured with @ref sd_ble_cfg_set will have default + * configuration. + * + * @note @ref sd_ble_cfg_set may be called at any time when the SoftDevice is enabled (see @ref + * sd_softdevice_enable) while the BLE part of the SoftDevice is not enabled (see @ref + * sd_ble_enable). + * + * @note Error codes for the configurations are described in the configuration structs. + * + * @mscs + * @mmsc{@ref BLE_COMMON_ENABLE} + * @endmscs + * + * @retval ::NRF_SUCCESS The configuration has been added successfully. + * @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid cfg_id supplied. + * @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by app_ram_base is not + * large enough to fit this configuration's memory requirement. + */ +SVCALL(SD_BLE_CFG_SET, uint32_t, sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base)); + +/**@brief Get an event from the pending events queue. + * + * @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. + * This buffer must be aligned to the extend defined by @ref BLE_EVT_PTR_ALIGNMENT. + * The buffer should be interpreted as a @ref ble_evt_t struct. + * @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length. + * + * @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that + * an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt. + * The application is free to choose whether to call this function from thread mode (main context) or directly from the + * Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher + * priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) + * every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so + * could potentially leave events in the internal queue without the application being aware of this fact. + * + * Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to + * be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event, + * @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size. + * The maximum possible event length is defined by @ref BLE_EVT_LEN_MAX. The application may also "peek" the event length + * by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return: + * + * \code + * uint16_t len; + * errcode = sd_ble_evt_get(NULL, &len); + * \endcode + * + * @mscs + * @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC} + * @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled. + * @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer. + */ +SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len)); + + +/**@brief Add a Vendor Specific base UUID. + * + * @details This call enables the application to add a Vendor Specific base UUID to the BLE stack's table, for later + * use with all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t + * format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code + * paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses + * for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to + * @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the UUID field + * in the same structure contains the 2 bytes at indexes 12 and 13. The number of possible 128-bit UUIDs available to + * the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, + * although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array. + * + * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by + * the 16-bit uuid field in @ref ble_uuid_t. + * + * @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in + * p_uuid_type along with an @ref NRF_SUCCESS error code. + * + * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific base UUID disregarding + * bytes 12 and 13. + * @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored. + * + * @retval ::NRF_SUCCESS Successfully added the Vendor Specific base UUID. + * @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid. + * @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs. + */ +SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type)); + + +/**@brief Remove a Vendor Specific base UUID. + * + * @details This call removes a Vendor Specific base UUID that has been added with @ref sd_ble_uuid_vs_add. This function allows + * the application to reuse memory allocated for Vendor Specific base UUIDs. + * + * @note Currently this function can only be called with a p_uuid_type set to @ref BLE_UUID_TYPE_UNKNOWN or the last added UUID type. + * + * @param[inout] p_uuid_type Pointer to a uint8_t where its value matches the UUID type in @ref ble_uuid_t::type to be removed. + * If the type is set to @ref BLE_UUID_TYPE_UNKNOWN, or the pointer is NULL, the last Vendor Specific + * base UUID will be removed. If the function returns successfully, the UUID type that was removed will + * be written back to @p p_uuid_type. If function returns with a failure, it contains the last type that + * is in use by the ATT Server. + * + * @retval ::NRF_SUCCESS Successfully removed the Vendor Specific base UUID. + * @retval ::NRF_ERROR_INVALID_ADDR If p_uuid_type is invalid. + * @retval ::NRF_ERROR_INVALID_PARAM If p_uuid_type points to a non-valid UUID type. + * @retval ::NRF_ERROR_FORBIDDEN If the Vendor Specific base UUID is in use by the ATT Server. + */ +SVCALL(SD_BLE_UUID_VS_REMOVE, uint32_t, sd_ble_uuid_vs_remove(uint8_t *p_uuid_type)); + + +/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure. + * + * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared + * to the corresponding ones in each entry of the table of Vendor Specific base UUIDs populated with @ref sd_ble_uuid_vs_add + * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index + * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type. + * + * @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE. + * + * @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes). + * @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes. + * @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length. + * @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs. + */ +SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid)); + + +/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit). + * + * @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed. + * + * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes. + * @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes). + * @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored. + * + * @retval ::NRF_SUCCESS Successfully encoded into the buffer. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type. + */ +SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le)); + + +/**@brief Get Version Information. + * + * @details This call allows the application to get the BLE stack version information. + * + * @param[out] p_version Pointer to a ble_version_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Version information stored successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure). + */ +SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version)); + + +/**@brief Provide a user memory block. + * + * @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_block Pointer to a user memory block structure or NULL if memory is managed by the application. + * + * @mscs + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_PEER_CANCEL_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully queued a response to the peer. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid user memory block length supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no user memory request pending. + */ +SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block)); + +/**@brief Set a BLE option. + * + * @details This call allows the application to set the value of an option. + * + * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS. + * @param[in] p_opt Pointer to a ble_opt_t structure containing the option value. + * + * @retval ::NRF_SUCCESS Option set successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed. + */ +SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt)); + + +/**@brief Get a BLE option. + * + * @details This call allows the application to retrieve the value of an option. + * + * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS. + * @param[out] p_opt Pointer to a ble_opt_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Option retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed. + * @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported. + * + */ +SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt)); + +/** @} */ +#ifdef __cplusplus +} +#endif +#endif /* BLE_H__ */ + +/** + @} + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_err.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_err.h new file mode 100644 index 0000000..1b4820d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_err.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 - 2018, 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. + */ + +/** + @addtogroup BLE_COMMON + @{ + @addtogroup nrf_error + @{ + @ingroup BLE_COMMON + @} + + @defgroup ble_err General error codes + @{ + + @brief General error code definitions for the BLE API. + + @ingroup BLE_COMMON +*/ +#ifndef NRF_BLE_ERR_H__ +#define NRF_BLE_ERR_H__ + +#include "nrf_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* @defgroup BLE_ERRORS Error Codes + * @{ */ +#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */ +#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */ +#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */ +#define BLE_ERROR_INVALID_ADV_HANDLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid advertising handle. */ +#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */ +#define BLE_ERROR_BLOCKED_BY_OTHER_LINKS (NRF_ERROR_STK_BASE_NUM+0x006) /**< The attempt to change link settings failed due to the scheduling of other links. */ +/** @} */ + + +/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges + * @brief Assignment of subranges for module specific error codes. + * @note For specific error codes, see ble_.h or ble_error_.h. + * @{ */ +#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ +#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ +#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ +#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif + + +/** + @} + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gap.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gap.h new file mode 100644 index 0000000..b78b267 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gap.h @@ -0,0 +1,2829 @@ +/* + * Copyright (c) 2011 - 2019, 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. + */ + +/** + @addtogroup BLE_GAP Generic Access Profile (GAP) + @{ + @brief Definitions and prototypes for the GAP interface. + */ + +#ifndef BLE_GAP_H__ +#define BLE_GAP_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup BLE_GAP_ENUMERATIONS Enumerations + * @{ */ + +/**@brief GAP API SVC numbers. + */ +enum BLE_GAP_SVCS +{ + SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */ + SD_BLE_GAP_ADDR_GET = BLE_GAP_SVC_BASE + 1, /**< Get own Bluetooth Address. */ + SD_BLE_GAP_WHITELIST_SET = BLE_GAP_SVC_BASE + 2, /**< Set active whitelist. */ + SD_BLE_GAP_DEVICE_IDENTITIES_SET = BLE_GAP_SVC_BASE + 3, /**< Set device identity list. */ + SD_BLE_GAP_PRIVACY_SET = BLE_GAP_SVC_BASE + 4, /**< Set Privacy settings*/ + SD_BLE_GAP_PRIVACY_GET = BLE_GAP_SVC_BASE + 5, /**< Get Privacy settings*/ + SD_BLE_GAP_ADV_SET_CONFIGURE = BLE_GAP_SVC_BASE + 6, /**< Configure an advertising set. */ + SD_BLE_GAP_ADV_START = BLE_GAP_SVC_BASE + 7, /**< Start Advertising. */ + SD_BLE_GAP_ADV_STOP = BLE_GAP_SVC_BASE + 8, /**< Stop Advertising. */ + SD_BLE_GAP_CONN_PARAM_UPDATE = BLE_GAP_SVC_BASE + 9, /**< Connection Parameter Update. */ + SD_BLE_GAP_DISCONNECT = BLE_GAP_SVC_BASE + 10, /**< Disconnect. */ + SD_BLE_GAP_TX_POWER_SET = BLE_GAP_SVC_BASE + 11, /**< Set TX Power. */ + SD_BLE_GAP_APPEARANCE_SET = BLE_GAP_SVC_BASE + 12, /**< Set Appearance. */ + SD_BLE_GAP_APPEARANCE_GET = BLE_GAP_SVC_BASE + 13, /**< Get Appearance. */ + SD_BLE_GAP_PPCP_SET = BLE_GAP_SVC_BASE + 14, /**< Set PPCP. */ + SD_BLE_GAP_PPCP_GET = BLE_GAP_SVC_BASE + 15, /**< Get PPCP. */ + SD_BLE_GAP_DEVICE_NAME_SET = BLE_GAP_SVC_BASE + 16, /**< Set Device Name. */ + SD_BLE_GAP_DEVICE_NAME_GET = BLE_GAP_SVC_BASE + 17, /**< Get Device Name. */ + SD_BLE_GAP_AUTHENTICATE = BLE_GAP_SVC_BASE + 18, /**< Initiate Pairing/Bonding. */ + SD_BLE_GAP_SEC_PARAMS_REPLY = BLE_GAP_SVC_BASE + 19, /**< Reply with Security Parameters. */ + SD_BLE_GAP_AUTH_KEY_REPLY = BLE_GAP_SVC_BASE + 20, /**< Reply with an authentication key. */ + SD_BLE_GAP_LESC_DHKEY_REPLY = BLE_GAP_SVC_BASE + 21, /**< Reply with an LE Secure Connections DHKey. */ + SD_BLE_GAP_KEYPRESS_NOTIFY = BLE_GAP_SVC_BASE + 22, /**< Notify of a keypress during an authentication procedure. */ + SD_BLE_GAP_LESC_OOB_DATA_GET = BLE_GAP_SVC_BASE + 23, /**< Get the local LE Secure Connections OOB data. */ + SD_BLE_GAP_LESC_OOB_DATA_SET = BLE_GAP_SVC_BASE + 24, /**< Set the remote LE Secure Connections OOB data. */ + SD_BLE_GAP_ENCRYPT = BLE_GAP_SVC_BASE + 25, /**< Initiate encryption procedure. */ + SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */ + SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */ + SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */ + SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */ + SD_BLE_GAP_SCAN_START = BLE_GAP_SVC_BASE + 30, /**< Start Scanning. */ + SD_BLE_GAP_SCAN_STOP = BLE_GAP_SVC_BASE + 31, /**< Stop Scanning. */ + SD_BLE_GAP_CONNECT = BLE_GAP_SVC_BASE + 32, /**< Connect. */ + SD_BLE_GAP_CONNECT_CANCEL = BLE_GAP_SVC_BASE + 33, /**< Cancel ongoing connection procedure. */ + SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */ + SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */ + SD_BLE_GAP_DATA_LENGTH_UPDATE = BLE_GAP_SVC_BASE + 36, /**< Initiate or respond to a Data Length Update Procedure. */ + SD_BLE_GAP_QOS_CHANNEL_SURVEY_START = BLE_GAP_SVC_BASE + 37, /**< Start Quality of Service (QoS) channel survey module. */ + SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP = BLE_GAP_SVC_BASE + 38, /**< Stop Quality of Service (QoS) channel survey module. */ + SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */ + SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET = BLE_GAP_SVC_BASE + 40, /**< Get the next connection event counter. */ + SD_BLE_GAP_CONN_EVT_TRIGGER_START = BLE_GAP_SVC_BASE + 41, /** Start triggering a given task on connection event start. */ + SD_BLE_GAP_CONN_EVT_TRIGGER_STOP = BLE_GAP_SVC_BASE + 42, /** Stop triggering the task configured using @ref sd_ble_gap_conn_evt_trigger_start. */ +}; + +/**@brief GAP Event IDs. + * IDs that uniquely identify an event coming from the stack to the application. + */ +enum BLE_GAP_EVTS +{ + BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connected to peer. \n See @ref ble_gap_evt_connected_t */ + BLE_GAP_EVT_DISCONNECTED = BLE_GAP_EVT_BASE + 1, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */ + BLE_GAP_EVT_CONN_PARAM_UPDATE = BLE_GAP_EVT_BASE + 2, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */ + BLE_GAP_EVT_SEC_PARAMS_REQUEST = BLE_GAP_EVT_BASE + 3, /**< Request to provide security parameters. \n Reply with @ref sd_ble_gap_sec_params_reply. \n See @ref ble_gap_evt_sec_params_request_t. */ + BLE_GAP_EVT_SEC_INFO_REQUEST = BLE_GAP_EVT_BASE + 4, /**< Request to provide security information. \n Reply with @ref sd_ble_gap_sec_info_reply. \n See @ref ble_gap_evt_sec_info_request_t. */ + BLE_GAP_EVT_PASSKEY_DISPLAY = BLE_GAP_EVT_BASE + 5, /**< Request to display a passkey to the user. \n In LESC Numeric Comparison, reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_passkey_display_t. */ + BLE_GAP_EVT_KEY_PRESSED = BLE_GAP_EVT_BASE + 6, /**< Notification of a keypress on the remote device.\n See @ref ble_gap_evt_key_pressed_t */ + BLE_GAP_EVT_AUTH_KEY_REQUEST = BLE_GAP_EVT_BASE + 7, /**< Request to provide an authentication key. \n Reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_auth_key_request_t. */ + BLE_GAP_EVT_LESC_DHKEY_REQUEST = BLE_GAP_EVT_BASE + 8, /**< Request to calculate an LE Secure Connections DHKey. \n Reply with @ref sd_ble_gap_lesc_dhkey_reply. \n See @ref ble_gap_evt_lesc_dhkey_request_t */ + BLE_GAP_EVT_AUTH_STATUS = BLE_GAP_EVT_BASE + 9, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */ + BLE_GAP_EVT_CONN_SEC_UPDATE = BLE_GAP_EVT_BASE + 10, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */ + BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */ + BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */ + BLE_GAP_EVT_ADV_REPORT = BLE_GAP_EVT_BASE + 13, /**< Advertising report. \n See @ref ble_gap_evt_adv_report_t. */ + BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n See @ref ble_gap_evt_sec_request_t. */ + BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 15, /**< Connection Parameter Update Request. \n Reply with @ref sd_ble_gap_conn_param_update. \n See @ref ble_gap_evt_conn_param_update_request_t. */ + BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */ + BLE_GAP_EVT_PHY_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 17, /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */ + BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */ + BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 19, /**< Data Length Update Request. \n Reply with @ref sd_ble_gap_data_length_update. \n See @ref ble_gap_evt_data_length_update_request_t. */ + BLE_GAP_EVT_DATA_LENGTH_UPDATE = BLE_GAP_EVT_BASE + 20, /**< LL Data Channel PDU payload length updated. \n See @ref ble_gap_evt_data_length_update_t. */ + BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT = BLE_GAP_EVT_BASE + 21, /**< Channel survey report. \n See @ref ble_gap_evt_qos_channel_survey_report_t. */ + BLE_GAP_EVT_ADV_SET_TERMINATED = BLE_GAP_EVT_BASE + 22, /**< Advertising set terminated. \n See @ref ble_gap_evt_adv_set_terminated_t. */ +}; + +/**@brief GAP Option IDs. + * IDs that uniquely identify a GAP option. + */ +enum BLE_GAP_OPTS +{ + BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */ + BLE_GAP_OPT_LOCAL_CONN_LATENCY = BLE_GAP_OPT_BASE + 1, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */ + BLE_GAP_OPT_PASSKEY = BLE_GAP_OPT_BASE + 2, /**< Set passkey. @ref ble_gap_opt_passkey_t */ + BLE_GAP_OPT_COMPAT_MODE_1 = BLE_GAP_OPT_BASE + 3, /**< Compatibility mode. @ref ble_gap_opt_compat_mode_1_t */ + BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT = BLE_GAP_OPT_BASE + 4, /**< Set Authenticated payload timeout. @ref ble_gap_opt_auth_payload_timeout_t */ + BLE_GAP_OPT_SLAVE_LATENCY_DISABLE = BLE_GAP_OPT_BASE + 5, /**< Disable slave latency. @ref ble_gap_opt_slave_latency_disable_t */ +}; + +/**@brief GAP Configuration IDs. + * + * IDs that uniquely identify a GAP configuration. + */ +enum BLE_GAP_CFGS +{ + BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */ + BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */ + BLE_GAP_CFG_PPCP_INCL_CONFIG = BLE_GAP_CFG_BASE + 2, /**< Peripheral Preferred Connection Parameters characteristic + inclusion configuration. */ + BLE_GAP_CFG_CAR_INCL_CONFIG = BLE_GAP_CFG_BASE + 3, /**< Central Address Resolution characteristic + inclusion configuration. */ +}; + +/**@brief GAP TX Power roles. + */ +enum BLE_GAP_TX_POWER_ROLES +{ + BLE_GAP_TX_POWER_ROLE_ADV = 1, /**< Advertiser role. */ + BLE_GAP_TX_POWER_ROLE_SCAN_INIT = 2, /**< Scanner and initiator role. */ + BLE_GAP_TX_POWER_ROLE_CONN = 3, /**< Connection role. */ +}; + +/** @} */ + +/**@addtogroup BLE_GAP_DEFINES Defines + * @{ */ + +/**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP + * @{ */ +#define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */ +#define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */ +#define BLE_ERROR_GAP_INVALID_BLE_ADDR (NRF_GAP_ERR_BASE + 0x002) /**< The upper two bits of the address do not correspond to the specified address type. */ +#define BLE_ERROR_GAP_WHITELIST_IN_USE (NRF_GAP_ERR_BASE + 0x003) /**< Attempt to modify the whitelist while already in use by another operation. */ +#define BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE (NRF_GAP_ERR_BASE + 0x004) /**< Attempt to modify the device identity list while already in use by another operation. */ +#define BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE (NRF_GAP_ERR_BASE + 0x005) /**< The device identity list contains entries with duplicate identity addresses. */ +/**@} */ + + +/**@defgroup BLE_GAP_ROLES GAP Roles + * @{ */ +#define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */ +#define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */ +#define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */ +/**@} */ + + +/**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources + * @{ */ +#define BLE_GAP_TIMEOUT_SRC_SCAN 0x01 /**< Scanning timeout. */ +#define BLE_GAP_TIMEOUT_SRC_CONN 0x02 /**< Connection timeout. */ +#define BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD 0x03 /**< Authenticated payload timeout. */ +/**@} */ + + +/**@defgroup BLE_GAP_ADDR_TYPES GAP Address types + * @{ */ +#define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public (identity) address.*/ +#define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random static (identity) address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Random private resolvable address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Random private non-resolvable address. */ +#define BLE_GAP_ADDR_TYPE_ANONYMOUS 0x7F /**< An advertiser may advertise without its address. + This type of advertising is called anonymous. */ +/**@} */ + + +/**@brief The default interval in seconds at which a private address is refreshed. */ +#define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (900) /* 15 minutes. */ +/**@brief The maximum interval in seconds at which a private address can be refreshed. */ +#define BLE_GAP_MAX_PRIVATE_ADDR_CYCLE_INTERVAL_S (41400) /* 11 hours 30 minutes. */ + + +/** @brief BLE address length. */ +#define BLE_GAP_ADDR_LEN (6) + +/**@defgroup BLE_GAP_PRIVACY_MODES Privacy modes + * @{ */ +#define BLE_GAP_PRIVACY_MODE_OFF 0x00 /**< Device will send and accept its identity address for its own address. */ +#define BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY 0x01 /**< Device will send and accept only private addresses for its own address. */ +#define BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY 0x02 /**< Device will send and accept only private addresses for its own address, + and will not accept a peer using identity address as sender address when + the peer IRK is exchanged, non-zero and added to the identity list. */ +/**@} */ + +/** @brief Invalid power level. */ +#define BLE_GAP_POWER_LEVEL_INVALID 127 + +/** @brief Advertising set handle not set. */ +#define BLE_GAP_ADV_SET_HANDLE_NOT_SET (0xFF) + +/** @brief The default number of advertising sets. */ +#define BLE_GAP_ADV_SET_COUNT_DEFAULT (1) + +/** @brief The maximum number of advertising sets supported by this SoftDevice. */ +#define BLE_GAP_ADV_SET_COUNT_MAX (1) + +/**@defgroup BLE_GAP_ADV_SET_DATA_SIZES Advertising data sizes. + * @{ */ +#define BLE_GAP_ADV_SET_DATA_SIZE_MAX (31) /**< Maximum data length for an advertising set. + If more advertising data is required, use extended advertising instead. */ +#define BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED (255) /**< Maximum supported data length for an extended advertising set. */ + +#define BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED (238) /**< Maximum supported data length for an extended connectable advertising set. */ +/**@}. */ + +/** @brief Set ID not available in advertising report. */ +#define BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE 0xFF + +/**@defgroup BLE_GAP_EVT_ADV_SET_TERMINATED_REASON GAP Advertising Set Terminated reasons + * @{ */ +#define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT 0x01 /**< Timeout value reached. */ +#define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_LIMIT_REACHED 0x02 /**< @ref ble_gap_adv_params_t::max_adv_evts was reached. */ +/**@} */ + +/**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format + * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm + * @{ */ +#define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */ +#define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */ +#define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */ +#define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */ +#define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */ +#define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */ +#define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */ +#define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */ +#define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */ +#define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID. */ +#define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */ +#define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */ +#define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */ +#define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL 0x1A /**< Advertising Interval. */ +#define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 0x1B /**< LE Bluetooth Device Address. */ +#define BLE_GAP_AD_TYPE_LE_ROLE 0x1C /**< LE Role. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256 0x1D /**< Simple Pairing Hash C-256. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 0x1E /**< Simple Pairing Randomizer R-256. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID 0x20 /**< Service Data - 32-bit UUID. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID 0x21 /**< Service Data - 128-bit UUID. */ +#define BLE_GAP_AD_TYPE_LESC_CONFIRMATION_VALUE 0x22 /**< LE Secure Connections Confirmation Value */ +#define BLE_GAP_AD_TYPE_LESC_RANDOM_VALUE 0x23 /**< LE Secure Connections Random Value */ +#define BLE_GAP_AD_TYPE_URI 0x24 /**< URI */ +#define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA 0x3D /**< 3D Information Data. */ +#define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */ +/**@} */ + + +/**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags + * @{ */ +#define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */ +#define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */ +#define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */ +#define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */ +#define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */ +#define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE Limited Discoverable Mode, BR/EDR not supported. */ +#define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE General Discoverable Mode, BR/EDR not supported. */ +/**@} */ + + +/**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min + * @{ */ +#define BLE_GAP_ADV_INTERVAL_MIN 0x000020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ +#define BLE_GAP_ADV_INTERVAL_MAX 0x004000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ + /**@} */ + + +/**@defgroup BLE_GAP_SCAN_INTERVALS GAP Scan interval max and min + * @{ */ +#define BLE_GAP_SCAN_INTERVAL_MIN 0x0004 /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */ +#define BLE_GAP_SCAN_INTERVAL_MAX 0xFFFF /**< Maximum Scan interval in 625 us units, i.e. 40,959.375 s. */ + /** @} */ + + +/**@defgroup BLE_GAP_SCAN_WINDOW GAP Scan window max and min + * @{ */ +#define BLE_GAP_SCAN_WINDOW_MIN 0x0004 /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */ +#define BLE_GAP_SCAN_WINDOW_MAX 0xFFFF /**< Maximum Scan window in 625 us units, i.e. 40,959.375 s. */ + /** @} */ + + +/**@defgroup BLE_GAP_SCAN_TIMEOUT GAP Scan timeout max and min + * @{ */ +#define BLE_GAP_SCAN_TIMEOUT_MIN 0x0001 /**< Minimum Scan timeout in 10 ms units, i.e 10 ms. */ +#define BLE_GAP_SCAN_TIMEOUT_UNLIMITED 0x0000 /**< Continue to scan forever. */ + /** @} */ + +/**@defgroup BLE_GAP_SCAN_BUFFER_SIZE GAP Minimum scanner buffer size + * + * Scan buffers are used for storing advertising data received from an advertiser. + * If ble_gap_scan_params_t::extended is set to 0, @ref BLE_GAP_SCAN_BUFFER_MIN is the minimum scan buffer length. + * else the minimum scan buffer size is @ref BLE_GAP_SCAN_BUFFER_EXTENDED_MIN. + * @{ */ +#define BLE_GAP_SCAN_BUFFER_MIN (31) /**< Minimum data length for an + advertising set. */ +#define BLE_GAP_SCAN_BUFFER_MAX (31) /**< Maximum data length for an + advertising set. */ +#define BLE_GAP_SCAN_BUFFER_EXTENDED_MIN (255) /**< Minimum data length for an + extended advertising set. */ +#define BLE_GAP_SCAN_BUFFER_EXTENDED_MAX (1650) /**< Maximum data length for an + extended advertising set. */ +#define BLE_GAP_SCAN_BUFFER_EXTENDED_MAX_SUPPORTED (255) /**< Maximum supported data length for + an extended advertising set. */ +/** @} */ + +/**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types + * + * Advertising types defined in Bluetooth Core Specification v5.0, Vol 6, Part B, Section 4.4.2. + * + * The maximum advertising data length is defined by @ref BLE_GAP_ADV_SET_DATA_SIZE_MAX. + * The maximum supported data length for an extended advertiser is defined by + * @ref BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED + * Note that some of the advertising types do not support advertising data. Non-scannable types do not support + * scan response data. + * + * @{ */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED 0x01 /**< Connectable and scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE 0x02 /**< Connectable non-scannable directed advertising + events. Advertising interval is less that 3.75 ms. + Use this type for fast reconnections. + @note Advertising data is not supported. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED 0x03 /**< Connectable non-scannable directed advertising + events. + @note Advertising data is not supported. */ +#define BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x04 /**< Non-connectable scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x05 /**< Non-connectable non-scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED 0x06 /**< Connectable non-scannable undirected advertising + events using extended advertising PDUs. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_DIRECTED 0x07 /**< Connectable non-scannable directed advertising + events using extended advertising PDUs. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x08 /**< Non-connectable scannable undirected advertising + events using extended advertising PDUs. + @note Only scan response data is supported. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_DIRECTED 0x09 /**< Non-connectable scannable directed advertising + events using extended advertising PDUs. + @note Only scan response data is supported. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x0A /**< Non-connectable non-scannable undirected advertising + events using extended advertising PDUs. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED 0x0B /**< Non-connectable non-scannable directed advertising + events using extended advertising PDUs. */ +/**@} */ + +/**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies + * @{ */ +#define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */ +#define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */ +#define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */ +#define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */ +/**@} */ + +/**@defgroup BLE_GAP_ADV_DATA_STATUS GAP Advertising data status + * @{ */ +#define BLE_GAP_ADV_DATA_STATUS_COMPLETE 0x00 /**< All data in the advertising event have been received. */ +#define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA 0x01 /**< More data to be received. + @note This value will only be used if + @ref ble_gap_scan_params_t::report_incomplete_evts and + @ref ble_gap_adv_report_type_t::extended_pdu are set to true. */ +#define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED 0x02 /**< Incomplete data. Buffer size insufficient to receive more. + @note This value will only be used if + @ref ble_gap_adv_report_type_t::extended_pdu is set to true. */ +#define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MISSED 0x03 /**< Failed to receive the remaining data. + @note This value will only be used if + @ref ble_gap_adv_report_type_t::extended_pdu is set to true. */ +/**@} */ + +/**@defgroup BLE_GAP_SCAN_FILTER_POLICIES GAP Scanner filter policies + * @{ */ +#define BLE_GAP_SCAN_FP_ACCEPT_ALL 0x00 /**< Accept all advertising packets except directed advertising packets + not addressed to this device. */ +#define BLE_GAP_SCAN_FP_WHITELIST 0x01 /**< Accept advertising packets from devices in the whitelist except directed + packets not addressed to this device. */ +#define BLE_GAP_SCAN_FP_ALL_NOT_RESOLVED_DIRECTED 0x02 /**< Accept all advertising packets specified in @ref BLE_GAP_SCAN_FP_ACCEPT_ALL. + In addition, accept directed advertising packets, where the advertiser's + address is a resolvable private address that cannot be resolved. */ +#define BLE_GAP_SCAN_FP_WHITELIST_NOT_RESOLVED_DIRECTED 0x03 /**< Accept all advertising packets specified in @ref BLE_GAP_SCAN_FP_WHITELIST. + In addition, accept directed advertising packets, where the advertiser's + address is a resolvable private address that cannot be resolved. */ +/**@} */ + +/**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values in 10 ms units + * @{ */ +#define BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX (128) /**< Maximum high duty advertising time in 10 ms units. Corresponds to 1.28 s. */ +#define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX (18000) /**< Maximum advertising time in 10 ms units corresponding to TGAP(lim_adv_timeout) = 180 s in limited discoverable mode. */ +#define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) /**< Unlimited advertising in general discoverable mode. + For high duty cycle advertising, this corresponds to @ref BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX. */ +/**@} */ + + +/**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes + * @{ */ +#define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */ +#define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */ +#define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */ +/**@} */ + + +/**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities + * @{ */ +#define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */ +#define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */ +#define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */ +#define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */ +#define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */ +/**@} */ + + +/**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types + * @{ */ +#define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */ +#define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */ +#define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */ +/**@} */ + + +/**@defgroup BLE_GAP_KP_NOT_TYPES GAP Keypress Notification Types + * @{ */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_START 0x00 /**< Passkey entry started. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_IN 0x01 /**< Passkey digit entered. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_OUT 0x02 /**< Passkey digit erased. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_CLEAR 0x03 /**< Passkey cleared. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_END 0x04 /**< Passkey entry completed. */ +/**@} */ + + +/**@defgroup BLE_GAP_SEC_STATUS GAP Security status + * @{ */ +#define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Procedure completed with success. */ +#define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */ +#define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE1_BEGIN 0x03 /**< Reserved for Future Use range #1 begin. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE1_END 0x80 /**< Reserved for Future Use range #1 end. */ +#define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user canceled or other). */ +#define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */ +#define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */ +#define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */ +#define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */ +#define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */ +#define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */ +#define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */ +#define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */ +#define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */ +#define BLE_GAP_SEC_STATUS_DHKEY_FAILURE 0x8B /**< DHKey check failure. */ +#define BLE_GAP_SEC_STATUS_NUM_COMP_FAILURE 0x8C /**< Numeric Comparison failure. */ +#define BLE_GAP_SEC_STATUS_BR_EDR_IN_PROG 0x8D /**< BR/EDR pairing in progress. */ +#define BLE_GAP_SEC_STATUS_X_TRANS_KEY_DISALLOWED 0x8E /**< BR/EDR Link Key cannot be used for LE keys. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE2_BEGIN 0x8F /**< Reserved for Future Use range #2 begin. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE2_END 0xFF /**< Reserved for Future Use range #2 end. */ +/**@} */ + + +/**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources + * @{ */ +#define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */ +#define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */ +/**@} */ + + +/**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits + * @{ */ +#define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connection interval specified in connect parameters. */ +#define BLE_GAP_CP_MIN_CONN_INTVL_MIN 0x0006 /**< Lowest minimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */ +#define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connection interval specified in connect parameters. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_MIN 0x0006 /**< Lowest maximum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ +#define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x01F3 /**< Highest slave latency permitted, in connection events. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */ +/**@} */ + + +/**@defgroup BLE_GAP_DEVNAME GAP device name defines. + * @{ */ +#define BLE_GAP_DEVNAME_DEFAULT "nRF5x" /**< Default device name value. */ +#define BLE_GAP_DEVNAME_DEFAULT_LEN 31 /**< Default number of octets in device name. */ +#define BLE_GAP_DEVNAME_MAX_LEN 248 /**< Maximum number of octets in device name. */ +/**@} */ + + +/**@brief Disable RSSI events for connections */ +#define BLE_GAP_RSSI_THRESHOLD_INVALID 0xFF + +/**@defgroup BLE_GAP_PHYS GAP PHYs + * @{ */ +#define BLE_GAP_PHY_AUTO 0x00 /**< Automatic PHY selection. Refer @ref sd_ble_gap_phy_update for more information.*/ +#define BLE_GAP_PHY_1MBPS 0x01 /**< 1 Mbps PHY. */ +#define BLE_GAP_PHY_2MBPS 0x02 /**< 2 Mbps PHY. */ +#define BLE_GAP_PHY_CODED 0x04 /**< Coded PHY. */ +#define BLE_GAP_PHY_NOT_SET 0xFF /**< PHY is not configured. */ + +/**@brief Supported PHYs in connections, for scanning, and for advertising. */ +#define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS) /**< All PHYs except @ref BLE_GAP_PHY_CODED are supported. */ + +/**@} */ + +/**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters + * + * See @ref ble_gap_conn_sec_mode_t. + * @{ */ +/**@brief Set sec_mode pointed to by ptr to have no access rights.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0) +/**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0) +/**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0) +/**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0) +/**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 4;} while(0) +/**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0) +/**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0) +/**@} */ + + +/**@brief GAP Security Random Number Length. */ +#define BLE_GAP_SEC_RAND_LEN 8 + + +/**@brief GAP Security Key Length. */ +#define BLE_GAP_SEC_KEY_LEN 16 + + +/**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key Length. */ +#define BLE_GAP_LESC_P256_PK_LEN 64 + + +/**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman DHKey Length. */ +#define BLE_GAP_LESC_DHKEY_LEN 32 + + +/**@brief GAP Passkey Length. */ +#define BLE_GAP_PASSKEY_LEN 6 + + +/**@brief Maximum amount of addresses in the whitelist. */ +#define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8) + + +/**@brief Maximum amount of identities in the device identities list. */ +#define BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT (8) + + +/**@brief Default connection count for a configuration. */ +#define BLE_GAP_CONN_COUNT_DEFAULT (1) + + +/**@defgroup BLE_GAP_EVENT_LENGTH GAP event length defines. + * @{ */ +#define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */ +#define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */ +/**@} */ + + +/**@defgroup BLE_GAP_ROLE_COUNT GAP concurrent connection count defines. + * @{ */ +#define BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT (1) /**< Default maximum number of connections concurrently acting as peripherals. */ +#define BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT (3) /**< Default maximum number of connections concurrently acting as centrals. */ +#define BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT (1) /**< Default number of SMP instances shared between all connections acting as centrals. */ +#define BLE_GAP_ROLE_COUNT_COMBINED_MAX (20) /**< Maximum supported number of concurrent connections in the peripheral and central roles combined. */ + +/**@} */ + +/**@brief Automatic data length parameter. */ +#define BLE_GAP_DATA_LENGTH_AUTO 0 + +/**@defgroup BLE_GAP_AUTH_PAYLOAD_TIMEOUT Authenticated payload timeout defines. + * @{ */ +#define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX (48000) /**< Maximum authenticated payload timeout in 10 ms units, i.e. 8 minutes. */ +#define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MIN (1) /**< Minimum authenticated payload timeout in 10 ms units, i.e. 10 ms. */ +/**@} */ + +/**@defgroup GAP_SEC_MODES GAP Security Modes + * @{ */ +#define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */ +/**@} */ + +/**@brief The total number of channels in Bluetooth Low Energy. */ +#define BLE_GAP_CHANNEL_COUNT (40) + +/**@defgroup BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS Quality of Service (QoS) Channel survey interval defines + * @{ */ +#define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS (0) /**< Continuous channel survey. */ +#define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_MIN_US (7500) /**< Minimum channel survey interval in microseconds (7.5 ms). */ +#define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_MAX_US (4000000) /**< Maximum channel survey interval in microseconds (4 s). */ + /**@} */ + +/** @} */ + +/** @defgroup BLE_GAP_CHAR_INCL_CONFIG GAP Characteristic inclusion configurations + * @{ + */ +#define BLE_GAP_CHAR_INCL_CONFIG_INCLUDE (0) /**< Include the characteristic in the Attribute Table */ +#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITH_SPACE (1) /**< Do not include the characteristic in the Attribute table. + The SoftDevice will reserve the attribute handles + which are otherwise used for this characteristic. + By reserving the attribute handles it will be possible + to upgrade the SoftDevice without changing handle of the + Service Changed characteristic. */ +#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE (2) /**< Do not include the characteristic in the Attribute table. + The SoftDevice will not reserve the attribute handles + which are otherwise used for this characteristic. */ +/**@} */ + + +/** @defgroup BLE_GAP_CHAR_INCL_CONFIG_DEFAULTS Characteristic inclusion default values + * @{ */ +#define BLE_GAP_PPCP_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */ +#define BLE_GAP_CAR_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */ +/**@} */ + +/**@addtogroup BLE_GAP_STRUCTURES Structures + * @{ */ + +/**@brief Advertising event properties. */ +typedef struct +{ + uint8_t type; /**< Advertising type. See @ref BLE_GAP_ADV_TYPES. */ + uint8_t anonymous : 1; /**< Omit advertiser's address from all PDUs. + @note Anonymous advertising is only available for + @ref BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED and + @ref BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED. */ + uint8_t include_tx_power : 1; /**< This feature is not supported on this SoftDevice. */ +} ble_gap_adv_properties_t; + + +/**@brief Advertising report type. */ +typedef struct +{ + uint16_t connectable : 1; /**< Connectable advertising event type. */ + uint16_t scannable : 1; /**< Scannable advertising event type. */ + uint16_t directed : 1; /**< Directed advertising event type. */ + uint16_t scan_response : 1; /**< Received a scan response. */ + uint16_t extended_pdu : 1; /**< Received an extended advertising set. */ + uint16_t status : 2; /**< Data status. See @ref BLE_GAP_ADV_DATA_STATUS. */ + uint16_t reserved : 9; /**< Reserved for future use. */ +} ble_gap_adv_report_type_t; + +/**@brief Advertising Auxiliary Pointer. */ +typedef struct +{ + uint16_t aux_offset; /**< Time offset from the beginning of advertising packet to the auxiliary packet in 100 us units. */ + uint8_t aux_phy; /**< Indicates the PHY on which the auxiliary advertising packet is sent. See @ref BLE_GAP_PHYS. */ +} ble_gap_aux_pointer_t; + +/**@brief Bluetooth Low Energy address. */ +typedef struct +{ + uint8_t addr_id_peer : 1; /**< Only valid for peer addresses. + This bit is set by the SoftDevice to indicate whether the address has been resolved from + a Resolvable Private Address (when the peer is using privacy). + If set to 1, @ref addr and @ref addr_type refer to the identity address of the resolved address. + + This bit is ignored when a variable of type @ref ble_gap_addr_t is used as input to API functions. */ + uint8_t addr_type : 7; /**< See @ref BLE_GAP_ADDR_TYPES. */ + uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. + @ref addr is not used if @ref addr_type is @ref BLE_GAP_ADDR_TYPE_ANONYMOUS. */ +} ble_gap_addr_t; + + +/**@brief GAP connection parameters. + * + * @note When ble_conn_params_t is received in an event, both min_conn_interval and + * max_conn_interval will be equal to the connection interval set by the central. + * + * @note If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies: + * conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval + * that corresponds to the following Bluetooth Spec requirement: + * The Supervision_Timeout in milliseconds shall be larger than + * (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds. + */ +typedef struct +{ + uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/ +} ble_gap_conn_params_t; + + +/**@brief GAP connection security modes. + * + * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n + * Security Mode 1 Level 1: No security is needed (aka open link).\n + * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n + * Security Mode 1 Level 3: MITM protected encrypted link required.\n + * Security Mode 1 Level 4: LESC MITM protected encrypted link using a 128-bit strength encryption key required.\n + * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n + * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n + */ +typedef struct +{ + uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */ + uint8_t lv : 4; /**< Level (1, 2, 3 or 4), 0 for no permissions at all. */ + +} ble_gap_conn_sec_mode_t; + + +/**@brief GAP connection security status.*/ +typedef struct +{ + ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/ + uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */ +} ble_gap_conn_sec_t; + +/**@brief Identity Resolving Key. */ +typedef struct +{ + uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */ +} ble_gap_irk_t; + + +/**@brief Channel mask (40 bits). + * Every channel is represented with a bit positioned as per channel index defined in Bluetooth Core Specification v5.0, + * Vol 6, Part B, Section 1.4.1. The LSB contained in array element 0 represents channel index 0, and bit 39 represents + * channel index 39. If a bit is set to 1, the channel is not used. + */ +typedef uint8_t ble_gap_ch_mask_t[5]; + + +/**@brief GAP advertising parameters. */ +typedef struct +{ + ble_gap_adv_properties_t properties; /**< The properties of the advertising events. */ + ble_gap_addr_t const *p_peer_addr; /**< Address of a known peer. + @note ble_gap_addr_t::addr_type cannot be + @ref BLE_GAP_ADDR_TYPE_ANONYMOUS. + - When privacy is enabled and the local device uses + @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE addresses, + the device identity list is searched for a matching entry. If + the local IRK for that device identity is set, the local IRK + for that device will be used to generate the advertiser address + field in the advertising packet. + - If @ref ble_gap_adv_properties_t::type is directed, this must be + set to the targeted scanner or initiator. If the peer address is + in the device identity list, the peer IRK for that device will be + used to generate @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE + target addresses used in the advertising event PDUs. */ + uint32_t interval; /**< Advertising interval in 625 us units. @sa BLE_GAP_ADV_INTERVALS. + @note If @ref ble_gap_adv_properties_t::type is set to + @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE + advertising, this parameter is ignored. */ + uint16_t duration; /**< Advertising duration in 10 ms units. When timeout is reached, + an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised. + @sa BLE_GAP_ADV_TIMEOUT_VALUES. + @note The SoftDevice will always complete at least one advertising + event even if the duration is set too low. */ + uint8_t max_adv_evts; /**< Maximum advertising events that shall be sent prior to disabling + advertising. Setting the value to 0 disables the limitation. When + the count of advertising events specified by this parameter + (if not 0) is reached, advertising will be automatically stopped + and an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised + @note If @ref ble_gap_adv_properties_t::type is set to + @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE, + this parameter is ignored. */ + ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels. + At least one of the primary channels, that is channel index 37-39, must be used. + Masking away secondary advertising channels is not supported. */ + uint8_t filter_policy; /**< Filter Policy. @sa BLE_GAP_ADV_FILTER_POLICIES. */ + uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets + are transmitted. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS + will be used. + The only supported value by this SoftDevice is @ref BLE_GAP_PHY_1MBPS. */ + uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising channel packets + are transmitted. + If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS will be used. + Valid values are + @ref BLE_GAP_PHY_1MBPS and @ref BLE_GAP_PHY_2MBPS. @ref BLE_GAP_PHY_CODED + is not supported by this SoftDevice. + If @ref ble_gap_adv_properties_t::type is an extended advertising type + and connectable, this is the PHY that will be used to establish a + connection and send AUX_ADV_IND packets on. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is not an extended advertising type. */ + uint8_t set_id:4; /**< The advertising set identifier distinguishes this advertising set from other + advertising sets transmitted by this and other devices. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is not an extended advertising type. */ + uint8_t scan_req_notification:1; /**< Enable scan request notifications for this advertising set. When a + scan request is received and the scanner address is allowed + by the filter policy, @ref BLE_GAP_EVT_SCAN_REQ_REPORT is raised. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is a non-scannable + advertising type. */ +} ble_gap_adv_params_t; + + +/**@brief GAP advertising data buffers. + * + * The application must provide the buffers for advertisement. The memory shall reside in application RAM, and + * shall never be modified while advertising. The data shall be kept alive until either: + * - @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised. + * - @ref BLE_GAP_EVT_CONNECTED is raised with @ref ble_gap_evt_connected_t::adv_handle set to the corresponding + * advertising handle. + * - Advertising is stopped. + * - Advertising data is changed. + * To update advertising data while advertising, provide new buffers to @ref sd_ble_gap_adv_set_configure. */ +typedef struct +{ + ble_data_t adv_data; /**< Advertising data. + @note + Advertising data can only be specified for a @ref ble_gap_adv_properties_t::type + that is allowed to contain advertising data. */ + ble_data_t scan_rsp_data; /**< Scan response data. + @note + Scan response data can only be specified for a @ref ble_gap_adv_properties_t::type + that is scannable. */ +} ble_gap_adv_data_t; + + +/**@brief GAP scanning parameters. */ +typedef struct +{ + uint8_t extended : 1; /**< If 1, the scanner will accept extended advertising packets. + If set to 0, the scanner will not receive advertising packets + on secondary advertising channels, and will not be able + to receive long advertising PDUs. */ + uint8_t report_incomplete_evts : 1; /**< If 1, events of type @ref ble_gap_evt_adv_report_t may have + @ref ble_gap_adv_report_type_t::status set to + @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. + This parameter is ignored when used with @ref sd_ble_gap_connect + @note This may be used to abort receiving more packets from an extended + advertising event, and is only available for extended + scanning, see @ref sd_ble_gap_scan_start. + @note This feature is not supported by this SoftDevice. */ + uint8_t active : 1; /**< If 1, perform active scanning by sending scan requests. + This parameter is ignored when used with @ref sd_ble_gap_connect. */ + uint8_t filter_policy : 2; /**< Scanning filter policy. @sa BLE_GAP_SCAN_FILTER_POLICIES. + @note Only @ref BLE_GAP_SCAN_FP_ACCEPT_ALL and + @ref BLE_GAP_SCAN_FP_WHITELIST are valid when used with + @ref sd_ble_gap_connect */ + uint8_t scan_phys; /**< Bitfield of PHYs to scan on. If set to @ref BLE_GAP_PHY_AUTO, + scan_phys will default to @ref BLE_GAP_PHY_1MBPS. + - If @ref ble_gap_scan_params_t::extended is set to 0, the only + supported PHY is @ref BLE_GAP_PHY_1MBPS. + - When used with @ref sd_ble_gap_scan_start, + the bitfield indicates the PHYs the scanner will use for scanning + on primary advertising channels. The scanner will accept + @ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs. + - When used with @ref sd_ble_gap_connect, the bitfield indicates + the PHYs the initiator will use for scanning on primary advertising + channels. The initiator will accept connections initiated on either + of the @ref BLE_GAP_PHYS_SUPPORTED PHYs. + If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS, + the primary scan PHY is @ref BLE_GAP_PHY_1MBPS. */ + uint16_t interval; /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */ + uint16_t window; /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW. */ + uint16_t timeout; /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */ + ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels. + At least one of the primary channels, that is channel index 37-39, must be + set to 0. + Masking away secondary channels is not supported. */ +} ble_gap_scan_params_t; + + +/**@brief Privacy. + * + * The privacy feature provides a way for the device to avoid being tracked over a period of time. + * The privacy feature, when enabled, hides the local device identity and replaces it with a private address + * that is automatically refreshed at a specified interval. + * + * If a device still wants to be recognized by other peers, it needs to share it's Identity Resolving Key (IRK). + * With this key, a device can generate a random private address that can only be recognized by peers in possession of that key, + * and devices can establish connections without revealing their real identities. + * + * Both network privacy (@ref BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY) and device privacy (@ref BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY) + * are supported. + * + * @note If the device IRK is updated, the new IRK becomes the one to be distributed in all + * bonding procedures performed after @ref sd_ble_gap_privacy_set returns. + * The IRK distributed during bonding procedure is the device IRK that is active when @ref sd_ble_gap_sec_params_reply is called. + */ +typedef struct +{ + uint8_t privacy_mode; /**< Privacy mode, see @ref BLE_GAP_PRIVACY_MODES. Default is @ref BLE_GAP_PRIVACY_MODE_OFF. */ + uint8_t private_addr_type; /**< The private address type must be either @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. */ + uint16_t private_addr_cycle_s; /**< Private address cycle interval in seconds. Providing an address cycle value of 0 will use the default value defined by @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S. */ + ble_gap_irk_t *p_device_irk; /**< When used as input, pointer to IRK structure that will be used as the default IRK. If NULL, the device default IRK will be used. + When used as output, pointer to IRK structure where the current default IRK will be written to. If NULL, this argument is ignored. + By default, the default IRK is used to generate random private resolvable addresses for the local device unless instructed otherwise. */ +} ble_gap_privacy_params_t; + + +/**@brief PHY preferences for TX and RX + * @note tx_phys and rx_phys are bit fields. Multiple bits can be set in them to indicate multiple preferred PHYs for each direction. + * @code + * p_gap_phys->tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS; + * p_gap_phys->rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS; + * @endcode + * + */ +typedef struct +{ + uint8_t tx_phys; /**< Preferred transmit PHYs, see @ref BLE_GAP_PHYS. */ + uint8_t rx_phys; /**< Preferred receive PHYs, see @ref BLE_GAP_PHYS. */ +} ble_gap_phys_t; + +/** @brief Keys that can be exchanged during a bonding procedure. */ +typedef struct +{ + uint8_t enc : 1; /**< Long Term Key and Master Identification. */ + uint8_t id : 1; /**< Identity Resolving Key and Identity Address Information. */ + uint8_t sign : 1; /**< Connection Signature Resolving Key. */ + uint8_t link : 1; /**< Derive the Link Key from the LTK. */ +} ble_gap_sec_kdist_t; + + +/**@brief GAP security parameters. */ +typedef struct +{ + uint8_t bond : 1; /**< Perform bonding. */ + uint8_t mitm : 1; /**< Enable Man In The Middle protection. */ + uint8_t lesc : 1; /**< Enable LE Secure Connection pairing. */ + uint8_t keypress : 1; /**< Enable generation of keypress notifications. */ + uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */ + uint8_t oob : 1; /**< The OOB data flag. + - In LE legacy pairing, this flag is set if a device has out of band authentication data. + The OOB method is used if both of the devices have out of band authentication data. + - In LE Secure Connections pairing, this flag is set if a device has the peer device's out of band authentication data. + The OOB method is used if at least one device has the peer device's OOB data available. */ + uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */ + uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */ + ble_gap_sec_kdist_t kdist_own; /**< Key distribution bitmap: keys that the local device will distribute. */ + ble_gap_sec_kdist_t kdist_peer; /**< Key distribution bitmap: keys that the remote device will distribute. */ +} ble_gap_sec_params_t; + + +/**@brief GAP Encryption Information. */ +typedef struct +{ + uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */ + uint8_t lesc : 1; /**< Key generated using LE Secure Connections. */ + uint8_t auth : 1; /**< Authenticated Key. */ + uint8_t ltk_len : 6; /**< LTK length in octets. */ +} ble_gap_enc_info_t; + + +/**@brief GAP Master Identification. */ +typedef struct +{ + uint16_t ediv; /**< Encrypted Diversifier. */ + uint8_t rand[BLE_GAP_SEC_RAND_LEN]; /**< Random Number. */ +} ble_gap_master_id_t; + + +/**@brief GAP Signing Information. */ +typedef struct +{ + uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /**< Connection Signature Resolving Key. */ +} ble_gap_sign_info_t; + + +/**@brief GAP LE Secure Connections P-256 Public Key. */ +typedef struct +{ + uint8_t pk[BLE_GAP_LESC_P256_PK_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key. Stored in the standard SMP protocol format: {X,Y} both in little-endian. */ +} ble_gap_lesc_p256_pk_t; + + +/**@brief GAP LE Secure Connections DHKey. */ +typedef struct +{ + uint8_t key[BLE_GAP_LESC_DHKEY_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman Key. Stored in little-endian. */ +} ble_gap_lesc_dhkey_t; + + +/**@brief GAP LE Secure Connections OOB data. */ +typedef struct +{ + ble_gap_addr_t addr; /**< Bluetooth address of the device. */ + uint8_t r[BLE_GAP_SEC_KEY_LEN]; /**< Random Number. */ + uint8_t c[BLE_GAP_SEC_KEY_LEN]; /**< Confirm Value. */ +} ble_gap_lesc_oob_data_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONNECTED. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1 + and the address is the device's identity address. */ + uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ + uint8_t adv_handle; /**< Advertising handle in which advertising has ended. + This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */ + ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated + advertising set. The advertising buffers provided in + @ref sd_ble_gap_adv_set_configure are now released. + This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */ +} ble_gap_evt_connected_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_DISCONNECTED. */ +typedef struct +{ + uint8_t reason; /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */ +} ble_gap_evt_disconnected_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE. */ +typedef struct +{ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ +} ble_gap_evt_conn_param_update_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST. */ +typedef struct +{ + ble_gap_phys_t peer_preferred_phys; /**< The PHYs the peer prefers to use. */ +} ble_gap_evt_phy_update_request_t; + +/**@brief Event Structure for @ref BLE_GAP_EVT_PHY_UPDATE. */ +typedef struct +{ + uint8_t status; /**< Status of the procedure, see @ref BLE_HCI_STATUS_CODES.*/ + uint8_t tx_phy; /**< TX PHY for this connection, see @ref BLE_GAP_PHYS. */ + uint8_t rx_phy; /**< RX PHY for this connection, see @ref BLE_GAP_PHYS. */ +} ble_gap_evt_phy_update_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. */ +typedef struct +{ + ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */ +} ble_gap_evt_sec_params_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_SEC_INFO_REQUEST. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */ + ble_gap_master_id_t master_id; /**< Master Identification for LTK lookup. */ + uint8_t enc_info : 1; /**< If 1, Encryption Information required. */ + uint8_t id_info : 1; /**< If 1, Identity Information required. */ + uint8_t sign_info : 1; /**< If 1, Signing Information required. */ +} ble_gap_evt_sec_info_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_PASSKEY_DISPLAY. */ +typedef struct +{ + uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */ + uint8_t match_request : 1; /**< If 1 requires the application to report the match using @ref sd_ble_gap_auth_key_reply + with either @ref BLE_GAP_AUTH_KEY_TYPE_NONE if there is no match or + @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY if there is a match. */ +} ble_gap_evt_passkey_display_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_KEY_PRESSED. */ +typedef struct +{ + uint8_t kp_not; /**< Keypress notification type, see @ref BLE_GAP_KP_NOT_TYPES. */ +} ble_gap_evt_key_pressed_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_AUTH_KEY_REQUEST. */ +typedef struct +{ + uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */ +} ble_gap_evt_auth_key_request_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST. */ +typedef struct +{ + ble_gap_lesc_p256_pk_t *p_pk_peer; /**< LE Secure Connections remote P-256 Public Key. This will point to the application-supplied memory + inside the keyset during the call to @ref sd_ble_gap_sec_params_reply. */ + uint8_t oobd_req :1; /**< LESC OOB data required. A call to @ref sd_ble_gap_lesc_oob_data_set is required to complete the procedure. */ +} ble_gap_evt_lesc_dhkey_request_t; + + +/**@brief Security levels supported. + * @note See Bluetooth Specification Version 4.2 Volume 3, Part C, Chapter 10, Section 10.2.1. +*/ +typedef struct +{ + uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */ + uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */ + uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */ + uint8_t lv4 : 1; /**< If 1: Level 4 is supported. */ +} ble_gap_sec_levels_t; + + +/**@brief Encryption Key. */ +typedef struct +{ + ble_gap_enc_info_t enc_info; /**< Encryption Information. */ + ble_gap_master_id_t master_id; /**< Master Identification. */ +} ble_gap_enc_key_t; + + +/**@brief Identity Key. */ +typedef struct +{ + ble_gap_irk_t id_info; /**< Identity Resolving Key. */ + ble_gap_addr_t id_addr_info; /**< Identity Address. */ +} ble_gap_id_key_t; + + +/**@brief Security Keys. */ +typedef struct +{ + ble_gap_enc_key_t *p_enc_key; /**< Encryption Key, or NULL. */ + ble_gap_id_key_t *p_id_key; /**< Identity Key, or NULL. */ + ble_gap_sign_info_t *p_sign_key; /**< Signing Key, or NULL. */ + ble_gap_lesc_p256_pk_t *p_pk; /**< LE Secure Connections P-256 Public Key. When in debug mode the application must use the value defined + in the Core Bluetooth Specification v4.2 Vol.3, Part H, Section 2.3.5.6.1 */ +} ble_gap_sec_keys_t; + + +/**@brief Security key set for both local and peer keys. */ +typedef struct +{ + ble_gap_sec_keys_t keys_own; /**< Keys distributed by the local device. For LE Secure Connections the encryption key will be generated locally and will always be stored if bonding. */ + ble_gap_sec_keys_t keys_peer; /**< Keys distributed by the remote device. For LE Secure Connections, p_enc_key must always be NULL. */ +} ble_gap_sec_keyset_t; + + +/**@brief Data Length Update Procedure parameters. */ +typedef struct +{ + uint16_t max_tx_octets; /**< Maximum number of payload octets that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ + uint16_t max_rx_octets; /**< Maximum number of payload octets that a Controller supports for reception of a single Link Layer Data Channel PDU. */ + uint16_t max_tx_time_us; /**< Maximum time, in microseconds, that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ + uint16_t max_rx_time_us; /**< Maximum time, in microseconds, that a Controller supports for reception of a single Link Layer Data Channel PDU. */ +} ble_gap_data_length_params_t; + + +/**@brief Data Length Update Procedure local limitation. */ +typedef struct +{ + uint16_t tx_payload_limited_octets; /**< If > 0, the requested TX packet length is too long by this many octets. */ + uint16_t rx_payload_limited_octets; /**< If > 0, the requested RX packet length is too long by this many octets. */ + uint16_t tx_rx_time_limited_us; /**< If > 0, the requested combination of TX and RX packet lengths is too long by this many microseconds. */ +} ble_gap_data_length_limitation_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */ +typedef struct +{ + uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */ + uint8_t error_src : 2; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */ + uint8_t bonded : 1; /**< Procedure resulted in a bond. */ + uint8_t lesc : 1; /**< Procedure resulted in a LE Secure Connection. */ + ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */ + ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */ + ble_gap_sec_kdist_t kdist_own; /**< Bitmap stating which keys were exchanged (distributed) by the local device. If bonding with LE Secure Connections, the enc bit will be always set. */ + ble_gap_sec_kdist_t kdist_peer; /**< Bitmap stating which keys were exchanged (distributed) by the remote device. If bonding with LE Secure Connections, the enc bit will never be set. */ +} ble_gap_evt_auth_status_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONN_SEC_UPDATE. */ +typedef struct +{ + ble_gap_conn_sec_t conn_sec; /**< Connection security level. */ +} ble_gap_evt_conn_sec_update_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */ + union + { + ble_data_t adv_report_buffer; /**< If source is set to @ref BLE_GAP_TIMEOUT_SRC_SCAN, the released + scan buffer is contained in this field. */ + } params; /**< Event Parameters. */ +} ble_gap_evt_timeout_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */ +typedef struct +{ + int8_t rssi; /**< Received Signal Strength Indication in dBm. */ + uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */ +} ble_gap_evt_rssi_changed_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */ +typedef struct +{ + uint8_t reason; /**< Reason for why the advertising set terminated. See + @ref BLE_GAP_EVT_ADV_SET_TERMINATED_REASON. */ + uint8_t adv_handle; /**< Advertising handle in which advertising has ended. */ + uint8_t num_completed_adv_events; /**< If @ref ble_gap_adv_params_t::max_adv_evts was not set to 0, + this field indicates the number of completed advertising events. */ + ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated + advertising set. The advertising buffers provided in + @ref sd_ble_gap_adv_set_configure are now released. */ +} ble_gap_evt_adv_set_terminated_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_ADV_REPORT. + * + * @note If @ref ble_gap_adv_report_type_t::status is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, + * not all fields in the advertising report may be available. + * + * @note When ble_gap_adv_report_type_t::status is not set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, + * scanning will be paused. To continue scanning, call @ref sd_ble_gap_scan_start. + */ +typedef struct +{ + ble_gap_adv_report_type_t type; /**< Advertising report type. See @ref ble_gap_adv_report_type_t. */ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr is resolved: + @ref ble_gap_addr_t::addr_id_peer is set to 1 and the address is the + peer's identity address. */ + ble_gap_addr_t direct_addr; /**< Contains the target address of the advertising event if + @ref ble_gap_adv_report_type_t::directed is set to 1. If the + SoftDevice was able to resolve the address, + @ref ble_gap_addr_t::addr_id_peer is set to 1 and the direct_addr + contains the local identity address. If the target address of the + advertising event is @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE, + and the SoftDevice was unable to resolve it, the application may try + to resolve this address to find out if the advertising event was + directed to us. */ + uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising packet was received. + See @ref BLE_GAP_PHYS. */ + uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising packet was received. + See @ref BLE_GAP_PHYS. This field is set to @ref BLE_GAP_PHY_NOT_SET if no packets + were received on a secondary advertising channel. */ + int8_t tx_power; /**< TX Power reported by the advertiser in the last packet header received. + This field is set to @ref BLE_GAP_POWER_LEVEL_INVALID if the + last received packet did not contain the Tx Power field. + @note TX Power is only included in extended advertising packets. */ + int8_t rssi; /**< Received Signal Strength Indication in dBm of the last packet received. */ + uint8_t ch_index; /**< Channel Index on which the last advertising packet is received (0-39). */ + uint8_t set_id; /**< Set ID of the received advertising data. Set ID is not present + if set to @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */ + uint16_t data_id:12; /**< The advertising data ID of the received advertising data. Data ID + is not present if @ref ble_gap_evt_adv_report_t::set_id is set to + @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */ + ble_data_t data; /**< Received advertising or scan response data. If + @ref ble_gap_adv_report_type_t::status is not set to + @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the data buffer provided + in @ref sd_ble_gap_scan_start is now released. */ + ble_gap_aux_pointer_t aux_pointer; /**< The offset and PHY of the next advertising packet in this extended advertising + event. @note This field is only set if @ref ble_gap_adv_report_type_t::status + is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. */ +} ble_gap_evt_adv_report_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */ +typedef struct +{ + uint8_t bond : 1; /**< Perform bonding. */ + uint8_t mitm : 1; /**< Man In The Middle protection requested. */ + uint8_t lesc : 1; /**< LE Secure Connections requested. */ + uint8_t keypress : 1; /**< Generation of keypress notifications requested. */ +} ble_gap_evt_sec_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST. */ +typedef struct +{ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ +} ble_gap_evt_conn_param_update_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */ +typedef struct +{ + uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */ + int8_t rssi; /**< Received Signal Strength Indication in dBm. */ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1 + and the address is the device's identity address. */ +} ble_gap_evt_scan_req_report_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST. */ +typedef struct +{ + ble_gap_data_length_params_t peer_params; /**< Peer data length parameters. */ +} ble_gap_evt_data_length_update_request_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE. + */ +typedef struct +{ + ble_gap_data_length_params_t effective_params; /**< The effective data length parameters. */ +} ble_gap_evt_data_length_update_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT. */ +typedef struct +{ + int8_t channel_energy[BLE_GAP_CHANNEL_COUNT]; /**< The measured energy on the Bluetooth Low Energy + channels, in dBm, indexed by Channel Index. + If no measurement is available for the given channel, channel_energy is set to + @ref BLE_GAP_POWER_LEVEL_INVALID. */ +} ble_gap_evt_qos_channel_survey_report_t; + +/**@brief GAP event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occurred. */ + union /**< union alternative identified by evt_id in enclosing struct. */ + { + ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */ + ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */ + ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */ + ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */ + ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */ + ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */ + ble_gap_evt_key_pressed_t key_pressed; /**< Key Pressed Event Parameters. */ + ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */ + ble_gap_evt_lesc_dhkey_request_t lesc_dhkey_request; /**< LE Secure Connections DHKey calculation request. */ + ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */ + ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */ + ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */ + ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event Parameters. */ + ble_gap_evt_adv_report_t adv_report; /**< Advertising Report Event Parameters. */ + ble_gap_evt_adv_set_terminated_t adv_set_terminated; /**< Advertising Set Terminated Event Parameters. */ + ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */ + ble_gap_evt_conn_param_update_request_t conn_param_update_request; /**< Connection Parameter Update Parameters. */ + ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report Parameters. */ + ble_gap_evt_phy_update_request_t phy_update_request; /**< PHY Update Request Event Parameters. */ + ble_gap_evt_phy_update_t phy_update; /**< PHY Update Parameters. */ + ble_gap_evt_data_length_update_request_t data_length_update_request; /**< Data Length Update Request Event Parameters. */ + ble_gap_evt_data_length_update_t data_length_update; /**< Data Length Update Event Parameters. */ + ble_gap_evt_qos_channel_survey_report_t qos_channel_survey_report; /**< Quality of Service (QoS) Channel Survey Report Parameters. */ + } params; /**< Event Parameters. */ +} ble_gap_evt_t; + + +/** + * @brief BLE GAP connection configuration parameters, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_CONN_COUNT The connection count for the connection configurations is zero. + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - The sum of conn_count for all connection configurations combined exceeds UINT8_MAX. + * - The event length is smaller than @ref BLE_GAP_EVENT_LENGTH_MIN. + */ +typedef struct +{ + uint8_t conn_count; /**< The number of concurrent connections the application can create with this configuration. + The default and minimum value is @ref BLE_GAP_CONN_COUNT_DEFAULT. */ + uint16_t event_length; /**< The time set aside for this connection on every connection interval in 1.25 ms units. + The default value is @ref BLE_GAP_EVENT_LENGTH_DEFAULT, the minimum value is @ref BLE_GAP_EVENT_LENGTH_MIN. + The event length and the connection interval are the primary parameters + for setting the throughput of a connection. + See the SoftDevice Specification for details on throughput. */ +} ble_gap_conn_cfg_t; + + +/** + * @brief Configuration of maximum concurrent connections in the different connected roles, set with + * @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_CONN_COUNT The sum of periph_role_count and central_role_count is too + * large. The maximum supported sum of concurrent connections is + * @ref BLE_GAP_ROLE_COUNT_COMBINED_MAX. + * @retval ::NRF_ERROR_INVALID_PARAM central_sec_count is larger than central_role_count. + * @retval ::NRF_ERROR_RESOURCES The adv_set_count is too large. The maximum + * supported advertising handles is + * @ref BLE_GAP_ADV_SET_COUNT_MAX. + */ +typedef struct +{ + uint8_t adv_set_count; /**< Maximum number of advertising sets. Default value is @ref BLE_GAP_ADV_SET_COUNT_DEFAULT. */ + uint8_t periph_role_count; /**< Maximum number of connections concurrently acting as a peripheral. Default value is @ref BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT. */ + uint8_t central_role_count; /**< Maximum number of connections concurrently acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT. */ + uint8_t central_sec_count; /**< Number of SMP instances shared between all connections acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT. */ + uint8_t qos_channel_survey_role_available:1; /**< If set, the Quality of Service (QoS) channel survey module is available to the + application using @ref sd_ble_gap_qos_channel_survey_start. */ +} ble_gap_cfg_role_count_t; + + +/** + * @brief Device name and its properties, set with @ref sd_ble_cfg_set. + * + * @note If the device name is not configured, the default device name will be + * @ref BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be + * @ref BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name + * will have no write access. + * + * @note If @ref max_len is more than @ref BLE_GAP_DEVNAME_DEFAULT_LEN and vloc is set to @ref BLE_GATTS_VLOC_STACK, + * the attribute table size must be increased to have room for the longer device name (see + * @ref sd_ble_cfg_set and @ref ble_gatts_cfg_attr_tab_size_t). + * + * @note If vloc is @ref BLE_GATTS_VLOC_STACK : + * - p_value must point to non-volatile memory (flash) or be NULL. + * - If p_value is NULL, the device name will initially be empty. + * + * @note If vloc is @ref BLE_GATTS_VLOC_USER : + * - p_value cannot be NULL. + * - If the device name is writable, p_value must point to volatile memory (RAM). + * + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - Invalid device name location (vloc). + * - Invalid device name security mode. + * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true: + * - The device name length is invalid (must be between 0 and @ref BLE_GAP_DEVNAME_MAX_LEN). + * - The device name length is too long for the given Attribute Table. + * @retval ::NRF_ERROR_NOT_SUPPORTED Device name security mode is not supported. + */ +typedef struct +{ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ + uint8_t vloc:2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ + uint8_t *p_value; /**< Pointer to where the value (device name) is stored or will be stored. */ + uint16_t current_len; /**< Current length in bytes of the memory pointed to by p_value.*/ + uint16_t max_len; /**< Maximum length in bytes of the memory pointed to by p_value.*/ +} ble_gap_cfg_device_name_t; + + +/**@brief Peripheral Preferred Connection Parameters include configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t include_cfg; /**< Inclusion configuration of the Peripheral Preferred Connection Parameters characteristic. + See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_PPCP_INCL_CONFIG_DEFAULT. */ +} ble_gap_cfg_ppcp_incl_cfg_t; + + +/**@brief Central Address Resolution include configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t include_cfg; /**< Inclusion configuration of the Central Address Resolution characteristic. + See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_CAR_INCL_CONFIG_DEFAULT. */ +} ble_gap_cfg_car_incl_cfg_t; + + +/**@brief Configuration structure for GAP configurations. */ +typedef union +{ + ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */ + ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */ + ble_gap_cfg_ppcp_incl_cfg_t ppcp_include_cfg; /**< Peripheral Preferred Connection Parameters characteristic include + configuration, cfg_id is @ref BLE_GAP_CFG_PPCP_INCL_CONFIG. */ + ble_gap_cfg_car_incl_cfg_t car_include_cfg; /**< Central Address Resolution characteristic include configuration, + cfg_id is @ref BLE_GAP_CFG_CAR_INCL_CONFIG. */ +} ble_gap_cfg_t; + + +/**@brief Channel Map option. + * + * @details Used with @ref sd_ble_opt_get to get the current channel map + * or @ref sd_ble_opt_set to set a new channel map. When setting the + * channel map, it applies to all current and future connections. When getting the + * current channel map, it applies to a single connection and the connection handle + * must be supplied. + * + * @note Setting the channel map may take some time, depending on connection parameters. + * The time taken may be different for each connection and the get operation will + * return the previous channel map until the new one has taken effect. + * + * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed. + * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46. + * + * @retval ::NRF_SUCCESS Get or set successful. + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - Less then two bits in @ref ch_map are set. + * - Bits for primary advertising channels (37-39) are set. + * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get. + * + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle (only applicable for get) */ + uint8_t ch_map[5]; /**< Channel Map (37-bit). */ +} ble_gap_opt_ch_map_t; + + +/**@brief Local connection latency option. + * + * @details Local connection latency is a feature which enables the slave to improve + * current consumption by ignoring the slave latency set by the peer. The + * local connection latency can only be set to a multiple of the slave latency, + * and cannot be longer than half of the supervision timeout. + * + * @details Used with @ref sd_ble_opt_set to set the local connection latency. The + * @ref sd_ble_opt_get is not supported for this option, but the actual + * local connection latency (unless set to NULL) is set as a return parameter + * when setting the option. + * + * @note The latency set will be truncated down to the closest slave latency event + * multiple, or the nearest multiple before half of the supervision timeout. + * + * @note The local connection latency is disabled by default, and needs to be enabled for new + * connections and whenever the connection is updated. + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle */ + uint16_t requested_latency; /**< Requested local connection latency. */ + uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */ +} ble_gap_opt_local_conn_latency_t; + +/**@brief Disable slave latency + * + * @details Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection + * (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. When disabled, the + * peripheral will ignore the slave_latency set by the central. + * + * @note Shall only be called on peripheral links. + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle */ + uint8_t disable : 1; /**< Set to 1 to disable slave latency. Set to 0 enable it again.*/ +} ble_gap_opt_slave_latency_disable_t; + +/**@brief Passkey Option. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC} + * @endmscs + * + * @details Structure containing the passkey to be used during pairing. This can be used with @ref + * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication + * instead of generating a random one. + * + * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks. + * + * @note @ref sd_ble_opt_get is not supported for this option. + * + */ +typedef struct +{ + uint8_t const * p_passkey; /**< Pointer to 6-digit ASCII string (digit 0..9 only, no NULL termination) passkey to be used during pairing. If this is NULL, the SoftDevice will generate a random passkey if required.*/ +} ble_gap_opt_passkey_t; + + +/**@brief Compatibility mode 1 option. + * + * @details This can be used with @ref sd_ble_opt_set to enable and disable + * compatibility mode 1. Compatibility mode 1 is disabled by default. + * + * @note Compatibility mode 1 enables interoperability with devices that do not support a value of + * 0 for the WinOffset parameter in the Link Layer CONNECT_IND packet. This applies to a + * limited set of legacy peripheral devices from another vendor. Enabling this compatibility + * mode will only have an effect if the local device will act as a central device and + * initiate a connection to a peripheral device. In that case it may lead to the connection + * creation taking up to one connection interval longer to complete for all connections. + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable compatibility mode 1.*/ +} ble_gap_opt_compat_mode_1_t; + + +/**@brief Authenticated payload timeout option. + * + * @details This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other + * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX. + * + * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated + * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted + * link. + * + * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance + * to reset the timer. In addition the stack will try to prioritize running of LE ping over other + * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects + * on other activities, it is recommended to use high timeout values. + * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)). + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. auth_payload_timeout was outside of allowed range. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle */ + uint16_t auth_payload_timeout; /**< Requested timeout in 10 ms unit, see @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT. */ +} ble_gap_opt_auth_payload_timeout_t; + +/**@brief Option structure for GAP options. */ +typedef union +{ + ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */ + ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */ + ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/ + ble_gap_opt_compat_mode_1_t compat_mode_1; /**< Parameters for the compatibility mode 1 option.*/ + ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/ + ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */ +} ble_gap_opt_t; + +/**@brief Connection event triggering parameters. */ +typedef struct +{ + uint8_t ppi_ch_id; /**< PPI channel to use. This channel should be regarded as reserved until + connection event PPI task triggering is stopped. + The PPI channel ID can not be one of the PPI channels reserved by + the SoftDevice. See @ref NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK. */ + uint32_t task_endpoint; /**< Task Endpoint to trigger. */ + uint16_t conn_evt_counter_start; /**< The connection event on which the task triggering should start. */ + uint16_t period_in_events; /**< Trigger period. Valid range is [1, 32767]. + If the device is in slave role and slave latency is enabled, + this parameter should be set to a multiple of (slave latency + 1) + to ensure low power operation. */ +} ble_gap_conn_event_trigger_t; +/**@} */ + +/**@addtogroup BLE_GAP_FUNCTIONS Functions + * @{ */ + +/**@brief Set the local Bluetooth identity address. + * + * The local Bluetooth identity address is the address that identifies this device to other peers. + * The address type must be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC. + * + * @note The identity address cannot be changed while advertising, scanning or creating a connection. + * + * @note This address will be distributed to the peer during bonding. + * If the address changes, the address stored in the peer device will not be valid and the ability to + * reconnect using the old address will be lost. + * + * @note By default the SoftDevice will set an address of type @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being + * enabled. The address is a random number populated during the IC manufacturing process and remains unchanged + * for the lifetime of each IC. + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @endmscs + * + * @param[in] p_addr Pointer to address structure. + * + * @retval ::NRF_SUCCESS Address successfully set. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising, + * scanning or creating a connection. + */ +SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr)); + + +/**@brief Get local Bluetooth identity address. + * + * @note This will always return the identity address irrespective of the privacy settings, + * i.e. the address type will always be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC. + * + * @param[out] p_addr Pointer to address structure to be filled in. + * + * @retval ::NRF_SUCCESS Address successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + */ +SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr)); + + +/**@brief Get the Bluetooth device address used by the advertiser. + * + * @note This function will return the local Bluetooth address used in advertising PDUs. When + * using privacy, the SoftDevice will generate a new private address every + * @ref ble_gap_privacy_params_t::private_addr_cycle_s configured using + * @ref sd_ble_gap_privacy_set. Hence depending on when the application calls this API, the + * address returned may not be the latest address that is used in the advertising PDUs. + * + * @param[in] adv_handle The advertising handle to get the address from. + * @param[out] p_addr Pointer to address structure to be filled in. + * + * @retval ::NRF_SUCCESS Address successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. + * @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising. + */ +SVCALL(SD_BLE_GAP_ADV_ADDR_GET, uint32_t, sd_ble_gap_adv_addr_get(uint8_t adv_handle, ble_gap_addr_t *p_addr)); + + +/**@brief Set the active whitelist in the SoftDevice. + * + * @note Only one whitelist can be used at a time and the whitelist is shared between the BLE roles. + * The whitelist cannot be set if a BLE role is using the whitelist. + * + * @note If an address is resolved using the information in the device identity list, then the whitelist + * filter policy applies to the peer identity address and not the resolvable address sent on air. + * + * @mscs + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC} + * @endmscs + * + * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses, if NULL the whitelist will be cleared. + * @param[in] len Length of the whitelist, maximum @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. + * + * @retval ::NRF_SUCCESS The whitelist is successfully set/cleared. + * @retval ::NRF_ERROR_INVALID_ADDR The whitelist (or one of its entries) provided is invalid. + * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE The whitelist is in use by a BLE role and cannot be set or cleared. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied. + * @retval ::NRF_ERROR_DATA_SIZE The given whitelist size is invalid (zero or too large); this can only return when + * pp_wl_addrs is not NULL. + */ +SVCALL(SD_BLE_GAP_WHITELIST_SET, uint32_t, sd_ble_gap_whitelist_set(ble_gap_addr_t const * const * pp_wl_addrs, uint8_t len)); + + +/**@brief Set device identity list. + * + * @note Only one device identity list can be used at a time and the list is shared between the BLE roles. + * The device identity list cannot be set if a BLE role is using the list. + * + * @param[in] pp_id_keys Pointer to an array of peer identity addresses and peer IRKs, if NULL the device identity list will be cleared. + * @param[in] pp_local_irks Pointer to an array of local IRKs. Each entry in the array maps to the entry in pp_id_keys at the same index. + * To fill in the list with the currently set device IRK for all peers, set to NULL. + * @param[in] len Length of the device identity list, maximum @ref BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT. + * + * @mscs + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS The device identity list successfully set/cleared. + * @retval ::NRF_ERROR_INVALID_ADDR The device identity list (or one of its entries) provided is invalid. + * This code may be returned if the local IRK list also has an invalid entry. + * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE The device identity list is in use and cannot be set or cleared. + * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE The device identity list contains multiple entries with the same identity address. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied. + * @retval ::NRF_ERROR_DATA_SIZE The given device identity list size invalid (zero or too large); this can + * only return when pp_id_keys is not NULL. + */ +SVCALL(SD_BLE_GAP_DEVICE_IDENTITIES_SET, uint32_t, sd_ble_gap_device_identities_set(ble_gap_id_key_t const * const * pp_id_keys, ble_gap_irk_t const * const * pp_local_irks, uint8_t len)); + + +/**@brief Set privacy settings. + * + * @note Privacy settings cannot be changed while advertising, scanning or creating a connection. + * + * @param[in] p_privacy_params Privacy settings. + * + * @mscs + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied. + * @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid. + * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer. + * @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided. + * @retval ::NRF_ERROR_NOT_SUPPORTED The SoftDevice does not support privacy if the Central Address Resolution + characteristic is not configured to be included and the SoftDevice is configured + to support central roles. + See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t. + * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising, scanning + * or creating a connection. + */ +SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params)); + + +/**@brief Get privacy settings. + * + * @note ::ble_gap_privacy_params_t::p_device_irk must be initialized to NULL or a valid address before this function is called. + * If it is initialized to a valid address, the address pointed to will contain the current device IRK on return. + * + * @param[in,out] p_privacy_params Privacy settings. + * + * @retval ::NRF_SUCCESS Privacy settings read. + * @retval ::NRF_ERROR_INVALID_ADDR The pointer given for returning the privacy settings may be NULL or invalid. + * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer. + */ +SVCALL(SD_BLE_GAP_PRIVACY_GET, uint32_t, sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params)); + + +/**@brief Configure an advertising set. Set, clear or update advertising and scan response data. + * + * @note The format of the advertising data will be checked by this call to ensure interoperability. + * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and + * duplicating the local name in the advertising data and scan response data. + * + * @note In order to update advertising data while advertising, new advertising buffers must be provided. + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in,out] p_adv_handle Provide a pointer to a handle containing @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to configure + * a new advertising set. On success, a new handle is then returned through the pointer. + * Provide a pointer to an existing advertising handle to configure an existing advertising set. + * @param[in] p_adv_data Advertising data. If set to NULL, no advertising data will be used. See @ref ble_gap_adv_data_t. + * @param[in] p_adv_params Advertising parameters. When this function is used to update advertising data while advertising, + * this parameter must be NULL. See @ref ble_gap_adv_params_t. + * + * @retval ::NRF_SUCCESS Advertising set successfully configured. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied: + * - Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t. + * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t. + * - Use of whitelist requested but whitelist has not been set, + * see @ref sd_ble_gap_whitelist_set. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR ble_gap_adv_params_t::p_peer_addr is invalid. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - It is invalid to provide non-NULL advertising set parameters while advertising. + * - It is invalid to provide the same data buffers while advertising. To update + * advertising data, provide new advertising buffers. + * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. Use @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to + * configure a new advertising handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied. + * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied. Check the advertising data format specification + * given in Bluetooth Specification Version 5.0, Volume 3, Part C, Chapter 11. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data length or advertising parameter configuration. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to configure a new advertising handle. Update an + * existing advertising handle instead. + * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied. + */ +SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t const *p_adv_params)); + + +/**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). + * + * @note Only one advertiser may be active at any time. + * + * @events + * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.} + * @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.} + * @event{@ref BLE_GAP_EVT_SCAN_REQ_REPORT, A scan request was received.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in] adv_handle Advertising handle to advertise on, received from @ref sd_ble_gap_adv_set_configure. + * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or + * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. For non-connectable + * advertising, this is ignored. + * + * @retval ::NRF_SUCCESS The BLE stack has started advertising. + * @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising. + * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration + * tag has been reached; connectable advertiser cannot be started. + * To increase the number of available connections, + * use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure. + * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied: + * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t. + * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set. + * @retval ::NRF_ERROR_RESOURCES Either: + * - adv_handle is configured with connectable advertising, but the event_length parameter + * associated with conn_cfg_tag is too small to be able to establish a connection on + * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length. + * - Not enough BLE role slots available. + Stop one or more currently active roles (Central, Peripheral, Broadcaster or Observer) and try again. + * - p_adv_params is configured with connectable advertising, but the event_length parameter + * associated with conn_cfg_tag is too small to be able to establish a connection on + * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + */ +SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag)); + + +/**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in] adv_handle The advertising handle that should stop advertising. + * + * @retval ::NRF_SUCCESS The BLE stack has stopped advertising. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle. + * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising. + */ +SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle)); + + + +/**@brief Update connection parameters. + * + * @details In the central role this will initiate a Link Layer connection parameter update procedure, + * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for + * the central to perform the procedure. In both cases, and regardless of success or failure, the application + * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event. + * + * @details This function can be used as a central both to reply to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST or to start the procedure unrequested. + * + * @events + * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CPU_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} + * @mmsc{@ref BLE_GAP_MULTILINK_CPU_MSC} + * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CPU_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role, + * the parameters in the PPCP characteristic of the GAP service will be used instead. + * If NULL is provided on a central role and in response to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected + * + * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established. + * @retval ::NRF_ERROR_BUSY Procedure already in progress, wait for pending procedures to complete and retry. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GAP_CONN_PARAM_UPDATE, uint32_t, sd_ble_gap_conn_param_update(uint16_t conn_handle, ble_gap_conn_params_t const *p_conn_params)); + + +/**@brief Disconnect (GAP Link Termination). + * + * @details This call initiates the disconnection procedure, and its completion will be communicated to the application + * with a @ref BLE_GAP_EVT_DISCONNECTED event. + * + * @events + * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CONN_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE). + * + * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established. + */ +SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code)); + + +/**@brief Set the radio's transmit power. + * + * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for + * possible roles. + * @param[in] handle The handle parameter is interpreted depending on role: + * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle. + * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle, + * will use the specified transmit power, and include it in the advertising packet headers if + * @ref ble_gap_adv_properties_t::include_tx_power set. + * - For all other roles handle is ignored. + * @param[in] tx_power Radio transmit power in dBm (see note for accepted values). + * + * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm. + * @note The initiator will have the same transmit power as the scanner. + * @note When a connection is created it will inherit the transmit power from the initiator or + * advertiser leading to the connection. + * + * @retval ::NRF_SUCCESS Successfully changed the transmit power. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power)); + + +/**@brief Set GAP Appearance value. + * + * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES. + * + * @retval ::NRF_SUCCESS Appearance value set successfully. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + */ +SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance)); + + +/**@brief Get GAP Appearance value. + * + * @param[out] p_appearance Pointer to appearance (16-bit) to be filled in, see @ref BLE_APPEARANCES. + * + * @retval ::NRF_SUCCESS Appearance value retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *p_appearance)); + + +/**@brief Set GAP Peripheral Preferred Connection Parameters. + * + * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters. + * + * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table, + see @ref ble_gap_cfg_ppcp_incl_cfg_t. + */ +SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params)); + + +/**@brief Get GAP Peripheral Preferred Connection Parameters. + * + * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored. + * + * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table, + see @ref ble_gap_cfg_ppcp_incl_cfg_t. + */ +SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params)); + + +/**@brief Set GAP device name. + * + * @note If the device name is located in application flash memory (see @ref ble_gap_cfg_device_name_t), + * it cannot be changed. Then @ref NRF_ERROR_FORBIDDEN will be returned. + * + * @param[in] p_write_perm Write permissions for the Device Name characteristic, see @ref ble_gap_conn_sec_mode_t. + * @param[in] p_dev_name Pointer to a UTF-8 encoded, non NULL-terminated string. + * @param[in] len Length of the UTF-8, non NULL-terminated string pointed to by p_dev_name in octets (must be smaller or equal than @ref BLE_GAP_DEVNAME_MAX_LEN). + * + * @retval ::NRF_SUCCESS GAP device name and permissions set successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @retval ::NRF_ERROR_FORBIDDEN Device name is not writable. + */ +SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const *p_write_perm, uint8_t const *p_dev_name, uint16_t len)); + + +/**@brief Get GAP device name. + * + * @note If the device name is longer than the size of the supplied buffer, + * p_len will return the complete device name length, + * and not the number of bytes actually returned in p_dev_name. + * The application may use this information to allocate a suitable buffer size. + * + * @param[out] p_dev_name Pointer to an empty buffer where the UTF-8 non NULL-terminated string will be placed. Set to NULL to obtain the complete device name length. + * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output. + * + * @retval ::NRF_SUCCESS GAP device name retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + */ +SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len)); + + +/**@brief Initiate the GAP Authentication procedure. + * + * @details In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected), + * otherwise in the peripheral role, an SMP Security Request will be sent. + * + * @events + * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:} + * @event{@ref BLE_GAP_EVT_SEC_PARAMS_REQUEST} + * @event{@ref BLE_GAP_EVT_SEC_INFO_REQUEST} + * @event{@ref BLE_GAP_EVT_PASSKEY_DISPLAY} + * @event{@ref BLE_GAP_EVT_KEY_PRESSED} + * @event{@ref BLE_GAP_EVT_AUTH_KEY_REQUEST} + * @event{@ref BLE_GAP_EVT_LESC_DHKEY_REQUEST} + * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE} + * @event{@ref BLE_GAP_EVT_AUTH_STATUS} + * @event{@ref BLE_GAP_EVT_TIMEOUT} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sec_params Pointer to the @ref ble_gap_sec_params_t structure with the security parameters to be used during the pairing or bonding procedure. + * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used. + * In the central role, this pointer may be NULL to reject a Security Request. + * + * @retval ::NRF_SUCCESS Successfully initiated authentication procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - No link has been established. + * - An encryption is already executing or queued. + * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported. + * Distribution of own Identity Information is only supported if the Central + * Address Resolution characteristic is configured to be included or + * the Softdevice is configured to support peripheral roles only. + * See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t. + * @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited. + */ +SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params)); + + +/**@brief Reply with GAP security parameters. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @events + * @event{This function is used during authentication procedures, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_PERIPH_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_CONFIRM_FAIL_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_KS_TOO_SMALL_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS. + * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. In the central role this must be set to NULL, as the parameters have + * already been provided during a previous call to @ref sd_ble_gap_authenticate. + * @param[in,out] p_sec_keyset Pointer to a @ref ble_gap_sec_keyset_t security keyset structure. Any keys generated and/or distributed as a result of the ongoing security procedure + * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application + * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event. + * Note that the SoftDevice expects the application to provide memory for storing the + * peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key + * can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the + * @ref BLE_GAP_EVT_AUTH_STATUS event. + * + * @retval ::NRF_SUCCESS Successfully accepted security parameter from the application. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported. + * Distribution of own Identity Information is only supported if the Central + * Address Resolution characteristic is configured to be included or + * the Softdevice is configured to support peripheral roles only. + * See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t. + */ +SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const *p_sec_params, ble_gap_sec_keyset_t const *p_sec_keyset)); + + +/**@brief Reply with an authentication key. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_AUTH_KEY_REQUEST or a @ref BLE_GAP_EVT_PASSKEY_DISPLAY, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @events + * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES. + * @param[in] p_key If key type is @ref BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL. + * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination) + * or NULL when confirming LE Secure Connections Numeric Comparison. + * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in little-endian format. + * + * @retval ::NRF_SUCCESS Authentication key successfully set. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Authentication key has not been requested. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const *p_key)); + + +/**@brief Reply with an LE Secure connections DHKey. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @events + * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dhkey LE Secure Connections DHKey. + * + * @retval ::NRF_SUCCESS DHKey successfully set. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - The peer is not authenticated. + * - The application has not pulled a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_LESC_DHKEY_REPLY, uint32_t, sd_ble_gap_lesc_dhkey_reply(uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey)); + + +/**@brief Notify the peer of a local keypress. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] kp_not See @ref BLE_GAP_KP_NOT_TYPES. + * + * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Authentication key not requested. + * - Passkey has not been entered. + * - Keypresses have not been enabled by both peers. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time. + */ +SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not)); + + +/**@brief Generate a set of OOB data to send to a peer out of band. + * + * @note The @ref ble_gap_addr_t included in the OOB data returned will be the currently active one (or, if a connection has already been established, + * the one used during connection setup). The application may manually overwrite it with an updated value. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. Can be @ref BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet. + * @param[in] p_pk_own LE Secure Connections local P-256 Public Key. + * @param[out] p_oobd_own The OOB data to be sent out of band to a peer. + * + * @retval ::NRF_SUCCESS OOB data successfully generated. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_LESC_OOB_DATA_GET, uint32_t, sd_ble_gap_lesc_oob_data_get(uint16_t conn_handle, ble_gap_lesc_p256_pk_t const *p_pk_own, ble_gap_lesc_oob_data_t *p_oobd_own)); + +/**@brief Provide the OOB data sent/received out of band. + * + * @note An authentication procedure with OOB selected as an algorithm must be in progress when calling this function. + * @note A @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event with the oobd_req set to 1 must have been received prior to calling this function. + * + * @events + * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_oobd_own The OOB data sent out of band to a peer or NULL if the peer has not received OOB data. + * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. + * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received. + * Must correspond to @ref ble_gap_sec_params_t::oob flag + * in @ref sd_ble_gap_authenticate in the central role or + * in @ref sd_ble_gap_sec_params_reply in the peripheral role. + * + * @retval ::NRF_SUCCESS OOB data accepted. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Authentication key not requested + * - Not expecting LESC OOB data + * - Have not actually exchanged passkeys. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_LESC_OOB_DATA_SET, uint32_t, sd_ble_gap_lesc_oob_data_set(uint16_t conn_handle, ble_gap_lesc_oob_data_t const *p_oobd_own, ble_gap_lesc_oob_data_t const *p_oobd_peer)); + + +/**@brief Initiate GAP Encryption procedure. + * + * @details In the central role, this function will initiate the encryption procedure using the encryption information provided. + * + * @events + * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE, The connection security has been updated.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_MSC} + * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_master_id Pointer to a @ref ble_gap_master_id_t master identification structure. + * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. + * + * @retval ::NRF_SUCCESS Successfully initiated authentication procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::BLE_ERROR_INVALID_ROLE Operation is not supported in the Peripheral role. + * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, wait for pending procedures to complete and retry. + */ +SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info)); + + +/**@brief Reply with GAP security information. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_INFO_REQUEST, calling it at other times will result in @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * @note Data signing is not yet supported, and p_sign_info must therefore be NULL. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_ENC_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. May be NULL to signal none is available. + * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t identity information structure. May be NULL to signal none is available. + * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information structure. May be NULL to signal none is available. + * + * @retval ::NRF_SUCCESS Successfully accepted security information. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - No link has been established. + * - No @ref BLE_GAP_EVT_SEC_REQUEST pending. + * - Encryption information provided by the app without being requested. See @ref ble_gap_evt_sec_info_request_t::enc_info. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info)); + + +/**@brief Get the current connection security. + * + * @param[in] conn_handle Connection handle. + * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Current connection security successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t *p_conn_sec)); + + +/**@brief Start reporting the received signal strength to the application. + * + * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called. + * + * @events + * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is + * dependent on the settings of the threshold_dbm + * and skip_count input parameters.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} + * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] threshold_dbm Minimum change in dBm before triggering the @ref BLE_GAP_EVT_RSSI_CHANGED event. Events are disabled if threshold_dbm equals @ref BLE_GAP_RSSI_THRESHOLD_INVALID. + * @param[in] skip_count Number of RSSI samples with a change of threshold_dbm or more before sending a new @ref BLE_GAP_EVT_RSSI_CHANGED event. + * + * @retval ::NRF_SUCCESS Successfully activated RSSI reporting. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count)); + + +/**@brief Stop reporting the received signal strength. + * + * @note An RSSI change detected before the call but not yet received by the application + * may be reported after @ref sd_ble_gap_rssi_stop has been called. + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} + * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * + * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle)); + + +/**@brief Get the received signal strength for the last connection event. + * + * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND + * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start. + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored. + * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored. + * + * @retval ::NRF_SUCCESS Successfully read the RSSI. + * @retval ::NRF_ERROR_NOT_FOUND No sample is available. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing. + */ +SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi, uint8_t *p_ch_index)); + + +/**@brief Start or continue scanning (GAP Discovery procedure, Observer Procedure). + * + * @note A call to this function will require the application to keep the memory pointed by + * p_adv_report_buffer alive until the buffer is released. The buffer is released when the scanner is stopped + * or when this function is called with another buffer. + * + * @note The scanner will automatically stop in the following cases: + * - @ref sd_ble_gap_scan_stop is called. + * - @ref sd_ble_gap_connect is called. + * - A @ref BLE_GAP_EVT_TIMEOUT with source set to @ref BLE_GAP_TIMEOUT_SRC_SCAN is received. + * - When a @ref BLE_GAP_EVT_ADV_REPORT event is received and @ref ble_gap_adv_report_type_t::status is not set to + * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. In this case scanning is only paused to let the application + * access received data. The application must call this function to continue scanning, or call @ref sd_ble_gap_scan_stop + * to stop scanning. + * + * @note If a @ref BLE_GAP_EVT_ADV_REPORT event is received with @ref ble_gap_adv_report_type_t::status set to + * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the scanner will continue scanning, and the application will + * receive more reports from this advertising event. The following reports will include the old and new received data. + * + * @events + * @event{@ref BLE_GAP_EVT_ADV_REPORT, An advertising or scan response packet has been received.} + * @event{@ref BLE_GAP_EVT_TIMEOUT, Scanner has timed out.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_SCAN_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in] p_scan_params Pointer to scan parameters structure. When this function is used to continue + * scanning, this parameter must be NULL. + * @param[in] p_adv_report_buffer Pointer to buffer used to store incoming advertising data. + * The memory pointed to should be kept alive until the scanning is stopped. + * See @ref BLE_GAP_SCAN_BUFFER_SIZE for minimum and maximum buffer size. + * If the scanner receives advertising data larger than can be stored in the buffer, + * a @ref BLE_GAP_EVT_ADV_REPORT will be raised with @ref ble_gap_adv_report_type_t::status + * set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED. + * + * @retval ::NRF_SUCCESS Successfully initiated scanning procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Scanning is already ongoing and p_scan_params was not NULL + * - Scanning is not running and p_scan_params was NULL. + * - The scanner has timed out when this function is called to continue scanning. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. See @ref ble_gap_scan_params_t. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported parameters supplied. See @ref ble_gap_scan_params_t. + * @retval ::NRF_ERROR_INVALID_LENGTH The provided buffer length is invalid. See @ref BLE_GAP_SCAN_BUFFER_MIN. + * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available. + * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + */ +SVCALL(SD_BLE_GAP_SCAN_START, uint32_t, sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params, ble_data_t const * p_adv_report_buffer)); + + +/**@brief Stop scanning (GAP Discovery procedure, Observer Procedure). + * + * @note The buffer provided in @ref sd_ble_gap_scan_start is released. + * + * @mscs + * @mmsc{@ref BLE_GAP_SCAN_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully stopped scanning procedure. + * @retval ::NRF_ERROR_INVALID_STATE Not in the scanning state. + */ +SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void)); + + +/**@brief Create a connection (GAP Link Establishment). + * + * @note If a scanning procedure is currently in progress it will be automatically stopped when calling this function. + * The scanning procedure will be stopped even if the function returns an error. + * + * @events + * @event{@ref BLE_GAP_EVT_CONNECTED, A connection was established.} + * @event{@ref BLE_GAP_EVT_TIMEOUT, Failed to establish a connection.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC} + * @endmscs + * + * @param[in] p_peer_addr Pointer to peer identity address. If @ref ble_gap_scan_params_t::filter_policy is set to use + * whitelist, then p_peer_addr is ignored. + * @param[in] p_scan_params Pointer to scan parameters structure. + * @param[in] p_conn_params Pointer to desired connection parameters. + * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or + * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. + * + * @retval ::NRF_SUCCESS Successfully initiated connection procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid parameter(s) pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * - Invalid parameter(s) in p_scan_params or p_conn_params. + * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set. + * - Peer address was not present in the device identity list, see @ref sd_ble_gap_device_identities_set. + * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found. + * @retval ::NRF_ERROR_INVALID_STATE The SoftDevice is in an invalid state to perform this operation. This may be due to an + * existing locally initiated connect procedure, which must complete before initiating again. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address. + * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration tag has been reached. + * To increase the number of available connections, + * use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP. + * @retval ::NRF_ERROR_RESOURCES Either: + * - Not enough BLE role slots available. + * Stop one or more currently active roles (Central, Peripheral or Observer) and try again. + * - The event_length parameter associated with conn_cfg_tag is too small to be able to + * establish a connection on the selected @ref ble_gap_scan_params_t::scan_phys. + * Use @ref sd_ble_cfg_set to increase the event length. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + */ +SVCALL(SD_BLE_GAP_CONNECT, uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params, uint8_t conn_cfg_tag)); + + +/**@brief Cancel a connection establishment. + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully canceled an ongoing connection procedure. + * @retval ::NRF_ERROR_INVALID_STATE No locally initiated connect procedure started or connection + * completed occurred. + */ +SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void)); + + +/**@brief Initiate or respond to a PHY Update Procedure + * + * @details This function is used to initiate or respond to a PHY Update Procedure. It will always + * generate a @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed. + * If this function is used to initiate a PHY Update procedure and the only option + * provided in @ref ble_gap_phys_t::tx_phys and @ref ble_gap_phys_t::rx_phys is the + * currently active PHYs in the respective directions, the SoftDevice will generate a + * @ref BLE_GAP_EVT_PHY_UPDATE with the current PHYs set and will not initiate the + * procedure in the Link Layer. + * + * If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys is @ref BLE_GAP_PHY_AUTO, + * then the stack will select PHYs based on the peer's PHY preferences and the local link + * configuration. The PHY Update procedure will for this case result in a PHY combination + * that respects the time constraints configured with @ref sd_ble_cfg_set and the current + * link layer data length. + * + * When acting as a central, the SoftDevice will select the fastest common PHY in each direction. + * + * If the peer does not support the PHY Update Procedure, then the resulting + * @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to + * @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE. + * + * If the PHY Update procedure was rejected by the peer due to a procedure collision, the status + * will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or + * @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION. + * If the peer responds to the PHY Update procedure with invalid parameters, the status + * will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS. + * If the PHY Update procedure was rejected by the peer for a different reason, the status will + * contain the reason as specified by the peer. + * + * @events + * @event{@ref BLE_GAP_EVT_PHY_UPDATE, Result of the PHY Update Procedure.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_PHY_UPDATE} + * @mmsc{@ref BLE_GAP_PERIPHERAL_PHY_UPDATE} + * @endmscs + * + * @param[in] conn_handle Connection handle to indicate the connection for which the PHY Update is requested. + * @param[in] p_gap_phys Pointer to PHY structure. + * + * @retval ::NRF_SUCCESS Successfully requested a PHY Update. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. + * @retval ::NRF_ERROR_BUSY Procedure is already in progress or not allowed at this time. Process pending events and wait for the pending procedure to complete and retry. + * + */ +SVCALL(SD_BLE_GAP_PHY_UPDATE, uint32_t, sd_ble_gap_phy_update(uint16_t conn_handle, ble_gap_phys_t const *p_gap_phys)); + + +/**@brief Initiate or respond to a Data Length Update Procedure. + * + * @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of + * p_dl_params, the SoftDevice will choose the highest value supported in current + * configuration and connection parameters. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update + * Procedure. Set any member to @ref BLE_GAP_DATA_LENGTH_AUTO to let + * the SoftDevice automatically decide the value for that member. + * Set to NULL to use automatic values for all members. + * @param[out] p_dl_limitation Pointer to limitation to be written when local device does not + * have enough resources or does not support the requested Data Length + * Update parameters. Ignored if NULL. + * + * @mscs + * @mmsc{@ref BLE_GAP_DATA_LENGTH_UPDATE_PROCEDURE_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully set Data Length Extension initiation/response parameters. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The requested parameters are not supported by the SoftDevice. Inspect + * p_dl_limitation to see which parameter is not supported. + * @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the requested parameters. + * Use @ref sd_ble_cfg_set with @ref BLE_CONN_CFG_GAP to increase the connection event length. + * Inspect p_dl_limitation to see where the limitation is. + * @retval ::NRF_ERROR_BUSY Peer has already initiated a Data Length Update Procedure. Process the + * pending @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event to respond. + */ +SVCALL(SD_BLE_GAP_DATA_LENGTH_UPDATE, uint32_t, sd_ble_gap_data_length_update(uint16_t conn_handle, ble_gap_data_length_params_t const *p_dl_params, ble_gap_data_length_limitation_t *p_dl_limitation)); + +/**@brief Start the Quality of Service (QoS) channel survey module. + * + * @details The channel survey module provides measurements of the energy levels on + * the Bluetooth Low Energy channels. When the module is enabled, @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT + * events will periodically report the measured energy levels for each channel. + * + * @note The measurements are scheduled with lower priority than other Bluetooth Low Energy roles, + * Radio Timeslot API events and Flash API events. + * + * @note The channel survey module will attempt to do measurements so that the average interval + * between measurements will be interval_us. However due to the channel survey module + * having the lowest priority of all roles and modules, this may not be possible. In that + * case fewer than expected channel survey reports may be given. + * + * @note In order to use the channel survey module, @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available + * must be set. This is done using @ref sd_ble_cfg_set. + * + * @param[in] interval_us Requested average interval for the measurements and reports. See + * @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS for valid ranges. If set + * to @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS, the channel + * survey role will be scheduled at every available opportunity. + * + * @retval ::NRF_SUCCESS The module is successfully started. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. interval_us is out of the + * allowed range. + * @retval ::NRF_ERROR_INVALID_STATE Trying to start the module when already running. + * @retval ::NRF_ERROR_RESOURCES The channel survey module is not available to the application. + * Set @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available using + * @ref sd_ble_cfg_set. + */ +SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, uint32_t, sd_ble_gap_qos_channel_survey_start(uint32_t interval_us)); + +/**@brief Stop the Quality of Service (QoS) channel survey module. + * + * @note The SoftDevice may generate one @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT event after this + * function is called. + * + * @retval ::NRF_SUCCESS The module is successfully stopped. + * @retval ::NRF_ERROR_INVALID_STATE Trying to stop the module when it is not running. + */ +SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP, uint32_t, sd_ble_gap_qos_channel_survey_stop(void)); + + +/**@brief Obtain the next connection event counter value. + * + * @details The connection event counter is initialized to zero on the first connection event. The value is incremented + * by one for each connection event. For more information see Bluetooth Core Specification v5.0, Vol 6, Part B, + * Section 4.5.1. + * + * @note The connection event counter obtained through this API will be outdated if this API is called + * at the same time as the connection event counter is incremented. + * + * @note This API will always return the last connection event counter + 1. + * The actual connection event may be multiple connection events later if: + * - Slave latency is enabled and there is no data to transmit or receive. + * - Another role is scheduled with a higher priority at the same time as the next connection event. + * + * @param[in] conn_handle Connection handle. + * @param[out] p_counter Pointer to the variable where the next connection event counter will be written. + * + * @retval ::NRF_SUCCESS The connection event counter was successfully retrieved. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET, uint32_t, sd_ble_gap_next_conn_evt_counter_get(uint16_t conn_handle, uint16_t * p_counter)); + + +/**@brief Start triggering a given task on connection event start. + * + * @details When enabled, this feature will trigger a PPI task at the start of connection events. + * The application can configure the SoftDevice to trigger every N connection events starting from + * a given connection event counter. See also @ref ble_gap_conn_event_trigger_t. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_params Connection event trigger parameters. + * + * @retval ::NRF_SUCCESS Success. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. See @ref ble_gap_conn_event_trigger_t. + * @retval ::NRF_ERROR_INVALID_STATE Either: + * - Trying to start connection event triggering when it is already ongoing. + * - @ref ble_gap_conn_event_trigger_t::conn_evt_counter_start is in the past. + * Use @ref sd_ble_gap_next_conn_evt_counter_get to find a new value + to be used as ble_gap_conn_event_trigger_t::conn_evt_counter_start. + */ +SVCALL(SD_BLE_GAP_CONN_EVT_TRIGGER_START, uint32_t, sd_ble_gap_conn_evt_trigger_start(uint16_t conn_handle, ble_gap_conn_event_trigger_t const * p_params)); + + +/**@brief Stop triggering the task configured using @ref sd_ble_gap_conn_evt_trigger_start. + * + * @param[in] conn_handle Connection handle. + * + * @retval ::NRF_SUCCESS Success. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_STATE Trying to stop connection event triggering when it is not enabled. + */ +SVCALL(SD_BLE_GAP_CONN_EVT_TRIGGER_STOP, uint32_t, sd_ble_gap_conn_evt_trigger_stop(uint16_t conn_handle)); + + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_GAP_H__ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatt.h new file mode 100644 index 0000000..c392884 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatt.h @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2013 - 2018, 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. + */ + +/** + @addtogroup BLE_GATT Generic Attribute Profile (GATT) Common + @{ + @brief Common definitions and prototypes for the GATT interfaces. + */ + +#ifndef BLE_GATT_H__ +#define BLE_GATT_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_GATT_DEFINES Defines + * @{ */ + +/** @brief Default ATT MTU, in bytes. */ +#define BLE_GATT_ATT_MTU_DEFAULT 23 + +/**@brief Invalid Attribute Handle. */ +#define BLE_GATT_HANDLE_INVALID 0x0000 + +/**@brief First Attribute Handle. */ +#define BLE_GATT_HANDLE_START 0x0001 + +/**@brief Last Attribute Handle. */ +#define BLE_GATT_HANDLE_END 0xFFFF + +/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources + * @{ */ +#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */ +/** @} */ + +/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations + * @{ */ +#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */ +#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */ +#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ +#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ +#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */ +/** @} */ + +/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags + * @{ */ +#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00 /**< Cancel prepared write. */ +#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01 /**< Execute prepared write. */ +/** @} */ + +/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations + * @{ */ +#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */ +#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */ +/** @} */ + +/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes + * @{ */ +#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */ +#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */ +#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */ +#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */ +#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */ +#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorization. */ +#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */ +#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */ +#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */ +#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */ +#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Insufficient resources. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */ +#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */ +#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */ +#define BLE_GATT_STATUS_ATTERR_CPS_WRITE_REQ_REJECTED 0x01FC /**< ATT Common Profile and Service Error: Write request rejected. */ +#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */ +#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */ +#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */ +/** @} */ + + +/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats + * @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml + * @{ */ +#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */ +#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */ +#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */ +#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */ +#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */ +#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */ +#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */ +#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */ +#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */ +#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */ +#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */ +#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */ +/** @} */ + +/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces + * @{ + */ +#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */ +#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */ +/** @} */ + +/** @} */ + +/** @addtogroup BLE_GATT_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE GATT connection configuration parameters, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_INVALID_PARAM att_mtu is smaller than @ref BLE_GATT_ATT_MTU_DEFAULT. + */ +typedef struct +{ + uint16_t att_mtu; /**< Maximum size of ATT packet the SoftDevice can send or receive. + The default and minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. + @mscs + @mmsc{@ref BLE_GATTC_MTU_EXCHANGE} + @mmsc{@ref BLE_GATTS_MTU_EXCHANGE} + @endmscs + */ +} ble_gatt_conn_cfg_t; + +/**@brief GATT Characteristic Properties. */ +typedef struct +{ + /* Standard properties */ + uint8_t broadcast :1; /**< Broadcasting of the value permitted. */ + uint8_t read :1; /**< Reading the value permitted. */ + uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */ + uint8_t write :1; /**< Writing the value with Write Request permitted. */ + uint8_t notify :1; /**< Notification of the value permitted. */ + uint8_t indicate :1; /**< Indications of the value permitted. */ + uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */ +} ble_gatt_char_props_t; + +/**@brief GATT Characteristic Extended Properties. */ +typedef struct +{ + /* Extended properties */ + uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */ + uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */ +} ble_gatt_char_ext_props_t; + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_GATT_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gattc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gattc.h new file mode 100644 index 0000000..7fb3920 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gattc.h @@ -0,0 +1,715 @@ +/* + * 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. + */ + +/** + @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client + @{ + @brief Definitions and prototypes for the GATT Client interface. + */ + +#ifndef BLE_GATTC_H__ +#define BLE_GATTC_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" +#include "ble_gatt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations + * @{ */ + +/**@brief GATTC API SVC numbers. */ +enum BLE_GATTC_SVCS +{ + SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */ + SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */ + SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */ + SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */ + SD_BLE_GATTC_ATTR_INFO_DISCOVER, /**< Attribute Information Discovery. */ + SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */ + SD_BLE_GATTC_READ, /**< Generic read. */ + SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */ + SD_BLE_GATTC_WRITE, /**< Generic write. */ + SD_BLE_GATTC_HV_CONFIRM, /**< Handle Value Confirmation. */ + SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. */ +}; + +/** + * @brief GATT Client Event IDs. + */ +enum BLE_GATTC_EVTS +{ + BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. \n See @ref ble_gattc_evt_prim_srvc_disc_rsp_t. */ + BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. \n See @ref ble_gattc_evt_rel_disc_rsp_t. */ + BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. \n See @ref ble_gattc_evt_char_disc_rsp_t. */ + BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. \n See @ref ble_gattc_evt_desc_disc_rsp_t. */ + BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, /**< Attribute Information Response event. \n See @ref ble_gattc_evt_attr_info_disc_rsp_t. */ + BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. \n See @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t. */ + BLE_GATTC_EVT_READ_RSP, /**< Read Response event. \n See @ref ble_gattc_evt_read_rsp_t. */ + BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. \n See @ref ble_gattc_evt_char_vals_read_rsp_t. */ + BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. \n See @ref ble_gattc_evt_write_rsp_t. */ + BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. \n Confirm indication with @ref sd_ble_gattc_hv_confirm. \n See @ref ble_gattc_evt_hvx_t. */ + BLE_GATTC_EVT_EXCHANGE_MTU_RSP, /**< Exchange MTU Response event. \n See @ref ble_gattc_evt_exchange_mtu_rsp_t. */ + BLE_GATTC_EVT_TIMEOUT, /**< Timeout event. \n See @ref ble_gattc_evt_timeout_t. */ + BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE /**< Write without Response transmission complete. \n See @ref ble_gattc_evt_write_cmd_tx_complete_t. */ +}; + +/** @} */ + +/** @addtogroup BLE_GATTC_DEFINES Defines + * @{ */ + +/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC + * @{ */ +#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) /**< Procedure not Permitted. */ +/** @} */ + +/** @defgroup BLE_GATTC_ATTR_INFO_FORMAT Attribute Information Formats + * @{ */ +#define BLE_GATTC_ATTR_INFO_FORMAT_16BIT 1 /**< 16-bit Attribute Information Format. */ +#define BLE_GATTC_ATTR_INFO_FORMAT_128BIT 2 /**< 128-bit Attribute Information Format. */ +/** @} */ + +/** @defgroup BLE_GATTC_DEFAULTS GATT Client defaults + * @{ */ +#define BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT 1 /**< Default number of Write without Response that can be queued for transmission. */ +/** @} */ + +/** @} */ + +/** @addtogroup BLE_GATTC_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE GATTC connection configuration parameters, set with @ref sd_ble_cfg_set. + */ +typedef struct +{ + uint8_t write_cmd_tx_queue_size; /**< The guaranteed minimum number of Write without Response that can be queued for transmission. + The default value is @ref BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT */ +} ble_gattc_conn_cfg_t; + +/**@brief Operation Handle Range. */ +typedef struct +{ + uint16_t start_handle; /**< Start Handle. */ + uint16_t end_handle; /**< End Handle. */ +} ble_gattc_handle_range_t; + + +/**@brief GATT service. */ +typedef struct +{ + ble_uuid_t uuid; /**< Service UUID. */ + ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */ +} ble_gattc_service_t; + + +/**@brief GATT include. */ +typedef struct +{ + uint16_t handle; /**< Include Handle. */ + ble_gattc_service_t included_srvc; /**< Handle of the included service. */ +} ble_gattc_include_t; + + +/**@brief GATT characteristic. */ +typedef struct +{ + ble_uuid_t uuid; /**< Characteristic UUID. */ + ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ + uint8_t char_ext_props : 1; /**< Extended properties present. */ + uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */ + uint16_t handle_value; /**< Handle of the Characteristic Value. */ +} ble_gattc_char_t; + + +/**@brief GATT descriptor. */ +typedef struct +{ + uint16_t handle; /**< Descriptor Handle. */ + ble_uuid_t uuid; /**< Descriptor UUID. */ +} ble_gattc_desc_t; + + +/**@brief Write Parameters. */ +typedef struct +{ + uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */ + uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */ + uint16_t handle; /**< Handle to the attribute to be written. */ + uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */ + uint16_t len; /**< Length of data in bytes. */ + uint8_t const *p_value; /**< Pointer to the value data. */ +} ble_gattc_write_params_t; + +/**@brief Attribute Information for 16-bit Attribute UUID. */ +typedef struct +{ + uint16_t handle; /**< Attribute handle. */ + ble_uuid_t uuid; /**< 16-bit Attribute UUID. */ +} ble_gattc_attr_info16_t; + +/**@brief Attribute Information for 128-bit Attribute UUID. */ +typedef struct +{ + uint16_t handle; /**< Attribute handle. */ + ble_uuid128_t uuid; /**< 128-bit Attribute UUID. */ +} ble_gattc_attr_info128_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Service count. */ + ble_gattc_service_t services[1]; /**< Service data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_prim_srvc_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_REL_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Include count. */ + ble_gattc_include_t includes[1]; /**< Include data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_rel_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Characteristic count. */ + ble_gattc_char_t chars[1]; /**< Characteristic data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_char_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_DESC_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Descriptor count. */ + ble_gattc_desc_t descs[1]; /**< Descriptor data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_desc_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Attribute count. */ + uint8_t format; /**< Attribute information format, see @ref BLE_GATTC_ATTR_INFO_FORMAT. */ + union { + ble_gattc_attr_info16_t attr_info16[1]; /**< Attribute information for 16-bit Attribute UUID. + @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ + ble_gattc_attr_info128_t attr_info128[1]; /**< Attribute information for 128-bit Attribute UUID. + @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ + } info; /**< Attribute information union. */ +} ble_gattc_evt_attr_info_disc_rsp_t; + +/**@brief GATT read by UUID handle value pair. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t *p_value; /**< Pointer to the Attribute Value, length is available in @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t::value_len. */ +} ble_gattc_handle_value_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */ +typedef struct +{ + uint16_t count; /**< Handle-Value Pair Count. */ + uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */ + uint8_t handle_value[1]; /**< Handle-Value(s) list. To iterate through the list use @ref sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter. + @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_char_val_by_uuid_read_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint16_t offset; /**< Offset of the attribute data. */ + uint16_t len; /**< Attribute data length. */ + uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_read_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */ +typedef struct +{ + uint16_t len; /**< Concatenated Attribute values length. */ + uint8_t values[1]; /**< Attribute values. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_char_vals_read_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_RSP. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */ + uint16_t offset; /**< Data offset. */ + uint16_t len; /**< Data length. */ + uint8_t data[1]; /**< Data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_write_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_HVX. */ +typedef struct +{ + uint16_t handle; /**< Handle to which the HVx operation applies. */ + uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ + uint16_t len; /**< Attribute data length. */ + uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_hvx_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP. */ +typedef struct +{ + uint16_t server_rx_mtu; /**< Server RX MTU size. */ +} ble_gattc_evt_exchange_mtu_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ +} ble_gattc_evt_timeout_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE. */ +typedef struct +{ + uint8_t count; /**< Number of write without response transmissions completed. */ +} ble_gattc_evt_write_cmd_tx_complete_t; + +/**@brief GATTC event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occurred. */ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ + uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases @ref BLE_GATT_HANDLE_INVALID. */ + union + { + ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */ + ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */ + ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */ + ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */ + ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */ + ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */ + ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */ + ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */ + ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */ + ble_gattc_evt_exchange_mtu_rsp_t exchange_mtu_rsp; /**< Exchange MTU Response Event Parameters. */ + ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */ + ble_gattc_evt_attr_info_disc_rsp_t attr_info_disc_rsp; /**< Attribute Information Discovery Event Parameters. */ + ble_gattc_evt_write_cmd_tx_complete_t write_cmd_tx_complete; /**< Write without Response transmission complete Event Parameters. */ + } params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */ +} ble_gattc_evt_t; +/** @} */ + +/** @addtogroup BLE_GATTC_FUNCTIONS Functions + * @{ */ + +/**@brief Initiate or continue a GATT Primary Service Discovery procedure. + * + * @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle. + * If the last service has not been reached, this function must be called again with an updated start handle value to continue the search. + * + * @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with + * type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event. + * + * @events + * @event{@ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_PRIM_SRVC_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] start_handle Handle to start searching from. + * @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid)); + + +/**@brief Initiate or continue a GATT Relationship Discovery procedure. + * + * @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached, + * this must be called again with an updated handle range to continue the search. + * + * @events + * @event{@ref BLE_GATTC_EVT_REL_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_REL_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Characteristic Discovery procedure. + * + * @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with + * type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event. + * + * @events + * @event{@ref BLE_GATTC_EVT_CHAR_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_CHAR_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure. + * + * @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @events + * @event{@ref BLE_GATTC_EVT_DESC_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_DESC_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure. + * + * @details This function initiates or resumes a Read using Characteristic UUID procedure. If the last Characteristic has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @events + * @event{@ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_READ_UUID_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_uuid Pointer to a Characteristic value UUID to read. + * @param[in] p_handle_range A pointer to the range of handles to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure. + * + * @details This function initiates or resumes a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor + * to be read is longer than ATT_MTU - 1, this function must be called multiple times with appropriate offset to read the + * complete value. + * + * @events + * @event{@ref BLE_GATTC_EVT_READ_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_VALUE_READ_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] handle The handle of the attribute to be read. + * @param[in] offset Offset into the attribute value to be read. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Read (Long) procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset)); + + +/**@brief Initiate a GATT Read Multiple Characteristic Values procedure. + * + * @details This function initiates a GATT Read Multiple Characteristic Values procedure. + * + * @events + * @event{@ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_READ_MULT_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read. + * @param[in] handle_count The number of handles in p_handles. + * + * @retval ::NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count)); + + +/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure. + * + * @details This function can perform all write procedures described in GATT. + * + * @note Only one write with response procedure can be ongoing per connection at a time. + * If the application tries to write with response while another write with response procedure is ongoing, + * the function call will return @ref NRF_ERROR_BUSY. + * A @ref BLE_GATTC_EVT_WRITE_RSP event will be issued as soon as the write response arrives from the peer. + * + * @note The number of Write without Response that can be queued is configured by @ref ble_gattc_conn_cfg_t::write_cmd_tx_queue_size + * When the queue is full, the function call will return @ref NRF_ERROR_RESOURCES. + * A @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event will be issued as soon as the transmission of the write without response is complete. + * + * @note The application can keep track of the available queue element count for writes without responses by following the procedure below: + * - Store initial queue element count in a variable. + * - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS. + * - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event. + * + * @events + * @event{@ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE, Write without response transmission complete.} + * @event{@ref BLE_GATTC_EVT_WRITE_RSP, Write response received from the peer.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_VALUE_WRITE_WITHOUT_RESP_MSC} + * @mmsc{@ref BLE_GATTC_VALUE_WRITE_MSC} + * @mmsc{@ref BLE_GATTC_VALUE_LONG_WRITE_MSC} + * @mmsc{@ref BLE_GATTC_VALUE_RELIABLE_WRITE_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_write_params A pointer to a write parameters structure. + * + * @retval ::NRF_SUCCESS Successfully started the Write procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @retval ::NRF_ERROR_BUSY For write with response, procedure already in progress. Wait for a @ref BLE_GATTC_EVT_WRITE_RSP event and retry. + * @retval ::NRF_ERROR_RESOURCES Too many writes without responses queued. + * Wait for a @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event and retry. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params)); + + +/**@brief Send a Handle Value Confirmation to the GATT Server. + * + * @mscs + * @mmsc{@ref BLE_GATTC_HVI_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] handle The handle of the attribute in the indication. + * + * @retval ::NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed. + * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle)); + +/**@brief Discovers information about a range of attributes on a GATT server. + * + * @events + * @event{@ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, Generated when information about a range of attributes has been received.} + * @endevents + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range The range of handles to request information about. + * + * @retval ::NRF_SUCCESS Successfully started an attribute information discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid connection state + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range)); + +/**@brief Start an ATT_MTU exchange by sending an Exchange MTU Request to the server. + * + * @details The SoftDevice sets ATT_MTU to the minimum of: + * - The Client RX MTU value, and + * - The Server RX MTU value from @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP. + * + * However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_ATT_MTU_DEFAULT. + * + * @events + * @event{@ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_MTU_EXCHANGE} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] client_rx_mtu Client RX MTU size. + * - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. + * - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration + used for this connection. + * - The value must be equal to Server RX MTU size given in @ref sd_ble_gatts_exchange_mtu_reply + * if an ATT_MTU exchange has already been performed in the other direction. + * + * @retval ::NRF_SUCCESS Successfully sent request to the server. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid connection state or an ATT_MTU exchange was already requested once. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid Client RX MTU size supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, uint32_t, sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, uint16_t client_rx_mtu)); + +/**@brief Iterate through Handle-Value(s) list in @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event. + * + * @param[in] p_gattc_evt Pointer to event buffer containing @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event. + * @note If the buffer contains different event, behavior is undefined. + * @param[in,out] p_iter Iterator, points to @ref ble_gattc_handle_value_t structure that will be filled in with + * the next Handle-Value pair in each iteration. If the function returns other than + * @ref NRF_SUCCESS, it will not be changed. + * - To start iteration, initialize the structure to zero. + * - To continue, pass the value from previous iteration. + * + * \code + * ble_gattc_handle_value_t iter; + * memset(&iter, 0, sizeof(ble_gattc_handle_value_t)); + * while (sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(&ble_evt.evt.gattc_evt, &iter) == NRF_SUCCESS) + * { + * app_handle = iter.handle; + * memcpy(app_value, iter.p_value, ble_evt.evt.gattc_evt.params.char_val_by_uuid_read_rsp.value_len); + * } + * \endcode + * + * @retval ::NRF_SUCCESS Successfully retrieved the next Handle-Value pair. + * @retval ::NRF_ERROR_NOT_FOUND No more Handle-Value pairs available in the list. + */ +__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter); + +/** @} */ + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter) +{ + uint32_t value_len = p_gattc_evt->params.char_val_by_uuid_read_rsp.value_len; + uint8_t *p_first = p_gattc_evt->params.char_val_by_uuid_read_rsp.handle_value; + uint8_t *p_next = p_iter->p_value ? p_iter->p_value + value_len : p_first; + + if ((p_next - p_first) / (sizeof(uint16_t) + value_len) < p_gattc_evt->params.char_val_by_uuid_read_rsp.count) + { + p_iter->handle = (uint16_t)p_next[1] << 8 | p_next[0]; + p_iter->p_value = p_next + sizeof(uint16_t); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_NOT_FOUND; + } +} + +#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ + +#ifdef __cplusplus +} +#endif +#endif /* BLE_GATTC_H__ */ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatts.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatts.h new file mode 100644 index 0000000..394d8d1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_gatts.h @@ -0,0 +1,845 @@ +/* + * Copyright (c) 2011 - 2018, 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. + */ + +/** + @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server + @{ + @brief Definitions and prototypes for the GATTS interface. + */ + +#ifndef BLE_GATTS_H__ +#define BLE_GATTS_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" +#include "ble_gatt.h" +#include "ble_gap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations + * @{ */ + +/** + * @brief GATTS API SVC numbers. + */ +enum BLE_GATTS_SVCS +{ + SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */ + SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */ + SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */ + SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */ + SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */ + SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */ + SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */ + SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */ + SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */ + SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */ + SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */ + SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */ + SD_BLE_GATTS_ATTR_GET, /**< Retrieve the UUID and/or metadata of an attribute. */ + SD_BLE_GATTS_EXCHANGE_MTU_REPLY /**< Reply to Exchange MTU Request. */ +}; + +/** + * @brief GATT Server Event IDs. + */ +enum BLE_GATTS_EVTS +{ + BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */ + BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */ + BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */ + BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */ + BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. \n No additional event structure applies. */ + BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. \n Reply with @ref sd_ble_gatts_exchange_mtu_reply. \n See @ref ble_gatts_evt_exchange_mtu_request_t. */ + BLE_GATTS_EVT_TIMEOUT, /**< Peer failed to respond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */ + BLE_GATTS_EVT_HVN_TX_COMPLETE /**< Handle Value Notification transmission complete. \n See @ref ble_gatts_evt_hvn_tx_complete_t. */ +}; + +/**@brief GATTS Configuration IDs. + * + * IDs that uniquely identify a GATTS configuration. + */ +enum BLE_GATTS_CFGS +{ + BLE_GATTS_CFG_SERVICE_CHANGED = BLE_GATTS_CFG_BASE, /**< Service changed configuration. */ + BLE_GATTS_CFG_ATTR_TAB_SIZE, /**< Attribute table size configuration. */ +}; + +/** @} */ + +/** @addtogroup BLE_GATTS_DEFINES Defines + * @{ */ + +/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS + * @{ */ +#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */ +#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */ +/** @} */ + +/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths + * @{ */ +#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */ +#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */ +/** @} */ + +/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types + * @{ */ +#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */ +#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */ +#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */ +/** @} */ + + +/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types + * @{ */ +#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */ +#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */ +#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */ +#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */ +#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */ +#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */ +#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */ +#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */ +/** @} */ + + +/** @defgroup BLE_GATTS_OPS GATT Server Operations + * @{ */ +#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */ +#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */ +#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ +#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ +#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */ +#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */ +/** @} */ + +/** @defgroup BLE_GATTS_VLOCS GATT Value Locations + * @{ */ +#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */ +#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */ +#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack + will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */ +/** @} */ + +/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types + * @{ */ +#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */ +#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */ +#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */ +/** @} */ + +/** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags + * @{ */ +#define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */ +#define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */ +/** @} */ + +/** @defgroup BLE_GATTS_SERVICE_CHANGED Service Changed Inclusion Values + * @{ + */ +#define BLE_GATTS_SERVICE_CHANGED_DEFAULT (1) /**< Default is to include the Service Changed characteristic in the Attribute Table. */ +/** @} */ + +/** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size + * @{ + */ +#define BLE_GATTS_ATTR_TAB_SIZE_MIN (248) /**< Minimum Attribute Table size */ +#define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT (1408) /**< Default Attribute Table size. */ +/** @} */ + +/** @defgroup BLE_GATTS_DEFAULTS GATT Server defaults + * @{ + */ +#define BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT 1 /**< Default number of Handle Value Notifications that can be queued for transmission. */ +/** @} */ + +/** @} */ + +/** @addtogroup BLE_GATTS_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE GATTS connection configuration parameters, set with @ref sd_ble_cfg_set. + */ +typedef struct +{ + uint8_t hvn_tx_queue_size; /**< Minimum guaranteed number of Handle Value Notifications that can be queued for transmission. + The default value is @ref BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT */ +} ble_gatts_conn_cfg_t; + +/**@brief Attribute metadata. */ +typedef struct +{ + ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ + uint8_t vlen :1; /**< Variable length attribute. */ + uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ + uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */ + uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */ +} ble_gatts_attr_md_t; + + +/**@brief GATT Attribute. */ +typedef struct +{ + ble_uuid_t const *p_uuid; /**< Pointer to the attribute UUID. */ + ble_gatts_attr_md_t const *p_attr_md; /**< Pointer to the attribute metadata structure. */ + uint16_t init_len; /**< Initial attribute value length in bytes. */ + uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */ + uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */ + uint8_t *p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer + that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location. + The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/ +} ble_gatts_attr_t; + +/**@brief GATT Attribute Value. */ +typedef struct +{ + uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/ + uint16_t offset; /**< Attribute value offset. */ + uint8_t *p_value; /**< Pointer to where value is stored or will be stored. + If value is stored in user memory, only the attribute length is updated when p_value == NULL. + Set to NULL when reading to obtain the complete length of the attribute value */ +} ble_gatts_value_t; + + +/**@brief GATT Characteristic Presentation Format. */ +typedef struct +{ + uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */ + int8_t exponent; /**< Exponent for integer data types. */ + uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */ + uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ + uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ +} ble_gatts_char_pf_t; + + +/**@brief GATT Characteristic metadata. */ +typedef struct +{ + ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ + ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */ + uint8_t const *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */ + uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */ + uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */ + ble_gatts_char_pf_t const *p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */ + ble_gatts_attr_md_t const *p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */ + ble_gatts_attr_md_t const *p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */ + ble_gatts_attr_md_t const *p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */ +} ble_gatts_char_md_t; + + +/**@brief GATT Characteristic Definition Handles. */ +typedef struct +{ + uint16_t value_handle; /**< Handle to the characteristic value. */ + uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ + uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ + uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ +} ble_gatts_char_handles_t; + + +/**@brief GATT HVx parameters. */ +typedef struct +{ + uint16_t handle; /**< Characteristic Value Handle. */ + uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ + uint16_t offset; /**< Offset within the attribute value. */ + uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after return. */ + uint8_t const *p_data; /**< Actual data content, use NULL to use the current attribute value. */ +} ble_gatts_hvx_params_t; + +/**@brief GATT Authorization parameters. */ +typedef struct +{ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ + uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value. + Please note that for @ref BLE_GATTS_AUTHORIZE_TYPE_WRITE operations this bit must always be set, + as the data to be written needs to be stored and later provided by the application. */ + uint16_t offset; /**< Offset of the attribute value being updated. */ + uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */ + uint8_t const *p_data; /**< Pointer to new value used to update the attribute value. */ +} ble_gatts_authorize_params_t; + +/**@brief GATT Read or Write Authorize Reply parameters. */ +typedef struct +{ + uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ + union { + ble_gatts_authorize_params_t read; /**< Read authorization parameters. */ + ble_gatts_authorize_params_t write; /**< Write authorization parameters. */ + } params; /**< Reply Parameters. */ +} ble_gatts_rw_authorize_reply_params_t; + +/**@brief Service Changed Inclusion configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t service_changed : 1; /**< If 1, include the Service Changed characteristic in the Attribute Table. Default is @ref BLE_GATTS_SERVICE_CHANGED_DEFAULT. */ +} ble_gatts_cfg_service_changed_t; + +/**@brief Attribute table size configuration parameters, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true: + * - The specified Attribute Table size is too small. + * The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN. + * - The specified Attribute Table size is not a multiple of 4. + */ +typedef struct +{ + uint32_t attr_tab_size; /**< Attribute table size. Default is @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT, minimum is @ref BLE_GATTS_ATTR_TAB_SIZE_MIN. */ +} ble_gatts_cfg_attr_tab_size_t; + +/**@brief Config structure for GATTS configurations. */ +typedef union +{ + ble_gatts_cfg_service_changed_t service_changed; /**< Include service changed characteristic, cfg_id is @ref BLE_GATTS_CFG_SERVICE_CHANGED. */ + ble_gatts_cfg_attr_tab_size_t attr_tab_size; /**< Attribute table size, cfg_id is @ref BLE_GATTS_CFG_ATTR_TAB_SIZE. */ +} ble_gatts_cfg_t; + + +/**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + ble_uuid_t uuid; /**< Attribute UUID. */ + uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */ + uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalize the writing operation. */ + uint16_t offset; /**< Offset for the write operation. */ + uint16_t len; /**< Length of the received data. */ + uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gatts_evt_write_t; + +/**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + ble_uuid_t uuid; /**< Attribute UUID. */ + uint16_t offset; /**< Offset for the read operation. */ +} ble_gatts_evt_read_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */ +typedef struct +{ + uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ + union { + ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */ + ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */ + } request; /**< Request Parameters. */ +} ble_gatts_evt_rw_authorize_request_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */ +typedef struct +{ + uint8_t hint; /**< Hint (currently unused). */ +} ble_gatts_evt_sys_attr_missing_t; + + +/**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ +} ble_gatts_evt_hvc_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST. */ +typedef struct +{ + uint16_t client_rx_mtu; /**< Client RX MTU size. */ +} ble_gatts_evt_exchange_mtu_request_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ +} ble_gatts_evt_timeout_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_HVN_TX_COMPLETE. */ +typedef struct +{ + uint8_t count; /**< Number of notification transmissions completed. */ +} ble_gatts_evt_hvn_tx_complete_t; + +/**@brief GATTS event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which the event occurred. */ + union + { + ble_gatts_evt_write_t write; /**< Write Event Parameters. */ + ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */ + ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */ + ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */ + ble_gatts_evt_exchange_mtu_request_t exchange_mtu_request; /**< Exchange MTU Request Event Parameters. */ + ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */ + ble_gatts_evt_hvn_tx_complete_t hvn_tx_complete; /**< Handle Value Notification transmission complete Event Parameters. */ + } params; /**< Event Parameters. */ +} ble_gatts_evt_t; + +/** @} */ + +/** @addtogroup BLE_GATTS_FUNCTIONS Functions + * @{ */ + +/**@brief Add a service declaration to the Attribute Table. + * + * @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to + * add a secondary service declaration that is not referenced by another service later in the Attribute Table. + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES. + * @param[in] p_uuid Pointer to service UUID. + * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully added a service declaration. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)); + + +/**@brief Add an include declaration to the Attribute Table. + * + * @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time). + * + * @note The included service must already be present in the Attribute Table prior to this call. + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] inc_srvc_handle Handle of the included service. + * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully added an include declaration. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. + * @retval ::NRF_ERROR_NOT_SUPPORTED Feature is not supported, service_handle must be that of the last added service. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + */ +SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle)); + + +/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table. + * + * @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time). + * + * @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writable auxiliaries bits, + * readable (no security) and writable (selectable) CCCDs and SCCDs and valid presentation format values. + * + * @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions. + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] p_char_md Characteristic metadata. + * @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value. + * @param[out] p_handles Pointer to the structure where the assigned handles will be stored. + * + * @retval ::NRF_SUCCESS Successfully added a characteristic. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles)); + + +/**@brief Add a descriptor to the Attribute Table. + * + * @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time). + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] p_attr Pointer to the attribute structure. + * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully added a descriptor. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle)); + +/**@brief Set the value of a given attribute. + * + * @note Values other than system attributes can be set at any time, regardless of whether any active connections exist. + * + * @mscs + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute. + * @param[in] handle Attribute handle. + * @param[in,out] p_value Attribute value information. + * + * @retval ::NRF_SUCCESS Successfully set the value of the attribute. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute. + */ +SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)); + +/**@brief Get the value of a given attribute. + * + * @note If the attribute value is longer than the size of the supplied buffer, + * @ref ble_gatts_value_t::len will return the total attribute value length (excluding offset), + * and not the number of bytes actually returned in @ref ble_gatts_value_t::p_value. + * The application may use this information to allocate a suitable buffer size. + * + * @note When retrieving system attribute values with this function, the connection handle + * may refer to an already disconnected connection. Refer to the documentation of + * @ref sd_ble_gatts_sys_attr_get for further information. + * + * @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute. + * @param[in] handle Attribute handle. + * @param[in,out] p_value Attribute value information. + * + * @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute. + * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + */ +SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)); + +/**@brief Notify or Indicate an attribute value. + * + * @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation + * (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that + * the application can atomically perform a value update and a server initiated transaction with a single API call. + * + * @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. + * The Attribute Table has been updated if one of the following error codes is returned: @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, + * @ref NRF_ERROR_FORBIDDEN, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and @ref NRF_ERROR_RESOURCES. + * The caller can check whether the value has been updated by looking at the contents of *(@ref ble_gatts_hvx_params_t::p_len). + * + * @note Only one indication procedure can be ongoing per connection at a time. + * If the application tries to indicate an attribute value while another indication procedure is ongoing, + * the function call will return @ref NRF_ERROR_BUSY. + * A @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from the peer. + * + * @note The number of Handle Value Notifications that can be queued is configured by @ref ble_gatts_conn_cfg_t::hvn_tx_queue_size + * When the queue is full, the function call will return @ref NRF_ERROR_RESOURCES. + * A @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event will be issued as soon as the transmission of the notification is complete. + * + * @note The application can keep track of the available queue element count for notifications by following the procedure below: + * - Store initial queue element count in a variable. + * - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS. + * - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event. + * + * @events + * @event{@ref BLE_GATTS_EVT_HVN_TX_COMPLETE, Notification transmission complete.} + * @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from the peer.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} + * @mmsc{@ref BLE_GATTS_HVN_MSC} + * @mmsc{@ref BLE_GATTS_HVI_MSC} + * @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in,out] p_hvx_params Pointer to an HVx parameters structure. If @ref ble_gatts_hvx_params_t::p_data + * contains a non-NULL pointer the attribute value will be updated with the contents + * pointed by it before sending the notification or indication. If the attribute value + * is updated, @ref ble_gatts_hvx_params_t::p_len is updated by the SoftDevice to + * contain the number of actual bytes written, else it will be set to 0. + * + * @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true: + * - Invalid Connection State + * - Notifications and/or indications not enabled in the CCCD + * - An ATT_MTU exchange is ongoing + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate. + * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + * @retval ::NRF_ERROR_FORBIDDEN The connection's current security level is lower than the one required by the write permissions of the CCCD associated with this characteristic. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @retval ::NRF_ERROR_BUSY For @ref BLE_GATT_HVX_INDICATION Procedure already in progress. Wait for a @ref BLE_GATTS_EVT_HVC event and retry. + * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + * @retval ::NRF_ERROR_RESOURCES Too many notifications queued. + * Wait for a @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event and retry. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)); + +/**@brief Indicate the Service Changed attribute value. + * + * @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute + * Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will + * be issued. + * + * @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here. + * + * @events + * @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTS_SC_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] start_handle Start of affected attribute handle range. + * @param[in] end_handle End of affected attribute handle range. + * + * @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref + * sd_ble_cfg_set and @ref ble_gatts_cfg_service_changed_t. + * @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true: + * - Invalid Connection State + * - Notifications and/or indications not enabled in the CCCD + * - An ATT_MTU exchange is ongoing + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application. + * @retval ::NRF_ERROR_BUSY Procedure already in progress. + * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)); + +/**@brief Respond to a Read/Write authorization request. + * + * @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application. + * + * @mscs + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} + * @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_PEER_CANCEL_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application. + * + * @note @ref ble_gatts_authorize_params_t::p_data is ignored when this function is used to respond + * to a @ref BLE_GATTS_AUTHORIZE_TYPE_READ event if @ref ble_gatts_authorize_params_t::update + * is set to 0. + * + * @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending. + * @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid, + * handle supplied does not match requested handle, + * or invalid data to be written provided by the application. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params)); + + +/**@brief Update persistent system attribute information. + * + * @details Supply information about persistent system attributes to the stack, + * previously obtained using @ref sd_ble_gatts_sys_attr_get. + * This call is only allowed for active connections, and is usually + * made immediately after a connection is established with an known bonded device, + * often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. + * + * p_sysattrs may point directly to the application's stored copy of the system attributes + * obtained using @ref sd_ble_gatts_sys_attr_get. + * If the pointer is NULL, the system attribute info is initialized, assuming that + * the application does not have any previously saved system attribute data for this device. + * + * @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration. + * + * @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially. + * This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or + * reset the SoftDevice to return to a known state. + * + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified. + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified. + * + * @mscs + * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} + * @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC} + * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL. + * @param[in] len Size of data pointed by p_sys_attr_data, in octets. + * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS + * + * @retval ::NRF_SUCCESS Successfully set the system attribute information. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied. + * @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags)); + + +/**@brief Retrieve persistent system attribute information from the stack. + * + * @details This call is used to retrieve information about values to be stored persistently by the application + * during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device, + * the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set. + * If retrieved after disconnection, the data should be read before a new connection established. The connection handle for + * the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it. + * Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes + * may be written to at any time by the peer during a connection's lifetime. + * + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned. + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned. + * + * @mscs + * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle of the recently terminated connection. + * @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described + * in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data. + * @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditionally updated to actual length of system attribute data. + * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS + * + * @retval ::NRF_SUCCESS Successfully retrieved the system attribute information. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied. + * @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer. + * @retval ::NRF_ERROR_NOT_FOUND No system attributes found. + */ +SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags)); + + +/**@brief Retrieve the first valid user attribute handle. + * + * @param[out] p_handle Pointer to an integer where the handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully retrieved the handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle)); + +/**@brief Retrieve the attribute UUID and/or metadata. + * + * @param[in] handle Attribute handle + * @param[out] p_uuid UUID of the attribute. Use NULL to omit this field. + * @param[out] p_md Metadata of the attribute. Use NULL to omit this field. + * + * @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata, + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL. + * @retval ::NRF_ERROR_NOT_FOUND Attribute was not found. + */ +SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md)); + +/**@brief Reply to an ATT_MTU exchange request by sending an Exchange MTU Response to the client. + * + * @details This function is only used to reply to a @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST event. + * + * @details The SoftDevice sets ATT_MTU to the minimum of: + * - The Client RX MTU value from @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, and + * - The Server RX MTU value. + * + * However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_ATT_MTU_DEFAULT. + * + * @mscs + * @mmsc{@ref BLE_GATTS_MTU_EXCHANGE} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] server_rx_mtu Server RX MTU size. + * - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. + * - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration + * used for this connection. + * - The value must be equal to Client RX MTU size given in @ref sd_ble_gattc_exchange_mtu_request + * if an ATT_MTU exchange has already been performed in the other direction. + * + * @retval ::NRF_SUCCESS Successfully sent response to the client. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no ATT_MTU exchange request pending. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid Server RX MTU size supplied. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu)); +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_GATTS_H__ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_hci.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_hci.h new file mode 100644 index 0000000..f0dde9a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_hci.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2012 - 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. + */ + +/** + @addtogroup BLE_COMMON + @{ +*/ + + +#ifndef BLE_HCI_H__ +#define BLE_HCI_H__ +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes + * @{ */ + +#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 /**< Success. */ +#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 /**< Unknown BLE Command. */ +#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 /**< Unknown Connection Identifier. */ +/*0x03 Hardware Failure +0x04 Page Timeout +*/ +#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 /**< Authentication Failure. */ +#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 /**< Pin or Key missing. */ +#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 /**< Memory Capacity Exceeded. */ +#define BLE_HCI_CONNECTION_TIMEOUT 0x08 /**< Connection Timeout. */ +/*0x09 Connection Limit Exceeded +0x0A Synchronous Connection Limit To A Device Exceeded +0x0B ACL Connection Already Exists*/ +#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C /**< Command Disallowed. */ +/*0x0D Connection Rejected due to Limited Resources +0x0E Connection Rejected Due To Security Reasons +0x0F Connection Rejected due to Unacceptable BD_ADDR +0x10 Connection Accept Timeout Exceeded +0x11 Unsupported Feature or Parameter Value*/ +#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 /**< Invalid BLE Command Parameters. */ +#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */ +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 /**< Remote Device Terminated Connection due to low resources.*/ +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 /**< Remote Device Terminated Connection due to power off. */ +#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 /**< Local Host Terminated Connection. */ +/* +0x17 Repeated Attempts +0x18 Pairing Not Allowed +0x19 Unknown LMP PDU +*/ +#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A /**< Unsupported Remote Feature. */ +/* +0x1B SCO Offset Rejected +0x1C SCO Interval Rejected +0x1D SCO Air Mode Rejected*/ +#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E /**< Invalid LMP Parameters. */ +#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F /**< Unspecified Error. */ +/*0x20 Unsupported LMP Parameter Value +0x21 Role Change Not Allowed +*/ +#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 /**< LMP Response Timeout. */ +#define BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23 /**< LMP Error Transaction Collision/LL Procedure Collision. */ +#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 /**< LMP PDU Not Allowed. */ +/*0x25 Encryption Mode Not Acceptable +0x26 Link Key Can Not be Changed +0x27 Requested QoS Not Supported +*/ +#define BLE_HCI_INSTANT_PASSED 0x28 /**< Instant Passed. */ +#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 /**< Pairing with Unit Key Unsupported. */ +#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A /**< Different Transaction Collision. */ +/* +0x2B Reserved +0x2C QoS Unacceptable Parameter +0x2D QoS Rejected +0x2E Channel Classification Not Supported +0x2F Insufficient Security +*/ +#define BLE_HCI_PARAMETER_OUT_OF_MANDATORY_RANGE 0x30 /**< Parameter Out Of Mandatory Range. */ +/* +0x31 Reserved +0x32 Role Switch Pending +0x33 Reserved +0x34 Reserved Slot Violation +0x35 Role Switch Failed +0x36 Extended Inquiry Response Too Large +0x37 Secure Simple Pairing Not Supported By Host. +0x38 Host Busy - Pairing +0x39 Connection Rejected due to No Suitable Channel Found*/ +#define BLE_HCI_CONTROLLER_BUSY 0x3A /**< Controller Busy. */ +#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B /**< Connection Interval Unacceptable. */ +#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C /**< Directed Advertisement Timeout. */ +#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D /**< Connection Terminated due to MIC Failure. */ +#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E /**< Connection Failed to be Established. */ + +/** @} */ + + +#ifdef __cplusplus +} +#endif +#endif // BLE_HCI_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_l2cap.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_l2cap.h similarity index 90% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_l2cap.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_l2cap.h index 3b53ded..edaf664 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_l2cap.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_l2cap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,10 +45,12 @@ #ifndef BLE_L2CAP_H__ #define BLE_L2CAP_H__ -#include "ble_types.h" +#include +#include "nrf_svc.h" +#include "nrf_error.h" #include "ble_ranges.h" +#include "ble_types.h" #include "ble_err.h" -#include "nrf_svc.h" #ifdef __cplusplus extern "C" { @@ -82,32 +84,32 @@ extern "C" { /**@brief L2CAP API SVC numbers. */ enum BLE_L2CAP_SVCS { - SD_BLE_L2CAP_CH_SETUP = BLE_L2CAP_SVC_BASE, /**< Set up an L2CAP channel. */ - SD_BLE_L2CAP_CH_RELEASE, /**< Release an L2CAP channel. */ - SD_BLE_L2CAP_CH_RX, /**< Receive an SDU on an L2CAP channel. */ - SD_BLE_L2CAP_CH_TX, /**< Transmit an SDU on an L2CAP channel. */ - SD_BLE_L2CAP_CH_FLOW_CONTROL, /**< Advanced SDU reception flow control. */ + SD_BLE_L2CAP_CH_SETUP = BLE_L2CAP_SVC_BASE + 0, /**< Set up an L2CAP channel. */ + SD_BLE_L2CAP_CH_RELEASE = BLE_L2CAP_SVC_BASE + 1, /**< Release an L2CAP channel. */ + SD_BLE_L2CAP_CH_RX = BLE_L2CAP_SVC_BASE + 2, /**< Receive an SDU on an L2CAP channel. */ + SD_BLE_L2CAP_CH_TX = BLE_L2CAP_SVC_BASE + 3, /**< Transmit an SDU on an L2CAP channel. */ + SD_BLE_L2CAP_CH_FLOW_CONTROL = BLE_L2CAP_SVC_BASE + 4, /**< Advanced SDU reception flow control. */ }; /**@brief L2CAP Event IDs. */ enum BLE_L2CAP_EVTS { - BLE_L2CAP_EVT_CH_SETUP_REQUEST = BLE_L2CAP_EVT_BASE, /**< L2CAP Channel Setup Request event. - \n See @ref ble_l2cap_evt_ch_setup_request_t. */ - BLE_L2CAP_EVT_CH_SETUP_REFUSED, /**< L2CAP Channel Setup Refused event. - \n See @ref ble_l2cap_evt_ch_setup_refused_t. */ - BLE_L2CAP_EVT_CH_SETUP, /**< L2CAP Channel Setup Completed event. - \n See @ref ble_l2cap_evt_ch_setup_t. */ - BLE_L2CAP_EVT_CH_RELEASED, /**< L2CAP Channel Released event. - \n No additional event structure applies. */ - BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED, /**< L2CAP Channel SDU data buffer released event. - \n See @ref ble_l2cap_evt_ch_sdu_buf_released_t. */ - BLE_L2CAP_EVT_CH_CREDIT, /**< L2CAP Channel Credit received. - \n See @ref ble_l2cap_evt_ch_credit_t. */ - BLE_L2CAP_EVT_CH_RX, /**< L2CAP Channel SDU received. - \n See @ref ble_l2cap_evt_ch_rx_t. */ - BLE_L2CAP_EVT_CH_TX, /**< L2CAP Channel SDU transmitted. - \n See @ref ble_l2cap_evt_ch_tx_t. */ + BLE_L2CAP_EVT_CH_SETUP_REQUEST = BLE_L2CAP_EVT_BASE + 0, /**< L2CAP Channel Setup Request event. + \n See @ref ble_l2cap_evt_ch_setup_request_t. */ + BLE_L2CAP_EVT_CH_SETUP_REFUSED = BLE_L2CAP_EVT_BASE + 1, /**< L2CAP Channel Setup Refused event. + \n See @ref ble_l2cap_evt_ch_setup_refused_t. */ + BLE_L2CAP_EVT_CH_SETUP = BLE_L2CAP_EVT_BASE + 2, /**< L2CAP Channel Setup Completed event. + \n See @ref ble_l2cap_evt_ch_setup_t. */ + BLE_L2CAP_EVT_CH_RELEASED = BLE_L2CAP_EVT_BASE + 3, /**< L2CAP Channel Released event. + \n No additional event structure applies. */ + BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED = BLE_L2CAP_EVT_BASE + 4, /**< L2CAP Channel SDU data buffer released event. + \n See @ref ble_l2cap_evt_ch_sdu_buf_released_t. */ + BLE_L2CAP_EVT_CH_CREDIT = BLE_L2CAP_EVT_BASE + 5, /**< L2CAP Channel Credit received. + \n See @ref ble_l2cap_evt_ch_credit_t. */ + BLE_L2CAP_EVT_CH_RX = BLE_L2CAP_EVT_BASE + 6, /**< L2CAP Channel SDU received. + \n See @ref ble_l2cap_evt_ch_rx_t. */ + BLE_L2CAP_EVT_CH_TX = BLE_L2CAP_EVT_BASE + 7, /**< L2CAP Channel SDU transmitted. + \n See @ref ble_l2cap_evt_ch_tx_t. */ }; /** @} */ @@ -250,7 +252,7 @@ typedef struct ble_l2cap_ch_tx_params_t tx_params; /**< L2CAP channel TX parameters. */ } ble_l2cap_evt_ch_setup_t; -/**@brief L2CAP Channel SDU Data Duffer Released event. */ +/**@brief L2CAP Channel SDU Data Buffer Released event. */ typedef struct { ble_data_t sdu_buf; /**< Returned reception or transmission SDU data buffer. The SoftDevice @@ -472,8 +474,8 @@ SVCALL(SD_BLE_L2CAP_CH_TX, uint32_t, sd_ble_l2cap_ch_tx(uint16_t conn_handle, ui * available to the peer. If the value written by the SoftDevice is 0 when * credits parameter was set to 0, the peer will not be able to send more * data until more credits are provided by calling this function again with - * credits > 0. This parameter is ignored when local_cid is set to @ref - * BLE_L2CAP_CID_INVALID. + * credits > 0. This parameter is ignored when local_cid is set to + * @ref BLE_L2CAP_CID_INVALID. * * @note Application should take care when setting number of credits higher than default value. In * this case the application must make sure that the SoftDevice always has reception buffers diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_ranges.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_ranges.h similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_ranges.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_ranges.h index 5b9d891..0935bca 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/headers/ble_ranges.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_ranges.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2012 - 2018, Nordic Semiconductor ASA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -67,15 +67,15 @@ extern "C" { #define BLE_SVC_LAST 0x6B /**< Common BLE SVC last. */ #define BLE_GAP_SVC_BASE 0x6C /**< GAP BLE SVC base. */ -#define BLE_GAP_SVC_LAST 0x93 /**< GAP BLE SVC last. */ +#define BLE_GAP_SVC_LAST 0x9A /**< GAP BLE SVC last. */ -#define BLE_GATTC_SVC_BASE 0x94 /**< GATTC BLE SVC base. */ -#define BLE_GATTC_SVC_LAST 0x9F /**< GATTC BLE SVC last. */ +#define BLE_GATTC_SVC_BASE 0x9B /**< GATTC BLE SVC base. */ +#define BLE_GATTC_SVC_LAST 0xA7 /**< GATTC BLE SVC last. */ -#define BLE_GATTS_SVC_BASE 0xA0 /**< GATTS BLE SVC base. */ -#define BLE_GATTS_SVC_LAST 0xAF /**< GATTS BLE SVC last. */ +#define BLE_GATTS_SVC_BASE 0xA8 /**< GATTS BLE SVC base. */ +#define BLE_GATTS_SVC_LAST 0xB7 /**< GATTS BLE SVC last. */ -#define BLE_L2CAP_SVC_BASE 0xB0 /**< L2CAP BLE SVC base. */ +#define BLE_L2CAP_SVC_BASE 0xB8 /**< L2CAP BLE SVC base. */ #define BLE_L2CAP_SVC_LAST 0xBF /**< L2CAP BLE SVC last. */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_types.h new file mode 100644 index 0000000..88c9318 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/ble_types.h @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2012 - 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. + */ + +/** + @addtogroup BLE_COMMON + @{ + @defgroup ble_types Common types and macro definitions + @{ + + @brief Common types and macro definitions for the BLE SoftDevice. + */ + +#ifndef BLE_TYPES_H__ +#define BLE_TYPES_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_TYPES_DEFINES Defines + * @{ */ + +/** @defgroup BLE_CONN_HANDLES BLE Connection Handles + * @{ */ +#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */ +#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */ +/** @} */ + + +/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs + * @{ */ +/* Generic UUIDs, applicable to all services */ +#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */ +#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */ +#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */ +#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */ +#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */ +#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */ +#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */ +/* GATT specific UUIDs */ +#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */ +#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */ +/* GAP specific UUIDs */ +#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */ +#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_CAR 0x2AA6 /**< Central Address Resolution Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_RPA_ONLY 0x2AC9 /**< Resolvable Private Address Only Characteristic. */ +/** @} */ + + +/** @defgroup BLE_UUID_TYPES Types of UUID + * @{ */ +#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */ +#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */ +#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */ +/** @} */ + + +/** @defgroup BLE_APPEARANCES Bluetooth Appearance values + * @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml + * @{ */ +#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */ +#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */ +#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */ +#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */ +#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */ +#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */ +#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */ +#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */ +#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */ +#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */ +#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */ +#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */ +#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */ +#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */ +#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */ +#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */ +#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */ +#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */ +#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */ +#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */ +#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */ +#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */ +#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */ +#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystick (HID Subtype). */ +#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */ +#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */ +#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */ +#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */ +#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */ +#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */ +#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */ +#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */ +#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */ +#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */ +#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */ +#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */ +#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */ +#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */ +#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */ +#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */ +#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */ +#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */ +/** @} */ + +/** @brief Set .type and .uuid fields of ble_uuid_struct to specified UUID value. */ +#define BLE_UUID_BLE_ASSIGN(instance, value) do {\ + instance.type = BLE_UUID_TYPE_BLE; \ + instance.uuid = value;} while(0) + +/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */ +#define BLE_UUID_COPY_PTR(dst, src) do {\ + (dst)->type = (src)->type; \ + (dst)->uuid = (src)->uuid;} while(0) + +/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */ +#define BLE_UUID_COPY_INST(dst, src) do {\ + (dst).type = (src).type; \ + (dst).uuid = (src).uuid;} while(0) + +/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */ +#define BLE_UUID_EQ(p_uuid1, p_uuid2) \ + (((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid)) + +/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */ +#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \ + (((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid)) + +/** @} */ + +/** @addtogroup BLE_TYPES_STRUCTURES Structures + * @{ */ + +/** @brief 128 bit UUID values. */ +typedef struct +{ + uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */ +} ble_uuid128_t; + +/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */ +typedef struct +{ + uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */ + uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is @ref BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */ +} ble_uuid_t; + +/**@brief Data structure. */ +typedef struct +{ + uint8_t *p_data; /**< Pointer to the data buffer provided to/from the application. */ + uint16_t len; /**< Length of the data buffer, in bytes. */ +} ble_data_t; + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* BLE_TYPES_H__ */ + +/** + @} + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf52/nrf_mbr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf52/nrf_mbr.h new file mode 100644 index 0000000..42e09fc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf52/nrf_mbr.h @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2014 - 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. + */ + +/** + @defgroup nrf_mbr_api Master Boot Record API + @{ + + @brief APIs for updating SoftDevice and BootLoader + +*/ + +#ifndef NRF_MBR_H__ +#define NRF_MBR_H__ + +#include "nrf_svc.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup NRF_MBR_DEFINES Defines + * @{ */ + +/**@brief MBR SVC Base number. */ +#define MBR_SVC_BASE (0x18) + +/**@brief Page size in words. */ +#define MBR_PAGE_SIZE_IN_WORDS (1024) + +/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash. +This is the offset where the first byte of the SoftDevice hex file is written. */ +#define MBR_SIZE (0x1000) + +/** @brief Location (in the flash memory) of the bootloader address. */ +#define MBR_BOOTLOADER_ADDR (0xFF8) + +/** @brief Location (in UICR) of the bootloader address. */ +#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0])) + +/** @brief Location (in the flash memory) of the address of the MBR parameter page. */ +#define MBR_PARAM_PAGE_ADDR (0xFFC) + +/** @brief Location (in UICR) of the address of the MBR parameter page. */ +#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1])) + + +/** @} */ + +/** @addtogroup NRF_MBR_ENUMS Enumerations + * @{ */ + +/**@brief nRF Master Boot Record API SVC numbers. */ +enum NRF_MBR_SVCS +{ + SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */ +}; + +/**@brief Possible values for ::sd_mbr_command_t.command */ +enum NRF_MBR_COMMANDS +{ + SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/ + SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/ + SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/ + SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/ + SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/ + SD_MBR_COMMAND_RESERVED, + SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/ +}; + +/** @} */ + +/** @addtogroup NRF_MBR_TYPES Types + * @{ */ + +/**@brief This command copies part of a new SoftDevice + * + * The destination area is erased before copying. + * If dst is in the middle of a flash page, that whole flash page will be erased. + * If (dst+len) is in the middle of a flash page, that whole flash page will be erased. + * + * The user of this function is responsible for setting the BPROT registers. + * + * @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly. + * @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying. + */ +typedef struct +{ + uint32_t *src; /**< Pointer to the source of data to be copied.*/ + uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/ + uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/ +} sd_mbr_command_copy_sd_t; + + +/**@brief This command works like memcmp, but takes the length in words. + * + * @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal. + * @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal. + */ +typedef struct +{ + uint32_t *ptr1; /**< Pointer to block of memory. */ + uint32_t *ptr2; /**< Pointer to block of memory. */ + uint32_t len; /**< Number of 32 bit words to compare.*/ +} sd_mbr_command_compare_t; + + +/**@brief This command copies a new BootLoader. + * + * The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to + * the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * The bootloader destination is erased by this function. + * If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased. + * + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. + * + * This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is + * not intended to be written. + * + * On success, this function will not return. It will start the new bootloader from reset-vector as normal. + * + * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. + * @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set. + * @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. + */ +typedef struct +{ + uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/ + uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */ +} sd_mbr_command_copy_bl_t; + +/**@brief Change the address the MBR starts after a reset + * + * Once this function has been called, this address is where the MBR will start to forward + * interrupts to after a reset. + * + * To restore default forwarding, this function should be called with @ref address set to 0. If a + * bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will + * be forwarded to the SoftDevice. + * + * The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or + * @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. + * + * On success, this function will not return. It will reset the device. + * + * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. + * @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. + */ +typedef struct +{ + uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ +} sd_mbr_command_vector_table_base_set_t; + +/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR + * + * Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not + * change where the MBR starts after reset. + * + * @retval ::NRF_SUCCESS + */ +typedef struct +{ + uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ +} sd_mbr_command_irq_forward_address_set_t; + +/**@brief Input structure containing data used when calling ::sd_mbr_command + * + * Depending on what command value that is set, the corresponding params value type must also be + * set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command + * @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params. + */ +typedef struct +{ + uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */ + union + { + sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/ + sd_mbr_command_compare_t compare; /**< Parameters for verify.*/ + sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */ + sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/ + sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/ + } params; /**< Command parameters. */ +} sd_mbr_command_t; + +/** @} */ + +/** @addtogroup NRF_MBR_FUNCTIONS Functions + * @{ */ + +/**@brief Issue Master Boot Record commands + * + * Commands used when updating a SoftDevice and bootloader. + * + * The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires + * parameters to be retained by the MBR when resetting the IC. This is done in a separate flash + * page. The location of the flash page should be provided by the application in either + * @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR + * will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to + * store the command before reset. When an address is specified, the page it refers to must not be + * used by the application. If no address is provided by the application, i.e. both + * @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use + * flash will be unavailable and return @ref NRF_ERROR_NO_MEM. + * + * @param[in] param Pointer to a struct describing the command. + * + * @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t, + * ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t, + * ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t + * + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided + * @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given. +*/ +SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param)); + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_MBR_H__ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error.h new file mode 100644 index 0000000..6badee9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014 - 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. + */ + + /** + @defgroup nrf_error SoftDevice Global Error Codes + @{ + + @brief Global Error definitions +*/ + +/* Header guard */ +#ifndef NRF_ERROR_H__ +#define NRF_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions + * @{ */ +#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base +#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base +#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base +#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base +/** @} */ + +#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command +#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing +#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled +#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error +#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation +#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found +#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported +#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter +#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state +#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length +#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags +#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data +#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size +#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out +#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer +#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation +#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address +#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy +#define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded. +#define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation + +#ifdef __cplusplus +} +#endif +#endif // NRF_ERROR_H__ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_sdm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_sdm.h new file mode 100644 index 0000000..530959b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_sdm.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2012 - 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. + */ + + /** + @addtogroup nrf_sdm_api + @{ + @defgroup nrf_sdm_error SoftDevice Manager Error Codes + @{ + + @brief Error definitions for the SDM API +*/ + +/* Header guard */ +#ifndef NRF_ERROR_SDM_H__ +#define NRF_ERROR_SDM_H__ + +#include "nrf_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source. +#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). +#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing). + +#ifdef __cplusplus +} +#endif +#endif // NRF_ERROR_SDM_H__ + +/** + @} + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_soc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_soc.h new file mode 100644 index 0000000..1e784b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_error_soc.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012 - 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. + */ + +/** + @addtogroup nrf_soc_api + @{ + @defgroup nrf_soc_error SoC Library Error Codes + @{ + + @brief Error definitions for the SoC library + +*/ + +/* Header guard */ +#ifndef NRF_ERROR_SOC_H__ +#define NRF_ERROR_SOC_H__ + +#include "nrf_error.h" +#ifdef __cplusplus +extern "C" { +#endif + +/* Mutex Errors */ +#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken + +/* NVIC errors */ +#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available +#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed +#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return + +/* Power errors */ +#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown +#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown +#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return + +/* Rand errors */ +#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values + +/* PPI errors */ +#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel +#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group + +#ifdef __cplusplus +} +#endif +#endif // NRF_ERROR_SOC_H__ +/** + @} + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_nvic.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_nvic.h new file mode 100644 index 0000000..1f79cc3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_nvic.h @@ -0,0 +1,491 @@ +/* + * Copyright (c) 2016 - 2018, 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. + */ + +/** + * @defgroup nrf_nvic_api SoftDevice NVIC API + * @{ + * + * @note In order to use this module, the following code has to be added to a .c file: + * \code + * nrf_nvic_state_t nrf_nvic_state = {0}; + * \endcode + * + * @note Definitions and declarations starting with __ (double underscore) in this header file are + * not intended for direct use by the application. + * + * @brief APIs for the accessing NVIC when using a SoftDevice. + * + */ + +#ifndef NRF_NVIC_H__ +#define NRF_NVIC_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "nrf_error_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup NRF_NVIC_DEFINES Defines + * @{ */ + +/**@defgroup NRF_NVIC_ISER_DEFINES SoftDevice NVIC internal definitions + * @{ */ + +#define __NRF_NVIC_NVMC_IRQn (30) /**< The peripheral ID of the NVMC. IRQ numbers are used to identify peripherals, but the NVMC doesn't have an IRQ number in the MDK. */ + +#define __NRF_NVIC_ISER_COUNT (2) /**< The number of ISER/ICER registers in the NVIC that are used. */ + +/**@brief Interrupt priority levels used by the SoftDevice. */ +#define __NRF_NVIC_SD_IRQ_PRIOS ((uint8_t)( \ + (1U << 0) /**< Priority level high .*/ \ + | (1U << 1) /**< Priority level medium. */ \ + | (1U << 4) /**< Priority level low. */ \ + )) + +/**@brief Interrupt priority levels available to the application. */ +#define __NRF_NVIC_APP_IRQ_PRIOS ((uint8_t)~__NRF_NVIC_SD_IRQ_PRIOS) + +/**@brief Interrupts used by the SoftDevice, with IRQn in the range 0-31. */ +#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \ + (1U << POWER_CLOCK_IRQn) \ + | (1U << RADIO_IRQn) \ + | (1U << RTC0_IRQn) \ + | (1U << TIMER0_IRQn) \ + | (1U << RNG_IRQn) \ + | (1U << ECB_IRQn) \ + | (1U << CCM_AAR_IRQn) \ + | (1U << TEMP_IRQn) \ + | (1U << __NRF_NVIC_NVMC_IRQn) \ + | (1U << (uint32_t)SWI5_IRQn) \ + )) + +/**@brief Interrupts used by the SoftDevice, with IRQn in the range 32-63. */ +#define __NRF_NVIC_SD_IRQS_1 ((uint32_t)0) + +/**@brief Interrupts available for to application, with IRQn in the range 0-31. */ +#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0) + +/**@brief Interrupts available for to application, with IRQn in the range 32-63. */ +#define __NRF_NVIC_APP_IRQS_1 (~__NRF_NVIC_SD_IRQS_1) + +/**@} */ + +/**@} */ + +/**@addtogroup NRF_NVIC_VARIABLES Variables + * @{ */ + +/**@brief Type representing the state struct for the SoftDevice NVIC module. */ +typedef struct +{ + uint32_t volatile __irq_masks[__NRF_NVIC_ISER_COUNT]; /**< IRQs enabled by the application in the NVIC. */ + uint32_t volatile __cr_flag; /**< Non-zero if already in a critical region */ +} nrf_nvic_state_t; + +/**@brief Variable keeping the state for the SoftDevice NVIC module. This must be declared in an + * application source file. */ +extern nrf_nvic_state_t nrf_nvic_state; + +/**@} */ + +/**@addtogroup NRF_NVIC_INTERNAL_FUNCTIONS SoftDevice NVIC internal functions + * @{ */ + +/**@brief Disables IRQ interrupts globally, including the SoftDevice's interrupts. + * + * @retval The value of PRIMASK prior to disabling the interrupts. + */ +__STATIC_INLINE int __sd_nvic_irq_disable(void); + +/**@brief Enables IRQ interrupts globally, including the SoftDevice's interrupts. + */ +__STATIC_INLINE void __sd_nvic_irq_enable(void); + +/**@brief Checks if IRQn is available to application + * @param[in] IRQn IRQ to check + * + * @retval 1 (true) if the IRQ to check is available to the application + */ +__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn); + +/**@brief Checks if priority is available to application + * @param[in] priority priority to check + * + * @retval 1 (true) if the priority to check is available to the application + */ +__STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority); + +/**@} */ + +/**@addtogroup NRF_NVIC_FUNCTIONS SoftDevice NVIC public functions + * @{ */ + +/**@brief Enable External Interrupt. + * @note Corresponds to NVIC_EnableIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt was enabled. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn); + +/**@brief Disable External Interrupt. + * @note Corresponds to NVIC_DisableIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt was disabled. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn); + +/**@brief Get Pending Interrupt. + * @note Corresponds to NVIC_GetPendingIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS. + * @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ. + * + * @retval ::NRF_SUCCESS The interrupt is available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq); + +/**@brief Set Pending Interrupt. + * @note Corresponds to NVIC_SetPendingIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt is set pending. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn); + +/**@brief Clear Pending Interrupt. + * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt pending flag is cleared. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn); + +/**@brief Set Interrupt Priority. + * @note Corresponds to NVIC_SetPriority in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * @pre Priority is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS. + * @param[in] priority A valid IRQ priority for use by the application. + * + * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority); + +/**@brief Get Interrupt Priority. + * @note Corresponds to NVIC_GetPriority in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS. + * @param[out] p_priority Return value from NVIC_GetPriority. + * + * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority); + +/**@brief System Reset. + * @note Corresponds to NVIC_SystemReset in CMSIS. + * + * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN + */ +__STATIC_INLINE uint32_t sd_nvic_SystemReset(void); + +/**@brief Enter critical region. + * + * @post Application interrupts will be disabled. + * @note sd_nvic_critical_region_enter() and ::sd_nvic_critical_region_exit() must be called in matching pairs inside each + * execution context + * @sa sd_nvic_critical_region_exit + * + * @param[out] p_is_nested_critical_region If 1, the application is now in a nested critical region. + * + * @retval ::NRF_SUCCESS + */ +__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region); + +/**@brief Exit critical region. + * + * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter. + * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called. + * + * @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter. + * + * @retval ::NRF_SUCCESS + */ +__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region); + +/**@} */ + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +__STATIC_INLINE int __sd_nvic_irq_disable(void) +{ + int pm = __get_PRIMASK(); + __disable_irq(); + return pm; +} + +__STATIC_INLINE void __sd_nvic_irq_enable(void) +{ + __enable_irq(); +} + +__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn) +{ + if (IRQn < 32) + { + return ((1UL<= (1 << __NVIC_PRIO_BITS)) + || (((1 << priority) & __NRF_NVIC_APP_IRQ_PRIOS) == 0) + ) + { + return 0; + } + return 1; +} + + +__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn) +{ + if (!__sd_nvic_app_accessible_irq(IRQn)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } + if (!__sd_nvic_is_app_accessible_priority(NVIC_GetPriority(IRQn))) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED; + } + + if (nrf_nvic_state.__cr_flag) + { + nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] |= (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F)); + } + else + { + NVIC_EnableIRQ(IRQn); + } + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn) +{ + if (!__sd_nvic_app_accessible_irq(IRQn)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } + + if (nrf_nvic_state.__cr_flag) + { + nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] &= ~(1UL << ((uint32_t)(IRQn) & 0x1F)); + } + else + { + NVIC_DisableIRQ(IRQn); + } + + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + *p_pending_irq = NVIC_GetPendingIRQ(IRQn); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + NVIC_SetPendingIRQ(IRQn); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + NVIC_ClearPendingIRQ(IRQn); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if (!__sd_nvic_app_accessible_irq(IRQn)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } + + if (!__sd_nvic_is_app_accessible_priority(priority)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED; + } + + NVIC_SetPriority(IRQn, (uint32_t)priority); + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + *p_priority = (NVIC_GetPriority(IRQn) & 0xFF); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_SystemReset(void) +{ + NVIC_SystemReset(); + return NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN; +} + +__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region) +{ + int was_masked = __sd_nvic_irq_disable(); + if (!nrf_nvic_state.__cr_flag) + { + nrf_nvic_state.__cr_flag = 1; + nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 ); + NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0; + nrf_nvic_state.__irq_masks[1] = ( NVIC->ICER[1] & __NRF_NVIC_APP_IRQS_1 ); + NVIC->ICER[1] = __NRF_NVIC_APP_IRQS_1; + *p_is_nested_critical_region = 0; + } + else + { + *p_is_nested_critical_region = 1; + } + if (!was_masked) + { + __sd_nvic_irq_enable(); + } + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region) +{ + if (nrf_nvic_state.__cr_flag && (is_nested_critical_region == 0)) + { + int was_masked = __sd_nvic_irq_disable(); + NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0]; + NVIC->ISER[1] = nrf_nvic_state.__irq_masks[1]; + nrf_nvic_state.__cr_flag = 0; + if (!was_masked) + { + __sd_nvic_irq_enable(); + } + } + + return NRF_SUCCESS; +} + +#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_NVIC_H__ + +/**@} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sd_def.h similarity index 77% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sd_def.h index 3bcdb2e..1bbe3e0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_keys.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sd_def.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,31 +35,25 @@ * 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 MICRO_ECC_LIB_KEYS_H__ -#define MICRO_ECC_LIB_KEYS_H__ - -/** @file - * - * @defgroup nrf_crypto_backend_micro_ecc_lib_ecc_keys micro-ecc backend ECC key types. - * @{ - * @ingroup nrf_crypto_backend_microecc * - * @brief Provides types required for CC310 backend ECC keys. */ +#ifndef NRF_SD_DEF_H__ +#define NRF_SD_DEF_H__ #include -#include "nrf_crypto_keys.h" #ifdef __cplusplus extern "C" { #endif +#define SD_PPI_CHANNELS_USED 0xFFFE0000uL /**< PPI channels utilized by SotfDevice (not available to the application). */ +#define SD_PPI_GROUPS_USED 0x0000000CuL /**< PPI groups utilized by SoftDevice (not available to the application). */ +#define SD_TIMERS_USED 0x00000001uL /**< Timers used by SoftDevice. */ +#define SD_SWI_USED 0x0000003CuL /**< Software interrupts used by SoftDevice */ + + #ifdef __cplusplus } #endif -/**@} */ - -#endif // MICRO_ECC_LIB_KEYS_H__ +#endif /* NRF_SD_DEF_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sdm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sdm.h new file mode 100644 index 0000000..db05d92 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_sdm.h @@ -0,0 +1,371 @@ +/* + * Copyright (c) 2015 - 2018, 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. + */ + +/** + @defgroup nrf_sdm_api SoftDevice Manager API + @{ + + @brief APIs for SoftDevice management. + +*/ + +#ifndef NRF_SDM_H__ +#define NRF_SDM_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "nrf_error_sdm.h" +#include "nrf_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup NRF_SDM_DEFINES Defines + * @{ */ +#ifdef NRFSOC_DOXYGEN +/// Declared in nrf_mbr.h +#define MBR_SIZE 0 +#warning test +#endif + +/** @brief The major version for the SoftDevice binary distributed with this header file. */ +#define SD_MAJOR_VERSION (7) + +/** @brief The minor version for the SoftDevice binary distributed with this header file. */ +#define SD_MINOR_VERSION (0) + +/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */ +#define SD_BUGFIX_VERSION (1) + +/** @brief The SoftDevice variant of this firmware. */ +#define SD_VARIANT_ID 132 + +/** @brief The full version number for the SoftDevice binary this header file was distributed + * with, as a decimal number in the form Mmmmbbb, where: + * - M is major version (one or more digits) + * - mmm is minor version (three digits) + * - bbb is bugfix version (three digits). */ +#define SD_VERSION (SD_MAJOR_VERSION * 1000000 + SD_MINOR_VERSION * 1000 + SD_BUGFIX_VERSION) + +/** @brief SoftDevice Manager SVC Base number. */ +#define SDM_SVC_BASE 0x10 + +/** @brief SoftDevice unique string size in bytes. */ +#define SD_UNIQUE_STR_SIZE 20 + +/** @brief Invalid info field. Returned when an info field does not exist. */ +#define SDM_INFO_FIELD_INVALID (0) + +/** @brief Defines the SoftDevice Information Structure location (address) as an offset from +the start of the SoftDevice (without MBR)*/ +#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000) + +/** @brief Defines the absolute SoftDevice Information Structure location (address) when the + * SoftDevice is installed just above the MBR (the usual case). */ +#define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE) + +/** @brief Defines the offset for the SoftDevice Information Structure size value relative to the + * SoftDevice base address. The size value is of type uint8_t. */ +#define SD_INFO_STRUCT_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET) + +/** @brief Defines the offset for the SoftDevice size value relative to the SoftDevice base address. + * The size value is of type uint32_t. */ +#define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08) + +/** @brief Defines the offset for FWID value relative to the SoftDevice base address. The FWID value + * is of type uint16_t. */ +#define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C) + +/** @brief Defines the offset for the SoftDevice ID relative to the SoftDevice base address. The ID + * is of type uint32_t. */ +#define SD_ID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10) + +/** @brief Defines the offset for the SoftDevice version relative to the SoftDevice base address in + * the same format as @ref SD_VERSION, stored as an uint32_t. */ +#define SD_VERSION_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14) + +/** @brief Defines the offset for the SoftDevice unique string relative to the SoftDevice base address. + * The SD_UNIQUE_STR is stored as an array of uint8_t. The size of array is @ref SD_UNIQUE_STR_SIZE. + */ +#define SD_UNIQUE_STR_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x18) + +/** @brief Defines a macro for retrieving the actual SoftDevice Information Structure size value + * from a given base address. Use @ref MBR_SIZE as the argument when the SoftDevice is + * installed just above the MBR (the usual case). */ +#define SD_INFO_STRUCT_SIZE_GET(baseaddr) (*((uint8_t *) ((baseaddr) + SD_INFO_STRUCT_SIZE_OFFSET))) + +/** @brief Defines a macro for retrieving the actual SoftDevice size value from a given base + * address. Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above + * the MBR (the usual case). */ +#define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET))) + +/** @brief Defines the amount of flash that is used by the SoftDevice. + * Add @ref MBR_SIZE to find the first available flash address when the SoftDevice is installed + * just above the MBR (the usual case). + */ +#define SD_FLASH_SIZE 0x25000 + +/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use + * @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual + * case). */ +#define SD_FWID_GET(baseaddr) (*((uint16_t *) ((baseaddr) + SD_FWID_OFFSET))) + +/** @brief Defines a macro for retrieving the actual SoftDevice ID from a given base address. Use + * @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the + * usual case). */ +#define SD_ID_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \ + ? (*((uint32_t *) ((baseaddr) + SD_ID_OFFSET))) : SDM_INFO_FIELD_INVALID) + +/** @brief Defines a macro for retrieving the actual SoftDevice version from a given base address. + * Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR + * (the usual case). */ +#define SD_VERSION_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \ + ? (*((uint32_t *) ((baseaddr) + SD_VERSION_OFFSET))) : SDM_INFO_FIELD_INVALID) + +/** @brief Defines a macro for retrieving the address of SoftDevice unique str based on a given base address. + * Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR + * (the usual case). */ +#define SD_UNIQUE_STR_ADDR_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_UNIQUE_STR_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \ + ? (((uint8_t *) ((baseaddr) + SD_UNIQUE_STR_OFFSET))) : SDM_INFO_FIELD_INVALID) + +/**@defgroup NRF_FAULT_ID_RANGES Fault ID ranges + * @{ */ +#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */ +#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */ +/**@} */ + +/**@defgroup NRF_FAULT_IDS Fault ID types + * @{ */ +#define NRF_FAULT_ID_SD_ASSERT (NRF_FAULT_ID_SD_RANGE_START + 1) /**< SoftDevice assertion. The info parameter is reserved for future used. */ +#define NRF_FAULT_ID_APP_MEMACC (NRF_FAULT_ID_APP_RANGE_START + 1) /**< Application invalid memory access. The info parameter will contain 0x00000000, + in case of SoftDevice RAM access violation. In case of SoftDevice peripheral + register violation the info parameter will contain the sub-region number of + PREGION[0], on whose address range the disallowed write access caused the + memory access fault. */ +/**@} */ + +/** @} */ + +/** @addtogroup NRF_SDM_ENUMS Enumerations + * @{ */ + +/**@brief nRF SoftDevice Manager API SVC numbers. */ +enum NRF_SD_SVCS +{ + SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */ + SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */ + SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */ + SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */ + SVC_SDM_LAST /**< Placeholder for last SDM SVC */ +}; + +/** @} */ + +/** @addtogroup NRF_SDM_DEFINES Defines + * @{ */ + +/**@defgroup NRF_CLOCK_LF_ACCURACY Clock accuracy + * @{ */ + +#define NRF_CLOCK_LF_ACCURACY_250_PPM (0) /**< Default: 250 ppm */ +#define NRF_CLOCK_LF_ACCURACY_500_PPM (1) /**< 500 ppm */ +#define NRF_CLOCK_LF_ACCURACY_150_PPM (2) /**< 150 ppm */ +#define NRF_CLOCK_LF_ACCURACY_100_PPM (3) /**< 100 ppm */ +#define NRF_CLOCK_LF_ACCURACY_75_PPM (4) /**< 75 ppm */ +#define NRF_CLOCK_LF_ACCURACY_50_PPM (5) /**< 50 ppm */ +#define NRF_CLOCK_LF_ACCURACY_30_PPM (6) /**< 30 ppm */ +#define NRF_CLOCK_LF_ACCURACY_20_PPM (7) /**< 20 ppm */ +#define NRF_CLOCK_LF_ACCURACY_10_PPM (8) /**< 10 ppm */ +#define NRF_CLOCK_LF_ACCURACY_5_PPM (9) /**< 5 ppm */ +#define NRF_CLOCK_LF_ACCURACY_2_PPM (10) /**< 2 ppm */ +#define NRF_CLOCK_LF_ACCURACY_1_PPM (11) /**< 1 ppm */ + +/** @} */ + +/**@defgroup NRF_CLOCK_LF_SRC Possible LFCLK oscillator sources + * @{ */ + +#define NRF_CLOCK_LF_SRC_RC (0) /**< LFCLK RC oscillator. */ +#define NRF_CLOCK_LF_SRC_XTAL (1) /**< LFCLK crystal oscillator. */ +#define NRF_CLOCK_LF_SRC_SYNTH (2) /**< LFCLK Synthesized from HFCLK. */ + +/** @} */ + +/** @} */ + +/** @addtogroup NRF_SDM_TYPES Types + * @{ */ + +/**@brief Type representing LFCLK oscillator source. */ +typedef struct +{ + uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */ + uint8_t rc_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second + units (nRF52: 1-32). + @note To avoid excessive clock drift, 0.5 degrees Celsius is the + maximum temperature change allowed in one calibration timer + interval. The interval should be selected to ensure this. + + @note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. */ + uint8_t rc_temp_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: How often (in number of calibration + intervals) the RC oscillator shall be calibrated if the temperature + hasn't changed. + 0: Always calibrate even if the temperature hasn't changed. + 1: Only calibrate if the temperature has changed (legacy - nRF51 only). + 2-33: Check the temperature and only calibrate if it has changed, + however calibration will take place every rc_temp_ctiv + intervals in any case. + + @note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. + + @note For nRF52, the application must ensure calibration at least once + every 8 seconds to ensure +/-500 ppm clock stability. The + recommended configuration for ::NRF_CLOCK_LF_SRC_RC on nRF52 is + rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at + least once every 8 seconds and for temperature changes of 0.5 + degrees Celsius every 4 seconds. See the Product Specification + for the nRF52 device being used for more information.*/ + uint8_t accuracy; /**< External clock accuracy used in the LL to compute timing + windows, see @ref NRF_CLOCK_LF_ACCURACY.*/ +} nrf_clock_lf_cfg_t; + +/**@brief Fault Handler type. + * + * When certain unrecoverable errors occur within the application or SoftDevice the fault handler will be called back. + * The protocol stack will be in an undefined state when this happens and the only way to recover will be to + * perform a reset, using e.g. CMSIS NVIC_SystemReset(). + * If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset(). + * + * @note It is recommended to either perform a reset in the fault handler or to let the SoftDevice reset the device. + * Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripherial may + * continously transmit packets. + * + * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback. + * + * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. + * @param[in] pc The program counter of the instruction that triggered the fault. + * @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details. + * + * @note When id is set to @ref NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time when + * the fault is detected by the CPU. The CPU program counter may have advanced up to 2 instructions (no branching) after the one that triggered the fault. + */ +typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info); + +/** @} */ + +/** @addtogroup NRF_SDM_FUNCTIONS Functions + * @{ */ + +/**@brief Enables the SoftDevice and by extension the protocol stack. + * + * @note Some care must be taken if a low frequency clock source is already running when calling this function: + * If the LF clock has a different source then the one currently running, it will be stopped. Then, the new + * clock source will be started. + * + * @note This function has no effect when returning with an error. + * + * @post If return code is ::NRF_SUCCESS + * - SoC library and protocol stack APIs are made available. + * - A portion of RAM will be unavailable (see relevant SDS documentation). + * - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation). + * - Interrupts will not arrive from protected peripherals or interrupts. + * - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice. + * - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation). + * - Chosen low frequency clock source will be running. + * + * @param p_clock_lf_cfg Low frequency clock source and accuracy. + If NULL the clock will be configured as an RC source with rc_ctiv = 16 and .rc_temp_ctiv = 2 + In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock. + * @param fault_handler Callback to be invoked in case of fault, cannot be NULL. + * + * @retval ::NRF_SUCCESS + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated. + * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level. + * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid clock source configuration supplied in p_clock_lf_cfg. + */ +SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler)); + + +/**@brief Disables the SoftDevice and by extension the protocol stack. + * + * Idempotent function to disable the SoftDevice. + * + * @post SoC library and protocol stack APIs are made unavailable. + * @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest). + * @post All peripherals used by the SoftDevice will be reset to default values. + * @post All of RAM become available. + * @post All interrupts are forwarded to the application. + * @post LFCLK source chosen in ::sd_softdevice_enable will be left running. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void)); + +/**@brief Check if the SoftDevice is enabled. + * + * @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled)); + +/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice + * + * This function is only intended to be called when a bootloader is enabled. + * + * @param[in] address The base address of the interrupt vector table for forwarded interrupts. + + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address)); + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_SDM_H__ + +/** + @} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_soc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_soc.h new file mode 100644 index 0000000..0d29293 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_soc.h @@ -0,0 +1,1000 @@ +/* + * Copyright (c) 2015 - 2019, 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. + */ + +/** + * @defgroup nrf_soc_api SoC Library API + * @{ + * + * @brief APIs for the SoC library. + * + */ + +#ifndef NRF_SOC_H__ +#define NRF_SOC_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "nrf_error_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup NRF_SOC_DEFINES Defines + * @{ */ + +/**@brief The number of the lowest SVC number reserved for the SoC library. */ +#define SOC_SVC_BASE (0x20) /**< Base value for SVCs that are available when the SoftDevice is disabled. */ +#define SOC_SVC_BASE_NOT_AVAILABLE (0x2C) /**< Base value for SVCs that are not available when the SoftDevice is disabled. */ + +/**@brief Guaranteed time for application to process radio inactive notification. */ +#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62) + +/**@brief The minimum allowed timeslot extension time. */ +#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200) + +/**@brief The maximum processing time to handle a timeslot extension. */ +#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (20) + +/**@brief The latest time before the end of a timeslot the timeslot can be extended. */ +#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (82) + +#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */ +#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */ +#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */ + +#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ +#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. + The default interrupt priority for this handler is set to 6 */ +#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */ +#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. + The default interrupt priority for this handler is set to 6 */ +#define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */ +#define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */ + +#define NRF_RADIO_DISTANCE_MAX_US (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */ + +#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */ + +#define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */ + +/**@brief Mask of PPI channels reserved by the SoftDevice when the SoftDevice is disabled. */ +#define NRF_SOC_SD_PPI_CHANNELS_SD_DISABLED_MSK ((uint32_t)(0)) + +/**@brief Mask of PPI channels reserved by the SoftDevice when the SoftDevice is enabled. */ +#define NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK ((uint32_t)( \ + (1U << 17) \ + | (1U << 18) \ + | (1U << 19) \ + | (1U << 20) \ + | (1U << 21) \ + | (1U << 22) \ + | (1U << 23) \ + | (1U << 24) \ + | (1U << 25) \ + | (1U << 26) \ + | (1U << 27) \ + | (1U << 28) \ + | (1U << 29) \ + | (1U << 30) \ + | (1U << 31) \ + )) + +/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is disabled. */ +#define NRF_SOC_SD_PPI_GROUPS_SD_DISABLED_MSK ((uint32_t)(0)) + +/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is enabled. */ +#define NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK ((uint32_t)( \ + (1U << 4) \ + | (1U << 5) \ + )) + +/**@} */ + +/**@addtogroup NRF_SOC_ENUMS Enumerations + * @{ */ + +/**@brief The SVC numbers used by the SVC functions in the SoC library. */ +enum NRF_SOC_SVCS +{ + SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE, + SD_PPI_CHANNEL_ENABLE_SET = SOC_SVC_BASE + 1, + SD_PPI_CHANNEL_ENABLE_CLR = SOC_SVC_BASE + 2, + SD_PPI_CHANNEL_ASSIGN = SOC_SVC_BASE + 3, + SD_PPI_GROUP_TASK_ENABLE = SOC_SVC_BASE + 4, + SD_PPI_GROUP_TASK_DISABLE = SOC_SVC_BASE + 5, + SD_PPI_GROUP_ASSIGN = SOC_SVC_BASE + 6, + SD_PPI_GROUP_GET = SOC_SVC_BASE + 7, + SD_FLASH_PAGE_ERASE = SOC_SVC_BASE + 8, + SD_FLASH_WRITE = SOC_SVC_BASE + 9, + SD_FLASH_PROTECT = SOC_SVC_BASE + 10, + SD_PROTECTED_REGISTER_WRITE = SOC_SVC_BASE + 11, + SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE, + SD_MUTEX_ACQUIRE = SOC_SVC_BASE_NOT_AVAILABLE + 1, + SD_MUTEX_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 2, + SD_RAND_APPLICATION_POOL_CAPACITY_GET = SOC_SVC_BASE_NOT_AVAILABLE + 3, + SD_RAND_APPLICATION_BYTES_AVAILABLE_GET = SOC_SVC_BASE_NOT_AVAILABLE + 4, + SD_RAND_APPLICATION_VECTOR_GET = SOC_SVC_BASE_NOT_AVAILABLE + 5, + SD_POWER_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 6, + SD_POWER_SYSTEM_OFF = SOC_SVC_BASE_NOT_AVAILABLE + 7, + SD_POWER_RESET_REASON_GET = SOC_SVC_BASE_NOT_AVAILABLE + 8, + SD_POWER_RESET_REASON_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 9, + SD_POWER_POF_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 10, + SD_POWER_POF_THRESHOLD_SET = SOC_SVC_BASE_NOT_AVAILABLE + 11, + SD_POWER_RAM_POWER_SET = SOC_SVC_BASE_NOT_AVAILABLE + 13, + SD_POWER_RAM_POWER_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 14, + SD_POWER_RAM_POWER_GET = SOC_SVC_BASE_NOT_AVAILABLE + 15, + SD_POWER_GPREGRET_SET = SOC_SVC_BASE_NOT_AVAILABLE + 16, + SD_POWER_GPREGRET_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 17, + SD_POWER_GPREGRET_GET = SOC_SVC_BASE_NOT_AVAILABLE + 18, + SD_POWER_DCDC_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 19, + SD_APP_EVT_WAIT = SOC_SVC_BASE_NOT_AVAILABLE + 21, + SD_CLOCK_HFCLK_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 22, + SD_CLOCK_HFCLK_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 23, + SD_CLOCK_HFCLK_IS_RUNNING = SOC_SVC_BASE_NOT_AVAILABLE + 24, + SD_RADIO_NOTIFICATION_CFG_SET = SOC_SVC_BASE_NOT_AVAILABLE + 25, + SD_ECB_BLOCK_ENCRYPT = SOC_SVC_BASE_NOT_AVAILABLE + 26, + SD_ECB_BLOCKS_ENCRYPT = SOC_SVC_BASE_NOT_AVAILABLE + 27, + SD_RADIO_SESSION_OPEN = SOC_SVC_BASE_NOT_AVAILABLE + 28, + SD_RADIO_SESSION_CLOSE = SOC_SVC_BASE_NOT_AVAILABLE + 29, + SD_RADIO_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 30, + SD_EVT_GET = SOC_SVC_BASE_NOT_AVAILABLE + 31, + SD_TEMP_GET = SOC_SVC_BASE_NOT_AVAILABLE + 32, + SVC_SOC_LAST = SOC_SVC_BASE_NOT_AVAILABLE + 37 +}; + +/**@brief Possible values of a ::nrf_mutex_t. */ +enum NRF_MUTEX_VALUES +{ + NRF_MUTEX_FREE, + NRF_MUTEX_TAKEN +}; + +/**@brief Power modes. */ +enum NRF_POWER_MODES +{ + NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */ + NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */ +}; + + +/**@brief Power failure thresholds */ +enum NRF_POWER_THRESHOLDS +{ + NRF_POWER_THRESHOLD_V17 = 4UL, /**< 1.7 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V18, /**< 1.8 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V19, /**< 1.9 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V20, /**< 2.0 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V22, /**< 2.2 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V24, /**< 2.4 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V26, /**< 2.6 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V27, /**< 2.7 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V28 /**< 2.8 Volts power failure threshold. */ +}; + + + +/**@brief DC/DC converter modes. */ +enum NRF_POWER_DCDC_MODES +{ + NRF_POWER_DCDC_DISABLE, /**< The DCDC is disabled. */ + NRF_POWER_DCDC_ENABLE /**< The DCDC is enabled. */ +}; + +/**@brief Radio notification distances. */ +enum NRF_RADIO_NOTIFICATION_DISTANCES +{ + NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */ + NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */ +}; + + +/**@brief Radio notification types. */ +enum NRF_RADIO_NOTIFICATION_TYPES +{ + NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */ +}; + +/**@brief The Radio signal callback types. */ +enum NRF_RADIO_CALLBACK_SIGNAL_TYPE +{ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */ +}; + +/**@brief The actions requested by the signal callback. + * + * This code gives the SOC instructions about what action to take when the signal callback has + * returned. + */ +enum NRF_RADIO_SIGNAL_CALLBACK_ACTION +{ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current + timeslot. Maximum execution time for this action: + @ref NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US. + This action must be started at least + @ref NRF_RADIO_MIN_EXTENSION_MARGIN_US before + the end of the timeslot. */ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */ +}; + +/**@brief Radio timeslot high frequency clock source configuration. */ +enum NRF_RADIO_HFCLK_CFG +{ + NRF_RADIO_HFCLK_CFG_XTAL_GUARANTEED, /**< The SoftDevice will guarantee that the high frequency clock source is the + external crystal for the whole duration of the timeslot. This should be the + preferred option for events that use the radio or require high timing accuracy. + @note The SoftDevice will automatically turn on and off the external crystal, + at the beginning and end of the timeslot, respectively. The crystal may also + intentionally be left running after the timeslot, in cases where it is needed + by the SoftDevice shortly after the end of the timeslot. */ + NRF_RADIO_HFCLK_CFG_NO_GUARANTEE /**< This configuration allows for earlier and tighter scheduling of timeslots. + The RC oscillator may be the clock source in part or for the whole duration of the timeslot. + The RC oscillator's accuracy must therefore be taken into consideration. + @note If the application will use the radio peripheral in timeslots with this configuration, + it must make sure that the crystal is running and stable before starting the radio. */ +}; + +/**@brief Radio timeslot priorities. */ +enum NRF_RADIO_PRIORITY +{ + NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */ + NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activities of the SoftDevice stack(s)). */ +}; + +/**@brief Radio timeslot request type. */ +enum NRF_RADIO_REQUEST_TYPE +{ + NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request radio timeslot as early as possible. This should always be used for the first request in a session. */ + NRF_RADIO_REQ_TYPE_NORMAL /**< Normal radio timeslot request. */ +}; + +/**@brief SoC Events. */ +enum NRF_SOC_EVTS +{ + NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */ + NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */ + NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */ + NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */ + NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */ + NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */ + NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio timeslot signal callback handler return was invalid. */ + NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio timeslot session is idle. */ + NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio timeslot session is closed. */ + NRF_EVT_NUMBER_OF_EVTS +}; + +/**@} */ + + +/**@addtogroup NRF_SOC_STRUCTURES Structures + * @{ */ + +/**@brief Represents a mutex for use with the nrf_mutex functions. + * @note Accessing the value directly is not safe, use the mutex functions! + */ +typedef volatile uint8_t nrf_mutex_t; + +/**@brief Parameters for a request for a timeslot as early as possible. */ +typedef struct +{ + uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */ + uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */ + uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */ + uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */ +} nrf_radio_request_earliest_t; + +/**@brief Parameters for a normal radio timeslot request. */ +typedef struct +{ + uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */ + uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */ + uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */ + uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */ +} nrf_radio_request_normal_t; + +/**@brief Radio timeslot request parameters. */ +typedef struct +{ + uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */ + union + { + nrf_radio_request_earliest_t earliest; /**< Parameters for requesting a radio timeslot as early as possible. */ + nrf_radio_request_normal_t normal; /**< Parameters for requesting a normal radio timeslot. */ + } params; /**< Parameter union. */ +} nrf_radio_request_t; + +/**@brief Return parameters of the radio timeslot signal callback. */ +typedef struct +{ + uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */ + union + { + struct + { + nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */ + } request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */ + struct + { + uint32_t length_us; /**< Requested extension of the radio timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */ + } extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */ + } params; /**< Parameter union. */ +} nrf_radio_signal_callback_return_param_t; + +/**@brief The radio timeslot signal callback type. + * + * @note In case of invalid return parameters, the radio timeslot will automatically end + * immediately after returning from the signal callback and the + * @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent. + * @note The returned struct pointer must remain valid after the signal callback + * function returns. For instance, this means that it must not point to a stack variable. + * + * @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE. + * + * @return Pointer to structure containing action requested by the application. + */ +typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type); + +/**@brief AES ECB parameter typedefs */ +typedef uint8_t soc_ecb_key_t[SOC_ECB_KEY_LENGTH]; /**< Encryption key type. */ +typedef uint8_t soc_ecb_cleartext_t[SOC_ECB_CLEARTEXT_LENGTH]; /**< Cleartext data type. */ +typedef uint8_t soc_ecb_ciphertext_t[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Ciphertext data type. */ + +/**@brief AES ECB data structure */ +typedef struct +{ + soc_ecb_key_t key; /**< Encryption key. */ + soc_ecb_cleartext_t cleartext; /**< Cleartext data. */ + soc_ecb_ciphertext_t ciphertext; /**< Ciphertext data. */ +} nrf_ecb_hal_data_t; + +/**@brief AES ECB block. Used to provide multiple blocks in a single call + to @ref sd_ecb_blocks_encrypt.*/ +typedef struct +{ + soc_ecb_key_t const * p_key; /**< Pointer to the Encryption key. */ + soc_ecb_cleartext_t const * p_cleartext; /**< Pointer to the Cleartext data. */ + soc_ecb_ciphertext_t * p_ciphertext; /**< Pointer to the Ciphertext data. */ +} nrf_ecb_hal_data_block_t; + +/**@} */ + +/**@addtogroup NRF_SOC_FUNCTIONS Functions + * @{ */ + +/**@brief Initialize a mutex. + * + * @param[in] p_mutex Pointer to the mutex to initialize. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex)); + +/**@brief Attempt to acquire a mutex. + * + * @param[in] p_mutex Pointer to the mutex to acquire. + * + * @retval ::NRF_SUCCESS The mutex was successfully acquired. + * @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired. + */ +SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex)); + +/**@brief Release a mutex. + * + * @param[in] p_mutex Pointer to the mutex to release. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex)); + +/**@brief Query the capacity of the application random pool. + * + * @param[out] p_pool_capacity The capacity of the pool. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY_GET, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity)); + +/**@brief Get number of random bytes available to the application. + * + * @param[out] p_bytes_available The number of bytes currently available in the pool. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE_GET, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available)); + +/**@brief Get random bytes from the application pool. + * + * @param[out] p_buff Pointer to unit8_t buffer for storing the bytes. + * @param[in] length Number of bytes to take from pool and place in p_buff. + * + * @retval ::NRF_SUCCESS The requested bytes were written to p_buff. + * @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available. +*/ +SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length)); + +/**@brief Gets the reset reason register. + * + * @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason)); + +/**@brief Clears the bits of the reset reason register. + * + * @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk)); + +/**@brief Sets the power mode when in CPU sleep. + * + * @param[in] power_mode The power mode to use when in CPU sleep, see @ref NRF_POWER_MODES. @sa sd_app_evt_wait + * + * @retval ::NRF_SUCCESS The power mode was set. + * @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown. + */ +SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(uint8_t power_mode)); + +/**@brief Puts the chip in System OFF mode. + * + * @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN + */ +SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void)); + +/**@brief Enables or disables the power-fail comparator. + * + * Enabling this will give a SoftDevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs. + * The event can be retrieved with sd_evt_get(); + * + * @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable)); + + +/**@brief Sets the power failure comparator threshold value. + * + * + * @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS. + * + * @retval ::NRF_SUCCESS The power failure threshold was set. + * @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown. + */ +SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold)); + + +/**@brief Writes the NRF_POWER->RAM[index].POWERSET register. + * + * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERSET register to write to. + * @param[in] ram_powerset Contains the word to write to the NRF_POWER->RAM[index].POWERSET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAM_POWER_SET, uint32_t, sd_power_ram_power_set(uint8_t index, uint32_t ram_powerset)); + +/**@brief Writes the NRF_POWER->RAM[index].POWERCLR register. + * + * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERCLR register to write to. + * @param[in] ram_powerclr Contains the word to write to the NRF_POWER->RAM[index].POWERCLR register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAM_POWER_CLR, uint32_t, sd_power_ram_power_clr(uint8_t index, uint32_t ram_powerclr)); + +/**@brief Get contents of NRF_POWER->RAM[index].POWER register, indicates power status of RAM[index] blocks. + * + * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWER register to read from. + * @param[out] p_ram_power Content of NRF_POWER->RAM[index].POWER register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAM_POWER_GET, uint32_t, sd_power_ram_power_get(uint8_t index, uint32_t * p_ram_power)); + +/**@brief Set bits in the general purpose retention registers (NRF_POWER->GPREGRET*). + * + * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2. + * @param[in] gpregret_msk Bits to be set in the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk)); + +/**@brief Clear bits in the general purpose retention registers (NRF_POWER->GPREGRET*). + * + * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2. + * @param[in] gpregret_msk Bits to be clear in the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_id, uint32_t gpregret_msk)); + +/**@brief Get contents of the general purpose retention registers (NRF_POWER->GPREGRET*). + * + * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2. + * @param[out] p_gpregret Contents of the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret)); + +/**@brief Enable or disable the DC/DC regulator. + * + * @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES. + * + * @retval ::NRF_SUCCESS + * @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid. + */ +SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode)); + + +/**@brief Request the high frequency crystal oscillator. + * + * Will start the high frequency crystal oscillator, the startup time of the crystal varies + * and the ::sd_clock_hfclk_is_running function can be polled to check if it has started. + * + * @see sd_clock_hfclk_is_running + * @see sd_clock_hfclk_release + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void)); + +/**@brief Releases the high frequency crystal oscillator. + * + * Will stop the high frequency crystal oscillator, this happens immediately. + * + * @see sd_clock_hfclk_is_running + * @see sd_clock_hfclk_request + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void)); + +/**@brief Checks if the high frequency crystal oscillator is running. + * + * @see sd_clock_hfclk_request + * @see sd_clock_hfclk_release + * + * @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running)); + +/**@brief Waits for an application event. + * + * An application event is either an application interrupt or a pended interrupt when the interrupt + * is disabled. + * + * When the application waits for an application event by calling this function, an interrupt that + * is enabled will be taken immediately on pending since this function will wait in thread mode, + * then the execution will return in the application's main thread. + * + * In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M + * MCU's System Control Register (SCR), CMSIS_SCB. In that case, when a disabled interrupt gets + * pended, this function will return to the application's main thread. + * + * @note The application must ensure that the pended flag is cleared using ::sd_nvic_ClearPendingIRQ + * in order to sleep using this function. This is only necessary for disabled interrupts, as + * the interrupt handler will clear the pending flag automatically for enabled interrupts. + * + * @note If an application interrupt has happened since the last time sd_app_evt_wait was + * called this function will return immediately and not go to sleep. This is to avoid race + * conditions that can occur when a flag is updated in the interrupt handler and processed + * in the main loop. + * + * @post An application interrupt has happened or a interrupt pending flag is set. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void)); + +/**@brief Get PPI channel enable register contents. + * + * @param[out] p_channel_enable The contents of the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable)); + +/**@brief Set PPI channel enable register. + * + * @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk)); + +/**@brief Clear PPI channel enable register. + * + * @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk)); + +/**@brief Assign endpoints to a PPI channel. + * + * @param[in] channel_num Number of the PPI channel to assign. + * @param[in] evt_endpoint Event endpoint of the PPI channel. + * @param[in] task_endpoint Task endpoint of the PPI channel. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint)); + +/**@brief Task to enable a channel group. + * + * @param[in] group_num Number of the channel group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num)); + +/**@brief Task to disable a channel group. + * + * @param[in] group_num Number of the PPI group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num)); + +/**@brief Assign PPI channels to a channel group. + * + * @param[in] group_num Number of the channel group. + * @param[in] channel_msk Mask of the channels to assign to the group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk)); + +/**@brief Gets the PPI channels of a channel group. + * + * @param[in] group_num Number of the channel group. + * @param[out] p_channel_msk Mask of the channels assigned to the group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk)); + +/**@brief Configures the Radio Notification signal. + * + * @note + * - The notification signal latency depends on the interrupt priority settings of SWI used + * for notification signal. + * - To ensure that the radio notification signal behaves in a consistent way, the radio + * notifications must be configured when there is no protocol stack or other SoftDevice + * activity in progress. It is recommended that the radio notification signal is + * configured directly after the SoftDevice has been enabled. + * - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice + * will interrupt the application to do Radio Event preparation. + * - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have + * to shorten the connection events to have time for the Radio Notification signals. + * + * @param[in] type Type of notification signal, see @ref NRF_RADIO_NOTIFICATION_TYPES. + * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio + * notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is + * recommended (but not required) to be used with + * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE. + * + * @param[in] distance Distance between the notification signal and start of radio activity, see @ref NRF_RADIO_NOTIFICATION_DISTANCES. + * This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or + * @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used. + * + * @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid. + * @retval ::NRF_ERROR_INVALID_STATE A protocol stack or other SoftDevice is running. Stop all + * running activities and retry. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(uint8_t type, uint8_t distance)); + +/**@brief Encrypts a block according to the specified parameters. + * + * 128-bit AES encryption. + * + * @note: + * - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while + * the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application + * main or low interrupt level. + * + * @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input + * parameters and one output parameter). + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data)); + +/**@brief Encrypts multiple data blocks provided as an array of data block structures. + * + * @details: Performs 128-bit AES encryption on multiple data blocks + * + * @note: + * - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while + * the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application + * main or low interrupt level. + * + * @param[in] block_count Count of blocks in the p_data_blocks array. + * @param[in,out] p_data_blocks Pointer to the first entry in a contiguous array of + * @ref nrf_ecb_hal_data_block_t structures. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_ECB_BLOCKS_ENCRYPT, uint32_t, sd_ecb_blocks_encrypt(uint8_t block_count, nrf_ecb_hal_data_block_t * p_data_blocks)); + +/**@brief Gets any pending events generated by the SoC API. + * + * The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned. + * + * @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending. + * + * @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter. + * @retval ::NRF_ERROR_NOT_FOUND No pending events. + */ +SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id)); + +/**@brief Get the temperature measured on the chip + * + * This function will block until the temperature measurement is done. + * It takes around 50 us from call to return. + * + * @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees Celsius. + * + * @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp + */ +SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp)); + +/**@brief Flash Write +* +* Commands to write a buffer to flash +* +* If the SoftDevice is enabled: +* This call initiates the flash access command, and its completion will be communicated to the +* application with exactly one of the following events: +* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed. +* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started. +* +* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the + * write has been completed +* +* @note +* - This call takes control over the radio and the CPU during flash erase and write to make sure that +* they will not interfere with the flash access. This means that all interrupts will be blocked +* for a predictable time (depending on the NVMC specification in the device's Product Specification +* and the command parameters). +* - The data in the p_src buffer should not be modified before the @ref NRF_EVT_FLASH_OPERATION_SUCCESS +* or the @ref NRF_EVT_FLASH_OPERATION_ERROR have been received if the SoftDevice is enabled. +* - This call will make the SoftDevice trigger a hardfault when the page is written, if it is +* protected. +* +* +* @param[in] p_dst Pointer to start of flash location to be written. +* @param[in] p_src Pointer to buffer with data to be written. +* @param[in] size Number of 32-bit words to write. Maximum size is the number of words in one +* flash page. See the device's Product Specification for details. +* +* @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned. +* @retval ::NRF_ERROR_BUSY The previous command has not yet completed. +* @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or higher than the maximum allowed size. +* @retval ::NRF_ERROR_FORBIDDEN Tried to write to an address outside the application flash area. +* @retval ::NRF_SUCCESS The command was accepted. +*/ +SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const * p_src, uint32_t size)); + + +/**@brief Flash Erase page +* +* Commands to erase a flash page +* If the SoftDevice is enabled: +* This call initiates the flash access command, and its completion will be communicated to the +* application with exactly one of the following events: +* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed. +* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started. +* +* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the +* erase has been completed +* +* @note +* - This call takes control over the radio and the CPU during flash erase and write to make sure that +* they will not interfere with the flash access. This means that all interrupts will be blocked +* for a predictable time (depending on the NVMC specification in the device's Product Specification +* and the command parameters). +* - This call will make the SoftDevice trigger a hardfault when the page is erased, if it is +* protected. +* +* +* @param[in] page_number Page number of the page to erase +* +* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error. +* @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page. +* @retval ::NRF_ERROR_BUSY The previous command has not yet completed. +* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a page outside the application flash area. +* @retval ::NRF_SUCCESS The command was accepted. +*/ +SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number)); + + +/**@brief Flash Protection set + * + * Commands to set the flash protection configuration registers. + This sets the CONFIGx registers of the BPROT peripheral. + * + * @note Not all parameters are valid for all products. Some bits in each parameter may not be + * valid for your product. Please refer your Product Specification for more details. + * + * @note To read the values read them directly. They are only write-protected. + * + * @note It is possible to use @ref sd_protected_register_write instead of this function. + * + * @param[in] block_cfg0 Value to be written to the configuration register. + * @param[in] block_cfg1 Value to be written to the configuration register. + * @param[in] block_cfg2 Value to be written to the configuration register. + * @param[in] block_cfg3 Value to be written to the configuration register. + * + * @retval ::NRF_ERROR_NOT_SUPPORTED Non-zero value supplied to one or more of the unsupported parameters. + * @retval ::NRF_SUCCESS Values successfully written to configuration registers. + */ +SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3)); + +/**@brief Opens a session for radio timeslot requests. + * + * @note Only one session can be open at a time. + * @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot + * starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed + * by the application. + * @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0 + * interrupt occurs. + * @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO + * interrupt occurs. + * @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This + * implies that none of the sd_* API calls can be used from p_radio_signal_callback(). + * + * @param[in] p_radio_signal_callback The signal callback. + * + * @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer. + * @retval ::NRF_ERROR_BUSY If session cannot be opened. + * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error. + * @retval ::NRF_SUCCESS Otherwise. + */ + SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback)); + +/**@brief Closes a session for radio timeslot requests. + * + * @note Any current radio timeslot will be finished before the session is closed. + * @note If a radio timeslot is scheduled when the session is closed, it will be canceled. + * @note The application cannot consider the session closed until the @ref NRF_EVT_RADIO_SESSION_CLOSED + * event is received. + * + * @retval ::NRF_ERROR_FORBIDDEN If session not opened. + * @retval ::NRF_ERROR_BUSY If session is currently being closed. + * @retval ::NRF_SUCCESS Otherwise. + */ + SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void)); + +/**@brief Requests a radio timeslot. + * + * @note The request type is determined by p_request->request_type, and can be one of @ref NRF_RADIO_REQ_TYPE_EARLIEST + * and @ref NRF_RADIO_REQ_TYPE_NORMAL. The first request in a session must always be of type @ref NRF_RADIO_REQ_TYPE_EARLIEST. + * @note For a normal request (@ref NRF_RADIO_REQ_TYPE_NORMAL), the start time of a radio timeslot is specified by + * p_request->distance_us and is given relative to the start of the previous timeslot. + * @note A too small p_request->distance_us will lead to a @ref NRF_EVT_RADIO_BLOCKED event. + * @note Timeslots scheduled too close will lead to a @ref NRF_EVT_RADIO_BLOCKED event. + * @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths. + * @note If an opportunity for the first radio timeslot is not found before 100 ms after the call to this + * function, it is not scheduled, and instead a @ref NRF_EVT_RADIO_BLOCKED event is sent. + * The application may then try to schedule the first radio timeslot again. + * @note Successful requests will result in nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START). + * Unsuccessful requests will result in a @ref NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS. + * @note The jitter in the start time of the radio timeslots is +/- @ref NRF_RADIO_START_JITTER_US us. + * @note The nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the + * specified radio timeslot start, but this does not affect the actual start time of the timeslot. + * @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency + * (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is + * guaranteed to be clocked from the external crystal. + * @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral + * during the radio timeslot. + * + * @param[in] p_request Pointer to the request parameters. + * + * @retval ::NRF_ERROR_FORBIDDEN Either: + * - The session is not open. + * - The session is not IDLE. + * - This is the first request and its type is not @ref NRF_RADIO_REQ_TYPE_EARLIEST. + * - The request type was set to @ref NRF_RADIO_REQ_TYPE_NORMAL after a + * @ref NRF_RADIO_REQ_TYPE_EARLIEST request was blocked. + * @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid. + * @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid. + * @retval ::NRF_SUCCESS Otherwise. + */ + SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t const * p_request)); + +/**@brief Write register protected by the SoftDevice + * + * This function writes to a register that is write-protected by the SoftDevice. Please refer to your + * SoftDevice Specification for more details about which registers that are protected by SoftDevice. + * This function can write to the following protected peripheral: + * - BPROT + * + * @note Protected registers may be read directly. + * @note Register that are write-once will return @ref NRF_SUCCESS on second set, even the value in + * the register has not changed. See the Product Specification for more details about register + * properties. + * + * @param[in] p_register Pointer to register to be written. + * @param[in] value Value to be written to the register. + * + * @retval ::NRF_ERROR_INVALID_ADDR This function can not write to the reguested register. + * @retval ::NRF_SUCCESS Value successfully written to register. + * + */ +SVCALL(SD_PROTECTED_REGISTER_WRITE, uint32_t, sd_protected_register_write(volatile uint32_t * p_register, uint32_t value)); + +/**@} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_SOC_H__ + +/**@} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_svc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_svc.h new file mode 100644 index 0000000..231a54f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/headers/nrf_svc.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2012 - 2019, 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 NRF_SVC__ +#define NRF_SVC__ + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Supervisor call declaration. + * + * A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception. + * The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice. + * + * @param[in] number The SVC number to be used. + * @param[in] return_type The return type of the SVC function. + * @param[in] signature Function signature. The function can have at most four arguments. + */ + +#ifdef SVCALL_AS_NORMAL_FUNCTION +#define SVCALL(number, return_type, signature) return_type signature +#else + +#ifndef SVCALL +#if defined (__CC_ARM) +#define SVCALL(number, return_type, signature) return_type __svc(number) signature +#elif defined (__GNUC__) +#ifdef __cplusplus +#define GCC_CAST_CPP (uint16_t) +#else +#define GCC_CAST_CPP +#endif +#define SVCALL(number, return_type, signature) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ + __attribute__((naked)) \ + __attribute__((unused)) \ + static return_type signature \ + { \ + __asm( \ + "svc %0\n" \ + "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ + ); \ + } \ + _Pragma("GCC diagnostic pop") + +#elif defined (__ICCARM__) +#define PRAGMA(x) _Pragma(#x) +#define SVCALL(number, return_type, signature) \ +PRAGMA(swi_number = (number)) \ + __swi return_type signature; +#else +#define SVCALL(number, return_type, signature) return_type signature +#endif +#endif // SVCALL + +#endif // SVCALL_AS_NORMAL_FUNCTION + +#ifdef __cplusplus +} +#endif +#endif // NRF_SVC__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/hex/s132_nrf52_7.0.1_licence-agreement.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/hex/s132_nrf52_7.0.1_licence-agreement.txt new file mode 100644 index 0000000..9225328 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/hex/s132_nrf52_7.0.1_licence-agreement.txt @@ -0,0 +1,35 @@ +Copyright (c) 2007 - 2019, 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. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld new file mode 100644 index 0000000..59a8b40 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/armgcc/armgcc_s132_nrf52832_xxaa.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 + RAM (rwx) : ORIGIN = 0x20001668, LENGTH = 0xe998 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf index 8870582..50659c9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/softdevice/s132/toolchain/iar/iar_s132_nrf52832_xxaa.icf @@ -2,32 +2,35 @@ /*-Editor annotation file-*/ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ -define symbol __ICFEDIT_intvec_start__ = 0x23000; +define symbol __ICFEDIT_intvec_start__ = 0x26000; /*-Memory Regions-*/ -define symbol __ICFEDIT_region_ROM_start__ = 0x23000; +define symbol __ICFEDIT_region_ROM_start__ = 0x26000; define symbol __ICFEDIT_region_ROM_end__ = 0x7ffff; -define symbol __ICFEDIT_region_RAM_start__ = 0x20001368; +define symbol __ICFEDIT_region_RAM_start__ = 0x20001668; define symbol __ICFEDIT_region_RAM_end__ = 0x2000ffff; export symbol __ICFEDIT_region_RAM_start__; export symbol __ICFEDIT_region_RAM_end__; /*-Sizes-*/ -define symbol __ICFEDIT_size_cstack__ = 0x800; -define symbol __ICFEDIT_size_heap__ = 0x200; +define symbol __ICFEDIT_size_cstack__ = ; +define symbol __ICFEDIT_size_heap__ = ; /**** End of ICF editor section. ###ICF###*/ define memory mem with size = 4G; define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; +define block RO_END with alignment = 8, size = 0 { }; initialize by copy { readwrite }; do not initialize { section .noinit }; keep { section .intvec }; place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; -place in ROM_region { readonly }; +place in ROM_region { readonly, + block RO_END }; place in RAM_region { readwrite, block CSTACK, block HEAP }; diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/uicr_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/arm/uicr_config.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/uicr_config.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/arm/uicr_config.h index be5a40c..670d4f1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/arm/uicr_config.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/arm/uicr_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2013 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ /* Template files (including this one) are application specific and therefore expected to diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/dsp/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/dsp/license.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/dsp/license.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/dsp/license.txt diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/arm_common_tables.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/arm_common_tables.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/arm_common_tables.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/arm_common_tables.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/arm_const_structs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/arm_const_structs.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/arm_const_structs.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/arm_const_structs.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/arm_math.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/arm_math.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/arm_math.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/arm_math.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/cmsis_armcc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/cmsis_armcc.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/cmsis_armcc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/cmsis_armcc.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/cmsis_armcc_V6.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/cmsis_armcc_V6.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/cmsis_armcc_V6.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/cmsis_armcc_V6.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/cmsis_gcc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/cmsis_gcc.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/cmsis_gcc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/cmsis_gcc.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm0.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm0.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm0.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm0.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm0plus.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm0plus.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm0plus.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm0plus.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm3.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm3.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm3.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm3.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm4.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm4.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm4.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm4.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm7.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm7.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cm7.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cm7.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cmFunc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cmFunc.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cmFunc.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cmFunc.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cmInstr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cmInstr.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cmInstr.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cmInstr.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cmSimd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cmSimd.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_cmSimd.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_cmSimd.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_sc000.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_sc000.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_sc000.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_sc000.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_sc300.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_sc300.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include/core_sc300.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/cmsis/include/core_sc300.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.common b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.common similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.common rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.common diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.posix b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.posix new file mode 100644 index 0000000..2719784 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.posix @@ -0,0 +1,3 @@ +GNU_INSTALL_ROOT ?= /usr/local/gcc-arm-none-eabi-7-2018-q2-update/bin/ +GNU_VERSION ?= 7.3.1 +GNU_PREFIX ?= arm-none-eabi diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.windows b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.windows similarity index 67% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.windows rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.windows index 1cbdb26..317b77d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/Makefile.windows +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/Makefile.windows @@ -1,3 +1,3 @@ -GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q3/bin/ -GNU_VERSION := 4.9.3 +GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/9 2019-q4-major/bin/ +GNU_VERSION := 7.3.1 GNU_PREFIX := arm-none-eabi diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/dump.mk b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/dump.mk similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/dump.mk rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/dump.mk diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_nrf51_common.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/gcc_nrf51_common.ld similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc/gcc_nrf51_common.ld rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/gcc/gcc_nrf51_common.ld diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_nrf51_blank_xxaa.icf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/iar/iar_nrf51_blank_xxaa.icf similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_nrf51_blank_xxaa.icf rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/iar/iar_nrf51_blank_xxaa.icf diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_nrf51_blank_xxac.icf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/iar/iar_nrf51_blank_xxac.icf similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/toolchain/iar/iar_nrf51_blank_xxac.icf rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/components/toolchain/iar/iar_nrf51_blank_xxac.icf diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/armgcc/generic_gcc_nrf52.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/armgcc/generic_gcc_nrf52.ld new file mode 100644 index 0000000..ad801f9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/armgcc/generic_gcc_nrf52.ld @@ -0,0 +1,130 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x19000, LENGTH = 0x17000 + RAM (rwx) : ORIGIN = 0x20001118, LENGTH = 0x4ee8 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/config/sdk_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/config/sdk_config.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/config/sdk_config.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/config/sdk_config.h index cf507c2..2e75a88 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/config/sdk_config.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/config/sdk_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -46,135 +46,172 @@ #ifdef USE_APP_CONFIG #include "app_config.h" #endif -// Board Support +// nRF_BLE //========================================================== -// BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module -#ifndef BSP_BTN_BLE_ENABLED -#define BSP_BTN_BLE_ENABLED 0 +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 #endif -// -//========================================================== +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands + -// nRF_ANT +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) //========================================================== -// ANTFS_ENABLED - ant_fs - ANT File Share module. -//========================================================== -#ifndef ANTFS_ENABLED -#define ANTFS_ENABLED 0 +#ifndef NRF_BLE_QWR_ENABLED +#define NRF_BLE_QWR_ENABLED 0 #endif -// ANTFS_CONFIG_NETWORK_NUMBER - ANT-FS network number. -#ifndef ANTFS_CONFIG_NETWORK_NUMBER -#define ANTFS_CONFIG_NETWORK_NUMBER 0 +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 #endif -// ANTFS_CONFIG_CHANNEL_NUMBER - ANT-FS channel number. -#ifndef ANTFS_CONFIG_CHANNEL_NUMBER -#define ANTFS_CONFIG_CHANNEL_NUMBER 0 -#endif +// -// ANTFS_CONFIG_PAIRING_TIMEOUT - Pairing timeout - how long the UI will wait for a response to a pairing request before switching to the link layer, in seconds. -#ifndef ANTFS_CONFIG_PAIRING_TIMEOUT -#define ANTFS_CONFIG_PAIRING_TIMEOUT 120 +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 #endif -// ANTFS_CONFIG_LINK_COMMAND_TIMEOUT - Command timeout - how long the client will wait without receiving any commands before switching to the link layer, in seconds. -#ifndef ANTFS_CONFIG_LINK_COMMAND_TIMEOUT -#define ANTFS_CONFIG_LINK_COMMAND_TIMEOUT 10 +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 #endif -// ANTFS_CONFIG_TRANS_TYPE - ANT-FS Transmission Type. -#ifndef ANTFS_CONFIG_TRANS_TYPE -#define ANTFS_CONFIG_TRANS_TYPE 10 +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 #endif -// ANTFS_CONFIG_DEVICE_TYPE - ANT device type for channel configuration. -#ifndef ANTFS_CONFIG_DEVICE_TYPE -#define ANTFS_CONFIG_DEVICE_TYPE 1 +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 #endif -// ANTFS_CONFIG_BEACON_STATUS_PERIOD - ANT-FS Beacon Message Period. +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. -// <0=> 0.5 Hz -// <1=> 1 Hz -// <2=> 2 Hz -// <3=> 4 Hz -// <4=> 8 Hz -#ifndef ANTFS_CONFIG_BEACON_STATUS_PERIOD -#define ANTFS_CONFIG_BEACON_STATUS_PERIOD 3 +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 #endif -// ANTFS_CONFIG_TRANSMIT_POWER - ANT Transmit Power. +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. -// <0=> Lowest ANT Tx power level setting. (-20dBm) -// <1=> ANT Tx power > Lvl 0. (-12dBm) -// <2=> ANT Tx power > Lvl 1. (-4dBm) -// <3=> ANT Tx power > Lvl 2. Default tx power level. (0dBm) -// <4=> ANT Tx power > Lvl 3. (+4dBm) -// <128=> Custom tx power selection -#ifndef ANTFS_CONFIG_TRANSMIT_POWER -#define ANTFS_CONFIG_TRANSMIT_POWER 3 +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 #endif -// ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER - ANT Custom Transmit Power. -#ifndef ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER -#define ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER 0 +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 #endif -// ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED - Use pairing and key exchange authentication. - +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif -#ifndef ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED -#define ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED 0 +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 #endif -// ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED - Use passkey authentication. - +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. -#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED -#define ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED 0 +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 #endif -// ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED - Allow host to bypass authentication. - +// -#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED -#define ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED 0 +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 #endif -// ANTFS_CONFIG_UPLOAD_ENABLED - Support upload operation. +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client -#ifndef ANTFS_CONFIG_UPLOAD_ENABLED -#define ANTFS_CONFIG_UPLOAD_ENABLED 0 +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 #endif -// ANTFS_CONFIG_DEBUG_LED_ENABLED - Enables LED debug in the module. +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client -#ifndef ANTFS_CONFIG_DEBUG_LED_ENABLED -#define ANTFS_CONFIG_DEBUG_LED_ENABLED 0 +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 #endif -// +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif -// ANT_BPWR_ENABLED - ant_bpwr - Bicycle Power Profile +// BLE_BAS_ENABLED - ble_bas - Battery Service //========================================================== -#ifndef ANT_BPWR_ENABLED -#define ANT_BPWR_ENABLED 0 +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 #endif -// ANT_BPWR_LOG_ENABLED - Enables general logging in the module. +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef ANT_BPWR_LOG_ENABLED -#define ANT_BPWR_LOG_ENABLED 0 +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 #endif -// ANT_BPWR_LOG_LEVEL - Default Severity level +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -182,11 +219,11 @@ // <3=> Info // <4=> Debug -#ifndef ANT_BPWR_LOG_LEVEL -#define ANT_BPWR_LOG_LEVEL 3 +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 #endif -// ANT_BPWR_INFO_COLOR - ANSI escape code prefix. +// BLE_BAS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -198,30 +235,11 @@ // <7=> Cyan // <8=> White -#ifndef ANT_BPWR_INFO_COLOR -#define ANT_BPWR_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_COMMON_LOG_ENABLED - Enables logging of BPWR tracing common data. -//========================================================== -#ifndef ANT_BPWR_COMMON_LOG_ENABLED -#define ANT_BPWR_COMMON_LOG_ENABLED 0 -#endif -// ANT_BPWR_COMMON_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_COMMON_LOG_LEVEL -#define ANT_BPWR_COMMON_LOG_LEVEL 3 +#ifndef BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 #endif -// ANT_BPWR_COMMON_INFO_COLOR - ANSI escape code prefix. +// BLE_BAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -233,123 +251,88 @@ // <7=> Cyan // <8=> White -#ifndef ANT_BPWR_COMMON_INFO_COLOR -#define ANT_BPWR_COMMON_INFO_COLOR 0 +#ifndef BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 #endif // -// ANT_BPWR_PAGE_TORQUE_LOG_ENABLED - Enables logging of BPWR torque page in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_TORQUE_LOG_ENABLED -#define ANT_BPWR_PAGE_TORQUE_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_TORQUE_LOG_LEVEL - Default Severity level +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BPWR_PAGE_TORQUE_LOG_LEVEL -#define ANT_BPWR_PAGE_TORQUE_LOG_LEVEL 3 +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 #endif -// ANT_BPWR_PAGE_TORQUE_INFO_COLOR - ANSI escape code prefix. +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BPWR_PAGE_TORQUE_INFO_COLOR -#define ANT_BPWR_PAGE_TORQUE_INFO_COLOR 0 +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 #endif -// +// BLE_DIS_ENABLED - ble_dis - Device Information Service + -// ANT_BPWR_PAGE_1_LOG_ENABLED - Enables logging of BPWR page 1 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_1_LOG_ENABLED -#define ANT_BPWR_PAGE_1_LOG_ENABLED 0 +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 #endif -// ANT_BPWR_PAGE_1_LOG_LEVEL - Default Severity level + +// BLE_GLS_ENABLED - ble_gls - Glucose Service -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BPWR_PAGE_1_LOG_LEVEL -#define ANT_BPWR_PAGE_1_LOG_LEVEL 3 +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 #endif -// ANT_BPWR_PAGE_1_INFO_COLOR - ANSI escape code prefix. +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BPWR_PAGE_1_INFO_COLOR -#define ANT_BPWR_PAGE_1_INFO_COLOR 0 +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 #endif -// +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + -// ANT_BPWR_PAGE_16_LOG_ENABLED - Enables logging of BPWR page 16 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_16_LOG_ENABLED -#define ANT_BPWR_PAGE_16_LOG_ENABLED 0 +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 #endif -// ANT_BPWR_PAGE_16_LOG_LEVEL - Default Severity level + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BPWR_PAGE_16_LOG_LEVEL -#define ANT_BPWR_PAGE_16_LOG_LEVEL 3 +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 #endif -// ANT_BPWR_PAGE_16_INFO_COLOR - ANSI escape code prefix. +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BPWR_PAGE_16_INFO_COLOR -#define ANT_BPWR_PAGE_16_INFO_COLOR 0 +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 #endif -// +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif -// ANT_BPWR_PAGE_17_LOG_ENABLED - Enables logging of BPWR page 17 in the module. +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef ANT_BPWR_PAGE_17_LOG_ENABLED -#define ANT_BPWR_PAGE_17_LOG_ENABLED 0 +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 #endif -// ANT_BPWR_PAGE_17_LOG_LEVEL - Default Severity level +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -357,11 +340,11 @@ // <3=> Info // <4=> Debug -#ifndef ANT_BPWR_PAGE_17_LOG_LEVEL -#define ANT_BPWR_PAGE_17_LOG_LEVEL 3 +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 #endif -// ANT_BPWR_PAGE_17_INFO_COLOR - ANSI escape code prefix. +// BLE_IAS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -373,30 +356,11 @@ // <7=> Cyan // <8=> White -#ifndef ANT_BPWR_PAGE_17_INFO_COLOR -#define ANT_BPWR_PAGE_17_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_PAGE_18_LOG_ENABLED - Enables logging of BPWR page 18 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_18_LOG_ENABLED -#define ANT_BPWR_PAGE_18_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_18_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_PAGE_18_LOG_LEVEL -#define ANT_BPWR_PAGE_18_LOG_LEVEL 3 +#ifndef BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 #endif -// ANT_BPWR_PAGE_18_INFO_COLOR - ANSI escape code prefix. +// BLE_IAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -408,95 +372,53 @@ // <7=> Cyan // <8=> White -#ifndef ANT_BPWR_PAGE_18_INFO_COLOR -#define ANT_BPWR_PAGE_18_INFO_COLOR 0 +#ifndef BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 #endif // // -// ANT_BSC_ENABLED - ant_bsc - Bicycle Speed and Cadence Profile -//========================================================== -#ifndef ANT_BSC_ENABLED -#define ANT_BSC_ENABLED 0 -#endif -// ANT_BSC_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_BSC_LOG_ENABLED -#define ANT_BSC_LOG_ENABLED 0 -#endif -// ANT_BSC_LOG_LEVEL - Default Severity level +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BSC_LOG_LEVEL -#define ANT_BSC_LOG_LEVEL 3 +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 #endif -// ANT_BSC_INFO_COLOR - ANSI escape code prefix. +// BLE_LBS_ENABLED - ble_lbs - LED Button Service -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BSC_INFO_COLOR -#define ANT_BSC_INFO_COLOR 0 +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 0 #endif -// - -// ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED - Enables logging of BSC Combined page 0 in the module. -//========================================================== -#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED -#define ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED 0 -#endif -// ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL - Default Severity level +// BLE_LLS_ENABLED - ble_lls - Link Loss Service -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL -#define ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL 3 +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 #endif -// ANT_BSC_COMBINED_PAGE_0_INFO_COLOR - ANSI escape code prefix. +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BSC_COMBINED_PAGE_0_INFO_COLOR -#define ANT_BSC_COMBINED_PAGE_0_INFO_COLOR 0 +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 #endif -// - -// ANT_BSC_PAGE_0_LOG_ENABLED - Enables logging of BSC page 0 in the module. +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef ANT_BSC_PAGE_0_LOG_ENABLED -#define ANT_BSC_PAGE_0_LOG_ENABLED 0 +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 #endif -// ANT_BSC_PAGE_0_LOG_LEVEL - Default Severity level +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -504,11 +426,11 @@ // <3=> Info // <4=> Debug -#ifndef ANT_BSC_PAGE_0_LOG_LEVEL -#define ANT_BSC_PAGE_0_LOG_LEVEL 3 +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 #endif -// ANT_BSC_PAGE_0_INFO_COLOR - ANSI escape code prefix. +// BLE_NUS_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -520,30 +442,11 @@ // <7=> Cyan // <8=> White -#ifndef ANT_BSC_PAGE_0_INFO_COLOR -#define ANT_BSC_PAGE_0_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_1_LOG_ENABLED - Enables logging of BSC page 1 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_1_LOG_ENABLED -#define ANT_BSC_PAGE_1_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_1_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_1_LOG_LEVEL -#define ANT_BSC_PAGE_1_LOG_LEVEL 3 +#ifndef BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 #endif -// ANT_BSC_PAGE_1_INFO_COLOR - ANSI escape code prefix. +// BLE_NUS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -555,958 +458,784 @@ // <7=> Cyan // <8=> White -#ifndef ANT_BSC_PAGE_1_INFO_COLOR -#define ANT_BSC_PAGE_1_INFO_COLOR 0 +#ifndef BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 #endif // -// ANT_BSC_PAGE_2_LOG_ENABLED - Enables logging of BSC page 2 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_2_LOG_ENABLED -#define ANT_BSC_PAGE_2_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_2_LOG_LEVEL - Default Severity level +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BSC_PAGE_2_LOG_LEVEL -#define ANT_BSC_PAGE_2_LOG_LEVEL 3 +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 #endif -// ANT_BSC_PAGE_2_INFO_COLOR - ANSI escape code prefix. +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BSC_PAGE_2_INFO_COLOR -#define ANT_BSC_PAGE_2_INFO_COLOR 0 +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 #endif -// - -// ANT_BSC_PAGE_3_LOG_ENABLED - Enables logging of BSC page 3 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_3_LOG_ENABLED -#define ANT_BSC_PAGE_3_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_3_LOG_LEVEL - Default Severity level +// BLE_TPS_ENABLED - ble_tps - TX Power Service -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BSC_PAGE_3_LOG_LEVEL -#define ANT_BSC_PAGE_3_LOG_LEVEL 3 +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 #endif -// ANT_BSC_PAGE_3_INFO_COLOR - ANSI escape code prefix. +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BSC_PAGE_3_INFO_COLOR -#define ANT_BSC_PAGE_3_INFO_COLOR 0 +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 #endif // -// ANT_BSC_PAGE_4_LOG_ENABLED - Enables logging of BSC page 4 in the module. +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard //========================================================== -#ifndef ANT_BSC_PAGE_4_LOG_ENABLED -#define ANT_BSC_PAGE_4_LOG_ENABLED 0 +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 #endif -// ANT_BSC_PAGE_4_LOG_LEVEL - Default Severity level +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes -#ifndef ANT_BSC_PAGE_4_LOG_LEVEL -#define ANT_BSC_PAGE_4_LOG_LEVEL 3 +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 #endif -// ANT_BSC_PAGE_4_INFO_COLOR - ANSI escape code prefix. +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. // <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) -#ifndef ANT_BSC_PAGE_4_INFO_COLOR -#define ANT_BSC_PAGE_4_INFO_COLOR 0 +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 #endif -// +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. -// ANT_BSC_PAGE_5_LOG_ENABLED - Enables logging of BSC page 5 in the module. +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). //========================================================== -#ifndef ANT_BSC_PAGE_5_LOG_ENABLED -#define ANT_BSC_PAGE_5_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 #endif -// ANT_BSC_PAGE_5_LOG_LEVEL - Default Severity level +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_BSC_PAGE_5_LOG_LEVEL -#define ANT_BSC_PAGE_5_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 #endif -// ANT_BSC_PAGE_5_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_BSC_PAGE_5_INFO_COLOR -#define ANT_BSC_PAGE_5_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + -// +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif -// ANT_CHANNEL_CONFIG_ENABLED - ant_channel_config - ANT common channel configuration +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation -#ifndef ANT_CHANNEL_CONFIG_ENABLED -#define ANT_CHANNEL_CONFIG_ENABLED 0 -#endif +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -// ANT_COMMON_PAGE_70_ENABLED - ant_common_page_70 - ANT+ common page 70 -//========================================================== -#ifndef ANT_COMMON_PAGE_70_ENABLED -#define ANT_COMMON_PAGE_70_ENABLED 0 -#endif -// ANT_COMMON_PAGE_70_LOG_ENABLED - Enables logging of common page 70 in the module. -//========================================================== -#ifndef ANT_COMMON_PAGE_70_LOG_ENABLED -#define ANT_COMMON_PAGE_70_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 #endif -// ANT_COMMON_PAGE_70_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_COMMON_PAGE_70_LOG_LEVEL -#define ANT_COMMON_PAGE_70_LOG_LEVEL 3 +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 #endif -// ANT_COMMON_PAGE_70_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_COMMON_PAGE_70_INFO_COLOR -#define ANT_COMMON_PAGE_70_INFO_COLOR 0 +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 #endif // -// +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. -// ANT_COMMON_PAGE_80_ENABLED - ant_common_page_80 - ANT+ common page 80 -//========================================================== -#ifndef ANT_COMMON_PAGE_80_ENABLED -#define ANT_COMMON_PAGE_80_ENABLED 0 -#endif -// ANT_COMMON_PAGE_80_LOG_ENABLED - Enables logging of common page 80 in the module. +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). //========================================================== -#ifndef ANT_COMMON_PAGE_80_LOG_ENABLED -#define ANT_COMMON_PAGE_80_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 #endif -// ANT_COMMON_PAGE_80_LOG_LEVEL - Default Severity level +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_COMMON_PAGE_80_LOG_LEVEL -#define ANT_COMMON_PAGE_80_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 #endif -// ANT_COMMON_PAGE_80_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_COMMON_PAGE_80_INFO_COLOR -#define ANT_COMMON_PAGE_80_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 #endif -// - -// +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + -// ANT_COMMON_PAGE_81_ENABLED - ant_common_page_81 - ANT+ common page 81 -//========================================================== -#ifndef ANT_COMMON_PAGE_81_ENABLED -#define ANT_COMMON_PAGE_81_ENABLED 0 -#endif -// ANT_COMMON_PAGE_81_LOG_ENABLED - Enables logging of common page 81 in the module. -//========================================================== -#ifndef ANT_COMMON_PAGE_81_LOG_ENABLED -#define ANT_COMMON_PAGE_81_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 #endif -// ANT_COMMON_PAGE_81_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_COMMON_PAGE_81_LOG_LEVEL -#define ANT_COMMON_PAGE_81_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 #endif -// ANT_COMMON_PAGE_81_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_COMMON_PAGE_81_INFO_COLOR -#define ANT_COMMON_PAGE_81_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + -// +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif -// ANT_ENCRYPT_CONFIG_ENABLED - ant_encrypt_config - Cryptographic ANT stack configuration +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. -#ifndef ANT_ENCRYPT_CONFIG_ENABLED -#define ANT_ENCRYPT_CONFIG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 #endif -// ANT_HRM_ENABLED - ant_hrm - Heart Rate Monitor Profile -//========================================================== -#ifndef ANT_HRM_ENABLED -#define ANT_HRM_ENABLED 0 -#endif -// ANT_HRM_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_HRM_LOG_ENABLED -#define ANT_HRM_LOG_ENABLED 0 +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 #endif -// ANT_HRM_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_HRM_LOG_LEVEL -#define ANT_HRM_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 #endif -// ANT_HRM_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_HRM_INFO_COLOR -#define ANT_HRM_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + -// ANT_HRM_PAGE_0_LOG_ENABLED - Enables logging of HRM page 0 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_0_LOG_ENABLED -#define ANT_HRM_PAGE_0_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 #endif -// ANT_HRM_PAGE_0_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_HRM_PAGE_0_LOG_LEVEL -#define ANT_HRM_PAGE_0_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 #endif -// ANT_HRM_PAGE_0_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_HRM_PAGE_0_INFO_COLOR -#define ANT_HRM_PAGE_0_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + -// ANT_HRM_PAGE_1_LOG_ENABLED - Enables logging of HRM page 1 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_1_LOG_ENABLED -#define ANT_HRM_PAGE_1_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 #endif -// ANT_HRM_PAGE_1_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_HRM_PAGE_1_LOG_LEVEL -#define ANT_HRM_PAGE_1_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 #endif -// ANT_HRM_PAGE_1_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_HRM_PAGE_1_INFO_COLOR -#define ANT_HRM_PAGE_1_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + -// ANT_HRM_PAGE_2_LOG_ENABLED - Enables logging of HRM page 2 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_2_LOG_ENABLED -#define ANT_HRM_PAGE_2_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 #endif -// ANT_HRM_PAGE_2_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_HRM_PAGE_2_LOG_LEVEL -#define ANT_HRM_PAGE_2_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 #endif -// ANT_HRM_PAGE_2_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_HRM_PAGE_2_INFO_COLOR -#define ANT_HRM_PAGE_2_INFO_COLOR 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + -// ANT_HRM_PAGE_3_LOG_ENABLED - Enables logging of HRM page 3 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_3_LOG_ENABLED -#define ANT_HRM_PAGE_3_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 #endif -// ANT_HRM_PAGE_3_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_HRM_PAGE_3_LOG_LEVEL -#define ANT_HRM_PAGE_3_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 #endif -// ANT_HRM_PAGE_3_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_HRM_PAGE_3_INFO_COLOR -#define ANT_HRM_PAGE_3_INFO_COLOR 0 -#endif - -// - -// ANT_HRM_PAGE_4_LOG_ENABLED - Enables logging of HRM page 4 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_4_LOG_ENABLED -#define ANT_HRM_PAGE_4_LOG_ENABLED 0 -#endif -// ANT_HRM_PAGE_4_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// CC310 backend implementation for hardware-accelerated SHA-256. -#ifndef ANT_HRM_PAGE_4_LOG_LEVEL -#define ANT_HRM_PAGE_4_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 #endif -// ANT_HRM_PAGE_4_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_PAGE_4_INFO_COLOR -#define ANT_HRM_PAGE_4_INFO_COLOR 0 -#endif -// +// CC310 backend implementation for SHA-512 (in software). -// +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif -// ANT_KEY_MANAGER_ENABLED - ant_key_manager - Software Component +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 -#ifndef ANT_KEY_MANAGER_ENABLED -#define ANT_KEY_MANAGER_ENABLED 0 +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 #endif -// ANT_REQUEST_CONTROLLER_ENABLED - ant_request_controller - ANT+ request controller +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 -#ifndef ANT_REQUEST_CONTROLLER_ENABLED -#define ANT_REQUEST_CONTROLLER_ENABLED 0 -#endif +// CC310 backend implementation for HMAC using SHA-512 (in software). -// ANT_SDM_ENABLED - ant_sdm - Stride Based Speed and Distance Monitor Profile -//========================================================== -#ifndef ANT_SDM_ENABLED -#define ANT_SDM_ENABLED 0 -#endif -// ANT_SDM_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_SDM_LOG_ENABLED -#define ANT_SDM_LOG_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 #endif -// ANT_SDM_LOG_LEVEL - Default Severity level + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef ANT_SDM_LOG_LEVEL -#define ANT_SDM_LOG_LEVEL 3 +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 #endif -// ANT_SDM_INFO_COLOR - ANSI escape code prefix. +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef ANT_SDM_INFO_COLOR -#define ANT_SDM_INFO_COLOR 0 -#endif +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used -// +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif // -// ANT_SEARCH_CONFIG_ENABLED - ant_search_config - ANT common search configuration +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. //========================================================== -#ifndef ANT_SEARCH_CONFIG_ENABLED -#define ANT_SEARCH_CONFIG_ENABLED 0 -#endif -// ANT_DEFAULT_LOW_PRIORITY_TIMEOUT - Default low priority search time-out. <0-255> - - -#ifndef ANT_DEFAULT_LOW_PRIORITY_TIMEOUT -#define ANT_DEFAULT_LOW_PRIORITY_TIMEOUT 2 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 #endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + -// ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT - Default high priority search time-out. <0-255> - - -#ifndef ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT -#define ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT 10 +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 #endif // -// ANT_STACK_CONFIG_ENABLED - ant_stack_config - Common ANT stack configuration +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. //========================================================== -#ifndef ANT_STACK_CONFIG_ENABLED -#define ANT_STACK_CONFIG_ENABLED 0 -#endif -// ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels -#ifndef ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED -#define ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 #endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + -// ANT_CONFIG_ENCRYPTED_CHANNELS - Encrypted ANT channels -#ifndef ANT_CONFIG_ENCRYPTED_CHANNELS -#define ANT_CONFIG_ENCRYPTED_CHANNELS 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 #endif -// ANT_CONFIG_EVENT_QUEUE_SIZE - Event queue size -#ifndef ANT_CONFIG_EVENT_QUEUE_SIZE -#define ANT_CONFIG_EVENT_QUEUE_SIZE 32 -#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + -// ANT_CONFIG_BURST_QUEUE_SIZE - ANT burst queue size -#ifndef ANT_CONFIG_BURST_QUEUE_SIZE -#define ANT_CONFIG_BURST_QUEUE_SIZE 128 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + -// ANT_STATE_INDICATOR_ENABLED - ant_state_indicator - ANT state indicator using BSP -//========================================================== -#ifndef ANT_STATE_INDICATOR_ENABLED -#define ANT_STATE_INDICATOR_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 #endif -// ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY - Shutdown observer priority. -#ifndef ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY -#define ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY 1 -#endif - -// -// -//========================================================== +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + -// nRF_BLE +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif -//========================================================== -// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. -#ifndef BLE_ADVERTISING_ENABLED -#define BLE_ADVERTISING_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 #endif -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 #endif -// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. -#ifndef BLE_RACP_ENABLED -#define BLE_RACP_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 #endif -// NRF_BLE_CONN_PARAMS_ENABLED - ble_conn_params - Initiating and executing a connection parameters negotiation procedure -//========================================================== -#ifndef NRF_BLE_CONN_PARAMS_ENABLED -#define NRF_BLE_CONN_PARAMS_ENABLED 0 -#endif -// NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION - The largest acceptable deviation in slave latency. -// The largest deviation (+ or -) from the requested slave latency that will not be renegotiated. +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + -#ifndef NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION -#define NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION 499 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 #endif -// NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION - The largest acceptable deviation (in 10 ms units) in supervision timeout. -// The largest deviation (+ or -, in 10 ms units) from the requested supervision timeout that will not be renegotiated. +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS -#ifndef NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION -#define NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION 65535 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 #endif -// - -// NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -#ifndef NRF_BLE_QWR_ENABLED -#define NRF_BLE_QWR_ENABLED 0 -#endif +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS -// PEER_MANAGER_ENABLED - peer_manager - Peer Manager -//========================================================== -#ifndef PEER_MANAGER_ENABLED -#define PEER_MANAGER_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 #endif -// PM_MAX_REGISTRANTS -// Number of event handlers that can be registered. -#ifndef PM_MAX_REGISTRANTS -#define PM_MAX_REGISTRANTS 3 -#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + -// PM_FLASH_BUFFERS -// Number of internal buffers for flash operations. -// Decrease this value to lower RAM usage. +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS -#ifndef PM_FLASH_BUFFERS -#define PM_FLASH_BUFFERS 8 +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + -// -//========================================================== +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS -// nRF_BLE_Services +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif -//========================================================== -// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve -#ifndef BLE_ANCS_C_ENABLED -#define BLE_ANCS_C_ENABLED 0 +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 #endif -// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve -#ifndef BLE_ANS_C_ENABLED -#define BLE_ANS_C_ENABLED 0 +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 #endif -// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve -#ifndef BLE_BAS_C_ENABLED -#define BLE_BAS_C_ENABLED 0 +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 #endif -// BLE_BAS_ENABLED - ble_bas - Battery Service +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve -#ifndef BLE_BAS_ENABLED -#define BLE_BAS_ENABLED 0 +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 #endif -// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve -#ifndef BLE_CSCS_ENABLED -#define BLE_CSCS_ENABLED 0 +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 #endif -// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve -#ifndef BLE_CTS_C_ENABLED -#define BLE_CTS_C_ENABLED 0 +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 #endif -// BLE_DIS_ENABLED - ble_dis - Device Information Service +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve -#ifndef BLE_DIS_ENABLED -#define BLE_DIS_ENABLED 0 +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 #endif -// BLE_GLS_ENABLED - ble_gls - Glucose Service +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve -#ifndef BLE_GLS_ENABLED -#define BLE_GLS_ENABLED 0 +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 #endif -// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. -#ifndef BLE_HIDS_ENABLED -#define BLE_HIDS_ENABLED 0 +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 #endif -// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. -#ifndef BLE_HRS_C_ENABLED -#define BLE_HRS_C_ENABLED 0 +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 #endif -// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. -#ifndef BLE_HRS_ENABLED -#define BLE_HRS_ENABLED 0 +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 #endif -// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. -#ifndef BLE_HTS_ENABLED -#define BLE_HTS_ENABLED 0 +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 #endif -// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve -#ifndef BLE_IAS_C_ENABLED -#define BLE_IAS_C_ENABLED 0 +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 #endif -// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve -#ifndef BLE_IAS_ENABLED -#define BLE_IAS_ENABLED 0 +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 #endif -// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve -#ifndef BLE_LBS_C_ENABLED -#define BLE_LBS_C_ENABLED 0 +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 #endif -// BLE_LBS_ENABLED - ble_lbs - LED Button Service +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve -#ifndef BLE_LBS_ENABLED -#define BLE_LBS_ENABLED 0 +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 #endif -// BLE_LLS_ENABLED - ble_lls - Link Loss Service +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. -#ifndef BLE_LLS_ENABLED -#define BLE_LLS_ENABLED 0 +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 #endif -// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 -#ifndef BLE_NUS_C_ENABLED -#define BLE_NUS_C_ENABLED 0 +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 #endif -// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. -#ifndef BLE_NUS_ENABLED -#define BLE_NUS_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 #endif -// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve -#ifndef BLE_RSCS_C_ENABLED -#define BLE_RSCS_C_ENABLED 0 +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 #endif -// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH -#ifndef BLE_RSCS_ENABLED -#define BLE_RSCS_ENABLED 0 +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 #endif -// BLE_TPS_ENABLED - ble_tps - TX Power Service +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme -#ifndef BLE_TPS_ENABLED -#define BLE_TPS_ENABLED 0 +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 #endif -// -//========================================================== +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + -// nRF_Core +// Oberon backend implementation for SHA-256. -//========================================================== -// NRF_MPU_ENABLED - nrf_mpu - Module for MPU -//========================================================== -#ifndef NRF_MPU_ENABLED -#define NRF_MPU_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 #endif -// NRF_MPU_CLI_CMDS - Enable CLI commands specific to the module + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality -#ifndef NRF_MPU_CLI_CMDS -#define NRF_MPU_CLI_CMDS 1 +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 #endif -// +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + -// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Module for Protecting Stack -//========================================================== -#ifndef NRF_STACK_GUARD_ENABLED -#define NRF_STACK_GUARD_ENABLED 0 +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 #endif -// NRF_STACK_GUARD_CONFIG_SIZE - Size of stack guard + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 -// <5=> 32 bytes -// <6=> 64 bytes -// <7=> 128 bytes -// <8=> 256 bytes -// <9=> 512 bytes -// <10=> 1024 bytes -// <11=> 2048 bytes -// <12=> 4096 bytes -#ifndef NRF_STACK_GUARD_CONFIG_SIZE -#define NRF_STACK_GUARD_CONFIG_SIZE 7 +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 #endif // -// -//========================================================== - -// nRF_Crypto +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. +// Enables the nrf_crypto backend for Optiga Trust X devices. //========================================================== -// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library -//========================================================== -#ifndef NRF_CRYPTO_ENABLED -#define NRF_CRYPTO_ENABLED 0 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 #endif -// NRF_CRYPTO_BACKEND_CC310_LIB - Enable the ARM Cryptocell CC310 backend +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG -// The hardware-accelerated cryptography backend is available only on nRF52840. +// The Optiga backend provide external chip RNG. -#ifndef NRF_CRYPTO_BACKEND_CC310_LIB -#define NRF_CRYPTO_BACKEND_CC310_LIB 1 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 #endif -// NRF_CRYPTO_BACKEND_MICRO_ECC - Enable the micro-ecc software backend - -// The micro-ecc library provides a software implementation of ECC cryptography for nRF5 Series devices. -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC -#define NRF_CRYPTO_BACKEND_MICRO_ECC 0 -#endif -// NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 - Enable SHA256 +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 -// Enable SHA256 cryptographic hash functionality. -// Enable this setting if you need SHA256 support, for example to verify signatures. +// The Optiga backend provide external chip ECC using secp256r1. -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 -#define NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 1 +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 #endif -// NRF_CRYPTO_BACKEND_MICRO_ECC_RNG - Enable random number generator +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data -// Enable random number generation. -// Enable this setting if you need to generate cryptographic keys. -// This setting requires the RNG peripheral driver to be present. +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_RNG -#define NRF_CRYPTO_BACKEND_MICRO_ECC_RNG 0 +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 #endif // -// - // //========================================================== @@ -1539,164 +1268,7 @@ // nRF_Drivers //========================================================== -// APP_USBD_ENABLED - app_usbd - USB Device library -//========================================================== -#ifndef APP_USBD_ENABLED -#define APP_USBD_ENABLED 0 -#endif -// APP_USBD_VID - Vendor ID <0x0000-0xFFFF> - - -// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ - -#ifndef APP_USBD_VID -#define APP_USBD_VID 0 -#endif - -// APP_USBD_PID - Product ID <0x0000-0xFFFF> - - -// Selected Product ID - -#ifndef APP_USBD_PID -#define APP_USBD_PID 0 -#endif - -// APP_USBD_DEVICE_VER_MAJOR - Device version, major part <0-99> - - -// 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 - -// APP_USBD_DEVICE_VER_MINOR - Device version, minor part <0-99> - - -// 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 - -// APP_USBD_EVENT_QUEUE_ENABLE - Enable event queue - -// This is the default configuration when all the events are placed into internal queue. -// Disable it when external queue is used like app_scheduler or if you wish to process all events inside interrupts. -// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. -// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable and disable. -//========================================================== -#ifndef APP_USBD_EVENT_QUEUE_ENABLE -#define APP_USBD_EVENT_QUEUE_ENABLE 1 -#endif -// APP_USBD_EVENT_QUEUE_SIZE - The size of event queue <16-64> - - -// The size of the queue for the events that would be processed in the main loop. - -#ifndef APP_USBD_EVENT_QUEUE_SIZE -#define APP_USBD_EVENT_QUEUE_SIZE 32 -#endif - -// - -// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module -//========================================================== -#ifndef APP_USBD_CONFIG_LOG_ENABLED -#define APP_USBD_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_CONFIG_LOG_LEVEL -#define APP_USBD_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_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 APP_USBD_CONFIG_INFO_COLOR -#define APP_USBD_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_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 APP_USBD_CONFIG_DEBUG_COLOR -#define APP_USBD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver -//========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 0 -#endif -// CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency - -// <0=> Default (64 MHz) - -#ifndef CLOCK_CONFIG_XTAL_FREQ -#define CLOCK_CONFIG_XTAL_FREQ 0 -#endif - -// 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 - -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// 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 - -// - -// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer //========================================================== #ifndef COMP_ENABLED #define COMP_ENABLED 0 @@ -1781,26 +1353,26 @@ // <7=> 7 #ifndef COMP_CONFIG_IRQ_PRIORITY -#define COMP_CONFIG_IRQ_PRIORITY 7 +#define COMP_CONFIG_IRQ_PRIORITY 6 #endif // -// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer #ifndef EGU_ENABLED #define EGU_ENABLED 0 #endif -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer //========================================================== #ifndef GPIOTE_ENABLED #define GPIOTE_ENABLED 0 #endif // 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 +#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 #endif // GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority @@ -1817,12 +1389,12 @@ // <7=> 7 #ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 7 +#define GPIOTE_CONFIG_IRQ_PRIORITY 6 #endif // -// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer //========================================================== #ifndef I2S_ENABLED #define I2S_ENABLED 0 @@ -1963,12 +1535,63 @@ // <7=> 7 #ifndef I2S_CONFIG_IRQ_PRIORITY -#define I2S_CONFIG_IRQ_PRIORITY 7 +#define I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 // -// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer //========================================================== #ifndef LPCOMP_ENABLED #define LPCOMP_ENABLED 0 @@ -2043,48 +1666,30 @@ // <7=> 7 #ifndef LPCOMP_CONFIG_IRQ_PRIORITY -#define LPCOMP_CONFIG_IRQ_PRIORITY 7 +#define LPCOMP_CONFIG_IRQ_PRIORITY 6 #endif // -// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver //========================================================== -#ifndef PDM_ENABLED -#define PDM_ENABLED 0 -#endif -// PDM_CONFIG_MODE - Mode - -// <0=> Stereo -// <1=> Mono - -#ifndef PDM_CONFIG_MODE -#define PDM_CONFIG_MODE 1 -#endif - -// PDM_CONFIG_EDGE - Edge - -// <0=> Left falling -// <1=> Left rising - -#ifndef PDM_CONFIG_EDGE -#define PDM_CONFIG_EDGE 0 +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 0 #endif - -// PDM_CONFIG_CLOCK_FREQ - Clock frequency +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source -// <134217728=> 1000k -// <138412032=> 1032k (default) -// <142606336=> 1067k +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing -#ifndef PDM_CONFIG_CLOCK_FREQ -#define PDM_CONFIG_CLOCK_FREQ 138412032 +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 #endif -// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2094,154 +1699,136 @@ // <6=> 6 // <7=> 7 -#ifndef PDM_CONFIG_IRQ_PRIORITY -#define PDM_CONFIG_IRQ_PRIORITY 7 -#endif - -// - -// PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module - - -#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED -#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 #endif -// POWER_ENABLED - nrf_drv_power - POWER peripheral driver +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef POWER_ENABLED -#define POWER_ENABLED 0 +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 #endif -// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// 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 +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 #endif -// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator +// NRFX_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 -// This settings means only that components for DCDC regulator are installed and it can be enabled. +#ifndef NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif -#ifndef POWER_CONFIG_DEFAULT_DCDCEN -#define POWER_CONFIG_DEFAULT_DCDCEN 0 -#endif - -// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator +// NRFX_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 -// 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 +#ifndef NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 #endif // -// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - - -#ifndef PPI_ENABLED -#define PPI_ENABLED 0 -#endif +// -// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver //========================================================== -#ifndef PWM_ENABLED -#define PWM_ENABLED 0 -#endif -// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN -#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 -#endif - -// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN -#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 #endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef -// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN -#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 #endif -// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> - +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential -#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN -#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 #endif -// PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock +// NRFX_COMP_CONFIG_SPEED_MODE - Speed 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 +// <0=> Low power +// <1=> Normal +// <2=> High speed -#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK -#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 #endif -// PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode +// NRFX_COMP_CONFIG_HYST - Hystheresis -// <0=> Up -// <1=> Up and Down - -#ifndef PWM_DEFAULT_CONFIG_COUNT_MODE -#define PWM_DEFAULT_CONFIG_COUNT_MODE 0 -#endif +// <0=> No +// <1=> 50mV -// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value -#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE -#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 #endif -// PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode +// NRFX_COMP_CONFIG_ISOURCE - Current Source -// <0=> Common -// <1=> Grouped -// <2=> Individual -// <3=> Waveform +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA -#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE -#define PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 #endif -// PWM_DEFAULT_CONFIG_STEP_MODE - Step mode +// NRFX_COMP_CONFIG_INPUT - Analog input -// <0=> Auto -// <1=> Triggered +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef PWM_DEFAULT_CONFIG_STEP_MODE -#define PWM_DEFAULT_CONFIG_STEP_MODE 0 +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 #endif -// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2251,128 +1838,176 @@ // <6=> 6 // <7=> 7 -#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY -#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 #endif -// PWM0_ENABLED - Enable PWM0 instance - - -#ifndef PWM0_ENABLED -#define PWM0_ENABLED 0 +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 #endif - -// PWM1_ENABLED - Enable PWM1 instance +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef PWM1_ENABLED -#define PWM1_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 #endif -// PWM2_ENABLED - Enable PWM2 instance +// NRFX_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 PWM2_ENABLED -#define PWM2_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 #endif -// PWM3_ENABLED - Enable PWM3 instance +// NRFX_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 PWM3_ENABLED -#define PWM3_ENABLED 0 +#ifndef NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 #endif // -// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver //========================================================== -#ifndef QDEC_ENABLED -#define QDEC_ENABLED 0 +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 0 #endif -// QDEC_CONFIG_REPORTPER - Report period +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> 10 Samples -// <1=> 40 Samples -// <2=> 80 Samples -// <3=> 120 Samples -// <4=> 160 Samples -// <5=> 200 Samples -// <6=> 240 Samples -// <7=> 280 Samples +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef QDEC_CONFIG_REPORTPER -#define QDEC_CONFIG_REPORTPER 0 +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 #endif -// QDEC_CONFIG_SAMPLEPER - Sample period +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level -// <0=> 128 us -// <1=> 256 us -// <2=> 512 us -// <3=> 1024 us -// <4=> 2048 us -// <5=> 4096 us -// <6=> 8192 us -// <7=> 16384 us +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef QDEC_CONFIG_SAMPLEPER -#define QDEC_CONFIG_SAMPLEPER 7 +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 #endif -// QDEC_CONFIG_PIO_A - A pin <0-31> - +// NRFX_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 QDEC_CONFIG_PIO_A -#define QDEC_CONFIG_PIO_A 31 +#ifndef NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 #endif -// QDEC_CONFIG_PIO_B - B pin <0-31> - +// NRFX_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 QDEC_CONFIG_PIO_B -#define QDEC_CONFIG_PIO_B 31 +#ifndef NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 #endif -// QDEC_CONFIG_PIO_LED - LED pin <0-31> - +// -#ifndef QDEC_CONFIG_PIO_LED -#define QDEC_CONFIG_PIO_LED 31 -#endif +// -// QDEC_CONFIG_LEDPRE - LED pre -#ifndef QDEC_CONFIG_LEDPRE -#define QDEC_CONFIG_LEDPRE 511 +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 #endif - -// QDEC_CONFIG_LEDPOL - LED polarity +// NRFX_PDM_CONFIG_MODE - Mode -// <0=> Active low -// <1=> Active high +// <0=> Stereo +// <1=> Mono -#ifndef QDEC_CONFIG_LEDPOL -#define QDEC_CONFIG_LEDPOL 1 +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 #endif -// QDEC_CONFIG_DBFEN - Debouncing enable +// NRFX_PDM_CONFIG_EDGE - Edge +// <0=> Left falling +// <1=> Left rising -#ifndef QDEC_CONFIG_DBFEN -#define QDEC_CONFIG_DBFEN 0 +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 #endif -// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k -#ifndef QDEC_CONFIG_SAMPLE_INTEN -#define QDEC_CONFIG_SAMPLE_INTEN 0 +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 #endif -// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2382,71 +2017,70 @@ // <6=> 6 // <7=> 7 -#ifndef QDEC_CONFIG_IRQ_PRIORITY -#define QDEC_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 #endif -// - -// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef RNG_ENABLED -#define RNG_ENABLED 0 +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 #endif -// RNG_CONFIG_ERROR_CORRECTION - Error correction +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef RNG_CONFIG_ERROR_CORRECTION -#define RNG_CONFIG_ERROR_CORRECTION 0 -#endif - -// RNG_CONFIG_POOL_SIZE - Pool size -#ifndef RNG_CONFIG_POOL_SIZE -#define RNG_CONFIG_POOL_SIZE 32 +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 #endif -// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_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 -// 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 +#ifndef NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 #endif -// +// NRFX_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 -// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver -//========================================================== -#ifndef RTC_ENABLED -#define RTC_ENABLED 0 +#ifndef NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 #endif -// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> - -#ifndef RTC_DEFAULT_CONFIG_FREQUENCY -#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 -#endif +// -// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering - +// -#ifndef RTC_DEFAULT_CONFIG_RELIABLE -#define RTC_DEFAULT_CONFIG_RELIABLE 0 +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 #endif - -// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2456,184 +2090,179 @@ // <6=> 6 // <7=> 7 -#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY -#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 #endif -// RTC0_ENABLED - Enable RTC0 instance +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator -#ifndef RTC0_ENABLED -#define RTC0_ENABLED 0 -#endif - -// RTC1_ENABLED - Enable RTC1 instance - +// This settings means only that components for DCDC regulator are installed and it can be enabled. -#ifndef RTC1_ENABLED -#define RTC1_ENABLED 0 +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 #endif -// RTC2_ENABLED - Enable RTC2 instance +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator -#ifndef RTC2_ENABLED -#define RTC2_ENABLED 0 -#endif +// This settings means only that components for DCDC regulator are installed and it can be enabled. -// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt -#ifndef NRF_MAXIMUM_LATENCY_US -#define NRF_MAXIMUM_LATENCY_US 2000 +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 #endif // -// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator //========================================================== -#ifndef SAADC_ENABLED -#define SAADC_ENABLED 0 +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 #endif -// SAADC_CONFIG_RESOLUTION - Resolution - -// <0=> 8 bit -// <1=> 10 bit -// <2=> 12 bit -// <3=> 14 bit - -#ifndef SAADC_CONFIG_RESOLUTION -#define SAADC_CONFIG_RESOLUTION 1 +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 #endif - -// SAADC_CONFIG_OVERSAMPLE - Sample period +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level -// <0=> Disabled -// <1=> 2x -// <2=> 4x -// <3=> 8x -// <4=> 16x -// <5=> 32x -// <6=> 64x -// <7=> 128x -// <8=> 256x +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef SAADC_CONFIG_OVERSAMPLE -#define SAADC_CONFIG_OVERSAMPLE 0 +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 #endif -// SAADC_CONFIG_LP_MODE - Enabling low power mode +// NRFX_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 SAADC_CONFIG_LP_MODE -#define SAADC_CONFIG_LP_MODE 0 +#ifndef NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 #endif -// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_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 -// 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 +#ifndef NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 #endif // -// SPIS_ENABLED - nrf_drv_spis - SPI Slave driver +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver //========================================================== -#ifndef SPIS_ENABLED -#define SPIS_ENABLED 0 +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 #endif -// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_PWM0_ENABLED - Enable PWM0 instance -// 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 +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 #endif -// SPIS_DEFAULT_MODE - Mode - -// <0=> MODE_0 -// <1=> MODE_1 -// <2=> MODE_2 -// <3=> MODE_3 +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> -#ifndef SPIS_DEFAULT_MODE -#define SPIS_DEFAULT_MODE 0 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 #endif -// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order - -// <0=> MSB first -// <1=> LSB first +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> -#ifndef SPIS_DEFAULT_BIT_ORDER -#define SPIS_DEFAULT_BIT_ORDER 0 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 #endif -// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> -#ifndef SPIS_DEFAULT_DEF -#define SPIS_DEFAULT_DEF 255 +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 #endif -// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> -#ifndef SPIS_DEFAULT_ORC -#define SPIS_DEFAULT_ORC 255 +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 #endif -// SPIS0_ENABLED - Enable SPIS0 instance +// NRFX_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 kHz -#ifndef SPIS0_ENABLED -#define SPIS0_ENABLED 0 +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 #endif -// SPIS1_ENABLED - Enable SPIS1 instance +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif -#ifndef SPIS1_ENABLED -#define SPIS1_ENABLED 0 +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 #endif -// SPIS2_ENABLED - Enable SPIS2 instance +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform -#ifndef SPIS2_ENABLED -#define SPIS2_ENABLED 0 +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 #endif -// +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 0 +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 #endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2643,142 +2272,149 @@ // <6=> 6 // <7=> 7 -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// SPI0_ENABLED - Enable SPI0 instance +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 0 +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 #endif -// SPI0_USE_EASY_DMA - Use EasyDMA +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 1 +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 #endif -// SPI0_DEFAULT_FREQUENCY - SPI frequency +// NRFX_PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif -#ifndef SPI0_DEFAULT_FREQUENCY -#define SPI0_DEFAULT_FREQUENCY 1073741824 +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 #endif // -// SPI1_ENABLED - Enable SPI1 instance +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver //========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 #endif -// SPI1_USE_EASY_DMA - Use EasyDMA +// NRFX_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 SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 -#endif - -// 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 +#ifndef NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 #endif -// +// NRFX_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 -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 #endif -// SPI2_USE_EASY_DMA - Use EasyDMA - -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 #endif -// SPI2_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 +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> -#ifndef SPI2_DEFAULT_FREQUENCY -#define SPI2_DEFAULT_FREQUENCY 1073741824 + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 #endif -// +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> -// -// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver -//========================================================== -#ifndef TIMER_ENABLED -#define TIMER_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 #endif -// 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 +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 #endif -// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity -// <0=> Timer -// <1=> Counter +// <0=> Active low +// <1=> Active high -#ifndef TIMER_DEFAULT_CONFIG_MODE -#define TIMER_DEFAULT_CONFIG_MODE 0 +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 #endif -// TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable -// <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 +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 #endif -// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2788,86 +2424,77 @@ // <6=> 6 // <7=> 7 -#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY -#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 #endif -// TIMER0_ENABLED - Enable TIMER0 instance - - -#ifndef TIMER0_ENABLED -#define TIMER0_ENABLED 0 +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 #endif - -// TIMER1_ENABLED - Enable TIMER1 instance +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef TIMER1_ENABLED -#define TIMER1_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 #endif -// TIMER2_ENABLED - Enable TIMER2 instance +// NRFX_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 TIMER2_ENABLED -#define TIMER2_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 #endif -// TIMER3_ENABLED - Enable TIMER3 instance +// NRFX_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 TIMER3_ENABLED -#define TIMER3_ENABLED 0 +#ifndef NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 #endif -// TIMER4_ENABLED - Enable TIMER4 instance - - -#ifndef TIMER4_ENABLED -#define TIMER4_ENABLED 0 -#endif +// // -// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver //========================================================== -#ifndef TWIS_ENABLED -#define TWIS_ENABLED 0 -#endif -// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 -#ifndef TWIS_DEFAULT_CONFIG_ADDR0 -#define TWIS_DEFAULT_CONFIG_ADDR0 0 -#endif - -// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 -#ifndef TWIS_DEFAULT_CONFIG_ADDR1 -#define TWIS_DEFAULT_CONFIG_ADDR1 0 -#endif - -// 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 +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 #endif - -// TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction -// <0=> Disabled -// <1=> Pull down -// <3=> Pull up -#ifndef TWIS_DEFAULT_CONFIG_SDA_PULL -#define TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 #endif -// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2877,77 +2504,103 @@ // <6=> 6 // <7=> 7 -#ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY -#define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 #endif -// TWIS0_ENABLED - Enable TWIS0 instance - - -#ifndef TWIS0_ENABLED -#define TWIS0_ENABLED 0 +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 #endif - -// TWIS1_ENABLED - Enable TWIS1 instance +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef TWIS1_ENABLED -#define TWIS1_ENABLED 0 +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 #endif -// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once +// NRFX_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 -// 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 +#ifndef NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 #endif -// TWIS_NO_SYNC_MODE - Remove support for synchronous mode +// NRFX_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 -// 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 +#ifndef NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 #endif // -// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver //========================================================== -#ifndef TWI_ENABLED -#define TWI_ENABLED 0 +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 #endif -// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency +// NRFX_RTC0_ENABLED - Enable RTC0 instance -// <26738688=> 100k -// <67108864=> 250k -// <104857600=> 400k -#ifndef TWI_DEFAULT_CONFIG_FREQUENCY -#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 #endif -// TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init +// NRFX_RTC1_ENABLED - Enable RTC1 instance -#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT -#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 #endif -// TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit - +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif -#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT -#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 #endif -// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -2957,90 +2610,104 @@ // <6=> 6 // <7=> 7 -#ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY -#define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// TWI0_ENABLED - Enable TWI0 instance +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWI0_ENABLED -#define TWI0_ENABLED 0 +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 #endif -// TWI0_USE_EASY_DMA - Use EasyDMA (if present) +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef TWI0_USE_EASY_DMA -#define TWI0_USE_EASY_DMA 0 +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 #endif -// - -// TWI1_ENABLED - Enable TWI1 instance -//========================================================== -#ifndef TWI1_ENABLED -#define TWI1_ENABLED 0 -#endif -// TWI1_USE_EASY_DMA - Use EasyDMA (if present) +// NRFX_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 TWI1_USE_EASY_DMA -#define TWI1_USE_EASY_DMA 0 +#ifndef NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 #endif -// - -// - -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver -//========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 0 -#endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control +// NRFX_RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. -// <0=> Disabled -// <1=> Enabled +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 +#ifndef NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 #endif -// UART_DEFAULT_CONFIG_PARITY - Parity +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution -// <0=> Excluded -// <14=> Included +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 #endif -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period -// <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=> 1000000 baud +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 #endif -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -3050,63 +2717,87 @@ // <6=> 6 // <7=> 7 -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 #endif -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 #endif -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode +// NRFX_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 UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 +#ifndef NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 #endif -// UART0_ENABLED - Enable UART0 instance -//========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 1 -#endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRFX_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 UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 +#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 #endif // -// UART1_ENABLED - Enable UART1 instance +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver //========================================================== -#ifndef UART1_ENABLED -#define UART1_ENABLED 0 +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 #endif -// UART1_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance -#ifndef UART1_CONFIG_USE_EASY_DMA -#define UART1_CONFIG_USE_EASY_DMA 1 +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 #endif -// - -// +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP -// USBD_ENABLED - nrf_drv_usbd - USB driver -//========================================================== -#ifndef USBD_ENABLED -#define USBD_ENABLED 0 +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 #endif -// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -3116,48 +2807,77 @@ // <6=> 6 // <7=> 7 -#ifndef USBD_CONFIG_IRQ_PRIORITY -#define USBD_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// NRF_DRV_USBD_DMASCHEDULER_MODE - USBD SMA scheduler working scheme +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level -// <0=> Prioritized access -// <1=> Round Robin +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_DRV_USBD_DMASCHEDULER_MODE -#define NRF_DRV_USBD_DMASCHEDULER_MODE 0 +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 #endif -// +// NRFX_SPIM_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 -// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver -//========================================================== -#ifndef WDT_ENABLED -#define WDT_ENABLED 0 +#ifndef NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 #endif -// WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode + +// NRFX_SPIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. -// <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 +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef WDT_CONFIG_BEHAVIOUR -#define WDT_CONFIG_BEHAVIOUR 1 +#ifndef NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 #endif -// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> +// +// -#ifndef WDT_CONFIG_RELOAD_VALUE -#define WDT_CONFIG_RELOAD_VALUE 2000 +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 #endif - -// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -3167,75 +2887,101 @@ // <6=> 6 // <7=> 7 -#ifndef WDT_CONFIG_IRQ_PRIORITY -#define WDT_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> -// -//========================================================== -// nRF_Libraries +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif -//========================================================== -// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher - +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> -#ifndef APP_GPIOTE_ENABLED -#define APP_GPIOTE_ENABLED 0 + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 #endif -// APP_PWM_ENABLED - app_pwm - PWM functionality +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_PWM_ENABLED -#define APP_PWM_ENABLED 0 +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 #endif -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler -//========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 0 -#endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature +// NRFX_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 APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 +#ifndef NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 #endif -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling +// NRFX_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 APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 +#ifndef NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 #endif // -// APP_TIMER_ENABLED - app_timer - Application timer functionality +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver //========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 0 +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 #endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. +// NRFX_SPI0_ENABLED - Enable SPI0 instance -// <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 +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 #endif -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + // <0=> 0 (highest) // <1=> 1 // <2=> 2 @@ -3245,3060 +2991,2841 @@ // <6=> 6 // <7=> 7 -#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY -#define APP_TIMER_CONFIG_IRQ_PRIORITY 7 +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. - -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 #endif - -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 0 +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 #endif -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling +// NRFX_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 APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 +#ifndef NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 #endif -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on +// NRFX_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 -// If option is enabled RTC is kept running even if there is no active timers. -// 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 +#ifndef NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// // -// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support -#ifndef NRF_TWI_MNGR_ENABLED -#define NRF_TWI_MNGR_ENABLED 0 +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 #endif -// APP_UART_ENABLED - app_uart - UART driver -//========================================================== -#ifndef APP_UART_ENABLED -#define APP_UART_ENABLED 0 -#endif -// APP_UART_DRIVER_INSTANCE - UART instance used +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver -// <0=> 0 -#ifndef APP_UART_DRIVER_INSTANCE -#define APP_UART_DRIVER_INSTANCE 0 +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 #endif -// - -// APP_USBD_CLASS_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver -#ifndef APP_USBD_CLASS_AUDIO_ENABLED -#define APP_USBD_CLASS_AUDIO_ENABLED 0 +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 #endif -// APP_USBD_CLASS_CDC_ACM_ENABLED - app_usbd_cdc_acm - USB CDC ACM class +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver -#ifndef APP_USBD_CLASS_CDC_ACM_ENABLED -#define APP_USBD_CLASS_CDC_ACM_ENABLED 0 +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 #endif -// APP_USBD_CLASS_HID_ENABLED - app_usbd_hid - USB HID class +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver -#ifndef APP_USBD_CLASS_HID_ENABLED -#define APP_USBD_CLASS_HID_ENABLED 0 +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 #endif -// APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver -#ifndef APP_USBD_HID_GENERIC_ENABLED -#define APP_USBD_HID_GENERIC_ENABLED 0 +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 #endif -// APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver -#ifndef APP_USBD_HID_KBD_ENABLED -#define APP_USBD_HID_KBD_ENABLED 0 +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 #endif -// APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef APP_USBD_HID_MOUSE_ENABLED -#define APP_USBD_HID_MOUSE_ENABLED 0 +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 #endif -// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class +// NRFX_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 APP_USBD_MSC_ENABLED -#define APP_USBD_MSC_ENABLED 0 +#ifndef NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 #endif -// BUTTON_ENABLED - app_button - buttons handling module +// NRFX_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 BUTTON_ENABLED -#define BUTTON_ENABLED 0 +#ifndef NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 #endif -// CRC16_ENABLED - crc16 - CRC16 calculation routines +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance -#ifndef CRC16_ENABLED -#define CRC16_ENABLED 0 +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 #endif -// CRC32_ENABLED - crc32 - CRC32 calculation routines +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance -#ifndef CRC32_ENABLED -#define CRC32_ENABLED 0 +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 #endif -// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance -#ifndef ECC_ENABLED -#define ECC_ENABLED 0 +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 #endif -// FDS_ENABLED - fds - Flash data storage module -//========================================================== -#ifndef FDS_ENABLED -#define FDS_ENABLED 0 +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 #endif -// Pages - Virtual page settings -// Configure the number of virtual pages to use and their size. -//========================================================== -// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. -// One of the virtual pages is reserved by the system for garbage collection. -// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. -// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter -#ifndef FDS_VIRTUAL_PAGES -#define FDS_VIRTUAL_PAGES 3 +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 #endif -// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit -// Expressed in number of 4-byte words. -// By default, a virtual page is the same size as a physical page. -// 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 +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 #endif -// -//========================================================== +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -// Backend - Backend configuration +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif -// Configure which nrf_fstorage backend is used by FDS to write to flash. +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// FDS_BACKEND - FDS flash backend. +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. -// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. -// <1=> NRF_FSTORAGE_NVMC -// <2=> NRF_FSTORAGE_SD - -#ifndef FDS_BACKEND -#define FDS_BACKEND 2 +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 #endif -// -//========================================================== +// NRFX_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 -// Queue - Queue settings +#ifndef NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif -//========================================================== -// FDS_OP_QUEUE_SIZE - Size of the internal queue. -// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. +// NRFX_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 FDS_OP_QUEUE_SIZE -#define FDS_OP_QUEUE_SIZE 4 +#ifndef NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 #endif -// -//========================================================== - -// CRC - CRC functionality +// -//========================================================== -// FDS_CRC_CHECK_ON_READ - Enable CRC checks. +// -// Save a record's CRC when it is written to flash and check it when the record is opened. -// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. -// Additionally, they will not be garbage collected until they are deleted. +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver //========================================================== -#ifndef FDS_CRC_CHECK_ON_READ -#define FDS_CRC_CHECK_ON_READ 0 +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 #endif -// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance -// Perform a CRC check on newly written records. -// This setting can be used to make sure that the record data was not altered while being written to flash. -// <1=> Enabled -// <0=> Disabled - -#ifndef FDS_CRC_CHECK_ON_WRITE -#define FDS_CRC_CHECK_ON_WRITE 0 +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 #endif -// +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k -// -//========================================================== +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif -// Users - Number of users +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + -//========================================================== -// FDS_MAX_USERS - Maximum number of callbacks that can be registered. -#ifndef FDS_MAX_USERS -#define FDS_MAX_USERS 4 +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 #endif -// -//========================================================== +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -// +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif -// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef HARDFAULT_HANDLER_ENABLED -#define HARDFAULT_HANDLER_ENABLED 0 +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 #endif -// HARDFAULT_HANDLER_GDB_PSP_BACKTRACE - Bypass the GDB problem with multiple stack pointers backtrace +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// There is a known bug in GDB which causes it to incorrectly backtrace the code -// when multiple stack pointers are used (main and process stack pointers). -// This option enables the fix for that problem and allows to see the proper backtrace info. -// It makes it possible to trace the code to the exact point where a HardFault appeared. -// This option requires additional commands and may temporarily switch MSP stack to store data on PSP space. -// This is an optional parameter - enable it while debugging. -// Before a HardFault handler exits, the stack will be reverted to its previous value. - -#ifndef HARDFAULT_HANDLER_GDB_PSP_BACKTRACE -#define HARDFAULT_HANDLER_GDB_PSP_BACKTRACE 1 +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 #endif -// - -// 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 -// HCI_TX_BUF_SIZE - TX buffer size in bytes. -#ifndef HCI_TX_BUF_SIZE -#define HCI_TX_BUF_SIZE 600 -#endif +// NRFX_TWIM_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 -// HCI_RX_BUF_SIZE - RX buffer size in bytes. -#ifndef HCI_RX_BUF_SIZE -#define HCI_RX_BUF_SIZE 600 +#ifndef NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 #endif -// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. -#ifndef HCI_RX_BUF_QUEUE_SIZE -#define HCI_RX_BUF_QUEUE_SIZE 4 +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 #endif // -// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver //========================================================== -#ifndef HCI_SLIP_ENABLED -#define HCI_SLIP_ENABLED 0 +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 #endif -// HCI_UART_BAUDRATE - Default Baudrate +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance -// <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=> 1000000 baud -#ifndef HCI_UART_BAUDRATE -#define HCI_UART_BAUDRATE 30801920 +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 #endif -// HCI_UART_FLOW_CONTROL - Hardware Flow Control +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once -// <0=> Disabled -// <1=> Enabled -#ifndef HCI_UART_FLOW_CONTROL -#define HCI_UART_FLOW_CONTROL 0 -#endif +// 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. -// HCI_UART_RX_PIN - UART RX pin -#ifndef HCI_UART_RX_PIN -#define HCI_UART_RX_PIN 8 +#ifndef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 #endif -// HCI_UART_TX_PIN - UART TX pin -#ifndef HCI_UART_TX_PIN -#define HCI_UART_TX_PIN 6 +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 #endif -// HCI_UART_RTS_PIN - UART RTS pin -#ifndef HCI_UART_RTS_PIN -#define HCI_UART_RTS_PIN 5 +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 #endif -// HCI_UART_CTS_PIN - UART CTS pin -#ifndef HCI_UART_CTS_PIN -#define HCI_UART_CTS_PIN 7 +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 #endif -// +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up -// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport -//========================================================== -#ifndef HCI_TRANSPORT_ENABLED -#define HCI_TRANSPORT_ENABLED 0 -#endif -// 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 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 #endif -// - -// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up -#ifndef LED_SOFTBLINK_ENABLED -#define LED_SOFTBLINK_ENABLED 0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 #endif -// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef LOW_POWER_PWM_ENABLED -#define LOW_POWER_PWM_ENABLED 0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef MEM_MANAGER_ENABLED -#define MEM_MANAGER_ENABLED 0 -#endif -// 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 +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 #endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. -// 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 +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 #endif -// MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> - +// NRFX_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 MEMORY_MANAGER_MEDIUM_BLOCK_COUNT -#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 +#ifndef NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 #endif -// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. -// Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized. +// NRFX_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 MEMORY_MANAGER_MEDIUM_BLOCK_SIZE -#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 +#ifndef NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 #endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + -// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. -// 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 +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 #endif -// MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block. <0-255> - +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k -#ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT -#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0 +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 #endif -// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. -// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + -#ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE -#define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 1320 +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 #endif -// MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block. <0-255> - +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT -#define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 0 +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. -// 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 +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 #endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block. <0-255> +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif +// NRFX_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 MEMORY_MANAGER_XSMALL_BLOCK_COUNT -#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0 +#ifndef NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 #endif -// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. -// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. +// NRFX_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 MEMORY_MANAGER_XSMALL_BLOCK_SIZE -#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64 +#ifndef NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 #endif -// 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 +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 0 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 #endif -// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. -// Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized. +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled -#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE -#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32 +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 #endif -// MEM_MANAGER_DISABLE_API_PARAM_CHECK - Disable API parameter checks in the module. +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity +// <0=> Excluded +// <14=> Included -#ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK -#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 #endif -// +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 0 -#endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 #endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> - - -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 #endif - -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 #endif -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. +// NRFX_UARTE_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 NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#ifndef NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 #endif -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. +// NRFX_UARTE_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 NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#ifndef NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 #endif // // -// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver //========================================================== -#ifndef NRF_CSENSE_ENABLED -#define NRF_CSENSE_ENABLED 0 +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 0 #endif -// 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 +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 #endif -// 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 +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled -// 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 +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 #endif -// 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 +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included -// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. -#ifndef NRF_CSENSE_MAX_VALUE -#define NRF_CSENSE_MAX_VALUE 1000 +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 #endif -// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. -// This is used when capacitive sensor does not use COMP. +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud -#ifndef NRF_CSENSE_OUTPUT_PIN -#define NRF_CSENSE_OUTPUT_PIN 26 +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 #endif -// +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module -//========================================================== -#ifndef NRF_DRV_CSENSE_ENABLED -#define NRF_DRV_CSENSE_ENABLED 0 +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// USE_COMP - Use the comparator to implement the capacitive sensor driver. -// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef USE_COMP -#define USE_COMP 0 +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 #endif -// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). -#ifndef TIMER0_FOR_CSENSE -#define TIMER0_FOR_CSENSE 1 +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 #endif -// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). -#ifndef TIMER1_FOR_CSENSE -#define TIMER1_FOR_CSENSE 2 +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 #endif -// MEASUREMENT_PERIOD - Single measurement period. -// Time of a single measurement can be calculated as -// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). -// I_SOURCE, VUP, and VDOWN are values used to initialize COMP and C is the capacitance of the used pad. +// NRFX_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 MEASUREMENT_PERIOD -#define MEASUREMENT_PERIOD 20 +#ifndef NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 #endif // // -// NRF_FPRINTF_ENABLED - nrf_fprintf - fprintf function. +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 0 +#ifndef NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 #endif -// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library -//========================================================== -#ifndef NRF_FSTORAGE_ENABLED -#define NRF_FSTORAGE_ENABLED 0 -#endif -// nrf_fstorage_sd - Implementation using the SoftDevice. +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> -// Configuration options for the fstorage implementation using the SoftDevice. -//========================================================== -// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations. -// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. -#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE -#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 #endif -// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy. -// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. -// The SoftDevice might fail to schedule flash access due to high BLE activity. +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling -#ifndef NRF_FSTORAGE_SD_MAX_RETRIES -#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 #endif -// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation. -// This value must be a multiple of four. -// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. -// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. -// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 -#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE -#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 #endif -// +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module +// NRFX_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 NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 0 +#ifndef NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 #endif -// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module -//========================================================== -#ifndef NRF_PWR_MGMT_ENABLED -#define NRF_PWR_MGMT_ENABLED 0 +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 #endif -// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. -// Selected pin will be set when CPU is in sleep mode. +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer //========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED -#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 0 #endif -// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number +// CLOCK_CONFIG_LF_SRC - LF Clock Source -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing -#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN -#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 #endif -// - -// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source -// Module will trace percentage of CPU usage in one second intervals. - -#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED -#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 #endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 -#endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). -// Shutdown procedure will begin no earlier than after this number of seconds. +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +// 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 6 #endif // -// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. - - -#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED -#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 #endif - -// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. +// PDM_CONFIG_MODE - Mode +// <0=> Stereo +// <1=> Mono -#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY -#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 #endif -// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. +// PDM_CONFIG_EDGE - Edge +// <0=> Left falling +// <1=> Left rising -#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER -#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 -#endif - -// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. -// The number of stages of the shutdown process. - -#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT -#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 #endif -// - -// NRF_QUEUE_ENABLED - nrf_queue - Queue module +// PDM_CONFIG_CLOCK_FREQ - Clock frequency +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k -#ifndef NRF_QUEUE_ENABLED -#define NRF_QUEUE_ENABLED 0 +#ifndef PDM_CONFIG_CLOCK_FREQ +#define PDM_CONFIG_CLOCK_FREQ 138412032 #endif -// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority -#ifndef NRF_SECTION_ITER_ENABLED -#define NRF_SECTION_ITER_ENABLED 0 -#endif - -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. - +// 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 NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 0 +#ifndef PDM_CONFIG_IRQ_PRIORITY +#define PDM_CONFIG_IRQ_PRIORITY 6 #endif -// SLIP_ENABLED - slip - SLIP encoding and decoding - - -#ifndef SLIP_ENABLED -#define SLIP_ENABLED 0 -#endif +// -// TASK_MANAGER_ENABLED - task_manager - Task manager. +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer //========================================================== -#ifndef TASK_MANAGER_ENABLED -#define TASK_MANAGER_ENABLED 0 +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 #endif -// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority -#ifndef TASK_MANAGER_CLI_CMDS -#define TASK_MANAGER_CLI_CMDS 1 -#endif - -// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created -#ifndef TASK_MANAGER_CONFIG_MAX_TASKS -#define TASK_MANAGER_CONFIG_MAX_TASKS 2 -#endif +// 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 -// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) -#ifndef TASK_MANAGER_CONFIG_STACK_SIZE -#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#ifndef POWER_CONFIG_IRQ_PRIORITY +#define POWER_CONFIG_IRQ_PRIORITY 6 #endif -// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator -#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED -#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +// 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 -// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator -// <0=> Disabled -// <4=> 32 bytes -// <5=> 64 bytes -// <6=> 128 bytes -// <7=> 256 bytes -// <8=> 512 bytes -#ifndef TASK_MANAGER_CONFIG_STACK_GUARD -#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +// 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 // -// nrf_cli - Command line interface. - -//========================================================== -// NRF_CLI_ENABLED - Enable/disable CLI module. +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer -#ifndef NRF_CLI_ENABLED -#define NRF_CLI_ENABLED 0 +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 #endif -// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to command handler. -#ifndef NRF_CLI_ARGC_MAX -#define NRF_CLI_ARGC_MAX 12 +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 #endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> -// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI build in commands. - -#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED -#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 #endif -// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for single command. -#ifndef NRF_CLI_CMD_BUFF_SIZE -#define NRF_CLI_CMD_BUFF_SIZE 128 -#endif +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> -// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. -#ifndef NRF_CLI_PRINTF_BUFF_SIZE -#define NRF_CLI_PRINTF_BUFF_SIZE 23 -#endif -// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. -//========================================================== -#ifndef NRF_CLI_HISTORY_ENABLED -#define NRF_CLI_HISTORY_ENABLED 1 -#endif -// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history -#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE -#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 #endif -// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects -#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT -#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 #endif -// +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> -// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. - -#ifndef NRF_CLI_VT100_COLORS_ENABLED -#define NRF_CLI_VT100_COLORS_ENABLED 1 +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 #endif -// NRF_CLI_LOG_BACKEND - Enable logger backend interface. +// 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 kHz -#ifndef NRF_CLI_LOG_BACKEND -#define NRF_CLI_LOG_BACKEND 1 +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 #endif -// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager +// PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode +// <0=> Up +// <1=> Up and Down -#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED -#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#ifndef PWM_DEFAULT_CONFIG_COUNT_MODE +#define PWM_DEFAULT_CONFIG_COUNT_MODE 0 #endif -// -//========================================================== - -// nrf_cli_rtt - RTT command line interface transport. +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif -//========================================================== -// NRF_CLI_RTT_ENABLED - Enable/disable CLI RTT module. +// PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform -#ifndef NRF_CLI_RTT_ENABLED -#define NRF_CLI_RTT_ENABLED 0 +#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE +#define PWM_DEFAULT_CONFIG_LOAD_MODE 0 #endif -// NRF_CLI_RTT_TERMINAL_ID - RTT terminal ID for CLI. -#ifndef NRF_CLI_RTT_TERMINAL_ID -#define NRF_CLI_RTT_TERMINAL_ID 0 +// 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 -// -//========================================================== +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + -// -//========================================================== +// 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 -// nRF_Log +#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif -//========================================================== -// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend -//========================================================== -#ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 0 +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 #endif -// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. -#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 #endif // -// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer //========================================================== -#ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 0 +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 #endif -// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin -#ifndef NRF_LOG_BACKEND_UART_TX_PIN -#define NRF_LOG_BACKEND_UART_TX_PIN 6 +// 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 -// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate +// QDEC_CONFIG_SAMPLEPER - Sample period -// <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=> 1000000 baud +// <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 NRF_LOG_BACKEND_UART_BAUDRATE -#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#ifndef QDEC_CONFIG_SAMPLEPER +#define QDEC_CONFIG_SAMPLEPER 7 #endif -// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. -// Size of the buffer is a trade-off between RAM usage and processing. -// if buffer is smaller then strings will often be fragmented. -// It is recommended to use size which will fit typical log and only the -// longer one will be fragmented. +// QDEC_CONFIG_PIO_A - A pin <0-31> + -#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE -#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 #endif -// +// QDEC_CONFIG_PIO_B - B pin <0-31> -// nrf_log - Logging -//========================================================== -// NRF_LOG_ENABLED - Logging module for nRF5 SDK -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 0 +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 #endif -// 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 + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 #endif -// 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 +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 #endif -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_LEDPOL - LED polarity -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> Active low +// <1=> Active high -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 0 +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 #endif -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. +// QDEC_CONFIG_DBFEN - Debouncing enable -// <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 +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 #endif -// - -// NRF_LOG_DEFAULT_LEVEL - Default Severity level +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 3 +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 #endif -// NRF_LOG_DEFERRED - Enable deffered logger. +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority -// Log data is buffered and can be processed in idle. +// 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 NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#ifndef QDEC_CONFIG_IRQ_PRIORITY +#define QDEC_CONFIG_IRQ_PRIORITY 6 #endif -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). - - -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 +// -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 #endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 #endif -// NRF_LOG_USES_TIMESTAMP - Enable timestamping +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO -// Function for getting the timestamp is provided by the user +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 #endif -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. +// QSPI_CONFIG_ADDRMODE - Addressing mode. +// <0=> 24bit +// <1=> 32bit -#ifndef NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 1 +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 #endif -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. +// QSPI_CONFIG_MODE - SPI mode. +// <0=> Mode 0 +// <1=> Mode 1 -#ifndef NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 1 +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 #endif -// Log message pool - Configuration of log message pool +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 -//========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED #endif -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif -#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED #endif -// -//========================================================== +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif -// +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif -// nrf_log module configuration +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif -//========================================================== -// nrf_log in nRF_Core +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + +// 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 QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer //========================================================== -// NRF_MPU_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_CONFIG_LOG_ENABLED -#define NRF_MPU_CONFIG_LOG_ENABLED 0 +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 #endif -// NRF_MPU_CONFIG_LOG_LEVEL - Default Severity level +// RNG_CONFIG_ERROR_CORRECTION - Error correction -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_MPU_CONFIG_LOG_LEVEL -#define NRF_MPU_CONFIG_LOG_LEVEL 3 +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 #endif -// NRF_MPU_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 NRF_MPU_CONFIG_INFO_COLOR -#define NRF_MPU_CONFIG_INFO_COLOR 0 +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 #endif -// NRF_MPU_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_MPU_CONFIG_DEBUG_COLOR -#define NRF_MPU_CONFIG_DEBUG_COLOR 0 +// 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 6 #endif // -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer //========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 #endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 #endif -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 #endif -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 -#endif -// +// 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 -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// RTC0_ENABLED - Enable RTC0 instance -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. +// RTC1_ENABLED - Enable RTC1 instance -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 #endif -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// RTC2_ENABLED - Enable RTC2 instance -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 #endif // -// +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer //========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 #endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// SAADC_CONFIG_OVERSAMPLE - Sample period -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 +#ifndef SAADC_CONFIG_OVERSAMPLE +#define SAADC_CONFIG_OVERSAMPLE 0 #endif -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_LP_MODE - Enabling low power mode -// <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 +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 #endif -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority -// <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 +// 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 6 #endif // -// COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer //========================================================== -#ifndef COMMON_CONFIG_LOG_ENABLED -#define COMMON_CONFIG_LOG_ENABLED 0 +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 #endif -// COMMON_CONFIG_LOG_LEVEL - Default Severity level +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef COMMON_CONFIG_LOG_LEVEL -#define COMMON_CONFIG_LOG_LEVEL 3 +// 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 6 #endif -// COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. +// SPIS_DEFAULT_MODE - Mode -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> MODE_0 +// <1=> MODE_1 +// <2=> MODE_2 +// <3=> MODE_3 -#ifndef COMMON_CONFIG_INFO_COLOR -#define COMMON_CONFIG_INFO_COLOR 0 +#ifndef SPIS_DEFAULT_MODE +#define SPIS_DEFAULT_MODE 0 #endif -// COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> MSB first +// <1=> LSB first -#ifndef COMMON_CONFIG_DEBUG_COLOR -#define COMMON_CONFIG_DEBUG_COLOR 0 +#ifndef SPIS_DEFAULT_BIT_ORDER +#define SPIS_DEFAULT_BIT_ORDER 0 #endif -// +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 -#endif -// 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 +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 #endif -// 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 +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 #endif -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPIS0_ENABLED - Enable SPIS0 instance -// <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 +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 #endif // -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer //========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 #endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 +// 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 6 #endif -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 #endif -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA -// <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 +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 #endif // -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer //========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 #endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <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 I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 +#ifndef TIMER_DEFAULT_CONFIG_FREQUENCY +#define TIMER_DEFAULT_CONFIG_FREQUENCY 0 #endif -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> Timer +// <1=> Counter -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 #endif -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 +#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 #endif -// - -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 -#endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 +// 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 6 #endif -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER0_ENABLED - Enable TIMER0 instance -// <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 +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 #endif -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER1_ENABLED - Enable TIMER1 instance -// <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 +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 #endif -// - -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 -#endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level +// TIMER2_ENABLED - Enable TIMER2 instance -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 #endif -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TIMER3_ENABLED - Enable TIMER3 instance -// <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 +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 #endif -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TIMER4_ENABLED - Enable TIMER4 instance -// <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 +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 #endif // -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer //========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 #endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level +// TWIS0_ENABLED - Enable TWIS0 instance -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 #endif -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS1_ENABLED - Enable TWIS1 instance -// <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 +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 #endif -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once -// <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 +// 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 -// +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 +// 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 -// PWM_CONFIG_LOG_LEVEL - Default Severity level + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 +#ifndef TWIS_DEFAULT_CONFIG_SCL_PULL +#define TWIS_DEFAULT_CONFIG_SCL_PULL 0 #endif -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 +#ifndef TWIS_DEFAULT_CONFIG_SDA_PULL +#define TWIS_DEFAULT_CONFIG_SDA_PULL 0 #endif -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <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 +// 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 6 #endif // -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer //========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 #endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 #endif -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init -// <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 +#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT +#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 #endif -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit -// <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 +#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 #endif -// - -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 -#endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 -#endif -// 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 +// 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_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 +#ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 #endif -// 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 +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 #endif - -// RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED - Enables logging of random numbers. +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) -#ifndef RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED -#define RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED 0 +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 #endif // -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer //========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 +#ifndef UART_ENABLED +#define UART_ENABLED 0 #endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <0=> Disabled +// <1=> Enabled -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 #endif -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_DEFAULT_CONFIG_PARITY - Parity -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> Excluded +// <14=> Included -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 #endif -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <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=> 1000000 baud -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 #endif -// +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 +// 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 6 #endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 #endif -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode -// <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 +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 #endif -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 0 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA -// <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 +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 #endif // -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component //========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 #endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 +// 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 6 #endif -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <0=> Prioritized access +// <1=> Round Robin -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 #endif -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers -// <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 +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 #endif // -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer //========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 #endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level +// WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <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 SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 3 -#endif +#ifndef WDT_CONFIG_BEHAVIOUR +#define WDT_CONFIG_BEHAVIOUR 1 +#endif -// 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 +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 #endif -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority -// <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 +// 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 6 #endif // -// SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// nrfx_i2s - I2S peripheral driver + +//========================================================== +// //========================================================== -#ifndef SWI_CONFIG_LOG_ENABLED -#define SWI_CONFIG_LOG_ENABLED 0 -#endif -// 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 +// nrfx_lpcomp - LPCOMP peripheral driver -// 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 +// nrfx_qspi - QSPI peripheral driver -// 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 +// nrfx_usbd - USBD peripheral driver -// +//========================================================== +// +//========================================================== -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +// //========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 -#endif -// 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 +// nRF_Drivers_External -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module -// <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 +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 #endif -// 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 +// +//========================================================== -// +// nRF_Libraries -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 #endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// APP_PWM_ENABLED - app_pwm - PWM functionality -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 #endif -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 0 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature -// <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 +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 #endif -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling -// <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 +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 #endif // -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI //========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 #endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level +// APP_SDCARD_SPI_INSTANCE - SPI instance used -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// <0=> 0 +// <1=> 1 +// <2=> 2 -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 #endif -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_SDCARD_FREQ_INIT - SPI frequency -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 #endif -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_SDCARD_FREQ_DATA - SPI frequency -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 #endif // -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_TIMER_ENABLED - app_timer - Application timer functionality //========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 0 #endif -// UART_CONFIG_LOG_LEVEL - Default Severity level +// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 +// <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 1 #endif -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority -// <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 +// 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 6 #endif -// 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 +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 #endif -// +// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler + -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module -//========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 +#ifndef APP_TIMER_CONFIG_USE_SCHEDULER +#define APP_TIMER_CONFIG_USE_SCHEDULER 0 #endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 +// If option is enabled RTC is kept running even if there is no active timers. +// 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 -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 #endif -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 #endif +// +//========================================================== + // -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library //========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 #endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 #endif -// 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 +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 #endif -// 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 +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 + +// Major 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 -// +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> -// -//========================================================== -// nrf_log in nRF_Libraries +// Minor device version, will be converted automatically to BCD notation. Use just decimal values. -//========================================================== -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_DEVICE_VER_MINOR +#define APP_USBD_DEVICE_VER_MINOR 0 #endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 #endif -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 #endif -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 #endif -// +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. //========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 #endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 #endif -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 #endif -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 #endif -// +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> -// MEM_MANAGER_ENABLE_LOGS - Enable debug trace in the module. - -#ifndef MEM_MANAGER_ENABLE_LOGS -#define MEM_MANAGER_ENABLE_LOGS 0 -#endif +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 #endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 #endif -// NRF_BALLOC_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 +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) #endif -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") #endif // -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. //========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 #endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 #endif -// NRF_CLI_BLE_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 +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") #endif -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") #endif // -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. //========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 #endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 #endif -// NRF_CLI_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 +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") #endif -// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) #endif // -// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class //========================================================== -#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED -#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 #endif -// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> -#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL -#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 -#endif -// NRF_MEMOBJ_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 +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. -#ifndef NRF_MEMOBJ_CONFIG_INFO_COLOR -#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 #endif -// NRF_MEMOBJ_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 +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> -#ifndef NRF_MEMOBJ_CONFIG_DEBUG_COLOR -#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 #endif // -// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED -#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 -#endif -// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level +// APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL -#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#ifndef APP_USBD_HID_GENERIC_ENABLED +#define APP_USBD_HID_GENERIC_ENABLED 0 #endif -// NRF_PWR_MGMT_CONFIG_INFO_COLOR - ANSI escape code prefix. +// APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR -#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#ifndef APP_USBD_HID_KBD_ENABLED +#define APP_USBD_HID_KBD_ENABLED 0 #endif -// NRF_PWR_MGMT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR -#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#ifndef APP_USBD_HID_MOUSE_ENABLED +#define APP_USBD_HID_MOUSE_ENABLED 0 #endif -// +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + -// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. -//========================================================== -#ifndef NRF_SDH_ANT_LOG_ENABLED -#define NRF_SDH_ANT_LOG_ENABLED 1 +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 #endif -// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// CRC16_ENABLED - crc16 - CRC16 calculation routines -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_SDH_ANT_LOG_LEVEL -#define NRF_SDH_ANT_LOG_LEVEL 3 +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 #endif -// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. +// CRC32_ENABLED - crc32 - CRC32 calculation routines -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_SDH_ANT_INFO_COLOR -#define NRF_SDH_ANT_INFO_COLOR 0 +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 #endif -// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_SDH_ANT_DEBUG_COLOR -#define NRF_SDH_ANT_DEBUG_COLOR 0 +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 #endif -// - -// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +// FDS_ENABLED - fds - Flash data storage module //========================================================== -#ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 #endif -// NRF_SDH_BLE_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug +// Pages - Virtual page settings -#ifndef NRF_SDH_BLE_LOG_LEVEL -#define NRF_SDH_BLE_LOG_LEVEL 3 +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 #endif -// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_SDH_BLE_INFO_COLOR -#define NRF_SDH_BLE_INFO_COLOR 0 +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 -// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. -#ifndef NRF_SDH_BLE_DEBUG_COLOR -#define NRF_SDH_BLE_DEBUG_COLOR 0 +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 #endif -// +// +//========================================================== -// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. //========================================================== -#ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 -#endif -// NRF_SDH_LOG_LEVEL - Default Severity level +// FDS_BACKEND - FDS flash backend. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_SDH_LOG_LEVEL -#define NRF_SDH_LOG_LEVEL 3 +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 #endif -// NRF_SDH_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 NRF_SDH_INFO_COLOR -#define NRF_SDH_INFO_COLOR 0 -#endif +// Queue - Queue settings -// NRF_SDH_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. -#ifndef NRF_SDH_DEBUG_COLOR -#define NRF_SDH_DEBUG_COLOR 0 +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 #endif -// - -// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +// //========================================================== -#ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 -#endif -// NRF_SDH_SOC_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NRF_SDH_SOC_LOG_LEVEL -#define NRF_SDH_SOC_LOG_LEVEL 3 -#endif +// CRC - CRC functionality -// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. -#ifndef NRF_SDH_SOC_INFO_COLOR -#define NRF_SDH_SOC_INFO_COLOR 0 +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 #endif - -// NRF_SDH_SOC_DEBUG_COLOR - ANSI escape code prefix. +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef NRF_SDH_SOC_DEBUG_COLOR -#define NRF_SDH_SOC_DEBUG_COLOR 0 +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 #endif // @@ -6306,353 +5833,242 @@ // //========================================================== -// -//========================================================== +// Users - Number of users -// //========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif // //========================================================== -// nRF_NFC +// -//========================================================== -// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - Encoding the advertising data and/or scan response data which is specific for OOB pairing -//========================================================== -#ifndef NFC_BLE_OOB_ADVDATA_ENABLED -#define NFC_BLE_OOB_ADVDATA_ENABLED 0 -#endif -// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release -// <1=> Enabled -// <0=> Disabled -#ifndef ADVANCED_ADVDATA_SUPPORT -#define ADVANCED_ADVDATA_SUPPORT 0 +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 #endif -// - -// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +// HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI //========================================================== -#ifndef NFC_BLE_PAIR_LIB_ENABLED -#define NFC_BLE_PAIR_LIB_ENABLED 0 +#ifndef HCI_MEM_POOL_ENABLED +#define HCI_MEM_POOL_ENABLED 0 #endif -// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED -#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 #endif -// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL -#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 #endif -// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_INFO_COLOR -#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 -#endif - -// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_DEBUG_COLOR -#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 #endif // -// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. - -//========================================================== -// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. - -// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI //========================================================== -#ifndef BLE_NFC_SEC_PARAM_BOND -#define BLE_NFC_SEC_PARAM_BOND 1 +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 #endif -// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. +// 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=> 1000000 baud -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 #endif -// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. +// HCI_UART_FLOW_CONTROL - Hardware Flow Control +// <0=> Disabled +// <1=> Enabled -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 #endif -// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. - +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 31 +#endif -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 31 #endif -// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. - +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 31 +#endif -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 31 #endif -// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. - +// -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 -// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 #endif -// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 #endif -// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. - - -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 #endif +// MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block. <0-255> -// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. - -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT +#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1 #endif -// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. - +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized. -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE +#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32 #endif -// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. - +// MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> + -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT +#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 #endif -// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. - +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized. -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE +#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 #endif -// +// MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block. <0-255> -// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. - -// <7=> 7 -// <8=> 8 -// <9=> 9 -// <10=> 10 -// <11=> 11 -// <12=> 12 -// <13=> 13 -// <14=> 14 -// <15=> 15 -// <16=> 16 -#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE -#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT +#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0 #endif -// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. - -// <7=> 7 -// <8=> 8 -// <9=> 9 -// <10=> 10 -// <11=> 11 -// <12=> 12 -// <13=> 13 -// <14=> 14 -// <15=> 15 -// <16=> 16 +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized. -#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE -#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE +#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 256 #endif -// -//========================================================== +// MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block. <0-255> -// -// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module -//========================================================== -#ifndef NFC_NDEF_MSG_ENABLED -#define NFC_NDEF_MSG_ENABLED 0 +#ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT +#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0 #endif -// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type - -// <2=> Type 2 Tag -// <4=> Type 4 Tag -#ifndef NFC_NDEF_MSG_TAG_TYPE -#define NFC_NDEF_MSG_TAG_TYPE 2 +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 -// +// MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block. <0-255> -// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module -//========================================================== -#ifndef NFC_NDEF_MSG_PARSER_ENABLED -#define NFC_NDEF_MSG_PARSER_ENABLED 0 -#endif -// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED -#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 -#endif -// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL -#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 +#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT +#define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 0 #endif -// NFC_NDEF_MSG_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized. -#ifndef NFC_NDEF_MSG_PARSER_INFO_COLOR -#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 +#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE +#define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 3444 #endif -// - -// +// MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block. <0-255> -// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module -//========================================================== -#ifndef NFC_NDEF_RECORD_PARSER_ENABLED -#define NFC_NDEF_RECORD_PARSER_ENABLED 0 -#endif -// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED -#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 -#endif -// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL -#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#ifndef MEMORY_MANAGER_XSMALL_BLOCK_COUNT +#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0 #endif -// NFC_NDEF_RECORD_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. -#ifndef NFC_NDEF_RECORD_PARSER_INFO_COLOR -#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 +#ifndef MEMORY_MANAGER_XSMALL_BLOCK_SIZE +#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64 #endif -// +// MEMORY_MANAGER_XXSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra small' block. <0-255> -// -// NFC_T2T_HAL_ENABLED - nfc_t2t_hal - Hardware Abstraction Layer for NFC library. -//========================================================== -#ifndef NFC_T2T_HAL_ENABLED -#define NFC_T2T_HAL_ENABLED 0 +#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_COUNT +#define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 0 #endif -// NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// 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 +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized. -#ifndef NFCT_CONFIG_IRQ_PRIORITY -#define NFCT_CONFIG_IRQ_PRIORITY 7 +#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE +#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32 #endif -// HAL_NFC_CONFIG_LOG_ENABLED - Enables logging in the module. +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -#ifndef HAL_NFC_CONFIG_LOG_ENABLED -#define HAL_NFC_CONFIG_LOG_ENABLED 0 +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 #endif -// HAL_NFC_CONFIG_LOG_LEVEL - Default Severity level +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error @@ -6660,11 +6076,11 @@ // <3=> Info // <4=> Debug -#ifndef HAL_NFC_CONFIG_LOG_LEVEL -#define HAL_NFC_CONFIG_LOG_LEVEL 3 +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 #endif -// HAL_NFC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// MEM_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -6676,11 +6092,11 @@ // <7=> Cyan // <8=> White -#ifndef HAL_NFC_CONFIG_INFO_COLOR -#define HAL_NFC_CONFIG_INFO_COLOR 0 +#ifndef MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 #endif -// HAL_NFC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// MEM_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black @@ -6692,230 +6108,235 @@ // <7=> Cyan // <8=> White -#ifndef HAL_NFC_CONFIG_DEBUG_COLOR -#define HAL_NFC_CONFIG_DEBUG_COLOR 0 +#ifndef MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 #endif -// HAL_NFC_CONFIG_LOG_LEVEL - Default Severity level +// + +// MEM_MANAGER_DISABLE_API_PARAM_CHECK - Disable API parameter checks in the module. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef HAL_NFC_CONFIG_LOG_LEVEL -#define HAL_NFC_CONFIG_LOG_LEVEL 3 +#ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK +#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 #endif -// HAL_NFC_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 HAL_NFC_CONFIG_INFO_COLOR -#define HAL_NFC_CONFIG_INFO_COLOR 0 +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 #endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> -// HAL_NFC_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 HAL_NFC_CONFIG_DEBUG_COLOR -#define HAL_NFC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 #endif -// +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> -// HAL_NFC_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. -//========================================================== -#ifndef HAL_NFC_CONFIG_DEBUG_PIN_ENABLED -#define HAL_NFC_CONFIG_DEBUG_PIN_ENABLED 0 + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 #endif -// HAL_NFC_HCLOCK_ON_DEBUG_PIN - Pin number + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_HCLOCK_ON_DEBUG_PIN -#define HAL_NFC_HCLOCK_ON_DEBUG_PIN 11 +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 #endif -// HAL_NFC_HCLOCK_OFF_DEBUG_PIN - Pin number +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_HCLOCK_OFF_DEBUG_PIN -#define HAL_NFC_HCLOCK_OFF_DEBUG_PIN 12 +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 #endif -// HAL_NFC_NFC_EVENT_DEBUG_PIN - Pin number +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_NFC_EVENT_DEBUG_PIN -#define HAL_NFC_NFC_EVENT_DEBUG_PIN 24 +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 0 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 0 #endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. -// HAL_NFC_DETECT_EVENT_DEBUG_PIN - Pin number +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number // <0=> 0 (P0.0) // <1=> 1 (P0.1) @@ -6949,1219 +6370,3307 @@ // <29=> 29 (P0.29) // <30=> 30 (P0.30) // <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) // <4294967295=> Not connected -#ifndef HAL_NFC_DETECT_EVENT_DEBUG_PIN -#define HAL_NFC_DETECT_EVENT_DEBUG_PIN 25 +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 #endif -// HAL_NFC_TIMER4_EVENT_DEBUG_PIN - Pin number +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_TIMER4_EVENT_DEBUG_PIN -#define HAL_NFC_TIMER4_EVENT_DEBUG_PIN 28 +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 #endif -// HAL_NFC_HCLOCK_ON_DEBUG_PIN - Pin number - -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. -#ifndef HAL_NFC_HCLOCK_ON_DEBUG_PIN -#define HAL_NFC_HCLOCK_ON_DEBUG_PIN 31 +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 #endif -// HAL_NFC_HCLOCK_OFF_DEBUG_PIN - Pin number +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_HCLOCK_OFF_DEBUG_PIN -#define HAL_NFC_HCLOCK_OFF_DEBUG_PIN 31 +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 #endif -// HAL_NFC_NFC_EVENT_DEBUG_PIN - Pin number +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_NFC_EVENT_DEBUG_PIN -#define HAL_NFC_NFC_EVENT_DEBUG_PIN 31 +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 #endif -// HAL_NFC_DETECT_EVENT_DEBUG_PIN - Pin number +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_DETECT_EVENT_DEBUG_PIN -#define HAL_NFC_DETECT_EVENT_DEBUG_PIN 31 +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 #endif -// HAL_NFC_TIMER4_EVENT_DEBUG_PIN - Pin number - -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. -#ifndef HAL_NFC_TIMER4_EVENT_DEBUG_PIN -#define HAL_NFC_TIMER4_EVENT_DEBUG_PIN 31 +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 #endif // -// - -// NFC_T4T_HAL_ENABLED - nfc_t4t_hal - Hardware Abstraction Layer for NFC library. +// NRF_QUEUE_ENABLED - nrf_queue - Queue module //========================================================== -#ifndef NFC_T4T_HAL_ENABLED -#define NFC_T4T_HAL_ENABLED 0 +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 #endif -// NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module -// 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 NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// -#ifndef NFCT_CONFIG_IRQ_PRIORITY -#define NFCT_CONFIG_IRQ_PRIORITY 7 +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 #endif -// HAL_NFC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef HAL_NFC_CONFIG_LOG_ENABLED -#define HAL_NFC_CONFIG_LOG_ENABLED 0 +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 #endif -// HAL_NFC_CONFIG_LOG_LEVEL - Default Severity level + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef HAL_NFC_CONFIG_LOG_LEVEL -#define HAL_NFC_CONFIG_LOG_LEVEL 3 +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 #endif -// HAL_NFC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef HAL_NFC_CONFIG_INFO_COLOR -#define HAL_NFC_CONFIG_INFO_COLOR 0 +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 #endif -// HAL_NFC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef HAL_NFC_CONFIG_DEBUG_COLOR -#define HAL_NFC_CONFIG_DEBUG_COLOR 0 +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 #endif -// HAL_NFC_CONFIG_LOG_LEVEL - Default Severity level +// SLIP_ENABLED - slip - SLIP encoding and decoding -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug -#ifndef HAL_NFC_CONFIG_LOG_LEVEL -#define HAL_NFC_CONFIG_LOG_LEVEL 3 +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 #endif -// HAL_NFC_CONFIG_INFO_COLOR - ANSI escape code prefix. +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef HAL_NFC_CONFIG_INFO_COLOR -#define HAL_NFC_CONFIG_INFO_COLOR 0 +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 #endif -// HAL_NFC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White -#ifndef HAL_NFC_CONFIG_DEBUG_COLOR -#define HAL_NFC_CONFIG_DEBUG_COLOR 0 +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 #endif // -// HAL_NFC_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. +// app_button - buttons handling module + //========================================================== -#ifndef HAL_NFC_CONFIG_DEBUG_PIN_ENABLED -#define HAL_NFC_CONFIG_DEBUG_PIN_ENABLED 0 +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 #endif -// HAL_NFC_HCLOCK_ON_DEBUG_PIN - Pin number + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_HCLOCK_ON_DEBUG_PIN -#define HAL_NFC_HCLOCK_ON_DEBUG_PIN 31 +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 #endif -// HAL_NFC_HCLOCK_OFF_DEBUG_PIN - Pin number +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_HCLOCK_OFF_DEBUG_PIN -#define HAL_NFC_HCLOCK_OFF_DEBUG_PIN 31 +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 #endif -// HAL_NFC_NFC_EVENT_DEBUG_PIN - Pin number +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_NFC_EVENT_DEBUG_PIN -#define HAL_NFC_NFC_EVENT_DEBUG_PIN 31 +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 #endif -// HAL_NFC_DETECT_EVENT_DEBUG_PIN - Pin number +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_DETECT_EVENT_DEBUG_PIN -#define HAL_NFC_DETECT_EVENT_DEBUG_PIN 31 +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 #endif -// HAL_NFC_TIMER4_EVENT_DEBUG_PIN - Pin number +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected -#ifndef HAL_NFC_TIMER4_EVENT_DEBUG_PIN -#define HAL_NFC_TIMER4_EVENT_DEBUG_PIN 31 +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_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 USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_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 USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 +#endif +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_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 APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_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 APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 0 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 #endif -// HAL_NFC_HCLOCK_ON_DEBUG_PIN - Pin number +// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef HAL_NFC_HCLOCK_ON_DEBUG_PIN -#define HAL_NFC_HCLOCK_ON_DEBUG_PIN 31 +#ifndef NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 #endif -// HAL_NFC_HCLOCK_OFF_DEBUG_PIN - Pin number +// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef HAL_NFC_HCLOCK_OFF_DEBUG_PIN -#define HAL_NFC_HCLOCK_OFF_DEBUG_PIN 31 +#ifndef NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 #endif -// HAL_NFC_NFC_EVENT_DEBUG_PIN - Pin number +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef HAL_NFC_NFC_EVENT_DEBUG_PIN -#define HAL_NFC_NFC_EVENT_DEBUG_PIN 31 +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 #endif -// HAL_NFC_DETECT_EVENT_DEBUG_PIN - Pin number +// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -#ifndef HAL_NFC_DETECT_EVENT_DEBUG_PIN -#define HAL_NFC_DETECT_EVENT_DEBUG_PIN 31 +#ifndef NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 #endif -// HAL_NFC_TIMER4_EVENT_DEBUG_PIN - Pin number +// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <32=> 32 (P1.0) -// <33=> 33 (P1.1) -// <34=> 34 (P1.2) -// <35=> 35 (P1.3) -// <36=> 36 (P1.4) -// <37=> 37 (P1.5) -// <38=> 38 (P1.6) -// <39=> 39 (P1.7) -// <40=> 40 (P1.8) -// <41=> 41 (P1.9) -// <42=> 42 (P1.10) -// <43=> 43 (P1.11) -// <44=> 44 (P1.12) -// <45=> 45 (P1.13) -// <46=> 46 (P1.14) -// <47=> 47 (P1.15) -// <4294967295=> Not connected +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_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 HAL_NFC_TIMER4_EVENT_DEBUG_PIN -#define HAL_NFC_TIMER4_EVENT_DEBUG_PIN 31 +#ifndef NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 #endif -// - -// - -// -//========================================================== +// NRF_SDH_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -// nRF_Segger_RTT +#ifndef NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif -//========================================================== -// segger_rtt - SEGGER RTT +// +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. //========================================================== -// SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer. -// Note that either @ref NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE -// 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 512 +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 #endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// 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 +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 #endif -// 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 +// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -// 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 +#ifndef NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 #endif -// SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. +// NRF_SDH_SOC_DEBUG_COLOR - ANSI escape code prefix. +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White -// The following modes are supported: -// - SKIP - Do not block, output nothing. -// - TRIM - Do not block, output as much as fits. -// - 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 +#ifndef NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 #endif -// -//========================================================== - -// -//========================================================== - -// nRF_SoftDevice +// +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_SDH_ANT_ENABLED - nrf_sdh_ant - SoftDevice ANT event handler -//========================================================== -#ifndef NRF_SDH_ANT_ENABLED -#define NRF_SDH_ANT_ENABLED 0 +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 #endif -// ANT Channels +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -//========================================================== -// NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels. -#ifndef NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED -#define NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED 0 +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 #endif -// NRF_SDH_ANT_ENCRYPTED_CHANNELS - Encrypted ANT channels. -#ifndef NRF_SDH_ANT_ENCRYPTED_CHANNELS -#define NRF_SDH_ANT_ENCRYPTED_CHANNELS 0 +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 #endif -// -//========================================================== +// NRF_SORTLIST_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 -// ANT Queues +#ifndef NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== -// NRF_SDH_ANT_EVENT_QUEUE_SIZE - Event queue size. -#ifndef NRF_SDH_ANT_EVENT_QUEUE_SIZE -#define NRF_SDH_ANT_EVENT_QUEUE_SIZE 32 +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 #endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -// NRF_SDH_ANT_BURST_QUEUE_SIZE - ANT burst queue size. -#ifndef NRF_SDH_ANT_BURST_QUEUE_SIZE -#define NRF_SDH_ANT_BURST_QUEUE_SIZE 128 +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 #endif -// -//========================================================== +// NRF_TWI_SENSOR_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 -// ANT Observers - Observers and priority levels +#ifndef NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif -//========================================================== -// NRF_SDH_ANT_OBSERVER_PRIO_LEVELS - Total number of priority levels for ANT observers. -// This setting configures the number of priority levels available for the ANT event handlers. -// The priority level of a handler determines the order in which it receives events, with respect to other handlers. +// NRF_TWI_SENSOR_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 NRF_SDH_ANT_OBSERVER_PRIO_LEVELS -#define NRF_SDH_ANT_OBSERVER_PRIO_LEVELS 2 +#ifndef NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 #endif -// ANT Observers priorities - Invididual priorities +// +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. //========================================================== -// ANT_BPWR_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Bicycle Power Profile. +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef ANT_BPWR_ANT_OBSERVER_PRIO -#define ANT_BPWR_ANT_OBSERVER_PRIO 1 +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 #endif -// ANT_BSC_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Bicycle Speed and Cadence Profile. +// PM_LOG_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 ANT_BSC_ANT_OBSERVER_PRIO -#define ANT_BSC_ANT_OBSERVER_PRIO 1 +#ifndef PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 #endif -// ANT_ENCRYPT_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Cryptographic ANT stack configuration module. +// PM_LOG_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 ANT_ENCRYPT_ANT_OBSERVER_PRIO -#define ANT_ENCRYPT_ANT_OBSERVER_PRIO 1 +#ifndef PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 #endif -// ANT_HRM_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Heart Rate Monitor. +// -#ifndef ANT_HRM_ANT_OBSERVER_PRIO -#define ANT_HRM_ANT_OBSERVER_PRIO 1 -#endif +// +//========================================================== -// ANT_SDM_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Stride Based Speed and Distance Monitor Profile. +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug -#ifndef ANT_SDM_ANT_OBSERVER_PRIO -#define ANT_SDM_ANT_OBSERVER_PRIO 1 +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 #endif -// ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the ANT state indicator module. +// SER_HAL_TRANSPORT_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 ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO -#define ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO 1 +#ifndef SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 #endif -// BSP_BTN_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Button Control module. +// SER_HAL_TRANSPORT_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 BSP_BTN_ANT_OBSERVER_PRIO -#define BSP_BTN_ANT_OBSERVER_PRIO 1 +#ifndef SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 #endif +// + // //========================================================== // //========================================================== - // +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== // NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler //========================================================== #ifndef NRF_SDH_BLE_ENABLED @@ -8169,9 +9678,18 @@ #endif // BLE Stack configuration - Stack configuration parameters -// These values are not used directly by the SoftDevice handler but the application or other libraries might depend on them. -// Keep them up-to-date with the desired configuration. +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. //========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + // NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 @@ -8182,14 +9700,18 @@ #define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 #endif -// NRF_SDH_BLE_TOTAL_LINK_COUNT - Maximum number of total concurrent connections using the default configuration. +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT #define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 #endif -// NRF_SDH_BLE_GAP_EVENT_LENGTH - The time set aside for this connection on every connection interval in 1.25 ms units. +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + #ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH -#define NRF_SDH_BLE_GAP_EVENT_LENGTH 3 +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 #endif // NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. @@ -8225,7 +9747,7 @@ // The priority level of a handler determines the order in which it receives events, with respect to other handlers. #ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS -#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 3 +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 #endif // BLE Observers priorities - Invididual priorities @@ -8235,7 +9757,7 @@ // Priority with which BLE events are dispatched to the Advertising module. #ifndef BLE_ADV_BLE_OBSERVER_PRIO -#define BLE_ADV_BLE_OBSERVER_PRIO 2 +#define BLE_ADV_BLE_OBSERVER_PRIO 1 #endif // BLE_ANCS_C_BLE_OBSERVER_PRIO @@ -8277,7 +9799,7 @@ // Priority with which BLE events are dispatched to the Connection parameters module. #ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO -#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 2 +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 #endif // BLE_CONN_STATE_BLE_OBSERVER_PRIO @@ -8315,6 +9837,13 @@ #define BLE_DFU_BLE_OBSERVER_PRIO 2 #endif +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + // BLE_GLS_BLE_OBSERVER_PRIO // Priority with which BLE events are dispatched to the Glucose Service. @@ -8455,6 +9984,20 @@ #define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 #endif +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + // NRF_BLE_BMS_BLE_OBSERVER_PRIO // Priority with which BLE events are dispatched to the Bond Management Service. @@ -8469,6 +10012,13 @@ #define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 #endif +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + // NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO // Priority with which BLE events are dispatched to the GATT Service Client. @@ -8480,7 +10030,14 @@ // Priority with which BLE events are dispatched to the GATT module. #ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO -#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 2 +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 #endif // NRF_BLE_QWR_BLE_OBSERVER_PRIO @@ -8490,11 +10047,16 @@ #define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 #endif -// PM_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Peer Manager module. +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. #ifndef PM_BLE_OBSERVER_PRIO -#define PM_BLE_OBSERVER_PRIO 2 +#define PM_BLE_OBSERVER_PRIO 1 #endif // @@ -8558,19 +10120,23 @@ #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 #endif -// NRF_SDH_CLOCK_LF_XTAL_ACCURACY - External crystal clock accuracy used in the LL to compute timing windows. +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. -// <0=> NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM -// <1=> NRF_CLOCK_LF_XTAL_ACCURACY_500_PPM -// <2=> NRF_CLOCK_LF_XTAL_ACCURACY_150_PPM -// <3=> NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM -// <4=> NRF_CLOCK_LF_XTAL_ACCURACY_75_PPM -// <5=> NRF_CLOCK_LF_XTAL_ACCURACY_50_PPM -// <6=> NRF_CLOCK_LF_XTAL_ACCURACY_30_PPM -// <7=> NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM -#ifndef NRF_SDH_CLOCK_LF_XTAL_ACCURACY -#define NRF_SDH_CLOCK_LF_XTAL_ACCURACY 7 +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 #endif // @@ -8689,13 +10255,6 @@ // SoC Observers priorities - Invididual priorities //========================================================== -// BLE_ADV_SOC_OBSERVER_PRIO -// Priority with which SoC events are dispatched to the Advertising module. - -#ifndef BLE_ADV_SOC_OBSERVER_PRIO -#define BLE_ADV_SOC_OBSERVER_PRIO 1 -#endif - // BLE_DFU_SOC_OBSERVER_PRIO // Priority with which BLE events are dispatched to the DFU Service. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/ses/flash_placement.xml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/ses/flash_placement.xml new file mode 100644 index 0000000..39c2e94 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52810/ses/flash_placement.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/Makefile new file mode 100644 index 0000000..47a79a6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/Makefile @@ -0,0 +1,234 @@ +PROJECT_NAME := generic_nrf52811_xxaa +TARGETS := toxophilite +OUTPUT_DIRECTORY := _build + +SDK_ROOT := ../../.. +PROJ_DIR := ../.. + +$(OUTPUT_DIRECTORY)/toxophilite.out: \ + LINKER_SCRIPT := generic_gcc_nrf52.ld + +# Source files common to all targets +SRC_FILES += \ + $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52811.S \ + $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ + $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \ + $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \ + $(SDK_ROOT)/components/libraries/timer/app_timer2.c \ + $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ + $(SDK_ROOT)/components/libraries/timer/drv_rtc.c \ + $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \ + $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ + $(SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \ + $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \ + $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \ + $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \ + $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \ + $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \ + $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \ + $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \ + $(SDK_ROOT)/components/libraries/sortlist/nrf_sortlist.c \ + $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \ + $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \ + $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \ + $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \ + $(PROJ_DIR)/main.c \ + $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52811.c \ + $(SDK_ROOT)/external/utf_converter/utf.c \ + $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \ + $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \ + $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \ + +# Include folders common to all targets +INC_FOLDERS += \ + $(SDK_ROOT)/components/libraries/sdcard \ + $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \ + $(SDK_ROOT)/components/ble/ble_services/ble_tps \ + $(SDK_ROOT)/components/libraries/experimental_section_vars \ + $(SDK_ROOT)/components/libraries/crc32 \ + $(SDK_ROOT)/components/libraries/csense_drv \ + $(SDK_ROOT)/components/libraries/fstorage \ + $(SDK_ROOT)/components/libraries/cli \ + $(SDK_ROOT)/components/ble/ble_services/ble_lbs \ + $(SDK_ROOT)/components/libraries/atomic_fifo \ + $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \ + $(SDK_ROOT)/components/softdevice/s112/headers/nrf52 \ + $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \ + $(SDK_ROOT)/components/libraries/scheduler \ + $(SDK_ROOT)/components/libraries/memobj \ + $(SDK_ROOT)/components/ble/ble_services/ble_nus \ + $(SDK_ROOT)/components/libraries/hci \ + $(SDK_ROOT)/components/libraries/queue \ + $(SDK_ROOT)/components/ble/ble_services/ble_hrs \ + $(SDK_ROOT)/components/libraries/mem_manager \ + $(SDK_ROOT)/components/libraries/usbd/class/hid \ + $(SDK_ROOT)/components/libraries/mutex \ + $(SDK_ROOT)/components/ble/peer_manager \ + $(SDK_ROOT)/components/ble/ble_services/ble_bas \ + $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \ + $(SDK_ROOT)/components/softdevice/common \ + $(SDK_ROOT)/components/libraries/mpu \ + $(SDK_ROOT)/components/libraries/twi_mngr \ + $(SDK_ROOT)/components/libraries/usbd/class/audio \ + $(SDK_ROOT)/components/libraries/experimental_task_manager \ + $(SDK_ROOT)/components/libraries/stack_guard \ + $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \ + $(SDK_ROOT)/components/libraries/util \ + $(SDK_ROOT)/components/libraries/timer \ + $(SDK_ROOT)/integration/nrfx \ + $(SDK_ROOT)/components/libraries/spi_mngr \ + $(SDK_ROOT)/components/libraries/usbd/class/cdc \ + $(SDK_ROOT)/components/libraries/gfx \ + $(SDK_ROOT)/components/ble/ble_services/ble_dfu \ + $(SDK_ROOT)/components/ble/ble_dtm \ + $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \ + $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \ + $(SDK_ROOT)/modules/nrfx/drivers/include \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(SDK_ROOT)/components/ble/ble_services/ble_rscs \ + $(SDK_ROOT)/components/libraries/balloc \ + $(SDK_ROOT)/components/libraries/sortlist \ + $(SDK_ROOT)/components/ble/nrf_ble_qwr \ + $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \ + $(SDK_ROOT)/components/libraries/pwm \ + $(SDK_ROOT)/components/libraries/ringbuf \ + $(SDK_ROOT)/components/libraries/slip \ + $(SDK_ROOT)/components/ble/ble_services/ble_hids \ + $(SDK_ROOT)/components/ble/ble_advertising \ + ../config \ + $(SDK_ROOT)/modules/nrfx/hal \ + $(SDK_ROOT)/components/libraries/pwr_mgmt \ + $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \ + $(SDK_ROOT)/modules/nrfx \ + $(SDK_ROOT)/components/libraries/csense \ + $(SDK_ROOT)/components/libraries/fds \ + $(SDK_ROOT)/components/libraries/delay \ + $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \ + $(SDK_ROOT)/integration/nrfx/legacy \ + $(SDK_ROOT)/components/libraries/usbd \ + $(SDK_ROOT)/components/libraries/log \ + $(SDK_ROOT)/components/ble/common \ + $(SDK_ROOT)/components/libraries/usbd/class/msc \ + $(SDK_ROOT)/external/fprintf \ + $(SDK_ROOT)/components/libraries/crypto \ + $(SDK_ROOT)/components \ + $(SDK_ROOT)/external/utf_converter \ + $(SDK_ROOT)/components/libraries/log/src \ + $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \ + $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \ + $(SDK_ROOT)/components/libraries/ecc \ + $(SDK_ROOT)/components/ble/ble_services/ble_cscs \ + $(SDK_ROOT)/components/ble/ble_services/ble_dis \ + $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \ + $(SDK_ROOT)/components/libraries/crc16 \ + $(SDK_ROOT)/components/libraries/low_power_pwm \ + $(SDK_ROOT)/components/softdevice/s112/headers \ + $(SDK_ROOT)/components/libraries/led_softblink \ + $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \ + $(SDK_ROOT)/modules/nrfx/mdk \ + $(SDK_ROOT)/components/libraries/atomic \ + $(SDK_ROOT)/components/ble/ble_services/ble_gls \ + $(SDK_ROOT)/components/ble/ble_racp \ + $(SDK_ROOT)/components/ble/ble_services/ble_hts \ + $(SDK_ROOT)/components/ble/ble_services/ble_ias \ + $(SDK_ROOT)/components/libraries/svc \ + $(SDK_ROOT)/components/libraries/twi_sensor \ + $(SDK_ROOT)/components/libraries/button \ + $(SDK_ROOT)/components/libraries/strerror \ + $(SDK_ROOT)/components/ble/ble_services/ble_lls \ + $(SDK_ROOT)/components/libraries/gpiote \ + $(SDK_ROOT)/components/libraries/hardfault \ + +# Libraries common to all targets +LIB_FILES += \ + +# Optimization flags +OPT = -O3 -g3 +# Uncomment the line below to enable link time optimization +#OPT += -flto + +# C flags common to all targets +CFLAGS += $(OPT) +CFLAGS += -DAPP_TIMER_V2 +CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED +CFLAGS += -DFLOAT_ABI_SOFT +CFLAGS += -DNRF52811_XXAA +CFLAGS += -DNRF_SD_BLE_API_VERSION=7 +CFLAGS += -DS112 +CFLAGS += -DSOFTDEVICE_PRESENT +CFLAGS += -mcpu=cortex-m4 +CFLAGS += -mthumb -mabi=aapcs +CFLAGS += -Wall -Werror +CFLAGS += -mfloat-abi=soft +# keep every function in a separate section, this allows linker to discard unused ones +CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing +CFLAGS += -fno-builtin -fshort-enums + +# C++ flags common to all targets +CXXFLAGS += $(OPT) +# Assembler flags common to all targets +ASMFLAGS += -g3 +ASMFLAGS += -mcpu=cortex-m4 +ASMFLAGS += -mthumb -mabi=aapcs +ASMFLAGS += -mfloat-abi=soft +ASMFLAGS += -DAPP_TIMER_V2 +ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED +ASMFLAGS += -DFLOAT_ABI_SOFT +ASMFLAGS += -DNRF52811_XXAA +ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7 +ASMFLAGS += -DS112 +ASMFLAGS += -DSOFTDEVICE_PRESENT + +# Linker flags +LDFLAGS += $(OPT) +LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT) +LDFLAGS += -mcpu=cortex-m4 +# let linker dump unused sections +LDFLAGS += -Wl,--gc-sections +# use newlib in nano version +LDFLAGS += --specs=nano.specs + +toxophilite: CFLAGS += -D__HEAP_SIZE=4096 +toxophilite: CFLAGS += -D__STACK_SIZE=4096 +toxophilite: ASMFLAGS += -D__HEAP_SIZE=4096 +toxophilite: ASMFLAGS += -D__STACK_SIZE=4096 + +# Add standard libraries at the very end of the linker input, after all objects +# that may need symbols provided by these libraries. +LIB_FILES += -lc -lnosys -lm + + +.PHONY: default help + +# Default target - first one defined +default: toxophilite + +# Print all targets that can be built +help: + @echo following targets are available: + @echo toxophilite + @echo sdk_config - starting external tool for editing sdk_config.h + @echo flash - flashing binary + +TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc + + +include $(TEMPLATE_PATH)/Makefile.common + +$(foreach target, $(TARGETS), $(call define_target, $(target))) + +.PHONY: flash erase + +# Flash the program +flash: default + @echo Flashing: $(OUTPUT_DIRECTORY)/toxophilite.hex + nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/toxophilite.hex --sectorerase + nrfjprog -f nrf52 --reset + +erase: + nrfjprog -f nrf52 --eraseall + +SDK_CONFIG_FILE := ../config/sdk_config.h +CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar +sdk_config: + java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/generic_gcc_nrf52.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/generic_gcc_nrf52.ld new file mode 100644 index 0000000..ad801f9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/armgcc/generic_gcc_nrf52.ld @@ -0,0 +1,130 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x19000, LENGTH = 0x17000 + RAM (rwx) : ORIGIN = 0x20001118, LENGTH = 0x4ee8 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/config/sdk_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/config/sdk_config.h new file mode 100644 index 0000000..0fc9038 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/config/sdk_config.h @@ -0,0 +1,10335 @@ +/** + * Copyright (c) 2017 - 2019, 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 SDK_CONFIG_H +#define SDK_CONFIG_H +// <<< Use Configuration Wizard in Context Menu >>>\n +#ifdef USE_APP_CONFIG +#include "app_config.h" +#endif +// nRF_BLE + +//========================================================== +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module + + +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 +#endif + +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands + + +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif + +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// 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 +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// + +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 +#endif + +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 +#endif + +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 +#endif + +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client + + +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 +#endif + +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client + + +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 +#endif + +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif + +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service + + +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 +#endif + +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client + + +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 +#endif + +// BLE_DIS_ENABLED - ble_dis - Device Information Service + + +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 +#endif + +// BLE_GLS_ENABLED - ble_gls - Glucose Service + + +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 +#endif + +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service + + +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 +#endif + +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + + +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 +#endif + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service + + +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 +#endif + +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service + + +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 +#endif + +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif + +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client + + +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 +#endif + +// BLE_LBS_ENABLED - ble_lbs - LED Button Service + + +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 0 +#endif + +// BLE_LLS_ENABLED - ble_lls - Link Loss Service + + +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 +#endif + +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service + + +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 +#endif + +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client + + +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 +#endif + +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service + + +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 +#endif + +// BLE_TPS_ENABLED - ble_tps - TX Power Service + + +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. + +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes + +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 +#endif + +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + + +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + + +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + + +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + + +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + + +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + + +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// +//========================================================== + +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 +#endif + +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 0 +#endif +// 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 1 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 0 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 0 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 0 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 0 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 0 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// nrfx_i2s - I2S peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_lpcomp - LPCOMP peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_qspi - QSPI peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_usbd - USBD peripheral driver + +//========================================================== +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 0 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 0 +#endif +// 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 1 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> + + +// Major 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 + +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> + + +// Minor 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 + +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// 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 + +// 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 + +// 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 + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 31 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 31 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 31 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 31 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 0 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_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 USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_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 USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 +#endif +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_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 APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_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 APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 0 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_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 NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 +#endif + +// NRF_SDH_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 NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +//========================================================== +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 +#endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 +#endif + +// + +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#endif +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== +// NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler +//========================================================== +#ifndef NRF_SDH_BLE_ENABLED +#define NRF_SDH_BLE_ENABLED 0 +#endif +// BLE Stack configuration - Stack configuration parameters + +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. +//========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + +// NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. +#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. +#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + +#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + +#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 +#endif + +// NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. +#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23 +#endif + +// NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. +#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE +#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408 +#endif + +// NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. +#ifndef NRF_SDH_BLE_VS_UUID_COUNT +#define NRF_SDH_BLE_VS_UUID_COUNT 0 +#endif + +// NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. + + +#ifndef NRF_SDH_BLE_SERVICE_CHANGED +#define NRF_SDH_BLE_SERVICE_CHANGED 0 +#endif + +// +//========================================================== + +// BLE Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_BLE_OBSERVER_PRIO_LEVELS - Total number of priority levels for BLE observers. +// This setting configures the number of priority levels available for BLE event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 +#endif + +// BLE Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Advertising module. + +#ifndef BLE_ADV_BLE_OBSERVER_PRIO +#define BLE_ADV_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_ANCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Apple Notification Service Client. + +#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO +#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_ANS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Alert Notification Service Client. + +#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO +#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service. + +#ifndef BLE_BAS_BLE_OBSERVER_PRIO +#define BLE_BAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service Client. + +#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO +#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Blood Pressure Service. + +#ifndef BLE_BPS_BLE_OBSERVER_PRIO +#define BLE_BPS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection parameters module. + +#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_CONN_STATE_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection State module. + +#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO +#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 +#endif + +// BLE_CSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. + +#ifndef BLE_CSCS_BLE_OBSERVER_PRIO +#define BLE_CSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Current Time Service Client. + +#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO +#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DB_DISC_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Database Discovery module. + +#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO +#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_BLE_OBSERVER_PRIO +#define BLE_DFU_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_GLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Glucose Service. + +#ifndef BLE_GLS_BLE_OBSERVER_PRIO +#define BLE_GLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HIDS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Human Interface Device Service. + +#ifndef BLE_HIDS_BLE_OBSERVER_PRIO +#define BLE_HIDS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service. + +#ifndef BLE_HRS_BLE_OBSERVER_PRIO +#define BLE_HRS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service Client. + +#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO +#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Health Thermometer Service. + +#ifndef BLE_HTS_BLE_OBSERVER_PRIO +#define BLE_HTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service. + +#ifndef BLE_IAS_BLE_OBSERVER_PRIO +#define BLE_IAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service Client. + +#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO +#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service. + +#ifndef BLE_LBS_BLE_OBSERVER_PRIO +#define BLE_LBS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service Client. + +#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO +#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Link Loss Service. + +#ifndef BLE_LLS_BLE_OBSERVER_PRIO +#define BLE_LLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LNS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Location Navigation Service. + +#ifndef BLE_LNS_BLE_OBSERVER_PRIO +#define BLE_LNS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Service. + +#ifndef BLE_NUS_BLE_OBSERVER_PRIO +#define BLE_NUS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Central Service. + +#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO +#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service. + +#ifndef BLE_OTS_BLE_OBSERVER_PRIO +#define BLE_OTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service client. + +#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO +#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. + +#ifndef BLE_RSCS_BLE_OBSERVER_PRIO +#define BLE_RSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. + +#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO +#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_TPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the TX Power Service. + +#ifndef BLE_TPS_BLE_OBSERVER_PRIO +#define BLE_TPS_BLE_OBSERVER_PRIO 2 +#endif + +// BSP_BTN_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Button Control module. + +#ifndef BSP_BTN_BLE_OBSERVER_PRIO +#define BSP_BTN_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_BMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Bond Management Service. + +#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO +#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_CGMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. + +#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO +#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Service Client. + +#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATT_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT module. + +#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_QWR_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Queued writes module. + +#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO +#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. +#ifndef PM_BLE_OBSERVER_PRIO +#define PM_BLE_OBSERVER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler +//========================================================== +#ifndef NRF_SDH_ENABLED +#define NRF_SDH_ENABLED 0 +#endif +// Dispatch model + +// This setting configures how Stack events are dispatched to the application. +//========================================================== +// NRF_SDH_DISPATCH_MODEL + + +// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. +// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. +// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. +// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT +// <1=> NRF_SDH_DISPATCH_MODEL_APPSH +// <2=> NRF_SDH_DISPATCH_MODEL_POLLING + +#ifndef NRF_SDH_DISPATCH_MODEL +#define NRF_SDH_DISPATCH_MODEL 0 +#endif + +// +//========================================================== + +// Clock - SoftDevice clock configuration + +//========================================================== +// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. + +// <0=> NRF_CLOCK_LF_SRC_RC +// <1=> NRF_CLOCK_LF_SRC_XTAL +// <2=> NRF_CLOCK_LF_SRC_SYNTH + +#ifndef NRF_SDH_CLOCK_LF_SRC +#define NRF_SDH_CLOCK_LF_SRC 1 +#endif + +// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. +#ifndef NRF_SDH_CLOCK_LF_RC_CTIV +#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. +// How often (in number of calibration intervals) the RC oscillator shall be calibrated +// if the temperature has not changed. + +#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV +#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM + +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#endif + +// +//========================================================== + +// SDH Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_REQ_OBSERVER_PRIO_LEVELS - Total number of priority levels for request observers. +// This setting configures the number of priority levels available for the SoftDevice request event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_REQ_OBSERVER_PRIO_LEVELS +#define NRF_SDH_REQ_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STATE_OBSERVER_PRIO_LEVELS - Total number of priority levels for state observers. +// This setting configures the number of priority levels available for the SoftDevice state event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STATE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STATE_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STACK_OBSERVER_PRIO_LEVELS - Total number of priority levels for stack event observers. +// This setting configures the number of priority levels available for the SoftDevice stack event handlers (ANT, BLE, SoC). +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STACK_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 +#endif + + +// State Observers priorities - Invididual priorities + +//========================================================== +// CLOCK_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO +#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO +#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// RNG_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to this module. + +#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO +#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// Stack Event Observers priorities - Invididual priorities + +//========================================================== +// NRF_SDH_ANT_STACK_OBSERVER_PRIO +// This setting configures the priority with which ANT events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have ANT events dispatched before or after other stack events, such as BLE or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_ANT_STACK_OBSERVER_PRIO +#define NRF_SDH_ANT_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_BLE_STACK_OBSERVER_PRIO +// This setting configures the priority with which BLE events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have BLE events dispatched before or after other stack events, such as ANT or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_BLE_STACK_OBSERVER_PRIO +#define NRF_SDH_BLE_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_SOC_STACK_OBSERVER_PRIO +// This setting configures the priority with which SoC events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have SoC events dispatched before or after other stack events, such as ANT or BLE. +// Zero is the highest priority. + +#ifndef NRF_SDH_SOC_STACK_OBSERVER_PRIO +#define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler +//========================================================== +#ifndef NRF_SDH_SOC_ENABLED +#define NRF_SDH_SOC_ENABLED 0 +#endif +// SoC Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. +// This setting configures the number of priority levels available for the SoC event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS +#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 +#endif + +// SoC Observers priorities - Invididual priorities + +//========================================================== +// BLE_DFU_SOC_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_SOC_OBSERVER_PRIO +#define BLE_DFU_SOC_OBSERVER_PRIO 1 +#endif + +// CLOCK_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO +#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO +#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// +//========================================================== + +// <<< end of configuration section >>> +#endif //SDK_CONFIG_H + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/flash_placement.xml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/flash_placement.xml new file mode 100644 index 0000000..39c2e94 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/flash_placement.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/generic_nrf52811_xxaa.emProject b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/generic_nrf52811_xxaa.emProject new file mode 100644 index 0000000..390aea2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52811/ses/generic_nrf52811_xxaa.emProject @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/armgcc/generic_gcc_nrf52.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/armgcc/generic_gcc_nrf52.ld new file mode 100644 index 0000000..2f48fa2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/armgcc/generic_gcc_nrf52.ld @@ -0,0 +1,136 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x30000, LENGTH = 0x50000 + RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0xe000 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_ant_observers : + { + PROVIDE(__start_sdh_ant_observers = .); + KEEP(*(SORT(.sdh_ant_observers*))) + PROVIDE(__stop_sdh_ant_observers = .); + } > FLASH + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/config/sdk_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/config/sdk_config.h new file mode 100644 index 0000000..9250959 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/config/sdk_config.h @@ -0,0 +1,12826 @@ +/** + * Copyright (c) 2017 - 2019, 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 SDK_CONFIG_H +#define SDK_CONFIG_H +// <<< Use Configuration Wizard in Context Menu >>>\n +#ifdef USE_APP_CONFIG +#include "app_config.h" +#endif +// nRF_ANT + +//========================================================== +// ANTFS_ENABLED - ant_fs - ANT File Share module. +//========================================================== +#ifndef ANTFS_ENABLED +#define ANTFS_ENABLED 0 +#endif +// ANTFS_CONFIG_NETWORK_NUMBER - ANT-FS network number. +#ifndef ANTFS_CONFIG_NETWORK_NUMBER +#define ANTFS_CONFIG_NETWORK_NUMBER 0 +#endif + +// ANTFS_CONFIG_CHANNEL_NUMBER - ANT-FS channel number. +#ifndef ANTFS_CONFIG_CHANNEL_NUMBER +#define ANTFS_CONFIG_CHANNEL_NUMBER 0 +#endif + +// ANTFS_CONFIG_PAIRING_TIMEOUT - Pairing timeout - how long the UI will wait for a response to a pairing request before switching to the link layer, in seconds. +#ifndef ANTFS_CONFIG_PAIRING_TIMEOUT +#define ANTFS_CONFIG_PAIRING_TIMEOUT 120 +#endif + +// ANTFS_CONFIG_LINK_COMMAND_TIMEOUT - Command timeout - how long the client will wait without receiving any commands before switching to the link layer, in seconds. +#ifndef ANTFS_CONFIG_LINK_COMMAND_TIMEOUT +#define ANTFS_CONFIG_LINK_COMMAND_TIMEOUT 10 +#endif + +// ANTFS_CONFIG_TRANS_TYPE - ANT-FS Transmission Type. +#ifndef ANTFS_CONFIG_TRANS_TYPE +#define ANTFS_CONFIG_TRANS_TYPE 10 +#endif + +// ANTFS_CONFIG_DEVICE_TYPE - ANT device type for channel configuration. +#ifndef ANTFS_CONFIG_DEVICE_TYPE +#define ANTFS_CONFIG_DEVICE_TYPE 1 +#endif + +// ANTFS_CONFIG_BEACON_STATUS_PERIOD - ANT-FS Beacon Message Period. + +// <0=> 0.5 Hz +// <1=> 1 Hz +// <2=> 2 Hz +// <3=> 4 Hz +// <4=> 8 Hz + +#ifndef ANTFS_CONFIG_BEACON_STATUS_PERIOD +#define ANTFS_CONFIG_BEACON_STATUS_PERIOD 3 +#endif + +// ANTFS_CONFIG_TRANSMIT_POWER - ANT Transmit Power. + +// <0=> Lowest ANT Tx power level setting. (-20dBm) +// <1=> ANT Tx power > Lvl 0. (-12dBm) +// <2=> ANT Tx power > Lvl 1. (-4dBm) +// <3=> ANT Tx power > Lvl 2. Default tx power level. (0dBm) +// <4=> ANT Tx power > Lvl 3. (+4dBm) +// <128=> Custom tx power selection + +#ifndef ANTFS_CONFIG_TRANSMIT_POWER +#define ANTFS_CONFIG_TRANSMIT_POWER 3 +#endif + +// ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER - ANT Custom Transmit Power. +#ifndef ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER +#define ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER 0 +#endif + +// ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED - Use pairing and key exchange authentication. + + +#ifndef ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED +#define ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED 0 +#endif + +// ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED - Use passkey authentication. + + +#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED +#define ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED 0 +#endif + +// ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED - Allow host to bypass authentication. + + +#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED +#define ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED 0 +#endif + +// ANTFS_CONFIG_UPLOAD_ENABLED - Support upload operation. + + +#ifndef ANTFS_CONFIG_UPLOAD_ENABLED +#define ANTFS_CONFIG_UPLOAD_ENABLED 0 +#endif + +// ANTFS_CONFIG_DEBUG_LED_ENABLED - Enables LED debug in the module. + + +#ifndef ANTFS_CONFIG_DEBUG_LED_ENABLED +#define ANTFS_CONFIG_DEBUG_LED_ENABLED 0 +#endif + +// + +// ANT_BPWR_ENABLED - ant_bpwr - Bicycle Power Profile +//========================================================== +#ifndef ANT_BPWR_ENABLED +#define ANT_BPWR_ENABLED 0 +#endif +// ANT_BPWR_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_BPWR_LOG_ENABLED +#define ANT_BPWR_LOG_ENABLED 0 +#endif +// ANT_BPWR_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_LOG_LEVEL +#define ANT_BPWR_LOG_LEVEL 3 +#endif + +// ANT_BPWR_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 ANT_BPWR_INFO_COLOR +#define ANT_BPWR_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_COMMON_LOG_ENABLED - Enables logging of BPWR tracing common data. +//========================================================== +#ifndef ANT_BPWR_COMMON_LOG_ENABLED +#define ANT_BPWR_COMMON_LOG_ENABLED 0 +#endif +// ANT_BPWR_COMMON_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_COMMON_LOG_LEVEL +#define ANT_BPWR_COMMON_LOG_LEVEL 3 +#endif + +// ANT_BPWR_COMMON_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 ANT_BPWR_COMMON_INFO_COLOR +#define ANT_BPWR_COMMON_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_TORQUE_LOG_ENABLED - Enables logging of BPWR torque page in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_TORQUE_LOG_ENABLED +#define ANT_BPWR_PAGE_TORQUE_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_TORQUE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_TORQUE_LOG_LEVEL +#define ANT_BPWR_PAGE_TORQUE_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_TORQUE_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 ANT_BPWR_PAGE_TORQUE_INFO_COLOR +#define ANT_BPWR_PAGE_TORQUE_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_1_LOG_ENABLED - Enables logging of BPWR page 1 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_1_LOG_ENABLED +#define ANT_BPWR_PAGE_1_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_1_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_1_LOG_LEVEL +#define ANT_BPWR_PAGE_1_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_1_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 ANT_BPWR_PAGE_1_INFO_COLOR +#define ANT_BPWR_PAGE_1_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_16_LOG_ENABLED - Enables logging of BPWR page 16 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_16_LOG_ENABLED +#define ANT_BPWR_PAGE_16_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_16_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_16_LOG_LEVEL +#define ANT_BPWR_PAGE_16_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_16_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 ANT_BPWR_PAGE_16_INFO_COLOR +#define ANT_BPWR_PAGE_16_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_17_LOG_ENABLED - Enables logging of BPWR page 17 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_17_LOG_ENABLED +#define ANT_BPWR_PAGE_17_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_17_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_17_LOG_LEVEL +#define ANT_BPWR_PAGE_17_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_17_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 ANT_BPWR_PAGE_17_INFO_COLOR +#define ANT_BPWR_PAGE_17_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_18_LOG_ENABLED - Enables logging of BPWR page 18 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_18_LOG_ENABLED +#define ANT_BPWR_PAGE_18_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_18_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_18_LOG_LEVEL +#define ANT_BPWR_PAGE_18_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_18_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 ANT_BPWR_PAGE_18_INFO_COLOR +#define ANT_BPWR_PAGE_18_INFO_COLOR 0 +#endif + +// + +// + +// ANT_BSC_ENABLED - ant_bsc - Bicycle Speed and Cadence Profile +//========================================================== +#ifndef ANT_BSC_ENABLED +#define ANT_BSC_ENABLED 0 +#endif +// ANT_BSC_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_BSC_LOG_ENABLED +#define ANT_BSC_LOG_ENABLED 0 +#endif +// ANT_BSC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_LOG_LEVEL +#define ANT_BSC_LOG_LEVEL 3 +#endif + +// ANT_BSC_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 ANT_BSC_INFO_COLOR +#define ANT_BSC_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED - Enables logging of BSC Combined page 0 in the module. +//========================================================== +#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED +#define ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED 0 +#endif +// ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL +#define ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL 3 +#endif + +// ANT_BSC_COMBINED_PAGE_0_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 ANT_BSC_COMBINED_PAGE_0_INFO_COLOR +#define ANT_BSC_COMBINED_PAGE_0_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_0_LOG_ENABLED - Enables logging of BSC page 0 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_0_LOG_ENABLED +#define ANT_BSC_PAGE_0_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_0_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_0_LOG_LEVEL +#define ANT_BSC_PAGE_0_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_0_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 ANT_BSC_PAGE_0_INFO_COLOR +#define ANT_BSC_PAGE_0_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_1_LOG_ENABLED - Enables logging of BSC page 1 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_1_LOG_ENABLED +#define ANT_BSC_PAGE_1_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_1_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_1_LOG_LEVEL +#define ANT_BSC_PAGE_1_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_1_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 ANT_BSC_PAGE_1_INFO_COLOR +#define ANT_BSC_PAGE_1_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_2_LOG_ENABLED - Enables logging of BSC page 2 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_2_LOG_ENABLED +#define ANT_BSC_PAGE_2_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_2_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_2_LOG_LEVEL +#define ANT_BSC_PAGE_2_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_2_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 ANT_BSC_PAGE_2_INFO_COLOR +#define ANT_BSC_PAGE_2_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_3_LOG_ENABLED - Enables logging of BSC page 3 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_3_LOG_ENABLED +#define ANT_BSC_PAGE_3_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_3_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_3_LOG_LEVEL +#define ANT_BSC_PAGE_3_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_3_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 ANT_BSC_PAGE_3_INFO_COLOR +#define ANT_BSC_PAGE_3_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_4_LOG_ENABLED - Enables logging of BSC page 4 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_4_LOG_ENABLED +#define ANT_BSC_PAGE_4_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_4_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_4_LOG_LEVEL +#define ANT_BSC_PAGE_4_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_4_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 ANT_BSC_PAGE_4_INFO_COLOR +#define ANT_BSC_PAGE_4_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_5_LOG_ENABLED - Enables logging of BSC page 5 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_5_LOG_ENABLED +#define ANT_BSC_PAGE_5_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_5_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_5_LOG_LEVEL +#define ANT_BSC_PAGE_5_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_5_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 ANT_BSC_PAGE_5_INFO_COLOR +#define ANT_BSC_PAGE_5_INFO_COLOR 0 +#endif + +// + +// + +// ANT_CHANNEL_CONFIG_ENABLED - ant_channel_config - ANT common channel configuration + + +#ifndef ANT_CHANNEL_CONFIG_ENABLED +#define ANT_CHANNEL_CONFIG_ENABLED 0 +#endif + +// ANT_COMMON_PAGE_70_ENABLED - ant_common_page_70 - ANT+ common page 70 +//========================================================== +#ifndef ANT_COMMON_PAGE_70_ENABLED +#define ANT_COMMON_PAGE_70_ENABLED 0 +#endif +// ANT_COMMON_PAGE_70_LOG_ENABLED - Enables logging of common page 70 in the module. +//========================================================== +#ifndef ANT_COMMON_PAGE_70_LOG_ENABLED +#define ANT_COMMON_PAGE_70_LOG_ENABLED 0 +#endif +// ANT_COMMON_PAGE_70_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_COMMON_PAGE_70_LOG_LEVEL +#define ANT_COMMON_PAGE_70_LOG_LEVEL 3 +#endif + +// ANT_COMMON_PAGE_70_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 ANT_COMMON_PAGE_70_INFO_COLOR +#define ANT_COMMON_PAGE_70_INFO_COLOR 0 +#endif + +// + +// + +// ANT_COMMON_PAGE_80_ENABLED - ant_common_page_80 - ANT+ common page 80 +//========================================================== +#ifndef ANT_COMMON_PAGE_80_ENABLED +#define ANT_COMMON_PAGE_80_ENABLED 0 +#endif +// ANT_COMMON_PAGE_80_LOG_ENABLED - Enables logging of common page 80 in the module. +//========================================================== +#ifndef ANT_COMMON_PAGE_80_LOG_ENABLED +#define ANT_COMMON_PAGE_80_LOG_ENABLED 0 +#endif +// ANT_COMMON_PAGE_80_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_COMMON_PAGE_80_LOG_LEVEL +#define ANT_COMMON_PAGE_80_LOG_LEVEL 3 +#endif + +// ANT_COMMON_PAGE_80_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 ANT_COMMON_PAGE_80_INFO_COLOR +#define ANT_COMMON_PAGE_80_INFO_COLOR 0 +#endif + +// + +// + +// ANT_COMMON_PAGE_81_ENABLED - ant_common_page_81 - ANT+ common page 81 +//========================================================== +#ifndef ANT_COMMON_PAGE_81_ENABLED +#define ANT_COMMON_PAGE_81_ENABLED 0 +#endif +// ANT_COMMON_PAGE_81_LOG_ENABLED - Enables logging of common page 81 in the module. +//========================================================== +#ifndef ANT_COMMON_PAGE_81_LOG_ENABLED +#define ANT_COMMON_PAGE_81_LOG_ENABLED 0 +#endif +// ANT_COMMON_PAGE_81_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_COMMON_PAGE_81_LOG_LEVEL +#define ANT_COMMON_PAGE_81_LOG_LEVEL 3 +#endif + +// ANT_COMMON_PAGE_81_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 ANT_COMMON_PAGE_81_INFO_COLOR +#define ANT_COMMON_PAGE_81_INFO_COLOR 0 +#endif + +// + +// + +// ANT_ENCRYPT_CONFIG_ENABLED - ant_encrypt_config - Cryptographic ANT stack configuration + + +#ifndef ANT_ENCRYPT_CONFIG_ENABLED +#define ANT_ENCRYPT_CONFIG_ENABLED 0 +#endif + +// ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED - ant_encrypt_negotiation_slave - Encryption negotiation for encrypted ANT slave channels + + +#ifndef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED +#define ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED 0 +#endif + +// ANT_HRM_ENABLED - ant_hrm - Heart Rate Monitor Profile +//========================================================== +#ifndef ANT_HRM_ENABLED +#define ANT_HRM_ENABLED 0 +#endif +// ANT_HRM_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_HRM_LOG_ENABLED +#define ANT_HRM_LOG_ENABLED 0 +#endif +// ANT_HRM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_LOG_LEVEL +#define ANT_HRM_LOG_LEVEL 3 +#endif + +// ANT_HRM_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 ANT_HRM_INFO_COLOR +#define ANT_HRM_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_0_LOG_ENABLED - Enables logging of HRM page 0 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_0_LOG_ENABLED +#define ANT_HRM_PAGE_0_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_0_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_0_LOG_LEVEL +#define ANT_HRM_PAGE_0_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_0_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 ANT_HRM_PAGE_0_INFO_COLOR +#define ANT_HRM_PAGE_0_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_1_LOG_ENABLED - Enables logging of HRM page 1 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_1_LOG_ENABLED +#define ANT_HRM_PAGE_1_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_1_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_1_LOG_LEVEL +#define ANT_HRM_PAGE_1_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_1_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 ANT_HRM_PAGE_1_INFO_COLOR +#define ANT_HRM_PAGE_1_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_2_LOG_ENABLED - Enables logging of HRM page 2 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_2_LOG_ENABLED +#define ANT_HRM_PAGE_2_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_2_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_2_LOG_LEVEL +#define ANT_HRM_PAGE_2_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_2_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 ANT_HRM_PAGE_2_INFO_COLOR +#define ANT_HRM_PAGE_2_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_3_LOG_ENABLED - Enables logging of HRM page 3 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_3_LOG_ENABLED +#define ANT_HRM_PAGE_3_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_3_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_3_LOG_LEVEL +#define ANT_HRM_PAGE_3_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_3_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 ANT_HRM_PAGE_3_INFO_COLOR +#define ANT_HRM_PAGE_3_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_4_LOG_ENABLED - Enables logging of HRM page 4 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_4_LOG_ENABLED +#define ANT_HRM_PAGE_4_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_4_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_4_LOG_LEVEL +#define ANT_HRM_PAGE_4_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_4_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 ANT_HRM_PAGE_4_INFO_COLOR +#define ANT_HRM_PAGE_4_INFO_COLOR 0 +#endif + +// + +// + +// ANT_KEY_MANAGER_ENABLED - ant_key_manager - Software Component + + +#ifndef ANT_KEY_MANAGER_ENABLED +#define ANT_KEY_MANAGER_ENABLED 0 +#endif + +// ANT_REQUEST_CONTROLLER_ENABLED - ant_request_controller - ANT+ request controller + + +#ifndef ANT_REQUEST_CONTROLLER_ENABLED +#define ANT_REQUEST_CONTROLLER_ENABLED 0 +#endif + +// ANT_SDM_ENABLED - ant_sdm - Stride Based Speed and Distance Monitor Profile +//========================================================== +#ifndef ANT_SDM_ENABLED +#define ANT_SDM_ENABLED 0 +#endif +// ANT_SDM_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_SDM_LOG_ENABLED +#define ANT_SDM_LOG_ENABLED 0 +#endif +// ANT_SDM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_SDM_LOG_LEVEL +#define ANT_SDM_LOG_LEVEL 3 +#endif + +// ANT_SDM_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 ANT_SDM_INFO_COLOR +#define ANT_SDM_INFO_COLOR 0 +#endif + +// + +// + +// ANT_SEARCH_CONFIG_ENABLED - ant_search_config - ANT common search configuration +//========================================================== +#ifndef ANT_SEARCH_CONFIG_ENABLED +#define ANT_SEARCH_CONFIG_ENABLED 0 +#endif +// ANT_DEFAULT_LOW_PRIORITY_TIMEOUT - Default low priority search time-out. <0-255> + + +#ifndef ANT_DEFAULT_LOW_PRIORITY_TIMEOUT +#define ANT_DEFAULT_LOW_PRIORITY_TIMEOUT 2 +#endif + +// ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT - Default high priority search time-out. <0-255> + + +#ifndef ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT +#define ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT 10 +#endif + +// + +// ANT_STATE_INDICATOR_ENABLED - ant_state_indicator - ANT state indicator using BSP +//========================================================== +#ifndef ANT_STATE_INDICATOR_ENABLED +#define ANT_STATE_INDICATOR_ENABLED 0 +#endif +// ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY - Shutdown observer priority. +#ifndef ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY +#define ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY 1 +#endif + +// + +// +//========================================================== + +// nRF_BLE + +//========================================================== +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module + + +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 +#endif + +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands + + +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif + +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// 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 +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// + +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 +#endif + +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 +#endif + +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 +#endif + +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client + + +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 +#endif + +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client + + +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 +#endif + +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif + +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service + + +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 +#endif + +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client + + +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 +#endif + +// BLE_DIS_ENABLED - ble_dis - Device Information Service + + +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 +#endif + +// BLE_GLS_ENABLED - ble_gls - Glucose Service + + +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 +#endif + +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service + + +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 +#endif + +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + + +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 +#endif + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service + + +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 +#endif + +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service + + +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 +#endif + +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif + +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client + + +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 +#endif + +// BLE_LBS_ENABLED - ble_lbs - LED Button Service + + +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 0 +#endif + +// BLE_LLS_ENABLED - ble_lls - Link Loss Service + + +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 +#endif + +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service + + +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 +#endif + +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client + + +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 +#endif + +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service + + +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 +#endif + +// BLE_TPS_ENABLED - ble_tps - TX Power Service + + +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. + +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes + +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 +#endif + +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + + +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + + +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + + +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + + +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + + +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + + +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// +//========================================================== + +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 +#endif + +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 0 +#endif +// 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 1 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_NFCT_ENABLED - nrfx_nfct - NFCT peripheral driver +//========================================================== +#ifndef NRFX_NFCT_ENABLED +#define NRFX_NFCT_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_NFCT_CONFIG_IRQ_PRIORITY +#define NRFX_NFCT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_NFCT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_NFCT_CONFIG_LOG_ENABLED +#define NRFX_NFCT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_NFCT_CONFIG_LOG_LEVEL +#define NRFX_NFCT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_NFCT_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 NRFX_NFCT_CONFIG_INFO_COLOR +#define NRFX_NFCT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_NFCT_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 NRFX_NFCT_CONFIG_DEBUG_COLOR +#define NRFX_NFCT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 0 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_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 NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 0 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 0 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 0 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 0 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 0 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 0 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// 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 + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 0 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 0 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// 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 + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 0 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 0 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// nrfx_qspi - QSPI peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_usbd - USBD peripheral driver + +//========================================================== +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 0 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 0 +#endif +// 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 1 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> + + +// Major 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 + +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> + + +// Minor 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 + +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// 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 + +// 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 + +// 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 + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 31 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 31 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 31 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 31 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 0 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_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 USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_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 USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 +#endif +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_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 APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_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 APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 1 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_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 NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 +#endif + +// NRF_SDH_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 NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +//========================================================== +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 +#endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 +#endif + +// + +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#endif +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_NFC + +//========================================================== +// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder + + +#ifndef NFC_AC_REC_ENABLED +#define NFC_AC_REC_ENABLED 0 +#endif + +// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser + + +#ifndef NFC_AC_REC_PARSER_ENABLED +#define NFC_AC_REC_PARSER_ENABLED 0 +#endif + +// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder +//========================================================== +#ifndef NFC_BLE_OOB_ADVDATA_ENABLED +#define NFC_BLE_OOB_ADVDATA_ENABLED 0 +#endif +// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) + +// <1=> Enabled +// <0=> Disabled + +#ifndef ADVANCED_ADVDATA_SUPPORT +#define ADVANCED_ADVDATA_SUPPORT 0 +#endif + +// + +// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser + + +#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED +#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 +#endif + +// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_ENABLED +#define NFC_BLE_PAIR_LIB_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED +#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL +#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 +#endif + +// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_INFO_COLOR +#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 +#endif + +// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_DEBUG_COLOR +#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 +#endif + +// + +// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. + +//========================================================== +// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. + +// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +//========================================================== +#ifndef BLE_NFC_SEC_PARAM_BOND +#define BLE_NFC_SEC_PARAM_BOND 1 +#endif +// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#endif + +// + +// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#endif + +// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#endif + +// +//========================================================== + +// + +// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder + + +#ifndef NFC_BLE_PAIR_MSG_ENABLED +#define NFC_BLE_PAIR_MSG_ENABLED 0 +#endif + +// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data + + +#ifndef NFC_CH_COMMON_ENABLED +#define NFC_CH_COMMON_ENABLED 0 +#endif + +// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder + + +#ifndef NFC_EP_OOB_REC_ENABLED +#define NFC_EP_OOB_REC_ENABLED 0 +#endif + +// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder + + +#ifndef NFC_HS_REC_ENABLED +#define NFC_HS_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder + + +#ifndef NFC_LE_OOB_REC_ENABLED +#define NFC_LE_OOB_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser + + +#ifndef NFC_LE_OOB_REC_PARSER_ENABLED +#define NFC_LE_OOB_REC_PARSER_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED +#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED +#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 +#endif + +// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module +//========================================================== +#ifndef NFC_NDEF_MSG_ENABLED +#define NFC_NDEF_MSG_ENABLED 0 +#endif +// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type + +// <2=> Type 2 Tag +// <4=> Type 4 Tag + +#ifndef NFC_NDEF_MSG_TAG_TYPE +#define NFC_NDEF_MSG_TAG_TYPE 2 +#endif + +// + +// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_ENABLED +#define NFC_NDEF_MSG_PARSER_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED +#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL +#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_MSG_PARSER_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 NFC_NDEF_MSG_PARSER_INFO_COLOR +#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module + + +#ifndef NFC_NDEF_RECORD_ENABLED +#define NFC_NDEF_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_ENABLED +#define NFC_NDEF_RECORD_PARSER_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED +#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL +#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_RECORD_PARSER_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 NFC_NDEF_RECORD_PARSER_INFO_COLOR +#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag + + +#ifndef NFC_NDEF_TEXT_RECORD_ENABLED +#define NFC_NDEF_TEXT_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_MSG_ENABLED +#define NFC_NDEF_URI_MSG_ENABLED 0 +#endif + +// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_REC_ENABLED +#define NFC_NDEF_URI_REC_ENABLED 0 +#endif + +// NFC_PLATFORM_ENABLED - nfc_platform - NFC platform module for Clock control. +//========================================================== +#ifndef NFC_PLATFORM_ENABLED +#define NFC_PLATFORM_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_PLATFORM_LOG_ENABLED +#define NFC_PLATFORM_LOG_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_PLATFORM_LOG_LEVEL +#define NFC_PLATFORM_LOG_LEVEL 3 +#endif + +// NFC_PLATFORM_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 NFC_PLATFORM_INFO_COLOR +#define NFC_PLATFORM_INFO_COLOR 0 +#endif + +// NFC_PLATFORM_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 NFC_PLATFORM_DEBUG_COLOR +#define NFC_PLATFORM_DEBUG_COLOR 0 +#endif + +// + +// + +// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data +//========================================================== +#ifndef NFC_T2T_PARSER_ENABLED +#define NFC_T2T_PARSER_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T2T_PARSER_LOG_ENABLED +#define NFC_T2T_PARSER_LOG_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T2T_PARSER_LOG_LEVEL +#define NFC_T2T_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T2T_PARSER_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 NFC_T2T_PARSER_INFO_COLOR +#define NFC_T2T_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_APDU_ENABLED +#define NFC_T4T_APDU_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_APDU_LOG_ENABLED +#define NFC_T4T_APDU_LOG_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_APDU_LOG_LEVEL +#define NFC_T4T_APDU_LOG_LEVEL 3 +#endif + +// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_APDU_LOG_COLOR +#define NFC_T4T_APDU_LOG_COLOR 0 +#endif + +// + +// + +// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED +#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED +#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL +#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_CC_FILE_PARSER_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 NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 +#endif + +// NFC_T4T_HL_DETECTION_PROCEDURES_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 NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 +#endif + +// + +// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage +#ifndef APDU_BUFF_SIZE +#define APDU_BUFF_SIZE 250 +#endif + +// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage +#ifndef CC_STORAGE_BUFF_SIZE +#define CC_STORAGE_BUFF_SIZE 64 +#endif + +// + +// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_TLV_BLOCK_PARSER_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 NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== +// NRF_SDH_ANT_ENABLED - nrf_sdh_ant - SoftDevice ANT event handler +//========================================================== +#ifndef NRF_SDH_ANT_ENABLED +#define NRF_SDH_ANT_ENABLED 0 +#endif +// ANT Channels + +//========================================================== +// NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels. +#ifndef NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED +#define NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED 0 +#endif + +// NRF_SDH_ANT_ENCRYPTED_CHANNELS - Encrypted ANT channels. +#ifndef NRF_SDH_ANT_ENCRYPTED_CHANNELS +#define NRF_SDH_ANT_ENCRYPTED_CHANNELS 0 +#endif + +// +//========================================================== + +// ANT Queues + +//========================================================== +// NRF_SDH_ANT_EVENT_QUEUE_SIZE - Event queue size. +#ifndef NRF_SDH_ANT_EVENT_QUEUE_SIZE +#define NRF_SDH_ANT_EVENT_QUEUE_SIZE 32 +#endif + +// NRF_SDH_ANT_BURST_QUEUE_SIZE - ANT burst queue size. +#ifndef NRF_SDH_ANT_BURST_QUEUE_SIZE +#define NRF_SDH_ANT_BURST_QUEUE_SIZE 128 +#endif + +// +//========================================================== + +// ANT Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_ANT_OBSERVER_PRIO_LEVELS - Total number of priority levels for ANT observers. +// This setting configures the number of priority levels available for the ANT event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_ANT_OBSERVER_PRIO_LEVELS +#define NRF_SDH_ANT_OBSERVER_PRIO_LEVELS 2 +#endif + +// ANT Observers priorities - Invididual priorities + +//========================================================== +// ANT_BPWR_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Bicycle Power Profile. + +#ifndef ANT_BPWR_ANT_OBSERVER_PRIO +#define ANT_BPWR_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_BSC_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Bicycle Speed and Cadence Profile. + +#ifndef ANT_BSC_ANT_OBSERVER_PRIO +#define ANT_BSC_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_ENCRYPT_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Cryptographic ANT stack configuration module. + +#ifndef ANT_ENCRYPT_ANT_OBSERVER_PRIO +#define ANT_ENCRYPT_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_HRM_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Heart Rate Monitor. + +#ifndef ANT_HRM_ANT_OBSERVER_PRIO +#define ANT_HRM_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_SDM_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Stride Based Speed and Distance Monitor Profile. + +#ifndef ANT_SDM_ANT_OBSERVER_PRIO +#define ANT_SDM_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the ANT state indicator module. + +#ifndef ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO +#define ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO 1 +#endif + +// BSP_BTN_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Button Control module. + +#ifndef BSP_BTN_ANT_OBSERVER_PRIO +#define BSP_BTN_ANT_OBSERVER_PRIO 1 +#endif + +// NRF_DFU_ANT_EVT_HANDLER_PRIO - DFU ANT event handling priority. +// Priority used to register the ANT event handler for DFU purposes. Change this if there is other ANT event handlers that should be higher priority. + +#ifndef NRF_DFU_ANT_EVT_HANDLER_PRIO +#define NRF_DFU_ANT_EVT_HANDLER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler +//========================================================== +#ifndef NRF_SDH_BLE_ENABLED +#define NRF_SDH_BLE_ENABLED 0 +#endif +// BLE Stack configuration - Stack configuration parameters + +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. +//========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + +// NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. +#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. +#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + +#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + +#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 +#endif + +// NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. +#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23 +#endif + +// NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. +#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE +#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408 +#endif + +// NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. +#ifndef NRF_SDH_BLE_VS_UUID_COUNT +#define NRF_SDH_BLE_VS_UUID_COUNT 0 +#endif + +// NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. + + +#ifndef NRF_SDH_BLE_SERVICE_CHANGED +#define NRF_SDH_BLE_SERVICE_CHANGED 0 +#endif + +// +//========================================================== + +// BLE Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_BLE_OBSERVER_PRIO_LEVELS - Total number of priority levels for BLE observers. +// This setting configures the number of priority levels available for BLE event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 +#endif + +// BLE Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Advertising module. + +#ifndef BLE_ADV_BLE_OBSERVER_PRIO +#define BLE_ADV_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_ANCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Apple Notification Service Client. + +#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO +#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_ANS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Alert Notification Service Client. + +#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO +#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service. + +#ifndef BLE_BAS_BLE_OBSERVER_PRIO +#define BLE_BAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service Client. + +#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO +#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Blood Pressure Service. + +#ifndef BLE_BPS_BLE_OBSERVER_PRIO +#define BLE_BPS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection parameters module. + +#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_CONN_STATE_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection State module. + +#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO +#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 +#endif + +// BLE_CSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. + +#ifndef BLE_CSCS_BLE_OBSERVER_PRIO +#define BLE_CSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Current Time Service Client. + +#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO +#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DB_DISC_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Database Discovery module. + +#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO +#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_BLE_OBSERVER_PRIO +#define BLE_DFU_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_GLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Glucose Service. + +#ifndef BLE_GLS_BLE_OBSERVER_PRIO +#define BLE_GLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HIDS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Human Interface Device Service. + +#ifndef BLE_HIDS_BLE_OBSERVER_PRIO +#define BLE_HIDS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service. + +#ifndef BLE_HRS_BLE_OBSERVER_PRIO +#define BLE_HRS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service Client. + +#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO +#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Health Thermometer Service. + +#ifndef BLE_HTS_BLE_OBSERVER_PRIO +#define BLE_HTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service. + +#ifndef BLE_IAS_BLE_OBSERVER_PRIO +#define BLE_IAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service Client. + +#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO +#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service. + +#ifndef BLE_LBS_BLE_OBSERVER_PRIO +#define BLE_LBS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service Client. + +#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO +#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Link Loss Service. + +#ifndef BLE_LLS_BLE_OBSERVER_PRIO +#define BLE_LLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LNS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Location Navigation Service. + +#ifndef BLE_LNS_BLE_OBSERVER_PRIO +#define BLE_LNS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Service. + +#ifndef BLE_NUS_BLE_OBSERVER_PRIO +#define BLE_NUS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Central Service. + +#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO +#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service. + +#ifndef BLE_OTS_BLE_OBSERVER_PRIO +#define BLE_OTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service client. + +#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO +#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. + +#ifndef BLE_RSCS_BLE_OBSERVER_PRIO +#define BLE_RSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. + +#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO +#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_TPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the TX Power Service. + +#ifndef BLE_TPS_BLE_OBSERVER_PRIO +#define BLE_TPS_BLE_OBSERVER_PRIO 2 +#endif + +// BSP_BTN_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Button Control module. + +#ifndef BSP_BTN_BLE_OBSERVER_PRIO +#define BSP_BTN_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_BMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Bond Management Service. + +#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO +#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_CGMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. + +#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO +#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Service Client. + +#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATT_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT module. + +#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_QWR_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Queued writes module. + +#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO +#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. +#ifndef PM_BLE_OBSERVER_PRIO +#define PM_BLE_OBSERVER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler +//========================================================== +#ifndef NRF_SDH_ENABLED +#define NRF_SDH_ENABLED 0 +#endif +// Dispatch model + +// This setting configures how Stack events are dispatched to the application. +//========================================================== +// NRF_SDH_DISPATCH_MODEL + + +// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. +// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. +// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. +// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT +// <1=> NRF_SDH_DISPATCH_MODEL_APPSH +// <2=> NRF_SDH_DISPATCH_MODEL_POLLING + +#ifndef NRF_SDH_DISPATCH_MODEL +#define NRF_SDH_DISPATCH_MODEL 0 +#endif + +// +//========================================================== + +// Clock - SoftDevice clock configuration + +//========================================================== +// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. + +// <0=> NRF_CLOCK_LF_SRC_RC +// <1=> NRF_CLOCK_LF_SRC_XTAL +// <2=> NRF_CLOCK_LF_SRC_SYNTH + +#ifndef NRF_SDH_CLOCK_LF_SRC +#define NRF_SDH_CLOCK_LF_SRC 1 +#endif + +// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. +#ifndef NRF_SDH_CLOCK_LF_RC_CTIV +#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. +// How often (in number of calibration intervals) the RC oscillator shall be calibrated +// if the temperature has not changed. + +#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV +#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM + +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#endif + +// +//========================================================== + +// SDH Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_REQ_OBSERVER_PRIO_LEVELS - Total number of priority levels for request observers. +// This setting configures the number of priority levels available for the SoftDevice request event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_REQ_OBSERVER_PRIO_LEVELS +#define NRF_SDH_REQ_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STATE_OBSERVER_PRIO_LEVELS - Total number of priority levels for state observers. +// This setting configures the number of priority levels available for the SoftDevice state event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STATE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STATE_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STACK_OBSERVER_PRIO_LEVELS - Total number of priority levels for stack event observers. +// This setting configures the number of priority levels available for the SoftDevice stack event handlers (ANT, BLE, SoC). +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STACK_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 +#endif + + +// State Observers priorities - Invididual priorities + +//========================================================== +// CLOCK_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO +#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO +#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// RNG_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to this module. + +#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO +#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// Stack Event Observers priorities - Invididual priorities + +//========================================================== +// NRF_SDH_ANT_STACK_OBSERVER_PRIO +// This setting configures the priority with which ANT events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have ANT events dispatched before or after other stack events, such as BLE or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_ANT_STACK_OBSERVER_PRIO +#define NRF_SDH_ANT_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_BLE_STACK_OBSERVER_PRIO +// This setting configures the priority with which BLE events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have BLE events dispatched before or after other stack events, such as ANT or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_BLE_STACK_OBSERVER_PRIO +#define NRF_SDH_BLE_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_SOC_STACK_OBSERVER_PRIO +// This setting configures the priority with which SoC events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have SoC events dispatched before or after other stack events, such as ANT or BLE. +// Zero is the highest priority. + +#ifndef NRF_SDH_SOC_STACK_OBSERVER_PRIO +#define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler +//========================================================== +#ifndef NRF_SDH_SOC_ENABLED +#define NRF_SDH_SOC_ENABLED 0 +#endif +// SoC Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. +// This setting configures the number of priority levels available for the SoC event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS +#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 +#endif + +// SoC Observers priorities - Invididual priorities + +//========================================================== +// BLE_DFU_SOC_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_SOC_OBSERVER_PRIO +#define BLE_DFU_SOC_OBSERVER_PRIO 1 +#endif + +// CLOCK_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO +#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO +#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// +//========================================================== + +// <<< end of configuration section >>> +#endif //SDK_CONFIG_H + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/ses/flash_placement.xml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/ses/flash_placement.xml new file mode 100644 index 0000000..76f2281 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52832/ses/flash_placement.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/Makefile new file mode 100644 index 0000000..24492cc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/Makefile @@ -0,0 +1,264 @@ +PROJECT_NAME := generic_nrf52833_xxaa +TARGETS := toxophilite +OUTPUT_DIRECTORY := _build + +SDK_ROOT := ../../.. +PROJ_DIR := ../.. + +$(OUTPUT_DIRECTORY)/toxophilite.out: \ + LINKER_SCRIPT := generic_gcc_nrf52.ld + +# Source files common to all targets +SRC_FILES += \ + $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52833.S \ + $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ + $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \ + $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \ + $(SDK_ROOT)/components/libraries/timer/app_timer2.c \ + $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ + $(SDK_ROOT)/components/libraries/timer/drv_rtc.c \ + $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \ + $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ + $(SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \ + $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \ + $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \ + $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \ + $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \ + $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \ + $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \ + $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \ + $(SDK_ROOT)/components/libraries/sortlist/nrf_sortlist.c \ + $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \ + $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \ + $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \ + $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \ + $(PROJ_DIR)/main.c \ + $(SDK_ROOT)/components/ble/common/ble_advdata.c \ + $(SDK_ROOT)/components/ble/common/ble_srv_common.c \ + $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52833.c \ + $(SDK_ROOT)/external/utf_converter/utf.c \ + $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \ + $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \ + $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \ + +# Include folders common to all targets +INC_FOLDERS += \ + $(SDK_ROOT)/components/libraries/sdcard \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/common \ + $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ac_rec_parser \ + $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \ + $(SDK_ROOT)/components/softdevice/s113/headers/nrf52 \ + $(SDK_ROOT)/components/ble/ble_services/ble_tps \ + $(SDK_ROOT)/components/libraries/experimental_section_vars \ + $(SDK_ROOT)/components/libraries/crc32 \ + $(SDK_ROOT)/components/libraries/csense_drv \ + $(SDK_ROOT)/components/nfc/ndef/generic/record \ + $(SDK_ROOT)/components/libraries/fstorage \ + $(SDK_ROOT)/components/libraries/cli \ + $(SDK_ROOT)/components/ble/ble_services/ble_lbs \ + $(SDK_ROOT)/components/libraries/atomic_fifo \ + $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_lib \ + $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \ + $(SDK_ROOT)/components/libraries/scheduler \ + $(SDK_ROOT)/components/libraries/memobj \ + $(SDK_ROOT)/components/ble/ble_services/ble_nus \ + $(SDK_ROOT)/components/libraries/hci \ + $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser \ + $(SDK_ROOT)/components/libraries/queue \ + $(SDK_ROOT)/components/ble/ble_services/ble_hrs \ + $(SDK_ROOT)/components/libraries/mem_manager \ + $(SDK_ROOT)/components/nfc/t4t_lib \ + $(SDK_ROOT)/components/libraries/usbd/class/hid \ + $(SDK_ROOT)/components/nfc/t2t_parser \ + $(SDK_ROOT)/components/nfc/t4t_parser/hl_detection_procedure \ + $(SDK_ROOT)/components/nfc/ndef/generic/message \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/hs_rec \ + $(SDK_ROOT)/components/libraries/mutex \ + $(SDK_ROOT)/components/ble/peer_manager \ + $(SDK_ROOT)/components/ble/ble_services/ble_bas \ + $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \ + $(SDK_ROOT)/components/softdevice/common \ + $(SDK_ROOT)/components/libraries/mpu \ + $(SDK_ROOT)/components/libraries/twi_mngr \ + $(SDK_ROOT)/components/libraries/usbd/class/audio \ + $(SDK_ROOT)/components/libraries/experimental_task_manager \ + $(SDK_ROOT)/components/libraries/stack_guard \ + $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \ + $(SDK_ROOT)/components/libraries/util \ + $(SDK_ROOT)/components/softdevice/s113/headers \ + $(SDK_ROOT)/components/libraries/timer \ + $(SDK_ROOT)/components/nfc/ndef/uri \ + $(SDK_ROOT)/integration/nrfx \ + $(SDK_ROOT)/components/nfc/ndef/parser/record \ + $(SDK_ROOT)/components/libraries/spi_mngr \ + $(SDK_ROOT)/components/libraries/usbd/class/cdc \ + $(SDK_ROOT)/components/libraries/gfx \ + $(SDK_ROOT)/components/ble/ble_services/ble_dfu \ + $(SDK_ROOT)/components/nfc/t4t_parser/tlv \ + $(SDK_ROOT)/components/ble/ble_dtm \ + $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \ + $(SDK_ROOT)/components/nfc/ndef/launchapp \ + $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \ + $(SDK_ROOT)/external/utf_converter \ + $(SDK_ROOT)/modules/nrfx/drivers/include \ + $(SDK_ROOT)/components/nfc/platform \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(SDK_ROOT)/components/ble/ble_services/ble_rscs \ + $(SDK_ROOT)/components/libraries/balloc \ + $(SDK_ROOT)/components/libraries/sortlist \ + $(SDK_ROOT)/components/ble/nrf_ble_qwr \ + $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \ + $(SDK_ROOT)/components/libraries/pwm \ + $(SDK_ROOT)/components/libraries/ringbuf \ + $(SDK_ROOT)/components/nfc/t4t_parser/cc_file \ + $(SDK_ROOT)/components/libraries/slip \ + $(SDK_ROOT)/components/ble/ble_services/ble_hids \ + $(SDK_ROOT)/components/ble/ble_advertising \ + ../config \ + $(SDK_ROOT)/modules/nrfx/hal \ + $(SDK_ROOT)/components/nfc/t2t_lib \ + $(SDK_ROOT)/components/libraries/pwr_mgmt \ + $(SDK_ROOT)/components/nfc/ndef/text \ + $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \ + $(SDK_ROOT)/modules/nrfx \ + $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser \ + $(SDK_ROOT)/components/libraries/csense \ + $(SDK_ROOT)/components/libraries/fds \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/le_oob_rec \ + $(SDK_ROOT)/components/libraries/delay \ + $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \ + $(SDK_ROOT)/integration/nrfx/legacy \ + $(SDK_ROOT)/components/libraries/usbd \ + $(SDK_ROOT)/components/libraries/log \ + $(SDK_ROOT)/components/ble/common \ + $(SDK_ROOT)/components/libraries/usbd/class/msc \ + $(SDK_ROOT)/external/fprintf \ + $(SDK_ROOT)/components/libraries/crypto \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/ep_oob_rec \ + $(SDK_ROOT)/components \ + $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser \ + $(SDK_ROOT)/components/libraries/log/src \ + $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \ + $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \ + $(SDK_ROOT)/components/libraries/ecc \ + $(SDK_ROOT)/components/ble/ble_services/ble_cscs \ + $(SDK_ROOT)/components/ble/ble_services/ble_dis \ + $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \ + $(SDK_ROOT)/components/libraries/crc16 \ + $(SDK_ROOT)/components/libraries/low_power_pwm \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_msg \ + $(SDK_ROOT)/components/nfc/t4t_parser/apdu \ + $(SDK_ROOT)/components/libraries/led_softblink \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_oob_advdata \ + $(SDK_ROOT)/components/nfc/ndef/parser/message \ + $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \ + $(SDK_ROOT)/modules/nrfx/mdk \ + $(SDK_ROOT)/components/libraries/atomic \ + $(SDK_ROOT)/components/ble/ble_services/ble_gls \ + $(SDK_ROOT)/components/ble/ble_racp \ + $(SDK_ROOT)/components/ble/ble_services/ble_hts \ + $(SDK_ROOT)/components/ble/ble_services/ble_ias \ + $(SDK_ROOT)/components/libraries/svc \ + $(SDK_ROOT)/components/libraries/twi_sensor \ + $(SDK_ROOT)/components/libraries/button \ + $(SDK_ROOT)/components/libraries/strerror \ + $(SDK_ROOT)/components/ble/ble_services/ble_lls \ + $(SDK_ROOT)/components/libraries/gpiote \ + $(SDK_ROOT)/components/libraries/hardfault \ + $(SDK_ROOT)/components/nfc/ndef/connection_handover/ac_rec \ + +# Libraries common to all targets +LIB_FILES += \ + +# Optimization flags +OPT = -O3 -g3 +# Uncomment the line below to enable link time optimization +#OPT += -flto + +# C flags common to all targets +CFLAGS += $(OPT) +CFLAGS += -DAPP_TIMER_V2 +CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED +CFLAGS += -DFLOAT_ABI_HARD +CFLAGS += -DNRF52833_XXAA +CFLAGS += -DNRF_SD_BLE_API_VERSION=7 +CFLAGS += -DS113 +CFLAGS += -DSOFTDEVICE_PRESENT +CFLAGS += -mcpu=cortex-m4 +CFLAGS += -mthumb -mabi=aapcs +CFLAGS += -Wall -Werror +CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 +# keep every function in a separate section, this allows linker to discard unused ones +CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing +CFLAGS += -fno-builtin -fshort-enums + +# C++ flags common to all targets +CXXFLAGS += $(OPT) +# Assembler flags common to all targets +ASMFLAGS += -g3 +ASMFLAGS += -mcpu=cortex-m4 +ASMFLAGS += -mthumb -mabi=aapcs +ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 +ASMFLAGS += -DAPP_TIMER_V2 +ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED +ASMFLAGS += -DFLOAT_ABI_HARD +ASMFLAGS += -DNRF52833_XXAA +ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7 +ASMFLAGS += -DS113 +ASMFLAGS += -DSOFTDEVICE_PRESENT + +# Linker flags +LDFLAGS += $(OPT) +LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT) +LDFLAGS += -mcpu=cortex-m4 +LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 +# let linker dump unused sections +LDFLAGS += -Wl,--gc-sections +# use newlib in nano version +LDFLAGS += --specs=nano.specs + +toxophilite: CFLAGS += -D__HEAP_SIZE=4096 +toxophilite: CFLAGS += -D__STACK_SIZE=4096 +toxophilite: ASMFLAGS += -D__HEAP_SIZE=4096 +toxophilite: ASMFLAGS += -D__STACK_SIZE=4096 + +# Add standard libraries at the very end of the linker input, after all objects +# that may need symbols provided by these libraries. +LIB_FILES += -lc -lnosys -lm + + +.PHONY: default help + +# Default target - first one defined +default: toxophilite + +# Print all targets that can be built +help: + @echo following targets are available: + @echo toxophilite + @echo sdk_config - starting external tool for editing sdk_config.h + @echo flash - flashing binary + +TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc + + +include $(TEMPLATE_PATH)/Makefile.common + +$(foreach target, $(TARGETS), $(call define_target, $(target))) + +.PHONY: flash erase + +# Flash the program +flash: default + @echo Flashing: $(OUTPUT_DIRECTORY)/toxophilite.hex + nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/toxophilite.hex --sectorerase + nrfjprog -f nrf52 --reset + +erase: + nrfjprog -f nrf52 --eraseall + +SDK_CONFIG_FILE := ../config/sdk_config.h +CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar +sdk_config: + java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/generic_gcc_nrf52.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/generic_gcc_nrf52.ld new file mode 100644 index 0000000..d625237 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/armgcc/generic_gcc_nrf52.ld @@ -0,0 +1,130 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x1c000, LENGTH = 0x64000 + RAM (rwx) : ORIGIN = 0x20001198, LENGTH = 0x1ee68 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/config/sdk_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/config/sdk_config.h new file mode 100644 index 0000000..13eb3be --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/config/sdk_config.h @@ -0,0 +1,11576 @@ +/** + * Copyright (c) 2017 - 2019, 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 SDK_CONFIG_H +#define SDK_CONFIG_H +// <<< Use Configuration Wizard in Context Menu >>>\n +#ifdef USE_APP_CONFIG +#include "app_config.h" +#endif +// nRF_BLE + +//========================================================== +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module + + +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 +#endif + +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands + + +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif + +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// 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 +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// + +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 +#endif + +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 +#endif + +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 +#endif + +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client + + +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 +#endif + +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client + + +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 +#endif + +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif + +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service + + +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 +#endif + +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client + + +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 +#endif + +// BLE_DIS_ENABLED - ble_dis - Device Information Service + + +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 +#endif + +// BLE_GLS_ENABLED - ble_gls - Glucose Service + + +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 +#endif + +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service + + +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 +#endif + +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + + +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 +#endif + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service + + +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 +#endif + +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service + + +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 +#endif + +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif + +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client + + +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 +#endif + +// BLE_LBS_ENABLED - ble_lbs - LED Button Service + + +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 0 +#endif + +// BLE_LLS_ENABLED - ble_lls - Link Loss Service + + +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 +#endif + +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service + + +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 +#endif + +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client + + +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 +#endif + +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service + + +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 +#endif + +// BLE_TPS_ENABLED - ble_tps - TX Power Service + + +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. + +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes + +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 +#endif + +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + + +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + + +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + + +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + + +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + + +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + + +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// +//========================================================== + +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 +#endif + +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 0 +#endif +// 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 1 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_NFCT_ENABLED - nrfx_nfct - NFCT peripheral driver +//========================================================== +#ifndef NRFX_NFCT_ENABLED +#define NRFX_NFCT_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_NFCT_CONFIG_IRQ_PRIORITY +#define NRFX_NFCT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_NFCT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_NFCT_CONFIG_LOG_ENABLED +#define NRFX_NFCT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_NFCT_CONFIG_LOG_LEVEL +#define NRFX_NFCT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_NFCT_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 NRFX_NFCT_CONFIG_INFO_COLOR +#define NRFX_NFCT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_NFCT_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 NRFX_NFCT_CONFIG_DEBUG_COLOR +#define NRFX_NFCT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 0 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 0 +#endif + +// NRFX_PWM3_ENABLED - Enable PWM3 instance + + +#ifndef NRFX_PWM3_ENABLED +#define NRFX_PWM3_ENABLED 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 0 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 +#endif + +// NRFX_SPIM3_ENABLED - Enable SPIM3 instance + + +#ifndef NRFX_SPIM3_ENABLED +#define NRFX_SPIM3_ENABLED 0 +#endif + +// NRFX_SPIM_EXTENDED_ENABLED - Enable extended SPIM features + + +#ifndef NRFX_SPIM_EXTENDED_ENABLED +#define NRFX_SPIM_EXTENDED_ENABLED 0 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 0 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 0 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 0 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE1_ENABLED - Enable UARTE1 instance +#ifndef NRFX_UARTE1_ENABLED +#define NRFX_UARTE1_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 0 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_USBD_ENABLED - nrfx_usbd - USBD peripheral driver +//========================================================== +#ifndef NRFX_USBD_ENABLED +#define NRFX_USBD_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_USBD_CONFIG_IRQ_PRIORITY +#define NRFX_USBD_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_USBD_CONFIG_DMASCHEDULER_MODE - USBD DMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef NRFX_USBD_CONFIG_DMASCHEDULER_MODE +#define NRFX_USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// NRFX_USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. + +#ifndef NRFX_USBD_CONFIG_ISO_IN_ZLP +#define NRFX_USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 0 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// PWM3_ENABLED - Enable PWM3 instance + + +#ifndef PWM3_ENABLED +#define PWM3_ENABLED 0 +#endif + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 0 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 0 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 0 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// UART1_ENABLED - Enable UART1 instance +//========================================================== +#ifndef UART1_ENABLED +#define UART1_ENABLED 0 +#endif +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// nrfx_qspi - QSPI peripheral driver + +//========================================================== +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 0 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 0 +#endif +// 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 1 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> + + +// Major 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 + +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> + + +// Minor 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 + +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// 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 + +// 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 + +// 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 + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 31 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 31 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 31 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 31 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 0 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <32=> 32 (P1.0) +// <33=> 33 (P1.1) +// <34=> 34 (P1.2) +// <35=> 35 (P1.3) +// <36=> 36 (P1.4) +// <37=> 37 (P1.5) +// <38=> 38 (P1.6) +// <39=> 39 (P1.7) +// <40=> 40 (P1.8) +// <41=> 41 (P1.9) +// <42=> 42 (P1.10) +// <43=> 43 (P1.11) +// <44=> 44 (P1.12) +// <45=> 45 (P1.13) +// <46=> 46 (P1.14) +// <47=> 47 (P1.15) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_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 USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_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 USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 +#endif +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_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 APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_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 APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 0 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_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 NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 +#endif + +// NRF_SDH_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 NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +//========================================================== +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 +#endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 +#endif + +// + +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#endif +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_NFC + +//========================================================== +// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder + + +#ifndef NFC_AC_REC_ENABLED +#define NFC_AC_REC_ENABLED 0 +#endif + +// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser + + +#ifndef NFC_AC_REC_PARSER_ENABLED +#define NFC_AC_REC_PARSER_ENABLED 0 +#endif + +// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder +//========================================================== +#ifndef NFC_BLE_OOB_ADVDATA_ENABLED +#define NFC_BLE_OOB_ADVDATA_ENABLED 0 +#endif +// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) + +// <1=> Enabled +// <0=> Disabled + +#ifndef ADVANCED_ADVDATA_SUPPORT +#define ADVANCED_ADVDATA_SUPPORT 0 +#endif + +// + +// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser + + +#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED +#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 +#endif + +// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_ENABLED +#define NFC_BLE_PAIR_LIB_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED +#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL +#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 +#endif + +// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_INFO_COLOR +#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 +#endif + +// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_DEBUG_COLOR +#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 +#endif + +// + +// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. + +//========================================================== +// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. + +// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +//========================================================== +#ifndef BLE_NFC_SEC_PARAM_BOND +#define BLE_NFC_SEC_PARAM_BOND 1 +#endif +// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#endif + +// + +// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#endif + +// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#endif + +// +//========================================================== + +// + +// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder + + +#ifndef NFC_BLE_PAIR_MSG_ENABLED +#define NFC_BLE_PAIR_MSG_ENABLED 0 +#endif + +// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data + + +#ifndef NFC_CH_COMMON_ENABLED +#define NFC_CH_COMMON_ENABLED 0 +#endif + +// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder + + +#ifndef NFC_EP_OOB_REC_ENABLED +#define NFC_EP_OOB_REC_ENABLED 0 +#endif + +// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder + + +#ifndef NFC_HS_REC_ENABLED +#define NFC_HS_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder + + +#ifndef NFC_LE_OOB_REC_ENABLED +#define NFC_LE_OOB_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser + + +#ifndef NFC_LE_OOB_REC_PARSER_ENABLED +#define NFC_LE_OOB_REC_PARSER_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED +#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED +#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 +#endif + +// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module +//========================================================== +#ifndef NFC_NDEF_MSG_ENABLED +#define NFC_NDEF_MSG_ENABLED 0 +#endif +// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type + +// <2=> Type 2 Tag +// <4=> Type 4 Tag + +#ifndef NFC_NDEF_MSG_TAG_TYPE +#define NFC_NDEF_MSG_TAG_TYPE 2 +#endif + +// + +// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_ENABLED +#define NFC_NDEF_MSG_PARSER_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED +#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL +#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_MSG_PARSER_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 NFC_NDEF_MSG_PARSER_INFO_COLOR +#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module + + +#ifndef NFC_NDEF_RECORD_ENABLED +#define NFC_NDEF_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_ENABLED +#define NFC_NDEF_RECORD_PARSER_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED +#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL +#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_RECORD_PARSER_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 NFC_NDEF_RECORD_PARSER_INFO_COLOR +#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag + + +#ifndef NFC_NDEF_TEXT_RECORD_ENABLED +#define NFC_NDEF_TEXT_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_MSG_ENABLED +#define NFC_NDEF_URI_MSG_ENABLED 0 +#endif + +// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_REC_ENABLED +#define NFC_NDEF_URI_REC_ENABLED 0 +#endif + +// NFC_PLATFORM_ENABLED - nfc_platform - NFC platform module for Clock control. +//========================================================== +#ifndef NFC_PLATFORM_ENABLED +#define NFC_PLATFORM_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_PLATFORM_LOG_ENABLED +#define NFC_PLATFORM_LOG_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_PLATFORM_LOG_LEVEL +#define NFC_PLATFORM_LOG_LEVEL 3 +#endif + +// NFC_PLATFORM_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 NFC_PLATFORM_INFO_COLOR +#define NFC_PLATFORM_INFO_COLOR 0 +#endif + +// NFC_PLATFORM_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 NFC_PLATFORM_DEBUG_COLOR +#define NFC_PLATFORM_DEBUG_COLOR 0 +#endif + +// + +// + +// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data +//========================================================== +#ifndef NFC_T2T_PARSER_ENABLED +#define NFC_T2T_PARSER_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T2T_PARSER_LOG_ENABLED +#define NFC_T2T_PARSER_LOG_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T2T_PARSER_LOG_LEVEL +#define NFC_T2T_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T2T_PARSER_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 NFC_T2T_PARSER_INFO_COLOR +#define NFC_T2T_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_APDU_ENABLED +#define NFC_T4T_APDU_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_APDU_LOG_ENABLED +#define NFC_T4T_APDU_LOG_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_APDU_LOG_LEVEL +#define NFC_T4T_APDU_LOG_LEVEL 3 +#endif + +// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_APDU_LOG_COLOR +#define NFC_T4T_APDU_LOG_COLOR 0 +#endif + +// + +// + +// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED +#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED +#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL +#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_CC_FILE_PARSER_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 NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 +#endif + +// NFC_T4T_HL_DETECTION_PROCEDURES_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 NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 +#endif + +// + +// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage +#ifndef APDU_BUFF_SIZE +#define APDU_BUFF_SIZE 250 +#endif + +// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage +#ifndef CC_STORAGE_BUFF_SIZE +#define CC_STORAGE_BUFF_SIZE 64 +#endif + +// + +// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_TLV_BLOCK_PARSER_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 NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== +// NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler +//========================================================== +#ifndef NRF_SDH_BLE_ENABLED +#define NRF_SDH_BLE_ENABLED 0 +#endif +// BLE Stack configuration - Stack configuration parameters + +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. +//========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + +// NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. +#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. +#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + +#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + +#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 +#endif + +// NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. +#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23 +#endif + +// NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. +#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE +#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408 +#endif + +// NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. +#ifndef NRF_SDH_BLE_VS_UUID_COUNT +#define NRF_SDH_BLE_VS_UUID_COUNT 0 +#endif + +// NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. + + +#ifndef NRF_SDH_BLE_SERVICE_CHANGED +#define NRF_SDH_BLE_SERVICE_CHANGED 0 +#endif + +// +//========================================================== + +// BLE Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_BLE_OBSERVER_PRIO_LEVELS - Total number of priority levels for BLE observers. +// This setting configures the number of priority levels available for BLE event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 +#endif + +// BLE Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Advertising module. + +#ifndef BLE_ADV_BLE_OBSERVER_PRIO +#define BLE_ADV_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_ANCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Apple Notification Service Client. + +#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO +#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_ANS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Alert Notification Service Client. + +#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO +#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service. + +#ifndef BLE_BAS_BLE_OBSERVER_PRIO +#define BLE_BAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service Client. + +#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO +#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Blood Pressure Service. + +#ifndef BLE_BPS_BLE_OBSERVER_PRIO +#define BLE_BPS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection parameters module. + +#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_CONN_STATE_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection State module. + +#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO +#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 +#endif + +// BLE_CSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. + +#ifndef BLE_CSCS_BLE_OBSERVER_PRIO +#define BLE_CSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Current Time Service Client. + +#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO +#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DB_DISC_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Database Discovery module. + +#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO +#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_BLE_OBSERVER_PRIO +#define BLE_DFU_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_GLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Glucose Service. + +#ifndef BLE_GLS_BLE_OBSERVER_PRIO +#define BLE_GLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HIDS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Human Interface Device Service. + +#ifndef BLE_HIDS_BLE_OBSERVER_PRIO +#define BLE_HIDS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service. + +#ifndef BLE_HRS_BLE_OBSERVER_PRIO +#define BLE_HRS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service Client. + +#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO +#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Health Thermometer Service. + +#ifndef BLE_HTS_BLE_OBSERVER_PRIO +#define BLE_HTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service. + +#ifndef BLE_IAS_BLE_OBSERVER_PRIO +#define BLE_IAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service Client. + +#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO +#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service. + +#ifndef BLE_LBS_BLE_OBSERVER_PRIO +#define BLE_LBS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service Client. + +#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO +#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Link Loss Service. + +#ifndef BLE_LLS_BLE_OBSERVER_PRIO +#define BLE_LLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LNS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Location Navigation Service. + +#ifndef BLE_LNS_BLE_OBSERVER_PRIO +#define BLE_LNS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Service. + +#ifndef BLE_NUS_BLE_OBSERVER_PRIO +#define BLE_NUS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Central Service. + +#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO +#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service. + +#ifndef BLE_OTS_BLE_OBSERVER_PRIO +#define BLE_OTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service client. + +#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO +#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. + +#ifndef BLE_RSCS_BLE_OBSERVER_PRIO +#define BLE_RSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. + +#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO +#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_TPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the TX Power Service. + +#ifndef BLE_TPS_BLE_OBSERVER_PRIO +#define BLE_TPS_BLE_OBSERVER_PRIO 2 +#endif + +// BSP_BTN_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Button Control module. + +#ifndef BSP_BTN_BLE_OBSERVER_PRIO +#define BSP_BTN_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_BMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Bond Management Service. + +#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO +#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_CGMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. + +#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO +#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Service Client. + +#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATT_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT module. + +#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_QWR_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Queued writes module. + +#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO +#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. +#ifndef PM_BLE_OBSERVER_PRIO +#define PM_BLE_OBSERVER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler +//========================================================== +#ifndef NRF_SDH_ENABLED +#define NRF_SDH_ENABLED 0 +#endif +// Dispatch model + +// This setting configures how Stack events are dispatched to the application. +//========================================================== +// NRF_SDH_DISPATCH_MODEL + + +// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. +// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. +// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. +// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT +// <1=> NRF_SDH_DISPATCH_MODEL_APPSH +// <2=> NRF_SDH_DISPATCH_MODEL_POLLING + +#ifndef NRF_SDH_DISPATCH_MODEL +#define NRF_SDH_DISPATCH_MODEL 0 +#endif + +// +//========================================================== + +// Clock - SoftDevice clock configuration + +//========================================================== +// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. + +// <0=> NRF_CLOCK_LF_SRC_RC +// <1=> NRF_CLOCK_LF_SRC_XTAL +// <2=> NRF_CLOCK_LF_SRC_SYNTH + +#ifndef NRF_SDH_CLOCK_LF_SRC +#define NRF_SDH_CLOCK_LF_SRC 1 +#endif + +// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. +#ifndef NRF_SDH_CLOCK_LF_RC_CTIV +#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. +// How often (in number of calibration intervals) the RC oscillator shall be calibrated +// if the temperature has not changed. + +#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV +#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM + +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#endif + +// +//========================================================== + +// SDH Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_REQ_OBSERVER_PRIO_LEVELS - Total number of priority levels for request observers. +// This setting configures the number of priority levels available for the SoftDevice request event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_REQ_OBSERVER_PRIO_LEVELS +#define NRF_SDH_REQ_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STATE_OBSERVER_PRIO_LEVELS - Total number of priority levels for state observers. +// This setting configures the number of priority levels available for the SoftDevice state event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STATE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STATE_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STACK_OBSERVER_PRIO_LEVELS - Total number of priority levels for stack event observers. +// This setting configures the number of priority levels available for the SoftDevice stack event handlers (ANT, BLE, SoC). +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STACK_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 +#endif + + +// State Observers priorities - Invididual priorities + +//========================================================== +// CLOCK_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO +#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO +#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// RNG_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to this module. + +#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO +#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// Stack Event Observers priorities - Invididual priorities + +//========================================================== +// NRF_SDH_ANT_STACK_OBSERVER_PRIO +// This setting configures the priority with which ANT events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have ANT events dispatched before or after other stack events, such as BLE or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_ANT_STACK_OBSERVER_PRIO +#define NRF_SDH_ANT_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_BLE_STACK_OBSERVER_PRIO +// This setting configures the priority with which BLE events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have BLE events dispatched before or after other stack events, such as ANT or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_BLE_STACK_OBSERVER_PRIO +#define NRF_SDH_BLE_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_SOC_STACK_OBSERVER_PRIO +// This setting configures the priority with which SoC events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have SoC events dispatched before or after other stack events, such as ANT or BLE. +// Zero is the highest priority. + +#ifndef NRF_SDH_SOC_STACK_OBSERVER_PRIO +#define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler +//========================================================== +#ifndef NRF_SDH_SOC_ENABLED +#define NRF_SDH_SOC_ENABLED 0 +#endif +// SoC Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. +// This setting configures the number of priority levels available for the SoC event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS +#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 +#endif + +// SoC Observers priorities - Invididual priorities + +//========================================================== +// BLE_DFU_SOC_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_SOC_OBSERVER_PRIO +#define BLE_DFU_SOC_OBSERVER_PRIO 1 +#endif + +// CLOCK_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO +#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO +#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// +//========================================================== + +// <<< end of configuration section >>> +#endif //SDK_CONFIG_H + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/flash_placement.xml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/flash_placement.xml new file mode 100644 index 0000000..39c2e94 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/flash_placement.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/generic_nrf52833_xxaa.emProject b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/generic_nrf52833_xxaa.emProject new file mode 100644 index 0000000..e0f1287 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52833/ses/generic_nrf52833_xxaa.emProject @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/armgcc/generic_gcc_nrf52.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/armgcc/generic_gcc_nrf52.ld new file mode 100644 index 0000000..369cc8d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/armgcc/generic_gcc_nrf52.ld @@ -0,0 +1,130 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xd9000 + RAM (rwx) : ORIGIN = 0x20005968, LENGTH = 0x3a698 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/config/sdk_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/config/sdk_config.h new file mode 100644 index 0000000..07e1387 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/config/sdk_config.h @@ -0,0 +1,11698 @@ +/** + * Copyright (c) 2017 - 2019, 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 SDK_CONFIG_H +#define SDK_CONFIG_H +// <<< Use Configuration Wizard in Context Menu >>>\n +#ifdef USE_APP_CONFIG +#include "app_config.h" +#endif +// nRF_BLE + +//========================================================== +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module + + +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 +#endif + +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands + + +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif + +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// 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 +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// + +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 +#endif + +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 +#endif + +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 +#endif + +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client + + +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 +#endif + +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client + + +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 +#endif + +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif + +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_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 BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service + + +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 +#endif + +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client + + +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 +#endif + +// BLE_DIS_ENABLED - ble_dis - Device Information Service + + +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 +#endif + +// BLE_GLS_ENABLED - ble_gls - Glucose Service + + +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 +#endif + +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service + + +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 +#endif + +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + + +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 +#endif + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service + + +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 +#endif + +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service + + +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 +#endif + +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif + +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_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 BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client + + +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 +#endif + +// BLE_LBS_ENABLED - ble_lbs - LED Button Service + + +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 0 +#endif + +// BLE_LLS_ENABLED - ble_lls - Link Loss Service + + +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 +#endif + +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service + + +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 +#endif + +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_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 BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client + + +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 +#endif + +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service + + +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 +#endif + +// BLE_TPS_ENABLED - ble_tps - TX Power Service + + +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. + +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes + +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 +#endif + +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + + +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + + +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + + +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + + +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + + +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + + +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// +//========================================================== + +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 +#endif + +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// 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 + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// 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 + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// 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 + +// 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 + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 0 +#endif +// 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 1 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// 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 + +// 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 + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// 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 + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// 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 + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_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 NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_NFCT_ENABLED - nrfx_nfct - NFCT peripheral driver +//========================================================== +#ifndef NRFX_NFCT_ENABLED +#define NRFX_NFCT_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_NFCT_CONFIG_IRQ_PRIORITY +#define NRFX_NFCT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_NFCT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_NFCT_CONFIG_LOG_ENABLED +#define NRFX_NFCT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_NFCT_CONFIG_LOG_LEVEL +#define NRFX_NFCT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_NFCT_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 NRFX_NFCT_CONFIG_INFO_COLOR +#define NRFX_NFCT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_NFCT_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 NRFX_NFCT_CONFIG_DEBUG_COLOR +#define NRFX_NFCT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 0 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 0 +#endif + +// NRFX_PWM3_ENABLED - Enable PWM3 instance + + +#ifndef NRFX_PWM3_ENABLED +#define NRFX_PWM3_ENABLED 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_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 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_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 NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_QSPI_ENABLED - nrfx_qspi - QSPI peripheral driver +//========================================================== +#ifndef NRFX_QSPI_ENABLED +#define NRFX_QSPI_ENABLED 0 +#endif +// NRFX_QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef NRFX_QSPI_CONFIG_SCK_DELAY +#define NRFX_QSPI_CONFIG_SCK_DELAY 1 +#endif + +// NRFX_QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef NRFX_QSPI_CONFIG_XIP_OFFSET +#define NRFX_QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// NRFX_QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef NRFX_QSPI_CONFIG_READOC +#define NRFX_QSPI_CONFIG_READOC 0 +#endif + +// NRFX_QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef NRFX_QSPI_CONFIG_WRITEOC +#define NRFX_QSPI_CONFIG_WRITEOC 0 +#endif + +// NRFX_QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef NRFX_QSPI_CONFIG_ADDRMODE +#define NRFX_QSPI_CONFIG_ADDRMODE 0 +#endif + +// NRFX_QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef NRFX_QSPI_CONFIG_MODE +#define NRFX_QSPI_CONFIG_MODE 0 +#endif + +// NRFX_QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef NRFX_QSPI_CONFIG_FREQUENCY +#define NRFX_QSPI_CONFIG_FREQUENCY 15 +#endif + +// NRFX_QSPI_PIN_SCK - SCK pin value. +#ifndef NRFX_QSPI_PIN_SCK +#define NRFX_QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// NRFX_QSPI_PIN_CSN - CSN pin value. +#ifndef NRFX_QSPI_PIN_CSN +#define NRFX_QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// NRFX_QSPI_PIN_IO0 - IO0 pin value. +#ifndef NRFX_QSPI_PIN_IO0 +#define NRFX_QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// NRFX_QSPI_PIN_IO1 - IO1 pin value. +#ifndef NRFX_QSPI_PIN_IO1 +#define NRFX_QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// NRFX_QSPI_PIN_IO2 - IO2 pin value. +#ifndef NRFX_QSPI_PIN_IO2 +#define NRFX_QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// NRFX_QSPI_PIN_IO3 - IO3 pin value. +#ifndef NRFX_QSPI_PIN_IO3 +#define NRFX_QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// NRFX_QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QSPI_CONFIG_IRQ_PRIORITY +#define NRFX_QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 0 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 +#endif + +// NRFX_SPIM3_ENABLED - Enable SPIM3 instance + + +#ifndef NRFX_SPIM3_ENABLED +#define NRFX_SPIM3_ENABLED 0 +#endif + +// NRFX_SPIM_EXTENDED_ENABLED - Enable extended SPIM features + + +#ifndef NRFX_SPIM_EXTENDED_ENABLED +#define NRFX_SPIM_EXTENDED_ENABLED 0 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_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 NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 0 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 0 +#endif + +// NRFX_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 NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_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 NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 0 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE1_ENABLED - Enable UARTE1 instance +#ifndef NRFX_UARTE1_ENABLED +#define NRFX_UARTE1_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_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 +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_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 NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 0 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_USBD_ENABLED - nrfx_usbd - USBD peripheral driver +//========================================================== +#ifndef NRFX_USBD_ENABLED +#define NRFX_USBD_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_USBD_CONFIG_IRQ_PRIORITY +#define NRFX_USBD_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_USBD_CONFIG_DMASCHEDULER_MODE - USBD DMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef NRFX_USBD_CONFIG_DMASCHEDULER_MODE +#define NRFX_USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// NRFX_USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. + +#ifndef NRFX_USBD_CONFIG_ISO_IN_ZLP +#define NRFX_USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_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 NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_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 NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 0 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// 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 + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// 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 + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// 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 + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// 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 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// 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 + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// 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 + +// 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 + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// PWM3_ENABLED - Enable PWM3 instance + + +#ifndef PWM3_ENABLED +#define PWM3_ENABLED 0 +#endif + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// 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 + +// 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 + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// 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 + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// 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 + +// 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 + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// 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 + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// 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 + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// 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 + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// 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 + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// 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 + +// 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 + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// 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 + +// 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 + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 0 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 0 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// 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=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 0 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// UART1_ENABLED - Enable UART1 instance +//========================================================== +#ifndef UART1_ENABLED +#define UART1_ENABLED 0 +#endif +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// 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 + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 0 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 0 +#endif +// 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 1 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// 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 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// 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 + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// 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 + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> + + +// Major 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 + +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> + + +// Minor 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 + +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// 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 + +// 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 + +// 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 + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// 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 + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// 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 +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// 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=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 31 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 31 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 31 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 31 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// 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 + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// 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 + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// 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 + +// 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 + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// 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 + +// 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 + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// 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 + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_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 MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// 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 + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// 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 + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 0 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <32=> 32 (P1.0) +// <33=> 33 (P1.1) +// <34=> 34 (P1.2) +// <35=> 35 (P1.3) +// <36=> 36 (P1.4) +// <37=> 37 (P1.5) +// <38=> 38 (P1.6) +// <39=> 39 (P1.7) +// <40=> 40 (P1.8) +// <41=> 41 (P1.9) +// <42=> 42 (P1.10) +// <43=> 43 (P1.11) +// <44=> 44 (P1.12) +// <45=> 45 (P1.13) +// <46=> 46 (P1.14) +// <47=> 47 (P1.15) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// 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 + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// 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 +// 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 + +// 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 2 +#endif + +// 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 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_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 NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_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 NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_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 TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_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 MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_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 NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// 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 + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_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 USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_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 USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// 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 + +// 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 + +// 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 + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 +#endif +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 +#endif + +// APP_BUTTON_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 APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_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 APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_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 APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_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 APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_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 APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_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 APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_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 APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_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 APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_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 NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_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 NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_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 NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_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 NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_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 NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_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 NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_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 NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_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 NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_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 NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_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 NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_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 NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_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 NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 0 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 +#endif + +// NRF_SDH_ANT_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 NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_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 NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_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 NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 +#endif + +// NRF_SDH_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 NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +//========================================================== +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 +#endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 +#endif + +// NRF_SDH_SOC_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 NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 +#endif + +// + +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#endif +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#endif + +// NRF_SORTLIST_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 NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_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 NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_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 PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_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 PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_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 SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_NFC + +//========================================================== +// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder + + +#ifndef NFC_AC_REC_ENABLED +#define NFC_AC_REC_ENABLED 0 +#endif + +// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser + + +#ifndef NFC_AC_REC_PARSER_ENABLED +#define NFC_AC_REC_PARSER_ENABLED 0 +#endif + +// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder +//========================================================== +#ifndef NFC_BLE_OOB_ADVDATA_ENABLED +#define NFC_BLE_OOB_ADVDATA_ENABLED 0 +#endif +// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) + +// <1=> Enabled +// <0=> Disabled + +#ifndef ADVANCED_ADVDATA_SUPPORT +#define ADVANCED_ADVDATA_SUPPORT 0 +#endif + +// + +// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser + + +#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED +#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 +#endif + +// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_ENABLED +#define NFC_BLE_PAIR_LIB_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED +#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL +#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 +#endif + +// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_INFO_COLOR +#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 +#endif + +// NFC_BLE_PAIR_LIB_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 NFC_BLE_PAIR_LIB_DEBUG_COLOR +#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 +#endif + +// + +// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. + +//========================================================== +// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. + +// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +//========================================================== +#ifndef BLE_NFC_SEC_PARAM_BOND +#define BLE_NFC_SEC_PARAM_BOND 1 +#endif +// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#endif + +// + +// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#endif + +// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#endif + +// +//========================================================== + +// + +// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder + + +#ifndef NFC_BLE_PAIR_MSG_ENABLED +#define NFC_BLE_PAIR_MSG_ENABLED 0 +#endif + +// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data + + +#ifndef NFC_CH_COMMON_ENABLED +#define NFC_CH_COMMON_ENABLED 0 +#endif + +// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder + + +#ifndef NFC_EP_OOB_REC_ENABLED +#define NFC_EP_OOB_REC_ENABLED 0 +#endif + +// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder + + +#ifndef NFC_HS_REC_ENABLED +#define NFC_HS_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder + + +#ifndef NFC_LE_OOB_REC_ENABLED +#define NFC_LE_OOB_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser + + +#ifndef NFC_LE_OOB_REC_PARSER_ENABLED +#define NFC_LE_OOB_REC_PARSER_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED +#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED +#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 +#endif + +// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module +//========================================================== +#ifndef NFC_NDEF_MSG_ENABLED +#define NFC_NDEF_MSG_ENABLED 0 +#endif +// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type + +// <2=> Type 2 Tag +// <4=> Type 4 Tag + +#ifndef NFC_NDEF_MSG_TAG_TYPE +#define NFC_NDEF_MSG_TAG_TYPE 2 +#endif + +// + +// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_ENABLED +#define NFC_NDEF_MSG_PARSER_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED +#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL +#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_MSG_PARSER_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 NFC_NDEF_MSG_PARSER_INFO_COLOR +#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module + + +#ifndef NFC_NDEF_RECORD_ENABLED +#define NFC_NDEF_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_ENABLED +#define NFC_NDEF_RECORD_PARSER_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED +#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL +#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_RECORD_PARSER_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 NFC_NDEF_RECORD_PARSER_INFO_COLOR +#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag + + +#ifndef NFC_NDEF_TEXT_RECORD_ENABLED +#define NFC_NDEF_TEXT_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_MSG_ENABLED +#define NFC_NDEF_URI_MSG_ENABLED 0 +#endif + +// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_REC_ENABLED +#define NFC_NDEF_URI_REC_ENABLED 0 +#endif + +// NFC_PLATFORM_ENABLED - nfc_platform - NFC platform module for Clock control. +//========================================================== +#ifndef NFC_PLATFORM_ENABLED +#define NFC_PLATFORM_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_PLATFORM_LOG_ENABLED +#define NFC_PLATFORM_LOG_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_PLATFORM_LOG_LEVEL +#define NFC_PLATFORM_LOG_LEVEL 3 +#endif + +// NFC_PLATFORM_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 NFC_PLATFORM_INFO_COLOR +#define NFC_PLATFORM_INFO_COLOR 0 +#endif + +// NFC_PLATFORM_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 NFC_PLATFORM_DEBUG_COLOR +#define NFC_PLATFORM_DEBUG_COLOR 0 +#endif + +// + +// + +// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data +//========================================================== +#ifndef NFC_T2T_PARSER_ENABLED +#define NFC_T2T_PARSER_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T2T_PARSER_LOG_ENABLED +#define NFC_T2T_PARSER_LOG_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T2T_PARSER_LOG_LEVEL +#define NFC_T2T_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T2T_PARSER_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 NFC_T2T_PARSER_INFO_COLOR +#define NFC_T2T_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_APDU_ENABLED +#define NFC_T4T_APDU_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_APDU_LOG_ENABLED +#define NFC_T4T_APDU_LOG_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_APDU_LOG_LEVEL +#define NFC_T4T_APDU_LOG_LEVEL 3 +#endif + +// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_APDU_LOG_COLOR +#define NFC_T4T_APDU_LOG_COLOR 0 +#endif + +// + +// + +// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED +#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED +#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL +#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_CC_FILE_PARSER_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 NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 +#endif + +// NFC_T4T_HL_DETECTION_PROCEDURES_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 NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 +#endif + +// + +// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage +#ifndef APDU_BUFF_SIZE +#define APDU_BUFF_SIZE 250 +#endif + +// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage +#ifndef CC_STORAGE_BUFF_SIZE +#define CC_STORAGE_BUFF_SIZE 64 +#endif + +// + +// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_TLV_BLOCK_PARSER_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 NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== +// NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler +//========================================================== +#ifndef NRF_SDH_BLE_ENABLED +#define NRF_SDH_BLE_ENABLED 0 +#endif +// BLE Stack configuration - Stack configuration parameters + +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. +//========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + +// NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. +#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. +#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + +#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + +#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 +#endif + +// NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. +#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23 +#endif + +// NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. +#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE +#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408 +#endif + +// NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. +#ifndef NRF_SDH_BLE_VS_UUID_COUNT +#define NRF_SDH_BLE_VS_UUID_COUNT 0 +#endif + +// NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. + + +#ifndef NRF_SDH_BLE_SERVICE_CHANGED +#define NRF_SDH_BLE_SERVICE_CHANGED 0 +#endif + +// +//========================================================== + +// BLE Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_BLE_OBSERVER_PRIO_LEVELS - Total number of priority levels for BLE observers. +// This setting configures the number of priority levels available for BLE event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 +#endif + +// BLE Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Advertising module. + +#ifndef BLE_ADV_BLE_OBSERVER_PRIO +#define BLE_ADV_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_ANCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Apple Notification Service Client. + +#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO +#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_ANS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Alert Notification Service Client. + +#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO +#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service. + +#ifndef BLE_BAS_BLE_OBSERVER_PRIO +#define BLE_BAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service Client. + +#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO +#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Blood Pressure Service. + +#ifndef BLE_BPS_BLE_OBSERVER_PRIO +#define BLE_BPS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection parameters module. + +#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_CONN_STATE_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection State module. + +#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO +#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 +#endif + +// BLE_CSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. + +#ifndef BLE_CSCS_BLE_OBSERVER_PRIO +#define BLE_CSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Current Time Service Client. + +#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO +#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DB_DISC_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Database Discovery module. + +#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO +#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_BLE_OBSERVER_PRIO +#define BLE_DFU_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_GLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Glucose Service. + +#ifndef BLE_GLS_BLE_OBSERVER_PRIO +#define BLE_GLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HIDS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Human Interface Device Service. + +#ifndef BLE_HIDS_BLE_OBSERVER_PRIO +#define BLE_HIDS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service. + +#ifndef BLE_HRS_BLE_OBSERVER_PRIO +#define BLE_HRS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service Client. + +#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO +#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Health Thermometer Service. + +#ifndef BLE_HTS_BLE_OBSERVER_PRIO +#define BLE_HTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service. + +#ifndef BLE_IAS_BLE_OBSERVER_PRIO +#define BLE_IAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service Client. + +#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO +#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service. + +#ifndef BLE_LBS_BLE_OBSERVER_PRIO +#define BLE_LBS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service Client. + +#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO +#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Link Loss Service. + +#ifndef BLE_LLS_BLE_OBSERVER_PRIO +#define BLE_LLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LNS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Location Navigation Service. + +#ifndef BLE_LNS_BLE_OBSERVER_PRIO +#define BLE_LNS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Service. + +#ifndef BLE_NUS_BLE_OBSERVER_PRIO +#define BLE_NUS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Central Service. + +#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO +#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service. + +#ifndef BLE_OTS_BLE_OBSERVER_PRIO +#define BLE_OTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service client. + +#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO +#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. + +#ifndef BLE_RSCS_BLE_OBSERVER_PRIO +#define BLE_RSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. + +#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO +#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_TPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the TX Power Service. + +#ifndef BLE_TPS_BLE_OBSERVER_PRIO +#define BLE_TPS_BLE_OBSERVER_PRIO 2 +#endif + +// BSP_BTN_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Button Control module. + +#ifndef BSP_BTN_BLE_OBSERVER_PRIO +#define BSP_BTN_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_BMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Bond Management Service. + +#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO +#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_CGMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. + +#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO +#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Service Client. + +#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATT_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT module. + +#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_QWR_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Queued writes module. + +#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO +#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. +#ifndef PM_BLE_OBSERVER_PRIO +#define PM_BLE_OBSERVER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler +//========================================================== +#ifndef NRF_SDH_ENABLED +#define NRF_SDH_ENABLED 0 +#endif +// Dispatch model + +// This setting configures how Stack events are dispatched to the application. +//========================================================== +// NRF_SDH_DISPATCH_MODEL + + +// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. +// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. +// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. +// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT +// <1=> NRF_SDH_DISPATCH_MODEL_APPSH +// <2=> NRF_SDH_DISPATCH_MODEL_POLLING + +#ifndef NRF_SDH_DISPATCH_MODEL +#define NRF_SDH_DISPATCH_MODEL 0 +#endif + +// +//========================================================== + +// Clock - SoftDevice clock configuration + +//========================================================== +// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. + +// <0=> NRF_CLOCK_LF_SRC_RC +// <1=> NRF_CLOCK_LF_SRC_XTAL +// <2=> NRF_CLOCK_LF_SRC_SYNTH + +#ifndef NRF_SDH_CLOCK_LF_SRC +#define NRF_SDH_CLOCK_LF_SRC 1 +#endif + +// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. +#ifndef NRF_SDH_CLOCK_LF_RC_CTIV +#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. +// How often (in number of calibration intervals) the RC oscillator shall be calibrated +// if the temperature has not changed. + +#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV +#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM + +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#endif + +// +//========================================================== + +// SDH Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_REQ_OBSERVER_PRIO_LEVELS - Total number of priority levels for request observers. +// This setting configures the number of priority levels available for the SoftDevice request event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_REQ_OBSERVER_PRIO_LEVELS +#define NRF_SDH_REQ_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STATE_OBSERVER_PRIO_LEVELS - Total number of priority levels for state observers. +// This setting configures the number of priority levels available for the SoftDevice state event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STATE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STATE_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STACK_OBSERVER_PRIO_LEVELS - Total number of priority levels for stack event observers. +// This setting configures the number of priority levels available for the SoftDevice stack event handlers (ANT, BLE, SoC). +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STACK_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 +#endif + + +// State Observers priorities - Invididual priorities + +//========================================================== +// CLOCK_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO +#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO +#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// RNG_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to this module. + +#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO +#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// Stack Event Observers priorities - Invididual priorities + +//========================================================== +// NRF_SDH_ANT_STACK_OBSERVER_PRIO +// This setting configures the priority with which ANT events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have ANT events dispatched before or after other stack events, such as BLE or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_ANT_STACK_OBSERVER_PRIO +#define NRF_SDH_ANT_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_BLE_STACK_OBSERVER_PRIO +// This setting configures the priority with which BLE events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have BLE events dispatched before or after other stack events, such as ANT or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_BLE_STACK_OBSERVER_PRIO +#define NRF_SDH_BLE_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_SOC_STACK_OBSERVER_PRIO +// This setting configures the priority with which SoC events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have SoC events dispatched before or after other stack events, such as ANT or BLE. +// Zero is the highest priority. + +#ifndef NRF_SDH_SOC_STACK_OBSERVER_PRIO +#define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler +//========================================================== +#ifndef NRF_SDH_SOC_ENABLED +#define NRF_SDH_SOC_ENABLED 0 +#endif +// SoC Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. +// This setting configures the number of priority levels available for the SoC event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS +#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 +#endif + +// SoC Observers priorities - Invididual priorities + +//========================================================== +// BLE_DFU_SOC_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_SOC_OBSERVER_PRIO +#define BLE_DFU_SOC_OBSERVER_PRIO 1 +#endif + +// CLOCK_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO +#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO +#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// +//========================================================== + +// <<< end of configuration section >>> +#endif //SDK_CONFIG_H + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/ses/flash_placement.xml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/ses/flash_placement.xml new file mode 100644 index 0000000..39c2e94 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/config/nrf52840/ses/flash_placement.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/bitops.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/bitops.h new file mode 100644 index 0000000..e2b9d55 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/bitops.h @@ -0,0 +1,290 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef BITOPS_H +#define BITOPS_H + +#include +#include + +/* Assorted bitwise and common operations used in ciphers. */ + +/** Circularly rotate right x by n bits. + * 0 > n > 32. */ +static inline uint32_t rotr32(uint32_t x, unsigned n) +{ + return (x >> n) | (x << (32 - n)); +} + +/** Circularly rotate left x by n bits. + * 0 > n > 32. */ +static inline uint32_t rotl32(uint32_t x, unsigned n) +{ + return (x << n) | (x >> (32 - n)); +} + +/** Circularly rotate right x by n bits. + * 0 > n > 64. */ +static inline uint64_t rotr64(uint64_t x, unsigned n) +{ + return (x >> n) | (x << (64 - n)); +} + +/** Circularly rotate left x by n bits. + * 0 > n > 64. */ +static inline uint64_t rotl64(uint64_t x, unsigned n) +{ + return (x << n) | (x >> (64 - n)); +} + +/** Read 4 bytes from buf, as a 32-bit big endian quantity. */ +static inline uint32_t read32_be(const uint8_t buf[4]) +{ + return (buf[0] << 24) | + (buf[1] << 16) | + (buf[2] << 8) | + (buf[3]); +} + +/** Read 4 bytes from buf, as a 32-bit little endian quantity. */ +static inline uint32_t read32_le(const uint8_t buf[4]) +{ + return (buf[3] << 24) | + (buf[2] << 16) | + (buf[1] << 8) | + (buf[0]); +} + +/** Read 8 bytes from buf, as a 64-bit big endian quantity. */ +static inline uint64_t read64_be(const uint8_t buf[8]) +{ + uint32_t hi = read32_be(buf), + lo = read32_be(buf + 4); + return ((uint64_t)hi) << 32 | + lo; +} + +/** Read 8 bytes from buf, as a 64-bit little endian quantity. */ +static inline uint64_t read64_le(const uint8_t buf[8]) +{ + uint32_t hi = read32_le(buf + 4), + lo = read32_le(buf); + return ((uint64_t)hi) << 32 | + lo; +} + +/** Encode v as a 32-bit big endian quantity into buf. */ +static inline void write32_be(uint32_t v, uint8_t buf[4]) +{ + *buf++ = (v >> 24) & 0xff; + *buf++ = (v >> 16) & 0xff; + *buf++ = (v >> 8) & 0xff; + *buf = v & 0xff; +} + +/** Encode v as a 32-bit little endian quantity into buf. */ +static inline void write32_le(uint32_t v, uint8_t buf[4]) +{ + *buf++ = v & 0xff; + *buf++ = (v >> 8) & 0xff; + *buf++ = (v >> 16) & 0xff; + *buf = (v >> 24) & 0xff; +} + +/** Encode v as a 64-bit big endian quantity into buf. */ +static inline void write64_be(uint64_t v, uint8_t buf[8]) +{ + *buf++ = (v >> 56) & 0xff; + *buf++ = (v >> 48) & 0xff; + *buf++ = (v >> 40) & 0xff; + *buf++ = (v >> 32) & 0xff; + *buf++ = (v >> 24) & 0xff; + *buf++ = (v >> 16) & 0xff; + *buf++ = (v >> 8) & 0xff; + *buf = v & 0xff; +} + +/** Encode v as a 64-bit little endian quantity into buf. */ +static inline void write64_le(uint64_t v, uint8_t buf[8]) +{ + *buf++ = v & 0xff; + *buf++ = (v >> 8) & 0xff; + *buf++ = (v >> 16) & 0xff; + *buf++ = (v >> 24) & 0xff; + *buf++ = (v >> 32) & 0xff; + *buf++ = (v >> 40) & 0xff; + *buf++ = (v >> 48) & 0xff; + *buf = (v >> 56) & 0xff; +} + +/** out = in ^ b8. + * out and in may alias. */ +static inline void xor_b8(uint8_t *out, const uint8_t *in, uint8_t b8, size_t len) +{ + for (size_t i = 0; i < len; i++) + out[i] = in[i] ^ b8; +} + +/** out = x ^ y. + * out, x and y may alias. */ +static inline void xor_bb(uint8_t *out, const uint8_t *x, const uint8_t *y, size_t len) +{ + for (size_t i = 0; i < len; i++) + out[i] = x[i] ^ y[i]; +} + +/* out ^= x + * out and x may alias. */ +static inline void xor_words(uint32_t *out, const uint32_t *x, size_t nwords) +{ + for (size_t i = 0; i < nwords; i++) + out[i] ^= x[i]; +} + +/** Produce 0xffffffff if x == y, zero otherwise, without branching. */ +static inline uint32_t mask_u32(uint32_t x, uint32_t y) +{ + uint32_t diff = x ^ y; + uint32_t diff_is_zero = ~diff & (diff - 1); + return - (diff_is_zero >> 31); +} + +/** Product 0xff if x == y, zero otherwise, without branching. */ +static inline uint8_t mask_u8(uint32_t x, uint32_t y) +{ + uint32_t diff = x ^ y; + uint8_t diff_is_zero = ~diff & (diff - 1); + return - (diff_is_zero >> 7); +} + +/** Select the ith entry from the given table of n values, in a side channel-silent + * way. */ +static inline uint32_t select_u32(uint32_t i, volatile const uint32_t *tab, uint32_t n) +{ + uint32_t r = 0; + + for (uint32_t ii = 0; ii < n; ii++) + { + uint32_t mask = mask_u32(i, ii); + r = (r & ~mask) | (tab[ii] & mask); + } + + return r; +} + +/** Select the ith entry from the given table of n values, in a side channel-silent + * way. */ +static inline uint8_t select_u8(uint32_t i, volatile const uint8_t *tab, uint32_t n) +{ + uint8_t r = 0; + + for (uint32_t ii = 0; ii < n; ii++) + { + uint8_t mask = mask_u8(i, ii); + r = (r & ~mask) | (tab[ii] & mask); + } + + return r; +} + +/** Select the ath, bth, cth and dth entries from the given table of n values, + * placing the results into a, b, c and d. */ +static inline void select_u8x4(uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d, + volatile const uint8_t *tab, uint32_t n) +{ + uint8_t ra = 0, + rb = 0, + rc = 0, + rd = 0; + uint8_t mask; + + for (uint32_t i = 0; i < n; i++) + { + uint8_t item = tab[i]; + + mask = mask_u8(*a, i); ra = (ra & ~mask) | (item & mask); + mask = mask_u8(*b, i); rb = (rb & ~mask) | (item & mask); + mask = mask_u8(*c, i); rc = (rc & ~mask) | (item & mask); + mask = mask_u8(*d, i); rd = (rd & ~mask) | (item & mask); + } + + *a = ra; + *b = rb; + *c = rc; + *d = rd; +} + +/** out ^= if0 or if1, depending on the value of bit. */ +static inline void select_xor128(uint32_t out[4], + const uint32_t if0[4], + const uint32_t if1[4], + uint8_t bit) +{ + uint32_t mask1 = mask_u32(bit, 1); + uint32_t mask0 = ~mask1; + + out[0] ^= (if0[0] & mask0) | (if1[0] & mask1); + out[1] ^= (if0[1] & mask0) | (if1[1] & mask1); + out[2] ^= (if0[2] & mask0) | (if1[2] & mask1); + out[3] ^= (if0[3] & mask0) | (if1[3] & mask1); +} + +/** Increments the integer stored at v (of non-zero length len) + * with the least significant byte first. */ +static inline void incr_le(uint8_t *v, size_t len) +{ + size_t i = 0; + while (1) + { + if (++v[i] != 0) + return; + i++; + if (i == len) + return; + } +} + +/** Increments the integer stored at v (of non-zero length len) + * with the most significant byte last. */ +static inline void incr_be(uint8_t *v, size_t len) +{ + len--; + while (1) + { + if (++v[len] != 0) + return; + if (len == 0) + return; + len--; + } +} + +/** Copies len bytes from in to out, with in shifted left by offset bits + * to the right. */ +static inline void copy_bytes_unaligned(uint8_t *out, const uint8_t *in, size_t len, uint8_t offset) +{ + uint8_t byte_off = offset / 8; + uint8_t bit_off = offset & 7; + uint8_t rmask = (1 << bit_off) - 1; + uint8_t lmask = ~rmask; + + for (size_t i = 0; i < len; i++) + { + out[i] = (in[i + byte_off] << bit_off) & lmask; + out[i] |= (in[i + byte_off + 1] >> (8 - bit_off)) & rmask; + } +} + + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.c new file mode 100644 index 0000000..c65f1a2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.c @@ -0,0 +1,197 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#include "blockwise.h" +#include "bitops.h" +#include "tassert.h" +#include + +#ifndef MIN + #define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +void cf_blockwise_accumulate(uint8_t *partial, size_t *npartial, size_t nblock, + const void *inp, size_t nbytes, + cf_blockwise_in_fn process, + void *ctx) +{ + cf_blockwise_accumulate_final(partial, npartial, nblock, + inp, nbytes, + process, process, ctx); +} + +void cf_blockwise_accumulate_final(uint8_t *partial, size_t *npartial, size_t nblock, + const void *inp, size_t nbytes, + cf_blockwise_in_fn process, + cf_blockwise_in_fn process_final, + void *ctx) +{ + const uint8_t *bufin = inp; + assert(partial && *npartial < nblock); + assert(inp || !nbytes); + assert(process && ctx); + + /* If we have partial data, copy in to buffer. */ + if (*npartial && nbytes) + { + size_t space = nblock - *npartial; + size_t taken = MIN(space, nbytes); + + memcpy(partial + *npartial, bufin, taken); + + bufin += taken; + nbytes -= taken; + *npartial += taken; + + /* If that gives us a full block, process it. */ + if (*npartial == nblock) + { + if (nbytes == 0) + process_final(ctx, partial); + else + process(ctx, partial); + *npartial = 0; + } + } + + /* now nbytes < nblock or *npartial == 0. */ + + /* If we have a full block of data, process it directly. */ + while (nbytes >= nblock) + { + /* Partial buffer must be empty, or we're ignoring extant data */ + assert(*npartial == 0); + + if (nbytes == nblock) + process_final(ctx, bufin); + else + process(ctx, bufin); + bufin += nblock; + nbytes -= nblock; + } + + /* Finally, if we have remaining data, buffer it. */ + while (nbytes) + { + size_t space = nblock - *npartial; + size_t taken = MIN(space, nbytes); + + memcpy(partial + *npartial, bufin, taken); + + bufin += taken; + nbytes -= taken; + *npartial += taken; + + /* If we started with *npartial, we must have copied it + * in first. */ + assert(*npartial < nblock); + } +} + +void cf_blockwise_xor(uint8_t *partial, size_t *npartial, size_t nblock, + const void *inp, void *outp, size_t nbytes, + cf_blockwise_out_fn process, void *ctx) +{ + const uint8_t *inb = inp; + uint8_t *outb = outp; + + assert(partial && *npartial < nblock); + assert(inp || !nbytes); + assert(process && ctx); + + while (nbytes) + { + /* If we're out of material, and need more, produce a block. */ + if (*npartial == 0) + { + process(ctx, partial); + *npartial = nblock; + } + + size_t offset = nblock - *npartial; + size_t taken = MIN(*npartial, nbytes); + xor_bb(outb, inb, partial + offset, taken); + *npartial -= taken; + nbytes -= taken; + outb += taken; + inb += taken; + } +} + +void cf_blockwise_acc_byte(uint8_t *partial, size_t *npartial, + size_t nblock, + uint8_t byte, size_t nbytes, + cf_blockwise_in_fn process, + void *ctx) +{ + /* only memset the whole of the block once */ + int filled = 0; + + while (nbytes) + { + size_t start = *npartial; + size_t count = MIN(nbytes, nblock - start); + + if (!filled) + memset(partial + start, byte, count); + + if (start == 0 && count == nblock) + filled = 1; + + if (start + count == nblock) + { + process(ctx, partial); + *npartial = 0; + } else { + *npartial += count; + } + + nbytes -= count; + } +} + +void cf_blockwise_acc_pad(uint8_t *partial, size_t *npartial, + size_t nblock, + uint8_t fbyte, uint8_t mbyte, uint8_t lbyte, + size_t nbytes, + cf_blockwise_in_fn process, + void *ctx) +{ + + switch (nbytes) + { + case 0: break; + case 1: fbyte ^= lbyte; + cf_blockwise_accumulate(partial, npartial, nblock, &fbyte, 1, process, ctx); + break; + case 2: + cf_blockwise_accumulate(partial, npartial, nblock, &fbyte, 1, process, ctx); + cf_blockwise_accumulate(partial, npartial, nblock, &lbyte, 1, process, ctx); + break; + default: + cf_blockwise_accumulate(partial, npartial, nblock, &fbyte, 1, process, ctx); + + /* If the middle and last bytes differ, then process the last byte separately. + * Otherwise, just extend the middle block size. */ + if (lbyte != mbyte) + { + cf_blockwise_acc_byte(partial, npartial, nblock, mbyte, nbytes - 2, process, ctx); + cf_blockwise_accumulate(partial, npartial, nblock, &lbyte, 1, process, ctx); + } else { + cf_blockwise_acc_byte(partial, npartial, nblock, mbyte, nbytes - 1, process, ctx); + } + + break; + } +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.h new file mode 100644 index 0000000..a20ff95 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/blockwise.h @@ -0,0 +1,147 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef BLOCKWISE_H +#define BLOCKWISE_H + +#include +#include + +/* Processing function for cf_blockwise_accumulate. */ +typedef void (*cf_blockwise_in_fn)(void *ctx, const uint8_t *data); + +/* Processing function for cf_blockwise_xor. */ +typedef void (*cf_blockwise_out_fn)(void *ctx, uint8_t *data); + +/* This function manages the common abstraction of accumulating input in + * a buffer, and processing it when a full block is available. + * + * partial is the buffer (maintained by the caller) + * on entry, npartial is the currently valid count of used bytes on + * the front of partial. + * on exit, npartial is updated to reflect the status of partial. + * nblock is the blocksize to accumulate -- partial must be at least + * this long! + * input is the new data to process, of length nbytes. + * process is the processing function, passed ctx and a pointer + * to the data to process (always exactly nblock bytes long!) + * which may not neccessarily be the same as partial. + */ +void cf_blockwise_accumulate(uint8_t *partial, size_t *npartial, + size_t nblock, + const void *input, size_t nbytes, + cf_blockwise_in_fn process, + void *ctx); + +/* This function manages the common abstraction of accumulating input in + * a buffer, and processing it when a full block is available. + * This version supports calling a different processing function for + * the last block. + * + * partial is the buffer (maintained by the caller) + * on entry, npartial is the currently valid count of used bytes on + * the front of partial. + * on exit, npartial is updated to reflect the status of partial. + * nblock is the blocksize to accumulate -- partial must be at least + * this long! + * input is the new data to process, of length nbytes. + * process is the processing function, passed ctx and a pointer + * to the data to process (always exactly nblock bytes long!) + * which may not neccessarily be the same as partial. + * process_final is called last (but may not be called at all if + * all input is buffered). + */ +void cf_blockwise_accumulate_final(uint8_t *partial, size_t *npartial, + size_t nblock, + const void *input, size_t nbytes, + cf_blockwise_in_fn process, + cf_blockwise_in_fn process_final, + void *ctx); + +/* This function manages XORing an input stream with a keystream + * to produce an output stream. The keystream is produced in blocks + * (ala a block cipher in counter mode). + * + * partial is the keystream buffer (maintained by the caller) + * on entry, *npartial is the currently valid count of bytes in partial: + * unused bytes are at the *end*. So *npartial = 4 means the last four + * bytes of partial are usable as keystream. + * on exit, npartial is updated to reflect the new state of partial. + * nblock is the blocksize to accumulate -- partial must be at least + * this long! + * input is the new data to process, of length nbytes. + * output is where to write input xored with the keystream -- also length + * nbytes. + * process is the processing function, passed ctx and partial which it + * should fill with fresh key stream. + */ +void cf_blockwise_xor(uint8_t *partial, size_t *npartial, + size_t nblock, + const void *input, void *output, size_t nbytes, + cf_blockwise_out_fn newblock, + void *ctx); + +/* This function processes a single byte a number of times. It's useful + * for padding, and more efficient than calling cf_blockwise_accumulate + * a bunch of times. + * + * partial is the buffer (maintained by the caller) + * on entry, npartial is the currently valid count of used bytes on + * the front of partial. + * on exit, npartial is updated to reflect the status of partial. + * nblock is the blocksize to accumulate -- partial must be at least + * this long! + * process is the processing function, passed ctx and a pointer + * to the data to process (always exactly nblock bytes long!) + * which may not neccessarily be the same as partial. + * byte is the byte to process, nbytes times. + */ +void cf_blockwise_acc_byte(uint8_t *partial, size_t *npartial, + size_t nblock, + uint8_t byte, size_t nbytes, + cf_blockwise_in_fn process, + void *ctx); + +/* This function attempts to process patterns of bytes common in + * block cipher padding. + * + * This takes three bytes: + * - a first byte, fbyte, + * - a middle byte, mbyte, + * - a last byte, lbyte. + * + * If nbytes is zero, nothing happens. + * If nbytes is one, the byte fbyte ^ lbyte is processed. + * If nbytes is two, the fbyte then lbyte are processed. + * If nbytes is three or more, fbyte, then one or more mbytes, then fbyte + * is processed. + * + * partial is the buffer (maintained by the caller) + * on entry, npartial is the currently valid count of used bytes on + * the front of partial. + * on exit, npartial is updated to reflect the status of partial. + * nblock is the blocksize to accumulate -- partial must be at least + * this long! + * process is the processing function, passed ctx and a pointer + * to the data to process (always exactly nblock bytes long!) + * which may not neccessarily be the same as partial. + */ +void cf_blockwise_acc_pad(uint8_t *partial, size_t *npartial, + size_t nblock, + uint8_t fbyte, uint8_t mbyte, uint8_t lbyte, + size_t nbytes, + cf_blockwise_in_fn process, + void *ctx); + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cf_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cf_config.h new file mode 100644 index 0000000..ceb7e8d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cf_config.h @@ -0,0 +1,59 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef CF_CONFIG_H +#define CF_CONFIG_H + +/** + * Library configuration + * ===================== + */ + +/* .. c:macro:: CF_SIDE_CHANNEL_PROTECTION + * Define this as 1 if you need all available side channel protections. + * **This option may alter the ABI**. + * + * This has a non-trivial performance penalty. Where a + * side-channel free option is cheap or free (like checking + * a MAC) this is always done in a side-channel free way. + * + * The default is **on** for all available protections. + */ +#ifndef CF_SIDE_CHANNEL_PROTECTION +# define CF_SIDE_CHANNEL_PROTECTION 1 +#endif + +/* .. c:macro:: CF_TIME_SIDE_CHANNEL_PROTECTION + * Define this as 1 if you need timing/branch prediction side channel + * protection. + * + * You probably want this. The default is on. */ +#ifndef CF_TIME_SIDE_CHANNEL_PROTECTION +# define CF_TIME_SIDE_CHANNEL_PROTECTION CF_SIDE_CHANNEL_PROTECTION +#endif + +/* .. c:macro:: CF_CACHE_SIDE_CHANNEL_PROTECTION + * Define this as 1 if you need cache side channel protection. + * + * If you have a microcontroller with no cache, you can turn this off + * without negative effects. + * + * The default is on. This will have some performance impact, + * especially on AES. + */ +#ifndef CF_CACHE_SIDE_CHANNEL_PROTECTION +# define CF_CACHE_SIDE_CHANNEL_PROTECTION CF_SIDE_CHANNEL_PROTECTION +#endif + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_cmac.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_cmac.c new file mode 100644 index 0000000..51f5843 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_cmac.c @@ -0,0 +1,150 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#include "handy.h" +#include "prp.h" +#include "modes.h" +#include "bitops.h" +#include "blockwise.h" +#include "gf128.h" +#include "tassert.h" + +#include + +void cf_cmac_init(cf_cmac *ctx, const cf_prp *prp, void *prpctx) +{ + uint8_t L[CF_MAXBLOCK]; + assert(prp->blocksz == 16); + + mem_clean(ctx, sizeof *ctx); + + /* L = E_K(0^n) */ + mem_clean(L, prp->blocksz); + prp->encrypt(prpctx, L, L); + + /* B = 2L */ + cf_gf128 gf; + cf_gf128_frombytes_be(L, gf); + cf_gf128_double(gf, gf); + cf_gf128_tobytes_be(gf, ctx->B); + + /* P = 4L */ + cf_gf128_double(gf, gf); + cf_gf128_tobytes_be(gf, ctx->P); + + ctx->prp = prp; + ctx->prpctx = prpctx; +} + +void cf_cmac_sign(cf_cmac *ctx, const uint8_t *data, size_t len, uint8_t out[CF_MAXBLOCK]) +{ + cf_cmac_stream stream; + stream.cmac = *ctx; + cf_cmac_stream_reset(&stream); + cf_cmac_stream_update(&stream, data, len, 1); + cf_cmac_stream_final(&stream, out); +} + +void cf_cmac_stream_init(cf_cmac_stream *ctx, const cf_prp *prp, void *prpctx) +{ + cf_cmac_init(&ctx->cmac, prp, prpctx); + cf_cmac_stream_reset(ctx); +} + +void cf_cmac_stream_reset(cf_cmac_stream *ctx) +{ + uint8_t iv_zero[CF_MAXBLOCK] = { 0 }; + cf_cbc_init(&ctx->cbc, ctx->cmac.prp, ctx->cmac.prpctx, iv_zero); + mem_clean(ctx->buffer, sizeof ctx->buffer); + ctx->used = 0; + ctx->processed = 0; + ctx->finalised = 0; +} + +static void cmac_process(void *vctx, const uint8_t *block) +{ + cf_cmac_stream *ctx = vctx; + uint8_t output[CF_MAXBLOCK]; + cf_cbc_encrypt(&ctx->cbc, block, output, 1); + ctx->processed += ctx->cmac.prp->blocksz; +} + +static void cmac_process_final(cf_cmac_stream *ctx, const uint8_t *block, + const uint8_t *xor) +{ + uint8_t input[CF_MAXBLOCK]; + uint8_t output[CF_MAXBLOCK]; + xor_bb(input, block, xor, ctx->cmac.prp->blocksz); + cf_cbc_encrypt(&ctx->cbc, input, output, 1); + ctx->processed += ctx->cmac.prp->blocksz; + /* signature is in ctx->cbc.block. */ +} + +static void cmac_process_final_nopad(void *vctx, const uint8_t *block) +{ + cf_cmac_stream *ctx = vctx; + cmac_process_final(ctx, block, ctx->cmac.B); + ctx->finalised = 1; +} + +static void cmac_process_final_pad(void *vctx, const uint8_t *block) +{ + cf_cmac_stream *ctx = vctx; + cmac_process_final(ctx, block, ctx->cmac.P); + ctx->finalised = 1; +} + +void cf_cmac_stream_update(cf_cmac_stream *ctx, const uint8_t *data, size_t len, int isfinal) +{ + size_t blocksz = ctx->cmac.prp->blocksz; + cf_blockwise_in_fn final_fn = cmac_process; + int needpad = 0; + + if (isfinal) + { + int whole_number_of_blocks = ((len + ctx->used) & 0xf) == 0; + int empty_message = len == 0 && ctx->used == 0 && ctx->processed == 0; + + assert(!ctx->finalised); /* finalised before? */ + assert(len != 0 || empty_message); /* we can't be told we're done after the fact. */ + + /* If we have a whole number of blocks, and at least 1 block, we XOR in B. + * Otherwise, we need to pad and XOR in P. */ + if (whole_number_of_blocks && !empty_message) + final_fn = cmac_process_final_nopad; + else + needpad = 1; + } + + /* Input data */ + cf_blockwise_accumulate_final(ctx->buffer, &ctx->used, blocksz, + data, len, + cmac_process, + final_fn, ctx); + + /* Input padding */ + if (needpad) + { + cf_blockwise_acc_pad(ctx->buffer, &ctx->used, blocksz, + 0x80, 0x00, 0x00, blocksz - ctx->used, + cmac_process_final_pad, ctx); + } +} + +void cf_cmac_stream_final(cf_cmac_stream *ctx, uint8_t out[CF_MAXBLOCK]) +{ + assert(ctx->finalised); + memcpy(out, ctx->cbc.block, ctx->cmac.prp->blocksz); +} + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.c new file mode 100644 index 0000000..c4e01b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.c @@ -0,0 +1,416 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#include +#include +#include "handy.h" +#include "cf_config.h" +#include "cifra_eax_aes.h" +#include "bitops.h" +#include "tassert.h" + +static const uint8_t S[256] = +{ + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, + 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, + 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, + 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, + 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, + 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, + 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, + 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, + 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, + 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, + 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, + 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, + 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, + 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, + 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, + 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, + 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, + 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, + 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 +}; + +static const uint8_t Rcon[11] = +{ + 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 +}; + +#ifdef INLINE_FUNCS +static inline uint32_t word4(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) +{ + return b0 << 24 | b1 << 16 | b2 << 8 | b3; +} + +static inline uint8_t byte(uint32_t w, unsigned x) +{ + /* nb. bytes are numbered 0 (leftmost, top) + * to 3 (rightmost). */ + x = 3 - x; + return (w >> (x * 8)) & 0xff; +} + +static uint32_t round_constant(uint32_t i) +{ + return Rcon[i] << 24; +} + +static uint32_t rot_word(uint32_t w) +{ + /* Takes + * word [a0,a1,a2,a3] + * returns + * word [a1,a2,a3,a0] + * + */ + return rotl32(w, 8); +} +#endif + +#define word4(a, b, c, d) (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | (d)) +#define byte(w, x) ((w >> ((3 - (x)) << 3)) & 0xff) +#define round_constant(i) ((uint32_t)(Rcon[i]) << 24) +#define rot_word(w) rotl32((w), 8) + +static uint32_t sub_word(uint32_t w, const uint8_t *sbox) +{ + uint8_t a = byte(w, 0), + b = byte(w, 1), + c = byte(w, 2), + d = byte(w, 3); +#if CF_CACHE_SIDE_CHANNEL_PROTECTION + select_u8x4(&a, &b, &c, &d, sbox, 256); +#else + a = sbox[a]; + b = sbox[b]; + c = sbox[c]; + d = sbox[d]; +#endif + return word4(a, b, c, d); +} + +static void aes_schedule(cf_aes_context *ctx, const uint8_t *key, size_t nkey) +{ + size_t i, + nb = AES_BLOCKSZ / 4, + nk = nkey / 4, + n = nb * (ctx->rounds + 1); + uint32_t *w = ctx->ks; + + /* First words are just the key. */ + for (i = 0; i < nk; i++) + { + w[i] = read32_be(key + i * 4); + } + + uint32_t i_div_nk = 1; + uint32_t i_mod_nk = 0; + + for (; i < n; i++, i_mod_nk++) + { + uint32_t temp = w[i - 1]; + + if (i_mod_nk == nk) + { + i_div_nk++; + i_mod_nk = 0; + } + + if (i_mod_nk == 0) + temp = sub_word(rot_word(temp), S) ^ round_constant(i_div_nk); + else if (nk > 6 && i_mod_nk == 4) + temp = sub_word(temp, S); + + w[i] = w[i - nk] ^ temp; + } +} + +void cf_aes_init(cf_aes_context *ctx, const uint8_t *key, size_t nkey) +{ + memset(ctx, 0, sizeof *ctx); + + switch (nkey) + { +#if CF_AES_MAXROUNDS >= AES128_ROUNDS + case 16: + ctx->rounds = AES128_ROUNDS; + aes_schedule(ctx, key, nkey); + break; +#endif + +#if CF_AES_MAXROUNDS >= AES192_ROUNDS + case 24: + ctx->rounds = AES192_ROUNDS; + aes_schedule(ctx, key, nkey); + break; +#endif + +#if CF_AES_MAXROUNDS >= AES256_ROUNDS + case 32: + ctx->rounds = AES256_ROUNDS; + aes_schedule(ctx, key, nkey); + break; +#endif + + default: + abort(); + } +} + +static void add_round_key(uint32_t state[4], const uint32_t rk[4]) +{ + state[0] ^= rk[0]; + state[1] ^= rk[1]; + state[2] ^= rk[2]; + state[3] ^= rk[3]; +} + +static void sub_block(uint32_t state[4]) +{ + state[0] = sub_word(state[0], S); + state[1] = sub_word(state[1], S); + state[2] = sub_word(state[2], S); + state[3] = sub_word(state[3], S); +} + +static void shift_rows(uint32_t state[4]) +{ + uint32_t u, v, x, y; + + u = word4(byte(state[0], 0), + byte(state[1], 1), + byte(state[2], 2), + byte(state[3], 3)); + + v = word4(byte(state[1], 0), + byte(state[2], 1), + byte(state[3], 2), + byte(state[0], 3)); + + x = word4(byte(state[2], 0), + byte(state[3], 1), + byte(state[0], 2), + byte(state[1], 3)); + + y = word4(byte(state[3], 0), + byte(state[0], 1), + byte(state[1], 2), + byte(state[2], 3)); + + state[0] = u; + state[1] = v; + state[2] = x; + state[3] = y; +} + +static uint32_t gf_poly_mul2(uint32_t x) +{ + return + ((x & 0x7f7f7f7f) << 1) ^ + (((x & 0x80808080) >> 7) * 0x1b); +} + +static uint32_t mix_column(uint32_t x) +{ + uint32_t x2 = gf_poly_mul2(x); + return x2 ^ rotr32(x ^ x2, 24) ^ rotr32(x, 16) ^ rotr32(x, 8); +} + +static void mix_columns(uint32_t state[4]) +{ + state[0] = mix_column(state[0]); + state[1] = mix_column(state[1]); + state[2] = mix_column(state[2]); + state[3] = mix_column(state[3]); +} + +void cf_aes_encrypt(const cf_aes_context *ctx, + const uint8_t in[AES_BLOCKSZ], + uint8_t out[AES_BLOCKSZ]) +{ + assert(ctx->rounds == AES128_ROUNDS || + ctx->rounds == AES192_ROUNDS || + ctx->rounds == AES256_ROUNDS); + + uint32_t state[4] = { + read32_be(in + 0), + read32_be(in + 4), + read32_be(in + 8), + read32_be(in + 12) + }; + + const uint32_t *round_keys = ctx->ks; + add_round_key(state, round_keys); + round_keys += 4; + + for (uint32_t round = 1; round < ctx->rounds; round++) + { + sub_block(state); + shift_rows(state); + mix_columns(state); + add_round_key(state, round_keys); + round_keys += 4; + } + + sub_block(state); + shift_rows(state); + add_round_key(state, round_keys); + + write32_be(state[0], out + 0); + write32_be(state[1], out + 4); + write32_be(state[2], out + 8); + write32_be(state[3], out + 12); +} + +#if CF_AES_ENCRYPT_ONLY == 0 +static const uint8_t S_inv[256] = +{ + 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, + 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, + 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, + 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, + 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, + 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, + 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, + 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, + 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, + 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, + 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, + 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, + 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, + 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, + 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, + 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, + 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, + 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, + 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, + 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d +}; + +static void inv_sub_block(uint32_t state[4]) +{ + state[0] = sub_word(state[0], S_inv); + state[1] = sub_word(state[1], S_inv); + state[2] = sub_word(state[2], S_inv); + state[3] = sub_word(state[3], S_inv); +} + +static void inv_shift_rows(uint32_t state[4]) +{ + uint32_t u, v, x, y; + + u = word4(byte(state[0], 0), + byte(state[3], 1), + byte(state[2], 2), + byte(state[1], 3)); + + v = word4(byte(state[1], 0), + byte(state[0], 1), + byte(state[3], 2), + byte(state[2], 3)); + + x = word4(byte(state[2], 0), + byte(state[1], 1), + byte(state[0], 2), + byte(state[3], 3)); + + y = word4(byte(state[3], 0), + byte(state[2], 1), + byte(state[1], 2), + byte(state[0], 3)); + + state[0] = u; + state[1] = v; + state[2] = x; + state[3] = y; +} + +static uint32_t inv_mix_column(uint32_t x) +{ + uint32_t x2 = gf_poly_mul2(x), + x4 = gf_poly_mul2(x2), + x9 = x ^ gf_poly_mul2(x4), + x11 = x2 ^ x9, + x13 = x4 ^ x9; + + return x ^ x2 ^ x13 ^ rotr32(x11, 24) ^ rotr32(x13, 16) ^ rotr32(x9, 8); +} + +static void inv_mix_columns(uint32_t state[4]) +{ + state[0] = inv_mix_column(state[0]); + state[1] = inv_mix_column(state[1]); + state[2] = inv_mix_column(state[2]); + state[3] = inv_mix_column(state[3]); +} + +void cf_aes_decrypt(const cf_aes_context *ctx, + const uint8_t in[AES_BLOCKSZ], + uint8_t out[AES_BLOCKSZ]) +{ + assert(ctx->rounds == AES128_ROUNDS || + ctx->rounds == AES192_ROUNDS || + ctx->rounds == AES256_ROUNDS); + + uint32_t state[4] = { + read32_be(in + 0), + read32_be(in + 4), + read32_be(in + 8), + read32_be(in + 12) + }; + + const uint32_t *round_keys = &ctx->ks[ctx->rounds << 2]; + add_round_key(state, round_keys); + round_keys -= 4; + + for (uint32_t round = ctx->rounds - 1; round != 0; round--) + { + inv_shift_rows(state); + inv_sub_block(state); + add_round_key(state, round_keys); + inv_mix_columns(state); + round_keys -= 4; + } + + inv_shift_rows(state); + inv_sub_block(state); + add_round_key(state, round_keys); + + write32_be(state[0], out + 0); + write32_be(state[1], out + 4); + write32_be(state[2], out + 8); + write32_be(state[3], out + 12); +} +#else +void cf_aes_decrypt(const cf_aes_context *ctx, + const uint8_t in[AES_BLOCKSZ], + uint8_t out[AES_BLOCKSZ]) +{ + abort(); +} +#endif + +void cf_aes_finish(cf_aes_context *ctx) +{ + mem_clean(ctx, sizeof *ctx); +} + +const cf_prp cf_aes = { + .blocksz = AES_BLOCKSZ, + .encrypt = (cf_prp_block) cf_aes_encrypt, + .decrypt = (cf_prp_block) cf_aes_decrypt +}; + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.h new file mode 100644 index 0000000..2ee7f46 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/cifra_eax_aes.h @@ -0,0 +1,152 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +/** + * The AES block cipher + * ==================== + * + * This is a small, simple implementation of AES. Key expansion is done + * first, filling in a :c:type:`cf_aes_context`. Then encryption and + * decryption can be performed as desired. + * + * Usually you don't want to use AES directly; you should use it via + * a :doc:`block cipher mode `. + */ + +#ifndef AES_H +#define AES_H + +#include +#include + +#include "prp.h" + +/* .. c:macro:: AES_BLOCKSZ + * AES has a 128-bit block size. This quantity is in bytes. + */ +#define AES_BLOCKSZ 16 + +/* --- Size configuration --- */ + +/* .. c:macro:: AES128_ROUNDS + * .. c:macro:: AES192_ROUNDS + * .. c:macro:: AES256_ROUNDS + * + * Round counts for different key sizes. + */ +#define AES128_ROUNDS 10 +#define AES192_ROUNDS 12 +#define AES256_ROUNDS 14 + +/* .. c:macro:: CF_AES_MAXROUNDS + * + * You can reduce the maximum number of rounds this implementation + * supports. This reduces the storage needed by :c:type:`cf_aes_context`. + * + * The default is :c:macro:`AES256_ROUNDS` and is good for all key + * sizes. + */ +#ifndef CF_AES_MAXROUNDS +# define CF_AES_MAXROUNDS AES256_ROUNDS +#endif + +/* .. c:macro:: CF_AES_ENCRYPT_ONLY + * + * Define this to 1 if you don't need to decrypt anything. + * This saves space. :c:func:`cf_aes_decrypt` calls `abort(3)`. + */ +#ifndef CF_AES_ENCRYPT_ONLY +# define CF_AES_ENCRYPT_ONLY 0 +#endif + +/* .. c:type:: cf_aes_context + * This type represents an expanded AES key. Create one + * using :c:func:`cf_aes_init`, make use of one using + * :c:func:`cf_aes_encrypt` or :c:func:`cf_aes_decrypt`. + * + * The contents of this structure are equivalent to the + * original key material. You should clean the + * contents of this structure with :c:func:`cf_aes_finish` + * when you're done. + * + * .. c:member:: cf_aes_context.rounds + * + * Number of rounds to use, set by :c:func:`cf_aes_init`. + * + * This depends on the original key size, and will be + * :c:macro:`AES128_ROUNDS`, :c:macro:`AES192_ROUNDS` or + * :c:macro:`AES256_ROUNDS`. + * + * .. c:member:: cf_aes_context.ks + * + * Expanded key material. Filled in by :c:func:`cf_aes_init`. + */ +typedef struct +{ + uint32_t rounds; + uint32_t ks[AES_BLOCKSZ / 4 * (CF_AES_MAXROUNDS + 1)]; +} cf_aes_context; + +/* .. c:function:: $DECL + * This function does AES key expansion. It destroys + * existing contents of :c:data:`ctx`. + * + * :param ctx: expanded key context, filled in by this function. + * :param key: pointer to key material, of :c:data:`nkey` bytes. + * :param nkey: length of key material. Must be `16`, `24` or `32`. + */ +extern void cf_aes_init(cf_aes_context *ctx, + const uint8_t *key, + size_t nkey); + +/* .. c:function:: $DECL + * Encrypts the given block, from :c:data:`in` to :c:data:`out`. + * These may alias. + * + * Fails at runtime if :c:data:`ctx` is invalid. + * + * :param ctx: expanded key context + * :param in: input block (read) + * :param out: output block (written) + */ +extern void cf_aes_encrypt(const cf_aes_context *ctx, + const uint8_t in[AES_BLOCKSZ], + uint8_t out[AES_BLOCKSZ]); + +/* .. c:function:: $DECL + * Decrypts the given block, from :c:data:`in` to :c:data:`out`. + * These may alias. + * + * Fails at runtime if :c:data:`ctx` is invalid. + * + * :param ctx: expanded key context + * :param in: input block (read) + * :param out: output block (written) + */ +extern void cf_aes_decrypt(const cf_aes_context *ctx, + const uint8_t in[AES_BLOCKSZ], + uint8_t out[AES_BLOCKSZ]); + +/* .. c:function:: $DECL + * Erase scheduled key material. + * + * Call this when you're done to erase the round keys. */ +extern void cf_aes_finish(cf_aes_context *ctx); + +/* .. c:var:: const cf_prp cf_aes + * Abstract interface to AES. See :c:type:`cf_prp` for + * more information. */ +extern const cf_prp cf_aes; + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/eax.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/eax.c new file mode 100644 index 0000000..ac5e392 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/eax.c @@ -0,0 +1,115 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#include "prp.h" +#include "modes.h" +#include "tassert.h" +#include "handy.h" +#include + +static void cmac_compute_n(cf_cmac_stream *ctx, + uint8_t t, + const uint8_t *input, size_t ninput, + uint8_t out[CF_MAXBLOCK]) +{ + size_t blocksz = ctx->cmac.prp->blocksz; + assert(blocksz > 0); + + uint8_t firstblock[CF_MAXBLOCK]; + memset(firstblock, 0, blocksz); + firstblock[blocksz - 1] = t; + + cf_cmac_stream_reset(ctx); + if (ninput) + { + cf_cmac_stream_update(ctx, firstblock, blocksz, 0); + cf_cmac_stream_update(ctx, input, ninput, 1); + } else { + cf_cmac_stream_update(ctx, firstblock, blocksz, 1); + } + + cf_cmac_stream_final(ctx, out); +} + +void cf_eax_encrypt(const cf_prp *prp, void *prpctx, + const uint8_t *plain, size_t nplain, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + uint8_t *cipher, /* the same size as nplain */ + uint8_t *tag, size_t ntag) +{ + uint8_t NN[CF_MAXBLOCK], + HH[CF_MAXBLOCK], + CC[CF_MAXBLOCK]; + + cf_cmac_stream cmac; + cf_cmac_stream_init(&cmac, prp, prpctx); + + /* NN = OMAC_K^0(N) */ + cmac_compute_n(&cmac, 0, nonce, nnonce, NN); + + /* HH = OMAC_K^1(H) */ + cmac_compute_n(&cmac, 1, header, nheader, HH); + + /* C = CTR_K^NN(M) */ + cf_ctr ctr; + cf_ctr_init(&ctr, prp, prpctx, NN); + cf_ctr_cipher(&ctr, plain, cipher, nplain); + + /* CC = OMAC_K^2(C) */ + cmac_compute_n(&cmac, 2, cipher, nplain, CC); + + /* Tag = NN ^ CC ^ HH + * T = Tag [ first tau bits ] */ + assert(ntag <= prp->blocksz); + for (size_t i = 0; i < ntag; i++) + tag[i] = NN[i] ^ CC[i] ^ HH[i]; +} + +int cf_eax_decrypt(const cf_prp *prp, void *prpctx, + const uint8_t *cipher, size_t ncipher, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + const uint8_t *tag, size_t ntag, + uint8_t *plain) /* the same size as ncipher */ +{ + uint8_t NN[CF_MAXBLOCK], + HH[CF_MAXBLOCK], + CC[CF_MAXBLOCK]; + + cf_cmac_stream cmac; + cf_cmac_stream_init(&cmac, prp, prpctx); + + /* NN = OMAC_K^0(N) */ + cmac_compute_n(&cmac, 0, nonce, nnonce, NN); + + /* HH = OMAC_K^1(H) */ + cmac_compute_n(&cmac, 1, header, nheader, HH); + + /* CC = OMAC_K^2(C) */ + cmac_compute_n(&cmac, 2, cipher, ncipher, CC); + + uint8_t tt[CF_MAXBLOCK]; + assert(ntag && ntag <= prp->blocksz); + for (size_t i = 0; i < ntag; i++) + tt[i] = NN[i] ^ CC[i] ^ HH[i]; + + if (!mem_eq(tt, tag, ntag)) + return 1; + + cf_ctr ctr; + cf_ctr_init(&ctr, prp, prpctx, NN); + cf_ctr_cipher(&ctr, cipher, plain, ncipher); + return 0; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.c new file mode 100644 index 0000000..b957cea --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.c @@ -0,0 +1,113 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#include "cf_config.h" +#include "gf128.h" +#include "bitops.h" + +#include + +void cf_gf128_tobytes_be(const cf_gf128 in, uint8_t out[16]) +{ + write32_be(in[0], out + 0); + write32_be(in[1], out + 4); + write32_be(in[2], out + 8); + write32_be(in[3], out + 12); +} + +void cf_gf128_frombytes_be(const uint8_t in[16], cf_gf128 out) +{ + out[0] = read32_be(in + 0); + out[1] = read32_be(in + 4); + out[2] = read32_be(in + 8); + out[3] = read32_be(in + 12); +} + +/* out = 2 * in. Arguments may alias. */ +void cf_gf128_double(const cf_gf128 in, cf_gf128 out) +{ + uint8_t table[2] = { 0x00, 0x87 }; + uint32_t borrow = 0; + uint32_t inword; + + inword = in[3]; out[3] = (inword << 1) | borrow; borrow = inword >> 31; + inword = in[2]; out[2] = (inword << 1) | borrow; borrow = inword >> 31; + inword = in[1]; out[1] = (inword << 1) | borrow; borrow = inword >> 31; + inword = in[0]; out[0] = (inword << 1) | borrow; borrow = inword >> 31; + +#if CF_CACHE_SIDE_CHANNEL_PROTECTION + out[3] ^= select_u8(borrow, table, 2); +#else + out[3] ^= table[borrow]; +#endif +} + +/* out = 2 * in. Arguments may alias. */ +void cf_gf128_double_le(const cf_gf128 in, cf_gf128 out) +{ + uint8_t table[2] = { 0x00, 0xe1 }; + uint32_t borrow = 0; + uint32_t inword; + + inword = in[0]; out[0] = (inword >> 1) | (borrow << 31); borrow = inword & 1; + inword = in[1]; out[1] = (inword >> 1) | (borrow << 31); borrow = inword & 1; + inword = in[2]; out[2] = (inword >> 1) | (borrow << 31); borrow = inword & 1; + inword = in[3]; out[3] = (inword >> 1) | (borrow << 31); borrow = inword & 1; + +#if CF_CACHE_SIDE_CHANNEL_PROTECTION + out[0] ^= select_u8(borrow, table, 2) << 24; +#else + out[0] ^= table[borrow] << 24; +#endif +} + +/* out = x + y. Arguments may alias. */ +void cf_gf128_add(const cf_gf128 x, const cf_gf128 y, cf_gf128 out) +{ + out[0] = x[0] ^ y[0]; + out[1] = x[1] ^ y[1]; + out[2] = x[2] ^ y[2]; + out[3] = x[3] ^ y[3]; +} + +/* out = xy. Arguments may alias. */ +void cf_gf128_mul(const cf_gf128 x, const cf_gf128 y, cf_gf128 out) +{ +#if CF_TIME_SIDE_CHANNEL_PROTECTION + cf_gf128 zero = { 0 }; +#endif + + /* Z_0 = 0^128 + * V_0 = Y */ + cf_gf128 Z, V; + memset(Z, 0, sizeof Z); + memcpy(V, y, sizeof V); + + for (int i = 0; i < 128; i++) + { + uint32_t word = x[i >> 5]; + uint8_t bit = (word >> (31 - (i & 31))) & 1; + +#if CF_TIME_SIDE_CHANNEL_PROTECTION + select_xor128(Z, zero, V, bit); +#else + if (bit) + xor_words(Z, V, 4); +#endif + + cf_gf128_double_le(V, V); + } + + memcpy(out, Z, sizeof Z); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.h new file mode 100644 index 0000000..7560862 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/gf128.h @@ -0,0 +1,55 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef GF128_H +#define GF128_H + +#include +#include + +/** + * @brief Operations in GF(2^128). + * + * These implementations are constant time, but relatively slow. + */ + +typedef uint32_t cf_gf128[4]; + +/* Unpack from big-endian bytes into out. */ +void cf_gf128_frombytes_be(const uint8_t in[16], cf_gf128 out); + +/* Pack in big-endian order into out. */ +void cf_gf128_tobytes_be(const cf_gf128 in, uint8_t out[16]); + +/* out = 2 * in. Arguments may not alias. */ +void cf_gf128_double(const cf_gf128 in, cf_gf128 out); + +/* out = 2 * in. Arguments may not alias. + * This differs from cf_gf128_double because it interprets the + * block in little endian: the lsb is the msb of the + * first element, the msb is the lsb of the last element. + * + * GCM uses this convention. */ +void cf_gf128_double_le(const cf_gf128 in, cf_gf128 out); + +/* out = x + y. Arguments may alias. */ +void cf_gf128_add(const cf_gf128 x, const cf_gf128 y, cf_gf128 out); + +/* out = xy. Arguments may alias. + * + * This uses cf_gf128_double_le internally, and is suitable for + * GCM. */ +void cf_gf128_mul(const cf_gf128 x, const cf_gf128 y, cf_gf128 out); + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/handy.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/handy.h new file mode 100644 index 0000000..fe40871 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/handy.h @@ -0,0 +1,88 @@ +#ifndef HANDY_H +#define HANDY_H + +#include +#include +#include + +/* + * Handy CPP defines and C inline functions. + */ + +/* Evaluates to the number of items in array-type variable arr. */ +#define ARRAYCOUNT(arr) (sizeof arr / sizeof arr[0]) + +/* Normal MIN/MAX macros. Evaluate argument expressions only once. */ +#ifndef MIN + #define MIN(x, y) \ + ({ typeof (x) __x = (x); \ + typeof (y) __y = (y); \ + __x < __y ? __x : __y; }) +#endif +#ifndef MAX + #define MAX(x, y) \ + ({ typeof (x) __x = (x); \ + typeof (y) __y = (y); \ + __x > __y ? __x : __y; }) +#endif + +/* Swap two values. Uses GCC type inference magic. */ +#ifndef SWAP + #define SWAP(x, y) \ + do { \ + typeof (x) __tmp = (x); \ + (x) = (y); \ + (y) = __tmp; \ + } while (0) +#endif + +/** Stringify its argument. */ +#define STRINGIFY(x) STRINGIFY_(x) +#define STRINGIFY_(x) #x + +/* Error handling macros. + * + * These expect a zero = success, non-zero = error convention. + */ + +/** Error: return. + * + * If the expression fails, return the error from this function. */ +#define ER(expr) do { typeof (expr) err_ = (expr); if (err_) return err_; } while (0) + +/** Error: goto. + * + * If the expression fails, goto x_err. Assumes defn of label + * x_err and 'error_type err'. */ +#define EG(expr) do { err = (expr); if (err) goto x_err; } while (0) + +/** Like memset(ptr, 0, len), but not allowed to be removed by + * compilers. */ +static inline void mem_clean(volatile void *v, size_t len) +{ + if (len) + { + memset((void *) v, 0, len); + (void) *((volatile uint8_t *) v); + } +} + +/** Returns 1 if len bytes at va equal len bytes at vb, 0 if they do not. + * Does not leak length of common prefix through timing. */ +static inline unsigned mem_eq(const void *va, const void *vb, size_t len) +{ + const volatile uint8_t *a = va; + const volatile uint8_t *b = vb; + uint8_t tmp; + uint8_t diff = 0; + + while (len--) + { + tmp = *b++; + diff |= *a++ ^ tmp; + } + + return !diff; +} + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/license.txt new file mode 100644 index 0000000..1625c17 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/license.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.c new file mode 100644 index 0000000..1e44af1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.c @@ -0,0 +1,99 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#include "prp.h" +#include "modes.h" +#include "bitops.h" +#include "blockwise.h" + +#include +#include "tassert.h" + +/* CBC */ +void cf_cbc_init(cf_cbc *ctx, const cf_prp *prp, void *prpctx, const uint8_t iv[CF_MAXBLOCK]) +{ + ctx->prp = prp; + ctx->prpctx = prpctx; + memcpy(ctx->block, iv, prp->blocksz); +} + +void cf_cbc_encrypt(cf_cbc *ctx, const uint8_t *input, uint8_t *output, size_t blocks) +{ + uint8_t buf[CF_MAXBLOCK]; + size_t nblk = ctx->prp->blocksz; + + while (blocks--) + { + xor_bb(buf, input, ctx->block, nblk); + ctx->prp->encrypt(ctx->prpctx, buf, ctx->block); + memcpy(output, ctx->block, nblk); + input += nblk; + output += nblk; + } +} + +void cf_cbc_decrypt(cf_cbc *ctx, const uint8_t *input, uint8_t *output, size_t blocks) +{ + uint8_t buf[CF_MAXBLOCK]; + size_t nblk = ctx->prp->blocksz; + + while (blocks--) + { + ctx->prp->decrypt(ctx->prpctx, input, buf); + xor_bb(output, buf, ctx->block, nblk); + memcpy(ctx->block, input, nblk); + input += nblk; + output += nblk; + } +} + +/* CTR */ +void cf_ctr_init(cf_ctr *ctx, const cf_prp *prp, void *prpctx, const uint8_t nonce[CF_MAXBLOCK]) +{ + memset(ctx, 0, sizeof *ctx); + ctx->counter_offset = 0; + ctx->counter_width = prp->blocksz; + ctx->prp = prp; + ctx->prpctx = prpctx; + ctx->nkeymat = 0; + memcpy(ctx->nonce, nonce, prp->blocksz); +} + +void cf_ctr_custom_counter(cf_ctr *ctx, size_t offset, size_t width) +{ + assert(ctx->prp->blocksz <= offset + width); + ctx->counter_offset = offset; + ctx->counter_width = width; +} + +static void ctr_next_block(void *vctx, uint8_t *out) +{ + cf_ctr *ctx = vctx; + ctx->prp->encrypt(ctx->prpctx, ctx->nonce, out); + incr_be(ctx->nonce + ctx->counter_offset, ctx->counter_width); +} + +void cf_ctr_cipher(cf_ctr *ctx, const uint8_t *input, uint8_t *output, size_t bytes) +{ + cf_blockwise_xor(ctx->keymat, &ctx->nkeymat, + ctx->prp->blocksz, + input, output, bytes, + ctr_next_block, + ctx); +} + +void cf_ctr_discard_block(cf_ctr *ctx) +{ + ctx->nkeymat = 0; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.h new file mode 100644 index 0000000..75f9bfd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/modes.h @@ -0,0 +1,560 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef MODES_H +#define MODES_H + +#include +#include + +#include "prp.h" + +/** + * Block cipher modes + * ================== + */ + +/** + * CBC mode + * -------- + * This implementation allows encryption or decryption of whole + * blocks in CBC mode. It does not offer a byte-wise incremental + * interface, or do any padding. + * + * This mode provides no useful integrity and should not be used + * directly. + */ + +/* .. c:type:: cf_cbc + * This structure binds together the things needed to encrypt/decrypt whole + * blocks in CBC mode. + * + * .. c:member:: cf_cbc.prp + * How to encrypt or decrypt blocks. This could be, for example, :c:data:`cf_aes`. + * + * .. c:member:: cf_cbc.prpctx + * Private data for prp functions. For a `prp` of `cf_aes`, this would be a + * pointer to a :c:type:`cf_aes_context` instance. + * + * .. c:member:: cf_cbc.block + * The IV or last ciphertext block. + */ +typedef struct +{ + const cf_prp *prp; + void *prpctx; + uint8_t block[CF_MAXBLOCK]; +} cf_cbc; + +/* .. c:function:: $DECL + * Initialise CBC encryption/decryption context using selected prp, prp context and IV. */ +void cf_cbc_init(cf_cbc *ctx, const cf_prp *prp, void *prpctx, const uint8_t iv[CF_MAXBLOCK]); + +/* .. c:function:: $DECL + * Encrypt blocks in CBC mode. input and output + * must point to blocks * ctx->prp->blocksz bytes of storage (and may alias). */ +void cf_cbc_encrypt(cf_cbc *ctx, const uint8_t *input, uint8_t *output, size_t blocks); + +/* .. c:function:: $DECL + * Decrypt blocks in CBC mode. input and output + * must point to blocks * ctx->prp->blocksz bytes of storage (and may alias). */ +void cf_cbc_decrypt(cf_cbc *ctx, const uint8_t *input, uint8_t *output, size_t blocks); + +/** + * Counter mode + * ------------ + * This implementation allows incremental encryption/decryption of + * messages. Encryption and decryption are the same operation. + * + * The counter is always big-endian, but has configurable location + * and size within the nonce block. The counter wraps, so you + * should make sure the length of a message with a given nonce + * doesn't cause nonce reuse. + * + * This mode provides no integrity and should not be used directly. + */ + +/* .. c:type:: cf_ctr + * + * .. c:member:: cf_ctr.prp + * How to encrypt or decrypt blocks. This could be, for example, :c:data:`cf_aes`. + * + * .. c:member:: cf_ctr.prpctx + * Private data for prp functions. For a `prp` of `cf_aes`, this would be a + * pointer to a :c:type:`cf_aes_context` instance. + * + * .. c:member:: cf_ctr.nonce + * The next block to encrypt to get another block of key stream. + * + * .. c:member:: cf_ctr.keymat + * The current block of key stream. + * + * .. c:member:: cf_ctr.nkeymat + * The number of bytes at the end of :c:member:`keymat` that are so-far unused. + * If this is zero, all the bytes are used up and/or of undefined value. + * + * .. c:member:: cf_ctr.counter_offset + * The offset (in bytes) of the counter block within the nonce. + * + * .. c:member:: cf_ctr.counter_width + * The width (in bytes) of the counter block in the nonce. + */ +typedef struct +{ + const cf_prp *prp; + void *prpctx; + uint8_t nonce[CF_MAXBLOCK]; + uint8_t keymat[CF_MAXBLOCK]; + size_t nkeymat; + size_t counter_offset; + size_t counter_width; +} cf_ctr; + +/* .. c:function:: $DECL + * Initialise CTR encryption/decryption context using selected prp and nonce. + * (nb, this only increments the whole nonce as a big endian block) */ +void cf_ctr_init(cf_ctr *ctx, const cf_prp *prp, void *prpctx, const uint8_t nonce[CF_MAXBLOCK]); + +/* .. c:function:: $DECL + * Set the location and width of the nonce counter. + * + * eg. offset = 12, width = 4 means the counter is mod 2^32 and placed + * at the end of the nonce. */ +void cf_ctr_custom_counter(cf_ctr *ctx, size_t offset, size_t width); + +/* .. c:function:: $DECL + * Encrypt or decrypt bytes in CTR mode. + * input and output may alias and must point to specified number of bytes. */ +void cf_ctr_cipher(cf_ctr *ctx, const uint8_t *input, uint8_t *output, size_t bytes); + +/* .. c:function:: $DECL + * Discards the rest of this block of key stream. */ +void cf_ctr_discard_block(cf_ctr *ctx); + +/** + * CBC-MAC + * ------- + * This is a incremental interface to computing a CBC-MAC tag over a message. + * + * It optionally pads the message with PKCS#5/PKCS#7 padding -- if you don't + * do this, messages must be an exact number of blocks long. + * + * You shouldn't use this directly because it isn't secure for variable-length + * messages. Use CMAC instead. + */ + +/* .. c:type:: cf_cbcmac_stream + * Stream interface to CBC-MAC signing. + * + * .. c:member:: cf_cbcmac.prp + * How to encrypt or decrypt blocks. This could be, for example, :c:data:`cf_aes`. + * + * .. c:member:: cf_cbcmac.prpctx + * Private data for prp functions. For a `prp` of `cf_aes`, this would be a + * pointer to a :c:type:`cf_aes_context` instance. + * + * .. c:member:: cf_cbcmac.cbc + * CBC data. + * + * .. c:member:: cf_cbcmac.buffer + * Buffer for data which can't be processed until we have a full block. + * + * .. c:member:: cf_cbcmac.used + * How many bytes at the front of :c:member:`buffer` are valid. + */ +typedef struct +{ + const cf_prp *prp; + void *prpctx; + cf_cbc cbc; + uint8_t buffer[CF_MAXBLOCK]; + size_t used; +} cf_cbcmac_stream; + +/* .. c:function:: $DECL + * Initialise CBC-MAC signing context using selected prp. */ +void cf_cbcmac_stream_init(cf_cbcmac_stream *ctx, const cf_prp *prp, void *prpctx); + +/* .. c:function:: $DECL + * Reset the streaming signing context, to sign a new message. */ +void cf_cbcmac_stream_reset(cf_cbcmac_stream *ctx); + +/* .. c:function:: $DECL + * Process ndata bytes at data. */ +void cf_cbcmac_stream_update(cf_cbcmac_stream *ctx, const uint8_t *data, size_t ndata); + +/* .. c:function:: $DECL + * Finish the current block of data by adding zeroes. Does nothing if there + * are no bytes awaiting processing. */ +void cf_cbcmac_stream_finish_block_zero(cf_cbcmac_stream *ctx); + +/* .. c:function:: $DECL + * Output the MAC to ctx->prp->blocksz bytes at out. + * ctx->used must be zero: the inputed message must be an exact number of + * blocks. */ +void cf_cbcmac_stream_nopad_final(cf_cbcmac_stream *ctx, uint8_t out[CF_MAXBLOCK]); + +/* .. c:function:: $DECL + * Output the MAC to ctx->prp->blocksz bytes at out. + * + * The message is padded with PKCS#5 padding. */ +void cf_cbcmac_stream_pad_final(cf_cbcmac_stream *ctx, uint8_t out[CF_MAXBLOCK]); + +/** + * CMAC + * ---- + * This is both a one-shot and incremental interface to + * computing a CMAC tag over a message. + * + * The one-shot interface separates out the per-key computation, + * so if you need to compute lots of MACs with one key you don't + * pay that cost more than once. + * + * CMAC is a good choice for a symmetric MAC. + */ + +/* .. c:type:: cf_cmac + * One-shot interface to CMAC signing. + * + * .. c:member:: cf_cmac.prp + * How to encrypt or decrypt blocks. This could be, for example, :c:data:`cf_aes`. + * + * .. c:member:: cf_cmac.prpctx + * Private data for prp functions. For a `prp` of `cf_aes`, this would be a + * pointer to a :c:type:`cf_aes_context` instance. + * + * .. c:member:: cf_cmac.B + * The XOR offset for the last message block if it is a complete block + * (also known as K\ :sub:`1`). + * + * .. c:member:: cf_cmac.P + * The XOR offset for the last message block if it is a partial block + * (also known as K\ :sub:`2`). + */ +typedef struct +{ + const cf_prp *prp; + void *prpctx; + uint8_t B[CF_MAXBLOCK]; + uint8_t P[CF_MAXBLOCK]; +} cf_cmac; + +/* .. c:function:: $DECL + * Initialise CMAC signing context using selected prp. */ +void cf_cmac_init(cf_cmac *ctx, const cf_prp *prp, void *prpctx); + +/* .. c:function:: $DECL + * CMAC sign the given data. The MAC is written to ctx->prp->blocksz + * bytes at out. This is a one-shot function. */ +void cf_cmac_sign(cf_cmac *ctx, const uint8_t *data, size_t bytes, + uint8_t out[CF_MAXBLOCK]); + +/* .. c:type:: cf_cmac_stream + * Stream interface to CMAC signing. + * + * Input data in arbitrary chunks using :c:func:`cf_cmac_stream_update`. + * The last bit of data must be signalled with the `isfinal` flag to + * that function, and the data cannot be zero length unless the whole + * message is empty. + * + * .. c:member:: cf_cmac_stream.cmac + * CMAC one-shot data. + * + * .. c:member:: cf_cmac_stream.cbc + * CBC block encryption data. + * + * .. c:member:: cf_cmac_stream.buffer + * Buffer for data which can't be processed until we have a full block. + * + * .. c:member:: cf_cmac_stream.used + * How many bytes at the front of :c:member:`buffer` are valid. + * + * .. c:member:: cf_cmac_stream.processed + * How many bytes in total we've processed. This is used to correctly + * process empty messages. + * + * .. c:member:: cf_cmac_stream.finalised + * A flag set when the final chunk of the message has been processed. + * Only when this flag is set can you get the MAC out. + */ +typedef struct +{ + cf_cmac cmac; + cf_cbc cbc; + uint8_t buffer[CF_MAXBLOCK]; + size_t used; + size_t processed; + int finalised; +} cf_cmac_stream; + +/* .. c:function:: $DECL + * Initialise CMAC streaming signing context using selected prp. */ +void cf_cmac_stream_init(cf_cmac_stream *ctx, const cf_prp *prp, void *prpctx); + +/* .. c:function:: $DECL + * Reset the streaming signing context, to sign a new message. */ +void cf_cmac_stream_reset(cf_cmac_stream *ctx); + +/* .. c:function:: $DECL + * Process ndata bytes at data. isfinal is non-zero if this is the last piece + * of data. */ +void cf_cmac_stream_update(cf_cmac_stream *ctx, const uint8_t *data, size_t ndata, + int isfinal); + +/* .. c:function:: $DECL + * Output the MAC to ctx->cmac->prp->blocksz bytes at out. + * cf_cmac_stream_update with isfinal non-zero must have been called + * since the last _init/_reset. */ +void cf_cmac_stream_final(cf_cmac_stream *ctx, uint8_t out[CF_MAXBLOCK]); + +/** + * EAX + * --- + * + * The EAX authenticated encryption mode. This is a one-shot + * interface. + * + * EAX is a pretty respectable and fast AEAD mode. + */ + +/* .. c:function:: $DECL + * EAX authenticated encryption. + * + * This function does not fail. + * + * :param prp/prpctx: describe the block cipher to use. + * :param plain: message plaintext. + * :param nplain: length of message. May be zero. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. May be zero. + * :param nonce: nonce. This must not repeat for a given key. + * :param nnonce: length of nonce. The nonce can be any length. + * :param cipher: ciphertext output. `nplain` bytes are written here. + * :param tag: authentication tag. `ntag` bytes are written here. + * :param ntag: authentication tag length. This must be non-zero and no greater than `prp->blocksz`. + */ +void cf_eax_encrypt(const cf_prp *prp, void *prpctx, + const uint8_t *plain, size_t nplain, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + uint8_t *cipher, + uint8_t *tag, size_t ntag); + +/* .. c:function:: $DECL + * EAX authenticated decryption. + * + * :return: 0 on success, non-zero on error. Nothing is written to plain on error. + * + * :param prp/prpctx: describe the block cipher to use. + * :param cipher: message ciphertext. + * :param ncipher: message length. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. + * :param nonce: nonce. + * :param nnonce: length of nonce. + * :param tag: authentication tag. `ntag` bytes are read from here. + * :param ntag: authentication tag length. + * :param plain: plaintext output. `ncipher` bytes are written here. + */ +int cf_eax_decrypt(const cf_prp *prp, void *prpctx, + const uint8_t *cipher, size_t ncipher, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + const uint8_t *tag, size_t ntag, + uint8_t *plain); + +/** + * GCM + * --- + * The GCM ('Galois counter mode') authenticated encryption mode. + * This is a one-shot interface. + * + * GCM is a reasonably respectable AEAD mode. It's somewhat more + * complex than EAX, and side channel-free implementations can + * be quite slow. + */ + +/* .. c:function:: $DECL + * GCM authenticated encryption. + * + * This function does not fail. + * + * :param prp/prpctx: describe the block cipher to use. + * :param plain: message plaintext. + * :param nplain: length of message. May be zero. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. May be zero. + * :param nonce: nonce. This must not repeat for a given key. + * :param nnonce: length of nonce. The nonce can be any length, but 12 bytes is strongly recommended. + * :param cipher: ciphertext output. `nplain` bytes are written here. + * :param tag: authentication tag. `ntag` bytes are written here. + * :param ntag: authentication tag length. This must be non-zero and no greater than `prp->blocksz`. + * + * This function does not fail. + */ +void cf_gcm_encrypt(const cf_prp *prp, void *prpctx, + const uint8_t *plain, size_t nplain, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + uint8_t *cipher, + uint8_t *tag, size_t ntag); + +/* .. c:function:: $DECL + * GCM authenticated decryption. + * + * :return: 0 on success, non-zero on error. Nothing is written to plain on error. + * + * :param prp: describe the block cipher to use. + * :param prpctx: describe the block cipher to use. + * :param cipher: message ciphertext. + * :param ncipher: message length. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. + * :param nonce: nonce. + * :param nnonce: length of nonce. + * :param tag: authentication tag. `ntag` bytes are read from here. + * :param ntag: authentication tag length. + * :param plain: plaintext output. `ncipher` bytes are written here. + */ +int cf_gcm_decrypt(const cf_prp *prp, void *prpctx, + const uint8_t *cipher, size_t ncipher, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + const uint8_t *tag, size_t ntag, + uint8_t *plain); + +/** + * CCM + * --- + * + * The CCM ('Counter with CBC-MAC') authenticated encryption mode. + * CCM is a widely used AEAD mode (in IPSec, WPA2, Bluetooth, etc.) + * + * It works (at a high level) by just gluing together CTR and CBC-MAC + * modes (in MAC-then-encrypt mode) and then fixing the problems inherent + * with CBC-MAC in over-complicated ways. + * + * This is a one-shot interface, which is good because the underlying + * mechanism isn't actually online: you need to know the message length + * before you start, or do everything in two passes. + */ + +/* .. c:function:: $DECL + * CCM authenticated encryption. + * + * This function does not fail. + * + * :param prp/prpctx: describe the block cipher to use. + * :param plain: message plaintext. + * :param nplain: length of message. May be zero. Must meet the constraints placed on it by `L`. + * :param L: length of the message length encoding. This must be in the interval `[2,8]` and gives a maximum message size of 2\ :sup:`8L` bytes. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. May be zero. + * :param nonce: nonce. This must not repeat for a given key. + * :param nnonce: length of nonce. Must be exactly `15 - L` bytes for a 128-bit block cipher. + * :param cipher: ciphertext output. `nplain` bytes are written here. + * :param tag: authentication tag. `ntag` bytes are written here. + * :param ntag: authentication tag length. This must be 4, 6, 8, 10, 12, 14 or 16. + */ +void cf_ccm_encrypt(const cf_prp *prp, void *prpctx, + const uint8_t *plain, size_t nplain, size_t L, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + uint8_t *cipher, + uint8_t *tag, size_t ntag); + +/* .. c:function:: $DECL + * CCM authenticated decryption. + * + * :return: 0 on success, non-zero on error. Plain is cleared on error. + * + * :param prp: describe the block cipher to use. + * :param prpctx: describe the block cipher to use. + * :param cipher: message ciphertext. + * :param ncipher: length of message. + * :param L: length of the message length encoding. See :c:func:`cf_ccm_encrypt`. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. + * :param nonce: nonce. + * :param nnonce: length of nonce. + * :param tag: authentication tag. `ntag` bytes are read from here. + * :param ntag: authentication tag length. This must be 4, 6, 8, 10, 12, 14 or 16. + * :param plain: plaintext output. `ncipher` bytes are written here. + */ +int cf_ccm_decrypt(const cf_prp *prp, void *prpctx, + const uint8_t *cipher, size_t ncipher, size_t L, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + const uint8_t *tag, size_t ntag, + uint8_t *plain); + +/** + * OCB + * --- + * + * OCB is an authenticated encryption mode by Phil Rogaway. + * + * This is version 3, as standardised in RFC7253. It's defined + * only for block ciphers with a 128-bit block size. + * + * This is a one-shot interface. + */ + +/* .. c:function:: $DECL + * OCB authenticated encryption. + * + * This function does not fail. + * + * :param prp/prpctx: describe the block cipher to use. + * :param plain: message plaintext. + * :param nplain: length of message. May be zero. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. May be zero. + * :param nonce: nonce. This must not repeat for a given key. + * :param nnonce: length of nonce. Must be 15 or fewer bytes. + * :param cipher: ciphertext output. `nplain` bytes are written here. + * :param tag: authentication tag. `ntag` bytes are written here. + * :param ntag: authentication tag length. Must be 16 or fewer bytes. + */ +void cf_ocb_encrypt(const cf_prp *prp, void *prpctx, + const uint8_t *plain, size_t nplain, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + uint8_t *cipher, + uint8_t *tag, size_t ntag); + +/* .. c:function:: $DECL + * OCB authenticated decryption. + * + * :return: 0 on success, non-zero on error. `plain` is cleared on error. + * + * :param prp: describe the block cipher to use. + * :param prpctx: describe the block cipher to use. + * :param cipher: message ciphertext. + * :param ncipher: length of message. + * :param header: additionally authenticated data (AAD). + * :param nheader: length of AAD. + * :param nonce: nonce. + * :param nnonce: length of nonce. + * :param tag: authentication tag. `ntag` bytes are read from here. + * :param ntag: authentication tag length. + * :param plain: plaintext output. `ncipher` bytes are written here. + */ +int cf_ocb_decrypt(const cf_prp *prp, void *prpctx, + const uint8_t *cipher, size_t ncipher, + const uint8_t *header, size_t nheader, + const uint8_t *nonce, size_t nnonce, + const uint8_t *tag, size_t ntag, + uint8_t *plain); +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/prp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/prp.h new file mode 100644 index 0000000..1aa7258 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/prp.h @@ -0,0 +1,64 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef PRP_H +#define PRP_H + +#include +#include + +/** + * General block cipher description + * ================================ + * This allows us to implement block cipher modes which can work + * with different block ciphers. + */ + +/* .. c:type:: cf_prp_block + * Block processing function type. + * + * The `in` and `out` blocks may alias. + * + * :rtype: void + * :param ctx: block cipher-specific context object. + * :param in: input block. + * :param out: output block. + */ +typedef void (*cf_prp_block)(void *ctx, const uint8_t *in, uint8_t *out); + +/* .. c:type:: cf_prp + * Describes an PRP in a general way. + * + * .. c:member:: cf_prp.blocksz + * Block size in bytes. Must be no more than :c:macro:`CF_MAXBLOCK`. + * + * .. c:member:: cf_prp.encrypt + * Block encryption function. + * + * .. c:member:: cf_prp.decrypt + * Block decryption function. + */ +typedef struct +{ + size_t blocksz; + cf_prp_block encrypt; + cf_prp_block decrypt; +} cf_prp; + +/* .. c:macro:: CF_MAXBLOCK + * The maximum block cipher blocksize we support, in bytes. + */ +#define CF_MAXBLOCK 16 + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/tassert.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/tassert.h new file mode 100644 index 0000000..58ebb4c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/cifra_AES128-EAX/tassert.h @@ -0,0 +1,32 @@ +/* + * cifra - embedded cryptography library + * Written in 2014 by Joseph Birr-Pixton + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to the + * public domain worldwide. This software is distributed without any + * warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication + * along with this software. If not, see + * . + */ + +#ifndef TASSERT_H +#define TASSERT_H + +/* Tiny assert + * ----------- + * + * This is an assert(3) definition which doesn't include any + * strings, but just branches to abort(3) on failure. + */ + +#ifndef FULL_FAT_ASSERT +# include +# define assert(expr) do { if (!(expr)) abort(); } while (0) +#else +# include +#endif + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.c new file mode 100644 index 0000000..49d9bd4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.c @@ -0,0 +1,208 @@ +/* $NetBSD: fnmatch.c,v 1.26 2014/10/12 22:32:33 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 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. + */ + +/* + * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. + * Compares a filename or pathname to a pattern. + */ + +#include +#include "fnmatch.h" +#include + +#define EOS '\0' + +static inline int foldcase(int ch, int flags) +{ + + if ((flags & FNM_CASEFOLD) != 0 && isupper(ch)) + return tolower(ch); + return ch; +} + +#define FOLDCASE(ch, flags) foldcase((unsigned char)(ch), (flags)) + +static const char * rangematch(const char *pattern, int test, int flags) +{ + int negate, ok, need; + char c, c2; + + if (pattern == NULL) + { + return NULL; + } + + /* + * A bracket expression starting with an unquoted circumflex + * character produces unspecified results (IEEE 1003.2-1992, + * 3.13.2). This implementation treats it like '!', for + * consistency with the regular expression syntax. + * J.T. Conklin (conklin@ngai.kaleida.com) + */ + if ((negate = (*pattern == '!' || *pattern == '^')) != 0) + ++pattern; + + need = 1; + for (ok = 0; (c = FOLDCASE(*pattern++, flags)) != ']' || need;) { + need = 0; + if (c == '/') + return (void *)-1; + if (c == '\\' && !(flags & FNM_NOESCAPE)) + c = FOLDCASE(*pattern++, flags); + if (c == EOS) + return NULL; + if (*pattern == '-' + && (c2 = FOLDCASE(*(pattern + 1), flags)) != EOS && + c2 != ']') { + pattern += 2; + if (c2 == '\\' && !(flags & FNM_NOESCAPE)) + c2 = FOLDCASE(*pattern++, flags); + if (c2 == EOS) + return NULL; + if (c <= test && test <= c2) + ok = 1; + } else if (c == test) + ok = 1; + } + return ok == negate ? NULL : pattern; +} + + +static int fnmatchx(const char *pattern, const char *string, int flags, size_t recursion) +{ + const char *stringstart, *r; + char c, test; + + if ((pattern == NULL) || (string == NULL)) + { + return FNM_NOMATCH; + } + + if (recursion-- == 0) + return FNM_NORES; + + for (stringstart = string;;) { + switch (c = FOLDCASE(*pattern++, flags)) { + case EOS: + if ((flags & FNM_LEADING_DIR) && *string == '/') + return 0; + return *string == EOS ? 0 : FNM_NOMATCH; + case '?': + if (*string == EOS) + return FNM_NOMATCH; + if (*string == '/' && (flags & FNM_PATHNAME)) + return FNM_NOMATCH; + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return FNM_NOMATCH; + ++string; + break; + case '*': + c = FOLDCASE(*pattern, flags); + /* Collapse multiple stars. */ + while (c == '*') + c = FOLDCASE(*++pattern, flags); + + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return FNM_NOMATCH; + + /* Optimize for pattern with * at end or before /. */ + if (c == EOS) { + if (flags & FNM_PATHNAME) + return (flags & FNM_LEADING_DIR) || + strchr(string, '/') == NULL ? + 0 : FNM_NOMATCH; + else + return 0; + } else if (c == '/' && flags & FNM_PATHNAME) { + if ((string = strchr(string, '/')) == NULL) + return FNM_NOMATCH; + break; + } + + /* General case, use recursion. */ + while ((test = FOLDCASE(*string, flags)) != EOS) { + int e; + switch ((e = fnmatchx(pattern, string, + flags & ~FNM_PERIOD, recursion))) { + case FNM_NOMATCH: + break; + default: + return e; + } + if (test == '/' && flags & FNM_PATHNAME) + break; + ++string; + } + return FNM_NOMATCH; + case '[': + if (*string == EOS) + return FNM_NOMATCH; + if (*string == '/' && flags & FNM_PATHNAME) + return FNM_NOMATCH; + if ((r = rangematch(pattern, + FOLDCASE(*string, flags), flags)) == NULL) + return FNM_NOMATCH; + if (r == (void *)-1) { + if (*string != '[') + return FNM_NOMATCH; + } else + pattern = r; + ++string; + break; + case '\\': + if (!(flags & FNM_NOESCAPE)) { + if ((c = FOLDCASE(*pattern++, flags)) == EOS) { + c = '\0'; + --pattern; + } + } + /* FALLTHROUGH */ + default: + if (c != FOLDCASE(*string++, flags)) + return FNM_NOMATCH; + break; + } + } + /* NOTREACHED */ +} + +int fnmatch(const char *pattern, const char *string, int flags) +{ + return fnmatchx(pattern, string, flags, 64); +} + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.h new file mode 100644 index 0000000..5fa453f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fnmatch/fnmatch.h @@ -0,0 +1,50 @@ +/* $NetBSD: fnmatch.h,v 1.12.50.1 2011/02/08 16:18:55 bouyer Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 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. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#define FNM_NOMATCH 1 /* Match failed. */ +#define FNM_NOSYS 2 /* Function not implemented. */ +#define FNM_NORES 3 /* Out of resources */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ +#define FNM_CASEFOLD 0x08 /* Pattern is matched case-insensitive */ +#define FNM_LEADING_DIR 0x10 /* Ignore / after Imatch. */ + +int fnmatch(const char *, const char *, int); + +#endif /* !_FNMATCH_H_ */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf.c similarity index 96% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf.c index 07c96c4..419b3da 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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(NRF_FPRINTF) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf.h similarity index 98% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf.h index 9f987a1..3edb2c7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,7 +35,7 @@ * 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 NRF_FPRINTF_H__ #define NRF_FPRINTF_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf_format.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf_format.c similarity index 66% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf_format.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf_format.c index a1a2ee9..05b4e78 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf_format.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf_format.c @@ -65,12 +65,39 @@ #include "nrf_fprintf.h" #include "nrf_fprintf_format.h" -#define NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY (1u << 0) -#define NRF_CLI_FORMAT_FLAG_PAD_ZERO (1u << 1) -#define NRF_CLI_FORMAT_FLAG_PRINT_SIGN (1u << 2) +#define NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY (1u << 0) +#define NRF_CLI_FORMAT_FLAG_PAD_ZERO (1u << 1) +#define NRF_CLI_FORMAT_FLAG_PRINT_SIGN (1u << 2) + +#define NRF_CLI_FORMAT_DOUBLE_DEF_PRECISION 6 + +#define NRF_CLI_FORMAT_DOUBLE_SIGN_POSITION 63U +#define NRF_CLI_FORMAT_DOUBLE_SIGN_MASK 1ULL +#define NRF_CLI_FORMAT_DOUBLE_SIGN (NRF_CLI_FORMAT_DOUBLE_SIGN_MASK << NRF_CLI_FORMAT_DOUBLE_SIGN_POSITION) +#define NRF_CLI_FORMAT_DOUBLE_EXP_POSITION 52U +#define NRF_CLI_FORMAT_DOUBLE_EXP_MASK 0x7FFULL +#define NRF_CLI_FORMAT_DOUBLE_EXP (NRF_CLI_FORMAT_DOUBLE_EXP_MASK << NRF_CLI_FORMAT_DOUBLE_EXP_POSITION) +#define NRF_CLI_FORMAT_DOUBLE_MANT_POSITION 0U +#define NRF_CLI_FORMAT_DOUBLE_MANT_MASK 0xFFFFFFFFFFFFF +#define NRF_CLI_FORMAT_DOUBLE_MANT (NRF_CLI_FORMAT_DOUBLE_MANT_MASK << NRF_CLI_FORMAT_DOUBLE_MANT_POSITION) + +#define NRF_CLI_FORMAT_DOUBLE_SIGN_GET(v) (!!((v) & NRF_CLI_FORMAT_DOUBLE_SIGN)) +#define NRF_CLI_FORMAT_DOUBLE_EXP_GET(v) (((v) & NRF_CLI_FORMAT_DOUBLE_EXP) >> NRF_CLI_FORMAT_DOUBLE_EXP_POSITION) +#define NRF_CLI_FORMAT_DOUBLE_MANT_GET(v) (((v) & NRF_CLI_FORMAT_DOUBLE_MANT) >> NRF_CLI_FORMAT_DOUBLE_MANT_POSITION) +#define NRF_CLI_FORMAT_REQ_SIGN_SPACE(s, f) ((s) | (!!((f) & NRF_CLI_FORMAT_FLAG_PRINT_SIGN))) + +#define HIGH_32(v) ((v) >> 32) +#define LOW_32(v) (((1ULL << 32) - 1) & v) + static void buffer_add(nrf_fprintf_ctx_t * const p_ctx, char c) { +#if NRF_MODULE_ENABLED(NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF) + if (c == '\n') + { + buffer_add(p_ctx, '\r'); + } +#endif p_ctx->p_io_buffer[p_ctx->io_buffer_cnt++] = c; if (p_ctx->io_buffer_cnt >= p_ctx->io_buffer_size) @@ -311,6 +338,255 @@ static void int_print(nrf_fprintf_ctx_t * const p_ctx, unsigned_print(p_ctx, (uint32_t)v, Base, NumDigits, FieldWidth, FormatFlags); } +#if NRF_MODULE_ENABLED(NRF_FPRINTF_DOUBLE) + +static void fill_space(nrf_fprintf_ctx_t * const p_ctx, + uint8_t len, + bool zeros) +{ + for (; len > 0; len--) + { + if (zeros) + { + buffer_add(p_ctx, '0'); + } + else + { + buffer_add(p_ctx, ' '); + } + } +} + +static void float_print(nrf_fprintf_ctx_t * const p_ctx, + double v, + uint32_t digits, + uint32_t width, + uint32_t format, + bool uppercase) +{ + bool sign, transform = false; + uint64_t num, mant, lead, low, base, res, carry, x, s0, s1, s2, s3, fr; + int32_t exp; + uint8_t highest, offset, lead_len = 0, skipped = 0; + uint8_t precision = digits ? digits + 1 : NRF_CLI_FORMAT_DOUBLE_DEF_PRECISION + 1; + /* Default digits should be -1, because 0 could be a requirement, not the default. + * This should be changed for the whole library. + */ + + if ((v > 0.0) && (v < 1.0)) + { + v += 1.0; + transform = true; + } + else if ((v > -1.0) && (v < 0.0)) + { + v -= 1.0; + transform = true; + } + + memcpy(&num, &v, sizeof(num)); + sign = NRF_CLI_FORMAT_DOUBLE_SIGN_GET(num); + exp = NRF_CLI_FORMAT_DOUBLE_EXP_GET(num); + mant = NRF_CLI_FORMAT_DOUBLE_MANT_GET(num); + + /* Special cases */ + if (exp == NRF_CLI_FORMAT_DOUBLE_EXP_MASK) + { + if (width && (!(format & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY))) + { + fill_space(p_ctx, width - 3 - NRF_CLI_FORMAT_REQ_SIGN_SPACE(sign, format), false); + } + + if (sign) + { + buffer_add(p_ctx, '-'); + } + else if (format & NRF_CLI_FORMAT_FLAG_PRINT_SIGN) + { + buffer_add(p_ctx, '+'); + } + + if (mant != 0) + { + if(uppercase) + { + buffer_add(p_ctx, 'N'); + buffer_add(p_ctx, 'A'); + buffer_add(p_ctx, 'N'); + } + else + { + buffer_add(p_ctx, 'n'); + buffer_add(p_ctx, 'a'); + buffer_add(p_ctx, 'n'); + } + } + else + { + if(uppercase) + { + buffer_add(p_ctx, 'I'); + buffer_add(p_ctx, 'N'); + buffer_add(p_ctx, 'F'); + } + else + { + buffer_add(p_ctx, 'i'); + buffer_add(p_ctx, 'n'); + buffer_add(p_ctx, 'f'); + } + } + return; + } + + /* Add leading 1 to mantissa (except 0.0) */ + if ((mant != 0) || (exp != 0)) + { + mant |= (1ULL << 52); + } + + /* Convert the exponent */ + exp = exp - 1023; + + /* Whole numbers */ + offset = 52 - exp; + + if (offset > 64) + { + /* Float fraction offset overflow */ + return; + } + + lead = (mant >> (offset)); + + /* Fraction */ + low = mant & (~(lead << offset)); + + while (((low & 0x1) == 0) && low > 0) + { + low = low >> 1U; + skipped++; + } + + highest = (offset - skipped); + base = 1; + + for(uint8_t i = 0; i < precision; i++) + { + base *= 10; + } + + /* Handle multiplication with possible overflow */ + x = LOW_32(low) * LOW_32(base); + s0 = LOW_32(x); + + x = HIGH_32(low) * LOW_32(base) + HIGH_32(x); + s1 = LOW_32(x); + s2 = HIGH_32(x); + + x = s1 + LOW_32(low) * HIGH_32(base); + s1 = LOW_32(x); + + x = s2 + HIGH_32(low) * HIGH_32(base) + HIGH_32(x); + s2 = LOW_32(x); + s3 = HIGH_32(x); + + res = s1 << 32 | s0; + carry = s3 << 32 | s2; + + /* Divide and combine */ + carry = carry << (64 - highest); + res = res >> highest; + fr = res | carry; + + /* Roundup */ + if (fr%10 >= 5) + { + fr /= 10; + fr++; + } + else + { + fr /= 10; + } + precision--; + + if (transform && (lead == 1)) + { + lead = 0; + } + + /* Maximum precision handled by int_print() is 10 */ + if (precision > 10) + { + for (uint8_t delta = precision - 10; delta > 0; delta--) + { + fr /= 10; + } + precision = 10; + } + + res = lead; + while (res > 0) + { + res /= 10; + lead_len++; + } + + if ((lead == 0) && (fr == 0)) + { + lead_len = 1; + } + + if(lead_len == 0) + { + lead_len = 1; + } + + if (width && (!(format & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY))) + { + int32_t space = width - lead_len - precision - NRF_CLI_FORMAT_REQ_SIGN_SPACE(sign, format) - 1; + if (space > 0) + { + fill_space(p_ctx, space, format & NRF_CLI_FORMAT_FLAG_PAD_ZERO); + } + } + + if (sign) + { + buffer_add(p_ctx, '-'); + } + else if (format & NRF_CLI_FORMAT_FLAG_PRINT_SIGN) + { + buffer_add(p_ctx, '+'); + } + + int_print(p_ctx, + lead, + 10u, + 0, + 0, + 0); + buffer_add(p_ctx, '.'); + int_print(p_ctx, + fr, + 10u, + precision, + 0, + 0); + + if (width && (format & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY)) + { + int32_t space = width - lead_len - precision - NRF_CLI_FORMAT_REQ_SIGN_SPACE(sign, format) - 1; + if (space > 0) + { + fill_space(p_ctx, space, false); + } + } +} + +#endif + void nrf_fprintf_fmt(nrf_fprintf_ctx_t * const p_ctx, char const * p_fmt, va_list * p_args) @@ -488,6 +764,30 @@ void nrf_fprintf_fmt(nrf_fprintf_ctx_t * const p_ctx, case '%': buffer_add(p_ctx, '%'); break; +#if NRF_MODULE_ENABLED(NRF_FPRINTF_DOUBLE) + case 'f': + { + double dbl = va_arg(*p_args, double); + float_print(p_ctx, + dbl, + NumDigits, + FieldWidth, + FormatFlags, + false); + break; + } + case 'F': + { + double dbl = va_arg(*p_args, double); + float_print(p_ctx, + dbl, + NumDigits, + FieldWidth, + FormatFlags, + true); + break; + } +#endif default: break; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf_format.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf_format.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/fprintf/nrf_fprintf_format.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/fprintf/nrf_fprintf_format.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/config/FreeRTOSConfig.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/config/FreeRTOSConfig.h similarity index 73% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/config/FreeRTOSConfig.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/config/FreeRTOSConfig.h index 36c7de7..0016b72 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/config/FreeRTOSConfig.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/config/FreeRTOSConfig.h @@ -1,67 +1,30 @@ /* - FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that has become a de facto standard. * - * * - * Help yourself get started quickly and support the FreeRTOS * - * project by purchasing a FreeRTOS tutorial book, reference * - * manual, or both from: http://www.FreeRTOS.org/Documentation * - * * - * Thank you! * - * * - *************************************************************************** - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available from the following - link: http://www.freertos.org/a00114.html - - 1 tab == 4 spaces! - - *************************************************************************** - * * - * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong?" * - * * - * http://www.FreeRTOS.org/FAQHelp.html * - * * - *************************************************************************** - - http://www.FreeRTOS.org - Documentation, books, training, latest versions, - license and Real Time Engineers Ltd. contact details. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef FREERTOS_CONFIG_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/license/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/license/license.txt new file mode 100644 index 0000000..83e25ea --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/license/license.txt @@ -0,0 +1,38 @@ +The FreeRTOS kernel is released under the MIT open source license, the text of +which is provided below. + +This license covers the FreeRTOS kernel source files, which are located in the +/FreeRTOS/Source directory of the official FreeRTOS kernel download. It also +covers most of the source files in the demo application projects, which are +located in the /FreeRTOS/Demo directory of the official FreeRTOS download. The +demo projects may also include third party software that is not part of FreeRTOS +and is licensed separately to FreeRTOS. Examples of third party software +includes header files provided by chip or tools vendors, linker scripts, +peripheral drivers, etc. All the software in subdirectories of the /FreeRTOS +directory is either open source or distributed with permission, and is free for +use. For the avoidance of doubt, refer to the comments at the top of each +source file. + + +License text: +------------- + +Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. If you wish to use our Amazon +FreeRTOS name, please do so in a fair use way that does not cause confusion. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/port.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/port.c new file mode 100644 index 0000000..271c269 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/port.c @@ -0,0 +1,128 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the ARM CM0 port. + *----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* + * Start first task is a separate function so it can be tested in isolation. + */ +void vPortStartFirstTask( void ); + +/* + * Exception handlers. + */ +void xPortPendSVHandler( void ); +void vPortSVCHandler( void ); + + +/*-----------------------------------------------------------*/ + +__asm void vPortSVCHandler( void ) +{ + /* This function is no longer used, but retained for backward + compatibility. */ +} +/*-----------------------------------------------------------*/ + +__asm void vPortStartFirstTask( void ) +{ + PRESERVE8 + EXTERN __Vectors + + /* Use the NVIC offset register to locate the stack. */ + ldr r0, =__Vectors + ldr r0, [r0] + /* Set the msp back to the start of the stack. */ + msr msp, r0 + + ldr r3, =pxCurrentTCB /* Obtain location of pxCurrentTCB. */ + ldr r1, [r3] + ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + movs r0, #2 /* Switch to the psp stack. */ + msr CONTROL, r0 + pop {r0-r5} /* Pop the registers that are saved automatically. */ + mov lr, r5 /* lr is now in r5. */ + cpsie i /* The first task has its context and interrupts can be enabled. */ + pop {pc} /* Finally, pop the PC to jump to the user defined task code. */ + + ALIGN +} +/*-----------------------------------------------------------*/ + +__asm void xPortPendSVHandler( void ) +{ + extern vPortSafeTaskSwitchContext + extern pxCurrentTCB + + PRESERVE8 + + mrs r0, psp + + ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */ + ldr r2, [r3] + + subs r0, #32 /* Make space for the remaining low registers. */ + str r0, [r2] /* Save the new top of stack. */ + stmia r0!, {r4-r7} /* Store the low registers that are not saved automatically. */ + mov r4, r8 /* Store the high registers. */ + mov r5, r9 + mov r6, r10 + mov r7, r11 + stmia r0!, {r4-r7} + + push {r3, r14} + bl vPortSafeTaskSwitchContext + pop {r2, r3} /* lr goes in r3. r2 now holds tcb pointer. */ + + ldr r1, [r2] + ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */ + adds r0, #16 /* Move to the high registers. */ + ldmia r0!, {r4-r7} /* Pop the high registers. */ + mov r8, r4 + mov r9, r5 + mov r10, r6 + mov r11, r7 + + msr psp, r0 /* Remember the new top of stack for the task. */ + + subs r0, #32 /* Go back for the low registers that are not automatically restored. */ + ldmia r0!, {r4-r7} /* Pop low registers. */ + + bx r3 + ALIGN +} +/*-----------------------------------------------------------*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/portmacro.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/portmacro.h new file mode 100644 index 0000000..85b7735 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf51/portmacro.h @@ -0,0 +1,34 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#include "portmacro_cmsis.h" + +#endif /* PORTMACRO_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/port.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/port.c new file mode 100644 index 0000000..5a09444 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/port.c @@ -0,0 +1,153 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the ARM CM4F port. + *----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + + +/* + * Start first task is a separate function so it can be tested in isolation. + */ +void vPortStartFirstTask( void ); + +/* + * Exception handlers. + */ +void xPortPendSVHandler( void ); +void vPortSVCHandler( void ); + + +/*-----------------------------------------------------------*/ + +__asm void vPortSVCHandler( void ) +{ + PRESERVE8 + + /* Get the location of the current TCB. */ + ldr r3, =pxCurrentTCB + ldr r1, [r3] + ldr r0, [r1] + /* Pop the core registers. */ + ldmia r0!, {r4-r11, r14} + msr psp, r0 + isb + mov r0, #0 + msr basepri, r0 + bx r14 +} +/*-----------------------------------------------------------*/ + +__asm void vPortStartFirstTask( void ) +{ + PRESERVE8 + EXTERN __Vectors + + /* Use the NVIC offset register to locate the stack. */ + ldr r0, =__Vectors + ldr r0, [r0] + /* Set the msp back to the start of the stack. */ + msr msp, r0 + /* Globally enable interrupts. */ + cpsie i + cpsie f + dsb + isb +#ifdef SOFTDEVICE_PRESENT + /* Block kernel interrupts only (PendSV) before calling SVC */ + mov r0, #(configKERNEL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) + msr basepri, r0 +#endif + /* Call SVC to start the first task. */ + svc 0 + + ALIGN +} +/*-----------------------------------------------------------*/ + +__asm void xPortPendSVHandler( void ) +{ + extern uxCriticalNesting; + extern pxCurrentTCB; + extern vTaskSwitchContext; + + PRESERVE8 + + mrs r0, psp + isb + /* Get the location of the current TCB. */ + ldr r3, =pxCurrentTCB + ldr r2, [r3] + + /* Is the task using the FPU context? If so, push high vfp registers. */ + tst r14, #0x10 + it eq + vstmdbeq r0!, {s16-s31} + + /* Save the core registers. */ + stmdb r0!, {r4-r11, r14} + + /* Save the new top of stack into the first member of the TCB. */ + str r0, [r2] + + stmdb sp!, {r3} + mov r0, #(configMAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) + msr basepri, r0 + dsb + isb + bl vTaskSwitchContext + mov r0, #0 + msr basepri, r0 + ldmia sp!, {r3} + + /* The first item in pxCurrentTCB is the task top of stack. */ + ldr r1, [r3] + ldr r0, [r1] + + /* Pop the core registers. */ + ldmia r0!, {r4-r11, r14} + + /* Is the task using the FPU context? If so, pop the high vfp registers + too. */ + tst r14, #0x10 + it eq + vldmiaeq r0!, {s16-s31} + + msr psp, r0 + isb + + bx r14 + + ALIGN +} +/*-----------------------------------------------------------*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/portmacro.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/portmacro.h new file mode 100644 index 0000000..85b7735 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/ARM/nrf52/portmacro.h @@ -0,0 +1,34 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#include "portmacro_cmsis.h" + +#endif /* PORTMACRO_H */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/port_cmsis.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/port_cmsis.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/port_cmsis.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/port_cmsis.c index e27e7c1..d6d209f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/port_cmsis.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/port_cmsis.c @@ -1,74 +1,33 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM4F port. + * Implementation of functions defined in portable.h for the ARM CM0 port. *----------------------------------------------------------*/ /* Scheduler includes. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c index 6a38a80..1eb0a7b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/port_cmsis_systick.c @@ -1,78 +1,37 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* Scheduler includes. */ #include "FreeRTOS.h" #include "task.h" /*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM4F port. + * Implementation of functions defined in portable.h for the ARM CM0 port. * CMSIS compatible layer to menage SysTick ticking source. *----------------------------------------------------------*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h index 92d7050..dd540b7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf51/portmacro_cmsis.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef PORTMACRO_CMSIS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/port_cmsis.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/port_cmsis.c similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/port_cmsis.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/port_cmsis.c index 69ae734..2fbec43 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/port_cmsis.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/port_cmsis.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- * Implementation of functions defined in portable.h for the ARM CM4F port. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c similarity index 70% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c index 31a767e..cd0bce7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c @@ -1,77 +1,35 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* Scheduler includes. */ #include "FreeRTOS.h" #include "task.h" #include "app_util.h" -#include "nrf_log.h" #ifdef SOFTDEVICE_PRESENT #include "nrf_soc.h" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h similarity index 62% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h index 54a7ab8..3d2dee5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h @@ -1,72 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef PORTMACRO_CMSIS_H #define PORTMACRO_CMSIS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/port.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/port.c similarity index 55% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/port.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/port.c index 9c1e752..b11642c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf51/port.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/port.c @@ -1,74 +1,33 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM4F port. + * Implementation of functions defined in portable.h for the ARM CM0 port. *----------------------------------------------------------*/ /* Scheduler includes. */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/portmacro.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/portmacro.h new file mode 100644 index 0000000..3458498 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf51/portmacro.h @@ -0,0 +1,36 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#include "portmacro_cmsis.h" + +#endif /* PORTMACRO_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/port.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/port.c similarity index 58% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/port.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/port.c index cec0778..5b5b4f1 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/GCC/nrf52/port.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/port.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- * Implementation of functions defined in portable.h for the ARM CM4F port. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/portmacro.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/portmacro.h new file mode 100644 index 0000000..3458498 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/GCC/nrf52/portmacro.h @@ -0,0 +1,36 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#include "portmacro_cmsis.h" + +#endif /* PORTMACRO_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/port.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/port.c similarity index 57% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/port.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/port.c index 0575f36..855eefd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf51/port.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/port.c @@ -1,74 +1,33 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM4F port. + * Implementation of functions defined in portable.h for the ARM CM0 port. *----------------------------------------------------------*/ /* Scheduler includes. */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/portmacro.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/portmacro.h new file mode 100644 index 0000000..0db0c52 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf51/portmacro.h @@ -0,0 +1,40 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#include "portmacro_cmsis.h" + +/* Suppress warnings that are generated by the IAR tools, but cannot be fixed in +the source code because to do so would cause other compilers to generate +warnings. */ +#pragma diag_suppress=Pe191 +#pragma diag_suppress=Pa082 + +#endif /* PORTMACRO_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/port.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/port.c similarity index 62% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/port.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/port.c index 5f0f17f..626ea68 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/portable/IAR/nrf52/port.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/port.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- * Implementation of functions defined in portable.h for the ARM CM4F port. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/portmacro.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/portmacro.h new file mode 100644 index 0000000..497bb01 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/portable/IAR/nrf52/portmacro.h @@ -0,0 +1,41 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#include "portmacro_cmsis.h" + +/* Suppress warnings that are generated by the IAR tools, but cannot be fixed in +the source code because to do so would cause other compilers to generate +warnings. */ +#pragma diag_suppress=Pe191 +#pragma diag_suppress=Pa082 + +#endif /* PORTMACRO_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/readme.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/readme.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/readme.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/readme.txt diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/croutine.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/croutine.c similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/croutine.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/croutine.c index 670aada..4efe70b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/croutine.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/croutine.c @@ -1,78 +1,37 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #include "FreeRTOS.h" #include "task.h" #include "croutine.h" /* Remove the whole file is co-routines are not being used. */ -#if ( configUSE_CO_ROUTINES != 0 ) +#if( configUSE_CO_ROUTINES != 0 ) /* * Some kernel aware debuggers require data to be viewed to be global, rather @@ -108,7 +67,7 @@ static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0; */ #define prvAddCoRoutineToReadyQueue( pxCRCB ) \ { \ - if ( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \ + if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \ { \ uxTopCoRoutineReadyPriority = pxCRCB->uxPriority; \ } \ @@ -148,18 +107,18 @@ CRCB_t *pxCoRoutine; /* Allocate the memory that will store the co-routine control block. */ pxCoRoutine = ( CRCB_t * ) pvPortMalloc( sizeof( CRCB_t ) ); - if ( pxCoRoutine ) + if( pxCoRoutine ) { /* If pxCurrentCoRoutine is NULL then this is the first co-routine to be created and the co-routine data structures need initialising. */ - if ( pxCurrentCoRoutine == NULL ) + if( pxCurrentCoRoutine == NULL ) { pxCurrentCoRoutine = pxCoRoutine; prvInitialiseCoRoutineLists(); } /* Check the priority is within limits. */ - if ( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES ) + if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES ) { uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1; } @@ -214,7 +173,7 @@ TickType_t xTimeToWake; /* The list item will be inserted in wake time order. */ listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake ); - if ( xTimeToWake < xCoRoutineTickCount ) + if( xTimeToWake < xCoRoutineTickCount ) { /* Wake time has overflowed. Place this item in the overflow list. */ @@ -227,7 +186,7 @@ TickType_t xTimeToWake; vListInsert( ( List_t * ) pxDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) ); } - if ( pxEventList ) + if( pxEventList ) { /* Also add the co-routine to an event list. If this is done then the function must be called with interrupts disabled. */ @@ -241,7 +200,7 @@ static void prvCheckPendingReadyList( void ) /* Are there any co-routines waiting to get moved to the ready list? These are co-routines that have been readied by an ISR. The ISR cannot access the ready lists itself. */ - while ( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE ) + while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE ) { CRCB_t *pxUnblockedCRCB; @@ -264,13 +223,13 @@ static void prvCheckDelayedList( void ) CRCB_t *pxCRCB; xPassedTicks = xTaskGetTickCount() - xLastTickCount; - while ( xPassedTicks ) + while( xPassedTicks ) { xCoRoutineTickCount++; xPassedTicks--; /* If the tick count has overflowed we need to swap the ready lists. */ - if ( xCoRoutineTickCount == 0 ) + if( xCoRoutineTickCount == 0 ) { List_t * pxTemp; @@ -282,11 +241,11 @@ CRCB_t *pxCRCB; } /* See if this tick has made a timeout expire. */ - while ( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE ) + while( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE ) { pxCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList ); - if ( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) ) + if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) ) { /* Timeout not yet expired. */ break; @@ -302,7 +261,7 @@ CRCB_t *pxCRCB; ( void ) uxListRemove( &( pxCRCB->xGenericListItem ) ); /* Is the co-routine waiting on an event also? */ - if ( pxCRCB->xEventListItem.pvContainer ) + if( pxCRCB->xEventListItem.pvContainer ) { ( void ) uxListRemove( &( pxCRCB->xEventListItem ) ); } @@ -326,9 +285,9 @@ void vCoRoutineSchedule( void ) prvCheckDelayedList(); /* Find the highest priority queue that contains ready co-routines. */ - while ( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) + while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) { - if ( uxTopCoRoutineReadyPriority == 0 ) + if( uxTopCoRoutineReadyPriority == 0 ) { /* No more co-routines to check. */ return; @@ -351,7 +310,7 @@ static void prvInitialiseCoRoutineLists( void ) { UBaseType_t uxPriority; - for ( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ ) + for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ ) { vListInitialise( ( List_t * ) &( pxReadyCoRoutineLists[ uxPriority ] ) ); } @@ -379,7 +338,7 @@ BaseType_t xReturn; ( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) ); vListInsertEnd( ( List_t * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) ); - if ( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority ) + if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority ) { xReturn = pdTRUE; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/event_groups.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/event_groups.c similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/event_groups.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/event_groups.c index 8be425e..d942e15 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/event_groups.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/event_groups.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* Standard includes. */ #include @@ -87,14 +46,6 @@ header files above, but not in this file, in order to generate the correct privileged Vs unprivileged linkage and placement. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ -#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( configUSE_TIMERS == 0 ) - #error configUSE_TIMERS must be set to 1 to make the xEventGroupSetBitFromISR() function available. -#endif - -#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 0 ) - #error INCLUDE_xTimerPendFunctionCall must also be set to one to make the xEventGroupSetBitFromISR() function available. -#endif - /* The following bit fields convey control information in a task's event list item value. It is important they don't clash with the taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */ @@ -115,10 +66,13 @@ typedef struct xEventGroupDefinition EventBits_t uxEventBits; List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */ - #if ( configUSE_TRACE_FACILITY == 1 ) + #if( configUSE_TRACE_FACILITY == 1 ) UBaseType_t uxEventGroupNumber; #endif + #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */ + #endif } EventGroup_t; /*-----------------------------------------------------------*/ @@ -131,28 +85,93 @@ typedef struct xEventGroupDefinition * wait condition is met if any of the bits set in uxBitsToWait for are also set * in uxCurrentEventBits. */ -static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits ); +static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits ) PRIVILEGED_FUNCTION; /*-----------------------------------------------------------*/ -EventGroupHandle_t xEventGroupCreate( void ) -{ -EventGroup_t *pxEventBits; +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) ); - if ( pxEventBits != NULL ) + EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) { - pxEventBits->uxEventBits = 0; - vListInitialise( &( pxEventBits->xTasksWaitingForBits ) ); - traceEVENT_GROUP_CREATE( pxEventBits ); + EventGroup_t *pxEventBits; + + /* A StaticEventGroup_t object must be provided. */ + configASSERT( pxEventGroupBuffer ); + + #if( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + variable of type StaticEventGroup_t equals the size of the real + event group structure. */ + volatile size_t xSize = sizeof( StaticEventGroup_t ); + configASSERT( xSize == sizeof( EventGroup_t ) ); + } + #endif /* configASSERT_DEFINED */ + + /* The user has provided a statically allocated event group - use it. */ + pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 EventGroup_t and StaticEventGroup_t are guaranteed to have the same size and alignment requirement - checked by configASSERT(). */ + + if( pxEventBits != NULL ) + { + pxEventBits->uxEventBits = 0; + vListInitialise( &( pxEventBits->xTasksWaitingForBits ) ); + + #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + { + /* Both static and dynamic allocation can be used, so note that + this event group was created statically in case the event group + is later deleted. */ + pxEventBits->ucStaticallyAllocated = pdTRUE; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + + traceEVENT_GROUP_CREATE( pxEventBits ); + } + else + { + traceEVENT_GROUP_CREATE_FAILED(); + } + + return ( EventGroupHandle_t ) pxEventBits; } - else + +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + + EventGroupHandle_t xEventGroupCreate( void ) { - traceEVENT_GROUP_CREATE_FAILED(); + EventGroup_t *pxEventBits; + + /* Allocate the event group. */ + pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) ); + + if( pxEventBits != NULL ) + { + pxEventBits->uxEventBits = 0; + vListInitialise( &( pxEventBits->xTasksWaitingForBits ) ); + + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* Both static and dynamic allocation can be used, so note this + event group was allocated statically in case the event group is + later deleted. */ + pxEventBits->ucStaticallyAllocated = pdFALSE; + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ + + traceEVENT_GROUP_CREATE( pxEventBits ); + } + else + { + traceEVENT_GROUP_CREATE_FAILED(); + } + + return ( EventGroupHandle_t ) pxEventBits; } - return ( EventGroupHandle_t ) pxEventBits; -} +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ /*-----------------------------------------------------------*/ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) @@ -176,7 +195,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet ); - if ( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor ) + if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor ) { /* All the rendezvous bits are now set - no need to block. */ uxReturn = ( uxOriginalBitValue | uxBitsToSet ); @@ -189,7 +208,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; } else { - if ( xTicksToWait != ( TickType_t ) 0 ) + if( xTicksToWait != ( TickType_t ) 0 ) { traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ); @@ -209,14 +228,15 @@ BaseType_t xTimeoutOccurred = pdFALSE; /* The rendezvous bits were not set, but no block time was specified - just return the current event bit value. */ uxReturn = pxEventBits->uxEventBits; + xTimeoutOccurred = pdTRUE; } } } xAlreadyYielded = xTaskResumeAll(); - if ( xTicksToWait != ( TickType_t ) 0 ) + if( xTicksToWait != ( TickType_t ) 0 ) { - if ( xAlreadyYielded == pdFALSE ) + if( xAlreadyYielded == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -231,7 +251,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; event list item, and they should now be retrieved then cleared. */ uxReturn = uxTaskResetEventItemValue(); - if ( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 ) + if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 ) { /* The task timed out, just return the current event bit value. */ taskENTER_CRITICAL(); @@ -242,7 +262,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; bits it was waiting for were set, it is possible that since it unblocked another task has set the bits. If this is the case then it needs to clear the bits before exiting. */ - if ( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor ) + if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor ) { pxEventBits->uxEventBits &= ~uxBitsToWaitFor; } @@ -267,6 +287,9 @@ BaseType_t xTimeoutOccurred = pdFALSE; traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ); + /* Prevent compiler warnings when trace macros are not used. */ + ( void ) xTimeoutOccurred; + return uxReturn; } /*-----------------------------------------------------------*/ @@ -296,7 +319,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; /* Check to see if the wait condition is already met or not. */ xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits ); - if ( xWaitConditionMet != pdFALSE ) + if( xWaitConditionMet != pdFALSE ) { /* The wait condition has already been met so there is no need to block. */ @@ -304,7 +327,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; xTicksToWait = ( TickType_t ) 0; /* Clear the wait bits if requested to do so. */ - if ( xClearOnExit != pdFALSE ) + if( xClearOnExit != pdFALSE ) { pxEventBits->uxEventBits &= ~uxBitsToWaitFor; } @@ -313,11 +336,12 @@ BaseType_t xTimeoutOccurred = pdFALSE; mtCOVERAGE_TEST_MARKER(); } } - else if ( xTicksToWait == ( TickType_t ) 0 ) + else if( xTicksToWait == ( TickType_t ) 0 ) { /* The wait condition has not been met, but no block time was specified, so just return the current value. */ uxReturn = uxCurrentEventBits; + xTimeoutOccurred = pdTRUE; } else { @@ -325,7 +349,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; set. uxControlBits are used to remember the specified behaviour of this call to xEventGroupWaitBits() - for use when the event bits unblock the task. */ - if ( xClearOnExit != pdFALSE ) + if( xClearOnExit != pdFALSE ) { uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT; } @@ -334,7 +358,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; mtCOVERAGE_TEST_MARKER(); } - if ( xWaitForAllBits != pdFALSE ) + if( xWaitForAllBits != pdFALSE ) { uxControlBits |= eventWAIT_FOR_ALL_BITS; } @@ -358,9 +382,9 @@ BaseType_t xTimeoutOccurred = pdFALSE; } xAlreadyYielded = xTaskResumeAll(); - if ( xTicksToWait != ( TickType_t ) 0 ) + if( xTicksToWait != ( TickType_t ) 0 ) { - if ( xAlreadyYielded == pdFALSE ) + if( xAlreadyYielded == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -375,7 +399,7 @@ BaseType_t xTimeoutOccurred = pdFALSE; event list item, and they should now be retrieved then cleared. */ uxReturn = uxTaskResetEventItemValue(); - if ( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 ) + if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 ) { taskENTER_CRITICAL(); { @@ -384,9 +408,9 @@ BaseType_t xTimeoutOccurred = pdFALSE; /* It is possible that the event bits were updated between this task leaving the Blocked state and running again. */ - if ( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE ) + if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE ) { - if ( xClearOnExit != pdFALSE ) + if( xClearOnExit != pdFALSE ) { pxEventBits->uxEventBits &= ~uxBitsToWaitFor; } @@ -399,11 +423,9 @@ BaseType_t xTimeoutOccurred = pdFALSE; { mtCOVERAGE_TEST_MARKER(); } + xTimeoutOccurred = pdTRUE; } taskEXIT_CRITICAL(); - - /* Prevent compiler warnings when trace macros are not used. */ - xTimeoutOccurred = pdFALSE; } else { @@ -415,6 +437,9 @@ BaseType_t xTimeoutOccurred = pdFALSE; } traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ); + /* Prevent compiler warnings when trace macros are not used. */ + ( void ) xTimeoutOccurred; + return uxReturn; } /*-----------------------------------------------------------*/ @@ -503,7 +528,7 @@ BaseType_t xMatchFound = pdFALSE; pxEventBits->uxEventBits |= uxBitsToSet; /* See if the new bit value should unblock any tasks. */ - while ( pxListItem != pxListEnd ) + while( pxListItem != pxListEnd ) { pxNext = listGET_NEXT( pxListItem ); uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem ); @@ -513,10 +538,10 @@ BaseType_t xMatchFound = pdFALSE; uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES; uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES; - if ( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 ) + if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 ) { /* Just looking for single bit being set. */ - if ( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 ) + if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 ) { xMatchFound = pdTRUE; } @@ -525,7 +550,7 @@ BaseType_t xMatchFound = pdFALSE; mtCOVERAGE_TEST_MARKER(); } } - else if ( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor ) + else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor ) { /* All bits are set. */ xMatchFound = pdTRUE; @@ -535,10 +560,10 @@ BaseType_t xMatchFound = pdFALSE; /* Need all bits to be set, but not all the bits were set. */ } - if ( xMatchFound != pdFALSE ) + if( xMatchFound != pdFALSE ) { /* The bits match. Should the bits be cleared on exit? */ - if ( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 ) + if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 ) { uxBitsToClear |= uxBitsWaitedFor; } @@ -552,7 +577,7 @@ BaseType_t xMatchFound = pdFALSE; eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows that is was unblocked due to its required bits matching, rather than because it timed out. */ - ( void ) xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET ); + vTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET ); } /* Move onto the next list item. Note pxListItem->pxNext is not @@ -580,15 +605,34 @@ const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits ); { traceEVENT_GROUP_DELETE( xEventGroup ); - while ( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 ) + while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 ) { /* Unblock the task, returning 0 as the event list is being deleted - and cannot therefore have any bits set. */ - configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) ); - ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET ); + and cannot therefore have any bits set. */ + configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) ); + vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET ); } - vPortFree( pxEventBits ); + #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) + { + /* The event group can only have been allocated dynamically - free + it again. */ + vPortFree( pxEventBits ); + } + #elif( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + { + /* The event group could have been allocated statically or + dynamically, so check before attempting to free the memory. */ + if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE ) + { + vPortFree( pxEventBits ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ } ( void ) xTaskResumeAll(); } @@ -614,11 +658,11 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co { BaseType_t xWaitConditionMet = pdFALSE; - if ( xWaitForAllBits == pdFALSE ) + if( xWaitForAllBits == pdFALSE ) { /* Task only has to wait for one bit within uxBitsToWaitFor to be set. Is one already set? */ - if ( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 ) + if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 ) { xWaitConditionMet = pdTRUE; } @@ -631,7 +675,7 @@ BaseType_t xWaitConditionMet = pdFALSE; { /* Task has to wait for all the bits in uxBitsToWaitFor to be set. Are they set already? */ - if ( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor ) + if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor ) { xWaitConditionMet = pdTRUE; } @@ -667,7 +711,7 @@ BaseType_t xWaitConditionMet = pdFALSE; UBaseType_t xReturn; EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; - if ( xEventGroup == NULL ) + if( xEventGroup == NULL ) { xReturn = 0; } @@ -679,5 +723,17 @@ BaseType_t xWaitConditionMet = pdFALSE; return xReturn; } -#endif +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vEventGroupSetNumber( void * xEventGroup, UBaseType_t uxEventGroupNumber ) + { + ( ( EventGroup_t * ) xEventGroup )->uxEventGroupNumber = uxEventGroupNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/FreeRTOS.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/FreeRTOS.h similarity index 55% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/FreeRTOS.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/FreeRTOS.h index 5bea616..04b2204 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/FreeRTOS.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/FreeRTOS.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef INC_FREERTOS_H #define INC_FREERTOS_H @@ -103,6 +62,15 @@ extern "C" { /* Definitions specific to the port being used. */ #include "portable.h" +/* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */ +#ifndef configUSE_NEWLIB_REENTRANT + #define configUSE_NEWLIB_REENTRANT 0 +#endif + +/* Required if struct _reent is used. */ +#if ( configUSE_NEWLIB_REENTRANT == 1 ) + #include +#endif /* * Check all the required application specific macros have been defined. * These macros are application specific and (as downloaded) are defined @@ -117,6 +85,10 @@ extern "C" { #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. #endif +#if configMAX_PRIORITIES < 1 + #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. +#endif + #ifndef configUSE_PREEMPTION #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif @@ -129,82 +101,98 @@ extern "C" { #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif +#ifndef configUSE_16_BIT_TICKS + #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_CO_ROUTINES + #define configUSE_CO_ROUTINES 0 +#endif + #ifndef INCLUDE_vTaskPrioritySet - #error Missing definition: INCLUDE_vTaskPrioritySet must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #define INCLUDE_vTaskPrioritySet 0 #endif #ifndef INCLUDE_uxTaskPriorityGet - #error Missing definition: INCLUDE_uxTaskPriorityGet must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #define INCLUDE_uxTaskPriorityGet 0 #endif #ifndef INCLUDE_vTaskDelete - #error Missing definition: INCLUDE_vTaskDelete must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #define INCLUDE_vTaskDelete 0 #endif #ifndef INCLUDE_vTaskSuspend - #error Missing definition: INCLUDE_vTaskSuspend must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #define INCLUDE_vTaskSuspend 0 #endif #ifndef INCLUDE_vTaskDelayUntil - #error Missing definition: INCLUDE_vTaskDelayUntil must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #define INCLUDE_vTaskDelayUntil 0 #endif #ifndef INCLUDE_vTaskDelay - #error Missing definition: INCLUDE_vTaskDelay must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #define INCLUDE_vTaskDelay 0 #endif -#ifndef configUSE_16_BIT_TICKS - #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#ifndef INCLUDE_xTaskGetIdleTaskHandle + #define INCLUDE_xTaskGetIdleTaskHandle 0 #endif -#ifndef configMAX_PRIORITIES - #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. +#ifndef INCLUDE_xTaskAbortDelay + #define INCLUDE_xTaskAbortDelay 0 #endif -#ifndef configUSE_CO_ROUTINES - #define configUSE_CO_ROUTINES 0 +#ifndef INCLUDE_xQueueGetMutexHolder + #define INCLUDE_xQueueGetMutexHolder 0 #endif -#if configUSE_CO_ROUTINES != 0 - #ifndef configMAX_CO_ROUTINE_PRIORITIES - #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. - #endif +#ifndef INCLUDE_xSemaphoreGetMutexHolder + #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder #endif -#ifndef INCLUDE_xTaskGetIdleTaskHandle - #define INCLUDE_xTaskGetIdleTaskHandle 0 +#ifndef INCLUDE_xTaskGetHandle + #define INCLUDE_xTaskGetHandle 0 #endif -#ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle - #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0 +#ifndef INCLUDE_uxTaskGetStackHighWaterMark + #define INCLUDE_uxTaskGetStackHighWaterMark 0 #endif -#ifndef INCLUDE_xQueueGetMutexHolder - #define INCLUDE_xQueueGetMutexHolder 0 +#ifndef INCLUDE_eTaskGetState + #define INCLUDE_eTaskGetState 0 #endif -#ifndef INCLUDE_xSemaphoreGetMutexHolder - #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder +#ifndef INCLUDE_xTaskResumeFromISR + #define INCLUDE_xTaskResumeFromISR 1 #endif -#ifndef INCLUDE_pcTaskGetTaskName - #define INCLUDE_pcTaskGetTaskName 0 +#ifndef INCLUDE_xTimerPendFunctionCall + #define INCLUDE_xTimerPendFunctionCall 0 #endif -#ifndef configUSE_APPLICATION_TASK_TAG - #define configUSE_APPLICATION_TASK_TAG 0 +#ifndef INCLUDE_xTaskGetSchedulerState + #define INCLUDE_xTaskGetSchedulerState 0 #endif -#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS - #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 +#ifndef INCLUDE_xTaskGetCurrentTaskHandle + #define INCLUDE_xTaskGetCurrentTaskHandle 0 #endif -#ifndef INCLUDE_uxTaskGetStackHighWaterMark - #define INCLUDE_uxTaskGetStackHighWaterMark 0 +#if configUSE_CO_ROUTINES != 0 + #ifndef configMAX_CO_ROUTINE_PRIORITIES + #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. + #endif #endif -#ifndef INCLUDE_eTaskGetState - #define INCLUDE_eTaskGetState 0 +#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK + #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 +#endif + +#ifndef configUSE_APPLICATION_TASK_TAG + #define configUSE_APPLICATION_TASK_TAG 0 +#endif + +#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS + #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 #endif #ifndef configUSE_RECURSIVE_MUTEXES @@ -243,18 +231,6 @@ extern "C" { #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h #endif -#ifndef INCLUDE_xTaskResumeFromISR - #define INCLUDE_xTaskResumeFromISR 1 -#endif - -#ifndef INCLUDE_xEventGroupSetBitFromISR - #define INCLUDE_xEventGroupSetBitFromISR 0 -#endif - -#ifndef INCLUDE_xTimerPendFunctionCall - #define INCLUDE_xTimerPendFunctionCall 0 -#endif - #ifndef configASSERT #define configASSERT( x ) #define configASSERT_DEFINED 0 @@ -279,15 +255,6 @@ extern "C" { #endif /* configUSE_TIMERS */ -#ifndef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 0 -#endif - -#ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 -#endif - - #ifndef portSET_INTERRUPT_MASK_FROM_ISR #define portSET_INTERRUPT_MASK_FROM_ISR() 0 #endif @@ -315,6 +282,7 @@ extern "C" { #if ( configQUEUE_REGISTRY_SIZE < 1 ) #define vQueueAddToRegistry( xQueue, pcName ) #define vQueueUnregisterQueue( xQueue ) + #define pcQueueGetName( xQueue ) #endif #ifndef portPOINTER_SIZE_TYPE @@ -387,6 +355,14 @@ extern "C" { #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #endif +#ifndef traceBLOCKING_ON_QUEUE_PEEK + /* Task is about to block because it cannot read from a + queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + upon which the read was attempted. pxCurrentTCB points to the TCB of the + task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) +#endif + #ifndef traceBLOCKING_ON_QUEUE_SEND /* Task is about to block because it cannot write to a queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore @@ -399,12 +375,24 @@ extern "C" { #define configCHECK_FOR_STACK_OVERFLOW 0 #endif +#ifndef configRECORD_STACK_HIGH_ADDRESS + #define configRECORD_STACK_HIGH_ADDRESS 0 +#endif + +#ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H + #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 +#endif + /* The following event macros are embedded in the kernel API calls. */ #ifndef traceMOVED_TASK_TO_READY_STATE #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) #endif +#ifndef tracePOST_MOVED_TASK_TO_READY_STATE + #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) +#endif + #ifndef traceQUEUE_CREATE #define traceQUEUE_CREATE( pxNewQueue ) #endif @@ -461,6 +449,10 @@ extern "C" { #define traceQUEUE_PEEK( pxQueue ) #endif +#ifndef traceQUEUE_PEEK_FAILED + #define traceQUEUE_PEEK_FAILED( pxQueue ) +#endif + #ifndef traceQUEUE_PEEK_FROM_ISR #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) #endif @@ -506,7 +498,7 @@ extern "C" { #endif #ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL() + #define traceTASK_DELAY_UNTIL( x ) #endif #ifndef traceTASK_DELAY @@ -617,6 +609,86 @@ extern "C" { #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName) #endif +#ifndef traceTASK_NOTIFY_TAKE_BLOCK + #define traceTASK_NOTIFY_TAKE_BLOCK() +#endif + +#ifndef traceTASK_NOTIFY_TAKE + #define traceTASK_NOTIFY_TAKE() +#endif + +#ifndef traceTASK_NOTIFY_WAIT_BLOCK + #define traceTASK_NOTIFY_WAIT_BLOCK() +#endif + +#ifndef traceTASK_NOTIFY_WAIT + #define traceTASK_NOTIFY_WAIT() +#endif + +#ifndef traceTASK_NOTIFY + #define traceTASK_NOTIFY() +#endif + +#ifndef traceTASK_NOTIFY_FROM_ISR + #define traceTASK_NOTIFY_FROM_ISR() +#endif + +#ifndef traceTASK_NOTIFY_GIVE_FROM_ISR + #define traceTASK_NOTIFY_GIVE_FROM_ISR() +#endif + +#ifndef traceSTREAM_BUFFER_CREATE_FAILED + #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED + #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_CREATE + #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_DELETE + #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_RESET + #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) +#endif + +#ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND + #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_SEND + #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) +#endif + +#ifndef traceSTREAM_BUFFER_SEND_FAILED + #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_SEND_FROM_ISR + #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) +#endif + +#ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE + #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_RECEIVE + #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) +#endif + +#ifndef traceSTREAM_BUFFER_RECEIVE_FAILED + #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR + #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) +#endif + #ifndef configGENERATE_RUN_TIME_STATS #define configGENERATE_RUN_TIME_STATS 0 #endif @@ -651,14 +723,6 @@ extern "C" { #define portYIELD_WITHIN_API portYIELD #endif -#ifndef pvPortMallocAligned - #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) ) -#endif - -#ifndef vPortFreeAligned - #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree ) -#endif - #ifndef portSUPPRESS_TICKS_AND_SLEEP #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) #endif @@ -675,6 +739,10 @@ extern "C" { #define configUSE_TICKLESS_IDLE 0 #endif +#ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING + #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) +#endif + #ifndef configPRE_SLEEP_PROCESSING #define configPRE_SLEEP_PROCESSING( x ) #endif @@ -691,6 +759,10 @@ extern "C" { #define portTASK_USES_FLOATING_POINT() #endif +#ifndef portTASK_CALLS_SECURE_FUNCTIONS + #define portTASK_CALLS_SECURE_FUNCTIONS() +#endif + #ifndef configUSE_TIME_SLICING #define configUSE_TIME_SLICING 1 #endif @@ -699,10 +771,6 @@ extern "C" { #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 #endif -#ifndef configUSE_NEWLIB_REENTRANT - #define configUSE_NEWLIB_REENTRANT 0 -#endif - #ifndef configUSE_STATS_FORMATTING_FUNCTIONS #define configUSE_STATS_FORMATTING_FUNCTIONS 0 #endif @@ -743,7 +811,42 @@ extern "C" { #define portTICK_TYPE_IS_ATOMIC 0 #endif -#if ( portTICK_TYPE_IS_ATOMIC == 0 ) +#ifndef configSUPPORT_STATIC_ALLOCATION + /* Defaults to 0 for backward compatibility. */ + #define configSUPPORT_STATIC_ALLOCATION 0 +#endif + +#ifndef configSUPPORT_DYNAMIC_ALLOCATION + /* Defaults to 1 for backward compatibility. */ + #define configSUPPORT_DYNAMIC_ALLOCATION 1 +#endif + +#ifndef configSTACK_DEPTH_TYPE + /* Defaults to uint16_t for backward compatibility, but can be overridden + in FreeRTOSConfig.h if uint16_t is too restrictive. */ + #define configSTACK_DEPTH_TYPE uint16_t +#endif + +/* Sanity check the configuration. */ +#if( configUSE_TICKLESS_IDLE != 0 ) + #if( INCLUDE_vTaskSuspend != 1 ) + #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 + #endif /* INCLUDE_vTaskSuspend */ +#endif /* configUSE_TICKLESS_IDLE */ + +#if( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) + #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. +#endif + +#if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) + #error configUSE_MUTEXES must be set to 1 to use recursive mutexes +#endif + +#ifndef configINITIAL_TICK_COUNT + #define configINITIAL_TICK_COUNT 0 +#endif + +#if( portTICK_TYPE_IS_ATOMIC == 0 ) /* Either variables of tick type cannot be read atomically, or portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when the tick count is returned to the standard critical section macros. */ @@ -766,6 +869,32 @@ V8 if desired. */ #define configENABLE_BACKWARD_COMPATIBILITY 1 #endif +#ifndef configPRINTF + /* configPRINTF() was not defined, so define it away to nothing. To use + configPRINTF() then define it as follows (where MyPrintFunction() is + provided by the application writer): + + void MyPrintFunction(const char *pcFormat, ... ); + #define configPRINTF( X ) MyPrintFunction X + + Then call like a standard printf() function, but placing brackets around + all parameters so they are passed as a single parameter. For example: + configPRINTF( ("Value = %d", MyVariable) ); */ + #define configPRINTF( X ) +#endif + +#ifndef configMAX + /* The application writer has not provided their own MAX macro, so define + the following generic implementation. */ + #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) +#endif + +#ifndef configMIN + /* The application writer has not provided their own MAX macro, so define + the following generic implementation. */ + #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) +#endif + #if configENABLE_BACKWARD_COMPATIBILITY == 1 #define eTaskStateGet eTaskGetState #define portTickType TickType_t @@ -782,6 +911,10 @@ V8 if desired. */ #define xCoRoutineHandle CoRoutineHandle_t #define pdTASK_HOOK_CODE TaskHookFunction_t #define portTICK_RATE_MS portTICK_PERIOD_MS + #define pcTaskGetTaskName pcTaskGetName + #define pcTimerGetTimerName pcTimerGetName + #define pcQueueGetQueueName pcQueueGetName + #define vTaskGetTaskInfo vTaskGetInfo /* Backward compatibility within the scheduler code only - these definitions are not really required but are included for completeness. */ @@ -791,6 +924,243 @@ V8 if desired. */ #define xList List_t #endif /* configENABLE_BACKWARD_COMPATIBILITY */ +#if( configUSE_ALTERNATIVE_API != 0 ) + #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 +#endif + +/* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even +if floating point hardware is otherwise supported by the FreeRTOS port in use. +This constant is not supported by all FreeRTOS ports that include floating +point support. */ +#ifndef configUSE_TASK_FPU_SUPPORT + #define configUSE_TASK_FPU_SUPPORT 1 +#endif + +/* + * In line with software engineering best practice, FreeRTOS implements a strict + * data hiding policy, so the real structures used by FreeRTOS to maintain the + * state of tasks, queues, semaphores, etc. are not accessible to the application + * code. However, if the application writer wants to statically allocate such + * an object then the size of the object needs to be know. Dummy structures + * that are guaranteed to have the same size and alignment requirements of the + * real objects are used for this purpose. The dummy list and list item + * structures below are used for inclusion in such a dummy structure. + */ +struct xSTATIC_LIST_ITEM +{ + TickType_t xDummy1; + void *pvDummy2[ 4 ]; +}; +typedef struct xSTATIC_LIST_ITEM StaticListItem_t; + +/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ +struct xSTATIC_MINI_LIST_ITEM +{ + TickType_t xDummy1; + void *pvDummy2[ 2 ]; +}; +typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; + +/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ +typedef struct xSTATIC_LIST +{ + UBaseType_t uxDummy1; + void *pvDummy2; + StaticMiniListItem_t xDummy3; +} StaticList_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the Task structure used internally by + * FreeRTOS is not accessible to application code. However, if the application + * writer wants to statically allocate the memory required to create a task then + * the size of the task object needs to be know. The StaticTask_t structure + * below is provided for this purpose. Its sizes and alignment requirements are + * guaranteed to match those of the genuine structure, no matter which + * architecture is being used, and no matter how the values in FreeRTOSConfig.h + * are set. Its contents are somewhat obfuscated in the hope users will + * recognise that it would be unwise to make direct use of the structure members. + */ +typedef struct xSTATIC_TCB +{ + void *pxDummy1; + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xDummy2; + #endif + StaticListItem_t xDummy3[ 2 ]; + UBaseType_t uxDummy5; + void *pxDummy6; + uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + void *pxDummy8; + #endif + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxDummy9; + #endif + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy10[ 2 ]; + #endif + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxDummy12[ 2 ]; + #endif + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + void *pxDummy14; + #endif + #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void *pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulDummy16; + #endif + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + struct _reent xDummy17; + #endif + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t ulDummy18; + uint8_t ucDummy19; + #endif + #if( ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) || ( portUSING_MPU_WRAPPERS == 1 ) ) + uint8_t uxDummy20; + #endif + + #if( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDummy21; + #endif + +} StaticTask_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the Queue structure used internally by + * FreeRTOS is not accessible to application code. However, if the application + * writer wants to statically allocate the memory required to create a queue + * then the size of the queue object needs to be know. The StaticQueue_t + * structure below is provided for this purpose. Its sizes and alignment + * requirements are guaranteed to match those of the genuine structure, no + * matter which architecture is being used, and no matter how the values in + * FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in the hope + * users will recognise that it would be unwise to make direct use of the + * structure members. + */ +typedef struct xSTATIC_QUEUE +{ + void *pvDummy1[ 3 ]; + + union + { + void *pvDummy2; + UBaseType_t uxDummy2; + } u; + + StaticList_t xDummy3[ 2 ]; + UBaseType_t uxDummy4[ 3 ]; + uint8_t ucDummy5[ 2 ]; + + #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy6; + #endif + + #if ( configUSE_QUEUE_SETS == 1 ) + void *pvDummy7; + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy8; + uint8_t ucDummy9; + #endif + +} StaticQueue_t; +typedef StaticQueue_t StaticSemaphore_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the event group structure used + * internally by FreeRTOS is not accessible to application code. However, if + * the application writer wants to statically allocate the memory required to + * create an event group then the size of the event group object needs to be + * know. The StaticEventGroup_t structure below is provided for this purpose. + * Its sizes and alignment requirements are guaranteed to match those of the + * genuine structure, no matter which architecture is being used, and no matter + * how the values in FreeRTOSConfig.h are set. Its contents are somewhat + * obfuscated in the hope users will recognise that it would be unwise to make + * direct use of the structure members. + */ +typedef struct xSTATIC_EVENT_GROUP +{ + TickType_t xDummy1; + StaticList_t xDummy2; + + #if( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy3; + #endif + + #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy4; + #endif + +} StaticEventGroup_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the software timer structure used + * internally by FreeRTOS is not accessible to application code. However, if + * the application writer wants to statically allocate the memory required to + * create a software timer then the size of the queue object needs to be know. + * The StaticTimer_t structure below is provided for this purpose. Its sizes + * and alignment requirements are guaranteed to match those of the genuine + * structure, no matter which architecture is being used, and no matter how the + * values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in + * the hope users will recognise that it would be unwise to make direct use of + * the structure members. + */ +typedef struct xSTATIC_TIMER +{ + void *pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + UBaseType_t uxDummy4; + void *pvDummy5[ 2 ]; + #if( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy6; + #endif + + #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy7; + #endif + +} StaticTimer_t; + +/* +* In line with software engineering best practice, especially when supplying a +* library that is likely to change in future versions, FreeRTOS implements a +* strict data hiding policy. This means the stream buffer structure used +* internally by FreeRTOS is not accessible to application code. However, if +* the application writer wants to statically allocate the memory required to +* create a stream buffer then the size of the stream buffer object needs to be +* know. The StaticStreamBuffer_t structure below is provided for this purpose. +* Its size and alignment requirements are guaranteed to match those of the +* genuine structure, no matter which architecture is being used, and no matter +* how the values in FreeRTOSConfig.h are set. Its contents are somewhat +* obfuscated in the hope users will recognise that it would be unwise to make +* direct use of the structure members. +*/ +typedef struct xSTATIC_STREAM_BUFFER +{ + size_t uxDummy1[ 4 ]; + void * pvDummy2[ 3 ]; + uint8_t ucDummy3; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy4; + #endif +} StaticStreamBuffer_t; + +/* Message buffers are built on stream buffers. */ +typedef StaticStreamBuffer_t StaticMessageBuffer_t; + #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/StackMacros.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/StackMacros.h new file mode 100644 index 0000000..127b153 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/StackMacros.h @@ -0,0 +1,134 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef STACK_MACROS_H +#define STACK_MACROS_H + +#ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ + #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. +#endif + +/* + * Call the stack overflow hook function if the stack of the task being swapped + * out is currently overflowed, or looks like it might have overflowed in the + * past. + * + * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check + * the current stack state only - comparing the current top of stack value to + * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 + * will also cause the last few stack bytes to be checked to ensure the value + * to which the bytes were set when the task was created have not been + * overwritten. Note this second test does not guarantee that an overflowed + * stack will always be recognised. + */ + +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) + + /* Only the current stack state is to be checked. */ + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) + + /* Only the current stack state is to be checked. */ + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) + + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ + const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ + \ + if( ( pulStack[ 0 ] != ulCheckValue ) || \ + ( pulStack[ 1 ] != ulCheckValue ) || \ + ( pulStack[ 2 ] != ulCheckValue ) || \ + ( pulStack[ 3 ] != ulCheckValue ) ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) + + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ +/*-----------------------------------------------------------*/ + +/* Remove stack overflow macro if not being used. */ +#ifndef taskCHECK_FOR_STACK_OVERFLOW + #define taskCHECK_FOR_STACK_OVERFLOW() +#endif + + + +#endif /* STACK_MACROS_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/croutine.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/croutine.h similarity index 83% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/croutine.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/croutine.h index 1d12dd3..502045c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/croutine.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/croutine.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef CO_ROUTINE_H #define CO_ROUTINE_H @@ -137,7 +96,7 @@ typedef struct corCoRoutineControlBlock // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // This co-routine just delays for a fixed period, then toggles // an LED. Two co-routines are created using this function, so @@ -161,7 +120,7 @@ typedef struct corCoRoutineControlBlock // Create two co-routines at priority 0. The first is given index 0 // so (from the code above) toggles LED 5 every 200 ticks. The second // is given index 1 so toggles LED 6 every 400 ticks. - for ( uxIndex = 0; uxIndex < 2; uxIndex++ ) + for( uxIndex = 0; uxIndex < 2; uxIndex++ ) { xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex ); } @@ -203,7 +162,7 @@ BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPri // infinite loop. void vApplicationIdleHook( void ) { - for ( ;; ) + for( ;; ) { vCoRoutineSchedule(); } @@ -232,7 +191,7 @@ void vCoRoutineSchedule( void ); // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // Co-routine functionality goes here. } @@ -243,7 +202,7 @@ void vCoRoutineSchedule( void ); * \defgroup crSTART crSTART * \ingroup Tasks */ -#define crSTART( pxCRCB ) switch ( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: +#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: /** * croutine. h @@ -263,7 +222,7 @@ void vCoRoutineSchedule( void ); // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // Co-routine functionality goes here. } @@ -315,7 +274,7 @@ void vCoRoutineSchedule( void ); // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // Delay for 200ms. crDELAY( xHandle, xDelayTime ); @@ -330,7 +289,7 @@ void vCoRoutineSchedule( void ); * \ingroup Tasks */ #define crDELAY( xHandle, xTicksToDelay ) \ - if ( ( xTicksToDelay ) > 0 ) \ + if( ( xTicksToDelay ) > 0 ) \ { \ vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ } \ @@ -396,12 +355,12 @@ void vCoRoutineSchedule( void ); // Co-routines must begin with a call to crSTART(). crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // This assumes the queue has already been created. crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult ); - if ( xResult != pdPASS ) + if( xResult != pdPASS ) { // The message was not posted! } @@ -422,12 +381,12 @@ void vCoRoutineSchedule( void ); #define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ { \ *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if ( *( pxResult ) == errQUEUE_BLOCKED ) \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ { \ crSET_STATE0( ( xHandle ) ); \ *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ } \ - if ( *pxResult == errQUEUE_YIELD ) \ + if( *pxResult == errQUEUE_YIELD ) \ { \ crSET_STATE1( ( xHandle ) ); \ *pxResult = pdPASS; \ @@ -494,12 +453,12 @@ void vCoRoutineSchedule( void ); // All co-routines must start with a call to crSTART(). crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // Wait for data to become available on the queue. crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); - if ( xResult == pdPASS ) + if( xResult == pdPASS ) { // We received the LED to flash - flash it! vParTestToggleLED( uxLEDToFlash ); @@ -514,12 +473,12 @@ void vCoRoutineSchedule( void ); #define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ { \ *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if ( *( pxResult ) == errQUEUE_BLOCKED ) \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ { \ crSET_STATE0( ( xHandle ) ); \ *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ } \ - if ( *( pxResult ) == errQUEUE_YIELD ) \ + if( *( pxResult ) == errQUEUE_YIELD ) \ { \ crSET_STATE1( ( xHandle ) ); \ *( pxResult ) = pdPASS; \ @@ -578,14 +537,14 @@ void vCoRoutineSchedule( void ); // All co-routines must start with a call to crSTART(). crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // Wait for data to become available on the queue. This assumes the // queue xCommsRxQueue has already been created! crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); // Was a character received? - if ( xResult == pdPASS ) + if( xResult == pdPASS ) { // Process the character here. } @@ -603,7 +562,7 @@ void vCoRoutineSchedule( void ); BaseType_t xCRWokenByPost = pdFALSE; // We loop around reading characters until there are none left in the UART. - while ( UART_RX_REG_NOT_EMPTY() ) + while( UART_RX_REG_NOT_EMPTY() ) { // Obtain the character from the UART. cRxedChar = UART_RX_REG; @@ -678,12 +637,12 @@ void vCoRoutineSchedule( void ); // All co-routines must start with a call to crSTART(). crSTART( xHandle ); - for ( ;; ) + for( ;; ) { // Send the next character to the queue. crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult ); - if ( xResult == pdPASS ) + if( xResult == pdPASS ) { // The character was successfully posted to the queue. } @@ -701,7 +660,7 @@ void vCoRoutineSchedule( void ); // cCharToTx will maintain its value across the delay as it is // declared static. cCharToTx++; - if ( cCharToTx > 'x' ) + if( cCharToTx > 'x' ) { cCharToTx = 'a'; } @@ -718,13 +677,13 @@ void vCoRoutineSchedule( void ); char cCharToTx; BaseType_t xCRWokenByPost = pdFALSE; - while ( UART_TX_REG_EMPTY() ) + while( UART_TX_REG_EMPTY() ) { // Are there any characters in the queue waiting to be sent? // xCRWokenByPost will automatically be set to pdTRUE if a co-routine // is woken by the post - ensuring that only a single co-routine is // woken no matter how many times we go around this loop. - if ( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) ) + if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) ) { SEND_CHARACTER( cCharToTx ); } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/deprecated_definitions.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/deprecated_definitions.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/deprecated_definitions.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/deprecated_definitions.h index e5c0bb2..113e78b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/deprecated_definitions.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/deprecated_definitions.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef DEPRECATED_DEFINITIONS_H #define DEPRECATED_DEFINITIONS_H diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/event_groups.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/event_groups.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/event_groups.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/event_groups.h index b18b126..34e6926 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/event_groups.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/event_groups.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef EVENT_GROUPS_H #define EVENT_GROUPS_H @@ -74,6 +33,7 @@ #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" #endif +/* FreeRTOS includes. */ #include "timers.h" #ifdef __cplusplus @@ -137,7 +97,17 @@ typedef TickType_t EventBits_t; EventGroupHandle_t xEventGroupCreate( void ); * - * Create a new event group. This function cannot be called from an interrupt. + * Create a new event group. + * + * Internally, within the FreeRTOS implementation, event groups use a [small] + * block of memory, in which the event group's structure is stored. If an event + * groups is created using xEventGropuCreate() then the required memory is + * automatically dynamically allocated inside the xEventGroupCreate() function. + * (see http://www.freertos.org/a00111.html). If an event group is created + * using xEventGropuCreateStatic() then the application writer must instead + * provide the memory that will get used by the event group. + * xEventGroupCreateStatic() therefore allows an event group to be created + * without using any dynamic memory allocation. * * Although event groups are not related to ticks, for internal implementation * reasons the number of bits available for use in an event group is dependent @@ -160,7 +130,7 @@ typedef TickType_t EventBits_t; xCreatedEventGroup = xEventGroupCreate(); // Was the event group created successfully? - if ( xCreatedEventGroup == NULL ) + if( xCreatedEventGroup == NULL ) { // The event group was not created because there was insufficient // FreeRTOS heap available. @@ -173,7 +143,62 @@ typedef TickType_t EventBits_t; * \defgroup xEventGroupCreate xEventGroupCreate * \ingroup EventGroup */ -EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#endif + +/** + * event_groups.h + *
      + EventGroupHandle_t xEventGroupCreateStatic( EventGroupHandle_t * pxEventGroupBuffer );
      + 
      + * + * Create a new event group. + * + * Internally, within the FreeRTOS implementation, event groups use a [small] + * block of memory, in which the event group's structure is stored. If an event + * groups is created using xEventGropuCreate() then the required memory is + * automatically dynamically allocated inside the xEventGroupCreate() function. + * (see http://www.freertos.org/a00111.html). If an event group is created + * using xEventGropuCreateStatic() then the application writer must instead + * provide the memory that will get used by the event group. + * xEventGroupCreateStatic() therefore allows an event group to be created + * without using any dynamic memory allocation. + * + * Although event groups are not related to ticks, for internal implementation + * reasons the number of bits available for use in an event group is dependent + * on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h. If + * configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit + * 0 to bit 7). If configUSE_16_BIT_TICKS is set to 0 then each event group has + * 24 usable bits (bit 0 to bit 23). The EventBits_t type is used to store + * event bits within an event group. + * + * @param pxEventGroupBuffer pxEventGroupBuffer must point to a variable of type + * StaticEventGroup_t, which will be then be used to hold the event group's data + * structures, removing the need for the memory to be allocated dynamically. + * + * @return If the event group was created then a handle to the event group is + * returned. If pxEventGroupBuffer was NULL then NULL is returned. + * + * Example usage: +
      +	// StaticEventGroup_t is a publicly accessible structure that has the same
      +	// size and alignment requirements as the real event group structure.  It is
      +	// provided as a mechanism for applications to know the size of the event
      +	// group (which is dependent on the architecture and configuration file
      +	// settings) without breaking the strict data hiding policy by exposing the
      +	// real event group internals.  This StaticEventGroup_t variable is passed
      +	// into the xSemaphoreCreateEventGroupStatic() function and is used to store
      +	// the event group's data structures
      +	StaticEventGroup_t xEventGroupBuffer;
      +
      +	// Create the event group without dynamically allocating any memory.
      +	xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );
      +   
      + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) PRIVILEGED_FUNCTION; +#endif /** * event_groups.h @@ -245,15 +270,15 @@ EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; pdFALSE, // Don't wait for both bits, either bit will do. xTicksToWait ); // Wait a maximum of 100ms for either bit to be set. - if ( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) + if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) { // xEventGroupWaitBits() returned because both bits were set. } - else if ( ( uxBits & BIT_0 ) != 0 ) + else if( ( uxBits & BIT_0 ) != 0 ) { // xEventGroupWaitBits() returned because just BIT_0 was set. } - else if ( ( uxBits & BIT_4 ) != 0 ) + else if( ( uxBits & BIT_4 ) != 0 ) { // xEventGroupWaitBits() returned because just BIT_4 was set. } @@ -300,17 +325,17 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits xEventGroup, // The event group being updated. BIT_0 | BIT_4 );// The bits being cleared. - if ( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) + if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) { // Both bit 0 and bit 4 were set before xEventGroupClearBits() was // called. Both will now be clear (not set). } - else if ( ( uxBits & BIT_0 ) != 0 ) + else if( ( uxBits & BIT_0 ) != 0 ) { // Bit 0 was set before xEventGroupClearBits() was called. It will // now be clear. } - else if ( ( uxBits & BIT_4 ) != 0 ) + else if( ( uxBits & BIT_4 ) != 0 ) { // Bit 4 was set before xEventGroupClearBits() was called. It will // now be clear. @@ -370,17 +395,17 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit xEventGroup, // The event group being updated. BIT_0 | BIT_4 ); // The bits being set. - if ( xResult == pdPASS ) + if( xResult == pdPASS ) { // The message was posted successfully. } } - * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR + * \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR * \ingroup EventGroup */ -#if ( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); +#if( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; #else #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) #endif @@ -428,18 +453,18 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit xEventGroup, // The event group being updated. BIT_0 | BIT_4 );// The bits being set. - if ( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) + if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) { // Both bit 0 and bit 4 remained set when the function returned. } - else if ( ( uxBits & BIT_0 ) != 0 ) + else if( ( uxBits & BIT_0 ) != 0 ) { // Bit 0 remained set when the function returned, but bit 4 was // cleared. It might be that bit 4 was cleared automatically as a // task that was waiting for bit 4 was removed from the Blocked // state. } - else if ( ( uxBits & BIT_4 ) != 0 ) + else if( ( uxBits & BIT_4 ) != 0 ) { // Bit 4 remained set when the function returned, but bit 0 was // cleared. It might be that bit 0 was cleared automatically as a @@ -470,7 +495,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * Setting bits in an event group is not a deterministic operation because there * are an unknown number of tasks that may be waiting for the bit or bits being * set. FreeRTOS does not allow nondeterministic operations to be performed in - * interrupts or from critical sections. Therefore xEventGroupSetBitFromISR() + * interrupts or from critical sections. Therefore xEventGroupSetBitsFromISR() * sends a message to the timer task to have the set operation performed in the * context of the timer task - where a scheduler lock is used in place of a * critical section. @@ -518,7 +543,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ &xHigherPriorityTaskWoken ); // Was the message posted successfully? - if ( xResult == pdPASS ) + if( xResult == pdPASS ) { // If xHigherPriorityTaskWoken is now set to pdTRUE then a context // switch should be requested. The macro used is port specific and @@ -531,8 +556,8 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR * \ingroup EventGroup */ -#if ( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); +#if( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; #else #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) #endif @@ -600,7 +625,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ EventBits_t uxReturn; TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS; - for ( ;; ) + for( ;; ) { // Perform task functionality here. @@ -611,7 +636,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ // for this to happen. uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait ); - if ( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS ) + if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS ) { // All three tasks reached the synchronisation point before the call // to xEventGroupSync() timed out. @@ -621,7 +646,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ void vTask1( void *pvParameters ) { - for ( ;; ) + for( ;; ) { // Perform task functionality here. @@ -640,7 +665,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ void vTask2( void *pvParameters ) { - for ( ;; ) + for( ;; ) { // Perform task functionality here. @@ -697,7 +722,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR * \ingroup EventGroup */ -EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); +EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** * event_groups.h @@ -711,14 +736,16 @@ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); * * @param xEventGroup The event group being deleted. */ -void vEventGroupDelete( EventGroupHandle_t xEventGroup ); +void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /* For internal use only. */ -void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ); -void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ); +void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; +void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; + #if (configUSE_TRACE_FACILITY == 1) - UBaseType_t uxEventGroupGetNumber( void* xEventGroup ); + UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION; + void vEventGroupSetNumber( void* xEventGroup, UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; #endif #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/list.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/list.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/list.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/list.h index 091e44f..e3e569f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/list.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/list.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* * This is the list implementation used by the scheduler. While it is tailored @@ -143,7 +102,7 @@ then check that the known values do not get corrupted during the execution of the application. These may catch the list data structures being overwritten in memory. They will not catch data errors caused by incorrect configuration or use of FreeRTOS.*/ -#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) +#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) /* Define the macros to do nothing. */ #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE @@ -180,19 +139,19 @@ use of FreeRTOS.*/ */ struct xLIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ void * configLIST_VOLATILE pvContainer; /*< Pointer to the list in which this list item is placed (if any). */ - listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ }; typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ struct xMINI_LIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ configLIST_VOLATILE TickType_t xItemValue; struct xLIST_ITEM * configLIST_VOLATILE pxNext; struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; @@ -205,9 +164,9 @@ typedef struct xMINI_LIST_ITEM MiniListItem_t; typedef struct xLIST { listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE UBaseType_t uxNumberOfItems; - ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ - MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ + volatile UBaseType_t uxNumberOfItems; + ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ + MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ } List_t; @@ -321,7 +280,7 @@ List_t * const pxConstList = ( pxList ); \ /* Increment the index to the next item and return the item, ensuring */ \ /* we don't return the marker used at the end of the list. */ \ ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - if ( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ + if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ { \ ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ } \ @@ -383,7 +342,7 @@ List_t * const pxConstList = ( pxList ); \ * \page vListInitialise vListInitialise * \ingroup LinkedList */ -void vListInitialise( List_t * const pxList ); +void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION; /* * Must be called before a list item is used. This sets the list container to @@ -394,7 +353,7 @@ void vListInitialise( List_t * const pxList ); * \page vListInitialiseItem vListInitialiseItem * \ingroup LinkedList */ -void vListInitialiseItem( ListItem_t * const pxItem ); +void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION; /* * Insert a list item into a list. The item will be inserted into the list in @@ -407,19 +366,19 @@ void vListInitialiseItem( ListItem_t * const pxItem ); * \page vListInsert vListInsert * \ingroup LinkedList */ -void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ); +void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Insert a list item into a list. The item will be inserted in a position * such that it will be the last item within the list returned by multiple * calls to listGET_OWNER_OF_NEXT_ENTRY. * - * The list member pvIndex is used to walk through a list. Calling - * listGET_OWNER_OF_NEXT_ENTRY increments pvIndex to the next item in the list. + * The list member pxIndex is used to walk through a list. Calling + * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list. * Placing an item in a list using vListInsertEnd effectively places the item - * in the list position pointed to by pvIndex. This means that every other + * in the list position pointed to by pxIndex. This means that every other * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before - * the pvIndex parameter again points to the item being inserted. + * the pxIndex parameter again points to the item being inserted. * * @param pxList The list into which the item is to be inserted. * @@ -428,7 +387,7 @@ void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ); * \page vListInsertEnd vListInsertEnd * \ingroup LinkedList */ -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ); +void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Remove an item from a list. The list item has a pointer to the list that @@ -443,7 +402,7 @@ void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ); * \page uxListRemove uxListRemove * \ingroup LinkedList */ -UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ); +UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION; #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/message_buffer.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/message_buffer.h new file mode 100644 index 0000000..cdd050c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/message_buffer.h @@ -0,0 +1,780 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + +/* + * Message buffers build functionality on top of FreeRTOS stream buffers. + * Whereas stream buffers are used to send a continuous stream of data from one + * task or interrupt to another, message buffers are used to send variable + * length discrete messages from one task or interrupt to another. Their + * implementation is light weight, making them particularly suited for interrupt + * to task and core to core communication scenarios. + * + * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer + * implementation (so also the message buffer implementation, as message buffers + * are built on top of stream buffers) assumes there is only one task or + * interrupt that will write to the buffer (the writer), and only one task or + * interrupt that will read from the buffer (the reader). It is safe for the + * writer and reader to be different tasks or interrupts, but, unlike other + * FreeRTOS objects, it is not safe to have multiple different writers or + * multiple different readers. If there are to be multiple different writers + * then the application writer must place each call to a writing API function + * (such as xMessageBufferSend()) inside a critical section and set the send + * block time to 0. Likewise, if there are to be multiple different readers + * then the application writer must place each call to a reading API function + * (such as xMessageBufferRead()) inside a critical section and set the receive + * timeout to 0. + * + * Message buffers hold variable length messages. To enable that, when a + * message is written to the message buffer an additional sizeof( size_t ) bytes + * are also written to store the message's length (that happens internally, with + * the API function). sizeof( size_t ) is typically 4 bytes on a 32-bit + * architecture, so writing a 10 byte message to a message buffer on a 32-bit + * architecture will actually reduce the available space in the message buffer + * by 14 bytes (10 byte are used by the message, and 4 bytes to hold the length + * of the message). + */ + +#ifndef FREERTOS_MESSAGE_BUFFER_H +#define FREERTOS_MESSAGE_BUFFER_H + +/* Message buffers are built onto of stream buffers. */ +#include "stream_buffer.h" + +#if defined( __cplusplus ) +extern "C" { +#endif + +/** + * Type by which message buffers are referenced. For example, a call to + * xMessageBufferCreate() returns an MessageBufferHandle_t variable that can + * then be used as a parameter to xMessageBufferSend(), xMessageBufferReceive(), + * etc. + */ +typedef void * MessageBufferHandle_t; + +/*-----------------------------------------------------------*/ + +/** + * message_buffer.h + * +
      +MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes );
      +
      + * + * Creates a new message buffer using dynamically allocated memory. See + * xMessageBufferCreateStatic() for a version that uses statically allocated + * memory (memory that is allocated at compile time). + * + * configSUPPORT_DYNAMIC_ALLOCATION must be set to 1 or left undefined in + * FreeRTOSConfig.h for xMessageBufferCreate() to be available. + * + * @param xBufferSizeBytes The total number of bytes (not messages) the message + * buffer will be able to hold at any one time. When a message is written to + * the message buffer an additional sizeof( size_t ) bytes are also written to + * store the message's length. sizeof( size_t ) is typically 4 bytes on a + * 32-bit architecture, so on most 32-bit architectures a 10 byte message will + * take up 14 bytes of message buffer space. + * + * @return If NULL is returned, then the message buffer cannot be created + * because there is insufficient heap memory available for FreeRTOS to allocate + * the message buffer data structures and storage area. A non-NULL value being + * returned indicates that the message buffer has been created successfully - + * the returned value should be stored as the handle to the created message + * buffer. + * + * Example use: +
      +
      +void vAFunction( void )
      +{
      +MessageBufferHandle_t xMessageBuffer;
      +const size_t xMessageBufferSizeBytes = 100;
      +
      +    // Create a message buffer that can hold 100 bytes.  The memory used to hold
      +    // both the message buffer structure and the messages themselves is allocated
      +    // dynamically.  Each message added to the buffer consumes an additional 4
      +    // bytes which are used to hold the lengh of the message.
      +    xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes );
      +
      +    if( xMessageBuffer == NULL )
      +    {
      +        // There was not enough heap memory space available to create the
      +        // message buffer.
      +    }
      +    else
      +    {
      +        // The message buffer was created successfully and can now be used.
      +    }
      +
      +
      + * \defgroup xMessageBufferCreate xMessageBufferCreate + * \ingroup MessageBufferManagement + */ +#define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) + +/** + * message_buffer.h + * +
      +MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes,
      +                                                  uint8_t *pucMessageBufferStorageArea,
      +                                                  StaticMessageBuffer_t *pxStaticMessageBuffer );
      +
      + * Creates a new message buffer using statically allocated memory. See + * xMessageBufferCreate() for a version that uses dynamically allocated memory. + * + * @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the + * pucMessageBufferStorageArea parameter. When a message is written to the + * message buffer an additional sizeof( size_t ) bytes are also written to store + * the message's length. sizeof( size_t ) is typically 4 bytes on a 32-bit + * architecture, so on most 32-bit architecture a 10 byte message will take up + * 14 bytes of message buffer space. The maximum number of bytes that can be + * stored in the message buffer is actually (xBufferSizeBytes - 1). + * + * @param pucMessageBufferStorageArea Must point to a uint8_t array that is at + * least xBufferSizeBytes + 1 big. This is the array to which messages are + * copied when they are written to the message buffer. + * + * @param pxStaticMessageBuffer Must point to a variable of type + * StaticMessageBuffer_t, which will be used to hold the message buffer's data + * structure. + * + * @return If the message buffer is created successfully then a handle to the + * created message buffer is returned. If either pucMessageBufferStorageArea or + * pxStaticmessageBuffer are NULL then NULL is returned. + * + * Example use: +
      +
      +// Used to dimension the array used to hold the messages.  The available space
      +// will actually be one less than this, so 999.
      +#define STORAGE_SIZE_BYTES 1000
      +
      +// Defines the memory that will actually hold the messages within the message
      +// buffer.
      +static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ];
      +
      +// The variable used to hold the message buffer structure.
      +StaticMessageBuffer_t xMessageBufferStruct;
      +
      +void MyFunction( void )
      +{
      +MessageBufferHandle_t xMessageBuffer;
      +
      +    xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ),
      +                                                 ucBufferStorage,
      +                                                 &xMessageBufferStruct );
      +
      +    // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer
      +    // parameters were NULL, xMessageBuffer will not be NULL, and can be used to
      +    // reference the created message buffer in other message buffer API calls.
      +
      +    // Other code that uses the message buffer can go here.
      +}
      +
      +
      + * \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic + * \ingroup MessageBufferManagement + */ +#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) + +/** + * message_buffer.h + * +
      +size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer,
      +                           const void *pvTxData,
      +                           size_t xDataLengthBytes,
      +                           TickType_t xTicksToWait );
      +
      + *
      + * Sends a discrete message to the message buffer.  The message can be any
      + * length that fits within the buffer's free space, and is copied into the
      + * buffer.
      + *
      + * ***NOTE***:  Uniquely among FreeRTOS objects, the stream buffer
      + * implementation (so also the message buffer implementation, as message buffers
      + * are built on top of stream buffers) assumes there is only one task or
      + * interrupt that will write to the buffer (the writer), and only one task or
      + * interrupt that will read from the buffer (the reader).  It is safe for the
      + * writer and reader to be different tasks or interrupts, but, unlike other
      + * FreeRTOS objects, it is not safe to have multiple different writers or
      + * multiple different readers.  If there are to be multiple different writers
      + * then the application writer must place each call to a writing API function
      + * (such as xMessageBufferSend()) inside a critical section and set the send
      + * block time to 0.  Likewise, if there are to be multiple different readers
      + * then the application writer must place each call to a reading API function
      + * (such as xMessageBufferRead()) inside a critical section and set the receive
      + * block time to 0.
      + *
      + * Use xMessageBufferSend() to write to a message buffer from a task.  Use
      + * xMessageBufferSendFromISR() to write to a message buffer from an interrupt
      + * service routine (ISR).
      + *
      + * @param xMessageBuffer The handle of the message buffer to which a message is
      + * being sent.
      + *
      + * @param pvTxData A pointer to the message that is to be copied into the
      + * message buffer.
      + *
      + * @param xDataLengthBytes The length of the message.  That is, the number of
      + * bytes to copy from pvTxData into the message buffer.  When a message is
      + * written to the message buffer an additional sizeof( size_t ) bytes are also
      + * written to store the message's length.  sizeof( size_t ) is typically 4 bytes
      + * on a 32-bit architecture, so on most 32-bit architecture setting
      + * xDataLengthBytes to 20 will reduce the free space in the message buffer by 24
      + * bytes (20 bytes of message data and 4 bytes to hold the message length).
      + *
      + * @param xTicksToWait The maximum amount of time the calling task should remain
      + * in the Blocked state to wait for enough space to become available in the
      + * message buffer, should the message buffer have insufficient space when
      + * xMessageBufferSend() is called.  The calling task will never block if
      + * xTicksToWait is zero.  The block time is specified in tick periods, so the
      + * absolute time it represents is dependent on the tick frequency.  The macro
      + * pdMS_TO_TICKS() can be used to convert a time specified in milliseconds into
      + * a time specified in ticks.  Setting xTicksToWait to portMAX_DELAY will cause
      + * the task to wait indefinitely (without timing out), provided
      + * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h.  Tasks do not use any
      + * CPU time when they are in the Blocked state.
      + *
      + * @return The number of bytes written to the message buffer.  If the call to
      + * xMessageBufferSend() times out before there was enough space to write the
      + * message into the message buffer then zero is returned.  If the call did not
      + * time out then xDataLengthBytes is returned.
      + *
      + * Example use:
      +
      +void vAFunction( MessageBufferHandle_t xMessageBuffer )
      +{
      +size_t xBytesSent;
      +uint8_t ucArrayToSend[] = { 0, 1, 2, 3 };
      +char *pcStringToSend = "String to send";
      +const TickType_t x100ms = pdMS_TO_TICKS( 100 );
      +
      +    // Send an array to the message buffer, blocking for a maximum of 100ms to
      +    // wait for enough space to be available in the message buffer.
      +    xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms );
      +
      +    if( xBytesSent != sizeof( ucArrayToSend ) )
      +    {
      +        // The call to xMessageBufferSend() times out before there was enough
      +        // space in the buffer for the data to be written.
      +    }
      +
      +    // Send the string to the message buffer.  Return immediately if there is
      +    // not enough space in the buffer.
      +    xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 );
      +
      +    if( xBytesSent != strlen( pcStringToSend ) )
      +    {
      +        // The string could not be added to the message buffer because there was
      +        // not enough free space in the buffer.
      +    }
      +}
      +
      + * \defgroup xMessageBufferSend xMessageBufferSend + * \ingroup MessageBufferManagement + */ +#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) + +/** + * message_buffer.h + * +
      +size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer,
      +                                  const void *pvTxData,
      +                                  size_t xDataLengthBytes,
      +                                  BaseType_t *pxHigherPriorityTaskWoken );
      +
      + *
      + * Interrupt safe version of the API function that sends a discrete message to
      + * the message buffer.  The message can be any length that fits within the
      + * buffer's free space, and is copied into the buffer.
      + *
      + * ***NOTE***:  Uniquely among FreeRTOS objects, the stream buffer
      + * implementation (so also the message buffer implementation, as message buffers
      + * are built on top of stream buffers) assumes there is only one task or
      + * interrupt that will write to the buffer (the writer), and only one task or
      + * interrupt that will read from the buffer (the reader).  It is safe for the
      + * writer and reader to be different tasks or interrupts, but, unlike other
      + * FreeRTOS objects, it is not safe to have multiple different writers or
      + * multiple different readers.  If there are to be multiple different writers
      + * then the application writer must place each call to a writing API function
      + * (such as xMessageBufferSend()) inside a critical section and set the send
      + * block time to 0.  Likewise, if there are to be multiple different readers
      + * then the application writer must place each call to a reading API function
      + * (such as xMessageBufferRead()) inside a critical section and set the receive
      + * block time to 0.
      + *
      + * Use xMessageBufferSend() to write to a message buffer from a task.  Use
      + * xMessageBufferSendFromISR() to write to a message buffer from an interrupt
      + * service routine (ISR).
      + *
      + * @param xMessageBuffer The handle of the message buffer to which a message is
      + * being sent.
      + *
      + * @param pvTxData A pointer to the message that is to be copied into the
      + * message buffer.
      + *
      + * @param xDataLengthBytes The length of the message.  That is, the number of
      + * bytes to copy from pvTxData into the message buffer.  When a message is
      + * written to the message buffer an additional sizeof( size_t ) bytes are also
      + * written to store the message's length.  sizeof( size_t ) is typically 4 bytes
      + * on a 32-bit architecture, so on most 32-bit architecture setting
      + * xDataLengthBytes to 20 will reduce the free space in the message buffer by 24
      + * bytes (20 bytes of message data and 4 bytes to hold the message length).
      + *
      + * @param pxHigherPriorityTaskWoken  It is possible that a message buffer will
      + * have a task blocked on it waiting for data.  Calling
      + * xMessageBufferSendFromISR() can make data available, and so cause a task that
      + * was waiting for data to leave the Blocked state.  If calling
      + * xMessageBufferSendFromISR() causes a task to leave the Blocked state, and the
      + * unblocked task has a priority higher than the currently executing task (the
      + * task that was interrupted), then, internally, xMessageBufferSendFromISR()
      + * will set *pxHigherPriorityTaskWoken to pdTRUE.  If
      + * xMessageBufferSendFromISR() sets this value to pdTRUE, then normally a
      + * context switch should be performed before the interrupt is exited.  This will
      + * ensure that the interrupt returns directly to the highest priority Ready
      + * state task.  *pxHigherPriorityTaskWoken should be set to pdFALSE before it
      + * is passed into the function.  See the code example below for an example.
      + *
      + * @return The number of bytes actually written to the message buffer.  If the
      + * message buffer didn't have enough free space for the message to be stored
      + * then 0 is returned, otherwise xDataLengthBytes is returned.
      + *
      + * Example use:
      +
      +// A message buffer that has already been created.
      +MessageBufferHandle_t xMessageBuffer;
      +
      +void vAnInterruptServiceRoutine( void )
      +{
      +size_t xBytesSent;
      +char *pcStringToSend = "String to send";
      +BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE.
      +
      +    // Attempt to send the string to the message buffer.
      +    xBytesSent = xMessageBufferSendFromISR( xMessageBuffer,
      +                                            ( void * ) pcStringToSend,
      +                                            strlen( pcStringToSend ),
      +                                            &xHigherPriorityTaskWoken );
      +
      +    if( xBytesSent != strlen( pcStringToSend ) )
      +    {
      +        // The string could not be added to the message buffer because there was
      +        // not enough free space in the buffer.
      +    }
      +
      +    // If xHigherPriorityTaskWoken was set to pdTRUE inside
      +    // xMessageBufferSendFromISR() then a task that has a priority above the
      +    // priority of the currently executing task was unblocked and a context
      +    // switch should be performed to ensure the ISR returns to the unblocked
      +    // task.  In most FreeRTOS ports this is done by simply passing
      +    // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the
      +    // variables value, and perform the context switch if necessary.  Check the
      +    // documentation for the port in use for port specific instructions.
      +    taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
      +}
      +
      + * \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR + * \ingroup MessageBufferManagement + */ +#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) + +/** + * message_buffer.h + * +
      +size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer,
      +                              void *pvRxData,
      +                              size_t xBufferLengthBytes,
      +                              TickType_t xTicksToWait );
      +
      + * + * Receives a discrete message from a message buffer. Messages can be of + * variable length and are copied out of the buffer. + * + * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer + * implementation (so also the message buffer implementation, as message buffers + * are built on top of stream buffers) assumes there is only one task or + * interrupt that will write to the buffer (the writer), and only one task or + * interrupt that will read from the buffer (the reader). It is safe for the + * writer and reader to be different tasks or interrupts, but, unlike other + * FreeRTOS objects, it is not safe to have multiple different writers or + * multiple different readers. If there are to be multiple different writers + * then the application writer must place each call to a writing API function + * (such as xMessageBufferSend()) inside a critical section and set the send + * block time to 0. Likewise, if there are to be multiple different readers + * then the application writer must place each call to a reading API function + * (such as xMessageBufferRead()) inside a critical section and set the receive + * block time to 0. + * + * Use xMessageBufferReceive() to read from a message buffer from a task. Use + * xMessageBufferReceiveFromISR() to read from a message buffer from an + * interrupt service routine (ISR). + * + * @param xMessageBuffer The handle of the message buffer from which a message + * is being received. + * + * @param pvRxData A pointer to the buffer into which the received message is + * to be copied. + * + * @param xBufferLengthBytes The length of the buffer pointed to by the pvRxData + * parameter. This sets the maximum length of the message that can be received. + * If xBufferLengthBytes is too small to hold the next message then the message + * will be left in the message buffer and 0 will be returned. + * + * @param xTicksToWait The maximum amount of time the task should remain in the + * Blocked state to wait for a message, should the message buffer be empty. + * xMessageBufferReceive() will return immediately if xTicksToWait is zero and + * the message buffer is empty. The block time is specified in tick periods, so + * the absolute time it represents is dependent on the tick frequency. The + * macro pdMS_TO_TICKS() can be used to convert a time specified in milliseconds + * into a time specified in ticks. Setting xTicksToWait to portMAX_DELAY will + * cause the task to wait indefinitely (without timing out), provided + * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. Tasks do not use any + * CPU time when they are in the Blocked state. + * + * @return The length, in bytes, of the message read from the message buffer, if + * any. If xMessageBufferReceive() times out before a message became available + * then zero is returned. If the length of the message is greater than + * xBufferLengthBytes then the message will be left in the message buffer and + * zero is returned. + * + * Example use: +
      +void vAFunction( MessageBuffer_t xMessageBuffer )
      +{
      +uint8_t ucRxData[ 20 ];
      +size_t xReceivedBytes;
      +const TickType_t xBlockTime = pdMS_TO_TICKS( 20 );
      +
      +    // Receive the next message from the message buffer.  Wait in the Blocked
      +    // state (so not using any CPU processing time) for a maximum of 100ms for
      +    // a message to become available.
      +    xReceivedBytes = xMessageBufferReceive( xMessageBuffer,
      +                                            ( void * ) ucRxData,
      +                                            sizeof( ucRxData ),
      +                                            xBlockTime );
      +
      +    if( xReceivedBytes > 0 )
      +    {
      +        // A ucRxData contains a message that is xReceivedBytes long.  Process
      +        // the message here....
      +    }
      +}
      +
      + * \defgroup xMessageBufferReceive xMessageBufferReceive + * \ingroup MessageBufferManagement + */ +#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) + + +/** + * message_buffer.h + * +
      +size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer,
      +                                     void *pvRxData,
      +                                     size_t xBufferLengthBytes,
      +                                     BaseType_t *pxHigherPriorityTaskWoken );
      +
      + * + * An interrupt safe version of the API function that receives a discrete + * message from a message buffer. Messages can be of variable length and are + * copied out of the buffer. + * + * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer + * implementation (so also the message buffer implementation, as message buffers + * are built on top of stream buffers) assumes there is only one task or + * interrupt that will write to the buffer (the writer), and only one task or + * interrupt that will read from the buffer (the reader). It is safe for the + * writer and reader to be different tasks or interrupts, but, unlike other + * FreeRTOS objects, it is not safe to have multiple different writers or + * multiple different readers. If there are to be multiple different writers + * then the application writer must place each call to a writing API function + * (such as xMessageBufferSend()) inside a critical section and set the send + * block time to 0. Likewise, if there are to be multiple different readers + * then the application writer must place each call to a reading API function + * (such as xMessageBufferRead()) inside a critical section and set the receive + * block time to 0. + * + * Use xMessageBufferReceive() to read from a message buffer from a task. Use + * xMessageBufferReceiveFromISR() to read from a message buffer from an + * interrupt service routine (ISR). + * + * @param xMessageBuffer The handle of the message buffer from which a message + * is being received. + * + * @param pvRxData A pointer to the buffer into which the received message is + * to be copied. + * + * @param xBufferLengthBytes The length of the buffer pointed to by the pvRxData + * parameter. This sets the maximum length of the message that can be received. + * If xBufferLengthBytes is too small to hold the next message then the message + * will be left in the message buffer and 0 will be returned. + * + * @param pxHigherPriorityTaskWoken It is possible that a message buffer will + * have a task blocked on it waiting for space to become available. Calling + * xMessageBufferReceiveFromISR() can make space available, and so cause a task + * that is waiting for space to leave the Blocked state. If calling + * xMessageBufferReceiveFromISR() causes a task to leave the Blocked state, and + * the unblocked task has a priority higher than the currently executing task + * (the task that was interrupted), then, internally, + * xMessageBufferReceiveFromISR() will set *pxHigherPriorityTaskWoken to pdTRUE. + * If xMessageBufferReceiveFromISR() sets this value to pdTRUE, then normally a + * context switch should be performed before the interrupt is exited. That will + * ensure the interrupt returns directly to the highest priority Ready state + * task. *pxHigherPriorityTaskWoken should be set to pdFALSE before it is + * passed into the function. See the code example below for an example. + * + * @return The length, in bytes, of the message read from the message buffer, if + * any. + * + * Example use: +
      +// A message buffer that has already been created.
      +MessageBuffer_t xMessageBuffer;
      +
      +void vAnInterruptServiceRoutine( void )
      +{
      +uint8_t ucRxData[ 20 ];
      +size_t xReceivedBytes;
      +BaseType_t xHigherPriorityTaskWoken = pdFALSE;  // Initialised to pdFALSE.
      +
      +    // Receive the next message from the message buffer.
      +    xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer,
      +                                                  ( void * ) ucRxData,
      +                                                  sizeof( ucRxData ),
      +                                                  &xHigherPriorityTaskWoken );
      +
      +    if( xReceivedBytes > 0 )
      +    {
      +        // A ucRxData contains a message that is xReceivedBytes long.  Process
      +        // the message here....
      +    }
      +
      +    // If xHigherPriorityTaskWoken was set to pdTRUE inside
      +    // xMessageBufferReceiveFromISR() then a task that has a priority above the
      +    // priority of the currently executing task was unblocked and a context
      +    // switch should be performed to ensure the ISR returns to the unblocked
      +    // task.  In most FreeRTOS ports this is done by simply passing
      +    // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the
      +    // variables value, and perform the context switch if necessary.  Check the
      +    // documentation for the port in use for port specific instructions.
      +    taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
      +}
      +
      + * \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR + * \ingroup MessageBufferManagement + */ +#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) + +/** + * message_buffer.h + * +
      +void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer );
      +
      + * + * Deletes a message buffer that was previously created using a call to + * xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message + * buffer was created using dynamic memory (that is, by xMessageBufferCreate()), + * then the allocated memory is freed. + * + * A message buffer handle must not be used after the message buffer has been + * deleted. + * + * @param xMessageBuffer The handle of the message buffer to be deleted. + * + */ +#define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) + +/** + * message_buffer.h +
      +BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer ) );
      +
      + * + * Tests to see if a message buffer is full. A message buffer is full if it + * cannot accept any more messages, of any size, until space is made available + * by a message being removed from the message buffer. + * + * @param xMessageBuffer The handle of the message buffer being queried. + * + * @return If the message buffer referenced by xMessageBuffer is full then + * pdTRUE is returned. Otherwise pdFALSE is returned. + */ +#define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) + +/** + * message_buffer.h +
      +BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer ) );
      +
      + * + * Tests to see if a message buffer is empty (does not contain any messages). + * + * @param xMessageBuffer The handle of the message buffer being queried. + * + * @return If the message buffer referenced by xMessageBuffer is empty then + * pdTRUE is returned. Otherwise pdFALSE is returned. + * + */ +#define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) + +/** + * message_buffer.h +
      +BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer );
      +
      + * + * Resets a message buffer to its initial empty state, discarding any message it + * contained. + * + * A message buffer can only be reset if there are no tasks blocked on it. + * + * @param xMessageBuffer The handle of the message buffer being reset. + * + * @return If the message buffer was reset then pdPASS is returned. If the + * message buffer could not be reset because either there was a task blocked on + * the message queue to wait for space to become available, or to wait for a + * a message to be available, then pdFAIL is returned. + * + * \defgroup xMessageBufferReset xMessageBufferReset + * \ingroup MessageBufferManagement + */ +#define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) + + +/** + * message_buffer.h +
      +size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) );
      +
      + * Returns the number of bytes of free space in the message buffer. + * + * @param xMessageBuffer The handle of the message buffer being queried. + * + * @return The number of bytes that can be written to the message buffer before + * the message buffer would be full. When a message is written to the message + * buffer an additional sizeof( size_t ) bytes are also written to store the + * message's length. sizeof( size_t ) is typically 4 bytes on a 32-bit + * architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size + * of the largest message that can be written to the message buffer is 6 bytes. + * + * \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable + * \ingroup MessageBufferManagement + */ +#define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) + +/** + * message_buffer.h + * +
      +BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
      +
      + * + * For advanced users only. + * + * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when + * data is sent to a message buffer or stream buffer. If there was a task that + * was blocked on the message or stream buffer waiting for data to arrive then + * the sbSEND_COMPLETED() macro sends a notification to the task to remove it + * from the Blocked state. xMessageBufferSendCompletedFromISR() does the same + * thing. It is provided to enable application writers to implement their own + * version of sbSEND_COMPLETED(), and MUST NOT BE USED AT ANY OTHER TIME. + * + * See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for + * additional information. + * + * @param xStreamBuffer The handle of the stream buffer to which data was + * written. + * + * @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be + * initialised to pdFALSE before it is passed into + * xMessageBufferSendCompletedFromISR(). If calling + * xMessageBufferSendCompletedFromISR() removes a task from the Blocked state, + * and the task has a priority above the priority of the currently running task, + * then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a + * context switch should be performed before exiting the ISR. + * + * @return If a task was removed from the Blocked state then pdTRUE is returned. + * Otherwise pdFALSE is returned. + * + * \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR + * \ingroup StreamBufferManagement + */ +#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) + +/** + * message_buffer.h + * +
      +BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
      +
      + * + * For advanced users only. + * + * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when + * data is read out of a message buffer or stream buffer. If there was a task + * that was blocked on the message or stream buffer waiting for data to arrive + * then the sbRECEIVE_COMPLETED() macro sends a notification to the task to + * remove it from the Blocked state. xMessageBufferReceiveCompletedFromISR() + * does the same thing. It is provided to enable application writers to + * implement their own version of sbRECEIVE_COMPLETED(), and MUST NOT BE USED AT + * ANY OTHER TIME. + * + * See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for + * additional information. + * + * @param xStreamBuffer The handle of the stream buffer from which data was + * read. + * + * @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be + * initialised to pdFALSE before it is passed into + * xMessageBufferReceiveCompletedFromISR(). If calling + * xMessageBufferReceiveCompletedFromISR() removes a task from the Blocked state, + * and the task has a priority above the priority of the currently running task, + * then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a + * context switch should be performed before exiting the ISR. + * + * @return If a task was removed from the Blocked state then pdTRUE is returned. + * Otherwise pdFALSE is returned. + * + * \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR + * \ingroup StreamBufferManagement + */ +#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) + +#if defined( __cplusplus ) +} /* extern "C" */ +#endif + +#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_prototypes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_prototypes.h new file mode 100644 index 0000000..3931ee6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_prototypes.h @@ -0,0 +1,156 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* + * When the MPU is used the standard (non MPU) API functions are mapped to + * equivalents that start "MPU_", the prototypes for which are defined in this + * header files. This will cause the application code to call the MPU_ version + * which wraps the non-MPU version with privilege promoting then demoting code, + * so the kernel code always runs will full privileges. + */ + + +#ifndef MPU_PROTOTYPES_H +#define MPU_PROTOTYPES_H + +/* MPU versions of tasks.h API functions. */ +BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask ); +TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ); +BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ); +void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ); +void MPU_vTaskDelay( const TickType_t xTicksToDelay ); +void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ); +BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ); +UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t xTask ); +eTaskState MPU_eTaskGetState( TaskHandle_t xTask ); +void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ); +void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ); +void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ); +void MPU_vTaskResume( TaskHandle_t xTaskToResume ); +void MPU_vTaskStartScheduler( void ); +void MPU_vTaskSuspendAll( void ); +BaseType_t MPU_xTaskResumeAll( void ); +TickType_t MPU_xTaskGetTickCount( void ); +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ); +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ); +TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ); +UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ); +void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ); +TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ); +void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ); +void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ); +BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ); +TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ); +UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ); +void MPU_vTaskList( char * pcWriteBuffer ); +void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ); +BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ); +BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); +uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); +BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ); +BaseType_t MPU_xTaskIncrementTick( void ); +TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ); +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ); +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ); +void MPU_vTaskMissedYield( void ); +BaseType_t MPU_xTaskGetSchedulerState( void ); + +/* MPU versions of queue.h API functions. */ +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ); +BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ); +BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ); +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ); +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ); +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ); +void MPU_vQueueDelete( QueueHandle_t xQueue ); +QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ); +QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ); +QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ); +QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ); +void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ); +BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ); +BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ); +void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ); +void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ); +const char * MPU_pcQueueGetName( QueueHandle_t xQueue ); +QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ); +QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ); +QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ); +BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ); +BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ); +QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ); +BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ); +void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ); +UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ); +uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ); + +/* MPU versions of timers.h API functions. */ +TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ); +TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ); +void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ); +void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); +BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ); +TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ); +BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ); +const char * MPU_pcTimerGetName( TimerHandle_t xTimer ); +TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ); +TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ); +BaseType_t MPU_xTimerCreateTimerTask( void ); +BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ); + +/* MPU versions of event_group.h API functions. */ +EventGroupHandle_t MPU_xEventGroupCreate( void ); +EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ); +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ); +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ); +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ); +UBaseType_t MPU_uxEventGroupGetNumber( void* xEventGroup ); + +/* MPU versions of message/stream_buffer.h API functions. */ +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ); +size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ); +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ); +size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ); +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ); +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ); +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ); +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ); +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ); +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ); +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ); +StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ); +StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ); + + + +#endif /* MPU_PROTOTYPES_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_wrappers.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_wrappers.h new file mode 100644 index 0000000..e434e3b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/mpu_wrappers.h @@ -0,0 +1,182 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef MPU_WRAPPERS_H +#define MPU_WRAPPERS_H + +/* This file redefines API functions to be called through a wrapper macro, but +only for ports that are using the MPU. */ +#ifdef portUSING_MPU_WRAPPERS + + /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is + included from queue.c or task.c to prevent it from having an effect within + those files. */ + #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + + /* + * Map standard (non MPU) API functions to equivalents that start + * "MPU_". This will cause the application code to call the MPU_ + * version, which wraps the non-MPU version with privilege promoting + * then demoting code, so the kernel code always runs will full + * privileges. + */ + + /* Map standard tasks.h API functions to the MPU equivalents. */ + #define xTaskCreate MPU_xTaskCreate + #define xTaskCreateStatic MPU_xTaskCreateStatic + #define xTaskCreateRestricted MPU_xTaskCreateRestricted + #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions + #define vTaskDelete MPU_vTaskDelete + #define vTaskDelay MPU_vTaskDelay + #define vTaskDelayUntil MPU_vTaskDelayUntil + #define xTaskAbortDelay MPU_xTaskAbortDelay + #define uxTaskPriorityGet MPU_uxTaskPriorityGet + #define eTaskGetState MPU_eTaskGetState + #define vTaskGetInfo MPU_vTaskGetInfo + #define vTaskPrioritySet MPU_vTaskPrioritySet + #define vTaskSuspend MPU_vTaskSuspend + #define vTaskResume MPU_vTaskResume + #define vTaskSuspendAll MPU_vTaskSuspendAll + #define xTaskResumeAll MPU_xTaskResumeAll + #define xTaskGetTickCount MPU_xTaskGetTickCount + #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks + #define pcTaskGetName MPU_pcTaskGetName + #define xTaskGetHandle MPU_xTaskGetHandle + #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark + #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag + #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag + #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer + #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer + #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook + #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle + #define uxTaskGetSystemState MPU_uxTaskGetSystemState + #define vTaskList MPU_vTaskList + #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define xTaskGenericNotify MPU_xTaskGenericNotify + #define xTaskNotifyWait MPU_xTaskNotifyWait + #define ulTaskNotifyTake MPU_ulTaskNotifyTake + #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear + + #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle + #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState + #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut + #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState + + /* Map standard queue.h API functions to the MPU equivalents. */ + #define xQueueGenericSend MPU_xQueueGenericSend + #define xQueueReceive MPU_xQueueReceive + #define xQueuePeek MPU_xQueuePeek + #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake + #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting + #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable + #define vQueueDelete MPU_vQueueDelete + #define xQueueCreateMutex MPU_xQueueCreateMutex + #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic + #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore + #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic + #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder + #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive + #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive + #define xQueueGenericCreate MPU_xQueueGenericCreate + #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic + #define xQueueCreateSet MPU_xQueueCreateSet + #define xQueueAddToSet MPU_xQueueAddToSet + #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet + #define xQueueSelectFromSet MPU_xQueueSelectFromSet + #define xQueueGenericReset MPU_xQueueGenericReset + + #if( configQUEUE_REGISTRY_SIZE > 0 ) + #define vQueueAddToRegistry MPU_vQueueAddToRegistry + #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue + #define pcQueueGetName MPU_pcQueueGetName + #endif + + /* Map standard timer.h API functions to the MPU equivalents. */ + #define xTimerCreate MPU_xTimerCreate + #define xTimerCreateStatic MPU_xTimerCreateStatic + #define pvTimerGetTimerID MPU_pvTimerGetTimerID + #define vTimerSetTimerID MPU_vTimerSetTimerID + #define xTimerIsTimerActive MPU_xTimerIsTimerActive + #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle + #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall + #define pcTimerGetName MPU_pcTimerGetName + #define xTimerGetPeriod MPU_xTimerGetPeriod + #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime + #define xTimerGenericCommand MPU_xTimerGenericCommand + + /* Map standard event_group.h API functions to the MPU equivalents. */ + #define xEventGroupCreate MPU_xEventGroupCreate + #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic + #define xEventGroupWaitBits MPU_xEventGroupWaitBits + #define xEventGroupClearBits MPU_xEventGroupClearBits + #define xEventGroupSetBits MPU_xEventGroupSetBits + #define xEventGroupSync MPU_xEventGroupSync + #define vEventGroupDelete MPU_vEventGroupDelete + + /* Map standard message/stream_buffer.h API functions to the MPU + equivalents. */ + #define xStreamBufferSend MPU_xStreamBufferSend + #define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR + #define xStreamBufferReceive MPU_xStreamBufferReceive + #define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR + #define vStreamBufferDelete MPU_vStreamBufferDelete + #define xStreamBufferIsFull MPU_xStreamBufferIsFull + #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty + #define xStreamBufferReset MPU_xStreamBufferReset + #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable + #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable + #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel + #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate + #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic + + + /* Remove the privileged function macro, but keep the PRIVILEGED_DATA + macro so applications can place data in privileged access sections + (useful when using statically allocated objects). */ + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) + + #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + + /* Ensure API functions go in the privileged execution section. */ + #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) + #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) + + #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + +#else /* portUSING_MPU_WRAPPERS */ + + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA + #define portUSING_MPU_WRAPPERS 0 + +#endif /* portUSING_MPU_WRAPPERS */ + + +#endif /* MPU_WRAPPERS_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/portable.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/portable.h similarity index 52% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/portable.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/portable.h index dc4417b..95be167 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/portable.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/portable.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- * Portable layer API. Each function must be defined for each port. @@ -94,6 +53,14 @@ must be set in the compiler's include path. */ #include "portmacro.h" #endif +#if portBYTE_ALIGNMENT == 32 + #define portBYTE_ALIGNMENT_MASK ( 0x001f ) +#endif + +#if portBYTE_ALIGNMENT == 16 + #define portBYTE_ALIGNMENT_MASK ( 0x000f ) +#endif + #if portBYTE_ALIGNMENT == 8 #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) #endif @@ -130,7 +97,7 @@ extern "C" { * the order that the port expects to find them. * */ -#if ( portUSING_MPU_WRAPPERS == 1 ) +#if( portUSING_MPU_WRAPPERS == 1 ) StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; #else StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; @@ -154,7 +121,7 @@ typedef struct HeapRegion * terminated by a HeapRegions_t structure that has a size of 0. The region * with the lowest start address must appear first in the array. */ -void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ); +void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; /* @@ -186,9 +153,9 @@ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; * Fills the xMPUSettings structure with the memory region information * contained in xRegions. */ -#if ( portUSING_MPU_WRAPPERS == 1 ) +#if( portUSING_MPU_WRAPPERS == 1 ) struct xMEMORY_REGION; - void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint16_t usStackDepth ) PRIVILEGED_FUNCTION; + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; #endif #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/projdefs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/projdefs.h new file mode 100644 index 0000000..f3bada2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/projdefs.h @@ -0,0 +1,125 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PROJDEFS_H +#define PROJDEFS_H + +/* + * Defines the prototype to which task functions must conform. Defined in this + * file to ensure the type is known before portable.h is included. + */ +typedef void (*TaskFunction_t)( void * ); + +/* Converts a time in milliseconds to a time in ticks. This macro can be +overridden by a macro of the same name defined in FreeRTOSConfig.h in case the +definition here is not suitable for your application. */ +#ifndef pdMS_TO_TICKS + #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) +#endif + +#define pdFALSE ( ( BaseType_t ) 0 ) +#define pdTRUE ( ( BaseType_t ) 1 ) + +#define pdPASS ( pdTRUE ) +#define pdFAIL ( pdFALSE ) +#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) +#define errQUEUE_FULL ( ( BaseType_t ) 0 ) + +/* FreeRTOS error definitions. */ +#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) +#define errQUEUE_BLOCKED ( -4 ) +#define errQUEUE_YIELD ( -5 ) + +/* Macros used for basic data corruption checks. */ +#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES + #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 +#endif + +#if( configUSE_16_BIT_TICKS == 1 ) + #define pdINTEGRITY_CHECK_VALUE 0x5a5a +#else + #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL +#endif + +/* The following errno values are used by FreeRTOS+ components, not FreeRTOS +itself. */ +#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ +#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ +#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ +#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ +#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ +#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ +#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ +#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ +#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ +#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ +#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ +#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ +#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ +#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ +#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ +#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ +#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ +#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ +#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ +#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ +#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ +#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ +#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ +#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ +#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ +#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ +#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ +#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ +#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ +#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ +#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ +#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ +#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ +#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ +#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ +#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ +#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ +#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ +#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ + +/* The following endian values are used by FreeRTOS+ components, not FreeRTOS +itself. */ +#define pdFREERTOS_LITTLE_ENDIAN 0 +#define pdFREERTOS_BIG_ENDIAN 1 + +/* Re-defining endian values for generic naming. */ +#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN +#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN + + +#endif /* PROJDEFS_H */ + + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/queue.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/queue.h similarity index 82% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/queue.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/queue.h index 2432c18..916498e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/queue.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/queue.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef QUEUE_H @@ -123,8 +82,20 @@ typedef void * QueueSetMemberHandle_t; ); *
      * - * Creates a new queue instance. This allocates the storage required by the - * new queue and returns a handle for the queue. + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * http://www.freertos.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * http://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -151,7 +122,7 @@ typedef void * QueueSetMemberHandle_t; // Create a queue capable of containing 10 uint32_t values. xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); - if ( xQueue1 == 0 ) + if( xQueue1 == 0 ) { // Queue was not created and must not be used. } @@ -159,7 +130,7 @@ typedef void * QueueSetMemberHandle_t; // Create a queue capable of containing 10 pointers to AMessage structures. // These should be passed by pointer as they contain a lot of data. xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) ); - if ( xQueue2 == 0 ) + if( xQueue2 == 0 ) { // Queue was not created and must not be used. } @@ -170,7 +141,95 @@ typedef void * QueueSetMemberHandle_t; * \defgroup xQueueCreate xQueueCreate * \ingroup QueueManagement */ -#define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE ) +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) +#endif + +/** + * queue. h + *
      + QueueHandle_t xQueueCreateStatic(
      +							  UBaseType_t uxQueueLength,
      +							  UBaseType_t uxItemSize,
      +							  uint8_t *pucQueueStorageBuffer,
      +							  StaticQueue_t *pxQueueBuffer
      +						  );
      + * 
      + * + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * http://www.freertos.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * http://www.FreeRTOS.org/Embedded-RTOS-Queues.html + * + * @param uxQueueLength The maximum number of items that the queue can contain. + * + * @param uxItemSize The number of bytes each item in the queue will require. + * Items are queued by copy, not by reference, so this is the number of bytes + * that will be copied for each posted item. Each item on the queue must be + * the same size. + * + * @param pucQueueStorageBuffer If uxItemSize is not zero then + * pucQueueStorageBuffer must point to a uint8_t array that is at least large + * enough to hold the maximum number of items that can be in the queue at any + * one time - which is ( uxQueueLength * uxItemsSize ) bytes. If uxItemSize is + * zero then pucQueueStorageBuffer can be NULL. + * + * @param pxQueueBuffer Must point to a variable of type StaticQueue_t, which + * will be used to hold the queue's data structure. + * + * @return If the queue is created then a handle to the created queue is + * returned. If pxQueueBuffer is NULL then NULL is returned. + * + * Example usage: +
      + struct AMessage
      + {
      +	char ucMessageID;
      +	char ucData[ 20 ];
      + };
      +
      + #define QUEUE_LENGTH 10
      + #define ITEM_SIZE sizeof( uint32_t )
      +
      + // xQueueBuffer will hold the queue structure.
      + StaticQueue_t xQueueBuffer;
      +
      + // ucQueueStorage will hold the items posted to the queue.  Must be at least
      + // [(queue length) * ( queue item size)] bytes long.
      + uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];
      +
      + void vATask( void *pvParameters )
      + {
      + QueueHandle_t xQueue1;
      +
      +	// Create a queue capable of containing 10 uint32_t values.
      +	xQueue1 = xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold.
      +							ITEM_SIZE	  // The size of each item in the queue
      +							&( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue.
      +							&xQueueBuffer ); // The buffer that will hold the queue structure.
      +
      +	// The queue is guaranteed to be created successfully as no dynamic memory
      +	// allocation is used.  Therefore xQueue1 is now a handle to a valid queue.
      +
      +	// ... Rest of task code.
      + }
      + 
      + * \defgroup xQueueCreateStatic xQueueCreateStatic + * \ingroup QueueManagement + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) +#endif /* configSUPPORT_STATIC_ALLOCATION */ /** * queue. h @@ -182,8 +241,6 @@ typedef void * QueueSetMemberHandle_t; ); *
      * - * This is a macro that calls xQueueGenericSend(). - * * Post an item to the front of a queue. The item is queued by copy, not by * reference. This function must not be called from an interrupt service * routine. See xQueueSendFromISR () for an alternative which may be used @@ -228,17 +285,17 @@ typedef void * QueueSetMemberHandle_t; // ... - if ( xQueue1 != 0 ) + if( xQueue1 != 0 ) { // Send an uint32_t. Wait for 10 ticks for space to become // available if necessary. - if ( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) + if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) { // Failed to post the message, even after 10 ticks. } } - if ( xQueue2 != 0 ) + if( xQueue2 != 0 ) { // Send a pointer to a struct AMessage object. Don't block if the // queue is already full. @@ -310,17 +367,17 @@ typedef void * QueueSetMemberHandle_t; // ... - if ( xQueue1 != 0 ) + if( xQueue1 != 0 ) { // Send an uint32_t. Wait for 10 ticks for space to become // available if necessary. - if ( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) + if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) { // Failed to post the message, even after 10 ticks. } } - if ( xQueue2 != 0 ) + if( xQueue2 != 0 ) { // Send a pointer to a struct AMessage object. Don't block if the // queue is already full. @@ -394,17 +451,17 @@ typedef void * QueueSetMemberHandle_t; // ... - if ( xQueue1 != 0 ) + if( xQueue1 != 0 ) { // Send an uint32_t. Wait for 10 ticks for space to become // available if necessary. - if ( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) + if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) { // Failed to post the message, even after 10 ticks. } } - if ( xQueue2 != 0 ) + if( xQueue2 != 0 ) { // Send a pointer to a struct AMessage object. Don't block if the // queue is already full. @@ -474,7 +531,7 @@ typedef void * QueueSetMemberHandle_t; ulValReceived = 0; xQueuePeek( xQueue, &ulValReceived, 0 ); - if ( ulValReceived != 10 ) + if( ulValReceived != 10 ) { // Error unless the item was removed by a different task. } @@ -490,7 +547,7 @@ typedef void * QueueSetMemberHandle_t; // The value read should be the last value written, even though the // queue was already full when the value was written. - if ( ulValReceived != 100 ) + if( ulValReceived != 100 ) { // Error! } @@ -565,17 +622,17 @@ typedef void * QueueSetMemberHandle_t; // ... - if ( xQueue1 != 0 ) + if( xQueue1 != 0 ) { // Send an uint32_t. Wait for 10 ticks for space to become // available if necessary. - if ( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS ) + if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS ) { // Failed to post the message, even after 10 ticks. } } - if ( xQueue2 != 0 ) + if( xQueue2 != 0 ) { // Send a pointer to a struct AMessage object. Don't block if the // queue is already full. @@ -596,12 +653,10 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ *
        BaseType_t xQueuePeek(
       							 QueueHandle_t xQueue,
      -							 void *pvBuffer,
      +							 void * const pvBuffer,
       							 TickType_t xTicksToWait
       						 );
      * - * This is a macro that calls the xQueueGenericReceive() function. - * * Receive an item from a queue without removing the item from the queue. * The item is received by copy so a buffer of adequate size must be * provided. The number of bytes copied into the buffer was defined when @@ -648,7 +703,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ // Create a queue capable of containing 10 pointers to AMessage structures. // These should be passed by pointer as they contain a lot of data. xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) ); - if ( xQueue == 0 ) + if( xQueue == 0 ) { // Failed to create the queue. } @@ -668,11 +723,11 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ { struct AMessage *pxRxedMessage; - if ( xQueue != 0 ) + if( xQueue != 0 ) { // Peek a message on the created queue. Block for 10 ticks if a // message is not immediately available. - if ( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) + if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) { // pcRxedMessage now points to the struct AMessage variable posted // by vATask, but the item still remains on the queue. @@ -682,10 +737,10 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ // ... Rest of task code. }
      - * \defgroup xQueueReceive xQueueReceive + * \defgroup xQueuePeek xQueuePeek * \ingroup QueueManagement */ -#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) +BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * queue. h @@ -729,8 +784,6 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV TickType_t xTicksToWait );
      * - * This is a macro that calls the xQueueGenericReceive() function. - * * Receive an item from a queue. The item is received by copy so a buffer of * adequate size must be provided. The number of bytes copied into the buffer * was defined when the queue was created. @@ -774,7 +827,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV // Create a queue capable of containing 10 pointers to AMessage structures. // These should be passed by pointer as they contain a lot of data. xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) ); - if ( xQueue == 0 ) + if( xQueue == 0 ) { // Failed to create the queue. } @@ -794,11 +847,11 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV { struct AMessage *pxRxedMessage; - if ( xQueue != 0 ) + if( xQueue != 0 ) { // Receive a message on the created queue. Block for 10 ticks if a // message is not immediately available. - if ( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) + if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) { // pcRxedMessage now points to the struct AMessage variable posted // by vATask. @@ -811,106 +864,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * \defgroup xQueueReceive xQueueReceive * \ingroup QueueManagement */ -#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) - - -/** - * queue. h - *
      - BaseType_t xQueueGenericReceive(
      -									   QueueHandle_t	xQueue,
      -									   void	*pvBuffer,
      -									   TickType_t	xTicksToWait
      -									   BaseType_t	xJustPeek
      -									);
      - * - * It is preferred that the macro xQueueReceive() be used rather than calling - * this function directly. - * - * Receive an item from a queue. The item is received by copy so a buffer of - * adequate size must be provided. The number of bytes copied into the buffer - * was defined when the queue was created. - * - * This function must not be used in an interrupt service routine. See - * xQueueReceiveFromISR for an alternative that can. - * - * @param xQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * xQueueGenericReceive() will return immediately if the queue is empty and - * xTicksToWait is 0. - * - * @param xJustPeek When set to true, the item received from the queue is not - * actually removed from the queue - meaning a subsequent call to - * xQueueReceive() will return the same item. When set to false, the item - * being received from the queue is also removed from the queue. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
      - struct AMessage
      - {
      -	char ucMessageID;
      -	char ucData[ 20 ];
      - } xMessage;
      -
      - QueueHandle_t xQueue;
      -
      - // Task to create a queue and post a value.
      - void vATask( void *pvParameters )
      - {
      - struct AMessage *pxMessage;
      -
      -	// Create a queue capable of containing 10 pointers to AMessage structures.
      -	// These should be passed by pointer as they contain a lot of data.
      -	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
      -	if ( xQueue == 0 )
      -	{
      -		// Failed to create the queue.
      -	}
      -
      -	// ...
      -
      -	// Send a pointer to a struct AMessage object.  Don't block if the
      -	// queue is already full.
      -	pxMessage = & xMessage;
      -	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
      -
      -	// ... Rest of task code.
      - }
      -
      - // Task to receive from the queue.
      - void vADifferentTask( void *pvParameters )
      - {
      - struct AMessage *pxRxedMessage;
      -
      -	if ( xQueue != 0 )
      -	{
      -		// Receive a message on the created queue.  Block for 10 ticks if a
      -		// message is not immediately available.
      -		if ( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
      -		{
      -			// pcRxedMessage now points to the struct AMessage variable posted
      -			// by vATask.
      -		}
      -	}
      -
      -	// ... Rest of task code.
      - }
      - 
      - * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) PRIVILEGED_FUNCTION; +BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * queue. h @@ -1013,10 +967,10 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; // Post the byte. xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); - } while ( portINPUT_BYTE( BUFFER_COUNT ) ); + } while( portINPUT_BYTE( BUFFER_COUNT ) ); // Now the buffer is empty we can switch context if necessary. - if ( xHigherPriorityTaskWoken ) + if( xHigherPriorityTaskWoken ) { taskYIELD (); } @@ -1084,10 +1038,10 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; // Post the byte. xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); - } while ( portINPUT_BYTE( BUFFER_COUNT ) ); + } while( portINPUT_BYTE( BUFFER_COUNT ) ); // Now the buffer is empty we can switch context if necessary. - if ( xHigherPriorityTaskWoken ) + if( xHigherPriorityTaskWoken ) { taskYIELD (); } @@ -1171,7 +1125,7 @@ uint32_t ulVarToSend, ulValReceived; // ... - if ( xHigherPrioritytaskWoken == pdTRUE ) + if( xHigherPrioritytaskWoken == pdTRUE ) { // Writing to the queue caused a task to unblock and the unblocked task // has a priority higher than or equal to the priority of the currently @@ -1244,10 +1198,10 @@ uint32_t ulVarToSend, ulValReceived; // Post the byte. xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); - } while ( portINPUT_BYTE( BUFFER_COUNT ) ); + } while( portINPUT_BYTE( BUFFER_COUNT ) ); // Now the buffer is empty we can switch context if necessary. - if ( xHigherPriorityTaskWoken ) + if( xHigherPriorityTaskWoken ) { // Actual macro used here is port specific. portYIELD_FROM_ISR (); @@ -1323,11 +1277,11 @@ uint32_t ulVarToSend, ulValReceived; // Post each byte. xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK ); - } while ( portINPUT_BYTE( BUFFER_COUNT ) ); + } while( portINPUT_BYTE( BUFFER_COUNT ) ); // Now the buffer is empty we can switch context if necessary. Note that the // name of the yield function required is port specific. - if ( xHigherPriorityTaskWokenByPost ) + if( xHigherPriorityTaskWokenByPost ) { taskYIELD_YIELD_FROM_ISR(); } @@ -1380,7 +1334,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP // Create a queue capable of containing 10 characters. xQueue = xQueueCreate( 10, sizeof( char ) ); - if ( xQueue == 0 ) + if( xQueue == 0 ) { // Failed to create the queue. } @@ -1407,7 +1361,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP BaseType_t xTaskWokenByReceive = pdFALSE; char cRxedChar; - while ( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) ) + while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) ) { // A character was received. Output the character now. vOutputCharacter( cRxedChar ); @@ -1418,7 +1372,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP // task will be woken. } - if ( cTaskWokenByPost != ( char ) pdFALSE; + if( cTaskWokenByPost != ( char ) pdFALSE; { taskYIELD (); } @@ -1437,28 +1391,6 @@ BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FU BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - -/* - * xQueueAltGenericSend() is an alternative version of xQueueGenericSend(). - * Likewise xQueueAltGenericReceive() is an alternative version of - * xQueueGenericReceive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ); -BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking ); -#define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) -#define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) -#define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) -#define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) - /* * The functions defined above are for passing data to and from tasks. The * functions below are the equivalents for passing data to and from @@ -1479,8 +1411,12 @@ BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTi * these functions directly. */ QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; +void* xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; /* * For internal use only. Use xSemaphoreTakeMutexRecursive() or @@ -1517,7 +1453,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION * stores a pointer to the string - so the string must be persistent (global or * preferably in ROM/Flash), not on the stack. */ -#if configQUEUE_REGISTRY_SIZE > 0 +#if( configQUEUE_REGISTRY_SIZE > 0 ) void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif @@ -1531,15 +1467,42 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION * * @param xQueue The handle of the queue being removed from the registry. */ -#if configQUEUE_REGISTRY_SIZE > 0 +#if( configQUEUE_REGISTRY_SIZE > 0 ) void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; #endif /* - * Generic version of the queue creation function, which is in turn called by - * any queue, semaphore or mutex creation function or macro. + * The queue registry is provided as a means for kernel aware debuggers to + * locate queues, semaphores and mutexes. Call pcQueueGetName() to look + * up and return the name of a queue in the queue registry from the queue's + * handle. + * + * @param xQueue The handle of the queue the name of which will be returned. + * @return If the queue is in the registry then a pointer to the name of the + * queue is returned. If the queue is not in the registry then NULL is + * returned. + */ +#if( configQUEUE_REGISTRY_SIZE > 0 ) + const char *pcQueueGetName( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#endif + +/* + * Generic version of the function used to creaet a queue using dynamic memory + * allocation. This is called by other functions and macros that create other + * RTOS objects that use the queue structure as their base. */ -QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#endif + +/* + * Generic version of the function used to creaet a queue using dynamic memory + * allocation. This is called by other functions and macros that create other + * RTOS objects that use the queue structure as their base. + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#endif /* * Queue sets provide a mechanism to allow a task to block (pend) on a read @@ -1676,7 +1639,7 @@ QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const Ti QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; /* Not public API functions. */ -void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/semphr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/semphr.h new file mode 100644 index 0000000..e48f245 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/semphr.h @@ -0,0 +1,1141 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef SEMAPHORE_H +#define SEMAPHORE_H + +#ifndef INC_FREERTOS_H + #error "include FreeRTOS.h" must appear in source files before "include semphr.h" +#endif + +#include "queue.h" + +typedef QueueHandle_t SemaphoreHandle_t; + +#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) +#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) +#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) + + +/** + * semphr. h + *
      vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
      + * + * In many usage scenarios it is faster and more memory efficient to use a + * direct to task notification in place of a binary semaphore! + * http://www.freertos.org/RTOS-task-notifications.html + * + * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the + * xSemaphoreCreateBinary() function. Note that binary semaphores created using + * the vSemaphoreCreateBinary() macro are created in a state such that the + * first call to 'take' the semaphore would pass, whereas binary semaphores + * created using xSemaphoreCreateBinary() are created in a state such that the + * the semaphore must first be 'given' before it can be 'taken'. + * + * Macro that implements a semaphore by using the existing queue mechanism. + * The queue length is 1 as this is a binary semaphore. The data size is 0 + * as we don't want to actually store any data - we just want to know if the + * queue is empty or full. + * + * This type of semaphore can be used for pure synchronisation between tasks or + * between an interrupt and a task. The semaphore need not be given back once + * obtained, so one task/interrupt can continuously 'give' the semaphore while + * another continuously 'takes' the semaphore. For this reason this type of + * semaphore does not use a priority inheritance mechanism. For an alternative + * that does use priority inheritance see xSemaphoreCreateMutex(). + * + * @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      + void vATask( void * pvParameters )
      + {
      +    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
      +    // This is a macro so pass the variable in directly.
      +    vSemaphoreCreateBinary( xSemaphore );
      +
      +    if( xSemaphore != NULL )
      +    {
      +        // The semaphore was created successfully.
      +        // The semaphore can now be used.
      +    }
      + }
      + 
      + * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * \ingroup Semaphores + */ +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define vSemaphoreCreateBinary( xSemaphore ) \ + { \ + ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ + if( ( xSemaphore ) != NULL ) \ + { \ + ( void ) xSemaphoreGive( ( xSemaphore ) ); \ + } \ + } +#endif + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateBinary( void )
      + * + * Creates a new binary semaphore instance, and returns a handle by which the + * new semaphore can be referenced. + * + * In many usage scenarios it is faster and more memory efficient to use a + * direct to task notification in place of a binary semaphore! + * http://www.freertos.org/RTOS-task-notifications.html + * + * Internally, within the FreeRTOS implementation, binary semaphores use a block + * of memory, in which the semaphore structure is stored. If a binary semaphore + * is created using xSemaphoreCreateBinary() then the required memory is + * automatically dynamically allocated inside the xSemaphoreCreateBinary() + * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * is created using xSemaphoreCreateBinaryStatic() then the application writer + * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a + * binary semaphore to be created without using any dynamic memory allocation. + * + * The old vSemaphoreCreateBinary() macro is now deprecated in favour of this + * xSemaphoreCreateBinary() function. Note that binary semaphores created using + * the vSemaphoreCreateBinary() macro are created in a state such that the + * first call to 'take' the semaphore would pass, whereas binary semaphores + * created using xSemaphoreCreateBinary() are created in a state such that the + * the semaphore must first be 'given' before it can be 'taken'. + * + * This type of semaphore can be used for pure synchronisation between tasks or + * between an interrupt and a task. The semaphore need not be given back once + * obtained, so one task/interrupt can continuously 'give' the semaphore while + * another continuously 'takes' the semaphore. For this reason this type of + * semaphore does not use a priority inheritance mechanism. For an alternative + * that does use priority inheritance see xSemaphoreCreateMutex(). + * + * @return Handle to the created semaphore, or NULL if the memory required to + * hold the semaphore's data structures could not be allocated. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      + void vATask( void * pvParameters )
      + {
      +    // Semaphore cannot be used before a call to xSemaphoreCreateBinary().
      +    // This is a macro so pass the variable in directly.
      +    xSemaphore = xSemaphoreCreateBinary();
      +
      +    if( xSemaphore != NULL )
      +    {
      +        // The semaphore was created successfully.
      +        // The semaphore can now be used.
      +    }
      + }
      + 
      + * \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary + * \ingroup Semaphores + */ +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#endif + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer )
      + * + * Creates a new binary semaphore instance, and returns a handle by which the + * new semaphore can be referenced. + * + * NOTE: In many usage scenarios it is faster and more memory efficient to use a + * direct to task notification in place of a binary semaphore! + * http://www.freertos.org/RTOS-task-notifications.html + * + * Internally, within the FreeRTOS implementation, binary semaphores use a block + * of memory, in which the semaphore structure is stored. If a binary semaphore + * is created using xSemaphoreCreateBinary() then the required memory is + * automatically dynamically allocated inside the xSemaphoreCreateBinary() + * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * is created using xSemaphoreCreateBinaryStatic() then the application writer + * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a + * binary semaphore to be created without using any dynamic memory allocation. + * + * This type of semaphore can be used for pure synchronisation between tasks or + * between an interrupt and a task. The semaphore need not be given back once + * obtained, so one task/interrupt can continuously 'give' the semaphore while + * another continuously 'takes' the semaphore. For this reason this type of + * semaphore does not use a priority inheritance mechanism. For an alternative + * that does use priority inheritance see xSemaphoreCreateMutex(). + * + * @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t, + * which will then be used to hold the semaphore's data structure, removing the + * need for the memory to be allocated dynamically. + * + * @return If the semaphore is created then a handle to the created semaphore is + * returned. If pxSemaphoreBuffer is NULL then NULL is returned. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore = NULL;
      + StaticSemaphore_t xSemaphoreBuffer;
      +
      + void vATask( void * pvParameters )
      + {
      +    // Semaphore cannot be used before a call to xSemaphoreCreateBinary().
      +    // The semaphore's data structures will be placed in the xSemaphoreBuffer
      +    // variable, the address of which is passed into the function.  The
      +    // function's parameter is not NULL, so the function will not attempt any
      +    // dynamic memory allocation, and therefore the function will not return
      +    // return NULL.
      +    xSemaphore = xSemaphoreCreateBinary( &xSemaphoreBuffer );
      +
      +    // Rest of task code goes here.
      + }
      + 
      + * \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic + * \ingroup Semaphores + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** + * semphr. h + *
      xSemaphoreTake(
      + *                   SemaphoreHandle_t xSemaphore,
      + *                   TickType_t xBlockTime
      + *               )
      + * + * Macro to obtain a semaphore. The semaphore must have previously been + * created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or + * xSemaphoreCreateCounting(). + * + * @param xSemaphore A handle to the semaphore being taken - obtained when + * the semaphore was created. + * + * @param xBlockTime The time in ticks to wait for the semaphore to become + * available. The macro portTICK_PERIOD_MS can be used to convert this to a + * real time. A block time of zero can be used to poll the semaphore. A block + * time of portMAX_DELAY can be used to block indefinitely (provided + * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h). + * + * @return pdTRUE if the semaphore was obtained. pdFALSE + * if xBlockTime expired without the semaphore becoming available. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      + // A task that creates a semaphore.
      + void vATask( void * pvParameters )
      + {
      +    // Create the semaphore to guard a shared resource.
      +    xSemaphore = xSemaphoreCreateBinary();
      + }
      +
      + // A task that uses the semaphore.
      + void vAnotherTask( void * pvParameters )
      + {
      +    // ... Do other things.
      +
      +    if( xSemaphore != NULL )
      +    {
      +        // See if we can obtain the semaphore.  If the semaphore is not available
      +        // wait 10 ticks to see if it becomes free.
      +        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
      +        {
      +            // We were able to obtain the semaphore and can now access the
      +            // shared resource.
      +
      +            // ...
      +
      +            // We have finished accessing the shared resource.  Release the
      +            // semaphore.
      +            xSemaphoreGive( xSemaphore );
      +        }
      +        else
      +        {
      +            // We could not obtain the semaphore and can therefore not access
      +            // the shared resource safely.
      +        }
      +    }
      + }
      + 
      + * \defgroup xSemaphoreTake xSemaphoreTake + * \ingroup Semaphores + */ +#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) + +/** + * semphr. h + * xSemaphoreTakeRecursive( + * SemaphoreHandle_t xMutex, + * TickType_t xBlockTime + * ) + * + * Macro to recursively obtain, or 'take', a mutex type semaphore. + * The mutex must have previously been created using a call to + * xSemaphoreCreateRecursiveMutex(); + * + * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this + * macro to be available. + * + * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). + * + * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex + * doesn't become available again until the owner has called + * xSemaphoreGiveRecursive() for each successful 'take' request. For example, + * if a task successfully 'takes' the same mutex 5 times then the mutex will + * not be available to any other task until it has also 'given' the mutex back + * exactly five times. + * + * @param xMutex A handle to the mutex being obtained. This is the + * handle returned by xSemaphoreCreateRecursiveMutex(); + * + * @param xBlockTime The time in ticks to wait for the semaphore to become + * available. The macro portTICK_PERIOD_MS can be used to convert this to a + * real time. A block time of zero can be used to poll the semaphore. If + * the task already owns the semaphore then xSemaphoreTakeRecursive() will + * return immediately no matter what the value of xBlockTime. + * + * @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime + * expired without the semaphore becoming available. + * + * Example usage: +
      + SemaphoreHandle_t xMutex = NULL;
      +
      + // A task that creates a mutex.
      + void vATask( void * pvParameters )
      + {
      +    // Create the mutex to guard a shared resource.
      +    xMutex = xSemaphoreCreateRecursiveMutex();
      + }
      +
      + // A task that uses the mutex.
      + void vAnotherTask( void * pvParameters )
      + {
      +    // ... Do other things.
      +
      +    if( xMutex != NULL )
      +    {
      +        // See if we can obtain the mutex.  If the mutex is not available
      +        // wait 10 ticks to see if it becomes free.
      +        if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
      +        {
      +            // We were able to obtain the mutex and can now access the
      +            // shared resource.
      +
      +            // ...
      +            // For some reason due to the nature of the code further calls to
      +            // xSemaphoreTakeRecursive() are made on the same mutex.  In real
      +            // code these would not be just sequential calls as this would make
      +            // no sense.  Instead the calls are likely to be buried inside
      +            // a more complex call structure.
      +            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
      +            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
      +
      +            // The mutex has now been 'taken' three times, so will not be
      +            // available to another task until it has also been given back
      +            // three times.  Again it is unlikely that real code would have
      +            // these calls sequentially, but instead buried in a more complex
      +            // call structure.  This is just for illustrative purposes.
      +            xSemaphoreGiveRecursive( xMutex );
      +            xSemaphoreGiveRecursive( xMutex );
      +            xSemaphoreGiveRecursive( xMutex );
      +
      +            // Now the mutex can be taken by other tasks.
      +        }
      +        else
      +        {
      +            // We could not obtain the mutex and can therefore not access
      +            // the shared resource safely.
      +        }
      +    }
      + }
      + 
      + * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive + * \ingroup Semaphores + */ +#if( configUSE_RECURSIVE_MUTEXES == 1 ) + #define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) +#endif + +/** + * semphr. h + *
      xSemaphoreGive( SemaphoreHandle_t xSemaphore )
      + * + * Macro to release a semaphore. The semaphore must have previously been + * created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or + * xSemaphoreCreateCounting(). and obtained using sSemaphoreTake(). + * + * This macro must not be used from an ISR. See xSemaphoreGiveFromISR () for + * an alternative which can be used from an ISR. + * + * This macro must also not be used on semaphores created using + * xSemaphoreCreateRecursiveMutex(). + * + * @param xSemaphore A handle to the semaphore being released. This is the + * handle returned when the semaphore was created. + * + * @return pdTRUE if the semaphore was released. pdFALSE if an error occurred. + * Semaphores are implemented using queues. An error can occur if there is + * no space on the queue to post a message - indicating that the + * semaphore was not first obtained correctly. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      + void vATask( void * pvParameters )
      + {
      +    // Create the semaphore to guard a shared resource.
      +    xSemaphore = vSemaphoreCreateBinary();
      +
      +    if( xSemaphore != NULL )
      +    {
      +        if( xSemaphoreGive( xSemaphore ) != pdTRUE )
      +        {
      +            // We would expect this call to fail because we cannot give
      +            // a semaphore without first "taking" it!
      +        }
      +
      +        // Obtain the semaphore - don't block if the semaphore is not
      +        // immediately available.
      +        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
      +        {
      +            // We now have the semaphore and can access the shared resource.
      +
      +            // ...
      +
      +            // We have finished accessing the shared resource so can free the
      +            // semaphore.
      +            if( xSemaphoreGive( xSemaphore ) != pdTRUE )
      +            {
      +                // We would not expect this call to fail because we must have
      +                // obtained the semaphore to get here.
      +            }
      +        }
      +    }
      + }
      + 
      + * \defgroup xSemaphoreGive xSemaphoreGive + * \ingroup Semaphores + */ +#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) + +/** + * semphr. h + *
      xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
      + * + * Macro to recursively release, or 'give', a mutex type semaphore. + * The mutex must have previously been created using a call to + * xSemaphoreCreateRecursiveMutex(); + * + * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this + * macro to be available. + * + * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). + * + * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex + * doesn't become available again until the owner has called + * xSemaphoreGiveRecursive() for each successful 'take' request. For example, + * if a task successfully 'takes' the same mutex 5 times then the mutex will + * not be available to any other task until it has also 'given' the mutex back + * exactly five times. + * + * @param xMutex A handle to the mutex being released, or 'given'. This is the + * handle returned by xSemaphoreCreateMutex(); + * + * @return pdTRUE if the semaphore was given. + * + * Example usage: +
      + SemaphoreHandle_t xMutex = NULL;
      +
      + // A task that creates a mutex.
      + void vATask( void * pvParameters )
      + {
      +    // Create the mutex to guard a shared resource.
      +    xMutex = xSemaphoreCreateRecursiveMutex();
      + }
      +
      + // A task that uses the mutex.
      + void vAnotherTask( void * pvParameters )
      + {
      +    // ... Do other things.
      +
      +    if( xMutex != NULL )
      +    {
      +        // See if we can obtain the mutex.  If the mutex is not available
      +        // wait 10 ticks to see if it becomes free.
      +        if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
      +        {
      +            // We were able to obtain the mutex and can now access the
      +            // shared resource.
      +
      +            // ...
      +            // For some reason due to the nature of the code further calls to
      +			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
      +			// code these would not be just sequential calls as this would make
      +			// no sense.  Instead the calls are likely to be buried inside
      +			// a more complex call structure.
      +            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
      +            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
      +
      +            // The mutex has now been 'taken' three times, so will not be
      +			// available to another task until it has also been given back
      +			// three times.  Again it is unlikely that real code would have
      +			// these calls sequentially, it would be more likely that the calls
      +			// to xSemaphoreGiveRecursive() would be called as a call stack
      +			// unwound.  This is just for demonstrative purposes.
      +            xSemaphoreGiveRecursive( xMutex );
      +			xSemaphoreGiveRecursive( xMutex );
      +			xSemaphoreGiveRecursive( xMutex );
      +
      +			// Now the mutex can be taken by other tasks.
      +        }
      +        else
      +        {
      +            // We could not obtain the mutex and can therefore not access
      +            // the shared resource safely.
      +        }
      +    }
      + }
      + 
      + * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive + * \ingroup Semaphores + */ +#if( configUSE_RECURSIVE_MUTEXES == 1 ) + #define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) +#endif + +/** + * semphr. h + *
      + xSemaphoreGiveFromISR(
      +                          SemaphoreHandle_t xSemaphore,
      +                          BaseType_t *pxHigherPriorityTaskWoken
      +                      )
      + * + * Macro to release a semaphore. The semaphore must have previously been + * created with a call to xSemaphoreCreateBinary() or xSemaphoreCreateCounting(). + * + * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) + * must not be used with this macro. + * + * This macro can be used from an ISR. + * + * @param xSemaphore A handle to the semaphore being released. This is the + * handle returned when the semaphore was created. + * + * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL. + * + * Example usage: +
      + \#define LONG_TIME 0xffff
      + \#define TICKS_TO_WAIT	10
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      + // Repetitive task.
      + void vATask( void * pvParameters )
      + {
      +    for( ;; )
      +    {
      +        // We want this task to run every 10 ticks of a timer.  The semaphore
      +        // was created before this task was started.
      +
      +        // Block waiting for the semaphore to become available.
      +        if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
      +        {
      +            // It is time to execute.
      +
      +            // ...
      +
      +            // We have finished our task.  Return to the top of the loop where
      +            // we will block on the semaphore until it is time to execute
      +            // again.  Note when using the semaphore for synchronisation with an
      +			// ISR in this manner there is no need to 'give' the semaphore back.
      +        }
      +    }
      + }
      +
      + // Timer ISR
      + void vTimerISR( void * pvParameters )
      + {
      + static uint8_t ucLocalTickCount = 0;
      + static BaseType_t xHigherPriorityTaskWoken;
      +
      +    // A timer tick has occurred.
      +
      +    // ... Do other time functions.
      +
      +    // Is it time for vATask () to run?
      +	xHigherPriorityTaskWoken = pdFALSE;
      +    ucLocalTickCount++;
      +    if( ucLocalTickCount >= TICKS_TO_WAIT )
      +    {
      +        // Unblock the task by releasing the semaphore.
      +        xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
      +
      +        // Reset the count so we release the semaphore again in 10 ticks time.
      +        ucLocalTickCount = 0;
      +    }
      +
      +    if( xHigherPriorityTaskWoken != pdFALSE )
      +    {
      +        // We can force a context switch here.  Context switching from an
      +        // ISR uses port specific syntax.  Check the demo task for your port
      +        // to find the syntax required.
      +    }
      + }
      + 
      + * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR + * \ingroup Semaphores + */ +#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) + +/** + * semphr. h + *
      + xSemaphoreTakeFromISR(
      +                          SemaphoreHandle_t xSemaphore,
      +                          BaseType_t *pxHigherPriorityTaskWoken
      +                      )
      + * + * Macro to take a semaphore from an ISR. The semaphore must have + * previously been created with a call to xSemaphoreCreateBinary() or + * xSemaphoreCreateCounting(). + * + * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) + * must not be used with this macro. + * + * This macro can be used from an ISR, however taking a semaphore from an ISR + * is not a common operation. It is likely to only be useful when taking a + * counting semaphore when an interrupt is obtaining an object from a resource + * pool (when the semaphore count indicates the number of resources available). + * + * @param xSemaphore A handle to the semaphore being taken. This is the + * handle returned when the semaphore was created. + * + * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return pdTRUE if the semaphore was successfully taken, otherwise + * pdFALSE + */ +#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateMutex( void )
      + * + * Creates a new mutex type semaphore instance, and returns a handle by which + * the new mutex can be referenced. + * + * Internally, within the FreeRTOS implementation, mutex semaphores use a block + * of memory, in which the mutex structure is stored. If a mutex is created + * using xSemaphoreCreateMutex() then the required memory is automatically + * dynamically allocated inside the xSemaphoreCreateMutex() function. (see + * http://www.freertos.org/a00111.html). If a mutex is created using + * xSemaphoreCreateMutexStatic() then the application writer must provided the + * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created + * without using any dynamic memory allocation. + * + * Mutexes created using this function can be accessed using the xSemaphoreTake() + * and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and + * xSemaphoreGiveRecursive() macros must not be used. + * + * This type of semaphore uses a priority inheritance mechanism so a task + * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the + * semaphore it is no longer required. + * + * Mutex type semaphores cannot be used from within interrupt service routines. + * + * See xSemaphoreCreateBinary() for an alternative implementation that can be + * used for pure synchronisation (where one task or interrupt always 'gives' the + * semaphore and another always 'takes' the semaphore) and from within interrupt + * service routines. + * + * @return If the mutex was successfully created then a handle to the created + * semaphore is returned. If there was not enough heap to allocate the mutex + * data structures then NULL is returned. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore;
      +
      + void vATask( void * pvParameters )
      + {
      +    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
      +    // This is a macro so pass the variable in directly.
      +    xSemaphore = xSemaphoreCreateMutex();
      +
      +    if( xSemaphore != NULL )
      +    {
      +        // The semaphore was created successfully.
      +        // The semaphore can now be used.
      +    }
      + }
      + 
      + * \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex + * \ingroup Semaphores + */ +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) +#endif + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer )
      + * + * Creates a new mutex type semaphore instance, and returns a handle by which + * the new mutex can be referenced. + * + * Internally, within the FreeRTOS implementation, mutex semaphores use a block + * of memory, in which the mutex structure is stored. If a mutex is created + * using xSemaphoreCreateMutex() then the required memory is automatically + * dynamically allocated inside the xSemaphoreCreateMutex() function. (see + * http://www.freertos.org/a00111.html). If a mutex is created using + * xSemaphoreCreateMutexStatic() then the application writer must provided the + * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created + * without using any dynamic memory allocation. + * + * Mutexes created using this function can be accessed using the xSemaphoreTake() + * and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and + * xSemaphoreGiveRecursive() macros must not be used. + * + * This type of semaphore uses a priority inheritance mechanism so a task + * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the + * semaphore it is no longer required. + * + * Mutex type semaphores cannot be used from within interrupt service routines. + * + * See xSemaphoreCreateBinary() for an alternative implementation that can be + * used for pure synchronisation (where one task or interrupt always 'gives' the + * semaphore and another always 'takes' the semaphore) and from within interrupt + * service routines. + * + * @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t, + * which will be used to hold the mutex's data structure, removing the need for + * the memory to be allocated dynamically. + * + * @return If the mutex was successfully created then a handle to the created + * mutex is returned. If pxMutexBuffer was NULL then NULL is returned. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore;
      + StaticSemaphore_t xMutexBuffer;
      +
      + void vATask( void * pvParameters )
      + {
      +    // A mutex cannot be used before it has been created.  xMutexBuffer is
      +    // into xSemaphoreCreateMutexStatic() so no dynamic memory allocation is
      +    // attempted.
      +    xSemaphore = xSemaphoreCreateMutexStatic( &xMutexBuffer );
      +
      +    // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
      +    // so there is no need to check it.
      + }
      + 
      + * \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic + * \ingroup Semaphores + */ + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) +#endif /* configSUPPORT_STATIC_ALLOCATION */ + + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )
      + * + * Creates a new recursive mutex type semaphore instance, and returns a handle + * by which the new recursive mutex can be referenced. + * + * Internally, within the FreeRTOS implementation, recursive mutexs use a block + * of memory, in which the mutex structure is stored. If a recursive mutex is + * created using xSemaphoreCreateRecursiveMutex() then the required memory is + * automatically dynamically allocated inside the + * xSemaphoreCreateRecursiveMutex() function. (see + * http://www.freertos.org/a00111.html). If a recursive mutex is created using + * xSemaphoreCreateRecursiveMutexStatic() then the application writer must + * provide the memory that will get used by the mutex. + * xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to + * be created without using any dynamic memory allocation. + * + * Mutexes created using this macro can be accessed using the + * xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The + * xSemaphoreTake() and xSemaphoreGive() macros must not be used. + * + * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex + * doesn't become available again until the owner has called + * xSemaphoreGiveRecursive() for each successful 'take' request. For example, + * if a task successfully 'takes' the same mutex 5 times then the mutex will + * not be available to any other task until it has also 'given' the mutex back + * exactly five times. + * + * This type of semaphore uses a priority inheritance mechanism so a task + * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the + * semaphore it is no longer required. + * + * Mutex type semaphores cannot be used from within interrupt service routines. + * + * See xSemaphoreCreateBinary() for an alternative implementation that can be + * used for pure synchronisation (where one task or interrupt always 'gives' the + * semaphore and another always 'takes' the semaphore) and from within interrupt + * service routines. + * + * @return xSemaphore Handle to the created mutex semaphore. Should be of type + * SemaphoreHandle_t. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore;
      +
      + void vATask( void * pvParameters )
      + {
      +    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
      +    // This is a macro so pass the variable in directly.
      +    xSemaphore = xSemaphoreCreateRecursiveMutex();
      +
      +    if( xSemaphore != NULL )
      +    {
      +        // The semaphore was created successfully.
      +        // The semaphore can now be used.
      +    }
      + }
      + 
      + * \defgroup xSemaphoreCreateRecursiveMutex xSemaphoreCreateRecursiveMutex + * \ingroup Semaphores + */ +#if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) + #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) +#endif + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic( StaticSemaphore_t *pxMutexBuffer )
      + * + * Creates a new recursive mutex type semaphore instance, and returns a handle + * by which the new recursive mutex can be referenced. + * + * Internally, within the FreeRTOS implementation, recursive mutexs use a block + * of memory, in which the mutex structure is stored. If a recursive mutex is + * created using xSemaphoreCreateRecursiveMutex() then the required memory is + * automatically dynamically allocated inside the + * xSemaphoreCreateRecursiveMutex() function. (see + * http://www.freertos.org/a00111.html). If a recursive mutex is created using + * xSemaphoreCreateRecursiveMutexStatic() then the application writer must + * provide the memory that will get used by the mutex. + * xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to + * be created without using any dynamic memory allocation. + * + * Mutexes created using this macro can be accessed using the + * xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The + * xSemaphoreTake() and xSemaphoreGive() macros must not be used. + * + * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex + * doesn't become available again until the owner has called + * xSemaphoreGiveRecursive() for each successful 'take' request. For example, + * if a task successfully 'takes' the same mutex 5 times then the mutex will + * not be available to any other task until it has also 'given' the mutex back + * exactly five times. + * + * This type of semaphore uses a priority inheritance mechanism so a task + * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the + * semaphore it is no longer required. + * + * Mutex type semaphores cannot be used from within interrupt service routines. + * + * See xSemaphoreCreateBinary() for an alternative implementation that can be + * used for pure synchronisation (where one task or interrupt always 'gives' the + * semaphore and another always 'takes' the semaphore) and from within interrupt + * service routines. + * + * @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t, + * which will then be used to hold the recursive mutex's data structure, + * removing the need for the memory to be allocated dynamically. + * + * @return If the recursive mutex was successfully created then a handle to the + * created recursive mutex is returned. If pxMutexBuffer was NULL then NULL is + * returned. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore;
      + StaticSemaphore_t xMutexBuffer;
      +
      + void vATask( void * pvParameters )
      + {
      +    // A recursive semaphore cannot be used before it is created.  Here a
      +    // recursive mutex is created using xSemaphoreCreateRecursiveMutexStatic().
      +    // The address of xMutexBuffer is passed into the function, and will hold
      +    // the mutexes data structures - so no dynamic memory allocation will be
      +    // attempted.
      +    xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &xMutexBuffer );
      +
      +    // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
      +    // so there is no need to check it.
      + }
      + 
      + * \defgroup xSemaphoreCreateRecursiveMutexStatic xSemaphoreCreateRecursiveMutexStatic + * \ingroup Semaphores + */ +#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) + #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )
      + * + * Creates a new counting semaphore instance, and returns a handle by which the + * new counting semaphore can be referenced. + * + * In many usage scenarios it is faster and more memory efficient to use a + * direct to task notification in place of a counting semaphore! + * http://www.freertos.org/RTOS-task-notifications.html + * + * Internally, within the FreeRTOS implementation, counting semaphores use a + * block of memory, in which the counting semaphore structure is stored. If a + * counting semaphore is created using xSemaphoreCreateCounting() then the + * required memory is automatically dynamically allocated inside the + * xSemaphoreCreateCounting() function. (see + * http://www.freertos.org/a00111.html). If a counting semaphore is created + * using xSemaphoreCreateCountingStatic() then the application writer can + * instead optionally provide the memory that will get used by the counting + * semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting + * semaphore to be created without using any dynamic memory allocation. + * + * Counting semaphores are typically used for two things: + * + * 1) Counting events. + * + * In this usage scenario an event handler will 'give' a semaphore each time + * an event occurs (incrementing the semaphore count value), and a handler + * task will 'take' a semaphore each time it processes an event + * (decrementing the semaphore count value). The count value is therefore + * the difference between the number of events that have occurred and the + * number that have been processed. In this case it is desirable for the + * initial count value to be zero. + * + * 2) Resource management. + * + * In this usage scenario the count value indicates the number of resources + * available. To obtain control of a resource a task must first obtain a + * semaphore - decrementing the semaphore count value. When the count value + * reaches zero there are no free resources. When a task finishes with the + * resource it 'gives' the semaphore back - incrementing the semaphore count + * value. In this case it is desirable for the initial count value to be + * equal to the maximum count value, indicating that all resources are free. + * + * @param uxMaxCount The maximum count value that can be reached. When the + * semaphore reaches this value it can no longer be 'given'. + * + * @param uxInitialCount The count value assigned to the semaphore when it is + * created. + * + * @return Handle to the created semaphore. Null if the semaphore could not be + * created. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore;
      +
      + void vATask( void * pvParameters )
      + {
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      +    // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
      +    // The max value to which the semaphore can count should be 10, and the
      +    // initial value assigned to the count should be 0.
      +    xSemaphore = xSemaphoreCreateCounting( 10, 0 );
      +
      +    if( xSemaphore != NULL )
      +    {
      +        // The semaphore was created successfully.
      +        // The semaphore can now be used.
      +    }
      + }
      + 
      + * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting + * \ingroup Semaphores + */ +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) +#endif + +/** + * semphr. h + *
      SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer )
      + * + * Creates a new counting semaphore instance, and returns a handle by which the + * new counting semaphore can be referenced. + * + * In many usage scenarios it is faster and more memory efficient to use a + * direct to task notification in place of a counting semaphore! + * http://www.freertos.org/RTOS-task-notifications.html + * + * Internally, within the FreeRTOS implementation, counting semaphores use a + * block of memory, in which the counting semaphore structure is stored. If a + * counting semaphore is created using xSemaphoreCreateCounting() then the + * required memory is automatically dynamically allocated inside the + * xSemaphoreCreateCounting() function. (see + * http://www.freertos.org/a00111.html). If a counting semaphore is created + * using xSemaphoreCreateCountingStatic() then the application writer must + * provide the memory. xSemaphoreCreateCountingStatic() therefore allows a + * counting semaphore to be created without using any dynamic memory allocation. + * + * Counting semaphores are typically used for two things: + * + * 1) Counting events. + * + * In this usage scenario an event handler will 'give' a semaphore each time + * an event occurs (incrementing the semaphore count value), and a handler + * task will 'take' a semaphore each time it processes an event + * (decrementing the semaphore count value). The count value is therefore + * the difference between the number of events that have occurred and the + * number that have been processed. In this case it is desirable for the + * initial count value to be zero. + * + * 2) Resource management. + * + * In this usage scenario the count value indicates the number of resources + * available. To obtain control of a resource a task must first obtain a + * semaphore - decrementing the semaphore count value. When the count value + * reaches zero there are no free resources. When a task finishes with the + * resource it 'gives' the semaphore back - incrementing the semaphore count + * value. In this case it is desirable for the initial count value to be + * equal to the maximum count value, indicating that all resources are free. + * + * @param uxMaxCount The maximum count value that can be reached. When the + * semaphore reaches this value it can no longer be 'given'. + * + * @param uxInitialCount The count value assigned to the semaphore when it is + * created. + * + * @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t, + * which will then be used to hold the semaphore's data structure, removing the + * need for the memory to be allocated dynamically. + * + * @return If the counting semaphore was successfully created then a handle to + * the created counting semaphore is returned. If pxSemaphoreBuffer was NULL + * then NULL is returned. + * + * Example usage: +
      + SemaphoreHandle_t xSemaphore;
      + StaticSemaphore_t xSemaphoreBuffer;
      +
      + void vATask( void * pvParameters )
      + {
      + SemaphoreHandle_t xSemaphore = NULL;
      +
      +    // Counting semaphore cannot be used before they have been created.  Create
      +    // a counting semaphore using xSemaphoreCreateCountingStatic().  The max
      +    // value to which the semaphore can count is 10, and the initial value
      +    // assigned to the count will be 0.  The address of xSemaphoreBuffer is
      +    // passed in and will be used to hold the semaphore structure, so no dynamic
      +    // memory allocation will be used.
      +    xSemaphore = xSemaphoreCreateCounting( 10, 0, &xSemaphoreBuffer );
      +
      +    // No memory allocation was attempted so xSemaphore cannot be NULL, so there
      +    // is no need to check its value.
      + }
      + 
      + * \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic + * \ingroup Semaphores + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** + * semphr. h + *
      void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );
      + * + * Delete a semaphore. This function must be used with care. For example, + * do not delete a mutex type semaphore if the mutex is held by a task. + * + * @param xSemaphore A handle to the semaphore to be deleted. + * + * \defgroup vSemaphoreDelete vSemaphoreDelete + * \ingroup Semaphores + */ +#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) + +/** + * semphr.h + *
      TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );
      + * + * If xMutex is indeed a mutex type semaphore, return the current mutex holder. + * If xMutex is not a mutex type semaphore, or the mutex is available (not held + * by a task), return NULL. + * + * Note: This is a good way of determining if the calling task is the mutex + * holder, but not a good way of determining the identity of the mutex holder as + * the holder may change between the function exiting and the returned value + * being tested. + */ +#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) + +/** + * semphr.h + *
      TaskHandle_t xSemaphoreGetMutexHolderFromISR( SemaphoreHandle_t xMutex );
      + * + * If xMutex is indeed a mutex type semaphore, return the current mutex holder. + * If xMutex is not a mutex type semaphore, or the mutex is available (not held + * by a task), return NULL. + * + */ +#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) + +/** + * semphr.h + *
      UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );
      + * + * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns + * its current count value. If the semaphore is a binary semaphore then + * uxSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the + * semaphore is not available. + * + */ +#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) + +#endif /* SEMAPHORE_H */ + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stack_macros.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stack_macros.h new file mode 100644 index 0000000..99f6502 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stack_macros.h @@ -0,0 +1,130 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef STACK_MACROS_H +#define STACK_MACROS_H + +/* + * Call the stack overflow hook function if the stack of the task being swapped + * out is currently overflowed, or looks like it might have overflowed in the + * past. + * + * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check + * the current stack state only - comparing the current top of stack value to + * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 + * will also cause the last few stack bytes to be checked to ensure the value + * to which the bytes were set when the task was created have not been + * overwritten. Note this second test does not guarantee that an overflowed + * stack will always be recognised. + */ + +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) + + /* Only the current stack state is to be checked. */ + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) + + /* Only the current stack state is to be checked. */ + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) + + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ + const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ + \ + if( ( pulStack[ 0 ] != ulCheckValue ) || \ + ( pulStack[ 1 ] != ulCheckValue ) || \ + ( pulStack[ 2 ] != ulCheckValue ) || \ + ( pulStack[ 3 ] != ulCheckValue ) ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ +/*-----------------------------------------------------------*/ + +#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) + + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ +/*-----------------------------------------------------------*/ + +/* Remove stack overflow macro if not being used. */ +#ifndef taskCHECK_FOR_STACK_OVERFLOW + #define taskCHECK_FOR_STACK_OVERFLOW() +#endif + + + +#endif /* STACK_MACROS_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/stdint.readme b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stdint.readme similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/stdint.readme rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stdint.readme diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stream_buffer.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stream_buffer.h new file mode 100644 index 0000000..55c6e6e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/stream_buffer.h @@ -0,0 +1,849 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* + * Stream buffers are used to send a continuous stream of data from one task or + * interrupt to another. Their implementation is light weight, making them + * particularly suited for interrupt to task and core to core communication + * scenarios. + * + * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer + * implementation (so also the message buffer implementation, as message buffers + * are built on top of stream buffers) assumes there is only one task or + * interrupt that will write to the buffer (the writer), and only one task or + * interrupt that will read from the buffer (the reader). It is safe for the + * writer and reader to be different tasks or interrupts, but, unlike other + * FreeRTOS objects, it is not safe to have multiple different writers or + * multiple different readers. If there are to be multiple different writers + * then the application writer must place each call to a writing API function + * (such as xStreamBufferSend()) inside a critical section and set the send + * block time to 0. Likewise, if there are to be multiple different readers + * then the application writer must place each call to a reading API function + * (such as xStreamBufferRead()) inside a critical section section and set the + * receive block time to 0. + * + */ + +#ifndef STREAM_BUFFER_H +#define STREAM_BUFFER_H + +/** + * Type by which stream buffers are referenced. For example, a call to + * xStreamBufferCreate() returns an StreamBufferHandle_t variable that can + * then be used as a parameter to xStreamBufferSend(), xStreamBufferReceive(), + * etc. + */ +typedef void * StreamBufferHandle_t; + + +/** + * message_buffer.h + * +
      +StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes );
      +
      + * + * Creates a new stream buffer using dynamically allocated memory. See + * xStreamBufferCreateStatic() for a version that uses statically allocated + * memory (memory that is allocated at compile time). + * + * configSUPPORT_DYNAMIC_ALLOCATION must be set to 1 or left undefined in + * FreeRTOSConfig.h for xStreamBufferCreate() to be available. + * + * @param xBufferSizeBytes The total number of bytes the stream buffer will be + * able to hold at any one time. + * + * @param xTriggerLevelBytes The number of bytes that must be in the stream + * buffer before a task that is blocked on the stream buffer to wait for data is + * moved out of the blocked state. For example, if a task is blocked on a read + * of an empty stream buffer that has a trigger level of 1 then the task will be + * unblocked when a single byte is written to the buffer or the task's block + * time expires. As another example, if a task is blocked on a read of an empty + * stream buffer that has a trigger level of 10 then the task will not be + * unblocked until the stream buffer contains at least 10 bytes or the task's + * block time expires. If a reading task's block time expires before the + * trigger level is reached then the task will still receive however many bytes + * are actually available. Setting a trigger level of 0 will result in a + * trigger level of 1 being used. It is not valid to specify a trigger level + * that is greater than the buffer size. + * + * @return If NULL is returned, then the stream buffer cannot be created + * because there is insufficient heap memory available for FreeRTOS to allocate + * the stream buffer data structures and storage area. A non-NULL value being + * returned indicates that the stream buffer has been created successfully - + * the returned value should be stored as the handle to the created stream + * buffer. + * + * Example use: +
      +
      +void vAFunction( void )
      +{
      +StreamBufferHandle_t xStreamBuffer;
      +const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10;
      +
      +    // Create a stream buffer that can hold 100 bytes.  The memory used to hold
      +    // both the stream buffer structure and the data in the stream buffer is
      +    // allocated dynamically.
      +    xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel );
      +
      +    if( xStreamBuffer == NULL )
      +    {
      +        // There was not enough heap memory space available to create the
      +        // stream buffer.
      +    }
      +    else
      +    {
      +        // The stream buffer was created successfully and can now be used.
      +    }
      +}
      +
      + * \defgroup xStreamBufferCreate xStreamBufferCreate + * \ingroup StreamBufferManagement + */ +#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) + +/** + * stream_buffer.h + * +
      +StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes,
      +                                                size_t xTriggerLevelBytes,
      +                                                uint8_t *pucStreamBufferStorageArea,
      +                                                StaticStreamBuffer_t *pxStaticStreamBuffer );
      +
      + * Creates a new stream buffer using statically allocated memory. See + * xStreamBufferCreate() for a version that uses dynamically allocated memory. + * + * configSUPPORT_STATIC_ALLOCATION must be set to 1 in FreeRTOSConfig.h for + * xStreamBufferCreateStatic() to be available. + * + * @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the + * pucStreamBufferStorageArea parameter. + * + * @param xTriggerLevelBytes The number of bytes that must be in the stream + * buffer before a task that is blocked on the stream buffer to wait for data is + * moved out of the blocked state. For example, if a task is blocked on a read + * of an empty stream buffer that has a trigger level of 1 then the task will be + * unblocked when a single byte is written to the buffer or the task's block + * time expires. As another example, if a task is blocked on a read of an empty + * stream buffer that has a trigger level of 10 then the task will not be + * unblocked until the stream buffer contains at least 10 bytes or the task's + * block time expires. If a reading task's block time expires before the + * trigger level is reached then the task will still receive however many bytes + * are actually available. Setting a trigger level of 0 will result in a + * trigger level of 1 being used. It is not valid to specify a trigger level + * that is greater than the buffer size. + * + * @param pucStreamBufferStorageArea Must point to a uint8_t array that is at + * least xBufferSizeBytes + 1 big. This is the array to which streams are + * copied when they are written to the stream buffer. + * + * @param pxStaticStreamBuffer Must point to a variable of type + * StaticStreamBuffer_t, which will be used to hold the stream buffer's data + * structure. + * + * @return If the stream buffer is created successfully then a handle to the + * created stream buffer is returned. If either pucStreamBufferStorageArea or + * pxStaticstreamBuffer are NULL then NULL is returned. + * + * Example use: +
      +
      +// Used to dimension the array used to hold the streams.  The available space
      +// will actually be one less than this, so 999.
      +#define STORAGE_SIZE_BYTES 1000
      +
      +// Defines the memory that will actually hold the streams within the stream
      +// buffer.
      +static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ];
      +
      +// The variable used to hold the stream buffer structure.
      +StaticStreamBuffer_t xStreamBufferStruct;
      +
      +void MyFunction( void )
      +{
      +StreamBufferHandle_t xStreamBuffer;
      +const size_t xTriggerLevel = 1;
      +
      +    xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ),
      +                                               xTriggerLevel,
      +                                               ucBufferStorage,
      +                                               &xStreamBufferStruct );
      +
      +    // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer
      +    // parameters were NULL, xStreamBuffer will not be NULL, and can be used to
      +    // reference the created stream buffer in other stream buffer API calls.
      +
      +    // Other code that uses the stream buffer can go here.
      +}
      +
      +
      + * \defgroup xStreamBufferCreateStatic xStreamBufferCreateStatic + * \ingroup StreamBufferManagement + */ +#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) + +/** + * stream_buffer.h + * +
      +size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
      +                          const void *pvTxData,
      +                          size_t xDataLengthBytes,
      +                          TickType_t xTicksToWait );
      +
      + *
      + * Sends bytes to a stream buffer.  The bytes are copied into the stream buffer.
      + *
      + * ***NOTE***:  Uniquely among FreeRTOS objects, the stream buffer
      + * implementation (so also the message buffer implementation, as message buffers
      + * are built on top of stream buffers) assumes there is only one task or
      + * interrupt that will write to the buffer (the writer), and only one task or
      + * interrupt that will read from the buffer (the reader).  It is safe for the
      + * writer and reader to be different tasks or interrupts, but, unlike other
      + * FreeRTOS objects, it is not safe to have multiple different writers or
      + * multiple different readers.  If there are to be multiple different writers
      + * then the application writer must place each call to a writing API function
      + * (such as xStreamBufferSend()) inside a critical section and set the send
      + * block time to 0.  Likewise, if there are to be multiple different readers
      + * then the application writer must place each call to a reading API function
      + * (such as xStreamBufferRead()) inside a critical section and set the receive
      + * block time to 0.
      + *
      + * Use xStreamBufferSend() to write to a stream buffer from a task.  Use
      + * xStreamBufferSendFromISR() to write to a stream buffer from an interrupt
      + * service routine (ISR).
      + *
      + * @param xStreamBuffer The handle of the stream buffer to which a stream is
      + * being sent.
      + *
      + * @param pvTxData A pointer to the buffer that holds the bytes to be copied
      + * into the stream buffer.
      + *
      + * @param xDataLengthBytes   The maximum number of bytes to copy from pvTxData
      + * into the stream buffer.
      + *
      + * @param xTicksToWait The maximum amount of time the task should remain in the
      + * Blocked state to wait for enough space to become available in the stream
      + * buffer, should the stream buffer contain too little space to hold the
      + * another xDataLengthBytes bytes.  The block time is specified in tick periods,
      + * so the absolute time it represents is dependent on the tick frequency.  The
      + * macro pdMS_TO_TICKS() can be used to convert a time specified in milliseconds
      + * into a time specified in ticks.  Setting xTicksToWait to portMAX_DELAY will
      + * cause the task to wait indefinitely (without timing out), provided
      + * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h.  If a task times out
      + * before it can write all xDataLengthBytes into the buffer it will still write
      + * as many bytes as possible.  A task does not use any CPU time when it is in
      + * the blocked state.
      + *
      + * @return The number of bytes written to the stream buffer.  If a task times
      + * out before it can write all xDataLengthBytes into the buffer it will still
      + * write as many bytes as possible.
      + *
      + * Example use:
      +
      +void vAFunction( StreamBufferHandle_t xStreamBuffer )
      +{
      +size_t xBytesSent;
      +uint8_t ucArrayToSend[] = { 0, 1, 2, 3 };
      +char *pcStringToSend = "String to send";
      +const TickType_t x100ms = pdMS_TO_TICKS( 100 );
      +
      +    // Send an array to the stream buffer, blocking for a maximum of 100ms to
      +    // wait for enough space to be available in the stream buffer.
      +    xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms );
      +
      +    if( xBytesSent != sizeof( ucArrayToSend ) )
      +    {
      +        // The call to xStreamBufferSend() times out before there was enough
      +        // space in the buffer for the data to be written, but it did
      +        // successfully write xBytesSent bytes.
      +    }
      +
      +    // Send the string to the stream buffer.  Return immediately if there is not
      +    // enough space in the buffer.
      +    xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 );
      +
      +    if( xBytesSent != strlen( pcStringToSend ) )
      +    {
      +        // The entire string could not be added to the stream buffer because
      +        // there was not enough free space in the buffer, but xBytesSent bytes
      +        // were sent.  Could try again to send the remaining bytes.
      +    }
      +}
      +
      + * \defgroup xStreamBufferSend xStreamBufferSend + * \ingroup StreamBufferManagement + */ +size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + const void *pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
      +                                 const void *pvTxData,
      +                                 size_t xDataLengthBytes,
      +                                 BaseType_t *pxHigherPriorityTaskWoken );
      +
      + *
      + * Interrupt safe version of the API function that sends a stream of bytes to
      + * the stream buffer.
      + *
      + * ***NOTE***:  Uniquely among FreeRTOS objects, the stream buffer
      + * implementation (so also the message buffer implementation, as message buffers
      + * are built on top of stream buffers) assumes there is only one task or
      + * interrupt that will write to the buffer (the writer), and only one task or
      + * interrupt that will read from the buffer (the reader).  It is safe for the
      + * writer and reader to be different tasks or interrupts, but, unlike other
      + * FreeRTOS objects, it is not safe to have multiple different writers or
      + * multiple different readers.  If there are to be multiple different writers
      + * then the application writer must place each call to a writing API function
      + * (such as xStreamBufferSend()) inside a critical section and set the send
      + * block time to 0.  Likewise, if there are to be multiple different readers
      + * then the application writer must place each call to a reading API function
      + * (such as xStreamBufferRead()) inside a critical section and set the receive
      + * block time to 0.
      + *
      + * Use xStreamBufferSend() to write to a stream buffer from a task.  Use
      + * xStreamBufferSendFromISR() to write to a stream buffer from an interrupt
      + * service routine (ISR).
      + *
      + * @param xStreamBuffer The handle of the stream buffer to which a stream is
      + * being sent.
      + *
      + * @param pvTxData A pointer to the data that is to be copied into the stream
      + * buffer.
      + *
      + * @param xDataLengthBytes The maximum number of bytes to copy from pvTxData
      + * into the stream buffer.
      + *
      + * @param pxHigherPriorityTaskWoken  It is possible that a stream buffer will
      + * have a task blocked on it waiting for data.  Calling
      + * xStreamBufferSendFromISR() can make data available, and so cause a task that
      + * was waiting for data to leave the Blocked state.  If calling
      + * xStreamBufferSendFromISR() causes a task to leave the Blocked state, and the
      + * unblocked task has a priority higher than the currently executing task (the
      + * task that was interrupted), then, internally, xStreamBufferSendFromISR()
      + * will set *pxHigherPriorityTaskWoken to pdTRUE.  If
      + * xStreamBufferSendFromISR() sets this value to pdTRUE, then normally a
      + * context switch should be performed before the interrupt is exited.  This will
      + * ensure that the interrupt returns directly to the highest priority Ready
      + * state task.  *pxHigherPriorityTaskWoken should be set to pdFALSE before it
      + * is passed into the function.  See the example code below for an example.
      + *
      + * @return The number of bytes actually written to the stream buffer, which will
      + * be less than xDataLengthBytes if the stream buffer didn't have enough free
      + * space for all the bytes to be written.
      + *
      + * Example use:
      +
      +// A stream buffer that has already been created.
      +StreamBufferHandle_t xStreamBuffer;
      +
      +void vAnInterruptServiceRoutine( void )
      +{
      +size_t xBytesSent;
      +char *pcStringToSend = "String to send";
      +BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE.
      +
      +    // Attempt to send the string to the stream buffer.
      +    xBytesSent = xStreamBufferSendFromISR( xStreamBuffer,
      +                                           ( void * ) pcStringToSend,
      +                                           strlen( pcStringToSend ),
      +                                           &xHigherPriorityTaskWoken );
      +
      +    if( xBytesSent != strlen( pcStringToSend ) )
      +    {
      +        // There was not enough free space in the stream buffer for the entire
      +        // string to be written, ut xBytesSent bytes were written.
      +    }
      +
      +    // If xHigherPriorityTaskWoken was set to pdTRUE inside
      +    // xStreamBufferSendFromISR() then a task that has a priority above the
      +    // priority of the currently executing task was unblocked and a context
      +    // switch should be performed to ensure the ISR returns to the unblocked
      +    // task.  In most FreeRTOS ports this is done by simply passing
      +    // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the
      +    // variables value, and perform the context switch if necessary.  Check the
      +    // documentation for the port in use for port specific instructions.
      +    taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
      +}
      +
      + * \defgroup xStreamBufferSendFromISR xStreamBufferSendFromISR + * \ingroup StreamBufferManagement + */ +size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, + const void *pvTxData, + size_t xDataLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
      +                             void *pvRxData,
      +                             size_t xBufferLengthBytes,
      +                             TickType_t xTicksToWait );
      +
      + * + * Receives bytes from a stream buffer. + * + * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer + * implementation (so also the message buffer implementation, as message buffers + * are built on top of stream buffers) assumes there is only one task or + * interrupt that will write to the buffer (the writer), and only one task or + * interrupt that will read from the buffer (the reader). It is safe for the + * writer and reader to be different tasks or interrupts, but, unlike other + * FreeRTOS objects, it is not safe to have multiple different writers or + * multiple different readers. If there are to be multiple different writers + * then the application writer must place each call to a writing API function + * (such as xStreamBufferSend()) inside a critical section and set the send + * block time to 0. Likewise, if there are to be multiple different readers + * then the application writer must place each call to a reading API function + * (such as xStreamBufferRead()) inside a critical section and set the receive + * block time to 0. + * + * Use xStreamBufferReceive() to read from a stream buffer from a task. Use + * xStreamBufferReceiveFromISR() to read from a stream buffer from an + * interrupt service routine (ISR). + * + * @param xStreamBuffer The handle of the stream buffer from which bytes are to + * be received. + * + * @param pvRxData A pointer to the buffer into which the received bytes will be + * copied. + * + * @param xBufferLengthBytes The length of the buffer pointed to by the + * pvRxData parameter. This sets the maximum number of bytes to receive in one + * call. xStreamBufferReceive will return as many bytes as possible up to a + * maximum set by xBufferLengthBytes. + * + * @param xTicksToWait The maximum amount of time the task should remain in the + * Blocked state to wait for data to become available if the stream buffer is + * empty. xStreamBufferReceive() will return immediately if xTicksToWait is + * zero. The block time is specified in tick periods, so the absolute time it + * represents is dependent on the tick frequency. The macro pdMS_TO_TICKS() can + * be used to convert a time specified in milliseconds into a time specified in + * ticks. Setting xTicksToWait to portMAX_DELAY will cause the task to wait + * indefinitely (without timing out), provided INCLUDE_vTaskSuspend is set to 1 + * in FreeRTOSConfig.h. A task does not use any CPU time when it is in the + * Blocked state. + * + * @return The number of bytes actually read from the stream buffer, which will + * be less than xBufferLengthBytes if the call to xStreamBufferReceive() timed + * out before xBufferLengthBytes were available. + * + * Example use: +
      +void vAFunction( StreamBuffer_t xStreamBuffer )
      +{
      +uint8_t ucRxData[ 20 ];
      +size_t xReceivedBytes;
      +const TickType_t xBlockTime = pdMS_TO_TICKS( 20 );
      +
      +    // Receive up to another sizeof( ucRxData ) bytes from the stream buffer.
      +    // Wait in the Blocked state (so not using any CPU processing time) for a
      +    // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be
      +    // available.
      +    xReceivedBytes = xStreamBufferReceive( xStreamBuffer,
      +                                           ( void * ) ucRxData,
      +                                           sizeof( ucRxData ),
      +                                           xBlockTime );
      +
      +    if( xReceivedBytes > 0 )
      +    {
      +        // A ucRxData contains another xRecievedBytes bytes of data, which can
      +        // be processed here....
      +    }
      +}
      +
      + * \defgroup xStreamBufferReceive xStreamBufferReceive + * \ingroup StreamBufferManagement + */ +size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + void *pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
      +                                    void *pvRxData,
      +                                    size_t xBufferLengthBytes,
      +                                    BaseType_t *pxHigherPriorityTaskWoken );
      +
      + * + * An interrupt safe version of the API function that receives bytes from a + * stream buffer. + * + * Use xStreamBufferReceive() to read bytes from a stream buffer from a task. + * Use xStreamBufferReceiveFromISR() to read bytes from a stream buffer from an + * interrupt service routine (ISR). + * + * @param xStreamBuffer The handle of the stream buffer from which a stream + * is being received. + * + * @param pvRxData A pointer to the buffer into which the received bytes are + * copied. + * + * @param xBufferLengthBytes The length of the buffer pointed to by the + * pvRxData parameter. This sets the maximum number of bytes to receive in one + * call. xStreamBufferReceive will return as many bytes as possible up to a + * maximum set by xBufferLengthBytes. + * + * @param pxHigherPriorityTaskWoken It is possible that a stream buffer will + * have a task blocked on it waiting for space to become available. Calling + * xStreamBufferReceiveFromISR() can make space available, and so cause a task + * that is waiting for space to leave the Blocked state. If calling + * xStreamBufferReceiveFromISR() causes a task to leave the Blocked state, and + * the unblocked task has a priority higher than the currently executing task + * (the task that was interrupted), then, internally, + * xStreamBufferReceiveFromISR() will set *pxHigherPriorityTaskWoken to pdTRUE. + * If xStreamBufferReceiveFromISR() sets this value to pdTRUE, then normally a + * context switch should be performed before the interrupt is exited. That will + * ensure the interrupt returns directly to the highest priority Ready state + * task. *pxHigherPriorityTaskWoken should be set to pdFALSE before it is + * passed into the function. See the code example below for an example. + * + * @return The number of bytes read from the stream buffer, if any. + * + * Example use: +
      +// A stream buffer that has already been created.
      +StreamBuffer_t xStreamBuffer;
      +
      +void vAnInterruptServiceRoutine( void )
      +{
      +uint8_t ucRxData[ 20 ];
      +size_t xReceivedBytes;
      +BaseType_t xHigherPriorityTaskWoken = pdFALSE;  // Initialised to pdFALSE.
      +
      +    // Receive the next stream from the stream buffer.
      +    xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer,
      +                                                  ( void * ) ucRxData,
      +                                                  sizeof( ucRxData ),
      +                                                  &xHigherPriorityTaskWoken );
      +
      +    if( xReceivedBytes > 0 )
      +    {
      +        // ucRxData contains xReceivedBytes read from the stream buffer.
      +        // Process the stream here....
      +    }
      +
      +    // If xHigherPriorityTaskWoken was set to pdTRUE inside
      +    // xStreamBufferReceiveFromISR() then a task that has a priority above the
      +    // priority of the currently executing task was unblocked and a context
      +    // switch should be performed to ensure the ISR returns to the unblocked
      +    // task.  In most FreeRTOS ports this is done by simply passing
      +    // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the
      +    // variables value, and perform the context switch if necessary.  Check the
      +    // documentation for the port in use for port specific instructions.
      +    taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
      +}
      +
      + * \defgroup xStreamBufferReceiveFromISR xStreamBufferReceiveFromISR + * \ingroup StreamBufferManagement + */ +size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, + void *pvRxData, + size_t xBufferLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer );
      +
      + * + * Deletes a stream buffer that was previously created using a call to + * xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream + * buffer was created using dynamic memory (that is, by xStreamBufferCreate()), + * then the allocated memory is freed. + * + * A stream buffer handle must not be used after the stream buffer has been + * deleted. + * + * @param xStreamBuffer The handle of the stream buffer to be deleted. + * + * \defgroup vStreamBufferDelete vStreamBufferDelete + * \ingroup StreamBufferManagement + */ +void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer );
      +
      + * + * Queries a stream buffer to see if it is full. A stream buffer is full if it + * does not have any free space, and therefore cannot accept any more data. + * + * @param xStreamBuffer The handle of the stream buffer being queried. + * + * @return If the stream buffer is full then pdTRUE is returned. Otherwise + * pdFALSE is returned. + * + * \defgroup xStreamBufferIsFull xStreamBufferIsFull + * \ingroup StreamBufferManagement + */ +BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer );
      +
      + * + * Queries a stream buffer to see if it is empty. A stream buffer is empty if + * it does not contain any data. + * + * @param xStreamBuffer The handle of the stream buffer being queried. + * + * @return If the stream buffer is empty then pdTRUE is returned. Otherwise + * pdFALSE is returned. + * + * \defgroup xStreamBufferIsEmpty xStreamBufferIsEmpty + * \ingroup StreamBufferManagement + */ +BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer );
      +
      + * + * Resets a stream buffer to its initial, empty, state. Any data that was in + * the stream buffer is discarded. A stream buffer can only be reset if there + * are no tasks blocked waiting to either send to or receive from the stream + * buffer. + * + * @param xStreamBuffer The handle of the stream buffer being reset. + * + * @return If the stream buffer is reset then pdPASS is returned. If there was + * a task blocked waiting to send to or read from the stream buffer then the + * stream buffer is not reset and pdFAIL is returned. + * + * \defgroup xStreamBufferReset xStreamBufferReset + * \ingroup StreamBufferManagement + */ +BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer );
      +
      + * + * Queries a stream buffer to see how much free space it contains, which is + * equal to the amount of data that can be sent to the stream buffer before it + * is full. + * + * @param xStreamBuffer The handle of the stream buffer being queried. + * + * @return The number of bytes that can be written to the stream buffer before + * the stream buffer would be full. + * + * \defgroup xStreamBufferSpacesAvailable xStreamBufferSpacesAvailable + * \ingroup StreamBufferManagement + */ +size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer );
      +
      + * + * Queries a stream buffer to see how much data it contains, which is equal to + * the number of bytes that can be read from the stream buffer before the stream + * buffer would be empty. + * + * @param xStreamBuffer The handle of the stream buffer being queried. + * + * @return The number of bytes that can be read from the stream buffer before + * the stream buffer would be empty. + * + * \defgroup xStreamBufferBytesAvailable xStreamBufferBytesAvailable + * \ingroup StreamBufferManagement + */ +size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel );
      +
      + * + * A stream buffer's trigger level is the number of bytes that must be in the + * stream buffer before a task that is blocked on the stream buffer to + * wait for data is moved out of the blocked state. For example, if a task is + * blocked on a read of an empty stream buffer that has a trigger level of 1 + * then the task will be unblocked when a single byte is written to the buffer + * or the task's block time expires. As another example, if a task is blocked + * on a read of an empty stream buffer that has a trigger level of 10 then the + * task will not be unblocked until the stream buffer contains at least 10 bytes + * or the task's block time expires. If a reading task's block time expires + * before the trigger level is reached then the task will still receive however + * many bytes are actually available. Setting a trigger level of 0 will result + * in a trigger level of 1 being used. It is not valid to specify a trigger + * level that is greater than the buffer size. + * + * A trigger level is set when the stream buffer is created, and can be modified + * using xStreamBufferSetTriggerLevel(). + * + * @param xStreamBuffer The handle of the stream buffer being updated. + * + * @param xTriggerLevel The new trigger level for the stream buffer. + * + * @return If xTriggerLevel was less than or equal to the stream buffer's length + * then the trigger level will be updated and pdTRUE is returned. Otherwise + * pdFALSE is returned. + * + * \defgroup xStreamBufferSetTriggerLevel xStreamBufferSetTriggerLevel + * \ingroup StreamBufferManagement + */ +BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
      +
      + * + * For advanced users only. + * + * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when + * data is sent to a message buffer or stream buffer. If there was a task that + * was blocked on the message or stream buffer waiting for data to arrive then + * the sbSEND_COMPLETED() macro sends a notification to the task to remove it + * from the Blocked state. xStreamBufferSendCompletedFromISR() does the same + * thing. It is provided to enable application writers to implement their own + * version of sbSEND_COMPLETED(), and MUST NOT BE USED AT ANY OTHER TIME. + * + * See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for + * additional information. + * + * @param xStreamBuffer The handle of the stream buffer to which data was + * written. + * + * @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be + * initialised to pdFALSE before it is passed into + * xStreamBufferSendCompletedFromISR(). If calling + * xStreamBufferSendCompletedFromISR() removes a task from the Blocked state, + * and the task has a priority above the priority of the currently running task, + * then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a + * context switch should be performed before exiting the ISR. + * + * @return If a task was removed from the Blocked state then pdTRUE is returned. + * Otherwise pdFALSE is returned. + * + * \defgroup xStreamBufferSendCompletedFromISR xStreamBufferSendCompletedFromISR + * \ingroup StreamBufferManagement + */ +BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/** + * stream_buffer.h + * +
      +BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
      +
      + * + * For advanced users only. + * + * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when + * data is read out of a message buffer or stream buffer. If there was a task + * that was blocked on the message or stream buffer waiting for data to arrive + * then the sbRECEIVE_COMPLETED() macro sends a notification to the task to + * remove it from the Blocked state. xStreamBufferReceiveCompletedFromISR() + * does the same thing. It is provided to enable application writers to + * implement their own version of sbRECEIVE_COMPLETED(), and MUST NOT BE USED AT + * ANY OTHER TIME. + * + * See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for + * additional information. + * + * @param xStreamBuffer The handle of the stream buffer from which data was + * read. + * + * @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be + * initialised to pdFALSE before it is passed into + * xStreamBufferReceiveCompletedFromISR(). If calling + * xStreamBufferReceiveCompletedFromISR() removes a task from the Blocked state, + * and the task has a priority above the priority of the currently running task, + * then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a + * context switch should be performed before exiting the ISR. + * + * @return If a task was removed from the Blocked state then pdTRUE is returned. + * Otherwise pdFALSE is returned. + * + * \defgroup xStreamBufferReceiveCompletedFromISR xStreamBufferReceiveCompletedFromISR + * \ingroup StreamBufferManagement + */ +BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/* Functions below here are not part of the public API. */ +StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; + +StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; + +#if( configUSE_TRACE_FACILITY == 1 ) + void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; +#endif + +#if defined( __cplusplus ) +extern "C" { +#endif + +#endif /* !defined( STREAM_BUFFER_H ) */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/task.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/task.h similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/task.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/task.h index cf312f3..ca6866e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/task.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/task.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef INC_TASK_H @@ -85,10 +44,10 @@ extern "C" { * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V8.2.1" -#define tskKERNEL_VERSION_MAJOR 8 -#define tskKERNEL_VERSION_MINOR 2 -#define tskKERNEL_VERSION_BUILD 1 +#define tskKERNEL_VERSION_NUMBER "V9.0.0" +#define tskKERNEL_VERSION_MAJOR 9 +#define tskKERNEL_VERSION_MINOR 0 +#define tskKERNEL_VERSION_BUILD 0 /** * task. h @@ -115,7 +74,8 @@ typedef enum eReady, /* The task being queried is in a read or pending ready list. */ eBlocked, /* The task being queried is in the Blocked state. */ eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ - eDeleted /* The task being queried has been deleted, but its TCB has not yet been freed. */ + eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */ + eInvalid /* Used as an 'invalid state' value. */ } eTaskState; /* Actions that can be performed when vTaskNotify() is called. */ @@ -159,6 +119,9 @@ typedef struct xTASK_PARAMETERS UBaseType_t uxPriority; StackType_t *puxStackBuffer; MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; + #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + StaticTask_t * const pxTaskBuffer; + #endif } TaskParameters_t; /* Used with the uxTaskGetSystemState() function to return the state of each task @@ -172,6 +135,7 @@ typedef struct xTASK_STATUS UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ + StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */ uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ } TaskStatus_t; @@ -183,7 +147,6 @@ typedef enum eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ } eSleepModeStatus; - /** * Defines the priority used by the idle task. This must not be modified. * @@ -214,7 +177,7 @@ typedef enum * \ingroup SchedulerControl */ #define taskENTER_CRITICAL() portENTER_CRITICAL() -#define taskENTER_CRITICAL_FROM_ISR( x ) portSET_INTERRUPT_MASK_FROM_ISR( x ) +#define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() /** * task. h @@ -229,7 +192,7 @@ typedef enum * \ingroup SchedulerControl */ #define taskEXIT_CRITICAL() portEXIT_CRITICAL() -#define taskEXIT_CRITICAL_FROM_ISR() portCLEAR_INTERRUPT_MASK_FROM_ISR() +#define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) /** * task. h * @@ -268,7 +231,7 @@ is used in assert() statements. */ BaseType_t xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, - uint16_t usStackDepth, + configSTACK_DEPTH_TYPE usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pvCreatedTask @@ -276,6 +239,19 @@ is used in assert() statements. */ * * Create a new task and add it to the list of tasks that are ready to run. * + * Internally, within the FreeRTOS implementation, tasks use two blocks of + * memory. The first block is used to hold the task's data structures. The + * second block is used by the task as its stack. If a task is created using + * xTaskCreate() then both blocks of memory are automatically dynamically + * allocated inside the xTaskCreate() function. (see + * http://www.freertos.org/a00111.html). If a task is created using + * xTaskCreateStatic() then the application writer must provide the required + * memory. xTaskCreateStatic() therefore allows a task to be created without + * using any dynamic memory allocation. + * + * See xTaskCreateStatic() for a version that does not use any dynamic memory + * allocation. + * * xTaskCreate() can only be used to create a task that has unrestricted * access to the entire microcontroller memory map. Systems that include MPU * support can alternatively create an MPU constrained task using @@ -313,7 +289,7 @@ is used in assert() statements. */ // Task to be created. void vTaskCode( void * pvParameters ) { - for ( ;; ) + for( ;; ) { // Task code goes here. } @@ -333,7 +309,7 @@ is used in assert() statements. */ configASSERT( xHandle ); // Use the handle to delete the task. - if ( xHandle != NULL ) + if( xHandle != NULL ) { vTaskDelete( xHandle ); } @@ -342,13 +318,139 @@ is used in assert() statements. */ * \defgroup xTaskCreate xTaskCreate * \ingroup Tasks */ -#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) ) +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + BaseType_t xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const configSTACK_DEPTH_TYPE usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION; +#endif + +/** + * task. h + *
      + TaskHandle_t xTaskCreateStatic( TaskFunction_t pvTaskCode,
      +								 const char * const pcName,
      +								 uint32_t ulStackDepth,
      +								 void *pvParameters,
      +								 UBaseType_t uxPriority,
      +								 StackType_t *pxStackBuffer,
      +								 StaticTask_t *pxTaskBuffer );
      + * + * Create a new task and add it to the list of tasks that are ready to run. + * + * Internally, within the FreeRTOS implementation, tasks use two blocks of + * memory. The first block is used to hold the task's data structures. The + * second block is used by the task as its stack. If a task is created using + * xTaskCreate() then both blocks of memory are automatically dynamically + * allocated inside the xTaskCreate() function. (see + * http://www.freertos.org/a00111.html). If a task is created using + * xTaskCreateStatic() then the application writer must provide the required + * memory. xTaskCreateStatic() therefore allows a task to be created without + * using any dynamic memory allocation. + * + * @param pvTaskCode Pointer to the task entry function. Tasks + * must be implemented to never return (i.e. continuous loop). + * + * @param pcName A descriptive name for the task. This is mainly used to + * facilitate debugging. The maximum length of the string is defined by + * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h. + * + * @param ulStackDepth The size of the task stack specified as the number of + * variables the stack can hold - not the number of bytes. For example, if + * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes + * will be allocated for stack storage. + * + * @param pvParameters Pointer that will be used as the parameter for the task + * being created. + * + * @param uxPriority The priority at which the task will run. + * + * @param pxStackBuffer Must point to a StackType_t array that has at least + * ulStackDepth indexes - the array will then be used as the task's stack, + * removing the need for the stack to be allocated dynamically. + * + * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will + * then be used to hold the task's data structures, removing the need for the + * memory to be allocated dynamically. + * + * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will + * be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer + * are NULL then the task will not be created and + * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned. + * + * Example usage: +
      +
      +    // Dimensions the buffer that the task being created will use as its stack.
      +    // NOTE:  This is the number of words the stack will hold, not the number of
      +    // bytes.  For example, if each stack item is 32-bits, and this is set to 100,
      +    // then 400 bytes (100 * 32-bits) will be allocated.
      +    #define STACK_SIZE 200
      +
      +    // Structure that will hold the TCB of the task being created.
      +    StaticTask_t xTaskBuffer;
      +
      +    // Buffer that the task being created will use as its stack.  Note this is
      +    // an array of StackType_t variables.  The size of StackType_t is dependent on
      +    // the RTOS port.
      +    StackType_t xStack[ STACK_SIZE ];
      +
      +    // Function that implements the task being created.
      +    void vTaskCode( void * pvParameters )
      +    {
      +        // The parameter value is expected to be 1 as 1 is passed in the
      +        // pvParameters value in the call to xTaskCreateStatic().
      +        configASSERT( ( uint32_t ) pvParameters == 1UL );
      +
      +        for( ;; )
      +        {
      +            // Task code goes here.
      +        }
      +    }
      +
      +    // Function that creates a task.
      +    void vOtherFunction( void )
      +    {
      +        TaskHandle_t xHandle = NULL;
      +
      +        // Create the task without using any dynamic memory allocation.
      +        xHandle = xTaskCreateStatic(
      +                      vTaskCode,       // Function that implements the task.
      +                      "NAME",          // Text name for the task.
      +                      STACK_SIZE,      // Stack size in words, not bytes.
      +                      ( void * ) 1,    // Parameter passed into the task.
      +                      tskIDLE_PRIORITY,// Priority at which the task is created.
      +                      xStack,          // Array to use as the task's stack.
      +                      &xTaskBuffer );  // Variable to hold the task's data structure.
      +
      +        // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
      +        // been created, and xHandle will be the task's handle.  Use the handle
      +        // to suspend the task.
      +        vTaskSuspend( xHandle );
      +    }
      +   
      + * \defgroup xTaskCreateStatic xTaskCreateStatic + * \ingroup Tasks + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const puxStackBuffer, + StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION; +#endif /* configSUPPORT_STATIC_ALLOCATION */ /** * task. h *
        BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
      * + * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1. + * * xTaskCreateRestricted() should only be used in systems that include an MPU * implementation. * @@ -356,6 +458,9 @@ is used in assert() statements. */ * The function parameters define the memory regions and associated access * permissions allocated to the task. * + * See xTaskCreateRestrictedStatic() for a version that does not use any + * dynamic memory allocation. + * * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region @@ -405,13 +510,103 @@ TaskHandle_t xHandle; // Will only get here if there was insufficient memory to create the idle // and/or timer task. - for ( ;; ); + for( ;; ); }
      * \defgroup xTaskCreateRestricted xTaskCreateRestricted * \ingroup Tasks */ -#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) ) +#if( portUSING_MPU_WRAPPERS == 1 ) + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) PRIVILEGED_FUNCTION; +#endif + +/** + * task. h + *
      + BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
      + * + * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1. + * + * xTaskCreateRestrictedStatic() should only be used in systems that include an + * MPU implementation. + * + * Internally, within the FreeRTOS implementation, tasks use two blocks of + * memory. The first block is used to hold the task's data structures. The + * second block is used by the task as its stack. If a task is created using + * xTaskCreateRestricted() then the stack is provided by the application writer, + * and the memory used to hold the task's data structure is automatically + * dynamically allocated inside the xTaskCreateRestricted() function. If a task + * is created using xTaskCreateRestrictedStatic() then the application writer + * must provide the memory used to hold the task's data structures too. + * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be + * created without using any dynamic memory allocation. + * + * @param pxTaskDefinition Pointer to a structure that contains a member + * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API + * documentation) plus an optional stack buffer and the memory region + * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure + * contains an additional member, which is used to point to a variable of type + * StaticTask_t - which is then used to hold the task's data structure. + * + * @param pxCreatedTask Used to pass back a handle by which the created task + * can be referenced. + * + * @return pdPASS if the task was successfully created and added to a ready + * list, otherwise an error code defined in the file projdefs.h + * + * Example usage: +
      +// Create an TaskParameters_t structure that defines the task to be created.
      +// The StaticTask_t variable is only included in the structure when
      +// configSUPPORT_STATIC_ALLOCATION is set to 1.  The PRIVILEGED_DATA macro can
      +// be used to force the variable into the RTOS kernel's privileged data area.
      +static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
      +static const TaskParameters_t xCheckTaskParameters =
      +{
      +	vATask,		// pvTaskCode - the function that implements the task.
      +	"ATask",	// pcName - just a text name for the task to assist debugging.
      +	100,		// usStackDepth	- the stack size DEFINED IN WORDS.
      +	NULL,		// pvParameters - passed into the task function as the function parameters.
      +	( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
      +	cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
      +
      +	// xRegions - Allocate up to three separate memory regions for access by
      +	// the task, with appropriate access permissions.  Different processors have
      +	// different memory alignment requirements - refer to the FreeRTOS documentation
      +	// for full information.
      +	{
      +		// Base address					Length	Parameters
      +        { cReadWriteArray,				32,		portMPU_REGION_READ_WRITE },
      +        { cReadOnlyArray,				32,		portMPU_REGION_READ_ONLY },
      +        { cPrivilegedOnlyAccessArray,	128,	portMPU_REGION_PRIVILEGED_READ_WRITE }
      +	}
      +
      +	&xTaskBuffer; // Holds the task's data structure.
      +};
      +
      +int main( void )
      +{
      +TaskHandle_t xHandle;
      +
      +	// Create a task from the const structure defined above.  The task handle
      +	// is requested (the second parameter is not NULL) but in this case just for
      +	// demonstration purposes as its not actually used.
      +	xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
      +
      +	// Start the scheduler.
      +	vTaskStartScheduler();
      +
      +	// Will only get here if there was insufficient memory to create the idle
      +	// and/or timer task.
      +	for( ;; );
      +}
      +   
      + * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic + * \ingroup Tasks + */ +#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) PRIVILEGED_FUNCTION; +#endif /** * task. h @@ -541,7 +736,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; // Block for 500ms. const TickType_t xDelay = 500 / portTICK_PERIOD_MS; - for ( ;; ) + for( ;; ) { // Simply toggle the LED every 500ms, blocking between each toggle. vToggleLED(); @@ -599,7 +794,7 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; // Initialise the xLastWakeTime variable with the current time. xLastWakeTime = xTaskGetTickCount (); - for ( ;; ) + for( ;; ) { // Wait for the next cycle. vTaskDelayUntil( &xLastWakeTime, xFrequency ); @@ -613,6 +808,31 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; */ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; +/** + * task. h + *
      BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
      + * + * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this + * function to be available. + * + * A task will enter the Blocked state when it is waiting for an event. The + * event it is waiting for can be a temporal event (waiting for a time), such + * as when vTaskDelay() is called, or an event on an object, such as when + * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task + * that is in the Blocked state is used in a call to xTaskAbortDelay() then the + * task will leave the Blocked state, and return from whichever function call + * placed the task into the Blocked state. + * + * @param xTask The handle of the task to remove from the Blocked state. + * + * @return If the task referenced by xTask was not in the Blocked state then + * pdFAIL is returned. Otherwise pdPASS is returned. + * + * \defgroup xTaskAbortDelay xTaskAbortDelay + * \ingroup TaskCtrl + */ +BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + /** * task. h *
      UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );
      @@ -641,7 +861,7 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT // Use the handle to obtain the priority of the created task. // It was created with tskIDLE_PRIORITY, but may have changed // it itself. - if ( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY ) + if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY ) { // The task has changed it's priority. } @@ -649,7 +869,7 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT // ... // Is our priority higher than the created task? - if ( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) ) + if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) ) { // Our priority (obtained using NULL handle) is higher. } @@ -686,6 +906,62 @@ UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; */ eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; +/** + * task. h + *
      void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
      + * + * configUSE_TRACE_FACILITY must be defined as 1 for this function to be + * available. See the configuration section for more information. + * + * Populates a TaskStatus_t structure with information about a task. + * + * @param xTask Handle of the task being queried. If xTask is NULL then + * information will be returned about the calling task. + * + * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be + * filled with information about the task referenced by the handle passed using + * the xTask parameter. + * + * @xGetFreeStackSpace The TaskStatus_t structure contains a member to report + * the stack high water mark of the task being queried. Calculating the stack + * high water mark takes a relatively long time, and can make the system + * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to + * allow the high water mark checking to be skipped. The high watermark value + * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is + * not set to pdFALSE; + * + * @param eState The TaskStatus_t structure contains a member to report the + * state of the task being queried. Obtaining the task state is not as fast as + * a simple assignment - so the eState parameter is provided to allow the state + * information to be omitted from the TaskStatus_t structure. To obtain state + * information then set eState to eInvalid - otherwise the value passed in + * eState will be reported as the task state in the TaskStatus_t structure. + * + * Example usage: +
      + void vAFunction( void )
      + {
      + TaskHandle_t xHandle;
      + TaskStatus_t xTaskDetails;
      +
      +    // Obtain the handle of a task from its name.
      +    xHandle = xTaskGetHandle( "Task_Name" );
      +
      +    // Check the handle is not NULL.
      +    configASSERT( xHandle );
      +
      +    // Use the handle to obtain further information about the task.
      +    vTaskGetInfo( xHandle,
      +                  &xTaskDetails,
      +                  pdTRUE, // Include the high water mark in xTaskDetails.
      +                  eInvalid ); // Include the task state in xTaskDetails.
      + }
      +   
      + * \defgroup vTaskGetInfo vTaskGetInfo + * \ingroup TaskCtrl + */ +void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION; + /** * task. h *
      void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
      @@ -917,7 +1193,7 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
        void vTaskCode( void * pvParameters )
        {
      -	 for ( ;; )
      +	 for( ;; )
       	 {
       		 // Task code goes here.
       
      @@ -965,7 +1241,7 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
          
        void vTask1( void * pvParameters )
        {
      -	 for ( ;; )
      +	 for( ;; )
       	 {
       		 // Task code goes here.
       
      @@ -1014,7 +1290,7 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
          
        void vTask1( void * pvParameters )
        {
      -	 for ( ;; )
      +	 for( ;; )
       	 {
       		 // Task code goes here.
       
      @@ -1039,7 +1315,7 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
       		 // The operation is complete.  Restart the kernel.  We want to force
       		 // a context switch - but there is no point if resuming the scheduler
       		 // caused a context switch already.
      -		 if ( !xTaskResumeAll () )
      +		 if( !xTaskResumeAll () )
       		 {
       			  taskYIELD ();
       		 }
      @@ -1098,17 +1374,32 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
       
       /**
        * task. h
      - * 
      char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery );
      + *
      char *pcTaskGetName( TaskHandle_t xTaskToQuery );
      * * @return The text (human readable) name of the task referenced by the handle * xTaskToQuery. A task can query its own name by either passing in its own - * handle, or by setting xTaskToQuery to NULL. INCLUDE_pcTaskGetTaskName must be - * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available. + * handle, or by setting xTaskToQuery to NULL. * - * \defgroup pcTaskGetTaskName pcTaskGetTaskName + * \defgroup pcTaskGetName pcTaskGetName * \ingroup TaskUtils */ -char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * task. h + *
      TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
      + * + * NOTE: This function takes a relatively long time to complete and should be + * used sparingly. + * + * @return The handle of the task that has the human readable name pcNameToQuery. + * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle + * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available. + * + * \defgroup pcTaskGetHandle pcTaskGetHandle + * \ingroup TaskUtils + */ +TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * task.h @@ -1159,15 +1450,15 @@ constant. */ #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ #endif /* ifdef configUSE_APPLICATION_TASK_TAG */ -#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) +#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) /* Each task contains an array of pointers that is dimensioned by the configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The kernel does not use the pointers itself, so the application writer can use the pointers for any purpose they wish. The following two functions are used to set and query a pointer respectively. */ - void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ); - void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ); + void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION; + void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION; #endif @@ -1191,7 +1482,7 @@ BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) * Simply returns the handle of the idle task. It is not valid to call * xTaskGetIdleTaskHandle() before the scheduler has been started. */ -TaskHandle_t xTaskGetIdleTaskHandle( void ); +TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; /** * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for @@ -1249,7 +1540,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ); // allocated statically at compile time. pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) ); - if ( pxTaskStatusArray != NULL ) + if( pxTaskStatusArray != NULL ) { // Generate raw status information about each task. uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime ); @@ -1258,18 +1549,18 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ); ulTotalRunTime /= 100UL; // Avoid divide by zero errors. - if ( ulTotalRunTime > 0 ) + if( ulTotalRunTime > 0 ) { // For each populated position in the pxTaskStatusArray array, // format the raw data as human readable ASCII data - for ( x = 0; x < uxArraySize; x++ ) + for( x = 0; x < uxArraySize; x++ ) { // What percentage of the total run time has the task used? // This will always be rounded down to the nearest integer. // ulTotalRunTimeDiv100 has already been divided by 100. ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime; - if ( ulStatsAsPercentage > 0UL ) + if( ulStatsAsPercentage > 0UL ) { sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); } @@ -1290,7 +1581,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ); }
      */ -UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ); +UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; /** * task. h @@ -1437,30 +1728,30 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9 * @param eAction Specifies how the notification updates the task's notification * value, if at all. Valid values for eAction are as follows: * - * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() - * always returns pdPASS in this case. + * eSetBits - + * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * always returns pdPASS in this case. * - * eIncrement - - * The task's notification value is incremented. ulValue is not used and - * xTaskNotify() always returns pdPASS in this case. + * eIncrement - + * The task's notification value is incremented. ulValue is not used and + * xTaskNotify() always returns pdPASS in this case. * - * eSetValueWithOverwrite - - * The task's notification value is set to the value of ulValue, even if the - * task being notified had not yet processed the previous notification (the - * task already had a notification pending). xTaskNotify() always returns - * pdPASS in this case. + * eSetValueWithOverwrite - + * The task's notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification (the + * task already had a notification pending). xTaskNotify() always returns + * pdPASS in this case. * - * eSetValueWithoutOverwrite - - * If the task being notified did not already have a notification pending then - * the task's notification value is set to ulValue and xTaskNotify() will - * return pdPASS. If the task being notified already had a notification - * pending then no action is performed and pdFAIL is returned. + * eSetValueWithoutOverwrite - + * If the task being notified did not already have a notification pending then + * the task's notification value is set to ulValue and xTaskNotify() will + * return pdPASS. If the task being notified already had a notification + * pending then no action is performed and pdFAIL is returned. * - * eNoAction - - * The task receives a notification without its notification value being - * updated. ulValue is not used and xTaskNotify() always returns pdPASS in - * this case. + * eNoAction - + * The task receives a notification without its notification value being + * updated. ulValue is not used and xTaskNotify() always returns pdPASS in + * this case. * * pulPreviousNotificationValue - * Can be used to pass out the subject task's notification value before any @@ -1472,7 +1763,7 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9 * \defgroup xTaskNotify xTaskNotify * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ); +BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) @@ -1523,30 +1814,30 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * @param eAction Specifies how the notification updates the task's notification * value, if at all. Valid values for eAction are as follows: * - * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() - * always returns pdPASS in this case. + * eSetBits - + * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * always returns pdPASS in this case. * - * eIncrement - - * The task's notification value is incremented. ulValue is not used and - * xTaskNotify() always returns pdPASS in this case. + * eIncrement - + * The task's notification value is incremented. ulValue is not used and + * xTaskNotify() always returns pdPASS in this case. * - * eSetValueWithOverwrite - - * The task's notification value is set to the value of ulValue, even if the - * task being notified had not yet processed the previous notification (the - * task already had a notification pending). xTaskNotify() always returns - * pdPASS in this case. + * eSetValueWithOverwrite - + * The task's notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification (the + * task already had a notification pending). xTaskNotify() always returns + * pdPASS in this case. * - * eSetValueWithoutOverwrite - - * If the task being notified did not already have a notification pending then - * the task's notification value is set to ulValue and xTaskNotify() will - * return pdPASS. If the task being notified already had a notification - * pending then no action is performed and pdFAIL is returned. + * eSetValueWithoutOverwrite - + * If the task being notified did not already have a notification pending then + * the task's notification value is set to ulValue and xTaskNotify() will + * return pdPASS. If the task being notified already had a notification + * pending then no action is performed and pdFAIL is returned. * - * eNoAction - - * The task receives a notification without its notification value being - * updated. ulValue is not used and xTaskNotify() always returns pdPASS in - * this case. + * eNoAction - + * The task receives a notification without its notification value being + * updated. ulValue is not used and xTaskNotify() always returns pdPASS in + * this case. * * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the @@ -1563,7 +1854,9 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * \defgroup xTaskNotify xTaskNotify * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); +BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) /** * task. h @@ -1638,7 +1931,7 @@ BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * \defgroup xTaskNotifyWait xTaskNotifyWait * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); +BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * task. h @@ -1684,7 +1977,7 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * \defgroup xTaskNotifyGive xTaskNotifyGive * \ingroup TaskNotifications */ -#define xTaskNotifyGive( xTaskToNotify ) xTaskNotify( ( xTaskToNotify ), 0, eIncrement ); +#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL ) /** * task. h @@ -1739,7 +2032,7 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * \defgroup xTaskNotifyWait xTaskNotifyWait * \ingroup TaskNotifications */ -void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ); +void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** * task. h @@ -1808,7 +2101,23 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri * \defgroup ulTaskNotifyTake ulTaskNotifyTake * \ingroup TaskNotifications */ -uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); +uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
      BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
      + * + * If the notification state of the task referenced by the handle xTask is + * eNotified, then set the task's notification state to eNotWaitingNotification. + * The task's notification value is not altered. Set xTask to NULL to clear the + * notification state of the calling task. + * + * @return pdTRUE if the task's notification state was set to + * eNotWaitingNotification, otherwise pdFALSE. + * \defgroup xTaskNotifyStateClear xTaskNotifyStateClear + * \ingroup TaskNotifications + */ +BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); /*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES @@ -1876,7 +2185,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte * indefinitely, whereas vTaskPlaceOnEventList() does. * */ -void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -1887,14 +2196,14 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType * Removes a task from both the specified event list and the list of blocked * tasks, and places it on a ready queue. * - * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called + * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called * if either an event occurs to unblock a task, or the block timeout period * expires. * * xTaskRemoveFromEventList() is used when the event list is in task priority * order. It removes the list item from the head of the event list as that will * have the highest priority owning task of all the tasks on the event list. - * xTaskRemoveFromUnorderedEventList() is used when the event list is not + * vTaskRemoveFromUnorderedEventList() is used when the event list is not * ordered and the event list items hold something other than the owning tasks * priority. In this case the event list item value is updated to the value * passed in the xItemValue parameter. @@ -1903,7 +2212,7 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType * making the call, otherwise pdFALSE. */ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; +void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY @@ -1953,7 +2262,7 @@ BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION; * Raises the priority of the mutex holder to that of the calling task should * the mutex holder have a priority less than the calling task. */ -void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; +BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; /* * Set the priority of a task back to its proper priority in the case that it @@ -1962,10 +2271,14 @@ void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTIO BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; /* - * Generic version of the task creation function which is in turn called by the - * xTaskCreate() and xTaskCreateRestricted() macros. + * If a higher priority task attempting to obtain a mutex caused a lower + * priority task to inherit the higher priority task's priority - but the higher + * priority task then timed out without obtaining the mutex, then the lower + * priority task will disinherit the priority again - but only down as far as + * the highest priority task that is still waiting for the mutex (if there were + * more than one task waiting for the mutex). */ -BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; /* * Get the uxTCBNumber assigned to the task referenced by the xTask parameter. @@ -2008,7 +2321,14 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION; * For internal use only. Increment the mutex held count when a mutex is * taken and return the handle of the task that has taken the mutex. */ -void *pvTaskIncrementMutexHeldCount( void ); +void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; + +/* + * For internal use only. Same as vTaskSetTimeOutState(), but without a critial + * section. + */ +void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; + #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/timers.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/timers.h similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/timers.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/timers.h index 7182ca3..084b15a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/include/timers.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/include/timers.h @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #ifndef TIMERS_H @@ -135,9 +94,17 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * void * pvTimerID, * TimerCallbackFunction_t pxCallbackFunction ); * - * Creates a new software timer instance. This allocates the storage required - * by the new timer, initialises the new timers internal state, and returns a - * handle by which the new timer can be referenced. + * Creates a new software timer instance, and returns a handle by which the + * created software timer can be referenced. + * + * Internally, within the FreeRTOS implementation, software timers use a block + * of memory, in which the timer data structure is stored. If a software timer + * is created using xTimerCreate() then the required memory is automatically + * dynamically allocated inside the xTimerCreate() function. (see + * http://www.freertos.org/a00111.html). If a software timer is created using + * xTimerCreateStatic() then the application writer must provide the memory that + * will get used by the software timer. xTimerCreateStatic() therefore allows a + * software timer to be created without using any dynamic memory allocation. * * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and @@ -204,7 +171,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * lExpireCounters[ lArrayIndex ] += 1; * * // If the timer has expired 10 times then stop it from running. - * if ( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) + * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) * { * // Do not use a block time if calling a timer API function from a * // timer callback function, as doing so could cause a deadlock! @@ -219,7 +186,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * // Create then start some timers. Starting the timers before the scheduler * // has been started means the timers will start running immediately that * // the scheduler starts. - * for ( x = 0; x < NUM_TIMERS; x++ ) + * for( x = 0; x < NUM_TIMERS; x++ ) * { * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel. * ( 100 * x ), // The timer period in ticks. @@ -228,7 +195,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * vTimerCallback // Each timer calls the same callback when it expires. * ); * - * if ( xTimers[ x ] == NULL ) + * if( xTimers[ x ] == NULL ) * { * // The timer was not created. * } @@ -237,7 +204,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * // Start the timer. No block time is specified, and even if one was * // it would be ignored because the scheduler has not yet been * // started. - * if ( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) + * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) * { * // The timer could not be set into the Active state. * } @@ -250,14 +217,151 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * // Starting the scheduler will start the timers running as they have already * // been set into the active state. - * xTaskStartScheduler(); + * vTaskStartScheduler(); + * + * // Should not reach here. + * for( ;; ); + * } + * @endverbatim + */ +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; +#endif + +/** + * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction, + * StaticTimer_t *pxTimerBuffer ); + * + * Creates a new software timer instance, and returns a handle by which the + * created software timer can be referenced. + * + * Internally, within the FreeRTOS implementation, software timers use a block + * of memory, in which the timer data structure is stored. If a software timer + * is created using xTimerCreate() then the required memory is automatically + * dynamically allocated inside the xTimerCreate() function. (see + * http://www.freertos.org/a00111.html). If a software timer is created using + * xTimerCreateStatic() then the application writer must provide the memory that + * will get used by the software timer. xTimerCreateStatic() therefore allows a + * software timer to be created without using any dynamic memory allocation. + * + * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), + * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and + * xTimerChangePeriodFromISR() API functions can all be used to transition a + * timer into the active state. + * + * @param pcTimerName A text name that is assigned to the timer. This is done + * purely to assist debugging. The kernel itself only ever references a timer + * by its handle, and never by its name. + * + * @param xTimerPeriodInTicks The timer period. The time is defined in tick + * periods so the constant portTICK_PERIOD_MS can be used to convert a time that + * has been specified in milliseconds. For example, if the timer must expire + * after 100 ticks, then xTimerPeriodInTicks should be set to 100. + * Alternatively, if the timer must expire after 500ms, then xPeriod can be set + * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or + * equal to 1000. + * + * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will + * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. + * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and + * enter the dormant state after it expires. + * + * @param pvTimerID An identifier that is assigned to the timer being created. + * Typically this would be used in the timer callback function to identify which + * timer expired when the same callback function is assigned to more than one + * timer. + * + * @param pxCallbackFunction The function to call when the timer expires. + * Callback functions must have the prototype defined by TimerCallbackFunction_t, + * which is "void vCallbackFunction( TimerHandle_t xTimer );". + * + * @param pxTimerBuffer Must point to a variable of type StaticTimer_t, which + * will be then be used to hold the software timer's data structures, removing + * the need for the memory to be allocated dynamically. + * + * @return If the timer is created then a handle to the created timer is + * returned. If pxTimerBuffer was NULL then NULL is returned. + * + * Example usage: + * @verbatim + * + * // The buffer used to hold the software timer's data structure. + * static StaticTimer_t xTimerBuffer; + * + * // A variable that will be incremented by the software timer's callback + * // function. + * UBaseType_t uxVariableToIncrement = 0; + * + * // A software timer callback function that increments a variable passed to + * // it when the software timer was created. After the 5th increment the + * // callback function stops the software timer. + * static void prvTimerCallback( TimerHandle_t xExpiredTimer ) + * { + * UBaseType_t *puxVariableToIncrement; + * BaseType_t xReturned; + * + * // Obtain the address of the variable to increment from the timer ID. + * puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer ); + * + * // Increment the variable to show the timer callback has executed. + * ( *puxVariableToIncrement )++; + * + * // If this callback has executed the required number of times, stop the + * // timer. + * if( *puxVariableToIncrement == 5 ) + * { + * // This is called from a timer callback so must not block. + * xTimerStop( xExpiredTimer, staticDONT_BLOCK ); + * } + * } + * + * + * void main( void ) + * { + * // Create the software time. xTimerCreateStatic() has an extra parameter + * // than the normal xTimerCreate() API function. The parameter is a pointer + * // to the StaticTimer_t structure that will hold the software timer + * // structure. If the parameter is passed as NULL then the structure will be + * // allocated dynamically, just as if xTimerCreate() had been called. + * xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS. + * xTimerPeriod, // The period of the timer in ticks. + * pdTRUE, // This is an auto-reload timer. + * ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function + * prvTimerCallback, // The function to execute when the timer expires. + * &xTimerBuffer ); // The buffer that will hold the software timer structure. + * + * // The scheduler has not started yet so a block time is not used. + * xReturned = xTimerStart( xTimer, 0 ); + * + * // ... + * // Create tasks here. + * // ... + * + * // Starting the scheduler will start the timers running as they have already + * // been set into the active state. + * vTaskStartScheduler(); * * // Should not reach here. - * for ( ;; ); + * for( ;; ); * } * @endverbatim */ -TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION; +#endif /* configSUPPORT_STATIC_ALLOCATION */ /** * void *pvTimerGetTimerID( TimerHandle_t xTimer ); @@ -279,7 +383,7 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi * * See the xTimerCreate() API function example usage scenario. */ -void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); @@ -300,7 +404,7 @@ void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * * See the xTimerCreate() API function example usage scenario. */ -void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; +void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; /** * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); @@ -326,7 +430,7 @@ void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FU * // This function assumes xTimer has already been created. * void vAFunction( TimerHandle_t xTimer ) * { - * if ( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if ( xTimerIsTimerActive( xTimer ) )" + * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" * { * // xTimer is active, do something. * } @@ -342,13 +446,10 @@ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * - * xTimerGetTimerDaemonTaskHandle() is only available if - * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h. - * * Simply returns the handle of the timer service/daemon task. It it not valid * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started. */ -TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); +TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; /** * BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait ); @@ -498,7 +599,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // started. * void vAFunction( TimerHandle_t xTimer ) * { - * if ( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if ( xTimerIsTimerActive( xTimer ) )" + * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" * { * // xTimer is already active - delete it. * xTimerDelete( xTimer ); @@ -509,7 +610,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // cause the timer to start. Block for a maximum of 100 ticks if the * // change period command cannot immediately be sent to the timer * // command queue. - * if ( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS ) + * if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS ) * { * // The command was successfully sent. * } @@ -634,7 +735,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // key inactivity. Wait 10 ticks for the command to be successfully sent * // if it cannot be sent immediately. * vSetBacklightState( BACKLIGHT_ON ); - * if ( xTimerReset( xBacklightTimer, 100 ) != pdPASS ) + * if( xTimerReset( xBacklightTimer, 100 ) != pdPASS ) * { * // The reset command was not executed successfully. Take appropriate * // action here. @@ -656,7 +757,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * vBacklightTimerCallback // The callback function that switches the LCD back-light off. * ); * - * if ( xBacklightTimer == NULL ) + * if( xBacklightTimer == NULL ) * { * // The timer was not created. * } @@ -665,7 +766,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // Start the timer. No block time is specified, and even if one was * // it would be ignored because the scheduler has not yet been * // started. - * if ( xTimerStart( xBacklightTimer, 0 ) != pdPASS ) + * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS ) * { * // The timer could not be set into the Active state. * } @@ -677,10 +778,10 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * * // Starting the scheduler will start the timer running as it has already * // been set into the active state. - * xTaskStartScheduler(); + * vTaskStartScheduler(); * * // Should not reach here. - * for ( ;; ); + * for( ;; ); * } * @endverbatim */ @@ -749,7 +850,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // as both cause the timer to re-calculate its expiry time. * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was * // declared (in this function). - * if ( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) * { * // The start command was not executed successfully. Take appropriate * // action here. @@ -762,7 +863,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // from inside an ISR varies from port to port, and from compiler to * // compiler. Inspect the demos for the port you are using to find the * // actual syntax required. - * if ( xHigherPriorityTaskWoken != pdFALSE ) + * if( xHigherPriorityTaskWoken != pdFALSE ) * { * // Call the interrupt safe yield function here (actual function * // depends on the FreeRTOS port being used). @@ -814,7 +915,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined * // (within this function). As this is an interrupt service routine, only * // FreeRTOS API functions that end in "FromISR" can be used. - * if ( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) * { * // The stop command was not executed successfully. Take appropriate * // action here. @@ -825,7 +926,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // from inside an ISR varies from port to port, and from compiler to * // compiler. Inspect the demos for the port you are using to find the * // actual syntax required. - * if ( xHigherPriorityTaskWoken != pdFALSE ) + * if( xHigherPriorityTaskWoken != pdFALSE ) * { * // Call the interrupt safe yield function here (actual function * // depends on the FreeRTOS port being used). @@ -887,7 +988,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined * // (within this function). As this is an interrupt service routine, only * // FreeRTOS API functions that end in "FromISR" can be used. - * if ( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) * { * // The command to change the timers period was not executed * // successfully. Take appropriate action here. @@ -898,7 +999,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // from inside an ISR varies from port to port, and from compiler to * // compiler. Inspect the demos for the port you are using to find the * // actual syntax required. - * if ( xHigherPriorityTaskWoken != pdFALSE ) + * if( xHigherPriorityTaskWoken != pdFALSE ) * { * // Call the interrupt safe yield function here (actual function * // depends on the FreeRTOS port being used). @@ -971,7 +1072,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // as both cause the timer to re-calculate its expiry time. * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was * // declared (in this function). - * if ( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) * { * // The reset command was not executed successfully. Take appropriate * // action here. @@ -984,7 +1085,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * // from inside an ISR varies from port to port, and from compiler to * // compiler. Inspect the demos for the port you are using to find the * // actual syntax required. - * if ( xHigherPriorityTaskWoken != pdFALSE ) + * if( xHigherPriorityTaskWoken != pdFALSE ) * { * // Call the interrupt safe yield function here (actual function * // depends on the FreeRTOS port being used). @@ -1083,7 +1184,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); * } * @endverbatim */ -BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ); +BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** * BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, @@ -1117,10 +1218,10 @@ BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void * timer daemon task, otherwise pdFALSE is returned. * */ -BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ); +BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** - * const char * const pcTimerGetTimerName( TimerHandle_t xTimer ); + * const char * const pcTimerGetName( TimerHandle_t xTimer ); * * Returns the name that was assigned to a timer when the timer was created. * @@ -1128,7 +1229,33 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvPar * * @return The name assigned to the timer specified by the xTimer parameter. */ -const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); + * + * Returns the period of a timer. + * + * @param xTimer The handle of the timer being queried. + * + * @return The period of the timer in ticks. + */ +TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + +/** +* TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ); +* +* Returns the time in ticks at which the timer will expire. If this is less +* than the current tick count then the expiry time has overflowed from the +* current time. +* +* @param xTimer The handle of the timer being queried. +* +* @return If the timer is running then the time in ticks at which the timer +* will next expire is returned. If the timer is not running then the return +* value is undefined. +*/ +TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /* * Functions beyond this part are not part of the public API and are intended @@ -1137,6 +1264,11 @@ const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualifi BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION; BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#if( configUSE_TRACE_FACILITY == 1 ) + void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +#endif + #ifdef __cplusplus } #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/list.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/list.c similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/list.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/list.c index 2bb8f37..8e3560a 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/list.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/list.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #include @@ -161,7 +120,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; share of the CPU. However, if the xItemValue is the same as the back marker the iteration loop below will not end. Therefore the value is checked first, and the algorithm slightly modified if necessary. */ - if ( xValueOfInsertion == portMAX_DELAY ) + if( xValueOfInsertion == portMAX_DELAY ) { pxIterator = pxList->xListEnd.pxPrevious; } @@ -189,7 +148,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; before vTaskStartScheduler() has been called?). **********************************************************************/ - for ( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ + for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ { /* There is nothing to do here, just iterating to the wanted insertion position. */ @@ -222,7 +181,7 @@ List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer; mtCOVERAGE_TEST_DELAY(); /* Make sure the index is left pointing to a valid item. */ - if ( pxList->pxIndex == pxItemToRemove ) + if( pxList->pxIndex == pxItemToRemove ) { pxList->pxIndex = pxItemToRemove->pxPrevious; } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/Common/mpu_wrappers.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/Common/mpu_wrappers.c new file mode 100644 index 0000000..a0cc775 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/Common/mpu_wrappers.c @@ -0,0 +1,1291 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* + * Implementation of the wrapper functions used to raise the processor privilege + * before calling a standard FreeRTOS API function. + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "timers.h" +#include "event_groups.h" +#include "stream_buffer.h" +#include "mpu_prototypes.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* + * Checks to see if being called from the context of an unprivileged task, and + * if so raises the privilege level and returns false - otherwise does nothing + * other than return true. + */ +extern BaseType_t xPortRaisePrivilege( void ); + +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskCreateRestricted( pxTaskDefinition, pxCreatedTask ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif /* conifgSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskCreateRestrictedStatic( pxTaskDefinition, pxCreatedTask ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif /* conifgSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, uint16_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ) + { + TaskHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const xRegions ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskAllocateMPURegions( xTask, xRegions ); + vPortResetPrivilege( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelete == 1 ) + void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskDelete( pxTaskToDelete ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelayUntil == 1 ) + void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, TickType_t xTimeIncrement ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskAbortDelay == 1 ) + BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskAbortDelay( xTask ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelay == 1 ) + void MPU_vTaskDelay( TickType_t xTicksToDelay ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskDelay( xTicksToDelay ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskPriorityGet == 1 ) + UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t pxTask ) + { + UBaseType_t uxReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + uxReturn = uxTaskPriorityGet( pxTask ); + vPortResetPrivilege( xRunningPrivileged ); + return uxReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskPrioritySet == 1 ) + void MPU_vTaskPrioritySet( TaskHandle_t pxTask, UBaseType_t uxNewPriority ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskPrioritySet( pxTask, uxNewPriority ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_eTaskGetState == 1 ) + eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + eTaskState eReturn; + + eReturn = eTaskGetState( pxTask ); + vPortResetPrivilege( xRunningPrivileged ); + return eReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TRACE_FACILITY == 1 ) + void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) + TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) + { + TaskHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetIdleTaskHandle(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskSuspend( pxTaskToSuspend ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskResume( pxTaskToResume ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +void MPU_vTaskSuspendAll( void ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskSuspendAll(); + vPortResetPrivilege( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xTaskResumeAll( void ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskResumeAll(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +TickType_t MPU_xTaskGetTickCount( void ) +{ +TickType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetTickCount(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) +{ +UBaseType_t uxReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + uxReturn = uxTaskGetNumberOfTasks(); + vPortResetPrivilege( xRunningPrivileged ); + return uxReturn; +} +/*-----------------------------------------------------------*/ + +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) +{ +char *pcReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + pcReturn = pcTaskGetName( xTaskToQuery ); + vPortResetPrivilege( xRunningPrivileged ); + return pcReturn; +} +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetHandle == 1 ) + TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ) + { + TaskHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetHandle( pcNameToQuery ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + void MPU_vTaskList( char *pcWriteBuffer ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskList( pcWriteBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskGetRunTimeStats( pcWriteBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskSetApplicationTaskTag( xTask, pxTagValue ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) + { + TaskHookFunction_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetApplicationTaskTag( xTask ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) + void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) + void *MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) + { + void *pvReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex ); + vPortResetPrivilege( xRunningPrivileged ); + return pvReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t *pxTaskStatusArray, UBaseType_t uxArraySize, uint32_t *pulTotalRunTime ) + { + UBaseType_t uxReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime ); + vPortResetPrivilege( xRunningPrivileged ); + return uxReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) + UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) + { + UBaseType_t uxReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + uxReturn = uxTaskGetStackHighWaterMark( xTask ); + vPortResetPrivilege( xRunningPrivileged ); + return uxReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) + TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) + { + TaskHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetCurrentTaskHandle(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetSchedulerState == 1 ) + BaseType_t MPU_xTaskGetSchedulerState( void ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetSchedulerState(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTaskSetTimeOutState( pxTimeOut ); + vPortResetPrivilege( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGenericNotify( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) + { + uint32_t ulReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + ulReturn = ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + return ulReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskNotifyStateClear( xTask ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t ucQueueType ) + { + QueueHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) + { + QueueHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue, BaseType_t xNewQueue ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueGenericReset( pxQueue, xNewQueue ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +UBaseType_t uxReturn; + + uxReturn = uxQueueMessagesWaiting( pxQueue ); + vPortResetPrivilege( xRunningPrivileged ); + return uxReturn; +} +/*-----------------------------------------------------------*/ + +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +UBaseType_t uxReturn; + + uxReturn = uxQueueSpacesAvailable( xQueue ); + vPortResetPrivilege( xRunningPrivileged ); + return uxReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue, void * const pvBuffer, TickType_t xTicksToWait ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +BaseType_t xReturn; + + xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +BaseType_t xReturn; + + xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +BaseType_t xReturn; + + xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t pxQueue, void * const pvBuffer ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +BaseType_t xReturn; + + xReturn = xQueuePeekFromISR( pxQueue, pvBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); +void * xReturn; + + xReturn = ( void * ) xQueueGetMutexHolder( xSemaphore ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +#if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) + { + QueueHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueCreateMutex( ucQueueType ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) + { + QueueHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, UBaseType_t uxInitialCount ) + { + QueueHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) + { + QueueHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xBlockTime ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueGiveMutexRecursive( xMutex ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) + { + QueueSetHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueCreateSet( uxEventQueueLength ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t xBlockTimeTicks ) + { + QueueSetMemberHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if configQUEUE_REGISTRY_SIZE > 0 + void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vQueueAddToRegistry( xQueue, pcName ); + + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if configQUEUE_REGISTRY_SIZE > 0 + void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vQueueUnregisterQueue( xQueue ); + + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if configQUEUE_REGISTRY_SIZE > 0 + const char *MPU_pcQueueGetName( QueueHandle_t xQueue ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + const char *pcReturn; + + pcReturn = pcQueueGetName( xQueue ); + + vPortResetPrivilege( xRunningPrivileged ); + return pcReturn; + } +#endif +/*-----------------------------------------------------------*/ + +void MPU_vQueueDelete( QueueHandle_t xQueue ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vQueueDelete( xQueue ); + + vPortResetPrivilege( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + void *MPU_pvPortMalloc( size_t xSize ) + { + void *pvReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + pvReturn = pvPortMalloc( xSize ); + + vPortResetPrivilege( xRunningPrivileged ); + + return pvReturn; + } +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + void MPU_vPortFree( void *pv ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vPortFree( pv ); + + vPortResetPrivilege( xRunningPrivileged ); + } +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + void MPU_vPortInitialiseBlocks( void ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vPortInitialiseBlocks(); + + vPortResetPrivilege( xRunningPrivileged ); + } +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + size_t MPU_xPortGetFreeHeapSize( void ) + { + size_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xPortGetFreeHeapSize(); + + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) + TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) + { + TimerHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) + TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ) + { + TimerHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxTimerBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + void *MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) + { + void * pvReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + pvReturn = pvTimerGetTimerID( xTimer ); + vPortResetPrivilege( xRunningPrivileged ); + + return pvReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTimerSetTimerID( xTimer, pvNewID ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerIsTimerActive( xTimer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) + { + TaskHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerGetTimerDaemonTaskHandle(); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) + BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerPendFunctionCall( xFunctionToPend, pvParameter1, ulParameter2, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) + { + const char * pcReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + pcReturn = pcTimerGetName( xTimer ); + vPortResetPrivilege( xRunningPrivileged ); + + return pcReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) + { + TickType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerGetPeriod( xTimer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) + { + TickType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerGetExpiryTime( xTimer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) + { + BaseType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + EventGroupHandle_t MPU_xEventGroupCreate( void ) + { + EventGroupHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xEventGroupCreate(); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) + { + EventGroupHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xEventGroupCreateStatic( pxEventGroupBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) +{ +EventBits_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) +{ +EventBits_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) +{ +EventBits_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) +{ +EventBits_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vEventGroupDelete( xEventGroup ); + vPortResetPrivilege( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ) +{ +size_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ) +{ +size_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferSendFromISR( xStreamBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ) +{ +size_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ) +{ +size_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferReceiveFromISR( xStreamBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vStreamBufferDelete( xStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferIsFull( xStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferIsEmpty( xStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferReset( xStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) +{ +size_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferSpacesAvailable( xStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) +{ +size_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferBytesAvailable( xStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) +{ +BaseType_t xReturn; +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ) + { + StreamBufferHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ) + { + StreamBufferHandle_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer, pucStreamBufferStorageArea, pxStaticStreamBuffer ); + vPortResetPrivilege( xRunningPrivileged ); + + return xReturn; + } +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + + +/* Functions that the application writer wants to execute in privileged mode +can be defined in application_defined_privileged_functions.h. The functions +must take the same format as those above whereby the privilege state on exit +equals the privilege state on entry. For example: + +void MPU_FunctionName( [parameters ] ) +{ +BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + FunctionName( [parameters ] ); + + vPortResetPrivilege( xRunningPrivileged ); +} +*/ + +#if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1 + #include "application_defined_privileged_functions.h" +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/ReadMe.url b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/ReadMe.url new file mode 100644 index 0000000..6c23737 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/ReadMe.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 +[InternetShortcut] +URL=http://www.freertos.org/a00111.html +IDList= diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_1.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_1.c new file mode 100644 index 0000000..ca44e18 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_1.c @@ -0,0 +1,148 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + +/* + * The simplest possible implementation of pvPortMalloc(). Note that this + * implementation does NOT allow allocated memory to be freed again. + * + * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the + * memory management pages of http://www.FreeRTOS.org for more information. + */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/* A few bytes might be lost to byte aligning the heap start address. */ +#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) + +/* Allocate the memory for the heap. */ +/* Allocate the memory for the heap. */ +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#else + static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/* Index into the ucHeap array. */ +static size_t xNextFreeByte = ( size_t ) 0; + +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +void *pvReturn = NULL; +static uint8_t *pucAlignedHeap = NULL; + + /* Ensure that blocks are always aligned to the required number of bytes. */ + #if( portBYTE_ALIGNMENT != 1 ) + { + if( xWantedSize & portBYTE_ALIGNMENT_MASK ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); + } + } + #endif + + vTaskSuspendAll(); + { + if( pucAlignedHeap == NULL ) + { + /* Ensure the heap starts on a correctly aligned boundary. */ + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + } + + /* Check there is enough room left for the allocation. */ + if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && + ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ + { + /* Return the next free byte then increment the index past this + block. */ + pvReturn = pucAlignedHeap + xNextFreeByte; + xNextFreeByte += xWantedSize; + } + + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + } + #endif + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ + /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and + heap_4.c for alternative implementations, and the memory management pages of + http://www.FreeRTOS.org for more information. */ + ( void ) pv; + + /* Force an assert as it is invalid to call this function. */ + configASSERT( pv == NULL ); +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* Only required when static memory is not cleared. */ + xNextFreeByte = ( size_t ) 0; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return ( configADJUSTED_HEAP_SIZE - xNextFreeByte ); +} + + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_2.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_2.c similarity index 62% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_2.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_2.c index df0d956..392f729 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_2.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_2.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* * A sample implementation of pvPortMalloc() and vPortFree() that permits @@ -88,6 +47,10 @@ task.h is included from an application file. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE +#if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + /* A few bytes might be lost to byte aligning the heap start address. */ #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) @@ -97,7 +60,14 @@ task.h is included from an application file. */ static void prvHeapInit( void ); /* Allocate the memory for the heap. */ -static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#else + static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + /* Define the linked list structure. This is used to link free blocks in order of their size. */ @@ -127,14 +97,14 @@ static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE; */ #define prvInsertBlockIntoFreeList( pxBlockToInsert ) \ { \ -BlockLink_t *pxIterator; \ +BlockLink_t *pxIterator; \ size_t xBlockSize; \ \ xBlockSize = pxBlockToInsert->xBlockSize; \ \ /* Iterate through the list until a block is found that has a larger size */ \ /* than the block we are inserting. */ \ - for ( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \ { \ /* There is nothing to do here - just iterate to the correct position. */ \ } \ @@ -156,7 +126,7 @@ void *pvReturn = NULL; { /* If this is the first call to malloc then the heap will require initialisation to setup the list of free blocks. */ - if ( xHeapHasBeenInitialised == pdFALSE ) + if( xHeapHasBeenInitialised == pdFALSE ) { prvHeapInit(); xHeapHasBeenInitialised = pdTRUE; @@ -164,32 +134,32 @@ void *pvReturn = NULL; /* The wanted size is increased so it can contain a BlockLink_t structure in addition to the requested amount of bytes. */ - if ( xWantedSize > 0 ) + if( xWantedSize > 0 ) { xWantedSize += heapSTRUCT_SIZE; /* Ensure that blocks are always aligned to the required number of bytes. */ - if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 ) + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 ) { /* Byte alignment required. */ xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); } } - if ( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) ) + if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) ) { /* Blocks are stored in byte order - traverse the list from the start (smallest) block until one of adequate size is found. */ pxPreviousBlock = &xStart; pxBlock = xStart.pxNextFreeBlock; - while ( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) { pxPreviousBlock = pxBlock; pxBlock = pxBlock->pxNextFreeBlock; } /* If we found the end marker then a block of adequate size was not found. */ - if ( pxBlock != &xEnd ) + if( pxBlock != &xEnd ) { /* Return the memory space - jumping over the BlockLink_t structure at its start. */ @@ -200,7 +170,7 @@ void *pvReturn = NULL; pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; /* If the block is larger than required it can be split into two. */ - if ( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) { /* This block is to be split into two. Create a new block following the number of bytes requested. The void cast is @@ -224,9 +194,9 @@ void *pvReturn = NULL; } ( void ) xTaskResumeAll(); - #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + #if( configUSE_MALLOC_FAILED_HOOK == 1 ) { - if ( pvReturn == NULL ) + if( pvReturn == NULL ) { extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); @@ -243,7 +213,7 @@ void vPortFree( void *pv ) uint8_t *puc = ( uint8_t * ) pv; BlockLink_t *pxLink; - if ( pv != NULL ) + if( pv != NULL ) { /* The memory being freed will have an BlockLink_t structure immediately before it. */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_3.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_3.c new file mode 100644 index 0000000..cd12bcf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_3.c @@ -0,0 +1,98 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + +/* + * Implementation of pvPortMalloc() and vPortFree() that relies on the + * compilers own malloc() and free() implementations. + * + * This file can only be used if the linker is configured to to generate + * a heap memory area. + * + * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the + * memory management pages of http://www.FreeRTOS.org for more information. + */ + +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +void *pvReturn; + + vTaskSuspendAll(); + { + pvReturn = malloc( xWantedSize ); + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + } + #endif + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ + if( pv ) + { + vTaskSuspendAll(); + { + free( pv ); + traceFREE( pv, 0 ); + } + ( void ) xTaskResumeAll(); + } +} + + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_4.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_4.c similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_4.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_4.c index 287f5e6..0fab62e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_4.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_4.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* * A sample implementation of pvPortMalloc() and vPortFree() that combines @@ -87,14 +46,18 @@ task.h is included from an application file. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE +#if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + /* Block sizes must not get too small. */ -#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize * 2 ) ) +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) /* Assumes 8bit bytes! */ #define heapBITS_PER_BYTE ( ( size_t ) 8 ) /* Allocate the memory for the heap. */ -#if ( configAPPLICATION_ALLOCATED_HEAP == 1 ) +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) /* The application writer has already defined the array used for the RTOS heap - probably so it can be placed in a special segment or address. */ extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; @@ -130,7 +93,7 @@ static void prvHeapInit( void ); /* The size of the structure placed at the beginning of each allocated memory block must by correctly byte aligned. */ -static const size_t xHeapStructSize = ( ( sizeof( BlockLink_t ) + ( ( ( size_t ) portBYTE_ALIGNMENT_MASK ) - ( size_t ) 1 ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ) ); +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); /* Create a couple of list links to mark the start and end of the list. */ static BlockLink_t xStart, *pxEnd = NULL; @@ -157,7 +120,7 @@ void *pvReturn = NULL; { /* If this is the first call to malloc then the heap will require initialisation to setup the list of free blocks. */ - if ( pxEnd == NULL ) + if( pxEnd == NULL ) { prvHeapInit(); } @@ -170,17 +133,17 @@ void *pvReturn = NULL; set. The top bit of the block size member of the BlockLink_t structure is used to determine who owns the block - the application or the kernel, so it must be free. */ - if ( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) { /* The wanted size is increased so it can contain a BlockLink_t structure in addition to the requested amount of bytes. */ - if ( xWantedSize > 0 ) + if( xWantedSize > 0 ) { xWantedSize += xHeapStructSize; /* Ensure that blocks are always aligned to the required number of bytes. */ - if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) { /* Byte alignment required. */ xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); @@ -196,13 +159,13 @@ void *pvReturn = NULL; mtCOVERAGE_TEST_MARKER(); } - if ( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { /* Traverse the list from the start (lowest address) block until one of adequate size is found. */ pxPreviousBlock = &xStart; pxBlock = xStart.pxNextFreeBlock; - while ( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) { pxPreviousBlock = pxBlock; pxBlock = pxBlock->pxNextFreeBlock; @@ -210,7 +173,7 @@ void *pvReturn = NULL; /* If the end marker was reached then a block of adequate size was not found. */ - if ( pxBlock != pxEnd ) + if( pxBlock != pxEnd ) { /* Return the memory space pointed to - jumping over the BlockLink_t structure at its start. */ @@ -222,14 +185,14 @@ void *pvReturn = NULL; /* If the block is larger than required it can be split into two. */ - if ( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) { /* This block is to be split into two. Create a new block following the number of bytes requested. The void cast is used to prevent byte alignment warnings from the compiler. */ pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); - configASSERT( ( ( ( uint32_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 ); + configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 ); /* Calculate the sizes of two blocks split from the single block. */ @@ -237,7 +200,7 @@ void *pvReturn = NULL; pxBlock->xBlockSize = xWantedSize; /* Insert the new block into the list of free blocks. */ - prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); + prvInsertBlockIntoFreeList( pxNewBlockLink ); } else { @@ -246,7 +209,7 @@ void *pvReturn = NULL; xFreeBytesRemaining -= pxBlock->xBlockSize; - if ( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) { xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; } @@ -279,9 +242,9 @@ void *pvReturn = NULL; } ( void ) xTaskResumeAll(); - #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + #if( configUSE_MALLOC_FAILED_HOOK == 1 ) { - if ( pvReturn == NULL ) + if( pvReturn == NULL ) { extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); @@ -293,7 +256,7 @@ void *pvReturn = NULL; } #endif - configASSERT( ( ( ( uint32_t ) pvReturn ) & portBYTE_ALIGNMENT_MASK ) == 0 ); + configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 ); return pvReturn; } /*-----------------------------------------------------------*/ @@ -303,7 +266,7 @@ void vPortFree( void *pv ) uint8_t *puc = ( uint8_t * ) pv; BlockLink_t *pxLink; - if ( pv != NULL ) + if( pv != NULL ) { /* The memory being freed will have an BlockLink_t structure immediately before it. */ @@ -316,9 +279,9 @@ BlockLink_t *pxLink; configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); configASSERT( pxLink->pxNextFreeBlock == NULL ); - if ( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) { - if ( pxLink->pxNextFreeBlock == NULL ) + if( pxLink->pxNextFreeBlock == NULL ) { /* The block is being returned to the heap - it is no longer allocated. */ @@ -368,20 +331,20 @@ static void prvHeapInit( void ) { BlockLink_t *pxFirstFreeBlock; uint8_t *pucAlignedHeap; -uint32_t ulAddress; +size_t uxAddress; size_t xTotalHeapSize = configTOTAL_HEAP_SIZE; /* Ensure the heap starts on a correctly aligned boundary. */ - ulAddress = ( uint32_t ) ucHeap; + uxAddress = ( size_t ) ucHeap; - if ( ( ulAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) + if( ( uxAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) { - ulAddress += ( portBYTE_ALIGNMENT - 1 ); - ulAddress &= ~( ( uint32_t ) portBYTE_ALIGNMENT_MASK ); - xTotalHeapSize -= ulAddress - ( uint32_t ) ucHeap; + uxAddress += ( portBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; } - pucAlignedHeap = ( uint8_t * ) ulAddress; + pucAlignedHeap = ( uint8_t * ) uxAddress; /* xStart is used to hold a pointer to the first item in the list of free blocks. The void cast is used to prevent compiler warnings. */ @@ -390,17 +353,17 @@ size_t xTotalHeapSize = configTOTAL_HEAP_SIZE; /* pxEnd is used to mark the end of the list of free blocks and is inserted at the end of the heap space. */ - ulAddress = ( ( uint32_t ) pucAlignedHeap ) + xTotalHeapSize; - ulAddress -= xHeapStructSize; - ulAddress &= ~( ( uint32_t ) portBYTE_ALIGNMENT_MASK ); - pxEnd = ( void * ) ulAddress; + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; pxEnd->xBlockSize = 0; pxEnd->pxNextFreeBlock = NULL; /* To start with there is a single free block that is sized to take up the entire heap space, minus the space taken by pxEnd. */ pxFirstFreeBlock = ( void * ) pucAlignedHeap; - pxFirstFreeBlock->xBlockSize = ulAddress - ( uint32_t ) pxFirstFreeBlock; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; pxFirstFreeBlock->pxNextFreeBlock = pxEnd; /* Only one block exists - and it covers the entire usable heap space. */ @@ -419,7 +382,7 @@ uint8_t *puc; /* Iterate through the list until a block is found that has a higher address than the block being inserted. */ - for ( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) { /* Nothing to do here, just iterate to the right position. */ } @@ -427,7 +390,7 @@ uint8_t *puc; /* Do the block being inserted, and the block it is being inserted after make a contiguous block of memory? */ puc = ( uint8_t * ) pxIterator; - if ( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) { pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; pxBlockToInsert = pxIterator; @@ -440,9 +403,9 @@ uint8_t *puc; /* Do the block being inserted, and the block it is being inserted before make a contiguous block of memory? */ puc = ( uint8_t * ) pxBlockToInsert; - if ( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) { - if ( pxIterator->pxNextFreeBlock != pxEnd ) + if( pxIterator->pxNextFreeBlock != pxEnd ) { /* Form one big block from the two blocks. */ pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; @@ -462,7 +425,7 @@ uint8_t *puc; before and the block after, then it's pxNextFreeBlock pointer will have already been set, and should not be set here as that would make it point to itself. */ - if ( pxIterator != pxBlockToInsert ) + if( pxIterator != pxBlockToInsert ) { pxIterator->pxNextFreeBlock = pxBlockToInsert; } diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_5.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_5.c similarity index 66% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_5.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_5.c index 79624a0..958501b 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/portable/MemMang/heap_5.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/MemMang/heap_5.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* * A sample implementation of pvPortMalloc() that allows the heap to be defined @@ -121,8 +80,12 @@ task.h is included from an application file. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE +#if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + /* Block sizes must not get too small. */ -#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( uxHeapStructSize << 1 ) ) +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) /* Assumes 8bit bytes! */ #define heapBITS_PER_BYTE ( ( size_t ) 8 ) @@ -149,15 +112,15 @@ static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); /* The size of the structure placed at the beginning of each allocated memory block must by correctly byte aligned. */ -static const uint32_t uxHeapStructSize = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK ); +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); /* Create a couple of list links to mark the start and end of the list. */ static BlockLink_t xStart, *pxEnd = NULL; /* Keeps track of the number of free bytes remaining, but says nothing about fragmentation. */ -static size_t xFreeBytesRemaining = 0; -static size_t xMinimumEverFreeBytesRemaining = 0; +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; /* Gets set to the top bit of an size_t type. When this bit in the xBlockSize member of an BlockLink_t structure is set then the block belongs to the @@ -182,17 +145,17 @@ void *pvReturn = NULL; set. The top bit of the block size member of the BlockLink_t structure is used to determine who owns the block - the application or the kernel, so it must be free. */ - if ( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) { /* The wanted size is increased so it can contain a BlockLink_t structure in addition to the requested amount of bytes. */ - if ( xWantedSize > 0 ) + if( xWantedSize > 0 ) { - xWantedSize += uxHeapStructSize; + xWantedSize += xHeapStructSize; /* Ensure that blocks are always aligned to the required number of bytes. */ - if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) { /* Byte alignment required. */ xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); @@ -207,13 +170,13 @@ void *pvReturn = NULL; mtCOVERAGE_TEST_MARKER(); } - if ( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { /* Traverse the list from the start (lowest address) block until one of adequate size is found. */ pxPreviousBlock = &xStart; pxBlock = xStart.pxNextFreeBlock; - while ( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) { pxPreviousBlock = pxBlock; pxBlock = pxBlock->pxNextFreeBlock; @@ -221,11 +184,11 @@ void *pvReturn = NULL; /* If the end marker was reached then a block of adequate size was not found. */ - if ( pxBlock != pxEnd ) + if( pxBlock != pxEnd ) { /* Return the memory space pointed to - jumping over the BlockLink_t structure at its start. */ - pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + uxHeapStructSize ); + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); /* This block is being returned for use so must be taken out of the list of free blocks. */ @@ -233,7 +196,7 @@ void *pvReturn = NULL; /* If the block is larger than required it can be split into two. */ - if ( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) { /* This block is to be split into two. Create a new block following the number of bytes requested. The void @@ -256,7 +219,7 @@ void *pvReturn = NULL; xFreeBytesRemaining -= pxBlock->xBlockSize; - if ( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) { xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; } @@ -289,9 +252,9 @@ void *pvReturn = NULL; } ( void ) xTaskResumeAll(); - #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + #if( configUSE_MALLOC_FAILED_HOOK == 1 ) { - if ( pvReturn == NULL ) + if( pvReturn == NULL ) { extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); @@ -312,11 +275,11 @@ void vPortFree( void *pv ) uint8_t *puc = ( uint8_t * ) pv; BlockLink_t *pxLink; - if ( pv != NULL ) + if( pv != NULL ) { /* The memory being freed will have an BlockLink_t structure immediately before it. */ - puc -= uxHeapStructSize; + puc -= xHeapStructSize; /* This casting is to keep the compiler from issuing warnings. */ pxLink = ( void * ) puc; @@ -325,9 +288,9 @@ BlockLink_t *pxLink; configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); configASSERT( pxLink->pxNextFreeBlock == NULL ); - if ( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) { - if ( pxLink->pxNextFreeBlock == NULL ) + if( pxLink->pxNextFreeBlock == NULL ) { /* The block is being returned to the heap - it is no longer allocated. */ @@ -374,7 +337,7 @@ uint8_t *puc; /* Iterate through the list until a block is found that has a higher address than the block being inserted. */ - for ( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) { /* Nothing to do here, just iterate to the right position. */ } @@ -382,7 +345,7 @@ uint8_t *puc; /* Do the block being inserted, and the block it is being inserted after make a contiguous block of memory? */ puc = ( uint8_t * ) pxIterator; - if ( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) { pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; pxBlockToInsert = pxIterator; @@ -395,9 +358,9 @@ uint8_t *puc; /* Do the block being inserted, and the block it is being inserted before make a contiguous block of memory? */ puc = ( uint8_t * ) pxBlockToInsert; - if ( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) { - if ( pxIterator->pxNextFreeBlock != pxEnd ) + if( pxIterator->pxNextFreeBlock != pxEnd ) { /* Form one big block from the two blocks. */ pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; @@ -417,7 +380,7 @@ uint8_t *puc; before and the block after, then it's pxNextFreeBlock pointer will have already been set, and should not be set here as that would make it point to itself. */ - if ( pxIterator != pxBlockToInsert ) + if( pxIterator != pxBlockToInsert ) { pxIterator->pxNextFreeBlock = pxBlockToInsert; } @@ -431,10 +394,10 @@ uint8_t *puc; void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) { BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock; -uint8_t *pucAlignedHeap; +size_t xAlignedHeap; size_t xTotalRegionSize, xTotalHeapSize = 0; BaseType_t xDefinedRegions = 0; -uint32_t ulAddress; +size_t xAddress; const HeapRegion_t *pxHeapRegion; /* Can only call once! */ @@ -442,29 +405,29 @@ const HeapRegion_t *pxHeapRegion; pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); - while ( pxHeapRegion->xSizeInBytes > 0 ) + while( pxHeapRegion->xSizeInBytes > 0 ) { xTotalRegionSize = pxHeapRegion->xSizeInBytes; /* Ensure the heap region starts on a correctly aligned boundary. */ - ulAddress = ( uint32_t ) pxHeapRegion->pucStartAddress; - if ( ( ulAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) + xAddress = ( size_t ) pxHeapRegion->pucStartAddress; + if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) { - ulAddress += ( portBYTE_ALIGNMENT - 1 ); - ulAddress &= ~portBYTE_ALIGNMENT_MASK; + xAddress += ( portBYTE_ALIGNMENT - 1 ); + xAddress &= ~portBYTE_ALIGNMENT_MASK; /* Adjust the size for the bytes lost to alignment. */ - xTotalRegionSize -= ulAddress - ( uint32_t ) pxHeapRegion->pucStartAddress; + xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress; } - pucAlignedHeap = ( uint8_t * ) ulAddress; + xAlignedHeap = xAddress; /* Set xStart if it has not already been set. */ - if ( xDefinedRegions == 0 ) + if( xDefinedRegions == 0 ) { /* xStart is used to hold a pointer to the first item in the list of free blocks. The void cast is used to prevent compiler warnings. */ - xStart.pxNextFreeBlock = ( BlockLink_t * ) pucAlignedHeap; + xStart.pxNextFreeBlock = ( BlockLink_t * ) xAlignedHeap; xStart.xBlockSize = ( size_t ) 0; } else @@ -474,7 +437,7 @@ const HeapRegion_t *pxHeapRegion; configASSERT( pxEnd != NULL ); /* Check blocks are passed in with increasing start addresses. */ - configASSERT( ulAddress > ( uint32_t ) pxEnd ); + configASSERT( xAddress > ( size_t ) pxEnd ); } /* Remember the location of the end marker in the previous region, if @@ -483,23 +446,23 @@ const HeapRegion_t *pxHeapRegion; /* pxEnd is used to mark the end of the list of free blocks and is inserted at the end of the region space. */ - ulAddress = ( ( uint32_t ) pucAlignedHeap ) + xTotalRegionSize; - ulAddress -= uxHeapStructSize; - ulAddress &= ~portBYTE_ALIGNMENT_MASK; - pxEnd = ( BlockLink_t * ) ulAddress; + xAddress = xAlignedHeap + xTotalRegionSize; + xAddress -= xHeapStructSize; + xAddress &= ~portBYTE_ALIGNMENT_MASK; + pxEnd = ( BlockLink_t * ) xAddress; pxEnd->xBlockSize = 0; pxEnd->pxNextFreeBlock = NULL; /* To start with there is a single free block in this region that is sized to take up the entire heap region minus the space taken by the free block structure. */ - pxFirstFreeBlockInRegion = ( BlockLink_t * ) pucAlignedHeap; - pxFirstFreeBlockInRegion->xBlockSize = ulAddress - ( uint32_t ) pxFirstFreeBlockInRegion; + pxFirstFreeBlockInRegion = ( BlockLink_t * ) xAlignedHeap; + pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion; pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd; /* If this is not the first region that makes up the entire heap space then link the previous region to this region. */ - if ( pxPreviousFreeBlock != NULL ) + if( pxPreviousFreeBlock != NULL ) { pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion; } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/readme.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/readme.txt new file mode 100644 index 0000000..b68d2d5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/portable/readme.txt @@ -0,0 +1,20 @@ +Each real time kernel port consists of three files that contain the core kernel +components and are common to every port, and one or more files that are +specific to a particular microcontroller and/or compiler. + + ++ The FreeRTOS/Source/Portable/MemMang directory contains the five sample +memory allocators as described on the http://www.FreeRTOS.org WEB site. + ++ The other directories each contain files specific to a particular +microcontroller or compiler, where the directory name denotes the compiler +specific files the directory contains. + + + +For example, if you are interested in the [compiler] port for the [architecture] +microcontroller, then the port specific files are contained in +FreeRTOS/Source/Portable/[compiler]/[architecture] directory. If this is the +only port you are interested in then all the other directories can be +ignored. + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/queue.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/queue.c similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/queue.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/queue.c index 7cc3914..9a46f46 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/queue.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/queue.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ #include #include @@ -90,9 +49,9 @@ privileged Vs unprivileged linkage and placement. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ -/* Constants used with the xRxLock and xTxLock structure members. */ -#define queueUNLOCKED ( ( BaseType_t ) -1 ) -#define queueLOCKED_UNMODIFIED ( ( BaseType_t ) 0 ) +/* Constants used with the cRxLock and cTxLock structure members. */ +#define queueUNLOCKED ( ( int8_t ) -1 ) +#define queueLOCKED_UNMODIFIED ( ( int8_t ) 0 ) /* When the Queue_t structure is used to represent a base queue its pcHead and pcTail members are used as pointers into the queue storage area. When the @@ -114,7 +73,7 @@ zero. */ #define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 ) #define queueMUTEX_GIVE_BLOCK_TIME ( ( TickType_t ) 0U ) -#if ( configUSE_PREEMPTION == 0 ) +#if( configUSE_PREEMPTION == 0 ) /* If the cooperative scheduler is being used then a yield should not be performed just because a higher priority task has been woken. */ #define queueYIELD_IF_USING_PREEMPTION() @@ -146,18 +105,22 @@ typedef struct QueueDefinition UBaseType_t uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ UBaseType_t uxItemSize; /*< The size of each items that the queue will hold. */ - volatile BaseType_t xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - volatile BaseType_t xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile int8_t cRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile int8_t cTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxQueueNumber; - uint8_t ucQueueType; + #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the memory used by the queue was statically allocated to ensure no attempt is made to free the memory. */ #endif #if ( configUSE_QUEUE_SETS == 1 ) struct QueueDefinition *pxQueueSetContainer; #endif + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxQueueNumber; + uint8_t ucQueueType; + #endif + } xQUEUE; /* The old xQUEUE name is maintained above then typedefed to the new Queue_t @@ -189,7 +152,7 @@ typedef xQUEUE Queue_t; /* The queue registry is simply an array of QueueRegistryItem_t structures. The pcQueueName member of a structure being NULL is indicative of the array position being vacant. */ - QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; + PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; #endif /* configQUEUE_REGISTRY_SIZE */ @@ -236,6 +199,31 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; #endif +/* + * Called after a Queue_t structure has been allocated either statically or + * dynamically to fill in the structure's members. + */ +static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, const uint8_t ucQueueType, Queue_t *pxNewQueue ) PRIVILEGED_FUNCTION; + +/* + * Mutexes are a special type of queue. When a mutex is created, first the + * queue is created, then prvInitialiseMutex() is called to configure the queue + * as a mutex. + */ +#if( configUSE_MUTEXES == 1 ) + static void prvInitialiseMutex( Queue_t *pxNewQueue ) PRIVILEGED_FUNCTION; +#endif + +#if( configUSE_MUTEXES == 1 ) + /* + * If a task waiting for a mutex causes the mutex holder to inherit a + * priority, but the waiting task times out, then the holder should + * disinherit the priority - but only down to the highest priority of any + * other tasks that are waiting for the same mutex. This function returns + * that priority. + */ + static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue ) PRIVILEGED_FUNCTION; +#endif /*-----------------------------------------------------------*/ /* @@ -245,13 +233,13 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer #define prvLockQueue( pxQueue ) \ taskENTER_CRITICAL(); \ { \ - if ( ( pxQueue )->xRxLock == queueUNLOCKED ) \ + if( ( pxQueue )->cRxLock == queueUNLOCKED ) \ { \ - ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED; \ + ( pxQueue )->cRxLock = queueLOCKED_UNMODIFIED; \ } \ - if ( ( pxQueue )->xTxLock == queueUNLOCKED ) \ + if( ( pxQueue )->cTxLock == queueUNLOCKED ) \ { \ - ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED; \ + ( pxQueue )->cTxLock = queueLOCKED_UNMODIFIED; \ } \ } \ taskEXIT_CRITICAL() @@ -269,19 +257,19 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; pxQueue->pcWriteTo = pxQueue->pcHead; pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize ); - pxQueue->xRxLock = queueUNLOCKED; - pxQueue->xTxLock = queueUNLOCKED; + pxQueue->cRxLock = queueUNLOCKED; + pxQueue->cTxLock = queueUNLOCKED; - if ( xNewQueue == pdFALSE ) + if( xNewQueue == pdFALSE ) { /* If there are tasks blocked waiting to read from the queue, then the tasks will remain blocked as after this function exits the queue will still be empty. If there are tasks blocked waiting to write to the queue, then one should be unblocked as after this function exits it will be possible to write to it. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) { queueYIELD_IF_USING_PREEMPTION(); } @@ -310,132 +298,171 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } /*-----------------------------------------------------------*/ -QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) -{ -Queue_t *pxNewQueue; -size_t xQueueSizeInBytes; -QueueHandle_t xReturn = NULL; -int8_t *pcAllocatedBuffer; +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - /* Remove compiler warnings about unused parameters should - configUSE_TRACE_FACILITY not be set to 1. */ - ( void ) ucQueueType; + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) + { + Queue_t *pxNewQueue; - configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); + configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); - if ( uxItemSize == ( UBaseType_t ) 0 ) - { - /* There is not going to be a queue storage area. */ - xQueueSizeInBytes = ( size_t ) 0; - } - else - { - /* The queue is one byte longer than asked for to make wrap checking - easier/faster. */ - xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + /* The StaticQueue_t structure and the queue storage area must be + supplied. */ + configASSERT( pxStaticQueue != NULL ); + + /* A queue storage area should be provided if the item size is not 0, and + should not be provided if the item size is 0. */ + configASSERT( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ); + configASSERT( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ); + + #if( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + variable of type StaticQueue_t or StaticSemaphore_t equals the size of + the real queue and semaphore structures. */ + volatile size_t xSize = sizeof( StaticQueue_t ); + configASSERT( xSize == sizeof( Queue_t ) ); + } + #endif /* configASSERT_DEFINED */ + + /* The address of a statically allocated queue was passed in, use it. + The address of a statically allocated storage area was also passed in + but is already set. */ + pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + + if( pxNewQueue != NULL ) + { + #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + { + /* Queues can be allocated wither statically or dynamically, so + note this queue was allocated statically in case the queue is + later deleted. */ + pxNewQueue->ucStaticallyAllocated = pdTRUE; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + + prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); + } + else + { + traceQUEUE_CREATE_FAILED( ucQueueType ); + } + + return pxNewQueue; } - /* Allocate the new queue structure and storage area. */ - pcAllocatedBuffer = ( int8_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - if ( pcAllocatedBuffer != NULL ) + QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) { - pxNewQueue = ( Queue_t * ) pcAllocatedBuffer; /*lint !e826 MISRA The buffer cannot be too small because it was dimensioned by sizeof( Queue_t ) + xQueueSizeInBytes. */ + Queue_t *pxNewQueue; + size_t xQueueSizeInBytes; + uint8_t *pucQueueStorage; + + configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); - if ( uxItemSize == ( UBaseType_t ) 0 ) + if( uxItemSize == ( UBaseType_t ) 0 ) { - /* No RAM was allocated for the queue storage area, but PC head - cannot be set to NULL because NULL is used as a key to say the queue - is used as a mutex. Therefore just set pcHead to point to the queue - as a benign value that is known to be within the memory map. */ - pxNewQueue->pcHead = ( int8_t * ) pxNewQueue; + /* There is not going to be a queue storage area. */ + xQueueSizeInBytes = ( size_t ) 0; } else { - /* Jump past the queue structure to find the location of the queue - storage area - adding the padding bytes to get a better alignment. */ - pxNewQueue->pcHead = pcAllocatedBuffer + sizeof( Queue_t ); + /* Allocate enough space to hold the maximum number of items that + can be in the queue at any time. */ + xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ } - /* Initialise the queue members as described above where the queue type - is defined. */ - pxNewQueue->uxLength = uxQueueLength; - pxNewQueue->uxItemSize = uxItemSize; - ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); + pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); - #if ( configUSE_TRACE_FACILITY == 1 ) + if( pxNewQueue != NULL ) { - pxNewQueue->ucQueueType = ucQueueType; - } - #endif /* configUSE_TRACE_FACILITY */ + /* Jump past the queue structure to find the location of the queue + storage area. */ + pucQueueStorage = ( ( uint8_t * ) pxNewQueue ) + sizeof( Queue_t ); + + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* Queues can be created either statically or dynamically, so + note this task was created dynamically in case it is later + deleted. */ + pxNewQueue->ucStaticallyAllocated = pdFALSE; + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ - #if ( configUSE_QUEUE_SETS == 1 ) + prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); + } + else { - pxNewQueue->pxQueueSetContainer = NULL; + traceQUEUE_CREATE_FAILED( ucQueueType ); } - #endif /* configUSE_QUEUE_SETS */ - traceQUEUE_CREATE( pxNewQueue ); - xReturn = pxNewQueue; + return pxNewQueue; + } + +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, const uint8_t ucQueueType, Queue_t *pxNewQueue ) +{ + /* Remove compiler warnings about unused parameters should + configUSE_TRACE_FACILITY not be set to 1. */ + ( void ) ucQueueType; + + if( uxItemSize == ( UBaseType_t ) 0 ) + { + /* No RAM was allocated for the queue storage area, but PC head cannot + be set to NULL because NULL is used as a key to say the queue is used as + a mutex. Therefore just set pcHead to point to the queue as a benign + value that is known to be within the memory map. */ + pxNewQueue->pcHead = ( int8_t * ) pxNewQueue; } else { - mtCOVERAGE_TEST_MARKER(); + /* Set the head to the start of the queue storage area. */ + pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage; } - configASSERT( xReturn ); + /* Initialise the queue members as described where the queue type is + defined. */ + pxNewQueue->uxLength = uxQueueLength; + pxNewQueue->uxItemSize = uxItemSize; + ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); - return xReturn; + #if ( configUSE_TRACE_FACILITY == 1 ) + { + pxNewQueue->ucQueueType = ucQueueType; + } + #endif /* configUSE_TRACE_FACILITY */ + + #if( configUSE_QUEUE_SETS == 1 ) + { + pxNewQueue->pxQueueSetContainer = NULL; + } + #endif /* configUSE_QUEUE_SETS */ + + traceQUEUE_CREATE( pxNewQueue ); } /*-----------------------------------------------------------*/ -#if ( configUSE_MUTEXES == 1 ) +#if( configUSE_MUTEXES == 1 ) - QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) + static void prvInitialiseMutex( Queue_t *pxNewQueue ) { - Queue_t *pxNewQueue; - - /* Prevent compiler warnings about unused parameters if - configUSE_TRACE_FACILITY does not equal 1. */ - ( void ) ucQueueType; - - /* Allocate the new queue structure. */ - pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) ); - if ( pxNewQueue != NULL ) + if( pxNewQueue != NULL ) { - /* Information required for priority inheritance. */ + /* The queue create function will set all the queue structure members + correctly for a generic queue, but this function is creating a + mutex. Overwrite those members that need to be set differently - + in particular the information required for priority inheritance. */ pxNewQueue->pxMutexHolder = NULL; pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX; - /* Queues used as a mutex no data is actually copied into or out - of the queue. */ - pxNewQueue->pcWriteTo = NULL; - pxNewQueue->u.pcReadFrom = NULL; - - /* Each mutex has a length of 1 (like a binary semaphore) and - an item size of 0 as nothing is actually copied into or out - of the mutex. */ - pxNewQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; - pxNewQueue->uxLength = ( UBaseType_t ) 1U; - pxNewQueue->uxItemSize = ( UBaseType_t ) 0U; - pxNewQueue->xRxLock = queueUNLOCKED; - pxNewQueue->xTxLock = queueUNLOCKED; - - #if ( configUSE_TRACE_FACILITY == 1 ) - { - pxNewQueue->ucQueueType = ucQueueType; - } - #endif - - #if ( configUSE_QUEUE_SETS == 1 ) - { - pxNewQueue->pxQueueSetContainer = NULL; - } - #endif - - /* Ensure the event queues start with the correct state. */ - vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); + /* In case this is a recursive mutex. */ + pxNewQueue->u.uxRecursiveCallCount = 0; traceCREATE_MUTEX( pxNewQueue ); @@ -446,8 +473,41 @@ int8_t *pcAllocatedBuffer; { traceCREATE_MUTEX_FAILED(); } + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) + { + Queue_t *pxNewQueue; + const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0; + + pxNewQueue = ( Queue_t * ) xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType ); + prvInitialiseMutex( pxNewQueue ); + + return pxNewQueue; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) + { + Queue_t *pxNewQueue; + const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0; + + /* Prevent compiler warnings about unused parameters if + configUSE_TRACE_FACILITY does not equal 1. */ + ( void ) ucQueueType; + + pxNewQueue = ( Queue_t * ) xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType ); + prvInitialiseMutex( pxNewQueue ); - configASSERT( pxNewQueue ); return pxNewQueue; } @@ -467,7 +527,7 @@ int8_t *pcAllocatedBuffer; following critical section exiting and the function returning. */ taskENTER_CRITICAL(); { - if ( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) + if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) { pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder; } @@ -484,6 +544,32 @@ int8_t *pcAllocatedBuffer; #endif /*-----------------------------------------------------------*/ +#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) + + void* xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) + { + void *pxReturn; + + configASSERT( xSemaphore ); + + /* Mutexes cannot be used in interrupt service routines, so the mutex + holder should not change in an ISR, and therefore a critical section is + not required here. */ + if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) + { + pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder; + } + else + { + pxReturn = NULL; + } + + return pxReturn; + } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */ + +#endif +/*-----------------------------------------------------------*/ + #if ( configUSE_RECURSIVE_MUTEXES == 1 ) BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) @@ -499,7 +585,7 @@ int8_t *pcAllocatedBuffer; this is the only condition we are interested in it does not matter if pxMutexHolder is accessed simultaneously by another task. Therefore no mutual exclusion is required to test the pxMutexHolder variable. */ - if ( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */ + if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */ { traceGIVE_MUTEX_RECURSIVE( pxMutex ); @@ -510,8 +596,8 @@ int8_t *pcAllocatedBuffer; uxRecursiveCallCount member. */ ( pxMutex->u.uxRecursiveCallCount )--; - /* Have we unwound the call count? */ - if ( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 ) + /* Has the recursive call count unwound to 0? */ + if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 ) { /* Return the mutex. This will automatically unblock any other task that might be waiting to access the mutex. */ @@ -553,19 +639,19 @@ int8_t *pcAllocatedBuffer; traceTAKE_MUTEX_RECURSIVE( pxMutex ); - if ( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ + if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ { ( pxMutex->u.uxRecursiveCallCount )++; xReturn = pdPASS; } else { - xReturn = xQueueGenericReceive( pxMutex, NULL, xTicksToWait, pdFALSE ); + xReturn = xQueueSemaphoreTake( pxMutex, xTicksToWait ); /* pdPASS will only be returned if the mutex was successfully obtained. The calling task may have entered the Blocked state before reaching here. */ - if ( xReturn == pdPASS ) + if( xReturn != pdFAIL ) { ( pxMutex->u.uxRecursiveCallCount )++; } @@ -581,7 +667,35 @@ int8_t *pcAllocatedBuffer; #endif /* configUSE_RECURSIVE_MUTEXES */ /*-----------------------------------------------------------*/ -#if ( configUSE_COUNTING_SEMAPHORES == 1 ) +#if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) + { + QueueHandle_t xHandle; + + configASSERT( uxMaxCount != 0 ); + configASSERT( uxInitialCount <= uxMaxCount ); + + xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); + + if( xHandle != NULL ) + { + ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + + traceCREATE_COUNTING_SEMAPHORE(); + } + else + { + traceCREATE_COUNTING_SEMAPHORE_FAILED(); + } + + return xHandle; + } + +#endif /* ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) { @@ -592,7 +706,7 @@ int8_t *pcAllocatedBuffer; xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); - if ( xHandle != NULL ) + if( xHandle != NULL ) { ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; @@ -603,11 +717,10 @@ int8_t *pcAllocatedBuffer; traceCREATE_COUNTING_SEMAPHORE_FAILED(); } - configASSERT( xHandle ); return xHandle; } -#endif /* configUSE_COUNTING_SEMAPHORES */ +#endif /* ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ /*-----------------------------------------------------------*/ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) @@ -629,7 +742,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; /* This function relaxes the coding standard somewhat to allow return statements within the function itself. This is done in the interest of execution time efficiency. */ - for ( ;; ) + for( ;; ) { taskENTER_CRITICAL(); { @@ -637,16 +750,16 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; highest priority task wanting to access the queue. If the head item in the queue is to be overwritten then it does not matter if the queue is full. */ - if ( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) + if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) { traceQUEUE_SEND( pxQueue ); xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); #if ( configUSE_QUEUE_SETS == 1 ) { - if ( pxQueue->pxQueueSetContainer != NULL ) + if( pxQueue->pxQueueSetContainer != NULL ) { - if ( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE ) + if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) != pdFALSE ) { /* The queue is a member of a queue set, and posting to the queue set caused a higher priority task to @@ -662,9 +775,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; { /* If there was a task waiting for data to arrive on the queue then unblock it now. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The unblocked task has a priority higher than our own so yield immediately. Yes it is ok to @@ -677,7 +790,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; mtCOVERAGE_TEST_MARKER(); } } - else if ( xYieldRequired != pdFALSE ) + else if( xYieldRequired != pdFALSE ) { /* This path is a special case that will only get executed if the task was holding multiple mutexes @@ -695,9 +808,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; { /* If there was a task waiting for data to arrive on the queue then unblock it now. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The unblocked task has a priority higher than our own so yield immediately. Yes it is ok to do @@ -710,7 +823,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; mtCOVERAGE_TEST_MARKER(); } } - else if ( xYieldRequired != pdFALSE ) + else if( xYieldRequired != pdFALSE ) { /* This path is a special case that will only get executed if the task was holding multiple mutexes and @@ -730,7 +843,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } else { - if ( xTicksToWait == ( TickType_t ) 0 ) + if( xTicksToWait == ( TickType_t ) 0 ) { /* The queue was full and no block time is specified (or the block time has expired) so leave now. */ @@ -741,11 +854,11 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; traceQUEUE_SEND_FAILED( pxQueue ); return errQUEUE_FULL; } - else if ( xEntryTimeSet == pdFALSE ) + else if( xEntryTimeSet == pdFALSE ) { /* The queue was full and a block time was specified so configure the timeout structure. */ - vTaskSetTimeOutState( &xTimeOut ); + vTaskInternalSetTimeOutState( &xTimeOut ); xEntryTimeSet = pdTRUE; } else @@ -764,16 +877,16 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; prvLockQueue( pxQueue ); /* Update the timeout state to see if it has expired yet. */ - if ( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) { - if ( prvIsQueueFull( pxQueue ) != pdFALSE ) + if( prvIsQueueFull( pxQueue ) != pdFALSE ) { traceBLOCKING_ON_QUEUE_SEND( pxQueue ); vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); /* Unlocking the queue means queue events can effect the - event list. It is possible that interrupts occurring now - remove this task from the event list again - but as the + event list. It is possible that interrupts occurring now + remove this task from the event list again - but as the scheduler is suspended the task will go onto the pending ready last instead of the actual ready list. */ prvUnlockQueue( pxQueue ); @@ -783,7 +896,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; task is already in a ready list before it yields - in which case the yield will not cause a context switch unless there is also a higher priority task in the pending ready list. */ - if ( xTaskResumeAll() == pdFALSE ) + if( xTaskResumeAll() == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -801,8 +914,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; prvUnlockQueue( pxQueue ); ( void ) xTaskResumeAll(); - /* Return to the original privilege level before exiting the - function. */ traceQUEUE_SEND_FAILED( pxQueue ); return errQUEUE_FULL; } @@ -810,37 +921,73 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } /*-----------------------------------------------------------*/ -#if ( configUSE_ALTERNATIVE_API == 1 ) +BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) +{ +BaseType_t xReturn; +UBaseType_t uxSavedInterruptStatus; +Queue_t * const pxQueue = ( Queue_t * ) xQueue; - BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) - { - BaseType_t xEntryTimeSet = pdFALSE; - TimeOut_t xTimeOut; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; + configASSERT( pxQueue ); + configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); - configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + /* RTOS ports that support interrupt nesting have the concept of a maximum + system call (or maximum API call) interrupt priority. Interrupts that are + above the maximum system call priority are kept permanently enabled, even + when the RTOS kernel is in a critical section, but cannot make any calls to + FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + failure if a FreeRTOS API function is called from an interrupt that has been + assigned a priority above the configured maximum system call priority. + Only FreeRTOS functions that end in FromISR can be called from interrupts + that have been assigned a priority at or (logically) below the maximum + system call interrupt priority. FreeRTOS maintains a separate interrupt + safe API to ensure interrupt entry is as fast and as simple as possible. + More information (albeit Cortex-M specific) is provided on the following + link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - for ( ;; ) + /* Similar to xQueueGenericSend, except without blocking if there is no room + in the queue. Also don't directly wake a task that was blocked on a queue + read, instead return a flag to say whether a context switch is required or + not (i.e. has a task with a higher priority than us been woken by this + post). */ + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) { - taskENTER_CRITICAL(); + const int8_t cTxLock = pxQueue->cTxLock; + + traceQUEUE_SEND_FROM_ISR( pxQueue ); + + /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a + semaphore or mutex. That means prvCopyDataToQueue() cannot result + in a task disinheriting a priority and prvCopyDataToQueue() can be + called here even though the disinherit function does not check if + the scheduler is suspended before accessing the ready lists. */ + ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + + /* The event list is not altered if the queue is locked. This will + be done when the queue is unlocked later. */ + if( cTxLock == queueUNLOCKED ) { - /* Is there room on the queue now? To be running we must be - the highest priority task wanting to access the queue. */ - if ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + #if ( configUSE_QUEUE_SETS == 1 ) { - traceQUEUE_SEND( pxQueue ); - prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - /* If there was a task waiting for data to arrive on the - queue then unblock it now. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( pxQueue->pxQueueSetContainer != NULL ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) + if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) != pdFALSE ) { - /* The unblocked task has a priority higher than - our own so yield immediately. */ - portYIELD_WITHIN_API(); + /* The queue is a member of a queue set, and posting + to the queue set caused a higher priority task to + unblock. A context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } else { @@ -849,132 +996,43 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } else { - mtCOVERAGE_TEST_MARKER(); + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so + record that a context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } - - taskEXIT_CRITICAL(); - return pdPASS; } - else + #else /* configUSE_QUEUE_SETS */ { - if ( xTicksToWait == ( TickType_t ) 0 ) - { - taskEXIT_CRITICAL(); - return errQUEUE_FULL; - } - else if ( xEntryTimeSet == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if ( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if ( prvIsQueueFull( pxQueue ) != pdFALSE ) - { - traceBLOCKING_ON_QUEUE_SEND( pxQueue ); - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - taskEXIT_CRITICAL(); - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - } - taskEXIT_CRITICAL(); - } - } - -#endif /* configUSE_ALTERNATIVE_API */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_ALTERNATIVE_API == 1 ) - - BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking ) - { - BaseType_t xEntryTimeSet = pdFALSE; - TimeOut_t xTimeOut; - int8_t *pcOriginalReadPosition; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - - for ( ;; ) - { - taskENTER_CRITICAL(); - { - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - /* Remember our read position in case we are just peeking. */ - pcOriginalReadPosition = pxQueue->u.pcReadFrom; - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - - if ( xJustPeeking == pdFALSE ) - { - traceQUEUE_RECEIVE( pxQueue ); - - /* Data is actually being removed (not just peeked). */ - --( pxQueue->uxMessagesWaiting ); - - #if ( configUSE_MUTEXES == 1 ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { - if ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* Record the information required to implement - priority inheritance should it become necessary. */ - pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - else - { - traceQUEUE_PEEK( pxQueue ); - - /* The data is not being removed, so reset our read - pointer. */ - pxQueue->u.pcReadFrom = pcOriginalReadPosition; - - /* The data is being left in the queue, so see if there are - any other tasks waiting for the data. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + /* The task waiting has a higher priority so record that a + context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) { - /* The task waiting has a higher priority than this task. */ - portYIELD_WITHIN_API(); + *pxHigherPriorityTaskWoken = pdTRUE; } else { @@ -986,84 +1044,56 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; mtCOVERAGE_TEST_MARKER(); } } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if ( xTicksToWait == ( TickType_t ) 0 ) - { - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - else if ( xEntryTimeSet == pdFALSE ) - { - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if ( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if ( prvIsQueueEmpty( pxQueue ) != pdFALSE ) - { - traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); - - #if ( configUSE_MUTEXES == 1 ) - { - if ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - taskENTER_CRITICAL(); - { - vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - portYIELD_WITHIN_API(); - } else { mtCOVERAGE_TEST_MARKER(); } } - else - { - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } + #endif /* configUSE_QUEUE_SETS */ } - taskEXIT_CRITICAL(); + else + { + /* Increment the lock count so the task that unlocks the queue + knows that data was posted while it was locked. */ + pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 ); + } + + xReturn = pdPASS; + } + else + { + traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); + xReturn = errQUEUE_FULL; } } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - -#endif /* configUSE_ALTERNATIVE_API */ + return xReturn; +} /*-----------------------------------------------------------*/ -BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) +BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) { BaseType_t xReturn; UBaseType_t uxSavedInterruptStatus; Queue_t * const pxQueue = ( Queue_t * ) xQueue; + /* Similar to xQueueGenericSendFromISR() but used with semaphores where the + item size is 0. Don't directly wake a task that was blocked on a queue + read, instead return a flag to say whether a context switch is required or + not (i.e. has a task with a higher priority than us been woken by this + post). */ + configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); + + /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR() + if the item size is not 0. */ + configASSERT( pxQueue->uxItemSize == 0 ); + + /* Normally a mutex would not be given from an interrupt, especially if + there is a mutex holder, as priority inheritance makes no sense for an + interrupts, only tasks. */ + configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) ); /* RTOS ports that support interrupt nesting have the concept of a maximum system call (or maximum API call) interrupt priority. Interrupts that are @@ -1081,38 +1111,41 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - /* Similar to xQueueGenericSend, except without blocking if there is no room - in the queue. Also don't directly wake a task that was blocked on a queue - read, instead return a flag to say whether a context switch is required or - not (i.e. has a task with a higher priority than us been woken by this - post). */ uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { - if ( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + /* When the queue is used to implement a semaphore no data is ever + moved through the queue but it is still valid to see if the queue 'has + space'. */ + if( uxMessagesWaiting < pxQueue->uxLength ) { + const int8_t cTxLock = pxQueue->cTxLock; + traceQUEUE_SEND_FROM_ISR( pxQueue ); - /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a - semaphore or mutex. That means prvCopyDataToQueue() cannot result - in a task disinheriting a priority and prvCopyDataToQueue() can be - called here even though the disinherit function does not check if - the scheduler is suspended before accessing the ready lists. */ - ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + /* A task can only have an inherited priority if it is a mutex + holder - and if there is a mutex holder then the mutex cannot be + given from an ISR. As this is the ISR version of the function it + can be assumed there is no mutex holder and no need to determine if + priority disinheritance is needed. Simply increase the count of + messages (semaphores) available. */ + pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1; /* The event list is not altered if the queue is locked. This will be done when the queue is unlocked later. */ - if ( pxQueue->xTxLock == queueUNLOCKED ) + if( cTxLock == queueUNLOCKED ) { #if ( configUSE_QUEUE_SETS == 1 ) { - if ( pxQueue->pxQueueSetContainer != NULL ) + if( pxQueue->pxQueueSetContainer != NULL ) { - if ( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE ) + if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) != pdFALSE ) { - /* The queue is a member of a queue set, and posting - to the queue set caused a higher priority task to - unblock. A context switch is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) + /* The semaphore is a member of a queue set, and + posting to the queue set caused a higher priority + task to unblock. A context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) { *pxHigherPriorityTaskWoken = pdTRUE; } @@ -1128,13 +1161,13 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } else { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The task waiting has a higher priority so record that a context switch is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) + if( pxHigherPriorityTaskWoken != NULL ) { *pxHigherPriorityTaskWoken = pdTRUE; } @@ -1156,13 +1189,13 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } #else /* configUSE_QUEUE_SETS */ { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The task waiting has a higher priority so record that a context switch is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) + if( pxHigherPriorityTaskWoken != NULL ) { *pxHigherPriorityTaskWoken = pdTRUE; } @@ -1187,7 +1220,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; { /* Increment the lock count so the task that unlocks the queue knows that data was posted while it was locked. */ - ++( pxQueue->xTxLock ); + pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 ); } xReturn = pdPASS; @@ -1204,232 +1237,422 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } /*-----------------------------------------------------------*/ -BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) +BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) { -BaseType_t xReturn; -UBaseType_t uxSavedInterruptStatus; +BaseType_t xEntryTimeSet = pdFALSE; +TimeOut_t xTimeOut; Queue_t * const pxQueue = ( Queue_t * ) xQueue; - /* Similar to xQueueGenericSendFromISR() but used with semaphores where the - item size is 0. Don't directly wake a task that was blocked on a queue - read, instead return a flag to say whether a context switch is required or - not (i.e. has a task with a higher priority than us been woken by this - post). */ + /* Check the pointer is not NULL. */ + configASSERT( ( pxQueue ) ); - configASSERT( pxQueue ); + /* The buffer into which data is received can only be NULL if the data size + is zero (so no data is copied into the buffer. */ + configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) ); - /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR() - if the item size is not 0. */ + /* Cannot block if the scheduler is suspended. */ + #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + { + configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); + } + #endif + + + /* This function relaxes the coding standard somewhat to allow return + statements within the function itself. This is done in the interest + of execution time efficiency. */ + + for( ;; ) + { + taskENTER_CRITICAL(); + { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + /* Is there data in the queue now? To be running the calling task + must be the highest priority task wanting to access the queue. */ + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + /* Data available, remove one item. */ + prvCopyDataFromQueue( pxQueue, pvBuffer ); + traceQUEUE_RECEIVE( pxQueue ); + pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; + + /* There is now space in the queue, were any tasks waiting to + post to the queue? If so, unblock the highest priority waiting + task. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + taskEXIT_CRITICAL(); + return pdPASS; + } + else + { + if( xTicksToWait == ( TickType_t ) 0 ) + { + /* The queue was empty and no block time is specified (or + the block time has expired) so leave now. */ + taskEXIT_CRITICAL(); + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else if( xEntryTimeSet == pdFALSE ) + { + /* The queue was empty and a block time was specified so + configure the timeout structure. */ + vTaskInternalSetTimeOutState( &xTimeOut ); + xEntryTimeSet = pdTRUE; + } + else + { + /* Entry time was already set. */ + mtCOVERAGE_TEST_MARKER(); + } + } + } + taskEXIT_CRITICAL(); + + /* Interrupts and other tasks can send to and receive from the queue + now the critical section has been exited. */ + + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + + /* Update the timeout state to see if it has expired yet. */ + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + /* The timeout has not expired. If the queue is still empty place + the task on the list of tasks waiting to receive from the queue. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + prvUnlockQueue( pxQueue ); + if( xTaskResumeAll() == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* The queue contains data again. Loop back to try and read the + data. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + } + } + else + { + /* Timed out. If there is no data in the queue exit, otherwise loop + back and attempt to read the data. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) +{ +BaseType_t xEntryTimeSet = pdFALSE; +TimeOut_t xTimeOut; +Queue_t * const pxQueue = ( Queue_t * ) xQueue; + +#if( configUSE_MUTEXES == 1 ) + BaseType_t xInheritanceOccurred = pdFALSE; +#endif + + /* Check the queue pointer is not NULL. */ + configASSERT( ( pxQueue ) ); + + /* Check this really is a semaphore, in which case the item size will be + 0. */ configASSERT( pxQueue->uxItemSize == 0 ); - /* Normally a mutex would not be given from an interrupt, and doing so is - definitely wrong if there is a mutex holder as priority inheritance makes no - sense for an interrupts, only tasks. */ - configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) ); + /* Cannot block if the scheduler is suspended. */ + #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + { + configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); + } + #endif - /* RTOS ports that support interrupt nesting have the concept of a maximum - system call (or maximum API call) interrupt priority. Interrupts that are - above the maximum system call priority are kept permanently enabled, even - when the RTOS kernel is in a critical section, but cannot make any calls to - FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h - then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has been - assigned a priority above the configured maximum system call priority. - Only FreeRTOS functions that end in FromISR can be called from interrupts - that have been assigned a priority at or (logically) below the maximum - system call interrupt priority. FreeRTOS maintains a separate interrupt - safe API to ensure interrupt entry is as fast and as simple as possible. - More information (albeit Cortex-M specific) is provided on the following - link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* When the queue is used to implement a semaphore no data is ever - moved through the queue but it is still valid to see if the queue 'has - space'. */ - if ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - traceQUEUE_SEND_FROM_ISR( pxQueue ); + /* This function relaxes the coding standard somewhat to allow return + statements within the function itself. This is done in the interest + of execution time efficiency. */ + + for( ;; ) + { + taskENTER_CRITICAL(); + { + /* Semaphores are queues with an item size of 0, and where the + number of messages in the queue is the semaphore's count value. */ + const UBaseType_t uxSemaphoreCount = pxQueue->uxMessagesWaiting; + + /* Is there data in the queue now? To be running the calling task + must be the highest priority task wanting to access the queue. */ + if( uxSemaphoreCount > ( UBaseType_t ) 0 ) + { + traceQUEUE_RECEIVE( pxQueue ); + + /* Semaphores are queues with a data size of zero and where the + messages waiting is the semaphore's count. Reduce the count. */ + pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1; + + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + /* Record the information required to implement + priority inheritance should it become necessary. */ + pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_MUTEXES */ + + /* Check to see if other tasks are blocked waiting to give the + semaphore, and if so, unblock the highest priority such task. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + taskEXIT_CRITICAL(); + return pdPASS; + } + else + { + if( xTicksToWait == ( TickType_t ) 0 ) + { + /* For inheritance to have occurred there must have been an + initial timeout, and an adjusted timeout cannot become 0, as + if it were 0 the function would have exited. */ + #if( configUSE_MUTEXES == 1 ) + { + configASSERT( xInheritanceOccurred == pdFALSE ); + } + #endif /* configUSE_MUTEXES */ + + /* The semaphore count was 0 and no block time is specified + (or the block time has expired) so exit now. */ + taskEXIT_CRITICAL(); + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else if( xEntryTimeSet == pdFALSE ) + { + /* The semaphore count was 0 and a block time was specified + so configure the timeout structure ready to block. */ + vTaskInternalSetTimeOutState( &xTimeOut ); + xEntryTimeSet = pdTRUE; + } + else + { + /* Entry time was already set. */ + mtCOVERAGE_TEST_MARKER(); + } + } + } + taskEXIT_CRITICAL(); + + /* Interrupts and other tasks can give to and take from the semaphore + now the critical section has been exited. */ - /* A task can only have an inherited priority if it is a mutex - holder - and if there is a mutex holder then the mutex cannot be - given from an ISR. As this is the ISR version of the function it - can be assumed there is no mutex holder and no need to determine if - priority disinheritance is needed. Simply increase the count of - messages (semaphores) available. */ - ++( pxQueue->uxMessagesWaiting ); + vTaskSuspendAll(); + prvLockQueue( pxQueue ); - /* The event list is not altered if the queue is locked. This will - be done when the queue is unlocked later. */ - if ( pxQueue->xTxLock == queueUNLOCKED ) + /* Update the timeout state to see if it has expired yet. */ + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + /* A block time is specified and not expired. If the semaphore + count is 0 then enter the Blocked state to wait for a semaphore to + become available. As semaphores are implemented with queues the + queue being empty is equivalent to the semaphore count being 0. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) { - #if ( configUSE_QUEUE_SETS == 1 ) + traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); + + #if ( configUSE_MUTEXES == 1 ) { - if ( pxQueue->pxQueueSetContainer != NULL ) + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) { - if ( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE ) - { - /* The semaphore is a member of a queue set, and - posting to the queue set caused a higher priority - task to unblock. A context switch is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else + taskENTER_CRITICAL(); { - mtCOVERAGE_TEST_MARKER(); + xInheritanceOccurred = xTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); } + taskEXIT_CRITICAL(); } else { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so - record that a context switch is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + mtCOVERAGE_TEST_MARKER(); } } - #else /* configUSE_QUEUE_SETS */ + #endif + + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + prvUnlockQueue( pxQueue ); + if( xTaskResumeAll() == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* There was no timeout and the semaphore count was not 0, so + attempt to take the semaphore again. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + } + } + else + { + /* Timed out. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + + /* If the semaphore count is 0 exit now as the timeout has + expired. Otherwise return to attempt to take the semaphore that is + known to be available. As semaphores are implemented by queues the + queue being empty is equivalent to the semaphore count being 0. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + #if ( configUSE_MUTEXES == 1 ) { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + /* xInheritanceOccurred could only have be set if + pxQueue->uxQueueType == queueQUEUE_IS_MUTEX so no need to + test the mutex type again to check it is actually a mutex. */ + if( xInheritanceOccurred != pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else + taskENTER_CRITICAL(); { - mtCOVERAGE_TEST_MARKER(); + UBaseType_t uxHighestWaitingPriority; + + /* This task blocking on the mutex caused another + task to inherit this task's priority. Now this task + has timed out the priority should be disinherited + again, but only as low as the next highest priority + task that is waiting for the same mutex. */ + uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue ); + vTaskPriorityDisinheritAfterTimeout( ( void * ) pxQueue->pxMutexHolder, uxHighestWaitingPriority ); } - } - else - { - mtCOVERAGE_TEST_MARKER(); + taskEXIT_CRITICAL(); } } - #endif /* configUSE_QUEUE_SETS */ + #endif /* configUSE_MUTEXES */ + + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; } else { - /* Increment the lock count so the task that unlocks the queue - knows that data was posted while it was locked. */ - ++( pxQueue->xTxLock ); + mtCOVERAGE_TEST_MARKER(); } - - xReturn = pdPASS; - } - else - { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); - xReturn = errQUEUE_FULL; } } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; } /*-----------------------------------------------------------*/ -BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeeking ) +BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) { BaseType_t xEntryTimeSet = pdFALSE; TimeOut_t xTimeOut; int8_t *pcOriginalReadPosition; Queue_t * const pxQueue = ( Queue_t * ) xQueue; - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + /* Check the pointer is not NULL. */ + configASSERT( ( pxQueue ) ); + + /* The buffer into which data is received can only be NULL if the data size + is zero (so no data is copied into the buffer. */ + configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) ); + + /* Cannot block if the scheduler is suspended. */ #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) { configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); } #endif + /* This function relaxes the coding standard somewhat to allow return statements within the function itself. This is done in the interest of execution time efficiency. */ - for ( ;; ) + for( ;; ) { taskENTER_CRITICAL(); { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + /* Is there data in the queue now? To be running the calling task - must be the highest priority task wanting to access the queue. */ - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + must be the highest priority task wanting to access the queue. */ + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) { - /* Remember the read position in case the queue is only being - peeked. */ + /* Remember the read position so it can be reset after the data + is read from the queue as this function is only peeking the + data, not removing it. */ pcOriginalReadPosition = pxQueue->u.pcReadFrom; prvCopyDataFromQueue( pxQueue, pvBuffer ); + traceQUEUE_PEEK( pxQueue ); - if ( xJustPeeking == pdFALSE ) - { - traceQUEUE_RECEIVE( pxQueue ); - - /* Actually removing data, not just peeking. */ - --( pxQueue->uxMessagesWaiting ); - - #if ( configUSE_MUTEXES == 1 ) - { - if ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* Record the information required to implement - priority inheritance should it become necessary. */ - pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_MUTEXES */ + /* The data is not being removed, so reset the read pointer. */ + pxQueue->u.pcReadFrom = pcOriginalReadPosition; - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + /* The data is being left in the queue, so see if there are + any other tasks waiting for the data. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + /* The task waiting has a higher priority than this task. */ + queueYIELD_IF_USING_PREEMPTION(); } else { @@ -1438,30 +1661,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } else { - traceQUEUE_PEEK( pxQueue ); - - /* The data is not being removed, so reset the read - pointer. */ - pxQueue->u.pcReadFrom = pcOriginalReadPosition; - - /* The data is being left in the queue, so see if there are - any other tasks waiting for the data. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than this task. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + mtCOVERAGE_TEST_MARKER(); } taskEXIT_CRITICAL(); @@ -1469,19 +1669,20 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } else { - if ( xTicksToWait == ( TickType_t ) 0 ) + if( xTicksToWait == ( TickType_t ) 0 ) { /* The queue was empty and no block time is specified (or the block time has expired) so leave now. */ taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); + traceQUEUE_PEEK_FAILED( pxQueue ); return errQUEUE_EMPTY; } - else if ( xEntryTimeSet == pdFALSE ) + else if( xEntryTimeSet == pdFALSE ) { /* The queue was empty and a block time was specified so - configure the timeout structure. */ - vTaskSetTimeOutState( &xTimeOut ); + configure the timeout structure ready to enter the blocked + state. */ + vTaskInternalSetTimeOutState( &xTimeOut ); xEntryTimeSet = pdTRUE; } else @@ -1500,32 +1701,16 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; prvLockQueue( pxQueue ); /* Update the timeout state to see if it has expired yet. */ - if ( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) { - if ( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + /* Timeout has not expired yet, check to see if there is data in the + queue now, and if not enter the Blocked state to wait for data. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) { - traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); - - #if ( configUSE_MUTEXES == 1 ) - { - if ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - taskENTER_CRITICAL(); - { - vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - + traceBLOCKING_ON_QUEUE_PEEK( pxQueue ); vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); prvUnlockQueue( pxQueue ); - if ( xTaskResumeAll() == pdFALSE ) + if( xTaskResumeAll() == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -1536,17 +1721,28 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } else { - /* Try again. */ + /* There is data in the queue now, so don't enter the blocked + state, instead return to try and obtain the data. */ prvUnlockQueue( pxQueue ); ( void ) xTaskResumeAll(); } } else { + /* The timeout has expired. If there is still no data in the queue + exit, otherwise go back and try to read the data again. */ prvUnlockQueue( pxQueue ); ( void ) xTaskResumeAll(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; + + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceQUEUE_PEEK_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } } } @@ -1579,27 +1775,31 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + /* Cannot block in an ISR, so check there is data available. */ - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) { + const int8_t cRxLock = pxQueue->cRxLock; + traceQUEUE_RECEIVE_FROM_ISR( pxQueue ); prvCopyDataFromQueue( pxQueue, pvBuffer ); - --( pxQueue->uxMessagesWaiting ); + pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; /* If the queue is locked the event list will not be modified. Instead update the lock count so the task that unlocks the queue will know that an ISR has removed data while the queue was locked. */ - if ( pxQueue->xRxLock == queueUNLOCKED ) + if( cRxLock == queueUNLOCKED ) { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) { /* The task waiting has a higher priority than us so force a context switch. */ - if ( pxHigherPriorityTaskWoken != NULL ) + if( pxHigherPriorityTaskWoken != NULL ) { *pxHigherPriorityTaskWoken = pdTRUE; } @@ -1622,7 +1822,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; { /* Increment the lock count so the task that unlocks the queue knows that data was removed while it was locked. */ - ++( pxQueue->xRxLock ); + pxQueue->cRxLock = ( int8_t ) ( cRxLock + 1 ); } xReturn = pdPASS; @@ -1669,7 +1869,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { /* Cannot block in an ISR, so check there is data available. */ - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) { traceQUEUE_PEEK_FROM_ISR( pxQueue ); @@ -1744,14 +1944,40 @@ void vQueueDelete( QueueHandle_t xQueue ) Queue_t * const pxQueue = ( Queue_t * ) xQueue; configASSERT( pxQueue ); - traceQUEUE_DELETE( pxQueue ); + #if ( configQUEUE_REGISTRY_SIZE > 0 ) { vQueueUnregisterQueue( pxQueue ); } #endif - vPortFree( pxQueue ); + + #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) + { + /* The queue can only have been allocated dynamically - free it + again. */ + vPortFree( pxQueue ); + } + #elif( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + { + /* The queue could have been allocated statically or dynamically, so + check before attempting to free the memory. */ + if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdFALSE ) + { + vPortFree( pxQueue ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #else + { + /* The queue must have been statically allocated, so is not going to be + deleted. Avoid compiler warnings about the unused parameter. */ + ( void ) pxQueue; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ } /*-----------------------------------------------------------*/ @@ -1785,15 +2011,47 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; #endif /* configUSE_TRACE_FACILITY */ /*-----------------------------------------------------------*/ +#if( configUSE_MUTEXES == 1 ) + + static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue ) + { + UBaseType_t uxHighestPriorityOfWaitingTasks; + + /* If a task waiting for a mutex causes the mutex holder to inherit a + priority, but the waiting task times out, then the holder should + disinherit the priority - but only down to the highest priority of any + other tasks that are waiting for the same mutex. For this purpose, + return the priority of the highest priority task that is waiting for the + mutex. */ + if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0 ) + { + uxHighestPriorityOfWaitingTasks = configMAX_PRIORITIES - listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) ); + } + else + { + uxHighestPriorityOfWaitingTasks = tskIDLE_PRIORITY; + } + + return uxHighestPriorityOfWaitingTasks; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) { BaseType_t xReturn = pdFALSE; +UBaseType_t uxMessagesWaiting; + + /* This function is called from a critical section. */ - if ( pxQueue->uxItemSize == ( UBaseType_t ) 0 ) + uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + if( pxQueue->uxItemSize == ( UBaseType_t ) 0 ) { #if ( configUSE_MUTEXES == 1 ) { - if ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) { /* The mutex is no longer being held. */ xReturn = xTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder ); @@ -1806,11 +2064,11 @@ BaseType_t xReturn = pdFALSE; } #endif /* configUSE_MUTEXES */ } - else if ( xPosition == queueSEND_TO_BACK ) + else if( xPosition == queueSEND_TO_BACK ) { ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. */ pxQueue->pcWriteTo += pxQueue->uxItemSize; - if ( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ + if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ { pxQueue->pcWriteTo = pxQueue->pcHead; } @@ -1823,7 +2081,7 @@ BaseType_t xReturn = pdFALSE; { ( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ pxQueue->u.pcReadFrom -= pxQueue->uxItemSize; - if ( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ + if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ { pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize ); } @@ -1832,15 +2090,15 @@ BaseType_t xReturn = pdFALSE; mtCOVERAGE_TEST_MARKER(); } - if ( xPosition == queueOVERWRITE ) + if( xPosition == queueOVERWRITE ) { - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) { /* An item is not being added but overwritten, so subtract one from the recorded number of items in the queue so when one is added again below the number of recorded items remains correct. */ - --( pxQueue->uxMessagesWaiting ); + --uxMessagesWaiting; } else { @@ -1853,7 +2111,7 @@ BaseType_t xReturn = pdFALSE; } } - ++( pxQueue->uxMessagesWaiting ); + pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1; return xReturn; } @@ -1861,10 +2119,10 @@ BaseType_t xReturn = pdFALSE; static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer ) { - if ( pxQueue->uxItemSize != ( UBaseType_t ) 0 ) + if( pxQueue->uxItemSize != ( UBaseType_t ) 0 ) { pxQueue->u.pcReadFrom += pxQueue->uxItemSize; - if ( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */ + if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */ { pxQueue->u.pcReadFrom = pxQueue->pcHead; } @@ -1887,16 +2145,18 @@ static void prvUnlockQueue( Queue_t * const pxQueue ) updated. */ taskENTER_CRITICAL(); { + int8_t cTxLock = pxQueue->cTxLock; + /* See if data was added to the queue while it was locked. */ - while ( pxQueue->xTxLock > queueLOCKED_UNMODIFIED ) + while( cTxLock > queueLOCKED_UNMODIFIED ) { /* Data was posted while the queue was locked. Are any tasks blocked waiting for data to become available? */ #if ( configUSE_QUEUE_SETS == 1 ) { - if ( pxQueue->pxQueueSetContainer != NULL ) + if( pxQueue->pxQueueSetContainer != NULL ) { - if ( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE ) + if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) != pdFALSE ) { /* The queue is a member of a queue set, and posting to the queue set caused a higher priority task to unblock. @@ -1910,11 +2170,12 @@ static void prvUnlockQueue( Queue_t * const pxQueue ) } else { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + /* Tasks that are removed from the event list will get + added to the pending ready list as the scheduler is still + suspended. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The task waiting has a higher priority so record that a context switch is required. */ @@ -1935,12 +2196,12 @@ static void prvUnlockQueue( Queue_t * const pxQueue ) { /* Tasks that are removed from the event list will get added to the pending ready list as the scheduler is still suspended. */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { - /* The task waiting has a higher priority so record that a - context switch is required. */ + /* The task waiting has a higher priority so record that + a context switch is required. */ vTaskMissedYield(); } else @@ -1955,21 +2216,23 @@ static void prvUnlockQueue( Queue_t * const pxQueue ) } #endif /* configUSE_QUEUE_SETS */ - --( pxQueue->xTxLock ); + --cTxLock; } - pxQueue->xTxLock = queueUNLOCKED; + pxQueue->cTxLock = queueUNLOCKED; } taskEXIT_CRITICAL(); /* Do the same for the Rx lock. */ taskENTER_CRITICAL(); { - while ( pxQueue->xRxLock > queueLOCKED_UNMODIFIED ) + int8_t cRxLock = pxQueue->cRxLock; + + while( cRxLock > queueLOCKED_UNMODIFIED ) { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) { vTaskMissedYield(); } @@ -1978,7 +2241,7 @@ static void prvUnlockQueue( Queue_t * const pxQueue ) mtCOVERAGE_TEST_MARKER(); } - --( pxQueue->xRxLock ); + --cRxLock; } else { @@ -1986,7 +2249,7 @@ static void prvUnlockQueue( Queue_t * const pxQueue ) } } - pxQueue->xRxLock = queueUNLOCKED; + pxQueue->cRxLock = queueUNLOCKED; } taskEXIT_CRITICAL(); } @@ -1998,7 +2261,7 @@ BaseType_t xReturn; taskENTER_CRITICAL(); { - if ( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) { xReturn = pdTRUE; } @@ -2018,7 +2281,7 @@ BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) BaseType_t xReturn; configASSERT( xQueue ); - if ( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 ) + if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 ) { xReturn = pdTRUE; } @@ -2037,7 +2300,7 @@ BaseType_t xReturn; taskENTER_CRITICAL(); { - if ( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) + if( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) { xReturn = pdTRUE; } @@ -2057,7 +2320,7 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) BaseType_t xReturn; configASSERT( xQueue ); - if ( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength ) + if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength ) { xReturn = pdTRUE; } @@ -2082,11 +2345,11 @@ BaseType_t xReturn; between the check to see if the queue is full and blocking on the queue. */ portDISABLE_INTERRUPTS(); { - if ( prvIsQueueFull( pxQueue ) != pdFALSE ) + if( prvIsQueueFull( pxQueue ) != pdFALSE ) { /* The queue is full - do we want to block or just leave without posting? */ - if ( xTicksToWait > ( TickType_t ) 0 ) + if( xTicksToWait > ( TickType_t ) 0 ) { /* As this is called from a coroutine we cannot block directly, but return indicating that we need to block. */ @@ -2105,20 +2368,20 @@ BaseType_t xReturn; portDISABLE_INTERRUPTS(); { - if ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) { /* There is room in the queue, copy the data into the queue. */ prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); xReturn = pdPASS; /* Were any co-routines waiting for data to become available? */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { /* In this instance the co-routine could be placed directly into the ready list as we are within a critical section. Instead the same pending ready list mechanism is used as if the event were caused from within an interrupt. */ - if ( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The co-routine waiting has a higher priority so record that a yield might be appropriate. */ @@ -2159,11 +2422,11 @@ BaseType_t xReturn; between the check to see if the queue is empty and blocking on the queue. */ portDISABLE_INTERRUPTS(); { - if ( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) { /* There are no messages in the queue, do we want to block or just leave with nothing? */ - if ( xTicksToWait > ( TickType_t ) 0 ) + if( xTicksToWait > ( TickType_t ) 0 ) { /* As this is a co-routine we cannot block directly, but return indicating that we need to block. */ @@ -2186,11 +2449,11 @@ BaseType_t xReturn; portDISABLE_INTERRUPTS(); { - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) { /* Data is available from the queue. */ pxQueue->u.pcReadFrom += pxQueue->uxItemSize; - if ( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) + if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) { pxQueue->u.pcReadFrom = pxQueue->pcHead; } @@ -2204,13 +2467,13 @@ BaseType_t xReturn; xReturn = pdPASS; /* Were any co-routines waiting for space to become available? */ - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { /* In this instance the co-routine could be placed directly into the ready list as we are within a critical section. Instead the same pending ready list mechanism is used as if the event were caused from within an interrupt. */ - if ( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) { xReturn = errQUEUE_YIELD; } @@ -2245,17 +2508,17 @@ BaseType_t xReturn; /* Cannot block within an ISR so if there is no space on the queue then exit without doing anything. */ - if ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) { prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); /* We only want to wake one co-routine per ISR, so check that a co-routine has not already been woken. */ - if ( xCoRoutinePreviouslyWoken == pdFALSE ) + if( xCoRoutinePreviouslyWoken == pdFALSE ) { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { return pdTRUE; } @@ -2294,11 +2557,11 @@ BaseType_t xReturn; /* We cannot block from an ISR, so check there is data available. If not then just leave without doing anything. */ - if ( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) { /* Copy the data from the queue. */ pxQueue->u.pcReadFrom += pxQueue->uxItemSize; - if ( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) + if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) { pxQueue->u.pcReadFrom = pxQueue->pcHead; } @@ -2309,11 +2572,11 @@ BaseType_t xReturn; --( pxQueue->uxMessagesWaiting ); ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); - if ( ( *pxCoRoutineWoken ) == pdFALSE ) + if( ( *pxCoRoutineWoken ) == pdFALSE ) { - if ( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { - if ( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) { *pxCoRoutineWoken = pdTRUE; } @@ -2353,9 +2616,9 @@ BaseType_t xReturn; /* See if there is an empty space in the registry. A NULL name denotes a free slot. */ - for ( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) { - if ( xQueueRegistry[ ux ].pcQueueName == NULL ) + if( xQueueRegistry[ ux ].pcQueueName == NULL ) { /* Store the information on this queue. */ xQueueRegistry[ ux ].pcQueueName = pcQueueName; @@ -2374,6 +2637,34 @@ BaseType_t xReturn; #endif /* configQUEUE_REGISTRY_SIZE */ /*-----------------------------------------------------------*/ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + + const char *pcQueueGetName( QueueHandle_t xQueue ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + { + UBaseType_t ux; + const char *pcReturn = NULL; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + + /* Note there is nothing here to protect against another task adding or + removing entries from the registry while it is being searched. */ + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) + { + if( xQueueRegistry[ ux ].xHandle == xQueue ) + { + pcReturn = xQueueRegistry[ ux ].pcQueueName; + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + return pcReturn; + } /*lint !e818 xQueue cannot be a pointer to const because it is a typedef. */ + +#endif /* configQUEUE_REGISTRY_SIZE */ +/*-----------------------------------------------------------*/ + #if ( configQUEUE_REGISTRY_SIZE > 0 ) void vQueueUnregisterQueue( QueueHandle_t xQueue ) @@ -2382,12 +2673,17 @@ BaseType_t xReturn; /* See if the handle of the queue being unregistered in actually in the registry. */ - for ( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) { - if ( xQueueRegistry[ ux ].xHandle == xQueue ) + if( xQueueRegistry[ ux ].xHandle == xQueue ) { /* Set the name to NULL to show that this slot if free again. */ xQueueRegistry[ ux ].pcQueueName = NULL; + + /* Set the handle to NULL to ensure the same queue handle cannot + appear in the registry twice if it is added, removed, then + added again. */ + xQueueRegistry[ ux ].xHandle = ( QueueHandle_t ) 0; break; } else @@ -2403,7 +2699,7 @@ BaseType_t xReturn; #if ( configUSE_TIMERS == 1 ) - void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait ) + void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) { Queue_t * const pxQueue = ( Queue_t * ) xQueue; @@ -2422,10 +2718,10 @@ BaseType_t xReturn; the queue is locked, and the calling task blocks on the queue, then the calling task will be immediately unblocked when the queue is unlocked. */ prvLockQueue( pxQueue ); - if ( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U ) + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U ) { /* There is nothing in the queue, block for the specified period. */ - vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait, xWaitIndefinitely ); } else { @@ -2437,13 +2733,13 @@ BaseType_t xReturn; #endif /* configUSE_TIMERS */ /*-----------------------------------------------------------*/ -#if ( configUSE_QUEUE_SETS == 1 ) +#if( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) { QueueSetHandle_t pxQueue; - pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( Queue_t * ), queueQUEUE_TYPE_SET ); + pxQueue = xQueueGenericCreate( uxEventQueueLength, ( UBaseType_t ) sizeof( Queue_t * ), queueQUEUE_TYPE_SET ); return pxQueue; } @@ -2459,12 +2755,12 @@ BaseType_t xReturn; taskENTER_CRITICAL(); { - if ( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL ) + if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL ) { /* Cannot add a queue/semaphore to more than one queue set. */ xReturn = pdFAIL; } - else if ( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 ) + else if( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 ) { /* Cannot add a queue/semaphore to a queue set if there are already items in the queue/semaphore. */ @@ -2491,12 +2787,12 @@ BaseType_t xReturn; BaseType_t xReturn; Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore; - if ( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet ) + if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet ) { /* The queue was not a member of the set. */ xReturn = pdFAIL; } - else if ( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 ) + else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 ) { /* It is dangerous to remove a queue from a set when the queue is not empty because the queue set will still hold pending events for @@ -2526,7 +2822,7 @@ BaseType_t xReturn; { QueueSetMemberHandle_t xReturn = NULL; - ( void ) xQueueGenericReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait, pdFALSE ); /*lint !e961 Casting from one typedef to another is not redundant. */ + ( void ) xQueueReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait ); /*lint !e961 Casting from one typedef to another is not redundant. */ return xReturn; } @@ -2558,18 +2854,20 @@ BaseType_t xReturn; configASSERT( pxQueueSetContainer ); configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ); - if ( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ) + if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ) { + const int8_t cTxLock = pxQueueSetContainer->cTxLock; + traceQUEUE_SEND( pxQueueSetContainer ); /* The data copied is the handle of the queue that contains data. */ xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition ); - if ( pxQueueSetContainer->xTxLock == queueUNLOCKED ) + if( cTxLock == queueUNLOCKED ) { - if ( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE ) + if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE ) { - if ( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE ) + if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The task waiting has a higher priority. */ xReturn = pdTRUE; @@ -2586,7 +2884,7 @@ BaseType_t xReturn; } else { - ( pxQueueSetContainer->xTxLock )++; + pxQueueSetContainer->cTxLock = ( int8_t ) ( cTxLock + 1 ); } } else diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/readme.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/readme.txt similarity index 88% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/readme.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/readme.txt index a54da50..58480c5 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/readme.txt +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/readme.txt @@ -1,17 +1,17 @@ Each real time kernel port consists of three files that contain the core kernel -components and are common to every port, and one or more files that are +components and are common to every port, and one or more files that are specific to a particular microcontroller and or compiler. -+ The FreeRTOS/Source directory contains the three files that are common to -every port - list.c, queue.c and tasks.c. The kernel is contained within these ++ The FreeRTOS/Source directory contains the three files that are common to +every port - list.c, queue.c and tasks.c. The kernel is contained within these three files. croutine.c implements the optional co-routine functionality - which is normally only used on very memory limited systems. -+ The FreeRTOS/Source/Portable directory contains the files that are specific to ++ The FreeRTOS/Source/Portable directory contains the files that are specific to a particular microcontroller and or compiler. -+ The FreeRTOS/Source/include directory contains the real time kernel header ++ The FreeRTOS/Source/include directory contains the real time kernel header files. -See the readme file in the FreeRTOS/Source/Portable directory for more -information. +See the readme file in the FreeRTOS/Source/Portable directory for more +information. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/stream_buffer.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/stream_buffer.c new file mode 100644 index 0000000..f51a144 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/stream_buffer.c @@ -0,0 +1,1196 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "stream_buffer.h" + +/* Lint e961 and e750 are suppressed as a MISRA exception justified because the +MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the +header files above, but not in this file, in order to generate the correct +privileged Vs unprivileged linkage and placement. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ + +/* If the user has not provided application specific Rx notification macros, +or #defined the notification macros away, them provide default implementations +that uses task notifications. */ +/*lint -save -e9026 Function like macros allowed and needed here so they can be overidden. */ +#ifndef sbRECEIVE_COMPLETED + #define sbRECEIVE_COMPLETED( pxStreamBuffer ) \ + vTaskSuspendAll(); \ + { \ + if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL ) \ + { \ + ( void ) xTaskNotify( ( pxStreamBuffer )->xTaskWaitingToSend, \ + ( uint32_t ) 0, \ + eNoAction ); \ + ( pxStreamBuffer )->xTaskWaitingToSend = NULL; \ + } \ + } \ + ( void ) xTaskResumeAll(); +#endif /* sbRECEIVE_COMPLETED */ + +#ifndef sbRECEIVE_COMPLETED_FROM_ISR + #define sbRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, \ + pxHigherPriorityTaskWoken ) \ + { \ + UBaseType_t uxSavedInterruptStatus; \ + \ + uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); \ + { \ + if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL ) \ + { \ + ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToSend, \ + ( uint32_t ) 0, \ + eNoAction, \ + pxHigherPriorityTaskWoken ); \ + ( pxStreamBuffer )->xTaskWaitingToSend = NULL; \ + } \ + } \ + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ + } +#endif /* sbRECEIVE_COMPLETED_FROM_ISR */ + +/* If the user has not provided an application specific Tx notification macro, +or #defined the notification macro away, them provide a default implementation +that uses task notifications. */ +#ifndef sbSEND_COMPLETED + #define sbSEND_COMPLETED( pxStreamBuffer ) \ + vTaskSuspendAll(); \ + { \ + if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL ) \ + { \ + ( void ) xTaskNotify( ( pxStreamBuffer )->xTaskWaitingToReceive, \ + ( uint32_t ) 0, \ + eNoAction ); \ + ( pxStreamBuffer )->xTaskWaitingToReceive = NULL; \ + } \ + } \ + ( void ) xTaskResumeAll(); +#endif /* sbSEND_COMPLETED */ + +#ifndef sbSEND_COMPLETE_FROM_ISR + #define sbSEND_COMPLETE_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken ) \ + { \ + UBaseType_t uxSavedInterruptStatus; \ + \ + uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); \ + { \ + if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL ) \ + { \ + ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToReceive, \ + ( uint32_t ) 0, \ + eNoAction, \ + pxHigherPriorityTaskWoken ); \ + ( pxStreamBuffer )->xTaskWaitingToReceive = NULL; \ + } \ + } \ + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ + } +#endif /* sbSEND_COMPLETE_FROM_ISR */ +/*lint -restore (9026) */ + +/* The number of bytes used to hold the length of a message in the buffer. */ +#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) ) + +/* Bits stored in the ucFlags field of the stream buffer. */ +#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */ +#define sbFLAGS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 2 ) /* Set if the stream buffer was created using statically allocated memory. */ + +/*-----------------------------------------------------------*/ + +/* Structure that hold state information on the buffer. */ +typedef struct xSTREAM_BUFFER /*lint !e9058 Style convention uses tag. */ +{ + volatile size_t xTail; /* Index to the next item to read within the buffer. */ + volatile size_t xHead; /* Index to the next item to write within the buffer. */ + size_t xLength; /* The length of the buffer pointed to by pucBuffer. */ + size_t xTriggerLevelBytes; /* The number of bytes that must be in the stream buffer before a task that is waiting for data is unblocked. */ + volatile TaskHandle_t xTaskWaitingToReceive; /* Holds the handle of a task waiting for data, or NULL if no tasks are waiting. */ + volatile TaskHandle_t xTaskWaitingToSend; /* Holds the handle of a task waiting to send data to a message buffer that is full. */ + uint8_t *pucBuffer; /* Points to the buffer itself - that is - the RAM that stores the data passed through the buffer. */ + uint8_t ucFlags; + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxStreamBufferNumber; /* Used for tracing purposes. */ + #endif +} StreamBuffer_t; + +/* + * The number of bytes available to be read from the buffer. + */ +static size_t prvBytesInBuffer( const StreamBuffer_t * const pxStreamBuffer ) PRIVILEGED_FUNCTION; + +/* + * Add xCount bytes from pucData into the pxStreamBuffer message buffer. + * Returns the number of bytes written, which will either equal xCount in the + * success case, or 0 if there was not enough space in the buffer (in which case + * no data is written into the buffer). + */ +static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, const uint8_t *pucData, size_t xCount ) PRIVILEGED_FUNCTION; + +/* + * If the stream buffer is being used as a message buffer, then reads an entire + * message out of the buffer. If the stream buffer is being used as a stream + * buffer then read as many bytes as possible from the buffer. + * prvReadBytesFromBuffer() is called to actually extract the bytes from the + * buffer's data storage area. + */ +static size_t prvReadMessageFromBuffer( StreamBuffer_t *pxStreamBuffer, + void *pvRxData, + size_t xBufferLengthBytes, + size_t xBytesAvailable, + size_t xBytesToStoreMessageLength ) PRIVILEGED_FUNCTION; + +/* + * If the stream buffer is being used as a message buffer, then writes an entire + * message to the buffer. If the stream buffer is being used as a stream + * buffer then write as many bytes as possible to the buffer. + * prvWriteBytestoBuffer() is called to actually send the bytes to the buffer's + * data storage area. + */ +static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer, + const void * pvTxData, + size_t xDataLengthBytes, + size_t xSpace, + size_t xRequiredSpace ) PRIVILEGED_FUNCTION; + +/* + * Read xMaxCount bytes from the pxStreamBuffer message buffer and write them + * to pucData. + */ +static size_t prvReadBytesFromBuffer( StreamBuffer_t *pxStreamBuffer, + uint8_t *pucData, + size_t xMaxCount, + size_t xBytesAvailable ); PRIVILEGED_FUNCTION + +/* + * Called by both pxStreamBufferCreate() and pxStreamBufferCreateStatic() to + * initialise the members of the newly created stream buffer structure. + */ +static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer, + uint8_t * const pucBuffer, + size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; + +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + + StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ) + { + uint8_t *pucAllocatedMemory; + + /* In case the stream buffer is going to be used as a message buffer + (that is, it will hold discrete messages with a little meta data that + says how big the next message is) check the buffer will be large enough + to hold at least one message. */ + configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH ); + configASSERT( xTriggerLevelBytes <= xBufferSizeBytes ); + + /* A trigger level of 0 would cause a waiting task to unblock even when + the buffer was empty. */ + if( xTriggerLevelBytes == ( size_t ) 0 ) + { + xTriggerLevelBytes = ( size_t ) 1; /*lint !e9044 Parameter modified to ensure it doesn't have a dangerous value. */ + } + + /* A stream buffer requires a StreamBuffer_t structure and a buffer. + Both are allocated in a single call to pvPortMalloc(). The + StreamBuffer_t structure is placed at the start of the allocated memory + and the buffer follows immediately after. The requested size is + incremented so the free space is returned as the user would expect - + this is a quirk of the implementation that means otherwise the free + space would be reported as one byte smaller than would be logically + expected. */ + xBufferSizeBytes++; + pucAllocatedMemory = ( uint8_t * ) pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) ); /*lint !e9079 malloc() only returns void*. */ + + if( pucAllocatedMemory != NULL ) + { + prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */ + pucAllocatedMemory + sizeof( StreamBuffer_t ), /* Storage area follows. */ /*lint !e9016 Indexing past structure valid for uint8_t pointer, also storage area has no alignment requirement. */ + xBufferSizeBytes, + xTriggerLevelBytes, + xIsMessageBuffer ); + + traceSTREAM_BUFFER_CREATE( ( ( StreamBuffer_t * ) pucAllocatedMemory ), xIsMessageBuffer ); + } + else + { + traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ); + } + + return ( StreamBufferHandle_t * ) pucAllocatedMemory; /*lint !e9087 !e826 Safe cast as allocated memory is aligned. */ + } + +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + + StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) + { + StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) pxStaticStreamBuffer; /*lint !e740 !e9087 Safe cast as StaticStreamBuffer_t is opaque Streambuffer_t. */ + StreamBufferHandle_t xReturn; + + configASSERT( pucStreamBufferStorageArea ); + configASSERT( pxStaticStreamBuffer ); + configASSERT( xTriggerLevelBytes <= xBufferSizeBytes ); + + /* A trigger level of 0 would cause a waiting task to unblock even when + the buffer was empty. */ + if( xTriggerLevelBytes == ( size_t ) 0 ) + { + xTriggerLevelBytes = ( size_t ) 1; /*lint !e9044 Function parameter deliberately modified to ensure it is in range. */ + } + + /* In case the stream buffer is going to be used as a message buffer + (that is, it will hold discrete messages with a little meta data that + says how big the next message is) check the buffer will be large enough + to hold at least one message. */ + configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH ); + + #if( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + variable of type StaticStreamBuffer_t equals the size of the real + message buffer structure. */ + volatile size_t xSize = sizeof( StaticStreamBuffer_t ); + configASSERT( xSize == sizeof( StreamBuffer_t ) ); + } + #endif /* configASSERT_DEFINED */ + + if( ( pucStreamBufferStorageArea != NULL ) && ( pxStaticStreamBuffer != NULL ) ) + { + prvInitialiseNewStreamBuffer( pxStreamBuffer, + pucStreamBufferStorageArea, + xBufferSizeBytes, + xTriggerLevelBytes, + xIsMessageBuffer ); + + /* Remember this was statically allocated in case it is ever deleted + again. */ + pxStreamBuffer->ucFlags |= sbFLAGS_IS_STATICALLY_ALLOCATED; + + traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ); + + xReturn = ( StreamBufferHandle_t ) pxStaticStreamBuffer; /*lint !e9087 Data hiding requires cast to opaque type. */ + } + else + { + xReturn = NULL; + traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ); + } + + return xReturn; + } + +#endif /* ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ +/*-----------------------------------------------------------*/ + +void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) +{ +StreamBuffer_t * pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ + + configASSERT( pxStreamBuffer ); + + traceSTREAM_BUFFER_DELETE( xStreamBuffer ); + + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) pdFALSE ) + { + #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + { + /* Both the structure and the buffer were allocated using a single call + to pvPortMalloc(), hence only one call to vPortFree() is required. */ + vPortFree( ( void * ) pxStreamBuffer ); /*lint !e9087 Standard free() semantics require void *, plus pxStreamBuffer was allocated by pvPortMalloc(). */ + } + #else + { + /* Should not be possible to get here, ucFlags must be corrupt. + Force an assert. */ + configASSERT( xStreamBuffer == ( StreamBufferHandle_t ) ~0 ); + } + #endif + } + else + { + /* The structure and buffer were not allocated dynamically and cannot be + freed - just scrub the structure so future use will assert. */ + memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); + } +} +/*-----------------------------------------------------------*/ + +BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +BaseType_t xReturn = pdFAIL, xIsMessageBuffer; + +#if( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxStreamBufferNumber; +#endif + + configASSERT( pxStreamBuffer ); + + #if( configUSE_TRACE_FACILITY == 1 ) + { + /* Store the stream buffer number so it can be restored after the + reset. */ + uxStreamBufferNumber = pxStreamBuffer->uxStreamBufferNumber; + } + #endif + + /* Can only reset a message buffer if there are no tasks blocked on it. */ + if( pxStreamBuffer->xTaskWaitingToReceive == NULL ) + { + if( pxStreamBuffer->xTaskWaitingToSend == NULL ) + { + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) + { + xIsMessageBuffer = pdTRUE; + } + else + { + xIsMessageBuffer = pdFALSE; + } + + prvInitialiseNewStreamBuffer( pxStreamBuffer, + pxStreamBuffer->pucBuffer, + pxStreamBuffer->xLength, + pxStreamBuffer->xTriggerLevelBytes, + xIsMessageBuffer ); + xReturn = pdPASS; + + #if( configUSE_TRACE_FACILITY == 1 ) + { + pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber; + } + #endif + + traceSTREAM_BUFFER_RESET( xStreamBuffer ); + } + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +BaseType_t xReturn; + + configASSERT( pxStreamBuffer ); + + /* It is not valid for the trigger level to be 0. */ + if( xTriggerLevel == ( size_t ) 0 ) + { + xTriggerLevel = ( size_t ) 1; /*lint !e9044 Parameter modified to ensure it doesn't have a dangerous value. */ + } + + /* The trigger level is the number of bytes that must be in the stream + buffer before a task that is waiting for data is unblocked. */ + if( xTriggerLevel <= pxStreamBuffer->xLength ) + { + pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel; + xReturn = pdPASS; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) +{ +const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +size_t xSpace; + + configASSERT( pxStreamBuffer ); + + xSpace = pxStreamBuffer->xLength + pxStreamBuffer->xTail; + xSpace -= pxStreamBuffer->xHead; + xSpace -= ( size_t ) 1; + + if( xSpace >= pxStreamBuffer->xLength ) + { + xSpace -= pxStreamBuffer->xLength; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xSpace; +} +/*-----------------------------------------------------------*/ + +size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) +{ +const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +size_t xReturn; + + configASSERT( pxStreamBuffer ); + + xReturn = prvBytesInBuffer( pxStreamBuffer ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + const void *pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +size_t xReturn, xSpace = 0; +size_t xRequiredSpace = xDataLengthBytes; +TimeOut_t xTimeOut; + + configASSERT( pvTxData ); + configASSERT( pxStreamBuffer ); + + /* This send function is used to write to both message buffers and stream + buffers. If this is a message buffer then the space needed must be + increased by the amount of bytes needed to store the length of the + message. */ + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) + { + xRequiredSpace += sbBYTES_TO_STORE_MESSAGE_LENGTH; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( xTicksToWait != ( TickType_t ) 0 ) + { + vTaskSetTimeOutState( &xTimeOut ); + + do + { + /* Wait until the required number of bytes are free in the message + buffer. */ + taskENTER_CRITICAL(); + { + xSpace = xStreamBufferSpacesAvailable( pxStreamBuffer ); + + if( xSpace < xRequiredSpace ) + { + /* Clear notification state as going to wait for space. */ + ( void ) xTaskNotifyStateClear( NULL ); + + /* Should only be one writer. */ + configASSERT( pxStreamBuffer->xTaskWaitingToSend == NULL ); + pxStreamBuffer->xTaskWaitingToSend = xTaskGetCurrentTaskHandle(); + } + else + { + taskEXIT_CRITICAL(); + break; + } + } + taskEXIT_CRITICAL(); + + traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ); + ( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait ); + pxStreamBuffer->xTaskWaitingToSend = NULL; + + } while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( xSpace == ( size_t ) 0 ) + { + xSpace = xStreamBufferSpacesAvailable( pxStreamBuffer ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xReturn = prvWriteMessageToBuffer( pxStreamBuffer, pvTxData, xDataLengthBytes, xSpace, xRequiredSpace ); + + if( xReturn > ( size_t ) 0 ) + { + traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ); + + /* Was a task waiting for the data? */ + if( prvBytesInBuffer( pxStreamBuffer ) >= pxStreamBuffer->xTriggerLevelBytes ) + { + sbSEND_COMPLETED( pxStreamBuffer ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ); + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, + const void *pvTxData, + size_t xDataLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +size_t xReturn, xSpace; +size_t xRequiredSpace = xDataLengthBytes; + + configASSERT( pvTxData ); + configASSERT( pxStreamBuffer ); + + /* This send function is used to write to both message buffers and stream + buffers. If this is a message buffer then the space needed must be + increased by the amount of bytes needed to store the length of the + message. */ + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) + { + xRequiredSpace += sbBYTES_TO_STORE_MESSAGE_LENGTH; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xSpace = xStreamBufferSpacesAvailable( pxStreamBuffer ); + xReturn = prvWriteMessageToBuffer( pxStreamBuffer, pvTxData, xDataLengthBytes, xSpace, xRequiredSpace ); + + if( xReturn > ( size_t ) 0 ) + { + /* Was a task waiting for the data? */ + if( prvBytesInBuffer( pxStreamBuffer ) >= pxStreamBuffer->xTriggerLevelBytes ) + { + sbSEND_COMPLETE_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer, + const void * pvTxData, + size_t xDataLengthBytes, + size_t xSpace, + size_t xRequiredSpace ) +{ + BaseType_t xShouldWrite; + size_t xReturn; + + if( xSpace == ( size_t ) 0 ) + { + /* Doesn't matter if this is a stream buffer or a message buffer, there + is no space to write. */ + xShouldWrite = pdFALSE; + } + else if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) == ( uint8_t ) 0 ) + { + /* This is a stream buffer, as opposed to a message buffer, so writing a + stream of bytes rather than discrete messages. Write as many bytes as + possible. */ + xShouldWrite = pdTRUE; + xDataLengthBytes = configMIN( xDataLengthBytes, xSpace ); /*lint !e9044 Function parameter modified to ensure it is capped to available space. */ + } + else if( xSpace >= xRequiredSpace ) + { + /* This is a message buffer, as opposed to a stream buffer, and there + is enough space to write both the message length and the message itself + into the buffer. Start by writing the length of the data, the data + itself will be written later in this function. */ + xShouldWrite = pdTRUE; + ( void ) prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xDataLengthBytes ), sbBYTES_TO_STORE_MESSAGE_LENGTH ); + } + else + { + /* There is space available, but not enough space. */ + xShouldWrite = pdFALSE; + } + + if( xShouldWrite != pdFALSE ) + { + /* Writes the data itself. */ + xReturn = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) pvTxData, xDataLengthBytes ); /*lint !e9079 Storage buffer is implemented as uint8_t for ease of sizing, alighment and access. */ + } + else + { + xReturn = 0; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + void *pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength; + + configASSERT( pvRxData ); + configASSERT( pxStreamBuffer ); + + /* This receive function is used by both message buffers, which store + discrete messages, and stream buffers, which store a continuous stream of + bytes. Discrete messages include an additional + sbBYTES_TO_STORE_MESSAGE_LENGTH bytes that hold the length of the + message. */ + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) + { + xBytesToStoreMessageLength = sbBYTES_TO_STORE_MESSAGE_LENGTH; + } + else + { + xBytesToStoreMessageLength = 0; + } + + if( xTicksToWait != ( TickType_t ) 0 ) + { + /* Checking if there is data and clearing the notification state must be + performed atomically. */ + taskENTER_CRITICAL(); + { + xBytesAvailable = prvBytesInBuffer( pxStreamBuffer ); + + /* If this function was invoked by a message buffer read then + xBytesToStoreMessageLength holds the number of bytes used to hold + the length of the next discrete message. If this function was + invoked by a stream buffer read then xBytesToStoreMessageLength will + be 0. */ + if( xBytesAvailable <= xBytesToStoreMessageLength ) + { + /* Clear notification state as going to wait for data. */ + ( void ) xTaskNotifyStateClear( NULL ); + + /* Should only be one reader. */ + configASSERT( pxStreamBuffer->xTaskWaitingToReceive == NULL ); + pxStreamBuffer->xTaskWaitingToReceive = xTaskGetCurrentTaskHandle(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + if( xBytesAvailable <= xBytesToStoreMessageLength ) + { + /* Wait for data to be available. */ + traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ); + ( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait ); + pxStreamBuffer->xTaskWaitingToReceive = NULL; + + /* Recheck the data available after blocking. */ + xBytesAvailable = prvBytesInBuffer( pxStreamBuffer ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + xBytesAvailable = prvBytesInBuffer( pxStreamBuffer ); + } + + /* Whether receiving a discrete message (where xBytesToStoreMessageLength + holds the number of bytes used to store the message length) or a stream of + bytes (where xBytesToStoreMessageLength is zero), the number of bytes + available must be greater than xBytesToStoreMessageLength to be able to + read bytes from the buffer. */ + if( xBytesAvailable > xBytesToStoreMessageLength ) + { + xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength ); + + /* Was a task waiting for space in the buffer? */ + if( xReceivedLength != ( size_t ) 0 ) + { + traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ); + sbRECEIVE_COMPLETED( pxStreamBuffer ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ); + mtCOVERAGE_TEST_MARKER(); + } + + return xReceivedLength; +} +/*-----------------------------------------------------------*/ + +size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, + void *pvRxData, + size_t xBufferLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength; + + configASSERT( pvRxData ); + configASSERT( pxStreamBuffer ); + + /* This receive function is used by both message buffers, which store + discrete messages, and stream buffers, which store a continuous stream of + bytes. Discrete messages include an additional + sbBYTES_TO_STORE_MESSAGE_LENGTH bytes that hold the length of the + message. */ + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) + { + xBytesToStoreMessageLength = sbBYTES_TO_STORE_MESSAGE_LENGTH; + } + else + { + xBytesToStoreMessageLength = 0; + } + + xBytesAvailable = prvBytesInBuffer( pxStreamBuffer ); + + /* Whether receiving a discrete message (where xBytesToStoreMessageLength + holds the number of bytes used to store the message length) or a stream of + bytes (where xBytesToStoreMessageLength is zero), the number of bytes + available must be greater than xBytesToStoreMessageLength to be able to + read bytes from the buffer. */ + if( xBytesAvailable > xBytesToStoreMessageLength ) + { + xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength ); + + /* Was a task waiting for space in the buffer? */ + if( xReceivedLength != ( size_t ) 0 ) + { + sbRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ); + + return xReceivedLength; +} +/*-----------------------------------------------------------*/ + +static size_t prvReadMessageFromBuffer( StreamBuffer_t *pxStreamBuffer, + void *pvRxData, + size_t xBufferLengthBytes, + size_t xBytesAvailable, + size_t xBytesToStoreMessageLength ) +{ +size_t xOriginalTail, xReceivedLength, xNextMessageLength; + + if( xBytesToStoreMessageLength != ( size_t ) 0 ) + { + /* A discrete message is being received. First receive the length + of the message. A copy of the tail is stored so the buffer can be + returned to its prior state if the length of the message is too + large for the provided buffer. */ + xOriginalTail = pxStreamBuffer->xTail; + ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable ); + + /* Reduce the number of bytes available by the number of bytes just + read out. */ + xBytesAvailable -= xBytesToStoreMessageLength; + + /* Check there is enough space in the buffer provided by the + user. */ + if( xNextMessageLength > xBufferLengthBytes ) + { + /* The user has provided insufficient space to read the message + so return the buffer to its previous state (so the length of + the message is in the buffer again). */ + pxStreamBuffer->xTail = xOriginalTail; + xNextMessageLength = 0; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* A stream of bytes is being received (as opposed to a discrete + message), so read as many bytes as possible. */ + xNextMessageLength = xBufferLengthBytes; + } + + /* Read the actual data. */ + xReceivedLength = prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) pvRxData, xNextMessageLength, xBytesAvailable ); /*lint !e9079 Data storage area is implemented as uint8_t array for ease of sizing, indexing and alignment. */ + + return xReceivedLength; +} +/*-----------------------------------------------------------*/ + +BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) +{ +const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +BaseType_t xReturn; +size_t xTail; + + configASSERT( pxStreamBuffer ); + + /* True if no bytes are available. */ + xTail = pxStreamBuffer->xTail; + if( pxStreamBuffer->xHead == xTail ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) +{ +BaseType_t xReturn; +size_t xBytesToStoreMessageLength; +const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ + + configASSERT( pxStreamBuffer ); + + /* This generic version of the receive function is used by both message + buffers, which store discrete messages, and stream buffers, which store a + continuous stream of bytes. Discrete messages include an additional + sbBYTES_TO_STORE_MESSAGE_LENGTH bytes that hold the length of the message. */ + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) + { + xBytesToStoreMessageLength = sbBYTES_TO_STORE_MESSAGE_LENGTH; + } + else + { + xBytesToStoreMessageLength = 0; + } + + /* True if the available space equals zero. */ + if( xStreamBufferSpacesAvailable( xStreamBuffer ) <= xBytesToStoreMessageLength ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +BaseType_t xReturn; +UBaseType_t uxSavedInterruptStatus; + + configASSERT( pxStreamBuffer ); + + uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); + { + if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL ) + { + ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToReceive, + ( uint32_t ) 0, + eNoAction, + pxHigherPriorityTaskWoken ); + ( pxStreamBuffer )->xTaskWaitingToReceive = NULL; + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) +{ +StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */ +BaseType_t xReturn; +UBaseType_t uxSavedInterruptStatus; + + configASSERT( pxStreamBuffer ); + + uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); + { + if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL ) + { + ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToSend, + ( uint32_t ) 0, + eNoAction, + pxHigherPriorityTaskWoken ); + ( pxStreamBuffer )->xTaskWaitingToSend = NULL; + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, const uint8_t *pucData, size_t xCount ) +{ +size_t xNextHead, xFirstLength; + + configASSERT( xCount > ( size_t ) 0 ); + + xNextHead = pxStreamBuffer->xHead; + + /* Calculate the number of bytes that can be added in the first write - + which may be less than the total number of bytes that need to be added if + the buffer will wrap back to the beginning. */ + xFirstLength = configMIN( pxStreamBuffer->xLength - xNextHead, xCount ); + + /* Write as many bytes as can be written in the first write. */ + configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength ); + memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */ + + /* If the number of bytes written was less than the number that could be + written in the first write... */ + if( xCount > xFirstLength ) + { + /* ...then write the remaining bytes to the start of the buffer. */ + configASSERT( ( xCount - xFirstLength ) <= pxStreamBuffer->xLength ); + memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xNextHead += xCount; + if( xNextHead >= pxStreamBuffer->xLength ) + { + xNextHead -= pxStreamBuffer->xLength; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + pxStreamBuffer->xHead = xNextHead; + + return xCount; +} +/*-----------------------------------------------------------*/ + +static size_t prvReadBytesFromBuffer( StreamBuffer_t *pxStreamBuffer, uint8_t *pucData, size_t xMaxCount, size_t xBytesAvailable ) +{ +size_t xCount, xFirstLength, xNextTail; + + /* Use the minimum of the wanted bytes and the available bytes. */ + xCount = configMIN( xBytesAvailable, xMaxCount ); + + if( xCount > ( size_t ) 0 ) + { + xNextTail = pxStreamBuffer->xTail; + + /* Calculate the number of bytes that can be read - which may be + less than the number wanted if the data wraps around to the start of + the buffer. */ + xFirstLength = configMIN( pxStreamBuffer->xLength - xNextTail, xCount ); + + /* Obtain the number of bytes it is possible to obtain in the first + read. Asserts check bounds of read and write. */ + configASSERT( xFirstLength <= xMaxCount ); + configASSERT( ( xNextTail + xFirstLength ) <= pxStreamBuffer->xLength ); + memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */ + + /* If the total number of wanted bytes is greater than the number + that could be read in the first read... */ + if( xCount > xFirstLength ) + { + /*...then read the remaining bytes from the start of the buffer. */ + configASSERT( xCount <= xMaxCount ); + memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Move the tail pointer to effectively remove the data read from + the buffer. */ + xNextTail += xCount; + + if( xNextTail >= pxStreamBuffer->xLength ) + { + xNextTail -= pxStreamBuffer->xLength; + } + + pxStreamBuffer->xTail = xNextTail; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xCount; +} +/*-----------------------------------------------------------*/ + +static size_t prvBytesInBuffer( const StreamBuffer_t * const pxStreamBuffer ) +{ +/* Returns the distance between xTail and xHead. */ +size_t xCount; + + xCount = pxStreamBuffer->xLength + pxStreamBuffer->xHead; + xCount -= pxStreamBuffer->xTail; + if ( xCount >= pxStreamBuffer->xLength ) + { + xCount -= pxStreamBuffer->xLength; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xCount; +} +/*-----------------------------------------------------------*/ + +static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer, + uint8_t * const pucBuffer, + size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) +{ + /* Assert here is deliberately writing to the entire buffer to ensure it can + be written to without generating exceptions, and is setting the buffer to a + known value to assist in development/debugging. */ + #if( configASSERT_DEFINED == 1 ) + { + /* The value written just has to be identifiable when looking at the + memory. Don't use 0xA5 as that is the stack fill value and could + result in confusion as to what is actually being observed. */ + const BaseType_t xWriteValue = 0x55; + configASSERT( memset( pucBuffer, ( int ) xWriteValue, xBufferSizeBytes ) == pucBuffer ); + } + #endif + + memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */ + pxStreamBuffer->pucBuffer = pucBuffer; + pxStreamBuffer->xLength = xBufferSizeBytes; + pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes; + + if( xIsMessageBuffer != pdFALSE ) + { + pxStreamBuffer->ucFlags |= sbFLAGS_IS_MESSAGE_BUFFER; + } +} + +#if ( configUSE_TRACE_FACILITY == 1 ) + + UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) + { + return ( ( StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) + { + ( ( StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber = uxStreamBufferNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) + { + return ( ( StreamBuffer_t * )xStreamBuffer )->ucFlags | sbFLAGS_IS_MESSAGE_BUFFER; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/tasks.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/tasks.c similarity index 58% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/tasks.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/tasks.c index a557543..e920fa6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/tasks.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/tasks.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* Standard includes. */ #include @@ -80,7 +39,7 @@ task.h is included from an application file. */ #include "FreeRTOS.h" #include "task.h" #include "timers.h" -#include "StackMacros.h" +#include "stack_macros.h" /* Lint e961 and e750 are suppressed as a MISRA exception justified because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the @@ -98,19 +57,7 @@ functions but without including stdio.h here. */ #include #endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */ -/* Sanity check the configuration. */ -#if configUSE_TICKLESS_IDLE != 0 - #if INCLUDE_vTaskSuspend != 1 - #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 - #endif /* INCLUDE_vTaskSuspend */ -#endif /* configUSE_TICKLESS_IDLE */ - -/* - * Defines the size, in words, of the stack allocated to the idle task. - */ -#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE - -#if ( configUSE_PREEMPTION == 0 ) +#if( configUSE_PREEMPTION == 0 ) /* If the cooperative scheduler is being used then a yield should not be performed just because a higher priority task has been woken. */ #define taskYIELD_IF_USING_PREEMPTION() @@ -118,157 +65,10 @@ functions but without including stdio.h here. */ #define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API() #endif -/* Value that can be assigned to the eNotifyState member of the TCB. */ -typedef enum -{ - eNotWaitingNotification = 0, - eWaitingNotification, - eNotified -} eNotifyValue; - -/* - * Task control block. A task control block (TCB) is allocated for each task, - * and stores task state information, including a pointer to the task's context - * (the task's run time environment, including register values) - */ -typedef struct tskTaskControlBlock -{ - volatile StackType_t *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */ - - #if ( portUSING_MPU_WRAPPERS == 1 ) - xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ - BaseType_t xUsingStaticallyAllocatedStack; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */ - #endif - - ListItem_t xGenericListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ - ListItem_t xEventListItem; /*< Used to reference a task from an event list. */ - UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */ - StackType_t *pxStack; /*< Points to the start of the stack. */ - char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - - #if ( portSTACK_GROWTH > 0 ) - StackType_t *pxEndOfStack; /*< Points to the end of the stack on architectures where the stack grows up from low memory. */ - #endif - - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */ - #endif - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */ - UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */ - #endif - - #if ( configUSE_MUTEXES == 1 ) - UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */ - UBaseType_t uxMutexesHeld; - #endif - - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - TaskHookFunction_t pxTaskTag; - #endif - - #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ - #endif - - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - /* Allocate a Newlib reent structure that is specific to this task. - Note Newlib support has been included by popular demand, but is not - used by the FreeRTOS maintainers themselves. FreeRTOS is not - responsible for resulting newlib operation. User must be familiar with - newlib and must provide system-wide implementations of the necessary - stubs. Be warned that (at the time of writing) the current newlib design - implements a system-wide malloc() that must be provided with locks. */ - struct _reent xNewLib_reent; - #endif - - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - volatile uint32_t ulNotifiedValue; - volatile eNotifyValue eNotifyState; - #endif - -} tskTCB; - -/* The old tskTCB name is maintained above then typedefed to the new TCB_t name -below to enable the use of older kernel aware debuggers. */ -typedef tskTCB TCB_t; - -/* - * Some kernel aware debuggers require the data the debugger needs access to to - * be global, rather than file scope. - */ -#ifdef portREMOVE_STATIC_QUALIFIER - #define static -#endif - -/*lint -e956 A manual analysis and inspection has been used to determine which -static variables must be declared volatile. */ - -PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL; - -/* Lists for ready and blocked tasks. --------------------*/ -PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ];/*< Prioritised ready tasks. */ -PRIVILEGED_DATA static List_t xDelayedTaskList1; /*< Delayed tasks. */ -PRIVILEGED_DATA static List_t xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */ -PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList; /*< Points to the delayed task list currently being used. */ -PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */ -PRIVILEGED_DATA static List_t xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed. */ - -#if ( INCLUDE_vTaskDelete == 1 ) - - PRIVILEGED_DATA static List_t xTasksWaitingTermination; /*< Tasks that have been deleted - but their memory not yet freed. */ - PRIVILEGED_DATA static volatile UBaseType_t uxTasksDeleted = ( UBaseType_t ) 0U; - -#endif - -#if ( INCLUDE_vTaskSuspend == 1 ) - - PRIVILEGED_DATA static List_t xSuspendedTaskList; /*< Tasks that are currently suspended. */ - -#endif - -#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) - - PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandle = NULL; /*< Holds the handle of the idle task. The idle task is created automatically when the scheduler is started. */ - -#endif - -/* Other file private variables. --------------------------------*/ -PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U; -PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) 0U; -PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY; -PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE; -PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U; -PRIVILEGED_DATA static volatile BaseType_t xYieldPending = pdFALSE; -PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0; -PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U; -PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime = portMAX_DELAY; - -/* Context switches are held pending while the scheduler is suspended. Also, -interrupts must not manipulate the xGenericListItem of a TCB, or any of the -lists the xGenericListItem can be referenced from, if the scheduler is suspended. -If an interrupt needs to unblock a task while the scheduler is suspended then it -moves the task's event list item into the xPendingReadyList, ready for the -kernel to move the task from the pending ready list into the real ready list -when the scheduler is unsuspended. The pending ready list itself can only be -accessed from a critical section. */ -PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE; - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ - PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ - -#endif - -/*lint +e956 */ - -/* Debugging and trace facilities private variables and macros. ------------*/ +/* Values that can be assigned to the ucNotifyState member of the TCB. */ +#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 ) +#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 ) +#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 ) /* * The value used to fill the stack of a task when the task is created. This @@ -276,6 +76,37 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t */ #define tskSTACK_FILL_BYTE ( 0xa5U ) +/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using +dynamically allocated RAM, in which case when any task is deleted it is known +that both the task's stack and TCB need to be freed. Sometimes the +FreeRTOSConfig.h settings only allow a task to be created using statically +allocated RAM, in which case when any task is deleted it is known that neither +the task's stack or TCB should be freed. Sometimes the FreeRTOSConfig.h +settings allow a task to be created using either statically or dynamically +allocated RAM, in which case a member of the TCB is used to record whether the +stack and/or TCB were allocated statically or dynamically, so when a task is +deleted the RAM that was allocated dynamically is freed again and no attempt is +made to free the RAM that was allocated statically. +tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a +task to be created using either statically or dynamically allocated RAM. Note +that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with +a statically allocated stack and a dynamically allocated TCB. +!!!NOTE!!! If the definition of tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is +changed then the definition of StaticTask_t must also be updated. */ +#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) +#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 ) +#define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 ) +#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 ) + +/* If any of the following are set then task stacks are filled with a known +value so the high water mark can be determined. If none of the following are +set then don't fill the stack so there is no unnecessary dependency on memset. */ +#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) + #define tskSET_NEW_STACKS_TO_KNOWN_VALUE 1 +#else + #define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0 +#endif + /* * Macros used by vListTask to indicate which state a task is in. */ @@ -284,7 +115,19 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t #define tskDELETED_CHAR ( 'D' ) #define tskSUSPENDED_CHAR ( 'S' ) -/*-----------------------------------------------------------*/ +/* + * Some kernel aware debuggers require the data the debugger needs access to be + * global, rather than file scope. + */ +#ifdef portREMOVE_STATIC_QUALIFIER + #define static +#endif + +/* The name allocated to the Idle task. This can be overridden by defining +configIDLE_TASK_NAME in FreeRTOSConfig.h. */ +#ifndef configIDLE_TASK_NAME + #define configIDLE_TASK_NAME "IDLE" +#endif #if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) @@ -296,7 +139,7 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t state task. */ #define taskRECORD_READY_PRIORITY( uxPriority ) \ { \ - if ( ( uxPriority ) > uxTopReadyPriority ) \ + if( ( uxPriority ) > uxTopReadyPriority ) \ { \ uxTopReadyPriority = ( uxPriority ); \ } \ @@ -306,16 +149,19 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t #define taskSELECT_HIGHEST_PRIORITY_TASK() \ { \ + UBaseType_t uxTopPriority = uxTopReadyPriority; \ + \ /* Find the highest priority queue that contains ready tasks. */ \ - while ( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ) \ + while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopPriority ] ) ) ) \ { \ - configASSERT( uxTopReadyPriority ); \ - --uxTopReadyPriority; \ + configASSERT( uxTopPriority ); \ + --uxTopPriority; \ } \ \ /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of \ the same priority get an equal share of the processor time. */ \ - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ); \ + listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \ + uxTopReadyPriority = uxTopPriority; \ } /* taskSELECT_HIGHEST_PRIORITY_TASK */ /*-----------------------------------------------------------*/ @@ -341,7 +187,7 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t { \ UBaseType_t uxTopPriority; \ \ - /* Find the highest priority queue that contains ready tasks. */ \ + /* Find the highest priority list that contains ready tasks. */ \ portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority ); \ configASSERT( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ uxTopPriority ] ) ) > 0 ); \ listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \ @@ -354,7 +200,7 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t or suspended list then it won't be in a ready list. */ #define taskRESET_READY_PRIORITY( uxPriority ) \ { \ - if ( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == ( UBaseType_t ) 0 ) \ + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == ( UBaseType_t ) 0 ) \ { \ portRESET_READY_PRIORITY( ( uxPriority ), ( uxTopReadyPriority ) ); \ } \ @@ -389,7 +235,8 @@ count overflows. */ #define prvAddTaskToReadyList( pxTCB ) \ traceMOVED_TASK_TO_READY_STATE( pxTCB ); \ taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \ - vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) ) + vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \ + tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) /*-----------------------------------------------------------*/ /* @@ -408,28 +255,172 @@ being used for another purpose. The following bit definition is used to inform the scheduler that the value should not be changed - in which case it is the responsibility of whichever module is using the value to ensure it gets set back to its original value when it is released. */ -#if configUSE_16_BIT_TICKS == 1 +#if( configUSE_16_BIT_TICKS == 1 ) #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x8000U #else #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x80000000UL #endif +/* + * Task control block. A task control block (TCB) is allocated for each task, + * and stores task state information, including a pointer to the task's context + * (the task's run time environment, including register values) + */ +typedef struct tskTaskControlBlock +{ + volatile StackType_t *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */ + + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ + #endif + + ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ + ListItem_t xEventListItem; /*< Used to reference a task from an event list. */ + UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */ + StackType_t *pxStack; /*< Points to the start of the stack. */ + char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + StackType_t *pxEndOfStack; /*< Points to the highest valid address for the stack. */ + #endif + + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */ + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */ + UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */ + #endif + + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */ + UBaseType_t uxMutexesHeld; + #endif + + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + TaskHookFunction_t pxTaskTag; + #endif + + #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + + #if( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ + #endif + + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + /* Allocate a Newlib reent structure that is specific to this task. + Note Newlib support has been included by popular demand, but is not + used by the FreeRTOS maintainers themselves. FreeRTOS is not + responsible for resulting newlib operation. User must be familiar with + newlib and must provide system-wide implementations of the necessary + stubs. Be warned that (at the time of writing) the current newlib design + implements a system-wide malloc() that must be provided with locks. */ + struct _reent xNewLib_reent; + #endif + + #if( configUSE_TASK_NOTIFICATIONS == 1 ) + volatile uint32_t ulNotifiedValue; + volatile uint8_t ucNotifyState; + #endif + + /* See the comments above the definition of + tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */ + #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */ + uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */ + #endif + + #if( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDelayAborted; + #endif + +} tskTCB; + +/* The old tskTCB name is maintained above then typedefed to the new TCB_t name +below to enable the use of older kernel aware debuggers. */ +typedef tskTCB TCB_t; + +/*lint -save -e956 A manual analysis and inspection has been used to determine +which static variables must be declared volatile. */ + +PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL; + +/* Lists for ready and blocked tasks. --------------------*/ +PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ];/*< Prioritised ready tasks. */ +PRIVILEGED_DATA static List_t xDelayedTaskList1; /*< Delayed tasks. */ +PRIVILEGED_DATA static List_t xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */ +PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList; /*< Points to the delayed task list currently being used. */ +PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */ +PRIVILEGED_DATA static List_t xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed. */ + +#if( INCLUDE_vTaskDelete == 1 ) + + PRIVILEGED_DATA static List_t xTasksWaitingTermination; /*< Tasks that have been deleted - but their memory not yet freed. */ + PRIVILEGED_DATA static volatile UBaseType_t uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U; + +#endif + +#if ( INCLUDE_vTaskSuspend == 1 ) + + PRIVILEGED_DATA static List_t xSuspendedTaskList; /*< Tasks that are currently suspended. */ + +#endif + +/* Other file private variables. --------------------------------*/ +PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U; +PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT; +PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY; +PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE; +PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U; +PRIVILEGED_DATA static volatile BaseType_t xYieldPending = pdFALSE; +PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0; +PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U; +PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime = ( TickType_t ) 0U; /* Initialised to portMAX_DELAY before the scheduler starts. */ +PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandle = NULL; /*< Holds the handle of the idle task. The idle task is created automatically when the scheduler is started. */ + +/* Context switches are held pending while the scheduler is suspended. Also, +interrupts must not manipulate the xStateListItem of a TCB, or any of the +lists the xStateListItem can be referenced from, if the scheduler is suspended. +If an interrupt needs to unblock a task while the scheduler is suspended then it +moves the task's event list item into the xPendingReadyList, ready for the +kernel to move the task from the pending ready list into the real ready list +when the scheduler is unsuspended. The pending ready list itself can only be +accessed from a critical section. */ +PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE; + +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + + PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ + PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ + +#endif + +/*lint -restore */ + +/*-----------------------------------------------------------*/ + /* Callback function prototypes. --------------------------*/ -#if configCHECK_FOR_STACK_OVERFLOW > 0 +#if( configCHECK_FOR_STACK_OVERFLOW > 0 ) + extern void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ); + #endif -#if configUSE_TICK_HOOK > 0 +#if( configUSE_TICK_HOOK > 0 ) + extern void vApplicationTickHook( void ); + #endif -/* File private functions. --------------------------------*/ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) -/* - * Utility to ready a TCB for a given task. Mainly just copies the parameters - * into the TCB structure. - */ -static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + extern void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +#endif + +/* File private functions. --------------------------------*/ /** * Utility task that simply returns pdTRUE if the task referenced by xTask is @@ -437,7 +428,9 @@ static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const p * is in any other state. */ #if ( INCLUDE_vTaskSuspend == 1 ) + static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + #endif /* INCLUDE_vTaskSuspend */ /* @@ -483,13 +476,7 @@ static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION; * The currently executing task is entering the Blocked state. Add the task to * either the current or the overflow delayed task list. */ -static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) PRIVILEGED_FUNCTION; - -/* - * Allocates memory from the heap for a TCB and associated stack. Checks the - * allocation was successful. - */ -static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer ) PRIVILEGED_FUNCTION; +static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) PRIVILEGED_FUNCTION; /* * Fills an TaskStatus_t structure with information on each task that is @@ -501,7 +488,17 @@ static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * */ #if ( configUSE_TRACE_FACILITY == 1 ) - static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) PRIVILEGED_FUNCTION; + static UBaseType_t prvListTasksWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Searches pxList for a task with name pcNameToQuery - returning a handle to + * the task if it is found, or NULL if the task is not found. + */ +#if ( INCLUDE_xTaskGetHandle == 1 ) + + static TCB_t *prvSearchForNameWithinSingleList( List_t *pxList, const char pcNameToQuery[] ) PRIVILEGED_FUNCTION; #endif @@ -512,157 +509,556 @@ static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * */ #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) - static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION; + static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Return the amount of time, in ticks, that will pass before the kernel will + * next move a task from the Blocked state to the Running state. + * + * This conditional compilation should use inequality to 0, not equality to 1. + * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user + * defined low power mode implementations require configUSE_TICKLESS_IDLE to be + * set to a value other than 1. + */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + + static TickType_t prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Set xNextTaskUnblockTime to the time at which the next Blocked state task + * will exit the Blocked state. + */ +static void prvResetNextTaskUnblockTime( void ); + +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) + + /* + * Helper function used to pad task names with spaces when printing out + * human readable tables of task information. + */ + static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Called after a Task_t structure has been allocated either statically or + * dynamically to fill in the structure's members. + */ +static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask, + TCB_t *pxNewTCB, + const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; + +/* + * Called after a new task has been created and initialised to place the task + * under the control of the scheduler. + */ +static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION; + +/* + * freertos_tasks_c_additions_init() should only be called if the user definable + * macro FREERTOS_TASKS_C_ADDITIONS_INIT() is defined, as that is the only macro + * called by the function. + */ +#ifdef FREERTOS_TASKS_C_ADDITIONS_INIT + + static void freertos_tasks_c_additions_init( void ) PRIVILEGED_FUNCTION; + +#endif + +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + + TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const puxStackBuffer, + StaticTask_t * const pxTaskBuffer ) + { + TCB_t *pxNewTCB; + TaskHandle_t xReturn; + + configASSERT( puxStackBuffer != NULL ); + configASSERT( pxTaskBuffer != NULL ); + + #if( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + variable of type StaticTask_t equals the size of the real task + structure. */ + volatile size_t xSize = sizeof( StaticTask_t ); + configASSERT( xSize == sizeof( TCB_t ) ); + } + #endif /* configASSERT_DEFINED */ + + + if( ( pxTaskBuffer != NULL ) && ( puxStackBuffer != NULL ) ) + { + /* The memory used for the task's TCB and stack are passed into this + function - use them. */ + pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer; + + #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */ + { + /* Tasks can be created statically or dynamically, so note this + task was created statically in case the task is later deleted. */ + pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + + prvInitialiseNewTask( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, &xReturn, pxNewTCB, NULL ); + prvAddNewTaskToReadyList( pxNewTCB ); + } + else + { + xReturn = NULL; + } + + return xReturn; + } + +#endif /* SUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) + { + TCB_t *pxNewTCB; + BaseType_t xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + + configASSERT( pxTaskDefinition->puxStackBuffer != NULL ); + configASSERT( pxTaskDefinition->pxTaskBuffer != NULL ); + + if( ( pxTaskDefinition->puxStackBuffer != NULL ) && ( pxTaskDefinition->pxTaskBuffer != NULL ) ) + { + /* Allocate space for the TCB. Where the memory comes from depends + on the implementation of the port malloc function and whether or + not static allocation is being used. */ + pxNewTCB = ( TCB_t * ) pxTaskDefinition->pxTaskBuffer; + + /* Store the stack location in the TCB. */ + pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer; + + #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + { + /* Tasks can be created statically or dynamically, so note this + task was created statically in case the task is later deleted. */ + pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + + prvInitialiseNewTask( pxTaskDefinition->pvTaskCode, + pxTaskDefinition->pcName, + ( uint32_t ) pxTaskDefinition->usStackDepth, + pxTaskDefinition->pvParameters, + pxTaskDefinition->uxPriority, + pxCreatedTask, pxNewTCB, + pxTaskDefinition->xRegions ); + + prvAddNewTaskToReadyList( pxNewTCB ); + xReturn = pdPASS; + } + + return xReturn; + } + +#endif /* ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ +/*-----------------------------------------------------------*/ + +#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) + { + TCB_t *pxNewTCB; + BaseType_t xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + + configASSERT( pxTaskDefinition->puxStackBuffer ); + + if( pxTaskDefinition->puxStackBuffer != NULL ) + { + /* Allocate space for the TCB. Where the memory comes from depends + on the implementation of the port malloc function and whether or + not static allocation is being used. */ + pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); + + if( pxNewTCB != NULL ) + { + /* Store the stack location in the TCB. */ + pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer; + + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* Tasks can be created statically or dynamically, so note + this task had a statically allocated stack in case it is + later deleted. The TCB was allocated dynamically. */ + pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY; + } + #endif + + prvInitialiseNewTask( pxTaskDefinition->pvTaskCode, + pxTaskDefinition->pcName, + ( uint32_t ) pxTaskDefinition->usStackDepth, + pxTaskDefinition->pvParameters, + pxTaskDefinition->uxPriority, + pxCreatedTask, pxNewTCB, + pxTaskDefinition->xRegions ); + + prvAddNewTaskToReadyList( pxNewTCB ); + xReturn = pdPASS; + } + } + + return xReturn; + } + +#endif /* portUSING_MPU_WRAPPERS */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + + BaseType_t xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const configSTACK_DEPTH_TYPE usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) + { + TCB_t *pxNewTCB; + BaseType_t xReturn; + + /* If the stack grows down then allocate the stack then the TCB so the stack + does not grow into the TCB. Likewise if the stack grows up then allocate + the TCB then the stack. */ + #if( portSTACK_GROWTH > 0 ) + { + /* Allocate space for the TCB. Where the memory comes from depends on + the implementation of the port malloc function and whether or not static + allocation is being used. */ + pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); + + if( pxNewTCB != NULL ) + { + /* Allocate space for the stack used by the task being created. + The base of the stack memory stored in the TCB so the task can + be deleted later if required. */ + pxNewTCB->pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + if( pxNewTCB->pxStack == NULL ) + { + /* Could not allocate the stack. Delete the allocated TCB. */ + vPortFree( pxNewTCB ); + pxNewTCB = NULL; + } + } + } + #else /* portSTACK_GROWTH */ + { + StackType_t *pxStack; + + /* Allocate space for the stack used by the task being created. */ + pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + if( pxStack != NULL ) + { + /* Allocate space for the TCB. */ + pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); /*lint !e961 MISRA exception as the casts are only redundant for some paths. */ + + if( pxNewTCB != NULL ) + { + /* Store the stack location in the TCB. */ + pxNewTCB->pxStack = pxStack; + } + else + { + /* The stack cannot be used as the TCB was not created. Free + it again. */ + vPortFree( pxStack ); + } + } + else + { + pxNewTCB = NULL; + } + } + #endif /* portSTACK_GROWTH */ + + if( pxNewTCB != NULL ) + { + #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */ + { + /* Tasks can be created statically or dynamically, so note this + task was created dynamically in case it is later deleted. */ + pxNewTCB->ucStaticallyAllocated = tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB; + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ + + prvInitialiseNewTask( pxTaskCode, pcName, ( uint32_t ) usStackDepth, pvParameters, uxPriority, pxCreatedTask, pxNewTCB, NULL ); + prvAddNewTaskToReadyList( pxNewTCB ); + xReturn = pdPASS; + } + else + { + xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + } + + return xReturn; + } + +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask, + TCB_t *pxNewTCB, + const MemoryRegion_t * const xRegions ) +{ +StackType_t *pxTopOfStack; +UBaseType_t x; + + #if( portUSING_MPU_WRAPPERS == 1 ) + /* Should the task be created in privileged mode? */ + BaseType_t xRunPrivileged; + if( ( uxPriority & portPRIVILEGE_BIT ) != 0U ) + { + xRunPrivileged = pdTRUE; + } + else + { + xRunPrivileged = pdFALSE; + } + uxPriority &= ~portPRIVILEGE_BIT; + #endif /* portUSING_MPU_WRAPPERS == 1 */ + + /* Avoid dependency on memset() if it is not required. */ + #if( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 ) + { + /* Fill the stack with a known value to assist debugging. */ + ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) ulStackDepth * sizeof( StackType_t ) ); + } + #endif /* tskSET_NEW_STACKS_TO_KNOWN_VALUE */ + + /* Calculate the top of stack address. This depends on whether the stack + grows from high memory to low (as per the 80x86) or vice versa. + portSTACK_GROWTH is used to make the result positive or negative as required + by the port. */ + #if( portSTACK_GROWTH < 0 ) + { + pxTopOfStack = pxNewTCB->pxStack + ( ulStackDepth - ( uint32_t ) 1 ); + pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */ + + /* Check the alignment of the calculated top of stack is correct. */ + configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); + + #if( configRECORD_STACK_HIGH_ADDRESS == 1 ) + { + /* Also record the stack's high address, which may assist + debugging. */ + pxNewTCB->pxEndOfStack = pxTopOfStack; + } + #endif /* configRECORD_STACK_HIGH_ADDRESS */ + } + #else /* portSTACK_GROWTH */ + { + pxTopOfStack = pxNewTCB->pxStack; + + /* Check the alignment of the stack buffer is correct. */ + configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); + + /* The other extreme of the stack space is required if stack checking is + performed. */ + pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( ulStackDepth - ( uint32_t ) 1 ); + } + #endif /* portSTACK_GROWTH */ + + /* Store the task name in the TCB. */ + for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ ) + { + pxNewTCB->pcTaskName[ x ] = pcName[ x ]; + + /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than + configMAX_TASK_NAME_LEN characters just in case the memory after the + string is not accessible (extremely unlikely). */ + if( pcName[ x ] == 0x00 ) + { + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + /* Ensure the name string is terminated in the case that the string length + was greater or equal to configMAX_TASK_NAME_LEN. */ + pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0'; + + /* This is used as an array index so must ensure it's not too large. First + remove the privilege bit if one is present. */ + if( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + { + uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + pxNewTCB->uxPriority = uxPriority; + #if ( configUSE_MUTEXES == 1 ) + { + pxNewTCB->uxBasePriority = uxPriority; + pxNewTCB->uxMutexesHeld = 0; + } + #endif /* configUSE_MUTEXES */ + + vListInitialiseItem( &( pxNewTCB->xStateListItem ) ); + vListInitialiseItem( &( pxNewTCB->xEventListItem ) ); + + /* Set the pxNewTCB as a link back from the ListItem_t. This is so we can get + back to the containing TCB from a generic item in a list. */ + listSET_LIST_ITEM_OWNER( &( pxNewTCB->xStateListItem ), pxNewTCB ); + + /* Event lists are always in priority order. */ + listSET_LIST_ITEM_VALUE( &( pxNewTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + listSET_LIST_ITEM_OWNER( &( pxNewTCB->xEventListItem ), pxNewTCB ); + + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + { + pxNewTCB->uxCriticalNesting = ( UBaseType_t ) 0U; + } + #endif /* portCRITICAL_NESTING_IN_TCB */ + + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + { + pxNewTCB->pxTaskTag = NULL; + } + #endif /* configUSE_APPLICATION_TASK_TAG */ -#endif + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + { + pxNewTCB->ulRunTimeCounter = 0UL; + } + #endif /* configGENERATE_RUN_TIME_STATS */ -/* - * Return the amount of time, in ticks, that will pass before the kernel will - * next move a task from the Blocked state to the Running state. - * - * This conditional compilation should use inequality to 0, not equality to 1. - * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user - * defined low power mode implementations require configUSE_TICKLESS_IDLE to be - * set to a value other than 1. - */ -#if ( configUSE_TICKLESS_IDLE != 0 ) + #if ( portUSING_MPU_WRAPPERS == 1 ) + { + vPortStoreTaskMPUSettings( &( pxNewTCB->xMPUSettings ), xRegions, pxNewTCB->pxStack, ulStackDepth ); + } + #else + { + /* Avoid compiler warning about unreferenced parameter. */ + ( void ) xRegions; + } + #endif - static TickType_t prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION; + #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) + { + for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ ) + { + pxNewTCB->pvThreadLocalStoragePointers[ x ] = NULL; + } + } + #endif -#endif + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + { + pxNewTCB->ulNotifiedValue = 0; + pxNewTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION; + } + #endif -/* - * Set xNextTaskUnblockTime to the time at which the next Blocked state task - * will exit the Blocked state. - */ -static void prvResetNextTaskUnblockTime( void ); + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + { + /* Initialise this task's Newlib reent structure. */ + _REENT_INIT_PTR( ( &( pxNewTCB->xNewLib_reent ) ) ); + } + #endif -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) + #if( INCLUDE_xTaskAbortDelay == 1 ) + { + pxNewTCB->ucDelayAborted = pdFALSE; + } + #endif - /* - * Helper function used to pad task names with spaces when printing out - * human readable tables of task information. - */ - static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName ); + /* Initialize the TCB stack to look as if the task was already running, + but had been interrupted by the scheduler. The return address is set + to the start of the task function. Once the stack has been initialised + the top of stack variable is updated. */ + #if( portUSING_MPU_WRAPPERS == 1 ) + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #else /* portUSING_MPU_WRAPPERS */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); + } + #endif /* portUSING_MPU_WRAPPERS */ -#endif + if( ( void * ) pxCreatedTask != NULL ) + { + /* Pass the handle out in an anonymous way. The handle can be used to + change the created task's priority, delete the created task, etc.*/ + *pxCreatedTask = ( TaskHandle_t ) pxNewTCB; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} /*-----------------------------------------------------------*/ -BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) { -BaseType_t xReturn; -TCB_t * pxNewTCB; -StackType_t *pxTopOfStack; - - configASSERT( pxTaskCode ); - configASSERT( ( ( uxPriority & ( UBaseType_t ) ( ~portPRIVILEGE_BIT ) ) < ( UBaseType_t ) configMAX_PRIORITIES ) ); - - /* Allocate the memory required by the TCB and stack for the new task, - checking that the allocation was successful. */ - pxNewTCB = prvAllocateTCBAndStack( usStackDepth, puxStackBuffer ); - - if ( pxNewTCB != NULL ) + /* Ensure interrupts don't access the task lists while the lists are being + updated. */ + taskENTER_CRITICAL(); { - #if ( portUSING_MPU_WRAPPERS == 1 ) - /* Should the task be created in privileged mode? */ - BaseType_t xRunPrivileged; - if ( ( uxPriority & portPRIVILEGE_BIT ) != 0U ) - { - xRunPrivileged = pdTRUE; - } - else - { - xRunPrivileged = pdFALSE; - } - uxPriority &= ~portPRIVILEGE_BIT; + uxCurrentNumberOfTasks++; + if( pxCurrentTCB == NULL ) + { + /* There are no other tasks, or all the other tasks are in + the suspended state - make this the current task. */ + pxCurrentTCB = pxNewTCB; - if ( puxStackBuffer != NULL ) + if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 ) { - /* The application provided its own stack. Note this so no - attempt is made to delete the stack should that task be - deleted. */ - pxNewTCB->xUsingStaticallyAllocatedStack = pdTRUE; + /* This is the first task to be created so do the preliminary + initialisation required. We will not recover if this call + fails, but we will report the failure. */ + prvInitialiseTaskLists(); } else { - /* The stack was allocated dynamically. Note this so it can be - deleted again if the task is deleted. */ - pxNewTCB->xUsingStaticallyAllocatedStack = pdFALSE; + mtCOVERAGE_TEST_MARKER(); } - #endif /* portUSING_MPU_WRAPPERS == 1 */ - - /* Calculate the top of stack address. This depends on whether the - stack grows from high memory to low (as per the 80x86) or vice versa. - portSTACK_GROWTH is used to make the result positive or negative as - required by the port. */ - #if ( portSTACK_GROWTH < 0 ) - { - pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 ); - pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */ - - /* Check the alignment of the calculated top of stack is correct. */ - configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - } - #else /* portSTACK_GROWTH */ - { - pxTopOfStack = pxNewTCB->pxStack; - - /* Check the alignment of the stack buffer is correct. */ - configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - - /* If we want to use stack checking on architectures that use - a positive stack growth direction then we also need to store the - other extreme of the stack space. */ - pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ); - } - #endif /* portSTACK_GROWTH */ - - /* Setup the newly allocated TCB with the initial state of the task. */ - prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority, xRegions, usStackDepth ); - - /* Initialize the TCB stack to look as if the task was already running, - but had been interrupted by the scheduler. The return address is set - to the start of the task function. Once the stack has been initialised - the top of stack variable is updated. */ - #if ( portUSING_MPU_WRAPPERS == 1 ) - { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); - } - #else /* portUSING_MPU_WRAPPERS */ - { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); - } - #endif /* portUSING_MPU_WRAPPERS */ - - if ( ( void * ) pxCreatedTask != NULL ) - { - /* Pass the TCB out - in an anonymous way. The calling function/ - task can use this as a handle to delete the task later if - required.*/ - *pxCreatedTask = ( TaskHandle_t ) pxNewTCB; } else { - mtCOVERAGE_TEST_MARKER(); - } - - /* Ensure interrupts don't access the task lists while they are being - updated. */ - taskENTER_CRITICAL(); - { - uxCurrentNumberOfTasks++; - if ( pxCurrentTCB == NULL ) + /* If the scheduler is not already running, make this task the + current task if it is the highest priority task to be created + so far. */ + if( xSchedulerRunning == pdFALSE ) { - /* There are no other tasks, or all the other tasks are in - the suspended state - make this the current task. */ - pxCurrentTCB = pxNewTCB; - - if ( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 ) + if( pxCurrentTCB->uxPriority <= pxNewTCB->uxPriority ) { - /* This is the first task to be created so do the preliminary - initialisation required. We will not recover if this call - fails, but we will report the failure. */ - prvInitialiseTaskLists(); + pxCurrentTCB = pxNewTCB; } else { @@ -671,71 +1067,43 @@ StackType_t *pxTopOfStack; } else { - /* If the scheduler is not already running, make this task the - current task if it is the highest priority task to be created - so far. */ - if ( xSchedulerRunning == pdFALSE ) - { - if ( pxCurrentTCB->uxPriority <= uxPriority ) - { - pxCurrentTCB = pxNewTCB; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + mtCOVERAGE_TEST_MARKER(); } + } - uxTaskNumber++; + uxTaskNumber++; - #if ( configUSE_TRACE_FACILITY == 1 ) - { - /* Add a counter into the TCB for tracing only. */ - pxNewTCB->uxTCBNumber = uxTaskNumber; - } - #endif /* configUSE_TRACE_FACILITY */ - traceTASK_CREATE( pxNewTCB ); + #if ( configUSE_TRACE_FACILITY == 1 ) + { + /* Add a counter into the TCB for tracing only. */ + pxNewTCB->uxTCBNumber = uxTaskNumber; + } + #endif /* configUSE_TRACE_FACILITY */ + traceTASK_CREATE( pxNewTCB ); - prvAddTaskToReadyList( pxNewTCB ); + prvAddTaskToReadyList( pxNewTCB ); - xReturn = pdPASS; - portSETUP_TCB( pxNewTCB ); - } - taskEXIT_CRITICAL(); - } - else - { - xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; - traceTASK_CREATE_FAILED(); + portSETUP_TCB( pxNewTCB ); } + taskEXIT_CRITICAL(); - if ( xReturn == pdPASS ) + if( xSchedulerRunning != pdFALSE ) { - if ( xSchedulerRunning != pdFALSE ) + /* If the created task is of a higher priority than the current task + then it should run now. */ + if( pxCurrentTCB->uxPriority < pxNewTCB->uxPriority ) { - /* If the created task is of a higher priority than the current task - then it should run now. */ - if ( pxCurrentTCB->uxPriority < uxPriority ) - { - taskYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + taskYIELD_IF_USING_PREEMPTION(); } else { mtCOVERAGE_TEST_MARKER(); } } - - return xReturn; + else + { + mtCOVERAGE_TEST_MARKER(); + } } /*-----------------------------------------------------------*/ @@ -751,11 +1119,8 @@ StackType_t *pxTopOfStack; being deleted. */ pxTCB = prvGetTCBFromHandle( xTaskToDelete ); - /* Remove task from the ready list and place in the termination list. - This will stop the task from be scheduled. The idle task will check - the termination list and free up any memory allocated by the - scheduler for the TCB and stack. */ - if ( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) + /* Remove task from the ready list. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) { taskRESET_READY_PRIORITY( pxTCB->uxPriority ); } @@ -765,7 +1130,7 @@ StackType_t *pxTopOfStack; } /* Is the task waiting on an event also? */ - if ( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) { ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); } @@ -774,16 +1139,42 @@ StackType_t *pxTopOfStack; mtCOVERAGE_TEST_MARKER(); } - vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) ); + /* Increment the uxTaskNumber also so kernel aware debuggers can + detect that the task lists need re-generating. This is done before + portPRE_TASK_DELETE_HOOK() as in the Windows port that macro will + not return. */ + uxTaskNumber++; - /* Increment the ucTasksDeleted variable so the idle task knows - there is a task that has been deleted and that it should therefore - check the xTasksWaitingTermination list. */ - ++uxTasksDeleted; + if( pxTCB == pxCurrentTCB ) + { + /* A task is deleting itself. This cannot complete within the + task itself, as a context switch to another task is required. + Place the task in the termination list. The idle task will + check the termination list and free up any memory allocated by + the scheduler for the TCB and stack of the deleted task. */ + vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xStateListItem ) ); + + /* Increment the ucTasksDeleted variable so the idle task knows + there is a task that has been deleted and that it should therefore + check the xTasksWaitingTermination list. */ + ++uxDeletedTasksWaitingCleanUp; - /* Increment the uxTaskNumberVariable also so kernel aware debuggers - can detect that the task lists need re-generating. */ - uxTaskNumber++; + /* The pre-delete hook is primarily for the Windows simulator, + in which Windows specific clean up operations are performed, + after which it is not possible to yield away from this task - + hence xYieldPending is used to latch that a context switch is + required. */ + portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending ); + } + else + { + --uxCurrentNumberOfTasks; + prvDeleteTCB( pxTCB ); + + /* Reset the next expected unblock time in case it referred to + the task that has just been deleted. */ + prvResetNextTaskUnblockTime(); + } traceTASK_DELETE( pxTCB ); } @@ -791,29 +1182,16 @@ StackType_t *pxTopOfStack; /* Force a reschedule if it is the currently running task that has just been deleted. */ - if ( xSchedulerRunning != pdFALSE ) + if( xSchedulerRunning != pdFALSE ) { - if ( pxTCB == pxCurrentTCB ) + if( pxTCB == pxCurrentTCB ) { configASSERT( uxSchedulerSuspended == 0 ); - - /* The pre-delete hook is primarily for the Windows simulator, - in which Windows specific clean up operations are performed, - after which it is not possible to yield away from this task - - hence xYieldPending is used to latch that a context switch is - required. */ - portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending ); portYIELD_WITHIN_API(); } else { - /* Reset the next expected unblock time in case it referred to - the task that has just been deleted. */ - taskENTER_CRITICAL(); - { - prvResetNextTaskUnblockTime(); - } - taskEXIT_CRITICAL(); + mtCOVERAGE_TEST_MARKER(); } } } @@ -841,14 +1219,14 @@ StackType_t *pxTopOfStack; /* Generate the tick time at which the task wants to wake. */ xTimeToWake = *pxPreviousWakeTime + xTimeIncrement; - if ( xConstTickCount < *pxPreviousWakeTime ) + if( xConstTickCount < *pxPreviousWakeTime ) { /* The tick count has overflowed since this function was lasted called. In this case the only time we should ever actually delay is if the wake time has also overflowed, and the wake time is greater than the tick time. When this is the case it is as if neither time had overflowed. */ - if ( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xConstTickCount ) ) + if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xConstTickCount ) ) { xShouldDelay = pdTRUE; } @@ -862,7 +1240,7 @@ StackType_t *pxTopOfStack; /* The tick time has not overflowed. In this case we will delay if either the wake time has overflowed, and/or the tick time is less than the wake time. */ - if ( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xConstTickCount ) ) + if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xConstTickCount ) ) { xShouldDelay = pdTRUE; } @@ -875,25 +1253,13 @@ StackType_t *pxTopOfStack; /* Update the wake time ready for the next call. */ *pxPreviousWakeTime = xTimeToWake; - if ( xShouldDelay != pdFALSE ) + if( xShouldDelay != pdFALSE ) { - traceTASK_DELAY_UNTIL(); - - /* Remove the task from the ready list before adding it to the - blocked list as the same list item is used for both lists. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + traceTASK_DELAY_UNTIL( xTimeToWake ); - prvAddCurrentTaskToDelayedList( xTimeToWake ); + /* prvAddCurrentTaskToDelayedList() needs the block time, not + the time to wake, so subtract the current tick count. */ + prvAddCurrentTaskToDelayedList( xTimeToWake - xConstTickCount, pdFALSE ); } else { @@ -904,7 +1270,7 @@ StackType_t *pxTopOfStack; /* Force a reschedule if xTaskResumeAll has not already done so, we may have put ourselves to sleep. */ - if ( xAlreadyYielded == pdFALSE ) + if( xAlreadyYielded == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -921,12 +1287,10 @@ StackType_t *pxTopOfStack; void vTaskDelay( const TickType_t xTicksToDelay ) { - TickType_t xTimeToWake; BaseType_t xAlreadyYielded = pdFALSE; - /* A delay time of zero just forces a reschedule. */ - if ( xTicksToDelay > ( TickType_t ) 0U ) + if( xTicksToDelay > ( TickType_t ) 0U ) { configASSERT( uxSchedulerSuspended == 0 ); vTaskSuspendAll(); @@ -940,26 +1304,7 @@ StackType_t *pxTopOfStack; This task cannot be in an event list as it is the currently executing task. */ - - /* Calculate the time to wake - this may overflow but this is - not a problem. */ - xTimeToWake = xTickCount + xTicksToDelay; - - /* We must remove ourselves from the ready list before adding - ourselves to the blocked list as the same list item is used for - both lists. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - prvAddCurrentTaskToDelayedList( xTimeToWake ); + prvAddCurrentTaskToDelayedList( xTicksToDelay, pdFALSE ); } xAlreadyYielded = xTaskResumeAll(); } @@ -970,7 +1315,7 @@ StackType_t *pxTopOfStack; /* Force a reschedule if xTaskResumeAll has not already done so, we may have put ourselves to sleep. */ - if ( xAlreadyYielded == pdFALSE ) + if( xAlreadyYielded == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -983,7 +1328,7 @@ StackType_t *pxTopOfStack; #endif /* INCLUDE_vTaskDelay */ /*-----------------------------------------------------------*/ -#if ( INCLUDE_eTaskGetState == 1 ) +#if( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) ) eTaskState eTaskGetState( TaskHandle_t xTask ) { @@ -993,7 +1338,7 @@ StackType_t *pxTopOfStack; configASSERT( pxTCB ); - if ( pxTCB == pxCurrentTCB ) + if( pxTCB == pxCurrentTCB ) { /* The task calling this function is querying its own state. */ eReturn = eRunning; @@ -1002,11 +1347,11 @@ StackType_t *pxTopOfStack; { taskENTER_CRITICAL(); { - pxStateList = ( List_t * ) listLIST_ITEM_CONTAINER( &( pxTCB->xGenericListItem ) ); + pxStateList = ( List_t * ) listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) ); } taskEXIT_CRITICAL(); - if ( ( pxStateList == pxDelayedTaskList ) || ( pxStateList == pxOverflowDelayedTaskList ) ) + if( ( pxStateList == pxDelayedTaskList ) || ( pxStateList == pxOverflowDelayedTaskList ) ) { /* The task being queried is referenced from one of the Blocked lists. */ @@ -1014,12 +1359,12 @@ StackType_t *pxTopOfStack; } #if ( INCLUDE_vTaskSuspend == 1 ) - else if ( pxStateList == &xSuspendedTaskList ) + else if( pxStateList == &xSuspendedTaskList ) { /* The task being queried is referenced from the suspended list. Is it genuinely suspended or is it block indefinitely? */ - if ( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ) + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ) { eReturn = eSuspended; } @@ -1031,10 +1376,11 @@ StackType_t *pxTopOfStack; #endif #if ( INCLUDE_vTaskDelete == 1 ) - else if ( pxStateList == &xTasksWaitingTermination ) + else if( ( pxStateList == &xTasksWaitingTermination ) || ( pxStateList == NULL ) ) { /* The task being queried is referenced from the deleted - tasks list. */ + tasks list, or it is not referenced from any lists at + all. */ eReturn = eDeleted; } #endif @@ -1062,8 +1408,8 @@ StackType_t *pxTopOfStack; taskENTER_CRITICAL(); { - /* If null is passed in here then we are changing the - priority of the calling function. */ + /* If null is passed in here then it is the priority of the that + called uxTaskPriorityGet() that is being queried. */ pxTCB = prvGetTCBFromHandle( xTask ); uxReturn = pxTCB->uxPriority; } @@ -1126,7 +1472,7 @@ StackType_t *pxTopOfStack; configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) ); /* Ensure the new priority is valid. */ - if ( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) { uxNewPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; } @@ -1153,18 +1499,18 @@ StackType_t *pxTopOfStack; } #endif - if ( uxCurrentBasePriority != uxNewPriority ) + if( uxCurrentBasePriority != uxNewPriority ) { /* The priority change may have readied a task of higher priority than the calling task. */ - if ( uxNewPriority > uxCurrentBasePriority ) + if( uxNewPriority > uxCurrentBasePriority ) { - if ( pxTCB != pxCurrentTCB ) + if( pxTCB != pxCurrentTCB ) { /* The priority of a task other than the currently running task is being raised. Is the priority being raised above that of the running task? */ - if ( uxNewPriority >= pxCurrentTCB->uxPriority ) + if( uxNewPriority >= pxCurrentTCB->uxPriority ) { xYieldRequired = pdTRUE; } @@ -1180,7 +1526,7 @@ StackType_t *pxTopOfStack; priority task able to run so no yield is required. */ } } - else if ( pxTCB == pxCurrentTCB ) + else if( pxTCB == pxCurrentTCB ) { /* Setting the priority of the running task down means there may now be another task of higher priority that @@ -1203,7 +1549,7 @@ StackType_t *pxTopOfStack; { /* Only change the priority being used if the task is not currently using an inherited priority. */ - if ( pxTCB->uxBasePriority == pxTCB->uxPriority ) + if( pxTCB->uxBasePriority == pxTCB->uxPriority ) { pxTCB->uxPriority = uxNewPriority; } @@ -1223,7 +1569,7 @@ StackType_t *pxTopOfStack; /* Only reset the event list item value if the value is not being used for anything else. */ - if ( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) + if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) { listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ } @@ -1233,15 +1579,15 @@ StackType_t *pxTopOfStack; } /* If the task is in the blocked or suspended list we need do - nothing more than change it's priority variable. However, if + nothing more than change its priority variable. However, if the task is in a ready list it needs to be removed and placed in the list appropriate to its new priority. */ - if ( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE ) { - /* The task is currently in its ready list - remove before adding - it to it's new ready list. As we are in a critical section we - can do this even if the scheduler is suspended. */ - if ( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) + /* The task is currently in its ready list - remove before + adding it to it's new ready list. As we are in a critical + section we can do this even if the scheduler is suspended. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) { /* It is known that the task is in its ready list so there is no need to check again and the port level @@ -1259,7 +1605,7 @@ StackType_t *pxTopOfStack; mtCOVERAGE_TEST_MARKER(); } - if ( xYieldRequired == pdTRUE ) + if( xYieldRequired != pdFALSE ) { taskYIELD_IF_USING_PREEMPTION(); } @@ -1295,7 +1641,7 @@ StackType_t *pxTopOfStack; /* Remove task from the ready/delayed list and place in the suspended list. */ - if ( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) { taskRESET_READY_PRIORITY( pxTCB->uxPriority ); } @@ -1305,7 +1651,7 @@ StackType_t *pxTopOfStack; } /* Is the task waiting on an event also? */ - if ( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) { ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); } @@ -1314,13 +1660,39 @@ StackType_t *pxTopOfStack; mtCOVERAGE_TEST_MARKER(); } - vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ); + vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xStateListItem ) ); + + #if( configUSE_TASK_NOTIFICATIONS == 1 ) + { + if( pxTCB->ucNotifyState == taskWAITING_NOTIFICATION ) + { + /* The task was blocked to wait for a notification, but is + now suspended, so no notification was received. */ + pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION; + } + } + #endif } taskEXIT_CRITICAL(); - if ( pxTCB == pxCurrentTCB ) + if( xSchedulerRunning != pdFALSE ) + { + /* Reset the next expected unblock time in case it referred to the + task that is now in the Suspended state. */ + taskENTER_CRITICAL(); + { + prvResetNextTaskUnblockTime(); + } + taskEXIT_CRITICAL(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( pxTCB == pxCurrentTCB ) { - if ( xSchedulerRunning != pdFALSE ) + if( xSchedulerRunning != pdFALSE ) { /* The current task has just been suspended. */ configASSERT( uxSchedulerSuspended == 0 ); @@ -1331,7 +1703,7 @@ StackType_t *pxTopOfStack; /* The scheduler is not running, but the task that was pointed to by pxCurrentTCB has just been suspended and pxCurrentTCB must be adjusted to point to a different task. */ - if ( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) + if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) { /* No other tasks are ready, so set pxCurrentTCB back to NULL so when the next task is created pxCurrentTCB will @@ -1347,21 +1719,7 @@ StackType_t *pxTopOfStack; } else { - if ( xSchedulerRunning != pdFALSE ) - { - /* A task other than the currently running task was suspended, - reset the next expected unblock time in case it referred to the - task that is now in the Suspended state. */ - taskENTER_CRITICAL(); - { - prvResetNextTaskUnblockTime(); - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + mtCOVERAGE_TEST_MARKER(); } } @@ -1382,14 +1740,14 @@ StackType_t *pxTopOfStack; configASSERT( xTask ); /* Is the task being resumed actually in the suspended list? */ - if ( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE ) + if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xStateListItem ) ) != pdFALSE ) { /* Has the task already been resumed from within an ISR? */ - if ( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE ) + if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE ) { /* Is it in the suspended list because it is in the Suspended state, or because is is blocked with no timeout? */ - if ( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE ) + if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE ) /*lint !e961. The cast is only redundant when NULL is used. */ { xReturn = pdTRUE; } @@ -1425,21 +1783,21 @@ StackType_t *pxTopOfStack; /* The parameter cannot be NULL as it is impossible to resume the currently executing task. */ - if ( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) ) + if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) ) { taskENTER_CRITICAL(); { - if ( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE ) + if( prvTaskIsTaskSuspended( pxTCB ) != pdFALSE ) { traceTASK_RESUME( pxTCB ); - /* As we are in a critical section we can access the ready - lists even if the scheduler is suspended. */ - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + /* The ready list can be accessed even if the scheduler is + suspended because this is inside a critical section. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); - /* We may have just resumed a higher priority task. */ - if ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + /* A higher priority task may have just been resumed. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { /* This yield may not cause the task just resumed to run, but will leave the lists in the correct state for the @@ -1498,16 +1856,16 @@ StackType_t *pxTopOfStack; uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { - if ( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE ) + if( prvTaskIsTaskSuspended( pxTCB ) != pdFALSE ) { traceTASK_RESUME_FROM_ISR( pxTCB ); /* Check the ready lists can be accessed. */ - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { /* Ready lists can be accessed so move the task from the suspended list to the ready list directly. */ - if ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { xYieldRequired = pdTRUE; } @@ -1516,7 +1874,7 @@ StackType_t *pxTopOfStack; mtCOVERAGE_TEST_MARKER(); } - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); } else @@ -1545,22 +1903,47 @@ void vTaskStartScheduler( void ) BaseType_t xReturn; /* Add the idle task at the lowest priority. */ - #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) { - /* Create the idle task, storing its handle in xIdleTaskHandle so it can - be returned by the xTaskGetIdleTaskHandle() function. */ - xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ + StaticTask_t *pxIdleTaskTCBBuffer = NULL; + StackType_t *pxIdleTaskStackBuffer = NULL; + uint32_t ulIdleTaskStackSize; + + /* The Idle task is created using user provided RAM - obtain the + address of the RAM then create the idle task. */ + vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize ); + xIdleTaskHandle = xTaskCreateStatic( prvIdleTask, + configIDLE_TASK_NAME, + ulIdleTaskStackSize, + ( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */ + ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), + pxIdleTaskStackBuffer, + pxIdleTaskTCBBuffer ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ + + if( xIdleTaskHandle != NULL ) + { + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } } #else { - /* Create the idle task without storing its handle. */ - xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ + /* The Idle task is being created using dynamically allocated RAM. */ + xReturn = xTaskCreate( prvIdleTask, + configIDLE_TASK_NAME, + configMINIMAL_STACK_SIZE, + ( void * ) NULL, + ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), + &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ } - #endif /* INCLUDE_xTaskGetIdleTaskHandle */ + #endif /* configSUPPORT_STATIC_ALLOCATION */ #if ( configUSE_TIMERS == 1 ) { - if ( xReturn == pdPASS ) + if( xReturn == pdPASS ) { xReturn = xTimerCreateTimerTask(); } @@ -1571,8 +1954,17 @@ BaseType_t xReturn; } #endif /* configUSE_TIMERS */ - if ( xReturn == pdPASS ) + if( xReturn == pdPASS ) { + /* freertos_tasks_c_additions_init() should only be called if the user + definable macro FREERTOS_TASKS_C_ADDITIONS_INIT() is defined, as that is + the only macro called by the function. */ + #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT + { + freertos_tasks_c_additions_init(); + } + #endif + /* Interrupts are turned off here, to ensure a tick does not occur before or during the call to xPortStartScheduler(). The stacks of the created tasks contain a status word with interrupts switched on @@ -1588,17 +1980,21 @@ BaseType_t xReturn; } #endif /* configUSE_NEWLIB_REENTRANT */ + xNextTaskUnblockTime = portMAX_DELAY; xSchedulerRunning = pdTRUE; xTickCount = ( TickType_t ) 0U; /* If configGENERATE_RUN_TIME_STATS is defined then the following macro must be defined to configure the timer/counter used to generate - the run time counter time base. */ + the run time counter time base. NOTE: If configGENERATE_RUN_TIME_STATS + is set to 0 and the following line fails to build then ensure you do not + have portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() defined in your + FreeRTOSConfig.h file. */ portCONFIGURE_TIMER_FOR_RUN_TIME_STATS(); /* Setting up the timer tick is hardware specific and thus in the portable interface. */ - if ( xPortStartScheduler() != pdFALSE ) + if( xPortStartScheduler() != pdFALSE ) { /* Should not reach here as if the scheduler is running the function will not return. */ @@ -1613,8 +2009,12 @@ BaseType_t xReturn; /* This line will only be reached if the kernel could not be started, because there was not enough FreeRTOS heap to create the idle task or the timer task. */ - configASSERT( xReturn ); + configASSERT( xReturn != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ); } + + /* Prevent compiler warnings if INCLUDE_xTaskGetIdleTaskHandle is set to 0, + meaning xIdleTaskHandle is not used anywhere else. */ + ( void ) xIdleTaskHandle; } /*-----------------------------------------------------------*/ @@ -1644,18 +2044,53 @@ void vTaskSuspendAll( void ) static TickType_t prvGetExpectedIdleTime( void ) { TickType_t xReturn; + UBaseType_t uxHigherPriorityReadyTasks = pdFALSE; + + /* uxHigherPriorityReadyTasks takes care of the case where + configUSE_PREEMPTION is 0, so there may be tasks above the idle priority + task that are in the Ready state, even though the idle task is + running. */ + #if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) + { + if( uxTopReadyPriority > tskIDLE_PRIORITY ) + { + uxHigherPriorityReadyTasks = pdTRUE; + } + } + #else + { + const UBaseType_t uxLeastSignificantBit = ( UBaseType_t ) 0x01; + + /* When port optimised task selection is used the uxTopReadyPriority + variable is used as a bit map. If bits other than the least + significant bit are set then there are tasks that have a priority + above the idle priority that are in the Ready state. This takes + care of the case where the co-operative scheduler is in use. */ + if( uxTopReadyPriority > uxLeastSignificantBit ) + { + uxHigherPriorityReadyTasks = pdTRUE; + } + } + #endif - if ( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY ) + if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY ) { xReturn = 0; } - else if ( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 ) + else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 ) { /* There are other idle priority tasks in the ready state. If time slicing is used then the very next tick interrupt must be processed. */ xReturn = 0; } + else if( uxHigherPriorityReadyTasks != pdFALSE ) + { + /* There are tasks in the Ready state that have a priority above the + idle priority. This path can only be reached if + configUSE_PREEMPTION is 0. */ + xReturn = 0; + } else { xReturn = xNextTaskUnblockTime - xTickCount; @@ -1669,7 +2104,7 @@ void vTaskSuspendAll( void ) BaseType_t xTaskResumeAll( void ) { -TCB_t *pxTCB; +TCB_t *pxTCB = NULL; BaseType_t xAlreadyYielded = pdFALSE; /* If uxSchedulerSuspended is zero then this function does not match a @@ -1685,22 +2120,22 @@ BaseType_t xAlreadyYielded = pdFALSE; { --uxSchedulerSuspended; - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - if ( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U ) + if( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U ) { /* Move any readied tasks from the pending list into the appropriate ready list. */ - while ( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE ) + while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE ) { pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) ); ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); /* If the moved task has a priority higher than the current task then a yield must be performed. */ - if ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { xYieldPending = pdTRUE; } @@ -1710,33 +2145,50 @@ BaseType_t xAlreadyYielded = pdFALSE; } } + if( pxTCB != NULL ) + { + /* A task was unblocked while the scheduler was suspended, + which may have prevented the next unblock time from being + re-calculated, in which case re-calculate it now. Mainly + important for low power tickless implementations, where + this can prevent an unnecessary exit from low power + state. */ + prvResetNextTaskUnblockTime(); + } + /* If any ticks occurred while the scheduler was suspended then they should be processed now. This ensures the tick count does not slip, and that any delayed tasks are resumed at the correct time. */ - if ( uxPendedTicks > ( UBaseType_t ) 0U ) { - while ( uxPendedTicks > ( UBaseType_t ) 0U ) + UBaseType_t uxPendedCounts = uxPendedTicks; /* Non-volatile copy. */ + + if( uxPendedCounts > ( UBaseType_t ) 0U ) { - if ( xTaskIncrementTick() != pdFALSE ) - { - xYieldPending = pdTRUE; - } - else + do { - mtCOVERAGE_TEST_MARKER(); - } - --uxPendedTicks; + if( xTaskIncrementTick() != pdFALSE ) + { + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + --uxPendedCounts; + } while( uxPendedCounts > ( UBaseType_t ) 0U ); + + uxPendedTicks = 0; + } + else + { + mtCOVERAGE_TEST_MARKER(); } - } - else - { - mtCOVERAGE_TEST_MARKER(); } - if ( xYieldPending == pdTRUE ) + if( xYieldPending != pdFALSE ) { - #if ( configUSE_PREEMPTION != 0 ) + #if( configUSE_PREEMPTION != 0 ) { xAlreadyYielded = pdTRUE; } @@ -1814,19 +2266,142 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) } /*-----------------------------------------------------------*/ -#if ( INCLUDE_pcTaskGetTaskName == 1 ) +char *pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +{ +TCB_t *pxTCB; + + /* If null is passed in here then the name of the calling task is being + queried. */ + pxTCB = prvGetTCBFromHandle( xTaskToQuery ); + configASSERT( pxTCB ); + return &( pxTCB->pcTaskName[ 0 ] ); +} +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetHandle == 1 ) - char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + static TCB_t *prvSearchForNameWithinSingleList( List_t *pxList, const char pcNameToQuery[] ) { - TCB_t *pxTCB; + TCB_t *pxNextTCB, *pxFirstTCB, *pxReturn = NULL; + UBaseType_t x; + char cNextChar; - /* If null is passed in here then the name of the calling task is being queried. */ - pxTCB = prvGetTCBFromHandle( xTaskToQuery ); - configASSERT( pxTCB ); - return &( pxTCB->pcTaskName[ 0 ] ); + /* This function is called with the scheduler suspended. */ + + if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); + + do + { + listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); + + /* Check each character in the name looking for a match or + mismatch. */ + for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ ) + { + cNextChar = pxNextTCB->pcTaskName[ x ]; + + if( cNextChar != pcNameToQuery[ x ] ) + { + /* Characters didn't match. */ + break; + } + else if( cNextChar == 0x00 ) + { + /* Both strings terminated, a match must have been + found. */ + pxReturn = pxNextTCB; + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + if( pxReturn != NULL ) + { + /* The handle has been found. */ + break; + } + + } while( pxNextTCB != pxFirstTCB ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return pxReturn; + } + +#endif /* INCLUDE_xTaskGetHandle */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetHandle == 1 ) + + TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + { + UBaseType_t uxQueue = configMAX_PRIORITIES; + TCB_t* pxTCB; + + /* Task names will be truncated to configMAX_TASK_NAME_LEN - 1 bytes. */ + configASSERT( strlen( pcNameToQuery ) < configMAX_TASK_NAME_LEN ); + + vTaskSuspendAll(); + { + /* Search the ready lists. */ + do + { + uxQueue--; + pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) &( pxReadyTasksLists[ uxQueue ] ), pcNameToQuery ); + + if( pxTCB != NULL ) + { + /* Found the handle. */ + break; + } + + } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + /* Search the delayed lists. */ + if( pxTCB == NULL ) + { + pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) pxDelayedTaskList, pcNameToQuery ); + } + + if( pxTCB == NULL ) + { + pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) pxOverflowDelayedTaskList, pcNameToQuery ); + } + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + if( pxTCB == NULL ) + { + /* Search the suspended list. */ + pxTCB = prvSearchForNameWithinSingleList( &xSuspendedTaskList, pcNameToQuery ); + } + } + #endif + + #if( INCLUDE_vTaskDelete == 1 ) + { + if( pxTCB == NULL ) + { + /* Search the deleted list. */ + pxTCB = prvSearchForNameWithinSingleList( &xTasksWaitingTermination, pcNameToQuery ); + } + } + #endif + } + ( void ) xTaskResumeAll(); + + return ( TaskHandle_t ) pxTCB; } -#endif /* INCLUDE_pcTaskGetTaskName */ +#endif /* INCLUDE_xTaskGetHandle */ /*-----------------------------------------------------------*/ #if ( configUSE_TRACE_FACILITY == 1 ) @@ -1838,27 +2413,27 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) vTaskSuspendAll(); { /* Is there a space in the array for each task in the system? */ - if ( uxArraySize >= uxCurrentNumberOfTasks ) + if( uxArraySize >= uxCurrentNumberOfTasks ) { /* Fill in an TaskStatus_t structure with information on each task in the Ready state. */ do { uxQueue--; - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ); + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ); - } while ( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ /* Fill in an TaskStatus_t structure with information on each task in the Blocked state. */ - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked ); - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked ); + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked ); + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked ); - #if ( INCLUDE_vTaskDelete == 1 ) + #if( INCLUDE_vTaskDelete == 1 ) { /* Fill in an TaskStatus_t structure with information on each task that has been deleted but not yet cleaned up. */ - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted ); + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted ); } #endif @@ -1866,13 +2441,13 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) { /* Fill in an TaskStatus_t structure with information on each task in the Suspended state. */ - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended ); + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended ); } #endif #if ( configGENERATE_RUN_TIME_STATS == 1) { - if ( pulTotalRunTime != NULL ) + if( pulTotalRunTime != NULL ) { #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE portALT_GET_RUN_TIME_COUNTER_VALUE( ( *pulTotalRunTime ) ); @@ -1883,7 +2458,7 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) } #else { - if ( pulTotalRunTime != NULL ) + if( pulTotalRunTime != NULL ) { *pulTotalRunTime = 0; } @@ -1920,6 +2495,8 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) This is to ensure vTaskStepTick() is available when user defined low power mode implementations require configUSE_TICKLESS_IDLE to be set to a value other than 1. */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + void vTaskStepTick( const TickType_t xTicksToJump ) { /* Correct the tick count value after a period during which the tick @@ -1930,7 +2507,83 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than traceINCREASE_TICK_COUNT( xTicksToJump ); } +#endif /* configUSE_TICKLESS_IDLE */ +/*----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskAbortDelay == 1 ) + + BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) + { + TCB_t *pxTCB = ( TCB_t * ) xTask; + BaseType_t xReturn; + + configASSERT( pxTCB ); + + vTaskSuspendAll(); + { + /* A task can only be prematurely removed from the Blocked state if + it is actually in the Blocked state. */ + if( eTaskGetState( xTask ) == eBlocked ) + { + xReturn = pdPASS; + + /* Remove the reference to the task from the blocked list. An + interrupt won't touch the xStateListItem because the + scheduler is suspended. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + + /* Is the task waiting on an event also? If so remove it from + the event list too. Interrupts can touch the event list item, + even though the scheduler is suspended, so a critical section + is used. */ + taskENTER_CRITICAL(); + { + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + pxTCB->ucDelayAborted = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + /* Place the unblocked task into the appropriate ready list. */ + prvAddTaskToReadyList( pxTCB ); + + /* A task being unblocked cannot cause an immediate context + switch if preemption is turned off. */ + #if ( configUSE_PREEMPTION == 1 ) + { + /* Preemption is on, but a context switch should only be + performed if the unblocked task has a priority that is + equal to or higher than the currently executing task. */ + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* Pend the yield to be performed when the scheduler + is unsuspended. */ + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_PREEMPTION */ + } + else + { + xReturn = pdFAIL; + } + } + ( void ) xTaskResumeAll(); + + return xReturn; + } +#endif /* INCLUDE_xTaskAbortDelay */ /*----------------------------------------------------------*/ BaseType_t xTaskIncrementTick( void ) @@ -1943,105 +2596,103 @@ BaseType_t xSwitchRequired = pdFALSE; Increments the tick then checks to see if the new tick value will cause any tasks to be unblocked. */ traceTASK_INCREMENT_TICK( xTickCount ); - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { + /* Minor optimisation. The tick count cannot change in this + block. */ + const TickType_t xConstTickCount = xTickCount + ( TickType_t ) 1; + /* Increment the RTOS tick, switching the delayed and overflowed delayed lists if it wraps to 0. */ - ++xTickCount; + xTickCount = xConstTickCount; + if( xConstTickCount == ( TickType_t ) 0U ) /*lint !e774 'if' does not always evaluate to false as it is looking for an overflow. */ { - /* Minor optimisation. The tick count cannot change in this - block. */ - const TickType_t xConstTickCount = xTickCount; - - if ( xConstTickCount == ( TickType_t ) 0U ) - { - taskSWITCH_DELAYED_LISTS(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + taskSWITCH_DELAYED_LISTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } - /* See if this tick has made a timeout expire. Tasks are stored in - the queue in the order of their wake time - meaning once one task - has been found whose block time has not expired there is no need to - look any further down the list. */ - if ( xConstTickCount >= xNextTaskUnblockTime ) + /* See if this tick has made a timeout expire. Tasks are stored in + the queue in the order of their wake time - meaning once one task + has been found whose block time has not expired there is no need to + look any further down the list. */ + if( xConstTickCount >= xNextTaskUnblockTime ) + { + for( ;; ) { - for ( ;; ) + if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) + { + /* The delayed list is empty. Set xNextTaskUnblockTime + to the maximum possible value so it is extremely + unlikely that the + if( xTickCount >= xNextTaskUnblockTime ) test will pass + next time through. */ + xNextTaskUnblockTime = portMAX_DELAY; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + break; + } + else { - if ( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) + /* The delayed list is not empty, get the value of the + item at the head of the delayed list. This is the time + at which the task at the head of the delayed list must + be removed from the Blocked state. */ + pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); + xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xStateListItem ) ); + + if( xConstTickCount < xItemValue ) { - /* The delayed list is empty. Set xNextTaskUnblockTime - to the maximum possible value so it is extremely - unlikely that the - if ( xTickCount >= xNextTaskUnblockTime ) test will pass - next time through. */ - xNextTaskUnblockTime = portMAX_DELAY; + /* It is not time to unblock this item yet, but the + item value is the time at which the task at the head + of the blocked list must be removed from the Blocked + state - so record the item value in + xNextTaskUnblockTime. */ + xNextTaskUnblockTime = xItemValue; break; } else { - /* The delayed list is not empty, get the value of the - item at the head of the delayed list. This is the time - at which the task at the head of the delayed list must - be removed from the Blocked state. */ - pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); - xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ); - - if ( xConstTickCount < xItemValue ) - { - /* It is not time to unblock this item yet, but the - item value is the time at which the task at the head - of the blocked list must be removed from the Blocked - state - so record the item value in - xNextTaskUnblockTime. */ - xNextTaskUnblockTime = xItemValue; - break; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + mtCOVERAGE_TEST_MARKER(); + } + + /* It is time to remove the item from the Blocked state. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + + /* Is the task waiting on an event also? If so remove + it from the event list. */ + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } - /* It is time to remove the item from the Blocked state. */ - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + /* Place the unblocked task into the appropriate ready + list. */ + prvAddTaskToReadyList( pxTCB ); - /* Is the task waiting on an event also? If so remove - it from the event list. */ - if ( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + /* A task being unblocked cannot cause an immediate + context switch if preemption is turned off. */ + #if ( configUSE_PREEMPTION == 1 ) + { + /* Preemption is on, but a context switch should + only be performed if the unblocked task has a + priority that is equal to or higher than the + currently executing task. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + xSwitchRequired = pdTRUE; } else { mtCOVERAGE_TEST_MARKER(); } - - /* Place the unblocked task into the appropriate ready - list. */ - prvAddTaskToReadyList( pxTCB ); - - /* A task being unblocked cannot cause an immediate - context switch if preemption is turned off. */ - #if ( configUSE_PREEMPTION == 1 ) - { - /* Preemption is on, but a context switch should - only be performed if the unblocked task has a - priority that is equal to or higher than the - currently executing task. */ - if ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - xSwitchRequired = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_PREEMPTION */ } + #endif /* configUSE_PREEMPTION */ } } } @@ -2051,7 +2702,7 @@ BaseType_t xSwitchRequired = pdFALSE; writer has not explicitly turned time slicing off. */ #if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) { - if ( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 ) + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 ) { xSwitchRequired = pdTRUE; } @@ -2066,7 +2717,7 @@ BaseType_t xSwitchRequired = pdFALSE; { /* Guard against the tick hook being called when the pended tick count is being unwound (when the scheduler is being unlocked). */ - if ( uxPendedTicks == ( UBaseType_t ) 0U ) + if( uxPendedTicks == ( UBaseType_t ) 0U ) { vApplicationTickHook(); } @@ -2092,7 +2743,7 @@ BaseType_t xSwitchRequired = pdFALSE; #if ( configUSE_PREEMPTION == 1 ) { - if ( xYieldPending != pdFALSE ) + if( xYieldPending != pdFALSE ) { xSwitchRequired = pdTRUE; } @@ -2115,7 +2766,7 @@ BaseType_t xSwitchRequired = pdFALSE; /* If xTask is NULL then it is the task hook of the calling task that is getting set. */ - if ( xTask == NULL ) + if( xTask == NULL ) { xTCB = ( TCB_t * ) pxCurrentTCB; } @@ -2142,7 +2793,7 @@ BaseType_t xSwitchRequired = pdFALSE; TaskHookFunction_t xReturn; /* If xTask is NULL then we are setting our own task hook. */ - if ( xTask == NULL ) + if( xTask == NULL ) { xTCB = ( TCB_t * ) pxCurrentTCB; } @@ -2173,7 +2824,7 @@ BaseType_t xSwitchRequired = pdFALSE; BaseType_t xReturn; /* If xTask is NULL then we are calling our own task hook. */ - if ( xTask == NULL ) + if( xTask == NULL ) { xTCB = ( TCB_t * ) pxCurrentTCB; } @@ -2182,7 +2833,7 @@ BaseType_t xSwitchRequired = pdFALSE; xTCB = ( TCB_t * ) xTask; } - if ( xTCB->pxTaskTag != NULL ) + if( xTCB->pxTaskTag != NULL ) { xReturn = xTCB->pxTaskTag( pvParameter ); } @@ -2199,7 +2850,7 @@ BaseType_t xSwitchRequired = pdFALSE; void vTaskSwitchContext( void ) { - if ( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE ) { /* The scheduler is currently suspended - do not allow a context switch. */ @@ -2219,13 +2870,13 @@ void vTaskSwitchContext( void ) #endif /* Add the amount of time the task has been running to the - accumulated time so far. The time the task started running was + accumulated time so far. The time the task started running was stored in ulTaskSwitchedInTime. Note that there is no overflow - protection here so count values are only valid until the timer + protection here so count values are only valid until the timer overflows. The guard against negative values is to protect against suspect run time stat counter implementations - which are provided by the application, not the kernel. */ - if ( ulTotalRunTime > ulTaskSwitchedInTime ) + if( ulTotalRunTime > ulTaskSwitchedInTime ) { pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime ); } @@ -2238,8 +2889,7 @@ void vTaskSwitchContext( void ) #endif /* configGENERATE_RUN_TIME_STATS */ /* Check for stack overflow, if configured. */ - taskFIRST_CHECK_FOR_STACK_OVERFLOW(); - taskSECOND_CHECK_FOR_STACK_OVERFLOW(); + taskCHECK_FOR_STACK_OVERFLOW(); /* Select a new task to run using either the generic C or port optimised asm code. */ @@ -2259,8 +2909,6 @@ void vTaskSwitchContext( void ) void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) { -TickType_t xTimeToWake; - configASSERT( pxEventList ); /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE @@ -2272,54 +2920,12 @@ TickType_t xTimeToWake; list is locked, preventing simultaneous access from interrupts. */ vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) ); - /* The task must be removed from from the ready list before it is added to - the blocked list as the same list item is used for both lists. Exclusive - access to the ready lists guaranteed because the scheduler is locked. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is no need to - check, and the port reset macro can be called directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if ( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead of a delayed task - list to ensure the task is not woken by a timing event. It will - block indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be woken if the event - does not occur. This may overflow but this doesn't matter, the - scheduler will handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter, the scheduler - will handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); } /*-----------------------------------------------------------*/ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) { -TickType_t xTimeToWake; - configASSERT( pxEventList ); /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by @@ -2338,56 +2944,14 @@ TickType_t xTimeToWake; the task level). */ vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); - /* The task must be removed from the ready list before it is added to the - blocked list. Exclusive access can be assured to the ready list as the - scheduler is locked. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is no need to - check, and the port reset macro can be called directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if ( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead of a delayed task - list to ensure it is not woken by a timing event. It will block - indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be woken if the event - does not occur. This may overflow but this doesn't matter, the - kernel will manage it correctly. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter, the kernel - will manage it correctly. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); } /*-----------------------------------------------------------*/ -#if configUSE_TIMERS == 1 +#if( configUSE_TIMERS == 1 ) - void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait ) + void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) { - TickType_t xTimeToWake; - configASSERT( pxEventList ); /* This function should not be called by application code hence the @@ -2402,27 +2966,16 @@ TickType_t xTimeToWake; can be used in place of vListInsert. */ vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); - /* We must remove this task from the ready list before adding it to the - blocked list as the same list item is used for both lists. This - function is called with the scheduler locked so interrupts will not - access the lists at the same time. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is no need to - check, and the port reset macro can be called directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else + /* If the task should block indefinitely then set the block time to a + value that will be recognised as an indefinite delay inside the + prvAddCurrentTaskToDelayedList() function. */ + if( xWaitIndefinitely != pdFALSE ) { - mtCOVERAGE_TEST_MARKER(); + xTicksToWait = portMAX_DELAY; } - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter. */ - xTimeToWake = xTickCount + xTicksToWait; - - traceTASK_DELAY_UNTIL(); - prvAddCurrentTaskToDelayedList( xTimeToWake ); + traceTASK_DELAY_UNTIL( ( xTickCount + xTicksToWait ) ); + prvAddCurrentTaskToDelayedList( xTicksToWait, xWaitIndefinitely ); } #endif /* configUSE_TIMERS */ @@ -2450,9 +3003,9 @@ BaseType_t xReturn; configASSERT( pxUnblockedTCB ); ( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) ); - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); prvAddTaskToReadyList( pxUnblockedTCB ); } else @@ -2462,7 +3015,7 @@ BaseType_t xReturn; vListInsertEnd( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); } - if ( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) + if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) { /* Return true if the task removed from the event list has a higher priority than the calling task. This allows the calling task to know if @@ -2478,12 +3031,12 @@ BaseType_t xReturn; xReturn = pdFALSE; } - #if ( configUSE_TICKLESS_IDLE == 1 ) + #if( configUSE_TICKLESS_IDLE != 0 ) { /* If a task is blocked on a kernel object then xNextTaskUnblockTime might be set to the blocked task's time out time. If the task is unblocked for a reason other than a timeout xNextTaskUnblockTime is - normally left unchanged, because it is automatically get reset to a new + normally left unchanged, because it is automatically reset to a new value when the tick count equals xNextTaskUnblockTime. However if tickless idling is used it might be more important to enter sleep mode at the earliest possible time - so reset xNextTaskUnblockTime here to @@ -2496,10 +3049,9 @@ BaseType_t xReturn; } /*-----------------------------------------------------------*/ -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) +void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) { TCB_t *pxUnblockedTCB; -BaseType_t xReturn; /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by the event flags implementation. */ @@ -2517,33 +3069,35 @@ BaseType_t xReturn; /* Remove the task from the delayed list and add it to the ready list. The scheduler is suspended so interrupts will not be accessing the ready lists. */ - ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); prvAddTaskToReadyList( pxUnblockedTCB ); - if ( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) + if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) { - /* Return true if the task removed from the event list has - a higher priority than the calling task. This allows - the calling task to know if it should force a context - switch now. */ - xReturn = pdTRUE; - - /* Mark that a yield is pending in case the user is not using the - "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */ + /* The unblocked task has a priority above that of the calling task, so + a context switch is required. This function is called with the + scheduler suspended so xYieldPending is set so the context switch + occurs immediately that the scheduler is resumed (unsuspended). */ xYieldPending = pdTRUE; } - else - { - xReturn = pdFALSE; - } - - return xReturn; } /*-----------------------------------------------------------*/ void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) { configASSERT( pxTimeOut ); + taskENTER_CRITICAL(); + { + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = xTickCount; + } + taskEXIT_CRITICAL(); +} +/*-----------------------------------------------------------*/ + +void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) +{ + /* For internal use only as it does not use a critical section. */ pxTimeOut->xOverflowCount = xNumOfOverflows; pxTimeOut->xTimeOnEntering = xTickCount; } @@ -2560,35 +3114,49 @@ BaseType_t xReturn; { /* Minor optimisation. The tick count cannot change in this block. */ const TickType_t xConstTickCount = xTickCount; + const TickType_t xElapsedTime = xConstTickCount - pxTimeOut->xTimeOnEntering; + + #if( INCLUDE_xTaskAbortDelay == 1 ) + if( pxCurrentTCB->ucDelayAborted != pdFALSE ) + { + /* The delay was aborted, which is not the same as a time out, + but has the same result. */ + pxCurrentTCB->ucDelayAborted = pdFALSE; + xReturn = pdTRUE; + } + else + #endif #if ( INCLUDE_vTaskSuspend == 1 ) - /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is - the maximum block time then the task should block indefinitely, and - therefore never time out. */ - if ( *pxTicksToWait == portMAX_DELAY ) + if( *pxTicksToWait == portMAX_DELAY ) { + /* If INCLUDE_vTaskSuspend is set to 1 and the block time + specified is the maximum block time then the task should block + indefinitely, and therefore never time out. */ xReturn = pdFALSE; } - else /* We are not blocking indefinitely, perform the checks below. */ + else #endif - if ( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */ + if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */ { - /* The tick count is greater than the time at which vTaskSetTimeout() - was called, but has also overflowed since vTaskSetTimeOut() was called. - It must have wrapped all the way around and gone past us again. This - passed since vTaskSetTimeout() was called. */ + /* The tick count is greater than the time at which + vTaskSetTimeout() was called, but has also overflowed since + vTaskSetTimeOut() was called. It must have wrapped all the way + around and gone past again. This passed since vTaskSetTimeout() + was called. */ xReturn = pdTRUE; } - else if ( ( xConstTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait ) + else if( xElapsedTime < *pxTicksToWait ) /*lint !e961 Explicit casting is only redundant with some compilers, whereas others require it to prevent integer conversion errors. */ { /* Not a genuine timeout. Adjust parameters for time remaining. */ - *pxTicksToWait -= ( xConstTickCount - pxTimeOut->xTimeOnEntering ); - vTaskSetTimeOutState( pxTimeOut ); + *pxTicksToWait -= xElapsedTime; + vTaskInternalSetTimeOutState( pxTimeOut ); xReturn = pdFALSE; } else { + *pxTicksToWait = 0; xReturn = pdTRUE; } } @@ -2611,7 +3179,7 @@ void vTaskMissedYield( void ) UBaseType_t uxReturn; TCB_t *pxTCB; - if ( xTask != NULL ) + if( xTask != NULL ) { pxTCB = ( TCB_t * ) xTask; uxReturn = pxTCB->uxTaskNumber; @@ -2633,7 +3201,7 @@ void vTaskMissedYield( void ) { TCB_t *pxTCB; - if ( xTask != NULL ) + if( xTask != NULL ) { pxTCB = ( TCB_t * ) xTask; pxTCB->uxTaskNumber = uxHandle; @@ -2658,9 +3226,18 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) /* Stop warnings. */ ( void ) pvParameters; - for ( ;; ) + /** THIS IS THE RTOS IDLE TASK - WHICH IS CREATED AUTOMATICALLY WHEN THE + SCHEDULER IS STARTED. **/ + + /* In case a task that has a secure context deletes itself, in which case + the idle task is responsible for deleting the task's secure context, if + any. */ + portTASK_CALLS_SECURE_FUNCTIONS(); + + for( ;; ) { - /* See if any tasks have been deleted. */ + /* See if any tasks have deleted themselves - if so then the idle task + is responsible for freeing the deleted task's TCB and stack. */ prvCheckTasksWaitingTermination(); #if ( configUSE_PREEMPTION == 0 ) @@ -2684,7 +3261,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) the list, and an occasional incorrect value will not matter. If the ready list at the idle priority contains more than one task then a task other than the idle task is ready to execute. */ - if ( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 ) + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 ) { taskYIELD(); } @@ -2723,7 +3300,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) valid. */ xExpectedIdleTime = prvGetExpectedIdleTime(); - if ( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) + if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) { vTaskSuspendAll(); { @@ -2733,7 +3310,12 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) configASSERT( xNextTaskUnblockTime >= xTickCount ); xExpectedIdleTime = prvGetExpectedIdleTime(); - if ( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) + /* Define the following macro to set xExpectedIdleTime to 0 + if the application does not want + portSUPPRESS_TICKS_AND_SLEEP() to be called. */ + configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( xExpectedIdleTime ); + + if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) { traceLOW_POWER_IDLE_BEGIN(); portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ); @@ -2756,158 +3338,44 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) } /*-----------------------------------------------------------*/ -#if configUSE_TICKLESS_IDLE != 0 +#if( configUSE_TICKLESS_IDLE != 0 ) eSleepModeStatus eTaskConfirmSleepModeStatus( void ) { + /* The idle task exists in addition to the application tasks. */ + const UBaseType_t uxNonApplicationTasks = 1; eSleepModeStatus eReturn = eStandardSleep; - if ( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 ) + if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 ) { /* A task was made ready while the scheduler was suspended. */ eReturn = eAbortSleep; } - else if ( xYieldPending != pdFALSE ) + else if( xYieldPending != pdFALSE ) { /* A yield was pended while the scheduler was suspended. */ eReturn = eAbortSleep; } else { - #if configUSE_TIMERS == 0 + /* If all the tasks are in the suspended list (which might mean they + have an infinite block time rather than actually being suspended) + then it is safe to turn all clocks off and just wait for external + interrupts. */ + if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) { - /* The idle task exists in addition to the application tasks. */ - const UBaseType_t uxNonApplicationTasks = 1; - - /* If timers are not being used and all the tasks are in the - suspended list (which might mean they have an infinite block - time rather than actually being suspended) then it is safe to - turn all clocks off and just wait for external interrupts. */ - if ( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) - { - eReturn = eNoTasksWaitingTimeout; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + eReturn = eNoTasksWaitingTimeout; + } + else + { + mtCOVERAGE_TEST_MARKER(); } - #endif /* configUSE_TIMERS */ } return eReturn; } -#endif /* configUSE_TICKLESS_IDLE */ -/*-----------------------------------------------------------*/ - -static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ -{ -UBaseType_t x; - - /* Store the task name in the TCB. */ - for ( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ ) - { - pxTCB->pcTaskName[ x ] = pcName[ x ]; - - /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than - configMAX_TASK_NAME_LEN characters just in case the memory after the - string is not accessible (extremely unlikely). */ - if ( pcName[ x ] == 0x00 ) - { - break; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - /* Ensure the name string is terminated in the case that the string length - was greater or equal to configMAX_TASK_NAME_LEN. */ - pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0'; - - /* This is used as an array index so must ensure it's not too large. First - remove the privilege bit if one is present. */ - if ( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) - { - uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - pxTCB->uxPriority = uxPriority; - #if ( configUSE_MUTEXES == 1 ) - { - pxTCB->uxBasePriority = uxPriority; - pxTCB->uxMutexesHeld = 0; - } - #endif /* configUSE_MUTEXES */ - - vListInitialiseItem( &( pxTCB->xGenericListItem ) ); - vListInitialiseItem( &( pxTCB->xEventListItem ) ); - - /* Set the pxTCB as a link back from the ListItem_t. This is so we can get - back to the containing TCB from a generic item in a list. */ - listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB ); - - /* Event lists are always in priority order. */ - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB ); - - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - { - pxTCB->uxCriticalNesting = ( UBaseType_t ) 0U; - } - #endif /* portCRITICAL_NESTING_IN_TCB */ - - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - { - pxTCB->pxTaskTag = NULL; - } - #endif /* configUSE_APPLICATION_TASK_TAG */ - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - pxTCB->ulRunTimeCounter = 0UL; - } - #endif /* configGENERATE_RUN_TIME_STATS */ - - #if ( portUSING_MPU_WRAPPERS == 1 ) - { - vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, pxTCB->pxStack, usStackDepth ); - } - #else /* portUSING_MPU_WRAPPERS */ - { - ( void ) xRegions; - ( void ) usStackDepth; - } - #endif /* portUSING_MPU_WRAPPERS */ - - #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - { - for ( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ ) - { - pxTCB->pvThreadLocalStoragePointers[ x ] = NULL; - } - } - #endif - - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - { - pxTCB->ulNotifiedValue = 0; - pxTCB->eNotifyState = eNotWaitingNotification; - } - #endif - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - { - /* Initialise this task's Newlib reent structure. */ - _REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) ); - } - #endif /* configUSE_NEWLIB_REENTRANT */ -} +#endif /* configUSE_TICKLESS_IDLE */ /*-----------------------------------------------------------*/ #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) @@ -2916,7 +3384,7 @@ UBaseType_t x; { TCB_t *pxTCB; - if ( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) + if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) { pxTCB = prvGetTCBFromHandle( xTaskToSet ); pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue; @@ -2933,7 +3401,7 @@ UBaseType_t x; void *pvReturn = NULL; TCB_t *pxTCB; - if ( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) + if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) { pxTCB = prvGetTCBFromHandle( xTaskToQuery ); pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ]; @@ -2955,10 +3423,11 @@ UBaseType_t x; { TCB_t *pxTCB; - /* If null is passed in here then we are deleting ourselves. */ + /* If null is passed in here then we are modifying the MPU settings of + the calling task. */ pxTCB = prvGetTCBFromHandle( xTaskToModify ); - vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 ); + vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 ); } #endif /* portUSING_MPU_WRAPPERS */ @@ -2968,7 +3437,7 @@ static void prvInitialiseTaskLists( void ) { UBaseType_t uxPriority; - for ( uxPriority = ( UBaseType_t ) 0U; uxPriority < ( UBaseType_t ) configMAX_PRIORITIES; uxPriority++ ) + for( uxPriority = ( UBaseType_t ) 0U; uxPriority < ( UBaseType_t ) configMAX_PRIORITIES; uxPriority++ ) { vListInitialise( &( pxReadyTasksLists[ uxPriority ] ) ); } @@ -2998,223 +3467,150 @@ UBaseType_t uxPriority; static void prvCheckTasksWaitingTermination( void ) { + + /** THIS FUNCTION IS CALLED FROM THE RTOS IDLE TASK **/ + #if ( INCLUDE_vTaskDelete == 1 ) { - BaseType_t xListIsEmpty; + TCB_t *pxTCB; - /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called - too often in the idle task. */ - while ( uxTasksDeleted > ( UBaseType_t ) 0U ) + /* uxDeletedTasksWaitingCleanUp is used to prevent vTaskSuspendAll() + being called too often in the idle task. */ + while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U ) { - vTaskSuspendAll(); + taskENTER_CRITICAL(); { - xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination ); + pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + --uxCurrentNumberOfTasks; + --uxDeletedTasksWaitingCleanUp; } - ( void ) xTaskResumeAll(); - - if ( xListIsEmpty == pdFALSE ) - { - TCB_t *pxTCB; - - taskENTER_CRITICAL(); - { - pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) ); - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - --uxCurrentNumberOfTasks; - --uxTasksDeleted; - } - taskEXIT_CRITICAL(); + taskEXIT_CRITICAL(); - prvDeleteTCB( pxTCB ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + prvDeleteTCB( pxTCB ); } } - #endif /* vTaskDelete */ + #endif /* INCLUDE_vTaskDelete */ } /*-----------------------------------------------------------*/ -static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) -{ - /* The list item will be inserted in wake time order. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); +#if( configUSE_TRACE_FACILITY == 1 ) - if ( xTimeToWake < xTickCount ) - { - /* Wake time has overflowed. Place this item in the overflow list. */ - vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else + void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) { - /* The wake time has not overflowed, so the current block list is used. */ - vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) ); + TCB_t *pxTCB; + + /* xTask is NULL then get the state of the calling task. */ + pxTCB = prvGetTCBFromHandle( xTask ); - /* If the task entering the blocked state was placed at the head of the - list of blocked tasks then xNextTaskUnblockTime needs to be updated - too. */ - if ( xTimeToWake < xNextTaskUnblockTime ) + pxTaskStatus->xHandle = ( TaskHandle_t ) pxTCB; + pxTaskStatus->pcTaskName = ( const char * ) &( pxTCB->pcTaskName [ 0 ] ); + pxTaskStatus->uxCurrentPriority = pxTCB->uxPriority; + pxTaskStatus->pxStackBase = pxTCB->pxStack; + pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber; + + #if ( configUSE_MUTEXES == 1 ) { - xNextTaskUnblockTime = xTimeToWake; + pxTaskStatus->uxBasePriority = pxTCB->uxBasePriority; } - else + #else { - mtCOVERAGE_TEST_MARKER(); + pxTaskStatus->uxBasePriority = 0; } - } -} -/*-----------------------------------------------------------*/ - -static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer ) -{ -TCB_t *pxNewTCB; - - /* If the stack grows down then allocate the stack then the TCB so the stack - does not grow into the TCB. Likewise if the stack grows up then allocate - the TCB then the stack. */ - #if ( portSTACK_GROWTH > 0 ) - { - /* Allocate space for the TCB. Where the memory comes from depends on - the implementation of the port malloc function. */ - pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); + #endif - if ( pxNewTCB != NULL ) + #if ( configGENERATE_RUN_TIME_STATS == 1 ) { - /* Allocate space for the stack used by the task being created. - The base of the stack memory stored in the TCB so the task can - be deleted later if required. */ - pxNewTCB->pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - if ( pxNewTCB->pxStack == NULL ) - { - /* Could not allocate the stack. Delete the allocated TCB. */ - vPortFree( pxNewTCB ); - pxNewTCB = NULL; - } + pxTaskStatus->ulRunTimeCounter = pxTCB->ulRunTimeCounter; } - } - #else /* portSTACK_GROWTH */ - { - StackType_t *pxStack; - - /* Allocate space for the stack used by the task being created. */ - pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - if ( pxStack != NULL ) + #else { - /* Allocate space for the TCB. Where the memory comes from depends - on the implementation of the port malloc function. */ - pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); + pxTaskStatus->ulRunTimeCounter = 0; + } + #endif - if ( pxNewTCB != NULL ) + /* Obtaining the task state is a little fiddly, so is only done if the + value of eState passed into this function is eInvalid - otherwise the + state is just set to whatever is passed in. */ + if( eState != eInvalid ) + { + if( pxTCB == pxCurrentTCB ) { - /* Store the stack location in the TCB. */ - pxNewTCB->pxStack = pxStack; + pxTaskStatus->eCurrentState = eRunning; } else { - /* The stack cannot be used as the TCB was not created. Free it - again. */ - vPortFree( pxStack ); + pxTaskStatus->eCurrentState = eState; + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + /* If the task is in the suspended list then there is a + chance it is actually just blocked indefinitely - so really + it should be reported as being in the Blocked state. */ + if( eState == eSuspended ) + { + vTaskSuspendAll(); + { + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + pxTaskStatus->eCurrentState = eBlocked; + } + } + ( void ) xTaskResumeAll(); + } + } + #endif /* INCLUDE_vTaskSuspend */ } } else { - pxNewTCB = NULL; + pxTaskStatus->eCurrentState = eTaskGetState( pxTCB ); } - } - #endif /* portSTACK_GROWTH */ - if ( pxNewTCB != NULL ) - { - /* Avoid dependency on memset() if it is not required. */ - #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) + /* Obtaining the stack space takes some time, so the xGetFreeStackSpace + parameter is provided to allow it to be skipped. */ + if( xGetFreeStackSpace != pdFALSE ) + { + #if ( portSTACK_GROWTH > 0 ) + { + pxTaskStatus->usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxTCB->pxEndOfStack ); + } + #else + { + pxTaskStatus->usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxTCB->pxStack ); + } + #endif + } + else { - /* Just to help debugging. */ - ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( StackType_t ) ); + pxTaskStatus->usStackHighWaterMark = 0; } - #endif /* ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) ) */ } - return pxNewTCB; -} +#endif /* configUSE_TRACE_FACILITY */ /*-----------------------------------------------------------*/ #if ( configUSE_TRACE_FACILITY == 1 ) - static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) - { - volatile TCB_t *pxNextTCB, *pxFirstTCB; - UBaseType_t uxTask = 0; - - if ( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); - - /* Populate an TaskStatus_t structure within the - pxTaskStatusArray array for each task that is referenced from - pxList. See the definition of TaskStatus_t in task.h for the - meaning of each TaskStatus_t structure member. */ - do - { - listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); - - pxTaskStatusArray[ uxTask ].xHandle = ( TaskHandle_t ) pxNextTCB; - pxTaskStatusArray[ uxTask ].pcTaskName = ( const char * ) &( pxNextTCB->pcTaskName [ 0 ] ); - pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber; - pxTaskStatusArray[ uxTask ].eCurrentState = eState; - pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority; - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - /* If the task is in the suspended list then there is a chance - it is actually just blocked indefinitely - so really it should - be reported as being in the Blocked state. */ - if ( eState == eSuspended ) - { - if ( listLIST_ITEM_CONTAINER( &( pxNextTCB->xEventListItem ) ) != NULL ) - { - pxTaskStatusArray[ uxTask ].eCurrentState = eBlocked; - } - } - } - #endif /* INCLUDE_vTaskSuspend */ - - #if ( configUSE_MUTEXES == 1 ) - { - pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority; - } - #else - { - pxTaskStatusArray[ uxTask ].uxBasePriority = 0; - } - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - pxTaskStatusArray[ uxTask ].ulRunTimeCounter = pxNextTCB->ulRunTimeCounter; - } - #else - { - pxTaskStatusArray[ uxTask ].ulRunTimeCounter = 0; - } - #endif - - #if ( portSTACK_GROWTH > 0 ) - { - pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxEndOfStack ); - } - #else - { - pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxStack ); - } - #endif - - uxTask++; + static UBaseType_t prvListTasksWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) + { + configLIST_VOLATILE TCB_t *pxNextTCB, *pxFirstTCB; + UBaseType_t uxTask = 0; + + if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); - } while ( pxNextTCB != pxFirstTCB ); + /* Populate an TaskStatus_t structure within the + pxTaskStatusArray array for each task that is referenced from + pxList. See the definition of TaskStatus_t in task.h for the + meaning of each TaskStatus_t structure member. */ + do + { + listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); + vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState ); + uxTask++; + } while( pxNextTCB != pxFirstTCB ); } else { @@ -3233,7 +3629,7 @@ TCB_t *pxNewTCB; { uint32_t ulCount = 0U; - while ( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE ) + while( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE ) { pucStackByte -= portSTACK_GROWTH; ulCount++; @@ -3292,22 +3688,40 @@ TCB_t *pxNewTCB; } #endif /* configUSE_NEWLIB_REENTRANT */ - #if ( portUSING_MPU_WRAPPERS == 1 ) + #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( portUSING_MPU_WRAPPERS == 0 ) ) { - /* Only free the stack if it was allocated dynamically in the first - place. */ - if ( pxTCB->xUsingStaticallyAllocatedStack == pdFALSE ) - { - vPortFreeAligned( pxTCB->pxStack ); - } + /* The task can only have been allocated dynamically - free both + the stack and TCB. */ + vPortFree( pxTCB->pxStack ); + vPortFree( pxTCB ); } - #else + #elif( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */ { - vPortFreeAligned( pxTCB->pxStack ); + /* The task could have been allocated statically or dynamically, so + check what was statically allocated before trying to free the + memory. */ + if( pxTCB->ucStaticallyAllocated == tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ) + { + /* Both the stack and TCB were allocated dynamically, so both + must be freed. */ + vPortFree( pxTCB->pxStack ); + vPortFree( pxTCB ); + } + else if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_ONLY ) + { + /* Only the stack was statically allocated, so the TCB is the + only memory that must be freed. */ + vPortFree( pxTCB ); + } + else + { + /* Neither the stack nor the TCB were allocated dynamically, so + nothing needs to be freed. */ + configASSERT( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB ); + mtCOVERAGE_TEST_MARKER(); + } } - #endif - - vPortFree( pxTCB ); + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ } #endif /* INCLUDE_vTaskDelete */ @@ -3317,11 +3731,11 @@ static void prvResetNextTaskUnblockTime( void ) { TCB_t *pxTCB; - if ( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) + if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) { /* The new current delayed list is empty. Set xNextTaskUnblockTime to the maximum possible value so it is extremely unlikely that the - if ( xTickCount >= xNextTaskUnblockTime ) test will pass until + if( xTickCount >= xNextTaskUnblockTime ) test will pass until there is an item in the delayed list. */ xNextTaskUnblockTime = portMAX_DELAY; } @@ -3332,7 +3746,7 @@ TCB_t *pxTCB; which the task at the head of the delayed list should be removed from the Blocked state. */ ( pxTCB ) = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); - xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xGenericListItem ) ); + xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xStateListItem ) ); } } /*-----------------------------------------------------------*/ @@ -3360,13 +3774,13 @@ TCB_t *pxTCB; { BaseType_t xReturn; - if ( xSchedulerRunning == pdFALSE ) + if( xSchedulerRunning == pdFALSE ) { xReturn = taskSCHEDULER_NOT_STARTED; } else { - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { xReturn = taskSCHEDULER_RUNNING; } @@ -3384,25 +3798,27 @@ TCB_t *pxTCB; #if ( configUSE_MUTEXES == 1 ) - void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) + BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) { - TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder; + TCB_t * const pxMutexHolderTCB = ( TCB_t * ) pxMutexHolder; + BaseType_t xReturn = pdFALSE; /* If the mutex was given back by an interrupt while the queue was - locked then the mutex holder might now be NULL. */ - if ( pxMutexHolder != NULL ) + locked then the mutex holder might now be NULL. _RB_ Is this still + needed as interrupts can no longer use mutexes? */ + if( pxMutexHolder != NULL ) { /* If the holder of the mutex has a priority below the priority of the task attempting to obtain the mutex then it will temporarily inherit the priority of the task attempting to obtain the mutex. */ - if ( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) + if( pxMutexHolderTCB->uxPriority < pxCurrentTCB->uxPriority ) { /* Adjust the mutex holder state to account for its new priority. Only reset the event list item value if the value is - not being used for anything else. */ - if ( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) + not being used for anything else. */ + if( ( listGET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) { - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + listSET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ } else { @@ -3411,11 +3827,11 @@ TCB_t *pxTCB; /* If the task being modified is in the ready state it will need to be moved into a new list. */ - if ( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxMutexHolderTCB->uxPriority ] ), &( pxMutexHolderTCB->xStateListItem ) ) != pdFALSE ) { - if ( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) + if( uxListRemove( &( pxMutexHolderTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) { - taskRESET_READY_PRIORITY( pxTCB->uxPriority ); + taskRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority ); } else { @@ -3423,26 +3839,45 @@ TCB_t *pxTCB; } /* Inherit the priority before being moved into the new list. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - prvAddTaskToReadyList( pxTCB ); + pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority; + prvAddTaskToReadyList( pxMutexHolderTCB ); } else { /* Just inherit the priority. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; + pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority; } - traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority ); + traceTASK_PRIORITY_INHERIT( pxMutexHolderTCB, pxCurrentTCB->uxPriority ); + + /* Inheritance occurred. */ + xReturn = pdTRUE; } else { - mtCOVERAGE_TEST_MARKER(); + if( pxMutexHolderTCB->uxBasePriority < pxCurrentTCB->uxPriority ) + { + /* The base priority of the mutex holder is lower than the + priority of the task attempting to take the mutex, but the + current priority of the mutex holder is not lower than the + priority of the task attempting to take the mutex. + Therefore the mutex holder must have already inherited a + priority, but inheritance would have occurred if that had + not been the case. */ + xReturn = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } } else { mtCOVERAGE_TEST_MARKER(); } + + return xReturn; } #endif /* configUSE_MUTEXES */ @@ -3455,30 +3890,29 @@ TCB_t *pxTCB; TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder; BaseType_t xReturn = pdFALSE; - if ( pxMutexHolder != NULL ) + if( pxMutexHolder != NULL ) { /* A task can only have an inherited priority if it holds the mutex. If the mutex is held by a task then it cannot be given from an interrupt, and if a mutex is given by the holding task then it must be the running state task. */ configASSERT( pxTCB == pxCurrentTCB ); - configASSERT( pxTCB->uxMutexesHeld ); ( pxTCB->uxMutexesHeld )--; /* Has the holder of the mutex inherited the priority of another task? */ - if ( pxTCB->uxPriority != pxTCB->uxBasePriority ) + if( pxTCB->uxPriority != pxTCB->uxBasePriority ) { /* Only disinherit if no other mutexes are held. */ - if ( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) + if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) { /* A task can only have an inherited priority if it holds the mutex. If the mutex is held by a task then it cannot be given from an interrupt, and if a mutex is given by the - holding task then it must be the running state task. Remove - the holding task from the ready list. */ - if ( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) + holding task then it must be the running state task. Remove + the holding task from the ready list. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) { taskRESET_READY_PRIORITY( pxTCB->uxPriority ); } @@ -3529,13 +3963,115 @@ TCB_t *pxTCB; #endif /* configUSE_MUTEXES */ /*-----------------------------------------------------------*/ +#if ( configUSE_MUTEXES == 1 ) + + void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) + { + TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder; + UBaseType_t uxPriorityUsedOnEntry, uxPriorityToUse; + const UBaseType_t uxOnlyOneMutexHeld = ( UBaseType_t ) 1; + + if( pxMutexHolder != NULL ) + { + /* If pxMutexHolder is not NULL then the holder must hold at least + one mutex. */ + configASSERT( pxTCB->uxMutexesHeld ); + + /* Determine the priority to which the priority of the task that + holds the mutex should be set. This will be the greater of the + holding task's base priority and the priority of the highest + priority task that is waiting to obtain the mutex. */ + if( pxTCB->uxBasePriority < uxHighestPriorityWaitingTask ) + { + uxPriorityToUse = uxHighestPriorityWaitingTask; + } + else + { + uxPriorityToUse = pxTCB->uxBasePriority; + } + + /* Does the priority need to change? */ + if( pxTCB->uxPriority != uxPriorityToUse ) + { + /* Only disinherit if no other mutexes are held. This is a + simplification in the priority inheritance implementation. If + the task that holds the mutex is also holding other mutexes then + the other mutexes may have caused the priority inheritance. */ + if( pxTCB->uxMutexesHeld == uxOnlyOneMutexHeld ) + { + /* If a task has timed out because it already holds the + mutex it was trying to obtain then it cannot of inherited + its own priority. */ + configASSERT( pxTCB != pxCurrentTCB ); + + /* Disinherit the priority, remembering the previous + priority to facilitate determining the subject task's + state. */ + traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority ); + uxPriorityUsedOnEntry = pxTCB->uxPriority; + pxTCB->uxPriority = uxPriorityToUse; + + /* Only reset the event list item value if the value is not + being used for anything else. */ + if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) + { + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriorityToUse ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* If the running task is not the task that holds the mutex + then the task that holds the mutex could be in either the + Ready, Blocked or Suspended states. Only remove the task + from its current state list if it is in the Ready state as + the task's priority is going to change and there is one + Ready list per priority. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE ) + { + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + taskRESET_READY_PRIORITY( pxTCB->uxPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + prvAddTaskToReadyList( pxTCB ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) void vTaskEnterCritical( void ) { portDISABLE_INTERRUPTS(); - if ( xSchedulerRunning != pdFALSE ) + if( xSchedulerRunning != pdFALSE ) { ( pxCurrentTCB->uxCriticalNesting )++; @@ -3545,11 +4081,10 @@ TCB_t *pxTCB; interrupt. Only assert if the critical nesting count is 1 to protect against recursive calls if the assert function also uses a critical section. */ - if ( pxCurrentTCB->uxCriticalNesting == 1 ) + if( pxCurrentTCB->uxCriticalNesting == 1 ) { portASSERT_IF_IN_ISR(); } - } else { @@ -3564,13 +4099,13 @@ TCB_t *pxTCB; void vTaskExitCritical( void ) { - if ( xSchedulerRunning != pdFALSE ) + if( xSchedulerRunning != pdFALSE ) { - if ( pxCurrentTCB->uxCriticalNesting > 0U ) + if( pxCurrentTCB->uxCriticalNesting > 0U ) { ( pxCurrentTCB->uxCriticalNesting )--; - if ( pxCurrentTCB->uxCriticalNesting == 0U ) + if( pxCurrentTCB->uxCriticalNesting == 0U ) { portENABLE_INTERRUPTS(); } @@ -3597,14 +4132,14 @@ TCB_t *pxTCB; static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName ) { - BaseType_t x; + size_t x; /* Start by copying the entire string. */ strcpy( pcBuffer, pcTaskName ); /* Pad the end of the string with spaces to ensure columns line up when printed out. */ - for ( x = strlen( pcBuffer ); x < ( configMAX_TASK_NAME_LEN - 1 ); x++ ) + for( x = strlen( pcBuffer ); x < ( size_t ) ( configMAX_TASK_NAME_LEN - 1 ); x++ ) { pcBuffer[ x ] = ' '; } @@ -3619,7 +4154,7 @@ TCB_t *pxTCB; #endif /* ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) */ /*-----------------------------------------------------------*/ -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) void vTaskList( char * pcWriteBuffer ) { @@ -3659,18 +4194,20 @@ TCB_t *pxTCB; function is executing. */ uxArraySize = uxCurrentNumberOfTasks; - /* Allocate an array index for each task. */ + /* Allocate an array index for each task. NOTE! if + configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will + equate to NULL. */ pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); - if ( pxTaskStatusArray != NULL ) + if( pxTaskStatusArray != NULL ) { /* Generate the (binary) data. */ uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL ); /* Create a human readable table from the binary data. */ - for ( x = 0; x < uxArraySize; x++ ) + for( x = 0; x < uxArraySize; x++ ) { - switch ( pxTaskStatusArray[ x ].eCurrentState ) + switch( pxTaskStatusArray[ x ].eCurrentState ) { case eReady: cStatus = tskREADY_CHAR; break; @@ -3699,7 +4236,8 @@ TCB_t *pxTCB; pcWriteBuffer += strlen( pcWriteBuffer ); } - /* Free the array again. */ + /* Free the array again. NOTE! If configSUPPORT_DYNAMIC_ALLOCATION + is 0 then vPortFree() will be #defined to nothing. */ vPortFree( pxTaskStatusArray ); } else @@ -3708,10 +4246,10 @@ TCB_t *pxTCB; } } -#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */ +#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ /*----------------------------------------------------------*/ -#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) +#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) void vTaskGetRunTimeStats( char *pcWriteBuffer ) { @@ -3719,7 +4257,7 @@ TCB_t *pxTCB; volatile UBaseType_t uxArraySize, x; uint32_t ulTotalTime, ulStatsAsPercentage; - #if ( configUSE_TRACE_FACILITY != 1 ) + #if( configUSE_TRACE_FACILITY != 1 ) { #error configUSE_TRACE_FACILITY must also be set to 1 in FreeRTOSConfig.h to use vTaskGetRunTimeStats(). } @@ -3757,10 +4295,12 @@ TCB_t *pxTCB; function is executing. */ uxArraySize = uxCurrentNumberOfTasks; - /* Allocate an array index for each task. */ + /* Allocate an array index for each task. NOTE! If + configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will + equate to NULL. */ pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); - if ( pxTaskStatusArray != NULL ) + if( pxTaskStatusArray != NULL ) { /* Generate the (binary) data. */ uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalTime ); @@ -3769,10 +4309,10 @@ TCB_t *pxTCB; ulTotalTime /= 100UL; /* Avoid divide by zero errors. */ - if ( ulTotalTime > 0 ) + if( ulTotalTime > 0 ) { /* Create a human readable table from the binary data. */ - for ( x = 0; x < uxArraySize; x++ ) + for( x = 0; x < uxArraySize; x++ ) { /* What percentage of the total run time has the task used? This will always be rounded down to the nearest integer. @@ -3784,7 +4324,7 @@ TCB_t *pxTCB; easily. */ pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); - if ( ulStatsAsPercentage > 0UL ) + if( ulStatsAsPercentage > 0UL ) { #ifdef portLU_PRINTF_SPECIFIER_REQUIRED { @@ -3823,7 +4363,8 @@ TCB_t *pxTCB; mtCOVERAGE_TEST_MARKER(); } - /* Free the array again. */ + /* Free the array again. NOTE! If configSUPPORT_DYNAMIC_ALLOCATION + is 0 then vPortFree() will be #defined to nothing. */ vPortFree( pxTaskStatusArray ); } else @@ -3832,7 +4373,7 @@ TCB_t *pxTCB; } } -#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */ +#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */ /*-----------------------------------------------------------*/ TickType_t uxTaskResetEventItemValue( void ) @@ -3855,7 +4396,7 @@ TickType_t uxReturn; { /* If xSemaphoreCreateMutex() is called before any tasks have been created then pxCurrentTCB will be NULL. */ - if ( pxCurrentTCB != NULL ) + if( pxCurrentTCB != NULL ) { ( pxCurrentTCB->uxMutexesHeld )++; } @@ -3866,67 +4407,24 @@ TickType_t uxReturn; #endif /* configUSE_MUTEXES */ /*-----------------------------------------------------------*/ -#if ( configUSE_TASK_NOTIFICATIONS == 1 ) +#if( configUSE_TASK_NOTIFICATIONS == 1 ) uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) { - TickType_t xTimeToWake; uint32_t ulReturn; taskENTER_CRITICAL(); { /* Only block if the notification count is not already non-zero. */ - if ( pxCurrentTCB->ulNotifiedValue == 0UL ) + if( pxCurrentTCB->ulNotifiedValue == 0UL ) { /* Mark this task as waiting for a notification. */ - pxCurrentTCB->eNotifyState = eWaitingNotification; + pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION; - if ( xTicksToWait > ( TickType_t ) 0 ) + if( xTicksToWait > ( TickType_t ) 0 ) { - /* The task is going to block. First it must be removed - from the ready list. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if ( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead - of a delayed task list to ensure the task is not - woken by a timing event. It will block - indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be - woken if no notification events occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be - woken if the event does not occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); + traceTASK_NOTIFY_TAKE_BLOCK(); /* All ports are written to allow a yield in a critical section (some will yield immediately, others wait until the @@ -3948,17 +4446,18 @@ TickType_t uxReturn; taskENTER_CRITICAL(); { + traceTASK_NOTIFY_TAKE(); ulReturn = pxCurrentTCB->ulNotifiedValue; - if ( ulReturn != 0UL ) + if( ulReturn != 0UL ) { - if ( xClearCountOnExit != pdFALSE ) + if( xClearCountOnExit != pdFALSE ) { pxCurrentTCB->ulNotifiedValue = 0UL; } else { - ( pxCurrentTCB->ulNotifiedValue )--; + pxCurrentTCB->ulNotifiedValue = ulReturn - ( uint32_t ) 1; } } else @@ -3966,7 +4465,7 @@ TickType_t uxReturn; mtCOVERAGE_TEST_MARKER(); } - pxCurrentTCB->eNotifyState = eNotWaitingNotification; + pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION; } taskEXIT_CRITICAL(); @@ -3976,17 +4475,16 @@ TickType_t uxReturn; #endif /* configUSE_TASK_NOTIFICATIONS */ /*-----------------------------------------------------------*/ -#if ( configUSE_TASK_NOTIFICATIONS == 1 ) +#if( configUSE_TASK_NOTIFICATIONS == 1 ) BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) { - TickType_t xTimeToWake; BaseType_t xReturn; taskENTER_CRITICAL(); { /* Only block if a notification is not already pending. */ - if ( pxCurrentTCB->eNotifyState != eNotified ) + if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED ) { /* Clear bits in the task's notification value as bits may get set by the notifying task or interrupt. This can be used to @@ -3994,54 +4492,12 @@ TickType_t uxReturn; pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry; /* Mark this task as waiting for a notification. */ - pxCurrentTCB->eNotifyState = eWaitingNotification; + pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION; - if ( xTicksToWait > ( TickType_t ) 0 ) + if( xTicksToWait > ( TickType_t ) 0 ) { - /* The task is going to block. First it must be removed - from the ready list. */ - if ( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if ( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead - of a delayed task list to ensure the task is not - woken by a timing event. It will block - indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be - woken if no notification events occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be - woken if the event does not occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); + traceTASK_NOTIFY_WAIT_BLOCK(); /* All ports are written to allow a yield in a critical section (some will yield immediately, others wait until the @@ -4063,18 +4519,20 @@ TickType_t uxReturn; taskENTER_CRITICAL(); { - if ( pulNotificationValue != NULL ) + traceTASK_NOTIFY_WAIT(); + + if( pulNotificationValue != NULL ) { /* Output the current notification value, which may or may not have changed. */ *pulNotificationValue = pxCurrentTCB->ulNotifiedValue; } - /* If eNotifyValue is set then either the task never entered the + /* If ucNotifyValue is set then either the task never entered the blocked state (because a notification was already pending) or the task unblocked because of a notification. Otherwise the task unblocked because of a timeout. */ - if ( pxCurrentTCB->eNotifyState == eWaitingNotification ) + if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED ) { /* A notification was not received. */ xReturn = pdFALSE; @@ -4087,7 +4545,7 @@ TickType_t uxReturn; xReturn = pdTRUE; } - pxCurrentTCB->eNotifyState = eNotWaitingNotification; + pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION; } taskEXIT_CRITICAL(); @@ -4097,29 +4555,29 @@ TickType_t uxReturn; #endif /* configUSE_TASK_NOTIFICATIONS */ /*-----------------------------------------------------------*/ -#if ( configUSE_TASK_NOTIFICATIONS == 1 ) +#if( configUSE_TASK_NOTIFICATIONS == 1 ) BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) { TCB_t * pxTCB; - eNotifyValue eOriginalNotifyState; BaseType_t xReturn = pdPASS; + uint8_t ucOriginalNotifyState; configASSERT( xTaskToNotify ); pxTCB = ( TCB_t * ) xTaskToNotify; taskENTER_CRITICAL(); { - if ( pulPreviousNotificationValue != NULL ) + if( pulPreviousNotificationValue != NULL ) { *pulPreviousNotificationValue = pxTCB->ulNotifiedValue; } - eOriginalNotifyState = pxTCB->eNotifyState; + ucOriginalNotifyState = pxTCB->ucNotifyState; - pxTCB->eNotifyState = eNotified; + pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED; - switch ( eAction ) + switch( eAction ) { case eSetBits : pxTCB->ulNotifiedValue |= ulValue; @@ -4134,7 +4592,7 @@ TickType_t uxReturn; break; case eSetValueWithoutOverwrite : - if ( eOriginalNotifyState != eNotified ) + if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED ) { pxTCB->ulNotifiedValue = ulValue; } @@ -4151,18 +4609,35 @@ TickType_t uxReturn; break; } + traceTASK_NOTIFY(); /* If the task is in the blocked state specifically to wait for a notification then unblock it now. */ - if ( eOriginalNotifyState == eWaitingNotification ) + if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) { - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); /* The task should not have been on an event list. */ configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); - if ( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + #if( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked waiting for a notification then + xNextTaskUnblockTime might be set to the blocked task's time + out time. If the task is unblocked for a reason other than + a timeout xNextTaskUnblockTime is normally left unchanged, + because it will automatically get reset to a new value when + the tick count equals xNextTaskUnblockTime. However if + tickless idling is used it might be more important to enter + sleep mode at the earliest possible time - so reset + xNextTaskUnblockTime here to ensure it is updated at the + earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif + + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) { /* The notified task has a priority above the currently executing task so a yield is required. */ @@ -4186,12 +4661,12 @@ TickType_t uxReturn; #endif /* configUSE_TASK_NOTIFICATIONS */ /*-----------------------------------------------------------*/ -#if ( configUSE_TASK_NOTIFICATIONS == 1 ) +#if( configUSE_TASK_NOTIFICATIONS == 1 ) - BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ) + BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) { TCB_t * pxTCB; - eNotifyValue eOriginalNotifyState; + uint8_t ucOriginalNotifyState; BaseType_t xReturn = pdPASS; UBaseType_t uxSavedInterruptStatus; @@ -4219,11 +4694,15 @@ TickType_t uxReturn; uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { - eOriginalNotifyState = pxTCB->eNotifyState; + if( pulPreviousNotificationValue != NULL ) + { + *pulPreviousNotificationValue = pxTCB->ulNotifiedValue; + } - pxTCB->eNotifyState = eNotified; + ucOriginalNotifyState = pxTCB->ucNotifyState; + pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED; - switch ( eAction ) + switch( eAction ) { case eSetBits : pxTCB->ulNotifiedValue |= ulValue; @@ -4238,7 +4717,7 @@ TickType_t uxReturn; break; case eSetValueWithoutOverwrite : - if ( eOriginalNotifyState != eNotified ) + if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED ) { pxTCB->ulNotifiedValue = ulValue; } @@ -4255,17 +4734,18 @@ TickType_t uxReturn; break; } + traceTASK_NOTIFY_FROM_ISR(); /* If the task is in the blocked state specifically to wait for a notification then unblock it now. */ - if ( eOriginalNotifyState == eWaitingNotification ) + if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) { /* The task should not have been on an event list. */ configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); } else @@ -4275,14 +4755,21 @@ TickType_t uxReturn; vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); } - if ( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) { /* The notified task has a priority above the currently executing task so a yield is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) + if( pxHigherPriorityTaskWoken != NULL ) { *pxHigherPriorityTaskWoken = pdTRUE; } + else + { + /* Mark that a yield is pending in case the user is not + using the "xHigherPriorityTaskWoken" parameter to an ISR + safe FreeRTOS function. */ + xYieldPending = pdTRUE; + } } else { @@ -4298,12 +4785,12 @@ TickType_t uxReturn; #endif /* configUSE_TASK_NOTIFICATIONS */ /*-----------------------------------------------------------*/ -#if ( configUSE_TASK_NOTIFICATIONS == 1 ) +#if( configUSE_TASK_NOTIFICATIONS == 1 ) void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) { TCB_t * pxTCB; - eNotifyValue eOriginalNotifyState; + uint8_t ucOriginalNotifyState; UBaseType_t uxSavedInterruptStatus; configASSERT( xTaskToNotify ); @@ -4330,23 +4817,25 @@ TickType_t uxReturn; uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { - eOriginalNotifyState = pxTCB->eNotifyState; - pxTCB->eNotifyState = eNotified; + ucOriginalNotifyState = pxTCB->ucNotifyState; + pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED; /* 'Giving' is equivalent to incrementing a count in a counting semaphore. */ ( pxTCB->ulNotifiedValue )++; + traceTASK_NOTIFY_GIVE_FROM_ISR(); + /* If the task is in the blocked state specifically to wait for a notification then unblock it now. */ - if ( eOriginalNotifyState == eWaitingNotification ) + if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) { /* The task should not have been on an event list. */ configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); - if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); } else @@ -4356,14 +4845,21 @@ TickType_t uxReturn; vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); } - if ( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) { /* The notified task has a priority above the currently executing task so a yield is required. */ - if ( pxHigherPriorityTaskWoken != NULL ) + if( pxHigherPriorityTaskWoken != NULL ) { *pxHigherPriorityTaskWoken = pdTRUE; } + else + { + /* Mark that a yield is pending in case the user is not + using the "xHigherPriorityTaskWoken" parameter in an ISR + safe FreeRTOS function. */ + xYieldPending = pdTRUE; + } } else { @@ -4378,8 +4874,169 @@ TickType_t uxReturn; /*-----------------------------------------------------------*/ +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + + BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ) + { + TCB_t *pxTCB; + BaseType_t xReturn; + + /* If null is passed in here then it is the calling task that is having + its notification state cleared. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + taskENTER_CRITICAL(); + { + if( pxTCB->ucNotifyState == taskNOTIFICATION_RECEIVED ) + { + pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION; + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } + } + taskEXIT_CRITICAL(); + + return xReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + + +static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) +{ +TickType_t xTimeToWake; +const TickType_t xConstTickCount = xTickCount; + + #if( INCLUDE_xTaskAbortDelay == 1 ) + { + /* About to enter a delayed list, so ensure the ucDelayAborted flag is + reset to pdFALSE so it can be detected as having been set to pdTRUE + when the task leaves the Blocked state. */ + pxCurrentTCB->ucDelayAborted = pdFALSE; + } + #endif + + /* Remove the task from the ready list before adding it to the blocked list + as the same list item is used for both lists. */ + if( uxListRemove( &( pxCurrentTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + /* The current task must be in a ready list, so there is no need to + check, and the port reset macro can be called directly. */ + portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) ) + { + /* Add the task to the suspended task list instead of a delayed task + list to ensure it is not woken by a timing event. It will block + indefinitely. */ + vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) ); + } + else + { + /* Calculate the time at which the task should be woken if the event + does not occur. This may overflow but this doesn't matter, the + kernel will manage it correctly. */ + xTimeToWake = xConstTickCount + xTicksToWait; + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake ); + + if( xTimeToWake < xConstTickCount ) + { + /* Wake time has overflowed. Place this item in the overflow + list. */ + vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + } + else + { + /* The wake time has not overflowed, so the current block list + is used. */ + vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + + /* If the task entering the blocked state was placed at the + head of the list of blocked tasks then xNextTaskUnblockTime + needs to be updated too. */ + if( xTimeToWake < xNextTaskUnblockTime ) + { + xNextTaskUnblockTime = xTimeToWake; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + } + #else /* INCLUDE_vTaskSuspend */ + { + /* Calculate the time at which the task should be woken if the event + does not occur. This may overflow but this doesn't matter, the kernel + will manage it correctly. */ + xTimeToWake = xConstTickCount + xTicksToWait; + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake ); + + if( xTimeToWake < xConstTickCount ) + { + /* Wake time has overflowed. Place this item in the overflow list. */ + vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + } + else + { + /* The wake time has not overflowed, so the current block list is used. */ + vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + + /* If the task entering the blocked state was placed at the head of the + list of blocked tasks then xNextTaskUnblockTime needs to be updated + too. */ + if( xTimeToWake < xNextTaskUnblockTime ) + { + xNextTaskUnblockTime = xTimeToWake; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + /* Avoid compiler warning when INCLUDE_vTaskSuspend is not 1. */ + ( void ) xCanBlockIndefinitely; + } + #endif /* INCLUDE_vTaskSuspend */ +} + +/* Code below here allows additional code to be inserted into this source file, +especially where access to file scope functions and data is needed (for example +when performing module tests). */ #ifdef FREERTOS_MODULE_TEST #include "tasks_test_access_functions.h" #endif + +#if( configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H == 1 ) + + #include "freertos_tasks_c_additions.h" + + static void freertos_tasks_c_additions_init( void ) + { + #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT + FREERTOS_TASKS_C_ADDITIONS_INIT(); + #endif + } + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/timers.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/timers.c similarity index 64% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/timers.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/timers.c index 201f024..b006385 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/freertos/source/timers.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/freertos/source/timers.c @@ -1,71 +1,30 @@ /* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* Standard includes. */ #include @@ -100,6 +59,12 @@ configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ /* Misc definitions. */ #define tmrNO_DELAY ( TickType_t ) 0U +/* The name assigned to the timer service task. This can be overridden by +defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */ +#ifndef configTIMER_SERVICE_TASK_NAME + #define configTIMER_SERVICE_TASK_NAME "Tmr Svc" +#endif + /* The definition of the timers themselves. */ typedef struct tmrTimerControl { @@ -109,9 +74,13 @@ typedef struct tmrTimerControl UBaseType_t uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one-shot timer. */ void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */ TimerCallbackFunction_t pxCallbackFunction; /*<< The function that will be called when the timer expires. */ - #if ( configUSE_TRACE_FACILITY == 1 ) + #if( configUSE_TRACE_FACILITY == 1 ) UBaseType_t uxTimerNumber; /*<< An ID assigned by trace tools such as FreeRTOS+Trace */ #endif + + #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucStaticallyAllocated; /*<< Set to pdTRUE if the timer was created statically so no attempt is made to free the memory again if the timer is later deleted. */ + #endif } xTIMER; /* The old xTIMER name is maintained above then typedefed to the new Timer_t @@ -154,8 +123,8 @@ typedef struct tmrTimerQueueMessage } u; } DaemonTaskMessage_t; -/*lint -e956 A manual analysis and inspection has been used to determine which -static variables must be declared volatile. */ +/*lint -save -e956 A manual analysis and inspection has been used to determine +which static variables must be declared volatile. */ /* The list in which active timers are stored. Timers are referenced in expire time order, with the nearest expiry time at the front of the list. Only the @@ -167,16 +136,21 @@ PRIVILEGED_DATA static List_t *pxOverflowTimerList; /* A queue that is used to send commands to the timer service task. */ PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL; +PRIVILEGED_DATA static TaskHandle_t xTimerTaskHandle = NULL; -#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) +/*lint -restore */ - PRIVILEGED_DATA static TaskHandle_t xTimerTaskHandle = NULL; +/*-----------------------------------------------------------*/ -#endif +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) -/*lint +e956 */ + /* If static allocation is supported then the application must provide the + following callback function - which enables the application to optionally + provide the memory that will be used by the timer task as the task's stack + and TCB. */ + extern void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ); -/*-----------------------------------------------------------*/ +#endif /* * Initialise the infrastructure used by the timer service task if it has not @@ -195,7 +169,7 @@ static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION; * Called by the timer service task to interpret and process a command it * received on the timer queue. */ -static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION; +static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION; /* * Insert the timer into either xActiveTimerList1, or xActiveTimerList2, @@ -233,8 +207,18 @@ static TickType_t prvGetNextExpireTime( BaseType_t * const pxListWasEmpty ) PRIV * If a timer has expired, process it. Otherwise, block the timer service task * until either a timer does expire or a command is received. */ -static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION; +static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION; +/* + * Called after a Timer_t structure has been allocated either statically or + * dynamically to fill in the structure's members. + */ +static void prvInitialiseNewTimer( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + Timer_t *pxNewTimer ) PRIVILEGED_FUNCTION; /*-----------------------------------------------------------*/ BaseType_t xTimerCreateTimerTask( void ) @@ -247,20 +231,38 @@ BaseType_t xReturn = pdFAIL; been created then the initialisation will already have been performed. */ prvCheckForValidListAndQueue(); - if ( xTimerQueue != NULL ) + if( xTimerQueue != NULL ) { - #if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) { - /* Create the timer task, storing its handle in xTimerTaskHandle so - it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */ - xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle ); + StaticTask_t *pxTimerTaskTCBBuffer = NULL; + StackType_t *pxTimerTaskStackBuffer = NULL; + uint32_t ulTimerTaskStackSize; + + vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &ulTimerTaskStackSize ); + xTimerTaskHandle = xTaskCreateStatic( prvTimerTask, + configTIMER_SERVICE_TASK_NAME, + ulTimerTaskStackSize, + NULL, + ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, + pxTimerTaskStackBuffer, + pxTimerTaskTCBBuffer ); + + if( xTimerTaskHandle != NULL ) + { + xReturn = pdPASS; + } } #else { - /* Create the timer task without storing its handle. */ - xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL); + xReturn = xTaskCreate( prvTimerTask, + configTIMER_SERVICE_TASK_NAME, + configTIMER_TASK_STACK_DEPTH, + NULL, + ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, + &xTimerTaskHandle ); } - #endif + #endif /* configSUPPORT_STATIC_ALLOCATION */ } else { @@ -272,44 +274,108 @@ BaseType_t xReturn = pdFAIL; } /*-----------------------------------------------------------*/ -TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ -{ -Timer_t *pxNewTimer; +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - /* Allocate the timer structure. */ - if ( xTimerPeriodInTicks == ( TickType_t ) 0U ) + TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) { - pxNewTimer = NULL; + Timer_t *pxNewTimer; + + pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) ); + + if( pxNewTimer != NULL ) + { + prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer ); + + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* Timers can be created statically or dynamically, so note this + timer was created dynamically in case the timer is later + deleted. */ + pxNewTimer->ucStaticallyAllocated = pdFALSE; + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ + } + + return pxNewTimer; } - else + +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + + TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t *pxTimerBuffer ) { - pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) ); - if ( pxNewTimer != NULL ) + Timer_t *pxNewTimer; + + #if( configASSERT_DEFINED == 1 ) { - /* Ensure the infrastructure used by the timer service task has been - created/initialised. */ - prvCheckForValidListAndQueue(); - - /* Initialise the timer structure members using the function parameters. */ - pxNewTimer->pcTimerName = pcTimerName; - pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks; - pxNewTimer->uxAutoReload = uxAutoReload; - pxNewTimer->pvTimerID = pvTimerID; - pxNewTimer->pxCallbackFunction = pxCallbackFunction; - vListInitialiseItem( &( pxNewTimer->xTimerListItem ) ); - - traceTIMER_CREATE( pxNewTimer ); + /* Sanity check that the size of the structure used to declare a + variable of type StaticTimer_t equals the size of the real timer + structure. */ + volatile size_t xSize = sizeof( StaticTimer_t ); + configASSERT( xSize == sizeof( Timer_t ) ); } - else + #endif /* configASSERT_DEFINED */ + + /* A pointer to a StaticTimer_t structure MUST be provided, use it. */ + configASSERT( pxTimerBuffer ); + pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + + if( pxNewTimer != NULL ) { - traceTIMER_CREATE_FAILED(); + prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer ); + + #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + { + /* Timers can be created statically or dynamically so note this + timer was created statically in case it is later deleted. */ + pxNewTimer->ucStaticallyAllocated = pdTRUE; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ } + + return pxNewTimer; } +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +static void prvInitialiseNewTimer( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + Timer_t *pxNewTimer ) +{ /* 0 is not a valid value for xTimerPeriodInTicks. */ configASSERT( ( xTimerPeriodInTicks > 0 ) ); - return ( TimerHandle_t ) pxNewTimer; + if( pxNewTimer != NULL ) + { + /* Ensure the infrastructure used by the timer service task has been + created/initialised. */ + prvCheckForValidListAndQueue(); + + /* Initialise the timer structure members using the function + parameters. */ + pxNewTimer->pcTimerName = pcTimerName; + pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks; + pxNewTimer->uxAutoReload = uxAutoReload; + pxNewTimer->pvTimerID = pvTimerID; + pxNewTimer->pxCallbackFunction = pxCallbackFunction; + vListInitialiseItem( &( pxNewTimer->xTimerListItem ) ); + traceTIMER_CREATE( pxNewTimer ); + } } /*-----------------------------------------------------------*/ @@ -318,18 +384,20 @@ BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommand BaseType_t xReturn = pdFAIL; DaemonTaskMessage_t xMessage; + configASSERT( xTimer ); + /* Send a message to the timer service task to perform a particular action on a particular timer definition. */ - if ( xTimerQueue != NULL ) + if( xTimerQueue != NULL ) { /* Send a command to the timer service task to start the xTimer timer. */ xMessage.xMessageID = xCommandID; xMessage.u.xTimerParameters.xMessageValue = xOptionalValue; xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer; - if ( xCommandID < tmrFIRST_FROM_ISR_COMMAND ) + if( xCommandID < tmrFIRST_FROM_ISR_COMMAND ) { - if ( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING ) + if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING ) { xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait ); } @@ -354,23 +422,40 @@ DaemonTaskMessage_t xMessage; } /*-----------------------------------------------------------*/ -#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) +TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) +{ + /* If xTimerGetTimerDaemonTaskHandle() is called before the scheduler has been + started, then xTimerTaskHandle will be NULL. */ + configASSERT( ( xTimerTaskHandle != NULL ) ); + return xTimerTaskHandle; +} +/*-----------------------------------------------------------*/ - TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) - { - /* If xTimerGetTimerDaemonTaskHandle() is called before the scheduler has been - started, then xTimerTaskHandle will be NULL. */ - configASSERT( ( xTimerTaskHandle != NULL ) ); - return xTimerTaskHandle; - } +TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) +{ +Timer_t *pxTimer = ( Timer_t * ) xTimer; -#endif + configASSERT( xTimer ); + return pxTimer->xTimerPeriodInTicks; +} /*-----------------------------------------------------------*/ -const char * pcTimerGetTimerName( TimerHandle_t xTimer ) +TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) +{ +Timer_t * pxTimer = ( Timer_t * ) xTimer; +TickType_t xReturn; + + configASSERT( xTimer ); + xReturn = listGET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ) ); + return xReturn; +} +/*-----------------------------------------------------------*/ + +const char * pcTimerGetName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ { Timer_t *pxTimer = ( Timer_t * ) xTimer; + configASSERT( xTimer ); return pxTimer->pcTimerName; } /*-----------------------------------------------------------*/ @@ -387,12 +472,12 @@ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTi /* If the timer is an auto reload timer then calculate the next expiry time and re-insert the timer in the list of active timers. */ - if ( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) + if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) { /* The timer is inserted into a list using a time relative to anything other than the current time. It will therefore be inserted into the correct list relative to the time this task thinks it is now. */ - if ( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) == pdTRUE ) + if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) != pdFALSE ) { /* The timer expired before it was added to the active timer list. Reload it now. */ @@ -423,7 +508,19 @@ BaseType_t xListWasEmpty; /* Just to avoid compiler warnings. */ ( void ) pvParameters; - for ( ;; ) + #if( configUSE_DAEMON_TASK_STARTUP_HOOK == 1 ) + { + extern void vApplicationDaemonTaskStartupHook( void ); + + /* Allow the application writer to execute some code in the context of + this task at the point the task starts executing. This is useful if the + application includes initialisation code that would benefit from + executing after the scheduler has been started. */ + vApplicationDaemonTaskStartupHook(); + } + #endif /* configUSE_DAEMON_TASK_STARTUP_HOOK */ + + for( ;; ) { /* Query the timers list to see if it contains any timers, and if so, obtain the time at which the next timer will expire. */ @@ -439,7 +536,7 @@ BaseType_t xListWasEmpty; } /*-----------------------------------------------------------*/ -static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) +static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty ) { TickType_t xTimeNow; BaseType_t xTimerListsWereSwitched; @@ -452,10 +549,10 @@ BaseType_t xTimerListsWereSwitched; when the lists were switched will have been processed within the prvSampleTimeNow() function. */ xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); - if ( xTimerListsWereSwitched == pdFALSE ) + if( xTimerListsWereSwitched == pdFALSE ) { /* The tick count has not overflowed, has the timer expired? */ - if ( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) ) + if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) ) { ( void ) xTaskResumeAll(); prvProcessExpiredTimer( xNextExpireTime, xTimeNow ); @@ -468,9 +565,16 @@ BaseType_t xTimerListsWereSwitched; received - whichever comes first. The following line cannot be reached unless xNextExpireTime > xTimeNow, except in the case when the current timer list is empty. */ - vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) ); + if( xListWasEmpty != pdFALSE ) + { + /* The current timer list is empty - is the overflow list + also empty? */ + xListWasEmpty = listLIST_IS_EMPTY( pxOverflowTimerList ); + } + + vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ), xListWasEmpty ); - if ( xTaskResumeAll() == pdFALSE ) + if( xTaskResumeAll() == pdFALSE ) { /* Yield to wait for either a command to arrive, or the block time to expire. If a command arrived between the @@ -504,7 +608,7 @@ TickType_t xNextExpireTime; timer lists will be switched and the next expiry time can be re-assessed. */ *pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList ); - if ( *pxListWasEmpty == pdFALSE ) + if( *pxListWasEmpty == pdFALSE ) { xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); } @@ -525,7 +629,7 @@ PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Va xTimeNow = xTaskGetTickCount(); - if ( xTimeNow < xLastTime ) + if( xTimeNow < xLastTime ) { prvSwitchTimerLists(); *pxTimerListsWereSwitched = pdTRUE; @@ -548,11 +652,11 @@ BaseType_t xProcessTimerNow = pdFALSE; listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xNextExpiryTime ); listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); - if ( xNextExpiryTime <= xTimeNow ) + if( xNextExpiryTime <= xTimeNow ) { /* Has the expiry time elapsed between the command to start/reset a timer was issued, and the time the command was processed? */ - if ( ( xTimeNow - xCommandTime ) >= pxTimer->xTimerPeriodInTicks ) + if( ( ( TickType_t ) ( xTimeNow - xCommandTime ) ) >= pxTimer->xTimerPeriodInTicks ) /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ { /* The time between a command being issued and the command being processed actually exceeds the timers period. */ @@ -565,7 +669,7 @@ BaseType_t xProcessTimerNow = pdFALSE; } else { - if ( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) ) + if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) ) { /* If, since the command was issued, the tick count has overflowed but the expiry time has not, then the timer must have already passed @@ -589,13 +693,13 @@ Timer_t *pxTimer; BaseType_t xTimerListsWereSwitched, xResult; TickType_t xTimeNow; - while ( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */ + while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */ { #if ( INCLUDE_xTimerPendFunctionCall == 1 ) { /* Negative commands are pended function calls rather than timer commands. */ - if ( xMessage.xMessageID < ( BaseType_t ) 0 ) + if( xMessage.xMessageID < ( BaseType_t ) 0 ) { const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters ); @@ -615,13 +719,13 @@ TickType_t xTimeNow; /* Commands that are positive are timer commands rather than pended function calls. */ - if ( xMessage.xMessageID >= ( BaseType_t ) 0 ) + if( xMessage.xMessageID >= ( BaseType_t ) 0 ) { /* The messages uses the xTimerParameters member to work on a software timer. */ pxTimer = xMessage.u.xTimerParameters.pxTimer; - if ( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE ) + if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE ) /*lint !e961. The cast is only redundant when NULL is passed into the macro. */ { /* The timer is in a list, remove it. */ ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); @@ -641,7 +745,7 @@ TickType_t xTimeNow; pre-empted the timer daemon task after the xTimeNow value was set). */ xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); - switch ( xMessage.xMessageID ) + switch( xMessage.xMessageID ) { case tmrCOMMAND_START : case tmrCOMMAND_START_FROM_ISR : @@ -649,14 +753,14 @@ TickType_t xTimeNow; case tmrCOMMAND_RESET_FROM_ISR : case tmrCOMMAND_START_DONT_TRACE : /* Start or restart a timer. */ - if ( prvInsertTimerInActiveList( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.u.xTimerParameters.xMessageValue ) == pdTRUE ) + if( prvInsertTimerInActiveList( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.u.xTimerParameters.xMessageValue ) != pdFALSE ) { /* The timer expired before it was added to the active timer list. Process it now. */ pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); traceTIMER_EXPIRED( pxTimer ); - if ( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) + if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) { xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY ); configASSERT( xResult ); @@ -684,19 +788,40 @@ TickType_t xTimeNow; pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.xMessageValue; configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) ); - /* The new period does not really have a reference, and can be - longer or shorter than the old one. The command time is - therefore set to the current time, and as the period cannot be - zero the next expiry time can only be in the future, meaning - (unlike for the xTimerStart() case above) there is no fail case - that needs to be handled here. */ + /* The new period does not really have a reference, and can + be longer or shorter than the old one. The command time is + therefore set to the current time, and as the period cannot + be zero the next expiry time can only be in the future, + meaning (unlike for the xTimerStart() case above) there is + no fail case that needs to be handled here. */ ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow ); break; case tmrCOMMAND_DELETE : /* The timer has already been removed from the active list, - just free up the memory. */ - vPortFree( pxTimer ); + just free up the memory if the memory was dynamically + allocated. */ + #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) + { + /* The timer can only have been allocated dynamically - + free it again. */ + vPortFree( pxTimer ); + } + #elif( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + { + /* The timer could have been allocated statically or + dynamically, so check before attempting to free the + memory. */ + if( pxTimer->ucStaticallyAllocated == ( uint8_t ) pdFALSE ) + { + vPortFree( pxTimer ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ break; default : @@ -719,7 +844,7 @@ BaseType_t xResult; If there are any timers still referenced from the current timer list then they must have expired and should be processed before the lists are switched. */ - while ( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE ) + while( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE ) { xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); @@ -733,7 +858,7 @@ BaseType_t xResult; have not yet been switched. */ pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); - if ( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) + if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) { /* Calculate the reload value, and if the reload value results in the timer going into the same timer list then it has already expired @@ -742,7 +867,7 @@ BaseType_t xResult; to restart the timer to ensure it is only inserted into a list after the lists have been swapped. */ xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ); - if ( xReloadTime > xNextExpireTime ) + if( xReloadTime > xNextExpireTime ) { listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime ); listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); @@ -774,18 +899,31 @@ static void prvCheckForValidListAndQueue( void ) initialised. */ taskENTER_CRITICAL(); { - if ( xTimerQueue == NULL ) + if( xTimerQueue == NULL ) { vListInitialise( &xActiveTimerList1 ); vListInitialise( &xActiveTimerList2 ); pxCurrentTimerList = &xActiveTimerList1; pxOverflowTimerList = &xActiveTimerList2; - xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) ); - configASSERT( xTimerQueue ); + + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* The timer queue is allocated statically in case + configSUPPORT_DYNAMIC_ALLOCATION is 0. */ + static StaticQueue_t xStaticTimerQueue; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */ + static uint8_t ucStaticTimerQueueStorage[ ( size_t ) configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ]; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */ + + xTimerQueue = xQueueCreateStatic( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, ( UBaseType_t ) sizeof( DaemonTaskMessage_t ), &( ucStaticTimerQueueStorage[ 0 ] ), &xStaticTimerQueue ); + } + #else + { + xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) ); + } + #endif #if ( configQUEUE_REGISTRY_SIZE > 0 ) { - if ( xTimerQueue != NULL ) + if( xTimerQueue != NULL ) { vQueueAddToRegistry( xTimerQueue, "TmrQ" ); } @@ -810,13 +948,15 @@ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) BaseType_t xTimerIsInActiveList; Timer_t *pxTimer = ( Timer_t * ) xTimer; + configASSERT( xTimer ); + /* Is the timer in the list of active timers? */ taskENTER_CRITICAL(); { /* Checking to see if it is in the NULL list in effect checks to see if it is referenced from either the current or the overflow timer lists in one go, but the logic has to be reversed, hence the '!'. */ - xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); + xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); /*lint !e961. Cast is only redundant when NULL is passed into the macro. */ } taskEXIT_CRITICAL(); @@ -841,7 +981,7 @@ void *pvReturn; } /*-----------------------------------------------------------*/ -void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) +void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) { Timer_t * const pxTimer = ( Timer_t * ) xTimer; @@ -855,7 +995,7 @@ Timer_t * const pxTimer = ( Timer_t * ) xTimer; } /*-----------------------------------------------------------*/ -#if ( INCLUDE_xTimerPendFunctionCall == 1 ) +#if( INCLUDE_xTimerPendFunctionCall == 1 ) BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) { @@ -879,7 +1019,7 @@ Timer_t * const pxTimer = ( Timer_t * ) xTimer; #endif /* INCLUDE_xTimerPendFunctionCall */ /*-----------------------------------------------------------*/ -#if ( INCLUDE_xTimerPendFunctionCall == 1 ) +#if( INCLUDE_xTimerPendFunctionCall == 1 ) BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) { @@ -908,6 +1048,26 @@ Timer_t * const pxTimer = ( Timer_t * ) xTimer; #endif /* INCLUDE_xTimerPendFunctionCall */ /*-----------------------------------------------------------*/ +#if ( configUSE_TRACE_FACILITY == 1 ) + + UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) + { + return ( ( Timer_t * ) xTimer )->uxTimerNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) + { + ( ( Timer_t * ) xTimer )->uxTimerNumber = uxTimerNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + /* This entire source file will be skipped if the application is not configured to include software timer functionality. If you want to include software timer functionality then ensure configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/licenses_external.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/licenses_external.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/licenses_external.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/licenses_external.txt diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/.travis.yml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/.travis.yml new file mode 100644 index 0000000..fa01e5a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/.travis.yml @@ -0,0 +1,39 @@ +language: c +compiler: +- clang +- gcc +sudo: false +cache: ccache +script: +- tests/scripts/recursion.pl library/*.c +- tests/scripts/check-generated-files.sh +- tests/scripts/check-doxy-blocks.pl +- tests/scripts/check-names.sh +- tests/scripts/doxygen.sh +- cmake -D CMAKE_BUILD_TYPE:String="Check" . +- make +- make test +- programs/test/selftest +- OSSL_NO_DTLS=1 tests/compat.sh +- tests/ssl-opt.sh -e '\(DTLS\|SCSV\).*openssl' +- tests/scripts/test-ref-configs.pl +- tests/scripts/curves.pl +- tests/scripts/key-exchanges.pl +after_failure: +- tests/scripts/travis-log-failure.sh +env: + global: + secure: "barHldniAfXyoWOD/vcO+E6/Xm4fmcaUoC9BeKW+LwsHqlDMLvugaJnmLXkSpkbYhVL61Hzf3bo0KPJn88AFc5Rkf8oYHPjH4adMnVXkf3B9ghHCgznqHsAH3choo6tnPxaFgOwOYmLGb382nQxfE5lUdvnM/W/psQjWt66A1+k=" + +addons: + apt: + packages: + - doxygen + - graphviz + coverity_scan: + project: + name: "ARMmbed/mbedtls" + notification_email: p.j.bakker@polarssl.org + build_command_prepend: + build_command: make + branch_pattern: coverity_scan diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/CMakeLists.txt new file mode 100644 index 0000000..3e47224 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/CMakeLists.txt @@ -0,0 +1,166 @@ +cmake_minimum_required(VERSION 2.6) +project("mbed TLS" C) + +option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF) +option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF) + +option(ENABLE_PROGRAMS "Build mbed TLS programs." ON) + +option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF) + +# the test suites currently have compile errors with MSVC +if(MSVC) + option(ENABLE_TESTING "Build mbed TLS tests." OFF) +else() + option(ENABLE_TESTING "Build mbed TLS tests." ON) +endif() + +# Warning string - created as a list for compatibility with CMake 2.8 +set(WARNING_BORDER "*******************************************************\n") +set(NULL_ENTROPY_WARN_L1 "**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined!\n") +set(NULL_ENTROPY_WARN_L2 "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES\n") +set(NULL_ENTROPY_WARN_L3 "**** AND IS *NOT* SUITABLE FOR PRODUCTION USE\n") + +set(NULL_ENTROPY_WARNING "${WARNING_BORDER}" + "${NULL_ENTROPY_WARN_L1}" + "${NULL_ENTROPY_WARN_L2}" + "${NULL_ENTROPY_WARN_L3}" + "${WARNING_BORDER}") + +find_package(Perl) +if(PERL_FOUND) + + # If NULL Entropy is configured, display an appropriate warning + execute_process(COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/config.pl -f ${CMAKE_SOURCE_DIR}/include/mbedtls/config.h get MBEDTLS_TEST_NULL_ENTROPY + RESULT_VARIABLE result) + if(${result} EQUAL 0) + message(WARNING ${NULL_ENTROPY_WARNING}) + + if(NOT UNSAFE_BUILD) + message(FATAL_ERROR "\ +\n\ +Warning! You have enabled MBEDTLS_TEST_NULL_ENTROPY. \ +This option is not safe for production use and negates all security \ +It is intended for development use only. \ +\n\ +To confirm you want to build with this option, re-run cmake with the \ +option: \n\ + cmake -DUNSAFE_BUILD=ON ") + + return() + endif() + endif() +endif() + +set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} + CACHE STRING "Choose the type of build: None Debug Release Coverage ASan ASanDbg MemSan MemSanDbg Check CheckFull" + FORCE) + +string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") + +if(CMAKE_COMPILER_IS_GNUCC) + # some warnings we want are not available with old GCC versions + # note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings") + if (GCC_VERSION VERSION_GREATER 4.5 OR GCC_VERSION VERSION_EQUAL 4.5) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlogical-op") + endif() + if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow") + endif() + set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g3") + set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage") + set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -O3") + set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ") + set(CMAKE_C_FLAGS_CHECK "-Werror -Os") + set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual") +endif(CMAKE_COMPILER_IS_GNUCC) + +if(CMAKE_COMPILER_IS_CLANG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow") + set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g3") + set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage") + set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover -O3") + set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ") + set(CMAKE_C_FLAGS_MEMSAN "-Werror -fsanitize=memory -O3") + set(CMAKE_C_FLAGS_MEMSANDBG "-Werror -fsanitize=memory -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2") + set(CMAKE_C_FLAGS_CHECK "-Werror -Os") +endif(CMAKE_COMPILER_IS_CLANG) + +if(MSVC) + # Strictest warnings, and treat as errors + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") +endif(MSVC) + +if(CMAKE_BUILD_TYPE STREQUAL "Coverage") + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) + set(CMAKE_SHARED_LINKER_FLAGS "--coverage") + endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) +endif(CMAKE_BUILD_TYPE STREQUAL "Coverage") + +if(LIB_INSTALL_DIR) +else() + set(LIB_INSTALL_DIR lib) +endif() + +include_directories(include/) + +if(ENABLE_ZLIB_SUPPORT) + find_package(ZLIB) + + if(ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIR}) + endif(ZLIB_FOUND) +endif(ENABLE_ZLIB_SUPPORT) + +add_subdirectory(library) +add_subdirectory(include) + +if(ENABLE_PROGRAMS) + add_subdirectory(programs) +endif() + +ADD_CUSTOM_TARGET(apidoc + COMMAND doxygen doxygen/mbedtls.doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +if(ENABLE_TESTING) + enable_testing() + + add_subdirectory(tests) + + # additional convenience targets for Unix only + if(UNIX) + + ADD_CUSTOM_TARGET(covtest + COMMAND make test + COMMAND programs/test/selftest + COMMAND tests/compat.sh + COMMAND tests/ssl-opt.sh + ) + + ADD_CUSTOM_TARGET(lcov + COMMAND rm -rf Coverage + COMMAND lcov --capture --initial --directory library/CMakeFiles/mbedtls.dir -o files.info + COMMAND lcov --capture --directory library/CMakeFiles/mbedtls.dir -o tests.info + COMMAND lcov --add-tracefile files.info --add-tracefile tests.info -o all.info + COMMAND lcov --remove all.info -o final.info '*.h' + COMMAND gendesc tests/Descriptions.txt -o descriptions + COMMAND genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --no-branch-coverage -o Coverage final.info + COMMAND rm -f files.info tests.info all.info final.info descriptions + ) + + ADD_CUSTOM_TARGET(memcheck + COMMAND sed -i.bak s+/usr/bin/valgrind+`which valgrind`+ DartConfiguration.tcl + COMMAND ctest -O memcheck.log -D ExperimentalMemCheck + COMMAND tail -n1 memcheck.log | grep 'Memory checking results:' > /dev/null + COMMAND rm -f memcheck.log + COMMAND mv DartConfiguration.tcl.bak DartConfiguration.tcl + ) + endif(UNIX) +endif() diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/ChangeLog b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/ChangeLog new file mode 100644 index 0000000..13de867 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/ChangeLog @@ -0,0 +1,2152 @@ +mbed TLS ChangeLog (Sorted per branch, date) + += mbed TLS 2.4.2 branch released 2017-03-08 + +Security + * Add checks to prevent signature forgeries for very large messages while + using RSA through the PK module in 64-bit systems. The issue was caused by + some data loss when casting a size_t to an unsigned int value in the + functions rsa_verify_wrap(), rsa_sign_wrap(), rsa_alt_sign_wrap() and + mbedtls_pk_sign(). Found by Jean-Philippe Aumasson. + * Fixed potential livelock during the parsing of a CRL in PEM format in + mbedtls_x509_crl_parse(). A string containing a CRL followed by trailing + characters after the footer could result in the execution of an infinite + loop. The issue can be triggered remotely. Found by Greg Zaverucha, + Microsoft. + * Removed MD5 from the allowed hash algorithms for CertificateRequest and + CertificateVerify messages, to prevent SLOTH attacks against TLS 1.2. + Introduced by interoperability fix for #513. + * Fixed a bug that caused freeing a buffer that was allocated on the stack, + when verifying the validity of a key on secp224k1. This could be + triggered remotely for example with a maliciously constructed certificate + and potentially could lead to remote code execution on some platforms. + Reported independently by rongsaws and Aleksandar Nikolic, Cisco Talos + team. #569 CVE-2017-2784 + +Bugfix + * Fix output certificate verification flags set by x509_crt_verify_top() when + traversing a chain of trusted CA. The issue would cause both flags, + MBEDTLS_X509_BADCERT_NOT_TRUSTED and MBEDTLS_X509_BADCERT_EXPIRED, to be + set when the verification conditions are not met regardless of the cause. + Found by Harm Verhagen and inestlerode. #665 #561 + * Fix the redefinition of macro ssl_set_bio to an undefined symbol + mbedtls_ssl_set_bio_timeout in compat-1.3.h, by removing it. + Found by omlib-lin. #673 + * Fix unused variable/function compilation warnings in pem.c, x509_crt.c and + x509_csr.c that are reported when building mbed TLS with a config.h that + does not define MBEDTLS_PEM_PARSE_C. Found by omnium21. #562 + * Fix incorrect renegotiation condition in ssl_check_ctr_renegotiate() that + would compare 64 bits of the record counter instead of 48 bits as indicated + in RFC 6347 Section 4.3.1. This could cause the execution of the + renegotiation routines at unexpected times when the protocol is DTLS. Found + by wariua. #687 + * Fixed multiple buffer overreads in mbedtls_pem_read_buffer() when parsing + the input string in PEM format to extract the different components. Found + by Eyal Itkin. + * Fixed potential arithmetic overflow in mbedtls_ctr_drbg_reseed() that could + cause buffer bound checks to be bypassed. Found by Eyal Itkin. + * Fixed potential arithmetic overflows in mbedtls_cipher_update() that could + cause buffer bound checks to be bypassed. Found by Eyal Itkin. + * Fixed potential arithmetic overflow in mbedtls_md2_update() that could + cause buffer bound checks to be bypassed. Found by Eyal Itkin. + * Fixed potential arithmetic overflow in mbedtls_base64_decode() that could + cause buffer bound checks to be bypassed. Found by Eyal Itkin. + * Fixed heap overreads in mbedtls_x509_get_time(). Found by Peng + Li/Yueh-Hsun Lin, KNOX Security, Samsung Research America. + * Fix potential memory leak in mbedtls_x509_crl_parse(). The leak was caused + by missing calls to mbedtls_pem_free() in cases when a + MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT error was encountered. Found and + fix proposed by Guido Vranken. #722 + * Fixed the templates used to generate project and solution files for Visual + Studio 2015 as well as the files themselves, to remove a build warning + generated in Visual Studio 2015. Reported by Steve Valliere. #742 + * Fix a resource leak in ssl_cookie, when using MBEDTLS_THREADING_C. + Raised and fix suggested by Alan Gillingham in the mbed TLS forum. #771 + * Fix 1 byte buffer overflow in mbedtls_mpi_write_string() when the MPI + number to write in hexadecimal is negative and requires an odd number of + digits. Found and fixed by Guido Vranken. + * Fix unlisted DES configuration dependency in some pkparse test cases. Found + by inestlerode. #555 + += mbed TLS 2.4.1 branch released 2016-12-13 + +Changes + * Update to CMAC test data, taken from - NIST Special Publication 800-38B - + Recommendation for Block Cipher Modes of Operation: The CMAC Mode for + Authentication – October 2016 + += mbed TLS 2.4.0 branch released 2016-10-17 + +Security + * Removed the MBEDTLS_SSL_AEAD_RANDOM_IV option, because it was not compliant + with RFC-5116 and could lead to session key recovery in very long TLS + sessions. "Nonce-Disrespecting Adversaries Practical Forgery Attacks on GCM in + TLS" - H. Bock, A. Zauner, S. Devlin, J. Somorovsky, P. Jovanovic. + https://eprint.iacr.org/2016/475.pdf + * Fixed potential stack corruption in mbedtls_x509write_crt_der() and + mbedtls_x509write_csr_der() when the signature is copied to the buffer + without checking whether there is enough space in the destination. The + issue cannot be triggered remotely. Found by Jethro Beekman. + +Features + * Added support for CMAC for AES and 3DES and AES-CMAC-PRF-128, as defined by + NIST SP 800-38B, RFC-4493 and RFC-4615. + * Added hardware entropy selftest to verify that the hardware entropy source + is functioning correctly. + * Added a script to print build environment info for diagnostic use in test + scripts, which is also now called by all.sh. + * Added the macro MBEDTLS_X509_MAX_FILE_PATH_LEN that enables the user to + configure the maximum length of a file path that can be buffered when + calling mbedtls_x509_crt_parse_path(). + * Added a configuration file config-no-entropy.h that configures the subset of + library features that do not require an entropy source. + * Added the macro MBEDTLS_ENTROPY_MIN_HARDWARE in config.h. This allows users + to configure the minimum number of bytes for entropy sources using the + mbedtls_hardware_poll() function. + +Bugfix + * Fix for platform time abstraction to avoid dependency issues where a build + may need time but not the standard C library abstraction, and added + configuration consistency checks to check_config.h + * Fix dependency issue in Makefile to allow parallel builds. + * Fix incorrect handling of block lengths in crypt_and_hash.c sample program, + when GCM is used. Found by udf2457. #441 + * Fix for key exchanges based on ECDH-RSA or ECDH-ECDSA which weren't + enabled unless others were also present. Found by David Fernandez. #428 + * Fix for out-of-tree builds using CMake. Found by jwurzer, and fix based on + a contribution from Tobias Tangemann. #541 + * Fixed cert_app.c sample program for debug output and for use when no root + certificates are provided. + * Fix conditional statement that would cause a 1 byte overread in + mbedtls_asn1_get_int(). Found and fixed by Guido Vranken. #599 + * Fixed pthread implementation to avoid unintended double initialisations + and double frees. Found by Niklas Amnebratt. + * Fixed the sample applications gen_key.c, cert_req.c and cert_write.c for + builds where the configuration MBEDTLS_PEM_WRITE_C is not defined. Found + by inestlerode. #559. + * Fix mbedtls_x509_get_sig() to update the ASN1 type in the mbedtls_x509_buf + data structure until after error checks are successful. Found by + subramanyam-c. #622 + * Fix documentation and implementation missmatch for function arguments of + mbedtls_gcm_finish(). Found by cmiatpaar. #602 + * Guarantee that P>Q at RSA key generation. Found by inestlerode. #558 + * Fix potential byte overread when verifying malformed SERVER_HELLO in + ssl_parse_hello_verify_request() for DTLS. Found by Guido Vranken. + * Fix check for validity of date when parsing in mbedtls_x509_get_time(). + Found by subramanyam-c. #626 + * Fix compatibility issue with Internet Explorer client authentication, + where the limited hash choices prevented the client from sending its + certificate. Found by teumas. #513 + * Fix compilation without MBEDTLS_SELF_TEST enabled. + +Changes + * Extended test coverage of special cases, and added new timing test suite. + * Removed self-tests from the basic-built-test.sh script, and added all + missing self-tests to the test suites, to ensure self-tests are only + executed once. + * Added support for 3 and 4 byte lengths to mbedtls_asn1_write_len(). + * Added support for a Yotta specific configuration file - + through the symbol YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE. + * Added optimization for code space for X.509/OID based on configured + features. Contributed by Aviv Palivoda. + * Renamed source file library/net.c to library/net_sockets.c to avoid + naming collision in projects which also have files with the common name + net.c. For consistency, the corresponding header file, net.h, is marked as + deprecated, and its contents moved to net_sockets.h. + * Changed the strategy for X.509 certificate parsing and validation, to no + longer disregard certificates with unrecognised fields. + += mbed TLS 2.3.0 branch released 2016-06-28 + +Security + * Fix missing padding length check in mbedtls_rsa_rsaes_pkcs1_v15_decrypt + required by PKCS1 v2.2 + * Fix potential integer overflow to buffer overflow in + mbedtls_rsa_rsaes_pkcs1_v15_encrypt and mbedtls_rsa_rsaes_oaep_encrypt + (not triggerable remotely in (D)TLS). + * Fix a potential integer underflow to buffer overread in + mbedtls_rsa_rsaes_oaep_decrypt. It is not triggerable remotely in + SSL/TLS. + +Features + * Support for platform abstraction of the standard C library time() + function. + +Bugfix + * Fix bug in mbedtls_mpi_add_mpi() that caused wrong results when the three + arguments where the same (in-place doubling). Found and fixed by Janos + Follath. #309 + * Fix potential build failures related to the 'apidoc' target, introduced + in the previous patch release. Found by Robert Scheck. #390 #391 + * Fix issue in Makefile that prevented building using armar. #386 + * Fix memory leak that occured only when ECJPAKE was enabled and ECDHE and + ECDSA was disabled in config.h . The leak didn't occur by default. + * Fix an issue that caused valid certificates to be rejected whenever an + expired or not yet valid certificate was parsed before a valid certificate + in the trusted certificate list. + * Fix bug in mbedtls_x509_crt_parse that caused trailing extra data in the + buffer after DER certificates to be included in the raw representation. + * Fix issue that caused a hang when generating RSA keys of odd bitlength + * Fix bug in mbedtls_rsa_rsaes_pkcs1_v15_encrypt that made null pointer + dereference possible. + * Fix issue that caused a crash if invalid curves were passed to + mbedtls_ssl_conf_curves. #373 + * Fix issue in ssl_fork_server which was preventing it from functioning. #429 + * Fix memory leaks in test framework + * Fix test in ssl-opt.sh that does not run properly with valgrind + * Fix unchecked calls to mmbedtls_md_setup(). Fix by Brian Murray. #502 + +Changes + * On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5, + don't use the optimized assembly for bignum multiplication. This removes + the need to pass -fomit-frame-pointer to avoid a build error with -O0. + * Disabled SSLv3 in the default configuration. + * Optimized mbedtls_mpi_zeroize() for MPI integer size. (Fix by Alexey + Skalozub). + * Fix non-compliance server extension handling. Extensions for SSLv3 are now + ignored, as required by RFC6101. + += mbed TLS 2.2.1 released 2016-01-05 + +Security + * Fix potential double free when mbedtls_asn1_store_named_data() fails to + allocate memory. Only used for certificate generation, not triggerable + remotely in SSL/TLS. Found by Rafał Przywara. #367 + * Disable MD5 handshake signatures in TLS 1.2 by default to prevent the + SLOTH attack on TLS 1.2 server authentication (other attacks from the + SLOTH paper do not apply to any version of mbed TLS or PolarSSL). + https://www.mitls.org/pages/attacks/SLOTH + +Bugfix + * Fix over-restrictive length limit in GCM. Found by Andreas-N. #362 + * Fix bug in certificate validation that caused valid chains to be rejected + when the first intermediate certificate has pathLenConstraint=0. Found by + Nicholas Wilson. Introduced in mbed TLS 2.2.0. #280 + * Removed potential leak in mbedtls_rsa_rsassa_pkcs1_v15_sign(), found by + JayaraghavendranK. #372 + * Fix suboptimal handling of unexpected records that caused interop issues + with some peers over unreliable links. Avoid dropping an entire DTLS + datagram if a single record in a datagram is unexpected, instead only + drop the record and look at subsequent records (if any are present) in + the same datagram. Found by jeannotlapin. #345 + += mbed TLS 2.2.0 released 2015-11-04 + +Security + * Fix potential double free if mbedtls_ssl_conf_psk() is called more than + once and some allocation fails. Cannot be forced remotely. Found by Guido + Vranken, Intelworks. + * Fix potential heap corruption on Windows when + mbedtls_x509_crt_parse_path() is passed a path longer than 2GB. Cannot be + triggered remotely. Found by Guido Vranken, Intelworks. + * Fix potential buffer overflow in some asn1_write_xxx() functions. + Cannot be triggered remotely unless you create X.509 certificates based + on untrusted input or write keys of untrusted origin. Found by Guido + Vranken, Intelworks. + * The X509 max_pathlen constraint was not enforced on intermediate + certificates. Found by Nicholas Wilson, fix and tests provided by + Janos Follath. #280 and #319 + +Features + * Experimental support for EC J-PAKE as defined in Thread 1.0.0. + Disabled by default as the specification might still change. + * Added a key extraction callback to accees the master secret and key + block. (Potential uses include EAP-TLS and Thread.) + +Bugfix + * Self-signed certificates were not excluded from pathlen counting, + resulting in some valid X.509 being incorrectly rejected. Found and fix + provided by Janos Follath. #319 + * Fix build error with configurations where ECDHE-PSK is the only key + exchange. Found and fix provided by Chris Hammond. #270 + * Fix build error with configurations where RSA, RSA-PSK, ECDH-RSA or + ECHD-ECDSA if the only key exchange. Multiple reports. #310 + * Fixed a bug causing some handshakes to fail due to some non-fatal alerts + not being properly ignored. Found by mancha and Kasom Koht-arsa, #308 + * mbedtls_x509_crt_verify(_with_profile)() now also checks the key type and + size/curve against the profile. Before that, there was no way to set a + minimum key size for end-entity certificates with RSA keys. Found by + Matthew Page of Scannex Electronics Ltd. + * Fix failures in MPI on Sparc(64) due to use of bad assembly code. + Found by Kurt Danielson. #292 + * Fix typo in name of the extKeyUsage OID. Found by inestlerode, #314 + * Fix bug in ASN.1 encoding of booleans that caused generated CA + certificates to be rejected by some applications, including OS X + Keychain. Found and fixed by Jonathan Leroy, Inikup. + +Changes + * Improved performance of mbedtls_ecp_muladd() when one of the scalars is 1 + or -1. + += mbed TLS 2.1.2 released 2015-10-06 + +Security + * Added fix for CVE-2015-5291 to prevent heap corruption due to buffer + overflow of the hostname or session ticket. Found by Guido Vranken, + Intelworks. + * Fix potential double-free if mbedtls_ssl_set_hs_psk() is called more than + once in the same handhake and mbedtls_ssl_conf_psk() was used. + Found and patch provided by Guido Vranken, Intelworks. Cannot be forced + remotely. + * Fix stack buffer overflow in pkcs12 decryption (used by + mbedtls_pk_parse_key(file)() when the password is > 129 bytes. + Found by Guido Vranken, Intelworks. Not triggerable remotely. + * Fix potential buffer overflow in mbedtls_mpi_read_string(). + Found by Guido Vranken, Intelworks. Not exploitable remotely in the context + of TLS, but might be in other uses. On 32 bit machines, requires reading a + string of close to or larger than 1GB to exploit; on 64 bit machines, would + require reading a string of close to or larger than 2^62 bytes. + * Fix potential random memory allocation in mbedtls_pem_read_buffer() + on crafted PEM input data. Found and fix provided by Guido Vranken, + Intelworks. Not triggerable remotely in TLS. Triggerable remotely if you + accept PEM data from an untrusted source. + * Fix possible heap buffer overflow in base64_encoded() when the input + buffer is 512MB or larger on 32-bit platforms. Found by Guido Vranken, + Intelworks. Not trigerrable remotely in TLS. + * Fix potential double-free if mbedtls_conf_psk() is called repeatedly on + the same mbedtls_ssl_config object and memory allocation fails. Found by + Guido Vranken, Intelworks. Cannot be forced remotely. + * Fix potential heap buffer overflow in servers that perform client + authentication against a crafted CA cert. Cannot be triggered remotely + unless you allow third parties to pick trust CAs for client auth. + Found by Guido Vranken, Intelworks. + +Bugfix + * Fix compile error in net.c with musl libc. Found and patch provided by + zhasha (#278). + * Fix macroization of 'inline' keyword when building as C++. (#279) + +Changes + * Added checking of hostname length in mbedtls_ssl_set_hostname() to ensure + domain names are compliant with RFC 1035. + * Fixed paths for check_config.h in example config files. (Found by bachp) + (#291) + += mbed TLS 2.1.1 released 2015-09-17 + +Security + * Add countermeasure against Lenstra's RSA-CRT attack for PKCS#1 v1.5 + signatures. (Found by Florian Weimer, Red Hat.) + https://securityblog.redhat.com/2015/09/02/factoring-rsa-keys-with-tls-perfect-forward-secrecy/ + * Fix possible client-side NULL pointer dereference (read) when the client + tries to continue the handshake after it failed (a misuse of the API). + (Found and patch provided by Fabian Foerg, Gotham Digital Science using + afl-fuzz.) + +Bugfix + * Fix warning when using a 64bit platform. (found by embedthis) (#275) + * Fix off-by-one error in parsing Supported Point Format extension that + caused some handshakes to fail. + +Changes + * Made X509 profile pointer const in mbedtls_ssl_conf_cert_profile() to allow + use of mbedtls_x509_crt_profile_next. (found by NWilson) + * When a client initiates a reconnect from the same port as a live + connection, if cookie verification is available + (MBEDTLS_SSL_DTLS_HELLO_VERIFY defined in config.h, and usable cookie + callbacks set with mbedtls_ssl_conf_dtls_cookies()), this will be + detected and mbedtls_ssl_read() will return + MBEDTLS_ERR_SSL_CLIENT_RECONNECT - it is then possible to start a new + handshake with the same context. (See RFC 6347 section 4.2.8.) + += mbed TLS 2.1.0 released 2015-09-04 + +Features + * Added support for yotta as a build system. + * Primary open source license changed to Apache 2.0 license. + +Bugfix + * Fix segfault in the benchmark program when benchmarking DHM. + * Fix build error with CMake and pre-4.5 versions of GCC (found by Hugo + Leisink). + * Fix bug when parsing a ServerHello without extensions (found by David + Sears). + * Fix bug in CMake lists that caused libmbedcrypto.a not to be installed + (found by Benoit Lecocq). + * Fix bug in Makefile that caused libmbedcrypto and libmbedx509 not to be + installed (found by Rawi666). + * Fix compile error with armcc 5 with --gnu option. + * Fix bug in Makefile that caused programs not to be installed correctly + (found by robotanarchy) (#232). + * Fix bug in Makefile that prevented from installing without building the + tests (found by robotanarchy) (#232). + * Fix missing -static-libgcc when building shared libraries for Windows + with make. + * Fix link error when building shared libraries for Windows with make. + * Fix error when loading libmbedtls.so. + * Fix bug in mbedtls_ssl_conf_default() that caused the default preset to + be always used (found by dcb314) (#235) + * Fix bug in mbedtls_rsa_public() and mbedtls_rsa_private() that could + result trying to unlock an unlocked mutex on invalid input (found by + Fredrik Axelsson) (#257) + * Fix -Wshadow warnings (found by hnrkp) (#240) + * Fix memory corruption on client with overlong PSK identity, around + SSL_MAX_CONTENT_LEN or higher - not triggerrable remotely (found by + Aleksandrs Saveljevs) (#238) + * Fix unused function warning when using MBEDTLS_MDx_ALT or + MBEDTLS_SHAxxx_ALT (found by Henrik) (#239) + * Fix memory corruption in pkey programs (found by yankuncheng) (#210) + +Changes + * The PEM parser now accepts a trailing space at end of lines (#226). + * It is now possible to #include a user-provided configuration file at the + end of the default config.h by defining MBEDTLS_USER_CONFIG_FILE on the + compiler's command line. + * When verifying a certificate chain, if an intermediate certificate is + trusted, no later cert is checked. (suggested by hannes-landeholm) + (#220). + * Prepend a "thread identifier" to debug messages (issue pointed out by + Hugo Leisink) (#210). + * Add mbedtls_ssl_get_max_frag_len() to query the current maximum fragment + length. + += mbed TLS 2.0.0 released 2015-07-13 + +Features + * Support for DTLS 1.0 and 1.2 (RFC 6347). + * Ability to override core functions from MDx, SHAx, AES and DES modules + with custom implementation (eg hardware accelerated), complementing the + ability to override the whole module. + * New server-side implementation of session tickets that rotate keys to + preserve forward secrecy, and allows sharing across multiple contexts. + * Added a concept of X.509 cerificate verification profile that controls + which algorithms and key sizes (curves for ECDSA) are acceptable. + * Expanded configurability of security parameters in the SSL module with + mbedtls_ssl_conf_dhm_min_bitlen() and mbedtls_ssl_conf_sig_hashes(). + * Introduced a concept of presets for SSL security-relevant configuration + parameters. + +API Changes + * The library has been split into libmbedcrypto, libmbedx509, libmbedtls. + You now need to link to all of them if you use TLS for example. + * All public identifiers moved to the mbedtls_* or MBEDTLS_* namespace. + Some names have been further changed to make them more consistent. + Migration helpers scripts/rename.pl and include/mbedlts/compat-1.3.h are + provided. Full list of renamings in scripts/data_files/rename-1.3-2.0.txt + * Renamings of fields inside structures, not covered by the previous list: + mbedtls_cipher_info_t.key_length -> key_bitlen + mbedtls_cipher_context_t.key_length -> key_bitlen + mbedtls_ecp_curve_info.size -> bit_size + * Headers are now found in the 'mbedtls' directory (previously 'polarssl'). + * The following _init() functions that could return errors have + been split into an _init() that returns void and another function that + should generally be the first function called on this context after init: + mbedtls_ssl_init() -> mbedtls_ssl_setup() + mbedtls_ccm_init() -> mbedtls_ccm_setkey() + mbedtls_gcm_init() -> mbedtls_gcm_setkey() + mbedtls_hmac_drbg_init() -> mbedtls_hmac_drbg_seed(_buf)() + mbedtls_ctr_drbg_init() -> mbedtls_ctr_drbg_seed() + Note that for mbedtls_ssl_setup(), you need to be done setting up the + ssl_config structure before calling it. + * Most ssl_set_xxx() functions (all except ssl_set_bio(), ssl_set_hostname(), + ssl_set_session() and ssl_set_client_transport_id(), plus + ssl_legacy_renegotiation()) have been renamed to mbedtls_ssl_conf_xxx() + (see rename.pl and compat-1.3.h above) and their first argument's type + changed from ssl_context to ssl_config. + * ssl_set_bio() changed signature (contexts merged, order switched, one + additional callback for read-with-timeout). + * The following functions have been introduced and must be used in callback + implementations (SNI, PSK) instead of their *conf counterparts: + mbedtls_ssl_set_hs_own_cert() + mbedtls_ssl_set_hs_ca_chain() + mbedtls_ssl_set_hs_psk() + * mbedtls_ssl_conf_ca_chain() lost its last argument (peer_cn), now set + using mbedtls_ssl_set_hostname(). + * mbedtls_ssl_conf_session_cache() changed prototype (only one context + pointer, parameters reordered). + * On server, mbedtls_ssl_conf_session_tickets_cb() must now be used in + place of mbedtls_ssl_conf_session_tickets() to enable session tickets. + * The SSL debug callback gained two new arguments (file name, line number). + * Debug modes were removed. + * mbedtls_ssl_conf_truncated_hmac() now returns void. + * mbedtls_memory_buffer_alloc_init() now returns void. + * X.509 verification flags are now an uint32_t. Affect the signature of: + mbedtls_ssl_get_verify_result() + mbedtls_x509_ctr_verify_info() + mbedtls_x509_crt_verify() (flags, f_vrfy -> needs to be updated) + mbedtls_ssl_conf_verify() (f_vrfy -> needs to be updated) + * The following functions changed prototype to avoid an in-out length + parameter: + mbedtls_base64_encode() + mbedtls_base64_decode() + mbedtls_mpi_write_string() + mbedtls_dhm_calc_secret() + * In the NET module, all "int" and "int *" arguments for file descriptors + changed type to "mbedtls_net_context *". + * net_accept() gained new arguments for the size of the client_ip buffer. + * In the threading layer, mbedtls_mutex_init() and mbedtls_mutex_free() now + return void. + * ecdsa_write_signature() gained an addtional md_alg argument and + ecdsa_write_signature_det() was deprecated. + * pk_sign() no longer accepts md_alg == POLARSSL_MD_NONE with ECDSA. + * Last argument of x509_crt_check_key_usage() and + mbedtls_x509write_crt_set_key_usage() changed from int to unsigned. + * test_ca_list (from certs.h) is renamed to test_cas_pem and is only + available if POLARSSL_PEM_PARSE_C is defined (it never worked without). + * Test certificates in certs.c are no longer guaranteed to be nul-terminated + strings; use the new *_len variables instead of strlen(). + * Functions mbedtls_x509_xxx_parse(), mbedtls_pk_parse_key(), + mbedtls_pk_parse_public_key() and mbedtls_dhm_parse_dhm() now expect the + length parameter to include the terminating null byte for PEM input. + * Signature of mpi_mul_mpi() changed to make the last argument unsigned + * calloc() is now used instead of malloc() everywhere. API of platform + layer and the memory_buffer_alloc module changed accordingly. + (Thanks to Mansour Moufid for helping with the replacement.) + * Change SSL_DISABLE_RENEGOTIATION config.h flag to SSL_RENEGOTIATION + (support for renegotiation now needs explicit enabling in config.h). + * Split MBEDTLS_HAVE_TIME into MBEDTLS_HAVE_TIME and MBEDTLS_HAVE_TIME_DATE + in config.h + * net_connect() and net_bind() have a new 'proto' argument to choose + between TCP and UDP, using the macros NET_PROTO_TCP or NET_PROTO_UDP. + Their 'port' argument type is changed to a string. + * Some constness fixes + +Removals + * Removed mbedtls_ecp_group_read_string(). Only named groups are supported. + * Removed mbedtls_ecp_sub() and mbedtls_ecp_add(), use + mbedtls_ecp_muladd(). + * Removed individual mdX_hmac, shaX_hmac, mdX_file and shaX_file functions + (use generic functions from md.h) + * Removed mbedtls_timing_msleep(). Use mbedtls_net_usleep() or a custom + waiting function. + * Removed test DHM parameters from the test certs module. + * Removed the PBKDF2 module (use PKCS5). + * Removed POLARSSL_ERROR_STRERROR_BC (use mbedtls_strerror()). + * Removed compat-1.2.h (helper for migrating from 1.2 to 1.3). + * Removed openssl.h (very partial OpenSSL compatibility layer). + * Configuration options POLARSSL_HAVE_LONGLONG was removed (now always on). + * Configuration options POLARSSL_HAVE_INT8 and POLARSSL_HAVE_INT16 have + been removed (compiler is required to support 32-bit operations). + * Configuration option POLARSSL_HAVE_IPV6 was removed (always enabled). + * Removed test program o_p_test, the script compat.sh does more. + * Removed test program ssl_test, superseded by ssl-opt.sh. + * Removed helper script active-config.pl + +New deprecations + * md_init_ctx() is deprecated in favour of md_setup(), that adds a third + argument (allowing memory savings if HMAC is not used) + +Semi-API changes (technically public, morally private) + * Renamed a few headers to include _internal in the name. Those headers are + not supposed to be included by users. + * Changed md_info_t into an opaque structure (use md_get_xxx() accessors). + * Changed pk_info_t into an opaque structure. + * Changed cipher_base_t into an opaque structure. + * Removed sig_oid2 and rename sig_oid1 to sig_oid in x509_crt and x509_crl. + * x509_crt.key_usage changed from unsigned char to unsigned int. + * Removed r and s from ecdsa_context + * Removed mode from des_context and des3_context + +Default behavior changes + * The default minimum TLS version is now TLS 1.0. + * RC4 is now blacklisted by default in the SSL/TLS layer, and excluded from the + default ciphersuite list returned by ssl_list_ciphersuites() + * Support for receiving SSLv2 ClientHello is now disabled by default at + compile time. + * The default authmode for SSL/TLS clients is now REQUIRED. + * Support for RSA_ALT contexts in the PK layer is now optional. Since is is + enabled in the default configuration, this is only noticeable if using a + custom config.h + * Default DHM parameters server-side upgraded from 1024 to 2048 bits. + * A minimum RSA key size of 2048 bits is now enforced during ceritificate + chain verification. + * Negotiation of truncated HMAC is now disabled by default on server too. + * The following functions are now case-sensitive: + mbedtls_cipher_info_from_string() + mbedtls_ecp_curve_info_from_name() + mbedtls_md_info_from_string() + mbedtls_ssl_ciphersuite_from_string() + mbedtls_version_check_feature() + +Requirement changes + * The minimum MSVC version required is now 2010 (better C99 support). + * The NET layer now unconditionnaly relies on getaddrinfo() and select(). + * Compiler is required to support C99 types such as long long and uint32_t. + +API changes from the 1.4 preview branch + * ssl_set_bio_timeout() was removed, split into mbedtls_ssl_set_bio() with + new prototype, and mbedtls_ssl_set_read_timeout(). + * The following functions now return void: + mbedtls_ssl_conf_transport() + mbedtls_ssl_conf_max_version() + mbedtls_ssl_conf_min_version() + * DTLS no longer hard-depends on TIMING_C, but uses a callback interface + instead, see mbedtls_ssl_set_timer_cb(), with the Timing module providing + an example implementation, see mbedtls_timing_delay_context and + mbedtls_timing_set/get_delay(). + * With UDP sockets, it is no longer necessary to call net_bind() again + after a successful net_accept(). + +Changes + * mbedtls_ctr_drbg_random() and mbedtls_hmac_drbg_random() are now + thread-safe if MBEDTLS_THREADING_C is enabled. + * Reduced ROM fooprint of SHA-256 and added an option to reduce it even + more (at the expense of performance) MBEDTLS_SHA256_SMALLER. + += mbed TLS 1.3 branch + +Security + * With authmode set to SSL_VERIFY_OPTIONAL, verification of keyUsage and + extendedKeyUsage on the leaf certificate was lost (results not accessible + via ssl_get_verify_results()). + * Add countermeasure against "Lucky 13 strikes back" cache-based attack, + https://dl.acm.org/citation.cfm?id=2714625 + +Features + * Improve ECC performance by using more efficient doubling formulas + (contributed by Peter Dettman). + * Add x509_crt_verify_info() to display certificate verification results. + * Add support for reading DH parameters with privateValueLength included + (contributed by Daniel Kahn Gillmor). + * Add support for bit strings in X.509 names (request by Fredrik Axelsson). + * Add support for id-at-uniqueIdentifier in X.509 names. + * Add support for overriding snprintf() (except on Windows) and exit() in + the platform layer. + * Add an option to use macros instead of function pointers in the platform + layer (helps get rid of unwanted references). + * Improved Makefiles for Windows targets by fixing library targets and making + cross-compilation easier (thanks to Alon Bar-Lev). + * The benchmark program also prints heap usage for public-key primitives + if POLARSSL_MEMORY_BUFFER_ALLOC_C and POLARSSL_MEMORY_DEBUG are defined. + * New script ecc-heap.sh helps measuring the impact of ECC parameters on + speed and RAM (heap only for now) usage. + * New script memory.sh helps measuring the ROM and RAM requirements of two + reduced configurations (PSK-CCM and NSA suite B). + * Add config flag POLARSSL_DEPRECATED_WARNING (off by default) to produce + warnings on use of deprecated functions (with GCC and Clang only). + * Add config flag POLARSSL_DEPRECATED_REMOVED (off by default) to produce + errors on use of deprecated functions. + +Bugfix + * Fix compile errors with PLATFORM_NO_STD_FUNCTIONS. + * Fix compile error with PLATFORM_EXIT_ALT (thanks to Rafał Przywara). + * Fix bug in entropy.c when THREADING_C is also enabled that caused + entropy_free() to crash (thanks to Rafał Przywara). + * Fix memory leak when gcm_setkey() and ccm_setkey() are used more than + once on the same context. + * Fix bug in ssl_mail_client when password is longer that username (found + by Bruno Pape). + * Fix undefined behaviour (memcmp( NULL, NULL, 0 );) in X.509 modules + (detected by Clang's 3.6 UBSan). + * mpi_size() and mpi_msb() would segfault when called on an mpi that is + initialized but not set (found by pravic). + * Fix detection of support for getrandom() on Linux (reported by syzzer) by + doing it at runtime (using uname) rather that compile time. + * Fix handling of symlinks by "make install" (found by Gaël PORTAY). + * Fix potential NULL pointer dereference (not trigerrable remotely) when + ssl_write() is called before the handshake is finished (introduced in + 1.3.10) (first reported by Martin Blumenstingl). + * Fix bug in pk_parse_key() that caused some valid private EC keys to be + rejected. + * Fix bug in Via Padlock support (found by Nikos Mavrogiannopoulos). + * Fix thread safety bug in RSA operations (found by Fredrik Axelsson). + * Fix hardclock() (only used in the benchmarking program) with some + versions of mingw64 (found by kxjhlele). + * Fix warnings from mingw64 in timing.c (found by kxjklele). + * Fix potential unintended sign extension in asn1_get_len() on 64-bit + platforms. + * Fix potential memory leak in ssl_set_psk() (found by Mansour Moufid). + * Fix compile error when POLARSSL_SSL_DISABLE_RENEGOTATION and + POLARSSL_SSL_SSESSION_TICKETS where both enabled in config.h (introduced + in 1.3.10). + * Add missing extern "C" guard in aesni.h (reported by amir zamani). + * Add missing dependency on SHA-256 in some x509 programs (reported by + Gergely Budai). + * Fix bug related to ssl_set_curves(): the client didn't check that the + curve picked by the server was actually allowed. + +Changes + * Remove bias in mpi_gen_prime (contributed by Pascal Junod). + * Remove potential sources of timing variations (some contributed by Pascal + Junod). + * Options POLARSSL_HAVE_INT8 and POLARSSL_HAVE_INT16 are deprecated. + * Enabling POLARSSL_NET_C without POLARSSL_HAVE_IPV6 is deprecated. + * compat-1.2.h and openssl.h are deprecated. + * Adjusting/overriding CFLAGS and LDFLAGS with the make build system is now + more flexible (warning: OFLAGS is not used any more) (see the README) + (contributed by Alon Bar-Lev). + * ssl_set_own_cert() no longer calls pk_check_pair() since the + performance impact was bad for some users (this was introduced in 1.3.10). + * Move from SHA-1 to SHA-256 in example programs using signatures + (suggested by Thorsten Mühlfelder). + * Remove some unneeded inclusions of header files from the standard library + "minimize" others (eg use stddef.h if only size_t is needed). + * Change #include lines in test files to use double quotes instead of angle + brackets for uniformity with the rest of the code. + * Remove dependency on sscanf() in X.509 parsing modules. + += mbed TLS 1.3.10 released 2015-02-09 +Security + * NULL pointer dereference in the buffer-based allocator when the buffer is + full and polarssl_free() is called (found by Mark Hasemeyer) + (only possible if POLARSSL_MEMORY_BUFFER_ALLOC_C is enabled, which it is + not by default). + * Fix remotely-triggerable uninitialised pointer dereference caused by + crafted X.509 certificate (TLS server is not affected if it doesn't ask for a + client certificate) (found using Codenomicon Defensics). + * Fix remotely-triggerable memory leak caused by crafted X.509 certificates + (TLS server is not affected if it doesn't ask for a client certificate) + (found using Codenomicon Defensics). + * Fix potential stack overflow while parsing crafted X.509 certificates + (TLS server is not affected if it doesn't ask for a client certificate) + (found using Codenomicon Defensics). + * Fix timing difference that could theoretically lead to a + Bleichenbacher-style attack in the RSA and RSA-PSK key exchanges + (reported by Sebastian Schinzel). + +Features + * Add support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv). + * Add support for Extended Master Secret (draft-ietf-tls-session-hash). + * Add support for Encrypt-then-MAC (RFC 7366). + * Add function pk_check_pair() to test if public and private keys match. + * Add x509_crl_parse_der(). + * Add compile-time option POLARSSL_X509_MAX_INTERMEDIATE_CA to limit the + length of an X.509 verification chain. + * Support for renegotiation can now be disabled at compile-time + * Support for 1/n-1 record splitting, a countermeasure against BEAST. + * Certificate selection based on signature hash, preferring SHA-1 over SHA-2 + for pre-1.2 clients when multiple certificates are available. + * Add support for getrandom() syscall on recent Linux kernels with Glibc or + a compatible enough libc (eg uClibc). + * Add ssl_set_arc4_support() to make it easier to disable RC4 at runtime + while using the default ciphersuite list. + * Added new error codes and debug messages about selection of + ciphersuite/certificate. + +Bugfix + * Stack buffer overflow if ctr_drbg_update() is called with too large + add_len (found by Jean-Philippe Aumasson) (not triggerable remotely). + * Possible buffer overflow of length at most POLARSSL_MEMORY_ALIGN_MULTIPLE + if memory_buffer_alloc_init() was called with buf not aligned and len not + a multiple of POLARSSL_MEMORY_ALIGN_MULTIPLE (not triggerable remotely). + * User set CFLAGS were ignored by Cmake with gcc (introduced in 1.3.9, found + by Julian Ospald). + * Fix potential undefined behaviour in Camellia. + * Fix potential failure in ECDSA signatures when POLARSSL_ECP_MAX_BITS is a + multiple of 8 (found by Gergely Budai). + * Fix unchecked return code in x509_crt_parse_path() on Windows (found by + Peter Vaskovic). + * Fix assembly selection for MIPS64 (thanks to James Cowgill). + * ssl_get_verify_result() now works even if the handshake was aborted due + to a failed verification (found by Fredrik Axelsson). + * Skip writing and parsing signature_algorithm extension if none of the + key exchanges enabled needs certificates. This fixes a possible interop + issue with some servers when a zero-length extension was sent. (Reported + by Peter Dettman.) + * On a 0-length input, base64_encode() did not correctly set output length + (found by Hendrik van den Boogaard). + +Changes + * Use deterministic nonces for AEAD ciphers in TLS by default (possible to + switch back to random with POLARSSL_SSL_AEAD_RANDOM_IV in config.h). + * Blind RSA private operations even when POLARSSL_RSA_NO_CRT is defined. + * ssl_set_own_cert() now returns an error on key-certificate mismatch. + * Forbid repeated extensions in X.509 certificates. + * debug_print_buf() now prints a text view in addition to hexadecimal. + * A specific error is now returned when there are ciphersuites in common + but none of them is usable due to external factors such as no certificate + with a suitable (extended)KeyUsage or curve or no PSK set. + * It is now possible to disable negotiation of truncated HMAC server-side + at runtime with ssl_set_truncated_hmac(). + * Example programs for SSL client and server now disable SSLv3 by default. + * Example programs for SSL client and server now disable RC4 by default. + * Use platform.h in all test suites and programs. + += PolarSSL 1.3.9 released 2014-10-20 +Security + * Lowest common hash was selected from signature_algorithms extension in + TLS 1.2 (found by Darren Bane) (introduced in 1.3.8). + * Remotely-triggerable memory leak when parsing some X.509 certificates + (server is not affected if it doesn't ask for a client certificate) + (found using Codenomicon Defensics). + * Remotely-triggerable memory leak when parsing crafted ClientHello + (not affected if ECC support was compiled out) (found using Codenomicon + Defensics). + +Bugfix + * Support escaping of commas in x509_string_to_names() + * Fix compile error in ssl_pthread_server (found by Julian Ospald). + * Fix net_accept() regarding non-blocking sockets (found by Luca Pesce). + * Don't print uninitialised buffer in ssl_mail_client (found by Marc Abel). + * Fix warnings from Clang's scan-build (contributed by Alfred Klomp). + * Fix compile error in timing.c when POLARSSL_NET_C and POLARSSL_SELFTEST + are defined but not POLARSSL_HAVE_TIME (found by Stephane Di Vito). + * Remove non-existent file from VS projects (found by Peter Vaskovic). + * ssl_read() could return non-application data records on server while + renegotation was pending, and on client when a HelloRequest was received. + * Server-initiated renegotiation would fail with non-blocking I/O if the + write callback returned WANT_WRITE when requesting renegotiation. + * ssl_close_notify() could send more than one message in some circumstances + with non-blocking I/O. + * Fix compiler warnings on iOS (found by Sander Niemeijer). + * x509_crt_parse() did not increase total_failed on PEM error + * Fix compile error with armcc in mpi_is_prime() + * Fix potential bad read in parsing ServerHello (found by Adrien + Vialletelle). + +Changes + * Ciphersuites using SHA-256 or SHA-384 now require TLS 1.x (there is no + standard defining how to use SHA-2 with SSL 3.0). + * Ciphersuites using RSA-PSK key exchange new require TLS 1.x (the spec is + ambiguous on how to encode some packets with SSL 3.0). + * Made buffer size in pk_write_(pub)key_pem() more dynamic, eg smaller if + RSA is disabled, larger if POLARSSL_MPI_MAX_SIZE is larger. + * ssl_read() now returns POLARSSL_ERR_NET_WANT_READ rather than + POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE on harmless alerts. + * POLARSSL_MPI_MAX_SIZE now defaults to 1024 in order to allow 8192 bits + RSA keys. + * Accept spaces at end of line or end of buffer in base64_decode(). + * X.509 certificates with more than one AttributeTypeAndValue per + RelativeDistinguishedName are not accepted any more. + += PolarSSL 1.3.8 released 2014-07-11 +Security + * Fix length checking for AEAD ciphersuites (found by Codenomicon). + It was possible to crash the server (and client) using crafted messages + when a GCM suite was chosen. + +Features + * Add CCM module and cipher mode to Cipher Layer + * Support for CCM and CCM_8 ciphersuites + * Support for parsing and verifying RSASSA-PSS signatures in the X.509 + modules (certificates, CRLs and CSRs). + * Blowfish in the cipher layer now supports variable length keys. + * Add example config.h for PSK with CCM, optimized for low RAM usage. + * Optimize for RAM usage in example config.h for NSA Suite B profile. + * Add POLARSSL_REMOVE_ARC4_CIPHERSUITES to allow removing RC4 ciphersuites + from the default list (inactive by default). + * Add server-side enforcement of sent renegotiation requests + (ssl_set_renegotiation_enforced()) + * Add SSL_CIPHERSUITES config.h flag to allow specifying a list of + ciphersuites to use and save some memory if the list is small. + +Changes + * Add LINK_WITH_PTHREAD option in CMake for explicit linking that is + required on some platforms (e.g. OpenBSD) + * Migrate zeroizing of data to polarssl_zeroize() instead of memset() + against unwanted compiler optimizations + * md_list() now returns hashes strongest first + * Selection of hash for signing ServerKeyExchange in TLS 1.2 now picks + strongest offered by client. + * All public contexts have _init() and _free() functions now for simpler + usage pattern + +Bugfix + * Fix in debug_print_msg() + * Enforce alignment in the buffer allocator even if buffer is not aligned + * Remove less-than-zero checks on unsigned numbers + * Stricter check on SSL ClientHello internal sizes compared to actual packet + size (found by TrustInSoft) + * Fix WSAStartup() return value check (found by Peter Vaskovic) + * Other minor issues (found by Peter Vaskovic) + * Fix symlink command for cross compiling with CMake (found by Andre + Heinecke) + * Fix DER output of gen_key app (found by Gergely Budai) + * Very small records were incorrectly rejected when truncated HMAC was in + use with some ciphersuites and versions (RC4 in all versions, CBC with + versions < TLS 1.1). + * Very large records using more than 224 bytes of padding were incorrectly + rejected with CBC-based ciphersuites and TLS >= 1.1 + * Very large records using less padding could cause a buffer overread of up + to 32 bytes with CBC-based ciphersuites and TLS >= 1.1 + * Restore ability to use a v1 cert as a CA if trusted locally. (This had + been removed in 1.3.6.) + * Restore ability to locally trust a self-signed cert that is not a proper + CA for use as an end entity certificate. (This had been removed in + 1.3.6.) + * Fix preprocessor checks for bn_mul PPC asm (found by Barry K. Nathan). + * Use \n\t rather than semicolons for bn_mul asm, since some assemblers + interpret semicolons as comment delimiters (found by Barry K. Nathan). + * Fix off-by-one error in parsing Supported Point Format extension that + caused some handshakes to fail. + * Fix possible miscomputation of the premaster secret with DHE-PSK key + exchange that caused some handshakes to fail with other implementations. + (Failure rate <= 1/255 with common DHM moduli.) + * Disable broken Sparc64 bn_mul assembly (found by Florian Obser). + * Fix base64_decode() to return and check length correctly (in case of + tight buffers) + * Fix mpi_write_string() to write "00" as hex output for empty MPI (found + by Hui Dong) + += PolarSSL 1.3.7 released on 2014-05-02 +Features + * debug_set_log_mode() added to determine raw or full logging + * debug_set_threshold() added to ignore messages over threshold level + * version_check_feature() added to check for compile-time options at + run-time + +Changes + * POLARSSL_CONFIG_OPTIONS has been removed. All values are individually + checked and filled in the relevant module headers + * Debug module only outputs full lines instead of parts + * Better support for the different Attribute Types from IETF PKIX (RFC 5280) + * AES-NI now compiles with "old" assemblers too + * Ciphersuites based on RC4 now have the lowest priority by default + +Bugfix + * Only iterate over actual certificates in ssl_write_certificate_request() + (found by Matthew Page) + * Typos in platform.c and pkcs11.c (found by Daniel Phillips and Steffan + Karger) + * cert_write app should use subject of issuer certificate as issuer of cert + * Fix false reject in padding check in ssl_decrypt_buf() for CBC + ciphersuites, for full SSL frames of data. + * Improve interoperability by not writing extension length in ClientHello / + ServerHello when no extensions are present (found by Matthew Page) + * rsa_check_pubkey() now allows an E up to N + * On OpenBSD, use arc4random_buf() instead of rand() to prevent warnings + * mpi_fill_random() was creating numbers larger than requested on + big-endian platform when size was not an integer number of limbs + * Fix dependencies issues in X.509 test suite. + * Some parts of ssl_tls.c were compiled even when the module was disabled. + * Fix detection of DragonflyBSD in net.c (found by Markus Pfeiffer) + * Fix detection of Clang on some Apple platforms with CMake + (found by Barry K. Nathan) + += PolarSSL 1.3.6 released on 2014-04-11 + +Features + * Support for the ALPN SSL extension + * Add option 'use_dev_random' to gen_key application + * Enable verification of the keyUsage extension for CA and leaf + certificates (POLARSSL_X509_CHECK_KEY_USAGE) + * Enable verification of the extendedKeyUsage extension + (POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE) + +Changes + * x509_crt_info() now prints information about parsed extensions as well + * pk_verify() now returns a specific error code when the signature is valid + but shorter than the supplied length. + * Use UTC time to check certificate validity. + * Reject certificates with times not in UTC, per RFC 5280. + +Security + * Avoid potential timing leak in ecdsa_sign() by blinding modular division. + (Found by Watson Ladd.) + * The notAfter date of some certificates was no longer checked since 1.3.5. + This affects certificates in the user-supplied chain except the top + certificate. If the user-supplied chain contains only one certificates, + it is not affected (ie, its notAfter date is properly checked). + * Prevent potential NULL pointer dereference in ssl_read_record() (found by + TrustInSoft) + +Bugfix + * The length of various ClientKeyExchange messages was not properly checked. + * Some example server programs were not sending the close_notify alert. + * Potential memory leak in mpi_exp_mod() when error occurs during + calculation of RR. + * Fixed malloc/free default #define in platform.c (found by Gergely Budai). + * Fixed type which made POLARSSL_ENTROPY_FORCE_SHA256 uneffective (found by + Gergely Budai). + * Fix #include path in ecdsa.h which wasn't accepted by some compilers. + (found by Gergely Budai) + * Fix compile errors when POLARSSL_ERROR_STRERROR_BC is undefined (found by + Shuo Chen). + * oid_get_numeric_string() used to truncate the output without returning an + error if the output buffer was just 1 byte too small. + * dhm_parse_dhm() (hence dhm_parse_dhmfile()) did not set dhm->len. + * Calling pk_debug() on an RSA-alt key would segfault. + * pk_get_size() and pk_get_len() were off by a factor 8 for RSA-alt keys. + * Potential buffer overwrite in pem_write_buffer() because of low length + indication (found by Thijs Alkemade) + * EC curves constants, which should be only in ROM since 1.3.3, were also + stored in RAM due to missing 'const's (found by Gergely Budai). + += PolarSSL 1.3.5 released on 2014-03-26 +Features + * HMAC-DRBG as a separate module + * Option to set the Curve preference order (disabled by default) + * Single Platform compatilibity layer (for memory / printf / fprintf) + * Ability to provide alternate timing implementation + * Ability to force the entropy module to use SHA-256 as its basis + (POLARSSL_ENTROPY_FORCE_SHA256) + * Testing script ssl-opt.sh added for testing 'live' ssl option + interoperability against OpenSSL and PolarSSL + * Support for reading EC keys that use SpecifiedECDomain in some cases. + * Entropy module now supports seed writing and reading + +Changes + * Deprecated the Memory layer + * entropy_add_source(), entropy_update_manual() and entropy_gather() + now thread-safe if POLARSSL_THREADING_C defined + * Improvements to the CMake build system, contributed by Julian Ospald. + * Work around a bug of the version of Clang shipped by Apple with Mavericks + that prevented bignum.c from compiling. (Reported by Rafael Baptista.) + * Revamped the compat.sh interoperatibility script to include support for + testing against GnuTLS + * Deprecated ssl_set_own_cert_rsa() and ssl_set_own_cert_rsa_alt() + * Improvements to tests/Makefile, contributed by Oden Eriksson. + +Security + * Forbid change of server certificate during renegotiation to prevent + "triple handshake" attack when authentication mode is 'optional' (the + attack was already impossible when authentication is required). + * Check notBefore timestamp of certificates and CRLs from the future. + * Forbid sequence number wrapping + * Fixed possible buffer overflow with overlong PSK + * Possible remotely-triggered out-of-bounds memory access fixed (found by + TrustInSoft) + +Bugfix + * ecp_gen_keypair() does more tries to prevent failure because of + statistics + * Fixed bug in RSA PKCS#1 v1.5 "reversed" operations + * Fixed testing with out-of-source builds using cmake + * Fixed version-major intolerance in server + * Fixed CMake symlinking on out-of-source builds + * Fixed dependency issues in test suite + * Programs rsa_sign_pss and rsa_verify_pss were not using PSS since 1.3.0 + * Bignum's MIPS-32 assembly was used on MIPS-64, causing chaos. (Found by + Alex Wilson.) + * ssl_cache was creating entries when max_entries=0 if TIMING_C was enabled. + * m_sleep() was sleeping twice too long on most Unix platforms. + * Fixed bug with session tickets and non-blocking I/O in the unlikely case + send() would return an EAGAIN error when sending the ticket. + * ssl_cache was leaking memory when reusing a timed out entry containing a + client certificate. + * ssl_srv was leaking memory when client presented a timed out ticket + containing a client certificate + * ssl_init() was leaving a dirty pointer in ssl_context if malloc of + out_ctr failed + * ssl_handshake_init() was leaving dirty pointers in subcontexts if malloc + of one of them failed + * Fix typo in rsa_copy() that impacted PKCS#1 v2 contexts + * x509_get_current_time() uses localtime_r() to prevent thread issues + += PolarSSL 1.3.4 released on 2014-01-27 +Features + * Support for the Koblitz curves: secp192k1, secp224k1, secp256k1 + * Support for RIPEMD-160 + * Support for AES CFB8 mode + * Support for deterministic ECDSA (RFC 6979) + +Bugfix + * Potential memory leak in bignum_selftest() + * Replaced expired test certificate + * ssl_mail_client now terminates lines with CRLF, instead of LF + * net module handles timeouts on blocking sockets better (found by Tilman + Sauerbeck) + * Assembly format fixes in bn_mul.h + +Security + * Missing MPI_CHK calls added around unguarded mpi calls (found by + TrustInSoft) + += PolarSSL 1.3.3 released on 2013-12-31 +Features + * EC key generation support in gen_key app + * Support for adhering to client ciphersuite order preference + (POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + * Support for Curve25519 + * Support for ECDH-RSA and ECDH-ECDSA key exchanges and ciphersuites + * Support for IPv6 in the NET module + * AES-NI support for AES, AES-GCM and AES key scheduling + * SSL Pthread-based server example added (ssl_pthread_server) + +Changes + * gen_prime() speedup + * Speedup of ECP multiplication operation + * Relaxed some SHA2 ciphersuite's version requirements + * Dropped use of readdir_r() instead of readdir() with threading support + * More constant-time checks in the RSA module + * Split off curves from ecp.c into ecp_curves.c + * Curves are now stored fully in ROM + * Memory usage optimizations in ECP module + * Removed POLARSSL_THREADING_DUMMY + +Bugfix + * Fixed bug in mpi_set_bit() on platforms where t_uint is wider than int + * Fixed X.509 hostname comparison (with non-regular characters) + * SSL now gracefully handles missing RNG + * Missing defines / cases for RSA_PSK key exchange + * crypt_and_hash app checks MAC before final decryption + * Potential memory leak in ssl_ticket_keys_init() + * Memory leak in benchmark application + * Fixed x509_crt_parse_path() bug on Windows platforms + * Added missing MPI_CHK() around some statements in mpi_div_mpi() (found by + TrustInSoft) + * Fixed potential overflow in certificate size verification in + ssl_write_certificate() (found by TrustInSoft) + +Security + * Possible remotely-triggered out-of-bounds memory access fixed (found by + TrustInSoft) + += PolarSSL 1.3.2 released on 2013-11-04 +Features + * PK tests added to test framework + * Added optional optimization for NIST MODP curves (POLARSSL_ECP_NIST_OPTIM) + * Support for Camellia-GCM mode and ciphersuites + +Changes + * Padding checks in cipher layer are now constant-time + * Value comparisons in SSL layer are now constant-time + * Support for serialNumber, postalAddress and postalCode in X509 names + * SSL Renegotiation was refactored + +Bugfix + * More stringent checks in cipher layer + * Server does not send out extensions not advertised by client + * Prevent possible alignment warnings on casting from char * to 'aligned *' + * Misc fixes and additions to dependency checks + * Const correctness + * cert_write with selfsign should use issuer_name as subject_name + * Fix ECDSA corner case: missing reduction mod N (found by DualTachyon) + * Defines to handle UEFI environment under MSVC + * Server-side initiated renegotiations send HelloRequest + += PolarSSL 1.3.1 released on 2013-10-15 +Features + * Support for Brainpool curves and TLS ciphersuites (RFC 7027) + * Support for ECDHE-PSK key-exchange and ciphersuites + * Support for RSA-PSK key-exchange and ciphersuites + +Changes + * RSA blinding locks for a smaller amount of time + * TLS compression only allocates working buffer once + * Introduced POLARSSL_HAVE_READDIR_R for systems without it + * config.h is more script-friendly + +Bugfix + * Missing MSVC defines added + * Compile errors with POLARSSL_RSA_NO_CRT + * Header files with 'polarssl/' + * Const correctness + * Possible naming collision in dhm_context + * Better support for MSVC + * threading_set_alt() name + * Added missing x509write_crt_set_version() + += PolarSSL 1.3.0 released on 2013-10-01 +Features + * Elliptic Curve Cryptography module added + * Elliptic Curve Diffie Hellman module added + * Ephemeral Elliptic Curve Diffie Hellman support for SSL/TLS + (ECDHE-based ciphersuites) + * Ephemeral Elliptic Curve Digital Signature Algorithm support for SSL/TLS + (ECDSA-based ciphersuites) + * Ability to specify allowed ciphersuites based on the protocol version. + * PSK and DHE-PSK based ciphersuites added + * Memory allocation abstraction layer added + * Buffer-based memory allocator added (no malloc() / free() / HEAP usage) + * Threading abstraction layer added (dummy / pthread / alternate) + * Public Key abstraction layer added + * Parsing Elliptic Curve keys + * Parsing Elliptic Curve certificates + * Support for max_fragment_length extension (RFC 6066) + * Support for truncated_hmac extension (RFC 6066) + * Support for zeros-and-length (ANSI X.923) padding, one-and-zeros + (ISO/IEC 7816-4) padding and zero padding in the cipher layer + * Support for session tickets (RFC 5077) + * Certificate Request (CSR) generation with extensions (key_usage, + ns_cert_type) + * X509 Certificate writing with extensions (basic_constraints, + issuer_key_identifier, etc) + * Optional blinding for RSA, DHM and EC + * Support for multiple active certificate / key pairs in SSL servers for + the same host (Not to be confused with SNI!) + +Changes + * Ability to enable / disable SSL v3 / TLS 1.0 / TLS 1.1 / TLS 1.2 + individually + * Introduced separate SSL Ciphersuites module that is based on + Cipher and MD information + * Internals for SSL module adapted to have separate IV pointer that is + dynamically set (Better support for hardware acceleration) + * Moved all OID functionality to a separate module. RSA function + prototypes for the RSA sign and verify functions changed as a result + * Split up the GCM module into a starts/update/finish cycle + * Client and server now filter sent and accepted ciphersuites on minimum + and maximum protocol version + * Ability to disable server_name extension (RFC 6066) + * Renamed error_strerror() to the less conflicting polarssl_strerror() + (Ability to keep old as well with POLARSSL_ERROR_STRERROR_BC) + * SHA2 renamed to SHA256, SHA4 renamed to SHA512 and functions accordingly + * All RSA operations require a random generator for blinding purposes + * X509 core refactored + * x509_crt_verify() now case insensitive for cn (RFC 6125 6.4) + * Also compiles / runs without time-based functions (!POLARSSL_HAVE_TIME) + * Support faulty X509 v1 certificates with extensions + (POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3) + +Bugfix + * Fixed parse error in ssl_parse_certificate_request() + * zlib compression/decompression skipped on empty blocks + * Support for AIX header locations in net.c module + * Fixed file descriptor leaks + +Security + * RSA blinding on CRT operations to counter timing attacks + (found by Cyril Arnaud and Pierre-Alain Fouque) + + += Version 1.2.14 released 2015-05-?? + +Security + * Fix potential invalid memory read in the server, that allows a client to + crash it remotely (found by Caj Larsson). + * Fix potential invalid memory read in certificate parsing, that allows a + client to crash the server remotely if client authentication is enabled + (found using Codenomicon Defensics). + * Add countermeasure against "Lucky 13 strikes back" cache-based attack, + https://dl.acm.org/citation.cfm?id=2714625 + +Bugfix + * Fix bug in Via Padlock support (found by Nikos Mavrogiannopoulos). + * Fix hardclock() (only used in the benchmarking program) with some + versions of mingw64 (found by kxjhlele). + * Fix warnings from mingw64 in timing.c (found by kxjklele). + * Fix potential unintended sign extension in asn1_get_len() on 64-bit + platforms (found with Coverity Scan). + += Version 1.2.13 released 2015-02-16 +Note: Although PolarSSL has been renamed to mbed TLS, no changes reflecting + this will be made in the 1.2 branch at this point. + +Security + * Fix remotely-triggerable uninitialised pointer dereference caused by + crafted X.509 certificate (TLS server is not affected if it doesn't ask + for a client certificate) (found using Codenomicon Defensics). + * Fix remotely-triggerable memory leak caused by crafted X.509 certificates + (TLS server is not affected if it doesn't ask for a client certificate) + (found using Codenomicon Defensics). + * Fix potential stack overflow while parsing crafted X.509 certificates + (TLS server is not affected if it doesn't ask for a client certificate) + found using Codenomicon Defensics). + * Fix buffer overread of size 1 when parsing crafted X.509 certificates + (TLS server is not affected if it doesn't ask for a client certificate). + +Bugfix + * Fix potential undefined behaviour in Camellia. + * Fix memory leaks in PKCS#5 and PKCS#12. + * Stack buffer overflow if ctr_drbg_update() is called with too large + add_len (found by Jean-Philippe Aumasson) (not triggerable remotely). + * Fix bug in MPI/bignum on s390/s390x (reported by Dan Horák) (introduced + in 1.2.12). + * Fix unchecked return code in x509_crt_parse_path() on Windows (found by + Peter Vaskovic). + * Fix assembly selection for MIPS64 (thanks to James Cowgill). + * ssl_get_verify_result() now works even if the handshake was aborted due + to a failed verification (found by Fredrik Axelsson). + * Skip writing and parsing signature_algorithm extension if none of the + key exchanges enabled needs certificates. This fixes a possible interop + issue with some servers when a zero-length extension was sent. (Reported + by Peter Dettman.) + * On a 0-length input, base64_encode() did not correctly set output length + (found by Hendrik van den Boogaard). + +Changes + * Blind RSA private operations even when POLARSSL_RSA_NO_CRT is defined. + * Forbid repeated extensions in X.509 certificates. + * Add compile-time option POLARSSL_X509_MAX_INTERMEDIATE_CA to limit the + length of an X.509 verification chain (default = 8). += Version 1.2.12 released 2014-10-24 + +Security + * Remotely-triggerable memory leak when parsing some X.509 certificates + (server is not affected if it doesn't ask for a client certificate). + (Found using Codenomicon Defensics.) + +Bugfix + * Fix potential bad read in parsing ServerHello (found by Adrien + Vialletelle). + * ssl_close_notify() could send more than one message in some circumstances + with non-blocking I/O. + * x509_crt_parse() did not increase total_failed on PEM error + * Fix compiler warnings on iOS (found by Sander Niemeijer). + * Don't print uninitialised buffer in ssl_mail_client (found by Marc Abel). + * Fix net_accept() regarding non-blocking sockets (found by Luca Pesce). + * ssl_read() could return non-application data records on server while + renegotation was pending, and on client when a HelloRequest was received. + * Fix warnings from Clang's scan-build (contributed by Alfred Klomp). + +Changes + * X.509 certificates with more than one AttributeTypeAndValue per + RelativeDistinguishedName are not accepted any more. + * ssl_read() now returns POLARSSL_ERR_NET_WANT_READ rather than + POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE on harmless alerts. + * Accept spaces at end of line or end of buffer in base64_decode(). + += Version 1.2.11 released 2014-07-11 +Features + * Entropy module now supports seed writing and reading + +Changes + * Introduced POLARSSL_HAVE_READDIR_R for systems without it + * Improvements to the CMake build system, contributed by Julian Ospald. + * Work around a bug of the version of Clang shipped by Apple with Mavericks + that prevented bignum.c from compiling. (Reported by Rafael Baptista.) + * Improvements to tests/Makefile, contributed by Oden Eriksson. + * Use UTC time to check certificate validity. + * Reject certificates with times not in UTC, per RFC 5280. + * Migrate zeroizing of data to polarssl_zeroize() instead of memset() + against unwanted compiler optimizations + +Security + * Forbid change of server certificate during renegotiation to prevent + "triple handshake" attack when authentication mode is optional (the + attack was already impossible when authentication is required). + * Check notBefore timestamp of certificates and CRLs from the future. + * Forbid sequence number wrapping + * Prevent potential NULL pointer dereference in ssl_read_record() (found by + TrustInSoft) + * Fix length checking for AEAD ciphersuites (found by Codenomicon). + It was possible to crash the server (and client) using crafted messages + when a GCM suite was chosen. + +Bugfix + * Fixed X.509 hostname comparison (with non-regular characters) + * SSL now gracefully handles missing RNG + * crypt_and_hash app checks MAC before final decryption + * Fixed x509_crt_parse_path() bug on Windows platforms + * Added missing MPI_CHK() around some statements in mpi_div_mpi() (found by + TrustInSoft) + * Fixed potential overflow in certificate size verification in + ssl_write_certificate() (found by TrustInSoft) + * Fix ASM format in bn_mul.h + * Potential memory leak in bignum_selftest() + * Replaced expired test certificate + * ssl_mail_client now terminates lines with CRLF, instead of LF + * Fix bug in RSA PKCS#1 v1.5 "reversed" operations + * Fixed testing with out-of-source builds using cmake + * Fixed version-major intolerance in server + * Fixed CMake symlinking on out-of-source builds + * Bignum's MIPS-32 assembly was used on MIPS-64, causing chaos. (Found by + Alex Wilson.) + * ssl_init() was leaving a dirty pointer in ssl_context if malloc of + out_ctr failed + * ssl_handshake_init() was leaving dirty pointers in subcontexts if malloc + of one of them failed + * x509_get_current_time() uses localtime_r() to prevent thread issues + * Some example server programs were not sending the close_notify alert. + * Potential memory leak in mpi_exp_mod() when error occurs during + calculation of RR. + * Improve interoperability by not writing extension length in ClientHello + when no extensions are present (found by Matthew Page) + * rsa_check_pubkey() now allows an E up to N + * On OpenBSD, use arc4random_buf() instead of rand() to prevent warnings + * mpi_fill_random() was creating numbers larger than requested on + big-endian platform when size was not an integer number of limbs + * Fix detection of DragonflyBSD in net.c (found by Markus Pfeiffer) + * Stricter check on SSL ClientHello internal sizes compared to actual packet + size (found by TrustInSoft) + * Fix preprocessor checks for bn_mul PPC asm (found by Barry K. Nathan). + * Use \n\t rather than semicolons for bn_mul asm, since some assemblers + interpret semicolons as comment delimiters (found by Barry K. Nathan). + * Disable broken Sparc64 bn_mul assembly (found by Florian Obser). + * Fix base64_decode() to return and check length correctly (in case of + tight buffers) + += Version 1.2.10 released 2013-10-07 +Changes + * Changed RSA blinding to a slower but thread-safe version + +Bugfix + * Fixed memory leak in RSA as a result of introduction of blinding + * Fixed ssl_pkcs11_decrypt() prototype + * Fixed MSVC project files + += Version 1.2.9 released 2013-10-01 +Changes + * x509_verify() now case insensitive for cn (RFC 6125 6.4) + +Bugfix + * Fixed potential memory leak when failing to resume a session + * Fixed potential file descriptor leaks (found by Remi Gacogne) + * Minor fixes + +Security + * Fixed potential heap buffer overflow on large hostname setting + * Fixed potential negative value misinterpretation in load_file() + * RSA blinding on CRT operations to counter timing attacks + (found by Cyril Arnaud and Pierre-Alain Fouque) + += Version 1.2.8 released 2013-06-19 +Features + * Parsing of PKCS#8 encrypted private key files + * PKCS#12 PBE and derivation functions + * Centralized module option values in config.h to allow user-defined + settings without editing header files by using POLARSSL_CONFIG_OPTIONS + +Changes + * HAVEGE random generator disabled by default + * Internally split up x509parse_key() into a (PEM) handler function + and specific DER parser functions for the PKCS#1 and unencrypted + PKCS#8 private key formats + * Added mechanism to provide alternative implementations for all + symmetric cipher and hash algorithms (e.g. POLARSSL_AES_ALT in + config.h) + * PKCS#5 module added. Moved PBKDF2 functionality inside and deprecated + old PBKDF2 module + +Bugfix + * Secure renegotiation extension should only be sent in case client + supports secure renegotiation + * Fixed offset for cert_type list in ssl_parse_certificate_request() + * Fixed const correctness issues that have no impact on the ABI + * x509parse_crt() now better handles PEM error situations + * ssl_parse_certificate() now calls x509parse_crt_der() directly + instead of the x509parse_crt() wrapper that can also parse PEM + certificates + * x509parse_crtpath() is now reentrant and uses more portable stat() + * Fixed bignum.c and bn_mul.h to support Thumb2 and LLVM compiler + * Fixed values for 2-key Triple DES in cipher layer + * ssl_write_certificate_request() can handle empty ca_chain + +Security + * A possible DoS during the SSL Handshake, due to faulty parsing of + PEM-encoded certificates has been fixed (found by Jack Lloyd) + += Version 1.2.7 released 2013-04-13 +Features + * Ability to specify allowed ciphersuites based on the protocol version. + +Changes + * Default Blowfish keysize is now 128-bits + * Test suites made smaller to accommodate Raspberry Pi + +Bugfix + * Fix for MPI assembly for ARM + * GCM adapted to support sizes > 2^29 + += Version 1.2.6 released 2013-03-11 +Bugfix + * Fixed memory leak in ssl_free() and ssl_reset() for active session + * Corrected GCM counter incrementation to use only 32-bits instead of + 128-bits (found by Yawning Angel) + * Fixes for 64-bit compilation with MS Visual Studio + * Fixed net_bind() for specified IP addresses on little endian systems + * Fixed assembly code for ARM (Thumb and regular) for some compilers + +Changes + * Internally split up rsa_pkcs1_encrypt(), rsa_pkcs1_decrypt(), + rsa_pkcs1_sign() and rsa_pkcs1_verify() to separate PKCS#1 v1.5 and + PKCS#1 v2.1 functions + * Added support for custom labels when using rsa_rsaes_oaep_encrypt() + or rsa_rsaes_oaep_decrypt() + * Re-added handling for SSLv2 Client Hello when the define + POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO is set + * The SSL session cache module (ssl_cache) now also retains peer_cert + information (not the entire chain) + +Security + * Removed further timing differences during SSL message decryption in + ssl_decrypt_buf() + * Removed timing differences due to bad padding from + rsa_rsaes_pkcs1_v15_decrypt() and rsa_pkcs1_decrypt() for PKCS#1 v1.5 + operations + += Version 1.2.5 released 2013-02-02 +Changes + * Allow enabling of dummy error_strerror() to support some use-cases + * Debug messages about padding errors during SSL message decryption are + disabled by default and can be enabled with POLARSSL_SSL_DEBUG_ALL + * Sending of security-relevant alert messages that do not break + interoperability can be switched on/off with the flag + POLARSSL_SSL_ALL_ALERT_MESSAGES + +Security + * Removed timing differences during SSL message decryption in + ssl_decrypt_buf() due to badly formatted padding + += Version 1.2.4 released 2013-01-25 +Changes + * More advanced SSL ciphersuite representation and moved to more dynamic + SSL core + * Added ssl_handshake_step() to allow single stepping the handshake process + +Bugfix + * Memory leak when using RSA_PKCS_V21 operations fixed + * Handle future version properly in ssl_write_certificate_request() + * Correctly handle CertificateRequest message in client for <= TLS 1.1 + without DN list + += Version 1.2.3 released 2012-11-26 +Bugfix + * Server not always sending correct CertificateRequest message + += Version 1.2.2 released 2012-11-24 +Changes + * Added p_hw_data to ssl_context for context specific hardware acceleration + data + * During verify trust-CA is only checked for expiration and CRL presence + +Bugfixes + * Fixed client authentication compatibility + * Fixed dependency on POLARSSL_SHA4_C in SSL modules + += Version 1.2.1 released 2012-11-20 +Changes + * Depth that the certificate verify callback receives is now numbered + bottom-up (Peer cert depth is 0) + +Bugfixes + * Fixes for MSVC6 + * Moved mpi_inv_mod() outside POLARSSL_GENPRIME + * Allow R and A to point to same mpi in mpi_div_mpi (found by Manuel + Pégourié-Gonnard) + * Fixed possible segfault in mpi_shift_r() (found by Manuel + Pégourié-Gonnard) + * Added max length check for rsa_pkcs1_sign with PKCS#1 v2.1 + += Version 1.2.0 released 2012-10-31 +Features + * Added support for NULL cipher (POLARSSL_CIPHER_NULL_CIPHER) and weak + ciphersuites (POLARSSL_ENABLE_WEAK_CIPHERSUITES). They are disabled by + default! + * Added support for wildcard certificates + * Added support for multi-domain certificates through the X509 Subject + Alternative Name extension + * Added preliminary ASN.1 buffer writing support + * Added preliminary X509 Certificate Request writing support + * Added key_app_writer example application + * Added cert_req example application + * Added base Galois Counter Mode (GCM) for AES + * Added TLS 1.2 support (RFC 5246) + * Added GCM suites to TLS 1.2 (RFC 5288) + * Added commandline error code convertor (util/strerror) + * Added support for Hardware Acceleration hooking in SSL/TLS + * Added OpenSSL / PolarSSL compatibility script (tests/compat.sh) and + example application (programs/ssl/o_p_test) (requires OpenSSL) + * Added X509 CA Path support + * Added Thumb assembly optimizations + * Added DEFLATE compression support as per RFC3749 (requires zlib) + * Added blowfish algorithm (Generic and cipher layer) + * Added PKCS#5 PBKDF2 key derivation function + * Added Secure Renegotiation (RFC 5746) + * Added predefined DHM groups from RFC 5114 + * Added simple SSL session cache implementation + * Added ServerName extension parsing (SNI) at server side + * Added option to add minimum accepted SSL/TLS protocol version + +Changes + * Removed redundant POLARSSL_DEBUG_MSG define + * AES code only check for Padlock once + * Fixed const-correctness mpi_get_bit() + * Documentation for mpi_lsb() and mpi_msb() + * Moved out_msg to out_hdr + 32 to support hardware acceleration + * Changed certificate verify behaviour to comply with RFC 6125 section 6.3 + to not match CN if subjectAltName extension is present (Closes ticket #56) + * Cipher layer cipher_mode_t POLARSSL_MODE_CFB128 is renamed to + POLARSSL_MODE_CFB, to also handle different block size CFB modes. + * Removed handling for SSLv2 Client Hello (as per RFC 5246 recommendation) + * Revamped session resumption handling + * Generalized external private key implementation handling (like PKCS#11) + in SSL/TLS + * Revamped x509_verify() and the SSL f_vrfy callback implementations + * Moved from unsigned long to fixed width uint32_t types throughout code + * Renamed ciphersuites naming scheme to IANA reserved names + +Bugfix + * Fixed handling error in mpi_cmp_mpi() on longer B values (found by + Hui Dong) + * Fixed potential heap corruption in x509_name allocation + * Fixed single RSA test that failed on Big Endian systems (Closes ticket #54) + * mpi_exp_mod() now correctly handles negative base numbers (Closes ticket + #52) + * Handle encryption with private key and decryption with public key as per + RFC 2313 + * Handle empty certificate subject names + * Prevent reading over buffer boundaries on X509 certificate parsing + * mpi_add_abs() now correctly handles adding short numbers to long numbers + with carry rollover (found by Ruslan Yushchenko) + * Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob + * Fixed MPI assembly for SPARC64 platform + +Security + * Fixed potential memory zeroization on miscrafted RSA key (found by Eloi + Vanderbeken) + += Version 1.1.8 released on 2013-10-01 +Bugfix + * Fixed potential memory leak when failing to resume a session + * Fixed potential file descriptor leaks + +Security + * Potential buffer-overflow for ssl_read_record() (independently found by + both TrustInSoft and Paul Brodeur of Leviathan Security Group) + * Potential negative value misinterpretation in load_file() + * Potential heap buffer overflow on large hostname setting + += Version 1.1.7 released on 2013-06-19 +Changes + * HAVEGE random generator disabled by default + +Bugfix + * x509parse_crt() now better handles PEM error situations + * ssl_parse_certificate() now calls x509parse_crt_der() directly + instead of the x509parse_crt() wrapper that can also parse PEM + certificates + * Fixed values for 2-key Triple DES in cipher layer + * ssl_write_certificate_request() can handle empty ca_chain + +Security + * A possible DoS during the SSL Handshake, due to faulty parsing of + PEM-encoded certificates has been fixed (found by Jack Lloyd) + += Version 1.1.6 released on 2013-03-11 +Bugfix + * Fixed net_bind() for specified IP addresses on little endian systems + +Changes + * Allow enabling of dummy error_strerror() to support some use-cases + * Debug messages about padding errors during SSL message decryption are + disabled by default and can be enabled with POLARSSL_SSL_DEBUG_ALL + +Security + * Removed timing differences during SSL message decryption in + ssl_decrypt_buf() + * Removed timing differences due to bad padding from + rsa_rsaes_pkcs1_v15_decrypt() and rsa_pkcs1_decrypt() for PKCS#1 v1.5 + operations + += Version 1.1.5 released on 2013-01-16 +Bugfix + * Fixed MPI assembly for SPARC64 platform + * Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob + * mpi_add_abs() now correctly handles adding short numbers to long numbers + with carry rollover + * Moved mpi_inv_mod() outside POLARSSL_GENPRIME + * Prevent reading over buffer boundaries on X509 certificate parsing + * mpi_exp_mod() now correctly handles negative base numbers (Closes ticket + #52) + * Fixed possible segfault in mpi_shift_r() (found by Manuel + Pégourié-Gonnard) + * Allow R and A to point to same mpi in mpi_div_mpi (found by Manuel + Pégourié-Gonnard) + * Added max length check for rsa_pkcs1_sign with PKCS#1 v2.1 + * Memory leak when using RSA_PKCS_V21 operations fixed + * Handle encryption with private key and decryption with public key as per + RFC 2313 + * Fixes for MSVC6 + +Security + * Fixed potential memory zeroization on miscrafted RSA key (found by Eloi + Vanderbeken) + += Version 1.1.4 released on 2012-05-31 +Bugfix + * Correctly handle empty SSL/TLS packets (Found by James Yonan) + * Fixed potential heap corruption in x509_name allocation + * Fixed single RSA test that failed on Big Endian systems (Closes ticket #54) + += Version 1.1.3 released on 2012-04-29 +Bugfix + * Fixed random MPI generation to not generate more size than requested. + += Version 1.1.2 released on 2012-04-26 +Bugfix + * Fixed handling error in mpi_cmp_mpi() on longer B values (found by + Hui Dong) + +Security + * Fixed potential memory corruption on miscrafted client messages (found by + Frama-C team at CEA LIST) + * Fixed generation of DHM parameters to correct length (found by Ruslan + Yushchenko) + += Version 1.1.1 released on 2012-01-23 +Bugfix + * Check for failed malloc() in ssl_set_hostname() and x509_get_entries() + (Closes ticket #47, found by Hugo Leisink) + * Fixed issues with Intel compiler on 64-bit systems (Closes ticket #50) + * Fixed multiple compiler warnings for VS6 and armcc + * Fixed bug in CTR_CRBG selftest + += Version 1.1.0 released on 2011-12-22 +Features + * Added ssl_session_reset() to allow better multi-connection pools of + SSL contexts without needing to set all non-connection-specific + data and pointers again. Adapted ssl_server to use this functionality. + * Added ssl_set_max_version() to allow clients to offer a lower maximum + supported version to a server to help buggy server implementations. + (Closes ticket #36) + * Added cipher_get_cipher_mode() and cipher_get_cipher_operation() + introspection functions (Closes ticket #40) + * Added CTR_DRBG based on AES-256-CTR (NIST SP 800-90) random generator + * Added a generic entropy accumulator that provides support for adding + custom entropy sources and added some generic and platform dependent + entropy sources + +Changes + * Documentation for AES and Camellia in modes CTR and CFB128 clarified. + * Fixed rsa_encrypt and rsa_decrypt examples to use public key for + encryption and private key for decryption. (Closes ticket #34) + * Inceased maximum size of ASN1 length reads to 32-bits. + * Added an EXPLICIT tag number parameter to x509_get_ext() + * Added a separate CRL entry extension parsing function + * Separated the ASN.1 parsing code from the X.509 specific parsing code. + So now there is a module that is controlled with POLARSSL_ASN1_PARSE_C. + * Changed the defined key-length of DES ciphers in cipher.h to include the + parity bits, to prevent mistakes in copying data. (Closes ticket #33) + * Loads of minimal changes to better support WINCE as a build target + (Credits go to Marco Lizza) + * Added POLARSSL_MPI_WINDOW_SIZE definition to allow easier time to memory + trade-off + * Introduced POLARSSL_MPI_MAX_SIZE and POLARSSL_MPI_MAX_BITS for MPI size + management (Closes ticket #44) + * Changed the used random function pointer to more flexible format. Renamed + havege_rand() to havege_random() to prevent mistakes. Lots of changes as + a consequence in library code and programs + * Moved all examples programs to use the new entropy and CTR_DRBG + * Added permissive certificate parsing to x509parse_crt() and + x509parse_crtfile(). With permissive parsing the parsing does not stop on + encountering a parse-error. Beware that the meaning of return values has + changed! + * All error codes are now negative. Even on mermory failures and IO errors. + +Bugfix + * Fixed faulty HMAC-MD2 implementation. Found by dibac. (Closes + ticket #37) + * Fixed a bug where the CRL parser expected an EXPLICIT ASN.1 tag + before version numbers + * Allowed X509 key usage parsing to accept 4 byte values instead of the + standard 1 byte version sometimes used by Microsoft. (Closes ticket #38) + * Fixed incorrect behaviour in case of RSASSA-PSS with a salt length + smaller than the hash length. (Closes ticket #41) + * If certificate serial is longer than 32 octets, serial number is now + appended with '....' after first 28 octets + * Improved build support for s390x and sparc64 in bignum.h + * Fixed MS Visual C++ name clash with int64 in sha4.h + * Corrected removal of leading "00:" in printing serial numbers in + certificates and CRLs + += Version 1.0.0 released on 2011-07-27 +Features + * Expanded cipher layer with support for CFB128 and CTR mode + * Added rsa_encrypt and rsa_decrypt simple example programs. + +Changes + * The generic cipher and message digest layer now have normal error + codes instead of integers + +Bugfix + * Undid faulty bug fix in ssl_write() when flushing old data (Ticket + #18) + += Version 0.99-pre5 released on 2011-05-26 +Features + * Added additional Cipher Block Modes to symmetric ciphers + (AES CTR, Camellia CTR, XTEA CBC) including the option to + enable and disable individual modes when needed + * Functions requiring File System functions can now be disabled + by undefining POLARSSL_FS_IO + * A error_strerror function() has been added to translate between + error codes and their description. + * Added mpi_get_bit() and mpi_set_bit() individual bit setter/getter + functions. + * Added ssl_mail_client and ssl_fork_server as example programs. + +Changes + * Major argument / variable rewrite. Introduced use of size_t + instead of int for buffer lengths and loop variables for + better unsigned / signed use. Renamed internal bigint types + t_int and t_dbl to t_uint and t_udbl in the process + * mpi_init() and mpi_free() now only accept a single MPI + argument and do not accept variable argument lists anymore. + * The error codes have been remapped and combining error codes + is now done with a PLUS instead of an OR as error codes + used are negative. + * Changed behaviour of net_read(), ssl_fetch_input() and ssl_recv(). + net_recv() now returns 0 on EOF instead of + POLARSSL_ERR_NET_CONN_RESET. ssl_fetch_input() returns + POLARSSL_ERR_SSL_CONN_EOF on an EOF from its f_recv() function. + ssl_read() returns 0 if a POLARSSL_ERR_SSL_CONN_EOF is received + after the handshake. + * Network functions now return POLARSSL_ERR_NET_WANT_READ or + POLARSSL_ERR_NET_WANT_WRITE instead of the ambiguous + POLARSSL_ERR_NET_TRY_AGAIN + += Version 0.99-pre4 released on 2011-04-01 +Features + * Added support for PKCS#1 v2.1 encoding and thus support + for the RSAES-OAEP and RSASSA-PSS operations. + * Reading of Public Key files incorporated into default x509 + functionality as well. + * Added mpi_fill_random() for centralized filling of big numbers + with random data (Fixed ticket #10) + +Changes + * Debug print of MPI now removes leading zero octets and + displays actual bit size of the value. + * x509parse_key() (and as a consequence x509parse_keyfile()) + does not zeroize memory in advance anymore. Use rsa_init() + before parsing a key or keyfile! + +Bugfix + * Debug output of MPI's now the same independent of underlying + platform (32-bit / 64-bit) (Fixes ticket #19, found by Mads + Kiilerich and Mihai Militaru) + * Fixed bug in ssl_write() when flushing old data (Fixed ticket + #18, found by Nikolay Epifanov) + * Fixed proper handling of RSASSA-PSS verification with variable + length salt lengths + += Version 0.99-pre3 released on 2011-02-28 +This release replaces version 0.99-pre2 which had possible copyright issues. +Features + * Parsing PEM private keys encrypted with DES and AES + are now supported as well (Fixes ticket #5) + * Added crl_app program to allow easy reading and + printing of X509 CRLs from file + +Changes + * Parsing of PEM files moved to separate module (Fixes + ticket #13). Also possible to remove PEM support for + systems only using DER encoding + +Bugfixes + * Corrected parsing of UTCTime dates before 1990 and + after 1950 + * Support more exotic OID's when parsing certificates + (found by Mads Kiilerich) + * Support more exotic name representations when parsing + certificates (found by Mads Kiilerich) + * Replaced the expired test certificates + * Do not bail out if no client certificate specified. Try + to negotiate anonymous connection (Fixes ticket #12, + found by Boris Krasnovskiy) + +Security fixes + * Fixed a possible Man-in-the-Middle attack on the + Diffie Hellman key exchange (thanks to Larry Highsmith, + Subreption LLC) + += Version 0.99-pre1 released on 2011-01-30 +Features +Note: Most of these features have been donated by Fox-IT + * Added Doxygen source code documentation parts + * Added reading of DHM context from memory and file + * Improved X509 certificate parsing to include extended + certificate fields, including Key Usage + * Improved certificate verification and verification + against the available CRLs + * Detection for DES weak keys and parity bits added + * Improvements to support integration in other + applications: + + Added generic message digest and cipher wrapper + + Improved information about current capabilities, + status, objects and configuration + + Added verification callback on certificate chain + verification to allow external blacklisting + + Additional example programs to show usage + * Added support for PKCS#11 through the use of the + libpkcs11-helper library + +Changes + * x509parse_time_expired() checks time in addition to + the existing date check + * The ciphers member of ssl_context and the cipher member + of ssl_session have been renamed to ciphersuites and + ciphersuite respectively. This clarifies the difference + with the generic cipher layer and is better naming + altogether + += Version 0.14.0 released on 2010-08-16 +Features + * Added support for SSL_EDH_RSA_AES_128_SHA and + SSL_EDH_RSA_CAMELLIA_128_SHA ciphersuites + * Added compile-time and run-time version information + * Expanded ssl_client2 arguments for more flexibility + * Added support for TLS v1.1 + +Changes + * Made Makefile cleaner + * Removed dependency on rand() in rsa_pkcs1_encrypt(). + Now using random fuction provided to function and + changed the prototype of rsa_pkcs1_encrypt(), + rsa_init() and rsa_gen_key(). + * Some SSL defines were renamed in order to avoid + future confusion + +Bug fixes + * Fixed CMake out of source build for tests (found by + kkert) + * rsa_check_private() now supports PKCS1v2 keys as well + * Fixed deadlock in rsa_pkcs1_encrypt() on failing random + generator + += Version 0.13.1 released on 2010-03-24 +Bug fixes + * Fixed Makefile in library that was mistakenly merged + * Added missing const string fixes + += Version 0.13.0 released on 2010-03-21 +Features + * Added option parsing for host and port selection to + ssl_client2 + * Added support for GeneralizedTime in X509 parsing + * Added cert_app program to allow easy reading and + printing of X509 certificates from file or SSL + connection. + +Changes + * Added const correctness for main code base + * X509 signature algorithm determination is now + in a function to allow easy future expansion + * Changed symmetric cipher functions to + identical interface (returning int result values) + * Changed ARC4 to use separate input/output buffer + * Added reset function for HMAC context as speed-up + for specific use-cases + +Bug fixes + * Fixed bug resulting in failure to send the last + certificate in the chain in ssl_write_certificate() and + ssl_write_certificate_request() (found by fatbob) + * Added small fixes for compiler warnings on a Mac + (found by Frank de Brabander) + * Fixed algorithmic bug in mpi_is_prime() (found by + Smbat Tonoyan) + += Version 0.12.1 released on 2009-10-04 +Changes + * Coverage test definitions now support 'depends_on' + tagging system. + * Tests requiring specific hashing algorithms now honor + the defines. + +Bug fixes + * Changed typo in #ifdef in x509parse.c (found + by Eduardo) + += Version 0.12.0 released on 2009-07-28 +Features + * Added CMake makefiles as alternative to regular Makefiles. + * Added preliminary Code Coverage tests for AES, ARC4, + Base64, MPI, SHA-family, MD-family, HMAC-SHA-family, + Camellia, DES, 3-DES, RSA PKCS#1, XTEA, Diffie-Hellman + and X509parse. + +Changes + * Error codes are not (necessarily) negative. Keep + this is mind when checking for errors. + * RSA_RAW renamed to SIG_RSA_RAW for consistency. + * Fixed typo in name of POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE. + * Changed interface for AES and Camellia setkey functions + to indicate invalid key lengths. + +Bug fixes + * Fixed include location of endian.h on FreeBSD (found by + Gabriel) + * Fixed include location of endian.h and name clash on + Apples (found by Martin van Hensbergen) + * Fixed HMAC-MD2 by modifying md2_starts(), so that the + required HMAC ipad and opad variables are not cleared. + (found by code coverage tests) + * Prevented use of long long in bignum if + POLARSSL_HAVE_LONGLONG not defined (found by Giles + Bathgate). + * Fixed incorrect handling of negative strings in + mpi_read_string() (found by code coverage tests). + * Fixed segfault on handling empty rsa_context in + rsa_check_pubkey() and rsa_check_privkey() (found by + code coverage tests). + * Fixed incorrect handling of one single negative input + value in mpi_add_abs() (found by code coverage tests). + * Fixed incorrect handling of negative first input + value in mpi_sub_abs() (found by code coverage tests). + * Fixed incorrect handling of negative first input + value in mpi_mod_mpi() and mpi_mod_int(). Resulting + change also affects mpi_write_string() (found by code + coverage tests). + * Corrected is_prime() results for 0, 1 and 2 (found by + code coverage tests). + * Fixed Camellia and XTEA for 64-bit Windows systems. + += Version 0.11.1 released on 2009-05-17 + * Fixed missing functionality for SHA-224, SHA-256, SHA384, + SHA-512 in rsa_pkcs1_sign() + += Version 0.11.0 released on 2009-05-03 + * Fixed a bug in mpi_gcd() so that it also works when both + input numbers are even and added testcases to check + (found by Pierre Habouzit). + * Added support for SHA-224, SHA-256, SHA-384 and SHA-512 + one way hash functions with the PKCS#1 v1.5 signing and + verification. + * Fixed minor bug regarding mpi_gcd located within the + POLARSSL_GENPRIME block. + * Fixed minor memory leak in x509parse_crt() and added better + handling of 'full' certificate chains (found by Mathias + Olsson). + * Centralized file opening and reading for x509 files into + load_file() + * Made definition of net_htons() endian-clean for big endian + systems (Found by Gernot). + * Undefining POLARSSL_HAVE_ASM now also handles prevents asm in + padlock and timing code. + * Fixed an off-by-one buffer allocation in ssl_set_hostname() + responsible for crashes and unwanted behaviour. + * Added support for Certificate Revocation List (CRL) parsing. + * Added support for CRL revocation to x509parse_verify() and + SSL/TLS code. + * Fixed compatibility of XTEA and Camellia on a 64-bit system + (found by Felix von Leitner). + += Version 0.10.0 released on 2009-01-12 + * Migrated XySSL to PolarSSL + * Added XTEA symmetric cipher + * Added Camellia symmetric cipher + * Added support for ciphersuites: SSL_RSA_CAMELLIA_128_SHA, + SSL_RSA_CAMELLIA_256_SHA and SSL_EDH_RSA_CAMELLIA_256_SHA + * Fixed dangerous bug that can cause a heap overflow in + rsa_pkcs1_decrypt (found by Christophe Devine) + +================================================================ +XySSL ChangeLog + += Version 0.9 released on 2008-03-16 + + * Added support for ciphersuite: SSL_RSA_AES_128_SHA + * Enabled support for large files by default in aescrypt2.c + * Preliminary openssl wrapper contributed by David Barrett + * Fixed a bug in ssl_write() that caused the same payload to + be sent twice in non-blocking mode when send returns EAGAIN + * Fixed ssl_parse_client_hello(): session id and challenge must + not be swapped in the SSLv2 ClientHello (found by Greg Robson) + * Added user-defined callback debug function (Krystian Kolodziej) + * Before freeing a certificate, properly zero out all cert. data + * Fixed the "mode" parameter so that encryption/decryption are + not swapped on PadLock; also fixed compilation on older versions + of gcc (bug reported by David Barrett) + * Correctly handle the case in padlock_xcryptcbc() when input or + ouput data is non-aligned by falling back to the software + implementation, as VIA Nehemiah cannot handle non-aligned buffers + * Fixed a memory leak in x509parse_crt() which was reported by Greg + Robson-Garth; some x509write.c fixes by Pascal Vizeli, thanks to + Matthew Page who reported several bugs + * Fixed x509_get_ext() to accept some rare certificates which have + an INTEGER instead of a BOOLEAN for BasicConstraints::cA. + * Added support on the client side for the TLS "hostname" extension + (patch contributed by David Patino) + * Make x509parse_verify() return BADCERT_CN_MISMATCH when an empty + string is passed as the CN (bug reported by spoofy) + * Added an option to enable/disable the BN assembly code + * Updated rsa_check_privkey() to verify that (D*E) = 1 % (P-1)*(Q-1) + * Disabled obsolete hash functions by default (MD2, MD4); updated + selftest and benchmark to not test ciphers that have been disabled + * Updated x509parse_cert_info() to correctly display byte 0 of the + serial number, setup correct server port in the ssl client example + * Fixed a critical denial-of-service with X.509 cert. verification: + peer may cause xyssl to loop indefinitely by sending a certificate + for which the RSA signature check fails (bug reported by Benoit) + * Added test vectors for: AES-CBC, AES-CFB, DES-CBC and 3DES-CBC, + HMAC-MD5, HMAC-SHA1, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512 + * Fixed HMAC-SHA-384 and HMAC-SHA-512 (thanks to Josh Sinykin) + * Modified ssl_parse_client_key_exchange() to protect against + Daniel Bleichenbacher attack on PKCS#1 v1.5 padding, as well + as the Klima-Pokorny-Rosa extension of Bleichenbacher's attack + * Updated rsa_gen_key() so that ctx->N is always nbits in size + * Fixed assembly PPC compilation errors on Mac OS X, thanks to + David Barrett and Dusan Semen + += Version 0.8 released on 2007-10-20 + + * Modified the HMAC functions to handle keys larger + than 64 bytes, thanks to Stephane Desneux and gary ng + * Fixed ssl_read_record() to properly update the handshake + message digests, which fixes IE6/IE7 client authentication + * Cleaned up the XYSSL* #defines, suggested by Azriel Fasten + * Fixed net_recv(), thanks to Lorenz Schori and Egon Kocjan + * Added user-defined callbacks for handling I/O and sessions + * Added lots of debugging output in the SSL/TLS functions + * Added preliminary X.509 cert. writing by Pascal Vizeli + * Added preliminary support for the VIA PadLock routines + * Added AES-CFB mode of operation, contributed by chmike + * Added an SSL/TLS stress testing program (ssl_test.c) + * Updated the RSA PKCS#1 code to allow choosing between + RSA_PUBLIC and RSA_PRIVATE, as suggested by David Barrett + * Updated ssl_read() to skip 0-length records from OpenSSL + * Fixed the make install target to comply with *BSD make + * Fixed a bug in mpi_read_binary() on 64-bit platforms + * mpi_is_prime() speedups, thanks to Kevin McLaughlin + * Fixed a long standing memory leak in mpi_is_prime() + * Replaced realloc with malloc in mpi_grow(), and set + the sign of zero as positive in mpi_init() (reported + by Jonathan M. McCune) + += Version 0.7 released on 2007-07-07 + + * Added support for the MicroBlaze soft-core processor + * Fixed a bug in ssl_tls.c which sometimes prevented SSL + connections from being established with non-blocking I/O + * Fixed a couple bugs in the VS6 and UNIX Makefiles + * Fixed the "PIC register ebx clobbered in asm" bug + * Added HMAC starts/update/finish support functions + * Added the SHA-224, SHA-384 and SHA-512 hash functions + * Fixed the net_set_*block routines, thanks to Andreas + * Added a few demonstration programs: md5sum, sha1sum, + dh_client, dh_server, rsa_genkey, rsa_sign, rsa_verify + * Added new bignum import and export helper functions + * Rewrote README.txt in program/ssl/ca to better explain + how to create a test PKI + += Version 0.6 released on 2007-04-01 + + * Ciphers used in SSL/TLS can now be disabled at compile + time, to reduce the memory footprint on embedded systems + * Added multiply assembly code for the TriCore and modified + havege_struct for this processor, thanks to David Patiño + * Added multiply assembly code for 64-bit PowerPCs, + thanks to Peking University and the OSU Open Source Lab + * Added experimental support of Quantum Cryptography + * Added support for autoconf, contributed by Arnaud Cornet + * Fixed "long long" compilation issues on IA-64 and PPC64 + * Fixed a bug introduced in xyssl-0.5/timing.c: hardclock + was not being correctly defined on ARM and MIPS + += Version 0.5 released on 2007-03-01 + + * Added multiply assembly code for SPARC and Alpha + * Added (beta) support for non-blocking I/O operations + * Implemented session resuming and client authentication + * Fixed some portability issues on WinCE, MINIX 3, Plan9 + (thanks to Benjamin Newman), HP-UX, FreeBSD and Solaris + * Improved the performance of the EDH key exchange + * Fixed a bug that caused valid packets with a payload + size of 16384 bytes to be rejected + += Version 0.4 released on 2007-02-01 + + * Added support for Ephemeral Diffie-Hellman key exchange + * Added multiply asm code for SSE2, ARM, PPC, MIPS and M68K + * Various improvement to the modular exponentiation code + * Rewrote the headers to generate the API docs with doxygen + * Fixed a bug in ssl_encrypt_buf (incorrect padding was + generated) and in ssl_parse_client_hello (max. client + version was not properly set), thanks to Didier Rebeix + * Fixed another bug in ssl_parse_client_hello: clients with + cipherlists larger than 96 bytes were incorrectly rejected + * Fixed a couple memory leak in x509_read.c + += Version 0.3 released on 2007-01-01 + + * Added server-side SSLv3 and TLSv1.0 support + * Multiple fixes to enhance the compatibility with g++, + thanks to Xosé Antón Otero Ferreira + * Fixed a bug in the CBC code, thanks to dowst; also, + the bignum code is no longer dependent on long long + * Updated rsa_pkcs1_sign to handle arbitrary large inputs + * Updated timing.c for improved compatibility with i386 + and 486 processors, thanks to Arnaud Cornet + += Version 0.2 released on 2006-12-01 + + * Updated timing.c to support ARM and MIPS arch + * Updated the MPI code to support 8086 on MSVC 1.5 + * Added the copyright notice at the top of havege.h + * Fixed a bug in sha2_hmac, thanks to newsoft/Wenfang Zhang + * Fixed a bug reported by Adrian Rüegsegger in x509_read_key + * Fixed a bug reported by Torsten Lauter in ssl_read_record + * Fixed a bug in rsa_check_privkey that would wrongly cause + valid RSA keys to be dismissed (thanks to oldwolf) + * Fixed a bug in mpi_is_prime that caused some primes to fail + the Miller-Rabin primality test + + I'd also like to thank Younès Hafri for the CRUX linux port, + Khalil Petit who added XySSL into pkgsrc and Arnaud Cornet + who maintains the Debian package :-) + += Version 0.1 released on 2006-11-01 + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/DartConfiguration.tcl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/DartConfiguration.tcl new file mode 100644 index 0000000..dfa0f07 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/DartConfiguration.tcl @@ -0,0 +1,4 @@ +Site: localhost +BuildName: mbed TLS-test +CoverageCommand: /usr/bin/gcov +MemoryCheckCommand: /usr/bin/valgrind diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/LICENSE b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/LICENSE new file mode 100644 index 0000000..546a8e6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/LICENSE @@ -0,0 +1,2 @@ +Unless specifically indicated otherwise in a file, files are licensed +under the Apache 2.0 license, as can be found in: apache-2.0.txt diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/Makefile new file mode 100644 index 0000000..d475868 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/Makefile @@ -0,0 +1,110 @@ + +DESTDIR=/usr/local +PREFIX=mbedtls_ + +.SILENT: + +.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean + +all: programs tests + $(MAKE) post_build + +no_test: programs + +programs: lib + $(MAKE) -C programs + +lib: + $(MAKE) -C library + +tests: lib + $(MAKE) -C tests + +ifndef WINDOWS +install: no_test + mkdir -p $(DESTDIR)/include/mbedtls + cp -r include/mbedtls $(DESTDIR)/include + + mkdir -p $(DESTDIR)/lib + cp -RP library/libmbedtls.* $(DESTDIR)/lib + cp -RP library/libmbedx509.* $(DESTDIR)/lib + cp -RP library/libmbedcrypto.* $(DESTDIR)/lib + + mkdir -p $(DESTDIR)/bin + for p in programs/*/* ; do \ + if [ -x $$p ] && [ ! -d $$p ] ; \ + then \ + f=$(PREFIX)`basename $$p` ; \ + cp $$p $(DESTDIR)/bin/$$f ; \ + fi \ + done + +uninstall: + rm -rf $(DESTDIR)/include/mbedtls + rm -f $(DESTDIR)/lib/libmbedtls.* + rm -f $(DESTDIR)/lib/libmbedx509.* + rm -f $(DESTDIR)/lib/libmbedcrypto.* + + for p in programs/*/* ; do \ + if [ -x $$p ] && [ ! -d $$p ] ; \ + then \ + f=$(PREFIX)`basename $$p` ; \ + rm -f $(DESTDIR)/bin/$$f ; \ + fi \ + done +endif + +WARNING_BORDER =*******************************************************\n +NULL_ENTROPY_WARN_L1=**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! ****\n +NULL_ENTROPY_WARN_L2=**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES ****\n +NULL_ENTROPY_WARN_L3=**** AND IS *NOT* SUITABLE FOR PRODUCTION USE ****\n + +NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER) + +# Post build steps +post_build: +ifndef WINDOWS + # If NULL Entropy is configured, display an appropriate warning + -scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \ + echo '$(NULL_ENTROPY_WARNING)' +endif + +clean: + $(MAKE) -C library clean + $(MAKE) -C programs clean + $(MAKE) -C tests clean +ifndef WINDOWS + find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} + +endif + +check: lib tests + $(MAKE) -C tests check + +test: check + +ifndef WINDOWS +# note: for coverage testing, build with: +# make CFLAGS='--coverage -g3 -O0' +covtest: + $(MAKE) check + programs/test/selftest + tests/compat.sh + tests/ssl-opt.sh + +lcov: + rm -rf Coverage + lcov --capture --initial --directory library -o files.info + lcov --capture --directory library -o tests.info + lcov --add-tracefile files.info --add-tracefile tests.info -o all.info + lcov --remove all.info -o final.info '*.h' + gendesc tests/Descriptions.txt -o descriptions + genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --no-branch-coverage -o Coverage final.info + rm -f files.info tests.info all.info final.info descriptions + +apidoc: + mkdir -p apidoc + doxygen doxygen/mbedtls.doxyfile + +apidoc_clean: + rm -rf apidoc +endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/README.md new file mode 100644 index 0000000..11b4ebf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/README.md @@ -0,0 +1,185 @@ +README for mbed TLS +=================== + +Configuration +------------- + +mbed TLS should build out of the box on most systems. Some platform specific options are available in the fully documented configuration file `include/mbedtls/config.h`, which is also the place where features can be selected. This file can be edited manually, or in a more programmatic way using the Perl script `scripts/config.pl` (use `--help` for usage instructions). + +Compiler options can be set using conventional environment variables such as `CC` and `CFLAGS` when using the Make and CMake build system (see below). + +Compiling +--------- + +There are currently four active build systems used within mbed TLS releases: + +- yotta +- Make +- CMake +- Microsoft Visual Studio (Visual Studio 6 and Visual Studio 2010) + +The main systems used for development are CMake and Make. Those systems are always complete and up-to-date. The others should reflect all changes present in the CMake and Make build system, although features may not be ported there automatically. + +Yotta, as a build system, is slightly different from the other build systems: + +- it provides a minimalistic configuration file by default +- depending on the yotta target, features of mbed OS may be used in examples and tests + +The Make and CMake build systems create three libraries: libmbedcrypto, libmbedx509, and libmbedtls. Note that libmbedtls depends on libmbedx509 and libmbedcrypto, and libmbedx509 depends on libmbedcrypto. As a result, some linkers will expect flags to be in a specific order, for example the GNU linker wants `-lmbedtls -lmbedx509 -lmbedcrypto`. Also, when loading shared libraries using dlopen(), you'll need to load libmbedcrypto first, then libmbedx509, before you can load libmbedtls. + +### Yotta + +[yotta](http://yottabuild.org) is a package manager and build system developed by mbed, and is the build system of mbed OS 16.03. To install it on your platform, please follow the yotta [installation instructions](http://docs.yottabuild.org/#installing). + +Once yotta is installed, you can use it to download the latest version of mbed TLS from the yotta registry with: + + yotta install mbedtls + +and build it with: + + yotta build + +If, on the other hand, you already have a copy of mbed TLS from a source other than the yotta registry, for example from cloning our GitHub repository, or from downloading a tarball of the standalone edition, then you'll first need to generate the yotta module by running: + + yotta/create-module.sh + +This should be executed from the root mbed TLS project directory. This will create the yotta module in the `yotta/module` directory within it. You can then change to that directory and build as usual: + + cd yotta/module + yotta build + +In any case, you'll probably want to set the yotta target before building unless it has already been set globally. For more information on using yotta, please consult the [yotta documentation](http://docs.yottabuild.org/). + +For more details on the yotta/mbed OS edition of mbed TLS, including example programs, please consult the [Readme at the root of the yotta module](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/README.md). + +### Make + +We intentionally only use the minimum of `Make` functionality, as a lot of `Make` features are not supported on all different implementations of Make or on different platforms. As such, the Makefiles sometimes require some manual changes or export statements in order to work for your platform. + +In order to build from the source code using Make, just enter at the command line: + + make + +In order to run the tests, enter: + + make check + +The tests need Perl to be built and run. If you don't have Perl installed, you can skip building the tests with: + + make no_test + +You'll still be able to run a much smaller set of tests with: + + programs/test/selftest + +In order to build for a Windows platform, you should use `WINDOWS_BUILD=1` if the target is Windows but the build environment is Unix-like (for instance when cross-compiling, or compiling from an MSYS shell), and `WINDOWS=1` if the build environment is a Windows shell (for instance using mingw32-make) (in that case some targets will not be available). + +Setting the variable `SHARED` in your environment will build shared libraries in addition to the static libraries. Setting `DEBUG` gives you a debug build. You can override `CFLAGS` and `LDFLAGS` by setting them in your environment or on the make command line; if you do so, essential parts such as `-I` will still be preserved. Warning options may be overridden separately using `WARNING_CFLAGS`. + +Depending on your platform, you might run into some issues. Please check the Makefiles in `library/`, `programs/` and `tests/` for options to manually add or remove for specific platforms. You can also check [the mbed TLS Knowledge Base](https://tls.mbed.org/kb) for articles on your platform or issue. + +In case you find that you need to do something else as well, please let us know what, so we can add it to the [mbed TLS knowledge base](https://tls.mbed.org/kb). + +### CMake + +In order to build the source using CMake, just enter at the command line: + + cmake . + make + +In order to run the tests, enter: + + make test + +The test suites need Perl to be built. If you don't have Perl installed, you'll want to disable the test suites with: + + cmake -DENABLE_TESTING=Off . + +If you disabled the test suites, but kept the programs enabled, you can still run a much smaller set of tests with: + + programs/test/selftest + +To configure CMake for building shared libraries, use: + + cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . + +There are many different build modes available within the CMake buildsystem. Most of them are available for gcc and clang, though some are compiler-specific: + +- Release. This generates the default code without any unnecessary information in the binary files. +- Debug. This generates debug information and disables optimization of the code. +- Coverage. This generates code coverage information in addition to debug information. +- ASan. This instruments the code with AddressSanitizer to check for memory errors. (This includes LeakSanitizer, with recent version of gcc and clang.) (With recent version of clang, this mode also instruments the code with UndefinedSanitizer to check for undefined behaviour.) +- ASanDbg. Same as ASan but slower, with debug information and better stack traces. +- MemSan. This instruments the code with MemorySanitizer to check for uninitialised memory reads. Experimental, needs recent clang on Linux/x86\_64. +- MemSanDbg. Same as MemSan but slower, with debug information, better stack traces and origin tracking. +- Check. This activates the compiler warnings that depend on optimization and treats all warnings as errors. + +Switching build modes in CMake is simple. For debug mode, enter at the command line: + + cmake -D CMAKE_BUILD_TYPE=Debug . + +To list other available CMake options, use: + + cmake -LH + +Note that, with CMake, if you want to change the compiler or its options after you already ran CMake, you need to clear its cache first, e.g. (using GNU find): + + find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} + + CC=gcc CFLAGS='-fstack-protector-strong -Wa,--noexecstack' cmake . + +### Microsoft Visual Studio + +The build files for Microsoft Visual Studio are generated for Visual Studio 2010. + +The solution file `mbedTLS.sln` contains all the basic projects needed to build the library and all the programs. The files in tests are not generated and compiled, as these need a perl environment as well. However, the selftest program in `programs/test/` is still available. + +Example programs +---------------- + +We've included example programs for a lot of different features and uses in `programs/`. Most programs only focus on a single feature or usage scenario, so keep that in mind when copying parts of the code. + +Tests +----- + +mbed TLS includes an elaborate test suite in `tests/` that initially requires Perl to generate the tests files (e.g. `test\_suite\_mpi.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_mpi.function`) and a `data file` (e.g. `suites/test\_suite\_mpi.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function. + +For machines with a Unix shell and OpenSSL (and optionally GnuTLS) installed, additional test scripts are available: + +- `tests/ssl-opt.sh` runs integration tests for various TLS options (renegotiation, resumption, etc.) and tests interoperability of these options with other implementations. +- `tests/compat.sh` tests interoperability of every ciphersuite with other implementations. +- `tests/scripts/test-ref-configs.pl` test builds in various reduced configurations. +- `tests/scripts/key-exchanges.pl` test builds in configurations with a single key exchange enabled +- `tests/scripts/all.sh` runs a combination of the above tests, plus some more, with various build options (such as ASan, full `config.h`, etc). + +Configurations +-------------- + +We provide some non-standard configurations focused on specific use cases in the `configs/` directory. You can read more about those in `configs/README.txt` + +Porting mbed TLS +---------------- + +mbed TLS can be ported to many different architectures, OS's and platforms. Before starting a port, you may find the following knowledge base articles useful: + +- [Porting mbed TLS to a new environment or OS](https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS) +- [What external dependencies does mbed TLS rely on?](https://tls.mbed.org/kb/development/what-external-dependencies-does-mbedtls-rely-on) +- [How do I configure mbed TLS](https://tls.mbed.org/kb/compiling-and-building/how-do-i-configure-mbedtls) + +Contributing +------------ + +We gratefully accept bug reports and contributions from the community. There are some requirements we need to fulfill in order to be able to integrate contributions: + +- All contributions, whether large or small require a Contributor's License Agreement (CLA) to be accepted. This is because source code can possibly fall under copyright law and we need your consent to share in the ownership of the copyright. +- We would ask that contributions conform to [our coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards), and that contributions should be fully tested before submission. +- As with any open source project, contributions will be reviewed by the project team and community and may need some modifications to be accepted. + +To accept the Contributor’s Licence Agreement (CLA), individual contributors can do this by creating an mbed account and [accepting the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/). Alternatively, for contributions from corporations, or those that do not wish to create an mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/). This agreement should be signed and returned to ARM as described in the instructions given. + +### Making a Contribution + +1. [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug. +2. Fork the [mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the "development" branch as a basis. +3. Write a test which shows that the bug was fixed or that the feature works as expected. +4. Send a pull request and bug us until it gets merged and published. Contributions may need some modifications, so work with us to get your change accepted. We will include your name in the ChangeLog :) + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/apache-2.0.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/apache-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/apache-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/circle.yml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/circle.yml new file mode 100644 index 0000000..eaed02a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/circle.yml @@ -0,0 +1,44 @@ +# Purpose: +# - To test and prove that a new commit in the mbed TLS repository builds +# and integrates with mbed-os properly. +# AND +# - To test and prove that the current development head of mbed TLS builds +# and integrates with the current mbed-os master branch. +# +# The script fetches all the prerequisites and builds the mbed TLS 'tls-client' +# example. This script is triggered by every commit and once each night and the +# exact behaviour depends on how it was triggered: +# - If it is a nightly build then it builds the mbed TLS development head with +# mbed-os master. +# - If it was triggered by the commit, then it builds the example with mbed TLS +# at that commit and mbed-os at the commit pointed by mbed-os.lib in the +# example repository. + +test: + override: + - cd ../mbed-os-example-tls/tls-client/ && mbed compile -m K64F -t GCC_ARM -c + +dependencies: + pre: + # Install gcc-arm + - cd .. && wget "https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2" + - cd .. && tar -xvjf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 + - ln -s ../gcc-arm-none-eabi-4_9-2015q3/bin/* ../bin/ + # Install mbed-cli + - cd ../ && git clone https://github.com/ARMmbed/mbed-cli.git + - cd ../mbed-cli && sudo -H pip install -e . + # Get the sample application + - cd ../ && git clone git@github.com:ARMmbed/mbed-os-example-tls.git + # Get mbed-os + - cd ../mbed-os-example-tls/tls-client && mbed deploy + # Update mbed-os to master only if it is a nightly build + - > + if [ -n "${RUN_NIGHTLY_BUILD}" ]; then + cd ../mbed-os-example-tls/tls-client/mbed-os/ && mbed update master; + fi + # Import mbedtls current revision + - ln -s ../../../../../../../mbedtls/ ../mbed-os-example-tls/tls-client/mbed-os/features/mbedtls/importer/TARGET_IGNORE/mbedtls + - cd ../mbed-os-example-tls/tls-client/mbed-os/features/mbedtls/importer/ && make + override: + # Install the missing python packages + - cd ../mbed-os-example-tls/tls-client/mbed-os/ && sudo -H pip install -r requirements.txt diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/README.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/README.txt new file mode 100644 index 0000000..e9867bc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/README.txt @@ -0,0 +1,26 @@ +This directory contains example configuration files. + +The examples are generally focused on a particular usage case (eg, support for +a restricted number of ciphersuites) and aim at minimizing resource usage for +this target. They can be used as a basis for custom configurations. + +These files are complete replacements for the default config.h. To use one of +them, you can pick one of the following methods: + +1. Replace the default file include/mbedtls/config.h with the chosen one. + (Depending on your compiler, you may need to ajust the line with + #include "mbedtls/check_config.h" then.) + +2. Define MBEDTLS_CONFIG_FILE and adjust the include path accordingly. + For example, using make: + + CFLAGS="-I$PWD/configs -DMBEDTLS_CONFIG_FILE=''" make + + Or, using cmake: + + find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} + + CFLAGS="-I$PWD/configs -DMBEDTLS_CONFIG_FILE=''" cmake . + make + +Note that the second method also works if you want to keep your custom +configuration file outside the mbed TLS tree. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-ccm-psk-tls1_2.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-ccm-psk-tls1_2.h new file mode 100644 index 0000000..aee10b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-ccm-psk-tls1_2.h @@ -0,0 +1,85 @@ +/* + * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites + * Distinguishing features: + * - no bignum, no PK, no X509 + * - fully modern and secure (provided the pre-shared keys have high entropy) + * - very low record overhead with CCM-8 + * - optimized for low RAM usage + * + * See README.txt for usage instructions. + */ +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +/* System support */ +//#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ +/* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */ + +/* mbed TLS feature support */ +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +#define MBEDTLS_SSL_PROTO_TLS1_2 + +/* mbed TLS modules */ +#define MBEDTLS_AES_C +#define MBEDTLS_CCM_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_MD_C +#define MBEDTLS_NET_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_SRV_C +#define MBEDTLS_SSL_TLS_C + +/* Save RAM at the expense of ROM */ +#define MBEDTLS_AES_ROM_TABLES + +/* Save some RAM by adjusting to your exact needs */ +#define MBEDTLS_PSK_MAX_LEN 16 /* 128-bits keys are generally enough */ + +/* + * You should adjust this to the exact number of sources you're using: default + * is the "platform_entropy_poll" source, but you may want to add other ones + * Minimum is 2 for the entropy test suite. + */ +#define MBEDTLS_ENTROPY_MAX_SOURCES 2 + +/* + * Use only CCM_8 ciphersuites, and + * save ROM and a few bytes of RAM by specifying our own ciphersuite list + */ +#define MBEDTLS_SSL_CIPHERSUITES \ + MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, \ + MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 + +/* + * Save RAM at the expense of interoperability: do this only if you control + * both ends of the connection! (See comments in "mbedtls/ssl.h".) + * The optimal size here depends on the typical size of records. + */ +#define MBEDTLS_SSL_MAX_CONTENT_LEN 512 + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-mini-tls1_1.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-mini-tls1_1.h new file mode 100644 index 0000000..e22363d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-mini-tls1_1.h @@ -0,0 +1,75 @@ +/* + * Minimal configuration for TLS 1.1 (RFC 4346) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * Minimal configuration for TLS 1.1 (RFC 4346), implementing only the + * required ciphersuite: MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * + * See README.txt for usage instructions. + */ + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +/* System support */ +#define MBEDTLS_HAVE_ASM +#define MBEDTLS_HAVE_TIME + +/* mbed TLS feature support */ +#define MBEDTLS_CIPHER_MODE_CBC +#define MBEDTLS_PKCS1_V15 +#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +#define MBEDTLS_SSL_PROTO_TLS1_1 + +/* mbed TLS modules */ +#define MBEDTLS_AES_C +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_DES_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_MD_C +#define MBEDTLS_MD5_C +#define MBEDTLS_NET_C +#define MBEDTLS_OID_C +#define MBEDTLS_PK_C +#define MBEDTLS_PK_PARSE_C +#define MBEDTLS_RSA_C +#define MBEDTLS_SHA1_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_SRV_C +#define MBEDTLS_SSL_TLS_C +#define MBEDTLS_X509_CRT_PARSE_C +#define MBEDTLS_X509_USE_C + +/* For test certificates */ +#define MBEDTLS_BASE64_C +#define MBEDTLS_CERTS_C +#define MBEDTLS_PEM_PARSE_C + +/* For testing with compat.sh */ +#define MBEDTLS_FS_IO + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-no-entropy.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-no-entropy.h new file mode 100644 index 0000000..95f17d4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-no-entropy.h @@ -0,0 +1,85 @@ +/** + * Minimal configuration of features that do not require an entropy source + * + * Copyright (C) 2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * Minimal configuration of features that do not require an entropy source + * Distinguishing reatures: + * - no entropy module + * - no TLS protocol implementation available due to absence of an entropy + * source + * + * See README.txt for usage instructions. + */ + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +/* System support */ +#define MBEDTLS_HAVE_ASM +#define MBEDTLS_HAVE_TIME + +/* mbed TLS feature support */ +#define MBEDTLS_CIPHER_MODE_CBC +#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define MBEDTLS_ECP_NIST_OPTIM +#define MBEDTLS_ECDSA_DETERMINISTIC +#define MBEDTLS_PK_RSA_ALT_SUPPORT +#define MBEDTLS_PKCS1_V15 +#define MBEDTLS_PKCS1_V21 +#define MBEDTLS_SELF_TEST +#define MBEDTLS_VERSION_FEATURES +#define MBEDTLS_X509_CHECK_KEY_USAGE +#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + +/* mbed TLS modules */ +#define MBEDTLS_AES_C +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BASE64_C +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_CCM_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_ERROR_C +#define MBEDTLS_GCM_C +#define MBEDTLS_HMAC_DRBG_C +#define MBEDTLS_MD_C +#define MBEDTLS_OID_C +#define MBEDTLS_PEM_PARSE_C +#define MBEDTLS_PK_C +#define MBEDTLS_PK_PARSE_C +#define MBEDTLS_PK_WRITE_C +#define MBEDTLS_PLATFORM_C +#define MBEDTLS_RSA_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_SHA512_C +#define MBEDTLS_VERSION_C +#define MBEDTLS_X509_USE_C +#define MBEDTLS_X509_CRT_PARSE_C +#define MBEDTLS_X509_CRL_PARSE_C + +#include "check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-picocoin.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-picocoin.h new file mode 100644 index 0000000..26b24a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-picocoin.h @@ -0,0 +1,71 @@ +/* + * Reduced configuration used by Picocoin. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * Reduced configuration used by Picocoin. + * + * See README.txt for usage instructions. + * + * Distinguishing features: + * - no SSL/TLS; + * - no X.509; + * - ECDSA/PK and some other chosen crypto bits. + */ + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +/* System support */ +#define MBEDTLS_HAVE_ASM +#define MBEDTLS_HAVE_TIME + +/* mbed TLS feature support */ +#define MBEDTLS_CIPHER_MODE_CBC +#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECDSA_DETERMINISTIC +#define MBEDTLS_PK_PARSE_EC_EXTENDED +#define MBEDTLS_ERROR_STRERROR_DUMMY +#define MBEDTLS_FS_IO + +/* mbed TLS modules */ +#define MBEDTLS_AESNI_C +#define MBEDTLS_AES_C +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BASE64_C +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_HMAC_DRBG_C +#define MBEDTLS_MD_C +#define MBEDTLS_OID_C +#define MBEDTLS_PADLOCK_C +#define MBEDTLS_PK_C +#define MBEDTLS_PK_PARSE_C +#define MBEDTLS_PK_WRITE_C +#define MBEDTLS_RIPEMD160_C +#define MBEDTLS_SHA1_C +#define MBEDTLS_SHA256_C + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-suite-b.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-suite-b.h new file mode 100644 index 0000000..3c4804c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-suite-b.h @@ -0,0 +1,114 @@ +/* + * Minimal configuration for TLS NSA Suite B Profile (RFC 6460) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * Minimal configuration for TLS NSA Suite B Profile (RFC 6460) + * + * Distinguishing features: + * - no RSA or classic DH, fully based on ECC + * - optimized for low RAM usage + * + * Possible improvements: + * - if 128-bit security is enough, disable secp384r1 and SHA-512 + * - use embedded certs in DER format and disable PEM_PARSE_C and BASE64_C + * + * See README.txt for usage instructions. + */ + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +/* System support */ +#define MBEDTLS_HAVE_ASM +#define MBEDTLS_HAVE_TIME + +/* mbed TLS feature support */ +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +#define MBEDTLS_SSL_PROTO_TLS1_2 + +/* mbed TLS modules */ +#define MBEDTLS_AES_C +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_ECDH_C +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_GCM_C +#define MBEDTLS_MD_C +#define MBEDTLS_NET_C +#define MBEDTLS_OID_C +#define MBEDTLS_PK_C +#define MBEDTLS_PK_PARSE_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_SHA512_C +#define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_SRV_C +#define MBEDTLS_SSL_TLS_C +#define MBEDTLS_X509_CRT_PARSE_C +#define MBEDTLS_X509_USE_C + +/* For test certificates */ +#define MBEDTLS_BASE64_C +#define MBEDTLS_CERTS_C +#define MBEDTLS_PEM_PARSE_C + +/* Save RAM at the expense of ROM */ +#define MBEDTLS_AES_ROM_TABLES + +/* Save RAM by adjusting to our exact needs */ +#define MBEDTLS_ECP_MAX_BITS 384 +#define MBEDTLS_MPI_MAX_SIZE 48 // 384 bits is 48 bytes + +/* Save RAM at the expense of speed, see ecp.h */ +#define MBEDTLS_ECP_WINDOW_SIZE 2 +#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 + +/* Significant speed benefit at the expense of some ROM */ +#define MBEDTLS_ECP_NIST_OPTIM + +/* + * You should adjust this to the exact number of sources you're using: default + * is the "mbedtls_platform_entropy_poll" source, but you may want to add other ones. + * Minimum is 2 for the entropy test suite. + */ +#define MBEDTLS_ENTROPY_MAX_SOURCES 2 + +/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */ +#define MBEDTLS_SSL_CIPHERSUITES \ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, \ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + +/* + * Save RAM at the expense of interoperability: do this only if you control + * both ends of the connection! (See coments in "mbedtls/ssl.h".) + * The minimum size here depends on the certificate chain used as well as the + * typical size of records. + */ +#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024 + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-thread.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-thread.h new file mode 100644 index 0000000..990fe08 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/configs/config-thread.h @@ -0,0 +1,91 @@ +/* + * Minimal configuration for using TLS as part of Thread + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * Minimal configuration for using TLS a part of Thread + * http://threadgroup.org/ + * + * Distinguishing features: + * - no RSA or classic DH, fully based on ECC + * - no X.509 + * - support for experimental EC J-PAKE key exchange + * + * See README.txt for usage instructions. + */ + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +/* System support */ +#define MBEDTLS_HAVE_ASM + +/* mbed TLS feature support */ +#define MBEDTLS_AES_ROM_TABLES +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_NIST_OPTIM +#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +#define MBEDTLS_SSL_PROTO_TLS1_2 +#define MBEDTLS_SSL_PROTO_DTLS +#define MBEDTLS_SSL_DTLS_ANTI_REPLAY +#define MBEDTLS_SSL_DTLS_HELLO_VERIFY +#define MBEDTLS_SSL_EXPORT_KEYS + +/* mbed TLS modules */ +#define MBEDTLS_AES_C +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_CCM_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_CMAC_C +#define MBEDTLS_ECJPAKE_C +#define MBEDTLS_ECP_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_HMAC_DRBG_C +#define MBEDTLS_MD_C +#define MBEDTLS_OID_C +#define MBEDTLS_PK_C +#define MBEDTLS_PK_PARSE_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_SSL_COOKIE_C +#define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_SRV_C +#define MBEDTLS_SSL_TLS_C + +/* For tests using ssl-opt.sh */ +#define MBEDTLS_NET_C +#define MBEDTLS_TIMING_C + +/* Save RAM at the expense of ROM */ +#define MBEDTLS_AES_ROM_TABLES + +/* Save RAM by adjusting to our exact needs */ +#define MBEDTLS_ECP_MAX_BITS 256 +#define MBEDTLS_MPI_MAX_SIZE 32 // 256 bits is 32 bytes + +/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */ +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_encdec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_encdec.h new file mode 100644 index 0000000..9538ed2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_encdec.h @@ -0,0 +1,69 @@ +/** + * @file + * Encryption/decryption module documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @addtogroup encdec_module Encryption/decryption module + * + * The Encryption/decryption module provides encryption/decryption functions. + * One can differentiate between symmetric and asymmetric algorithms; the + * symmetric ones are mostly used for message confidentiality and the asymmetric + * ones for key exchange and message integrity. + * Some symmetric algorithms provide different block cipher modes, mainly + * Electronic Code Book (ECB) which is used for short (64-bit) messages and + * Cipher Block Chaining (CBC) which provides the structure needed for longer + * messages. In addition the Cipher Feedback Mode (CFB-128) stream cipher mode, + * Counter mode (CTR) and Galois Counter Mode (GCM) are implemented for + * specific algorithms. + * + * All symmetric encryption algorithms are accessible via the generic cipher layer + * (see \c mbedtls_cipher_setup()). + * + * The asymmetric encryptrion algorithms are accessible via the generic public + * key layer (see \c mbedtls_pk_init()). + * + * The following algorithms are provided: + * - Symmetric: + * - AES (see \c mbedtls_aes_crypt_ecb(), \c mbedtls_aes_crypt_cbc(), \c mbedtls_aes_crypt_cfb128() and + * \c mbedtls_aes_crypt_ctr()). + * - ARCFOUR (see \c mbedtls_arc4_crypt()). + * - Blowfish / BF (see \c mbedtls_blowfish_crypt_ecb(), \c mbedtls_blowfish_crypt_cbc(), + * \c mbedtls_blowfish_crypt_cfb64() and \c mbedtls_blowfish_crypt_ctr()) + * - Camellia (see \c mbedtls_camellia_crypt_ecb(), \c mbedtls_camellia_crypt_cbc(), + * \c mbedtls_camellia_crypt_cfb128() and \c mbedtls_camellia_crypt_ctr()). + * - DES/3DES (see \c mbedtls_des_crypt_ecb(), \c mbedtls_des_crypt_cbc(), \c mbedtls_des3_crypt_ecb() + * and \c mbedtls_des3_crypt_cbc()). + * - GCM (AES-GCM and CAMELLIA-GCM) (see \c mbedtls_gcm_init()) + * - XTEA (see \c mbedtls_xtea_crypt_ecb()). + * - Asymmetric: + * - Diffie-Hellman-Merkle (see \c mbedtls_dhm_read_public(), \c mbedtls_dhm_make_public() + * and \c mbedtls_dhm_calc_secret()). + * - RSA (see \c mbedtls_rsa_public() and \c mbedtls_rsa_private()). + * - Elliptic Curves over GF(p) (see \c mbedtls_ecp_point_init()). + * - Elliptic Curve Digital Signature Algorithm (ECDSA) (see \c mbedtls_ecdsa_init()). + * - Elliptic Curve Diffie Hellman (ECDH) (see \c mbedtls_ecdh_init()). + * + * This module provides encryption/decryption which can be used to provide + * secrecy. + * + * It also provides asymmetric key functions which can be used for + * confidentiality, integrity, authentication and non-repudiation. + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_hashing.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_hashing.h new file mode 100644 index 0000000..49f15ea --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_hashing.h @@ -0,0 +1,41 @@ +/** + * @file + * Hashing module documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @addtogroup hashing_module Hashing module + * + * The Message Digest (MD) or Hashing module provides one-way hashing + * functions. Such functions can be used for creating a hash message + * authentication code (HMAC) when sending a message. Such a HMAC can be used + * in combination with a private key for authentication, which is a message + * integrity control. + * + * All hash algorithms can be accessed via the generic MD layer (see + * \c mbedtls_md_setup()) + * + * The following hashing-algorithms are provided: + * - MD2, MD4, MD5 128-bit one-way hash functions by Ron Rivest. + * - SHA-1, SHA-256, SHA-384/512 160-bit or more one-way hash functions by + * NIST and NSA. + * + * This module provides one-way hashing which can be used for authentication. + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_mainpage.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_mainpage.h new file mode 100644 index 0000000..13a64c4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_mainpage.h @@ -0,0 +1,93 @@ +/** + * @file + * Main page documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @mainpage mbed TLS v2.4.2 source code documentation + * + * This documentation describes the internal structure of mbed TLS. It was + * automatically generated from specially formatted comment blocks in + * mbed TLS's source code using Doxygen. (See + * http://www.stack.nl/~dimitri/doxygen/ for more information on Doxygen) + * + * mbed TLS has a simple setup: it provides the ingredients for an SSL/TLS + * implementation. These ingredients are listed as modules in the + * \ref mainpage_modules "Modules section". This "Modules section" introduces + * the high-level module concepts used throughout this documentation.\n + * Some examples of mbed TLS usage can be found in the \ref mainpage_examples + * "Examples section". + * + * @section mainpage_modules Modules + * + * mbed TLS supports SSLv3 up to TLSv1.2 communication by providing the + * following: + * - TCP/IP communication functions: listen, connect, accept, read/write. + * - SSL/TLS communication functions: init, handshake, read/write. + * - X.509 functions: CRT, CRL and key handling + * - Random number generation + * - Hashing + * - Encryption/decryption + * + * Above functions are split up neatly into logical interfaces. These can be + * used separately to provide any of the above functions or to mix-and-match + * into an SSL server/client solution that utilises a X.509 PKI. Examples of + * such implementations are amply provided with the source code. + * + * Note that mbed TLS does not provide a control channel or (multiple) session + * handling without additional work from the developer. + * + * @section mainpage_examples Examples + * + * Example server setup: + * + * \b Prerequisites: + * - X.509 certificate and private key + * - session handling functions + * + * \b Setup: + * - Load your certificate and your private RSA key (X.509 interface) + * - Setup the listening TCP socket (TCP/IP interface) + * - Accept incoming client connection (TCP/IP interface) + * - Initialise as an SSL-server (SSL/TLS interface) + * - Set parameters, e.g. authentication, ciphers, CA-chain, key exchange + * - Set callback functions RNG, IO, session handling + * - Perform an SSL-handshake (SSL/TLS interface) + * - Read/write data (SSL/TLS interface) + * - Close and cleanup (all interfaces) + * + * Example client setup: + * + * \b Prerequisites: + * - X.509 certificate and private key + * - X.509 trusted CA certificates + * + * \b Setup: + * - Load the trusted CA certificates (X.509 interface) + * - Load your certificate and your private RSA key (X.509 interface) + * - Setup a TCP/IP connection (TCP/IP interface) + * - Initialise as an SSL-client (SSL/TLS interface) + * - Set parameters, e.g. authentication mode, ciphers, CA-chain, session + * - Set callback functions RNG, IO + * - Perform an SSL-handshake (SSL/TLS interface) + * - Verify the server certificate (SSL/TLS interface) + * - Write/read data (SSL/TLS interface) + * - Close and cleanup (all interfaces) + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_rng.h new file mode 100644 index 0000000..0159ef3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_rng.h @@ -0,0 +1,43 @@ +/** + * @file + * Random number generator (RNG) module documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @addtogroup rng_module Random number generator (RNG) module + * + * The Random number generator (RNG) module provides random number + * generation, see \c mbedtls_ctr_drbg_random(). + * + * The block-cipher counter-mode based deterministic random + * bit generator (CTR_DBRG) as specified in NIST SP800-90. It needs an external + * source of entropy. For these purposes \c mbedtls_entropy_func() can be used. + * This is an implementation based on a simple entropy accumulator design. + * + * The other number generator that is included is less strong and uses the + * HAVEGE (HArdware Volatile Entropy Gathering and Expansion) software heuristic + * which considered unsafe for primary usage, but provides additional random + * to the entropy pool if enables. + * + * Meaning that there seems to be no practical algorithm that can guess + * the next bit with a probability larger than 1/2 in an output sequence. + * + * This module can be used to generate random numbers. + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_ssltls.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_ssltls.h new file mode 100644 index 0000000..7f104bd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_ssltls.h @@ -0,0 +1,48 @@ +/** + * @file + * SSL/TLS communication module documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @addtogroup ssltls_communication_module SSL/TLS communication module + * + * The SSL/TLS communication module provides the means to create an SSL/TLS + * communication channel. + * + * The basic provisions are: + * - initialise an SSL/TLS context (see \c mbedtls_ssl_init()). + * - perform an SSL/TLS handshake (see \c mbedtls_ssl_handshake()). + * - read/write (see \c mbedtls_ssl_read() and \c mbedtls_ssl_write()). + * - notify a peer that connection is being closed (see \c mbedtls_ssl_close_notify()). + * + * Many aspects of such a channel are set through parameters and callback + * functions: + * - the endpoint role: client or server. + * - the authentication mode. Should verification take place. + * - the Host-to-host communication channel. A TCP/IP module is provided. + * - the random number generator (RNG). + * - the ciphers to use for encryption/decryption. + * - session control functions. + * - X.509 parameters for certificate-handling and key exchange. + * + * This module can be used to create an SSL/TLS server and client and to provide a basic + * framework to setup and communicate through an SSL/TLS communication channel.\n + * Note that you need to provide for several aspects yourself as mentioned above. + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_tcpip.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_tcpip.h new file mode 100644 index 0000000..34d3ca1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_tcpip.h @@ -0,0 +1,43 @@ +/** + * @file + * TCP/IP communication module documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @addtogroup tcpip_communication_module TCP/IP communication module + * + * The TCP/IP communication module provides for a channel of + * communication for the \link ssltls_communication_module SSL/TLS communication + * module\endlink to use. + * In the TCP/IP-model it provides for communication up to the Transport + * (or Host-to-host) layer. + * SSL/TLS resides on top of that, in the Application layer, and makes use of + * its basic provisions: + * - listening on a port (see \c mbedtls_net_bind()). + * - accepting a connection (through \c mbedtls_net_accept()). + * - read/write (through \c mbedtls_net_recv()/\c mbedtls_net_send()). + * - close a connection (through \c mbedtls_net_close()). + * + * This way you have the means to, for example, implement and use an UDP or + * IPSec communication solution as a basis. + * + * This module can be used at server- and clientside to provide a basic + * means of communication over the internet. + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_x509.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_x509.h new file mode 100644 index 0000000..315f0e3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/input/doc_x509.h @@ -0,0 +1,42 @@ +/** + * @file + * X.509 module documentation file. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/** + * @addtogroup x509_module X.509 module + * + * The X.509 module provides X.509 support for reading, writing and verification + * of certificates. + * In summary: + * - X.509 certificate (CRT) reading (see \c mbedtls_x509_crt_parse(), + * \c mbedtls_x509_crt_parse_der(), \c mbedtls_x509_crt_parse_file()). + * - X.509 certificate revocation list (CRL) reading (see + * \c mbedtls_x509_crl_parse(), \c mbedtls_x509_crl_parse_der(), + * and \c mbedtls_x509_crl_parse_file()). + * - X.509 certificate signature verification (see \c + * mbedtls_x509_crt_verify() and \c mbedtls_x509_crt_verify_with_profile(). + * - X.509 certificate writing and certificate request writing (see + * \c mbedtls_x509write_crt_der() and \c mbedtls_x509write_csr_der()). + * + * This module can be used to build a certificate authority (CA) chain and + * verify its signature. It is also used to generate Certificate Signing + * Requests and X.509 certificates just as a CA would do. + */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/mbedtls.doxyfile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/mbedtls.doxyfile new file mode 100644 index 0000000..f4ec089 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/doxygen/mbedtls.doxyfile @@ -0,0 +1,1911 @@ +# Doxyfile 1.8.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed +# in front of the TAG it is preceding . +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "mbed TLS v2.4.2" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = apidoc/ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Latvian, Lithuanian, Norwegian, Macedonian, +# Persian, Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, +# Slovak, Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by by putting a % sign in front of the word +# or globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields or simple typedef fields will be shown +# inline in the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO (the default), structs, classes, and unions are shown on a separate +# page (for HTML and Man pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can +# be an expensive process and often the same symbol appear multiple times in +# the code, doxygen keeps a cache of pre-resolved symbols. If the cache is too +# small doxygen will become slower. If the cache is too large, memory is wasted. +# The cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid +# range is 0..9, the default is 0, corresponding to a cache size of 2^16 = 65536 +# symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if section-label ... \endif +# and \cond section-label ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. Do not use +# file names with spaces, bibtex cannot handle them. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.h + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = configs yotta/module + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = *_internal.h *_wrap.h + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be ignored. +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = . + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# SVG. The default value is HTML-CSS, which is slower, but has the best +# compatibility. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript +# pieces of code that will be used on startup of the MathJax code. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a web server instead of a web client using Javascript. +# There are two flavours of web server based search depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. +# See the manual for details. + +SERVER_BASED_SEARCH = NO + +# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain +# the search results. Doxygen ships with an example indexer (doxyindexer) and +# search engine (doxysearch.cgi) which are based on the open source search +# engine library Xapian. See the manual for configuration details. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will returned the search results when EXTERNAL_SEARCH is enabled. +# Doxygen ships with an example search engine (doxysearch) which is based on +# the open source search engine library Xapian. See the manual for configuration +# details. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id +# of to a relative location where the documentation can be found. +# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... + +EXTRA_SEARCH_MAPPINGS = + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = YES + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4 will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images +# or other source files which should be copied to the LaTeX output directory. +# Note that the files will be copied as-is; there are no commands or markers +# available. + +LATEX_EXTRA_FILES = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +#XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +#XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- + +# If the GENERATE_DOCBOOK tag is set to YES Doxygen will generate DOCBOOK files +# that can be used to generate PDF. + +GENERATE_DOCBOOK = NO + +# The DOCBOOK_OUTPUT tag is used to specify where the DOCBOOK pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in +# front of it. If left blank docbook will be used as the default path. + +DOCBOOK_OUTPUT = docbook + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = WIN32 \ + NTLM \ + USE_LZO \ + ENABLE_FRAGMENT \ + P2MP \ + P2MP_SERVER \ + USE_CRYPTO \ + USE_SSL \ + ENABLE_PLUGIN \ + ENABLE_MANAGEMENT \ + ENABLE_OCC \ + HAVE_GETTIMEOFDAY + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed +# in the related pages index. If set to NO, only the current project's +# pages will be listed. + +EXTERNAL_PAGES = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# manageable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 200 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 1000 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/CMakeLists.txt new file mode 100644 index 0000000..985a353 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/CMakeLists.txt @@ -0,0 +1,11 @@ +option(INSTALL_MBEDTLS_HEADERS "Install mbed TLS headers." ON) + +if(INSTALL_MBEDTLS_HEADERS) + + file(GLOB headers "mbedtls/*.h") + + install(FILES ${headers} + DESTINATION include/mbedtls + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +endif(INSTALL_MBEDTLS_HEADERS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aes.h new file mode 100644 index 0000000..a36e825 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aes.h @@ -0,0 +1,297 @@ +/** + * \file aes.h + * + * \brief AES block cipher + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_AES_H +#define MBEDTLS_AES_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +/* padlock.c and aesni.c rely on these values! */ +#define MBEDTLS_AES_ENCRYPT 1 +#define MBEDTLS_AES_DECRYPT 0 + +#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ +#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ + +#if !defined(MBEDTLS_AES_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief AES context structure + * + * \note buf is able to hold 32 extra bytes, which can be used: + * - for alignment purposes if VIA padlock is used, and/or + * - to simplify key expansion in the 256-bit case by + * generating an extra round key + */ +typedef struct +{ + int nr; /*!< number of rounds */ + uint32_t *rk; /*!< AES round keys */ + uint32_t buf[68]; /*!< unaligned data */ +} +mbedtls_aes_context; + +/** + * \brief Initialize AES context + * + * \param ctx AES context to be initialized + */ +void mbedtls_aes_init( mbedtls_aes_context *ctx ); + +/** + * \brief Clear AES context + * + * \param ctx AES context to be cleared + */ +void mbedtls_aes_free( mbedtls_aes_context *ctx ); + +/** + * \brief AES key schedule (encryption) + * + * \param ctx AES context to be initialized + * \param key encryption key + * \param keybits must be 128, 192 or 256 + * + * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + */ +int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, + unsigned int keybits ); + +/** + * \brief AES key schedule (decryption) + * + * \param ctx AES context to be initialized + * \param key decryption key + * \param keybits must be 128, 192 or 256 + * + * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + */ +int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, + unsigned int keybits ); + +/** + * \brief AES-ECB block encryption/decryption + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param input 16-byte input block + * \param output 16-byte output block + * + * \return 0 if successful + */ +int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief AES-CBC buffer encryption/decryption + * Length should be a multiple of the block + * size (16 bytes) + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH + */ +int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/** + * \brief AES-CFB128 buffer encryption/decryption. + * + * Note: Due to the nature of CFB you should use the same key schedule for + * both encryption and decryption. So a context initialized with + * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT. + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param length length of the input data + * \param iv_off offset in IV (updated after use) + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful + */ +int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); + +/** + * \brief AES-CFB8 buffer encryption/decryption. + * + * Note: Due to the nature of CFB you should use the same key schedule for + * both encryption and decryption. So a context initialized with + * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT. + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful + */ +int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); +#endif /*MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/** + * \brief AES-CTR buffer encryption/decryption + * + * Warning: You have to keep the maximum use of your counter in mind! + * + * Note: Due to the nature of CTR you should use the same key schedule for + * both encryption and decryption. So a context initialized with + * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT. + * + * \param ctx AES context + * \param length The length of the data + * \param nc_off The offset in the current stream_block (for resuming + * within current cipher stream). The offset pointer to + * should be 0 at the start of a stream. + * \param nonce_counter The 128-bit nonce and counter. + * \param stream_block The saved stream-block for resuming. Is overwritten + * by the function. + * \param input The input data stream + * \param output The output data stream + * + * \return 0 if successful + */ +int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[16], + unsigned char stream_block[16], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +/** + * \brief Internal AES block encryption function + * (Only exposed to allow overriding it, + * see MBEDTLS_AES_ENCRYPT_ALT) + * + * \param ctx AES context + * \param input Plaintext block + * \param output Output (ciphertext) block + */ +void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ); + +/** + * \brief Internal AES block decryption function + * (Only exposed to allow overriding it, + * see MBEDTLS_AES_DECRYPT_ALT) + * + * \param ctx AES context + * \param input Ciphertext block + * \param output Output (plaintext) block + */ +void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_AES_ALT */ +#include "aes_alt.h" +#endif /* MBEDTLS_AES_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_aes_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* aes.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aesni.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aesni.h new file mode 100644 index 0000000..b1b7f1c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/aesni.h @@ -0,0 +1,111 @@ +/** + * \file aesni.h + * + * \brief AES-NI for hardware AES acceleration on some Intel processors + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_AESNI_H +#define MBEDTLS_AESNI_H + +#include "aes.h" + +#define MBEDTLS_AESNI_AES 0x02000000u +#define MBEDTLS_AESNI_CLMUL 0x00000002u + +#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \ + ( defined(__amd64__) || defined(__x86_64__) ) && \ + ! defined(MBEDTLS_HAVE_X86_64) +#define MBEDTLS_HAVE_X86_64 +#endif + +#if defined(MBEDTLS_HAVE_X86_64) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief AES-NI features detection routine + * + * \param what The feature to detect + * (MBEDTLS_AESNI_AES or MBEDTLS_AESNI_CLMUL) + * + * \return 1 if CPU has support for the feature, 0 otherwise + */ +int mbedtls_aesni_has_support( unsigned int what ); + +/** + * \brief AES-NI AES-ECB block en(de)cryption + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param input 16-byte input block + * \param output 16-byte output block + * + * \return 0 on success (cannot fail) + */ +int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ); + +/** + * \brief GCM multiplication: c = a * b in GF(2^128) + * + * \param c Result + * \param a First operand + * \param b Second operand + * + * \note Both operands and result are bit strings interpreted as + * elements of GF(2^128) as per the GCM spec. + */ +void mbedtls_aesni_gcm_mult( unsigned char c[16], + const unsigned char a[16], + const unsigned char b[16] ); + +/** + * \brief Compute decryption round keys from encryption round keys + * + * \param invkey Round keys for the equivalent inverse cipher + * \param fwdkey Original round keys (for encryption) + * \param nr Number of rounds (that is, number of round keys minus one) + */ +void mbedtls_aesni_inverse_key( unsigned char *invkey, + const unsigned char *fwdkey, int nr ); + +/** + * \brief Perform key expansion (for encryption) + * + * \param rk Destination buffer where the round keys are written + * \param key Encryption key + * \param bits Key size in bits (must be 128, 192 or 256) + * + * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + */ +int mbedtls_aesni_setkey_enc( unsigned char *rk, + const unsigned char *key, + size_t bits ); + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_HAVE_X86_64 */ + +#endif /* MBEDTLS_AESNI_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/arc4.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/arc4.h new file mode 100644 index 0000000..5fc5395 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/arc4.h @@ -0,0 +1,113 @@ +/** + * \file arc4.h + * + * \brief The ARCFOUR stream cipher + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ARC4_H +#define MBEDTLS_ARC4_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#if !defined(MBEDTLS_ARC4_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief ARC4 context structure + */ +typedef struct +{ + int x; /*!< permutation index */ + int y; /*!< permutation index */ + unsigned char m[256]; /*!< permutation table */ +} +mbedtls_arc4_context; + +/** + * \brief Initialize ARC4 context + * + * \param ctx ARC4 context to be initialized + */ +void mbedtls_arc4_init( mbedtls_arc4_context *ctx ); + +/** + * \brief Clear ARC4 context + * + * \param ctx ARC4 context to be cleared + */ +void mbedtls_arc4_free( mbedtls_arc4_context *ctx ); + +/** + * \brief ARC4 key schedule + * + * \param ctx ARC4 context to be setup + * \param key the secret key + * \param keylen length of the key, in bytes + */ +void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, + unsigned int keylen ); + +/** + * \brief ARC4 cipher function + * + * \param ctx ARC4 context + * \param length length of the input data + * \param input buffer holding the input data + * \param output buffer for the output data + * + * \return 0 if successful + */ +int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, + unsigned char *output ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_ARC4_ALT */ +#include "arc4_alt.h" +#endif /* MBEDTLS_ARC4_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_arc4_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* arc4.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1.h new file mode 100644 index 0000000..082832c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1.h @@ -0,0 +1,342 @@ +/** + * \file asn1.h + * + * \brief Generic ASN.1 parsing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ASN1_H +#define MBEDTLS_ASN1_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#if defined(MBEDTLS_BIGNUM_C) +#include "bignum.h" +#endif + +/** + * \addtogroup asn1_module + * \{ + */ + +/** + * \name ASN1 Error codes + * These error codes are OR'ed to X509 error codes for + * higher error granularity. + * ASN1 is a standard to specify data structures. + * \{ + */ +#define MBEDTLS_ERR_ASN1_OUT_OF_DATA -0x0060 /**< Out of data when parsing an ASN1 data structure. */ +#define MBEDTLS_ERR_ASN1_UNEXPECTED_TAG -0x0062 /**< ASN1 tag was of an unexpected value. */ +#define MBEDTLS_ERR_ASN1_INVALID_LENGTH -0x0064 /**< Error when trying to determine the length or invalid length. */ +#define MBEDTLS_ERR_ASN1_LENGTH_MISMATCH -0x0066 /**< Actual length differs from expected length. */ +#define MBEDTLS_ERR_ASN1_INVALID_DATA -0x0068 /**< Data is invalid. (not used) */ +#define MBEDTLS_ERR_ASN1_ALLOC_FAILED -0x006A /**< Memory allocation failed */ +#define MBEDTLS_ERR_ASN1_BUF_TOO_SMALL -0x006C /**< Buffer too small when writing ASN.1 data structure. */ + +/* \} name */ + +/** + * \name DER constants + * These constants comply with DER encoded the ANS1 type tags. + * DER encoding uses hexadecimal representation. + * An example DER sequence is:\n + * - 0x02 -- tag indicating INTEGER + * - 0x01 -- length in octets + * - 0x05 -- value + * Such sequences are typically read into \c ::mbedtls_x509_buf. + * \{ + */ +#define MBEDTLS_ASN1_BOOLEAN 0x01 +#define MBEDTLS_ASN1_INTEGER 0x02 +#define MBEDTLS_ASN1_BIT_STRING 0x03 +#define MBEDTLS_ASN1_OCTET_STRING 0x04 +#define MBEDTLS_ASN1_NULL 0x05 +#define MBEDTLS_ASN1_OID 0x06 +#define MBEDTLS_ASN1_UTF8_STRING 0x0C +#define MBEDTLS_ASN1_SEQUENCE 0x10 +#define MBEDTLS_ASN1_SET 0x11 +#define MBEDTLS_ASN1_PRINTABLE_STRING 0x13 +#define MBEDTLS_ASN1_T61_STRING 0x14 +#define MBEDTLS_ASN1_IA5_STRING 0x16 +#define MBEDTLS_ASN1_UTC_TIME 0x17 +#define MBEDTLS_ASN1_GENERALIZED_TIME 0x18 +#define MBEDTLS_ASN1_UNIVERSAL_STRING 0x1C +#define MBEDTLS_ASN1_BMP_STRING 0x1E +#define MBEDTLS_ASN1_PRIMITIVE 0x00 +#define MBEDTLS_ASN1_CONSTRUCTED 0x20 +#define MBEDTLS_ASN1_CONTEXT_SPECIFIC 0x80 +/* \} name */ +/* \} addtogroup asn1_module */ + +/** Returns the size of the binary string, without the trailing \\0 */ +#define MBEDTLS_OID_SIZE(x) (sizeof(x) - 1) + +/** + * Compares an mbedtls_asn1_buf structure to a reference OID. + * + * Only works for 'defined' oid_str values (MBEDTLS_OID_HMAC_SHA1), you cannot use a + * 'unsigned char *oid' here! + */ +#define MBEDTLS_OID_CMP(oid_str, oid_buf) \ + ( ( MBEDTLS_OID_SIZE(oid_str) != (oid_buf)->len ) || \ + memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) != 0 ) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Functions to parse ASN.1 data structures + * \{ + */ + +/** + * Type-length-value structure that allows for ASN1 using DER. + */ +typedef struct mbedtls_asn1_buf +{ + int tag; /**< ASN1 type, e.g. MBEDTLS_ASN1_UTF8_STRING. */ + size_t len; /**< ASN1 length, in octets. */ + unsigned char *p; /**< ASN1 data, e.g. in ASCII. */ +} +mbedtls_asn1_buf; + +/** + * Container for ASN1 bit strings. + */ +typedef struct mbedtls_asn1_bitstring +{ + size_t len; /**< ASN1 length, in octets. */ + unsigned char unused_bits; /**< Number of unused bits at the end of the string */ + unsigned char *p; /**< Raw ASN1 data for the bit string */ +} +mbedtls_asn1_bitstring; + +/** + * Container for a sequence of ASN.1 items + */ +typedef struct mbedtls_asn1_sequence +{ + mbedtls_asn1_buf buf; /**< Buffer containing the given ASN.1 item. */ + struct mbedtls_asn1_sequence *next; /**< The next entry in the sequence. */ +} +mbedtls_asn1_sequence; + +/** + * Container for a sequence or list of 'named' ASN.1 data items + */ +typedef struct mbedtls_asn1_named_data +{ + mbedtls_asn1_buf oid; /**< The object identifier. */ + mbedtls_asn1_buf val; /**< The named value. */ + struct mbedtls_asn1_named_data *next; /**< The next entry in the sequence. */ + unsigned char next_merged; /**< Merge next item into the current one? */ +} +mbedtls_asn1_named_data; + +/** + * \brief Get the length of an ASN.1 element. + * Updates the pointer to immediately behind the length. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param len The variable that will receive the value + * + * \return 0 if successful, MBEDTLS_ERR_ASN1_OUT_OF_DATA on reaching + * end of data, MBEDTLS_ERR_ASN1_INVALID_LENGTH if length is + * unparseable. + */ +int mbedtls_asn1_get_len( unsigned char **p, + const unsigned char *end, + size_t *len ); + +/** + * \brief Get the tag and length of the tag. Check for the requested tag. + * Updates the pointer to immediately behind the tag and length. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param len The variable that will receive the length + * \param tag The expected tag + * + * \return 0 if successful, MBEDTLS_ERR_ASN1_UNEXPECTED_TAG if tag did + * not match requested tag, or another specific ASN.1 error code. + */ +int mbedtls_asn1_get_tag( unsigned char **p, + const unsigned char *end, + size_t *len, int tag ); + +/** + * \brief Retrieve a boolean ASN.1 tag and its value. + * Updates the pointer to immediately behind the full tag. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param val The variable that will receive the value + * + * \return 0 if successful or a specific ASN.1 error code. + */ +int mbedtls_asn1_get_bool( unsigned char **p, + const unsigned char *end, + int *val ); + +/** + * \brief Retrieve an integer ASN.1 tag and its value. + * Updates the pointer to immediately behind the full tag. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param val The variable that will receive the value + * + * \return 0 if successful or a specific ASN.1 error code. + */ +int mbedtls_asn1_get_int( unsigned char **p, + const unsigned char *end, + int *val ); + +/** + * \brief Retrieve a bitstring ASN.1 tag and its value. + * Updates the pointer to immediately behind the full tag. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param bs The variable that will receive the value + * + * \return 0 if successful or a specific ASN.1 error code. + */ +int mbedtls_asn1_get_bitstring( unsigned char **p, const unsigned char *end, + mbedtls_asn1_bitstring *bs); + +/** + * \brief Retrieve a bitstring ASN.1 tag without unused bits and its + * value. + * Updates the pointer to the beginning of the bit/octet string. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param len Length of the actual bit/octect string in bytes + * + * \return 0 if successful or a specific ASN.1 error code. + */ +int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end, + size_t *len ); + +/** + * \brief Parses and splits an ASN.1 "SEQUENCE OF " + * Updated the pointer to immediately behind the full sequence tag. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param cur First variable in the chain to fill + * \param tag Type of sequence + * + * \return 0 if successful or a specific ASN.1 error code. + */ +int mbedtls_asn1_get_sequence_of( unsigned char **p, + const unsigned char *end, + mbedtls_asn1_sequence *cur, + int tag); + +#if defined(MBEDTLS_BIGNUM_C) +/** + * \brief Retrieve a MPI value from an integer ASN.1 tag. + * Updates the pointer to immediately behind the full tag. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param X The MPI that will receive the value + * + * \return 0 if successful or a specific ASN.1 or MPI error code. + */ +int mbedtls_asn1_get_mpi( unsigned char **p, + const unsigned char *end, + mbedtls_mpi *X ); +#endif /* MBEDTLS_BIGNUM_C */ + +/** + * \brief Retrieve an AlgorithmIdentifier ASN.1 sequence. + * Updates the pointer to immediately behind the full + * AlgorithmIdentifier. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param alg The buffer to receive the OID + * \param params The buffer to receive the params (if any) + * + * \return 0 if successful or a specific ASN.1 or MPI error code. + */ +int mbedtls_asn1_get_alg( unsigned char **p, + const unsigned char *end, + mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params ); + +/** + * \brief Retrieve an AlgorithmIdentifier ASN.1 sequence with NULL or no + * params. + * Updates the pointer to immediately behind the full + * AlgorithmIdentifier. + * + * \param p The position in the ASN.1 data + * \param end End of data + * \param alg The buffer to receive the OID + * + * \return 0 if successful or a specific ASN.1 or MPI error code. + */ +int mbedtls_asn1_get_alg_null( unsigned char **p, + const unsigned char *end, + mbedtls_asn1_buf *alg ); + +/** + * \brief Find a specific named_data entry in a sequence or list based on + * the OID. + * + * \param list The list to seek through + * \param oid The OID to look for + * \param len Size of the OID + * + * \return NULL if not found, or a pointer to the existing entry. + */ +mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( mbedtls_asn1_named_data *list, + const char *oid, size_t len ); + +/** + * \brief Free a mbedtls_asn1_named_data entry + * + * \param entry The named data entry to free + */ +void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *entry ); + +/** + * \brief Free all entries in a mbedtls_asn1_named_data list + * Head will be set to NULL + * + * \param head Pointer to the head of the list of named data entries to free + */ +void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head ); + +#ifdef __cplusplus +} +#endif + +#endif /* asn1.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1write.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1write.h new file mode 100644 index 0000000..73ff32b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/asn1write.h @@ -0,0 +1,239 @@ +/** + * \file asn1write.h + * + * \brief ASN.1 buffer writing functionality + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ASN1_WRITE_H +#define MBEDTLS_ASN1_WRITE_H + +#include "asn1.h" + +#define MBEDTLS_ASN1_CHK_ADD(g, f) do { if( ( ret = f ) < 0 ) return( ret ); else \ + g += ret; } while( 0 ) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Write a length field in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param len the length to write + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len ); + +/** + * \brief Write a ASN.1 tag in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param tag the tag to write + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, + unsigned char tag ); + +/** + * \brief Write raw buffer data + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param buf data buffer to write + * \param size length of the data buffer + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t size ); + +#if defined(MBEDTLS_BIGNUM_C) +/** + * \brief Write a big number (MBEDTLS_ASN1_INTEGER) in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param X the MPI to write + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X ); +#endif /* MBEDTLS_BIGNUM_C */ + +/** + * \brief Write a NULL tag (MBEDTLS_ASN1_NULL) with zero data in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start ); + +/** + * \brief Write an OID tag (MBEDTLS_ASN1_OID) and data in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param oid the OID to write + * \param oid_len length of the OID + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len ); + +/** + * \brief Write an AlgorithmIdentifier sequence in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param oid the OID of the algorithm + * \param oid_len length of the OID + * \param par_len length of parameters, which must be already written. + * If 0, NULL parameters are added + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len, + size_t par_len ); + +/** + * \brief Write a boolean tag (MBEDTLS_ASN1_BOOLEAN) and value in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param boolean 0 or 1 + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean ); + +/** + * \brief Write an int tag (MBEDTLS_ASN1_INTEGER) and value in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param val the integer value + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ); + +/** + * \brief Write a printable string tag (MBEDTLS_ASN1_PRINTABLE_STRING) and + * value in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param text the text to write + * \param text_len length of the text + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ); + +/** + * \brief Write an IA5 string tag (MBEDTLS_ASN1_IA5_STRING) and + * value in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param text the text to write + * \param text_len length of the text + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ); + +/** + * \brief Write a bitstring tag (MBEDTLS_ASN1_BIT_STRING) and + * value in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param buf the bitstring + * \param bits the total number of bits in the bitstring + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t bits ); + +/** + * \brief Write an octet string tag (MBEDTLS_ASN1_OCTET_STRING) and + * value in ASN.1 format + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param buf data buffer to write + * \param size length of the data buffer + * + * \return the length written or a negative error code + */ +int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t size ); + +/** + * \brief Create or find a specific named_data entry for writing in a + * sequence or list based on the OID. If not already in there, + * a new entry is added to the head of the list. + * Warning: Destructive behaviour for the val data! + * + * \param list Pointer to the location of the head of the list to seek + * through (will be updated in case of a new entry) + * \param oid The OID to look for + * \param oid_len Size of the OID + * \param val Data to store (can be NULL if you want to fill it by hand) + * \param val_len Minimum length of the data buffer needed + * + * \return NULL if if there was a memory allocation error, or a pointer + * to the new / existing entry. + */ +mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data **list, + const char *oid, size_t oid_len, + const unsigned char *val, + size_t val_len ); + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_ASN1_WRITE_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/base64.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/base64.h new file mode 100644 index 0000000..352c652 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/base64.h @@ -0,0 +1,88 @@ +/** + * \file base64.h + * + * \brief RFC 1521 base64 encoding/decoding + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_BASE64_H +#define MBEDTLS_BASE64_H + +#include + +#define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */ +#define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Encode a buffer into base64 format + * + * \param dst destination buffer + * \param dlen size of the destination buffer + * \param olen number of bytes written + * \param src source buffer + * \param slen amount of data to be encoded + * + * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL. + * *olen is always updated to reflect the amount + * of data that has (or would have) been written. + * If that length cannot be represented, then no data is + * written to the buffer and *olen is set to the maximum + * length representable as a size_t. + * + * \note Call this function with dlen = 0 to obtain the + * required buffer size in *olen + */ +int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen ); + +/** + * \brief Decode a base64-formatted buffer + * + * \param dst destination buffer (can be NULL for checking size) + * \param dlen size of the destination buffer + * \param olen number of bytes written + * \param src source buffer + * \param slen amount of data to be decoded + * + * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or + * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is + * not correct. *olen is always updated to reflect the amount + * of data that has (or would have) been written. + * + * \note Call this function with *dst = NULL or dlen = 0 to obtain + * the required buffer size in *olen + */ +int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_base64_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* base64.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bignum.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bignum.h new file mode 100644 index 0000000..aa51556 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bignum.h @@ -0,0 +1,717 @@ +/** + * \file bignum.h + * + * \brief Multi-precision integer library + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_BIGNUM_H +#define MBEDTLS_BIGNUM_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if defined(MBEDTLS_FS_IO) +#include +#endif + +#define MBEDTLS_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An error occurred while reading from or writing to a file. */ +#define MBEDTLS_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_MPI_INVALID_CHARACTER -0x0006 /**< There is an invalid character in the digit string. */ +#define MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< The buffer is too small to write to. */ +#define MBEDTLS_ERR_MPI_NEGATIVE_VALUE -0x000A /**< The input arguments are negative or result in illegal output. */ +#define MBEDTLS_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< The input argument for division is zero, which is not allowed. */ +#define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */ +#define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */ + +#define MBEDTLS_MPI_CHK(f) do { if( ( ret = f ) != 0 ) goto cleanup; } while( 0 ) + +/* + * Maximum size MPIs are allowed to grow to in number of limbs. + */ +#define MBEDTLS_MPI_MAX_LIMBS 10000 + +#if !defined(MBEDTLS_MPI_WINDOW_SIZE) +/* + * Maximum window size used for modular exponentiation. Default: 6 + * Minimum value: 1. Maximum value: 6. + * + * Result is an array of ( 2 << MBEDTLS_MPI_WINDOW_SIZE ) MPIs used + * for the sliding window calculation. (So 64 by default) + * + * Reduction in size, reduces speed. + */ +#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ +#endif /* !MBEDTLS_MPI_WINDOW_SIZE */ + +#if !defined(MBEDTLS_MPI_MAX_SIZE) +/* + * Maximum size of MPIs allowed in bits and bytes for user-MPIs. + * ( Default: 512 bytes => 4096 bits, Maximum tested: 2048 bytes => 16384 bits ) + * + * Note: Calculations can results temporarily in larger MPIs. So the number + * of limbs required (MBEDTLS_MPI_MAX_LIMBS) is higher. + */ +#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ +#endif /* !MBEDTLS_MPI_MAX_SIZE */ + +#define MBEDTLS_MPI_MAX_BITS ( 8 * MBEDTLS_MPI_MAX_SIZE ) /**< Maximum number of bits for usable MPIs. */ + +/* + * When reading from files with mbedtls_mpi_read_file() and writing to files with + * mbedtls_mpi_write_file() the buffer should have space + * for a (short) label, the MPI (in the provided radix), the newline + * characters and the '\0'. + * + * By default we assume at least a 10 char label, a minimum radix of 10 + * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars). + * Autosized at compile time for at least a 10 char label, a minimum radix + * of 10 (decimal) for a number of MBEDTLS_MPI_MAX_BITS size. + * + * This used to be statically sized to 1250 for a maximum of 4096 bit + * numbers (1234 decimal chars). + * + * Calculate using the formula: + * MBEDTLS_MPI_RW_BUFFER_SIZE = ceil(MBEDTLS_MPI_MAX_BITS / ln(10) * ln(2)) + + * LabelSize + 6 + */ +#define MBEDTLS_MPI_MAX_BITS_SCALE100 ( 100 * MBEDTLS_MPI_MAX_BITS ) +#define MBEDTLS_LN_2_DIV_LN_10_SCALE100 332 +#define MBEDTLS_MPI_RW_BUFFER_SIZE ( ((MBEDTLS_MPI_MAX_BITS_SCALE100 + MBEDTLS_LN_2_DIV_LN_10_SCALE100 - 1) / MBEDTLS_LN_2_DIV_LN_10_SCALE100) + 10 + 6 ) + +/* + * Define the base integer type, architecture-wise. + * + * 32-bit integers can be forced on 64-bit arches (eg. for testing purposes) + * by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM + */ +#if ( ! defined(MBEDTLS_HAVE_INT32) && \ + defined(_MSC_VER) && defined(_M_AMD64) ) + #define MBEDTLS_HAVE_INT64 + typedef int64_t mbedtls_mpi_sint; + typedef uint64_t mbedtls_mpi_uint; +#else + #if ( ! defined(MBEDTLS_HAVE_INT32) && \ + defined(__GNUC__) && ( \ + defined(__amd64__) || defined(__x86_64__) || \ + defined(__ppc64__) || defined(__powerpc64__) || \ + defined(__ia64__) || defined(__alpha__) || \ + (defined(__sparc__) && defined(__arch64__)) || \ + defined(__s390x__) || defined(__mips64) ) ) + #define MBEDTLS_HAVE_INT64 + typedef int64_t mbedtls_mpi_sint; + typedef uint64_t mbedtls_mpi_uint; + /* mbedtls_t_udbl defined as 128-bit unsigned int */ + typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI))); + #define MBEDTLS_HAVE_UDBL + #else + #define MBEDTLS_HAVE_INT32 + typedef int32_t mbedtls_mpi_sint; + typedef uint32_t mbedtls_mpi_uint; + typedef uint64_t mbedtls_t_udbl; + #define MBEDTLS_HAVE_UDBL + #endif /* !MBEDTLS_HAVE_INT32 && __GNUC__ && 64-bit platform */ +#endif /* !MBEDTLS_HAVE_INT32 && _MSC_VER && _M_AMD64 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief MPI structure + */ +typedef struct +{ + int s; /*!< integer sign */ + size_t n; /*!< total # of limbs */ + mbedtls_mpi_uint *p; /*!< pointer to limbs */ +} +mbedtls_mpi; + +/** + * \brief Initialize one MPI (make internal references valid) + * This just makes it ready to be set or freed, + * but does not define a value for the MPI. + * + * \param X One MPI to initialize. + */ +void mbedtls_mpi_init( mbedtls_mpi *X ); + +/** + * \brief Unallocate one MPI + * + * \param X One MPI to unallocate. + */ +void mbedtls_mpi_free( mbedtls_mpi *X ); + +/** + * \brief Enlarge to the specified number of limbs + * + * \param X MPI to grow + * \param nblimbs The target number of limbs + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs ); + +/** + * \brief Resize down, keeping at least the specified number of limbs + * + * \param X MPI to shrink + * \param nblimbs The minimum number of limbs to keep + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs ); + +/** + * \brief Copy the contents of Y into X + * + * \param X Destination MPI + * \param Y Source MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ); + +/** + * \brief Swap the contents of X and Y + * + * \param X First MPI value + * \param Y Second MPI value + */ +void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ); + +/** + * \brief Safe conditional assignement X = Y if assign is 1 + * + * \param X MPI to conditionally assign to + * \param Y Value to be assigned + * \param assign 1: perform the assignment, 0: keep X's original value + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * + * \note This function is equivalent to + * if( assign ) mbedtls_mpi_copy( X, Y ); + * except that it avoids leaking any information about whether + * the assignment was done or not (the above code may leak + * information through branch prediction and/or memory access + * patterns analysis). + */ +int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign ); + +/** + * \brief Safe conditional swap X <-> Y if swap is 1 + * + * \param X First mbedtls_mpi value + * \param Y Second mbedtls_mpi value + * \param assign 1: perform the swap, 0: keep X and Y's original values + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * + * \note This function is equivalent to + * if( assign ) mbedtls_mpi_swap( X, Y ); + * except that it avoids leaking any information about whether + * the assignment was done or not (the above code may leak + * information through branch prediction and/or memory access + * patterns analysis). + */ +int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char assign ); + +/** + * \brief Set value from integer + * + * \param X MPI to set + * \param z Value to use + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ); + +/** + * \brief Get a specific bit from X + * + * \param X MPI to use + * \param pos Zero-based index of the bit in X + * + * \return Either a 0 or a 1 + */ +int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos ); + +/** + * \brief Set a bit of X to a specific value of 0 or 1 + * + * \note Will grow X if necessary to set a bit to 1 in a not yet + * existing limb. Will not grow if bit should be set to 0 + * + * \param X MPI to use + * \param pos Zero-based index of the bit in X + * \param val The value to set the bit to (0 or 1) + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1 + */ +int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val ); + +/** + * \brief Return the number of zero-bits before the least significant + * '1' bit + * + * Note: Thus also the zero-based index of the least significant '1' bit + * + * \param X MPI to use + */ +size_t mbedtls_mpi_lsb( const mbedtls_mpi *X ); + +/** + * \brief Return the number of bits up to and including the most + * significant '1' bit' + * + * Note: Thus also the one-based index of the most significant '1' bit + * + * \param X MPI to use + */ +size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X ); + +/** + * \brief Return the total size in bytes + * + * \param X MPI to use + */ +size_t mbedtls_mpi_size( const mbedtls_mpi *X ); + +/** + * \brief Import from an ASCII string + * + * \param X Destination MPI + * \param radix Input numeric base + * \param s Null-terminated string buffer + * + * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code + */ +int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ); + +/** + * \brief Export into an ASCII string + * + * \param X Source MPI + * \param radix Output numeric base + * \param buf Buffer to write the string to + * \param buflen Length of buf + * \param olen Length of the string written, including final NUL byte + * + * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code. + * *olen is always updated to reflect the amount + * of data that has (or would have) been written. + * + * \note Call this function with buflen = 0 to obtain the + * minimum required buffer size in *olen. + */ +int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, + char *buf, size_t buflen, size_t *olen ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Read X from an opened file + * + * \param X Destination MPI + * \param radix Input numeric base + * \param fin Input file handle + * + * \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if + * the file read buffer is too small or a + * MBEDTLS_ERR_MPI_XXX error code + */ +int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ); + +/** + * \brief Write X into an opened file, or stdout if fout is NULL + * + * \param p Prefix, can be NULL + * \param X Source MPI + * \param radix Output numeric base + * \param fout Output file handle (can be NULL) + * + * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code + * + * \note Set fout == NULL to print X on the console. + */ +int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout ); +#endif /* MBEDTLS_FS_IO */ + +/** + * \brief Import X from unsigned binary data, big endian + * + * \param X Destination MPI + * \param buf Input buffer + * \param buflen Input buffer size + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen ); + +/** + * \brief Export X into unsigned binary data, big endian. + * Always fills the whole buffer, which will start with zeros + * if the number is smaller. + * + * \param X Source MPI + * \param buf Output buffer + * \param buflen Output buffer size + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough + */ +int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen ); + +/** + * \brief Left-shift: X <<= count + * + * \param X MPI to shift + * \param count Amount to shift + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count ); + +/** + * \brief Right-shift: X >>= count + * + * \param X MPI to shift + * \param count Amount to shift + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count ); + +/** + * \brief Compare unsigned values + * + * \param X Left-hand MPI + * \param Y Right-hand MPI + * + * \return 1 if |X| is greater than |Y|, + * -1 if |X| is lesser than |Y| or + * 0 if |X| is equal to |Y| + */ +int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y ); + +/** + * \brief Compare signed values + * + * \param X Left-hand MPI + * \param Y Right-hand MPI + * + * \return 1 if X is greater than Y, + * -1 if X is lesser than Y or + * 0 if X is equal to Y + */ +int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y ); + +/** + * \brief Compare signed values + * + * \param X Left-hand MPI + * \param z The integer value to compare to + * + * \return 1 if X is greater than z, + * -1 if X is lesser than z or + * 0 if X is equal to z + */ +int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z ); + +/** + * \brief Unsigned addition: X = |A| + |B| + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Unsigned subtraction: X = |A| - |B| + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if B is greater than A + */ +int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Signed addition: X = A + B + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Signed subtraction: X = A - B + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Signed addition: X = A + b + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param b The integer value to add + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ); + +/** + * \brief Signed subtraction: X = A - b + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param b The integer value to subtract + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ); + +/** + * \brief Baseline multiplication: X = A * B + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Baseline multiplication: X = A * b + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param b The unsigned integer value to multiply with + * + * \note b is unsigned + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b ); + +/** + * \brief Division by mbedtls_mpi: A = Q * B + R + * + * \param Q Destination MPI for the quotient + * \param R Destination MPI for the rest value + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if B == 0 + * + * \note Either Q or R can be NULL. + */ +int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Division by int: A = Q * b + R + * + * \param Q Destination MPI for the quotient + * \param R Destination MPI for the rest value + * \param A Left-hand MPI + * \param b Integer to divide by + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if b == 0 + * + * \note Either Q or R can be NULL. + */ +int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b ); + +/** + * \brief Modulo: R = A mod B + * + * \param R Destination MPI for the rest value + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if B == 0, + * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if B < 0 + */ +int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Modulo: r = A mod b + * + * \param r Destination mbedtls_mpi_uint + * \param A Left-hand MPI + * \param b Integer to divide by + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if b == 0, + * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if b < 0 + */ +int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b ); + +/** + * \brief Sliding-window exponentiation: X = A^E mod N + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param E Exponent MPI + * \param N Modular MPI + * \param _RR Speed-up MPI used for recalculations + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or even or + * if E is negative + * + * \note _RR is used to avoid re-computing R*R mod N across + * multiple calls, which speeds up things a bit. It can + * be set to NULL if the extra performance is unneeded. + */ +int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR ); + +/** + * \brief Fill an MPI X with size bytes of random + * + * \param X Destination MPI + * \param size Size in bytes + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Greatest common divisor: G = gcd(A, B) + * + * \param G Destination MPI + * \param A Left-hand MPI + * \param B Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B ); + +/** + * \brief Modular inverse: X = A^-1 mod N + * + * \param X Destination MPI + * \param A Left-hand MPI + * \param N Right-hand MPI + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or nil + MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N + */ +int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ); + +/** + * \brief Miller-Rabin primality test + * + * \param X MPI to check + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful (probably prime), + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if X is not prime + */ +int mbedtls_mpi_is_prime( const mbedtls_mpi *X, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Prime number generation + * + * \param X Destination MPI + * \param nbits Required size of X in bits + * ( 3 <= nbits <= MBEDTLS_MPI_MAX_BITS ) + * \param dh_flag If 1, then (X-1)/2 will be prime too + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful (probably prime), + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if nbits is < 3 + */ +int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_mpi_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* bignum.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/blowfish.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/blowfish.h new file mode 100644 index 0000000..34626ee --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/blowfish.h @@ -0,0 +1,203 @@ +/** + * \file blowfish.h + * + * \brief Blowfish block cipher + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_BLOWFISH_H +#define MBEDTLS_BLOWFISH_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#define MBEDTLS_BLOWFISH_ENCRYPT 1 +#define MBEDTLS_BLOWFISH_DECRYPT 0 +#define MBEDTLS_BLOWFISH_MAX_KEY_BITS 448 +#define MBEDTLS_BLOWFISH_MIN_KEY_BITS 32 +#define MBEDTLS_BLOWFISH_ROUNDS 16 /**< Rounds to use. When increasing this value, make sure to extend the initialisation vectors */ +#define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */ + +#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016 /**< Invalid key length. */ +#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */ + +#if !defined(MBEDTLS_BLOWFISH_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Blowfish context structure + */ +typedef struct +{ + uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2]; /*!< Blowfish round keys */ + uint32_t S[4][256]; /*!< key dependent S-boxes */ +} +mbedtls_blowfish_context; + +/** + * \brief Initialize Blowfish context + * + * \param ctx Blowfish context to be initialized + */ +void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx ); + +/** + * \brief Clear Blowfish context + * + * \param ctx Blowfish context to be cleared + */ +void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx ); + +/** + * \brief Blowfish key schedule + * + * \param ctx Blowfish context to be initialized + * \param key encryption key + * \param keybits must be between 32 and 448 bits + * + * \return 0 if successful, or MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH + */ +int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key, + unsigned int keybits ); + +/** + * \brief Blowfish-ECB block encryption/decryption + * + * \param ctx Blowfish context + * \param mode MBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT + * \param input 8-byte input block + * \param output 8-byte output block + * + * \return 0 if successful + */ +int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, + int mode, + const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], + unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief Blowfish-CBC buffer encryption/decryption + * Length should be a multiple of the block + * size (8 bytes) + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx Blowfish context + * \param mode MBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful, or + * MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH + */ +int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, + int mode, + size_t length, + unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/** + * \brief Blowfish CFB buffer encryption/decryption. + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx Blowfish context + * \param mode MBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT + * \param length length of the input data + * \param iv_off offset in IV (updated after use) + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful + */ +int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ); +#endif /*MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/** + * \brief Blowfish-CTR buffer encryption/decryption + * + * Warning: You have to keep the maximum use of your counter in mind! + * + * \param ctx Blowfish context + * \param length The length of the data + * \param nc_off The offset in the current stream_block (for resuming + * within current cipher stream). The offset pointer to + * should be 0 at the start of a stream. + * \param nonce_counter The 64-bit nonce and counter. + * \param stream_block The saved stream-block for resuming. Is overwritten + * by the function. + * \param input The input data stream + * \param output The output data stream + * + * \return 0 if successful + */ +int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE], + unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_BLOWFISH_ALT */ +#include "blowfish_alt.h" +#endif /* MBEDTLS_BLOWFISH_ALT */ + +#endif /* blowfish.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bn_mul.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bn_mul.h new file mode 100644 index 0000000..cac3f14 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/bn_mul.h @@ -0,0 +1,885 @@ +/** + * \file bn_mul.h + * + * \brief Multi-precision integer library + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * Multiply source vector [s] with b, add result + * to destination vector [d] and set carry c. + * + * Currently supports: + * + * . IA-32 (386+) . AMD64 / EM64T + * . IA-32 (SSE2) . Motorola 68000 + * . PowerPC, 32-bit . MicroBlaze + * . PowerPC, 64-bit . TriCore + * . SPARC v8 . ARM v3+ + * . Alpha . MIPS32 + * . C, longlong . C, generic + */ +#ifndef MBEDTLS_BN_MUL_H +#define MBEDTLS_BN_MUL_H + +#include "bignum.h" + +#if defined(MBEDTLS_HAVE_ASM) + +#ifndef asm +#define asm __asm +#endif + +/* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ +#if defined(__GNUC__) && \ + ( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 ) +#if defined(__i386__) + +#define MULADDC_INIT \ + asm( \ + "movl %%ebx, %0 \n\t" \ + "movl %5, %%esi \n\t" \ + "movl %6, %%edi \n\t" \ + "movl %7, %%ecx \n\t" \ + "movl %8, %%ebx \n\t" + +#define MULADDC_CORE \ + "lodsl \n\t" \ + "mull %%ebx \n\t" \ + "addl %%ecx, %%eax \n\t" \ + "adcl $0, %%edx \n\t" \ + "addl (%%edi), %%eax \n\t" \ + "adcl $0, %%edx \n\t" \ + "movl %%edx, %%ecx \n\t" \ + "stosl \n\t" + +#if defined(MBEDTLS_HAVE_SSE2) + +#define MULADDC_HUIT \ + "movd %%ecx, %%mm1 \n\t" \ + "movd %%ebx, %%mm0 \n\t" \ + "movd (%%edi), %%mm3 \n\t" \ + "paddq %%mm3, %%mm1 \n\t" \ + "movd (%%esi), %%mm2 \n\t" \ + "pmuludq %%mm0, %%mm2 \n\t" \ + "movd 4(%%esi), %%mm4 \n\t" \ + "pmuludq %%mm0, %%mm4 \n\t" \ + "movd 8(%%esi), %%mm6 \n\t" \ + "pmuludq %%mm0, %%mm6 \n\t" \ + "movd 12(%%esi), %%mm7 \n\t" \ + "pmuludq %%mm0, %%mm7 \n\t" \ + "paddq %%mm2, %%mm1 \n\t" \ + "movd 4(%%edi), %%mm3 \n\t" \ + "paddq %%mm4, %%mm3 \n\t" \ + "movd 8(%%edi), %%mm5 \n\t" \ + "paddq %%mm6, %%mm5 \n\t" \ + "movd 12(%%edi), %%mm4 \n\t" \ + "paddq %%mm4, %%mm7 \n\t" \ + "movd %%mm1, (%%edi) \n\t" \ + "movd 16(%%esi), %%mm2 \n\t" \ + "pmuludq %%mm0, %%mm2 \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "movd 20(%%esi), %%mm4 \n\t" \ + "pmuludq %%mm0, %%mm4 \n\t" \ + "paddq %%mm3, %%mm1 \n\t" \ + "movd 24(%%esi), %%mm6 \n\t" \ + "pmuludq %%mm0, %%mm6 \n\t" \ + "movd %%mm1, 4(%%edi) \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "movd 28(%%esi), %%mm3 \n\t" \ + "pmuludq %%mm0, %%mm3 \n\t" \ + "paddq %%mm5, %%mm1 \n\t" \ + "movd 16(%%edi), %%mm5 \n\t" \ + "paddq %%mm5, %%mm2 \n\t" \ + "movd %%mm1, 8(%%edi) \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "paddq %%mm7, %%mm1 \n\t" \ + "movd 20(%%edi), %%mm5 \n\t" \ + "paddq %%mm5, %%mm4 \n\t" \ + "movd %%mm1, 12(%%edi) \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "paddq %%mm2, %%mm1 \n\t" \ + "movd 24(%%edi), %%mm5 \n\t" \ + "paddq %%mm5, %%mm6 \n\t" \ + "movd %%mm1, 16(%%edi) \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "paddq %%mm4, %%mm1 \n\t" \ + "movd 28(%%edi), %%mm5 \n\t" \ + "paddq %%mm5, %%mm3 \n\t" \ + "movd %%mm1, 20(%%edi) \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "paddq %%mm6, %%mm1 \n\t" \ + "movd %%mm1, 24(%%edi) \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "paddq %%mm3, %%mm1 \n\t" \ + "movd %%mm1, 28(%%edi) \n\t" \ + "addl $32, %%edi \n\t" \ + "addl $32, %%esi \n\t" \ + "psrlq $32, %%mm1 \n\t" \ + "movd %%mm1, %%ecx \n\t" + +#define MULADDC_STOP \ + "emms \n\t" \ + "movl %4, %%ebx \n\t" \ + "movl %%ecx, %1 \n\t" \ + "movl %%edi, %2 \n\t" \ + "movl %%esi, %3 \n\t" \ + : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ + : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ + : "eax", "ecx", "edx", "esi", "edi" \ + ); + +#else + +#define MULADDC_STOP \ + "movl %4, %%ebx \n\t" \ + "movl %%ecx, %1 \n\t" \ + "movl %%edi, %2 \n\t" \ + "movl %%esi, %3 \n\t" \ + : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ + : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ + : "eax", "ecx", "edx", "esi", "edi" \ + ); +#endif /* SSE2 */ +#endif /* i386 */ + +#if defined(__amd64__) || defined (__x86_64__) + +#define MULADDC_INIT \ + asm( \ + "xorq %%r8, %%r8 \n\t" + +#define MULADDC_CORE \ + "movq (%%rsi), %%rax \n\t" \ + "mulq %%rbx \n\t" \ + "addq $8, %%rsi \n\t" \ + "addq %%rcx, %%rax \n\t" \ + "movq %%r8, %%rcx \n\t" \ + "adcq $0, %%rdx \n\t" \ + "nop \n\t" \ + "addq %%rax, (%%rdi) \n\t" \ + "adcq %%rdx, %%rcx \n\t" \ + "addq $8, %%rdi \n\t" + +#define MULADDC_STOP \ + : "+c" (c), "+D" (d), "+S" (s) \ + : "b" (b) \ + : "rax", "rdx", "r8" \ + ); + +#endif /* AMD64 */ + +#if defined(__mc68020__) || defined(__mcpu32__) + +#define MULADDC_INIT \ + asm( \ + "movl %3, %%a2 \n\t" \ + "movl %4, %%a3 \n\t" \ + "movl %5, %%d3 \n\t" \ + "movl %6, %%d2 \n\t" \ + "moveq #0, %%d0 \n\t" + +#define MULADDC_CORE \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d4:%%d1 \n\t" \ + "addl %%d3, %%d1 \n\t" \ + "addxl %%d0, %%d4 \n\t" \ + "moveq #0, %%d3 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "addxl %%d4, %%d3 \n\t" + +#define MULADDC_STOP \ + "movl %%d3, %0 \n\t" \ + "movl %%a3, %1 \n\t" \ + "movl %%a2, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "d0", "d1", "d2", "d3", "d4", "a2", "a3" \ + ); + +#define MULADDC_HUIT \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d4:%%d1 \n\t" \ + "addxl %%d3, %%d1 \n\t" \ + "addxl %%d0, %%d4 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d3:%%d1 \n\t" \ + "addxl %%d4, %%d1 \n\t" \ + "addxl %%d0, %%d3 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d4:%%d1 \n\t" \ + "addxl %%d3, %%d1 \n\t" \ + "addxl %%d0, %%d4 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d3:%%d1 \n\t" \ + "addxl %%d4, %%d1 \n\t" \ + "addxl %%d0, %%d3 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d4:%%d1 \n\t" \ + "addxl %%d3, %%d1 \n\t" \ + "addxl %%d0, %%d4 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d3:%%d1 \n\t" \ + "addxl %%d4, %%d1 \n\t" \ + "addxl %%d0, %%d3 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d4:%%d1 \n\t" \ + "addxl %%d3, %%d1 \n\t" \ + "addxl %%d0, %%d4 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "movel %%a2@+, %%d1 \n\t" \ + "mulul %%d2, %%d3:%%d1 \n\t" \ + "addxl %%d4, %%d1 \n\t" \ + "addxl %%d0, %%d3 \n\t" \ + "addl %%d1, %%a3@+ \n\t" \ + "addxl %%d0, %%d3 \n\t" + +#endif /* MC68000 */ + +#if defined(__powerpc64__) || defined(__ppc64__) + +#if defined(__MACH__) && defined(__APPLE__) + +#define MULADDC_INIT \ + asm( \ + "ld r3, %3 \n\t" \ + "ld r4, %4 \n\t" \ + "ld r5, %5 \n\t" \ + "ld r6, %6 \n\t" \ + "addi r3, r3, -8 \n\t" \ + "addi r4, r4, -8 \n\t" \ + "addic r5, r5, 0 \n\t" + +#define MULADDC_CORE \ + "ldu r7, 8(r3) \n\t" \ + "mulld r8, r7, r6 \n\t" \ + "mulhdu r9, r7, r6 \n\t" \ + "adde r8, r8, r5 \n\t" \ + "ld r7, 8(r4) \n\t" \ + "addze r5, r9 \n\t" \ + "addc r8, r8, r7 \n\t" \ + "stdu r8, 8(r4) \n\t" + +#define MULADDC_STOP \ + "addze r5, r5 \n\t" \ + "addi r4, r4, 8 \n\t" \ + "addi r3, r3, 8 \n\t" \ + "std r5, %0 \n\t" \ + "std r4, %1 \n\t" \ + "std r3, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ + ); + + +#else /* __MACH__ && __APPLE__ */ + +#define MULADDC_INIT \ + asm( \ + "ld %%r3, %3 \n\t" \ + "ld %%r4, %4 \n\t" \ + "ld %%r5, %5 \n\t" \ + "ld %%r6, %6 \n\t" \ + "addi %%r3, %%r3, -8 \n\t" \ + "addi %%r4, %%r4, -8 \n\t" \ + "addic %%r5, %%r5, 0 \n\t" + +#define MULADDC_CORE \ + "ldu %%r7, 8(%%r3) \n\t" \ + "mulld %%r8, %%r7, %%r6 \n\t" \ + "mulhdu %%r9, %%r7, %%r6 \n\t" \ + "adde %%r8, %%r8, %%r5 \n\t" \ + "ld %%r7, 8(%%r4) \n\t" \ + "addze %%r5, %%r9 \n\t" \ + "addc %%r8, %%r8, %%r7 \n\t" \ + "stdu %%r8, 8(%%r4) \n\t" + +#define MULADDC_STOP \ + "addze %%r5, %%r5 \n\t" \ + "addi %%r4, %%r4, 8 \n\t" \ + "addi %%r3, %%r3, 8 \n\t" \ + "std %%r5, %0 \n\t" \ + "std %%r4, %1 \n\t" \ + "std %%r3, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ + ); + +#endif /* __MACH__ && __APPLE__ */ + +#elif defined(__powerpc__) || defined(__ppc__) /* end PPC64/begin PPC32 */ + +#if defined(__MACH__) && defined(__APPLE__) + +#define MULADDC_INIT \ + asm( \ + "lwz r3, %3 \n\t" \ + "lwz r4, %4 \n\t" \ + "lwz r5, %5 \n\t" \ + "lwz r6, %6 \n\t" \ + "addi r3, r3, -4 \n\t" \ + "addi r4, r4, -4 \n\t" \ + "addic r5, r5, 0 \n\t" + +#define MULADDC_CORE \ + "lwzu r7, 4(r3) \n\t" \ + "mullw r8, r7, r6 \n\t" \ + "mulhwu r9, r7, r6 \n\t" \ + "adde r8, r8, r5 \n\t" \ + "lwz r7, 4(r4) \n\t" \ + "addze r5, r9 \n\t" \ + "addc r8, r8, r7 \n\t" \ + "stwu r8, 4(r4) \n\t" + +#define MULADDC_STOP \ + "addze r5, r5 \n\t" \ + "addi r4, r4, 4 \n\t" \ + "addi r3, r3, 4 \n\t" \ + "stw r5, %0 \n\t" \ + "stw r4, %1 \n\t" \ + "stw r3, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ + ); + +#else /* __MACH__ && __APPLE__ */ + +#define MULADDC_INIT \ + asm( \ + "lwz %%r3, %3 \n\t" \ + "lwz %%r4, %4 \n\t" \ + "lwz %%r5, %5 \n\t" \ + "lwz %%r6, %6 \n\t" \ + "addi %%r3, %%r3, -4 \n\t" \ + "addi %%r4, %%r4, -4 \n\t" \ + "addic %%r5, %%r5, 0 \n\t" + +#define MULADDC_CORE \ + "lwzu %%r7, 4(%%r3) \n\t" \ + "mullw %%r8, %%r7, %%r6 \n\t" \ + "mulhwu %%r9, %%r7, %%r6 \n\t" \ + "adde %%r8, %%r8, %%r5 \n\t" \ + "lwz %%r7, 4(%%r4) \n\t" \ + "addze %%r5, %%r9 \n\t" \ + "addc %%r8, %%r8, %%r7 \n\t" \ + "stwu %%r8, 4(%%r4) \n\t" + +#define MULADDC_STOP \ + "addze %%r5, %%r5 \n\t" \ + "addi %%r4, %%r4, 4 \n\t" \ + "addi %%r3, %%r3, 4 \n\t" \ + "stw %%r5, %0 \n\t" \ + "stw %%r4, %1 \n\t" \ + "stw %%r3, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ + ); + +#endif /* __MACH__ && __APPLE__ */ + +#endif /* PPC32 */ + +/* + * The Sparc(64) assembly is reported to be broken. + * Disable it for now, until we're able to fix it. + */ +#if 0 && defined(__sparc__) +#if defined(__sparc64__) + +#define MULADDC_INIT \ + asm( \ + "ldx %3, %%o0 \n\t" \ + "ldx %4, %%o1 \n\t" \ + "ld %5, %%o2 \n\t" \ + "ld %6, %%o3 \n\t" + +#define MULADDC_CORE \ + "ld [%%o0], %%o4 \n\t" \ + "inc 4, %%o0 \n\t" \ + "ld [%%o1], %%o5 \n\t" \ + "umul %%o3, %%o4, %%o4 \n\t" \ + "addcc %%o4, %%o2, %%o4 \n\t" \ + "rd %%y, %%g1 \n\t" \ + "addx %%g1, 0, %%g1 \n\t" \ + "addcc %%o4, %%o5, %%o4 \n\t" \ + "st %%o4, [%%o1] \n\t" \ + "addx %%g1, 0, %%o2 \n\t" \ + "inc 4, %%o1 \n\t" + + #define MULADDC_STOP \ + "st %%o2, %0 \n\t" \ + "stx %%o1, %1 \n\t" \ + "stx %%o0, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "g1", "o0", "o1", "o2", "o3", "o4", \ + "o5" \ + ); + +#else /* __sparc64__ */ + +#define MULADDC_INIT \ + asm( \ + "ld %3, %%o0 \n\t" \ + "ld %4, %%o1 \n\t" \ + "ld %5, %%o2 \n\t" \ + "ld %6, %%o3 \n\t" + +#define MULADDC_CORE \ + "ld [%%o0], %%o4 \n\t" \ + "inc 4, %%o0 \n\t" \ + "ld [%%o1], %%o5 \n\t" \ + "umul %%o3, %%o4, %%o4 \n\t" \ + "addcc %%o4, %%o2, %%o4 \n\t" \ + "rd %%y, %%g1 \n\t" \ + "addx %%g1, 0, %%g1 \n\t" \ + "addcc %%o4, %%o5, %%o4 \n\t" \ + "st %%o4, [%%o1] \n\t" \ + "addx %%g1, 0, %%o2 \n\t" \ + "inc 4, %%o1 \n\t" + +#define MULADDC_STOP \ + "st %%o2, %0 \n\t" \ + "st %%o1, %1 \n\t" \ + "st %%o0, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "g1", "o0", "o1", "o2", "o3", "o4", \ + "o5" \ + ); + +#endif /* __sparc64__ */ +#endif /* __sparc__ */ + +#if defined(__microblaze__) || defined(microblaze) + +#define MULADDC_INIT \ + asm( \ + "lwi r3, %3 \n\t" \ + "lwi r4, %4 \n\t" \ + "lwi r5, %5 \n\t" \ + "lwi r6, %6 \n\t" \ + "andi r7, r6, 0xffff \n\t" \ + "bsrli r6, r6, 16 \n\t" + +#define MULADDC_CORE \ + "lhui r8, r3, 0 \n\t" \ + "addi r3, r3, 2 \n\t" \ + "lhui r9, r3, 0 \n\t" \ + "addi r3, r3, 2 \n\t" \ + "mul r10, r9, r6 \n\t" \ + "mul r11, r8, r7 \n\t" \ + "mul r12, r9, r7 \n\t" \ + "mul r13, r8, r6 \n\t" \ + "bsrli r8, r10, 16 \n\t" \ + "bsrli r9, r11, 16 \n\t" \ + "add r13, r13, r8 \n\t" \ + "add r13, r13, r9 \n\t" \ + "bslli r10, r10, 16 \n\t" \ + "bslli r11, r11, 16 \n\t" \ + "add r12, r12, r10 \n\t" \ + "addc r13, r13, r0 \n\t" \ + "add r12, r12, r11 \n\t" \ + "addc r13, r13, r0 \n\t" \ + "lwi r10, r4, 0 \n\t" \ + "add r12, r12, r10 \n\t" \ + "addc r13, r13, r0 \n\t" \ + "add r12, r12, r5 \n\t" \ + "addc r5, r13, r0 \n\t" \ + "swi r12, r4, 0 \n\t" \ + "addi r4, r4, 4 \n\t" + +#define MULADDC_STOP \ + "swi r5, %0 \n\t" \ + "swi r4, %1 \n\t" \ + "swi r3, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r3", "r4" "r5", "r6", "r7", "r8", \ + "r9", "r10", "r11", "r12", "r13" \ + ); + +#endif /* MicroBlaze */ + +#if defined(__tricore__) + +#define MULADDC_INIT \ + asm( \ + "ld.a %%a2, %3 \n\t" \ + "ld.a %%a3, %4 \n\t" \ + "ld.w %%d4, %5 \n\t" \ + "ld.w %%d1, %6 \n\t" \ + "xor %%d5, %%d5 \n\t" + +#define MULADDC_CORE \ + "ld.w %%d0, [%%a2+] \n\t" \ + "madd.u %%e2, %%e4, %%d0, %%d1 \n\t" \ + "ld.w %%d0, [%%a3] \n\t" \ + "addx %%d2, %%d2, %%d0 \n\t" \ + "addc %%d3, %%d3, 0 \n\t" \ + "mov %%d4, %%d3 \n\t" \ + "st.w [%%a3+], %%d2 \n\t" + +#define MULADDC_STOP \ + "st.w %0, %%d4 \n\t" \ + "st.a %1, %%a3 \n\t" \ + "st.a %2, %%a2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "d0", "d1", "e2", "d4", "a2", "a3" \ + ); + +#endif /* TriCore */ + +/* + * gcc -O0 by default uses r7 for the frame pointer, so it complains about our + * use of r7 below, unless -fomit-frame-pointer is passed. Unfortunately, + * passing that option is not easy when building with yotta. + * + * On the other hand, -fomit-frame-pointer is implied by any -Ox options with + * x !=0, which we can detect using __OPTIMIZE__ (which is also defined by + * clang and armcc5 under the same conditions). + * + * So, only use the optimized assembly below for optimized build, which avoids + * the build error and is pretty reasonable anyway. + */ +#if defined(__GNUC__) && !defined(__OPTIMIZE__) +#define MULADDC_CANNOT_USE_R7 +#endif + +#if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7) + +#if defined(__thumb__) && !defined(__thumb2__) + +#define MULADDC_INIT \ + asm( \ + "ldr r0, %3 \n\t" \ + "ldr r1, %4 \n\t" \ + "ldr r2, %5 \n\t" \ + "ldr r3, %6 \n\t" \ + "lsr r7, r3, #16 \n\t" \ + "mov r9, r7 \n\t" \ + "lsl r7, r3, #16 \n\t" \ + "lsr r7, r7, #16 \n\t" \ + "mov r8, r7 \n\t" + +#define MULADDC_CORE \ + "ldmia r0!, {r6} \n\t" \ + "lsr r7, r6, #16 \n\t" \ + "lsl r6, r6, #16 \n\t" \ + "lsr r6, r6, #16 \n\t" \ + "mov r4, r8 \n\t" \ + "mul r4, r6 \n\t" \ + "mov r3, r9 \n\t" \ + "mul r6, r3 \n\t" \ + "mov r5, r9 \n\t" \ + "mul r5, r7 \n\t" \ + "mov r3, r8 \n\t" \ + "mul r7, r3 \n\t" \ + "lsr r3, r6, #16 \n\t" \ + "add r5, r5, r3 \n\t" \ + "lsr r3, r7, #16 \n\t" \ + "add r5, r5, r3 \n\t" \ + "add r4, r4, r2 \n\t" \ + "mov r2, #0 \n\t" \ + "adc r5, r2 \n\t" \ + "lsl r3, r6, #16 \n\t" \ + "add r4, r4, r3 \n\t" \ + "adc r5, r2 \n\t" \ + "lsl r3, r7, #16 \n\t" \ + "add r4, r4, r3 \n\t" \ + "adc r5, r2 \n\t" \ + "ldr r3, [r1] \n\t" \ + "add r4, r4, r3 \n\t" \ + "adc r2, r5 \n\t" \ + "stmia r1!, {r4} \n\t" + +#define MULADDC_STOP \ + "str r2, %0 \n\t" \ + "str r1, %1 \n\t" \ + "str r0, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r0", "r1", "r2", "r3", "r4", "r5", \ + "r6", "r7", "r8", "r9", "cc" \ + ); + +#else + +#define MULADDC_INIT \ + asm( \ + "ldr r0, %3 \n\t" \ + "ldr r1, %4 \n\t" \ + "ldr r2, %5 \n\t" \ + "ldr r3, %6 \n\t" + +#define MULADDC_CORE \ + "ldr r4, [r0], #4 \n\t" \ + "mov r5, #0 \n\t" \ + "ldr r6, [r1] \n\t" \ + "umlal r2, r5, r3, r4 \n\t" \ + "adds r7, r6, r2 \n\t" \ + "adc r2, r5, #0 \n\t" \ + "str r7, [r1], #4 \n\t" + +#define MULADDC_STOP \ + "str r2, %0 \n\t" \ + "str r1, %1 \n\t" \ + "str r0, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "r0", "r1", "r2", "r3", "r4", "r5", \ + "r6", "r7", "cc" \ + ); + +#endif /* Thumb */ + +#endif /* ARMv3 */ + +#if defined(__alpha__) + +#define MULADDC_INIT \ + asm( \ + "ldq $1, %3 \n\t" \ + "ldq $2, %4 \n\t" \ + "ldq $3, %5 \n\t" \ + "ldq $4, %6 \n\t" + +#define MULADDC_CORE \ + "ldq $6, 0($1) \n\t" \ + "addq $1, 8, $1 \n\t" \ + "mulq $6, $4, $7 \n\t" \ + "umulh $6, $4, $6 \n\t" \ + "addq $7, $3, $7 \n\t" \ + "cmpult $7, $3, $3 \n\t" \ + "ldq $5, 0($2) \n\t" \ + "addq $7, $5, $7 \n\t" \ + "cmpult $7, $5, $5 \n\t" \ + "stq $7, 0($2) \n\t" \ + "addq $2, 8, $2 \n\t" \ + "addq $6, $3, $3 \n\t" \ + "addq $5, $3, $3 \n\t" + +#define MULADDC_STOP \ + "stq $3, %0 \n\t" \ + "stq $2, %1 \n\t" \ + "stq $1, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "$1", "$2", "$3", "$4", "$5", "$6", "$7" \ + ); +#endif /* Alpha */ + +#if defined(__mips__) && !defined(__mips64) + +#define MULADDC_INIT \ + asm( \ + "lw $10, %3 \n\t" \ + "lw $11, %4 \n\t" \ + "lw $12, %5 \n\t" \ + "lw $13, %6 \n\t" + +#define MULADDC_CORE \ + "lw $14, 0($10) \n\t" \ + "multu $13, $14 \n\t" \ + "addi $10, $10, 4 \n\t" \ + "mflo $14 \n\t" \ + "mfhi $9 \n\t" \ + "addu $14, $12, $14 \n\t" \ + "lw $15, 0($11) \n\t" \ + "sltu $12, $14, $12 \n\t" \ + "addu $15, $14, $15 \n\t" \ + "sltu $14, $15, $14 \n\t" \ + "addu $12, $12, $9 \n\t" \ + "sw $15, 0($11) \n\t" \ + "addu $12, $12, $14 \n\t" \ + "addi $11, $11, 4 \n\t" + +#define MULADDC_STOP \ + "sw $12, %0 \n\t" \ + "sw $11, %1 \n\t" \ + "sw $10, %2 \n\t" \ + : "=m" (c), "=m" (d), "=m" (s) \ + : "m" (s), "m" (d), "m" (c), "m" (b) \ + : "$9", "$10", "$11", "$12", "$13", "$14", "$15" \ + ); + +#endif /* MIPS */ +#endif /* GNUC */ + +#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) + +#define MULADDC_INIT \ + __asm mov esi, s \ + __asm mov edi, d \ + __asm mov ecx, c \ + __asm mov ebx, b + +#define MULADDC_CORE \ + __asm lodsd \ + __asm mul ebx \ + __asm add eax, ecx \ + __asm adc edx, 0 \ + __asm add eax, [edi] \ + __asm adc edx, 0 \ + __asm mov ecx, edx \ + __asm stosd + +#if defined(MBEDTLS_HAVE_SSE2) + +#define EMIT __asm _emit + +#define MULADDC_HUIT \ + EMIT 0x0F EMIT 0x6E EMIT 0xC9 \ + EMIT 0x0F EMIT 0x6E EMIT 0xC3 \ + EMIT 0x0F EMIT 0x6E EMIT 0x1F \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ + EMIT 0x0F EMIT 0x6E EMIT 0x16 \ + EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ + EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \ + EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ + EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \ + EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ + EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \ + EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ + EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xDC \ + EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xEE \ + EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \ + EMIT 0x0F EMIT 0xD4 EMIT 0xFC \ + EMIT 0x0F EMIT 0x7E EMIT 0x0F \ + EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \ + EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \ + EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ + EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \ + EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \ + EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCD \ + EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCF \ + EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ + EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCC \ + EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \ + EMIT 0x0F EMIT 0xD4 EMIT 0xDD \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCE \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ + EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \ + EMIT 0x83 EMIT 0xC7 EMIT 0x20 \ + EMIT 0x83 EMIT 0xC6 EMIT 0x20 \ + EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ + EMIT 0x0F EMIT 0x7E EMIT 0xC9 + +#define MULADDC_STOP \ + EMIT 0x0F EMIT 0x77 \ + __asm mov c, ecx \ + __asm mov d, edi \ + __asm mov s, esi \ + +#else + +#define MULADDC_STOP \ + __asm mov c, ecx \ + __asm mov d, edi \ + __asm mov s, esi \ + +#endif /* SSE2 */ +#endif /* MSVC */ + +#endif /* MBEDTLS_HAVE_ASM */ + +#if !defined(MULADDC_CORE) +#if defined(MBEDTLS_HAVE_UDBL) + +#define MULADDC_INIT \ +{ \ + mbedtls_t_udbl r; \ + mbedtls_mpi_uint r0, r1; + +#define MULADDC_CORE \ + r = *(s++) * (mbedtls_t_udbl) b; \ + r0 = (mbedtls_mpi_uint) r; \ + r1 = (mbedtls_mpi_uint)( r >> biL ); \ + r0 += c; r1 += (r0 < c); \ + r0 += *d; r1 += (r0 < *d); \ + c = r1; *(d++) = r0; + +#define MULADDC_STOP \ +} + +#else +#define MULADDC_INIT \ +{ \ + mbedtls_mpi_uint s0, s1, b0, b1; \ + mbedtls_mpi_uint r0, r1, rx, ry; \ + b0 = ( b << biH ) >> biH; \ + b1 = ( b >> biH ); + +#define MULADDC_CORE \ + s0 = ( *s << biH ) >> biH; \ + s1 = ( *s >> biH ); s++; \ + rx = s0 * b1; r0 = s0 * b0; \ + ry = s1 * b0; r1 = s1 * b1; \ + r1 += ( rx >> biH ); \ + r1 += ( ry >> biH ); \ + rx <<= biH; ry <<= biH; \ + r0 += rx; r1 += (r0 < rx); \ + r0 += ry; r1 += (r0 < ry); \ + r0 += c; r1 += (r0 < c); \ + r0 += *d; r1 += (r0 < *d); \ + c = r1; *(d++) = r0; + +#define MULADDC_STOP \ +} + +#endif /* C (generic) */ +#endif /* C (longlong) */ + +#endif /* bn_mul.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/camellia.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/camellia.h new file mode 100644 index 0000000..0424d62 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/camellia.h @@ -0,0 +1,235 @@ +/** + * \file camellia.h + * + * \brief Camellia block cipher + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CAMELLIA_H +#define MBEDTLS_CAMELLIA_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#define MBEDTLS_CAMELLIA_ENCRYPT 1 +#define MBEDTLS_CAMELLIA_DECRYPT 0 + +#define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024 /**< Invalid key length. */ +#define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */ + +#if !defined(MBEDTLS_CAMELLIA_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief CAMELLIA context structure + */ +typedef struct +{ + int nr; /*!< number of rounds */ + uint32_t rk[68]; /*!< CAMELLIA round keys */ +} +mbedtls_camellia_context; + +/** + * \brief Initialize CAMELLIA context + * + * \param ctx CAMELLIA context to be initialized + */ +void mbedtls_camellia_init( mbedtls_camellia_context *ctx ); + +/** + * \brief Clear CAMELLIA context + * + * \param ctx CAMELLIA context to be cleared + */ +void mbedtls_camellia_free( mbedtls_camellia_context *ctx ); + +/** + * \brief CAMELLIA key schedule (encryption) + * + * \param ctx CAMELLIA context to be initialized + * \param key encryption key + * \param keybits must be 128, 192 or 256 + * + * \return 0 if successful, or MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH + */ +int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key, + unsigned int keybits ); + +/** + * \brief CAMELLIA key schedule (decryption) + * + * \param ctx CAMELLIA context to be initialized + * \param key decryption key + * \param keybits must be 128, 192 or 256 + * + * \return 0 if successful, or MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH + */ +int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key, + unsigned int keybits ); + +/** + * \brief CAMELLIA-ECB block encryption/decryption + * + * \param ctx CAMELLIA context + * \param mode MBEDTLS_CAMELLIA_ENCRYPT or MBEDTLS_CAMELLIA_DECRYPT + * \param input 16-byte input block + * \param output 16-byte output block + * + * \return 0 if successful + */ +int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief CAMELLIA-CBC buffer encryption/decryption + * Length should be a multiple of the block + * size (16 bytes) + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx CAMELLIA context + * \param mode MBEDTLS_CAMELLIA_ENCRYPT or MBEDTLS_CAMELLIA_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful, or + * MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH + */ +int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/** + * \brief CAMELLIA-CFB128 buffer encryption/decryption + * + * Note: Due to the nature of CFB you should use the same key schedule for + * both encryption and decryption. So a context initialized with + * mbedtls_camellia_setkey_enc() for both MBEDTLS_CAMELLIA_ENCRYPT and CAMELLIE_DECRYPT. + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx CAMELLIA context + * \param mode MBEDTLS_CAMELLIA_ENCRYPT or MBEDTLS_CAMELLIA_DECRYPT + * \param length length of the input data + * \param iv_off offset in IV (updated after use) + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful, or + * MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH + */ +int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/** + * \brief CAMELLIA-CTR buffer encryption/decryption + * + * Warning: You have to keep the maximum use of your counter in mind! + * + * Note: Due to the nature of CTR you should use the same key schedule for + * both encryption and decryption. So a context initialized with + * mbedtls_camellia_setkey_enc() for both MBEDTLS_CAMELLIA_ENCRYPT and MBEDTLS_CAMELLIA_DECRYPT. + * + * \param ctx CAMELLIA context + * \param length The length of the data + * \param nc_off The offset in the current stream_block (for resuming + * within current cipher stream). The offset pointer to + * should be 0 at the start of a stream. + * \param nonce_counter The 128-bit nonce and counter. + * \param stream_block The saved stream-block for resuming. Is overwritten + * by the function. + * \param input The input data stream + * \param output The output data stream + * + * \return 0 if successful + */ +int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[16], + unsigned char stream_block[16], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_CAMELLIA_ALT */ +#include "camellia_alt.h" +#endif /* MBEDTLS_CAMELLIA_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_camellia_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* camellia.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ccm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ccm.h new file mode 100644 index 0000000..ef75839 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ccm.h @@ -0,0 +1,141 @@ +/** + * \file ccm.h + * + * \brief Counter with CBC-MAC (CCM) for 128-bit block ciphers + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CCM_H +#define MBEDTLS_CCM_H + +#include "cipher.h" + +#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief CCM context structure + */ +typedef struct { + mbedtls_cipher_context_t cipher_ctx; /*!< cipher context used */ +} +mbedtls_ccm_context; + +/** + * \brief Initialize CCM context (just makes references valid) + * Makes the context ready for mbedtls_ccm_setkey() or + * mbedtls_ccm_free(). + * + * \param ctx CCM context to initialize + */ +void mbedtls_ccm_init( mbedtls_ccm_context *ctx ); + +/** + * \brief CCM initialization (encryption and decryption) + * + * \param ctx CCM context to be initialized + * \param cipher cipher to use (a 128-bit block cipher) + * \param key encryption key + * \param keybits key size in bits (must be acceptable by the cipher) + * + * \return 0 if successful, or a cipher specific error code + */ +int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, + mbedtls_cipher_id_t cipher, + const unsigned char *key, + unsigned int keybits ); + +/** + * \brief Free a CCM context and underlying cipher sub-context + * + * \param ctx CCM context to free + */ +void mbedtls_ccm_free( mbedtls_ccm_context *ctx ); + +/** + * \brief CCM buffer encryption + * + * \param ctx CCM context + * \param length length of the input data in bytes + * \param iv nonce (initialization vector) + * \param iv_len length of IV in bytes + * must be 2, 3, 4, 5, 6, 7 or 8 + * \param add additional data + * \param add_len length of additional data in bytes + * must be less than 2^16 - 2^8 + * \param input buffer holding the input data + * \param output buffer for holding the output data + * must be at least 'length' bytes wide + * \param tag buffer for holding the tag + * \param tag_len length of the tag to generate in bytes + * must be 4, 6, 8, 10, 14 or 16 + * + * \note The tag is written to a separate buffer. To get the tag + * concatenated with the output as in the CCM spec, use + * tag = output + length and make sure the output buffer is + * at least length + tag_len wide. + * + * \return 0 if successful + */ +int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + unsigned char *tag, size_t tag_len ); + +/** + * \brief CCM buffer authenticated decryption + * + * \param ctx CCM context + * \param length length of the input data + * \param iv initialization vector + * \param iv_len length of IV + * \param add additional data + * \param add_len length of additional data + * \param input buffer holding the input data + * \param output buffer for holding the output data + * \param tag buffer holding the tag + * \param tag_len length of the tag + * + * \return 0 if successful and authenticated, + * MBEDTLS_ERR_CCM_AUTH_FAILED if tag does not match + */ +int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + const unsigned char *tag, size_t tag_len ); + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_ccm_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CCM_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/certs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/certs.h new file mode 100644 index 0000000..ca49086 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/certs.h @@ -0,0 +1,99 @@ +/** + * \file certs.h + * + * \brief Sample certificates and DHM parameters for testing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CERTS_H +#define MBEDTLS_CERTS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) +/* Concatenation of all CA certificates in PEM format if available */ +extern const char mbedtls_test_cas_pem[]; +extern const size_t mbedtls_test_cas_pem_len; +#endif + +/* List of all CA certificates, terminated by NULL */ +extern const char * mbedtls_test_cas[]; +extern const size_t mbedtls_test_cas_len[]; + +/* + * Convenience for users who just want a certificate: + * RSA by default, or ECDSA if RSA is not available + */ +extern const char * mbedtls_test_ca_crt; +extern const size_t mbedtls_test_ca_crt_len; +extern const char * mbedtls_test_ca_key; +extern const size_t mbedtls_test_ca_key_len; +extern const char * mbedtls_test_ca_pwd; +extern const size_t mbedtls_test_ca_pwd_len; +extern const char * mbedtls_test_srv_crt; +extern const size_t mbedtls_test_srv_crt_len; +extern const char * mbedtls_test_srv_key; +extern const size_t mbedtls_test_srv_key_len; +extern const char * mbedtls_test_cli_crt; +extern const size_t mbedtls_test_cli_crt_len; +extern const char * mbedtls_test_cli_key; +extern const size_t mbedtls_test_cli_key_len; + +#if defined(MBEDTLS_ECDSA_C) +extern const char mbedtls_test_ca_crt_ec[]; +extern const size_t mbedtls_test_ca_crt_ec_len; +extern const char mbedtls_test_ca_key_ec[]; +extern const size_t mbedtls_test_ca_key_ec_len; +extern const char mbedtls_test_ca_pwd_ec[]; +extern const size_t mbedtls_test_ca_pwd_ec_len; +extern const char mbedtls_test_srv_crt_ec[]; +extern const size_t mbedtls_test_srv_crt_ec_len; +extern const char mbedtls_test_srv_key_ec[]; +extern const size_t mbedtls_test_srv_key_ec_len; +extern const char mbedtls_test_cli_crt_ec[]; +extern const size_t mbedtls_test_cli_crt_ec_len; +extern const char mbedtls_test_cli_key_ec[]; +extern const size_t mbedtls_test_cli_key_ec_len; +#endif + +#if defined(MBEDTLS_RSA_C) +extern const char mbedtls_test_ca_crt_rsa[]; +extern const size_t mbedtls_test_ca_crt_rsa_len; +extern const char mbedtls_test_ca_key_rsa[]; +extern const size_t mbedtls_test_ca_key_rsa_len; +extern const char mbedtls_test_ca_pwd_rsa[]; +extern const size_t mbedtls_test_ca_pwd_rsa_len; +extern const char mbedtls_test_srv_crt_rsa[]; +extern const size_t mbedtls_test_srv_crt_rsa_len; +extern const char mbedtls_test_srv_key_rsa[]; +extern const size_t mbedtls_test_srv_key_rsa_len; +extern const char mbedtls_test_cli_crt_rsa[]; +extern const size_t mbedtls_test_cli_crt_rsa_len; +extern const char mbedtls_test_cli_key_rsa[]; +extern const size_t mbedtls_test_cli_key_rsa_len; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* certs.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/check_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/check_config.h new file mode 100644 index 0000000..fe86c1e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/check_config.h @@ -0,0 +1,628 @@ +/** + * \file check_config.h + * + * \brief Consistency checks for configuration options + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * It is recommended to include this file from your config.h + * in order to catch dependency issues early. + */ + +#ifndef MBEDTLS_CHECK_CONFIG_H +#define MBEDTLS_CHECK_CONFIG_H + +/* + * We assume CHAR_BIT is 8 in many places. In practice, this is true on our + * target platforms, so not an issue, but let's just be extra sure. + */ +#include +#if CHAR_BIT != 8 +#error "mbed TLS requires a platform with 8-bit chars" +#endif + +#if defined(_WIN32) +#if !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_C is required on Windows" +#endif + +/* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as + * it would confuse config.pl. */ +#if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \ + !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) +#define MBEDTLS_PLATFORM_SNPRINTF_ALT +#endif +#endif /* _WIN32 */ + +#if defined(TARGET_LIKE_MBED) && \ + ( defined(MBEDTLS_NET_C) || defined(MBEDTLS_TIMING_C) ) +#error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS" +#endif + +#if defined(MBEDTLS_DEPRECATED_WARNING) && \ + !defined(__GNUC__) && !defined(__clang__) +#error "MBEDTLS_DEPRECATED_WARNING only works with GCC and Clang" +#endif + +#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME) +#error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense" +#endif + +#if defined(MBEDTLS_AESNI_C) && !defined(MBEDTLS_HAVE_ASM) +#error "MBEDTLS_AESNI_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C) +#error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_DHM_C) && !defined(MBEDTLS_BIGNUM_C) +#error "MBEDTLS_DHM_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_CMAC_C) && \ + !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C) +#error "MBEDTLS_CMAC_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C) +#error "MBEDTLS_ECDH_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECDSA_C) && \ + ( !defined(MBEDTLS_ECP_C) || \ + !defined(MBEDTLS_ASN1_PARSE_C) || \ + !defined(MBEDTLS_ASN1_WRITE_C) ) +#error "MBEDTLS_ECDSA_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECJPAKE_C) && \ + ( !defined(MBEDTLS_ECP_C) || !defined(MBEDTLS_MD_C) ) +#error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C) +#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \ + !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) ) +#error "MBEDTLS_ECP_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \ + !defined(MBEDTLS_SHA256_C)) +#error "MBEDTLS_ENTROPY_C defined, but not all prerequisites" +#endif +#if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \ + defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64) +#error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" +#endif +#if defined(MBEDTLS_ENTROPY_C) && \ + ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \ + && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32) +#error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" +#endif +#if defined(MBEDTLS_ENTROPY_C) && \ + defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C) +#error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ + ( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) ) +#error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites" +#endif +#if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ + ( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \ + defined(MBEDTLS_HAVEGE_C) ) +#error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too" +#endif + +#if defined(MBEDTLS_GCM_C) && ( \ + !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) ) +#error "MBEDTLS_GCM_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C) +#error "MBEDTLS_HAVEGE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C) +#error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \ + ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) +#error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) +#error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C) +#error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \ + !defined(MBEDTLS_ECDH_C) +#error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) +#error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) +#error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ + ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDSA_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) ) +#error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ + ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ + !defined(MBEDTLS_PKCS1_V15) ) +#error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ + !defined(MBEDTLS_PKCS1_V15) ) +#error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \ + ( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) ) +#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ + ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) +#error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM) +#error "MBEDTLS_PADLOCK_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C) +#error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C) +#error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PK_C) && \ + ( !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) ) +#error "MBEDTLS_PK_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C) +#error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C) +#error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PKCS11_C) && !defined(MBEDTLS_PK_C) +#error "MBEDTLS_PKCS11_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\ + defined(MBEDTLS_PLATFORM_EXIT_ALT) ) +#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\ + ( !defined(MBEDTLS_PLATFORM_C) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ + ( !defined(MBEDTLS_PLATFORM_C) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ + ( !defined(MBEDTLS_PLATFORM_C) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ + defined(MBEDTLS_PLATFORM_TIME_ALT) ) +#error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ + defined(MBEDTLS_PLATFORM_TIME_ALT) ) +#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\ + defined(MBEDTLS_PLATFORM_FPRINTF_ALT) ) +#error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ + ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) +#error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ + defined(MBEDTLS_PLATFORM_STD_FREE) +#error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO) +#error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is" +#endif + +#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ + ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) +#error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ + defined(MBEDTLS_PLATFORM_STD_CALLOC) +#error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO) +#error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is" +#endif + +#if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\ + defined(MBEDTLS_PLATFORM_PRINTF_ALT) ) +#error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) +#error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\ + defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) ) +#error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\ + !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) +#error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) +#error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) +#error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY) +#error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\ + !defined(MBEDTLS_PLATFORM_EXIT_ALT) +#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\ + ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\ + !defined(MBEDTLS_PLATFORM_FPRINTF_ALT) +#error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\ + !defined(MBEDTLS_PLATFORM_PRINTF_ALT) +#error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\ + !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) +#error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ENTROPY_NV_SEED) &&\ + ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) ) +#error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\ + !defined(MBEDTLS_ENTROPY_NV_SEED) +#error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\ + !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) +#error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\ + !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) +#error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\ + defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) +#error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\ + defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) +#error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ + !defined(MBEDTLS_OID_C) ) +#error "MBEDTLS_RSA_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \ + !defined(MBEDTLS_PKCS1_V15) ) +#error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled" +#endif + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \ + ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) ) +#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_PROTO_SSL3) && ( !defined(MBEDTLS_MD5_C) || \ + !defined(MBEDTLS_SHA1_C) ) +#error "MBEDTLS_SSL_PROTO_SSL3 defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1) && ( !defined(MBEDTLS_MD5_C) || \ + !defined(MBEDTLS_SHA1_C) ) +#error "MBEDTLS_SSL_PROTO_TLS1 defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) && ( !defined(MBEDTLS_MD5_C) || \ + !defined(MBEDTLS_SHA1_C) ) +#error "MBEDTLS_SSL_PROTO_TLS1_1 defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && ( !defined(MBEDTLS_SHA1_C) && \ + !defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA512_C) ) +#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_2) +#error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C) +#error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \ + !defined(MBEDTLS_MD_C) ) +#error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C) +#error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_TLS_C) && (!defined(MBEDTLS_SSL_PROTO_SSL3) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1) && !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_2)) +#error "MBEDTLS_SSL_TLS_C defined, but no protocols are active" +#endif + +#if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) && !defined(MBEDTLS_SSL_PROTO_TLS1)) +#error "Illegal protocol selection" +#endif + +#if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_TLS1) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_SSL_PROTO_TLS1_1)) +#error "Illegal protocol selection" +#endif + +#if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) && (!defined(MBEDTLS_SSL_PROTO_TLS1) || \ + !defined(MBEDTLS_SSL_PROTO_TLS1_1))) +#error "Illegal protocol selection" +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS) +#error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \ + !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) +#error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \ + ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) +#error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \ + ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) +#error "MBEDTLS_SSL_DTLS_BADMAC_LIMIT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_2) +#error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequsites" +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ + !defined(MBEDTLS_SSL_PROTO_TLS1_2) +#error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequsites" +#endif + +#if defined(MBEDTLS_SSL_TICKET_C) && !defined(MBEDTLS_CIPHER_C) +#error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) && \ + !defined(MBEDTLS_SSL_PROTO_SSL3) && !defined(MBEDTLS_SSL_PROTO_TLS1) +#error "MBEDTLS_SSL_CBC_RECORD_SPLITTING defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \ + !defined(MBEDTLS_X509_CRT_PARSE_C) +#error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_THREADING_PTHREAD) +#if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) +#error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites" +#endif +#define MBEDTLS_THREADING_IMPL +#endif + +#if defined(MBEDTLS_THREADING_ALT) +#if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) +#error "MBEDTLS_THREADING_ALT defined, but not all prerequisites" +#endif +#define MBEDTLS_THREADING_IMPL +#endif + +#if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL) +#error "MBEDTLS_THREADING_C defined, single threading implementation required" +#endif +#undef MBEDTLS_THREADING_IMPL + +#if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C) +#error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ + !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \ + !defined(MBEDTLS_PK_PARSE_C) ) +#error "MBEDTLS_X509_USE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ + !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \ + !defined(MBEDTLS_PK_WRITE_C) ) +#error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) +#error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) +#error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) +#error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) +#error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) +#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites" +#endif + +/* + * Avoid warning from -pedantic. This is a convenient place for this + * workaround since this is included by every single file before the + * #if defined(MBEDTLS_xxx_C) that results in emtpy translation units. + */ +typedef int mbedtls_iso_c_forbids_empty_translation_units; + +#endif /* MBEDTLS_CHECK_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher.h new file mode 100644 index 0000000..b12e388 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher.h @@ -0,0 +1,709 @@ +/** + * \file cipher.h + * + * \brief Generic cipher wrapper. + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_CIPHER_H +#define MBEDTLS_CIPHER_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) +#define MBEDTLS_CIPHER_MODE_AEAD +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#define MBEDTLS_CIPHER_MODE_WITH_PADDING +#endif + +#if defined(MBEDTLS_ARC4_C) +#define MBEDTLS_CIPHER_MODE_STREAM +#endif + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +#define MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */ +#define MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA -0x6100 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_CIPHER_ALLOC_FAILED -0x6180 /**< Failed to allocate memory. */ +#define MBEDTLS_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */ +#define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */ +#define MBEDTLS_ERR_CIPHER_AUTH_FAILED -0x6300 /**< Authentication failed (for AEAD modes). */ +#define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT -0x6380 /**< The context is invalid, eg because it was free()ed. */ + +#define MBEDTLS_CIPHER_VARIABLE_IV_LEN 0x01 /**< Cipher accepts IVs of variable length */ +#define MBEDTLS_CIPHER_VARIABLE_KEY_LEN 0x02 /**< Cipher accepts keys of variable length */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + MBEDTLS_CIPHER_ID_NONE = 0, + MBEDTLS_CIPHER_ID_NULL, + MBEDTLS_CIPHER_ID_AES, + MBEDTLS_CIPHER_ID_DES, + MBEDTLS_CIPHER_ID_3DES, + MBEDTLS_CIPHER_ID_CAMELLIA, + MBEDTLS_CIPHER_ID_BLOWFISH, + MBEDTLS_CIPHER_ID_ARC4, +} mbedtls_cipher_id_t; + +typedef enum { + MBEDTLS_CIPHER_NONE = 0, + MBEDTLS_CIPHER_NULL, + MBEDTLS_CIPHER_AES_128_ECB, + MBEDTLS_CIPHER_AES_192_ECB, + MBEDTLS_CIPHER_AES_256_ECB, + MBEDTLS_CIPHER_AES_128_CBC, + MBEDTLS_CIPHER_AES_192_CBC, + MBEDTLS_CIPHER_AES_256_CBC, + MBEDTLS_CIPHER_AES_128_CFB128, + MBEDTLS_CIPHER_AES_192_CFB128, + MBEDTLS_CIPHER_AES_256_CFB128, + MBEDTLS_CIPHER_AES_128_CTR, + MBEDTLS_CIPHER_AES_192_CTR, + MBEDTLS_CIPHER_AES_256_CTR, + MBEDTLS_CIPHER_AES_128_GCM, + MBEDTLS_CIPHER_AES_192_GCM, + MBEDTLS_CIPHER_AES_256_GCM, + MBEDTLS_CIPHER_CAMELLIA_128_ECB, + MBEDTLS_CIPHER_CAMELLIA_192_ECB, + MBEDTLS_CIPHER_CAMELLIA_256_ECB, + MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_CIPHER_CAMELLIA_192_CBC, + MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_CIPHER_CAMELLIA_128_CFB128, + MBEDTLS_CIPHER_CAMELLIA_192_CFB128, + MBEDTLS_CIPHER_CAMELLIA_256_CFB128, + MBEDTLS_CIPHER_CAMELLIA_128_CTR, + MBEDTLS_CIPHER_CAMELLIA_192_CTR, + MBEDTLS_CIPHER_CAMELLIA_256_CTR, + MBEDTLS_CIPHER_CAMELLIA_128_GCM, + MBEDTLS_CIPHER_CAMELLIA_192_GCM, + MBEDTLS_CIPHER_CAMELLIA_256_GCM, + MBEDTLS_CIPHER_DES_ECB, + MBEDTLS_CIPHER_DES_CBC, + MBEDTLS_CIPHER_DES_EDE_ECB, + MBEDTLS_CIPHER_DES_EDE_CBC, + MBEDTLS_CIPHER_DES_EDE3_ECB, + MBEDTLS_CIPHER_DES_EDE3_CBC, + MBEDTLS_CIPHER_BLOWFISH_ECB, + MBEDTLS_CIPHER_BLOWFISH_CBC, + MBEDTLS_CIPHER_BLOWFISH_CFB64, + MBEDTLS_CIPHER_BLOWFISH_CTR, + MBEDTLS_CIPHER_ARC4_128, + MBEDTLS_CIPHER_AES_128_CCM, + MBEDTLS_CIPHER_AES_192_CCM, + MBEDTLS_CIPHER_AES_256_CCM, + MBEDTLS_CIPHER_CAMELLIA_128_CCM, + MBEDTLS_CIPHER_CAMELLIA_192_CCM, + MBEDTLS_CIPHER_CAMELLIA_256_CCM, +} mbedtls_cipher_type_t; + +typedef enum { + MBEDTLS_MODE_NONE = 0, + MBEDTLS_MODE_ECB, + MBEDTLS_MODE_CBC, + MBEDTLS_MODE_CFB, + MBEDTLS_MODE_OFB, /* Unused! */ + MBEDTLS_MODE_CTR, + MBEDTLS_MODE_GCM, + MBEDTLS_MODE_STREAM, + MBEDTLS_MODE_CCM, +} mbedtls_cipher_mode_t; + +typedef enum { + MBEDTLS_PADDING_PKCS7 = 0, /**< PKCS7 padding (default) */ + MBEDTLS_PADDING_ONE_AND_ZEROS, /**< ISO/IEC 7816-4 padding */ + MBEDTLS_PADDING_ZEROS_AND_LEN, /**< ANSI X.923 padding */ + MBEDTLS_PADDING_ZEROS, /**< zero padding (not reversible!) */ + MBEDTLS_PADDING_NONE, /**< never pad (full blocks only) */ +} mbedtls_cipher_padding_t; + +typedef enum { + MBEDTLS_OPERATION_NONE = -1, + MBEDTLS_DECRYPT = 0, + MBEDTLS_ENCRYPT, +} mbedtls_operation_t; + +enum { + /** Undefined key length */ + MBEDTLS_KEY_LENGTH_NONE = 0, + /** Key length, in bits (including parity), for DES keys */ + MBEDTLS_KEY_LENGTH_DES = 64, + /** Key length, in bits (including parity), for DES in two key EDE */ + MBEDTLS_KEY_LENGTH_DES_EDE = 128, + /** Key length, in bits (including parity), for DES in three-key EDE */ + MBEDTLS_KEY_LENGTH_DES_EDE3 = 192, +}; + +/** Maximum length of any IV, in bytes */ +#define MBEDTLS_MAX_IV_LENGTH 16 +/** Maximum block size of any cipher, in bytes */ +#define MBEDTLS_MAX_BLOCK_LENGTH 16 + +/** + * Base cipher information (opaque struct). + */ +typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t; + +/** + * CMAC context (opaque struct). + */ +typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t; + +/** + * Cipher information. Allows cipher functions to be called in a generic way. + */ +typedef struct { + /** Full cipher identifier (e.g. MBEDTLS_CIPHER_AES_256_CBC) */ + mbedtls_cipher_type_t type; + + /** Cipher mode (e.g. MBEDTLS_MODE_CBC) */ + mbedtls_cipher_mode_t mode; + + /** Cipher key length, in bits (default length for variable sized ciphers) + * (Includes parity bits for ciphers like DES) */ + unsigned int key_bitlen; + + /** Name of the cipher */ + const char * name; + + /** IV/NONCE size, in bytes. + * For cipher that accept many sizes: recommended size */ + unsigned int iv_size; + + /** Flags for variable IV size, variable key size, etc. */ + int flags; + + /** block size, in bytes */ + unsigned int block_size; + + /** Base cipher information and functions */ + const mbedtls_cipher_base_t *base; + +} mbedtls_cipher_info_t; + +/** + * Generic cipher context. + */ +typedef struct { + /** Information about the associated cipher */ + const mbedtls_cipher_info_t *cipher_info; + + /** Key length to use */ + int key_bitlen; + + /** Operation that the context's key has been initialised for */ + mbedtls_operation_t operation; + +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) + /** Padding functions to use, if relevant for cipher mode */ + void (*add_padding)( unsigned char *output, size_t olen, size_t data_len ); + int (*get_padding)( unsigned char *input, size_t ilen, size_t *data_len ); +#endif + + /** Buffer for data that hasn't been encrypted yet */ + unsigned char unprocessed_data[MBEDTLS_MAX_BLOCK_LENGTH]; + + /** Number of bytes that still need processing */ + size_t unprocessed_len; + + /** Current IV or NONCE_COUNTER for CTR-mode */ + unsigned char iv[MBEDTLS_MAX_IV_LENGTH]; + + /** IV size in bytes (for ciphers with variable-length IVs) */ + size_t iv_size; + + /** Cipher-specific context */ + void *cipher_ctx; + +#if defined(MBEDTLS_CMAC_C) + /** CMAC Specific context */ + mbedtls_cmac_context_t *cmac_ctx; +#endif +} mbedtls_cipher_context_t; + +/** + * \brief Returns the list of ciphers supported by the generic cipher module. + * + * \return a statically allocated array of ciphers, the last entry + * is 0. + */ +const int *mbedtls_cipher_list( void ); + +/** + * \brief Returns the cipher information structure associated + * with the given cipher name. + * + * \param cipher_name Name of the cipher to search for. + * + * \return the cipher information structure associated with the + * given cipher_name, or NULL if not found. + */ +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name ); + +/** + * \brief Returns the cipher information structure associated + * with the given cipher type. + * + * \param cipher_type Type of the cipher to search for. + * + * \return the cipher information structure associated with the + * given cipher_type, or NULL if not found. + */ +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type ); + +/** + * \brief Returns the cipher information structure associated + * with the given cipher id, key size and mode. + * + * \param cipher_id Id of the cipher to search for + * (e.g. MBEDTLS_CIPHER_ID_AES) + * \param key_bitlen Length of the key in bits + * \param mode Cipher mode (e.g. MBEDTLS_MODE_CBC) + * + * \return the cipher information structure associated with the + * given cipher_type, or NULL if not found. + */ +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id, + int key_bitlen, + const mbedtls_cipher_mode_t mode ); + +/** + * \brief Initialize a cipher_context (as NONE) + */ +void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ); + +/** + * \brief Free and clear the cipher-specific context of ctx. + * Freeing ctx itself remains the responsibility of the + * caller. + */ +void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ); + +/** + * \brief Initialises and fills the cipher context structure with + * the appropriate values. + * + * \note Currently also clears structure. In future versions you + * will be required to call mbedtls_cipher_init() on the structure + * first. + * + * \param ctx context to initialise. May not be NULL. + * \param cipher_info cipher to use. + * + * \return 0 on success, + * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter failure, + * MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the + * cipher-specific context failed. + */ +int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ); + +/** + * \brief Returns the block size of the given cipher. + * + * \param ctx cipher's context. Must have been initialised. + * + * \return size of the cipher's blocks, or 0 if ctx has not been + * initialised. + */ +static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return 0; + + return ctx->cipher_info->block_size; +} + +/** + * \brief Returns the mode of operation for the cipher. + * (e.g. MBEDTLS_MODE_CBC) + * + * \param ctx cipher's context. Must have been initialised. + * + * \return mode of operation, or MBEDTLS_MODE_NONE if ctx + * has not been initialised. + */ +static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return MBEDTLS_MODE_NONE; + + return ctx->cipher_info->mode; +} + +/** + * \brief Returns the size of the cipher's IV/NONCE in bytes. + * + * \param ctx cipher's context. Must have been initialised. + * + * \return If IV has not been set yet: (recommended) IV size + * (0 for ciphers not using IV/NONCE). + * If IV has already been set: actual size. + */ +static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return 0; + + if( ctx->iv_size != 0 ) + return (int) ctx->iv_size; + + return (int) ctx->cipher_info->iv_size; +} + +/** + * \brief Returns the type of the given cipher. + * + * \param ctx cipher's context. Must have been initialised. + * + * \return type of the cipher, or MBEDTLS_CIPHER_NONE if ctx has + * not been initialised. + */ +static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return MBEDTLS_CIPHER_NONE; + + return ctx->cipher_info->type; +} + +/** + * \brief Returns the name of the given cipher, as a string. + * + * \param ctx cipher's context. Must have been initialised. + * + * \return name of the cipher, or NULL if ctx was not initialised. + */ +static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return 0; + + return ctx->cipher_info->name; +} + +/** + * \brief Returns the key length of the cipher. + * + * \param ctx cipher's context. Must have been initialised. + * + * \return cipher's key length, in bits, or + * MBEDTLS_KEY_LENGTH_NONE if ctx has not been + * initialised. + */ +static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return MBEDTLS_KEY_LENGTH_NONE; + + return (int) ctx->cipher_info->key_bitlen; +} + +/** + * \brief Returns the operation of the given cipher. + * + * \param ctx cipher's context. Must have been initialised. + * + * \return operation (MBEDTLS_ENCRYPT or MBEDTLS_DECRYPT), + * or MBEDTLS_OPERATION_NONE if ctx has not been + * initialised. + */ +static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return MBEDTLS_OPERATION_NONE; + + return ctx->operation; +} + +/** + * \brief Set the key to use with the given context. + * + * \param ctx generic cipher context. May not be NULL. Must have been + * initialised using cipher_context_from_type or + * cipher_context_from_string. + * \param key The key to use. + * \param key_bitlen key length to use, in bits. + * \param operation Operation that the key will be used for, either + * MBEDTLS_ENCRYPT or MBEDTLS_DECRYPT. + * + * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if + * parameter verification fails or a cipher specific + * error code. + */ +int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, + int key_bitlen, const mbedtls_operation_t operation ); + +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) +/** + * \brief Set padding mode, for cipher modes that use padding. + * (Default: PKCS7 padding.) + * + * \param ctx generic cipher context + * \param mode padding mode + * + * \returns 0 on success, MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE + * if selected padding mode is not supported, or + * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode + * does not support padding. + */ +int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ); +#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ + +/** + * \brief Set the initialization vector (IV) or nonce + * + * \param ctx generic cipher context + * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers) + * \param iv_len IV length for ciphers with variable-size IV; + * discarded by ciphers with fixed-size IV. + * + * \returns 0 on success, or MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + * + * \note Some ciphers don't use IVs nor NONCE. For these + * ciphers, this function has no effect. + */ +int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len ); + +/** + * \brief Finish preparation of the given context + * + * \param ctx generic cipher context + * + * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + * if parameter verification fails. + */ +int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ); + +#if defined(MBEDTLS_GCM_C) +/** + * \brief Add additional data (for AEAD ciphers). + * Currently only supported with GCM. + * Must be called exactly once, after mbedtls_cipher_reset(). + * + * \param ctx generic cipher context + * \param ad Additional data to use. + * \param ad_len Length of ad. + * + * \return 0 on success, or a specific error code. + */ +int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, + const unsigned char *ad, size_t ad_len ); +#endif /* MBEDTLS_GCM_C */ + +/** + * \brief Generic cipher update function. Encrypts/decrypts + * using the given cipher context. Writes as many block + * size'd blocks of data as possible to output. Any data + * that cannot be written immediately will either be added + * to the next block, or flushed when cipher_final is + * called. + * Exception: for MBEDTLS_MODE_ECB, expects single block + * in size (e.g. 16 bytes for AES) + * + * \param ctx generic cipher context + * \param input buffer holding the input data + * \param ilen length of the input data + * \param output buffer for the output data. Should be able to hold at + * least ilen + block_size. Cannot be the same buffer as + * input! + * \param olen length of the output data, will be filled with the + * actual number of bytes written. + * + * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if + * parameter verification fails, + * MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE on an + * unsupported mode for a cipher or a cipher specific + * error code. + * + * \note If the underlying cipher is GCM, all calls to this + * function, except the last one before mbedtls_cipher_finish(), + * must have ilen a multiple of the block size. + */ +int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, + size_t ilen, unsigned char *output, size_t *olen ); + +/** + * \brief Generic cipher finalisation function. If data still + * needs to be flushed from an incomplete block, data + * contained within it will be padded with the size of + * the last block, and written to the output buffer. + * + * \param ctx Generic cipher context + * \param output buffer to write data to. Needs block_size available. + * \param olen length of the data written to the output buffer. + * + * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if + * parameter verification fails, + * MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption + * expected a full block but was not provided one, + * MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding + * while decrypting or a cipher specific error code. + */ +int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, + unsigned char *output, size_t *olen ); + +#if defined(MBEDTLS_GCM_C) +/** + * \brief Write tag for AEAD ciphers. + * Currently only supported with GCM. + * Must be called after mbedtls_cipher_finish(). + * + * \param ctx Generic cipher context + * \param tag buffer to write the tag + * \param tag_len Length of the tag to write + * + * \return 0 on success, or a specific error code. + */ +int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, + unsigned char *tag, size_t tag_len ); + +/** + * \brief Check tag for AEAD ciphers. + * Currently only supported with GCM. + * Must be called after mbedtls_cipher_finish(). + * + * \param ctx Generic cipher context + * \param tag Buffer holding the tag + * \param tag_len Length of the tag to check + * + * \return 0 on success, or a specific error code. + */ +int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, + const unsigned char *tag, size_t tag_len ); +#endif /* MBEDTLS_GCM_C */ + +/** + * \brief Generic all-in-one encryption/decryption + * (for all ciphers except AEAD constructs). + * + * \param ctx generic cipher context + * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers) + * \param iv_len IV length for ciphers with variable-size IV; + * discarded by ciphers with fixed-size IV. + * \param input buffer holding the input data + * \param ilen length of the input data + * \param output buffer for the output data. Should be able to hold at + * least ilen + block_size. Cannot be the same buffer as + * input! + * \param olen length of the output data, will be filled with the + * actual number of bytes written. + * + * \note Some ciphers don't use IVs nor NONCE. For these + * ciphers, use iv = NULL and iv_len = 0. + * + * \returns 0 on success, or + * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or + * MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption + * expected a full block but was not provided one, or + * MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding + * while decrypting, or + * a cipher specific error code. + */ +int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen ); + +#if defined(MBEDTLS_CIPHER_MODE_AEAD) +/** + * \brief Generic autenticated encryption (AEAD ciphers). + * + * \param ctx generic cipher context + * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers) + * \param iv_len IV length for ciphers with variable-size IV; + * discarded by ciphers with fixed-size IV. + * \param ad Additional data to authenticate. + * \param ad_len Length of ad. + * \param input buffer holding the input data + * \param ilen length of the input data + * \param output buffer for the output data. + * Should be able to hold at least ilen. + * \param olen length of the output data, will be filled with the + * actual number of bytes written. + * \param tag buffer for the authentication tag + * \param tag_len desired tag length + * + * \returns 0 on success, or + * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or + * a cipher specific error code. + */ +int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *ad, size_t ad_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, + unsigned char *tag, size_t tag_len ); + +/** + * \brief Generic autenticated decryption (AEAD ciphers). + * + * \param ctx generic cipher context + * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers) + * \param iv_len IV length for ciphers with variable-size IV; + * discarded by ciphers with fixed-size IV. + * \param ad Additional data to be authenticated. + * \param ad_len Length of ad. + * \param input buffer holding the input data + * \param ilen length of the input data + * \param output buffer for the output data. + * Should be able to hold at least ilen. + * \param olen length of the output data, will be filled with the + * actual number of bytes written. + * \param tag buffer holding the authentication tag + * \param tag_len length of the authentication tag + * + * \returns 0 on success, or + * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or + * MBEDTLS_ERR_CIPHER_AUTH_FAILED if data isn't authentic, + * or a cipher specific error code. + * + * \note If the data is not authentic, then the output buffer + * is zeroed out to prevent the unauthentic plaintext to + * be used by mistake, making this interface safer. + */ +int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *ad, size_t ad_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, + const unsigned char *tag, size_t tag_len ); +#endif /* MBEDTLS_CIPHER_MODE_AEAD */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CIPHER_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher_internal.h new file mode 100644 index 0000000..6c58bcc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cipher_internal.h @@ -0,0 +1,109 @@ +/** + * \file cipher_internal.h + * + * \brief Cipher wrappers. + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CIPHER_WRAP_H +#define MBEDTLS_CIPHER_WRAP_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "cipher.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Base cipher information. The non-mode specific functions and values. + */ +struct mbedtls_cipher_base_t +{ + /** Base Cipher type (e.g. MBEDTLS_CIPHER_ID_AES) */ + mbedtls_cipher_id_t cipher; + + /** Encrypt using ECB */ + int (*ecb_func)( void *ctx, mbedtls_operation_t mode, + const unsigned char *input, unsigned char *output ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + /** Encrypt using CBC */ + int (*cbc_func)( void *ctx, mbedtls_operation_t mode, size_t length, + unsigned char *iv, const unsigned char *input, + unsigned char *output ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + /** Encrypt using CFB (Full length) */ + int (*cfb_func)( void *ctx, mbedtls_operation_t mode, size_t length, size_t *iv_off, + unsigned char *iv, const unsigned char *input, + unsigned char *output ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + /** Encrypt using CTR */ + int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, + const unsigned char *input, unsigned char *output ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + /** Encrypt using STREAM */ + int (*stream_func)( void *ctx, size_t length, + const unsigned char *input, unsigned char *output ); +#endif + + /** Set key for encryption purposes */ + int (*setkey_enc_func)( void *ctx, const unsigned char *key, + unsigned int key_bitlen ); + + /** Set key for decryption purposes */ + int (*setkey_dec_func)( void *ctx, const unsigned char *key, + unsigned int key_bitlen); + + /** Allocate a new context */ + void * (*ctx_alloc_func)( void ); + + /** Free the given context */ + void (*ctx_free_func)( void *ctx ); + +}; + +typedef struct +{ + mbedtls_cipher_type_t type; + const mbedtls_cipher_info_t *info; +} mbedtls_cipher_definition_t; + +extern const mbedtls_cipher_definition_t mbedtls_cipher_definitions[]; + +extern int mbedtls_cipher_supported[]; + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CIPHER_WRAP_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cmac.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cmac.h new file mode 100644 index 0000000..9a2b96b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/cmac.h @@ -0,0 +1,170 @@ +/** + * \file cmac.h + * + * \brief Cipher-based Message Authentication Code (CMAC) Mode for + * Authentication + * + * Copyright (C) 2015-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CMAC_H +#define MBEDTLS_CMAC_H + +#include "mbedtls/cipher.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MBEDTLS_AES_BLOCK_SIZE 16 +#define MBEDTLS_DES3_BLOCK_SIZE 8 + +#if defined(MBEDTLS_AES_C) +#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /* longest used by CMAC is AES */ +#else +#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /* longest used by CMAC is 3DES */ +#endif + +/** + * CMAC context structure - Contains internal state information only + */ +struct mbedtls_cmac_context_t +{ + /** Internal state of the CMAC algorithm */ + unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX]; + + /** Unprocessed data - either data that was not block aligned and is still + * pending to be processed, or the final block */ + unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX]; + + /** Length of data pending to be processed */ + size_t unprocessed_len; +}; + +/** + * \brief Set the CMAC key and prepare to authenticate the input + * data. + * Should be called with an initialized cipher context. + * + * \param ctx Cipher context. This should be a cipher context, + * initialized to be one of the following types: + * MBEDTLS_CIPHER_AES_128_ECB, MBEDTLS_CIPHER_AES_192_ECB, + * MBEDTLS_CIPHER_AES_256_ECB or + * MBEDTLS_CIPHER_DES_EDE3_ECB. + * \param key CMAC key + * \param keybits length of the CMAC key in bits + * (must be acceptable by the cipher) + * + * \return 0 if successful, or a cipher specific error code + */ +int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, + const unsigned char *key, size_t keybits ); + +/** + * \brief Generic CMAC process buffer. + * Called between mbedtls_cipher_cmac_starts() or + * mbedtls_cipher_cmac_reset() and + * mbedtls_cipher_cmac_finish(). + * May be called repeatedly. + * + * \param ctx CMAC context + * \param input buffer holding the data + * \param ilen length of the input data + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, + const unsigned char *input, size_t ilen ); + +/** + * \brief Output CMAC. + * Called after mbedtls_cipher_cmac_update(). + * Usually followed by mbedtls_cipher_cmac_reset(), then + * mbedtls_cipher_cmac_starts(), or mbedtls_cipher_free(). + * + * \param ctx CMAC context + * \param output Generic CMAC checksum result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, + unsigned char *output ); + +/** + * \brief Prepare to authenticate a new message with the same key. + * Called after mbedtls_cipher_cmac_finish() and before + * mbedtls_cipher_cmac_update(). + * + * \param ctx CMAC context to be reset + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ); + +/** + * \brief Output = Generic_CMAC( cmac key, input buffer ) + * + * \param cipher_info message digest info + * \param key CMAC key + * \param keylen length of the CMAC key in bits + * \param input buffer holding the data + * \param ilen length of the input data + * \param output Generic CMAC-result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, + const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char *output ); + +#if defined(MBEDTLS_AES_C) +/** + * \brief AES-CMAC-128-PRF + * Implementation of (AES-CMAC-PRF-128), as defined in RFC 4615 + * + * \param key PRF key + * \param key_len PRF key length in bytes + * \param input buffer holding the input data + * \param in_len length of the input data in bytes + * \param output buffer holding the generated pseudorandom output (16 bytes) + * + * \return 0 if successful + */ +int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len, + const unsigned char *input, size_t in_len, + unsigned char output[16] ); +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) ) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_cmac_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CMAC_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/compat-1.3.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/compat-1.3.h new file mode 100644 index 0000000..af51b5f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/compat-1.3.h @@ -0,0 +1,2633 @@ +/** + * \file compat-1.3.h + * + * \brief Compatibility definitions for using mbed TLS with client code written + * for the PolarSSL naming conventions. + * + * \deprecated Use the new names directly instead + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) + +#if defined(MBEDTLS_DEPRECATED_WARNING) +#warning "Including compat-1.3.h is deprecated" +#endif + +#ifndef MBEDTLS_COMPAT13_H +#define MBEDTLS_COMPAT13_H + +/* + * config.h options + */ +#if defined MBEDTLS_AESNI_C +#define POLARSSL_AESNI_C MBEDTLS_AESNI_C +#endif +#if defined MBEDTLS_AES_ALT +#define POLARSSL_AES_ALT MBEDTLS_AES_ALT +#endif +#if defined MBEDTLS_AES_C +#define POLARSSL_AES_C MBEDTLS_AES_C +#endif +#if defined MBEDTLS_AES_ROM_TABLES +#define POLARSSL_AES_ROM_TABLES MBEDTLS_AES_ROM_TABLES +#endif +#if defined MBEDTLS_ARC4_ALT +#define POLARSSL_ARC4_ALT MBEDTLS_ARC4_ALT +#endif +#if defined MBEDTLS_ARC4_C +#define POLARSSL_ARC4_C MBEDTLS_ARC4_C +#endif +#if defined MBEDTLS_ASN1_PARSE_C +#define POLARSSL_ASN1_PARSE_C MBEDTLS_ASN1_PARSE_C +#endif +#if defined MBEDTLS_ASN1_WRITE_C +#define POLARSSL_ASN1_WRITE_C MBEDTLS_ASN1_WRITE_C +#endif +#if defined MBEDTLS_BASE64_C +#define POLARSSL_BASE64_C MBEDTLS_BASE64_C +#endif +#if defined MBEDTLS_BIGNUM_C +#define POLARSSL_BIGNUM_C MBEDTLS_BIGNUM_C +#endif +#if defined MBEDTLS_BLOWFISH_ALT +#define POLARSSL_BLOWFISH_ALT MBEDTLS_BLOWFISH_ALT +#endif +#if defined MBEDTLS_BLOWFISH_C +#define POLARSSL_BLOWFISH_C MBEDTLS_BLOWFISH_C +#endif +#if defined MBEDTLS_CAMELLIA_ALT +#define POLARSSL_CAMELLIA_ALT MBEDTLS_CAMELLIA_ALT +#endif +#if defined MBEDTLS_CAMELLIA_C +#define POLARSSL_CAMELLIA_C MBEDTLS_CAMELLIA_C +#endif +#if defined MBEDTLS_CAMELLIA_SMALL_MEMORY +#define POLARSSL_CAMELLIA_SMALL_MEMORY MBEDTLS_CAMELLIA_SMALL_MEMORY +#endif +#if defined MBEDTLS_CCM_C +#define POLARSSL_CCM_C MBEDTLS_CCM_C +#endif +#if defined MBEDTLS_CERTS_C +#define POLARSSL_CERTS_C MBEDTLS_CERTS_C +#endif +#if defined MBEDTLS_CIPHER_C +#define POLARSSL_CIPHER_C MBEDTLS_CIPHER_C +#endif +#if defined MBEDTLS_CIPHER_MODE_CBC +#define POLARSSL_CIPHER_MODE_CBC MBEDTLS_CIPHER_MODE_CBC +#endif +#if defined MBEDTLS_CIPHER_MODE_CFB +#define POLARSSL_CIPHER_MODE_CFB MBEDTLS_CIPHER_MODE_CFB +#endif +#if defined MBEDTLS_CIPHER_MODE_CTR +#define POLARSSL_CIPHER_MODE_CTR MBEDTLS_CIPHER_MODE_CTR +#endif +#if defined MBEDTLS_CIPHER_NULL_CIPHER +#define POLARSSL_CIPHER_NULL_CIPHER MBEDTLS_CIPHER_NULL_CIPHER +#endif +#if defined MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#define POLARSSL_CIPHER_PADDING_ONE_AND_ZEROS MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#endif +#if defined MBEDTLS_CIPHER_PADDING_PKCS7 +#define POLARSSL_CIPHER_PADDING_PKCS7 MBEDTLS_CIPHER_PADDING_PKCS7 +#endif +#if defined MBEDTLS_CIPHER_PADDING_ZEROS +#define POLARSSL_CIPHER_PADDING_ZEROS MBEDTLS_CIPHER_PADDING_ZEROS +#endif +#if defined MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#define POLARSSL_CIPHER_PADDING_ZEROS_AND_LEN MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#endif +#if defined MBEDTLS_CTR_DRBG_C +#define POLARSSL_CTR_DRBG_C MBEDTLS_CTR_DRBG_C +#endif +#if defined MBEDTLS_DEBUG_C +#define POLARSSL_DEBUG_C MBEDTLS_DEBUG_C +#endif +#if defined MBEDTLS_DEPRECATED_REMOVED +#define POLARSSL_DEPRECATED_REMOVED MBEDTLS_DEPRECATED_REMOVED +#endif +#if defined MBEDTLS_DEPRECATED_WARNING +#define POLARSSL_DEPRECATED_WARNING MBEDTLS_DEPRECATED_WARNING +#endif +#if defined MBEDTLS_DES_ALT +#define POLARSSL_DES_ALT MBEDTLS_DES_ALT +#endif +#if defined MBEDTLS_DES_C +#define POLARSSL_DES_C MBEDTLS_DES_C +#endif +#if defined MBEDTLS_DHM_C +#define POLARSSL_DHM_C MBEDTLS_DHM_C +#endif +#if defined MBEDTLS_ECDH_C +#define POLARSSL_ECDH_C MBEDTLS_ECDH_C +#endif +#if defined MBEDTLS_ECDSA_C +#define POLARSSL_ECDSA_C MBEDTLS_ECDSA_C +#endif +#if defined MBEDTLS_ECDSA_DETERMINISTIC +#define POLARSSL_ECDSA_DETERMINISTIC MBEDTLS_ECDSA_DETERMINISTIC +#endif +#if defined MBEDTLS_ECP_C +#define POLARSSL_ECP_C MBEDTLS_ECP_C +#endif +#if defined MBEDTLS_ECP_DP_BP256R1_ENABLED +#define POLARSSL_ECP_DP_BP256R1_ENABLED MBEDTLS_ECP_DP_BP256R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_BP384R1_ENABLED +#define POLARSSL_ECP_DP_BP384R1_ENABLED MBEDTLS_ECP_DP_BP384R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_BP512R1_ENABLED +#define POLARSSL_ECP_DP_BP512R1_ENABLED MBEDTLS_ECP_DP_BP512R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_CURVE25519_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP192K1_ENABLED +#define POLARSSL_ECP_DP_SECP192K1_ENABLED MBEDTLS_ECP_DP_SECP192K1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define POLARSSL_ECP_DP_SECP192R1_ENABLED MBEDTLS_ECP_DP_SECP192R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP224K1_ENABLED +#define POLARSSL_ECP_DP_SECP224K1_ENABLED MBEDTLS_ECP_DP_SECP224K1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define POLARSSL_ECP_DP_SECP224R1_ENABLED MBEDTLS_ECP_DP_SECP224R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define POLARSSL_ECP_DP_SECP256K1_ENABLED MBEDTLS_ECP_DP_SECP256K1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define POLARSSL_ECP_DP_SECP256R1_ENABLED MBEDTLS_ECP_DP_SECP256R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define POLARSSL_ECP_DP_SECP384R1_ENABLED MBEDTLS_ECP_DP_SECP384R1_ENABLED +#endif +#if defined MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define POLARSSL_ECP_DP_SECP521R1_ENABLED MBEDTLS_ECP_DP_SECP521R1_ENABLED +#endif +#if defined MBEDTLS_ECP_FIXED_POINT_OPTIM +#define POLARSSL_ECP_FIXED_POINT_OPTIM MBEDTLS_ECP_FIXED_POINT_OPTIM +#endif +#if defined MBEDTLS_ECP_MAX_BITS +#define POLARSSL_ECP_MAX_BITS MBEDTLS_ECP_MAX_BITS +#endif +#if defined MBEDTLS_ECP_NIST_OPTIM +#define POLARSSL_ECP_NIST_OPTIM MBEDTLS_ECP_NIST_OPTIM +#endif +#if defined MBEDTLS_ECP_WINDOW_SIZE +#define POLARSSL_ECP_WINDOW_SIZE MBEDTLS_ECP_WINDOW_SIZE +#endif +#if defined MBEDTLS_ENABLE_WEAK_CIPHERSUITES +#define POLARSSL_ENABLE_WEAK_CIPHERSUITES MBEDTLS_ENABLE_WEAK_CIPHERSUITES +#endif +#if defined MBEDTLS_ENTROPY_C +#define POLARSSL_ENTROPY_C MBEDTLS_ENTROPY_C +#endif +#if defined MBEDTLS_ENTROPY_FORCE_SHA256 +#define POLARSSL_ENTROPY_FORCE_SHA256 MBEDTLS_ENTROPY_FORCE_SHA256 +#endif +#if defined MBEDTLS_ERROR_C +#define POLARSSL_ERROR_C MBEDTLS_ERROR_C +#endif +#if defined MBEDTLS_ERROR_STRERROR_BC +#define POLARSSL_ERROR_STRERROR_BC MBEDTLS_ERROR_STRERROR_BC +#endif +#if defined MBEDTLS_ERROR_STRERROR_DUMMY +#define POLARSSL_ERROR_STRERROR_DUMMY MBEDTLS_ERROR_STRERROR_DUMMY +#endif +#if defined MBEDTLS_FS_IO +#define POLARSSL_FS_IO MBEDTLS_FS_IO +#endif +#if defined MBEDTLS_GCM_C +#define POLARSSL_GCM_C MBEDTLS_GCM_C +#endif +#if defined MBEDTLS_GENPRIME +#define POLARSSL_GENPRIME MBEDTLS_GENPRIME +#endif +#if defined MBEDTLS_HAVEGE_C +#define POLARSSL_HAVEGE_C MBEDTLS_HAVEGE_C +#endif +#if defined MBEDTLS_HAVE_ASM +#define POLARSSL_HAVE_ASM MBEDTLS_HAVE_ASM +#endif +#if defined MBEDTLS_HAVE_SSE2 +#define POLARSSL_HAVE_SSE2 MBEDTLS_HAVE_SSE2 +#endif +#if defined MBEDTLS_HAVE_TIME +#define POLARSSL_HAVE_TIME MBEDTLS_HAVE_TIME +#endif +#if defined MBEDTLS_HMAC_DRBG_C +#define POLARSSL_HMAC_DRBG_C MBEDTLS_HMAC_DRBG_C +#endif +#if defined MBEDTLS_HMAC_DRBG_MAX_INPUT +#define POLARSSL_HMAC_DRBG_MAX_INPUT MBEDTLS_HMAC_DRBG_MAX_INPUT +#endif +#if defined MBEDTLS_HMAC_DRBG_MAX_REQUEST +#define POLARSSL_HMAC_DRBG_MAX_REQUEST MBEDTLS_HMAC_DRBG_MAX_REQUEST +#endif +#if defined MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT +#define POLARSSL_HMAC_DRBG_MAX_SEED_INPUT MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT +#endif +#if defined MBEDTLS_HMAC_DRBG_RESEED_INTERVAL +#define POLARSSL_HMAC_DRBG_RESEED_INTERVAL MBEDTLS_HMAC_DRBG_RESEED_INTERVAL +#endif +#if defined MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED +#define POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED +#define POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +#define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED +#define POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +#define POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +#define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +#define POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +#define POLARSSL_KEY_EXCHANGE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +#define POLARSSL_KEY_EXCHANGE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +#endif +#if defined MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +#define POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +#endif +#if defined MBEDTLS_MD2_ALT +#define POLARSSL_MD2_ALT MBEDTLS_MD2_ALT +#endif +#if defined MBEDTLS_MD2_C +#define POLARSSL_MD2_C MBEDTLS_MD2_C +#endif +#if defined MBEDTLS_MD2_PROCESS_ALT +#define POLARSSL_MD2_PROCESS_ALT MBEDTLS_MD2_PROCESS_ALT +#endif +#if defined MBEDTLS_MD4_ALT +#define POLARSSL_MD4_ALT MBEDTLS_MD4_ALT +#endif +#if defined MBEDTLS_MD4_C +#define POLARSSL_MD4_C MBEDTLS_MD4_C +#endif +#if defined MBEDTLS_MD4_PROCESS_ALT +#define POLARSSL_MD4_PROCESS_ALT MBEDTLS_MD4_PROCESS_ALT +#endif +#if defined MBEDTLS_MD5_ALT +#define POLARSSL_MD5_ALT MBEDTLS_MD5_ALT +#endif +#if defined MBEDTLS_MD5_C +#define POLARSSL_MD5_C MBEDTLS_MD5_C +#endif +#if defined MBEDTLS_MD5_PROCESS_ALT +#define POLARSSL_MD5_PROCESS_ALT MBEDTLS_MD5_PROCESS_ALT +#endif +#if defined MBEDTLS_MD_C +#define POLARSSL_MD_C MBEDTLS_MD_C +#endif +#if defined MBEDTLS_MEMORY_ALIGN_MULTIPLE +#define POLARSSL_MEMORY_ALIGN_MULTIPLE MBEDTLS_MEMORY_ALIGN_MULTIPLE +#endif +#if defined MBEDTLS_MEMORY_BACKTRACE +#define POLARSSL_MEMORY_BACKTRACE MBEDTLS_MEMORY_BACKTRACE +#endif +#if defined MBEDTLS_MEMORY_BUFFER_ALLOC_C +#define POLARSSL_MEMORY_BUFFER_ALLOC_C MBEDTLS_MEMORY_BUFFER_ALLOC_C +#endif +#if defined MBEDTLS_MEMORY_C +#define POLARSSL_MEMORY_C MBEDTLS_MEMORY_C +#endif +#if defined MBEDTLS_MEMORY_DEBUG +#define POLARSSL_MEMORY_DEBUG MBEDTLS_MEMORY_DEBUG +#endif +#if defined MBEDTLS_MPI_MAX_SIZE +#define POLARSSL_MPI_MAX_SIZE MBEDTLS_MPI_MAX_SIZE +#endif +#if defined MBEDTLS_MPI_WINDOW_SIZE +#define POLARSSL_MPI_WINDOW_SIZE MBEDTLS_MPI_WINDOW_SIZE +#endif +#if defined MBEDTLS_NET_C +#define POLARSSL_NET_C MBEDTLS_NET_C +#endif +#if defined MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES +#define POLARSSL_NO_DEFAULT_ENTROPY_SOURCES MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES +#endif +#if defined MBEDTLS_NO_PLATFORM_ENTROPY +#define POLARSSL_NO_PLATFORM_ENTROPY MBEDTLS_NO_PLATFORM_ENTROPY +#endif +#if defined MBEDTLS_OID_C +#define POLARSSL_OID_C MBEDTLS_OID_C +#endif +#if defined MBEDTLS_PADLOCK_C +#define POLARSSL_PADLOCK_C MBEDTLS_PADLOCK_C +#endif +#if defined MBEDTLS_PBKDF2_C +#define POLARSSL_PBKDF2_C MBEDTLS_PBKDF2_C +#endif +#if defined MBEDTLS_PEM_PARSE_C +#define POLARSSL_PEM_PARSE_C MBEDTLS_PEM_PARSE_C +#endif +#if defined MBEDTLS_PEM_WRITE_C +#define POLARSSL_PEM_WRITE_C MBEDTLS_PEM_WRITE_C +#endif +#if defined MBEDTLS_PKCS11_C +#define POLARSSL_PKCS11_C MBEDTLS_PKCS11_C +#endif +#if defined MBEDTLS_PKCS12_C +#define POLARSSL_PKCS12_C MBEDTLS_PKCS12_C +#endif +#if defined MBEDTLS_PKCS1_V15 +#define POLARSSL_PKCS1_V15 MBEDTLS_PKCS1_V15 +#endif +#if defined MBEDTLS_PKCS1_V21 +#define POLARSSL_PKCS1_V21 MBEDTLS_PKCS1_V21 +#endif +#if defined MBEDTLS_PKCS5_C +#define POLARSSL_PKCS5_C MBEDTLS_PKCS5_C +#endif +#if defined MBEDTLS_PK_C +#define POLARSSL_PK_C MBEDTLS_PK_C +#endif +#if defined MBEDTLS_PK_PARSE_C +#define POLARSSL_PK_PARSE_C MBEDTLS_PK_PARSE_C +#endif +#if defined MBEDTLS_PK_PARSE_EC_EXTENDED +#define POLARSSL_PK_PARSE_EC_EXTENDED MBEDTLS_PK_PARSE_EC_EXTENDED +#endif +#if defined MBEDTLS_PK_RSA_ALT_SUPPORT +#define POLARSSL_PK_RSA_ALT_SUPPORT MBEDTLS_PK_RSA_ALT_SUPPORT +#endif +#if defined MBEDTLS_PK_WRITE_C +#define POLARSSL_PK_WRITE_C MBEDTLS_PK_WRITE_C +#endif +#if defined MBEDTLS_PLATFORM_C +#define POLARSSL_PLATFORM_C MBEDTLS_PLATFORM_C +#endif +#if defined MBEDTLS_PLATFORM_EXIT_ALT +#define POLARSSL_PLATFORM_EXIT_ALT MBEDTLS_PLATFORM_EXIT_ALT +#endif +#if defined MBEDTLS_PLATFORM_EXIT_MACRO +#define POLARSSL_PLATFORM_EXIT_MACRO MBEDTLS_PLATFORM_EXIT_MACRO +#endif +#if defined MBEDTLS_PLATFORM_FPRINTF_ALT +#define POLARSSL_PLATFORM_FPRINTF_ALT MBEDTLS_PLATFORM_FPRINTF_ALT +#endif +#if defined MBEDTLS_PLATFORM_FPRINTF_MACRO +#define POLARSSL_PLATFORM_FPRINTF_MACRO MBEDTLS_PLATFORM_FPRINTF_MACRO +#endif +#if defined MBEDTLS_PLATFORM_FREE_MACRO +#define POLARSSL_PLATFORM_FREE_MACRO MBEDTLS_PLATFORM_FREE_MACRO +#endif +#if defined MBEDTLS_PLATFORM_MEMORY +#define POLARSSL_PLATFORM_MEMORY MBEDTLS_PLATFORM_MEMORY +#endif +#if defined MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +#define POLARSSL_PLATFORM_NO_STD_FUNCTIONS MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +#endif +#if defined MBEDTLS_PLATFORM_PRINTF_ALT +#define POLARSSL_PLATFORM_PRINTF_ALT MBEDTLS_PLATFORM_PRINTF_ALT +#endif +#if defined MBEDTLS_PLATFORM_PRINTF_MACRO +#define POLARSSL_PLATFORM_PRINTF_MACRO MBEDTLS_PLATFORM_PRINTF_MACRO +#endif +#if defined MBEDTLS_PLATFORM_SNPRINTF_ALT +#define POLARSSL_PLATFORM_SNPRINTF_ALT MBEDTLS_PLATFORM_SNPRINTF_ALT +#endif +#if defined MBEDTLS_PLATFORM_SNPRINTF_MACRO +#define POLARSSL_PLATFORM_SNPRINTF_MACRO MBEDTLS_PLATFORM_SNPRINTF_MACRO +#endif +#if defined MBEDTLS_PLATFORM_STD_EXIT +#define POLARSSL_PLATFORM_STD_EXIT MBEDTLS_PLATFORM_STD_EXIT +#endif +#if defined MBEDTLS_PLATFORM_STD_FPRINTF +#define POLARSSL_PLATFORM_STD_FPRINTF MBEDTLS_PLATFORM_STD_FPRINTF +#endif +#if defined MBEDTLS_PLATFORM_STD_FREE +#define POLARSSL_PLATFORM_STD_FREE MBEDTLS_PLATFORM_STD_FREE +#endif +#if defined MBEDTLS_PLATFORM_STD_MALLOC +#define POLARSSL_PLATFORM_STD_MALLOC MBEDTLS_PLATFORM_STD_MALLOC +#endif +#if defined MBEDTLS_PLATFORM_STD_MEM_HDR +#define POLARSSL_PLATFORM_STD_MEM_HDR MBEDTLS_PLATFORM_STD_MEM_HDR +#endif +#if defined MBEDTLS_PLATFORM_STD_PRINTF +#define POLARSSL_PLATFORM_STD_PRINTF MBEDTLS_PLATFORM_STD_PRINTF +#endif +#if defined MBEDTLS_PLATFORM_STD_SNPRINTF +#define POLARSSL_PLATFORM_STD_SNPRINTF MBEDTLS_PLATFORM_STD_SNPRINTF +#endif +#if defined MBEDTLS_PSK_MAX_LEN +#define POLARSSL_PSK_MAX_LEN MBEDTLS_PSK_MAX_LEN +#endif +#if defined MBEDTLS_REMOVE_ARC4_CIPHERSUITES +#define POLARSSL_REMOVE_ARC4_CIPHERSUITES MBEDTLS_REMOVE_ARC4_CIPHERSUITES +#endif +#if defined MBEDTLS_RIPEMD160_ALT +#define POLARSSL_RIPEMD160_ALT MBEDTLS_RIPEMD160_ALT +#endif +#if defined MBEDTLS_RIPEMD160_C +#define POLARSSL_RIPEMD160_C MBEDTLS_RIPEMD160_C +#endif +#if defined MBEDTLS_RIPEMD160_PROCESS_ALT +#define POLARSSL_RIPEMD160_PROCESS_ALT MBEDTLS_RIPEMD160_PROCESS_ALT +#endif +#if defined MBEDTLS_RSA_C +#define POLARSSL_RSA_C MBEDTLS_RSA_C +#endif +#if defined MBEDTLS_RSA_NO_CRT +#define POLARSSL_RSA_NO_CRT MBEDTLS_RSA_NO_CRT +#endif +#if defined MBEDTLS_SELF_TEST +#define POLARSSL_SELF_TEST MBEDTLS_SELF_TEST +#endif +#if defined MBEDTLS_SHA1_ALT +#define POLARSSL_SHA1_ALT MBEDTLS_SHA1_ALT +#endif +#if defined MBEDTLS_SHA1_C +#define POLARSSL_SHA1_C MBEDTLS_SHA1_C +#endif +#if defined MBEDTLS_SHA1_PROCESS_ALT +#define POLARSSL_SHA1_PROCESS_ALT MBEDTLS_SHA1_PROCESS_ALT +#endif +#if defined MBEDTLS_SHA256_ALT +#define POLARSSL_SHA256_ALT MBEDTLS_SHA256_ALT +#endif +#if defined MBEDTLS_SHA256_C +#define POLARSSL_SHA256_C MBEDTLS_SHA256_C +#endif +#if defined MBEDTLS_SHA256_PROCESS_ALT +#define POLARSSL_SHA256_PROCESS_ALT MBEDTLS_SHA256_PROCESS_ALT +#endif +#if defined MBEDTLS_SHA512_ALT +#define POLARSSL_SHA512_ALT MBEDTLS_SHA512_ALT +#endif +#if defined MBEDTLS_SHA512_C +#define POLARSSL_SHA512_C MBEDTLS_SHA512_C +#endif +#if defined MBEDTLS_SHA512_PROCESS_ALT +#define POLARSSL_SHA512_PROCESS_ALT MBEDTLS_SHA512_PROCESS_ALT +#endif +#if defined MBEDTLS_SSL_AEAD_RANDOM_IV +#define POLARSSL_SSL_AEAD_RANDOM_IV MBEDTLS_SSL_AEAD_RANDOM_IV +#endif +#if defined MBEDTLS_SSL_ALERT_MESSAGES +#define POLARSSL_SSL_ALERT_MESSAGES MBEDTLS_SSL_ALERT_MESSAGES +#endif +#if defined MBEDTLS_SSL_ALL_ALERT_MESSAGES +#define POLARSSL_SSL_ALL_ALERT_MESSAGES MBEDTLS_SSL_ALL_ALERT_MESSAGES +#endif +#if defined MBEDTLS_SSL_ALPN +#define POLARSSL_SSL_ALPN MBEDTLS_SSL_ALPN +#endif +#if defined MBEDTLS_SSL_CACHE_C +#define POLARSSL_SSL_CACHE_C MBEDTLS_SSL_CACHE_C +#endif +#if defined MBEDTLS_SSL_CBC_RECORD_SPLITTING +#define POLARSSL_SSL_CBC_RECORD_SPLITTING MBEDTLS_SSL_CBC_RECORD_SPLITTING +#endif +#if defined MBEDTLS_SSL_CLI_C +#define POLARSSL_SSL_CLI_C MBEDTLS_SSL_CLI_C +#endif +#if defined MBEDTLS_SSL_COOKIE_C +#define POLARSSL_SSL_COOKIE_C MBEDTLS_SSL_COOKIE_C +#endif +#if defined MBEDTLS_SSL_COOKIE_TIMEOUT +#define POLARSSL_SSL_COOKIE_TIMEOUT MBEDTLS_SSL_COOKIE_TIMEOUT +#endif +#if defined MBEDTLS_SSL_DEBUG_ALL +#define POLARSSL_SSL_DEBUG_ALL MBEDTLS_SSL_DEBUG_ALL +#endif +#if defined MBEDTLS_SSL_DISABLE_RENEGOTIATION +#define POLARSSL_SSL_DISABLE_RENEGOTIATION MBEDTLS_SSL_DISABLE_RENEGOTIATION +#endif +#if defined MBEDTLS_SSL_DTLS_ANTI_REPLAY +#define POLARSSL_SSL_DTLS_ANTI_REPLAY MBEDTLS_SSL_DTLS_ANTI_REPLAY +#endif +#if defined MBEDTLS_SSL_DTLS_BADMAC_LIMIT +#define POLARSSL_SSL_DTLS_BADMAC_LIMIT MBEDTLS_SSL_DTLS_BADMAC_LIMIT +#endif +#if defined MBEDTLS_SSL_DTLS_HELLO_VERIFY +#define POLARSSL_SSL_DTLS_HELLO_VERIFY MBEDTLS_SSL_DTLS_HELLO_VERIFY +#endif +#if defined MBEDTLS_SSL_ENCRYPT_THEN_MAC +#define POLARSSL_SSL_ENCRYPT_THEN_MAC MBEDTLS_SSL_ENCRYPT_THEN_MAC +#endif +#if defined MBEDTLS_SSL_EXTENDED_MASTER_SECRET +#define POLARSSL_SSL_EXTENDED_MASTER_SECRET MBEDTLS_SSL_EXTENDED_MASTER_SECRET +#endif +#if defined MBEDTLS_SSL_FALLBACK_SCSV +#define POLARSSL_SSL_FALLBACK_SCSV MBEDTLS_SSL_FALLBACK_SCSV +#endif +#if defined MBEDTLS_SSL_HW_RECORD_ACCEL +#define POLARSSL_SSL_HW_RECORD_ACCEL MBEDTLS_SSL_HW_RECORD_ACCEL +#endif +#if defined MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +#define POLARSSL_SSL_MAX_FRAGMENT_LENGTH MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +#endif +#if defined MBEDTLS_SSL_PROTO_DTLS +#define POLARSSL_SSL_PROTO_DTLS MBEDTLS_SSL_PROTO_DTLS +#endif +#if defined MBEDTLS_SSL_PROTO_SSL3 +#define POLARSSL_SSL_PROTO_SSL3 MBEDTLS_SSL_PROTO_SSL3 +#endif +#if defined MBEDTLS_SSL_PROTO_TLS1 +#define POLARSSL_SSL_PROTO_TLS1 MBEDTLS_SSL_PROTO_TLS1 +#endif +#if defined MBEDTLS_SSL_PROTO_TLS1_1 +#define POLARSSL_SSL_PROTO_TLS1_1 MBEDTLS_SSL_PROTO_TLS1_1 +#endif +#if defined MBEDTLS_SSL_PROTO_TLS1_2 +#define POLARSSL_SSL_PROTO_TLS1_2 MBEDTLS_SSL_PROTO_TLS1_2 +#endif +#if defined MBEDTLS_SSL_RENEGOTIATION +#define POLARSSL_SSL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION +#endif +#if defined MBEDTLS_SSL_SERVER_NAME_INDICATION +#define POLARSSL_SSL_SERVER_NAME_INDICATION MBEDTLS_SSL_SERVER_NAME_INDICATION +#endif +#if defined MBEDTLS_SSL_SESSION_TICKETS +#define POLARSSL_SSL_SESSION_TICKETS MBEDTLS_SSL_SESSION_TICKETS +#endif +#if defined MBEDTLS_SSL_SRV_C +#define POLARSSL_SSL_SRV_C MBEDTLS_SSL_SRV_C +#endif +#if defined MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE +#define POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE +#endif +#if defined MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO +#define POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO +#endif +#if defined MBEDTLS_SSL_TLS_C +#define POLARSSL_SSL_TLS_C MBEDTLS_SSL_TLS_C +#endif +#if defined MBEDTLS_SSL_TRUNCATED_HMAC +#define POLARSSL_SSL_TRUNCATED_HMAC MBEDTLS_SSL_TRUNCATED_HMAC +#endif +#if defined MBEDTLS_THREADING_ALT +#define POLARSSL_THREADING_ALT MBEDTLS_THREADING_ALT +#endif +#if defined MBEDTLS_THREADING_C +#define POLARSSL_THREADING_C MBEDTLS_THREADING_C +#endif +#if defined MBEDTLS_THREADING_PTHREAD +#define POLARSSL_THREADING_PTHREAD MBEDTLS_THREADING_PTHREAD +#endif +#if defined MBEDTLS_TIMING_ALT +#define POLARSSL_TIMING_ALT MBEDTLS_TIMING_ALT +#endif +#if defined MBEDTLS_TIMING_C +#define POLARSSL_TIMING_C MBEDTLS_TIMING_C +#endif +#if defined MBEDTLS_VERSION_C +#define POLARSSL_VERSION_C MBEDTLS_VERSION_C +#endif +#if defined MBEDTLS_VERSION_FEATURES +#define POLARSSL_VERSION_FEATURES MBEDTLS_VERSION_FEATURES +#endif +#if defined MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 +#define POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3 MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 +#endif +#if defined MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION +#define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION +#endif +#if defined MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE +#define POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE +#endif +#if defined MBEDTLS_X509_CHECK_KEY_USAGE +#define POLARSSL_X509_CHECK_KEY_USAGE MBEDTLS_X509_CHECK_KEY_USAGE +#endif +#if defined MBEDTLS_X509_CREATE_C +#define POLARSSL_X509_CREATE_C MBEDTLS_X509_CREATE_C +#endif +#if defined MBEDTLS_X509_CRL_PARSE_C +#define POLARSSL_X509_CRL_PARSE_C MBEDTLS_X509_CRL_PARSE_C +#endif +#if defined MBEDTLS_X509_CRT_PARSE_C +#define POLARSSL_X509_CRT_PARSE_C MBEDTLS_X509_CRT_PARSE_C +#endif +#if defined MBEDTLS_X509_CRT_WRITE_C +#define POLARSSL_X509_CRT_WRITE_C MBEDTLS_X509_CRT_WRITE_C +#endif +#if defined MBEDTLS_X509_CSR_PARSE_C +#define POLARSSL_X509_CSR_PARSE_C MBEDTLS_X509_CSR_PARSE_C +#endif +#if defined MBEDTLS_X509_CSR_WRITE_C +#define POLARSSL_X509_CSR_WRITE_C MBEDTLS_X509_CSR_WRITE_C +#endif +#if defined MBEDTLS_X509_MAX_INTERMEDIATE_CA +#define POLARSSL_X509_MAX_INTERMEDIATE_CA MBEDTLS_X509_MAX_INTERMEDIATE_CA +#endif +#if defined MBEDTLS_X509_RSASSA_PSS_SUPPORT +#define POLARSSL_X509_RSASSA_PSS_SUPPORT MBEDTLS_X509_RSASSA_PSS_SUPPORT +#endif +#if defined MBEDTLS_X509_USE_C +#define POLARSSL_X509_USE_C MBEDTLS_X509_USE_C +#endif +#if defined MBEDTLS_XTEA_ALT +#define POLARSSL_XTEA_ALT MBEDTLS_XTEA_ALT +#endif +#if defined MBEDTLS_XTEA_C +#define POLARSSL_XTEA_C MBEDTLS_XTEA_C +#endif +#if defined MBEDTLS_ZLIB_SUPPORT +#define POLARSSL_ZLIB_SUPPORT MBEDTLS_ZLIB_SUPPORT +#endif + +/* + * Misc names (macros, types, functions, enum constants...) + */ +#define AES_DECRYPT MBEDTLS_AES_DECRYPT +#define AES_ENCRYPT MBEDTLS_AES_ENCRYPT +#define ASN1_BIT_STRING MBEDTLS_ASN1_BIT_STRING +#define ASN1_BMP_STRING MBEDTLS_ASN1_BMP_STRING +#define ASN1_BOOLEAN MBEDTLS_ASN1_BOOLEAN +#define ASN1_CHK_ADD MBEDTLS_ASN1_CHK_ADD +#define ASN1_CONSTRUCTED MBEDTLS_ASN1_CONSTRUCTED +#define ASN1_CONTEXT_SPECIFIC MBEDTLS_ASN1_CONTEXT_SPECIFIC +#define ASN1_GENERALIZED_TIME MBEDTLS_ASN1_GENERALIZED_TIME +#define ASN1_IA5_STRING MBEDTLS_ASN1_IA5_STRING +#define ASN1_INTEGER MBEDTLS_ASN1_INTEGER +#define ASN1_NULL MBEDTLS_ASN1_NULL +#define ASN1_OCTET_STRING MBEDTLS_ASN1_OCTET_STRING +#define ASN1_OID MBEDTLS_ASN1_OID +#define ASN1_PRIMITIVE MBEDTLS_ASN1_PRIMITIVE +#define ASN1_PRINTABLE_STRING MBEDTLS_ASN1_PRINTABLE_STRING +#define ASN1_SEQUENCE MBEDTLS_ASN1_SEQUENCE +#define ASN1_SET MBEDTLS_ASN1_SET +#define ASN1_T61_STRING MBEDTLS_ASN1_T61_STRING +#define ASN1_UNIVERSAL_STRING MBEDTLS_ASN1_UNIVERSAL_STRING +#define ASN1_UTC_TIME MBEDTLS_ASN1_UTC_TIME +#define ASN1_UTF8_STRING MBEDTLS_ASN1_UTF8_STRING +#define BADCERT_CN_MISMATCH MBEDTLS_X509_BADCERT_CN_MISMATCH +#define BADCERT_EXPIRED MBEDTLS_X509_BADCERT_EXPIRED +#define BADCERT_FUTURE MBEDTLS_X509_BADCERT_FUTURE +#define BADCERT_MISSING MBEDTLS_X509_BADCERT_MISSING +#define BADCERT_NOT_TRUSTED MBEDTLS_X509_BADCERT_NOT_TRUSTED +#define BADCERT_OTHER MBEDTLS_X509_BADCERT_OTHER +#define BADCERT_REVOKED MBEDTLS_X509_BADCERT_REVOKED +#define BADCERT_SKIP_VERIFY MBEDTLS_X509_BADCERT_SKIP_VERIFY +#define BADCRL_EXPIRED MBEDTLS_X509_BADCRL_EXPIRED +#define BADCRL_FUTURE MBEDTLS_X509_BADCRL_FUTURE +#define BADCRL_NOT_TRUSTED MBEDTLS_X509_BADCRL_NOT_TRUSTED +#define BLOWFISH_BLOCKSIZE MBEDTLS_BLOWFISH_BLOCKSIZE +#define BLOWFISH_DECRYPT MBEDTLS_BLOWFISH_DECRYPT +#define BLOWFISH_ENCRYPT MBEDTLS_BLOWFISH_ENCRYPT +#define BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY_BITS +#define BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY_BITS +#define BLOWFISH_ROUNDS MBEDTLS_BLOWFISH_ROUNDS +#define CAMELLIA_DECRYPT MBEDTLS_CAMELLIA_DECRYPT +#define CAMELLIA_ENCRYPT MBEDTLS_CAMELLIA_ENCRYPT +#define COLLECT_SIZE MBEDTLS_HAVEGE_COLLECT_SIZE +#define CTR_DRBG_BLOCKSIZE MBEDTLS_CTR_DRBG_BLOCKSIZE +#define CTR_DRBG_ENTROPY_LEN MBEDTLS_CTR_DRBG_ENTROPY_LEN +#define CTR_DRBG_KEYBITS MBEDTLS_CTR_DRBG_KEYBITS +#define CTR_DRBG_KEYSIZE MBEDTLS_CTR_DRBG_KEYSIZE +#define CTR_DRBG_MAX_INPUT MBEDTLS_CTR_DRBG_MAX_INPUT +#define CTR_DRBG_MAX_REQUEST MBEDTLS_CTR_DRBG_MAX_REQUEST +#define CTR_DRBG_MAX_SEED_INPUT MBEDTLS_CTR_DRBG_MAX_SEED_INPUT +#define CTR_DRBG_PR_OFF MBEDTLS_CTR_DRBG_PR_OFF +#define CTR_DRBG_PR_ON MBEDTLS_CTR_DRBG_PR_ON +#define CTR_DRBG_RESEED_INTERVAL MBEDTLS_CTR_DRBG_RESEED_INTERVAL +#define CTR_DRBG_SEEDLEN MBEDTLS_CTR_DRBG_SEEDLEN +#define DEPRECATED MBEDTLS_DEPRECATED +#define DES_DECRYPT MBEDTLS_DES_DECRYPT +#define DES_ENCRYPT MBEDTLS_DES_ENCRYPT +#define DES_KEY_SIZE MBEDTLS_DES_KEY_SIZE +#define ENTROPY_BLOCK_SIZE MBEDTLS_ENTROPY_BLOCK_SIZE +#define ENTROPY_MAX_GATHER MBEDTLS_ENTROPY_MAX_GATHER +#define ENTROPY_MAX_SEED_SIZE MBEDTLS_ENTROPY_MAX_SEED_SIZE +#define ENTROPY_MAX_SOURCES MBEDTLS_ENTROPY_MAX_SOURCES +#define ENTROPY_MIN_HARDCLOCK MBEDTLS_ENTROPY_MIN_HARDCLOCK +#define ENTROPY_MIN_HAVEGE MBEDTLS_ENTROPY_MIN_HAVEGE +#define ENTROPY_MIN_PLATFORM MBEDTLS_ENTROPY_MIN_PLATFORM +#define ENTROPY_SOURCE_MANUAL MBEDTLS_ENTROPY_SOURCE_MANUAL +#define EXT_AUTHORITY_KEY_IDENTIFIER MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER +#define EXT_BASIC_CONSTRAINTS MBEDTLS_X509_EXT_BASIC_CONSTRAINTS +#define EXT_CERTIFICATE_POLICIES MBEDTLS_X509_EXT_CERTIFICATE_POLICIES +#define EXT_CRL_DISTRIBUTION_POINTS MBEDTLS_X509_EXT_CRL_DISTRIBUTION_POINTS +#define EXT_EXTENDED_KEY_USAGE MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE +#define EXT_FRESHEST_CRL MBEDTLS_X509_EXT_FRESHEST_CRL +#define EXT_INIHIBIT_ANYPOLICY MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY +#define EXT_ISSUER_ALT_NAME MBEDTLS_X509_EXT_ISSUER_ALT_NAME +#define EXT_KEY_USAGE MBEDTLS_X509_EXT_KEY_USAGE +#define EXT_NAME_CONSTRAINTS MBEDTLS_X509_EXT_NAME_CONSTRAINTS +#define EXT_NS_CERT_TYPE MBEDTLS_X509_EXT_NS_CERT_TYPE +#define EXT_POLICY_CONSTRAINTS MBEDTLS_X509_EXT_POLICY_CONSTRAINTS +#define EXT_POLICY_MAPPINGS MBEDTLS_X509_EXT_POLICY_MAPPINGS +#define EXT_SUBJECT_ALT_NAME MBEDTLS_X509_EXT_SUBJECT_ALT_NAME +#define EXT_SUBJECT_DIRECTORY_ATTRS MBEDTLS_X509_EXT_SUBJECT_DIRECTORY_ATTRS +#define EXT_SUBJECT_KEY_IDENTIFIER MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER +#define GCM_DECRYPT MBEDTLS_GCM_DECRYPT +#define GCM_ENCRYPT MBEDTLS_GCM_ENCRYPT +#define KU_CRL_SIGN MBEDTLS_X509_KU_CRL_SIGN +#define KU_DATA_ENCIPHERMENT MBEDTLS_X509_KU_DATA_ENCIPHERMENT +#define KU_DIGITAL_SIGNATURE MBEDTLS_X509_KU_DIGITAL_SIGNATURE +#define KU_KEY_AGREEMENT MBEDTLS_X509_KU_KEY_AGREEMENT +#define KU_KEY_CERT_SIGN MBEDTLS_X509_KU_KEY_CERT_SIGN +#define KU_KEY_ENCIPHERMENT MBEDTLS_X509_KU_KEY_ENCIPHERMENT +#define KU_NON_REPUDIATION MBEDTLS_X509_KU_NON_REPUDIATION +#define LN_2_DIV_LN_10_SCALE100 MBEDTLS_LN_2_DIV_LN_10_SCALE100 +#define MD_CONTEXT_T_INIT MBEDTLS_MD_CONTEXT_T_INIT +#define MEMORY_VERIFY_ALLOC MBEDTLS_MEMORY_VERIFY_ALLOC +#define MEMORY_VERIFY_ALWAYS MBEDTLS_MEMORY_VERIFY_ALWAYS +#define MEMORY_VERIFY_FREE MBEDTLS_MEMORY_VERIFY_FREE +#define MEMORY_VERIFY_NONE MBEDTLS_MEMORY_VERIFY_NONE +#define MPI_CHK MBEDTLS_MPI_CHK +#define NET_PROTO_TCP MBEDTLS_NET_PROTO_TCP +#define NET_PROTO_UDP MBEDTLS_NET_PROTO_UDP +#define NS_CERT_TYPE_EMAIL MBEDTLS_X509_NS_CERT_TYPE_EMAIL +#define NS_CERT_TYPE_EMAIL_CA MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA +#define NS_CERT_TYPE_OBJECT_SIGNING MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING +#define NS_CERT_TYPE_OBJECT_SIGNING_CA MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA +#define NS_CERT_TYPE_RESERVED MBEDTLS_X509_NS_CERT_TYPE_RESERVED +#define NS_CERT_TYPE_SSL_CA MBEDTLS_X509_NS_CERT_TYPE_SSL_CA +#define NS_CERT_TYPE_SSL_CLIENT MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT +#define NS_CERT_TYPE_SSL_SERVER MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER +#define OID_ANSI_X9_62 MBEDTLS_OID_ANSI_X9_62 +#define OID_ANSI_X9_62_FIELD_TYPE MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE +#define OID_ANSI_X9_62_PRIME_FIELD MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD +#define OID_ANSI_X9_62_SIG MBEDTLS_OID_ANSI_X9_62_SIG +#define OID_ANSI_X9_62_SIG_SHA2 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 +#define OID_ANY_EXTENDED_KEY_USAGE MBEDTLS_OID_ANY_EXTENDED_KEY_USAGE +#define OID_AT MBEDTLS_OID_AT +#define OID_AT_CN MBEDTLS_OID_AT_CN +#define OID_AT_COUNTRY MBEDTLS_OID_AT_COUNTRY +#define OID_AT_DN_QUALIFIER MBEDTLS_OID_AT_DN_QUALIFIER +#define OID_AT_GENERATION_QUALIFIER MBEDTLS_OID_AT_GENERATION_QUALIFIER +#define OID_AT_GIVEN_NAME MBEDTLS_OID_AT_GIVEN_NAME +#define OID_AT_INITIALS MBEDTLS_OID_AT_INITIALS +#define OID_AT_LOCALITY MBEDTLS_OID_AT_LOCALITY +#define OID_AT_ORGANIZATION MBEDTLS_OID_AT_ORGANIZATION +#define OID_AT_ORG_UNIT MBEDTLS_OID_AT_ORG_UNIT +#define OID_AT_POSTAL_ADDRESS MBEDTLS_OID_AT_POSTAL_ADDRESS +#define OID_AT_POSTAL_CODE MBEDTLS_OID_AT_POSTAL_CODE +#define OID_AT_PSEUDONYM MBEDTLS_OID_AT_PSEUDONYM +#define OID_AT_SERIAL_NUMBER MBEDTLS_OID_AT_SERIAL_NUMBER +#define OID_AT_STATE MBEDTLS_OID_AT_STATE +#define OID_AT_SUR_NAME MBEDTLS_OID_AT_SUR_NAME +#define OID_AT_TITLE MBEDTLS_OID_AT_TITLE +#define OID_AT_UNIQUE_IDENTIFIER MBEDTLS_OID_AT_UNIQUE_IDENTIFIER +#define OID_AUTHORITY_KEY_IDENTIFIER MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER +#define OID_BASIC_CONSTRAINTS MBEDTLS_OID_BASIC_CONSTRAINTS +#define OID_CERTICOM MBEDTLS_OID_CERTICOM +#define OID_CERTIFICATE_POLICIES MBEDTLS_OID_CERTIFICATE_POLICIES +#define OID_CLIENT_AUTH MBEDTLS_OID_CLIENT_AUTH +#define OID_CMP MBEDTLS_OID_CMP +#define OID_CODE_SIGNING MBEDTLS_OID_CODE_SIGNING +#define OID_COUNTRY_US MBEDTLS_OID_COUNTRY_US +#define OID_CRL_DISTRIBUTION_POINTS MBEDTLS_OID_CRL_DISTRIBUTION_POINTS +#define OID_CRL_NUMBER MBEDTLS_OID_CRL_NUMBER +#define OID_DES_CBC MBEDTLS_OID_DES_CBC +#define OID_DES_EDE3_CBC MBEDTLS_OID_DES_EDE3_CBC +#define OID_DIGEST_ALG_MD2 MBEDTLS_OID_DIGEST_ALG_MD2 +#define OID_DIGEST_ALG_MD4 MBEDTLS_OID_DIGEST_ALG_MD4 +#define OID_DIGEST_ALG_MD5 MBEDTLS_OID_DIGEST_ALG_MD5 +#define OID_DIGEST_ALG_SHA1 MBEDTLS_OID_DIGEST_ALG_SHA1 +#define OID_DIGEST_ALG_SHA224 MBEDTLS_OID_DIGEST_ALG_SHA224 +#define OID_DIGEST_ALG_SHA256 MBEDTLS_OID_DIGEST_ALG_SHA256 +#define OID_DIGEST_ALG_SHA384 MBEDTLS_OID_DIGEST_ALG_SHA384 +#define OID_DIGEST_ALG_SHA512 MBEDTLS_OID_DIGEST_ALG_SHA512 +#define OID_DOMAIN_COMPONENT MBEDTLS_OID_DOMAIN_COMPONENT +#define OID_ECDSA_SHA1 MBEDTLS_OID_ECDSA_SHA1 +#define OID_ECDSA_SHA224 MBEDTLS_OID_ECDSA_SHA224 +#define OID_ECDSA_SHA256 MBEDTLS_OID_ECDSA_SHA256 +#define OID_ECDSA_SHA384 MBEDTLS_OID_ECDSA_SHA384 +#define OID_ECDSA_SHA512 MBEDTLS_OID_ECDSA_SHA512 +#define OID_EC_ALG_ECDH MBEDTLS_OID_EC_ALG_ECDH +#define OID_EC_ALG_UNRESTRICTED MBEDTLS_OID_EC_ALG_UNRESTRICTED +#define OID_EC_BRAINPOOL_V1 MBEDTLS_OID_EC_BRAINPOOL_V1 +#define OID_EC_GRP_BP256R1 MBEDTLS_OID_EC_GRP_BP256R1 +#define OID_EC_GRP_BP384R1 MBEDTLS_OID_EC_GRP_BP384R1 +#define OID_EC_GRP_BP512R1 MBEDTLS_OID_EC_GRP_BP512R1 +#define OID_EC_GRP_SECP192K1 MBEDTLS_OID_EC_GRP_SECP192K1 +#define OID_EC_GRP_SECP192R1 MBEDTLS_OID_EC_GRP_SECP192R1 +#define OID_EC_GRP_SECP224K1 MBEDTLS_OID_EC_GRP_SECP224K1 +#define OID_EC_GRP_SECP224R1 MBEDTLS_OID_EC_GRP_SECP224R1 +#define OID_EC_GRP_SECP256K1 MBEDTLS_OID_EC_GRP_SECP256K1 +#define OID_EC_GRP_SECP256R1 MBEDTLS_OID_EC_GRP_SECP256R1 +#define OID_EC_GRP_SECP384R1 MBEDTLS_OID_EC_GRP_SECP384R1 +#define OID_EC_GRP_SECP521R1 MBEDTLS_OID_EC_GRP_SECP521R1 +#define OID_EMAIL_PROTECTION MBEDTLS_OID_EMAIL_PROTECTION +#define OID_EXTENDED_KEY_USAGE MBEDTLS_OID_EXTENDED_KEY_USAGE +#define OID_FRESHEST_CRL MBEDTLS_OID_FRESHEST_CRL +#define OID_GOV MBEDTLS_OID_GOV +#define OID_HMAC_SHA1 MBEDTLS_OID_HMAC_SHA1 +#define OID_ID_CE MBEDTLS_OID_ID_CE +#define OID_INIHIBIT_ANYPOLICY MBEDTLS_OID_INIHIBIT_ANYPOLICY +#define OID_ISO_CCITT_DS MBEDTLS_OID_ISO_CCITT_DS +#define OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ISO_IDENTIFIED_ORG +#define OID_ISO_ITU_COUNTRY MBEDTLS_OID_ISO_ITU_COUNTRY +#define OID_ISO_ITU_US_ORG MBEDTLS_OID_ISO_ITU_US_ORG +#define OID_ISO_MEMBER_BODIES MBEDTLS_OID_ISO_MEMBER_BODIES +#define OID_ISSUER_ALT_NAME MBEDTLS_OID_ISSUER_ALT_NAME +#define OID_KEY_USAGE MBEDTLS_OID_KEY_USAGE +#define OID_KP MBEDTLS_OID_KP +#define OID_MGF1 MBEDTLS_OID_MGF1 +#define OID_NAME_CONSTRAINTS MBEDTLS_OID_NAME_CONSTRAINTS +#define OID_NETSCAPE MBEDTLS_OID_NETSCAPE +#define OID_NS_BASE_URL MBEDTLS_OID_NS_BASE_URL +#define OID_NS_CA_POLICY_URL MBEDTLS_OID_NS_CA_POLICY_URL +#define OID_NS_CA_REVOCATION_URL MBEDTLS_OID_NS_CA_REVOCATION_URL +#define OID_NS_CERT MBEDTLS_OID_NS_CERT +#define OID_NS_CERT_SEQUENCE MBEDTLS_OID_NS_CERT_SEQUENCE +#define OID_NS_CERT_TYPE MBEDTLS_OID_NS_CERT_TYPE +#define OID_NS_COMMENT MBEDTLS_OID_NS_COMMENT +#define OID_NS_DATA_TYPE MBEDTLS_OID_NS_DATA_TYPE +#define OID_NS_RENEWAL_URL MBEDTLS_OID_NS_RENEWAL_URL +#define OID_NS_REVOCATION_URL MBEDTLS_OID_NS_REVOCATION_URL +#define OID_NS_SSL_SERVER_NAME MBEDTLS_OID_NS_SSL_SERVER_NAME +#define OID_OCSP_SIGNING MBEDTLS_OID_OCSP_SIGNING +#define OID_OIW_SECSIG MBEDTLS_OID_OIW_SECSIG +#define OID_OIW_SECSIG_ALG MBEDTLS_OID_OIW_SECSIG_ALG +#define OID_OIW_SECSIG_SHA1 MBEDTLS_OID_OIW_SECSIG_SHA1 +#define OID_ORGANIZATION MBEDTLS_OID_ORGANIZATION +#define OID_ORG_ANSI_X9_62 MBEDTLS_OID_ORG_ANSI_X9_62 +#define OID_ORG_CERTICOM MBEDTLS_OID_ORG_CERTICOM +#define OID_ORG_DOD MBEDTLS_OID_ORG_DOD +#define OID_ORG_GOV MBEDTLS_OID_ORG_GOV +#define OID_ORG_NETSCAPE MBEDTLS_OID_ORG_NETSCAPE +#define OID_ORG_OIW MBEDTLS_OID_ORG_OIW +#define OID_ORG_RSA_DATA_SECURITY MBEDTLS_OID_ORG_RSA_DATA_SECURITY +#define OID_ORG_TELETRUST MBEDTLS_OID_ORG_TELETRUST +#define OID_PKCS MBEDTLS_OID_PKCS +#define OID_PKCS1 MBEDTLS_OID_PKCS1 +#define OID_PKCS12 MBEDTLS_OID_PKCS12 +#define OID_PKCS12_PBE MBEDTLS_OID_PKCS12_PBE +#define OID_PKCS12_PBE_SHA1_DES2_EDE_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC +#define OID_PKCS12_PBE_SHA1_DES3_EDE_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC +#define OID_PKCS12_PBE_SHA1_RC2_128_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_128_CBC +#define OID_PKCS12_PBE_SHA1_RC2_40_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_40_CBC +#define OID_PKCS12_PBE_SHA1_RC4_128 MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_128 +#define OID_PKCS12_PBE_SHA1_RC4_40 MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_40 +#define OID_PKCS1_MD2 MBEDTLS_OID_PKCS1_MD2 +#define OID_PKCS1_MD4 MBEDTLS_OID_PKCS1_MD4 +#define OID_PKCS1_MD5 MBEDTLS_OID_PKCS1_MD5 +#define OID_PKCS1_RSA MBEDTLS_OID_PKCS1_RSA +#define OID_PKCS1_SHA1 MBEDTLS_OID_PKCS1_SHA1 +#define OID_PKCS1_SHA224 MBEDTLS_OID_PKCS1_SHA224 +#define OID_PKCS1_SHA256 MBEDTLS_OID_PKCS1_SHA256 +#define OID_PKCS1_SHA384 MBEDTLS_OID_PKCS1_SHA384 +#define OID_PKCS1_SHA512 MBEDTLS_OID_PKCS1_SHA512 +#define OID_PKCS5 MBEDTLS_OID_PKCS5 +#define OID_PKCS5_PBES2 MBEDTLS_OID_PKCS5_PBES2 +#define OID_PKCS5_PBE_MD2_DES_CBC MBEDTLS_OID_PKCS5_PBE_MD2_DES_CBC +#define OID_PKCS5_PBE_MD2_RC2_CBC MBEDTLS_OID_PKCS5_PBE_MD2_RC2_CBC +#define OID_PKCS5_PBE_MD5_DES_CBC MBEDTLS_OID_PKCS5_PBE_MD5_DES_CBC +#define OID_PKCS5_PBE_MD5_RC2_CBC MBEDTLS_OID_PKCS5_PBE_MD5_RC2_CBC +#define OID_PKCS5_PBE_SHA1_DES_CBC MBEDTLS_OID_PKCS5_PBE_SHA1_DES_CBC +#define OID_PKCS5_PBE_SHA1_RC2_CBC MBEDTLS_OID_PKCS5_PBE_SHA1_RC2_CBC +#define OID_PKCS5_PBKDF2 MBEDTLS_OID_PKCS5_PBKDF2 +#define OID_PKCS5_PBMAC1 MBEDTLS_OID_PKCS5_PBMAC1 +#define OID_PKCS9 MBEDTLS_OID_PKCS9 +#define OID_PKCS9_CSR_EXT_REQ MBEDTLS_OID_PKCS9_CSR_EXT_REQ +#define OID_PKCS9_EMAIL MBEDTLS_OID_PKCS9_EMAIL +#define OID_PKIX MBEDTLS_OID_PKIX +#define OID_POLICY_CONSTRAINTS MBEDTLS_OID_POLICY_CONSTRAINTS +#define OID_POLICY_MAPPINGS MBEDTLS_OID_POLICY_MAPPINGS +#define OID_PRIVATE_KEY_USAGE_PERIOD MBEDTLS_OID_PRIVATE_KEY_USAGE_PERIOD +#define OID_RSASSA_PSS MBEDTLS_OID_RSASSA_PSS +#define OID_RSA_COMPANY MBEDTLS_OID_RSA_COMPANY +#define OID_RSA_SHA_OBS MBEDTLS_OID_RSA_SHA_OBS +#define OID_SERVER_AUTH MBEDTLS_OID_SERVER_AUTH +#define OID_SIZE MBEDTLS_OID_SIZE +#define OID_SUBJECT_ALT_NAME MBEDTLS_OID_SUBJECT_ALT_NAME +#define OID_SUBJECT_DIRECTORY_ATTRS MBEDTLS_OID_SUBJECT_DIRECTORY_ATTRS +#define OID_SUBJECT_KEY_IDENTIFIER MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER +#define OID_TELETRUST MBEDTLS_OID_TELETRUST +#define OID_TIME_STAMPING MBEDTLS_OID_TIME_STAMPING +#define PADLOCK_ACE MBEDTLS_PADLOCK_ACE +#define PADLOCK_ALIGN16 MBEDTLS_PADLOCK_ALIGN16 +#define PADLOCK_PHE MBEDTLS_PADLOCK_PHE +#define PADLOCK_PMM MBEDTLS_PADLOCK_PMM +#define PADLOCK_RNG MBEDTLS_PADLOCK_RNG +#define PKCS12_DERIVE_IV MBEDTLS_PKCS12_DERIVE_IV +#define PKCS12_DERIVE_KEY MBEDTLS_PKCS12_DERIVE_KEY +#define PKCS12_DERIVE_MAC_KEY MBEDTLS_PKCS12_DERIVE_MAC_KEY +#define PKCS12_PBE_DECRYPT MBEDTLS_PKCS12_PBE_DECRYPT +#define PKCS12_PBE_ENCRYPT MBEDTLS_PKCS12_PBE_ENCRYPT +#define PKCS5_DECRYPT MBEDTLS_PKCS5_DECRYPT +#define PKCS5_ENCRYPT MBEDTLS_PKCS5_ENCRYPT +#define POLARSSL_AESNI_AES MBEDTLS_AESNI_AES +#define POLARSSL_AESNI_CLMUL MBEDTLS_AESNI_CLMUL +#define POLARSSL_AESNI_H MBEDTLS_AESNI_H +#define POLARSSL_AES_H MBEDTLS_AES_H +#define POLARSSL_ARC4_H MBEDTLS_ARC4_H +#define POLARSSL_ASN1_H MBEDTLS_ASN1_H +#define POLARSSL_ASN1_WRITE_H MBEDTLS_ASN1_WRITE_H +#define POLARSSL_BASE64_H MBEDTLS_BASE64_H +#define POLARSSL_BIGNUM_H MBEDTLS_BIGNUM_H +#define POLARSSL_BLOWFISH_H MBEDTLS_BLOWFISH_H +#define POLARSSL_BN_MUL_H MBEDTLS_BN_MUL_H +#define POLARSSL_CAMELLIA_H MBEDTLS_CAMELLIA_H +#define POLARSSL_CCM_H MBEDTLS_CCM_H +#define POLARSSL_CERTS_H MBEDTLS_CERTS_H +#define POLARSSL_CHECK_CONFIG_H MBEDTLS_CHECK_CONFIG_H +#define POLARSSL_CIPHERSUITE_NODTLS MBEDTLS_CIPHERSUITE_NODTLS +#define POLARSSL_CIPHERSUITE_SHORT_TAG MBEDTLS_CIPHERSUITE_SHORT_TAG +#define POLARSSL_CIPHERSUITE_WEAK MBEDTLS_CIPHERSUITE_WEAK +#define POLARSSL_CIPHER_AES_128_CBC MBEDTLS_CIPHER_AES_128_CBC +#define POLARSSL_CIPHER_AES_128_CCM MBEDTLS_CIPHER_AES_128_CCM +#define POLARSSL_CIPHER_AES_128_CFB128 MBEDTLS_CIPHER_AES_128_CFB128 +#define POLARSSL_CIPHER_AES_128_CTR MBEDTLS_CIPHER_AES_128_CTR +#define POLARSSL_CIPHER_AES_128_ECB MBEDTLS_CIPHER_AES_128_ECB +#define POLARSSL_CIPHER_AES_128_GCM MBEDTLS_CIPHER_AES_128_GCM +#define POLARSSL_CIPHER_AES_192_CBC MBEDTLS_CIPHER_AES_192_CBC +#define POLARSSL_CIPHER_AES_192_CCM MBEDTLS_CIPHER_AES_192_CCM +#define POLARSSL_CIPHER_AES_192_CFB128 MBEDTLS_CIPHER_AES_192_CFB128 +#define POLARSSL_CIPHER_AES_192_CTR MBEDTLS_CIPHER_AES_192_CTR +#define POLARSSL_CIPHER_AES_192_ECB MBEDTLS_CIPHER_AES_192_ECB +#define POLARSSL_CIPHER_AES_192_GCM MBEDTLS_CIPHER_AES_192_GCM +#define POLARSSL_CIPHER_AES_256_CBC MBEDTLS_CIPHER_AES_256_CBC +#define POLARSSL_CIPHER_AES_256_CCM MBEDTLS_CIPHER_AES_256_CCM +#define POLARSSL_CIPHER_AES_256_CFB128 MBEDTLS_CIPHER_AES_256_CFB128 +#define POLARSSL_CIPHER_AES_256_CTR MBEDTLS_CIPHER_AES_256_CTR +#define POLARSSL_CIPHER_AES_256_ECB MBEDTLS_CIPHER_AES_256_ECB +#define POLARSSL_CIPHER_AES_256_GCM MBEDTLS_CIPHER_AES_256_GCM +#define POLARSSL_CIPHER_ARC4_128 MBEDTLS_CIPHER_ARC4_128 +#define POLARSSL_CIPHER_BLOWFISH_CBC MBEDTLS_CIPHER_BLOWFISH_CBC +#define POLARSSL_CIPHER_BLOWFISH_CFB64 MBEDTLS_CIPHER_BLOWFISH_CFB64 +#define POLARSSL_CIPHER_BLOWFISH_CTR MBEDTLS_CIPHER_BLOWFISH_CTR +#define POLARSSL_CIPHER_BLOWFISH_ECB MBEDTLS_CIPHER_BLOWFISH_ECB +#define POLARSSL_CIPHER_CAMELLIA_128_CBC MBEDTLS_CIPHER_CAMELLIA_128_CBC +#define POLARSSL_CIPHER_CAMELLIA_128_CCM MBEDTLS_CIPHER_CAMELLIA_128_CCM +#define POLARSSL_CIPHER_CAMELLIA_128_CFB128 MBEDTLS_CIPHER_CAMELLIA_128_CFB128 +#define POLARSSL_CIPHER_CAMELLIA_128_CTR MBEDTLS_CIPHER_CAMELLIA_128_CTR +#define POLARSSL_CIPHER_CAMELLIA_128_ECB MBEDTLS_CIPHER_CAMELLIA_128_ECB +#define POLARSSL_CIPHER_CAMELLIA_128_GCM MBEDTLS_CIPHER_CAMELLIA_128_GCM +#define POLARSSL_CIPHER_CAMELLIA_192_CBC MBEDTLS_CIPHER_CAMELLIA_192_CBC +#define POLARSSL_CIPHER_CAMELLIA_192_CCM MBEDTLS_CIPHER_CAMELLIA_192_CCM +#define POLARSSL_CIPHER_CAMELLIA_192_CFB128 MBEDTLS_CIPHER_CAMELLIA_192_CFB128 +#define POLARSSL_CIPHER_CAMELLIA_192_CTR MBEDTLS_CIPHER_CAMELLIA_192_CTR +#define POLARSSL_CIPHER_CAMELLIA_192_ECB MBEDTLS_CIPHER_CAMELLIA_192_ECB +#define POLARSSL_CIPHER_CAMELLIA_192_GCM MBEDTLS_CIPHER_CAMELLIA_192_GCM +#define POLARSSL_CIPHER_CAMELLIA_256_CBC MBEDTLS_CIPHER_CAMELLIA_256_CBC +#define POLARSSL_CIPHER_CAMELLIA_256_CCM MBEDTLS_CIPHER_CAMELLIA_256_CCM +#define POLARSSL_CIPHER_CAMELLIA_256_CFB128 MBEDTLS_CIPHER_CAMELLIA_256_CFB128 +#define POLARSSL_CIPHER_CAMELLIA_256_CTR MBEDTLS_CIPHER_CAMELLIA_256_CTR +#define POLARSSL_CIPHER_CAMELLIA_256_ECB MBEDTLS_CIPHER_CAMELLIA_256_ECB +#define POLARSSL_CIPHER_CAMELLIA_256_GCM MBEDTLS_CIPHER_CAMELLIA_256_GCM +#define POLARSSL_CIPHER_DES_CBC MBEDTLS_CIPHER_DES_CBC +#define POLARSSL_CIPHER_DES_ECB MBEDTLS_CIPHER_DES_ECB +#define POLARSSL_CIPHER_DES_EDE3_CBC MBEDTLS_CIPHER_DES_EDE3_CBC +#define POLARSSL_CIPHER_DES_EDE3_ECB MBEDTLS_CIPHER_DES_EDE3_ECB +#define POLARSSL_CIPHER_DES_EDE_CBC MBEDTLS_CIPHER_DES_EDE_CBC +#define POLARSSL_CIPHER_DES_EDE_ECB MBEDTLS_CIPHER_DES_EDE_ECB +#define POLARSSL_CIPHER_H MBEDTLS_CIPHER_H +#define POLARSSL_CIPHER_ID_3DES MBEDTLS_CIPHER_ID_3DES +#define POLARSSL_CIPHER_ID_AES MBEDTLS_CIPHER_ID_AES +#define POLARSSL_CIPHER_ID_ARC4 MBEDTLS_CIPHER_ID_ARC4 +#define POLARSSL_CIPHER_ID_BLOWFISH MBEDTLS_CIPHER_ID_BLOWFISH +#define POLARSSL_CIPHER_ID_CAMELLIA MBEDTLS_CIPHER_ID_CAMELLIA +#define POLARSSL_CIPHER_ID_DES MBEDTLS_CIPHER_ID_DES +#define POLARSSL_CIPHER_ID_NONE MBEDTLS_CIPHER_ID_NONE +#define POLARSSL_CIPHER_ID_NULL MBEDTLS_CIPHER_ID_NULL +#define POLARSSL_CIPHER_MODE_AEAD MBEDTLS_CIPHER_MODE_AEAD +#define POLARSSL_CIPHER_MODE_STREAM MBEDTLS_CIPHER_MODE_STREAM +#define POLARSSL_CIPHER_MODE_WITH_PADDING MBEDTLS_CIPHER_MODE_WITH_PADDING +#define POLARSSL_CIPHER_NONE MBEDTLS_CIPHER_NONE +#define POLARSSL_CIPHER_NULL MBEDTLS_CIPHER_NULL +#define POLARSSL_CIPHER_VARIABLE_IV_LEN MBEDTLS_CIPHER_VARIABLE_IV_LEN +#define POLARSSL_CIPHER_VARIABLE_KEY_LEN MBEDTLS_CIPHER_VARIABLE_KEY_LEN +#define POLARSSL_CIPHER_WRAP_H MBEDTLS_CIPHER_WRAP_H +#define POLARSSL_CONFIG_H MBEDTLS_CONFIG_H +#define POLARSSL_CTR_DRBG_H MBEDTLS_CTR_DRBG_H +#define POLARSSL_DEBUG_H MBEDTLS_DEBUG_H +#define POLARSSL_DEBUG_LOG_FULL MBEDTLS_DEBUG_LOG_FULL +#define POLARSSL_DEBUG_LOG_RAW MBEDTLS_DEBUG_LOG_RAW +#define POLARSSL_DECRYPT MBEDTLS_DECRYPT +#define POLARSSL_DES_H MBEDTLS_DES_H +#define POLARSSL_DHM_H MBEDTLS_DHM_H +#define POLARSSL_DHM_RFC2409_MODP_1024_G MBEDTLS_DHM_RFC2409_MODP_1024_G +#define POLARSSL_DHM_RFC2409_MODP_1024_P MBEDTLS_DHM_RFC2409_MODP_1024_P +#define POLARSSL_DHM_RFC3526_MODP_2048_G MBEDTLS_DHM_RFC3526_MODP_2048_G +#define POLARSSL_DHM_RFC3526_MODP_2048_P MBEDTLS_DHM_RFC3526_MODP_2048_P +#define POLARSSL_DHM_RFC3526_MODP_3072_G MBEDTLS_DHM_RFC3526_MODP_3072_G +#define POLARSSL_DHM_RFC3526_MODP_3072_P MBEDTLS_DHM_RFC3526_MODP_3072_P +#define POLARSSL_DHM_RFC5114_MODP_1024_G MBEDTLS_DHM_RFC5114_MODP_1024_G +#define POLARSSL_DHM_RFC5114_MODP_1024_P MBEDTLS_DHM_RFC5114_MODP_1024_P +#define POLARSSL_DHM_RFC5114_MODP_2048_G MBEDTLS_DHM_RFC5114_MODP_2048_G +#define POLARSSL_DHM_RFC5114_MODP_2048_P MBEDTLS_DHM_RFC5114_MODP_2048_P +#define POLARSSL_ECDH_H MBEDTLS_ECDH_H +#define POLARSSL_ECDH_OURS MBEDTLS_ECDH_OURS +#define POLARSSL_ECDH_THEIRS MBEDTLS_ECDH_THEIRS +#define POLARSSL_ECDSA_H MBEDTLS_ECDSA_H +#define POLARSSL_ECP_DP_BP256R1 MBEDTLS_ECP_DP_BP256R1 +#define POLARSSL_ECP_DP_BP384R1 MBEDTLS_ECP_DP_BP384R1 +#define POLARSSL_ECP_DP_BP512R1 MBEDTLS_ECP_DP_BP512R1 +#define POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_CURVE25519 +#define POLARSSL_ECP_DP_MAX MBEDTLS_ECP_DP_MAX +#define POLARSSL_ECP_DP_NONE MBEDTLS_ECP_DP_NONE +#define POLARSSL_ECP_DP_SECP192K1 MBEDTLS_ECP_DP_SECP192K1 +#define POLARSSL_ECP_DP_SECP192R1 MBEDTLS_ECP_DP_SECP192R1 +#define POLARSSL_ECP_DP_SECP224K1 MBEDTLS_ECP_DP_SECP224K1 +#define POLARSSL_ECP_DP_SECP224R1 MBEDTLS_ECP_DP_SECP224R1 +#define POLARSSL_ECP_DP_SECP256K1 MBEDTLS_ECP_DP_SECP256K1 +#define POLARSSL_ECP_DP_SECP256R1 MBEDTLS_ECP_DP_SECP256R1 +#define POLARSSL_ECP_DP_SECP384R1 MBEDTLS_ECP_DP_SECP384R1 +#define POLARSSL_ECP_DP_SECP521R1 MBEDTLS_ECP_DP_SECP521R1 +#define POLARSSL_ECP_H MBEDTLS_ECP_H +#define POLARSSL_ECP_MAX_BYTES MBEDTLS_ECP_MAX_BYTES +#define POLARSSL_ECP_MAX_PT_LEN MBEDTLS_ECP_MAX_PT_LEN +#define POLARSSL_ECP_PF_COMPRESSED MBEDTLS_ECP_PF_COMPRESSED +#define POLARSSL_ECP_PF_UNCOMPRESSED MBEDTLS_ECP_PF_UNCOMPRESSED +#define POLARSSL_ECP_TLS_NAMED_CURVE MBEDTLS_ECP_TLS_NAMED_CURVE +#define POLARSSL_ENCRYPT MBEDTLS_ENCRYPT +#define POLARSSL_ENTROPY_H MBEDTLS_ENTROPY_H +#define POLARSSL_ENTROPY_POLL_H MBEDTLS_ENTROPY_POLL_H +#define POLARSSL_ENTROPY_SHA256_ACCUMULATOR MBEDTLS_ENTROPY_SHA256_ACCUMULATOR +#define POLARSSL_ENTROPY_SHA512_ACCUMULATOR MBEDTLS_ENTROPY_SHA512_ACCUMULATOR +#define POLARSSL_ERROR_H MBEDTLS_ERROR_H +#define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH +#define POLARSSL_ERR_AES_INVALID_KEY_LENGTH MBEDTLS_ERR_AES_INVALID_KEY_LENGTH +#define POLARSSL_ERR_ASN1_BUF_TOO_SMALL MBEDTLS_ERR_ASN1_BUF_TOO_SMALL +#define POLARSSL_ERR_ASN1_INVALID_DATA MBEDTLS_ERR_ASN1_INVALID_DATA +#define POLARSSL_ERR_ASN1_INVALID_LENGTH MBEDTLS_ERR_ASN1_INVALID_LENGTH +#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +#define POLARSSL_ERR_ASN1_MALLOC_FAILED MBEDTLS_ERR_ASN1_ALLOC_FAILED +#define POLARSSL_ERR_ASN1_OUT_OF_DATA MBEDTLS_ERR_ASN1_OUT_OF_DATA +#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL +#define POLARSSL_ERR_BASE64_INVALID_CHARACTER MBEDTLS_ERR_BASE64_INVALID_CHARACTER +#define POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH +#define POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH +#define POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH +#define POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH +#define POLARSSL_ERR_CCM_AUTH_FAILED MBEDTLS_ERR_CCM_AUTH_FAILED +#define POLARSSL_ERR_CCM_BAD_INPUT MBEDTLS_ERR_CCM_BAD_INPUT +#define POLARSSL_ERR_CIPHER_ALLOC_FAILED MBEDTLS_ERR_CIPHER_ALLOC_FAILED +#define POLARSSL_ERR_CIPHER_AUTH_FAILED MBEDTLS_ERR_CIPHER_AUTH_FAILED +#define POLARSSL_ERR_CIPHER_BAD_INPUT_DATA MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +#define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED +#define POLARSSL_ERR_CIPHER_INVALID_PADDING MBEDTLS_ERR_CIPHER_INVALID_PADDING +#define POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED +#define POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR +#define POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG +#define POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG +#define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH +#define POLARSSL_ERR_DHM_BAD_INPUT_DATA MBEDTLS_ERR_DHM_BAD_INPUT_DATA +#define POLARSSL_ERR_DHM_CALC_SECRET_FAILED MBEDTLS_ERR_DHM_CALC_SECRET_FAILED +#define POLARSSL_ERR_DHM_FILE_IO_ERROR MBEDTLS_ERR_DHM_FILE_IO_ERROR +#define POLARSSL_ERR_DHM_INVALID_FORMAT MBEDTLS_ERR_DHM_INVALID_FORMAT +#define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED +#define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED +#define POLARSSL_ERR_DHM_MALLOC_FAILED MBEDTLS_ERR_DHM_ALLOC_FAILED +#define POLARSSL_ERR_DHM_READ_PARAMS_FAILED MBEDTLS_ERR_DHM_READ_PARAMS_FAILED +#define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED +#define POLARSSL_ERR_ECP_BAD_INPUT_DATA MBEDTLS_ERR_ECP_BAD_INPUT_DATA +#define POLARSSL_ERR_ECP_BUFFER_TOO_SMALL MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL +#define POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_ECP_INVALID_KEY MBEDTLS_ERR_ECP_INVALID_KEY +#define POLARSSL_ERR_ECP_MALLOC_FAILED MBEDTLS_ERR_ECP_ALLOC_FAILED +#define POLARSSL_ERR_ECP_RANDOM_FAILED MBEDTLS_ERR_ECP_RANDOM_FAILED +#define POLARSSL_ERR_ECP_SIG_LEN_MISMATCH MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH +#define POLARSSL_ERR_ECP_VERIFY_FAILED MBEDTLS_ERR_ECP_VERIFY_FAILED +#define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR +#define POLARSSL_ERR_ENTROPY_MAX_SOURCES MBEDTLS_ERR_ENTROPY_MAX_SOURCES +#define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED +#define POLARSSL_ERR_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_ENTROPY_SOURCE_FAILED +#define POLARSSL_ERR_GCM_AUTH_FAILED MBEDTLS_ERR_GCM_AUTH_FAILED +#define POLARSSL_ERR_GCM_BAD_INPUT MBEDTLS_ERR_GCM_BAD_INPUT +#define POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED +#define POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR +#define POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG +#define POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG +#define POLARSSL_ERR_MD2_FILE_IO_ERROR MBEDTLS_ERR_MD2_FILE_IO_ERROR +#define POLARSSL_ERR_MD4_FILE_IO_ERROR MBEDTLS_ERR_MD4_FILE_IO_ERROR +#define POLARSSL_ERR_MD5_FILE_IO_ERROR MBEDTLS_ERR_MD5_FILE_IO_ERROR +#define POLARSSL_ERR_MD_ALLOC_FAILED MBEDTLS_ERR_MD_ALLOC_FAILED +#define POLARSSL_ERR_MD_BAD_INPUT_DATA MBEDTLS_ERR_MD_BAD_INPUT_DATA +#define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_MD_FILE_IO_ERROR MBEDTLS_ERR_MD_FILE_IO_ERROR +#define POLARSSL_ERR_MPI_BAD_INPUT_DATA MBEDTLS_ERR_MPI_BAD_INPUT_DATA +#define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL +#define POLARSSL_ERR_MPI_DIVISION_BY_ZERO MBEDTLS_ERR_MPI_DIVISION_BY_ZERO +#define POLARSSL_ERR_MPI_FILE_IO_ERROR MBEDTLS_ERR_MPI_FILE_IO_ERROR +#define POLARSSL_ERR_MPI_INVALID_CHARACTER MBEDTLS_ERR_MPI_INVALID_CHARACTER +#define POLARSSL_ERR_MPI_MALLOC_FAILED MBEDTLS_ERR_MPI_ALLOC_FAILED +#define POLARSSL_ERR_MPI_NEGATIVE_VALUE MBEDTLS_ERR_MPI_NEGATIVE_VALUE +#define POLARSSL_ERR_MPI_NOT_ACCEPTABLE MBEDTLS_ERR_MPI_NOT_ACCEPTABLE +#define POLARSSL_ERR_NET_ACCEPT_FAILED MBEDTLS_ERR_NET_ACCEPT_FAILED +#define POLARSSL_ERR_NET_BIND_FAILED MBEDTLS_ERR_NET_BIND_FAILED +#define POLARSSL_ERR_NET_CONNECT_FAILED MBEDTLS_ERR_NET_CONNECT_FAILED +#define POLARSSL_ERR_NET_CONN_RESET MBEDTLS_ERR_NET_CONN_RESET +#define POLARSSL_ERR_NET_LISTEN_FAILED MBEDTLS_ERR_NET_LISTEN_FAILED +#define POLARSSL_ERR_NET_RECV_FAILED MBEDTLS_ERR_NET_RECV_FAILED +#define POLARSSL_ERR_NET_SEND_FAILED MBEDTLS_ERR_NET_SEND_FAILED +#define POLARSSL_ERR_NET_SOCKET_FAILED MBEDTLS_ERR_NET_SOCKET_FAILED +#define POLARSSL_ERR_NET_TIMEOUT MBEDTLS_ERR_SSL_TIMEOUT +#define POLARSSL_ERR_NET_UNKNOWN_HOST MBEDTLS_ERR_NET_UNKNOWN_HOST +#define POLARSSL_ERR_NET_WANT_READ MBEDTLS_ERR_SSL_WANT_READ +#define POLARSSL_ERR_NET_WANT_WRITE MBEDTLS_ERR_SSL_WANT_WRITE +#define POLARSSL_ERR_OID_BUF_TOO_SMALL MBEDTLS_ERR_OID_BUF_TOO_SMALL +#define POLARSSL_ERR_OID_NOT_FOUND MBEDTLS_ERR_OID_NOT_FOUND +#define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED +#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA MBEDTLS_ERR_PBKDF2_BAD_INPUT_DATA +#define POLARSSL_ERR_PEM_BAD_INPUT_DATA MBEDTLS_ERR_PEM_BAD_INPUT_DATA +#define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_PEM_INVALID_DATA MBEDTLS_ERR_PEM_INVALID_DATA +#define POLARSSL_ERR_PEM_INVALID_ENC_IV MBEDTLS_ERR_PEM_INVALID_ENC_IV +#define POLARSSL_ERR_PEM_MALLOC_FAILED MBEDTLS_ERR_PEM_ALLOC_FAILED +#define POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT +#define POLARSSL_ERR_PEM_PASSWORD_MISMATCH MBEDTLS_ERR_PEM_PASSWORD_MISMATCH +#define POLARSSL_ERR_PEM_PASSWORD_REQUIRED MBEDTLS_ERR_PEM_PASSWORD_REQUIRED +#define POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG +#define POLARSSL_ERR_PKCS12_BAD_INPUT_DATA MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA +#define POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH +#define POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT +#define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA +#define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_PKCS5_INVALID_FORMAT MBEDTLS_ERR_PKCS5_INVALID_FORMAT +#define POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH +#define POLARSSL_ERR_PK_BAD_INPUT_DATA MBEDTLS_ERR_PK_BAD_INPUT_DATA +#define POLARSSL_ERR_PK_FEATURE_UNAVAILABLE MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_PK_FILE_IO_ERROR MBEDTLS_ERR_PK_FILE_IO_ERROR +#define POLARSSL_ERR_PK_INVALID_ALG MBEDTLS_ERR_PK_INVALID_ALG +#define POLARSSL_ERR_PK_INVALID_PUBKEY MBEDTLS_ERR_PK_INVALID_PUBKEY +#define POLARSSL_ERR_PK_KEY_INVALID_FORMAT MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +#define POLARSSL_ERR_PK_KEY_INVALID_VERSION MBEDTLS_ERR_PK_KEY_INVALID_VERSION +#define POLARSSL_ERR_PK_MALLOC_FAILED MBEDTLS_ERR_PK_ALLOC_FAILED +#define POLARSSL_ERR_PK_PASSWORD_MISMATCH MBEDTLS_ERR_PK_PASSWORD_MISMATCH +#define POLARSSL_ERR_PK_PASSWORD_REQUIRED MBEDTLS_ERR_PK_PASSWORD_REQUIRED +#define POLARSSL_ERR_PK_SIG_LEN_MISMATCH MBEDTLS_ERR_PK_SIG_LEN_MISMATCH +#define POLARSSL_ERR_PK_TYPE_MISMATCH MBEDTLS_ERR_PK_TYPE_MISMATCH +#define POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE +#define POLARSSL_ERR_PK_UNKNOWN_PK_ALG MBEDTLS_ERR_PK_UNKNOWN_PK_ALG +#define POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR +#define POLARSSL_ERR_RSA_BAD_INPUT_DATA MBEDTLS_ERR_RSA_BAD_INPUT_DATA +#define POLARSSL_ERR_RSA_INVALID_PADDING MBEDTLS_ERR_RSA_INVALID_PADDING +#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED MBEDTLS_ERR_RSA_KEY_CHECK_FAILED +#define POLARSSL_ERR_RSA_KEY_GEN_FAILED MBEDTLS_ERR_RSA_KEY_GEN_FAILED +#define POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE +#define POLARSSL_ERR_RSA_PRIVATE_FAILED MBEDTLS_ERR_RSA_PRIVATE_FAILED +#define POLARSSL_ERR_RSA_PUBLIC_FAILED MBEDTLS_ERR_RSA_PUBLIC_FAILED +#define POLARSSL_ERR_RSA_RNG_FAILED MBEDTLS_ERR_RSA_RNG_FAILED +#define POLARSSL_ERR_RSA_VERIFY_FAILED MBEDTLS_ERR_RSA_VERIFY_FAILED +#define POLARSSL_ERR_SHA1_FILE_IO_ERROR MBEDTLS_ERR_SHA1_FILE_IO_ERROR +#define POLARSSL_ERR_SHA256_FILE_IO_ERROR MBEDTLS_ERR_SHA256_FILE_IO_ERROR +#define POLARSSL_ERR_SHA512_FILE_IO_ERROR MBEDTLS_ERR_SHA512_FILE_IO_ERROR +#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE +#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST +#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY +#define POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC +#define POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO +#define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE +#define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS +#define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP +#define POLARSSL_ERR_SSL_BAD_HS_FINISHED MBEDTLS_ERR_SSL_BAD_HS_FINISHED +#define POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET +#define POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION +#define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO +#define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE +#define POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE +#define POLARSSL_ERR_SSL_BAD_INPUT_DATA MBEDTLS_ERR_SSL_BAD_INPUT_DATA +#define POLARSSL_ERR_SSL_BUFFER_TOO_SMALL MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL +#define POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED +#define POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED +#define POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE +#define POLARSSL_ERR_SSL_COMPRESSION_FAILED MBEDTLS_ERR_SSL_COMPRESSION_FAILED +#define POLARSSL_ERR_SSL_CONN_EOF MBEDTLS_ERR_SSL_CONN_EOF +#define POLARSSL_ERR_SSL_COUNTER_WRAPPING MBEDTLS_ERR_SSL_COUNTER_WRAPPING +#define POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE +#define POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_SSL_HELLO_VERIFY_REQUIRED MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED +#define POLARSSL_ERR_SSL_HW_ACCEL_FAILED MBEDTLS_ERR_SSL_HW_ACCEL_FAILED +#define POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH +#define POLARSSL_ERR_SSL_INTERNAL_ERROR MBEDTLS_ERR_SSL_INTERNAL_ERROR +#define POLARSSL_ERR_SSL_INVALID_MAC MBEDTLS_ERR_SSL_INVALID_MAC +#define POLARSSL_ERR_SSL_INVALID_RECORD MBEDTLS_ERR_SSL_INVALID_RECORD +#define POLARSSL_ERR_SSL_MALLOC_FAILED MBEDTLS_ERR_SSL_ALLOC_FAILED +#define POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN +#define POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE +#define POLARSSL_ERR_SSL_NO_RNG MBEDTLS_ERR_SSL_NO_RNG +#define POLARSSL_ERR_SSL_NO_USABLE_CIPHERSUITE MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE +#define POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY +#define POLARSSL_ERR_SSL_PEER_VERIFY_FAILED MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED +#define POLARSSL_ERR_SSL_PK_TYPE_MISMATCH MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH +#define POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED +#define POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED +#define POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE +#define POLARSSL_ERR_SSL_UNKNOWN_CIPHER MBEDTLS_ERR_SSL_UNKNOWN_CIPHER +#define POLARSSL_ERR_SSL_UNKNOWN_IDENTITY MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY +#define POLARSSL_ERR_SSL_WAITING_SERVER_HELLO_RENEGO MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO +#define POLARSSL_ERR_THREADING_BAD_INPUT_DATA MBEDTLS_ERR_THREADING_BAD_INPUT_DATA +#define POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_THREADING_MUTEX_ERROR MBEDTLS_ERR_THREADING_MUTEX_ERROR +#define POLARSSL_ERR_X509_BAD_INPUT_DATA MBEDTLS_ERR_X509_BAD_INPUT_DATA +#define POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT +#define POLARSSL_ERR_X509_CERT_VERIFY_FAILED MBEDTLS_ERR_X509_CERT_VERIFY_FAILED +#define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE +#define POLARSSL_ERR_X509_FILE_IO_ERROR MBEDTLS_ERR_X509_FILE_IO_ERROR +#define POLARSSL_ERR_X509_INVALID_ALG MBEDTLS_ERR_X509_INVALID_ALG +#define POLARSSL_ERR_X509_INVALID_DATE MBEDTLS_ERR_X509_INVALID_DATE +#define POLARSSL_ERR_X509_INVALID_EXTENSIONS MBEDTLS_ERR_X509_INVALID_EXTENSIONS +#define POLARSSL_ERR_X509_INVALID_FORMAT MBEDTLS_ERR_X509_INVALID_FORMAT +#define POLARSSL_ERR_X509_INVALID_NAME MBEDTLS_ERR_X509_INVALID_NAME +#define POLARSSL_ERR_X509_INVALID_SERIAL MBEDTLS_ERR_X509_INVALID_SERIAL +#define POLARSSL_ERR_X509_INVALID_SIGNATURE MBEDTLS_ERR_X509_INVALID_SIGNATURE +#define POLARSSL_ERR_X509_INVALID_VERSION MBEDTLS_ERR_X509_INVALID_VERSION +#define POLARSSL_ERR_X509_MALLOC_FAILED MBEDTLS_ERR_X509_ALLOC_FAILED +#define POLARSSL_ERR_X509_SIG_MISMATCH MBEDTLS_ERR_X509_SIG_MISMATCH +#define POLARSSL_ERR_X509_UNKNOWN_OID MBEDTLS_ERR_X509_UNKNOWN_OID +#define POLARSSL_ERR_X509_UNKNOWN_SIG_ALG MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG +#define POLARSSL_ERR_X509_UNKNOWN_VERSION MBEDTLS_ERR_X509_UNKNOWN_VERSION +#define POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH +#define POLARSSL_GCM_H MBEDTLS_GCM_H +#define POLARSSL_HAVEGE_H MBEDTLS_HAVEGE_H +#define POLARSSL_HAVE_INT32 MBEDTLS_HAVE_INT32 +#define POLARSSL_HAVE_INT64 MBEDTLS_HAVE_INT64 +#define POLARSSL_HAVE_UDBL MBEDTLS_HAVE_UDBL +#define POLARSSL_HAVE_X86 MBEDTLS_HAVE_X86 +#define POLARSSL_HAVE_X86_64 MBEDTLS_HAVE_X86_64 +#define POLARSSL_HMAC_DRBG_H MBEDTLS_HMAC_DRBG_H +#define POLARSSL_HMAC_DRBG_PR_OFF MBEDTLS_HMAC_DRBG_PR_OFF +#define POLARSSL_HMAC_DRBG_PR_ON MBEDTLS_HMAC_DRBG_PR_ON +#define POLARSSL_KEY_EXCHANGE_DHE_PSK MBEDTLS_KEY_EXCHANGE_DHE_PSK +#define POLARSSL_KEY_EXCHANGE_DHE_RSA MBEDTLS_KEY_EXCHANGE_DHE_RSA +#define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +#define POLARSSL_KEY_EXCHANGE_ECDHE_PSK MBEDTLS_KEY_EXCHANGE_ECDHE_PSK +#define POLARSSL_KEY_EXCHANGE_ECDHE_RSA MBEDTLS_KEY_EXCHANGE_ECDHE_RSA +#define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA +#define POLARSSL_KEY_EXCHANGE_ECDH_RSA MBEDTLS_KEY_EXCHANGE_ECDH_RSA +#define POLARSSL_KEY_EXCHANGE_NONE MBEDTLS_KEY_EXCHANGE_NONE +#define POLARSSL_KEY_EXCHANGE_PSK MBEDTLS_KEY_EXCHANGE_PSK +#define POLARSSL_KEY_EXCHANGE_RSA MBEDTLS_KEY_EXCHANGE_RSA +#define POLARSSL_KEY_EXCHANGE_RSA_PSK MBEDTLS_KEY_EXCHANGE_RSA_PSK +#define POLARSSL_KEY_EXCHANGE__SOME__ECDHE_ENABLED MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED +#define POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED +#define POLARSSL_KEY_EXCHANGE__WITH_CERT__ENABLED MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED +#define POLARSSL_KEY_LENGTH_DES MBEDTLS_KEY_LENGTH_DES +#define POLARSSL_KEY_LENGTH_DES_EDE MBEDTLS_KEY_LENGTH_DES_EDE +#define POLARSSL_KEY_LENGTH_DES_EDE3 MBEDTLS_KEY_LENGTH_DES_EDE3 +#define POLARSSL_KEY_LENGTH_NONE MBEDTLS_KEY_LENGTH_NONE +#define POLARSSL_MAX_BLOCK_LENGTH MBEDTLS_MAX_BLOCK_LENGTH +#define POLARSSL_MAX_IV_LENGTH MBEDTLS_MAX_IV_LENGTH +#define POLARSSL_MD2_H MBEDTLS_MD2_H +#define POLARSSL_MD4_H MBEDTLS_MD4_H +#define POLARSSL_MD5_H MBEDTLS_MD5_H +#define POLARSSL_MD_H MBEDTLS_MD_H +#define POLARSSL_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE +#define POLARSSL_MD_MD2 MBEDTLS_MD_MD2 +#define POLARSSL_MD_MD4 MBEDTLS_MD_MD4 +#define POLARSSL_MD_MD5 MBEDTLS_MD_MD5 +#define POLARSSL_MD_NONE MBEDTLS_MD_NONE +#define POLARSSL_MD_RIPEMD160 MBEDTLS_MD_RIPEMD160 +#define POLARSSL_MD_SHA1 MBEDTLS_MD_SHA1 +#define POLARSSL_MD_SHA224 MBEDTLS_MD_SHA224 +#define POLARSSL_MD_SHA256 MBEDTLS_MD_SHA256 +#define POLARSSL_MD_SHA384 MBEDTLS_MD_SHA384 +#define POLARSSL_MD_SHA512 MBEDTLS_MD_SHA512 +#define POLARSSL_MD_WRAP_H MBEDTLS_MD_WRAP_H +#define POLARSSL_MEMORY_BUFFER_ALLOC_H MBEDTLS_MEMORY_BUFFER_ALLOC_H +#define POLARSSL_MEMORY_H MBEDTLS_MEMORY_H +#define POLARSSL_MODE_CBC MBEDTLS_MODE_CBC +#define POLARSSL_MODE_CCM MBEDTLS_MODE_CCM +#define POLARSSL_MODE_CFB MBEDTLS_MODE_CFB +#define POLARSSL_MODE_CTR MBEDTLS_MODE_CTR +#define POLARSSL_MODE_ECB MBEDTLS_MODE_ECB +#define POLARSSL_MODE_GCM MBEDTLS_MODE_GCM +#define POLARSSL_MODE_NONE MBEDTLS_MODE_NONE +#define POLARSSL_MODE_OFB MBEDTLS_MODE_OFB +#define POLARSSL_MODE_STREAM MBEDTLS_MODE_STREAM +#define POLARSSL_MPI_MAX_BITS MBEDTLS_MPI_MAX_BITS +#define POLARSSL_MPI_MAX_BITS_SCALE100 MBEDTLS_MPI_MAX_BITS_SCALE100 +#define POLARSSL_MPI_MAX_LIMBS MBEDTLS_MPI_MAX_LIMBS +#define POLARSSL_MPI_RW_BUFFER_SIZE MBEDTLS_MPI_RW_BUFFER_SIZE +#define POLARSSL_NET_H MBEDTLS_NET_H +#define POLARSSL_NET_LISTEN_BACKLOG MBEDTLS_NET_LISTEN_BACKLOG +#define POLARSSL_OID_H MBEDTLS_OID_H +#define POLARSSL_OPERATION_NONE MBEDTLS_OPERATION_NONE +#define POLARSSL_PADDING_NONE MBEDTLS_PADDING_NONE +#define POLARSSL_PADDING_ONE_AND_ZEROS MBEDTLS_PADDING_ONE_AND_ZEROS +#define POLARSSL_PADDING_PKCS7 MBEDTLS_PADDING_PKCS7 +#define POLARSSL_PADDING_ZEROS MBEDTLS_PADDING_ZEROS +#define POLARSSL_PADDING_ZEROS_AND_LEN MBEDTLS_PADDING_ZEROS_AND_LEN +#define POLARSSL_PADLOCK_H MBEDTLS_PADLOCK_H +#define POLARSSL_PBKDF2_H MBEDTLS_PBKDF2_H +#define POLARSSL_PEM_H MBEDTLS_PEM_H +#define POLARSSL_PKCS11_H MBEDTLS_PKCS11_H +#define POLARSSL_PKCS12_H MBEDTLS_PKCS12_H +#define POLARSSL_PKCS5_H MBEDTLS_PKCS5_H +#define POLARSSL_PK_DEBUG_ECP MBEDTLS_PK_DEBUG_ECP +#define POLARSSL_PK_DEBUG_MAX_ITEMS MBEDTLS_PK_DEBUG_MAX_ITEMS +#define POLARSSL_PK_DEBUG_MPI MBEDTLS_PK_DEBUG_MPI +#define POLARSSL_PK_DEBUG_NONE MBEDTLS_PK_DEBUG_NONE +#define POLARSSL_PK_ECDSA MBEDTLS_PK_ECDSA +#define POLARSSL_PK_ECKEY MBEDTLS_PK_ECKEY +#define POLARSSL_PK_ECKEY_DH MBEDTLS_PK_ECKEY_DH +#define POLARSSL_PK_H MBEDTLS_PK_H +#define POLARSSL_PK_NONE MBEDTLS_PK_NONE +#define POLARSSL_PK_RSA MBEDTLS_PK_RSA +#define POLARSSL_PK_RSASSA_PSS MBEDTLS_PK_RSASSA_PSS +#define POLARSSL_PK_RSA_ALT MBEDTLS_PK_RSA_ALT +#define POLARSSL_PK_WRAP_H MBEDTLS_PK_WRAP_H +#define POLARSSL_PLATFORM_H MBEDTLS_PLATFORM_H +#define POLARSSL_PREMASTER_SIZE MBEDTLS_PREMASTER_SIZE +#define POLARSSL_RIPEMD160_H MBEDTLS_RIPEMD160_H +#define POLARSSL_RSA_H MBEDTLS_RSA_H +#define POLARSSL_SHA1_H MBEDTLS_SHA1_H +#define POLARSSL_SHA256_H MBEDTLS_SHA256_H +#define POLARSSL_SHA512_H MBEDTLS_SHA512_H +#define POLARSSL_SSL_CACHE_H MBEDTLS_SSL_CACHE_H +#define POLARSSL_SSL_CIPHERSUITES_H MBEDTLS_SSL_CIPHERSUITES_H +#define POLARSSL_SSL_COOKIE_H MBEDTLS_SSL_COOKIE_H +#define POLARSSL_SSL_H MBEDTLS_SSL_H +#define POLARSSL_THREADING_H MBEDTLS_THREADING_H +#define POLARSSL_THREADING_IMPL MBEDTLS_THREADING_IMPL +#define POLARSSL_TIMING_H MBEDTLS_TIMING_H +#define POLARSSL_VERSION_H MBEDTLS_VERSION_H +#define POLARSSL_VERSION_MAJOR MBEDTLS_VERSION_MAJOR +#define POLARSSL_VERSION_MINOR MBEDTLS_VERSION_MINOR +#define POLARSSL_VERSION_NUMBER MBEDTLS_VERSION_NUMBER +#define POLARSSL_VERSION_PATCH MBEDTLS_VERSION_PATCH +#define POLARSSL_VERSION_STRING MBEDTLS_VERSION_STRING +#define POLARSSL_VERSION_STRING_FULL MBEDTLS_VERSION_STRING_FULL +#define POLARSSL_X509_CRL_H MBEDTLS_X509_CRL_H +#define POLARSSL_X509_CRT_H MBEDTLS_X509_CRT_H +#define POLARSSL_X509_CSR_H MBEDTLS_X509_CSR_H +#define POLARSSL_X509_H MBEDTLS_X509_H +#define POLARSSL_XTEA_H MBEDTLS_XTEA_H +#define RSA_CRYPT MBEDTLS_RSA_CRYPT +#define RSA_PKCS_V15 MBEDTLS_RSA_PKCS_V15 +#define RSA_PKCS_V21 MBEDTLS_RSA_PKCS_V21 +#define RSA_PRIVATE MBEDTLS_RSA_PRIVATE +#define RSA_PUBLIC MBEDTLS_RSA_PUBLIC +#define RSA_SALT_LEN_ANY MBEDTLS_RSA_SALT_LEN_ANY +#define RSA_SIGN MBEDTLS_RSA_SIGN +#define SSL_ALERT_LEVEL_FATAL MBEDTLS_SSL_ALERT_LEVEL_FATAL +#define SSL_ALERT_LEVEL_WARNING MBEDTLS_SSL_ALERT_LEVEL_WARNING +#define SSL_ALERT_MSG_ACCESS_DENIED MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED +#define SSL_ALERT_MSG_BAD_CERT MBEDTLS_SSL_ALERT_MSG_BAD_CERT +#define SSL_ALERT_MSG_BAD_RECORD_MAC MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC +#define SSL_ALERT_MSG_CERT_EXPIRED MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED +#define SSL_ALERT_MSG_CERT_REVOKED MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED +#define SSL_ALERT_MSG_CERT_UNKNOWN MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN +#define SSL_ALERT_MSG_CLOSE_NOTIFY MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY +#define SSL_ALERT_MSG_DECODE_ERROR MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR +#define SSL_ALERT_MSG_DECOMPRESSION_FAILURE MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE +#define SSL_ALERT_MSG_DECRYPTION_FAILED MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED +#define SSL_ALERT_MSG_DECRYPT_ERROR MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR +#define SSL_ALERT_MSG_EXPORT_RESTRICTION MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION +#define SSL_ALERT_MSG_HANDSHAKE_FAILURE MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE +#define SSL_ALERT_MSG_ILLEGAL_PARAMETER MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER +#define SSL_ALERT_MSG_INAPROPRIATE_FALLBACK MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK +#define SSL_ALERT_MSG_INSUFFICIENT_SECURITY MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY +#define SSL_ALERT_MSG_INTERNAL_ERROR MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR +#define SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL +#define SSL_ALERT_MSG_NO_CERT MBEDTLS_SSL_ALERT_MSG_NO_CERT +#define SSL_ALERT_MSG_NO_RENEGOTIATION MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION +#define SSL_ALERT_MSG_PROTOCOL_VERSION MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION +#define SSL_ALERT_MSG_RECORD_OVERFLOW MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW +#define SSL_ALERT_MSG_UNEXPECTED_MESSAGE MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE +#define SSL_ALERT_MSG_UNKNOWN_CA MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA +#define SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY +#define SSL_ALERT_MSG_UNRECOGNIZED_NAME MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME +#define SSL_ALERT_MSG_UNSUPPORTED_CERT MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT +#define SSL_ALERT_MSG_UNSUPPORTED_EXT MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT +#define SSL_ALERT_MSG_USER_CANCELED MBEDTLS_SSL_ALERT_MSG_USER_CANCELED +#define SSL_ANTI_REPLAY_DISABLED MBEDTLS_SSL_ANTI_REPLAY_DISABLED +#define SSL_ANTI_REPLAY_ENABLED MBEDTLS_SSL_ANTI_REPLAY_ENABLED +#define SSL_ARC4_DISABLED MBEDTLS_SSL_ARC4_DISABLED +#define SSL_ARC4_ENABLED MBEDTLS_SSL_ARC4_ENABLED +#define SSL_BUFFER_LEN MBEDTLS_SSL_BUFFER_LEN +#define SSL_CACHE_DEFAULT_MAX_ENTRIES MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES +#define SSL_CACHE_DEFAULT_TIMEOUT MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT +#define SSL_CBC_RECORD_SPLITTING_DISABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED +#define SSL_CBC_RECORD_SPLITTING_ENABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED +#define SSL_CERTIFICATE_REQUEST MBEDTLS_SSL_CERTIFICATE_REQUEST +#define SSL_CERTIFICATE_VERIFY MBEDTLS_SSL_CERTIFICATE_VERIFY +#define SSL_CERT_TYPE_ECDSA_SIGN MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN +#define SSL_CERT_TYPE_RSA_SIGN MBEDTLS_SSL_CERT_TYPE_RSA_SIGN +#define SSL_CHANNEL_INBOUND MBEDTLS_SSL_CHANNEL_INBOUND +#define SSL_CHANNEL_OUTBOUND MBEDTLS_SSL_CHANNEL_OUTBOUND +#define SSL_CIPHERSUITES MBEDTLS_SSL_CIPHERSUITES +#define SSL_CLIENT_CERTIFICATE MBEDTLS_SSL_CLIENT_CERTIFICATE +#define SSL_CLIENT_CHANGE_CIPHER_SPEC MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC +#define SSL_CLIENT_FINISHED MBEDTLS_SSL_CLIENT_FINISHED +#define SSL_CLIENT_HELLO MBEDTLS_SSL_CLIENT_HELLO +#define SSL_CLIENT_KEY_EXCHANGE MBEDTLS_SSL_CLIENT_KEY_EXCHANGE +#define SSL_COMPRESSION_ADD MBEDTLS_SSL_COMPRESSION_ADD +#define SSL_COMPRESS_DEFLATE MBEDTLS_SSL_COMPRESS_DEFLATE +#define SSL_COMPRESS_NULL MBEDTLS_SSL_COMPRESS_NULL +#define SSL_DEBUG_BUF MBEDTLS_SSL_DEBUG_BUF +#define SSL_DEBUG_CRT MBEDTLS_SSL_DEBUG_CRT +#define SSL_DEBUG_ECP MBEDTLS_SSL_DEBUG_ECP +#define SSL_DEBUG_MPI MBEDTLS_SSL_DEBUG_MPI +#define SSL_DEBUG_MSG MBEDTLS_SSL_DEBUG_MSG +#define SSL_DEBUG_RET MBEDTLS_SSL_DEBUG_RET +#define SSL_DEFAULT_TICKET_LIFETIME MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME +#define SSL_DTLS_TIMEOUT_DFL_MAX MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX +#define SSL_DTLS_TIMEOUT_DFL_MIN MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN +#define SSL_EMPTY_RENEGOTIATION_INFO MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO +#define SSL_ETM_DISABLED MBEDTLS_SSL_ETM_DISABLED +#define SSL_ETM_ENABLED MBEDTLS_SSL_ETM_ENABLED +#define SSL_EXTENDED_MS_DISABLED MBEDTLS_SSL_EXTENDED_MS_DISABLED +#define SSL_EXTENDED_MS_ENABLED MBEDTLS_SSL_EXTENDED_MS_ENABLED +#define SSL_FALLBACK_SCSV MBEDTLS_SSL_FALLBACK_SCSV +#define SSL_FLUSH_BUFFERS MBEDTLS_SSL_FLUSH_BUFFERS +#define SSL_HANDSHAKE_OVER MBEDTLS_SSL_HANDSHAKE_OVER +#define SSL_HANDSHAKE_WRAPUP MBEDTLS_SSL_HANDSHAKE_WRAPUP +#define SSL_HASH_MD5 MBEDTLS_SSL_HASH_MD5 +#define SSL_HASH_NONE MBEDTLS_SSL_HASH_NONE +#define SSL_HASH_SHA1 MBEDTLS_SSL_HASH_SHA1 +#define SSL_HASH_SHA224 MBEDTLS_SSL_HASH_SHA224 +#define SSL_HASH_SHA256 MBEDTLS_SSL_HASH_SHA256 +#define SSL_HASH_SHA384 MBEDTLS_SSL_HASH_SHA384 +#define SSL_HASH_SHA512 MBEDTLS_SSL_HASH_SHA512 +#define SSL_HELLO_REQUEST MBEDTLS_SSL_HELLO_REQUEST +#define SSL_HS_CERTIFICATE MBEDTLS_SSL_HS_CERTIFICATE +#define SSL_HS_CERTIFICATE_REQUEST MBEDTLS_SSL_HS_CERTIFICATE_REQUEST +#define SSL_HS_CERTIFICATE_VERIFY MBEDTLS_SSL_HS_CERTIFICATE_VERIFY +#define SSL_HS_CLIENT_HELLO MBEDTLS_SSL_HS_CLIENT_HELLO +#define SSL_HS_CLIENT_KEY_EXCHANGE MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE +#define SSL_HS_FINISHED MBEDTLS_SSL_HS_FINISHED +#define SSL_HS_HELLO_REQUEST MBEDTLS_SSL_HS_HELLO_REQUEST +#define SSL_HS_HELLO_VERIFY_REQUEST MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST +#define SSL_HS_NEW_SESSION_TICKET MBEDTLS_SSL_HS_NEW_SESSION_TICKET +#define SSL_HS_SERVER_HELLO MBEDTLS_SSL_HS_SERVER_HELLO +#define SSL_HS_SERVER_HELLO_DONE MBEDTLS_SSL_HS_SERVER_HELLO_DONE +#define SSL_HS_SERVER_KEY_EXCHANGE MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE +#define SSL_INITIAL_HANDSHAKE MBEDTLS_SSL_INITIAL_HANDSHAKE +#define SSL_IS_CLIENT MBEDTLS_SSL_IS_CLIENT +#define SSL_IS_FALLBACK MBEDTLS_SSL_IS_FALLBACK +#define SSL_IS_NOT_FALLBACK MBEDTLS_SSL_IS_NOT_FALLBACK +#define SSL_IS_SERVER MBEDTLS_SSL_IS_SERVER +#define SSL_LEGACY_ALLOW_RENEGOTIATION MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION +#define SSL_LEGACY_BREAK_HANDSHAKE MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE +#define SSL_LEGACY_NO_RENEGOTIATION MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION +#define SSL_LEGACY_RENEGOTIATION MBEDTLS_SSL_LEGACY_RENEGOTIATION +#define SSL_MAC_ADD MBEDTLS_SSL_MAC_ADD +#define SSL_MAJOR_VERSION_3 MBEDTLS_SSL_MAJOR_VERSION_3 +#define SSL_MAX_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN +#define SSL_MAX_FRAG_LEN_1024 MBEDTLS_SSL_MAX_FRAG_LEN_1024 +#define SSL_MAX_FRAG_LEN_2048 MBEDTLS_SSL_MAX_FRAG_LEN_2048 +#define SSL_MAX_FRAG_LEN_4096 MBEDTLS_SSL_MAX_FRAG_LEN_4096 +#define SSL_MAX_FRAG_LEN_512 MBEDTLS_SSL_MAX_FRAG_LEN_512 +#define SSL_MAX_FRAG_LEN_INVALID MBEDTLS_SSL_MAX_FRAG_LEN_INVALID +#define SSL_MAX_FRAG_LEN_NONE MBEDTLS_SSL_MAX_FRAG_LEN_NONE +#define SSL_MAX_MAJOR_VERSION MBEDTLS_SSL_MAX_MAJOR_VERSION +#define SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MAX_MINOR_VERSION +#define SSL_MINOR_VERSION_0 MBEDTLS_SSL_MINOR_VERSION_0 +#define SSL_MINOR_VERSION_1 MBEDTLS_SSL_MINOR_VERSION_1 +#define SSL_MINOR_VERSION_2 MBEDTLS_SSL_MINOR_VERSION_2 +#define SSL_MINOR_VERSION_3 MBEDTLS_SSL_MINOR_VERSION_3 +#define SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MIN_MAJOR_VERSION +#define SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MIN_MINOR_VERSION +#define SSL_MSG_ALERT MBEDTLS_SSL_MSG_ALERT +#define SSL_MSG_APPLICATION_DATA MBEDTLS_SSL_MSG_APPLICATION_DATA +#define SSL_MSG_CHANGE_CIPHER_SPEC MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC +#define SSL_MSG_HANDSHAKE MBEDTLS_SSL_MSG_HANDSHAKE +#define SSL_PADDING_ADD MBEDTLS_SSL_PADDING_ADD +#define SSL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION +#define SSL_RENEGOTIATION_DISABLED MBEDTLS_SSL_RENEGOTIATION_DISABLED +#define SSL_RENEGOTIATION_DONE MBEDTLS_SSL_RENEGOTIATION_DONE +#define SSL_RENEGOTIATION_ENABLED MBEDTLS_SSL_RENEGOTIATION_ENABLED +#define SSL_RENEGOTIATION_NOT_ENFORCED MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED +#define SSL_RENEGOTIATION_PENDING MBEDTLS_SSL_RENEGOTIATION_PENDING +#define SSL_RENEGO_MAX_RECORDS_DEFAULT MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT +#define SSL_RETRANS_FINISHED MBEDTLS_SSL_RETRANS_FINISHED +#define SSL_RETRANS_PREPARING MBEDTLS_SSL_RETRANS_PREPARING +#define SSL_RETRANS_SENDING MBEDTLS_SSL_RETRANS_SENDING +#define SSL_RETRANS_WAITING MBEDTLS_SSL_RETRANS_WAITING +#define SSL_SECURE_RENEGOTIATION MBEDTLS_SSL_SECURE_RENEGOTIATION +#define SSL_SERVER_CERTIFICATE MBEDTLS_SSL_SERVER_CERTIFICATE +#define SSL_SERVER_CHANGE_CIPHER_SPEC MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC +#define SSL_SERVER_FINISHED MBEDTLS_SSL_SERVER_FINISHED +#define SSL_SERVER_HELLO MBEDTLS_SSL_SERVER_HELLO +#define SSL_SERVER_HELLO_DONE MBEDTLS_SSL_SERVER_HELLO_DONE +#define SSL_SERVER_HELLO_VERIFY_REQUEST_SENT MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT +#define SSL_SERVER_KEY_EXCHANGE MBEDTLS_SSL_SERVER_KEY_EXCHANGE +#define SSL_SERVER_NEW_SESSION_TICKET MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET +#define SSL_SESSION_TICKETS_DISABLED MBEDTLS_SSL_SESSION_TICKETS_DISABLED +#define SSL_SESSION_TICKETS_ENABLED MBEDTLS_SSL_SESSION_TICKETS_ENABLED +#define SSL_SIG_ANON MBEDTLS_SSL_SIG_ANON +#define SSL_SIG_ECDSA MBEDTLS_SSL_SIG_ECDSA +#define SSL_SIG_RSA MBEDTLS_SSL_SIG_RSA +#define SSL_TRANSPORT_DATAGRAM MBEDTLS_SSL_TRANSPORT_DATAGRAM +#define SSL_TRANSPORT_STREAM MBEDTLS_SSL_TRANSPORT_STREAM +#define SSL_TRUNCATED_HMAC_LEN MBEDTLS_SSL_TRUNCATED_HMAC_LEN +#define SSL_TRUNC_HMAC_DISABLED MBEDTLS_SSL_TRUNC_HMAC_DISABLED +#define SSL_TRUNC_HMAC_ENABLED MBEDTLS_SSL_TRUNC_HMAC_ENABLED +#define SSL_VERIFY_DATA_MAX_LEN MBEDTLS_SSL_VERIFY_DATA_MAX_LEN +#define SSL_VERIFY_NONE MBEDTLS_SSL_VERIFY_NONE +#define SSL_VERIFY_OPTIONAL MBEDTLS_SSL_VERIFY_OPTIONAL +#define SSL_VERIFY_REQUIRED MBEDTLS_SSL_VERIFY_REQUIRED +#define TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA +#define TLS_DHE_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA +#define TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 +#define TLS_DHE_PSK_WITH_AES_128_CCM MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM +#define TLS_DHE_PSK_WITH_AES_128_CCM_8 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8 +#define TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 +#define TLS_DHE_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA +#define TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 +#define TLS_DHE_PSK_WITH_AES_256_CCM MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM +#define TLS_DHE_PSK_WITH_AES_256_CCM_8 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8 +#define TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 +#define TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_DHE_PSK_WITH_NULL_SHA MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA +#define TLS_DHE_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 +#define TLS_DHE_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 +#define TLS_DHE_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA +#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA +#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA +#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 +#define TLS_DHE_RSA_WITH_AES_128_CCM MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM +#define TLS_DHE_RSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8 +#define TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 +#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA +#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 +#define TLS_DHE_RSA_WITH_AES_256_CCM MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM +#define TLS_DHE_RSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8 +#define TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 +#define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA +#define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA +#define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 +#define TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_DHE_RSA_WITH_DES_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA +#define TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA +#define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA +#define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 +#define TLS_ECDHE_ECDSA_WITH_AES_128_CCM MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM +#define TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 +#define TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 +#define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA +#define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 +#define TLS_ECDHE_ECDSA_WITH_AES_256_CCM MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM +#define TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 +#define TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 +#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_ECDHE_ECDSA_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA +#define TLS_ECDHE_ECDSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA +#define TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA +#define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA +#define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 +#define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA +#define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 +#define TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_ECDHE_PSK_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA +#define TLS_ECDHE_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 +#define TLS_ECDHE_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 +#define TLS_ECDHE_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA +#define TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA +#define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA +#define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 +#define TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 +#define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA +#define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 +#define TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 +#define TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_ECDHE_RSA_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA +#define TLS_ECDHE_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA +#define TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA +#define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA +#define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 +#define TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 +#define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA +#define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 +#define TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 +#define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_ECDH_ECDSA_WITH_NULL_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA +#define TLS_ECDH_ECDSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA +#define TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA +#define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA +#define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 +#define TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 +#define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA +#define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 +#define TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 +#define TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_ECDH_RSA_WITH_NULL_SHA MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA +#define TLS_ECDH_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA +#define TLS_EXT_ALPN MBEDTLS_TLS_EXT_ALPN +#define TLS_EXT_ENCRYPT_THEN_MAC MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC +#define TLS_EXT_EXTENDED_MASTER_SECRET MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET +#define TLS_EXT_MAX_FRAGMENT_LENGTH MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH +#define TLS_EXT_RENEGOTIATION_INFO MBEDTLS_TLS_EXT_RENEGOTIATION_INFO +#define TLS_EXT_SERVERNAME MBEDTLS_TLS_EXT_SERVERNAME +#define TLS_EXT_SERVERNAME_HOSTNAME MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME +#define TLS_EXT_SESSION_TICKET MBEDTLS_TLS_EXT_SESSION_TICKET +#define TLS_EXT_SIG_ALG MBEDTLS_TLS_EXT_SIG_ALG +#define TLS_EXT_SUPPORTED_ELLIPTIC_CURVES MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES +#define TLS_EXT_SUPPORTED_POINT_FORMATS MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS +#define TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT +#define TLS_EXT_TRUNCATED_HMAC MBEDTLS_TLS_EXT_TRUNCATED_HMAC +#define TLS_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA +#define TLS_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA +#define TLS_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 +#define TLS_PSK_WITH_AES_128_CCM MBEDTLS_TLS_PSK_WITH_AES_128_CCM +#define TLS_PSK_WITH_AES_128_CCM_8 MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 +#define TLS_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 +#define TLS_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA +#define TLS_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 +#define TLS_PSK_WITH_AES_256_CCM MBEDTLS_TLS_PSK_WITH_AES_256_CCM +#define TLS_PSK_WITH_AES_256_CCM_8 MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8 +#define TLS_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 +#define TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_PSK_WITH_NULL_SHA MBEDTLS_TLS_PSK_WITH_NULL_SHA +#define TLS_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_PSK_WITH_NULL_SHA256 +#define TLS_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_PSK_WITH_NULL_SHA384 +#define TLS_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_PSK_WITH_RC4_128_SHA +#define TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA +#define TLS_RSA_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA +#define TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 +#define TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 +#define TLS_RSA_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA +#define TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 +#define TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 +#define TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 +#define TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_RSA_PSK_WITH_NULL_SHA MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA +#define TLS_RSA_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 +#define TLS_RSA_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 +#define TLS_RSA_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA +#define TLS_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA +#define TLS_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA +#define TLS_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 +#define TLS_RSA_WITH_AES_128_CCM MBEDTLS_TLS_RSA_WITH_AES_128_CCM +#define TLS_RSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8 +#define TLS_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 +#define TLS_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA +#define TLS_RSA_WITH_AES_256_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 +#define TLS_RSA_WITH_AES_256_CCM MBEDTLS_TLS_RSA_WITH_AES_256_CCM +#define TLS_RSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8 +#define TLS_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 +#define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA +#define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 +#define TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 +#define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA +#define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 +#define TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 +#define TLS_RSA_WITH_DES_CBC_SHA MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA +#define TLS_RSA_WITH_NULL_MD5 MBEDTLS_TLS_RSA_WITH_NULL_MD5 +#define TLS_RSA_WITH_NULL_SHA MBEDTLS_TLS_RSA_WITH_NULL_SHA +#define TLS_RSA_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_WITH_NULL_SHA256 +#define TLS_RSA_WITH_RC4_128_MD5 MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 +#define TLS_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_WITH_RC4_128_SHA +#define UL64 MBEDTLS_UL64 +#define X509_CRT_VERSION_1 MBEDTLS_X509_CRT_VERSION_1 +#define X509_CRT_VERSION_2 MBEDTLS_X509_CRT_VERSION_2 +#define X509_CRT_VERSION_3 MBEDTLS_X509_CRT_VERSION_3 +#define X509_FORMAT_DER MBEDTLS_X509_FORMAT_DER +#define X509_FORMAT_PEM MBEDTLS_X509_FORMAT_PEM +#define X509_MAX_DN_NAME_SIZE MBEDTLS_X509_MAX_DN_NAME_SIZE +#define X509_RFC5280_MAX_SERIAL_LEN MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN +#define X509_RFC5280_UTC_TIME_LEN MBEDTLS_X509_RFC5280_UTC_TIME_LEN +#define XTEA_DECRYPT MBEDTLS_XTEA_DECRYPT +#define XTEA_ENCRYPT MBEDTLS_XTEA_ENCRYPT +#define _asn1_bitstring mbedtls_asn1_bitstring +#define _asn1_buf mbedtls_asn1_buf +#define _asn1_named_data mbedtls_asn1_named_data +#define _asn1_sequence mbedtls_asn1_sequence +#define _ssl_cache_context mbedtls_ssl_cache_context +#define _ssl_cache_entry mbedtls_ssl_cache_entry +#define _ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t +#define _ssl_context mbedtls_ssl_context +#define _ssl_flight_item mbedtls_ssl_flight_item +#define _ssl_handshake_params mbedtls_ssl_handshake_params +#define _ssl_key_cert mbedtls_ssl_key_cert +#define _ssl_premaster_secret mbedtls_ssl_premaster_secret +#define _ssl_session mbedtls_ssl_session +#define _ssl_ticket_keys mbedtls_ssl_ticket_keys +#define _ssl_transform mbedtls_ssl_transform +#define _x509_crl mbedtls_x509_crl +#define _x509_crl_entry mbedtls_x509_crl_entry +#define _x509_crt mbedtls_x509_crt +#define _x509_csr mbedtls_x509_csr +#define _x509_time mbedtls_x509_time +#define _x509write_cert mbedtls_x509write_cert +#define _x509write_csr mbedtls_x509write_csr +#define aes_context mbedtls_aes_context +#define aes_crypt_cbc mbedtls_aes_crypt_cbc +#define aes_crypt_cfb128 mbedtls_aes_crypt_cfb128 +#define aes_crypt_cfb8 mbedtls_aes_crypt_cfb8 +#define aes_crypt_ctr mbedtls_aes_crypt_ctr +#define aes_crypt_ecb mbedtls_aes_crypt_ecb +#define aes_free mbedtls_aes_free +#define aes_init mbedtls_aes_init +#define aes_self_test mbedtls_aes_self_test +#define aes_setkey_dec mbedtls_aes_setkey_dec +#define aes_setkey_enc mbedtls_aes_setkey_enc +#define aesni_crypt_ecb mbedtls_aesni_crypt_ecb +#define aesni_gcm_mult mbedtls_aesni_gcm_mult +#define aesni_inverse_key mbedtls_aesni_inverse_key +#define aesni_setkey_enc mbedtls_aesni_setkey_enc +#define aesni_supports mbedtls_aesni_has_support +#define alarmed mbedtls_timing_alarmed +#define arc4_context mbedtls_arc4_context +#define arc4_crypt mbedtls_arc4_crypt +#define arc4_free mbedtls_arc4_free +#define arc4_init mbedtls_arc4_init +#define arc4_self_test mbedtls_arc4_self_test +#define arc4_setup mbedtls_arc4_setup +#define asn1_bitstring mbedtls_asn1_bitstring +#define asn1_buf mbedtls_asn1_buf +#define asn1_find_named_data mbedtls_asn1_find_named_data +#define asn1_free_named_data mbedtls_asn1_free_named_data +#define asn1_free_named_data_list mbedtls_asn1_free_named_data_list +#define asn1_get_alg mbedtls_asn1_get_alg +#define asn1_get_alg_null mbedtls_asn1_get_alg_null +#define asn1_get_bitstring mbedtls_asn1_get_bitstring +#define asn1_get_bitstring_null mbedtls_asn1_get_bitstring_null +#define asn1_get_bool mbedtls_asn1_get_bool +#define asn1_get_int mbedtls_asn1_get_int +#define asn1_get_len mbedtls_asn1_get_len +#define asn1_get_mpi mbedtls_asn1_get_mpi +#define asn1_get_sequence_of mbedtls_asn1_get_sequence_of +#define asn1_get_tag mbedtls_asn1_get_tag +#define asn1_named_data mbedtls_asn1_named_data +#define asn1_sequence mbedtls_asn1_sequence +#define asn1_store_named_data mbedtls_asn1_store_named_data +#define asn1_write_algorithm_identifier mbedtls_asn1_write_algorithm_identifier +#define asn1_write_bitstring mbedtls_asn1_write_bitstring +#define asn1_write_bool mbedtls_asn1_write_bool +#define asn1_write_ia5_string mbedtls_asn1_write_ia5_string +#define asn1_write_int mbedtls_asn1_write_int +#define asn1_write_len mbedtls_asn1_write_len +#define asn1_write_mpi mbedtls_asn1_write_mpi +#define asn1_write_null mbedtls_asn1_write_null +#define asn1_write_octet_string mbedtls_asn1_write_octet_string +#define asn1_write_oid mbedtls_asn1_write_oid +#define asn1_write_printable_string mbedtls_asn1_write_printable_string +#define asn1_write_raw_buffer mbedtls_asn1_write_raw_buffer +#define asn1_write_tag mbedtls_asn1_write_tag +#define base64_decode mbedtls_base64_decode +#define base64_encode mbedtls_base64_encode +#define base64_self_test mbedtls_base64_self_test +#define blowfish_context mbedtls_blowfish_context +#define blowfish_crypt_cbc mbedtls_blowfish_crypt_cbc +#define blowfish_crypt_cfb64 mbedtls_blowfish_crypt_cfb64 +#define blowfish_crypt_ctr mbedtls_blowfish_crypt_ctr +#define blowfish_crypt_ecb mbedtls_blowfish_crypt_ecb +#define blowfish_free mbedtls_blowfish_free +#define blowfish_init mbedtls_blowfish_init +#define blowfish_setkey mbedtls_blowfish_setkey +#define camellia_context mbedtls_camellia_context +#define camellia_crypt_cbc mbedtls_camellia_crypt_cbc +#define camellia_crypt_cfb128 mbedtls_camellia_crypt_cfb128 +#define camellia_crypt_ctr mbedtls_camellia_crypt_ctr +#define camellia_crypt_ecb mbedtls_camellia_crypt_ecb +#define camellia_free mbedtls_camellia_free +#define camellia_init mbedtls_camellia_init +#define camellia_self_test mbedtls_camellia_self_test +#define camellia_setkey_dec mbedtls_camellia_setkey_dec +#define camellia_setkey_enc mbedtls_camellia_setkey_enc +#define ccm_auth_decrypt mbedtls_ccm_auth_decrypt +#define ccm_context mbedtls_ccm_context +#define ccm_encrypt_and_tag mbedtls_ccm_encrypt_and_tag +#define ccm_free mbedtls_ccm_free +#define ccm_init mbedtls_ccm_init +#define ccm_self_test mbedtls_ccm_self_test +#define cipher_auth_decrypt mbedtls_cipher_auth_decrypt +#define cipher_auth_encrypt mbedtls_cipher_auth_encrypt +#define cipher_base_t mbedtls_cipher_base_t +#define cipher_check_tag mbedtls_cipher_check_tag +#define cipher_context_t mbedtls_cipher_context_t +#define cipher_crypt mbedtls_cipher_crypt +#define cipher_definition_t mbedtls_cipher_definition_t +#define cipher_definitions mbedtls_cipher_definitions +#define cipher_finish mbedtls_cipher_finish +#define cipher_free mbedtls_cipher_free +#define cipher_free_ctx mbedtls_cipher_free_ctx +#define cipher_get_block_size mbedtls_cipher_get_block_size +#define cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode +#define cipher_get_iv_size mbedtls_cipher_get_iv_size +#define cipher_get_key_size mbedtls_cipher_get_key_bitlen +#define cipher_get_name mbedtls_cipher_get_name +#define cipher_get_operation mbedtls_cipher_get_operation +#define cipher_get_type mbedtls_cipher_get_type +#define cipher_id_t mbedtls_cipher_id_t +#define cipher_info_from_string mbedtls_cipher_info_from_string +#define cipher_info_from_type mbedtls_cipher_info_from_type +#define cipher_info_from_values mbedtls_cipher_info_from_values +#define cipher_info_t mbedtls_cipher_info_t +#define cipher_init mbedtls_cipher_init +#define cipher_init_ctx mbedtls_cipher_setup +#define cipher_list mbedtls_cipher_list +#define cipher_mode_t mbedtls_cipher_mode_t +#define cipher_padding_t mbedtls_cipher_padding_t +#define cipher_reset mbedtls_cipher_reset +#define cipher_self_test mbedtls_cipher_self_test +#define cipher_set_iv mbedtls_cipher_set_iv +#define cipher_set_padding_mode mbedtls_cipher_set_padding_mode +#define cipher_setkey mbedtls_cipher_setkey +#define cipher_type_t mbedtls_cipher_type_t +#define cipher_update mbedtls_cipher_update +#define cipher_update_ad mbedtls_cipher_update_ad +#define cipher_write_tag mbedtls_cipher_write_tag +#define ctr_drbg_context mbedtls_ctr_drbg_context +#define ctr_drbg_free mbedtls_ctr_drbg_free +#define ctr_drbg_init mbedtls_ctr_drbg_init +#define ctr_drbg_init_entropy_len mbedtls_ctr_drbg_init_entropy_len +#define ctr_drbg_random mbedtls_ctr_drbg_random +#define ctr_drbg_random_with_add mbedtls_ctr_drbg_random_with_add +#define ctr_drbg_reseed mbedtls_ctr_drbg_reseed +#define ctr_drbg_self_test mbedtls_ctr_drbg_self_test +#define ctr_drbg_set_entropy_len mbedtls_ctr_drbg_set_entropy_len +#define ctr_drbg_set_prediction_resistance mbedtls_ctr_drbg_set_prediction_resistance +#define ctr_drbg_set_reseed_interval mbedtls_ctr_drbg_set_reseed_interval +#define ctr_drbg_update mbedtls_ctr_drbg_update +#define ctr_drbg_update_seed_file mbedtls_ctr_drbg_update_seed_file +#define ctr_drbg_write_seed_file mbedtls_ctr_drbg_write_seed_file +#define debug_fmt mbedtls_debug_fmt +#define debug_print_buf mbedtls_debug_print_buf +#define debug_print_crt mbedtls_debug_print_crt +#define debug_print_ecp mbedtls_debug_print_ecp +#define debug_print_mpi mbedtls_debug_print_mpi +#define debug_print_msg mbedtls_debug_print_msg +#define debug_print_ret mbedtls_debug_print_ret +#define debug_set_log_mode mbedtls_debug_set_log_mode +#define debug_set_threshold mbedtls_debug_set_threshold +#define des3_context mbedtls_des3_context +#define des3_crypt_cbc mbedtls_des3_crypt_cbc +#define des3_crypt_ecb mbedtls_des3_crypt_ecb +#define des3_free mbedtls_des3_free +#define des3_init mbedtls_des3_init +#define des3_set2key_dec mbedtls_des3_set2key_dec +#define des3_set2key_enc mbedtls_des3_set2key_enc +#define des3_set3key_dec mbedtls_des3_set3key_dec +#define des3_set3key_enc mbedtls_des3_set3key_enc +#define des_context mbedtls_des_context +#define des_crypt_cbc mbedtls_des_crypt_cbc +#define des_crypt_ecb mbedtls_des_crypt_ecb +#define des_free mbedtls_des_free +#define des_init mbedtls_des_init +#define des_key_check_key_parity mbedtls_des_key_check_key_parity +#define des_key_check_weak mbedtls_des_key_check_weak +#define des_key_set_parity mbedtls_des_key_set_parity +#define des_self_test mbedtls_des_self_test +#define des_setkey_dec mbedtls_des_setkey_dec +#define des_setkey_enc mbedtls_des_setkey_enc +#define dhm_calc_secret mbedtls_dhm_calc_secret +#define dhm_context mbedtls_dhm_context +#define dhm_free mbedtls_dhm_free +#define dhm_init mbedtls_dhm_init +#define dhm_make_params mbedtls_dhm_make_params +#define dhm_make_public mbedtls_dhm_make_public +#define dhm_parse_dhm mbedtls_dhm_parse_dhm +#define dhm_parse_dhmfile mbedtls_dhm_parse_dhmfile +#define dhm_read_params mbedtls_dhm_read_params +#define dhm_read_public mbedtls_dhm_read_public +#define dhm_self_test mbedtls_dhm_self_test +#define ecdh_calc_secret mbedtls_ecdh_calc_secret +#define ecdh_compute_shared mbedtls_ecdh_compute_shared +#define ecdh_context mbedtls_ecdh_context +#define ecdh_free mbedtls_ecdh_free +#define ecdh_gen_public mbedtls_ecdh_gen_public +#define ecdh_get_params mbedtls_ecdh_get_params +#define ecdh_init mbedtls_ecdh_init +#define ecdh_make_params mbedtls_ecdh_make_params +#define ecdh_make_public mbedtls_ecdh_make_public +#define ecdh_read_params mbedtls_ecdh_read_params +#define ecdh_read_public mbedtls_ecdh_read_public +#define ecdh_self_test mbedtls_ecdh_self_test +#define ecdh_side mbedtls_ecdh_side +#define ecdsa_context mbedtls_ecdsa_context +#define ecdsa_free mbedtls_ecdsa_free +#define ecdsa_from_keypair mbedtls_ecdsa_from_keypair +#define ecdsa_genkey mbedtls_ecdsa_genkey +#define ecdsa_info mbedtls_ecdsa_info +#define ecdsa_init mbedtls_ecdsa_init +#define ecdsa_read_signature mbedtls_ecdsa_read_signature +#define ecdsa_self_test mbedtls_ecdsa_self_test +#define ecdsa_sign mbedtls_ecdsa_sign +#define ecdsa_sign_det mbedtls_ecdsa_sign_det +#define ecdsa_verify mbedtls_ecdsa_verify +#define ecdsa_write_signature mbedtls_ecdsa_write_signature +#define ecdsa_write_signature_det mbedtls_ecdsa_write_signature_det +#define eckey_info mbedtls_eckey_info +#define eckeydh_info mbedtls_eckeydh_info +#define ecp_add mbedtls_ecp_add +#define ecp_check_privkey mbedtls_ecp_check_privkey +#define ecp_check_pub_priv mbedtls_ecp_check_pub_priv +#define ecp_check_pubkey mbedtls_ecp_check_pubkey +#define ecp_copy mbedtls_ecp_copy +#define ecp_curve_info mbedtls_ecp_curve_info +#define ecp_curve_info_from_grp_id mbedtls_ecp_curve_info_from_grp_id +#define ecp_curve_info_from_name mbedtls_ecp_curve_info_from_name +#define ecp_curve_info_from_tls_id mbedtls_ecp_curve_info_from_tls_id +#define ecp_curve_list mbedtls_ecp_curve_list +#define ecp_gen_key mbedtls_ecp_gen_key +#define ecp_gen_keypair mbedtls_ecp_gen_keypair +#define ecp_group mbedtls_ecp_group +#define ecp_group_copy mbedtls_ecp_group_copy +#define ecp_group_free mbedtls_ecp_group_free +#define ecp_group_id mbedtls_ecp_group_id +#define ecp_group_init mbedtls_ecp_group_init +#define ecp_group_read_string mbedtls_ecp_group_read_string +#define ecp_grp_id_list mbedtls_ecp_grp_id_list +#define ecp_is_zero mbedtls_ecp_is_zero +#define ecp_keypair mbedtls_ecp_keypair +#define ecp_keypair_free mbedtls_ecp_keypair_free +#define ecp_keypair_init mbedtls_ecp_keypair_init +#define ecp_mul mbedtls_ecp_mul +#define ecp_point mbedtls_ecp_point +#define ecp_point_free mbedtls_ecp_point_free +#define ecp_point_init mbedtls_ecp_point_init +#define ecp_point_read_binary mbedtls_ecp_point_read_binary +#define ecp_point_read_string mbedtls_ecp_point_read_string +#define ecp_point_write_binary mbedtls_ecp_point_write_binary +#define ecp_self_test mbedtls_ecp_self_test +#define ecp_set_zero mbedtls_ecp_set_zero +#define ecp_sub mbedtls_ecp_sub +#define ecp_tls_read_group mbedtls_ecp_tls_read_group +#define ecp_tls_read_point mbedtls_ecp_tls_read_point +#define ecp_tls_write_group mbedtls_ecp_tls_write_group +#define ecp_tls_write_point mbedtls_ecp_tls_write_point +#define ecp_use_known_dp mbedtls_ecp_group_load +#define entropy_add_source mbedtls_entropy_add_source +#define entropy_context mbedtls_entropy_context +#define entropy_free mbedtls_entropy_free +#define entropy_func mbedtls_entropy_func +#define entropy_gather mbedtls_entropy_gather +#define entropy_init mbedtls_entropy_init +#define entropy_self_test mbedtls_entropy_self_test +#define entropy_update_manual mbedtls_entropy_update_manual +#define entropy_update_seed_file mbedtls_entropy_update_seed_file +#define entropy_write_seed_file mbedtls_entropy_write_seed_file +#define error_strerror mbedtls_strerror +#define f_source_ptr mbedtls_entropy_f_source_ptr +#define gcm_auth_decrypt mbedtls_gcm_auth_decrypt +#define gcm_context mbedtls_gcm_context +#define gcm_crypt_and_tag mbedtls_gcm_crypt_and_tag +#define gcm_finish mbedtls_gcm_finish +#define gcm_free mbedtls_gcm_free +#define gcm_init mbedtls_gcm_init +#define gcm_self_test mbedtls_gcm_self_test +#define gcm_starts mbedtls_gcm_starts +#define gcm_update mbedtls_gcm_update +#define get_timer mbedtls_timing_get_timer +#define hardclock mbedtls_timing_hardclock +#define hardclock_poll mbedtls_hardclock_poll +#define havege_free mbedtls_havege_free +#define havege_init mbedtls_havege_init +#define havege_poll mbedtls_havege_poll +#define havege_random mbedtls_havege_random +#define havege_state mbedtls_havege_state +#define hmac_drbg_context mbedtls_hmac_drbg_context +#define hmac_drbg_free mbedtls_hmac_drbg_free +#define hmac_drbg_init mbedtls_hmac_drbg_init +#define hmac_drbg_init_buf mbedtls_hmac_drbg_init_buf +#define hmac_drbg_random mbedtls_hmac_drbg_random +#define hmac_drbg_random_with_add mbedtls_hmac_drbg_random_with_add +#define hmac_drbg_reseed mbedtls_hmac_drbg_reseed +#define hmac_drbg_self_test mbedtls_hmac_drbg_self_test +#define hmac_drbg_set_entropy_len mbedtls_hmac_drbg_set_entropy_len +#define hmac_drbg_set_prediction_resistance mbedtls_hmac_drbg_set_prediction_resistance +#define hmac_drbg_set_reseed_interval mbedtls_hmac_drbg_set_reseed_interval +#define hmac_drbg_update mbedtls_hmac_drbg_update +#define hmac_drbg_update_seed_file mbedtls_hmac_drbg_update_seed_file +#define hmac_drbg_write_seed_file mbedtls_hmac_drbg_write_seed_file +#define hr_time mbedtls_timing_hr_time +#define key_exchange_type_t mbedtls_key_exchange_type_t +#define md mbedtls_md +#define md2 mbedtls_md2 +#define md2_context mbedtls_md2_context +#define md2_file mbedtls_md2_file +#define md2_finish mbedtls_md2_finish +#define md2_free mbedtls_md2_free +#define md2_hmac mbedtls_md2_hmac +#define md2_hmac_finish mbedtls_md2_hmac_finish +#define md2_hmac_reset mbedtls_md2_hmac_reset +#define md2_hmac_starts mbedtls_md2_hmac_starts +#define md2_hmac_update mbedtls_md2_hmac_update +#define md2_info mbedtls_md2_info +#define md2_init mbedtls_md2_init +#define md2_process mbedtls_md2_process +#define md2_self_test mbedtls_md2_self_test +#define md2_starts mbedtls_md2_starts +#define md2_update mbedtls_md2_update +#define md4 mbedtls_md4 +#define md4_context mbedtls_md4_context +#define md4_file mbedtls_md4_file +#define md4_finish mbedtls_md4_finish +#define md4_free mbedtls_md4_free +#define md4_hmac mbedtls_md4_hmac +#define md4_hmac_finish mbedtls_md4_hmac_finish +#define md4_hmac_reset mbedtls_md4_hmac_reset +#define md4_hmac_starts mbedtls_md4_hmac_starts +#define md4_hmac_update mbedtls_md4_hmac_update +#define md4_info mbedtls_md4_info +#define md4_init mbedtls_md4_init +#define md4_process mbedtls_md4_process +#define md4_self_test mbedtls_md4_self_test +#define md4_starts mbedtls_md4_starts +#define md4_update mbedtls_md4_update +#define md5 mbedtls_md5 +#define md5_context mbedtls_md5_context +#define md5_file mbedtls_md5_file +#define md5_finish mbedtls_md5_finish +#define md5_free mbedtls_md5_free +#define md5_hmac mbedtls_md5_hmac +#define md5_hmac_finish mbedtls_md5_hmac_finish +#define md5_hmac_reset mbedtls_md5_hmac_reset +#define md5_hmac_starts mbedtls_md5_hmac_starts +#define md5_hmac_update mbedtls_md5_hmac_update +#define md5_info mbedtls_md5_info +#define md5_init mbedtls_md5_init +#define md5_process mbedtls_md5_process +#define md5_self_test mbedtls_md5_self_test +#define md5_starts mbedtls_md5_starts +#define md5_update mbedtls_md5_update +#define md_context_t mbedtls_md_context_t +#define md_file mbedtls_md_file +#define md_finish mbedtls_md_finish +#define md_free mbedtls_md_free +#define md_free_ctx mbedtls_md_free_ctx +#define md_get_name mbedtls_md_get_name +#define md_get_size mbedtls_md_get_size +#define md_get_type mbedtls_md_get_type +#define md_hmac mbedtls_md_hmac +#define md_hmac_finish mbedtls_md_hmac_finish +#define md_hmac_reset mbedtls_md_hmac_reset +#define md_hmac_starts mbedtls_md_hmac_starts +#define md_hmac_update mbedtls_md_hmac_update +#define md_info_from_string mbedtls_md_info_from_string +#define md_info_from_type mbedtls_md_info_from_type +#define md_info_t mbedtls_md_info_t +#define md_init mbedtls_md_init +#define md_init_ctx mbedtls_md_init_ctx +#define md_list mbedtls_md_list +#define md_process mbedtls_md_process +#define md_starts mbedtls_md_starts +#define md_type_t mbedtls_md_type_t +#define md_update mbedtls_md_update +#define memory_buffer_alloc_cur_get mbedtls_memory_buffer_alloc_cur_get +#define memory_buffer_alloc_free mbedtls_memory_buffer_alloc_free +#define memory_buffer_alloc_init mbedtls_memory_buffer_alloc_init +#define memory_buffer_alloc_max_get mbedtls_memory_buffer_alloc_max_get +#define memory_buffer_alloc_max_reset mbedtls_memory_buffer_alloc_max_reset +#define memory_buffer_alloc_self_test mbedtls_memory_buffer_alloc_self_test +#define memory_buffer_alloc_status mbedtls_memory_buffer_alloc_status +#define memory_buffer_alloc_verify mbedtls_memory_buffer_alloc_verify +#define memory_buffer_set_verify mbedtls_memory_buffer_set_verify +#define memory_set_own mbedtls_memory_set_own +#define mpi mbedtls_mpi +#define mpi_add_abs mbedtls_mpi_add_abs +#define mpi_add_int mbedtls_mpi_add_int +#define mpi_add_mpi mbedtls_mpi_add_mpi +#define mpi_cmp_abs mbedtls_mpi_cmp_abs +#define mpi_cmp_int mbedtls_mpi_cmp_int +#define mpi_cmp_mpi mbedtls_mpi_cmp_mpi +#define mpi_copy mbedtls_mpi_copy +#define mpi_div_int mbedtls_mpi_div_int +#define mpi_div_mpi mbedtls_mpi_div_mpi +#define mpi_exp_mod mbedtls_mpi_exp_mod +#define mpi_fill_random mbedtls_mpi_fill_random +#define mpi_free mbedtls_mpi_free +#define mpi_gcd mbedtls_mpi_gcd +#define mpi_gen_prime mbedtls_mpi_gen_prime +#define mpi_get_bit mbedtls_mpi_get_bit +#define mpi_grow mbedtls_mpi_grow +#define mpi_init mbedtls_mpi_init +#define mpi_inv_mod mbedtls_mpi_inv_mod +#define mpi_is_prime mbedtls_mpi_is_prime +#define mpi_lsb mbedtls_mpi_lsb +#define mpi_lset mbedtls_mpi_lset +#define mpi_mod_int mbedtls_mpi_mod_int +#define mpi_mod_mpi mbedtls_mpi_mod_mpi +#define mpi_msb mbedtls_mpi_bitlen +#define mpi_mul_int mbedtls_mpi_mul_int +#define mpi_mul_mpi mbedtls_mpi_mul_mpi +#define mpi_read_binary mbedtls_mpi_read_binary +#define mpi_read_file mbedtls_mpi_read_file +#define mpi_read_string mbedtls_mpi_read_string +#define mpi_safe_cond_assign mbedtls_mpi_safe_cond_assign +#define mpi_safe_cond_swap mbedtls_mpi_safe_cond_swap +#define mpi_self_test mbedtls_mpi_self_test +#define mpi_set_bit mbedtls_mpi_set_bit +#define mpi_shift_l mbedtls_mpi_shift_l +#define mpi_shift_r mbedtls_mpi_shift_r +#define mpi_shrink mbedtls_mpi_shrink +#define mpi_size mbedtls_mpi_size +#define mpi_sub_abs mbedtls_mpi_sub_abs +#define mpi_sub_int mbedtls_mpi_sub_int +#define mpi_sub_mpi mbedtls_mpi_sub_mpi +#define mpi_swap mbedtls_mpi_swap +#define mpi_write_binary mbedtls_mpi_write_binary +#define mpi_write_file mbedtls_mpi_write_file +#define mpi_write_string mbedtls_mpi_write_string +#define net_accept mbedtls_net_accept +#define net_bind mbedtls_net_bind +#define net_close mbedtls_net_free +#define net_connect mbedtls_net_connect +#define net_recv mbedtls_net_recv +#define net_recv_timeout mbedtls_net_recv_timeout +#define net_send mbedtls_net_send +#define net_set_block mbedtls_net_set_block +#define net_set_nonblock mbedtls_net_set_nonblock +#define net_usleep mbedtls_net_usleep +#define oid_descriptor_t mbedtls_oid_descriptor_t +#define oid_get_attr_short_name mbedtls_oid_get_attr_short_name +#define oid_get_cipher_alg mbedtls_oid_get_cipher_alg +#define oid_get_ec_grp mbedtls_oid_get_ec_grp +#define oid_get_extended_key_usage mbedtls_oid_get_extended_key_usage +#define oid_get_md_alg mbedtls_oid_get_md_alg +#define oid_get_numeric_string mbedtls_oid_get_numeric_string +#define oid_get_oid_by_ec_grp mbedtls_oid_get_oid_by_ec_grp +#define oid_get_oid_by_md mbedtls_oid_get_oid_by_md +#define oid_get_oid_by_pk_alg mbedtls_oid_get_oid_by_pk_alg +#define oid_get_oid_by_sig_alg mbedtls_oid_get_oid_by_sig_alg +#define oid_get_pk_alg mbedtls_oid_get_pk_alg +#define oid_get_pkcs12_pbe_alg mbedtls_oid_get_pkcs12_pbe_alg +#define oid_get_sig_alg mbedtls_oid_get_sig_alg +#define oid_get_sig_alg_desc mbedtls_oid_get_sig_alg_desc +#define oid_get_x509_ext_type mbedtls_oid_get_x509_ext_type +#define operation_t mbedtls_operation_t +#define padlock_supports mbedtls_padlock_has_support +#define padlock_xcryptcbc mbedtls_padlock_xcryptcbc +#define padlock_xcryptecb mbedtls_padlock_xcryptecb +#define pbkdf2_hmac mbedtls_pbkdf2_hmac +#define pbkdf2_self_test mbedtls_pbkdf2_self_test +#define pem_context mbedtls_pem_context +#define pem_free mbedtls_pem_free +#define pem_init mbedtls_pem_init +#define pem_read_buffer mbedtls_pem_read_buffer +#define pem_write_buffer mbedtls_pem_write_buffer +#define pk_can_do mbedtls_pk_can_do +#define pk_check_pair mbedtls_pk_check_pair +#define pk_context mbedtls_pk_context +#define pk_debug mbedtls_pk_debug +#define pk_debug_item mbedtls_pk_debug_item +#define pk_debug_type mbedtls_pk_debug_type +#define pk_decrypt mbedtls_pk_decrypt +#define pk_ec mbedtls_pk_ec +#define pk_encrypt mbedtls_pk_encrypt +#define pk_free mbedtls_pk_free +#define pk_get_len mbedtls_pk_get_len +#define pk_get_name mbedtls_pk_get_name +#define pk_get_size mbedtls_pk_get_bitlen +#define pk_get_type mbedtls_pk_get_type +#define pk_info_from_type mbedtls_pk_info_from_type +#define pk_info_t mbedtls_pk_info_t +#define pk_init mbedtls_pk_init +#define pk_init_ctx mbedtls_pk_setup +#define pk_init_ctx_rsa_alt mbedtls_pk_setup_rsa_alt +#define pk_load_file mbedtls_pk_load_file +#define pk_parse_key mbedtls_pk_parse_key +#define pk_parse_keyfile mbedtls_pk_parse_keyfile +#define pk_parse_public_key mbedtls_pk_parse_public_key +#define pk_parse_public_keyfile mbedtls_pk_parse_public_keyfile +#define pk_parse_subpubkey mbedtls_pk_parse_subpubkey +#define pk_rsa mbedtls_pk_rsa +#define pk_rsa_alt_decrypt_func mbedtls_pk_rsa_alt_decrypt_func +#define pk_rsa_alt_key_len_func mbedtls_pk_rsa_alt_key_len_func +#define pk_rsa_alt_sign_func mbedtls_pk_rsa_alt_sign_func +#define pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options +#define pk_sign mbedtls_pk_sign +#define pk_type_t mbedtls_pk_type_t +#define pk_verify mbedtls_pk_verify +#define pk_verify_ext mbedtls_pk_verify_ext +#define pk_write_key_der mbedtls_pk_write_key_der +#define pk_write_key_pem mbedtls_pk_write_key_pem +#define pk_write_pubkey mbedtls_pk_write_pubkey +#define pk_write_pubkey_der mbedtls_pk_write_pubkey_der +#define pk_write_pubkey_pem mbedtls_pk_write_pubkey_pem +#define pkcs11_context mbedtls_pkcs11_context +#define pkcs11_decrypt mbedtls_pkcs11_decrypt +#define pkcs11_priv_key_free mbedtls_pkcs11_priv_key_free +#define pkcs11_priv_key_init mbedtls_pkcs11_priv_key_bind +#define pkcs11_sign mbedtls_pkcs11_sign +#define pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_bind +#define pkcs12_derivation mbedtls_pkcs12_derivation +#define pkcs12_pbe mbedtls_pkcs12_pbe +#define pkcs12_pbe_sha1_rc4_128 mbedtls_pkcs12_pbe_sha1_rc4_128 +#define pkcs5_pbes2 mbedtls_pkcs5_pbes2 +#define pkcs5_pbkdf2_hmac mbedtls_pkcs5_pbkdf2_hmac +#define pkcs5_self_test mbedtls_pkcs5_self_test +#define platform_entropy_poll mbedtls_platform_entropy_poll +#define platform_set_exit mbedtls_platform_set_exit +#define platform_set_fprintf mbedtls_platform_set_fprintf +#define platform_set_malloc_free mbedtls_platform_set_malloc_free +#define platform_set_printf mbedtls_platform_set_printf +#define platform_set_snprintf mbedtls_platform_set_snprintf +#define polarssl_exit mbedtls_exit +#define polarssl_fprintf mbedtls_fprintf +#define polarssl_free mbedtls_free +#define polarssl_malloc mbedtls_malloc +#define polarssl_mutex_free mbedtls_mutex_free +#define polarssl_mutex_init mbedtls_mutex_init +#define polarssl_mutex_lock mbedtls_mutex_lock +#define polarssl_mutex_unlock mbedtls_mutex_unlock +#define polarssl_printf mbedtls_printf +#define polarssl_snprintf mbedtls_snprintf +#define polarssl_strerror mbedtls_strerror +#define ripemd160 mbedtls_ripemd160 +#define ripemd160_context mbedtls_ripemd160_context +#define ripemd160_file mbedtls_ripemd160_file +#define ripemd160_finish mbedtls_ripemd160_finish +#define ripemd160_free mbedtls_ripemd160_free +#define ripemd160_hmac mbedtls_ripemd160_hmac +#define ripemd160_hmac_finish mbedtls_ripemd160_hmac_finish +#define ripemd160_hmac_reset mbedtls_ripemd160_hmac_reset +#define ripemd160_hmac_starts mbedtls_ripemd160_hmac_starts +#define ripemd160_hmac_update mbedtls_ripemd160_hmac_update +#define ripemd160_info mbedtls_ripemd160_info +#define ripemd160_init mbedtls_ripemd160_init +#define ripemd160_process mbedtls_ripemd160_process +#define ripemd160_self_test mbedtls_ripemd160_self_test +#define ripemd160_starts mbedtls_ripemd160_starts +#define ripemd160_update mbedtls_ripemd160_update +#define rsa_alt_context mbedtls_rsa_alt_context +#define rsa_alt_info mbedtls_rsa_alt_info +#define rsa_check_privkey mbedtls_rsa_check_privkey +#define rsa_check_pub_priv mbedtls_rsa_check_pub_priv +#define rsa_check_pubkey mbedtls_rsa_check_pubkey +#define rsa_context mbedtls_rsa_context +#define rsa_copy mbedtls_rsa_copy +#define rsa_decrypt_func mbedtls_rsa_decrypt_func +#define rsa_free mbedtls_rsa_free +#define rsa_gen_key mbedtls_rsa_gen_key +#define rsa_info mbedtls_rsa_info +#define rsa_init mbedtls_rsa_init +#define rsa_key_len_func mbedtls_rsa_key_len_func +#define rsa_pkcs1_decrypt mbedtls_rsa_pkcs1_decrypt +#define rsa_pkcs1_encrypt mbedtls_rsa_pkcs1_encrypt +#define rsa_pkcs1_sign mbedtls_rsa_pkcs1_sign +#define rsa_pkcs1_verify mbedtls_rsa_pkcs1_verify +#define rsa_private mbedtls_rsa_private +#define rsa_public mbedtls_rsa_public +#define rsa_rsaes_oaep_decrypt mbedtls_rsa_rsaes_oaep_decrypt +#define rsa_rsaes_oaep_encrypt mbedtls_rsa_rsaes_oaep_encrypt +#define rsa_rsaes_pkcs1_v15_decrypt mbedtls_rsa_rsaes_pkcs1_v15_decrypt +#define rsa_rsaes_pkcs1_v15_encrypt mbedtls_rsa_rsaes_pkcs1_v15_encrypt +#define rsa_rsassa_pkcs1_v15_sign mbedtls_rsa_rsassa_pkcs1_v15_sign +#define rsa_rsassa_pkcs1_v15_verify mbedtls_rsa_rsassa_pkcs1_v15_verify +#define rsa_rsassa_pss_sign mbedtls_rsa_rsassa_pss_sign +#define rsa_rsassa_pss_verify mbedtls_rsa_rsassa_pss_verify +#define rsa_rsassa_pss_verify_ext mbedtls_rsa_rsassa_pss_verify_ext +#define rsa_self_test mbedtls_rsa_self_test +#define rsa_set_padding mbedtls_rsa_set_padding +#define rsa_sign_func mbedtls_rsa_sign_func +#define safer_memcmp mbedtls_ssl_safer_memcmp +#define set_alarm mbedtls_set_alarm +#define sha1 mbedtls_sha1 +#define sha1_context mbedtls_sha1_context +#define sha1_file mbedtls_sha1_file +#define sha1_finish mbedtls_sha1_finish +#define sha1_free mbedtls_sha1_free +#define sha1_hmac mbedtls_sha1_hmac +#define sha1_hmac_finish mbedtls_sha1_hmac_finish +#define sha1_hmac_reset mbedtls_sha1_hmac_reset +#define sha1_hmac_starts mbedtls_sha1_hmac_starts +#define sha1_hmac_update mbedtls_sha1_hmac_update +#define sha1_info mbedtls_sha1_info +#define sha1_init mbedtls_sha1_init +#define sha1_process mbedtls_sha1_process +#define sha1_self_test mbedtls_sha1_self_test +#define sha1_starts mbedtls_sha1_starts +#define sha1_update mbedtls_sha1_update +#define sha224_info mbedtls_sha224_info +#define sha256 mbedtls_sha256 +#define sha256_context mbedtls_sha256_context +#define sha256_file mbedtls_sha256_file +#define sha256_finish mbedtls_sha256_finish +#define sha256_free mbedtls_sha256_free +#define sha256_hmac mbedtls_sha256_hmac +#define sha256_hmac_finish mbedtls_sha256_hmac_finish +#define sha256_hmac_reset mbedtls_sha256_hmac_reset +#define sha256_hmac_starts mbedtls_sha256_hmac_starts +#define sha256_hmac_update mbedtls_sha256_hmac_update +#define sha256_info mbedtls_sha256_info +#define sha256_init mbedtls_sha256_init +#define sha256_process mbedtls_sha256_process +#define sha256_self_test mbedtls_sha256_self_test +#define sha256_starts mbedtls_sha256_starts +#define sha256_update mbedtls_sha256_update +#define sha384_info mbedtls_sha384_info +#define sha512 mbedtls_sha512 +#define sha512_context mbedtls_sha512_context +#define sha512_file mbedtls_sha512_file +#define sha512_finish mbedtls_sha512_finish +#define sha512_free mbedtls_sha512_free +#define sha512_hmac mbedtls_sha512_hmac +#define sha512_hmac_finish mbedtls_sha512_hmac_finish +#define sha512_hmac_reset mbedtls_sha512_hmac_reset +#define sha512_hmac_starts mbedtls_sha512_hmac_starts +#define sha512_hmac_update mbedtls_sha512_hmac_update +#define sha512_info mbedtls_sha512_info +#define sha512_init mbedtls_sha512_init +#define sha512_process mbedtls_sha512_process +#define sha512_self_test mbedtls_sha512_self_test +#define sha512_starts mbedtls_sha512_starts +#define sha512_update mbedtls_sha512_update +#define source_state mbedtls_entropy_source_state +#define ssl_cache_context mbedtls_ssl_cache_context +#define ssl_cache_entry mbedtls_ssl_cache_entry +#define ssl_cache_free mbedtls_ssl_cache_free +#define ssl_cache_get mbedtls_ssl_cache_get +#define ssl_cache_init mbedtls_ssl_cache_init +#define ssl_cache_set mbedtls_ssl_cache_set +#define ssl_cache_set_max_entries mbedtls_ssl_cache_set_max_entries +#define ssl_cache_set_timeout mbedtls_ssl_cache_set_timeout +#define ssl_check_cert_usage mbedtls_ssl_check_cert_usage +#define ssl_ciphersuite_from_id mbedtls_ssl_ciphersuite_from_id +#define ssl_ciphersuite_from_string mbedtls_ssl_ciphersuite_from_string +#define ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t +#define ssl_ciphersuite_uses_ec mbedtls_ssl_ciphersuite_uses_ec +#define ssl_ciphersuite_uses_psk mbedtls_ssl_ciphersuite_uses_psk +#define ssl_close_notify mbedtls_ssl_close_notify +#define ssl_context mbedtls_ssl_context +#define ssl_cookie_check mbedtls_ssl_cookie_check +#define ssl_cookie_check_t mbedtls_ssl_cookie_check_t +#define ssl_cookie_ctx mbedtls_ssl_cookie_ctx +#define ssl_cookie_free mbedtls_ssl_cookie_free +#define ssl_cookie_init mbedtls_ssl_cookie_init +#define ssl_cookie_set_timeout mbedtls_ssl_cookie_set_timeout +#define ssl_cookie_setup mbedtls_ssl_cookie_setup +#define ssl_cookie_write mbedtls_ssl_cookie_write +#define ssl_cookie_write_t mbedtls_ssl_cookie_write_t +#define ssl_curve_is_acceptable mbedtls_ssl_curve_is_acceptable +#define ssl_derive_keys mbedtls_ssl_derive_keys +#define ssl_dtls_replay_check mbedtls_ssl_dtls_replay_check +#define ssl_dtls_replay_update mbedtls_ssl_dtls_replay_update +#define ssl_fetch_input mbedtls_ssl_fetch_input +#define ssl_flight_item mbedtls_ssl_flight_item +#define ssl_flush_output mbedtls_ssl_flush_output +#define ssl_free mbedtls_ssl_free +#define ssl_get_alpn_protocol mbedtls_ssl_get_alpn_protocol +#define ssl_get_bytes_avail mbedtls_ssl_get_bytes_avail +#define ssl_get_ciphersuite mbedtls_ssl_get_ciphersuite +#define ssl_get_ciphersuite_id mbedtls_ssl_get_ciphersuite_id +#define ssl_get_ciphersuite_name mbedtls_ssl_get_ciphersuite_name +#define ssl_get_ciphersuite_sig_pk_alg mbedtls_ssl_get_ciphersuite_sig_pk_alg +#define ssl_get_peer_cert mbedtls_ssl_get_peer_cert +#define ssl_get_record_expansion mbedtls_ssl_get_record_expansion +#define ssl_get_session mbedtls_ssl_get_session +#define ssl_get_verify_result mbedtls_ssl_get_verify_result +#define ssl_get_version mbedtls_ssl_get_version +#define ssl_handshake mbedtls_ssl_handshake +#define ssl_handshake_client_step mbedtls_ssl_handshake_client_step +#define ssl_handshake_free mbedtls_ssl_handshake_free +#define ssl_handshake_params mbedtls_ssl_handshake_params +#define ssl_handshake_server_step mbedtls_ssl_handshake_server_step +#define ssl_handshake_step mbedtls_ssl_handshake_step +#define ssl_handshake_wrapup mbedtls_ssl_handshake_wrapup +#define ssl_hdr_len mbedtls_ssl_hdr_len +#define ssl_hs_hdr_len mbedtls_ssl_hs_hdr_len +#define ssl_hw_record_activate mbedtls_ssl_hw_record_activate +#define ssl_hw_record_finish mbedtls_ssl_hw_record_finish +#define ssl_hw_record_init mbedtls_ssl_hw_record_init +#define ssl_hw_record_read mbedtls_ssl_hw_record_read +#define ssl_hw_record_reset mbedtls_ssl_hw_record_reset +#define ssl_hw_record_write mbedtls_ssl_hw_record_write +#define ssl_init mbedtls_ssl_init +#define ssl_key_cert mbedtls_ssl_key_cert +#define ssl_legacy_renegotiation mbedtls_ssl_conf_legacy_renegotiation +#define ssl_list_ciphersuites mbedtls_ssl_list_ciphersuites +#define ssl_md_alg_from_hash mbedtls_ssl_md_alg_from_hash +#define ssl_optimize_checksum mbedtls_ssl_optimize_checksum +#define ssl_own_cert mbedtls_ssl_own_cert +#define ssl_own_key mbedtls_ssl_own_key +#define ssl_parse_certificate mbedtls_ssl_parse_certificate +#define ssl_parse_change_cipher_spec mbedtls_ssl_parse_change_cipher_spec +#define ssl_parse_finished mbedtls_ssl_parse_finished +#define ssl_pk_alg_from_sig mbedtls_ssl_pk_alg_from_sig +#define ssl_pkcs11_decrypt mbedtls_ssl_pkcs11_decrypt +#define ssl_pkcs11_key_len mbedtls_ssl_pkcs11_key_len +#define ssl_pkcs11_sign mbedtls_ssl_pkcs11_sign +#define ssl_psk_derive_premaster mbedtls_ssl_psk_derive_premaster +#define ssl_read mbedtls_ssl_read +#define ssl_read_record mbedtls_ssl_read_record +#define ssl_read_version mbedtls_ssl_read_version +#define ssl_recv_flight_completed mbedtls_ssl_recv_flight_completed +#define ssl_renegotiate mbedtls_ssl_renegotiate +#define ssl_resend mbedtls_ssl_resend +#define ssl_reset_checksum mbedtls_ssl_reset_checksum +#define ssl_send_alert_message mbedtls_ssl_send_alert_message +#define ssl_send_fatal_handshake_failure mbedtls_ssl_send_fatal_handshake_failure +#define ssl_send_flight_completed mbedtls_ssl_send_flight_completed +#define ssl_session mbedtls_ssl_session +#define ssl_session_free mbedtls_ssl_session_free +#define ssl_session_init mbedtls_ssl_session_init +#define ssl_session_reset mbedtls_ssl_session_reset +#define ssl_set_alpn_protocols mbedtls_ssl_conf_alpn_protocols +#define ssl_set_arc4_support mbedtls_ssl_conf_arc4_support +#define ssl_set_authmode mbedtls_ssl_conf_authmode +#define ssl_set_bio mbedtls_ssl_set_bio +#define ssl_set_ca_chain mbedtls_ssl_conf_ca_chain +#define ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting +#define ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites +#define ssl_set_ciphersuites_for_version mbedtls_ssl_conf_ciphersuites_for_version +#define ssl_set_client_transport_id mbedtls_ssl_set_client_transport_id +#define ssl_set_curves mbedtls_ssl_conf_curves +#define ssl_set_dbg mbedtls_ssl_conf_dbg +#define ssl_set_dh_param mbedtls_ssl_conf_dh_param +#define ssl_set_dh_param_ctx mbedtls_ssl_conf_dh_param_ctx +#define ssl_set_dtls_anti_replay mbedtls_ssl_conf_dtls_anti_replay +#define ssl_set_dtls_badmac_limit mbedtls_ssl_conf_dtls_badmac_limit +#define ssl_set_dtls_cookies mbedtls_ssl_conf_dtls_cookies +#define ssl_set_encrypt_then_mac mbedtls_ssl_conf_encrypt_then_mac +#define ssl_set_endpoint mbedtls_ssl_conf_endpoint +#define ssl_set_extended_master_secret mbedtls_ssl_conf_extended_master_secret +#define ssl_set_fallback mbedtls_ssl_conf_fallback +#define ssl_set_handshake_timeout mbedtls_ssl_conf_handshake_timeout +#define ssl_set_hostname mbedtls_ssl_set_hostname +#define ssl_set_max_frag_len mbedtls_ssl_conf_max_frag_len +#define ssl_set_max_version mbedtls_ssl_conf_max_version +#define ssl_set_min_version mbedtls_ssl_conf_min_version +#define ssl_set_own_cert mbedtls_ssl_conf_own_cert +#define ssl_set_own_cert_alt mbedtls_ssl_set_own_cert_alt +#define ssl_set_own_cert_rsa mbedtls_ssl_set_own_cert_rsa +#define ssl_set_psk mbedtls_ssl_conf_psk +#define ssl_set_psk_cb mbedtls_ssl_conf_psk_cb +#define ssl_set_renegotiation mbedtls_ssl_conf_renegotiation +#define ssl_set_renegotiation_enforced mbedtls_ssl_conf_renegotiation_enforced +#define ssl_set_renegotiation_period mbedtls_ssl_conf_renegotiation_period +#define ssl_set_rng mbedtls_ssl_conf_rng +#define ssl_set_session mbedtls_ssl_set_session +#define ssl_set_session_cache mbedtls_ssl_conf_session_cache +#define ssl_set_session_ticket_lifetime mbedtls_ssl_conf_session_ticket_lifetime +#define ssl_set_session_tickets mbedtls_ssl_conf_session_tickets +#define ssl_set_sni mbedtls_ssl_conf_sni +#define ssl_set_transport mbedtls_ssl_conf_transport +#define ssl_set_truncated_hmac mbedtls_ssl_conf_truncated_hmac +#define ssl_set_verify mbedtls_ssl_conf_verify +#define ssl_sig_from_pk mbedtls_ssl_sig_from_pk +#define ssl_states mbedtls_ssl_states +#define ssl_ticket_keys mbedtls_ssl_ticket_keys +#define ssl_transform mbedtls_ssl_transform +#define ssl_transform_free mbedtls_ssl_transform_free +#define ssl_write mbedtls_ssl_write +#define ssl_write_certificate mbedtls_ssl_write_certificate +#define ssl_write_change_cipher_spec mbedtls_ssl_write_change_cipher_spec +#define ssl_write_finished mbedtls_ssl_write_finished +#define ssl_write_record mbedtls_ssl_write_record +#define ssl_write_version mbedtls_ssl_write_version +#define supported_ciphers mbedtls_cipher_supported +#define t_sint mbedtls_mpi_sint +#define t_udbl mbedtls_t_udbl +#define t_uint mbedtls_mpi_uint +#define test_ca_crt mbedtls_test_ca_crt +#define test_ca_crt_ec mbedtls_test_ca_crt_ec +#define test_ca_crt_rsa mbedtls_test_ca_crt_rsa +#define test_ca_key mbedtls_test_ca_key +#define test_ca_key_ec mbedtls_test_ca_key_ec +#define test_ca_key_rsa mbedtls_test_ca_key_rsa +#define test_ca_list mbedtls_test_cas_pem +#define test_ca_pwd mbedtls_test_ca_pwd +#define test_ca_pwd_ec mbedtls_test_ca_pwd_ec +#define test_ca_pwd_rsa mbedtls_test_ca_pwd_rsa +#define test_cli_crt mbedtls_test_cli_crt +#define test_cli_crt_ec mbedtls_test_cli_crt_ec +#define test_cli_crt_rsa mbedtls_test_cli_crt_rsa +#define test_cli_key mbedtls_test_cli_key +#define test_cli_key_ec mbedtls_test_cli_key_ec +#define test_cli_key_rsa mbedtls_test_cli_key_rsa +#define test_dhm_params mbedtls_test_dhm_params +#define test_srv_crt mbedtls_test_srv_crt +#define test_srv_crt_ec mbedtls_test_srv_crt_ec +#define test_srv_crt_rsa mbedtls_test_srv_crt_rsa +#define test_srv_key mbedtls_test_srv_key +#define test_srv_key_ec mbedtls_test_srv_key_ec +#define test_srv_key_rsa mbedtls_test_srv_key_rsa +#define threading_mutex_t mbedtls_threading_mutex_t +#define threading_set_alt mbedtls_threading_set_alt +#define timing_self_test mbedtls_timing_self_test +#define version_check_feature mbedtls_version_check_feature +#define version_get_number mbedtls_version_get_number +#define version_get_string mbedtls_version_get_string +#define version_get_string_full mbedtls_version_get_string_full +#define x509_bitstring mbedtls_x509_bitstring +#define x509_buf mbedtls_x509_buf +#define x509_crl mbedtls_x509_crl +#define x509_crl_entry mbedtls_x509_crl_entry +#define x509_crl_free mbedtls_x509_crl_free +#define x509_crl_info mbedtls_x509_crl_info +#define x509_crl_init mbedtls_x509_crl_init +#define x509_crl_parse mbedtls_x509_crl_parse +#define x509_crl_parse_der mbedtls_x509_crl_parse_der +#define x509_crl_parse_file mbedtls_x509_crl_parse_file +#define x509_crt mbedtls_x509_crt +#define x509_crt_check_extended_key_usage mbedtls_x509_crt_check_extended_key_usage +#define x509_crt_check_key_usage mbedtls_x509_crt_check_key_usage +#define x509_crt_free mbedtls_x509_crt_free +#define x509_crt_info mbedtls_x509_crt_info +#define x509_crt_init mbedtls_x509_crt_init +#define x509_crt_parse mbedtls_x509_crt_parse +#define x509_crt_parse_der mbedtls_x509_crt_parse_der +#define x509_crt_parse_file mbedtls_x509_crt_parse_file +#define x509_crt_parse_path mbedtls_x509_crt_parse_path +#define x509_crt_revoked mbedtls_x509_crt_is_revoked +#define x509_crt_verify mbedtls_x509_crt_verify +#define x509_csr mbedtls_x509_csr +#define x509_csr_free mbedtls_x509_csr_free +#define x509_csr_info mbedtls_x509_csr_info +#define x509_csr_init mbedtls_x509_csr_init +#define x509_csr_parse mbedtls_x509_csr_parse +#define x509_csr_parse_der mbedtls_x509_csr_parse_der +#define x509_csr_parse_file mbedtls_x509_csr_parse_file +#define x509_dn_gets mbedtls_x509_dn_gets +#define x509_get_alg mbedtls_x509_get_alg +#define x509_get_alg_null mbedtls_x509_get_alg_null +#define x509_get_ext mbedtls_x509_get_ext +#define x509_get_name mbedtls_x509_get_name +#define x509_get_rsassa_pss_params mbedtls_x509_get_rsassa_pss_params +#define x509_get_serial mbedtls_x509_get_serial +#define x509_get_sig mbedtls_x509_get_sig +#define x509_get_sig_alg mbedtls_x509_get_sig_alg +#define x509_get_time mbedtls_x509_get_time +#define x509_key_size_helper mbedtls_x509_key_size_helper +#define x509_name mbedtls_x509_name +#define x509_oid_get_description mbedtls_x509_oid_get_description +#define x509_oid_get_numeric_string mbedtls_x509_oid_get_numeric_string +#define x509_self_test mbedtls_x509_self_test +#define x509_sequence mbedtls_x509_sequence +#define x509_serial_gets mbedtls_x509_serial_gets +#define x509_set_extension mbedtls_x509_set_extension +#define x509_sig_alg_gets mbedtls_x509_sig_alg_gets +#define x509_string_to_names mbedtls_x509_string_to_names +#define x509_time mbedtls_x509_time +#define x509_time_expired mbedtls_x509_time_is_past +#define x509_time_future mbedtls_x509_time_is_future +#define x509_write_extensions mbedtls_x509_write_extensions +#define x509_write_names mbedtls_x509_write_names +#define x509_write_sig mbedtls_x509_write_sig +#define x509write_cert mbedtls_x509write_cert +#define x509write_crt_der mbedtls_x509write_crt_der +#define x509write_crt_free mbedtls_x509write_crt_free +#define x509write_crt_init mbedtls_x509write_crt_init +#define x509write_crt_pem mbedtls_x509write_crt_pem +#define x509write_crt_set_authority_key_identifier mbedtls_x509write_crt_set_authority_key_identifier +#define x509write_crt_set_basic_constraints mbedtls_x509write_crt_set_basic_constraints +#define x509write_crt_set_extension mbedtls_x509write_crt_set_extension +#define x509write_crt_set_issuer_key mbedtls_x509write_crt_set_issuer_key +#define x509write_crt_set_issuer_name mbedtls_x509write_crt_set_issuer_name +#define x509write_crt_set_key_usage mbedtls_x509write_crt_set_key_usage +#define x509write_crt_set_md_alg mbedtls_x509write_crt_set_md_alg +#define x509write_crt_set_ns_cert_type mbedtls_x509write_crt_set_ns_cert_type +#define x509write_crt_set_serial mbedtls_x509write_crt_set_serial +#define x509write_crt_set_subject_key mbedtls_x509write_crt_set_subject_key +#define x509write_crt_set_subject_key_identifier mbedtls_x509write_crt_set_subject_key_identifier +#define x509write_crt_set_subject_name mbedtls_x509write_crt_set_subject_name +#define x509write_crt_set_validity mbedtls_x509write_crt_set_validity +#define x509write_crt_set_version mbedtls_x509write_crt_set_version +#define x509write_csr mbedtls_x509write_csr +#define x509write_csr_der mbedtls_x509write_csr_der +#define x509write_csr_free mbedtls_x509write_csr_free +#define x509write_csr_init mbedtls_x509write_csr_init +#define x509write_csr_pem mbedtls_x509write_csr_pem +#define x509write_csr_set_extension mbedtls_x509write_csr_set_extension +#define x509write_csr_set_key mbedtls_x509write_csr_set_key +#define x509write_csr_set_key_usage mbedtls_x509write_csr_set_key_usage +#define x509write_csr_set_md_alg mbedtls_x509write_csr_set_md_alg +#define x509write_csr_set_ns_cert_type mbedtls_x509write_csr_set_ns_cert_type +#define x509write_csr_set_subject_name mbedtls_x509write_csr_set_subject_name +#define xtea_context mbedtls_xtea_context +#define xtea_crypt_cbc mbedtls_xtea_crypt_cbc +#define xtea_crypt_ecb mbedtls_xtea_crypt_ecb +#define xtea_free mbedtls_xtea_free +#define xtea_init mbedtls_xtea_init +#define xtea_self_test mbedtls_xtea_self_test +#define xtea_setup mbedtls_xtea_setup + +#endif /* compat-1.3.h */ +#endif /* MBEDTLS_DEPRECATED_REMOVED */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/config.h new file mode 100644 index 0000000..0f7e29b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/config.h @@ -0,0 +1,2600 @@ +/** + * \file config.h + * + * \brief Configuration options (set of defines) + * + * This set of compile-time options may be used to enable + * or disable features selectively, and reduce the global + * memory footprint. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +/** + * \name SECTION: System support + * + * This section sets system specific settings. + * \{ + */ + +/** + * \def MBEDTLS_HAVE_ASM + * + * The compiler has support for asm(). + * + * Requires support for asm() in compiler. + * + * Used in: + * library/timing.c + * library/padlock.c + * include/mbedtls/bn_mul.h + * + * Comment to disable the use of assembly code. + */ +#define MBEDTLS_HAVE_ASM + +/** + * \def MBEDTLS_HAVE_SSE2 + * + * CPU supports SSE2 instruction set. + * + * Uncomment if the CPU supports SSE2 (IA-32 specific). + */ +//#define MBEDTLS_HAVE_SSE2 + +/** + * \def MBEDTLS_HAVE_TIME + * + * System has time.h and time(). + * The time does not need to be correct, only time differences are used, + * by contrast with MBEDTLS_HAVE_TIME_DATE + * + * Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT, + * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and + * MBEDTLS_PLATFORM_STD_TIME. + * + * Comment if your system does not support time functions + */ +#define MBEDTLS_HAVE_TIME + +/** + * \def MBEDTLS_HAVE_TIME_DATE + * + * System has time.h and time(), gmtime() and the clock is correct. + * The time needs to be correct (not necesarily very accurate, but at least + * the date should be correct). This is used to verify the validity period of + * X.509 certificates. + * + * Comment if your system does not have a correct clock. + */ +#define MBEDTLS_HAVE_TIME_DATE + +/** + * \def MBEDTLS_PLATFORM_MEMORY + * + * Enable the memory allocation layer. + * + * By default mbed TLS uses the system-provided calloc() and free(). + * This allows different allocators (self-implemented or provided) to be + * provided to the platform abstraction layer. + * + * Enabling MBEDTLS_PLATFORM_MEMORY without the + * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide + * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and + * free() function pointer at runtime. + * + * Enabling MBEDTLS_PLATFORM_MEMORY and specifying + * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the + * alternate function at compile time. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Enable this layer to allow use of alternative memory allocators. + */ +//#define MBEDTLS_PLATFORM_MEMORY + +/** + * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + * + * Do not assign standard functions in the platform layer (e.g. calloc() to + * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) + * + * This makes sure there are no linking errors on platforms that do not support + * these functions. You will HAVE to provide alternatives, either at runtime + * via the platform_set_xxx() functions or at compile time by setting + * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a + * MBEDTLS_PLATFORM_XXX_MACRO. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Uncomment to prevent default assignment of standard functions in the + * platform layer. + */ +//#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + +/** + * \def MBEDTLS_PLATFORM_EXIT_ALT + * + * MBEDTLS_PLATFORM_XXX_ALT: Uncomment a macro to let mbed TLS support the + * function in the platform abstraction layer. + * + * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will + * provide a function "mbedtls_platform_set_printf()" that allows you to set an + * alternative printf function pointer. + * + * All these define require MBEDTLS_PLATFORM_C to be defined! + * + * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; + * it will be enabled automatically by check_config.h + * + * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as + * MBEDTLS_PLATFORM_XXX_MACRO! + * + * Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME + * + * Uncomment a macro to enable alternate implementation of specific base + * platform function + */ +//#define MBEDTLS_PLATFORM_EXIT_ALT +//#define MBEDTLS_PLATFORM_TIME_ALT +//#define MBEDTLS_PLATFORM_FPRINTF_ALT +//#define MBEDTLS_PLATFORM_PRINTF_ALT +//#define MBEDTLS_PLATFORM_SNPRINTF_ALT +//#define MBEDTLS_PLATFORM_NV_SEED_ALT + +/** + * \def MBEDTLS_DEPRECATED_WARNING + * + * Mark deprecated functions so that they generate a warning if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * This only works with GCC and Clang. With other compilers, you may want to + * use MBEDTLS_DEPRECATED_REMOVED + * + * Uncomment to get warnings on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_WARNING + +/** + * \def MBEDTLS_DEPRECATED_REMOVED + * + * Remove deprecated functions so that they generate an error if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * Uncomment to get errors on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_REMOVED + +/* \} name SECTION: System support */ + +/** + * \name SECTION: mbed TLS feature support + * + * This section sets support for features that are or are not needed + * within the modules that are enabled. + * \{ + */ + +/** + * \def MBEDTLS_TIMING_ALT + * + * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), + * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() + * + * Only works if you have MBEDTLS_TIMING_C enabled. + * + * You will need to provide a header "timing_alt.h" and an implementation at + * compile time. + */ +//#define MBEDTLS_TIMING_ALT + +/** + * \def MBEDTLS_AES_ALT + * + * MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your + * alternate core implementation of a symmetric crypto or hash module (e.g. + * platform specific assembly optimized implementations). Keep in mind that + * the function prototypes should remain the same. + * + * This replaces the whole module. If you only want to replace one of the + * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer + * provide the "struct mbedtls_aes_context" definition and omit the base function + * declarations and implementations. "aes_alt.h" will be included from + * "aes.h" to include the new function definitions. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * module. + */ +//#define MBEDTLS_AES_ALT +//#define MBEDTLS_ARC4_ALT +//#define MBEDTLS_BLOWFISH_ALT +//#define MBEDTLS_CAMELLIA_ALT +//#define MBEDTLS_DES_ALT +//#define MBEDTLS_XTEA_ALT +//#define MBEDTLS_MD2_ALT +//#define MBEDTLS_MD4_ALT +//#define MBEDTLS_MD5_ALT +//#define MBEDTLS_RIPEMD160_ALT +//#define MBEDTLS_SHA1_ALT +//#define MBEDTLS_SHA256_ALT +//#define MBEDTLS_SHA512_ALT + +/** + * \def MBEDTLS_MD2_PROCESS_ALT + * + * MBEDTLS__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use you + * alternate core implementation of symmetric crypto or hash function. Keep in + * mind that function prototypes should remain the same. + * + * This replaces only one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will + * no longer provide the mbedtls_sha1_process() function, but it will still provide + * the other function (using your mbedtls_sha1_process() function) and the definition + * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible + * with this definition. + * + * Note: if you use the AES_xxx_ALT macros, then is is recommended to also set + * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES + * tables. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + */ +//#define MBEDTLS_MD2_PROCESS_ALT +//#define MBEDTLS_MD4_PROCESS_ALT +//#define MBEDTLS_MD5_PROCESS_ALT +//#define MBEDTLS_RIPEMD160_PROCESS_ALT +//#define MBEDTLS_SHA1_PROCESS_ALT +//#define MBEDTLS_SHA256_PROCESS_ALT +//#define MBEDTLS_SHA512_PROCESS_ALT +//#define MBEDTLS_DES_SETKEY_ALT +//#define MBEDTLS_DES_CRYPT_ECB_ALT +//#define MBEDTLS_DES3_CRYPT_ECB_ALT +//#define MBEDTLS_AES_SETKEY_ENC_ALT +//#define MBEDTLS_AES_SETKEY_DEC_ALT +//#define MBEDTLS_AES_ENCRYPT_ALT +//#define MBEDTLS_AES_DECRYPT_ALT + +/** + * \def MBEDTLS_TEST_NULL_ENTROPY + * + * Enables testing and use of mbed TLS without any configured entropy sources. + * This permits use of the library on platforms before an entropy source has + * been integrated (see for example the MBEDTLS_ENTROPY_HARDWARE_ALT or the + * MBEDTLS_ENTROPY_NV_SEED switches). + * + * WARNING! This switch MUST be disabled in production builds, and is suitable + * only for development. + * Enabling the switch negates any security provided by the library. + * + * Requires MBEDTLS_ENTROPY_C, MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + * + */ +//#define MBEDTLS_TEST_NULL_ENTROPY + +/** + * \def MBEDTLS_ENTROPY_HARDWARE_ALT + * + * Uncomment this macro to let mbed TLS use your own implementation of a + * hardware entropy collector. + * + * Your function must be called \c mbedtls_hardware_poll(), have the same + * prototype as declared in entropy_poll.h, and accept NULL as first argument. + * + * Uncomment to use your own hardware entropy collector. + */ +//#define MBEDTLS_ENTROPY_HARDWARE_ALT + +/** + * \def MBEDTLS_AES_ROM_TABLES + * + * Store the AES tables in ROM. + * + * Uncomment this macro to store the AES tables in ROM. + */ +//#define MBEDTLS_AES_ROM_TABLES + +/** + * \def MBEDTLS_CAMELLIA_SMALL_MEMORY + * + * Use less ROM for the Camellia implementation (saves about 768 bytes). + * + * Uncomment this macro to use less memory for Camellia. + */ +//#define MBEDTLS_CAMELLIA_SMALL_MEMORY + +/** + * \def MBEDTLS_CIPHER_MODE_CBC + * + * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CBC + +/** + * \def MBEDTLS_CIPHER_MODE_CFB + * + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CFB + +/** + * \def MBEDTLS_CIPHER_MODE_CTR + * + * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CTR + +/** + * \def MBEDTLS_CIPHER_NULL_CIPHER + * + * Enable NULL cipher. + * Warning: Only do so when you know what you are doing. This allows for + * encryption or channels without any security! + * + * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable + * the following ciphersuites: + * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA + * + * Uncomment this macro to enable the NULL cipher and ciphersuites + */ +//#define MBEDTLS_CIPHER_NULL_CIPHER + +/** + * \def MBEDTLS_CIPHER_PADDING_PKCS7 + * + * MBEDTLS_CIPHER_PADDING_XXX: Uncomment or comment macros to add support for + * specific padding modes in the cipher layer with cipher modes that support + * padding (e.g. CBC) + * + * If you disable all padding modes, only full blocks can be used with CBC. + * + * Enable padding modes in the cipher layer. + */ +#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#define MBEDTLS_CIPHER_PADDING_ZEROS + +/** + * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES + * + * Enable weak ciphersuites in SSL / TLS. + * Warning: Only do so when you know what you are doing. This allows for + * channels with virtually no security at all! + * + * This enables the following ciphersuites: + * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA + * + * Uncomment this macro to enable weak ciphersuites + */ +//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES + +/** + * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES + * + * Remove RC4 ciphersuites by default in SSL / TLS. + * This flag removes the ciphersuites based on RC4 from the default list as + * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to + * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them + * explicitly. + * + * Uncomment this macro to remove RC4 ciphersuites by default. + */ +#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES + +/** + * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED + * + * MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve + * module. By default all supported curves are enabled. + * + * Comment macros to disable the curve and functions for it + */ +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#define MBEDTLS_ECP_DP_BP512R1_ENABLED +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED + +/** + * \def MBEDTLS_ECP_NIST_OPTIM + * + * Enable specific 'modulo p' routines for each NIST prime. + * Depending on the prime and architecture, makes operations 4 to 8 times + * faster on the corresponding curve. + * + * Comment this macro to disable NIST curves optimisation. + */ +#define MBEDTLS_ECP_NIST_OPTIM + +/** + * \def MBEDTLS_ECDSA_DETERMINISTIC + * + * Enable deterministic ECDSA (RFC 6979). + * Standard ECDSA is "fragile" in the sense that lack of entropy when signing + * may result in a compromise of the long-term signing key. This is avoided by + * the deterministic variant. + * + * Requires: MBEDTLS_HMAC_DRBG_C + * + * Comment this macro to disable deterministic ECDSA. + */ +#define MBEDTLS_ECDSA_DETERMINISTIC + +/** + * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + * + * Enable the PSK based ciphersuite modes in SSL / TLS. + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + * + * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + * + * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + * + * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + * + * Enable the RSA-only based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + */ +#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + * + * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + * + * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + * + * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + * + * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + * + * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + * + * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Requires: MBEDTLS_ECJPAKE_C + * MBEDTLS_SHA256_C + * MBEDTLS_ECP_DP_SECP256R1_ENABLED + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + +/** + * \def MBEDTLS_PK_PARSE_EC_EXTENDED + * + * Enhance support for reading EC keys using variants of SEC1 not allowed by + * RFC 5915 and RFC 5480. + * + * Currently this means parsing the SpecifiedECDomain choice of EC + * parameters (only known groups are supported, not arbitrary domains, to + * avoid validation issues). + * + * Disable if you only need to support RFC 5915 + 5480 key formats. + */ +#define MBEDTLS_PK_PARSE_EC_EXTENDED + +/** + * \def MBEDTLS_ERROR_STRERROR_DUMMY + * + * Enable a dummy error function to make use of mbedtls_strerror() in + * third party libraries easier when MBEDTLS_ERROR_C is disabled + * (no effect when MBEDTLS_ERROR_C is enabled). + * + * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're + * not using mbedtls_strerror() or error_strerror() in your application. + * + * Disable if you run into name conflicts and want to really remove the + * mbedtls_strerror() + */ +#define MBEDTLS_ERROR_STRERROR_DUMMY + +/** + * \def MBEDTLS_GENPRIME + * + * Enable the prime-number generation code. + * + * Requires: MBEDTLS_BIGNUM_C + */ +#define MBEDTLS_GENPRIME + +/** + * \def MBEDTLS_FS_IO + * + * Enable functions that use the filesystem. + */ +#define MBEDTLS_FS_IO + +/** + * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + * + * Do not add default entropy sources. These are the platform specific, + * mbedtls_timing_hardclock and HAVEGE based poll functions. + * + * This is useful to have more control over the added entropy sources in an + * application. + * + * Uncomment this macro to prevent loading of default entropy functions. + */ +//#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + +/** + * \def MBEDTLS_NO_PLATFORM_ENTROPY + * + * Do not use built-in platform entropy functions. + * This is useful if your platform does not support + * standards like the /dev/urandom or Windows CryptoAPI. + * + * Uncomment this macro to disable the built-in platform entropy functions. + */ +//#define MBEDTLS_NO_PLATFORM_ENTROPY + +/** + * \def MBEDTLS_ENTROPY_FORCE_SHA256 + * + * Force the entropy accumulator to use a SHA-256 accumulator instead of the + * default SHA-512 based one (if both are available). + * + * Requires: MBEDTLS_SHA256_C + * + * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option + * if you have performance concerns. + * + * This option is only useful if both MBEDTLS_SHA256_C and + * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. + */ +//#define MBEDTLS_ENTROPY_FORCE_SHA256 + +/** + * \def MBEDTLS_ENTROPY_NV_SEED + * + * Enable the non-volatile (NV) seed file-based entropy source. + * (Also enables the NV seed read/write functions in the platform layer) + * + * This is crucial (if not required) on systems that do not have a + * cryptographic entropy source (in hardware or kernel) available. + * + * Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C + * + * \note The read/write functions that are used by the entropy source are + * determined in the platform layer, and can be modified at runtime and/or + * compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used. + * + * \note If you use the default implementation functions that read a seedfile + * with regular fopen(), please make sure you make a seedfile with the + * proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at + * least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from + * and written to or you will get an entropy source error! The default + * implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE + * bytes from the file. + * + * \note The entropy collector will write to the seed file before entropy is + * given to an external source, to update it. + */ +//#define MBEDTLS_ENTROPY_NV_SEED + +/** + * \def MBEDTLS_MEMORY_DEBUG + * + * Enable debugging of buffer allocator memory issues. Automatically prints + * (to stderr) all (fatal) messages on memory allocation issues. Enables + * function for 'debug output' of allocated memory. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Uncomment this macro to let the buffer allocator print out error messages. + */ +//#define MBEDTLS_MEMORY_DEBUG + +/** + * \def MBEDTLS_MEMORY_BACKTRACE + * + * Include backtrace information with each allocated block. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * GLIBC-compatible backtrace() an backtrace_symbols() support + * + * Uncomment this macro to include backtrace information + */ +//#define MBEDTLS_MEMORY_BACKTRACE + +/** + * \def MBEDTLS_PK_RSA_ALT_SUPPORT + * + * Support external private RSA keys (eg from a HSM) in the PK layer. + * + * Comment this macro to disable support for external private RSA keys. + */ +#define MBEDTLS_PK_RSA_ALT_SUPPORT + +/** + * \def MBEDTLS_PKCS1_V15 + * + * Enable support for PKCS#1 v1.5 encoding. + * + * Requires: MBEDTLS_RSA_C + * + * This enables support for PKCS#1 v1.5 operations. + */ +#define MBEDTLS_PKCS1_V15 + +/** + * \def MBEDTLS_PKCS1_V21 + * + * Enable support for PKCS#1 v2.1 encoding. + * + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C + * + * This enables support for RSAES-OAEP and RSASSA-PSS operations. + */ +#define MBEDTLS_PKCS1_V21 + +/** + * \def MBEDTLS_RSA_NO_CRT + * + * Do not use the Chinese Remainder Theorem for the RSA private operation. + * + * Uncomment this macro to disable the use of CRT in RSA. + * + */ +//#define MBEDTLS_RSA_NO_CRT + +/** + * \def MBEDTLS_SELF_TEST + * + * Enable the checkup functions (*_self_test). + */ +#define MBEDTLS_SELF_TEST + +/** + * \def MBEDTLS_SHA256_SMALLER + * + * Enable an implementation of SHA-256 that has lower ROM footprint but also + * lower performance. + * + * The default implementation is meant to be a reasonnable compromise between + * performance and size. This version optimizes more aggressively for size at + * the expense of performance. Eg on Cortex-M4 it reduces the size of + * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about + * 30%. + * + * Uncomment to enable the smaller implementation of SHA256. + */ +//#define MBEDTLS_SHA256_SMALLER + +/** + * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES + * + * Enable sending of alert messages in case of encountered errors as per RFC. + * If you choose not to send the alert messages, mbed TLS can still communicate + * with other servers, only debugging of failures is harder. + * + * The advantage of not sending alert messages, is that no information is given + * about reasons for failures thus preventing adversaries of gaining intel. + * + * Enable sending of all alert messages + */ +#define MBEDTLS_SSL_ALL_ALERT_MESSAGES + +/** + * \def MBEDTLS_SSL_DEBUG_ALL + * + * Enable the debug messages in SSL module for all issues. + * Debug messages have been disabled in some places to prevent timing + * attacks due to (unbalanced) debugging function calls. + * + * If you need all error reporting you should enable this during debugging, + * but remove this for production servers that should log as well. + * + * Uncomment this macro to report all debug messages on errors introducing + * a timing side-channel. + * + */ +//#define MBEDTLS_SSL_DEBUG_ALL + +/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC + * + * Enable support for Encrypt-then-MAC, RFC 7366. + * + * This allows peers that both support it to use a more robust protection for + * ciphersuites using CBC, providing deep resistance against timing attacks + * on the padding or underlying cipher. + * + * This only affects CBC ciphersuites, and is useless if none is defined. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Encrypt-then-MAC + */ +#define MBEDTLS_SSL_ENCRYPT_THEN_MAC + +/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET + * + * Enable support for Extended Master Secret, aka Session Hash + * (draft-ietf-tls-session-hash-02). + * + * This was introduced as "the proper fix" to the Triple Handshake familiy of + * attacks, but it is recommended to always use it (even if you disable + * renegotiation), since it actually fixes a more fundamental issue in the + * original SSL/TLS design, and has implications beyond Triple Handshake. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Extended Master Secret. + */ +#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET + +/** + * \def MBEDTLS_SSL_FALLBACK_SCSV + * + * Enable support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv-00). + * + * For servers, it is recommended to always enable this, unless you support + * only one version of TLS, or know for sure that none of your clients + * implements a fallback strategy. + * + * For clients, you only need this if you're using a fallback strategy, which + * is not recommended in the first place, unless you absolutely need it to + * interoperate with buggy (version-intolerant) servers. + * + * Comment this macro to disable support for FALLBACK_SCSV + */ +#define MBEDTLS_SSL_FALLBACK_SCSV + +/** + * \def MBEDTLS_SSL_HW_RECORD_ACCEL + * + * Enable hooking functions in SSL module for hardware acceleration of + * individual records. + * + * Uncomment this macro to enable hooking functions. + */ +//#define MBEDTLS_SSL_HW_RECORD_ACCEL + +/** + * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING + * + * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. + * + * This is a countermeasure to the BEAST attack, which also minimizes the risk + * of interoperability issues compared to sending 0-length records. + * + * Comment this macro to disable 1/n-1 record splitting. + */ +#define MBEDTLS_SSL_CBC_RECORD_SPLITTING + +/** + * \def MBEDTLS_SSL_RENEGOTIATION + * + * Disable support for TLS renegotiation. + * + * The two main uses of renegotiation are (1) refresh keys on long-lived + * connections and (2) client authentication after the initial handshake. + * If you don't need renegotiation, it's probably better to disable it, since + * it has been associated with security issues in the past and is easy to + * misuse/misunderstand. + * + * Comment this to disable support for renegotiation. + */ +#define MBEDTLS_SSL_RENEGOTIATION + +/** + * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + * + * Enable support for receiving and parsing SSLv2 Client Hello messages for the + * SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to enable support for SSLv2 Client Hello messages. + */ +//#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + +/** + * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + * + * Pick the ciphersuite according to the client's preferences rather than ours + * in the SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to respect client's ciphersuite order + */ +//#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + +/** + * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + * + * Enable support for RFC 6066 max_fragment_length extension in SSL. + * + * Comment this macro to disable support for the max_fragment_length extension + */ +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + +/** + * \def MBEDTLS_SSL_PROTO_SSL3 + * + * Enable support for SSL 3.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for SSL 3.0 + */ +//#define MBEDTLS_SSL_PROTO_SSL3 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1 + * + * Enable support for TLS 1.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.0 + */ +#define MBEDTLS_SSL_PROTO_TLS1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_1 + * + * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 + */ +#define MBEDTLS_SSL_PROTO_TLS1_1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_2 + * + * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). + * + * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C + * (Depends on ciphersuites) + * + * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 + */ +#define MBEDTLS_SSL_PROTO_TLS1_2 + +/** + * \def MBEDTLS_SSL_PROTO_DTLS + * + * Enable support for DTLS (all available versions). + * + * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, + * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_1 + * or MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for DTLS + */ +#define MBEDTLS_SSL_PROTO_DTLS + +/** + * \def MBEDTLS_SSL_ALPN + * + * Enable support for RFC 7301 Application Layer Protocol Negotiation. + * + * Comment this macro to disable support for ALPN. + */ +#define MBEDTLS_SSL_ALPN + +/** + * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY + * + * Enable support for the anti-replay mechanism in DTLS. + * + * Requires: MBEDTLS_SSL_TLS_C + * MBEDTLS_SSL_PROTO_DTLS + * + * \warning Disabling this is often a security risk! + * See mbedtls_ssl_conf_dtls_anti_replay() for details. + * + * Comment this to disable anti-replay in DTLS. + */ +#define MBEDTLS_SSL_DTLS_ANTI_REPLAY + +/** + * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Enable support for HelloVerifyRequest on DTLS servers. + * + * This feature is highly recommended to prevent DTLS servers being used as + * amplifiers in DoS attacks against other hosts. It should always be enabled + * unless you know for sure amplification cannot be a problem in the + * environment in which your server operates. + * + * \warning Disabling this can ba a security risk! (see above) + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Comment this to disable support for HelloVerifyRequest. + */ +#define MBEDTLS_SSL_DTLS_HELLO_VERIFY + +/** + * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + * + * Enable server-side support for clients that reconnect from the same port. + * + * Some clients unexpectedly close the connection and try to reconnect using the + * same source port. This needs special support from the server to handle the + * new connection securely, as described in section 4.2.8 of RFC 6347. This + * flag enables that support. + * + * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Comment this to disable support for clients reusing the source port. + */ +#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + +/** + * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT + * + * Enable support for a limit of records with bad MAC. + * + * See mbedtls_ssl_conf_dtls_badmac_limit(). + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + */ +#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT + +/** + * \def MBEDTLS_SSL_SESSION_TICKETS + * + * Enable support for RFC 5077 session tickets in SSL. + * Client-side, provides full support for session tickets (maintainance of a + * session store remains the responsibility of the application, though). + * Server-side, you also need to provide callbacks for writing and parsing + * tickets, including authenticated encryption and key management. Example + * callbacks are provided by MBEDTLS_SSL_TICKET_C. + * + * Comment this macro to disable support for SSL session tickets + */ +#define MBEDTLS_SSL_SESSION_TICKETS + +/** + * \def MBEDTLS_SSL_EXPORT_KEYS + * + * Enable support for exporting key block and master secret. + * This is required for certain users of TLS, e.g. EAP-TLS. + * + * Comment this macro to disable support for key export + */ +#define MBEDTLS_SSL_EXPORT_KEYS + +/** + * \def MBEDTLS_SSL_SERVER_NAME_INDICATION + * + * Enable support for RFC 6066 server name indication (SNI) in SSL. + * + * Requires: MBEDTLS_X509_CRT_PARSE_C + * + * Comment this macro to disable support for server name indication in SSL + */ +#define MBEDTLS_SSL_SERVER_NAME_INDICATION + +/** + * \def MBEDTLS_SSL_TRUNCATED_HMAC + * + * Enable support for RFC 6066 truncated HMAC in SSL. + * + * Comment this macro to disable support for truncated HMAC in SSL + */ +#define MBEDTLS_SSL_TRUNCATED_HMAC + +/** + * \def MBEDTLS_THREADING_ALT + * + * Provide your own alternate threading implementation. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to allow your own alternate threading implementation. + */ +//#define MBEDTLS_THREADING_ALT + +/** + * \def MBEDTLS_THREADING_PTHREAD + * + * Enable the pthread wrapper layer for the threading layer. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to enable pthread mutexes. + */ +//#define MBEDTLS_THREADING_PTHREAD + +/** + * \def MBEDTLS_VERSION_FEATURES + * + * Allow run-time checking of compile-time enabled features. Thus allowing users + * to check at run-time if the library is for instance compiled with threading + * support via mbedtls_version_check_feature(). + * + * Requires: MBEDTLS_VERSION_C + * + * Comment this to disable run-time checking and save ROM space + */ +#define MBEDTLS_VERSION_FEATURES + +/** + * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an extension in a v1 or v2 certificate. + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + +/** + * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an unknown critical extension. + * + * \warning Depending on your PKI use, enabling this can be a security risk! + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + +/** + * \def MBEDTLS_X509_CHECK_KEY_USAGE + * + * Enable verification of the keyUsage extension (CA and leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused + * (intermediate) CA and leaf certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip keyUsage checking for both CA and leaf certificates. + */ +#define MBEDTLS_X509_CHECK_KEY_USAGE + +/** + * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + * + * Enable verification of the extendedKeyUsage extension (leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip extendedKeyUsage checking for certificates. + */ +#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + +/** + * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT + * + * Enable parsing and verification of X.509 certificates, CRLs and CSRS + * signed with RSASSA-PSS (aka PKCS#1 v2.1). + * + * Comment this macro to disallow using RSASSA-PSS in certificates. + */ +#define MBEDTLS_X509_RSASSA_PSS_SUPPORT + +/** + * \def MBEDTLS_ZLIB_SUPPORT + * + * If set, the SSL/TLS module uses ZLIB to support compression and + * decompression of packet data. + * + * \warning TLS-level compression MAY REDUCE SECURITY! See for example the + * CRIME attack. Before enabling this option, you should examine with care if + * CRIME or similar exploits may be a applicable to your use case. + * + * \note Currently compression can't be used with DTLS. + * + * Used in: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This feature requires zlib library and headers to be present. + * + * Uncomment to enable use of ZLIB + */ +//#define MBEDTLS_ZLIB_SUPPORT +/* \} name SECTION: mbed TLS feature support */ + +/** + * \name SECTION: mbed TLS modules + * + * This section enables or disables entire modules in mbed TLS + * \{ + */ + +/** + * \def MBEDTLS_AESNI_C + * + * Enable AES-NI support on x86-64. + * + * Module: library/aesni.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the AES-NI instructions on x86-64 + */ +#define MBEDTLS_AESNI_C + +/** + * \def MBEDTLS_AES_C + * + * Enable the AES block cipher. + * + * Module: library/aes.c + * Caller: library/ssl_tls.c + * library/pem.c + * library/ctr_drbg.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * + * PEM_PARSE uses AES for decrypting encrypted keys. + */ +#define MBEDTLS_AES_C + +/** + * \def MBEDTLS_ARC4_C + * + * Enable the ARCFOUR stream cipher. + * + * Module: library/arc4.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_ARC4_C + +/** + * \def MBEDTLS_ASN1_PARSE_C + * + * Enable the generic ASN1 parser. + * + * Module: library/asn1.c + * Caller: library/x509.c + * library/dhm.c + * library/pkcs12.c + * library/pkcs5.c + * library/pkparse.c + */ +#define MBEDTLS_ASN1_PARSE_C + +/** + * \def MBEDTLS_ASN1_WRITE_C + * + * Enable the generic ASN1 writer. + * + * Module: library/asn1write.c + * Caller: library/ecdsa.c + * library/pkwrite.c + * library/x509_create.c + * library/x509write_crt.c + * library/x509write_csr.c + */ +#define MBEDTLS_ASN1_WRITE_C + +/** + * \def MBEDTLS_BASE64_C + * + * Enable the Base64 module. + * + * Module: library/base64.c + * Caller: library/pem.c + * + * This module is required for PEM support (required by X.509). + */ +#define MBEDTLS_BASE64_C + +/** + * \def MBEDTLS_BIGNUM_C + * + * Enable the multi-precision integer library. + * + * Module: library/bignum.c + * Caller: library/dhm.c + * library/ecp.c + * library/ecdsa.c + * library/rsa.c + * library/ssl_tls.c + * + * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. + */ +#define MBEDTLS_BIGNUM_C + +/** + * \def MBEDTLS_BLOWFISH_C + * + * Enable the Blowfish block cipher. + * + * Module: library/blowfish.c + */ +#define MBEDTLS_BLOWFISH_C + +/** + * \def MBEDTLS_CAMELLIA_C + * + * Enable the Camellia block cipher. + * + * Module: library/camellia.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +#define MBEDTLS_CAMELLIA_C + +/** + * \def MBEDTLS_CCM_C + * + * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. + * + * Module: library/ccm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-CCM ciphersuites, if other requisites are + * enabled as well. + */ +#define MBEDTLS_CCM_C + +/** + * \def MBEDTLS_CERTS_C + * + * Enable the test certificates. + * + * Module: library/certs.c + * Caller: + * + * This module is used for testing (ssl_client/server). + */ +#define MBEDTLS_CERTS_C + +/** + * \def MBEDTLS_CIPHER_C + * + * Enable the generic cipher layer. + * + * Module: library/cipher.c + * Caller: library/ssl_tls.c + * + * Uncomment to enable generic cipher wrappers. + */ +#define MBEDTLS_CIPHER_C + +/** + * \def MBEDTLS_CMAC_C + * + * Enable the CMAC (Cipher-based Message Authentication Code) mode for block + * ciphers. + * + * Module: library/cmac.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C + * + */ +//#define MBEDTLS_CMAC_C + +/** + * \def MBEDTLS_CTR_DRBG_C + * + * Enable the CTR_DRBG AES-256-based random generator. + * + * Module: library/ctr_drbg.c + * Caller: + * + * Requires: MBEDTLS_AES_C + * + * This module provides the CTR_DRBG AES-256 random number generator. + */ +#define MBEDTLS_CTR_DRBG_C + +/** + * \def MBEDTLS_DEBUG_C + * + * Enable the debug functions. + * + * Module: library/debug.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module provides debugging functions. + */ +#define MBEDTLS_DEBUG_C + +/** + * \def MBEDTLS_DES_C + * + * Enable the DES block cipher. + * + * Module: library/des.c + * Caller: library/pem.c + * library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * + * PEM_PARSE uses DES/3DES for decrypting encrypted keys. + */ +#define MBEDTLS_DES_C + +/** + * \def MBEDTLS_DHM_C + * + * Enable the Diffie-Hellman-Merkle module. + * + * Module: library/dhm.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * DHE-RSA, DHE-PSK + */ +#define MBEDTLS_DHM_C + +/** + * \def MBEDTLS_ECDH_C + * + * Enable the elliptic curve Diffie-Hellman library. + * + * Module: library/ecdh.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK + * + * Requires: MBEDTLS_ECP_C + */ +#define MBEDTLS_ECDH_C + +/** + * \def MBEDTLS_ECDSA_C + * + * Enable the elliptic curve DSA library. + * + * Module: library/ecdsa.c + * Caller: + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C + */ +#define MBEDTLS_ECDSA_C + +/** + * \def MBEDTLS_ECJPAKE_C + * + * Enable the elliptic curve J-PAKE library. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Module: library/ecjpake.c + * Caller: + * + * This module is used by the following key exchanges: + * ECJPAKE + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C + */ +//#define MBEDTLS_ECJPAKE_C + +/** + * \def MBEDTLS_ECP_C + * + * Enable the elliptic curve over GF(p) library. + * + * Module: library/ecp.c + * Caller: library/ecdh.c + * library/ecdsa.c + * library/ecjpake.c + * + * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED + */ +#define MBEDTLS_ECP_C + +/** + * \def MBEDTLS_ENTROPY_C + * + * Enable the platform-specific entropy code. + * + * Module: library/entropy.c + * Caller: + * + * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C + * + * This module provides a generic entropy pool + */ +#define MBEDTLS_ENTROPY_C + +/** + * \def MBEDTLS_ERROR_C + * + * Enable error code to error string conversion. + * + * Module: library/error.c + * Caller: + * + * This module enables mbedtls_strerror(). + */ +#define MBEDTLS_ERROR_C + +/** + * \def MBEDTLS_GCM_C + * + * Enable the Galois/Counter Mode (GCM) for AES. + * + * Module: library/gcm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other + * requisites are enabled as well. + */ +#define MBEDTLS_GCM_C + +/** + * \def MBEDTLS_HAVEGE_C + * + * Enable the HAVEGE random generator. + * + * Warning: the HAVEGE random generator is not suitable for virtualized + * environments + * + * Warning: the HAVEGE random generator is dependent on timing and specific + * processor traits. It is therefore not advised to use HAVEGE as + * your applications primary random generator or primary entropy pool + * input. As a secondary input to your entropy pool, it IS able add + * the (limited) extra entropy it provides. + * + * Module: library/havege.c + * Caller: + * + * Requires: MBEDTLS_TIMING_C + * + * Uncomment to enable the HAVEGE random generator. + */ +//#define MBEDTLS_HAVEGE_C + +/** + * \def MBEDTLS_HMAC_DRBG_C + * + * Enable the HMAC_DRBG random generator. + * + * Module: library/hmac_drbg.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * Uncomment to enable the HMAC_DRBG random number geerator. + */ +#define MBEDTLS_HMAC_DRBG_C + +/** + * \def MBEDTLS_MD_C + * + * Enable the generic message digest layer. + * + * Module: library/md.c + * Caller: + * + * Uncomment to enable generic message digest wrappers. + */ +#define MBEDTLS_MD_C + +/** + * \def MBEDTLS_MD2_C + * + * Enable the MD2 hash algorithm. + * + * Module: library/md2.c + * Caller: + * + * Uncomment to enable support for (rare) MD2-signed X.509 certs. + */ +//#define MBEDTLS_MD2_C + +/** + * \def MBEDTLS_MD4_C + * + * Enable the MD4 hash algorithm. + * + * Module: library/md4.c + * Caller: + * + * Uncomment to enable support for (rare) MD4-signed X.509 certs. + */ +//#define MBEDTLS_MD4_C + +/** + * \def MBEDTLS_MD5_C + * + * Enable the MD5 hash algorithm. + * + * Module: library/md5.c + * Caller: library/md.c + * library/pem.c + * library/ssl_tls.c + * + * This module is required for SSL/TLS and X.509. + * PEM_PARSE uses MD5 for decrypting encrypted keys. + */ +#define MBEDTLS_MD5_C + +/** + * \def MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Enable the buffer allocator implementation that makes use of a (stack) + * based buffer to 'allocate' dynamic memory. (replaces calloc() and free() + * calls) + * + * Module: library/memory_buffer_alloc.c + * + * Requires: MBEDTLS_PLATFORM_C + * MBEDTLS_PLATFORM_MEMORY (to use it within mbed TLS) + * + * Enable this module to enable the buffer memory allocator. + */ +//#define MBEDTLS_MEMORY_BUFFER_ALLOC_C + +/** + * \def MBEDTLS_NET_C + * + * Enable the TCP and UDP over IPv6/IPv4 networking routines. + * + * \note This module only works on POSIX/Unix (including Linux, BSD and OS X) + * and Windows. For other platforms, you'll want to disable it, and write your + * own networking callbacks to be passed to \c mbedtls_ssl_set_bio(). + * + * \note See also our Knowledge Base article about porting to a new + * environment: + * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS + * + * Module: library/net_sockets.c + * + * This module provides networking routines. + */ +#define MBEDTLS_NET_C + +/** + * \def MBEDTLS_OID_C + * + * Enable the OID database. + * + * Module: library/oid.c + * Caller: library/asn1write.c + * library/pkcs5.c + * library/pkparse.c + * library/pkwrite.c + * library/rsa.c + * library/x509.c + * library/x509_create.c + * library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c + * library/x509write_crt.c + * library/x509write_csr.c + * + * This modules translates between OIDs and internal values. + */ +#define MBEDTLS_OID_C + +/** + * \def MBEDTLS_PADLOCK_C + * + * Enable VIA Padlock support on x86. + * + * Module: library/padlock.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the VIA PadLock on x86. + */ +#define MBEDTLS_PADLOCK_C + +/** + * \def MBEDTLS_PEM_PARSE_C + * + * Enable PEM decoding / parsing. + * + * Module: library/pem.c + * Caller: library/dhm.c + * library/pkparse.c + * library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for decoding / parsing PEM files. + */ +#define MBEDTLS_PEM_PARSE_C + +/** + * \def MBEDTLS_PEM_WRITE_C + * + * Enable PEM encoding / writing. + * + * Module: library/pem.c + * Caller: library/pkwrite.c + * library/x509write_crt.c + * library/x509write_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for encoding / writing PEM files. + */ +#define MBEDTLS_PEM_WRITE_C + +/** + * \def MBEDTLS_PK_C + * + * Enable the generic public (asymetric) key layer. + * + * Module: library/pk.c + * Caller: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C + * + * Uncomment to enable generic public key wrappers. + */ +#define MBEDTLS_PK_C + +/** + * \def MBEDTLS_PK_PARSE_C + * + * Enable the generic public (asymetric) key parser. + * + * Module: library/pkparse.c + * Caller: library/x509_crt.c + * library/x509_csr.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key parse functions. + */ +#define MBEDTLS_PK_PARSE_C + +/** + * \def MBEDTLS_PK_WRITE_C + * + * Enable the generic public (asymetric) key writer. + * + * Module: library/pkwrite.c + * Caller: library/x509write.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key write functions. + */ +#define MBEDTLS_PK_WRITE_C + +/** + * \def MBEDTLS_PKCS5_C + * + * Enable PKCS#5 functions. + * + * Module: library/pkcs5.c + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the PKCS#5 functions. + */ +#define MBEDTLS_PKCS5_C + +/** + * \def MBEDTLS_PKCS11_C + * + * Enable wrapper for PKCS#11 smartcard support. + * + * Module: library/pkcs11.c + * Caller: library/pk.c + * + * Requires: MBEDTLS_PK_C + * + * This module enables SSL/TLS PKCS #11 smartcard support. + * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) + */ +//#define MBEDTLS_PKCS11_C + +/** + * \def MBEDTLS_PKCS12_C + * + * Enable PKCS#12 PBE functions. + * Adds algorithms for parsing PKCS#8 encrypted private keys + * + * Module: library/pkcs12.c + * Caller: library/pkparse.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * Can use: MBEDTLS_ARC4_C + * + * This module enables PKCS#12 functions. + */ +#define MBEDTLS_PKCS12_C + +/** + * \def MBEDTLS_PLATFORM_C + * + * Enable the platform abstraction layer that allows you to re-assign + * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). + * + * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT + * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned + * above to be specified at runtime or compile time respectively. + * + * \note This abstraction layer must be enabled on Windows (including MSYS2) + * as other module rely on it for a fixed snprintf implementation. + * + * Module: library/platform.c + * Caller: Most other .c files + * + * This module enables abstraction of common (libc) functions. + */ +#define MBEDTLS_PLATFORM_C + +/** + * \def MBEDTLS_RIPEMD160_C + * + * Enable the RIPEMD-160 hash algorithm. + * + * Module: library/ripemd160.c + * Caller: library/md.c + * + */ +#define MBEDTLS_RIPEMD160_C + +/** + * \def MBEDTLS_RSA_C + * + * Enable the RSA public-key cryptosystem. + * + * Module: library/rsa.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509.c + * + * This module is used by the following key exchanges: + * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C + */ +#define MBEDTLS_RSA_C + +/** + * \def MBEDTLS_SHA1_C + * + * Enable the SHA1 cryptographic hash algorithm. + * + * Module: library/sha1.c + * Caller: library/md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509write_crt.c + * + * This module is required for SSL/TLS and SHA1-signed certificates. + */ +#define MBEDTLS_SHA1_C + +/** + * \def MBEDTLS_SHA256_C + * + * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. + * + * Module: library/sha256.c + * Caller: library/entropy.c + * library/md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module adds support for SHA-224 and SHA-256. + * This module is required for the SSL/TLS 1.2 PRF function. + */ +#define MBEDTLS_SHA256_C + +/** + * \def MBEDTLS_SHA512_C + * + * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. + * + * Module: library/sha512.c + * Caller: library/entropy.c + * library/md.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This module adds support for SHA-384 and SHA-512. + */ +#define MBEDTLS_SHA512_C + +/** + * \def MBEDTLS_SSL_CACHE_C + * + * Enable simple SSL cache implementation. + * + * Module: library/ssl_cache.c + * Caller: + * + * Requires: MBEDTLS_SSL_CACHE_C + */ +#define MBEDTLS_SSL_CACHE_C + +/** + * \def MBEDTLS_SSL_COOKIE_C + * + * Enable basic implementation of DTLS cookies for hello verification. + * + * Module: library/ssl_cookie.c + * Caller: + */ +#define MBEDTLS_SSL_COOKIE_C + +/** + * \def MBEDTLS_SSL_TICKET_C + * + * Enable an implementation of TLS server-side callbacks for session tickets. + * + * Module: library/ssl_ticket.c + * Caller: + * + * Requires: MBEDTLS_CIPHER_C + */ +#define MBEDTLS_SSL_TICKET_C + +/** + * \def MBEDTLS_SSL_CLI_C + * + * Enable the SSL/TLS client code. + * + * Module: library/ssl_cli.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS client support. + */ +#define MBEDTLS_SSL_CLI_C + +/** + * \def MBEDTLS_SSL_SRV_C + * + * Enable the SSL/TLS server code. + * + * Module: library/ssl_srv.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS server support. + */ +#define MBEDTLS_SSL_SRV_C + +/** + * \def MBEDTLS_SSL_TLS_C + * + * Enable the generic SSL/TLS code. + * + * Module: library/ssl_tls.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * and at least one of the MBEDTLS_SSL_PROTO_XXX defines + * + * This module is required for SSL/TLS. + */ +#define MBEDTLS_SSL_TLS_C + +/** + * \def MBEDTLS_THREADING_C + * + * Enable the threading abstraction layer. + * By default mbed TLS assumes it is used in a non-threaded environment or that + * contexts are not shared between threads. If you do intend to use contexts + * between threads, you will need to enable this layer to prevent race + * conditions. See also our Knowledge Base article about threading: + * https://tls.mbed.org/kb/development/thread-safety-and-multi-threading + * + * Module: library/threading.c + * + * This allows different threading implementations (self-implemented or + * provided). + * + * You will have to enable either MBEDTLS_THREADING_ALT or + * MBEDTLS_THREADING_PTHREAD. + * + * Enable this layer to allow use of mutexes within mbed TLS + */ +//#define MBEDTLS_THREADING_C + +/** + * \def MBEDTLS_TIMING_C + * + * Enable the semi-portable timing interface. + * + * \note The provided implementation only works on POSIX/Unix (including Linux, + * BSD and OS X) and Windows. On other platforms, you can either disable that + * module and provide your own implementations of the callbacks needed by + * \c mbedtls_ssl_set_timer_cb() for DTLS, or leave it enabled and provide + * your own implementation of the whole module by setting + * \c MBEDTLS_TIMING_ALT in the current file. + * + * \note See also our Knowledge Base article about porting to a new + * environment: + * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS + * + * Module: library/timing.c + * Caller: library/havege.c + * + * This module is used by the HAVEGE random number generator. + */ +#define MBEDTLS_TIMING_C + +/** + * \def MBEDTLS_VERSION_C + * + * Enable run-time version information. + * + * Module: library/version.c + * + * This module provides run-time version information. + */ +#define MBEDTLS_VERSION_C + +/** + * \def MBEDTLS_X509_USE_C + * + * Enable X.509 core for using certificates. + * + * Module: library/x509.c + * Caller: library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, + * MBEDTLS_PK_PARSE_C + * + * This module is required for the X.509 parsing modules. + */ +#define MBEDTLS_X509_USE_C + +/** + * \def MBEDTLS_X509_CRT_PARSE_C + * + * Enable X.509 certificate parsing. + * + * Module: library/x509_crt.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 certificate parsing. + */ +#define MBEDTLS_X509_CRT_PARSE_C + +/** + * \def MBEDTLS_X509_CRL_PARSE_C + * + * Enable X.509 CRL parsing. + * + * Module: library/x509_crl.c + * Caller: library/x509_crt.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 CRL parsing. + */ +#define MBEDTLS_X509_CRL_PARSE_C + +/** + * \def MBEDTLS_X509_CSR_PARSE_C + * + * Enable X.509 Certificate Signing Request (CSR) parsing. + * + * Module: library/x509_csr.c + * Caller: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is used for reading X.509 certificate request. + */ +#define MBEDTLS_X509_CSR_PARSE_C + +/** + * \def MBEDTLS_X509_CREATE_C + * + * Enable X.509 core for creating certificates. + * + * Module: library/x509_create.c + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C + * + * This module is the basis for creating X.509 certificates and CSRs. + */ +#define MBEDTLS_X509_CREATE_C + +/** + * \def MBEDTLS_X509_CRT_WRITE_C + * + * Enable creating X.509 certificates. + * + * Module: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate creation. + */ +#define MBEDTLS_X509_CRT_WRITE_C + +/** + * \def MBEDTLS_X509_CSR_WRITE_C + * + * Enable creating X.509 Certificate Signing Requests (CSR). + * + * Module: library/x509_csr_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate request writing. + */ +#define MBEDTLS_X509_CSR_WRITE_C + +/** + * \def MBEDTLS_XTEA_C + * + * Enable the XTEA block cipher. + * + * Module: library/xtea.c + * Caller: + */ +#define MBEDTLS_XTEA_C + +/* \} name SECTION: mbed TLS modules */ + +/** + * \name SECTION: Module configuration options + * + * This section allows for the setting of module specific sizes and + * configuration options. The default values are already present in the + * relevant header files and should suffice for the regular use cases. + * + * Our advice is to enable options and change their values here + * only if you have a good reason and know the consequences. + * + * Please check the respective header file for documentation on these + * parameters (to prevent duplicate documentation). + * \{ + */ + +/* MPI / BIGNUM options */ +//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ +//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ + +/* CTR_DRBG options */ +//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ +//#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* HMAC_DRBG options */ +//#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* ECP options */ +//#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ +//#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ + +/* Entropy options */ +//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ +//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ +//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */ + +/* Memory buffer allocator options */ +//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ + +/* Platform options */ +//#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ +//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ +//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" /**< Seed file to read/write with default implementation */ + +/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ +/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ +//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ +//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ +//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ +//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ + +/* SSL Cache options */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ + +/* SSL options */ +//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ +//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ +//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ +//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ + +/** + * Complete list of ciphersuites to use, in order of preference. + * + * \warning No dependency checking is done on that field! This option can only + * be used to restrict the set of available ciphersuites. It is your + * responsibility to make sure the needed modules are active. + * + * Use this to save a few hundred bytes of ROM (default ordering of all + * available ciphersuites) and a few to a few hundred bytes of RAM. + * + * The value below is only an example, not the default. + */ +//#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + +/* X509 options */ +//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ +//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */ + +/* \} name SECTION: Customisation configuration options */ + +/* Target and application specific configurations */ +//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "mbedtls/target_config.h" + +#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE) +#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE +#endif + +/* + * Allow user to override any previous default. + * + * Use two macro names for that, as: + * - with yotta the prefix YOTTA_CFG_ is forced + * - without yotta is looks weird to have a YOTTA prefix. + */ +#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) +#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE +#elif defined(MBEDTLS_USER_CONFIG_FILE) +#include MBEDTLS_USER_CONFIG_FILE +#endif + +#include "check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ctr_drbg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ctr_drbg.h new file mode 100644 index 0000000..059d3c5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ctr_drbg.h @@ -0,0 +1,290 @@ +/** + * \file ctr_drbg.h + * + * \brief CTR_DRBG based on AES-256 (NIST SP 800-90) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CTR_DRBG_H +#define MBEDTLS_CTR_DRBG_H + +#include "aes.h" + +#if defined(MBEDTLS_THREADING_C) +#include "mbedtls/threading.h" +#endif + +#define MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */ +#define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< Too many random requested in single call. */ +#define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< Input too large (Entropy + additional). */ +#define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read/write error in file. */ + +#define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< Block size used by the cipher */ +#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< Key size used by the cipher */ +#define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 ) +#define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE ) + /**< The seed length (counter + AES key) */ + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) +#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256) +#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ +#else +#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ +#endif +#endif + +#if !defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL) +#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +#endif + +#if !defined(MBEDTLS_CTR_DRBG_MAX_INPUT) +#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +#endif + +#if !defined(MBEDTLS_CTR_DRBG_MAX_REQUEST) +#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +#endif + +#if !defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT) +#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ +#endif + +/* \} name SECTION: Module settings */ + +#define MBEDTLS_CTR_DRBG_PR_OFF 0 /**< No prediction resistance */ +#define MBEDTLS_CTR_DRBG_PR_ON 1 /**< Prediction resistance enabled */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief CTR_DRBG context structure + */ +typedef struct +{ + unsigned char counter[16]; /*!< counter (V) */ + int reseed_counter; /*!< reseed counter */ + int prediction_resistance; /*!< enable prediction resistance (Automatic + reseed before every random generation) */ + size_t entropy_len; /*!< amount of entropy grabbed on each + (re)seed */ + int reseed_interval; /*!< reseed interval */ + + mbedtls_aes_context aes_ctx; /*!< AES context */ + + /* + * Callbacks (Entropy) + */ + int (*f_entropy)(void *, unsigned char *, size_t); + + void *p_entropy; /*!< context for the entropy function */ + +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; +#endif +} +mbedtls_ctr_drbg_context; + +/** + * \brief CTR_DRBG context initialization + * Makes the context ready for mbedtls_ctr_drbg_seed() or + * mbedtls_ctr_drbg_free(). + * + * \param ctx CTR_DRBG context to be initialized + */ +void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx ); + +/** + * \brief CTR_DRBG initial seeding + * Seed and setup entropy source for future reseeds. + * + * Note: Personalization data can be provided in addition to the more generic + * entropy source to make this instantiation as unique as possible. + * + * \param ctx CTR_DRBG context to be seeded + * \param f_entropy Entropy callback (p_entropy, buffer to fill, buffer + * length) + * \param p_entropy Entropy context + * \param custom Personalization data (Device specific identifiers) + * (Can be NULL) + * \param len Length of personalization data + * + * \return 0 if successful, or + * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED + */ +int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx, + int (*f_entropy)(void *, unsigned char *, size_t), + void *p_entropy, + const unsigned char *custom, + size_t len ); + +/** + * \brief Clear CTR_CRBG context data + * + * \param ctx CTR_DRBG context to clear + */ +void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx ); + +/** + * \brief Enable / disable prediction resistance (Default: Off) + * + * Note: If enabled, entropy is used for ctx->entropy_len before each call! + * Only use this if you have ample supply of good entropy! + * + * \param ctx CTR_DRBG context + * \param resistance MBEDTLS_CTR_DRBG_PR_ON or MBEDTLS_CTR_DRBG_PR_OFF + */ +void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx, + int resistance ); + +/** + * \brief Set the amount of entropy grabbed on each (re)seed + * (Default: MBEDTLS_CTR_DRBG_ENTROPY_LEN) + * + * \param ctx CTR_DRBG context + * \param len Amount of entropy to grab + */ +void mbedtls_ctr_drbg_set_entropy_len( mbedtls_ctr_drbg_context *ctx, + size_t len ); + +/** + * \brief Set the reseed interval + * (Default: MBEDTLS_CTR_DRBG_RESEED_INTERVAL) + * + * \param ctx CTR_DRBG context + * \param interval Reseed interval + */ +void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx, + int interval ); + +/** + * \brief CTR_DRBG reseeding (extracts data from entropy source) + * + * \param ctx CTR_DRBG context + * \param additional Additional data to add to state (Can be NULL) + * \param len Length of additional data + * + * \return 0 if successful, or + * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED + */ +int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx, + const unsigned char *additional, size_t len ); + +/** + * \brief CTR_DRBG update state + * + * \param ctx CTR_DRBG context + * \param additional Additional data to update state with + * \param add_len Length of additional data + * + * \note If add_len is greater than MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, + * only the first MBEDTLS_CTR_DRBG_MAX_SEED_INPUT bytes are used, + * the remaining ones are silently discarded. + */ +void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, + const unsigned char *additional, size_t add_len ); + +/** + * \brief CTR_DRBG generate random with additional update input + * + * Note: Automatically reseeds if reseed_counter is reached. + * + * \param p_rng CTR_DRBG context + * \param output Buffer to fill + * \param output_len Length of the buffer + * \param additional Additional data to update with (Can be NULL) + * \param add_len Length of additional data + * + * \return 0 if successful, or + * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED, or + * MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG + */ +int mbedtls_ctr_drbg_random_with_add( void *p_rng, + unsigned char *output, size_t output_len, + const unsigned char *additional, size_t add_len ); + +/** + * \brief CTR_DRBG generate random + * + * Note: Automatically reseeds if reseed_counter is reached. + * + * \param p_rng CTR_DRBG context + * \param output Buffer to fill + * \param output_len Length of the buffer + * + * \return 0 if successful, or + * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED, or + * MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG + */ +int mbedtls_ctr_drbg_random( void *p_rng, + unsigned char *output, size_t output_len ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Write a seed file + * + * \param ctx CTR_DRBG context + * \param path Name of the file + * + * \return 0 if successful, + * MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, or + * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED + */ +int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ); + +/** + * \brief Read and update a seed file. Seed is added to this + * instance + * + * \param ctx CTR_DRBG context + * \param path Name of the file + * + * \return 0 if successful, + * MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, + * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or + * MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG + */ +int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ); +#endif /* MBEDTLS_FS_IO */ + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_ctr_drbg_self_test( int verbose ); + +/* Internal functions (do not call directly) */ +int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *, + int (*)(void *, unsigned char *, size_t), void *, + const unsigned char *, size_t, size_t ); + +#ifdef __cplusplus +} +#endif + +#endif /* ctr_drbg.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/debug.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/debug.h new file mode 100644 index 0000000..2957996 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/debug.h @@ -0,0 +1,228 @@ +/** + * \file debug.h + * + * \brief Functions for controlling and providing debug output from the library. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_DEBUG_H +#define MBEDTLS_DEBUG_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "ssl.h" + +#if defined(MBEDTLS_ECP_C) +#include "ecp.h" +#endif + +#if defined(MBEDTLS_DEBUG_C) + +#define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__ + +#define MBEDTLS_SSL_DEBUG_MSG( level, args ) \ + mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \ + MBEDTLS_DEBUG_STRIP_PARENS args ) + +#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \ + mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ) + +#define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \ + mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ) + +#if defined(MBEDTLS_BIGNUM_C) +#define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \ + mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ) +#endif + +#if defined(MBEDTLS_ECP_C) +#define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \ + mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X ) +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +#define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \ + mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ) +#endif + +#else /* MBEDTLS_DEBUG_C */ + +#define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 ) +#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) +#define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) +#define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) +#define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) +#define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) + +#endif /* MBEDTLS_DEBUG_C */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Set the threshold error level to handle globally all debug output. + * Debug messages that have a level over the threshold value are + * discarded. + * (Default value: 0 = No debug ) + * + * \param threshold theshold level of messages to filter on. Messages at a + * higher level will be discarded. + * - Debug levels + * - 0 No debug + * - 1 Error + * - 2 State change + * - 3 Informational + * - 4 Verbose + */ +void mbedtls_debug_set_threshold( int threshold ); + +/** + * \brief Print a message to the debug output. This function is always used + * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl + * context, file and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the message has occurred in + * \param line line number the message has occurred at + * \param format format specifier, in printf format + * \param ... variables used by the format specifier + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *format, ... ); + +/** + * \brief Print the return value of a function to the debug output. This + * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro, + * which supplies the ssl context, file and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the error has occurred in + * \param line line number the error has occurred in + * \param text the name of the function that returned the error + * \param ret the return code value + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, int ret ); + +/** + * \brief Output a buffer of size len bytes to the debug output. This function + * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro, + * which supplies the ssl context, file and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the error has occurred in + * \param line line number the error has occurred in + * \param text a name or label for the buffer being dumped. Normally the + * variable or buffer name + * \param buf the buffer to be outputted + * \param len length of the buffer + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, const char *text, + const unsigned char *buf, size_t len ); + +#if defined(MBEDTLS_BIGNUM_C) +/** + * \brief Print a MPI variable to the debug output. This function is always + * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the + * ssl context, file and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the error has occurred in + * \param line line number the error has occurred in + * \param text a name or label for the MPI being output. Normally the + * variable name + * \param X the MPI variable + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_mpi *X ); +#endif + +#if defined(MBEDTLS_ECP_C) +/** + * \brief Print an ECP point to the debug output. This function is always + * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the + * ssl context, file and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the error has occurred in + * \param line line number the error has occurred in + * \param text a name or label for the ECP point being output. Normally the + * variable name + * \param X the ECP point + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_ecp_point *X ); +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * \brief Print a X.509 certificate structure to the debug output. This + * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro, + * which supplies the ssl context, file and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the error has occurred in + * \param line line number the error has occurred in + * \param text a name or label for the certificate being output + * \param crt X.509 certificate structure + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_x509_crt *crt ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* debug.h */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/des.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/des.h new file mode 100644 index 0000000..5ca2ecf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/des.h @@ -0,0 +1,306 @@ +/** + * \file des.h + * + * \brief DES block cipher + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_DES_H +#define MBEDTLS_DES_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#define MBEDTLS_DES_ENCRYPT 1 +#define MBEDTLS_DES_DECRYPT 0 + +#define MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH -0x0032 /**< The data input has an invalid length. */ + +#define MBEDTLS_DES_KEY_SIZE 8 + +#if !defined(MBEDTLS_DES_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief DES context structure + */ +typedef struct +{ + uint32_t sk[32]; /*!< DES subkeys */ +} +mbedtls_des_context; + +/** + * \brief Triple-DES context structure + */ +typedef struct +{ + uint32_t sk[96]; /*!< 3DES subkeys */ +} +mbedtls_des3_context; + +/** + * \brief Initialize DES context + * + * \param ctx DES context to be initialized + */ +void mbedtls_des_init( mbedtls_des_context *ctx ); + +/** + * \brief Clear DES context + * + * \param ctx DES context to be cleared + */ +void mbedtls_des_free( mbedtls_des_context *ctx ); + +/** + * \brief Initialize Triple-DES context + * + * \param ctx DES3 context to be initialized + */ +void mbedtls_des3_init( mbedtls_des3_context *ctx ); + +/** + * \brief Clear Triple-DES context + * + * \param ctx DES3 context to be cleared + */ +void mbedtls_des3_free( mbedtls_des3_context *ctx ); + +/** + * \brief Set key parity on the given key to odd. + * + * DES keys are 56 bits long, but each byte is padded with + * a parity bit to allow verification. + * + * \param key 8-byte secret key + */ +void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] ); + +/** + * \brief Check that key parity on the given key is odd. + * + * DES keys are 56 bits long, but each byte is padded with + * a parity bit to allow verification. + * + * \param key 8-byte secret key + * + * \return 0 is parity was ok, 1 if parity was not correct. + */ +int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); + +/** + * \brief Check that key is not a weak or semi-weak DES key + * + * \param key 8-byte secret key + * + * \return 0 if no weak key was found, 1 if a weak key was identified. + */ +int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); + +/** + * \brief DES key schedule (56-bit, encryption) + * + * \param ctx DES context to be initialized + * \param key 8-byte secret key + * + * \return 0 + */ +int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); + +/** + * \brief DES key schedule (56-bit, decryption) + * + * \param ctx DES context to be initialized + * \param key 8-byte secret key + * + * \return 0 + */ +int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); + +/** + * \brief Triple-DES key schedule (112-bit, encryption) + * + * \param ctx 3DES context to be initialized + * \param key 16-byte secret key + * + * \return 0 + */ +int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); + +/** + * \brief Triple-DES key schedule (112-bit, decryption) + * + * \param ctx 3DES context to be initialized + * \param key 16-byte secret key + * + * \return 0 + */ +int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); + +/** + * \brief Triple-DES key schedule (168-bit, encryption) + * + * \param ctx 3DES context to be initialized + * \param key 24-byte secret key + * + * \return 0 + */ +int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); + +/** + * \brief Triple-DES key schedule (168-bit, decryption) + * + * \param ctx 3DES context to be initialized + * \param key 24-byte secret key + * + * \return 0 + */ +int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); + +/** + * \brief DES-ECB block encryption/decryption + * + * \param ctx DES context + * \param input 64-bit input block + * \param output 64-bit output block + * + * \return 0 if successful + */ +int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, + const unsigned char input[8], + unsigned char output[8] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief DES-CBC buffer encryption/decryption + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx DES context + * \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + */ +int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, + int mode, + size_t length, + unsigned char iv[8], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +/** + * \brief 3DES-ECB block encryption/decryption + * + * \param ctx 3DES context + * \param input 64-bit input block + * \param output 64-bit output block + * + * \return 0 if successful + */ +int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, + const unsigned char input[8], + unsigned char output[8] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief 3DES-CBC buffer encryption/decryption + * + * \note Upon exit, the content of the IV is updated so that you can + * call the function same function again on the following + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If on the other hand you need to retain the contents of the + * IV, you should either save it manually or use the cipher + * module instead. + * + * \param ctx 3DES context + * \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if successful, or MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH + */ +int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, + int mode, + size_t length, + unsigned char iv[8], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +/** + * \brief Internal function for key expansion. + * (Only exposed to allow overriding it, + * see MBEDTLS_DES_SETKEY_ALT) + * + * \param SK Round keys + * \param key Base key + */ +void mbedtls_des_setkey( uint32_t SK[32], + const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_DES_ALT */ +#include "des_alt.h" +#endif /* MBEDTLS_DES_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_des_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* des.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/dhm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/dhm.h new file mode 100644 index 0000000..d7ab152 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/dhm.h @@ -0,0 +1,305 @@ +/** + * \file dhm.h + * + * \brief Diffie-Hellman-Merkle key exchange + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_DHM_H +#define MBEDTLS_DHM_H + +#include "bignum.h" + +/* + * DHM Error codes + */ +#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */ +#define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */ +#define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */ +#define MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 /**< Making of the public value failed. */ +#define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */ +#define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */ +#define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */ +#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read/write of file failed. */ + +/** + * RFC 3526 defines a number of standardized Diffie-Hellman groups + * for IKE. + * RFC 5114 defines a number of standardized Diffie-Hellman groups + * that can be used. + * + * Some are included here for convenience. + * + * Included are: + * RFC 3526 3. 2048-bit MODP Group + * RFC 3526 4. 3072-bit MODP Group + * RFC 3526 5. 4096-bit MODP Group + * RFC 5114 2.2. 2048-bit MODP Group with 224-bit Prime Order Subgroup + */ +#define MBEDTLS_DHM_RFC3526_MODP_2048_P \ + "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \ + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \ + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \ + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \ + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \ + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \ + "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \ + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \ + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \ + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \ + "15728E5A8AACAA68FFFFFFFFFFFFFFFF" + +#define MBEDTLS_DHM_RFC3526_MODP_2048_G "02" + +#define MBEDTLS_DHM_RFC3526_MODP_3072_P \ + "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \ + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \ + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \ + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \ + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \ + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \ + "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \ + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \ + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \ + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \ + "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \ + "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \ + "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \ + "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \ + "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \ + "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF" + +#define MBEDTLS_DHM_RFC3526_MODP_3072_G "02" + +#define MBEDTLS_DHM_RFC3526_MODP_4096_P \ + "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \ + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \ + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \ + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \ + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \ + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \ + "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \ + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \ + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \ + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \ + "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \ + "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \ + "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \ + "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \ + "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \ + "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \ + "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \ + "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \ + "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \ + "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \ + "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \ + "FFFFFFFFFFFFFFFF" + +#define MBEDTLS_DHM_RFC3526_MODP_4096_G "02" + +#define MBEDTLS_DHM_RFC5114_MODP_2048_P \ + "AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \ + "B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \ + "EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \ + "9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \ + "C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \ + "B3BF8A317091883681286130BC8985DB1602E714415D9330" \ + "278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \ + "CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \ + "BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \ + "C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \ + "CF9DE5384E71B81C0AC4DFFE0C10E64F" + +#define MBEDTLS_DHM_RFC5114_MODP_2048_G \ + "AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF"\ + "74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA"\ + "AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7"\ + "C17669101999024AF4D027275AC1348BB8A762D0521BC98A"\ + "E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE"\ + "F180EB34118E98D119529A45D6F834566E3025E316A330EF"\ + "BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB"\ + "10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381"\ + "B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269"\ + "EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179"\ + "81BC087F2A7065B384B890D3191F2BFA" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief DHM context structure + */ +typedef struct +{ + size_t len; /*!< size(P) in chars */ + mbedtls_mpi P; /*!< prime modulus */ + mbedtls_mpi G; /*!< generator */ + mbedtls_mpi X; /*!< secret value */ + mbedtls_mpi GX; /*!< self = G^X mod P */ + mbedtls_mpi GY; /*!< peer = G^Y mod P */ + mbedtls_mpi K; /*!< key = GY^X mod P */ + mbedtls_mpi RP; /*!< cached R^2 mod P */ + mbedtls_mpi Vi; /*!< blinding value */ + mbedtls_mpi Vf; /*!< un-blinding value */ + mbedtls_mpi pX; /*!< previous X */ +} +mbedtls_dhm_context; + +/** + * \brief Initialize DHM context + * + * \param ctx DHM context to be initialized + */ +void mbedtls_dhm_init( mbedtls_dhm_context *ctx ); + +/** + * \brief Parse the ServerKeyExchange parameters + * + * \param ctx DHM context + * \param p &(start of input buffer) + * \param end end of buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code + */ +int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx, + unsigned char **p, + const unsigned char *end ); + +/** + * \brief Setup and write the ServerKeyExchange parameters + * + * \param ctx DHM context + * \param x_size private value size in bytes + * \param output destination buffer + * \param olen number of chars written + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \note This function assumes that ctx->P and ctx->G + * have already been properly set (for example + * using mbedtls_mpi_read_string or mbedtls_mpi_read_binary). + * + * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code + */ +int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, + unsigned char *output, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Import the peer's public value G^Y + * + * \param ctx DHM context + * \param input input buffer + * \param ilen size of buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code + */ +int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx, + const unsigned char *input, size_t ilen ); + +/** + * \brief Create own private value X and export G^X + * + * \param ctx DHM context + * \param x_size private value size in bytes + * \param output destination buffer + * \param olen must be at least equal to the size of P, ctx->len + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code + */ +int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, + unsigned char *output, size_t olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Derive and export the shared secret (G^Y)^X mod P + * + * \param ctx DHM context + * \param output destination buffer + * \param output_size size of the destination buffer + * \param olen on exit, holds the actual number of bytes written + * \param f_rng RNG function, for blinding purposes + * \param p_rng RNG parameter + * + * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code + * + * \note If non-NULL, f_rng is used to blind the input as + * countermeasure against timing attacks. Blinding is + * automatically used if and only if our secret value X is + * re-used and costs nothing otherwise, so it is recommended + * to always pass a non-NULL f_rng argument. + */ +int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, + unsigned char *output, size_t output_size, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Free and clear the components of a DHM key + * + * \param ctx DHM context to free and clear + */ +void mbedtls_dhm_free( mbedtls_dhm_context *ctx ); + +#if defined(MBEDTLS_ASN1_PARSE_C) +/** \ingroup x509_module */ +/** + * \brief Parse DHM parameters in PEM or DER format + * + * \param dhm DHM context to be initialized + * \param dhmin input buffer + * \param dhminlen size of the buffer + * (including the terminating null byte for PEM data) + * + * \return 0 if successful, or a specific DHM or PEM error code + */ +int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin, + size_t dhminlen ); + +#if defined(MBEDTLS_FS_IO) +/** \ingroup x509_module */ +/** + * \brief Load and parse DHM parameters + * + * \param dhm DHM context to be initialized + * \param path filename to read the DHM Parameters from + * + * \return 0 if successful, or a specific DHM or PEM error code + */ +int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ); +#endif /* MBEDTLS_FS_IO */ +#endif /* MBEDTLS_ASN1_PARSE_C */ + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_dhm_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* dhm.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdh.h new file mode 100644 index 0000000..625a281 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdh.h @@ -0,0 +1,214 @@ +/** + * \file ecdh.h + * + * \brief Elliptic curve Diffie-Hellman + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ECDH_H +#define MBEDTLS_ECDH_H + +#include "ecp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * When importing from an EC key, select if it is our key or the peer's key + */ +typedef enum +{ + MBEDTLS_ECDH_OURS, + MBEDTLS_ECDH_THEIRS, +} mbedtls_ecdh_side; + +/** + * \brief ECDH context structure + */ +typedef struct +{ + mbedtls_ecp_group grp; /*!< elliptic curve used */ + mbedtls_mpi d; /*!< our secret value (private key) */ + mbedtls_ecp_point Q; /*!< our public value (public key) */ + mbedtls_ecp_point Qp; /*!< peer's public value (public key) */ + mbedtls_mpi z; /*!< shared secret */ + int point_format; /*!< format for point export in TLS messages */ + mbedtls_ecp_point Vi; /*!< blinding value (for later) */ + mbedtls_ecp_point Vf; /*!< un-blinding value (for later) */ + mbedtls_mpi _d; /*!< previous d (for later) */ +} +mbedtls_ecdh_context; + +/** + * \brief Generate a public key. + * Raw function that only does the core computation. + * + * \param grp ECP group + * \param d Destination MPI (secret exponent, aka private key) + * \param Q Destination point (public key) + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + */ +int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Compute shared secret + * Raw function that only does the core computation. + * + * \param grp ECP group + * \param z Destination MPI (shared secret) + * \param Q Public key from other party + * \param d Our secret exponent (private key) + * \param f_rng RNG function (see notes) + * \param p_rng RNG parameter + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + * + * \note If f_rng is not NULL, it is used to implement + * countermeasures against potential elaborate timing + * attacks, see \c mbedtls_ecp_mul() for details. + */ +int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, + const mbedtls_ecp_point *Q, const mbedtls_mpi *d, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Initialize context + * + * \param ctx Context to initialize + */ +void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ); + +/** + * \brief Free context + * + * \param ctx Context to free + */ +void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ); + +/** + * \brief Generate a public key and a TLS ServerKeyExchange payload. + * (First function used by a TLS server for ECDHE.) + * + * \param ctx ECDH context + * \param olen number of chars written + * \param buf destination buffer + * \param blen length of buffer + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \note This function assumes that ctx->grp has already been + * properly set (for example using mbedtls_ecp_group_load). + * + * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code + */ +int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Parse and procress a TLS ServerKeyExhange payload. + * (First function used by a TLS client for ECDHE.) + * + * \param ctx ECDH context + * \param buf pointer to start of input buffer + * \param end one past end of buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code + */ +int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, + const unsigned char **buf, const unsigned char *end ); + +/** + * \brief Setup an ECDH context from an EC key. + * (Used by clients and servers in place of the + * ServerKeyEchange for static ECDH: import ECDH parameters + * from a certificate's EC key information.) + * + * \param ctx ECDH constext to set + * \param key EC key to use + * \param side Is it our key (1) or the peer's key (0) ? + * + * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code + */ +int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, + mbedtls_ecdh_side side ); + +/** + * \brief Generate a public key and a TLS ClientKeyExchange payload. + * (Second function used by a TLS client for ECDH(E).) + * + * \param ctx ECDH context + * \param olen number of bytes actually written + * \param buf destination buffer + * \param blen size of destination buffer + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code + */ +int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Parse and process a TLS ClientKeyExchange payload. + * (Second function used by a TLS server for ECDH(E).) + * + * \param ctx ECDH context + * \param buf start of input buffer + * \param blen length of input buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code + */ +int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, size_t blen ); + +/** + * \brief Derive and export the shared secret. + * (Last function used by both TLS client en servers.) + * + * \param ctx ECDH context + * \param olen number of bytes written + * \param buf destination buffer + * \param blen buffer length + * \param f_rng RNG function, see notes for \c mbedtls_ecdh_compute_shared() + * \param p_rng RNG parameter + * + * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code + */ +int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +#ifdef __cplusplus +} +#endif + +#endif /* ecdh.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdsa.h new file mode 100644 index 0000000..52827d8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecdsa.h @@ -0,0 +1,248 @@ +/** + * \file ecdsa.h + * + * \brief Elliptic curve DSA + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ECDSA_H +#define MBEDTLS_ECDSA_H + +#include "ecp.h" +#include "md.h" + +/* + * RFC 4492 page 20: + * + * Ecdsa-Sig-Value ::= SEQUENCE { + * r INTEGER, + * s INTEGER + * } + * + * Size is at most + * 1 (tag) + 1 (len) + 1 (initial 0) + ECP_MAX_BYTES for each of r and s, + * twice that + 1 (tag) + 2 (len) for the sequence + * (assuming ECP_MAX_BYTES is less than 126 for r and s, + * and less than 124 (total len <= 255) for the sequence) + */ +#if MBEDTLS_ECP_MAX_BYTES > 124 +#error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN" +#endif +/** Maximum size of an ECDSA signature in bytes */ +#define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) ) + +/** + * \brief ECDSA context structure + */ +typedef mbedtls_ecp_keypair mbedtls_ecdsa_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Compute ECDSA signature of a previously hashed message + * + * \note The deterministic version is usually prefered. + * + * \param grp ECP group + * \param r First output integer + * \param s Second output integer + * \param d Private signing key + * \param buf Message hash + * \param blen Length of buf + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + */ +int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, + const mbedtls_mpi *d, const unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) +/** + * \brief Compute ECDSA signature of a previously hashed message, + * deterministic version (RFC 6979). + * + * \param grp ECP group + * \param r First output integer + * \param s Second output integer + * \param d Private signing key + * \param buf Message hash + * \param blen Length of buf + * \param md_alg MD algorithm used to hash the message + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + */ +int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, + const mbedtls_mpi *d, const unsigned char *buf, size_t blen, + mbedtls_md_type_t md_alg ); +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ + +/** + * \brief Verify ECDSA signature of a previously hashed message + * + * \param grp ECP group + * \param buf Message hash + * \param blen Length of buf + * \param Q Public key to use for verification + * \param r First integer of the signature + * \param s Second integer of the signature + * + * \return 0 if successful, + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + */ +int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s); + +/** + * \brief Compute ECDSA signature and write it to buffer, + * serialized as defined in RFC 4492 page 20. + * (Not thread-safe to use same context in multiple threads) + * + * \note The deterministice version (RFC 6979) is used if + * MBEDTLS_ECDSA_DETERMINISTIC is defined. + * + * \param ctx ECDSA context + * \param md_alg Algorithm that was used to hash the message + * \param hash Message hash + * \param hlen Length of hash + * \param sig Buffer that will hold the signature + * \param slen Length of the signature written + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \note The "sig" buffer must be at least as large as twice the + * size of the curve used, plus 9 (eg. 73 bytes if a 256-bit + * curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe. + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or + * MBEDTLS_ERR_ASN1_XXX error code + */ +int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hlen, + unsigned char *sig, size_t *slen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif +/** + * \brief Compute ECDSA signature and write it to buffer, + * serialized as defined in RFC 4492 page 20. + * Deterministic version, RFC 6979. + * (Not thread-safe to use same context in multiple threads) + * + * \deprecated Superseded by mbedtls_ecdsa_write_signature() in 2.0.0 + * + * \param ctx ECDSA context + * \param hash Message hash + * \param hlen Length of hash + * \param sig Buffer that will hold the signature + * \param slen Length of the signature written + * \param md_alg MD algorithm used to hash the message + * + * \note The "sig" buffer must be at least as large as twice the + * size of the curve used, plus 9 (eg. 73 bytes if a 256-bit + * curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe. + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or + * MBEDTLS_ERR_ASN1_XXX error code + */ +int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + unsigned char *sig, size_t *slen, + mbedtls_md_type_t md_alg ) MBEDTLS_DEPRECATED; +#undef MBEDTLS_DEPRECATED +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ + +/** + * \brief Read and verify an ECDSA signature + * + * \param ctx ECDSA context + * \param hash Message hash + * \param hlen Size of hash + * \param sig Signature to read and verify + * \param slen Size of sig + * + * \return 0 if successful, + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid, + * MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is + * valid but its actual length is less than siglen, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX error code + */ +int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen ); + +/** + * \brief Generate an ECDSA keypair on the given curve + * + * \param ctx ECDSA context in which the keypair should be stored + * \param gid Group (elliptic curve) to use. One of the various + * MBEDTLS_ECP_DP_XXX macros depending on configuration. + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code. + */ +int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +/** + * \brief Set an ECDSA context from an EC key pair + * + * \param ctx ECDSA context to set + * \param key EC key to use + * + * \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code. + */ +int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key ); + +/** + * \brief Initialize context + * + * \param ctx Context to initialize + */ +void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx ); + +/** + * \brief Free context + * + * \param ctx Context to free + */ +void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx ); + +#ifdef __cplusplus +} +#endif + +#endif /* ecdsa.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecjpake.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecjpake.h new file mode 100644 index 0000000..b7b6160 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecjpake.h @@ -0,0 +1,238 @@ +/** + * \file ecjpake.h + * + * \brief Elliptic curve J-PAKE + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ECJPAKE_H +#define MBEDTLS_ECJPAKE_H + +/* + * J-PAKE is a password-authenticated key exchange that allows deriving a + * strong shared secret from a (potentially low entropy) pre-shared + * passphrase, with forward secrecy and mutual authentication. + * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling + * + * This file implements the Elliptic Curve variant of J-PAKE, + * as defined in Chapter 7.4 of the Thread v1.0 Specification, + * available to members of the Thread Group http://threadgroup.org/ + * + * As the J-PAKE algorithm is inherently symmetric, so is our API. + * Each party needs to send its first round message, in any order, to the + * other party, then each sends its second round message, in any order. + * The payloads are serialized in a way suitable for use in TLS, but could + * also be use outside TLS. + */ + +#include "ecp.h" +#include "md.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Roles in the EC J-PAKE exchange + */ +typedef enum { + MBEDTLS_ECJPAKE_CLIENT = 0, /**< Client */ + MBEDTLS_ECJPAKE_SERVER, /**< Server */ +} mbedtls_ecjpake_role; + +/** + * EC J-PAKE context structure. + * + * J-PAKE is a symmetric protocol, except for the identifiers used in + * Zero-Knowledge Proofs, and the serialization of the second message + * (KeyExchange) as defined by the Thread spec. + * + * In order to benefit from this symmetry, we choose a different naming + * convetion from the Thread v1.0 spec. Correspondance is indicated in the + * description as a pair C: client name, S: server name + */ +typedef struct +{ + const mbedtls_md_info_t *md_info; /**< Hash to use */ + mbedtls_ecp_group grp; /**< Elliptic curve */ + mbedtls_ecjpake_role role; /**< Are we client or server? */ + int point_format; /**< Format for point export */ + + mbedtls_ecp_point Xm1; /**< My public key 1 C: X1, S: X3 */ + mbedtls_ecp_point Xm2; /**< My public key 2 C: X2, S: X4 */ + mbedtls_ecp_point Xp1; /**< Peer public key 1 C: X3, S: X1 */ + mbedtls_ecp_point Xp2; /**< Peer public key 2 C: X4, S: X2 */ + mbedtls_ecp_point Xp; /**< Peer public key C: Xs, S: Xc */ + + mbedtls_mpi xm1; /**< My private key 1 C: x1, S: x3 */ + mbedtls_mpi xm2; /**< My private key 2 C: x2, S: x4 */ + + mbedtls_mpi s; /**< Pre-shared secret (passphrase) */ +} mbedtls_ecjpake_context; + +/** + * \brief Initialize a context + * (just makes it ready for setup() or free()). + * + * \param ctx context to initialize + */ +void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx ); + +/** + * \brief Set up a context for use + * + * \note Currently the only values for hash/curve allowed by the + * standard are MBEDTLS_MD_SHA256/MBEDTLS_ECP_DP_SECP256R1. + * + * \param ctx context to set up + * \param role Our role: client or server + * \param hash hash function to use (MBEDTLS_MD_XXX) + * \param curve elliptic curve identifier (MBEDTLS_ECP_DP_XXX) + * \param secret pre-shared secret (passphrase) + * \param len length of the shared secret + * + * \return 0 if successfull, + * a negative error code otherwise + */ +int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, + mbedtls_ecjpake_role role, + mbedtls_md_type_t hash, + mbedtls_ecp_group_id curve, + const unsigned char *secret, + size_t len ); + +/* + * \brief Check if a context is ready for use + * + * \param ctx Context to check + * + * \return 0 if the context is ready for use, + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise + */ +int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx ); + +/** + * \brief Generate and write the first round message + * (TLS: contents of the Client/ServerHello extension, + * excluding extension type and length bytes) + * + * \param ctx Context to use + * \param buf Buffer to write the contents to + * \param len Buffer size + * \param olen Will be updated with the number of bytes written + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successfull, + * a negative error code otherwise + */ +int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx, + unsigned char *buf, size_t len, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Read and process the first round message + * (TLS: contents of the Client/ServerHello extension, + * excluding extension type and length bytes) + * + * \param ctx Context to use + * \param buf Pointer to extension contents + * \param len Extension length + * + * \return 0 if successfull, + * a negative error code otherwise + */ +int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx, + const unsigned char *buf, + size_t len ); + +/** + * \brief Generate and write the second round message + * (TLS: contents of the Client/ServerKeyExchange) + * + * \param ctx Context to use + * \param buf Buffer to write the contents to + * \param len Buffer size + * \param olen Will be updated with the number of bytes written + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successfull, + * a negative error code otherwise + */ +int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx, + unsigned char *buf, size_t len, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Read and process the second round message + * (TLS: contents of the Client/ServerKeyExchange) + * + * \param ctx Context to use + * \param buf Pointer to the message + * \param len Message length + * + * \return 0 if successfull, + * a negative error code otherwise + */ +int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx, + const unsigned char *buf, + size_t len ); + +/** + * \brief Derive the shared secret + * (TLS: Pre-Master Secret) + * + * \param ctx Context to use + * \param buf Buffer to write the contents to + * \param len Buffer size + * \param olen Will be updated with the number of bytes written + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successfull, + * a negative error code otherwise + */ +int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx, + unsigned char *buf, size_t len, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Free a context's content + * + * \param ctx context to free + */ +void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx ); + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_ecjpake_self_test( int verbose ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ecjpake.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecp.h new file mode 100644 index 0000000..5246c78 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ecp.h @@ -0,0 +1,669 @@ +/** + * \file ecp.h + * + * \brief Elliptic curves over GF(p) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ECP_H +#define MBEDTLS_ECP_H + +#include "bignum.h" + +/* + * ECP error codes + */ +#define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00 /**< The buffer is too small to write to. */ +#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80 /**< Requested curve not available. */ +#define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00 /**< The signature is not valid. */ +#define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 /**< Memory allocation failed. */ +#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as (ephemeral) key, failed. */ +#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */ +#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Domain parameters (curve, subgroup and generator) identifiers. + * + * Only curves over prime fields are supported. + * + * \warning This library does not support validation of arbitrary domain + * parameters. Therefore, only well-known domain parameters from trusted + * sources should be used. See mbedtls_ecp_group_load(). + */ +typedef enum +{ + MBEDTLS_ECP_DP_NONE = 0, + MBEDTLS_ECP_DP_SECP192R1, /*!< 192-bits NIST curve */ + MBEDTLS_ECP_DP_SECP224R1, /*!< 224-bits NIST curve */ + MBEDTLS_ECP_DP_SECP256R1, /*!< 256-bits NIST curve */ + MBEDTLS_ECP_DP_SECP384R1, /*!< 384-bits NIST curve */ + MBEDTLS_ECP_DP_SECP521R1, /*!< 521-bits NIST curve */ + MBEDTLS_ECP_DP_BP256R1, /*!< 256-bits Brainpool curve */ + MBEDTLS_ECP_DP_BP384R1, /*!< 384-bits Brainpool curve */ + MBEDTLS_ECP_DP_BP512R1, /*!< 512-bits Brainpool curve */ + MBEDTLS_ECP_DP_CURVE25519, /*!< Curve25519 */ + MBEDTLS_ECP_DP_SECP192K1, /*!< 192-bits "Koblitz" curve */ + MBEDTLS_ECP_DP_SECP224K1, /*!< 224-bits "Koblitz" curve */ + MBEDTLS_ECP_DP_SECP256K1, /*!< 256-bits "Koblitz" curve */ +} mbedtls_ecp_group_id; + +/** + * Number of supported curves (plus one for NONE). + * + * (Montgomery curves excluded for now.) + */ +#define MBEDTLS_ECP_DP_MAX 12 + +/** + * Curve information for use by other modules + */ +typedef struct +{ + mbedtls_ecp_group_id grp_id; /*!< Internal identifier */ + uint16_t tls_id; /*!< TLS NamedCurve identifier */ + uint16_t bit_size; /*!< Curve size in bits */ + const char *name; /*!< Human-friendly name */ +} mbedtls_ecp_curve_info; + +/** + * \brief ECP point structure (jacobian coordinates) + * + * \note All functions expect and return points satisfying + * the following condition: Z == 0 or Z == 1. (Other + * values of Z are used by internal functions only.) + * The point is zero, or "at infinity", if Z == 0. + * Otherwise, X and Y are its standard (affine) coordinates. + */ +typedef struct +{ + mbedtls_mpi X; /*!< the point's X coordinate */ + mbedtls_mpi Y; /*!< the point's Y coordinate */ + mbedtls_mpi Z; /*!< the point's Z coordinate */ +} +mbedtls_ecp_point; + +/** + * \brief ECP group structure + * + * We consider two types of curves equations: + * 1. Short Weierstrass y^2 = x^3 + A x + B mod P (SEC1 + RFC 4492) + * 2. Montgomery, y^2 = x^3 + A x^2 + x mod P (Curve25519 + draft) + * In both cases, a generator G for a prime-order subgroup is fixed. In the + * short weierstrass, this subgroup is actually the whole curve, and its + * cardinal is denoted by N. + * + * In the case of Short Weierstrass curves, our code requires that N is an odd + * prime. (Use odd in mbedtls_ecp_mul() and prime in mbedtls_ecdsa_sign() for blinding.) + * + * In the case of Montgomery curves, we don't store A but (A + 2) / 4 which is + * the quantity actually used in the formulas. Also, nbits is not the size of N + * but the required size for private keys. + * + * If modp is NULL, reduction modulo P is done using a generic algorithm. + * Otherwise, it must point to a function that takes an mbedtls_mpi in the range + * 0..2^(2*pbits)-1 and transforms it in-place in an integer of little more + * than pbits, so that the integer may be efficiently brought in the 0..P-1 + * range by a few additions or substractions. It must return 0 on success and + * non-zero on failure. + */ +typedef struct +{ + mbedtls_ecp_group_id id; /*!< internal group identifier */ + mbedtls_mpi P; /*!< prime modulus of the base field */ + mbedtls_mpi A; /*!< 1. A in the equation, or 2. (A + 2) / 4 */ + mbedtls_mpi B; /*!< 1. B in the equation, or 2. unused */ + mbedtls_ecp_point G; /*!< generator of the (sub)group used */ + mbedtls_mpi N; /*!< 1. the order of G, or 2. unused */ + size_t pbits; /*!< number of bits in P */ + size_t nbits; /*!< number of bits in 1. P, or 2. private keys */ + unsigned int h; /*!< internal: 1 if the constants are static */ + int (*modp)(mbedtls_mpi *); /*!< function for fast reduction mod P */ + int (*t_pre)(mbedtls_ecp_point *, void *); /*!< unused */ + int (*t_post)(mbedtls_ecp_point *, void *); /*!< unused */ + void *t_data; /*!< unused */ + mbedtls_ecp_point *T; /*!< pre-computed points for ecp_mul_comb() */ + size_t T_size; /*!< number for pre-computed points */ +} +mbedtls_ecp_group; + +/** + * \brief ECP key pair structure + * + * A generic key pair that could be used for ECDSA, fixed ECDH, etc. + * + * \note Members purposefully in the same order as struc mbedtls_ecdsa_context. + */ +typedef struct +{ + mbedtls_ecp_group grp; /*!< Elliptic curve and base point */ + mbedtls_mpi d; /*!< our secret value */ + mbedtls_ecp_point Q; /*!< our public value */ +} +mbedtls_ecp_keypair; + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_ECP_MAX_BITS) +/** + * Maximum size of the groups (that is, of N and P) + */ +#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ +#endif + +#define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 ) +#define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 ) + +#if !defined(MBEDTLS_ECP_WINDOW_SIZE) +/* + * Maximum "window" size used for point multiplication. + * Default: 6. + * Minimum value: 2. Maximum value: 7. + * + * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) ) + * points used for point multiplication. This value is directly tied to EC + * peak memory usage, so decreasing it by one should roughly cut memory usage + * by two (if large curves are in use). + * + * Reduction in size may reduce speed, but larger curves are impacted first. + * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1): + * w-size: 6 5 4 3 2 + * 521 145 141 135 120 97 + * 384 214 209 198 177 146 + * 256 320 320 303 262 226 + + * 224 475 475 453 398 342 + * 192 640 640 633 587 476 + */ +#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +#endif /* MBEDTLS_ECP_WINDOW_SIZE */ + +#if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM) +/* + * Trade memory for speed on fixed-point multiplication. + * + * This speeds up repeated multiplication of the generator (that is, the + * multiplication in ECDSA signatures, and half of the multiplications in + * ECDSA verification and ECDHE) by a factor roughly 3 to 4. + * + * The cost is increasing EC peak memory usage by a factor roughly 2. + * + * Change this value to 0 to reduce peak memory usage. + */ +#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ +#endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */ + +/* \} name SECTION: Module settings */ + +/* + * Point formats, from RFC 4492's enum ECPointFormat + */ +#define MBEDTLS_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format */ +#define MBEDTLS_ECP_PF_COMPRESSED 1 /**< Compressed point format */ + +/* + * Some other constants from RFC 4492 + */ +#define MBEDTLS_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */ + +/** + * \brief Get the list of supported curves in order of preferrence + * (full information) + * + * \return A statically allocated array, the last entry is 0. + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ); + +/** + * \brief Get the list of supported curves in order of preferrence + * (grp_id only) + * + * \return A statically allocated array, + * terminated with MBEDTLS_ECP_DP_NONE. + */ +const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void ); + +/** + * \brief Get curve information from an internal group identifier + * + * \param grp_id A MBEDTLS_ECP_DP_XXX value + * + * \return The associated curve information or NULL + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id ); + +/** + * \brief Get curve information from a TLS NamedCurve value + * + * \param tls_id A MBEDTLS_ECP_DP_XXX value + * + * \return The associated curve information or NULL + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id ); + +/** + * \brief Get curve information from a human-readable name + * + * \param name The name + * + * \return The associated curve information or NULL + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name ); + +/** + * \brief Initialize a point (as zero) + */ +void mbedtls_ecp_point_init( mbedtls_ecp_point *pt ); + +/** + * \brief Initialize a group (to something meaningless) + */ +void mbedtls_ecp_group_init( mbedtls_ecp_group *grp ); + +/** + * \brief Initialize a key pair (as an invalid one) + */ +void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key ); + +/** + * \brief Free the components of a point + */ +void mbedtls_ecp_point_free( mbedtls_ecp_point *pt ); + +/** + * \brief Free the components of an ECP group + */ +void mbedtls_ecp_group_free( mbedtls_ecp_group *grp ); + +/** + * \brief Free the components of a key pair + */ +void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key ); + +/** + * \brief Copy the contents of point Q into P + * + * \param P Destination point + * \param Q Source point + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ); + +/** + * \brief Copy the contents of a group object + * + * \param dst Destination group + * \param src Source group + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src ); + +/** + * \brief Set a point to zero + * + * \param pt Destination point + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt ); + +/** + * \brief Tell if a point is zero + * + * \param pt Point to test + * + * \return 1 if point is zero, 0 otherwise + */ +int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt ); + +/** + * \brief Compare two points + * + * \note This assumes the points are normalized. Otherwise, + * they may compare as "not equal" even if they are. + * + * \param P First point to compare + * \param Q Second point to compare + * + * \return 0 if the points are equal, + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise + */ +int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P, + const mbedtls_ecp_point *Q ); + +/** + * \brief Import a non-zero point from two ASCII strings + * + * \param P Destination point + * \param radix Input numeric base + * \param x First affine coordinate as a null-terminated string + * \param y Second affine coordinate as a null-terminated string + * + * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code + */ +int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix, + const char *x, const char *y ); + +/** + * \brief Export a point into unsigned binary data + * + * \param grp Group to which the point should belong + * \param P Point to export + * \param format Point format, should be a MBEDTLS_ECP_PF_XXX macro + * \param olen Length of the actual output + * \param buf Output buffer + * \param buflen Length of the output buffer + * + * \return 0 if successful, + * or MBEDTLS_ERR_ECP_BAD_INPUT_DATA + * or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL + */ +int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, + int format, size_t *olen, + unsigned char *buf, size_t buflen ); + +/** + * \brief Import a point from unsigned binary data + * + * \param grp Group to which the point should belong + * \param P Point to import + * \param buf Input buffer + * \param ilen Actual length of input + * + * \return 0 if successful, + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format + * is not implemented. + * + * \note This function does NOT check that the point actually + * belongs to the given group, see mbedtls_ecp_check_pubkey() for + * that. + */ +int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, + const unsigned char *buf, size_t ilen ); + +/** + * \brief Import a point from a TLS ECPoint record + * + * \param grp ECP group used + * \param pt Destination point + * \param buf $(Start of input buffer) + * \param len Buffer length + * + * \note buf is updated to point right after the ECPoint on exit + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_XXX if initialization failed + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid + */ +int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, + const unsigned char **buf, size_t len ); + +/** + * \brief Export a point as a TLS ECPoint record + * + * \param grp ECP group used + * \param pt Point to export + * \param format Export format + * \param olen length of data written + * \param buf Buffer to write to + * \param blen Buffer length + * + * \return 0 if successful, + * or MBEDTLS_ERR_ECP_BAD_INPUT_DATA + * or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL + */ +int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt, + int format, size_t *olen, + unsigned char *buf, size_t blen ); + +/** + * \brief Set a group using well-known domain parameters + * + * \param grp Destination group + * \param index Index in the list of well-known domain parameters + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_XXX if initialization failed + * MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE for unkownn groups + * + * \note Index should be a value of RFC 4492's enum NamedCurve, + * usually in the form of a MBEDTLS_ECP_DP_XXX macro. + */ +int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id index ); + +/** + * \brief Set a group from a TLS ECParameters record + * + * \param grp Destination group + * \param buf &(Start of input buffer) + * \param len Buffer length + * + * \note buf is updated to point right after ECParameters on exit + * + * \return 0 if successful, + * MBEDTLS_ERR_MPI_XXX if initialization failed + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid + */ +int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len ); + +/** + * \brief Write the TLS ECParameters record for a group + * + * \param grp ECP group used + * \param olen Number of bytes actually written + * \param buf Buffer to write to + * \param blen Buffer length + * + * \return 0 if successful, + * or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL + */ +int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, + unsigned char *buf, size_t blen ); + +/** + * \brief Multiplication by an integer: R = m * P + * (Not thread-safe to use same group in multiple threads) + * + * \note In order to prevent timing attacks, this function + * executes the exact same sequence of (base field) + * operations for any valid m. It avoids any if-branch or + * array index depending on the value of m. + * + * \note If f_rng is not NULL, it is used to randomize intermediate + * results in order to prevent potential timing attacks + * targeting these results. It is recommended to always + * provide a non-NULL f_rng (the overhead is negligible). + * + * \param grp ECP group + * \param R Destination point + * \param m Integer by which to multiply + * \param P Point to multiply + * \param f_rng RNG function (see notes) + * \param p_rng RNG parameter + * + * \return 0 if successful, + * MBEDTLS_ERR_ECP_INVALID_KEY if m is not a valid privkey + * or P is not a valid pubkey, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +/** + * \brief Multiplication and addition of two points by integers: + * R = m * P + n * Q + * (Not thread-safe to use same group in multiple threads) + * + * \note In contrast to mbedtls_ecp_mul(), this function does not guarantee + * a constant execution flow and timing. + * + * \param grp ECP group + * \param R Destination point + * \param m Integer by which to multiply P + * \param P Point to multiply by m + * \param n Integer by which to multiply Q + * \param Q Point to be multiplied by n + * + * \return 0 if successful, + * MBEDTLS_ERR_ECP_INVALID_KEY if m or n is not a valid privkey + * or P or Q is not a valid pubkey, + * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + */ +int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + const mbedtls_mpi *n, const mbedtls_ecp_point *Q ); + +/** + * \brief Check that a point is a valid public key on this curve + * + * \param grp Curve/group the point should belong to + * \param pt Point to check + * + * \return 0 if point is a valid public key, + * MBEDTLS_ERR_ECP_INVALID_KEY otherwise. + * + * \note This function only checks the point is non-zero, has valid + * coordinates and lies on the curve, but not that it is + * indeed a multiple of G. This is additional check is more + * expensive, isn't required by standards, and shouldn't be + * necessary if the group used has a small cofactor. In + * particular, it is useless for the NIST groups which all + * have a cofactor of 1. + * + * \note Uses bare components rather than an mbedtls_ecp_keypair structure + * in order to ease use with other structures such as + * mbedtls_ecdh_context of mbedtls_ecdsa_context. + */ +int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ); + +/** + * \brief Check that an mbedtls_mpi is a valid private key for this curve + * + * \param grp Group used + * \param d Integer to check + * + * \return 0 if point is a valid private key, + * MBEDTLS_ERR_ECP_INVALID_KEY otherwise. + * + * \note Uses bare components rather than an mbedtls_ecp_keypair structure + * in order to ease use with other structures such as + * mbedtls_ecdh_context of mbedtls_ecdsa_context. + */ +int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d ); + +/** + * \brief Generate a keypair with configurable base point + * + * \param grp ECP group + * \param G Chosen base point + * \param d Destination MPI (secret part) + * \param Q Destination point (public part) + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + * + * \note Uses bare components rather than an mbedtls_ecp_keypair structure + * in order to ease use with other structures such as + * mbedtls_ecdh_context of mbedtls_ecdsa_context. + */ +int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, + const mbedtls_ecp_point *G, + mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Generate a keypair + * + * \param grp ECP group + * \param d Destination MPI (secret part) + * \param Q Destination point (public part) + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + * + * \note Uses bare components rather than an mbedtls_ecp_keypair structure + * in order to ease use with other structures such as + * mbedtls_ecdh_context of mbedtls_ecdsa_context. + */ +int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Generate a keypair + * + * \param grp_id ECP group identifier + * \param key Destination keypair + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 if successful, + * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + */ +int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +/** + * \brief Check a public-private key pair + * + * \param pub Keypair structure holding a public key + * \param prv Keypair structure holding a private (plus public) key + * + * \return 0 if successful (keys are valid and match), or + * MBEDTLS_ERR_ECP_BAD_INPUT_DATA, or + * a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX code. + */ +int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv ); + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_ecp_self_test( int verbose ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ecp.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy.h new file mode 100644 index 0000000..747aca4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy.h @@ -0,0 +1,287 @@ +/** + * \file entropy.h + * + * \brief Entropy accumulator implementation + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ENTROPY_H +#define MBEDTLS_ENTROPY_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256) +#include "sha512.h" +#define MBEDTLS_ENTROPY_SHA512_ACCUMULATOR +#else +#if defined(MBEDTLS_SHA256_C) +#define MBEDTLS_ENTROPY_SHA256_ACCUMULATOR +#include "sha256.h" +#endif +#endif + +#if defined(MBEDTLS_THREADING_C) +#include "threading.h" +#endif + +#if defined(MBEDTLS_HAVEGE_C) +#include "havege.h" +#endif + +#define MBEDTLS_ERR_ENTROPY_SOURCE_FAILED -0x003C /**< Critical entropy source failure. */ +#define MBEDTLS_ERR_ENTROPY_MAX_SOURCES -0x003E /**< No more sources can be added. */ +#define MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 /**< No sources have been added to poll. */ +#define MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE -0x003D /**< No strong sources have been added to poll. */ +#define MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR -0x003F /**< Read/write error in file. */ + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_ENTROPY_MAX_SOURCES) +#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ +#endif + +#if !defined(MBEDTLS_ENTROPY_MAX_GATHER) +#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ +#endif + +/* \} name SECTION: Module settings */ + +#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) +#define MBEDTLS_ENTROPY_BLOCK_SIZE 64 /**< Block size of entropy accumulator (SHA-512) */ +#else +#define MBEDTLS_ENTROPY_BLOCK_SIZE 32 /**< Block size of entropy accumulator (SHA-256) */ +#endif + +#define MBEDTLS_ENTROPY_MAX_SEED_SIZE 1024 /**< Maximum size of seed we read from seed file */ +#define MBEDTLS_ENTROPY_SOURCE_MANUAL MBEDTLS_ENTROPY_MAX_SOURCES + +#define MBEDTLS_ENTROPY_SOURCE_STRONG 1 /**< Entropy source is strong */ +#define MBEDTLS_ENTROPY_SOURCE_WEAK 0 /**< Entropy source is weak */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Entropy poll callback pointer + * + * \param data Callback-specific data pointer + * \param output Data to fill + * \param len Maximum size to provide + * \param olen The actual amount of bytes put into the buffer (Can be 0) + * + * \return 0 if no critical failures occurred, + * MBEDTLS_ERR_ENTROPY_SOURCE_FAILED otherwise + */ +typedef int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, size_t len, + size_t *olen); + +/** + * \brief Entropy source state + */ +typedef struct +{ + mbedtls_entropy_f_source_ptr f_source; /**< The entropy source callback */ + void * p_source; /**< The callback data pointer */ + size_t size; /**< Amount received in bytes */ + size_t threshold; /**< Minimum bytes required before release */ + int strong; /**< Is the source strong? */ +} +mbedtls_entropy_source_state; + +/** + * \brief Entropy context structure + */ +typedef struct +{ +#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) + mbedtls_sha512_context accumulator; +#else + mbedtls_sha256_context accumulator; +#endif + int source_count; + mbedtls_entropy_source_state source[MBEDTLS_ENTROPY_MAX_SOURCES]; +#if defined(MBEDTLS_HAVEGE_C) + mbedtls_havege_state havege_data; +#endif +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; /*!< mutex */ +#endif +#if defined(MBEDTLS_ENTROPY_NV_SEED) + int initial_entropy_run; +#endif +} +mbedtls_entropy_context; + +/** + * \brief Initialize the context + * + * \param ctx Entropy context to initialize + */ +void mbedtls_entropy_init( mbedtls_entropy_context *ctx ); + +/** + * \brief Free the data in the context + * + * \param ctx Entropy context to free + */ +void mbedtls_entropy_free( mbedtls_entropy_context *ctx ); + +/** + * \brief Adds an entropy source to poll + * (Thread-safe if MBEDTLS_THREADING_C is enabled) + * + * \param ctx Entropy context + * \param f_source Entropy function + * \param p_source Function data + * \param threshold Minimum required from source before entropy is released + * ( with mbedtls_entropy_func() ) (in bytes) + * \param strong MBEDTLS_ENTROPY_SOURCE_STRONG or + * MBEDTSL_ENTROPY_SOURCE_WEAK. + * At least one strong source needs to be added. + * Weaker sources (such as the cycle counter) can be used as + * a complement. + * + * \return 0 if successful or MBEDTLS_ERR_ENTROPY_MAX_SOURCES + */ +int mbedtls_entropy_add_source( mbedtls_entropy_context *ctx, + mbedtls_entropy_f_source_ptr f_source, void *p_source, + size_t threshold, int strong ); + +/** + * \brief Trigger an extra gather poll for the accumulator + * (Thread-safe if MBEDTLS_THREADING_C is enabled) + * + * \param ctx Entropy context + * + * \return 0 if successful, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED + */ +int mbedtls_entropy_gather( mbedtls_entropy_context *ctx ); + +/** + * \brief Retrieve entropy from the accumulator + * (Maximum length: MBEDTLS_ENTROPY_BLOCK_SIZE) + * (Thread-safe if MBEDTLS_THREADING_C is enabled) + * + * \param data Entropy context + * \param output Buffer to fill + * \param len Number of bytes desired, must be at most MBEDTLS_ENTROPY_BLOCK_SIZE + * + * \return 0 if successful, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED + */ +int mbedtls_entropy_func( void *data, unsigned char *output, size_t len ); + +/** + * \brief Add data to the accumulator manually + * (Thread-safe if MBEDTLS_THREADING_C is enabled) + * + * \param ctx Entropy context + * \param data Data to add + * \param len Length of data + * + * \return 0 if successful + */ +int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx, + const unsigned char *data, size_t len ); + +#if defined(MBEDTLS_ENTROPY_NV_SEED) +/** + * \brief Trigger an update of the seed file in NV by using the + * current entropy pool. + * + * \param ctx Entropy context + * + * \return 0 if successful + */ +int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx ); +#endif /* MBEDTLS_ENTROPY_NV_SEED */ + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Write a seed file + * + * \param ctx Entropy context + * \param path Name of the file + * + * \return 0 if successful, + * MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR on file error, or + * MBEDTLS_ERR_ENTROPY_SOURCE_FAILED + */ +int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *path ); + +/** + * \brief Read and update a seed file. Seed is added to this + * instance. No more than MBEDTLS_ENTROPY_MAX_SEED_SIZE bytes are + * read from the seed file. The rest is ignored. + * + * \param ctx Entropy context + * \param path Name of the file + * + * \return 0 if successful, + * MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR on file error, + * MBEDTLS_ERR_ENTROPY_SOURCE_FAILED + */ +int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *path ); +#endif /* MBEDTLS_FS_IO */ + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine + * + * This module self-test also calls the entropy self-test, + * mbedtls_entropy_source_self_test(); + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_entropy_self_test( int verbose ); + +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) +/** + * \brief Checkup routine + * + * Verifies the integrity of the hardware entropy source + * provided by the function 'mbedtls_hardware_poll()'. + * + * Note this is the only hardware entropy source that is known + * at link time, and other entropy sources configured + * dynamically at runtime by the function + * mbedtls_entropy_add_source() will not be tested. + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_entropy_source_self_test( int verbose ); +#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ +#endif /* MBEDTLS_SELF_TEST */ + +#ifdef __cplusplus +} +#endif + +#endif /* entropy.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy_poll.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy_poll.h new file mode 100644 index 0000000..81258d5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/entropy_poll.h @@ -0,0 +1,109 @@ +/** + * \file entropy_poll.h + * + * \brief Platform-specific and custom entropy polling functions + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ENTROPY_POLL_H +#define MBEDTLS_ENTROPY_POLL_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Default thresholds for built-in sources, in bytes + */ +#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */ +#define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */ +#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */ +#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE) +#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */ +#endif + +/** + * \brief Entropy poll callback that provides 0 entropy. + */ +#if defined(MBEDTLS_TEST_NULL_ENTROPY) + int mbedtls_null_entropy_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + +#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) +/** + * \brief Platform-specific entropy poll callback + */ +int mbedtls_platform_entropy_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + +#if defined(MBEDTLS_HAVEGE_C) +/** + * \brief HAVEGE based entropy poll callback + * + * Requires an HAVEGE state as its data pointer. + */ +int mbedtls_havege_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + +#if defined(MBEDTLS_TIMING_C) +/** + * \brief mbedtls_timing_hardclock-based entropy poll callback + */ +int mbedtls_hardclock_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) +/** + * \brief Entropy poll callback for a hardware source + * + * \warning This is not provided by mbed TLS! + * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h. + * + * \note This must accept NULL as its first argument. + */ +int mbedtls_hardware_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + +#if defined(MBEDTLS_ENTROPY_NV_SEED) +/** + * \brief Entropy poll callback for a non-volatile seed file + * + * \note This must accept NULL as its first argument. + */ +int mbedtls_nv_seed_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* entropy_poll.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/error.h new file mode 100644 index 0000000..5e549f6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/error.h @@ -0,0 +1,107 @@ +/** + * \file error.h + * + * \brief Error to string translation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_ERROR_H +#define MBEDTLS_ERROR_H + +#include + +/** + * Error code layout. + * + * Currently we try to keep all error codes within the negative space of 16 + * bits signed integers to support all platforms (-0x0001 - -0x7FFF). In + * addition we'd like to give two layers of information on the error if + * possible. + * + * For that purpose the error codes are segmented in the following manner: + * + * 16 bit error code bit-segmentation + * + * 1 bit - Unused (sign bit) + * 3 bits - High level module ID + * 5 bits - Module-dependent error code + * 7 bits - Low level module errors + * + * For historical reasons, low-level error codes are divided in even and odd, + * even codes were assigned first, and -1 is reserved for other errors. + * + * Low-level module errors (0x0002-0x007E, 0x0003-0x007F) + * + * Module Nr Codes assigned + * MPI 7 0x0002-0x0010 + * GCM 2 0x0012-0x0014 + * BLOWFISH 2 0x0016-0x0018 + * THREADING 3 0x001A-0x001E + * AES 2 0x0020-0x0022 + * CAMELLIA 2 0x0024-0x0026 + * XTEA 1 0x0028-0x0028 + * BASE64 2 0x002A-0x002C + * OID 1 0x002E-0x002E 0x000B-0x000B + * PADLOCK 1 0x0030-0x0030 + * DES 1 0x0032-0x0032 + * CTR_DBRG 4 0x0034-0x003A + * ENTROPY 3 0x003C-0x0040 0x003D-0x003F + * NET 11 0x0042-0x0052 0x0043-0x0045 + * ASN1 7 0x0060-0x006C + * PBKDF2 1 0x007C-0x007C + * HMAC_DRBG 4 0x0003-0x0009 + * CCM 2 0x000D-0x000F + * + * High-level module nr (3 bits - 0x0...-0x7...) + * Name ID Nr of Errors + * PEM 1 9 + * PKCS#12 1 4 (Started from top) + * X509 2 19 + * PKCS5 2 4 (Started from top) + * DHM 3 9 + * PK 3 14 (Started from top) + * RSA 4 9 + * ECP 4 8 (Started from top) + * MD 5 4 + * CIPHER 6 6 + * SSL 6 17 (Started from top) + * SSL 7 31 + * + * Module dependent error code (5 bits 0x.00.-0x.F8.) + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Translate a mbed TLS error code into a string representation, + * Result is truncated if necessary and always includes a terminating + * null byte. + * + * \param errnum error code + * \param buffer buffer to place representation in + * \param buflen length of the buffer + */ +void mbedtls_strerror( int errnum, char *buffer, size_t buflen ); + +#ifdef __cplusplus +} +#endif + +#endif /* error.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/gcm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/gcm.h new file mode 100644 index 0000000..1b77aae --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/gcm.h @@ -0,0 +1,220 @@ +/** + * \file gcm.h + * + * \brief Galois/Counter mode for 128-bit block ciphers + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_GCM_H +#define MBEDTLS_GCM_H + +#include "cipher.h" + +#include + +#define MBEDTLS_GCM_ENCRYPT 1 +#define MBEDTLS_GCM_DECRYPT 0 + +#define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012 /**< Authenticated decryption failed. */ +#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief GCM context structure + */ +typedef struct { + mbedtls_cipher_context_t cipher_ctx;/*!< cipher context used */ + uint64_t HL[16]; /*!< Precalculated HTable */ + uint64_t HH[16]; /*!< Precalculated HTable */ + uint64_t len; /*!< Total data length */ + uint64_t add_len; /*!< Total add length */ + unsigned char base_ectr[16];/*!< First ECTR for tag */ + unsigned char y[16]; /*!< Y working value */ + unsigned char buf[16]; /*!< buf working value */ + int mode; /*!< Encrypt or Decrypt */ +} +mbedtls_gcm_context; + +/** + * \brief Initialize GCM context (just makes references valid) + * Makes the context ready for mbedtls_gcm_setkey() or + * mbedtls_gcm_free(). + * + * \param ctx GCM context to initialize + */ +void mbedtls_gcm_init( mbedtls_gcm_context *ctx ); + +/** + * \brief GCM initialization (encryption) + * + * \param ctx GCM context to be initialized + * \param cipher cipher to use (a 128-bit block cipher) + * \param key encryption key + * \param keybits must be 128, 192 or 256 + * + * \return 0 if successful, or a cipher specific error code + */ +int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, + mbedtls_cipher_id_t cipher, + const unsigned char *key, + unsigned int keybits ); + +/** + * \brief GCM buffer encryption/decryption using a block cipher + * + * \note On encryption, the output buffer can be the same as the input buffer. + * On decryption, the output buffer cannot be the same as input buffer. + * If buffers overlap, the output buffer must trail at least 8 bytes + * behind the input buffer. + * + * \param ctx GCM context + * \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT + * \param length length of the input data + * \param iv initialization vector + * \param iv_len length of IV + * \param add additional data + * \param add_len length of additional data + * \param input buffer holding the input data + * \param output buffer for holding the output data + * \param tag_len length of the tag to generate + * \param tag buffer for holding the tag + * + * \return 0 if successful + */ +int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx, + int mode, + size_t length, + const unsigned char *iv, + size_t iv_len, + const unsigned char *add, + size_t add_len, + const unsigned char *input, + unsigned char *output, + size_t tag_len, + unsigned char *tag ); + +/** + * \brief GCM buffer authenticated decryption using a block cipher + * + * \note On decryption, the output buffer cannot be the same as input buffer. + * If buffers overlap, the output buffer must trail at least 8 bytes + * behind the input buffer. + * + * \param ctx GCM context + * \param length length of the input data + * \param iv initialization vector + * \param iv_len length of IV + * \param add additional data + * \param add_len length of additional data + * \param tag buffer holding the tag + * \param tag_len length of the tag + * \param input buffer holding the input data + * \param output buffer for holding the output data + * + * \return 0 if successful and authenticated, + * MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match + */ +int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, + size_t length, + const unsigned char *iv, + size_t iv_len, + const unsigned char *add, + size_t add_len, + const unsigned char *tag, + size_t tag_len, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Generic GCM stream start function + * + * \param ctx GCM context + * \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT + * \param iv initialization vector + * \param iv_len length of IV + * \param add additional data (or NULL if length is 0) + * \param add_len length of additional data + * + * \return 0 if successful + */ +int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, + int mode, + const unsigned char *iv, + size_t iv_len, + const unsigned char *add, + size_t add_len ); + +/** + * \brief Generic GCM update function. Encrypts/decrypts using the + * given GCM context. Expects input to be a multiple of 16 + * bytes! Only the last call before mbedtls_gcm_finish() can be less + * than 16 bytes! + * + * \note On decryption, the output buffer cannot be the same as input buffer. + * If buffers overlap, the output buffer must trail at least 8 bytes + * behind the input buffer. + * + * \param ctx GCM context + * \param length length of the input data + * \param input buffer holding the input data + * \param output buffer for holding the output data + * + * \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT + */ +int mbedtls_gcm_update( mbedtls_gcm_context *ctx, + size_t length, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Generic GCM finalisation function. Wraps up the GCM stream + * and generates the tag. The tag can have a maximum length of + * 16 bytes. + * + * \param ctx GCM context + * \param tag buffer for holding the tag + * \param tag_len length of the tag to generate (must be at least 4) + * + * \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT + */ +int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, + unsigned char *tag, + size_t tag_len ); + +/** + * \brief Free a GCM context and underlying cipher sub-context + * + * \param ctx GCM context to free + */ +void mbedtls_gcm_free( mbedtls_gcm_context *ctx ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_gcm_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* gcm.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/havege.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/havege.h new file mode 100644 index 0000000..dac5d31 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/havege.h @@ -0,0 +1,74 @@ +/** + * \file havege.h + * + * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_HAVEGE_H +#define MBEDTLS_HAVEGE_H + +#include + +#define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief HAVEGE state structure + */ +typedef struct +{ + int PT1, PT2, offset[2]; + int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; + int WALK[8192]; +} +mbedtls_havege_state; + +/** + * \brief HAVEGE initialization + * + * \param hs HAVEGE state to be initialized + */ +void mbedtls_havege_init( mbedtls_havege_state *hs ); + +/** + * \brief Clear HAVEGE state + * + * \param hs HAVEGE state to be cleared + */ +void mbedtls_havege_free( mbedtls_havege_state *hs ); + +/** + * \brief HAVEGE rand function + * + * \param p_rng A HAVEGE state + * \param output Buffer to fill + * \param len Length of buffer + * + * \return 0 + */ +int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); + +#ifdef __cplusplus +} +#endif + +#endif /* havege.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/hmac_drbg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/hmac_drbg.h new file mode 100644 index 0000000..e010558 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/hmac_drbg.h @@ -0,0 +1,299 @@ +/** + * \file hmac_drbg.h + * + * \brief HMAC_DRBG (NIST SP 800-90A) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_HMAC_DRBG_H +#define MBEDTLS_HMAC_DRBG_H + +#include "md.h" + +#if defined(MBEDTLS_THREADING_C) +#include "mbedtls/threading.h" +#endif + +/* + * Error codes + */ +#define MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -0x0003 /**< Too many random requested in single call. */ +#define MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0005 /**< Input too large (Entropy + additional). */ +#define MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR -0x0007 /**< Read/write error in file. */ +#define MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED -0x0009 /**< The entropy source failed. */ + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_HMAC_DRBG_RESEED_INTERVAL) +#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +#endif + +#if !defined(MBEDTLS_HMAC_DRBG_MAX_INPUT) +#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +#endif + +#if !defined(MBEDTLS_HMAC_DRBG_MAX_REQUEST) +#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +#endif + +#if !defined(MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT) +#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ +#endif + +/* \} name SECTION: Module settings */ + +#define MBEDTLS_HMAC_DRBG_PR_OFF 0 /**< No prediction resistance */ +#define MBEDTLS_HMAC_DRBG_PR_ON 1 /**< Prediction resistance enabled */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * HMAC_DRBG context. + */ +typedef struct +{ + /* Working state: the key K is not stored explicitely, + * but is implied by the HMAC context */ + mbedtls_md_context_t md_ctx; /*!< HMAC context (inc. K) */ + unsigned char V[MBEDTLS_MD_MAX_SIZE]; /*!< V in the spec */ + int reseed_counter; /*!< reseed counter */ + + /* Administrative state */ + size_t entropy_len; /*!< entropy bytes grabbed on each (re)seed */ + int prediction_resistance; /*!< enable prediction resistance (Automatic + reseed before every random generation) */ + int reseed_interval; /*!< reseed interval */ + + /* Callbacks */ + int (*f_entropy)(void *, unsigned char *, size_t); /*!< entropy function */ + void *p_entropy; /*!< context for the entropy function */ + +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; +#endif +} mbedtls_hmac_drbg_context; + +/** + * \brief HMAC_DRBG context initialization + * Makes the context ready for mbedtls_hmac_drbg_seed(), + * mbedtls_hmac_drbg_seed_buf() or + * mbedtls_hmac_drbg_free(). + * + * \param ctx HMAC_DRBG context to be initialized + */ +void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx ); + +/** + * \brief HMAC_DRBG initial seeding + * Seed and setup entropy source for future reseeds. + * + * \param ctx HMAC_DRBG context to be seeded + * \param md_info MD algorithm to use for HMAC_DRBG + * \param f_entropy Entropy callback (p_entropy, buffer to fill, buffer + * length) + * \param p_entropy Entropy context + * \param custom Personalization data (Device specific identifiers) + * (Can be NULL) + * \param len Length of personalization data + * + * \note The "security strength" as defined by NIST is set to: + * 128 bits if md_alg is SHA-1, + * 192 bits if md_alg is SHA-224, + * 256 bits if md_alg is SHA-256 or higher. + * Note that SHA-256 is just as efficient as SHA-224. + * + * \return 0 if successful, or + * MBEDTLS_ERR_MD_BAD_INPUT_DATA, or + * MBEDTLS_ERR_MD_ALLOC_FAILED, or + * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED. + */ +int mbedtls_hmac_drbg_seed( mbedtls_hmac_drbg_context *ctx, + const mbedtls_md_info_t * md_info, + int (*f_entropy)(void *, unsigned char *, size_t), + void *p_entropy, + const unsigned char *custom, + size_t len ); + +/** + * \brief Initilisation of simpified HMAC_DRBG (never reseeds). + * (For use with deterministic ECDSA.) + * + * \param ctx HMAC_DRBG context to be initialised + * \param md_info MD algorithm to use for HMAC_DRBG + * \param data Concatenation of entropy string and additional data + * \param data_len Length of data in bytes + * + * \return 0 if successful, or + * MBEDTLS_ERR_MD_BAD_INPUT_DATA, or + * MBEDTLS_ERR_MD_ALLOC_FAILED. + */ +int mbedtls_hmac_drbg_seed_buf( mbedtls_hmac_drbg_context *ctx, + const mbedtls_md_info_t * md_info, + const unsigned char *data, size_t data_len ); + +/** + * \brief Enable / disable prediction resistance (Default: Off) + * + * Note: If enabled, entropy is used for ctx->entropy_len before each call! + * Only use this if you have ample supply of good entropy! + * + * \param ctx HMAC_DRBG context + * \param resistance MBEDTLS_HMAC_DRBG_PR_ON or MBEDTLS_HMAC_DRBG_PR_OFF + */ +void mbedtls_hmac_drbg_set_prediction_resistance( mbedtls_hmac_drbg_context *ctx, + int resistance ); + +/** + * \brief Set the amount of entropy grabbed on each reseed + * (Default: given by the security strength, which + * depends on the hash used, see \c mbedtls_hmac_drbg_init() ) + * + * \param ctx HMAC_DRBG context + * \param len Amount of entropy to grab, in bytes + */ +void mbedtls_hmac_drbg_set_entropy_len( mbedtls_hmac_drbg_context *ctx, + size_t len ); + +/** + * \brief Set the reseed interval + * (Default: MBEDTLS_HMAC_DRBG_RESEED_INTERVAL) + * + * \param ctx HMAC_DRBG context + * \param interval Reseed interval + */ +void mbedtls_hmac_drbg_set_reseed_interval( mbedtls_hmac_drbg_context *ctx, + int interval ); + +/** + * \brief HMAC_DRBG update state + * + * \param ctx HMAC_DRBG context + * \param additional Additional data to update state with, or NULL + * \param add_len Length of additional data, or 0 + * + * \note Additional data is optional, pass NULL and 0 as second + * third argument if no additional data is being used. + */ +void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx, + const unsigned char *additional, size_t add_len ); + +/** + * \brief HMAC_DRBG reseeding (extracts data from entropy source) + * + * \param ctx HMAC_DRBG context + * \param additional Additional data to add to state (Can be NULL) + * \param len Length of additional data + * + * \return 0 if successful, or + * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED + */ +int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx, + const unsigned char *additional, size_t len ); + +/** + * \brief HMAC_DRBG generate random with additional update input + * + * Note: Automatically reseeds if reseed_counter is reached or PR is enabled. + * + * \param p_rng HMAC_DRBG context + * \param output Buffer to fill + * \param output_len Length of the buffer + * \param additional Additional data to update with (can be NULL) + * \param add_len Length of additional data (can be 0) + * + * \return 0 if successful, or + * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED, or + * MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG, or + * MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG. + */ +int mbedtls_hmac_drbg_random_with_add( void *p_rng, + unsigned char *output, size_t output_len, + const unsigned char *additional, + size_t add_len ); + +/** + * \brief HMAC_DRBG generate random + * + * Note: Automatically reseeds if reseed_counter is reached or PR is enabled. + * + * \param p_rng HMAC_DRBG context + * \param output Buffer to fill + * \param out_len Length of the buffer + * + * \return 0 if successful, or + * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED, or + * MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG + */ +int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len ); + +/** + * \brief Free an HMAC_DRBG context + * + * \param ctx HMAC_DRBG context to free. + */ +void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Write a seed file + * + * \param ctx HMAC_DRBG context + * \param path Name of the file + * + * \return 0 if successful, 1 on file error, or + * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED + */ +int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ); + +/** + * \brief Read and update a seed file. Seed is added to this + * instance + * + * \param ctx HMAC_DRBG context + * \param path Name of the file + * + * \return 0 if successful, 1 on file error, + * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED or + * MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG + */ +int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ); +#endif /* MBEDTLS_FS_IO */ + + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_hmac_drbg_self_test( int verbose ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* hmac_drbg.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md.h new file mode 100644 index 0000000..9b996a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md.h @@ -0,0 +1,354 @@ +/** + * \file md.h + * + * \brief Generic message digest wrapper + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_MD_H +#define MBEDTLS_MD_H + +#include + +#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */ +#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */ +#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + MBEDTLS_MD_NONE=0, + MBEDTLS_MD_MD2, + MBEDTLS_MD_MD4, + MBEDTLS_MD_MD5, + MBEDTLS_MD_SHA1, + MBEDTLS_MD_SHA224, + MBEDTLS_MD_SHA256, + MBEDTLS_MD_SHA384, + MBEDTLS_MD_SHA512, + MBEDTLS_MD_RIPEMD160, +} mbedtls_md_type_t; + +#if defined(MBEDTLS_SHA512_C) +#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */ +#else +#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */ +#endif + +/** + * Opaque struct defined in md_internal.h + */ +typedef struct mbedtls_md_info_t mbedtls_md_info_t; + +/** + * Generic message digest context. + */ +typedef struct { + /** Information about the associated message digest */ + const mbedtls_md_info_t *md_info; + + /** Digest-specific context */ + void *md_ctx; + + /** HMAC part of the context */ + void *hmac_ctx; +} mbedtls_md_context_t; + +/** + * \brief Returns the list of digests supported by the generic digest module. + * + * \return a statically allocated array of digests, the last entry + * is 0. + */ +const int *mbedtls_md_list( void ); + +/** + * \brief Returns the message digest information associated with the + * given digest name. + * + * \param md_name Name of the digest to search for. + * + * \return The message digest information associated with md_name or + * NULL if not found. + */ +const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name ); + +/** + * \brief Returns the message digest information associated with the + * given digest type. + * + * \param md_type type of digest to search for. + * + * \return The message digest information associated with md_type or + * NULL if not found. + */ +const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type ); + +/** + * \brief Initialize a md_context (as NONE) + * This should always be called first. + * Prepares the context for mbedtls_md_setup() or mbedtls_md_free(). + */ +void mbedtls_md_init( mbedtls_md_context_t *ctx ); + +/** + * \brief Free and clear the internal structures of ctx. + * Can be called at any time after mbedtls_md_init(). + * Mandatory once mbedtls_md_setup() has been called. + */ +void mbedtls_md_free( mbedtls_md_context_t *ctx ); + +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif +/** + * \brief Select MD to use and allocate internal structures. + * Should be called after mbedtls_md_init() or mbedtls_md_free(). + * Makes it necessary to call mbedtls_md_free() later. + * + * \deprecated Superseded by mbedtls_md_setup() in 2.0.0 + * + * \param ctx Context to set up. + * \param md_info Message digest to use. + * + * \returns \c 0 on success, + * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, + * \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure. + */ +int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED; +#undef MBEDTLS_DEPRECATED +#endif /* MBEDTLS_DEPRECATED_REMOVED */ + +/** + * \brief Select MD to use and allocate internal structures. + * Should be called after mbedtls_md_init() or mbedtls_md_free(). + * Makes it necessary to call mbedtls_md_free() later. + * + * \param ctx Context to set up. + * \param md_info Message digest to use. + * \param hmac 0 to save some memory if HMAC will not be used, + * non-zero is HMAC is going to be used with this context. + * + * \returns \c 0 on success, + * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, + * \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure. + */ +int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac ); + +/** + * \brief Clone the state of an MD context + * + * \note The two contexts must have been setup to the same type + * (cloning from SHA-256 to SHA-512 make no sense). + * + * \warning Only clones the MD state, not the HMAC state! (for now) + * + * \param dst The destination context + * \param src The context to be cloned + * + * \return \c 0 on success, + * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure. + */ +int mbedtls_md_clone( mbedtls_md_context_t *dst, + const mbedtls_md_context_t *src ); + +/** + * \brief Returns the size of the message digest output. + * + * \param md_info message digest info + * + * \return size of the message digest output in bytes. + */ +unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info ); + +/** + * \brief Returns the type of the message digest output. + * + * \param md_info message digest info + * + * \return type of the message digest output. + */ +mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info ); + +/** + * \brief Returns the name of the message digest output. + * + * \param md_info message digest info + * + * \return name of the message digest output. + */ +const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info ); + +/** + * \brief Prepare the context to digest a new message. + * Generally called after mbedtls_md_setup() or mbedtls_md_finish(). + * Followed by mbedtls_md_update(). + * + * \param ctx generic message digest context. + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_starts( mbedtls_md_context_t *ctx ); + +/** + * \brief Generic message digest process buffer + * Called between mbedtls_md_starts() and mbedtls_md_finish(). + * May be called repeatedly. + * + * \param ctx Generic message digest context + * \param input buffer holding the datal + * \param ilen length of the input data + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ); + +/** + * \brief Generic message digest final digest + * Called after mbedtls_md_update(). + * Usually followed by mbedtls_md_free() or mbedtls_md_starts(). + * + * \param ctx Generic message digest context + * \param output Generic message digest checksum result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ); + +/** + * \brief Output = message_digest( input buffer ) + * + * \param md_info message digest info + * \param input buffer holding the data + * \param ilen length of the input data + * \param output Generic message digest checksum result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, + unsigned char *output ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Output = message_digest( file contents ) + * + * \param md_info message digest info + * \param path input file name + * \param output generic message digest checksum result + * + * \return 0 if successful, + * MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed, + * MBEDTLS_ERR_MD_BAD_INPUT_DATA if md_info was NULL. + */ +int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, + unsigned char *output ); +#endif /* MBEDTLS_FS_IO */ + +/** + * \brief Set HMAC key and prepare to authenticate a new message. + * Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish(). + * + * \param ctx HMAC context + * \param key HMAC secret key + * \param keylen length of the HMAC key in bytes + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, + size_t keylen ); + +/** + * \brief Generic HMAC process buffer. + * Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset() + * and mbedtls_md_hmac_finish(). + * May be called repeatedly. + * + * \param ctx HMAC context + * \param input buffer holding the data + * \param ilen length of the input data + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, + size_t ilen ); + +/** + * \brief Output HMAC. + * Called after mbedtls_md_hmac_update(). + * Usually followed by mbedtls_md_hmac_reset(), + * mbedtls_md_hmac_starts(), or mbedtls_md_free(). + * + * \param ctx HMAC context + * \param output Generic HMAC checksum result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output); + +/** + * \brief Prepare to authenticate a new message with the same key. + * Called after mbedtls_md_hmac_finish() and before + * mbedtls_md_hmac_update(). + * + * \param ctx HMAC context to be reset + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ); + +/** + * \brief Output = Generic_HMAC( hmac key, input buffer ) + * + * \param md_info message digest info + * \param key HMAC secret key + * \param keylen length of the HMAC key in bytes + * \param input buffer holding the data + * \param ilen length of the input data + * \param output Generic HMAC-result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char *output ); + +/* Internal use */ +int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data ); + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_MD_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md2.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md2.h new file mode 100644 index 0000000..0f93fbf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md2.h @@ -0,0 +1,136 @@ +/** + * \file md2.h + * + * \brief MD2 message digest algorithm (hash function) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_MD2_H +#define MBEDTLS_MD2_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#if !defined(MBEDTLS_MD2_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief MD2 context structure + */ +typedef struct +{ + unsigned char cksum[16]; /*!< checksum of the data block */ + unsigned char state[48]; /*!< intermediate digest state */ + unsigned char buffer[16]; /*!< data block being processed */ + size_t left; /*!< amount of data in buffer */ +} +mbedtls_md2_context; + +/** + * \brief Initialize MD2 context + * + * \param ctx MD2 context to be initialized + */ +void mbedtls_md2_init( mbedtls_md2_context *ctx ); + +/** + * \brief Clear MD2 context + * + * \param ctx MD2 context to be cleared + */ +void mbedtls_md2_free( mbedtls_md2_context *ctx ); + +/** + * \brief Clone (the state of) an MD2 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_md2_clone( mbedtls_md2_context *dst, + const mbedtls_md2_context *src ); + +/** + * \brief MD2 context setup + * + * \param ctx context to be initialized + */ +void mbedtls_md2_starts( mbedtls_md2_context *ctx ); + +/** + * \brief MD2 process buffer + * + * \param ctx MD2 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen ); + +/** + * \brief MD2 final digest + * + * \param ctx MD2 context + * \param output MD2 checksum result + */ +void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_MD2_ALT */ +#include "md2_alt.h" +#endif /* MBEDTLS_MD2_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = MD2( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output MD2 checksum result + */ +void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_md2_self_test( int verbose ); + +/* Internal use */ +void mbedtls_md2_process( mbedtls_md2_context *ctx ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_md2.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md4.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md4.h new file mode 100644 index 0000000..45214d4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md4.h @@ -0,0 +1,136 @@ +/** + * \file md4.h + * + * \brief MD4 message digest algorithm (hash function) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_MD4_H +#define MBEDTLS_MD4_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if !defined(MBEDTLS_MD4_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief MD4 context structure + */ +typedef struct +{ + uint32_t total[2]; /*!< number of bytes processed */ + uint32_t state[4]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +mbedtls_md4_context; + +/** + * \brief Initialize MD4 context + * + * \param ctx MD4 context to be initialized + */ +void mbedtls_md4_init( mbedtls_md4_context *ctx ); + +/** + * \brief Clear MD4 context + * + * \param ctx MD4 context to be cleared + */ +void mbedtls_md4_free( mbedtls_md4_context *ctx ); + +/** + * \brief Clone (the state of) an MD4 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_md4_clone( mbedtls_md4_context *dst, + const mbedtls_md4_context *src ); + +/** + * \brief MD4 context setup + * + * \param ctx context to be initialized + */ +void mbedtls_md4_starts( mbedtls_md4_context *ctx ); + +/** + * \brief MD4 process buffer + * + * \param ctx MD4 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen ); + +/** + * \brief MD4 final digest + * + * \param ctx MD4 context + * \param output MD4 checksum result + */ +void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_MD4_ALT */ +#include "md4_alt.h" +#endif /* MBEDTLS_MD4_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = MD4( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output MD4 checksum result + */ +void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_md4_self_test( int verbose ); + +/* Internal use */ +void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_md4.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md5.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md5.h new file mode 100644 index 0000000..5a64061 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md5.h @@ -0,0 +1,136 @@ +/** + * \file md5.h + * + * \brief MD5 message digest algorithm (hash function) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_MD5_H +#define MBEDTLS_MD5_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if !defined(MBEDTLS_MD5_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief MD5 context structure + */ +typedef struct +{ + uint32_t total[2]; /*!< number of bytes processed */ + uint32_t state[4]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +mbedtls_md5_context; + +/** + * \brief Initialize MD5 context + * + * \param ctx MD5 context to be initialized + */ +void mbedtls_md5_init( mbedtls_md5_context *ctx ); + +/** + * \brief Clear MD5 context + * + * \param ctx MD5 context to be cleared + */ +void mbedtls_md5_free( mbedtls_md5_context *ctx ); + +/** + * \brief Clone (the state of) an MD5 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_md5_clone( mbedtls_md5_context *dst, + const mbedtls_md5_context *src ); + +/** + * \brief MD5 context setup + * + * \param ctx context to be initialized + */ +void mbedtls_md5_starts( mbedtls_md5_context *ctx ); + +/** + * \brief MD5 process buffer + * + * \param ctx MD5 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen ); + +/** + * \brief MD5 final digest + * + * \param ctx MD5 context + * \param output MD5 checksum result + */ +void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] ); + +/* Internal use */ +void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_MD5_ALT */ +#include "md5_alt.h" +#endif /* MBEDTLS_MD5_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = MD5( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output MD5 checksum result + */ +void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_md5_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_md5.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md_internal.h new file mode 100644 index 0000000..e2441bb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/md_internal.h @@ -0,0 +1,114 @@ +/** + * \file md_internal.h + * + * \brief Message digest wrappers. + * + * \warning This in an internal header. Do not include directly. + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_MD_WRAP_H +#define MBEDTLS_MD_WRAP_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "md.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Message digest information. + * Allows message digest functions to be called in a generic way. + */ +struct mbedtls_md_info_t +{ + /** Digest identifier */ + mbedtls_md_type_t type; + + /** Name of the message digest */ + const char * name; + + /** Output length of the digest function in bytes */ + int size; + + /** Block length of the digest function in bytes */ + int block_size; + + /** Digest initialisation function */ + void (*starts_func)( void *ctx ); + + /** Digest update function */ + void (*update_func)( void *ctx, const unsigned char *input, size_t ilen ); + + /** Digest finalisation function */ + void (*finish_func)( void *ctx, unsigned char *output ); + + /** Generic digest function */ + void (*digest_func)( const unsigned char *input, size_t ilen, + unsigned char *output ); + + /** Allocate a new context */ + void * (*ctx_alloc_func)( void ); + + /** Free the given context */ + void (*ctx_free_func)( void *ctx ); + + /** Clone state from a context */ + void (*clone_func)( void *dst, const void *src ); + + /** Internal use only */ + void (*process_func)( void *ctx, const unsigned char *input ); +}; + +#if defined(MBEDTLS_MD2_C) +extern const mbedtls_md_info_t mbedtls_md2_info; +#endif +#if defined(MBEDTLS_MD4_C) +extern const mbedtls_md_info_t mbedtls_md4_info; +#endif +#if defined(MBEDTLS_MD5_C) +extern const mbedtls_md_info_t mbedtls_md5_info; +#endif +#if defined(MBEDTLS_RIPEMD160_C) +extern const mbedtls_md_info_t mbedtls_ripemd160_info; +#endif +#if defined(MBEDTLS_SHA1_C) +extern const mbedtls_md_info_t mbedtls_sha1_info; +#endif +#if defined(MBEDTLS_SHA256_C) +extern const mbedtls_md_info_t mbedtls_sha224_info; +extern const mbedtls_md_info_t mbedtls_sha256_info; +#endif +#if defined(MBEDTLS_SHA512_C) +extern const mbedtls_md_info_t mbedtls_sha384_info; +extern const mbedtls_md_info_t mbedtls_sha512_info; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_MD_WRAP_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/memory_buffer_alloc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/memory_buffer_alloc.h new file mode 100644 index 0000000..d5df316 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/memory_buffer_alloc.h @@ -0,0 +1,150 @@ +/** + * \file memory_buffer_alloc.h + * + * \brief Buffer-based memory allocator + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_MEMORY_BUFFER_ALLOC_H +#define MBEDTLS_MEMORY_BUFFER_ALLOC_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_MEMORY_ALIGN_MULTIPLE) +#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ +#endif + +/* \} name SECTION: Module settings */ + +#define MBEDTLS_MEMORY_VERIFY_NONE 0 +#define MBEDTLS_MEMORY_VERIFY_ALLOC (1 << 0) +#define MBEDTLS_MEMORY_VERIFY_FREE (1 << 1) +#define MBEDTLS_MEMORY_VERIFY_ALWAYS (MBEDTLS_MEMORY_VERIFY_ALLOC | MBEDTLS_MEMORY_VERIFY_FREE) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Initialize use of stack-based memory allocator. + * The stack-based allocator does memory management inside the + * presented buffer and does not call calloc() and free(). + * It sets the global mbedtls_calloc() and mbedtls_free() pointers + * to its own functions. + * (Provided mbedtls_calloc() and mbedtls_free() are thread-safe if + * MBEDTLS_THREADING_C is defined) + * + * \note This code is not optimized and provides a straight-forward + * implementation of a stack-based memory allocator. + * + * \param buf buffer to use as heap + * \param len size of the buffer + */ +void mbedtls_memory_buffer_alloc_init( unsigned char *buf, size_t len ); + +/** + * \brief Free the mutex for thread-safety and clear remaining memory + */ +void mbedtls_memory_buffer_alloc_free( void ); + +/** + * \brief Determine when the allocator should automatically verify the state + * of the entire chain of headers / meta-data. + * (Default: MBEDTLS_MEMORY_VERIFY_NONE) + * + * \param verify One of MBEDTLS_MEMORY_VERIFY_NONE, MBEDTLS_MEMORY_VERIFY_ALLOC, + * MBEDTLS_MEMORY_VERIFY_FREE or MBEDTLS_MEMORY_VERIFY_ALWAYS + */ +void mbedtls_memory_buffer_set_verify( int verify ); + +#if defined(MBEDTLS_MEMORY_DEBUG) +/** + * \brief Print out the status of the allocated memory (primarily for use + * after a program should have de-allocated all memory) + * Prints out a list of 'still allocated' blocks and their stack + * trace if MBEDTLS_MEMORY_BACKTRACE is defined. + */ +void mbedtls_memory_buffer_alloc_status( void ); + +/** + * \brief Get the peak heap usage so far + * + * \param max_used Peak number of bytes in use or committed. This + * includes bytes in allocated blocks too small to split + * into smaller blocks but larger than the requested size. + * \param max_blocks Peak number of blocks in use, including free and used + */ +void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks ); + +/** + * \brief Reset peak statistics + */ +void mbedtls_memory_buffer_alloc_max_reset( void ); + +/** + * \brief Get the current heap usage + * + * \param cur_used Current number of bytes in use or committed. This + * includes bytes in allocated blocks too small to split + * into smaller blocks but larger than the requested size. + * \param cur_blocks Current number of blocks in use, including free and used + */ +void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks ); +#endif /* MBEDTLS_MEMORY_DEBUG */ + +/** + * \brief Verifies that all headers in the memory buffer are correct + * and contain sane values. Helps debug buffer-overflow errors. + * + * Prints out first failure if MBEDTLS_MEMORY_DEBUG is defined. + * Prints out full header information if MBEDTLS_MEMORY_DEBUG + * is defined. (Includes stack trace information for each block if + * MBEDTLS_MEMORY_BACKTRACE is defined as well). + * + * \return 0 if verified, 1 otherwise + */ +int mbedtls_memory_buffer_alloc_verify( void ); + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_memory_buffer_alloc_self_test( int verbose ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* memory_buffer_alloc.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net.h new file mode 100644 index 0000000..774559b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net.h @@ -0,0 +1,31 @@ +/** + * \file net.h + * + * \brief Deprecated header file that includes mbedtls/net_sockets.h + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + * + * \deprecated Superseded by mbedtls/net_sockets.h + */ + +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#include "mbedtls/net_sockets.h" +#if defined(MBEDTLS_DEPRECATED_WARNING) +#warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" +#endif /* MBEDTLS_DEPRECATED_WARNING */ +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net_sockets.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net_sockets.h new file mode 100644 index 0000000..de33552 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/net_sockets.h @@ -0,0 +1,225 @@ +/** + * \file net_sockets.h + * + * \brief Network communication functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_NET_SOCKETS_H +#define MBEDTLS_NET_SOCKETS_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "ssl.h" + +#include +#include + +#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */ +#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */ +#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */ +#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */ +#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */ +#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */ +#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */ +#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */ +#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */ +#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */ +#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */ + +#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */ + +#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */ +#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Wrapper type for sockets. + * + * Currently backed by just a file descriptor, but might be more in the future + * (eg two file descriptors for combined IPv4 + IPv6 support, or additional + * structures for hand-made UDP demultiplexing). + */ +typedef struct +{ + int fd; /**< The underlying file descriptor */ +} +mbedtls_net_context; + +/** + * \brief Initialize a context + * Just makes the context ready to be used or freed safely. + * + * \param ctx Context to initialize + */ +void mbedtls_net_init( mbedtls_net_context *ctx ); + +/** + * \brief Initiate a connection with host:port in the given protocol + * + * \param ctx Socket to use + * \param host Host to connect to + * \param port Port to connect to + * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP + * + * \return 0 if successful, or one of: + * MBEDTLS_ERR_NET_SOCKET_FAILED, + * MBEDTLS_ERR_NET_UNKNOWN_HOST, + * MBEDTLS_ERR_NET_CONNECT_FAILED + * + * \note Sets the socket in connected mode even with UDP. + */ +int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto ); + +/** + * \brief Create a receiving socket on bind_ip:port in the chosen + * protocol. If bind_ip == NULL, all interfaces are bound. + * + * \param ctx Socket to use + * \param bind_ip IP to bind to, can be NULL + * \param port Port number to use + * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP + * + * \return 0 if successful, or one of: + * MBEDTLS_ERR_NET_SOCKET_FAILED, + * MBEDTLS_ERR_NET_BIND_FAILED, + * MBEDTLS_ERR_NET_LISTEN_FAILED + * + * \note Regardless of the protocol, opens the sockets and binds it. + * In addition, make the socket listening if protocol is TCP. + */ +int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto ); + +/** + * \brief Accept a connection from a remote client + * + * \param bind_ctx Relevant socket + * \param client_ctx Will contain the connected client socket + * \param client_ip Will contain the client IP address + * \param buf_size Size of the client_ip buffer + * \param ip_len Will receive the size of the client IP written + * + * \return 0 if successful, or + * MBEDTLS_ERR_NET_ACCEPT_FAILED, or + * MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small, + * MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to + * non-blocking and accept() would block. + */ +int mbedtls_net_accept( mbedtls_net_context *bind_ctx, + mbedtls_net_context *client_ctx, + void *client_ip, size_t buf_size, size_t *ip_len ); + +/** + * \brief Set the socket blocking + * + * \param ctx Socket to set + * + * \return 0 if successful, or a non-zero error code + */ +int mbedtls_net_set_block( mbedtls_net_context *ctx ); + +/** + * \brief Set the socket non-blocking + * + * \param ctx Socket to set + * + * \return 0 if successful, or a non-zero error code + */ +int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ); + +/** + * \brief Portable usleep helper + * + * \param usec Amount of microseconds to sleep + * + * \note Real amount of time slept will not be less than + * select()'s timeout granularity (typically, 10ms). + */ +void mbedtls_net_usleep( unsigned long usec ); + +/** + * \brief Read at most 'len' characters. If no error occurs, + * the actual amount read is returned. + * + * \param ctx Socket + * \param buf The buffer to write to + * \param len Maximum length of the buffer + * + * \return the number of bytes received, + * or a non-zero error code; with a non-blocking socket, + * MBEDTLS_ERR_SSL_WANT_READ indicates read() would block. + */ +int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ); + +/** + * \brief Write at most 'len' characters. If no error occurs, + * the actual amount read is returned. + * + * \param ctx Socket + * \param buf The buffer to read from + * \param len The length of the buffer + * + * \return the number of bytes sent, + * or a non-zero error code; with a non-blocking socket, + * MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block. + */ +int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); + +/** + * \brief Read at most 'len' characters, blocking for at most + * 'timeout' seconds. If no error occurs, the actual amount + * read is returned. + * + * \param ctx Socket + * \param buf The buffer to write to + * \param len Maximum length of the buffer + * \param timeout Maximum number of milliseconds to wait for data + * 0 means no timeout (wait forever) + * + * \return the number of bytes received, + * or a non-zero error code: + * MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out, + * MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. + * + * \note This function will block (until data becomes available or + * timeout is reached) even if the socket is set to + * non-blocking. Handling timeouts with non-blocking reads + * requires a different strategy. + */ +int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, + uint32_t timeout ); + +/** + * \brief Gracefully shutdown the connection and free associated data + * + * \param ctx The context to free + */ +void mbedtls_net_free( mbedtls_net_context *ctx ); + +#ifdef __cplusplus +} +#endif + +#endif /* net_sockets.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/oid.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/oid.h new file mode 100644 index 0000000..fcecdaf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/oid.h @@ -0,0 +1,570 @@ +/** + * \file oid.h + * + * \brief Object Identifier (OID) database + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_OID_H +#define MBEDTLS_OID_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "asn1.h" +#include "pk.h" + +#include + +#if defined(MBEDTLS_CIPHER_C) +#include "cipher.h" +#endif + +#if defined(MBEDTLS_MD_C) +#include "md.h" +#endif + +#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) +#include "x509.h" +#endif + +#define MBEDTLS_ERR_OID_NOT_FOUND -0x002E /**< OID is not found. */ +#define MBEDTLS_ERR_OID_BUF_TOO_SMALL -0x000B /**< output buffer is too small */ + +/* + * Top level OID tuples + */ +#define MBEDTLS_OID_ISO_MEMBER_BODIES "\x2a" /* {iso(1) member-body(2)} */ +#define MBEDTLS_OID_ISO_IDENTIFIED_ORG "\x2b" /* {iso(1) identified-organization(3)} */ +#define MBEDTLS_OID_ISO_CCITT_DS "\x55" /* {joint-iso-ccitt(2) ds(5)} */ +#define MBEDTLS_OID_ISO_ITU_COUNTRY "\x60" /* {joint-iso-itu-t(2) country(16)} */ + +/* + * ISO Member bodies OID parts + */ +#define MBEDTLS_OID_COUNTRY_US "\x86\x48" /* {us(840)} */ +#define MBEDTLS_OID_ORG_RSA_DATA_SECURITY "\x86\xf7\x0d" /* {rsadsi(113549)} */ +#define MBEDTLS_OID_RSA_COMPANY MBEDTLS_OID_ISO_MEMBER_BODIES MBEDTLS_OID_COUNTRY_US \ + MBEDTLS_OID_ORG_RSA_DATA_SECURITY /* {iso(1) member-body(2) us(840) rsadsi(113549)} */ +#define MBEDTLS_OID_ORG_ANSI_X9_62 "\xce\x3d" /* ansi-X9-62(10045) */ +#define MBEDTLS_OID_ANSI_X9_62 MBEDTLS_OID_ISO_MEMBER_BODIES MBEDTLS_OID_COUNTRY_US \ + MBEDTLS_OID_ORG_ANSI_X9_62 + +/* + * ISO Identified organization OID parts + */ +#define MBEDTLS_OID_ORG_DOD "\x06" /* {dod(6)} */ +#define MBEDTLS_OID_ORG_OIW "\x0e" +#define MBEDTLS_OID_OIW_SECSIG MBEDTLS_OID_ORG_OIW "\x03" +#define MBEDTLS_OID_OIW_SECSIG_ALG MBEDTLS_OID_OIW_SECSIG "\x02" +#define MBEDTLS_OID_OIW_SECSIG_SHA1 MBEDTLS_OID_OIW_SECSIG_ALG "\x1a" +#define MBEDTLS_OID_ORG_CERTICOM "\x81\x04" /* certicom(132) */ +#define MBEDTLS_OID_CERTICOM MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ORG_CERTICOM +#define MBEDTLS_OID_ORG_TELETRUST "\x24" /* teletrust(36) */ +#define MBEDTLS_OID_TELETRUST MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ORG_TELETRUST + +/* + * ISO ITU OID parts + */ +#define MBEDTLS_OID_ORGANIZATION "\x01" /* {organization(1)} */ +#define MBEDTLS_OID_ISO_ITU_US_ORG MBEDTLS_OID_ISO_ITU_COUNTRY MBEDTLS_OID_COUNTRY_US MBEDTLS_OID_ORGANIZATION /* {joint-iso-itu-t(2) country(16) us(840) organization(1)} */ + +#define MBEDTLS_OID_ORG_GOV "\x65" /* {gov(101)} */ +#define MBEDTLS_OID_GOV MBEDTLS_OID_ISO_ITU_US_ORG MBEDTLS_OID_ORG_GOV /* {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101)} */ + +#define MBEDTLS_OID_ORG_NETSCAPE "\x86\xF8\x42" /* {netscape(113730)} */ +#define MBEDTLS_OID_NETSCAPE MBEDTLS_OID_ISO_ITU_US_ORG MBEDTLS_OID_ORG_NETSCAPE /* Netscape OID {joint-iso-itu-t(2) country(16) us(840) organization(1) netscape(113730)} */ + +/* ISO arc for standard certificate and CRL extensions */ +#define MBEDTLS_OID_ID_CE MBEDTLS_OID_ISO_CCITT_DS "\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */ + +/** + * Private Internet Extensions + * { iso(1) identified-organization(3) dod(6) internet(1) + * security(5) mechanisms(5) pkix(7) } + */ +#define MBEDTLS_OID_PKIX MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ORG_DOD "\x01\x05\x05\x07" + +/* + * Arc for standard naming attributes + */ +#define MBEDTLS_OID_AT MBEDTLS_OID_ISO_CCITT_DS "\x04" /**< id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4} */ +#define MBEDTLS_OID_AT_CN MBEDTLS_OID_AT "\x03" /**< id-at-commonName AttributeType:= {id-at 3} */ +#define MBEDTLS_OID_AT_SUR_NAME MBEDTLS_OID_AT "\x04" /**< id-at-surName AttributeType:= {id-at 4} */ +#define MBEDTLS_OID_AT_SERIAL_NUMBER MBEDTLS_OID_AT "\x05" /**< id-at-serialNumber AttributeType:= {id-at 5} */ +#define MBEDTLS_OID_AT_COUNTRY MBEDTLS_OID_AT "\x06" /**< id-at-countryName AttributeType:= {id-at 6} */ +#define MBEDTLS_OID_AT_LOCALITY MBEDTLS_OID_AT "\x07" /**< id-at-locality AttributeType:= {id-at 7} */ +#define MBEDTLS_OID_AT_STATE MBEDTLS_OID_AT "\x08" /**< id-at-state AttributeType:= {id-at 8} */ +#define MBEDTLS_OID_AT_ORGANIZATION MBEDTLS_OID_AT "\x0A" /**< id-at-organizationName AttributeType:= {id-at 10} */ +#define MBEDTLS_OID_AT_ORG_UNIT MBEDTLS_OID_AT "\x0B" /**< id-at-organizationalUnitName AttributeType:= {id-at 11} */ +#define MBEDTLS_OID_AT_TITLE MBEDTLS_OID_AT "\x0C" /**< id-at-title AttributeType:= {id-at 12} */ +#define MBEDTLS_OID_AT_POSTAL_ADDRESS MBEDTLS_OID_AT "\x10" /**< id-at-postalAddress AttributeType:= {id-at 16} */ +#define MBEDTLS_OID_AT_POSTAL_CODE MBEDTLS_OID_AT "\x11" /**< id-at-postalCode AttributeType:= {id-at 17} */ +#define MBEDTLS_OID_AT_GIVEN_NAME MBEDTLS_OID_AT "\x2A" /**< id-at-givenName AttributeType:= {id-at 42} */ +#define MBEDTLS_OID_AT_INITIALS MBEDTLS_OID_AT "\x2B" /**< id-at-initials AttributeType:= {id-at 43} */ +#define MBEDTLS_OID_AT_GENERATION_QUALIFIER MBEDTLS_OID_AT "\x2C" /**< id-at-generationQualifier AttributeType:= {id-at 44} */ +#define MBEDTLS_OID_AT_UNIQUE_IDENTIFIER MBEDTLS_OID_AT "\x2D" /**< id-at-uniqueIdentifier AttributType:= {id-at 45} */ +#define MBEDTLS_OID_AT_DN_QUALIFIER MBEDTLS_OID_AT "\x2E" /**< id-at-dnQualifier AttributeType:= {id-at 46} */ +#define MBEDTLS_OID_AT_PSEUDONYM MBEDTLS_OID_AT "\x41" /**< id-at-pseudonym AttributeType:= {id-at 65} */ + +#define MBEDTLS_OID_DOMAIN_COMPONENT "\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x19" /** id-domainComponent AttributeType:= {itu-t(0) data(9) pss(2342) ucl(19200300) pilot(100) pilotAttributeType(1) domainComponent(25)} */ + +/* + * OIDs for standard certificate extensions + */ +#define MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER MBEDTLS_OID_ID_CE "\x23" /**< id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } */ +#define MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER MBEDTLS_OID_ID_CE "\x0E" /**< id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } */ +#define MBEDTLS_OID_KEY_USAGE MBEDTLS_OID_ID_CE "\x0F" /**< id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } */ +#define MBEDTLS_OID_CERTIFICATE_POLICIES MBEDTLS_OID_ID_CE "\x20" /**< id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } */ +#define MBEDTLS_OID_POLICY_MAPPINGS MBEDTLS_OID_ID_CE "\x21" /**< id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } */ +#define MBEDTLS_OID_SUBJECT_ALT_NAME MBEDTLS_OID_ID_CE "\x11" /**< id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } */ +#define MBEDTLS_OID_ISSUER_ALT_NAME MBEDTLS_OID_ID_CE "\x12" /**< id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } */ +#define MBEDTLS_OID_SUBJECT_DIRECTORY_ATTRS MBEDTLS_OID_ID_CE "\x09" /**< id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } */ +#define MBEDTLS_OID_BASIC_CONSTRAINTS MBEDTLS_OID_ID_CE "\x13" /**< id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } */ +#define MBEDTLS_OID_NAME_CONSTRAINTS MBEDTLS_OID_ID_CE "\x1E" /**< id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } */ +#define MBEDTLS_OID_POLICY_CONSTRAINTS MBEDTLS_OID_ID_CE "\x24" /**< id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } */ +#define MBEDTLS_OID_EXTENDED_KEY_USAGE MBEDTLS_OID_ID_CE "\x25" /**< id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } */ +#define MBEDTLS_OID_CRL_DISTRIBUTION_POINTS MBEDTLS_OID_ID_CE "\x1F" /**< id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } */ +#define MBEDTLS_OID_INIHIBIT_ANYPOLICY MBEDTLS_OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */ +#define MBEDTLS_OID_FRESHEST_CRL MBEDTLS_OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */ + +/* + * Netscape certificate extensions + */ +#define MBEDTLS_OID_NS_CERT MBEDTLS_OID_NETSCAPE "\x01" +#define MBEDTLS_OID_NS_CERT_TYPE MBEDTLS_OID_NS_CERT "\x01" +#define MBEDTLS_OID_NS_BASE_URL MBEDTLS_OID_NS_CERT "\x02" +#define MBEDTLS_OID_NS_REVOCATION_URL MBEDTLS_OID_NS_CERT "\x03" +#define MBEDTLS_OID_NS_CA_REVOCATION_URL MBEDTLS_OID_NS_CERT "\x04" +#define MBEDTLS_OID_NS_RENEWAL_URL MBEDTLS_OID_NS_CERT "\x07" +#define MBEDTLS_OID_NS_CA_POLICY_URL MBEDTLS_OID_NS_CERT "\x08" +#define MBEDTLS_OID_NS_SSL_SERVER_NAME MBEDTLS_OID_NS_CERT "\x0C" +#define MBEDTLS_OID_NS_COMMENT MBEDTLS_OID_NS_CERT "\x0D" +#define MBEDTLS_OID_NS_DATA_TYPE MBEDTLS_OID_NETSCAPE "\x02" +#define MBEDTLS_OID_NS_CERT_SEQUENCE MBEDTLS_OID_NS_DATA_TYPE "\x05" + +/* + * OIDs for CRL extensions + */ +#define MBEDTLS_OID_PRIVATE_KEY_USAGE_PERIOD MBEDTLS_OID_ID_CE "\x10" +#define MBEDTLS_OID_CRL_NUMBER MBEDTLS_OID_ID_CE "\x14" /**< id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } */ + +/* + * X.509 v3 Extended key usage OIDs + */ +#define MBEDTLS_OID_ANY_EXTENDED_KEY_USAGE MBEDTLS_OID_EXTENDED_KEY_USAGE "\x00" /**< anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } */ + +#define MBEDTLS_OID_KP MBEDTLS_OID_PKIX "\x03" /**< id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } */ +#define MBEDTLS_OID_SERVER_AUTH MBEDTLS_OID_KP "\x01" /**< id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } */ +#define MBEDTLS_OID_CLIENT_AUTH MBEDTLS_OID_KP "\x02" /**< id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } */ +#define MBEDTLS_OID_CODE_SIGNING MBEDTLS_OID_KP "\x03" /**< id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } */ +#define MBEDTLS_OID_EMAIL_PROTECTION MBEDTLS_OID_KP "\x04" /**< id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } */ +#define MBEDTLS_OID_TIME_STAMPING MBEDTLS_OID_KP "\x08" /**< id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } */ +#define MBEDTLS_OID_OCSP_SIGNING MBEDTLS_OID_KP "\x09" /**< id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } */ + +/* + * PKCS definition OIDs + */ + +#define MBEDTLS_OID_PKCS MBEDTLS_OID_RSA_COMPANY "\x01" /**< pkcs OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) 1 } */ +#define MBEDTLS_OID_PKCS1 MBEDTLS_OID_PKCS "\x01" /**< pkcs-1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } */ +#define MBEDTLS_OID_PKCS5 MBEDTLS_OID_PKCS "\x05" /**< pkcs-5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 5 } */ +#define MBEDTLS_OID_PKCS9 MBEDTLS_OID_PKCS "\x09" /**< pkcs-9 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 9 } */ +#define MBEDTLS_OID_PKCS12 MBEDTLS_OID_PKCS "\x0c" /**< pkcs-12 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 12 } */ + +/* + * PKCS#1 OIDs + */ +#define MBEDTLS_OID_PKCS1_RSA MBEDTLS_OID_PKCS1 "\x01" /**< rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } */ +#define MBEDTLS_OID_PKCS1_MD2 MBEDTLS_OID_PKCS1 "\x02" /**< md2WithRSAEncryption ::= { pkcs-1 2 } */ +#define MBEDTLS_OID_PKCS1_MD4 MBEDTLS_OID_PKCS1 "\x03" /**< md4WithRSAEncryption ::= { pkcs-1 3 } */ +#define MBEDTLS_OID_PKCS1_MD5 MBEDTLS_OID_PKCS1 "\x04" /**< md5WithRSAEncryption ::= { pkcs-1 4 } */ +#define MBEDTLS_OID_PKCS1_SHA1 MBEDTLS_OID_PKCS1 "\x05" /**< sha1WithRSAEncryption ::= { pkcs-1 5 } */ +#define MBEDTLS_OID_PKCS1_SHA224 MBEDTLS_OID_PKCS1 "\x0e" /**< sha224WithRSAEncryption ::= { pkcs-1 14 } */ +#define MBEDTLS_OID_PKCS1_SHA256 MBEDTLS_OID_PKCS1 "\x0b" /**< sha256WithRSAEncryption ::= { pkcs-1 11 } */ +#define MBEDTLS_OID_PKCS1_SHA384 MBEDTLS_OID_PKCS1 "\x0c" /**< sha384WithRSAEncryption ::= { pkcs-1 12 } */ +#define MBEDTLS_OID_PKCS1_SHA512 MBEDTLS_OID_PKCS1 "\x0d" /**< sha512WithRSAEncryption ::= { pkcs-1 13 } */ + +#define MBEDTLS_OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D" + +#define MBEDTLS_OID_PKCS9_EMAIL MBEDTLS_OID_PKCS9 "\x01" /**< emailAddress AttributeType ::= { pkcs-9 1 } */ + +/* RFC 4055 */ +#define MBEDTLS_OID_RSASSA_PSS MBEDTLS_OID_PKCS1 "\x0a" /**< id-RSASSA-PSS ::= { pkcs-1 10 } */ +#define MBEDTLS_OID_MGF1 MBEDTLS_OID_PKCS1 "\x08" /**< id-mgf1 ::= { pkcs-1 8 } */ + +/* + * Digest algorithms + */ +#define MBEDTLS_OID_DIGEST_ALG_MD2 MBEDTLS_OID_RSA_COMPANY "\x02\x02" /**< id-mbedtls_md2 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 2 } */ +#define MBEDTLS_OID_DIGEST_ALG_MD4 MBEDTLS_OID_RSA_COMPANY "\x02\x04" /**< id-mbedtls_md4 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 4 } */ +#define MBEDTLS_OID_DIGEST_ALG_MD5 MBEDTLS_OID_RSA_COMPANY "\x02\x05" /**< id-mbedtls_md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA1 MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_OIW_SECSIG_SHA1 /**< id-mbedtls_sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 26 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA224 MBEDTLS_OID_GOV "\x03\x04\x02\x04" /**< id-sha224 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 4 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA256 MBEDTLS_OID_GOV "\x03\x04\x02\x01" /**< id-mbedtls_sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 1 } */ + +#define MBEDTLS_OID_DIGEST_ALG_SHA384 MBEDTLS_OID_GOV "\x03\x04\x02\x02" /**< id-sha384 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 2 } */ + +#define MBEDTLS_OID_DIGEST_ALG_SHA512 MBEDTLS_OID_GOV "\x03\x04\x02\x03" /**< id-mbedtls_sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 3 } */ + +#define MBEDTLS_OID_HMAC_SHA1 MBEDTLS_OID_RSA_COMPANY "\x02\x07" /**< id-hmacWithSHA1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 7 } */ + +/* + * Encryption algorithms + */ +#define MBEDTLS_OID_DES_CBC MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_OIW_SECSIG_ALG "\x07" /**< desCBC OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 7 } */ +#define MBEDTLS_OID_DES_EDE3_CBC MBEDTLS_OID_RSA_COMPANY "\x03\x07" /**< des-ede3-cbc OBJECT IDENTIFIER ::= { iso(1) member-body(2) -- us(840) rsadsi(113549) encryptionAlgorithm(3) 7 } */ + +/* + * PKCS#5 OIDs + */ +#define MBEDTLS_OID_PKCS5_PBKDF2 MBEDTLS_OID_PKCS5 "\x0c" /**< id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12} */ +#define MBEDTLS_OID_PKCS5_PBES2 MBEDTLS_OID_PKCS5 "\x0d" /**< id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13} */ +#define MBEDTLS_OID_PKCS5_PBMAC1 MBEDTLS_OID_PKCS5 "\x0e" /**< id-PBMAC1 OBJECT IDENTIFIER ::= {pkcs-5 14} */ + +/* + * PKCS#5 PBES1 algorithms + */ +#define MBEDTLS_OID_PKCS5_PBE_MD2_DES_CBC MBEDTLS_OID_PKCS5 "\x01" /**< pbeWithMD2AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 1} */ +#define MBEDTLS_OID_PKCS5_PBE_MD2_RC2_CBC MBEDTLS_OID_PKCS5 "\x04" /**< pbeWithMD2AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 4} */ +#define MBEDTLS_OID_PKCS5_PBE_MD5_DES_CBC MBEDTLS_OID_PKCS5 "\x03" /**< pbeWithMD5AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 3} */ +#define MBEDTLS_OID_PKCS5_PBE_MD5_RC2_CBC MBEDTLS_OID_PKCS5 "\x06" /**< pbeWithMD5AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 6} */ +#define MBEDTLS_OID_PKCS5_PBE_SHA1_DES_CBC MBEDTLS_OID_PKCS5 "\x0a" /**< pbeWithSHA1AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 10} */ +#define MBEDTLS_OID_PKCS5_PBE_SHA1_RC2_CBC MBEDTLS_OID_PKCS5 "\x0b" /**< pbeWithSHA1AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 11} */ + +/* + * PKCS#8 OIDs + */ +#define MBEDTLS_OID_PKCS9_CSR_EXT_REQ MBEDTLS_OID_PKCS9 "\x0e" /**< extensionRequest OBJECT IDENTIFIER ::= {pkcs-9 14} */ + +/* + * PKCS#12 PBE OIDs + */ +#define MBEDTLS_OID_PKCS12_PBE MBEDTLS_OID_PKCS12 "\x01" /**< pkcs-12PbeIds OBJECT IDENTIFIER ::= {pkcs-12 1} */ + +#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_128 MBEDTLS_OID_PKCS12_PBE "\x01" /**< pbeWithSHAAnd128BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 1} */ +#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_40 MBEDTLS_OID_PKCS12_PBE "\x02" /**< pbeWithSHAAnd40BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 2} */ +#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC MBEDTLS_OID_PKCS12_PBE "\x03" /**< pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} */ +#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC MBEDTLS_OID_PKCS12_PBE "\x04" /**< pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4} */ +#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_128_CBC MBEDTLS_OID_PKCS12_PBE "\x05" /**< pbeWithSHAAnd128BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 5} */ +#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_40_CBC MBEDTLS_OID_PKCS12_PBE "\x06" /**< pbeWithSHAAnd40BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 6} */ + +/* + * EC key algorithms from RFC 5480 + */ + +/* id-ecPublicKey OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 } */ +#define MBEDTLS_OID_EC_ALG_UNRESTRICTED MBEDTLS_OID_ANSI_X9_62 "\x02\01" + +/* id-ecDH OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) + * schemes(1) ecdh(12) } */ +#define MBEDTLS_OID_EC_ALG_ECDH MBEDTLS_OID_CERTICOM "\x01\x0c" + +/* + * ECParameters namedCurve identifiers, from RFC 5480, RFC 5639, and SEC2 + */ + +/* secp192r1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 1 } */ +#define MBEDTLS_OID_EC_GRP_SECP192R1 MBEDTLS_OID_ANSI_X9_62 "\x03\x01\x01" + +/* secp224r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 33 } */ +#define MBEDTLS_OID_EC_GRP_SECP224R1 MBEDTLS_OID_CERTICOM "\x00\x21" + +/* secp256r1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 7 } */ +#define MBEDTLS_OID_EC_GRP_SECP256R1 MBEDTLS_OID_ANSI_X9_62 "\x03\x01\x07" + +/* secp384r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 34 } */ +#define MBEDTLS_OID_EC_GRP_SECP384R1 MBEDTLS_OID_CERTICOM "\x00\x22" + +/* secp521r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 35 } */ +#define MBEDTLS_OID_EC_GRP_SECP521R1 MBEDTLS_OID_CERTICOM "\x00\x23" + +/* secp192k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 31 } */ +#define MBEDTLS_OID_EC_GRP_SECP192K1 MBEDTLS_OID_CERTICOM "\x00\x1f" + +/* secp224k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 32 } */ +#define MBEDTLS_OID_EC_GRP_SECP224K1 MBEDTLS_OID_CERTICOM "\x00\x20" + +/* secp256k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 10 } */ +#define MBEDTLS_OID_EC_GRP_SECP256K1 MBEDTLS_OID_CERTICOM "\x00\x0a" + +/* RFC 5639 4.1 + * ecStdCurvesAndGeneration OBJECT IDENTIFIER::= {iso(1) + * identified-organization(3) teletrust(36) algorithm(3) signature- + * algorithm(3) ecSign(2) 8} + * ellipticCurve OBJECT IDENTIFIER ::= {ecStdCurvesAndGeneration 1} + * versionOne OBJECT IDENTIFIER ::= {ellipticCurve 1} */ +#define MBEDTLS_OID_EC_BRAINPOOL_V1 MBEDTLS_OID_TELETRUST "\x03\x03\x02\x08\x01\x01" + +/* brainpoolP256r1 OBJECT IDENTIFIER ::= {versionOne 7} */ +#define MBEDTLS_OID_EC_GRP_BP256R1 MBEDTLS_OID_EC_BRAINPOOL_V1 "\x07" + +/* brainpoolP384r1 OBJECT IDENTIFIER ::= {versionOne 11} */ +#define MBEDTLS_OID_EC_GRP_BP384R1 MBEDTLS_OID_EC_BRAINPOOL_V1 "\x0B" + +/* brainpoolP512r1 OBJECT IDENTIFIER ::= {versionOne 13} */ +#define MBEDTLS_OID_EC_GRP_BP512R1 MBEDTLS_OID_EC_BRAINPOOL_V1 "\x0D" + +/* + * SEC1 C.1 + * + * prime-field OBJECT IDENTIFIER ::= { id-fieldType 1 } + * id-fieldType OBJECT IDENTIFIER ::= { ansi-X9-62 fieldType(1)} + */ +#define MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE MBEDTLS_OID_ANSI_X9_62 "\x01" +#define MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE "\x01" + +/* + * ECDSA signature identifiers, from RFC 5480 + */ +#define MBEDTLS_OID_ANSI_X9_62_SIG MBEDTLS_OID_ANSI_X9_62 "\x04" /* signatures(4) */ +#define MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 MBEDTLS_OID_ANSI_X9_62_SIG "\x03" /* ecdsa-with-SHA2(3) */ + +/* ecdsa-with-SHA1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) 1 } */ +#define MBEDTLS_OID_ECDSA_SHA1 MBEDTLS_OID_ANSI_X9_62_SIG "\x01" + +/* ecdsa-with-SHA224 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 1 } */ +#define MBEDTLS_OID_ECDSA_SHA224 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x01" + +/* ecdsa-with-SHA256 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 2 } */ +#define MBEDTLS_OID_ECDSA_SHA256 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x02" + +/* ecdsa-with-SHA384 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 3 } */ +#define MBEDTLS_OID_ECDSA_SHA384 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x03" + +/* ecdsa-with-SHA512 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 4 } */ +#define MBEDTLS_OID_ECDSA_SHA512 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x04" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Base OID descriptor structure + */ +typedef struct { + const char *asn1; /*!< OID ASN.1 representation */ + size_t asn1_len; /*!< length of asn1 */ + const char *name; /*!< official name (e.g. from RFC) */ + const char *description; /*!< human friendly description */ +} mbedtls_oid_descriptor_t; + +/** + * \brief Translate an ASN.1 OID into its numeric representation + * (e.g. "\x2A\x86\x48\x86\xF7\x0D" into "1.2.840.113549") + * + * \param buf buffer to put representation in + * \param size size of the buffer + * \param oid OID to translate + * + * \return Length of the string written (excluding final NULL) or + * MBEDTLS_ERR_OID_BUF_TOO_SMALL in case of error + */ +int mbedtls_oid_get_numeric_string( char *buf, size_t size, const mbedtls_asn1_buf *oid ); + +#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) +/** + * \brief Translate an X.509 extension OID into local values + * + * \param oid OID to use + * \param ext_type place to store the extension type + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_x509_ext_type( const mbedtls_asn1_buf *oid, int *ext_type ); +#endif + +/** + * \brief Translate an X.509 attribute type OID into the short name + * (e.g. the OID for an X520 Common Name into "CN") + * + * \param oid OID to use + * \param short_name place to store the string pointer + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_attr_short_name( const mbedtls_asn1_buf *oid, const char **short_name ); + +/** + * \brief Translate PublicKeyAlgorithm OID into pk_type + * + * \param oid OID to use + * \param pk_alg place to store public key algorithm + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_pk_alg( const mbedtls_asn1_buf *oid, mbedtls_pk_type_t *pk_alg ); + +/** + * \brief Translate pk_type into PublicKeyAlgorithm OID + * + * \param pk_alg Public key type to look for + * \param oid place to store ASN.1 OID string pointer + * \param olen length of the OID + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_oid_by_pk_alg( mbedtls_pk_type_t pk_alg, + const char **oid, size_t *olen ); + +#if defined(MBEDTLS_ECP_C) +/** + * \brief Translate NamedCurve OID into an EC group identifier + * + * \param oid OID to use + * \param grp_id place to store group id + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_ec_grp( const mbedtls_asn1_buf *oid, mbedtls_ecp_group_id *grp_id ); + +/** + * \brief Translate EC group identifier into NamedCurve OID + * + * \param grp_id EC group identifier + * \param oid place to store ASN.1 OID string pointer + * \param olen length of the OID + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_oid_by_ec_grp( mbedtls_ecp_group_id grp_id, + const char **oid, size_t *olen ); +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_MD_C) +/** + * \brief Translate SignatureAlgorithm OID into md_type and pk_type + * + * \param oid OID to use + * \param md_alg place to store message digest algorithm + * \param pk_alg place to store public key algorithm + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_sig_alg( const mbedtls_asn1_buf *oid, + mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg ); + +/** + * \brief Translate SignatureAlgorithm OID into description + * + * \param oid OID to use + * \param desc place to store string pointer + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_sig_alg_desc( const mbedtls_asn1_buf *oid, const char **desc ); + +/** + * \brief Translate md_type and pk_type into SignatureAlgorithm OID + * + * \param md_alg message digest algorithm + * \param pk_alg public key algorithm + * \param oid place to store ASN.1 OID string pointer + * \param olen length of the OID + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_oid_by_sig_alg( mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, + const char **oid, size_t *olen ); + +/** + * \brief Translate hash algorithm OID into md_type + * + * \param oid OID to use + * \param md_alg place to store message digest algorithm + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_md_alg( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg ); +#endif /* MBEDTLS_MD_C */ + +/** + * \brief Translate Extended Key Usage OID into description + * + * \param oid OID to use + * \param desc place to store string pointer + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_extended_key_usage( const mbedtls_asn1_buf *oid, const char **desc ); + +/** + * \brief Translate md_type into hash algorithm OID + * + * \param md_alg message digest algorithm + * \param oid place to store ASN.1 OID string pointer + * \param olen length of the OID + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_oid_by_md( mbedtls_md_type_t md_alg, const char **oid, size_t *olen ); + +#if defined(MBEDTLS_CIPHER_C) +/** + * \brief Translate encryption algorithm OID into cipher_type + * + * \param oid OID to use + * \param cipher_alg place to store cipher algorithm + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_cipher_alg( const mbedtls_asn1_buf *oid, mbedtls_cipher_type_t *cipher_alg ); +#endif /* MBEDTLS_CIPHER_C */ + +#if defined(MBEDTLS_PKCS12_C) +/** + * \brief Translate PKCS#12 PBE algorithm OID into md_type and + * cipher_type + * + * \param oid OID to use + * \param md_alg place to store message digest algorithm + * \param cipher_alg place to store cipher algorithm + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_pkcs12_pbe_alg( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg, + mbedtls_cipher_type_t *cipher_alg ); +#endif /* MBEDTLS_PKCS12_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* oid.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/padlock.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/padlock.h new file mode 100644 index 0000000..2045a5a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/padlock.h @@ -0,0 +1,107 @@ +/** + * \file padlock.h + * + * \brief VIA PadLock ACE for HW encryption/decryption supported by some + * processors + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PADLOCK_H +#define MBEDTLS_PADLOCK_H + +#include "aes.h" + +#define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */ + +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define MBEDTLS_HAVE_ASAN +#endif +#endif + +/* Some versions of ASan result in errors about not enough registers */ +#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) && \ + !defined(MBEDTLS_HAVE_ASAN) + +#ifndef MBEDTLS_HAVE_X86 +#define MBEDTLS_HAVE_X86 +#endif + +#include + +#define MBEDTLS_PADLOCK_RNG 0x000C +#define MBEDTLS_PADLOCK_ACE 0x00C0 +#define MBEDTLS_PADLOCK_PHE 0x0C00 +#define MBEDTLS_PADLOCK_PMM 0x3000 + +#define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) x & ~15)) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief PadLock detection routine + * + * \param feature The feature to detect + * + * \return 1 if CPU has support for the feature, 0 otherwise + */ +int mbedtls_padlock_has_support( int feature ); + +/** + * \brief PadLock AES-ECB block en(de)cryption + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param input 16-byte input block + * \param output 16-byte output block + * + * \return 0 if success, 1 if operation failed + */ +int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ); + +/** + * \brief PadLock AES-CBC buffer en(de)cryption + * + * \param ctx AES context + * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT + * \param length length of the input data + * \param iv initialization vector (updated after use) + * \param input buffer holding the input data + * \param output buffer holding the output data + * + * \return 0 if success, 1 if operation failed + */ +int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); + +#ifdef __cplusplus +} +#endif + +#endif /* HAVE_X86 */ + +#endif /* padlock.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pem.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pem.h new file mode 100644 index 0000000..54dc02d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pem.h @@ -0,0 +1,129 @@ +/** + * \file pem.h + * + * \brief Privacy Enhanced Mail (PEM) decoding + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PEM_H +#define MBEDTLS_PEM_H + +#include + +/** + * \name PEM Error codes + * These error codes are returned in case of errors reading the + * PEM data. + * \{ + */ +#define MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT -0x1080 /**< No PEM header or footer found. */ +#define MBEDTLS_ERR_PEM_INVALID_DATA -0x1100 /**< PEM string is not as expected. */ +#define MBEDTLS_ERR_PEM_ALLOC_FAILED -0x1180 /**< Failed to allocate memory. */ +#define MBEDTLS_ERR_PEM_INVALID_ENC_IV -0x1200 /**< RSA IV is not in hex-format. */ +#define MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG -0x1280 /**< Unsupported key encryption algorithm. */ +#define MBEDTLS_ERR_PEM_PASSWORD_REQUIRED -0x1300 /**< Private key password can't be empty. */ +#define MBEDTLS_ERR_PEM_PASSWORD_MISMATCH -0x1380 /**< Given private key password does not allow for correct decryption. */ +#define MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE -0x1400 /**< Unavailable feature, e.g. hashing/encryption combination. */ +#define MBEDTLS_ERR_PEM_BAD_INPUT_DATA -0x1480 /**< Bad input parameters to function. */ +/* \} name */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) +/** + * \brief PEM context structure + */ +typedef struct +{ + unsigned char *buf; /*!< buffer for decoded data */ + size_t buflen; /*!< length of the buffer */ + unsigned char *info; /*!< buffer for extra header information */ +} +mbedtls_pem_context; + +/** + * \brief PEM context setup + * + * \param ctx context to be initialized + */ +void mbedtls_pem_init( mbedtls_pem_context *ctx ); + +/** + * \brief Read a buffer for PEM information and store the resulting + * data into the specified context buffers. + * + * \param ctx context to use + * \param header header string to seek and expect + * \param footer footer string to seek and expect + * \param data source data to look in (must be nul-terminated) + * \param pwd password for decryption (can be NULL) + * \param pwdlen length of password + * \param use_len destination for total length used (set after header is + * correctly read, so unless you get + * MBEDTLS_ERR_PEM_BAD_INPUT_DATA or + * MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT, use_len is + * the length to skip) + * + * \note Attempts to check password correctness by verifying if + * the decrypted text starts with an ASN.1 sequence of + * appropriate length + * + * \return 0 on success, or a specific PEM error code + */ +int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const char *footer, + const unsigned char *data, + const unsigned char *pwd, + size_t pwdlen, size_t *use_len ); + +/** + * \brief PEM context memory freeing + * + * \param ctx context to be freed + */ +void mbedtls_pem_free( mbedtls_pem_context *ctx ); +#endif /* MBEDTLS_PEM_PARSE_C */ + +#if defined(MBEDTLS_PEM_WRITE_C) +/** + * \brief Write a buffer of PEM information from a DER encoded + * buffer. + * + * \param header header string to write + * \param footer footer string to write + * \param der_data DER data to write + * \param der_len length of the DER data + * \param buf buffer to write to + * \param buf_len length of output buffer + * \param olen total length written / required (if buf_len is not enough) + * + * \return 0 on success, or a specific PEM or BASE64 error code. On + * MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL olen is the required + * size. + */ +int mbedtls_pem_write_buffer( const char *header, const char *footer, + const unsigned char *der_data, size_t der_len, + unsigned char *buf, size_t buf_len, size_t *olen ); +#endif /* MBEDTLS_PEM_WRITE_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* pem.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk.h new file mode 100644 index 0000000..f9f9b9b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk.h @@ -0,0 +1,616 @@ +/** + * \file pk.h + * + * \brief Public Key abstraction layer + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_PK_H +#define MBEDTLS_PK_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "md.h" + +#if defined(MBEDTLS_RSA_C) +#include "rsa.h" +#endif + +#if defined(MBEDTLS_ECP_C) +#include "ecp.h" +#endif + +#if defined(MBEDTLS_ECDSA_C) +#include "ecdsa.h" +#endif + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +#define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80 /**< Memory allocation failed. */ +#define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00 /**< Type mismatch, eg attempt to encrypt with an ECDSA key */ +#define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_PK_FILE_IO_ERROR -0x3E00 /**< Read/write of file failed. */ +#define MBEDTLS_ERR_PK_KEY_INVALID_VERSION -0x3D80 /**< Unsupported key version */ +#define MBEDTLS_ERR_PK_KEY_INVALID_FORMAT -0x3D00 /**< Invalid key tag or value. */ +#define MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -0x3C80 /**< Key algorithm is unsupported (only RSA and EC are supported). */ +#define MBEDTLS_ERR_PK_PASSWORD_REQUIRED -0x3C00 /**< Private key password can't be empty. */ +#define MBEDTLS_ERR_PK_PASSWORD_MISMATCH -0x3B80 /**< Given private key password does not allow for correct decryption. */ +#define MBEDTLS_ERR_PK_INVALID_PUBKEY -0x3B00 /**< The pubkey tag or value is invalid (only RSA and EC are supported). */ +#define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80 /**< The algorithm tag or value is invalid. */ +#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */ +#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */ +#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The signature is valid but its length is less than expected. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Public key types + */ +typedef enum { + MBEDTLS_PK_NONE=0, + MBEDTLS_PK_RSA, + MBEDTLS_PK_ECKEY, + MBEDTLS_PK_ECKEY_DH, + MBEDTLS_PK_ECDSA, + MBEDTLS_PK_RSA_ALT, + MBEDTLS_PK_RSASSA_PSS, +} mbedtls_pk_type_t; + +/** + * \brief Options for RSASSA-PSS signature verification. + * See \c mbedtls_rsa_rsassa_pss_verify_ext() + */ +typedef struct +{ + mbedtls_md_type_t mgf1_hash_id; + int expected_salt_len; + +} mbedtls_pk_rsassa_pss_options; + +/** + * \brief Types for interfacing with the debug module + */ +typedef enum +{ + MBEDTLS_PK_DEBUG_NONE = 0, + MBEDTLS_PK_DEBUG_MPI, + MBEDTLS_PK_DEBUG_ECP, +} mbedtls_pk_debug_type; + +/** + * \brief Item to send to the debug module + */ +typedef struct +{ + mbedtls_pk_debug_type type; + const char *name; + void *value; +} mbedtls_pk_debug_item; + +/** Maximum number of item send for debugging, plus 1 */ +#define MBEDTLS_PK_DEBUG_MAX_ITEMS 3 + +/** + * \brief Public key information and operations + */ +typedef struct mbedtls_pk_info_t mbedtls_pk_info_t; + +/** + * \brief Public key container + */ +typedef struct +{ + const mbedtls_pk_info_t * pk_info; /**< Public key informations */ + void * pk_ctx; /**< Underlying public key context */ +} mbedtls_pk_context; + +#if defined(MBEDTLS_RSA_C) +/** + * Quick access to an RSA context inside a PK context. + * + * \warning You must make sure the PK context actually holds an RSA context + * before using this function! + */ +static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk ) +{ + return( (mbedtls_rsa_context *) (pk).pk_ctx ); +} +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) +/** + * Quick access to an EC context inside a PK context. + * + * \warning You must make sure the PK context actually holds an EC context + * before using this function! + */ +static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk ) +{ + return( (mbedtls_ecp_keypair *) (pk).pk_ctx ); +} +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +/** + * \brief Types for RSA-alt abstraction + */ +typedef int (*mbedtls_pk_rsa_alt_decrypt_func)( void *ctx, int mode, size_t *olen, + const unsigned char *input, unsigned char *output, + size_t output_max_len ); +typedef int (*mbedtls_pk_rsa_alt_sign_func)( void *ctx, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, + const unsigned char *hash, unsigned char *sig ); +typedef size_t (*mbedtls_pk_rsa_alt_key_len_func)( void *ctx ); +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ + +/** + * \brief Return information associated with the given PK type + * + * \param pk_type PK type to search for. + * + * \return The PK info associated with the type or NULL if not found. + */ +const mbedtls_pk_info_t *mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type ); + +/** + * \brief Initialize a mbedtls_pk_context (as NONE) + */ +void mbedtls_pk_init( mbedtls_pk_context *ctx ); + +/** + * \brief Free a mbedtls_pk_context + */ +void mbedtls_pk_free( mbedtls_pk_context *ctx ); + +/** + * \brief Initialize a PK context with the information given + * and allocates the type-specific PK subcontext. + * + * \param ctx Context to initialize. Must be empty (type NONE). + * \param info Information to use + * + * \return 0 on success, + * MBEDTLS_ERR_PK_BAD_INPUT_DATA on invalid input, + * MBEDTLS_ERR_PK_ALLOC_FAILED on allocation failure. + * + * \note For contexts holding an RSA-alt key, use + * \c mbedtls_pk_setup_rsa_alt() instead. + */ +int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ); + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +/** + * \brief Initialize an RSA-alt context + * + * \param ctx Context to initialize. Must be empty (type NONE). + * \param key RSA key pointer + * \param decrypt_func Decryption function + * \param sign_func Signing function + * \param key_len_func Function returning key length in bytes + * + * \return 0 on success, or MBEDTLS_ERR_PK_BAD_INPUT_DATA if the + * context wasn't already initialized as RSA_ALT. + * + * \note This function replaces \c mbedtls_pk_setup() for RSA-alt. + */ +int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, + mbedtls_pk_rsa_alt_decrypt_func decrypt_func, + mbedtls_pk_rsa_alt_sign_func sign_func, + mbedtls_pk_rsa_alt_key_len_func key_len_func ); +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ + +/** + * \brief Get the size in bits of the underlying key + * + * \param ctx Context to use + * + * \return Key size in bits, or 0 on error + */ +size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ); + +/** + * \brief Get the length in bytes of the underlying key + * \param ctx Context to use + * + * \return Key length in bytes, or 0 on error + */ +static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx ) +{ + return( ( mbedtls_pk_get_bitlen( ctx ) + 7 ) / 8 ); +} + +/** + * \brief Tell if a context can do the operation given by type + * + * \param ctx Context to test + * \param type Target type + * + * \return 0 if context can't do the operations, + * 1 otherwise. + */ +int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ); + +/** + * \brief Verify signature (including padding if relevant). + * + * \param ctx PK context to use + * \param md_alg Hash algorithm used (see notes) + * \param hash Hash of the message to sign + * \param hash_len Hash length or 0 (see notes) + * \param sig Signature to verify + * \param sig_len Signature length + * + * \return 0 on success (signature is valid), + * MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if the signature is + * valid but its actual length is less than sig_len, + * or a specific error code. + * + * \note For RSA keys, the default padding type is PKCS#1 v1.5. + * Use \c mbedtls_pk_verify_ext( MBEDTLS_PK_RSASSA_PSS, ... ) + * to verify RSASSA_PSS signatures. + * + * \note If hash_len is 0, then the length associated with md_alg + * is used instead, or an error returned if it is invalid. + * + * \note md_alg may be MBEDTLS_MD_NONE, only if hash_len != 0 + */ +int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ); + +/** + * \brief Verify signature, with options. + * (Includes verification of the padding depending on type.) + * + * \param type Signature type (inc. possible padding type) to verify + * \param options Pointer to type-specific options, or NULL + * \param ctx PK context to use + * \param md_alg Hash algorithm used (see notes) + * \param hash Hash of the message to sign + * \param hash_len Hash length or 0 (see notes) + * \param sig Signature to verify + * \param sig_len Signature length + * + * \return 0 on success (signature is valid), + * MBEDTLS_ERR_PK_TYPE_MISMATCH if the PK context can't be + * used for this type of signatures, + * MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if the signature is + * valid but its actual length is less than sig_len, + * or a specific error code. + * + * \note If hash_len is 0, then the length associated with md_alg + * is used instead, or an error returned if it is invalid. + * + * \note md_alg may be MBEDTLS_MD_NONE, only if hash_len != 0 + * + * \note If type is MBEDTLS_PK_RSASSA_PSS, then options must point + * to a mbedtls_pk_rsassa_pss_options structure, + * otherwise it must be NULL. + */ +int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options, + mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ); + +/** + * \brief Make signature, including padding if relevant. + * + * \param ctx PK context to use - must hold a private key + * \param md_alg Hash algorithm used (see notes) + * \param hash Hash of the message to sign + * \param hash_len Hash length or 0 (see notes) + * \param sig Place to write the signature + * \param sig_len Number of bytes written + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \return 0 on success, or a specific error code. + * + * \note For RSA keys, the default padding type is PKCS#1 v1.5. + * There is no interface in the PK module to make RSASSA-PSS + * signatures yet. + * + * \note If hash_len is 0, then the length associated with md_alg + * is used instead, or an error returned if it is invalid. + * + * \note For RSA, md_alg may be MBEDTLS_MD_NONE if hash_len != 0. + * For ECDSA, md_alg may never be MBEDTLS_MD_NONE. + */ +int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +/** + * \brief Decrypt message (including padding if relevant). + * + * \param ctx PK context to use - must hold a private key + * \param input Input to decrypt + * \param ilen Input size + * \param output Decrypted output + * \param olen Decrypted message length + * \param osize Size of the output buffer + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \note For RSA keys, the default padding type is PKCS#1 v1.5. + * + * \return 0 on success, or a specific error code. + */ +int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +/** + * \brief Encrypt message (including padding if relevant). + * + * \param ctx PK context to use + * \param input Message to encrypt + * \param ilen Message size + * \param output Encrypted output + * \param olen Encrypted output length + * \param osize Size of the output buffer + * \param f_rng RNG function + * \param p_rng RNG parameter + * + * \note For RSA keys, the default padding type is PKCS#1 v1.5. + * + * \return 0 on success, or a specific error code. + */ +int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +/** + * \brief Check if a public-private pair of keys matches. + * + * \param pub Context holding a public key. + * \param prv Context holding a private (and public) key. + * + * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA + */ +int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv ); + +/** + * \brief Export debug information + * + * \param ctx Context to use + * \param items Place to write debug items + * + * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA + */ +int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items ); + +/** + * \brief Access the type name + * + * \param ctx Context to use + * + * \return Type name on success, or "invalid PK" + */ +const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx ); + +/** + * \brief Get the key type + * + * \param ctx Context to use + * + * \return Type on success, or MBEDTLS_PK_NONE + */ +mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ); + +#if defined(MBEDTLS_PK_PARSE_C) +/** \ingroup pk_module */ +/** + * \brief Parse a private key in PEM or DER format + * + * \param ctx key to be initialized + * \param key input buffer + * \param keylen size of the buffer + * (including the terminating null byte for PEM data) + * \param pwd password for decryption (optional) + * \param pwdlen size of the password + * + * \note On entry, ctx must be empty, either freshly initialised + * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a + * specific key type, check the result with mbedtls_pk_can_do(). + * + * \note The key is also checked for correctness. + * + * \return 0 if successful, or a specific PK or PEM error code + */ +int mbedtls_pk_parse_key( mbedtls_pk_context *ctx, + const unsigned char *key, size_t keylen, + const unsigned char *pwd, size_t pwdlen ); + +/** \ingroup pk_module */ +/** + * \brief Parse a public key in PEM or DER format + * + * \param ctx key to be initialized + * \param key input buffer + * \param keylen size of the buffer + * (including the terminating null byte for PEM data) + * + * \note On entry, ctx must be empty, either freshly initialised + * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a + * specific key type, check the result with mbedtls_pk_can_do(). + * + * \note The key is also checked for correctness. + * + * \return 0 if successful, or a specific PK or PEM error code + */ +int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx, + const unsigned char *key, size_t keylen ); + +#if defined(MBEDTLS_FS_IO) +/** \ingroup pk_module */ +/** + * \brief Load and parse a private key + * + * \param ctx key to be initialized + * \param path filename to read the private key from + * \param password password to decrypt the file (can be NULL) + * + * \note On entry, ctx must be empty, either freshly initialised + * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a + * specific key type, check the result with mbedtls_pk_can_do(). + * + * \note The key is also checked for correctness. + * + * \return 0 if successful, or a specific PK or PEM error code + */ +int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, + const char *path, const char *password ); + +/** \ingroup pk_module */ +/** + * \brief Load and parse a public key + * + * \param ctx key to be initialized + * \param path filename to read the public key from + * + * \note On entry, ctx must be empty, either freshly initialised + * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If + * you need a specific key type, check the result with + * mbedtls_pk_can_do(). + * + * \note The key is also checked for correctness. + * + * \return 0 if successful, or a specific PK or PEM error code + */ +int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ); +#endif /* MBEDTLS_FS_IO */ +#endif /* MBEDTLS_PK_PARSE_C */ + +#if defined(MBEDTLS_PK_WRITE_C) +/** + * \brief Write a private key to a PKCS#1 or SEC1 DER structure + * Note: data is written at the end of the buffer! Use the + * return value to determine where you should start + * using the buffer + * + * \param ctx private to write away + * \param buf buffer to write to + * \param size size of the buffer + * + * \return length of data written if successful, or a specific + * error code + */ +int mbedtls_pk_write_key_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); + +/** + * \brief Write a public key to a SubjectPublicKeyInfo DER structure + * Note: data is written at the end of the buffer! Use the + * return value to determine where you should start + * using the buffer + * + * \param ctx public key to write away + * \param buf buffer to write to + * \param size size of the buffer + * + * \return length of data written if successful, or a specific + * error code + */ +int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); + +#if defined(MBEDTLS_PEM_WRITE_C) +/** + * \brief Write a public key to a PEM string + * + * \param ctx public key to write away + * \param buf buffer to write to + * \param size size of the buffer + * + * \return 0 if successful, or a specific error code + */ +int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); + +/** + * \brief Write a private key to a PKCS#1 or SEC1 PEM string + * + * \param ctx private to write away + * \param buf buffer to write to + * \param size size of the buffer + * + * \return 0 if successful, or a specific error code + */ +int mbedtls_pk_write_key_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); +#endif /* MBEDTLS_PEM_WRITE_C */ +#endif /* MBEDTLS_PK_WRITE_C */ + +/* + * WARNING: Low-level functions. You probably do not want to use these unless + * you are certain you do ;) + */ + +#if defined(MBEDTLS_PK_PARSE_C) +/** + * \brief Parse a SubjectPublicKeyInfo DER structure + * + * \param p the position in the ASN.1 data + * \param end end of the buffer + * \param pk the key to fill + * + * \return 0 if successful, or a specific PK error code + */ +int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end, + mbedtls_pk_context *pk ); +#endif /* MBEDTLS_PK_PARSE_C */ + +#if defined(MBEDTLS_PK_WRITE_C) +/** + * \brief Write a subjectPublicKey to ASN.1 data + * Note: function works backwards in data buffer + * + * \param p reference to current position pointer + * \param start start of the buffer (for bounds-checking) + * \param key public key to write away + * + * \return the length written or a negative error code + */ +int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start, + const mbedtls_pk_context *key ); +#endif /* MBEDTLS_PK_WRITE_C */ + +/* + * Internal module functions. You probably do not want to use these unless you + * know you do. + */ +#if defined(MBEDTLS_FS_IO) +int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_PK_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk_internal.h new file mode 100644 index 0000000..01d0f21 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pk_internal.h @@ -0,0 +1,114 @@ +/** + * \file pk.h + * + * \brief Public Key abstraction layer: wrapper functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_PK_WRAP_H +#define MBEDTLS_PK_WRAP_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "pk.h" + +struct mbedtls_pk_info_t +{ + /** Public key type */ + mbedtls_pk_type_t type; + + /** Type name */ + const char *name; + + /** Get key size in bits */ + size_t (*get_bitlen)( const void * ); + + /** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */ + int (*can_do)( mbedtls_pk_type_t type ); + + /** Verify signature */ + int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ); + + /** Make signature */ + int (*sign_func)( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + + /** Decrypt message */ + int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + + /** Encrypt message */ + int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + + /** Check public-private key pair */ + int (*check_pair_func)( const void *pub, const void *prv ); + + /** Allocate a new context */ + void * (*ctx_alloc_func)( void ); + + /** Free the given context */ + void (*ctx_free_func)( void *ctx ); + + /** Interface with the debug module */ + void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items ); + +}; +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +/* Container for RSA-alt */ +typedef struct +{ + void *key; + mbedtls_pk_rsa_alt_decrypt_func decrypt_func; + mbedtls_pk_rsa_alt_sign_func sign_func; + mbedtls_pk_rsa_alt_key_len_func key_len_func; +} mbedtls_rsa_alt_context; +#endif + +#if defined(MBEDTLS_RSA_C) +extern const mbedtls_pk_info_t mbedtls_rsa_info; +#endif + +#if defined(MBEDTLS_ECP_C) +extern const mbedtls_pk_info_t mbedtls_eckey_info; +extern const mbedtls_pk_info_t mbedtls_eckeydh_info; +#endif + +#if defined(MBEDTLS_ECDSA_C) +extern const mbedtls_pk_info_t mbedtls_ecdsa_info; +#endif + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +extern const mbedtls_pk_info_t mbedtls_rsa_alt_info; +#endif + +#endif /* MBEDTLS_PK_WRAP_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs11.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs11.h new file mode 100644 index 0000000..2e88928 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs11.h @@ -0,0 +1,173 @@ +/** + * \file pkcs11.h + * + * \brief Wrapper for PKCS#11 library libpkcs11-helper + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PKCS11_H +#define MBEDTLS_PKCS11_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PKCS11_C) + +#include "x509_crt.h" + +#include + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Context for PKCS #11 private keys. + */ +typedef struct { + pkcs11h_certificate_t pkcs11h_cert; + int len; +} mbedtls_pkcs11_context; + +/** + * Initialize a mbedtls_pkcs11_context. + * (Just making memory references valid.) + */ +void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx ); + +/** + * Fill in a mbed TLS certificate, based on the given PKCS11 helper certificate. + * + * \param cert X.509 certificate to fill + * \param pkcs11h_cert PKCS #11 helper certificate + * + * \return 0 on success. + */ +int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert ); + +/** + * Set up a mbedtls_pkcs11_context storing the given certificate. Note that the + * mbedtls_pkcs11_context will take over control of the certificate, freeing it when + * done. + * + * \param priv_key Private key structure to fill. + * \param pkcs11_cert PKCS #11 helper certificate + * + * \return 0 on success + */ +int mbedtls_pkcs11_priv_key_bind( mbedtls_pkcs11_context *priv_key, + pkcs11h_certificate_t pkcs11_cert ); + +/** + * Free the contents of the given private key context. Note that the structure + * itself is not freed. + * + * \param priv_key Private key structure to cleanup + */ +void mbedtls_pkcs11_priv_key_free( mbedtls_pkcs11_context *priv_key ); + +/** + * \brief Do an RSA private key decrypt, then remove the message + * padding + * + * \param ctx PKCS #11 context + * \param mode must be MBEDTLS_RSA_PRIVATE, for compatibility with rsa.c's signature + * \param input buffer holding the encrypted data + * \param output buffer that will hold the plaintext + * \param olen will contain the plaintext length + * \param output_max_len maximum length of the output buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise + * an error is thrown. + */ +int mbedtls_pkcs11_decrypt( mbedtls_pkcs11_context *ctx, + int mode, size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len ); + +/** + * \brief Do a private RSA to sign a message digest + * + * \param ctx PKCS #11 context + * \param mode must be MBEDTLS_RSA_PRIVATE, for compatibility with rsa.c's signature + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer that will hold the ciphertext + * + * \return 0 if the signing operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_pkcs11_sign( mbedtls_pkcs11_context *ctx, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ); + +/** + * SSL/TLS wrappers for PKCS#11 functions + */ +static inline int mbedtls_ssl_pkcs11_decrypt( void *ctx, int mode, size_t *olen, + const unsigned char *input, unsigned char *output, + size_t output_max_len ) +{ + return mbedtls_pkcs11_decrypt( (mbedtls_pkcs11_context *) ctx, mode, olen, input, output, + output_max_len ); +} + +static inline int mbedtls_ssl_pkcs11_sign( void *ctx, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, + const unsigned char *hash, unsigned char *sig ) +{ + ((void) f_rng); + ((void) p_rng); + return mbedtls_pkcs11_sign( (mbedtls_pkcs11_context *) ctx, mode, md_alg, + hashlen, hash, sig ); +} + +static inline size_t mbedtls_ssl_pkcs11_key_len( void *ctx ) +{ + return ( (mbedtls_pkcs11_context *) ctx )->len; +} + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_PKCS11_C */ + +#endif /* MBEDTLS_PKCS11_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs12.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs12.h new file mode 100644 index 0000000..9b2d904 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs12.h @@ -0,0 +1,119 @@ +/** + * \file pkcs12.h + * + * \brief PKCS#12 Personal Information Exchange Syntax + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PKCS12_H +#define MBEDTLS_PKCS12_H + +#include "md.h" +#include "cipher.h" +#include "asn1.h" + +#include + +#define MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA -0x1F80 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE -0x1F00 /**< Feature not available, e.g. unsupported encryption scheme. */ +#define MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT -0x1E80 /**< PBE ASN.1 data not as expected. */ +#define MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH -0x1E00 /**< Given private key password does not allow for correct decryption. */ + +#define MBEDTLS_PKCS12_DERIVE_KEY 1 /**< encryption/decryption key */ +#define MBEDTLS_PKCS12_DERIVE_IV 2 /**< initialization vector */ +#define MBEDTLS_PKCS12_DERIVE_MAC_KEY 3 /**< integrity / MAC key */ + +#define MBEDTLS_PKCS12_PBE_DECRYPT 0 +#define MBEDTLS_PKCS12_PBE_ENCRYPT 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief PKCS12 Password Based function (encryption / decryption) + * for pbeWithSHAAnd128BitRC4 + * + * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure + * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT + * \param pwd the password used (may be NULL if no password is used) + * \param pwdlen length of the password (may be 0) + * \param input the input data + * \param len data length + * \param output the output buffer + * + * \return 0 if successful, or a MBEDTLS_ERR_XXX code + */ +int mbedtls_pkcs12_pbe_sha1_rc4_128( mbedtls_asn1_buf *pbe_params, int mode, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *input, size_t len, + unsigned char *output ); + +/** + * \brief PKCS12 Password Based function (encryption / decryption) + * for cipher-based and mbedtls_md-based PBE's + * + * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure + * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT + * \param cipher_type the cipher used + * \param md_type the mbedtls_md used + * \param pwd the password used (may be NULL if no password is used) + * \param pwdlen length of the password (may be 0) + * \param input the input data + * \param len data length + * \param output the output buffer + * + * \return 0 if successful, or a MBEDTLS_ERR_XXX code + */ +int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode, + mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *input, size_t len, + unsigned char *output ); + +/** + * \brief The PKCS#12 derivation function uses a password and a salt + * to produce pseudo-random bits for a particular "purpose". + * + * Depending on the given id, this function can produce an + * encryption/decryption key, an nitialization vector or an + * integrity key. + * + * \param data buffer to store the derived data in + * \param datalen length to fill + * \param pwd password to use (may be NULL if no password is used) + * \param pwdlen length of the password (may be 0) + * \param salt salt buffer to use + * \param saltlen length of the salt + * \param mbedtls_md mbedtls_md type to use during the derivation + * \param id id that describes the purpose (can be MBEDTLS_PKCS12_DERIVE_KEY, + * MBEDTLS_PKCS12_DERIVE_IV or MBEDTLS_PKCS12_DERIVE_MAC_KEY) + * \param iterations number of iterations + * + * \return 0 if successful, or a MD, BIGNUM type error. + */ +int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *salt, size_t saltlen, + mbedtls_md_type_t mbedtls_md, int id, int iterations ); + +#ifdef __cplusplus +} +#endif + +#endif /* pkcs12.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs5.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs5.h new file mode 100644 index 0000000..ec5cb9e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/pkcs5.h @@ -0,0 +1,94 @@ +/** + * \file pkcs5.h + * + * \brief PKCS#5 functions + * + * \author Mathias Olsson + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PKCS5_H +#define MBEDTLS_PKCS5_H + +#include "asn1.h" +#include "md.h" + +#include +#include + +#define MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA -0x2f80 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_PKCS5_INVALID_FORMAT -0x2f00 /**< Unexpected ASN.1 data. */ +#define MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE -0x2e80 /**< Requested encryption or digest alg not available. */ +#define MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH -0x2e00 /**< Given private key password does not allow for correct decryption. */ + +#define MBEDTLS_PKCS5_DECRYPT 0 +#define MBEDTLS_PKCS5_ENCRYPT 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief PKCS#5 PBES2 function + * + * \param pbe_params the ASN.1 algorithm parameters + * \param mode either MBEDTLS_PKCS5_DECRYPT or MBEDTLS_PKCS5_ENCRYPT + * \param pwd password to use when generating key + * \param pwdlen length of password + * \param data data to process + * \param datalen length of data + * \param output output buffer + * + * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails. + */ +int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *data, size_t datalen, + unsigned char *output ); + +/** + * \brief PKCS#5 PBKDF2 using HMAC + * + * \param ctx Generic HMAC context + * \param password Password to use when generating key + * \param plen Length of password + * \param salt Salt to use when generating key + * \param slen Length of salt + * \param iteration_count Iteration count + * \param key_length Length of generated key in bytes + * \param output Generated key. Must be at least as big as key_length + * + * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails. + */ +int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *password, + size_t plen, const unsigned char *salt, size_t slen, + unsigned int iteration_count, + uint32_t key_length, unsigned char *output ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_pkcs5_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* pkcs5.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform.h new file mode 100644 index 0000000..b1b019e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform.h @@ -0,0 +1,295 @@ +/** + * \file platform.h + * + * \brief mbed TLS Platform abstraction layer + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PLATFORM_H +#define MBEDTLS_PLATFORM_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) +#include +#include +#include +#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) +#if defined(_WIN32) +#define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< Default snprintf to use */ +#else +#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use */ +#endif +#endif +#if !defined(MBEDTLS_PLATFORM_STD_PRINTF) +#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF) +#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_CALLOC) +#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_FREE) +#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_EXIT) +#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_TIME) +#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) +#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) +#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< Default exit value to use */ +#endif +#if defined(MBEDTLS_FS_IO) +#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) +#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read +#endif +#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) +#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write +#endif +#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE) +#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" +#endif +#endif /* MBEDTLS_FS_IO */ +#else /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ +#if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) +#include MBEDTLS_PLATFORM_STD_MEM_HDR +#endif +#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ + + +/* \} name SECTION: Module settings */ + +/* + * The function pointers for calloc and free + */ +#if defined(MBEDTLS_PLATFORM_MEMORY) +#if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \ + defined(MBEDTLS_PLATFORM_CALLOC_MACRO) +#define mbedtls_free MBEDTLS_PLATFORM_FREE_MACRO +#define mbedtls_calloc MBEDTLS_PLATFORM_CALLOC_MACRO +#else +/* For size_t */ +#include +extern void * (*mbedtls_calloc)( size_t n, size_t size ); +extern void (*mbedtls_free)( void *ptr ); + +/** + * \brief Set your own memory implementation function pointers + * + * \param calloc_func the calloc function implementation + * \param free_func the free function implementation + * + * \return 0 if successful + */ +int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ), + void (*free_func)( void * ) ); +#endif /* MBEDTLS_PLATFORM_FREE_MACRO && MBEDTLS_PLATFORM_CALLOC_MACRO */ +#else /* !MBEDTLS_PLATFORM_MEMORY */ +#define mbedtls_free free +#define mbedtls_calloc calloc +#endif /* MBEDTLS_PLATFORM_MEMORY && !MBEDTLS_PLATFORM_{FREE,CALLOC}_MACRO */ + +/* + * The function pointers for fprintf + */ +#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) +/* We need FILE * */ +#include +extern int (*mbedtls_fprintf)( FILE *stream, const char *format, ... ); + +/** + * \brief Set your own fprintf function pointer + * + * \param fprintf_func the fprintf function implementation + * + * \return 0 + */ +int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *, + ... ) ); +#else +#if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) +#define mbedtls_fprintf MBEDTLS_PLATFORM_FPRINTF_MACRO +#else +#define mbedtls_fprintf fprintf +#endif /* MBEDTLS_PLATFORM_FPRINTF_MACRO */ +#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */ + +/* + * The function pointers for printf + */ +#if defined(MBEDTLS_PLATFORM_PRINTF_ALT) +extern int (*mbedtls_printf)( const char *format, ... ); + +/** + * \brief Set your own printf function pointer + * + * \param printf_func the printf function implementation + * + * \return 0 + */ +int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) ); +#else /* !MBEDTLS_PLATFORM_PRINTF_ALT */ +#if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) +#define mbedtls_printf MBEDTLS_PLATFORM_PRINTF_MACRO +#else +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_PRINTF_MACRO */ +#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */ + +/* + * The function pointers for snprintf + * + * The snprintf implementation should conform to C99: + * - it *must* always correctly zero-terminate the buffer + * (except when n == 0, then it must leave the buffer untouched) + * - however it is acceptable to return -1 instead of the required length when + * the destination buffer is too short. + */ +#if defined(_WIN32) +/* For Windows (inc. MSYS2), we provide our own fixed implementation */ +int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... ); +#endif + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) +extern int (*mbedtls_snprintf)( char * s, size_t n, const char * format, ... ); + +/** + * \brief Set your own snprintf function pointer + * + * \param snprintf_func the snprintf function implementation + * + * \return 0 + */ +int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n, + const char * format, ... ) ); +#else /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ +#if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) +#define mbedtls_snprintf MBEDTLS_PLATFORM_SNPRINTF_MACRO +#else +#define mbedtls_snprintf snprintf +#endif /* MBEDTLS_PLATFORM_SNPRINTF_MACRO */ +#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ + +/* + * The function pointers for exit + */ +#if defined(MBEDTLS_PLATFORM_EXIT_ALT) +extern void (*mbedtls_exit)( int status ); + +/** + * \brief Set your own exit function pointer + * + * \param exit_func the exit function implementation + * + * \return 0 + */ +int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); +#else +#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) +#define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO +#else +#define mbedtls_exit exit +#endif /* MBEDTLS_PLATFORM_EXIT_MACRO */ +#endif /* MBEDTLS_PLATFORM_EXIT_ALT */ + +/* + * The default exit values + */ +#if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) +#define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS +#else +#define MBEDTLS_EXIT_SUCCESS 0 +#endif +#if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) +#define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE +#else +#define MBEDTLS_EXIT_FAILURE 1 +#endif + +/* + * The function pointers for reading from and writing a seed file to + * Non-Volatile storage (NV) in a platform-independent way + * + * Only enabled when the NV seed entropy source is enabled + */ +#if defined(MBEDTLS_ENTROPY_NV_SEED) +#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) +/* Internal standard platform definitions */ +int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len ); +int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len ); +#endif + +#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) +extern int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ); +extern int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ); + +/** + * \brief Set your own seed file writing/reading functions + * + * \param nv_seed_read_func the seed reading function implementation + * \param nv_seed_write_func the seed writing function implementation + * + * \return 0 + */ +int mbedtls_platform_set_nv_seed( + int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ), + int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) + ); +#else +#if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \ + defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) +#define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO +#define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO +#else +#define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read +#define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write +#endif +#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ +#endif /* MBEDTLS_ENTROPY_NV_SEED */ + +#ifdef __cplusplus +} +#endif + +#endif /* platform.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform_time.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform_time.h new file mode 100644 index 0000000..abb3431 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/platform_time.h @@ -0,0 +1,81 @@ +/** + * \file platform_time.h + * + * \brief mbed TLS Platform time abstraction + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PLATFORM_TIME_H +#define MBEDTLS_PLATFORM_TIME_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +/* + * The time_t datatype + */ +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) +typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t; +#else +/* For time_t */ +#include +typedef time_t mbedtls_time_t; +#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */ + +/* + * The function pointers for time + */ +#if defined(MBEDTLS_PLATFORM_TIME_ALT) +extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time ); + +/** + * \brief Set your own time function pointer + * + * \param time_func the time function implementation + * + * \return 0 + */ +int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) ); +#else +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) +#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO +#else +#define mbedtls_time time +#endif /* MBEDTLS_PLATFORM_TIME_MACRO */ +#endif /* MBEDTLS_PLATFORM_TIME_ALT */ + +#ifdef __cplusplus +} +#endif + +#endif /* platform_time.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ripemd160.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ripemd160.h new file mode 100644 index 0000000..7083fc8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ripemd160.h @@ -0,0 +1,138 @@ +/** + * \file ripemd160.h + * + * \brief RIPE MD-160 message digest + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_RIPEMD160_H +#define MBEDTLS_RIPEMD160_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if !defined(MBEDTLS_RIPEMD160_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief RIPEMD-160 context structure + */ +typedef struct +{ + uint32_t total[2]; /*!< number of bytes processed */ + uint32_t state[5]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +mbedtls_ripemd160_context; + +/** + * \brief Initialize RIPEMD-160 context + * + * \param ctx RIPEMD-160 context to be initialized + */ +void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx ); + +/** + * \brief Clear RIPEMD-160 context + * + * \param ctx RIPEMD-160 context to be cleared + */ +void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx ); + +/** + * \brief Clone (the state of) an RIPEMD-160 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst, + const mbedtls_ripemd160_context *src ); + +/** + * \brief RIPEMD-160 context setup + * + * \param ctx context to be initialized + */ +void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx ); + +/** + * \brief RIPEMD-160 process buffer + * + * \param ctx RIPEMD-160 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx, + const unsigned char *input, size_t ilen ); + +/** + * \brief RIPEMD-160 final digest + * + * \param ctx RIPEMD-160 context + * \param output RIPEMD-160 checksum result + */ +void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] ); + +/* Internal use */ +void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_RIPEMD160_ALT */ +#include "ripemd160.h" +#endif /* MBEDTLS_RIPEMD160_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = RIPEMD-160( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output RIPEMD-160 checksum result + */ +void mbedtls_ripemd160( const unsigned char *input, size_t ilen, + unsigned char output[20] ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_ripemd160_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_ripemd160.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/rsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/rsa.h new file mode 100644 index 0000000..54653df --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/rsa.h @@ -0,0 +1,652 @@ +/** + * \file rsa.h + * + * \brief The RSA public-key cryptosystem + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_RSA_H +#define MBEDTLS_RSA_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "bignum.h" +#include "md.h" + +#if defined(MBEDTLS_THREADING_C) +#include "threading.h" +#endif + +/* + * RSA Error codes + */ +#define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */ +#define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */ +#define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the library's validity check. */ +#define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */ +#define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */ +#define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */ +#define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */ +#define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */ + +/* + * RSA constants + */ +#define MBEDTLS_RSA_PUBLIC 0 +#define MBEDTLS_RSA_PRIVATE 1 + +#define MBEDTLS_RSA_PKCS_V15 0 +#define MBEDTLS_RSA_PKCS_V21 1 + +#define MBEDTLS_RSA_SIGN 1 +#define MBEDTLS_RSA_CRYPT 2 + +#define MBEDTLS_RSA_SALT_LEN_ANY -1 + +/* + * The above constants may be used even if the RSA module is compile out, + * eg for alternative (PKCS#11) RSA implemenations in the PK layers. + */ +#if defined(MBEDTLS_RSA_C) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief RSA context structure + */ +typedef struct +{ + int ver; /*!< always 0 */ + size_t len; /*!< size(N) in chars */ + + mbedtls_mpi N; /*!< public modulus */ + mbedtls_mpi E; /*!< public exponent */ + + mbedtls_mpi D; /*!< private exponent */ + mbedtls_mpi P; /*!< 1st prime factor */ + mbedtls_mpi Q; /*!< 2nd prime factor */ + mbedtls_mpi DP; /*!< D % (P - 1) */ + mbedtls_mpi DQ; /*!< D % (Q - 1) */ + mbedtls_mpi QP; /*!< 1 / (Q % P) */ + + mbedtls_mpi RN; /*!< cached R^2 mod N */ + mbedtls_mpi RP; /*!< cached R^2 mod P */ + mbedtls_mpi RQ; /*!< cached R^2 mod Q */ + + mbedtls_mpi Vi; /*!< cached blinding value */ + mbedtls_mpi Vf; /*!< cached un-blinding value */ + + int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and + MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */ + int hash_id; /*!< Hash identifier of mbedtls_md_type_t as + specified in the mbedtls_md.h header file + for the EME-OAEP and EMSA-PSS + encoding */ +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex */ +#endif +} +mbedtls_rsa_context; + +/** + * \brief Initialize an RSA context + * + * Note: Set padding to MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP + * encryption scheme and the RSASSA-PSS signature scheme. + * + * \param ctx RSA context to be initialized + * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21 + * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier + * + * \note The hash_id parameter is actually ignored + * when using MBEDTLS_RSA_PKCS_V15 padding. + * + * \note Choice of padding mode is strictly enforced for private key + * operations, since there might be security concerns in + * mixing padding modes. For public key operations it's merely + * a default value, which can be overriden by calling specific + * rsa_rsaes_xxx or rsa_rsassa_xxx functions. + * + * \note The chosen hash is always used for OEAP encryption. + * For PSS signatures, it's always used for making signatures, + * but can be overriden (and always is, if set to + * MBEDTLS_MD_NONE) for verifying them. + */ +void mbedtls_rsa_init( mbedtls_rsa_context *ctx, + int padding, + int hash_id); + +/** + * \brief Set padding for an already initialized RSA context + * See \c mbedtls_rsa_init() for details. + * + * \param ctx RSA context to be set + * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21 + * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier + */ +void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id); + +/** + * \brief Generate an RSA keypair + * + * \param ctx RSA context that will hold the key + * \param f_rng RNG function + * \param p_rng RNG parameter + * \param nbits size of the public key in bits + * \param exponent public exponent (e.g., 65537) + * + * \note mbedtls_rsa_init() must be called beforehand to setup + * the RSA context. + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + */ +int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + unsigned int nbits, int exponent ); + +/** + * \brief Check a public RSA key + * + * \param ctx RSA context to be checked + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + */ +int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ); + +/** + * \brief Check a private RSA key + * + * \param ctx RSA context to be checked + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + */ +int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ); + +/** + * \brief Check a public-private RSA key pair. + * Check each of the contexts, and make sure they match. + * + * \param pub RSA context holding the public key + * \param prv RSA context holding the private key + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + */ +int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv ); + +/** + * \brief Do an RSA public key operation + * + * \param ctx RSA context + * \param input input buffer + * \param output output buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note This function does NOT take care of message + * padding. Also, be sure to set input[0] = 0 or ensure that + * input is smaller than N. + * + * \note The input and output buffers must be large + * enough (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_public( mbedtls_rsa_context *ctx, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Do an RSA private key operation + * + * \param ctx RSA context + * \param f_rng RNG function (Needed for blinding) + * \param p_rng RNG parameter + * \param input input buffer + * \param output output buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The input and output buffers must be large + * enough (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_private( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Generic wrapper to perform a PKCS#1 encryption using the + * mode from the context. Add the message padding, then do an + * RSA operation. + * + * \param ctx RSA context + * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding + * and MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param ilen contains the plaintext length + * \param input buffer holding the data to be encrypted + * \param output buffer that will hold the ciphertext + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t ilen, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT) + * + * \param ctx RSA context + * \param f_rng RNG function (Needed for padding and MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param ilen contains the plaintext length + * \param input buffer holding the data to be encrypted + * \param output buffer that will hold the ciphertext + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t ilen, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT) + * + * \param ctx RSA context + * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding + * and MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param label buffer holding the custom label to use + * \param label_len contains the label length + * \param ilen contains the plaintext length + * \param input buffer holding the data to be encrypted + * \param output buffer that will hold the ciphertext + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + const unsigned char *label, size_t label_len, + size_t ilen, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief Generic wrapper to perform a PKCS#1 decryption using the + * mode from the context. Do an RSA operation, then remove + * the message padding + * + * \param ctx RSA context + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param olen will contain the plaintext length + * \param input buffer holding the encrypted data + * \param output buffer that will hold the plaintext + * \param output_max_len maximum length of the output buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise + * an error is thrown. + */ +int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len ); + +/** + * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT) + * + * \param ctx RSA context + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param olen will contain the plaintext length + * \param input buffer holding the encrypted data + * \param output buffer that will hold the plaintext + * \param output_max_len maximum length of the output buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise + * an error is thrown. + */ +int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len ); + +/** + * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT) + * + * \param ctx RSA context + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param label buffer holding the custom label to use + * \param label_len contains the label length + * \param olen will contain the plaintext length + * \param input buffer holding the encrypted data + * \param output buffer that will hold the plaintext + * \param output_max_len maximum length of the output buffer + * + * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The output buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise + * an error is thrown. + */ +int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + const unsigned char *label, size_t label_len, + size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len ); + +/** + * \brief Generic wrapper to perform a PKCS#1 signature using the + * mode from the context. Do a private RSA operation to sign + * a message digest + * + * \param ctx RSA context + * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for + * MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer that will hold the ciphertext + * + * \return 0 if the signing operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + * + * \note In case of PKCS#1 v2.1 encoding, see comments on + * \note \c mbedtls_rsa_rsassa_pss_sign() for details on md_alg and hash_id. + */ +int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ); + +/** + * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN) + * + * \param ctx RSA context + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer that will hold the ciphertext + * + * \return 0 if the signing operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ); + +/** + * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN) + * + * \param ctx RSA context + * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for + * MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer that will hold the ciphertext + * + * \return 0 if the signing operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + * + * \note The hash_id in the RSA context is the one used for the + * encoding. md_alg in the function call is the type of hash + * that is encoded. According to RFC 3447 it is advised to + * keep both hashes the same. + */ +int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ); + +/** + * \brief Generic wrapper to perform a PKCS#1 verification using the + * mode from the context. Do a public RSA operation and check + * the message digest + * + * \param ctx points to an RSA public key + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer holding the ciphertext + * + * \return 0 if the verify operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + * + * \note In case of PKCS#1 v2.1 encoding, see comments on + * \c mbedtls_rsa_rsassa_pss_verify() about md_alg and hash_id. + */ +int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + const unsigned char *sig ); + +/** + * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY) + * + * \param ctx points to an RSA public key + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer holding the ciphertext + * + * \return 0 if the verify operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + */ +int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + const unsigned char *sig ); + +/** + * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY) + * (This is the "simple" version.) + * + * \param ctx points to an RSA public key + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param sig buffer holding the ciphertext + * + * \return 0 if the verify operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + * + * \note The hash_id in the RSA context is the one used for the + * verification. md_alg in the function call is the type of + * hash that is verified. According to RFC 3447 it is advised to + * keep both hashes the same. If hash_id in the RSA context is + * unset, the md_alg from the function call is used. + */ +int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + const unsigned char *sig ); + +/** + * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY) + * (This is the version with "full" options.) + * + * \param ctx points to an RSA public key + * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE) + * \param p_rng RNG parameter + * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE + * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) + * \param hashlen message digest length (for MBEDTLS_MD_NONE only) + * \param hash buffer holding the message digest + * \param mgf1_hash_id message digest used for mask generation + * \param expected_salt_len Length of the salt used in padding, use + * MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length + * \param sig buffer holding the ciphertext + * + * \return 0 if the verify operation was successful, + * or an MBEDTLS_ERR_RSA_XXX error code + * + * \note The "sig" buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). + * + * \note The hash_id in the RSA context is ignored. + */ +int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + mbedtls_md_type_t mgf1_hash_id, + int expected_salt_len, + const unsigned char *sig ); + +/** + * \brief Copy the components of an RSA context + * + * \param dst Destination context + * \param src Source context + * + * \return 0 on success, + * MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure + */ +int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src ); + +/** + * \brief Free the components of an RSA key + * + * \param ctx RSA Context to free + */ +void mbedtls_rsa_free( mbedtls_rsa_context *ctx ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_rsa_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_RSA_C */ + +#endif /* rsa.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha1.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha1.h new file mode 100644 index 0000000..7a67c6c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha1.h @@ -0,0 +1,136 @@ +/** + * \file sha1.h + * + * \brief SHA-1 cryptographic hash function + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SHA1_H +#define MBEDTLS_SHA1_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if !defined(MBEDTLS_SHA1_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SHA-1 context structure + */ +typedef struct +{ + uint32_t total[2]; /*!< number of bytes processed */ + uint32_t state[5]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +mbedtls_sha1_context; + +/** + * \brief Initialize SHA-1 context + * + * \param ctx SHA-1 context to be initialized + */ +void mbedtls_sha1_init( mbedtls_sha1_context *ctx ); + +/** + * \brief Clear SHA-1 context + * + * \param ctx SHA-1 context to be cleared + */ +void mbedtls_sha1_free( mbedtls_sha1_context *ctx ); + +/** + * \brief Clone (the state of) a SHA-1 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_sha1_clone( mbedtls_sha1_context *dst, + const mbedtls_sha1_context *src ); + +/** + * \brief SHA-1 context setup + * + * \param ctx context to be initialized + */ +void mbedtls_sha1_starts( mbedtls_sha1_context *ctx ); + +/** + * \brief SHA-1 process buffer + * + * \param ctx SHA-1 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen ); + +/** + * \brief SHA-1 final digest + * + * \param ctx SHA-1 context + * \param output SHA-1 checksum result + */ +void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] ); + +/* Internal use */ +void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_SHA1_ALT */ +#include "sha1_alt.h" +#endif /* MBEDTLS_SHA1_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = SHA-1( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output SHA-1 checksum result + */ +void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_sha1_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_sha1.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha256.h new file mode 100644 index 0000000..f8041ad --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha256.h @@ -0,0 +1,141 @@ +/** + * \file sha256.h + * + * \brief SHA-224 and SHA-256 cryptographic hash function + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SHA256_H +#define MBEDTLS_SHA256_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if !defined(MBEDTLS_SHA256_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SHA-256 context structure + */ +typedef struct +{ + uint32_t total[2]; /*!< number of bytes processed */ + uint32_t state[8]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ + int is224; /*!< 0 => SHA-256, else SHA-224 */ +} +mbedtls_sha256_context; + +/** + * \brief Initialize SHA-256 context + * + * \param ctx SHA-256 context to be initialized + */ +void mbedtls_sha256_init( mbedtls_sha256_context *ctx ); + +/** + * \brief Clear SHA-256 context + * + * \param ctx SHA-256 context to be cleared + */ +void mbedtls_sha256_free( mbedtls_sha256_context *ctx ); + +/** + * \brief Clone (the state of) a SHA-256 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_sha256_clone( mbedtls_sha256_context *dst, + const mbedtls_sha256_context *src ); + +/** + * \brief SHA-256 context setup + * + * \param ctx context to be initialized + * \param is224 0 = use SHA256, 1 = use SHA224 + */ +void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ); + +/** + * \brief SHA-256 process buffer + * + * \param ctx SHA-256 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, + size_t ilen ); + +/** + * \brief SHA-256 final digest + * + * \param ctx SHA-256 context + * \param output SHA-224/256 checksum result + */ +void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] ); + +/* Internal use */ +void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_SHA256_ALT */ +#include "sha256_alt.h" +#endif /* MBEDTLS_SHA256_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = SHA-256( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output SHA-224/256 checksum result + * \param is224 0 = use SHA256, 1 = use SHA224 + */ +void mbedtls_sha256( const unsigned char *input, size_t ilen, + unsigned char output[32], int is224 ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_sha256_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_sha256.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha512.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha512.h new file mode 100644 index 0000000..627694f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/sha512.h @@ -0,0 +1,141 @@ +/** + * \file sha512.h + * + * \brief SHA-384 and SHA-512 cryptographic hash function + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SHA512_H +#define MBEDTLS_SHA512_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#if !defined(MBEDTLS_SHA512_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SHA-512 context structure + */ +typedef struct +{ + uint64_t total[2]; /*!< number of bytes processed */ + uint64_t state[8]; /*!< intermediate digest state */ + unsigned char buffer[128]; /*!< data block being processed */ + int is384; /*!< 0 => SHA-512, else SHA-384 */ +} +mbedtls_sha512_context; + +/** + * \brief Initialize SHA-512 context + * + * \param ctx SHA-512 context to be initialized + */ +void mbedtls_sha512_init( mbedtls_sha512_context *ctx ); + +/** + * \brief Clear SHA-512 context + * + * \param ctx SHA-512 context to be cleared + */ +void mbedtls_sha512_free( mbedtls_sha512_context *ctx ); + +/** + * \brief Clone (the state of) a SHA-512 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void mbedtls_sha512_clone( mbedtls_sha512_context *dst, + const mbedtls_sha512_context *src ); + +/** + * \brief SHA-512 context setup + * + * \param ctx context to be initialized + * \param is384 0 = use SHA512, 1 = use SHA384 + */ +void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 ); + +/** + * \brief SHA-512 process buffer + * + * \param ctx SHA-512 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input, + size_t ilen ); + +/** + * \brief SHA-512 final digest + * + * \param ctx SHA-512 context + * \param output SHA-384/512 checksum result + */ +void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_SHA512_ALT */ +#include "sha512_alt.h" +#endif /* MBEDTLS_SHA512_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = SHA-512( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output SHA-384/512 checksum result + * \param is384 0 = use SHA512, 1 = use SHA384 + */ +void mbedtls_sha512( const unsigned char *input, size_t ilen, + unsigned char output[64], int is384 ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_sha512_self_test( int verbose ); + +/* Internal use */ +void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] ); + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_sha512.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl.h new file mode 100644 index 0000000..495e02c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl.h @@ -0,0 +1,2559 @@ +/** + * \file ssl.h + * + * \brief SSL/TLS functions. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SSL_H +#define MBEDTLS_SSL_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "bignum.h" +#include "ecp.h" + +#include "ssl_ciphersuites.h" + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +#include "x509_crt.h" +#include "x509_crl.h" +#endif + +#if defined(MBEDTLS_DHM_C) +#include "dhm.h" +#endif + +#if defined(MBEDTLS_ECDH_C) +#include "ecdh.h" +#endif + +#if defined(MBEDTLS_ZLIB_SUPPORT) +#include "zlib.h" +#endif + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +/* + * SSL Error codes + */ +#define MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE -0x7080 /**< The requested feature is not available. */ +#define MBEDTLS_ERR_SSL_BAD_INPUT_DATA -0x7100 /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_SSL_INVALID_MAC -0x7180 /**< Verification of the message MAC failed. */ +#define MBEDTLS_ERR_SSL_INVALID_RECORD -0x7200 /**< An invalid SSL record was received. */ +#define MBEDTLS_ERR_SSL_CONN_EOF -0x7280 /**< The connection indicated an EOF. */ +#define MBEDTLS_ERR_SSL_UNKNOWN_CIPHER -0x7300 /**< An unknown cipher was received. */ +#define MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN -0x7380 /**< The server has no ciphersuites in common with the client. */ +#define MBEDTLS_ERR_SSL_NO_RNG -0x7400 /**< No RNG was provided to the SSL module. */ +#define MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480 /**< No client certification received from the client, but required by the authentication mode. */ +#define MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500 /**< Our own certificate(s) is/are too large to send in an SSL message. */ +#define MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED -0x7580 /**< The own certificate is not set, but needed by the server. */ +#define MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600 /**< The own private key or pre-shared key is not set, but needed. */ +#define MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED -0x7680 /**< No CA Chain is set, but required to operate. */ +#define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE -0x7700 /**< An unexpected message was received from our peer. */ +#define MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780 /**< A fatal alert message was received from our peer. */ +#define MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED -0x7800 /**< Verification of our peer failed. */ +#define MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880 /**< The peer notified us that the connection is going to be closed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900 /**< Processing of the ClientHello handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980 /**< Processing of the ServerHello handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00 /**< Processing of the Certificate handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80 /**< Processing of the CertificateRequest handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00 /**< Processing of the ServerKeyExchange handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80 /**< Processing of the ServerHelloDone handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00 /**< Processing of the ClientKeyExchange handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP -0x7C80 /**< Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS -0x7D00 /**< Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80 /**< Processing of the CertificateVerify handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00 /**< Processing of the ChangeCipherSpec handshake message failed. */ +#define MBEDTLS_ERR_SSL_BAD_HS_FINISHED -0x7E80 /**< Processing of the Finished handshake message failed. */ +#define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00 /**< Memory allocation failed */ +#define MBEDTLS_ERR_SSL_HW_ACCEL_FAILED -0x7F80 /**< Hardware acceleration function returned with error */ +#define MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80 /**< Hardware acceleration function skipped / left alone data */ +#define MBEDTLS_ERR_SSL_COMPRESSION_FAILED -0x6F00 /**< Processing of the compression / decompression failed */ +#define MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80 /**< Handshake protocol not within min/max boundaries */ +#define MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET -0x6E00 /**< Processing of the NewSessionTicket handshake message failed. */ +#define MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED -0x6D80 /**< Session ticket has expired. */ +#define MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH -0x6D00 /**< Public key type mismatch (eg, asked for RSA key exchange and presented EC key) */ +#define MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY -0x6C80 /**< Unknown identity received (eg, PSK identity) */ +#define MBEDTLS_ERR_SSL_INTERNAL_ERROR -0x6C00 /**< Internal error (eg, unexpected failure in lower-level module) */ +#define MBEDTLS_ERR_SSL_COUNTER_WRAPPING -0x6B80 /**< A counter would wrap (eg, too many messages exchanged). */ +#define MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO -0x6B00 /**< Unexpected message at ServerHello in renegotiation. */ +#define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80 /**< DTLS client must retry for hello verification */ +#define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00 /**< A buffer is too small to receive or write a message */ +#define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980 /**< None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages). */ +#define MBEDTLS_ERR_SSL_WANT_READ -0x6900 /**< Connection requires a read call. */ +#define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880 /**< Connection requires a write call. */ +#define MBEDTLS_ERR_SSL_TIMEOUT -0x6800 /**< The operation timed out. */ +#define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780 /**< The client initiated a reconnect from the same port. */ +#define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700 /**< Record header looks valid but is not expected. */ +#define MBEDTLS_ERR_SSL_NON_FATAL -0x6680 /**< The alert message received indicates a non-fatal error. */ +#define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */ + +/* + * Various constants + */ +#define MBEDTLS_SSL_MAJOR_VERSION_3 3 +#define MBEDTLS_SSL_MINOR_VERSION_0 0 /*!< SSL v3.0 */ +#define MBEDTLS_SSL_MINOR_VERSION_1 1 /*!< TLS v1.0 */ +#define MBEDTLS_SSL_MINOR_VERSION_2 2 /*!< TLS v1.1 */ +#define MBEDTLS_SSL_MINOR_VERSION_3 3 /*!< TLS v1.2 */ + +#define MBEDTLS_SSL_TRANSPORT_STREAM 0 /*!< TLS */ +#define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1 /*!< DTLS */ + +#define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255 /*!< Maximum host name defined in RFC 1035 */ + +/* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c + * NONE must be zero so that memset()ing structure to zero works */ +#define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0 /*!< don't use this extension */ +#define MBEDTLS_SSL_MAX_FRAG_LEN_512 1 /*!< MaxFragmentLength 2^9 */ +#define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2 /*!< MaxFragmentLength 2^10 */ +#define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3 /*!< MaxFragmentLength 2^11 */ +#define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4 /*!< MaxFragmentLength 2^12 */ +#define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5 /*!< first invalid value */ + +#define MBEDTLS_SSL_IS_CLIENT 0 +#define MBEDTLS_SSL_IS_SERVER 1 + +#define MBEDTLS_SSL_IS_NOT_FALLBACK 0 +#define MBEDTLS_SSL_IS_FALLBACK 1 + +#define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0 +#define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1 + +#define MBEDTLS_SSL_ETM_DISABLED 0 +#define MBEDTLS_SSL_ETM_ENABLED 1 + +#define MBEDTLS_SSL_COMPRESS_NULL 0 +#define MBEDTLS_SSL_COMPRESS_DEFLATE 1 + +#define MBEDTLS_SSL_VERIFY_NONE 0 +#define MBEDTLS_SSL_VERIFY_OPTIONAL 1 +#define MBEDTLS_SSL_VERIFY_REQUIRED 2 +#define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */ + +#define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0 +#define MBEDTLS_SSL_SECURE_RENEGOTIATION 1 + +#define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0 +#define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1 + +#define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0 +#define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1 + +#define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1 +#define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16 + +#define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0 +#define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1 +#define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2 + +#define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0 +#define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1 +#define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */ + +#define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0 +#define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1 + +#define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0 +#define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1 + +#define MBEDTLS_SSL_ARC4_ENABLED 0 +#define MBEDTLS_SSL_ARC4_DISABLED 1 + +#define MBEDTLS_SSL_PRESET_DEFAULT 0 +#define MBEDTLS_SSL_PRESET_SUITEB 2 + +/* + * Default range for DTLS retransmission timer value, in milliseconds. + * RFC 6347 4.2.4.1 says from 1 second to 60 seconds. + */ +#define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000 +#define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000 + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME) +#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ +#endif + +/* + * Maxium fragment length in bytes, + * determines the size of each of the two internal I/O buffers. + * + * Note: the RFC defines the default size of SSL / TLS messages. If you + * change the value here, other clients / servers may not be able to + * communicate with you anymore. Only change this value if you control + * both sides of the connection and have it reduced at both sides, or + * if you're using the Max Fragment Length extension and you know all your + * peers are using it too! + */ +#if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN) +#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /**< Size of the input / output buffer */ +#endif + +/* \} name SECTION: Module settings */ + +/* + * Length of the verify data for secure renegotiation + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) +#define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36 +#else +#define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12 +#endif + +/* + * Signaling ciphersuite values (SCSV) + */ +#define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF /**< renegotiation info ext */ +#define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600 /**< RFC 7507 section 2 */ + +/* + * Supported Signature and Hash algorithms (For TLS 1.2) + * RFC 5246 section 7.4.1.4.1 + */ +#define MBEDTLS_SSL_HASH_NONE 0 +#define MBEDTLS_SSL_HASH_MD5 1 +#define MBEDTLS_SSL_HASH_SHA1 2 +#define MBEDTLS_SSL_HASH_SHA224 3 +#define MBEDTLS_SSL_HASH_SHA256 4 +#define MBEDTLS_SSL_HASH_SHA384 5 +#define MBEDTLS_SSL_HASH_SHA512 6 + +#define MBEDTLS_SSL_SIG_ANON 0 +#define MBEDTLS_SSL_SIG_RSA 1 +#define MBEDTLS_SSL_SIG_ECDSA 3 + +/* + * Client Certificate Types + * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5 + */ +#define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1 +#define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64 + +/* + * Message, alert and handshake types + */ +#define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20 +#define MBEDTLS_SSL_MSG_ALERT 21 +#define MBEDTLS_SSL_MSG_HANDSHAKE 22 +#define MBEDTLS_SSL_MSG_APPLICATION_DATA 23 + +#define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1 +#define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2 + +#define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */ +#define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */ +#define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */ +#define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */ +#define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */ +#define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */ +#define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */ +#define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */ +#define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */ +#define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */ +#define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */ +#define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */ +#define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */ +#define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */ +#define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */ +#define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */ +#define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */ +#define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */ +#define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */ +#define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */ +#define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */ +#define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */ +#define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */ +#define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */ +#define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */ +#define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */ +#define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */ +#define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */ +#define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */ + +#define MBEDTLS_SSL_HS_HELLO_REQUEST 0 +#define MBEDTLS_SSL_HS_CLIENT_HELLO 1 +#define MBEDTLS_SSL_HS_SERVER_HELLO 2 +#define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3 +#define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4 +#define MBEDTLS_SSL_HS_CERTIFICATE 11 +#define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12 +#define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13 +#define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14 +#define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15 +#define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16 +#define MBEDTLS_SSL_HS_FINISHED 20 + +/* + * TLS extensions + */ +#define MBEDTLS_TLS_EXT_SERVERNAME 0 +#define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0 + +#define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1 + +#define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4 + +#define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10 +#define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11 + +#define MBEDTLS_TLS_EXT_SIG_ALG 13 + +#define MBEDTLS_TLS_EXT_ALPN 16 + +#define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */ +#define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */ + +#define MBEDTLS_TLS_EXT_SESSION_TICKET 35 + +#define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */ + +#define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01 + +/* + * Size defines + */ +#if !defined(MBEDTLS_PSK_MAX_LEN) +#define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */ +#endif + +/* Dummy type used only for its size */ +union mbedtls_ssl_premaster_secret +{ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE + + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES + + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */ +#endif +}; + +#define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SSL state machine + */ +typedef enum +{ + MBEDTLS_SSL_HELLO_REQUEST, + MBEDTLS_SSL_CLIENT_HELLO, + MBEDTLS_SSL_SERVER_HELLO, + MBEDTLS_SSL_SERVER_CERTIFICATE, + MBEDTLS_SSL_SERVER_KEY_EXCHANGE, + MBEDTLS_SSL_CERTIFICATE_REQUEST, + MBEDTLS_SSL_SERVER_HELLO_DONE, + MBEDTLS_SSL_CLIENT_CERTIFICATE, + MBEDTLS_SSL_CLIENT_KEY_EXCHANGE, + MBEDTLS_SSL_CERTIFICATE_VERIFY, + MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC, + MBEDTLS_SSL_CLIENT_FINISHED, + MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC, + MBEDTLS_SSL_SERVER_FINISHED, + MBEDTLS_SSL_FLUSH_BUFFERS, + MBEDTLS_SSL_HANDSHAKE_WRAPUP, + MBEDTLS_SSL_HANDSHAKE_OVER, + MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET, + MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT, +} +mbedtls_ssl_states; + +/** + * \brief Callback type: send data on the network. + * + * \note That callback may be either blocking or non-blocking. + * + * \param ctx Context for the send callback (typically a file descriptor) + * \param buf Buffer holding the data to send + * \param len Length of the data to send + * + * \return The callback must return the number of bytes sent if any, + * or a non-zero error code. + * If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_WRITE + * must be returned when the operation would block. + * + * \note The callback is allowed to send fewer bytes than requested. + * It must always return the number of bytes actually sent. + */ +typedef int mbedtls_ssl_send_t( void *ctx, + const unsigned char *buf, + size_t len ); + +/** + * \brief Callback type: receive data from the network. + * + * \note That callback may be either blocking or non-blocking. + * + * \param ctx Context for the receive callback (typically a file + * descriptor) + * \param buf Buffer to write the received data to + * \param len Length of the receive buffer + * + * \return The callback must return the number of bytes received, + * or a non-zero error code. + * If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_READ + * must be returned when the operation would block. + * + * \note The callback may receive fewer bytes than the length of the + * buffer. It must always return the number of bytes actually + * received and written to the buffer. + */ +typedef int mbedtls_ssl_recv_t( void *ctx, + unsigned char *buf, + size_t len ); + +/** + * \brief Callback type: receive data from the network, with timeout + * + * \note That callback must block until data is received, or the + * timeout delay expires, or the operation is interrupted by a + * signal. + * + * \param ctx Context for the receive callback (typically a file descriptor) + * \param buf Buffer to write the received data to + * \param len Length of the receive buffer + * \param timeout Maximum nomber of millisecondes to wait for data + * 0 means no timeout (potentially waiting forever) + * + * \return The callback must return the number of bytes received, + * or a non-zero error code: + * \c MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out, + * \c MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. + * + * \note The callback may receive fewer bytes than the length of the + * buffer. It must always return the number of bytes actually + * received and written to the buffer. + */ +typedef int mbedtls_ssl_recv_timeout_t( void *ctx, + unsigned char *buf, + size_t len, + uint32_t timeout ); +/** + * \brief Callback type: set a pair of timers/delays to watch + * + * \param ctx Context pointer + * \param int_ms Intermediate delay in milliseconds + * \param fin_ms Final delay in milliseconds + * 0 cancels the current timer. + * + * \note This callback must at least store the necessary information + * for the associated \c mbedtls_ssl_get_timer_t callback to + * return correct information. + * + * \note If using a event-driven style of programming, an event must + * be generated when the final delay is passed. The event must + * cause a call to \c mbedtls_ssl_handshake() with the proper + * SSL context to be scheduled. Care must be taken to ensure + * that at most one such call happens at a time. + * + * \note Only one timer at a time must be running. Calling this + * function while a timer is running must cancel it. Cancelled + * timers must not generate any event. + */ +typedef void mbedtls_ssl_set_timer_t( void * ctx, + uint32_t int_ms, + uint32_t fin_ms ); + +/** + * \brief Callback type: get status of timers/delays + * + * \param ctx Context pointer + * + * \return This callback must return: + * -1 if cancelled (fin_ms == 0), + * 0 if none of the delays have passed, + * 1 if only the intermediate delay has passed, + * 2 if the final delay has passed. + */ +typedef int mbedtls_ssl_get_timer_t( void * ctx ); + + +/* Defined below */ +typedef struct mbedtls_ssl_session mbedtls_ssl_session; +typedef struct mbedtls_ssl_context mbedtls_ssl_context; +typedef struct mbedtls_ssl_config mbedtls_ssl_config; + +/* Defined in ssl_internal.h */ +typedef struct mbedtls_ssl_transform mbedtls_ssl_transform; +typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params; +#if defined(MBEDTLS_X509_CRT_PARSE_C) +typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert; +#endif +#if defined(MBEDTLS_SSL_PROTO_DTLS) +typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item; +#endif + +/* + * This structure is used for storing current session data. + */ +struct mbedtls_ssl_session +{ +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t start; /*!< starting time */ +#endif + int ciphersuite; /*!< chosen ciphersuite */ + int compression; /*!< chosen compression */ + size_t id_len; /*!< session id length */ + unsigned char id[32]; /*!< session identifier */ + unsigned char master[48]; /*!< the master secret */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt *peer_cert; /*!< peer X.509 cert chain */ +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + uint32_t verify_result; /*!< verification result */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) + unsigned char *ticket; /*!< RFC 5077 session ticket */ + size_t ticket_len; /*!< session ticket length */ + uint32_t ticket_lifetime; /*!< ticket lifetime hint */ +#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + unsigned char mfl_code; /*!< MaxFragmentLength negotiated by peer */ +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + int trunc_hmac; /*!< flag for truncated hmac activation */ +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + int encrypt_then_mac; /*!< flag for EtM activation */ +#endif +}; + +/** + * SSL/TLS configuration to be shared between mbedtls_ssl_context structures. + */ +struct mbedtls_ssl_config +{ + /* Group items by size (largest first) to minimize padding overhead */ + + /* + * Pointers + */ + + const int *ciphersuite_list[4]; /*!< allowed ciphersuites per version */ + + /** Callback for printing debug output */ + void (*f_dbg)(void *, int, const char *, int, const char *); + void *p_dbg; /*!< context for the debug function */ + + /** Callback for getting (pseudo-)random numbers */ + int (*f_rng)(void *, unsigned char *, size_t); + void *p_rng; /*!< context for the RNG function */ + + /** Callback to retrieve a session from the cache */ + int (*f_get_cache)(void *, mbedtls_ssl_session *); + /** Callback to store a session into the cache */ + int (*f_set_cache)(void *, const mbedtls_ssl_session *); + void *p_cache; /*!< context for cache callbacks */ + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + /** Callback for setting cert according to SNI extension */ + int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t); + void *p_sni; /*!< context for SNI callback */ +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /** Callback to customize X.509 certificate chain verification */ + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *); + void *p_vrfy; /*!< context for X.509 verify calllback */ +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + /** Callback to retrieve PSK key from identity */ + int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t); + void *p_psk; /*!< context for PSK callback */ +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) + /** Callback to create & write a cookie for ClientHello veirifcation */ + int (*f_cookie_write)( void *, unsigned char **, unsigned char *, + const unsigned char *, size_t ); + /** Callback to verify validity of a ClientHello cookie */ + int (*f_cookie_check)( void *, const unsigned char *, size_t, + const unsigned char *, size_t ); + void *p_cookie; /*!< context for the cookie callbacks */ +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C) + /** Callback to create & write a session ticket */ + int (*f_ticket_write)( void *, const mbedtls_ssl_session *, + unsigned char *, const unsigned char *, size_t *, uint32_t * ); + /** Callback to parse a session ticket into a session structure */ + int (*f_ticket_parse)( void *, mbedtls_ssl_session *, unsigned char *, size_t); + void *p_ticket; /*!< context for the ticket callbacks */ +#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + /** Callback to export key block and master secret */ + int (*f_export_keys)( void *, const unsigned char *, + const unsigned char *, size_t, size_t, size_t ); + void *p_export_keys; /*!< context for key export callback */ +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + const mbedtls_x509_crt_profile *cert_profile; /*!< verification profile */ + mbedtls_ssl_key_cert *key_cert; /*!< own certificate/key pair(s) */ + mbedtls_x509_crt *ca_chain; /*!< trusted CAs */ + mbedtls_x509_crl *ca_crl; /*!< trusted CAs CRLs */ +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + const int *sig_hashes; /*!< allowed signature hashes */ +#endif + +#if defined(MBEDTLS_ECP_C) + const mbedtls_ecp_group_id *curve_list; /*!< allowed curves */ +#endif + +#if defined(MBEDTLS_DHM_C) + mbedtls_mpi dhm_P; /*!< prime modulus for DHM */ + mbedtls_mpi dhm_G; /*!< generator for DHM */ +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + unsigned char *psk; /*!< pre-shared key */ + size_t psk_len; /*!< length of the pre-shared key */ + unsigned char *psk_identity; /*!< identity for PSK negotiation */ + size_t psk_identity_len;/*!< length of identity */ +#endif + +#if defined(MBEDTLS_SSL_ALPN) + const char **alpn_list; /*!< ordered list of protocols */ +#endif + + /* + * Numerical settings (int then char) + */ + + uint32_t read_timeout; /*!< timeout for mbedtls_ssl_read (ms) */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + uint32_t hs_timeout_min; /*!< initial value of the handshake + retransmission timeout (ms) */ + uint32_t hs_timeout_max; /*!< maximum value of the handshake + retransmission timeout (ms) */ +#endif + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renego_max_records; /*!< grace period for renegotiation */ + unsigned char renego_period[8]; /*!< value of the record counters + that triggers renegotiation */ +#endif + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) + unsigned int badmac_limit; /*!< limit of records with a bad MAC */ +#endif + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) + unsigned int dhm_min_bitlen; /*!< min. bit length of the DHM prime */ +#endif + + unsigned char max_major_ver; /*!< max. major version used */ + unsigned char max_minor_ver; /*!< max. minor version used */ + unsigned char min_major_ver; /*!< min. major version used */ + unsigned char min_minor_ver; /*!< min. minor version used */ + + /* + * Flags (bitfields) + */ + + unsigned int endpoint : 1; /*!< 0: client, 1: server */ + unsigned int transport : 1; /*!< stream (TLS) or datagram (DTLS) */ + unsigned int authmode : 2; /*!< MBEDTLS_SSL_VERIFY_XXX */ + /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */ + unsigned int allow_legacy_renegotiation : 2 ; /*!< MBEDTLS_LEGACY_XXX */ +#if defined(MBEDTLS_ARC4_C) + unsigned int arc4_disabled : 1; /*!< blacklist RC4 ciphersuites? */ +#endif +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + unsigned int mfl_code : 3; /*!< desired fragment length */ +#endif +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + unsigned int encrypt_then_mac : 1 ; /*!< negotiate encrypt-then-mac? */ +#endif +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + unsigned int extended_ms : 1; /*!< negotiate extended master secret? */ +#endif +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + unsigned int anti_replay : 1; /*!< detect and prevent replay? */ +#endif +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + unsigned int cbc_record_splitting : 1; /*!< do cbc record splitting */ +#endif +#if defined(MBEDTLS_SSL_RENEGOTIATION) + unsigned int disable_renegotiation : 1; /*!< disable renegotiation? */ +#endif +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + unsigned int trunc_hmac : 1; /*!< negotiate truncated hmac? */ +#endif +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + unsigned int session_tickets : 1; /*!< use session tickets? */ +#endif +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C) + unsigned int fallback : 1; /*!< is this a fallback? */ +#endif +}; + + +struct mbedtls_ssl_context +{ + const mbedtls_ssl_config *conf; /*!< configuration information */ + + /* + * Miscellaneous + */ + int state; /*!< SSL handshake: current state */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renego_status; /*!< Initial, in progress, pending? */ + int renego_records_seen; /*!< Records since renego request, or with DTLS, + number of retransmissions of request if + renego_max_records is < 0 */ +#endif + + int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */ + int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */ + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) + unsigned badmac_seen; /*!< records with a bad MAC received */ +#endif + + mbedtls_ssl_send_t *f_send; /*!< Callback for network send */ + mbedtls_ssl_recv_t *f_recv; /*!< Callback for network receive */ + mbedtls_ssl_recv_timeout_t *f_recv_timeout; + /*!< Callback for network receive with timeout */ + + void *p_bio; /*!< context for I/O operations */ + + /* + * Session layer + */ + mbedtls_ssl_session *session_in; /*!< current session data (in) */ + mbedtls_ssl_session *session_out; /*!< current session data (out) */ + mbedtls_ssl_session *session; /*!< negotiated session data */ + mbedtls_ssl_session *session_negotiate; /*!< session data in negotiation */ + + mbedtls_ssl_handshake_params *handshake; /*!< params required only during + the handshake process */ + + /* + * Record layer transformations + */ + mbedtls_ssl_transform *transform_in; /*!< current transform params (in) */ + mbedtls_ssl_transform *transform_out; /*!< current transform params (in) */ + mbedtls_ssl_transform *transform; /*!< negotiated transform params */ + mbedtls_ssl_transform *transform_negotiate; /*!< transform params in negotiation */ + + /* + * Timers + */ + void *p_timer; /*!< context for the timer callbacks */ + + mbedtls_ssl_set_timer_t *f_set_timer; /*!< set timer callback */ + mbedtls_ssl_get_timer_t *f_get_timer; /*!< get timer callback */ + + /* + * Record layer (incoming data) + */ + unsigned char *in_buf; /*!< input buffer */ + unsigned char *in_ctr; /*!< 64-bit incoming message counter + TLS: maintained by us + DTLS: read from peer */ + unsigned char *in_hdr; /*!< start of record header */ + unsigned char *in_len; /*!< two-bytes message length field */ + unsigned char *in_iv; /*!< ivlen-byte IV */ + unsigned char *in_msg; /*!< message contents (in_iv+ivlen) */ + unsigned char *in_offt; /*!< read offset in application data */ + + int in_msgtype; /*!< record header: message type */ + size_t in_msglen; /*!< record header: message length */ + size_t in_left; /*!< amount of data read so far */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + uint16_t in_epoch; /*!< DTLS epoch for incoming records */ + size_t next_record_offset; /*!< offset of the next record in datagram + (equal to in_left if none) */ +#endif +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + uint64_t in_window_top; /*!< last validated record seq_num */ + uint64_t in_window; /*!< bitmask for replay detection */ +#endif + + size_t in_hslen; /*!< current handshake message length, + including the handshake header */ + int nb_zero; /*!< # of 0-length encrypted messages */ + int record_read; /*!< record is already present */ + + /* + * Record layer (outgoing data) + */ + unsigned char *out_buf; /*!< output buffer */ + unsigned char *out_ctr; /*!< 64-bit outgoing message counter */ + unsigned char *out_hdr; /*!< start of record header */ + unsigned char *out_len; /*!< two-bytes message length field */ + unsigned char *out_iv; /*!< ivlen-byte IV */ + unsigned char *out_msg; /*!< message contents (out_iv+ivlen) */ + + int out_msgtype; /*!< record header: message type */ + size_t out_msglen; /*!< record header: message length */ + size_t out_left; /*!< amount of data not yet written */ + +#if defined(MBEDTLS_ZLIB_SUPPORT) + unsigned char *compress_buf; /*!< zlib data buffer */ +#endif +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + signed char split_done; /*!< current record already splitted? */ +#endif + + /* + * PKI layer + */ + int client_auth; /*!< flag for client auth. */ + + /* + * User settings + */ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + char *hostname; /*!< expected peer CN for verification + (and SNI if available) */ +#endif + +#if defined(MBEDTLS_SSL_ALPN) + const char *alpn_chosen; /*!< negotiated protocol */ +#endif + + /* + * Information for DTLS hello verify + */ +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) + unsigned char *cli_id; /*!< transport-level ID of the client */ + size_t cli_id_len; /*!< length of cli_id */ +#endif + + /* + * Secure renegotiation + */ + /* needed to know when to send extension on server */ + int secure_renegotiation; /*!< does peer support legacy or + secure renegotiation */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + size_t verify_data_len; /*!< length of verify data stored */ + char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */ + char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */ +#endif +}; + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + +#define MBEDTLS_SSL_CHANNEL_OUTBOUND 0 +#define MBEDTLS_SSL_CHANNEL_INBOUND 1 + +extern int (*mbedtls_ssl_hw_record_init)(mbedtls_ssl_context *ssl, + const unsigned char *key_enc, const unsigned char *key_dec, + size_t keylen, + const unsigned char *iv_enc, const unsigned char *iv_dec, + size_t ivlen, + const unsigned char *mac_enc, const unsigned char *mac_dec, + size_t maclen); +extern int (*mbedtls_ssl_hw_record_activate)(mbedtls_ssl_context *ssl, int direction); +extern int (*mbedtls_ssl_hw_record_reset)(mbedtls_ssl_context *ssl); +extern int (*mbedtls_ssl_hw_record_write)(mbedtls_ssl_context *ssl); +extern int (*mbedtls_ssl_hw_record_read)(mbedtls_ssl_context *ssl); +extern int (*mbedtls_ssl_hw_record_finish)(mbedtls_ssl_context *ssl); +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ + +/** + * \brief Returns the list of ciphersuites supported by the SSL/TLS module. + * + * \return a statically allocated array of ciphersuites, the last + * entry is 0. + */ +const int *mbedtls_ssl_list_ciphersuites( void ); + +/** + * \brief Return the name of the ciphersuite associated with the + * given ID + * + * \param ciphersuite_id SSL ciphersuite ID + * + * \return a string containing the ciphersuite name + */ +const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id ); + +/** + * \brief Return the ID of the ciphersuite associated with the + * given name + * + * \param ciphersuite_name SSL ciphersuite name + * + * \return the ID with the ciphersuite or 0 if not found + */ +int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name ); + +/** + * \brief Initialize an SSL context + * Just makes the context ready for mbedtls_ssl_setup() or + * mbedtls_ssl_free() + * + * \param ssl SSL context + */ +void mbedtls_ssl_init( mbedtls_ssl_context *ssl ); + +/** + * \brief Set up an SSL context for use + * + * \note No copy of the configuration context is made, it can be + * shared by many mbedtls_ssl_context structures. + * + * \warning Modifying the conf structure after it has been used in this + * function is unsupported! + * + * \param ssl SSL context + * \param conf SSL configuration to use + * + * \return 0 if successful, or MBEDTLS_ERR_SSL_ALLOC_FAILED if + * memory allocation failed + */ +int mbedtls_ssl_setup( mbedtls_ssl_context *ssl, + const mbedtls_ssl_config *conf ); + +/** + * \brief Reset an already initialized SSL context for re-use + * while retaining application-set variables, function + * pointers and data. + * + * \param ssl SSL context + * \return 0 if successful, or MBEDTLS_ERR_SSL_ALLOC_FAILED, + MBEDTLS_ERR_SSL_HW_ACCEL_FAILED or + * MBEDTLS_ERR_SSL_COMPRESSION_FAILED + */ +int mbedtls_ssl_session_reset( mbedtls_ssl_context *ssl ); + +/** + * \brief Set the current endpoint type + * + * \param conf SSL configuration + * \param endpoint must be MBEDTLS_SSL_IS_CLIENT or MBEDTLS_SSL_IS_SERVER + */ +void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint ); + +/** + * \brief Set the transport type (TLS or DTLS). + * Default: TLS + * + * \note For DTLS, you must either provide a recv callback that + * doesn't block, or one that handles timeouts, see + * \c mbedtls_ssl_set_bio(). You also need to provide timer + * callbacks with \c mbedtls_ssl_set_timer_cb(). + * + * \param conf SSL configuration + * \param transport transport type: + * MBEDTLS_SSL_TRANSPORT_STREAM for TLS, + * MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS. + */ +void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport ); + +/** + * \brief Set the certificate verification mode + * Default: NONE on server, REQUIRED on client + * + * \param conf SSL configuration + * \param authmode can be: + * + * MBEDTLS_SSL_VERIFY_NONE: peer certificate is not checked + * (default on server) + * (insecure on client) + * + * MBEDTLS_SSL_VERIFY_OPTIONAL: peer certificate is checked, however the + * handshake continues even if verification failed; + * mbedtls_ssl_get_verify_result() can be called after the + * handshake is complete. + * + * MBEDTLS_SSL_VERIFY_REQUIRED: peer *must* present a valid certificate, + * handshake is aborted if verification failed. + * (default on client) + * + * \note On client, MBEDTLS_SSL_VERIFY_REQUIRED is the recommended mode. + * With MBEDTLS_SSL_VERIFY_OPTIONAL, the user needs to call mbedtls_ssl_get_verify_result() at + * the right time(s), which may not be obvious, while REQUIRED always perform + * the verification as soon as possible. For example, REQUIRED was protecting + * against the "triple handshake" attack even before it was found. + */ +void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * \brief Set the verification callback (Optional). + * + * If set, the verify callback is called for each + * certificate in the chain. For implementation + * information, please see \c x509parse_verify() + * + * \param conf SSL configuration + * \param f_vrfy verification function + * \param p_vrfy verification parameter + */ +void mbedtls_ssl_conf_verify( mbedtls_ssl_config *conf, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +/** + * \brief Set the random number generator callback + * + * \param conf SSL configuration + * \param f_rng RNG function + * \param p_rng RNG parameter + */ +void mbedtls_ssl_conf_rng( mbedtls_ssl_config *conf, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Set the debug callback + * + * The callback has the following argument: + * void * opaque context for the callback + * int debug level + * const char * file name + * int line number + * const char * message + * + * \param conf SSL configuration + * \param f_dbg debug function + * \param p_dbg debug parameter + */ +void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf, + void (*f_dbg)(void *, int, const char *, int, const char *), + void *p_dbg ); + +/** + * \brief Set the underlying BIO callbacks for write, read and + * read-with-timeout. + * + * \param ssl SSL context + * \param p_bio parameter (context) shared by BIO callbacks + * \param f_send write callback + * \param f_recv read callback + * \param f_recv_timeout blocking read callback with timeout. + * + * \note One of f_recv or f_recv_timeout can be NULL, in which case + * the other is used. If both are non-NULL, f_recv_timeout is + * used and f_recv is ignored (as if it were NULL). + * + * \note The two most common use cases are: + * - non-blocking I/O, f_recv != NULL, f_recv_timeout == NULL + * - blocking I/O, f_recv == NULL, f_recv_timout != NULL + * + * \note For DTLS, you need to provide either a non-NULL + * f_recv_timeout callback, or a f_recv that doesn't block. + * + * \note See the documentations of \c mbedtls_ssl_sent_t, + * \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for + * the conventions those callbacks must follow. + * + * \note On some platforms, net_sockets.c provides + * \c mbedtls_net_send(), \c mbedtls_net_recv() and + * \c mbedtls_net_recv_timeout() that are suitable to be used + * here. + */ +void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl, + void *p_bio, + mbedtls_ssl_send_t *f_send, + mbedtls_ssl_recv_t *f_recv, + mbedtls_ssl_recv_timeout_t *f_recv_timeout ); + +/** + * \brief Set the timeout period for mbedtls_ssl_read() + * (Default: no timeout.) + * + * \param conf SSL configuration context + * \param timeout Timeout value in milliseconds. + * Use 0 for no timeout (default). + * + * \note With blocking I/O, this will only work if a non-NULL + * \c f_recv_timeout was set with \c mbedtls_ssl_set_bio(). + * With non-blocking I/O, this will only work if timer + * callbacks were set with \c mbedtls_ssl_set_timer_cb(). + * + * \note With non-blocking I/O, you may also skip this function + * altogether and handle timeouts at the application layer. + */ +void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout ); + +/** + * \brief Set the timer callbacks (Mandatory for DTLS.) + * + * \param ssl SSL context + * \param p_timer parameter (context) shared by timer callbacks + * \param f_set_timer set timer callback + * \param f_get_timer get timer callback. Must return: + * + * \note See the documentation of \c mbedtls_ssl_set_timer_t and + * \c mbedtls_ssl_get_timer_t for the conventions this pair of + * callbacks must follow. + * + * \note On some platforms, timing.c provides + * \c mbedtls_timing_set_delay() and + * \c mbedtls_timing_get_delay() that are suitable for using + * here, except if using an event-driven style. + * + * \note See also the "DTLS tutorial" article in our knowledge base. + * https://tls.mbed.org/kb/how-to/dtls-tutorial + */ +void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *ssl, + void *p_timer, + mbedtls_ssl_set_timer_t *f_set_timer, + mbedtls_ssl_get_timer_t *f_get_timer ); + +/** + * \brief Callback type: generate and write session ticket + * + * \note This describes what a callback implementation should do. + * This callback should generate an encrypted and + * authenticated ticket for the session and write it to the + * output buffer. Here, ticket means the opaque ticket part + * of the NewSessionTicket structure of RFC 5077. + * + * \param p_ticket Context for the callback + * \param session SSL session to be written in the ticket + * \param start Start of the output buffer + * \param end End of the output buffer + * \param tlen On exit, holds the length written + * \param lifetime On exit, holds the lifetime of the ticket in seconds + * + * \return 0 if successful, or + * a specific MBEDTLS_ERR_XXX code. + */ +typedef int mbedtls_ssl_ticket_write_t( void *p_ticket, + const mbedtls_ssl_session *session, + unsigned char *start, + const unsigned char *end, + size_t *tlen, + uint32_t *lifetime ); + +#if defined(MBEDTLS_SSL_EXPORT_KEYS) +/** + * \brief Callback type: Export key block and master secret + * + * \note This is required for certain uses of TLS, e.g. EAP-TLS + * (RFC 5216) and Thread. The key pointers are ephemeral and + * therefore must not be stored. The master secret and keys + * should not be used directly except as an input to a key + * derivation function. + * + * \param p_expkey Context for the callback + * \param ms Pointer to master secret (fixed length: 48 bytes) + * \param kb Pointer to key block, see RFC 5246 section 6.3 + * (variable length: 2 * maclen + 2 * keylen + 2 * ivlen). + * \param maclen MAC length + * \param keylen Key length + * \param ivlen IV length + * + * \return 0 if successful, or + * a specific MBEDTLS_ERR_XXX code. + */ +typedef int mbedtls_ssl_export_keys_t( void *p_expkey, + const unsigned char *ms, + const unsigned char *kb, + size_t maclen, + size_t keylen, + size_t ivlen ); +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ + +/** + * \brief Callback type: parse and load session ticket + * + * \note This describes what a callback implementation should do. + * This callback should parse a session ticket as generated + * by the corresponding mbedtls_ssl_ticket_write_t function, + * and, if the ticket is authentic and valid, load the + * session. + * + * \note The implementation is allowed to modify the first len + * bytes of the input buffer, eg to use it as a temporary + * area for the decrypted ticket contents. + * + * \param p_ticket Context for the callback + * \param session SSL session to be loaded + * \param buf Start of the buffer containing the ticket + * \param len Length of the ticket. + * + * \return 0 if successful, or + * MBEDTLS_ERR_SSL_INVALID_MAC if not authentic, or + * MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED if expired, or + * any other non-zero code for other failures. + */ +typedef int mbedtls_ssl_ticket_parse_t( void *p_ticket, + mbedtls_ssl_session *session, + unsigned char *buf, + size_t len ); + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C) +/** + * \brief Configure SSL session ticket callbacks (server only). + * (Default: none.) + * + * \note On server, session tickets are enabled by providing + * non-NULL callbacks. + * + * \note On client, use \c mbedtls_ssl_conf_session_tickets(). + * + * \param conf SSL configuration context + * \param f_ticket_write Callback for writing a ticket + * \param f_ticket_parse Callback for parsing a ticket + * \param p_ticket Context shared by the two callbacks + */ +void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf, + mbedtls_ssl_ticket_write_t *f_ticket_write, + mbedtls_ssl_ticket_parse_t *f_ticket_parse, + void *p_ticket ); +#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_EXPORT_KEYS) +/** + * \brief Configure key export callback. + * (Default: none.) + * + * \note See \c mbedtls_ssl_export_keys_t. + * + * \param conf SSL configuration context + * \param f_export_keys Callback for exporting keys + * \param p_export_keys Context for the callback + */ +void mbedtls_ssl_conf_export_keys_cb( mbedtls_ssl_config *conf, + mbedtls_ssl_export_keys_t *f_export_keys, + void *p_export_keys ); +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ + +/** + * \brief Callback type: generate a cookie + * + * \param ctx Context for the callback + * \param p Buffer to write to, + * must be updated to point right after the cookie + * \param end Pointer to one past the end of the output buffer + * \param info Client ID info that was passed to + * \c mbedtls_ssl_set_client_transport_id() + * \param ilen Length of info in bytes + * + * \return The callback must return 0 on success, + * or a negative error code. + */ +typedef int mbedtls_ssl_cookie_write_t( void *ctx, + unsigned char **p, unsigned char *end, + const unsigned char *info, size_t ilen ); + +/** + * \brief Callback type: verify a cookie + * + * \param ctx Context for the callback + * \param cookie Cookie to verify + * \param clen Length of cookie + * \param info Client ID info that was passed to + * \c mbedtls_ssl_set_client_transport_id() + * \param ilen Length of info in bytes + * + * \return The callback must return 0 if cookie is valid, + * or a negative error code. + */ +typedef int mbedtls_ssl_cookie_check_t( void *ctx, + const unsigned char *cookie, size_t clen, + const unsigned char *info, size_t ilen ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) +/** + * \brief Register callbacks for DTLS cookies + * (Server only. DTLS only.) + * + * Default: dummy callbacks that fail, in order to force you to + * register working callbacks (and initialize their context). + * + * To disable HelloVerifyRequest, register NULL callbacks. + * + * \warning Disabling hello verification allows your server to be used + * for amplification in DoS attacks against other hosts. + * Only disable if you known this can't happen in your + * particular environment. + * + * \note See comments on \c mbedtls_ssl_handshake() about handling + * the MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED that is expected + * on the first handshake attempt when this is enabled. + * + * \note This is also necessary to handle client reconnection from + * the same port as described in RFC 6347 section 4.2.8 (only + * the variant with cookies is supported currently). See + * comments on \c mbedtls_ssl_read() for details. + * + * \param conf SSL configuration + * \param f_cookie_write Cookie write callback + * \param f_cookie_check Cookie check callback + * \param p_cookie Context for both callbacks + */ +void mbedtls_ssl_conf_dtls_cookies( mbedtls_ssl_config *conf, + mbedtls_ssl_cookie_write_t *f_cookie_write, + mbedtls_ssl_cookie_check_t *f_cookie_check, + void *p_cookie ); + +/** + * \brief Set client's transport-level identification info. + * (Server only. DTLS only.) + * + * This is usually the IP address (and port), but could be + * anything identify the client depending on the underlying + * network stack. Used for HelloVerifyRequest with DTLS. + * This is *not* used to route the actual packets. + * + * \param ssl SSL context + * \param info Transport-level info identifying the client (eg IP + port) + * \param ilen Length of info in bytes + * + * \note An internal copy is made, so the info buffer can be reused. + * + * \return 0 on success, + * MBEDTLS_ERR_SSL_BAD_INPUT_DATA if used on client, + * MBEDTLS_ERR_SSL_ALLOC_FAILED if out of memory. + */ +int mbedtls_ssl_set_client_transport_id( mbedtls_ssl_context *ssl, + const unsigned char *info, + size_t ilen ); + +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +/** + * \brief Enable or disable anti-replay protection for DTLS. + * (DTLS only, no effect on TLS.) + * Default: enabled. + * + * \param conf SSL configuration + * \param mode MBEDTLS_SSL_ANTI_REPLAY_ENABLED or MBEDTLS_SSL_ANTI_REPLAY_DISABLED. + * + * \warning Disabling this is a security risk unless the application + * protocol handles duplicated packets in a safe way. You + * should not disable this without careful consideration. + * However, if your application already detects duplicated + * packets and needs information about them to adjust its + * transmission strategy, then you'll want to disable this. + */ +void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode ); +#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) +/** + * \brief Set a limit on the number of records with a bad MAC + * before terminating the connection. + * (DTLS only, no effect on TLS.) + * Default: 0 (disabled). + * + * \param conf SSL configuration + * \param limit Limit, or 0 to disable. + * + * \note If the limit is N, then the connection is terminated when + * the Nth non-authentic record is seen. + * + * \note Records with an invalid header are not counted, only the + * ones going through the authentication-decryption phase. + * + * \note This is a security trade-off related to the fact that it's + * often relatively easy for an active attacker ot inject UDP + * datagrams. On one hand, setting a low limit here makes it + * easier for such an attacker to forcibly terminated a + * connection. On the other hand, a high limit or no limit + * might make us waste resources checking authentication on + * many bogus packets. + */ +void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limit ); +#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +/** + * \brief Set retransmit timeout values for the DTLS handshake. + * (DTLS only, no effect on TLS.) + * + * \param conf SSL configuration + * \param min Initial timeout value in milliseconds. + * Default: 1000 (1 second). + * \param max Maximum timeout value in milliseconds. + * Default: 60000 (60 seconds). + * + * \note Default values are from RFC 6347 section 4.2.4.1. + * + * \note The 'min' value should typically be slightly above the + * expected round-trip time to your peer, plus whatever time + * it takes for the peer to process the message. For example, + * if your RTT is about 600ms and you peer needs up to 1s to + * do the cryptographic operations in the handshake, then you + * should set 'min' slightly above 1600. Lower values of 'min' + * might cause spurious resends which waste network resources, + * while larger value of 'min' will increase overall latency + * on unreliable network links. + * + * \note The more unreliable your network connection is, the larger + * your max / min ratio needs to be in order to achieve + * reliable handshakes. + * + * \note Messages are retransmitted up to log2(ceil(max/min)) times. + * For example, if min = 1s and max = 5s, the retransmit plan + * goes: send ... 1s -> resend ... 2s -> resend ... 4s -> + * resend ... 5s -> give up and return a timeout error. + */ +void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max ); +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +#if defined(MBEDTLS_SSL_SRV_C) +/** + * \brief Set the session cache callbacks (server-side only) + * If not set, no session resuming is done (except if session + * tickets are enabled too). + * + * The session cache has the responsibility to check for stale + * entries based on timeout. See RFC 5246 for recommendations. + * + * Warning: session.peer_cert is cleared by the SSL/TLS layer on + * connection shutdown, so do not cache the pointer! Either set + * it to NULL or make a full copy of the certificate. + * + * The get callback is called once during the initial handshake + * to enable session resuming. The get function has the + * following parameters: (void *parameter, mbedtls_ssl_session *session) + * If a valid entry is found, it should fill the master of + * the session object with the cached values and return 0, + * return 1 otherwise. Optionally peer_cert can be set as well + * if it is properly present in cache entry. + * + * The set callback is called once during the initial handshake + * to enable session resuming after the entire handshake has + * been finished. The set function has the following parameters: + * (void *parameter, const mbedtls_ssl_session *session). The function + * should create a cache entry for future retrieval based on + * the data in the session structure and should keep in mind + * that the mbedtls_ssl_session object presented (and all its referenced + * data) is cleared by the SSL/TLS layer when the connection is + * terminated. It is recommended to add metadata to determine if + * an entry is still valid in the future. Return 0 if + * successfully cached, return 1 otherwise. + * + * \param conf SSL configuration + * \param p_cache parmater (context) for both callbacks + * \param f_get_cache session get callback + * \param f_set_cache session set callback + */ +void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf, + void *p_cache, + int (*f_get_cache)(void *, mbedtls_ssl_session *), + int (*f_set_cache)(void *, const mbedtls_ssl_session *) ); +#endif /* MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_CLI_C) +/** + * \brief Request resumption of session (client-side only) + * Session data is copied from presented session structure. + * + * \param ssl SSL context + * \param session session context + * + * \return 0 if successful, + * MBEDTLS_ERR_SSL_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_SSL_BAD_INPUT_DATA if used server-side or + * arguments are otherwise invalid + * + * \sa mbedtls_ssl_get_session() + */ +int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session ); +#endif /* MBEDTLS_SSL_CLI_C */ + +/** + * \brief Set the list of allowed ciphersuites and the preference + * order. First in the list has the highest preference. + * (Overrides all version-specific lists) + * + * The ciphersuites array is not copied, and must remain + * valid for the lifetime of the ssl_config. + * + * Note: The server uses its own preferences + * over the preference of the client unless + * MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE is defined! + * + * \param conf SSL configuration + * \param ciphersuites 0-terminated list of allowed ciphersuites + */ +void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, + const int *ciphersuites ); + +/** + * \brief Set the list of allowed ciphersuites and the + * preference order for a specific version of the protocol. + * (Only useful on the server side) + * + * The ciphersuites array is not copied, and must remain + * valid for the lifetime of the ssl_config. + * + * \param conf SSL configuration + * \param ciphersuites 0-terminated list of allowed ciphersuites + * \param major Major version number (only MBEDTLS_SSL_MAJOR_VERSION_3 + * supported) + * \param minor Minor version number (MBEDTLS_SSL_MINOR_VERSION_0, + * MBEDTLS_SSL_MINOR_VERSION_1 and MBEDTLS_SSL_MINOR_VERSION_2, + * MBEDTLS_SSL_MINOR_VERSION_3 supported) + * + * \note With DTLS, use MBEDTLS_SSL_MINOR_VERSION_2 for DTLS 1.0 + * and MBEDTLS_SSL_MINOR_VERSION_3 for DTLS 1.2 + */ +void mbedtls_ssl_conf_ciphersuites_for_version( mbedtls_ssl_config *conf, + const int *ciphersuites, + int major, int minor ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * \brief Set the X.509 security profile used for verification + * + * \note The restrictions are enforced for all certificates in the + * chain. However, signatures in the handshake are not covered + * by this setting but by \b mbedtls_ssl_conf_sig_hashes(). + * + * \param conf SSL configuration + * \param profile Profile to use + */ +void mbedtls_ssl_conf_cert_profile( mbedtls_ssl_config *conf, + const mbedtls_x509_crt_profile *profile ); + +/** + * \brief Set the data required to verify peer certificate + * + * \param conf SSL configuration + * \param ca_chain trusted CA chain (meaning all fully trusted top-level CAs) + * \param ca_crl trusted CA CRLs + */ +void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf, + mbedtls_x509_crt *ca_chain, + mbedtls_x509_crl *ca_crl ); + +/** + * \brief Set own certificate chain and private key + * + * \note own_cert should contain in order from the bottom up your + * certificate chain. The top certificate (self-signed) + * can be omitted. + * + * \note On server, this function can be called multiple times to + * provision more than one cert/key pair (eg one ECDSA, one + * RSA with SHA-256, one RSA with SHA-1). An adequate + * certificate will be selected according to the client's + * advertised capabilities. In case mutliple certificates are + * adequate, preference is given to the one set by the first + * call to this function, then second, etc. + * + * \note On client, only the first call has any effect. That is, + * only one client certificate can be provisioned. The + * server's preferences in its CertficateRequest message will + * be ignored and our only cert will be sent regardless of + * whether it matches those preferences - the server can then + * decide what it wants to do with it. + * + * \param conf SSL configuration + * \param own_cert own public certificate chain + * \param pk_key own private key + * + * \return 0 on success or MBEDTLS_ERR_SSL_ALLOC_FAILED + */ +int mbedtls_ssl_conf_own_cert( mbedtls_ssl_config *conf, + mbedtls_x509_crt *own_cert, + mbedtls_pk_context *pk_key ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +/** + * \brief Set the Pre Shared Key (PSK) and the expected identity name + * + * \note This is mainly useful for clients. Servers will usually + * want to use \c mbedtls_ssl_conf_psk_cb() instead. + * + * \note Currently clients can only register one pre-shared key. + * In other words, the servers' identity hint is ignored. + * Support for setting multiple PSKs on clients and selecting + * one based on the identity hint is not a planned feature but + * feedback is welcomed. + * + * \param conf SSL configuration + * \param psk pointer to the pre-shared key + * \param psk_len pre-shared key length + * \param psk_identity pointer to the pre-shared key identity + * \param psk_identity_len identity key length + * + * \return 0 if successful or MBEDTLS_ERR_SSL_ALLOC_FAILED + */ +int mbedtls_ssl_conf_psk( mbedtls_ssl_config *conf, + const unsigned char *psk, size_t psk_len, + const unsigned char *psk_identity, size_t psk_identity_len ); + + +/** + * \brief Set the Pre Shared Key (PSK) for the current handshake + * + * \note This should only be called inside the PSK callback, + * ie the function passed to \c mbedtls_ssl_conf_psk_cb(). + * + * \param ssl SSL context + * \param psk pointer to the pre-shared key + * \param psk_len pre-shared key length + * + * \return 0 if successful or MBEDTLS_ERR_SSL_ALLOC_FAILED + */ +int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl, + const unsigned char *psk, size_t psk_len ); + +/** + * \brief Set the PSK callback (server-side only). + * + * If set, the PSK callback is called for each + * handshake where a PSK ciphersuite was negotiated. + * The caller provides the identity received and wants to + * receive the actual PSK data and length. + * + * The callback has the following parameters: (void *parameter, + * mbedtls_ssl_context *ssl, const unsigned char *psk_identity, + * size_t identity_len) + * If a valid PSK identity is found, the callback should use + * \c mbedtls_ssl_set_hs_psk() on the ssl context to set the + * correct PSK and return 0. + * Any other return value will result in a denied PSK identity. + * + * \note If you set a PSK callback using this function, then you + * don't need to set a PSK key and identity using + * \c mbedtls_ssl_conf_psk(). + * + * \param conf SSL configuration + * \param f_psk PSK identity function + * \param p_psk PSK identity parameter + */ +void mbedtls_ssl_conf_psk_cb( mbedtls_ssl_config *conf, + int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, + size_t), + void *p_psk ); +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C) +/** + * \brief Set the Diffie-Hellman public P and G values, + * read as hexadecimal strings (server-side only) + * (Default: MBEDTLS_DHM_RFC5114_MODP_2048_[PG]) + * + * \param conf SSL configuration + * \param dhm_P Diffie-Hellman-Merkle modulus + * \param dhm_G Diffie-Hellman-Merkle generator + * + * \return 0 if successful + */ +int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf, const char *dhm_P, const char *dhm_G ); + +/** + * \brief Set the Diffie-Hellman public P and G values, + * read from existing context (server-side only) + * + * \param conf SSL configuration + * \param dhm_ctx Diffie-Hellman-Merkle context + * + * \return 0 if successful + */ +int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx ); +#endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */ + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) +/** + * \brief Set the minimum length for Diffie-Hellman parameters. + * (Client-side only.) + * (Default: 1024 bits.) + * + * \param conf SSL configuration + * \param bitlen Minimum bit length of the DHM prime + */ +void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, + unsigned int bitlen ); +#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_ECP_C) +/** + * \brief Set the allowed curves in order of preference. + * (Default: all defined curves.) + * + * On server: this only affects selection of the ECDHE curve; + * the curves used for ECDH and ECDSA are determined by the + * list of available certificates instead. + * + * On client: this affects the list of curves offered for any + * use. The server can override our preference order. + * + * Both sides: limits the set of curves accepted for use in + * ECDHE and in the peer's end-entity certificate. + * + * \note This has no influence on which curves are allowed inside the + * certificate chains, see \c mbedtls_ssl_conf_cert_profile() + * for that. For the end-entity certificate however, the key + * will be accepted only if it is allowed both by this list + * and by the cert profile. + * + * \note This list should be ordered by decreasing preference + * (preferred curve first). + * + * \param conf SSL configuration + * \param curves Ordered list of allowed curves, + * terminated by MBEDTLS_ECP_DP_NONE. + */ +void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, + const mbedtls_ecp_group_id *curves ); +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +/** + * \brief Set the allowed hashes for signatures during the handshake. + * (Default: all available hashes except MD5.) + * + * \note This only affects which hashes are offered and can be used + * for signatures during the handshake. Hashes for message + * authentication and the TLS PRF are controlled by the + * ciphersuite, see \c mbedtls_ssl_conf_ciphersuites(). Hashes + * used for certificate signature are controlled by the + * verification profile, see \c mbedtls_ssl_conf_cert_profile(). + * + * \note This list should be ordered by decreasing preference + * (preferred hash first). + * + * \param conf SSL configuration + * \param hashes Ordered list of allowed signature hashes, + * terminated by \c MBEDTLS_MD_NONE. + */ +void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, + const int *hashes ); +#endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * \brief Set the hostname to check against the received server + * certificate. It sets the ServerName TLS extension too, + * if the extension is enabled. + * (client-side only) + * + * \param ssl SSL context + * \param hostname the server hostname + * + * \return 0 if successful or MBEDTLS_ERR_SSL_ALLOC_FAILED + */ +int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +/** + * \brief Set own certificate and key for the current handshake + * + * \note Same as \c mbedtls_ssl_conf_own_cert() but for use within + * the SNI callback. + * + * \param ssl SSL context + * \param own_cert own public certificate chain + * \param pk_key own private key + * + * \return 0 on success or MBEDTLS_ERR_SSL_ALLOC_FAILED + */ +int mbedtls_ssl_set_hs_own_cert( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *own_cert, + mbedtls_pk_context *pk_key ); + +/** + * \brief Set the data required to verify peer certificate for the + * current handshake + * + * \note Same as \c mbedtls_ssl_conf_ca_chain() but for use within + * the SNI callback. + * + * \param ssl SSL context + * \param ca_chain trusted CA chain (meaning all fully trusted top-level CAs) + * \param ca_crl trusted CA CRLs + */ +void mbedtls_ssl_set_hs_ca_chain( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *ca_chain, + mbedtls_x509_crl *ca_crl ); + +/** + * \brief Set authmode for the current handshake. + * + * \note Same as \c mbedtls_ssl_conf_authmode() but for use within + * the SNI callback. + * + * \param ssl SSL context + * \param authmode MBEDTLS_SSL_VERIFY_NONE, MBEDTLS_SSL_VERIFY_OPTIONAL or + * MBEDTLS_SSL_VERIFY_REQUIRED + */ +void mbedtls_ssl_set_hs_authmode( mbedtls_ssl_context *ssl, + int authmode ); + +/** + * \brief Set server side ServerName TLS extension callback + * (optional, server-side only). + * + * If set, the ServerName callback is called whenever the + * server receives a ServerName TLS extension from the client + * during a handshake. The ServerName callback has the + * following parameters: (void *parameter, mbedtls_ssl_context *ssl, + * const unsigned char *hostname, size_t len). If a suitable + * certificate is found, the callback must set the + * certificate(s) and key(s) to use with \c + * mbedtls_ssl_set_hs_own_cert() (can be called repeatedly), + * and may optionally adjust the CA and associated CRL with \c + * mbedtls_ssl_set_hs_ca_chain() as well as the client + * authentication mode with \c mbedtls_ssl_set_hs_authmode(), + * then must return 0. If no matching name is found, the + * callback must either set a default cert, or + * return non-zero to abort the handshake at this point. + * + * \param conf SSL configuration + * \param f_sni verification function + * \param p_sni verification parameter + */ +void mbedtls_ssl_conf_sni( mbedtls_ssl_config *conf, + int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, + size_t), + void *p_sni ); +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +/** + * \brief Set the EC J-PAKE password for current handshake. + * + * \note An internal copy is made, and destroyed as soon as the + * handshake is completed, or when the SSL context is reset or + * freed. + * + * \note The SSL context needs to be already set up. The right place + * to call this function is between \c mbedtls_ssl_setup() or + * \c mbedtls_ssl_reset() and \c mbedtls_ssl_handshake(). + * + * \param ssl SSL context + * \param pw EC J-PAKE password (pre-shared secret) + * \param pw_len length of pw in bytes + * + * \return 0 on success, or a negative error code. + */ +int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl, + const unsigned char *pw, + size_t pw_len ); +#endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN) +/** + * \brief Set the supported Application Layer Protocols. + * + * \param conf SSL configuration + * \param protos Pointer to a NULL-terminated list of supported protocols, + * in decreasing preference order. The pointer to the list is + * recorded by the library for later reference as required, so + * the lifetime of the table must be atleast as long as the + * lifetime of the SSL configuration structure. + * + * \return 0 on success, or MBEDTLS_ERR_SSL_BAD_INPUT_DATA. + */ +int mbedtls_ssl_conf_alpn_protocols( mbedtls_ssl_config *conf, const char **protos ); + +/** + * \brief Get the name of the negotiated Application Layer Protocol. + * This function should be called after the handshake is + * completed. + * + * \param ssl SSL context + * + * \return Protcol name, or NULL if no protocol was negotiated. + */ +const char *mbedtls_ssl_get_alpn_protocol( const mbedtls_ssl_context *ssl ); +#endif /* MBEDTLS_SSL_ALPN */ + +/** + * \brief Set the maximum supported version sent from the client side + * and/or accepted at the server side + * (Default: MBEDTLS_SSL_MAX_MAJOR_VERSION, MBEDTLS_SSL_MAX_MINOR_VERSION) + * + * \note This ignores ciphersuites from higher versions. + * + * \note With DTLS, use MBEDTLS_SSL_MINOR_VERSION_2 for DTLS 1.0 and + * MBEDTLS_SSL_MINOR_VERSION_3 for DTLS 1.2 + * + * \param conf SSL configuration + * \param major Major version number (only MBEDTLS_SSL_MAJOR_VERSION_3 supported) + * \param minor Minor version number (MBEDTLS_SSL_MINOR_VERSION_0, + * MBEDTLS_SSL_MINOR_VERSION_1 and MBEDTLS_SSL_MINOR_VERSION_2, + * MBEDTLS_SSL_MINOR_VERSION_3 supported) + */ +void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor ); + +/** + * \brief Set the minimum accepted SSL/TLS protocol version + * (Default: TLS 1.0) + * + * \note Input outside of the SSL_MAX_XXXXX_VERSION and + * SSL_MIN_XXXXX_VERSION range is ignored. + * + * \note MBEDTLS_SSL_MINOR_VERSION_0 (SSL v3) should be avoided. + * + * \note With DTLS, use MBEDTLS_SSL_MINOR_VERSION_2 for DTLS 1.0 and + * MBEDTLS_SSL_MINOR_VERSION_3 for DTLS 1.2 + * + * \param conf SSL configuration + * \param major Major version number (only MBEDTLS_SSL_MAJOR_VERSION_3 supported) + * \param minor Minor version number (MBEDTLS_SSL_MINOR_VERSION_0, + * MBEDTLS_SSL_MINOR_VERSION_1 and MBEDTLS_SSL_MINOR_VERSION_2, + * MBEDTLS_SSL_MINOR_VERSION_3 supported) + */ +void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor ); + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C) +/** + * \brief Set the fallback flag (client-side only). + * (Default: MBEDTLS_SSL_IS_NOT_FALLBACK). + * + * \note Set to MBEDTLS_SSL_IS_FALLBACK when preparing a fallback + * connection, that is a connection with max_version set to a + * lower value than the value you're willing to use. Such + * fallback connections are not recommended but are sometimes + * necessary to interoperate with buggy (version-intolerant) + * servers. + * + * \warning You should NOT set this to MBEDTLS_SSL_IS_FALLBACK for + * non-fallback connections! This would appear to work for a + * while, then cause failures when the server is upgraded to + * support a newer TLS version. + * + * \param conf SSL configuration + * \param fallback MBEDTLS_SSL_IS_NOT_FALLBACK or MBEDTLS_SSL_IS_FALLBACK + */ +void mbedtls_ssl_conf_fallback( mbedtls_ssl_config *conf, char fallback ); +#endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +/** + * \brief Enable or disable Encrypt-then-MAC + * (Default: MBEDTLS_SSL_ETM_ENABLED) + * + * \note This should always be enabled, it is a security + * improvement, and should not cause any interoperability + * issue (used only if the peer supports it too). + * + * \param conf SSL configuration + * \param etm MBEDTLS_SSL_ETM_ENABLED or MBEDTLS_SSL_ETM_DISABLED + */ +void mbedtls_ssl_conf_encrypt_then_mac( mbedtls_ssl_config *conf, char etm ); +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +/** + * \brief Enable or disable Extended Master Secret negotiation. + * (Default: MBEDTLS_SSL_EXTENDED_MS_ENABLED) + * + * \note This should always be enabled, it is a security fix to the + * protocol, and should not cause any interoperability issue + * (used only if the peer supports it too). + * + * \param conf SSL configuration + * \param ems MBEDTLS_SSL_EXTENDED_MS_ENABLED or MBEDTLS_SSL_EXTENDED_MS_DISABLED + */ +void mbedtls_ssl_conf_extended_master_secret( mbedtls_ssl_config *conf, char ems ); +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_ARC4_C) +/** + * \brief Disable or enable support for RC4 + * (Default: MBEDTLS_SSL_ARC4_DISABLED) + * + * \warning Use of RC4 in DTLS/TLS has been prohibited by RFC 7465 + * for security reasons. Use at your own risk. + * + * \note This function is deprecated and will likely be removed in + * a future version of the library. + * RC4 is disabled by default at compile time and needs to be + * actively enabled for use with legacy systems. + * + * \param conf SSL configuration + * \param arc4 MBEDTLS_SSL_ARC4_ENABLED or MBEDTLS_SSL_ARC4_DISABLED + */ +void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 ); +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +/** + * \brief Set the maximum fragment length to emit and/or negotiate + * (Default: MBEDTLS_SSL_MAX_CONTENT_LEN, usually 2^14 bytes) + * (Server: set maximum fragment length to emit, + * usually negotiated by the client during handshake + * (Client: set maximum fragment length to emit *and* + * negotiate with the server during handshake) + * + * \param conf SSL configuration + * \param mfl_code Code for maximum fragment length (allowed values: + * MBEDTLS_SSL_MAX_FRAG_LEN_512, MBEDTLS_SSL_MAX_FRAG_LEN_1024, + * MBEDTLS_SSL_MAX_FRAG_LEN_2048, MBEDTLS_SSL_MAX_FRAG_LEN_4096) + * + * \return 0 if successful or MBEDTLS_ERR_SSL_BAD_INPUT_DATA + */ +int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code ); +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +/** + * \brief Activate negotiation of truncated HMAC + * (Default: MBEDTLS_SSL_TRUNC_HMAC_DISABLED) + * + * \param conf SSL configuration + * \param truncate Enable or disable (MBEDTLS_SSL_TRUNC_HMAC_ENABLED or + * MBEDTLS_SSL_TRUNC_HMAC_DISABLED) + */ +void mbedtls_ssl_conf_truncated_hmac( mbedtls_ssl_config *conf, int truncate ); +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) +/** + * \brief Enable / Disable 1/n-1 record splitting + * (Default: MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED) + * + * \note Only affects SSLv3 and TLS 1.0, not higher versions. + * Does not affect non-CBC ciphersuites in any version. + * + * \param conf SSL configuration + * \param split MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED or + * MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED + */ +void mbedtls_ssl_conf_cbc_record_splitting( mbedtls_ssl_config *conf, char split ); +#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) +/** + * \brief Enable / Disable session tickets (client only). + * (Default: MBEDTLS_SSL_SESSION_TICKETS_ENABLED.) + * + * \note On server, use \c mbedtls_ssl_conf_session_tickets_cb(). + * + * \param conf SSL configuration + * \param use_tickets Enable or disable (MBEDTLS_SSL_SESSION_TICKETS_ENABLED or + * MBEDTLS_SSL_SESSION_TICKETS_DISABLED) + */ +void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets ); +#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +/** + * \brief Enable / Disable renegotiation support for connection when + * initiated by peer + * (Default: MBEDTLS_SSL_RENEGOTIATION_DISABLED) + * + * \warning It is recommended to always disable renegotation unless you + * know you need it and you know what you're doing. In the + * past, there have been several issues associated with + * renegotiation or a poor understanding of its properties. + * + * \note Server-side, enabling renegotiation also makes the server + * susceptible to a resource DoS by a malicious client. + * + * \param conf SSL configuration + * \param renegotiation Enable or disable (MBEDTLS_SSL_RENEGOTIATION_ENABLED or + * MBEDTLS_SSL_RENEGOTIATION_DISABLED) + */ +void mbedtls_ssl_conf_renegotiation( mbedtls_ssl_config *conf, int renegotiation ); +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +/** + * \brief Prevent or allow legacy renegotiation. + * (Default: MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION) + * + * MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION allows connections to + * be established even if the peer does not support + * secure renegotiation, but does not allow renegotiation + * to take place if not secure. + * (Interoperable and secure option) + * + * MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION allows renegotiations + * with non-upgraded peers. Allowing legacy renegotiation + * makes the connection vulnerable to specific man in the + * middle attacks. (See RFC 5746) + * (Most interoperable and least secure option) + * + * MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE breaks off connections + * if peer does not support secure renegotiation. Results + * in interoperability issues with non-upgraded peers + * that do not support renegotiation altogether. + * (Most secure option, interoperability issues) + * + * \param conf SSL configuration + * \param allow_legacy Prevent or allow (SSL_NO_LEGACY_RENEGOTIATION, + * SSL_ALLOW_LEGACY_RENEGOTIATION or + * MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE) + */ +void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +/** + * \brief Enforce renegotiation requests. + * (Default: enforced, max_records = 16) + * + * When we request a renegotiation, the peer can comply or + * ignore the request. This function allows us to decide + * whether to enforce our renegotiation requests by closing + * the connection if the peer doesn't comply. + * + * However, records could already be in transit from the peer + * when the request is emitted. In order to increase + * reliability, we can accept a number of records before the + * expected handshake records. + * + * The optimal value is highly dependent on the specific usage + * scenario. + * + * \note With DTLS and server-initiated renegotiation, the + * HelloRequest is retransmited every time mbedtls_ssl_read() times + * out or receives Application Data, until: + * - max_records records have beens seen, if it is >= 0, or + * - the number of retransmits that would happen during an + * actual handshake has been reached. + * Please remember the request might be lost a few times + * if you consider setting max_records to a really low value. + * + * \warning On client, the grace period can only happen during + * mbedtls_ssl_read(), as opposed to mbedtls_ssl_write() and mbedtls_ssl_renegotiate() + * which always behave as if max_record was 0. The reason is, + * if we receive application data from the server, we need a + * place to write it, which only happens during mbedtls_ssl_read(). + * + * \param conf SSL configuration + * \param max_records Use MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED if you don't want to + * enforce renegotiation, or a non-negative value to enforce + * it but allow for a grace period of max_records records. + */ +void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_records ); + +/** + * \brief Set record counter threshold for periodic renegotiation. + * (Default: 2^48 - 1) + * + * Renegotiation is automatically triggered when a record + * counter (outgoing or ingoing) crosses the defined + * threshold. The default value is meant to prevent the + * connection from being closed when the counter is about to + * reached its maximal value (it is not allowed to wrap). + * + * Lower values can be used to enforce policies such as "keys + * must be refreshed every N packets with cipher X". + * + * The renegotiation period can be disabled by setting + * conf->disable_renegotiation to + * MBEDTLS_SSL_RENEGOTIATION_DISABLED. + * + * \note When the configured transport is + * MBEDTLS_SSL_TRANSPORT_DATAGRAM the maximum renegotiation + * period is 2^48 - 1, and for MBEDTLS_SSL_TRANSPORT_STREAM, + * the maximum renegotiation period is 2^64 - 1. + * + * \param conf SSL configuration + * \param period The threshold value: a big-endian 64-bit number. + */ +void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf, + const unsigned char period[8] ); +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +/** + * \brief Return the number of data bytes available to read + * + * \param ssl SSL context + * + * \return how many bytes are available in the read buffer + */ +size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl ); + +/** + * \brief Return the result of the certificate verification + * + * \param ssl SSL context + * + * \return 0 if successful, + * -1 if result is not available (eg because the handshake was + * aborted too early), or + * a combination of BADCERT_xxx and BADCRL_xxx flags, see + * x509.h + */ +uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl ); + +/** + * \brief Return the name of the current ciphersuite + * + * \param ssl SSL context + * + * \return a string containing the ciphersuite name + */ +const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl ); + +/** + * \brief Return the current SSL version (SSLv3/TLSv1/etc) + * + * \param ssl SSL context + * + * \return a string containing the SSL version + */ +const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl ); + +/** + * \brief Return the (maximum) number of bytes added by the record + * layer: header + encryption/MAC overhead (inc. padding) + * + * \param ssl SSL context + * + * \return Current maximum record expansion in bytes, or + * MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE if compression is + * enabled, which makes expansion much less predictable + */ +int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ); + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +/** + * \brief Return the maximum fragment length (payload, in bytes). + * This is the value negotiated with peer if any, + * or the locally configured value. + * + * \note With DTLS, \c mbedtls_ssl_write() will return an error if + * called with a larger length value. + * With TLS, \c mbedtls_ssl_write() will fragment the input if + * necessary and return the number of bytes written; it is up + * to the caller to call \c mbedtls_ssl_write() again in + * order to send the remaining bytes if any. + * + * \param ssl SSL context + * + * \return Current maximum fragment length. + */ +size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl ); +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * \brief Return the peer certificate from the current connection + * + * Note: Can be NULL in case no certificate was sent during + * the handshake. Different calls for the same connection can + * return the same or different pointers for the same + * certificate and even a different certificate altogether. + * The peer cert CAN change in a single connection if + * renegotiation is performed. + * + * \param ssl SSL context + * + * \return the current peer certificate + */ +const mbedtls_x509_crt *mbedtls_ssl_get_peer_cert( const mbedtls_ssl_context *ssl ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_CLI_C) +/** + * \brief Save session in order to resume it later (client-side only) + * Session data is copied to presented session structure. + * + * \warning Currently, peer certificate is lost in the operation. + * + * \param ssl SSL context + * \param session session context + * + * \return 0 if successful, + * MBEDTLS_ERR_SSL_ALLOC_FAILED if memory allocation failed, + * MBEDTLS_ERR_SSL_BAD_INPUT_DATA if used server-side or + * arguments are otherwise invalid + * + * \sa mbedtls_ssl_set_session() + */ +int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session *session ); +#endif /* MBEDTLS_SSL_CLI_C */ + +/** + * \brief Perform the SSL handshake + * + * \param ssl SSL context + * + * \return 0 if successful, or + * MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or + * MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED (see below), or + * a specific SSL error code. + * + * \note If this function returns something other than 0 or + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + * + * \note If DTLS is in use, then you may choose to handle + * MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging + * purposes, as it is an expected return value rather than an + * actual error, but you still need to reset/free the context. + */ +int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl ); + +/** + * \brief Perform a single step of the SSL handshake + * + * \note The state of the context (ssl->state) will be at + * the next state after execution of this function. Do not + * call this function if state is MBEDTLS_SSL_HANDSHAKE_OVER. + * + * \note If this function returns something other than 0 or + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + * + * \param ssl SSL context + * + * \return 0 if successful, or + * MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or + * a specific SSL error code. + */ +int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +/** + * \brief Initiate an SSL renegotiation on the running connection. + * Client: perform the renegotiation right now. + * Server: request renegotiation, which will be performed + * during the next call to mbedtls_ssl_read() if honored by + * client. + * + * \param ssl SSL context + * + * \return 0 if successful, or any mbedtls_ssl_handshake() return + * value. + * + * \note If this function returns something other than 0 or + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + */ +int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl ); +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +/** + * \brief Read at most 'len' application data bytes + * + * \param ssl SSL context + * \param buf buffer that will hold the data + * \param len maximum number of bytes to read + * + * \return the number of bytes read, or + * 0 for EOF, or + * MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or + * MBEDTLS_ERR_SSL_CLIENT_RECONNECT (see below), or + * another negative error code. + * + * \note If this function returns something other than a positive + * value or MBEDTLS_ERR_SSL_WANT_READ/WRITE or + * MBEDTLS_ERR_SSL_CLIENT_RECONNECT, then the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + * + * \note When this function return MBEDTLS_ERR_SSL_CLIENT_RECONNECT + * (which can only happen server-side), it means that a client + * is initiating a new connection using the same source port. + * You can either treat that as a connection close and wait + * for the client to resend a ClientHello, or directly + * continue with \c mbedtls_ssl_handshake() with the same + * context (as it has beeen reset internally). Either way, you + * should make sure this is seen by the application as a new + * connection: application state, if any, should be reset, and + * most importantly the identity of the client must be checked + * again. WARNING: not validating the identity of the client + * again, or not transmitting the new identity to the + * application layer, would allow authentication bypass! + */ +int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ); + +/** + * \brief Try to write exactly 'len' application data bytes + * + * \warning This function will do partial writes in some cases. If the + * return value is non-negative but less than length, the + * function must be called again with updated arguments: + * buf + ret, len - ret (if ret is the return value) until + * it returns a value equal to the last 'len' argument. + * + * \param ssl SSL context + * \param buf buffer holding the data + * \param len how many bytes must be written + * + * \return the number of bytes actually written (may be less than len), + * or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ, + * or another negative error code. + * + * \note If this function returns something other than a positive + * value or MBEDTLS_ERR_SSL_WANT_READ/WRITE, the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + * + * \note When this function returns MBEDTLS_ERR_SSL_WANT_WRITE/READ, + * it must be called later with the *same* arguments, + * until it returns a positive value. + * + * \note If the requested length is greater than the maximum + * fragment length (either the built-in limit or the one set + * or negotiated with the peer), then: + * - with TLS, less bytes than requested are written. + * - with DTLS, MBEDTLS_ERR_SSL_BAD_INPUT_DATA is returned. + * \c mbedtls_ssl_get_max_frag_len() may be used to query the + * active maximum fragment length. + */ +int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len ); + +/** + * \brief Send an alert message + * + * \param ssl SSL context + * \param level The alert level of the message + * (MBEDTLS_SSL_ALERT_LEVEL_WARNING or MBEDTLS_SSL_ALERT_LEVEL_FATAL) + * \param message The alert message (SSL_ALERT_MSG_*) + * + * \return 0 if successful, or a specific SSL error code. + * + * \note If this function returns something other than 0 or + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + */ +int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl, + unsigned char level, + unsigned char message ); +/** + * \brief Notify the peer that the connection is being closed + * + * \param ssl SSL context + * + * \return 0 if successful, or a specific SSL error code. + * + * \note If this function returns something other than 0 or + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context + * becomes unusable, and you should either free it or call + * \c mbedtls_ssl_session_reset() on it before re-using it for + * a new connection; the current connection must be closed. + */ +int mbedtls_ssl_close_notify( mbedtls_ssl_context *ssl ); + +/** + * \brief Free referenced items in an SSL context and clear memory + * + * \param ssl SSL context + */ +void mbedtls_ssl_free( mbedtls_ssl_context *ssl ); + +/** + * \brief Initialize an SSL configuration context + * Just makes the context ready for + * mbedtls_ssl_config_defaults() or mbedtls_ssl_config_free(). + * + * \note You need to call mbedtls_ssl_config_defaults() unless you + * manually set all of the relevent fields yourself. + * + * \param conf SSL configuration context + */ +void mbedtls_ssl_config_init( mbedtls_ssl_config *conf ); + +/** + * \brief Load reasonnable default SSL configuration values. + * (You need to call mbedtls_ssl_config_init() first.) + * + * \param conf SSL configuration context + * \param endpoint MBEDTLS_SSL_IS_CLIENT or MBEDTLS_SSL_IS_SERVER + * \param transport MBEDTLS_SSL_TRANSPORT_STREAM for TLS, or + * MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS + * \param preset a MBEDTLS_SSL_PRESET_XXX value + * + * \note See \c mbedtls_ssl_conf_transport() for notes on DTLS. + * + * \return 0 if successful, or + * MBEDTLS_ERR_XXX_ALLOC_FAILED on memory allocation error. + */ +int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, + int endpoint, int transport, int preset ); + +/** + * \brief Free an SSL configuration context + * + * \param conf SSL configuration context + */ +void mbedtls_ssl_config_free( mbedtls_ssl_config *conf ); + +/** + * \brief Initialize SSL session structure + * + * \param session SSL session + */ +void mbedtls_ssl_session_init( mbedtls_ssl_session *session ); + +/** + * \brief Free referenced items in an SSL session including the + * peer certificate and clear memory + * + * \param session SSL session + */ +void mbedtls_ssl_session_free( mbedtls_ssl_session *session ); + +#ifdef __cplusplus +} +#endif + +#endif /* ssl.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cache.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cache.h new file mode 100644 index 0000000..3734bb7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cache.h @@ -0,0 +1,143 @@ +/** + * \file ssl_cache.h + * + * \brief SSL session cache implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SSL_CACHE_H +#define MBEDTLS_SSL_CACHE_H + +#include "ssl.h" + +#if defined(MBEDTLS_THREADING_C) +#include "threading.h" +#endif + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +#if !defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT) +#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /*!< 1 day */ +#endif + +#if !defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES) +#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /*!< Maximum entries in cache */ +#endif + +/* \} name SECTION: Module settings */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct mbedtls_ssl_cache_context mbedtls_ssl_cache_context; +typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry; + +/** + * \brief This structure is used for storing cache entries + */ +struct mbedtls_ssl_cache_entry +{ +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t timestamp; /*!< entry timestamp */ +#endif + mbedtls_ssl_session session; /*!< entry session */ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_buf peer_cert; /*!< entry peer_cert */ +#endif + mbedtls_ssl_cache_entry *next; /*!< chain pointer */ +}; + +/** + * \brief Cache context + */ +struct mbedtls_ssl_cache_context +{ + mbedtls_ssl_cache_entry *chain; /*!< start of the chain */ + int timeout; /*!< cache entry timeout */ + int max_entries; /*!< maximum entries */ +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; /*!< mutex */ +#endif +}; + +/** + * \brief Initialize an SSL cache context + * + * \param cache SSL cache context + */ +void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache ); + +/** + * \brief Cache get callback implementation + * (Thread-safe if MBEDTLS_THREADING_C is enabled) + * + * \param data SSL cache context + * \param session session to retrieve entry for + */ +int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ); + +/** + * \brief Cache set callback implementation + * (Thread-safe if MBEDTLS_THREADING_C is enabled) + * + * \param data SSL cache context + * \param session session to store entry for + */ +int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ); + +#if defined(MBEDTLS_HAVE_TIME) +/** + * \brief Set the cache timeout + * (Default: MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT (1 day)) + * + * A timeout of 0 indicates no timeout. + * + * \param cache SSL cache context + * \param timeout cache entry timeout in seconds + */ +void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout ); +#endif /* MBEDTLS_HAVE_TIME */ + +/** + * \brief Set the maximum number of cache entries + * (Default: MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES (50)) + * + * \param cache SSL cache context + * \param max cache entry maximum + */ +void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max ); + +/** + * \brief Free referenced items in a cache context and clear memory + * + * \param cache SSL cache context + */ +void mbedtls_ssl_cache_free( mbedtls_ssl_cache_context *cache ); + +#ifdef __cplusplus +} +#endif + +#endif /* ssl_cache.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ciphersuites.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ciphersuites.h new file mode 100644 index 0000000..deaaa37 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ciphersuites.h @@ -0,0 +1,321 @@ +/** + * \file ssl_ciphersuites.h + * + * \brief SSL Ciphersuites for mbed TLS + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SSL_CIPHERSUITES_H +#define MBEDTLS_SSL_CIPHERSUITES_H + +#include "pk.h" +#include "cipher.h" +#include "md.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Supported ciphersuites (Official IANA names) + */ +#define MBEDTLS_TLS_RSA_WITH_NULL_MD5 0x01 /**< Weak! */ +#define MBEDTLS_TLS_RSA_WITH_NULL_SHA 0x02 /**< Weak! */ + +#define MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 0x04 +#define MBEDTLS_TLS_RSA_WITH_RC4_128_SHA 0x05 +#define MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA 0x09 /**< Weak! Not in TLS 1.2 */ + +#define MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x0A + +#define MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA 0x15 /**< Weak! Not in TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x16 + +#define MBEDTLS_TLS_PSK_WITH_NULL_SHA 0x2C /**< Weak! */ +#define MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA 0x2D /**< Weak! */ +#define MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA 0x2E /**< Weak! */ +#define MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA 0x2F + +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x33 +#define MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA 0x35 +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x39 + +#define MBEDTLS_TLS_RSA_WITH_NULL_SHA256 0x3B /**< Weak! */ +#define MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 0x3C /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 0x3D /**< TLS 1.2 */ + +#define MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA 0x41 +#define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x45 + +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x67 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x6B /**< TLS 1.2 */ + +#define MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA 0x84 +#define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x88 + +#define MBEDTLS_TLS_PSK_WITH_RC4_128_SHA 0x8A +#define MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA 0x8B +#define MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA 0x8C +#define MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA 0x8D + +#define MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA 0x8E +#define MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA 0x8F +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA 0x90 +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA 0x91 + +#define MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA 0x92 +#define MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA 0x93 +#define MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA 0x94 +#define MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA 0x95 + +#define MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 0x9C /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 0x9D /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 0x9E /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 0x9F /**< TLS 1.2 */ + +#define MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 0xA8 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 0xA9 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 0xAA /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 0xAB /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 0xAC /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 0xAD /**< TLS 1.2 */ + +#define MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 0xAE +#define MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 0xAF +#define MBEDTLS_TLS_PSK_WITH_NULL_SHA256 0xB0 /**< Weak! */ +#define MBEDTLS_TLS_PSK_WITH_NULL_SHA384 0xB1 /**< Weak! */ + +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 0xB2 +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 0xB3 +#define MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 0xB4 /**< Weak! */ +#define MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 0xB5 /**< Weak! */ + +#define MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 0xB6 +#define MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 0xB7 +#define MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 0xB8 /**< Weak! */ +#define MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 0xB9 /**< Weak! */ + +#define MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xBA /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xBE /**< TLS 1.2 */ + +#define MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 0xC0 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0xC4 /**< TLS 1.2 */ + +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA 0xC001 /**< Weak! */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA 0xC002 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA 0xC003 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0xC004 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0xC005 /**< Not in SSL3! */ + +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA 0xC006 /**< Weak! */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA 0xC007 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA 0xC008 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0xC009 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0xC00A /**< Not in SSL3! */ + +#define MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA 0xC00B /**< Weak! */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA 0xC00C /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA 0xC00D /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA 0xC00E /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA 0xC00F /**< Not in SSL3! */ + +#define MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA 0xC010 /**< Weak! */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA 0xC011 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA 0xC012 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA 0xC013 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA 0xC014 /**< Not in SSL3! */ + +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 0xC023 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 0xC024 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 0xC025 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 0xC026 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 0xC027 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 0xC028 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 0xC029 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 0xC02A /**< TLS 1.2 */ + +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0xC02B /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0xC02C /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0xC02D /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0xC02E /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0xC02F /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0xC030 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 0xC031 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 0xC032 /**< TLS 1.2 */ + +#define MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA 0xC033 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 0xC034 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA 0xC035 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA 0xC036 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0xC037 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0xC038 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA 0xC039 /**< Weak! No SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 0xC03A /**< Weak! No SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 0xC03B /**< Weak! No SSL3! */ + +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC072 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC073 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC074 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC075 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xC076 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0xC077 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xC078 /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0xC079 /**< Not in SSL3! */ + +#define MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 0xC07A /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 0xC07B /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 0xC07C /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 0xC07D /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 0xC086 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 0xC087 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 0xC088 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 0xC089 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 0xC08A /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 0xC08B /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 0xC08C /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 0xC08D /**< TLS 1.2 */ + +#define MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC08E /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC08F /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC090 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC091 /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC092 /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC093 /**< TLS 1.2 */ + +#define MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 0xC094 +#define MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 0xC095 +#define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0xC096 +#define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0xC097 +#define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 0xC098 +#define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 0xC099 +#define MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0xC09A /**< Not in SSL3! */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0xC09B /**< Not in SSL3! */ + +#define MBEDTLS_TLS_RSA_WITH_AES_128_CCM 0xC09C /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_AES_256_CCM 0xC09D /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM 0xC09E /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM 0xC09F /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8 0xC0A0 /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8 0xC0A1 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8 0xC0A2 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8 0xC0A3 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_AES_128_CCM 0xC0A4 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_AES_256_CCM 0xC0A5 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM 0xC0A6 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM 0xC0A7 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 0xC0A8 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8 0xC0A9 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8 0xC0AA /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8 0xC0AB /**< TLS 1.2 */ +/* The last two are named with PSK_DHE in the RFC, which looks like a typo */ + +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM 0xC0AC /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM 0xC0AD /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 0xC0AF /**< TLS 1.2 */ + +#define MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 0xC0FF /**< experimental */ + +/* Reminder: update mbedtls_ssl_premaster_secret when adding a new key exchange. + * Reminder: update MBEDTLS_KEY_EXCHANGE__xxx below + */ +typedef enum { + MBEDTLS_KEY_EXCHANGE_NONE = 0, + MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_KEY_EXCHANGE_ECJPAKE, +} mbedtls_key_exchange_type_t; + +/* Key exchanges using a certificate */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED +#endif + +/* Key exchanges using a PSK */ +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED +#endif + +/* Key exchanges using a ECDHE */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED +#endif + +typedef struct mbedtls_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t; + +#define MBEDTLS_CIPHERSUITE_WEAK 0x01 /**< Weak ciphersuite flag */ +#define MBEDTLS_CIPHERSUITE_SHORT_TAG 0x02 /**< Short authentication tag, + eg for CCM_8 */ +#define MBEDTLS_CIPHERSUITE_NODTLS 0x04 /**< Can't be used with DTLS */ + +/** + * \brief This structure is used for storing ciphersuite information + */ +struct mbedtls_ssl_ciphersuite_t +{ + int id; + const char * name; + + mbedtls_cipher_type_t cipher; + mbedtls_md_type_t mac; + mbedtls_key_exchange_type_t key_exchange; + + int min_major_ver; + int min_minor_ver; + int max_major_ver; + int max_minor_ver; + + unsigned char flags; +}; + +const int *mbedtls_ssl_list_ciphersuites( void ); + +const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string( const char *ciphersuite_name ); +const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuite_id ); + +#if defined(MBEDTLS_PK_C) +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg( const mbedtls_ssl_ciphersuite_t *info ); +#endif + +int mbedtls_ssl_ciphersuite_uses_ec( const mbedtls_ssl_ciphersuite_t *info ); +int mbedtls_ssl_ciphersuite_uses_psk( const mbedtls_ssl_ciphersuite_t *info ); + +#ifdef __cplusplus +} +#endif + +#endif /* ssl_ciphersuites.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cookie.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cookie.h new file mode 100644 index 0000000..037e1c3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_cookie.h @@ -0,0 +1,108 @@ +/** + * \file ssl_cookie.h + * + * \brief DTLS cookie callbacks implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SSL_COOKIE_H +#define MBEDTLS_SSL_COOKIE_H + +#include "ssl.h" + +#if defined(MBEDTLS_THREADING_C) +#include "threading.h" +#endif + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ +#ifndef MBEDTLS_SSL_COOKIE_TIMEOUT +#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ +#endif + +/* \} name SECTION: Module settings */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Context for the default cookie functions. + */ +typedef struct +{ + mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */ +#if !defined(MBEDTLS_HAVE_TIME) + unsigned long serial; /*!< serial number for expiration */ +#endif + unsigned long timeout; /*!< timeout delay, in seconds if HAVE_TIME, + or in number of tickets issued */ + +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; +#endif +} mbedtls_ssl_cookie_ctx; + +/** + * \brief Initialize cookie context + */ +void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx ); + +/** + * \brief Setup cookie context (generate keys) + */ +int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief Set expiration delay for cookies + * (Default MBEDTLS_SSL_COOKIE_TIMEOUT) + * + * \param ctx Cookie contex + * \param delay Delay, in seconds if HAVE_TIME, or in number of cookies + * issued in the meantime. + * 0 to disable expiration (NOT recommended) + */ +void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay ); + +/** + * \brief Free cookie context + */ +void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ); + +/** + * \brief Generate cookie, see \c mbedtls_ssl_cookie_write_t + */ +mbedtls_ssl_cookie_write_t mbedtls_ssl_cookie_write; + +/** + * \brief Verify cookie, see \c mbedtls_ssl_cookie_write_t + */ +mbedtls_ssl_cookie_check_t mbedtls_ssl_cookie_check; + +#ifdef __cplusplus +} +#endif + +#endif /* ssl_cookie.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_internal.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_internal.h new file mode 100644 index 0000000..668c0f5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_internal.h @@ -0,0 +1,500 @@ +/** + * \file ssl_ticket.h + * + * \brief Internal functions shared by the SSL modules + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SSL_INTERNAL_H +#define MBEDTLS_SSL_INTERNAL_H + +#include "ssl.h" + +#if defined(MBEDTLS_MD5_C) +#include "md5.h" +#endif + +#if defined(MBEDTLS_SHA1_C) +#include "sha1.h" +#endif + +#if defined(MBEDTLS_SHA256_C) +#include "sha256.h" +#endif + +#if defined(MBEDTLS_SHA512_C) +#include "sha512.h" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +#include "ecjpake.h" +#endif + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +/* Determine minimum supported version */ +#define MBEDTLS_SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3 + +#if defined(MBEDTLS_SSL_PROTO_SSL3) +#define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_0 +#else +#if defined(MBEDTLS_SSL_PROTO_TLS1) +#define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_1 +#else +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) +#define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_2 +#else +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_3 +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1 */ +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +/* Determine maximum supported version */ +#define MBEDTLS_SSL_MAX_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3 + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_3 +#else +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) +#define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_2 +#else +#if defined(MBEDTLS_SSL_PROTO_TLS1) +#define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_1 +#else +#if defined(MBEDTLS_SSL_PROTO_SSL3) +#define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_0 +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#define MBEDTLS_SSL_INITIAL_HANDSHAKE 0 +#define MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS 1 /* In progress */ +#define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */ +#define MBEDTLS_SSL_RENEGOTIATION_PENDING 3 /* Requested (server only) */ + +/* + * DTLS retransmission states, see RFC 6347 4.2.4 + * + * The SENDING state is merged in PREPARING for initial sends, + * but is distinct for resends. + * + * Note: initial state is wrong for server, but is not used anyway. + */ +#define MBEDTLS_SSL_RETRANS_PREPARING 0 +#define MBEDTLS_SSL_RETRANS_SENDING 1 +#define MBEDTLS_SSL_RETRANS_WAITING 2 +#define MBEDTLS_SSL_RETRANS_FINISHED 3 + +/* + * Allow extra bytes for record, authentication and encryption overhead: + * counter (8) + header (5) + IV(16) + MAC (16-48) + padding (0-256) + * and allow for a maximum of 1024 of compression expansion if + * enabled. + */ +#if defined(MBEDTLS_ZLIB_SUPPORT) +#define MBEDTLS_SSL_COMPRESSION_ADD 1024 +#else +#define MBEDTLS_SSL_COMPRESSION_ADD 0 +#endif + +#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_MODE_CBC) +/* Ciphersuites using HMAC */ +#if defined(MBEDTLS_SHA512_C) +#define MBEDTLS_SSL_MAC_ADD 48 /* SHA-384 used for HMAC */ +#elif defined(MBEDTLS_SHA256_C) +#define MBEDTLS_SSL_MAC_ADD 32 /* SHA-256 used for HMAC */ +#else +#define MBEDTLS_SSL_MAC_ADD 20 /* SHA-1 used for HMAC */ +#endif +#else +/* AEAD ciphersuites: GCM and CCM use a 128 bits tag */ +#define MBEDTLS_SSL_MAC_ADD 16 +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#define MBEDTLS_SSL_PADDING_ADD 256 +#else +#define MBEDTLS_SSL_PADDING_ADD 0 +#endif + +#define MBEDTLS_SSL_BUFFER_LEN ( MBEDTLS_SSL_MAX_CONTENT_LEN \ + + MBEDTLS_SSL_COMPRESSION_ADD \ + + 29 /* counter + header + IV */ \ + + MBEDTLS_SSL_MAC_ADD \ + + MBEDTLS_SSL_PADDING_ADD \ + ) + +/* + * TLS extension flags (for extensions with outgoing ServerHello content + * that need it (e.g. for RENEGOTIATION_INFO the server already knows because + * of state of the renegotiation flag, so no indicator is required) + */ +#define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT (1 << 0) +#define MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK (1 << 1) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This structure contains the parameters only needed during handshake. + */ +struct mbedtls_ssl_handshake_params +{ + /* + * Handshake specific crypto variables + */ + int sig_alg; /*!< Hash algorithm for signature */ + int verify_sig_alg; /*!< Signature algorithm for verify */ +#if defined(MBEDTLS_DHM_C) + mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */ +#endif +#if defined(MBEDTLS_ECDH_C) + mbedtls_ecdh_context ecdh_ctx; /*!< ECDH key exchange */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + mbedtls_ecjpake_context ecjpake_ctx; /*!< EC J-PAKE key exchange */ +#if defined(MBEDTLS_SSL_CLI_C) + unsigned char *ecjpake_cache; /*!< Cache for ClientHello ext */ + size_t ecjpake_cache_len; /*!< Length of cached data */ +#endif +#endif +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + const mbedtls_ecp_curve_info **curves; /*!< Supported elliptic curves */ +#endif +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + unsigned char *psk; /*!< PSK from the callback */ + size_t psk_len; /*!< Length of PSK from callback */ +#endif +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_ssl_key_cert *key_cert; /*!< chosen key/cert pair (server) */ +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + int sni_authmode; /*!< authmode from SNI callback */ + mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */ + mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */ + mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */ +#endif +#endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + unsigned int out_msg_seq; /*!< Outgoing handshake sequence number */ + unsigned int in_msg_seq; /*!< Incoming handshake sequence number */ + + unsigned char *verify_cookie; /*!< Cli: HelloVerifyRequest cookie + Srv: unused */ + unsigned char verify_cookie_len; /*!< Cli: cookie length + Srv: flag for sending a cookie */ + + unsigned char *hs_msg; /*!< Reassembled handshake message */ + + uint32_t retransmit_timeout; /*!< Current value of timeout */ + unsigned char retransmit_state; /*!< Retransmission state */ + mbedtls_ssl_flight_item *flight; /*!< Current outgoing flight */ + mbedtls_ssl_flight_item *cur_msg; /*!< Current message in flight */ + unsigned int in_flight_start_seq; /*!< Minimum message sequence in the + flight being received */ + mbedtls_ssl_transform *alt_transform_out; /*!< Alternative transform for + resending messages */ + unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter + for resending messages */ +#endif + + /* + * Checksum contexts + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + mbedtls_md5_context fin_md5; + mbedtls_sha1_context fin_sha1; +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) + mbedtls_sha256_context fin_sha256; +#endif +#if defined(MBEDTLS_SHA512_C) + mbedtls_sha512_context fin_sha512; +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + void (*update_checksum)(mbedtls_ssl_context *, const unsigned char *, size_t); + void (*calc_verify)(mbedtls_ssl_context *, unsigned char *); + void (*calc_finished)(mbedtls_ssl_context *, unsigned char *, int); + int (*tls_prf)(const unsigned char *, size_t, const char *, + const unsigned char *, size_t, + unsigned char *, size_t); + + size_t pmslen; /*!< premaster length */ + + unsigned char randbytes[64]; /*!< random bytes */ + unsigned char premaster[MBEDTLS_PREMASTER_SIZE]; + /*!< premaster secret */ + + int resume; /*!< session resume indicator*/ + int max_major_ver; /*!< max. major version client*/ + int max_minor_ver; /*!< max. minor version client*/ + int cli_exts; /*!< client extension presence*/ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + int new_session_ticket; /*!< use NewSessionTicket? */ +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + int extended_ms; /*!< use Extended Master Secret? */ +#endif +}; + +/* + * This structure contains a full set of runtime transform parameters + * either in negotiation or active. + */ +struct mbedtls_ssl_transform +{ + /* + * Session specific crypto layer + */ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + /*!< Chosen cipersuite_info */ + unsigned int keylen; /*!< symmetric key length (bytes) */ + size_t minlen; /*!< min. ciphertext length */ + size_t ivlen; /*!< IV length */ + size_t fixed_ivlen; /*!< Fixed part of IV (AEAD) */ + size_t maclen; /*!< MAC length */ + + unsigned char iv_enc[16]; /*!< IV (encryption) */ + unsigned char iv_dec[16]; /*!< IV (decryption) */ + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + /* Needed only for SSL v3.0 secret */ + unsigned char mac_enc[20]; /*!< SSL v3.0 secret (enc) */ + unsigned char mac_dec[20]; /*!< SSL v3.0 secret (dec) */ +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + + mbedtls_md_context_t md_ctx_enc; /*!< MAC (encryption) */ + mbedtls_md_context_t md_ctx_dec; /*!< MAC (decryption) */ + + mbedtls_cipher_context_t cipher_ctx_enc; /*!< encryption context */ + mbedtls_cipher_context_t cipher_ctx_dec; /*!< decryption context */ + + /* + * Session specific compression layer + */ +#if defined(MBEDTLS_ZLIB_SUPPORT) + z_stream ctx_deflate; /*!< compression context */ + z_stream ctx_inflate; /*!< decompression context */ +#endif +}; + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/* + * List of certificate + private key pairs + */ +struct mbedtls_ssl_key_cert +{ + mbedtls_x509_crt *cert; /*!< cert */ + mbedtls_pk_context *key; /*!< private key */ + mbedtls_ssl_key_cert *next; /*!< next key/cert pair */ +}; +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +/* + * List of handshake messages kept around for resending + */ +struct mbedtls_ssl_flight_item +{ + unsigned char *p; /*!< message, including handshake headers */ + size_t len; /*!< length of p */ + unsigned char type; /*!< type of the message: handshake or CCS */ + mbedtls_ssl_flight_item *next; /*!< next handshake message(s) */ +}; +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + +/** + * \brief Free referenced items in an SSL transform context and clear + * memory + * + * \param transform SSL transform context + */ +void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ); + +/** + * \brief Free referenced items in an SSL handshake context and clear + * memory + * + * \param handshake SSL handshake context + */ +void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake ); + +int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); +void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ); + +void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ); +void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ); + +int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_write_change_cipher_spec( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ); + +void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl, + const mbedtls_ssl_ciphersuite_t *ciphersuite_info ); + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exchange_type_t key_ex ); +#endif + +#if defined(MBEDTLS_PK_C) +unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk ); +mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig ); +#endif + +mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash ); +unsigned char mbedtls_ssl_hash_from_md_alg( int md ); +int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md ); + +#if defined(MBEDTLS_ECP_C) +int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id ); +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl, + mbedtls_md_type_t md ); +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +static inline mbedtls_pk_context *mbedtls_ssl_own_key( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_key_cert *key_cert; + + if( ssl->handshake != NULL && ssl->handshake->key_cert != NULL ) + key_cert = ssl->handshake->key_cert; + else + key_cert = ssl->conf->key_cert; + + return( key_cert == NULL ? NULL : key_cert->key ); +} + +static inline mbedtls_x509_crt *mbedtls_ssl_own_cert( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_key_cert *key_cert; + + if( ssl->handshake != NULL && ssl->handshake->key_cert != NULL ) + key_cert = ssl->handshake->key_cert; + else + key_cert = ssl->conf->key_cert; + + return( key_cert == NULL ? NULL : key_cert->cert ); +} + +/* + * Check usage of a certificate wrt extensions: + * keyUsage, extendedKeyUsage (later), and nSCertType (later). + * + * Warning: cert_endpoint is the endpoint of the cert (ie, of our peer when we + * check a cert we received from them)! + * + * Return 0 if everything is OK, -1 if not. + */ +int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt *cert, + const mbedtls_ssl_ciphersuite_t *ciphersuite, + int cert_endpoint, + uint32_t *flags ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +void mbedtls_ssl_write_version( int major, int minor, int transport, + unsigned char ver[2] ); +void mbedtls_ssl_read_version( int *major, int *minor, int transport, + const unsigned char ver[2] ); + +static inline size_t mbedtls_ssl_hdr_len( const mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + return( 13 ); +#else + ((void) ssl); +#endif + return( 5 ); +} + +static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + return( 12 ); +#else + ((void) ssl); +#endif + return( 4 ); +} + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl ); +void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ); +#endif + +/* Visible for testing purposes only */ +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +int mbedtls_ssl_dtls_replay_check( mbedtls_ssl_context *ssl ); +void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl ); +#endif + +/* constant-time buffer comparison */ +static inline int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n ) +{ + size_t i; + const unsigned char *A = (const unsigned char *) a; + const unsigned char *B = (const unsigned char *) b; + unsigned char diff = 0; + + for( i = 0; i < n; i++ ) + diff |= A[i] ^ B[i]; + + return( diff ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* ssl_internal.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ticket.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ticket.h new file mode 100644 index 0000000..7c6bc61 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/ssl_ticket.h @@ -0,0 +1,135 @@ +/** + * \file ssl_ticket.h + * + * \brief TLS server ticket callbacks implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_SSL_TICKET_H +#define MBEDTLS_SSL_TICKET_H + +/* + * This implementation of the session ticket callbacks includes key + * management, rotating the keys periodically in order to preserve forward + * secrecy, when MBEDTLS_HAVE_TIME is defined. + */ + +#include "ssl.h" +#include "cipher.h" + +#if defined(MBEDTLS_THREADING_C) +#include "threading.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Information for session ticket protection + */ +typedef struct +{ + unsigned char name[4]; /*!< random key identifier */ + uint32_t generation_time; /*!< key generation timestamp (seconds) */ + mbedtls_cipher_context_t ctx; /*!< context for auth enc/decryption */ +} +mbedtls_ssl_ticket_key; + +/** + * \brief Context for session ticket handling functions + */ +typedef struct +{ + mbedtls_ssl_ticket_key keys[2]; /*!< ticket protection keys */ + unsigned char active; /*!< index of the currently active key */ + + uint32_t ticket_lifetime; /*!< lifetime of tickets in seconds */ + + /** Callback for getting (pseudo-)random numbers */ + int (*f_rng)(void *, unsigned char *, size_t); + void *p_rng; /*!< context for the RNG function */ + +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; +#endif +} +mbedtls_ssl_ticket_context; + +/** + * \brief Initialize a ticket context. + * (Just make it ready for mbedtls_ssl_ticket_setup() + * or mbedtls_ssl_ticket_free().) + * + * \param ctx Context to be initialized + */ +void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ); + +/** + * \brief Prepare context to be actually used + * + * \param ctx Context to be set up + * \param f_rng RNG callback function + * \param p_rng RNG callback context + * \param cipher AEAD cipher to use for ticket protection. + * Recommended value: MBEDTLS_CIPHER_AES_256_GCM. + * \param lifetime Tickets lifetime in seconds + * Recommended value: 86400 (one day). + * + * \note It is highly recommended to select a cipher that is at + * least as strong as the the strongest ciphersuite + * supported. Usually that means a 256-bit key. + * + * \note The lifetime of the keys is twice the lifetime of tickets. + * It is recommended to pick a reasonnable lifetime so as not + * to negate the benefits of forward secrecy. + * + * \return 0 if successful, + * or a specific MBEDTLS_ERR_XXX error code + */ +int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_cipher_type_t cipher, + uint32_t lifetime ); + +/** + * \brief Implementation of the ticket write callback + * + * \note See \c mbedlts_ssl_ticket_write_t for description + */ +mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write; + +/** + * \brief Implementation of the ticket parse callback + * + * \note See \c mbedlts_ssl_ticket_parse_t for description + */ +mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse; + +/** + * \brief Free a context's content and zeroize it. + * + * \param ctx Context to be cleaned up + */ +void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ); + +#ifdef __cplusplus +} +#endif + +#endif /* ssl_ticket.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/threading.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/threading.h new file mode 100644 index 0000000..b0c34ec --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/threading.h @@ -0,0 +1,106 @@ +/** + * \file threading.h + * + * \brief Threading abstraction layer + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_THREADING_H +#define MBEDTLS_THREADING_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A /**< The selected feature is not available. */ +#define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA -0x001C /**< Bad input parameters to function. */ +#define MBEDTLS_ERR_THREADING_MUTEX_ERROR -0x001E /**< Locking / unlocking / free failed with error code. */ + +#if defined(MBEDTLS_THREADING_PTHREAD) +#include +typedef struct +{ + pthread_mutex_t mutex; + char is_valid; +} mbedtls_threading_mutex_t; +#endif + +#if defined(MBEDTLS_THREADING_ALT) +/* You should define the mbedtls_threading_mutex_t type in your header */ +#include "threading_alt.h" + +/** + * \brief Set your alternate threading implementation function + * pointers and initialize global mutexes. If used, this + * function must be called once in the main thread before any + * other mbed TLS function is called, and + * mbedtls_threading_free_alt() must be called once in the main + * thread after all other mbed TLS functions. + * + * \note mutex_init() and mutex_free() don't return a status code. + * If mutex_init() fails, it should leave its argument (the + * mutex) in a state such that mutex_lock() will fail when + * called with this argument. + * + * \param mutex_init the init function implementation + * \param mutex_free the free function implementation + * \param mutex_lock the lock function implementation + * \param mutex_unlock the unlock function implementation + */ +void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ), + void (*mutex_free)( mbedtls_threading_mutex_t * ), + int (*mutex_lock)( mbedtls_threading_mutex_t * ), + int (*mutex_unlock)( mbedtls_threading_mutex_t * ) ); + +/** + * \brief Free global mutexes. + */ +void mbedtls_threading_free_alt( void ); +#endif /* MBEDTLS_THREADING_ALT */ + +#if defined(MBEDTLS_THREADING_C) +/* + * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock + * + * All these functions are expected to work or the result will be undefined. + */ +extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex ); +extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex ); +extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex ); +extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex ); + +/* + * Global mutexes + */ +extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; +extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex; +#endif /* MBEDTLS_THREADING_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* threading.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/timing.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/timing.h new file mode 100644 index 0000000..ae7a713 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/timing.h @@ -0,0 +1,141 @@ +/** + * \file timing.h + * + * \brief Portable interface to the CPU cycle counter + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_TIMING_H +#define MBEDTLS_TIMING_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if !defined(MBEDTLS_TIMING_ALT) +// Regular implementation +// + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief timer structure + */ +struct mbedtls_timing_hr_time +{ + unsigned char opaque[32]; +}; + +/** + * \brief Context for mbedtls_timing_set/get_delay() + */ +typedef struct +{ + struct mbedtls_timing_hr_time timer; + uint32_t int_ms; + uint32_t fin_ms; +} mbedtls_timing_delay_context; + +extern volatile int mbedtls_timing_alarmed; + +/** + * \brief Return the CPU cycle counter value + * + * \warning This is only a best effort! Do not rely on this! + * In particular, it is known to be unreliable on virtual + * machines. + */ +unsigned long mbedtls_timing_hardclock( void ); + +/** + * \brief Return the elapsed time in milliseconds + * + * \param val points to a timer structure + * \param reset if set to 1, the timer is restarted + */ +unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ); + +/** + * \brief Setup an alarm clock + * + * \param seconds delay before the "mbedtls_timing_alarmed" flag is set + * + * \warning Only one alarm at a time is supported. In a threaded + * context, this means one for the whole process, not one per + * thread. + */ +void mbedtls_set_alarm( int seconds ); + +/** + * \brief Set a pair of delays to watch + * (See \c mbedtls_timing_get_delay().) + * + * \param data Pointer to timing data + * Must point to a valid \c mbedtls_timing_delay_context struct. + * \param int_ms First (intermediate) delay in milliseconds. + * \param fin_ms Second (final) delay in milliseconds. + * Pass 0 to cancel the current delay. + */ +void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ); + +/** + * \brief Get the status of delays + * (Memory helper: number of delays passed.) + * + * \param data Pointer to timing data + * Must point to a valid \c mbedtls_timing_delay_context struct. + * + * \return -1 if cancelled (fin_ms = 0) + * 0 if none of the delays are passed, + * 1 if only the intermediate delay is passed, + * 2 if the final delay is passed. + */ +int mbedtls_timing_get_delay( void *data ); + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_TIMING_ALT */ +#include "timing_alt.h" +#endif /* MBEDTLS_TIMING_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_timing_self_test( int verbose ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* timing.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/version.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/version.h new file mode 100644 index 0000000..f00e158 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/version.h @@ -0,0 +1,111 @@ +/** + * \file version.h + * + * \brief Run-time version information + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * This set of compile-time defines and run-time variables can be used to + * determine the version number of the mbed TLS library used. + */ +#ifndef MBEDTLS_VERSION_H +#define MBEDTLS_VERSION_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +/** + * The version number x.y.z is split into three parts. + * Major, Minor, Patchlevel + */ +#define MBEDTLS_VERSION_MAJOR 2 +#define MBEDTLS_VERSION_MINOR 4 +#define MBEDTLS_VERSION_PATCH 2 + +/** + * The single version number has the following structure: + * MMNNPP00 + * Major version | Minor version | Patch version + */ +#define MBEDTLS_VERSION_NUMBER 0x02040200 +#define MBEDTLS_VERSION_STRING "2.4.2" +#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.2" + +#if defined(MBEDTLS_VERSION_C) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Get the version number. + * + * \return The constructed version number in the format + * MMNNPP00 (Major, Minor, Patch). + */ +unsigned int mbedtls_version_get_number( void ); + +/** + * Get the version string ("x.y.z"). + * + * \param string The string that will receive the value. + * (Should be at least 9 bytes in size) + */ +void mbedtls_version_get_string( char *string ); + +/** + * Get the full version string ("mbed TLS x.y.z"). + * + * \param string The string that will receive the value. The mbed TLS version + * string will use 18 bytes AT MOST including a terminating + * null byte. + * (So the buffer should be at least 18 bytes to receive this + * version string). + */ +void mbedtls_version_get_string_full( char *string ); + +/** + * \brief Check if support for a feature was compiled into this + * mbed TLS binary. This allows you to see at runtime if the + * library was for instance compiled with or without + * Multi-threading support. + * + * \note only checks against defines in the sections "System + * support", "mbed TLS modules" and "mbed TLS feature + * support" in config.h + * + * \param feature The string for the define to check (e.g. "MBEDTLS_AES_C") + * + * \return 0 if the feature is present, + * -1 if the feature is not present and + * -2 if support for feature checking as a whole was not + * compiled in. + */ +int mbedtls_version_check_feature( const char *feature ); + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_VERSION_C */ + +#endif /* version.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509.h new file mode 100644 index 0000000..f219bf1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509.h @@ -0,0 +1,331 @@ +/** + * \file x509.h + * + * \brief X.509 generic defines and structures + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_X509_H +#define MBEDTLS_X509_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "asn1.h" +#include "pk.h" + +#if defined(MBEDTLS_RSA_C) +#include "rsa.h" +#endif + +/** + * \addtogroup x509_module + * \{ + */ + +#if !defined(MBEDTLS_X509_MAX_INTERMEDIATE_CA) +/** + * Maximum number of intermediate CAs in a verification chain. + * That is, maximum length of the chain, excluding the end-entity certificate + * and the trusted root certificate. + * + * Set this to a low value to prevent an adversary from making you waste + * resources verifying an overlong certificate chain. + */ +#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 +#endif + +/** + * \name X509 Error codes + * \{ + */ +#define MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE -0x2080 /**< Unavailable feature, e.g. RSA hashing/encryption combination. */ +#define MBEDTLS_ERR_X509_UNKNOWN_OID -0x2100 /**< Requested OID is unknown. */ +#define MBEDTLS_ERR_X509_INVALID_FORMAT -0x2180 /**< The CRT/CRL/CSR format is invalid, e.g. different type expected. */ +#define MBEDTLS_ERR_X509_INVALID_VERSION -0x2200 /**< The CRT/CRL/CSR version element is invalid. */ +#define MBEDTLS_ERR_X509_INVALID_SERIAL -0x2280 /**< The serial tag or value is invalid. */ +#define MBEDTLS_ERR_X509_INVALID_ALG -0x2300 /**< The algorithm tag or value is invalid. */ +#define MBEDTLS_ERR_X509_INVALID_NAME -0x2380 /**< The name tag or value is invalid. */ +#define MBEDTLS_ERR_X509_INVALID_DATE -0x2400 /**< The date tag or value is invalid. */ +#define MBEDTLS_ERR_X509_INVALID_SIGNATURE -0x2480 /**< The signature tag or value invalid. */ +#define MBEDTLS_ERR_X509_INVALID_EXTENSIONS -0x2500 /**< The extension tag or value is invalid. */ +#define MBEDTLS_ERR_X509_UNKNOWN_VERSION -0x2580 /**< CRT/CRL/CSR has an unsupported version number. */ +#define MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG -0x2600 /**< Signature algorithm (oid) is unsupported. */ +#define MBEDTLS_ERR_X509_SIG_MISMATCH -0x2680 /**< Signature algorithms do not match. (see \c ::mbedtls_x509_crt sig_oid) */ +#define MBEDTLS_ERR_X509_CERT_VERIFY_FAILED -0x2700 /**< Certificate verification failed, e.g. CRL, CA or signature check failed. */ +#define MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT -0x2780 /**< Format not recognized as DER or PEM. */ +#define MBEDTLS_ERR_X509_BAD_INPUT_DATA -0x2800 /**< Input invalid. */ +#define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880 /**< Allocation of memory failed. */ +#define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900 /**< Read/write of file failed. */ +#define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980 /**< Destination buffer is too small. */ +/* \} name */ + +/** + * \name X509 Verify codes + * \{ + */ +/* Reminder: update x509_crt_verify_strings[] in library/x509_crt.c */ +#define MBEDTLS_X509_BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */ +#define MBEDTLS_X509_BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */ +#define MBEDTLS_X509_BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */ +#define MBEDTLS_X509_BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */ +#define MBEDTLS_X509_BADCRL_NOT_TRUSTED 0x10 /**< The CRL is not correctly signed by the trusted CA. */ +#define MBEDTLS_X509_BADCRL_EXPIRED 0x20 /**< The CRL is expired. */ +#define MBEDTLS_X509_BADCERT_MISSING 0x40 /**< Certificate was missing. */ +#define MBEDTLS_X509_BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was skipped. */ +#define MBEDTLS_X509_BADCERT_OTHER 0x0100 /**< Other reason (can be used by verify callback) */ +#define MBEDTLS_X509_BADCERT_FUTURE 0x0200 /**< The certificate validity starts in the future. */ +#define MBEDTLS_X509_BADCRL_FUTURE 0x0400 /**< The CRL is from the future */ +#define MBEDTLS_X509_BADCERT_KEY_USAGE 0x0800 /**< Usage does not match the keyUsage extension. */ +#define MBEDTLS_X509_BADCERT_EXT_KEY_USAGE 0x1000 /**< Usage does not match the extendedKeyUsage extension. */ +#define MBEDTLS_X509_BADCERT_NS_CERT_TYPE 0x2000 /**< Usage does not match the nsCertType extension. */ +#define MBEDTLS_X509_BADCERT_BAD_MD 0x4000 /**< The certificate is signed with an unacceptable hash. */ +#define MBEDTLS_X509_BADCERT_BAD_PK 0x8000 /**< The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA). */ +#define MBEDTLS_X509_BADCERT_BAD_KEY 0x010000 /**< The certificate is signed with an unacceptable key (eg bad curve, RSA too short). */ +#define MBEDTLS_X509_BADCRL_BAD_MD 0x020000 /**< The CRL is signed with an unacceptable hash. */ +#define MBEDTLS_X509_BADCRL_BAD_PK 0x040000 /**< The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA). */ +#define MBEDTLS_X509_BADCRL_BAD_KEY 0x080000 /**< The CRL is signed with an unacceptable key (eg bad curve, RSA too short). */ + +/* \} name */ +/* \} addtogroup x509_module */ + +/* + * X.509 v3 Key Usage Extension flags + * Reminder: update x509_info_key_usage() when adding new flags. + */ +#define MBEDTLS_X509_KU_DIGITAL_SIGNATURE (0x80) /* bit 0 */ +#define MBEDTLS_X509_KU_NON_REPUDIATION (0x40) /* bit 1 */ +#define MBEDTLS_X509_KU_KEY_ENCIPHERMENT (0x20) /* bit 2 */ +#define MBEDTLS_X509_KU_DATA_ENCIPHERMENT (0x10) /* bit 3 */ +#define MBEDTLS_X509_KU_KEY_AGREEMENT (0x08) /* bit 4 */ +#define MBEDTLS_X509_KU_KEY_CERT_SIGN (0x04) /* bit 5 */ +#define MBEDTLS_X509_KU_CRL_SIGN (0x02) /* bit 6 */ +#define MBEDTLS_X509_KU_ENCIPHER_ONLY (0x01) /* bit 7 */ +#define MBEDTLS_X509_KU_DECIPHER_ONLY (0x8000) /* bit 8 */ + +/* + * Netscape certificate types + * (http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn3.html) + */ + +#define MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT (0x80) /* bit 0 */ +#define MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER (0x40) /* bit 1 */ +#define MBEDTLS_X509_NS_CERT_TYPE_EMAIL (0x20) /* bit 2 */ +#define MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING (0x10) /* bit 3 */ +#define MBEDTLS_X509_NS_CERT_TYPE_RESERVED (0x08) /* bit 4 */ +#define MBEDTLS_X509_NS_CERT_TYPE_SSL_CA (0x04) /* bit 5 */ +#define MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA (0x02) /* bit 6 */ +#define MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01) /* bit 7 */ + +/* + * X.509 extension types + * + * Comments refer to the status for using certificates. Status can be + * different for writing certificates or reading CRLs or CSRs. + */ +#define MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER (1 << 0) +#define MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER (1 << 1) +#define MBEDTLS_X509_EXT_KEY_USAGE (1 << 2) +#define MBEDTLS_X509_EXT_CERTIFICATE_POLICIES (1 << 3) +#define MBEDTLS_X509_EXT_POLICY_MAPPINGS (1 << 4) +#define MBEDTLS_X509_EXT_SUBJECT_ALT_NAME (1 << 5) /* Supported (DNS) */ +#define MBEDTLS_X509_EXT_ISSUER_ALT_NAME (1 << 6) +#define MBEDTLS_X509_EXT_SUBJECT_DIRECTORY_ATTRS (1 << 7) +#define MBEDTLS_X509_EXT_BASIC_CONSTRAINTS (1 << 8) /* Supported */ +#define MBEDTLS_X509_EXT_NAME_CONSTRAINTS (1 << 9) +#define MBEDTLS_X509_EXT_POLICY_CONSTRAINTS (1 << 10) +#define MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE (1 << 11) +#define MBEDTLS_X509_EXT_CRL_DISTRIBUTION_POINTS (1 << 12) +#define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY (1 << 13) +#define MBEDTLS_X509_EXT_FRESHEST_CRL (1 << 14) + +#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) + +/* + * Storage format identifiers + * Recognized formats: PEM and DER + */ +#define MBEDTLS_X509_FORMAT_DER 1 +#define MBEDTLS_X509_FORMAT_PEM 2 + +#define MBEDTLS_X509_MAX_DN_NAME_SIZE 256 /**< Maximum value size of a DN entry */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup x509_module + * \{ */ + +/** + * \name Structures for parsing X.509 certificates, CRLs and CSRs + * \{ + */ + +/** + * Type-length-value structure that allows for ASN1 using DER. + */ +typedef mbedtls_asn1_buf mbedtls_x509_buf; + +/** + * Container for ASN1 bit strings. + */ +typedef mbedtls_asn1_bitstring mbedtls_x509_bitstring; + +/** + * Container for ASN1 named information objects. + * It allows for Relative Distinguished Names (e.g. cn=localhost,ou=code,etc.). + */ +typedef mbedtls_asn1_named_data mbedtls_x509_name; + +/** + * Container for a sequence of ASN.1 items + */ +typedef mbedtls_asn1_sequence mbedtls_x509_sequence; + +/** Container for date and time (precision in seconds). */ +typedef struct mbedtls_x509_time +{ + int year, mon, day; /**< Date. */ + int hour, min, sec; /**< Time. */ +} +mbedtls_x509_time; + +/** \} name Structures for parsing X.509 certificates, CRLs and CSRs */ +/** \} addtogroup x509_module */ + +/** + * \brief Store the certificate DN in printable form into buf; + * no more than size characters will be written. + * + * \param buf Buffer to write to + * \param size Maximum size of buffer + * \param dn The X509 name to represent + * + * \return The length of the string written (not including the + * terminated nul byte), or a negative error code. + */ +int mbedtls_x509_dn_gets( char *buf, size_t size, const mbedtls_x509_name *dn ); + +/** + * \brief Store the certificate serial in printable form into buf; + * no more than size characters will be written. + * + * \param buf Buffer to write to + * \param size Maximum size of buffer + * \param serial The X509 serial to represent + * + * \return The length of the string written (not including the + * terminated nul byte), or a negative error code. + */ +int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *serial ); + +/** + * \brief Check a given mbedtls_x509_time against the system time + * and tell if it's in the past. + * + * \note Intended usage is "if( is_past( valid_to ) ) ERROR". + * Hence the return value of 1 if on internal errors. + * + * \param time mbedtls_x509_time to check + * + * \return 1 if the given time is in the past or an error occured, + * 0 otherwise. + */ +int mbedtls_x509_time_is_past( const mbedtls_x509_time *time ); + +/** + * \brief Check a given mbedtls_x509_time against the system time + * and tell if it's in the future. + * + * \note Intended usage is "if( is_future( valid_from ) ) ERROR". + * Hence the return value of 1 if on internal errors. + * + * \param time mbedtls_x509_time to check + * + * \return 1 if the given time is in the future or an error occured, + * 0 otherwise. + */ +int mbedtls_x509_time_is_future( const mbedtls_x509_time *time ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_x509_self_test( int verbose ); + +/* + * Internal module functions. You probably do not want to use these unless you + * know you do. + */ +int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end, + mbedtls_x509_name *cur ); +int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *alg ); +int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *alg, mbedtls_x509_buf *params ); +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) +int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params, + mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md, + int *salt_len ); +#endif +int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig ); +int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, + mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, + void **sig_opts ); +int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end, + mbedtls_x509_time *time ); +int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *serial ); +int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *ext, int tag ); +int mbedtls_x509_sig_alg_gets( char *buf, size_t size, const mbedtls_x509_buf *sig_oid, + mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, + const void *sig_opts ); +int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name ); +int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name ); +int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len, + int critical, const unsigned char *val, + size_t val_len ); +int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start, + mbedtls_asn1_named_data *first ); +int mbedtls_x509_write_names( unsigned char **p, unsigned char *start, + mbedtls_asn1_named_data *first ); +int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len, + unsigned char *sig, size_t size ); + +#define MBEDTLS_X509_SAFE_SNPRINTF \ + do { \ + if( ret < 0 || (size_t) ret >= n ) \ + return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL ); \ + \ + n -= (size_t) ret; \ + p += (size_t) ret; \ + } while( 0 ) + +#ifdef __cplusplus +} +#endif + +#endif /* x509.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crl.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crl.h new file mode 100644 index 0000000..7988439 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crl.h @@ -0,0 +1,173 @@ +/** + * \file x509_crl.h + * + * \brief X.509 certificate revocation list parsing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_X509_CRL_H +#define MBEDTLS_X509_CRL_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "x509.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup x509_module + * \{ */ + +/** + * \name Structures and functions for parsing CRLs + * \{ + */ + +/** + * Certificate revocation list entry. + * Contains the CA-specific serial numbers and revocation dates. + */ +typedef struct mbedtls_x509_crl_entry +{ + mbedtls_x509_buf raw; + + mbedtls_x509_buf serial; + + mbedtls_x509_time revocation_date; + + mbedtls_x509_buf entry_ext; + + struct mbedtls_x509_crl_entry *next; +} +mbedtls_x509_crl_entry; + +/** + * Certificate revocation list structure. + * Every CRL may have multiple entries. + */ +typedef struct mbedtls_x509_crl +{ + mbedtls_x509_buf raw; /**< The raw certificate data (DER). */ + mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ + + int version; /**< CRL version (1=v1, 2=v2) */ + mbedtls_x509_buf sig_oid; /**< CRL signature type identifier */ + + mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). */ + + mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */ + + mbedtls_x509_time this_update; + mbedtls_x509_time next_update; + + mbedtls_x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */ + + mbedtls_x509_buf crl_ext; + + mbedtls_x509_buf sig_oid2; + mbedtls_x509_buf sig; + mbedtls_md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */ + mbedtls_pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ + void *sig_opts; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ + + struct mbedtls_x509_crl *next; +} +mbedtls_x509_crl; + +/** + * \brief Parse a DER-encoded CRL and append it to the chained list + * + * \param chain points to the start of the chain + * \param buf buffer holding the CRL data in DER format + * \param buflen size of the buffer + * (including the terminating null byte for PEM data) + * + * \return 0 if successful, or a specific X509 or PEM error code + */ +int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain, + const unsigned char *buf, size_t buflen ); +/** + * \brief Parse one or more CRLs and append them to the chained list + * + * \note Mutliple CRLs are accepted only if using PEM format + * + * \param chain points to the start of the chain + * \param buf buffer holding the CRL data in PEM or DER format + * \param buflen size of the buffer + * (including the terminating null byte for PEM data) + * + * \return 0 if successful, or a specific X509 or PEM error code + */ +int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Load one or more CRLs and append them to the chained list + * + * \note Mutliple CRLs are accepted only if using PEM format + * + * \param chain points to the start of the chain + * \param path filename to read the CRLs from (in PEM or DER encoding) + * + * \return 0 if successful, or a specific X509 or PEM error code + */ +int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path ); +#endif /* MBEDTLS_FS_IO */ + +/** + * \brief Returns an informational string about the CRL. + * + * \param buf Buffer to write to + * \param size Maximum size of buffer + * \param prefix A line prefix + * \param crl The X509 CRL to represent + * + * \return The length of the string written (not including the + * terminated nul byte), or a negative error code. + */ +int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_crl *crl ); + +/** + * \brief Initialize a CRL (chain) + * + * \param crl CRL chain to initialize + */ +void mbedtls_x509_crl_init( mbedtls_x509_crl *crl ); + +/** + * \brief Unallocate all CRL data + * + * \param crl CRL chain to free + */ +void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ); + +/* \} name */ +/* \} addtogroup x509_module */ + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_x509_crl.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crt.h new file mode 100644 index 0000000..383e484 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_crt.h @@ -0,0 +1,654 @@ +/** + * \file x509_crt.h + * + * \brief X.509 certificate parsing and writing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_X509_CRT_H +#define MBEDTLS_X509_CRT_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "x509.h" +#include "x509_crl.h" + +/** + * \addtogroup x509_module + * \{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Structures and functions for parsing and writing X.509 certificates + * \{ + */ + +/** + * Container for an X.509 certificate. The certificate may be chained. + */ +typedef struct mbedtls_x509_crt +{ + mbedtls_x509_buf raw; /**< The raw certificate data (DER). */ + mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ + + int version; /**< The X.509 version. (1=v1, 2=v2, 3=v3) */ + mbedtls_x509_buf serial; /**< Unique id for certificate issued by a specific CA. */ + mbedtls_x509_buf sig_oid; /**< Signature algorithm, e.g. sha1RSA */ + + mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). Used for quick comparison. */ + mbedtls_x509_buf subject_raw; /**< The raw subject data (DER). Used for quick comparison. */ + + mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */ + mbedtls_x509_name subject; /**< The parsed subject data (named information object). */ + + mbedtls_x509_time valid_from; /**< Start time of certificate validity. */ + mbedtls_x509_time valid_to; /**< End time of certificate validity. */ + + mbedtls_pk_context pk; /**< Container for the public key context. */ + + mbedtls_x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */ + mbedtls_x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */ + mbedtls_x509_buf v3_ext; /**< Optional X.509 v3 extensions. */ + mbedtls_x509_sequence subject_alt_names; /**< Optional list of Subject Alternative Names (Only dNSName supported). */ + + int ext_types; /**< Bit string containing detected and parsed extensions */ + int ca_istrue; /**< Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise. */ + int max_pathlen; /**< Optional Basic Constraint extension value: The maximum path length to the root certificate. Path length is 1 higher than RFC 5280 'meaning', so 1+ */ + + unsigned int key_usage; /**< Optional key usage extension value: See the values in x509.h */ + + mbedtls_x509_sequence ext_key_usage; /**< Optional list of extended key usage OIDs. */ + + unsigned char ns_cert_type; /**< Optional Netscape certificate type extension value: See the values in x509.h */ + + mbedtls_x509_buf sig; /**< Signature: hash of the tbs part signed with the private key. */ + mbedtls_md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */ + mbedtls_pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ + void *sig_opts; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ + + struct mbedtls_x509_crt *next; /**< Next certificate in the CA-chain. */ +} +mbedtls_x509_crt; + +/** + * Build flag from an algorithm/curve identifier (pk, md, ecp) + * Since 0 is always XXX_NONE, ignore it. + */ +#define MBEDTLS_X509_ID_FLAG( id ) ( 1 << ( id - 1 ) ) + +/** + * Security profile for certificate verification. + * + * All lists are bitfields, built by ORing flags from MBEDTLS_X509_ID_FLAG(). + */ +typedef struct +{ + uint32_t allowed_mds; /**< MDs for signatures */ + uint32_t allowed_pks; /**< PK algs for signatures */ + uint32_t allowed_curves; /**< Elliptic curves for ECDSA */ + uint32_t rsa_min_bitlen; /**< Minimum size for RSA keys */ +} +mbedtls_x509_crt_profile; + +#define MBEDTLS_X509_CRT_VERSION_1 0 +#define MBEDTLS_X509_CRT_VERSION_2 1 +#define MBEDTLS_X509_CRT_VERSION_3 2 + +#define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32 +#define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15 + +#if !defined( MBEDTLS_X509_MAX_FILE_PATH_LEN ) +#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 +#endif + +/** + * Container for writing a certificate (CRT) + */ +typedef struct mbedtls_x509write_cert +{ + int version; + mbedtls_mpi serial; + mbedtls_pk_context *subject_key; + mbedtls_pk_context *issuer_key; + mbedtls_asn1_named_data *subject; + mbedtls_asn1_named_data *issuer; + mbedtls_md_type_t md_alg; + char not_before[MBEDTLS_X509_RFC5280_UTC_TIME_LEN + 1]; + char not_after[MBEDTLS_X509_RFC5280_UTC_TIME_LEN + 1]; + mbedtls_asn1_named_data *extensions; +} +mbedtls_x509write_cert; + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * Default security profile. Should provide a good balance between security + * and compatibility with current deployments. + */ +extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; + +/** + * Expected next default profile. Recommended for new deployments. + * Currently targets a 128-bit security level, except for RSA-2048. + */ +extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; + +/** + * NSA Suite B profile. + */ +extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb; + +/** + * \brief Parse a single DER formatted certificate and add it + * to the chained list. + * + * \param chain points to the start of the chain + * \param buf buffer holding the certificate DER data + * \param buflen size of the buffer + * + * \return 0 if successful, or a specific X509 or PEM error code + */ +int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain, const unsigned char *buf, + size_t buflen ); + +/** + * \brief Parse one or more certificates and add them + * to the chained list. Parses permissively. If some + * certificates can be parsed, the result is the number + * of failed certificates it encountered. If none complete + * correctly, the first error is returned. + * + * \param chain points to the start of the chain + * \param buf buffer holding the certificate data in PEM or DER format + * \param buflen size of the buffer + * (including the terminating null byte for PEM data) + * + * \return 0 if all certificates parsed successfully, a positive number + * if partly successful or a specific X509 or PEM error code + */ +int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Load one or more certificates and add them + * to the chained list. Parses permissively. If some + * certificates can be parsed, the result is the number + * of failed certificates it encountered. If none complete + * correctly, the first error is returned. + * + * \param chain points to the start of the chain + * \param path filename to read the certificates from + * + * \return 0 if all certificates parsed successfully, a positive number + * if partly successful or a specific X509 or PEM error code + */ +int mbedtls_x509_crt_parse_file( mbedtls_x509_crt *chain, const char *path ); + +/** + * \brief Load one or more certificate files from a path and add them + * to the chained list. Parses permissively. If some + * certificates can be parsed, the result is the number + * of failed certificates it encountered. If none complete + * correctly, the first error is returned. + * + * \param chain points to the start of the chain + * \param path directory / folder to read the certificate files from + * + * \return 0 if all certificates parsed successfully, a positive number + * if partly successful or a specific X509 or PEM error code + */ +int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path ); +#endif /* MBEDTLS_FS_IO */ + +/** + * \brief Returns an informational string about the + * certificate. + * + * \param buf Buffer to write to + * \param size Maximum size of buffer + * \param prefix A line prefix + * \param crt The X509 certificate to represent + * + * \return The length of the string written (not including the + * terminated nul byte), or a negative error code. + */ +int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_crt *crt ); + +/** + * \brief Returns an informational string about the + * verification status of a certificate. + * + * \param buf Buffer to write to + * \param size Maximum size of buffer + * \param prefix A line prefix + * \param flags Verification flags created by mbedtls_x509_crt_verify() + * + * \return The length of the string written (not including the + * terminated nul byte), or a negative error code. + */ +int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix, + uint32_t flags ); + +/** + * \brief Verify the certificate signature + * + * The verify callback is a user-supplied callback that + * can clear / modify / add flags for a certificate. If set, + * the verification callback is called for each + * certificate in the chain (from the trust-ca down to the + * presented crt). The parameters for the callback are: + * (void *parameter, mbedtls_x509_crt *crt, int certificate_depth, + * int *flags). With the flags representing current flags for + * that specific certificate and the certificate depth from + * the bottom (Peer cert depth = 0). + * + * All flags left after returning from the callback + * are also returned to the application. The function should + * return 0 for anything but a fatal error. + * + * \note In case verification failed, the results can be displayed + * using \c mbedtls_x509_crt_verify_info() + * + * \note Same as \c mbedtls_x509_crt_verify_with_profile() with the + * default security profile. + * + * \note It is your responsibility to provide up-to-date CRLs for + * all trusted CAs. If no CRL is provided for the CA that was + * used to sign the certificate, CRL verification is skipped + * silently, that is *without* setting any flag. + * + * \param crt a certificate (chain) to be verified + * \param trust_ca the list of trusted CAs + * \param ca_crl the list of CRLs for trusted CAs (see note above) + * \param cn expected Common Name (can be set to + * NULL if the CN must not be verified) + * \param flags result of the verification + * \param f_vrfy verification function + * \param p_vrfy verification parameter + * + * \return 0 if successful or MBEDTLS_ERR_X509_CERT_VERIFY_FAILED + * in which case *flags will have one or more + * MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX flags + * set, + * or another error in case of a fatal error encountered + * during the verification process. + */ +int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const char *cn, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ); + +/** + * \brief Verify the certificate signature according to profile + * + * \note Same as \c mbedtls_x509_crt_verify(), but with explicit + * security profile. + * + * \note The restrictions on keys (RSA minimum size, allowed curves + * for ECDSA) apply to all certificates: trusted root, + * intermediate CAs if any, and end entity certificate. + * + * \param crt a certificate (chain) to be verified + * \param trust_ca the list of trusted CAs + * \param ca_crl the list of CRLs for trusted CAs + * \param profile security profile for verification + * \param cn expected Common Name (can be set to + * NULL if the CN must not be verified) + * \param flags result of the verification + * \param f_vrfy verification function + * \param p_vrfy verification parameter + * + * \return 0 if successful or MBEDTLS_ERR_X509_CERT_VERIFY_FAILED + * in which case *flags will have one or more + * MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX flags + * set, + * or another error in case of a fatal error encountered + * during the verification process. + */ +int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + const char *cn, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ); + +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) +/** + * \brief Check usage of certificate against keyUsage extension. + * + * \param crt Leaf certificate used. + * \param usage Intended usage(s) (eg MBEDTLS_X509_KU_KEY_ENCIPHERMENT + * before using the certificate to perform an RSA key + * exchange). + * + * \note Except for decipherOnly and encipherOnly, a bit set in the + * usage argument means this bit MUST be set in the + * certificate. For decipherOnly and encipherOnly, it means + * that bit MAY be set. + * + * \return 0 is these uses of the certificate are allowed, + * MBEDTLS_ERR_X509_BAD_INPUT_DATA if the keyUsage extension + * is present but does not match the usage argument. + * + * \note You should only call this function on leaf certificates, on + * (intermediate) CAs the keyUsage extension is automatically + * checked by \c mbedtls_x509_crt_verify(). + */ +int mbedtls_x509_crt_check_key_usage( const mbedtls_x509_crt *crt, + unsigned int usage ); +#endif /* MBEDTLS_X509_CHECK_KEY_USAGE) */ + +#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) +/** + * \brief Check usage of certificate against extentedJeyUsage. + * + * \param crt Leaf certificate used. + * \param usage_oid Intended usage (eg MBEDTLS_OID_SERVER_AUTH or MBEDTLS_OID_CLIENT_AUTH). + * \param usage_len Length of usage_oid (eg given by MBEDTLS_OID_SIZE()). + * + * \return 0 if this use of the certificate is allowed, + * MBEDTLS_ERR_X509_BAD_INPUT_DATA if not. + * + * \note Usually only makes sense on leaf certificates. + */ +int mbedtls_x509_crt_check_extended_key_usage( const mbedtls_x509_crt *crt, + const char *usage_oid, + size_t usage_len ); +#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) */ + +#if defined(MBEDTLS_X509_CRL_PARSE_C) +/** + * \brief Verify the certificate revocation status + * + * \param crt a certificate to be verified + * \param crl the CRL to verify against + * + * \return 1 if the certificate is revoked, 0 otherwise + * + */ +int mbedtls_x509_crt_is_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl ); +#endif /* MBEDTLS_X509_CRL_PARSE_C */ + +/** + * \brief Initialize a certificate (chain) + * + * \param crt Certificate chain to initialize + */ +void mbedtls_x509_crt_init( mbedtls_x509_crt *crt ); + +/** + * \brief Unallocate all certificate data + * + * \param crt Certificate chain to free + */ +void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +/* \} name */ +/* \} addtogroup x509_module */ + +#if defined(MBEDTLS_X509_CRT_WRITE_C) +/** + * \brief Initialize a CRT writing context + * + * \param ctx CRT context to initialize + */ +void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx ); + +/** + * \brief Set the verion for a Certificate + * Default: MBEDTLS_X509_CRT_VERSION_3 + * + * \param ctx CRT context to use + * \param version version to set (MBEDTLS_X509_CRT_VERSION_1, MBEDTLS_X509_CRT_VERSION_2 or + * MBEDTLS_X509_CRT_VERSION_3) + */ +void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version ); + +/** + * \brief Set the serial number for a Certificate. + * + * \param ctx CRT context to use + * \param serial serial number to set + * + * \return 0 if successful + */ +int mbedtls_x509write_crt_set_serial( mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial ); + +/** + * \brief Set the validity period for a Certificate + * Timestamps should be in string format for UTC timezone + * i.e. "YYYYMMDDhhmmss" + * e.g. "20131231235959" for December 31st 2013 + * at 23:59:59 + * + * \param ctx CRT context to use + * \param not_before not_before timestamp + * \param not_after not_after timestamp + * + * \return 0 if timestamp was parsed successfully, or + * a specific error code + */ +int mbedtls_x509write_crt_set_validity( mbedtls_x509write_cert *ctx, const char *not_before, + const char *not_after ); + +/** + * \brief Set the issuer name for a Certificate + * Issuer names should contain a comma-separated list + * of OID types and values: + * e.g. "C=UK,O=ARM,CN=mbed TLS CA" + * + * \param ctx CRT context to use + * \param issuer_name issuer name to set + * + * \return 0 if issuer name was parsed successfully, or + * a specific error code + */ +int mbedtls_x509write_crt_set_issuer_name( mbedtls_x509write_cert *ctx, + const char *issuer_name ); + +/** + * \brief Set the subject name for a Certificate + * Subject names should contain a comma-separated list + * of OID types and values: + * e.g. "C=UK,O=ARM,CN=mbed TLS Server 1" + * + * \param ctx CRT context to use + * \param subject_name subject name to set + * + * \return 0 if subject name was parsed successfully, or + * a specific error code + */ +int mbedtls_x509write_crt_set_subject_name( mbedtls_x509write_cert *ctx, + const char *subject_name ); + +/** + * \brief Set the subject public key for the certificate + * + * \param ctx CRT context to use + * \param key public key to include + */ +void mbedtls_x509write_crt_set_subject_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ); + +/** + * \brief Set the issuer key used for signing the certificate + * + * \param ctx CRT context to use + * \param key private key to sign with + */ +void mbedtls_x509write_crt_set_issuer_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ); + +/** + * \brief Set the MD algorithm to use for the signature + * (e.g. MBEDTLS_MD_SHA1) + * + * \param ctx CRT context to use + * \param md_alg MD algorithm to use + */ +void mbedtls_x509write_crt_set_md_alg( mbedtls_x509write_cert *ctx, mbedtls_md_type_t md_alg ); + +/** + * \brief Generic function to add to or replace an extension in the + * CRT + * + * \param ctx CRT context to use + * \param oid OID of the extension + * \param oid_len length of the OID + * \param critical if the extension is critical (per the RFC's definition) + * \param val value of the extension OCTET STRING + * \param val_len length of the value data + * + * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_crt_set_extension( mbedtls_x509write_cert *ctx, + const char *oid, size_t oid_len, + int critical, + const unsigned char *val, size_t val_len ); + +/** + * \brief Set the basicConstraints extension for a CRT + * + * \param ctx CRT context to use + * \param is_ca is this a CA certificate + * \param max_pathlen maximum length of certificate chains below this + * certificate (only for CA certificates, -1 is + * inlimited) + * + * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_crt_set_basic_constraints( mbedtls_x509write_cert *ctx, + int is_ca, int max_pathlen ); + +#if defined(MBEDTLS_SHA1_C) +/** + * \brief Set the subjectKeyIdentifier extension for a CRT + * Requires that mbedtls_x509write_crt_set_subject_key() has been + * called before + * + * \param ctx CRT context to use + * + * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_crt_set_subject_key_identifier( mbedtls_x509write_cert *ctx ); + +/** + * \brief Set the authorityKeyIdentifier extension for a CRT + * Requires that mbedtls_x509write_crt_set_issuer_key() has been + * called before + * + * \param ctx CRT context to use + * + * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_crt_set_authority_key_identifier( mbedtls_x509write_cert *ctx ); +#endif /* MBEDTLS_SHA1_C */ + +/** + * \brief Set the Key Usage Extension flags + * (e.g. MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_KEY_CERT_SIGN) + * + * \param ctx CRT context to use + * \param key_usage key usage flags to set + * + * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, + unsigned int key_usage ); + +/** + * \brief Set the Netscape Cert Type flags + * (e.g. MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT | MBEDTLS_X509_NS_CERT_TYPE_EMAIL) + * + * \param ctx CRT context to use + * \param ns_cert_type Netscape Cert Type flags to set + * + * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx, + unsigned char ns_cert_type ); + +/** + * \brief Free the contents of a CRT write context + * + * \param ctx CRT context to free + */ +void mbedtls_x509write_crt_free( mbedtls_x509write_cert *ctx ); + +/** + * \brief Write a built up certificate to a X509 DER structure + * Note: data is written at the end of the buffer! Use the + * return value to determine where you should start + * using the buffer + * + * \param ctx certificate to write away + * \param buf buffer to write to + * \param size size of the buffer + * \param f_rng RNG function (for signature, see note) + * \param p_rng RNG parameter + * + * \return length of data written if successful, or a specific + * error code + * + * \note f_rng may be NULL if RSA is used for signature and the + * signature is made offline (otherwise f_rng is desirable + * for countermeasures against timing attacks). + * ECDSA signatures always require a non-NULL f_rng. + */ +int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +#if defined(MBEDTLS_PEM_WRITE_C) +/** + * \brief Write a built up certificate to a X509 PEM string + * + * \param ctx certificate to write away + * \param buf buffer to write to + * \param size size of the buffer + * \param f_rng RNG function (for signature, see note) + * \param p_rng RNG parameter + * + * \return 0 if successful, or a specific error code + * + * \note f_rng may be NULL if RSA is used for signature and the + * signature is made offline (otherwise f_rng is desirable + * for countermeasures against timing attacks). + * ECDSA signatures always require a non-NULL f_rng. + */ +int mbedtls_x509write_crt_pem( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); +#endif /* MBEDTLS_PEM_WRITE_C */ +#endif /* MBEDTLS_X509_CRT_WRITE_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_x509_crt.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_csr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_csr.h new file mode 100644 index 0000000..fe9843c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/x509_csr.h @@ -0,0 +1,298 @@ +/** + * \file x509_csr.h + * + * \brief X.509 certificate signing request parsing and writing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_X509_CSR_H +#define MBEDTLS_X509_CSR_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "x509.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup x509_module + * \{ */ + +/** + * \name Structures and functions for X.509 Certificate Signing Requests (CSR) + * \{ + */ + +/** + * Certificate Signing Request (CSR) structure. + */ +typedef struct mbedtls_x509_csr +{ + mbedtls_x509_buf raw; /**< The raw CSR data (DER). */ + mbedtls_x509_buf cri; /**< The raw CertificateRequestInfo body (DER). */ + + int version; /**< CSR version (1=v1). */ + + mbedtls_x509_buf subject_raw; /**< The raw subject data (DER). */ + mbedtls_x509_name subject; /**< The parsed subject data (named information object). */ + + mbedtls_pk_context pk; /**< Container for the public key context. */ + + mbedtls_x509_buf sig_oid; + mbedtls_x509_buf sig; + mbedtls_md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */ + mbedtls_pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ + void *sig_opts; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ +} +mbedtls_x509_csr; + +/** + * Container for writing a CSR + */ +typedef struct mbedtls_x509write_csr +{ + mbedtls_pk_context *key; + mbedtls_asn1_named_data *subject; + mbedtls_md_type_t md_alg; + mbedtls_asn1_named_data *extensions; +} +mbedtls_x509write_csr; + +#if defined(MBEDTLS_X509_CSR_PARSE_C) +/** + * \brief Load a Certificate Signing Request (CSR) in DER format + * + * \note CSR attributes (if any) are currently silently ignored. + * + * \param csr CSR context to fill + * \param buf buffer holding the CRL data + * \param buflen size of the buffer + * + * \return 0 if successful, or a specific X509 error code + */ +int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr, + const unsigned char *buf, size_t buflen ); + +/** + * \brief Load a Certificate Signing Request (CSR), DER or PEM format + * + * \note See notes for \c mbedtls_x509_csr_parse_der() + * + * \param csr CSR context to fill + * \param buf buffer holding the CRL data + * \param buflen size of the buffer + * (including the terminating null byte for PEM data) + * + * \return 0 if successful, or a specific X509 or PEM error code + */ +int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen ); + +#if defined(MBEDTLS_FS_IO) +/** + * \brief Load a Certificate Signing Request (CSR) + * + * \note See notes for \c mbedtls_x509_csr_parse() + * + * \param csr CSR context to fill + * \param path filename to read the CSR from + * + * \return 0 if successful, or a specific X509 or PEM error code + */ +int mbedtls_x509_csr_parse_file( mbedtls_x509_csr *csr, const char *path ); +#endif /* MBEDTLS_FS_IO */ + +/** + * \brief Returns an informational string about the + * CSR. + * + * \param buf Buffer to write to + * \param size Maximum size of buffer + * \param prefix A line prefix + * \param csr The X509 CSR to represent + * + * \return The length of the string written (not including the + * terminated nul byte), or a negative error code. + */ +int mbedtls_x509_csr_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_csr *csr ); + +/** + * \brief Initialize a CSR + * + * \param csr CSR to initialize + */ +void mbedtls_x509_csr_init( mbedtls_x509_csr *csr ); + +/** + * \brief Unallocate all CSR data + * + * \param csr CSR to free + */ +void mbedtls_x509_csr_free( mbedtls_x509_csr *csr ); +#endif /* MBEDTLS_X509_CSR_PARSE_C */ + +/* \} name */ +/* \} addtogroup x509_module */ + +#if defined(MBEDTLS_X509_CSR_WRITE_C) +/** + * \brief Initialize a CSR context + * + * \param ctx CSR context to initialize + */ +void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx ); + +/** + * \brief Set the subject name for a CSR + * Subject names should contain a comma-separated list + * of OID types and values: + * e.g. "C=UK,O=ARM,CN=mbed TLS Server 1" + * + * \param ctx CSR context to use + * \param subject_name subject name to set + * + * \return 0 if subject name was parsed successfully, or + * a specific error code + */ +int mbedtls_x509write_csr_set_subject_name( mbedtls_x509write_csr *ctx, + const char *subject_name ); + +/** + * \brief Set the key for a CSR (public key will be included, + * private key used to sign the CSR when writing it) + * + * \param ctx CSR context to use + * \param key Asymetric key to include + */ +void mbedtls_x509write_csr_set_key( mbedtls_x509write_csr *ctx, mbedtls_pk_context *key ); + +/** + * \brief Set the MD algorithm to use for the signature + * (e.g. MBEDTLS_MD_SHA1) + * + * \param ctx CSR context to use + * \param md_alg MD algorithm to use + */ +void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg ); + +/** + * \brief Set the Key Usage Extension flags + * (e.g. MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_KEY_CERT_SIGN) + * + * \param ctx CSR context to use + * \param key_usage key usage flags to set + * + * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage ); + +/** + * \brief Set the Netscape Cert Type flags + * (e.g. MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT | MBEDTLS_X509_NS_CERT_TYPE_EMAIL) + * + * \param ctx CSR context to use + * \param ns_cert_type Netscape Cert Type flags to set + * + * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_csr_set_ns_cert_type( mbedtls_x509write_csr *ctx, + unsigned char ns_cert_type ); + +/** + * \brief Generic function to add to or replace an extension in the + * CSR + * + * \param ctx CSR context to use + * \param oid OID of the extension + * \param oid_len length of the OID + * \param val value of the extension OCTET STRING + * \param val_len length of the value data + * + * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED + */ +int mbedtls_x509write_csr_set_extension( mbedtls_x509write_csr *ctx, + const char *oid, size_t oid_len, + const unsigned char *val, size_t val_len ); + +/** + * \brief Free the contents of a CSR context + * + * \param ctx CSR context to free + */ +void mbedtls_x509write_csr_free( mbedtls_x509write_csr *ctx ); + +/** + * \brief Write a CSR (Certificate Signing Request) to a + * DER structure + * Note: data is written at the end of the buffer! Use the + * return value to determine where you should start + * using the buffer + * + * \param ctx CSR to write away + * \param buf buffer to write to + * \param size size of the buffer + * \param f_rng RNG function (for signature, see note) + * \param p_rng RNG parameter + * + * \return length of data written if successful, or a specific + * error code + * + * \note f_rng may be NULL if RSA is used for signature and the + * signature is made offline (otherwise f_rng is desirable + * for countermeasures against timing attacks). + * ECDSA signatures always require a non-NULL f_rng. + */ +int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +#if defined(MBEDTLS_PEM_WRITE_C) +/** + * \brief Write a CSR (Certificate Signing Request) to a + * PEM string + * + * \param ctx CSR to write away + * \param buf buffer to write to + * \param size size of the buffer + * \param f_rng RNG function (for signature, see note) + * \param p_rng RNG parameter + * + * \return 0 if successful, or a specific error code + * + * \note f_rng may be NULL if RSA is used for signature and the + * signature is made offline (otherwise f_rng is desirable + * for countermeasures against timing attacks). + * ECDSA signatures always require a non-NULL f_rng. + */ +int mbedtls_x509write_csr_pem( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); +#endif /* MBEDTLS_PEM_WRITE_C */ +#endif /* MBEDTLS_X509_CSR_WRITE_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* mbedtls_x509_csr.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/xtea.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/xtea.h new file mode 100644 index 0000000..b073f84 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/include/mbedtls/xtea.h @@ -0,0 +1,139 @@ +/** + * \file xtea.h + * + * \brief XTEA block cipher (32-bit) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_XTEA_H +#define MBEDTLS_XTEA_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#define MBEDTLS_XTEA_ENCRYPT 1 +#define MBEDTLS_XTEA_DECRYPT 0 + +#define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028 /**< The data input has an invalid length. */ + +#if !defined(MBEDTLS_XTEA_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief XTEA context structure + */ +typedef struct +{ + uint32_t k[4]; /*!< key */ +} +mbedtls_xtea_context; + +/** + * \brief Initialize XTEA context + * + * \param ctx XTEA context to be initialized + */ +void mbedtls_xtea_init( mbedtls_xtea_context *ctx ); + +/** + * \brief Clear XTEA context + * + * \param ctx XTEA context to be cleared + */ +void mbedtls_xtea_free( mbedtls_xtea_context *ctx ); + +/** + * \brief XTEA key schedule + * + * \param ctx XTEA context to be initialized + * \param key the secret key + */ +void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] ); + +/** + * \brief XTEA cipher function + * + * \param ctx XTEA context + * \param mode MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT + * \param input 8-byte input block + * \param output 8-byte output block + * + * \return 0 if successful + */ +int mbedtls_xtea_crypt_ecb( mbedtls_xtea_context *ctx, + int mode, + const unsigned char input[8], + unsigned char output[8] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief XTEA CBC cipher function + * + * \param ctx XTEA context + * \param mode MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT + * \param length the length of input, multiple of 8 + * \param iv initialization vector for CBC mode + * \param input input block + * \param output output block + * + * \return 0 if successful, + * MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH if the length % 8 != 0 + */ +int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx, + int mode, + size_t length, + unsigned char iv[8], + const unsigned char *input, + unsigned char *output); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#ifdef __cplusplus +} +#endif + +#else /* MBEDTLS_XTEA_ALT */ +#include "xtea_alt.h" +#endif /* MBEDTLS_XTEA_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_xtea_self_test( int verbose ); + +#ifdef __cplusplus +} +#endif + +#endif /* xtea.h */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/CMakeLists.txt new file mode 100644 index 0000000..f2c1e5c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/CMakeLists.txt @@ -0,0 +1,162 @@ +option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON) +option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF) +option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF) + +set(src_crypto + aes.c + aesni.c + arc4.c + asn1parse.c + asn1write.c + base64.c + bignum.c + blowfish.c + camellia.c + ccm.c + cipher.c + cipher_wrap.c + cmac.c + ctr_drbg.c + des.c + dhm.c + ecdh.c + ecdsa.c + ecjpake.c + ecp.c + ecp_curves.c + entropy.c + entropy_poll.c + error.c + gcm.c + havege.c + hmac_drbg.c + md.c + md2.c + md4.c + md5.c + md_wrap.c + memory_buffer_alloc.c + oid.c + padlock.c + pem.c + pk.c + pk_wrap.c + pkcs12.c + pkcs5.c + pkparse.c + pkwrite.c + platform.c + ripemd160.c + rsa.c + sha1.c + sha256.c + sha512.c + threading.c + timing.c + version.c + version_features.c + xtea.c +) + +set(src_x509 + certs.c + pkcs11.c + x509.c + x509_create.c + x509_crl.c + x509_crt.c + x509_csr.c + x509write_crt.c + x509write_csr.c +) + +set(src_tls + debug.c + net_sockets.c + ssl_cache.c + ssl_ciphersuites.c + ssl_cli.c + ssl_cookie.c + ssl_srv.c + ssl_ticket.c + ssl_tls.c +) + +if(CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") +endif(CMAKE_COMPILER_IS_GNUCC) + +if(CMAKE_COMPILER_IS_CLANG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code") +endif(CMAKE_COMPILER_IS_CLANG) + +if(WIN32) + set(libs ${libs} ws2_32) +endif(WIN32) + +if(USE_PKCS11_HELPER_LIBRARY) + set(libs ${libs} pkcs11-helper) +endif(USE_PKCS11_HELPER_LIBRARY) + +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + +if(LINK_WITH_PTHREAD) + set(libs ${libs} pthread) +endif() + +if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) + message(FATAL_ERROR "Need to choose static or shared mbedtls build!") +endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) + +if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) + set(mbedtls_static_target "mbedtls_static") + set(mbedx509_static_target "mbedx509_static") + set(mbedcrypto_static_target "mbedcrypto_static") +elseif(USE_STATIC_MBEDTLS_LIBRARY) + set(mbedtls_static_target "mbedtls") + set(mbedx509_static_target "mbedx509") + set(mbedcrypto_static_target "mbedcrypto") +endif() + +if(USE_STATIC_MBEDTLS_LIBRARY) + add_library(${mbedcrypto_static_target} STATIC ${src_crypto}) + set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto) + target_link_libraries(${mbedcrypto_static_target} ${libs}) + + add_library(${mbedx509_static_target} STATIC ${src_x509}) + set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) + target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target}) + + add_library(${mbedtls_static_target} STATIC ${src_tls}) + set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) + target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) + + install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} + DESTINATION ${LIB_INSTALL_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +endif(USE_STATIC_MBEDTLS_LIBRARY) + +if(USE_SHARED_MBEDTLS_LIBRARY) + add_library(mbedcrypto SHARED ${src_crypto}) + set_target_properties(mbedcrypto PROPERTIES VERSION 2.4.2 SOVERSION 0) + target_link_libraries(mbedcrypto ${libs}) + + add_library(mbedx509 SHARED ${src_x509}) + set_target_properties(mbedx509 PROPERTIES VERSION 2.4.2 SOVERSION 0) + target_link_libraries(mbedx509 ${libs} mbedcrypto) + + add_library(mbedtls SHARED ${src_tls}) + set_target_properties(mbedtls PROPERTIES VERSION 2.4.2 SOVERSION 10) + target_link_libraries(mbedtls ${libs} mbedx509) + + install(TARGETS mbedtls mbedx509 mbedcrypto + DESTINATION ${LIB_INSTALL_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +endif(USE_SHARED_MBEDTLS_LIBRARY) + +add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls) +if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) + add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static) +endif() diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/Makefile new file mode 100644 index 0000000..28f9231 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/Makefile @@ -0,0 +1,169 @@ + +# Also see "include/mbedtls/config.h" + +CFLAGS ?= -O2 +WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement +LDFLAGS ?= + +LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 +LOCAL_LDFLAGS = + +ifdef DEBUG +LOCAL_CFLAGS += -g3 +endif + +# MicroBlaze specific options: +# CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift + +# To compile on Plan9: +# CFLAGS += -D_BSD_EXTENSION + +# if were running on Windows build for Windows +ifdef WINDOWS +WINDOWS_BUILD=1 +endif + +# To compile as a shared library: +ifdef SHARED +# all code is position-indep with mingw, avoid warning about useless flag +ifndef WINDOWS_BUILD +LOCAL_CFLAGS += -fPIC -fpic +endif +endif + +SOEXT_TLS=so.10 +SOEXT_X509=so.0 +SOEXT_CRYPTO=so.0 + +DLEXT=so +# OSX shared library extension: +# DLEXT=dylib + +# Windows shared library extension: +ifdef WINDOWS_BUILD +DLEXT=dll +endif + +OBJS_CRYPTO= aes.o aesni.o arc4.o \ + asn1parse.o asn1write.o base64.o \ + bignum.o blowfish.o camellia.o \ + ccm.o cipher.o cipher_wrap.o \ + cmac.o ctr_drbg.o des.o \ + dhm.o ecdh.o ecdsa.o \ + ecjpake.o ecp.o \ + ecp_curves.o entropy.o entropy_poll.o \ + error.o gcm.o havege.o \ + hmac_drbg.o md.o md2.o \ + md4.o md5.o md_wrap.o \ + memory_buffer_alloc.o oid.o \ + padlock.o pem.o pk.o \ + pk_wrap.o pkcs12.o pkcs5.o \ + pkparse.o pkwrite.o platform.o \ + ripemd160.o rsa.o sha1.o \ + sha256.o sha512.o threading.o \ + timing.o version.o \ + version_features.o xtea.o + +OBJS_X509= certs.o pkcs11.o x509.o \ + x509_create.o x509_crl.o x509_crt.o \ + x509_csr.o x509write_crt.o x509write_csr.o + +OBJS_TLS= debug.o net_sockets.o \ + ssl_cache.o ssl_ciphersuites.o \ + ssl_cli.o ssl_cookie.o \ + ssl_srv.o ssl_ticket.o \ + ssl_tls.o + +.SILENT: + +.PHONY: all static shared clean + +ifndef SHARED +all: static +else +all: shared static +endif + +static: libmbedcrypto.a libmbedx509.a libmbedtls.a + +shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) + +# tls +libmbedtls.a: $(OBJS_TLS) + echo " AR $@" + $(AR) -rc $@ $(OBJS_TLS) + echo " RL $@" + $(AR) -s $@ + +libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so + echo " LD $@" + $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS) + +libmbedtls.so: libmbedtls.$(SOEXT_TLS) + echo " LN $@ -> $<" + ln -sf $< $@ + +libmbedtls.dylib: $(OBJS_TLS) + echo " LD $@" + $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS) + +libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll + echo " LD $@" + $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -lmbedx509 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) + +# x509 +libmbedx509.a: $(OBJS_X509) + echo " AR $@" + $(AR) -rc $@ $(OBJS_X509) + echo " RL $@" + $(AR) -s $@ + +libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so + echo " LD $@" + $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) + +libmbedx509.so: libmbedx509.$(SOEXT_X509) + echo " LN $@ -> $<" + ln -sf $< $@ + +libmbedx509.dylib: $(OBJS_X509) + echo " LD $@" + $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) + +libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll + echo " LD $@" + $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) + +# crypto +libmbedcrypto.a: $(OBJS_CRYPTO) + echo " AR $@" + $(AR) -rc $@ $(OBJS_CRYPTO) + echo " RL $@" + $(AR) -s $@ + +libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) + echo " LD $@" + $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) + +libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) + echo " LN $@ -> $<" + ln -sf $< $@ + +libmbedcrypto.dylib: $(OBJS_CRYPTO) + echo " LD $@" + $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) + +libmbedcrypto.dll: $(OBJS_CRYPTO) + echo " LD $@" + $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) + +.c.o: + echo " CC $<" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< + +clean: +ifndef WINDOWS + rm -f *.o libmbed* +else + del /Q /F *.o libmbed* +endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aes.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aes.c new file mode 100644 index 0000000..a186dee --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aes.c @@ -0,0 +1,1492 @@ +/* + * FIPS-197 compliant AES implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The AES block cipher was designed by Vincent Rijmen and Joan Daemen. + * + * http://csrc.nist.gov/encryption/aes/rijndael/Rijndael.pdf + * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_AES_C) + +#include + +#include "mbedtls/aes.h" +#if defined(MBEDTLS_PADLOCK_C) +#include "mbedtls/padlock.h" +#endif +#if defined(MBEDTLS_AESNI_C) +#include "mbedtls/aesni.h" +#endif + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_AES_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef GET_UINT32_LE +#define GET_UINT32_LE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ +} +#endif + +#ifndef PUT_UINT32_LE +#define PUT_UINT32_LE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +} +#endif + +#if defined(MBEDTLS_PADLOCK_C) && \ + ( defined(MBEDTLS_HAVE_X86) || defined(MBEDTLS_PADLOCK_ALIGN16) ) +static int aes_padlock_ace = -1; +#endif + +#if defined(MBEDTLS_AES_ROM_TABLES) +/* + * Forward S-box + */ +static const unsigned char FSb[256] = +{ + 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, + 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, + 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, + 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, + 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, + 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, + 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, + 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, + 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, + 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, + 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, + 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, + 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, + 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, + 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, + 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, + 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, + 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, + 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, + 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, + 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, + 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, + 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, + 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, + 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, + 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, + 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, + 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, + 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, + 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, + 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, + 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 +}; + +/* + * Forward tables + */ +#define FT \ +\ + V(A5,63,63,C6), V(84,7C,7C,F8), V(99,77,77,EE), V(8D,7B,7B,F6), \ + V(0D,F2,F2,FF), V(BD,6B,6B,D6), V(B1,6F,6F,DE), V(54,C5,C5,91), \ + V(50,30,30,60), V(03,01,01,02), V(A9,67,67,CE), V(7D,2B,2B,56), \ + V(19,FE,FE,E7), V(62,D7,D7,B5), V(E6,AB,AB,4D), V(9A,76,76,EC), \ + V(45,CA,CA,8F), V(9D,82,82,1F), V(40,C9,C9,89), V(87,7D,7D,FA), \ + V(15,FA,FA,EF), V(EB,59,59,B2), V(C9,47,47,8E), V(0B,F0,F0,FB), \ + V(EC,AD,AD,41), V(67,D4,D4,B3), V(FD,A2,A2,5F), V(EA,AF,AF,45), \ + V(BF,9C,9C,23), V(F7,A4,A4,53), V(96,72,72,E4), V(5B,C0,C0,9B), \ + V(C2,B7,B7,75), V(1C,FD,FD,E1), V(AE,93,93,3D), V(6A,26,26,4C), \ + V(5A,36,36,6C), V(41,3F,3F,7E), V(02,F7,F7,F5), V(4F,CC,CC,83), \ + V(5C,34,34,68), V(F4,A5,A5,51), V(34,E5,E5,D1), V(08,F1,F1,F9), \ + V(93,71,71,E2), V(73,D8,D8,AB), V(53,31,31,62), V(3F,15,15,2A), \ + V(0C,04,04,08), V(52,C7,C7,95), V(65,23,23,46), V(5E,C3,C3,9D), \ + V(28,18,18,30), V(A1,96,96,37), V(0F,05,05,0A), V(B5,9A,9A,2F), \ + V(09,07,07,0E), V(36,12,12,24), V(9B,80,80,1B), V(3D,E2,E2,DF), \ + V(26,EB,EB,CD), V(69,27,27,4E), V(CD,B2,B2,7F), V(9F,75,75,EA), \ + V(1B,09,09,12), V(9E,83,83,1D), V(74,2C,2C,58), V(2E,1A,1A,34), \ + V(2D,1B,1B,36), V(B2,6E,6E,DC), V(EE,5A,5A,B4), V(FB,A0,A0,5B), \ + V(F6,52,52,A4), V(4D,3B,3B,76), V(61,D6,D6,B7), V(CE,B3,B3,7D), \ + V(7B,29,29,52), V(3E,E3,E3,DD), V(71,2F,2F,5E), V(97,84,84,13), \ + V(F5,53,53,A6), V(68,D1,D1,B9), V(00,00,00,00), V(2C,ED,ED,C1), \ + V(60,20,20,40), V(1F,FC,FC,E3), V(C8,B1,B1,79), V(ED,5B,5B,B6), \ + V(BE,6A,6A,D4), V(46,CB,CB,8D), V(D9,BE,BE,67), V(4B,39,39,72), \ + V(DE,4A,4A,94), V(D4,4C,4C,98), V(E8,58,58,B0), V(4A,CF,CF,85), \ + V(6B,D0,D0,BB), V(2A,EF,EF,C5), V(E5,AA,AA,4F), V(16,FB,FB,ED), \ + V(C5,43,43,86), V(D7,4D,4D,9A), V(55,33,33,66), V(94,85,85,11), \ + V(CF,45,45,8A), V(10,F9,F9,E9), V(06,02,02,04), V(81,7F,7F,FE), \ + V(F0,50,50,A0), V(44,3C,3C,78), V(BA,9F,9F,25), V(E3,A8,A8,4B), \ + V(F3,51,51,A2), V(FE,A3,A3,5D), V(C0,40,40,80), V(8A,8F,8F,05), \ + V(AD,92,92,3F), V(BC,9D,9D,21), V(48,38,38,70), V(04,F5,F5,F1), \ + V(DF,BC,BC,63), V(C1,B6,B6,77), V(75,DA,DA,AF), V(63,21,21,42), \ + V(30,10,10,20), V(1A,FF,FF,E5), V(0E,F3,F3,FD), V(6D,D2,D2,BF), \ + V(4C,CD,CD,81), V(14,0C,0C,18), V(35,13,13,26), V(2F,EC,EC,C3), \ + V(E1,5F,5F,BE), V(A2,97,97,35), V(CC,44,44,88), V(39,17,17,2E), \ + V(57,C4,C4,93), V(F2,A7,A7,55), V(82,7E,7E,FC), V(47,3D,3D,7A), \ + V(AC,64,64,C8), V(E7,5D,5D,BA), V(2B,19,19,32), V(95,73,73,E6), \ + V(A0,60,60,C0), V(98,81,81,19), V(D1,4F,4F,9E), V(7F,DC,DC,A3), \ + V(66,22,22,44), V(7E,2A,2A,54), V(AB,90,90,3B), V(83,88,88,0B), \ + V(CA,46,46,8C), V(29,EE,EE,C7), V(D3,B8,B8,6B), V(3C,14,14,28), \ + V(79,DE,DE,A7), V(E2,5E,5E,BC), V(1D,0B,0B,16), V(76,DB,DB,AD), \ + V(3B,E0,E0,DB), V(56,32,32,64), V(4E,3A,3A,74), V(1E,0A,0A,14), \ + V(DB,49,49,92), V(0A,06,06,0C), V(6C,24,24,48), V(E4,5C,5C,B8), \ + V(5D,C2,C2,9F), V(6E,D3,D3,BD), V(EF,AC,AC,43), V(A6,62,62,C4), \ + V(A8,91,91,39), V(A4,95,95,31), V(37,E4,E4,D3), V(8B,79,79,F2), \ + V(32,E7,E7,D5), V(43,C8,C8,8B), V(59,37,37,6E), V(B7,6D,6D,DA), \ + V(8C,8D,8D,01), V(64,D5,D5,B1), V(D2,4E,4E,9C), V(E0,A9,A9,49), \ + V(B4,6C,6C,D8), V(FA,56,56,AC), V(07,F4,F4,F3), V(25,EA,EA,CF), \ + V(AF,65,65,CA), V(8E,7A,7A,F4), V(E9,AE,AE,47), V(18,08,08,10), \ + V(D5,BA,BA,6F), V(88,78,78,F0), V(6F,25,25,4A), V(72,2E,2E,5C), \ + V(24,1C,1C,38), V(F1,A6,A6,57), V(C7,B4,B4,73), V(51,C6,C6,97), \ + V(23,E8,E8,CB), V(7C,DD,DD,A1), V(9C,74,74,E8), V(21,1F,1F,3E), \ + V(DD,4B,4B,96), V(DC,BD,BD,61), V(86,8B,8B,0D), V(85,8A,8A,0F), \ + V(90,70,70,E0), V(42,3E,3E,7C), V(C4,B5,B5,71), V(AA,66,66,CC), \ + V(D8,48,48,90), V(05,03,03,06), V(01,F6,F6,F7), V(12,0E,0E,1C), \ + V(A3,61,61,C2), V(5F,35,35,6A), V(F9,57,57,AE), V(D0,B9,B9,69), \ + V(91,86,86,17), V(58,C1,C1,99), V(27,1D,1D,3A), V(B9,9E,9E,27), \ + V(38,E1,E1,D9), V(13,F8,F8,EB), V(B3,98,98,2B), V(33,11,11,22), \ + V(BB,69,69,D2), V(70,D9,D9,A9), V(89,8E,8E,07), V(A7,94,94,33), \ + V(B6,9B,9B,2D), V(22,1E,1E,3C), V(92,87,87,15), V(20,E9,E9,C9), \ + V(49,CE,CE,87), V(FF,55,55,AA), V(78,28,28,50), V(7A,DF,DF,A5), \ + V(8F,8C,8C,03), V(F8,A1,A1,59), V(80,89,89,09), V(17,0D,0D,1A), \ + V(DA,BF,BF,65), V(31,E6,E6,D7), V(C6,42,42,84), V(B8,68,68,D0), \ + V(C3,41,41,82), V(B0,99,99,29), V(77,2D,2D,5A), V(11,0F,0F,1E), \ + V(CB,B0,B0,7B), V(FC,54,54,A8), V(D6,BB,BB,6D), V(3A,16,16,2C) + +#define V(a,b,c,d) 0x##a##b##c##d +static const uint32_t FT0[256] = { FT }; +#undef V + +#define V(a,b,c,d) 0x##b##c##d##a +static const uint32_t FT1[256] = { FT }; +#undef V + +#define V(a,b,c,d) 0x##c##d##a##b +static const uint32_t FT2[256] = { FT }; +#undef V + +#define V(a,b,c,d) 0x##d##a##b##c +static const uint32_t FT3[256] = { FT }; +#undef V + +#undef FT + +/* + * Reverse S-box + */ +static const unsigned char RSb[256] = +{ + 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, + 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, + 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, + 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, + 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, + 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, + 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, + 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, + 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, + 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, + 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, + 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, + 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, + 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, + 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, + 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, + 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, + 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, + 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, + 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, + 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, + 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, + 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, + 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, + 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, + 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, + 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, + 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, + 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, + 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, + 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D +}; + +/* + * Reverse tables + */ +#define RT \ +\ + V(50,A7,F4,51), V(53,65,41,7E), V(C3,A4,17,1A), V(96,5E,27,3A), \ + V(CB,6B,AB,3B), V(F1,45,9D,1F), V(AB,58,FA,AC), V(93,03,E3,4B), \ + V(55,FA,30,20), V(F6,6D,76,AD), V(91,76,CC,88), V(25,4C,02,F5), \ + V(FC,D7,E5,4F), V(D7,CB,2A,C5), V(80,44,35,26), V(8F,A3,62,B5), \ + V(49,5A,B1,DE), V(67,1B,BA,25), V(98,0E,EA,45), V(E1,C0,FE,5D), \ + V(02,75,2F,C3), V(12,F0,4C,81), V(A3,97,46,8D), V(C6,F9,D3,6B), \ + V(E7,5F,8F,03), V(95,9C,92,15), V(EB,7A,6D,BF), V(DA,59,52,95), \ + V(2D,83,BE,D4), V(D3,21,74,58), V(29,69,E0,49), V(44,C8,C9,8E), \ + V(6A,89,C2,75), V(78,79,8E,F4), V(6B,3E,58,99), V(DD,71,B9,27), \ + V(B6,4F,E1,BE), V(17,AD,88,F0), V(66,AC,20,C9), V(B4,3A,CE,7D), \ + V(18,4A,DF,63), V(82,31,1A,E5), V(60,33,51,97), V(45,7F,53,62), \ + V(E0,77,64,B1), V(84,AE,6B,BB), V(1C,A0,81,FE), V(94,2B,08,F9), \ + V(58,68,48,70), V(19,FD,45,8F), V(87,6C,DE,94), V(B7,F8,7B,52), \ + V(23,D3,73,AB), V(E2,02,4B,72), V(57,8F,1F,E3), V(2A,AB,55,66), \ + V(07,28,EB,B2), V(03,C2,B5,2F), V(9A,7B,C5,86), V(A5,08,37,D3), \ + V(F2,87,28,30), V(B2,A5,BF,23), V(BA,6A,03,02), V(5C,82,16,ED), \ + V(2B,1C,CF,8A), V(92,B4,79,A7), V(F0,F2,07,F3), V(A1,E2,69,4E), \ + V(CD,F4,DA,65), V(D5,BE,05,06), V(1F,62,34,D1), V(8A,FE,A6,C4), \ + V(9D,53,2E,34), V(A0,55,F3,A2), V(32,E1,8A,05), V(75,EB,F6,A4), \ + V(39,EC,83,0B), V(AA,EF,60,40), V(06,9F,71,5E), V(51,10,6E,BD), \ + V(F9,8A,21,3E), V(3D,06,DD,96), V(AE,05,3E,DD), V(46,BD,E6,4D), \ + V(B5,8D,54,91), V(05,5D,C4,71), V(6F,D4,06,04), V(FF,15,50,60), \ + V(24,FB,98,19), V(97,E9,BD,D6), V(CC,43,40,89), V(77,9E,D9,67), \ + V(BD,42,E8,B0), V(88,8B,89,07), V(38,5B,19,E7), V(DB,EE,C8,79), \ + V(47,0A,7C,A1), V(E9,0F,42,7C), V(C9,1E,84,F8), V(00,00,00,00), \ + V(83,86,80,09), V(48,ED,2B,32), V(AC,70,11,1E), V(4E,72,5A,6C), \ + V(FB,FF,0E,FD), V(56,38,85,0F), V(1E,D5,AE,3D), V(27,39,2D,36), \ + V(64,D9,0F,0A), V(21,A6,5C,68), V(D1,54,5B,9B), V(3A,2E,36,24), \ + V(B1,67,0A,0C), V(0F,E7,57,93), V(D2,96,EE,B4), V(9E,91,9B,1B), \ + V(4F,C5,C0,80), V(A2,20,DC,61), V(69,4B,77,5A), V(16,1A,12,1C), \ + V(0A,BA,93,E2), V(E5,2A,A0,C0), V(43,E0,22,3C), V(1D,17,1B,12), \ + V(0B,0D,09,0E), V(AD,C7,8B,F2), V(B9,A8,B6,2D), V(C8,A9,1E,14), \ + V(85,19,F1,57), V(4C,07,75,AF), V(BB,DD,99,EE), V(FD,60,7F,A3), \ + V(9F,26,01,F7), V(BC,F5,72,5C), V(C5,3B,66,44), V(34,7E,FB,5B), \ + V(76,29,43,8B), V(DC,C6,23,CB), V(68,FC,ED,B6), V(63,F1,E4,B8), \ + V(CA,DC,31,D7), V(10,85,63,42), V(40,22,97,13), V(20,11,C6,84), \ + V(7D,24,4A,85), V(F8,3D,BB,D2), V(11,32,F9,AE), V(6D,A1,29,C7), \ + V(4B,2F,9E,1D), V(F3,30,B2,DC), V(EC,52,86,0D), V(D0,E3,C1,77), \ + V(6C,16,B3,2B), V(99,B9,70,A9), V(FA,48,94,11), V(22,64,E9,47), \ + V(C4,8C,FC,A8), V(1A,3F,F0,A0), V(D8,2C,7D,56), V(EF,90,33,22), \ + V(C7,4E,49,87), V(C1,D1,38,D9), V(FE,A2,CA,8C), V(36,0B,D4,98), \ + V(CF,81,F5,A6), V(28,DE,7A,A5), V(26,8E,B7,DA), V(A4,BF,AD,3F), \ + V(E4,9D,3A,2C), V(0D,92,78,50), V(9B,CC,5F,6A), V(62,46,7E,54), \ + V(C2,13,8D,F6), V(E8,B8,D8,90), V(5E,F7,39,2E), V(F5,AF,C3,82), \ + V(BE,80,5D,9F), V(7C,93,D0,69), V(A9,2D,D5,6F), V(B3,12,25,CF), \ + V(3B,99,AC,C8), V(A7,7D,18,10), V(6E,63,9C,E8), V(7B,BB,3B,DB), \ + V(09,78,26,CD), V(F4,18,59,6E), V(01,B7,9A,EC), V(A8,9A,4F,83), \ + V(65,6E,95,E6), V(7E,E6,FF,AA), V(08,CF,BC,21), V(E6,E8,15,EF), \ + V(D9,9B,E7,BA), V(CE,36,6F,4A), V(D4,09,9F,EA), V(D6,7C,B0,29), \ + V(AF,B2,A4,31), V(31,23,3F,2A), V(30,94,A5,C6), V(C0,66,A2,35), \ + V(37,BC,4E,74), V(A6,CA,82,FC), V(B0,D0,90,E0), V(15,D8,A7,33), \ + V(4A,98,04,F1), V(F7,DA,EC,41), V(0E,50,CD,7F), V(2F,F6,91,17), \ + V(8D,D6,4D,76), V(4D,B0,EF,43), V(54,4D,AA,CC), V(DF,04,96,E4), \ + V(E3,B5,D1,9E), V(1B,88,6A,4C), V(B8,1F,2C,C1), V(7F,51,65,46), \ + V(04,EA,5E,9D), V(5D,35,8C,01), V(73,74,87,FA), V(2E,41,0B,FB), \ + V(5A,1D,67,B3), V(52,D2,DB,92), V(33,56,10,E9), V(13,47,D6,6D), \ + V(8C,61,D7,9A), V(7A,0C,A1,37), V(8E,14,F8,59), V(89,3C,13,EB), \ + V(EE,27,A9,CE), V(35,C9,61,B7), V(ED,E5,1C,E1), V(3C,B1,47,7A), \ + V(59,DF,D2,9C), V(3F,73,F2,55), V(79,CE,14,18), V(BF,37,C7,73), \ + V(EA,CD,F7,53), V(5B,AA,FD,5F), V(14,6F,3D,DF), V(86,DB,44,78), \ + V(81,F3,AF,CA), V(3E,C4,68,B9), V(2C,34,24,38), V(5F,40,A3,C2), \ + V(72,C3,1D,16), V(0C,25,E2,BC), V(8B,49,3C,28), V(41,95,0D,FF), \ + V(71,01,A8,39), V(DE,B3,0C,08), V(9C,E4,B4,D8), V(90,C1,56,64), \ + V(61,84,CB,7B), V(70,B6,32,D5), V(74,5C,6C,48), V(42,57,B8,D0) + +#define V(a,b,c,d) 0x##a##b##c##d +static const uint32_t RT0[256] = { RT }; +#undef V + +#define V(a,b,c,d) 0x##b##c##d##a +static const uint32_t RT1[256] = { RT }; +#undef V + +#define V(a,b,c,d) 0x##c##d##a##b +static const uint32_t RT2[256] = { RT }; +#undef V + +#define V(a,b,c,d) 0x##d##a##b##c +static const uint32_t RT3[256] = { RT }; +#undef V + +#undef RT + +/* + * Round constants + */ +static const uint32_t RCON[10] = +{ + 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080, + 0x0000001B, 0x00000036 +}; + +#else /* MBEDTLS_AES_ROM_TABLES */ + +/* + * Forward S-box & tables + */ +static unsigned char FSb[256]; +static uint32_t FT0[256]; +static uint32_t FT1[256]; +static uint32_t FT2[256]; +static uint32_t FT3[256]; + +/* + * Reverse S-box & tables + */ +static unsigned char RSb[256]; +static uint32_t RT0[256]; +static uint32_t RT1[256]; +static uint32_t RT2[256]; +static uint32_t RT3[256]; + +/* + * Round constants + */ +static uint32_t RCON[10]; + +/* + * Tables generation code + */ +#define ROTL8(x) ( ( x << 8 ) & 0xFFFFFFFF ) | ( x >> 24 ) +#define XTIME(x) ( ( x << 1 ) ^ ( ( x & 0x80 ) ? 0x1B : 0x00 ) ) +#define MUL(x,y) ( ( x && y ) ? pow[(log[x]+log[y]) % 255] : 0 ) + +static int aes_init_done = 0; + +static void aes_gen_tables( void ) +{ + int i, x, y, z; + int pow[256]; + int log[256]; + + /* + * compute pow and log tables over GF(2^8) + */ + for( i = 0, x = 1; i < 256; i++ ) + { + pow[i] = x; + log[x] = i; + x = ( x ^ XTIME( x ) ) & 0xFF; + } + + /* + * calculate the round constants + */ + for( i = 0, x = 1; i < 10; i++ ) + { + RCON[i] = (uint32_t) x; + x = XTIME( x ) & 0xFF; + } + + /* + * generate the forward and reverse S-boxes + */ + FSb[0x00] = 0x63; + RSb[0x63] = 0x00; + + for( i = 1; i < 256; i++ ) + { + x = pow[255 - log[i]]; + + y = x; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; + x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; + x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; + x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; + x ^= y ^ 0x63; + + FSb[i] = (unsigned char) x; + RSb[x] = (unsigned char) i; + } + + /* + * generate the forward and reverse tables + */ + for( i = 0; i < 256; i++ ) + { + x = FSb[i]; + y = XTIME( x ) & 0xFF; + z = ( y ^ x ) & 0xFF; + + FT0[i] = ( (uint32_t) y ) ^ + ( (uint32_t) x << 8 ) ^ + ( (uint32_t) x << 16 ) ^ + ( (uint32_t) z << 24 ); + + FT1[i] = ROTL8( FT0[i] ); + FT2[i] = ROTL8( FT1[i] ); + FT3[i] = ROTL8( FT2[i] ); + + x = RSb[i]; + + RT0[i] = ( (uint32_t) MUL( 0x0E, x ) ) ^ + ( (uint32_t) MUL( 0x09, x ) << 8 ) ^ + ( (uint32_t) MUL( 0x0D, x ) << 16 ) ^ + ( (uint32_t) MUL( 0x0B, x ) << 24 ); + + RT1[i] = ROTL8( RT0[i] ); + RT2[i] = ROTL8( RT1[i] ); + RT3[i] = ROTL8( RT2[i] ); + } +} + +#endif /* MBEDTLS_AES_ROM_TABLES */ + +void mbedtls_aes_init( mbedtls_aes_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_aes_context ) ); +} + +void mbedtls_aes_free( mbedtls_aes_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_aes_context ) ); +} + +/* + * AES key schedule (encryption) + */ +#if !defined(MBEDTLS_AES_SETKEY_ENC_ALT) +int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, + unsigned int keybits ) +{ + unsigned int i; + uint32_t *RK; + +#if !defined(MBEDTLS_AES_ROM_TABLES) + if( aes_init_done == 0 ) + { + aes_gen_tables(); + aes_init_done = 1; + + } +#endif + + switch( keybits ) + { + case 128: ctx->nr = 10; break; + case 192: ctx->nr = 12; break; + case 256: ctx->nr = 14; break; + default : return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH ); + } + +#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16) + if( aes_padlock_ace == -1 ) + aes_padlock_ace = mbedtls_padlock_has_support( MBEDTLS_PADLOCK_ACE ); + + if( aes_padlock_ace ) + ctx->rk = RK = MBEDTLS_PADLOCK_ALIGN16( ctx->buf ); + else +#endif + ctx->rk = RK = ctx->buf; + +#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) + if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) ) + return( mbedtls_aesni_setkey_enc( (unsigned char *) ctx->rk, key, keybits ) ); +#endif + + for( i = 0; i < ( keybits >> 5 ); i++ ) + { + GET_UINT32_LE( RK[i], key, i << 2 ); + } + + switch( ctx->nr ) + { + case 10: + + for( i = 0; i < 10; i++, RK += 4 ) + { + RK[4] = RK[0] ^ RCON[i] ^ + ( (uint32_t) FSb[ ( RK[3] >> 8 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( RK[3] >> 16 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( RK[3] >> 24 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( RK[3] ) & 0xFF ] << 24 ); + + RK[5] = RK[1] ^ RK[4]; + RK[6] = RK[2] ^ RK[5]; + RK[7] = RK[3] ^ RK[6]; + } + break; + + case 12: + + for( i = 0; i < 8; i++, RK += 6 ) + { + RK[6] = RK[0] ^ RCON[i] ^ + ( (uint32_t) FSb[ ( RK[5] >> 8 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( RK[5] >> 16 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( RK[5] >> 24 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( RK[5] ) & 0xFF ] << 24 ); + + RK[7] = RK[1] ^ RK[6]; + RK[8] = RK[2] ^ RK[7]; + RK[9] = RK[3] ^ RK[8]; + RK[10] = RK[4] ^ RK[9]; + RK[11] = RK[5] ^ RK[10]; + } + break; + + case 14: + + for( i = 0; i < 7; i++, RK += 8 ) + { + RK[8] = RK[0] ^ RCON[i] ^ + ( (uint32_t) FSb[ ( RK[7] >> 8 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( RK[7] >> 16 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( RK[7] >> 24 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( RK[7] ) & 0xFF ] << 24 ); + + RK[9] = RK[1] ^ RK[8]; + RK[10] = RK[2] ^ RK[9]; + RK[11] = RK[3] ^ RK[10]; + + RK[12] = RK[4] ^ + ( (uint32_t) FSb[ ( RK[11] ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( RK[11] >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( RK[11] >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( RK[11] >> 24 ) & 0xFF ] << 24 ); + + RK[13] = RK[5] ^ RK[12]; + RK[14] = RK[6] ^ RK[13]; + RK[15] = RK[7] ^ RK[14]; + } + break; + } + + return( 0 ); +} +#endif /* !MBEDTLS_AES_SETKEY_ENC_ALT */ + +/* + * AES key schedule (decryption) + */ +#if !defined(MBEDTLS_AES_SETKEY_DEC_ALT) +int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, + unsigned int keybits ) +{ + int i, j, ret; + mbedtls_aes_context cty; + uint32_t *RK; + uint32_t *SK; + + mbedtls_aes_init( &cty ); + +#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16) + if( aes_padlock_ace == -1 ) + aes_padlock_ace = mbedtls_padlock_has_support( MBEDTLS_PADLOCK_ACE ); + + if( aes_padlock_ace ) + ctx->rk = RK = MBEDTLS_PADLOCK_ALIGN16( ctx->buf ); + else +#endif + ctx->rk = RK = ctx->buf; + + /* Also checks keybits */ + if( ( ret = mbedtls_aes_setkey_enc( &cty, key, keybits ) ) != 0 ) + goto exit; + + ctx->nr = cty.nr; + +#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) + if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) ) + { + mbedtls_aesni_inverse_key( (unsigned char *) ctx->rk, + (const unsigned char *) cty.rk, ctx->nr ); + goto exit; + } +#endif + + SK = cty.rk + cty.nr * 4; + + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + + for( i = ctx->nr - 1, SK -= 8; i > 0; i--, SK -= 8 ) + { + for( j = 0; j < 4; j++, SK++ ) + { + *RK++ = RT0[ FSb[ ( *SK ) & 0xFF ] ] ^ + RT1[ FSb[ ( *SK >> 8 ) & 0xFF ] ] ^ + RT2[ FSb[ ( *SK >> 16 ) & 0xFF ] ] ^ + RT3[ FSb[ ( *SK >> 24 ) & 0xFF ] ]; + } + } + + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + +exit: + mbedtls_aes_free( &cty ); + + return( ret ); +} +#endif /* !MBEDTLS_AES_SETKEY_DEC_ALT */ + +#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ +{ \ + X0 = *RK++ ^ FT0[ ( Y0 ) & 0xFF ] ^ \ + FT1[ ( Y1 >> 8 ) & 0xFF ] ^ \ + FT2[ ( Y2 >> 16 ) & 0xFF ] ^ \ + FT3[ ( Y3 >> 24 ) & 0xFF ]; \ + \ + X1 = *RK++ ^ FT0[ ( Y1 ) & 0xFF ] ^ \ + FT1[ ( Y2 >> 8 ) & 0xFF ] ^ \ + FT2[ ( Y3 >> 16 ) & 0xFF ] ^ \ + FT3[ ( Y0 >> 24 ) & 0xFF ]; \ + \ + X2 = *RK++ ^ FT0[ ( Y2 ) & 0xFF ] ^ \ + FT1[ ( Y3 >> 8 ) & 0xFF ] ^ \ + FT2[ ( Y0 >> 16 ) & 0xFF ] ^ \ + FT3[ ( Y1 >> 24 ) & 0xFF ]; \ + \ + X3 = *RK++ ^ FT0[ ( Y3 ) & 0xFF ] ^ \ + FT1[ ( Y0 >> 8 ) & 0xFF ] ^ \ + FT2[ ( Y1 >> 16 ) & 0xFF ] ^ \ + FT3[ ( Y2 >> 24 ) & 0xFF ]; \ +} + +#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ +{ \ + X0 = *RK++ ^ RT0[ ( Y0 ) & 0xFF ] ^ \ + RT1[ ( Y3 >> 8 ) & 0xFF ] ^ \ + RT2[ ( Y2 >> 16 ) & 0xFF ] ^ \ + RT3[ ( Y1 >> 24 ) & 0xFF ]; \ + \ + X1 = *RK++ ^ RT0[ ( Y1 ) & 0xFF ] ^ \ + RT1[ ( Y0 >> 8 ) & 0xFF ] ^ \ + RT2[ ( Y3 >> 16 ) & 0xFF ] ^ \ + RT3[ ( Y2 >> 24 ) & 0xFF ]; \ + \ + X2 = *RK++ ^ RT0[ ( Y2 ) & 0xFF ] ^ \ + RT1[ ( Y1 >> 8 ) & 0xFF ] ^ \ + RT2[ ( Y0 >> 16 ) & 0xFF ] ^ \ + RT3[ ( Y3 >> 24 ) & 0xFF ]; \ + \ + X3 = *RK++ ^ RT0[ ( Y3 ) & 0xFF ] ^ \ + RT1[ ( Y2 >> 8 ) & 0xFF ] ^ \ + RT2[ ( Y1 >> 16 ) & 0xFF ] ^ \ + RT3[ ( Y0 >> 24 ) & 0xFF ]; \ +} + +/* + * AES-ECB block encryption + */ +#if !defined(MBEDTLS_AES_ENCRYPT_ALT) +void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ) +{ + int i; + uint32_t *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; + + RK = ctx->rk; + + GET_UINT32_LE( X0, input, 0 ); X0 ^= *RK++; + GET_UINT32_LE( X1, input, 4 ); X1 ^= *RK++; + GET_UINT32_LE( X2, input, 8 ); X2 ^= *RK++; + GET_UINT32_LE( X3, input, 12 ); X3 ^= *RK++; + + for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- ) + { + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); + } + + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); + + X0 = *RK++ ^ \ + ( (uint32_t) FSb[ ( Y0 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( Y3 >> 24 ) & 0xFF ] << 24 ); + + X1 = *RK++ ^ \ + ( (uint32_t) FSb[ ( Y1 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( Y0 >> 24 ) & 0xFF ] << 24 ); + + X2 = *RK++ ^ \ + ( (uint32_t) FSb[ ( Y2 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( Y1 >> 24 ) & 0xFF ] << 24 ); + + X3 = *RK++ ^ \ + ( (uint32_t) FSb[ ( Y3 ) & 0xFF ] ) ^ + ( (uint32_t) FSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) FSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) FSb[ ( Y2 >> 24 ) & 0xFF ] << 24 ); + + PUT_UINT32_LE( X0, output, 0 ); + PUT_UINT32_LE( X1, output, 4 ); + PUT_UINT32_LE( X2, output, 8 ); + PUT_UINT32_LE( X3, output, 12 ); +} +#endif /* !MBEDTLS_AES_ENCRYPT_ALT */ + +/* + * AES-ECB block decryption + */ +#if !defined(MBEDTLS_AES_DECRYPT_ALT) +void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ) +{ + int i; + uint32_t *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; + + RK = ctx->rk; + + GET_UINT32_LE( X0, input, 0 ); X0 ^= *RK++; + GET_UINT32_LE( X1, input, 4 ); X1 ^= *RK++; + GET_UINT32_LE( X2, input, 8 ); X2 ^= *RK++; + GET_UINT32_LE( X3, input, 12 ); X3 ^= *RK++; + + for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- ) + { + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); + } + + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); + + X0 = *RK++ ^ \ + ( (uint32_t) RSb[ ( Y0 ) & 0xFF ] ) ^ + ( (uint32_t) RSb[ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) RSb[ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) RSb[ ( Y1 >> 24 ) & 0xFF ] << 24 ); + + X1 = *RK++ ^ \ + ( (uint32_t) RSb[ ( Y1 ) & 0xFF ] ) ^ + ( (uint32_t) RSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) RSb[ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) RSb[ ( Y2 >> 24 ) & 0xFF ] << 24 ); + + X2 = *RK++ ^ \ + ( (uint32_t) RSb[ ( Y2 ) & 0xFF ] ) ^ + ( (uint32_t) RSb[ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) RSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) RSb[ ( Y3 >> 24 ) & 0xFF ] << 24 ); + + X3 = *RK++ ^ \ + ( (uint32_t) RSb[ ( Y3 ) & 0xFF ] ) ^ + ( (uint32_t) RSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ + ( (uint32_t) RSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ + ( (uint32_t) RSb[ ( Y0 >> 24 ) & 0xFF ] << 24 ); + + PUT_UINT32_LE( X0, output, 0 ); + PUT_UINT32_LE( X1, output, 4 ); + PUT_UINT32_LE( X2, output, 8 ); + PUT_UINT32_LE( X3, output, 12 ); +} +#endif /* !MBEDTLS_AES_DECRYPT_ALT */ + +/* + * AES-ECB block encryption/decryption + */ +int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ) +{ +#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) + if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) ) + return( mbedtls_aesni_crypt_ecb( ctx, mode, input, output ) ); +#endif + +#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) + if( aes_padlock_ace ) + { + if( mbedtls_padlock_xcryptecb( ctx, mode, input, output ) == 0 ) + return( 0 ); + + // If padlock data misaligned, we just fall back to + // unaccelerated mode + // + } +#endif + + if( mode == MBEDTLS_AES_ENCRYPT ) + mbedtls_aes_encrypt( ctx, input, output ); + else + mbedtls_aes_decrypt( ctx, input, output ); + + return( 0 ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * AES-CBC buffer encryption/decryption + */ +int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + int i; + unsigned char temp[16]; + + if( length % 16 ) + return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); + +#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) + if( aes_padlock_ace ) + { + if( mbedtls_padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 ) + return( 0 ); + + // If padlock data misaligned, we just fall back to + // unaccelerated mode + // + } +#endif + + if( mode == MBEDTLS_AES_DECRYPT ) + { + while( length > 0 ) + { + memcpy( temp, input, 16 ); + mbedtls_aes_crypt_ecb( ctx, mode, input, output ); + + for( i = 0; i < 16; i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, 16 ); + + input += 16; + output += 16; + length -= 16; + } + } + else + { + while( length > 0 ) + { + for( i = 0; i < 16; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_aes_crypt_ecb( ctx, mode, output, output ); + memcpy( iv, output, 16 ); + + input += 16; + output += 16; + length -= 16; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/* + * AES-CFB128 buffer encryption/decryption + */ +int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + int c; + size_t n = *iv_off; + + if( mode == MBEDTLS_AES_DECRYPT ) + { + while( length-- ) + { + if( n == 0 ) + mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + + c = *input++; + *output++ = (unsigned char)( c ^ iv[n] ); + iv[n] = (unsigned char) c; + + n = ( n + 1 ) & 0x0F; + } + } + else + { + while( length-- ) + { + if( n == 0 ) + mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + + iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); + + n = ( n + 1 ) & 0x0F; + } + } + + *iv_off = n; + + return( 0 ); +} + +/* + * AES-CFB8 buffer encryption/decryption + */ +int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + unsigned char c; + unsigned char ov[17]; + + while( length-- ) + { + memcpy( ov, iv, 16 ); + mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + + if( mode == MBEDTLS_AES_DECRYPT ) + ov[16] = *input; + + c = *output++ = (unsigned char)( iv[0] ^ *input++ ); + + if( mode == MBEDTLS_AES_ENCRYPT ) + ov[16] = c; + + memcpy( iv, ov + 1, 16 ); + } + + return( 0 ); +} +#endif /*MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * AES-CTR buffer encryption/decryption + */ +int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[16], + unsigned char stream_block[16], + const unsigned char *input, + unsigned char *output ) +{ + int c, i; + size_t n = *nc_off; + + while( length-- ) + { + if( n == 0 ) { + mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, nonce_counter, stream_block ); + + for( i = 16; i > 0; i-- ) + if( ++nonce_counter[i - 1] != 0 ) + break; + } + c = *input++; + *output++ = (unsigned char)( c ^ stream_block[n] ); + + n = ( n + 1 ) & 0x0F; + } + + *nc_off = n; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#endif /* !MBEDTLS_AES_ALT */ + +#if defined(MBEDTLS_SELF_TEST) +/* + * AES test vectors from: + * + * http://csrc.nist.gov/archive/aes/rijndael/rijndael-vals.zip + */ +static const unsigned char aes_test_ecb_dec[3][16] = +{ + { 0x44, 0x41, 0x6A, 0xC2, 0xD1, 0xF5, 0x3C, 0x58, + 0x33, 0x03, 0x91, 0x7E, 0x6B, 0xE9, 0xEB, 0xE0 }, + { 0x48, 0xE3, 0x1E, 0x9E, 0x25, 0x67, 0x18, 0xF2, + 0x92, 0x29, 0x31, 0x9C, 0x19, 0xF1, 0x5B, 0xA4 }, + { 0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB, 0x38, 0x2D, + 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE } +}; + +static const unsigned char aes_test_ecb_enc[3][16] = +{ + { 0xC3, 0x4C, 0x05, 0x2C, 0xC0, 0xDA, 0x8D, 0x73, + 0x45, 0x1A, 0xFE, 0x5F, 0x03, 0xBE, 0x29, 0x7F }, + { 0xF3, 0xF6, 0x75, 0x2A, 0xE8, 0xD7, 0x83, 0x11, + 0x38, 0xF0, 0x41, 0x56, 0x06, 0x31, 0xB1, 0x14 }, + { 0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0, 0xEE, 0x5D, + 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4 } +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const unsigned char aes_test_cbc_dec[3][16] = +{ + { 0xFA, 0xCA, 0x37, 0xE0, 0xB0, 0xC8, 0x53, 0x73, + 0xDF, 0x70, 0x6E, 0x73, 0xF7, 0xC9, 0xAF, 0x86 }, + { 0x5D, 0xF6, 0x78, 0xDD, 0x17, 0xBA, 0x4E, 0x75, + 0xB6, 0x17, 0x68, 0xC6, 0xAD, 0xEF, 0x7C, 0x7B }, + { 0x48, 0x04, 0xE1, 0x81, 0x8F, 0xE6, 0x29, 0x75, + 0x19, 0xA3, 0xE8, 0x8C, 0x57, 0x31, 0x04, 0x13 } +}; + +static const unsigned char aes_test_cbc_enc[3][16] = +{ + { 0x8A, 0x05, 0xFC, 0x5E, 0x09, 0x5A, 0xF4, 0x84, + 0x8A, 0x08, 0xD3, 0x28, 0xD3, 0x68, 0x8E, 0x3D }, + { 0x7B, 0xD9, 0x66, 0xD5, 0x3A, 0xD8, 0xC1, 0xBB, + 0x85, 0xD2, 0xAD, 0xFA, 0xE8, 0x7B, 0xB1, 0x04 }, + { 0xFE, 0x3C, 0x53, 0x65, 0x3E, 0x2F, 0x45, 0xB5, + 0x6F, 0xCD, 0x88, 0xB2, 0xCC, 0x89, 0x8F, 0xF0 } +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/* + * AES-CFB128 test vectors from: + * + * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf + */ +static const unsigned char aes_test_cfb128_key[3][32] = +{ + { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, + 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }, + { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, + 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, + 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B }, + { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, + 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, + 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, + 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } +}; + +static const unsigned char aes_test_cfb128_iv[16] = +{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F +}; + +static const unsigned char aes_test_cfb128_pt[64] = +{ + 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, + 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A, + 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, + 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51, + 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, + 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF, + 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, + 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10 +}; + +static const unsigned char aes_test_cfb128_ct[3][64] = +{ + { 0x3B, 0x3F, 0xD9, 0x2E, 0xB7, 0x2D, 0xAD, 0x20, + 0x33, 0x34, 0x49, 0xF8, 0xE8, 0x3C, 0xFB, 0x4A, + 0xC8, 0xA6, 0x45, 0x37, 0xA0, 0xB3, 0xA9, 0x3F, + 0xCD, 0xE3, 0xCD, 0xAD, 0x9F, 0x1C, 0xE5, 0x8B, + 0x26, 0x75, 0x1F, 0x67, 0xA3, 0xCB, 0xB1, 0x40, + 0xB1, 0x80, 0x8C, 0xF1, 0x87, 0xA4, 0xF4, 0xDF, + 0xC0, 0x4B, 0x05, 0x35, 0x7C, 0x5D, 0x1C, 0x0E, + 0xEA, 0xC4, 0xC6, 0x6F, 0x9F, 0xF7, 0xF2, 0xE6 }, + { 0xCD, 0xC8, 0x0D, 0x6F, 0xDD, 0xF1, 0x8C, 0xAB, + 0x34, 0xC2, 0x59, 0x09, 0xC9, 0x9A, 0x41, 0x74, + 0x67, 0xCE, 0x7F, 0x7F, 0x81, 0x17, 0x36, 0x21, + 0x96, 0x1A, 0x2B, 0x70, 0x17, 0x1D, 0x3D, 0x7A, + 0x2E, 0x1E, 0x8A, 0x1D, 0xD5, 0x9B, 0x88, 0xB1, + 0xC8, 0xE6, 0x0F, 0xED, 0x1E, 0xFA, 0xC4, 0xC9, + 0xC0, 0x5F, 0x9F, 0x9C, 0xA9, 0x83, 0x4F, 0xA0, + 0x42, 0xAE, 0x8F, 0xBA, 0x58, 0x4B, 0x09, 0xFF }, + { 0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, + 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, + 0x39, 0xFF, 0xED, 0x14, 0x3B, 0x28, 0xB1, 0xC8, + 0x32, 0x11, 0x3C, 0x63, 0x31, 0xE5, 0x40, 0x7B, + 0xDF, 0x10, 0x13, 0x24, 0x15, 0xE5, 0x4B, 0x92, + 0xA1, 0x3E, 0xD0, 0xA8, 0x26, 0x7A, 0xE2, 0xF9, + 0x75, 0xA3, 0x85, 0x74, 0x1A, 0xB9, 0xCE, 0xF8, + 0x20, 0x31, 0x62, 0x3D, 0x55, 0xB1, 0xE4, 0x71 } +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * AES-CTR test vectors from: + * + * http://www.faqs.org/rfcs/rfc3686.html + */ + +static const unsigned char aes_test_ctr_key[3][16] = +{ + { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, + 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E }, + { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, + 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63 }, + { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, + 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC } +}; + +static const unsigned char aes_test_ctr_nonce_counter[3][16] = +{ + { 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, + { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, + 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, + { 0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, + 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01 } +}; + +static const unsigned char aes_test_ctr_pt[3][48] = +{ + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 } +}; + +static const unsigned char aes_test_ctr_ct[3][48] = +{ + { 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, + 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8 }, + { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, + 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, + 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, + 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28 }, + { 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, + 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, + 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, + 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, + 0x25, 0xB2, 0x07, 0x2F } +}; + +static const int aes_test_ctr_len[3] = + { 16, 32, 36 }; +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +/* + * Checkup routine + */ +int mbedtls_aes_self_test( int verbose ) +{ + int ret = 0, i, j, u, v; + unsigned char key[32]; + unsigned char buf[64]; +#if defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB) + unsigned char iv[16]; +#endif +#if defined(MBEDTLS_CIPHER_MODE_CBC) + unsigned char prv[16]; +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) || defined(MBEDTLS_CIPHER_MODE_CFB) + size_t offset; +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + int len; + unsigned char nonce_counter[16]; + unsigned char stream_block[16]; +#endif + mbedtls_aes_context ctx; + + memset( key, 0, 32 ); + mbedtls_aes_init( &ctx ); + + /* + * ECB mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " AES-ECB-%3d (%s): ", 128 + u * 64, + ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); + + memset( buf, 0, 16 ); + + if( v == MBEDTLS_AES_DECRYPT ) + { + mbedtls_aes_setkey_dec( &ctx, key, 128 + u * 64 ); + + for( j = 0; j < 10000; j++ ) + mbedtls_aes_crypt_ecb( &ctx, v, buf, buf ); + + if( memcmp( buf, aes_test_ecb_dec[u], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + else + { + mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 ); + + for( j = 0; j < 10000; j++ ) + mbedtls_aes_crypt_ecb( &ctx, v, buf, buf ); + + if( memcmp( buf, aes_test_ecb_enc[u], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + /* + * CBC mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " AES-CBC-%3d (%s): ", 128 + u * 64, + ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); + + memset( iv , 0, 16 ); + memset( prv, 0, 16 ); + memset( buf, 0, 16 ); + + if( v == MBEDTLS_AES_DECRYPT ) + { + mbedtls_aes_setkey_dec( &ctx, key, 128 + u * 64 ); + + for( j = 0; j < 10000; j++ ) + mbedtls_aes_crypt_cbc( &ctx, v, 16, iv, buf, buf ); + + if( memcmp( buf, aes_test_cbc_dec[u], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + else + { + mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 ); + + for( j = 0; j < 10000; j++ ) + { + unsigned char tmp[16]; + + mbedtls_aes_crypt_cbc( &ctx, v, 16, iv, buf, buf ); + + memcpy( tmp, prv, 16 ); + memcpy( prv, buf, 16 ); + memcpy( buf, tmp, 16 ); + } + + if( memcmp( prv, aes_test_cbc_enc[u], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + /* + * CFB128 mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " AES-CFB128-%3d (%s): ", 128 + u * 64, + ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); + + memcpy( iv, aes_test_cfb128_iv, 16 ); + memcpy( key, aes_test_cfb128_key[u], 16 + u * 8 ); + + offset = 0; + mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 ); + + if( v == MBEDTLS_AES_DECRYPT ) + { + memcpy( buf, aes_test_cfb128_ct[u], 64 ); + mbedtls_aes_crypt_cfb128( &ctx, v, 64, &offset, iv, buf, buf ); + + if( memcmp( buf, aes_test_cfb128_pt, 64 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + else + { + memcpy( buf, aes_test_cfb128_pt, 64 ); + mbedtls_aes_crypt_cfb128( &ctx, v, 64, &offset, iv, buf, buf ); + + if( memcmp( buf, aes_test_cfb128_ct[u], 64 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + /* + * CTR mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " AES-CTR-128 (%s): ", + ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); + + memcpy( nonce_counter, aes_test_ctr_nonce_counter[u], 16 ); + memcpy( key, aes_test_ctr_key[u], 16 ); + + offset = 0; + mbedtls_aes_setkey_enc( &ctx, key, 128 ); + + if( v == MBEDTLS_AES_DECRYPT ) + { + len = aes_test_ctr_len[u]; + memcpy( buf, aes_test_ctr_ct[u], len ); + + mbedtls_aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); + + if( memcmp( buf, aes_test_ctr_pt[u], len ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + else + { + len = aes_test_ctr_len[u]; + memcpy( buf, aes_test_ctr_pt[u], len ); + + mbedtls_aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); + + if( memcmp( buf, aes_test_ctr_ct[u], len ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + + ret = 0; + +exit: + mbedtls_aes_free( &ctx ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_AES_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aesni.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aesni.c new file mode 100644 index 0000000..1ca3c3e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/aesni.c @@ -0,0 +1,464 @@ +/* + * AES-NI support functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * [AES-WP] http://software.intel.com/en-us/articles/intel-advanced-encryption-standard-aes-instructions-set + * [CLMUL-WP] http://software.intel.com/en-us/articles/intel-carry-less-multiplication-instruction-and-its-usage-for-computing-the-gcm-mode/ + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_AESNI_C) + +#include "mbedtls/aesni.h" + +#include + +#ifndef asm +#define asm __asm +#endif + +#if defined(MBEDTLS_HAVE_X86_64) + +/* + * AES-NI support detection routine + */ +int mbedtls_aesni_has_support( unsigned int what ) +{ + static int done = 0; + static unsigned int c = 0; + + if( ! done ) + { + asm( "movl $1, %%eax \n\t" + "cpuid \n\t" + : "=c" (c) + : + : "eax", "ebx", "edx" ); + done = 1; + } + + return( ( c & what ) != 0 ); +} + +/* + * Binutils needs to be at least 2.19 to support AES-NI instructions. + * Unfortunately, a lot of users have a lower version now (2014-04). + * Emit bytecode directly in order to support "old" version of gas. + * + * Opcodes from the Intel architecture reference manual, vol. 3. + * We always use registers, so we don't need prefixes for memory operands. + * Operand macros are in gas order (src, dst) as opposed to Intel order + * (dst, src) in order to blend better into the surrounding assembly code. + */ +#define AESDEC ".byte 0x66,0x0F,0x38,0xDE," +#define AESDECLAST ".byte 0x66,0x0F,0x38,0xDF," +#define AESENC ".byte 0x66,0x0F,0x38,0xDC," +#define AESENCLAST ".byte 0x66,0x0F,0x38,0xDD," +#define AESIMC ".byte 0x66,0x0F,0x38,0xDB," +#define AESKEYGENA ".byte 0x66,0x0F,0x3A,0xDF," +#define PCLMULQDQ ".byte 0x66,0x0F,0x3A,0x44," + +#define xmm0_xmm0 "0xC0" +#define xmm0_xmm1 "0xC8" +#define xmm0_xmm2 "0xD0" +#define xmm0_xmm3 "0xD8" +#define xmm0_xmm4 "0xE0" +#define xmm1_xmm0 "0xC1" +#define xmm1_xmm2 "0xD1" + +/* + * AES-NI AES-ECB block en(de)cryption + */ +int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ) +{ + asm( "movdqu (%3), %%xmm0 \n\t" // load input + "movdqu (%1), %%xmm1 \n\t" // load round key 0 + "pxor %%xmm1, %%xmm0 \n\t" // round 0 + "add $16, %1 \n\t" // point to next round key + "subl $1, %0 \n\t" // normal rounds = nr - 1 + "test %2, %2 \n\t" // mode? + "jz 2f \n\t" // 0 = decrypt + + "1: \n\t" // encryption loop + "movdqu (%1), %%xmm1 \n\t" // load round key + AESENC xmm1_xmm0 "\n\t" // do round + "add $16, %1 \n\t" // point to next round key + "subl $1, %0 \n\t" // loop + "jnz 1b \n\t" + "movdqu (%1), %%xmm1 \n\t" // load round key + AESENCLAST xmm1_xmm0 "\n\t" // last round + "jmp 3f \n\t" + + "2: \n\t" // decryption loop + "movdqu (%1), %%xmm1 \n\t" + AESDEC xmm1_xmm0 "\n\t" // do round + "add $16, %1 \n\t" + "subl $1, %0 \n\t" + "jnz 2b \n\t" + "movdqu (%1), %%xmm1 \n\t" // load round key + AESDECLAST xmm1_xmm0 "\n\t" // last round + + "3: \n\t" + "movdqu %%xmm0, (%4) \n\t" // export output + : + : "r" (ctx->nr), "r" (ctx->rk), "r" (mode), "r" (input), "r" (output) + : "memory", "cc", "xmm0", "xmm1" ); + + + return( 0 ); +} + +/* + * GCM multiplication: c = a times b in GF(2^128) + * Based on [CLMUL-WP] algorithms 1 (with equation 27) and 5. + */ +void mbedtls_aesni_gcm_mult( unsigned char c[16], + const unsigned char a[16], + const unsigned char b[16] ) +{ + unsigned char aa[16], bb[16], cc[16]; + size_t i; + + /* The inputs are in big-endian order, so byte-reverse them */ + for( i = 0; i < 16; i++ ) + { + aa[i] = a[15 - i]; + bb[i] = b[15 - i]; + } + + asm( "movdqu (%0), %%xmm0 \n\t" // a1:a0 + "movdqu (%1), %%xmm1 \n\t" // b1:b0 + + /* + * Caryless multiplication xmm2:xmm1 = xmm0 * xmm1 + * using [CLMUL-WP] algorithm 1 (p. 13). + */ + "movdqa %%xmm1, %%xmm2 \n\t" // copy of b1:b0 + "movdqa %%xmm1, %%xmm3 \n\t" // same + "movdqa %%xmm1, %%xmm4 \n\t" // same + PCLMULQDQ xmm0_xmm1 ",0x00 \n\t" // a0*b0 = c1:c0 + PCLMULQDQ xmm0_xmm2 ",0x11 \n\t" // a1*b1 = d1:d0 + PCLMULQDQ xmm0_xmm3 ",0x10 \n\t" // a0*b1 = e1:e0 + PCLMULQDQ xmm0_xmm4 ",0x01 \n\t" // a1*b0 = f1:f0 + "pxor %%xmm3, %%xmm4 \n\t" // e1+f1:e0+f0 + "movdqa %%xmm4, %%xmm3 \n\t" // same + "psrldq $8, %%xmm4 \n\t" // 0:e1+f1 + "pslldq $8, %%xmm3 \n\t" // e0+f0:0 + "pxor %%xmm4, %%xmm2 \n\t" // d1:d0+e1+f1 + "pxor %%xmm3, %%xmm1 \n\t" // c1+e0+f1:c0 + + /* + * Now shift the result one bit to the left, + * taking advantage of [CLMUL-WP] eq 27 (p. 20) + */ + "movdqa %%xmm1, %%xmm3 \n\t" // r1:r0 + "movdqa %%xmm2, %%xmm4 \n\t" // r3:r2 + "psllq $1, %%xmm1 \n\t" // r1<<1:r0<<1 + "psllq $1, %%xmm2 \n\t" // r3<<1:r2<<1 + "psrlq $63, %%xmm3 \n\t" // r1>>63:r0>>63 + "psrlq $63, %%xmm4 \n\t" // r3>>63:r2>>63 + "movdqa %%xmm3, %%xmm5 \n\t" // r1>>63:r0>>63 + "pslldq $8, %%xmm3 \n\t" // r0>>63:0 + "pslldq $8, %%xmm4 \n\t" // r2>>63:0 + "psrldq $8, %%xmm5 \n\t" // 0:r1>>63 + "por %%xmm3, %%xmm1 \n\t" // r1<<1|r0>>63:r0<<1 + "por %%xmm4, %%xmm2 \n\t" // r3<<1|r2>>62:r2<<1 + "por %%xmm5, %%xmm2 \n\t" // r3<<1|r2>>62:r2<<1|r1>>63 + + /* + * Now reduce modulo the GCM polynomial x^128 + x^7 + x^2 + x + 1 + * using [CLMUL-WP] algorithm 5 (p. 20). + * Currently xmm2:xmm1 holds x3:x2:x1:x0 (already shifted). + */ + /* Step 2 (1) */ + "movdqa %%xmm1, %%xmm3 \n\t" // x1:x0 + "movdqa %%xmm1, %%xmm4 \n\t" // same + "movdqa %%xmm1, %%xmm5 \n\t" // same + "psllq $63, %%xmm3 \n\t" // x1<<63:x0<<63 = stuff:a + "psllq $62, %%xmm4 \n\t" // x1<<62:x0<<62 = stuff:b + "psllq $57, %%xmm5 \n\t" // x1<<57:x0<<57 = stuff:c + + /* Step 2 (2) */ + "pxor %%xmm4, %%xmm3 \n\t" // stuff:a+b + "pxor %%xmm5, %%xmm3 \n\t" // stuff:a+b+c + "pslldq $8, %%xmm3 \n\t" // a+b+c:0 + "pxor %%xmm3, %%xmm1 \n\t" // x1+a+b+c:x0 = d:x0 + + /* Steps 3 and 4 */ + "movdqa %%xmm1,%%xmm0 \n\t" // d:x0 + "movdqa %%xmm1,%%xmm4 \n\t" // same + "movdqa %%xmm1,%%xmm5 \n\t" // same + "psrlq $1, %%xmm0 \n\t" // e1:x0>>1 = e1:e0' + "psrlq $2, %%xmm4 \n\t" // f1:x0>>2 = f1:f0' + "psrlq $7, %%xmm5 \n\t" // g1:x0>>7 = g1:g0' + "pxor %%xmm4, %%xmm0 \n\t" // e1+f1:e0'+f0' + "pxor %%xmm5, %%xmm0 \n\t" // e1+f1+g1:e0'+f0'+g0' + // e0'+f0'+g0' is almost e0+f0+g0, ex\tcept for some missing + // bits carried from d. Now get those\t bits back in. + "movdqa %%xmm1,%%xmm3 \n\t" // d:x0 + "movdqa %%xmm1,%%xmm4 \n\t" // same + "movdqa %%xmm1,%%xmm5 \n\t" // same + "psllq $63, %%xmm3 \n\t" // d<<63:stuff + "psllq $62, %%xmm4 \n\t" // d<<62:stuff + "psllq $57, %%xmm5 \n\t" // d<<57:stuff + "pxor %%xmm4, %%xmm3 \n\t" // d<<63+d<<62:stuff + "pxor %%xmm5, %%xmm3 \n\t" // missing bits of d:stuff + "psrldq $8, %%xmm3 \n\t" // 0:missing bits of d + "pxor %%xmm3, %%xmm0 \n\t" // e1+f1+g1:e0+f0+g0 + "pxor %%xmm1, %%xmm0 \n\t" // h1:h0 + "pxor %%xmm2, %%xmm0 \n\t" // x3+h1:x2+h0 + + "movdqu %%xmm0, (%2) \n\t" // done + : + : "r" (aa), "r" (bb), "r" (cc) + : "memory", "cc", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" ); + + /* Now byte-reverse the outputs */ + for( i = 0; i < 16; i++ ) + c[i] = cc[15 - i]; + + return; +} + +/* + * Compute decryption round keys from encryption round keys + */ +void mbedtls_aesni_inverse_key( unsigned char *invkey, + const unsigned char *fwdkey, int nr ) +{ + unsigned char *ik = invkey; + const unsigned char *fk = fwdkey + 16 * nr; + + memcpy( ik, fk, 16 ); + + for( fk -= 16, ik += 16; fk > fwdkey; fk -= 16, ik += 16 ) + asm( "movdqu (%0), %%xmm0 \n\t" + AESIMC xmm0_xmm0 "\n\t" + "movdqu %%xmm0, (%1) \n\t" + : + : "r" (fk), "r" (ik) + : "memory", "xmm0" ); + + memcpy( ik, fk, 16 ); +} + +/* + * Key expansion, 128-bit case + */ +static void aesni_setkey_enc_128( unsigned char *rk, + const unsigned char *key ) +{ + asm( "movdqu (%1), %%xmm0 \n\t" // copy the original key + "movdqu %%xmm0, (%0) \n\t" // as round key 0 + "jmp 2f \n\t" // skip auxiliary routine + + /* + * Finish generating the next round key. + * + * On entry xmm0 is r3:r2:r1:r0 and xmm1 is X:stuff:stuff:stuff + * with X = rot( sub( r3 ) ) ^ RCON. + * + * On exit, xmm0 is r7:r6:r5:r4 + * with r4 = X + r0, r5 = r4 + r1, r6 = r5 + r2, r7 = r6 + r3 + * and those are written to the round key buffer. + */ + "1: \n\t" + "pshufd $0xff, %%xmm1, %%xmm1 \n\t" // X:X:X:X + "pxor %%xmm0, %%xmm1 \n\t" // X+r3:X+r2:X+r1:r4 + "pslldq $4, %%xmm0 \n\t" // r2:r1:r0:0 + "pxor %%xmm0, %%xmm1 \n\t" // X+r3+r2:X+r2+r1:r5:r4 + "pslldq $4, %%xmm0 \n\t" // etc + "pxor %%xmm0, %%xmm1 \n\t" + "pslldq $4, %%xmm0 \n\t" + "pxor %%xmm1, %%xmm0 \n\t" // update xmm0 for next time! + "add $16, %0 \n\t" // point to next round key + "movdqu %%xmm0, (%0) \n\t" // write it + "ret \n\t" + + /* Main "loop" */ + "2: \n\t" + AESKEYGENA xmm0_xmm1 ",0x01 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x02 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x04 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x08 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x10 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x20 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x40 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x80 \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x1B \n\tcall 1b \n\t" + AESKEYGENA xmm0_xmm1 ",0x36 \n\tcall 1b \n\t" + : + : "r" (rk), "r" (key) + : "memory", "cc", "0" ); +} + +/* + * Key expansion, 192-bit case + */ +static void aesni_setkey_enc_192( unsigned char *rk, + const unsigned char *key ) +{ + asm( "movdqu (%1), %%xmm0 \n\t" // copy original round key + "movdqu %%xmm0, (%0) \n\t" + "add $16, %0 \n\t" + "movq 16(%1), %%xmm1 \n\t" + "movq %%xmm1, (%0) \n\t" + "add $8, %0 \n\t" + "jmp 2f \n\t" // skip auxiliary routine + + /* + * Finish generating the next 6 quarter-keys. + * + * On entry xmm0 is r3:r2:r1:r0, xmm1 is stuff:stuff:r5:r4 + * and xmm2 is stuff:stuff:X:stuff with X = rot( sub( r3 ) ) ^ RCON. + * + * On exit, xmm0 is r9:r8:r7:r6 and xmm1 is stuff:stuff:r11:r10 + * and those are written to the round key buffer. + */ + "1: \n\t" + "pshufd $0x55, %%xmm2, %%xmm2 \n\t" // X:X:X:X + "pxor %%xmm0, %%xmm2 \n\t" // X+r3:X+r2:X+r1:r4 + "pslldq $4, %%xmm0 \n\t" // etc + "pxor %%xmm0, %%xmm2 \n\t" + "pslldq $4, %%xmm0 \n\t" + "pxor %%xmm0, %%xmm2 \n\t" + "pslldq $4, %%xmm0 \n\t" + "pxor %%xmm2, %%xmm0 \n\t" // update xmm0 = r9:r8:r7:r6 + "movdqu %%xmm0, (%0) \n\t" + "add $16, %0 \n\t" + "pshufd $0xff, %%xmm0, %%xmm2 \n\t" // r9:r9:r9:r9 + "pxor %%xmm1, %%xmm2 \n\t" // stuff:stuff:r9+r5:r10 + "pslldq $4, %%xmm1 \n\t" // r2:r1:r0:0 + "pxor %%xmm2, %%xmm1 \n\t" // xmm1 = stuff:stuff:r11:r10 + "movq %%xmm1, (%0) \n\t" + "add $8, %0 \n\t" + "ret \n\t" + + "2: \n\t" + AESKEYGENA xmm1_xmm2 ",0x01 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x02 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x04 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x08 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x10 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x20 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x40 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x80 \n\tcall 1b \n\t" + + : + : "r" (rk), "r" (key) + : "memory", "cc", "0" ); +} + +/* + * Key expansion, 256-bit case + */ +static void aesni_setkey_enc_256( unsigned char *rk, + const unsigned char *key ) +{ + asm( "movdqu (%1), %%xmm0 \n\t" + "movdqu %%xmm0, (%0) \n\t" + "add $16, %0 \n\t" + "movdqu 16(%1), %%xmm1 \n\t" + "movdqu %%xmm1, (%0) \n\t" + "jmp 2f \n\t" // skip auxiliary routine + + /* + * Finish generating the next two round keys. + * + * On entry xmm0 is r3:r2:r1:r0, xmm1 is r7:r6:r5:r4 and + * xmm2 is X:stuff:stuff:stuff with X = rot( sub( r7 )) ^ RCON + * + * On exit, xmm0 is r11:r10:r9:r8 and xmm1 is r15:r14:r13:r12 + * and those have been written to the output buffer. + */ + "1: \n\t" + "pshufd $0xff, %%xmm2, %%xmm2 \n\t" + "pxor %%xmm0, %%xmm2 \n\t" + "pslldq $4, %%xmm0 \n\t" + "pxor %%xmm0, %%xmm2 \n\t" + "pslldq $4, %%xmm0 \n\t" + "pxor %%xmm0, %%xmm2 \n\t" + "pslldq $4, %%xmm0 \n\t" + "pxor %%xmm2, %%xmm0 \n\t" + "add $16, %0 \n\t" + "movdqu %%xmm0, (%0) \n\t" + + /* Set xmm2 to stuff:Y:stuff:stuff with Y = subword( r11 ) + * and proceed to generate next round key from there */ + AESKEYGENA xmm0_xmm2 ",0x00 \n\t" + "pshufd $0xaa, %%xmm2, %%xmm2 \n\t" + "pxor %%xmm1, %%xmm2 \n\t" + "pslldq $4, %%xmm1 \n\t" + "pxor %%xmm1, %%xmm2 \n\t" + "pslldq $4, %%xmm1 \n\t" + "pxor %%xmm1, %%xmm2 \n\t" + "pslldq $4, %%xmm1 \n\t" + "pxor %%xmm2, %%xmm1 \n\t" + "add $16, %0 \n\t" + "movdqu %%xmm1, (%0) \n\t" + "ret \n\t" + + /* + * Main "loop" - Generating one more key than necessary, + * see definition of mbedtls_aes_context.buf + */ + "2: \n\t" + AESKEYGENA xmm1_xmm2 ",0x01 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x02 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x04 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x08 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x10 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x20 \n\tcall 1b \n\t" + AESKEYGENA xmm1_xmm2 ",0x40 \n\tcall 1b \n\t" + : + : "r" (rk), "r" (key) + : "memory", "cc", "0" ); +} + +/* + * Key expansion, wrapper + */ +int mbedtls_aesni_setkey_enc( unsigned char *rk, + const unsigned char *key, + size_t bits ) +{ + switch( bits ) + { + case 128: aesni_setkey_enc_128( rk, key ); break; + case 192: aesni_setkey_enc_192( rk, key ); break; + case 256: aesni_setkey_enc_256( rk, key ); break; + default : return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH ); + } + + return( 0 ); +} + +#endif /* MBEDTLS_HAVE_X86_64 */ + +#endif /* MBEDTLS_AESNI_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/arc4.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/arc4.c new file mode 100644 index 0000000..05b33d3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/arc4.c @@ -0,0 +1,205 @@ +/* + * An implementation of the ARCFOUR algorithm + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The ARCFOUR algorithm was publicly disclosed on 94/09. + * + * http://groups.google.com/group/sci.crypt/msg/10a300c9d21afca0 + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ARC4_C) + +#include "mbedtls/arc4.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_ARC4_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +void mbedtls_arc4_init( mbedtls_arc4_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_arc4_context ) ); +} + +void mbedtls_arc4_free( mbedtls_arc4_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_arc4_context ) ); +} + +/* + * ARC4 key schedule + */ +void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, + unsigned int keylen ) +{ + int i, j, a; + unsigned int k; + unsigned char *m; + + ctx->x = 0; + ctx->y = 0; + m = ctx->m; + + for( i = 0; i < 256; i++ ) + m[i] = (unsigned char) i; + + j = k = 0; + + for( i = 0; i < 256; i++, k++ ) + { + if( k >= keylen ) k = 0; + + a = m[i]; + j = ( j + a + key[k] ) & 0xFF; + m[i] = m[j]; + m[j] = (unsigned char) a; + } +} + +/* + * ARC4 cipher function + */ +int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, + unsigned char *output ) +{ + int x, y, a, b; + size_t i; + unsigned char *m; + + x = ctx->x; + y = ctx->y; + m = ctx->m; + + for( i = 0; i < length; i++ ) + { + x = ( x + 1 ) & 0xFF; a = m[x]; + y = ( y + a ) & 0xFF; b = m[y]; + + m[x] = (unsigned char) b; + m[y] = (unsigned char) a; + + output[i] = (unsigned char) + ( input[i] ^ m[(unsigned char)( a + b )] ); + } + + ctx->x = x; + ctx->y = y; + + return( 0 ); +} + +#endif /* !MBEDTLS_ARC4_ALT */ + +#if defined(MBEDTLS_SELF_TEST) +/* + * ARC4 tests vectors as posted by Eric Rescorla in sep. 1994: + * + * http://groups.google.com/group/comp.security.misc/msg/10a300c9d21afca0 + */ +static const unsigned char arc4_test_key[3][8] = +{ + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +}; + +static const unsigned char arc4_test_pt[3][8] = +{ + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +}; + +static const unsigned char arc4_test_ct[3][8] = +{ + { 0x75, 0xB7, 0x87, 0x80, 0x99, 0xE0, 0xC5, 0x96 }, + { 0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79 }, + { 0xDE, 0x18, 0x89, 0x41, 0xA3, 0x37, 0x5D, 0x3A } +}; + +/* + * Checkup routine + */ +int mbedtls_arc4_self_test( int verbose ) +{ + int i, ret = 0; + unsigned char ibuf[8]; + unsigned char obuf[8]; + mbedtls_arc4_context ctx; + + mbedtls_arc4_init( &ctx ); + + for( i = 0; i < 3; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " ARC4 test #%d: ", i + 1 ); + + memcpy( ibuf, arc4_test_pt[i], 8 ); + + mbedtls_arc4_setup( &ctx, arc4_test_key[i], 8 ); + mbedtls_arc4_crypt( &ctx, 8, ibuf, obuf ); + + if( memcmp( obuf, arc4_test_ct[i], 8 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_arc4_free( &ctx ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_ARC4_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1parse.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1parse.c new file mode 100644 index 0000000..4dd65c0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1parse.c @@ -0,0 +1,393 @@ +/* + * Generic ASN.1 parsing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ASN1_PARSE_C) + +#include "mbedtls/asn1.h" + +#include + +#if defined(MBEDTLS_BIGNUM_C) +#include "mbedtls/bignum.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * ASN.1 DER decoding routines + */ +int mbedtls_asn1_get_len( unsigned char **p, + const unsigned char *end, + size_t *len ) +{ + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + if( ( **p & 0x80 ) == 0 ) + *len = *(*p)++; + else + { + switch( **p & 0x7F ) + { + case 1: + if( ( end - *p ) < 2 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + *len = (*p)[1]; + (*p) += 2; + break; + + case 2: + if( ( end - *p ) < 3 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + *len = ( (size_t)(*p)[1] << 8 ) | (*p)[2]; + (*p) += 3; + break; + + case 3: + if( ( end - *p ) < 4 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + *len = ( (size_t)(*p)[1] << 16 ) | + ( (size_t)(*p)[2] << 8 ) | (*p)[3]; + (*p) += 4; + break; + + case 4: + if( ( end - *p ) < 5 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + *len = ( (size_t)(*p)[1] << 24 ) | ( (size_t)(*p)[2] << 16 ) | + ( (size_t)(*p)[3] << 8 ) | (*p)[4]; + (*p) += 5; + break; + + default: + return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + } + } + + if( *len > (size_t) ( end - *p ) ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + return( 0 ); +} + +int mbedtls_asn1_get_tag( unsigned char **p, + const unsigned char *end, + size_t *len, int tag ) +{ + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + if( **p != tag ) + return( MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + (*p)++; + + return( mbedtls_asn1_get_len( p, end, len ) ); +} + +int mbedtls_asn1_get_bool( unsigned char **p, + const unsigned char *end, + int *val ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_BOOLEAN ) ) != 0 ) + return( ret ); + + if( len != 1 ) + return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + + *val = ( **p != 0 ) ? 1 : 0; + (*p)++; + + return( 0 ); +} + +int mbedtls_asn1_get_int( unsigned char **p, + const unsigned char *end, + int *val ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 ) + return( ret ); + + if( len == 0 || len > sizeof( int ) || ( **p & 0x80 ) != 0 ) + return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + + *val = 0; + + while( len-- > 0 ) + { + *val = ( *val << 8 ) | **p; + (*p)++; + } + + return( 0 ); +} + +#if defined(MBEDTLS_BIGNUM_C) +int mbedtls_asn1_get_mpi( unsigned char **p, + const unsigned char *end, + mbedtls_mpi *X ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 ) + return( ret ); + + ret = mbedtls_mpi_read_binary( X, *p, len ); + + *p += len; + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C */ + +int mbedtls_asn1_get_bitstring( unsigned char **p, const unsigned char *end, + mbedtls_asn1_bitstring *bs) +{ + int ret; + + /* Certificate type is a single byte bitstring */ + if( ( ret = mbedtls_asn1_get_tag( p, end, &bs->len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 ) + return( ret ); + + /* Check length, subtract one for actual bit string length */ + if( bs->len < 1 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + bs->len -= 1; + + /* Get number of unused bits, ensure unused bits <= 7 */ + bs->unused_bits = **p; + if( bs->unused_bits > 7 ) + return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + (*p)++; + + /* Get actual bitstring */ + bs->p = *p; + *p += bs->len; + + if( *p != end ) + return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * Get a bit string without unused bits + */ +int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end, + size_t *len ) +{ + int ret; + + if( ( ret = mbedtls_asn1_get_tag( p, end, len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 ) + return( ret ); + + if( (*len)-- < 2 || *(*p)++ != 0 ) + return( MBEDTLS_ERR_ASN1_INVALID_DATA ); + + return( 0 ); +} + + + +/* + * Parses and splits an ASN.1 "SEQUENCE OF " + */ +int mbedtls_asn1_get_sequence_of( unsigned char **p, + const unsigned char *end, + mbedtls_asn1_sequence *cur, + int tag) +{ + int ret; + size_t len; + mbedtls_asn1_buf *buf; + + /* Get main sequence tag */ + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( ret ); + + if( *p + len != end ) + return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + while( *p < end ) + { + buf = &(cur->buf); + buf->tag = **p; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &buf->len, tag ) ) != 0 ) + return( ret ); + + buf->p = *p; + *p += buf->len; + + /* Allocate and assign next pointer */ + if( *p < end ) + { + cur->next = (mbedtls_asn1_sequence*)mbedtls_calloc( 1, + sizeof( mbedtls_asn1_sequence ) ); + + if( cur->next == NULL ) + return( MBEDTLS_ERR_ASN1_ALLOC_FAILED ); + + cur = cur->next; + } + } + + /* Set final sequence entry's next pointer to NULL */ + cur->next = NULL; + + if( *p != end ) + return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +int mbedtls_asn1_get_alg( unsigned char **p, + const unsigned char *end, + mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( ret ); + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + alg->tag = **p; + end = *p + len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &alg->len, MBEDTLS_ASN1_OID ) ) != 0 ) + return( ret ); + + alg->p = *p; + *p += alg->len; + + if( *p == end ) + { + mbedtls_zeroize( params, sizeof(mbedtls_asn1_buf) ); + return( 0 ); + } + + params->tag = **p; + (*p)++; + + if( ( ret = mbedtls_asn1_get_len( p, end, ¶ms->len ) ) != 0 ) + return( ret ); + + params->p = *p; + *p += params->len; + + if( *p != end ) + return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +int mbedtls_asn1_get_alg_null( unsigned char **p, + const unsigned char *end, + mbedtls_asn1_buf *alg ) +{ + int ret; + mbedtls_asn1_buf params; + + memset( ¶ms, 0, sizeof(mbedtls_asn1_buf) ); + + if( ( ret = mbedtls_asn1_get_alg( p, end, alg, ¶ms ) ) != 0 ) + return( ret ); + + if( ( params.tag != MBEDTLS_ASN1_NULL && params.tag != 0 ) || params.len != 0 ) + return( MBEDTLS_ERR_ASN1_INVALID_DATA ); + + return( 0 ); +} + +void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *cur ) +{ + if( cur == NULL ) + return; + + mbedtls_free( cur->oid.p ); + mbedtls_free( cur->val.p ); + + mbedtls_zeroize( cur, sizeof( mbedtls_asn1_named_data ) ); +} + +void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head ) +{ + mbedtls_asn1_named_data *cur; + + while( ( cur = *head ) != NULL ) + { + *head = cur->next; + mbedtls_asn1_free_named_data( cur ); + mbedtls_free( cur ); + } +} + +mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( mbedtls_asn1_named_data *list, + const char *oid, size_t len ) +{ + while( list != NULL ) + { + if( list->oid.len == len && + memcmp( list->oid.p, oid, len ) == 0 ) + { + break; + } + + list = list->next; + } + + return( list ); +} + +#endif /* MBEDTLS_ASN1_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1write.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1write.c new file mode 100644 index 0000000..69b61b2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/asn1write.c @@ -0,0 +1,390 @@ +/* + * ASN.1 buffer writing functionality + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ASN1_WRITE_C) + +#include "mbedtls/asn1write.h" + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len ) +{ + if( len < 0x80 ) + { + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = (unsigned char) len; + return( 1 ); + } + + if( len <= 0xFF ) + { + if( *p - start < 2 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = (unsigned char) len; + *--(*p) = 0x81; + return( 2 ); + } + + if( len <= 0xFFFF ) + { + if( *p - start < 3 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = ( len ) & 0xFF; + *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = 0x82; + return( 3 ); + } + + if( len <= 0xFFFFFF ) + { + if( *p - start < 4 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = ( len ) & 0xFF; + *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = ( len >> 16 ) & 0xFF; + *--(*p) = 0x83; + return( 4 ); + } + + if( len <= 0xFFFFFFFF ) + { + if( *p - start < 5 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = ( len ) & 0xFF; + *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = ( len >> 16 ) & 0xFF; + *--(*p) = ( len >> 24 ) & 0xFF; + *--(*p) = 0x84; + return( 5 ); + } + + return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); +} + +int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag ) +{ + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = tag; + + return( 1 ); +} + +int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t size ) +{ + size_t len = 0; + + if( *p < start || (size_t)( *p - start ) < size ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len = size; + (*p) -= len; + memcpy( *p, buf, len ); + + return( (int) len ); +} + +#if defined(MBEDTLS_BIGNUM_C) +int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X ) +{ + int ret; + size_t len = 0; + + // Write the MPI + // + len = mbedtls_mpi_size( X ); + + if( *p < start || (size_t)( *p - start ) < len ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + (*p) -= len; + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( X, *p, len ) ); + + // DER format assumes 2s complement for numbers, so the leftmost bit + // should be 0 for positive numbers and 1 for negative numbers. + // + if( X->s ==1 && **p & 0x80 ) + { + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = 0x00; + len += 1; + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_INTEGER ) ); + + ret = (int) len; + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C */ + +int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start ) +{ + int ret; + size_t len = 0; + + // Write NULL + // + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, 0) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_NULL ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) oid, oid_len ) ); + MBEDTLS_ASN1_CHK_ADD( len , mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len , mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_OID ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len, + size_t par_len ) +{ + int ret; + size_t len = 0; + + if( par_len == 0 ) + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_null( p, start ) ); + else + len += par_len; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( p, start, oid, oid_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean ) +{ + int ret; + size_t len = 0; + + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = (boolean) ? 255 : 0; + len++; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_BOOLEAN ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ) +{ + int ret; + size_t len = 0; + + // TODO negative values and values larger than 128 + // DER format assumes 2s complement for numbers, so the leftmost bit + // should be 0 for positive numbers and 1 for negative numbers. + // + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len += 1; + *--(*p) = val; + + if( val > 0 && **p & 0x80 ) + { + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = 0x00; + len += 1; + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_INTEGER ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) text, text_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_PRINTABLE_STRING ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) text, text_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_IA5_STRING ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t bits ) +{ + int ret; + size_t len = 0, size; + + size = ( bits / 8 ) + ( ( bits % 8 ) ? 1 : 0 ); + + // Calculate byte length + // + if( *p < start || (size_t)( *p - start ) < size + 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len = size + 1; + (*p) -= size; + memcpy( *p, buf, size ); + + // Write unused bits + // + *--(*p) = (unsigned char) (size * 8 - bits); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_BIT_STRING ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t size ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, buf, size ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_OCTET_STRING ) ); + + return( (int) len ); +} + +mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data **head, + const char *oid, size_t oid_len, + const unsigned char *val, + size_t val_len ) +{ + mbedtls_asn1_named_data *cur; + + if( ( cur = mbedtls_asn1_find_named_data( *head, oid, oid_len ) ) == NULL ) + { + // Add new entry if not present yet based on OID + // + cur = (mbedtls_asn1_named_data*)mbedtls_calloc( 1, + sizeof(mbedtls_asn1_named_data) ); + if( cur == NULL ) + return( NULL ); + + cur->oid.len = oid_len; + cur->oid.p = mbedtls_calloc( 1, oid_len ); + if( cur->oid.p == NULL ) + { + mbedtls_free( cur ); + return( NULL ); + } + + memcpy( cur->oid.p, oid, oid_len ); + + cur->val.len = val_len; + cur->val.p = mbedtls_calloc( 1, val_len ); + if( cur->val.p == NULL ) + { + mbedtls_free( cur->oid.p ); + mbedtls_free( cur ); + return( NULL ); + } + + cur->next = *head; + *head = cur; + } + else if( cur->val.len < val_len ) + { + /* + * Enlarge existing value buffer if needed + * Preserve old data until the allocation succeeded, to leave list in + * a consistent state in case allocation fails. + */ + void *p = mbedtls_calloc( 1, val_len ); + if( p == NULL ) + return( NULL ); + + mbedtls_free( cur->val.p ); + cur->val.p = p; + cur->val.len = val_len; + } + + if( val != NULL ) + memcpy( cur->val.p, val, val_len ); + + return( cur ); +} +#endif /* MBEDTLS_ASN1_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/base64.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/base64.c new file mode 100644 index 0000000..f06b57b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/base64.c @@ -0,0 +1,293 @@ +/* + * RFC 1521 base64 encoding/decoding + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_BASE64_C) + +#include "mbedtls/base64.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#include +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +static const unsigned char base64_enc_map[64] = +{ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '/' +}; + +static const unsigned char base64_dec_map[128] = +{ + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 62, 127, 127, 127, 63, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, + 127, 64, 127, 127, 127, 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 127, 127, 127, 127, 127, 127, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 127, 127, 127, 127, 127 +}; + +#define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */ + +/* + * Encode a buffer into base64 format + */ +int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen ) +{ + size_t i, n; + int C1, C2, C3; + unsigned char *p; + + if( slen == 0 ) + { + *olen = 0; + return( 0 ); + } + + n = slen / 3 + ( slen % 3 != 0 ); + + if( n > ( BASE64_SIZE_T_MAX - 1 ) / 4 ) + { + *olen = BASE64_SIZE_T_MAX; + return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); + } + + n *= 4; + + if( ( dlen < n + 1 ) || ( NULL == dst ) ) + { + *olen = n + 1; + return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); + } + + n = ( slen / 3 ) * 3; + + for( i = 0, p = dst; i < n; i += 3 ) + { + C1 = *src++; + C2 = *src++; + C3 = *src++; + + *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; + *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; + *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F]; + *p++ = base64_enc_map[C3 & 0x3F]; + } + + if( i < slen ) + { + C1 = *src++; + C2 = ( ( i + 1 ) < slen ) ? *src++ : 0; + + *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; + *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; + + if( ( i + 1 ) < slen ) + *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F]; + else *p++ = '='; + + *p++ = '='; + } + + *olen = p - dst; + *p = 0; + + return( 0 ); +} + +/* + * Decode a base64-formatted buffer + */ +int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen ) +{ + size_t i, n; + uint32_t j, x; + unsigned char *p; + + /* First pass: check for validity and get output length */ + for( i = n = j = 0; i < slen; i++ ) + { + /* Skip spaces before checking for EOL */ + x = 0; + while( i < slen && src[i] == ' ' ) + { + ++i; + ++x; + } + + /* Spaces at end of buffer are OK */ + if( i == slen ) + break; + + if( ( slen - i ) >= 2 && + src[i] == '\r' && src[i + 1] == '\n' ) + continue; + + if( src[i] == '\n' ) + continue; + + /* Space inside a line is an error */ + if( x != 0 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + + if( src[i] == '=' && ++j > 2 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + + if( src[i] > 127 || base64_dec_map[src[i]] == 127 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + + if( base64_dec_map[src[i]] < 64 && j != 0 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + + n++; + } + + if( n == 0 ) + { + *olen = 0; + return( 0 ); + } + + /* The following expression is to calculate the following formula without + * risk of integer overflow in n: + * n = ( ( n * 6 ) + 7 ) >> 3; + */ + n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 ); + n -= j; + + if( dst == NULL || dlen < n ) + { + *olen = n; + return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); + } + + for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ ) + { + if( *src == '\r' || *src == '\n' || *src == ' ' ) + continue; + + j -= ( base64_dec_map[*src] == 64 ); + x = ( x << 6 ) | ( base64_dec_map[*src] & 0x3F ); + + if( ++n == 4 ) + { + n = 0; + if( j > 0 ) *p++ = (unsigned char)( x >> 16 ); + if( j > 1 ) *p++ = (unsigned char)( x >> 8 ); + if( j > 2 ) *p++ = (unsigned char)( x ); + } + } + + *olen = p - dst; + + return( 0 ); +} + +#if defined(MBEDTLS_SELF_TEST) + +static const unsigned char base64_test_dec[64] = +{ + 0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD, + 0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01, + 0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09, + 0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13, + 0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31, + 0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38, + 0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B, + 0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97 +}; + +static const unsigned char base64_test_enc[] = + "JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK" + "swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw=="; + +/* + * Checkup routine + */ +int mbedtls_base64_self_test( int verbose ) +{ + size_t len; + const unsigned char *src; + unsigned char buffer[128]; + + if( verbose != 0 ) + mbedtls_printf( " Base64 encoding test: " ); + + src = base64_test_dec; + + if( mbedtls_base64_encode( buffer, sizeof( buffer ), &len, src, 64 ) != 0 || + memcmp( base64_test_enc, buffer, 88 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n Base64 decoding test: " ); + + src = base64_test_enc; + + if( mbedtls_base64_decode( buffer, sizeof( buffer ), &len, src, 88 ) != 0 || + memcmp( base64_test_dec, buffer, 64 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_BASE64_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/bignum.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/bignum.c new file mode 100644 index 0000000..8b9082c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/bignum.c @@ -0,0 +1,2447 @@ +/* + * Multi-precision integer library + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * The following sources were referenced in the design of this Multi-precision + * Integer library: + * + * [1] Handbook of Applied Cryptography - 1997 + * Menezes, van Oorschot and Vanstone + * + * [2] Multi-Precision Math + * Tom St Denis + * https://github.com/libtom/libtommath/blob/develop/tommath.pdf + * + * [3] GNU Multi-Precision Arithmetic Library + * https://gmplib.org/manual/index.html + * + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_BIGNUM_C) + +#include "mbedtls/bignum.h" +#include "mbedtls/bn_mul.h" + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n ) { + volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0; +} + +#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */ +#define biL (ciL << 3) /* bits in limb */ +#define biH (ciL << 2) /* half limb size */ + +#define MPI_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */ + +/* + * Convert between bits/chars and number of limbs + * Divide first in order to avoid potential overflows + */ +#define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) ) +#define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) ) + +/* + * Initialize one MPI + */ +void mbedtls_mpi_init( mbedtls_mpi *X ) +{ + if( X == NULL ) + return; + + X->s = 1; + X->n = 0; + X->p = NULL; +} + +/* + * Unallocate one MPI + */ +void mbedtls_mpi_free( mbedtls_mpi *X ) +{ + if( X == NULL ) + return; + + if( X->p != NULL ) + { + mbedtls_mpi_zeroize( X->p, X->n ); + mbedtls_free( X->p ); + } + + X->s = 1; + X->n = 0; + X->p = NULL; +} + +/* + * Enlarge to the specified number of limbs + */ +int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs ) +{ + mbedtls_mpi_uint *p; + + if( nblimbs > MBEDTLS_MPI_MAX_LIMBS ) + return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); + + if( X->n < nblimbs ) + { + if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( nblimbs, ciL ) ) == NULL ) + return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); + + if( X->p != NULL ) + { + memcpy( p, X->p, X->n * ciL ); + mbedtls_mpi_zeroize( X->p, X->n ); + mbedtls_free( X->p ); + } + + X->n = nblimbs; + X->p = p; + } + + return( 0 ); +} + +/* + * Resize down as much as possible, + * while keeping at least the specified number of limbs + */ +int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs ) +{ + mbedtls_mpi_uint *p; + size_t i; + + /* Actually resize up in this case */ + if( X->n <= nblimbs ) + return( mbedtls_mpi_grow( X, nblimbs ) ); + + for( i = X->n - 1; i > 0; i-- ) + if( X->p[i] != 0 ) + break; + i++; + + if( i < nblimbs ) + i = nblimbs; + + if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( i, ciL ) ) == NULL ) + return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); + + if( X->p != NULL ) + { + memcpy( p, X->p, i * ciL ); + mbedtls_mpi_zeroize( X->p, X->n ); + mbedtls_free( X->p ); + } + + X->n = i; + X->p = p; + + return( 0 ); +} + +/* + * Copy the contents of Y into X + */ +int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ) +{ + int ret; + size_t i; + + if( X == Y ) + return( 0 ); + + if( Y->p == NULL ) + { + mbedtls_mpi_free( X ); + return( 0 ); + } + + for( i = Y->n - 1; i > 0; i-- ) + if( Y->p[i] != 0 ) + break; + i++; + + X->s = Y->s; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) ); + + memset( X->p, 0, X->n * ciL ); + memcpy( X->p, Y->p, i * ciL ); + +cleanup: + + return( ret ); +} + +/* + * Swap the contents of X and Y + */ +void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ) +{ + mbedtls_mpi T; + + memcpy( &T, X, sizeof( mbedtls_mpi ) ); + memcpy( X, Y, sizeof( mbedtls_mpi ) ); + memcpy( Y, &T, sizeof( mbedtls_mpi ) ); +} + +/* + * Conditionally assign X = Y, without leaking information + * about whether the assignment was made or not. + * (Leaking information about the respective sizes of X and Y is ok however.) + */ +int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign ) +{ + int ret = 0; + size_t i; + + /* make sure assign is 0 or 1 in a time-constant manner */ + assign = (assign | (unsigned char)-assign) >> 7; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) ); + + X->s = X->s * ( 1 - assign ) + Y->s * assign; + + for( i = 0; i < Y->n; i++ ) + X->p[i] = X->p[i] * ( 1 - assign ) + Y->p[i] * assign; + + for( ; i < X->n; i++ ) + X->p[i] *= ( 1 - assign ); + +cleanup: + return( ret ); +} + +/* + * Conditionally swap X and Y, without leaking information + * about whether the swap was made or not. + * Here it is not ok to simply swap the pointers, which whould lead to + * different memory access patterns when X and Y are used afterwards. + */ +int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char swap ) +{ + int ret, s; + size_t i; + mbedtls_mpi_uint tmp; + + if( X == Y ) + return( 0 ); + + /* make sure swap is 0 or 1 in a time-constant manner */ + swap = (swap | (unsigned char)-swap) >> 7; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( Y, X->n ) ); + + s = X->s; + X->s = X->s * ( 1 - swap ) + Y->s * swap; + Y->s = Y->s * ( 1 - swap ) + s * swap; + + + for( i = 0; i < X->n; i++ ) + { + tmp = X->p[i]; + X->p[i] = X->p[i] * ( 1 - swap ) + Y->p[i] * swap; + Y->p[i] = Y->p[i] * ( 1 - swap ) + tmp * swap; + } + +cleanup: + return( ret ); +} + +/* + * Set value from integer + */ +int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ) +{ + int ret; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, 1 ) ); + memset( X->p, 0, X->n * ciL ); + + X->p[0] = ( z < 0 ) ? -z : z; + X->s = ( z < 0 ) ? -1 : 1; + +cleanup: + + return( ret ); +} + +/* + * Get a specific bit + */ +int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos ) +{ + if( X->n * biL <= pos ) + return( 0 ); + + return( ( X->p[pos / biL] >> ( pos % biL ) ) & 0x01 ); +} + +/* + * Set a bit to a specific value of 0 or 1 + */ +int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val ) +{ + int ret = 0; + size_t off = pos / biL; + size_t idx = pos % biL; + + if( val != 0 && val != 1 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + if( X->n * biL <= pos ) + { + if( val == 0 ) + return( 0 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, off + 1 ) ); + } + + X->p[off] &= ~( (mbedtls_mpi_uint) 0x01 << idx ); + X->p[off] |= (mbedtls_mpi_uint) val << idx; + +cleanup: + + return( ret ); +} + +/* + * Return the number of less significant zero-bits + */ +size_t mbedtls_mpi_lsb( const mbedtls_mpi *X ) +{ + size_t i, j, count = 0; + + for( i = 0; i < X->n; i++ ) + for( j = 0; j < biL; j++, count++ ) + if( ( ( X->p[i] >> j ) & 1 ) != 0 ) + return( count ); + + return( 0 ); +} + +/* + * Count leading zero bits in a given integer + */ +static size_t mbedtls_clz( const mbedtls_mpi_uint x ) +{ + size_t j; + mbedtls_mpi_uint mask = (mbedtls_mpi_uint) 1 << (biL - 1); + + for( j = 0; j < biL; j++ ) + { + if( x & mask ) break; + + mask >>= 1; + } + + return j; +} + +/* + * Return the number of bits + */ +size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X ) +{ + size_t i, j; + + if( X->n == 0 ) + return( 0 ); + + for( i = X->n - 1; i > 0; i-- ) + if( X->p[i] != 0 ) + break; + + j = biL - mbedtls_clz( X->p[i] ); + + return( ( i * biL ) + j ); +} + +/* + * Return the total size in bytes + */ +size_t mbedtls_mpi_size( const mbedtls_mpi *X ) +{ + return( ( mbedtls_mpi_bitlen( X ) + 7 ) >> 3 ); +} + +/* + * Convert an ASCII character to digit value + */ +static int mpi_get_digit( mbedtls_mpi_uint *d, int radix, char c ) +{ + *d = 255; + + if( c >= 0x30 && c <= 0x39 ) *d = c - 0x30; + if( c >= 0x41 && c <= 0x46 ) *d = c - 0x37; + if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57; + + if( *d >= (mbedtls_mpi_uint) radix ) + return( MBEDTLS_ERR_MPI_INVALID_CHARACTER ); + + return( 0 ); +} + +/* + * Import from an ASCII string + */ +int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) +{ + int ret; + size_t i, j, slen, n; + mbedtls_mpi_uint d; + mbedtls_mpi T; + + if( radix < 2 || radix > 16 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &T ); + + slen = strlen( s ); + + if( radix == 16 ) + { + if( slen > MPI_SIZE_T_MAX >> 2 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + n = BITS_TO_LIMBS( slen << 2 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, n ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); + + for( i = slen, j = 0; i > 0; i--, j++ ) + { + if( i == 1 && s[i - 1] == '-' ) + { + X->s = -1; + break; + } + + MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i - 1] ) ); + X->p[j / ( 2 * ciL )] |= d << ( ( j % ( 2 * ciL ) ) << 2 ); + } + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); + + for( i = 0; i < slen; i++ ) + { + if( i == 0 && s[i] == '-' ) + { + X->s = -1; + continue; + } + + MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i] ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T, X, radix ) ); + + if( X->s == 1 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, &T, d ) ); + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( X, &T, d ) ); + } + } + } + +cleanup: + + mbedtls_mpi_free( &T ); + + return( ret ); +} + +/* + * Helper to write the digits high-order first + */ +static int mpi_write_hlp( mbedtls_mpi *X, int radix, char **p ) +{ + int ret; + mbedtls_mpi_uint r; + + if( radix < 2 || radix > 16 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, radix ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_div_int( X, NULL, X, radix ) ); + + if( mbedtls_mpi_cmp_int( X, 0 ) != 0 ) + MBEDTLS_MPI_CHK( mpi_write_hlp( X, radix, p ) ); + + if( r < 10 ) + *(*p)++ = (char)( r + 0x30 ); + else + *(*p)++ = (char)( r + 0x37 ); + +cleanup: + + return( ret ); +} + +/* + * Export into an ASCII string + */ +int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, + char *buf, size_t buflen, size_t *olen ) +{ + int ret = 0; + size_t n; + char *p; + mbedtls_mpi T; + + if( radix < 2 || radix > 16 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + n = mbedtls_mpi_bitlen( X ); + if( radix >= 4 ) n >>= 1; + if( radix >= 16 ) n >>= 1; + /* + * Round up the buffer length to an even value to ensure that there is + * enough room for hexadecimal values that can be represented in an odd + * number of digits. + */ + n += 3 + ( ( n + 1 ) & 1 ); + + if( buflen < n ) + { + *olen = n; + return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); + } + + p = buf; + mbedtls_mpi_init( &T ); + + if( X->s == -1 ) + *p++ = '-'; + + if( radix == 16 ) + { + int c; + size_t i, j, k; + + for( i = X->n, k = 0; i > 0; i-- ) + { + for( j = ciL; j > 0; j-- ) + { + c = ( X->p[i - 1] >> ( ( j - 1 ) << 3) ) & 0xFF; + + if( c == 0 && k == 0 && ( i + j ) != 2 ) + continue; + + *(p++) = "0123456789ABCDEF" [c / 16]; + *(p++) = "0123456789ABCDEF" [c % 16]; + k = 1; + } + } + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &T, X ) ); + + if( T.s == -1 ) + T.s = 1; + + MBEDTLS_MPI_CHK( mpi_write_hlp( &T, radix, &p ) ); + } + + *p++ = '\0'; + *olen = p - buf; + +cleanup: + + mbedtls_mpi_free( &T ); + + return( ret ); +} + +#if defined(MBEDTLS_FS_IO) +/* + * Read X from an opened file + */ +int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ) +{ + mbedtls_mpi_uint d; + size_t slen; + char *p; + /* + * Buffer should have space for (short) label and decimal formatted MPI, + * newline characters and '\0' + */ + char s[ MBEDTLS_MPI_RW_BUFFER_SIZE ]; + + memset( s, 0, sizeof( s ) ); + if( fgets( s, sizeof( s ) - 1, fin ) == NULL ) + return( MBEDTLS_ERR_MPI_FILE_IO_ERROR ); + + slen = strlen( s ); + if( slen == sizeof( s ) - 2 ) + return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); + + if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; } + if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; } + + p = s + slen; + while( --p >= s ) + if( mpi_get_digit( &d, radix, *p ) != 0 ) + break; + + return( mbedtls_mpi_read_string( X, radix, p + 1 ) ); +} + +/* + * Write X into an opened file (or stdout if fout == NULL) + */ +int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout ) +{ + int ret; + size_t n, slen, plen; + /* + * Buffer should have space for (short) label and decimal formatted MPI, + * newline characters and '\0' + */ + char s[ MBEDTLS_MPI_RW_BUFFER_SIZE ]; + + memset( s, 0, sizeof( s ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_write_string( X, radix, s, sizeof( s ) - 2, &n ) ); + + if( p == NULL ) p = ""; + + plen = strlen( p ); + slen = strlen( s ); + s[slen++] = '\r'; + s[slen++] = '\n'; + + if( fout != NULL ) + { + if( fwrite( p, 1, plen, fout ) != plen || + fwrite( s, 1, slen, fout ) != slen ) + return( MBEDTLS_ERR_MPI_FILE_IO_ERROR ); + } + else + mbedtls_printf( "%s%s", p, s ); + +cleanup: + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ + +/* + * Import X from unsigned binary data, big endian + */ +int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen ) +{ + int ret; + size_t i, j, n; + + for( n = 0; n < buflen; n++ ) + if( buf[n] != 0 ) + break; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); + + for( i = buflen, j = 0; i > n; i--, j++ ) + X->p[j / ciL] |= ((mbedtls_mpi_uint) buf[i - 1]) << ((j % ciL) << 3); + +cleanup: + + return( ret ); +} + +/* + * Export X into unsigned binary data, big endian + */ +int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen ) +{ + size_t i, j, n; + + n = mbedtls_mpi_size( X ); + + if( buflen < n ) + return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); + + memset( buf, 0, buflen ); + + for( i = buflen - 1, j = 0; n > 0; i--, j++, n-- ) + buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) ); + + return( 0 ); +} + +/* + * Left-shift: X <<= count + */ +int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count ) +{ + int ret; + size_t i, v0, t1; + mbedtls_mpi_uint r0 = 0, r1; + + v0 = count / (biL ); + t1 = count & (biL - 1); + + i = mbedtls_mpi_bitlen( X ) + count; + + if( X->n * biL < i ) + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, BITS_TO_LIMBS( i ) ) ); + + ret = 0; + + /* + * shift by count / limb_size + */ + if( v0 > 0 ) + { + for( i = X->n; i > v0; i-- ) + X->p[i - 1] = X->p[i - v0 - 1]; + + for( ; i > 0; i-- ) + X->p[i - 1] = 0; + } + + /* + * shift by count % limb_size + */ + if( t1 > 0 ) + { + for( i = v0; i < X->n; i++ ) + { + r1 = X->p[i] >> (biL - t1); + X->p[i] <<= t1; + X->p[i] |= r0; + r0 = r1; + } + } + +cleanup: + + return( ret ); +} + +/* + * Right-shift: X >>= count + */ +int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count ) +{ + size_t i, v0, v1; + mbedtls_mpi_uint r0 = 0, r1; + + v0 = count / biL; + v1 = count & (biL - 1); + + if( v0 > X->n || ( v0 == X->n && v1 > 0 ) ) + return mbedtls_mpi_lset( X, 0 ); + + /* + * shift by count / limb_size + */ + if( v0 > 0 ) + { + for( i = 0; i < X->n - v0; i++ ) + X->p[i] = X->p[i + v0]; + + for( ; i < X->n; i++ ) + X->p[i] = 0; + } + + /* + * shift by count % limb_size + */ + if( v1 > 0 ) + { + for( i = X->n; i > 0; i-- ) + { + r1 = X->p[i - 1] << (biL - v1); + X->p[i - 1] >>= v1; + X->p[i - 1] |= r0; + r0 = r1; + } + } + + return( 0 ); +} + +/* + * Compare unsigned values + */ +int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y ) +{ + size_t i, j; + + for( i = X->n; i > 0; i-- ) + if( X->p[i - 1] != 0 ) + break; + + for( j = Y->n; j > 0; j-- ) + if( Y->p[j - 1] != 0 ) + break; + + if( i == 0 && j == 0 ) + return( 0 ); + + if( i > j ) return( 1 ); + if( j > i ) return( -1 ); + + for( ; i > 0; i-- ) + { + if( X->p[i - 1] > Y->p[i - 1] ) return( 1 ); + if( X->p[i - 1] < Y->p[i - 1] ) return( -1 ); + } + + return( 0 ); +} + +/* + * Compare signed values + */ +int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y ) +{ + size_t i, j; + + for( i = X->n; i > 0; i-- ) + if( X->p[i - 1] != 0 ) + break; + + for( j = Y->n; j > 0; j-- ) + if( Y->p[j - 1] != 0 ) + break; + + if( i == 0 && j == 0 ) + return( 0 ); + + if( i > j ) return( X->s ); + if( j > i ) return( -Y->s ); + + if( X->s > 0 && Y->s < 0 ) return( 1 ); + if( Y->s > 0 && X->s < 0 ) return( -1 ); + + for( ; i > 0; i-- ) + { + if( X->p[i - 1] > Y->p[i - 1] ) return( X->s ); + if( X->p[i - 1] < Y->p[i - 1] ) return( -X->s ); + } + + return( 0 ); +} + +/* + * Compare signed values + */ +int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z ) +{ + mbedtls_mpi Y; + mbedtls_mpi_uint p[1]; + + *p = ( z < 0 ) ? -z : z; + Y.s = ( z < 0 ) ? -1 : 1; + Y.n = 1; + Y.p = p; + + return( mbedtls_mpi_cmp_mpi( X, &Y ) ); +} + +/* + * Unsigned addition: X = |A| + |B| (HAC 14.7) + */ +int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret; + size_t i, j; + mbedtls_mpi_uint *o, *p, c, tmp; + + if( X == B ) + { + const mbedtls_mpi *T = A; A = X; B = T; + } + + if( X != A ) + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, A ) ); + + /* + * X should always be positive as a result of unsigned additions. + */ + X->s = 1; + + for( j = B->n; j > 0; j-- ) + if( B->p[j - 1] != 0 ) + break; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, j ) ); + + o = B->p; p = X->p; c = 0; + + /* + * tmp is used because it might happen that p == o + */ + for( i = 0; i < j; i++, o++, p++ ) + { + tmp= *o; + *p += c; c = ( *p < c ); + *p += tmp; c += ( *p < tmp ); + } + + while( c != 0 ) + { + if( i >= X->n ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + 1 ) ); + p = X->p + i; + } + + *p += c; c = ( *p < c ); i++; p++; + } + +cleanup: + + return( ret ); +} + +/* + * Helper for mbedtls_mpi subtraction + */ +static void mpi_sub_hlp( size_t n, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d ) +{ + size_t i; + mbedtls_mpi_uint c, z; + + for( i = c = 0; i < n; i++, s++, d++ ) + { + z = ( *d < c ); *d -= c; + c = ( *d < *s ) + z; *d -= *s; + } + + while( c != 0 ) + { + z = ( *d < c ); *d -= c; + c = z; i++; d++; + } +} + +/* + * Unsigned subtraction: X = |A| - |B| (HAC 14.9) + */ +int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + mbedtls_mpi TB; + int ret; + size_t n; + + if( mbedtls_mpi_cmp_abs( A, B ) < 0 ) + return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE ); + + mbedtls_mpi_init( &TB ); + + if( X == B ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) ); + B = &TB; + } + + if( X != A ) + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, A ) ); + + /* + * X should always be positive as a result of unsigned subtractions. + */ + X->s = 1; + + ret = 0; + + for( n = B->n; n > 0; n-- ) + if( B->p[n - 1] != 0 ) + break; + + mpi_sub_hlp( n, B->p, X->p ); + +cleanup: + + mbedtls_mpi_free( &TB ); + + return( ret ); +} + +/* + * Signed addition: X = A + B + */ +int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret, s = A->s; + + if( A->s * B->s < 0 ) + { + if( mbedtls_mpi_cmp_abs( A, B ) >= 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, A, B ) ); + X->s = s; + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, B, A ) ); + X->s = -s; + } + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( X, A, B ) ); + X->s = s; + } + +cleanup: + + return( ret ); +} + +/* + * Signed subtraction: X = A - B + */ +int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret, s = A->s; + + if( A->s * B->s > 0 ) + { + if( mbedtls_mpi_cmp_abs( A, B ) >= 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, A, B ) ); + X->s = s; + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, B, A ) ); + X->s = -s; + } + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( X, A, B ) ); + X->s = s; + } + +cleanup: + + return( ret ); +} + +/* + * Signed addition: X = A + b + */ +int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ) +{ + mbedtls_mpi _B; + mbedtls_mpi_uint p[1]; + + p[0] = ( b < 0 ) ? -b : b; + _B.s = ( b < 0 ) ? -1 : 1; + _B.n = 1; + _B.p = p; + + return( mbedtls_mpi_add_mpi( X, A, &_B ) ); +} + +/* + * Signed subtraction: X = A - b + */ +int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ) +{ + mbedtls_mpi _B; + mbedtls_mpi_uint p[1]; + + p[0] = ( b < 0 ) ? -b : b; + _B.s = ( b < 0 ) ? -1 : 1; + _B.n = 1; + _B.p = p; + + return( mbedtls_mpi_sub_mpi( X, A, &_B ) ); +} + +/* + * Helper for mbedtls_mpi multiplication + */ +static +#if defined(__APPLE__) && defined(__arm__) +/* + * Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn) + * appears to need this to prevent bad ARM code generation at -O3. + */ +__attribute__ ((noinline)) +#endif +void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mpi_uint b ) +{ + mbedtls_mpi_uint c = 0, t = 0; + +#if defined(MULADDC_HUIT) + for( ; i >= 8; i -= 8 ) + { + MULADDC_INIT + MULADDC_HUIT + MULADDC_STOP + } + + for( ; i > 0; i-- ) + { + MULADDC_INIT + MULADDC_CORE + MULADDC_STOP + } +#else /* MULADDC_HUIT */ + for( ; i >= 16; i -= 16 ) + { + MULADDC_INIT + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + MULADDC_STOP + } + + for( ; i >= 8; i -= 8 ) + { + MULADDC_INIT + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + + MULADDC_CORE MULADDC_CORE + MULADDC_CORE MULADDC_CORE + MULADDC_STOP + } + + for( ; i > 0; i-- ) + { + MULADDC_INIT + MULADDC_CORE + MULADDC_STOP + } +#endif /* MULADDC_HUIT */ + + t++; + + do { + *d += c; c = ( *d < c ); d++; + } + while( c != 0 ); +} + +/* + * Baseline multiplication: X = A * B (HAC 14.12) + */ +int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret; + size_t i, j; + mbedtls_mpi TA, TB; + + mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB ); + + if( X == A ) { MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) ); A = &TA; } + if( X == B ) { MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) ); B = &TB; } + + for( i = A->n; i > 0; i-- ) + if( A->p[i - 1] != 0 ) + break; + + for( j = B->n; j > 0; j-- ) + if( B->p[j - 1] != 0 ) + break; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + j ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); + + for( i++; j > 0; j-- ) + mpi_mul_hlp( i - 1, A->p, X->p + j - 1, B->p[j - 1] ); + + X->s = A->s * B->s; + +cleanup: + + mbedtls_mpi_free( &TB ); mbedtls_mpi_free( &TA ); + + return( ret ); +} + +/* + * Baseline multiplication: X = A * b + */ +int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b ) +{ + mbedtls_mpi _B; + mbedtls_mpi_uint p[1]; + + _B.s = 1; + _B.n = 1; + _B.p = p; + p[0] = b; + + return( mbedtls_mpi_mul_mpi( X, A, &_B ) ); +} + +/* + * Unsigned integer divide - double mbedtls_mpi_uint dividend, u1/u0, and + * mbedtls_mpi_uint divisor, d + */ +static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1, + mbedtls_mpi_uint u0, mbedtls_mpi_uint d, mbedtls_mpi_uint *r ) +{ +#if defined(MBEDTLS_HAVE_UDBL) + mbedtls_t_udbl dividend, quotient; +#else + const mbedtls_mpi_uint radix = (mbedtls_mpi_uint) 1 << biH; + const mbedtls_mpi_uint uint_halfword_mask = ( (mbedtls_mpi_uint) 1 << biH ) - 1; + mbedtls_mpi_uint d0, d1, q0, q1, rAX, r0, quotient; + mbedtls_mpi_uint u0_msw, u0_lsw; + size_t s; +#endif + + /* + * Check for overflow + */ + if( 0 == d || u1 >= d ) + { + if (r != NULL) *r = ~0; + + return ( ~0 ); + } + +#if defined(MBEDTLS_HAVE_UDBL) + dividend = (mbedtls_t_udbl) u1 << biL; + dividend |= (mbedtls_t_udbl) u0; + quotient = dividend / d; + if( quotient > ( (mbedtls_t_udbl) 1 << biL ) - 1 ) + quotient = ( (mbedtls_t_udbl) 1 << biL ) - 1; + + if( r != NULL ) + *r = (mbedtls_mpi_uint)( dividend - (quotient * d ) ); + + return (mbedtls_mpi_uint) quotient; +#else + + /* + * Algorithm D, Section 4.3.1 - The Art of Computer Programming + * Vol. 2 - Seminumerical Algorithms, Knuth + */ + + /* + * Normalize the divisor, d, and dividend, u0, u1 + */ + s = mbedtls_clz( d ); + d = d << s; + + u1 = u1 << s; + u1 |= ( u0 >> ( biL - s ) ) & ( -(mbedtls_mpi_sint)s >> ( biL - 1 ) ); + u0 = u0 << s; + + d1 = d >> biH; + d0 = d & uint_halfword_mask; + + u0_msw = u0 >> biH; + u0_lsw = u0 & uint_halfword_mask; + + /* + * Find the first quotient and remainder + */ + q1 = u1 / d1; + r0 = u1 - d1 * q1; + + while( q1 >= radix || ( q1 * d0 > radix * r0 + u0_msw ) ) + { + q1 -= 1; + r0 += d1; + + if ( r0 >= radix ) break; + } + + rAX = ( u1 * radix ) + ( u0_msw - q1 * d ); + q0 = rAX / d1; + r0 = rAX - q0 * d1; + + while( q0 >= radix || ( q0 * d0 > radix * r0 + u0_lsw ) ) + { + q0 -= 1; + r0 += d1; + + if ( r0 >= radix ) break; + } + + if (r != NULL) + *r = ( rAX * radix + u0_lsw - q0 * d ) >> s; + + quotient = q1 * radix + q0; + + return quotient; +#endif +} + +/* + * Division by mbedtls_mpi: A = Q * B + R (HAC 14.20) + */ +int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret; + size_t i, n, t, k; + mbedtls_mpi X, Y, Z, T1, T2; + + if( mbedtls_mpi_cmp_int( B, 0 ) == 0 ) + return( MBEDTLS_ERR_MPI_DIVISION_BY_ZERO ); + + mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); + mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 ); + + if( mbedtls_mpi_cmp_abs( A, B ) < 0 ) + { + if( Q != NULL ) MBEDTLS_MPI_CHK( mbedtls_mpi_lset( Q, 0 ) ); + if( R != NULL ) MBEDTLS_MPI_CHK( mbedtls_mpi_copy( R, A ) ); + return( 0 ); + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &X, A ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Y, B ) ); + X.s = Y.s = 1; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &Z, A->n + 2 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &Z, 0 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T1, 2 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T2, 3 ) ); + + k = mbedtls_mpi_bitlen( &Y ) % biL; + if( k < biL - 1 ) + { + k = biL - 1 - k; + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &X, k ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &Y, k ) ); + } + else k = 0; + + n = X.n - 1; + t = Y.n - 1; + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &Y, biL * ( n - t ) ) ); + + while( mbedtls_mpi_cmp_mpi( &X, &Y ) >= 0 ) + { + Z.p[n - t]++; + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &X, &X, &Y ) ); + } + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Y, biL * ( n - t ) ) ); + + for( i = n; i > t ; i-- ) + { + if( X.p[i] >= Y.p[t] ) + Z.p[i - t - 1] = ~0; + else + { + Z.p[i - t - 1] = mbedtls_int_div_int( X.p[i], X.p[i - 1], + Y.p[t], NULL); + } + + Z.p[i - t - 1]++; + do + { + Z.p[i - t - 1]--; + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &T1, 0 ) ); + T1.p[0] = ( t < 1 ) ? 0 : Y.p[t - 1]; + T1.p[1] = Y.p[t]; + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &T2, 0 ) ); + T2.p[0] = ( i < 2 ) ? 0 : X.p[i - 2]; + T2.p[1] = ( i < 1 ) ? 0 : X.p[i - 1]; + T2.p[2] = X.p[i]; + } + while( mbedtls_mpi_cmp_mpi( &T1, &T2 ) > 0 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T1, biL * ( i - t - 1 ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &X, &X, &T1 ) ); + + if( mbedtls_mpi_cmp_int( &X, 0 ) < 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &T1, &Y ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T1, biL * ( i - t - 1 ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &X, &X, &T1 ) ); + Z.p[i - t - 1]--; + } + } + + if( Q != NULL ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( Q, &Z ) ); + Q->s = A->s * B->s; + } + + if( R != NULL ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &X, k ) ); + X.s = A->s; + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( R, &X ) ); + + if( mbedtls_mpi_cmp_int( R, 0 ) == 0 ) + R->s = 1; + } + +cleanup: + + mbedtls_mpi_free( &X ); mbedtls_mpi_free( &Y ); mbedtls_mpi_free( &Z ); + mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 ); + + return( ret ); +} + +/* + * Division by int: A = Q * b + R + */ +int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b ) +{ + mbedtls_mpi _B; + mbedtls_mpi_uint p[1]; + + p[0] = ( b < 0 ) ? -b : b; + _B.s = ( b < 0 ) ? -1 : 1; + _B.n = 1; + _B.p = p; + + return( mbedtls_mpi_div_mpi( Q, R, A, &_B ) ); +} + +/* + * Modulo: R = A mod B + */ +int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret; + + if( mbedtls_mpi_cmp_int( B, 0 ) < 0 ) + return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( NULL, R, A, B ) ); + + while( mbedtls_mpi_cmp_int( R, 0 ) < 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( R, R, B ) ); + + while( mbedtls_mpi_cmp_mpi( R, B ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( R, R, B ) ); + +cleanup: + + return( ret ); +} + +/* + * Modulo: r = A mod b + */ +int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b ) +{ + size_t i; + mbedtls_mpi_uint x, y, z; + + if( b == 0 ) + return( MBEDTLS_ERR_MPI_DIVISION_BY_ZERO ); + + if( b < 0 ) + return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE ); + + /* + * handle trivial cases + */ + if( b == 1 ) + { + *r = 0; + return( 0 ); + } + + if( b == 2 ) + { + *r = A->p[0] & 1; + return( 0 ); + } + + /* + * general case + */ + for( i = A->n, y = 0; i > 0; i-- ) + { + x = A->p[i - 1]; + y = ( y << biH ) | ( x >> biH ); + z = y / b; + y -= z * b; + + x <<= biH; + y = ( y << biH ) | ( x >> biH ); + z = y / b; + y -= z * b; + } + + /* + * If A is negative, then the current y represents a negative value. + * Flipping it to the positive side. + */ + if( A->s < 0 && y != 0 ) + y = b - y; + + *r = y; + + return( 0 ); +} + +/* + * Fast Montgomery initialization (thanks to Tom St Denis) + */ +static void mpi_montg_init( mbedtls_mpi_uint *mm, const mbedtls_mpi *N ) +{ + mbedtls_mpi_uint x, m0 = N->p[0]; + unsigned int i; + + x = m0; + x += ( ( m0 + 2 ) & 4 ) << 1; + + for( i = biL; i >= 8; i /= 2 ) + x *= ( 2 - ( m0 * x ) ); + + *mm = ~x + 1; +} + +/* + * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36) + */ +static int mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi *N, mbedtls_mpi_uint mm, + const mbedtls_mpi *T ) +{ + size_t i, n, m; + mbedtls_mpi_uint u0, u1, *d; + + if( T->n < N->n + 1 || T->p == NULL ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + memset( T->p, 0, T->n * ciL ); + + d = T->p; + n = N->n; + m = ( B->n < n ) ? B->n : n; + + for( i = 0; i < n; i++ ) + { + /* + * T = (T + u0*B + u1*N) / 2^biL + */ + u0 = A->p[i]; + u1 = ( d[0] + u0 * B->p[0] ) * mm; + + mpi_mul_hlp( m, B->p, d, u0 ); + mpi_mul_hlp( n, N->p, d, u1 ); + + *d++ = u0; d[n + 1] = 0; + } + + memcpy( A->p, d, ( n + 1 ) * ciL ); + + if( mbedtls_mpi_cmp_abs( A, N ) >= 0 ) + mpi_sub_hlp( n, N->p, A->p ); + else + /* prevent timing attacks */ + mpi_sub_hlp( n, A->p, T->p ); + + return( 0 ); +} + +/* + * Montgomery reduction: A = A * R^-1 mod N + */ +static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint mm, const mbedtls_mpi *T ) +{ + mbedtls_mpi_uint z = 1; + mbedtls_mpi U; + + U.n = U.s = (int) z; + U.p = &z; + + return( mpi_montmul( A, &U, N, mm, T ) ); +} + +/* + * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) + */ +int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR ) +{ + int ret; + size_t wbits, wsize, one = 1; + size_t i, j, nblimbs; + size_t bufsize, nbits; + mbedtls_mpi_uint ei, mm, state; + mbedtls_mpi RR, T, W[ 2 << MBEDTLS_MPI_WINDOW_SIZE ], Apos; + int neg; + + if( mbedtls_mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + if( mbedtls_mpi_cmp_int( E, 0 ) < 0 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + /* + * Init temps and window size + */ + mpi_montg_init( &mm, N ); + mbedtls_mpi_init( &RR ); mbedtls_mpi_init( &T ); + mbedtls_mpi_init( &Apos ); + memset( W, 0, sizeof( W ) ); + + i = mbedtls_mpi_bitlen( E ); + + wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 : + ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1; + + if( wsize > MBEDTLS_MPI_WINDOW_SIZE ) + wsize = MBEDTLS_MPI_WINDOW_SIZE; + + j = N->n + 1; + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, j ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[1], j ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T, j * 2 ) ); + + /* + * Compensate for negative A (and correct at the end) + */ + neg = ( A->s == -1 ); + if( neg ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Apos, A ) ); + Apos.s = 1; + A = &Apos; + } + + /* + * If 1st call, pre-compute R^2 mod N + */ + if( _RR == NULL || _RR->p == NULL ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &RR, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &RR, N->n * 2 * biL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &RR, &RR, N ) ); + + if( _RR != NULL ) + memcpy( _RR, &RR, sizeof( mbedtls_mpi ) ); + } + else + memcpy( &RR, _RR, sizeof( mbedtls_mpi ) ); + + /* + * W[1] = A * R^2 * R^-1 mod N = A * R mod N + */ + if( mbedtls_mpi_cmp_mpi( A, N ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &W[1], A, N ) ); + else + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[1], A ) ); + + MBEDTLS_MPI_CHK( mpi_montmul( &W[1], &RR, N, mm, &T ) ); + + /* + * X = R^2 * R^-1 mod N = R mod N + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, &RR ) ); + MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &T ) ); + + if( wsize > 1 ) + { + /* + * W[1 << (wsize - 1)] = W[1] ^ (wsize - 1) + */ + j = one << ( wsize - 1 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[j], N->n + 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[j], &W[1] ) ); + + for( i = 0; i < wsize - 1; i++ ) + MBEDTLS_MPI_CHK( mpi_montmul( &W[j], &W[j], N, mm, &T ) ); + + /* + * W[i] = W[i - 1] * W[1] + */ + for( i = j + 1; i < ( one << wsize ); i++ ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[i], N->n + 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[i], &W[i - 1] ) ); + + MBEDTLS_MPI_CHK( mpi_montmul( &W[i], &W[1], N, mm, &T ) ); + } + } + + nblimbs = E->n; + bufsize = 0; + nbits = 0; + wbits = 0; + state = 0; + + while( 1 ) + { + if( bufsize == 0 ) + { + if( nblimbs == 0 ) + break; + + nblimbs--; + + bufsize = sizeof( mbedtls_mpi_uint ) << 3; + } + + bufsize--; + + ei = (E->p[nblimbs] >> bufsize) & 1; + + /* + * skip leading 0s + */ + if( ei == 0 && state == 0 ) + continue; + + if( ei == 0 && state == 1 ) + { + /* + * out of window, square X + */ + MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &T ) ); + continue; + } + + /* + * add ei to current window + */ + state = 2; + + nbits++; + wbits |= ( ei << ( wsize - nbits ) ); + + if( nbits == wsize ) + { + /* + * X = X^wsize R^-1 mod N + */ + for( i = 0; i < wsize; i++ ) + MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &T ) ); + + /* + * X = X * W[wbits] R^-1 mod N + */ + MBEDTLS_MPI_CHK( mpi_montmul( X, &W[wbits], N, mm, &T ) ); + + state--; + nbits = 0; + wbits = 0; + } + } + + /* + * process the remaining bits + */ + for( i = 0; i < nbits; i++ ) + { + MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &T ) ); + + wbits <<= 1; + + if( ( wbits & ( one << wsize ) ) != 0 ) + MBEDTLS_MPI_CHK( mpi_montmul( X, &W[1], N, mm, &T ) ); + } + + /* + * X = A^E * R * R^-1 mod N = A^E mod N + */ + MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &T ) ); + + if( neg ) + { + X->s = -1; + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( X, N, X ) ); + } + +cleanup: + + for( i = ( one << ( wsize - 1 ) ); i < ( one << wsize ); i++ ) + mbedtls_mpi_free( &W[i] ); + + mbedtls_mpi_free( &W[1] ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &Apos ); + + if( _RR == NULL || _RR->p == NULL ) + mbedtls_mpi_free( &RR ); + + return( ret ); +} + +/* + * Greatest common divisor: G = gcd(A, B) (HAC 14.54) + */ +int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B ) +{ + int ret; + size_t lz, lzt; + mbedtls_mpi TG, TA, TB; + + mbedtls_mpi_init( &TG ); mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) ); + + lz = mbedtls_mpi_lsb( &TA ); + lzt = mbedtls_mpi_lsb( &TB ); + + if( lzt < lz ) + lz = lzt; + + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, lz ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, lz ) ); + + TA.s = TB.s = 1; + + while( mbedtls_mpi_cmp_int( &TA, 0 ) != 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, mbedtls_mpi_lsb( &TA ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, mbedtls_mpi_lsb( &TB ) ) ); + + if( mbedtls_mpi_cmp_mpi( &TA, &TB ) >= 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &TA, &TA, &TB ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, 1 ) ); + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &TB, &TB, &TA ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, 1 ) ); + } + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &TB, lz ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( G, &TB ) ); + +cleanup: + + mbedtls_mpi_free( &TG ); mbedtls_mpi_free( &TA ); mbedtls_mpi_free( &TB ); + + return( ret ); +} + +/* + * Fill X with size bytes of random. + * + * Use a temporary bytes representation to make sure the result is the same + * regardless of the platform endianness (useful when f_rng is actually + * deterministic, eg for tests). + */ +int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + + if( size > MBEDTLS_MPI_MAX_SIZE ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + MBEDTLS_MPI_CHK( f_rng( p_rng, buf, size ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( X, buf, size ) ); + +cleanup: + return( ret ); +} + +/* + * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64) + */ +int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ) +{ + int ret; + mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2; + + if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TU ); mbedtls_mpi_init( &U1 ); mbedtls_mpi_init( &U2 ); + mbedtls_mpi_init( &G ); mbedtls_mpi_init( &TB ); mbedtls_mpi_init( &TV ); + mbedtls_mpi_init( &V1 ); mbedtls_mpi_init( &V2 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, A, N ) ); + + if( mbedtls_mpi_cmp_int( &G, 1 ) != 0 ) + { + ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + goto cleanup; + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &TA, A, N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TU, &TA ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TV, N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &U1, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &U2, 0 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &V1, 0 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &V2, 1 ) ); + + do + { + while( ( TU.p[0] & 1 ) == 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TU, 1 ) ); + + if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &U1, &U1, &TB ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U2, &U2, &TA ) ); + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &U1, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &U2, 1 ) ); + } + + while( ( TV.p[0] & 1 ) == 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TV, 1 ) ); + + if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &V1, &V1, &TB ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V2, &V2, &TA ) ); + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &V1, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &V2, 1 ) ); + } + + if( mbedtls_mpi_cmp_mpi( &TU, &TV ) >= 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &TU, &TU, &TV ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U1, &U1, &V1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U2, &U2, &V2 ) ); + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &TV, &TV, &TU ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V1, &V1, &U1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V2, &V2, &U2 ) ); + } + } + while( mbedtls_mpi_cmp_int( &TU, 0 ) != 0 ); + + while( mbedtls_mpi_cmp_int( &V1, 0 ) < 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &V1, &V1, N ) ); + + while( mbedtls_mpi_cmp_mpi( &V1, N ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V1, &V1, N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, &V1 ) ); + +cleanup: + + mbedtls_mpi_free( &TA ); mbedtls_mpi_free( &TU ); mbedtls_mpi_free( &U1 ); mbedtls_mpi_free( &U2 ); + mbedtls_mpi_free( &G ); mbedtls_mpi_free( &TB ); mbedtls_mpi_free( &TV ); + mbedtls_mpi_free( &V1 ); mbedtls_mpi_free( &V2 ); + + return( ret ); +} + +#if defined(MBEDTLS_GENPRIME) + +static const int small_prime[] = +{ + 3, 5, 7, 11, 13, 17, 19, 23, + 29, 31, 37, 41, 43, 47, 53, 59, + 61, 67, 71, 73, 79, 83, 89, 97, + 101, 103, 107, 109, 113, 127, 131, 137, + 139, 149, 151, 157, 163, 167, 173, 179, + 181, 191, 193, 197, 199, 211, 223, 227, + 229, 233, 239, 241, 251, 257, 263, 269, + 271, 277, 281, 283, 293, 307, 311, 313, + 317, 331, 337, 347, 349, 353, 359, 367, + 373, 379, 383, 389, 397, 401, 409, 419, + 421, 431, 433, 439, 443, 449, 457, 461, + 463, 467, 479, 487, 491, 499, 503, 509, + 521, 523, 541, 547, 557, 563, 569, 571, + 577, 587, 593, 599, 601, 607, 613, 617, + 619, 631, 641, 643, 647, 653, 659, 661, + 673, 677, 683, 691, 701, 709, 719, 727, + 733, 739, 743, 751, 757, 761, 769, 773, + 787, 797, 809, 811, 821, 823, 827, 829, + 839, 853, 857, 859, 863, 877, 881, 883, + 887, 907, 911, 919, 929, 937, 941, 947, + 953, 967, 971, 977, 983, 991, 997, -103 +}; + +/* + * Small divisors test (X must be positive) + * + * Return values: + * 0: no small factor (possible prime, more tests needed) + * 1: certain prime + * MBEDTLS_ERR_MPI_NOT_ACCEPTABLE: certain non-prime + * other negative: error + */ +static int mpi_check_small_factors( const mbedtls_mpi *X ) +{ + int ret = 0; + size_t i; + mbedtls_mpi_uint r; + + if( ( X->p[0] & 1 ) == 0 ) + return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); + + for( i = 0; small_prime[i] > 0; i++ ) + { + if( mbedtls_mpi_cmp_int( X, small_prime[i] ) <= 0 ) + return( 1 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, small_prime[i] ) ); + + if( r == 0 ) + return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); + } + +cleanup: + return( ret ); +} + +/* + * Miller-Rabin pseudo-primality test (HAC 4.24) + */ +static int mpi_miller_rabin( const mbedtls_mpi *X, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret, count; + size_t i, j, k, n, s; + mbedtls_mpi W, R, T, A, RR; + + mbedtls_mpi_init( &W ); mbedtls_mpi_init( &R ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &A ); + mbedtls_mpi_init( &RR ); + + /* + * W = |X| - 1 + * R = W >> lsb( W ) + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &W, X, 1 ) ); + s = mbedtls_mpi_lsb( &W ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R, &W ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &R, s ) ); + + i = mbedtls_mpi_bitlen( X ); + /* + * HAC, table 4.4 + */ + n = ( ( i >= 1300 ) ? 2 : ( i >= 850 ) ? 3 : + ( i >= 650 ) ? 4 : ( i >= 350 ) ? 8 : + ( i >= 250 ) ? 12 : ( i >= 150 ) ? 18 : 27 ); + + for( i = 0; i < n; i++ ) + { + /* + * pick a random A, 1 < A < |X| - 1 + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) ); + + if( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 ) + { + j = mbedtls_mpi_bitlen( &A ) - mbedtls_mpi_bitlen( &W ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &A, j + 1 ) ); + } + A.p[0] |= 3; + + count = 0; + do { + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) ); + + j = mbedtls_mpi_bitlen( &A ); + k = mbedtls_mpi_bitlen( &W ); + if (j > k) { + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &A, j - k ) ); + } + + if (count++ > 30) { + return MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + } + + } while ( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 || + mbedtls_mpi_cmp_int( &A, 1 ) <= 0 ); + + /* + * A = A^R mod |X| + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &A, &A, &R, X, &RR ) ); + + if( mbedtls_mpi_cmp_mpi( &A, &W ) == 0 || + mbedtls_mpi_cmp_int( &A, 1 ) == 0 ) + continue; + + j = 1; + while( j < s && mbedtls_mpi_cmp_mpi( &A, &W ) != 0 ) + { + /* + * A = A * A mod |X| + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &A, &A ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &A, &T, X ) ); + + if( mbedtls_mpi_cmp_int( &A, 1 ) == 0 ) + break; + + j++; + } + + /* + * not prime if A != |X| - 1 or A == 1 + */ + if( mbedtls_mpi_cmp_mpi( &A, &W ) != 0 || + mbedtls_mpi_cmp_int( &A, 1 ) == 0 ) + { + ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + break; + } + } + +cleanup: + mbedtls_mpi_free( &W ); mbedtls_mpi_free( &R ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &A ); + mbedtls_mpi_free( &RR ); + + return( ret ); +} + +/* + * Pseudo-primality test: small factors, then Miller-Rabin + */ +int mbedtls_mpi_is_prime( const mbedtls_mpi *X, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_mpi XX; + + XX.s = 1; + XX.n = X->n; + XX.p = X->p; + + if( mbedtls_mpi_cmp_int( &XX, 0 ) == 0 || + mbedtls_mpi_cmp_int( &XX, 1 ) == 0 ) + return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); + + if( mbedtls_mpi_cmp_int( &XX, 2 ) == 0 ) + return( 0 ); + + if( ( ret = mpi_check_small_factors( &XX ) ) != 0 ) + { + if( ret == 1 ) + return( 0 ); + + return( ret ); + } + + return( mpi_miller_rabin( &XX, f_rng, p_rng ) ); +} + +/* + * Prime number generation + */ +int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + size_t k, n; + mbedtls_mpi_uint r; + mbedtls_mpi Y; + + if( nbits < 3 || nbits > MBEDTLS_MPI_MAX_BITS ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &Y ); + + n = BITS_TO_LIMBS( nbits ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( X, n * ciL, f_rng, p_rng ) ); + + k = mbedtls_mpi_bitlen( X ); + if( k > nbits ) MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( X, k - nbits + 1 ) ); + + mbedtls_mpi_set_bit( X, nbits-1, 1 ); + + X->p[0] |= 1; + + if( dh_flag == 0 ) + { + while( ( ret = mbedtls_mpi_is_prime( X, f_rng, p_rng ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ) + goto cleanup; + + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 2 ) ); + } + } + else + { + /* + * An necessary condition for Y and X = 2Y + 1 to be prime + * is X = 2 mod 3 (which is equivalent to Y = 2 mod 3). + * Make sure it is satisfied, while keeping X = 3 mod 4 + */ + + X->p[0] |= 2; + + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, 3 ) ); + if( r == 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 8 ) ); + else if( r == 1 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 4 ) ); + + /* Set Y = (X-1) / 2, which is X / 2 because X is odd */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Y, X ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Y, 1 ) ); + + while( 1 ) + { + /* + * First, check small factors for X and Y + * before doing Miller-Rabin on any of them + */ + if( ( ret = mpi_check_small_factors( X ) ) == 0 && + ( ret = mpi_check_small_factors( &Y ) ) == 0 && + ( ret = mpi_miller_rabin( X, f_rng, p_rng ) ) == 0 && + ( ret = mpi_miller_rabin( &Y, f_rng, p_rng ) ) == 0 ) + { + break; + } + + if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ) + goto cleanup; + + /* + * Next candidates. We want to preserve Y = (X-1) / 2 and + * Y = 1 mod 2 and Y = 2 mod 3 (eq X = 3 mod 4 and X = 2 mod 3) + * so up Y by 6 and X by 12. + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 12 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &Y, &Y, 6 ) ); + } + } + +cleanup: + + mbedtls_mpi_free( &Y ); + + return( ret ); +} + +#endif /* MBEDTLS_GENPRIME */ + +#if defined(MBEDTLS_SELF_TEST) + +#define GCD_PAIR_COUNT 3 + +static const int gcd_pairs[GCD_PAIR_COUNT][3] = +{ + { 693, 609, 21 }, + { 1764, 868, 28 }, + { 768454923, 542167814, 1 } +}; + +/* + * Checkup routine + */ +int mbedtls_mpi_self_test( int verbose ) +{ + int ret, i; + mbedtls_mpi A, E, N, X, Y, U, V; + + mbedtls_mpi_init( &A ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &X ); + mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &U ); mbedtls_mpi_init( &V ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &A, 16, + "EFE021C2645FD1DC586E69184AF4A31E" \ + "D5F53E93B5F123FA41680867BA110131" \ + "944FE7952E2517337780CB0DB80E61AA" \ + "E7C8DDC6C5C6AADEB34EB38A2F40D5E6" ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &E, 16, + "B2E7EFD37075B9F03FF989C7C5051C20" \ + "34D2A323810251127E7BF8625A4F49A5" \ + "F3E27F4DA8BD59C47D6DAABA4C8127BD" \ + "5B5C25763222FEFCCFC38B832366C29E" ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &N, 16, + "0066A198186C18C10B2F5ED9B522752A" \ + "9830B69916E535C8F047518A889A43A5" \ + "94B6BED27A168D31D4A52F88925AA8F5" ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &X, &A, &N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16, + "602AB7ECA597A3D6B56FF9829A5E8B85" \ + "9E857EA95A03512E2BAE7391688D264A" \ + "A5663B0341DB9CCFD2C4C5F421FEC814" \ + "8001B72E848A38CAE1C65F78E56ABDEF" \ + "E12D3C039B8A02D6BE593F0BBBDA56F1" \ + "ECF677152EF804370C1A305CAF3B5BF1" \ + "30879B56C61DE584A0F53A2447A51E" ) ); + + if( verbose != 0 ) + mbedtls_printf( " MPI test #1 (mul_mpi): " ); + + if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto cleanup; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &X, &Y, &A, &N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16, + "256567336059E52CAE22925474705F39A94" ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &V, 16, + "6613F26162223DF488E9CD48CC132C7A" \ + "0AC93C701B001B092E4E5B9F73BCD27B" \ + "9EE50D0657C77F374E903CDFA4C642" ) ); + + if( verbose != 0 ) + mbedtls_printf( " MPI test #2 (div_mpi): " ); + + if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 || + mbedtls_mpi_cmp_mpi( &Y, &V ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto cleanup; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &X, &A, &E, &N, NULL ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16, + "36E139AEA55215609D2816998ED020BB" \ + "BD96C37890F65171D948E9BC7CBAA4D9" \ + "325D24D6A3C12710F10A09FA08AB87" ) ); + + if( verbose != 0 ) + mbedtls_printf( " MPI test #3 (exp_mod): " ); + + if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto cleanup; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &X, &A, &N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16, + "003A0AAEDD7E784FC07D8F9EC6E3BFD5" \ + "C3DBA76456363A10869622EAC2DD84EC" \ + "C5B8A74DAC4D09E03B5E0BE779F2DF61" ) ); + + if( verbose != 0 ) + mbedtls_printf( " MPI test #4 (inv_mod): " ); + + if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto cleanup; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " MPI test #5 (simple gcd): " ); + + for( i = 0; i < GCD_PAIR_COUNT; i++ ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &X, gcd_pairs[i][0] ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &Y, gcd_pairs[i][1] ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &A, &X, &Y ) ); + + if( mbedtls_mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed at %d\n", i ); + + ret = 1; + goto cleanup; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + +cleanup: + + if( ret != 0 && verbose != 0 ) + mbedtls_printf( "Unexpected error, return code = %08X\n", ret ); + + mbedtls_mpi_free( &A ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &N ); mbedtls_mpi_free( &X ); + mbedtls_mpi_free( &Y ); mbedtls_mpi_free( &U ); mbedtls_mpi_free( &V ); + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_BIGNUM_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/blowfish.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/blowfish.c new file mode 100644 index 0000000..9003f0d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/blowfish.c @@ -0,0 +1,656 @@ +/* + * Blowfish implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The Blowfish block cipher was designed by Bruce Schneier in 1993. + * http://www.schneier.com/blowfish.html + * http://en.wikipedia.org/wiki/Blowfish_%28cipher%29 + * + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_BLOWFISH_C) + +#include "mbedtls/blowfish.h" + +#include + +#if !defined(MBEDTLS_BLOWFISH_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +static const uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2] = { + 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, + 0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, + 0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL, + 0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, + 0x9216D5D9L, 0x8979FB1BL +}; + +/* declarations of data at the end of this file */ +static const uint32_t S[4][256]; + +static uint32_t F( mbedtls_blowfish_context *ctx, uint32_t x ) +{ + unsigned short a, b, c, d; + uint32_t y; + + d = (unsigned short)(x & 0xFF); + x >>= 8; + c = (unsigned short)(x & 0xFF); + x >>= 8; + b = (unsigned short)(x & 0xFF); + x >>= 8; + a = (unsigned short)(x & 0xFF); + y = ctx->S[0][a] + ctx->S[1][b]; + y = y ^ ctx->S[2][c]; + y = y + ctx->S[3][d]; + + return( y ); +} + +static void blowfish_enc( mbedtls_blowfish_context *ctx, uint32_t *xl, uint32_t *xr ) +{ + uint32_t Xl, Xr, temp; + short i; + + Xl = *xl; + Xr = *xr; + + for( i = 0; i < MBEDTLS_BLOWFISH_ROUNDS; ++i ) + { + Xl = Xl ^ ctx->P[i]; + Xr = F( ctx, Xl ) ^ Xr; + + temp = Xl; + Xl = Xr; + Xr = temp; + } + + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ ctx->P[MBEDTLS_BLOWFISH_ROUNDS]; + Xl = Xl ^ ctx->P[MBEDTLS_BLOWFISH_ROUNDS + 1]; + + *xl = Xl; + *xr = Xr; +} + +static void blowfish_dec( mbedtls_blowfish_context *ctx, uint32_t *xl, uint32_t *xr ) +{ + uint32_t Xl, Xr, temp; + short i; + + Xl = *xl; + Xr = *xr; + + for( i = MBEDTLS_BLOWFISH_ROUNDS + 1; i > 1; --i ) + { + Xl = Xl ^ ctx->P[i]; + Xr = F( ctx, Xl ) ^ Xr; + + temp = Xl; + Xl = Xr; + Xr = temp; + } + + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ ctx->P[1]; + Xl = Xl ^ ctx->P[0]; + + *xl = Xl; + *xr = Xr; +} + +void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_blowfish_context ) ); +} + +void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_blowfish_context ) ); +} + +/* + * Blowfish key schedule + */ +int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key, + unsigned int keybits ) +{ + unsigned int i, j, k; + uint32_t data, datal, datar; + + if( keybits < MBEDTLS_BLOWFISH_MIN_KEY_BITS || keybits > MBEDTLS_BLOWFISH_MAX_KEY_BITS || + ( keybits % 8 ) ) + { + return( MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH ); + } + + keybits >>= 3; + + for( i = 0; i < 4; i++ ) + { + for( j = 0; j < 256; j++ ) + ctx->S[i][j] = S[i][j]; + } + + j = 0; + for( i = 0; i < MBEDTLS_BLOWFISH_ROUNDS + 2; ++i ) + { + data = 0x00000000; + for( k = 0; k < 4; ++k ) + { + data = ( data << 8 ) | key[j++]; + if( j >= keybits ) + j = 0; + } + ctx->P[i] = P[i] ^ data; + } + + datal = 0x00000000; + datar = 0x00000000; + + for( i = 0; i < MBEDTLS_BLOWFISH_ROUNDS + 2; i += 2 ) + { + blowfish_enc( ctx, &datal, &datar ); + ctx->P[i] = datal; + ctx->P[i + 1] = datar; + } + + for( i = 0; i < 4; i++ ) + { + for( j = 0; j < 256; j += 2 ) + { + blowfish_enc( ctx, &datal, &datar ); + ctx->S[i][j] = datal; + ctx->S[i][j + 1] = datar; + } + } + return( 0 ); +} + +/* + * Blowfish-ECB block encryption/decryption + */ +int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, + int mode, + const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], + unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] ) +{ + uint32_t X0, X1; + + GET_UINT32_BE( X0, input, 0 ); + GET_UINT32_BE( X1, input, 4 ); + + if( mode == MBEDTLS_BLOWFISH_DECRYPT ) + { + blowfish_dec( ctx, &X0, &X1 ); + } + else /* MBEDTLS_BLOWFISH_ENCRYPT */ + { + blowfish_enc( ctx, &X0, &X1 ); + } + + PUT_UINT32_BE( X0, output, 0 ); + PUT_UINT32_BE( X1, output, 4 ); + + return( 0 ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * Blowfish-CBC buffer encryption/decryption + */ +int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, + int mode, + size_t length, + unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ) +{ + int i; + unsigned char temp[MBEDTLS_BLOWFISH_BLOCKSIZE]; + + if( length % MBEDTLS_BLOWFISH_BLOCKSIZE ) + return( MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH ); + + if( mode == MBEDTLS_BLOWFISH_DECRYPT ) + { + while( length > 0 ) + { + memcpy( temp, input, MBEDTLS_BLOWFISH_BLOCKSIZE ); + mbedtls_blowfish_crypt_ecb( ctx, mode, input, output ); + + for( i = 0; i < MBEDTLS_BLOWFISH_BLOCKSIZE;i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, MBEDTLS_BLOWFISH_BLOCKSIZE ); + + input += MBEDTLS_BLOWFISH_BLOCKSIZE; + output += MBEDTLS_BLOWFISH_BLOCKSIZE; + length -= MBEDTLS_BLOWFISH_BLOCKSIZE; + } + } + else + { + while( length > 0 ) + { + for( i = 0; i < MBEDTLS_BLOWFISH_BLOCKSIZE; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_blowfish_crypt_ecb( ctx, mode, output, output ); + memcpy( iv, output, MBEDTLS_BLOWFISH_BLOCKSIZE ); + + input += MBEDTLS_BLOWFISH_BLOCKSIZE; + output += MBEDTLS_BLOWFISH_BLOCKSIZE; + length -= MBEDTLS_BLOWFISH_BLOCKSIZE; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/* + * Blowfish CFB buffer encryption/decryption + */ +int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ) +{ + int c; + size_t n = *iv_off; + + if( mode == MBEDTLS_BLOWFISH_DECRYPT ) + { + while( length-- ) + { + if( n == 0 ) + mbedtls_blowfish_crypt_ecb( ctx, MBEDTLS_BLOWFISH_ENCRYPT, iv, iv ); + + c = *input++; + *output++ = (unsigned char)( c ^ iv[n] ); + iv[n] = (unsigned char) c; + + n = ( n + 1 ) % MBEDTLS_BLOWFISH_BLOCKSIZE; + } + } + else + { + while( length-- ) + { + if( n == 0 ) + mbedtls_blowfish_crypt_ecb( ctx, MBEDTLS_BLOWFISH_ENCRYPT, iv, iv ); + + iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); + + n = ( n + 1 ) % MBEDTLS_BLOWFISH_BLOCKSIZE; + } + } + + *iv_off = n; + + return( 0 ); +} +#endif /*MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * Blowfish CTR buffer encryption/decryption + */ +int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE], + unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ) +{ + int c, i; + size_t n = *nc_off; + + while( length-- ) + { + if( n == 0 ) { + mbedtls_blowfish_crypt_ecb( ctx, MBEDTLS_BLOWFISH_ENCRYPT, nonce_counter, + stream_block ); + + for( i = MBEDTLS_BLOWFISH_BLOCKSIZE; i > 0; i-- ) + if( ++nonce_counter[i - 1] != 0 ) + break; + } + c = *input++; + *output++ = (unsigned char)( c ^ stream_block[n] ); + + n = ( n + 1 ) % MBEDTLS_BLOWFISH_BLOCKSIZE; + } + + *nc_off = n; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +static const uint32_t S[4][256] = { + { 0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L, + 0xB8E1AFEDL, 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L, + 0x24A19947L, 0xB3916CF7L, 0x0801F2E2L, 0x858EFC16L, + 0x636920D8L, 0x71574E69L, 0xA458FEA3L, 0xF4933D7EL, + 0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL, + 0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L, + 0xC5D1B023L, 0x286085F0L, 0xCA417918L, 0xB8DB38EFL, + 0x8E79DCB0L, 0x603A180EL, 0x6C9E0E8BL, 0xB01E8A3EL, + 0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, 0x55605C60L, + 0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L, + 0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL, + 0xA15486AFL, 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL, + 0x2BA9C55DL, 0x741831F6L, 0xCE5C3E16L, 0x9B87931EL, + 0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, 0x28958677L, + 0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L, + 0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L, + 0xEF845D5DL, 0xE98575B1L, 0xDC262302L, 0xEB651B88L, + 0x23893E81L, 0xD396ACC5L, 0x0F6D6FF3L, 0x83F44239L, + 0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, 0x9E1F9B5EL, + 0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L, + 0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L, + 0x6EEF0B6CL, 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L, + 0xA1F1651DL, 0x39AF0176L, 0x66CA593EL, 0x82430E88L, + 0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, 0x3B8B5EBEL, + 0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L, + 0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL, + 0x37D0D724L, 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL, + 0x075372C9L, 0x80991B7BL, 0x25D479D8L, 0xF6E8DEF7L, + 0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, 0x04C006BAL, + 0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L, + 0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL, + 0x6DFC511FL, 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L, + 0xBEE3D004L, 0xDE334AFDL, 0x660F2807L, 0x192E4BB3L, + 0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, 0xB9D3FBDBL, + 0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L, + 0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L, + 0x3C7516DFL, 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL, + 0x323DB5FAL, 0xFD238760L, 0x53317B48L, 0x3E00DF82L, + 0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, 0xDF1769DBL, + 0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L, + 0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L, + 0x10FA3D98L, 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL, + 0x9A53E479L, 0xB6F84565L, 0xD28E49BCL, 0x4BFB9790L, + 0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, 0xCEE4C6E8L, + 0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L, + 0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L, + 0xD08ED1D0L, 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L, + 0x8FF6E2FBL, 0xF2122B64L, 0x8888B812L, 0x900DF01CL, + 0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, 0xB3A8C1ADL, + 0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L, + 0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L, + 0xB4A84FE0L, 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L, + 0x165FA266L, 0x80957705L, 0x93CC7314L, 0x211A1477L, + 0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, 0xFB9D35CFL, + 0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L, + 0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL, + 0x2464369BL, 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL, + 0x78C14389L, 0xD95A537FL, 0x207D5BA2L, 0x02E5B9C5L, + 0x83260376L, 0x6295CFA9L, 0x11C81968L, 0x4E734A41L, + 0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L, + 0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L, + 0x08BA6FB5L, 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L, + 0xB6636521L, 0xE7B9F9B6L, 0xFF34052EL, 0xC5855664L, + 0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, 0x6E85076AL }, + { 0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, 0xC4192623L, + 0xAD6EA6B0L, 0x49A7DF7DL, 0x9CEE60B8L, 0x8FEDB266L, + 0xECAA8C71L, 0x699A17FFL, 0x5664526CL, 0xC2B19EE1L, + 0x193602A5L, 0x75094C29L, 0xA0591340L, 0xE4183A3EL, + 0x3F54989AL, 0x5B429D65L, 0x6B8FE4D6L, 0x99F73FD6L, + 0xA1D29C07L, 0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L, + 0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, 0x021ECC5EL, + 0x09686B3FL, 0x3EBAEFC9L, 0x3C971814L, 0x6B6A70A1L, + 0x687F3584L, 0x52A0E286L, 0xB79C5305L, 0xAA500737L, + 0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, 0x5716F2B8L, + 0xB03ADA37L, 0xF0500C0DL, 0xF01C1F04L, 0x0200B3FFL, + 0xAE0CF51AL, 0x3CB574B2L, 0x25837A58L, 0xDC0921BDL, + 0xD19113F9L, 0x7CA92FF6L, 0x94324773L, 0x22F54701L, + 0x3AE5E581L, 0x37C2DADCL, 0xC8B57634L, 0x9AF3DDA7L, + 0xA9446146L, 0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L, + 0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, 0x183EB331L, + 0x4E548B38L, 0x4F6DB908L, 0x6F420D03L, 0xF60A04BFL, + 0x2CB81290L, 0x24977C79L, 0x5679B072L, 0xBCAF89AFL, + 0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, 0xDCCF3F2EL, + 0x5512721FL, 0x2E6B7124L, 0x501ADDE6L, 0x9F84CD87L, + 0x7A584718L, 0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL, + 0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, 0xC464C3D2L, + 0xEF1C1847L, 0x3215D908L, 0xDD433B37L, 0x24C2BA16L, + 0x12A14D43L, 0x2A65C451L, 0x50940002L, 0x133AE4DDL, + 0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, 0x5F11199BL, + 0x043556F1L, 0xD7A3C76BL, 0x3C11183BL, 0x5924A509L, + 0xF28FE6EDL, 0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL, + 0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, 0x5A3E2AB3L, + 0x771FE71CL, 0x4E3D06FAL, 0x2965DCB9L, 0x99E71D0FL, + 0x803E89D6L, 0x5266C825L, 0x2E4CC978L, 0x9C10B36AL, + 0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, 0x1E0A2DF4L, + 0xF2F74EA7L, 0x361D2B3DL, 0x1939260FL, 0x19C27960L, + 0x5223A708L, 0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L, + 0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, 0x018CFF28L, + 0xC332DDEFL, 0xBE6C5AA5L, 0x65582185L, 0x68AB9802L, + 0xEECEA50FL, 0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L, + 0x1521B628L, 0x29076170L, 0xECDD4775L, 0x619F1510L, + 0x13CCA830L, 0xEB61BD96L, 0x0334FE1EL, 0xAA0363CFL, + 0xB5735C90L, 0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L, + 0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, 0xB2F3846EL, + 0x648B1EAFL, 0x19BDF0CAL, 0xA02369B9L, 0x655ABB50L, + 0x40685A32L, 0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L, + 0x9B540B19L, 0x875FA099L, 0x95F7997EL, 0x623D7DA8L, + 0xF837889AL, 0x97E32D77L, 0x11ED935FL, 0x16681281L, + 0x0E358829L, 0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L, + 0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, 0x1AC24696L, + 0xCDB30AEBL, 0x532E3054L, 0x8FD948E4L, 0x6DBC3128L, + 0x58EBF2EFL, 0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L, + 0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, 0x203E13E0L, + 0x45EEE2B6L, 0xA3AAABEAL, 0xDB6C4F15L, 0xFACB4FD0L, + 0xC742F442L, 0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L, + 0xD81E799EL, 0x86854DC7L, 0xE44B476AL, 0x3D816250L, + 0xCF62A1F2L, 0x5B8D2646L, 0xFC8883A0L, 0xC1C7B6A3L, + 0x7F1524C3L, 0x69CB7492L, 0x47848A0BL, 0x5692B285L, + 0x095BBF00L, 0xAD19489DL, 0x1462B174L, 0x23820E00L, + 0x58428D2AL, 0x0C55F5EAL, 0x1DADF43EL, 0x233F7061L, + 0x3372F092L, 0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL, + 0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, 0xCE77326EL, + 0xA6078084L, 0x19F8509EL, 0xE8EFD855L, 0x61D99735L, + 0xA969A7AAL, 0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL, + 0x9E447A2EL, 0xC3453484L, 0xFDD56705L, 0x0E1E9EC9L, + 0xDB73DBD3L, 0x105588CDL, 0x675FDA79L, 0xE3674340L, + 0xC5C43465L, 0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L, + 0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, 0xDB83ADF7L }, + { 0xE93D5A68L, 0x948140F7L, 0xF64C261CL, 0x94692934L, + 0x411520F7L, 0x7602D4F7L, 0xBCF46B2EL, 0xD4A20068L, + 0xD4082471L, 0x3320F46AL, 0x43B7D4B7L, 0x500061AFL, + 0x1E39F62EL, 0x97244546L, 0x14214F74L, 0xBF8B8840L, + 0x4D95FC1DL, 0x96B591AFL, 0x70F4DDD3L, 0x66A02F45L, + 0xBFBC09ECL, 0x03BD9785L, 0x7FAC6DD0L, 0x31CB8504L, + 0x96EB27B3L, 0x55FD3941L, 0xDA2547E6L, 0xABCA0A9AL, + 0x28507825L, 0x530429F4L, 0x0A2C86DAL, 0xE9B66DFBL, + 0x68DC1462L, 0xD7486900L, 0x680EC0A4L, 0x27A18DEEL, + 0x4F3FFEA2L, 0xE887AD8CL, 0xB58CE006L, 0x7AF4D6B6L, + 0xAACE1E7CL, 0xD3375FECL, 0xCE78A399L, 0x406B2A42L, + 0x20FE9E35L, 0xD9F385B9L, 0xEE39D7ABL, 0x3B124E8BL, + 0x1DC9FAF7L, 0x4B6D1856L, 0x26A36631L, 0xEAE397B2L, + 0x3A6EFA74L, 0xDD5B4332L, 0x6841E7F7L, 0xCA7820FBL, + 0xFB0AF54EL, 0xD8FEB397L, 0x454056ACL, 0xBA489527L, + 0x55533A3AL, 0x20838D87L, 0xFE6BA9B7L, 0xD096954BL, + 0x55A867BCL, 0xA1159A58L, 0xCCA92963L, 0x99E1DB33L, + 0xA62A4A56L, 0x3F3125F9L, 0x5EF47E1CL, 0x9029317CL, + 0xFDF8E802L, 0x04272F70L, 0x80BB155CL, 0x05282CE3L, + 0x95C11548L, 0xE4C66D22L, 0x48C1133FL, 0xC70F86DCL, + 0x07F9C9EEL, 0x41041F0FL, 0x404779A4L, 0x5D886E17L, + 0x325F51EBL, 0xD59BC0D1L, 0xF2BCC18FL, 0x41113564L, + 0x257B7834L, 0x602A9C60L, 0xDFF8E8A3L, 0x1F636C1BL, + 0x0E12B4C2L, 0x02E1329EL, 0xAF664FD1L, 0xCAD18115L, + 0x6B2395E0L, 0x333E92E1L, 0x3B240B62L, 0xEEBEB922L, + 0x85B2A20EL, 0xE6BA0D99L, 0xDE720C8CL, 0x2DA2F728L, + 0xD0127845L, 0x95B794FDL, 0x647D0862L, 0xE7CCF5F0L, + 0x5449A36FL, 0x877D48FAL, 0xC39DFD27L, 0xF33E8D1EL, + 0x0A476341L, 0x992EFF74L, 0x3A6F6EABL, 0xF4F8FD37L, + 0xA812DC60L, 0xA1EBDDF8L, 0x991BE14CL, 0xDB6E6B0DL, + 0xC67B5510L, 0x6D672C37L, 0x2765D43BL, 0xDCD0E804L, + 0xF1290DC7L, 0xCC00FFA3L, 0xB5390F92L, 0x690FED0BL, + 0x667B9FFBL, 0xCEDB7D9CL, 0xA091CF0BL, 0xD9155EA3L, + 0xBB132F88L, 0x515BAD24L, 0x7B9479BFL, 0x763BD6EBL, + 0x37392EB3L, 0xCC115979L, 0x8026E297L, 0xF42E312DL, + 0x6842ADA7L, 0xC66A2B3BL, 0x12754CCCL, 0x782EF11CL, + 0x6A124237L, 0xB79251E7L, 0x06A1BBE6L, 0x4BFB6350L, + 0x1A6B1018L, 0x11CAEDFAL, 0x3D25BDD8L, 0xE2E1C3C9L, + 0x44421659L, 0x0A121386L, 0xD90CEC6EL, 0xD5ABEA2AL, + 0x64AF674EL, 0xDA86A85FL, 0xBEBFE988L, 0x64E4C3FEL, + 0x9DBC8057L, 0xF0F7C086L, 0x60787BF8L, 0x6003604DL, + 0xD1FD8346L, 0xF6381FB0L, 0x7745AE04L, 0xD736FCCCL, + 0x83426B33L, 0xF01EAB71L, 0xB0804187L, 0x3C005E5FL, + 0x77A057BEL, 0xBDE8AE24L, 0x55464299L, 0xBF582E61L, + 0x4E58F48FL, 0xF2DDFDA2L, 0xF474EF38L, 0x8789BDC2L, + 0x5366F9C3L, 0xC8B38E74L, 0xB475F255L, 0x46FCD9B9L, + 0x7AEB2661L, 0x8B1DDF84L, 0x846A0E79L, 0x915F95E2L, + 0x466E598EL, 0x20B45770L, 0x8CD55591L, 0xC902DE4CL, + 0xB90BACE1L, 0xBB8205D0L, 0x11A86248L, 0x7574A99EL, + 0xB77F19B6L, 0xE0A9DC09L, 0x662D09A1L, 0xC4324633L, + 0xE85A1F02L, 0x09F0BE8CL, 0x4A99A025L, 0x1D6EFE10L, + 0x1AB93D1DL, 0x0BA5A4DFL, 0xA186F20FL, 0x2868F169L, + 0xDCB7DA83L, 0x573906FEL, 0xA1E2CE9BL, 0x4FCD7F52L, + 0x50115E01L, 0xA70683FAL, 0xA002B5C4L, 0x0DE6D027L, + 0x9AF88C27L, 0x773F8641L, 0xC3604C06L, 0x61A806B5L, + 0xF0177A28L, 0xC0F586E0L, 0x006058AAL, 0x30DC7D62L, + 0x11E69ED7L, 0x2338EA63L, 0x53C2DD94L, 0xC2C21634L, + 0xBBCBEE56L, 0x90BCB6DEL, 0xEBFC7DA1L, 0xCE591D76L, + 0x6F05E409L, 0x4B7C0188L, 0x39720A3DL, 0x7C927C24L, + 0x86E3725FL, 0x724D9DB9L, 0x1AC15BB4L, 0xD39EB8FCL, + 0xED545578L, 0x08FCA5B5L, 0xD83D7CD3L, 0x4DAD0FC4L, + 0x1E50EF5EL, 0xB161E6F8L, 0xA28514D9L, 0x6C51133CL, + 0x6FD5C7E7L, 0x56E14EC4L, 0x362ABFCEL, 0xDDC6C837L, + 0xD79A3234L, 0x92638212L, 0x670EFA8EL, 0x406000E0L }, + { 0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL, + 0x5CB0679EL, 0x4FA33742L, 0xD3822740L, 0x99BC9BBEL, + 0xD5118E9DL, 0xBF0F7315L, 0xD62D1C7EL, 0xC700C47BL, + 0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, 0x6A366EB4L, + 0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L, + 0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L, + 0x2939BBDBL, 0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L, + 0xA1FAD5F0L, 0x6A2D519AL, 0x63EF8CE2L, 0x9A86EE22L, + 0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, 0x9CF2D0A4L, + 0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L, + 0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L, + 0xC72FEFD3L, 0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L, + 0x80E4A915L, 0x87B08601L, 0x9B09E6ADL, 0x3B3EE593L, + 0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, 0x022B8B51L, + 0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L, + 0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL, + 0xE029AC71L, 0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL, + 0xE8D3C48DL, 0x283B57CCL, 0xF8D56629L, 0x79132E28L, + 0x785F0191L, 0xED756055L, 0xF7960E44L, 0xE3D35E8CL, + 0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL, + 0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL, + 0x1B3F6D9BL, 0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L, + 0x7533D928L, 0xB155FDF5L, 0x03563482L, 0x8ABA3CBBL, + 0x28517711L, 0xC20AD9F8L, 0xABCC5167L, 0xCCAD925FL, + 0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L, + 0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L, + 0xA8B6E37EL, 0xC3293D46L, 0x48DE5369L, 0x6413E680L, + 0xA2AE0810L, 0xDD6DB224L, 0x69852DFDL, 0x09072166L, + 0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, 0x1C20C8AEL, + 0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL, + 0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L, + 0x72EACEA8L, 0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L, + 0xD29BE463L, 0x542F5D9EL, 0xAEC2771BL, 0xF64E6370L, + 0x740E0D8DL, 0xE75B1357L, 0xF8721671L, 0xAF537D5DL, + 0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L, + 0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L, + 0x6F3F3B82L, 0x3520AB82L, 0x011A1D4BL, 0x277227F8L, + 0x611560B1L, 0xE7933FDCL, 0xBB3A792BL, 0x344525BDL, + 0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, 0xA01FBAC9L, + 0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L, + 0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L, + 0x0339C32AL, 0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL, + 0xF79E59B7L, 0x43F5BB3AL, 0xF2D519FFL, 0x27D9459CL, + 0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, 0x9B941525L, + 0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L, + 0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L, + 0xE0EC6E0EL, 0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L, + 0x9F1F9532L, 0xE0D392DFL, 0xD3A0342BL, 0x8971F21EL, + 0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, 0xC37632D8L, + 0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL, + 0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL, + 0x1618B166L, 0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L, + 0xF523F357L, 0xA6327623L, 0x93A83531L, 0x56CCCD02L, + 0xACF08162L, 0x5A75EBB5L, 0x6E163697L, 0x88D273CCL, + 0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L, + 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, + 0xC9AA53FDL, 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, + 0x71126905L, 0xB2040222L, 0xB6CBCF7CL, 0xCD769C2BL, + 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, 0x2547ADF0L, + 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, + 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, + 0x1948C25CL, 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, + 0x90D4F869L, 0xA65CDEA0L, 0x3F09252DL, 0xC208E69FL, + 0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L } +}; + +#endif /* !MBEDTLS_BLOWFISH_ALT */ +#endif /* MBEDTLS_BLOWFISH_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/camellia.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/camellia.c new file mode 100644 index 0000000..ac6f96a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/camellia.c @@ -0,0 +1,1072 @@ +/* + * Camellia implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The Camellia block cipher was designed by NTT and Mitsubishi Electric + * Corporation. + * + * http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/01espec.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CAMELLIA_C) + +#include "mbedtls/camellia.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_CAMELLIA_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +static const unsigned char SIGMA_CHARS[6][8] = +{ + { 0xa0, 0x9e, 0x66, 0x7f, 0x3b, 0xcc, 0x90, 0x8b }, + { 0xb6, 0x7a, 0xe8, 0x58, 0x4c, 0xaa, 0x73, 0xb2 }, + { 0xc6, 0xef, 0x37, 0x2f, 0xe9, 0x4f, 0x82, 0xbe }, + { 0x54, 0xff, 0x53, 0xa5, 0xf1, 0xd3, 0x6f, 0x1c }, + { 0x10, 0xe5, 0x27, 0xfa, 0xde, 0x68, 0x2d, 0x1d }, + { 0xb0, 0x56, 0x88, 0xc2, 0xb3, 0xe6, 0xc1, 0xfd } +}; + +#if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY) + +static const unsigned char FSb[256] = +{ + 112,130, 44,236,179, 39,192,229,228,133, 87, 53,234, 12,174, 65, + 35,239,107,147, 69, 25,165, 33,237, 14, 79, 78, 29,101,146,189, + 134,184,175,143,124,235, 31,206, 62, 48,220, 95, 94,197, 11, 26, + 166,225, 57,202,213, 71, 93, 61,217, 1, 90,214, 81, 86,108, 77, + 139, 13,154,102,251,204,176, 45,116, 18, 43, 32,240,177,132,153, + 223, 76,203,194, 52,126,118, 5,109,183,169, 49,209, 23, 4,215, + 20, 88, 58, 97,222, 27, 17, 28, 50, 15,156, 22, 83, 24,242, 34, + 254, 68,207,178,195,181,122,145, 36, 8,232,168, 96,252,105, 80, + 170,208,160,125,161,137, 98,151, 84, 91, 30,149,224,255,100,210, + 16,196, 0, 72,163,247,117,219,138, 3,230,218, 9, 63,221,148, + 135, 92,131, 2,205, 74,144, 51,115,103,246,243,157,127,191,226, + 82,155,216, 38,200, 55,198, 59,129,150,111, 75, 19,190, 99, 46, + 233,121,167,140,159,110,188,142, 41,245,249,182, 47,253,180, 89, + 120,152, 6,106,231, 70,113,186,212, 37,171, 66,136,162,141,250, + 114, 7,185, 85,248,238,172, 10, 54, 73, 42,104, 60, 56,241,164, + 64, 40,211,123,187,201, 67,193, 21,227,173,244,119,199,128,158 +}; + +#define SBOX1(n) FSb[(n)] +#define SBOX2(n) (unsigned char)((FSb[(n)] >> 7 ^ FSb[(n)] << 1) & 0xff) +#define SBOX3(n) (unsigned char)((FSb[(n)] >> 1 ^ FSb[(n)] << 7) & 0xff) +#define SBOX4(n) FSb[((n) << 1 ^ (n) >> 7) &0xff] + +#else /* MBEDTLS_CAMELLIA_SMALL_MEMORY */ + +static const unsigned char FSb[256] = +{ + 112, 130, 44, 236, 179, 39, 192, 229, 228, 133, 87, 53, 234, 12, 174, 65, + 35, 239, 107, 147, 69, 25, 165, 33, 237, 14, 79, 78, 29, 101, 146, 189, + 134, 184, 175, 143, 124, 235, 31, 206, 62, 48, 220, 95, 94, 197, 11, 26, + 166, 225, 57, 202, 213, 71, 93, 61, 217, 1, 90, 214, 81, 86, 108, 77, + 139, 13, 154, 102, 251, 204, 176, 45, 116, 18, 43, 32, 240, 177, 132, 153, + 223, 76, 203, 194, 52, 126, 118, 5, 109, 183, 169, 49, 209, 23, 4, 215, + 20, 88, 58, 97, 222, 27, 17, 28, 50, 15, 156, 22, 83, 24, 242, 34, + 254, 68, 207, 178, 195, 181, 122, 145, 36, 8, 232, 168, 96, 252, 105, 80, + 170, 208, 160, 125, 161, 137, 98, 151, 84, 91, 30, 149, 224, 255, 100, 210, + 16, 196, 0, 72, 163, 247, 117, 219, 138, 3, 230, 218, 9, 63, 221, 148, + 135, 92, 131, 2, 205, 74, 144, 51, 115, 103, 246, 243, 157, 127, 191, 226, + 82, 155, 216, 38, 200, 55, 198, 59, 129, 150, 111, 75, 19, 190, 99, 46, + 233, 121, 167, 140, 159, 110, 188, 142, 41, 245, 249, 182, 47, 253, 180, 89, + 120, 152, 6, 106, 231, 70, 113, 186, 212, 37, 171, 66, 136, 162, 141, 250, + 114, 7, 185, 85, 248, 238, 172, 10, 54, 73, 42, 104, 60, 56, 241, 164, + 64, 40, 211, 123, 187, 201, 67, 193, 21, 227, 173, 244, 119, 199, 128, 158 +}; + +static const unsigned char FSb2[256] = +{ + 224, 5, 88, 217, 103, 78, 129, 203, 201, 11, 174, 106, 213, 24, 93, 130, + 70, 223, 214, 39, 138, 50, 75, 66, 219, 28, 158, 156, 58, 202, 37, 123, + 13, 113, 95, 31, 248, 215, 62, 157, 124, 96, 185, 190, 188, 139, 22, 52, + 77, 195, 114, 149, 171, 142, 186, 122, 179, 2, 180, 173, 162, 172, 216, 154, + 23, 26, 53, 204, 247, 153, 97, 90, 232, 36, 86, 64, 225, 99, 9, 51, + 191, 152, 151, 133, 104, 252, 236, 10, 218, 111, 83, 98, 163, 46, 8, 175, + 40, 176, 116, 194, 189, 54, 34, 56, 100, 30, 57, 44, 166, 48, 229, 68, + 253, 136, 159, 101, 135, 107, 244, 35, 72, 16, 209, 81, 192, 249, 210, 160, + 85, 161, 65, 250, 67, 19, 196, 47, 168, 182, 60, 43, 193, 255, 200, 165, + 32, 137, 0, 144, 71, 239, 234, 183, 21, 6, 205, 181, 18, 126, 187, 41, + 15, 184, 7, 4, 155, 148, 33, 102, 230, 206, 237, 231, 59, 254, 127, 197, + 164, 55, 177, 76, 145, 110, 141, 118, 3, 45, 222, 150, 38, 125, 198, 92, + 211, 242, 79, 25, 63, 220, 121, 29, 82, 235, 243, 109, 94, 251, 105, 178, + 240, 49, 12, 212, 207, 140, 226, 117, 169, 74, 87, 132, 17, 69, 27, 245, + 228, 14, 115, 170, 241, 221, 89, 20, 108, 146, 84, 208, 120, 112, 227, 73, + 128, 80, 167, 246, 119, 147, 134, 131, 42, 199, 91, 233, 238, 143, 1, 61 +}; + +static const unsigned char FSb3[256] = +{ + 56, 65, 22, 118, 217, 147, 96, 242, 114, 194, 171, 154, 117, 6, 87, 160, + 145, 247, 181, 201, 162, 140, 210, 144, 246, 7, 167, 39, 142, 178, 73, 222, + 67, 92, 215, 199, 62, 245, 143, 103, 31, 24, 110, 175, 47, 226, 133, 13, + 83, 240, 156, 101, 234, 163, 174, 158, 236, 128, 45, 107, 168, 43, 54, 166, + 197, 134, 77, 51, 253, 102, 88, 150, 58, 9, 149, 16, 120, 216, 66, 204, + 239, 38, 229, 97, 26, 63, 59, 130, 182, 219, 212, 152, 232, 139, 2, 235, + 10, 44, 29, 176, 111, 141, 136, 14, 25, 135, 78, 11, 169, 12, 121, 17, + 127, 34, 231, 89, 225, 218, 61, 200, 18, 4, 116, 84, 48, 126, 180, 40, + 85, 104, 80, 190, 208, 196, 49, 203, 42, 173, 15, 202, 112, 255, 50, 105, + 8, 98, 0, 36, 209, 251, 186, 237, 69, 129, 115, 109, 132, 159, 238, 74, + 195, 46, 193, 1, 230, 37, 72, 153, 185, 179, 123, 249, 206, 191, 223, 113, + 41, 205, 108, 19, 100, 155, 99, 157, 192, 75, 183, 165, 137, 95, 177, 23, + 244, 188, 211, 70, 207, 55, 94, 71, 148, 250, 252, 91, 151, 254, 90, 172, + 60, 76, 3, 53, 243, 35, 184, 93, 106, 146, 213, 33, 68, 81, 198, 125, + 57, 131, 220, 170, 124, 119, 86, 5, 27, 164, 21, 52, 30, 28, 248, 82, + 32, 20, 233, 189, 221, 228, 161, 224, 138, 241, 214, 122, 187, 227, 64, 79 +}; + +static const unsigned char FSb4[256] = +{ + 112, 44, 179, 192, 228, 87, 234, 174, 35, 107, 69, 165, 237, 79, 29, 146, + 134, 175, 124, 31, 62, 220, 94, 11, 166, 57, 213, 93, 217, 90, 81, 108, + 139, 154, 251, 176, 116, 43, 240, 132, 223, 203, 52, 118, 109, 169, 209, 4, + 20, 58, 222, 17, 50, 156, 83, 242, 254, 207, 195, 122, 36, 232, 96, 105, + 170, 160, 161, 98, 84, 30, 224, 100, 16, 0, 163, 117, 138, 230, 9, 221, + 135, 131, 205, 144, 115, 246, 157, 191, 82, 216, 200, 198, 129, 111, 19, 99, + 233, 167, 159, 188, 41, 249, 47, 180, 120, 6, 231, 113, 212, 171, 136, 141, + 114, 185, 248, 172, 54, 42, 60, 241, 64, 211, 187, 67, 21, 173, 119, 128, + 130, 236, 39, 229, 133, 53, 12, 65, 239, 147, 25, 33, 14, 78, 101, 189, + 184, 143, 235, 206, 48, 95, 197, 26, 225, 202, 71, 61, 1, 214, 86, 77, + 13, 102, 204, 45, 18, 32, 177, 153, 76, 194, 126, 5, 183, 49, 23, 215, + 88, 97, 27, 28, 15, 22, 24, 34, 68, 178, 181, 145, 8, 168, 252, 80, + 208, 125, 137, 151, 91, 149, 255, 210, 196, 72, 247, 219, 3, 218, 63, 148, + 92, 2, 74, 51, 103, 243, 127, 226, 155, 38, 55, 59, 150, 75, 190, 46, + 121, 140, 110, 142, 245, 182, 253, 89, 152, 106, 70, 186, 37, 66, 162, 250, + 7, 85, 238, 10, 73, 104, 56, 164, 40, 123, 201, 193, 227, 244, 199, 158 +}; + +#define SBOX1(n) FSb[(n)] +#define SBOX2(n) FSb2[(n)] +#define SBOX3(n) FSb3[(n)] +#define SBOX4(n) FSb4[(n)] + +#endif /* MBEDTLS_CAMELLIA_SMALL_MEMORY */ + +static const unsigned char shifts[2][4][4] = +{ + { + { 1, 1, 1, 1 }, /* KL */ + { 0, 0, 0, 0 }, /* KR */ + { 1, 1, 1, 1 }, /* KA */ + { 0, 0, 0, 0 } /* KB */ + }, + { + { 1, 0, 1, 1 }, /* KL */ + { 1, 1, 0, 1 }, /* KR */ + { 1, 1, 1, 0 }, /* KA */ + { 1, 1, 0, 1 } /* KB */ + } +}; + +static const signed char indexes[2][4][20] = +{ + { + { 0, 1, 2, 3, 8, 9, 10, 11, 38, 39, + 36, 37, 23, 20, 21, 22, 27, -1, -1, 26 }, /* KL -> RK */ + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* KR -> RK */ + { 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, + 18, 19, -1, 24, 25, -1, 31, 28, 29, 30 }, /* KA -> RK */ + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } /* KB -> RK */ + }, + { + { 0, 1, 2, 3, 61, 62, 63, 60, -1, -1, + -1, -1, 27, 24, 25, 26, 35, 32, 33, 34 }, /* KL -> RK */ + { -1, -1, -1, -1, 8, 9, 10, 11, 16, 17, + 18, 19, -1, -1, -1, -1, 39, 36, 37, 38 }, /* KR -> RK */ + { -1, -1, -1, -1, 12, 13, 14, 15, 58, 59, + 56, 57, 31, 28, 29, 30, -1, -1, -1, -1 }, /* KA -> RK */ + { 4, 5, 6, 7, 65, 66, 67, 64, 20, 21, + 22, 23, -1, -1, -1, -1, 43, 40, 41, 42 } /* KB -> RK */ + } +}; + +static const signed char transposes[2][20] = +{ + { + 21, 22, 23, 20, + -1, -1, -1, -1, + 18, 19, 16, 17, + 11, 8, 9, 10, + 15, 12, 13, 14 + }, + { + 25, 26, 27, 24, + 29, 30, 31, 28, + 18, 19, 16, 17, + -1, -1, -1, -1, + -1, -1, -1, -1 + } +}; + +/* Shift macro for 128 bit strings with rotation smaller than 32 bits (!) */ +#define ROTL(DEST, SRC, SHIFT) \ +{ \ + (DEST)[0] = (SRC)[0] << (SHIFT) ^ (SRC)[1] >> (32 - (SHIFT)); \ + (DEST)[1] = (SRC)[1] << (SHIFT) ^ (SRC)[2] >> (32 - (SHIFT)); \ + (DEST)[2] = (SRC)[2] << (SHIFT) ^ (SRC)[3] >> (32 - (SHIFT)); \ + (DEST)[3] = (SRC)[3] << (SHIFT) ^ (SRC)[0] >> (32 - (SHIFT)); \ +} + +#define FL(XL, XR, KL, KR) \ +{ \ + (XR) = ((((XL) & (KL)) << 1) | (((XL) & (KL)) >> 31)) ^ (XR); \ + (XL) = ((XR) | (KR)) ^ (XL); \ +} + +#define FLInv(YL, YR, KL, KR) \ +{ \ + (YL) = ((YR) | (KR)) ^ (YL); \ + (YR) = ((((YL) & (KL)) << 1) | (((YL) & (KL)) >> 31)) ^ (YR); \ +} + +#define SHIFT_AND_PLACE(INDEX, OFFSET) \ +{ \ + TK[0] = KC[(OFFSET) * 4 + 0]; \ + TK[1] = KC[(OFFSET) * 4 + 1]; \ + TK[2] = KC[(OFFSET) * 4 + 2]; \ + TK[3] = KC[(OFFSET) * 4 + 3]; \ + \ + for( i = 1; i <= 4; i++ ) \ + if( shifts[(INDEX)][(OFFSET)][i -1] ) \ + ROTL(TK + i * 4, TK, ( 15 * i ) % 32); \ + \ + for( i = 0; i < 20; i++ ) \ + if( indexes[(INDEX)][(OFFSET)][i] != -1 ) { \ + RK[indexes[(INDEX)][(OFFSET)][i]] = TK[ i ]; \ + } \ +} + +static void camellia_feistel( const uint32_t x[2], const uint32_t k[2], + uint32_t z[2]) +{ + uint32_t I0, I1; + I0 = x[0] ^ k[0]; + I1 = x[1] ^ k[1]; + + I0 = ((uint32_t) SBOX1((I0 >> 24) & 0xFF) << 24) | + ((uint32_t) SBOX2((I0 >> 16) & 0xFF) << 16) | + ((uint32_t) SBOX3((I0 >> 8) & 0xFF) << 8) | + ((uint32_t) SBOX4((I0 ) & 0xFF) ); + I1 = ((uint32_t) SBOX2((I1 >> 24) & 0xFF) << 24) | + ((uint32_t) SBOX3((I1 >> 16) & 0xFF) << 16) | + ((uint32_t) SBOX4((I1 >> 8) & 0xFF) << 8) | + ((uint32_t) SBOX1((I1 ) & 0xFF) ); + + I0 ^= (I1 << 8) | (I1 >> 24); + I1 ^= (I0 << 16) | (I0 >> 16); + I0 ^= (I1 >> 8) | (I1 << 24); + I1 ^= (I0 >> 8) | (I0 << 24); + + z[0] ^= I1; + z[1] ^= I0; +} + +void mbedtls_camellia_init( mbedtls_camellia_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_camellia_context ) ); +} + +void mbedtls_camellia_free( mbedtls_camellia_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_camellia_context ) ); +} + +/* + * Camellia key schedule (encryption) + */ +int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key, + unsigned int keybits ) +{ + int idx; + size_t i; + uint32_t *RK; + unsigned char t[64]; + uint32_t SIGMA[6][2]; + uint32_t KC[16]; + uint32_t TK[20]; + + RK = ctx->rk; + + memset( t, 0, 64 ); + memset( RK, 0, sizeof(ctx->rk) ); + + switch( keybits ) + { + case 128: ctx->nr = 3; idx = 0; break; + case 192: + case 256: ctx->nr = 4; idx = 1; break; + default : return( MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH ); + } + + for( i = 0; i < keybits / 8; ++i ) + t[i] = key[i]; + + if( keybits == 192 ) { + for( i = 0; i < 8; i++ ) + t[24 + i] = ~t[16 + i]; + } + + /* + * Prepare SIGMA values + */ + for( i = 0; i < 6; i++ ) { + GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 ); + GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 ); + } + + /* + * Key storage in KC + * Order: KL, KR, KA, KB + */ + memset( KC, 0, sizeof(KC) ); + + /* Store KL, KR */ + for( i = 0; i < 8; i++ ) + GET_UINT32_BE( KC[i], t, i * 4 ); + + /* Generate KA */ + for( i = 0; i < 4; ++i ) + KC[8 + i] = KC[i] ^ KC[4 + i]; + + camellia_feistel( KC + 8, SIGMA[0], KC + 10 ); + camellia_feistel( KC + 10, SIGMA[1], KC + 8 ); + + for( i = 0; i < 4; ++i ) + KC[8 + i] ^= KC[i]; + + camellia_feistel( KC + 8, SIGMA[2], KC + 10 ); + camellia_feistel( KC + 10, SIGMA[3], KC + 8 ); + + if( keybits > 128 ) { + /* Generate KB */ + for( i = 0; i < 4; ++i ) + KC[12 + i] = KC[4 + i] ^ KC[8 + i]; + + camellia_feistel( KC + 12, SIGMA[4], KC + 14 ); + camellia_feistel( KC + 14, SIGMA[5], KC + 12 ); + } + + /* + * Generating subkeys + */ + + /* Manipulating KL */ + SHIFT_AND_PLACE( idx, 0 ); + + /* Manipulating KR */ + if( keybits > 128 ) { + SHIFT_AND_PLACE( idx, 1 ); + } + + /* Manipulating KA */ + SHIFT_AND_PLACE( idx, 2 ); + + /* Manipulating KB */ + if( keybits > 128 ) { + SHIFT_AND_PLACE( idx, 3 ); + } + + /* Do transpositions */ + for( i = 0; i < 20; i++ ) { + if( transposes[idx][i] != -1 ) { + RK[32 + 12 * idx + i] = RK[transposes[idx][i]]; + } + } + + return( 0 ); +} + +/* + * Camellia key schedule (decryption) + */ +int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key, + unsigned int keybits ) +{ + int idx, ret; + size_t i; + mbedtls_camellia_context cty; + uint32_t *RK; + uint32_t *SK; + + mbedtls_camellia_init( &cty ); + + /* Also checks keybits */ + if( ( ret = mbedtls_camellia_setkey_enc( &cty, key, keybits ) ) != 0 ) + goto exit; + + ctx->nr = cty.nr; + idx = ( ctx->nr == 4 ); + + RK = ctx->rk; + SK = cty.rk + 24 * 2 + 8 * idx * 2; + + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + + for( i = 22 + 8 * idx, SK -= 6; i > 0; i--, SK -= 4 ) + { + *RK++ = *SK++; + *RK++ = *SK++; + } + + SK -= 2; + + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + *RK++ = *SK++; + +exit: + mbedtls_camellia_free( &cty ); + + return( ret ); +} + +/* + * Camellia-ECB block encryption/decryption + */ +int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ) +{ + int NR; + uint32_t *RK, X[4]; + + ( (void) mode ); + + NR = ctx->nr; + RK = ctx->rk; + + GET_UINT32_BE( X[0], input, 0 ); + GET_UINT32_BE( X[1], input, 4 ); + GET_UINT32_BE( X[2], input, 8 ); + GET_UINT32_BE( X[3], input, 12 ); + + X[0] ^= *RK++; + X[1] ^= *RK++; + X[2] ^= *RK++; + X[3] ^= *RK++; + + while( NR ) { + --NR; + camellia_feistel( X, RK, X + 2 ); + RK += 2; + camellia_feistel( X + 2, RK, X ); + RK += 2; + camellia_feistel( X, RK, X + 2 ); + RK += 2; + camellia_feistel( X + 2, RK, X ); + RK += 2; + camellia_feistel( X, RK, X + 2 ); + RK += 2; + camellia_feistel( X + 2, RK, X ); + RK += 2; + + if( NR ) { + FL(X[0], X[1], RK[0], RK[1]); + RK += 2; + FLInv(X[2], X[3], RK[0], RK[1]); + RK += 2; + } + } + + X[2] ^= *RK++; + X[3] ^= *RK++; + X[0] ^= *RK++; + X[1] ^= *RK++; + + PUT_UINT32_BE( X[2], output, 0 ); + PUT_UINT32_BE( X[3], output, 4 ); + PUT_UINT32_BE( X[0], output, 8 ); + PUT_UINT32_BE( X[1], output, 12 ); + + return( 0 ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * Camellia-CBC buffer encryption/decryption + */ +int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + int i; + unsigned char temp[16]; + + if( length % 16 ) + return( MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH ); + + if( mode == MBEDTLS_CAMELLIA_DECRYPT ) + { + while( length > 0 ) + { + memcpy( temp, input, 16 ); + mbedtls_camellia_crypt_ecb( ctx, mode, input, output ); + + for( i = 0; i < 16; i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, 16 ); + + input += 16; + output += 16; + length -= 16; + } + } + else + { + while( length > 0 ) + { + for( i = 0; i < 16; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_camellia_crypt_ecb( ctx, mode, output, output ); + memcpy( iv, output, 16 ); + + input += 16; + output += 16; + length -= 16; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/* + * Camellia-CFB128 buffer encryption/decryption + */ +int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + int c; + size_t n = *iv_off; + + if( mode == MBEDTLS_CAMELLIA_DECRYPT ) + { + while( length-- ) + { + if( n == 0 ) + mbedtls_camellia_crypt_ecb( ctx, MBEDTLS_CAMELLIA_ENCRYPT, iv, iv ); + + c = *input++; + *output++ = (unsigned char)( c ^ iv[n] ); + iv[n] = (unsigned char) c; + + n = ( n + 1 ) & 0x0F; + } + } + else + { + while( length-- ) + { + if( n == 0 ) + mbedtls_camellia_crypt_ecb( ctx, MBEDTLS_CAMELLIA_ENCRYPT, iv, iv ); + + iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); + + n = ( n + 1 ) & 0x0F; + } + } + + *iv_off = n; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * Camellia-CTR buffer encryption/decryption + */ +int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[16], + unsigned char stream_block[16], + const unsigned char *input, + unsigned char *output ) +{ + int c, i; + size_t n = *nc_off; + + while( length-- ) + { + if( n == 0 ) { + mbedtls_camellia_crypt_ecb( ctx, MBEDTLS_CAMELLIA_ENCRYPT, nonce_counter, + stream_block ); + + for( i = 16; i > 0; i-- ) + if( ++nonce_counter[i - 1] != 0 ) + break; + } + c = *input++; + *output++ = (unsigned char)( c ^ stream_block[n] ); + + n = ( n + 1 ) & 0x0F; + } + + *nc_off = n; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ +#endif /* !MBEDTLS_CAMELLIA_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +/* + * Camellia test vectors from: + * + * http://info.isl.ntt.co.jp/crypt/eng/camellia/technology.html: + * http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/cryptrec/intermediate.txt + * http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/cryptrec/t_camellia.txt + * (For each bitlength: Key 0, Nr 39) + */ +#define CAMELLIA_TESTS_ECB 2 + +static const unsigned char camellia_test_ecb_key[3][CAMELLIA_TESTS_ECB][32] = +{ + { + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, + { + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, + { + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, +}; + +static const unsigned char camellia_test_ecb_plain[CAMELLIA_TESTS_ECB][16] = +{ + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, + { 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +}; + +static const unsigned char camellia_test_ecb_cipher[3][CAMELLIA_TESTS_ECB][16] = +{ + { + { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73, + 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 }, + { 0x38, 0x3C, 0x6C, 0x2A, 0xAB, 0xEF, 0x7F, 0xDE, + 0x25, 0xCD, 0x47, 0x0B, 0xF7, 0x74, 0xA3, 0x31 } + }, + { + { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8, + 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 }, + { 0xD1, 0x76, 0x3F, 0xC0, 0x19, 0xD7, 0x7C, 0xC9, + 0x30, 0xBF, 0xF2, 0xA5, 0x6F, 0x7C, 0x93, 0x64 } + }, + { + { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, + 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 }, + { 0x05, 0x03, 0xFB, 0x10, 0xAB, 0x24, 0x1E, 0x7C, + 0xF4, 0x5D, 0x8C, 0xDE, 0xEE, 0x47, 0x43, 0x35 } + } +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#define CAMELLIA_TESTS_CBC 3 + +static const unsigned char camellia_test_cbc_key[3][32] = +{ + { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, + 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } + , + { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, + 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, + 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B } + , + { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, + 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, + 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, + 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } +}; + +static const unsigned char camellia_test_cbc_iv[16] = + + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F } +; + +static const unsigned char camellia_test_cbc_plain[CAMELLIA_TESTS_CBC][16] = +{ + { 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, + 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A }, + { 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, + 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51 }, + { 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, + 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF } + +}; + +static const unsigned char camellia_test_cbc_cipher[3][CAMELLIA_TESTS_CBC][16] = +{ + { + { 0x16, 0x07, 0xCF, 0x49, 0x4B, 0x36, 0xBB, 0xF0, + 0x0D, 0xAE, 0xB0, 0xB5, 0x03, 0xC8, 0x31, 0xAB }, + { 0xA2, 0xF2, 0xCF, 0x67, 0x16, 0x29, 0xEF, 0x78, + 0x40, 0xC5, 0xA5, 0xDF, 0xB5, 0x07, 0x48, 0x87 }, + { 0x0F, 0x06, 0x16, 0x50, 0x08, 0xCF, 0x8B, 0x8B, + 0x5A, 0x63, 0x58, 0x63, 0x62, 0x54, 0x3E, 0x54 } + }, + { + { 0x2A, 0x48, 0x30, 0xAB, 0x5A, 0xC4, 0xA1, 0xA2, + 0x40, 0x59, 0x55, 0xFD, 0x21, 0x95, 0xCF, 0x93 }, + { 0x5D, 0x5A, 0x86, 0x9B, 0xD1, 0x4C, 0xE5, 0x42, + 0x64, 0xF8, 0x92, 0xA6, 0xDD, 0x2E, 0xC3, 0xD5 }, + { 0x37, 0xD3, 0x59, 0xC3, 0x34, 0x98, 0x36, 0xD8, + 0x84, 0xE3, 0x10, 0xAD, 0xDF, 0x68, 0xC4, 0x49 } + }, + { + { 0xE6, 0xCF, 0xA3, 0x5F, 0xC0, 0x2B, 0x13, 0x4A, + 0x4D, 0x2C, 0x0B, 0x67, 0x37, 0xAC, 0x3E, 0xDA }, + { 0x36, 0xCB, 0xEB, 0x73, 0xBD, 0x50, 0x4B, 0x40, + 0x70, 0xB1, 0xB7, 0xDE, 0x2B, 0x21, 0xEB, 0x50 }, + { 0xE3, 0x1A, 0x60, 0x55, 0x29, 0x7D, 0x96, 0xCA, + 0x33, 0x30, 0xCD, 0xF1, 0xB1, 0x86, 0x0A, 0x83 } + } +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * Camellia-CTR test vectors from: + * + * http://www.faqs.org/rfcs/rfc5528.html + */ + +static const unsigned char camellia_test_ctr_key[3][16] = +{ + { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, + 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E }, + { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, + 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63 }, + { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, + 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC } +}; + +static const unsigned char camellia_test_ctr_nonce_counter[3][16] = +{ + { 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, + { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, + 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, + { 0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, + 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01 } +}; + +static const unsigned char camellia_test_ctr_pt[3][48] = +{ + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 } +}; + +static const unsigned char camellia_test_ctr_ct[3][48] = +{ + { 0xD0, 0x9D, 0xC2, 0x9A, 0x82, 0x14, 0x61, 0x9A, + 0x20, 0x87, 0x7C, 0x76, 0xDB, 0x1F, 0x0B, 0x3F }, + { 0xDB, 0xF3, 0xC7, 0x8D, 0xC0, 0x83, 0x96, 0xD4, + 0xDA, 0x7C, 0x90, 0x77, 0x65, 0xBB, 0xCB, 0x44, + 0x2B, 0x8E, 0x8E, 0x0F, 0x31, 0xF0, 0xDC, 0xA7, + 0x2C, 0x74, 0x17, 0xE3, 0x53, 0x60, 0xE0, 0x48 }, + { 0xB1, 0x9D, 0x1F, 0xCD, 0xCB, 0x75, 0xEB, 0x88, + 0x2F, 0x84, 0x9C, 0xE2, 0x4D, 0x85, 0xCF, 0x73, + 0x9C, 0xE6, 0x4B, 0x2B, 0x5C, 0x9D, 0x73, 0xF1, + 0x4F, 0x2D, 0x5D, 0x9D, 0xCE, 0x98, 0x89, 0xCD, + 0xDF, 0x50, 0x86, 0x96 } +}; + +static const int camellia_test_ctr_len[3] = + { 16, 32, 36 }; +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +/* + * Checkup routine + */ +int mbedtls_camellia_self_test( int verbose ) +{ + int i, j, u, v; + unsigned char key[32]; + unsigned char buf[64]; + unsigned char src[16]; + unsigned char dst[16]; +#if defined(MBEDTLS_CIPHER_MODE_CBC) + unsigned char iv[16]; +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + size_t offset, len; + unsigned char nonce_counter[16]; + unsigned char stream_block[16]; +#endif + + mbedtls_camellia_context ctx; + + memset( key, 0, 32 ); + + for( j = 0; j < 6; j++ ) { + u = j >> 1; + v = j & 1; + + if( verbose != 0 ) + mbedtls_printf( " CAMELLIA-ECB-%3d (%s): ", 128 + u * 64, + (v == MBEDTLS_CAMELLIA_DECRYPT) ? "dec" : "enc"); + + for( i = 0; i < CAMELLIA_TESTS_ECB; i++ ) { + memcpy( key, camellia_test_ecb_key[u][i], 16 + 8 * u ); + + if( v == MBEDTLS_CAMELLIA_DECRYPT ) { + mbedtls_camellia_setkey_dec( &ctx, key, 128 + u * 64 ); + memcpy( src, camellia_test_ecb_cipher[u][i], 16 ); + memcpy( dst, camellia_test_ecb_plain[i], 16 ); + } else { /* MBEDTLS_CAMELLIA_ENCRYPT */ + mbedtls_camellia_setkey_enc( &ctx, key, 128 + u * 64 ); + memcpy( src, camellia_test_ecb_plain[i], 16 ); + memcpy( dst, camellia_test_ecb_cipher[u][i], 16 ); + } + + mbedtls_camellia_crypt_ecb( &ctx, v, src, buf ); + + if( memcmp( buf, dst, 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + /* + * CBC mode + */ + for( j = 0; j < 6; j++ ) + { + u = j >> 1; + v = j & 1; + + if( verbose != 0 ) + mbedtls_printf( " CAMELLIA-CBC-%3d (%s): ", 128 + u * 64, + ( v == MBEDTLS_CAMELLIA_DECRYPT ) ? "dec" : "enc" ); + + memcpy( src, camellia_test_cbc_iv, 16 ); + memcpy( dst, camellia_test_cbc_iv, 16 ); + memcpy( key, camellia_test_cbc_key[u], 16 + 8 * u ); + + if( v == MBEDTLS_CAMELLIA_DECRYPT ) { + mbedtls_camellia_setkey_dec( &ctx, key, 128 + u * 64 ); + } else { + mbedtls_camellia_setkey_enc( &ctx, key, 128 + u * 64 ); + } + + for( i = 0; i < CAMELLIA_TESTS_CBC; i++ ) { + + if( v == MBEDTLS_CAMELLIA_DECRYPT ) { + memcpy( iv , src, 16 ); + memcpy( src, camellia_test_cbc_cipher[u][i], 16 ); + memcpy( dst, camellia_test_cbc_plain[i], 16 ); + } else { /* MBEDTLS_CAMELLIA_ENCRYPT */ + memcpy( iv , dst, 16 ); + memcpy( src, camellia_test_cbc_plain[i], 16 ); + memcpy( dst, camellia_test_cbc_cipher[u][i], 16 ); + } + + mbedtls_camellia_crypt_cbc( &ctx, v, 16, iv, src, buf ); + + if( memcmp( buf, dst, 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + /* + * CTR mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " CAMELLIA-CTR-128 (%s): ", + ( v == MBEDTLS_CAMELLIA_DECRYPT ) ? "dec" : "enc" ); + + memcpy( nonce_counter, camellia_test_ctr_nonce_counter[u], 16 ); + memcpy( key, camellia_test_ctr_key[u], 16 ); + + offset = 0; + mbedtls_camellia_setkey_enc( &ctx, key, 128 ); + + if( v == MBEDTLS_CAMELLIA_DECRYPT ) + { + len = camellia_test_ctr_len[u]; + memcpy( buf, camellia_test_ctr_ct[u], len ); + + mbedtls_camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); + + if( memcmp( buf, camellia_test_ctr_pt[u], len ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + else + { + len = camellia_test_ctr_len[u]; + memcpy( buf, camellia_test_ctr_pt[u], len ); + + mbedtls_camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); + + if( memcmp( buf, camellia_test_ctr_ct[u], len ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_CAMELLIA_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ccm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ccm.c new file mode 100644 index 0000000..13a8fd1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ccm.c @@ -0,0 +1,464 @@ +/* + * NIST SP800-38C compliant CCM implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * Definition of CCM: + * http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf + * RFC 3610 "Counter with CBC-MAC (CCM)" + * + * Related: + * RFC 5116 "An Interface and Algorithms for Authenticated Encryption" + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CCM_C) + +#include "mbedtls/ccm.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +#define CCM_ENCRYPT 0 +#define CCM_DECRYPT 1 + +/* + * Initialize context + */ +void mbedtls_ccm_init( mbedtls_ccm_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_ccm_context ) ); +} + +int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, + mbedtls_cipher_id_t cipher, + const unsigned char *key, + unsigned int keybits ) +{ + int ret; + const mbedtls_cipher_info_t *cipher_info; + + cipher_info = mbedtls_cipher_info_from_values( cipher, keybits, MBEDTLS_MODE_ECB ); + if( cipher_info == NULL ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + if( cipher_info->block_size != 16 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + mbedtls_cipher_free( &ctx->cipher_ctx ); + + if( ( ret = mbedtls_cipher_setup( &ctx->cipher_ctx, cipher_info ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_cipher_setkey( &ctx->cipher_ctx, key, keybits, + MBEDTLS_ENCRYPT ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} + +/* + * Free context + */ +void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) +{ + mbedtls_cipher_free( &ctx->cipher_ctx ); + mbedtls_zeroize( ctx, sizeof( mbedtls_ccm_context ) ); +} + +/* + * Macros for common operations. + * Results in smaller compiled code than static inline functions. + */ + +/* + * Update the CBC-MAC state in y using a block in b + * (Always using b as the source helps the compiler optimise a bit better.) + */ +#define UPDATE_CBC_MAC \ + for( i = 0; i < 16; i++ ) \ + y[i] ^= b[i]; \ + \ + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, y, 16, y, &olen ) ) != 0 ) \ + return( ret ); + +/* + * Encrypt or decrypt a partial block with CTR + * Warning: using b for temporary storage! src and dst must not be b! + * This avoids allocating one more 16 bytes buffer while allowing src == dst. + */ +#define CTR_CRYPT( dst, src, len ) \ + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctr, 16, b, &olen ) ) != 0 ) \ + return( ret ); \ + \ + for( i = 0; i < len; i++ ) \ + dst[i] = src[i] ^ b[i]; + +/* + * Authenticated encryption or decryption + */ +static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + unsigned char *tag, size_t tag_len ) +{ + int ret; + unsigned char i; + unsigned char q; + size_t len_left, olen; + unsigned char b[16]; + unsigned char y[16]; + unsigned char ctr[16]; + const unsigned char *src; + unsigned char *dst; + + /* + * Check length requirements: SP800-38C A.1 + * Additional requirement: a < 2^16 - 2^8 to simplify the code. + * 'length' checked later (when writing it to the first block) + */ + if( tag_len < 4 || tag_len > 16 || tag_len % 2 != 0 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + /* Also implies q is within bounds */ + if( iv_len < 7 || iv_len > 13 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + if( add_len > 0xFF00 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + q = 16 - 1 - (unsigned char) iv_len; + + /* + * First block B_0: + * 0 .. 0 flags + * 1 .. iv_len nonce (aka iv) + * iv_len+1 .. 15 length + * + * With flags as (bits): + * 7 0 + * 6 add present? + * 5 .. 3 (t - 2) / 2 + * 2 .. 0 q - 1 + */ + b[0] = 0; + b[0] |= ( add_len > 0 ) << 6; + b[0] |= ( ( tag_len - 2 ) / 2 ) << 3; + b[0] |= q - 1; + + memcpy( b + 1, iv, iv_len ); + + for( i = 0, len_left = length; i < q; i++, len_left >>= 8 ) + b[15-i] = (unsigned char)( len_left & 0xFF ); + + if( len_left > 0 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + + /* Start CBC-MAC with first block */ + memset( y, 0, 16 ); + UPDATE_CBC_MAC; + + /* + * If there is additional data, update CBC-MAC with + * add_len, add, 0 (padding to a block boundary) + */ + if( add_len > 0 ) + { + size_t use_len; + len_left = add_len; + src = add; + + memset( b, 0, 16 ); + b[0] = (unsigned char)( ( add_len >> 8 ) & 0xFF ); + b[1] = (unsigned char)( ( add_len ) & 0xFF ); + + use_len = len_left < 16 - 2 ? len_left : 16 - 2; + memcpy( b + 2, src, use_len ); + len_left -= use_len; + src += use_len; + + UPDATE_CBC_MAC; + + while( len_left > 0 ) + { + use_len = len_left > 16 ? 16 : len_left; + + memset( b, 0, 16 ); + memcpy( b, src, use_len ); + UPDATE_CBC_MAC; + + len_left -= use_len; + src += use_len; + } + } + + /* + * Prepare counter block for encryption: + * 0 .. 0 flags + * 1 .. iv_len nonce (aka iv) + * iv_len+1 .. 15 counter (initially 1) + * + * With flags as (bits): + * 7 .. 3 0 + * 2 .. 0 q - 1 + */ + ctr[0] = q - 1; + memcpy( ctr + 1, iv, iv_len ); + memset( ctr + 1 + iv_len, 0, q ); + ctr[15] = 1; + + /* + * Authenticate and {en,de}crypt the message. + * + * The only difference between encryption and decryption is + * the respective order of authentication and {en,de}cryption. + */ + len_left = length; + src = input; + dst = output; + + while( len_left > 0 ) + { + size_t use_len = len_left > 16 ? 16 : len_left; + + if( mode == CCM_ENCRYPT ) + { + memset( b, 0, 16 ); + memcpy( b, src, use_len ); + UPDATE_CBC_MAC; + } + + CTR_CRYPT( dst, src, use_len ); + + if( mode == CCM_DECRYPT ) + { + memset( b, 0, 16 ); + memcpy( b, dst, use_len ); + UPDATE_CBC_MAC; + } + + dst += use_len; + src += use_len; + len_left -= use_len; + + /* + * Increment counter. + * No need to check for overflow thanks to the length check above. + */ + for( i = 0; i < q; i++ ) + if( ++ctr[15-i] != 0 ) + break; + } + + /* + * Authentication: reset counter and crypt/mask internal tag + */ + for( i = 0; i < q; i++ ) + ctr[15-i] = 0; + + CTR_CRYPT( y, y, 16 ); + memcpy( tag, y, tag_len ); + + return( 0 ); +} + +/* + * Authenticated encryption + */ +int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + unsigned char *tag, size_t tag_len ) +{ + return( ccm_auth_crypt( ctx, CCM_ENCRYPT, length, iv, iv_len, + add, add_len, input, output, tag, tag_len ) ); +} + +/* + * Authenticated decryption + */ +int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + const unsigned char *tag, size_t tag_len ) +{ + int ret; + unsigned char check_tag[16]; + unsigned char i; + int diff; + + if( ( ret = ccm_auth_crypt( ctx, CCM_DECRYPT, length, + iv, iv_len, add, add_len, + input, output, check_tag, tag_len ) ) != 0 ) + { + return( ret ); + } + + /* Check tag in "constant-time" */ + for( diff = 0, i = 0; i < tag_len; i++ ) + diff |= tag[i] ^ check_tag[i]; + + if( diff != 0 ) + { + mbedtls_zeroize( output, length ); + return( MBEDTLS_ERR_CCM_AUTH_FAILED ); + } + + return( 0 ); +} + + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +/* + * Examples 1 to 3 from SP800-38C Appendix C + */ + +#define NB_TESTS 3 + +/* + * The data is the same for all tests, only the used length changes + */ +static const unsigned char key[] = { + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f +}; + +static const unsigned char iv[] = { + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b +}; + +static const unsigned char ad[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13 +}; + +static const unsigned char msg[] = { + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, +}; + +static const size_t iv_len [NB_TESTS] = { 7, 8, 12 }; +static const size_t add_len[NB_TESTS] = { 8, 16, 20 }; +static const size_t msg_len[NB_TESTS] = { 4, 16, 24 }; +static const size_t tag_len[NB_TESTS] = { 4, 6, 8 }; + +static const unsigned char res[NB_TESTS][32] = { + { 0x71, 0x62, 0x01, 0x5b, 0x4d, 0xac, 0x25, 0x5d }, + { 0xd2, 0xa1, 0xf0, 0xe0, 0x51, 0xea, 0x5f, 0x62, + 0x08, 0x1a, 0x77, 0x92, 0x07, 0x3d, 0x59, 0x3d, + 0x1f, 0xc6, 0x4f, 0xbf, 0xac, 0xcd }, + { 0xe3, 0xb2, 0x01, 0xa9, 0xf5, 0xb7, 0x1a, 0x7a, + 0x9b, 0x1c, 0xea, 0xec, 0xcd, 0x97, 0xe7, 0x0b, + 0x61, 0x76, 0xaa, 0xd9, 0xa4, 0x42, 0x8a, 0xa5, + 0x48, 0x43, 0x92, 0xfb, 0xc1, 0xb0, 0x99, 0x51 } +}; + +int mbedtls_ccm_self_test( int verbose ) +{ + mbedtls_ccm_context ctx; + unsigned char out[32]; + size_t i; + int ret; + + mbedtls_ccm_init( &ctx ); + + if( mbedtls_ccm_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, key, 8 * sizeof key ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( " CCM: setup failed" ); + + return( 1 ); + } + + for( i = 0; i < NB_TESTS; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " CCM-AES #%u: ", (unsigned int) i + 1 ); + + ret = mbedtls_ccm_encrypt_and_tag( &ctx, msg_len[i], + iv, iv_len[i], ad, add_len[i], + msg, out, + out + msg_len[i], tag_len[i] ); + + if( ret != 0 || + memcmp( out, res[i], msg_len[i] + tag_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + ret = mbedtls_ccm_auth_decrypt( &ctx, msg_len[i], + iv, iv_len[i], ad, add_len[i], + res[i], out, + res[i] + msg_len[i], tag_len[i] ); + + if( ret != 0 || + memcmp( out, msg, msg_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + mbedtls_ccm_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +#endif /* MBEDTLS_CCM_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/certs.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/certs.c new file mode 100644 index 0000000..ffe6bc9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/certs.c @@ -0,0 +1,351 @@ +/* + * X.509 test certificates + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "mbedtls/certs.h" + +#if defined(MBEDTLS_CERTS_C) + +#if defined(MBEDTLS_ECDSA_C) +#define TEST_CA_CRT_EC \ +"-----BEGIN CERTIFICATE-----\r\n" \ +"MIICUjCCAdegAwIBAgIJAMFD4n5iQ8zoMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYT\r\n" \ +"Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \ +"QyBDQTAeFw0xMzA5MjQxNTQ5NDhaFw0yMzA5MjIxNTQ5NDhaMD4xCzAJBgNVBAYT\r\n" \ +"Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \ +"QyBDQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABMPaKzRBN1gvh1b+/Im6KUNLTuBu\r\n" \ +"ww5XUzM5WNRStJGVOQsj318XJGJI/BqVKc4sLYfCiFKAr9ZqqyHduNMcbli4yuiy\r\n" \ +"aY7zQa0pw7RfdadHb9UZKVVpmlM7ILRmFmAzHqOBoDCBnTAdBgNVHQ4EFgQUnW0g\r\n" \ +"JEkBPyvLeLUZvH4kydv7NnwwbgYDVR0jBGcwZYAUnW0gJEkBPyvLeLUZvH4kydv7\r\n" \ +"NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UE\r\n" \ +"AxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAwGA1UdEwQFMAMBAf8w\r\n" \ +"CgYIKoZIzj0EAwIDaQAwZgIxAMO0YnNWKJUAfXgSJtJxexn4ipg+kv4znuR50v56\r\n" \ +"t4d0PCu412mUC6Nnd7izvtE2MgIxAP1nnJQjZ8BWukszFQDG48wxCCyci9qpdSMv\r\n" \ +"uCjn8pwUOkABXK8Mss90fzCfCEOtIA==\r\n" \ +"-----END CERTIFICATE-----\r\n" +const char mbedtls_test_ca_crt_ec[] = TEST_CA_CRT_EC; + +const char mbedtls_test_ca_key_ec[] = +"-----BEGIN EC PRIVATE KEY-----\r\n" +"Proc-Type: 4,ENCRYPTED\r\n" +"DEK-Info: DES-EDE3-CBC,307EAB469933D64E\r\n" +"\r\n" +"IxbrRmKcAzctJqPdTQLA4SWyBYYGYJVkYEna+F7Pa5t5Yg/gKADrFKcm6B72e7DG\r\n" +"ihExtZI648s0zdYw6qSJ74vrPSuWDe5qm93BqsfVH9svtCzWHW0pm1p0KTBCFfUq\r\n" +"UsuWTITwJImcnlAs1gaRZ3sAWm7cOUidL0fo2G0fYUFNcYoCSLffCFTEHBuPnagb\r\n" +"a77x/sY1Bvii8S9/XhDTb6pTMx06wzrm\r\n" +"-----END EC PRIVATE KEY-----\r\n"; + +const char mbedtls_test_ca_pwd_ec[] = "PolarSSLTest"; + +const char mbedtls_test_srv_crt_ec[] = +"-----BEGIN CERTIFICATE-----\r\n" +"MIICHzCCAaWgAwIBAgIBCTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G\r\n" +"A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN\r\n" +"MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" +"A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEG\r\n" +"CCqGSM49AwEHA0IABDfMVtl2CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA\r\n" +"2CMR/+ov0jRdXRa9iojCa3cNVc2KKg76Aci07f+jgZ0wgZowCQYDVR0TBAIwADAd\r\n" +"BgNVHQ4EFgQUUGGlj9QH2deCAQzlZX+MY0anE74wbgYDVR0jBGcwZYAUnW0gJEkB\r\n" +"PyvLeLUZvH4kydv7NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xh\r\n" +"clNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAoG\r\n" +"CCqGSM49BAMCA2gAMGUCMQCaLFzXptui5WQN8LlO3ddh1hMxx6tzgLvT03MTVK2S\r\n" +"C12r0Lz3ri/moSEpNZWqPjkCMCE2f53GXcYLqyfyJR078c/xNSUU5+Xxl7VZ414V\r\n" +"fGa5kHvHARBPc8YAIVIqDvHH1Q==\r\n" +"-----END CERTIFICATE-----\r\n"; + +const char mbedtls_test_srv_key_ec[] = +"-----BEGIN EC PRIVATE KEY-----\r\n" +"MHcCAQEEIPEqEyB2AnCoPL/9U/YDHvdqXYbIogTywwyp6/UfDw6noAoGCCqGSM49\r\n" +"AwEHoUQDQgAEN8xW2XYJHlpyPsdZLf8gbu58+QaRdNCtFLX3aCJZYpJO5QDYIxH/\r\n" +"6i/SNF1dFr2KiMJrdw1VzYoqDvoByLTt/w==\r\n" +"-----END EC PRIVATE KEY-----\r\n"; + +const char mbedtls_test_cli_crt_ec[] = +"-----BEGIN CERTIFICATE-----\r\n" +"MIICLDCCAbKgAwIBAgIBDTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G\r\n" +"A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN\r\n" +"MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjBBMQswCQYDVQQGEwJOTDERMA8G\r\n" +"A1UEChMIUG9sYXJTU0wxHzAdBgNVBAMTFlBvbGFyU1NMIFRlc3QgQ2xpZW50IDIw\r\n" +"WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARX5a6xc9/TrLuTuIH/Eq7u5lOszlVT\r\n" +"9jQOzC7jYyUL35ji81xgNpbA1RgUcOV/n9VLRRjlsGzVXPiWj4dwo+THo4GdMIGa\r\n" +"MAkGA1UdEwQCMAAwHQYDVR0OBBYEFHoAX4Zk/OBd5REQO7LmO8QmP8/iMG4GA1Ud\r\n" +"IwRnMGWAFJ1tICRJAT8ry3i1Gbx+JMnb+zZ8oUKkQDA+MQswCQYDVQQGEwJOTDER\r\n" +"MA8GA1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0GC\r\n" +"CQDBQ+J+YkPM6DAKBggqhkjOPQQDAgNoADBlAjBKZQ17IIOimbmoD/yN7o89u3BM\r\n" +"lgOsjnhw3fIOoLIWy2WOGsk/LGF++DzvrRzuNiACMQCd8iem1XS4JK7haj8xocpU\r\n" +"LwjQje5PDGHfd3h9tP38Qknu5bJqws0md2KOKHyeV0U=\r\n" +"-----END CERTIFICATE-----\r\n"; + +const char mbedtls_test_cli_key_ec[] = +"-----BEGIN EC PRIVATE KEY-----\r\n" +"MHcCAQEEIPb3hmTxZ3/mZI3vyk7p3U3wBf+WIop6hDhkFzJhmLcqoAoGCCqGSM49\r\n" +"AwEHoUQDQgAEV+WusXPf06y7k7iB/xKu7uZTrM5VU/Y0Dswu42MlC9+Y4vNcYDaW\r\n" +"wNUYFHDlf5/VS0UY5bBs1Vz4lo+HcKPkxw==\r\n" +"-----END EC PRIVATE KEY-----\r\n"; + +const size_t mbedtls_test_ca_crt_ec_len = sizeof( mbedtls_test_ca_crt_ec ); +const size_t mbedtls_test_ca_key_ec_len = sizeof( mbedtls_test_ca_key_ec ); +const size_t mbedtls_test_ca_pwd_ec_len = sizeof( mbedtls_test_ca_pwd_ec ) - 1; +const size_t mbedtls_test_srv_crt_ec_len = sizeof( mbedtls_test_srv_crt_ec ); +const size_t mbedtls_test_srv_key_ec_len = sizeof( mbedtls_test_srv_key_ec ); +const size_t mbedtls_test_cli_crt_ec_len = sizeof( mbedtls_test_cli_crt_ec ); +const size_t mbedtls_test_cli_key_ec_len = sizeof( mbedtls_test_cli_key_ec ); +#else +#define TEST_CA_CRT_EC +#endif /* MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_RSA_C) +#define TEST_CA_CRT_RSA \ +"-----BEGIN CERTIFICATE-----\r\n" \ +"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" \ +"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ +"MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \ +"A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \ +"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \ +"mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \ +"50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" \ +"YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" \ +"R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" \ +"KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" \ +"gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH\r\n" \ +"/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV\r\n" \ +"BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz\r\n" \ +"dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ\r\n" \ +"SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H\r\n" \ +"DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF\r\n" \ +"pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf\r\n" \ +"m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n" \ +"7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n" \ +"-----END CERTIFICATE-----\r\n" +const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA; + +const char mbedtls_test_ca_key_rsa[] = +"-----BEGIN RSA PRIVATE KEY-----\r\n" +"Proc-Type: 4,ENCRYPTED\r\n" +"DEK-Info: DES-EDE3-CBC,A8A95B05D5B7206B\r\n" +"\r\n" +"9Qd9GeArejl1GDVh2lLV1bHt0cPtfbh5h/5zVpAVaFpqtSPMrElp50Rntn9et+JA\r\n" +"7VOyboR+Iy2t/HU4WvA687k3Bppe9GwKHjHhtl//8xFKwZr3Xb5yO5JUP8AUctQq\r\n" +"Nb8CLlZyuUC+52REAAthdWgsX+7dJO4yabzUcQ22Tp9JSD0hiL43BlkWYUNK3dAo\r\n" +"PZlmiptjnzVTjg1MxsBSydZinWOLBV8/JQgxSPo2yD4uEfig28qbvQ2wNIn0pnAb\r\n" +"GxnSAOazkongEGfvcjIIs+LZN9gXFhxcOh6kc4Q/c99B7QWETwLLkYgZ+z1a9VY9\r\n" +"gEU7CwCxYCD+h9hY6FPmsK0/lC4O7aeRKpYq00rPPxs6i7phiexg6ax6yTMmArQq\r\n" +"QmK3TAsJm8V/J5AWpLEV6jAFgRGymGGHnof0DXzVWZidrcZJWTNuGEX90nB3ee2w\r\n" +"PXJEFWKoD3K3aFcSLdHYr3mLGxP7H9ThQai9VsycxZKS5kwvBKQ//YMrmFfwPk8x\r\n" +"vTeY4KZMaUrveEel5tWZC94RSMKgxR6cyE1nBXyTQnDOGbfpNNgBKxyKbINWoOJU\r\n" +"WJZAwlsQn+QzCDwpri7+sV1mS3gBE6UY7aQmnmiiaC2V3Hbphxct/en5QsfDOt1X\r\n" +"JczSfpRWLlbPznZg8OQh/VgCMA58N5DjOzTIK7sJJ5r+94ZBTCpgAMbF588f0NTR\r\n" +"KCe4yrxGJR7X02M4nvD4IwOlpsQ8xQxZtOSgXv4LkxvdU9XJJKWZ/XNKJeWztxSe\r\n" +"Z1vdTc2YfsDBA2SEv33vxHx2g1vqtw8SjDRT2RaQSS0QuSaMJimdOX6mTOCBKk1J\r\n" +"9Q5mXTrER+/LnK0jEmXsBXWA5bqqVZIyahXSx4VYZ7l7w/PHiUDtDgyRhMMKi4n2\r\n" +"iQvQcWSQTjrpnlJbca1/DkpRt3YwrvJwdqb8asZU2VrNETh5x0QVefDRLFiVpif/\r\n" +"tUaeAe/P1F8OkS7OIZDs1SUbv/sD2vMbhNkUoCms3/PvNtdnvgL4F0zhaDpKCmlT\r\n" +"P8vx49E7v5CyRNmED9zZg4o3wmMqrQO93PtTug3Eu9oVx1zPQM1NVMyBa2+f29DL\r\n" +"1nuTCeXdo9+ni45xx+jAI4DCwrRdhJ9uzZyC6962H37H6D+5naNvClFR1s6li1Gb\r\n" +"nqPoiy/OBsEx9CaDGcqQBp5Wme/3XW+6z1ISOx+igwNTVCT14mHdBMbya0eIKft5\r\n" +"X+GnwtgEMyCYyyWuUct8g4RzErcY9+yW9Om5Hzpx4zOuW4NPZgPDTgK+t2RSL/Yq\r\n" +"rE1njrgeGYcVeG3f+OftH4s6fPbq7t1A5ZgUscbLMBqr9tK+OqygR4EgKBPsH6Cz\r\n" +"L6zlv/2RV0qAHvVuDJcIDIgwY5rJtINEm32rhOeFNJwZS5MNIC1czXZx5//ugX7l\r\n" +"I4sy5nbVhwSjtAk8Xg5dZbdTZ6mIrb7xqH+fdakZor1khG7bC2uIwibD3cSl2XkR\r\n" +"wN48lslbHnqqagr6Xm1nNOSVl8C/6kbJEsMpLhAezfRtGwvOucoaE+WbeUNolGde\r\n" +"P/eQiddSf0brnpiLJRh7qZrl9XuqYdpUqnoEdMAfotDOID8OtV7gt8a48ad8VPW2\r\n" +"-----END RSA PRIVATE KEY-----\r\n"; + +const char mbedtls_test_ca_pwd_rsa[] = "PolarSSLTest"; + +const char mbedtls_test_srv_crt_rsa[] = +"-----BEGIN CERTIFICATE-----\r\n" +"MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" +"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" +"MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" +"A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN\r\n" +"AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN\r\n" +"owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz\r\n" +"NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM\r\n" +"tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P\r\n" +"hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya\r\n" +"HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD\r\n" +"VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw\r\n" +"FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQADggEBAJxnXClY\r\n" +"oHkbp70cqBrsGXLybA74czbO5RdLEgFs7rHVS9r+c293luS/KdliLScZqAzYVylw\r\n" +"UfRWvKMoWhHYKp3dEIS4xTXk6/5zXxhv9Rw8SGc8qn6vITHk1S1mPevtekgasY5Y\r\n" +"iWQuM3h4YVlRH3HHEMAD1TnAexfXHHDFQGe+Bd1iAbz1/sH9H8l4StwX6egvTK3M\r\n" +"wXRwkKkvjKaEDA9ATbZx0mI8LGsxSuCqe9r9dyjmttd47J1p1Rulz3CLzaRcVIuS\r\n" +"RRQfaD8neM9c1S/iJ/amTVqJxA1KOdOS5780WhPfSArA+g4qAmSjelc3p4wWpha8\r\n" +"zhuYwjVuX6JHG0c=\r\n" +"-----END CERTIFICATE-----\r\n"; + +const char mbedtls_test_srv_key_rsa[] = +"-----BEGIN RSA PRIVATE KEY-----\r\n" +"MIIEpAIBAAKCAQEAwU2j3efNHdEE10lyuJmsDnjkOjxKzzoTFtBa5M2jAIin7h5r\r\n" +"lqdStJDvLXJ6PiSa/LY0rCT1d+AmZIycsCh9odrqjObJHJa8/sEEUrM21KP64bF2\r\n" +"2JDBYbRmUjaiJlOqq3ReB30Zgtsq2B+g2Q0cLUlm91slc0boC4pPaQy1AJDh2oIQ\r\n" +"Zn2uVCuLZXmRoeJhw81ASQjuaAzxi4bSRr/QuKoRAx5/VqgaHkQYDw+Fi9qLRF7i\r\n" +"GMZiL8dmjfpd2H3zJ4kpAcWQDj8n8TDISg7v1t7HxydrxwU9esQCPJodPg/oNJhb\r\n" +"y3NLUpbYEaIsgIhpOVrTD7DeWS8Rx/fqEgEwlwIDAQABAoIBAQCXR0S8EIHFGORZ\r\n" +"++AtOg6eENxD+xVs0f1IeGz57Tjo3QnXX7VBZNdj+p1ECvhCE/G7XnkgU5hLZX+G\r\n" +"Z0jkz/tqJOI0vRSdLBbipHnWouyBQ4e/A1yIJdlBtqXxJ1KE/ituHRbNc4j4kL8Z\r\n" +"/r6pvwnTI0PSx2Eqs048YdS92LT6qAv4flbNDxMn2uY7s4ycS4Q8w1JXnCeaAnYm\r\n" +"WYI5wxO+bvRELR2Mcz5DmVnL8jRyml6l6582bSv5oufReFIbyPZbQWlXgYnpu6He\r\n" +"GTc7E1zKYQGG/9+DQUl/1vQuCPqQwny0tQoX2w5tdYpdMdVm+zkLtbajzdTviJJa\r\n" +"TWzL6lt5AoGBAN86+SVeJDcmQJcv4Eq6UhtRr4QGMiQMz0Sod6ettYxYzMgxtw28\r\n" +"CIrgpozCc+UaZJLo7UxvC6an85r1b2nKPCLQFaggJ0H4Q0J/sZOhBIXaoBzWxveK\r\n" +"nupceKdVxGsFi8CDy86DBfiyFivfBj+47BbaQzPBj7C4rK7UlLjab2rDAoGBAN2u\r\n" +"AM2gchoFiu4v1HFL8D7lweEpi6ZnMJjnEu/dEgGQJFjwdpLnPbsj4c75odQ4Gz8g\r\n" +"sw9lao9VVzbusoRE/JGI4aTdO0pATXyG7eG1Qu+5Yc1YGXcCrliA2xM9xx+d7f+s\r\n" +"mPzN+WIEg5GJDYZDjAzHG5BNvi/FfM1C9dOtjv2dAoGAF0t5KmwbjWHBhcVqO4Ic\r\n" +"BVvN3BIlc1ue2YRXEDlxY5b0r8N4XceMgKmW18OHApZxfl8uPDauWZLXOgl4uepv\r\n" +"whZC3EuWrSyyICNhLY21Ah7hbIEBPF3L3ZsOwC+UErL+dXWLdB56Jgy3gZaBeW7b\r\n" +"vDrEnocJbqCm7IukhXHOBK8CgYEAwqdHB0hqyNSzIOGY7v9abzB6pUdA3BZiQvEs\r\n" +"3LjHVd4HPJ2x0N8CgrBIWOE0q8+0hSMmeE96WW/7jD3fPWwCR5zlXknxBQsfv0gP\r\n" +"3BC5PR0Qdypz+d+9zfMf625kyit4T/hzwhDveZUzHnk1Cf+IG7Q+TOEnLnWAWBED\r\n" +"ISOWmrUCgYAFEmRxgwAc/u+D6t0syCwAYh6POtscq9Y0i9GyWk89NzgC4NdwwbBH\r\n" +"4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n" +"TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n" +"-----END RSA PRIVATE KEY-----\r\n"; + +const char mbedtls_test_cli_crt_rsa[] = +"-----BEGIN CERTIFICATE-----\r\n" +"MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" +"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" +"MTEwMjEyMTQ0NDA3WhcNMjEwMjEyMTQ0NDA3WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n" +"A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN\r\n" +"BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f\r\n" +"M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu\r\n" +"1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw\r\n" +"MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v\r\n" +"4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/\r\n" +"/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB\r\n" +"o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf\r\n" +"BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQUFAAOC\r\n" +"AQEAAn86isAM8X+mVwJqeItt6E9slhEQbAofyk+diH1Lh8Y9iLlWQSKbw/UXYjx5\r\n" +"LLPZcniovxIcARC/BjyZR9g3UwTHNGNm+rwrqa15viuNOFBchykX/Orsk02EH7NR\r\n" +"Alw5WLPorYjED6cdVQgBl9ot93HdJogRiXCxErM7NC8/eP511mjq+uLDjLKH8ZPQ\r\n" +"8I4ekHJnroLsDkIwXKGIsvIBHQy2ac/NwHLCQOK6mfum1pRx52V4Utu5dLLjD5bM\r\n" +"xOBC7KU4xZKuMXXZM6/93Yb51K/J4ahf1TxJlTWXtnzDr9saEYdNy2SKY/6ZiDNH\r\n" +"D+stpAKiQLAWaAusIWKYEyw9MQ==\r\n" +"-----END CERTIFICATE-----\r\n"; + +const char mbedtls_test_cli_key_rsa[] = +"-----BEGIN RSA PRIVATE KEY-----\r\n" +"MIIEpAIBAAKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6fM60Nj4o8VmXl3ETZzGaF\r\n" +"B9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu1C93KYRhTYJQj6eVSHD1\r\n" +"bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEwMjDV0/YI0FZPRo7yX/k9\r\n" +"Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v4Jv4EFbMs44TFeY0BGbH\r\n" +"7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx//DZrtenNLQNiTrM9AM+v\r\n" +"dqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQABAoIBAGdNtfYDiap6bzst\r\n" +"yhCiI8m9TtrhZw4MisaEaN/ll3XSjaOG2dvV6xMZCMV+5TeXDHOAZnY18Yi18vzz\r\n" +"4Ut2TnNFzizCECYNaA2fST3WgInnxUkV3YXAyP6CNxJaCmv2aA0yFr2kFVSeaKGt\r\n" +"ymvljNp2NVkvm7Th8fBQBO7I7AXhz43k0mR7XmPgewe8ApZOG3hstkOaMvbWAvWA\r\n" +"zCZupdDjZYjOJqlA4eEA4H8/w7F83r5CugeBE8LgEREjLPiyejrU5H1fubEY+h0d\r\n" +"l5HZBJ68ybTXfQ5U9o/QKA3dd0toBEhhdRUDGzWtjvwkEQfqF1reGWj/tod/gCpf\r\n" +"DFi6X0ECgYEA4wOv/pjSC3ty6TuOvKX2rOUiBrLXXv2JSxZnMoMiWI5ipLQt+RYT\r\n" +"VPafL/m7Dn6MbwjayOkcZhBwk5CNz5A6Q4lJ64Mq/lqHznRCQQ2Mc1G8eyDF/fYL\r\n" +"Ze2pLvwP9VD5jTc2miDfw+MnvJhywRRLcemDFP8k4hQVtm8PMp3ZmNECgYEA4gz7\r\n" +"wzObR4gn8ibe617uQPZjWzUj9dUHYd+in1gwBCIrtNnaRn9I9U/Q6tegRYpii4ys\r\n" +"c176NmU+umy6XmuSKV5qD9bSpZWG2nLFnslrN15Lm3fhZxoeMNhBaEDTnLT26yoi\r\n" +"33gp0mSSWy94ZEqipms+ULF6sY1ZtFW6tpGFoy8CgYAQHhnnvJflIs2ky4q10B60\r\n" +"ZcxFp3rtDpkp0JxhFLhiizFrujMtZSjYNm5U7KkgPVHhLELEUvCmOnKTt4ap/vZ0\r\n" +"BxJNe1GZH3pW6SAvGDQpl9sG7uu/vTFP+lCxukmzxB0DrrDcvorEkKMom7ZCCRvW\r\n" +"KZsZ6YeH2Z81BauRj218kQKBgQCUV/DgKP2985xDTT79N08jUo3hTP5MVYCCuj/+\r\n" +"UeEw1TvZcx3LJby7P6Xad6a1/BqveaGyFKIfEFIaBUBItk801sDDpDaYc4gL00Xc\r\n" +"7lFuBHOZkxJYlss5QrGpuOEl9ZwUt5IrFLBdYaKqNHzNVC1pCPfb/JyH6Dr2HUxq\r\n" +"gxUwAQKBgQCcU6G2L8AG9d9c0UpOyL1tMvFe5Ttw0KjlQVdsh1MP6yigYo9DYuwu\r\n" +"bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n" +"8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n" +"-----END RSA PRIVATE KEY-----\r\n"; + +const size_t mbedtls_test_ca_crt_rsa_len = sizeof( mbedtls_test_ca_crt_rsa ); +const size_t mbedtls_test_ca_key_rsa_len = sizeof( mbedtls_test_ca_key_rsa ); +const size_t mbedtls_test_ca_pwd_rsa_len = sizeof( mbedtls_test_ca_pwd_rsa ) - 1; +const size_t mbedtls_test_srv_crt_rsa_len = sizeof( mbedtls_test_srv_crt_rsa ); +const size_t mbedtls_test_srv_key_rsa_len = sizeof( mbedtls_test_srv_key_rsa ); +const size_t mbedtls_test_cli_crt_rsa_len = sizeof( mbedtls_test_cli_crt_rsa ); +const size_t mbedtls_test_cli_key_rsa_len = sizeof( mbedtls_test_cli_key_rsa ); +#else +#define TEST_CA_CRT_RSA +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_PEM_PARSE_C) +/* Concatenation of all available CA certificates */ +const char mbedtls_test_cas_pem[] = TEST_CA_CRT_RSA TEST_CA_CRT_EC; +const size_t mbedtls_test_cas_pem_len = sizeof( mbedtls_test_cas_pem ); +#endif + +/* List of all available CA certificates */ +const char * mbedtls_test_cas[] = { +#if defined(MBEDTLS_RSA_C) + mbedtls_test_ca_crt_rsa, +#endif +#if defined(MBEDTLS_ECDSA_C) + mbedtls_test_ca_crt_ec, +#endif + NULL +}; +const size_t mbedtls_test_cas_len[] = { +#if defined(MBEDTLS_RSA_C) + sizeof( mbedtls_test_ca_crt_rsa ), +#endif +#if defined(MBEDTLS_ECDSA_C) + sizeof( mbedtls_test_ca_crt_ec ), +#endif + 0 +}; + +#if defined(MBEDTLS_RSA_C) +const char *mbedtls_test_ca_crt = mbedtls_test_ca_crt_rsa; +const char *mbedtls_test_ca_key = mbedtls_test_ca_key_rsa; +const char *mbedtls_test_ca_pwd = mbedtls_test_ca_pwd_rsa; +const char *mbedtls_test_srv_crt = mbedtls_test_srv_crt_rsa; +const char *mbedtls_test_srv_key = mbedtls_test_srv_key_rsa; +const char *mbedtls_test_cli_crt = mbedtls_test_cli_crt_rsa; +const char *mbedtls_test_cli_key = mbedtls_test_cli_key_rsa; +const size_t mbedtls_test_ca_crt_len = sizeof( mbedtls_test_ca_crt_rsa ); +const size_t mbedtls_test_ca_key_len = sizeof( mbedtls_test_ca_key_rsa ); +const size_t mbedtls_test_ca_pwd_len = sizeof( mbedtls_test_ca_pwd_rsa ) - 1; +const size_t mbedtls_test_srv_crt_len = sizeof( mbedtls_test_srv_crt_rsa ); +const size_t mbedtls_test_srv_key_len = sizeof( mbedtls_test_srv_key_rsa ); +const size_t mbedtls_test_cli_crt_len = sizeof( mbedtls_test_cli_crt_rsa ); +const size_t mbedtls_test_cli_key_len = sizeof( mbedtls_test_cli_key_rsa ); +#else /* ! MBEDTLS_RSA_C, so MBEDTLS_ECDSA_C */ +const char *mbedtls_test_ca_crt = mbedtls_test_ca_crt_ec; +const char *mbedtls_test_ca_key = mbedtls_test_ca_key_ec; +const char *mbedtls_test_ca_pwd = mbedtls_test_ca_pwd_ec; +const char *mbedtls_test_srv_crt = mbedtls_test_srv_crt_ec; +const char *mbedtls_test_srv_key = mbedtls_test_srv_key_ec; +const char *mbedtls_test_cli_crt = mbedtls_test_cli_crt_ec; +const char *mbedtls_test_cli_key = mbedtls_test_cli_key_ec; +const size_t mbedtls_test_ca_crt_len = sizeof( mbedtls_test_ca_crt_ec ); +const size_t mbedtls_test_ca_key_len = sizeof( mbedtls_test_ca_key_ec ); +const size_t mbedtls_test_ca_pwd_len = sizeof( mbedtls_test_ca_pwd_ec ) - 1; +const size_t mbedtls_test_srv_crt_len = sizeof( mbedtls_test_srv_crt_ec ); +const size_t mbedtls_test_srv_key_len = sizeof( mbedtls_test_srv_key_ec ); +const size_t mbedtls_test_cli_crt_len = sizeof( mbedtls_test_cli_crt_ec ); +const size_t mbedtls_test_cli_key_len = sizeof( mbedtls_test_cli_key_ec ); +#endif /* MBEDTLS_RSA_C */ + +#endif /* MBEDTLS_CERTS_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher.c new file mode 100644 index 0000000..e9e0b22 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher.c @@ -0,0 +1,917 @@ +/** + * \file cipher.c + * + * \brief Generic cipher wrapper for mbed TLS + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CIPHER_C) + +#include "mbedtls/cipher.h" +#include "mbedtls/cipher_internal.h" + +#include +#include + +#if defined(MBEDTLS_GCM_C) +#include "mbedtls/gcm.h" +#endif + +#if defined(MBEDTLS_CCM_C) +#include "mbedtls/ccm.h" +#endif + +#if defined(MBEDTLS_CMAC_C) +#include "mbedtls/cmac.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) +#define MBEDTLS_CIPHER_MODE_STREAM +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +static int supported_init = 0; + +const int *mbedtls_cipher_list( void ) +{ + const mbedtls_cipher_definition_t *def; + int *type; + + if( ! supported_init ) + { + def = mbedtls_cipher_definitions; + type = mbedtls_cipher_supported; + + while( def->type != 0 ) + *type++ = (*def++).type; + + *type = 0; + + supported_init = 1; + } + + return( mbedtls_cipher_supported ); +} + +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type ) +{ + const mbedtls_cipher_definition_t *def; + + for( def = mbedtls_cipher_definitions; def->info != NULL; def++ ) + if( def->type == cipher_type ) + return( def->info ); + + return( NULL ); +} + +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name ) +{ + const mbedtls_cipher_definition_t *def; + + if( NULL == cipher_name ) + return( NULL ); + + for( def = mbedtls_cipher_definitions; def->info != NULL; def++ ) + if( ! strcmp( def->info->name, cipher_name ) ) + return( def->info ); + + return( NULL ); +} + +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id, + int key_bitlen, + const mbedtls_cipher_mode_t mode ) +{ + const mbedtls_cipher_definition_t *def; + + for( def = mbedtls_cipher_definitions; def->info != NULL; def++ ) + if( def->info->base->cipher == cipher_id && + def->info->key_bitlen == (unsigned) key_bitlen && + def->info->mode == mode ) + return( def->info ); + + return( NULL ); +} + +void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_cipher_context_t ) ); +} + +void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ) +{ + if( ctx == NULL ) + return; + +#if defined(MBEDTLS_CMAC_C) + if( ctx->cmac_ctx ) + { + mbedtls_zeroize( ctx->cmac_ctx, sizeof( mbedtls_cmac_context_t ) ); + mbedtls_free( ctx->cmac_ctx ); + } +#endif + + if( ctx->cipher_ctx ) + ctx->cipher_info->base->ctx_free_func( ctx->cipher_ctx ); + + mbedtls_zeroize( ctx, sizeof(mbedtls_cipher_context_t) ); +} + +int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ) +{ + if( NULL == cipher_info || NULL == ctx ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + memset( ctx, 0, sizeof( mbedtls_cipher_context_t ) ); + + if( NULL == ( ctx->cipher_ctx = cipher_info->base->ctx_alloc_func() ) ) + return( MBEDTLS_ERR_CIPHER_ALLOC_FAILED ); + + ctx->cipher_info = cipher_info; + +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) + /* + * Ignore possible errors caused by a cipher mode that doesn't use padding + */ +#if defined(MBEDTLS_CIPHER_PADDING_PKCS7) + (void) mbedtls_cipher_set_padding_mode( ctx, MBEDTLS_PADDING_PKCS7 ); +#else + (void) mbedtls_cipher_set_padding_mode( ctx, MBEDTLS_PADDING_NONE ); +#endif +#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ + + return( 0 ); +} + +int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, + int key_bitlen, const mbedtls_operation_t operation ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( ( ctx->cipher_info->flags & MBEDTLS_CIPHER_VARIABLE_KEY_LEN ) == 0 && + (int) ctx->cipher_info->key_bitlen != key_bitlen ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + ctx->key_bitlen = key_bitlen; + ctx->operation = operation; + + /* + * For CFB and CTR mode always use the encryption key schedule + */ + if( MBEDTLS_ENCRYPT == operation || + MBEDTLS_MODE_CFB == ctx->cipher_info->mode || + MBEDTLS_MODE_CTR == ctx->cipher_info->mode ) + { + return ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key, + ctx->key_bitlen ); + } + + if( MBEDTLS_DECRYPT == operation ) + return ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key, + ctx->key_bitlen ); + + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +} + +int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len ) +{ + size_t actual_iv_size; + + if( NULL == ctx || NULL == ctx->cipher_info || NULL == iv ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* avoid buffer overflow in ctx->iv */ + if( iv_len > MBEDTLS_MAX_IV_LENGTH ) + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); + + if( ( ctx->cipher_info->flags & MBEDTLS_CIPHER_VARIABLE_IV_LEN ) != 0 ) + actual_iv_size = iv_len; + else + { + actual_iv_size = ctx->cipher_info->iv_size; + + /* avoid reading past the end of input buffer */ + if( actual_iv_size > iv_len ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + memcpy( ctx->iv, iv, actual_iv_size ); + ctx->iv_size = actual_iv_size; + + return( 0 ); +} + +int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + ctx->unprocessed_len = 0; + + return( 0 ); +} + +#if defined(MBEDTLS_GCM_C) +int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, + const unsigned char *ad, size_t ad_len ) +{ + if( NULL == ctx || NULL == ctx->cipher_info ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) + { + return mbedtls_gcm_starts( (mbedtls_gcm_context *) ctx->cipher_ctx, ctx->operation, + ctx->iv, ctx->iv_size, ad, ad_len ); + } + + return( 0 ); +} +#endif /* MBEDTLS_GCM_C */ + +int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, + size_t ilen, unsigned char *output, size_t *olen ) +{ + int ret; + size_t block_size = 0; + + if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + *olen = 0; + block_size = mbedtls_cipher_get_block_size( ctx ); + + if( ctx->cipher_info->mode == MBEDTLS_MODE_ECB ) + { + if( ilen != block_size ) + return( MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED ); + + *olen = ilen; + + if( 0 != ( ret = ctx->cipher_info->base->ecb_func( ctx->cipher_ctx, + ctx->operation, input, output ) ) ) + { + return( ret ); + } + + return( 0 ); + } + +#if defined(MBEDTLS_GCM_C) + if( ctx->cipher_info->mode == MBEDTLS_MODE_GCM ) + { + *olen = ilen; + return mbedtls_gcm_update( (mbedtls_gcm_context *) ctx->cipher_ctx, ilen, input, + output ); + } +#endif + + if ( 0 == block_size ) + { + return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT; + } + + if( input == output && + ( ctx->unprocessed_len != 0 || ilen % block_size ) ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + if( ctx->cipher_info->mode == MBEDTLS_MODE_CBC ) + { + size_t copy_len = 0; + + /* + * If there is not enough data for a full block, cache it. + */ + if( ( ctx->operation == MBEDTLS_DECRYPT && + ilen <= block_size - ctx->unprocessed_len ) || + ( ctx->operation == MBEDTLS_ENCRYPT && + ilen < block_size - ctx->unprocessed_len ) ) + { + memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input, + ilen ); + + ctx->unprocessed_len += ilen; + return( 0 ); + } + + /* + * Process cached data first + */ + if( 0 != ctx->unprocessed_len ) + { + copy_len = block_size - ctx->unprocessed_len; + + memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input, + copy_len ); + + if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, + ctx->operation, block_size, ctx->iv, + ctx->unprocessed_data, output ) ) ) + { + return( ret ); + } + + *olen += block_size; + output += block_size; + ctx->unprocessed_len = 0; + + input += copy_len; + ilen -= copy_len; + } + + /* + * Cache final, incomplete block + */ + if( 0 != ilen ) + { + if( 0 == block_size ) + { + return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT; + } + + copy_len = ilen % block_size; + if( copy_len == 0 && ctx->operation == MBEDTLS_DECRYPT ) + copy_len = block_size; + + memcpy( ctx->unprocessed_data, &( input[ilen - copy_len] ), + copy_len ); + + ctx->unprocessed_len += copy_len; + ilen -= copy_len; + } + + /* + * Process remaining full blocks + */ + if( ilen ) + { + if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, + ctx->operation, ilen, ctx->iv, input, output ) ) ) + { + return( ret ); + } + + *olen += ilen; + } + + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + if( ctx->cipher_info->mode == MBEDTLS_MODE_CFB ) + { + if( 0 != ( ret = ctx->cipher_info->base->cfb_func( ctx->cipher_ctx, + ctx->operation, ilen, &ctx->unprocessed_len, ctx->iv, + input, output ) ) ) + { + return( ret ); + } + + *olen = ilen; + + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + if( ctx->cipher_info->mode == MBEDTLS_MODE_CTR ) + { + if( 0 != ( ret = ctx->cipher_info->base->ctr_func( ctx->cipher_ctx, + ilen, &ctx->unprocessed_len, ctx->iv, + ctx->unprocessed_data, input, output ) ) ) + { + return( ret ); + } + + *olen = ilen; + + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + if( ctx->cipher_info->mode == MBEDTLS_MODE_STREAM ) + { + if( 0 != ( ret = ctx->cipher_info->base->stream_func( ctx->cipher_ctx, + ilen, input, output ) ) ) + { + return( ret ); + } + + *olen = ilen; + + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_STREAM */ + + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); +} + +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) +#if defined(MBEDTLS_CIPHER_PADDING_PKCS7) +/* + * PKCS7 (and PKCS5) padding: fill with ll bytes, with ll = padding_len + */ +static void add_pkcs_padding( unsigned char *output, size_t output_len, + size_t data_len ) +{ + size_t padding_len = output_len - data_len; + unsigned char i; + + for( i = 0; i < padding_len; i++ ) + output[data_len + i] = (unsigned char) padding_len; +} + +static int get_pkcs_padding( unsigned char *input, size_t input_len, + size_t *data_len ) +{ + size_t i, pad_idx; + unsigned char padding_len, bad = 0; + + if( NULL == input || NULL == data_len ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + padding_len = input[input_len - 1]; + *data_len = input_len - padding_len; + + /* Avoid logical || since it results in a branch */ + bad |= padding_len > input_len; + bad |= padding_len == 0; + + /* The number of bytes checked must be independent of padding_len, + * so pick input_len, which is usually 8 or 16 (one block) */ + pad_idx = input_len - padding_len; + for( i = 0; i < input_len; i++ ) + bad |= ( input[i] ^ padding_len ) * ( i >= pad_idx ); + + return( MBEDTLS_ERR_CIPHER_INVALID_PADDING * ( bad != 0 ) ); +} +#endif /* MBEDTLS_CIPHER_PADDING_PKCS7 */ + +#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS) +/* + * One and zeros padding: fill with 80 00 ... 00 + */ +static void add_one_and_zeros_padding( unsigned char *output, + size_t output_len, size_t data_len ) +{ + size_t padding_len = output_len - data_len; + unsigned char i = 0; + + output[data_len] = 0x80; + for( i = 1; i < padding_len; i++ ) + output[data_len + i] = 0x00; +} + +static int get_one_and_zeros_padding( unsigned char *input, size_t input_len, + size_t *data_len ) +{ + size_t i; + unsigned char done = 0, prev_done, bad; + + if( NULL == input || NULL == data_len ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + bad = 0xFF; + *data_len = 0; + for( i = input_len; i > 0; i-- ) + { + prev_done = done; + done |= ( input[i-1] != 0 ); + *data_len |= ( i - 1 ) * ( done != prev_done ); + bad &= ( input[i-1] ^ 0x80 ) | ( done == prev_done ); + } + + return( MBEDTLS_ERR_CIPHER_INVALID_PADDING * ( bad != 0 ) ); + +} +#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */ + +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN) +/* + * Zeros and len padding: fill with 00 ... 00 ll, where ll is padding length + */ +static void add_zeros_and_len_padding( unsigned char *output, + size_t output_len, size_t data_len ) +{ + size_t padding_len = output_len - data_len; + unsigned char i = 0; + + for( i = 1; i < padding_len; i++ ) + output[data_len + i - 1] = 0x00; + output[output_len - 1] = (unsigned char) padding_len; +} + +static int get_zeros_and_len_padding( unsigned char *input, size_t input_len, + size_t *data_len ) +{ + size_t i, pad_idx; + unsigned char padding_len, bad = 0; + + if( NULL == input || NULL == data_len ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + padding_len = input[input_len - 1]; + *data_len = input_len - padding_len; + + /* Avoid logical || since it results in a branch */ + bad |= padding_len > input_len; + bad |= padding_len == 0; + + /* The number of bytes checked must be independent of padding_len */ + pad_idx = input_len - padding_len; + for( i = 0; i < input_len - 1; i++ ) + bad |= input[i] * ( i >= pad_idx ); + + return( MBEDTLS_ERR_CIPHER_INVALID_PADDING * ( bad != 0 ) ); +} +#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */ + +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS) +/* + * Zero padding: fill with 00 ... 00 + */ +static void add_zeros_padding( unsigned char *output, + size_t output_len, size_t data_len ) +{ + size_t i; + + for( i = data_len; i < output_len; i++ ) + output[i] = 0x00; +} + +static int get_zeros_padding( unsigned char *input, size_t input_len, + size_t *data_len ) +{ + size_t i; + unsigned char done = 0, prev_done; + + if( NULL == input || NULL == data_len ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + *data_len = 0; + for( i = input_len; i > 0; i-- ) + { + prev_done = done; + done |= ( input[i-1] != 0 ); + *data_len |= i * ( done != prev_done ); + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_PADDING_ZEROS */ + +/* + * No padding: don't pad :) + * + * There is no add_padding function (check for NULL in mbedtls_cipher_finish) + * but a trivial get_padding function + */ +static int get_no_padding( unsigned char *input, size_t input_len, + size_t *data_len ) +{ + if( NULL == input || NULL == data_len ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + *data_len = input_len; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ + +int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, + unsigned char *output, size_t *olen ) +{ + if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + *olen = 0; + + if( MBEDTLS_MODE_CFB == ctx->cipher_info->mode || + MBEDTLS_MODE_CTR == ctx->cipher_info->mode || + MBEDTLS_MODE_GCM == ctx->cipher_info->mode || + MBEDTLS_MODE_STREAM == ctx->cipher_info->mode ) + { + return( 0 ); + } + + if( MBEDTLS_MODE_ECB == ctx->cipher_info->mode ) + { + if( ctx->unprocessed_len != 0 ) + return( MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED ); + + return( 0 ); + } + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + if( MBEDTLS_MODE_CBC == ctx->cipher_info->mode ) + { + int ret = 0; + + if( MBEDTLS_ENCRYPT == ctx->operation ) + { + /* check for 'no padding' mode */ + if( NULL == ctx->add_padding ) + { + if( 0 != ctx->unprocessed_len ) + return( MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED ); + + return( 0 ); + } + + ctx->add_padding( ctx->unprocessed_data, mbedtls_cipher_get_iv_size( ctx ), + ctx->unprocessed_len ); + } + else if( mbedtls_cipher_get_block_size( ctx ) != ctx->unprocessed_len ) + { + /* + * For decrypt operations, expect a full block, + * or an empty block if no padding + */ + if( NULL == ctx->add_padding && 0 == ctx->unprocessed_len ) + return( 0 ); + + return( MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED ); + } + + /* cipher block */ + if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, + ctx->operation, mbedtls_cipher_get_block_size( ctx ), ctx->iv, + ctx->unprocessed_data, output ) ) ) + { + return( ret ); + } + + /* Set output size for decryption */ + if( MBEDTLS_DECRYPT == ctx->operation ) + return ctx->get_padding( output, mbedtls_cipher_get_block_size( ctx ), + olen ); + + /* Set output size for encryption */ + *olen = mbedtls_cipher_get_block_size( ctx ); + return( 0 ); + } +#else + ((void) output); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); +} + +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) +int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ) +{ + if( NULL == ctx || + MBEDTLS_MODE_CBC != ctx->cipher_info->mode ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + switch( mode ) + { +#if defined(MBEDTLS_CIPHER_PADDING_PKCS7) + case MBEDTLS_PADDING_PKCS7: + ctx->add_padding = add_pkcs_padding; + ctx->get_padding = get_pkcs_padding; + break; +#endif +#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS) + case MBEDTLS_PADDING_ONE_AND_ZEROS: + ctx->add_padding = add_one_and_zeros_padding; + ctx->get_padding = get_one_and_zeros_padding; + break; +#endif +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN) + case MBEDTLS_PADDING_ZEROS_AND_LEN: + ctx->add_padding = add_zeros_and_len_padding; + ctx->get_padding = get_zeros_and_len_padding; + break; +#endif +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS) + case MBEDTLS_PADDING_ZEROS: + ctx->add_padding = add_zeros_padding; + ctx->get_padding = get_zeros_padding; + break; +#endif + case MBEDTLS_PADDING_NONE: + ctx->add_padding = NULL; + ctx->get_padding = get_no_padding; + break; + + default: + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ + +#if defined(MBEDTLS_GCM_C) +int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, + unsigned char *tag, size_t tag_len ) +{ + if( NULL == ctx || NULL == ctx->cipher_info || NULL == tag ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( MBEDTLS_ENCRYPT != ctx->operation ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) + return mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, tag, tag_len ); + + return( 0 ); +} + +int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, + const unsigned char *tag, size_t tag_len ) +{ + int ret; + + if( NULL == ctx || NULL == ctx->cipher_info || + MBEDTLS_DECRYPT != ctx->operation ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) + { + unsigned char check_tag[16]; + size_t i; + int diff; + + if( tag_len > sizeof( check_tag ) ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( 0 != ( ret = mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, + check_tag, tag_len ) ) ) + { + return( ret ); + } + + /* Check the tag in "constant-time" */ + for( diff = 0, i = 0; i < tag_len; i++ ) + diff |= tag[i] ^ check_tag[i]; + + if( diff != 0 ) + return( MBEDTLS_ERR_CIPHER_AUTH_FAILED ); + + return( 0 ); + } + + return( 0 ); +} +#endif /* MBEDTLS_GCM_C */ + +/* + * Packet-oriented wrapper for non-AEAD modes + */ +int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen ) +{ + int ret; + size_t finish_olen; + + if( ( ret = mbedtls_cipher_set_iv( ctx, iv, iv_len ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_cipher_reset( ctx ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_cipher_update( ctx, input, ilen, output, olen ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_cipher_finish( ctx, output + *olen, &finish_olen ) ) != 0 ) + return( ret ); + + *olen += finish_olen; + + return( 0 ); +} + +#if defined(MBEDTLS_CIPHER_MODE_AEAD) +/* + * Packet-oriented encryption for AEAD modes + */ +int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *ad, size_t ad_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, + unsigned char *tag, size_t tag_len ) +{ +#if defined(MBEDTLS_GCM_C) + if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) + { + *olen = ilen; + return( mbedtls_gcm_crypt_and_tag( ctx->cipher_ctx, MBEDTLS_GCM_ENCRYPT, ilen, + iv, iv_len, ad, ad_len, input, output, + tag_len, tag ) ); + } +#endif /* MBEDTLS_GCM_C */ +#if defined(MBEDTLS_CCM_C) + if( MBEDTLS_MODE_CCM == ctx->cipher_info->mode ) + { + *olen = ilen; + return( mbedtls_ccm_encrypt_and_tag( ctx->cipher_ctx, ilen, + iv, iv_len, ad, ad_len, input, output, + tag, tag_len ) ); + } +#endif /* MBEDTLS_CCM_C */ + + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); +} + +/* + * Packet-oriented decryption for AEAD modes + */ +int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *ad, size_t ad_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, + const unsigned char *tag, size_t tag_len ) +{ +#if defined(MBEDTLS_GCM_C) + if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) + { + int ret; + + *olen = ilen; + ret = mbedtls_gcm_auth_decrypt( ctx->cipher_ctx, ilen, + iv, iv_len, ad, ad_len, + tag, tag_len, input, output ); + + if( ret == MBEDTLS_ERR_GCM_AUTH_FAILED ) + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + + return( ret ); + } +#endif /* MBEDTLS_GCM_C */ +#if defined(MBEDTLS_CCM_C) + if( MBEDTLS_MODE_CCM == ctx->cipher_info->mode ) + { + int ret; + + *olen = ilen; + ret = mbedtls_ccm_auth_decrypt( ctx->cipher_ctx, ilen, + iv, iv_len, ad, ad_len, + input, output, tag, tag_len ); + + if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + + return( ret ); + } +#endif /* MBEDTLS_CCM_C */ + + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); +} +#endif /* MBEDTLS_CIPHER_MODE_AEAD */ + +#endif /* MBEDTLS_CIPHER_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher_wrap.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher_wrap.c new file mode 100644 index 0000000..dc76af8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cipher_wrap.c @@ -0,0 +1,1451 @@ +/** + * \file cipher_wrap.c + * + * \brief Generic cipher wrapper for mbed TLS + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CIPHER_C) + +#include "mbedtls/cipher_internal.h" + +#if defined(MBEDTLS_AES_C) +#include "mbedtls/aes.h" +#endif + +#if defined(MBEDTLS_ARC4_C) +#include "mbedtls/arc4.h" +#endif + +#if defined(MBEDTLS_CAMELLIA_C) +#include "mbedtls/camellia.h" +#endif + +#if defined(MBEDTLS_DES_C) +#include "mbedtls/des.h" +#endif + +#if defined(MBEDTLS_BLOWFISH_C) +#include "mbedtls/blowfish.h" +#endif + +#if defined(MBEDTLS_GCM_C) +#include "mbedtls/gcm.h" +#endif + +#if defined(MBEDTLS_CCM_C) +#include "mbedtls/ccm.h" +#endif + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +#include +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if defined(MBEDTLS_GCM_C) +/* shared by all GCM ciphers */ +static void *gcm_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) ); + + if( ctx != NULL ) + mbedtls_gcm_init( (mbedtls_gcm_context *) ctx ); + + return( ctx ); +} + +static void gcm_ctx_free( void *ctx ) +{ + mbedtls_gcm_free( ctx ); + mbedtls_free( ctx ); +} +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CCM_C) +/* shared by all CCM ciphers */ +static void *ccm_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) ); + + if( ctx != NULL ) + mbedtls_ccm_init( (mbedtls_ccm_context *) ctx ); + + return( ctx ); +} + +static void ccm_ctx_free( void *ctx ) +{ + mbedtls_ccm_free( ctx ); + mbedtls_free( ctx ); +} +#endif /* MBEDTLS_CCM_C */ + +#if defined(MBEDTLS_AES_C) + +static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aes_crypt_ecb( (mbedtls_aes_context *) ctx, operation, input, output ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, + unsigned char *iv, const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aes_crypt_cbc( (mbedtls_aes_context *) ctx, operation, length, iv, input, + output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aes_crypt_cfb128( (mbedtls_aes_context *) ctx, operation, length, iv_off, iv, + input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter, + stream_block, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_bitlen ); +} + +static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen ); +} + +static void * aes_ctx_alloc( void ) +{ + mbedtls_aes_context *aes = mbedtls_calloc( 1, sizeof( mbedtls_aes_context ) ); + + if( aes == NULL ) + return( NULL ); + + mbedtls_aes_init( aes ); + + return( aes ); +} + +static void aes_ctx_free( void *ctx ) +{ + mbedtls_aes_free( (mbedtls_aes_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t aes_info = { + MBEDTLS_CIPHER_ID_AES, + aes_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + aes_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + aes_crypt_cfb128_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + aes_crypt_ctr_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + aes_setkey_enc_wrap, + aes_setkey_dec_wrap, + aes_ctx_alloc, + aes_ctx_free +}; + +static const mbedtls_cipher_info_t aes_128_ecb_info = { + MBEDTLS_CIPHER_AES_128_ECB, + MBEDTLS_MODE_ECB, + 128, + "AES-128-ECB", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_192_ecb_info = { + MBEDTLS_CIPHER_AES_192_ECB, + MBEDTLS_MODE_ECB, + 192, + "AES-192-ECB", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_256_ecb_info = { + MBEDTLS_CIPHER_AES_256_ECB, + MBEDTLS_MODE_ECB, + 256, + "AES-256-ECB", + 16, + 0, + 16, + &aes_info +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t aes_128_cbc_info = { + MBEDTLS_CIPHER_AES_128_CBC, + MBEDTLS_MODE_CBC, + 128, + "AES-128-CBC", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_192_cbc_info = { + MBEDTLS_CIPHER_AES_192_CBC, + MBEDTLS_MODE_CBC, + 192, + "AES-192-CBC", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_256_cbc_info = { + MBEDTLS_CIPHER_AES_256_CBC, + MBEDTLS_MODE_CBC, + 256, + "AES-256-CBC", + 16, + 0, + 16, + &aes_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static const mbedtls_cipher_info_t aes_128_cfb128_info = { + MBEDTLS_CIPHER_AES_128_CFB128, + MBEDTLS_MODE_CFB, + 128, + "AES-128-CFB128", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_192_cfb128_info = { + MBEDTLS_CIPHER_AES_192_CFB128, + MBEDTLS_MODE_CFB, + 192, + "AES-192-CFB128", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_256_cfb128_info = { + MBEDTLS_CIPHER_AES_256_CFB128, + MBEDTLS_MODE_CFB, + 256, + "AES-256-CFB128", + 16, + 0, + 16, + &aes_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static const mbedtls_cipher_info_t aes_128_ctr_info = { + MBEDTLS_CIPHER_AES_128_CTR, + MBEDTLS_MODE_CTR, + 128, + "AES-128-CTR", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_192_ctr_info = { + MBEDTLS_CIPHER_AES_192_CTR, + MBEDTLS_MODE_CTR, + 192, + "AES-192-CTR", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_256_ctr_info = { + MBEDTLS_CIPHER_AES_256_CTR, + MBEDTLS_MODE_CTR, + 256, + "AES-256-CTR", + 16, + 0, + 16, + &aes_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_GCM_C) +static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES, + key, key_bitlen ); +} + +static const mbedtls_cipher_base_t gcm_aes_info = { + MBEDTLS_CIPHER_ID_AES, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + gcm_aes_setkey_wrap, + gcm_aes_setkey_wrap, + gcm_ctx_alloc, + gcm_ctx_free, +}; + +static const mbedtls_cipher_info_t aes_128_gcm_info = { + MBEDTLS_CIPHER_AES_128_GCM, + MBEDTLS_MODE_GCM, + 128, + "AES-128-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_aes_info +}; + +static const mbedtls_cipher_info_t aes_192_gcm_info = { + MBEDTLS_CIPHER_AES_192_GCM, + MBEDTLS_MODE_GCM, + 192, + "AES-192-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_aes_info +}; + +static const mbedtls_cipher_info_t aes_256_gcm_info = { + MBEDTLS_CIPHER_AES_256_GCM, + MBEDTLS_MODE_GCM, + 256, + "AES-256-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_aes_info +}; +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CCM_C) +static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES, + key, key_bitlen ); +} + +static const mbedtls_cipher_base_t ccm_aes_info = { + MBEDTLS_CIPHER_ID_AES, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + ccm_aes_setkey_wrap, + ccm_aes_setkey_wrap, + ccm_ctx_alloc, + ccm_ctx_free, +}; + +static const mbedtls_cipher_info_t aes_128_ccm_info = { + MBEDTLS_CIPHER_AES_128_CCM, + MBEDTLS_MODE_CCM, + 128, + "AES-128-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aes_info +}; + +static const mbedtls_cipher_info_t aes_192_ccm_info = { + MBEDTLS_CIPHER_AES_192_CCM, + MBEDTLS_MODE_CCM, + 192, + "AES-192-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aes_info +}; + +static const mbedtls_cipher_info_t aes_256_ccm_info = { + MBEDTLS_CIPHER_AES_256_CCM, + MBEDTLS_MODE_CCM, + 256, + "AES-256-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aes_info +}; +#endif /* MBEDTLS_CCM_C */ + +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) + +static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_camellia_crypt_ecb( (mbedtls_camellia_context *) ctx, operation, input, + output ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, unsigned char *iv, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_camellia_crypt_cbc( (mbedtls_camellia_context *) ctx, operation, length, iv, + input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_camellia_crypt_cfb128( (mbedtls_camellia_context *) ctx, operation, length, + iv_off, iv, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_camellia_crypt_ctr( (mbedtls_camellia_context *) ctx, length, nc_off, + nonce_counter, stream_block, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_camellia_setkey_dec( (mbedtls_camellia_context *) ctx, key, key_bitlen ); +} + +static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_camellia_setkey_enc( (mbedtls_camellia_context *) ctx, key, key_bitlen ); +} + +static void * camellia_ctx_alloc( void ) +{ + mbedtls_camellia_context *ctx; + ctx = mbedtls_calloc( 1, sizeof( mbedtls_camellia_context ) ); + + if( ctx == NULL ) + return( NULL ); + + mbedtls_camellia_init( ctx ); + + return( ctx ); +} + +static void camellia_ctx_free( void *ctx ) +{ + mbedtls_camellia_free( (mbedtls_camellia_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t camellia_info = { + MBEDTLS_CIPHER_ID_CAMELLIA, + camellia_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + camellia_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + camellia_crypt_cfb128_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + camellia_crypt_ctr_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + camellia_setkey_enc_wrap, + camellia_setkey_dec_wrap, + camellia_ctx_alloc, + camellia_ctx_free +}; + +static const mbedtls_cipher_info_t camellia_128_ecb_info = { + MBEDTLS_CIPHER_CAMELLIA_128_ECB, + MBEDTLS_MODE_ECB, + 128, + "CAMELLIA-128-ECB", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_ecb_info = { + MBEDTLS_CIPHER_CAMELLIA_192_ECB, + MBEDTLS_MODE_ECB, + 192, + "CAMELLIA-192-ECB", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_ecb_info = { + MBEDTLS_CIPHER_CAMELLIA_256_ECB, + MBEDTLS_MODE_ECB, + 256, + "CAMELLIA-256-ECB", + 16, + 0, + 16, + &camellia_info +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t camellia_128_cbc_info = { + MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_MODE_CBC, + 128, + "CAMELLIA-128-CBC", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_cbc_info = { + MBEDTLS_CIPHER_CAMELLIA_192_CBC, + MBEDTLS_MODE_CBC, + 192, + "CAMELLIA-192-CBC", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_cbc_info = { + MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_MODE_CBC, + 256, + "CAMELLIA-256-CBC", + 16, + 0, + 16, + &camellia_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static const mbedtls_cipher_info_t camellia_128_cfb128_info = { + MBEDTLS_CIPHER_CAMELLIA_128_CFB128, + MBEDTLS_MODE_CFB, + 128, + "CAMELLIA-128-CFB128", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_cfb128_info = { + MBEDTLS_CIPHER_CAMELLIA_192_CFB128, + MBEDTLS_MODE_CFB, + 192, + "CAMELLIA-192-CFB128", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_cfb128_info = { + MBEDTLS_CIPHER_CAMELLIA_256_CFB128, + MBEDTLS_MODE_CFB, + 256, + "CAMELLIA-256-CFB128", + 16, + 0, + 16, + &camellia_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static const mbedtls_cipher_info_t camellia_128_ctr_info = { + MBEDTLS_CIPHER_CAMELLIA_128_CTR, + MBEDTLS_MODE_CTR, + 128, + "CAMELLIA-128-CTR", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_ctr_info = { + MBEDTLS_CIPHER_CAMELLIA_192_CTR, + MBEDTLS_MODE_CTR, + 192, + "CAMELLIA-192-CTR", + 16, + 0, + 16, + &camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_ctr_info = { + MBEDTLS_CIPHER_CAMELLIA_256_CTR, + MBEDTLS_MODE_CTR, + 256, + "CAMELLIA-256-CTR", + 16, + 0, + 16, + &camellia_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_GCM_C) +static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, + key, key_bitlen ); +} + +static const mbedtls_cipher_base_t gcm_camellia_info = { + MBEDTLS_CIPHER_ID_CAMELLIA, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + gcm_camellia_setkey_wrap, + gcm_camellia_setkey_wrap, + gcm_ctx_alloc, + gcm_ctx_free, +}; + +static const mbedtls_cipher_info_t camellia_128_gcm_info = { + MBEDTLS_CIPHER_CAMELLIA_128_GCM, + MBEDTLS_MODE_GCM, + 128, + "CAMELLIA-128-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_gcm_info = { + MBEDTLS_CIPHER_CAMELLIA_192_GCM, + MBEDTLS_MODE_GCM, + 192, + "CAMELLIA-192-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_gcm_info = { + MBEDTLS_CIPHER_CAMELLIA_256_GCM, + MBEDTLS_MODE_GCM, + 256, + "CAMELLIA-256-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_camellia_info +}; +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CCM_C) +static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, + key, key_bitlen ); +} + +static const mbedtls_cipher_base_t ccm_camellia_info = { + MBEDTLS_CIPHER_ID_CAMELLIA, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + ccm_camellia_setkey_wrap, + ccm_camellia_setkey_wrap, + ccm_ctx_alloc, + ccm_ctx_free, +}; + +static const mbedtls_cipher_info_t camellia_128_ccm_info = { + MBEDTLS_CIPHER_CAMELLIA_128_CCM, + MBEDTLS_MODE_CCM, + 128, + "CAMELLIA-128-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_ccm_info = { + MBEDTLS_CIPHER_CAMELLIA_192_CCM, + MBEDTLS_MODE_CCM, + 192, + "CAMELLIA-192-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_ccm_info = { + MBEDTLS_CIPHER_CAMELLIA_256_CCM, + MBEDTLS_MODE_CCM, + 256, + "CAMELLIA-256-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_camellia_info +}; +#endif /* MBEDTLS_CCM_C */ + +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) + +static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, + const unsigned char *input, unsigned char *output ) +{ + ((void) operation); + return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output ); +} + +static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, + const unsigned char *input, unsigned char *output ) +{ + ((void) operation); + return mbedtls_des3_crypt_ecb( (mbedtls_des3_context *) ctx, input, output ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, + unsigned char *iv, const unsigned char *input, unsigned char *output ) +{ + return mbedtls_des_crypt_cbc( (mbedtls_des_context *) ctx, operation, length, iv, input, + output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, + unsigned char *iv, const unsigned char *input, unsigned char *output ) +{ + return mbedtls_des3_crypt_cbc( (mbedtls_des3_context *) ctx, operation, length, iv, input, + output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +static int des_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) key_bitlen); + + return mbedtls_des_setkey_dec( (mbedtls_des_context *) ctx, key ); +} + +static int des_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) key_bitlen); + + return mbedtls_des_setkey_enc( (mbedtls_des_context *) ctx, key ); +} + +static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) key_bitlen); + + return mbedtls_des3_set2key_dec( (mbedtls_des3_context *) ctx, key ); +} + +static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) key_bitlen); + + return mbedtls_des3_set2key_enc( (mbedtls_des3_context *) ctx, key ); +} + +static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) key_bitlen); + + return mbedtls_des3_set3key_dec( (mbedtls_des3_context *) ctx, key ); +} + +static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) key_bitlen); + + return mbedtls_des3_set3key_enc( (mbedtls_des3_context *) ctx, key ); +} + +static void * des_ctx_alloc( void ) +{ + mbedtls_des_context *des = mbedtls_calloc( 1, sizeof( mbedtls_des_context ) ); + + if( des == NULL ) + return( NULL ); + + mbedtls_des_init( des ); + + return( des ); +} + +static void des_ctx_free( void *ctx ) +{ + mbedtls_des_free( (mbedtls_des_context *) ctx ); + mbedtls_free( ctx ); +} + +static void * des3_ctx_alloc( void ) +{ + mbedtls_des3_context *des3; + des3 = mbedtls_calloc( 1, sizeof( mbedtls_des3_context ) ); + + if( des3 == NULL ) + return( NULL ); + + mbedtls_des3_init( des3 ); + + return( des3 ); +} + +static void des3_ctx_free( void *ctx ) +{ + mbedtls_des3_free( (mbedtls_des3_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t des_info = { + MBEDTLS_CIPHER_ID_DES, + des_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + des_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + des_setkey_enc_wrap, + des_setkey_dec_wrap, + des_ctx_alloc, + des_ctx_free +}; + +static const mbedtls_cipher_info_t des_ecb_info = { + MBEDTLS_CIPHER_DES_ECB, + MBEDTLS_MODE_ECB, + MBEDTLS_KEY_LENGTH_DES, + "DES-ECB", + 8, + 0, + 8, + &des_info +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t des_cbc_info = { + MBEDTLS_CIPHER_DES_CBC, + MBEDTLS_MODE_CBC, + MBEDTLS_KEY_LENGTH_DES, + "DES-CBC", + 8, + 0, + 8, + &des_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +static const mbedtls_cipher_base_t des_ede_info = { + MBEDTLS_CIPHER_ID_DES, + des3_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + des3_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + des3_set2key_enc_wrap, + des3_set2key_dec_wrap, + des3_ctx_alloc, + des3_ctx_free +}; + +static const mbedtls_cipher_info_t des_ede_ecb_info = { + MBEDTLS_CIPHER_DES_EDE_ECB, + MBEDTLS_MODE_ECB, + MBEDTLS_KEY_LENGTH_DES_EDE, + "DES-EDE-ECB", + 8, + 0, + 8, + &des_ede_info +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t des_ede_cbc_info = { + MBEDTLS_CIPHER_DES_EDE_CBC, + MBEDTLS_MODE_CBC, + MBEDTLS_KEY_LENGTH_DES_EDE, + "DES-EDE-CBC", + 8, + 0, + 8, + &des_ede_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +static const mbedtls_cipher_base_t des_ede3_info = { + MBEDTLS_CIPHER_ID_3DES, + des3_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + des3_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + des3_set3key_enc_wrap, + des3_set3key_dec_wrap, + des3_ctx_alloc, + des3_ctx_free +}; + +static const mbedtls_cipher_info_t des_ede3_ecb_info = { + MBEDTLS_CIPHER_DES_EDE3_ECB, + MBEDTLS_MODE_ECB, + MBEDTLS_KEY_LENGTH_DES_EDE3, + "DES-EDE3-ECB", + 8, + 0, + 8, + &des_ede3_info +}; +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t des_ede3_cbc_info = { + MBEDTLS_CIPHER_DES_EDE3_CBC, + MBEDTLS_MODE_CBC, + MBEDTLS_KEY_LENGTH_DES_EDE3, + "DES-EDE3-CBC", + 8, + 0, + 8, + &des_ede3_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_BLOWFISH_C) + +static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_blowfish_crypt_ecb( (mbedtls_blowfish_context *) ctx, operation, input, + output ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, unsigned char *iv, const unsigned char *input, + unsigned char *output ) +{ + return mbedtls_blowfish_crypt_cbc( (mbedtls_blowfish_context *) ctx, operation, length, iv, + input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_blowfish_crypt_cfb64( (mbedtls_blowfish_context *) ctx, operation, length, + iv_off, iv, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_blowfish_crypt_ctr( (mbedtls_blowfish_context *) ctx, length, nc_off, + nonce_counter, stream_block, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +static int blowfish_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_bitlen ); +} + +static void * blowfish_ctx_alloc( void ) +{ + mbedtls_blowfish_context *ctx; + ctx = mbedtls_calloc( 1, sizeof( mbedtls_blowfish_context ) ); + + if( ctx == NULL ) + return( NULL ); + + mbedtls_blowfish_init( ctx ); + + return( ctx ); +} + +static void blowfish_ctx_free( void *ctx ) +{ + mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t blowfish_info = { + MBEDTLS_CIPHER_ID_BLOWFISH, + blowfish_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + blowfish_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + blowfish_crypt_cfb64_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + blowfish_crypt_ctr_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + blowfish_setkey_wrap, + blowfish_setkey_wrap, + blowfish_ctx_alloc, + blowfish_ctx_free +}; + +static const mbedtls_cipher_info_t blowfish_ecb_info = { + MBEDTLS_CIPHER_BLOWFISH_ECB, + MBEDTLS_MODE_ECB, + 128, + "BLOWFISH-ECB", + 8, + MBEDTLS_CIPHER_VARIABLE_KEY_LEN, + 8, + &blowfish_info +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t blowfish_cbc_info = { + MBEDTLS_CIPHER_BLOWFISH_CBC, + MBEDTLS_MODE_CBC, + 128, + "BLOWFISH-CBC", + 8, + MBEDTLS_CIPHER_VARIABLE_KEY_LEN, + 8, + &blowfish_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static const mbedtls_cipher_info_t blowfish_cfb64_info = { + MBEDTLS_CIPHER_BLOWFISH_CFB64, + MBEDTLS_MODE_CFB, + 128, + "BLOWFISH-CFB64", + 8, + MBEDTLS_CIPHER_VARIABLE_KEY_LEN, + 8, + &blowfish_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static const mbedtls_cipher_info_t blowfish_ctr_info = { + MBEDTLS_CIPHER_BLOWFISH_CTR, + MBEDTLS_MODE_CTR, + 128, + "BLOWFISH-CTR", + 8, + MBEDTLS_CIPHER_VARIABLE_KEY_LEN, + 8, + &blowfish_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CTR */ +#endif /* MBEDTLS_BLOWFISH_C */ + +#if defined(MBEDTLS_ARC4_C) +static int arc4_crypt_stream_wrap( void *ctx, size_t length, + const unsigned char *input, + unsigned char *output ) +{ + return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) ); +} + +static int arc4_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + /* we get key_bitlen in bits, arc4 expects it in bytes */ + if( key_bitlen % 8 != 0 ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_bitlen / 8 ); + return( 0 ); +} + +static void * arc4_ctx_alloc( void ) +{ + mbedtls_arc4_context *ctx; + ctx = mbedtls_calloc( 1, sizeof( mbedtls_arc4_context ) ); + + if( ctx == NULL ) + return( NULL ); + + mbedtls_arc4_init( ctx ); + + return( ctx ); +} + +static void arc4_ctx_free( void *ctx ) +{ + mbedtls_arc4_free( (mbedtls_arc4_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t arc4_base_info = { + MBEDTLS_CIPHER_ID_ARC4, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + arc4_crypt_stream_wrap, +#endif + arc4_setkey_wrap, + arc4_setkey_wrap, + arc4_ctx_alloc, + arc4_ctx_free +}; + +static const mbedtls_cipher_info_t arc4_128_info = { + MBEDTLS_CIPHER_ARC4_128, + MBEDTLS_MODE_STREAM, + 128, + "ARC4-128", + 0, + 0, + 1, + &arc4_base_info +}; +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +static int null_crypt_stream( void *ctx, size_t length, + const unsigned char *input, + unsigned char *output ) +{ + ((void) ctx); + memmove( output, input, length ); + return( 0 ); +} + +static int null_setkey( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + ((void) ctx); + ((void) key); + ((void) key_bitlen); + + return( 0 ); +} + +static void * null_ctx_alloc( void ) +{ + return( (void *) 1 ); +} + +static void null_ctx_free( void *ctx ) +{ + ((void) ctx); +} + +static const mbedtls_cipher_base_t null_base_info = { + MBEDTLS_CIPHER_ID_NULL, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + null_crypt_stream, +#endif + null_setkey, + null_setkey, + null_ctx_alloc, + null_ctx_free +}; + +static const mbedtls_cipher_info_t null_cipher_info = { + MBEDTLS_CIPHER_NULL, + MBEDTLS_MODE_STREAM, + 0, + "NULL", + 0, + 0, + 1, + &null_base_info +}; +#endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */ + +const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = +{ +#if defined(MBEDTLS_AES_C) + { MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info }, + { MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info }, + { MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info }, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info }, + { MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info }, + { MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + { MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info }, + { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info }, + { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info }, + { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info }, + { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info }, +#endif +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info }, + { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info }, + { MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info }, +#endif +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info }, + { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info }, + { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info }, +#endif +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_ARC4_C) + { MBEDTLS_CIPHER_ARC4_128, &arc4_128_info }, +#endif + +#if defined(MBEDTLS_BLOWFISH_C) + { MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info }, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + { MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + { MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info }, +#endif +#endif /* MBEDTLS_BLOWFISH_C */ + +#if defined(MBEDTLS_CAMELLIA_C) + { MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info }, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + { MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + { MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info }, +#endif +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info }, +#endif +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info }, +#endif +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) + { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info }, + { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info }, + { MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info }, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_CIPHER_DES_CBC, &des_cbc_info }, + { MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info }, + { MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info }, +#endif +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) + { MBEDTLS_CIPHER_NULL, &null_cipher_info }, +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ + + { MBEDTLS_CIPHER_NONE, NULL } +}; + +#define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0] +int mbedtls_cipher_supported[NUM_CIPHERS]; + +#endif /* MBEDTLS_CIPHER_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cmac.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cmac.c new file mode 100644 index 0000000..b2fe713 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/cmac.c @@ -0,0 +1,1074 @@ +/* + * \file cmac.c + * + * \brief NIST SP800-38B compliant CMAC implementation for AES and 3DES + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * References: + * + * - NIST SP 800-38B Recommendation for Block Cipher Modes of Operation: The + * CMAC Mode for Authentication + * http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf + * + * - RFC 4493 - The AES-CMAC Algorithm + * https://tools.ietf.org/html/rfc4493 + * + * - RFC 4615 - The Advanced Encryption Standard-Cipher-based Message + * Authentication Code-Pseudo-Random Function-128 (AES-CMAC-PRF-128) + * Algorithm for the Internet Key Exchange Protocol (IKE) + * https://tools.ietf.org/html/rfc4615 + * + * Additional test vectors: ISO/IEC 9797-1 + * + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CMAC_C) + +#include "mbedtls/cmac.h" + +#include + + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#if defined(MBEDTLS_SELF_TEST) +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_SELF_TEST */ +#endif /* MBEDTLS_PLATFORM_C */ + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * Multiplication by u in the Galois field of GF(2^n) + * + * As explained in NIST SP 800-38B, this can be computed: + * + * If MSB(p) = 0, then p = (p << 1) + * If MSB(p) = 1, then p = (p << 1) ^ R_n + * with R_64 = 0x1B and R_128 = 0x87 + * + * Input and output MUST NOT point to the same buffer + * Block size must be 8 bytes or 16 bytes - the block sizes for DES and AES. + */ +static int cmac_multiply_by_u( unsigned char *output, + const unsigned char *input, + size_t blocksize ) +{ + const unsigned char R_128 = 0x87; + const unsigned char R_64 = 0x1B; + unsigned char R_n, mask; + unsigned char overflow = 0x00; + int i; + + if( blocksize == MBEDTLS_AES_BLOCK_SIZE ) + { + R_n = R_128; + } + else if( blocksize == MBEDTLS_DES3_BLOCK_SIZE ) + { + R_n = R_64; + } + else + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + for( i = (int)blocksize - 1; i >= 0; i-- ) + { + output[i] = input[i] << 1 | overflow; + overflow = input[i] >> 7; + } + + /* mask = ( input[0] >> 7 ) ? 0xff : 0x00 + * using bit operations to avoid branches */ + + /* MSVC has a warning about unary minus on unsigned, but this is + * well-defined and precisely what we want to do here */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + mask = - ( input[0] >> 7 ); +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + + output[ blocksize - 1 ] ^= R_n & mask; + + return( 0 ); +} + +/* + * Generate subkeys + * + * - as specified by RFC 4493, section 2.3 Subkey Generation Algorithm + */ +static int cmac_generate_subkeys( mbedtls_cipher_context_t *ctx, + unsigned char* K1, unsigned char* K2 ) +{ + int ret; + unsigned char L[MBEDTLS_CIPHER_BLKSIZE_MAX]; + size_t olen, block_size; + + mbedtls_zeroize( L, sizeof( L ) ); + + block_size = ctx->cipher_info->block_size; + + /* Calculate Ek(0) */ + if( ( ret = mbedtls_cipher_update( ctx, L, block_size, L, &olen ) ) != 0 ) + goto exit; + + /* + * Generate K1 and K2 + */ + if( ( ret = cmac_multiply_by_u( K1, L , block_size ) ) != 0 ) + goto exit; + + if( ( ret = cmac_multiply_by_u( K2, K1 , block_size ) ) != 0 ) + goto exit; + +exit: + mbedtls_zeroize( L, sizeof( L ) ); + + return( ret ); +} + +static void cmac_xor_block( unsigned char *output, const unsigned char *input1, + const unsigned char *input2, + const size_t block_size ) +{ + size_t index; + + for( index = 0; index < block_size; index++ ) + output[ index ] = input1[ index ] ^ input2[ index ]; +} + +/* + * Create padded last block from (partial) last block. + * + * We can't use the padding option from the cipher layer, as it only works for + * CBC and we use ECB mode, and anyway we need to XOR K1 or K2 in addition. + */ +static void cmac_pad( unsigned char padded_block[MBEDTLS_CIPHER_BLKSIZE_MAX], + size_t padded_block_len, + const unsigned char *last_block, + size_t last_block_len ) +{ + size_t j; + + for( j = 0; j < padded_block_len; j++ ) + { + if( j < last_block_len ) + padded_block[j] = last_block[j]; + else if( j == last_block_len ) + padded_block[j] = 0x80; + else + padded_block[j] = 0x00; + } +} + +int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, + const unsigned char *key, size_t keybits ) +{ + mbedtls_cipher_type_t type; + mbedtls_cmac_context_t *cmac_ctx; + int retval; + + if( ctx == NULL || ctx->cipher_info == NULL || key == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( ( retval = mbedtls_cipher_setkey( ctx, key, (int)keybits, + MBEDTLS_ENCRYPT ) ) != 0 ) + return( retval ); + + type = ctx->cipher_info->type; + + switch( type ) + { + case MBEDTLS_CIPHER_AES_128_ECB: + case MBEDTLS_CIPHER_AES_192_ECB: + case MBEDTLS_CIPHER_AES_256_ECB: + case MBEDTLS_CIPHER_DES_EDE3_ECB: + break; + default: + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + /* Allocated and initialise in the cipher context memory for the CMAC + * context */ + cmac_ctx = mbedtls_calloc( 1, sizeof( mbedtls_cmac_context_t ) ); + if( cmac_ctx == NULL ) + return( MBEDTLS_ERR_CIPHER_ALLOC_FAILED ); + + ctx->cmac_ctx = cmac_ctx; + + mbedtls_zeroize( cmac_ctx->state, sizeof( cmac_ctx->state ) ); + + return 0; +} + +int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, + const unsigned char *input, size_t ilen ) +{ + mbedtls_cmac_context_t* cmac_ctx; + unsigned char *state; + int ret = 0; + size_t n, j, olen, block_size; + + if( ctx == NULL || ctx->cipher_info == NULL || input == NULL || + ctx->cmac_ctx == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + cmac_ctx = ctx->cmac_ctx; + block_size = ctx->cipher_info->block_size; + state = ctx->cmac_ctx->state; + + /* Is there data still to process from the last call, that's greater in + * size than a block? */ + if( cmac_ctx->unprocessed_len > 0 && + ilen > block_size - cmac_ctx->unprocessed_len ) + { + memcpy( &cmac_ctx->unprocessed_block[cmac_ctx->unprocessed_len], + input, + block_size - cmac_ctx->unprocessed_len ); + + cmac_xor_block( state, cmac_ctx->unprocessed_block, state, block_size ); + + if( ( ret = mbedtls_cipher_update( ctx, state, block_size, state, + &olen ) ) != 0 ) + { + goto exit; + } + + input += block_size - cmac_ctx->unprocessed_len; + ilen -= block_size - cmac_ctx->unprocessed_len; + cmac_ctx->unprocessed_len = 0; + } + + /* n is the number of blocks including any final partial block */ + n = ( ilen + block_size - 1 ) / block_size; + + /* Iterate across the input data in block sized chunks, excluding any + * final partial or complete block */ + for( j = 1; j < n; j++ ) + { + cmac_xor_block( state, input, state, block_size ); + + if( ( ret = mbedtls_cipher_update( ctx, state, block_size, state, + &olen ) ) != 0 ) + goto exit; + + ilen -= block_size; + input += block_size; + } + + /* If there is data left over that wasn't aligned to a block */ + if( ilen > 0 ) + { + memcpy( &cmac_ctx->unprocessed_block[cmac_ctx->unprocessed_len], + input, + ilen ); + cmac_ctx->unprocessed_len += ilen; + } + +exit: + return( ret ); +} + +int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, + unsigned char *output ) +{ + mbedtls_cmac_context_t* cmac_ctx; + unsigned char *state, *last_block; + unsigned char K1[MBEDTLS_CIPHER_BLKSIZE_MAX]; + unsigned char K2[MBEDTLS_CIPHER_BLKSIZE_MAX]; + unsigned char M_last[MBEDTLS_CIPHER_BLKSIZE_MAX]; + int ret; + size_t olen, block_size; + + if( ctx == NULL || ctx->cipher_info == NULL || ctx->cmac_ctx == NULL || + output == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + cmac_ctx = ctx->cmac_ctx; + block_size = ctx->cipher_info->block_size; + state = cmac_ctx->state; + + mbedtls_zeroize( K1, sizeof( K1 ) ); + mbedtls_zeroize( K2, sizeof( K2 ) ); + cmac_generate_subkeys( ctx, K1, K2 ); + + last_block = cmac_ctx->unprocessed_block; + + /* Calculate last block */ + if( cmac_ctx->unprocessed_len < block_size ) + { + cmac_pad( M_last, block_size, last_block, cmac_ctx->unprocessed_len ); + cmac_xor_block( M_last, M_last, K2, block_size ); + } + else + { + /* Last block is complete block */ + cmac_xor_block( M_last, last_block, K1, block_size ); + } + + + cmac_xor_block( state, M_last, state, block_size ); + if( ( ret = mbedtls_cipher_update( ctx, state, block_size, state, + &olen ) ) != 0 ) + { + goto exit; + } + + memcpy( output, state, block_size ); + +exit: + /* Wipe the generated keys on the stack, and any other transients to avoid + * side channel leakage */ + mbedtls_zeroize( K1, sizeof( K1 ) ); + mbedtls_zeroize( K2, sizeof( K2 ) ); + + cmac_ctx->unprocessed_len = 0; + mbedtls_zeroize( cmac_ctx->unprocessed_block, + sizeof( cmac_ctx->unprocessed_block ) ); + + mbedtls_zeroize( state, MBEDTLS_CIPHER_BLKSIZE_MAX ); + return( ret ); +} + +int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ) +{ + mbedtls_cmac_context_t* cmac_ctx; + + if( ctx == NULL || ctx->cipher_info == NULL || ctx->cmac_ctx == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + cmac_ctx = ctx->cmac_ctx; + + /* Reset the internal state */ + cmac_ctx->unprocessed_len = 0; + mbedtls_zeroize( cmac_ctx->unprocessed_block, + sizeof( cmac_ctx->unprocessed_block ) ); + mbedtls_zeroize( cmac_ctx->state, + sizeof( cmac_ctx->state ) ); + + return( 0 ); +} + +int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, + const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + mbedtls_cipher_context_t ctx; + int ret; + + if( cipher_info == NULL || key == NULL || input == NULL || output == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + mbedtls_cipher_init( &ctx ); + + if( ( ret = mbedtls_cipher_setup( &ctx, cipher_info ) ) != 0 ) + goto exit; + + ret = mbedtls_cipher_cmac_starts( &ctx, key, keylen ); + if( ret != 0 ) + goto exit; + + ret = mbedtls_cipher_cmac_update( &ctx, input, ilen ); + if( ret != 0 ) + goto exit; + + ret = mbedtls_cipher_cmac_finish( &ctx, output ); + +exit: + mbedtls_cipher_free( &ctx ); + + return( ret ); +} + +#if defined(MBEDTLS_AES_C) +/* + * Implementation of AES-CMAC-PRF-128 defined in RFC 4615 + */ +int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_length, + const unsigned char *input, size_t in_len, + unsigned char *output ) +{ + int ret; + const mbedtls_cipher_info_t *cipher_info; + unsigned char zero_key[MBEDTLS_AES_BLOCK_SIZE]; + unsigned char int_key[MBEDTLS_AES_BLOCK_SIZE]; + + if( key == NULL || input == NULL || output == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_ECB ); + if( cipher_info == NULL ) + { + /* Failing at this point must be due to a build issue */ + ret = MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE; + goto exit; + } + + if( key_length == MBEDTLS_AES_BLOCK_SIZE ) + { + /* Use key as is */ + memcpy( int_key, key, MBEDTLS_AES_BLOCK_SIZE ); + } + else + { + memset( zero_key, 0, MBEDTLS_AES_BLOCK_SIZE ); + + ret = mbedtls_cipher_cmac( cipher_info, zero_key, 128, key, + key_length, int_key ); + if( ret != 0 ) + goto exit; + } + + ret = mbedtls_cipher_cmac( cipher_info, int_key, 128, input, in_len, + output ); + +exit: + mbedtls_zeroize( int_key, sizeof( int_key ) ); + + return( ret ); +} +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_SELF_TEST) +/* + * CMAC test data for SP800-38B + * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/AES_CMAC.pdf + * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/TDES_CMAC.pdf + * + * AES-CMAC-PRF-128 test data from RFC 4615 + * https://tools.ietf.org/html/rfc4615#page-4 + */ + +#define NB_CMAC_TESTS_PER_KEY 4 +#define NB_PRF_TESTS 3 + +#if defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) +/* All CMAC test inputs are truncated from the same 64 byte buffer. */ +static const unsigned char test_message[] = { + /* PT */ + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 +}; +#endif /* MBEDTLS_AES_C || MBEDTLS_DES_C */ + +#if defined(MBEDTLS_AES_C) +/* Truncation point of message for AES CMAC tests */ +static const unsigned int aes_message_lengths[NB_CMAC_TESTS_PER_KEY] = { + /* Mlen */ + 0, + 16, + 20, + 64 +}; + +/* CMAC-AES128 Test Data */ +static const unsigned char aes_128_key[16] = { + 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c +}; +static const unsigned char aes_128_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = { + { + /* K1 */ + 0xfb, 0xee, 0xd6, 0x18, 0x35, 0x71, 0x33, 0x66, + 0x7c, 0x85, 0xe0, 0x8f, 0x72, 0x36, 0xa8, 0xde + }, + { + /* K2 */ + 0xf7, 0xdd, 0xac, 0x30, 0x6a, 0xe2, 0x66, 0xcc, + 0xf9, 0x0b, 0xc1, 0x1e, 0xe4, 0x6d, 0x51, 0x3b + } +}; +static const unsigned char aes_128_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = { + { + /* Example #1 */ + 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28, + 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46 + }, + { + /* Example #2 */ + 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44, + 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c + }, + { + /* Example #3 */ + 0x7d, 0x85, 0x44, 0x9e, 0xa6, 0xea, 0x19, 0xc8, + 0x23, 0xa7, 0xbf, 0x78, 0x83, 0x7d, 0xfa, 0xde + }, + { + /* Example #4 */ + 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92, + 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe + } +}; + +/* CMAC-AES192 Test Data */ +static const unsigned char aes_192_key[24] = { + 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b +}; +static const unsigned char aes_192_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = { + { + /* K1 */ + 0x44, 0x8a, 0x5b, 0x1c, 0x93, 0x51, 0x4b, 0x27, + 0x3e, 0xe6, 0x43, 0x9d, 0xd4, 0xda, 0xa2, 0x96 + }, + { + /* K2 */ + 0x89, 0x14, 0xb6, 0x39, 0x26, 0xa2, 0x96, 0x4e, + 0x7d, 0xcc, 0x87, 0x3b, 0xa9, 0xb5, 0x45, 0x2c + } +}; +static const unsigned char aes_192_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = { + { + /* Example #1 */ + 0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5, + 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67 + }, + { + /* Example #2 */ + 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90, + 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84 + }, + { + /* Example #3 */ + 0x3d, 0x75, 0xc1, 0x94, 0xed, 0x96, 0x07, 0x04, + 0x44, 0xa9, 0xfa, 0x7e, 0xc7, 0x40, 0xec, 0xf8 + }, + { + /* Example #4 */ + 0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79, + 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11 + } +}; + +/* CMAC-AES256 Test Data */ +static const unsigned char aes_256_key[32] = { + 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4 +}; +static const unsigned char aes_256_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = { + { + /* K1 */ + 0xca, 0xd1, 0xed, 0x03, 0x29, 0x9e, 0xed, 0xac, + 0x2e, 0x9a, 0x99, 0x80, 0x86, 0x21, 0x50, 0x2f + }, + { + /* K2 */ + 0x95, 0xa3, 0xda, 0x06, 0x53, 0x3d, 0xdb, 0x58, + 0x5d, 0x35, 0x33, 0x01, 0x0c, 0x42, 0xa0, 0xd9 + } +}; +static const unsigned char aes_256_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = { + { + /* Example #1 */ + 0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e, + 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83 + }, + { + /* Example #2 */ + 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82, + 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c + }, + { + /* Example #3 */ + 0x15, 0x67, 0x27, 0xdc, 0x08, 0x78, 0x94, 0x4a, + 0x02, 0x3c, 0x1f, 0xe0, 0x3b, 0xad, 0x6d, 0x93 + }, + { + /* Example #4 */ + 0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5, + 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10 + } +}; +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_DES_C) +/* Truncation point of message for 3DES CMAC tests */ +static const unsigned int des3_message_lengths[NB_CMAC_TESTS_PER_KEY] = { + 0, + 16, + 20, + 32 +}; + +/* CMAC-TDES (Generation) - 2 Key Test Data */ +static const unsigned char des3_2key_key[24] = { + /* Key1 */ + 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + /* Key2 */ + 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xEF, 0x01, + /* Key3 */ + 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef +}; +static const unsigned char des3_2key_subkeys[2][8] = { + { + /* K1 */ + 0x0d, 0xd2, 0xcb, 0x7a, 0x3d, 0x88, 0x88, 0xd9 + }, + { + /* K2 */ + 0x1b, 0xa5, 0x96, 0xf4, 0x7b, 0x11, 0x11, 0xb2 + } +}; +static const unsigned char des3_2key_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_DES3_BLOCK_SIZE] = { + { + /* Sample #1 */ + 0x79, 0xce, 0x52, 0xa7, 0xf7, 0x86, 0xa9, 0x60 + }, + { + /* Sample #2 */ + 0xcc, 0x18, 0xa0, 0xb7, 0x9a, 0xf2, 0x41, 0x3b + }, + { + /* Sample #3 */ + 0xc0, 0x6d, 0x37, 0x7e, 0xcd, 0x10, 0x19, 0x69 + }, + { + /* Sample #4 */ + 0x9c, 0xd3, 0x35, 0x80, 0xf9, 0xb6, 0x4d, 0xfb + } +}; + +/* CMAC-TDES (Generation) - 3 Key Test Data */ +static const unsigned char des3_3key_key[24] = { + /* Key1 */ + 0x01, 0x23, 0x45, 0x67, 0x89, 0xaa, 0xcd, 0xef, + /* Key2 */ + 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, + /* Key3 */ + 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23 +}; +static const unsigned char des3_3key_subkeys[2][8] = { + { + /* K1 */ + 0x9d, 0x74, 0xe7, 0x39, 0x33, 0x17, 0x96, 0xc0 + }, + { + /* K2 */ + 0x3a, 0xe9, 0xce, 0x72, 0x66, 0x2f, 0x2d, 0x9b + } +}; +static const unsigned char des3_3key_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_DES3_BLOCK_SIZE] = { + { + /* Sample #1 */ + 0x7d, 0xb0, 0xd3, 0x7d, 0xf9, 0x36, 0xc5, 0x50 + }, + { + /* Sample #2 */ + 0x30, 0x23, 0x9c, 0xf1, 0xf5, 0x2e, 0x66, 0x09 + }, + { + /* Sample #3 */ + 0x6c, 0x9f, 0x3e, 0xe4, 0x92, 0x3f, 0x6b, 0xe2 + }, + { + /* Sample #4 */ + 0x99, 0x42, 0x9b, 0xd0, 0xbF, 0x79, 0x04, 0xe5 + } +}; + +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_AES_C) +/* AES AES-CMAC-PRF-128 Test Data */ +static const unsigned char PRFK[] = { + /* Key */ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0xed, 0xcb +}; + +/* Sizes in bytes */ +static const size_t PRFKlen[NB_PRF_TESTS] = { + 18, + 16, + 10 +}; + +/* Message */ +static const unsigned char PRFM[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13 +}; + +static const unsigned char PRFT[NB_PRF_TESTS][16] = { + { + 0x84, 0xa3, 0x48, 0xa4, 0xa4, 0x5d, 0x23, 0x5b, + 0xab, 0xff, 0xfc, 0x0d, 0x2b, 0x4d, 0xa0, 0x9a + }, + { + 0x98, 0x0a, 0xe8, 0x7b, 0x5f, 0x4c, 0x9c, 0x52, + 0x14, 0xf5, 0xb6, 0xa8, 0x45, 0x5e, 0x4c, 0x2d + }, + { + 0x29, 0x0d, 0x9e, 0x11, 0x2e, 0xdb, 0x09, 0xee, + 0x14, 0x1f, 0xcf, 0x64, 0xc0, 0xb7, 0x2f, 0x3d + } +}; +#endif /* MBEDTLS_AES_C */ + +static int cmac_test_subkeys( int verbose, + const char* testname, + const unsigned char* key, + int keybits, + const unsigned char* subkeys, + mbedtls_cipher_type_t cipher_type, + int block_size, + int num_tests ) +{ + int i, ret; + mbedtls_cipher_context_t ctx; + const mbedtls_cipher_info_t *cipher_info; + unsigned char K1[MBEDTLS_CIPHER_BLKSIZE_MAX]; + unsigned char K2[MBEDTLS_CIPHER_BLKSIZE_MAX]; + + cipher_info = mbedtls_cipher_info_from_type( cipher_type ); + if( cipher_info == NULL ) + { + /* Failing at this point must be due to a build issue */ + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); + } + + for( i = 0; i < num_tests; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " %s CMAC subkey #%u: ", testname, i + 1 ); + + mbedtls_cipher_init( &ctx ); + + if( ( ret = mbedtls_cipher_setup( &ctx, cipher_info ) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "test execution failed\n" ); + + goto cleanup; + } + + if( ( ret = mbedtls_cipher_setkey( &ctx, key, keybits, + MBEDTLS_ENCRYPT ) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "test execution failed\n" ); + + goto cleanup; + } + + ret = cmac_generate_subkeys( &ctx, K1, K2 ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + goto cleanup; + } + + if( ( ret = memcmp( K1, subkeys, block_size ) ) != 0 || + ( ret = memcmp( K2, &subkeys[block_size], block_size ) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + goto cleanup; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + mbedtls_cipher_free( &ctx ); + } + + goto exit; + +cleanup: + mbedtls_cipher_free( &ctx ); + +exit: + return( ret ); +} + +static int cmac_test_wth_cipher( int verbose, + const char* testname, + const unsigned char* key, + int keybits, + const unsigned char* messages, + const unsigned int message_lengths[4], + const unsigned char* expected_result, + mbedtls_cipher_type_t cipher_type, + int block_size, + int num_tests ) +{ + const mbedtls_cipher_info_t *cipher_info; + int i, ret; + unsigned char output[MBEDTLS_CIPHER_BLKSIZE_MAX]; + + cipher_info = mbedtls_cipher_info_from_type( cipher_type ); + if( cipher_info == NULL ) + { + /* Failing at this point must be due to a build issue */ + ret = MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE; + goto exit; + } + + for( i = 0; i < num_tests; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " %s CMAC #%u: ", testname, i + 1 ); + + if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, messages, + message_lengths[i], output ) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + goto exit; + } + + if( ( ret = memcmp( output, &expected_result[i * block_size], block_size ) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + +exit: + return( ret ); +} + +#if defined(MBEDTLS_AES_C) +static int test_aes128_cmac_prf( int verbose ) +{ + int i; + int ret; + unsigned char output[MBEDTLS_AES_BLOCK_SIZE]; + + for( i = 0; i < NB_PRF_TESTS; i++ ) + { + mbedtls_printf( " AES CMAC 128 PRF #%u: ", i ); + ret = mbedtls_aes_cmac_prf_128( PRFK, PRFKlen[i], PRFM, 20, output ); + if( ret != 0 || + memcmp( output, PRFT[i], MBEDTLS_AES_BLOCK_SIZE ) != 0 ) + { + + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( ret ); + } + else if( verbose != 0 ) + { + mbedtls_printf( "passed\n" ); + } + } + return( ret ); +} +#endif /* MBEDTLS_AES_C */ + +int mbedtls_cmac_self_test( int verbose ) +{ + int ret; + +#if defined(MBEDTLS_AES_C) + /* AES-128 */ + if( ( ret = cmac_test_subkeys( verbose, + "AES 128", + aes_128_key, + 128, + (const unsigned char*)aes_128_subkeys, + MBEDTLS_CIPHER_AES_128_ECB, + MBEDTLS_AES_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = cmac_test_wth_cipher( verbose, + "AES 128", + aes_128_key, + 128, + test_message, + aes_message_lengths, + (const unsigned char*)aes_128_expected_result, + MBEDTLS_CIPHER_AES_128_ECB, + MBEDTLS_AES_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + /* AES-192 */ + if( ( ret = cmac_test_subkeys( verbose, + "AES 192", + aes_192_key, + 192, + (const unsigned char*)aes_192_subkeys, + MBEDTLS_CIPHER_AES_192_ECB, + MBEDTLS_AES_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = cmac_test_wth_cipher( verbose, + "AES 192", + aes_192_key, + 192, + test_message, + aes_message_lengths, + (const unsigned char*)aes_192_expected_result, + MBEDTLS_CIPHER_AES_192_ECB, + MBEDTLS_AES_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + /* AES-256 */ + if( ( ret = cmac_test_subkeys( verbose, + "AES 256", + aes_256_key, + 256, + (const unsigned char*)aes_256_subkeys, + MBEDTLS_CIPHER_AES_256_ECB, + MBEDTLS_AES_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = cmac_test_wth_cipher ( verbose, + "AES 256", + aes_256_key, + 256, + test_message, + aes_message_lengths, + (const unsigned char*)aes_256_expected_result, + MBEDTLS_CIPHER_AES_256_ECB, + MBEDTLS_AES_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_DES_C) + /* 3DES 2 key */ + if( ( ret = cmac_test_subkeys( verbose, + "3DES 2 key", + des3_2key_key, + 192, + (const unsigned char*)des3_2key_subkeys, + MBEDTLS_CIPHER_DES_EDE3_ECB, + MBEDTLS_DES3_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = cmac_test_wth_cipher( verbose, + "3DES 2 key", + des3_2key_key, + 192, + test_message, + des3_message_lengths, + (const unsigned char*)des3_2key_expected_result, + MBEDTLS_CIPHER_DES_EDE3_ECB, + MBEDTLS_DES3_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + /* 3DES 3 key */ + if( ( ret = cmac_test_subkeys( verbose, + "3DES 3 key", + des3_3key_key, + 192, + (const unsigned char*)des3_3key_subkeys, + MBEDTLS_CIPHER_DES_EDE3_ECB, + MBEDTLS_DES3_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = cmac_test_wth_cipher( verbose, + "3DES 3 key", + des3_3key_key, + 192, + test_message, + des3_message_lengths, + (const unsigned char*)des3_3key_expected_result, + MBEDTLS_CIPHER_DES_EDE3_ECB, + MBEDTLS_DES3_BLOCK_SIZE, + NB_CMAC_TESTS_PER_KEY ) ) != 0 ) + { + return( ret ); + } +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_AES_C) + if( ( ret = test_aes128_cmac_prf( verbose ) ) != 0 ) + return( ret ); +#endif /* MBEDTLS_AES_C */ + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_CMAC_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ctr_drbg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ctr_drbg.c new file mode 100644 index 0000000..55612c7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ctr_drbg.c @@ -0,0 +1,594 @@ +/* + * CTR_DRBG implementation based on AES-256 (NIST SP 800-90) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The NIST SP 800-90 DRBGs are described in the following publucation. + * + * http://csrc.nist.gov/publications/nistpubs/800-90/SP800-90revised_March2007.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CTR_DRBG_C) + +#include "mbedtls/ctr_drbg.h" + +#include + +#if defined(MBEDTLS_FS_IO) +#include +#endif + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * CTR_DRBG context initialization + */ +void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_ctr_drbg_context ) ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &ctx->mutex ); +#endif +} + +/* + * Non-public function wrapped by mbedtls_ctr_drbg_seed(). Necessary to allow + * NIST tests to succeed (which require known length fixed entropy) + */ +int mbedtls_ctr_drbg_seed_entropy_len( + mbedtls_ctr_drbg_context *ctx, + int (*f_entropy)(void *, unsigned char *, size_t), + void *p_entropy, + const unsigned char *custom, + size_t len, + size_t entropy_len ) +{ + int ret; + unsigned char key[MBEDTLS_CTR_DRBG_KEYSIZE]; + + memset( key, 0, MBEDTLS_CTR_DRBG_KEYSIZE ); + + mbedtls_aes_init( &ctx->aes_ctx ); + + ctx->f_entropy = f_entropy; + ctx->p_entropy = p_entropy; + + ctx->entropy_len = entropy_len; + ctx->reseed_interval = MBEDTLS_CTR_DRBG_RESEED_INTERVAL; + + /* + * Initialize with an empty key + */ + mbedtls_aes_setkey_enc( &ctx->aes_ctx, key, MBEDTLS_CTR_DRBG_KEYBITS ); + + if( ( ret = mbedtls_ctr_drbg_reseed( ctx, custom, len ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx, + int (*f_entropy)(void *, unsigned char *, size_t), + void *p_entropy, + const unsigned char *custom, + size_t len ) +{ + return( mbedtls_ctr_drbg_seed_entropy_len( ctx, f_entropy, p_entropy, custom, len, + MBEDTLS_CTR_DRBG_ENTROPY_LEN ) ); +} + +void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx ) +{ + if( ctx == NULL ) + return; + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &ctx->mutex ); +#endif + mbedtls_aes_free( &ctx->aes_ctx ); + mbedtls_zeroize( ctx, sizeof( mbedtls_ctr_drbg_context ) ); +} + +void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx, int resistance ) +{ + ctx->prediction_resistance = resistance; +} + +void mbedtls_ctr_drbg_set_entropy_len( mbedtls_ctr_drbg_context *ctx, size_t len ) +{ + ctx->entropy_len = len; +} + +void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx, int interval ) +{ + ctx->reseed_interval = interval; +} + +static int block_cipher_df( unsigned char *output, + const unsigned char *data, size_t data_len ) +{ + unsigned char buf[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT + MBEDTLS_CTR_DRBG_BLOCKSIZE + 16]; + unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN]; + unsigned char key[MBEDTLS_CTR_DRBG_KEYSIZE]; + unsigned char chain[MBEDTLS_CTR_DRBG_BLOCKSIZE]; + unsigned char *p, *iv; + mbedtls_aes_context aes_ctx; + + int i, j; + size_t buf_len, use_len; + + if( data_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ) + return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG ); + + memset( buf, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT + MBEDTLS_CTR_DRBG_BLOCKSIZE + 16 ); + mbedtls_aes_init( &aes_ctx ); + + /* + * Construct IV (16 bytes) and S in buffer + * IV = Counter (in 32-bits) padded to 16 with zeroes + * S = Length input string (in 32-bits) || Length of output (in 32-bits) || + * data || 0x80 + * (Total is padded to a multiple of 16-bytes with zeroes) + */ + p = buf + MBEDTLS_CTR_DRBG_BLOCKSIZE; + *p++ = ( data_len >> 24 ) & 0xff; + *p++ = ( data_len >> 16 ) & 0xff; + *p++ = ( data_len >> 8 ) & 0xff; + *p++ = ( data_len ) & 0xff; + p += 3; + *p++ = MBEDTLS_CTR_DRBG_SEEDLEN; + memcpy( p, data, data_len ); + p[data_len] = 0x80; + + buf_len = MBEDTLS_CTR_DRBG_BLOCKSIZE + 8 + data_len + 1; + + for( i = 0; i < MBEDTLS_CTR_DRBG_KEYSIZE; i++ ) + key[i] = i; + + mbedtls_aes_setkey_enc( &aes_ctx, key, MBEDTLS_CTR_DRBG_KEYBITS ); + + /* + * Reduce data to MBEDTLS_CTR_DRBG_SEEDLEN bytes of data + */ + for( j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE ) + { + p = buf; + memset( chain, 0, MBEDTLS_CTR_DRBG_BLOCKSIZE ); + use_len = buf_len; + + while( use_len > 0 ) + { + for( i = 0; i < MBEDTLS_CTR_DRBG_BLOCKSIZE; i++ ) + chain[i] ^= p[i]; + p += MBEDTLS_CTR_DRBG_BLOCKSIZE; + use_len -= ( use_len >= MBEDTLS_CTR_DRBG_BLOCKSIZE ) ? + MBEDTLS_CTR_DRBG_BLOCKSIZE : use_len; + + mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, chain, chain ); + } + + memcpy( tmp + j, chain, MBEDTLS_CTR_DRBG_BLOCKSIZE ); + + /* + * Update IV + */ + buf[3]++; + } + + /* + * Do final encryption with reduced data + */ + mbedtls_aes_setkey_enc( &aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS ); + iv = tmp + MBEDTLS_CTR_DRBG_KEYSIZE; + p = output; + + for( j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE ) + { + mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + memcpy( p, iv, MBEDTLS_CTR_DRBG_BLOCKSIZE ); + p += MBEDTLS_CTR_DRBG_BLOCKSIZE; + } + + mbedtls_aes_free( &aes_ctx ); + + return( 0 ); +} + +static int ctr_drbg_update_internal( mbedtls_ctr_drbg_context *ctx, + const unsigned char data[MBEDTLS_CTR_DRBG_SEEDLEN] ) +{ + unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN]; + unsigned char *p = tmp; + int i, j; + + memset( tmp, 0, MBEDTLS_CTR_DRBG_SEEDLEN ); + + for( j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE ) + { + /* + * Increase counter + */ + for( i = MBEDTLS_CTR_DRBG_BLOCKSIZE; i > 0; i-- ) + if( ++ctx->counter[i - 1] != 0 ) + break; + + /* + * Crypt counter block + */ + mbedtls_aes_crypt_ecb( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->counter, p ); + + p += MBEDTLS_CTR_DRBG_BLOCKSIZE; + } + + for( i = 0; i < MBEDTLS_CTR_DRBG_SEEDLEN; i++ ) + tmp[i] ^= data[i]; + + /* + * Update key and counter + */ + mbedtls_aes_setkey_enc( &ctx->aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS ); + memcpy( ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE, MBEDTLS_CTR_DRBG_BLOCKSIZE ); + + return( 0 ); +} + +void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, + const unsigned char *additional, size_t add_len ) +{ + unsigned char add_input[MBEDTLS_CTR_DRBG_SEEDLEN]; + + if( add_len > 0 ) + { + /* MAX_INPUT would be more logical here, but we have to match + * block_cipher_df()'s limits since we can't propagate errors */ + if( add_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ) + add_len = MBEDTLS_CTR_DRBG_MAX_SEED_INPUT; + + block_cipher_df( add_input, additional, add_len ); + ctr_drbg_update_internal( ctx, add_input ); + } +} + +int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx, + const unsigned char *additional, size_t len ) +{ + unsigned char seed[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT]; + size_t seedlen = 0; + + if( ctx->entropy_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT || + len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - ctx->entropy_len ) + return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG ); + + memset( seed, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ); + + /* + * Gather entropy_len bytes of entropy to seed state + */ + if( 0 != ctx->f_entropy( ctx->p_entropy, seed, + ctx->entropy_len ) ) + { + return( MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED ); + } + + seedlen += ctx->entropy_len; + + /* + * Add additional data + */ + if( additional && len ) + { + memcpy( seed + seedlen, additional, len ); + seedlen += len; + } + + /* + * Reduce to 384 bits + */ + block_cipher_df( seed, seed, seedlen ); + + /* + * Update state + */ + ctr_drbg_update_internal( ctx, seed ); + ctx->reseed_counter = 1; + + return( 0 ); +} + +int mbedtls_ctr_drbg_random_with_add( void *p_rng, + unsigned char *output, size_t output_len, + const unsigned char *additional, size_t add_len ) +{ + int ret = 0; + mbedtls_ctr_drbg_context *ctx = (mbedtls_ctr_drbg_context *) p_rng; + unsigned char add_input[MBEDTLS_CTR_DRBG_SEEDLEN]; + unsigned char *p = output; + unsigned char tmp[MBEDTLS_CTR_DRBG_BLOCKSIZE]; + int i; + size_t use_len; + + if( output_len > MBEDTLS_CTR_DRBG_MAX_REQUEST ) + return( MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG ); + + if( add_len > MBEDTLS_CTR_DRBG_MAX_INPUT ) + return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG ); + + memset( add_input, 0, MBEDTLS_CTR_DRBG_SEEDLEN ); + + if( ctx->reseed_counter > ctx->reseed_interval || + ctx->prediction_resistance ) + { + if( ( ret = mbedtls_ctr_drbg_reseed( ctx, additional, add_len ) ) != 0 ) + return( ret ); + + add_len = 0; + } + + if( add_len > 0 ) + { + block_cipher_df( add_input, additional, add_len ); + ctr_drbg_update_internal( ctx, add_input ); + } + + while( output_len > 0 ) + { + /* + * Increase counter + */ + for( i = MBEDTLS_CTR_DRBG_BLOCKSIZE; i > 0; i-- ) + if( ++ctx->counter[i - 1] != 0 ) + break; + + /* + * Crypt counter block + */ + mbedtls_aes_crypt_ecb( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->counter, tmp ); + + use_len = ( output_len > MBEDTLS_CTR_DRBG_BLOCKSIZE ) ? MBEDTLS_CTR_DRBG_BLOCKSIZE : + output_len; + /* + * Copy random block to destination + */ + memcpy( p, tmp, use_len ); + p += use_len; + output_len -= use_len; + } + + ctr_drbg_update_internal( ctx, add_input ); + + ctx->reseed_counter++; + + return( 0 ); +} + +int mbedtls_ctr_drbg_random( void *p_rng, unsigned char *output, size_t output_len ) +{ + int ret; + mbedtls_ctr_drbg_context *ctx = (mbedtls_ctr_drbg_context *) p_rng; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + ret = mbedtls_ctr_drbg_random_with_add( ctx, output, output_len, NULL, 0 ); + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +#if defined(MBEDTLS_FS_IO) +int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ) +{ + int ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR; + FILE *f; + unsigned char buf[ MBEDTLS_CTR_DRBG_MAX_INPUT ]; + + if( ( f = fopen( path, "wb" ) ) == NULL ) + return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR ); + + if( ( ret = mbedtls_ctr_drbg_random( ctx, buf, MBEDTLS_CTR_DRBG_MAX_INPUT ) ) != 0 ) + goto exit; + + if( fwrite( buf, 1, MBEDTLS_CTR_DRBG_MAX_INPUT, f ) != MBEDTLS_CTR_DRBG_MAX_INPUT ) + { + ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR; + goto exit; + } + + ret = 0; + +exit: + fclose( f ); + return( ret ); +} + +int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ) +{ + FILE *f; + size_t n; + unsigned char buf[ MBEDTLS_CTR_DRBG_MAX_INPUT ]; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR ); + + fseek( f, 0, SEEK_END ); + n = (size_t) ftell( f ); + fseek( f, 0, SEEK_SET ); + + if( n > MBEDTLS_CTR_DRBG_MAX_INPUT ) + { + fclose( f ); + return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG ); + } + + if( fread( buf, 1, n, f ) != n ) + { + fclose( f ); + return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR ); + } + + fclose( f ); + + mbedtls_ctr_drbg_update( ctx, buf, n ); + + return( mbedtls_ctr_drbg_write_seed_file( ctx, path ) ); +} +#endif /* MBEDTLS_FS_IO */ + +#if defined(MBEDTLS_SELF_TEST) + +static const unsigned char entropy_source_pr[96] = + { 0xc1, 0x80, 0x81, 0xa6, 0x5d, 0x44, 0x02, 0x16, + 0x19, 0xb3, 0xf1, 0x80, 0xb1, 0xc9, 0x20, 0x02, + 0x6a, 0x54, 0x6f, 0x0c, 0x70, 0x81, 0x49, 0x8b, + 0x6e, 0xa6, 0x62, 0x52, 0x6d, 0x51, 0xb1, 0xcb, + 0x58, 0x3b, 0xfa, 0xd5, 0x37, 0x5f, 0xfb, 0xc9, + 0xff, 0x46, 0xd2, 0x19, 0xc7, 0x22, 0x3e, 0x95, + 0x45, 0x9d, 0x82, 0xe1, 0xe7, 0x22, 0x9f, 0x63, + 0x31, 0x69, 0xd2, 0x6b, 0x57, 0x47, 0x4f, 0xa3, + 0x37, 0xc9, 0x98, 0x1c, 0x0b, 0xfb, 0x91, 0x31, + 0x4d, 0x55, 0xb9, 0xe9, 0x1c, 0x5a, 0x5e, 0xe4, + 0x93, 0x92, 0xcf, 0xc5, 0x23, 0x12, 0xd5, 0x56, + 0x2c, 0x4a, 0x6e, 0xff, 0xdc, 0x10, 0xd0, 0x68 }; + +static const unsigned char entropy_source_nopr[64] = + { 0x5a, 0x19, 0x4d, 0x5e, 0x2b, 0x31, 0x58, 0x14, + 0x54, 0xde, 0xf6, 0x75, 0xfb, 0x79, 0x58, 0xfe, + 0xc7, 0xdb, 0x87, 0x3e, 0x56, 0x89, 0xfc, 0x9d, + 0x03, 0x21, 0x7c, 0x68, 0xd8, 0x03, 0x38, 0x20, + 0xf9, 0xe6, 0x5e, 0x04, 0xd8, 0x56, 0xf3, 0xa9, + 0xc4, 0x4a, 0x4c, 0xbd, 0xc1, 0xd0, 0x08, 0x46, + 0xf5, 0x98, 0x3d, 0x77, 0x1c, 0x1b, 0x13, 0x7e, + 0x4e, 0x0f, 0x9d, 0x8e, 0xf4, 0x09, 0xf9, 0x2e }; + +static const unsigned char nonce_pers_pr[16] = + { 0xd2, 0x54, 0xfc, 0xff, 0x02, 0x1e, 0x69, 0xd2, + 0x29, 0xc9, 0xcf, 0xad, 0x85, 0xfa, 0x48, 0x6c }; + +static const unsigned char nonce_pers_nopr[16] = + { 0x1b, 0x54, 0xb8, 0xff, 0x06, 0x42, 0xbf, 0xf5, + 0x21, 0xf1, 0x5c, 0x1c, 0x0b, 0x66, 0x5f, 0x3f }; + +static const unsigned char result_pr[16] = + { 0x34, 0x01, 0x16, 0x56, 0xb4, 0x29, 0x00, 0x8f, + 0x35, 0x63, 0xec, 0xb5, 0xf2, 0x59, 0x07, 0x23 }; + +static const unsigned char result_nopr[16] = + { 0xa0, 0x54, 0x30, 0x3d, 0x8a, 0x7e, 0xa9, 0x88, + 0x9d, 0x90, 0x3e, 0x07, 0x7c, 0x6f, 0x21, 0x8f }; + +static size_t test_offset; +static int ctr_drbg_self_test_entropy( void *data, unsigned char *buf, + size_t len ) +{ + const unsigned char *p = data; + memcpy( buf, p + test_offset, len ); + test_offset += len; + return( 0 ); +} + +#define CHK( c ) if( (c) != 0 ) \ + { \ + if( verbose != 0 ) \ + mbedtls_printf( "failed\n" ); \ + return( 1 ); \ + } + +/* + * Checkup routine + */ +int mbedtls_ctr_drbg_self_test( int verbose ) +{ + mbedtls_ctr_drbg_context ctx; + unsigned char buf[16]; + + mbedtls_ctr_drbg_init( &ctx ); + + /* + * Based on a NIST CTR_DRBG test vector (PR = True) + */ + if( verbose != 0 ) + mbedtls_printf( " CTR_DRBG (PR = TRUE) : " ); + + test_offset = 0; + CHK( mbedtls_ctr_drbg_seed_entropy_len( &ctx, ctr_drbg_self_test_entropy, + (void *) entropy_source_pr, nonce_pers_pr, 16, 32 ) ); + mbedtls_ctr_drbg_set_prediction_resistance( &ctx, MBEDTLS_CTR_DRBG_PR_ON ); + CHK( mbedtls_ctr_drbg_random( &ctx, buf, MBEDTLS_CTR_DRBG_BLOCKSIZE ) ); + CHK( mbedtls_ctr_drbg_random( &ctx, buf, MBEDTLS_CTR_DRBG_BLOCKSIZE ) ); + CHK( memcmp( buf, result_pr, MBEDTLS_CTR_DRBG_BLOCKSIZE ) ); + + mbedtls_ctr_drbg_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + /* + * Based on a NIST CTR_DRBG test vector (PR = FALSE) + */ + if( verbose != 0 ) + mbedtls_printf( " CTR_DRBG (PR = FALSE): " ); + + mbedtls_ctr_drbg_init( &ctx ); + + test_offset = 0; + CHK( mbedtls_ctr_drbg_seed_entropy_len( &ctx, ctr_drbg_self_test_entropy, + (void *) entropy_source_nopr, nonce_pers_nopr, 16, 32 ) ); + CHK( mbedtls_ctr_drbg_random( &ctx, buf, 16 ) ); + CHK( mbedtls_ctr_drbg_reseed( &ctx, NULL, 0 ) ); + CHK( mbedtls_ctr_drbg_random( &ctx, buf, 16 ) ); + CHK( memcmp( buf, result_nopr, 16 ) ); + + mbedtls_ctr_drbg_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/debug.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/debug.c new file mode 100644 index 0000000..f9229b3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/debug.c @@ -0,0 +1,368 @@ +/* + * Debugging routines + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_DEBUG_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#define mbedtls_time_t time_t +#define mbedtls_snprintf snprintf +#endif + +#include "mbedtls/debug.h" + +#include +#include +#include + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +#define DEBUG_BUF_SIZE 512 + +static int debug_threshold = 0; + +void mbedtls_debug_set_threshold( int threshold ) +{ + debug_threshold = threshold; +} + +/* + * All calls to f_dbg must be made via this function + */ +static inline void debug_send_line( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *str ) +{ + /* + * If in a threaded environment, we need a thread identifier. + * Since there is no portable way to get one, use the address of the ssl + * context instead, as it shouldn't be shared between threads. + */ +#if defined(MBEDTLS_THREADING_C) + char idstr[20 + DEBUG_BUF_SIZE]; /* 0x + 16 nibbles + ': ' */ + mbedtls_snprintf( idstr, sizeof( idstr ), "%p: %s", (void*)ssl, str ); + ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, idstr ); +#else + ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str ); +#endif +} + +void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *format, ... ) +{ + va_list argp; + char str[DEBUG_BUF_SIZE]; + int ret; + + if( NULL == ssl || NULL == ssl->conf || NULL == ssl->conf->f_dbg || level > debug_threshold ) + return; + + va_start( argp, format ); +#if defined(_WIN32) +#if defined(_TRUNCATE) + ret = _vsnprintf_s( str, DEBUG_BUF_SIZE, _TRUNCATE, format, argp ); +#else + ret = _vsnprintf( str, DEBUG_BUF_SIZE, format, argp ); + if( ret < 0 || (size_t) ret == DEBUG_BUF_SIZE ) + { + str[DEBUG_BUF_SIZE-1] = '\0'; + ret = -1; + } +#endif +#else + ret = vsnprintf( str, DEBUG_BUF_SIZE, format, argp ); +#endif + va_end( argp ); + + if( ret >= 0 && ret < DEBUG_BUF_SIZE - 1 ) + { + str[ret] = '\n'; + str[ret + 1] = '\0'; + } + + debug_send_line( ssl, level, file, line, str ); +} + +void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, int ret ) +{ + char str[DEBUG_BUF_SIZE]; + + if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + return; + + /* + * With non-blocking I/O and examples that just retry immediately, + * the logs would be quickly flooded with WANT_READ, so ignore that. + * Don't ignore WANT_WRITE however, since is is usually rare. + */ + if( ret == MBEDTLS_ERR_SSL_WANT_READ ) + return; + + mbedtls_snprintf( str, sizeof( str ), "%s() returned %d (-0x%04x)\n", + text, ret, -ret ); + + debug_send_line( ssl, level, file, line, str ); +} + +void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, const char *text, + const unsigned char *buf, size_t len ) +{ + char str[DEBUG_BUF_SIZE]; + char txt[17]; + size_t i, idx = 0; + + if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + return; + + mbedtls_snprintf( str + idx, sizeof( str ) - idx, "dumping '%s' (%u bytes)\n", + text, (unsigned int) len ); + + debug_send_line( ssl, level, file, line, str ); + + idx = 0; + memset( txt, 0, sizeof( txt ) ); + for( i = 0; i < len; i++ ) + { + if( i >= 4096 ) + break; + + if( i % 16 == 0 ) + { + if( i > 0 ) + { + mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %s\n", txt ); + debug_send_line( ssl, level, file, line, str ); + + idx = 0; + memset( txt, 0, sizeof( txt ) ); + } + + idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, "%04x: ", + (unsigned int) i ); + + } + + idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x", + (unsigned int) buf[i] ); + txt[i % 16] = ( buf[i] > 31 && buf[i] < 127 ) ? buf[i] : '.' ; + } + + if( len > 0 ) + { + for( /* i = i */; i % 16 != 0; i++ ) + idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " " ); + + mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %s\n", txt ); + debug_send_line( ssl, level, file, line, str ); + } +} + +#if defined(MBEDTLS_ECP_C) +void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_ecp_point *X ) +{ + char str[DEBUG_BUF_SIZE]; + + if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + return; + + mbedtls_snprintf( str, sizeof( str ), "%s(X)", text ); + mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->X ); + + mbedtls_snprintf( str, sizeof( str ), "%s(Y)", text ); + mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->Y ); +} +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_BIGNUM_C) +void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_mpi *X ) +{ + char str[DEBUG_BUF_SIZE]; + int j, k, zeros = 1; + size_t i, n, idx = 0; + + if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || X == NULL || level > debug_threshold ) + return; + + for( n = X->n - 1; n > 0; n-- ) + if( X->p[n] != 0 ) + break; + + for( j = ( sizeof(mbedtls_mpi_uint) << 3 ) - 1; j >= 0; j-- ) + if( ( ( X->p[n] >> j ) & 1 ) != 0 ) + break; + + mbedtls_snprintf( str + idx, sizeof( str ) - idx, "value of '%s' (%d bits) is:\n", + text, (int) ( ( n * ( sizeof(mbedtls_mpi_uint) << 3 ) ) + j + 1 ) ); + + debug_send_line( ssl, level, file, line, str ); + + idx = 0; + for( i = n + 1, j = 0; i > 0; i-- ) + { + if( zeros && X->p[i - 1] == 0 ) + continue; + + for( k = sizeof( mbedtls_mpi_uint ) - 1; k >= 0; k-- ) + { + if( zeros && ( ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ) == 0 ) + continue; + else + zeros = 0; + + if( j % 16 == 0 ) + { + if( j > 0 ) + { + mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" ); + debug_send_line( ssl, level, file, line, str ); + idx = 0; + } + } + + idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x", (unsigned int) + ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ); + + j++; + } + + } + + if( zeros == 1 ) + idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " 00" ); + + mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" ); + debug_send_line( ssl, level, file, line, str ); +} +#endif /* MBEDTLS_BIGNUM_C */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +static void debug_print_pk( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_pk_context *pk ) +{ + size_t i; + mbedtls_pk_debug_item items[MBEDTLS_PK_DEBUG_MAX_ITEMS]; + char name[16]; + + memset( items, 0, sizeof( items ) ); + + if( mbedtls_pk_debug( pk, items ) != 0 ) + { + debug_send_line( ssl, level, file, line, + "invalid PK context\n" ); + return; + } + + for( i = 0; i < MBEDTLS_PK_DEBUG_MAX_ITEMS; i++ ) + { + if( items[i].type == MBEDTLS_PK_DEBUG_NONE ) + return; + + mbedtls_snprintf( name, sizeof( name ), "%s%s", text, items[i].name ); + name[sizeof( name ) - 1] = '\0'; + + if( items[i].type == MBEDTLS_PK_DEBUG_MPI ) + mbedtls_debug_print_mpi( ssl, level, file, line, name, items[i].value ); + else +#if defined(MBEDTLS_ECP_C) + if( items[i].type == MBEDTLS_PK_DEBUG_ECP ) + mbedtls_debug_print_ecp( ssl, level, file, line, name, items[i].value ); + else +#endif + debug_send_line( ssl, level, file, line, + "should not happen\n" ); + } +} + +static void debug_print_line_by_line( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, const char *text ) +{ + char str[DEBUG_BUF_SIZE]; + const char *start, *cur; + + start = text; + for( cur = text; *cur != '\0'; cur++ ) + { + if( *cur == '\n' ) + { + size_t len = cur - start + 1; + if( len > DEBUG_BUF_SIZE - 1 ) + len = DEBUG_BUF_SIZE - 1; + + memcpy( str, start, len ); + str[len] = '\0'; + + debug_send_line( ssl, level, file, line, str ); + + start = cur + 1; + } + } +} + +void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const char *text, const mbedtls_x509_crt *crt ) +{ + char str[DEBUG_BUF_SIZE]; + int i = 0; + + if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || crt == NULL || level > debug_threshold ) + return; + + while( crt != NULL ) + { + char buf[1024]; + + mbedtls_snprintf( str, sizeof( str ), "%s #%d:\n", text, ++i ); + debug_send_line( ssl, level, file, line, str ); + + mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt ); + debug_print_line_by_line( ssl, level, file, line, buf ); + + debug_print_pk( ssl, level, file, line, "crt->", &crt->pk ); + + crt = crt->next; + } +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#endif /* MBEDTLS_DEBUG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/des.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/des.c new file mode 100644 index 0000000..09f95cf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/des.c @@ -0,0 +1,1061 @@ +/* + * FIPS-46-3 compliant Triple-DES implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * DES, on which TDES is based, was originally designed by Horst Feistel + * at IBM in 1974, and was adopted as a standard by NIST (formerly NBS). + * + * http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_DES_C) + +#include "mbedtls/des.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_DES_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +/* + * Expanded DES S-boxes + */ +static const uint32_t SB1[64] = +{ + 0x01010400, 0x00000000, 0x00010000, 0x01010404, + 0x01010004, 0x00010404, 0x00000004, 0x00010000, + 0x00000400, 0x01010400, 0x01010404, 0x00000400, + 0x01000404, 0x01010004, 0x01000000, 0x00000004, + 0x00000404, 0x01000400, 0x01000400, 0x00010400, + 0x00010400, 0x01010000, 0x01010000, 0x01000404, + 0x00010004, 0x01000004, 0x01000004, 0x00010004, + 0x00000000, 0x00000404, 0x00010404, 0x01000000, + 0x00010000, 0x01010404, 0x00000004, 0x01010000, + 0x01010400, 0x01000000, 0x01000000, 0x00000400, + 0x01010004, 0x00010000, 0x00010400, 0x01000004, + 0x00000400, 0x00000004, 0x01000404, 0x00010404, + 0x01010404, 0x00010004, 0x01010000, 0x01000404, + 0x01000004, 0x00000404, 0x00010404, 0x01010400, + 0x00000404, 0x01000400, 0x01000400, 0x00000000, + 0x00010004, 0x00010400, 0x00000000, 0x01010004 +}; + +static const uint32_t SB2[64] = +{ + 0x80108020, 0x80008000, 0x00008000, 0x00108020, + 0x00100000, 0x00000020, 0x80100020, 0x80008020, + 0x80000020, 0x80108020, 0x80108000, 0x80000000, + 0x80008000, 0x00100000, 0x00000020, 0x80100020, + 0x00108000, 0x00100020, 0x80008020, 0x00000000, + 0x80000000, 0x00008000, 0x00108020, 0x80100000, + 0x00100020, 0x80000020, 0x00000000, 0x00108000, + 0x00008020, 0x80108000, 0x80100000, 0x00008020, + 0x00000000, 0x00108020, 0x80100020, 0x00100000, + 0x80008020, 0x80100000, 0x80108000, 0x00008000, + 0x80100000, 0x80008000, 0x00000020, 0x80108020, + 0x00108020, 0x00000020, 0x00008000, 0x80000000, + 0x00008020, 0x80108000, 0x00100000, 0x80000020, + 0x00100020, 0x80008020, 0x80000020, 0x00100020, + 0x00108000, 0x00000000, 0x80008000, 0x00008020, + 0x80000000, 0x80100020, 0x80108020, 0x00108000 +}; + +static const uint32_t SB3[64] = +{ + 0x00000208, 0x08020200, 0x00000000, 0x08020008, + 0x08000200, 0x00000000, 0x00020208, 0x08000200, + 0x00020008, 0x08000008, 0x08000008, 0x00020000, + 0x08020208, 0x00020008, 0x08020000, 0x00000208, + 0x08000000, 0x00000008, 0x08020200, 0x00000200, + 0x00020200, 0x08020000, 0x08020008, 0x00020208, + 0x08000208, 0x00020200, 0x00020000, 0x08000208, + 0x00000008, 0x08020208, 0x00000200, 0x08000000, + 0x08020200, 0x08000000, 0x00020008, 0x00000208, + 0x00020000, 0x08020200, 0x08000200, 0x00000000, + 0x00000200, 0x00020008, 0x08020208, 0x08000200, + 0x08000008, 0x00000200, 0x00000000, 0x08020008, + 0x08000208, 0x00020000, 0x08000000, 0x08020208, + 0x00000008, 0x00020208, 0x00020200, 0x08000008, + 0x08020000, 0x08000208, 0x00000208, 0x08020000, + 0x00020208, 0x00000008, 0x08020008, 0x00020200 +}; + +static const uint32_t SB4[64] = +{ + 0x00802001, 0x00002081, 0x00002081, 0x00000080, + 0x00802080, 0x00800081, 0x00800001, 0x00002001, + 0x00000000, 0x00802000, 0x00802000, 0x00802081, + 0x00000081, 0x00000000, 0x00800080, 0x00800001, + 0x00000001, 0x00002000, 0x00800000, 0x00802001, + 0x00000080, 0x00800000, 0x00002001, 0x00002080, + 0x00800081, 0x00000001, 0x00002080, 0x00800080, + 0x00002000, 0x00802080, 0x00802081, 0x00000081, + 0x00800080, 0x00800001, 0x00802000, 0x00802081, + 0x00000081, 0x00000000, 0x00000000, 0x00802000, + 0x00002080, 0x00800080, 0x00800081, 0x00000001, + 0x00802001, 0x00002081, 0x00002081, 0x00000080, + 0x00802081, 0x00000081, 0x00000001, 0x00002000, + 0x00800001, 0x00002001, 0x00802080, 0x00800081, + 0x00002001, 0x00002080, 0x00800000, 0x00802001, + 0x00000080, 0x00800000, 0x00002000, 0x00802080 +}; + +static const uint32_t SB5[64] = +{ + 0x00000100, 0x02080100, 0x02080000, 0x42000100, + 0x00080000, 0x00000100, 0x40000000, 0x02080000, + 0x40080100, 0x00080000, 0x02000100, 0x40080100, + 0x42000100, 0x42080000, 0x00080100, 0x40000000, + 0x02000000, 0x40080000, 0x40080000, 0x00000000, + 0x40000100, 0x42080100, 0x42080100, 0x02000100, + 0x42080000, 0x40000100, 0x00000000, 0x42000000, + 0x02080100, 0x02000000, 0x42000000, 0x00080100, + 0x00080000, 0x42000100, 0x00000100, 0x02000000, + 0x40000000, 0x02080000, 0x42000100, 0x40080100, + 0x02000100, 0x40000000, 0x42080000, 0x02080100, + 0x40080100, 0x00000100, 0x02000000, 0x42080000, + 0x42080100, 0x00080100, 0x42000000, 0x42080100, + 0x02080000, 0x00000000, 0x40080000, 0x42000000, + 0x00080100, 0x02000100, 0x40000100, 0x00080000, + 0x00000000, 0x40080000, 0x02080100, 0x40000100 +}; + +static const uint32_t SB6[64] = +{ + 0x20000010, 0x20400000, 0x00004000, 0x20404010, + 0x20400000, 0x00000010, 0x20404010, 0x00400000, + 0x20004000, 0x00404010, 0x00400000, 0x20000010, + 0x00400010, 0x20004000, 0x20000000, 0x00004010, + 0x00000000, 0x00400010, 0x20004010, 0x00004000, + 0x00404000, 0x20004010, 0x00000010, 0x20400010, + 0x20400010, 0x00000000, 0x00404010, 0x20404000, + 0x00004010, 0x00404000, 0x20404000, 0x20000000, + 0x20004000, 0x00000010, 0x20400010, 0x00404000, + 0x20404010, 0x00400000, 0x00004010, 0x20000010, + 0x00400000, 0x20004000, 0x20000000, 0x00004010, + 0x20000010, 0x20404010, 0x00404000, 0x20400000, + 0x00404010, 0x20404000, 0x00000000, 0x20400010, + 0x00000010, 0x00004000, 0x20400000, 0x00404010, + 0x00004000, 0x00400010, 0x20004010, 0x00000000, + 0x20404000, 0x20000000, 0x00400010, 0x20004010 +}; + +static const uint32_t SB7[64] = +{ + 0x00200000, 0x04200002, 0x04000802, 0x00000000, + 0x00000800, 0x04000802, 0x00200802, 0x04200800, + 0x04200802, 0x00200000, 0x00000000, 0x04000002, + 0x00000002, 0x04000000, 0x04200002, 0x00000802, + 0x04000800, 0x00200802, 0x00200002, 0x04000800, + 0x04000002, 0x04200000, 0x04200800, 0x00200002, + 0x04200000, 0x00000800, 0x00000802, 0x04200802, + 0x00200800, 0x00000002, 0x04000000, 0x00200800, + 0x04000000, 0x00200800, 0x00200000, 0x04000802, + 0x04000802, 0x04200002, 0x04200002, 0x00000002, + 0x00200002, 0x04000000, 0x04000800, 0x00200000, + 0x04200800, 0x00000802, 0x00200802, 0x04200800, + 0x00000802, 0x04000002, 0x04200802, 0x04200000, + 0x00200800, 0x00000000, 0x00000002, 0x04200802, + 0x00000000, 0x00200802, 0x04200000, 0x00000800, + 0x04000002, 0x04000800, 0x00000800, 0x00200002 +}; + +static const uint32_t SB8[64] = +{ + 0x10001040, 0x00001000, 0x00040000, 0x10041040, + 0x10000000, 0x10001040, 0x00000040, 0x10000000, + 0x00040040, 0x10040000, 0x10041040, 0x00041000, + 0x10041000, 0x00041040, 0x00001000, 0x00000040, + 0x10040000, 0x10000040, 0x10001000, 0x00001040, + 0x00041000, 0x00040040, 0x10040040, 0x10041000, + 0x00001040, 0x00000000, 0x00000000, 0x10040040, + 0x10000040, 0x10001000, 0x00041040, 0x00040000, + 0x00041040, 0x00040000, 0x10041000, 0x00001000, + 0x00000040, 0x10040040, 0x00001000, 0x00041040, + 0x10001000, 0x00000040, 0x10000040, 0x10040000, + 0x10040040, 0x10000000, 0x00040000, 0x10001040, + 0x00000000, 0x10041040, 0x00040040, 0x10000040, + 0x10040000, 0x10001000, 0x10001040, 0x00000000, + 0x10041040, 0x00041000, 0x00041000, 0x00001040, + 0x00001040, 0x00040040, 0x10000000, 0x10041000 +}; + +/* + * PC1: left and right halves bit-swap + */ +static const uint32_t LHs[16] = +{ + 0x00000000, 0x00000001, 0x00000100, 0x00000101, + 0x00010000, 0x00010001, 0x00010100, 0x00010101, + 0x01000000, 0x01000001, 0x01000100, 0x01000101, + 0x01010000, 0x01010001, 0x01010100, 0x01010101 +}; + +static const uint32_t RHs[16] = +{ + 0x00000000, 0x01000000, 0x00010000, 0x01010000, + 0x00000100, 0x01000100, 0x00010100, 0x01010100, + 0x00000001, 0x01000001, 0x00010001, 0x01010001, + 0x00000101, 0x01000101, 0x00010101, 0x01010101, +}; + +/* + * Initial Permutation macro + */ +#define DES_IP(X,Y) \ +{ \ + T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \ + T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \ + T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \ + T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \ + Y = ((Y << 1) | (Y >> 31)) & 0xFFFFFFFF; \ + T = (X ^ Y) & 0xAAAAAAAA; Y ^= T; X ^= T; \ + X = ((X << 1) | (X >> 31)) & 0xFFFFFFFF; \ +} + +/* + * Final Permutation macro + */ +#define DES_FP(X,Y) \ +{ \ + X = ((X << 31) | (X >> 1)) & 0xFFFFFFFF; \ + T = (X ^ Y) & 0xAAAAAAAA; X ^= T; Y ^= T; \ + Y = ((Y << 31) | (Y >> 1)) & 0xFFFFFFFF; \ + T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \ + T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \ + T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \ + T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \ +} + +/* + * DES round macro + */ +#define DES_ROUND(X,Y) \ +{ \ + T = *SK++ ^ X; \ + Y ^= SB8[ (T ) & 0x3F ] ^ \ + SB6[ (T >> 8) & 0x3F ] ^ \ + SB4[ (T >> 16) & 0x3F ] ^ \ + SB2[ (T >> 24) & 0x3F ]; \ + \ + T = *SK++ ^ ((X << 28) | (X >> 4)); \ + Y ^= SB7[ (T ) & 0x3F ] ^ \ + SB5[ (T >> 8) & 0x3F ] ^ \ + SB3[ (T >> 16) & 0x3F ] ^ \ + SB1[ (T >> 24) & 0x3F ]; \ +} + +#define SWAP(a,b) { uint32_t t = a; a = b; b = t; t = 0; } + +void mbedtls_des_init( mbedtls_des_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_des_context ) ); +} + +void mbedtls_des_free( mbedtls_des_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_des_context ) ); +} + +void mbedtls_des3_init( mbedtls_des3_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_des3_context ) ); +} + +void mbedtls_des3_free( mbedtls_des3_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_des3_context ) ); +} + +static const unsigned char odd_parity_table[128] = { 1, 2, 4, 7, 8, + 11, 13, 14, 16, 19, 21, 22, 25, 26, 28, 31, 32, 35, 37, 38, 41, 42, 44, + 47, 49, 50, 52, 55, 56, 59, 61, 62, 64, 67, 69, 70, 73, 74, 76, 79, 81, + 82, 84, 87, 88, 91, 93, 94, 97, 98, 100, 103, 104, 107, 109, 110, 112, + 115, 117, 118, 121, 122, 124, 127, 128, 131, 133, 134, 137, 138, 140, + 143, 145, 146, 148, 151, 152, 155, 157, 158, 161, 162, 164, 167, 168, + 171, 173, 174, 176, 179, 181, 182, 185, 186, 188, 191, 193, 194, 196, + 199, 200, 203, 205, 206, 208, 211, 213, 214, 217, 218, 220, 223, 224, + 227, 229, 230, 233, 234, 236, 239, 241, 242, 244, 247, 248, 251, 253, + 254 }; + +void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] ) +{ + int i; + + for( i = 0; i < MBEDTLS_DES_KEY_SIZE; i++ ) + key[i] = odd_parity_table[key[i] / 2]; +} + +/* + * Check the given key's parity, returns 1 on failure, 0 on SUCCESS + */ +int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ) +{ + int i; + + for( i = 0; i < MBEDTLS_DES_KEY_SIZE; i++ ) + if( key[i] != odd_parity_table[key[i] / 2] ) + return( 1 ); + + return( 0 ); +} + +/* + * Table of weak and semi-weak keys + * + * Source: http://en.wikipedia.org/wiki/Weak_key + * + * Weak: + * Alternating ones + zeros (0x0101010101010101) + * Alternating 'F' + 'E' (0xFEFEFEFEFEFEFEFE) + * '0xE0E0E0E0F1F1F1F1' + * '0x1F1F1F1F0E0E0E0E' + * + * Semi-weak: + * 0x011F011F010E010E and 0x1F011F010E010E01 + * 0x01E001E001F101F1 and 0xE001E001F101F101 + * 0x01FE01FE01FE01FE and 0xFE01FE01FE01FE01 + * 0x1FE01FE00EF10EF1 and 0xE01FE01FF10EF10E + * 0x1FFE1FFE0EFE0EFE and 0xFE1FFE1FFE0EFE0E + * 0xE0FEE0FEF1FEF1FE and 0xFEE0FEE0FEF1FEF1 + * + */ + +#define WEAK_KEY_COUNT 16 + +static const unsigned char weak_key_table[WEAK_KEY_COUNT][MBEDTLS_DES_KEY_SIZE] = +{ + { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, + { 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE }, + { 0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E }, + { 0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1 }, + + { 0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E }, + { 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01 }, + { 0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1 }, + { 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01 }, + { 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE }, + { 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01 }, + { 0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1 }, + { 0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E }, + { 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE }, + { 0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E }, + { 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE }, + { 0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1 } +}; + +int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ) +{ + int i; + + for( i = 0; i < WEAK_KEY_COUNT; i++ ) + if( memcmp( weak_key_table[i], key, MBEDTLS_DES_KEY_SIZE) == 0 ) + return( 1 ); + + return( 0 ); +} + +#if !defined(MBEDTLS_DES_SETKEY_ALT) +void mbedtls_des_setkey( uint32_t SK[32], const unsigned char key[MBEDTLS_DES_KEY_SIZE] ) +{ + int i; + uint32_t X, Y, T; + + GET_UINT32_BE( X, key, 0 ); + GET_UINT32_BE( Y, key, 4 ); + + /* + * Permuted Choice 1 + */ + T = ((Y >> 4) ^ X) & 0x0F0F0F0F; X ^= T; Y ^= (T << 4); + T = ((Y ) ^ X) & 0x10101010; X ^= T; Y ^= (T ); + + X = (LHs[ (X ) & 0xF] << 3) | (LHs[ (X >> 8) & 0xF ] << 2) + | (LHs[ (X >> 16) & 0xF] << 1) | (LHs[ (X >> 24) & 0xF ] ) + | (LHs[ (X >> 5) & 0xF] << 7) | (LHs[ (X >> 13) & 0xF ] << 6) + | (LHs[ (X >> 21) & 0xF] << 5) | (LHs[ (X >> 29) & 0xF ] << 4); + + Y = (RHs[ (Y >> 1) & 0xF] << 3) | (RHs[ (Y >> 9) & 0xF ] << 2) + | (RHs[ (Y >> 17) & 0xF] << 1) | (RHs[ (Y >> 25) & 0xF ] ) + | (RHs[ (Y >> 4) & 0xF] << 7) | (RHs[ (Y >> 12) & 0xF ] << 6) + | (RHs[ (Y >> 20) & 0xF] << 5) | (RHs[ (Y >> 28) & 0xF ] << 4); + + X &= 0x0FFFFFFF; + Y &= 0x0FFFFFFF; + + /* + * calculate subkeys + */ + for( i = 0; i < 16; i++ ) + { + if( i < 2 || i == 8 || i == 15 ) + { + X = ((X << 1) | (X >> 27)) & 0x0FFFFFFF; + Y = ((Y << 1) | (Y >> 27)) & 0x0FFFFFFF; + } + else + { + X = ((X << 2) | (X >> 26)) & 0x0FFFFFFF; + Y = ((Y << 2) | (Y >> 26)) & 0x0FFFFFFF; + } + + *SK++ = ((X << 4) & 0x24000000) | ((X << 28) & 0x10000000) + | ((X << 14) & 0x08000000) | ((X << 18) & 0x02080000) + | ((X << 6) & 0x01000000) | ((X << 9) & 0x00200000) + | ((X >> 1) & 0x00100000) | ((X << 10) & 0x00040000) + | ((X << 2) & 0x00020000) | ((X >> 10) & 0x00010000) + | ((Y >> 13) & 0x00002000) | ((Y >> 4) & 0x00001000) + | ((Y << 6) & 0x00000800) | ((Y >> 1) & 0x00000400) + | ((Y >> 14) & 0x00000200) | ((Y ) & 0x00000100) + | ((Y >> 5) & 0x00000020) | ((Y >> 10) & 0x00000010) + | ((Y >> 3) & 0x00000008) | ((Y >> 18) & 0x00000004) + | ((Y >> 26) & 0x00000002) | ((Y >> 24) & 0x00000001); + + *SK++ = ((X << 15) & 0x20000000) | ((X << 17) & 0x10000000) + | ((X << 10) & 0x08000000) | ((X << 22) & 0x04000000) + | ((X >> 2) & 0x02000000) | ((X << 1) & 0x01000000) + | ((X << 16) & 0x00200000) | ((X << 11) & 0x00100000) + | ((X << 3) & 0x00080000) | ((X >> 6) & 0x00040000) + | ((X << 15) & 0x00020000) | ((X >> 4) & 0x00010000) + | ((Y >> 2) & 0x00002000) | ((Y << 8) & 0x00001000) + | ((Y >> 14) & 0x00000808) | ((Y >> 9) & 0x00000400) + | ((Y ) & 0x00000200) | ((Y << 7) & 0x00000100) + | ((Y >> 7) & 0x00000020) | ((Y >> 3) & 0x00000011) + | ((Y << 2) & 0x00000004) | ((Y >> 21) & 0x00000002); + } +} +#endif /* !MBEDTLS_DES_SETKEY_ALT */ + +/* + * DES key schedule (56-bit, encryption) + */ +int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ) +{ + mbedtls_des_setkey( ctx->sk, key ); + + return( 0 ); +} + +/* + * DES key schedule (56-bit, decryption) + */ +int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ) +{ + int i; + + mbedtls_des_setkey( ctx->sk, key ); + + for( i = 0; i < 16; i += 2 ) + { + SWAP( ctx->sk[i ], ctx->sk[30 - i] ); + SWAP( ctx->sk[i + 1], ctx->sk[31 - i] ); + } + + return( 0 ); +} + +static void des3_set2key( uint32_t esk[96], + uint32_t dsk[96], + const unsigned char key[MBEDTLS_DES_KEY_SIZE*2] ) +{ + int i; + + mbedtls_des_setkey( esk, key ); + mbedtls_des_setkey( dsk + 32, key + 8 ); + + for( i = 0; i < 32; i += 2 ) + { + dsk[i ] = esk[30 - i]; + dsk[i + 1] = esk[31 - i]; + + esk[i + 32] = dsk[62 - i]; + esk[i + 33] = dsk[63 - i]; + + esk[i + 64] = esk[i ]; + esk[i + 65] = esk[i + 1]; + + dsk[i + 64] = dsk[i ]; + dsk[i + 65] = dsk[i + 1]; + } +} + +/* + * Triple-DES key schedule (112-bit, encryption) + */ +int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ) +{ + uint32_t sk[96]; + + des3_set2key( ctx->sk, sk, key ); + mbedtls_zeroize( sk, sizeof( sk ) ); + + return( 0 ); +} + +/* + * Triple-DES key schedule (112-bit, decryption) + */ +int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ) +{ + uint32_t sk[96]; + + des3_set2key( sk, ctx->sk, key ); + mbedtls_zeroize( sk, sizeof( sk ) ); + + return( 0 ); +} + +static void des3_set3key( uint32_t esk[96], + uint32_t dsk[96], + const unsigned char key[24] ) +{ + int i; + + mbedtls_des_setkey( esk, key ); + mbedtls_des_setkey( dsk + 32, key + 8 ); + mbedtls_des_setkey( esk + 64, key + 16 ); + + for( i = 0; i < 32; i += 2 ) + { + dsk[i ] = esk[94 - i]; + dsk[i + 1] = esk[95 - i]; + + esk[i + 32] = dsk[62 - i]; + esk[i + 33] = dsk[63 - i]; + + dsk[i + 64] = esk[30 - i]; + dsk[i + 65] = esk[31 - i]; + } +} + +/* + * Triple-DES key schedule (168-bit, encryption) + */ +int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ) +{ + uint32_t sk[96]; + + des3_set3key( ctx->sk, sk, key ); + mbedtls_zeroize( sk, sizeof( sk ) ); + + return( 0 ); +} + +/* + * Triple-DES key schedule (168-bit, decryption) + */ +int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, + const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ) +{ + uint32_t sk[96]; + + des3_set3key( sk, ctx->sk, key ); + mbedtls_zeroize( sk, sizeof( sk ) ); + + return( 0 ); +} + +/* + * DES-ECB block encryption/decryption + */ +#if !defined(MBEDTLS_DES_CRYPT_ECB_ALT) +int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, + const unsigned char input[8], + unsigned char output[8] ) +{ + int i; + uint32_t X, Y, T, *SK; + + SK = ctx->sk; + + GET_UINT32_BE( X, input, 0 ); + GET_UINT32_BE( Y, input, 4 ); + + DES_IP( X, Y ); + + for( i = 0; i < 8; i++ ) + { + DES_ROUND( Y, X ); + DES_ROUND( X, Y ); + } + + DES_FP( Y, X ); + + PUT_UINT32_BE( Y, output, 0 ); + PUT_UINT32_BE( X, output, 4 ); + + return( 0 ); +} +#endif /* !MBEDTLS_DES_CRYPT_ECB_ALT */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * DES-CBC buffer encryption/decryption + */ +int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, + int mode, + size_t length, + unsigned char iv[8], + const unsigned char *input, + unsigned char *output ) +{ + int i; + unsigned char temp[8]; + + if( length % 8 ) + return( MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH ); + + if( mode == MBEDTLS_DES_ENCRYPT ) + { + while( length > 0 ) + { + for( i = 0; i < 8; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_des_crypt_ecb( ctx, output, output ); + memcpy( iv, output, 8 ); + + input += 8; + output += 8; + length -= 8; + } + } + else /* MBEDTLS_DES_DECRYPT */ + { + while( length > 0 ) + { + memcpy( temp, input, 8 ); + mbedtls_des_crypt_ecb( ctx, input, output ); + + for( i = 0; i < 8; i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, 8 ); + + input += 8; + output += 8; + length -= 8; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +/* + * 3DES-ECB block encryption/decryption + */ +#if !defined(MBEDTLS_DES3_CRYPT_ECB_ALT) +int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, + const unsigned char input[8], + unsigned char output[8] ) +{ + int i; + uint32_t X, Y, T, *SK; + + SK = ctx->sk; + + GET_UINT32_BE( X, input, 0 ); + GET_UINT32_BE( Y, input, 4 ); + + DES_IP( X, Y ); + + for( i = 0; i < 8; i++ ) + { + DES_ROUND( Y, X ); + DES_ROUND( X, Y ); + } + + for( i = 0; i < 8; i++ ) + { + DES_ROUND( X, Y ); + DES_ROUND( Y, X ); + } + + for( i = 0; i < 8; i++ ) + { + DES_ROUND( Y, X ); + DES_ROUND( X, Y ); + } + + DES_FP( Y, X ); + + PUT_UINT32_BE( Y, output, 0 ); + PUT_UINT32_BE( X, output, 4 ); + + return( 0 ); +} +#endif /* !MBEDTLS_DES3_CRYPT_ECB_ALT */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * 3DES-CBC buffer encryption/decryption + */ +int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, + int mode, + size_t length, + unsigned char iv[8], + const unsigned char *input, + unsigned char *output ) +{ + int i; + unsigned char temp[8]; + + if( length % 8 ) + return( MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH ); + + if( mode == MBEDTLS_DES_ENCRYPT ) + { + while( length > 0 ) + { + for( i = 0; i < 8; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_des3_crypt_ecb( ctx, output, output ); + memcpy( iv, output, 8 ); + + input += 8; + output += 8; + length -= 8; + } + } + else /* MBEDTLS_DES_DECRYPT */ + { + while( length > 0 ) + { + memcpy( temp, input, 8 ); + mbedtls_des3_crypt_ecb( ctx, input, output ); + + for( i = 0; i < 8; i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, 8 ); + + input += 8; + output += 8; + length -= 8; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#endif /* !MBEDTLS_DES_ALT */ + +#if defined(MBEDTLS_SELF_TEST) +/* + * DES and 3DES test vectors from: + * + * http://csrc.nist.gov/groups/STM/cavp/documents/des/tripledes-vectors.zip + */ +static const unsigned char des3_test_keys[24] = +{ + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, + 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23 +}; + +static const unsigned char des3_test_buf[8] = +{ + 0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 +}; + +static const unsigned char des3_test_ecb_dec[3][8] = +{ + { 0xCD, 0xD6, 0x4F, 0x2F, 0x94, 0x27, 0xC1, 0x5D }, + { 0x69, 0x96, 0xC8, 0xFA, 0x47, 0xA2, 0xAB, 0xEB }, + { 0x83, 0x25, 0x39, 0x76, 0x44, 0x09, 0x1A, 0x0A } +}; + +static const unsigned char des3_test_ecb_enc[3][8] = +{ + { 0x6A, 0x2A, 0x19, 0xF4, 0x1E, 0xCA, 0x85, 0x4B }, + { 0x03, 0xE6, 0x9F, 0x5B, 0xFA, 0x58, 0xEB, 0x42 }, + { 0xDD, 0x17, 0xE8, 0xB8, 0xB4, 0x37, 0xD2, 0x32 } +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const unsigned char des3_test_iv[8] = +{ + 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, +}; + +static const unsigned char des3_test_cbc_dec[3][8] = +{ + { 0x12, 0x9F, 0x40, 0xB9, 0xD2, 0x00, 0x56, 0xB3 }, + { 0x47, 0x0E, 0xFC, 0x9A, 0x6B, 0x8E, 0xE3, 0x93 }, + { 0xC5, 0xCE, 0xCF, 0x63, 0xEC, 0xEC, 0x51, 0x4C } +}; + +static const unsigned char des3_test_cbc_enc[3][8] = +{ + { 0x54, 0xF1, 0x5A, 0xF6, 0xEB, 0xE3, 0xA4, 0xB4 }, + { 0x35, 0x76, 0x11, 0x56, 0x5F, 0xA1, 0x8E, 0x4D }, + { 0xCB, 0x19, 0x1F, 0x85, 0xD1, 0xED, 0x84, 0x39 } +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +/* + * Checkup routine + */ +int mbedtls_des_self_test( int verbose ) +{ + int i, j, u, v, ret = 0; + mbedtls_des_context ctx; + mbedtls_des3_context ctx3; + unsigned char buf[8]; +#if defined(MBEDTLS_CIPHER_MODE_CBC) + unsigned char prv[8]; + unsigned char iv[8]; +#endif + + mbedtls_des_init( &ctx ); + mbedtls_des3_init( &ctx3 ); + /* + * ECB mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " DES%c-ECB-%3d (%s): ", + ( u == 0 ) ? ' ' : '3', 56 + u * 56, + ( v == MBEDTLS_DES_DECRYPT ) ? "dec" : "enc" ); + + memcpy( buf, des3_test_buf, 8 ); + + switch( i ) + { + case 0: + mbedtls_des_setkey_dec( &ctx, des3_test_keys ); + break; + + case 1: + mbedtls_des_setkey_enc( &ctx, des3_test_keys ); + break; + + case 2: + mbedtls_des3_set2key_dec( &ctx3, des3_test_keys ); + break; + + case 3: + mbedtls_des3_set2key_enc( &ctx3, des3_test_keys ); + break; + + case 4: + mbedtls_des3_set3key_dec( &ctx3, des3_test_keys ); + break; + + case 5: + mbedtls_des3_set3key_enc( &ctx3, des3_test_keys ); + break; + + default: + return( 1 ); + } + + for( j = 0; j < 10000; j++ ) + { + if( u == 0 ) + mbedtls_des_crypt_ecb( &ctx, buf, buf ); + else + mbedtls_des3_crypt_ecb( &ctx3, buf, buf ); + } + + if( ( v == MBEDTLS_DES_DECRYPT && + memcmp( buf, des3_test_ecb_dec[u], 8 ) != 0 ) || + ( v != MBEDTLS_DES_DECRYPT && + memcmp( buf, des3_test_ecb_enc[u], 8 ) != 0 ) ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + /* + * CBC mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + v = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " DES%c-CBC-%3d (%s): ", + ( u == 0 ) ? ' ' : '3', 56 + u * 56, + ( v == MBEDTLS_DES_DECRYPT ) ? "dec" : "enc" ); + + memcpy( iv, des3_test_iv, 8 ); + memcpy( prv, des3_test_iv, 8 ); + memcpy( buf, des3_test_buf, 8 ); + + switch( i ) + { + case 0: + mbedtls_des_setkey_dec( &ctx, des3_test_keys ); + break; + + case 1: + mbedtls_des_setkey_enc( &ctx, des3_test_keys ); + break; + + case 2: + mbedtls_des3_set2key_dec( &ctx3, des3_test_keys ); + break; + + case 3: + mbedtls_des3_set2key_enc( &ctx3, des3_test_keys ); + break; + + case 4: + mbedtls_des3_set3key_dec( &ctx3, des3_test_keys ); + break; + + case 5: + mbedtls_des3_set3key_enc( &ctx3, des3_test_keys ); + break; + + default: + return( 1 ); + } + + if( v == MBEDTLS_DES_DECRYPT ) + { + for( j = 0; j < 10000; j++ ) + { + if( u == 0 ) + mbedtls_des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); + else + mbedtls_des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); + } + } + else + { + for( j = 0; j < 10000; j++ ) + { + unsigned char tmp[8]; + + if( u == 0 ) + mbedtls_des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); + else + mbedtls_des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); + + memcpy( tmp, prv, 8 ); + memcpy( prv, buf, 8 ); + memcpy( buf, tmp, 8 ); + } + + memcpy( buf, prv, 8 ); + } + + if( ( v == MBEDTLS_DES_DECRYPT && + memcmp( buf, des3_test_cbc_dec[u], 8 ) != 0 ) || + ( v != MBEDTLS_DES_DECRYPT && + memcmp( buf, des3_test_cbc_enc[u], 8 ) != 0 ) ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_des_free( &ctx ); + mbedtls_des3_free( &ctx3 ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_DES_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/dhm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/dhm.c new file mode 100644 index 0000000..a4715d1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/dhm.c @@ -0,0 +1,627 @@ +/* + * Diffie-Hellman-Merkle key exchange + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The following sources were referenced in the design of this implementation + * of the Diffie-Hellman-Merkle algorithm: + * + * [1] Handbook of Applied Cryptography - 1997, Chapter 12 + * Menezes, van Oorschot and Vanstone + * + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_DHM_C) + +#include "mbedtls/dhm.h" + +#include + +#if defined(MBEDTLS_PEM_PARSE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_ASN1_PARSE_C) +#include "mbedtls/asn1.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * helper to validate the mbedtls_mpi size and import it + */ +static int dhm_read_bignum( mbedtls_mpi *X, + unsigned char **p, + const unsigned char *end ) +{ + int ret, n; + + if( end - *p < 2 ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + n = ( (*p)[0] << 8 ) | (*p)[1]; + (*p) += 2; + + if( (int)( end - *p ) < n ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_mpi_read_binary( X, *p, n ) ) != 0 ) + return( MBEDTLS_ERR_DHM_READ_PARAMS_FAILED + ret ); + + (*p) += n; + + return( 0 ); +} + +/* + * Verify sanity of parameter with regards to P + * + * Parameter should be: 2 <= public_param <= P - 2 + * + * For more information on the attack, see: + * http://www.cl.cam.ac.uk/~rja14/Papers/psandqs.pdf + * http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2643 + */ +static int dhm_check_range( const mbedtls_mpi *param, const mbedtls_mpi *P ) +{ + mbedtls_mpi L, U; + int ret = MBEDTLS_ERR_DHM_BAD_INPUT_DATA; + + mbedtls_mpi_init( &L ); mbedtls_mpi_init( &U ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &L, 2 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &U, P, 2 ) ); + + if( mbedtls_mpi_cmp_mpi( param, &L ) >= 0 && + mbedtls_mpi_cmp_mpi( param, &U ) <= 0 ) + { + ret = 0; + } + +cleanup: + mbedtls_mpi_free( &L ); mbedtls_mpi_free( &U ); + return( ret ); +} + +void mbedtls_dhm_init( mbedtls_dhm_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_dhm_context ) ); +} + +/* + * Parse the ServerKeyExchange parameters + */ +int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx, + unsigned char **p, + const unsigned char *end ) +{ + int ret; + + if( ( ret = dhm_read_bignum( &ctx->P, p, end ) ) != 0 || + ( ret = dhm_read_bignum( &ctx->G, p, end ) ) != 0 || + ( ret = dhm_read_bignum( &ctx->GY, p, end ) ) != 0 ) + return( ret ); + + if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) + return( ret ); + + ctx->len = mbedtls_mpi_size( &ctx->P ); + + return( 0 ); +} + +/* + * Setup and write the ServerKeyExchange parameters + */ +int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, + unsigned char *output, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret, count = 0; + size_t n1, n2, n3; + unsigned char *p; + + if( mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + /* + * Generate X as large as possible ( < P ) + */ + do + { + mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ); + + while( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->X, 1 ) ); + + if( count++ > 10 ) + return( MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED ); + } + while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); + + /* + * Calculate GX = G^X mod P + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, + &ctx->P , &ctx->RP ) ); + + if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) + return( ret ); + + /* + * export P, G, GX + */ +#define DHM_MPI_EXPORT(X,n) \ + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( X, p + 2, n ) ); \ + *p++ = (unsigned char)( n >> 8 ); \ + *p++ = (unsigned char)( n ); p += n; + + n1 = mbedtls_mpi_size( &ctx->P ); + n2 = mbedtls_mpi_size( &ctx->G ); + n3 = mbedtls_mpi_size( &ctx->GX ); + + p = output; + DHM_MPI_EXPORT( &ctx->P , n1 ); + DHM_MPI_EXPORT( &ctx->G , n2 ); + DHM_MPI_EXPORT( &ctx->GX, n3 ); + + *olen = p - output; + + ctx->len = n1; + +cleanup: + + if( ret != 0 ) + return( MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED + ret ); + + return( 0 ); +} + +/* + * Import the peer's public value G^Y + */ +int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx, + const unsigned char *input, size_t ilen ) +{ + int ret; + + if( ctx == NULL || ilen < 1 || ilen > ctx->len ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_mpi_read_binary( &ctx->GY, input, ilen ) ) != 0 ) + return( MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED + ret ); + + return( 0 ); +} + +/* + * Create own private value X and export G^X + */ +int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, + unsigned char *output, size_t olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret, count = 0; + + if( ctx == NULL || olen < 1 || olen > ctx->len ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + if( mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + /* + * generate X and calculate GX = G^X mod P + */ + do + { + mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ); + + while( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->X, 1 ) ); + + if( count++ > 10 ) + return( MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED ); + } + while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, + &ctx->P , &ctx->RP ) ); + + if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) + return( ret ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->GX, output, olen ) ); + +cleanup: + + if( ret != 0 ) + return( MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED + ret ); + + return( 0 ); +} + +/* + * Use the blinding method and optimisation suggested in section 10 of: + * KOCHER, Paul C. Timing attacks on implementations of Diffie-Hellman, RSA, + * DSS, and other systems. In : Advances in Cryptology-CRYPTO'96. Springer + * Berlin Heidelberg, 1996. p. 104-113. + */ +static int dhm_update_blinding( mbedtls_dhm_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret, count; + + /* + * Don't use any blinding the first time a particular X is used, + * but remember it to use blinding next time. + */ + if( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->pX ) != 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &ctx->pX, &ctx->X ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &ctx->Vi, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &ctx->Vf, 1 ) ); + + return( 0 ); + } + + /* + * Ok, we need blinding. Can we re-use existing values? + * If yes, just update them by squaring them. + */ + if( mbedtls_mpi_cmp_int( &ctx->Vi, 1 ) != 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &ctx->Vi ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->P ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vf, &ctx->Vf, &ctx->Vf ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vf, &ctx->Vf, &ctx->P ) ); + + return( 0 ); + } + + /* + * We need to generate blinding values from scratch + */ + + /* Vi = random( 2, P-1 ) */ + count = 0; + do + { + mbedtls_mpi_fill_random( &ctx->Vi, mbedtls_mpi_size( &ctx->P ), f_rng, p_rng ); + + while( mbedtls_mpi_cmp_mpi( &ctx->Vi, &ctx->P ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->Vi, 1 ) ); + + if( count++ > 10 ) + return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); + } + while( mbedtls_mpi_cmp_int( &ctx->Vi, 1 ) <= 0 ); + + /* Vf = Vi^-X mod P */ + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->Vf, &ctx->Vi, &ctx->P ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->Vf, &ctx->Vf, &ctx->X, &ctx->P, &ctx->RP ) ); + +cleanup: + return( ret ); +} + +/* + * Derive and export the shared secret (G^Y)^X mod P + */ +int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, + unsigned char *output, size_t output_size, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_mpi GYb; + + if( ctx == NULL || output_size < ctx->len ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + + if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) + return( ret ); + + mbedtls_mpi_init( &GYb ); + + /* Blind peer's value */ + if( f_rng != NULL ) + { + MBEDTLS_MPI_CHK( dhm_update_blinding( ctx, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &GYb, &ctx->GY, &ctx->Vi ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &GYb, &GYb, &ctx->P ) ); + } + else + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &GYb, &ctx->GY ) ); + + /* Do modular exponentiation */ + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->K, &GYb, &ctx->X, + &ctx->P, &ctx->RP ) ); + + /* Unblind secret value */ + if( f_rng != NULL ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->K, &ctx->K, &ctx->Vf ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->K, &ctx->K, &ctx->P ) ); + } + + *olen = mbedtls_mpi_size( &ctx->K ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->K, output, *olen ) ); + +cleanup: + mbedtls_mpi_free( &GYb ); + + if( ret != 0 ) + return( MBEDTLS_ERR_DHM_CALC_SECRET_FAILED + ret ); + + return( 0 ); +} + +/* + * Free the components of a DHM key + */ +void mbedtls_dhm_free( mbedtls_dhm_context *ctx ) +{ + mbedtls_mpi_free( &ctx->pX); mbedtls_mpi_free( &ctx->Vf ); mbedtls_mpi_free( &ctx->Vi ); + mbedtls_mpi_free( &ctx->RP ); mbedtls_mpi_free( &ctx->K ); mbedtls_mpi_free( &ctx->GY ); + mbedtls_mpi_free( &ctx->GX ); mbedtls_mpi_free( &ctx->X ); mbedtls_mpi_free( &ctx->G ); + mbedtls_mpi_free( &ctx->P ); + + mbedtls_zeroize( ctx, sizeof( mbedtls_dhm_context ) ); +} + +#if defined(MBEDTLS_ASN1_PARSE_C) +/* + * Parse DHM parameters + */ +int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin, + size_t dhminlen ) +{ + int ret; + size_t len; + unsigned char *p, *end; +#if defined(MBEDTLS_PEM_PARSE_C) + mbedtls_pem_context pem; + + mbedtls_pem_init( &pem ); + + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( dhminlen == 0 || dhmin[dhminlen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN DH PARAMETERS-----", + "-----END DH PARAMETERS-----", + dhmin, NULL, 0, &dhminlen ); + + if( ret == 0 ) + { + /* + * Was PEM encoded + */ + dhminlen = pem.buflen; + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + goto exit; + + p = ( ret == 0 ) ? pem.buf : (unsigned char *) dhmin; +#else + p = (unsigned char *) dhmin; +#endif /* MBEDTLS_PEM_PARSE_C */ + end = p + dhminlen; + + /* + * DHParams ::= SEQUENCE { + * prime INTEGER, -- P + * generator INTEGER, -- g + * privateValueLength INTEGER OPTIONAL + * } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + ret = MBEDTLS_ERR_DHM_INVALID_FORMAT + ret; + goto exit; + } + + end = p + len; + + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &dhm->P ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &dhm->G ) ) != 0 ) + { + ret = MBEDTLS_ERR_DHM_INVALID_FORMAT + ret; + goto exit; + } + + if( p != end ) + { + /* This might be the optional privateValueLength. + * If so, we can cleanly discard it */ + mbedtls_mpi rec; + mbedtls_mpi_init( &rec ); + ret = mbedtls_asn1_get_mpi( &p, end, &rec ); + mbedtls_mpi_free( &rec ); + if ( ret != 0 ) + { + ret = MBEDTLS_ERR_DHM_INVALID_FORMAT + ret; + goto exit; + } + if ( p != end ) + { + ret = MBEDTLS_ERR_DHM_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH; + goto exit; + } + } + + ret = 0; + + dhm->len = mbedtls_mpi_size( &dhm->P ); + +exit: +#if defined(MBEDTLS_PEM_PARSE_C) + mbedtls_pem_free( &pem ); +#endif + if( ret != 0 ) + mbedtls_dhm_free( dhm ); + + return( ret ); +} + +#if defined(MBEDTLS_FS_IO) +/* + * Load all data from a file into a given buffer. + * + * The file is expected to contain either PEM or DER encoded data. + * A terminating null byte is always appended. It is included in the announced + * length only if the data looks like it is PEM encoded. + */ +static int load_file( const char *path, unsigned char **buf, size_t *n ) +{ + FILE *f; + long size; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( MBEDTLS_ERR_DHM_FILE_IO_ERROR ); + + fseek( f, 0, SEEK_END ); + if( ( size = ftell( f ) ) == -1 ) + { + fclose( f ); + return( MBEDTLS_ERR_DHM_FILE_IO_ERROR ); + } + fseek( f, 0, SEEK_SET ); + + *n = (size_t) size; + + if( *n + 1 == 0 || + ( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL ) + { + fclose( f ); + return( MBEDTLS_ERR_DHM_ALLOC_FAILED ); + } + + if( fread( *buf, 1, *n, f ) != *n ) + { + fclose( f ); + mbedtls_free( *buf ); + return( MBEDTLS_ERR_DHM_FILE_IO_ERROR ); + } + + fclose( f ); + + (*buf)[*n] = '\0'; + + if( strstr( (const char *) *buf, "-----BEGIN " ) != NULL ) + ++*n; + + return( 0 ); +} + +/* + * Load and parse DHM parameters + */ +int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ) +{ + int ret; + size_t n; + unsigned char *buf; + + if( ( ret = load_file( path, &buf, &n ) ) != 0 ) + return( ret ); + + ret = mbedtls_dhm_parse_dhm( dhm, buf, n ); + + mbedtls_zeroize( buf, n ); + mbedtls_free( buf ); + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ +#endif /* MBEDTLS_ASN1_PARSE_C */ + +#if defined(MBEDTLS_SELF_TEST) + +static const char mbedtls_test_dhm_params[] = +"-----BEGIN DH PARAMETERS-----\r\n" +"MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh\r\n" +"1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32\r\n" +"9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC\r\n" +"-----END DH PARAMETERS-----\r\n"; + +static const size_t mbedtls_test_dhm_params_len = sizeof( mbedtls_test_dhm_params ); + +/* + * Checkup routine + */ +int mbedtls_dhm_self_test( int verbose ) +{ + int ret; + mbedtls_dhm_context dhm; + + mbedtls_dhm_init( &dhm ); + + if( verbose != 0 ) + mbedtls_printf( " DHM parameter load: " ); + + if( ( ret = mbedtls_dhm_parse_dhm( &dhm, + (const unsigned char *) mbedtls_test_dhm_params, + mbedtls_test_dhm_params_len ) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n\n" ); + +exit: + mbedtls_dhm_free( &dhm ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_DHM_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdh.c new file mode 100644 index 0000000..c0a8147 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdh.c @@ -0,0 +1,264 @@ +/* + * Elliptic curve Diffie-Hellman + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * References: + * + * SEC1 http://www.secg.org/index.php?action=secg,docs_secg + * RFC 4492 + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ECDH_C) + +#include "mbedtls/ecdh.h" + +#include + +/* + * Generate public key: simple wrapper around mbedtls_ecp_gen_keypair + */ +int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + return mbedtls_ecp_gen_keypair( grp, d, Q, f_rng, p_rng ); +} + +/* + * Compute shared secret (SEC1 3.3.1) + */ +int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, + const mbedtls_ecp_point *Q, const mbedtls_mpi *d, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_ecp_point P; + + mbedtls_ecp_point_init( &P ); + + /* + * Make sure Q is a valid pubkey before using it + */ + MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, Q ) ); + + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &P, d, Q, f_rng, p_rng ) ); + + if( mbedtls_ecp_is_zero( &P ) ) + { + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( z, &P.X ) ); + +cleanup: + mbedtls_ecp_point_free( &P ); + + return( ret ); +} + +/* + * Initialize context + */ +void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_ecdh_context ) ); +} + +/* + * Free context + */ +void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_ecp_group_free( &ctx->grp ); + mbedtls_ecp_point_free( &ctx->Q ); + mbedtls_ecp_point_free( &ctx->Qp ); + mbedtls_ecp_point_free( &ctx->Vi ); + mbedtls_ecp_point_free( &ctx->Vf ); + mbedtls_mpi_free( &ctx->d ); + mbedtls_mpi_free( &ctx->z ); + mbedtls_mpi_free( &ctx->_d ); +} + +/* + * Setup and write the ServerKeyExhange parameters (RFC 4492) + * struct { + * ECParameters curve_params; + * ECPoint public; + * } ServerECDHParams; + */ +int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + size_t grp_len, pt_len; + + if( ctx == NULL || ctx->grp.pbits == 0 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) + != 0 ) + return( ret ); + + if( ( ret = mbedtls_ecp_tls_write_group( &ctx->grp, &grp_len, buf, blen ) ) + != 0 ) + return( ret ); + + buf += grp_len; + blen -= grp_len; + + if( ( ret = mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, ctx->point_format, + &pt_len, buf, blen ) ) != 0 ) + return( ret ); + + *olen = grp_len + pt_len; + return( 0 ); +} + +/* + * Read the ServerKeyExhange parameters (RFC 4492) + * struct { + * ECParameters curve_params; + * ECPoint public; + * } ServerECDHParams; + */ +int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, + const unsigned char **buf, const unsigned char *end ) +{ + int ret; + + if( ( ret = mbedtls_ecp_tls_read_group( &ctx->grp, buf, end - *buf ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, buf, end - *buf ) ) + != 0 ) + return( ret ); + + return( 0 ); +} + +/* + * Get parameters from a keypair + */ +int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, + mbedtls_ecdh_side side ) +{ + int ret; + + if( ( ret = mbedtls_ecp_group_copy( &ctx->grp, &key->grp ) ) != 0 ) + return( ret ); + + /* If it's not our key, just import the public part as Qp */ + if( side == MBEDTLS_ECDH_THEIRS ) + return( mbedtls_ecp_copy( &ctx->Qp, &key->Q ) ); + + /* Our key: import public (as Q) and private parts */ + if( side != MBEDTLS_ECDH_OURS ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecp_copy( &ctx->Q, &key->Q ) ) != 0 || + ( ret = mbedtls_mpi_copy( &ctx->d, &key->d ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +/* + * Setup and export the client public value + */ +int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + + if( ctx == NULL || ctx->grp.pbits == 0 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) + != 0 ) + return( ret ); + + return mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, ctx->point_format, + olen, buf, blen ); +} + +/* + * Parse and import the client's public value + */ +int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, size_t blen ) +{ + int ret; + const unsigned char *p = buf; + + if( ctx == NULL ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, &p, blen ) ) != 0 ) + return( ret ); + + if( (size_t)( p - buf ) != blen ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + return( 0 ); +} + +/* + * Derive and export the shared secret + */ +int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + + if( ctx == NULL ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecdh_compute_shared( &ctx->grp, &ctx->z, &ctx->Qp, &ctx->d, + f_rng, p_rng ) ) != 0 ) + { + return( ret ); + } + + if( mbedtls_mpi_size( &ctx->z ) > blen ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + *olen = ctx->grp.pbits / 8 + ( ( ctx->grp.pbits % 8 ) != 0 ); + return mbedtls_mpi_write_binary( &ctx->z, buf, *olen ); +} + +#endif /* MBEDTLS_ECDH_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdsa.c new file mode 100644 index 0000000..4156f3c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecdsa.c @@ -0,0 +1,448 @@ +/* + * Elliptic curve DSA + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * References: + * + * SEC1 http://www.secg.org/index.php?action=secg,docs_secg + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ECDSA_C) + +#include "mbedtls/ecdsa.h" +#include "mbedtls/asn1write.h" + +#include + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) +#include "mbedtls/hmac_drbg.h" +#endif + +/* + * Derive a suitable integer for group grp from a buffer of length len + * SEC1 4.1.3 step 5 aka SEC1 4.1.4 step 3 + */ +static int derive_mpi( const mbedtls_ecp_group *grp, mbedtls_mpi *x, + const unsigned char *buf, size_t blen ) +{ + int ret; + size_t n_size = ( grp->nbits + 7 ) / 8; + size_t use_size = blen > n_size ? n_size : blen; + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( x, buf, use_size ) ); + if( use_size * 8 > grp->nbits ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( x, use_size * 8 - grp->nbits ) ); + + /* While at it, reduce modulo N */ + if( mbedtls_mpi_cmp_mpi( x, &grp->N ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( x, x, &grp->N ) ); + +cleanup: + return( ret ); +} + +/* + * Compute ECDSA signature of a hashed message (SEC1 4.1.3) + * Obviously, compared to SEC1 4.1.3, we skip step 4 (hash message) + */ +int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, + const mbedtls_mpi *d, const unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret, key_tries, sign_tries, blind_tries; + mbedtls_ecp_point R; + mbedtls_mpi k, e, t; + + /* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */ + if( grp->N.p == NULL ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + mbedtls_ecp_point_init( &R ); + mbedtls_mpi_init( &k ); mbedtls_mpi_init( &e ); mbedtls_mpi_init( &t ); + + sign_tries = 0; + do + { + /* + * Steps 1-3: generate a suitable ephemeral keypair + * and set r = xR mod n + */ + key_tries = 0; + do + { + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_keypair( grp, &k, &R, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( r, &R.X, &grp->N ) ); + + if( key_tries++ > 10 ) + { + ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; + goto cleanup; + } + } + while( mbedtls_mpi_cmp_int( r, 0 ) == 0 ); + + /* + * Step 5: derive MPI from hashed message + */ + MBEDTLS_MPI_CHK( derive_mpi( grp, &e, buf, blen ) ); + + /* + * Generate a random value to blind inv_mod in next step, + * avoiding a potential timing leak. + */ + blind_tries = 0; + do + { + size_t n_size = ( grp->nbits + 7 ) / 8; + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &t, n_size, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &t, 8 * n_size - grp->nbits ) ); + + /* See mbedtls_ecp_gen_keypair() */ + if( ++blind_tries > 30 ) + return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); + } + while( mbedtls_mpi_cmp_int( &t, 1 ) < 0 || + mbedtls_mpi_cmp_mpi( &t, &grp->N ) >= 0 ); + + /* + * Step 6: compute s = (e + r * d) / k = t (e + rd) / (kt) mod n + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( s, r, d ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &e, &e, s ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &e, &e, &t ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &k, &k, &t ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( s, &k, &grp->N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( s, s, &e ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( s, s, &grp->N ) ); + + if( sign_tries++ > 10 ) + { + ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; + goto cleanup; + } + } + while( mbedtls_mpi_cmp_int( s, 0 ) == 0 ); + +cleanup: + mbedtls_ecp_point_free( &R ); + mbedtls_mpi_free( &k ); mbedtls_mpi_free( &e ); mbedtls_mpi_free( &t ); + + return( ret ); +} + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) +/* + * Deterministic signature wrapper + */ +int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, + const mbedtls_mpi *d, const unsigned char *buf, size_t blen, + mbedtls_md_type_t md_alg ) +{ + int ret; + mbedtls_hmac_drbg_context rng_ctx; + unsigned char data[2 * MBEDTLS_ECP_MAX_BYTES]; + size_t grp_len = ( grp->nbits + 7 ) / 8; + const mbedtls_md_info_t *md_info; + mbedtls_mpi h; + + if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &h ); + mbedtls_hmac_drbg_init( &rng_ctx ); + + /* Use private key and message hash (reduced) to initialize HMAC_DRBG */ + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( d, data, grp_len ) ); + MBEDTLS_MPI_CHK( derive_mpi( grp, &h, buf, blen ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &h, data + grp_len, grp_len ) ); + mbedtls_hmac_drbg_seed_buf( &rng_ctx, md_info, data, 2 * grp_len ); + + ret = mbedtls_ecdsa_sign( grp, r, s, d, buf, blen, + mbedtls_hmac_drbg_random, &rng_ctx ); + +cleanup: + mbedtls_hmac_drbg_free( &rng_ctx ); + mbedtls_mpi_free( &h ); + + return( ret ); +} +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ + +/* + * Verify ECDSA signature of hashed message (SEC1 4.1.4) + * Obviously, compared to SEC1 4.1.3, we skip step 2 (hash message) + */ +int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s) +{ + int ret; + mbedtls_mpi e, s_inv, u1, u2; + mbedtls_ecp_point R; + + mbedtls_ecp_point_init( &R ); + mbedtls_mpi_init( &e ); mbedtls_mpi_init( &s_inv ); mbedtls_mpi_init( &u1 ); mbedtls_mpi_init( &u2 ); + + /* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */ + if( grp->N.p == NULL ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Step 1: make sure r and s are in range 1..n-1 + */ + if( mbedtls_mpi_cmp_int( r, 1 ) < 0 || mbedtls_mpi_cmp_mpi( r, &grp->N ) >= 0 || + mbedtls_mpi_cmp_int( s, 1 ) < 0 || mbedtls_mpi_cmp_mpi( s, &grp->N ) >= 0 ) + { + ret = MBEDTLS_ERR_ECP_VERIFY_FAILED; + goto cleanup; + } + + /* + * Additional precaution: make sure Q is valid + */ + MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, Q ) ); + + /* + * Step 3: derive MPI from hashed message + */ + MBEDTLS_MPI_CHK( derive_mpi( grp, &e, buf, blen ) ); + + /* + * Step 4: u1 = e / s mod n, u2 = r / s mod n + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &s_inv, s, &grp->N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &u1, &e, &s_inv ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &u1, &u1, &grp->N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &u2, r, &s_inv ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &u2, &u2, &grp->N ) ); + + /* + * Step 5: R = u1 G + u2 Q + * + * Since we're not using any secret data, no need to pass a RNG to + * mbedtls_ecp_mul() for countermesures. + */ + MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( grp, &R, &u1, &grp->G, &u2, Q ) ); + + if( mbedtls_ecp_is_zero( &R ) ) + { + ret = MBEDTLS_ERR_ECP_VERIFY_FAILED; + goto cleanup; + } + + /* + * Step 6: convert xR to an integer (no-op) + * Step 7: reduce xR mod n (gives v) + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &R.X, &R.X, &grp->N ) ); + + /* + * Step 8: check if v (that is, R.X) is equal to r + */ + if( mbedtls_mpi_cmp_mpi( &R.X, r ) != 0 ) + { + ret = MBEDTLS_ERR_ECP_VERIFY_FAILED; + goto cleanup; + } + +cleanup: + mbedtls_ecp_point_free( &R ); + mbedtls_mpi_free( &e ); mbedtls_mpi_free( &s_inv ); mbedtls_mpi_free( &u1 ); mbedtls_mpi_free( &u2 ); + + return( ret ); +} + +/* + * Convert a signature (given by context) to ASN.1 + */ +static int ecdsa_signature_to_asn1( const mbedtls_mpi *r, const mbedtls_mpi *s, + unsigned char *sig, size_t *slen ) +{ + int ret; + unsigned char buf[MBEDTLS_ECDSA_MAX_LEN]; + unsigned char *p = buf + sizeof( buf ); + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &p, buf, s ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &p, buf, r ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &p, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &p, buf, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ); + + memcpy( sig, p, len ); + *slen = len; + + return( 0 ); +} + +/* + * Compute and write signature + */ +int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hlen, + unsigned char *sig, size_t *slen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_mpi r, s; + + mbedtls_mpi_init( &r ); + mbedtls_mpi_init( &s ); + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + (void) f_rng; + (void) p_rng; + + MBEDTLS_MPI_CHK( mbedtls_ecdsa_sign_det( &ctx->grp, &r, &s, &ctx->d, + hash, hlen, md_alg ) ); +#else + (void) md_alg; + + MBEDTLS_MPI_CHK( mbedtls_ecdsa_sign( &ctx->grp, &r, &s, &ctx->d, + hash, hlen, f_rng, p_rng ) ); +#endif + + MBEDTLS_MPI_CHK( ecdsa_signature_to_asn1( &r, &s, sig, slen ) ); + +cleanup: + mbedtls_mpi_free( &r ); + mbedtls_mpi_free( &s ); + + return( ret ); +} + +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) && \ + defined(MBEDTLS_ECDSA_DETERMINISTIC) +int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + unsigned char *sig, size_t *slen, + mbedtls_md_type_t md_alg ) +{ + return( mbedtls_ecdsa_write_signature( ctx, md_alg, hash, hlen, sig, slen, + NULL, NULL ) ); +} +#endif + +/* + * Read and check signature + */ +int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen ) +{ + int ret; + unsigned char *p = (unsigned char *) sig; + const unsigned char *end = sig + slen; + size_t len; + mbedtls_mpi r, s; + + mbedtls_mpi_init( &r ); + mbedtls_mpi_init( &s ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + if( p + len != end ) + { + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH; + goto cleanup; + } + + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &r ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &s ) ) != 0 ) + { + ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + if( ( ret = mbedtls_ecdsa_verify( &ctx->grp, hash, hlen, + &ctx->Q, &r, &s ) ) != 0 ) + goto cleanup; + + if( p != end ) + ret = MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH; + +cleanup: + mbedtls_mpi_free( &r ); + mbedtls_mpi_free( &s ); + + return( ret ); +} + +/* + * Generate key pair + */ +int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + return( mbedtls_ecp_group_load( &ctx->grp, gid ) || + mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ); +} + +/* + * Set context from an mbedtls_ecp_keypair + */ +int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key ) +{ + int ret; + + if( ( ret = mbedtls_ecp_group_copy( &ctx->grp, &key->grp ) ) != 0 || + ( ret = mbedtls_mpi_copy( &ctx->d, &key->d ) ) != 0 || + ( ret = mbedtls_ecp_copy( &ctx->Q, &key->Q ) ) != 0 ) + { + mbedtls_ecdsa_free( ctx ); + } + + return( ret ); +} + +/* + * Initialize context + */ +void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx ) +{ + mbedtls_ecp_keypair_init( ctx ); +} + +/* + * Free context + */ +void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx ) +{ + mbedtls_ecp_keypair_free( ctx ); +} + +#endif /* MBEDTLS_ECDSA_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecjpake.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecjpake.c new file mode 100644 index 0000000..1fa1c2d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecjpake.c @@ -0,0 +1,1103 @@ +/* + * Elliptic curve J-PAKE + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * References in the code are to the Thread v1.0 Specification, + * available to members of the Thread Group http://threadgroup.org/ + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ECJPAKE_C) + +#include "mbedtls/ecjpake.h" + +#include + +/* + * Convert a mbedtls_ecjpake_role to identifier string + */ +static const char * const ecjpake_id[] = { + "client", + "server" +}; + +#define ID_MINE ( ecjpake_id[ ctx->role ] ) +#define ID_PEER ( ecjpake_id[ 1 - ctx->role ] ) + +/* + * Initialize context + */ +void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx ) +{ + if( ctx == NULL ) + return; + + ctx->md_info = NULL; + mbedtls_ecp_group_init( &ctx->grp ); + ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED; + + mbedtls_ecp_point_init( &ctx->Xm1 ); + mbedtls_ecp_point_init( &ctx->Xm2 ); + mbedtls_ecp_point_init( &ctx->Xp1 ); + mbedtls_ecp_point_init( &ctx->Xp2 ); + mbedtls_ecp_point_init( &ctx->Xp ); + + mbedtls_mpi_init( &ctx->xm1 ); + mbedtls_mpi_init( &ctx->xm2 ); + mbedtls_mpi_init( &ctx->s ); +} + +/* + * Free context + */ +void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx ) +{ + if( ctx == NULL ) + return; + + ctx->md_info = NULL; + mbedtls_ecp_group_free( &ctx->grp ); + + mbedtls_ecp_point_free( &ctx->Xm1 ); + mbedtls_ecp_point_free( &ctx->Xm2 ); + mbedtls_ecp_point_free( &ctx->Xp1 ); + mbedtls_ecp_point_free( &ctx->Xp2 ); + mbedtls_ecp_point_free( &ctx->Xp ); + + mbedtls_mpi_free( &ctx->xm1 ); + mbedtls_mpi_free( &ctx->xm2 ); + mbedtls_mpi_free( &ctx->s ); +} + +/* + * Setup context + */ +int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, + mbedtls_ecjpake_role role, + mbedtls_md_type_t hash, + mbedtls_ecp_group_id curve, + const unsigned char *secret, + size_t len ) +{ + int ret; + + ctx->role = role; + + if( ( ctx->md_info = mbedtls_md_info_from_type( hash ) ) == NULL ) + return( MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE ); + + MBEDTLS_MPI_CHK( mbedtls_ecp_group_load( &ctx->grp, curve ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->s, secret, len ) ); + +cleanup: + if( ret != 0 ) + mbedtls_ecjpake_free( ctx ); + + return( ret ); +} + +/* + * Check if context is ready for use + */ +int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx ) +{ + if( ctx->md_info == NULL || + ctx->grp.id == MBEDTLS_ECP_DP_NONE || + ctx->s.p == NULL ) + { + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + } + + return( 0 ); +} + +/* + * Write a point plus its length to a buffer + */ +static int ecjpake_write_len_point( unsigned char **p, + const unsigned char *end, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *P ) +{ + int ret; + size_t len; + + /* Need at least 4 for length plus 1 for point */ + if( end < *p || end - *p < 5 ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + ret = mbedtls_ecp_point_write_binary( grp, P, pf, + &len, *p + 4, end - ( *p + 4 ) ); + if( ret != 0 ) + return( ret ); + + (*p)[0] = (unsigned char)( ( len >> 24 ) & 0xFF ); + (*p)[1] = (unsigned char)( ( len >> 16 ) & 0xFF ); + (*p)[2] = (unsigned char)( ( len >> 8 ) & 0xFF ); + (*p)[3] = (unsigned char)( ( len ) & 0xFF ); + + *p += 4 + len; + + return( 0 ); +} + +/* + * Size of the temporary buffer for ecjpake_hash: + * 3 EC points plus their length, plus ID and its length (4 + 6 bytes) + */ +#define ECJPAKE_HASH_BUF_LEN ( 3 * ( 4 + MBEDTLS_ECP_MAX_PT_LEN ) + 4 + 6 ) + +/* + * Compute hash for ZKP (7.4.2.2.2.1) + */ +static int ecjpake_hash( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + const mbedtls_ecp_point *V, + const mbedtls_ecp_point *X, + const char *id, + mbedtls_mpi *h ) +{ + int ret; + unsigned char buf[ECJPAKE_HASH_BUF_LEN]; + unsigned char *p = buf; + const unsigned char *end = buf + sizeof( buf ); + const size_t id_len = strlen( id ); + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + + /* Write things to temporary buffer */ + MBEDTLS_MPI_CHK( ecjpake_write_len_point( &p, end, grp, pf, G ) ); + MBEDTLS_MPI_CHK( ecjpake_write_len_point( &p, end, grp, pf, V ) ); + MBEDTLS_MPI_CHK( ecjpake_write_len_point( &p, end, grp, pf, X ) ); + + if( end - p < 4 ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + *p++ = (unsigned char)( ( id_len >> 24 ) & 0xFF ); + *p++ = (unsigned char)( ( id_len >> 16 ) & 0xFF ); + *p++ = (unsigned char)( ( id_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( id_len ) & 0xFF ); + + if( end < p || (size_t)( end - p ) < id_len ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + memcpy( p, id, id_len ); + p += id_len; + + /* Compute hash */ + mbedtls_md( md_info, buf, p - buf, hash ); + + /* Turn it into an integer mod n */ + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( h, hash, + mbedtls_md_get_size( md_info ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( h, h, &grp->N ) ); + +cleanup: + return( ret ); +} + +/* + * Parse a ECShnorrZKP (7.4.2.2.2) and verify it (7.4.2.3.3) + */ +static int ecjpake_zkp_read( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + const mbedtls_ecp_point *X, + const char *id, + const unsigned char **p, + const unsigned char *end ) +{ + int ret; + mbedtls_ecp_point V, VV; + mbedtls_mpi r, h; + size_t r_len; + + mbedtls_ecp_point_init( &V ); + mbedtls_ecp_point_init( &VV ); + mbedtls_mpi_init( &r ); + mbedtls_mpi_init( &h ); + + /* + * struct { + * ECPoint V; + * opaque r<1..2^8-1>; + * } ECSchnorrZKP; + */ + if( end < *p ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_read_point( grp, &V, p, end - *p ) ); + + if( end < *p || (size_t)( end - *p ) < 1 ) + { + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + r_len = *(*p)++; + + if( end < *p || (size_t)( end - *p ) < r_len ) + { + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &r, *p, r_len ) ); + *p += r_len; + + /* + * Verification + */ + MBEDTLS_MPI_CHK( ecjpake_hash( md_info, grp, pf, G, &V, X, id, &h ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( (mbedtls_ecp_group *) grp, + &VV, &h, X, &r, G ) ); + + if( mbedtls_ecp_point_cmp( &VV, &V ) != 0 ) + { + ret = MBEDTLS_ERR_ECP_VERIFY_FAILED; + goto cleanup; + } + +cleanup: + mbedtls_ecp_point_free( &V ); + mbedtls_ecp_point_free( &VV ); + mbedtls_mpi_free( &r ); + mbedtls_mpi_free( &h ); + + return( ret ); +} + +/* + * Generate ZKP (7.4.2.3.2) and write it as ECSchnorrZKP (7.4.2.2.2) + */ +static int ecjpake_zkp_write( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + const mbedtls_mpi *x, + const mbedtls_ecp_point *X, + const char *id, + unsigned char **p, + const unsigned char *end, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_ecp_point V; + mbedtls_mpi v; + mbedtls_mpi h; /* later recycled to hold r */ + size_t len; + + if( end < *p ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + mbedtls_ecp_point_init( &V ); + mbedtls_mpi_init( &v ); + mbedtls_mpi_init( &h ); + + /* Compute signature */ + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_keypair_base( (mbedtls_ecp_group *) grp, + G, &v, &V, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( ecjpake_hash( md_info, grp, pf, G, &V, X, id, &h ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &h, &h, x ) ); /* x*h */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &h, &v, &h ) ); /* v - x*h */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &h, &h, &grp->N ) ); /* r */ + + /* Write it out */ + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_write_point( grp, &V, + pf, &len, *p, end - *p ) ); + *p += len; + + len = mbedtls_mpi_size( &h ); /* actually r */ + if( end < *p || (size_t)( end - *p ) < 1 + len || len > 255 ) + { + ret = MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL; + goto cleanup; + } + + *(*p)++ = (unsigned char)( len & 0xFF ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &h, *p, len ) ); /* r */ + *p += len; + +cleanup: + mbedtls_ecp_point_free( &V ); + mbedtls_mpi_free( &v ); + mbedtls_mpi_free( &h ); + + return( ret ); +} + +/* + * Parse a ECJPAKEKeyKP (7.4.2.2.1) and check proof + * Output: verified public key X + */ +static int ecjpake_kkp_read( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + mbedtls_ecp_point *X, + const char *id, + const unsigned char **p, + const unsigned char *end ) +{ + int ret; + + if( end < *p ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * struct { + * ECPoint X; + * ECSchnorrZKP zkp; + * } ECJPAKEKeyKP; + */ + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_read_point( grp, X, p, end - *p ) ); + if( mbedtls_ecp_is_zero( X ) ) + { + ret = MBEDTLS_ERR_ECP_INVALID_KEY; + goto cleanup; + } + + MBEDTLS_MPI_CHK( ecjpake_zkp_read( md_info, grp, pf, G, X, id, p, end ) ); + +cleanup: + return( ret ); +} + +/* + * Generate an ECJPAKEKeyKP + * Output: the serialized structure, plus private/public key pair + */ +static int ecjpake_kkp_write( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + mbedtls_mpi *x, + mbedtls_ecp_point *X, + const char *id, + unsigned char **p, + const unsigned char *end, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + size_t len; + + if( end < *p ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + /* Generate key (7.4.2.3.1) and write it out */ + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_keypair_base( (mbedtls_ecp_group *) grp, G, x, X, + f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_write_point( grp, X, + pf, &len, *p, end - *p ) ); + *p += len; + + /* Generate and write proof */ + MBEDTLS_MPI_CHK( ecjpake_zkp_write( md_info, grp, pf, G, x, X, id, + p, end, f_rng, p_rng ) ); + +cleanup: + return( ret ); +} + +/* + * Read a ECJPAKEKeyKPPairList (7.4.2.3) and check proofs + * Ouputs: verified peer public keys Xa, Xb + */ +static int ecjpake_kkpp_read( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + mbedtls_ecp_point *Xa, + mbedtls_ecp_point *Xb, + const char *id, + const unsigned char *buf, + size_t len ) +{ + int ret; + const unsigned char *p = buf; + const unsigned char *end = buf + len; + + /* + * struct { + * ECJPAKEKeyKP ecjpake_key_kp_pair_list[2]; + * } ECJPAKEKeyKPPairList; + */ + MBEDTLS_MPI_CHK( ecjpake_kkp_read( md_info, grp, pf, G, Xa, id, &p, end ) ); + MBEDTLS_MPI_CHK( ecjpake_kkp_read( md_info, grp, pf, G, Xb, id, &p, end ) ); + + if( p != end ) + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + +cleanup: + return( ret ); +} + +/* + * Generate a ECJPAKEKeyKPPairList + * Outputs: the serialized structure, plus two private/public key pairs + */ +static int ecjpake_kkpp_write( const mbedtls_md_info_t *md_info, + const mbedtls_ecp_group *grp, + const int pf, + const mbedtls_ecp_point *G, + mbedtls_mpi *xm1, + mbedtls_ecp_point *Xa, + mbedtls_mpi *xm2, + mbedtls_ecp_point *Xb, + const char *id, + unsigned char *buf, + size_t len, + size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + unsigned char *p = buf; + const unsigned char *end = buf + len; + + MBEDTLS_MPI_CHK( ecjpake_kkp_write( md_info, grp, pf, G, xm1, Xa, id, + &p, end, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( ecjpake_kkp_write( md_info, grp, pf, G, xm2, Xb, id, + &p, end, f_rng, p_rng ) ); + + *olen = p - buf; + +cleanup: + return( ret ); +} + +/* + * Read and process the first round message + */ +int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx, + const unsigned char *buf, + size_t len ) +{ + return( ecjpake_kkpp_read( ctx->md_info, &ctx->grp, ctx->point_format, + &ctx->grp.G, + &ctx->Xp1, &ctx->Xp2, ID_PEER, + buf, len ) ); +} + +/* + * Generate and write the first round message + */ +int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx, + unsigned char *buf, size_t len, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + return( ecjpake_kkpp_write( ctx->md_info, &ctx->grp, ctx->point_format, + &ctx->grp.G, + &ctx->xm1, &ctx->Xm1, &ctx->xm2, &ctx->Xm2, + ID_MINE, buf, len, olen, f_rng, p_rng ) ); +} + +/* + * Compute the sum of three points R = A + B + C + */ +static int ecjpake_ecp_add3( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_ecp_point *A, + const mbedtls_ecp_point *B, + const mbedtls_ecp_point *C ) +{ + int ret; + mbedtls_mpi one; + + mbedtls_mpi_init( &one ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &one, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( grp, R, &one, A, &one, B ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( grp, R, &one, R, &one, C ) ); + +cleanup: + mbedtls_mpi_free( &one ); + + return( ret ); +} + +/* + * Read and process second round message (C: 7.4.2.5, S: 7.4.2.6) + */ +int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx, + const unsigned char *buf, + size_t len ) +{ + int ret; + const unsigned char *p = buf; + const unsigned char *end = buf + len; + mbedtls_ecp_group grp; + mbedtls_ecp_point G; /* C: GB, S: GA */ + + mbedtls_ecp_group_init( &grp ); + mbedtls_ecp_point_init( &G ); + + /* + * Server: GA = X3 + X4 + X1 (7.4.2.6.1) + * Client: GB = X1 + X2 + X3 (7.4.2.5.1) + * Unified: G = Xm1 + Xm2 + Xp1 + * We need that before parsing in order to check Xp as we read it + */ + MBEDTLS_MPI_CHK( ecjpake_ecp_add3( &ctx->grp, &G, + &ctx->Xm1, &ctx->Xm2, &ctx->Xp1 ) ); + + /* + * struct { + * ECParameters curve_params; // only client reading server msg + * ECJPAKEKeyKP ecjpake_key_kp; + * } Client/ServerECJPAKEParams; + */ + if( ctx->role == MBEDTLS_ECJPAKE_CLIENT ) + { + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_read_group( &grp, &p, len ) ); + if( grp.id != ctx->grp.id ) + { + ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; + goto cleanup; + } + } + + MBEDTLS_MPI_CHK( ecjpake_kkp_read( ctx->md_info, &ctx->grp, + ctx->point_format, + &G, &ctx->Xp, ID_PEER, &p, end ) ); + + if( p != end ) + { + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + +cleanup: + mbedtls_ecp_group_free( &grp ); + mbedtls_ecp_point_free( &G ); + + return( ret ); +} + +/* + * Compute R = +/- X * S mod N, taking care not to leak S + */ +static int ecjpake_mul_secret( mbedtls_mpi *R, int sign, + const mbedtls_mpi *X, + const mbedtls_mpi *S, + const mbedtls_mpi *N, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_mpi b; /* Blinding value, then s + N * blinding */ + + mbedtls_mpi_init( &b ); + + /* b = s + rnd-128-bit * N */ + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &b, 16, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &b, &b, N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &b, &b, S ) ); + + /* R = sign * X * b mod N */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( R, X, &b ) ); + R->s *= sign; + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( R, R, N ) ); + +cleanup: + mbedtls_mpi_free( &b ); + + return( ret ); +} + +/* + * Generate and write the second round message (S: 7.4.2.5, C: 7.4.2.6) + */ +int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx, + unsigned char *buf, size_t len, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_ecp_point G; /* C: GA, S: GB */ + mbedtls_ecp_point Xm; /* C: Xc, S: Xs */ + mbedtls_mpi xm; /* C: xc, S: xs */ + unsigned char *p = buf; + const unsigned char *end = buf + len; + size_t ec_len; + + mbedtls_ecp_point_init( &G ); + mbedtls_ecp_point_init( &Xm ); + mbedtls_mpi_init( &xm ); + + /* + * First generate private/public key pair (S: 7.4.2.5.1, C: 7.4.2.6.1) + * + * Client: GA = X1 + X3 + X4 | xs = x2 * s | Xc = xc * GA + * Server: GB = X3 + X1 + X2 | xs = x4 * s | Xs = xs * GB + * Unified: G = Xm1 + Xp1 + Xp2 | xm = xm2 * s | Xm = xm * G + */ + MBEDTLS_MPI_CHK( ecjpake_ecp_add3( &ctx->grp, &G, + &ctx->Xp1, &ctx->Xp2, &ctx->Xm1 ) ); + MBEDTLS_MPI_CHK( ecjpake_mul_secret( &xm, 1, &ctx->xm2, &ctx->s, + &ctx->grp.N, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &ctx->grp, &Xm, &xm, &G, f_rng, p_rng ) ); + + /* + * Now write things out + * + * struct { + * ECParameters curve_params; // only server writing its message + * ECJPAKEKeyKP ecjpake_key_kp; + * } Client/ServerECJPAKEParams; + */ + if( ctx->role == MBEDTLS_ECJPAKE_SERVER ) + { + if( end < p ) + { + ret = MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL; + goto cleanup; + } + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_write_group( &ctx->grp, &ec_len, + p, end - p ) ); + p += ec_len; + } + + if( end < p ) + { + ret = MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL; + goto cleanup; + } + MBEDTLS_MPI_CHK( mbedtls_ecp_tls_write_point( &ctx->grp, &Xm, + ctx->point_format, &ec_len, p, end - p ) ); + p += ec_len; + + MBEDTLS_MPI_CHK( ecjpake_zkp_write( ctx->md_info, &ctx->grp, + ctx->point_format, + &G, &xm, &Xm, ID_MINE, + &p, end, f_rng, p_rng ) ); + + *olen = p - buf; + +cleanup: + mbedtls_ecp_point_free( &G ); + mbedtls_ecp_point_free( &Xm ); + mbedtls_mpi_free( &xm ); + + return( ret ); +} + +/* + * Derive PMS (7.4.2.7 / 7.4.2.8) + */ +int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx, + unsigned char *buf, size_t len, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_ecp_point K; + mbedtls_mpi m_xm2_s, one; + unsigned char kx[MBEDTLS_ECP_MAX_BYTES]; + size_t x_bytes; + + *olen = mbedtls_md_get_size( ctx->md_info ); + if( len < *olen ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + mbedtls_ecp_point_init( &K ); + mbedtls_mpi_init( &m_xm2_s ); + mbedtls_mpi_init( &one ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &one, 1 ) ); + + /* + * Client: K = ( Xs - X4 * x2 * s ) * x2 + * Server: K = ( Xc - X2 * x4 * s ) * x4 + * Unified: K = ( Xp - Xp2 * xm2 * s ) * xm2 + */ + MBEDTLS_MPI_CHK( ecjpake_mul_secret( &m_xm2_s, -1, &ctx->xm2, &ctx->s, + &ctx->grp.N, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( &ctx->grp, &K, + &one, &ctx->Xp, + &m_xm2_s, &ctx->Xp2 ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &ctx->grp, &K, &ctx->xm2, &K, + f_rng, p_rng ) ); + + /* PMS = SHA-256( K.X ) */ + x_bytes = ( ctx->grp.pbits + 7 ) / 8; + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &K.X, kx, x_bytes ) ); + MBEDTLS_MPI_CHK( mbedtls_md( ctx->md_info, kx, x_bytes, buf ) ); + +cleanup: + mbedtls_ecp_point_free( &K ); + mbedtls_mpi_free( &m_xm2_s ); + mbedtls_mpi_free( &one ); + + return( ret ); +} + +#undef ID_MINE +#undef ID_PEER + + +#if defined(MBEDTLS_SELF_TEST) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ + !defined(MBEDTLS_SHA256_C) +int mbedtls_ecjpake_self_test( int verbose ) +{ + (void) verbose; + return( 0 ); +} +#else + +static const unsigned char ecjpake_test_password[] = { + 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x6a, 0x70, 0x61, 0x6b, 0x65, 0x74, + 0x65, 0x73, 0x74 +}; + +static const unsigned char ecjpake_test_x1[] = { + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x21 +}; + +static const unsigned char ecjpake_test_x2[] = { + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x81 +}; + +static const unsigned char ecjpake_test_x3[] = { + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x81 +}; + +static const unsigned char ecjpake_test_x4[] = { + 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, + 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, + 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe1 +}; + +static const unsigned char ecjpake_test_cli_one[] = { + 0x41, 0x04, 0xac, 0xcf, 0x01, 0x06, 0xef, 0x85, 0x8f, 0xa2, 0xd9, 0x19, + 0x33, 0x13, 0x46, 0x80, 0x5a, 0x78, 0xb5, 0x8b, 0xba, 0xd0, 0xb8, 0x44, + 0xe5, 0xc7, 0x89, 0x28, 0x79, 0x14, 0x61, 0x87, 0xdd, 0x26, 0x66, 0xad, + 0xa7, 0x81, 0xbb, 0x7f, 0x11, 0x13, 0x72, 0x25, 0x1a, 0x89, 0x10, 0x62, + 0x1f, 0x63, 0x4d, 0xf1, 0x28, 0xac, 0x48, 0xe3, 0x81, 0xfd, 0x6e, 0xf9, + 0x06, 0x07, 0x31, 0xf6, 0x94, 0xa4, 0x41, 0x04, 0x1d, 0xd0, 0xbd, 0x5d, + 0x45, 0x66, 0xc9, 0xbe, 0xd9, 0xce, 0x7d, 0xe7, 0x01, 0xb5, 0xe8, 0x2e, + 0x08, 0xe8, 0x4b, 0x73, 0x04, 0x66, 0x01, 0x8a, 0xb9, 0x03, 0xc7, 0x9e, + 0xb9, 0x82, 0x17, 0x22, 0x36, 0xc0, 0xc1, 0x72, 0x8a, 0xe4, 0xbf, 0x73, + 0x61, 0x0d, 0x34, 0xde, 0x44, 0x24, 0x6e, 0xf3, 0xd9, 0xc0, 0x5a, 0x22, + 0x36, 0xfb, 0x66, 0xa6, 0x58, 0x3d, 0x74, 0x49, 0x30, 0x8b, 0xab, 0xce, + 0x20, 0x72, 0xfe, 0x16, 0x66, 0x29, 0x92, 0xe9, 0x23, 0x5c, 0x25, 0x00, + 0x2f, 0x11, 0xb1, 0x50, 0x87, 0xb8, 0x27, 0x38, 0xe0, 0x3c, 0x94, 0x5b, + 0xf7, 0xa2, 0x99, 0x5d, 0xda, 0x1e, 0x98, 0x34, 0x58, 0x41, 0x04, 0x7e, + 0xa6, 0xe3, 0xa4, 0x48, 0x70, 0x37, 0xa9, 0xe0, 0xdb, 0xd7, 0x92, 0x62, + 0xb2, 0xcc, 0x27, 0x3e, 0x77, 0x99, 0x30, 0xfc, 0x18, 0x40, 0x9a, 0xc5, + 0x36, 0x1c, 0x5f, 0xe6, 0x69, 0xd7, 0x02, 0xe1, 0x47, 0x79, 0x0a, 0xeb, + 0x4c, 0xe7, 0xfd, 0x65, 0x75, 0xab, 0x0f, 0x6c, 0x7f, 0xd1, 0xc3, 0x35, + 0x93, 0x9a, 0xa8, 0x63, 0xba, 0x37, 0xec, 0x91, 0xb7, 0xe3, 0x2b, 0xb0, + 0x13, 0xbb, 0x2b, 0x41, 0x04, 0xa4, 0x95, 0x58, 0xd3, 0x2e, 0xd1, 0xeb, + 0xfc, 0x18, 0x16, 0xaf, 0x4f, 0xf0, 0x9b, 0x55, 0xfc, 0xb4, 0xca, 0x47, + 0xb2, 0xa0, 0x2d, 0x1e, 0x7c, 0xaf, 0x11, 0x79, 0xea, 0x3f, 0xe1, 0x39, + 0x5b, 0x22, 0xb8, 0x61, 0x96, 0x40, 0x16, 0xfa, 0xba, 0xf7, 0x2c, 0x97, + 0x56, 0x95, 0xd9, 0x3d, 0x4d, 0xf0, 0xe5, 0x19, 0x7f, 0xe9, 0xf0, 0x40, + 0x63, 0x4e, 0xd5, 0x97, 0x64, 0x93, 0x77, 0x87, 0xbe, 0x20, 0xbc, 0x4d, + 0xee, 0xbb, 0xf9, 0xb8, 0xd6, 0x0a, 0x33, 0x5f, 0x04, 0x6c, 0xa3, 0xaa, + 0x94, 0x1e, 0x45, 0x86, 0x4c, 0x7c, 0xad, 0xef, 0x9c, 0xf7, 0x5b, 0x3d, + 0x8b, 0x01, 0x0e, 0x44, 0x3e, 0xf0 +}; + +static const unsigned char ecjpake_test_srv_one[] = { + 0x41, 0x04, 0x7e, 0xa6, 0xe3, 0xa4, 0x48, 0x70, 0x37, 0xa9, 0xe0, 0xdb, + 0xd7, 0x92, 0x62, 0xb2, 0xcc, 0x27, 0x3e, 0x77, 0x99, 0x30, 0xfc, 0x18, + 0x40, 0x9a, 0xc5, 0x36, 0x1c, 0x5f, 0xe6, 0x69, 0xd7, 0x02, 0xe1, 0x47, + 0x79, 0x0a, 0xeb, 0x4c, 0xe7, 0xfd, 0x65, 0x75, 0xab, 0x0f, 0x6c, 0x7f, + 0xd1, 0xc3, 0x35, 0x93, 0x9a, 0xa8, 0x63, 0xba, 0x37, 0xec, 0x91, 0xb7, + 0xe3, 0x2b, 0xb0, 0x13, 0xbb, 0x2b, 0x41, 0x04, 0x09, 0xf8, 0x5b, 0x3d, + 0x20, 0xeb, 0xd7, 0x88, 0x5c, 0xe4, 0x64, 0xc0, 0x8d, 0x05, 0x6d, 0x64, + 0x28, 0xfe, 0x4d, 0xd9, 0x28, 0x7a, 0xa3, 0x65, 0xf1, 0x31, 0xf4, 0x36, + 0x0f, 0xf3, 0x86, 0xd8, 0x46, 0x89, 0x8b, 0xc4, 0xb4, 0x15, 0x83, 0xc2, + 0xa5, 0x19, 0x7f, 0x65, 0xd7, 0x87, 0x42, 0x74, 0x6c, 0x12, 0xa5, 0xec, + 0x0a, 0x4f, 0xfe, 0x2f, 0x27, 0x0a, 0x75, 0x0a, 0x1d, 0x8f, 0xb5, 0x16, + 0x20, 0x93, 0x4d, 0x74, 0xeb, 0x43, 0xe5, 0x4d, 0xf4, 0x24, 0xfd, 0x96, + 0x30, 0x6c, 0x01, 0x17, 0xbf, 0x13, 0x1a, 0xfa, 0xbf, 0x90, 0xa9, 0xd3, + 0x3d, 0x11, 0x98, 0xd9, 0x05, 0x19, 0x37, 0x35, 0x14, 0x41, 0x04, 0x19, + 0x0a, 0x07, 0x70, 0x0f, 0xfa, 0x4b, 0xe6, 0xae, 0x1d, 0x79, 0xee, 0x0f, + 0x06, 0xae, 0xb5, 0x44, 0xcd, 0x5a, 0xdd, 0xaa, 0xbe, 0xdf, 0x70, 0xf8, + 0x62, 0x33, 0x21, 0x33, 0x2c, 0x54, 0xf3, 0x55, 0xf0, 0xfb, 0xfe, 0xc7, + 0x83, 0xed, 0x35, 0x9e, 0x5d, 0x0b, 0xf7, 0x37, 0x7a, 0x0f, 0xc4, 0xea, + 0x7a, 0xce, 0x47, 0x3c, 0x9c, 0x11, 0x2b, 0x41, 0xcc, 0xd4, 0x1a, 0xc5, + 0x6a, 0x56, 0x12, 0x41, 0x04, 0x36, 0x0a, 0x1c, 0xea, 0x33, 0xfc, 0xe6, + 0x41, 0x15, 0x64, 0x58, 0xe0, 0xa4, 0xea, 0xc2, 0x19, 0xe9, 0x68, 0x31, + 0xe6, 0xae, 0xbc, 0x88, 0xb3, 0xf3, 0x75, 0x2f, 0x93, 0xa0, 0x28, 0x1d, + 0x1b, 0xf1, 0xfb, 0x10, 0x60, 0x51, 0xdb, 0x96, 0x94, 0xa8, 0xd6, 0xe8, + 0x62, 0xa5, 0xef, 0x13, 0x24, 0xa3, 0xd9, 0xe2, 0x78, 0x94, 0xf1, 0xee, + 0x4f, 0x7c, 0x59, 0x19, 0x99, 0x65, 0xa8, 0xdd, 0x4a, 0x20, 0x91, 0x84, + 0x7d, 0x2d, 0x22, 0xdf, 0x3e, 0xe5, 0x5f, 0xaa, 0x2a, 0x3f, 0xb3, 0x3f, + 0xd2, 0xd1, 0xe0, 0x55, 0xa0, 0x7a, 0x7c, 0x61, 0xec, 0xfb, 0x8d, 0x80, + 0xec, 0x00, 0xc2, 0xc9, 0xeb, 0x12 +}; + +static const unsigned char ecjpake_test_srv_two[] = { + 0x03, 0x00, 0x17, 0x41, 0x04, 0x0f, 0xb2, 0x2b, 0x1d, 0x5d, 0x11, 0x23, + 0xe0, 0xef, 0x9f, 0xeb, 0x9d, 0x8a, 0x2e, 0x59, 0x0a, 0x1f, 0x4d, 0x7c, + 0xed, 0x2c, 0x2b, 0x06, 0x58, 0x6e, 0x8f, 0x2a, 0x16, 0xd4, 0xeb, 0x2f, + 0xda, 0x43, 0x28, 0xa2, 0x0b, 0x07, 0xd8, 0xfd, 0x66, 0x76, 0x54, 0xca, + 0x18, 0xc5, 0x4e, 0x32, 0xa3, 0x33, 0xa0, 0x84, 0x54, 0x51, 0xe9, 0x26, + 0xee, 0x88, 0x04, 0xfd, 0x7a, 0xf0, 0xaa, 0xa7, 0xa6, 0x41, 0x04, 0x55, + 0x16, 0xea, 0x3e, 0x54, 0xa0, 0xd5, 0xd8, 0xb2, 0xce, 0x78, 0x6b, 0x38, + 0xd3, 0x83, 0x37, 0x00, 0x29, 0xa5, 0xdb, 0xe4, 0x45, 0x9c, 0x9d, 0xd6, + 0x01, 0xb4, 0x08, 0xa2, 0x4a, 0xe6, 0x46, 0x5c, 0x8a, 0xc9, 0x05, 0xb9, + 0xeb, 0x03, 0xb5, 0xd3, 0x69, 0x1c, 0x13, 0x9e, 0xf8, 0x3f, 0x1c, 0xd4, + 0x20, 0x0f, 0x6c, 0x9c, 0xd4, 0xec, 0x39, 0x22, 0x18, 0xa5, 0x9e, 0xd2, + 0x43, 0xd3, 0xc8, 0x20, 0xff, 0x72, 0x4a, 0x9a, 0x70, 0xb8, 0x8c, 0xb8, + 0x6f, 0x20, 0xb4, 0x34, 0xc6, 0x86, 0x5a, 0xa1, 0xcd, 0x79, 0x06, 0xdd, + 0x7c, 0x9b, 0xce, 0x35, 0x25, 0xf5, 0x08, 0x27, 0x6f, 0x26, 0x83, 0x6c +}; + +static const unsigned char ecjpake_test_cli_two[] = { + 0x41, 0x04, 0x69, 0xd5, 0x4e, 0xe8, 0x5e, 0x90, 0xce, 0x3f, 0x12, 0x46, + 0x74, 0x2d, 0xe5, 0x07, 0xe9, 0x39, 0xe8, 0x1d, 0x1d, 0xc1, 0xc5, 0xcb, + 0x98, 0x8b, 0x58, 0xc3, 0x10, 0xc9, 0xfd, 0xd9, 0x52, 0x4d, 0x93, 0x72, + 0x0b, 0x45, 0x54, 0x1c, 0x83, 0xee, 0x88, 0x41, 0x19, 0x1d, 0xa7, 0xce, + 0xd8, 0x6e, 0x33, 0x12, 0xd4, 0x36, 0x23, 0xc1, 0xd6, 0x3e, 0x74, 0x98, + 0x9a, 0xba, 0x4a, 0xff, 0xd1, 0xee, 0x41, 0x04, 0x07, 0x7e, 0x8c, 0x31, + 0xe2, 0x0e, 0x6b, 0xed, 0xb7, 0x60, 0xc1, 0x35, 0x93, 0xe6, 0x9f, 0x15, + 0xbe, 0x85, 0xc2, 0x7d, 0x68, 0xcd, 0x09, 0xcc, 0xb8, 0xc4, 0x18, 0x36, + 0x08, 0x91, 0x7c, 0x5c, 0x3d, 0x40, 0x9f, 0xac, 0x39, 0xfe, 0xfe, 0xe8, + 0x2f, 0x72, 0x92, 0xd3, 0x6f, 0x0d, 0x23, 0xe0, 0x55, 0x91, 0x3f, 0x45, + 0xa5, 0x2b, 0x85, 0xdd, 0x8a, 0x20, 0x52, 0xe9, 0xe1, 0x29, 0xbb, 0x4d, + 0x20, 0x0f, 0x01, 0x1f, 0x19, 0x48, 0x35, 0x35, 0xa6, 0xe8, 0x9a, 0x58, + 0x0c, 0x9b, 0x00, 0x03, 0xba, 0xf2, 0x14, 0x62, 0xec, 0xe9, 0x1a, 0x82, + 0xcc, 0x38, 0xdb, 0xdc, 0xae, 0x60, 0xd9, 0xc5, 0x4c +}; + +static const unsigned char ecjpake_test_pms[] = { + 0xf3, 0xd4, 0x7f, 0x59, 0x98, 0x44, 0xdb, 0x92, 0xa5, 0x69, 0xbb, 0xe7, + 0x98, 0x1e, 0x39, 0xd9, 0x31, 0xfd, 0x74, 0x3b, 0xf2, 0x2e, 0x98, 0xf9, + 0xb4, 0x38, 0xf7, 0x19, 0xd3, 0xc4, 0xf3, 0x51 +}; + +/* Load my private keys and generate the correponding public keys */ +static int ecjpake_test_load( mbedtls_ecjpake_context *ctx, + const unsigned char *xm1, size_t len1, + const unsigned char *xm2, size_t len2 ) +{ + int ret; + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->xm1, xm1, len1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->xm2, xm2, len2 ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &ctx->grp, &ctx->Xm1, &ctx->xm1, + &ctx->grp.G, NULL, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &ctx->grp, &ctx->Xm2, &ctx->xm2, + &ctx->grp.G, NULL, NULL ) ); + +cleanup: + return( ret ); +} + +/* For tests we don't need a secure RNG; + * use the LGC from Numerical Recipes for simplicity */ +static int ecjpake_lgc( void *p, unsigned char *out, size_t len ) +{ + static uint32_t x = 42; + (void) p; + + while( len > 0 ) + { + size_t use_len = len > 4 ? 4 : len; + x = 1664525 * x + 1013904223; + memcpy( out, &x, use_len ); + out += use_len; + len -= use_len; + } + + return( 0 ); +} + +#define TEST_ASSERT( x ) \ + do { \ + if( x ) \ + ret = 0; \ + else \ + { \ + ret = 1; \ + goto cleanup; \ + } \ + } while( 0 ) + +/* + * Checkup routine + */ +int mbedtls_ecjpake_self_test( int verbose ) +{ + int ret; + mbedtls_ecjpake_context cli; + mbedtls_ecjpake_context srv; + unsigned char buf[512], pms[32]; + size_t len, pmslen; + + mbedtls_ecjpake_init( &cli ); + mbedtls_ecjpake_init( &srv ); + + if( verbose != 0 ) + mbedtls_printf( " ECJPAKE test #0 (setup): " ); + + TEST_ASSERT( mbedtls_ecjpake_setup( &cli, MBEDTLS_ECJPAKE_CLIENT, + MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, + ecjpake_test_password, + sizeof( ecjpake_test_password ) ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_setup( &srv, MBEDTLS_ECJPAKE_SERVER, + MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, + ecjpake_test_password, + sizeof( ecjpake_test_password ) ) == 0 ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " ECJPAKE test #1 (random handshake): " ); + + TEST_ASSERT( mbedtls_ecjpake_write_round_one( &cli, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_read_round_one( &srv, buf, len ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_write_round_one( &srv, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_read_round_one( &cli, buf, len ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_write_round_two( &srv, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_read_round_two( &cli, buf, len ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_derive_secret( &cli, + pms, sizeof( pms ), &pmslen, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_write_round_two( &cli, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_read_round_two( &srv, buf, len ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_derive_secret( &srv, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( len == pmslen ); + TEST_ASSERT( memcmp( buf, pms, len ) == 0 ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " ECJPAKE test #2 (reference handshake): " ); + + /* Simulate generation of round one */ + MBEDTLS_MPI_CHK( ecjpake_test_load( &cli, + ecjpake_test_x1, sizeof( ecjpake_test_x1 ), + ecjpake_test_x2, sizeof( ecjpake_test_x2 ) ) ); + + MBEDTLS_MPI_CHK( ecjpake_test_load( &srv, + ecjpake_test_x3, sizeof( ecjpake_test_x3 ), + ecjpake_test_x4, sizeof( ecjpake_test_x4 ) ) ); + + /* Read round one */ + TEST_ASSERT( mbedtls_ecjpake_read_round_one( &srv, + ecjpake_test_cli_one, + sizeof( ecjpake_test_cli_one ) ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_read_round_one( &cli, + ecjpake_test_srv_one, + sizeof( ecjpake_test_srv_one ) ) == 0 ); + + /* Skip generation of round two, read round two */ + TEST_ASSERT( mbedtls_ecjpake_read_round_two( &cli, + ecjpake_test_srv_two, + sizeof( ecjpake_test_srv_two ) ) == 0 ); + + TEST_ASSERT( mbedtls_ecjpake_read_round_two( &srv, + ecjpake_test_cli_two, + sizeof( ecjpake_test_cli_two ) ) == 0 ); + + /* Server derives PMS */ + TEST_ASSERT( mbedtls_ecjpake_derive_secret( &srv, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( len == sizeof( ecjpake_test_pms ) ); + TEST_ASSERT( memcmp( buf, ecjpake_test_pms, len ) == 0 ); + + memset( buf, 0, len ); /* Avoid interferences with next step */ + + /* Client derives PMS */ + TEST_ASSERT( mbedtls_ecjpake_derive_secret( &cli, + buf, sizeof( buf ), &len, ecjpake_lgc, NULL ) == 0 ); + + TEST_ASSERT( len == sizeof( ecjpake_test_pms ) ); + TEST_ASSERT( memcmp( buf, ecjpake_test_pms, len ) == 0 ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + +cleanup: + mbedtls_ecjpake_free( &cli ); + mbedtls_ecjpake_free( &srv ); + + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( ret ); +} + +#undef TEST_ASSERT + +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED && MBEDTLS_SHA256_C */ + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_ECJPAKE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp.c new file mode 100644 index 0000000..f51f225 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp.c @@ -0,0 +1,2092 @@ +/* + * Elliptic curves over GF(p): generic functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * References: + * + * SEC1 http://www.secg.org/index.php?action=secg,docs_secg + * GECC = Guide to Elliptic Curve Cryptography - Hankerson, Menezes, Vanstone + * FIPS 186-3 http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf + * RFC 4492 for the related TLS structures and constants + * + * [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf + * + * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis + * for elliptic curve cryptosystems. In : Cryptographic Hardware and + * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. + * + * + * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to + * render ECC resistant against Side Channel Attacks. IACR Cryptology + * ePrint Archive, 2004, vol. 2004, p. 342. + * + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ECP_C) + +#include "mbedtls/ecp.h" + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +#if defined(MBEDTLS_SELF_TEST) +/* + * Counts of point addition and doubling, and field multiplications. + * Used to test resistance of point multiplication to simple timing attacks. + */ +static unsigned long add_count, dbl_count, mul_count; +#endif + +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) +#define ECP_SHORTWEIERSTRASS +#endif + +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +#define ECP_MONTGOMERY +#endif + +/* + * Curve types: internal for now, might be exposed later + */ +typedef enum +{ + ECP_TYPE_NONE = 0, + ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */ + ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */ +} ecp_curve_type; + +/* + * List of supported curves: + * - internal ID + * - TLS NamedCurve ID (RFC 4492 sec. 5.1.1, RFC 7071 sec. 2) + * - size in bits + * - readable name + * + * Curves are listed in order: largest curves first, and for a given size, + * fastest curves first. This provides the default order for the SSL module. + * + * Reminder: update profiles in x509_crt.c when adding a new curves! + */ +static const mbedtls_ecp_curve_info ecp_supported_curves[] = +{ +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + { MBEDTLS_ECP_DP_SECP521R1, 25, 521, "secp521r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) + { MBEDTLS_ECP_DP_BP512R1, 28, 512, "brainpoolP512r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + { MBEDTLS_ECP_DP_SECP384R1, 24, 384, "secp384r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) + { MBEDTLS_ECP_DP_BP384R1, 27, 384, "brainpoolP384r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + { MBEDTLS_ECP_DP_SECP256R1, 23, 256, "secp256r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) + { MBEDTLS_ECP_DP_SECP256K1, 22, 256, "secp256k1" }, +#endif +#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) + { MBEDTLS_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) + { MBEDTLS_ECP_DP_SECP224R1, 21, 224, "secp224r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) + { MBEDTLS_ECP_DP_SECP224K1, 20, 224, "secp224k1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + { MBEDTLS_ECP_DP_SECP192R1, 19, 192, "secp192r1" }, +#endif +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) + { MBEDTLS_ECP_DP_SECP192K1, 18, 192, "secp192k1" }, +#endif + { MBEDTLS_ECP_DP_NONE, 0, 0, NULL }, +}; + +#define ECP_NB_CURVES sizeof( ecp_supported_curves ) / \ + sizeof( ecp_supported_curves[0] ) + +static mbedtls_ecp_group_id ecp_supported_grp_id[ECP_NB_CURVES]; + +/* + * List of supported curves and associated info + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ) +{ + return( ecp_supported_curves ); +} + +/* + * List of supported curves, group ID only + */ +const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void ) +{ + static int init_done = 0; + + if( ! init_done ) + { + size_t i = 0; + const mbedtls_ecp_curve_info *curve_info; + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + ecp_supported_grp_id[i++] = curve_info->grp_id; + } + ecp_supported_grp_id[i] = MBEDTLS_ECP_DP_NONE; + + init_done = 1; + } + + return( ecp_supported_grp_id ); +} + +/* + * Get the curve info for the internal identifier + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id ) +{ + const mbedtls_ecp_curve_info *curve_info; + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + if( curve_info->grp_id == grp_id ) + return( curve_info ); + } + + return( NULL ); +} + +/* + * Get the curve info from the TLS identifier + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id ) +{ + const mbedtls_ecp_curve_info *curve_info; + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + if( curve_info->tls_id == tls_id ) + return( curve_info ); + } + + return( NULL ); +} + +/* + * Get the curve info from the name + */ +const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name ) +{ + const mbedtls_ecp_curve_info *curve_info; + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + if( strcmp( curve_info->name, name ) == 0 ) + return( curve_info ); + } + + return( NULL ); +} + +/* + * Get the type of a curve + */ +static inline ecp_curve_type ecp_get_type( const mbedtls_ecp_group *grp ) +{ + if( grp->G.X.p == NULL ) + return( ECP_TYPE_NONE ); + + if( grp->G.Y.p == NULL ) + return( ECP_TYPE_MONTGOMERY ); + else + return( ECP_TYPE_SHORT_WEIERSTRASS ); +} + +/* + * Initialize (the components of) a point + */ +void mbedtls_ecp_point_init( mbedtls_ecp_point *pt ) +{ + if( pt == NULL ) + return; + + mbedtls_mpi_init( &pt->X ); + mbedtls_mpi_init( &pt->Y ); + mbedtls_mpi_init( &pt->Z ); +} + +/* + * Initialize (the components of) a group + */ +void mbedtls_ecp_group_init( mbedtls_ecp_group *grp ) +{ + if( grp == NULL ) + return; + + memset( grp, 0, sizeof( mbedtls_ecp_group ) ); +} + +/* + * Initialize (the components of) a key pair + */ +void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key ) +{ + if( key == NULL ) + return; + + mbedtls_ecp_group_init( &key->grp ); + mbedtls_mpi_init( &key->d ); + mbedtls_ecp_point_init( &key->Q ); +} + +/* + * Unallocate (the components of) a point + */ +void mbedtls_ecp_point_free( mbedtls_ecp_point *pt ) +{ + if( pt == NULL ) + return; + + mbedtls_mpi_free( &( pt->X ) ); + mbedtls_mpi_free( &( pt->Y ) ); + mbedtls_mpi_free( &( pt->Z ) ); +} + +/* + * Unallocate (the components of) a group + */ +void mbedtls_ecp_group_free( mbedtls_ecp_group *grp ) +{ + size_t i; + + if( grp == NULL ) + return; + + if( grp->h != 1 ) + { + mbedtls_mpi_free( &grp->P ); + mbedtls_mpi_free( &grp->A ); + mbedtls_mpi_free( &grp->B ); + mbedtls_ecp_point_free( &grp->G ); + mbedtls_mpi_free( &grp->N ); + } + + if( grp->T != NULL ) + { + for( i = 0; i < grp->T_size; i++ ) + mbedtls_ecp_point_free( &grp->T[i] ); + mbedtls_free( grp->T ); + } + + mbedtls_zeroize( grp, sizeof( mbedtls_ecp_group ) ); +} + +/* + * Unallocate (the components of) a key pair + */ +void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key ) +{ + if( key == NULL ) + return; + + mbedtls_ecp_group_free( &key->grp ); + mbedtls_mpi_free( &key->d ); + mbedtls_ecp_point_free( &key->Q ); +} + +/* + * Copy the contents of a point + */ +int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ) +{ + int ret; + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &P->X, &Q->X ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &P->Y, &Q->Y ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &P->Z, &Q->Z ) ); + +cleanup: + return( ret ); +} + +/* + * Copy the contents of a group object + */ +int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src ) +{ + return mbedtls_ecp_group_load( dst, src->id ); +} + +/* + * Set point to zero + */ +int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt ) +{ + int ret; + + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->X , 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->Y , 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->Z , 0 ) ); + +cleanup: + return( ret ); +} + +/* + * Tell if a point is zero + */ +int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt ) +{ + return( mbedtls_mpi_cmp_int( &pt->Z, 0 ) == 0 ); +} + +/* + * Compare two points lazyly + */ +int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P, + const mbedtls_ecp_point *Q ) +{ + if( mbedtls_mpi_cmp_mpi( &P->X, &Q->X ) == 0 && + mbedtls_mpi_cmp_mpi( &P->Y, &Q->Y ) == 0 && + mbedtls_mpi_cmp_mpi( &P->Z, &Q->Z ) == 0 ) + { + return( 0 ); + } + + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); +} + +/* + * Import a non-zero point from ASCII strings + */ +int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix, + const char *x, const char *y ) +{ + int ret; + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &P->X, radix, x ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &P->Y, radix, y ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &P->Z, 1 ) ); + +cleanup: + return( ret ); +} + +/* + * Export a point into unsigned binary data (SEC1 2.3.3) + */ +int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, + int format, size_t *olen, + unsigned char *buf, size_t buflen ) +{ + int ret = 0; + size_t plen; + + if( format != MBEDTLS_ECP_PF_UNCOMPRESSED && + format != MBEDTLS_ECP_PF_COMPRESSED ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Common case: P == 0 + */ + if( mbedtls_mpi_cmp_int( &P->Z, 0 ) == 0 ) + { + if( buflen < 1 ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + buf[0] = 0x00; + *olen = 1; + + return( 0 ); + } + + plen = mbedtls_mpi_size( &grp->P ); + + if( format == MBEDTLS_ECP_PF_UNCOMPRESSED ) + { + *olen = 2 * plen + 1; + + if( buflen < *olen ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + buf[0] = 0x04; + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &P->X, buf + 1, plen ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &P->Y, buf + 1 + plen, plen ) ); + } + else if( format == MBEDTLS_ECP_PF_COMPRESSED ) + { + *olen = plen + 1; + + if( buflen < *olen ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + buf[0] = 0x02 + mbedtls_mpi_get_bit( &P->Y, 0 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &P->X, buf + 1, plen ) ); + } + +cleanup: + return( ret ); +} + +/* + * Import a point from unsigned binary data (SEC1 2.3.4) + */ +int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, + const unsigned char *buf, size_t ilen ) +{ + int ret; + size_t plen; + + if( ilen < 1 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( buf[0] == 0x00 ) + { + if( ilen == 1 ) + return( mbedtls_ecp_set_zero( pt ) ); + else + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + } + + plen = mbedtls_mpi_size( &grp->P ); + + if( buf[0] != 0x04 ) + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); + + if( ilen != 2 * plen + 1 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &pt->X, buf + 1, plen ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &pt->Y, buf + 1 + plen, plen ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->Z, 1 ) ); + +cleanup: + return( ret ); +} + +/* + * Import a point from a TLS ECPoint record (RFC 4492) + * struct { + * opaque point <1..2^8-1>; + * } ECPoint; + */ +int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, + const unsigned char **buf, size_t buf_len ) +{ + unsigned char data_len; + const unsigned char *buf_start; + + /* + * We must have at least two bytes (1 for length, at least one for data) + */ + if( buf_len < 2 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + data_len = *(*buf)++; + if( data_len < 1 || data_len > buf_len - 1 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Save buffer start for read_binary and update buf + */ + buf_start = *buf; + *buf += data_len; + + return mbedtls_ecp_point_read_binary( grp, pt, buf_start, data_len ); +} + +/* + * Export a point as a TLS ECPoint record (RFC 4492) + * struct { + * opaque point <1..2^8-1>; + * } ECPoint; + */ +int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt, + int format, size_t *olen, + unsigned char *buf, size_t blen ) +{ + int ret; + + /* + * buffer length must be at least one, for our length byte + */ + if( blen < 1 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecp_point_write_binary( grp, pt, format, + olen, buf + 1, blen - 1) ) != 0 ) + return( ret ); + + /* + * write length to the first byte and update total length + */ + buf[0] = (unsigned char) *olen; + ++*olen; + + return( 0 ); +} + +/* + * Set a group from an ECParameters record (RFC 4492) + */ +int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len ) +{ + uint16_t tls_id; + const mbedtls_ecp_curve_info *curve_info; + + /* + * We expect at least three bytes (see below) + */ + if( len < 3 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * First byte is curve_type; only named_curve is handled + */ + if( *(*buf)++ != MBEDTLS_ECP_TLS_NAMED_CURVE ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Next two bytes are the namedcurve value + */ + tls_id = *(*buf)++; + tls_id <<= 8; + tls_id |= *(*buf)++; + + if( ( curve_info = mbedtls_ecp_curve_info_from_tls_id( tls_id ) ) == NULL ) + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); + + return mbedtls_ecp_group_load( grp, curve_info->grp_id ); +} + +/* + * Write the ECParameters record corresponding to a group (RFC 4492) + */ +int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, + unsigned char *buf, size_t blen ) +{ + const mbedtls_ecp_curve_info *curve_info; + + if( ( curve_info = mbedtls_ecp_curve_info_from_grp_id( grp->id ) ) == NULL ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * We are going to write 3 bytes (see below) + */ + *olen = 3; + if( blen < *olen ) + return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + + /* + * First byte is curve_type, always named_curve + */ + *buf++ = MBEDTLS_ECP_TLS_NAMED_CURVE; + + /* + * Next two bytes are the namedcurve value + */ + buf[0] = curve_info->tls_id >> 8; + buf[1] = curve_info->tls_id & 0xFF; + + return( 0 ); +} + +/* + * Wrapper around fast quasi-modp functions, with fall-back to mbedtls_mpi_mod_mpi. + * See the documentation of struct mbedtls_ecp_group. + * + * This function is in the critial loop for mbedtls_ecp_mul, so pay attention to perf. + */ +static int ecp_modp( mbedtls_mpi *N, const mbedtls_ecp_group *grp ) +{ + int ret; + + if( grp->modp == NULL ) + return( mbedtls_mpi_mod_mpi( N, N, &grp->P ) ); + + /* N->s < 0 is a much faster test, which fails only if N is 0 */ + if( ( N->s < 0 && mbedtls_mpi_cmp_int( N, 0 ) != 0 ) || + mbedtls_mpi_bitlen( N ) > 2 * grp->pbits ) + { + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + } + + MBEDTLS_MPI_CHK( grp->modp( N ) ); + + /* N->s < 0 is a much faster test, which fails only if N is 0 */ + while( N->s < 0 && mbedtls_mpi_cmp_int( N, 0 ) != 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( N, N, &grp->P ) ); + + while( mbedtls_mpi_cmp_mpi( N, &grp->P ) >= 0 ) + /* we known P, N and the result are positive */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( N, N, &grp->P ) ); + +cleanup: + return( ret ); +} + +/* + * Fast mod-p functions expect their argument to be in the 0..p^2 range. + * + * In order to guarantee that, we need to ensure that operands of + * mbedtls_mpi_mul_mpi are in the 0..p range. So, after each operation we will + * bring the result back to this range. + * + * The following macros are shortcuts for doing that. + */ + +/* + * Reduce a mbedtls_mpi mod p in-place, general case, to use after mbedtls_mpi_mul_mpi + */ +#if defined(MBEDTLS_SELF_TEST) +#define INC_MUL_COUNT mul_count++; +#else +#define INC_MUL_COUNT +#endif + +#define MOD_MUL( N ) do { MBEDTLS_MPI_CHK( ecp_modp( &N, grp ) ); INC_MUL_COUNT } \ + while( 0 ) + +/* + * Reduce a mbedtls_mpi mod p in-place, to use after mbedtls_mpi_sub_mpi + * N->s < 0 is a very fast test, which fails only if N is 0 + */ +#define MOD_SUB( N ) \ + while( N.s < 0 && mbedtls_mpi_cmp_int( &N, 0 ) != 0 ) \ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &N, &N, &grp->P ) ) + +/* + * Reduce a mbedtls_mpi mod p in-place, to use after mbedtls_mpi_add_mpi and mbedtls_mpi_mul_int. + * We known P, N and the result are positive, so sub_abs is correct, and + * a bit faster. + */ +#define MOD_ADD( N ) \ + while( mbedtls_mpi_cmp_mpi( &N, &grp->P ) >= 0 ) \ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &N, &N, &grp->P ) ) + +#if defined(ECP_SHORTWEIERSTRASS) +/* + * For curves in short Weierstrass form, we do all the internal operations in + * Jacobian coordinates. + * + * For multiplication, we'll use a comb method with coutermeasueres against + * SPA, hence timing attacks. + */ + +/* + * Normalize jacobian coordinates so that Z == 0 || Z == 1 (GECC 3.2.1) + * Cost: 1N := 1I + 3M + 1S + */ +static int ecp_normalize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt ) +{ + int ret; + mbedtls_mpi Zi, ZZi; + + if( mbedtls_mpi_cmp_int( &pt->Z, 0 ) == 0 ) + return( 0 ); + + mbedtls_mpi_init( &Zi ); mbedtls_mpi_init( &ZZi ); + + /* + * X = X / Z^2 mod p + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &Zi, &pt->Z, &grp->P ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ZZi, &Zi, &Zi ) ); MOD_MUL( ZZi ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->X, &pt->X, &ZZi ) ); MOD_MUL( pt->X ); + + /* + * Y = Y / Z^3 mod p + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->Y, &pt->Y, &ZZi ) ); MOD_MUL( pt->Y ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->Y, &pt->Y, &Zi ) ); MOD_MUL( pt->Y ); + + /* + * Z = 1 + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->Z, 1 ) ); + +cleanup: + + mbedtls_mpi_free( &Zi ); mbedtls_mpi_free( &ZZi ); + + return( ret ); +} + +/* + * Normalize jacobian coordinates of an array of (pointers to) points, + * using Montgomery's trick to perform only one inversion mod P. + * (See for example Cohen's "A Course in Computational Algebraic Number + * Theory", Algorithm 10.3.4.) + * + * Warning: fails (returning an error) if one of the points is zero! + * This should never happen, see choice of w in ecp_mul_comb(). + * + * Cost: 1N(t) := 1I + (6t - 3)M + 1S + */ +static int ecp_normalize_jac_many( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *T[], size_t t_len ) +{ + int ret; + size_t i; + mbedtls_mpi *c, u, Zi, ZZi; + + if( t_len < 2 ) + return( ecp_normalize_jac( grp, *T ) ); + + if( ( c = mbedtls_calloc( t_len, sizeof( mbedtls_mpi ) ) ) == NULL ) + return( MBEDTLS_ERR_ECP_ALLOC_FAILED ); + + mbedtls_mpi_init( &u ); mbedtls_mpi_init( &Zi ); mbedtls_mpi_init( &ZZi ); + + /* + * c[i] = Z_0 * ... * Z_i + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &c[0], &T[0]->Z ) ); + for( i = 1; i < t_len; i++ ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &c[i], &c[i-1], &T[i]->Z ) ); + MOD_MUL( c[i] ); + } + + /* + * u = 1 / (Z_0 * ... * Z_n) mod P + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &u, &c[t_len-1], &grp->P ) ); + + for( i = t_len - 1; ; i-- ) + { + /* + * Zi = 1 / Z_i mod p + * u = 1 / (Z_0 * ... * Z_i) mod P + */ + if( i == 0 ) { + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Zi, &u ) ); + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &Zi, &u, &c[i-1] ) ); MOD_MUL( Zi ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &u, &u, &T[i]->Z ) ); MOD_MUL( u ); + } + + /* + * proceed as in normalize() + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ZZi, &Zi, &Zi ) ); MOD_MUL( ZZi ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T[i]->X, &T[i]->X, &ZZi ) ); MOD_MUL( T[i]->X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T[i]->Y, &T[i]->Y, &ZZi ) ); MOD_MUL( T[i]->Y ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T[i]->Y, &T[i]->Y, &Zi ) ); MOD_MUL( T[i]->Y ); + + /* + * Post-precessing: reclaim some memory by shrinking coordinates + * - not storing Z (always 1) + * - shrinking other coordinates, but still keeping the same number of + * limbs as P, as otherwise it will too likely be regrown too fast. + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_shrink( &T[i]->X, grp->P.n ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shrink( &T[i]->Y, grp->P.n ) ); + mbedtls_mpi_free( &T[i]->Z ); + + if( i == 0 ) + break; + } + +cleanup: + + mbedtls_mpi_free( &u ); mbedtls_mpi_free( &Zi ); mbedtls_mpi_free( &ZZi ); + for( i = 0; i < t_len; i++ ) + mbedtls_mpi_free( &c[i] ); + mbedtls_free( c ); + + return( ret ); +} + +/* + * Conditional point inversion: Q -> -Q = (Q.X, -Q.Y, Q.Z) without leak. + * "inv" must be 0 (don't invert) or 1 (invert) or the result will be invalid + */ +static int ecp_safe_invert_jac( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *Q, + unsigned char inv ) +{ + int ret; + unsigned char nonzero; + mbedtls_mpi mQY; + + mbedtls_mpi_init( &mQY ); + + /* Use the fact that -Q.Y mod P = P - Q.Y unless Q.Y == 0 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &mQY, &grp->P, &Q->Y ) ); + nonzero = mbedtls_mpi_cmp_int( &Q->Y, 0 ) != 0; + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &Q->Y, &mQY, inv & nonzero ) ); + +cleanup: + mbedtls_mpi_free( &mQY ); + + return( ret ); +} + +/* + * Point doubling R = 2 P, Jacobian coordinates + * + * Based on http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html#doubling-dbl-1998-cmo-2 . + * + * We follow the variable naming fairly closely. The formula variations that trade a MUL for a SQR + * (plus a few ADDs) aren't useful as our bignum implementation doesn't distinguish squaring. + * + * Standard optimizations are applied when curve parameter A is one of { 0, -3 }. + * + * Cost: 1D := 3M + 4S (A == 0) + * 4M + 4S (A == -3) + * 3M + 6S + 1a otherwise + */ +static int ecp_double_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_ecp_point *P ) +{ + int ret; + mbedtls_mpi M, S, T, U; + +#if defined(MBEDTLS_SELF_TEST) + dbl_count++; +#endif + + mbedtls_mpi_init( &M ); mbedtls_mpi_init( &S ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &U ); + + /* Special case for A = -3 */ + if( grp->A.p == NULL ) + { + /* M = 3(X + Z^2)(X - Z^2) */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &P->Z, &P->Z ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &T, &P->X, &S ) ); MOD_ADD( T ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U, &P->X, &S ) ); MOD_SUB( U ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &T, &U ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &M, &S, 3 ) ); MOD_ADD( M ); + } + else + { + /* M = 3.X^2 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &P->X, &P->X ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &M, &S, 3 ) ); MOD_ADD( M ); + + /* Optimize away for "koblitz" curves with A = 0 */ + if( mbedtls_mpi_cmp_int( &grp->A, 0 ) != 0 ) + { + /* M += A.Z^4 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &P->Z, &P->Z ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &S, &S ) ); MOD_MUL( T ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &T, &grp->A ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &M, &M, &S ) ); MOD_ADD( M ); + } + } + + /* S = 4.X.Y^2 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &P->Y, &P->Y ) ); MOD_MUL( T ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T, 1 ) ); MOD_ADD( T ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &P->X, &T ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &S, 1 ) ); MOD_ADD( S ); + + /* U = 8.Y^4 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &U, &T, &T ) ); MOD_MUL( U ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &U, 1 ) ); MOD_ADD( U ); + + /* T = M^2 - 2.S */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &M, &M ) ); MOD_MUL( T ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T, &T, &S ) ); MOD_SUB( T ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T, &T, &S ) ); MOD_SUB( T ); + + /* S = M(S - T) - U */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &S, &S, &T ) ); MOD_SUB( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S, &S, &M ) ); MOD_MUL( S ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &S, &S, &U ) ); MOD_SUB( S ); + + /* U = 2.Y.Z */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &U, &P->Y, &P->Z ) ); MOD_MUL( U ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &U, 1 ) ); MOD_ADD( U ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R->X, &T ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R->Y, &S ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R->Z, &U ) ); + +cleanup: + mbedtls_mpi_free( &M ); mbedtls_mpi_free( &S ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &U ); + + return( ret ); +} + +/* + * Addition: R = P + Q, mixed affine-Jacobian coordinates (GECC 3.22) + * + * The coordinates of Q must be normalized (= affine), + * but those of P don't need to. R is not normalized. + * + * Special cases: (1) P or Q is zero, (2) R is zero, (3) P == Q. + * None of these cases can happen as intermediate step in ecp_mul_comb(): + * - at each step, P, Q and R are multiples of the base point, the factor + * being less than its order, so none of them is zero; + * - Q is an odd multiple of the base point, P an even multiple, + * due to the choice of precomputed points in the modified comb method. + * So branches for these cases do not leak secret information. + * + * We accept Q->Z being unset (saving memory in tables) as meaning 1. + * + * Cost: 1A := 8M + 3S + */ +static int ecp_add_mixed( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ) +{ + int ret; + mbedtls_mpi T1, T2, T3, T4, X, Y, Z; + +#if defined(MBEDTLS_SELF_TEST) + add_count++; +#endif + + /* + * Trivial cases: P == 0 or Q == 0 (case 1) + */ + if( mbedtls_mpi_cmp_int( &P->Z, 0 ) == 0 ) + return( mbedtls_ecp_copy( R, Q ) ); + + if( Q->Z.p != NULL && mbedtls_mpi_cmp_int( &Q->Z, 0 ) == 0 ) + return( mbedtls_ecp_copy( R, P ) ); + + /* + * Make sure Q coordinates are normalized + */ + if( Q->Z.p != NULL && mbedtls_mpi_cmp_int( &Q->Z, 1 ) != 0 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 ); mbedtls_mpi_init( &T3 ); mbedtls_mpi_init( &T4 ); + mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &P->Z, &P->Z ) ); MOD_MUL( T1 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T2, &T1, &P->Z ) ); MOD_MUL( T2 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T1, &Q->X ) ); MOD_MUL( T1 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T2, &T2, &Q->Y ) ); MOD_MUL( T2 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T1, &T1, &P->X ) ); MOD_SUB( T1 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T2, &T2, &P->Y ) ); MOD_SUB( T2 ); + + /* Special cases (2) and (3) */ + if( mbedtls_mpi_cmp_int( &T1, 0 ) == 0 ) + { + if( mbedtls_mpi_cmp_int( &T2, 0 ) == 0 ) + { + ret = ecp_double_jac( grp, R, P ); + goto cleanup; + } + else + { + ret = mbedtls_ecp_set_zero( R ); + goto cleanup; + } + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &Z, &P->Z, &T1 ) ); MOD_MUL( Z ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T3, &T1, &T1 ) ); MOD_MUL( T3 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T4, &T3, &T1 ) ); MOD_MUL( T4 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T3, &T3, &P->X ) ); MOD_MUL( T3 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &T3, 2 ) ); MOD_ADD( T1 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &X, &T2, &T2 ) ); MOD_MUL( X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &X, &X, &T1 ) ); MOD_SUB( X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &X, &X, &T4 ) ); MOD_SUB( X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T3, &T3, &X ) ); MOD_SUB( T3 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T3, &T3, &T2 ) ); MOD_MUL( T3 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T4, &T4, &P->Y ) ); MOD_MUL( T4 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &Y, &T3, &T4 ) ); MOD_SUB( Y ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R->X, &X ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R->Y, &Y ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R->Z, &Z ) ); + +cleanup: + + mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 ); mbedtls_mpi_free( &T3 ); mbedtls_mpi_free( &T4 ); + mbedtls_mpi_free( &X ); mbedtls_mpi_free( &Y ); mbedtls_mpi_free( &Z ); + + return( ret ); +} + +/* + * Randomize jacobian coordinates: + * (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l + * This is sort of the reverse operation of ecp_normalize_jac(). + * + * This countermeasure was first suggested in [2]. + */ +static int ecp_randomize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret; + mbedtls_mpi l, ll; + size_t p_size = ( grp->pbits + 7 ) / 8; + int count = 0; + + mbedtls_mpi_init( &l ); mbedtls_mpi_init( &ll ); + + /* Generate l such that 1 < l < p */ + do + { + mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ); + + while( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) ); + + if( count++ > 10 ) + return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); + } + while( mbedtls_mpi_cmp_int( &l, 1 ) <= 0 ); + + /* Z = l * Z */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->Z, &pt->Z, &l ) ); MOD_MUL( pt->Z ); + + /* X = l^2 * X */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ll, &l, &l ) ); MOD_MUL( ll ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->X, &pt->X, &ll ) ); MOD_MUL( pt->X ); + + /* Y = l^3 * Y */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ll, &ll, &l ) ); MOD_MUL( ll ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->Y, &pt->Y, &ll ) ); MOD_MUL( pt->Y ); + +cleanup: + mbedtls_mpi_free( &l ); mbedtls_mpi_free( &ll ); + + return( ret ); +} + +/* + * Check and define parameters used by the comb method (see below for details) + */ +#if MBEDTLS_ECP_WINDOW_SIZE < 2 || MBEDTLS_ECP_WINDOW_SIZE > 7 +#error "MBEDTLS_ECP_WINDOW_SIZE out of bounds" +#endif + +/* d = ceil( n / w ) */ +#define COMB_MAX_D ( MBEDTLS_ECP_MAX_BITS + 1 ) / 2 + +/* number of precomputed points */ +#define COMB_MAX_PRE ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) ) + +/* + * Compute the representation of m that will be used with our comb method. + * + * The basic comb method is described in GECC 3.44 for example. We use a + * modified version that provides resistance to SPA by avoiding zero + * digits in the representation as in [3]. We modify the method further by + * requiring that all K_i be odd, which has the small cost that our + * representation uses one more K_i, due to carries. + * + * Also, for the sake of compactness, only the seven low-order bits of x[i] + * are used to represent K_i, and the msb of x[i] encodes the the sign (s_i in + * the paper): it is set if and only if if s_i == -1; + * + * Calling conventions: + * - x is an array of size d + 1 + * - w is the size, ie number of teeth, of the comb, and must be between + * 2 and 7 (in practice, between 2 and MBEDTLS_ECP_WINDOW_SIZE) + * - m is the MPI, expected to be odd and such that bitlength(m) <= w * d + * (the result will be incorrect if these assumptions are not satisfied) + */ +static void ecp_comb_fixed( unsigned char x[], size_t d, + unsigned char w, const mbedtls_mpi *m ) +{ + size_t i, j; + unsigned char c, cc, adjust; + + memset( x, 0, d+1 ); + + /* First get the classical comb values (except for x_d = 0) */ + for( i = 0; i < d; i++ ) + for( j = 0; j < w; j++ ) + x[i] |= mbedtls_mpi_get_bit( m, i + d * j ) << j; + + /* Now make sure x_1 .. x_d are odd */ + c = 0; + for( i = 1; i <= d; i++ ) + { + /* Add carry and update it */ + cc = x[i] & c; + x[i] = x[i] ^ c; + c = cc; + + /* Adjust if needed, avoiding branches */ + adjust = 1 - ( x[i] & 0x01 ); + c |= x[i] & ( x[i-1] * adjust ); + x[i] = x[i] ^ ( x[i-1] * adjust ); + x[i-1] |= adjust << 7; + } +} + +/* + * Precompute points for the comb method + * + * If i = i_{w-1} ... i_1 is the binary representation of i, then + * T[i] = i_{w-1} 2^{(w-1)d} P + ... + i_1 2^d P + P + * + * T must be able to hold 2^{w - 1} elements + * + * Cost: d(w-1) D + (2^{w-1} - 1) A + 1 N(w-1) + 1 N(2^{w-1} - 1) + */ +static int ecp_precompute_comb( const mbedtls_ecp_group *grp, + mbedtls_ecp_point T[], const mbedtls_ecp_point *P, + unsigned char w, size_t d ) +{ + int ret; + unsigned char i, k; + size_t j; + mbedtls_ecp_point *cur, *TT[COMB_MAX_PRE - 1]; + + /* + * Set T[0] = P and + * T[2^{l-1}] = 2^{dl} P for l = 1 .. w-1 (this is not the final value) + */ + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &T[0], P ) ); + + k = 0; + for( i = 1; i < ( 1U << ( w - 1 ) ); i <<= 1 ) + { + cur = T + i; + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( cur, T + ( i >> 1 ) ) ); + for( j = 0; j < d; j++ ) + MBEDTLS_MPI_CHK( ecp_double_jac( grp, cur, cur ) ); + + TT[k++] = cur; + } + + MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, k ) ); + + /* + * Compute the remaining ones using the minimal number of additions + * Be careful to update T[2^l] only after using it! + */ + k = 0; + for( i = 1; i < ( 1U << ( w - 1 ) ); i <<= 1 ) + { + j = i; + while( j-- ) + { + MBEDTLS_MPI_CHK( ecp_add_mixed( grp, &T[i + j], &T[j], &T[i] ) ); + TT[k++] = &T[i + j]; + } + } + + MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, k ) ); + +cleanup: + return( ret ); +} + +/* + * Select precomputed point: R = sign(i) * T[ abs(i) / 2 ] + */ +static int ecp_select_comb( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_ecp_point T[], unsigned char t_len, + unsigned char i ) +{ + int ret; + unsigned char ii, j; + + /* Ignore the "sign" bit and scale down */ + ii = ( i & 0x7Fu ) >> 1; + + /* Read the whole table to thwart cache-based timing attacks */ + for( j = 0; j < t_len; j++ ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &R->X, &T[j].X, j == ii ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &R->Y, &T[j].Y, j == ii ) ); + } + + /* Safely invert result if i is "negative" */ + MBEDTLS_MPI_CHK( ecp_safe_invert_jac( grp, R, i >> 7 ) ); + +cleanup: + return( ret ); +} + +/* + * Core multiplication algorithm for the (modified) comb method. + * This part is actually common with the basic comb method (GECC 3.44) + * + * Cost: d A + d D + 1 R + */ +static int ecp_mul_comb_core( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_ecp_point T[], unsigned char t_len, + const unsigned char x[], size_t d, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + mbedtls_ecp_point Txi; + size_t i; + + mbedtls_ecp_point_init( &Txi ); + + /* Start with a non-zero point and randomize its coordinates */ + i = d; + MBEDTLS_MPI_CHK( ecp_select_comb( grp, R, T, t_len, x[i] ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->Z, 1 ) ); + if( f_rng != 0 ) + MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, R, f_rng, p_rng ) ); + + while( i-- != 0 ) + { + MBEDTLS_MPI_CHK( ecp_double_jac( grp, R, R ) ); + MBEDTLS_MPI_CHK( ecp_select_comb( grp, &Txi, T, t_len, x[i] ) ); + MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, R, &Txi ) ); + } + +cleanup: + mbedtls_ecp_point_free( &Txi ); + + return( ret ); +} + +/* + * Multiplication using the comb method, + * for curves in short Weierstrass form + */ +static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + unsigned char w, m_is_odd, p_eq_g, pre_len, i; + size_t d; + unsigned char k[COMB_MAX_D + 1]; + mbedtls_ecp_point *T; + mbedtls_mpi M, mm; + + mbedtls_mpi_init( &M ); + mbedtls_mpi_init( &mm ); + + /* we need N to be odd to trnaform m in an odd number, check now */ + if( mbedtls_mpi_get_bit( &grp->N, 0 ) != 1 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Minimize the number of multiplications, that is minimize + * 10 * d * w + 18 * 2^(w-1) + 11 * d + 7 * w, with d = ceil( nbits / w ) + * (see costs of the various parts, with 1S = 1M) + */ + w = grp->nbits >= 384 ? 5 : 4; + + /* + * If P == G, pre-compute a bit more, since this may be re-used later. + * Just adding one avoids upping the cost of the first mul too much, + * and the memory cost too. + */ +#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 + p_eq_g = ( mbedtls_mpi_cmp_mpi( &P->Y, &grp->G.Y ) == 0 && + mbedtls_mpi_cmp_mpi( &P->X, &grp->G.X ) == 0 ); + if( p_eq_g ) + w++; +#else + p_eq_g = 0; +#endif + + /* + * Make sure w is within bounds. + * (The last test is useful only for very small curves in the test suite.) + */ + if( w > MBEDTLS_ECP_WINDOW_SIZE ) + w = MBEDTLS_ECP_WINDOW_SIZE; + if( w >= grp->nbits ) + w = 2; + + /* Other sizes that depend on w */ + pre_len = 1U << ( w - 1 ); + d = ( grp->nbits + w - 1 ) / w; + + /* + * Prepare precomputed points: if P == G we want to + * use grp->T if already initialized, or initialize it. + */ + T = p_eq_g ? grp->T : NULL; + + if( T == NULL ) + { + T = mbedtls_calloc( pre_len, sizeof( mbedtls_ecp_point ) ); + if( T == NULL ) + { + ret = MBEDTLS_ERR_ECP_ALLOC_FAILED; + goto cleanup; + } + + MBEDTLS_MPI_CHK( ecp_precompute_comb( grp, T, P, w, d ) ); + + if( p_eq_g ) + { + grp->T = T; + grp->T_size = pre_len; + } + } + + /* + * Make sure M is odd (M = m or M = N - m, since N is odd) + * using the fact that m * P = - (N - m) * P + */ + m_is_odd = ( mbedtls_mpi_get_bit( m, 0 ) == 1 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &M, m ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &mm, &grp->N, m ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &M, &mm, ! m_is_odd ) ); + + /* + * Go for comb multiplication, R = M * P + */ + ecp_comb_fixed( k, d, w, &M ); + MBEDTLS_MPI_CHK( ecp_mul_comb_core( grp, R, T, pre_len, k, d, f_rng, p_rng ) ); + + /* + * Now get m * P from M * P and normalize it + */ + MBEDTLS_MPI_CHK( ecp_safe_invert_jac( grp, R, ! m_is_odd ) ); + MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) ); + +cleanup: + + if( T != NULL && ! p_eq_g ) + { + for( i = 0; i < pre_len; i++ ) + mbedtls_ecp_point_free( &T[i] ); + mbedtls_free( T ); + } + + mbedtls_mpi_free( &M ); + mbedtls_mpi_free( &mm ); + + if( ret != 0 ) + mbedtls_ecp_point_free( R ); + + return( ret ); +} + +#endif /* ECP_SHORTWEIERSTRASS */ + +#if defined(ECP_MONTGOMERY) +/* + * For Montgomery curves, we do all the internal arithmetic in projective + * coordinates. Import/export of points uses only the x coordinates, which is + * internaly represented as X / Z. + * + * For scalar multiplication, we'll use a Montgomery ladder. + */ + +/* + * Normalize Montgomery x/z coordinates: X = X/Z, Z = 1 + * Cost: 1M + 1I + */ +static int ecp_normalize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P ) +{ + int ret; + + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &P->Z, &P->Z, &grp->P ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &P->X, &P->X, &P->Z ) ); MOD_MUL( P->X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &P->Z, 1 ) ); + +cleanup: + return( ret ); +} + +/* + * Randomize projective x/z coordinates: + * (X, Z) -> (l X, l Z) for random l + * This is sort of the reverse operation of ecp_normalize_mxz(). + * + * This countermeasure was first suggested in [2]. + * Cost: 2M + */ +static int ecp_randomize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret; + mbedtls_mpi l; + size_t p_size = ( grp->pbits + 7 ) / 8; + int count = 0; + + mbedtls_mpi_init( &l ); + + /* Generate l such that 1 < l < p */ + do + { + mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ); + + while( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) ); + + if( count++ > 10 ) + return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); + } + while( mbedtls_mpi_cmp_int( &l, 1 ) <= 0 ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &P->X, &P->X, &l ) ); MOD_MUL( P->X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &P->Z, &P->Z, &l ) ); MOD_MUL( P->Z ); + +cleanup: + mbedtls_mpi_free( &l ); + + return( ret ); +} + +/* + * Double-and-add: R = 2P, S = P + Q, with d = X(P - Q), + * for Montgomery curves in x/z coordinates. + * + * http://www.hyperelliptic.org/EFD/g1p/auto-code/montgom/xz/ladder/mladd-1987-m.op3 + * with + * d = X1 + * P = (X2, Z2) + * Q = (X3, Z3) + * R = (X4, Z4) + * S = (X5, Z5) + * and eliminating temporary variables tO, ..., t4. + * + * Cost: 5M + 4S + */ +static int ecp_double_add_mxz( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *R, mbedtls_ecp_point *S, + const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, + const mbedtls_mpi *d ) +{ + int ret; + mbedtls_mpi A, AA, B, BB, E, C, D, DA, CB; + + mbedtls_mpi_init( &A ); mbedtls_mpi_init( &AA ); mbedtls_mpi_init( &B ); + mbedtls_mpi_init( &BB ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &C ); + mbedtls_mpi_init( &D ); mbedtls_mpi_init( &DA ); mbedtls_mpi_init( &CB ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &A, &P->X, &P->Z ) ); MOD_ADD( A ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &AA, &A, &A ) ); MOD_MUL( AA ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &B, &P->X, &P->Z ) ); MOD_SUB( B ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &BB, &B, &B ) ); MOD_MUL( BB ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &E, &AA, &BB ) ); MOD_SUB( E ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &C, &Q->X, &Q->Z ) ); MOD_ADD( C ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &D, &Q->X, &Q->Z ) ); MOD_SUB( D ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DA, &D, &A ) ); MOD_MUL( DA ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &CB, &C, &B ) ); MOD_MUL( CB ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &S->X, &DA, &CB ) ); MOD_MUL( S->X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S->X, &S->X, &S->X ) ); MOD_MUL( S->X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &S->Z, &DA, &CB ) ); MOD_SUB( S->Z ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S->Z, &S->Z, &S->Z ) ); MOD_MUL( S->Z ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &S->Z, d, &S->Z ) ); MOD_MUL( S->Z ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &R->X, &AA, &BB ) ); MOD_MUL( R->X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &R->Z, &grp->A, &E ) ); MOD_MUL( R->Z ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &R->Z, &BB, &R->Z ) ); MOD_ADD( R->Z ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &R->Z, &E, &R->Z ) ); MOD_MUL( R->Z ); + +cleanup: + mbedtls_mpi_free( &A ); mbedtls_mpi_free( &AA ); mbedtls_mpi_free( &B ); + mbedtls_mpi_free( &BB ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &C ); + mbedtls_mpi_free( &D ); mbedtls_mpi_free( &DA ); mbedtls_mpi_free( &CB ); + + return( ret ); +} + +/* + * Multiplication with Montgomery ladder in x/z coordinates, + * for curves in Montgomery form + */ +static int ecp_mul_mxz( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + size_t i; + unsigned char b; + mbedtls_ecp_point RP; + mbedtls_mpi PX; + + mbedtls_ecp_point_init( &RP ); mbedtls_mpi_init( &PX ); + + /* Save PX and read from P before writing to R, in case P == R */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &PX, &P->X ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &RP, P ) ); + + /* Set R to zero in modified x/z coordinates */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->X, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->Z, 0 ) ); + mbedtls_mpi_free( &R->Y ); + + /* RP.X might be sligtly larger than P, so reduce it */ + MOD_ADD( RP.X ); + + /* Randomize coordinates of the starting point */ + if( f_rng != NULL ) + MBEDTLS_MPI_CHK( ecp_randomize_mxz( grp, &RP, f_rng, p_rng ) ); + + /* Loop invariant: R = result so far, RP = R + P */ + i = mbedtls_mpi_bitlen( m ); /* one past the (zero-based) most significant bit */ + while( i-- > 0 ) + { + b = mbedtls_mpi_get_bit( m, i ); + /* + * if (b) R = 2R + P else R = 2R, + * which is: + * if (b) double_add( RP, R, RP, R ) + * else double_add( R, RP, R, RP ) + * but using safe conditional swaps to avoid leaks + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_swap( &R->X, &RP.X, b ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_swap( &R->Z, &RP.Z, b ) ); + MBEDTLS_MPI_CHK( ecp_double_add_mxz( grp, R, &RP, R, &RP, &PX ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_swap( &R->X, &RP.X, b ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_swap( &R->Z, &RP.Z, b ) ); + } + + MBEDTLS_MPI_CHK( ecp_normalize_mxz( grp, R ) ); + +cleanup: + mbedtls_ecp_point_free( &RP ); mbedtls_mpi_free( &PX ); + + return( ret ); +} + +#endif /* ECP_MONTGOMERY */ + +/* + * Multiplication R = m * P + */ +int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret; + + /* Common sanity checks */ + if( mbedtls_mpi_cmp_int( &P->Z, 1 ) != 0 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_ecp_check_privkey( grp, m ) ) != 0 || + ( ret = mbedtls_ecp_check_pubkey( grp, P ) ) != 0 ) + return( ret ); + +#if defined(ECP_MONTGOMERY) + if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) + return( ecp_mul_mxz( grp, R, m, P, f_rng, p_rng ) ); +#endif +#if defined(ECP_SHORTWEIERSTRASS) + if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS ) + return( ecp_mul_comb( grp, R, m, P, f_rng, p_rng ) ); +#endif + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); +} + +#if defined(ECP_SHORTWEIERSTRASS) +/* + * Check that an affine point is valid as a public key, + * short weierstrass curves (SEC1 3.2.3.1) + */ +static int ecp_check_pubkey_sw( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ) +{ + int ret; + mbedtls_mpi YY, RHS; + + /* pt coordinates must be normalized for our checks */ + if( mbedtls_mpi_cmp_int( &pt->X, 0 ) < 0 || + mbedtls_mpi_cmp_int( &pt->Y, 0 ) < 0 || + mbedtls_mpi_cmp_mpi( &pt->X, &grp->P ) >= 0 || + mbedtls_mpi_cmp_mpi( &pt->Y, &grp->P ) >= 0 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + + mbedtls_mpi_init( &YY ); mbedtls_mpi_init( &RHS ); + + /* + * YY = Y^2 + * RHS = X (X^2 + A) + B = X^3 + A X + B + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &YY, &pt->Y, &pt->Y ) ); MOD_MUL( YY ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &RHS, &pt->X, &pt->X ) ); MOD_MUL( RHS ); + + /* Special case for A = -3 */ + if( grp->A.p == NULL ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &RHS, &RHS, 3 ) ); MOD_SUB( RHS ); + } + else + { + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &RHS, &RHS, &grp->A ) ); MOD_ADD( RHS ); + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &RHS, &RHS, &pt->X ) ); MOD_MUL( RHS ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &RHS, &RHS, &grp->B ) ); MOD_ADD( RHS ); + + if( mbedtls_mpi_cmp_mpi( &YY, &RHS ) != 0 ) + ret = MBEDTLS_ERR_ECP_INVALID_KEY; + +cleanup: + + mbedtls_mpi_free( &YY ); mbedtls_mpi_free( &RHS ); + + return( ret ); +} +#endif /* ECP_SHORTWEIERSTRASS */ + +/* + * R = m * P with shortcuts for m == 1 and m == -1 + * NOT constant-time - ONLY for short Weierstrass! + */ +static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp, + mbedtls_ecp_point *R, + const mbedtls_mpi *m, + const mbedtls_ecp_point *P ) +{ + int ret; + + if( mbedtls_mpi_cmp_int( m, 1 ) == 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) ); + } + else if( mbedtls_mpi_cmp_int( m, -1 ) == 0 ) + { + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) ); + if( mbedtls_mpi_cmp_int( &R->Y, 0 ) != 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &R->Y, &grp->P, &R->Y ) ); + } + else + { + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, R, m, P, NULL, NULL ) ); + } + +cleanup: + return( ret ); +} + +/* + * Linear combination + * NOT constant-time + */ +int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + const mbedtls_mpi *n, const mbedtls_ecp_point *Q ) +{ + int ret; + mbedtls_ecp_point mP; + + if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS ) + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); + + mbedtls_ecp_point_init( &mP ); + + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, &mP, m, P ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, R, n, Q ) ); + + MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, &mP, R ) ); + MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) ); + +cleanup: + mbedtls_ecp_point_free( &mP ); + + return( ret ); +} + + +#if defined(ECP_MONTGOMERY) +/* + * Check validity of a public key for Montgomery curves with x-only schemes + */ +static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ) +{ + /* [Curve25519 p. 5] Just check X is the correct number of bytes */ + if( mbedtls_mpi_size( &pt->X ) > ( grp->nbits + 7 ) / 8 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + + return( 0 ); +} +#endif /* ECP_MONTGOMERY */ + +/* + * Check that a point is valid as a public key + */ +int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ) +{ + /* Must use affine coordinates */ + if( mbedtls_mpi_cmp_int( &pt->Z, 1 ) != 0 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + +#if defined(ECP_MONTGOMERY) + if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) + return( ecp_check_pubkey_mx( grp, pt ) ); +#endif +#if defined(ECP_SHORTWEIERSTRASS) + if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS ) + return( ecp_check_pubkey_sw( grp, pt ) ); +#endif + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); +} + +/* + * Check that an mbedtls_mpi is valid as a private key + */ +int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d ) +{ +#if defined(ECP_MONTGOMERY) + if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) + { + /* see [Curve25519] page 5 */ + if( mbedtls_mpi_get_bit( d, 0 ) != 0 || + mbedtls_mpi_get_bit( d, 1 ) != 0 || + mbedtls_mpi_get_bit( d, 2 ) != 0 || + mbedtls_mpi_bitlen( d ) - 1 != grp->nbits ) /* mbedtls_mpi_bitlen is one-based! */ + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + else + return( 0 ); + } +#endif /* ECP_MONTGOMERY */ +#if defined(ECP_SHORTWEIERSTRASS) + if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS ) + { + /* see SEC1 3.2 */ + if( mbedtls_mpi_cmp_int( d, 1 ) < 0 || + mbedtls_mpi_cmp_mpi( d, &grp->N ) >= 0 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + else + return( 0 ); + } +#endif /* ECP_SHORTWEIERSTRASS */ + + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); +} + +/* + * Generate a keypair with configurable base point + */ +int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, + const mbedtls_ecp_point *G, + mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + size_t n_size = ( grp->nbits + 7 ) / 8; + +#if defined(ECP_MONTGOMERY) + if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) + { + /* [M225] page 5 */ + size_t b; + + do { + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( d, n_size, f_rng, p_rng ) ); + } while( mbedtls_mpi_bitlen( d ) == 0); + + /* Make sure the most significant bit is nbits */ + b = mbedtls_mpi_bitlen( d ) - 1; /* mbedtls_mpi_bitlen is one-based */ + if( b > grp->nbits ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( d, b - grp->nbits ) ); + else + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, grp->nbits, 1 ) ); + + /* Make sure the last three bits are unset */ + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 0, 0 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 1, 0 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 2, 0 ) ); + } + else +#endif /* ECP_MONTGOMERY */ +#if defined(ECP_SHORTWEIERSTRASS) + if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS ) + { + /* SEC1 3.2.1: Generate d such that 1 <= n < N */ + int count = 0; + unsigned char rnd[MBEDTLS_ECP_MAX_BYTES]; + + /* + * Match the procedure given in RFC 6979 (deterministic ECDSA): + * - use the same byte ordering; + * - keep the leftmost nbits bits of the generated octet string; + * - try until result is in the desired range. + * This also avoids any biais, which is especially important for ECDSA. + */ + do + { + MBEDTLS_MPI_CHK( f_rng( p_rng, rnd, n_size ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( d, rnd, n_size ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( d, 8 * n_size - grp->nbits ) ); + + /* + * Each try has at worst a probability 1/2 of failing (the msb has + * a probability 1/2 of being 0, and then the result will be < N), + * so after 30 tries failure probability is a most 2**(-30). + * + * For most curves, 1 try is enough with overwhelming probability, + * since N starts with a lot of 1s in binary, but some curves + * such as secp224k1 are actually very close to the worst case. + */ + if( ++count > 30 ) + return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); + } + while( mbedtls_mpi_cmp_int( d, 1 ) < 0 || + mbedtls_mpi_cmp_mpi( d, &grp->N ) >= 0 ); + } + else +#endif /* ECP_SHORTWEIERSTRASS */ + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + +cleanup: + if( ret != 0 ) + return( ret ); + + return( mbedtls_ecp_mul( grp, Q, d, G, f_rng, p_rng ) ); +} + +/* + * Generate key pair, wrapper for conventional base point + */ +int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, + mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + return( mbedtls_ecp_gen_keypair_base( grp, &grp->G, d, Q, f_rng, p_rng ) ); +} + +/* + * Generate a keypair, prettier wrapper + */ +int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret; + + if( ( ret = mbedtls_ecp_group_load( &key->grp, grp_id ) ) != 0 ) + return( ret ); + + return( mbedtls_ecp_gen_keypair( &key->grp, &key->d, &key->Q, f_rng, p_rng ) ); +} + +/* + * Check a public-private key pair + */ +int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv ) +{ + int ret; + mbedtls_ecp_point Q; + mbedtls_ecp_group grp; + + if( pub->grp.id == MBEDTLS_ECP_DP_NONE || + pub->grp.id != prv->grp.id || + mbedtls_mpi_cmp_mpi( &pub->Q.X, &prv->Q.X ) || + mbedtls_mpi_cmp_mpi( &pub->Q.Y, &prv->Q.Y ) || + mbedtls_mpi_cmp_mpi( &pub->Q.Z, &prv->Q.Z ) ) + { + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + } + + mbedtls_ecp_point_init( &Q ); + mbedtls_ecp_group_init( &grp ); + + /* mbedtls_ecp_mul() needs a non-const group... */ + mbedtls_ecp_group_copy( &grp, &prv->grp ); + + /* Also checks d is valid */ + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &grp, &Q, &prv->d, &prv->grp.G, NULL, NULL ) ); + + if( mbedtls_mpi_cmp_mpi( &Q.X, &prv->Q.X ) || + mbedtls_mpi_cmp_mpi( &Q.Y, &prv->Q.Y ) || + mbedtls_mpi_cmp_mpi( &Q.Z, &prv->Q.Z ) ) + { + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + +cleanup: + mbedtls_ecp_point_free( &Q ); + mbedtls_ecp_group_free( &grp ); + + return( ret ); +} + +#if defined(MBEDTLS_SELF_TEST) + +/* + * Checkup routine + */ +int mbedtls_ecp_self_test( int verbose ) +{ + int ret; + size_t i; + mbedtls_ecp_group grp; + mbedtls_ecp_point R, P; + mbedtls_mpi m; + unsigned long add_c_prev, dbl_c_prev, mul_c_prev; + /* exponents especially adapted for secp192r1 */ + const char *exponents[] = + { + "000000000000000000000000000000000000000000000001", /* one */ + "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22830", /* N - 1 */ + "5EA6F389A38B8BC81E767753B15AA5569E1782E30ABE7D25", /* random */ + "400000000000000000000000000000000000000000000000", /* one and zeros */ + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", /* all ones */ + "555555555555555555555555555555555555555555555555", /* 101010... */ + }; + + mbedtls_ecp_group_init( &grp ); + mbedtls_ecp_point_init( &R ); + mbedtls_ecp_point_init( &P ); + mbedtls_mpi_init( &m ); + + /* Use secp192r1 if available, or any available curve */ +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + MBEDTLS_MPI_CHK( mbedtls_ecp_group_load( &grp, MBEDTLS_ECP_DP_SECP192R1 ) ); +#else + MBEDTLS_MPI_CHK( mbedtls_ecp_group_load( &grp, mbedtls_ecp_curve_list()->grp_id ) ); +#endif + + if( verbose != 0 ) + mbedtls_printf( " ECP test #1 (constant op_count, base point G): " ); + + /* Do a dummy multiplication first to trigger precomputation */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &m, 2 ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &grp, &P, &m, &grp.G, NULL, NULL ) ); + + add_count = 0; + dbl_count = 0; + mul_count = 0; + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &m, 16, exponents[0] ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &grp, &R, &m, &grp.G, NULL, NULL ) ); + + for( i = 1; i < sizeof( exponents ) / sizeof( exponents[0] ); i++ ) + { + add_c_prev = add_count; + dbl_c_prev = dbl_count; + mul_c_prev = mul_count; + add_count = 0; + dbl_count = 0; + mul_count = 0; + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &m, 16, exponents[i] ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &grp, &R, &m, &grp.G, NULL, NULL ) ); + + if( add_count != add_c_prev || + dbl_count != dbl_c_prev || + mul_count != mul_c_prev ) + { + if( verbose != 0 ) + mbedtls_printf( "failed (%u)\n", (unsigned int) i ); + + ret = 1; + goto cleanup; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " ECP test #2 (constant op_count, other point): " ); + /* We computed P = 2G last time, use it */ + + add_count = 0; + dbl_count = 0; + mul_count = 0; + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &m, 16, exponents[0] ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &grp, &R, &m, &P, NULL, NULL ) ); + + for( i = 1; i < sizeof( exponents ) / sizeof( exponents[0] ); i++ ) + { + add_c_prev = add_count; + dbl_c_prev = dbl_count; + mul_c_prev = mul_count; + add_count = 0; + dbl_count = 0; + mul_count = 0; + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &m, 16, exponents[i] ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( &grp, &R, &m, &P, NULL, NULL ) ); + + if( add_count != add_c_prev || + dbl_count != dbl_c_prev || + mul_count != mul_c_prev ) + { + if( verbose != 0 ) + mbedtls_printf( "failed (%u)\n", (unsigned int) i ); + + ret = 1; + goto cleanup; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + +cleanup: + + if( ret < 0 && verbose != 0 ) + mbedtls_printf( "Unexpected error, return code = %08X\n", ret ); + + mbedtls_ecp_group_free( &grp ); + mbedtls_ecp_point_free( &R ); + mbedtls_ecp_point_free( &P ); + mbedtls_mpi_free( &m ); + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_ECP_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp_curves.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp_curves.c new file mode 100644 index 0000000..a2a5495 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ecp_curves.c @@ -0,0 +1,1325 @@ +/* + * Elliptic curves over GF(p): curve-specific data and functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ECP_C) + +#include "mbedtls/ecp.h" + +#include + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +/* + * Conversion macros for embedded constants: + * build lists of mbedtls_mpi_uint's from lists of unsigned char's grouped by 8, 4 or 2 + */ +#if defined(MBEDTLS_HAVE_INT32) + +#define BYTES_TO_T_UINT_4( a, b, c, d ) \ + ( (mbedtls_mpi_uint) a << 0 ) | \ + ( (mbedtls_mpi_uint) b << 8 ) | \ + ( (mbedtls_mpi_uint) c << 16 ) | \ + ( (mbedtls_mpi_uint) d << 24 ) + +#define BYTES_TO_T_UINT_2( a, b ) \ + BYTES_TO_T_UINT_4( a, b, 0, 0 ) + +#define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ + BYTES_TO_T_UINT_4( a, b, c, d ), \ + BYTES_TO_T_UINT_4( e, f, g, h ) + +#else /* 64-bits */ + +#define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ + ( (mbedtls_mpi_uint) a << 0 ) | \ + ( (mbedtls_mpi_uint) b << 8 ) | \ + ( (mbedtls_mpi_uint) c << 16 ) | \ + ( (mbedtls_mpi_uint) d << 24 ) | \ + ( (mbedtls_mpi_uint) e << 32 ) | \ + ( (mbedtls_mpi_uint) f << 40 ) | \ + ( (mbedtls_mpi_uint) g << 48 ) | \ + ( (mbedtls_mpi_uint) h << 56 ) + +#define BYTES_TO_T_UINT_4( a, b, c, d ) \ + BYTES_TO_T_UINT_8( a, b, c, d, 0, 0, 0, 0 ) + +#define BYTES_TO_T_UINT_2( a, b ) \ + BYTES_TO_T_UINT_8( a, b, 0, 0, 0, 0, 0, 0 ) + +#endif /* bits in mbedtls_mpi_uint */ + +/* + * Note: the constants are in little-endian order + * to be directly usable in MPIs + */ + +/* + * Domain parameters for secp192r1 + */ +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) +static const mbedtls_mpi_uint secp192r1_p[] = { + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +static const mbedtls_mpi_uint secp192r1_b[] = { + BYTES_TO_T_UINT_8( 0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE ), + BYTES_TO_T_UINT_8( 0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F ), + BYTES_TO_T_UINT_8( 0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64 ), +}; +static const mbedtls_mpi_uint secp192r1_gx[] = { + BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ), + BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ), + BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ), +}; +static const mbedtls_mpi_uint secp192r1_gy[] = { + BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ), + BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ), + BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ), +}; +static const mbedtls_mpi_uint secp192r1_n[] = { + BYTES_TO_T_UINT_8( 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14 ), + BYTES_TO_T_UINT_8( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ + +/* + * Domain parameters for secp224r1 + */ +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) +static const mbedtls_mpi_uint secp224r1_p[] = { + BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), + BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), +}; +static const mbedtls_mpi_uint secp224r1_b[] = { + BYTES_TO_T_UINT_8( 0xB4, 0xFF, 0x55, 0x23, 0x43, 0x39, 0x0B, 0x27 ), + BYTES_TO_T_UINT_8( 0xBA, 0xD8, 0xBF, 0xD7, 0xB7, 0xB0, 0x44, 0x50 ), + BYTES_TO_T_UINT_8( 0x56, 0x32, 0x41, 0xF5, 0xAB, 0xB3, 0x04, 0x0C ), + BYTES_TO_T_UINT_4( 0x85, 0x0A, 0x05, 0xB4 ), +}; +static const mbedtls_mpi_uint secp224r1_gx[] = { + BYTES_TO_T_UINT_8( 0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34 ), + BYTES_TO_T_UINT_8( 0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A ), + BYTES_TO_T_UINT_8( 0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B ), + BYTES_TO_T_UINT_4( 0xBD, 0x0C, 0x0E, 0xB7 ), +}; +static const mbedtls_mpi_uint secp224r1_gy[] = { + BYTES_TO_T_UINT_8( 0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44 ), + BYTES_TO_T_UINT_8( 0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD ), + BYTES_TO_T_UINT_8( 0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5 ), + BYTES_TO_T_UINT_4( 0x88, 0x63, 0x37, 0xBD ), +}; +static const mbedtls_mpi_uint secp224r1_n[] = { + BYTES_TO_T_UINT_8( 0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13 ), + BYTES_TO_T_UINT_8( 0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), +}; +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ + +/* + * Domain parameters for secp256r1 + */ +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) +static const mbedtls_mpi_uint secp256r1_p[] = { + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), + BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), + BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +static const mbedtls_mpi_uint secp256r1_b[] = { + BYTES_TO_T_UINT_8( 0x4B, 0x60, 0xD2, 0x27, 0x3E, 0x3C, 0xCE, 0x3B ), + BYTES_TO_T_UINT_8( 0xF6, 0xB0, 0x53, 0xCC, 0xB0, 0x06, 0x1D, 0x65 ), + BYTES_TO_T_UINT_8( 0xBC, 0x86, 0x98, 0x76, 0x55, 0xBD, 0xEB, 0xB3 ), + BYTES_TO_T_UINT_8( 0xE7, 0x93, 0x3A, 0xAA, 0xD8, 0x35, 0xC6, 0x5A ), +}; +static const mbedtls_mpi_uint secp256r1_gx[] = { + BYTES_TO_T_UINT_8( 0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4 ), + BYTES_TO_T_UINT_8( 0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77 ), + BYTES_TO_T_UINT_8( 0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8 ), + BYTES_TO_T_UINT_8( 0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B ), +}; +static const mbedtls_mpi_uint secp256r1_gy[] = { + BYTES_TO_T_UINT_8( 0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB ), + BYTES_TO_T_UINT_8( 0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B ), + BYTES_TO_T_UINT_8( 0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E ), + BYTES_TO_T_UINT_8( 0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F ), +}; +static const mbedtls_mpi_uint secp256r1_n[] = { + BYTES_TO_T_UINT_8( 0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3 ), + BYTES_TO_T_UINT_8( 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ + +/* + * Domain parameters for secp384r1 + */ +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) +static const mbedtls_mpi_uint secp384r1_p[] = { + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), + BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +static const mbedtls_mpi_uint secp384r1_b[] = { + BYTES_TO_T_UINT_8( 0xEF, 0x2A, 0xEC, 0xD3, 0xED, 0xC8, 0x85, 0x2A ), + BYTES_TO_T_UINT_8( 0x9D, 0xD1, 0x2E, 0x8A, 0x8D, 0x39, 0x56, 0xC6 ), + BYTES_TO_T_UINT_8( 0x5A, 0x87, 0x13, 0x50, 0x8F, 0x08, 0x14, 0x03 ), + BYTES_TO_T_UINT_8( 0x12, 0x41, 0x81, 0xFE, 0x6E, 0x9C, 0x1D, 0x18 ), + BYTES_TO_T_UINT_8( 0x19, 0x2D, 0xF8, 0xE3, 0x6B, 0x05, 0x8E, 0x98 ), + BYTES_TO_T_UINT_8( 0xE4, 0xE7, 0x3E, 0xE2, 0xA7, 0x2F, 0x31, 0xB3 ), +}; +static const mbedtls_mpi_uint secp384r1_gx[] = { + BYTES_TO_T_UINT_8( 0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A ), + BYTES_TO_T_UINT_8( 0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55 ), + BYTES_TO_T_UINT_8( 0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59 ), + BYTES_TO_T_UINT_8( 0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E ), + BYTES_TO_T_UINT_8( 0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E ), + BYTES_TO_T_UINT_8( 0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA ), +}; +static const mbedtls_mpi_uint secp384r1_gy[] = { + BYTES_TO_T_UINT_8( 0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A ), + BYTES_TO_T_UINT_8( 0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A ), + BYTES_TO_T_UINT_8( 0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9 ), + BYTES_TO_T_UINT_8( 0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8 ), + BYTES_TO_T_UINT_8( 0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D ), + BYTES_TO_T_UINT_8( 0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36 ), +}; +static const mbedtls_mpi_uint secp384r1_n[] = { + BYTES_TO_T_UINT_8( 0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC ), + BYTES_TO_T_UINT_8( 0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58 ), + BYTES_TO_T_UINT_8( 0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7 ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + +/* + * Domain parameters for secp521r1 + */ +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) +static const mbedtls_mpi_uint secp521r1_p[] = { + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_2( 0xFF, 0x01 ), +}; +static const mbedtls_mpi_uint secp521r1_b[] = { + BYTES_TO_T_UINT_8( 0x00, 0x3F, 0x50, 0x6B, 0xD4, 0x1F, 0x45, 0xEF ), + BYTES_TO_T_UINT_8( 0xF1, 0x34, 0x2C, 0x3D, 0x88, 0xDF, 0x73, 0x35 ), + BYTES_TO_T_UINT_8( 0x07, 0xBF, 0xB1, 0x3B, 0xBD, 0xC0, 0x52, 0x16 ), + BYTES_TO_T_UINT_8( 0x7B, 0x93, 0x7E, 0xEC, 0x51, 0x39, 0x19, 0x56 ), + BYTES_TO_T_UINT_8( 0xE1, 0x09, 0xF1, 0x8E, 0x91, 0x89, 0xB4, 0xB8 ), + BYTES_TO_T_UINT_8( 0xF3, 0x15, 0xB3, 0x99, 0x5B, 0x72, 0xDA, 0xA2 ), + BYTES_TO_T_UINT_8( 0xEE, 0x40, 0x85, 0xB6, 0xA0, 0x21, 0x9A, 0x92 ), + BYTES_TO_T_UINT_8( 0x1F, 0x9A, 0x1C, 0x8E, 0x61, 0xB9, 0x3E, 0x95 ), + BYTES_TO_T_UINT_2( 0x51, 0x00 ), +}; +static const mbedtls_mpi_uint secp521r1_gx[] = { + BYTES_TO_T_UINT_8( 0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9 ), + BYTES_TO_T_UINT_8( 0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33 ), + BYTES_TO_T_UINT_8( 0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE ), + BYTES_TO_T_UINT_8( 0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1 ), + BYTES_TO_T_UINT_8( 0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8 ), + BYTES_TO_T_UINT_8( 0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C ), + BYTES_TO_T_UINT_8( 0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E ), + BYTES_TO_T_UINT_8( 0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85 ), + BYTES_TO_T_UINT_2( 0xC6, 0x00 ), +}; +static const mbedtls_mpi_uint secp521r1_gy[] = { + BYTES_TO_T_UINT_8( 0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88 ), + BYTES_TO_T_UINT_8( 0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35 ), + BYTES_TO_T_UINT_8( 0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5 ), + BYTES_TO_T_UINT_8( 0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97 ), + BYTES_TO_T_UINT_8( 0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17 ), + BYTES_TO_T_UINT_8( 0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98 ), + BYTES_TO_T_UINT_8( 0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C ), + BYTES_TO_T_UINT_8( 0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39 ), + BYTES_TO_T_UINT_2( 0x18, 0x01 ), +}; +static const mbedtls_mpi_uint secp521r1_n[] = { + BYTES_TO_T_UINT_8( 0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB ), + BYTES_TO_T_UINT_8( 0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B ), + BYTES_TO_T_UINT_8( 0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F ), + BYTES_TO_T_UINT_8( 0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51 ), + BYTES_TO_T_UINT_8( 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_2( 0xFF, 0x01 ), +}; +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) +static const mbedtls_mpi_uint secp192k1_p[] = { + BYTES_TO_T_UINT_8( 0x37, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +static const mbedtls_mpi_uint secp192k1_a[] = { + BYTES_TO_T_UINT_2( 0x00, 0x00 ), +}; +static const mbedtls_mpi_uint secp192k1_b[] = { + BYTES_TO_T_UINT_2( 0x03, 0x00 ), +}; +static const mbedtls_mpi_uint secp192k1_gx[] = { + BYTES_TO_T_UINT_8( 0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D ), + BYTES_TO_T_UINT_8( 0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26 ), + BYTES_TO_T_UINT_8( 0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB ), +}; +static const mbedtls_mpi_uint secp192k1_gy[] = { + BYTES_TO_T_UINT_8( 0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40 ), + BYTES_TO_T_UINT_8( 0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84 ), + BYTES_TO_T_UINT_8( 0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B ), +}; +static const mbedtls_mpi_uint secp192k1_n[] = { + BYTES_TO_T_UINT_8( 0x8D, 0xFD, 0xDE, 0x74, 0x6A, 0x46, 0x69, 0x0F ), + BYTES_TO_T_UINT_8( 0x17, 0xFC, 0xF2, 0x26, 0xFE, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) +static const mbedtls_mpi_uint secp224k1_p[] = { + BYTES_TO_T_UINT_8( 0x6D, 0xE5, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), +}; +static const mbedtls_mpi_uint secp224k1_a[] = { + BYTES_TO_T_UINT_2( 0x00, 0x00 ), +}; +static const mbedtls_mpi_uint secp224k1_b[] = { + BYTES_TO_T_UINT_2( 0x05, 0x00 ), +}; +static const mbedtls_mpi_uint secp224k1_gx[] = { + BYTES_TO_T_UINT_8( 0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F ), + BYTES_TO_T_UINT_8( 0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69 ), + BYTES_TO_T_UINT_8( 0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D ), + BYTES_TO_T_UINT_4( 0x33, 0x5B, 0x45, 0xA1 ), +}; +static const mbedtls_mpi_uint secp224k1_gy[] = { + BYTES_TO_T_UINT_8( 0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2 ), + BYTES_TO_T_UINT_8( 0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7 ), + BYTES_TO_T_UINT_8( 0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F ), + BYTES_TO_T_UINT_4( 0xED, 0x9F, 0x08, 0x7E ), +}; +static const mbedtls_mpi_uint secp224k1_n[] = { + BYTES_TO_T_UINT_8( 0xF7, 0xB1, 0x9F, 0x76, 0x71, 0xA9, 0xF0, 0xCA ), + BYTES_TO_T_UINT_8( 0x84, 0x61, 0xEC, 0xD2, 0xE8, 0xDC, 0x01, 0x00 ), + BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), + BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ), +}; +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) +static const mbedtls_mpi_uint secp256k1_p[] = { + BYTES_TO_T_UINT_8( 0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +static const mbedtls_mpi_uint secp256k1_a[] = { + BYTES_TO_T_UINT_2( 0x00, 0x00 ), +}; +static const mbedtls_mpi_uint secp256k1_b[] = { + BYTES_TO_T_UINT_2( 0x07, 0x00 ), +}; +static const mbedtls_mpi_uint secp256k1_gx[] = { + BYTES_TO_T_UINT_8( 0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59 ), + BYTES_TO_T_UINT_8( 0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02 ), + BYTES_TO_T_UINT_8( 0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55 ), + BYTES_TO_T_UINT_8( 0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79 ), +}; +static const mbedtls_mpi_uint secp256k1_gy[] = { + BYTES_TO_T_UINT_8( 0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C ), + BYTES_TO_T_UINT_8( 0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD ), + BYTES_TO_T_UINT_8( 0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D ), + BYTES_TO_T_UINT_8( 0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48 ), +}; +static const mbedtls_mpi_uint secp256k1_n[] = { + BYTES_TO_T_UINT_8( 0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF ), + BYTES_TO_T_UINT_8( 0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA ), + BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +}; +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + +/* + * Domain parameters for brainpoolP256r1 (RFC 5639 3.4) + */ +#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) +static const mbedtls_mpi_uint brainpoolP256r1_p[] = { + BYTES_TO_T_UINT_8( 0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20 ), + BYTES_TO_T_UINT_8( 0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E ), + BYTES_TO_T_UINT_8( 0x72, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), + BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), +}; +static const mbedtls_mpi_uint brainpoolP256r1_a[] = { + BYTES_TO_T_UINT_8( 0xD9, 0xB5, 0x30, 0xF3, 0x44, 0x4B, 0x4A, 0xE9 ), + BYTES_TO_T_UINT_8( 0x6C, 0x5C, 0xDC, 0x26, 0xC1, 0x55, 0x80, 0xFB ), + BYTES_TO_T_UINT_8( 0xE7, 0xFF, 0x7A, 0x41, 0x30, 0x75, 0xF6, 0xEE ), + BYTES_TO_T_UINT_8( 0x57, 0x30, 0x2C, 0xFC, 0x75, 0x09, 0x5A, 0x7D ), +}; +static const mbedtls_mpi_uint brainpoolP256r1_b[] = { + BYTES_TO_T_UINT_8( 0xB6, 0x07, 0x8C, 0xFF, 0x18, 0xDC, 0xCC, 0x6B ), + BYTES_TO_T_UINT_8( 0xCE, 0xE1, 0xF7, 0x5C, 0x29, 0x16, 0x84, 0x95 ), + BYTES_TO_T_UINT_8( 0xBF, 0x7C, 0xD7, 0xBB, 0xD9, 0xB5, 0x30, 0xF3 ), + BYTES_TO_T_UINT_8( 0x44, 0x4B, 0x4A, 0xE9, 0x6C, 0x5C, 0xDC, 0x26 ), +}; +static const mbedtls_mpi_uint brainpoolP256r1_gx[] = { + BYTES_TO_T_UINT_8( 0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A ), + BYTES_TO_T_UINT_8( 0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9 ), + BYTES_TO_T_UINT_8( 0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C ), + BYTES_TO_T_UINT_8( 0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B ), +}; +static const mbedtls_mpi_uint brainpoolP256r1_gy[] = { + BYTES_TO_T_UINT_8( 0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C ), + BYTES_TO_T_UINT_8( 0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2 ), + BYTES_TO_T_UINT_8( 0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97 ), + BYTES_TO_T_UINT_8( 0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54 ), +}; +static const mbedtls_mpi_uint brainpoolP256r1_n[] = { + BYTES_TO_T_UINT_8( 0xA7, 0x56, 0x48, 0x97, 0x82, 0x0E, 0x1E, 0x90 ), + BYTES_TO_T_UINT_8( 0xF7, 0xA6, 0x61, 0xB5, 0xA3, 0x7A, 0x39, 0x8C ), + BYTES_TO_T_UINT_8( 0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), + BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), +}; +#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ + +/* + * Domain parameters for brainpoolP384r1 (RFC 5639 3.6) + */ +#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) +static const mbedtls_mpi_uint brainpoolP384r1_p[] = { + BYTES_TO_T_UINT_8( 0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87 ), + BYTES_TO_T_UINT_8( 0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC ), + BYTES_TO_T_UINT_8( 0x23, 0x11, 0xB7, 0x7F, 0x19, 0xDA, 0xB1, 0x12 ), + BYTES_TO_T_UINT_8( 0xB4, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), + BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), + BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), +}; +static const mbedtls_mpi_uint brainpoolP384r1_a[] = { + BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), + BYTES_TO_T_UINT_8( 0xEB, 0xD4, 0x3A, 0x50, 0x4A, 0x81, 0xA5, 0x8A ), + BYTES_TO_T_UINT_8( 0x0F, 0xF9, 0x91, 0xBA, 0xEF, 0x65, 0x91, 0x13 ), + BYTES_TO_T_UINT_8( 0x87, 0x27, 0xB2, 0x4F, 0x8E, 0xA2, 0xBE, 0xC2 ), + BYTES_TO_T_UINT_8( 0xA0, 0xAF, 0x05, 0xCE, 0x0A, 0x08, 0x72, 0x3C ), + BYTES_TO_T_UINT_8( 0x0C, 0x15, 0x8C, 0x3D, 0xC6, 0x82, 0xC3, 0x7B ), +}; +static const mbedtls_mpi_uint brainpoolP384r1_b[] = { + BYTES_TO_T_UINT_8( 0x11, 0x4C, 0x50, 0xFA, 0x96, 0x86, 0xB7, 0x3A ), + BYTES_TO_T_UINT_8( 0x94, 0xC9, 0xDB, 0x95, 0x02, 0x39, 0xB4, 0x7C ), + BYTES_TO_T_UINT_8( 0xD5, 0x62, 0xEB, 0x3E, 0xA5, 0x0E, 0x88, 0x2E ), + BYTES_TO_T_UINT_8( 0xA6, 0xD2, 0xDC, 0x07, 0xE1, 0x7D, 0xB7, 0x2F ), + BYTES_TO_T_UINT_8( 0x7C, 0x44, 0xF0, 0x16, 0x54, 0xB5, 0x39, 0x8B ), + BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), +}; +static const mbedtls_mpi_uint brainpoolP384r1_gx[] = { + BYTES_TO_T_UINT_8( 0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF ), + BYTES_TO_T_UINT_8( 0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8 ), + BYTES_TO_T_UINT_8( 0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB ), + BYTES_TO_T_UINT_8( 0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88 ), + BYTES_TO_T_UINT_8( 0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2 ), + BYTES_TO_T_UINT_8( 0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D ), +}; +static const mbedtls_mpi_uint brainpoolP384r1_gy[] = { + BYTES_TO_T_UINT_8( 0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42 ), + BYTES_TO_T_UINT_8( 0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E ), + BYTES_TO_T_UINT_8( 0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1 ), + BYTES_TO_T_UINT_8( 0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62 ), + BYTES_TO_T_UINT_8( 0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C ), + BYTES_TO_T_UINT_8( 0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A ), +}; +static const mbedtls_mpi_uint brainpoolP384r1_n[] = { + BYTES_TO_T_UINT_8( 0x65, 0x65, 0x04, 0xE9, 0x02, 0x32, 0x88, 0x3B ), + BYTES_TO_T_UINT_8( 0x10, 0xC3, 0x7F, 0x6B, 0xAF, 0xB6, 0x3A, 0xCF ), + BYTES_TO_T_UINT_8( 0xA7, 0x25, 0x04, 0xAC, 0x6C, 0x6E, 0x16, 0x1F ), + BYTES_TO_T_UINT_8( 0xB3, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), + BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), + BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), +}; +#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ + +/* + * Domain parameters for brainpoolP512r1 (RFC 5639 3.7) + */ +#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) +static const mbedtls_mpi_uint brainpoolP512r1_p[] = { + BYTES_TO_T_UINT_8( 0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28 ), + BYTES_TO_T_UINT_8( 0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28 ), + BYTES_TO_T_UINT_8( 0xE6, 0x80, 0xA3, 0xE6, 0x2A, 0xA1, 0xCD, 0xAE ), + BYTES_TO_T_UINT_8( 0x42, 0x68, 0xC6, 0x9B, 0x00, 0x9B, 0x4D, 0x7D ), + BYTES_TO_T_UINT_8( 0x71, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), + BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), + BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), + BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), +}; +static const mbedtls_mpi_uint brainpoolP512r1_a[] = { + BYTES_TO_T_UINT_8( 0xCA, 0x94, 0xFC, 0x77, 0x4D, 0xAC, 0xC1, 0xE7 ), + BYTES_TO_T_UINT_8( 0xB9, 0xC7, 0xF2, 0x2B, 0xA7, 0x17, 0x11, 0x7F ), + BYTES_TO_T_UINT_8( 0xB5, 0xC8, 0x9A, 0x8B, 0xC9, 0xF1, 0x2E, 0x0A ), + BYTES_TO_T_UINT_8( 0xA1, 0x3A, 0x25, 0xA8, 0x5A, 0x5D, 0xED, 0x2D ), + BYTES_TO_T_UINT_8( 0xBC, 0x63, 0x98, 0xEA, 0xCA, 0x41, 0x34, 0xA8 ), + BYTES_TO_T_UINT_8( 0x10, 0x16, 0xF9, 0x3D, 0x8D, 0xDD, 0xCB, 0x94 ), + BYTES_TO_T_UINT_8( 0xC5, 0x4C, 0x23, 0xAC, 0x45, 0x71, 0x32, 0xE2 ), + BYTES_TO_T_UINT_8( 0x89, 0x3B, 0x60, 0x8B, 0x31, 0xA3, 0x30, 0x78 ), +}; +static const mbedtls_mpi_uint brainpoolP512r1_b[] = { + BYTES_TO_T_UINT_8( 0x23, 0xF7, 0x16, 0x80, 0x63, 0xBD, 0x09, 0x28 ), + BYTES_TO_T_UINT_8( 0xDD, 0xE5, 0xBA, 0x5E, 0xB7, 0x50, 0x40, 0x98 ), + BYTES_TO_T_UINT_8( 0x67, 0x3E, 0x08, 0xDC, 0xCA, 0x94, 0xFC, 0x77 ), + BYTES_TO_T_UINT_8( 0x4D, 0xAC, 0xC1, 0xE7, 0xB9, 0xC7, 0xF2, 0x2B ), + BYTES_TO_T_UINT_8( 0xA7, 0x17, 0x11, 0x7F, 0xB5, 0xC8, 0x9A, 0x8B ), + BYTES_TO_T_UINT_8( 0xC9, 0xF1, 0x2E, 0x0A, 0xA1, 0x3A, 0x25, 0xA8 ), + BYTES_TO_T_UINT_8( 0x5A, 0x5D, 0xED, 0x2D, 0xBC, 0x63, 0x98, 0xEA ), + BYTES_TO_T_UINT_8( 0xCA, 0x41, 0x34, 0xA8, 0x10, 0x16, 0xF9, 0x3D ), +}; +static const mbedtls_mpi_uint brainpoolP512r1_gx[] = { + BYTES_TO_T_UINT_8( 0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B ), + BYTES_TO_T_UINT_8( 0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C ), + BYTES_TO_T_UINT_8( 0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50 ), + BYTES_TO_T_UINT_8( 0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF ), + BYTES_TO_T_UINT_8( 0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4 ), + BYTES_TO_T_UINT_8( 0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85 ), + BYTES_TO_T_UINT_8( 0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A ), + BYTES_TO_T_UINT_8( 0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81 ), +}; +static const mbedtls_mpi_uint brainpoolP512r1_gy[] = { + BYTES_TO_T_UINT_8( 0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78 ), + BYTES_TO_T_UINT_8( 0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1 ), + BYTES_TO_T_UINT_8( 0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B ), + BYTES_TO_T_UINT_8( 0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2 ), + BYTES_TO_T_UINT_8( 0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0 ), + BYTES_TO_T_UINT_8( 0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2 ), + BYTES_TO_T_UINT_8( 0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0 ), + BYTES_TO_T_UINT_8( 0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D ), +}; +static const mbedtls_mpi_uint brainpoolP512r1_n[] = { + BYTES_TO_T_UINT_8( 0x69, 0x00, 0xA9, 0x9C, 0x82, 0x96, 0x87, 0xB5 ), + BYTES_TO_T_UINT_8( 0xDD, 0xDA, 0x5D, 0x08, 0x81, 0xD3, 0xB1, 0x1D ), + BYTES_TO_T_UINT_8( 0x47, 0x10, 0xAC, 0x7F, 0x19, 0x61, 0x86, 0x41 ), + BYTES_TO_T_UINT_8( 0x19, 0x26, 0xA9, 0x4C, 0x41, 0x5C, 0x3E, 0x55 ), + BYTES_TO_T_UINT_8( 0x70, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), + BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), + BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), + BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), +}; +#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ + +/* + * Create an MPI from embedded constants + * (assumes len is an exact multiple of sizeof mbedtls_mpi_uint) + */ +static inline void ecp_mpi_load( mbedtls_mpi *X, const mbedtls_mpi_uint *p, size_t len ) +{ + X->s = 1; + X->n = len / sizeof( mbedtls_mpi_uint ); + X->p = (mbedtls_mpi_uint *) p; +} + +/* + * Set an MPI to static value 1 + */ +static inline void ecp_mpi_set1( mbedtls_mpi *X ) +{ + static mbedtls_mpi_uint one[] = { 1 }; + X->s = 1; + X->n = 1; + X->p = one; +} + +/* + * Make group available from embedded constants + */ +static int ecp_group_load( mbedtls_ecp_group *grp, + const mbedtls_mpi_uint *p, size_t plen, + const mbedtls_mpi_uint *a, size_t alen, + const mbedtls_mpi_uint *b, size_t blen, + const mbedtls_mpi_uint *gx, size_t gxlen, + const mbedtls_mpi_uint *gy, size_t gylen, + const mbedtls_mpi_uint *n, size_t nlen) +{ + ecp_mpi_load( &grp->P, p, plen ); + if( a != NULL ) + ecp_mpi_load( &grp->A, a, alen ); + ecp_mpi_load( &grp->B, b, blen ); + ecp_mpi_load( &grp->N, n, nlen ); + + ecp_mpi_load( &grp->G.X, gx, gxlen ); + ecp_mpi_load( &grp->G.Y, gy, gylen ); + ecp_mpi_set1( &grp->G.Z ); + + grp->pbits = mbedtls_mpi_bitlen( &grp->P ); + grp->nbits = mbedtls_mpi_bitlen( &grp->N ); + + grp->h = 1; + + return( 0 ); +} + +#if defined(MBEDTLS_ECP_NIST_OPTIM) +/* Forward declarations */ +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) +static int ecp_mod_p192( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) +static int ecp_mod_p224( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) +static int ecp_mod_p256( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) +static int ecp_mod_p384( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) +static int ecp_mod_p521( mbedtls_mpi * ); +#endif + +#define NIST_MODP( P ) grp->modp = ecp_mod_ ## P; +#else +#define NIST_MODP( P ) +#endif /* MBEDTLS_ECP_NIST_OPTIM */ + +/* Additional forward declarations */ +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +static int ecp_mod_p255( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) +static int ecp_mod_p192k1( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) +static int ecp_mod_p224k1( mbedtls_mpi * ); +#endif +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) +static int ecp_mod_p256k1( mbedtls_mpi * ); +#endif + +#define LOAD_GROUP_A( G ) ecp_group_load( grp, \ + G ## _p, sizeof( G ## _p ), \ + G ## _a, sizeof( G ## _a ), \ + G ## _b, sizeof( G ## _b ), \ + G ## _gx, sizeof( G ## _gx ), \ + G ## _gy, sizeof( G ## _gy ), \ + G ## _n, sizeof( G ## _n ) ) + +#define LOAD_GROUP( G ) ecp_group_load( grp, \ + G ## _p, sizeof( G ## _p ), \ + NULL, 0, \ + G ## _b, sizeof( G ## _b ), \ + G ## _gx, sizeof( G ## _gx ), \ + G ## _gy, sizeof( G ## _gy ), \ + G ## _n, sizeof( G ## _n ) ) + +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +/* + * Specialized function for creating the Curve25519 group + */ +static int ecp_use_curve25519( mbedtls_ecp_group *grp ) +{ + int ret; + + /* Actually ( A + 2 ) / 4 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->A, 16, "01DB42" ) ); + + /* P = 2^255 - 19 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &grp->P, 255 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &grp->P, &grp->P, 19 ) ); + grp->pbits = mbedtls_mpi_bitlen( &grp->P ); + + /* Y intentionaly not set, since we use x/z coordinates. + * This is used as a marker to identify Montgomery curves! */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->G.X, 9 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->G.Z, 1 ) ); + mbedtls_mpi_free( &grp->G.Y ); + + /* Actually, the required msb for private keys */ + grp->nbits = 254; + +cleanup: + if( ret != 0 ) + mbedtls_ecp_group_free( grp ); + + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ + +/* + * Set a group using well-known domain parameters + */ +int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ) +{ + mbedtls_ecp_group_free( grp ); + + grp->id = id; + + switch( id ) + { +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + case MBEDTLS_ECP_DP_SECP192R1: + NIST_MODP( p192 ); + return( LOAD_GROUP( secp192r1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) + case MBEDTLS_ECP_DP_SECP224R1: + NIST_MODP( p224 ); + return( LOAD_GROUP( secp224r1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + case MBEDTLS_ECP_DP_SECP256R1: + NIST_MODP( p256 ); + return( LOAD_GROUP( secp256r1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + case MBEDTLS_ECP_DP_SECP384R1: + NIST_MODP( p384 ); + return( LOAD_GROUP( secp384r1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + case MBEDTLS_ECP_DP_SECP521R1: + NIST_MODP( p521 ); + return( LOAD_GROUP( secp521r1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) + case MBEDTLS_ECP_DP_SECP192K1: + grp->modp = ecp_mod_p192k1; + return( LOAD_GROUP_A( secp192k1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) + case MBEDTLS_ECP_DP_SECP224K1: + grp->modp = ecp_mod_p224k1; + return( LOAD_GROUP_A( secp224k1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) + case MBEDTLS_ECP_DP_SECP256K1: + grp->modp = ecp_mod_p256k1; + return( LOAD_GROUP_A( secp256k1 ) ); +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) + case MBEDTLS_ECP_DP_BP256R1: + return( LOAD_GROUP_A( brainpoolP256r1 ) ); +#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) + case MBEDTLS_ECP_DP_BP384R1: + return( LOAD_GROUP_A( brainpoolP384r1 ) ); +#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) + case MBEDTLS_ECP_DP_BP512R1: + return( LOAD_GROUP_A( brainpoolP512r1 ) ); +#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + case MBEDTLS_ECP_DP_CURVE25519: + grp->modp = ecp_mod_p255; + return( ecp_use_curve25519( grp ) ); +#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ + + default: + mbedtls_ecp_group_free( grp ); + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); + } +} + +#if defined(MBEDTLS_ECP_NIST_OPTIM) +/* + * Fast reduction modulo the primes used by the NIST curves. + * + * These functions are critical for speed, but not needed for correct + * operations. So, we make the choice to heavily rely on the internals of our + * bignum library, which creates a tight coupling between these functions and + * our MPI implementation. However, the coupling between the ECP module and + * MPI remains loose, since these functions can be deactivated at will. + */ + +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) +/* + * Compared to the way things are presented in FIPS 186-3 D.2, + * we proceed in columns, from right (least significant chunk) to left, + * adding chunks to N in place, and keeping a carry for the next chunk. + * This avoids moving things around in memory, and uselessly adding zeros, + * compared to the more straightforward, line-oriented approach. + * + * For this prime we need to handle data in chunks of 64 bits. + * Since this is always a multiple of our basic mbedtls_mpi_uint, we can + * use a mbedtls_mpi_uint * to designate such a chunk, and small loops to handle it. + */ + +/* Add 64-bit chunks (dst += src) and update carry */ +static inline void add64( mbedtls_mpi_uint *dst, mbedtls_mpi_uint *src, mbedtls_mpi_uint *carry ) +{ + unsigned char i; + mbedtls_mpi_uint c = 0; + for( i = 0; i < 8 / sizeof( mbedtls_mpi_uint ); i++, dst++, src++ ) + { + *dst += c; c = ( *dst < c ); + *dst += *src; c += ( *dst < *src ); + } + *carry += c; +} + +/* Add carry to a 64-bit chunk and update carry */ +static inline void carry64( mbedtls_mpi_uint *dst, mbedtls_mpi_uint *carry ) +{ + unsigned char i; + for( i = 0; i < 8 / sizeof( mbedtls_mpi_uint ); i++, dst++ ) + { + *dst += *carry; + *carry = ( *dst < *carry ); + } +} + +#define WIDTH 8 / sizeof( mbedtls_mpi_uint ) +#define A( i ) N->p + i * WIDTH +#define ADD( i ) add64( p, A( i ), &c ) +#define NEXT p += WIDTH; carry64( p, &c ) +#define LAST p += WIDTH; *p = c; while( ++p < end ) *p = 0 + +/* + * Fast quasi-reduction modulo p192 (FIPS 186-3 D.2.1) + */ +static int ecp_mod_p192( mbedtls_mpi *N ) +{ + int ret; + mbedtls_mpi_uint c = 0; + mbedtls_mpi_uint *p, *end; + + /* Make sure we have enough blocks so that A(5) is legal */ + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( N, 6 * WIDTH ) ); + + p = N->p; + end = p + N->n; + + ADD( 3 ); ADD( 5 ); NEXT; // A0 += A3 + A5 + ADD( 3 ); ADD( 4 ); ADD( 5 ); NEXT; // A1 += A3 + A4 + A5 + ADD( 4 ); ADD( 5 ); LAST; // A2 += A4 + A5 + +cleanup: + return( ret ); +} + +#undef WIDTH +#undef A +#undef ADD +#undef NEXT +#undef LAST +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) +/* + * The reader is advised to first understand ecp_mod_p192() since the same + * general structure is used here, but with additional complications: + * (1) chunks of 32 bits, and (2) subtractions. + */ + +/* + * For these primes, we need to handle data in chunks of 32 bits. + * This makes it more complicated if we use 64 bits limbs in MPI, + * which prevents us from using a uniform access method as for p192. + * + * So, we define a mini abstraction layer to access 32 bit chunks, + * load them in 'cur' for work, and store them back from 'cur' when done. + * + * While at it, also define the size of N in terms of 32-bit chunks. + */ +#define LOAD32 cur = A( i ); + +#if defined(MBEDTLS_HAVE_INT32) /* 32 bit */ + +#define MAX32 N->n +#define A( j ) N->p[j] +#define STORE32 N->p[i] = cur; + +#else /* 64-bit */ + +#define MAX32 N->n * 2 +#define A( j ) j % 2 ? (uint32_t)( N->p[j/2] >> 32 ) : (uint32_t)( N->p[j/2] ) +#define STORE32 \ + if( i % 2 ) { \ + N->p[i/2] &= 0x00000000FFFFFFFF; \ + N->p[i/2] |= ((mbedtls_mpi_uint) cur) << 32; \ + } else { \ + N->p[i/2] &= 0xFFFFFFFF00000000; \ + N->p[i/2] |= (mbedtls_mpi_uint) cur; \ + } + +#endif /* sizeof( mbedtls_mpi_uint ) */ + +/* + * Helpers for addition and subtraction of chunks, with signed carry. + */ +static inline void add32( uint32_t *dst, uint32_t src, signed char *carry ) +{ + *dst += src; + *carry += ( *dst < src ); +} + +static inline void sub32( uint32_t *dst, uint32_t src, signed char *carry ) +{ + *carry -= ( *dst < src ); + *dst -= src; +} + +#define ADD( j ) add32( &cur, A( j ), &c ); +#define SUB( j ) sub32( &cur, A( j ), &c ); + +/* + * Helpers for the main 'loop' + * (see fix_negative for the motivation of C) + */ +#define INIT( b ) \ + int ret; \ + signed char c = 0, cc; \ + uint32_t cur; \ + size_t i = 0, bits = b; \ + mbedtls_mpi C; \ + mbedtls_mpi_uint Cp[ b / 8 / sizeof( mbedtls_mpi_uint) + 1 ]; \ + \ + C.s = 1; \ + C.n = b / 8 / sizeof( mbedtls_mpi_uint) + 1; \ + C.p = Cp; \ + memset( Cp, 0, C.n * sizeof( mbedtls_mpi_uint ) ); \ + \ + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( N, b * 2 / 8 / sizeof( mbedtls_mpi_uint ) ) ); \ + LOAD32; + +#define NEXT \ + STORE32; i++; LOAD32; \ + cc = c; c = 0; \ + if( cc < 0 ) \ + sub32( &cur, -cc, &c ); \ + else \ + add32( &cur, cc, &c ); \ + +#define LAST \ + STORE32; i++; \ + cur = c > 0 ? c : 0; STORE32; \ + cur = 0; while( ++i < MAX32 ) { STORE32; } \ + if( c < 0 ) fix_negative( N, c, &C, bits ); + +/* + * If the result is negative, we get it in the form + * c * 2^(bits + 32) + N, with c negative and N positive shorter than 'bits' + */ +static inline int fix_negative( mbedtls_mpi *N, signed char c, mbedtls_mpi *C, size_t bits ) +{ + int ret; + + /* C = - c * 2^(bits + 32) */ +#if !defined(MBEDTLS_HAVE_INT64) + ((void) bits); +#else + if( bits == 224 ) + C->p[ C->n - 1 ] = ((mbedtls_mpi_uint) -c) << 32; + else +#endif + C->p[ C->n - 1 ] = (mbedtls_mpi_uint) -c; + + /* N = - ( C - N ) */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( N, C, N ) ); + N->s = -1; + +cleanup: + + return( ret ); +} + +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) +/* + * Fast quasi-reduction modulo p224 (FIPS 186-3 D.2.2) + */ +static int ecp_mod_p224( mbedtls_mpi *N ) +{ + INIT( 224 ); + + SUB( 7 ); SUB( 11 ); NEXT; // A0 += -A7 - A11 + SUB( 8 ); SUB( 12 ); NEXT; // A1 += -A8 - A12 + SUB( 9 ); SUB( 13 ); NEXT; // A2 += -A9 - A13 + SUB( 10 ); ADD( 7 ); ADD( 11 ); NEXT; // A3 += -A10 + A7 + A11 + SUB( 11 ); ADD( 8 ); ADD( 12 ); NEXT; // A4 += -A11 + A8 + A12 + SUB( 12 ); ADD( 9 ); ADD( 13 ); NEXT; // A5 += -A12 + A9 + A13 + SUB( 13 ); ADD( 10 ); LAST; // A6 += -A13 + A10 + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) +/* + * Fast quasi-reduction modulo p256 (FIPS 186-3 D.2.3) + */ +static int ecp_mod_p256( mbedtls_mpi *N ) +{ + INIT( 256 ); + + ADD( 8 ); ADD( 9 ); + SUB( 11 ); SUB( 12 ); SUB( 13 ); SUB( 14 ); NEXT; // A0 + + ADD( 9 ); ADD( 10 ); + SUB( 12 ); SUB( 13 ); SUB( 14 ); SUB( 15 ); NEXT; // A1 + + ADD( 10 ); ADD( 11 ); + SUB( 13 ); SUB( 14 ); SUB( 15 ); NEXT; // A2 + + ADD( 11 ); ADD( 11 ); ADD( 12 ); ADD( 12 ); ADD( 13 ); + SUB( 15 ); SUB( 8 ); SUB( 9 ); NEXT; // A3 + + ADD( 12 ); ADD( 12 ); ADD( 13 ); ADD( 13 ); ADD( 14 ); + SUB( 9 ); SUB( 10 ); NEXT; // A4 + + ADD( 13 ); ADD( 13 ); ADD( 14 ); ADD( 14 ); ADD( 15 ); + SUB( 10 ); SUB( 11 ); NEXT; // A5 + + ADD( 14 ); ADD( 14 ); ADD( 15 ); ADD( 15 ); ADD( 14 ); ADD( 13 ); + SUB( 8 ); SUB( 9 ); NEXT; // A6 + + ADD( 15 ); ADD( 15 ); ADD( 15 ); ADD( 8 ); + SUB( 10 ); SUB( 11 ); SUB( 12 ); SUB( 13 ); LAST; // A7 + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) +/* + * Fast quasi-reduction modulo p384 (FIPS 186-3 D.2.4) + */ +static int ecp_mod_p384( mbedtls_mpi *N ) +{ + INIT( 384 ); + + ADD( 12 ); ADD( 21 ); ADD( 20 ); + SUB( 23 ); NEXT; // A0 + + ADD( 13 ); ADD( 22 ); ADD( 23 ); + SUB( 12 ); SUB( 20 ); NEXT; // A2 + + ADD( 14 ); ADD( 23 ); + SUB( 13 ); SUB( 21 ); NEXT; // A2 + + ADD( 15 ); ADD( 12 ); ADD( 20 ); ADD( 21 ); + SUB( 14 ); SUB( 22 ); SUB( 23 ); NEXT; // A3 + + ADD( 21 ); ADD( 21 ); ADD( 16 ); ADD( 13 ); ADD( 12 ); ADD( 20 ); ADD( 22 ); + SUB( 15 ); SUB( 23 ); SUB( 23 ); NEXT; // A4 + + ADD( 22 ); ADD( 22 ); ADD( 17 ); ADD( 14 ); ADD( 13 ); ADD( 21 ); ADD( 23 ); + SUB( 16 ); NEXT; // A5 + + ADD( 23 ); ADD( 23 ); ADD( 18 ); ADD( 15 ); ADD( 14 ); ADD( 22 ); + SUB( 17 ); NEXT; // A6 + + ADD( 19 ); ADD( 16 ); ADD( 15 ); ADD( 23 ); + SUB( 18 ); NEXT; // A7 + + ADD( 20 ); ADD( 17 ); ADD( 16 ); + SUB( 19 ); NEXT; // A8 + + ADD( 21 ); ADD( 18 ); ADD( 17 ); + SUB( 20 ); NEXT; // A9 + + ADD( 22 ); ADD( 19 ); ADD( 18 ); + SUB( 21 ); NEXT; // A10 + + ADD( 23 ); ADD( 20 ); ADD( 19 ); + SUB( 22 ); LAST; // A11 + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + +#undef A +#undef LOAD32 +#undef STORE32 +#undef MAX32 +#undef INIT +#undef NEXT +#undef LAST + +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED || + MBEDTLS_ECP_DP_SECP256R1_ENABLED || + MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) +/* + * Here we have an actual Mersenne prime, so things are more straightforward. + * However, chunks are aligned on a 'weird' boundary (521 bits). + */ + +/* Size of p521 in terms of mbedtls_mpi_uint */ +#define P521_WIDTH ( 521 / 8 / sizeof( mbedtls_mpi_uint ) + 1 ) + +/* Bits to keep in the most significant mbedtls_mpi_uint */ +#define P521_MASK 0x01FF + +/* + * Fast quasi-reduction modulo p521 (FIPS 186-3 D.2.5) + * Write N as A1 + 2^521 A0, return A0 + A1 + */ +static int ecp_mod_p521( mbedtls_mpi *N ) +{ + int ret; + size_t i; + mbedtls_mpi M; + mbedtls_mpi_uint Mp[P521_WIDTH + 1]; + /* Worst case for the size of M is when mbedtls_mpi_uint is 16 bits: + * we need to hold bits 513 to 1056, which is 34 limbs, that is + * P521_WIDTH + 1. Otherwise P521_WIDTH is enough. */ + + if( N->n < P521_WIDTH ) + return( 0 ); + + /* M = A1 */ + M.s = 1; + M.n = N->n - ( P521_WIDTH - 1 ); + if( M.n > P521_WIDTH + 1 ) + M.n = P521_WIDTH + 1; + M.p = Mp; + memcpy( Mp, N->p + P521_WIDTH - 1, M.n * sizeof( mbedtls_mpi_uint ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &M, 521 % ( 8 * sizeof( mbedtls_mpi_uint ) ) ) ); + + /* N = A0 */ + N->p[P521_WIDTH - 1] &= P521_MASK; + for( i = P521_WIDTH; i < N->n; i++ ) + N->p[i] = 0; + + /* N = A0 + A1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( N, N, &M ) ); + +cleanup: + return( ret ); +} + +#undef P521_WIDTH +#undef P521_MASK +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ + +#endif /* MBEDTLS_ECP_NIST_OPTIM */ + +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + +/* Size of p255 in terms of mbedtls_mpi_uint */ +#define P255_WIDTH ( 255 / 8 / sizeof( mbedtls_mpi_uint ) + 1 ) + +/* + * Fast quasi-reduction modulo p255 = 2^255 - 19 + * Write N as A0 + 2^255 A1, return A0 + 19 * A1 + */ +static int ecp_mod_p255( mbedtls_mpi *N ) +{ + int ret; + size_t i; + mbedtls_mpi M; + mbedtls_mpi_uint Mp[P255_WIDTH + 2]; + + if( N->n < P255_WIDTH ) + return( 0 ); + + /* M = A1 */ + M.s = 1; + M.n = N->n - ( P255_WIDTH - 1 ); + if( M.n > P255_WIDTH + 1 ) + M.n = P255_WIDTH + 1; + M.p = Mp; + memset( Mp, 0, sizeof Mp ); + memcpy( Mp, N->p + P255_WIDTH - 1, M.n * sizeof( mbedtls_mpi_uint ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &M, 255 % ( 8 * sizeof( mbedtls_mpi_uint ) ) ) ); + M.n++; /* Make room for multiplication by 19 */ + + /* N = A0 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( N, 255, 0 ) ); + for( i = P255_WIDTH; i < N->n; i++ ) + N->p[i] = 0; + + /* N = A0 + 19 * A1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &M, &M, 19 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( N, N, &M ) ); + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ + defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) +/* + * Fast quasi-reduction modulo P = 2^s - R, + * with R about 33 bits, used by the Koblitz curves. + * + * Write N as A0 + 2^224 A1, return A0 + R * A1. + * Actually do two passes, since R is big. + */ +#define P_KOBLITZ_MAX ( 256 / 8 / sizeof( mbedtls_mpi_uint ) ) // Max limbs in P +#define P_KOBLITZ_R ( 8 / sizeof( mbedtls_mpi_uint ) ) // Limbs in R +static inline int ecp_mod_koblitz( mbedtls_mpi *N, mbedtls_mpi_uint *Rp, size_t p_limbs, + size_t adjust, size_t shift, mbedtls_mpi_uint mask ) +{ + int ret; + size_t i; + mbedtls_mpi M, R; + mbedtls_mpi_uint Mp[P_KOBLITZ_MAX + P_KOBLITZ_R + 1]; + + if( N->n < p_limbs ) + return( 0 ); + + /* Init R */ + R.s = 1; + R.p = Rp; + R.n = P_KOBLITZ_R; + + /* Common setup for M */ + M.s = 1; + M.p = Mp; + + /* M = A1 */ + M.n = N->n - ( p_limbs - adjust ); + if( M.n > p_limbs + adjust ) + M.n = p_limbs + adjust; + memset( Mp, 0, sizeof Mp ); + memcpy( Mp, N->p + p_limbs - adjust, M.n * sizeof( mbedtls_mpi_uint ) ); + if( shift != 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &M, shift ) ); + M.n += R.n; /* Make room for multiplication by R */ + + /* N = A0 */ + if( mask != 0 ) + N->p[p_limbs - 1] &= mask; + for( i = p_limbs; i < N->n; i++ ) + N->p[i] = 0; + + /* N = A0 + R * A1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &M, &M, &R ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( N, N, &M ) ); + + /* Second pass */ + + /* M = A1 */ + M.n = N->n - ( p_limbs - adjust ); + if( M.n > p_limbs + adjust ) + M.n = p_limbs + adjust; + memset( Mp, 0, sizeof Mp ); + memcpy( Mp, N->p + p_limbs - adjust, M.n * sizeof( mbedtls_mpi_uint ) ); + if( shift != 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &M, shift ) ); + M.n += R.n; /* Make room for multiplication by R */ + + /* N = A0 */ + if( mask != 0 ) + N->p[p_limbs - 1] &= mask; + for( i = p_limbs; i < N->n; i++ ) + N->p[i] = 0; + + /* N = A0 + R * A1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &M, &M, &R ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( N, N, &M ) ); + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED) || + MBEDTLS_ECP_DP_SECP224K1_ENABLED) || + MBEDTLS_ECP_DP_SECP256K1_ENABLED) */ + +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) +/* + * Fast quasi-reduction modulo p192k1 = 2^192 - R, + * with R = 2^32 + 2^12 + 2^8 + 2^7 + 2^6 + 2^3 + 1 = 0x0100001119 + */ +static int ecp_mod_p192k1( mbedtls_mpi *N ) +{ + static mbedtls_mpi_uint Rp[] = { + BYTES_TO_T_UINT_8( 0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; + + return( ecp_mod_koblitz( N, Rp, 192 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); +} +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) +/* + * Fast quasi-reduction modulo p224k1 = 2^224 - R, + * with R = 2^32 + 2^12 + 2^11 + 2^9 + 2^7 + 2^4 + 2 + 1 = 0x0100001A93 + */ +static int ecp_mod_p224k1( mbedtls_mpi *N ) +{ + static mbedtls_mpi_uint Rp[] = { + BYTES_TO_T_UINT_8( 0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; + +#if defined(MBEDTLS_HAVE_INT64) + return( ecp_mod_koblitz( N, Rp, 4, 1, 32, 0xFFFFFFFF ) ); +#else + return( ecp_mod_koblitz( N, Rp, 224 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); +#endif +} + +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) +/* + * Fast quasi-reduction modulo p256k1 = 2^256 - R, + * with R = 2^32 + 2^9 + 2^8 + 2^7 + 2^6 + 2^4 + 1 = 0x01000003D1 + */ +static int ecp_mod_p256k1( mbedtls_mpi *N ) +{ + static mbedtls_mpi_uint Rp[] = { + BYTES_TO_T_UINT_8( 0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; + return( ecp_mod_koblitz( N, Rp, 256 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); +} +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + +#endif /* MBEDTLS_ECP_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy.c new file mode 100644 index 0000000..d4d1b27 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy.c @@ -0,0 +1,655 @@ +/* + * Entropy accumulator implementation + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ENTROPY_C) + +#if defined(MBEDTLS_TEST_NULL_ENTROPY) +#warning "**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! " +#warning "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES " +#warning "**** THIS BUILD IS *NOT* SUITABLE FOR PRODUCTION USE " +#endif + +#include "mbedtls/entropy.h" +#include "mbedtls/entropy_poll.h" + +#include + +#if defined(MBEDTLS_FS_IO) +#include +#endif + +#if defined(MBEDTLS_ENTROPY_NV_SEED) +#include "mbedtls/platform.h" +#endif + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if defined(MBEDTLS_HAVEGE_C) +#include "mbedtls/havege.h" +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +#define ENTROPY_MAX_LOOP 256 /**< Maximum amount to loop before error */ + +void mbedtls_entropy_init( mbedtls_entropy_context *ctx ) +{ + memset( ctx, 0, sizeof(mbedtls_entropy_context) ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &ctx->mutex ); +#endif + +#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) + mbedtls_sha512_starts( &ctx->accumulator, 0 ); +#else + mbedtls_sha256_starts( &ctx->accumulator, 0 ); +#endif +#if defined(MBEDTLS_HAVEGE_C) + mbedtls_havege_init( &ctx->havege_data ); +#endif + +#if defined(MBEDTLS_TEST_NULL_ENTROPY) + mbedtls_entropy_add_source( ctx, mbedtls_null_entropy_poll, NULL, + 1, MBEDTLS_ENTROPY_SOURCE_STRONG ); +#endif + +#if !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) +#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) + mbedtls_entropy_add_source( ctx, mbedtls_platform_entropy_poll, NULL, + MBEDTLS_ENTROPY_MIN_PLATFORM, + MBEDTLS_ENTROPY_SOURCE_STRONG ); +#endif +#if defined(MBEDTLS_TIMING_C) + mbedtls_entropy_add_source( ctx, mbedtls_hardclock_poll, NULL, + MBEDTLS_ENTROPY_MIN_HARDCLOCK, + MBEDTLS_ENTROPY_SOURCE_WEAK ); +#endif +#if defined(MBEDTLS_HAVEGE_C) + mbedtls_entropy_add_source( ctx, mbedtls_havege_poll, &ctx->havege_data, + MBEDTLS_ENTROPY_MIN_HAVEGE, + MBEDTLS_ENTROPY_SOURCE_STRONG ); +#endif +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + mbedtls_entropy_add_source( ctx, mbedtls_hardware_poll, NULL, + MBEDTLS_ENTROPY_MIN_HARDWARE, + MBEDTLS_ENTROPY_SOURCE_STRONG ); +#endif +#if defined(MBEDTLS_ENTROPY_NV_SEED) + mbedtls_entropy_add_source( ctx, mbedtls_nv_seed_poll, NULL, + MBEDTLS_ENTROPY_BLOCK_SIZE, + MBEDTLS_ENTROPY_SOURCE_STRONG ); +#endif +#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */ +} + +void mbedtls_entropy_free( mbedtls_entropy_context *ctx ) +{ +#if defined(MBEDTLS_HAVEGE_C) + mbedtls_havege_free( &ctx->havege_data ); +#endif +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &ctx->mutex ); +#endif + mbedtls_zeroize( ctx, sizeof( mbedtls_entropy_context ) ); +} + +int mbedtls_entropy_add_source( mbedtls_entropy_context *ctx, + mbedtls_entropy_f_source_ptr f_source, void *p_source, + size_t threshold, int strong ) +{ + int index, ret = 0; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + index = ctx->source_count; + if( index >= MBEDTLS_ENTROPY_MAX_SOURCES ) + { + ret = MBEDTLS_ERR_ENTROPY_MAX_SOURCES; + goto exit; + } + + ctx->source[index].f_source = f_source; + ctx->source[index].p_source = p_source; + ctx->source[index].threshold = threshold; + ctx->source[index].strong = strong; + + ctx->source_count++; + +exit: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +/* + * Entropy accumulator update + */ +static int entropy_update( mbedtls_entropy_context *ctx, unsigned char source_id, + const unsigned char *data, size_t len ) +{ + unsigned char header[2]; + unsigned char tmp[MBEDTLS_ENTROPY_BLOCK_SIZE]; + size_t use_len = len; + const unsigned char *p = data; + + if( use_len > MBEDTLS_ENTROPY_BLOCK_SIZE ) + { +#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) + mbedtls_sha512( data, len, tmp, 0 ); +#else + mbedtls_sha256( data, len, tmp, 0 ); +#endif + p = tmp; + use_len = MBEDTLS_ENTROPY_BLOCK_SIZE; + } + + header[0] = source_id; + header[1] = use_len & 0xFF; + +#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) + mbedtls_sha512_update( &ctx->accumulator, header, 2 ); + mbedtls_sha512_update( &ctx->accumulator, p, use_len ); +#else + mbedtls_sha256_update( &ctx->accumulator, header, 2 ); + mbedtls_sha256_update( &ctx->accumulator, p, use_len ); +#endif + + return( 0 ); +} + +int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx, + const unsigned char *data, size_t len ) +{ + int ret; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + ret = entropy_update( ctx, MBEDTLS_ENTROPY_SOURCE_MANUAL, data, len ); + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +/* + * Run through the different sources to add entropy to our accumulator + */ +static int entropy_gather_internal( mbedtls_entropy_context *ctx ) +{ + int ret, i, have_one_strong = 0; + unsigned char buf[MBEDTLS_ENTROPY_MAX_GATHER]; + size_t olen; + + if( ctx->source_count == 0 ) + return( MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED ); + + /* + * Run through our entropy sources + */ + for( i = 0; i < ctx->source_count; i++ ) + { + if( ctx->source[i].strong == MBEDTLS_ENTROPY_SOURCE_STRONG ) + have_one_strong = 1; + + olen = 0; + if( ( ret = ctx->source[i].f_source( ctx->source[i].p_source, + buf, MBEDTLS_ENTROPY_MAX_GATHER, &olen ) ) != 0 ) + { + return( ret ); + } + + /* + * Add if we actually gathered something + */ + if( olen > 0 ) + { + entropy_update( ctx, (unsigned char) i, buf, olen ); + ctx->source[i].size += olen; + } + } + + if( have_one_strong == 0 ) + return( MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE ); + + return( 0 ); +} + +/* + * Thread-safe wrapper for entropy_gather_internal() + */ +int mbedtls_entropy_gather( mbedtls_entropy_context *ctx ) +{ + int ret; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + ret = entropy_gather_internal( ctx ); + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +int mbedtls_entropy_func( void *data, unsigned char *output, size_t len ) +{ + int ret, count = 0, i, done; + mbedtls_entropy_context *ctx = (mbedtls_entropy_context *) data; + unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; + + if( len > MBEDTLS_ENTROPY_BLOCK_SIZE ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + +#if defined(MBEDTLS_ENTROPY_NV_SEED) + /* Update the NV entropy seed before generating any entropy for outside + * use. + */ + if( ctx->initial_entropy_run == 0 ) + { + ctx->initial_entropy_run = 1; + if( ( ret = mbedtls_entropy_update_nv_seed( ctx ) ) != 0 ) + return( ret ); + } +#endif + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + /* + * Always gather extra entropy before a call + */ + do + { + if( count++ > ENTROPY_MAX_LOOP ) + { + ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; + goto exit; + } + + if( ( ret = entropy_gather_internal( ctx ) ) != 0 ) + goto exit; + + done = 1; + for( i = 0; i < ctx->source_count; i++ ) + if( ctx->source[i].size < ctx->source[i].threshold ) + done = 0; + } + while( ! done ); + + memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE ); + +#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) + mbedtls_sha512_finish( &ctx->accumulator, buf ); + + /* + * Reset accumulator and counters and recycle existing entropy + */ + memset( &ctx->accumulator, 0, sizeof( mbedtls_sha512_context ) ); + mbedtls_sha512_starts( &ctx->accumulator, 0 ); + mbedtls_sha512_update( &ctx->accumulator, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ); + + /* + * Perform second SHA-512 on entropy + */ + mbedtls_sha512( buf, MBEDTLS_ENTROPY_BLOCK_SIZE, buf, 0 ); +#else /* MBEDTLS_ENTROPY_SHA512_ACCUMULATOR */ + mbedtls_sha256_finish( &ctx->accumulator, buf ); + + /* + * Reset accumulator and counters and recycle existing entropy + */ + memset( &ctx->accumulator, 0, sizeof( mbedtls_sha256_context ) ); + mbedtls_sha256_starts( &ctx->accumulator, 0 ); + mbedtls_sha256_update( &ctx->accumulator, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ); + + /* + * Perform second SHA-256 on entropy + */ + mbedtls_sha256( buf, MBEDTLS_ENTROPY_BLOCK_SIZE, buf, 0 ); +#endif /* MBEDTLS_ENTROPY_SHA512_ACCUMULATOR */ + + for( i = 0; i < ctx->source_count; i++ ) + ctx->source[i].size = 0; + + memcpy( output, buf, len ); + + ret = 0; + +exit: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +#if defined(MBEDTLS_ENTROPY_NV_SEED) +int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx ) +{ + int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; + unsigned char buf[ MBEDTLS_ENTROPY_MAX_SEED_SIZE ]; + + /* Read new seed and write it to NV */ + if( ( ret = mbedtls_entropy_func( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 ) + return( ret ); + + if( mbedtls_nv_seed_write( buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) < 0 ) + return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR ); + + /* Manually update the remaining stream with a separator value to diverge */ + memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE ); + mbedtls_entropy_update_manual( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ); + + return( 0 ); +} +#endif /* MBEDTLS_ENTROPY_NV_SEED */ + +#if defined(MBEDTLS_FS_IO) +int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *path ) +{ + int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; + FILE *f; + unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; + + if( ( f = fopen( path, "wb" ) ) == NULL ) + return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR ); + + if( ( ret = mbedtls_entropy_func( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 ) + goto exit; + + if( fwrite( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) != MBEDTLS_ENTROPY_BLOCK_SIZE ) + { + ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; + goto exit; + } + + ret = 0; + +exit: + fclose( f ); + return( ret ); +} + +int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *path ) +{ + FILE *f; + size_t n; + unsigned char buf[ MBEDTLS_ENTROPY_MAX_SEED_SIZE ]; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR ); + + fseek( f, 0, SEEK_END ); + n = (size_t) ftell( f ); + fseek( f, 0, SEEK_SET ); + + if( n > MBEDTLS_ENTROPY_MAX_SEED_SIZE ) + n = MBEDTLS_ENTROPY_MAX_SEED_SIZE; + + if( fread( buf, 1, n, f ) != n ) + { + fclose( f ); + return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR ); + } + + fclose( f ); + + mbedtls_entropy_update_manual( ctx, buf, n ); + + return( mbedtls_entropy_write_seed_file( ctx, path ) ); +} +#endif /* MBEDTLS_FS_IO */ + +#if defined(MBEDTLS_SELF_TEST) +#if !defined(MBEDTLS_TEST_NULL_ENTROPY) +/* + * Dummy source function + */ +static int entropy_dummy_source( void *data, unsigned char *output, + size_t len, size_t *olen ) +{ + ((void) data); + + memset( output, 0x2a, len ); + *olen = len; + + return( 0 ); +} +#endif /* !MBEDTLS_TEST_NULL_ENTROPY */ + +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + +static int mbedtls_entropy_source_self_test_gather( unsigned char *buf, size_t buf_len ) +{ + int ret = 0; + size_t entropy_len = 0; + size_t olen = 0; + size_t attempts = buf_len; + + while( attempts > 0 && entropy_len < buf_len ) + { + if( ( ret = mbedtls_hardware_poll( NULL, buf + entropy_len, + buf_len - entropy_len, &olen ) ) != 0 ) + return( ret ); + + entropy_len += olen; + attempts--; + } + + if( entropy_len < buf_len ) + { + ret = 1; + } + + return( ret ); +} + + +static int mbedtls_entropy_source_self_test_check_bits( const unsigned char *buf, + size_t buf_len ) +{ + unsigned char set= 0xFF; + unsigned char unset = 0x00; + size_t i; + + for( i = 0; i < buf_len; i++ ) + { + set &= buf[i]; + unset |= buf[i]; + } + + return( set == 0xFF || unset == 0x00 ); +} + +/* + * A test to ensure hat the entropy sources are functioning correctly + * and there is no obvious failure. The test performs the following checks: + * - The entropy source is not providing only 0s (all bits unset) or 1s (all + * bits set). + * - The entropy source is not providing values in a pattern. Because the + * hardware could be providing data in an arbitrary length, this check polls + * the hardware entropy source twice and compares the result to ensure they + * are not equal. + * - The error code returned by the entropy source is not an error. + */ +int mbedtls_entropy_source_self_test( int verbose ) +{ + int ret = 0; + unsigned char buf0[2 * sizeof( unsigned long long int )]; + unsigned char buf1[2 * sizeof( unsigned long long int )]; + + if( verbose != 0 ) + mbedtls_printf( " ENTROPY_BIAS test: " ); + + memset( buf0, 0x00, sizeof( buf0 ) ); + memset( buf1, 0x00, sizeof( buf1 ) ); + + if( ( ret = mbedtls_entropy_source_self_test_gather( buf0, sizeof( buf0 ) ) ) != 0 ) + goto cleanup; + if( ( ret = mbedtls_entropy_source_self_test_gather( buf1, sizeof( buf1 ) ) ) != 0 ) + goto cleanup; + + /* Make sure that the returned values are not all 0 or 1 */ + if( ( ret = mbedtls_entropy_source_self_test_check_bits( buf0, sizeof( buf0 ) ) ) != 0 ) + goto cleanup; + if( ( ret = mbedtls_entropy_source_self_test_check_bits( buf1, sizeof( buf1 ) ) ) != 0 ) + goto cleanup; + + /* Make sure that the entropy source is not returning values in a + * pattern */ + ret = memcmp( buf0, buf1, sizeof( buf0 ) ) == 0; + +cleanup: + if( verbose != 0 ) + { + if( ret != 0 ) + mbedtls_printf( "failed\n" ); + else + mbedtls_printf( "passed\n" ); + + mbedtls_printf( "\n" ); + } + + return( ret != 0 ); +} + +#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ + +/* + * The actual entropy quality is hard to test, but we can at least + * test that the functions don't cause errors and write the correct + * amount of data to buffers. + */ +int mbedtls_entropy_self_test( int verbose ) +{ + int ret = 1; +#if !defined(MBEDTLS_TEST_NULL_ENTROPY) + mbedtls_entropy_context ctx; + unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 }; + unsigned char acc[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 }; + size_t i, j; +#endif /* !MBEDTLS_TEST_NULL_ENTROPY */ + + if( verbose != 0 ) + mbedtls_printf( " ENTROPY test: " ); + +#if !defined(MBEDTLS_TEST_NULL_ENTROPY) + mbedtls_entropy_init( &ctx ); + + /* First do a gather to make sure we have default sources */ + if( ( ret = mbedtls_entropy_gather( &ctx ) ) != 0 ) + goto cleanup; + + ret = mbedtls_entropy_add_source( &ctx, entropy_dummy_source, NULL, 16, + MBEDTLS_ENTROPY_SOURCE_WEAK ); + if( ret != 0 ) + goto cleanup; + + if( ( ret = mbedtls_entropy_update_manual( &ctx, buf, sizeof buf ) ) != 0 ) + goto cleanup; + + /* + * To test that mbedtls_entropy_func writes correct number of bytes: + * - use the whole buffer and rely on ASan to detect overruns + * - collect entropy 8 times and OR the result in an accumulator: + * any byte should then be 0 with probably 2^(-64), so requiring + * each of the 32 or 64 bytes to be non-zero has a false failure rate + * of at most 2^(-58) which is acceptable. + */ + for( i = 0; i < 8; i++ ) + { + if( ( ret = mbedtls_entropy_func( &ctx, buf, sizeof( buf ) ) ) != 0 ) + goto cleanup; + + for( j = 0; j < sizeof( buf ); j++ ) + acc[j] |= buf[j]; + } + + for( j = 0; j < sizeof( buf ); j++ ) + { + if( acc[j] == 0 ) + { + ret = 1; + goto cleanup; + } + } + +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + if( ( ret = mbedtls_entropy_source_self_test( 0 ) ) != 0 ) + goto cleanup; +#endif + +cleanup: + mbedtls_entropy_free( &ctx ); +#endif /* !MBEDTLS_TEST_NULL_ENTROPY */ + + if( verbose != 0 ) + { + if( ret != 0 ) + mbedtls_printf( "failed\n" ); + else + mbedtls_printf( "passed\n" ); + + mbedtls_printf( "\n" ); + } + + return( ret != 0 ); +} +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_ENTROPY_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy_poll.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy_poll.c new file mode 100644 index 0000000..a116e60 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/entropy_poll.c @@ -0,0 +1,268 @@ +/* + * Platform-specific and custom entropy polling functions + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ENTROPY_C) + +#include "mbedtls/entropy.h" +#include "mbedtls/entropy_poll.h" + +#if defined(MBEDTLS_TIMING_C) +#include +#include "mbedtls/timing.h" +#endif +#if defined(MBEDTLS_HAVEGE_C) +#include "mbedtls/havege.h" +#endif +#if defined(MBEDTLS_ENTROPY_NV_SEED) +#include "mbedtls/platform.h" +#endif + +#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) + +#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ + !defined(__APPLE__) && !defined(_WIN32) +#error "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h" +#endif + +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) + +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x0400 +#endif +#include +#include + +int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len, + size_t *olen ) +{ + HCRYPTPROV provider; + ((void) data); + *olen = 0; + + if( CryptAcquireContext( &provider, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) == FALSE ) + { + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + } + + if( CryptGenRandom( provider, (DWORD) len, output ) == FALSE ) + { + CryptReleaseContext( provider, 0 ); + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + } + + CryptReleaseContext( provider, 0 ); + *olen = len; + + return( 0 ); +} +#else /* _WIN32 && !EFIX64 && !EFI32 */ + +/* + * Test for Linux getrandom() support. + * Since there is no wrapper in the libc yet, use the generic syscall wrapper + * available in GNU libc and compatible libc's (eg uClibc). + */ +#if defined(__linux__) && defined(__GLIBC__) +#include +#include +#if defined(SYS_getrandom) +#define HAVE_GETRANDOM + +static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags ) +{ + /* MemSan cannot understand that the syscall writes to the buffer */ +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + memset( buf, 0, buflen ); +#endif +#endif + + return( syscall( SYS_getrandom, buf, buflen, flags ) ); +} + +#include +/* Check if version is at least 3.17.0 */ +static int check_version_3_17_plus( void ) +{ + int minor; + struct utsname un; + const char *ver; + + /* Get version information */ + uname(&un); + ver = un.release; + + /* Check major version; assume a single digit */ + if( ver[0] < '3' || ver[0] > '9' || ver [1] != '.' ) + return( -1 ); + + if( ver[0] - '0' > 3 ) + return( 0 ); + + /* Ok, so now we know major == 3, check minor. + * Assume 1 or 2 digits. */ + if( ver[2] < '0' || ver[2] > '9' ) + return( -1 ); + + minor = ver[2] - '0'; + + if( ver[3] >= '0' && ver[3] <= '9' ) + minor = 10 * minor + ver[3] - '0'; + else if( ver [3] != '.' ) + return( -1 ); + + if( minor < 17 ) + return( -1 ); + + return( 0 ); +} +static int has_getrandom = -1; +#endif /* SYS_getrandom */ +#endif /* __linux__ */ + +#include + +int mbedtls_platform_entropy_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) +{ + FILE *file; + size_t read_len; + ((void) data); + +#if defined(HAVE_GETRANDOM) + if( has_getrandom == -1 ) + has_getrandom = ( check_version_3_17_plus() == 0 ); + + if( has_getrandom ) + { + int ret; + + if( ( ret = getrandom_wrapper( output, len, 0 ) ) < 0 ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + + *olen = ret; + return( 0 ); + } +#endif /* HAVE_GETRANDOM */ + + *olen = 0; + + file = fopen( "/dev/urandom", "rb" ); + if( file == NULL ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + + read_len = fread( output, 1, len, file ); + if( read_len != len ) + { + fclose( file ); + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + } + + fclose( file ); + *olen = len; + + return( 0 ); +} +#endif /* _WIN32 && !EFIX64 && !EFI32 */ +#endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */ + +#if defined(MBEDTLS_TEST_NULL_ENTROPY) +int mbedtls_null_entropy_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) +{ + ((void) data); + ((void) output); + *olen = 0; + + if( len < sizeof(unsigned char) ) + return( 0 ); + + *olen = sizeof(unsigned char); + + return( 0 ); +} +#endif + +#if defined(MBEDTLS_TIMING_C) +int mbedtls_hardclock_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) +{ + unsigned long timer = mbedtls_timing_hardclock(); + ((void) data); + *olen = 0; + + if( len < sizeof(unsigned long) ) + return( 0 ); + + memcpy( output, &timer, sizeof(unsigned long) ); + *olen = sizeof(unsigned long); + + return( 0 ); +} +#endif /* MBEDTLS_TIMING_C */ + +#if defined(MBEDTLS_HAVEGE_C) +int mbedtls_havege_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) +{ + mbedtls_havege_state *hs = (mbedtls_havege_state *) data; + *olen = 0; + + if( mbedtls_havege_random( hs, output, len ) != 0 ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + + *olen = len; + + return( 0 ); +} +#endif /* MBEDTLS_HAVEGE_C */ + +#if defined(MBEDTLS_ENTROPY_NV_SEED) +int mbedtls_nv_seed_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) +{ + unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; + size_t use_len = MBEDTLS_ENTROPY_BLOCK_SIZE; + ((void) data); + + memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE ); + + if( mbedtls_nv_seed_read( buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) < 0 ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + + if( len < use_len ) + use_len = len; + + memcpy( output, buf, use_len ); + *olen = use_len; + + return( 0 ); +} +#endif /* MBEDTLS_ENTROPY_NV_SEED */ + +#endif /* MBEDTLS_ENTROPY_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/error.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/error.c new file mode 100644 index 0000000..dd2db0c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/error.c @@ -0,0 +1,707 @@ +/* + * Error message information + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) +#include "mbedtls/error.h" +#include +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#define mbedtls_snprintf snprintf +#define mbedtls_time_t time_t +#endif + +#if defined(MBEDTLS_ERROR_C) + +#include + +#if defined(MBEDTLS_AES_C) +#include "mbedtls/aes.h" +#endif + +#if defined(MBEDTLS_BASE64_C) +#include "mbedtls/base64.h" +#endif + +#if defined(MBEDTLS_BIGNUM_C) +#include "mbedtls/bignum.h" +#endif + +#if defined(MBEDTLS_BLOWFISH_C) +#include "mbedtls/blowfish.h" +#endif + +#if defined(MBEDTLS_CAMELLIA_C) +#include "mbedtls/camellia.h" +#endif + +#if defined(MBEDTLS_CCM_C) +#include "mbedtls/ccm.h" +#endif + +#if defined(MBEDTLS_CIPHER_C) +#include "mbedtls/cipher.h" +#endif + +#if defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/ctr_drbg.h" +#endif + +#if defined(MBEDTLS_DES_C) +#include "mbedtls/des.h" +#endif + +#if defined(MBEDTLS_DHM_C) +#include "mbedtls/dhm.h" +#endif + +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif + +#if defined(MBEDTLS_ENTROPY_C) +#include "mbedtls/entropy.h" +#endif + +#if defined(MBEDTLS_GCM_C) +#include "mbedtls/gcm.h" +#endif + +#if defined(MBEDTLS_HMAC_DRBG_C) +#include "mbedtls/hmac_drbg.h" +#endif + +#if defined(MBEDTLS_MD_C) +#include "mbedtls/md.h" +#endif + +#if defined(MBEDTLS_NET_C) +#include "mbedtls/net_sockets.h" +#endif + +#if defined(MBEDTLS_OID_C) +#include "mbedtls/oid.h" +#endif + +#if defined(MBEDTLS_PADLOCK_C) +#include "mbedtls/padlock.h" +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_PK_C) +#include "mbedtls/pk.h" +#endif + +#if defined(MBEDTLS_PKCS12_C) +#include "mbedtls/pkcs12.h" +#endif + +#if defined(MBEDTLS_PKCS5_C) +#include "mbedtls/pkcs5.h" +#endif + +#if defined(MBEDTLS_RSA_C) +#include "mbedtls/rsa.h" +#endif + +#if defined(MBEDTLS_SSL_TLS_C) +#include "mbedtls/ssl.h" +#endif + +#if defined(MBEDTLS_THREADING_C) +#include "mbedtls/threading.h" +#endif + +#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) +#include "mbedtls/x509.h" +#endif + +#if defined(MBEDTLS_XTEA_C) +#include "mbedtls/xtea.h" +#endif + + +void mbedtls_strerror( int ret, char *buf, size_t buflen ) +{ + size_t len; + int use_ret; + + if( buflen == 0 ) + return; + + memset( buf, 0x00, buflen ); + + if( ret < 0 ) + ret = -ret; + + if( ret & 0xFF80 ) + { + use_ret = ret & 0xFF80; + + // High level error codes + // + // BEGIN generated code +#if defined(MBEDTLS_CIPHER_C) + if( use_ret == -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); + if( use_ret == -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); + if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_PADDING) ) + mbedtls_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); + if( use_ret == -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) + mbedtls_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); + if( use_ret == -(MBEDTLS_ERR_CIPHER_AUTH_FAILED) ) + mbedtls_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" ); + if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT) ) + mbedtls_snprintf( buf, buflen, "CIPHER - The context is invalid, eg because it was free()ed" ); +#endif /* MBEDTLS_CIPHER_C */ + +#if defined(MBEDTLS_DHM_C) + if( use_ret == -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED) ) + mbedtls_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); + if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED) ) + mbedtls_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); + if( use_ret == -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED) ) + mbedtls_snprintf( buf, buflen, "DHM - Reading of the public values failed" ); + if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED) ) + mbedtls_snprintf( buf, buflen, "DHM - Making of the public value failed" ); + if( use_ret == -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED) ) + mbedtls_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); + if( use_ret == -(MBEDTLS_ERR_DHM_INVALID_FORMAT) ) + mbedtls_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" ); + if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" ); + if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "DHM - Read/write of file failed" ); +#endif /* MBEDTLS_DHM_C */ + +#if defined(MBEDTLS_ECP_C) + if( use_ret == -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "ECP - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); + if( use_ret == -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "ECP - Requested curve not available" ); + if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) ) + mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" ); + if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" ); + if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) ) + mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" ); + if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) ) + mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" ); + if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" ); +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_MD_C) + if( use_ret == -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "MD - The selected feature is not available" ); + if( use_ret == -(MBEDTLS_ERR_MD_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "MD - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_MD_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "MD - Failed to allocate memory" ); + if( use_ret == -(MBEDTLS_ERR_MD_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "MD - Opening or reading of file failed" ); +#endif /* MBEDTLS_MD_C */ + +#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) + if( use_ret == -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) ) + mbedtls_snprintf( buf, buflen, "PEM - No PEM header or footer found" ); + if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_DATA) ) + mbedtls_snprintf( buf, buflen, "PEM - PEM string is not as expected" ); + if( use_ret == -(MBEDTLS_ERR_PEM_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "PEM - Failed to allocate memory" ); + if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_ENC_IV) ) + mbedtls_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); + if( use_ret == -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG) ) + mbedtls_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); + if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED) ) + mbedtls_snprintf( buf, buflen, "PEM - Private key password can't be empty" ); + if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); + if( use_ret == -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); + if( use_ret == -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "PEM - Bad input parameters to function" ); +#endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */ + +#if defined(MBEDTLS_PK_C) + if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "PK - Memory allocation failed" ); + if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" ); + if( use_ret == -(MBEDTLS_ERR_PK_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "PK - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_PK_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "PK - Read/write of file failed" ); + if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION) ) + mbedtls_snprintf( buf, buflen, "PK - Unsupported key version" ); + if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT) ) + mbedtls_snprintf( buf, buflen, "PK - Invalid key tag or value" ); + if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG) ) + mbedtls_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" ); + if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED) ) + mbedtls_snprintf( buf, buflen, "PK - Private key password can't be empty" ); + if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" ); + if( use_ret == -(MBEDTLS_ERR_PK_INVALID_PUBKEY) ) + mbedtls_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" ); + if( use_ret == -(MBEDTLS_ERR_PK_INVALID_ALG) ) + mbedtls_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" ); + if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE) ) + mbedtls_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" ); + if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" ); + if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" ); +#endif /* MBEDTLS_PK_C */ + +#if defined(MBEDTLS_PKCS12_C) + if( use_ret == -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" ); + if( use_ret == -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT) ) + mbedtls_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" ); + if( use_ret == -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" ); +#endif /* MBEDTLS_PKCS12_C */ + +#if defined(MBEDTLS_PKCS5_C) + if( use_ret == -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT) ) + mbedtls_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" ); + if( use_ret == -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" ); + if( use_ret == -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" ); +#endif /* MBEDTLS_PKCS5_C */ + +#if defined(MBEDTLS_RSA_C) + if( use_ret == -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "RSA - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_RSA_INVALID_PADDING) ) + mbedtls_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); + if( use_ret == -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED) ) + mbedtls_snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); + if( use_ret == -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED) ) + mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the library's validity check" ); + if( use_ret == -(MBEDTLS_ERR_RSA_PUBLIC_FAILED) ) + mbedtls_snprintf( buf, buflen, "RSA - The public key operation failed" ); + if( use_ret == -(MBEDTLS_ERR_RSA_PRIVATE_FAILED) ) + mbedtls_snprintf( buf, buflen, "RSA - The private key operation failed" ); + if( use_ret == -(MBEDTLS_ERR_RSA_VERIFY_FAILED) ) + mbedtls_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); + if( use_ret == -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE) ) + mbedtls_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); + if( use_ret == -(MBEDTLS_ERR_RSA_RNG_FAILED) ) + mbedtls_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_SSL_TLS_C) + if( use_ret == -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "SSL - The requested feature is not available" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "SSL - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_MAC) ) + mbedtls_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_RECORD) ) + mbedtls_snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CONN_EOF) ) + mbedtls_snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); + if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_CIPHER) ) + mbedtls_snprintf( buf, buflen, "SSL - An unknown cipher was received" ); + if( use_ret == -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN) ) + mbedtls_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); + if( use_ret == -(MBEDTLS_ERR_SSL_NO_RNG) ) + mbedtls_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" ); + if( use_ret == -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE) ) + mbedtls_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE) ) + mbedtls_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED) ) + mbedtls_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); + if( use_ret == -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED) ) + mbedtls_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED) ) + mbedtls_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); + if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE) ) + mbedtls_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); + if( use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) ) + { + mbedtls_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); + return; + } + if( use_ret == -(MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED) ) + mbedtls_snprintf( buf, buflen, "SSL - Verification of our peer failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) ) + mbedtls_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "SSL - Memory allocation failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED) ) + mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); + if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) + mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); + if( use_ret == -(MBEDTLS_ERR_SSL_COMPRESSION_FAILED) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) + mbedtls_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) ) + mbedtls_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" ); + if( use_ret == -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED) ) + mbedtls_snprintf( buf, buflen, "SSL - Session ticket has expired" ); + if( use_ret == -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" ); + if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY) ) + mbedtls_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" ); + if( use_ret == -(MBEDTLS_ERR_SSL_INTERNAL_ERROR) ) + mbedtls_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" ); + if( use_ret == -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING) ) + mbedtls_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" ); + if( use_ret == -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) ) + mbedtls_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" ); + if( use_ret == -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) ) + mbedtls_snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" ); + if( use_ret == -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" ); + if( use_ret == -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) ) + mbedtls_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" ); + if( use_ret == -(MBEDTLS_ERR_SSL_WANT_READ) ) + mbedtls_snprintf( buf, buflen, "SSL - Connection requires a read call" ); + if( use_ret == -(MBEDTLS_ERR_SSL_WANT_WRITE) ) + mbedtls_snprintf( buf, buflen, "SSL - Connection requires a write call" ); + if( use_ret == -(MBEDTLS_ERR_SSL_TIMEOUT) ) + mbedtls_snprintf( buf, buflen, "SSL - The operation timed out" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT) ) + mbedtls_snprintf( buf, buflen, "SSL - The client initiated a reconnect from the same port" ); + if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD) ) + mbedtls_snprintf( buf, buflen, "SSL - Record header looks valid but is not expected" ); + if( use_ret == -(MBEDTLS_ERR_SSL_NON_FATAL) ) + mbedtls_snprintf( buf, buflen, "SSL - The alert message received indicates a non-fatal error" ); + if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH) ) + mbedtls_snprintf( buf, buflen, "SSL - Couldn't set the hash for verifying CertificateVerify" ); +#endif /* MBEDTLS_SSL_TLS_C */ + +#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) + if( use_ret == -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); + if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_OID) ) + mbedtls_snprintf( buf, buflen, "X509 - Requested OID is unknown" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_FORMAT) ) + mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_VERSION) ) + mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SERIAL) ) + mbedtls_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_ALG) ) + mbedtls_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_NAME) ) + mbedtls_snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_DATE) ) + mbedtls_snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SIGNATURE) ) + mbedtls_snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS) ) + mbedtls_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_VERSION) ) + mbedtls_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" ); + if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG) ) + mbedtls_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); + if( use_ret == -(MBEDTLS_ERR_X509_SIG_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" ); + if( use_ret == -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) ) + mbedtls_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); + if( use_ret == -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT) ) + mbedtls_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); + if( use_ret == -(MBEDTLS_ERR_X509_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "X509 - Input invalid" ); + if( use_ret == -(MBEDTLS_ERR_X509_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "X509 - Allocation of memory failed" ); + if( use_ret == -(MBEDTLS_ERR_X509_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" ); + if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" ); +#endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */ + // END generated code + + if( strlen( buf ) == 0 ) + mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); + } + + use_ret = ret & ~0xFF80; + + if( use_ret == 0 ) + return; + + // If high level code is present, make a concatenation between both + // error strings. + // + len = strlen( buf ); + + if( len > 0 ) + { + if( buflen - len < 5 ) + return; + + mbedtls_snprintf( buf + len, buflen - len, " : " ); + + buf += len + 3; + buflen -= len + 3; + } + + // Low level error codes + // + // BEGIN generated code +#if defined(MBEDTLS_AES_C) + if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) ) + mbedtls_snprintf( buf, buflen, "AES - Invalid key length" ); + if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) ) + mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" ); +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_ASN1_PARSE_C) + if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) ) + mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); + if( use_ret == -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) ) + mbedtls_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); + if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_LENGTH) ) + mbedtls_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); + if( use_ret == -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) ) + mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); + if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) ) + mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); + if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); + if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" ); +#endif /* MBEDTLS_ASN1_PARSE_C */ + +#if defined(MBEDTLS_BASE64_C) + if( use_ret == -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "BASE64 - Output buffer too small" ); + if( use_ret == -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER) ) + mbedtls_snprintf( buf, buflen, "BASE64 - Invalid character in input" ); +#endif /* MBEDTLS_BASE64_C */ + +#if defined(MBEDTLS_BIGNUM_C) + if( use_ret == -(MBEDTLS_ERR_MPI_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); + if( use_ret == -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_MPI_INVALID_CHARACTER) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); + if( use_ret == -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); + if( use_ret == -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); + if( use_ret == -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); + if( use_ret == -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); + if( use_ret == -(MBEDTLS_ERR_MPI_ALLOC_FAILED) ) + mbedtls_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); +#endif /* MBEDTLS_BIGNUM_C */ + +#if defined(MBEDTLS_BLOWFISH_C) + if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) + mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); + if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) + mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); +#endif /* MBEDTLS_BLOWFISH_C */ + +#if defined(MBEDTLS_CAMELLIA_C) + if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) + mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); + if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) + mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_CCM_C) + if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) ) + mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_CCM_AUTH_FAILED) ) + mbedtls_snprintf( buf, buflen, "CCM - Authenticated decryption failed" ); +#endif /* MBEDTLS_CCM_C */ + +#if defined(MBEDTLS_CTR_DRBG_C) + if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) + mbedtls_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); + if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) + mbedtls_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); + if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG) ) + mbedtls_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); + if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); +#endif /* MBEDTLS_CTR_DRBG_C */ + +#if defined(MBEDTLS_DES_C) + if( use_ret == -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH) ) + mbedtls_snprintf( buf, buflen, "DES - The data input has an invalid length" ); +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ENTROPY_C) + if( use_ret == -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED) ) + mbedtls_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); + if( use_ret == -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES) ) + mbedtls_snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); + if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED) ) + mbedtls_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); + if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE) ) + mbedtls_snprintf( buf, buflen, "ENTROPY - No strong sources have been added to poll" ); + if( use_ret == -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "ENTROPY - Read/write error in file" ); +#endif /* MBEDTLS_ENTROPY_C */ + +#if defined(MBEDTLS_GCM_C) + if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) ) + mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); + if( use_ret == -(MBEDTLS_ERR_GCM_BAD_INPUT) ) + mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" ); +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_HMAC_DRBG_C) + if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) + mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); + if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG) ) + mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" ); + if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR) ) + mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" ); + if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) ) + mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" ); +#endif /* MBEDTLS_HMAC_DRBG_C */ + +#if defined(MBEDTLS_NET_C) + if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" ); + if( use_ret == -(MBEDTLS_ERR_NET_CONNECT_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); + if( use_ret == -(MBEDTLS_ERR_NET_BIND_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Binding of the socket failed" ); + if( use_ret == -(MBEDTLS_ERR_NET_LISTEN_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Could not listen on the socket" ); + if( use_ret == -(MBEDTLS_ERR_NET_ACCEPT_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); + if( use_ret == -(MBEDTLS_ERR_NET_RECV_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Reading information from the socket failed" ); + if( use_ret == -(MBEDTLS_ERR_NET_SEND_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Sending information through the socket failed" ); + if( use_ret == -(MBEDTLS_ERR_NET_CONN_RESET) ) + mbedtls_snprintf( buf, buflen, "NET - Connection was reset by peer" ); + if( use_ret == -(MBEDTLS_ERR_NET_UNKNOWN_HOST) ) + mbedtls_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); + if( use_ret == -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" ); + if( use_ret == -(MBEDTLS_ERR_NET_INVALID_CONTEXT) ) + mbedtls_snprintf( buf, buflen, "NET - The context is invalid, eg because it was free()ed" ); +#endif /* MBEDTLS_NET_C */ + +#if defined(MBEDTLS_OID_C) + if( use_ret == -(MBEDTLS_ERR_OID_NOT_FOUND) ) + mbedtls_snprintf( buf, buflen, "OID - OID is not found" ); + if( use_ret == -(MBEDTLS_ERR_OID_BUF_TOO_SMALL) ) + mbedtls_snprintf( buf, buflen, "OID - output buffer is too small" ); +#endif /* MBEDTLS_OID_C */ + +#if defined(MBEDTLS_PADLOCK_C) + if( use_ret == -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED) ) + mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); +#endif /* MBEDTLS_PADLOCK_C */ + +#if defined(MBEDTLS_THREADING_C) + if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" ); + if( use_ret == -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "THREADING - Bad input parameters to function" ); + if( use_ret == -(MBEDTLS_ERR_THREADING_MUTEX_ERROR) ) + mbedtls_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" ); +#endif /* MBEDTLS_THREADING_C */ + +#if defined(MBEDTLS_XTEA_C) + if( use_ret == -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH) ) + mbedtls_snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); +#endif /* MBEDTLS_XTEA_C */ + // END generated code + + if( strlen( buf ) != 0 ) + return; + + mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); +} + +#else /* MBEDTLS_ERROR_C */ + +#if defined(MBEDTLS_ERROR_STRERROR_DUMMY) + +/* + * Provide an non-function in case MBEDTLS_ERROR_C is not defined + */ +void mbedtls_strerror( int ret, char *buf, size_t buflen ) +{ + ((void) ret); + + if( buflen > 0 ) + buf[0] = '\0'; +} + +#endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ + +#endif /* MBEDTLS_ERROR_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/gcm.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/gcm.c new file mode 100644 index 0000000..f1210c5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/gcm.c @@ -0,0 +1,952 @@ +/* + * NIST SP800-38D compliant GCM implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf + * + * See also: + * [MGV] http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf + * + * We use the algorithm described as Shoup's method with 4-bit tables in + * [MGV] 4.1, pp. 12-13, to enhance speed without using too much memory. + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_GCM_C) + +#include "mbedtls/gcm.h" + +#include + +#if defined(MBEDTLS_AESNI_C) +#include "mbedtls/aesni.h" +#endif + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Initialize a context + */ +void mbedtls_gcm_init( mbedtls_gcm_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_gcm_context ) ); +} + +/* + * Precompute small multiples of H, that is set + * HH[i] || HL[i] = H times i, + * where i is seen as a field element as in [MGV], ie high-order bits + * correspond to low powers of P. The result is stored in the same way, that + * is the high-order bit of HH corresponds to P^0 and the low-order bit of HL + * corresponds to P^127. + */ +static int gcm_gen_table( mbedtls_gcm_context *ctx ) +{ + int ret, i, j; + uint64_t hi, lo; + uint64_t vl, vh; + unsigned char h[16]; + size_t olen = 0; + + memset( h, 0, 16 ); + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, h, 16, h, &olen ) ) != 0 ) + return( ret ); + + /* pack h as two 64-bits ints, big-endian */ + GET_UINT32_BE( hi, h, 0 ); + GET_UINT32_BE( lo, h, 4 ); + vh = (uint64_t) hi << 32 | lo; + + GET_UINT32_BE( hi, h, 8 ); + GET_UINT32_BE( lo, h, 12 ); + vl = (uint64_t) hi << 32 | lo; + + /* 8 = 1000 corresponds to 1 in GF(2^128) */ + ctx->HL[8] = vl; + ctx->HH[8] = vh; + +#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) + /* With CLMUL support, we need only h, not the rest of the table */ + if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) + return( 0 ); +#endif + + /* 0 corresponds to 0 in GF(2^128) */ + ctx->HH[0] = 0; + ctx->HL[0] = 0; + + for( i = 4; i > 0; i >>= 1 ) + { + uint32_t T = ( vl & 1 ) * 0xe1000000U; + vl = ( vh << 63 ) | ( vl >> 1 ); + vh = ( vh >> 1 ) ^ ( (uint64_t) T << 32); + + ctx->HL[i] = vl; + ctx->HH[i] = vh; + } + + for( i = 2; i <= 8; i *= 2 ) + { + uint64_t *HiL = ctx->HL + i, *HiH = ctx->HH + i; + vh = *HiH; + vl = *HiL; + for( j = 1; j < i; j++ ) + { + HiH[j] = vh ^ ctx->HH[j]; + HiL[j] = vl ^ ctx->HL[j]; + } + } + + return( 0 ); +} + +int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, + mbedtls_cipher_id_t cipher, + const unsigned char *key, + unsigned int keybits ) +{ + int ret; + const mbedtls_cipher_info_t *cipher_info; + + cipher_info = mbedtls_cipher_info_from_values( cipher, keybits, MBEDTLS_MODE_ECB ); + if( cipher_info == NULL ) + return( MBEDTLS_ERR_GCM_BAD_INPUT ); + + if( cipher_info->block_size != 16 ) + return( MBEDTLS_ERR_GCM_BAD_INPUT ); + + mbedtls_cipher_free( &ctx->cipher_ctx ); + + if( ( ret = mbedtls_cipher_setup( &ctx->cipher_ctx, cipher_info ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_cipher_setkey( &ctx->cipher_ctx, key, keybits, + MBEDTLS_ENCRYPT ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = gcm_gen_table( ctx ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +/* + * Shoup's method for multiplication use this table with + * last4[x] = x times P^128 + * where x and last4[x] are seen as elements of GF(2^128) as in [MGV] + */ +static const uint64_t last4[16] = +{ + 0x0000, 0x1c20, 0x3840, 0x2460, + 0x7080, 0x6ca0, 0x48c0, 0x54e0, + 0xe100, 0xfd20, 0xd940, 0xc560, + 0x9180, 0x8da0, 0xa9c0, 0xb5e0 +}; + +/* + * Sets output to x times H using the precomputed tables. + * x and output are seen as elements of GF(2^128) as in [MGV]. + */ +static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16], + unsigned char output[16] ) +{ + int i = 0; + unsigned char lo, hi, rem; + uint64_t zh, zl; + +#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) + if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) { + unsigned char h[16]; + + PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 ); + PUT_UINT32_BE( ctx->HH[8], h, 4 ); + PUT_UINT32_BE( ctx->HL[8] >> 32, h, 8 ); + PUT_UINT32_BE( ctx->HL[8], h, 12 ); + + mbedtls_aesni_gcm_mult( output, x, h ); + return; + } +#endif /* MBEDTLS_AESNI_C && MBEDTLS_HAVE_X86_64 */ + + lo = x[15] & 0xf; + + zh = ctx->HH[lo]; + zl = ctx->HL[lo]; + + for( i = 15; i >= 0; i-- ) + { + lo = x[i] & 0xf; + hi = x[i] >> 4; + + if( i != 15 ) + { + rem = (unsigned char) zl & 0xf; + zl = ( zh << 60 ) | ( zl >> 4 ); + zh = ( zh >> 4 ); + zh ^= (uint64_t) last4[rem] << 48; + zh ^= ctx->HH[lo]; + zl ^= ctx->HL[lo]; + + } + + rem = (unsigned char) zl & 0xf; + zl = ( zh << 60 ) | ( zl >> 4 ); + zh = ( zh >> 4 ); + zh ^= (uint64_t) last4[rem] << 48; + zh ^= ctx->HH[hi]; + zl ^= ctx->HL[hi]; + } + + PUT_UINT32_BE( zh >> 32, output, 0 ); + PUT_UINT32_BE( zh, output, 4 ); + PUT_UINT32_BE( zl >> 32, output, 8 ); + PUT_UINT32_BE( zl, output, 12 ); +} + +int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, + int mode, + const unsigned char *iv, + size_t iv_len, + const unsigned char *add, + size_t add_len ) +{ + int ret; + unsigned char work_buf[16]; + size_t i; + const unsigned char *p; + size_t use_len, olen = 0; + + /* IV and AD are limited to 2^64 bits, so 2^61 bytes */ + if( ( (uint64_t) iv_len ) >> 61 != 0 || + ( (uint64_t) add_len ) >> 61 != 0 ) + { + return( MBEDTLS_ERR_GCM_BAD_INPUT ); + } + + memset( ctx->y, 0x00, sizeof(ctx->y) ); + memset( ctx->buf, 0x00, sizeof(ctx->buf) ); + + ctx->mode = mode; + ctx->len = 0; + ctx->add_len = 0; + + if( iv_len == 12 ) + { + memcpy( ctx->y, iv, iv_len ); + ctx->y[15] = 1; + } + else + { + memset( work_buf, 0x00, 16 ); + PUT_UINT32_BE( iv_len * 8, work_buf, 12 ); + + p = iv; + while( iv_len > 0 ) + { + use_len = ( iv_len < 16 ) ? iv_len : 16; + + for( i = 0; i < use_len; i++ ) + ctx->y[i] ^= p[i]; + + gcm_mult( ctx, ctx->y, ctx->y ); + + iv_len -= use_len; + p += use_len; + } + + for( i = 0; i < 16; i++ ) + ctx->y[i] ^= work_buf[i]; + + gcm_mult( ctx, ctx->y, ctx->y ); + } + + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->base_ectr, + &olen ) ) != 0 ) + { + return( ret ); + } + + ctx->add_len = add_len; + p = add; + while( add_len > 0 ) + { + use_len = ( add_len < 16 ) ? add_len : 16; + + for( i = 0; i < use_len; i++ ) + ctx->buf[i] ^= p[i]; + + gcm_mult( ctx, ctx->buf, ctx->buf ); + + add_len -= use_len; + p += use_len; + } + + return( 0 ); +} + +int mbedtls_gcm_update( mbedtls_gcm_context *ctx, + size_t length, + const unsigned char *input, + unsigned char *output ) +{ + int ret; + unsigned char ectr[16]; + size_t i; + const unsigned char *p; + unsigned char *out_p = output; + size_t use_len, olen = 0; + + if( output > input && (size_t) ( output - input ) < length ) + return( MBEDTLS_ERR_GCM_BAD_INPUT ); + + /* Total length is restricted to 2^39 - 256 bits, ie 2^36 - 2^5 bytes + * Also check for possible overflow */ + if( ctx->len + length < ctx->len || + (uint64_t) ctx->len + length > 0xFFFFFFFE0ull ) + { + return( MBEDTLS_ERR_GCM_BAD_INPUT ); + } + + ctx->len += length; + + p = input; + while( length > 0 ) + { + use_len = ( length < 16 ) ? length : 16; + + for( i = 16; i > 12; i-- ) + if( ++ctx->y[i - 1] != 0 ) + break; + + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ectr, + &olen ) ) != 0 ) + { + return( ret ); + } + + for( i = 0; i < use_len; i++ ) + { + if( ctx->mode == MBEDTLS_GCM_DECRYPT ) + ctx->buf[i] ^= p[i]; + out_p[i] = ectr[i] ^ p[i]; + if( ctx->mode == MBEDTLS_GCM_ENCRYPT ) + ctx->buf[i] ^= out_p[i]; + } + + gcm_mult( ctx, ctx->buf, ctx->buf ); + + length -= use_len; + p += use_len; + out_p += use_len; + } + + return( 0 ); +} + +int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, + unsigned char *tag, + size_t tag_len ) +{ + unsigned char work_buf[16]; + size_t i; + uint64_t orig_len = ctx->len * 8; + uint64_t orig_add_len = ctx->add_len * 8; + + if( tag_len > 16 || tag_len < 4 ) + return( MBEDTLS_ERR_GCM_BAD_INPUT ); + + memcpy( tag, ctx->base_ectr, tag_len ); + + if( orig_len || orig_add_len ) + { + memset( work_buf, 0x00, 16 ); + + PUT_UINT32_BE( ( orig_add_len >> 32 ), work_buf, 0 ); + PUT_UINT32_BE( ( orig_add_len ), work_buf, 4 ); + PUT_UINT32_BE( ( orig_len >> 32 ), work_buf, 8 ); + PUT_UINT32_BE( ( orig_len ), work_buf, 12 ); + + for( i = 0; i < 16; i++ ) + ctx->buf[i] ^= work_buf[i]; + + gcm_mult( ctx, ctx->buf, ctx->buf ); + + for( i = 0; i < tag_len; i++ ) + tag[i] ^= ctx->buf[i]; + } + + return( 0 ); +} + +int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx, + int mode, + size_t length, + const unsigned char *iv, + size_t iv_len, + const unsigned char *add, + size_t add_len, + const unsigned char *input, + unsigned char *output, + size_t tag_len, + unsigned char *tag ) +{ + int ret; + + if( ( ret = mbedtls_gcm_starts( ctx, mode, iv, iv_len, add, add_len ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_gcm_update( ctx, length, input, output ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_gcm_finish( ctx, tag, tag_len ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, + size_t length, + const unsigned char *iv, + size_t iv_len, + const unsigned char *add, + size_t add_len, + const unsigned char *tag, + size_t tag_len, + const unsigned char *input, + unsigned char *output ) +{ + int ret; + unsigned char check_tag[16]; + size_t i; + int diff; + + if( ( ret = mbedtls_gcm_crypt_and_tag( ctx, MBEDTLS_GCM_DECRYPT, length, + iv, iv_len, add, add_len, + input, output, tag_len, check_tag ) ) != 0 ) + { + return( ret ); + } + + /* Check tag in "constant-time" */ + for( diff = 0, i = 0; i < tag_len; i++ ) + diff |= tag[i] ^ check_tag[i]; + + if( diff != 0 ) + { + mbedtls_zeroize( output, length ); + return( MBEDTLS_ERR_GCM_AUTH_FAILED ); + } + + return( 0 ); +} + +void mbedtls_gcm_free( mbedtls_gcm_context *ctx ) +{ + mbedtls_cipher_free( &ctx->cipher_ctx ); + mbedtls_zeroize( ctx, sizeof( mbedtls_gcm_context ) ); +} + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +/* + * AES-GCM test vectors from: + * + * http://csrc.nist.gov/groups/STM/cavp/documents/mac/gcmtestvectors.zip + */ +#define MAX_TESTS 6 + +static const int key_index[MAX_TESTS] = + { 0, 0, 1, 1, 1, 1 }; + +static const unsigned char key[MAX_TESTS][32] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 }, +}; + +static const size_t iv_len[MAX_TESTS] = + { 12, 12, 12, 12, 8, 60 }; + +static const int iv_index[MAX_TESTS] = + { 0, 0, 1, 1, 1, 2 }; + +static const unsigned char iv[MAX_TESTS][64] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, + { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, + 0xde, 0xca, 0xf8, 0x88 }, + { 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, + 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, + 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, + 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, + 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, + 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, + 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, + 0xa6, 0x37, 0xb3, 0x9b }, +}; + +static const size_t add_len[MAX_TESTS] = + { 0, 0, 0, 20, 20, 20 }; + +static const int add_index[MAX_TESTS] = + { 0, 0, 0, 1, 1, 1 }; + +static const unsigned char additional[MAX_TESTS][64] = +{ + { 0x00 }, + { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, + 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, + 0xab, 0xad, 0xda, 0xd2 }, +}; + +static const size_t pt_len[MAX_TESTS] = + { 0, 16, 64, 60, 60, 60 }; + +static const int pt_index[MAX_TESTS] = + { 0, 0, 1, 1, 1, 1 }; + +static const unsigned char pt[MAX_TESTS][64] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, + 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, + 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, + 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, + 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, + 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, + 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, + 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55 }, +}; + +static const unsigned char ct[MAX_TESTS * 3][64] = +{ + { 0x00 }, + { 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, + 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78 }, + { 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, + 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, + 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, + 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, + 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, + 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, + 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, + 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85 }, + { 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, + 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, + 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, + 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, + 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, + 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, + 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, + 0x3d, 0x58, 0xe0, 0x91 }, + { 0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a, + 0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55, + 0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8, + 0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23, + 0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2, + 0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42, + 0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07, + 0xc2, 0x3f, 0x45, 0x98 }, + { 0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6, + 0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94, + 0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8, + 0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7, + 0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90, + 0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f, + 0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03, + 0x4c, 0x34, 0xae, 0xe5 }, + { 0x00 }, + { 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, + 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00 }, + { 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, + 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, + 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, + 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, + 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, + 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, + 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, + 0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56 }, + { 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, + 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, + 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, + 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, + 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, + 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, + 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, + 0xcc, 0xda, 0x27, 0x10 }, + { 0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54, + 0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8, + 0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f, + 0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57, + 0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75, + 0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9, + 0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f, + 0xa0, 0xf0, 0x62, 0xf7 }, + { 0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c, + 0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff, + 0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef, + 0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45, + 0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9, + 0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3, + 0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7, + 0xe9, 0xb7, 0x37, 0x3b }, + { 0x00 }, + { 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e, + 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18 }, + { 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, + 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, + 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, + 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, + 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, + 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, + 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, + 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad }, + { 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, + 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, + 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, + 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, + 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, + 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, + 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, + 0xbc, 0xc9, 0xf6, 0x62 }, + { 0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32, + 0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb, + 0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa, + 0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0, + 0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0, + 0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78, + 0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99, + 0xf4, 0x7c, 0x9b, 0x1f }, + { 0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1, + 0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20, + 0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19, + 0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4, + 0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45, + 0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde, + 0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e, + 0x44, 0xae, 0x7e, 0x3f }, +}; + +static const unsigned char tag[MAX_TESTS * 3][16] = +{ + { 0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61, + 0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a }, + { 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, + 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf }, + { 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6, + 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4 }, + { 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb, + 0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47 }, + { 0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85, + 0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb }, + { 0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa, + 0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50 }, + { 0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b, + 0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35 }, + { 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab, + 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb }, + { 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf, + 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14 }, + { 0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f, + 0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c }, + { 0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24, + 0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8 }, + { 0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb, + 0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9 }, + { 0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9, + 0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b }, + { 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0, + 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19 }, + { 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd, + 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c }, + { 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68, + 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b }, + { 0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4, + 0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2 }, + { 0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0, + 0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a }, +}; + +int mbedtls_gcm_self_test( int verbose ) +{ + mbedtls_gcm_context ctx; + unsigned char buf[64]; + unsigned char tag_buf[16]; + int i, j, ret; + mbedtls_cipher_id_t cipher = MBEDTLS_CIPHER_ID_AES; + + mbedtls_gcm_init( &ctx ); + + for( j = 0; j < 3; j++ ) + { + int key_len = 128 + 64 * j; + + for( i = 0; i < MAX_TESTS; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " AES-GCM-%3d #%d (%s): ", + key_len, i, "enc" ); + + mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len ); + + ret = mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT, + pt_len[i], + iv[iv_index[i]], iv_len[i], + additional[add_index[i]], add_len[i], + pt[pt_index[i]], buf, 16, tag_buf ); + + if( ret != 0 || + memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 || + memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + mbedtls_gcm_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " AES-GCM-%3d #%d (%s): ", + key_len, i, "dec" ); + + mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len ); + + ret = mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_DECRYPT, + pt_len[i], + iv[iv_index[i]], iv_len[i], + additional[add_index[i]], add_len[i], + ct[j * 6 + i], buf, 16, tag_buf ); + + if( ret != 0 || + memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 || + memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + mbedtls_gcm_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " AES-GCM-%3d #%d split (%s): ", + key_len, i, "enc" ); + + mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len ); + + ret = mbedtls_gcm_starts( &ctx, MBEDTLS_GCM_ENCRYPT, + iv[iv_index[i]], iv_len[i], + additional[add_index[i]], add_len[i] ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( pt_len[i] > 32 ) + { + size_t rest_len = pt_len[i] - 32; + ret = mbedtls_gcm_update( &ctx, 32, pt[pt_index[i]], buf ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + ret = mbedtls_gcm_update( &ctx, rest_len, pt[pt_index[i]] + 32, + buf + 32 ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + else + { + ret = mbedtls_gcm_update( &ctx, pt_len[i], pt[pt_index[i]], buf ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + + ret = mbedtls_gcm_finish( &ctx, tag_buf, 16 ); + if( ret != 0 || + memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 || + memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + mbedtls_gcm_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " AES-GCM-%3d #%d split (%s): ", + key_len, i, "dec" ); + + mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len ); + + ret = mbedtls_gcm_starts( &ctx, MBEDTLS_GCM_DECRYPT, + iv[iv_index[i]], iv_len[i], + additional[add_index[i]], add_len[i] ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( pt_len[i] > 32 ) + { + size_t rest_len = pt_len[i] - 32; + ret = mbedtls_gcm_update( &ctx, 32, ct[j * 6 + i], buf ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + ret = mbedtls_gcm_update( &ctx, rest_len, ct[j * 6 + i] + 32, + buf + 32 ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + else + { + ret = mbedtls_gcm_update( &ctx, pt_len[i], ct[j * 6 + i], buf ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + + ret = mbedtls_gcm_finish( &ctx, tag_buf, 16 ); + if( ret != 0 || + memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 || + memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + mbedtls_gcm_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + } + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +#endif /* MBEDTLS_GCM_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/havege.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/havege.c new file mode 100644 index 0000000..2b75ef7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/havege.c @@ -0,0 +1,245 @@ +/** + * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The HAVEGE RNG was designed by Andre Seznec in 2002. + * + * http://www.irisa.fr/caps/projects/hipsor/publi.php + * + * Contact: seznec(at)irisa_dot_fr - orocheco(at)irisa_dot_fr + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_HAVEGE_C) + +#include "mbedtls/havege.h" +#include "mbedtls/timing.h" + +#include + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* ------------------------------------------------------------------------ + * On average, one iteration accesses two 8-word blocks in the havege WALK + * table, and generates 16 words in the RES array. + * + * The data read in the WALK table is updated and permuted after each use. + * The result of the hardware clock counter read is used for this update. + * + * 25 conditional tests are present. The conditional tests are grouped in + * two nested groups of 12 conditional tests and 1 test that controls the + * permutation; on average, there should be 6 tests executed and 3 of them + * should be mispredicted. + * ------------------------------------------------------------------------ + */ + +#define SWAP(X,Y) { int *T = X; X = Y; Y = T; } + +#define TST1_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1; +#define TST2_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1; + +#define TST1_LEAVE U1++; } +#define TST2_LEAVE U2++; } + +#define ONE_ITERATION \ + \ + PTEST = PT1 >> 20; \ + \ + TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \ + TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \ + TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \ + \ + TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \ + TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \ + TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \ + \ + PTX = (PT1 >> 18) & 7; \ + PT1 &= 0x1FFF; \ + PT2 &= 0x1FFF; \ + CLK = (int) mbedtls_timing_hardclock(); \ + \ + i = 0; \ + A = &WALK[PT1 ]; RES[i++] ^= *A; \ + B = &WALK[PT2 ]; RES[i++] ^= *B; \ + C = &WALK[PT1 ^ 1]; RES[i++] ^= *C; \ + D = &WALK[PT2 ^ 4]; RES[i++] ^= *D; \ + \ + IN = (*A >> (1)) ^ (*A << (31)) ^ CLK; \ + *A = (*B >> (2)) ^ (*B << (30)) ^ CLK; \ + *B = IN ^ U1; \ + *C = (*C >> (3)) ^ (*C << (29)) ^ CLK; \ + *D = (*D >> (4)) ^ (*D << (28)) ^ CLK; \ + \ + A = &WALK[PT1 ^ 2]; RES[i++] ^= *A; \ + B = &WALK[PT2 ^ 2]; RES[i++] ^= *B; \ + C = &WALK[PT1 ^ 3]; RES[i++] ^= *C; \ + D = &WALK[PT2 ^ 6]; RES[i++] ^= *D; \ + \ + if( PTEST & 1 ) SWAP( A, C ); \ + \ + IN = (*A >> (5)) ^ (*A << (27)) ^ CLK; \ + *A = (*B >> (6)) ^ (*B << (26)) ^ CLK; \ + *B = IN; CLK = (int) mbedtls_timing_hardclock(); \ + *C = (*C >> (7)) ^ (*C << (25)) ^ CLK; \ + *D = (*D >> (8)) ^ (*D << (24)) ^ CLK; \ + \ + A = &WALK[PT1 ^ 4]; \ + B = &WALK[PT2 ^ 1]; \ + \ + PTEST = PT2 >> 1; \ + \ + PT2 = (RES[(i - 8) ^ PTY] ^ WALK[PT2 ^ PTY ^ 7]); \ + PT2 = ((PT2 & 0x1FFF) & (~8)) ^ ((PT1 ^ 8) & 0x8); \ + PTY = (PT2 >> 10) & 7; \ + \ + TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \ + TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \ + TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \ + \ + TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \ + TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \ + TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \ + \ + C = &WALK[PT1 ^ 5]; \ + D = &WALK[PT2 ^ 5]; \ + \ + RES[i++] ^= *A; \ + RES[i++] ^= *B; \ + RES[i++] ^= *C; \ + RES[i++] ^= *D; \ + \ + IN = (*A >> ( 9)) ^ (*A << (23)) ^ CLK; \ + *A = (*B >> (10)) ^ (*B << (22)) ^ CLK; \ + *B = IN ^ U2; \ + *C = (*C >> (11)) ^ (*C << (21)) ^ CLK; \ + *D = (*D >> (12)) ^ (*D << (20)) ^ CLK; \ + \ + A = &WALK[PT1 ^ 6]; RES[i++] ^= *A; \ + B = &WALK[PT2 ^ 3]; RES[i++] ^= *B; \ + C = &WALK[PT1 ^ 7]; RES[i++] ^= *C; \ + D = &WALK[PT2 ^ 7]; RES[i++] ^= *D; \ + \ + IN = (*A >> (13)) ^ (*A << (19)) ^ CLK; \ + *A = (*B >> (14)) ^ (*B << (18)) ^ CLK; \ + *B = IN; \ + *C = (*C >> (15)) ^ (*C << (17)) ^ CLK; \ + *D = (*D >> (16)) ^ (*D << (16)) ^ CLK; \ + \ + PT1 = ( RES[( i - 8 ) ^ PTX] ^ \ + WALK[PT1 ^ PTX ^ 7] ) & (~1); \ + PT1 ^= (PT2 ^ 0x10) & 0x10; \ + \ + for( n++, i = 0; i < 16; i++ ) \ + hs->pool[n % MBEDTLS_HAVEGE_COLLECT_SIZE] ^= RES[i]; + +/* + * Entropy gathering function + */ +static void havege_fill( mbedtls_havege_state *hs ) +{ + int i, n = 0; + int U1, U2, *A, *B, *C, *D; + int PT1, PT2, *WALK, RES[16]; + int PTX, PTY, CLK, PTEST, IN; + + WALK = hs->WALK; + PT1 = hs->PT1; + PT2 = hs->PT2; + + PTX = U1 = 0; + PTY = U2 = 0; + + (void)PTX; + + memset( RES, 0, sizeof( RES ) ); + + while( n < MBEDTLS_HAVEGE_COLLECT_SIZE * 4 ) + { + ONE_ITERATION + ONE_ITERATION + ONE_ITERATION + ONE_ITERATION + } + + hs->PT1 = PT1; + hs->PT2 = PT2; + + hs->offset[0] = 0; + hs->offset[1] = MBEDTLS_HAVEGE_COLLECT_SIZE / 2; +} + +/* + * HAVEGE initialization + */ +void mbedtls_havege_init( mbedtls_havege_state *hs ) +{ + memset( hs, 0, sizeof( mbedtls_havege_state ) ); + + havege_fill( hs ); +} + +void mbedtls_havege_free( mbedtls_havege_state *hs ) +{ + if( hs == NULL ) + return; + + mbedtls_zeroize( hs, sizeof( mbedtls_havege_state ) ); +} + +/* + * HAVEGE rand function + */ +int mbedtls_havege_random( void *p_rng, unsigned char *buf, size_t len ) +{ + int val; + size_t use_len; + mbedtls_havege_state *hs = (mbedtls_havege_state *) p_rng; + unsigned char *p = buf; + + while( len > 0 ) + { + use_len = len; + if( use_len > sizeof(int) ) + use_len = sizeof(int); + + if( hs->offset[1] >= MBEDTLS_HAVEGE_COLLECT_SIZE ) + havege_fill( hs ); + + val = hs->pool[hs->offset[0]++]; + val ^= hs->pool[hs->offset[1]++]; + + memcpy( p, &val, use_len ); + + len -= use_len; + p += use_len; + } + + return( 0 ); +} + +#endif /* MBEDTLS_HAVEGE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/hmac_drbg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/hmac_drbg.c new file mode 100644 index 0000000..bf5f9b5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/hmac_drbg.c @@ -0,0 +1,529 @@ +/* + * HMAC_DRBG implementation (NIST SP 800-90) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * The NIST SP 800-90A DRBGs are described in the following publication. + * http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf + * References below are based on rev. 1 (January 2012). + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_HMAC_DRBG_C) + +#include "mbedtls/hmac_drbg.h" + +#include + +#if defined(MBEDTLS_FS_IO) +#include +#endif + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_SELF_TEST */ +#endif /* MBEDTLS_PLATFORM_C */ + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * HMAC_DRBG context initialization + */ +void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_hmac_drbg_context ) ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &ctx->mutex ); +#endif +} + +/* + * HMAC_DRBG update, using optional additional data (10.1.2.2) + */ +void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx, + const unsigned char *additional, size_t add_len ) +{ + size_t md_len = mbedtls_md_get_size( ctx->md_ctx.md_info ); + unsigned char rounds = ( additional != NULL && add_len != 0 ) ? 2 : 1; + unsigned char sep[1]; + unsigned char K[MBEDTLS_MD_MAX_SIZE]; + + for( sep[0] = 0; sep[0] < rounds; sep[0]++ ) + { + /* Step 1 or 4 */ + mbedtls_md_hmac_reset( &ctx->md_ctx ); + mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len ); + mbedtls_md_hmac_update( &ctx->md_ctx, sep, 1 ); + if( rounds == 2 ) + mbedtls_md_hmac_update( &ctx->md_ctx, additional, add_len ); + mbedtls_md_hmac_finish( &ctx->md_ctx, K ); + + /* Step 2 or 5 */ + mbedtls_md_hmac_starts( &ctx->md_ctx, K, md_len ); + mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len ); + mbedtls_md_hmac_finish( &ctx->md_ctx, ctx->V ); + } +} + +/* + * Simplified HMAC_DRBG initialisation (for use with deterministic ECDSA) + */ +int mbedtls_hmac_drbg_seed_buf( mbedtls_hmac_drbg_context *ctx, + const mbedtls_md_info_t * md_info, + const unsigned char *data, size_t data_len ) +{ + int ret; + + if( ( ret = mbedtls_md_setup( &ctx->md_ctx, md_info, 1 ) ) != 0 ) + return( ret ); + + /* + * Set initial working state. + * Use the V memory location, which is currently all 0, to initialize the + * MD context with an all-zero key. Then set V to its initial value. + */ + mbedtls_md_hmac_starts( &ctx->md_ctx, ctx->V, mbedtls_md_get_size( md_info ) ); + memset( ctx->V, 0x01, mbedtls_md_get_size( md_info ) ); + + mbedtls_hmac_drbg_update( ctx, data, data_len ); + + return( 0 ); +} + +/* + * HMAC_DRBG reseeding: 10.1.2.4 (arabic) + 9.2 (Roman) + */ +int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx, + const unsigned char *additional, size_t len ) +{ + unsigned char seed[MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT]; + size_t seedlen; + + /* III. Check input length */ + if( len > MBEDTLS_HMAC_DRBG_MAX_INPUT || + ctx->entropy_len + len > MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT ) + { + return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG ); + } + + memset( seed, 0, MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT ); + + /* IV. Gather entropy_len bytes of entropy for the seed */ + if( ctx->f_entropy( ctx->p_entropy, seed, ctx->entropy_len ) != 0 ) + return( MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED ); + + seedlen = ctx->entropy_len; + + /* 1. Concatenate entropy and additional data if any */ + if( additional != NULL && len != 0 ) + { + memcpy( seed + seedlen, additional, len ); + seedlen += len; + } + + /* 2. Update state */ + mbedtls_hmac_drbg_update( ctx, seed, seedlen ); + + /* 3. Reset reseed_counter */ + ctx->reseed_counter = 1; + + /* 4. Done */ + return( 0 ); +} + +/* + * HMAC_DRBG initialisation (10.1.2.3 + 9.1) + */ +int mbedtls_hmac_drbg_seed( mbedtls_hmac_drbg_context *ctx, + const mbedtls_md_info_t * md_info, + int (*f_entropy)(void *, unsigned char *, size_t), + void *p_entropy, + const unsigned char *custom, + size_t len ) +{ + int ret; + size_t entropy_len, md_size; + + if( ( ret = mbedtls_md_setup( &ctx->md_ctx, md_info, 1 ) ) != 0 ) + return( ret ); + + md_size = mbedtls_md_get_size( md_info ); + + /* + * Set initial working state. + * Use the V memory location, which is currently all 0, to initialize the + * MD context with an all-zero key. Then set V to its initial value. + */ + mbedtls_md_hmac_starts( &ctx->md_ctx, ctx->V, md_size ); + memset( ctx->V, 0x01, md_size ); + + ctx->f_entropy = f_entropy; + ctx->p_entropy = p_entropy; + + ctx->reseed_interval = MBEDTLS_HMAC_DRBG_RESEED_INTERVAL; + + /* + * See SP800-57 5.6.1 (p. 65-66) for the security strength provided by + * each hash function, then according to SP800-90A rev1 10.1 table 2, + * min_entropy_len (in bits) is security_strength. + * + * (This also matches the sizes used in the NIST test vectors.) + */ + entropy_len = md_size <= 20 ? 16 : /* 160-bits hash -> 128 bits */ + md_size <= 28 ? 24 : /* 224-bits hash -> 192 bits */ + 32; /* better (256+) -> 256 bits */ + + /* + * For initialisation, use more entropy to emulate a nonce + * (Again, matches test vectors.) + */ + ctx->entropy_len = entropy_len * 3 / 2; + + if( ( ret = mbedtls_hmac_drbg_reseed( ctx, custom, len ) ) != 0 ) + return( ret ); + + ctx->entropy_len = entropy_len; + + return( 0 ); +} + +/* + * Set prediction resistance + */ +void mbedtls_hmac_drbg_set_prediction_resistance( mbedtls_hmac_drbg_context *ctx, + int resistance ) +{ + ctx->prediction_resistance = resistance; +} + +/* + * Set entropy length grabbed for reseeds + */ +void mbedtls_hmac_drbg_set_entropy_len( mbedtls_hmac_drbg_context *ctx, size_t len ) +{ + ctx->entropy_len = len; +} + +/* + * Set reseed interval + */ +void mbedtls_hmac_drbg_set_reseed_interval( mbedtls_hmac_drbg_context *ctx, int interval ) +{ + ctx->reseed_interval = interval; +} + +/* + * HMAC_DRBG random function with optional additional data: + * 10.1.2.5 (arabic) + 9.3 (Roman) + */ +int mbedtls_hmac_drbg_random_with_add( void *p_rng, + unsigned char *output, size_t out_len, + const unsigned char *additional, size_t add_len ) +{ + int ret; + mbedtls_hmac_drbg_context *ctx = (mbedtls_hmac_drbg_context *) p_rng; + size_t md_len = mbedtls_md_get_size( ctx->md_ctx.md_info ); + size_t left = out_len; + unsigned char *out = output; + + /* II. Check request length */ + if( out_len > MBEDTLS_HMAC_DRBG_MAX_REQUEST ) + return( MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG ); + + /* III. Check input length */ + if( add_len > MBEDTLS_HMAC_DRBG_MAX_INPUT ) + return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG ); + + /* 1. (aka VII and IX) Check reseed counter and PR */ + if( ctx->f_entropy != NULL && /* For no-reseeding instances */ + ( ctx->prediction_resistance == MBEDTLS_HMAC_DRBG_PR_ON || + ctx->reseed_counter > ctx->reseed_interval ) ) + { + if( ( ret = mbedtls_hmac_drbg_reseed( ctx, additional, add_len ) ) != 0 ) + return( ret ); + + add_len = 0; /* VII.4 */ + } + + /* 2. Use additional data if any */ + if( additional != NULL && add_len != 0 ) + mbedtls_hmac_drbg_update( ctx, additional, add_len ); + + /* 3, 4, 5. Generate bytes */ + while( left != 0 ) + { + size_t use_len = left > md_len ? md_len : left; + + mbedtls_md_hmac_reset( &ctx->md_ctx ); + mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len ); + mbedtls_md_hmac_finish( &ctx->md_ctx, ctx->V ); + + memcpy( out, ctx->V, use_len ); + out += use_len; + left -= use_len; + } + + /* 6. Update */ + mbedtls_hmac_drbg_update( ctx, additional, add_len ); + + /* 7. Update reseed counter */ + ctx->reseed_counter++; + + /* 8. Done */ + return( 0 ); +} + +/* + * HMAC_DRBG random function + */ +int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len ) +{ + int ret; + mbedtls_hmac_drbg_context *ctx = (mbedtls_hmac_drbg_context *) p_rng; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + ret = mbedtls_hmac_drbg_random_with_add( ctx, output, out_len, NULL, 0 ); + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +/* + * Free an HMAC_DRBG context + */ +void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx ) +{ + if( ctx == NULL ) + return; + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &ctx->mutex ); +#endif + mbedtls_md_free( &ctx->md_ctx ); + mbedtls_zeroize( ctx, sizeof( mbedtls_hmac_drbg_context ) ); +} + +#if defined(MBEDTLS_FS_IO) +int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ) +{ + int ret; + FILE *f; + unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ]; + + if( ( f = fopen( path, "wb" ) ) == NULL ) + return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR ); + + if( ( ret = mbedtls_hmac_drbg_random( ctx, buf, sizeof( buf ) ) ) != 0 ) + goto exit; + + if( fwrite( buf, 1, sizeof( buf ), f ) != sizeof( buf ) ) + { + ret = MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR; + goto exit; + } + + ret = 0; + +exit: + fclose( f ); + return( ret ); +} + +int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ) +{ + FILE *f; + size_t n; + unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ]; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR ); + + fseek( f, 0, SEEK_END ); + n = (size_t) ftell( f ); + fseek( f, 0, SEEK_SET ); + + if( n > MBEDTLS_HMAC_DRBG_MAX_INPUT ) + { + fclose( f ); + return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG ); + } + + if( fread( buf, 1, n, f ) != n ) + { + fclose( f ); + return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR ); + } + + fclose( f ); + + mbedtls_hmac_drbg_update( ctx, buf, n ); + + return( mbedtls_hmac_drbg_write_seed_file( ctx, path ) ); +} +#endif /* MBEDTLS_FS_IO */ + + +#if defined(MBEDTLS_SELF_TEST) + +#if !defined(MBEDTLS_SHA1_C) +/* Dummy checkup routine */ +int mbedtls_hmac_drbg_self_test( int verbose ) +{ + (void) verbose; + return( 0 ); +} +#else + +#define OUTPUT_LEN 80 + +/* From a NIST PR=true test vector */ +static const unsigned char entropy_pr[] = { + 0xa0, 0xc9, 0xab, 0x58, 0xf1, 0xe2, 0xe5, 0xa4, 0xde, 0x3e, 0xbd, 0x4f, + 0xf7, 0x3e, 0x9c, 0x5b, 0x64, 0xef, 0xd8, 0xca, 0x02, 0x8c, 0xf8, 0x11, + 0x48, 0xa5, 0x84, 0xfe, 0x69, 0xab, 0x5a, 0xee, 0x42, 0xaa, 0x4d, 0x42, + 0x17, 0x60, 0x99, 0xd4, 0x5e, 0x13, 0x97, 0xdc, 0x40, 0x4d, 0x86, 0xa3, + 0x7b, 0xf5, 0x59, 0x54, 0x75, 0x69, 0x51, 0xe4 }; +static const unsigned char result_pr[OUTPUT_LEN] = { + 0x9a, 0x00, 0xa2, 0xd0, 0x0e, 0xd5, 0x9b, 0xfe, 0x31, 0xec, 0xb1, 0x39, + 0x9b, 0x60, 0x81, 0x48, 0xd1, 0x96, 0x9d, 0x25, 0x0d, 0x3c, 0x1e, 0x94, + 0x10, 0x10, 0x98, 0x12, 0x93, 0x25, 0xca, 0xb8, 0xfc, 0xcc, 0x2d, 0x54, + 0x73, 0x19, 0x70, 0xc0, 0x10, 0x7a, 0xa4, 0x89, 0x25, 0x19, 0x95, 0x5e, + 0x4b, 0xc6, 0x00, 0x1d, 0x7f, 0x4e, 0x6a, 0x2b, 0xf8, 0xa3, 0x01, 0xab, + 0x46, 0x05, 0x5c, 0x09, 0xa6, 0x71, 0x88, 0xf1, 0xa7, 0x40, 0xee, 0xf3, + 0xe1, 0x5c, 0x02, 0x9b, 0x44, 0xaf, 0x03, 0x44 }; + +/* From a NIST PR=false test vector */ +static const unsigned char entropy_nopr[] = { + 0x79, 0x34, 0x9b, 0xbf, 0x7c, 0xdd, 0xa5, 0x79, 0x95, 0x57, 0x86, 0x66, + 0x21, 0xc9, 0x13, 0x83, 0x11, 0x46, 0x73, 0x3a, 0xbf, 0x8c, 0x35, 0xc8, + 0xc7, 0x21, 0x5b, 0x5b, 0x96, 0xc4, 0x8e, 0x9b, 0x33, 0x8c, 0x74, 0xe3, + 0xe9, 0x9d, 0xfe, 0xdf }; +static const unsigned char result_nopr[OUTPUT_LEN] = { + 0xc6, 0xa1, 0x6a, 0xb8, 0xd4, 0x20, 0x70, 0x6f, 0x0f, 0x34, 0xab, 0x7f, + 0xec, 0x5a, 0xdc, 0xa9, 0xd8, 0xca, 0x3a, 0x13, 0x3e, 0x15, 0x9c, 0xa6, + 0xac, 0x43, 0xc6, 0xf8, 0xa2, 0xbe, 0x22, 0x83, 0x4a, 0x4c, 0x0a, 0x0a, + 0xff, 0xb1, 0x0d, 0x71, 0x94, 0xf1, 0xc1, 0xa5, 0xcf, 0x73, 0x22, 0xec, + 0x1a, 0xe0, 0x96, 0x4e, 0xd4, 0xbf, 0x12, 0x27, 0x46, 0xe0, 0x87, 0xfd, + 0xb5, 0xb3, 0xe9, 0x1b, 0x34, 0x93, 0xd5, 0xbb, 0x98, 0xfa, 0xed, 0x49, + 0xe8, 0x5f, 0x13, 0x0f, 0xc8, 0xa4, 0x59, 0xb7 }; + +/* "Entropy" from buffer */ +static size_t test_offset; +static int hmac_drbg_self_test_entropy( void *data, + unsigned char *buf, size_t len ) +{ + const unsigned char *p = data; + memcpy( buf, p + test_offset, len ); + test_offset += len; + return( 0 ); +} + +#define CHK( c ) if( (c) != 0 ) \ + { \ + if( verbose != 0 ) \ + mbedtls_printf( "failed\n" ); \ + return( 1 ); \ + } + +/* + * Checkup routine for HMAC_DRBG with SHA-1 + */ +int mbedtls_hmac_drbg_self_test( int verbose ) +{ + mbedtls_hmac_drbg_context ctx; + unsigned char buf[OUTPUT_LEN]; + const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ); + + mbedtls_hmac_drbg_init( &ctx ); + + /* + * PR = True + */ + if( verbose != 0 ) + mbedtls_printf( " HMAC_DRBG (PR = True) : " ); + + test_offset = 0; + CHK( mbedtls_hmac_drbg_seed( &ctx, md_info, + hmac_drbg_self_test_entropy, (void *) entropy_pr, + NULL, 0 ) ); + mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON ); + CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); + CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); + CHK( memcmp( buf, result_pr, OUTPUT_LEN ) ); + mbedtls_hmac_drbg_free( &ctx ); + + mbedtls_hmac_drbg_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + /* + * PR = False + */ + if( verbose != 0 ) + mbedtls_printf( " HMAC_DRBG (PR = False) : " ); + + mbedtls_hmac_drbg_init( &ctx ); + + test_offset = 0; + CHK( mbedtls_hmac_drbg_seed( &ctx, md_info, + hmac_drbg_self_test_entropy, (void *) entropy_nopr, + NULL, 0 ) ); + CHK( mbedtls_hmac_drbg_reseed( &ctx, NULL, 0 ) ); + CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); + CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); + CHK( memcmp( buf, result_nopr, OUTPUT_LEN ) ); + mbedtls_hmac_drbg_free( &ctx ); + + mbedtls_hmac_drbg_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_HMAC_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md.c new file mode 100644 index 0000000..eda98f6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md.c @@ -0,0 +1,471 @@ +/** + * \file mbedtls_md.c + * + * \brief Generic message digest wrapper for mbed TLS + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_MD_C) + +#include "mbedtls/md.h" +#include "mbedtls/md_internal.h" + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include + +#if defined(MBEDTLS_FS_IO) +#include +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Reminder: update profiles in x509_crt.c when adding a new hash! + */ +static const int supported_digests[] = { + +#if defined(MBEDTLS_SHA512_C) + MBEDTLS_MD_SHA512, + MBEDTLS_MD_SHA384, +#endif + +#if defined(MBEDTLS_SHA256_C) + MBEDTLS_MD_SHA256, + MBEDTLS_MD_SHA224, +#endif + +#if defined(MBEDTLS_SHA1_C) + MBEDTLS_MD_SHA1, +#endif + +#if defined(MBEDTLS_RIPEMD160_C) + MBEDTLS_MD_RIPEMD160, +#endif + +#if defined(MBEDTLS_MD5_C) + MBEDTLS_MD_MD5, +#endif + +#if defined(MBEDTLS_MD4_C) + MBEDTLS_MD_MD4, +#endif + +#if defined(MBEDTLS_MD2_C) + MBEDTLS_MD_MD2, +#endif + + MBEDTLS_MD_NONE +}; + +const int *mbedtls_md_list( void ) +{ + return( supported_digests ); +} + +const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name ) +{ + if( NULL == md_name ) + return( NULL ); + + /* Get the appropriate digest information */ +#if defined(MBEDTLS_MD2_C) + if( !strcmp( "MD2", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_MD2 ); +#endif +#if defined(MBEDTLS_MD4_C) + if( !strcmp( "MD4", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_MD4 ); +#endif +#if defined(MBEDTLS_MD5_C) + if( !strcmp( "MD5", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_MD5 ); +#endif +#if defined(MBEDTLS_RIPEMD160_C) + if( !strcmp( "RIPEMD160", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_RIPEMD160 ); +#endif +#if defined(MBEDTLS_SHA1_C) + if( !strcmp( "SHA1", md_name ) || !strcmp( "SHA", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ); +#endif +#if defined(MBEDTLS_SHA256_C) + if( !strcmp( "SHA224", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_SHA224 ); + if( !strcmp( "SHA256", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ); +#endif +#if defined(MBEDTLS_SHA512_C) + if( !strcmp( "SHA384", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_SHA384 ); + if( !strcmp( "SHA512", md_name ) ) + return mbedtls_md_info_from_type( MBEDTLS_MD_SHA512 ); +#endif + return( NULL ); +} + +const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type ) +{ + switch( md_type ) + { +#if defined(MBEDTLS_MD2_C) + case MBEDTLS_MD_MD2: + return( &mbedtls_md2_info ); +#endif +#if defined(MBEDTLS_MD4_C) + case MBEDTLS_MD_MD4: + return( &mbedtls_md4_info ); +#endif +#if defined(MBEDTLS_MD5_C) + case MBEDTLS_MD_MD5: + return( &mbedtls_md5_info ); +#endif +#if defined(MBEDTLS_RIPEMD160_C) + case MBEDTLS_MD_RIPEMD160: + return( &mbedtls_ripemd160_info ); +#endif +#if defined(MBEDTLS_SHA1_C) + case MBEDTLS_MD_SHA1: + return( &mbedtls_sha1_info ); +#endif +#if defined(MBEDTLS_SHA256_C) + case MBEDTLS_MD_SHA224: + return( &mbedtls_sha224_info ); + case MBEDTLS_MD_SHA256: + return( &mbedtls_sha256_info ); +#endif +#if defined(MBEDTLS_SHA512_C) + case MBEDTLS_MD_SHA384: + return( &mbedtls_sha384_info ); + case MBEDTLS_MD_SHA512: + return( &mbedtls_sha512_info ); +#endif + default: + return( NULL ); + } +} + +void mbedtls_md_init( mbedtls_md_context_t *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_md_context_t ) ); +} + +void mbedtls_md_free( mbedtls_md_context_t *ctx ) +{ + if( ctx == NULL || ctx->md_info == NULL ) + return; + + if( ctx->md_ctx != NULL ) + ctx->md_info->ctx_free_func( ctx->md_ctx ); + + if( ctx->hmac_ctx != NULL ) + { + mbedtls_zeroize( ctx->hmac_ctx, 2 * ctx->md_info->block_size ); + mbedtls_free( ctx->hmac_ctx ); + } + + mbedtls_zeroize( ctx, sizeof( mbedtls_md_context_t ) ); +} + +int mbedtls_md_clone( mbedtls_md_context_t *dst, + const mbedtls_md_context_t *src ) +{ + if( dst == NULL || dst->md_info == NULL || + src == NULL || src->md_info == NULL || + dst->md_info != src->md_info ) + { + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + } + + dst->md_info->clone_func( dst->md_ctx, src->md_ctx ); + + return( 0 ); +} + +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) +int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) +{ + return mbedtls_md_setup( ctx, md_info, 1 ); +} +#endif + +int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac ) +{ + if( md_info == NULL || ctx == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + if( ( ctx->md_ctx = md_info->ctx_alloc_func() ) == NULL ) + return( MBEDTLS_ERR_MD_ALLOC_FAILED ); + + if( hmac != 0 ) + { + ctx->hmac_ctx = mbedtls_calloc( 2, md_info->block_size ); + if( ctx->hmac_ctx == NULL ) + { + md_info->ctx_free_func( ctx->md_ctx ); + return( MBEDTLS_ERR_MD_ALLOC_FAILED ); + } + } + + ctx->md_info = md_info; + + return( 0 ); +} + +int mbedtls_md_starts( mbedtls_md_context_t *ctx ) +{ + if( ctx == NULL || ctx->md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + ctx->md_info->starts_func( ctx->md_ctx ); + + return( 0 ); +} + +int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ) +{ + if( ctx == NULL || ctx->md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + ctx->md_info->update_func( ctx->md_ctx, input, ilen ); + + return( 0 ); +} + +int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ) +{ + if( ctx == NULL || ctx->md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + ctx->md_info->finish_func( ctx->md_ctx, output ); + + return( 0 ); +} + +int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + if( md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + md_info->digest_func( input, ilen, output ); + + return( 0 ); +} + +#if defined(MBEDTLS_FS_IO) +int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigned char *output ) +{ + int ret; + FILE *f; + size_t n; + mbedtls_md_context_t ctx; + unsigned char buf[1024]; + + if( md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( MBEDTLS_ERR_MD_FILE_IO_ERROR ); + + mbedtls_md_init( &ctx ); + + if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 ) + goto cleanup; + + md_info->starts_func( ctx.md_ctx ); + + while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) + md_info->update_func( ctx.md_ctx, buf, n ); + + if( ferror( f ) != 0 ) + { + ret = MBEDTLS_ERR_MD_FILE_IO_ERROR; + goto cleanup; + } + + md_info->finish_func( ctx.md_ctx, output ); + +cleanup: + fclose( f ); + mbedtls_md_free( &ctx ); + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ + +int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen ) +{ + unsigned char sum[MBEDTLS_MD_MAX_SIZE]; + unsigned char *ipad, *opad; + size_t i; + + if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + if( keylen > (size_t) ctx->md_info->block_size ) + { + ctx->md_info->starts_func( ctx->md_ctx ); + ctx->md_info->update_func( ctx->md_ctx, key, keylen ); + ctx->md_info->finish_func( ctx->md_ctx, sum ); + + keylen = ctx->md_info->size; + key = sum; + } + + ipad = (unsigned char *) ctx->hmac_ctx; + opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size; + + memset( ipad, 0x36, ctx->md_info->block_size ); + memset( opad, 0x5C, ctx->md_info->block_size ); + + for( i = 0; i < keylen; i++ ) + { + ipad[i] = (unsigned char)( ipad[i] ^ key[i] ); + opad[i] = (unsigned char)( opad[i] ^ key[i] ); + } + + mbedtls_zeroize( sum, sizeof( sum ) ); + + ctx->md_info->starts_func( ctx->md_ctx ); + ctx->md_info->update_func( ctx->md_ctx, ipad, ctx->md_info->block_size ); + + return( 0 ); +} + +int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ) +{ + if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + ctx->md_info->update_func( ctx->md_ctx, input, ilen ); + + return( 0 ); +} + +int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output ) +{ + unsigned char tmp[MBEDTLS_MD_MAX_SIZE]; + unsigned char *opad; + + if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size; + + ctx->md_info->finish_func( ctx->md_ctx, tmp ); + ctx->md_info->starts_func( ctx->md_ctx ); + ctx->md_info->update_func( ctx->md_ctx, opad, ctx->md_info->block_size ); + ctx->md_info->update_func( ctx->md_ctx, tmp, ctx->md_info->size ); + ctx->md_info->finish_func( ctx->md_ctx, output ); + + return( 0 ); +} + +int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ) +{ + unsigned char *ipad; + + if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + ipad = (unsigned char *) ctx->hmac_ctx; + + ctx->md_info->starts_func( ctx->md_ctx ); + ctx->md_info->update_func( ctx->md_ctx, ipad, ctx->md_info->block_size ); + + return( 0 ); +} + +int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + mbedtls_md_context_t ctx; + int ret; + + if( md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + mbedtls_md_init( &ctx ); + + if( ( ret = mbedtls_md_setup( &ctx, md_info, 1 ) ) != 0 ) + return( ret ); + + mbedtls_md_hmac_starts( &ctx, key, keylen ); + mbedtls_md_hmac_update( &ctx, input, ilen ); + mbedtls_md_hmac_finish( &ctx, output ); + + mbedtls_md_free( &ctx ); + + return( 0 ); +} + +int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data ) +{ + if( ctx == NULL || ctx->md_info == NULL ) + return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); + + ctx->md_info->process_func( ctx->md_ctx, data ); + + return( 0 ); +} + +unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info ) +{ + if( md_info == NULL ) + return( 0 ); + + return md_info->size; +} + +mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info ) +{ + if( md_info == NULL ) + return( MBEDTLS_MD_NONE ); + + return md_info->type; +} + +const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info ) +{ + if( md_info == NULL ) + return( NULL ); + + return md_info->name; +} + +#endif /* MBEDTLS_MD_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md2.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md2.c new file mode 100644 index 0000000..95cbcce --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md2.c @@ -0,0 +1,288 @@ +/* + * RFC 1115/1319 compliant MD2 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The MD2 algorithm was designed by Ron Rivest in 1989. + * + * http://www.ietf.org/rfc/rfc1115.txt + * http://www.ietf.org/rfc/rfc1319.txt + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_MD2_C) + +#include "mbedtls/md2.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_MD2_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +static const unsigned char PI_SUBST[256] = +{ + 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, + 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 0x62, 0xA7, 0x05, 0xF3, + 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, + 0x82, 0xCA, 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, + 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, 0xBE, 0x4E, + 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, + 0xBB, 0x2F, 0xEE, 0x7A, 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, + 0x07, 0x3F, 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, + 0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, 0x35, 0x3E, + 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, 0xFF, 0x19, 0x30, 0xB3, + 0x48, 0xA5, 0xB5, 0xD1, 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, + 0xAA, 0xC6, 0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, + 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, 0x45, 0x9D, + 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, 0x86, 0x5B, 0xCF, 0x65, + 0xE6, 0x2D, 0xA8, 0x02, 0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, + 0xB9, 0xF6, 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F, + 0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, 0xC3, 0x5C, + 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, 0x2C, 0x53, 0x0D, 0x6E, + 0x85, 0x28, 0x84, 0x09, 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, + 0x4D, 0x52, 0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, + 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A, 0x78, 0x88, + 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, + 0x3B, 0x00, 0x1D, 0x39, 0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, + 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, + 0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, + 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14 +}; + +void mbedtls_md2_init( mbedtls_md2_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_md2_context ) ); +} + +void mbedtls_md2_free( mbedtls_md2_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_md2_context ) ); +} + +void mbedtls_md2_clone( mbedtls_md2_context *dst, + const mbedtls_md2_context *src ) +{ + *dst = *src; +} + +/* + * MD2 context setup + */ +void mbedtls_md2_starts( mbedtls_md2_context *ctx ) +{ + memset( ctx->cksum, 0, 16 ); + memset( ctx->state, 0, 46 ); + memset( ctx->buffer, 0, 16 ); + ctx->left = 0; +} + +#if !defined(MBEDTLS_MD2_PROCESS_ALT) +void mbedtls_md2_process( mbedtls_md2_context *ctx ) +{ + int i, j; + unsigned char t = 0; + + for( i = 0; i < 16; i++ ) + { + ctx->state[i + 16] = ctx->buffer[i]; + ctx->state[i + 32] = + (unsigned char)( ctx->buffer[i] ^ ctx->state[i]); + } + + for( i = 0; i < 18; i++ ) + { + for( j = 0; j < 48; j++ ) + { + ctx->state[j] = (unsigned char) + ( ctx->state[j] ^ PI_SUBST[t] ); + t = ctx->state[j]; + } + + t = (unsigned char)( t + i ); + } + + t = ctx->cksum[15]; + + for( i = 0; i < 16; i++ ) + { + ctx->cksum[i] = (unsigned char) + ( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] ); + t = ctx->cksum[i]; + } +} +#endif /* !MBEDTLS_MD2_PROCESS_ALT */ + +/* + * MD2 process buffer + */ +void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen ) +{ + size_t fill; + + while( ilen > 0 ) + { + if( ilen > 16 - ctx->left ) + fill = 16 - ctx->left; + else + fill = ilen; + + memcpy( ctx->buffer + ctx->left, input, fill ); + + ctx->left += fill; + input += fill; + ilen -= fill; + + if( ctx->left == 16 ) + { + ctx->left = 0; + mbedtls_md2_process( ctx ); + } + } +} + +/* + * MD2 final digest + */ +void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] ) +{ + size_t i; + unsigned char x; + + x = (unsigned char)( 16 - ctx->left ); + + for( i = ctx->left; i < 16; i++ ) + ctx->buffer[i] = x; + + mbedtls_md2_process( ctx ); + + memcpy( ctx->buffer, ctx->cksum, 16 ); + mbedtls_md2_process( ctx ); + + memcpy( output, ctx->state, 16 ); +} + +#endif /* !MBEDTLS_MD2_ALT */ + +/* + * output = MD2( input buffer ) + */ +void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] ) +{ + mbedtls_md2_context ctx; + + mbedtls_md2_init( &ctx ); + mbedtls_md2_starts( &ctx ); + mbedtls_md2_update( &ctx, input, ilen ); + mbedtls_md2_finish( &ctx, output ); + mbedtls_md2_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) + +/* + * RFC 1319 test vectors + */ +static const char md2_test_str[7][81] = +{ + { "" }, + { "a" }, + { "abc" }, + { "message digest" }, + { "abcdefghijklmnopqrstuvwxyz" }, + { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, + { "12345678901234567890123456789012345678901234567890123456789012" \ + "345678901234567890" } +}; + +static const unsigned char md2_test_sum[7][16] = +{ + { 0x83, 0x50, 0xE5, 0xA3, 0xE2, 0x4C, 0x15, 0x3D, + 0xF2, 0x27, 0x5C, 0x9F, 0x80, 0x69, 0x27, 0x73 }, + { 0x32, 0xEC, 0x01, 0xEC, 0x4A, 0x6D, 0xAC, 0x72, + 0xC0, 0xAB, 0x96, 0xFB, 0x34, 0xC0, 0xB5, 0xD1 }, + { 0xDA, 0x85, 0x3B, 0x0D, 0x3F, 0x88, 0xD9, 0x9B, + 0x30, 0x28, 0x3A, 0x69, 0xE6, 0xDE, 0xD6, 0xBB }, + { 0xAB, 0x4F, 0x49, 0x6B, 0xFB, 0x2A, 0x53, 0x0B, + 0x21, 0x9F, 0xF3, 0x30, 0x31, 0xFE, 0x06, 0xB0 }, + { 0x4E, 0x8D, 0xDF, 0xF3, 0x65, 0x02, 0x92, 0xAB, + 0x5A, 0x41, 0x08, 0xC3, 0xAA, 0x47, 0x94, 0x0B }, + { 0xDA, 0x33, 0xDE, 0xF2, 0xA4, 0x2D, 0xF1, 0x39, + 0x75, 0x35, 0x28, 0x46, 0xC3, 0x03, 0x38, 0xCD }, + { 0xD5, 0x97, 0x6F, 0x79, 0xD8, 0x3D, 0x3A, 0x0D, + 0xC9, 0x80, 0x6C, 0x3C, 0x66, 0xF3, 0xEF, 0xD8 } +}; + +/* + * Checkup routine + */ +int mbedtls_md2_self_test( int verbose ) +{ + int i; + unsigned char md2sum[16]; + + for( i = 0; i < 7; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " MD2 test #%d: ", i + 1 ); + + mbedtls_md2( (unsigned char *) md2_test_str[i], + strlen( md2_test_str[i] ), md2sum ); + + if( memcmp( md2sum, md2_test_sum[i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_MD2_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md4.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md4.c new file mode 100644 index 0000000..11a77e3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md4.c @@ -0,0 +1,384 @@ +/* + * RFC 1186/1320 compliant MD4 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The MD4 algorithm was designed by Ron Rivest in 1990. + * + * http://www.ietf.org/rfc/rfc1186.txt + * http://www.ietf.org/rfc/rfc1320.txt + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_MD4_C) + +#include "mbedtls/md4.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_MD4_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef GET_UINT32_LE +#define GET_UINT32_LE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ +} +#endif + +#ifndef PUT_UINT32_LE +#define PUT_UINT32_LE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +} +#endif + +void mbedtls_md4_init( mbedtls_md4_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_md4_context ) ); +} + +void mbedtls_md4_free( mbedtls_md4_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_md4_context ) ); +} + +void mbedtls_md4_clone( mbedtls_md4_context *dst, + const mbedtls_md4_context *src ) +{ + *dst = *src; +} + +/* + * MD4 context setup + */ +void mbedtls_md4_starts( mbedtls_md4_context *ctx ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; +} + +#if !defined(MBEDTLS_MD4_PROCESS_ALT) +void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] ) +{ + uint32_t X[16], A, B, C, D; + + GET_UINT32_LE( X[ 0], data, 0 ); + GET_UINT32_LE( X[ 1], data, 4 ); + GET_UINT32_LE( X[ 2], data, 8 ); + GET_UINT32_LE( X[ 3], data, 12 ); + GET_UINT32_LE( X[ 4], data, 16 ); + GET_UINT32_LE( X[ 5], data, 20 ); + GET_UINT32_LE( X[ 6], data, 24 ); + GET_UINT32_LE( X[ 7], data, 28 ); + GET_UINT32_LE( X[ 8], data, 32 ); + GET_UINT32_LE( X[ 9], data, 36 ); + GET_UINT32_LE( X[10], data, 40 ); + GET_UINT32_LE( X[11], data, 44 ); + GET_UINT32_LE( X[12], data, 48 ); + GET_UINT32_LE( X[13], data, 52 ); + GET_UINT32_LE( X[14], data, 56 ); + GET_UINT32_LE( X[15], data, 60 ); + +#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + +#define F(x, y, z) ((x & y) | ((~x) & z)) +#define P(a,b,c,d,x,s) { a += F(b,c,d) + x; a = S(a,s); } + + P( A, B, C, D, X[ 0], 3 ); + P( D, A, B, C, X[ 1], 7 ); + P( C, D, A, B, X[ 2], 11 ); + P( B, C, D, A, X[ 3], 19 ); + P( A, B, C, D, X[ 4], 3 ); + P( D, A, B, C, X[ 5], 7 ); + P( C, D, A, B, X[ 6], 11 ); + P( B, C, D, A, X[ 7], 19 ); + P( A, B, C, D, X[ 8], 3 ); + P( D, A, B, C, X[ 9], 7 ); + P( C, D, A, B, X[10], 11 ); + P( B, C, D, A, X[11], 19 ); + P( A, B, C, D, X[12], 3 ); + P( D, A, B, C, X[13], 7 ); + P( C, D, A, B, X[14], 11 ); + P( B, C, D, A, X[15], 19 ); + +#undef P +#undef F + +#define F(x,y,z) ((x & y) | (x & z) | (y & z)) +#define P(a,b,c,d,x,s) { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); } + + P( A, B, C, D, X[ 0], 3 ); + P( D, A, B, C, X[ 4], 5 ); + P( C, D, A, B, X[ 8], 9 ); + P( B, C, D, A, X[12], 13 ); + P( A, B, C, D, X[ 1], 3 ); + P( D, A, B, C, X[ 5], 5 ); + P( C, D, A, B, X[ 9], 9 ); + P( B, C, D, A, X[13], 13 ); + P( A, B, C, D, X[ 2], 3 ); + P( D, A, B, C, X[ 6], 5 ); + P( C, D, A, B, X[10], 9 ); + P( B, C, D, A, X[14], 13 ); + P( A, B, C, D, X[ 3], 3 ); + P( D, A, B, C, X[ 7], 5 ); + P( C, D, A, B, X[11], 9 ); + P( B, C, D, A, X[15], 13 ); + +#undef P +#undef F + +#define F(x,y,z) (x ^ y ^ z) +#define P(a,b,c,d,x,s) { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); } + + P( A, B, C, D, X[ 0], 3 ); + P( D, A, B, C, X[ 8], 9 ); + P( C, D, A, B, X[ 4], 11 ); + P( B, C, D, A, X[12], 15 ); + P( A, B, C, D, X[ 2], 3 ); + P( D, A, B, C, X[10], 9 ); + P( C, D, A, B, X[ 6], 11 ); + P( B, C, D, A, X[14], 15 ); + P( A, B, C, D, X[ 1], 3 ); + P( D, A, B, C, X[ 9], 9 ); + P( C, D, A, B, X[ 5], 11 ); + P( B, C, D, A, X[13], 15 ); + P( A, B, C, D, X[ 3], 3 ); + P( D, A, B, C, X[11], 9 ); + P( C, D, A, B, X[ 7], 11 ); + P( B, C, D, A, X[15], 15 ); + +#undef F +#undef P + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; +} +#endif /* !MBEDTLS_MD4_PROCESS_ALT */ + +/* + * MD4 process buffer + */ +void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen ) +{ + size_t fill; + uint32_t left; + + if( ilen == 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t) ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if( ctx->total[0] < (uint32_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), + (void *) input, fill ); + mbedtls_md4_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 64 ) + { + mbedtls_md4_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if( ilen > 0 ) + { + memcpy( (void *) (ctx->buffer + left), + (void *) input, ilen ); + } +} + +static const unsigned char md4_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * MD4 final digest + */ +void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] ) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT32_LE( low, msglen, 0 ); + PUT_UINT32_LE( high, msglen, 4 ); + + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + mbedtls_md4_update( ctx, (unsigned char *) md4_padding, padn ); + mbedtls_md4_update( ctx, msglen, 8 ); + + PUT_UINT32_LE( ctx->state[0], output, 0 ); + PUT_UINT32_LE( ctx->state[1], output, 4 ); + PUT_UINT32_LE( ctx->state[2], output, 8 ); + PUT_UINT32_LE( ctx->state[3], output, 12 ); +} + +#endif /* !MBEDTLS_MD4_ALT */ + +/* + * output = MD4( input buffer ) + */ +void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] ) +{ + mbedtls_md4_context ctx; + + mbedtls_md4_init( &ctx ); + mbedtls_md4_starts( &ctx ); + mbedtls_md4_update( &ctx, input, ilen ); + mbedtls_md4_finish( &ctx, output ); + mbedtls_md4_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) + +/* + * RFC 1320 test vectors + */ +static const char md4_test_str[7][81] = +{ + { "" }, + { "a" }, + { "abc" }, + { "message digest" }, + { "abcdefghijklmnopqrstuvwxyz" }, + { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, + { "12345678901234567890123456789012345678901234567890123456789012" \ + "345678901234567890" } +}; + +static const unsigned char md4_test_sum[7][16] = +{ + { 0x31, 0xD6, 0xCF, 0xE0, 0xD1, 0x6A, 0xE9, 0x31, + 0xB7, 0x3C, 0x59, 0xD7, 0xE0, 0xC0, 0x89, 0xC0 }, + { 0xBD, 0xE5, 0x2C, 0xB3, 0x1D, 0xE3, 0x3E, 0x46, + 0x24, 0x5E, 0x05, 0xFB, 0xDB, 0xD6, 0xFB, 0x24 }, + { 0xA4, 0x48, 0x01, 0x7A, 0xAF, 0x21, 0xD8, 0x52, + 0x5F, 0xC1, 0x0A, 0xE8, 0x7A, 0xA6, 0x72, 0x9D }, + { 0xD9, 0x13, 0x0A, 0x81, 0x64, 0x54, 0x9F, 0xE8, + 0x18, 0x87, 0x48, 0x06, 0xE1, 0xC7, 0x01, 0x4B }, + { 0xD7, 0x9E, 0x1C, 0x30, 0x8A, 0xA5, 0xBB, 0xCD, + 0xEE, 0xA8, 0xED, 0x63, 0xDF, 0x41, 0x2D, 0xA9 }, + { 0x04, 0x3F, 0x85, 0x82, 0xF2, 0x41, 0xDB, 0x35, + 0x1C, 0xE6, 0x27, 0xE1, 0x53, 0xE7, 0xF0, 0xE4 }, + { 0xE3, 0x3B, 0x4D, 0xDC, 0x9C, 0x38, 0xF2, 0x19, + 0x9C, 0x3E, 0x7B, 0x16, 0x4F, 0xCC, 0x05, 0x36 } +}; + +/* + * Checkup routine + */ +int mbedtls_md4_self_test( int verbose ) +{ + int i; + unsigned char md4sum[16]; + + for( i = 0; i < 7; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " MD4 test #%d: ", i + 1 ); + + mbedtls_md4( (unsigned char *) md4_test_str[i], + strlen( md4_test_str[i] ), md4sum ); + + if( memcmp( md4sum, md4_test_sum[i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_MD4_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md5.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md5.c new file mode 100644 index 0000000..5d972dc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md5.c @@ -0,0 +1,404 @@ +/* + * RFC 1321 compliant MD5 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The MD5 algorithm was designed by Ron Rivest in 1991. + * + * http://www.ietf.org/rfc/rfc1321.txt + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_MD5_C) + +#include "mbedtls/md5.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_MD5_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef GET_UINT32_LE +#define GET_UINT32_LE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ +} +#endif + +#ifndef PUT_UINT32_LE +#define PUT_UINT32_LE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +} +#endif + +void mbedtls_md5_init( mbedtls_md5_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_md5_context ) ); +} + +void mbedtls_md5_free( mbedtls_md5_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_md5_context ) ); +} + +void mbedtls_md5_clone( mbedtls_md5_context *dst, + const mbedtls_md5_context *src ) +{ + *dst = *src; +} + +/* + * MD5 context setup + */ +void mbedtls_md5_starts( mbedtls_md5_context *ctx ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; +} + +#if !defined(MBEDTLS_MD5_PROCESS_ALT) +void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] ) +{ + uint32_t X[16], A, B, C, D; + + GET_UINT32_LE( X[ 0], data, 0 ); + GET_UINT32_LE( X[ 1], data, 4 ); + GET_UINT32_LE( X[ 2], data, 8 ); + GET_UINT32_LE( X[ 3], data, 12 ); + GET_UINT32_LE( X[ 4], data, 16 ); + GET_UINT32_LE( X[ 5], data, 20 ); + GET_UINT32_LE( X[ 6], data, 24 ); + GET_UINT32_LE( X[ 7], data, 28 ); + GET_UINT32_LE( X[ 8], data, 32 ); + GET_UINT32_LE( X[ 9], data, 36 ); + GET_UINT32_LE( X[10], data, 40 ); + GET_UINT32_LE( X[11], data, 44 ); + GET_UINT32_LE( X[12], data, 48 ); + GET_UINT32_LE( X[13], data, 52 ); + GET_UINT32_LE( X[14], data, 56 ); + GET_UINT32_LE( X[15], data, 60 ); + +#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define P(a,b,c,d,k,s,t) \ +{ \ + a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ +} + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + +#define F(x,y,z) (z ^ (x & (y ^ z))) + + P( A, B, C, D, 0, 7, 0xD76AA478 ); + P( D, A, B, C, 1, 12, 0xE8C7B756 ); + P( C, D, A, B, 2, 17, 0x242070DB ); + P( B, C, D, A, 3, 22, 0xC1BDCEEE ); + P( A, B, C, D, 4, 7, 0xF57C0FAF ); + P( D, A, B, C, 5, 12, 0x4787C62A ); + P( C, D, A, B, 6, 17, 0xA8304613 ); + P( B, C, D, A, 7, 22, 0xFD469501 ); + P( A, B, C, D, 8, 7, 0x698098D8 ); + P( D, A, B, C, 9, 12, 0x8B44F7AF ); + P( C, D, A, B, 10, 17, 0xFFFF5BB1 ); + P( B, C, D, A, 11, 22, 0x895CD7BE ); + P( A, B, C, D, 12, 7, 0x6B901122 ); + P( D, A, B, C, 13, 12, 0xFD987193 ); + P( C, D, A, B, 14, 17, 0xA679438E ); + P( B, C, D, A, 15, 22, 0x49B40821 ); + +#undef F + +#define F(x,y,z) (y ^ (z & (x ^ y))) + + P( A, B, C, D, 1, 5, 0xF61E2562 ); + P( D, A, B, C, 6, 9, 0xC040B340 ); + P( C, D, A, B, 11, 14, 0x265E5A51 ); + P( B, C, D, A, 0, 20, 0xE9B6C7AA ); + P( A, B, C, D, 5, 5, 0xD62F105D ); + P( D, A, B, C, 10, 9, 0x02441453 ); + P( C, D, A, B, 15, 14, 0xD8A1E681 ); + P( B, C, D, A, 4, 20, 0xE7D3FBC8 ); + P( A, B, C, D, 9, 5, 0x21E1CDE6 ); + P( D, A, B, C, 14, 9, 0xC33707D6 ); + P( C, D, A, B, 3, 14, 0xF4D50D87 ); + P( B, C, D, A, 8, 20, 0x455A14ED ); + P( A, B, C, D, 13, 5, 0xA9E3E905 ); + P( D, A, B, C, 2, 9, 0xFCEFA3F8 ); + P( C, D, A, B, 7, 14, 0x676F02D9 ); + P( B, C, D, A, 12, 20, 0x8D2A4C8A ); + +#undef F + +#define F(x,y,z) (x ^ y ^ z) + + P( A, B, C, D, 5, 4, 0xFFFA3942 ); + P( D, A, B, C, 8, 11, 0x8771F681 ); + P( C, D, A, B, 11, 16, 0x6D9D6122 ); + P( B, C, D, A, 14, 23, 0xFDE5380C ); + P( A, B, C, D, 1, 4, 0xA4BEEA44 ); + P( D, A, B, C, 4, 11, 0x4BDECFA9 ); + P( C, D, A, B, 7, 16, 0xF6BB4B60 ); + P( B, C, D, A, 10, 23, 0xBEBFBC70 ); + P( A, B, C, D, 13, 4, 0x289B7EC6 ); + P( D, A, B, C, 0, 11, 0xEAA127FA ); + P( C, D, A, B, 3, 16, 0xD4EF3085 ); + P( B, C, D, A, 6, 23, 0x04881D05 ); + P( A, B, C, D, 9, 4, 0xD9D4D039 ); + P( D, A, B, C, 12, 11, 0xE6DB99E5 ); + P( C, D, A, B, 15, 16, 0x1FA27CF8 ); + P( B, C, D, A, 2, 23, 0xC4AC5665 ); + +#undef F + +#define F(x,y,z) (y ^ (x | ~z)) + + P( A, B, C, D, 0, 6, 0xF4292244 ); + P( D, A, B, C, 7, 10, 0x432AFF97 ); + P( C, D, A, B, 14, 15, 0xAB9423A7 ); + P( B, C, D, A, 5, 21, 0xFC93A039 ); + P( A, B, C, D, 12, 6, 0x655B59C3 ); + P( D, A, B, C, 3, 10, 0x8F0CCC92 ); + P( C, D, A, B, 10, 15, 0xFFEFF47D ); + P( B, C, D, A, 1, 21, 0x85845DD1 ); + P( A, B, C, D, 8, 6, 0x6FA87E4F ); + P( D, A, B, C, 15, 10, 0xFE2CE6E0 ); + P( C, D, A, B, 6, 15, 0xA3014314 ); + P( B, C, D, A, 13, 21, 0x4E0811A1 ); + P( A, B, C, D, 4, 6, 0xF7537E82 ); + P( D, A, B, C, 11, 10, 0xBD3AF235 ); + P( C, D, A, B, 2, 15, 0x2AD7D2BB ); + P( B, C, D, A, 9, 21, 0xEB86D391 ); + +#undef F + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; +} +#endif /* !MBEDTLS_MD5_PROCESS_ALT */ + +/* + * MD5 process buffer + */ +void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen ) +{ + size_t fill; + uint32_t left; + + if( ilen == 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t) ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if( ctx->total[0] < (uint32_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), input, fill ); + mbedtls_md5_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 64 ) + { + mbedtls_md5_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if( ilen > 0 ) + { + memcpy( (void *) (ctx->buffer + left), input, ilen ); + } +} + +static const unsigned char md5_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * MD5 final digest + */ +void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] ) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT32_LE( low, msglen, 0 ); + PUT_UINT32_LE( high, msglen, 4 ); + + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + mbedtls_md5_update( ctx, md5_padding, padn ); + mbedtls_md5_update( ctx, msglen, 8 ); + + PUT_UINT32_LE( ctx->state[0], output, 0 ); + PUT_UINT32_LE( ctx->state[1], output, 4 ); + PUT_UINT32_LE( ctx->state[2], output, 8 ); + PUT_UINT32_LE( ctx->state[3], output, 12 ); +} + +#endif /* !MBEDTLS_MD5_ALT */ + +/* + * output = MD5( input buffer ) + */ +void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] ) +{ + mbedtls_md5_context ctx; + + mbedtls_md5_init( &ctx ); + mbedtls_md5_starts( &ctx ); + mbedtls_md5_update( &ctx, input, ilen ); + mbedtls_md5_finish( &ctx, output ); + mbedtls_md5_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) +/* + * RFC 1321 test vectors + */ +static const unsigned char md5_test_buf[7][81] = +{ + { "" }, + { "a" }, + { "abc" }, + { "message digest" }, + { "abcdefghijklmnopqrstuvwxyz" }, + { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, + { "12345678901234567890123456789012345678901234567890123456789012" \ + "345678901234567890" } +}; + +static const int md5_test_buflen[7] = +{ + 0, 1, 3, 14, 26, 62, 80 +}; + +static const unsigned char md5_test_sum[7][16] = +{ + { 0xD4, 0x1D, 0x8C, 0xD9, 0x8F, 0x00, 0xB2, 0x04, + 0xE9, 0x80, 0x09, 0x98, 0xEC, 0xF8, 0x42, 0x7E }, + { 0x0C, 0xC1, 0x75, 0xB9, 0xC0, 0xF1, 0xB6, 0xA8, + 0x31, 0xC3, 0x99, 0xE2, 0x69, 0x77, 0x26, 0x61 }, + { 0x90, 0x01, 0x50, 0x98, 0x3C, 0xD2, 0x4F, 0xB0, + 0xD6, 0x96, 0x3F, 0x7D, 0x28, 0xE1, 0x7F, 0x72 }, + { 0xF9, 0x6B, 0x69, 0x7D, 0x7C, 0xB7, 0x93, 0x8D, + 0x52, 0x5A, 0x2F, 0x31, 0xAA, 0xF1, 0x61, 0xD0 }, + { 0xC3, 0xFC, 0xD3, 0xD7, 0x61, 0x92, 0xE4, 0x00, + 0x7D, 0xFB, 0x49, 0x6C, 0xCA, 0x67, 0xE1, 0x3B }, + { 0xD1, 0x74, 0xAB, 0x98, 0xD2, 0x77, 0xD9, 0xF5, + 0xA5, 0x61, 0x1C, 0x2C, 0x9F, 0x41, 0x9D, 0x9F }, + { 0x57, 0xED, 0xF4, 0xA2, 0x2B, 0xE3, 0xC9, 0x55, + 0xAC, 0x49, 0xDA, 0x2E, 0x21, 0x07, 0xB6, 0x7A } +}; + +/* + * Checkup routine + */ +int mbedtls_md5_self_test( int verbose ) +{ + int i; + unsigned char md5sum[16]; + + for( i = 0; i < 7; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " MD5 test #%d: ", i + 1 ); + + mbedtls_md5( md5_test_buf[i], md5_test_buflen[i], md5sum ); + + if( memcmp( md5sum, md5_test_sum[i], 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_MD5_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md_wrap.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md_wrap.c new file mode 100644 index 0000000..2cfcae2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/md_wrap.c @@ -0,0 +1,575 @@ +/** + * \file md_wrap.c + * + * \brief Generic message digest wrapper for mbed TLS + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_MD_C) + +#include "mbedtls/md_internal.h" + +#if defined(MBEDTLS_MD2_C) +#include "mbedtls/md2.h" +#endif + +#if defined(MBEDTLS_MD4_C) +#include "mbedtls/md4.h" +#endif + +#if defined(MBEDTLS_MD5_C) +#include "mbedtls/md5.h" +#endif + +#if defined(MBEDTLS_RIPEMD160_C) +#include "mbedtls/ripemd160.h" +#endif + +#if defined(MBEDTLS_SHA1_C) +#include "mbedtls/sha1.h" +#endif + +#if defined(MBEDTLS_SHA256_C) +#include "mbedtls/sha256.h" +#endif + +#if defined(MBEDTLS_SHA512_C) +#include "mbedtls/sha512.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if defined(MBEDTLS_MD2_C) + +static void md2_starts_wrap( void *ctx ) +{ + mbedtls_md2_starts( (mbedtls_md2_context *) ctx ); +} + +static void md2_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_md2_update( (mbedtls_md2_context *) ctx, input, ilen ); +} + +static void md2_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_md2_finish( (mbedtls_md2_context *) ctx, output ); +} + +static void *md2_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_md2_context ) ); + + if( ctx != NULL ) + mbedtls_md2_init( (mbedtls_md2_context *) ctx ); + + return( ctx ); +} + +static void md2_ctx_free( void *ctx ) +{ + mbedtls_md2_free( (mbedtls_md2_context *) ctx ); + mbedtls_free( ctx ); +} + +static void md2_clone_wrap( void *dst, const void *src ) +{ + mbedtls_md2_clone( (mbedtls_md2_context *) dst, + (const mbedtls_md2_context *) src ); +} + +static void md2_process_wrap( void *ctx, const unsigned char *data ) +{ + ((void) data); + + mbedtls_md2_process( (mbedtls_md2_context *) ctx ); +} + +const mbedtls_md_info_t mbedtls_md2_info = { + MBEDTLS_MD_MD2, + "MD2", + 16, + 16, + md2_starts_wrap, + md2_update_wrap, + md2_finish_wrap, + mbedtls_md2, + md2_ctx_alloc, + md2_ctx_free, + md2_clone_wrap, + md2_process_wrap, +}; + +#endif /* MBEDTLS_MD2_C */ + +#if defined(MBEDTLS_MD4_C) + +static void md4_starts_wrap( void *ctx ) +{ + mbedtls_md4_starts( (mbedtls_md4_context *) ctx ); +} + +static void md4_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_md4_update( (mbedtls_md4_context *) ctx, input, ilen ); +} + +static void md4_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_md4_finish( (mbedtls_md4_context *) ctx, output ); +} + +static void *md4_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_md4_context ) ); + + if( ctx != NULL ) + mbedtls_md4_init( (mbedtls_md4_context *) ctx ); + + return( ctx ); +} + +static void md4_ctx_free( void *ctx ) +{ + mbedtls_md4_free( (mbedtls_md4_context *) ctx ); + mbedtls_free( ctx ); +} + +static void md4_clone_wrap( void *dst, const void *src ) +{ + mbedtls_md4_clone( (mbedtls_md4_context *) dst, + (const mbedtls_md4_context *) src ); +} + +static void md4_process_wrap( void *ctx, const unsigned char *data ) +{ + mbedtls_md4_process( (mbedtls_md4_context *) ctx, data ); +} + +const mbedtls_md_info_t mbedtls_md4_info = { + MBEDTLS_MD_MD4, + "MD4", + 16, + 64, + md4_starts_wrap, + md4_update_wrap, + md4_finish_wrap, + mbedtls_md4, + md4_ctx_alloc, + md4_ctx_free, + md4_clone_wrap, + md4_process_wrap, +}; + +#endif /* MBEDTLS_MD4_C */ + +#if defined(MBEDTLS_MD5_C) + +static void md5_starts_wrap( void *ctx ) +{ + mbedtls_md5_starts( (mbedtls_md5_context *) ctx ); +} + +static void md5_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_md5_update( (mbedtls_md5_context *) ctx, input, ilen ); +} + +static void md5_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_md5_finish( (mbedtls_md5_context *) ctx, output ); +} + +static void *md5_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_md5_context ) ); + + if( ctx != NULL ) + mbedtls_md5_init( (mbedtls_md5_context *) ctx ); + + return( ctx ); +} + +static void md5_ctx_free( void *ctx ) +{ + mbedtls_md5_free( (mbedtls_md5_context *) ctx ); + mbedtls_free( ctx ); +} + +static void md5_clone_wrap( void *dst, const void *src ) +{ + mbedtls_md5_clone( (mbedtls_md5_context *) dst, + (const mbedtls_md5_context *) src ); +} + +static void md5_process_wrap( void *ctx, const unsigned char *data ) +{ + mbedtls_md5_process( (mbedtls_md5_context *) ctx, data ); +} + +const mbedtls_md_info_t mbedtls_md5_info = { + MBEDTLS_MD_MD5, + "MD5", + 16, + 64, + md5_starts_wrap, + md5_update_wrap, + md5_finish_wrap, + mbedtls_md5, + md5_ctx_alloc, + md5_ctx_free, + md5_clone_wrap, + md5_process_wrap, +}; + +#endif /* MBEDTLS_MD5_C */ + +#if defined(MBEDTLS_RIPEMD160_C) + +static void ripemd160_starts_wrap( void *ctx ) +{ + mbedtls_ripemd160_starts( (mbedtls_ripemd160_context *) ctx ); +} + +static void ripemd160_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_ripemd160_update( (mbedtls_ripemd160_context *) ctx, input, ilen ); +} + +static void ripemd160_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_ripemd160_finish( (mbedtls_ripemd160_context *) ctx, output ); +} + +static void *ripemd160_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ripemd160_context ) ); + + if( ctx != NULL ) + mbedtls_ripemd160_init( (mbedtls_ripemd160_context *) ctx ); + + return( ctx ); +} + +static void ripemd160_ctx_free( void *ctx ) +{ + mbedtls_ripemd160_free( (mbedtls_ripemd160_context *) ctx ); + mbedtls_free( ctx ); +} + +static void ripemd160_clone_wrap( void *dst, const void *src ) +{ + mbedtls_ripemd160_clone( (mbedtls_ripemd160_context *) dst, + (const mbedtls_ripemd160_context *) src ); +} + +static void ripemd160_process_wrap( void *ctx, const unsigned char *data ) +{ + mbedtls_ripemd160_process( (mbedtls_ripemd160_context *) ctx, data ); +} + +const mbedtls_md_info_t mbedtls_ripemd160_info = { + MBEDTLS_MD_RIPEMD160, + "RIPEMD160", + 20, + 64, + ripemd160_starts_wrap, + ripemd160_update_wrap, + ripemd160_finish_wrap, + mbedtls_ripemd160, + ripemd160_ctx_alloc, + ripemd160_ctx_free, + ripemd160_clone_wrap, + ripemd160_process_wrap, +}; + +#endif /* MBEDTLS_RIPEMD160_C */ + +#if defined(MBEDTLS_SHA1_C) + +static void sha1_starts_wrap( void *ctx ) +{ + mbedtls_sha1_starts( (mbedtls_sha1_context *) ctx ); +} + +static void sha1_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_sha1_update( (mbedtls_sha1_context *) ctx, input, ilen ); +} + +static void sha1_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_sha1_finish( (mbedtls_sha1_context *) ctx, output ); +} + +static void *sha1_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_sha1_context ) ); + + if( ctx != NULL ) + mbedtls_sha1_init( (mbedtls_sha1_context *) ctx ); + + return( ctx ); +} + +static void sha1_clone_wrap( void *dst, const void *src ) +{ + mbedtls_sha1_clone( (mbedtls_sha1_context *) dst, + (const mbedtls_sha1_context *) src ); +} + +static void sha1_ctx_free( void *ctx ) +{ + mbedtls_sha1_free( (mbedtls_sha1_context *) ctx ); + mbedtls_free( ctx ); +} + +static void sha1_process_wrap( void *ctx, const unsigned char *data ) +{ + mbedtls_sha1_process( (mbedtls_sha1_context *) ctx, data ); +} + +const mbedtls_md_info_t mbedtls_sha1_info = { + MBEDTLS_MD_SHA1, + "SHA1", + 20, + 64, + sha1_starts_wrap, + sha1_update_wrap, + sha1_finish_wrap, + mbedtls_sha1, + sha1_ctx_alloc, + sha1_ctx_free, + sha1_clone_wrap, + sha1_process_wrap, +}; + +#endif /* MBEDTLS_SHA1_C */ + +/* + * Wrappers for generic message digests + */ +#if defined(MBEDTLS_SHA256_C) + +static void sha224_starts_wrap( void *ctx ) +{ + mbedtls_sha256_starts( (mbedtls_sha256_context *) ctx, 1 ); +} + +static void sha224_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_sha256_update( (mbedtls_sha256_context *) ctx, input, ilen ); +} + +static void sha224_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_sha256_finish( (mbedtls_sha256_context *) ctx, output ); +} + +static void sha224_wrap( const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + mbedtls_sha256( input, ilen, output, 1 ); +} + +static void *sha224_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_sha256_context ) ); + + if( ctx != NULL ) + mbedtls_sha256_init( (mbedtls_sha256_context *) ctx ); + + return( ctx ); +} + +static void sha224_ctx_free( void *ctx ) +{ + mbedtls_sha256_free( (mbedtls_sha256_context *) ctx ); + mbedtls_free( ctx ); +} + +static void sha224_clone_wrap( void *dst, const void *src ) +{ + mbedtls_sha256_clone( (mbedtls_sha256_context *) dst, + (const mbedtls_sha256_context *) src ); +} + +static void sha224_process_wrap( void *ctx, const unsigned char *data ) +{ + mbedtls_sha256_process( (mbedtls_sha256_context *) ctx, data ); +} + +const mbedtls_md_info_t mbedtls_sha224_info = { + MBEDTLS_MD_SHA224, + "SHA224", + 28, + 64, + sha224_starts_wrap, + sha224_update_wrap, + sha224_finish_wrap, + sha224_wrap, + sha224_ctx_alloc, + sha224_ctx_free, + sha224_clone_wrap, + sha224_process_wrap, +}; + +static void sha256_starts_wrap( void *ctx ) +{ + mbedtls_sha256_starts( (mbedtls_sha256_context *) ctx, 0 ); +} + +static void sha256_wrap( const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + mbedtls_sha256( input, ilen, output, 0 ); +} + +const mbedtls_md_info_t mbedtls_sha256_info = { + MBEDTLS_MD_SHA256, + "SHA256", + 32, + 64, + sha256_starts_wrap, + sha224_update_wrap, + sha224_finish_wrap, + sha256_wrap, + sha224_ctx_alloc, + sha224_ctx_free, + sha224_clone_wrap, + sha224_process_wrap, +}; + +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + +static void sha384_starts_wrap( void *ctx ) +{ + mbedtls_sha512_starts( (mbedtls_sha512_context *) ctx, 1 ); +} + +static void sha384_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) +{ + mbedtls_sha512_update( (mbedtls_sha512_context *) ctx, input, ilen ); +} + +static void sha384_finish_wrap( void *ctx, unsigned char *output ) +{ + mbedtls_sha512_finish( (mbedtls_sha512_context *) ctx, output ); +} + +static void sha384_wrap( const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + mbedtls_sha512( input, ilen, output, 1 ); +} + +static void *sha384_ctx_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_sha512_context ) ); + + if( ctx != NULL ) + mbedtls_sha512_init( (mbedtls_sha512_context *) ctx ); + + return( ctx ); +} + +static void sha384_ctx_free( void *ctx ) +{ + mbedtls_sha512_free( (mbedtls_sha512_context *) ctx ); + mbedtls_free( ctx ); +} + +static void sha384_clone_wrap( void *dst, const void *src ) +{ + mbedtls_sha512_clone( (mbedtls_sha512_context *) dst, + (const mbedtls_sha512_context *) src ); +} + +static void sha384_process_wrap( void *ctx, const unsigned char *data ) +{ + mbedtls_sha512_process( (mbedtls_sha512_context *) ctx, data ); +} + +const mbedtls_md_info_t mbedtls_sha384_info = { + MBEDTLS_MD_SHA384, + "SHA384", + 48, + 128, + sha384_starts_wrap, + sha384_update_wrap, + sha384_finish_wrap, + sha384_wrap, + sha384_ctx_alloc, + sha384_ctx_free, + sha384_clone_wrap, + sha384_process_wrap, +}; + +static void sha512_starts_wrap( void *ctx ) +{ + mbedtls_sha512_starts( (mbedtls_sha512_context *) ctx, 0 ); +} + +static void sha512_wrap( const unsigned char *input, size_t ilen, + unsigned char *output ) +{ + mbedtls_sha512( input, ilen, output, 0 ); +} + +const mbedtls_md_info_t mbedtls_sha512_info = { + MBEDTLS_MD_SHA512, + "SHA512", + 64, + 128, + sha512_starts_wrap, + sha384_update_wrap, + sha384_finish_wrap, + sha512_wrap, + sha384_ctx_alloc, + sha384_ctx_free, + sha384_clone_wrap, + sha384_process_wrap, +}; + +#endif /* MBEDTLS_SHA512_C */ + +#endif /* MBEDTLS_MD_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/memory_buffer_alloc.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/memory_buffer_alloc.c new file mode 100644 index 0000000..545d5a2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/memory_buffer_alloc.c @@ -0,0 +1,745 @@ +/* + * Buffer-based memory allocator + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#include "mbedtls/memory_buffer_alloc.h" + +/* No need for the header guard as MBEDTLS_MEMORY_BUFFER_ALLOC_C + is dependent upon MBEDTLS_PLATFORM_C */ +#include "mbedtls/platform.h" + +#include + +#if defined(MBEDTLS_MEMORY_BACKTRACE) +#include +#endif + +#if defined(MBEDTLS_THREADING_C) +#include "mbedtls/threading.h" +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +#define MAGIC1 0xFF00AA55 +#define MAGIC2 0xEE119966 +#define MAX_BT 20 + +typedef struct _memory_header memory_header; +struct _memory_header +{ + size_t magic1; + size_t size; + size_t alloc; + memory_header *prev; + memory_header *next; + memory_header *prev_free; + memory_header *next_free; +#if defined(MBEDTLS_MEMORY_BACKTRACE) + char **trace; + size_t trace_count; +#endif + size_t magic2; +}; + +typedef struct +{ + unsigned char *buf; + size_t len; + memory_header *first; + memory_header *first_free; + int verify; +#if defined(MBEDTLS_MEMORY_DEBUG) + size_t alloc_count; + size_t free_count; + size_t total_used; + size_t maximum_used; + size_t header_count; + size_t maximum_header_count; +#endif +#if defined(MBEDTLS_THREADING_C) + mbedtls_threading_mutex_t mutex; +#endif +} +buffer_alloc_ctx; + +static buffer_alloc_ctx heap; + +#if defined(MBEDTLS_MEMORY_DEBUG) +static void debug_header( memory_header *hdr ) +{ +#if defined(MBEDTLS_MEMORY_BACKTRACE) + size_t i; +#endif + + mbedtls_fprintf( stderr, "HDR: PTR(%10zu), PREV(%10zu), NEXT(%10zu), " + "ALLOC(%zu), SIZE(%10zu)\n", + (size_t) hdr, (size_t) hdr->prev, (size_t) hdr->next, + hdr->alloc, hdr->size ); + mbedtls_fprintf( stderr, " FPREV(%10zu), FNEXT(%10zu)\n", + (size_t) hdr->prev_free, (size_t) hdr->next_free ); + +#if defined(MBEDTLS_MEMORY_BACKTRACE) + mbedtls_fprintf( stderr, "TRACE: \n" ); + for( i = 0; i < hdr->trace_count; i++ ) + mbedtls_fprintf( stderr, "%s\n", hdr->trace[i] ); + mbedtls_fprintf( stderr, "\n" ); +#endif +} + +static void debug_chain() +{ + memory_header *cur = heap.first; + + mbedtls_fprintf( stderr, "\nBlock list\n" ); + while( cur != NULL ) + { + debug_header( cur ); + cur = cur->next; + } + + mbedtls_fprintf( stderr, "Free list\n" ); + cur = heap.first_free; + + while( cur != NULL ) + { + debug_header( cur ); + cur = cur->next_free; + } +} +#endif /* MBEDTLS_MEMORY_DEBUG */ + +static int verify_header( memory_header *hdr ) +{ + if( hdr->magic1 != MAGIC1 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: MAGIC1 mismatch\n" ); +#endif + return( 1 ); + } + + if( hdr->magic2 != MAGIC2 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: MAGIC2 mismatch\n" ); +#endif + return( 1 ); + } + + if( hdr->alloc > 1 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: alloc has illegal value\n" ); +#endif + return( 1 ); + } + + if( hdr->prev != NULL && hdr->prev == hdr->next ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: prev == next\n" ); +#endif + return( 1 ); + } + + if( hdr->prev_free != NULL && hdr->prev_free == hdr->next_free ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: prev_free == next_free\n" ); +#endif + return( 1 ); + } + + return( 0 ); +} + +static int verify_chain() +{ + memory_header *prv = heap.first, *cur = heap.first->next; + + if( verify_header( heap.first ) != 0 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: verification of first header " + "failed\n" ); +#endif + return( 1 ); + } + + if( heap.first->prev != NULL ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: verification failed: " + "first->prev != NULL\n" ); +#endif + return( 1 ); + } + + while( cur != NULL ) + { + if( verify_header( cur ) != 0 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: verification of header " + "failed\n" ); +#endif + return( 1 ); + } + + if( cur->prev != prv ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: verification failed: " + "cur->prev != prv\n" ); +#endif + return( 1 ); + } + + prv = cur; + cur = cur->next; + } + + return( 0 ); +} + +static void *buffer_alloc_calloc( size_t n, size_t size ) +{ + memory_header *new, *cur = heap.first_free; + unsigned char *p; + void *ret; + size_t original_len, len; +#if defined(MBEDTLS_MEMORY_BACKTRACE) + void *trace_buffer[MAX_BT]; + size_t trace_cnt; +#endif + + if( heap.buf == NULL || heap.first == NULL ) + return( NULL ); + + original_len = len = n * size; + + if( n != 0 && len / n != size ) + return( NULL ); + + if( len % MBEDTLS_MEMORY_ALIGN_MULTIPLE ) + { + len -= len % MBEDTLS_MEMORY_ALIGN_MULTIPLE; + len += MBEDTLS_MEMORY_ALIGN_MULTIPLE; + } + + // Find block that fits + // + while( cur != NULL ) + { + if( cur->size >= len ) + break; + + cur = cur->next_free; + } + + if( cur == NULL ) + return( NULL ); + + if( cur->alloc != 0 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: block in free_list but allocated " + "data\n" ); +#endif + mbedtls_exit( 1 ); + } + +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.alloc_count++; +#endif + + // Found location, split block if > memory_header + 4 room left + // + if( cur->size - len < sizeof(memory_header) + + MBEDTLS_MEMORY_ALIGN_MULTIPLE ) + { + cur->alloc = 1; + + // Remove from free_list + // + if( cur->prev_free != NULL ) + cur->prev_free->next_free = cur->next_free; + else + heap.first_free = cur->next_free; + + if( cur->next_free != NULL ) + cur->next_free->prev_free = cur->prev_free; + + cur->prev_free = NULL; + cur->next_free = NULL; + +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.total_used += cur->size; + if( heap.total_used > heap.maximum_used ) + heap.maximum_used = heap.total_used; +#endif +#if defined(MBEDTLS_MEMORY_BACKTRACE) + trace_cnt = backtrace( trace_buffer, MAX_BT ); + cur->trace = backtrace_symbols( trace_buffer, trace_cnt ); + cur->trace_count = trace_cnt; +#endif + + if( ( heap.verify & MBEDTLS_MEMORY_VERIFY_ALLOC ) && verify_chain() != 0 ) + mbedtls_exit( 1 ); + + ret = (unsigned char *) cur + sizeof( memory_header ); + memset( ret, 0, original_len ); + + return( ret ); + } + + p = ( (unsigned char *) cur ) + sizeof(memory_header) + len; + new = (memory_header *) p; + + new->size = cur->size - len - sizeof(memory_header); + new->alloc = 0; + new->prev = cur; + new->next = cur->next; +#if defined(MBEDTLS_MEMORY_BACKTRACE) + new->trace = NULL; + new->trace_count = 0; +#endif + new->magic1 = MAGIC1; + new->magic2 = MAGIC2; + + if( new->next != NULL ) + new->next->prev = new; + + // Replace cur with new in free_list + // + new->prev_free = cur->prev_free; + new->next_free = cur->next_free; + if( new->prev_free != NULL ) + new->prev_free->next_free = new; + else + heap.first_free = new; + + if( new->next_free != NULL ) + new->next_free->prev_free = new; + + cur->alloc = 1; + cur->size = len; + cur->next = new; + cur->prev_free = NULL; + cur->next_free = NULL; + +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.header_count++; + if( heap.header_count > heap.maximum_header_count ) + heap.maximum_header_count = heap.header_count; + heap.total_used += cur->size; + if( heap.total_used > heap.maximum_used ) + heap.maximum_used = heap.total_used; +#endif +#if defined(MBEDTLS_MEMORY_BACKTRACE) + trace_cnt = backtrace( trace_buffer, MAX_BT ); + cur->trace = backtrace_symbols( trace_buffer, trace_cnt ); + cur->trace_count = trace_cnt; +#endif + + if( ( heap.verify & MBEDTLS_MEMORY_VERIFY_ALLOC ) && verify_chain() != 0 ) + mbedtls_exit( 1 ); + + ret = (unsigned char *) cur + sizeof( memory_header ); + memset( ret, 0, original_len ); + + return( ret ); +} + +static void buffer_alloc_free( void *ptr ) +{ + memory_header *hdr, *old = NULL; + unsigned char *p = (unsigned char *) ptr; + + if( ptr == NULL || heap.buf == NULL || heap.first == NULL ) + return; + + if( p < heap.buf || p > heap.buf + heap.len ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: mbedtls_free() outside of managed " + "space\n" ); +#endif + mbedtls_exit( 1 ); + } + + p -= sizeof(memory_header); + hdr = (memory_header *) p; + + if( verify_header( hdr ) != 0 ) + mbedtls_exit( 1 ); + + if( hdr->alloc != 1 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_fprintf( stderr, "FATAL: mbedtls_free() on unallocated " + "data\n" ); +#endif + mbedtls_exit( 1 ); + } + + hdr->alloc = 0; + +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.free_count++; + heap.total_used -= hdr->size; +#endif + +#if defined(MBEDTLS_MEMORY_BACKTRACE) + free( hdr->trace ); + hdr->trace = NULL; + hdr->trace_count = 0; +#endif + + // Regroup with block before + // + if( hdr->prev != NULL && hdr->prev->alloc == 0 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.header_count--; +#endif + hdr->prev->size += sizeof(memory_header) + hdr->size; + hdr->prev->next = hdr->next; + old = hdr; + hdr = hdr->prev; + + if( hdr->next != NULL ) + hdr->next->prev = hdr; + + memset( old, 0, sizeof(memory_header) ); + } + + // Regroup with block after + // + if( hdr->next != NULL && hdr->next->alloc == 0 ) + { +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.header_count--; +#endif + hdr->size += sizeof(memory_header) + hdr->next->size; + old = hdr->next; + hdr->next = hdr->next->next; + + if( hdr->prev_free != NULL || hdr->next_free != NULL ) + { + if( hdr->prev_free != NULL ) + hdr->prev_free->next_free = hdr->next_free; + else + heap.first_free = hdr->next_free; + + if( hdr->next_free != NULL ) + hdr->next_free->prev_free = hdr->prev_free; + } + + hdr->prev_free = old->prev_free; + hdr->next_free = old->next_free; + + if( hdr->prev_free != NULL ) + hdr->prev_free->next_free = hdr; + else + heap.first_free = hdr; + + if( hdr->next_free != NULL ) + hdr->next_free->prev_free = hdr; + + if( hdr->next != NULL ) + hdr->next->prev = hdr; + + memset( old, 0, sizeof(memory_header) ); + } + + // Prepend to free_list if we have not merged + // (Does not have to stay in same order as prev / next list) + // + if( old == NULL ) + { + hdr->next_free = heap.first_free; + if( heap.first_free != NULL ) + heap.first_free->prev_free = hdr; + heap.first_free = hdr; + } + + if( ( heap.verify & MBEDTLS_MEMORY_VERIFY_FREE ) && verify_chain() != 0 ) + mbedtls_exit( 1 ); +} + +void mbedtls_memory_buffer_set_verify( int verify ) +{ + heap.verify = verify; +} + +int mbedtls_memory_buffer_alloc_verify() +{ + return verify_chain(); +} + +#if defined(MBEDTLS_MEMORY_DEBUG) +void mbedtls_memory_buffer_alloc_status() +{ + mbedtls_fprintf( stderr, + "Current use: %zu blocks / %zu bytes, max: %zu blocks / " + "%zu bytes (total %zu bytes), alloc / free: %zu / %zu\n", + heap.header_count, heap.total_used, + heap.maximum_header_count, heap.maximum_used, + heap.maximum_header_count * sizeof( memory_header ) + + heap.maximum_used, + heap.alloc_count, heap.free_count ); + + if( heap.first->next == NULL ) + mbedtls_fprintf( stderr, "All memory de-allocated in stack buffer\n" ); + else + { + mbedtls_fprintf( stderr, "Memory currently allocated:\n" ); + debug_chain(); + } +} + +void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks ) +{ + *max_used = heap.maximum_used; + *max_blocks = heap.maximum_header_count; +} + +void mbedtls_memory_buffer_alloc_max_reset( void ) +{ + heap.maximum_used = 0; + heap.maximum_header_count = 0; +} + +void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks ) +{ + *cur_used = heap.total_used; + *cur_blocks = heap.header_count; +} +#endif /* MBEDTLS_MEMORY_DEBUG */ + +#if defined(MBEDTLS_THREADING_C) +static void *buffer_alloc_calloc_mutexed( size_t n, size_t size ) +{ + void *buf; + if( mbedtls_mutex_lock( &heap.mutex ) != 0 ) + return( NULL ); + buf = buffer_alloc_calloc( n, size ); + if( mbedtls_mutex_unlock( &heap.mutex ) ) + return( NULL ); + return( buf ); +} + +static void buffer_alloc_free_mutexed( void *ptr ) +{ + /* We have to good option here, but corrupting the heap seems + * worse than loosing memory. */ + if( mbedtls_mutex_lock( &heap.mutex ) ) + return; + buffer_alloc_free( ptr ); + (void) mbedtls_mutex_unlock( &heap.mutex ); +} +#endif /* MBEDTLS_THREADING_C */ + +void mbedtls_memory_buffer_alloc_init( unsigned char *buf, size_t len ) +{ + memset( &heap, 0, sizeof(buffer_alloc_ctx) ); + memset( buf, 0, len ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &heap.mutex ); + mbedtls_platform_set_calloc_free( buffer_alloc_calloc_mutexed, + buffer_alloc_free_mutexed ); +#else + mbedtls_platform_set_calloc_free( buffer_alloc_calloc, buffer_alloc_free ); +#endif + + if( (size_t) buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE ) + { + /* Adjust len first since buf is used in the computation */ + len -= MBEDTLS_MEMORY_ALIGN_MULTIPLE + - (size_t) buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE; + buf += MBEDTLS_MEMORY_ALIGN_MULTIPLE + - (size_t) buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE; + } + + heap.buf = buf; + heap.len = len; + + heap.first = (memory_header *) buf; + heap.first->size = len - sizeof(memory_header); + heap.first->magic1 = MAGIC1; + heap.first->magic2 = MAGIC2; + heap.first_free = heap.first; +} + +void mbedtls_memory_buffer_alloc_free() +{ +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &heap.mutex ); +#endif + mbedtls_zeroize( &heap, sizeof(buffer_alloc_ctx) ); +} + +#if defined(MBEDTLS_SELF_TEST) +static int check_pointer( void *p ) +{ + if( p == NULL ) + return( -1 ); + + if( (size_t) p % MBEDTLS_MEMORY_ALIGN_MULTIPLE != 0 ) + return( -1 ); + + return( 0 ); +} + +static int check_all_free( ) +{ + if( +#if defined(MBEDTLS_MEMORY_DEBUG) + heap.total_used != 0 || +#endif + heap.first != heap.first_free || + (void *) heap.first != (void *) heap.buf ) + { + return( -1 ); + } + + return( 0 ); +} + +#define TEST_ASSERT( condition ) \ + if( ! (condition) ) \ + { \ + if( verbose != 0 ) \ + mbedtls_printf( "failed\n" ); \ + \ + ret = 1; \ + goto cleanup; \ + } + +int mbedtls_memory_buffer_alloc_self_test( int verbose ) +{ + unsigned char buf[1024]; + unsigned char *p, *q, *r, *end; + int ret = 0; + + if( verbose != 0 ) + mbedtls_printf( " MBA test #1 (basic alloc-free cycle): " ); + + mbedtls_memory_buffer_alloc_init( buf, sizeof( buf ) ); + + p = mbedtls_calloc( 1, 1 ); + q = mbedtls_calloc( 1, 128 ); + r = mbedtls_calloc( 1, 16 ); + + TEST_ASSERT( check_pointer( p ) == 0 && + check_pointer( q ) == 0 && + check_pointer( r ) == 0 ); + + mbedtls_free( r ); + mbedtls_free( q ); + mbedtls_free( p ); + + TEST_ASSERT( check_all_free( ) == 0 ); + + /* Memorize end to compare with the next test */ + end = heap.buf + heap.len; + + mbedtls_memory_buffer_alloc_free( ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " MBA test #2 (buf not aligned): " ); + + mbedtls_memory_buffer_alloc_init( buf + 1, sizeof( buf ) - 1 ); + + TEST_ASSERT( heap.buf + heap.len == end ); + + p = mbedtls_calloc( 1, 1 ); + q = mbedtls_calloc( 1, 128 ); + r = mbedtls_calloc( 1, 16 ); + + TEST_ASSERT( check_pointer( p ) == 0 && + check_pointer( q ) == 0 && + check_pointer( r ) == 0 ); + + mbedtls_free( r ); + mbedtls_free( q ); + mbedtls_free( p ); + + TEST_ASSERT( check_all_free( ) == 0 ); + + mbedtls_memory_buffer_alloc_free( ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " MBA test #3 (full): " ); + + mbedtls_memory_buffer_alloc_init( buf, sizeof( buf ) ); + + p = mbedtls_calloc( 1, sizeof( buf ) - sizeof( memory_header ) ); + + TEST_ASSERT( check_pointer( p ) == 0 ); + TEST_ASSERT( mbedtls_calloc( 1, 1 ) == NULL ); + + mbedtls_free( p ); + + p = mbedtls_calloc( 1, sizeof( buf ) - 2 * sizeof( memory_header ) - 16 ); + q = mbedtls_calloc( 1, 16 ); + + TEST_ASSERT( check_pointer( p ) == 0 && check_pointer( q ) == 0 ); + TEST_ASSERT( mbedtls_calloc( 1, 1 ) == NULL ); + + mbedtls_free( q ); + + TEST_ASSERT( mbedtls_calloc( 1, 17 ) == NULL ); + + mbedtls_free( p ); + + TEST_ASSERT( check_all_free( ) == 0 ); + + mbedtls_memory_buffer_alloc_free( ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + +cleanup: + mbedtls_memory_buffer_alloc_free( ); + + return( ret ); +} +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/net_sockets.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/net_sockets.c new file mode 100644 index 0000000..80be6ec --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/net_sockets.c @@ -0,0 +1,586 @@ +/* + * TCP/IP or UDP/IP networking functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_NET_C) + +#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ + !defined(__APPLE__) && !defined(_WIN32) +#error "This module only works on Unix and Windows, see MBEDTLS_NET_C in config.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#endif + +#include "mbedtls/net_sockets.h" + +#include + +#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ + !defined(EFI32) + +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +/* Enables getaddrinfo() & Co */ +#define _WIN32_WINNT 0x0501 +#include + +#include +#include + +#if defined(_MSC_VER) +#if defined(_WIN32_WCE) +#pragma comment( lib, "ws2.lib" ) +#else +#pragma comment( lib, "ws2_32.lib" ) +#endif +#endif /* _MSC_VER */ + +#define read(fd,buf,len) recv(fd,(char*)buf,(int) len,0) +#define write(fd,buf,len) send(fd,(char*)buf,(int) len,0) +#define close(fd) closesocket(fd) + +static int wsa_init_done = 0; + +#else /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ + +/* Some MS functions want int and MSVC warns if we pass size_t, + * but the standard fucntions use socklen_t, so cast only for MSVC */ +#if defined(_MSC_VER) +#define MSVC_INT_CAST (int) +#else +#define MSVC_INT_CAST +#endif + +#include + +#include + +#include + +/* + * Prepare for using the sockets interface + */ +static int net_prepare( void ) +{ +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) + WSADATA wsaData; + + if( wsa_init_done == 0 ) + { + if( WSAStartup( MAKEWORD(2,0), &wsaData ) != 0 ) + return( MBEDTLS_ERR_NET_SOCKET_FAILED ); + + wsa_init_done = 1; + } +#else +#if !defined(EFIX64) && !defined(EFI32) + signal( SIGPIPE, SIG_IGN ); +#endif +#endif + return( 0 ); +} + +/* + * Initialize a context + */ +void mbedtls_net_init( mbedtls_net_context *ctx ) +{ + ctx->fd = -1; +} + +/* + * Initiate a TCP connection with host:port and the given protocol + */ +int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, + const char *port, int proto ) +{ + int ret; + struct addrinfo hints, *addr_list, *cur; + + if( ( ret = net_prepare() ) != 0 ) + return( ret ); + + /* Do name resolution with both IPv6 and IPv4 */ + memset( &hints, 0, sizeof( hints ) ); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = proto == MBEDTLS_NET_PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM; + hints.ai_protocol = proto == MBEDTLS_NET_PROTO_UDP ? IPPROTO_UDP : IPPROTO_TCP; + + if( getaddrinfo( host, port, &hints, &addr_list ) != 0 ) + return( MBEDTLS_ERR_NET_UNKNOWN_HOST ); + + /* Try the sockaddrs until a connection succeeds */ + ret = MBEDTLS_ERR_NET_UNKNOWN_HOST; + for( cur = addr_list; cur != NULL; cur = cur->ai_next ) + { + ctx->fd = (int) socket( cur->ai_family, cur->ai_socktype, + cur->ai_protocol ); + if( ctx->fd < 0 ) + { + ret = MBEDTLS_ERR_NET_SOCKET_FAILED; + continue; + } + + if( connect( ctx->fd, cur->ai_addr, MSVC_INT_CAST cur->ai_addrlen ) == 0 ) + { + ret = 0; + break; + } + + close( ctx->fd ); + ret = MBEDTLS_ERR_NET_CONNECT_FAILED; + } + + freeaddrinfo( addr_list ); + + return( ret ); +} + +/* + * Create a listening socket on bind_ip:port + */ +int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto ) +{ + int n, ret; + struct addrinfo hints, *addr_list, *cur; + + if( ( ret = net_prepare() ) != 0 ) + return( ret ); + + /* Bind to IPv6 and/or IPv4, but only in the desired protocol */ + memset( &hints, 0, sizeof( hints ) ); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = proto == MBEDTLS_NET_PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM; + hints.ai_protocol = proto == MBEDTLS_NET_PROTO_UDP ? IPPROTO_UDP : IPPROTO_TCP; + if( bind_ip == NULL ) + hints.ai_flags = AI_PASSIVE; + + if( getaddrinfo( bind_ip, port, &hints, &addr_list ) != 0 ) + return( MBEDTLS_ERR_NET_UNKNOWN_HOST ); + + /* Try the sockaddrs until a binding succeeds */ + ret = MBEDTLS_ERR_NET_UNKNOWN_HOST; + for( cur = addr_list; cur != NULL; cur = cur->ai_next ) + { + ctx->fd = (int) socket( cur->ai_family, cur->ai_socktype, + cur->ai_protocol ); + if( ctx->fd < 0 ) + { + ret = MBEDTLS_ERR_NET_SOCKET_FAILED; + continue; + } + + n = 1; + if( setsockopt( ctx->fd, SOL_SOCKET, SO_REUSEADDR, + (const char *) &n, sizeof( n ) ) != 0 ) + { + close( ctx->fd ); + ret = MBEDTLS_ERR_NET_SOCKET_FAILED; + continue; + } + + if( bind( ctx->fd, cur->ai_addr, MSVC_INT_CAST cur->ai_addrlen ) != 0 ) + { + close( ctx->fd ); + ret = MBEDTLS_ERR_NET_BIND_FAILED; + continue; + } + + /* Listen only makes sense for TCP */ + if( proto == MBEDTLS_NET_PROTO_TCP ) + { + if( listen( ctx->fd, MBEDTLS_NET_LISTEN_BACKLOG ) != 0 ) + { + close( ctx->fd ); + ret = MBEDTLS_ERR_NET_LISTEN_FAILED; + continue; + } + } + + /* Bind was successful */ + ret = 0; + break; + } + + freeaddrinfo( addr_list ); + + return( ret ); + +} + +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) +/* + * Check if the requested operation would be blocking on a non-blocking socket + * and thus 'failed' with a negative return value. + */ +static int net_would_block( const mbedtls_net_context *ctx ) +{ + ((void) ctx); + return( WSAGetLastError() == WSAEWOULDBLOCK ); +} +#else +/* + * Check if the requested operation would be blocking on a non-blocking socket + * and thus 'failed' with a negative return value. + * + * Note: on a blocking socket this function always returns 0! + */ +static int net_would_block( const mbedtls_net_context *ctx ) +{ + /* + * Never return 'WOULD BLOCK' on a non-blocking socket + */ + if( ( fcntl( ctx->fd, F_GETFL ) & O_NONBLOCK ) != O_NONBLOCK ) + return( 0 ); + + switch( errno ) + { +#if defined EAGAIN + case EAGAIN: +#endif +#if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: +#endif + return( 1 ); + } + return( 0 ); +} +#endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ + +/* + * Accept a connection from a remote client + */ +int mbedtls_net_accept( mbedtls_net_context *bind_ctx, + mbedtls_net_context *client_ctx, + void *client_ip, size_t buf_size, size_t *ip_len ) +{ + int ret; + int type; + + struct sockaddr_storage client_addr; + +#if defined(__socklen_t_defined) || defined(_SOCKLEN_T) || \ + defined(_SOCKLEN_T_DECLARED) || defined(__DEFINED_socklen_t) + socklen_t n = (socklen_t) sizeof( client_addr ); + socklen_t type_len = (socklen_t) sizeof( type ); +#else + int n = (int) sizeof( client_addr ); + int type_len = (int) sizeof( type ); +#endif + + /* Is this a TCP or UDP socket? */ + if( getsockopt( bind_ctx->fd, SOL_SOCKET, SO_TYPE, + (void *) &type, &type_len ) != 0 || + ( type != SOCK_STREAM && type != SOCK_DGRAM ) ) + { + return( MBEDTLS_ERR_NET_ACCEPT_FAILED ); + } + + if( type == SOCK_STREAM ) + { + /* TCP: actual accept() */ + ret = client_ctx->fd = (int) accept( bind_ctx->fd, + (struct sockaddr *) &client_addr, &n ); + } + else + { + /* UDP: wait for a message, but keep it in the queue */ + char buf[1] = { 0 }; + + ret = (int) recvfrom( bind_ctx->fd, buf, sizeof( buf ), MSG_PEEK, + (struct sockaddr *) &client_addr, &n ); + +#if defined(_WIN32) + if( ret == SOCKET_ERROR && + WSAGetLastError() == WSAEMSGSIZE ) + { + /* We know buf is too small, thanks, just peeking here */ + ret = 0; + } +#endif + } + + if( ret < 0 ) + { + if( net_would_block( bind_ctx ) != 0 ) + return( MBEDTLS_ERR_SSL_WANT_READ ); + + return( MBEDTLS_ERR_NET_ACCEPT_FAILED ); + } + + /* UDP: hijack the listening socket to communicate with the client, + * then bind a new socket to accept new connections */ + if( type != SOCK_STREAM ) + { + struct sockaddr_storage local_addr; + int one = 1; + + if( connect( bind_ctx->fd, (struct sockaddr *) &client_addr, n ) != 0 ) + return( MBEDTLS_ERR_NET_ACCEPT_FAILED ); + + client_ctx->fd = bind_ctx->fd; + bind_ctx->fd = -1; /* In case we exit early */ + + n = sizeof( struct sockaddr_storage ); + if( getsockname( client_ctx->fd, + (struct sockaddr *) &local_addr, &n ) != 0 || + ( bind_ctx->fd = (int) socket( local_addr.ss_family, + SOCK_DGRAM, IPPROTO_UDP ) ) < 0 || + setsockopt( bind_ctx->fd, SOL_SOCKET, SO_REUSEADDR, + (const char *) &one, sizeof( one ) ) != 0 ) + { + return( MBEDTLS_ERR_NET_SOCKET_FAILED ); + } + + if( bind( bind_ctx->fd, (struct sockaddr *) &local_addr, n ) != 0 ) + { + return( MBEDTLS_ERR_NET_BIND_FAILED ); + } + } + + if( client_ip != NULL ) + { + if( client_addr.ss_family == AF_INET ) + { + struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr; + *ip_len = sizeof( addr4->sin_addr.s_addr ); + + if( buf_size < *ip_len ) + return( MBEDTLS_ERR_NET_BUFFER_TOO_SMALL ); + + memcpy( client_ip, &addr4->sin_addr.s_addr, *ip_len ); + } + else + { + struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr; + *ip_len = sizeof( addr6->sin6_addr.s6_addr ); + + if( buf_size < *ip_len ) + return( MBEDTLS_ERR_NET_BUFFER_TOO_SMALL ); + + memcpy( client_ip, &addr6->sin6_addr.s6_addr, *ip_len); + } + } + + return( 0 ); +} + +/* + * Set the socket blocking or non-blocking + */ +int mbedtls_net_set_block( mbedtls_net_context *ctx ) +{ +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) + u_long n = 0; + return( ioctlsocket( ctx->fd, FIONBIO, &n ) ); +#else + return( fcntl( ctx->fd, F_SETFL, fcntl( ctx->fd, F_GETFL ) & ~O_NONBLOCK ) ); +#endif +} + +int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ) +{ +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) + u_long n = 1; + return( ioctlsocket( ctx->fd, FIONBIO, &n ) ); +#else + return( fcntl( ctx->fd, F_SETFL, fcntl( ctx->fd, F_GETFL ) | O_NONBLOCK ) ); +#endif +} + +/* + * Portable usleep helper + */ +void mbedtls_net_usleep( unsigned long usec ) +{ +#if defined(_WIN32) + Sleep( ( usec + 999 ) / 1000 ); +#else + struct timeval tv; + tv.tv_sec = usec / 1000000; +#if defined(__unix__) || defined(__unix) || \ + ( defined(__APPLE__) && defined(__MACH__) ) + tv.tv_usec = (suseconds_t) usec % 1000000; +#else + tv.tv_usec = usec % 1000000; +#endif + select( 0, NULL, NULL, NULL, &tv ); +#endif +} + +/* + * Read at most 'len' characters + */ +int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ) +{ + int ret; + int fd = ((mbedtls_net_context *) ctx)->fd; + + if( fd < 0 ) + return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + + ret = (int) read( fd, buf, len ); + + if( ret < 0 ) + { + if( net_would_block( ctx ) != 0 ) + return( MBEDTLS_ERR_SSL_WANT_READ ); + +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) + if( WSAGetLastError() == WSAECONNRESET ) + return( MBEDTLS_ERR_NET_CONN_RESET ); +#else + if( errno == EPIPE || errno == ECONNRESET ) + return( MBEDTLS_ERR_NET_CONN_RESET ); + + if( errno == EINTR ) + return( MBEDTLS_ERR_SSL_WANT_READ ); +#endif + + return( MBEDTLS_ERR_NET_RECV_FAILED ); + } + + return( ret ); +} + +/* + * Read at most 'len' characters, blocking for at most 'timeout' ms + */ +int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, + uint32_t timeout ) +{ + int ret; + struct timeval tv; + fd_set read_fds; + int fd = ((mbedtls_net_context *) ctx)->fd; + + if( fd < 0 ) + return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + + FD_ZERO( &read_fds ); + FD_SET( fd, &read_fds ); + + tv.tv_sec = timeout / 1000; + tv.tv_usec = ( timeout % 1000 ) * 1000; + + ret = select( fd + 1, &read_fds, NULL, NULL, timeout == 0 ? NULL : &tv ); + + /* Zero fds ready means we timed out */ + if( ret == 0 ) + return( MBEDTLS_ERR_SSL_TIMEOUT ); + + if( ret < 0 ) + { +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) + if( WSAGetLastError() == WSAEINTR ) + return( MBEDTLS_ERR_SSL_WANT_READ ); +#else + if( errno == EINTR ) + return( MBEDTLS_ERR_SSL_WANT_READ ); +#endif + + return( MBEDTLS_ERR_NET_RECV_FAILED ); + } + + /* This call will not block */ + return( mbedtls_net_recv( ctx, buf, len ) ); +} + +/* + * Write at most 'len' characters + */ +int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ) +{ + int ret; + int fd = ((mbedtls_net_context *) ctx)->fd; + + if( fd < 0 ) + return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + + ret = (int) write( fd, buf, len ); + + if( ret < 0 ) + { + if( net_would_block( ctx ) != 0 ) + return( MBEDTLS_ERR_SSL_WANT_WRITE ); + +#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ + !defined(EFI32) + if( WSAGetLastError() == WSAECONNRESET ) + return( MBEDTLS_ERR_NET_CONN_RESET ); +#else + if( errno == EPIPE || errno == ECONNRESET ) + return( MBEDTLS_ERR_NET_CONN_RESET ); + + if( errno == EINTR ) + return( MBEDTLS_ERR_SSL_WANT_WRITE ); +#endif + + return( MBEDTLS_ERR_NET_SEND_FAILED ); + } + + return( ret ); +} + +/* + * Gracefully close the connection + */ +void mbedtls_net_free( mbedtls_net_context *ctx ) +{ + if( ctx->fd == -1 ) + return; + + shutdown( ctx->fd, 2 ); + close( ctx->fd ); + + ctx->fd = -1; +} + +#endif /* MBEDTLS_NET_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/oid.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/oid.c new file mode 100644 index 0000000..f13826e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/oid.c @@ -0,0 +1,710 @@ +/** + * \file oid.c + * + * \brief Object Identifier (OID) database + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_OID_C) + +#include "mbedtls/oid.h" +#include "mbedtls/rsa.h" + +#include +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#define mbedtls_snprintf snprintf +#endif + +#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) +#include "mbedtls/x509.h" +#endif + +/* + * Macro to automatically add the size of #define'd OIDs + */ +#define ADD_LEN(s) s, MBEDTLS_OID_SIZE(s) + +/* + * Macro to generate an internal function for oid_XXX_from_asn1() (used by + * the other functions) + */ +#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \ +static const TYPE_T * oid_ ## NAME ## _from_asn1( const mbedtls_asn1_buf *oid ) \ +{ \ + const TYPE_T *p = LIST; \ + const mbedtls_oid_descriptor_t *cur = (const mbedtls_oid_descriptor_t *) p; \ + if( p == NULL || oid == NULL ) return( NULL ); \ + while( cur->asn1 != NULL ) { \ + if( cur->asn1_len == oid->len && \ + memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \ + return( p ); \ + } \ + p++; \ + cur = (const mbedtls_oid_descriptor_t *) p; \ + } \ + return( NULL ); \ +} + +/* + * Macro to generate a function for retrieving a single attribute from the + * descriptor of an mbedtls_oid_descriptor_t wrapper. + */ +#define FN_OID_GET_DESCRIPTOR_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \ +int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \ +{ \ + const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \ + if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \ + *ATTR1 = data->descriptor.ATTR1; \ + return( 0 ); \ +} + +/* + * Macro to generate a function for retrieving a single attribute from an + * mbedtls_oid_descriptor_t wrapper. + */ +#define FN_OID_GET_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \ +int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \ +{ \ + const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \ + if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \ + *ATTR1 = data->ATTR1; \ + return( 0 ); \ +} + +/* + * Macro to generate a function for retrieving two attributes from an + * mbedtls_oid_descriptor_t wrapper. + */ +#define FN_OID_GET_ATTR2(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1, \ + ATTR2_TYPE, ATTR2) \ +int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 ) \ +{ \ + const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \ + if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \ + *ATTR1 = data->ATTR1; \ + *ATTR2 = data->ATTR2; \ + return( 0 ); \ +} + +/* + * Macro to generate a function for retrieving the OID based on a single + * attribute from a mbedtls_oid_descriptor_t wrapper. + */ +#define FN_OID_GET_OID_BY_ATTR1(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1) \ +int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \ +{ \ + const TYPE_T *cur = LIST; \ + while( cur->descriptor.asn1 != NULL ) { \ + if( cur->ATTR1 == ATTR1 ) { \ + *oid = cur->descriptor.asn1; \ + *olen = cur->descriptor.asn1_len; \ + return( 0 ); \ + } \ + cur++; \ + } \ + return( MBEDTLS_ERR_OID_NOT_FOUND ); \ +} + +/* + * Macro to generate a function for retrieving the OID based on two + * attributes from a mbedtls_oid_descriptor_t wrapper. + */ +#define FN_OID_GET_OID_BY_ATTR2(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1, \ + ATTR2_TYPE, ATTR2) \ +int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \ + size_t *olen ) \ +{ \ + const TYPE_T *cur = LIST; \ + while( cur->descriptor.asn1 != NULL ) { \ + if( cur->ATTR1 == ATTR1 && cur->ATTR2 == ATTR2 ) { \ + *oid = cur->descriptor.asn1; \ + *olen = cur->descriptor.asn1_len; \ + return( 0 ); \ + } \ + cur++; \ + } \ + return( MBEDTLS_ERR_OID_NOT_FOUND ); \ +} + +#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) +/* + * For X520 attribute types + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + const char *short_name; +} oid_x520_attr_t; + +static const oid_x520_attr_t oid_x520_attr_type[] = +{ + { + { ADD_LEN( MBEDTLS_OID_AT_CN ), "id-at-commonName", "Common Name" }, + "CN", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_COUNTRY ), "id-at-countryName", "Country" }, + "C", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_LOCALITY ), "id-at-locality", "Locality" }, + "L", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_STATE ), "id-at-state", "State" }, + "ST", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_ORGANIZATION ),"id-at-organizationName", "Organization" }, + "O", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_ORG_UNIT ), "id-at-organizationalUnitName", "Org Unit" }, + "OU", + }, + { + { ADD_LEN( MBEDTLS_OID_PKCS9_EMAIL ), "emailAddress", "E-mail address" }, + "emailAddress", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_SERIAL_NUMBER ),"id-at-serialNumber", "Serial number" }, + "serialNumber", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_POSTAL_ADDRESS ),"id-at-postalAddress", "Postal address" }, + "postalAddress", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_POSTAL_CODE ), "id-at-postalCode", "Postal code" }, + "postalCode", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_SUR_NAME ), "id-at-surName", "Surname" }, + "SN", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_GIVEN_NAME ), "id-at-givenName", "Given name" }, + "GN", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_INITIALS ), "id-at-initials", "Initials" }, + "initials", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_GENERATION_QUALIFIER ), "id-at-generationQualifier", "Generation qualifier" }, + "generationQualifier", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_TITLE ), "id-at-title", "Title" }, + "title", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_DN_QUALIFIER ),"id-at-dnQualifier", "Distinguished Name qualifier" }, + "dnQualifier", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_PSEUDONYM ), "id-at-pseudonym", "Pseudonym" }, + "pseudonym", + }, + { + { ADD_LEN( MBEDTLS_OID_DOMAIN_COMPONENT ), "id-domainComponent", "Domain component" }, + "DC", + }, + { + { ADD_LEN( MBEDTLS_OID_AT_UNIQUE_IDENTIFIER ), "id-at-uniqueIdentifier", "Unique Identifier" }, + "uniqueIdentifier", + }, + { + { NULL, 0, NULL, NULL }, + NULL, + } +}; + +FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type) +FN_OID_GET_ATTR1(mbedtls_oid_get_attr_short_name, oid_x520_attr_t, x520_attr, const char *, short_name) + +/* + * For X509 extensions + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + int ext_type; +} oid_x509_ext_t; + +static const oid_x509_ext_t oid_x509_ext[] = +{ + { + { ADD_LEN( MBEDTLS_OID_BASIC_CONSTRAINTS ), "id-ce-basicConstraints", "Basic Constraints" }, + MBEDTLS_X509_EXT_BASIC_CONSTRAINTS, + }, + { + { ADD_LEN( MBEDTLS_OID_KEY_USAGE ), "id-ce-keyUsage", "Key Usage" }, + MBEDTLS_X509_EXT_KEY_USAGE, + }, + { + { ADD_LEN( MBEDTLS_OID_EXTENDED_KEY_USAGE ), "id-ce-extKeyUsage", "Extended Key Usage" }, + MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE, + }, + { + { ADD_LEN( MBEDTLS_OID_SUBJECT_ALT_NAME ), "id-ce-subjectAltName", "Subject Alt Name" }, + MBEDTLS_X509_EXT_SUBJECT_ALT_NAME, + }, + { + { ADD_LEN( MBEDTLS_OID_NS_CERT_TYPE ), "id-netscape-certtype", "Netscape Certificate Type" }, + MBEDTLS_X509_EXT_NS_CERT_TYPE, + }, + { + { NULL, 0, NULL, NULL }, + 0, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_x509_ext_t, x509_ext, oid_x509_ext) +FN_OID_GET_ATTR1(mbedtls_oid_get_x509_ext_type, oid_x509_ext_t, x509_ext, int, ext_type) + +static const mbedtls_oid_descriptor_t oid_ext_key_usage[] = +{ + { ADD_LEN( MBEDTLS_OID_SERVER_AUTH ), "id-kp-serverAuth", "TLS Web Server Authentication" }, + { ADD_LEN( MBEDTLS_OID_CLIENT_AUTH ), "id-kp-clientAuth", "TLS Web Client Authentication" }, + { ADD_LEN( MBEDTLS_OID_CODE_SIGNING ), "id-kp-codeSigning", "Code Signing" }, + { ADD_LEN( MBEDTLS_OID_EMAIL_PROTECTION ), "id-kp-emailProtection", "E-mail Protection" }, + { ADD_LEN( MBEDTLS_OID_TIME_STAMPING ), "id-kp-timeStamping", "Time Stamping" }, + { ADD_LEN( MBEDTLS_OID_OCSP_SIGNING ), "id-kp-OCSPSigning", "OCSP Signing" }, + { NULL, 0, NULL, NULL }, +}; + +FN_OID_TYPED_FROM_ASN1(mbedtls_oid_descriptor_t, ext_key_usage, oid_ext_key_usage) +FN_OID_GET_ATTR1(mbedtls_oid_get_extended_key_usage, mbedtls_oid_descriptor_t, ext_key_usage, const char *, description) +#endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */ + +#if defined(MBEDTLS_MD_C) +/* + * For SignatureAlgorithmIdentifier + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + mbedtls_md_type_t md_alg; + mbedtls_pk_type_t pk_alg; +} oid_sig_alg_t; + +static const oid_sig_alg_t oid_sig_alg[] = +{ +#if defined(MBEDTLS_RSA_C) +#if defined(MBEDTLS_MD2_C) + { + { ADD_LEN( MBEDTLS_OID_PKCS1_MD2 ), "md2WithRSAEncryption", "RSA with MD2" }, + MBEDTLS_MD_MD2, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_MD2_C */ +#if defined(MBEDTLS_MD4_C) + { + { ADD_LEN( MBEDTLS_OID_PKCS1_MD4 ), "md4WithRSAEncryption", "RSA with MD4" }, + MBEDTLS_MD_MD4, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_MD4_C */ +#if defined(MBEDTLS_MD5_C) + { + { ADD_LEN( MBEDTLS_OID_PKCS1_MD5 ), "md5WithRSAEncryption", "RSA with MD5" }, + MBEDTLS_MD_MD5, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_MD5_C */ +#if defined(MBEDTLS_SHA1_C) + { + { ADD_LEN( MBEDTLS_OID_PKCS1_SHA1 ), "sha-1WithRSAEncryption", "RSA with SHA1" }, + MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) + { + { ADD_LEN( MBEDTLS_OID_PKCS1_SHA224 ), "sha224WithRSAEncryption", "RSA with SHA-224" }, + MBEDTLS_MD_SHA224, MBEDTLS_PK_RSA, + }, + { + { ADD_LEN( MBEDTLS_OID_PKCS1_SHA256 ), "sha256WithRSAEncryption", "RSA with SHA-256" }, + MBEDTLS_MD_SHA256, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { + { ADD_LEN( MBEDTLS_OID_PKCS1_SHA384 ), "sha384WithRSAEncryption", "RSA with SHA-384" }, + MBEDTLS_MD_SHA384, MBEDTLS_PK_RSA, + }, + { + { ADD_LEN( MBEDTLS_OID_PKCS1_SHA512 ), "sha512WithRSAEncryption", "RSA with SHA-512" }, + MBEDTLS_MD_SHA512, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA512_C */ +#if defined(MBEDTLS_SHA1_C) + { + { ADD_LEN( MBEDTLS_OID_RSA_SHA_OBS ), "sha-1WithRSAEncryption", "RSA with SHA1" }, + MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_SHA1_C) + { + { ADD_LEN( MBEDTLS_OID_ECDSA_SHA1 ), "ecdsa-with-SHA1", "ECDSA with SHA1" }, + MBEDTLS_MD_SHA1, MBEDTLS_PK_ECDSA, + }, +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) + { + { ADD_LEN( MBEDTLS_OID_ECDSA_SHA224 ), "ecdsa-with-SHA224", "ECDSA with SHA224" }, + MBEDTLS_MD_SHA224, MBEDTLS_PK_ECDSA, + }, + { + { ADD_LEN( MBEDTLS_OID_ECDSA_SHA256 ), "ecdsa-with-SHA256", "ECDSA with SHA256" }, + MBEDTLS_MD_SHA256, MBEDTLS_PK_ECDSA, + }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { + { ADD_LEN( MBEDTLS_OID_ECDSA_SHA384 ), "ecdsa-with-SHA384", "ECDSA with SHA384" }, + MBEDTLS_MD_SHA384, MBEDTLS_PK_ECDSA, + }, + { + { ADD_LEN( MBEDTLS_OID_ECDSA_SHA512 ), "ecdsa-with-SHA512", "ECDSA with SHA512" }, + MBEDTLS_MD_SHA512, MBEDTLS_PK_ECDSA, + }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_ECDSA_C */ +#if defined(MBEDTLS_RSA_C) + { + { ADD_LEN( MBEDTLS_OID_RSASSA_PSS ), "RSASSA-PSS", "RSASSA-PSS" }, + MBEDTLS_MD_NONE, MBEDTLS_PK_RSASSA_PSS, + }, +#endif /* MBEDTLS_RSA_C */ + { + { NULL, 0, NULL, NULL }, + MBEDTLS_MD_NONE, MBEDTLS_PK_NONE, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_sig_alg_t, sig_alg, oid_sig_alg) +FN_OID_GET_DESCRIPTOR_ATTR1(mbedtls_oid_get_sig_alg_desc, oid_sig_alg_t, sig_alg, const char *, description) +FN_OID_GET_ATTR2(mbedtls_oid_get_sig_alg, oid_sig_alg_t, sig_alg, mbedtls_md_type_t, md_alg, mbedtls_pk_type_t, pk_alg) +FN_OID_GET_OID_BY_ATTR2(mbedtls_oid_get_oid_by_sig_alg, oid_sig_alg_t, oid_sig_alg, mbedtls_pk_type_t, pk_alg, mbedtls_md_type_t, md_alg) +#endif /* MBEDTLS_MD_C */ + +/* + * For PublicKeyInfo (PKCS1, RFC 5480) + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + mbedtls_pk_type_t pk_alg; +} oid_pk_alg_t; + +static const oid_pk_alg_t oid_pk_alg[] = +{ + { + { ADD_LEN( MBEDTLS_OID_PKCS1_RSA ), "rsaEncryption", "RSA" }, + MBEDTLS_PK_RSA, + }, + { + { ADD_LEN( MBEDTLS_OID_EC_ALG_UNRESTRICTED ), "id-ecPublicKey", "Generic EC key" }, + MBEDTLS_PK_ECKEY, + }, + { + { ADD_LEN( MBEDTLS_OID_EC_ALG_ECDH ), "id-ecDH", "EC key for ECDH" }, + MBEDTLS_PK_ECKEY_DH, + }, + { + { NULL, 0, NULL, NULL }, + MBEDTLS_PK_NONE, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg) +FN_OID_GET_ATTR1(mbedtls_oid_get_pk_alg, oid_pk_alg_t, pk_alg, mbedtls_pk_type_t, pk_alg) +FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_pk_alg, oid_pk_alg_t, oid_pk_alg, mbedtls_pk_type_t, pk_alg) + +#if defined(MBEDTLS_ECP_C) +/* + * For namedCurve (RFC 5480) + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + mbedtls_ecp_group_id grp_id; +} oid_ecp_grp_t; + +static const oid_ecp_grp_t oid_ecp_grp[] = +{ +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192R1 ), "secp192r1", "secp192r1" }, + MBEDTLS_ECP_DP_SECP192R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224R1 ), "secp224r1", "secp224r1" }, + MBEDTLS_ECP_DP_SECP224R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256R1 ), "secp256r1", "secp256r1" }, + MBEDTLS_ECP_DP_SECP256R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP384R1 ), "secp384r1", "secp384r1" }, + MBEDTLS_ECP_DP_SECP384R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP521R1 ), "secp521r1", "secp521r1" }, + MBEDTLS_ECP_DP_SECP521R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192K1 ), "secp192k1", "secp192k1" }, + MBEDTLS_ECP_DP_SECP192K1, + }, +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224K1 ), "secp224k1", "secp224k1" }, + MBEDTLS_ECP_DP_SECP224K1, + }, +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256K1 ), "secp256k1", "secp256k1" }, + MBEDTLS_ECP_DP_SECP256K1, + }, +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_BP256R1 ), "brainpoolP256r1","brainpool256r1" }, + MBEDTLS_ECP_DP_BP256R1, + }, +#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_BP384R1 ), "brainpoolP384r1","brainpool384r1" }, + MBEDTLS_ECP_DP_BP384R1, + }, +#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) + { + { ADD_LEN( MBEDTLS_OID_EC_GRP_BP512R1 ), "brainpoolP512r1","brainpool512r1" }, + MBEDTLS_ECP_DP_BP512R1, + }, +#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ + { + { NULL, 0, NULL, NULL }, + MBEDTLS_ECP_DP_NONE, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_t, grp_id, oid_ecp_grp) +FN_OID_GET_ATTR1(mbedtls_oid_get_ec_grp, oid_ecp_grp_t, grp_id, mbedtls_ecp_group_id, grp_id) +FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_ec_grp, oid_ecp_grp_t, oid_ecp_grp, mbedtls_ecp_group_id, grp_id) +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_CIPHER_C) +/* + * For PKCS#5 PBES2 encryption algorithm + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + mbedtls_cipher_type_t cipher_alg; +} oid_cipher_alg_t; + +static const oid_cipher_alg_t oid_cipher_alg[] = +{ + { + { ADD_LEN( MBEDTLS_OID_DES_CBC ), "desCBC", "DES-CBC" }, + MBEDTLS_CIPHER_DES_CBC, + }, + { + { ADD_LEN( MBEDTLS_OID_DES_EDE3_CBC ), "des-ede3-cbc", "DES-EDE3-CBC" }, + MBEDTLS_CIPHER_DES_EDE3_CBC, + }, + { + { NULL, 0, NULL, NULL }, + MBEDTLS_CIPHER_NONE, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg) +FN_OID_GET_ATTR1(mbedtls_oid_get_cipher_alg, oid_cipher_alg_t, cipher_alg, mbedtls_cipher_type_t, cipher_alg) +#endif /* MBEDTLS_CIPHER_C */ + +#if defined(MBEDTLS_MD_C) +/* + * For digestAlgorithm + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + mbedtls_md_type_t md_alg; +} oid_md_alg_t; + +static const oid_md_alg_t oid_md_alg[] = +{ +#if defined(MBEDTLS_MD2_C) + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD2 ), "id-md2", "MD2" }, + MBEDTLS_MD_MD2, + }, +#endif /* MBEDTLS_MD2_C */ +#if defined(MBEDTLS_MD4_C) + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD4 ), "id-md4", "MD4" }, + MBEDTLS_MD_MD4, + }, +#endif /* MBEDTLS_MD4_C */ +#if defined(MBEDTLS_MD5_C) + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD5 ), "id-md5", "MD5" }, + MBEDTLS_MD_MD5, + }, +#endif /* MBEDTLS_MD5_C */ +#if defined(MBEDTLS_SHA1_C) + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA1 ), "id-sha1", "SHA-1" }, + MBEDTLS_MD_SHA1, + }, +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA224 ), "id-sha224", "SHA-224" }, + MBEDTLS_MD_SHA224, + }, + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA256 ), "id-sha256", "SHA-256" }, + MBEDTLS_MD_SHA256, + }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA384 ), "id-sha384", "SHA-384" }, + MBEDTLS_MD_SHA384, + }, + { + { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA512 ), "id-sha512", "SHA-512" }, + MBEDTLS_MD_SHA512, + }, +#endif /* MBEDTLS_SHA512_C */ + { + { NULL, 0, NULL, NULL }, + MBEDTLS_MD_NONE, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg) +FN_OID_GET_ATTR1(mbedtls_oid_get_md_alg, oid_md_alg_t, md_alg, mbedtls_md_type_t, md_alg) +FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_md, oid_md_alg_t, oid_md_alg, mbedtls_md_type_t, md_alg) +#endif /* MBEDTLS_MD_C */ + +#if defined(MBEDTLS_PKCS12_C) +/* + * For PKCS#12 PBEs + */ +typedef struct { + mbedtls_oid_descriptor_t descriptor; + mbedtls_md_type_t md_alg; + mbedtls_cipher_type_t cipher_alg; +} oid_pkcs12_pbe_alg_t; + +static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] = +{ + { + { ADD_LEN( MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC ), "pbeWithSHAAnd3-KeyTripleDES-CBC", "PBE with SHA1 and 3-Key 3DES" }, + MBEDTLS_MD_SHA1, MBEDTLS_CIPHER_DES_EDE3_CBC, + }, + { + { ADD_LEN( MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC ), "pbeWithSHAAnd2-KeyTripleDES-CBC", "PBE with SHA1 and 2-Key 3DES" }, + MBEDTLS_MD_SHA1, MBEDTLS_CIPHER_DES_EDE_CBC, + }, + { + { NULL, 0, NULL, NULL }, + MBEDTLS_MD_NONE, MBEDTLS_CIPHER_NONE, + }, +}; + +FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg) +FN_OID_GET_ATTR2(mbedtls_oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, mbedtls_md_type_t, md_alg, mbedtls_cipher_type_t, cipher_alg) +#endif /* MBEDTLS_PKCS12_C */ + +#define OID_SAFE_SNPRINTF \ + do { \ + if( ret < 0 || (size_t) ret >= n ) \ + return( MBEDTLS_ERR_OID_BUF_TOO_SMALL ); \ + \ + n -= (size_t) ret; \ + p += (size_t) ret; \ + } while( 0 ) + +/* Return the x.y.z.... style numeric string for the given OID */ +int mbedtls_oid_get_numeric_string( char *buf, size_t size, + const mbedtls_asn1_buf *oid ) +{ + int ret; + size_t i, n; + unsigned int value; + char *p; + + p = buf; + n = size; + + /* First byte contains first two dots */ + if( oid->len > 0 ) + { + ret = mbedtls_snprintf( p, n, "%d.%d", oid->p[0] / 40, oid->p[0] % 40 ); + OID_SAFE_SNPRINTF; + } + + value = 0; + for( i = 1; i < oid->len; i++ ) + { + /* Prevent overflow in value. */ + if( ( ( value << 7 ) >> 7 ) != value ) + return( MBEDTLS_ERR_OID_BUF_TOO_SMALL ); + + value <<= 7; + value += oid->p[i] & 0x7F; + + if( !( oid->p[i] & 0x80 ) ) + { + /* Last byte */ + ret = mbedtls_snprintf( p, n, ".%d", value ); + OID_SAFE_SNPRINTF; + value = 0; + } + } + + return( (int) ( size - n ) ); +} + +#endif /* MBEDTLS_OID_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/padlock.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/padlock.c new file mode 100644 index 0000000..b85ff9c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/padlock.c @@ -0,0 +1,170 @@ +/* + * VIA PadLock support functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * This implementation is based on the VIA PadLock Programming Guide: + * + * http://www.via.com.tw/en/downloads/whitepapers/initiatives/padlock/ + * programming_guide.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PADLOCK_C) + +#include "mbedtls/padlock.h" + +#include + +#ifndef asm +#define asm __asm +#endif + +#if defined(MBEDTLS_HAVE_X86) + +/* + * PadLock detection routine + */ +int mbedtls_padlock_has_support( int feature ) +{ + static int flags = -1; + int ebx = 0, edx = 0; + + if( flags == -1 ) + { + asm( "movl %%ebx, %0 \n\t" + "movl $0xC0000000, %%eax \n\t" + "cpuid \n\t" + "cmpl $0xC0000001, %%eax \n\t" + "movl $0, %%edx \n\t" + "jb unsupported \n\t" + "movl $0xC0000001, %%eax \n\t" + "cpuid \n\t" + "unsupported: \n\t" + "movl %%edx, %1 \n\t" + "movl %2, %%ebx \n\t" + : "=m" (ebx), "=m" (edx) + : "m" (ebx) + : "eax", "ecx", "edx" ); + + flags = edx; + } + + return( flags & feature ); +} + +/* + * PadLock AES-ECB block en(de)cryption + */ +int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx, + int mode, + const unsigned char input[16], + unsigned char output[16] ) +{ + int ebx = 0; + uint32_t *rk; + uint32_t *blk; + uint32_t *ctrl; + unsigned char buf[256]; + + rk = ctx->rk; + blk = MBEDTLS_PADLOCK_ALIGN16( buf ); + memcpy( blk, input, 16 ); + + ctrl = blk + 4; + *ctrl = 0x80 | ctx->nr | ( ( ctx->nr + ( mode^1 ) - 10 ) << 9 ); + + asm( "pushfl \n\t" + "popfl \n\t" + "movl %%ebx, %0 \n\t" + "movl $1, %%ecx \n\t" + "movl %2, %%edx \n\t" + "movl %3, %%ebx \n\t" + "movl %4, %%esi \n\t" + "movl %4, %%edi \n\t" + ".byte 0xf3,0x0f,0xa7,0xc8 \n\t" + "movl %1, %%ebx \n\t" + : "=m" (ebx) + : "m" (ebx), "m" (ctrl), "m" (rk), "m" (blk) + : "memory", "ecx", "edx", "esi", "edi" ); + + memcpy( output, blk, 16 ); + + return( 0 ); +} + +/* + * PadLock AES-CBC buffer en(de)cryption + */ +int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + int ebx = 0; + size_t count; + uint32_t *rk; + uint32_t *iw; + uint32_t *ctrl; + unsigned char buf[256]; + + if( ( (long) input & 15 ) != 0 || + ( (long) output & 15 ) != 0 ) + return( MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED ); + + rk = ctx->rk; + iw = MBEDTLS_PADLOCK_ALIGN16( buf ); + memcpy( iw, iv, 16 ); + + ctrl = iw + 4; + *ctrl = 0x80 | ctx->nr | ( ( ctx->nr + ( mode ^ 1 ) - 10 ) << 9 ); + + count = ( length + 15 ) >> 4; + + asm( "pushfl \n\t" + "popfl \n\t" + "movl %%ebx, %0 \n\t" + "movl %2, %%ecx \n\t" + "movl %3, %%edx \n\t" + "movl %4, %%ebx \n\t" + "movl %5, %%esi \n\t" + "movl %6, %%edi \n\t" + "movl %7, %%eax \n\t" + ".byte 0xf3,0x0f,0xa7,0xd0 \n\t" + "movl %1, %%ebx \n\t" + : "=m" (ebx) + : "m" (ebx), "m" (count), "m" (ctrl), + "m" (rk), "m" (input), "m" (output), "m" (iw) + : "memory", "eax", "ecx", "edx", "esi", "edi" ); + + memcpy( iv, iw, 16 ); + + return( 0 ); +} + +#endif /* MBEDTLS_HAVE_X86 */ + +#endif /* MBEDTLS_PADLOCK_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pem.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pem.c new file mode 100644 index 0000000..8dd86a4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pem.c @@ -0,0 +1,449 @@ +/* + * Privacy Enhanced Mail (PEM) decoding + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) + +#include "mbedtls/pem.h" +#include "mbedtls/base64.h" +#include "mbedtls/des.h" +#include "mbedtls/aes.h" +#include "mbedtls/md5.h" +#include "mbedtls/cipher.h" + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +void mbedtls_pem_init( mbedtls_pem_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_pem_context ) ); +} + +#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) ) +/* + * Read a 16-byte hex string and convert it to binary + */ +static int pem_get_iv( const unsigned char *s, unsigned char *iv, + size_t iv_len ) +{ + size_t i, j, k; + + memset( iv, 0, iv_len ); + + for( i = 0; i < iv_len * 2; i++, s++ ) + { + if( *s >= '0' && *s <= '9' ) j = *s - '0'; else + if( *s >= 'A' && *s <= 'F' ) j = *s - '7'; else + if( *s >= 'a' && *s <= 'f' ) j = *s - 'W'; else + return( MBEDTLS_ERR_PEM_INVALID_ENC_IV ); + + k = ( ( i & 1 ) != 0 ) ? j : j << 4; + + iv[i >> 1] = (unsigned char)( iv[i >> 1] | k ); + } + + return( 0 ); +} + +static void pem_pbkdf1( unsigned char *key, size_t keylen, + unsigned char *iv, + const unsigned char *pwd, size_t pwdlen ) +{ + mbedtls_md5_context md5_ctx; + unsigned char md5sum[16]; + size_t use_len; + + mbedtls_md5_init( &md5_ctx ); + + /* + * key[ 0..15] = MD5(pwd || IV) + */ + mbedtls_md5_starts( &md5_ctx ); + mbedtls_md5_update( &md5_ctx, pwd, pwdlen ); + mbedtls_md5_update( &md5_ctx, iv, 8 ); + mbedtls_md5_finish( &md5_ctx, md5sum ); + + if( keylen <= 16 ) + { + memcpy( key, md5sum, keylen ); + + mbedtls_md5_free( &md5_ctx ); + mbedtls_zeroize( md5sum, 16 ); + return; + } + + memcpy( key, md5sum, 16 ); + + /* + * key[16..23] = MD5(key[ 0..15] || pwd || IV]) + */ + mbedtls_md5_starts( &md5_ctx ); + mbedtls_md5_update( &md5_ctx, md5sum, 16 ); + mbedtls_md5_update( &md5_ctx, pwd, pwdlen ); + mbedtls_md5_update( &md5_ctx, iv, 8 ); + mbedtls_md5_finish( &md5_ctx, md5sum ); + + use_len = 16; + if( keylen < 32 ) + use_len = keylen - 16; + + memcpy( key + 16, md5sum, use_len ); + + mbedtls_md5_free( &md5_ctx ); + mbedtls_zeroize( md5sum, 16 ); +} + +#if defined(MBEDTLS_DES_C) +/* + * Decrypt with DES-CBC, using PBKDF1 for key derivation + */ +static void pem_des_decrypt( unsigned char des_iv[8], + unsigned char *buf, size_t buflen, + const unsigned char *pwd, size_t pwdlen ) +{ + mbedtls_des_context des_ctx; + unsigned char des_key[8]; + + mbedtls_des_init( &des_ctx ); + + pem_pbkdf1( des_key, 8, des_iv, pwd, pwdlen ); + + mbedtls_des_setkey_dec( &des_ctx, des_key ); + mbedtls_des_crypt_cbc( &des_ctx, MBEDTLS_DES_DECRYPT, buflen, + des_iv, buf, buf ); + + mbedtls_des_free( &des_ctx ); + mbedtls_zeroize( des_key, 8 ); +} + +/* + * Decrypt with 3DES-CBC, using PBKDF1 for key derivation + */ +static void pem_des3_decrypt( unsigned char des3_iv[8], + unsigned char *buf, size_t buflen, + const unsigned char *pwd, size_t pwdlen ) +{ + mbedtls_des3_context des3_ctx; + unsigned char des3_key[24]; + + mbedtls_des3_init( &des3_ctx ); + + pem_pbkdf1( des3_key, 24, des3_iv, pwd, pwdlen ); + + mbedtls_des3_set3key_dec( &des3_ctx, des3_key ); + mbedtls_des3_crypt_cbc( &des3_ctx, MBEDTLS_DES_DECRYPT, buflen, + des3_iv, buf, buf ); + + mbedtls_des3_free( &des3_ctx ); + mbedtls_zeroize( des3_key, 24 ); +} +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_AES_C) +/* + * Decrypt with AES-XXX-CBC, using PBKDF1 for key derivation + */ +static void pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen, + unsigned char *buf, size_t buflen, + const unsigned char *pwd, size_t pwdlen ) +{ + mbedtls_aes_context aes_ctx; + unsigned char aes_key[32]; + + mbedtls_aes_init( &aes_ctx ); + + pem_pbkdf1( aes_key, keylen, aes_iv, pwd, pwdlen ); + + mbedtls_aes_setkey_dec( &aes_ctx, aes_key, keylen * 8 ); + mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_DECRYPT, buflen, + aes_iv, buf, buf ); + + mbedtls_aes_free( &aes_ctx ); + mbedtls_zeroize( aes_key, keylen ); +} +#endif /* MBEDTLS_AES_C */ + +#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC && + ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ + +int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const char *footer, + const unsigned char *data, const unsigned char *pwd, + size_t pwdlen, size_t *use_len ) +{ + int ret, enc; + size_t len; + unsigned char *buf; + const unsigned char *s1, *s2, *end; +#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) ) + unsigned char pem_iv[16]; + mbedtls_cipher_type_t enc_alg = MBEDTLS_CIPHER_NONE; +#else + ((void) pwd); + ((void) pwdlen); +#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC && + ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ + + if( ctx == NULL ) + return( MBEDTLS_ERR_PEM_BAD_INPUT_DATA ); + + s1 = (unsigned char *) strstr( (const char *) data, header ); + + if( s1 == NULL ) + return( MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ); + + s2 = (unsigned char *) strstr( (const char *) data, footer ); + + if( s2 == NULL || s2 <= s1 ) + return( MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ); + + s1 += strlen( header ); + if( *s1 == ' ' ) s1++; + if( *s1 == '\r' ) s1++; + if( *s1 == '\n' ) s1++; + else return( MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ); + + end = s2; + end += strlen( footer ); + if( *end == ' ' ) end++; + if( *end == '\r' ) end++; + if( *end == '\n' ) end++; + *use_len = end - data; + + enc = 0; + + if( s2 - s1 >= 22 && memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 ) + { +#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) ) + enc++; + + s1 += 22; + if( *s1 == '\r' ) s1++; + if( *s1 == '\n' ) s1++; + else return( MBEDTLS_ERR_PEM_INVALID_DATA ); + + +#if defined(MBEDTLS_DES_C) + if( s2 - s1 >= 23 && memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 ) + { + enc_alg = MBEDTLS_CIPHER_DES_EDE3_CBC; + + s1 += 23; + if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8 ) != 0 ) + return( MBEDTLS_ERR_PEM_INVALID_ENC_IV ); + + s1 += 16; + } + else if( s2 - s1 >= 18 && memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 ) + { + enc_alg = MBEDTLS_CIPHER_DES_CBC; + + s1 += 18; + if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8) != 0 ) + return( MBEDTLS_ERR_PEM_INVALID_ENC_IV ); + + s1 += 16; + } +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_AES_C) + if( s2 - s1 >= 14 && memcmp( s1, "DEK-Info: AES-", 14 ) == 0 ) + { + if( s2 - s1 < 22 ) + return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG ); + else if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 ) + enc_alg = MBEDTLS_CIPHER_AES_128_CBC; + else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 ) + enc_alg = MBEDTLS_CIPHER_AES_192_CBC; + else if( memcmp( s1, "DEK-Info: AES-256-CBC,", 22 ) == 0 ) + enc_alg = MBEDTLS_CIPHER_AES_256_CBC; + else + return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG ); + + s1 += 22; + if( s2 - s1 < 32 || pem_get_iv( s1, pem_iv, 16 ) != 0 ) + return( MBEDTLS_ERR_PEM_INVALID_ENC_IV ); + + s1 += 32; + } +#endif /* MBEDTLS_AES_C */ + + if( enc_alg == MBEDTLS_CIPHER_NONE ) + return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG ); + + if( *s1 == '\r' ) s1++; + if( *s1 == '\n' ) s1++; + else return( MBEDTLS_ERR_PEM_INVALID_DATA ); +#else + return( MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE ); +#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC && + ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ + } + + if( s1 >= s2 ) + return( MBEDTLS_ERR_PEM_INVALID_DATA ); + + ret = mbedtls_base64_decode( NULL, 0, &len, s1, s2 - s1 ); + + if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER ) + return( MBEDTLS_ERR_PEM_INVALID_DATA + ret ); + + if( ( buf = mbedtls_calloc( 1, len ) ) == NULL ) + return( MBEDTLS_ERR_PEM_ALLOC_FAILED ); + + if( ( ret = mbedtls_base64_decode( buf, len, &len, s1, s2 - s1 ) ) != 0 ) + { + mbedtls_free( buf ); + return( MBEDTLS_ERR_PEM_INVALID_DATA + ret ); + } + + if( enc != 0 ) + { +#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) ) + if( pwd == NULL ) + { + mbedtls_free( buf ); + return( MBEDTLS_ERR_PEM_PASSWORD_REQUIRED ); + } + +#if defined(MBEDTLS_DES_C) + if( enc_alg == MBEDTLS_CIPHER_DES_EDE3_CBC ) + pem_des3_decrypt( pem_iv, buf, len, pwd, pwdlen ); + else if( enc_alg == MBEDTLS_CIPHER_DES_CBC ) + pem_des_decrypt( pem_iv, buf, len, pwd, pwdlen ); +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_AES_C) + if( enc_alg == MBEDTLS_CIPHER_AES_128_CBC ) + pem_aes_decrypt( pem_iv, 16, buf, len, pwd, pwdlen ); + else if( enc_alg == MBEDTLS_CIPHER_AES_192_CBC ) + pem_aes_decrypt( pem_iv, 24, buf, len, pwd, pwdlen ); + else if( enc_alg == MBEDTLS_CIPHER_AES_256_CBC ) + pem_aes_decrypt( pem_iv, 32, buf, len, pwd, pwdlen ); +#endif /* MBEDTLS_AES_C */ + + /* + * The result will be ASN.1 starting with a SEQUENCE tag, with 1 to 3 + * length bytes (allow 4 to be sure) in all known use cases. + * + * Use that as heurisitic to try detecting password mismatchs. + */ + if( len <= 2 || buf[0] != 0x30 || buf[1] > 0x83 ) + { + mbedtls_free( buf ); + return( MBEDTLS_ERR_PEM_PASSWORD_MISMATCH ); + } +#else + mbedtls_free( buf ); + return( MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE ); +#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC && + ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ + } + + ctx->buf = buf; + ctx->buflen = len; + + return( 0 ); +} + +void mbedtls_pem_free( mbedtls_pem_context *ctx ) +{ + mbedtls_free( ctx->buf ); + mbedtls_free( ctx->info ); + + mbedtls_zeroize( ctx, sizeof( mbedtls_pem_context ) ); +} +#endif /* MBEDTLS_PEM_PARSE_C */ + +#if defined(MBEDTLS_PEM_WRITE_C) +int mbedtls_pem_write_buffer( const char *header, const char *footer, + const unsigned char *der_data, size_t der_len, + unsigned char *buf, size_t buf_len, size_t *olen ) +{ + int ret; + unsigned char *encode_buf, *c, *p = buf; + size_t len = 0, use_len, add_len = 0; + + mbedtls_base64_encode( NULL, 0, &use_len, der_data, der_len ); + add_len = strlen( header ) + strlen( footer ) + ( use_len / 64 ) + 1; + + if( use_len + add_len > buf_len ) + { + *olen = use_len + add_len; + return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); + } + + if( ( encode_buf = mbedtls_calloc( 1, use_len ) ) == NULL ) + return( MBEDTLS_ERR_PEM_ALLOC_FAILED ); + + if( ( ret = mbedtls_base64_encode( encode_buf, use_len, &use_len, der_data, + der_len ) ) != 0 ) + { + mbedtls_free( encode_buf ); + return( ret ); + } + + memcpy( p, header, strlen( header ) ); + p += strlen( header ); + c = encode_buf; + + while( use_len ) + { + len = ( use_len > 64 ) ? 64 : use_len; + memcpy( p, c, len ); + use_len -= len; + p += len; + c += len; + *p++ = '\n'; + } + + memcpy( p, footer, strlen( footer ) ); + p += strlen( footer ); + + *p++ = '\0'; + *olen = p - buf; + + mbedtls_free( encode_buf ); + return( 0 ); +} +#endif /* MBEDTLS_PEM_WRITE_C */ +#endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk.c new file mode 100644 index 0000000..8d13bc5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk.c @@ -0,0 +1,383 @@ +/* + * Public Key abstraction layer + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PK_C) +#include "mbedtls/pk.h" +#include "mbedtls/pk_internal.h" + +#include "mbedtls/bignum.h" + +#if defined(MBEDTLS_RSA_C) +#include "mbedtls/rsa.h" +#endif +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif +#if defined(MBEDTLS_ECDSA_C) +#include "mbedtls/ecdsa.h" +#endif + +#include + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Initialise a mbedtls_pk_context + */ +void mbedtls_pk_init( mbedtls_pk_context *ctx ) +{ + if( ctx == NULL ) + return; + + ctx->pk_info = NULL; + ctx->pk_ctx = NULL; +} + +/* + * Free (the components of) a mbedtls_pk_context + */ +void mbedtls_pk_free( mbedtls_pk_context *ctx ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return; + + ctx->pk_info->ctx_free_func( ctx->pk_ctx ); + + mbedtls_zeroize( ctx, sizeof( mbedtls_pk_context ) ); +} + +/* + * Get pk_info structure from type + */ +const mbedtls_pk_info_t * mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type ) +{ + switch( pk_type ) { +#if defined(MBEDTLS_RSA_C) + case MBEDTLS_PK_RSA: + return( &mbedtls_rsa_info ); +#endif +#if defined(MBEDTLS_ECP_C) + case MBEDTLS_PK_ECKEY: + return( &mbedtls_eckey_info ); + case MBEDTLS_PK_ECKEY_DH: + return( &mbedtls_eckeydh_info ); +#endif +#if defined(MBEDTLS_ECDSA_C) + case MBEDTLS_PK_ECDSA: + return( &mbedtls_ecdsa_info ); +#endif + /* MBEDTLS_PK_RSA_ALT omitted on purpose */ + default: + return( NULL ); + } +} + +/* + * Initialise context + */ +int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ) +{ + if( ctx == NULL || info == NULL || ctx->pk_info != NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) + return( MBEDTLS_ERR_PK_ALLOC_FAILED ); + + ctx->pk_info = info; + + return( 0 ); +} + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +/* + * Initialize an RSA-alt context + */ +int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, + mbedtls_pk_rsa_alt_decrypt_func decrypt_func, + mbedtls_pk_rsa_alt_sign_func sign_func, + mbedtls_pk_rsa_alt_key_len_func key_len_func ) +{ + mbedtls_rsa_alt_context *rsa_alt; + const mbedtls_pk_info_t *info = &mbedtls_rsa_alt_info; + + if( ctx == NULL || ctx->pk_info != NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) + return( MBEDTLS_ERR_PK_ALLOC_FAILED ); + + ctx->pk_info = info; + + rsa_alt = (mbedtls_rsa_alt_context *) ctx->pk_ctx; + + rsa_alt->key = key; + rsa_alt->decrypt_func = decrypt_func; + rsa_alt->sign_func = sign_func; + rsa_alt->key_len_func = key_len_func; + + return( 0 ); +} +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ + +/* + * Tell if a PK can do the operations of the given type + */ +int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ) +{ + /* null or NONE context can't do anything */ + if( ctx == NULL || ctx->pk_info == NULL ) + return( 0 ); + + return( ctx->pk_info->can_do( type ) ); +} + +/* + * Helper for mbedtls_pk_sign and mbedtls_pk_verify + */ +static inline int pk_hashlen_helper( mbedtls_md_type_t md_alg, size_t *hash_len ) +{ + const mbedtls_md_info_t *md_info; + + if( *hash_len != 0 ) + return( 0 ); + + if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL ) + return( -1 ); + + *hash_len = mbedtls_md_get_size( md_info ); + return( 0 ); +} + +/* + * Verify a signature + */ +int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ) +{ + if( ctx == NULL || ctx->pk_info == NULL || + pk_hashlen_helper( md_alg, &hash_len ) != 0 ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ctx->pk_info->verify_func == NULL ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + + return( ctx->pk_info->verify_func( ctx->pk_ctx, md_alg, hash, hash_len, + sig, sig_len ) ); +} + +/* + * Verify a signature with options + */ +int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options, + mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ! mbedtls_pk_can_do( ctx, type ) ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + + if( type == MBEDTLS_PK_RSASSA_PSS ) + { +#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PKCS1_V21) + int ret; + const mbedtls_pk_rsassa_pss_options *pss_opts; + +#if defined(MBEDTLS_HAVE_INT64) + if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); +#endif /* MBEDTLS_HAVE_INT64 */ + + if( options == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + pss_opts = (const mbedtls_pk_rsassa_pss_options *) options; + + if( sig_len < mbedtls_pk_get_len( ctx ) ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + ret = mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_pk_rsa( *ctx ), + NULL, NULL, MBEDTLS_RSA_PUBLIC, + md_alg, (unsigned int) hash_len, hash, + pss_opts->mgf1_hash_id, + pss_opts->expected_salt_len, + sig ); + if( ret != 0 ) + return( ret ); + + if( sig_len > mbedtls_pk_get_len( ctx ) ) + return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH ); + + return( 0 ); +#else + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); +#endif /* MBEDTLS_RSA_C && MBEDTLS_PKCS1_V21 */ + } + + /* General case: no options */ + if( options != NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + return( mbedtls_pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) ); +} + +/* + * Make a signature + */ +int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + if( ctx == NULL || ctx->pk_info == NULL || + pk_hashlen_helper( md_alg, &hash_len ) != 0 ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ctx->pk_info->sign_func == NULL ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + + return( ctx->pk_info->sign_func( ctx->pk_ctx, md_alg, hash, hash_len, + sig, sig_len, f_rng, p_rng ) ); +} + +/* + * Decrypt message + */ +int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ctx->pk_info->decrypt_func == NULL ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + + return( ctx->pk_info->decrypt_func( ctx->pk_ctx, input, ilen, + output, olen, osize, f_rng, p_rng ) ); +} + +/* + * Encrypt message + */ +int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ctx->pk_info->encrypt_func == NULL ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + + return( ctx->pk_info->encrypt_func( ctx->pk_ctx, input, ilen, + output, olen, osize, f_rng, p_rng ) ); +} + +/* + * Check public-private key pair + */ +int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv ) +{ + if( pub == NULL || pub->pk_info == NULL || + prv == NULL || prv->pk_info == NULL || + prv->pk_info->check_pair_func == NULL ) + { + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + } + + if( prv->pk_info->type == MBEDTLS_PK_RSA_ALT ) + { + if( pub->pk_info->type != MBEDTLS_PK_RSA ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + } + else + { + if( pub->pk_info != prv->pk_info ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + } + + return( prv->pk_info->check_pair_func( pub->pk_ctx, prv->pk_ctx ) ); +} + +/* + * Get key size in bits + */ +size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( 0 ); + + return( ctx->pk_info->get_bitlen( ctx->pk_ctx ) ); +} + +/* + * Export debug information + */ +int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ctx->pk_info->debug_func == NULL ) + return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); + + ctx->pk_info->debug_func( ctx->pk_ctx, items ); + return( 0 ); +} + +/* + * Access the PK type name + */ +const char *mbedtls_pk_get_name( const mbedtls_pk_context *ctx ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( "invalid PK" ); + + return( ctx->pk_info->name ); +} + +/* + * Access the PK type + */ +mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ) +{ + if( ctx == NULL || ctx->pk_info == NULL ) + return( MBEDTLS_PK_NONE ); + + return( ctx->pk_info->type ); +} + +#endif /* MBEDTLS_PK_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk_wrap.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk_wrap.c new file mode 100644 index 0000000..db6274c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pk_wrap.c @@ -0,0 +1,513 @@ +/* + * Public Key abstraction layer: wrapper functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PK_C) +#include "mbedtls/pk_internal.h" + +/* Even if RSA not activated, for the sake of RSA-alt */ +#include "mbedtls/rsa.h" +#include "mbedtls/bignum.h" + +#include + +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif + +#if defined(MBEDTLS_ECDSA_C) +#include "mbedtls/ecdsa.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} +#endif + +#if defined(MBEDTLS_RSA_C) +static int rsa_can_do( mbedtls_pk_type_t type ) +{ + return( type == MBEDTLS_PK_RSA || + type == MBEDTLS_PK_RSASSA_PSS ); +} + +static size_t rsa_get_bitlen( const void *ctx ) +{ + return( 8 * ((const mbedtls_rsa_context *) ctx)->len ); +} + +static int rsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ) +{ + int ret; + +#if defined(MBEDTLS_HAVE_INT64) + if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); +#endif /* MBEDTLS_HAVE_INT64 */ + + if( sig_len < ((mbedtls_rsa_context *) ctx)->len ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( ( ret = mbedtls_rsa_pkcs1_verify( (mbedtls_rsa_context *) ctx, NULL, NULL, + MBEDTLS_RSA_PUBLIC, md_alg, + (unsigned int) hash_len, hash, sig ) ) != 0 ) + return( ret ); + + if( sig_len > ((mbedtls_rsa_context *) ctx)->len ) + return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH ); + + return( 0 ); +} + +static int rsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ +#if defined(MBEDTLS_HAVE_INT64) + if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); +#endif /* MBEDTLS_HAVE_INT64 */ + + *sig_len = ((mbedtls_rsa_context *) ctx)->len; + + return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, f_rng, p_rng, MBEDTLS_RSA_PRIVATE, + md_alg, (unsigned int) hash_len, hash, sig ) ); +} + +static int rsa_decrypt_wrap( void *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + if( ilen != ((mbedtls_rsa_context *) ctx)->len ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx, f_rng, p_rng, + MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) ); +} + +static int rsa_encrypt_wrap( void *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + *olen = ((mbedtls_rsa_context *) ctx)->len; + + if( *olen > osize ) + return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE ); + + return( mbedtls_rsa_pkcs1_encrypt( (mbedtls_rsa_context *) ctx, + f_rng, p_rng, MBEDTLS_RSA_PUBLIC, ilen, input, output ) ); +} + +static int rsa_check_pair_wrap( const void *pub, const void *prv ) +{ + return( mbedtls_rsa_check_pub_priv( (const mbedtls_rsa_context *) pub, + (const mbedtls_rsa_context *) prv ) ); +} + +static void *rsa_alloc_wrap( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_context ) ); + + if( ctx != NULL ) + mbedtls_rsa_init( (mbedtls_rsa_context *) ctx, 0, 0 ); + + return( ctx ); +} + +static void rsa_free_wrap( void *ctx ) +{ + mbedtls_rsa_free( (mbedtls_rsa_context *) ctx ); + mbedtls_free( ctx ); +} + +static void rsa_debug( const void *ctx, mbedtls_pk_debug_item *items ) +{ + items->type = MBEDTLS_PK_DEBUG_MPI; + items->name = "rsa.N"; + items->value = &( ((mbedtls_rsa_context *) ctx)->N ); + + items++; + + items->type = MBEDTLS_PK_DEBUG_MPI; + items->name = "rsa.E"; + items->value = &( ((mbedtls_rsa_context *) ctx)->E ); +} + +const mbedtls_pk_info_t mbedtls_rsa_info = { + MBEDTLS_PK_RSA, + "RSA", + rsa_get_bitlen, + rsa_can_do, + rsa_verify_wrap, + rsa_sign_wrap, + rsa_decrypt_wrap, + rsa_encrypt_wrap, + rsa_check_pair_wrap, + rsa_alloc_wrap, + rsa_free_wrap, + rsa_debug, +}; +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) +/* + * Generic EC key + */ +static int eckey_can_do( mbedtls_pk_type_t type ) +{ + return( type == MBEDTLS_PK_ECKEY || + type == MBEDTLS_PK_ECKEY_DH || + type == MBEDTLS_PK_ECDSA ); +} + +static size_t eckey_get_bitlen( const void *ctx ) +{ + return( ((mbedtls_ecp_keypair *) ctx)->grp.pbits ); +} + +#if defined(MBEDTLS_ECDSA_C) +/* Forward declarations */ +static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ); + +static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + +static int eckey_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ) +{ + int ret; + mbedtls_ecdsa_context ecdsa; + + mbedtls_ecdsa_init( &ecdsa ); + + if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 ) + ret = ecdsa_verify_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len ); + + mbedtls_ecdsa_free( &ecdsa ); + + return( ret ); +} + +static int eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret; + mbedtls_ecdsa_context ecdsa; + + mbedtls_ecdsa_init( &ecdsa ); + + if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 ) + ret = ecdsa_sign_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len, + f_rng, p_rng ); + + mbedtls_ecdsa_free( &ecdsa ); + + return( ret ); +} + +#endif /* MBEDTLS_ECDSA_C */ + +static int eckey_check_pair( const void *pub, const void *prv ) +{ + return( mbedtls_ecp_check_pub_priv( (const mbedtls_ecp_keypair *) pub, + (const mbedtls_ecp_keypair *) prv ) ); +} + +static void *eckey_alloc_wrap( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecp_keypair ) ); + + if( ctx != NULL ) + mbedtls_ecp_keypair_init( ctx ); + + return( ctx ); +} + +static void eckey_free_wrap( void *ctx ) +{ + mbedtls_ecp_keypair_free( (mbedtls_ecp_keypair *) ctx ); + mbedtls_free( ctx ); +} + +static void eckey_debug( const void *ctx, mbedtls_pk_debug_item *items ) +{ + items->type = MBEDTLS_PK_DEBUG_ECP; + items->name = "eckey.Q"; + items->value = &( ((mbedtls_ecp_keypair *) ctx)->Q ); +} + +const mbedtls_pk_info_t mbedtls_eckey_info = { + MBEDTLS_PK_ECKEY, + "EC", + eckey_get_bitlen, + eckey_can_do, +#if defined(MBEDTLS_ECDSA_C) + eckey_verify_wrap, + eckey_sign_wrap, +#else + NULL, + NULL, +#endif + NULL, + NULL, + eckey_check_pair, + eckey_alloc_wrap, + eckey_free_wrap, + eckey_debug, +}; + +/* + * EC key restricted to ECDH + */ +static int eckeydh_can_do( mbedtls_pk_type_t type ) +{ + return( type == MBEDTLS_PK_ECKEY || + type == MBEDTLS_PK_ECKEY_DH ); +} + +const mbedtls_pk_info_t mbedtls_eckeydh_info = { + MBEDTLS_PK_ECKEY_DH, + "EC_DH", + eckey_get_bitlen, /* Same underlying key structure */ + eckeydh_can_do, + NULL, + NULL, + NULL, + NULL, + eckey_check_pair, + eckey_alloc_wrap, /* Same underlying key structure */ + eckey_free_wrap, /* Same underlying key structure */ + eckey_debug, /* Same underlying key structure */ +}; +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_ECDSA_C) +static int ecdsa_can_do( mbedtls_pk_type_t type ) +{ + return( type == MBEDTLS_PK_ECDSA ); +} + +static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ) +{ + int ret; + ((void) md_alg); + + ret = mbedtls_ecdsa_read_signature( (mbedtls_ecdsa_context *) ctx, + hash, hash_len, sig, sig_len ); + + if( ret == MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH ) + return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH ); + + return( ret ); +} + +static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + return( mbedtls_ecdsa_write_signature( (mbedtls_ecdsa_context *) ctx, + md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng ) ); +} + +static void *ecdsa_alloc_wrap( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) ); + + if( ctx != NULL ) + mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx ); + + return( ctx ); +} + +static void ecdsa_free_wrap( void *ctx ) +{ + mbedtls_ecdsa_free( (mbedtls_ecdsa_context *) ctx ); + mbedtls_free( ctx ); +} + +const mbedtls_pk_info_t mbedtls_ecdsa_info = { + MBEDTLS_PK_ECDSA, + "ECDSA", + eckey_get_bitlen, /* Compatible key structures */ + ecdsa_can_do, + ecdsa_verify_wrap, + ecdsa_sign_wrap, + NULL, + NULL, + eckey_check_pair, /* Compatible key structures */ + ecdsa_alloc_wrap, + ecdsa_free_wrap, + eckey_debug, /* Compatible key structures */ +}; +#endif /* MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +/* + * Support for alternative RSA-private implementations + */ + +static int rsa_alt_can_do( mbedtls_pk_type_t type ) +{ + return( type == MBEDTLS_PK_RSA ); +} + +static size_t rsa_alt_get_bitlen( const void *ctx ) +{ + const mbedtls_rsa_alt_context *rsa_alt = (const mbedtls_rsa_alt_context *) ctx; + + return( 8 * rsa_alt->key_len_func( rsa_alt->key ) ); +} + +static int rsa_alt_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx; + +#if defined(MBEDTLS_HAVE_INT64) + if( UINT_MAX < hash_len ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); +#endif /* MBEDTLS_HAVE_INT64 */ + + *sig_len = rsa_alt->key_len_func( rsa_alt->key ); + + return( rsa_alt->sign_func( rsa_alt->key, f_rng, p_rng, MBEDTLS_RSA_PRIVATE, + md_alg, (unsigned int) hash_len, hash, sig ) ); +} + +static int rsa_alt_decrypt_wrap( void *ctx, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx; + + ((void) f_rng); + ((void) p_rng); + + if( ilen != rsa_alt->key_len_func( rsa_alt->key ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + return( rsa_alt->decrypt_func( rsa_alt->key, + MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) ); +} + +#if defined(MBEDTLS_RSA_C) +static int rsa_alt_check_pair( const void *pub, const void *prv ) +{ + unsigned char sig[MBEDTLS_MPI_MAX_SIZE]; + unsigned char hash[32]; + size_t sig_len = 0; + int ret; + + if( rsa_alt_get_bitlen( prv ) != rsa_get_bitlen( pub ) ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + + memset( hash, 0x2a, sizeof( hash ) ); + + if( ( ret = rsa_alt_sign_wrap( (void *) prv, MBEDTLS_MD_NONE, + hash, sizeof( hash ), + sig, &sig_len, NULL, NULL ) ) != 0 ) + { + return( ret ); + } + + if( rsa_verify_wrap( (void *) pub, MBEDTLS_MD_NONE, + hash, sizeof( hash ), sig, sig_len ) != 0 ) + { + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + } + + return( 0 ); +} +#endif /* MBEDTLS_RSA_C */ + +static void *rsa_alt_alloc_wrap( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_alt_context ) ); + + if( ctx != NULL ) + memset( ctx, 0, sizeof( mbedtls_rsa_alt_context ) ); + + return( ctx ); +} + +static void rsa_alt_free_wrap( void *ctx ) +{ + mbedtls_zeroize( ctx, sizeof( mbedtls_rsa_alt_context ) ); + mbedtls_free( ctx ); +} + +const mbedtls_pk_info_t mbedtls_rsa_alt_info = { + MBEDTLS_PK_RSA_ALT, + "RSA-alt", + rsa_alt_get_bitlen, + rsa_alt_can_do, + NULL, + rsa_alt_sign_wrap, + rsa_alt_decrypt_wrap, + NULL, +#if defined(MBEDTLS_RSA_C) + rsa_alt_check_pair, +#else + NULL, +#endif + rsa_alt_alloc_wrap, + rsa_alt_free_wrap, + NULL, +}; + +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ + +#endif /* MBEDTLS_PK_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs11.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs11.c new file mode 100644 index 0000000..0ea6425 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs11.c @@ -0,0 +1,240 @@ +/** + * \file pkcs11.c + * + * \brief Wrapper for PKCS#11 library libpkcs11-helper + * + * \author Adriaan de Jong + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#include "mbedtls/pkcs11.h" + +#if defined(MBEDTLS_PKCS11_C) + +#include "mbedtls/md.h" +#include "mbedtls/oid.h" +#include "mbedtls/x509_crt.h" + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include + +void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_pkcs11_context ) ); +} + +int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11_cert ) +{ + int ret = 1; + unsigned char *cert_blob = NULL; + size_t cert_blob_size = 0; + + if( cert == NULL ) + { + ret = 2; + goto cleanup; + } + + if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, NULL, + &cert_blob_size ) != CKR_OK ) + { + ret = 3; + goto cleanup; + } + + cert_blob = mbedtls_calloc( 1, cert_blob_size ); + if( NULL == cert_blob ) + { + ret = 4; + goto cleanup; + } + + if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, cert_blob, + &cert_blob_size ) != CKR_OK ) + { + ret = 5; + goto cleanup; + } + + if( 0 != mbedtls_x509_crt_parse( cert, cert_blob, cert_blob_size ) ) + { + ret = 6; + goto cleanup; + } + + ret = 0; + +cleanup: + if( NULL != cert_blob ) + mbedtls_free( cert_blob ); + + return( ret ); +} + + +int mbedtls_pkcs11_priv_key_bind( mbedtls_pkcs11_context *priv_key, + pkcs11h_certificate_t pkcs11_cert ) +{ + int ret = 1; + mbedtls_x509_crt cert; + + mbedtls_x509_crt_init( &cert ); + + if( priv_key == NULL ) + goto cleanup; + + if( 0 != mbedtls_pkcs11_x509_cert_bind( &cert, pkcs11_cert ) ) + goto cleanup; + + priv_key->len = mbedtls_pk_get_len( &cert.pk ); + priv_key->pkcs11h_cert = pkcs11_cert; + + ret = 0; + +cleanup: + mbedtls_x509_crt_free( &cert ); + + return( ret ); +} + +void mbedtls_pkcs11_priv_key_free( mbedtls_pkcs11_context *priv_key ) +{ + if( NULL != priv_key ) + pkcs11h_certificate_freeCertificate( priv_key->pkcs11h_cert ); +} + +int mbedtls_pkcs11_decrypt( mbedtls_pkcs11_context *ctx, + int mode, size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len ) +{ + size_t input_len, output_len; + + if( NULL == ctx ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( MBEDTLS_RSA_PRIVATE != mode ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + output_len = input_len = ctx->len; + + if( input_len < 16 || input_len > output_max_len ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + /* Determine size of output buffer */ + if( pkcs11h_certificate_decryptAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, input, + input_len, NULL, &output_len ) != CKR_OK ) + { + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + } + + if( output_len > output_max_len ) + return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE ); + + if( pkcs11h_certificate_decryptAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, input, + input_len, output, &output_len ) != CKR_OK ) + { + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + } + *olen = output_len; + return( 0 ); +} + +int mbedtls_pkcs11_sign( mbedtls_pkcs11_context *ctx, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ) +{ + size_t sig_len = 0, asn_len = 0, oid_size = 0; + unsigned char *p = sig; + const char *oid; + + if( NULL == ctx ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( MBEDTLS_RSA_PRIVATE != mode ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( md_alg != MBEDTLS_MD_NONE ) + { + const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( mbedtls_oid_get_oid_by_md( md_alg, &oid, &oid_size ) != 0 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + hashlen = mbedtls_md_get_size( md_info ); + asn_len = 10 + oid_size; + } + + sig_len = ctx->len; + if( hashlen > sig_len || asn_len > sig_len || + hashlen + asn_len > sig_len ) + { + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + } + + if( md_alg != MBEDTLS_MD_NONE ) + { + /* + * DigestInfo ::= SEQUENCE { + * digestAlgorithm DigestAlgorithmIdentifier, + * digest Digest } + * + * DigestAlgorithmIdentifier ::= AlgorithmIdentifier + * + * Digest ::= OCTET STRING + */ + *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED; + *p++ = (unsigned char) ( 0x08 + oid_size + hashlen ); + *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED; + *p++ = (unsigned char) ( 0x04 + oid_size ); + *p++ = MBEDTLS_ASN1_OID; + *p++ = oid_size & 0xFF; + memcpy( p, oid, oid_size ); + p += oid_size; + *p++ = MBEDTLS_ASN1_NULL; + *p++ = 0x00; + *p++ = MBEDTLS_ASN1_OCTET_STRING; + *p++ = hashlen; + } + + memcpy( p, hash, hashlen ); + + if( pkcs11h_certificate_signAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, sig, + asn_len + hashlen, sig, &sig_len ) != CKR_OK ) + { + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + } + + return( 0 ); +} + +#endif /* defined(MBEDTLS_PKCS11_C) */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs12.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs12.c new file mode 100644 index 0000000..c603a13 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs12.c @@ -0,0 +1,365 @@ +/* + * PKCS#12 Personal Information Exchange Syntax + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The PKCS #12 Personal Information Exchange Syntax Standard v1.1 + * + * http://www.rsa.com/rsalabs/pkcs/files/h11301-wp-pkcs-12v1-1-personal-information-exchange-syntax.pdf + * ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12v1-1.asn + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PKCS12_C) + +#include "mbedtls/pkcs12.h" +#include "mbedtls/asn1.h" +#include "mbedtls/cipher.h" + +#include + +#if defined(MBEDTLS_ARC4_C) +#include "mbedtls/arc4.h" +#endif + +#if defined(MBEDTLS_DES_C) +#include "mbedtls/des.h" +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +static int pkcs12_parse_pbe_params( mbedtls_asn1_buf *params, + mbedtls_asn1_buf *salt, int *iterations ) +{ + int ret; + unsigned char **p = ¶ms->p; + const unsigned char *end = params->p + params->len; + + /* + * pkcs-12PbeParams ::= SEQUENCE { + * salt OCTET STRING, + * iterations INTEGER + * } + * + */ + if( params->tag != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) + return( MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + if( ( ret = mbedtls_asn1_get_tag( p, end, &salt->len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT + ret ); + + salt->p = *p; + *p += salt->len; + + if( ( ret = mbedtls_asn1_get_int( p, end, iterations ) ) != 0 ) + return( MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT + ret ); + + if( *p != end ) + return( MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +#define PKCS12_MAX_PWDLEN 128 + +static int pkcs12_pbe_derive_key_iv( mbedtls_asn1_buf *pbe_params, mbedtls_md_type_t md_type, + const unsigned char *pwd, size_t pwdlen, + unsigned char *key, size_t keylen, + unsigned char *iv, size_t ivlen ) +{ + int ret, iterations = 0; + mbedtls_asn1_buf salt; + size_t i; + unsigned char unipwd[PKCS12_MAX_PWDLEN * 2 + 2]; + + if( pwdlen > PKCS12_MAX_PWDLEN ) + return( MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA ); + + memset( &salt, 0, sizeof(mbedtls_asn1_buf) ); + memset( &unipwd, 0, sizeof(unipwd) ); + + if( ( ret = pkcs12_parse_pbe_params( pbe_params, &salt, + &iterations ) ) != 0 ) + return( ret ); + + for( i = 0; i < pwdlen; i++ ) + unipwd[i * 2 + 1] = pwd[i]; + + if( ( ret = mbedtls_pkcs12_derivation( key, keylen, unipwd, pwdlen * 2 + 2, + salt.p, salt.len, md_type, + MBEDTLS_PKCS12_DERIVE_KEY, iterations ) ) != 0 ) + { + return( ret ); + } + + if( iv == NULL || ivlen == 0 ) + return( 0 ); + + if( ( ret = mbedtls_pkcs12_derivation( iv, ivlen, unipwd, pwdlen * 2 + 2, + salt.p, salt.len, md_type, + MBEDTLS_PKCS12_DERIVE_IV, iterations ) ) != 0 ) + { + return( ret ); + } + return( 0 ); +} + +#undef PKCS12_MAX_PWDLEN + +int mbedtls_pkcs12_pbe_sha1_rc4_128( mbedtls_asn1_buf *pbe_params, int mode, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *data, size_t len, + unsigned char *output ) +{ +#if !defined(MBEDTLS_ARC4_C) + ((void) pbe_params); + ((void) mode); + ((void) pwd); + ((void) pwdlen); + ((void) data); + ((void) len); + ((void) output); + return( MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE ); +#else + int ret; + unsigned char key[16]; + mbedtls_arc4_context ctx; + ((void) mode); + + mbedtls_arc4_init( &ctx ); + + if( ( ret = pkcs12_pbe_derive_key_iv( pbe_params, MBEDTLS_MD_SHA1, + pwd, pwdlen, + key, 16, NULL, 0 ) ) != 0 ) + { + return( ret ); + } + + mbedtls_arc4_setup( &ctx, key, 16 ); + if( ( ret = mbedtls_arc4_crypt( &ctx, len, data, output ) ) != 0 ) + goto exit; + +exit: + mbedtls_zeroize( key, sizeof( key ) ); + mbedtls_arc4_free( &ctx ); + + return( ret ); +#endif /* MBEDTLS_ARC4_C */ +} + +int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode, + mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *data, size_t len, + unsigned char *output ) +{ + int ret, keylen = 0; + unsigned char key[32]; + unsigned char iv[16]; + const mbedtls_cipher_info_t *cipher_info; + mbedtls_cipher_context_t cipher_ctx; + size_t olen = 0; + + cipher_info = mbedtls_cipher_info_from_type( cipher_type ); + if( cipher_info == NULL ) + return( MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE ); + + keylen = cipher_info->key_bitlen / 8; + + if( ( ret = pkcs12_pbe_derive_key_iv( pbe_params, md_type, pwd, pwdlen, + key, keylen, + iv, cipher_info->iv_size ) ) != 0 ) + { + return( ret ); + } + + mbedtls_cipher_init( &cipher_ctx ); + + if( ( ret = mbedtls_cipher_setup( &cipher_ctx, cipher_info ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_cipher_setkey( &cipher_ctx, key, 8 * keylen, (mbedtls_operation_t) mode ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_cipher_set_iv( &cipher_ctx, iv, cipher_info->iv_size ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_cipher_reset( &cipher_ctx ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_cipher_update( &cipher_ctx, data, len, + output, &olen ) ) != 0 ) + { + goto exit; + } + + if( ( ret = mbedtls_cipher_finish( &cipher_ctx, output + olen, &olen ) ) != 0 ) + ret = MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH; + +exit: + mbedtls_zeroize( key, sizeof( key ) ); + mbedtls_zeroize( iv, sizeof( iv ) ); + mbedtls_cipher_free( &cipher_ctx ); + + return( ret ); +} + +static void pkcs12_fill_buffer( unsigned char *data, size_t data_len, + const unsigned char *filler, size_t fill_len ) +{ + unsigned char *p = data; + size_t use_len; + + while( data_len > 0 ) + { + use_len = ( data_len > fill_len ) ? fill_len : data_len; + memcpy( p, filler, use_len ); + p += use_len; + data_len -= use_len; + } +} + +int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *salt, size_t saltlen, + mbedtls_md_type_t md_type, int id, int iterations ) +{ + int ret; + unsigned int j; + + unsigned char diversifier[128]; + unsigned char salt_block[128], pwd_block[128], hash_block[128]; + unsigned char hash_output[MBEDTLS_MD_MAX_SIZE]; + unsigned char *p; + unsigned char c; + + size_t hlen, use_len, v, i; + + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + + // This version only allows max of 64 bytes of password or salt + if( datalen > 128 || pwdlen > 64 || saltlen > 64 ) + return( MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA ); + + md_info = mbedtls_md_info_from_type( md_type ); + if( md_info == NULL ) + return( MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE ); + + mbedtls_md_init( &md_ctx ); + + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 ) + return( ret ); + hlen = mbedtls_md_get_size( md_info ); + + if( hlen <= 32 ) + v = 64; + else + v = 128; + + memset( diversifier, (unsigned char) id, v ); + + pkcs12_fill_buffer( salt_block, v, salt, saltlen ); + pkcs12_fill_buffer( pwd_block, v, pwd, pwdlen ); + + p = data; + while( datalen > 0 ) + { + // Calculate hash( diversifier || salt_block || pwd_block ) + if( ( ret = mbedtls_md_starts( &md_ctx ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_md_update( &md_ctx, diversifier, v ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_md_update( &md_ctx, salt_block, v ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_md_update( &md_ctx, pwd_block, v ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_md_finish( &md_ctx, hash_output ) ) != 0 ) + goto exit; + + // Perform remaining ( iterations - 1 ) recursive hash calculations + for( i = 1; i < (size_t) iterations; i++ ) + { + if( ( ret = mbedtls_md( md_info, hash_output, hlen, hash_output ) ) != 0 ) + goto exit; + } + + use_len = ( datalen > hlen ) ? hlen : datalen; + memcpy( p, hash_output, use_len ); + datalen -= use_len; + p += use_len; + + if( datalen == 0 ) + break; + + // Concatenating copies of hash_output into hash_block (B) + pkcs12_fill_buffer( hash_block, v, hash_output, hlen ); + + // B += 1 + for( i = v; i > 0; i-- ) + if( ++hash_block[i - 1] != 0 ) + break; + + // salt_block += B + c = 0; + for( i = v; i > 0; i-- ) + { + j = salt_block[i - 1] + hash_block[i - 1] + c; + c = (unsigned char) (j >> 8); + salt_block[i - 1] = j & 0xFF; + } + + // pwd_block += B + c = 0; + for( i = v; i > 0; i-- ) + { + j = pwd_block[i - 1] + hash_block[i - 1] + c; + c = (unsigned char) (j >> 8); + pwd_block[i - 1] = j & 0xFF; + } + } + + ret = 0; + +exit: + mbedtls_zeroize( salt_block, sizeof( salt_block ) ); + mbedtls_zeroize( pwd_block, sizeof( pwd_block ) ); + mbedtls_zeroize( hash_block, sizeof( hash_block ) ); + mbedtls_zeroize( hash_output, sizeof( hash_output ) ); + + mbedtls_md_free( &md_ctx ); + + return( ret ); +} + +#endif /* MBEDTLS_PKCS12_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs5.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs5.c new file mode 100644 index 0000000..e28d5a8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkcs5.c @@ -0,0 +1,406 @@ +/** + * \file pkcs5.c + * + * \brief PKCS#5 functions + * + * \author Mathias Olsson + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * PKCS#5 includes PBKDF2 and more + * + * http://tools.ietf.org/html/rfc2898 (Specification) + * http://tools.ietf.org/html/rfc6070 (Test vectors) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PKCS5_C) + +#include "mbedtls/pkcs5.h" +#include "mbedtls/asn1.h" +#include "mbedtls/cipher.h" +#include "mbedtls/oid.h" + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +static int pkcs5_parse_pbkdf2_params( const mbedtls_asn1_buf *params, + mbedtls_asn1_buf *salt, int *iterations, + int *keylen, mbedtls_md_type_t *md_type ) +{ + int ret; + mbedtls_asn1_buf prf_alg_oid; + unsigned char *p = params->p; + const unsigned char *end = params->p + params->len; + + if( params->tag != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + /* + * PBKDF2-params ::= SEQUENCE { + * salt OCTET STRING, + * iterationCount INTEGER, + * keyLength INTEGER OPTIONAL + * prf AlgorithmIdentifier DEFAULT algid-hmacWithSHA1 + * } + * + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &salt->len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret ); + + salt->p = p; + p += salt->len; + + if( ( ret = mbedtls_asn1_get_int( &p, end, iterations ) ) != 0 ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret ); + + if( p == end ) + return( 0 ); + + if( ( ret = mbedtls_asn1_get_int( &p, end, keylen ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret ); + } + + if( p == end ) + return( 0 ); + + if( ( ret = mbedtls_asn1_get_alg_null( &p, end, &prf_alg_oid ) ) != 0 ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret ); + + if( MBEDTLS_OID_CMP( MBEDTLS_OID_HMAC_SHA1, &prf_alg_oid ) != 0 ) + return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE ); + + *md_type = MBEDTLS_MD_SHA1; + + if( p != end ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode, + const unsigned char *pwd, size_t pwdlen, + const unsigned char *data, size_t datalen, + unsigned char *output ) +{ + int ret, iterations = 0, keylen = 0; + unsigned char *p, *end; + mbedtls_asn1_buf kdf_alg_oid, enc_scheme_oid, kdf_alg_params, enc_scheme_params; + mbedtls_asn1_buf salt; + mbedtls_md_type_t md_type = MBEDTLS_MD_SHA1; + unsigned char key[32], iv[32]; + size_t olen = 0; + const mbedtls_md_info_t *md_info; + const mbedtls_cipher_info_t *cipher_info; + mbedtls_md_context_t md_ctx; + mbedtls_cipher_type_t cipher_alg; + mbedtls_cipher_context_t cipher_ctx; + + p = pbe_params->p; + end = p + pbe_params->len; + + /* + * PBES2-params ::= SEQUENCE { + * keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}}, + * encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} + * } + */ + if( pbe_params->tag != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + if( ( ret = mbedtls_asn1_get_alg( &p, end, &kdf_alg_oid, &kdf_alg_params ) ) != 0 ) + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret ); + + // Only PBKDF2 supported at the moment + // + if( MBEDTLS_OID_CMP( MBEDTLS_OID_PKCS5_PBKDF2, &kdf_alg_oid ) != 0 ) + return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE ); + + if( ( ret = pkcs5_parse_pbkdf2_params( &kdf_alg_params, + &salt, &iterations, &keylen, + &md_type ) ) != 0 ) + { + return( ret ); + } + + md_info = mbedtls_md_info_from_type( md_type ); + if( md_info == NULL ) + return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE ); + + if( ( ret = mbedtls_asn1_get_alg( &p, end, &enc_scheme_oid, + &enc_scheme_params ) ) != 0 ) + { + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret ); + } + + if( mbedtls_oid_get_cipher_alg( &enc_scheme_oid, &cipher_alg ) != 0 ) + return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE ); + + cipher_info = mbedtls_cipher_info_from_type( cipher_alg ); + if( cipher_info == NULL ) + return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE ); + + /* + * The value of keylen from pkcs5_parse_pbkdf2_params() is ignored + * since it is optional and we don't know if it was set or not + */ + keylen = cipher_info->key_bitlen / 8; + + if( enc_scheme_params.tag != MBEDTLS_ASN1_OCTET_STRING || + enc_scheme_params.len != cipher_info->iv_size ) + { + return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT ); + } + + mbedtls_md_init( &md_ctx ); + mbedtls_cipher_init( &cipher_ctx ); + + memcpy( iv, enc_scheme_params.p, enc_scheme_params.len ); + + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 1 ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_pkcs5_pbkdf2_hmac( &md_ctx, pwd, pwdlen, salt.p, salt.len, + iterations, keylen, key ) ) != 0 ) + { + goto exit; + } + + if( ( ret = mbedtls_cipher_setup( &cipher_ctx, cipher_info ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_cipher_setkey( &cipher_ctx, key, 8 * keylen, (mbedtls_operation_t) mode ) ) != 0 ) + goto exit; + + if( ( ret = mbedtls_cipher_crypt( &cipher_ctx, iv, enc_scheme_params.len, + data, datalen, output, &olen ) ) != 0 ) + ret = MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH; + +exit: + mbedtls_md_free( &md_ctx ); + mbedtls_cipher_free( &cipher_ctx ); + + return( ret ); +} + +int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *password, + size_t plen, const unsigned char *salt, size_t slen, + unsigned int iteration_count, + uint32_t key_length, unsigned char *output ) +{ + int ret, j; + unsigned int i; + unsigned char md1[MBEDTLS_MD_MAX_SIZE]; + unsigned char work[MBEDTLS_MD_MAX_SIZE]; + unsigned char md_size = mbedtls_md_get_size( ctx->md_info ); + size_t use_len; + unsigned char *out_p = output; + unsigned char counter[4]; + + memset( counter, 0, 4 ); + counter[3] = 1; + + if( iteration_count > 0xFFFFFFFF ) + return( MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA ); + + while( key_length ) + { + // U1 ends up in work + // + if( ( ret = mbedtls_md_hmac_starts( ctx, password, plen ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_md_hmac_update( ctx, salt, slen ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_md_hmac_update( ctx, counter, 4 ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_md_hmac_finish( ctx, work ) ) != 0 ) + return( ret ); + + memcpy( md1, work, md_size ); + + for( i = 1; i < iteration_count; i++ ) + { + // U2 ends up in md1 + // + if( ( ret = mbedtls_md_hmac_starts( ctx, password, plen ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_md_hmac_update( ctx, md1, md_size ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_md_hmac_finish( ctx, md1 ) ) != 0 ) + return( ret ); + + // U1 xor U2 + // + for( j = 0; j < md_size; j++ ) + work[j] ^= md1[j]; + } + + use_len = ( key_length < md_size ) ? key_length : md_size; + memcpy( out_p, work, use_len ); + + key_length -= (uint32_t) use_len; + out_p += use_len; + + for( i = 4; i > 0; i-- ) + if( ++counter[i - 1] != 0 ) + break; + } + + return( 0 ); +} + +#if defined(MBEDTLS_SELF_TEST) + +#if !defined(MBEDTLS_SHA1_C) +int mbedtls_pkcs5_self_test( int verbose ) +{ + if( verbose != 0 ) + mbedtls_printf( " PBKDF2 (SHA1): skipped\n\n" ); + + return( 0 ); +} +#else + +#define MAX_TESTS 6 + +static const size_t plen[MAX_TESTS] = + { 8, 8, 8, 24, 9 }; + +static const unsigned char password[MAX_TESTS][32] = +{ + "password", + "password", + "password", + "passwordPASSWORDpassword", + "pass\0word", +}; + +static const size_t slen[MAX_TESTS] = + { 4, 4, 4, 36, 5 }; + +static const unsigned char salt[MAX_TESTS][40] = +{ + "salt", + "salt", + "salt", + "saltSALTsaltSALTsaltSALTsaltSALTsalt", + "sa\0lt", +}; + +static const uint32_t it_cnt[MAX_TESTS] = + { 1, 2, 4096, 4096, 4096 }; + +static const uint32_t key_len[MAX_TESTS] = + { 20, 20, 20, 25, 16 }; + +static const unsigned char result_key[MAX_TESTS][32] = +{ + { 0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, + 0xf3, 0xa9, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, + 0x2f, 0xe0, 0x37, 0xa6 }, + { 0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, + 0xcd, 0x1e, 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0, + 0xd8, 0xde, 0x89, 0x57 }, + { 0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, + 0xbe, 0xad, 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0, + 0x65, 0xa4, 0x29, 0xc1 }, + { 0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, + 0x80, 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a, + 0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70, + 0x38 }, + { 0x56, 0xfa, 0x6a, 0xa7, 0x55, 0x48, 0x09, 0x9d, + 0xcc, 0x37, 0xd7, 0xf0, 0x34, 0x25, 0xe0, 0xc3 }, +}; + +int mbedtls_pkcs5_self_test( int verbose ) +{ + mbedtls_md_context_t sha1_ctx; + const mbedtls_md_info_t *info_sha1; + int ret, i; + unsigned char key[64]; + + mbedtls_md_init( &sha1_ctx ); + + info_sha1 = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ); + if( info_sha1 == NULL ) + { + ret = 1; + goto exit; + } + + if( ( ret = mbedtls_md_setup( &sha1_ctx, info_sha1, 1 ) ) != 0 ) + { + ret = 1; + goto exit; + } + + for( i = 0; i < MAX_TESTS; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " PBKDF2 (SHA1) #%d: ", i ); + + ret = mbedtls_pkcs5_pbkdf2_hmac( &sha1_ctx, password[i], plen[i], salt[i], + slen[i], it_cnt[i], key_len[i], key ); + if( ret != 0 || + memcmp( result_key[i], key, key_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_md_free( &sha1_ctx ); + + return( ret ); +} +#endif /* MBEDTLS_SHA1_C */ + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_PKCS5_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkparse.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkparse.c new file mode 100644 index 0000000..efdf437 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkparse.c @@ -0,0 +1,1293 @@ +/* + * Public Key layer for parsing key files and structures + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PK_PARSE_C) + +#include "mbedtls/pk.h" +#include "mbedtls/asn1.h" +#include "mbedtls/oid.h" + +#include + +#if defined(MBEDTLS_RSA_C) +#include "mbedtls/rsa.h" +#endif +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif +#if defined(MBEDTLS_ECDSA_C) +#include "mbedtls/ecdsa.h" +#endif +#if defined(MBEDTLS_PEM_PARSE_C) +#include "mbedtls/pem.h" +#endif +#if defined(MBEDTLS_PKCS5_C) +#include "mbedtls/pkcs5.h" +#endif +#if defined(MBEDTLS_PKCS12_C) +#include "mbedtls/pkcs12.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if defined(MBEDTLS_FS_IO) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Load all data from a file into a given buffer. + * + * The file is expected to contain either PEM or DER encoded data. + * A terminating null byte is always appended. It is included in the announced + * length only if the data looks like it is PEM encoded. + */ +int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n ) +{ + FILE *f; + long size; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( MBEDTLS_ERR_PK_FILE_IO_ERROR ); + + fseek( f, 0, SEEK_END ); + if( ( size = ftell( f ) ) == -1 ) + { + fclose( f ); + return( MBEDTLS_ERR_PK_FILE_IO_ERROR ); + } + fseek( f, 0, SEEK_SET ); + + *n = (size_t) size; + + if( *n + 1 == 0 || + ( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL ) + { + fclose( f ); + return( MBEDTLS_ERR_PK_ALLOC_FAILED ); + } + + if( fread( *buf, 1, *n, f ) != *n ) + { + fclose( f ); + mbedtls_free( *buf ); + return( MBEDTLS_ERR_PK_FILE_IO_ERROR ); + } + + fclose( f ); + + (*buf)[*n] = '\0'; + + if( strstr( (const char *) *buf, "-----BEGIN " ) != NULL ) + ++*n; + + return( 0 ); +} + +/* + * Load and parse a private key + */ +int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, + const char *path, const char *pwd ) +{ + int ret; + size_t n; + unsigned char *buf; + + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) + return( ret ); + + if( pwd == NULL ) + ret = mbedtls_pk_parse_key( ctx, buf, n, NULL, 0 ); + else + ret = mbedtls_pk_parse_key( ctx, buf, n, + (const unsigned char *) pwd, strlen( pwd ) ); + + mbedtls_zeroize( buf, n ); + mbedtls_free( buf ); + + return( ret ); +} + +/* + * Load and parse a public key + */ +int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ) +{ + int ret; + size_t n; + unsigned char *buf; + + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) + return( ret ); + + ret = mbedtls_pk_parse_public_key( ctx, buf, n ); + + mbedtls_zeroize( buf, n ); + mbedtls_free( buf ); + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ + +#if defined(MBEDTLS_ECP_C) +/* Minimally parse an ECParameters buffer to and mbedtls_asn1_buf + * + * ECParameters ::= CHOICE { + * namedCurve OBJECT IDENTIFIER + * specifiedCurve SpecifiedECDomain -- = SEQUENCE { ... } + * -- implicitCurve NULL + * } + */ +static int pk_get_ecparams( unsigned char **p, const unsigned char *end, + mbedtls_asn1_buf *params ) +{ + int ret; + + /* Tag may be either OID or SEQUENCE */ + params->tag = **p; + if( params->tag != MBEDTLS_ASN1_OID +#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED) + && params->tag != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) +#endif + ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + } + + if( ( ret = mbedtls_asn1_get_tag( p, end, ¶ms->len, params->tag ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + params->p = *p; + *p += params->len; + + if( *p != end ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED) +/* + * Parse a SpecifiedECDomain (SEC 1 C.2) and (mostly) fill the group with it. + * WARNING: the resulting group should only be used with + * pk_group_id_from_specified(), since its base point may not be set correctly + * if it was encoded compressed. + * + * SpecifiedECDomain ::= SEQUENCE { + * version SpecifiedECDomainVersion(ecdpVer1 | ecdpVer2 | ecdpVer3, ...), + * fieldID FieldID {{FieldTypes}}, + * curve Curve, + * base ECPoint, + * order INTEGER, + * cofactor INTEGER OPTIONAL, + * hash HashAlgorithm OPTIONAL, + * ... + * } + * + * We only support prime-field as field type, and ignore hash and cofactor. + */ +static int pk_group_from_specified( const mbedtls_asn1_buf *params, mbedtls_ecp_group *grp ) +{ + int ret; + unsigned char *p = params->p; + const unsigned char * const end = params->p + params->len; + const unsigned char *end_field, *end_curve; + size_t len; + int ver; + + /* SpecifiedECDomainVersion ::= INTEGER { 1, 2, 3 } */ + if( ( ret = mbedtls_asn1_get_int( &p, end, &ver ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( ver < 1 || ver > 3 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + + /* + * FieldID { FIELD-ID:IOSet } ::= SEQUENCE { -- Finite field + * fieldType FIELD-ID.&id({IOSet}), + * parameters FIELD-ID.&Type({IOSet}{@fieldType}) + * } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( ret ); + + end_field = p + len; + + /* + * FIELD-ID ::= TYPE-IDENTIFIER + * FieldTypes FIELD-ID ::= { + * { Prime-p IDENTIFIED BY prime-field } | + * { Characteristic-two IDENTIFIED BY characteristic-two-field } + * } + * prime-field OBJECT IDENTIFIER ::= { id-fieldType 1 } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end_field, &len, MBEDTLS_ASN1_OID ) ) != 0 ) + return( ret ); + + if( len != MBEDTLS_OID_SIZE( MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD ) || + memcmp( p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len ) != 0 ) + { + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + } + + p += len; + + /* Prime-p ::= INTEGER -- Field of size p. */ + if( ( ret = mbedtls_asn1_get_mpi( &p, end_field, &grp->P ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + grp->pbits = mbedtls_mpi_bitlen( &grp->P ); + + if( p != end_field ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + /* + * Curve ::= SEQUENCE { + * a FieldElement, + * b FieldElement, + * seed BIT STRING OPTIONAL + * -- Shall be present if used in SpecifiedECDomain + * -- with version equal to ecdpVer2 or ecdpVer3 + * } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( ret ); + + end_curve = p + len; + + /* + * FieldElement ::= OCTET STRING + * containing an integer in the case of a prime field + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 || + ( ret = mbedtls_mpi_read_binary( &grp->A, p, len ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + p += len; + + if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 || + ( ret = mbedtls_mpi_read_binary( &grp->B, p, len ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + p += len; + + /* Ignore seed BIT STRING OPTIONAL */ + if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_BIT_STRING ) ) == 0 ) + p += len; + + if( p != end_curve ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + /* + * ECPoint ::= OCTET STRING + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( ( ret = mbedtls_ecp_point_read_binary( grp, &grp->G, + ( const unsigned char *) p, len ) ) != 0 ) + { + /* + * If we can't read the point because it's compressed, cheat by + * reading only the X coordinate and the parity bit of Y. + */ + if( ret != MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE || + ( p[0] != 0x02 && p[0] != 0x03 ) || + len != mbedtls_mpi_size( &grp->P ) + 1 || + mbedtls_mpi_read_binary( &grp->G.X, p + 1, len - 1 ) != 0 || + mbedtls_mpi_lset( &grp->G.Y, p[0] - 2 ) != 0 || + mbedtls_mpi_lset( &grp->G.Z, 1 ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + } + } + + p += len; + + /* + * order INTEGER + */ + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &grp->N ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + grp->nbits = mbedtls_mpi_bitlen( &grp->N ); + + /* + * Allow optional elements by purposefully not enforcing p == end here. + */ + + return( 0 ); +} + +/* + * Find the group id associated with an (almost filled) group as generated by + * pk_group_from_specified(), or return an error if unknown. + */ +static int pk_group_id_from_group( const mbedtls_ecp_group *grp, mbedtls_ecp_group_id *grp_id ) +{ + int ret = 0; + mbedtls_ecp_group ref; + const mbedtls_ecp_group_id *id; + + mbedtls_ecp_group_init( &ref ); + + for( id = mbedtls_ecp_grp_id_list(); *id != MBEDTLS_ECP_DP_NONE; id++ ) + { + /* Load the group associated to that id */ + mbedtls_ecp_group_free( &ref ); + MBEDTLS_MPI_CHK( mbedtls_ecp_group_load( &ref, *id ) ); + + /* Compare to the group we were given, starting with easy tests */ + if( grp->pbits == ref.pbits && grp->nbits == ref.nbits && + mbedtls_mpi_cmp_mpi( &grp->P, &ref.P ) == 0 && + mbedtls_mpi_cmp_mpi( &grp->A, &ref.A ) == 0 && + mbedtls_mpi_cmp_mpi( &grp->B, &ref.B ) == 0 && + mbedtls_mpi_cmp_mpi( &grp->N, &ref.N ) == 0 && + mbedtls_mpi_cmp_mpi( &grp->G.X, &ref.G.X ) == 0 && + mbedtls_mpi_cmp_mpi( &grp->G.Z, &ref.G.Z ) == 0 && + /* For Y we may only know the parity bit, so compare only that */ + mbedtls_mpi_get_bit( &grp->G.Y, 0 ) == mbedtls_mpi_get_bit( &ref.G.Y, 0 ) ) + { + break; + } + + } + +cleanup: + mbedtls_ecp_group_free( &ref ); + + *grp_id = *id; + + if( ret == 0 && *id == MBEDTLS_ECP_DP_NONE ) + ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; + + return( ret ); +} + +/* + * Parse a SpecifiedECDomain (SEC 1 C.2) and find the associated group ID + */ +static int pk_group_id_from_specified( const mbedtls_asn1_buf *params, + mbedtls_ecp_group_id *grp_id ) +{ + int ret; + mbedtls_ecp_group grp; + + mbedtls_ecp_group_init( &grp ); + + if( ( ret = pk_group_from_specified( params, &grp ) ) != 0 ) + goto cleanup; + + ret = pk_group_id_from_group( &grp, grp_id ); + +cleanup: + mbedtls_ecp_group_free( &grp ); + + return( ret ); +} +#endif /* MBEDTLS_PK_PARSE_EC_EXTENDED */ + +/* + * Use EC parameters to initialise an EC group + * + * ECParameters ::= CHOICE { + * namedCurve OBJECT IDENTIFIER + * specifiedCurve SpecifiedECDomain -- = SEQUENCE { ... } + * -- implicitCurve NULL + */ +static int pk_use_ecparams( const mbedtls_asn1_buf *params, mbedtls_ecp_group *grp ) +{ + int ret; + mbedtls_ecp_group_id grp_id; + + if( params->tag == MBEDTLS_ASN1_OID ) + { + if( mbedtls_oid_get_ec_grp( params, &grp_id ) != 0 ) + return( MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE ); + } + else + { +#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED) + if( ( ret = pk_group_id_from_specified( params, &grp_id ) ) != 0 ) + return( ret ); +#else + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); +#endif + } + + /* + * grp may already be initilialized; if so, make sure IDs match + */ + if( grp->id != MBEDTLS_ECP_DP_NONE && grp->id != grp_id ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + + if( ( ret = mbedtls_ecp_group_load( grp, grp_id ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +/* + * EC public key is an EC point + * + * The caller is responsible for clearing the structure upon failure if + * desired. Take care to pass along the possible ECP_FEATURE_UNAVAILABLE + * return code of mbedtls_ecp_point_read_binary() and leave p in a usable state. + */ +static int pk_get_ecpubkey( unsigned char **p, const unsigned char *end, + mbedtls_ecp_keypair *key ) +{ + int ret; + + if( ( ret = mbedtls_ecp_point_read_binary( &key->grp, &key->Q, + (const unsigned char *) *p, end - *p ) ) == 0 ) + { + ret = mbedtls_ecp_check_pubkey( &key->grp, &key->Q ); + } + + /* + * We know mbedtls_ecp_point_read_binary consumed all bytes or failed + */ + *p = (unsigned char *) end; + + return( ret ); +} +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_RSA_C) +/* + * RSAPublicKey ::= SEQUENCE { + * modulus INTEGER, -- n + * publicExponent INTEGER -- e + * } + */ +static int pk_get_rsapubkey( unsigned char **p, + const unsigned char *end, + mbedtls_rsa_context *rsa ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY + ret ); + + if( *p + len != end ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + if( ( ret = mbedtls_asn1_get_mpi( p, end, &rsa->N ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( p, end, &rsa->E ) ) != 0 ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY + ret ); + + if( *p != end ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + if( ( ret = mbedtls_rsa_check_pubkey( rsa ) ) != 0 ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY ); + + rsa->len = mbedtls_mpi_size( &rsa->N ); + + return( 0 ); +} +#endif /* MBEDTLS_RSA_C */ + +/* Get a PK algorithm identifier + * + * AlgorithmIdentifier ::= SEQUENCE { + * algorithm OBJECT IDENTIFIER, + * parameters ANY DEFINED BY algorithm OPTIONAL } + */ +static int pk_get_pk_alg( unsigned char **p, + const unsigned char *end, + mbedtls_pk_type_t *pk_alg, mbedtls_asn1_buf *params ) +{ + int ret; + mbedtls_asn1_buf alg_oid; + + memset( params, 0, sizeof(mbedtls_asn1_buf) ); + + if( ( ret = mbedtls_asn1_get_alg( p, end, &alg_oid, params ) ) != 0 ) + return( MBEDTLS_ERR_PK_INVALID_ALG + ret ); + + if( mbedtls_oid_get_pk_alg( &alg_oid, pk_alg ) != 0 ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + /* + * No parameters with RSA (only for EC) + */ + if( *pk_alg == MBEDTLS_PK_RSA && + ( ( params->tag != MBEDTLS_ASN1_NULL && params->tag != 0 ) || + params->len != 0 ) ) + { + return( MBEDTLS_ERR_PK_INVALID_ALG ); + } + + return( 0 ); +} + +/* + * SubjectPublicKeyInfo ::= SEQUENCE { + * algorithm AlgorithmIdentifier, + * subjectPublicKey BIT STRING } + */ +int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end, + mbedtls_pk_context *pk ) +{ + int ret; + size_t len; + mbedtls_asn1_buf alg_params; + mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE; + const mbedtls_pk_info_t *pk_info; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + end = *p + len; + + if( ( ret = pk_get_pk_alg( p, end, &pk_alg, &alg_params ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_asn1_get_bitstring_null( p, end, &len ) ) != 0 ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY + ret ); + + if( *p + len != end ) + return( MBEDTLS_ERR_PK_INVALID_PUBKEY + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + if( ( pk_info = mbedtls_pk_info_from_type( pk_alg ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ) + return( ret ); + +#if defined(MBEDTLS_RSA_C) + if( pk_alg == MBEDTLS_PK_RSA ) + { + ret = pk_get_rsapubkey( p, end, mbedtls_pk_rsa( *pk ) ); + } else +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECP_C) + if( pk_alg == MBEDTLS_PK_ECKEY_DH || pk_alg == MBEDTLS_PK_ECKEY ) + { + ret = pk_use_ecparams( &alg_params, &mbedtls_pk_ec( *pk )->grp ); + if( ret == 0 ) + ret = pk_get_ecpubkey( p, end, mbedtls_pk_ec( *pk ) ); + } else +#endif /* MBEDTLS_ECP_C */ + ret = MBEDTLS_ERR_PK_UNKNOWN_PK_ALG; + + if( ret == 0 && *p != end ) + ret = MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH; + + if( ret != 0 ) + mbedtls_pk_free( pk ); + + return( ret ); +} + +#if defined(MBEDTLS_RSA_C) +/* + * Parse a PKCS#1 encoded private RSA key + */ +static int pk_parse_key_pkcs1_der( mbedtls_rsa_context *rsa, + const unsigned char *key, + size_t keylen ) +{ + int ret; + size_t len; + unsigned char *p, *end; + + p = (unsigned char *) key; + end = p + keylen; + + /* + * This function parses the RSAPrivateKey (PKCS#1) + * + * RSAPrivateKey ::= SEQUENCE { + * version Version, + * modulus INTEGER, -- n + * publicExponent INTEGER, -- e + * privateExponent INTEGER, -- d + * prime1 INTEGER, -- p + * prime2 INTEGER, -- q + * exponent1 INTEGER, -- d mod (p-1) + * exponent2 INTEGER, -- d mod (q-1) + * coefficient INTEGER, -- (inverse of q) mod p + * otherPrimeInfos OtherPrimeInfos OPTIONAL + * } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + end = p + len; + + if( ( ret = mbedtls_asn1_get_int( &p, end, &rsa->ver ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + if( rsa->ver != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_VERSION ); + } + + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->N ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->E ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->D ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->P ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->Q ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DP ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DQ ) ) != 0 || + ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->QP ) ) != 0 ) + { + mbedtls_rsa_free( rsa ); + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + rsa->len = mbedtls_mpi_size( &rsa->N ); + + if( p != end ) + { + mbedtls_rsa_free( rsa ); + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + if( ( ret = mbedtls_rsa_check_privkey( rsa ) ) != 0 ) + { + mbedtls_rsa_free( rsa ); + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) +/* + * Parse a SEC1 encoded private EC key + */ +static int pk_parse_key_sec1_der( mbedtls_ecp_keypair *eck, + const unsigned char *key, + size_t keylen ) +{ + int ret; + int version, pubkey_done; + size_t len; + mbedtls_asn1_buf params; + unsigned char *p = (unsigned char *) key; + unsigned char *end = p + keylen; + unsigned char *end2; + + /* + * RFC 5915, or SEC1 Appendix C.4 + * + * ECPrivateKey ::= SEQUENCE { + * version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1), + * privateKey OCTET STRING, + * parameters [0] ECParameters {{ NamedCurve }} OPTIONAL, + * publicKey [1] BIT STRING OPTIONAL + * } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + end = p + len; + + if( ( ret = mbedtls_asn1_get_int( &p, end, &version ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( version != 1 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_VERSION ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( ( ret = mbedtls_mpi_read_binary( &eck->d, p, len ) ) != 0 ) + { + mbedtls_ecp_keypair_free( eck ); + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + p += len; + + pubkey_done = 0; + if( p != end ) + { + /* + * Is 'parameters' present? + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 0 ) ) == 0 ) + { + if( ( ret = pk_get_ecparams( &p, p + len, ¶ms) ) != 0 || + ( ret = pk_use_ecparams( ¶ms, &eck->grp ) ) != 0 ) + { + mbedtls_ecp_keypair_free( eck ); + return( ret ); + } + } + else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + { + mbedtls_ecp_keypair_free( eck ); + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + /* + * Is 'publickey' present? If not, or if we can't read it (eg because it + * is compressed), create it from the private key. + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 1 ) ) == 0 ) + { + end2 = p + len; + + if( ( ret = mbedtls_asn1_get_bitstring_null( &p, end2, &len ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( p + len != end2 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + if( ( ret = pk_get_ecpubkey( &p, end2, eck ) ) == 0 ) + pubkey_done = 1; + else + { + /* + * The only acceptable failure mode of pk_get_ecpubkey() above + * is if the point format is not recognized. + */ + if( ret != MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + } + } + else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + { + mbedtls_ecp_keypair_free( eck ); + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + } + + if( ! pubkey_done && + ( ret = mbedtls_ecp_mul( &eck->grp, &eck->Q, &eck->d, &eck->grp.G, + NULL, NULL ) ) != 0 ) + { + mbedtls_ecp_keypair_free( eck ); + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + if( ( ret = mbedtls_ecp_check_privkey( &eck->grp, &eck->d ) ) != 0 ) + { + mbedtls_ecp_keypair_free( eck ); + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_ECP_C */ + +/* + * Parse an unencrypted PKCS#8 encoded private key + */ +static int pk_parse_key_pkcs8_unencrypted_der( + mbedtls_pk_context *pk, + const unsigned char* key, + size_t keylen ) +{ + int ret, version; + size_t len; + mbedtls_asn1_buf params; + unsigned char *p = (unsigned char *) key; + unsigned char *end = p + keylen; + mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE; + const mbedtls_pk_info_t *pk_info; + + /* + * This function parses the PrivatKeyInfo object (PKCS#8 v1.2 = RFC 5208) + * + * PrivateKeyInfo ::= SEQUENCE { + * version Version, + * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, + * privateKey PrivateKey, + * attributes [0] IMPLICIT Attributes OPTIONAL } + * + * Version ::= INTEGER + * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier + * PrivateKey ::= OCTET STRING + * + * The PrivateKey OCTET STRING is a SEC1 ECPrivateKey + */ + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + end = p + len; + + if( ( ret = mbedtls_asn1_get_int( &p, end, &version ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( version != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_VERSION + ret ); + + if( ( ret = pk_get_pk_alg( &p, end, &pk_alg, ¶ms ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( len < 1 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + if( ( pk_info = mbedtls_pk_info_from_type( pk_alg ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ) + return( ret ); + +#if defined(MBEDTLS_RSA_C) + if( pk_alg == MBEDTLS_PK_RSA ) + { + if( ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ), p, len ) ) != 0 ) + { + mbedtls_pk_free( pk ); + return( ret ); + } + } else +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECP_C) + if( pk_alg == MBEDTLS_PK_ECKEY || pk_alg == MBEDTLS_PK_ECKEY_DH ) + { + if( ( ret = pk_use_ecparams( ¶ms, &mbedtls_pk_ec( *pk )->grp ) ) != 0 || + ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), p, len ) ) != 0 ) + { + mbedtls_pk_free( pk ); + return( ret ); + } + } else +#endif /* MBEDTLS_ECP_C */ + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + return( 0 ); +} + +/* + * Parse an encrypted PKCS#8 encoded private key + */ +#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) +static int pk_parse_key_pkcs8_encrypted_der( + mbedtls_pk_context *pk, + const unsigned char *key, size_t keylen, + const unsigned char *pwd, size_t pwdlen ) +{ + int ret, decrypted = 0; + size_t len; + unsigned char buf[2048]; + unsigned char *p, *end; + mbedtls_asn1_buf pbe_alg_oid, pbe_params; +#if defined(MBEDTLS_PKCS12_C) + mbedtls_cipher_type_t cipher_alg; + mbedtls_md_type_t md_alg; +#endif + + memset( buf, 0, sizeof( buf ) ); + + p = (unsigned char *) key; + end = p + keylen; + + if( pwdlen == 0 ) + return( MBEDTLS_ERR_PK_PASSWORD_REQUIRED ); + + /* + * This function parses the EncryptedPrivatKeyInfo object (PKCS#8) + * + * EncryptedPrivateKeyInfo ::= SEQUENCE { + * encryptionAlgorithm EncryptionAlgorithmIdentifier, + * encryptedData EncryptedData + * } + * + * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier + * + * EncryptedData ::= OCTET STRING + * + * The EncryptedData OCTET STRING is a PKCS#8 PrivateKeyInfo + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + } + + end = p + len; + + if( ( ret = mbedtls_asn1_get_alg( &p, end, &pbe_alg_oid, &pbe_params ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + + if( len > sizeof( buf ) ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + /* + * Decrypt EncryptedData with appropriate PDE + */ +#if defined(MBEDTLS_PKCS12_C) + if( mbedtls_oid_get_pkcs12_pbe_alg( &pbe_alg_oid, &md_alg, &cipher_alg ) == 0 ) + { + if( ( ret = mbedtls_pkcs12_pbe( &pbe_params, MBEDTLS_PKCS12_PBE_DECRYPT, + cipher_alg, md_alg, + pwd, pwdlen, p, len, buf ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH ) + return( MBEDTLS_ERR_PK_PASSWORD_MISMATCH ); + + return( ret ); + } + + decrypted = 1; + } + else if( MBEDTLS_OID_CMP( MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_128, &pbe_alg_oid ) == 0 ) + { + if( ( ret = mbedtls_pkcs12_pbe_sha1_rc4_128( &pbe_params, + MBEDTLS_PKCS12_PBE_DECRYPT, + pwd, pwdlen, + p, len, buf ) ) != 0 ) + { + return( ret ); + } + + // Best guess for password mismatch when using RC4. If first tag is + // not MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE + // + if( *buf != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) + return( MBEDTLS_ERR_PK_PASSWORD_MISMATCH ); + + decrypted = 1; + } + else +#endif /* MBEDTLS_PKCS12_C */ +#if defined(MBEDTLS_PKCS5_C) + if( MBEDTLS_OID_CMP( MBEDTLS_OID_PKCS5_PBES2, &pbe_alg_oid ) == 0 ) + { + if( ( ret = mbedtls_pkcs5_pbes2( &pbe_params, MBEDTLS_PKCS5_DECRYPT, pwd, pwdlen, + p, len, buf ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH ) + return( MBEDTLS_ERR_PK_PASSWORD_MISMATCH ); + + return( ret ); + } + + decrypted = 1; + } + else +#endif /* MBEDTLS_PKCS5_C */ + { + ((void) pwd); + } + + if( decrypted == 0 ) + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + + return( pk_parse_key_pkcs8_unencrypted_der( pk, buf, len ) ); +} +#endif /* MBEDTLS_PKCS12_C || MBEDTLS_PKCS5_C */ + +/* + * Parse a private key + */ +int mbedtls_pk_parse_key( mbedtls_pk_context *pk, + const unsigned char *key, size_t keylen, + const unsigned char *pwd, size_t pwdlen ) +{ + int ret; + const mbedtls_pk_info_t *pk_info; + +#if defined(MBEDTLS_PEM_PARSE_C) + size_t len; + mbedtls_pem_context pem; + + mbedtls_pem_init( &pem ); + +#if defined(MBEDTLS_RSA_C) + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( keylen == 0 || key[keylen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN RSA PRIVATE KEY-----", + "-----END RSA PRIVATE KEY-----", + key, pwd, pwdlen, &len ); + + if( ret == 0 ) + { + if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 || + ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ), + pem.buf, pem.buflen ) ) != 0 ) + { + mbedtls_pk_free( pk ); + } + + mbedtls_pem_free( &pem ); + return( ret ); + } + else if( ret == MBEDTLS_ERR_PEM_PASSWORD_MISMATCH ) + return( MBEDTLS_ERR_PK_PASSWORD_MISMATCH ); + else if( ret == MBEDTLS_ERR_PEM_PASSWORD_REQUIRED ) + return( MBEDTLS_ERR_PK_PASSWORD_REQUIRED ); + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + return( ret ); +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( keylen == 0 || key[keylen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN EC PRIVATE KEY-----", + "-----END EC PRIVATE KEY-----", + key, pwd, pwdlen, &len ); + if( ret == 0 ) + { + if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 || + ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), + pem.buf, pem.buflen ) ) != 0 ) + { + mbedtls_pk_free( pk ); + } + + mbedtls_pem_free( &pem ); + return( ret ); + } + else if( ret == MBEDTLS_ERR_PEM_PASSWORD_MISMATCH ) + return( MBEDTLS_ERR_PK_PASSWORD_MISMATCH ); + else if( ret == MBEDTLS_ERR_PEM_PASSWORD_REQUIRED ) + return( MBEDTLS_ERR_PK_PASSWORD_REQUIRED ); + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + return( ret ); +#endif /* MBEDTLS_ECP_C */ + + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( keylen == 0 || key[keylen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN PRIVATE KEY-----", + "-----END PRIVATE KEY-----", + key, NULL, 0, &len ); + if( ret == 0 ) + { + if( ( ret = pk_parse_key_pkcs8_unencrypted_der( pk, + pem.buf, pem.buflen ) ) != 0 ) + { + mbedtls_pk_free( pk ); + } + + mbedtls_pem_free( &pem ); + return( ret ); + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + return( ret ); + +#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( keylen == 0 || key[keylen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN ENCRYPTED PRIVATE KEY-----", + "-----END ENCRYPTED PRIVATE KEY-----", + key, NULL, 0, &len ); + if( ret == 0 ) + { + if( ( ret = pk_parse_key_pkcs8_encrypted_der( pk, + pem.buf, pem.buflen, + pwd, pwdlen ) ) != 0 ) + { + mbedtls_pk_free( pk ); + } + + mbedtls_pem_free( &pem ); + return( ret ); + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + return( ret ); +#endif /* MBEDTLS_PKCS12_C || MBEDTLS_PKCS5_C */ +#else + ((void) ret); + ((void) pwd); + ((void) pwdlen); +#endif /* MBEDTLS_PEM_PARSE_C */ + + /* + * At this point we only know it's not a PEM formatted key. Could be any + * of the known DER encoded private key formats + * + * We try the different DER format parsers to see if one passes without + * error + */ +#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) + if( ( ret = pk_parse_key_pkcs8_encrypted_der( pk, key, keylen, + pwd, pwdlen ) ) == 0 ) + { + return( 0 ); + } + + mbedtls_pk_free( pk ); + + if( ret == MBEDTLS_ERR_PK_PASSWORD_MISMATCH ) + { + return( ret ); + } +#endif /* MBEDTLS_PKCS12_C || MBEDTLS_PKCS5_C */ + + if( ( ret = pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen ) ) == 0 ) + return( 0 ); + + mbedtls_pk_free( pk ); + +#if defined(MBEDTLS_RSA_C) + if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 || + ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ), key, keylen ) ) == 0 ) + { + return( 0 ); + } + + mbedtls_pk_free( pk ); +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) + if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 || + ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), key, keylen ) ) == 0 ) + { + return( 0 ); + } + + mbedtls_pk_free( pk ); +#endif /* MBEDTLS_ECP_C */ + + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); +} + +/* + * Parse a public key + */ +int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx, + const unsigned char *key, size_t keylen ) +{ + int ret; + unsigned char *p; +#if defined(MBEDTLS_PEM_PARSE_C) + size_t len; + mbedtls_pem_context pem; + + mbedtls_pem_init( &pem ); + + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( keylen == 0 || key[keylen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN PUBLIC KEY-----", + "-----END PUBLIC KEY-----", + key, NULL, 0, &len ); + + if( ret == 0 ) + { + /* + * Was PEM encoded + */ + key = pem.buf; + keylen = pem.buflen; + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + { + mbedtls_pem_free( &pem ); + return( ret ); + } +#endif /* MBEDTLS_PEM_PARSE_C */ + p = (unsigned char *) key; + + ret = mbedtls_pk_parse_subpubkey( &p, p + keylen, ctx ); + +#if defined(MBEDTLS_PEM_PARSE_C) + mbedtls_pem_free( &pem ); +#endif + + return( ret ); +} + +#endif /* MBEDTLS_PK_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkwrite.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkwrite.c new file mode 100644 index 0000000..83b798c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/pkwrite.c @@ -0,0 +1,439 @@ +/* + * Public Key layer for writing key files and structures + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PK_WRITE_C) + +#include "mbedtls/pk.h" +#include "mbedtls/asn1write.h" +#include "mbedtls/oid.h" + +#include + +#if defined(MBEDTLS_RSA_C) +#include "mbedtls/rsa.h" +#endif +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif +#if defined(MBEDTLS_ECDSA_C) +#include "mbedtls/ecdsa.h" +#endif +#if defined(MBEDTLS_PEM_WRITE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#if defined(MBEDTLS_RSA_C) +/* + * RSAPublicKey ::= SEQUENCE { + * modulus INTEGER, -- n + * publicExponent INTEGER -- e + * } + */ +static int pk_write_rsa_pubkey( unsigned char **p, unsigned char *start, + mbedtls_rsa_context *rsa ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( p, start, &rsa->E ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( p, start, &rsa->N ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) +/* + * EC public key is an EC point + */ +static int pk_write_ec_pubkey( unsigned char **p, unsigned char *start, + mbedtls_ecp_keypair *ec ) +{ + int ret; + size_t len = 0; + unsigned char buf[MBEDTLS_ECP_MAX_PT_LEN]; + + if( ( ret = mbedtls_ecp_point_write_binary( &ec->grp, &ec->Q, + MBEDTLS_ECP_PF_UNCOMPRESSED, + &len, buf, sizeof( buf ) ) ) != 0 ) + { + return( ret ); + } + + if( *p < start || (size_t)( *p - start ) < len ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *p -= len; + memcpy( *p, buf, len ); + + return( (int) len ); +} + +/* + * ECParameters ::= CHOICE { + * namedCurve OBJECT IDENTIFIER + * } + */ +static int pk_write_ec_param( unsigned char **p, unsigned char *start, + mbedtls_ecp_keypair *ec ) +{ + int ret; + size_t len = 0; + const char *oid; + size_t oid_len; + + if( ( ret = mbedtls_oid_get_oid_by_ec_grp( ec->grp.id, &oid, &oid_len ) ) != 0 ) + return( ret ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( p, start, oid, oid_len ) ); + + return( (int) len ); +} +#endif /* MBEDTLS_ECP_C */ + +int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start, + const mbedtls_pk_context *key ) +{ + int ret; + size_t len = 0; + +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA ) + MBEDTLS_ASN1_CHK_ADD( len, pk_write_rsa_pubkey( p, start, mbedtls_pk_rsa( *key ) ) ); + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_ECKEY ) + MBEDTLS_ASN1_CHK_ADD( len, pk_write_ec_pubkey( p, start, mbedtls_pk_ec( *key ) ) ); + else +#endif + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + + return( (int) len ); +} + +int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *key, unsigned char *buf, size_t size ) +{ + int ret; + unsigned char *c; + size_t len = 0, par_len = 0, oid_len; + const char *oid; + + c = buf + size; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, key ) ); + + if( c - buf < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + /* + * SubjectPublicKeyInfo ::= SEQUENCE { + * algorithm AlgorithmIdentifier, + * subjectPublicKey BIT STRING } + */ + *--c = 0; + len += 1; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_BIT_STRING ) ); + + if( ( ret = mbedtls_oid_get_oid_by_pk_alg( mbedtls_pk_get_type( key ), + &oid, &oid_len ) ) != 0 ) + { + return( ret ); + } + +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_ECKEY ) + { + MBEDTLS_ASN1_CHK_ADD( par_len, pk_write_ec_param( &c, buf, mbedtls_pk_ec( *key ) ) ); + } +#endif + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_algorithm_identifier( &c, buf, oid, oid_len, + par_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +int mbedtls_pk_write_key_der( mbedtls_pk_context *key, unsigned char *buf, size_t size ) +{ + int ret; + unsigned char *c = buf + size; + size_t len = 0; + +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA ) + { + mbedtls_rsa_context *rsa = mbedtls_pk_rsa( *key ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->QP ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->DQ ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->DP ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->Q ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->P ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->D ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->E ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->N ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_int( &c, buf, 0 ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + } + else +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_ECKEY ) + { + mbedtls_ecp_keypair *ec = mbedtls_pk_ec( *key ); + size_t pub_len = 0, par_len = 0; + + /* + * RFC 5915, or SEC1 Appendix C.4 + * + * ECPrivateKey ::= SEQUENCE { + * version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1), + * privateKey OCTET STRING, + * parameters [0] ECParameters {{ NamedCurve }} OPTIONAL, + * publicKey [1] BIT STRING OPTIONAL + * } + */ + + /* publicKey */ + MBEDTLS_ASN1_CHK_ADD( pub_len, pk_write_ec_pubkey( &c, buf, ec ) ); + + if( c - buf < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + *--c = 0; + pub_len += 1; + + MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_asn1_write_len( &c, buf, pub_len ) ); + MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_BIT_STRING ) ); + + MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_asn1_write_len( &c, buf, pub_len ) ); + MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_asn1_write_tag( &c, buf, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 1 ) ); + len += pub_len; + + /* parameters */ + MBEDTLS_ASN1_CHK_ADD( par_len, pk_write_ec_param( &c, buf, ec ) ); + + MBEDTLS_ASN1_CHK_ADD( par_len, mbedtls_asn1_write_len( &c, buf, par_len ) ); + MBEDTLS_ASN1_CHK_ADD( par_len, mbedtls_asn1_write_tag( &c, buf, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 0 ) ); + len += par_len; + + /* privateKey: write as MPI then fix tag */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &ec->d ) ); + *c = MBEDTLS_ASN1_OCTET_STRING; + + /* version */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_int( &c, buf, 1 ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + } + else +#endif /* MBEDTLS_ECP_C */ + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + + return( (int) len ); +} + +#if defined(MBEDTLS_PEM_WRITE_C) + +#define PEM_BEGIN_PUBLIC_KEY "-----BEGIN PUBLIC KEY-----\n" +#define PEM_END_PUBLIC_KEY "-----END PUBLIC KEY-----\n" + +#define PEM_BEGIN_PRIVATE_KEY_RSA "-----BEGIN RSA PRIVATE KEY-----\n" +#define PEM_END_PRIVATE_KEY_RSA "-----END RSA PRIVATE KEY-----\n" +#define PEM_BEGIN_PRIVATE_KEY_EC "-----BEGIN EC PRIVATE KEY-----\n" +#define PEM_END_PRIVATE_KEY_EC "-----END EC PRIVATE KEY-----\n" + +/* + * Max sizes of key per types. Shown as tag + len (+ content). + */ + +#if defined(MBEDTLS_RSA_C) +/* + * RSA public keys: + * SubjectPublicKeyInfo ::= SEQUENCE { 1 + 3 + * algorithm AlgorithmIdentifier, 1 + 1 (sequence) + * + 1 + 1 + 9 (rsa oid) + * + 1 + 1 (params null) + * subjectPublicKey BIT STRING } 1 + 3 + (1 + below) + * RSAPublicKey ::= SEQUENCE { 1 + 3 + * modulus INTEGER, -- n 1 + 3 + MPI_MAX + 1 + * publicExponent INTEGER -- e 1 + 3 + MPI_MAX + 1 + * } + */ +#define RSA_PUB_DER_MAX_BYTES 38 + 2 * MBEDTLS_MPI_MAX_SIZE + +/* + * RSA private keys: + * RSAPrivateKey ::= SEQUENCE { 1 + 3 + * version Version, 1 + 1 + 1 + * modulus INTEGER, 1 + 3 + MPI_MAX + 1 + * publicExponent INTEGER, 1 + 3 + MPI_MAX + 1 + * privateExponent INTEGER, 1 + 3 + MPI_MAX + 1 + * prime1 INTEGER, 1 + 3 + MPI_MAX / 2 + 1 + * prime2 INTEGER, 1 + 3 + MPI_MAX / 2 + 1 + * exponent1 INTEGER, 1 + 3 + MPI_MAX / 2 + 1 + * exponent2 INTEGER, 1 + 3 + MPI_MAX / 2 + 1 + * coefficient INTEGER, 1 + 3 + MPI_MAX / 2 + 1 + * otherPrimeInfos OtherPrimeInfos OPTIONAL 0 (not supported) + * } + */ +#define MPI_MAX_SIZE_2 MBEDTLS_MPI_MAX_SIZE / 2 + \ + MBEDTLS_MPI_MAX_SIZE % 2 +#define RSA_PRV_DER_MAX_BYTES 47 + 3 * MBEDTLS_MPI_MAX_SIZE \ + + 5 * MPI_MAX_SIZE_2 + +#else /* MBEDTLS_RSA_C */ + +#define RSA_PUB_DER_MAX_BYTES 0 +#define RSA_PRV_DER_MAX_BYTES 0 + +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_ECP_C) +/* + * EC public keys: + * SubjectPublicKeyInfo ::= SEQUENCE { 1 + 2 + * algorithm AlgorithmIdentifier, 1 + 1 (sequence) + * + 1 + 1 + 7 (ec oid) + * + 1 + 1 + 9 (namedCurve oid) + * subjectPublicKey BIT STRING 1 + 2 + 1 [1] + * + 1 (point format) [1] + * + 2 * ECP_MAX (coords) [1] + * } + */ +#define ECP_PUB_DER_MAX_BYTES 30 + 2 * MBEDTLS_ECP_MAX_BYTES + +/* + * EC private keys: + * ECPrivateKey ::= SEQUENCE { 1 + 2 + * version INTEGER , 1 + 1 + 1 + * privateKey OCTET STRING, 1 + 1 + ECP_MAX + * parameters [0] ECParameters OPTIONAL, 1 + 1 + (1 + 1 + 9) + * publicKey [1] BIT STRING OPTIONAL 1 + 2 + [1] above + * } + */ +#define ECP_PRV_DER_MAX_BYTES 29 + 3 * MBEDTLS_ECP_MAX_BYTES + +#else /* MBEDTLS_ECP_C */ + +#define ECP_PUB_DER_MAX_BYTES 0 +#define ECP_PRV_DER_MAX_BYTES 0 + +#endif /* MBEDTLS_ECP_C */ + +#define PUB_DER_MAX_BYTES RSA_PUB_DER_MAX_BYTES > ECP_PUB_DER_MAX_BYTES ? \ + RSA_PUB_DER_MAX_BYTES : ECP_PUB_DER_MAX_BYTES +#define PRV_DER_MAX_BYTES RSA_PRV_DER_MAX_BYTES > ECP_PRV_DER_MAX_BYTES ? \ + RSA_PRV_DER_MAX_BYTES : ECP_PRV_DER_MAX_BYTES + +int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *key, unsigned char *buf, size_t size ) +{ + int ret; + unsigned char output_buf[PUB_DER_MAX_BYTES]; + size_t olen = 0; + + if( ( ret = mbedtls_pk_write_pubkey_der( key, output_buf, + sizeof(output_buf) ) ) < 0 ) + { + return( ret ); + } + + if( ( ret = mbedtls_pem_write_buffer( PEM_BEGIN_PUBLIC_KEY, PEM_END_PUBLIC_KEY, + output_buf + sizeof(output_buf) - ret, + ret, buf, size, &olen ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} + +int mbedtls_pk_write_key_pem( mbedtls_pk_context *key, unsigned char *buf, size_t size ) +{ + int ret; + unsigned char output_buf[PRV_DER_MAX_BYTES]; + const char *begin, *end; + size_t olen = 0; + + if( ( ret = mbedtls_pk_write_key_der( key, output_buf, sizeof(output_buf) ) ) < 0 ) + return( ret ); + +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA ) + { + begin = PEM_BEGIN_PRIVATE_KEY_RSA; + end = PEM_END_PRIVATE_KEY_RSA; + } + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_ECKEY ) + { + begin = PEM_BEGIN_PRIVATE_KEY_EC; + end = PEM_END_PRIVATE_KEY_EC; + } + else +#endif + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + + if( ( ret = mbedtls_pem_write_buffer( begin, end, + output_buf + sizeof(output_buf) - ret, + ret, buf, size, &olen ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_PEM_WRITE_C */ + +#endif /* MBEDTLS_PK_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/platform.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/platform.c new file mode 100644 index 0000000..8b336c3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/platform.c @@ -0,0 +1,307 @@ +/* + * Platform abstraction layer + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) + +#include "mbedtls/platform.h" + +#if defined(MBEDTLS_PLATFORM_MEMORY) +#if !defined(MBEDTLS_PLATFORM_STD_CALLOC) +static void *platform_calloc_uninit( size_t n, size_t size ) +{ + ((void) n); + ((void) size); + return( NULL ); +} + +#define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit +#endif /* !MBEDTLS_PLATFORM_STD_CALLOC */ + +#if !defined(MBEDTLS_PLATFORM_STD_FREE) +static void platform_free_uninit( void *ptr ) +{ + ((void) ptr); +} + +#define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit +#endif /* !MBEDTLS_PLATFORM_STD_FREE */ + +void * (*mbedtls_calloc)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC; +void (*mbedtls_free)( void * ) = MBEDTLS_PLATFORM_STD_FREE; + +int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ), + void (*free_func)( void * ) ) +{ + mbedtls_calloc = calloc_func; + mbedtls_free = free_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_MEMORY */ + +#if defined(_WIN32) +#include +int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... ) +{ + int ret; + va_list argp; + + /* Avoid calling the invalid parameter handler by checking ourselves */ + if( s == NULL || n == 0 || fmt == NULL ) + return( -1 ); + + va_start( argp, fmt ); +#if defined(_TRUNCATE) + ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp ); +#else + ret = _vsnprintf( s, n, fmt, argp ); + if( ret < 0 || (size_t) ret == n ) + { + s[n-1] = '\0'; + ret = -1; + } +#endif + va_end( argp ); + + return( ret ); +} +#endif + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) +#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static int platform_snprintf_uninit( char * s, size_t n, + const char * format, ... ) +{ + ((void) s); + ((void) n); + ((void) format); + return( 0 ); +} + +#define MBEDTLS_PLATFORM_STD_SNPRINTF platform_snprintf_uninit +#endif /* !MBEDTLS_PLATFORM_STD_SNPRINTF */ + +int (*mbedtls_snprintf)( char * s, size_t n, + const char * format, + ... ) = MBEDTLS_PLATFORM_STD_SNPRINTF; + +int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n, + const char * format, + ... ) ) +{ + mbedtls_snprintf = snprintf_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ + +#if defined(MBEDTLS_PLATFORM_PRINTF_ALT) +#if !defined(MBEDTLS_PLATFORM_STD_PRINTF) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static int platform_printf_uninit( const char *format, ... ) +{ + ((void) format); + return( 0 ); +} + +#define MBEDTLS_PLATFORM_STD_PRINTF platform_printf_uninit +#endif /* !MBEDTLS_PLATFORM_STD_PRINTF */ + +int (*mbedtls_printf)( const char *, ... ) = MBEDTLS_PLATFORM_STD_PRINTF; + +int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) ) +{ + mbedtls_printf = printf_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */ + +#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) +#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static int platform_fprintf_uninit( FILE *stream, const char *format, ... ) +{ + ((void) stream); + ((void) format); + return( 0 ); +} + +#define MBEDTLS_PLATFORM_STD_FPRINTF platform_fprintf_uninit +#endif /* !MBEDTLS_PLATFORM_STD_FPRINTF */ + +int (*mbedtls_fprintf)( FILE *, const char *, ... ) = + MBEDTLS_PLATFORM_STD_FPRINTF; + +int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) ) +{ + mbedtls_fprintf = fprintf_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */ + +#if defined(MBEDTLS_PLATFORM_EXIT_ALT) +#if !defined(MBEDTLS_PLATFORM_STD_EXIT) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static void platform_exit_uninit( int status ) +{ + ((void) status); +} + +#define MBEDTLS_PLATFORM_STD_EXIT platform_exit_uninit +#endif /* !MBEDTLS_PLATFORM_STD_EXIT */ + +void (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT; + +int mbedtls_platform_set_exit( void (*exit_func)( int status ) ) +{ + mbedtls_exit = exit_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_EXIT_ALT */ + +#if defined(MBEDTLS_HAVE_TIME) + +#if defined(MBEDTLS_PLATFORM_TIME_ALT) +#if !defined(MBEDTLS_PLATFORM_STD_TIME) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer ) +{ + ((void) timer); + return( 0 ); +} + +#define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit +#endif /* !MBEDTLS_PLATFORM_STD_TIME */ + +mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME; + +int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* timer ) ) +{ + mbedtls_time = time_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_TIME_ALT */ + +#endif /* MBEDTLS_HAVE_TIME */ + +#if defined(MBEDTLS_ENTROPY_NV_SEED) +#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) +/* Default implementations for the platform independent seed functions use + * standard libc file functions to read from and write to a pre-defined filename + */ +int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len ) +{ + FILE *file; + size_t n; + + if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL ) + return -1; + + if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len ) + { + fclose( file ); + return -1; + } + + fclose( file ); + return( (int)n ); +} + +int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len ) +{ + FILE *file; + size_t n; + + if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "w" ) ) == NULL ) + return -1; + + if( ( n = fwrite( buf, 1, buf_len, file ) ) != buf_len ) + { + fclose( file ); + return -1; + } + + fclose( file ); + return( (int)n ); +} +#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ + +#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) +#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static int platform_nv_seed_read_uninit( unsigned char *buf, size_t buf_len ) +{ + ((void) buf); + ((void) buf_len); + return( -1 ); +} + +#define MBEDTLS_PLATFORM_STD_NV_SEED_READ platform_nv_seed_read_uninit +#endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_READ */ + +#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) +/* + * Make dummy function to prevent NULL pointer dereferences + */ +static int platform_nv_seed_write_uninit( unsigned char *buf, size_t buf_len ) +{ + ((void) buf); + ((void) buf_len); + return( -1 ); +} + +#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE platform_nv_seed_write_uninit +#endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_WRITE */ + +int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ) = + MBEDTLS_PLATFORM_STD_NV_SEED_READ; +int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ) = + MBEDTLS_PLATFORM_STD_NV_SEED_WRITE; + +int mbedtls_platform_set_nv_seed( + int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ), + int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) ) +{ + mbedtls_nv_seed_read = nv_seed_read_func; + mbedtls_nv_seed_write = nv_seed_write_func; + return( 0 ); +} +#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ +#endif /* MBEDTLS_ENTROPY_NV_SEED */ + +#endif /* MBEDTLS_PLATFORM_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ripemd160.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ripemd160.c new file mode 100644 index 0000000..cdb0a63 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ripemd160.c @@ -0,0 +1,467 @@ +/* + * RIPE MD-160 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * The RIPEMD-160 algorithm was designed by RIPE in 1996 + * http://homes.esat.kuleuven.be/~bosselae/mbedtls_ripemd160.html + * http://ehash.iaik.tugraz.at/wiki/RIPEMD-160 + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_RIPEMD160_C) + +#include "mbedtls/ripemd160.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef GET_UINT32_LE +#define GET_UINT32_LE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ +} +#endif + +#ifndef PUT_UINT32_LE +#define PUT_UINT32_LE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +} +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_ripemd160_context ) ); +} + +void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_ripemd160_context ) ); +} + +void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst, + const mbedtls_ripemd160_context *src ) +{ + *dst = *src; +} + +/* + * RIPEMD-160 context setup + */ +void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xC3D2E1F0; +} + +#if !defined(MBEDTLS_RIPEMD160_PROCESS_ALT) +/* + * Process one block + */ +void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] ) +{ + uint32_t A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, X[16]; + + GET_UINT32_LE( X[ 0], data, 0 ); + GET_UINT32_LE( X[ 1], data, 4 ); + GET_UINT32_LE( X[ 2], data, 8 ); + GET_UINT32_LE( X[ 3], data, 12 ); + GET_UINT32_LE( X[ 4], data, 16 ); + GET_UINT32_LE( X[ 5], data, 20 ); + GET_UINT32_LE( X[ 6], data, 24 ); + GET_UINT32_LE( X[ 7], data, 28 ); + GET_UINT32_LE( X[ 8], data, 32 ); + GET_UINT32_LE( X[ 9], data, 36 ); + GET_UINT32_LE( X[10], data, 40 ); + GET_UINT32_LE( X[11], data, 44 ); + GET_UINT32_LE( X[12], data, 48 ); + GET_UINT32_LE( X[13], data, 52 ); + GET_UINT32_LE( X[14], data, 56 ); + GET_UINT32_LE( X[15], data, 60 ); + + A = Ap = ctx->state[0]; + B = Bp = ctx->state[1]; + C = Cp = ctx->state[2]; + D = Dp = ctx->state[3]; + E = Ep = ctx->state[4]; + +#define F1( x, y, z ) ( x ^ y ^ z ) +#define F2( x, y, z ) ( ( x & y ) | ( ~x & z ) ) +#define F3( x, y, z ) ( ( x | ~y ) ^ z ) +#define F4( x, y, z ) ( ( x & z ) | ( y & ~z ) ) +#define F5( x, y, z ) ( x ^ ( y | ~z ) ) + +#define S( x, n ) ( ( x << n ) | ( x >> (32 - n) ) ) + +#define P( a, b, c, d, e, r, s, f, k ) \ + a += f( b, c, d ) + X[r] + k; \ + a = S( a, s ) + e; \ + c = S( c, 10 ); + +#define P2( a, b, c, d, e, r, s, rp, sp ) \ + P( a, b, c, d, e, r, s, F, K ); \ + P( a ## p, b ## p, c ## p, d ## p, e ## p, rp, sp, Fp, Kp ); + +#define F F1 +#define K 0x00000000 +#define Fp F5 +#define Kp 0x50A28BE6 + P2( A, B, C, D, E, 0, 11, 5, 8 ); + P2( E, A, B, C, D, 1, 14, 14, 9 ); + P2( D, E, A, B, C, 2, 15, 7, 9 ); + P2( C, D, E, A, B, 3, 12, 0, 11 ); + P2( B, C, D, E, A, 4, 5, 9, 13 ); + P2( A, B, C, D, E, 5, 8, 2, 15 ); + P2( E, A, B, C, D, 6, 7, 11, 15 ); + P2( D, E, A, B, C, 7, 9, 4, 5 ); + P2( C, D, E, A, B, 8, 11, 13, 7 ); + P2( B, C, D, E, A, 9, 13, 6, 7 ); + P2( A, B, C, D, E, 10, 14, 15, 8 ); + P2( E, A, B, C, D, 11, 15, 8, 11 ); + P2( D, E, A, B, C, 12, 6, 1, 14 ); + P2( C, D, E, A, B, 13, 7, 10, 14 ); + P2( B, C, D, E, A, 14, 9, 3, 12 ); + P2( A, B, C, D, E, 15, 8, 12, 6 ); +#undef F +#undef K +#undef Fp +#undef Kp + +#define F F2 +#define K 0x5A827999 +#define Fp F4 +#define Kp 0x5C4DD124 + P2( E, A, B, C, D, 7, 7, 6, 9 ); + P2( D, E, A, B, C, 4, 6, 11, 13 ); + P2( C, D, E, A, B, 13, 8, 3, 15 ); + P2( B, C, D, E, A, 1, 13, 7, 7 ); + P2( A, B, C, D, E, 10, 11, 0, 12 ); + P2( E, A, B, C, D, 6, 9, 13, 8 ); + P2( D, E, A, B, C, 15, 7, 5, 9 ); + P2( C, D, E, A, B, 3, 15, 10, 11 ); + P2( B, C, D, E, A, 12, 7, 14, 7 ); + P2( A, B, C, D, E, 0, 12, 15, 7 ); + P2( E, A, B, C, D, 9, 15, 8, 12 ); + P2( D, E, A, B, C, 5, 9, 12, 7 ); + P2( C, D, E, A, B, 2, 11, 4, 6 ); + P2( B, C, D, E, A, 14, 7, 9, 15 ); + P2( A, B, C, D, E, 11, 13, 1, 13 ); + P2( E, A, B, C, D, 8, 12, 2, 11 ); +#undef F +#undef K +#undef Fp +#undef Kp + +#define F F3 +#define K 0x6ED9EBA1 +#define Fp F3 +#define Kp 0x6D703EF3 + P2( D, E, A, B, C, 3, 11, 15, 9 ); + P2( C, D, E, A, B, 10, 13, 5, 7 ); + P2( B, C, D, E, A, 14, 6, 1, 15 ); + P2( A, B, C, D, E, 4, 7, 3, 11 ); + P2( E, A, B, C, D, 9, 14, 7, 8 ); + P2( D, E, A, B, C, 15, 9, 14, 6 ); + P2( C, D, E, A, B, 8, 13, 6, 6 ); + P2( B, C, D, E, A, 1, 15, 9, 14 ); + P2( A, B, C, D, E, 2, 14, 11, 12 ); + P2( E, A, B, C, D, 7, 8, 8, 13 ); + P2( D, E, A, B, C, 0, 13, 12, 5 ); + P2( C, D, E, A, B, 6, 6, 2, 14 ); + P2( B, C, D, E, A, 13, 5, 10, 13 ); + P2( A, B, C, D, E, 11, 12, 0, 13 ); + P2( E, A, B, C, D, 5, 7, 4, 7 ); + P2( D, E, A, B, C, 12, 5, 13, 5 ); +#undef F +#undef K +#undef Fp +#undef Kp + +#define F F4 +#define K 0x8F1BBCDC +#define Fp F2 +#define Kp 0x7A6D76E9 + P2( C, D, E, A, B, 1, 11, 8, 15 ); + P2( B, C, D, E, A, 9, 12, 6, 5 ); + P2( A, B, C, D, E, 11, 14, 4, 8 ); + P2( E, A, B, C, D, 10, 15, 1, 11 ); + P2( D, E, A, B, C, 0, 14, 3, 14 ); + P2( C, D, E, A, B, 8, 15, 11, 14 ); + P2( B, C, D, E, A, 12, 9, 15, 6 ); + P2( A, B, C, D, E, 4, 8, 0, 14 ); + P2( E, A, B, C, D, 13, 9, 5, 6 ); + P2( D, E, A, B, C, 3, 14, 12, 9 ); + P2( C, D, E, A, B, 7, 5, 2, 12 ); + P2( B, C, D, E, A, 15, 6, 13, 9 ); + P2( A, B, C, D, E, 14, 8, 9, 12 ); + P2( E, A, B, C, D, 5, 6, 7, 5 ); + P2( D, E, A, B, C, 6, 5, 10, 15 ); + P2( C, D, E, A, B, 2, 12, 14, 8 ); +#undef F +#undef K +#undef Fp +#undef Kp + +#define F F5 +#define K 0xA953FD4E +#define Fp F1 +#define Kp 0x00000000 + P2( B, C, D, E, A, 4, 9, 12, 8 ); + P2( A, B, C, D, E, 0, 15, 15, 5 ); + P2( E, A, B, C, D, 5, 5, 10, 12 ); + P2( D, E, A, B, C, 9, 11, 4, 9 ); + P2( C, D, E, A, B, 7, 6, 1, 12 ); + P2( B, C, D, E, A, 12, 8, 5, 5 ); + P2( A, B, C, D, E, 2, 13, 8, 14 ); + P2( E, A, B, C, D, 10, 12, 7, 6 ); + P2( D, E, A, B, C, 14, 5, 6, 8 ); + P2( C, D, E, A, B, 1, 12, 2, 13 ); + P2( B, C, D, E, A, 3, 13, 13, 6 ); + P2( A, B, C, D, E, 8, 14, 14, 5 ); + P2( E, A, B, C, D, 11, 11, 0, 15 ); + P2( D, E, A, B, C, 6, 8, 3, 13 ); + P2( C, D, E, A, B, 15, 5, 9, 11 ); + P2( B, C, D, E, A, 13, 6, 11, 11 ); +#undef F +#undef K +#undef Fp +#undef Kp + + C = ctx->state[1] + C + Dp; + ctx->state[1] = ctx->state[2] + D + Ep; + ctx->state[2] = ctx->state[3] + E + Ap; + ctx->state[3] = ctx->state[4] + A + Bp; + ctx->state[4] = ctx->state[0] + B + Cp; + ctx->state[0] = C; +} +#endif /* !MBEDTLS_RIPEMD160_PROCESS_ALT */ + +/* + * RIPEMD-160 process buffer + */ +void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx, + const unsigned char *input, size_t ilen ) +{ + size_t fill; + uint32_t left; + + if( ilen == 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t) ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if( ctx->total[0] < (uint32_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), input, fill ); + mbedtls_ripemd160_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 64 ) + { + mbedtls_ripemd160_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if( ilen > 0 ) + { + memcpy( (void *) (ctx->buffer + left), input, ilen ); + } +} + +static const unsigned char ripemd160_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * RIPEMD-160 final digest + */ +void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] ) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT32_LE( low, msglen, 0 ); + PUT_UINT32_LE( high, msglen, 4 ); + + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + mbedtls_ripemd160_update( ctx, ripemd160_padding, padn ); + mbedtls_ripemd160_update( ctx, msglen, 8 ); + + PUT_UINT32_LE( ctx->state[0], output, 0 ); + PUT_UINT32_LE( ctx->state[1], output, 4 ); + PUT_UINT32_LE( ctx->state[2], output, 8 ); + PUT_UINT32_LE( ctx->state[3], output, 12 ); + PUT_UINT32_LE( ctx->state[4], output, 16 ); +} + +/* + * output = RIPEMD-160( input buffer ) + */ +void mbedtls_ripemd160( const unsigned char *input, size_t ilen, + unsigned char output[20] ) +{ + mbedtls_ripemd160_context ctx; + + mbedtls_ripemd160_init( &ctx ); + mbedtls_ripemd160_starts( &ctx ); + mbedtls_ripemd160_update( &ctx, input, ilen ); + mbedtls_ripemd160_finish( &ctx, output ); + mbedtls_ripemd160_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) +/* + * Test vectors from the RIPEMD-160 paper and + * http://homes.esat.kuleuven.be/~bosselae/mbedtls_ripemd160.html#HMAC + */ +#define TESTS 8 +#define KEYS 2 +static const char *ripemd160_test_input[TESTS] = +{ + "", + "a", + "abc", + "message digest", + "abcdefghijklmnopqrstuvwxyz", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", +}; + +static const unsigned char ripemd160_test_md[TESTS][20] = +{ + { 0x9c, 0x11, 0x85, 0xa5, 0xc5, 0xe9, 0xfc, 0x54, 0x61, 0x28, + 0x08, 0x97, 0x7e, 0xe8, 0xf5, 0x48, 0xb2, 0x25, 0x8d, 0x31 }, + { 0x0b, 0xdc, 0x9d, 0x2d, 0x25, 0x6b, 0x3e, 0xe9, 0xda, 0xae, + 0x34, 0x7b, 0xe6, 0xf4, 0xdc, 0x83, 0x5a, 0x46, 0x7f, 0xfe }, + { 0x8e, 0xb2, 0x08, 0xf7, 0xe0, 0x5d, 0x98, 0x7a, 0x9b, 0x04, + 0x4a, 0x8e, 0x98, 0xc6, 0xb0, 0x87, 0xf1, 0x5a, 0x0b, 0xfc }, + { 0x5d, 0x06, 0x89, 0xef, 0x49, 0xd2, 0xfa, 0xe5, 0x72, 0xb8, + 0x81, 0xb1, 0x23, 0xa8, 0x5f, 0xfa, 0x21, 0x59, 0x5f, 0x36 }, + { 0xf7, 0x1c, 0x27, 0x10, 0x9c, 0x69, 0x2c, 0x1b, 0x56, 0xbb, + 0xdc, 0xeb, 0x5b, 0x9d, 0x28, 0x65, 0xb3, 0x70, 0x8d, 0xbc }, + { 0x12, 0xa0, 0x53, 0x38, 0x4a, 0x9c, 0x0c, 0x88, 0xe4, 0x05, + 0xa0, 0x6c, 0x27, 0xdc, 0xf4, 0x9a, 0xda, 0x62, 0xeb, 0x2b }, + { 0xb0, 0xe2, 0x0b, 0x6e, 0x31, 0x16, 0x64, 0x02, 0x86, 0xed, + 0x3a, 0x87, 0xa5, 0x71, 0x30, 0x79, 0xb2, 0x1f, 0x51, 0x89 }, + { 0x9b, 0x75, 0x2e, 0x45, 0x57, 0x3d, 0x4b, 0x39, 0xf4, 0xdb, + 0xd3, 0x32, 0x3c, 0xab, 0x82, 0xbf, 0x63, 0x32, 0x6b, 0xfb }, +}; + +/* + * Checkup routine + */ +int mbedtls_ripemd160_self_test( int verbose ) +{ + int i; + unsigned char output[20]; + + memset( output, 0, sizeof output ); + + for( i = 0; i < TESTS; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " RIPEMD-160 test #%d: ", i + 1 ); + + mbedtls_ripemd160( (const unsigned char *) ripemd160_test_input[i], + strlen( ripemd160_test_input[i] ), + output ); + + if( memcmp( output, ripemd160_test_md[i], 20 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_RIPEMD160_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/rsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/rsa.c new file mode 100644 index 0000000..40ef2a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/rsa.c @@ -0,0 +1,1730 @@ +/* + * The RSA public-key cryptosystem + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The following sources were referenced in the design of this implementation + * of the RSA algorithm: + * + * [1] A method for obtaining digital signatures and public-key cryptosystems + * R Rivest, A Shamir, and L Adleman + * http://people.csail.mit.edu/rivest/pubs.html#RSA78 + * + * [2] Handbook of Applied Cryptography - 1997, Chapter 8 + * Menezes, van Oorschot and Vanstone + * + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_RSA_C) + +#include "mbedtls/rsa.h" +#include "mbedtls/oid.h" + +#include + +#if defined(MBEDTLS_PKCS1_V21) +#include "mbedtls/md.h" +#endif + +#if defined(MBEDTLS_PKCS1_V15) && !defined(__OpenBSD__) +#include +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +/* + * Initialize an RSA context + */ +void mbedtls_rsa_init( mbedtls_rsa_context *ctx, + int padding, + int hash_id ) +{ + memset( ctx, 0, sizeof( mbedtls_rsa_context ) ); + + mbedtls_rsa_set_padding( ctx, padding, hash_id ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &ctx->mutex ); +#endif +} + +/* + * Set padding for an existing RSA context + */ +void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id ) +{ + ctx->padding = padding; + ctx->hash_id = hash_id; +} + +#if defined(MBEDTLS_GENPRIME) + +/* + * Generate an RSA keypair + */ +int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + unsigned int nbits, int exponent ) +{ + int ret; + mbedtls_mpi P1, Q1, H, G; + + if( f_rng == NULL || nbits < 128 || exponent < 3 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( nbits % 2 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); + mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G ); + + /* + * find primes P and Q with Q < P so that: + * GCD( E, (P-1)*(Q-1) ) == 1 + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &ctx->E, exponent ) ); + + do + { + MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, nbits >> 1, 0, + f_rng, p_rng ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, nbits >> 1, 0, + f_rng, p_rng ) ); + + if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 ) + continue; + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) ); + if( mbedtls_mpi_bitlen( &ctx->N ) != nbits ) + continue; + + if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 ) + mbedtls_mpi_swap( &ctx->P, &ctx->Q ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) ); + } + while( mbedtls_mpi_cmp_int( &G, 1 ) != 0 ); + + /* + * D = E^-1 mod ((P-1)*(Q-1)) + * DP = D mod (P - 1) + * DQ = D mod (Q - 1) + * QP = Q^-1 mod P + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->D , &ctx->E, &H ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) ); + + ctx->len = ( mbedtls_mpi_bitlen( &ctx->N ) + 7 ) >> 3; + +cleanup: + + mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G ); + + if( ret != 0 ) + { + mbedtls_rsa_free( ctx ); + return( MBEDTLS_ERR_RSA_KEY_GEN_FAILED + ret ); + } + + return( 0 ); +} + +#endif /* MBEDTLS_GENPRIME */ + +/* + * Check a public RSA key + */ +int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ) +{ + if( !ctx->N.p || !ctx->E.p ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + + if( ( ctx->N.p[0] & 1 ) == 0 || + ( ctx->E.p[0] & 1 ) == 0 ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + + if( mbedtls_mpi_bitlen( &ctx->N ) < 128 || + mbedtls_mpi_bitlen( &ctx->N ) > MBEDTLS_MPI_MAX_BITS ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + + if( mbedtls_mpi_bitlen( &ctx->E ) < 2 || + mbedtls_mpi_cmp_mpi( &ctx->E, &ctx->N ) >= 0 ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + + return( 0 ); +} + +/* + * Check a private RSA key + */ +int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ) +{ + int ret; + mbedtls_mpi PQ, DE, P1, Q1, H, I, G, G2, L1, L2, DP, DQ, QP; + + if( ( ret = mbedtls_rsa_check_pubkey( ctx ) ) != 0 ) + return( ret ); + + if( !ctx->P.p || !ctx->Q.p || !ctx->D.p ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + + mbedtls_mpi_init( &PQ ); mbedtls_mpi_init( &DE ); mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); + mbedtls_mpi_init( &H ); mbedtls_mpi_init( &I ); mbedtls_mpi_init( &G ); mbedtls_mpi_init( &G2 ); + mbedtls_mpi_init( &L1 ); mbedtls_mpi_init( &L2 ); mbedtls_mpi_init( &DP ); mbedtls_mpi_init( &DQ ); + mbedtls_mpi_init( &QP ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G2, &P1, &Q1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &L1, &L2, &H, &G2 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &I, &DE, &L1 ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &DP, &ctx->D, &P1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &DQ, &ctx->D, &Q1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &QP, &ctx->Q, &ctx->P ) ); + /* + * Check for a valid PKCS1v2 private key + */ + if( mbedtls_mpi_cmp_mpi( &PQ, &ctx->N ) != 0 || + mbedtls_mpi_cmp_mpi( &DP, &ctx->DP ) != 0 || + mbedtls_mpi_cmp_mpi( &DQ, &ctx->DQ ) != 0 || + mbedtls_mpi_cmp_mpi( &QP, &ctx->QP ) != 0 || + mbedtls_mpi_cmp_int( &L2, 0 ) != 0 || + mbedtls_mpi_cmp_int( &I, 1 ) != 0 || + mbedtls_mpi_cmp_int( &G, 1 ) != 0 ) + { + ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; + } + +cleanup: + mbedtls_mpi_free( &PQ ); mbedtls_mpi_free( &DE ); mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); + mbedtls_mpi_free( &H ); mbedtls_mpi_free( &I ); mbedtls_mpi_free( &G ); mbedtls_mpi_free( &G2 ); + mbedtls_mpi_free( &L1 ); mbedtls_mpi_free( &L2 ); mbedtls_mpi_free( &DP ); mbedtls_mpi_free( &DQ ); + mbedtls_mpi_free( &QP ); + + if( ret == MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ) + return( ret ); + + if( ret != 0 ) + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED + ret ); + + return( 0 ); +} + +/* + * Check if contexts holding a public and private key match + */ +int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv ) +{ + if( mbedtls_rsa_check_pubkey( pub ) != 0 || + mbedtls_rsa_check_privkey( prv ) != 0 ) + { + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + } + + if( mbedtls_mpi_cmp_mpi( &pub->N, &prv->N ) != 0 || + mbedtls_mpi_cmp_mpi( &pub->E, &prv->E ) != 0 ) + { + return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); + } + + return( 0 ); +} + +/* + * Do an RSA public key operation + */ +int mbedtls_rsa_public( mbedtls_rsa_context *ctx, + const unsigned char *input, + unsigned char *output ) +{ + int ret; + size_t olen; + mbedtls_mpi T; + + mbedtls_mpi_init( &T ); + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &T, input, ctx->len ) ); + + if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 ) + { + ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA; + goto cleanup; + } + + olen = ctx->len; + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T, &T, &ctx->E, &ctx->N, &ctx->RN ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &T, output, olen ) ); + +cleanup: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + mbedtls_mpi_free( &T ); + + if( ret != 0 ) + return( MBEDTLS_ERR_RSA_PUBLIC_FAILED + ret ); + + return( 0 ); +} + +/* + * Generate or update blinding values, see section 10 of: + * KOCHER, Paul C. Timing attacks on implementations of Diffie-Hellman, RSA, + * DSS, and other systems. In : Advances in Cryptology-CRYPTO'96. Springer + * Berlin Heidelberg, 1996. p. 104-113. + */ +static int rsa_prepare_blinding( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + int ret, count = 0; + + if( ctx->Vf.p != NULL ) + { + /* We already have blinding values, just update them by squaring */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &ctx->Vi ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vf, &ctx->Vf, &ctx->Vf ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vf, &ctx->Vf, &ctx->N ) ); + + goto cleanup; + } + + /* Unblinding value: Vf = random number, invertible mod N */ + do { + if( count++ > 10 ) + return( MBEDTLS_ERR_RSA_RNG_FAILED ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->Vf, ctx->len - 1, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &ctx->Vi, &ctx->Vf, &ctx->N ) ); + } while( mbedtls_mpi_cmp_int( &ctx->Vi, 1 ) != 0 ); + + /* Blinding value: Vi = Vf^(-e) mod N */ + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->Vi, &ctx->Vf, &ctx->N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->Vi, &ctx->Vi, &ctx->E, &ctx->N, &ctx->RN ) ); + + +cleanup: + return( ret ); +} + +/* + * Do an RSA private key operation + */ +int mbedtls_rsa_private( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + const unsigned char *input, + unsigned char *output ) +{ + int ret; + size_t olen; + mbedtls_mpi T, T1, T2; + + /* Make sure we have private key info, prevent possible misuse */ + if( ctx->P.p == NULL || ctx->Q.p == NULL || ctx->D.p == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + mbedtls_mpi_init( &T ); mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 ); + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &T, input, ctx->len ) ); + if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 ) + { + ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA; + goto cleanup; + } + + if( f_rng != NULL ) + { + /* + * Blinding + * T = T * Vi mod N + */ + MBEDTLS_MPI_CHK( rsa_prepare_blinding( ctx, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &T, &ctx->Vi ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T, &ctx->N ) ); + } + +#if defined(MBEDTLS_RSA_NO_CRT) + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T, &T, &ctx->D, &ctx->N, &ctx->RN ) ); +#else + /* + * faster decryption using the CRT + * + * T1 = input ^ dP mod P + * T2 = input ^ dQ mod Q + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T1, &T, &ctx->DP, &ctx->P, &ctx->RP ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T2, &T, &ctx->DQ, &ctx->Q, &ctx->RQ ) ); + + /* + * T = (T1 - T2) * (Q^-1 mod P) mod P + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T, &T1, &T2 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T, &ctx->QP ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T1, &ctx->P ) ); + + /* + * T = T2 + T * Q + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T, &ctx->Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &T, &T2, &T1 ) ); +#endif /* MBEDTLS_RSA_NO_CRT */ + + if( f_rng != NULL ) + { + /* + * Unblind + * T = T * Vf mod N + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &T, &ctx->Vf ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T, &ctx->N ) ); + } + + olen = ctx->len; + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &T, output, olen ) ); + +cleanup: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + mbedtls_mpi_free( &T ); mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 ); + + if( ret != 0 ) + return( MBEDTLS_ERR_RSA_PRIVATE_FAILED + ret ); + + return( 0 ); +} + +#if defined(MBEDTLS_PKCS1_V21) +/** + * Generate and apply the MGF1 operation (from PKCS#1 v2.1) to a buffer. + * + * \param dst buffer to mask + * \param dlen length of destination buffer + * \param src source of the mask generation + * \param slen length of the source buffer + * \param md_ctx message digest context to use + */ +static void mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src, + size_t slen, mbedtls_md_context_t *md_ctx ) +{ + unsigned char mask[MBEDTLS_MD_MAX_SIZE]; + unsigned char counter[4]; + unsigned char *p; + unsigned int hlen; + size_t i, use_len; + + memset( mask, 0, MBEDTLS_MD_MAX_SIZE ); + memset( counter, 0, 4 ); + + hlen = mbedtls_md_get_size( md_ctx->md_info ); + + /* Generate and apply dbMask */ + p = dst; + + while( dlen > 0 ) + { + use_len = hlen; + if( dlen < hlen ) + use_len = dlen; + + mbedtls_md_starts( md_ctx ); + mbedtls_md_update( md_ctx, src, slen ); + mbedtls_md_update( md_ctx, counter, 4 ); + mbedtls_md_finish( md_ctx, mask ); + + for( i = 0; i < use_len; ++i ) + *p++ ^= mask[i]; + + counter[3]++; + + dlen -= use_len; + } +} +#endif /* MBEDTLS_PKCS1_V21 */ + +#if defined(MBEDTLS_PKCS1_V21) +/* + * Implementation of the PKCS#1 v2.1 RSAES-OAEP-ENCRYPT function + */ +int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + const unsigned char *label, size_t label_len, + size_t ilen, + const unsigned char *input, + unsigned char *output ) +{ + size_t olen; + int ret; + unsigned char *p = output; + unsigned int hlen; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( f_rng == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + md_info = mbedtls_md_info_from_type( (mbedtls_md_type_t) ctx->hash_id ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + olen = ctx->len; + hlen = mbedtls_md_get_size( md_info ); + + /* first comparison checks for overflow */ + if( ilen + 2 * hlen + 2 < ilen || olen < ilen + 2 * hlen + 2 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + memset( output, 0, olen ); + + *p++ = 0; + + /* Generate a random octet string seed */ + if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 ) + return( MBEDTLS_ERR_RSA_RNG_FAILED + ret ); + + p += hlen; + + /* Construct DB */ + mbedtls_md( md_info, label, label_len, p ); + p += hlen; + p += olen - 2 * hlen - 2 - ilen; + *p++ = 1; + memcpy( p, input, ilen ); + + mbedtls_md_init( &md_ctx ); + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 ) + { + mbedtls_md_free( &md_ctx ); + return( ret ); + } + + /* maskedDB: Apply dbMask to DB */ + mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen, + &md_ctx ); + + /* maskedSeed: Apply seedMask to seed */ + mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1, + &md_ctx ); + + mbedtls_md_free( &md_ctx ); + + return( ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, output, output ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, output, output ) ); +} +#endif /* MBEDTLS_PKCS1_V21 */ + +#if defined(MBEDTLS_PKCS1_V15) +/* + * Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-ENCRYPT function + */ +int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t ilen, + const unsigned char *input, + unsigned char *output ) +{ + size_t nb_pad, olen; + int ret; + unsigned char *p = output; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + // We don't check p_rng because it won't be dereferenced here + if( f_rng == NULL || input == NULL || output == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + olen = ctx->len; + + /* first comparison checks for overflow */ + if( ilen + 11 < ilen || olen < ilen + 11 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + nb_pad = olen - 3 - ilen; + + *p++ = 0; + if( mode == MBEDTLS_RSA_PUBLIC ) + { + *p++ = MBEDTLS_RSA_CRYPT; + + while( nb_pad-- > 0 ) + { + int rng_dl = 100; + + do { + ret = f_rng( p_rng, p, 1 ); + } while( *p == 0 && --rng_dl && ret == 0 ); + + /* Check if RNG failed to generate data */ + if( rng_dl == 0 || ret != 0 ) + return( MBEDTLS_ERR_RSA_RNG_FAILED + ret ); + + p++; + } + } + else + { + *p++ = MBEDTLS_RSA_SIGN; + + while( nb_pad-- > 0 ) + *p++ = 0xFF; + } + + *p++ = 0; + memcpy( p, input, ilen ); + + return( ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, output, output ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, output, output ) ); +} +#endif /* MBEDTLS_PKCS1_V15 */ + +/* + * Add the message padding, then do an RSA operation + */ +int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t ilen, + const unsigned char *input, + unsigned char *output ) +{ + switch( ctx->padding ) + { +#if defined(MBEDTLS_PKCS1_V15) + case MBEDTLS_RSA_PKCS_V15: + return mbedtls_rsa_rsaes_pkcs1_v15_encrypt( ctx, f_rng, p_rng, mode, ilen, + input, output ); +#endif + +#if defined(MBEDTLS_PKCS1_V21) + case MBEDTLS_RSA_PKCS_V21: + return mbedtls_rsa_rsaes_oaep_encrypt( ctx, f_rng, p_rng, mode, NULL, 0, + ilen, input, output ); +#endif + + default: + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + } +} + +#if defined(MBEDTLS_PKCS1_V21) +/* + * Implementation of the PKCS#1 v2.1 RSAES-OAEP-DECRYPT function + */ +int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + const unsigned char *label, size_t label_len, + size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len ) +{ + int ret; + size_t ilen, i, pad_len; + unsigned char *p, bad, pad_done; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + unsigned char lhash[MBEDTLS_MD_MAX_SIZE]; + unsigned int hlen; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + + /* + * Parameters sanity checks + */ + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + ilen = ctx->len; + + if( ilen < 16 || ilen > sizeof( buf ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + md_info = mbedtls_md_info_from_type( (mbedtls_md_type_t) ctx->hash_id ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + hlen = mbedtls_md_get_size( md_info ); + + // checking for integer underflow + if( 2 * hlen + 2 > ilen ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + /* + * RSA operation + */ + ret = ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, input, buf ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf ); + + if( ret != 0 ) + return( ret ); + + /* + * Unmask data and generate lHash + */ + mbedtls_md_init( &md_ctx ); + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 ) + { + mbedtls_md_free( &md_ctx ); + return( ret ); + } + + + /* Generate lHash */ + mbedtls_md( md_info, label, label_len, lhash ); + + /* seed: Apply seedMask to maskedSeed */ + mgf_mask( buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1, + &md_ctx ); + + /* DB: Apply dbMask to maskedDB */ + mgf_mask( buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen, + &md_ctx ); + + mbedtls_md_free( &md_ctx ); + + /* + * Check contents, in "constant-time" + */ + p = buf; + bad = 0; + + bad |= *p++; /* First byte must be 0 */ + + p += hlen; /* Skip seed */ + + /* Check lHash */ + for( i = 0; i < hlen; i++ ) + bad |= lhash[i] ^ *p++; + + /* Get zero-padding len, but always read till end of buffer + * (minus one, for the 01 byte) */ + pad_len = 0; + pad_done = 0; + for( i = 0; i < ilen - 2 * hlen - 2; i++ ) + { + pad_done |= p[i]; + pad_len += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1; + } + + p += pad_len; + bad |= *p++ ^ 0x01; + + /* + * The only information "leaked" is whether the padding was correct or not + * (eg, no data is copied if it was not correct). This meets the + * recommendations in PKCS#1 v2.2: an opponent cannot distinguish between + * the different error conditions. + */ + if( bad != 0 ) + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + + if( ilen - ( p - buf ) > output_max_len ) + return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE ); + + *olen = ilen - (p - buf); + memcpy( output, p, *olen ); + + return( 0 ); +} +#endif /* MBEDTLS_PKCS1_V21 */ + +#if defined(MBEDTLS_PKCS1_V15) +/* + * Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-DECRYPT function + */ +int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len) +{ + int ret; + size_t ilen, pad_count = 0, i; + unsigned char *p, bad, pad_done = 0; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + ilen = ctx->len; + + if( ilen < 16 || ilen > sizeof( buf ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + ret = ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, input, buf ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf ); + + if( ret != 0 ) + return( ret ); + + p = buf; + bad = 0; + + /* + * Check and get padding len in "constant-time" + */ + bad |= *p++; /* First byte must be 0 */ + + /* This test does not depend on secret data */ + if( mode == MBEDTLS_RSA_PRIVATE ) + { + bad |= *p++ ^ MBEDTLS_RSA_CRYPT; + + /* Get padding len, but always read till end of buffer + * (minus one, for the 00 byte) */ + for( i = 0; i < ilen - 3; i++ ) + { + pad_done |= ((p[i] | (unsigned char)-p[i]) >> 7) ^ 1; + pad_count += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1; + } + + p += pad_count; + bad |= *p++; /* Must be zero */ + } + else + { + bad |= *p++ ^ MBEDTLS_RSA_SIGN; + + /* Get padding len, but always read till end of buffer + * (minus one, for the 00 byte) */ + for( i = 0; i < ilen - 3; i++ ) + { + pad_done |= ( p[i] != 0xFF ); + pad_count += ( pad_done == 0 ); + } + + p += pad_count; + bad |= *p++; /* Must be zero */ + } + + bad |= ( pad_count < 8 ); + + if( bad ) + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + + if( ilen - ( p - buf ) > output_max_len ) + return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE ); + + *olen = ilen - (p - buf); + memcpy( output, p, *olen ); + + return( 0 ); +} +#endif /* MBEDTLS_PKCS1_V15 */ + +/* + * Do an RSA operation, then remove the message padding + */ +int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, size_t *olen, + const unsigned char *input, + unsigned char *output, + size_t output_max_len) +{ + switch( ctx->padding ) + { +#if defined(MBEDTLS_PKCS1_V15) + case MBEDTLS_RSA_PKCS_V15: + return mbedtls_rsa_rsaes_pkcs1_v15_decrypt( ctx, f_rng, p_rng, mode, olen, + input, output, output_max_len ); +#endif + +#if defined(MBEDTLS_PKCS1_V21) + case MBEDTLS_RSA_PKCS_V21: + return mbedtls_rsa_rsaes_oaep_decrypt( ctx, f_rng, p_rng, mode, NULL, 0, + olen, input, output, + output_max_len ); +#endif + + default: + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + } +} + +#if defined(MBEDTLS_PKCS1_V21) +/* + * Implementation of the PKCS#1 v2.1 RSASSA-PSS-SIGN function + */ +int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ) +{ + size_t olen; + unsigned char *p = sig; + unsigned char salt[MBEDTLS_MD_MAX_SIZE]; + unsigned int slen, hlen, offset = 0; + int ret; + size_t msb; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( f_rng == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + olen = ctx->len; + + if( md_alg != MBEDTLS_MD_NONE ) + { + /* Gather length of hash to sign */ + md_info = mbedtls_md_info_from_type( md_alg ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + hashlen = mbedtls_md_get_size( md_info ); + } + + md_info = mbedtls_md_info_from_type( (mbedtls_md_type_t) ctx->hash_id ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + hlen = mbedtls_md_get_size( md_info ); + slen = hlen; + + if( olen < hlen + slen + 2 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + memset( sig, 0, olen ); + + /* Generate salt of length slen */ + if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 ) + return( MBEDTLS_ERR_RSA_RNG_FAILED + ret ); + + /* Note: EMSA-PSS encoding is over the length of N - 1 bits */ + msb = mbedtls_mpi_bitlen( &ctx->N ) - 1; + p += olen - hlen * 2 - 2; + *p++ = 0x01; + memcpy( p, salt, slen ); + p += slen; + + mbedtls_md_init( &md_ctx ); + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 ) + { + mbedtls_md_free( &md_ctx ); + return( ret ); + } + + /* Generate H = Hash( M' ) */ + mbedtls_md_starts( &md_ctx ); + mbedtls_md_update( &md_ctx, p, 8 ); + mbedtls_md_update( &md_ctx, hash, hashlen ); + mbedtls_md_update( &md_ctx, salt, slen ); + mbedtls_md_finish( &md_ctx, p ); + + /* Compensate for boundary condition when applying mask */ + if( msb % 8 == 0 ) + offset = 1; + + /* maskedDB: Apply dbMask to DB */ + mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen, &md_ctx ); + + mbedtls_md_free( &md_ctx ); + + msb = mbedtls_mpi_bitlen( &ctx->N ) - 1; + sig[0] &= 0xFF >> ( olen * 8 - msb ); + + p += hlen; + *p++ = 0xBC; + + return( ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, sig, sig ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig ) ); +} +#endif /* MBEDTLS_PKCS1_V21 */ + +#if defined(MBEDTLS_PKCS1_V15) +/* + * Implementation of the PKCS#1 v2.1 RSASSA-PKCS1-V1_5-SIGN function + */ +/* + * Do an RSA operation to sign the message digest + */ +int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ) +{ + size_t nb_pad, olen, oid_size = 0; + unsigned char *p = sig; + const char *oid = NULL; + unsigned char *sig_try = NULL, *verif = NULL; + size_t i; + unsigned char diff; + volatile unsigned char diff_no_optimize; + int ret; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + olen = ctx->len; + nb_pad = olen - 3; + + if( md_alg != MBEDTLS_MD_NONE ) + { + const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + if( mbedtls_oid_get_oid_by_md( md_alg, &oid, &oid_size ) != 0 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + nb_pad -= 10 + oid_size; + + hashlen = mbedtls_md_get_size( md_info ); + } + + nb_pad -= hashlen; + + if( ( nb_pad < 8 ) || ( nb_pad > olen ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + *p++ = 0; + *p++ = MBEDTLS_RSA_SIGN; + memset( p, 0xFF, nb_pad ); + p += nb_pad; + *p++ = 0; + + if( md_alg == MBEDTLS_MD_NONE ) + { + memcpy( p, hash, hashlen ); + } + else + { + /* + * DigestInfo ::= SEQUENCE { + * digestAlgorithm DigestAlgorithmIdentifier, + * digest Digest } + * + * DigestAlgorithmIdentifier ::= AlgorithmIdentifier + * + * Digest ::= OCTET STRING + */ + *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED; + *p++ = (unsigned char) ( 0x08 + oid_size + hashlen ); + *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED; + *p++ = (unsigned char) ( 0x04 + oid_size ); + *p++ = MBEDTLS_ASN1_OID; + *p++ = oid_size & 0xFF; + memcpy( p, oid, oid_size ); + p += oid_size; + *p++ = MBEDTLS_ASN1_NULL; + *p++ = 0x00; + *p++ = MBEDTLS_ASN1_OCTET_STRING; + *p++ = hashlen; + memcpy( p, hash, hashlen ); + } + + if( mode == MBEDTLS_RSA_PUBLIC ) + return( mbedtls_rsa_public( ctx, sig, sig ) ); + + /* + * In order to prevent Lenstra's attack, make the signature in a + * temporary buffer and check it before returning it. + */ + sig_try = mbedtls_calloc( 1, ctx->len ); + if( sig_try == NULL ) + return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); + + verif = mbedtls_calloc( 1, ctx->len ); + if( verif == NULL ) + { + mbedtls_free( sig_try ); + return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); + } + + MBEDTLS_MPI_CHK( mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig_try ) ); + MBEDTLS_MPI_CHK( mbedtls_rsa_public( ctx, sig_try, verif ) ); + + /* Compare in constant time just in case */ + for( diff = 0, i = 0; i < ctx->len; i++ ) + diff |= verif[i] ^ sig[i]; + diff_no_optimize = diff; + + if( diff_no_optimize != 0 ) + { + ret = MBEDTLS_ERR_RSA_PRIVATE_FAILED; + goto cleanup; + } + + memcpy( sig, sig_try, ctx->len ); + +cleanup: + mbedtls_free( sig_try ); + mbedtls_free( verif ); + + return( ret ); +} +#endif /* MBEDTLS_PKCS1_V15 */ + +/* + * Do an RSA operation to sign the message digest + */ +int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + unsigned char *sig ) +{ + switch( ctx->padding ) + { +#if defined(MBEDTLS_PKCS1_V15) + case MBEDTLS_RSA_PKCS_V15: + return mbedtls_rsa_rsassa_pkcs1_v15_sign( ctx, f_rng, p_rng, mode, md_alg, + hashlen, hash, sig ); +#endif + +#if defined(MBEDTLS_PKCS1_V21) + case MBEDTLS_RSA_PKCS_V21: + return mbedtls_rsa_rsassa_pss_sign( ctx, f_rng, p_rng, mode, md_alg, + hashlen, hash, sig ); +#endif + + default: + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + } +} + +#if defined(MBEDTLS_PKCS1_V21) +/* + * Implementation of the PKCS#1 v2.1 RSASSA-PSS-VERIFY function + */ +int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + mbedtls_md_type_t mgf1_hash_id, + int expected_salt_len, + const unsigned char *sig ) +{ + int ret; + size_t siglen; + unsigned char *p; + unsigned char result[MBEDTLS_MD_MAX_SIZE]; + unsigned char zeros[8]; + unsigned int hlen; + size_t slen, msb; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + siglen = ctx->len; + + if( siglen < 16 || siglen > sizeof( buf ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + ret = ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, sig, buf ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, buf ); + + if( ret != 0 ) + return( ret ); + + p = buf; + + if( buf[siglen - 1] != 0xBC ) + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + + if( md_alg != MBEDTLS_MD_NONE ) + { + /* Gather length of hash to sign */ + md_info = mbedtls_md_info_from_type( md_alg ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + hashlen = mbedtls_md_get_size( md_info ); + } + + md_info = mbedtls_md_info_from_type( mgf1_hash_id ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + hlen = mbedtls_md_get_size( md_info ); + slen = siglen - hlen - 1; /* Currently length of salt + padding */ + + memset( zeros, 0, 8 ); + + /* + * Note: EMSA-PSS verification is over the length of N - 1 bits + */ + msb = mbedtls_mpi_bitlen( &ctx->N ) - 1; + + /* Compensate for boundary condition when applying mask */ + if( msb % 8 == 0 ) + { + p++; + siglen -= 1; + } + if( buf[0] >> ( 8 - siglen * 8 + msb ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + mbedtls_md_init( &md_ctx ); + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 ) + { + mbedtls_md_free( &md_ctx ); + return( ret ); + } + + mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx ); + + buf[0] &= 0xFF >> ( siglen * 8 - msb ); + + while( p < buf + siglen && *p == 0 ) + p++; + + if( p == buf + siglen || + *p++ != 0x01 ) + { + mbedtls_md_free( &md_ctx ); + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + } + + /* Actual salt len */ + slen -= p - buf; + + if( expected_salt_len != MBEDTLS_RSA_SALT_LEN_ANY && + slen != (size_t) expected_salt_len ) + { + mbedtls_md_free( &md_ctx ); + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + } + + /* + * Generate H = Hash( M' ) + */ + mbedtls_md_starts( &md_ctx ); + mbedtls_md_update( &md_ctx, zeros, 8 ); + mbedtls_md_update( &md_ctx, hash, hashlen ); + mbedtls_md_update( &md_ctx, p, slen ); + mbedtls_md_finish( &md_ctx, result ); + + mbedtls_md_free( &md_ctx ); + + if( memcmp( p + slen, result, hlen ) == 0 ) + return( 0 ); + else + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); +} + +/* + * Simplified PKCS#1 v2.1 RSASSA-PSS-VERIFY function + */ +int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + const unsigned char *sig ) +{ + mbedtls_md_type_t mgf1_hash_id = ( ctx->hash_id != MBEDTLS_MD_NONE ) + ? (mbedtls_md_type_t) ctx->hash_id + : md_alg; + + return( mbedtls_rsa_rsassa_pss_verify_ext( ctx, f_rng, p_rng, mode, + md_alg, hashlen, hash, + mgf1_hash_id, MBEDTLS_RSA_SALT_LEN_ANY, + sig ) ); + +} +#endif /* MBEDTLS_PKCS1_V21 */ + +#if defined(MBEDTLS_PKCS1_V15) +/* + * Implementation of the PKCS#1 v2.1 RSASSA-PKCS1-v1_5-VERIFY function + */ +int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + const unsigned char *sig ) +{ + int ret; + size_t len, siglen, asn1_len; + unsigned char *p, *end; + mbedtls_md_type_t msg_md_alg; + const mbedtls_md_info_t *md_info; + mbedtls_asn1_buf oid; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + siglen = ctx->len; + + if( siglen < 16 || siglen > sizeof( buf ) ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + + ret = ( mode == MBEDTLS_RSA_PUBLIC ) + ? mbedtls_rsa_public( ctx, sig, buf ) + : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, buf ); + + if( ret != 0 ) + return( ret ); + + p = buf; + + if( *p++ != 0 || *p++ != MBEDTLS_RSA_SIGN ) + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + + while( *p != 0 ) + { + if( p >= buf + siglen - 1 || *p != 0xFF ) + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + p++; + } + p++; + + len = siglen - ( p - buf ); + + if( len == hashlen && md_alg == MBEDTLS_MD_NONE ) + { + if( memcmp( p, hash, hashlen ) == 0 ) + return( 0 ); + else + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + } + + md_info = mbedtls_md_info_from_type( md_alg ); + if( md_info == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + hashlen = mbedtls_md_get_size( md_info ); + + end = p + len; + + /* + * Parse the ASN.1 structure inside the PKCS#1 v1.5 structure + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( asn1_len + 2 != len ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( asn1_len + 6 + hashlen != len ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &oid.len, MBEDTLS_ASN1_OID ) ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + oid.p = p; + p += oid.len; + + if( mbedtls_oid_get_md_alg( &oid, &msg_md_alg ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( md_alg != msg_md_alg ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + /* + * assume the algorithm parameters must be NULL + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_NULL ) ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( asn1_len != hashlen ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + if( memcmp( p, hash, hashlen ) != 0 ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + p += hashlen; + + if( p != end ) + return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); + + return( 0 ); +} +#endif /* MBEDTLS_PKCS1_V15 */ + +/* + * Do an RSA operation and check the message digest + */ +int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + int mode, + mbedtls_md_type_t md_alg, + unsigned int hashlen, + const unsigned char *hash, + const unsigned char *sig ) +{ + switch( ctx->padding ) + { +#if defined(MBEDTLS_PKCS1_V15) + case MBEDTLS_RSA_PKCS_V15: + return mbedtls_rsa_rsassa_pkcs1_v15_verify( ctx, f_rng, p_rng, mode, md_alg, + hashlen, hash, sig ); +#endif + +#if defined(MBEDTLS_PKCS1_V21) + case MBEDTLS_RSA_PKCS_V21: + return mbedtls_rsa_rsassa_pss_verify( ctx, f_rng, p_rng, mode, md_alg, + hashlen, hash, sig ); +#endif + + default: + return( MBEDTLS_ERR_RSA_INVALID_PADDING ); + } +} + +/* + * Copy the components of an RSA key + */ +int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src ) +{ + int ret; + + dst->ver = src->ver; + dst->len = src->len; + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->N, &src->N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->E, &src->E ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->D, &src->D ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->P, &src->P ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Q, &src->Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->DP, &src->DP ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->DQ, &src->DQ ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->QP, &src->QP ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RN, &src->RN ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RP, &src->RP ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RQ, &src->RQ ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Vi, &src->Vi ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Vf, &src->Vf ) ); + + dst->padding = src->padding; + dst->hash_id = src->hash_id; + +cleanup: + if( ret != 0 ) + mbedtls_rsa_free( dst ); + + return( ret ); +} + +/* + * Free the components of an RSA key + */ +void mbedtls_rsa_free( mbedtls_rsa_context *ctx ) +{ + mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->Vf ); + mbedtls_mpi_free( &ctx->RQ ); mbedtls_mpi_free( &ctx->RP ); mbedtls_mpi_free( &ctx->RN ); + mbedtls_mpi_free( &ctx->QP ); mbedtls_mpi_free( &ctx->DQ ); mbedtls_mpi_free( &ctx->DP ); + mbedtls_mpi_free( &ctx->Q ); mbedtls_mpi_free( &ctx->P ); mbedtls_mpi_free( &ctx->D ); + mbedtls_mpi_free( &ctx->E ); mbedtls_mpi_free( &ctx->N ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &ctx->mutex ); +#endif +} + +#if defined(MBEDTLS_SELF_TEST) + +#include "mbedtls/sha1.h" + +/* + * Example RSA-1024 keypair, for test purposes + */ +#define KEY_LEN 128 + +#define RSA_N "9292758453063D803DD603D5E777D788" \ + "8ED1D5BF35786190FA2F23EBC0848AEA" \ + "DDA92CA6C3D80B32C4D109BE0F36D6AE" \ + "7130B9CED7ACDF54CFC7555AC14EEBAB" \ + "93A89813FBF3C4F8066D2D800F7C38A8" \ + "1AE31942917403FF4946B0A83D3D3E05" \ + "EE57C6F5F5606FB5D4BC6CD34EE0801A" \ + "5E94BB77B07507233A0BC7BAC8F90F79" + +#define RSA_E "10001" + +#define RSA_D "24BF6185468786FDD303083D25E64EFC" \ + "66CA472BC44D253102F8B4A9D3BFA750" \ + "91386C0077937FE33FA3252D28855837" \ + "AE1B484A8A9A45F7EE8C0C634F99E8CD" \ + "DF79C5CE07EE72C7F123142198164234" \ + "CABB724CF78B8173B9F880FC86322407" \ + "AF1FEDFDDE2BEB674CA15F3E81A1521E" \ + "071513A1E85B5DFA031F21ECAE91A34D" + +#define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \ + "2C01CAD19EA484A87EA4377637E75500" \ + "FCB2005C5C7DD6EC4AC023CDA285D796" \ + "C3D9E75E1EFC42488BB4F1D13AC30A57" + +#define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \ + "E211C2B9E5DB1ED0BF61D0D9899620F4" \ + "910E4168387E3C30AA1E00C339A79508" \ + "8452DD96A9A5EA5D9DCA68DA636032AF" + +#define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \ + "3C94D22288ACD763FD8E5600ED4A702D" \ + "F84198A5F06C2E72236AE490C93F07F8" \ + "3CC559CD27BC2D1CA488811730BB5725" + +#define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \ + "D8AAEA56749EA28623272E4F7D0592AF" \ + "7C1F1313CAC9471B5C523BFE592F517B" \ + "407A1BD76C164B93DA2D32A383E58357" + +#define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \ + "F38D18D2B2F0E2DD275AA977E2BF4411" \ + "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \ + "A74206CEC169D74BF5A8C50D6F48EA08" + +#define PT_LEN 24 +#define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \ + "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD" + +#if defined(MBEDTLS_PKCS1_V15) +static int myrand( void *rng_state, unsigned char *output, size_t len ) +{ +#if !defined(__OpenBSD__) + size_t i; + + if( rng_state != NULL ) + rng_state = NULL; + + for( i = 0; i < len; ++i ) + output[i] = rand(); +#else + if( rng_state != NULL ) + rng_state = NULL; + + arc4random_buf( output, len ); +#endif /* !OpenBSD */ + + return( 0 ); +} +#endif /* MBEDTLS_PKCS1_V15 */ + +/* + * Checkup routine + */ +int mbedtls_rsa_self_test( int verbose ) +{ + int ret = 0; +#if defined(MBEDTLS_PKCS1_V15) + size_t len; + mbedtls_rsa_context rsa; + unsigned char rsa_plaintext[PT_LEN]; + unsigned char rsa_decrypted[PT_LEN]; + unsigned char rsa_ciphertext[KEY_LEN]; +#if defined(MBEDTLS_SHA1_C) + unsigned char sha1sum[20]; +#endif + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + + rsa.len = KEY_LEN; + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.N , 16, RSA_N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.E , 16, RSA_E ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.D , 16, RSA_D ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.P , 16, RSA_P ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.Q , 16, RSA_Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.DP, 16, RSA_DP ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.DQ, 16, RSA_DQ ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.QP, 16, RSA_QP ) ); + + if( verbose != 0 ) + mbedtls_printf( " RSA key validation: " ); + + if( mbedtls_rsa_check_pubkey( &rsa ) != 0 || + mbedtls_rsa_check_privkey( &rsa ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n PKCS#1 encryption : " ); + + memcpy( rsa_plaintext, RSA_PT, PT_LEN ); + + if( mbedtls_rsa_pkcs1_encrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PUBLIC, PT_LEN, + rsa_plaintext, rsa_ciphertext ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n PKCS#1 decryption : " ); + + if( mbedtls_rsa_pkcs1_decrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE, &len, + rsa_ciphertext, rsa_decrypted, + sizeof(rsa_decrypted) ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + +#if defined(MBEDTLS_SHA1_C) + if( verbose != 0 ) + mbedtls_printf( " PKCS#1 data sign : " ); + + mbedtls_sha1( rsa_plaintext, PT_LEN, sha1sum ); + + if( mbedtls_rsa_pkcs1_sign( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA1, 0, + sha1sum, rsa_ciphertext ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n PKCS#1 sig. verify: " ); + + if( mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA1, 0, + sha1sum, rsa_ciphertext ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); +#endif /* MBEDTLS_SHA1_C */ + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +cleanup: + mbedtls_rsa_free( &rsa ); +#else /* MBEDTLS_PKCS1_V15 */ + ((void) verbose); +#endif /* MBEDTLS_PKCS1_V15 */ + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_RSA_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha1.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha1.c new file mode 100644 index 0000000..2ccf2a2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha1.c @@ -0,0 +1,448 @@ +/* + * FIPS-180-1 compliant SHA-1 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The SHA-1 standard was published by NIST in 1993. + * + * http://www.itl.nist.gov/fipspubs/fip180-1.htm + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SHA1_C) + +#include "mbedtls/sha1.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_SHA1_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +void mbedtls_sha1_init( mbedtls_sha1_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_sha1_context ) ); +} + +void mbedtls_sha1_free( mbedtls_sha1_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_sha1_context ) ); +} + +void mbedtls_sha1_clone( mbedtls_sha1_context *dst, + const mbedtls_sha1_context *src ) +{ + *dst = *src; +} + +/* + * SHA-1 context setup + */ +void mbedtls_sha1_starts( mbedtls_sha1_context *ctx ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xC3D2E1F0; +} + +#if !defined(MBEDTLS_SHA1_PROCESS_ALT) +void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] ) +{ + uint32_t temp, W[16], A, B, C, D, E; + + GET_UINT32_BE( W[ 0], data, 0 ); + GET_UINT32_BE( W[ 1], data, 4 ); + GET_UINT32_BE( W[ 2], data, 8 ); + GET_UINT32_BE( W[ 3], data, 12 ); + GET_UINT32_BE( W[ 4], data, 16 ); + GET_UINT32_BE( W[ 5], data, 20 ); + GET_UINT32_BE( W[ 6], data, 24 ); + GET_UINT32_BE( W[ 7], data, 28 ); + GET_UINT32_BE( W[ 8], data, 32 ); + GET_UINT32_BE( W[ 9], data, 36 ); + GET_UINT32_BE( W[10], data, 40 ); + GET_UINT32_BE( W[11], data, 44 ); + GET_UINT32_BE( W[12], data, 48 ); + GET_UINT32_BE( W[13], data, 52 ); + GET_UINT32_BE( W[14], data, 56 ); + GET_UINT32_BE( W[15], data, 60 ); + +#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define R(t) \ +( \ + temp = W[( t - 3 ) & 0x0F] ^ W[( t - 8 ) & 0x0F] ^ \ + W[( t - 14 ) & 0x0F] ^ W[ t & 0x0F], \ + ( W[t & 0x0F] = S(temp,1) ) \ +) + +#define P(a,b,c,d,e,x) \ +{ \ + e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ +} + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + +#define F(x,y,z) (z ^ (x & (y ^ z))) +#define K 0x5A827999 + + P( A, B, C, D, E, W[0] ); + P( E, A, B, C, D, W[1] ); + P( D, E, A, B, C, W[2] ); + P( C, D, E, A, B, W[3] ); + P( B, C, D, E, A, W[4] ); + P( A, B, C, D, E, W[5] ); + P( E, A, B, C, D, W[6] ); + P( D, E, A, B, C, W[7] ); + P( C, D, E, A, B, W[8] ); + P( B, C, D, E, A, W[9] ); + P( A, B, C, D, E, W[10] ); + P( E, A, B, C, D, W[11] ); + P( D, E, A, B, C, W[12] ); + P( C, D, E, A, B, W[13] ); + P( B, C, D, E, A, W[14] ); + P( A, B, C, D, E, W[15] ); + P( E, A, B, C, D, R(16) ); + P( D, E, A, B, C, R(17) ); + P( C, D, E, A, B, R(18) ); + P( B, C, D, E, A, R(19) ); + +#undef K +#undef F + +#define F(x,y,z) (x ^ y ^ z) +#define K 0x6ED9EBA1 + + P( A, B, C, D, E, R(20) ); + P( E, A, B, C, D, R(21) ); + P( D, E, A, B, C, R(22) ); + P( C, D, E, A, B, R(23) ); + P( B, C, D, E, A, R(24) ); + P( A, B, C, D, E, R(25) ); + P( E, A, B, C, D, R(26) ); + P( D, E, A, B, C, R(27) ); + P( C, D, E, A, B, R(28) ); + P( B, C, D, E, A, R(29) ); + P( A, B, C, D, E, R(30) ); + P( E, A, B, C, D, R(31) ); + P( D, E, A, B, C, R(32) ); + P( C, D, E, A, B, R(33) ); + P( B, C, D, E, A, R(34) ); + P( A, B, C, D, E, R(35) ); + P( E, A, B, C, D, R(36) ); + P( D, E, A, B, C, R(37) ); + P( C, D, E, A, B, R(38) ); + P( B, C, D, E, A, R(39) ); + +#undef K +#undef F + +#define F(x,y,z) ((x & y) | (z & (x | y))) +#define K 0x8F1BBCDC + + P( A, B, C, D, E, R(40) ); + P( E, A, B, C, D, R(41) ); + P( D, E, A, B, C, R(42) ); + P( C, D, E, A, B, R(43) ); + P( B, C, D, E, A, R(44) ); + P( A, B, C, D, E, R(45) ); + P( E, A, B, C, D, R(46) ); + P( D, E, A, B, C, R(47) ); + P( C, D, E, A, B, R(48) ); + P( B, C, D, E, A, R(49) ); + P( A, B, C, D, E, R(50) ); + P( E, A, B, C, D, R(51) ); + P( D, E, A, B, C, R(52) ); + P( C, D, E, A, B, R(53) ); + P( B, C, D, E, A, R(54) ); + P( A, B, C, D, E, R(55) ); + P( E, A, B, C, D, R(56) ); + P( D, E, A, B, C, R(57) ); + P( C, D, E, A, B, R(58) ); + P( B, C, D, E, A, R(59) ); + +#undef K +#undef F + +#define F(x,y,z) (x ^ y ^ z) +#define K 0xCA62C1D6 + + P( A, B, C, D, E, R(60) ); + P( E, A, B, C, D, R(61) ); + P( D, E, A, B, C, R(62) ); + P( C, D, E, A, B, R(63) ); + P( B, C, D, E, A, R(64) ); + P( A, B, C, D, E, R(65) ); + P( E, A, B, C, D, R(66) ); + P( D, E, A, B, C, R(67) ); + P( C, D, E, A, B, R(68) ); + P( B, C, D, E, A, R(69) ); + P( A, B, C, D, E, R(70) ); + P( E, A, B, C, D, R(71) ); + P( D, E, A, B, C, R(72) ); + P( C, D, E, A, B, R(73) ); + P( B, C, D, E, A, R(74) ); + P( A, B, C, D, E, R(75) ); + P( E, A, B, C, D, R(76) ); + P( D, E, A, B, C, R(77) ); + P( C, D, E, A, B, R(78) ); + P( B, C, D, E, A, R(79) ); + +#undef K +#undef F + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; +} +#endif /* !MBEDTLS_SHA1_PROCESS_ALT */ + +/* + * SHA-1 process buffer + */ +void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen ) +{ + size_t fill; + uint32_t left; + + if( ilen == 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t) ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if( ctx->total[0] < (uint32_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), input, fill ); + mbedtls_sha1_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 64 ) + { + mbedtls_sha1_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if( ilen > 0 ) + memcpy( (void *) (ctx->buffer + left), input, ilen ); +} + +static const unsigned char sha1_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * SHA-1 final digest + */ +void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] ) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT32_BE( high, msglen, 0 ); + PUT_UINT32_BE( low, msglen, 4 ); + + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + mbedtls_sha1_update( ctx, sha1_padding, padn ); + mbedtls_sha1_update( ctx, msglen, 8 ); + + PUT_UINT32_BE( ctx->state[0], output, 0 ); + PUT_UINT32_BE( ctx->state[1], output, 4 ); + PUT_UINT32_BE( ctx->state[2], output, 8 ); + PUT_UINT32_BE( ctx->state[3], output, 12 ); + PUT_UINT32_BE( ctx->state[4], output, 16 ); +} + +#endif /* !MBEDTLS_SHA1_ALT */ + +/* + * output = SHA-1( input buffer ) + */ +void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] ) +{ + mbedtls_sha1_context ctx; + + mbedtls_sha1_init( &ctx ); + mbedtls_sha1_starts( &ctx ); + mbedtls_sha1_update( &ctx, input, ilen ); + mbedtls_sha1_finish( &ctx, output ); + mbedtls_sha1_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) +/* + * FIPS-180-1 test vectors + */ +static const unsigned char sha1_test_buf[3][57] = +{ + { "abc" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }, + { "" } +}; + +static const int sha1_test_buflen[3] = +{ + 3, 56, 1000 +}; + +static const unsigned char sha1_test_sum[3][20] = +{ + { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, + 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D }, + { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, + 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 }, + { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, + 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F } +}; + +/* + * Checkup routine + */ +int mbedtls_sha1_self_test( int verbose ) +{ + int i, j, buflen, ret = 0; + unsigned char buf[1024]; + unsigned char sha1sum[20]; + mbedtls_sha1_context ctx; + + mbedtls_sha1_init( &ctx ); + + /* + * SHA-1 + */ + for( i = 0; i < 3; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " SHA-1 test #%d: ", i + 1 ); + + mbedtls_sha1_starts( &ctx ); + + if( i == 2 ) + { + memset( buf, 'a', buflen = 1000 ); + + for( j = 0; j < 1000; j++ ) + mbedtls_sha1_update( &ctx, buf, buflen ); + } + else + mbedtls_sha1_update( &ctx, sha1_test_buf[i], + sha1_test_buflen[i] ); + + mbedtls_sha1_finish( &ctx, sha1sum ); + + if( memcmp( sha1sum, sha1_test_sum[i], 20 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_sha1_free( &ctx ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_SHA1_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha256.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha256.c new file mode 100644 index 0000000..ad25d38 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha256.c @@ -0,0 +1,458 @@ +/* + * FIPS-180-2 compliant SHA-256 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The SHA-256 Secure Hash Standard was published by NIST in 2002. + * + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SHA256_C) + +#include "mbedtls/sha256.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_SHA256_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +do { \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} while( 0 ) +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +do { \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} while( 0 ) +#endif + +void mbedtls_sha256_init( mbedtls_sha256_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_sha256_context ) ); +} + +void mbedtls_sha256_free( mbedtls_sha256_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_sha256_context ) ); +} + +void mbedtls_sha256_clone( mbedtls_sha256_context *dst, + const mbedtls_sha256_context *src ) +{ + *dst = *src; +} + +/* + * SHA-256 context setup + */ +void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + if( is224 == 0 ) + { + /* SHA-256 */ + ctx->state[0] = 0x6A09E667; + ctx->state[1] = 0xBB67AE85; + ctx->state[2] = 0x3C6EF372; + ctx->state[3] = 0xA54FF53A; + ctx->state[4] = 0x510E527F; + ctx->state[5] = 0x9B05688C; + ctx->state[6] = 0x1F83D9AB; + ctx->state[7] = 0x5BE0CD19; + } + else + { + /* SHA-224 */ + ctx->state[0] = 0xC1059ED8; + ctx->state[1] = 0x367CD507; + ctx->state[2] = 0x3070DD17; + ctx->state[3] = 0xF70E5939; + ctx->state[4] = 0xFFC00B31; + ctx->state[5] = 0x68581511; + ctx->state[6] = 0x64F98FA7; + ctx->state[7] = 0xBEFA4FA4; + } + + ctx->is224 = is224; +} + +#if !defined(MBEDTLS_SHA256_PROCESS_ALT) +static const uint32_t K[] = +{ + 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, + 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, + 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, + 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, + 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, + 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, + 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, + 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, + 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, + 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, + 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, + 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, + 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, + 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, + 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, + 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2, +}; + +#define SHR(x,n) ((x & 0xFFFFFFFF) >> n) +#define ROTR(x,n) (SHR(x,n) | (x << (32 - n))) + +#define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3)) +#define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10)) + +#define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22)) +#define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25)) + +#define F0(x,y,z) ((x & y) | (z & (x | y))) +#define F1(x,y,z) (z ^ (x & (y ^ z))) + +#define R(t) \ +( \ + W[t] = S1(W[t - 2]) + W[t - 7] + \ + S0(W[t - 15]) + W[t - 16] \ +) + +#define P(a,b,c,d,e,f,g,h,x,K) \ +{ \ + temp1 = h + S3(e) + F1(e,f,g) + K + x; \ + temp2 = S2(a) + F0(a,b,c); \ + d += temp1; h = temp1 + temp2; \ +} + +void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ) +{ + uint32_t temp1, temp2, W[64]; + uint32_t A[8]; + unsigned int i; + + for( i = 0; i < 8; i++ ) + A[i] = ctx->state[i]; + +#if defined(MBEDTLS_SHA256_SMALLER) + for( i = 0; i < 64; i++ ) + { + if( i < 16 ) + GET_UINT32_BE( W[i], data, 4 * i ); + else + R( i ); + + P( A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[i], K[i] ); + + temp1 = A[7]; A[7] = A[6]; A[6] = A[5]; A[5] = A[4]; A[4] = A[3]; + A[3] = A[2]; A[2] = A[1]; A[1] = A[0]; A[0] = temp1; + } +#else /* MBEDTLS_SHA256_SMALLER */ + for( i = 0; i < 16; i++ ) + GET_UINT32_BE( W[i], data, 4 * i ); + + for( i = 0; i < 16; i += 8 ) + { + P( A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[i+0], K[i+0] ); + P( A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[i+1], K[i+1] ); + P( A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[i+2], K[i+2] ); + P( A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[i+3], K[i+3] ); + P( A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[i+4], K[i+4] ); + P( A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[i+5], K[i+5] ); + P( A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[i+6], K[i+6] ); + P( A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[i+7], K[i+7] ); + } + + for( i = 16; i < 64; i += 8 ) + { + P( A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(i+0), K[i+0] ); + P( A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(i+1), K[i+1] ); + P( A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(i+2), K[i+2] ); + P( A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(i+3), K[i+3] ); + P( A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(i+4), K[i+4] ); + P( A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(i+5), K[i+5] ); + P( A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(i+6), K[i+6] ); + P( A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(i+7), K[i+7] ); + } +#endif /* MBEDTLS_SHA256_SMALLER */ + + for( i = 0; i < 8; i++ ) + ctx->state[i] += A[i]; +} +#endif /* !MBEDTLS_SHA256_PROCESS_ALT */ + +/* + * SHA-256 process buffer + */ +void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, + size_t ilen ) +{ + size_t fill; + uint32_t left; + + if( ilen == 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t) ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if( ctx->total[0] < (uint32_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), input, fill ); + mbedtls_sha256_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 64 ) + { + mbedtls_sha256_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if( ilen > 0 ) + memcpy( (void *) (ctx->buffer + left), input, ilen ); +} + +static const unsigned char sha256_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * SHA-256 final digest + */ +void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] ) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT32_BE( high, msglen, 0 ); + PUT_UINT32_BE( low, msglen, 4 ); + + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + mbedtls_sha256_update( ctx, sha256_padding, padn ); + mbedtls_sha256_update( ctx, msglen, 8 ); + + PUT_UINT32_BE( ctx->state[0], output, 0 ); + PUT_UINT32_BE( ctx->state[1], output, 4 ); + PUT_UINT32_BE( ctx->state[2], output, 8 ); + PUT_UINT32_BE( ctx->state[3], output, 12 ); + PUT_UINT32_BE( ctx->state[4], output, 16 ); + PUT_UINT32_BE( ctx->state[5], output, 20 ); + PUT_UINT32_BE( ctx->state[6], output, 24 ); + + if( ctx->is224 == 0 ) + PUT_UINT32_BE( ctx->state[7], output, 28 ); +} + +#endif /* !MBEDTLS_SHA256_ALT */ + +/* + * output = SHA-256( input buffer ) + */ +void mbedtls_sha256( const unsigned char *input, size_t ilen, + unsigned char output[32], int is224 ) +{ + mbedtls_sha256_context ctx; + + mbedtls_sha256_init( &ctx ); + mbedtls_sha256_starts( &ctx, is224 ); + mbedtls_sha256_update( &ctx, input, ilen ); + mbedtls_sha256_finish( &ctx, output ); + mbedtls_sha256_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) +/* + * FIPS-180-2 test vectors + */ +static const unsigned char sha256_test_buf[3][57] = +{ + { "abc" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }, + { "" } +}; + +static const int sha256_test_buflen[3] = +{ + 3, 56, 1000 +}; + +static const unsigned char sha256_test_sum[6][32] = +{ + /* + * SHA-224 test vectors + */ + { 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22, + 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3, + 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7, + 0xE3, 0x6C, 0x9D, 0xA7 }, + { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC, + 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50, + 0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19, + 0x52, 0x52, 0x25, 0x25 }, + { 0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8, + 0xBB, 0xB4, 0xC1, 0xEA, 0x97, 0x61, 0x8A, 0x4B, + 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48, 0xB2, 0xEE, + 0x4E, 0xE7, 0xAD, 0x67 }, + + /* + * SHA-256 test vectors + */ + { 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, + 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23, + 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C, + 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD }, + { 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, + 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39, + 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67, + 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 }, + { 0xCD, 0xC7, 0x6E, 0x5C, 0x99, 0x14, 0xFB, 0x92, + 0x81, 0xA1, 0xC7, 0xE2, 0x84, 0xD7, 0x3E, 0x67, + 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E, + 0x04, 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0 } +}; + +/* + * Checkup routine + */ +int mbedtls_sha256_self_test( int verbose ) +{ + int i, j, k, buflen, ret = 0; + unsigned char *buf; + unsigned char sha256sum[32]; + mbedtls_sha256_context ctx; + + buf = mbedtls_calloc( 1024, sizeof(unsigned char) ); + if( NULL == buf ) + { + if( verbose != 0 ) + mbedtls_printf( "Buffer allocation failed\n" ); + + return( 1 ); + } + + mbedtls_sha256_init( &ctx ); + + for( i = 0; i < 6; i++ ) + { + j = i % 3; + k = i < 3; + + if( verbose != 0 ) + mbedtls_printf( " SHA-%d test #%d: ", 256 - k * 32, j + 1 ); + + mbedtls_sha256_starts( &ctx, k ); + + if( j == 2 ) + { + memset( buf, 'a', buflen = 1000 ); + + for( j = 0; j < 1000; j++ ) + mbedtls_sha256_update( &ctx, buf, buflen ); + } + else + mbedtls_sha256_update( &ctx, sha256_test_buf[j], + sha256_test_buflen[j] ); + + mbedtls_sha256_finish( &ctx, sha256sum ); + + if( memcmp( sha256sum, sha256_test_sum[i], 32 - k * 4 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_sha256_free( &ctx ); + mbedtls_free( buf ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_SHA256_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha512.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha512.c new file mode 100644 index 0000000..724522a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/sha512.c @@ -0,0 +1,514 @@ +/* + * FIPS-180-2 compliant SHA-384/512 implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The SHA-512 Secure Hash Standard was published by NIST in 2002. + * + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SHA512_C) + +#include "mbedtls/sha512.h" + +#if defined(_MSC_VER) || defined(__WATCOMC__) + #define UL64(x) x##ui64 +#else + #define UL64(x) x##ULL +#endif + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_SHA512_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * 64-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT64_BE +#define GET_UINT64_BE(n,b,i) \ +{ \ + (n) = ( (uint64_t) (b)[(i) ] << 56 ) \ + | ( (uint64_t) (b)[(i) + 1] << 48 ) \ + | ( (uint64_t) (b)[(i) + 2] << 40 ) \ + | ( (uint64_t) (b)[(i) + 3] << 32 ) \ + | ( (uint64_t) (b)[(i) + 4] << 24 ) \ + | ( (uint64_t) (b)[(i) + 5] << 16 ) \ + | ( (uint64_t) (b)[(i) + 6] << 8 ) \ + | ( (uint64_t) (b)[(i) + 7] ); \ +} +#endif /* GET_UINT64_BE */ + +#ifndef PUT_UINT64_BE +#define PUT_UINT64_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 56 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \ + (b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 7] = (unsigned char) ( (n) ); \ +} +#endif /* PUT_UINT64_BE */ + +void mbedtls_sha512_init( mbedtls_sha512_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_sha512_context ) ); +} + +void mbedtls_sha512_free( mbedtls_sha512_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_sha512_context ) ); +} + +void mbedtls_sha512_clone( mbedtls_sha512_context *dst, + const mbedtls_sha512_context *src ) +{ + *dst = *src; +} + +/* + * SHA-512 context setup + */ +void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + if( is384 == 0 ) + { + /* SHA-512 */ + ctx->state[0] = UL64(0x6A09E667F3BCC908); + ctx->state[1] = UL64(0xBB67AE8584CAA73B); + ctx->state[2] = UL64(0x3C6EF372FE94F82B); + ctx->state[3] = UL64(0xA54FF53A5F1D36F1); + ctx->state[4] = UL64(0x510E527FADE682D1); + ctx->state[5] = UL64(0x9B05688C2B3E6C1F); + ctx->state[6] = UL64(0x1F83D9ABFB41BD6B); + ctx->state[7] = UL64(0x5BE0CD19137E2179); + } + else + { + /* SHA-384 */ + ctx->state[0] = UL64(0xCBBB9D5DC1059ED8); + ctx->state[1] = UL64(0x629A292A367CD507); + ctx->state[2] = UL64(0x9159015A3070DD17); + ctx->state[3] = UL64(0x152FECD8F70E5939); + ctx->state[4] = UL64(0x67332667FFC00B31); + ctx->state[5] = UL64(0x8EB44A8768581511); + ctx->state[6] = UL64(0xDB0C2E0D64F98FA7); + ctx->state[7] = UL64(0x47B5481DBEFA4FA4); + } + + ctx->is384 = is384; +} + +#if !defined(MBEDTLS_SHA512_PROCESS_ALT) + +/* + * Round constants + */ +static const uint64_t K[80] = +{ + UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD), + UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC), + UL64(0x3956C25BF348B538), UL64(0x59F111F1B605D019), + UL64(0x923F82A4AF194F9B), UL64(0xAB1C5ED5DA6D8118), + UL64(0xD807AA98A3030242), UL64(0x12835B0145706FBE), + UL64(0x243185BE4EE4B28C), UL64(0x550C7DC3D5FFB4E2), + UL64(0x72BE5D74F27B896F), UL64(0x80DEB1FE3B1696B1), + UL64(0x9BDC06A725C71235), UL64(0xC19BF174CF692694), + UL64(0xE49B69C19EF14AD2), UL64(0xEFBE4786384F25E3), + UL64(0x0FC19DC68B8CD5B5), UL64(0x240CA1CC77AC9C65), + UL64(0x2DE92C6F592B0275), UL64(0x4A7484AA6EA6E483), + UL64(0x5CB0A9DCBD41FBD4), UL64(0x76F988DA831153B5), + UL64(0x983E5152EE66DFAB), UL64(0xA831C66D2DB43210), + UL64(0xB00327C898FB213F), UL64(0xBF597FC7BEEF0EE4), + UL64(0xC6E00BF33DA88FC2), UL64(0xD5A79147930AA725), + UL64(0x06CA6351E003826F), UL64(0x142929670A0E6E70), + UL64(0x27B70A8546D22FFC), UL64(0x2E1B21385C26C926), + UL64(0x4D2C6DFC5AC42AED), UL64(0x53380D139D95B3DF), + UL64(0x650A73548BAF63DE), UL64(0x766A0ABB3C77B2A8), + UL64(0x81C2C92E47EDAEE6), UL64(0x92722C851482353B), + UL64(0xA2BFE8A14CF10364), UL64(0xA81A664BBC423001), + UL64(0xC24B8B70D0F89791), UL64(0xC76C51A30654BE30), + UL64(0xD192E819D6EF5218), UL64(0xD69906245565A910), + UL64(0xF40E35855771202A), UL64(0x106AA07032BBD1B8), + UL64(0x19A4C116B8D2D0C8), UL64(0x1E376C085141AB53), + UL64(0x2748774CDF8EEB99), UL64(0x34B0BCB5E19B48A8), + UL64(0x391C0CB3C5C95A63), UL64(0x4ED8AA4AE3418ACB), + UL64(0x5B9CCA4F7763E373), UL64(0x682E6FF3D6B2B8A3), + UL64(0x748F82EE5DEFB2FC), UL64(0x78A5636F43172F60), + UL64(0x84C87814A1F0AB72), UL64(0x8CC702081A6439EC), + UL64(0x90BEFFFA23631E28), UL64(0xA4506CEBDE82BDE9), + UL64(0xBEF9A3F7B2C67915), UL64(0xC67178F2E372532B), + UL64(0xCA273ECEEA26619C), UL64(0xD186B8C721C0C207), + UL64(0xEADA7DD6CDE0EB1E), UL64(0xF57D4F7FEE6ED178), + UL64(0x06F067AA72176FBA), UL64(0x0A637DC5A2C898A6), + UL64(0x113F9804BEF90DAE), UL64(0x1B710B35131C471B), + UL64(0x28DB77F523047D84), UL64(0x32CAAB7B40C72493), + UL64(0x3C9EBE0A15C9BEBC), UL64(0x431D67C49C100D4C), + UL64(0x4CC5D4BECB3E42B6), UL64(0x597F299CFC657E2A), + UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817) +}; + +void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] ) +{ + int i; + uint64_t temp1, temp2, W[80]; + uint64_t A, B, C, D, E, F, G, H; + +#define SHR(x,n) (x >> n) +#define ROTR(x,n) (SHR(x,n) | (x << (64 - n))) + +#define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7)) +#define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6)) + +#define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39)) +#define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41)) + +#define F0(x,y,z) ((x & y) | (z & (x | y))) +#define F1(x,y,z) (z ^ (x & (y ^ z))) + +#define P(a,b,c,d,e,f,g,h,x,K) \ +{ \ + temp1 = h + S3(e) + F1(e,f,g) + K + x; \ + temp2 = S2(a) + F0(a,b,c); \ + d += temp1; h = temp1 + temp2; \ +} + + for( i = 0; i < 16; i++ ) + { + GET_UINT64_BE( W[i], data, i << 3 ); + } + + for( ; i < 80; i++ ) + { + W[i] = S1(W[i - 2]) + W[i - 7] + + S0(W[i - 15]) + W[i - 16]; + } + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + F = ctx->state[5]; + G = ctx->state[6]; + H = ctx->state[7]; + i = 0; + + do + { + P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++; + P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++; + P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++; + P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++; + P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++; + P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++; + P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++; + P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++; + } + while( i < 80 ); + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; + ctx->state[5] += F; + ctx->state[6] += G; + ctx->state[7] += H; +} +#endif /* !MBEDTLS_SHA512_PROCESS_ALT */ + +/* + * SHA-512 process buffer + */ +void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input, + size_t ilen ) +{ + size_t fill; + unsigned int left; + + if( ilen == 0 ) + return; + + left = (unsigned int) (ctx->total[0] & 0x7F); + fill = 128 - left; + + ctx->total[0] += (uint64_t) ilen; + + if( ctx->total[0] < (uint64_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), input, fill ); + mbedtls_sha512_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 128 ) + { + mbedtls_sha512_process( ctx, input ); + input += 128; + ilen -= 128; + } + + if( ilen > 0 ) + memcpy( (void *) (ctx->buffer + left), input, ilen ); +} + +static const unsigned char sha512_padding[128] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * SHA-512 final digest + */ +void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] ) +{ + size_t last, padn; + uint64_t high, low; + unsigned char msglen[16]; + + high = ( ctx->total[0] >> 61 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT64_BE( high, msglen, 0 ); + PUT_UINT64_BE( low, msglen, 8 ); + + last = (size_t)( ctx->total[0] & 0x7F ); + padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last ); + + mbedtls_sha512_update( ctx, sha512_padding, padn ); + mbedtls_sha512_update( ctx, msglen, 16 ); + + PUT_UINT64_BE( ctx->state[0], output, 0 ); + PUT_UINT64_BE( ctx->state[1], output, 8 ); + PUT_UINT64_BE( ctx->state[2], output, 16 ); + PUT_UINT64_BE( ctx->state[3], output, 24 ); + PUT_UINT64_BE( ctx->state[4], output, 32 ); + PUT_UINT64_BE( ctx->state[5], output, 40 ); + + if( ctx->is384 == 0 ) + { + PUT_UINT64_BE( ctx->state[6], output, 48 ); + PUT_UINT64_BE( ctx->state[7], output, 56 ); + } +} + +#endif /* !MBEDTLS_SHA512_ALT */ + +/* + * output = SHA-512( input buffer ) + */ +void mbedtls_sha512( const unsigned char *input, size_t ilen, + unsigned char output[64], int is384 ) +{ + mbedtls_sha512_context ctx; + + mbedtls_sha512_init( &ctx ); + mbedtls_sha512_starts( &ctx, is384 ); + mbedtls_sha512_update( &ctx, input, ilen ); + mbedtls_sha512_finish( &ctx, output ); + mbedtls_sha512_free( &ctx ); +} + +#if defined(MBEDTLS_SELF_TEST) + +/* + * FIPS-180-2 test vectors + */ +static const unsigned char sha512_test_buf[3][113] = +{ + { "abc" }, + { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" }, + { "" } +}; + +static const int sha512_test_buflen[3] = +{ + 3, 112, 1000 +}; + +static const unsigned char sha512_test_sum[6][64] = +{ + /* + * SHA-384 test vectors + */ + { 0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B, + 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07, + 0x27, 0x2C, 0x32, 0xAB, 0x0E, 0xDE, 0xD1, 0x63, + 0x1A, 0x8B, 0x60, 0x5A, 0x43, 0xFF, 0x5B, 0xED, + 0x80, 0x86, 0x07, 0x2B, 0xA1, 0xE7, 0xCC, 0x23, + 0x58, 0xBA, 0xEC, 0xA1, 0x34, 0xC8, 0x25, 0xA7 }, + { 0x09, 0x33, 0x0C, 0x33, 0xF7, 0x11, 0x47, 0xE8, + 0x3D, 0x19, 0x2F, 0xC7, 0x82, 0xCD, 0x1B, 0x47, + 0x53, 0x11, 0x1B, 0x17, 0x3B, 0x3B, 0x05, 0xD2, + 0x2F, 0xA0, 0x80, 0x86, 0xE3, 0xB0, 0xF7, 0x12, + 0xFC, 0xC7, 0xC7, 0x1A, 0x55, 0x7E, 0x2D, 0xB9, + 0x66, 0xC3, 0xE9, 0xFA, 0x91, 0x74, 0x60, 0x39 }, + { 0x9D, 0x0E, 0x18, 0x09, 0x71, 0x64, 0x74, 0xCB, + 0x08, 0x6E, 0x83, 0x4E, 0x31, 0x0A, 0x4A, 0x1C, + 0xED, 0x14, 0x9E, 0x9C, 0x00, 0xF2, 0x48, 0x52, + 0x79, 0x72, 0xCE, 0xC5, 0x70, 0x4C, 0x2A, 0x5B, + 0x07, 0xB8, 0xB3, 0xDC, 0x38, 0xEC, 0xC4, 0xEB, + 0xAE, 0x97, 0xDD, 0xD8, 0x7F, 0x3D, 0x89, 0x85 }, + + /* + * SHA-512 test vectors + */ + { 0xDD, 0xAF, 0x35, 0xA1, 0x93, 0x61, 0x7A, 0xBA, + 0xCC, 0x41, 0x73, 0x49, 0xAE, 0x20, 0x41, 0x31, + 0x12, 0xE6, 0xFA, 0x4E, 0x89, 0xA9, 0x7E, 0xA2, + 0x0A, 0x9E, 0xEE, 0xE6, 0x4B, 0x55, 0xD3, 0x9A, + 0x21, 0x92, 0x99, 0x2A, 0x27, 0x4F, 0xC1, 0xA8, + 0x36, 0xBA, 0x3C, 0x23, 0xA3, 0xFE, 0xEB, 0xBD, + 0x45, 0x4D, 0x44, 0x23, 0x64, 0x3C, 0xE8, 0x0E, + 0x2A, 0x9A, 0xC9, 0x4F, 0xA5, 0x4C, 0xA4, 0x9F }, + { 0x8E, 0x95, 0x9B, 0x75, 0xDA, 0xE3, 0x13, 0xDA, + 0x8C, 0xF4, 0xF7, 0x28, 0x14, 0xFC, 0x14, 0x3F, + 0x8F, 0x77, 0x79, 0xC6, 0xEB, 0x9F, 0x7F, 0xA1, + 0x72, 0x99, 0xAE, 0xAD, 0xB6, 0x88, 0x90, 0x18, + 0x50, 0x1D, 0x28, 0x9E, 0x49, 0x00, 0xF7, 0xE4, + 0x33, 0x1B, 0x99, 0xDE, 0xC4, 0xB5, 0x43, 0x3A, + 0xC7, 0xD3, 0x29, 0xEE, 0xB6, 0xDD, 0x26, 0x54, + 0x5E, 0x96, 0xE5, 0x5B, 0x87, 0x4B, 0xE9, 0x09 }, + { 0xE7, 0x18, 0x48, 0x3D, 0x0C, 0xE7, 0x69, 0x64, + 0x4E, 0x2E, 0x42, 0xC7, 0xBC, 0x15, 0xB4, 0x63, + 0x8E, 0x1F, 0x98, 0xB1, 0x3B, 0x20, 0x44, 0x28, + 0x56, 0x32, 0xA8, 0x03, 0xAF, 0xA9, 0x73, 0xEB, + 0xDE, 0x0F, 0xF2, 0x44, 0x87, 0x7E, 0xA6, 0x0A, + 0x4C, 0xB0, 0x43, 0x2C, 0xE5, 0x77, 0xC3, 0x1B, + 0xEB, 0x00, 0x9C, 0x5C, 0x2C, 0x49, 0xAA, 0x2E, + 0x4E, 0xAD, 0xB2, 0x17, 0xAD, 0x8C, 0xC0, 0x9B } +}; + +/* + * Checkup routine + */ +int mbedtls_sha512_self_test( int verbose ) +{ + int i, j, k, buflen, ret = 0; + unsigned char *buf; + unsigned char sha512sum[64]; + mbedtls_sha512_context ctx; + + buf = mbedtls_calloc( 1024, sizeof(unsigned char) ); + if( NULL == buf ) + { + if( verbose != 0 ) + mbedtls_printf( "Buffer allocation failed\n" ); + + return( 1 ); + } + + mbedtls_sha512_init( &ctx ); + + for( i = 0; i < 6; i++ ) + { + j = i % 3; + k = i < 3; + + if( verbose != 0 ) + mbedtls_printf( " SHA-%d test #%d: ", 512 - k * 128, j + 1 ); + + mbedtls_sha512_starts( &ctx, k ); + + if( j == 2 ) + { + memset( buf, 'a', buflen = 1000 ); + + for( j = 0; j < 1000; j++ ) + mbedtls_sha512_update( &ctx, buf, buflen ); + } + else + mbedtls_sha512_update( &ctx, sha512_test_buf[j], + sha512_test_buflen[j] ); + + mbedtls_sha512_finish( &ctx, sha512sum ); + + if( memcmp( sha512sum, sha512_test_sum[i], 64 - k * 16 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_sha512_free( &ctx ); + mbedtls_free( buf ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_SHA512_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cache.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cache.c new file mode 100644 index 0000000..9b62de2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cache.c @@ -0,0 +1,326 @@ +/* + * SSL session cache implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * These session callbacks use a simple chained list + * to store and retrieve the session information. + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_CACHE_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/ssl_cache.h" + +#include + +void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache ) +{ + memset( cache, 0, sizeof( mbedtls_ssl_cache_context ) ); + + cache->timeout = MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT; + cache->max_entries = MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES; + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &cache->mutex ); +#endif +} + +int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ) +{ + int ret = 1; +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t t = mbedtls_time( NULL ); +#endif + mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data; + mbedtls_ssl_cache_entry *cur, *entry; + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_lock( &cache->mutex ) != 0 ) + return( 1 ); +#endif + + cur = cache->chain; + entry = NULL; + + while( cur != NULL ) + { + entry = cur; + cur = cur->next; + +#if defined(MBEDTLS_HAVE_TIME) + if( cache->timeout != 0 && + (int) ( t - entry->timestamp ) > cache->timeout ) + continue; +#endif + + if( session->ciphersuite != entry->session.ciphersuite || + session->compression != entry->session.compression || + session->id_len != entry->session.id_len ) + continue; + + if( memcmp( session->id, entry->session.id, + entry->session.id_len ) != 0 ) + continue; + + memcpy( session->master, entry->session.master, 48 ); + + session->verify_result = entry->session.verify_result; + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * Restore peer certificate (without rest of the original chain) + */ + if( entry->peer_cert.p != NULL ) + { + if( ( session->peer_cert = mbedtls_calloc( 1, + sizeof(mbedtls_x509_crt) ) ) == NULL ) + { + ret = 1; + goto exit; + } + + mbedtls_x509_crt_init( session->peer_cert ); + if( mbedtls_x509_crt_parse( session->peer_cert, entry->peer_cert.p, + entry->peer_cert.len ) != 0 ) + { + mbedtls_free( session->peer_cert ); + session->peer_cert = NULL; + ret = 1; + goto exit; + } + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + ret = 0; + goto exit; + } + +exit: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &cache->mutex ) != 0 ) + ret = 1; +#endif + + return( ret ); +} + +int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ) +{ + int ret = 1; +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t t = time( NULL ), oldest = 0; + mbedtls_ssl_cache_entry *old = NULL; +#endif + mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data; + mbedtls_ssl_cache_entry *cur, *prv; + int count = 0; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &cache->mutex ) ) != 0 ) + return( ret ); +#endif + + cur = cache->chain; + prv = NULL; + + while( cur != NULL ) + { + count++; + +#if defined(MBEDTLS_HAVE_TIME) + if( cache->timeout != 0 && + (int) ( t - cur->timestamp ) > cache->timeout ) + { + cur->timestamp = t; + break; /* expired, reuse this slot, update timestamp */ + } +#endif + + if( memcmp( session->id, cur->session.id, cur->session.id_len ) == 0 ) + break; /* client reconnected, keep timestamp for session id */ + +#if defined(MBEDTLS_HAVE_TIME) + if( oldest == 0 || cur->timestamp < oldest ) + { + oldest = cur->timestamp; + old = cur; + } +#endif + + prv = cur; + cur = cur->next; + } + + if( cur == NULL ) + { +#if defined(MBEDTLS_HAVE_TIME) + /* + * Reuse oldest entry if max_entries reached + */ + if( count >= cache->max_entries ) + { + if( old == NULL ) + { + ret = 1; + goto exit; + } + + cur = old; + } +#else /* MBEDTLS_HAVE_TIME */ + /* + * Reuse first entry in chain if max_entries reached, + * but move to last place + */ + if( count >= cache->max_entries ) + { + if( cache->chain == NULL ) + { + ret = 1; + goto exit; + } + + cur = cache->chain; + cache->chain = cur->next; + cur->next = NULL; + prv->next = cur; + } +#endif /* MBEDTLS_HAVE_TIME */ + else + { + /* + * max_entries not reached, create new entry + */ + cur = mbedtls_calloc( 1, sizeof(mbedtls_ssl_cache_entry) ); + if( cur == NULL ) + { + ret = 1; + goto exit; + } + + if( prv == NULL ) + cache->chain = cur; + else + prv->next = cur; + } + +#if defined(MBEDTLS_HAVE_TIME) + cur->timestamp = t; +#endif + } + + memcpy( &cur->session, session, sizeof( mbedtls_ssl_session ) ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * If we're reusing an entry, free its certificate first + */ + if( cur->peer_cert.p != NULL ) + { + mbedtls_free( cur->peer_cert.p ); + memset( &cur->peer_cert, 0, sizeof(mbedtls_x509_buf) ); + } + + /* + * Store peer certificate + */ + if( session->peer_cert != NULL ) + { + cur->peer_cert.p = mbedtls_calloc( 1, session->peer_cert->raw.len ); + if( cur->peer_cert.p == NULL ) + { + ret = 1; + goto exit; + } + + memcpy( cur->peer_cert.p, session->peer_cert->raw.p, + session->peer_cert->raw.len ); + cur->peer_cert.len = session->peer_cert->raw.len; + + cur->session.peer_cert = NULL; + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + ret = 0; + +exit: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &cache->mutex ) != 0 ) + ret = 1; +#endif + + return( ret ); +} + +#if defined(MBEDTLS_HAVE_TIME) +void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout ) +{ + if( timeout < 0 ) timeout = 0; + + cache->timeout = timeout; +} +#endif /* MBEDTLS_HAVE_TIME */ + +void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max ) +{ + if( max < 0 ) max = 0; + + cache->max_entries = max; +} + +void mbedtls_ssl_cache_free( mbedtls_ssl_cache_context *cache ) +{ + mbedtls_ssl_cache_entry *cur, *prv; + + cur = cache->chain; + + while( cur != NULL ) + { + prv = cur; + cur = cur->next; + + mbedtls_ssl_session_free( &prv->session ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_free( prv->peer_cert.p ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + mbedtls_free( prv ); + } + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &cache->mutex ); +#endif +} + +#endif /* MBEDTLS_SSL_CACHE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ciphersuites.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ciphersuites.c new file mode 100644 index 0000000..a762bf7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ciphersuites.c @@ -0,0 +1,1857 @@ +/** + * \file ssl_ciphersuites.c + * + * \brief SSL ciphersuites for mbed TLS + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_TLS_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#endif + +#include "mbedtls/ssl_ciphersuites.h" +#include "mbedtls/ssl.h" + +#include + +/* + * Ordered from most preferred to least preferred in terms of security. + * + * Current rule (except rc4, weak and null which come last): + * 1. By key exchange: + * Forward-secure non-PSK > forward-secure PSK > ECJPAKE > other non-PSK > other PSK + * 2. By key length and cipher: + * AES-256 > Camellia-256 > AES-128 > Camellia-128 > 3DES + * 3. By cipher mode when relevant GCM > CCM > CBC > CCM_8 + * 4. By hash function used when relevant + * 5. By key exchange/auth again: EC > non-EC + */ +static const int ciphersuite_preference[] = +{ +#if defined(MBEDTLS_SSL_CIPHERSUITES) + MBEDTLS_SSL_CIPHERSUITES, +#else + /* All AES-256 ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM, + MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8, + MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8, + + /* All CAMELLIA-256 ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, + + /* All AES-128 ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM, + MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, + MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8, + + /* All CAMELLIA-128 ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, + + /* All remaining >= 128-bit ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, + + /* The PSK ephemeral suites */ + MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM, + MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8, + + MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM, + MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8, + + MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, + + /* The ECJPAKE suite */ + MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8, + + /* All AES-256 suites */ + MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_RSA_WITH_AES_256_CCM, + MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256, + MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8, + + /* All CAMELLIA-256 suites */ + MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256, + MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, + MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, + + /* All AES-128 suites */ + MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_RSA_WITH_AES_128_CCM, + MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8, + + /* All CAMELLIA-128 suites */ + MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, + MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, + + /* All remaining >= 128-bit suites */ + MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, + + /* The RSA PSK suites */ + MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, + + MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, + + MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, + + /* The PSK suites */ + MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_PSK_WITH_AES_256_CCM, + MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384, + MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA, + MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, + MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, + + MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_PSK_WITH_AES_128_CCM, + MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256, + MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, + MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, + MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, + MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8, + + MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA, + + /* RC4 suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, + MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA, + MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA, + MBEDTLS_TLS_RSA_WITH_RC4_128_SHA, + MBEDTLS_TLS_RSA_WITH_RC4_128_MD5, + MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA, + MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA, + MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA, + MBEDTLS_TLS_PSK_WITH_RC4_128_SHA, + + /* Weak suites */ + MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA, + MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA, + + /* NULL suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA, + MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA, + MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384, + MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256, + MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384, + MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA, + + MBEDTLS_TLS_RSA_WITH_NULL_SHA256, + MBEDTLS_TLS_RSA_WITH_NULL_SHA, + MBEDTLS_TLS_RSA_WITH_NULL_MD5, + MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA, + MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA, + MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384, + MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256, + MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA, + MBEDTLS_TLS_PSK_WITH_NULL_SHA384, + MBEDTLS_TLS_PSK_WITH_NULL_SHA256, + MBEDTLS_TLS_PSK_WITH_NULL_SHA, + +#endif /* MBEDTLS_SSL_CIPHERSUITES */ + 0 +}; + +static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = +{ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_SHA1_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM, "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8, "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM, "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, "TLS-ECDHE-ECDSA-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA, "TLS-ECDHE-ECDSA-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_SHA1_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA, "TLS-ECDHE-RSA-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA, "TLS-ECDHE-RSA-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_SHA256_C) +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM, "TLS-DHE-RSA-WITH-AES-256-CCM", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8, "TLS-DHE-RSA-WITH-AES-256-CCM-8", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, + { MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM, "TLS-DHE-RSA-WITH-AES-128-CCM", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8, "TLS-DHE-RSA-WITH-AES-128-CCM-8", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384, "TLS-RSA-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_SHA256_C) +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256, "TLS-RSA-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256, "TLS-RSA-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256, "TLS-RSA-WITH-AES-256-CBC-SHA256", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA1_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA, "TLS-RSA-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA, "TLS-RSA-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_TLS_RSA_WITH_AES_256_CCM, "TLS-RSA-WITH-AES-256-CCM", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8, "TLS-RSA-WITH-AES-256-CCM-8", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, + { MBEDTLS_TLS_RSA_WITH_AES_128_CCM, "TLS-RSA-WITH-AES-128-CCM", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8, "TLS-RSA-WITH-AES-128-CCM-8", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256, "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-RSA-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_MD5_C) + { MBEDTLS_TLS_RSA_WITH_RC4_128_MD5, "TLS-RSA-WITH-RC4-128-MD5", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_MD5, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_WITH_RC4_128_SHA, "TLS-RSA-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_SHA1_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, "TLS-ECDH-RSA-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, "TLS-ECDH-RSA-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDH-RSA-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA, "TLS-ECDH-RSA-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA, "TLS-ECDH-RSA-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_SHA1_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA, "TLS-ECDH-ECDSA-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA, "TLS-ECDH-ECDSA-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256, "TLS-PSK-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384, "TLS-PSK-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256, "TLS-PSK-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384, "TLS-PSK-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, "TLS-PSK-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA, "TLS-PSK-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_TLS_PSK_WITH_AES_256_CCM, "TLS-PSK-WITH-AES-256-CCM", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, "TLS-PSK-WITH-AES-256-CCM-8", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, + { MBEDTLS_TLS_PSK_WITH_AES_128_CCM, "TLS-PSK-WITH-AES-128-CCM", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8, "TLS-PSK-WITH-AES-128-CCM-8", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-PSK-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_PSK_WITH_RC4_128_SHA, "TLS-PSK-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA, "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA, "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM, "TLS-DHE-PSK-WITH-AES-256-CCM", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8, "TLS-DHE-PSK-WITH-AES-256-CCM-8", + MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, + { MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM, "TLS-DHE-PSK-WITH-AES-128-CCM", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + { MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8, "TLS-DHE-PSK-WITH-AES-128-CCM-8", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA, "TLS-DHE-PSK-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) +#if defined(MBEDTLS_AES_C) + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA, "TLS-ECDHE-PSK-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", + MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, + + { MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", + MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_CAMELLIA_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", + MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", + MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", + MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_ARC4_C) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA, "TLS-RSA-PSK-WITH-RC4-128-SHA", + MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_NODTLS }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8, "TLS-ECJPAKE-WITH-AES-128-CCM-8", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECJPAKE, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_ENABLE_WEAK_CIPHERSUITES) +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) +#if defined(MBEDTLS_MD5_C) + { MBEDTLS_TLS_RSA_WITH_NULL_MD5, "TLS-RSA-WITH-NULL-MD5", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_MD5, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif + +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_WITH_NULL_SHA, "TLS-RSA-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif + +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_WITH_NULL_SHA256, "TLS-RSA-WITH-NULL-SHA256", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_PSK_WITH_NULL_SHA, "TLS-PSK-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ + +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_PSK_WITH_NULL_SHA256, "TLS-PSK-WITH-NULL-SHA256", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_PSK_WITH_NULL_SHA384, "TLS-PSK-WITH-NULL-SHA384", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA, "TLS-DHE-PSK-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ + +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256, "TLS-DHE-PSK-WITH-NULL-SHA256", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384, "TLS-DHE-PSK-WITH-NULL-SHA384", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA, "TLS-ECDHE-PSK-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ + +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256, "TLS-ECDHE-PSK-WITH-NULL-SHA256", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384, "TLS-ECDHE-PSK-WITH-NULL-SHA384", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA, "TLS-RSA-PSK-WITH-NULL-SHA", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ + +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256, "TLS-RSA-PSK-WITH-NULL-SHA256", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif + +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384, "TLS-RSA-PSK-WITH-NULL-SHA384", + MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ + +#if defined(MBEDTLS_DES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA, "TLS-DHE-RSA-WITH-DES-CBC-SHA", + MBEDTLS_CIPHER_DES_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) +#if defined(MBEDTLS_SHA1_C) + { MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA, "TLS-RSA-WITH-DES-CBC-SHA", + MBEDTLS_CIPHER_DES_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_WEAK }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ +#endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */ + + { 0, "", + MBEDTLS_CIPHER_NONE, MBEDTLS_MD_NONE, MBEDTLS_KEY_EXCHANGE_NONE, + 0, 0, 0, 0, 0 } +}; + +#if defined(MBEDTLS_SSL_CIPHERSUITES) +const int *mbedtls_ssl_list_ciphersuites( void ) +{ + return( ciphersuite_preference ); +} +#else +#define MAX_CIPHERSUITES sizeof( ciphersuite_definitions ) / \ + sizeof( ciphersuite_definitions[0] ) +static int supported_ciphersuites[MAX_CIPHERSUITES]; +static int supported_init = 0; + +const int *mbedtls_ssl_list_ciphersuites( void ) +{ + /* + * On initial call filter out all ciphersuites not supported by current + * build based on presence in the ciphersuite_definitions. + */ + if( supported_init == 0 ) + { + const int *p; + int *q; + + for( p = ciphersuite_preference, q = supported_ciphersuites; + *p != 0 && q < supported_ciphersuites + MAX_CIPHERSUITES - 1; + p++ ) + { +#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES) + const mbedtls_ssl_ciphersuite_t *cs_info; + if( ( cs_info = mbedtls_ssl_ciphersuite_from_id( *p ) ) != NULL && + cs_info->cipher != MBEDTLS_CIPHER_ARC4_128 ) +#else + if( mbedtls_ssl_ciphersuite_from_id( *p ) != NULL ) +#endif + *(q++) = *p; + } + *q = 0; + + supported_init = 1; + } + + return( supported_ciphersuites ); +} +#endif /* MBEDTLS_SSL_CIPHERSUITES */ + +const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string( + const char *ciphersuite_name ) +{ + const mbedtls_ssl_ciphersuite_t *cur = ciphersuite_definitions; + + if( NULL == ciphersuite_name ) + return( NULL ); + + while( cur->id != 0 ) + { + if( 0 == strcmp( cur->name, ciphersuite_name ) ) + return( cur ); + + cur++; + } + + return( NULL ); +} + +const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuite ) +{ + const mbedtls_ssl_ciphersuite_t *cur = ciphersuite_definitions; + + while( cur->id != 0 ) + { + if( cur->id == ciphersuite ) + return( cur ); + + cur++; + } + + return( NULL ); +} + +const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id ) +{ + const mbedtls_ssl_ciphersuite_t *cur; + + cur = mbedtls_ssl_ciphersuite_from_id( ciphersuite_id ); + + if( cur == NULL ) + return( "unknown" ); + + return( cur->name ); +} + +int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name ) +{ + const mbedtls_ssl_ciphersuite_t *cur; + + cur = mbedtls_ssl_ciphersuite_from_string( ciphersuite_name ); + + if( cur == NULL ) + return( 0 ); + + return( cur->id ); +} + +#if defined(MBEDTLS_PK_C) +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_RSA: + case MBEDTLS_KEY_EXCHANGE_DHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_RSA_PSK: + return( MBEDTLS_PK_RSA ); + + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + return( MBEDTLS_PK_ECDSA ); + + case MBEDTLS_KEY_EXCHANGE_ECDH_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA: + return( MBEDTLS_PK_ECKEY ); + + default: + return( MBEDTLS_PK_NONE ); + } +} +#endif /* MBEDTLS_PK_C */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) +int mbedtls_ssl_ciphersuite_uses_ec( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: + case MBEDTLS_KEY_EXCHANGE_ECDH_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +int mbedtls_ssl_ciphersuite_uses_psk( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_PSK: + case MBEDTLS_KEY_EXCHANGE_RSA_PSK: + case MBEDTLS_KEY_EXCHANGE_DHE_PSK: + case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#endif /* MBEDTLS_SSL_TLS_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cli.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cli.c new file mode 100644 index 0000000..223823b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cli.c @@ -0,0 +1,3405 @@ +/* + * SSLv3/TLSv1 client-side functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_CLI_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_internal.h" + +#include + +#include + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} +#endif + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +static void ssl_write_hostname_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t hostname_len; + + *olen = 0; + + if( ssl->hostname == NULL ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding server name extension: %s", + ssl->hostname ) ); + + hostname_len = strlen( ssl->hostname ); + + if( end < p || (size_t)( end - p ) < hostname_len + 9 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + /* + * struct { + * NameType name_type; + * select (name_type) { + * case host_name: HostName; + * } name; + * } ServerName; + * + * enum { + * host_name(0), (255) + * } NameType; + * + * opaque HostName<1..2^16-1>; + * + * struct { + * ServerName server_name_list<1..2^16-1> + * } ServerNameList; + */ + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME ) & 0xFF ); + + *p++ = (unsigned char)( ( (hostname_len + 5) >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( (hostname_len + 5) ) & 0xFF ); + + *p++ = (unsigned char)( ( (hostname_len + 3) >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( (hostname_len + 3) ) & 0xFF ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ) & 0xFF ); + *p++ = (unsigned char)( ( hostname_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( hostname_len ) & 0xFF ); + + memcpy( p, ssl->hostname, hostname_len ); + + *olen = hostname_len + 9; +} +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + *olen = 0; + + if( ssl->renego_status != MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding renegotiation extension" ) ); + + if( end < p || (size_t)( end - p ) < 5 + ssl->verify_data_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + /* + * Secure renegotiation + */ + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ) & 0xFF ); + + *p++ = 0x00; + *p++ = ( ssl->verify_data_len + 1 ) & 0xFF; + *p++ = ssl->verify_data_len & 0xFF; + + memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); + + *olen = 5 + ssl->verify_data_len; +} +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +/* + * Only if we handle at least one key exchange that needs signatures. + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +static void ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t sig_alg_len = 0; + const int *md; +#if defined(MBEDTLS_RSA_C) || defined(MBEDTLS_ECDSA_C) + unsigned char *sig_alg_list = buf + 6; +#endif + + *olen = 0; + + if( ssl->conf->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding signature_algorithms extension" ) ); + + for( md = ssl->conf->sig_hashes; *md != MBEDTLS_MD_NONE; md++ ) + { +#if defined(MBEDTLS_ECDSA_C) + sig_alg_len += 2; +#endif +#if defined(MBEDTLS_RSA_C) + sig_alg_len += 2; +#endif + } + + if( end < p || (size_t)( end - p ) < sig_alg_len + 6 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + /* + * Prepare signature_algorithms extension (TLS 1.2) + */ + sig_alg_len = 0; + + for( md = ssl->conf->sig_hashes; *md != MBEDTLS_MD_NONE; md++ ) + { +#if defined(MBEDTLS_ECDSA_C) + sig_alg_list[sig_alg_len++] = mbedtls_ssl_hash_from_md_alg( *md ); + sig_alg_list[sig_alg_len++] = MBEDTLS_SSL_SIG_ECDSA; +#endif +#if defined(MBEDTLS_RSA_C) + sig_alg_list[sig_alg_len++] = mbedtls_ssl_hash_from_md_alg( *md ); + sig_alg_list[sig_alg_len++] = MBEDTLS_SSL_SIG_RSA; +#endif + } + + /* + * enum { + * none(0), md5(1), sha1(2), sha224(3), sha256(4), sha384(5), + * sha512(6), (255) + * } HashAlgorithm; + * + * enum { anonymous(0), rsa(1), dsa(2), ecdsa(3), (255) } + * SignatureAlgorithm; + * + * struct { + * HashAlgorithm hash; + * SignatureAlgorithm signature; + * } SignatureAndHashAlgorithm; + * + * SignatureAndHashAlgorithm + * supported_signature_algorithms<2..2^16-2>; + */ + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SIG_ALG >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SIG_ALG ) & 0xFF ); + + *p++ = (unsigned char)( ( ( sig_alg_len + 2 ) >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( ( sig_alg_len + 2 ) ) & 0xFF ); + + *p++ = (unsigned char)( ( sig_alg_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( sig_alg_len ) & 0xFF ); + + *olen = 6 + sig_alg_len; +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static void ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + unsigned char *elliptic_curve_list = p + 6; + size_t elliptic_curve_len = 0; + const mbedtls_ecp_curve_info *info; +#if defined(MBEDTLS_ECP_C) + const mbedtls_ecp_group_id *grp_id; +#else + ((void) ssl); +#endif + + *olen = 0; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_elliptic_curves extension" ) ); + +#if defined(MBEDTLS_ECP_C) + for( grp_id = ssl->conf->curve_list; *grp_id != MBEDTLS_ECP_DP_NONE; grp_id++ ) + { + info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); +#else + for( info = mbedtls_ecp_curve_list(); info->grp_id != MBEDTLS_ECP_DP_NONE; info++ ) + { +#endif + if( info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid curve in ssl configuration" ) ); + return; + } + + elliptic_curve_len += 2; + } + + if( end < p || (size_t)( end - p ) < 6 + elliptic_curve_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + elliptic_curve_len = 0; + +#if defined(MBEDTLS_ECP_C) + for( grp_id = ssl->conf->curve_list; *grp_id != MBEDTLS_ECP_DP_NONE; grp_id++ ) + { + info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); +#else + for( info = mbedtls_ecp_curve_list(); info->grp_id != MBEDTLS_ECP_DP_NONE; info++ ) + { +#endif + elliptic_curve_list[elliptic_curve_len++] = info->tls_id >> 8; + elliptic_curve_list[elliptic_curve_len++] = info->tls_id & 0xFF; + } + + if( elliptic_curve_len == 0 ) + return; + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ) & 0xFF ); + + *p++ = (unsigned char)( ( ( elliptic_curve_len + 2 ) >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( ( elliptic_curve_len + 2 ) ) & 0xFF ); + + *p++ = (unsigned char)( ( ( elliptic_curve_len ) >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( ( elliptic_curve_len ) ) & 0xFF ); + + *olen = 6 + elliptic_curve_len; +} + +static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + *olen = 0; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_point_formats extension" ) ); + + if( end < p || (size_t)( end - p ) < 6 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ) & 0xFF ); + + *p++ = 0x00; + *p++ = 2; + + *p++ = 1; + *p++ = MBEDTLS_ECP_PF_UNCOMPRESSED; + + *olen = 6; +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + int ret; + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t kkpp_len; + + *olen = 0; + + /* Skip costly extension if we can't use EC J-PAKE anyway */ + if( mbedtls_ecjpake_check( &ssl->handshake->ecjpake_ctx ) != 0 ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding ecjpake_kkpp extension" ) ); + + if( end - p < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ) & 0xFF ); + + /* + * We may need to send ClientHello multiple times for Hello verification. + * We don't want to compute fresh values every time (both for performance + * and consistency reasons), so cache the extension content. + */ + if( ssl->handshake->ecjpake_cache == NULL || + ssl->handshake->ecjpake_cache_len == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "generating new ecjpake parameters" ) ); + + ret = mbedtls_ecjpake_write_round_one( &ssl->handshake->ecjpake_ctx, + p + 2, end - p - 2, &kkpp_len, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1 , "mbedtls_ecjpake_write_round_one", ret ); + return; + } + + ssl->handshake->ecjpake_cache = mbedtls_calloc( 1, kkpp_len ); + if( ssl->handshake->ecjpake_cache == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "allocation failed" ) ); + return; + } + + memcpy( ssl->handshake->ecjpake_cache, p + 2, kkpp_len ); + ssl->handshake->ecjpake_cache_len = kkpp_len; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "re-using cached ecjpake parameters" ) ); + + kkpp_len = ssl->handshake->ecjpake_cache_len; + + if( (size_t)( end - p - 2 ) < kkpp_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + memcpy( p + 2, ssl->handshake->ecjpake_cache, kkpp_len ); + } + + *p++ = (unsigned char)( ( kkpp_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( kkpp_len ) & 0xFF ); + + *olen = kkpp_len + 4; +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + *olen = 0; + + if( ssl->conf->mfl_code == MBEDTLS_SSL_MAX_FRAG_LEN_NONE ) { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding max_fragment_length extension" ) ); + + if( end < p || (size_t)( end - p ) < 5 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ) & 0xFF ); + + *p++ = 0x00; + *p++ = 1; + + *p++ = ssl->conf->mfl_code; + + *olen = 5; +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +static void ssl_write_truncated_hmac_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + *olen = 0; + + if( ssl->conf->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_DISABLED ) + { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding truncated_hmac extension" ) ); + + if( end < p || (size_t)( end - p ) < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_TRUNCATED_HMAC >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_TRUNCATED_HMAC ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + *olen = 0; + + if( ssl->conf->encrypt_then_mac == MBEDTLS_SSL_ETM_DISABLED || + ssl->conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding encrypt_then_mac " + "extension" ) ); + + if( end < p || (size_t)( end - p ) < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + *olen = 0; + + if( ssl->conf->extended_ms == MBEDTLS_SSL_EXTENDED_MS_DISABLED || + ssl->conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding extended_master_secret " + "extension" ) ); + + if( end < p || (size_t)( end - p ) < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t tlen = ssl->session_negotiate->ticket_len; + + *olen = 0; + + if( ssl->conf->session_tickets == MBEDTLS_SSL_SESSION_TICKETS_DISABLED ) + { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding session ticket extension" ) ); + + if( end < p || (size_t)( end - p ) < 4 + tlen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET ) & 0xFF ); + + *p++ = (unsigned char)( ( tlen >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( tlen ) & 0xFF ); + + *olen = 4; + + if( ssl->session_negotiate->ticket == NULL || tlen == 0 ) + { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "sending session ticket of length %d", tlen ) ); + + memcpy( p, ssl->session_negotiate->ticket, tlen ); + + *olen += tlen; +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) +static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t alpnlen = 0; + const char **cur; + + *olen = 0; + + if( ssl->conf->alpn_list == NULL ) + { + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding alpn extension" ) ); + + for( cur = ssl->conf->alpn_list; *cur != NULL; cur++ ) + alpnlen += (unsigned char)( strlen( *cur ) & 0xFF ) + 1; + + if( end < p || (size_t)( end - p ) < 6 + alpnlen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN ) & 0xFF ); + + /* + * opaque ProtocolName<1..2^8-1>; + * + * struct { + * ProtocolName protocol_name_list<2..2^16-1> + * } ProtocolNameList; + */ + + /* Skip writing extension and list length for now */ + p += 4; + + for( cur = ssl->conf->alpn_list; *cur != NULL; cur++ ) + { + *p = (unsigned char)( strlen( *cur ) & 0xFF ); + memcpy( p + 1, *cur, *p ); + p += 1 + *p; + } + + *olen = p - buf; + + /* List length = olen - 2 (ext_type) - 2 (ext_len) - 2 (list_len) */ + buf[4] = (unsigned char)( ( ( *olen - 6 ) >> 8 ) & 0xFF ); + buf[5] = (unsigned char)( ( ( *olen - 6 ) ) & 0xFF ); + + /* Extension length = olen - 2 (ext_type) - 2 (ext_len) */ + buf[2] = (unsigned char)( ( ( *olen - 4 ) >> 8 ) & 0xFF ); + buf[3] = (unsigned char)( ( ( *olen - 4 ) ) & 0xFF ); +} +#endif /* MBEDTLS_SSL_ALPN */ + +/* + * Generate random bytes for ClientHello + */ +static int ssl_generate_random( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *p = ssl->handshake->randbytes; +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t t; +#endif + + /* + * When responding to a verify request, MUST reuse random (RFC 6347 4.2.1) + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->verify_cookie != NULL ) + { + return( 0 ); + } +#endif + +#if defined(MBEDTLS_HAVE_TIME) + t = mbedtls_time( NULL ); + *p++ = (unsigned char)( t >> 24 ); + *p++ = (unsigned char)( t >> 16 ); + *p++ = (unsigned char)( t >> 8 ); + *p++ = (unsigned char)( t ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, current time: %lu", t ) ); +#else + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 ) + return( ret ); + + p += 4; +#endif /* MBEDTLS_HAVE_TIME */ + + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t i, n, olen, ext_len = 0; + unsigned char *buf; + unsigned char *p, *q; + unsigned char offer_compress; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); + + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided") ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + ssl->major_ver = ssl->conf->min_major_ver; + ssl->minor_ver = ssl->conf->min_minor_ver; + } + + if( ssl->conf->max_major_ver == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "configured max major version is invalid, " + "consider using mbedtls_ssl_config_defaults()" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + /* + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 highest version supported + * 6 . 9 current UNIX time + * 10 . 37 random bytes + */ + buf = ssl->out_msg; + p = buf + 4; + + mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, + ssl->conf->transport, p ); + p += 2; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, max version: [%d:%d]", + buf[4], buf[5] ) ); + + if( ( ret = ssl_generate_random( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); + return( ret ); + } + + memcpy( p, ssl->handshake->randbytes, 32 ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", p, 32 ); + p += 32; + + /* + * 38 . 38 session id length + * 39 . 39+n session id + * 39+n . 39+n DTLS only: cookie length (1 byte) + * 40+n . .. DTSL only: cookie + * .. . .. ciphersuitelist length (2 bytes) + * .. . .. ciphersuitelist + * .. . .. compression methods length (1 byte) + * .. . .. compression methods + * .. . .. extensions length (2 bytes) + * .. . .. extensions + */ + n = ssl->session_negotiate->id_len; + + if( n < 16 || n > 32 || +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE || +#endif + ssl->handshake->resume == 0 ) + { + n = 0; + } + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + /* + * RFC 5077 section 3.4: "When presenting a ticket, the client MAY + * generate and include a Session ID in the TLS ClientHello." + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + if( ssl->session_negotiate->ticket != NULL && + ssl->session_negotiate->ticket_len != 0 ) + { + ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id, 32 ); + + if( ret != 0 ) + return( ret ); + + ssl->session_negotiate->id_len = n = 32; + } + } +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + + *p++ = (unsigned char) n; + + for( i = 0; i < n; i++ ) + *p++ = ssl->session_negotiate->id[i]; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, session id len.: %d", n ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", buf + 39, n ); + + /* + * DTLS cookie + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + if( ssl->handshake->verify_cookie == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "no verify cookie to send" ) ); + *p++ = 0; + } + else + { + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, cookie", + ssl->handshake->verify_cookie, + ssl->handshake->verify_cookie_len ); + + *p++ = ssl->handshake->verify_cookie_len; + memcpy( p, ssl->handshake->verify_cookie, + ssl->handshake->verify_cookie_len ); + p += ssl->handshake->verify_cookie_len; + } + } +#endif + + /* + * Ciphersuite list + */ + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + + /* Skip writing ciphersuite length for now */ + n = 0; + q = p; + p += 2; + + for( i = 0; ciphersuites[i] != 0; i++ ) + { + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); + + if( ciphersuite_info == NULL ) + continue; + + if( ciphersuite_info->min_minor_ver > ssl->conf->max_minor_ver || + ciphersuite_info->max_minor_ver < ssl->conf->min_minor_ver ) + continue; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( ciphersuite_info->flags & MBEDTLS_CIPHERSUITE_NODTLS ) ) + continue; +#endif + +#if defined(MBEDTLS_ARC4_C) + if( ssl->conf->arc4_disabled == MBEDTLS_SSL_ARC4_DISABLED && + ciphersuite_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) + continue; +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE && + mbedtls_ecjpake_check( &ssl->handshake->ecjpake_ctx ) != 0 ) + continue; +#endif + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x", + ciphersuites[i] ) ); + + n++; + *p++ = (unsigned char)( ciphersuites[i] >> 8 ); + *p++ = (unsigned char)( ciphersuites[i] ); + } + + /* + * Add TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + *p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO >> 8 ); + *p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ); + n++; + } + + /* Some versions of OpenSSL don't handle it correctly if not at end */ +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + if( ssl->conf->fallback == MBEDTLS_SSL_IS_FALLBACK ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding FALLBACK_SCSV" ) ); + *p++ = (unsigned char)( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ); + *p++ = (unsigned char)( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ); + n++; + } +#endif + + *q++ = (unsigned char)( n >> 7 ); + *q++ = (unsigned char)( n << 1 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %d ciphersuites", n ) ); + +#if defined(MBEDTLS_ZLIB_SUPPORT) + offer_compress = 1; +#else + offer_compress = 0; +#endif + + /* + * We don't support compression with DTLS right now: is many records come + * in the same datagram, uncompressing one could overwrite the next one. + * We don't want to add complexity for handling that case unless there is + * an actual need for it. + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + offer_compress = 0; +#endif + + if( offer_compress ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, compress len.: %d", 2 ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, compress alg.: %d %d", + MBEDTLS_SSL_COMPRESS_DEFLATE, MBEDTLS_SSL_COMPRESS_NULL ) ); + + *p++ = 2; + *p++ = MBEDTLS_SSL_COMPRESS_DEFLATE; + *p++ = MBEDTLS_SSL_COMPRESS_NULL; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, compress len.: %d", 1 ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, compress alg.: %d", + MBEDTLS_SSL_COMPRESS_NULL ) ); + + *p++ = 1; + *p++ = MBEDTLS_SSL_COMPRESS_NULL; + } + + // First write extensions, then the total length + // +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + ssl_write_hostname_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + ssl_write_signature_algorithms_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl_write_supported_elliptic_curves_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; + + ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl_write_ecjpake_kkpp_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + ssl_write_max_fragment_length_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + ssl_write_truncated_hmac_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + ssl_write_encrypt_then_mac_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + ssl_write_extended_ms_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_ALPN) + ssl_write_alpn_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + ssl_write_session_ticket_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + + /* olen unused if all extensions are disabled */ + ((void) olen); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %d", + ext_len ) ); + + if( ext_len > 0 ) + { + *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + p += ext_len; + } + + ssl->out_msglen = p - buf; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_CLIENT_HELLO; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_send_flight_completed( ssl ); +#endif + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); + + return( 0 ); +} + +static int ssl_parse_renegotiation_info( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Check verify-data in constant-time. The length OTOH is no secret */ + if( len != 1 + ssl->verify_data_len * 2 || + buf[0] != ssl->verify_data_len * 2 || + mbedtls_ssl_safer_memcmp( buf + 1, + ssl->own_verify_data, ssl->verify_data_len ) != 0 || + mbedtls_ssl_safer_memcmp( buf + 1 + ssl->verify_data_len, + ssl->peer_verify_data, ssl->verify_data_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching renegotiation info" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + } + else +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + { + if( len != 1 || buf[0] != 0x00 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-zero length renegotiation info" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + } + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +static int ssl_parse_max_fragment_length_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + /* + * server should use the extension only if we did, + * and if so the server's value should match ours (and len is always 1) + */ + if( ssl->conf->mfl_code == MBEDTLS_SSL_MAX_FRAG_LEN_NONE || + len != 1 || + buf[0] != ssl->conf->mfl_code ) + { + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +static int ssl_parse_truncated_hmac_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( ssl->conf->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_DISABLED || + len != 0 ) + { + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + ((void) buf); + + ssl->session_negotiate->trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_ENABLED; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +static int ssl_parse_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( ssl->conf->encrypt_then_mac == MBEDTLS_SSL_ETM_DISABLED || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 || + len != 0 ) + { + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + ((void) buf); + + ssl->session_negotiate->encrypt_then_mac = MBEDTLS_SSL_ETM_ENABLED; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +static int ssl_parse_extended_ms_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( ssl->conf->extended_ms == MBEDTLS_SSL_EXTENDED_MS_DISABLED || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 || + len != 0 ) + { + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + ((void) buf); + + ssl->handshake->extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( ssl->conf->session_tickets == MBEDTLS_SSL_SESSION_TICKETS_DISABLED || + len != 0 ) + { + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + ((void) buf); + + ssl->handshake->new_session_ticket = 1; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t list_size; + const unsigned char *p; + + list_size = buf[0]; + if( list_size + 1 != len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + p = buf + 1; + while( list_size > 0 ) + { + if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED || + p[0] == MBEDTLS_ECP_PF_COMPRESSED ) + { +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) + ssl->handshake->ecdh_ctx.point_format = p[0]; +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl->handshake->ecjpake_ctx.point_format = p[0]; +#endif + MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) ); + return( 0 ); + } + + list_size--; + p++; + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no point format in common" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + + if( ssl->transform_negotiate->ciphersuite_info->key_exchange != + MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip ecjpake kkpp extension" ) ); + return( 0 ); + } + + /* If we got here, we no longer need our cached extension */ + mbedtls_free( ssl->handshake->ecjpake_cache ); + ssl->handshake->ecjpake_cache = NULL; + ssl->handshake->ecjpake_cache_len = 0; + + if( ( ret = mbedtls_ecjpake_read_round_one( &ssl->handshake->ecjpake_ctx, + buf, len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_one", ret ); + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN) +static int ssl_parse_alpn_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + size_t list_len, name_len; + const char **p; + + /* If we didn't send it, the server shouldn't send it */ + if( ssl->conf->alpn_list == NULL ) + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + + /* + * opaque ProtocolName<1..2^8-1>; + * + * struct { + * ProtocolName protocol_name_list<2..2^16-1> + * } ProtocolNameList; + * + * the "ProtocolNameList" MUST contain exactly one "ProtocolName" + */ + + /* Min length is 2 (list_len) + 1 (name_len) + 1 (name) */ + if( len < 4 ) + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + + list_len = ( buf[0] << 8 ) | buf[1]; + if( list_len != len - 2 ) + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + + name_len = buf[2]; + if( name_len != list_len - 1 ) + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + + /* Check that the server chosen protocol was in our list and save it */ + for( p = ssl->conf->alpn_list; *p != NULL; p++ ) + { + if( name_len == strlen( *p ) && + memcmp( buf + 3, *p, name_len ) == 0 ) + { + ssl->alpn_chosen = *p; + return( 0 ); + } + } + + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); +} +#endif /* MBEDTLS_SSL_ALPN */ + +/* + * Parse HelloVerifyRequest. Only called after verifying the HS type. + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) +static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl ) +{ + const unsigned char *p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); + int major_ver, minor_ver; + unsigned char cookie_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) ); + + /* + * struct { + * ProtocolVersion server_version; + * opaque cookie<0..2^8-1>; + * } HelloVerifyRequest; + */ + MBEDTLS_SSL_DEBUG_BUF( 3, "server version", p, 2 ); + mbedtls_ssl_read_version( &major_ver, &minor_ver, ssl->conf->transport, p ); + p += 2; + + /* + * Since the RFC is not clear on this point, accept DTLS 1.0 (TLS 1.1) + * even is lower than our min version. + */ + if( major_ver < MBEDTLS_SSL_MAJOR_VERSION_3 || + minor_ver < MBEDTLS_SSL_MINOR_VERSION_2 || + major_ver > ssl->conf->max_major_ver || + minor_ver > ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server version" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + cookie_len = *p++; + MBEDTLS_SSL_DEBUG_BUF( 3, "cookie", p, cookie_len ); + + if( ( ssl->in_msg + ssl->in_msglen ) - p < cookie_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, + ( "cookie length does not match incoming message size" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + mbedtls_free( ssl->handshake->verify_cookie ); + + ssl->handshake->verify_cookie = mbedtls_calloc( 1, cookie_len ); + if( ssl->handshake->verify_cookie == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", cookie_len ) ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + memcpy( ssl->handshake->verify_cookie, p, cookie_len ); + ssl->handshake->verify_cookie_len = cookie_len; + + /* Start over at ClientHello */ + ssl->state = MBEDTLS_SSL_CLIENT_HELLO; + mbedtls_ssl_reset_checksum( ssl ); + + mbedtls_ssl_recv_flight_completed( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse hello verify request" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) +{ + int ret, i; + size_t n; + size_t ext_len; + unsigned char *buf, *ext; + unsigned char comp; +#if defined(MBEDTLS_ZLIB_SUPPORT) + int accept_comp; +#endif +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renegotiation_info_seen = 0; +#endif + int handshake_failure = 0; + const mbedtls_ssl_ciphersuite_t *suite_info; +#if defined(MBEDTLS_DEBUG_C) + uint32_t t; +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello" ) ); + + buf = ssl->in_msg; + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + ssl->renego_records_seen++; + + if( ssl->conf->renego_max_records >= 0 && + ssl->renego_records_seen > ssl->conf->renego_max_records ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation requested, " + "but not honored by server" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-handshake message during renego" ) ); + return( MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + if( buf[0] == MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received hello verify request" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server hello" ) ); + return( ssl_parse_hello_verify_request( ssl ) ); + } + else + { + /* We made it through the verification process */ + mbedtls_free( ssl->handshake->verify_cookie ); + ssl->handshake->verify_cookie = NULL; + ssl->handshake->verify_cookie_len = 0; + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + if( ssl->in_hslen < 38 + mbedtls_ssl_hs_hdr_len( ssl ) || + buf[0] != MBEDTLS_SSL_HS_SERVER_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + /* + * 0 . 1 server_version + * 2 . 33 random (maybe including 4 bytes of Unix time) + * 34 . 34 session_id length = n + * 35 . 34+n session_id + * 35+n . 36+n cipher_suite + * 37+n . 37+n compression_method + * + * 38+n . 39+n extensions length (optional) + * 40+n . .. extensions + */ + buf += mbedtls_ssl_hs_hdr_len( ssl ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, version", buf + 0, 2 ); + mbedtls_ssl_read_version( &ssl->major_ver, &ssl->minor_ver, + ssl->conf->transport, buf + 0 ); + + if( ssl->major_ver < ssl->conf->min_major_ver || + ssl->minor_ver < ssl->conf->min_minor_ver || + ssl->major_ver > ssl->conf->max_major_ver || + ssl->minor_ver > ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server version out of bounds - " + " min: [%d:%d], server: [%d:%d], max: [%d:%d]", + ssl->conf->min_major_ver, ssl->conf->min_minor_ver, + ssl->major_ver, ssl->minor_ver, + ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + +#if defined(MBEDTLS_DEBUG_C) + t = ( (uint32_t) buf[2] << 24 ) + | ( (uint32_t) buf[3] << 16 ) + | ( (uint32_t) buf[4] << 8 ) + | ( (uint32_t) buf[5] ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) ); +#endif + + memcpy( ssl->handshake->randbytes + 32, buf + 2, 32 ); + + n = buf[34]; + + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 2, 32 ); + + if( n > 32 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + if( ssl->in_hslen > mbedtls_ssl_hs_hdr_len( ssl ) + 39 + n ) + { + ext_len = ( ( buf[38 + n] << 8 ) + | ( buf[39 + n] ) ); + + if( ( ext_len > 0 && ext_len < 4 ) || + ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + 40 + n + ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + } + else if( ssl->in_hslen == mbedtls_ssl_hs_hdr_len( ssl ) + 38 + n ) + { + ext_len = 0; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + /* ciphersuite (used later) */ + i = ( buf[35 + n] << 8 ) | buf[36 + n]; + + /* + * Read and check compression + */ + comp = buf[37 + n]; + +#if defined(MBEDTLS_ZLIB_SUPPORT) + /* See comments in ssl_write_client_hello() */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + accept_comp = 0; + else +#endif + accept_comp = 1; + + if( comp != MBEDTLS_SSL_COMPRESS_NULL && + ( comp != MBEDTLS_SSL_COMPRESS_DEFLATE || accept_comp == 0 ) ) +#else /* MBEDTLS_ZLIB_SUPPORT */ + if( comp != MBEDTLS_SSL_COMPRESS_NULL ) +#endif/* MBEDTLS_ZLIB_SUPPORT */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server hello, bad compression: %d", comp ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + + /* + * Initialize update checksum functions + */ + ssl->transform_negotiate->ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( i ); + + if( ssl->transform_negotiate->ciphersuite_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %04x not found", i ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + mbedtls_ssl_optimize_checksum( ssl, ssl->transform_negotiate->ciphersuite_info ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 35, n ); + + /* + * Check if the session can be resumed + */ + if( ssl->handshake->resume == 0 || n == 0 || +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE || +#endif + ssl->session_negotiate->ciphersuite != i || + ssl->session_negotiate->compression != comp || + ssl->session_negotiate->id_len != n || + memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 ) + { + ssl->state++; + ssl->handshake->resume = 0; +#if defined(MBEDTLS_HAVE_TIME) + ssl->session_negotiate->start = mbedtls_time( NULL ); +#endif + ssl->session_negotiate->ciphersuite = i; + ssl->session_negotiate->compression = comp; + ssl->session_negotiate->id_len = n; + memcpy( ssl->session_negotiate->id, buf + 35, n ); + } + else + { + ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", + ssl->handshake->resume ? "a" : "no" ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %04x", i ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: %d", buf[37 + n] ) ); + + suite_info = mbedtls_ssl_ciphersuite_from_id( ssl->session_negotiate->ciphersuite ); + if( suite_info == NULL +#if defined(MBEDTLS_ARC4_C) + || ( ssl->conf->arc4_disabled && + suite_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) +#endif + ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", suite_info->name ) ); + + i = 0; + while( 1 ) + { + if( ssl->conf->ciphersuite_list[ssl->minor_ver][i] == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + if( ssl->conf->ciphersuite_list[ssl->minor_ver][i++] == + ssl->session_negotiate->ciphersuite ) + { + break; + } + } + + if( comp != MBEDTLS_SSL_COMPRESS_NULL +#if defined(MBEDTLS_ZLIB_SUPPORT) + && comp != MBEDTLS_SSL_COMPRESS_DEFLATE +#endif + ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + ssl->session_negotiate->compression = comp; + + ext = buf + 40 + n; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "server hello, total extension length: %d", ext_len ) ); + + while( ext_len ) + { + unsigned int ext_id = ( ( ext[0] << 8 ) + | ( ext[1] ) ); + unsigned int ext_size = ( ( ext[2] << 8 ) + | ( ext[3] ) ); + + if( ext_size + 4 > ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + switch( ext_id ) + { + case MBEDTLS_TLS_EXT_RENEGOTIATION_INFO: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found renegotiation extension" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + renegotiation_info_seen = 1; +#endif + + if( ( ret = ssl_parse_renegotiation_info( ssl, ext + 4, + ext_size ) ) != 0 ) + return( ret ); + + break; + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + case MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found max_fragment_length extension" ) ); + + if( ( ret = ssl_parse_max_fragment_length_ext( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + case MBEDTLS_TLS_EXT_TRUNCATED_HMAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found truncated_hmac extension" ) ); + + if( ( ret = ssl_parse_truncated_hmac_ext( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + case MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found encrypt_then_mac extension" ) ); + + if( ( ret = ssl_parse_encrypt_then_mac_ext( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + case MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found extended_master_secret extension" ) ); + + if( ( ret = ssl_parse_extended_ms_ext( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + case MBEDTLS_TLS_EXT_SESSION_TICKET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found session_ticket extension" ) ); + + if( ( ret = ssl_parse_session_ticket_ext( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported_point_formats extension" ) ); + + if( ( ret = ssl_parse_supported_point_formats_ext( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_ECJPAKE_KKPP: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found ecjpake_kkpp extension" ) ); + + if( ( ret = ssl_parse_ecjpake_kkpp( ssl, + ext + 4, ext_size ) ) != 0 ) + { + return( ret ); + } + + break; +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN) + case MBEDTLS_TLS_EXT_ALPN: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found alpn extension" ) ); + + if( ( ret = ssl_parse_alpn_ext( ssl, ext + 4, ext_size ) ) != 0 ) + return( ret ); + + break; +#endif /* MBEDTLS_SSL_ALPN */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "unknown extension found: %d (ignoring)", + ext_id ) ); + } + + ext_len -= 4 + ext_size; + ext += 4 + ext_size; + + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + } + + /* + * Renegotiation security checks + */ + if( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) ); + handshake_failure = 1; + } +#if defined(MBEDTLS_SSL_RENEGOTIATION) + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION && + renegotiation_info_seen == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension missing (secure)" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation not allowed" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + renegotiation_info_seen == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension present (legacy)" ) ); + handshake_failure = 1; + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + if( handshake_failure == 1 ) + { + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server hello" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl, unsigned char **p, + unsigned char *end ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + + /* + * Ephemeral DH parameters: + * + * struct { + * opaque dh_p<1..2^16-1>; + * opaque dh_g<1..2^16-1>; + * opaque dh_Ys<1..2^16-1>; + * } ServerDHParams; + */ + if( ( ret = mbedtls_dhm_read_params( &ssl->handshake->dhm_ctx, p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 2, ( "mbedtls_dhm_read_params" ), ret ); + return( ret ); + } + + if( ssl->handshake->dhm_ctx.len * 8 < ssl->conf->dhm_min_bitlen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "DHM prime too short: %d < %d", + ssl->handshake->dhm_ctx.len * 8, + ssl->conf->dhm_min_bitlen ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: P ", &ssl->handshake->dhm_ctx.P ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: G ", &ssl->handshake->dhm_ctx.G ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GY", &ssl->handshake->dhm_ctx.GY ); + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +static int ssl_check_server_ecdh_params( const mbedtls_ssl_context *ssl ) +{ + const mbedtls_ecp_curve_info *curve_info; + + curve_info = mbedtls_ecp_curve_info_from_grp_id( ssl->handshake->ecdh_ctx.grp.id ); + if( curve_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) ); + +#if defined(MBEDTLS_ECP_C) + if( mbedtls_ssl_check_curve( ssl, ssl->handshake->ecdh_ctx.grp.id ) != 0 ) +#else + if( ssl->handshake->ecdh_ctx.grp.nbits < 163 || + ssl->handshake->ecdh_ctx.grp.nbits > 521 ) +#endif + return( -1 ); + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp", &ssl->handshake->ecdh_ctx.Qp ); + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) +static int ssl_parse_server_ecdh_params( mbedtls_ssl_context *ssl, + unsigned char **p, + unsigned char *end ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + + /* + * Ephemeral ECDH parameters: + * + * struct { + * ECParameters curve_params; + * ECPoint public; + * } ServerECDHParams; + */ + if( ( ret = mbedtls_ecdh_read_params( &ssl->handshake->ecdh_ctx, + (const unsigned char **) p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_read_params" ), ret ); + return( ret ); + } + + if( ssl_check_server_ecdh_params( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message (ECDHE curve)" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl, + unsigned char **p, + unsigned char *end ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t len; + ((void) ssl); + + /* + * PSK parameters: + * + * opaque psk_identity_hint<0..2^16-1>; + */ + len = (*p)[0] << 8 | (*p)[1]; + *p += 2; + + if( (*p) + len > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message (psk_identity_hint length)" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + /* + * Note: we currently ignore the PKS identity hint, as we only allow one + * PSK to be provisionned on the client. This could be changed later if + * someone needs that feature. + */ + *p += len; + ret = 0; + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) +/* + * Generate a pre-master secret and encrypt it with the server's RSA key + */ +static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl, + size_t offset, size_t *olen, + size_t pms_offset ) +{ + int ret; + size_t len_bytes = ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ? 0 : 2; + unsigned char *p = ssl->handshake->premaster + pms_offset; + + if( offset + len_bytes > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small for encrypted pms" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + /* + * Generate (part of) the pre-master as + * struct { + * ProtocolVersion client_version; + * opaque random[46]; + * } PreMasterSecret; + */ + mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, + ssl->conf->transport, p ); + + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p + 2, 46 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "f_rng", ret ); + return( ret ); + } + + ssl->handshake->pmslen = 48; + + if( ssl->session_negotiate->peer_cert == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "certificate required" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + /* + * Now write it out, encrypted + */ + if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, + MBEDTLS_PK_RSA ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "certificate key type mismatch" ) ); + return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH ); + } + + if( ( ret = mbedtls_pk_encrypt( &ssl->session_negotiate->peer_cert->pk, + p, ssl->handshake->pmslen, + ssl->out_msg + offset + len_bytes, olen, + MBEDTLS_SSL_MAX_CONTENT_LEN - offset - len_bytes, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_rsa_pkcs1_encrypt", ret ); + return( ret ); + } + +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( len_bytes == 2 ) + { + ssl->out_msg[offset+0] = (unsigned char)( *olen >> 8 ); + ssl->out_msg[offset+1] = (unsigned char)( *olen ); + *olen += 2; + } +#endif + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_parse_signature_algorithm( mbedtls_ssl_context *ssl, + unsigned char **p, + unsigned char *end, + mbedtls_md_type_t *md_alg, + mbedtls_pk_type_t *pk_alg ) +{ + ((void) ssl); + *md_alg = MBEDTLS_MD_NONE; + *pk_alg = MBEDTLS_PK_NONE; + + /* Only in TLS 1.2 */ + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 ) + { + return( 0 ); + } + + if( (*p) + 2 > end ) + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + + /* + * Get hash algorithm + */ + if( ( *md_alg = mbedtls_ssl_md_alg_from_hash( (*p)[0] ) ) == MBEDTLS_MD_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Server used unsupported " + "HashAlgorithm %d", *(p)[0] ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + /* + * Get signature algorithm + */ + if( ( *pk_alg = mbedtls_ssl_pk_alg_from_sig( (*p)[1] ) ) == MBEDTLS_PK_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server used unsupported " + "SignatureAlgorithm %d", (*p)[1] ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + /* + * Check if the hash is acceptable + */ + if( mbedtls_ssl_check_sig_hash( ssl, *md_alg ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server used HashAlgorithm " + "that was not offered" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Server used SignatureAlgorithm %d", (*p)[1] ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Server used HashAlgorithm %d", (*p)[0] ) ); + *p += 2; + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl ) +{ + int ret; + const mbedtls_ecp_keypair *peer_key; + + if( ssl->session_negotiate->peer_cert == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "certificate required" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, + MBEDTLS_PK_ECKEY ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key not ECDH capable" ) ); + return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH ); + } + + peer_key = mbedtls_pk_ec( ssl->session_negotiate->peer_cert->pk ); + + if( ( ret = mbedtls_ecdh_get_params( &ssl->handshake->ecdh_ctx, peer_key, + MBEDTLS_ECDH_THEIRS ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_get_params" ), ret ); + return( ret ); + } + + if( ssl_check_server_ecdh_params( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server certificate (ECDH curve)" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + unsigned char *p, *end; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server key exchange" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse server key exchange" ) ); + ssl->state++; + return( 0 ); + } + ((void) p); + ((void) end); +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA ) + { + if( ( ret = ssl_get_ecdh_params_from_cert( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_get_ecdh_params_from_cert", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse server key exchange" ) ); + ssl->state++; + return( 0 ); + } + ((void) p); + ((void) end); +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + /* + * ServerKeyExchange may be skipped with PSK and RSA-PSK when the server + * doesn't use a psk_identity_hint + */ + if( ssl->in_msg[0] != MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE ) + { + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + ssl->record_read = 1; + goto exit; + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); + end = ssl->in_msg + ssl->in_hslen; + MBEDTLS_SSL_DEBUG_BUF( 3, "server key exchange", p, end - p ); + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + if( ssl_parse_server_psk_hint( ssl, &p, end ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + } /* FALLTROUGH */ +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + ; /* nothing more to do */ + else +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED || + MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + if( ssl_parse_server_dh_params( ssl, &p, end ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ) + { + if( ssl_parse_server_ecdh_params( ssl, &p, end ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + ret = mbedtls_ecjpake_read_round_two( &ssl->handshake->ecjpake_ctx, + p, end - p ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_two", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ) + { + size_t sig_len, hashlen; + unsigned char hash[64]; + mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE; + mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE; + unsigned char *params = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); + size_t params_len = p - params; + + /* + * Handle the digitally-signed structure + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + if( ssl_parse_signature_algorithm( ssl, &p, end, + &md_alg, &pk_alg ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + if( pk_alg != mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_3 ) + { + pk_alg = mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info ); + + /* Default hash for ECDSA is SHA-1 */ + if( pk_alg == MBEDTLS_PK_ECDSA && md_alg == MBEDTLS_MD_NONE ) + md_alg = MBEDTLS_MD_SHA1; + } + else +#endif + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* + * Read signature + */ + sig_len = ( p[0] << 8 ) | p[1]; + p += 2; + + if( end != p + sig_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "signature", p, sig_len ); + + /* + * Compute the hash that has been signed + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( md_alg == MBEDTLS_MD_NONE ) + { + mbedtls_md5_context mbedtls_md5; + mbedtls_sha1_context mbedtls_sha1; + + mbedtls_md5_init( &mbedtls_md5 ); + mbedtls_sha1_init( &mbedtls_sha1 ); + + hashlen = 36; + + /* + * digitally-signed struct { + * opaque md5_hash[16]; + * opaque sha_hash[20]; + * }; + * + * md5_hash + * MD5(ClientHello.random + ServerHello.random + * + ServerParams); + * sha_hash + * SHA(ClientHello.random + ServerHello.random + * + ServerParams); + */ + mbedtls_md5_starts( &mbedtls_md5 ); + mbedtls_md5_update( &mbedtls_md5, ssl->handshake->randbytes, 64 ); + mbedtls_md5_update( &mbedtls_md5, params, params_len ); + mbedtls_md5_finish( &mbedtls_md5, hash ); + + mbedtls_sha1_starts( &mbedtls_sha1 ); + mbedtls_sha1_update( &mbedtls_sha1, ssl->handshake->randbytes, 64 ); + mbedtls_sha1_update( &mbedtls_sha1, params, params_len ); + mbedtls_sha1_finish( &mbedtls_sha1, hash + 16 ); + + mbedtls_md5_free( &mbedtls_md5 ); + mbedtls_sha1_free( &mbedtls_sha1 ); + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \ + MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( md_alg != MBEDTLS_MD_NONE ) + { + mbedtls_md_context_t ctx; + + mbedtls_md_init( &ctx ); + + /* Info from md_alg will be used instead */ + hashlen = 0; + + /* + * digitally-signed struct { + * opaque client_random[32]; + * opaque server_random[32]; + * ServerDHParams params; + * }; + */ + if( ( ret = mbedtls_md_setup( &ctx, + mbedtls_md_info_from_type( md_alg ), 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret ); + return( ret ); + } + + mbedtls_md_starts( &ctx ); + mbedtls_md_update( &ctx, ssl->handshake->randbytes, 64 ); + mbedtls_md_update( &ctx, params, params_len ); + mbedtls_md_finish( &ctx, hash ); + mbedtls_md_free( &ctx ); + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ + MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen : + (unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) ); + + if( ssl->session_negotiate->peer_cert == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "certificate required" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + /* + * Verify signature + */ + if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, pk_alg ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); + return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH ); + } + + if( ( ret = mbedtls_pk_verify( &ssl->session_negotiate->peer_cert->pk, + md_alg, hash, hashlen, p, sig_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +exit: + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server key exchange" ) ); + + return( 0 ); +} + +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate request" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate request" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *buf; + size_t n = 0; + size_t cert_type_len = 0, dn_len = 0; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate request" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate request" ) ); + ssl->state++; + return( 0 ); + } + + if( ssl->record_read == 0 ) + { + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + ssl->record_read = 1; + } + + ssl->client_auth = 0; + ssl->state++; + + if( ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE_REQUEST ) + ssl->client_auth++; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "got %s certificate request", + ssl->client_auth ? "a" : "no" ) ); + + if( ssl->client_auth == 0 ) + goto exit; + + ssl->record_read = 0; + + /* + * struct { + * ClientCertificateType certificate_types<1..2^8-1>; + * SignatureAndHashAlgorithm + * supported_signature_algorithms<2^16-1>; -- TLS 1.2 only + * DistinguishedName certificate_authorities<0..2^16-1>; + * } CertificateRequest; + * + * Since we only support a single certificate on clients, let's just + * ignore all the information that's supposed to help us pick a + * certificate. + * + * We could check that our certificate matches the request, and bail out + * if it doesn't, but it's simpler to just send the certificate anyway, + * and give the server the opportunity to decide if it should terminate + * the connection when it doesn't like our certificate. + * + * Same goes for the hash in TLS 1.2's signature_algorithms: at this + * point we only have one hash available (see comments in + * write_certificate_verify), so let's just use what we have. + * + * However, we still minimally parse the message to check it is at least + * superficially sane. + */ + buf = ssl->in_msg; + + /* certificate_types */ + cert_type_len = buf[mbedtls_ssl_hs_hdr_len( ssl )]; + n = cert_type_len; + + if( ssl->in_hslen < mbedtls_ssl_hs_hdr_len( ssl ) + 2 + n ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST ); + } + + /* supported_signature_algorithms */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + size_t sig_alg_len = ( ( buf[mbedtls_ssl_hs_hdr_len( ssl ) + 1 + n] << 8 ) + | ( buf[mbedtls_ssl_hs_hdr_len( ssl ) + 2 + n] ) ); +#if defined(MBEDTLS_DEBUG_C) + unsigned char* sig_alg = buf + mbedtls_ssl_hs_hdr_len( ssl ) + 3 + n; + size_t i; + + for( i = 0; i < sig_alg_len; i += 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Supported Signature Algorithm found: %d,%d", sig_alg[i], sig_alg[i + 1] ) ); + } +#endif + + n += 2 + sig_alg_len; + + if( ssl->in_hslen < mbedtls_ssl_hs_hdr_len( ssl ) + 2 + n ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST ); + } + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + /* certificate_authorities */ + dn_len = ( ( buf[mbedtls_ssl_hs_hdr_len( ssl ) + 1 + n] << 8 ) + | ( buf[mbedtls_ssl_hs_hdr_len( ssl ) + 2 + n] ) ); + + n += dn_len; + if( ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + 3 + n ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST ); + } + +exit: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate request" ) ); + + return( 0 ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello done" ) ); + + if( ssl->record_read == 0 ) + { + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + } + ssl->record_read = 0; + + if( ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) || + ssl->in_msg[0] != MBEDTLS_SSL_HS_SERVER_HELLO_DONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE ); + } + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_recv_flight_completed( ssl ); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server hello done" ) ); + + return( 0 ); +} + +static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t i, n; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client key exchange" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA ) + { + /* + * DHM key exchange -- send G^X mod P + */ + n = ssl->handshake->dhm_ctx.len; + + ssl->out_msg[4] = (unsigned char)( n >> 8 ); + ssl->out_msg[5] = (unsigned char)( n ); + i = 6; + + ret = mbedtls_dhm_make_public( &ssl->handshake->dhm_ctx, + (int) mbedtls_mpi_size( &ssl->handshake->dhm_ctx.P ), + &ssl->out_msg[i], n, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_make_public", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->handshake->dhm_ctx.X ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->handshake->dhm_ctx.GX ); + + if( ( ret = mbedtls_dhm_calc_secret( &ssl->handshake->dhm_ctx, + ssl->handshake->premaster, + MBEDTLS_PREMASTER_SIZE, + &ssl->handshake->pmslen, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA ) + { + /* + * ECDH key exchange -- send client public value + */ + i = 4; + + ret = mbedtls_ecdh_make_public( &ssl->handshake->ecdh_ctx, + &n, + &ssl->out_msg[i], 1000, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_make_public", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q", &ssl->handshake->ecdh_ctx.Q ); + + if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, + &ssl->handshake->pmslen, + ssl->handshake->premaster, + MBEDTLS_MPI_MAX_SIZE, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z", &ssl->handshake->ecdh_ctx.z ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + /* + * opaque psk_identity<0..2^16-1>; + */ + if( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no private key for PSK" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + i = 4; + n = ssl->conf->psk_identity_len; + + if( i + 2 + n > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "psk identity too long or " + "SSL buffer too short" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + ssl->out_msg[i++] = (unsigned char)( n >> 8 ); + ssl->out_msg[i++] = (unsigned char)( n ); + + memcpy( ssl->out_msg + i, ssl->conf->psk_identity, ssl->conf->psk_identity_len ); + i += ssl->conf->psk_identity_len; + +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ) + { + n = 0; + } + else +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + if( ( ret = ssl_write_encrypted_pms( ssl, i, &n, 2 ) ) != 0 ) + return( ret ); + } + else +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + /* + * ClientDiffieHellmanPublic public (DHM send G^X mod P) + */ + n = ssl->handshake->dhm_ctx.len; + + if( i + 2 + n > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "psk identity or DHM size too long" + " or SSL buffer too short" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + ssl->out_msg[i++] = (unsigned char)( n >> 8 ); + ssl->out_msg[i++] = (unsigned char)( n ); + + ret = mbedtls_dhm_make_public( &ssl->handshake->dhm_ctx, + (int) mbedtls_mpi_size( &ssl->handshake->dhm_ctx.P ), + &ssl->out_msg[i], n, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_make_public", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + /* + * ClientECDiffieHellmanPublic public; + */ + ret = mbedtls_ecdh_make_public( &ssl->handshake->ecdh_ctx, &n, + &ssl->out_msg[i], MBEDTLS_SSL_MAX_CONTENT_LEN - i, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_make_public", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q", &ssl->handshake->ecdh_ctx.Q ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA ) + { + i = 4; + if( ( ret = ssl_write_encrypted_pms( ssl, i, &n, 0 ) ) != 0 ) + return( ret ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + i = 4; + + ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx, + ssl->out_msg + i, MBEDTLS_SSL_MAX_CONTENT_LEN - i, &n, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_write_round_two", ret ); + return( ret ); + } + + ret = mbedtls_ecjpake_derive_secret( &ssl->handshake->ecjpake_ctx, + ssl->handshake->premaster, 32, &ssl->handshake->pmslen, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_derive_secret", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ + { + ((void) ciphersuite_info); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + ssl->out_msglen = i + n; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE; + + ssl->state++; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client key exchange" ) ); + + return( 0 ); +} + +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) ); + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + size_t n = 0, offset = 0; + unsigned char hash[48]; + unsigned char *hash_start = hash; + mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE; + unsigned int hashlen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) ); + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + if( ssl->client_auth == 0 || mbedtls_ssl_own_cert( ssl ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + if( mbedtls_ssl_own_key( ssl ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no private key for certificate" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + /* + * Make an RSA signature of the handshake digests + */ + ssl->handshake->calc_verify( ssl, hash ); + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 ) + { + /* + * digitally-signed struct { + * opaque md5_hash[16]; + * opaque sha_hash[20]; + * }; + * + * md5_hash + * MD5(handshake_messages); + * + * sha_hash + * SHA(handshake_messages); + */ + hashlen = 36; + md_alg = MBEDTLS_MD_NONE; + + /* + * For ECDSA, default hash is SHA-1 only + */ + if( mbedtls_pk_can_do( mbedtls_ssl_own_key( ssl ), MBEDTLS_PK_ECDSA ) ) + { + hash_start += 16; + hashlen -= 16; + md_alg = MBEDTLS_MD_SHA1; + } + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \ + MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + /* + * digitally-signed struct { + * opaque handshake_messages[handshake_messages_length]; + * }; + * + * Taking shortcut here. We assume that the server always allows the + * PRF Hash function and has sent it in the allowed signature + * algorithms list received in the Certificate Request message. + * + * Until we encounter a server that does not, we will take this + * shortcut. + * + * Reason: Otherwise we should have running hashes for SHA512 and SHA224 + * in order to satisfy 'weird' needs from the server side. + */ + if( ssl->transform_negotiate->ciphersuite_info->mac == + MBEDTLS_MD_SHA384 ) + { + md_alg = MBEDTLS_MD_SHA384; + ssl->out_msg[4] = MBEDTLS_SSL_HASH_SHA384; + } + else + { + md_alg = MBEDTLS_MD_SHA256; + ssl->out_msg[4] = MBEDTLS_SSL_HASH_SHA256; + } + ssl->out_msg[5] = mbedtls_ssl_sig_from_pk( mbedtls_ssl_own_key( ssl ) ); + + /* Info from md_alg will be used instead */ + hashlen = 0; + offset = 2; + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash_start, hashlen, + ssl->out_msg + 6 + offset, &n, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_sign", ret ); + return( ret ); + } + + ssl->out_msg[4 + offset] = (unsigned char)( n >> 8 ); + ssl->out_msg[5 + offset] = (unsigned char)( n ); + + ssl->out_msglen = 6 + n + offset; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_VERIFY; + + ssl->state++; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write certificate verify" ) ); + + return( ret ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl ) +{ + int ret; + uint32_t lifetime; + size_t ticket_len; + unsigned char *ticket; + const unsigned char *msg; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse new session ticket" ) ); + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad new session ticket message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + /* + * struct { + * uint32 ticket_lifetime_hint; + * opaque ticket<0..2^16-1>; + * } NewSessionTicket; + * + * 0 . 3 ticket_lifetime_hint + * 4 . 5 ticket_len (n) + * 6 . 5+n ticket content + */ + if( ssl->in_msg[0] != MBEDTLS_SSL_HS_NEW_SESSION_TICKET || + ssl->in_hslen < 6 + mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad new session ticket message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET ); + } + + msg = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); + + lifetime = ( msg[0] << 24 ) | ( msg[1] << 16 ) | + ( msg[2] << 8 ) | ( msg[3] ); + + ticket_len = ( msg[4] << 8 ) | ( msg[5] ); + + if( ticket_len + 6 + mbedtls_ssl_hs_hdr_len( ssl ) != ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad new session ticket message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket length: %d", ticket_len ) ); + + /* We're not waiting for a NewSessionTicket message any more */ + ssl->handshake->new_session_ticket = 0; + ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; + + /* + * Zero-length ticket means the server changed his mind and doesn't want + * to send a ticket after all, so just forget it + */ + if( ticket_len == 0 ) + return( 0 ); + + mbedtls_zeroize( ssl->session_negotiate->ticket, + ssl->session_negotiate->ticket_len ); + mbedtls_free( ssl->session_negotiate->ticket ); + ssl->session_negotiate->ticket = NULL; + ssl->session_negotiate->ticket_len = 0; + + if( ( ticket = mbedtls_calloc( 1, ticket_len ) ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ticket alloc failed" ) ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + memcpy( ticket, msg + 6, ticket_len ); + + ssl->session_negotiate->ticket = ticket; + ssl->session_negotiate->ticket_len = ticket_len; + ssl->session_negotiate->ticket_lifetime = lifetime; + + /* + * RFC 5077 section 3.4: + * "If the client receives a session ticket from the server, then it + * discards any Session ID that was sent in the ServerHello." + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket in use, discarding session id" ) ); + ssl->session_negotiate->id_len = 0; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse new session ticket" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +/* + * SSL handshake -- client side -- single step + */ +int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); + + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) + { + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + return( ret ); + } +#endif + + /* Change state now, so that it is right in mbedtls_ssl_read_record(), used + * by DTLS for dropping out-of-sequence ChangeCipherSpec records */ +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( ssl->state == MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC && + ssl->handshake->new_session_ticket != 0 ) + { + ssl->state = MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET; + } +#endif + + switch( ssl->state ) + { + case MBEDTLS_SSL_HELLO_REQUEST: + ssl->state = MBEDTLS_SSL_CLIENT_HELLO; + break; + + /* + * ==> ClientHello + */ + case MBEDTLS_SSL_CLIENT_HELLO: + ret = ssl_write_client_hello( ssl ); + break; + + /* + * <== ServerHello + * Certificate + * ( ServerKeyExchange ) + * ( CertificateRequest ) + * ServerHelloDone + */ + case MBEDTLS_SSL_SERVER_HELLO: + ret = ssl_parse_server_hello( ssl ); + break; + + case MBEDTLS_SSL_SERVER_CERTIFICATE: + ret = mbedtls_ssl_parse_certificate( ssl ); + break; + + case MBEDTLS_SSL_SERVER_KEY_EXCHANGE: + ret = ssl_parse_server_key_exchange( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_REQUEST: + ret = ssl_parse_certificate_request( ssl ); + break; + + case MBEDTLS_SSL_SERVER_HELLO_DONE: + ret = ssl_parse_server_hello_done( ssl ); + break; + + /* + * ==> ( Certificate/Alert ) + * ClientKeyExchange + * ( CertificateVerify ) + * ChangeCipherSpec + * Finished + */ + case MBEDTLS_SSL_CLIENT_CERTIFICATE: + ret = mbedtls_ssl_write_certificate( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_KEY_EXCHANGE: + ret = ssl_write_client_key_exchange( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_VERIFY: + ret = ssl_write_certificate_verify( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC: + ret = mbedtls_ssl_write_change_cipher_spec( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_FINISHED: + ret = mbedtls_ssl_write_finished( ssl ); + break; + + /* + * <== ( NewSessionTicket ) + * ChangeCipherSpec + * Finished + */ +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + case MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET: + ret = ssl_parse_new_session_ticket( ssl ); + break; +#endif + + case MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC: + ret = mbedtls_ssl_parse_change_cipher_spec( ssl ); + break; + + case MBEDTLS_SSL_SERVER_FINISHED: + ret = mbedtls_ssl_parse_finished( ssl ); + break; + + case MBEDTLS_SSL_FLUSH_BUFFERS: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "handshake: done" ) ); + ssl->state = MBEDTLS_SSL_HANDSHAKE_WRAPUP; + break; + + case MBEDTLS_SSL_HANDSHAKE_WRAPUP: + mbedtls_ssl_handshake_wrapup( ssl ); + break; + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + return( ret ); +} +#endif /* MBEDTLS_SSL_CLI_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cookie.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cookie.c new file mode 100644 index 0000000..caf1199 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_cookie.c @@ -0,0 +1,260 @@ +/* + * DTLS cookie callbacks implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * These session callbacks use a simple chained list + * to store and retrieve the session information. + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_COOKIE_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/ssl_internal.h" + +#include + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * If DTLS is in use, then at least one of SHA-1, SHA-256, SHA-512 is + * available. Try SHA-256 first, 512 wastes resources since we need to stay + * with max 32 bytes of cookie for DTLS 1.0 + */ +#if defined(MBEDTLS_SHA256_C) +#define COOKIE_MD MBEDTLS_MD_SHA224 +#define COOKIE_MD_OUTLEN 32 +#define COOKIE_HMAC_LEN 28 +#elif defined(MBEDTLS_SHA512_C) +#define COOKIE_MD MBEDTLS_MD_SHA384 +#define COOKIE_MD_OUTLEN 48 +#define COOKIE_HMAC_LEN 28 +#elif defined(MBEDTLS_SHA1_C) +#define COOKIE_MD MBEDTLS_MD_SHA1 +#define COOKIE_MD_OUTLEN 20 +#define COOKIE_HMAC_LEN 20 +#else +#error "DTLS hello verify needs SHA-1 or SHA-2" +#endif + +/* + * Cookies are formed of a 4-bytes timestamp (or serial number) and + * an HMAC of timestemp and client ID. + */ +#define COOKIE_LEN ( 4 + COOKIE_HMAC_LEN ) + +void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx ) +{ + mbedtls_md_init( &ctx->hmac_ctx ); +#if !defined(MBEDTLS_HAVE_TIME) + ctx->serial = 0; +#endif + ctx->timeout = MBEDTLS_SSL_COOKIE_TIMEOUT; + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &ctx->mutex ); +#endif +} + +void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay ) +{ + ctx->timeout = delay; +} + +void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ) +{ + mbedtls_md_free( &ctx->hmac_ctx ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &ctx->mutex ); +#endif + + mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_cookie_ctx ) ); +} + +int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + unsigned char key[COOKIE_MD_OUTLEN]; + + if( ( ret = f_rng( p_rng, key, sizeof( key ) ) ) != 0 ) + return( ret ); + + ret = mbedtls_md_setup( &ctx->hmac_ctx, mbedtls_md_info_from_type( COOKIE_MD ), 1 ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_md_hmac_starts( &ctx->hmac_ctx, key, sizeof( key ) ); + if( ret != 0 ) + return( ret ); + + mbedtls_zeroize( key, sizeof( key ) ); + + return( 0 ); +} + +/* + * Generate the HMAC part of a cookie + */ +static int ssl_cookie_hmac( mbedtls_md_context_t *hmac_ctx, + const unsigned char time[4], + unsigned char **p, unsigned char *end, + const unsigned char *cli_id, size_t cli_id_len ) +{ + unsigned char hmac_out[COOKIE_MD_OUTLEN]; + + if( (size_t)( end - *p ) < COOKIE_HMAC_LEN ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + if( mbedtls_md_hmac_reset( hmac_ctx ) != 0 || + mbedtls_md_hmac_update( hmac_ctx, time, 4 ) != 0 || + mbedtls_md_hmac_update( hmac_ctx, cli_id, cli_id_len ) != 0 || + mbedtls_md_hmac_finish( hmac_ctx, hmac_out ) != 0 ) + { + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + memcpy( *p, hmac_out, COOKIE_HMAC_LEN ); + *p += COOKIE_HMAC_LEN; + + return( 0 ); +} + +/* + * Generate cookie for DTLS ClientHello verification + */ +int mbedtls_ssl_cookie_write( void *p_ctx, + unsigned char **p, unsigned char *end, + const unsigned char *cli_id, size_t cli_id_len ) +{ + int ret; + mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx; + unsigned long t; + + if( ctx == NULL || cli_id == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( (size_t)( end - *p ) < COOKIE_LEN ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + +#if defined(MBEDTLS_HAVE_TIME) + t = (unsigned long) mbedtls_time( NULL ); +#else + t = ctx->serial++; +#endif + + (*p)[0] = (unsigned char)( t >> 24 ); + (*p)[1] = (unsigned char)( t >> 16 ); + (*p)[2] = (unsigned char)( t >> 8 ); + (*p)[3] = (unsigned char)( t ); + *p += 4; + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR + ret ); +#endif + + ret = ssl_cookie_hmac( &ctx->hmac_ctx, *p - 4, + p, end, cli_id, cli_id_len ); + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR + + MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +/* + * Check a cookie + */ +int mbedtls_ssl_cookie_check( void *p_ctx, + const unsigned char *cookie, size_t cookie_len, + const unsigned char *cli_id, size_t cli_id_len ) +{ + unsigned char ref_hmac[COOKIE_HMAC_LEN]; + int ret = 0; + unsigned char *p = ref_hmac; + mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx; + unsigned long cur_time, cookie_time; + + if( ctx == NULL || cli_id == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( cookie_len != COOKIE_LEN ) + return( -1 ); + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR + ret ); +#endif + + if( ssl_cookie_hmac( &ctx->hmac_ctx, cookie, + &p, p + sizeof( ref_hmac ), + cli_id, cli_id_len ) != 0 ) + ret = -1; + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR + + MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + if( ret != 0 ) + return( ret ); + + if( mbedtls_ssl_safer_memcmp( cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 ) + return( -1 ); + +#if defined(MBEDTLS_HAVE_TIME) + cur_time = (unsigned long) mbedtls_time( NULL ); +#else + cur_time = ctx->serial; +#endif + + cookie_time = ( (unsigned long) cookie[0] << 24 ) | + ( (unsigned long) cookie[1] << 16 ) | + ( (unsigned long) cookie[2] << 8 ) | + ( (unsigned long) cookie[3] ); + + if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout ) + return( -1 ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_COOKIE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_srv.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_srv.c new file mode 100644 index 0000000..fc0d2d7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_srv.c @@ -0,0 +1,3926 @@ +/* + * SSLv3/TLSv1 server-side functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_SRV_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_internal.h" + +#include + +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) +int mbedtls_ssl_set_client_transport_id( mbedtls_ssl_context *ssl, + const unsigned char *info, + size_t ilen ) +{ + if( ssl->conf->endpoint != MBEDTLS_SSL_IS_SERVER ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + mbedtls_free( ssl->cli_id ); + + if( ( ssl->cli_id = mbedtls_calloc( 1, ilen ) ) == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + memcpy( ssl->cli_id, info, ilen ); + ssl->cli_id_len = ilen; + + return( 0 ); +} + +void mbedtls_ssl_conf_dtls_cookies( mbedtls_ssl_config *conf, + mbedtls_ssl_cookie_write_t *f_cookie_write, + mbedtls_ssl_cookie_check_t *f_cookie_check, + void *p_cookie ) +{ + conf->f_cookie_write = f_cookie_write; + conf->f_cookie_check = f_cookie_check; + conf->p_cookie = p_cookie; +} +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +static int ssl_parse_servername_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + size_t servername_list_size, hostname_len; + const unsigned char *p; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "parse ServerName extension" ) ); + + servername_list_size = ( ( buf[0] << 8 ) | ( buf[1] ) ); + if( servername_list_size + 2 != len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + p = buf + 2; + while( servername_list_size > 0 ) + { + hostname_len = ( ( p[1] << 8 ) | p[2] ); + if( hostname_len + 3 > servername_list_size ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( p[0] == MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ) + { + ret = ssl->conf->f_sni( ssl->conf->p_sni, + ssl, p + 3, hostname_len ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_sni_wrapper", ret ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + return( 0 ); + } + + servername_list_size -= hostname_len + 3; + p += hostname_len + 3; + } + + if( servername_list_size != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +static int ssl_parse_renegotiation_info( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Check verify-data in constant-time. The length OTOH is no secret */ + if( len != 1 + ssl->verify_data_len || + buf[0] != ssl->verify_data_len || + mbedtls_ssl_safer_memcmp( buf + 1, ssl->peer_verify_data, + ssl->verify_data_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching renegotiation info" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } + else +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + { + if( len != 1 || buf[0] != 0x0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-zero length renegotiation info" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + } + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +static int ssl_parse_signature_algorithms_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t sig_alg_list_size; + const unsigned char *p; + const unsigned char *end = buf + len; + const int *md_cur; + + + sig_alg_list_size = ( ( buf[0] << 8 ) | ( buf[1] ) ); + if( sig_alg_list_size + 2 != len || + sig_alg_list_size % 2 != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * For now, ignore the SignatureAlgorithm part and rely on offered + * ciphersuites only for that part. To be fixed later. + * + * So, just look at the HashAlgorithm part. + */ + for( md_cur = ssl->conf->sig_hashes; *md_cur != MBEDTLS_MD_NONE; md_cur++ ) { + for( p = buf + 2; p < end; p += 2 ) { + if( *md_cur == (int) mbedtls_ssl_md_alg_from_hash( p[0] ) ) { + ssl->handshake->sig_alg = p[0]; + goto have_sig_alg; + } + } + } + + /* Some key echanges do not need signatures at all */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "no signature_algorithm in common" ) ); + return( 0 ); + +have_sig_alg: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext: %d", + ssl->handshake->sig_alg ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static int ssl_parse_supported_elliptic_curves( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t list_size, our_size; + const unsigned char *p; + const mbedtls_ecp_curve_info *curve_info, **curves; + + list_size = ( ( buf[0] << 8 ) | ( buf[1] ) ); + if( list_size + 2 != len || + list_size % 2 != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* Should never happen unless client duplicates the extension */ + if( ssl->handshake->curves != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* Don't allow our peer to make us allocate too much memory, + * and leave room for a final 0 */ + our_size = list_size / 2 + 1; + if( our_size > MBEDTLS_ECP_DP_MAX ) + our_size = MBEDTLS_ECP_DP_MAX; + + if( ( curves = mbedtls_calloc( our_size, sizeof( *curves ) ) ) == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + ssl->handshake->curves = curves; + + p = buf + 2; + while( list_size > 0 && our_size > 1 ) + { + curve_info = mbedtls_ecp_curve_info_from_tls_id( ( p[0] << 8 ) | p[1] ); + + if( curve_info != NULL ) + { + *curves++ = curve_info; + our_size--; + } + + list_size -= 2; + p += 2; + } + + return( 0 ); +} + +static int ssl_parse_supported_point_formats( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t list_size; + const unsigned char *p; + + list_size = buf[0]; + if( list_size + 1 != len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + p = buf + 1; + while( list_size > 0 ) + { + if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED || + p[0] == MBEDTLS_ECP_PF_COMPRESSED ) + { +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) + ssl->handshake->ecdh_ctx.point_format = p[0]; +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl->handshake->ecjpake_ctx.point_format = p[0]; +#endif + MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) ); + return( 0 ); + } + + list_size--; + p++; + } + + return( 0 ); +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + + if( mbedtls_ecjpake_check( &ssl->handshake->ecjpake_ctx ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip ecjpake kkpp extension" ) ); + return( 0 ); + } + + if( ( ret = mbedtls_ecjpake_read_round_one( &ssl->handshake->ecjpake_ctx, + buf, len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_one", ret ); + return( ret ); + } + + /* Only mark the extension as OK when we're sure it is */ + ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK; + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +static int ssl_parse_max_fragment_length_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 1 || buf[0] >= MBEDTLS_SSL_MAX_FRAG_LEN_INVALID ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->session_negotiate->mfl_code = buf[0]; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +static int ssl_parse_truncated_hmac_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ((void) buf); + + if( ssl->conf->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_ENABLED ) + ssl->session_negotiate->trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_ENABLED; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +static int ssl_parse_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ((void) buf); + + if( ssl->conf->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED && + ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl->session_negotiate->encrypt_then_mac = MBEDTLS_SSL_ETM_ENABLED; + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +static int ssl_parse_extended_ms_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ((void) buf); + + if( ssl->conf->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED && + ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl->handshake->extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t len ) +{ + int ret; + mbedtls_ssl_session session; + + mbedtls_ssl_session_init( &session ); + + if( ssl->conf->f_ticket_parse == NULL || + ssl->conf->f_ticket_write == NULL ) + { + return( 0 ); + } + + /* Remember the client asked us to send a new ticket */ + ssl->handshake->new_session_ticket = 1; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket length: %d", len ) ); + + if( len == 0 ) + return( 0 ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket rejected: renegotiating" ) ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + /* + * Failures are ok: just ignore the ticket and proceed. + */ + if( ( ret = ssl->conf->f_ticket_parse( ssl->conf->p_ticket, &session, + buf, len ) ) != 0 ) + { + mbedtls_ssl_session_free( &session ); + + if( ret == MBEDTLS_ERR_SSL_INVALID_MAC ) + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket is not authentic" ) ); + else if( ret == MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED ) + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket is expired" ) ); + else + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_ticket_parse", ret ); + + return( 0 ); + } + + /* + * Keep the session ID sent by the client, since we MUST send it back to + * inform them we're accepting the ticket (RFC 5077 section 3.4) + */ + session.id_len = ssl->session_negotiate->id_len; + memcpy( &session.id, ssl->session_negotiate->id, session.id_len ); + + mbedtls_ssl_session_free( ssl->session_negotiate ); + memcpy( ssl->session_negotiate, &session, sizeof( mbedtls_ssl_session ) ); + + /* Zeroize instead of free as we copied the content */ + mbedtls_zeroize( &session, sizeof( mbedtls_ssl_session ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from ticket" ) ); + + ssl->handshake->resume = 1; + + /* Don't send a new ticket after all, this one is OK */ + ssl->handshake->new_session_ticket = 0; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) +static int ssl_parse_alpn_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + size_t list_len, cur_len, ours_len; + const unsigned char *theirs, *start, *end; + const char **ours; + + /* If ALPN not configured, just ignore the extension */ + if( ssl->conf->alpn_list == NULL ) + return( 0 ); + + /* + * opaque ProtocolName<1..2^8-1>; + * + * struct { + * ProtocolName protocol_name_list<2..2^16-1> + * } ProtocolNameList; + */ + + /* Min length is 2 (list_len) + 1 (name_len) + 1 (name) */ + if( len < 4 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + list_len = ( buf[0] << 8 ) | buf[1]; + if( list_len != len - 2 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + /* + * Use our order of preference + */ + start = buf + 2; + end = buf + len; + for( ours = ssl->conf->alpn_list; *ours != NULL; ours++ ) + { + ours_len = strlen( *ours ); + for( theirs = start; theirs != end; theirs += cur_len ) + { + /* If the list is well formed, we should get equality first */ + if( theirs > end ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + cur_len = *theirs++; + + /* Empty strings MUST NOT be included */ + if( cur_len == 0 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + if( cur_len == ours_len && + memcmp( theirs, *ours, cur_len ) == 0 ) + { + ssl->alpn_chosen = *ours; + return( 0 ); + } + } + } + + /* If we get there, no match was found */ + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); +} +#endif /* MBEDTLS_SSL_ALPN */ + +/* + * Auxiliary functions for ServerHello parsing and related actions + */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/* + * Return 0 if the given key uses one of the acceptable curves, -1 otherwise + */ +#if defined(MBEDTLS_ECDSA_C) +static int ssl_check_key_curve( mbedtls_pk_context *pk, + const mbedtls_ecp_curve_info **curves ) +{ + const mbedtls_ecp_curve_info **crv = curves; + mbedtls_ecp_group_id grp_id = mbedtls_pk_ec( *pk )->grp.id; + + while( *crv != NULL ) + { + if( (*crv)->grp_id == grp_id ) + return( 0 ); + crv++; + } + + return( -1 ); +} +#endif /* MBEDTLS_ECDSA_C */ + +/* + * Try picking a certificate for this ciphersuite, + * return 0 on success and -1 on failure. + */ +static int ssl_pick_cert( mbedtls_ssl_context *ssl, + const mbedtls_ssl_ciphersuite_t * ciphersuite_info ) +{ + mbedtls_ssl_key_cert *cur, *list, *fallback = NULL; + mbedtls_pk_type_t pk_alg = mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info ); + uint32_t flags; + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_key_cert != NULL ) + list = ssl->handshake->sni_key_cert; + else +#endif + list = ssl->conf->key_cert; + + if( pk_alg == MBEDTLS_PK_NONE ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite requires certificate" ) ); + + if( list == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server has no certificate" ) ); + return( -1 ); + } + + for( cur = list; cur != NULL; cur = cur->next ) + { + MBEDTLS_SSL_DEBUG_CRT( 3, "candidate certificate chain, certificate", + cur->cert ); + + if( ! mbedtls_pk_can_do( cur->key, pk_alg ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: key type" ) ); + continue; + } + + /* + * This avoids sending the client a cert it'll reject based on + * keyUsage or other extensions. + * + * It also allows the user to provision different certificates for + * different uses based on keyUsage, eg if they want to avoid signing + * and decrypting with the same RSA key. + */ + if( mbedtls_ssl_check_cert_usage( cur->cert, ciphersuite_info, + MBEDTLS_SSL_IS_SERVER, &flags ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: " + "(extended) key usage extension" ) ); + continue; + } + +#if defined(MBEDTLS_ECDSA_C) + if( pk_alg == MBEDTLS_PK_ECDSA && + ssl_check_key_curve( cur->key, ssl->handshake->curves ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: elliptic curve" ) ); + continue; + } +#endif + + /* + * Try to select a SHA-1 certificate for pre-1.2 clients, but still + * present them a SHA-higher cert rather than failing if it's the only + * one we got that satisfies the other conditions. + */ + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_3 && + cur->cert->sig_md != MBEDTLS_MD_SHA1 ) + { + if( fallback == NULL ) + fallback = cur; + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate not preferred: " + "sha-2 with pre-TLS 1.2 client" ) ); + continue; + } + } + + /* If we get there, we got a winner */ + break; + } + + if( cur == NULL ) + cur = fallback; + + /* Do not update ssl->handshake->key_cert unless there is a match */ + if( cur != NULL ) + { + ssl->handshake->key_cert = cur; + MBEDTLS_SSL_DEBUG_CRT( 3, "selected certificate chain, certificate", + ssl->handshake->key_cert->cert ); + return( 0 ); + } + + return( -1 ); +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +/* + * Check if a given ciphersuite is suitable for use with our config/keys/etc + * Sets ciphersuite_info only if the suite matches. + */ +static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id, + const mbedtls_ssl_ciphersuite_t **ciphersuite_info ) +{ + const mbedtls_ssl_ciphersuite_t *suite_info; + + suite_info = mbedtls_ssl_ciphersuite_from_id( suite_id ); + if( suite_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "trying ciphersuite: %s", suite_info->name ) ); + + if( suite_info->min_minor_ver > ssl->minor_ver || + suite_info->max_minor_ver < ssl->minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: version" ) ); + return( 0 ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( suite_info->flags & MBEDTLS_CIPHERSUITE_NODTLS ) ) + return( 0 ); +#endif + +#if defined(MBEDTLS_ARC4_C) + if( ssl->conf->arc4_disabled == MBEDTLS_SSL_ARC4_DISABLED && + suite_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: rc4" ) ); + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( suite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE && + ( ssl->handshake->cli_exts & MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: ecjpake " + "not configured or ext missing" ) ); + return( 0 ); + } +#endif + + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) + if( mbedtls_ssl_ciphersuite_uses_ec( suite_info ) && + ( ssl->handshake->curves == NULL || + ssl->handshake->curves[0] == NULL ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: " + "no common elliptic curve" ) ); + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + /* If the ciphersuite requires a pre-shared key and we don't + * have one, skip it now rather than failing later */ + if( mbedtls_ssl_ciphersuite_uses_psk( suite_info ) && + ssl->conf->f_psk == NULL && + ( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL || + ssl->conf->psk_identity_len == 0 || ssl->conf->psk_len == 0 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: no pre-shared key" ) ); + return( 0 ); + } +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * Final check: if ciphersuite requires us to have a + * certificate/key of a particular type: + * - select the appropriate certificate if we have one, or + * - try the next ciphersuite if we don't + * This must be done last since we modify the key_cert list. + */ + if( ssl_pick_cert( ssl, suite_info ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: " + "no suitable certificate" ) ); + return( 0 ); + } +#endif + + *ciphersuite_info = suite_info; + return( 0 ); +} + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) +static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl ) +{ + int ret, got_common_suite; + unsigned int i, j; + size_t n; + unsigned int ciph_len, sess_len, chal_len; + unsigned char *buf, *p; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client hello v2" ) ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "client hello v2 illegal for renegotiation" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + buf = ssl->in_hdr; + + MBEDTLS_SSL_DEBUG_BUF( 4, "record header", buf, 5 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v2, message type: %d", + buf[2] ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v2, message len.: %d", + ( ( buf[0] & 0x7F ) << 8 ) | buf[1] ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v2, max. version: [%d:%d]", + buf[3], buf[4] ) ); + + /* + * SSLv2 Client Hello + * + * Record layer: + * 0 . 1 message length + * + * SSL layer: + * 2 . 2 message type + * 3 . 4 protocol version + */ + if( buf[2] != MBEDTLS_SSL_HS_CLIENT_HELLO || + buf[3] != MBEDTLS_SSL_MAJOR_VERSION_3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + n = ( ( buf[0] << 8 ) | buf[1] ) & 0x7FFF; + + if( n < 17 || n > 512 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; + ssl->minor_ver = ( buf[4] <= ssl->conf->max_minor_ver ) + ? buf[4] : ssl->conf->max_minor_ver; + + if( ssl->minor_ver < ssl->conf->min_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "client only supports ssl smaller than minimum" + " [%d:%d] < [%d:%d]", + ssl->major_ver, ssl->minor_ver, + ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + ssl->handshake->max_major_ver = buf[3]; + ssl->handshake->max_minor_ver = buf[4]; + + if( ( ret = mbedtls_ssl_fetch_input( ssl, 2 + n ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + + ssl->handshake->update_checksum( ssl, buf + 2, n ); + + buf = ssl->in_msg; + n = ssl->in_left - 5; + + /* + * 0 . 1 ciphersuitelist length + * 2 . 3 session id length + * 4 . 5 challenge length + * 6 . .. ciphersuitelist + * .. . .. session id + * .. . .. challenge + */ + MBEDTLS_SSL_DEBUG_BUF( 4, "record contents", buf, n ); + + ciph_len = ( buf[0] << 8 ) | buf[1]; + sess_len = ( buf[2] << 8 ) | buf[3]; + chal_len = ( buf[4] << 8 ) | buf[5]; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciph_len: %d, sess_len: %d, chal_len: %d", + ciph_len, sess_len, chal_len ) ); + + /* + * Make sure each parameter length is valid + */ + if( ciph_len < 3 || ( ciph_len % 3 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( sess_len > 32 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( chal_len < 8 || chal_len > 32 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( n != 6 + ciph_len + sess_len + chal_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, ciphersuitelist", + buf + 6, ciph_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", + buf + 6 + ciph_len, sess_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, challenge", + buf + 6 + ciph_len + sess_len, chal_len ); + + p = buf + 6 + ciph_len; + ssl->session_negotiate->id_len = sess_len; + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); + memcpy( ssl->session_negotiate->id, p, ssl->session_negotiate->id_len ); + + p += sess_len; + memset( ssl->handshake->randbytes, 0, 64 ); + memcpy( ssl->handshake->randbytes + 32 - chal_len, p, chal_len ); + + /* + * Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ + for( i = 0, p = buf + 6; i < ciph_len; i += 3, p += 3 ) + { + if( p[0] == 0 && p[1] == 0 && p[2] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "received TLS_EMPTY_RENEGOTIATION_INFO " ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV " + "during renegotiation" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + break; + } + } + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + for( i = 0, p = buf + 6; i < ciph_len; i += 3, p += 3 ) + { + if( p[0] == 0 && + p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) && + p[2] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "received FALLBACK_SCSV" ) ); + + if( ssl->minor_ver < ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "inapropriate fallback" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + break; + } + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + + got_common_suite = 0; + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + ciphersuite_info = NULL; +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 ) + { + for( i = 0; ciphersuites[i] != 0; i++ ) +#else + for( i = 0; ciphersuites[i] != 0; i++ ) + { + for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 ) +#endif + { + if( p[0] != 0 || + p[1] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || + p[2] != ( ( ciphersuites[i] ) & 0xFF ) ) + continue; + + got_common_suite = 1; + + if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i], + &ciphersuite_info ) ) != 0 ) + return( ret ); + + if( ciphersuite_info != NULL ) + goto have_ciphersuite_v2; + } + } + + if( got_common_suite ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got ciphersuites in common, " + "but none of them usable" ) ); + return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no ciphersuites in common" ) ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + +have_ciphersuite_v2: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "selected ciphersuite: %s", ciphersuite_info->name ) ); + + ssl->session_negotiate->ciphersuite = ciphersuites[i]; + ssl->transform_negotiate->ciphersuite_info = ciphersuite_info; + + /* + * SSLv2 Client Hello relevant renegotiation security checks + */ + if( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->in_left = 0; + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello v2" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO */ + +static int ssl_parse_client_hello( mbedtls_ssl_context *ssl ) +{ + int ret, got_common_suite; + size_t i, j; + size_t ciph_offset, comp_offset, ext_offset; + size_t msg_len, ciph_len, sess_len, comp_len, ext_len; +#if defined(MBEDTLS_SSL_PROTO_DTLS) + size_t cookie_offset, cookie_len; +#endif + unsigned char *buf, *p, *ext; +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renegotiation_info_seen = 0; +#endif + int handshake_failure = 0; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + int major, minor; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client hello" ) ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +read_record_header: +#endif + /* + * If renegotiating, then the input was read with mbedtls_ssl_read_record(), + * otherwise read it ourselves manually in order to support SSLv2 + * ClientHello, which doesn't use the same record layer format. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + if( ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + } + + buf = ssl->in_hdr; + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM ) +#endif + if( ( buf[0] & 0x80 ) != 0 ) + return ssl_parse_client_hello_v2( ssl ); +#endif + + MBEDTLS_SSL_DEBUG_BUF( 4, "record header", buf, mbedtls_ssl_hdr_len( ssl ) ); + + /* + * SSLv3/TLS Client Hello + * + * Record layer: + * 0 . 0 message type + * 1 . 2 protocol version + * 3 . 11 DTLS: epoch + record sequence number + * 3 . 4 message length + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, message type: %d", + buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, message len.: %d", + ( ssl->in_len[0] << 8 ) | ssl->in_len[1] ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, protocol version: [%d:%d]", + buf[1], buf[2] ) ); + + mbedtls_ssl_read_version( &major, &minor, ssl->conf->transport, buf + 1 ); + + /* According to RFC 5246 Appendix E.1, the version here is typically + * "{03,00}, the lowest version number supported by the client, [or] the + * value of ClientHello.client_version", so the only meaningful check here + * is the major version shouldn't be less than 3 */ + if( major < MBEDTLS_SSL_MAJOR_VERSION_3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* For DTLS if this is the initial handshake, remember the client sequence + * number to use it in our next message (RFC 6347 4.2.1) */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + /* Epoch should be 0 for initial handshakes */ + if( ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + memcpy( ssl->out_ctr + 2, ssl->in_ctr + 2, 6 ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "replayed record, discarding" ) ); + ssl->next_record_offset = 0; + ssl->in_left = 0; + goto read_record_header; + } + + /* No MAC to check yet, so we can update right now */ + mbedtls_ssl_dtls_replay_update( ssl ); +#endif + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + msg_len = ( ssl->in_len[0] << 8 ) | ssl->in_len[1]; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Set by mbedtls_ssl_read_record() */ + msg_len = ssl->in_hslen; + } + else +#endif + { + if( msg_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) + msg_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + + /* Done reading this record, get ready for the next one */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->next_record_offset = msg_len + mbedtls_ssl_hdr_len( ssl ); + else +#endif + ssl->in_left = 0; + } + + buf = ssl->in_msg; + + MBEDTLS_SSL_DEBUG_BUF( 4, "record contents", buf, msg_len ); + + ssl->handshake->update_checksum( ssl, buf, msg_len ); + + /* + * Handshake layer: + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 DTLS only: message seqence number + * 6 . 8 DTLS only: fragment offset + * 9 . 11 DTLS only: fragment length + */ + if( msg_len < mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, handshake type: %d", buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, handshake len.: %d", + ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ) ); + + /* We don't support fragmentation of ClientHello (yet?) */ + if( buf[1] != 0 || + msg_len != mbedtls_ssl_hs_hdr_len( ssl ) + ( ( buf[2] << 8 ) | buf[3] ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + /* + * Copy the client's handshake message_seq on initial handshakes, + * check sequence number on renego. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + /* This couldn't be done in ssl_prepare_handshake_record() */ + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + + if( cli_msg_seq != ssl->handshake->in_msg_seq ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message_seq: " + "%d (expected %d)", cli_msg_seq, + ssl->handshake->in_msg_seq ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->handshake->in_msg_seq++; + } + else +#endif + { + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + ssl->handshake->out_msg_seq = cli_msg_seq; + ssl->handshake->in_msg_seq = cli_msg_seq + 1; + } + + /* + * For now we don't support fragmentation, so make sure + * fragment_offset == 0 and fragment_length == length + */ + if( ssl->in_msg[6] != 0 || ssl->in_msg[7] != 0 || ssl->in_msg[8] != 0 || + memcmp( ssl->in_msg + 1, ssl->in_msg + 9, 3 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ClientHello fragmentation not supported" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + buf += mbedtls_ssl_hs_hdr_len( ssl ); + msg_len -= mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * ClientHello layer: + * 0 . 1 protocol version + * 2 . 33 random bytes (starting with 4 bytes of Unix time) + * 34 . 35 session id length (1 byte) + * 35 . 34+x session id + * 35+x . 35+x DTLS only: cookie length (1 byte) + * 36+x . .. DTLS only: cookie + * .. . .. ciphersuite list length (2 bytes) + * .. . .. ciphersuite list + * .. . .. compression alg. list length (1 byte) + * .. . .. compression alg. list + * .. . .. extensions length (2 bytes, optional) + * .. . .. extensions (optional) + */ + + /* + * Minimal length (with everything empty and extensions ommitted) is + * 2 + 32 + 1 + 2 + 1 = 38 bytes. Check that first, so that we can + * read at least up to session id length without worrying. + */ + if( msg_len < 38 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Check and save the protocol version + */ + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, version", buf, 2 ); + + mbedtls_ssl_read_version( &ssl->major_ver, &ssl->minor_ver, + ssl->conf->transport, buf ); + + ssl->handshake->max_major_ver = ssl->major_ver; + ssl->handshake->max_minor_ver = ssl->minor_ver; + + if( ssl->major_ver < ssl->conf->min_major_ver || + ssl->minor_ver < ssl->conf->min_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "client only supports ssl smaller than minimum" + " [%d:%d] < [%d:%d]", + ssl->major_ver, ssl->minor_ver, + ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + if( ssl->major_ver > ssl->conf->max_major_ver ) + { + ssl->major_ver = ssl->conf->max_major_ver; + ssl->minor_ver = ssl->conf->max_minor_ver; + } + else if( ssl->minor_ver > ssl->conf->max_minor_ver ) + ssl->minor_ver = ssl->conf->max_minor_ver; + + /* + * Save client random (inc. Unix time) + */ + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf + 2, 32 ); + + memcpy( ssl->handshake->randbytes, buf + 2, 32 ); + + /* + * Check the session ID length and save session ID + */ + sess_len = buf[34]; + + if( sess_len > sizeof( ssl->session_negotiate->id ) || + sess_len + 34 + 2 > msg_len ) /* 2 for cipherlist length field */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", buf + 35, sess_len ); + + ssl->session_negotiate->id_len = sess_len; + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); + memcpy( ssl->session_negotiate->id, buf + 35, + ssl->session_negotiate->id_len ); + + /* + * Check the cookie length and content + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + cookie_offset = 35 + sess_len; + cookie_len = buf[cookie_offset]; + + if( cookie_offset + 1 + cookie_len + 2 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, cookie", + buf + cookie_offset + 1, cookie_len ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( ssl->conf->f_cookie_check != NULL +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + if( ssl->conf->f_cookie_check( ssl->conf->p_cookie, + buf + cookie_offset + 1, cookie_len, + ssl->cli_id, ssl->cli_id_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "cookie verification failed" ) ); + ssl->handshake->verify_cookie_len = 1; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "cookie verification passed" ) ); + ssl->handshake->verify_cookie_len = 0; + } + } + else +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + { + /* We know we didn't send a cookie, so it should be empty */ + if( cookie_len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "cookie verification skipped" ) ); + } + + /* + * Check the ciphersuitelist length (will be parsed later) + */ + ciph_offset = cookie_offset + 1 + cookie_len; + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + ciph_offset = 35 + sess_len; + + ciph_len = ( buf[ciph_offset + 0] << 8 ) + | ( buf[ciph_offset + 1] ); + + if( ciph_len < 2 || + ciph_len + 2 + ciph_offset + 1 > msg_len || /* 1 for comp. alg. len */ + ( ciph_len % 2 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, ciphersuitelist", + buf + ciph_offset + 2, ciph_len ); + + /* + * Check the compression algorithms length and pick one + */ + comp_offset = ciph_offset + 2 + ciph_len; + + comp_len = buf[comp_offset]; + + if( comp_len < 1 || + comp_len > 16 || + comp_len + comp_offset + 1 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, compression", + buf + comp_offset + 1, comp_len ); + + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#if defined(MBEDTLS_ZLIB_SUPPORT) + for( i = 0; i < comp_len; ++i ) + { + if( buf[comp_offset + 1 + i] == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_DEFLATE; + break; + } + } +#endif + + /* See comments in ssl_write_client_hello() */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#endif + + /* Do not parse the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + /* + * Check the extension length + */ + ext_offset = comp_offset + 1 + comp_len; + if( msg_len > ext_offset ) + { + if( msg_len < ext_offset + 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ext_len = ( buf[ext_offset + 0] << 8 ) + | ( buf[ext_offset + 1] ); + + if( ( ext_len > 0 && ext_len < 4 ) || + msg_len != ext_offset + 2 + ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } + else + ext_len = 0; + + ext = buf + ext_offset + 2; + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", ext, ext_len ); + + while( ext_len != 0 ) + { + unsigned int ext_id = ( ( ext[0] << 8 ) + | ( ext[1] ) ); + unsigned int ext_size = ( ( ext[2] << 8 ) + | ( ext[3] ) ); + + if( ext_size + 4 > ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + switch( ext_id ) + { +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + case MBEDTLS_TLS_EXT_SERVERNAME: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found ServerName extension" ) ); + if( ssl->conf->f_sni == NULL ) + break; + + ret = ssl_parse_servername_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + + case MBEDTLS_TLS_EXT_RENEGOTIATION_INFO: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found renegotiation extension" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + renegotiation_info_seen = 1; +#endif + + ret = ssl_parse_renegotiation_info( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + case MBEDTLS_TLS_EXT_SIG_ALG: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found signature_algorithms extension" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + break; +#endif + + ret = ssl_parse_signature_algorithms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported elliptic curves extension" ) ); + + ret = ssl_parse_supported_elliptic_curves( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + + case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported point formats extension" ) ); + ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT; + + ret = ssl_parse_supported_point_formats( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_ECJPAKE_KKPP: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found ecjpake kkpp extension" ) ); + + ret = ssl_parse_ecjpake_kkpp( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + case MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found max fragment length extension" ) ); + + ret = ssl_parse_max_fragment_length_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + case MBEDTLS_TLS_EXT_TRUNCATED_HMAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found truncated hmac extension" ) ); + + ret = ssl_parse_truncated_hmac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + case MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found encrypt then mac extension" ) ); + + ret = ssl_parse_encrypt_then_mac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + case MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found extended master secret extension" ) ); + + ret = ssl_parse_extended_ms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + case MBEDTLS_TLS_EXT_SESSION_TICKET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found session ticket extension" ) ); + + ret = ssl_parse_session_ticket_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) + case MBEDTLS_TLS_EXT_ALPN: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found alpn extension" ) ); + + ret = ssl_parse_alpn_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "unknown extension found: %d (ignoring)", + ext_id ) ); + } + + ext_len -= 4 + ext_size; + ext += 4 + ext_size; + + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + for( i = 0, p = buf + 41 + sess_len; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) && + p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received FALLBACK_SCSV" ) ); + + if( ssl->minor_ver < ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "inapropriate fallback" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + break; + } + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + + /* + * Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ + for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "received TLS_EMPTY_RENEGOTIATION_INFO " ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV during renegotiation" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + break; + } + } + + /* + * Renegotiation security checks + */ + if( ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) ); + handshake_failure = 1; + } +#if defined(MBEDTLS_SSL_RENEGOTIATION) + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION && + renegotiation_info_seen == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension missing (secure)" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation not allowed" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + renegotiation_info_seen == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension present (legacy)" ) ); + handshake_failure = 1; + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + if( handshake_failure == 1 ) + { + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Search for a matching ciphersuite + * (At the end because we need information from the EC-based extensions + * and certificate from the SNI callback triggered by the SNI extension.) + */ + got_common_suite = 0; + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + ciphersuite_info = NULL; +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) + { + for( i = 0; ciphersuites[i] != 0; i++ ) +#else + for( i = 0; ciphersuites[i] != 0; i++ ) + { + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) +#endif + { + if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || + p[1] != ( ( ciphersuites[i] ) & 0xFF ) ) + continue; + + got_common_suite = 1; + + if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i], + &ciphersuite_info ) ) != 0 ) + return( ret ); + + if( ciphersuite_info != NULL ) + goto have_ciphersuite; + } + } + + if( got_common_suite ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got ciphersuites in common, " + "but none of them usable" ) ); + mbedtls_ssl_send_fatal_handshake_failure( ssl ); + return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no ciphersuites in common" ) ); + mbedtls_ssl_send_fatal_handshake_failure( ssl ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + +have_ciphersuite: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "selected ciphersuite: %s", ciphersuite_info->name ) ); + + ssl->session_negotiate->ciphersuite = ciphersuites[i]; + ssl->transform_negotiate->ciphersuite_info = ciphersuite_info; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_recv_flight_completed( ssl ); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +static void ssl_write_truncated_hmac_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->session_negotiate->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_DISABLED ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding truncated hmac extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_TRUNCATED_HMAC >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_TRUNCATED_HMAC ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const mbedtls_ssl_ciphersuite_t *suite = NULL; + const mbedtls_cipher_info_t *cipher = NULL; + + if( ssl->session_negotiate->encrypt_then_mac == MBEDTLS_SSL_EXTENDED_MS_DISABLED || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + *olen = 0; + return; + } + + /* + * RFC 7366: "If a server receives an encrypt-then-MAC request extension + * from a client and then selects a stream or Authenticated Encryption + * with Associated Data (AEAD) ciphersuite, it MUST NOT send an + * encrypt-then-MAC response extension back to the client." + */ + if( ( suite = mbedtls_ssl_ciphersuite_from_id( + ssl->session_negotiate->ciphersuite ) ) == NULL || + ( cipher = mbedtls_cipher_info_from_type( suite->cipher ) ) == NULL || + cipher->mode != MBEDTLS_MODE_CBC ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding encrypt then mac extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_DISABLED || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding extended master secret " + "extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->handshake->new_session_ticket == 0 ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding session ticket extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, secure renegotiation extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ) & 0xFF ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + *p++ = 0x00; + *p++ = ( ssl->verify_data_len * 2 + 1 ) & 0xFF; + *p++ = ssl->verify_data_len * 2 & 0xFF; + + memcpy( p, ssl->peer_verify_data, ssl->verify_data_len ); + p += ssl->verify_data_len; + memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); + p += ssl->verify_data_len; + } + else +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + { + *p++ = 0x00; + *p++ = 0x01; + *p++ = 0x00; + } + + *olen = p - buf; +} + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->session_negotiate->mfl_code == MBEDTLS_SSL_MAX_FRAG_LEN_NONE ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, max_fragment_length extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ) & 0xFF ); + + *p++ = 0x00; + *p++ = 1; + + *p++ = ssl->session_negotiate->mfl_code; + + *olen = 5; +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + ((void) ssl); + + if( ( ssl->handshake->cli_exts & + MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT ) == 0 ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, supported_point_formats extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ) & 0xFF ); + + *p++ = 0x00; + *p++ = 2; + + *p++ = 1; + *p++ = MBEDTLS_ECP_PF_UNCOMPRESSED; + + *olen = 6; +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + int ret; + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t kkpp_len; + + *olen = 0; + + /* Skip costly computation if not needed */ + if( ssl->transform_negotiate->ciphersuite_info->key_exchange != + MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, ecjpake kkpp extension" ) ); + + if( end - p < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ) & 0xFF ); + + ret = mbedtls_ecjpake_write_round_one( &ssl->handshake->ecjpake_ctx, + p + 2, end - p - 2, &kkpp_len, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1 , "mbedtls_ecjpake_write_round_one", ret ); + return; + } + + *p++ = (unsigned char)( ( kkpp_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( kkpp_len ) & 0xFF ); + + *olen = kkpp_len + 4; +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN ) +static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + if( ssl->alpn_chosen == NULL ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding alpn extension" ) ); + + /* + * 0 . 1 ext identifier + * 2 . 3 ext length + * 4 . 5 protocol list length + * 6 . 6 protocol name length + * 7 . 7+n protocol name + */ + buf[0] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN >> 8 ) & 0xFF ); + buf[1] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN ) & 0xFF ); + + *olen = 7 + strlen( ssl->alpn_chosen ); + + buf[2] = (unsigned char)( ( ( *olen - 4 ) >> 8 ) & 0xFF ); + buf[3] = (unsigned char)( ( ( *olen - 4 ) ) & 0xFF ); + + buf[4] = (unsigned char)( ( ( *olen - 6 ) >> 8 ) & 0xFF ); + buf[5] = (unsigned char)( ( ( *olen - 6 ) ) & 0xFF ); + + buf[6] = (unsigned char)( ( ( *olen - 7 ) ) & 0xFF ); + + memcpy( buf + 7, ssl->alpn_chosen, *olen - 7 ); +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) +static int ssl_write_hello_verify_request( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *p = ssl->out_msg + 4; + unsigned char *cookie_len_byte; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write hello verify request" ) ); + + /* + * struct { + * ProtocolVersion server_version; + * opaque cookie<0..2^8-1>; + * } HelloVerifyRequest; + */ + + /* The RFC is not clear on this point, but sending the actual negotiated + * version looks like the most interoperable thing to do. */ + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, p ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server version", p, 2 ); + p += 2; + + /* If we get here, f_cookie_check is not null */ + if( ssl->conf->f_cookie_write == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "inconsistent cookie callbacks" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* Skip length byte until we know the length */ + cookie_len_byte = p++; + + if( ( ret = ssl->conf->f_cookie_write( ssl->conf->p_cookie, + &p, ssl->out_buf + MBEDTLS_SSL_BUFFER_LEN, + ssl->cli_id, ssl->cli_id_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "f_cookie_write", ret ); + return( ret ); + } + + *cookie_len_byte = (unsigned char)( p - ( cookie_len_byte + 1 ) ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "cookie sent", cookie_len_byte + 1, *cookie_len_byte ); + + ssl->out_msglen = p - ssl->out_msg; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST; + + ssl->state = MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write hello verify request" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t t; +#endif + int ret; + size_t olen, ext_len = 0, n; + unsigned char *buf, *p; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server hello" ) ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->verify_cookie_len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "client hello was not authenticated" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello" ) ); + + return( ssl_write_hello_verify_request( ssl ) ); + } +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided") ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } + + /* + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 protocol version + * 6 . 9 UNIX time() + * 10 . 37 random bytes + */ + buf = ssl->out_msg; + p = buf + 4; + + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, p ); + p += 2; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen version: [%d:%d]", + buf[4], buf[5] ) ); + +#if defined(MBEDTLS_HAVE_TIME) + t = mbedtls_time( NULL ); + *p++ = (unsigned char)( t >> 24 ); + *p++ = (unsigned char)( t >> 16 ); + *p++ = (unsigned char)( t >> 8 ); + *p++ = (unsigned char)( t ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) ); +#else + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 ) + return( ret ); + + p += 4; +#endif /* MBEDTLS_HAVE_TIME */ + + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 ) + return( ret ); + + p += 28; + + memcpy( ssl->handshake->randbytes + 32, buf + 6, 32 ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 6, 32 ); + + /* + * Resume is 0 by default, see ssl_handshake_init(). + * It may be already set to 1 by ssl_parse_session_ticket_ext(). + * If not, try looking up session ID in our cache. + */ + if( ssl->handshake->resume == 0 && +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE && +#endif + ssl->session_negotiate->id_len != 0 && + ssl->conf->f_get_cache != NULL && + ssl->conf->f_get_cache( ssl->conf->p_cache, ssl->session_negotiate ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from cache" ) ); + ssl->handshake->resume = 1; + } + + if( ssl->handshake->resume == 0 ) + { + /* + * New session, create a new session id, + * unless we're about to issue a session ticket + */ + ssl->state++; + +#if defined(MBEDTLS_HAVE_TIME) + ssl->session_negotiate->start = mbedtls_time( NULL ); +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( ssl->handshake->new_session_ticket != 0 ) + { + ssl->session_negotiate->id_len = n = 0; + memset( ssl->session_negotiate->id, 0, 32 ); + } + else +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + { + ssl->session_negotiate->id_len = n = 32; + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id, + n ) ) != 0 ) + return( ret ); + } + } + else + { + /* + * Resuming a session + */ + n = ssl->session_negotiate->id_len; + ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + } + + /* + * 38 . 38 session id length + * 39 . 38+n session id + * 39+n . 40+n chosen ciphersuite + * 41+n . 41+n chosen compression alg. + * 42+n . 43+n extensions length + * 44+n . 43+n+m extensions + */ + *p++ = (unsigned char) ssl->session_negotiate->id_len; + memcpy( p, ssl->session_negotiate->id, ssl->session_negotiate->id_len ); + p += ssl->session_negotiate->id_len; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", + ssl->handshake->resume ? "a" : "no" ) ); + + *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite >> 8 ); + *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite ); + *p++ = (unsigned char)( ssl->session_negotiate->compression ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", + mbedtls_ssl_get_ciphersuite_name( ssl->session_negotiate->ciphersuite ) ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: 0x%02X", + ssl->session_negotiate->compression ) ); + + /* Do not write the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + + /* + * First write extensions, then the total length + */ + ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + ssl_write_max_fragment_length_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + ssl_write_truncated_hmac_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + ssl_write_encrypt_then_mac_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + ssl_write_extended_ms_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + ssl_write_session_ticket_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl_write_ecjpake_kkpp_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_ALPN) + ssl_write_alpn_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, total extension length: %d", ext_len ) ); + + if( ext_len > 0 ) + { + *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + p += ext_len; + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + + ssl->out_msglen = p - buf; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO; + + ret = mbedtls_ssl_write_record( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello" ) ); + + return( ret ); +} + +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate request" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + size_t dn_size, total_dn_size; /* excluding length bytes */ + size_t ct_len, sa_len; /* including length bytes */ + unsigned char *buf, *p; + const unsigned char * const end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const mbedtls_x509_crt *crt; + int authmode; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) ); + + ssl->state++; + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET ) + authmode = ssl->handshake->sni_authmode; + else +#endif + authmode = ssl->conf->authmode; + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE || + authmode == MBEDTLS_SSL_VERIFY_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate request" ) ); + return( 0 ); + } + + /* + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 4 cert type count + * 5 .. m-1 cert types + * m .. m+1 sig alg length (TLS 1.2 only) + * m+1 .. n-1 SignatureAndHashAlgorithms (TLS 1.2 only) + * n .. n+1 length of all DNs + * n+2 .. n+3 length of DN 1 + * n+4 .. ... Distinguished Name #1 + * ... .. ... length of DN 2, etc. + */ + buf = ssl->out_msg; + p = buf + 4; + + /* + * Supported certificate types + * + * ClientCertificateType certificate_types<1..2^8-1>; + * enum { (255) } ClientCertificateType; + */ + ct_len = 0; + +#if defined(MBEDTLS_RSA_C) + p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_RSA_SIGN; +#endif +#if defined(MBEDTLS_ECDSA_C) + p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN; +#endif + + p[0] = (unsigned char) ct_len++; + p += ct_len; + + sa_len = 0; +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + /* + * Add signature_algorithms for verify (TLS 1.2) + * + * SignatureAndHashAlgorithm supported_signature_algorithms<2..2^16-2>; + * + * struct { + * HashAlgorithm hash; + * SignatureAlgorithm signature; + * } SignatureAndHashAlgorithm; + * + * enum { (255) } HashAlgorithm; + * enum { (255) } SignatureAlgorithm; + */ + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + const int *cur; + + /* + * Supported signature algorithms + */ + for( cur = ssl->conf->sig_hashes; *cur != MBEDTLS_MD_NONE; cur++ ) + { + unsigned char hash = mbedtls_ssl_hash_from_md_alg( *cur ); + + if( MBEDTLS_SSL_HASH_NONE == hash || mbedtls_ssl_set_calc_verify_md( ssl, hash ) ) + continue; + +#if defined(MBEDTLS_RSA_C) + p[2 + sa_len++] = hash; + p[2 + sa_len++] = MBEDTLS_SSL_SIG_RSA; +#endif +#if defined(MBEDTLS_ECDSA_C) + p[2 + sa_len++] = hash; + p[2 + sa_len++] = MBEDTLS_SSL_SIG_ECDSA; +#endif + } + + p[0] = (unsigned char)( sa_len >> 8 ); + p[1] = (unsigned char)( sa_len ); + sa_len += 2; + p += sa_len; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + /* + * DistinguishedName certificate_authorities<0..2^16-1>; + * opaque DistinguishedName<1..2^16-1>; + */ + p += 2; +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_ca_chain != NULL ) + crt = ssl->handshake->sni_ca_chain; + else +#endif + crt = ssl->conf->ca_chain; + + total_dn_size = 0; + while( crt != NULL && crt->version != 0 ) + { + dn_size = crt->subject_raw.len; + + if( end < p || + (size_t)( end - p ) < dn_size || + (size_t)( end - p ) < 2 + dn_size ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "skipping CAs: buffer too short" ) ); + break; + } + + *p++ = (unsigned char)( dn_size >> 8 ); + *p++ = (unsigned char)( dn_size ); + memcpy( p, crt->subject_raw.p, dn_size ); + p += dn_size; + + MBEDTLS_SSL_DEBUG_BUF( 3, "requested DN", p - dn_size, dn_size ); + + total_dn_size += 2 + dn_size; + crt = crt->next; + } + + ssl->out_msglen = p - buf; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_REQUEST; + ssl->out_msg[4 + ct_len + sa_len] = (unsigned char)( total_dn_size >> 8 ); + ssl->out_msg[5 + ct_len + sa_len] = (unsigned char)( total_dn_size ); + + ret = mbedtls_ssl_write_record( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write certificate request" ) ); + + return( ret ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl ) +{ + int ret; + + if( ! mbedtls_pk_can_do( mbedtls_ssl_own_key( ssl ), MBEDTLS_PK_ECKEY ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key not ECDH capable" ) ); + return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH ); + } + + if( ( ret = mbedtls_ecdh_get_params( &ssl->handshake->ecdh_ctx, + mbedtls_pk_ec( *mbedtls_ssl_own_key( ssl ) ), + MBEDTLS_ECDH_OURS ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_get_params" ), ret ); + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t n = 0; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = + ssl->transform_negotiate->ciphersuite_info; + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + unsigned char *p = ssl->out_msg + 4; + unsigned char *dig_signed = p; + size_t dig_signed_len = 0, len; + ((void) dig_signed); + ((void) dig_signed_len); + ((void) len); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); + ssl->state++; + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA ) + { + ssl_get_ecdh_params_from_cert( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); + ssl->state++; + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + size_t jlen; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx, + p, end - p, &jlen, ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_write_round_two", ret ); + return( ret ); + } + + p += jlen; + n += jlen; + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + /* Note: we don't support identity hints, until someone asks + * for them. */ + *(p++) = 0x00; + *(p++) = 0x00; + + n += 2; + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + if( ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no DH parameters set" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + /* + * Ephemeral DH parameters: + * + * struct { + * opaque dh_p<1..2^16-1>; + * opaque dh_g<1..2^16-1>; + * opaque dh_Ys<1..2^16-1>; + * } ServerDHParams; + */ + if( ( ret = mbedtls_mpi_copy( &ssl->handshake->dhm_ctx.P, &ssl->conf->dhm_P ) ) != 0 || + ( ret = mbedtls_mpi_copy( &ssl->handshake->dhm_ctx.G, &ssl->conf->dhm_G ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_mpi_copy", ret ); + return( ret ); + } + + if( ( ret = mbedtls_dhm_make_params( &ssl->handshake->dhm_ctx, + (int) mbedtls_mpi_size( &ssl->handshake->dhm_ctx.P ), + p, &len, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_make_params", ret ); + return( ret ); + } + + dig_signed = p; + dig_signed_len = len; + + p += len; + n += len; + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->handshake->dhm_ctx.X ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: P ", &ssl->handshake->dhm_ctx.P ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: G ", &ssl->handshake->dhm_ctx.G ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->handshake->dhm_ctx.GX ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + /* + * Ephemeral ECDH parameters: + * + * struct { + * ECParameters curve_params; + * ECPoint public; + * } ServerECDHParams; + */ + const mbedtls_ecp_curve_info **curve = NULL; + const mbedtls_ecp_group_id *gid; + + /* Match our preference list against the offered curves */ + for( gid = ssl->conf->curve_list; *gid != MBEDTLS_ECP_DP_NONE; gid++ ) + for( curve = ssl->handshake->curves; *curve != NULL; curve++ ) + if( (*curve)->grp_id == *gid ) + goto curve_matching_done; + +curve_matching_done: + if( curve == NULL || *curve == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no matching curve for ECDHE" ) ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDHE curve: %s", (*curve)->name ) ); + + if( ( ret = mbedtls_ecp_group_load( &ssl->handshake->ecdh_ctx.grp, + (*curve)->grp_id ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecp_group_load", ret ); + return( ret ); + } + + if( ( ret = mbedtls_ecdh_make_params( &ssl->handshake->ecdh_ctx, &len, + p, MBEDTLS_SSL_MAX_CONTENT_LEN - n, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_make_params", ret ); + return( ret ); + } + + dig_signed = p; + dig_signed_len = len; + + p += len; + n += len; + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q ", &ssl->handshake->ecdh_ctx.Q ); + } +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ) + { + size_t signature_len = 0; + unsigned int hashlen = 0; + unsigned char hash[64]; + mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE; + + /* + * Choose hash algorithm. NONE means MD5 + SHA1 here. + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + md_alg = mbedtls_ssl_md_alg_from_hash( ssl->handshake->sig_alg ); + + if( md_alg == MBEDTLS_MD_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ciphersuite_info->key_exchange == + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ) + { + md_alg = MBEDTLS_MD_SHA1; + } + else +#endif + { + md_alg = MBEDTLS_MD_NONE; + } + + /* + * Compute the hash to be signed + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( md_alg == MBEDTLS_MD_NONE ) + { + mbedtls_md5_context mbedtls_md5; + mbedtls_sha1_context mbedtls_sha1; + + mbedtls_md5_init( &mbedtls_md5 ); + mbedtls_sha1_init( &mbedtls_sha1 ); + + /* + * digitally-signed struct { + * opaque md5_hash[16]; + * opaque sha_hash[20]; + * }; + * + * md5_hash + * MD5(ClientHello.random + ServerHello.random + * + ServerParams); + * sha_hash + * SHA(ClientHello.random + ServerHello.random + * + ServerParams); + */ + mbedtls_md5_starts( &mbedtls_md5 ); + mbedtls_md5_update( &mbedtls_md5, ssl->handshake->randbytes, 64 ); + mbedtls_md5_update( &mbedtls_md5, dig_signed, dig_signed_len ); + mbedtls_md5_finish( &mbedtls_md5, hash ); + + mbedtls_sha1_starts( &mbedtls_sha1 ); + mbedtls_sha1_update( &mbedtls_sha1, ssl->handshake->randbytes, 64 ); + mbedtls_sha1_update( &mbedtls_sha1, dig_signed, dig_signed_len ); + mbedtls_sha1_finish( &mbedtls_sha1, hash + 16 ); + + hashlen = 36; + + mbedtls_md5_free( &mbedtls_md5 ); + mbedtls_sha1_free( &mbedtls_sha1 ); + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \ + MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( md_alg != MBEDTLS_MD_NONE ) + { + mbedtls_md_context_t ctx; + const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); + + mbedtls_md_init( &ctx ); + + /* Info from md_alg will be used instead */ + hashlen = 0; + + /* + * digitally-signed struct { + * opaque client_random[32]; + * opaque server_random[32]; + * ServerDHParams params; + * }; + */ + if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret ); + return( ret ); + } + + mbedtls_md_starts( &ctx ); + mbedtls_md_update( &ctx, ssl->handshake->randbytes, 64 ); + mbedtls_md_update( &ctx, dig_signed, dig_signed_len ); + mbedtls_md_finish( &ctx, hash ); + mbedtls_md_free( &ctx ); + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ + MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen : + (unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) ); + + /* + * Make the signature + */ + if( mbedtls_ssl_own_key( ssl ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no private key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + *(p++) = ssl->handshake->sig_alg; + *(p++) = mbedtls_ssl_sig_from_pk( mbedtls_ssl_own_key( ssl ) ); + + n += 2; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash, hashlen, + p + 2 , &signature_len, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_sign", ret ); + return( ret ); + } + + *(p++) = (unsigned char)( signature_len >> 8 ); + *(p++) = (unsigned char)( signature_len ); + n += 2; + + MBEDTLS_SSL_DEBUG_BUF( 3, "my signature", p, signature_len ); + + n += signature_len; + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + + ssl->out_msglen = 4 + n; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE; + + ssl->state++; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server key exchange" ) ); + + return( 0 ); +} + +static int ssl_write_server_hello_done( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server hello done" ) ); + + ssl->out_msglen = 4; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO_DONE; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_send_flight_completed( ssl ); +#endif + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello done" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +static int ssl_parse_client_dh_public( mbedtls_ssl_context *ssl, unsigned char **p, + const unsigned char *end ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t n; + + /* + * Receive G^Y mod P, premaster = (G^Y)^X mod P + */ + if( *p + 2 > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + n = ( (*p)[0] << 8 ) | (*p)[1]; + *p += 2; + + if( *p + n > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_dhm_read_public( &ssl->handshake->dhm_ctx, *p, n ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_read_public", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); + } + + *p += n; + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GY", &ssl->handshake->dhm_ctx.GY ); + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) +static int ssl_parse_encrypted_pms( mbedtls_ssl_context *ssl, + const unsigned char *p, + const unsigned char *end, + size_t pms_offset ) +{ + int ret; + size_t len = mbedtls_pk_get_len( mbedtls_ssl_own_key( ssl ) ); + unsigned char *pms = ssl->handshake->premaster + pms_offset; + unsigned char ver[2]; + unsigned char fake_pms[48], peer_pms[48]; + unsigned char mask; + size_t i, peer_pmslen; + unsigned int diff; + + if( ! mbedtls_pk_can_do( mbedtls_ssl_own_key( ssl ), MBEDTLS_PK_RSA ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no RSA private key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + /* + * Decrypt the premaster using own private RSA key + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + if( *p++ != ( ( len >> 8 ) & 0xFF ) || + *p++ != ( ( len ) & 0xFF ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + } +#endif + + if( p + len != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + mbedtls_ssl_write_version( ssl->handshake->max_major_ver, + ssl->handshake->max_minor_ver, + ssl->conf->transport, ver ); + + /* + * Protection against Bleichenbacher's attack: invalid PKCS#1 v1.5 padding + * must not cause the connection to end immediately; instead, send a + * bad_record_mac later in the handshake. + * Also, avoid data-dependant branches here to protect against + * timing-based variants. + */ + ret = ssl->conf->f_rng( ssl->conf->p_rng, fake_pms, sizeof( fake_pms ) ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_pk_decrypt( mbedtls_ssl_own_key( ssl ), p, len, + peer_pms, &peer_pmslen, + sizeof( peer_pms ), + ssl->conf->f_rng, ssl->conf->p_rng ); + + diff = (unsigned int) ret; + diff |= peer_pmslen ^ 48; + diff |= peer_pms[0] ^ ver[0]; + diff |= peer_pms[1] ^ ver[1]; + +#if defined(MBEDTLS_SSL_DEBUG_ALL) + if( diff != 0 ) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); +#endif + + if( sizeof( ssl->handshake->premaster ) < pms_offset || + sizeof( ssl->handshake->premaster ) - pms_offset < 48 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + ssl->handshake->pmslen = 48; + + /* mask = diff ? 0xff : 0x00 using bit operations to avoid branches */ + /* MSVC has a warning about unary minus on unsigned, but this is + * well-defined and precisely what we want to do here */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + mask = - ( ( diff | - diff ) >> ( sizeof( unsigned int ) * 8 - 1 ) ); +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + + for( i = 0; i < ssl->handshake->pmslen; i++ ) + pms[i] = ( mask & fake_pms[i] ) | ( (~mask) & peer_pms[i] ); + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned char **p, + const unsigned char *end ) +{ + int ret = 0; + size_t n; + + if( ssl->conf->f_psk == NULL && + ( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL || + ssl->conf->psk_identity_len == 0 || ssl->conf->psk_len == 0 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no pre-shared key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + /* + * Receive client pre-shared key identity name + */ + if( *p + 2 > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + n = ( (*p)[0] << 8 ) | (*p)[1]; + *p += 2; + + if( n < 1 || n > 65535 || *p + n > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ssl->conf->f_psk != NULL ) + { + if( ssl->conf->f_psk( ssl->conf->p_psk, ssl, *p, n ) != 0 ) + ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY; + } + else + { + /* Identity is not a big secret since clients send it in the clear, + * but treat it carefully anyway, just in case */ + if( n != ssl->conf->psk_identity_len || + mbedtls_ssl_safer_memcmp( ssl->conf->psk_identity, *p, n ) != 0 ) + { + ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY; + } + } + + if( ret == MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY ) + { + MBEDTLS_SSL_DEBUG_BUF( 3, "Unknown PSK identity", *p, n ); + if( ( ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY ) ) != 0 ) + { + return( ret ); + } + + return( MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY ); + } + + *p += n; + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + unsigned char *p, *end; + + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client key exchange" ) ); + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); + end = ssl->in_msg + ssl->in_hslen; + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA ) + { + if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_dh_public" ), ret ); + return( ret ); + } + + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_dhm_calc_secret( &ssl->handshake->dhm_ctx, + ssl->handshake->premaster, + MBEDTLS_PREMASTER_SIZE, + &ssl->handshake->pmslen, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA ) + { + if( ( ret = mbedtls_ecdh_read_public( &ssl->handshake->ecdh_ctx, + p, end - p) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_read_public", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); + } + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp ", &ssl->handshake->ecdh_ctx.Qp ); + + if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, + &ssl->handshake->pmslen, + ssl->handshake->premaster, + MBEDTLS_MPI_MAX_SIZE, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z ", &ssl->handshake->ecdh_ctx.z ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + + if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 2 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_encrypted_pms" ), ret ); + return( ret ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_dh_public" ), ret ); + return( ret ); + } + + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + + if( ( ret = mbedtls_ecdh_read_public( &ssl->handshake->ecdh_ctx, + p, end - p ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_read_public", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); + } + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp ", &ssl->handshake->ecdh_ctx.Qp ); + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA ) + { + if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_parse_encrypted_pms_secret" ), ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + ret = mbedtls_ecjpake_read_round_two( &ssl->handshake->ecjpake_ctx, + p, end - p ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_two", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + ret = mbedtls_ecjpake_derive_secret( &ssl->handshake->ecjpake_ctx, + ssl->handshake->premaster, 32, &ssl->handshake->pmslen, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_derive_secret", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client key exchange" ) ); + + return( 0 ); +} + +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t i, sig_len; + unsigned char hash[48]; + unsigned char *hash_start = hash; + size_t hashlen; +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + mbedtls_pk_type_t pk_alg; +#endif + mbedtls_md_type_t md_alg; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE || + ssl->session_negotiate->peer_cert == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + /* Read the message without adding it to the checksum */ + do { + + if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret ); + return( ret ); + } + + ret = mbedtls_ssl_handle_message_type( ssl ); + + } while( MBEDTLS_ERR_SSL_NON_FATAL == ret ); + + if( 0 != ret ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_handle_message_type" ), ret ); + return( ret ); + } + + ssl->state++; + + /* Process the message contents */ + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || + ssl->in_msg[0] != MBEDTLS_SSL_HS_CERTIFICATE_VERIFY ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + i = mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * struct { + * SignatureAndHashAlgorithm algorithm; -- TLS 1.2 only + * opaque signature<0..2^16-1>; + * } DigitallySigned; + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 ) + { + md_alg = MBEDTLS_MD_NONE; + hashlen = 36; + + /* For ECDSA, use SHA-1, not MD-5 + SHA-1 */ + if( mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, + MBEDTLS_PK_ECDSA ) ) + { + hash_start += 16; + hashlen -= 16; + md_alg = MBEDTLS_MD_SHA1; + } + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || + MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + if( i + 2 > ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + /* + * Hash + */ + md_alg = mbedtls_ssl_md_alg_from_hash( ssl->in_msg[i] ); + + if( md_alg == MBEDTLS_MD_NONE || mbedtls_ssl_set_calc_verify_md( ssl, ssl->in_msg[i] ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "peer not adhering to requested sig_alg" + " for verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + +#if !defined(MBEDTLS_MD_SHA1) + if( MBEDTLS_MD_SHA1 == md_alg ) + hash_start += 16; +#endif + + /* Info from md_alg will be used instead */ + hashlen = 0; + + i++; + + /* + * Signature + */ + if( ( pk_alg = mbedtls_ssl_pk_alg_from_sig( ssl->in_msg[i] ) ) + == MBEDTLS_PK_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "peer not adhering to requested sig_alg" + " for verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + /* + * Check the certificate's key type matches the signature alg + */ + if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, pk_alg ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "sig_alg doesn't match cert key" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + i++; + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( i + 2 > ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + sig_len = ( ssl->in_msg[i] << 8 ) | ssl->in_msg[i+1]; + i += 2; + + if( i + sig_len != ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + /* Calculate hash and verify signature */ + ssl->handshake->calc_verify( ssl, hash ); + + if( ( ret = mbedtls_pk_verify( &ssl->session_negotiate->peer_cert->pk, + md_alg, hash_start, hashlen, + ssl->in_msg + i, sig_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify", ret ); + return( ret ); + } + + mbedtls_ssl_update_handshake_status( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate verify" ) ); + + return( ret ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t tlen; + uint32_t lifetime; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write new session ticket" ) ); + + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_NEW_SESSION_TICKET; + + /* + * struct { + * uint32 ticket_lifetime_hint; + * opaque ticket<0..2^16-1>; + * } NewSessionTicket; + * + * 4 . 7 ticket_lifetime_hint (0 = unspecified) + * 8 . 9 ticket_len (n) + * 10 . 9+n ticket content + */ + + if( ( ret = ssl->conf->f_ticket_write( ssl->conf->p_ticket, + ssl->session_negotiate, + ssl->out_msg + 10, + ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN, + &tlen, &lifetime ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_ticket_write", ret ); + tlen = 0; + } + + ssl->out_msg[4] = ( lifetime >> 24 ) & 0xFF; + ssl->out_msg[5] = ( lifetime >> 16 ) & 0xFF; + ssl->out_msg[6] = ( lifetime >> 8 ) & 0xFF; + ssl->out_msg[7] = ( lifetime ) & 0xFF; + + ssl->out_msg[8] = (unsigned char)( ( tlen >> 8 ) & 0xFF ); + ssl->out_msg[9] = (unsigned char)( ( tlen ) & 0xFF ); + + ssl->out_msglen = 10 + tlen; + + /* + * Morally equivalent to updating ssl->state, but NewSessionTicket and + * ChangeCipherSpec share the same state. + */ + ssl->handshake->new_session_ticket = 0; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write new session ticket" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +/* + * SSL handshake -- server side -- single step + */ +int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "server state: %d", ssl->state ) ); + + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) + { + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + return( ret ); + } +#endif + + switch( ssl->state ) + { + case MBEDTLS_SSL_HELLO_REQUEST: + ssl->state = MBEDTLS_SSL_CLIENT_HELLO; + break; + + /* + * <== ClientHello + */ + case MBEDTLS_SSL_CLIENT_HELLO: + ret = ssl_parse_client_hello( ssl ); + break; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + case MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT: + return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ); +#endif + + /* + * ==> ServerHello + * Certificate + * ( ServerKeyExchange ) + * ( CertificateRequest ) + * ServerHelloDone + */ + case MBEDTLS_SSL_SERVER_HELLO: + ret = ssl_write_server_hello( ssl ); + break; + + case MBEDTLS_SSL_SERVER_CERTIFICATE: + ret = mbedtls_ssl_write_certificate( ssl ); + break; + + case MBEDTLS_SSL_SERVER_KEY_EXCHANGE: + ret = ssl_write_server_key_exchange( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_REQUEST: + ret = ssl_write_certificate_request( ssl ); + break; + + case MBEDTLS_SSL_SERVER_HELLO_DONE: + ret = ssl_write_server_hello_done( ssl ); + break; + + /* + * <== ( Certificate/Alert ) + * ClientKeyExchange + * ( CertificateVerify ) + * ChangeCipherSpec + * Finished + */ + case MBEDTLS_SSL_CLIENT_CERTIFICATE: + ret = mbedtls_ssl_parse_certificate( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_KEY_EXCHANGE: + ret = ssl_parse_client_key_exchange( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_VERIFY: + ret = ssl_parse_certificate_verify( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC: + ret = mbedtls_ssl_parse_change_cipher_spec( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_FINISHED: + ret = mbedtls_ssl_parse_finished( ssl ); + break; + + /* + * ==> ( NewSessionTicket ) + * ChangeCipherSpec + * Finished + */ + case MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC: +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( ssl->handshake->new_session_ticket != 0 ) + ret = ssl_write_new_session_ticket( ssl ); + else +#endif + ret = mbedtls_ssl_write_change_cipher_spec( ssl ); + break; + + case MBEDTLS_SSL_SERVER_FINISHED: + ret = mbedtls_ssl_write_finished( ssl ); + break; + + case MBEDTLS_SSL_FLUSH_BUFFERS: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "handshake: done" ) ); + ssl->state = MBEDTLS_SSL_HANDSHAKE_WRAPUP; + break; + + case MBEDTLS_SSL_HANDSHAKE_WRAPUP: + mbedtls_ssl_handshake_wrapup( ssl ); + break; + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + return( ret ); +} +#endif /* MBEDTLS_SSL_SRV_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ticket.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ticket.c new file mode 100644 index 0000000..4d9116d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_ticket.c @@ -0,0 +1,489 @@ +/* + * TLS server tickets callbacks implementation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_TICKET_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/ssl_ticket.h" + +#include + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Initialze context + */ +void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_ssl_ticket_context ) ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_init( &ctx->mutex ); +#endif +} + +#define MAX_KEY_BYTES 32 /* 256 bits */ + +/* + * Generate/update a key + */ +static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx, + unsigned char index ) +{ + int ret; + unsigned char buf[MAX_KEY_BYTES]; + mbedtls_ssl_ticket_key *key = ctx->keys + index; + +#if defined(MBEDTLS_HAVE_TIME) + key->generation_time = (uint32_t) mbedtls_time( NULL ); +#endif + + if( ( ret = ctx->f_rng( ctx->p_rng, key->name, sizeof( key->name ) ) ) != 0 ) + return( ret ); + + if( ( ret = ctx->f_rng( ctx->p_rng, buf, sizeof( buf ) ) ) != 0 ) + return( ret ); + + /* With GCM and CCM, same context can encrypt & decrypt */ + ret = mbedtls_cipher_setkey( &key->ctx, buf, + mbedtls_cipher_get_key_bitlen( &key->ctx ), + MBEDTLS_ENCRYPT ); + + mbedtls_zeroize( buf, sizeof( buf ) ); + + return( ret ); +} + +/* + * Rotate/generate keys if necessary + */ +static int ssl_ticket_update_keys( mbedtls_ssl_ticket_context *ctx ) +{ +#if !defined(MBEDTLS_HAVE_TIME) + ((void) ctx); +#else + if( ctx->ticket_lifetime != 0 ) + { + uint32_t current_time = (uint32_t) mbedtls_time( NULL ); + uint32_t key_time = ctx->keys[ctx->active].generation_time; + + if( current_time > key_time && + current_time - key_time < ctx->ticket_lifetime ) + { + return( 0 ); + } + + ctx->active = 1 - ctx->active; + + return( ssl_ticket_gen_key( ctx, ctx->active ) ); + } + else +#endif /* MBEDTLS_HAVE_TIME */ + return( 0 ); +} + +/* + * Setup context for actual use + */ +int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_cipher_type_t cipher, + uint32_t lifetime ) +{ + int ret; + const mbedtls_cipher_info_t *cipher_info; + + ctx->f_rng = f_rng; + ctx->p_rng = p_rng; + + ctx->ticket_lifetime = lifetime; + + cipher_info = mbedtls_cipher_info_from_type( cipher); + if( cipher_info == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( cipher_info->mode != MBEDTLS_MODE_GCM && + cipher_info->mode != MBEDTLS_MODE_CCM ) + { + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + if( cipher_info->key_bitlen > 8 * MAX_KEY_BYTES ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_cipher_setup( &ctx->keys[0].ctx, cipher_info ) ) != 0 || + ( ret = mbedtls_cipher_setup( &ctx->keys[1].ctx, cipher_info ) ) != 0 ) + { + return( ret ); + } + + if( ( ret = ssl_ticket_gen_key( ctx, 0 ) ) != 0 || + ( ret = ssl_ticket_gen_key( ctx, 1 ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} + +/* + * Serialize a session in the following format: + * 0 . n-1 session structure, n = sizeof(mbedtls_ssl_session) + * n . n+2 peer_cert length = m (0 if no certificate) + * n+3 . n+2+m peer cert ASN.1 + */ +static int ssl_save_session( const mbedtls_ssl_session *session, + unsigned char *buf, size_t buf_len, + size_t *olen ) +{ + unsigned char *p = buf; + size_t left = buf_len; +#if defined(MBEDTLS_X509_CRT_PARSE_C) + size_t cert_len; +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + if( left < sizeof( mbedtls_ssl_session ) ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + memcpy( p, session, sizeof( mbedtls_ssl_session ) ); + p += sizeof( mbedtls_ssl_session ); + left -= sizeof( mbedtls_ssl_session ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( session->peer_cert == NULL ) + cert_len = 0; + else + cert_len = session->peer_cert->raw.len; + + if( left < 3 + cert_len ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + *p++ = (unsigned char)( cert_len >> 16 & 0xFF ); + *p++ = (unsigned char)( cert_len >> 8 & 0xFF ); + *p++ = (unsigned char)( cert_len & 0xFF ); + + if( session->peer_cert != NULL ) + memcpy( p, session->peer_cert->raw.p, cert_len ); + + p += cert_len; +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + *olen = p - buf; + + return( 0 ); +} + +/* + * Unserialise session, see ssl_save_session() + */ +static int ssl_load_session( mbedtls_ssl_session *session, + const unsigned char *buf, size_t len ) +{ + const unsigned char *p = buf; + const unsigned char * const end = buf + len; +#if defined(MBEDTLS_X509_CRT_PARSE_C) + size_t cert_len; +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + if( p + sizeof( mbedtls_ssl_session ) > end ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + memcpy( session, p, sizeof( mbedtls_ssl_session ) ); + p += sizeof( mbedtls_ssl_session ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( p + 3 > end ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + cert_len = ( p[0] << 16 ) | ( p[1] << 8 ) | p[2]; + p += 3; + + if( cert_len == 0 ) + { + session->peer_cert = NULL; + } + else + { + int ret; + + if( p + cert_len > end ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + session->peer_cert = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ); + + if( session->peer_cert == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + mbedtls_x509_crt_init( session->peer_cert ); + + if( ( ret = mbedtls_x509_crt_parse_der( session->peer_cert, + p, cert_len ) ) != 0 ) + { + mbedtls_x509_crt_free( session->peer_cert ); + mbedtls_free( session->peer_cert ); + session->peer_cert = NULL; + return( ret ); + } + + p += cert_len; + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + if( p != end ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + return( 0 ); +} + +/* + * Create session ticket, with the following structure: + * + * struct { + * opaque key_name[4]; + * opaque iv[12]; + * opaque encrypted_state<0..2^16-1>; + * opaque tag[16]; + * } ticket; + * + * The key_name, iv, and length of encrypted_state are the additional + * authenticated data. + */ +int mbedtls_ssl_ticket_write( void *p_ticket, + const mbedtls_ssl_session *session, + unsigned char *start, + const unsigned char *end, + size_t *tlen, + uint32_t *ticket_lifetime ) +{ + int ret; + mbedtls_ssl_ticket_context *ctx = p_ticket; + mbedtls_ssl_ticket_key *key; + unsigned char *key_name = start; + unsigned char *iv = start + 4; + unsigned char *state_len_bytes = iv + 12; + unsigned char *state = state_len_bytes + 2; + unsigned char *tag; + size_t clear_len, ciph_len; + + *tlen = 0; + + if( ctx == NULL || ctx->f_rng == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + /* We need at least 4 bytes for key_name, 12 for IV, 2 for len 16 for tag, + * in addition to session itself, that will be checked when writing it. */ + if( end - start < 4 + 12 + 2 + 16 ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + if( ( ret = ssl_ticket_update_keys( ctx ) ) != 0 ) + goto cleanup; + + key = &ctx->keys[ctx->active]; + + *ticket_lifetime = ctx->ticket_lifetime; + + memcpy( key_name, key->name, 4 ); + + if( ( ret = ctx->f_rng( ctx->p_rng, iv, 12 ) ) != 0 ) + goto cleanup; + + /* Dump session state */ + if( ( ret = ssl_save_session( session, + state, end - state, &clear_len ) ) != 0 || + (unsigned long) clear_len > 65535 ) + { + goto cleanup; + } + state_len_bytes[0] = ( clear_len >> 8 ) & 0xff; + state_len_bytes[1] = ( clear_len ) & 0xff; + + /* Encrypt and authenticate */ + tag = state + clear_len; + if( ( ret = mbedtls_cipher_auth_encrypt( &key->ctx, + iv, 12, key_name, 4 + 12 + 2, + state, clear_len, state, &ciph_len, tag, 16 ) ) != 0 ) + { + goto cleanup; + } + if( ciph_len != clear_len ) + { + ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; + goto cleanup; + } + + *tlen = 4 + 12 + 2 + 16 + ciph_len; + +cleanup: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +/* + * Select key based on name + */ +static mbedtls_ssl_ticket_key *ssl_ticket_select_key( + mbedtls_ssl_ticket_context *ctx, + const unsigned char name[4] ) +{ + unsigned char i; + + for( i = 0; i < sizeof( ctx->keys ) / sizeof( *ctx->keys ); i++ ) + if( memcmp( name, ctx->keys[i].name, 4 ) == 0 ) + return( &ctx->keys[i] ); + + return( NULL ); +} + +/* + * Load session ticket (see mbedtls_ssl_ticket_write for structure) + */ +int mbedtls_ssl_ticket_parse( void *p_ticket, + mbedtls_ssl_session *session, + unsigned char *buf, + size_t len ) +{ + int ret; + mbedtls_ssl_ticket_context *ctx = p_ticket; + mbedtls_ssl_ticket_key *key; + unsigned char *key_name = buf; + unsigned char *iv = buf + 4; + unsigned char *enc_len_p = iv + 12; + unsigned char *ticket = enc_len_p + 2; + unsigned char *tag; + size_t enc_len, clear_len; + + if( ctx == NULL || ctx->f_rng == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + /* See mbedtls_ssl_ticket_write() */ + if( len < 4 + 12 + 2 + 16 ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_THREADING_C) + if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) + return( ret ); +#endif + + if( ( ret = ssl_ticket_update_keys( ctx ) ) != 0 ) + goto cleanup; + + enc_len = ( enc_len_p[0] << 8 ) | enc_len_p[1]; + tag = ticket + enc_len; + + if( len != 4 + 12 + 2 + enc_len + 16 ) + { + ret = MBEDTLS_ERR_SSL_BAD_INPUT_DATA; + goto cleanup; + } + + /* Select key */ + if( ( key = ssl_ticket_select_key( ctx, key_name ) ) == NULL ) + { + /* We can't know for sure but this is a likely option unless we're + * under attack - this is only informative anyway */ + ret = MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED; + goto cleanup; + } + + /* Decrypt and authenticate */ + if( ( ret = mbedtls_cipher_auth_decrypt( &key->ctx, iv, 12, + key_name, 4 + 12 + 2, ticket, enc_len, + ticket, &clear_len, tag, 16 ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED ) + ret = MBEDTLS_ERR_SSL_INVALID_MAC; + + goto cleanup; + } + if( clear_len != enc_len ) + { + ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; + goto cleanup; + } + + /* Actually load session */ + if( ( ret = ssl_load_session( session, ticket, clear_len ) ) != 0 ) + goto cleanup; + +#if defined(MBEDTLS_HAVE_TIME) + { + /* Check for expiration */ + mbedtls_time_t current_time = mbedtls_time( NULL ); + + if( current_time < session->start || + (uint32_t)( current_time - session->start ) > ctx->ticket_lifetime ) + { + ret = MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED; + goto cleanup; + } + } +#endif + +cleanup: +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} + +/* + * Free context + */ +void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ) +{ + mbedtls_cipher_free( &ctx->keys[0].ctx ); + mbedtls_cipher_free( &ctx->keys[1].ctx ); + +#if defined(MBEDTLS_THREADING_C) + mbedtls_mutex_free( &ctx->mutex ); +#endif + + mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_ticket_context ) ); +} + +#endif /* MBEDTLS_SSL_TICKET_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_tls.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_tls.c new file mode 100644 index 0000000..d9ab832 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/ssl_tls.c @@ -0,0 +1,7687 @@ +/* + * SSLv3/TLSv1 shared functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The SSL 3.0 specification was drafted by Netscape in 1996, + * and became an IETF standard in 1999. + * + * http://wp.netscape.com/eng/ssl3/ + * http://www.ietf.org/rfc/rfc2246.txt + * http://www.ietf.org/rfc/rfc4346.txt + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_TLS_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_internal.h" + +#include + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +#include "mbedtls/oid.h" +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* Length of the "epoch" field in the record header */ +static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + return( 2 ); +#else + ((void) ssl); +#endif + return( 0 ); +} + +/* + * Start a timer. + * Passing millisecs = 0 cancels a running timer. + */ +static void ssl_set_timer( mbedtls_ssl_context *ssl, uint32_t millisecs ) +{ + if( ssl->f_set_timer == NULL ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "set_timer to %d ms", (int) millisecs ) ); + ssl->f_set_timer( ssl->p_timer, millisecs / 4, millisecs ); +} + +/* + * Return -1 is timer is expired, 0 if it isn't. + */ +static int ssl_check_timer( mbedtls_ssl_context *ssl ) +{ + if( ssl->f_get_timer == NULL ) + return( 0 ); + + if( ssl->f_get_timer( ssl->p_timer ) == 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "timer expired" ) ); + return( -1 ); + } + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +/* + * Double the retransmit timeout value, within the allowed range, + * returning -1 if the maximum value has already been reached. + */ +static int ssl_double_retransmit_timeout( mbedtls_ssl_context *ssl ) +{ + uint32_t new_timeout; + + if( ssl->handshake->retransmit_timeout >= ssl->conf->hs_timeout_max ) + return( -1 ); + + new_timeout = 2 * ssl->handshake->retransmit_timeout; + + /* Avoid arithmetic overflow and range overflow */ + if( new_timeout < ssl->handshake->retransmit_timeout || + new_timeout > ssl->conf->hs_timeout_max ) + { + new_timeout = ssl->conf->hs_timeout_max; + } + + ssl->handshake->retransmit_timeout = new_timeout; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "update timeout value to %d millisecs", + ssl->handshake->retransmit_timeout ) ); + + return( 0 ); +} + +static void ssl_reset_retransmit_timeout( mbedtls_ssl_context *ssl ) +{ + ssl->handshake->retransmit_timeout = ssl->conf->hs_timeout_min; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "update timeout value to %d millisecs", + ssl->handshake->retransmit_timeout ) ); +} +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +/* + * Convert max_fragment_length codes to length. + * RFC 6066 says: + * enum{ + * 2^9(1), 2^10(2), 2^11(3), 2^12(4), (255) + * } MaxFragmentLength; + * and we add 0 -> extension unused + */ +static unsigned int mfl_code_to_length[MBEDTLS_SSL_MAX_FRAG_LEN_INVALID] = +{ + MBEDTLS_SSL_MAX_CONTENT_LEN, /* MBEDTLS_SSL_MAX_FRAG_LEN_NONE */ + 512, /* MBEDTLS_SSL_MAX_FRAG_LEN_512 */ + 1024, /* MBEDTLS_SSL_MAX_FRAG_LEN_1024 */ + 2048, /* MBEDTLS_SSL_MAX_FRAG_LEN_2048 */ + 4096, /* MBEDTLS_SSL_MAX_FRAG_LEN_4096 */ +}; +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_CLI_C) +static int ssl_session_copy( mbedtls_ssl_session *dst, const mbedtls_ssl_session *src ) +{ + mbedtls_ssl_session_free( dst ); + memcpy( dst, src, sizeof( mbedtls_ssl_session ) ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( src->peer_cert != NULL ) + { + int ret; + + dst->peer_cert = mbedtls_calloc( 1, sizeof(mbedtls_x509_crt) ); + if( dst->peer_cert == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + mbedtls_x509_crt_init( dst->peer_cert ); + + if( ( ret = mbedtls_x509_crt_parse_der( dst->peer_cert, src->peer_cert->raw.p, + src->peer_cert->raw.len ) ) != 0 ) + { + mbedtls_free( dst->peer_cert ); + dst->peer_cert = NULL; + return( ret ); + } + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) + if( src->ticket != NULL ) + { + dst->ticket = mbedtls_calloc( 1, src->ticket_len ); + if( dst->ticket == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + memcpy( dst->ticket, src->ticket, src->ticket_len ); + } +#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ + + return( 0 ); +} +#endif /* MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) +int (*mbedtls_ssl_hw_record_init)( mbedtls_ssl_context *ssl, + const unsigned char *key_enc, const unsigned char *key_dec, + size_t keylen, + const unsigned char *iv_enc, const unsigned char *iv_dec, + size_t ivlen, + const unsigned char *mac_enc, const unsigned char *mac_dec, + size_t maclen ) = NULL; +int (*mbedtls_ssl_hw_record_activate)( mbedtls_ssl_context *ssl, int direction) = NULL; +int (*mbedtls_ssl_hw_record_reset)( mbedtls_ssl_context *ssl ) = NULL; +int (*mbedtls_ssl_hw_record_write)( mbedtls_ssl_context *ssl ) = NULL; +int (*mbedtls_ssl_hw_record_read)( mbedtls_ssl_context *ssl ) = NULL; +int (*mbedtls_ssl_hw_record_finish)( mbedtls_ssl_context *ssl ) = NULL; +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ + +/* + * Key material generation + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) +static int ssl3_prf( const unsigned char *secret, size_t slen, + const char *label, + const unsigned char *random, size_t rlen, + unsigned char *dstbuf, size_t dlen ) +{ + size_t i; + mbedtls_md5_context md5; + mbedtls_sha1_context sha1; + unsigned char padding[16]; + unsigned char sha1sum[20]; + ((void)label); + + mbedtls_md5_init( &md5 ); + mbedtls_sha1_init( &sha1 ); + + /* + * SSLv3: + * block = + * MD5( secret + SHA1( 'A' + secret + random ) ) + + * MD5( secret + SHA1( 'BB' + secret + random ) ) + + * MD5( secret + SHA1( 'CCC' + secret + random ) ) + + * ... + */ + for( i = 0; i < dlen / 16; i++ ) + { + memset( padding, (unsigned char) ('A' + i), 1 + i ); + + mbedtls_sha1_starts( &sha1 ); + mbedtls_sha1_update( &sha1, padding, 1 + i ); + mbedtls_sha1_update( &sha1, secret, slen ); + mbedtls_sha1_update( &sha1, random, rlen ); + mbedtls_sha1_finish( &sha1, sha1sum ); + + mbedtls_md5_starts( &md5 ); + mbedtls_md5_update( &md5, secret, slen ); + mbedtls_md5_update( &md5, sha1sum, 20 ); + mbedtls_md5_finish( &md5, dstbuf + i * 16 ); + } + + mbedtls_md5_free( &md5 ); + mbedtls_sha1_free( &sha1 ); + + mbedtls_zeroize( padding, sizeof( padding ) ); + mbedtls_zeroize( sha1sum, sizeof( sha1sum ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) +static int tls1_prf( const unsigned char *secret, size_t slen, + const char *label, + const unsigned char *random, size_t rlen, + unsigned char *dstbuf, size_t dlen ) +{ + size_t nb, hs; + size_t i, j, k; + const unsigned char *S1, *S2; + unsigned char tmp[128]; + unsigned char h_i[20]; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + int ret; + + mbedtls_md_init( &md_ctx ); + + if( sizeof( tmp ) < 20 + strlen( label ) + rlen ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + hs = ( slen + 1 ) / 2; + S1 = secret; + S2 = secret + slen - hs; + + nb = strlen( label ); + memcpy( tmp + 20, label, nb ); + memcpy( tmp + 20 + nb, random, rlen ); + nb += rlen; + + /* + * First compute P_md5(secret,label+random)[0..dlen] + */ + if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_MD5 ) ) == NULL ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 1 ) ) != 0 ) + return( ret ); + + mbedtls_md_hmac_starts( &md_ctx, S1, hs ); + mbedtls_md_hmac_update( &md_ctx, tmp + 20, nb ); + mbedtls_md_hmac_finish( &md_ctx, 4 + tmp ); + + for( i = 0; i < dlen; i += 16 ) + { + mbedtls_md_hmac_reset ( &md_ctx ); + mbedtls_md_hmac_update( &md_ctx, 4 + tmp, 16 + nb ); + mbedtls_md_hmac_finish( &md_ctx, h_i ); + + mbedtls_md_hmac_reset ( &md_ctx ); + mbedtls_md_hmac_update( &md_ctx, 4 + tmp, 16 ); + mbedtls_md_hmac_finish( &md_ctx, 4 + tmp ); + + k = ( i + 16 > dlen ) ? dlen % 16 : 16; + + for( j = 0; j < k; j++ ) + dstbuf[i + j] = h_i[j]; + } + + mbedtls_md_free( &md_ctx ); + + /* + * XOR out with P_sha1(secret,label+random)[0..dlen] + */ + if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ) ) == NULL ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 1 ) ) != 0 ) + return( ret ); + + mbedtls_md_hmac_starts( &md_ctx, S2, hs ); + mbedtls_md_hmac_update( &md_ctx, tmp + 20, nb ); + mbedtls_md_hmac_finish( &md_ctx, tmp ); + + for( i = 0; i < dlen; i += 20 ) + { + mbedtls_md_hmac_reset ( &md_ctx ); + mbedtls_md_hmac_update( &md_ctx, tmp, 20 + nb ); + mbedtls_md_hmac_finish( &md_ctx, h_i ); + + mbedtls_md_hmac_reset ( &md_ctx ); + mbedtls_md_hmac_update( &md_ctx, tmp, 20 ); + mbedtls_md_hmac_finish( &md_ctx, tmp ); + + k = ( i + 20 > dlen ) ? dlen % 20 : 20; + + for( j = 0; j < k; j++ ) + dstbuf[i + j] = (unsigned char)( dstbuf[i + j] ^ h_i[j] ); + } + + mbedtls_md_free( &md_ctx ); + + mbedtls_zeroize( tmp, sizeof( tmp ) ); + mbedtls_zeroize( h_i, sizeof( h_i ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1) || MBEDTLS_SSL_PROTO_TLS1_1 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +static int tls_prf_generic( mbedtls_md_type_t md_type, + const unsigned char *secret, size_t slen, + const char *label, + const unsigned char *random, size_t rlen, + unsigned char *dstbuf, size_t dlen ) +{ + size_t nb; + size_t i, j, k, md_len; + unsigned char tmp[128]; + unsigned char h_i[MBEDTLS_MD_MAX_SIZE]; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + int ret; + + mbedtls_md_init( &md_ctx ); + + if( ( md_info = mbedtls_md_info_from_type( md_type ) ) == NULL ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + md_len = mbedtls_md_get_size( md_info ); + + if( sizeof( tmp ) < md_len + strlen( label ) + rlen ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + nb = strlen( label ); + memcpy( tmp + md_len, label, nb ); + memcpy( tmp + md_len + nb, random, rlen ); + nb += rlen; + + /* + * Compute P_(secret, label + random)[0..dlen] + */ + if ( ( ret = mbedtls_md_setup( &md_ctx, md_info, 1 ) ) != 0 ) + return( ret ); + + mbedtls_md_hmac_starts( &md_ctx, secret, slen ); + mbedtls_md_hmac_update( &md_ctx, tmp + md_len, nb ); + mbedtls_md_hmac_finish( &md_ctx, tmp ); + + for( i = 0; i < dlen; i += md_len ) + { + mbedtls_md_hmac_reset ( &md_ctx ); + mbedtls_md_hmac_update( &md_ctx, tmp, md_len + nb ); + mbedtls_md_hmac_finish( &md_ctx, h_i ); + + mbedtls_md_hmac_reset ( &md_ctx ); + mbedtls_md_hmac_update( &md_ctx, tmp, md_len ); + mbedtls_md_hmac_finish( &md_ctx, tmp ); + + k = ( i + md_len > dlen ) ? dlen % md_len : md_len; + + for( j = 0; j < k; j++ ) + dstbuf[i + j] = h_i[j]; + } + + mbedtls_md_free( &md_ctx ); + + mbedtls_zeroize( tmp, sizeof( tmp ) ); + mbedtls_zeroize( h_i, sizeof( h_i ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_SHA256_C) +static int tls_prf_sha256( const unsigned char *secret, size_t slen, + const char *label, + const unsigned char *random, size_t rlen, + unsigned char *dstbuf, size_t dlen ) +{ + return( tls_prf_generic( MBEDTLS_MD_SHA256, secret, slen, + label, random, rlen, dstbuf, dlen ) ); +} +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) +static int tls_prf_sha384( const unsigned char *secret, size_t slen, + const char *label, + const unsigned char *random, size_t rlen, + unsigned char *dstbuf, size_t dlen ) +{ + return( tls_prf_generic( MBEDTLS_MD_SHA384, secret, slen, + label, random, rlen, dstbuf, dlen ) ); +} +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +static void ssl_update_checksum_start( mbedtls_ssl_context *, const unsigned char *, size_t ); + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) +static void ssl_update_checksum_md5sha1( mbedtls_ssl_context *, const unsigned char *, size_t ); +#endif + +#if defined(MBEDTLS_SSL_PROTO_SSL3) +static void ssl_calc_verify_ssl( mbedtls_ssl_context *, unsigned char * ); +static void ssl_calc_finished_ssl( mbedtls_ssl_context *, unsigned char *, int ); +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) +static void ssl_calc_verify_tls( mbedtls_ssl_context *, unsigned char * ); +static void ssl_calc_finished_tls( mbedtls_ssl_context *, unsigned char *, int ); +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) +static void ssl_update_checksum_sha256( mbedtls_ssl_context *, const unsigned char *, size_t ); +static void ssl_calc_verify_tls_sha256( mbedtls_ssl_context *,unsigned char * ); +static void ssl_calc_finished_tls_sha256( mbedtls_ssl_context *,unsigned char *, int ); +#endif + +#if defined(MBEDTLS_SHA512_C) +static void ssl_update_checksum_sha384( mbedtls_ssl_context *, const unsigned char *, size_t ); +static void ssl_calc_verify_tls_sha384( mbedtls_ssl_context *, unsigned char * ); +static void ssl_calc_finished_tls_sha384( mbedtls_ssl_context *, unsigned char *, int ); +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + unsigned char tmp[64]; + unsigned char keyblk[256]; + unsigned char *key1; + unsigned char *key2; + unsigned char *mac_enc; + unsigned char *mac_dec; + size_t iv_copy_len; + const mbedtls_cipher_info_t *cipher_info; + const mbedtls_md_info_t *md_info; + + mbedtls_ssl_session *session = ssl->session_negotiate; + mbedtls_ssl_transform *transform = ssl->transform_negotiate; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> derive keys" ) ); + + cipher_info = mbedtls_cipher_info_from_type( transform->ciphersuite_info->cipher ); + if( cipher_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher info for %d not found", + transform->ciphersuite_info->cipher ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + md_info = mbedtls_md_info_from_type( transform->ciphersuite_info->mac ); + if( md_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "mbedtls_md info for %d not found", + transform->ciphersuite_info->mac ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + /* + * Set appropriate PRF function and other SSL / TLS / TLS1.2 functions + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + handshake->tls_prf = ssl3_prf; + handshake->calc_verify = ssl_calc_verify_ssl; + handshake->calc_finished = ssl_calc_finished_ssl; + } + else +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_3 ) + { + handshake->tls_prf = tls1_prf; + handshake->calc_verify = ssl_calc_verify_tls; + handshake->calc_finished = ssl_calc_finished_tls; + } + else +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA512_C) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && + transform->ciphersuite_info->mac == MBEDTLS_MD_SHA384 ) + { + handshake->tls_prf = tls_prf_sha384; + handshake->calc_verify = ssl_calc_verify_tls_sha384; + handshake->calc_finished = ssl_calc_finished_tls_sha384; + } + else +#endif +#if defined(MBEDTLS_SHA256_C) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + handshake->tls_prf = tls_prf_sha256; + handshake->calc_verify = ssl_calc_verify_tls_sha256; + handshake->calc_finished = ssl_calc_finished_tls_sha256; + } + else +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* + * SSLv3: + * master = + * MD5( premaster + SHA1( 'A' + premaster + randbytes ) ) + + * MD5( premaster + SHA1( 'BB' + premaster + randbytes ) ) + + * MD5( premaster + SHA1( 'CCC' + premaster + randbytes ) ) + * + * TLSv1+: + * master = PRF( premaster, "master secret", randbytes )[0..47] + */ + if( handshake->resume == 0 ) + { + MBEDTLS_SSL_DEBUG_BUF( 3, "premaster secret", handshake->premaster, + handshake->pmslen ); + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + if( ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED ) + { + unsigned char session_hash[48]; + size_t hash_len; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "using extended master secret" ) ); + + ssl->handshake->calc_verify( ssl, session_hash ); + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { +#if defined(MBEDTLS_SHA512_C) + if( ssl->transform_negotiate->ciphersuite_info->mac == + MBEDTLS_MD_SHA384 ) + { + hash_len = 48; + } + else +#endif + hash_len = 32; + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + hash_len = 36; + + MBEDTLS_SSL_DEBUG_BUF( 3, "session hash", session_hash, hash_len ); + + ret = handshake->tls_prf( handshake->premaster, handshake->pmslen, + "extended master secret", + session_hash, hash_len, + session->master, 48 ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "prf", ret ); + return( ret ); + } + + } + else +#endif + ret = handshake->tls_prf( handshake->premaster, handshake->pmslen, + "master secret", + handshake->randbytes, 64, + session->master, 48 ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "prf", ret ); + return( ret ); + } + + mbedtls_zeroize( handshake->premaster, sizeof(handshake->premaster) ); + } + else + MBEDTLS_SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) ); + + /* + * Swap the client and server random values. + */ + memcpy( tmp, handshake->randbytes, 64 ); + memcpy( handshake->randbytes, tmp + 32, 32 ); + memcpy( handshake->randbytes + 32, tmp, 32 ); + mbedtls_zeroize( tmp, sizeof( tmp ) ); + + /* + * SSLv3: + * key block = + * MD5( master + SHA1( 'A' + master + randbytes ) ) + + * MD5( master + SHA1( 'BB' + master + randbytes ) ) + + * MD5( master + SHA1( 'CCC' + master + randbytes ) ) + + * MD5( master + SHA1( 'DDDD' + master + randbytes ) ) + + * ... + * + * TLSv1: + * key block = PRF( master, "key expansion", randbytes ) + */ + ret = handshake->tls_prf( session->master, 48, "key expansion", + handshake->randbytes, 64, keyblk, 256 ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "prf", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite = %s", + mbedtls_ssl_get_ciphersuite_name( session->ciphersuite ) ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "master secret", session->master, 48 ); + MBEDTLS_SSL_DEBUG_BUF( 4, "random bytes", handshake->randbytes, 64 ); + MBEDTLS_SSL_DEBUG_BUF( 4, "key block", keyblk, 256 ); + + mbedtls_zeroize( handshake->randbytes, sizeof( handshake->randbytes ) ); + + /* + * Determine the appropriate key, IV and MAC length. + */ + + transform->keylen = cipher_info->key_bitlen / 8; + + if( cipher_info->mode == MBEDTLS_MODE_GCM || + cipher_info->mode == MBEDTLS_MODE_CCM ) + { + transform->maclen = 0; + + transform->ivlen = 12; + transform->fixed_ivlen = 4; + + /* Minimum length is expicit IV + tag */ + transform->minlen = transform->ivlen - transform->fixed_ivlen + + ( transform->ciphersuite_info->flags & + MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16 ); + } + else + { + /* Initialize HMAC contexts */ + if( ( ret = mbedtls_md_setup( &transform->md_ctx_enc, md_info, 1 ) ) != 0 || + ( ret = mbedtls_md_setup( &transform->md_ctx_dec, md_info, 1 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret ); + return( ret ); + } + + /* Get MAC length */ + transform->maclen = mbedtls_md_get_size( md_info ); + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + /* + * If HMAC is to be truncated, we shall keep the leftmost bytes, + * (rfc 6066 page 13 or rfc 2104 section 4), + * so we only need to adjust the length here. + */ + if( session->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_ENABLED ) + transform->maclen = MBEDTLS_SSL_TRUNCATED_HMAC_LEN; +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + + /* IV length */ + transform->ivlen = cipher_info->iv_size; + + /* Minimum length */ + if( cipher_info->mode == MBEDTLS_MODE_STREAM ) + transform->minlen = transform->maclen; + else + { + /* + * GenericBlockCipher: + * 1. if EtM is in use: one block plus MAC + * otherwise: * first multiple of blocklen greater than maclen + * 2. IV except for SSL3 and TLS 1.0 + */ +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + if( session->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED ) + { + transform->minlen = transform->maclen + + cipher_info->block_size; + } + else +#endif + { + transform->minlen = transform->maclen + + cipher_info->block_size + - transform->maclen % cipher_info->block_size; + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_1 ) + ; /* No need to adjust minlen */ + else +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_2 || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + transform->minlen += transform->ivlen; + } + else +#endif + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "keylen: %d, minlen: %d, ivlen: %d, maclen: %d", + transform->keylen, transform->minlen, transform->ivlen, + transform->maclen ) ); + + /* + * Finally setup the cipher contexts, IVs and MAC secrets. + */ +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + key1 = keyblk + transform->maclen * 2; + key2 = keyblk + transform->maclen * 2 + transform->keylen; + + mac_enc = keyblk; + mac_dec = keyblk + transform->maclen; + + /* + * This is not used in TLS v1.1. + */ + iv_copy_len = ( transform->fixed_ivlen ) ? + transform->fixed_ivlen : transform->ivlen; + memcpy( transform->iv_enc, key2 + transform->keylen, iv_copy_len ); + memcpy( transform->iv_dec, key2 + transform->keylen + iv_copy_len, + iv_copy_len ); + } + else +#endif /* MBEDTLS_SSL_CLI_C */ +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + { + key1 = keyblk + transform->maclen * 2 + transform->keylen; + key2 = keyblk + transform->maclen * 2; + + mac_enc = keyblk + transform->maclen; + mac_dec = keyblk; + + /* + * This is not used in TLS v1.1. + */ + iv_copy_len = ( transform->fixed_ivlen ) ? + transform->fixed_ivlen : transform->ivlen; + memcpy( transform->iv_dec, key1 + transform->keylen, iv_copy_len ); + memcpy( transform->iv_enc, key1 + transform->keylen + iv_copy_len, + iv_copy_len ); + } + else +#endif /* MBEDTLS_SSL_SRV_C */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + if( transform->maclen > sizeof transform->mac_enc ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + memcpy( transform->mac_enc, mac_enc, transform->maclen ); + memcpy( transform->mac_dec, mac_dec, transform->maclen ); + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 ) + { + mbedtls_md_hmac_starts( &transform->md_ctx_enc, mac_enc, transform->maclen ); + mbedtls_md_hmac_starts( &transform->md_ctx_dec, mac_dec, transform->maclen ); + } + else +#endif + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_init != NULL ) + { + int ret = 0; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_init()" ) ); + + if( ( ret = mbedtls_ssl_hw_record_init( ssl, key1, key2, transform->keylen, + transform->iv_enc, transform->iv_dec, + iv_copy_len, + mac_enc, mac_dec, + transform->maclen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_init", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + } +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ + +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + if( ssl->conf->f_export_keys != NULL ) + { + ssl->conf->f_export_keys( ssl->conf->p_export_keys, + session->master, keyblk, + transform->maclen, transform->keylen, + iv_copy_len ); + } +#endif + + if( ( ret = mbedtls_cipher_setup( &transform->cipher_ctx_enc, + cipher_info ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup", ret ); + return( ret ); + } + + if( ( ret = mbedtls_cipher_setup( &transform->cipher_ctx_dec, + cipher_info ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup", ret ); + return( ret ); + } + + if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_enc, key1, + cipher_info->key_bitlen, + MBEDTLS_ENCRYPT ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); + return( ret ); + } + + if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_dec, key2, + cipher_info->key_bitlen, + MBEDTLS_DECRYPT ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); + return( ret ); + } + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + if( cipher_info->mode == MBEDTLS_MODE_CBC ) + { + if( ( ret = mbedtls_cipher_set_padding_mode( &transform->cipher_ctx_enc, + MBEDTLS_PADDING_NONE ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_set_padding_mode", ret ); + return( ret ); + } + + if( ( ret = mbedtls_cipher_set_padding_mode( &transform->cipher_ctx_dec, + MBEDTLS_PADDING_NONE ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_set_padding_mode", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + + mbedtls_zeroize( keyblk, sizeof( keyblk ) ); + +#if defined(MBEDTLS_ZLIB_SUPPORT) + // Initialize compression + // + if( session->compression == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + if( ssl->compress_buf == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Allocating compression buffer" ) ); + ssl->compress_buf = mbedtls_calloc( 1, MBEDTLS_SSL_BUFFER_LEN ); + if( ssl->compress_buf == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", + MBEDTLS_SSL_BUFFER_LEN ) ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Initializing zlib states" ) ); + + memset( &transform->ctx_deflate, 0, sizeof( transform->ctx_deflate ) ); + memset( &transform->ctx_inflate, 0, sizeof( transform->ctx_inflate ) ); + + if( deflateInit( &transform->ctx_deflate, + Z_DEFAULT_COMPRESSION ) != Z_OK || + inflateInit( &transform->ctx_inflate ) != Z_OK ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Failed to initialize compression" ) ); + return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED ); + } + } +#endif /* MBEDTLS_ZLIB_SUPPORT */ + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= derive keys" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_SSL3) +void ssl_calc_verify_ssl( mbedtls_ssl_context *ssl, unsigned char hash[36] ) +{ + mbedtls_md5_context md5; + mbedtls_sha1_context sha1; + unsigned char pad_1[48]; + unsigned char pad_2[48]; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc verify ssl" ) ); + + mbedtls_md5_init( &md5 ); + mbedtls_sha1_init( &sha1 ); + + mbedtls_md5_clone( &md5, &ssl->handshake->fin_md5 ); + mbedtls_sha1_clone( &sha1, &ssl->handshake->fin_sha1 ); + + memset( pad_1, 0x36, 48 ); + memset( pad_2, 0x5C, 48 ); + + mbedtls_md5_update( &md5, ssl->session_negotiate->master, 48 ); + mbedtls_md5_update( &md5, pad_1, 48 ); + mbedtls_md5_finish( &md5, hash ); + + mbedtls_md5_starts( &md5 ); + mbedtls_md5_update( &md5, ssl->session_negotiate->master, 48 ); + mbedtls_md5_update( &md5, pad_2, 48 ); + mbedtls_md5_update( &md5, hash, 16 ); + mbedtls_md5_finish( &md5, hash ); + + mbedtls_sha1_update( &sha1, ssl->session_negotiate->master, 48 ); + mbedtls_sha1_update( &sha1, pad_1, 40 ); + mbedtls_sha1_finish( &sha1, hash + 16 ); + + mbedtls_sha1_starts( &sha1 ); + mbedtls_sha1_update( &sha1, ssl->session_negotiate->master, 48 ); + mbedtls_sha1_update( &sha1, pad_2, 40 ); + mbedtls_sha1_update( &sha1, hash + 16, 20 ); + mbedtls_sha1_finish( &sha1, hash + 16 ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 36 ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) ); + + mbedtls_md5_free( &md5 ); + mbedtls_sha1_free( &sha1 ); + + return; +} +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) +void ssl_calc_verify_tls( mbedtls_ssl_context *ssl, unsigned char hash[36] ) +{ + mbedtls_md5_context md5; + mbedtls_sha1_context sha1; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc verify tls" ) ); + + mbedtls_md5_init( &md5 ); + mbedtls_sha1_init( &sha1 ); + + mbedtls_md5_clone( &md5, &ssl->handshake->fin_md5 ); + mbedtls_sha1_clone( &sha1, &ssl->handshake->fin_sha1 ); + + mbedtls_md5_finish( &md5, hash ); + mbedtls_sha1_finish( &sha1, hash + 16 ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 36 ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) ); + + mbedtls_md5_free( &md5 ); + mbedtls_sha1_free( &sha1 ); + + return; +} +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) +void ssl_calc_verify_tls_sha256( mbedtls_ssl_context *ssl, unsigned char hash[32] ) +{ + mbedtls_sha256_context sha256; + + mbedtls_sha256_init( &sha256 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc verify sha256" ) ); + + mbedtls_sha256_clone( &sha256, &ssl->handshake->fin_sha256 ); + mbedtls_sha256_finish( &sha256, hash ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 32 ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) ); + + mbedtls_sha256_free( &sha256 ); + + return; +} +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) +void ssl_calc_verify_tls_sha384( mbedtls_ssl_context *ssl, unsigned char hash[48] ) +{ + mbedtls_sha512_context sha512; + + mbedtls_sha512_init( &sha512 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc verify sha384" ) ); + + mbedtls_sha512_clone( &sha512, &ssl->handshake->fin_sha512 ); + mbedtls_sha512_finish( &sha512, hash ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 48 ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) ); + + mbedtls_sha512_free( &sha512 ); + + return; +} +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exchange_type_t key_ex ) +{ + unsigned char *p = ssl->handshake->premaster; + unsigned char *end = p + sizeof( ssl->handshake->premaster ); + const unsigned char *psk = ssl->conf->psk; + size_t psk_len = ssl->conf->psk_len; + + /* If the psk callback was called, use its result */ + if( ssl->handshake->psk != NULL ) + { + psk = ssl->handshake->psk; + psk_len = ssl->handshake->psk_len; + } + + /* + * PMS = struct { + * opaque other_secret<0..2^16-1>; + * opaque psk<0..2^16-1>; + * }; + * with "other_secret" depending on the particular key exchange + */ +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + if( key_ex == MBEDTLS_KEY_EXCHANGE_PSK ) + { + if( end - p < 2 ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + *(p++) = (unsigned char)( psk_len >> 8 ); + *(p++) = (unsigned char)( psk_len ); + + if( end < p || (size_t)( end - p ) < psk_len ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + memset( p, 0, psk_len ); + p += psk_len; + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( key_ex == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + /* + * other_secret already set by the ClientKeyExchange message, + * and is 48 bytes long + */ + *p++ = 0; + *p++ = 48; + p += 48; + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( key_ex == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + int ret; + size_t len; + + /* Write length only when we know the actual value */ + if( ( ret = mbedtls_dhm_calc_secret( &ssl->handshake->dhm_ctx, + p + 2, end - ( p + 2 ), &len, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret ); + return( ret ); + } + *(p++) = (unsigned char)( len >> 8 ); + *(p++) = (unsigned char)( len ); + p += len; + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( key_ex == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + int ret; + size_t zlen; + + if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, &zlen, + p + 2, end - ( p + 2 ), + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); + return( ret ); + } + + *(p++) = (unsigned char)( zlen >> 8 ); + *(p++) = (unsigned char)( zlen ); + p += zlen; + + MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z", &ssl->handshake->ecdh_ctx.z ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* opaque psk<0..2^16-1>; */ + if( end - p < 2 ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + *(p++) = (unsigned char)( psk_len >> 8 ); + *(p++) = (unsigned char)( psk_len ); + + if( end < p || (size_t)( end - p ) < psk_len ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + memcpy( p, psk, psk_len ); + p += psk_len; + + ssl->handshake->pmslen = p - ssl->handshake->premaster; + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_SSL_PROTO_SSL3) +/* + * SSLv3.0 MAC functions + */ +static void ssl_mac( mbedtls_md_context_t *md_ctx, unsigned char *secret, + unsigned char *buf, size_t len, + unsigned char *ctr, int type ) +{ + unsigned char header[11]; + unsigned char padding[48]; + int padlen; + int md_size = mbedtls_md_get_size( md_ctx->md_info ); + int md_type = mbedtls_md_get_type( md_ctx->md_info ); + + /* Only MD5 and SHA-1 supported */ + if( md_type == MBEDTLS_MD_MD5 ) + padlen = 48; + else + padlen = 40; + + memcpy( header, ctr, 8 ); + header[ 8] = (unsigned char) type; + header[ 9] = (unsigned char)( len >> 8 ); + header[10] = (unsigned char)( len ); + + memset( padding, 0x36, padlen ); + mbedtls_md_starts( md_ctx ); + mbedtls_md_update( md_ctx, secret, md_size ); + mbedtls_md_update( md_ctx, padding, padlen ); + mbedtls_md_update( md_ctx, header, 11 ); + mbedtls_md_update( md_ctx, buf, len ); + mbedtls_md_finish( md_ctx, buf + len ); + + memset( padding, 0x5C, padlen ); + mbedtls_md_starts( md_ctx ); + mbedtls_md_update( md_ctx, secret, md_size ); + mbedtls_md_update( md_ctx, padding, padlen ); + mbedtls_md_update( md_ctx, buf + len, md_size ); + mbedtls_md_finish( md_ctx, buf + len ); +} +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \ + ( defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) ) +#define SSL_SOME_MODES_USE_MAC +#endif + +/* + * Encryption/decryption functions + */ +static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) +{ + mbedtls_cipher_mode_t mode; + int auth_done = 0; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> encrypt buf" ) ); + + if( ssl->session_out == NULL || ssl->transform_out == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + mode = mbedtls_cipher_get_cipher_mode( &ssl->transform_out->cipher_ctx_enc ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "before encrypt: output payload", + ssl->out_msg, ssl->out_msglen ); + + /* + * Add MAC before if needed + */ +#if defined(SSL_SOME_MODES_USE_MAC) + if( mode == MBEDTLS_MODE_STREAM || + ( mode == MBEDTLS_MODE_CBC +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + && ssl->session_out->encrypt_then_mac == MBEDTLS_SSL_ETM_DISABLED +#endif + ) ) + { +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl_mac( &ssl->transform_out->md_ctx_enc, + ssl->transform_out->mac_enc, + ssl->out_msg, ssl->out_msglen, + ssl->out_ctr, ssl->out_msgtype ); + } + else +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 ) + { + mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, ssl->out_ctr, 8 ); + mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, ssl->out_hdr, 3 ); + mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, ssl->out_len, 2 ); + mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, + ssl->out_msg, ssl->out_msglen ); + mbedtls_md_hmac_finish( &ssl->transform_out->md_ctx_enc, + ssl->out_msg + ssl->out_msglen ); + mbedtls_md_hmac_reset( &ssl->transform_out->md_ctx_enc ); + } + else +#endif + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "computed mac", + ssl->out_msg + ssl->out_msglen, + ssl->transform_out->maclen ); + + ssl->out_msglen += ssl->transform_out->maclen; + auth_done++; + } +#endif /* AEAD not the only option */ + + /* + * Encrypt + */ +#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) + if( mode == MBEDTLS_MODE_STREAM ) + { + int ret; + size_t olen = 0; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " + "including %d bytes of padding", + ssl->out_msglen, 0 ) ); + + if( ( ret = mbedtls_cipher_crypt( &ssl->transform_out->cipher_ctx_enc, + ssl->transform_out->iv_enc, + ssl->transform_out->ivlen, + ssl->out_msg, ssl->out_msglen, + ssl->out_msg, &olen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_crypt", ret ); + return( ret ); + } + + if( ssl->out_msglen != olen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + else +#endif /* MBEDTLS_ARC4_C || MBEDTLS_CIPHER_NULL_CIPHER */ +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) + if( mode == MBEDTLS_MODE_GCM || + mode == MBEDTLS_MODE_CCM ) + { + int ret; + size_t enc_msglen, olen; + unsigned char *enc_msg; + unsigned char add_data[13]; + unsigned char taglen = ssl->transform_out->ciphersuite_info->flags & + MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16; + + memcpy( add_data, ssl->out_ctr, 8 ); + add_data[8] = ssl->out_msgtype; + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, add_data + 9 ); + add_data[11] = ( ssl->out_msglen >> 8 ) & 0xFF; + add_data[12] = ssl->out_msglen & 0xFF; + + MBEDTLS_SSL_DEBUG_BUF( 4, "additional data used for AEAD", + add_data, 13 ); + + /* + * Generate IV + */ + if( ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen != 8 ) + { + /* Reminder if we ever add an AEAD mode with a different size */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + memcpy( ssl->transform_out->iv_enc + ssl->transform_out->fixed_ivlen, + ssl->out_ctr, 8 ); + memcpy( ssl->out_iv, ssl->out_ctr, 8 ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "IV used", ssl->out_iv, + ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); + + /* + * Fix pointer positions and message length with added IV + */ + enc_msg = ssl->out_msg; + enc_msglen = ssl->out_msglen; + ssl->out_msglen += ssl->transform_out->ivlen - + ssl->transform_out->fixed_ivlen; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " + "including %d bytes of padding", + ssl->out_msglen, 0 ) ); + + /* + * Encrypt and authenticate + */ + if( ( ret = mbedtls_cipher_auth_encrypt( &ssl->transform_out->cipher_ctx_enc, + ssl->transform_out->iv_enc, + ssl->transform_out->ivlen, + add_data, 13, + enc_msg, enc_msglen, + enc_msg, &olen, + enc_msg + enc_msglen, taglen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_auth_encrypt", ret ); + return( ret ); + } + + if( olen != enc_msglen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + ssl->out_msglen += taglen; + auth_done++; + + MBEDTLS_SSL_DEBUG_BUF( 4, "after encrypt: tag", enc_msg + enc_msglen, taglen ); + } + else +#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */ +#if defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) + if( mode == MBEDTLS_MODE_CBC ) + { + int ret; + unsigned char *enc_msg; + size_t enc_msglen, padlen, olen = 0, i; + + padlen = ssl->transform_out->ivlen - ( ssl->out_msglen + 1 ) % + ssl->transform_out->ivlen; + if( padlen == ssl->transform_out->ivlen ) + padlen = 0; + + for( i = 0; i <= padlen; i++ ) + ssl->out_msg[ssl->out_msglen + i] = (unsigned char) padlen; + + ssl->out_msglen += padlen + 1; + + enc_msglen = ssl->out_msglen; + enc_msg = ssl->out_msg; + +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2) + /* + * Prepend per-record IV for block cipher in TLS v1.1 and up as per + * Method 1 (6.2.3.2. in RFC4346 and RFC5246) + */ + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + /* + * Generate IV + */ + ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->transform_out->iv_enc, + ssl->transform_out->ivlen ); + if( ret != 0 ) + return( ret ); + + memcpy( ssl->out_iv, ssl->transform_out->iv_enc, + ssl->transform_out->ivlen ); + + /* + * Fix pointer positions and message length with added IV + */ + enc_msg = ssl->out_msg; + enc_msglen = ssl->out_msglen; + ssl->out_msglen += ssl->transform_out->ivlen; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_1 || MBEDTLS_SSL_PROTO_TLS1_2 */ + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " + "including %d bytes of IV and %d bytes of padding", + ssl->out_msglen, ssl->transform_out->ivlen, + padlen + 1 ) ); + + if( ( ret = mbedtls_cipher_crypt( &ssl->transform_out->cipher_ctx_enc, + ssl->transform_out->iv_enc, + ssl->transform_out->ivlen, + enc_msg, enc_msglen, + enc_msg, &olen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_crypt", ret ); + return( ret ); + } + + if( enc_msglen != olen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_2 ) + { + /* + * Save IV in SSL3 and TLS1 + */ + memcpy( ssl->transform_out->iv_enc, + ssl->transform_out->cipher_ctx_enc.iv, + ssl->transform_out->ivlen ); + } +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + if( auth_done == 0 ) + { + /* + * MAC(MAC_write_key, seq_num + + * TLSCipherText.type + + * TLSCipherText.version + + * length_of( (IV +) ENC(...) ) + + * IV + // except for TLS 1.0 + * ENC(content + padding + padding_length)); + */ + unsigned char pseudo_hdr[13]; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "using encrypt then mac" ) ); + + memcpy( pseudo_hdr + 0, ssl->out_ctr, 8 ); + memcpy( pseudo_hdr + 8, ssl->out_hdr, 3 ); + pseudo_hdr[11] = (unsigned char)( ( ssl->out_msglen >> 8 ) & 0xFF ); + pseudo_hdr[12] = (unsigned char)( ( ssl->out_msglen ) & 0xFF ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "MAC'd meta-data", pseudo_hdr, 13 ); + + mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, pseudo_hdr, 13 ); + mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, + ssl->out_iv, ssl->out_msglen ); + mbedtls_md_hmac_finish( &ssl->transform_out->md_ctx_enc, + ssl->out_iv + ssl->out_msglen ); + mbedtls_md_hmac_reset( &ssl->transform_out->md_ctx_enc ); + + ssl->out_msglen += ssl->transform_out->maclen; + auth_done++; + } +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + } + else +#endif /* MBEDTLS_CIPHER_MODE_CBC && + ( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C ) */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* Make extra sure authentication was performed, exactly once */ + if( auth_done != 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= encrypt buf" ) ); + + return( 0 ); +} + +#define SSL_MAX_MAC_SIZE 48 + +static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) +{ + size_t i; + mbedtls_cipher_mode_t mode; + int auth_done = 0; +#if defined(SSL_SOME_MODES_USE_MAC) + size_t padlen = 0, correct = 1; +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> decrypt buf" ) ); + + if( ssl->session_in == NULL || ssl->transform_in == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + mode = mbedtls_cipher_get_cipher_mode( &ssl->transform_in->cipher_ctx_dec ); + + if( ssl->in_msglen < ssl->transform_in->minlen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "in_msglen (%d) < minlen (%d)", + ssl->in_msglen, ssl->transform_in->minlen ) ); + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } + +#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) + if( mode == MBEDTLS_MODE_STREAM ) + { + int ret; + size_t olen = 0; + + padlen = 0; + + if( ( ret = mbedtls_cipher_crypt( &ssl->transform_in->cipher_ctx_dec, + ssl->transform_in->iv_dec, + ssl->transform_in->ivlen, + ssl->in_msg, ssl->in_msglen, + ssl->in_msg, &olen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_crypt", ret ); + return( ret ); + } + + if( ssl->in_msglen != olen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + else +#endif /* MBEDTLS_ARC4_C || MBEDTLS_CIPHER_NULL_CIPHER */ +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) + if( mode == MBEDTLS_MODE_GCM || + mode == MBEDTLS_MODE_CCM ) + { + int ret; + size_t dec_msglen, olen; + unsigned char *dec_msg; + unsigned char *dec_msg_result; + unsigned char add_data[13]; + unsigned char taglen = ssl->transform_in->ciphersuite_info->flags & + MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16; + size_t explicit_iv_len = ssl->transform_in->ivlen - + ssl->transform_in->fixed_ivlen; + + if( ssl->in_msglen < explicit_iv_len + taglen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "msglen (%d) < explicit_iv_len (%d) " + "+ taglen (%d)", ssl->in_msglen, + explicit_iv_len, taglen ) ); + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } + dec_msglen = ssl->in_msglen - explicit_iv_len - taglen; + + dec_msg = ssl->in_msg; + dec_msg_result = ssl->in_msg; + ssl->in_msglen = dec_msglen; + + memcpy( add_data, ssl->in_ctr, 8 ); + add_data[8] = ssl->in_msgtype; + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, add_data + 9 ); + add_data[11] = ( ssl->in_msglen >> 8 ) & 0xFF; + add_data[12] = ssl->in_msglen & 0xFF; + + MBEDTLS_SSL_DEBUG_BUF( 4, "additional data used for AEAD", + add_data, 13 ); + + memcpy( ssl->transform_in->iv_dec + ssl->transform_in->fixed_ivlen, + ssl->in_iv, + ssl->transform_in->ivlen - ssl->transform_in->fixed_ivlen ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "IV used", ssl->transform_in->iv_dec, + ssl->transform_in->ivlen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "TAG used", dec_msg + dec_msglen, taglen ); + + /* + * Decrypt and authenticate + */ + if( ( ret = mbedtls_cipher_auth_decrypt( &ssl->transform_in->cipher_ctx_dec, + ssl->transform_in->iv_dec, + ssl->transform_in->ivlen, + add_data, 13, + dec_msg, dec_msglen, + dec_msg_result, &olen, + dec_msg + dec_msglen, taglen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_auth_decrypt", ret ); + + if( ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED ) + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + + return( ret ); + } + auth_done++; + + if( olen != dec_msglen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + else +#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */ +#if defined(MBEDTLS_CIPHER_MODE_CBC) && \ + ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) + if( mode == MBEDTLS_MODE_CBC ) + { + /* + * Decrypt and check the padding + */ + int ret; + unsigned char *dec_msg; + unsigned char *dec_msg_result; + size_t dec_msglen; + size_t minlen = 0; + size_t olen = 0; + + /* + * Check immediate ciphertext sanity + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + minlen += ssl->transform_in->ivlen; +#endif + + if( ssl->in_msglen < minlen + ssl->transform_in->ivlen || + ssl->in_msglen < minlen + ssl->transform_in->maclen + 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "msglen (%d) < max( ivlen(%d), maclen (%d) " + "+ 1 ) ( + expl IV )", ssl->in_msglen, + ssl->transform_in->ivlen, + ssl->transform_in->maclen ) ); + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } + + dec_msglen = ssl->in_msglen; + dec_msg = ssl->in_msg; + dec_msg_result = ssl->in_msg; + + /* + * Authenticate before decrypt if enabled + */ +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + if( ssl->session_in->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED ) + { + unsigned char computed_mac[SSL_MAX_MAC_SIZE]; + unsigned char pseudo_hdr[13]; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "using encrypt then mac" ) ); + + dec_msglen -= ssl->transform_in->maclen; + ssl->in_msglen -= ssl->transform_in->maclen; + + memcpy( pseudo_hdr + 0, ssl->in_ctr, 8 ); + memcpy( pseudo_hdr + 8, ssl->in_hdr, 3 ); + pseudo_hdr[11] = (unsigned char)( ( ssl->in_msglen >> 8 ) & 0xFF ); + pseudo_hdr[12] = (unsigned char)( ( ssl->in_msglen ) & 0xFF ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "MAC'd meta-data", pseudo_hdr, 13 ); + + mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, pseudo_hdr, 13 ); + mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, + ssl->in_iv, ssl->in_msglen ); + mbedtls_md_hmac_finish( &ssl->transform_in->md_ctx_dec, computed_mac ); + mbedtls_md_hmac_reset( &ssl->transform_in->md_ctx_dec ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "message mac", ssl->in_iv + ssl->in_msglen, + ssl->transform_in->maclen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "computed mac", computed_mac, + ssl->transform_in->maclen ); + + if( mbedtls_ssl_safer_memcmp( ssl->in_iv + ssl->in_msglen, computed_mac, + ssl->transform_in->maclen ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "message mac does not match" ) ); + + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } + auth_done++; + } +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + + /* + * Check length sanity + */ + if( ssl->in_msglen % ssl->transform_in->ivlen != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "msglen (%d) %% ivlen (%d) != 0", + ssl->in_msglen, ssl->transform_in->ivlen ) ); + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } + +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2) + /* + * Initialize for prepended IV for block cipher in TLS v1.1 and up + */ + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + dec_msglen -= ssl->transform_in->ivlen; + ssl->in_msglen -= ssl->transform_in->ivlen; + + for( i = 0; i < ssl->transform_in->ivlen; i++ ) + ssl->transform_in->iv_dec[i] = ssl->in_iv[i]; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_1 || MBEDTLS_SSL_PROTO_TLS1_2 */ + + if( ( ret = mbedtls_cipher_crypt( &ssl->transform_in->cipher_ctx_dec, + ssl->transform_in->iv_dec, + ssl->transform_in->ivlen, + dec_msg, dec_msglen, + dec_msg_result, &olen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_crypt", ret ); + return( ret ); + } + + if( dec_msglen != olen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_2 ) + { + /* + * Save IV in SSL3 and TLS1 + */ + memcpy( ssl->transform_in->iv_dec, + ssl->transform_in->cipher_ctx_dec.iv, + ssl->transform_in->ivlen ); + } +#endif + + padlen = 1 + ssl->in_msg[ssl->in_msglen - 1]; + + if( ssl->in_msglen < ssl->transform_in->maclen + padlen && + auth_done == 0 ) + { +#if defined(MBEDTLS_SSL_DEBUG_ALL) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "msglen (%d) < maclen (%d) + padlen (%d)", + ssl->in_msglen, ssl->transform_in->maclen, padlen ) ); +#endif + padlen = 0; + correct = 0; + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + if( padlen > ssl->transform_in->ivlen ) + { +#if defined(MBEDTLS_SSL_DEBUG_ALL) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad padding length: is %d, " + "should be no more than %d", + padlen, ssl->transform_in->ivlen ) ); +#endif + correct = 0; + } + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver > MBEDTLS_SSL_MINOR_VERSION_0 ) + { + /* + * TLSv1+: always check the padding up to the first failure + * and fake check up to 256 bytes of padding + */ + size_t pad_count = 0, real_count = 1; + size_t padding_idx = ssl->in_msglen - padlen - 1; + + /* + * Padding is guaranteed to be incorrect if: + * 1. padlen >= ssl->in_msglen + * + * 2. padding_idx >= MBEDTLS_SSL_MAX_CONTENT_LEN + + * ssl->transform_in->maclen + * + * In both cases we reset padding_idx to a safe value (0) to + * prevent out-of-buffer reads. + */ + correct &= ( ssl->in_msglen >= padlen + 1 ); + correct &= ( padding_idx < MBEDTLS_SSL_MAX_CONTENT_LEN + + ssl->transform_in->maclen ); + + padding_idx *= correct; + + for( i = 1; i <= 256; i++ ) + { + real_count &= ( i <= padlen ); + pad_count += real_count * + ( ssl->in_msg[padding_idx + i] == padlen - 1 ); + } + + correct &= ( pad_count == padlen ); /* Only 1 on correct padding */ + +#if defined(MBEDTLS_SSL_DEBUG_ALL) + if( padlen > 0 && correct == 0 ) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad padding byte detected" ) ); +#endif + padlen &= correct * 0x1FF; + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ + MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + ssl->in_msglen -= padlen; + } + else +#endif /* MBEDTLS_CIPHER_MODE_CBC && + ( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C ) */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "raw buffer after decryption", + ssl->in_msg, ssl->in_msglen ); + + /* + * Authenticate if not done yet. + * Compute the MAC regardless of the padding result (RFC4346, CBCTIME). + */ +#if defined(SSL_SOME_MODES_USE_MAC) + if( auth_done == 0 ) + { + unsigned char tmp[SSL_MAX_MAC_SIZE]; + + ssl->in_msglen -= ssl->transform_in->maclen; + + ssl->in_len[0] = (unsigned char)( ssl->in_msglen >> 8 ); + ssl->in_len[1] = (unsigned char)( ssl->in_msglen ); + + memcpy( tmp, ssl->in_msg + ssl->in_msglen, ssl->transform_in->maclen ); + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl_mac( &ssl->transform_in->md_ctx_dec, + ssl->transform_in->mac_dec, + ssl->in_msg, ssl->in_msglen, + ssl->in_ctr, ssl->in_msgtype ); + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver > MBEDTLS_SSL_MINOR_VERSION_0 ) + { + /* + * Process MAC and always update for padlen afterwards to make + * total time independent of padlen + * + * extra_run compensates MAC check for padlen + * + * Known timing attacks: + * - Lucky Thirteen (http://www.isg.rhul.ac.uk/tls/TLStiming.pdf) + * + * We use ( ( Lx + 8 ) / 64 ) to handle 'negative Lx' values + * correctly. (We round down instead of up, so -56 is the correct + * value for our calculations instead of -55) + */ + size_t j, extra_run = 0; + extra_run = ( 13 + ssl->in_msglen + padlen + 8 ) / 64 - + ( 13 + ssl->in_msglen + 8 ) / 64; + + extra_run &= correct * 0xFF; + + mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, ssl->in_ctr, 8 ); + mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, ssl->in_hdr, 3 ); + mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, ssl->in_len, 2 ); + mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, ssl->in_msg, + ssl->in_msglen ); + mbedtls_md_hmac_finish( &ssl->transform_in->md_ctx_dec, + ssl->in_msg + ssl->in_msglen ); + /* Call mbedtls_md_process at least once due to cache attacks */ + for( j = 0; j < extra_run + 1; j++ ) + mbedtls_md_process( &ssl->transform_in->md_ctx_dec, ssl->in_msg ); + + mbedtls_md_hmac_reset( &ssl->transform_in->md_ctx_dec ); + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ + MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "message mac", tmp, ssl->transform_in->maclen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "computed mac", ssl->in_msg + ssl->in_msglen, + ssl->transform_in->maclen ); + + if( mbedtls_ssl_safer_memcmp( tmp, ssl->in_msg + ssl->in_msglen, + ssl->transform_in->maclen ) != 0 ) + { +#if defined(MBEDTLS_SSL_DEBUG_ALL) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "message mac does not match" ) ); +#endif + correct = 0; + } + auth_done++; + + /* + * Finally check the correct flag + */ + if( correct == 0 ) + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } +#endif /* SSL_SOME_MODES_USE_MAC */ + + /* Make extra sure authentication was performed, exactly once */ + if( auth_done != 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( ssl->in_msglen == 0 ) + { + ssl->nb_zero++; + + /* + * Three or more empty messages may be a DoS attack + * (excessive CPU consumption). + */ + if( ssl->nb_zero > 3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received four consecutive empty " + "messages, possible DoS attack" ) ); + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } + } + else + ssl->nb_zero = 0; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ; /* in_ctr read from peer, not maintained internally */ + } + else +#endif + { + for( i = 8; i > ssl_ep_len( ssl ); i-- ) + if( ++ssl->in_ctr[i - 1] != 0 ) + break; + + /* The loop goes to its end iff the counter is wrapping */ + if( i == ssl_ep_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "incoming message counter would wrap" ) ); + return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); + } + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= decrypt buf" ) ); + + return( 0 ); +} + +#undef MAC_NONE +#undef MAC_PLAINTEXT +#undef MAC_CIPHERTEXT + +#if defined(MBEDTLS_ZLIB_SUPPORT) +/* + * Compression/decompression functions + */ +static int ssl_compress_buf( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *msg_post = ssl->out_msg; + size_t len_pre = ssl->out_msglen; + unsigned char *msg_pre = ssl->compress_buf; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> compress buf" ) ); + + if( len_pre == 0 ) + return( 0 ); + + memcpy( msg_pre, ssl->out_msg, len_pre ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "before compression: msglen = %d, ", + ssl->out_msglen ) ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "before compression: output payload", + ssl->out_msg, ssl->out_msglen ); + + ssl->transform_out->ctx_deflate.next_in = msg_pre; + ssl->transform_out->ctx_deflate.avail_in = len_pre; + ssl->transform_out->ctx_deflate.next_out = msg_post; + ssl->transform_out->ctx_deflate.avail_out = MBEDTLS_SSL_BUFFER_LEN; + + ret = deflate( &ssl->transform_out->ctx_deflate, Z_SYNC_FLUSH ); + if( ret != Z_OK ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "failed to perform compression (%d)", ret ) ); + return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED ); + } + + ssl->out_msglen = MBEDTLS_SSL_BUFFER_LEN - + ssl->transform_out->ctx_deflate.avail_out; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "after compression: msglen = %d, ", + ssl->out_msglen ) ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "after compression: output payload", + ssl->out_msg, ssl->out_msglen ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= compress buf" ) ); + + return( 0 ); +} + +static int ssl_decompress_buf( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *msg_post = ssl->in_msg; + size_t len_pre = ssl->in_msglen; + unsigned char *msg_pre = ssl->compress_buf; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> decompress buf" ) ); + + if( len_pre == 0 ) + return( 0 ); + + memcpy( msg_pre, ssl->in_msg, len_pre ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "before decompression: msglen = %d, ", + ssl->in_msglen ) ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "before decompression: input payload", + ssl->in_msg, ssl->in_msglen ); + + ssl->transform_in->ctx_inflate.next_in = msg_pre; + ssl->transform_in->ctx_inflate.avail_in = len_pre; + ssl->transform_in->ctx_inflate.next_out = msg_post; + ssl->transform_in->ctx_inflate.avail_out = MBEDTLS_SSL_MAX_CONTENT_LEN; + + ret = inflate( &ssl->transform_in->ctx_inflate, Z_SYNC_FLUSH ); + if( ret != Z_OK ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "failed to perform decompression (%d)", ret ) ); + return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED ); + } + + ssl->in_msglen = MBEDTLS_SSL_MAX_CONTENT_LEN - + ssl->transform_in->ctx_inflate.avail_out; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "after decompression: msglen = %d, ", + ssl->in_msglen ) ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "after decompression: input payload", + ssl->in_msg, ssl->in_msglen ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= decompress buf" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_ZLIB_SUPPORT */ + +#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_RENEGOTIATION) +static int ssl_write_hello_request( mbedtls_ssl_context *ssl ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +static int ssl_resend_hello_request( mbedtls_ssl_context *ssl ) +{ + /* If renegotiation is not enforced, retransmit until we would reach max + * timeout if we were using the usual handshake doubling scheme */ + if( ssl->conf->renego_max_records < 0 ) + { + uint32_t ratio = ssl->conf->hs_timeout_max / ssl->conf->hs_timeout_min + 1; + unsigned char doublings = 1; + + while( ratio != 0 ) + { + ++doublings; + ratio >>= 1; + } + + if( ++ssl->renego_records_seen > doublings ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "no longer retransmitting hello request" ) ); + return( 0 ); + } + } + + return( ssl_write_hello_request( ssl ) ); +} +#endif +#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_RENEGOTIATION */ + +/* + * Fill the input message buffer by appending data to it. + * The amount of data already fetched is in ssl->in_left. + * + * If we return 0, is it guaranteed that (at least) nb_want bytes are + * available (from this read and/or a previous one). Otherwise, an error code + * is returned (possibly EOF or WANT_READ). + * + * With stream transport (TLS) on success ssl->in_left == nb_want, but + * with datagram transport (DTLS) on success ssl->in_left >= nb_want, + * since we always read a whole datagram at once. + * + * For DTLS, it is up to the caller to set ssl->next_record_offset when + * they're done reading a record. + */ +int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ) +{ + int ret; + size_t len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> fetch input" ) ); + + if( ssl->f_recv == NULL && ssl->f_recv_timeout == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Bad usage of mbedtls_ssl_set_bio() " + "or mbedtls_ssl_set_bio()" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + if( nb_want > MBEDTLS_SSL_BUFFER_LEN - (size_t)( ssl->in_hdr - ssl->in_buf ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "requesting more data than fits" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + uint32_t timeout; + + /* Just to be sure */ + if( ssl->f_set_timer == NULL || ssl->f_get_timer == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "You must use " + "mbedtls_ssl_set_timer_cb() for DTLS" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + /* + * The point is, we need to always read a full datagram at once, so we + * sometimes read more then requested, and handle the additional data. + * It could be the rest of the current record (while fetching the + * header) and/or some other records in the same datagram. + */ + + /* + * Move to the next record in the already read datagram if applicable + */ + if( ssl->next_record_offset != 0 ) + { + if( ssl->in_left < ssl->next_record_offset ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + ssl->in_left -= ssl->next_record_offset; + + if( ssl->in_left != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "next record in same datagram, offset: %d", + ssl->next_record_offset ) ); + memmove( ssl->in_hdr, + ssl->in_hdr + ssl->next_record_offset, + ssl->in_left ); + } + + ssl->next_record_offset = 0; + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "in_left: %d, nb_want: %d", + ssl->in_left, nb_want ) ); + + /* + * Done if we already have enough data. + */ + if( nb_want <= ssl->in_left) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= fetch input" ) ); + return( 0 ); + } + + /* + * A record can't be split accross datagrams. If we need to read but + * are not at the beginning of a new record, the caller did something + * wrong. + */ + if( ssl->in_left != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* + * Don't even try to read if time's out already. + * This avoids by-passing the timer when repeatedly receiving messages + * that will end up being dropped. + */ + if( ssl_check_timer( ssl ) != 0 ) + ret = MBEDTLS_ERR_SSL_TIMEOUT; + else + { + len = MBEDTLS_SSL_BUFFER_LEN - ( ssl->in_hdr - ssl->in_buf ); + + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + timeout = ssl->handshake->retransmit_timeout; + else + timeout = ssl->conf->read_timeout; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "f_recv_timeout: %u ms", timeout ) ); + + if( ssl->f_recv_timeout != NULL ) + ret = ssl->f_recv_timeout( ssl->p_bio, ssl->in_hdr, len, + timeout ); + else + ret = ssl->f_recv( ssl->p_bio, ssl->in_hdr, len ); + + MBEDTLS_SSL_DEBUG_RET( 2, "ssl->f_recv(_timeout)", ret ); + + if( ret == 0 ) + return( MBEDTLS_ERR_SSL_CONN_EOF ); + } + + if( ret == MBEDTLS_ERR_SSL_TIMEOUT ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "timeout" ) ); + ssl_set_timer( ssl, 0 ); + + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + { + if( ssl_double_retransmit_timeout( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake timeout" ) ); + return( MBEDTLS_ERR_SSL_TIMEOUT ); + } + + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_resend", ret ); + return( ret ); + } + + return( MBEDTLS_ERR_SSL_WANT_READ ); + } +#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_RENEGOTIATION) + else if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ) + { + if( ( ret = ssl_resend_hello_request( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_resend_hello_request", ret ); + return( ret ); + } + + return( MBEDTLS_ERR_SSL_WANT_READ ); + } +#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_RENEGOTIATION */ + } + + if( ret < 0 ) + return( ret ); + + ssl->in_left = ret; + } + else +#endif + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "in_left: %d, nb_want: %d", + ssl->in_left, nb_want ) ); + + while( ssl->in_left < nb_want ) + { + len = nb_want - ssl->in_left; + + if( ssl_check_timer( ssl ) != 0 ) + ret = MBEDTLS_ERR_SSL_TIMEOUT; + else + { + if( ssl->f_recv_timeout != NULL ) + { + ret = ssl->f_recv_timeout( ssl->p_bio, + ssl->in_hdr + ssl->in_left, len, + ssl->conf->read_timeout ); + } + else + { + ret = ssl->f_recv( ssl->p_bio, + ssl->in_hdr + ssl->in_left, len ); + } + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "in_left: %d, nb_want: %d", + ssl->in_left, nb_want ) ); + MBEDTLS_SSL_DEBUG_RET( 2, "ssl->f_recv(_timeout)", ret ); + + if( ret == 0 ) + return( MBEDTLS_ERR_SSL_CONN_EOF ); + + if( ret < 0 ) + return( ret ); + + ssl->in_left += ret; + } + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= fetch input" ) ); + + return( 0 ); +} + +/* + * Flush any data not yet written + */ +int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *buf, i; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> flush output" ) ); + + if( ssl->f_send == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Bad usage of mbedtls_ssl_set_bio() " + "or mbedtls_ssl_set_bio()" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + /* Avoid incrementing counter if data is flushed */ + if( ssl->out_left == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= flush output" ) ); + return( 0 ); + } + + while( ssl->out_left > 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "message length: %d, out_left: %d", + mbedtls_ssl_hdr_len( ssl ) + ssl->out_msglen, ssl->out_left ) ); + + buf = ssl->out_hdr + mbedtls_ssl_hdr_len( ssl ) + + ssl->out_msglen - ssl->out_left; + ret = ssl->f_send( ssl->p_bio, buf, ssl->out_left ); + + MBEDTLS_SSL_DEBUG_RET( 2, "ssl->f_send", ret ); + + if( ret <= 0 ) + return( ret ); + + ssl->out_left -= ret; + } + + for( i = 8; i > ssl_ep_len( ssl ); i-- ) + if( ++ssl->out_ctr[i - 1] != 0 ) + break; + + /* The loop goes to its end iff the counter is wrapping */ + if( i == ssl_ep_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "outgoing message counter would wrap" ) ); + return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= flush output" ) ); + + return( 0 ); +} + +/* + * Functions to handle the DTLS retransmission state machine + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) +/* + * Append current handshake message to current outgoing flight + */ +static int ssl_flight_append( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_flight_item *msg; + + /* Allocate space for current message */ + if( ( msg = mbedtls_calloc( 1, sizeof( mbedtls_ssl_flight_item ) ) ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %d bytes failed", + sizeof( mbedtls_ssl_flight_item ) ) ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + if( ( msg->p = mbedtls_calloc( 1, ssl->out_msglen ) ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %d bytes failed", ssl->out_msglen ) ); + mbedtls_free( msg ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + /* Copy current handshake message with headers */ + memcpy( msg->p, ssl->out_msg, ssl->out_msglen ); + msg->len = ssl->out_msglen; + msg->type = ssl->out_msgtype; + msg->next = NULL; + + /* Append to the current flight */ + if( ssl->handshake->flight == NULL ) + ssl->handshake->flight = msg; + else + { + mbedtls_ssl_flight_item *cur = ssl->handshake->flight; + while( cur->next != NULL ) + cur = cur->next; + cur->next = msg; + } + + return( 0 ); +} + +/* + * Free the current flight of handshake messages + */ +static void ssl_flight_free( mbedtls_ssl_flight_item *flight ) +{ + mbedtls_ssl_flight_item *cur = flight; + mbedtls_ssl_flight_item *next; + + while( cur != NULL ) + { + next = cur->next; + + mbedtls_free( cur->p ); + mbedtls_free( cur ); + + cur = next; + } +} + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +static void ssl_dtls_replay_reset( mbedtls_ssl_context *ssl ); +#endif + +/* + * Swap transform_out and out_ctr with the alternative ones + */ +static void ssl_swap_epochs( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_transform *tmp_transform; + unsigned char tmp_out_ctr[8]; + + if( ssl->transform_out == ssl->handshake->alt_transform_out ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip swap epochs" ) ); + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "swap epochs" ) ); + + /* Swap transforms */ + tmp_transform = ssl->transform_out; + ssl->transform_out = ssl->handshake->alt_transform_out; + ssl->handshake->alt_transform_out = tmp_transform; + + /* Swap epoch + sequence_number */ + memcpy( tmp_out_ctr, ssl->out_ctr, 8 ); + memcpy( ssl->out_ctr, ssl->handshake->alt_out_ctr, 8 ); + memcpy( ssl->handshake->alt_out_ctr, tmp_out_ctr, 8 ); + + /* Adjust to the newly activated transform */ + if( ssl->transform_out != NULL && + ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + ssl->out_msg = ssl->out_iv + ssl->transform_out->ivlen - + ssl->transform_out->fixed_ivlen; + } + else + ssl->out_msg = ssl->out_iv; + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_activate != NULL ) + { + if( ( ret = mbedtls_ssl_hw_record_activate( ssl, MBEDTLS_SSL_CHANNEL_OUTBOUND ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_activate", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + } +#endif +} + +/* + * Retransmit the current flight of messages. + * + * Need to remember the current message in case flush_output returns + * WANT_WRITE, causing us to exit this function and come back later. + * This function must be called until state is no longer SENDING. + */ +int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_resend" ) ); + + if( ssl->handshake->retransmit_state != MBEDTLS_SSL_RETRANS_SENDING ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialise resending" ) ); + + ssl->handshake->cur_msg = ssl->handshake->flight; + ssl_swap_epochs( ssl ); + + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_SENDING; + } + + while( ssl->handshake->cur_msg != NULL ) + { + int ret; + mbedtls_ssl_flight_item *cur = ssl->handshake->cur_msg; + + /* Swap epochs before sending Finished: we can't do it after + * sending ChangeCipherSpec, in case write returns WANT_READ. + * Must be done before copying, may change out_msg pointer */ + if( cur->type == MBEDTLS_SSL_MSG_HANDSHAKE && + cur->p[0] == MBEDTLS_SSL_HS_FINISHED ) + { + ssl_swap_epochs( ssl ); + } + + memcpy( ssl->out_msg, cur->p, cur->len ); + ssl->out_msglen = cur->len; + ssl->out_msgtype = cur->type; + + ssl->handshake->cur_msg = cur->next; + + MBEDTLS_SSL_DEBUG_BUF( 3, "resent handshake message header", ssl->out_msg, 12 ); + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + } + + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_FINISHED; + else + { + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_WAITING; + ssl_set_timer( ssl, ssl->handshake->retransmit_timeout ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_resend" ) ); + + return( 0 ); +} + +/* + * To be called when the last message of an incoming flight is received. + */ +void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl ) +{ + /* We won't need to resend that one any more */ + ssl_flight_free( ssl->handshake->flight ); + ssl->handshake->flight = NULL; + ssl->handshake->cur_msg = NULL; + + /* The next incoming flight will start with this msg_seq */ + ssl->handshake->in_flight_start_seq = ssl->handshake->in_msg_seq; + + /* Cancel timer */ + ssl_set_timer( ssl, 0 ); + + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->in_msg[0] == MBEDTLS_SSL_HS_FINISHED ) + { + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_FINISHED; + } + else + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_PREPARING; +} + +/* + * To be called when the last message of an outgoing flight is send. + */ +void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl ) +{ + ssl_reset_retransmit_timeout( ssl ); + ssl_set_timer( ssl, ssl->handshake->retransmit_timeout ); + + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->in_msg[0] == MBEDTLS_SSL_HS_FINISHED ) + { + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_FINISHED; + } + else + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_WAITING; +} +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +/* + * Record layer functions + */ + +/* + * Write current record. + * Uses ssl->out_msgtype, ssl->out_msglen and bytes at ssl->out_msg. + */ +int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) +{ + int ret, done = 0, out_msg_type; + size_t len = ssl->out_msglen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write record" ) ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake != NULL && + ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) + { + ; /* Skip special handshake treatment when resending */ + } + else +#endif + if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) + { + out_msg_type = ssl->out_msg[0]; + + if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST && + ssl->handshake == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + ssl->out_msg[1] = (unsigned char)( ( len - 4 ) >> 16 ); + ssl->out_msg[2] = (unsigned char)( ( len - 4 ) >> 8 ); + ssl->out_msg[3] = (unsigned char)( ( len - 4 ) ); + + /* + * DTLS has additional fields in the Handshake layer, + * between the length field and the actual payload: + * uint16 message_seq; + * uint24 fragment_offset; + * uint24 fragment_length; + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + /* Make room for the additional DTLS fields */ + memmove( ssl->out_msg + 12, ssl->out_msg + 4, len - 4 ); + ssl->out_msglen += 8; + len += 8; + + /* Write message_seq and update it, except for HelloRequest */ + if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) + { + ssl->out_msg[4] = ( ssl->handshake->out_msg_seq >> 8 ) & 0xFF; + ssl->out_msg[5] = ( ssl->handshake->out_msg_seq ) & 0xFF; + ++( ssl->handshake->out_msg_seq ); + } + else + { + ssl->out_msg[4] = 0; + ssl->out_msg[5] = 0; + } + + /* We don't fragment, so frag_offset = 0 and frag_len = len */ + memset( ssl->out_msg + 6, 0x00, 3 ); + memcpy( ssl->out_msg + 9, ssl->out_msg + 1, 3 ); + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) + ssl->handshake->update_checksum( ssl, ssl->out_msg, len ); + } + + /* Save handshake and CCS messages for resending */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake != NULL && + ssl->handshake->retransmit_state != MBEDTLS_SSL_RETRANS_SENDING && + ( ssl->out_msgtype == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC || + ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) ) + { + if( ( ret = ssl_flight_append( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_flight_append", ret ); + return( ret ); + } + } +#endif + +#if defined(MBEDTLS_ZLIB_SUPPORT) + if( ssl->transform_out != NULL && + ssl->session_out->compression == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + if( ( ret = ssl_compress_buf( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_compress_buf", ret ); + return( ret ); + } + + len = ssl->out_msglen; + } +#endif /*MBEDTLS_ZLIB_SUPPORT */ + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_write != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_write()" ) ); + + ret = mbedtls_ssl_hw_record_write( ssl ); + if( ret != 0 && ret != MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_write", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + + if( ret == 0 ) + done = 1; + } +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ + if( !done ) + { + ssl->out_hdr[0] = (unsigned char) ssl->out_msgtype; + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, ssl->out_hdr + 1 ); + + ssl->out_len[0] = (unsigned char)( len >> 8 ); + ssl->out_len[1] = (unsigned char)( len ); + + if( ssl->transform_out != NULL ) + { + if( ( ret = ssl_encrypt_buf( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_encrypt_buf", ret ); + return( ret ); + } + + len = ssl->out_msglen; + ssl->out_len[0] = (unsigned char)( len >> 8 ); + ssl->out_len[1] = (unsigned char)( len ); + } + + ssl->out_left = mbedtls_ssl_hdr_len( ssl ) + ssl->out_msglen; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "output record: msgtype = %d, " + "version = [%d:%d], msglen = %d", + ssl->out_hdr[0], ssl->out_hdr[1], ssl->out_hdr[2], + ( ssl->out_len[0] << 8 ) | ssl->out_len[1] ) ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "output record sent to network", + ssl->out_hdr, mbedtls_ssl_hdr_len( ssl ) + ssl->out_msglen ); + } + + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flush_output", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write record" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +/* + * Mark bits in bitmask (used for DTLS HS reassembly) + */ +static void ssl_bitmask_set( unsigned char *mask, size_t offset, size_t len ) +{ + unsigned int start_bits, end_bits; + + start_bits = 8 - ( offset % 8 ); + if( start_bits != 8 ) + { + size_t first_byte_idx = offset / 8; + + /* Special case */ + if( len <= start_bits ) + { + for( ; len != 0; len-- ) + mask[first_byte_idx] |= 1 << ( start_bits - len ); + + /* Avoid potential issues with offset or len becoming invalid */ + return; + } + + offset += start_bits; /* Now offset % 8 == 0 */ + len -= start_bits; + + for( ; start_bits != 0; start_bits-- ) + mask[first_byte_idx] |= 1 << ( start_bits - 1 ); + } + + end_bits = len % 8; + if( end_bits != 0 ) + { + size_t last_byte_idx = ( offset + len ) / 8; + + len -= end_bits; /* Now len % 8 == 0 */ + + for( ; end_bits != 0; end_bits-- ) + mask[last_byte_idx] |= 1 << ( 8 - end_bits ); + } + + memset( mask + offset / 8, 0xFF, len / 8 ); +} + +/* + * Check that bitmask is full + */ +static int ssl_bitmask_check( unsigned char *mask, size_t len ) +{ + size_t i; + + for( i = 0; i < len / 8; i++ ) + if( mask[i] != 0xFF ) + return( -1 ); + + for( i = 0; i < len % 8; i++ ) + if( ( mask[len / 8] & ( 1 << ( 7 - i ) ) ) == 0 ) + return( -1 ); + + return( 0 ); +} + +/* + * Reassemble fragmented DTLS handshake messages. + * + * Use a temporary buffer for reassembly, divided in two parts: + * - the first holds the reassembled message (including handshake header), + * - the second holds a bitmask indicating which parts of the message + * (excluding headers) have been received so far. + */ +static int ssl_reassemble_dtls_handshake( mbedtls_ssl_context *ssl ) +{ + unsigned char *msg, *bitmask; + size_t frag_len, frag_off; + size_t msg_len = ssl->in_hslen - 12; /* Without headers */ + + if( ssl->handshake == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "not supported outside handshake (for now)" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + + /* + * For first fragment, check size and allocate buffer + */ + if( ssl->handshake->hs_msg == NULL ) + { + size_t alloc_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialize reassembly, total length = %d", + msg_len ) ); + + if( ssl->in_hslen > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake message too large" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + + /* The bitmask needs one bit per byte of message excluding header */ + alloc_len = 12 + msg_len + msg_len / 8 + ( msg_len % 8 != 0 ); + + ssl->handshake->hs_msg = mbedtls_calloc( 1, alloc_len ); + if( ssl->handshake->hs_msg == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", alloc_len ) ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + /* Prepare final header: copy msg_type, length and message_seq, + * then add standardised fragment_offset and fragment_length */ + memcpy( ssl->handshake->hs_msg, ssl->in_msg, 6 ); + memset( ssl->handshake->hs_msg + 6, 0, 3 ); + memcpy( ssl->handshake->hs_msg + 9, + ssl->handshake->hs_msg + 1, 3 ); + } + else + { + /* Make sure msg_type and length are consistent */ + if( memcmp( ssl->handshake->hs_msg, ssl->in_msg, 4 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "fragment header mismatch" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + } + + msg = ssl->handshake->hs_msg + 12; + bitmask = msg + msg_len; + + /* + * Check and copy current fragment + */ + frag_off = ( ssl->in_msg[6] << 16 ) | + ( ssl->in_msg[7] << 8 ) | + ssl->in_msg[8]; + frag_len = ( ssl->in_msg[9] << 16 ) | + ( ssl->in_msg[10] << 8 ) | + ssl->in_msg[11]; + + if( frag_off + frag_len > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid fragment offset/len: %d + %d > %d", + frag_off, frag_len, msg_len ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + if( frag_len + 12 > ssl->in_msglen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid fragment length: %d + 12 > %d", + frag_len, ssl->in_msglen ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "adding fragment, offset = %d, length = %d", + frag_off, frag_len ) ); + + memcpy( msg + frag_off, ssl->in_msg + 12, frag_len ); + ssl_bitmask_set( bitmask, frag_off, frag_len ); + + /* + * Do we have the complete message by now? + * If yes, finalize it, else ask to read the next record. + */ + if( ssl_bitmask_check( bitmask, msg_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "message is not complete yet" ) ); + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "handshake message completed" ) ); + + if( frag_len + 12 < ssl->in_msglen ) + { + /* + * We'got more handshake messages in the same record. + * This case is not handled now because no know implementation does + * that and it's hard to test, so we prefer to fail cleanly for now. + */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "last fragment not alone in its record" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + + if( ssl->in_left > ssl->next_record_offset ) + { + /* + * We've got more data in the buffer after the current record, + * that we don't want to overwrite. Move it before writing the + * reassembled message, and adjust in_left and next_record_offset. + */ + unsigned char *cur_remain = ssl->in_hdr + ssl->next_record_offset; + unsigned char *new_remain = ssl->in_msg + ssl->in_hslen; + size_t remain_len = ssl->in_left - ssl->next_record_offset; + + /* First compute and check new lengths */ + ssl->next_record_offset = new_remain - ssl->in_hdr; + ssl->in_left = ssl->next_record_offset + remain_len; + + if( ssl->in_left > MBEDTLS_SSL_BUFFER_LEN - + (size_t)( ssl->in_hdr - ssl->in_buf ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "reassembled message too large for buffer" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + memmove( new_remain, cur_remain, remain_len ); + } + + memcpy( ssl->in_msg, ssl->handshake->hs_msg, ssl->in_hslen ); + + mbedtls_free( ssl->handshake->hs_msg ); + ssl->handshake->hs_msg = NULL; + + MBEDTLS_SSL_DEBUG_BUF( 3, "reassembled handshake message", + ssl->in_msg, ssl->in_hslen ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ) +{ + if( ssl->in_msglen < mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake message too short: %d", + ssl->in_msglen ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + ( + ( ssl->in_msg[1] << 16 ) | + ( ssl->in_msg[2] << 8 ) | + ssl->in_msg[3] ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "handshake message: msglen =" + " %d, type = %d, hslen = %d", + ssl->in_msglen, ssl->in_msg[0], ssl->in_hslen ) ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + int ret; + unsigned int recv_msg_seq = ( ssl->in_msg[4] << 8 ) | ssl->in_msg[5]; + + /* ssl->handshake is NULL when receiving ClientHello for renego */ + if( ssl->handshake != NULL && + recv_msg_seq != ssl->handshake->in_msg_seq ) + { + /* Retransmit only on last message from previous flight, to avoid + * too many retransmissions. + * Besides, No sane server ever retransmits HelloVerifyRequest */ + if( recv_msg_seq == ssl->handshake->in_flight_start_seq - 1 && + ssl->in_msg[0] != MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received message from last flight, " + "message_seq = %d, start_of_flight = %d", + recv_msg_seq, + ssl->handshake->in_flight_start_seq ) ); + + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_resend", ret ); + return( ret ); + } + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "dropping out-of-sequence message: " + "message_seq = %d, expected = %d", + recv_msg_seq, + ssl->handshake->in_msg_seq ) ); + } + + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + /* Wait until message completion to increment in_msg_seq */ + + /* Reassemble if current message is fragmented or reassembly is + * already in progress */ + if( ssl->in_msglen < ssl->in_hslen || + memcmp( ssl->in_msg + 6, "\0\0\0", 3 ) != 0 || + memcmp( ssl->in_msg + 9, ssl->in_msg + 1, 3 ) != 0 || + ( ssl->handshake != NULL && ssl->handshake->hs_msg != NULL ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "found fragmented DTLS handshake message" ) ); + + if( ( ret = ssl_reassemble_dtls_handshake( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_reassemble_dtls_handshake", ret ); + return( ret ); + } + } + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + /* With TLS we don't handle fragmentation (for now) */ + if( ssl->in_msglen < ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLS handshake fragmentation not supported" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + + return( 0 ); +} + +void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ) +{ + + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER && + ssl->handshake != NULL ) + { + ssl->handshake->update_checksum( ssl, ssl->in_msg, ssl->in_hslen ); + } + + /* Handshake message is complete, increment counter */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake != NULL ) + { + ssl->handshake->in_msg_seq++; + } +#endif +} + +/* + * DTLS anti-replay: RFC 6347 4.1.2.6 + * + * in_window is a field of bits numbered from 0 (lsb) to 63 (msb). + * Bit n is set iff record number in_window_top - n has been seen. + * + * Usually, in_window_top is the last record number seen and the lsb of + * in_window is set. The only exception is the initial state (record number 0 + * not seen yet). + */ +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +static void ssl_dtls_replay_reset( mbedtls_ssl_context *ssl ) +{ + ssl->in_window_top = 0; + ssl->in_window = 0; +} + +static inline uint64_t ssl_load_six_bytes( unsigned char *buf ) +{ + return( ( (uint64_t) buf[0] << 40 ) | + ( (uint64_t) buf[1] << 32 ) | + ( (uint64_t) buf[2] << 24 ) | + ( (uint64_t) buf[3] << 16 ) | + ( (uint64_t) buf[4] << 8 ) | + ( (uint64_t) buf[5] ) ); +} + +/* + * Return 0 if sequence number is acceptable, -1 otherwise + */ +int mbedtls_ssl_dtls_replay_check( mbedtls_ssl_context *ssl ) +{ + uint64_t rec_seqnum = ssl_load_six_bytes( ssl->in_ctr + 2 ); + uint64_t bit; + + if( ssl->conf->anti_replay == MBEDTLS_SSL_ANTI_REPLAY_DISABLED ) + return( 0 ); + + if( rec_seqnum > ssl->in_window_top ) + return( 0 ); + + bit = ssl->in_window_top - rec_seqnum; + + if( bit >= 64 ) + return( -1 ); + + if( ( ssl->in_window & ( (uint64_t) 1 << bit ) ) != 0 ) + return( -1 ); + + return( 0 ); +} + +/* + * Update replay window on new validated record + */ +void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl ) +{ + uint64_t rec_seqnum = ssl_load_six_bytes( ssl->in_ctr + 2 ); + + if( ssl->conf->anti_replay == MBEDTLS_SSL_ANTI_REPLAY_DISABLED ) + return; + + if( rec_seqnum > ssl->in_window_top ) + { + /* Update window_top and the contents of the window */ + uint64_t shift = rec_seqnum - ssl->in_window_top; + + if( shift >= 64 ) + ssl->in_window = 1; + else + { + ssl->in_window <<= shift; + ssl->in_window |= 1; + } + + ssl->in_window_top = rec_seqnum; + } + else + { + /* Mark that number as seen in the current window */ + uint64_t bit = ssl->in_window_top - rec_seqnum; + + if( bit < 64 ) /* Always true, but be extra sure */ + ssl->in_window |= (uint64_t) 1 << bit; + } +} +#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ + +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && defined(MBEDTLS_SSL_SRV_C) +/* Forward declaration */ +static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ); + +/* + * Without any SSL context, check if a datagram looks like a ClientHello with + * a valid cookie, and if it doesn't, generate a HelloVerifyRequest message. + * Both input and output include full DTLS headers. + * + * - if cookie is valid, return 0 + * - if ClientHello looks superficially valid but cookie is not, + * fill obuf and set olen, then + * return MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED + * - otherwise return a specific error code + */ +static int ssl_check_dtls_clihlo_cookie( + mbedtls_ssl_cookie_write_t *f_cookie_write, + mbedtls_ssl_cookie_check_t *f_cookie_check, + void *p_cookie, + const unsigned char *cli_id, size_t cli_id_len, + const unsigned char *in, size_t in_len, + unsigned char *obuf, size_t buf_len, size_t *olen ) +{ + size_t sid_len, cookie_len; + unsigned char *p; + + if( f_cookie_write == NULL || f_cookie_check == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + /* + * Structure of ClientHello with record and handshake headers, + * and expected values. We don't need to check a lot, more checks will be + * done when actually parsing the ClientHello - skipping those checks + * avoids code duplication and does not make cookie forging any easier. + * + * 0-0 ContentType type; copied, must be handshake + * 1-2 ProtocolVersion version; copied + * 3-4 uint16 epoch; copied, must be 0 + * 5-10 uint48 sequence_number; copied + * 11-12 uint16 length; (ignored) + * + * 13-13 HandshakeType msg_type; (ignored) + * 14-16 uint24 length; (ignored) + * 17-18 uint16 message_seq; copied + * 19-21 uint24 fragment_offset; copied, must be 0 + * 22-24 uint24 fragment_length; (ignored) + * + * 25-26 ProtocolVersion client_version; (ignored) + * 27-58 Random random; (ignored) + * 59-xx SessionID session_id; 1 byte len + sid_len content + * 60+ opaque cookie<0..2^8-1>; 1 byte len + content + * ... + * + * Minimum length is 61 bytes. + */ + if( in_len < 61 || + in[0] != MBEDTLS_SSL_MSG_HANDSHAKE || + in[3] != 0 || in[4] != 0 || + in[19] != 0 || in[20] != 0 || in[21] != 0 ) + { + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + sid_len = in[59]; + if( sid_len > in_len - 61 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + cookie_len = in[60 + sid_len]; + if( cookie_len > in_len - 60 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + if( f_cookie_check( p_cookie, in + sid_len + 61, cookie_len, + cli_id, cli_id_len ) == 0 ) + { + /* Valid cookie */ + return( 0 ); + } + + /* + * If we get here, we've got an invalid cookie, let's prepare HVR. + * + * 0-0 ContentType type; copied + * 1-2 ProtocolVersion version; copied + * 3-4 uint16 epoch; copied + * 5-10 uint48 sequence_number; copied + * 11-12 uint16 length; olen - 13 + * + * 13-13 HandshakeType msg_type; hello_verify_request + * 14-16 uint24 length; olen - 25 + * 17-18 uint16 message_seq; copied + * 19-21 uint24 fragment_offset; copied + * 22-24 uint24 fragment_length; olen - 25 + * + * 25-26 ProtocolVersion server_version; 0xfe 0xff + * 27-27 opaque cookie<0..2^8-1>; cookie_len = olen - 27, cookie + * + * Minimum length is 28. + */ + if( buf_len < 28 ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + /* Copy most fields and adapt others */ + memcpy( obuf, in, 25 ); + obuf[13] = MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST; + obuf[25] = 0xfe; + obuf[26] = 0xff; + + /* Generate and write actual cookie */ + p = obuf + 28; + if( f_cookie_write( p_cookie, + &p, obuf + buf_len, cli_id, cli_id_len ) != 0 ) + { + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + *olen = p - obuf; + + /* Go back and fill length fields */ + obuf[27] = (unsigned char)( *olen - 28 ); + + obuf[14] = obuf[22] = (unsigned char)( ( *olen - 25 ) >> 16 ); + obuf[15] = obuf[23] = (unsigned char)( ( *olen - 25 ) >> 8 ); + obuf[16] = obuf[24] = (unsigned char)( ( *olen - 25 ) ); + + obuf[11] = (unsigned char)( ( *olen - 13 ) >> 8 ); + obuf[12] = (unsigned char)( ( *olen - 13 ) ); + + return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ); +} + +/* + * Handle possible client reconnect with the same UDP quadruplet + * (RFC 6347 Section 4.2.8). + * + * Called by ssl_parse_record_header() in case we receive an epoch 0 record + * that looks like a ClientHello. + * + * - if the input looks like a ClientHello without cookies, + * send back HelloVerifyRequest, then + * return MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED + * - if the input looks like a ClientHello with a valid cookie, + * reset the session of the current context, and + * return MBEDTLS_ERR_SSL_CLIENT_RECONNECT + * - if anything goes wrong, return a specific error code + * + * mbedtls_ssl_read_record() will ignore the record if anything else than + * MBEDTLS_ERR_SSL_CLIENT_RECONNECT or 0 is returned, although this function + * cannot not return 0. + */ +static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t len; + + ret = ssl_check_dtls_clihlo_cookie( + ssl->conf->f_cookie_write, + ssl->conf->f_cookie_check, + ssl->conf->p_cookie, + ssl->cli_id, ssl->cli_id_len, + ssl->in_buf, ssl->in_left, + ssl->out_buf, MBEDTLS_SSL_MAX_CONTENT_LEN, &len ); + + MBEDTLS_SSL_DEBUG_RET( 2, "ssl_check_dtls_clihlo_cookie", ret ); + + if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ) + { + /* Don't check write errors as we can't do anything here. + * If the error is permanent we'll catch it later, + * if it's not, then hopefully it'll work next time. */ + (void) ssl->f_send( ssl->p_bio, ssl->out_buf, len ); + + return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ); + } + + if( ret == 0 ) + { + /* Got a valid cookie, partially reset context */ + if( ( ret = ssl_session_reset_int( ssl, 1 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "reset", ret ); + return( ret ); + } + + return( MBEDTLS_ERR_SSL_CLIENT_RECONNECT ); + } + + return( ret ); +} +#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE && MBEDTLS_SSL_SRV_C */ + +/* + * ContentType type; + * ProtocolVersion version; + * uint16 epoch; // DTLS only + * uint48 sequence_number; // DTLS only + * uint16 length; + * + * Return 0 if header looks sane (and, for DTLS, the record is expected) + * MBEDTLS_ERR_SSL_INVALID_RECORD if the header looks bad, + * MBEDTLS_ERR_SSL_UNEXPECTED_RECORD (DTLS only) if sane but unexpected. + * + * With DTLS, mbedtls_ssl_read_record() will: + * 1. proceed with the record if this function returns 0 + * 2. drop only the current record if this function returns UNEXPECTED_RECORD + * 3. return CLIENT_RECONNECT if this function return that value + * 4. drop the whole datagram if this function returns anything else. + * Point 2 is needed when the peer is resending, and we have already received + * the first record from a datagram but are still waiting for the others. + */ +static int ssl_parse_record_header( mbedtls_ssl_context *ssl ) +{ + int ret; + int major_ver, minor_ver; + + MBEDTLS_SSL_DEBUG_BUF( 4, "input record header", ssl->in_hdr, mbedtls_ssl_hdr_len( ssl ) ); + + ssl->in_msgtype = ssl->in_hdr[0]; + ssl->in_msglen = ( ssl->in_len[0] << 8 ) | ssl->in_len[1]; + mbedtls_ssl_read_version( &major_ver, &minor_ver, ssl->conf->transport, ssl->in_hdr + 1 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "input record: msgtype = %d, " + "version = [%d:%d], msglen = %d", + ssl->in_msgtype, + major_ver, minor_ver, ssl->in_msglen ) ); + + /* Check record type */ + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->in_msgtype != MBEDTLS_SSL_MSG_ALERT && + ssl->in_msgtype != MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC && + ssl->in_msgtype != MBEDTLS_SSL_MSG_APPLICATION_DATA ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "unknown record type" ) ); + + if( ( ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE ) ) != 0 ) + { + return( ret ); + } + + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + /* Check version */ + if( major_ver != ssl->major_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "major version mismatch" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + if( minor_ver > ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "minor version mismatch" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + /* Check length against the size of our buffer */ + if( ssl->in_msglen > MBEDTLS_SSL_BUFFER_LEN + - (size_t)( ssl->in_msg - ssl->in_buf ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + /* Check length against bounds of the current transform and version */ + if( ssl->transform_in == NULL ) + { + if( ssl->in_msglen < 1 || + ssl->in_msglen > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + } + else + { + if( ssl->in_msglen < ssl->transform_in->minlen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 && + ssl->in_msglen > ssl->transform_in->minlen + MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + /* + * TLS encrypted messages can have up to 256 bytes of padding + */ + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 && + ssl->in_msglen > ssl->transform_in->minlen + + MBEDTLS_SSL_MAX_CONTENT_LEN + 256 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } +#endif + } + + /* + * DTLS-related tests done last, because most of them may result in + * silently dropping the record (but not the whole datagram), and we only + * want to consider that after ensuring that the "basic" fields (type, + * version, length) are sane. + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + unsigned int rec_epoch = ( ssl->in_ctr[0] << 8 ) | ssl->in_ctr[1]; + + /* Drop unexpected ChangeCipherSpec messages */ + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC && + ssl->state != MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC && + ssl->state != MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "dropping unexpected ChangeCipherSpec" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } + + /* Drop unexpected ApplicationData records, + * except at the beginning of renegotiations */ + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_APPLICATION_DATA && + ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ! ( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->state == MBEDTLS_SSL_SERVER_HELLO ) +#endif + ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "dropping unexpected ApplicationData" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } + + /* Check epoch (and sequence number) with DTLS */ + if( rec_epoch != ssl->in_epoch ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "record from another epoch: " + "expected %d, received %d", + ssl->in_epoch, rec_epoch ) ); + +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && defined(MBEDTLS_SSL_SRV_C) + /* + * Check for an epoch 0 ClientHello. We can't use in_msg here to + * access the first byte of record content (handshake type), as we + * have an active transform (possibly iv_len != 0), so use the + * fact that the record header len is 13 instead. + */ + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER && + rec_epoch == 0 && + ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->in_left > 13 && + ssl->in_buf[13] == MBEDTLS_SSL_HS_CLIENT_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "possible client reconnect " + "from the same port" ) ); + return( ssl_handle_possible_reconnect( ssl ) ); + } + else +#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE && MBEDTLS_SSL_SRV_C */ + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + /* Replay detection only works for the current epoch */ + if( rec_epoch == ssl->in_epoch && + mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "replayed record" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } +#endif + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + return( 0 ); +} + +/* + * If applicable, decrypt (and decompress) record content + */ +static int ssl_prepare_record_content( mbedtls_ssl_context *ssl ) +{ + int ret, done = 0; + + MBEDTLS_SSL_DEBUG_BUF( 4, "input record from network", + ssl->in_hdr, mbedtls_ssl_hdr_len( ssl ) + ssl->in_msglen ); + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_read != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_read()" ) ); + + ret = mbedtls_ssl_hw_record_read( ssl ); + if( ret != 0 && ret != MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_read", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + + if( ret == 0 ) + done = 1; + } +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ + if( !done && ssl->transform_in != NULL ) + { + if( ( ret = ssl_decrypt_buf( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_decrypt_buf", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "input payload after decrypt", + ssl->in_msg, ssl->in_msglen ); + + if( ssl->in_msglen > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + } + +#if defined(MBEDTLS_ZLIB_SUPPORT) + if( ssl->transform_in != NULL && + ssl->session_in->compression == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + if( ( ret = ssl_decompress_buf( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_decompress_buf", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_ZLIB_SUPPORT */ + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + mbedtls_ssl_dtls_replay_update( ssl ); + } +#endif + + return( 0 ); +} + +static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl ); + +/* + * Read a record. + * + * Silently ignore non-fatal alert (and for DTLS, invalid records as well, + * RFC 6347 4.1.2.7) and continue reading until a valid record is found. + * + */ +int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> read record" ) ); + + do { + + if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret ); + return( ret ); + } + + ret = mbedtls_ssl_handle_message_type( ssl ); + + } while( MBEDTLS_ERR_SSL_NON_FATAL == ret ); + + if( 0 != ret ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_handle_message_type" ), ret ); + return( ret ); + } + + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) + { + mbedtls_ssl_update_handshake_status( ssl ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= read record" ) ); + + return( 0 ); +} + +int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) +{ + int ret; + + if( ssl->in_hslen != 0 && ssl->in_hslen < ssl->in_msglen ) + { + /* + * Get next Handshake message in the current record + */ + ssl->in_msglen -= ssl->in_hslen; + + memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen, + ssl->in_msglen ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "remaining content in record", + ssl->in_msg, ssl->in_msglen ); + + return( 0 ); + } + + ssl->in_hslen = 0; + + /* + * Read the record header and parse it + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) +read_record_header: +#endif + + if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + + if( ( ret = ssl_parse_record_header( ssl ) ) != 0 ) + { +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ret != MBEDTLS_ERR_SSL_CLIENT_RECONNECT ) + { + if( ret == MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ) + { + /* Skip unexpected record (but not whole datagram) */ + ssl->next_record_offset = ssl->in_msglen + + mbedtls_ssl_hdr_len( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "discarding unexpected record " + "(header)" ) ); + } + else + { + /* Skip invalid record and the rest of the datagram */ + ssl->next_record_offset = 0; + ssl->in_left = 0; + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "discarding invalid record " + "(header)" ) ); + } + + /* Get next record */ + goto read_record_header; + } +#endif + return( ret ); + } + + /* + * Read and optionally decrypt the message contents + */ + if( ( ret = mbedtls_ssl_fetch_input( ssl, + mbedtls_ssl_hdr_len( ssl ) + ssl->in_msglen ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + + /* Done reading this record, get ready for the next one */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->next_record_offset = ssl->in_msglen + mbedtls_ssl_hdr_len( ssl ); + else +#endif + ssl->in_left = 0; + + if( ( ret = ssl_prepare_record_content( ssl ) ) != 0 ) + { +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + /* Silently discard invalid records */ + if( ret == MBEDTLS_ERR_SSL_INVALID_RECORD || + ret == MBEDTLS_ERR_SSL_INVALID_MAC ) + { + /* Except when waiting for Finished as a bad mac here + * probably means something went wrong in the handshake + * (eg wrong psk used, mitm downgrade attempt, etc.) */ + if( ssl->state == MBEDTLS_SSL_CLIENT_FINISHED || + ssl->state == MBEDTLS_SSL_SERVER_FINISHED ) + { +#if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES) + if( ret == MBEDTLS_ERR_SSL_INVALID_MAC ) + { + mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC ); + } +#endif + return( ret ); + } + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) + if( ssl->conf->badmac_limit != 0 && + ++ssl->badmac_seen >= ssl->conf->badmac_limit ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "too many records with bad MAC" ) ); + return( MBEDTLS_ERR_SSL_INVALID_MAC ); + } +#endif + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "discarding invalid record (mac)" ) ); + goto read_record_header; + } + + return( ret ); + } + else +#endif + { + /* Error out (and send alert) on invalid records */ +#if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES) + if( ret == MBEDTLS_ERR_SSL_INVALID_MAC ) + { + mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC ); + } +#endif + return( ret ); + } + } + + /* + * When we sent the last flight of the handshake, we MUST respond to a + * retransmit of the peer's previous flight with a retransmit. (In + * practice, only the Finished message will make it, other messages + * including CCS use the old transform so they're dropped as invalid.) + * + * If the record we received is not a handshake message, however, it + * means the peer received our last flight so we can clean up + * handshake info. + * + * This check needs to be done before prepare_handshake() due to an edge + * case: if the client immediately requests renegotiation, this + * finishes the current handshake first, avoiding the new ClientHello + * being mistaken for an ancient message in the current handshake. + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake != NULL && + ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + { + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->in_msg[0] == MBEDTLS_SSL_HS_FINISHED ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received retransmit of last flight" ) ); + + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_resend", ret ); + return( ret ); + } + + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + else + { + ssl_handshake_wrapup_free_hs_transform( ssl ); + } + } +#endif + + return( 0 ); +} + +int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ) +{ + int ret; + + /* + * Handle particular types of records + */ + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) + { + if( ( ret = mbedtls_ssl_prepare_handshake_record( ssl ) ) != 0 ) + { + return( ret ); + } + } + + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_ALERT ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "got an alert message, type: [%d:%d]", + ssl->in_msg[0], ssl->in_msg[1] ) ); + + /* + * Ignore non-fatal alerts, except close_notify and no_renegotiation + */ + if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_FATAL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "is a fatal alert message (msg %d)", + ssl->in_msg[1] ) ); + return( MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE ); + } + + if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING && + ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "is a close notify message" ) ); + return( MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY ); + } + +#if defined(MBEDTLS_SSL_RENEGOTIATION_ENABLED) + if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING && + ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "is a SSLv3 no_cert" ) ); + /* Will be handled when trying to parse ServerHello */ + return( 0 ); + } +#endif + +#if defined(MBEDTLS_SSL_PROTO_SSL3) && defined(MBEDTLS_SSL_SRV_C) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 && + ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING && + ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_NO_CERT ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "is a SSLv3 no_cert" ) ); + /* Will be handled in mbedtls_ssl_parse_certificate() */ + return( 0 ); + } +#endif /* MBEDTLS_SSL_PROTO_SSL3 && MBEDTLS_SSL_SRV_C */ + + /* Silently ignore: fetch new message */ + return MBEDTLS_ERR_SSL_NON_FATAL; + } + + return( 0 ); +} + +int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ) +{ + int ret; + + if( ( ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} + +int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl, + unsigned char level, + unsigned char message ) +{ + int ret; + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> send alert message" ) ); + + ssl->out_msgtype = MBEDTLS_SSL_MSG_ALERT; + ssl->out_msglen = 2; + ssl->out_msg[0] = level; + ssl->out_msg[1] = message; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= send alert message" ) ); + + return( 0 ); +} + +/* + * Handshake functions + */ +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} + +int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t i, n; + const mbedtls_x509_crt *crt; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate" ) ); + ssl->state++; + return( 0 ); + } + +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + if( ssl->client_auth == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate" ) ); + ssl->state++; + return( 0 ); + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + /* + * If using SSLv3 and got no cert, send an Alert message + * (otherwise an empty Certificate message will be sent). + */ + if( mbedtls_ssl_own_cert( ssl ) == NULL && + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl->out_msglen = 2; + ssl->out_msgtype = MBEDTLS_SSL_MSG_ALERT; + ssl->out_msg[0] = MBEDTLS_SSL_ALERT_LEVEL_WARNING; + ssl->out_msg[1] = MBEDTLS_SSL_ALERT_MSG_NO_CERT; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "got no certificate to send" ) ); + goto write_msg; + } +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + } +#endif /* MBEDTLS_SSL_CLI_C */ +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + { + if( mbedtls_ssl_own_cert( ssl ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no certificate to send" ) ); + return( MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED ); + } + } +#endif + + MBEDTLS_SSL_DEBUG_CRT( 3, "own certificate", mbedtls_ssl_own_cert( ssl ) ); + + /* + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 6 length of all certs + * 7 . 9 length of cert. 1 + * 10 . n-1 peer certificate + * n . n+2 length of cert. 2 + * n+3 . ... upper level cert, etc. + */ + i = 7; + crt = mbedtls_ssl_own_cert( ssl ); + + while( crt != NULL ) + { + n = crt->raw.len; + if( n > MBEDTLS_SSL_MAX_CONTENT_LEN - 3 - i ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "certificate too large, %d > %d", + i + 3 + n, MBEDTLS_SSL_MAX_CONTENT_LEN ) ); + return( MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE ); + } + + ssl->out_msg[i ] = (unsigned char)( n >> 16 ); + ssl->out_msg[i + 1] = (unsigned char)( n >> 8 ); + ssl->out_msg[i + 2] = (unsigned char)( n ); + + i += 3; memcpy( ssl->out_msg + i, crt->raw.p, n ); + i += n; crt = crt->next; + } + + ssl->out_msg[4] = (unsigned char)( ( i - 7 ) >> 16 ); + ssl->out_msg[5] = (unsigned char)( ( i - 7 ) >> 8 ); + ssl->out_msg[6] = (unsigned char)( ( i - 7 ) ); + + ssl->out_msglen = i; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE; + +#if defined(MBEDTLS_SSL_PROTO_SSL3) && defined(MBEDTLS_SSL_CLI_C) +write_msg: +#endif + + ssl->state++; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write certificate" ) ); + + return( ret ); +} + +int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t i, n; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + int authmode = ssl->conf->authmode; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + ssl->state++; + return( 0 ); + } + +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + ssl->state++; + return( 0 ); + } + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET ) + authmode = ssl->handshake->sni_authmode; +#endif + + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + authmode == MBEDTLS_SSL_VERIFY_NONE ) + { + ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_SKIP_VERIFY; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + ssl->state++; + return( 0 ); + } +#endif + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + ssl->state++; + +#if defined(MBEDTLS_SSL_SRV_C) +#if defined(MBEDTLS_SSL_PROTO_SSL3) + /* + * Check if the client sent an empty certificate + */ + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + if( ssl->in_msglen == 2 && + ssl->in_msgtype == MBEDTLS_SSL_MSG_ALERT && + ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING && + ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_NO_CERT ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "SSLv3 client has no certificate" ) ); + + ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_MISSING; + if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL ) + return( 0 ); + else + return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE ); + } + } +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + if( ssl->in_hslen == 3 + mbedtls_ssl_hs_hdr_len( ssl ) && + ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE && + memcmp( ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ), "\0\0\0", 3 ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLSv1 client has no certificate" ) ); + + ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_MISSING; + if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL ) + return( 0 ); + else + return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE ); + } + } +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ + MBEDTLS_SSL_PROTO_TLS1_2 */ +#endif /* MBEDTLS_SSL_SRV_C */ + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + if( ssl->in_msg[0] != MBEDTLS_SSL_HS_CERTIFICATE || + ssl->in_hslen < mbedtls_ssl_hs_hdr_len( ssl ) + 3 + 3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + + i = mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * Same message structure as in mbedtls_ssl_write_certificate() + */ + n = ( ssl->in_msg[i+1] << 8 ) | ssl->in_msg[i+2]; + + if( ssl->in_msg[i] != 0 || + ssl->in_hslen != n + 3 + mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + + /* In case we tried to reuse a session but it failed */ + if( ssl->session_negotiate->peer_cert != NULL ) + { + mbedtls_x509_crt_free( ssl->session_negotiate->peer_cert ); + mbedtls_free( ssl->session_negotiate->peer_cert ); + } + + if( ( ssl->session_negotiate->peer_cert = mbedtls_calloc( 1, + sizeof( mbedtls_x509_crt ) ) ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", + sizeof( mbedtls_x509_crt ) ) ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + mbedtls_x509_crt_init( ssl->session_negotiate->peer_cert ); + + i += 3; + + while( i < ssl->in_hslen ) + { + if( ssl->in_msg[i] != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + + n = ( (unsigned int) ssl->in_msg[i + 1] << 8 ) + | (unsigned int) ssl->in_msg[i + 2]; + i += 3; + + if( n < 128 || i + n > ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + + ret = mbedtls_x509_crt_parse_der( ssl->session_negotiate->peer_cert, + ssl->in_msg + i, n ); + if( 0 != ret && ( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + MBEDTLS_ERR_OID_NOT_FOUND ) != ret ) + { + MBEDTLS_SSL_DEBUG_RET( 1, " mbedtls_x509_crt_parse_der", ret ); + return( ret ); + } + + i += n; + } + + MBEDTLS_SSL_DEBUG_CRT( 3, "peer certificate", ssl->session_negotiate->peer_cert ); + + /* + * On client, make sure the server cert doesn't change during renego to + * avoid "triple handshake" attack: https://secure-resumption.com/ + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) && defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT && + ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + if( ssl->session->peer_cert == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "new server cert during renegotiation" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + + if( ssl->session->peer_cert->raw.len != + ssl->session_negotiate->peer_cert->raw.len || + memcmp( ssl->session->peer_cert->raw.p, + ssl->session_negotiate->peer_cert->raw.p, + ssl->session->peer_cert->raw.len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server cert changed during renegotiation" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ); + } + } +#endif /* MBEDTLS_SSL_RENEGOTIATION && MBEDTLS_SSL_CLI_C */ + + if( authmode != MBEDTLS_SSL_VERIFY_NONE ) + { + mbedtls_x509_crt *ca_chain; + mbedtls_x509_crl *ca_crl; + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_ca_chain != NULL ) + { + ca_chain = ssl->handshake->sni_ca_chain; + ca_crl = ssl->handshake->sni_ca_crl; + } + else +#endif + { + ca_chain = ssl->conf->ca_chain; + ca_crl = ssl->conf->ca_crl; + } + + if( ca_chain == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no CA chain" ) ); + return( MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED ); + } + + /* + * Main check: verify certificate + */ + ret = mbedtls_x509_crt_verify_with_profile( + ssl->session_negotiate->peer_cert, + ca_chain, ca_crl, + ssl->conf->cert_profile, + ssl->hostname, + &ssl->session_negotiate->verify_result, + ssl->conf->f_vrfy, ssl->conf->p_vrfy ); + + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "x509_verify_cert", ret ); + } + + /* + * Secondary checks: always done, but change 'ret' only if it was 0 + */ + +#if defined(MBEDTLS_ECP_C) + { + const mbedtls_pk_context *pk = &ssl->session_negotiate->peer_cert->pk; + + /* If certificate uses an EC key, make sure the curve is OK */ + if( mbedtls_pk_can_do( pk, MBEDTLS_PK_ECKEY ) && + mbedtls_ssl_check_curve( ssl, mbedtls_pk_ec( *pk )->grp.id ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate (EC key curve)" ) ); + if( ret == 0 ) + ret = MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE; + } + } +#endif /* MBEDTLS_ECP_C */ + + if( mbedtls_ssl_check_cert_usage( ssl->session_negotiate->peer_cert, + ciphersuite_info, + ! ssl->conf->endpoint, + &ssl->session_negotiate->verify_result ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate (usage extensions)" ) ); + if( ret == 0 ) + ret = MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE; + } + + if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL ) + ret = 0; + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); + + return( ret ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + !MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +int mbedtls_ssl_write_change_cipher_spec( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write change cipher spec" ) ); + + ssl->out_msgtype = MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC; + ssl->out_msglen = 1; + ssl->out_msg[0] = 1; + + ssl->state++; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write change cipher spec" ) ); + + return( 0 ); +} + +int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse change cipher spec" ) ); + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + if( ssl->in_msglen != 1 || ssl->in_msg[0] != 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC ); + } + + /* + * Switch to our negotiated transform and session parameters for inbound + * data. + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "switching to new transform spec for inbound data" ) ); + ssl->transform_in = ssl->transform_negotiate; + ssl->session_in = ssl->session_negotiate; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + ssl_dtls_replay_reset( ssl ); +#endif + + /* Increment epoch */ + if( ++ssl->in_epoch == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "DTLS epoch would wrap" ) ); + return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); + } + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + memset( ssl->in_ctr, 0, 8 ); + + /* + * Set the in_msg pointer to the correct location based on IV length + */ + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + ssl->in_msg = ssl->in_iv + ssl->transform_negotiate->ivlen - + ssl->transform_negotiate->fixed_ivlen; + } + else + ssl->in_msg = ssl->in_iv; + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_activate != NULL ) + { + if( ( ret = mbedtls_ssl_hw_record_activate( ssl, MBEDTLS_SSL_CHANNEL_INBOUND ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_activate", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + } +#endif + + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse change cipher spec" ) ); + + return( 0 ); +} + +void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl, + const mbedtls_ssl_ciphersuite_t *ciphersuite_info ) +{ + ((void) ciphersuite_info); + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_3 ) + ssl->handshake->update_checksum = ssl_update_checksum_md5sha1; + else +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA512_C) + if( ciphersuite_info->mac == MBEDTLS_MD_SHA384 ) + ssl->handshake->update_checksum = ssl_update_checksum_sha384; + else +#endif +#if defined(MBEDTLS_SHA256_C) + if( ciphersuite_info->mac != MBEDTLS_MD_SHA384 ) + ssl->handshake->update_checksum = ssl_update_checksum_sha256; + else +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return; + } +} + +void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + mbedtls_md5_starts( &ssl->handshake->fin_md5 ); + mbedtls_sha1_starts( &ssl->handshake->fin_sha1 ); +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) + mbedtls_sha256_starts( &ssl->handshake->fin_sha256, 0 ); +#endif +#if defined(MBEDTLS_SHA512_C) + mbedtls_sha512_starts( &ssl->handshake->fin_sha512, 1 ); +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +} + +static void ssl_update_checksum_start( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + mbedtls_md5_update( &ssl->handshake->fin_md5 , buf, len ); + mbedtls_sha1_update( &ssl->handshake->fin_sha1, buf, len ); +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) + mbedtls_sha256_update( &ssl->handshake->fin_sha256, buf, len ); +#endif +#if defined(MBEDTLS_SHA512_C) + mbedtls_sha512_update( &ssl->handshake->fin_sha512, buf, len ); +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +} + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) +static void ssl_update_checksum_md5sha1( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + mbedtls_md5_update( &ssl->handshake->fin_md5 , buf, len ); + mbedtls_sha1_update( &ssl->handshake->fin_sha1, buf, len ); +} +#endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) +static void ssl_update_checksum_sha256( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + mbedtls_sha256_update( &ssl->handshake->fin_sha256, buf, len ); +} +#endif + +#if defined(MBEDTLS_SHA512_C) +static void ssl_update_checksum_sha384( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + mbedtls_sha512_update( &ssl->handshake->fin_sha512, buf, len ); +} +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#if defined(MBEDTLS_SSL_PROTO_SSL3) +static void ssl_calc_finished_ssl( + mbedtls_ssl_context *ssl, unsigned char *buf, int from ) +{ + const char *sender; + mbedtls_md5_context md5; + mbedtls_sha1_context sha1; + + unsigned char padbuf[48]; + unsigned char md5sum[16]; + unsigned char sha1sum[20]; + + mbedtls_ssl_session *session = ssl->session_negotiate; + if( !session ) + session = ssl->session; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc finished ssl" ) ); + + mbedtls_md5_init( &md5 ); + mbedtls_sha1_init( &sha1 ); + + mbedtls_md5_clone( &md5, &ssl->handshake->fin_md5 ); + mbedtls_sha1_clone( &sha1, &ssl->handshake->fin_sha1 ); + + /* + * SSLv3: + * hash = + * MD5( master + pad2 + + * MD5( handshake + sender + master + pad1 ) ) + * + SHA1( master + pad2 + + * SHA1( handshake + sender + master + pad1 ) ) + */ + +#if !defined(MBEDTLS_MD5_ALT) + MBEDTLS_SSL_DEBUG_BUF( 4, "finished md5 state", (unsigned char *) + md5.state, sizeof( md5.state ) ); +#endif + +#if !defined(MBEDTLS_SHA1_ALT) + MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha1 state", (unsigned char *) + sha1.state, sizeof( sha1.state ) ); +#endif + + sender = ( from == MBEDTLS_SSL_IS_CLIENT ) ? "CLNT" + : "SRVR"; + + memset( padbuf, 0x36, 48 ); + + mbedtls_md5_update( &md5, (const unsigned char *) sender, 4 ); + mbedtls_md5_update( &md5, session->master, 48 ); + mbedtls_md5_update( &md5, padbuf, 48 ); + mbedtls_md5_finish( &md5, md5sum ); + + mbedtls_sha1_update( &sha1, (const unsigned char *) sender, 4 ); + mbedtls_sha1_update( &sha1, session->master, 48 ); + mbedtls_sha1_update( &sha1, padbuf, 40 ); + mbedtls_sha1_finish( &sha1, sha1sum ); + + memset( padbuf, 0x5C, 48 ); + + mbedtls_md5_starts( &md5 ); + mbedtls_md5_update( &md5, session->master, 48 ); + mbedtls_md5_update( &md5, padbuf, 48 ); + mbedtls_md5_update( &md5, md5sum, 16 ); + mbedtls_md5_finish( &md5, buf ); + + mbedtls_sha1_starts( &sha1 ); + mbedtls_sha1_update( &sha1, session->master, 48 ); + mbedtls_sha1_update( &sha1, padbuf , 40 ); + mbedtls_sha1_update( &sha1, sha1sum, 20 ); + mbedtls_sha1_finish( &sha1, buf + 16 ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calc finished result", buf, 36 ); + + mbedtls_md5_free( &md5 ); + mbedtls_sha1_free( &sha1 ); + + mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + mbedtls_zeroize( md5sum, sizeof( md5sum ) ); + mbedtls_zeroize( sha1sum, sizeof( sha1sum ) ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); +} +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) +static void ssl_calc_finished_tls( + mbedtls_ssl_context *ssl, unsigned char *buf, int from ) +{ + int len = 12; + const char *sender; + mbedtls_md5_context md5; + mbedtls_sha1_context sha1; + unsigned char padbuf[36]; + + mbedtls_ssl_session *session = ssl->session_negotiate; + if( !session ) + session = ssl->session; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc finished tls" ) ); + + mbedtls_md5_init( &md5 ); + mbedtls_sha1_init( &sha1 ); + + mbedtls_md5_clone( &md5, &ssl->handshake->fin_md5 ); + mbedtls_sha1_clone( &sha1, &ssl->handshake->fin_sha1 ); + + /* + * TLSv1: + * hash = PRF( master, finished_label, + * MD5( handshake ) + SHA1( handshake ) )[0..11] + */ + +#if !defined(MBEDTLS_MD5_ALT) + MBEDTLS_SSL_DEBUG_BUF( 4, "finished md5 state", (unsigned char *) + md5.state, sizeof( md5.state ) ); +#endif + +#if !defined(MBEDTLS_SHA1_ALT) + MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha1 state", (unsigned char *) + sha1.state, sizeof( sha1.state ) ); +#endif + + sender = ( from == MBEDTLS_SSL_IS_CLIENT ) + ? "client finished" + : "server finished"; + + mbedtls_md5_finish( &md5, padbuf ); + mbedtls_sha1_finish( &sha1, padbuf + 16 ); + + ssl->handshake->tls_prf( session->master, 48, sender, + padbuf, 36, buf, len ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calc finished result", buf, len ); + + mbedtls_md5_free( &md5 ); + mbedtls_sha1_free( &sha1 ); + + mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) +static void ssl_calc_finished_tls_sha256( + mbedtls_ssl_context *ssl, unsigned char *buf, int from ) +{ + int len = 12; + const char *sender; + mbedtls_sha256_context sha256; + unsigned char padbuf[32]; + + mbedtls_ssl_session *session = ssl->session_negotiate; + if( !session ) + session = ssl->session; + + mbedtls_sha256_init( &sha256 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc finished tls sha256" ) ); + + mbedtls_sha256_clone( &sha256, &ssl->handshake->fin_sha256 ); + + /* + * TLSv1.2: + * hash = PRF( master, finished_label, + * Hash( handshake ) )[0.11] + */ + +#if !defined(MBEDTLS_SHA256_ALT) + MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha2 state", (unsigned char *) + sha256.state, sizeof( sha256.state ) ); +#endif + + sender = ( from == MBEDTLS_SSL_IS_CLIENT ) + ? "client finished" + : "server finished"; + + mbedtls_sha256_finish( &sha256, padbuf ); + + ssl->handshake->tls_prf( session->master, 48, sender, + padbuf, 32, buf, len ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calc finished result", buf, len ); + + mbedtls_sha256_free( &sha256 ); + + mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); +} +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) +static void ssl_calc_finished_tls_sha384( + mbedtls_ssl_context *ssl, unsigned char *buf, int from ) +{ + int len = 12; + const char *sender; + mbedtls_sha512_context sha512; + unsigned char padbuf[48]; + + mbedtls_ssl_session *session = ssl->session_negotiate; + if( !session ) + session = ssl->session; + + mbedtls_sha512_init( &sha512 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc finished tls sha384" ) ); + + mbedtls_sha512_clone( &sha512, &ssl->handshake->fin_sha512 ); + + /* + * TLSv1.2: + * hash = PRF( master, finished_label, + * Hash( handshake ) )[0.11] + */ + +#if !defined(MBEDTLS_SHA512_ALT) + MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha512 state", (unsigned char *) + sha512.state, sizeof( sha512.state ) ); +#endif + + sender = ( from == MBEDTLS_SSL_IS_CLIENT ) + ? "client finished" + : "server finished"; + + mbedtls_sha512_finish( &sha512, padbuf ); + + ssl->handshake->tls_prf( session->master, 48, sender, + padbuf, 48, buf, len ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "calc finished result", buf, len ); + + mbedtls_sha512_free( &sha512 ); + + mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); +} +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "=> handshake wrapup: final free" ) ); + + /* + * Free our handshake params + */ + mbedtls_ssl_handshake_free( ssl->handshake ); + mbedtls_free( ssl->handshake ); + ssl->handshake = NULL; + + /* + * Free the previous transform and swith in the current one + */ + if( ssl->transform ) + { + mbedtls_ssl_transform_free( ssl->transform ); + mbedtls_free( ssl->transform ); + } + ssl->transform = ssl->transform_negotiate; + ssl->transform_negotiate = NULL; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "<= handshake wrapup: final free" ) ); +} + +void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ) +{ + int resume = ssl->handshake->resume; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "=> handshake wrapup" ) ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_DONE; + ssl->renego_records_seen = 0; + } +#endif + + /* + * Free the previous session and switch in the current one + */ + if( ssl->session ) + { +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + /* RFC 7366 3.1: keep the EtM state */ + ssl->session_negotiate->encrypt_then_mac = + ssl->session->encrypt_then_mac; +#endif + + mbedtls_ssl_session_free( ssl->session ); + mbedtls_free( ssl->session ); + } + ssl->session = ssl->session_negotiate; + ssl->session_negotiate = NULL; + + /* + * Add cache entry + */ + if( ssl->conf->f_set_cache != NULL && + ssl->session->id_len != 0 && + resume == 0 ) + { + if( ssl->conf->f_set_cache( ssl->conf->p_cache, ssl->session ) != 0 ) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "cache did not store session" ) ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->flight != NULL ) + { + /* Cancel handshake timer */ + ssl_set_timer( ssl, 0 ); + + /* Keep last flight around in case we need to resend it: + * we need the handshake and transform structures for that */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip freeing handshake and transform" ) ); + } + else +#endif + ssl_handshake_wrapup_free_hs_transform( ssl ); + + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "<= handshake wrapup" ) ); +} + +int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) +{ + int ret, hash_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished" ) ); + + /* + * Set the out_msg pointer to the correct location based on IV length + */ + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + ssl->out_msg = ssl->out_iv + ssl->transform_negotiate->ivlen - + ssl->transform_negotiate->fixed_ivlen; + } + else + ssl->out_msg = ssl->out_iv; + + ssl->handshake->calc_finished( ssl, ssl->out_msg + 4, ssl->conf->endpoint ); + + /* + * RFC 5246 7.4.9 (Page 63) says 12 is the default length and ciphersuites + * may define some other value. Currently (early 2016), no defined + * ciphersuite does this (and this is unlikely to change as activity has + * moved to TLS 1.3 now) so we can keep the hardcoded 12 here. + */ + hash_len = ( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) ? 36 : 12; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->verify_data_len = hash_len; + memcpy( ssl->own_verify_data, ssl->out_msg + 4, hash_len ); +#endif + + ssl->out_msglen = 4 + hash_len; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_FINISHED; + + /* + * In case of session resuming, invert the client and server + * ChangeCipherSpec messages order. + */ + if( ssl->handshake->resume != 0 ) + { +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + ssl->state = MBEDTLS_SSL_HANDSHAKE_WRAPUP; +#endif +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + ssl->state = MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC; +#endif + } + else + ssl->state++; + + /* + * Switch to our negotiated transform and session parameters for outbound + * data. + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "switching to new transform spec for outbound data" ) ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + unsigned char i; + + /* Remember current epoch settings for resending */ + ssl->handshake->alt_transform_out = ssl->transform_out; + memcpy( ssl->handshake->alt_out_ctr, ssl->out_ctr, 8 ); + + /* Set sequence_number to zero */ + memset( ssl->out_ctr + 2, 0, 6 ); + + /* Increment epoch */ + for( i = 2; i > 0; i-- ) + if( ++ssl->out_ctr[i - 1] != 0 ) + break; + + /* The loop goes to its end iff the counter is wrapping */ + if( i == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "DTLS epoch would wrap" ) ); + return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); + } + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + memset( ssl->out_ctr, 0, 8 ); + + ssl->transform_out = ssl->transform_negotiate; + ssl->session_out = ssl->session_negotiate; + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_activate != NULL ) + { + if( ( ret = mbedtls_ssl_hw_record_activate( ssl, MBEDTLS_SSL_CHANNEL_OUTBOUND ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_activate", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + } +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_send_flight_completed( ssl ); +#endif + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_SSL3) +#define SSL_MAX_HASH_LEN 36 +#else +#define SSL_MAX_HASH_LEN 12 +#endif + +int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned int hash_len; + unsigned char buf[SSL_MAX_HASH_LEN]; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished" ) ); + + ssl->handshake->calc_finished( ssl, buf, ssl->conf->endpoint ^ 1 ); + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + /* There is currently no ciphersuite using another length with TLS 1.2 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + hash_len = 36; + else +#endif + hash_len = 12; + + if( ssl->in_msg[0] != MBEDTLS_SSL_HS_FINISHED || + ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + hash_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_FINISHED ); + } + + if( mbedtls_ssl_safer_memcmp( ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ), + buf, hash_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_FINISHED ); + } + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->verify_data_len = hash_len; + memcpy( ssl->peer_verify_data, buf, hash_len ); +#endif + + if( ssl->handshake->resume != 0 ) + { +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + ssl->state = MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC; +#endif +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + ssl->state = MBEDTLS_SSL_HANDSHAKE_WRAPUP; +#endif + } + else + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_recv_flight_completed( ssl ); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished" ) ); + + return( 0 ); +} + +static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake ) +{ + memset( handshake, 0, sizeof( mbedtls_ssl_handshake_params ) ); + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + mbedtls_md5_init( &handshake->fin_md5 ); + mbedtls_sha1_init( &handshake->fin_sha1 ); + mbedtls_md5_starts( &handshake->fin_md5 ); + mbedtls_sha1_starts( &handshake->fin_sha1 ); +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) + mbedtls_sha256_init( &handshake->fin_sha256 ); + mbedtls_sha256_starts( &handshake->fin_sha256, 0 ); +#endif +#if defined(MBEDTLS_SHA512_C) + mbedtls_sha512_init( &handshake->fin_sha512 ); + mbedtls_sha512_starts( &handshake->fin_sha512, 1 ); +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + handshake->update_checksum = ssl_update_checksum_start; + handshake->sig_alg = MBEDTLS_SSL_HASH_SHA1; + +#if defined(MBEDTLS_DHM_C) + mbedtls_dhm_init( &handshake->dhm_ctx ); +#endif +#if defined(MBEDTLS_ECDH_C) + mbedtls_ecdh_init( &handshake->ecdh_ctx ); +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + mbedtls_ecjpake_init( &handshake->ecjpake_ctx ); +#if defined(MBEDTLS_SSL_CLI_C) + handshake->ecjpake_cache = NULL; + handshake->ecjpake_cache_len = 0; +#endif +#endif + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + handshake->sni_authmode = MBEDTLS_SSL_VERIFY_UNSET; +#endif +} + +static void ssl_transform_init( mbedtls_ssl_transform *transform ) +{ + memset( transform, 0, sizeof(mbedtls_ssl_transform) ); + + mbedtls_cipher_init( &transform->cipher_ctx_enc ); + mbedtls_cipher_init( &transform->cipher_ctx_dec ); + + mbedtls_md_init( &transform->md_ctx_enc ); + mbedtls_md_init( &transform->md_ctx_dec ); +} + +void mbedtls_ssl_session_init( mbedtls_ssl_session *session ) +{ + memset( session, 0, sizeof(mbedtls_ssl_session) ); +} + +static int ssl_handshake_init( mbedtls_ssl_context *ssl ) +{ + /* Clear old handshake information if present */ + if( ssl->transform_negotiate ) + mbedtls_ssl_transform_free( ssl->transform_negotiate ); + if( ssl->session_negotiate ) + mbedtls_ssl_session_free( ssl->session_negotiate ); + if( ssl->handshake ) + mbedtls_ssl_handshake_free( ssl->handshake ); + + /* + * Either the pointers are now NULL or cleared properly and can be freed. + * Now allocate missing structures. + */ + if( ssl->transform_negotiate == NULL ) + { + ssl->transform_negotiate = mbedtls_calloc( 1, sizeof(mbedtls_ssl_transform) ); + } + + if( ssl->session_negotiate == NULL ) + { + ssl->session_negotiate = mbedtls_calloc( 1, sizeof(mbedtls_ssl_session) ); + } + + if( ssl->handshake == NULL ) + { + ssl->handshake = mbedtls_calloc( 1, sizeof(mbedtls_ssl_handshake_params) ); + } + + /* All pointers should exist and can be directly freed without issue */ + if( ssl->handshake == NULL || + ssl->transform_negotiate == NULL || + ssl->session_negotiate == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc() of ssl sub-contexts failed" ) ); + + mbedtls_free( ssl->handshake ); + mbedtls_free( ssl->transform_negotiate ); + mbedtls_free( ssl->session_negotiate ); + + ssl->handshake = NULL; + ssl->transform_negotiate = NULL; + ssl->session_negotiate = NULL; + + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + /* Initialize structures */ + mbedtls_ssl_session_init( ssl->session_negotiate ); + ssl_transform_init( ssl->transform_negotiate ); + ssl_handshake_params_init( ssl->handshake ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ssl->handshake->alt_transform_out = ssl->transform_out; + + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_PREPARING; + else + ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_WAITING; + + ssl_set_timer( ssl, 0 ); + } +#endif + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) +/* Dummy cookie callbacks for defaults */ +static int ssl_cookie_write_dummy( void *ctx, + unsigned char **p, unsigned char *end, + const unsigned char *cli_id, size_t cli_id_len ) +{ + ((void) ctx); + ((void) p); + ((void) end); + ((void) cli_id); + ((void) cli_id_len); + + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +static int ssl_cookie_check_dummy( void *ctx, + const unsigned char *cookie, size_t cookie_len, + const unsigned char *cli_id, size_t cli_id_len ) +{ + ((void) ctx); + ((void) cookie); + ((void) cookie_len); + ((void) cli_id); + ((void) cli_id_len); + + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */ + +/* + * Initialize an SSL context + */ +void mbedtls_ssl_init( mbedtls_ssl_context *ssl ) +{ + memset( ssl, 0, sizeof( mbedtls_ssl_context ) ); +} + +/* + * Setup an SSL context + */ +int mbedtls_ssl_setup( mbedtls_ssl_context *ssl, + const mbedtls_ssl_config *conf ) +{ + int ret; + const size_t len = MBEDTLS_SSL_BUFFER_LEN; + + ssl->conf = conf; + + /* + * Prepare base structures + */ + if( ( ssl-> in_buf = mbedtls_calloc( 1, len ) ) == NULL || + ( ssl->out_buf = mbedtls_calloc( 1, len ) ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", len ) ); + mbedtls_free( ssl->in_buf ); + ssl->in_buf = NULL; + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ssl->out_hdr = ssl->out_buf; + ssl->out_ctr = ssl->out_buf + 3; + ssl->out_len = ssl->out_buf + 11; + ssl->out_iv = ssl->out_buf + 13; + ssl->out_msg = ssl->out_buf + 13; + + ssl->in_hdr = ssl->in_buf; + ssl->in_ctr = ssl->in_buf + 3; + ssl->in_len = ssl->in_buf + 11; + ssl->in_iv = ssl->in_buf + 13; + ssl->in_msg = ssl->in_buf + 13; + } + else +#endif + { + ssl->out_ctr = ssl->out_buf; + ssl->out_hdr = ssl->out_buf + 8; + ssl->out_len = ssl->out_buf + 11; + ssl->out_iv = ssl->out_buf + 13; + ssl->out_msg = ssl->out_buf + 13; + + ssl->in_ctr = ssl->in_buf; + ssl->in_hdr = ssl->in_buf + 8; + ssl->in_len = ssl->in_buf + 11; + ssl->in_iv = ssl->in_buf + 13; + ssl->in_msg = ssl->in_buf + 13; + } + + if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +/* + * Reset an initialized and used SSL context for re-use while retaining + * all application-set variables, function pointers and data. + * + * If partial is non-zero, keep data in the input buffer and client ID. + * (Use when a DTLS client reconnects from the same port.) + */ +static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) +{ + int ret; + + ssl->state = MBEDTLS_SSL_HELLO_REQUEST; + + /* Cancel any possibly running timer */ + ssl_set_timer( ssl, 0 ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->renego_status = MBEDTLS_SSL_INITIAL_HANDSHAKE; + ssl->renego_records_seen = 0; + + ssl->verify_data_len = 0; + memset( ssl->own_verify_data, 0, MBEDTLS_SSL_VERIFY_DATA_MAX_LEN ); + memset( ssl->peer_verify_data, 0, MBEDTLS_SSL_VERIFY_DATA_MAX_LEN ); +#endif + ssl->secure_renegotiation = MBEDTLS_SSL_LEGACY_RENEGOTIATION; + + ssl->in_offt = NULL; + + ssl->in_msg = ssl->in_buf + 13; + ssl->in_msgtype = 0; + ssl->in_msglen = 0; + if( partial == 0 ) + ssl->in_left = 0; +#if defined(MBEDTLS_SSL_PROTO_DTLS) + ssl->next_record_offset = 0; + ssl->in_epoch = 0; +#endif +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + ssl_dtls_replay_reset( ssl ); +#endif + + ssl->in_hslen = 0; + ssl->nb_zero = 0; + ssl->record_read = 0; + + ssl->out_msg = ssl->out_buf + 13; + ssl->out_msgtype = 0; + ssl->out_msglen = 0; + ssl->out_left = 0; +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + if( ssl->split_done != MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED ) + ssl->split_done = 0; +#endif + + ssl->transform_in = NULL; + ssl->transform_out = NULL; + + memset( ssl->out_buf, 0, MBEDTLS_SSL_BUFFER_LEN ); + if( partial == 0 ) + memset( ssl->in_buf, 0, MBEDTLS_SSL_BUFFER_LEN ); + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_reset != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_reset()" ) ); + if( ( ret = mbedtls_ssl_hw_record_reset( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_reset", ret ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); + } + } +#endif + + if( ssl->transform ) + { + mbedtls_ssl_transform_free( ssl->transform ); + mbedtls_free( ssl->transform ); + ssl->transform = NULL; + } + + if( ssl->session ) + { + mbedtls_ssl_session_free( ssl->session ); + mbedtls_free( ssl->session ); + ssl->session = NULL; + } + +#if defined(MBEDTLS_SSL_ALPN) + ssl->alpn_chosen = NULL; +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) + if( partial == 0 ) + { + mbedtls_free( ssl->cli_id ); + ssl->cli_id = NULL; + ssl->cli_id_len = 0; + } +#endif + + if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +/* + * Reset an initialized and used SSL context for re-use while retaining + * all application-set variables, function pointers and data. + */ +int mbedtls_ssl_session_reset( mbedtls_ssl_context *ssl ) +{ + return( ssl_session_reset_int( ssl, 0 ) ); +} + +/* + * SSL set accessors + */ +void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint ) +{ + conf->endpoint = endpoint; +} + +void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport ) +{ + conf->transport = transport; +} + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode ) +{ + conf->anti_replay = mode; +} +#endif + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) +void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limit ) +{ + conf->badmac_limit = limit; +} +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max ) +{ + conf->hs_timeout_min = min; + conf->hs_timeout_max = max; +} +#endif + +void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode ) +{ + conf->authmode = authmode; +} + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +void mbedtls_ssl_conf_verify( mbedtls_ssl_config *conf, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + conf->f_vrfy = f_vrfy; + conf->p_vrfy = p_vrfy; +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +void mbedtls_ssl_conf_rng( mbedtls_ssl_config *conf, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + conf->f_rng = f_rng; + conf->p_rng = p_rng; +} + +void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf, + void (*f_dbg)(void *, int, const char *, int, const char *), + void *p_dbg ) +{ + conf->f_dbg = f_dbg; + conf->p_dbg = p_dbg; +} + +void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl, + void *p_bio, + mbedtls_ssl_send_t *f_send, + mbedtls_ssl_recv_t *f_recv, + mbedtls_ssl_recv_timeout_t *f_recv_timeout ) +{ + ssl->p_bio = p_bio; + ssl->f_send = f_send; + ssl->f_recv = f_recv; + ssl->f_recv_timeout = f_recv_timeout; +} + +void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout ) +{ + conf->read_timeout = timeout; +} + +void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *ssl, + void *p_timer, + mbedtls_ssl_set_timer_t *f_set_timer, + mbedtls_ssl_get_timer_t *f_get_timer ) +{ + ssl->p_timer = p_timer; + ssl->f_set_timer = f_set_timer; + ssl->f_get_timer = f_get_timer; + + /* Make sure we start with no timer running */ + ssl_set_timer( ssl, 0 ); +} + +#if defined(MBEDTLS_SSL_SRV_C) +void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf, + void *p_cache, + int (*f_get_cache)(void *, mbedtls_ssl_session *), + int (*f_set_cache)(void *, const mbedtls_ssl_session *) ) +{ + conf->p_cache = p_cache; + conf->f_get_cache = f_get_cache; + conf->f_set_cache = f_set_cache; +} +#endif /* MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_CLI_C) +int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session ) +{ + int ret; + + if( ssl == NULL || + session == NULL || + ssl->session_negotiate == NULL || + ssl->conf->endpoint != MBEDTLS_SSL_IS_CLIENT ) + { + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + if( ( ret = ssl_session_copy( ssl->session_negotiate, session ) ) != 0 ) + return( ret ); + + ssl->handshake->resume = 1; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_CLI_C */ + +void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, + const int *ciphersuites ) +{ + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_0] = ciphersuites; + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_1] = ciphersuites; + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_2] = ciphersuites; + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_3] = ciphersuites; +} + +void mbedtls_ssl_conf_ciphersuites_for_version( mbedtls_ssl_config *conf, + const int *ciphersuites, + int major, int minor ) +{ + if( major != MBEDTLS_SSL_MAJOR_VERSION_3 ) + return; + + if( minor < MBEDTLS_SSL_MINOR_VERSION_0 || minor > MBEDTLS_SSL_MINOR_VERSION_3 ) + return; + + conf->ciphersuite_list[minor] = ciphersuites; +} + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +void mbedtls_ssl_conf_cert_profile( mbedtls_ssl_config *conf, + const mbedtls_x509_crt_profile *profile ) +{ + conf->cert_profile = profile; +} + +/* Append a new keycert entry to a (possibly empty) list */ +static int ssl_append_key_cert( mbedtls_ssl_key_cert **head, + mbedtls_x509_crt *cert, + mbedtls_pk_context *key ) +{ + mbedtls_ssl_key_cert *new; + + new = mbedtls_calloc( 1, sizeof( mbedtls_ssl_key_cert ) ); + if( new == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + new->cert = cert; + new->key = key; + new->next = NULL; + + /* Update head is the list was null, else add to the end */ + if( *head == NULL ) + { + *head = new; + } + else + { + mbedtls_ssl_key_cert *cur = *head; + while( cur->next != NULL ) + cur = cur->next; + cur->next = new; + } + + return( 0 ); +} + +int mbedtls_ssl_conf_own_cert( mbedtls_ssl_config *conf, + mbedtls_x509_crt *own_cert, + mbedtls_pk_context *pk_key ) +{ + return( ssl_append_key_cert( &conf->key_cert, own_cert, pk_key ) ); +} + +void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf, + mbedtls_x509_crt *ca_chain, + mbedtls_x509_crl *ca_crl ) +{ + conf->ca_chain = ca_chain; + conf->ca_crl = ca_crl; +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +int mbedtls_ssl_set_hs_own_cert( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *own_cert, + mbedtls_pk_context *pk_key ) +{ + return( ssl_append_key_cert( &ssl->handshake->sni_key_cert, + own_cert, pk_key ) ); +} + +void mbedtls_ssl_set_hs_ca_chain( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *ca_chain, + mbedtls_x509_crl *ca_crl ) +{ + ssl->handshake->sni_ca_chain = ca_chain; + ssl->handshake->sni_ca_crl = ca_crl; +} + +void mbedtls_ssl_set_hs_authmode( mbedtls_ssl_context *ssl, + int authmode ) +{ + ssl->handshake->sni_authmode = authmode; +} +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +/* + * Set EC J-PAKE password for current handshake + */ +int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl, + const unsigned char *pw, + size_t pw_len ) +{ + mbedtls_ecjpake_role role; + + if( ssl->handshake == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + role = MBEDTLS_ECJPAKE_SERVER; + else + role = MBEDTLS_ECJPAKE_CLIENT; + + return( mbedtls_ecjpake_setup( &ssl->handshake->ecjpake_ctx, + role, + MBEDTLS_MD_SHA256, + MBEDTLS_ECP_DP_SECP256R1, + pw, pw_len ) ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +int mbedtls_ssl_conf_psk( mbedtls_ssl_config *conf, + const unsigned char *psk, size_t psk_len, + const unsigned char *psk_identity, size_t psk_identity_len ) +{ + if( psk == NULL || psk_identity == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( psk_len > MBEDTLS_PSK_MAX_LEN ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + /* Identity len will be encoded on two bytes */ + if( ( psk_identity_len >> 16 ) != 0 || + psk_identity_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + if( conf->psk != NULL || conf->psk_identity != NULL ) + { + mbedtls_free( conf->psk ); + mbedtls_free( conf->psk_identity ); + conf->psk = NULL; + conf->psk_identity = NULL; + } + + if( ( conf->psk = mbedtls_calloc( 1, psk_len ) ) == NULL || + ( conf->psk_identity = mbedtls_calloc( 1, psk_identity_len ) ) == NULL ) + { + mbedtls_free( conf->psk ); + mbedtls_free( conf->psk_identity ); + conf->psk = NULL; + conf->psk_identity = NULL; + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + conf->psk_len = psk_len; + conf->psk_identity_len = psk_identity_len; + + memcpy( conf->psk, psk, conf->psk_len ); + memcpy( conf->psk_identity, psk_identity, conf->psk_identity_len ); + + return( 0 ); +} + +int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl, + const unsigned char *psk, size_t psk_len ) +{ + if( psk == NULL || ssl->handshake == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( psk_len > MBEDTLS_PSK_MAX_LEN ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( ssl->handshake->psk != NULL ) + mbedtls_free( ssl->handshake->psk ); + + if( ( ssl->handshake->psk = mbedtls_calloc( 1, psk_len ) ) == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + ssl->handshake->psk_len = psk_len; + memcpy( ssl->handshake->psk, psk, ssl->handshake->psk_len ); + + return( 0 ); +} + +void mbedtls_ssl_conf_psk_cb( mbedtls_ssl_config *conf, + int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, + size_t), + void *p_psk ) +{ + conf->f_psk = f_psk; + conf->p_psk = p_psk; +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C) +int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf, const char *dhm_P, const char *dhm_G ) +{ + int ret; + + if( ( ret = mbedtls_mpi_read_string( &conf->dhm_P, 16, dhm_P ) ) != 0 || + ( ret = mbedtls_mpi_read_string( &conf->dhm_G, 16, dhm_G ) ) != 0 ) + { + mbedtls_mpi_free( &conf->dhm_P ); + mbedtls_mpi_free( &conf->dhm_G ); + return( ret ); + } + + return( 0 ); +} + +int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx ) +{ + int ret; + + if( ( ret = mbedtls_mpi_copy( &conf->dhm_P, &dhm_ctx->P ) ) != 0 || + ( ret = mbedtls_mpi_copy( &conf->dhm_G, &dhm_ctx->G ) ) != 0 ) + { + mbedtls_mpi_free( &conf->dhm_P ); + mbedtls_mpi_free( &conf->dhm_G ); + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) +/* + * Set the minimum length for Diffie-Hellman parameters + */ +void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, + unsigned int bitlen ) +{ + conf->dhm_min_bitlen = bitlen; +} +#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +/* + * Set allowed/preferred hashes for handshake signatures + */ +void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, + const int *hashes ) +{ + conf->sig_hashes = hashes; +} +#endif + +#if defined(MBEDTLS_ECP_C) +/* + * Set the allowed elliptic curves + */ +void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, + const mbedtls_ecp_group_id *curve_list ) +{ + conf->curve_list = curve_list; +} +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname ) +{ + size_t hostname_len; + + if( hostname == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + hostname_len = strlen( hostname ); + + if( hostname_len + 1 == 0 ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( hostname_len > MBEDTLS_SSL_MAX_HOST_NAME_LEN ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + ssl->hostname = mbedtls_calloc( 1, hostname_len + 1 ); + + if( ssl->hostname == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + memcpy( ssl->hostname, hostname, hostname_len ); + + ssl->hostname[hostname_len] = '\0'; + + return( 0 ); +} +#endif + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +void mbedtls_ssl_conf_sni( mbedtls_ssl_config *conf, + int (*f_sni)(void *, mbedtls_ssl_context *, + const unsigned char *, size_t), + void *p_sni ) +{ + conf->f_sni = f_sni; + conf->p_sni = p_sni; +} +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +#if defined(MBEDTLS_SSL_ALPN) +int mbedtls_ssl_conf_alpn_protocols( mbedtls_ssl_config *conf, const char **protos ) +{ + size_t cur_len, tot_len; + const char **p; + + /* + * RFC 7301 3.1: "Empty strings MUST NOT be included and byte strings + * MUST NOT be truncated." + * We check lengths now rather than later. + */ + tot_len = 0; + for( p = protos; *p != NULL; p++ ) + { + cur_len = strlen( *p ); + tot_len += cur_len; + + if( cur_len == 0 || cur_len > 255 || tot_len > 65535 ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + conf->alpn_list = protos; + + return( 0 ); +} + +const char *mbedtls_ssl_get_alpn_protocol( const mbedtls_ssl_context *ssl ) +{ + return( ssl->alpn_chosen ); +} +#endif /* MBEDTLS_SSL_ALPN */ + +void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor ) +{ + conf->max_major_ver = major; + conf->max_minor_ver = minor; +} + +void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor ) +{ + conf->min_major_ver = major; + conf->min_minor_ver = minor; +} + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C) +void mbedtls_ssl_conf_fallback( mbedtls_ssl_config *conf, char fallback ) +{ + conf->fallback = fallback; +} +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +void mbedtls_ssl_conf_encrypt_then_mac( mbedtls_ssl_config *conf, char etm ) +{ + conf->encrypt_then_mac = etm; +} +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +void mbedtls_ssl_conf_extended_master_secret( mbedtls_ssl_config *conf, char ems ) +{ + conf->extended_ms = ems; +} +#endif + +#if defined(MBEDTLS_ARC4_C) +void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 ) +{ + conf->arc4_disabled = arc4; +} +#endif + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code ) +{ + if( mfl_code >= MBEDTLS_SSL_MAX_FRAG_LEN_INVALID || + mfl_code_to_length[mfl_code] > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + conf->mfl_code = mfl_code; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +void mbedtls_ssl_conf_truncated_hmac( mbedtls_ssl_config *conf, int truncate ) +{ + conf->trunc_hmac = truncate; +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) +void mbedtls_ssl_conf_cbc_record_splitting( mbedtls_ssl_config *conf, char split ) +{ + conf->cbc_record_splitting = split; +} +#endif + +void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy ) +{ + conf->allow_legacy_renegotiation = allow_legacy; +} + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +void mbedtls_ssl_conf_renegotiation( mbedtls_ssl_config *conf, int renegotiation ) +{ + conf->disable_renegotiation = renegotiation; +} + +void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_records ) +{ + conf->renego_max_records = max_records; +} + +void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf, + const unsigned char period[8] ) +{ + memcpy( conf->renego_period, period, 8 ); +} +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +#if defined(MBEDTLS_SSL_CLI_C) +void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets ) +{ + conf->session_tickets = use_tickets; +} +#endif + +#if defined(MBEDTLS_SSL_SRV_C) +void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf, + mbedtls_ssl_ticket_write_t *f_ticket_write, + mbedtls_ssl_ticket_parse_t *f_ticket_parse, + void *p_ticket ) +{ + conf->f_ticket_write = f_ticket_write; + conf->f_ticket_parse = f_ticket_parse; + conf->p_ticket = p_ticket; +} +#endif +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_EXPORT_KEYS) +void mbedtls_ssl_conf_export_keys_cb( mbedtls_ssl_config *conf, + mbedtls_ssl_export_keys_t *f_export_keys, + void *p_export_keys ) +{ + conf->f_export_keys = f_export_keys; + conf->p_export_keys = p_export_keys; +} +#endif + +/* + * SSL get accessors + */ +size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl ) +{ + return( ssl->in_offt == NULL ? 0 : ssl->in_msglen ); +} + +uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl ) +{ + if( ssl->session != NULL ) + return( ssl->session->verify_result ); + + if( ssl->session_negotiate != NULL ) + return( ssl->session_negotiate->verify_result ); + + return( 0xFFFFFFFF ); +} + +const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl ) +{ + if( ssl == NULL || ssl->session == NULL ) + return( NULL ); + + return mbedtls_ssl_get_ciphersuite_name( ssl->session->ciphersuite ); +} + +const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + switch( ssl->minor_ver ) + { + case MBEDTLS_SSL_MINOR_VERSION_2: + return( "DTLSv1.0" ); + + case MBEDTLS_SSL_MINOR_VERSION_3: + return( "DTLSv1.2" ); + + default: + return( "unknown (DTLS)" ); + } + } +#endif + + switch( ssl->minor_ver ) + { + case MBEDTLS_SSL_MINOR_VERSION_0: + return( "SSLv3.0" ); + + case MBEDTLS_SSL_MINOR_VERSION_1: + return( "TLSv1.0" ); + + case MBEDTLS_SSL_MINOR_VERSION_2: + return( "TLSv1.1" ); + + case MBEDTLS_SSL_MINOR_VERSION_3: + return( "TLSv1.2" ); + + default: + return( "unknown" ); + } +} + +int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ) +{ + size_t transform_expansion; + const mbedtls_ssl_transform *transform = ssl->transform_out; + +#if defined(MBEDTLS_ZLIB_SUPPORT) + if( ssl->session_out->compression != MBEDTLS_SSL_COMPRESS_NULL ) + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +#endif + + if( transform == NULL ) + return( (int) mbedtls_ssl_hdr_len( ssl ) ); + + switch( mbedtls_cipher_get_cipher_mode( &transform->cipher_ctx_enc ) ) + { + case MBEDTLS_MODE_GCM: + case MBEDTLS_MODE_CCM: + case MBEDTLS_MODE_STREAM: + transform_expansion = transform->minlen; + break; + + case MBEDTLS_MODE_CBC: + transform_expansion = transform->maclen + + mbedtls_cipher_get_block_size( &transform->cipher_ctx_enc ); + break; + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + return( (int)( mbedtls_ssl_hdr_len( ssl ) + transform_expansion ) ); +} + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl ) +{ + size_t max_len; + + /* + * Assume mfl_code is correct since it was checked when set + */ + max_len = mfl_code_to_length[ssl->conf->mfl_code]; + + /* + * Check if a smaller max length was negotiated + */ + if( ssl->session_out != NULL && + mfl_code_to_length[ssl->session_out->mfl_code] < max_len ) + { + max_len = mfl_code_to_length[ssl->session_out->mfl_code]; + } + + return max_len; +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +const mbedtls_x509_crt *mbedtls_ssl_get_peer_cert( const mbedtls_ssl_context *ssl ) +{ + if( ssl == NULL || ssl->session == NULL ) + return( NULL ); + + return( ssl->session->peer_cert ); +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_CLI_C) +int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session *dst ) +{ + if( ssl == NULL || + dst == NULL || + ssl->session == NULL || + ssl->conf->endpoint != MBEDTLS_SSL_IS_CLIENT ) + { + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + return( ssl_session_copy( dst, ssl->session ) ); +} +#endif /* MBEDTLS_SSL_CLI_C */ + +/* + * Perform a single step of the SSL handshake + */ +int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + ret = mbedtls_ssl_handshake_client_step( ssl ); +#endif +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + ret = mbedtls_ssl_handshake_server_step( ssl ); +#endif + + return( ret ); +} + +/* + * Perform the SSL handshake + */ +int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> handshake" ) ); + + while( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + { + ret = mbedtls_ssl_handshake_step( ssl ); + + if( ret != 0 ) + break; + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= handshake" ) ); + + return( ret ); +} + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +#if defined(MBEDTLS_SSL_SRV_C) +/* + * Write HelloRequest to request renegotiation on server + */ +static int ssl_write_hello_request( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write hello request" ) ); + + ssl->out_msglen = 4; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_HELLO_REQUEST; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write hello request" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SRV_C */ + +/* + * Actually renegotiate current connection, triggered by either: + * - any side: calling mbedtls_ssl_renegotiate(), + * - client: receiving a HelloRequest during mbedtls_ssl_read(), + * - server: receiving any handshake message on server during mbedtls_ssl_read() after + * the initial handshake is completed. + * If the handshake doesn't complete due to waiting for I/O, it will continue + * during the next calls to mbedtls_ssl_renegotiate() or mbedtls_ssl_read() respectively. + */ +static int ssl_start_renegotiation( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> renegotiate" ) ); + + if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) + return( ret ); + + /* RFC 6347 4.2.2: "[...] the HelloRequest will have message_seq = 0 and + * the ServerHello will have message_seq = 1" */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ) + { + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + ssl->handshake->out_msg_seq = 1; + else + ssl->handshake->in_msg_seq = 1; + } +#endif + + ssl->state = MBEDTLS_SSL_HELLO_REQUEST; + ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS; + + if( ( ret = mbedtls_ssl_handshake( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_handshake", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= renegotiate" ) ); + + return( 0 ); +} + +/* + * Renegotiate current connection on client, + * or request renegotiation on server + */ +int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_SSL_SRV_C) + /* On server, just send the request */ + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) + { + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_PENDING; + + /* Did we already try/start sending HelloRequest? */ + if( ssl->out_left != 0 ) + return( mbedtls_ssl_flush_output( ssl ) ); + + return( ssl_write_hello_request( ssl ) ); + } +#endif /* MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_CLI_C) + /* + * On client, either start the renegotiation process or, + * if already in progress, continue the handshake + */ + if( ssl->renego_status != MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + if( ( ret = ssl_start_renegotiation( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_start_renegotiation", ret ); + return( ret ); + } + } + else + { + if( ( ret = mbedtls_ssl_handshake( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_handshake", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_SSL_CLI_C */ + + return( ret ); +} + +/* + * Check record counters and renegotiate if they're above the limit. + */ +static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl ) +{ + size_t ep_len = ssl_ep_len( ssl ); + int in_ctr_cmp; + int out_ctr_cmp; + + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER || + ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING || + ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED ) + { + return( 0 ); + } + + in_ctr_cmp = memcmp( ssl->in_ctr + ep_len, + ssl->conf->renego_period + ep_len, 8 - ep_len ); + out_ctr_cmp = memcmp( ssl->out_ctr + ep_len, + ssl->conf->renego_period + ep_len, 8 - ep_len ); + + if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 ) + { + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "record counter limit reached: renegotiate" ) ); + return( mbedtls_ssl_renegotiate( ssl ) ); +} +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +/* + * Receive application data decrypted from the SSL layer + */ +int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) +{ + int ret, record_read = 0; + size_t n; + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> read" ) ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + + if( ssl->handshake != NULL && + ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) + { + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + return( ret ); + } + } +#endif + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ( ret = ssl_check_ctr_renegotiate( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_check_ctr_renegotiate", ret ); + return( ret ); + } +#endif + + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + { + ret = mbedtls_ssl_handshake( ssl ); + if( ret == MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO ) + { + record_read = 1; + } + else if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_handshake", ret ); + return( ret ); + } + } + + if( ssl->in_offt == NULL ) + { + /* Start timer if not already running */ + if( ssl->f_get_timer != NULL && + ssl->f_get_timer( ssl->p_timer ) == -1 ) + { + ssl_set_timer( ssl, ssl->conf->read_timeout ); + } + + if( ! record_read ) + { + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_SSL_CONN_EOF ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + } + + if( ssl->in_msglen == 0 && + ssl->in_msgtype == MBEDTLS_SSL_MSG_APPLICATION_DATA ) + { + /* + * OpenSSL sends empty messages to randomize the IV + */ + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_SSL_CONN_EOF ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + } + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received handshake message" ) ); + +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT && + ( ssl->in_msg[0] != MBEDTLS_SSL_HS_HELLO_REQUEST || + ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake received (not HelloRequest)" ) ); + + /* With DTLS, drop the packet (probably from last handshake) */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + return( MBEDTLS_ERR_SSL_WANT_READ ); +#endif + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake received (not ClientHello)" ) ); + + /* With DTLS, drop the packet (probably from last handshake) */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + return( MBEDTLS_ERR_SSL_WANT_READ ); +#endif + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } +#endif + + if( ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED || + ( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == + MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "refusing renegotiation, sending alert" ) ); + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + /* + * SSLv3 does not have a "no_renegotiation" alert + */ + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 ) + { + if( ( ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_WARNING, + MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION ) ) != 0 ) + { + return( ret ); + } + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || + MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + else + { + /* DTLS clients need to know renego is server-initiated */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_PENDING; + } +#endif + ret = ssl_start_renegotiation( ssl ); + if( ret == MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO ) + { + record_read = 1; + } + else if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_start_renegotiation", ret ); + return( ret ); + } + } + + /* If a non-handshake record was read during renego, fallthrough, + * else tell the user they should call mbedtls_ssl_read() again */ + if( ! record_read ) + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ) + { + + if( ssl->conf->renego_max_records >= 0 ) + { + if( ++ssl->renego_records_seen > ssl->conf->renego_max_records ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation requested, " + "but not honored by client" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + } + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + /* Fatal and closure alerts handled by mbedtls_ssl_read_record() */ + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_ALERT ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "ignoring non-fatal non-closure alert" ) ); + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_APPLICATION_DATA ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad application data message" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + ssl->in_offt = ssl->in_msg; + + /* We're going to return something now, cancel timer, + * except if handshake (renegotiation) is in progress */ + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + ssl_set_timer( ssl, 0 ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + /* If we requested renego but received AppData, resend HelloRequest. + * Do it now, after setting in_offt, to avoid taking this branch + * again if ssl_write_hello_request() returns WANT_WRITE */ +#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ) + { + if( ( ret = ssl_resend_hello_request( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_resend_hello_request", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_RENEGOTIATION */ +#endif + } + + n = ( len < ssl->in_msglen ) + ? len : ssl->in_msglen; + + memcpy( buf, ssl->in_offt, n ); + ssl->in_msglen -= n; + + if( ssl->in_msglen == 0 ) + /* all bytes consumed */ + ssl->in_offt = NULL; + else + /* more data available */ + ssl->in_offt += n; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= read" ) ); + + return( (int) n ); +} + +/* + * Send application data to be encrypted by the SSL layer, + * taking care of max fragment length and buffer size + */ +static int ssl_write_real( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + int ret; +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + size_t max_len = mbedtls_ssl_get_max_frag_len( ssl ); + + if( len > max_len ) + { +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "fragment larger than the (negotiated) " + "maximum fragment length: %d > %d", + len, max_len ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + else +#endif + len = max_len; + } +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + + if( ssl->out_left != 0 ) + { + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flush_output", ret ); + return( ret ); + } + } + else + { + ssl->out_msglen = len; + ssl->out_msgtype = MBEDTLS_SSL_MSG_APPLICATION_DATA; + memcpy( ssl->out_msg, buf, len ); + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + } + + return( (int) len ); +} + +/* + * Write application data, doing 1/n-1 splitting if necessary. + * + * With non-blocking I/O, ssl_write_real() may return WANT_WRITE, + * then the caller will call us again with the same arguments, so + * remember wether we already did the split or not. + */ +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) +static int ssl_write_split( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + int ret; + + if( ssl->conf->cbc_record_splitting == + MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED || + len <= 1 || + ssl->minor_ver > MBEDTLS_SSL_MINOR_VERSION_1 || + mbedtls_cipher_get_cipher_mode( &ssl->transform_out->cipher_ctx_enc ) + != MBEDTLS_MODE_CBC ) + { + return( ssl_write_real( ssl, buf, len ) ); + } + + if( ssl->split_done == 0 ) + { + if( ( ret = ssl_write_real( ssl, buf, 1 ) ) <= 0 ) + return( ret ); + ssl->split_done = 1; + } + + if( ( ret = ssl_write_real( ssl, buf + 1, len - 1 ) ) <= 0 ) + return( ret ); + ssl->split_done = 0; + + return( ret + 1 ); +} +#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ + +/* + * Write application data (public-facing wrapper) + */ +int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write" ) ); + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ( ret = ssl_check_ctr_renegotiate( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_check_ctr_renegotiate", ret ); + return( ret ); + } +#endif + + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) + { + if( ( ret = mbedtls_ssl_handshake( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_handshake", ret ); + return( ret ); + } + } + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + ret = ssl_write_split( ssl, buf, len ); +#else + ret = ssl_write_real( ssl, buf, len ); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write" ) ); + + return( ret ); +} + +/* + * Notify the peer that the connection is being closed + */ +int mbedtls_ssl_close_notify( mbedtls_ssl_context *ssl ) +{ + int ret; + + if( ssl == NULL || ssl->conf == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write close notify" ) ); + + if( ssl->out_left != 0 ) + return( mbedtls_ssl_flush_output( ssl ) ); + + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + { + if( ( ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_WARNING, + MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_send_alert_message", ret ); + return( ret ); + } + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write close notify" ) ); + + return( 0 ); +} + +void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ) +{ + if( transform == NULL ) + return; + +#if defined(MBEDTLS_ZLIB_SUPPORT) + deflateEnd( &transform->ctx_deflate ); + inflateEnd( &transform->ctx_inflate ); +#endif + + mbedtls_cipher_free( &transform->cipher_ctx_enc ); + mbedtls_cipher_free( &transform->cipher_ctx_dec ); + + mbedtls_md_free( &transform->md_ctx_enc ); + mbedtls_md_free( &transform->md_ctx_dec ); + + mbedtls_zeroize( transform, sizeof( mbedtls_ssl_transform ) ); +} + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +static void ssl_key_cert_free( mbedtls_ssl_key_cert *key_cert ) +{ + mbedtls_ssl_key_cert *cur = key_cert, *next; + + while( cur != NULL ) + { + next = cur->next; + mbedtls_free( cur ); + cur = next; + } +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake ) +{ + if( handshake == NULL ) + return; + +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + mbedtls_md5_free( &handshake->fin_md5 ); + mbedtls_sha1_free( &handshake->fin_sha1 ); +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_SHA256_C) + mbedtls_sha256_free( &handshake->fin_sha256 ); +#endif +#if defined(MBEDTLS_SHA512_C) + mbedtls_sha512_free( &handshake->fin_sha512 ); +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#if defined(MBEDTLS_DHM_C) + mbedtls_dhm_free( &handshake->dhm_ctx ); +#endif +#if defined(MBEDTLS_ECDH_C) + mbedtls_ecdh_free( &handshake->ecdh_ctx ); +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + mbedtls_ecjpake_free( &handshake->ecjpake_ctx ); +#if defined(MBEDTLS_SSL_CLI_C) + mbedtls_free( handshake->ecjpake_cache ); + handshake->ecjpake_cache = NULL; + handshake->ecjpake_cache_len = 0; +#endif +#endif + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + /* explicit void pointer cast for buggy MS compiler */ + mbedtls_free( (void *) handshake->curves ); +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + if( handshake->psk != NULL ) + { + mbedtls_zeroize( handshake->psk, handshake->psk_len ); + mbedtls_free( handshake->psk ); + } +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) && \ + defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + /* + * Free only the linked list wrapper, not the keys themselves + * since the belong to the SNI callback + */ + if( handshake->sni_key_cert != NULL ) + { + mbedtls_ssl_key_cert *cur = handshake->sni_key_cert, *next; + + while( cur != NULL ) + { + next = cur->next; + mbedtls_free( cur ); + cur = next; + } + } +#endif /* MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + mbedtls_free( handshake->verify_cookie ); + mbedtls_free( handshake->hs_msg ); + ssl_flight_free( handshake->flight ); +#endif + + mbedtls_zeroize( handshake, sizeof( mbedtls_ssl_handshake_params ) ); +} + +void mbedtls_ssl_session_free( mbedtls_ssl_session *session ) +{ + if( session == NULL ) + return; + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( session->peer_cert != NULL ) + { + mbedtls_x509_crt_free( session->peer_cert ); + mbedtls_free( session->peer_cert ); + } +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) + mbedtls_free( session->ticket ); +#endif + + mbedtls_zeroize( session, sizeof( mbedtls_ssl_session ) ); +} + +/* + * Free an SSL context + */ +void mbedtls_ssl_free( mbedtls_ssl_context *ssl ) +{ + if( ssl == NULL ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> free" ) ); + + if( ssl->out_buf != NULL ) + { + mbedtls_zeroize( ssl->out_buf, MBEDTLS_SSL_BUFFER_LEN ); + mbedtls_free( ssl->out_buf ); + } + + if( ssl->in_buf != NULL ) + { + mbedtls_zeroize( ssl->in_buf, MBEDTLS_SSL_BUFFER_LEN ); + mbedtls_free( ssl->in_buf ); + } + +#if defined(MBEDTLS_ZLIB_SUPPORT) + if( ssl->compress_buf != NULL ) + { + mbedtls_zeroize( ssl->compress_buf, MBEDTLS_SSL_BUFFER_LEN ); + mbedtls_free( ssl->compress_buf ); + } +#endif + + if( ssl->transform ) + { + mbedtls_ssl_transform_free( ssl->transform ); + mbedtls_free( ssl->transform ); + } + + if( ssl->handshake ) + { + mbedtls_ssl_handshake_free( ssl->handshake ); + mbedtls_ssl_transform_free( ssl->transform_negotiate ); + mbedtls_ssl_session_free( ssl->session_negotiate ); + + mbedtls_free( ssl->handshake ); + mbedtls_free( ssl->transform_negotiate ); + mbedtls_free( ssl->session_negotiate ); + } + + if( ssl->session ) + { + mbedtls_ssl_session_free( ssl->session ); + mbedtls_free( ssl->session ); + } + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( ssl->hostname != NULL ) + { + mbedtls_zeroize( ssl->hostname, strlen( ssl->hostname ) ); + mbedtls_free( ssl->hostname ); + } +#endif + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( mbedtls_ssl_hw_record_finish != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_finish()" ) ); + mbedtls_ssl_hw_record_finish( ssl ); + } +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) + mbedtls_free( ssl->cli_id ); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= free" ) ); + + /* Actually clear after last debug message */ + mbedtls_zeroize( ssl, sizeof( mbedtls_ssl_context ) ); +} + +/* + * Initialze mbedtls_ssl_config + */ +void mbedtls_ssl_config_init( mbedtls_ssl_config *conf ) +{ + memset( conf, 0, sizeof( mbedtls_ssl_config ) ); +} + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +static int ssl_preset_default_hashes[] = { +#if defined(MBEDTLS_SHA512_C) + MBEDTLS_MD_SHA512, + MBEDTLS_MD_SHA384, +#endif +#if defined(MBEDTLS_SHA256_C) + MBEDTLS_MD_SHA256, + MBEDTLS_MD_SHA224, +#endif +#if defined(MBEDTLS_SHA1_C) + MBEDTLS_MD_SHA1, +#endif + MBEDTLS_MD_NONE +}; +#endif + +static int ssl_preset_suiteb_ciphersuites[] = { + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + 0 +}; + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +static int ssl_preset_suiteb_hashes[] = { + MBEDTLS_MD_SHA256, + MBEDTLS_MD_SHA384, + MBEDTLS_MD_NONE +}; +#endif + +#if defined(MBEDTLS_ECP_C) +static mbedtls_ecp_group_id ssl_preset_suiteb_curves[] = { + MBEDTLS_ECP_DP_SECP256R1, + MBEDTLS_ECP_DP_SECP384R1, + MBEDTLS_ECP_DP_NONE +}; +#endif + +/* + * Load default in mbedtls_ssl_config + */ +int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, + int endpoint, int transport, int preset ) +{ +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C) + int ret; +#endif + + /* Use the functions here so that they are covered in tests, + * but otherwise access member directly for efficiency */ + mbedtls_ssl_conf_endpoint( conf, endpoint ); + mbedtls_ssl_conf_transport( conf, transport ); + + /* + * Things that are common to all presets + */ +#if defined(MBEDTLS_SSL_CLI_C) + if( endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + conf->authmode = MBEDTLS_SSL_VERIFY_REQUIRED; +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + conf->session_tickets = MBEDTLS_SSL_SESSION_TICKETS_ENABLED; +#endif + } +#endif + +#if defined(MBEDTLS_ARC4_C) + conf->arc4_disabled = MBEDTLS_SSL_ARC4_DISABLED; +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + conf->encrypt_then_mac = MBEDTLS_SSL_ETM_ENABLED; +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + conf->extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; +#endif + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + conf->cbc_record_splitting = MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED; +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) + conf->f_cookie_write = ssl_cookie_write_dummy; + conf->f_cookie_check = ssl_cookie_check_dummy; +#endif + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + conf->anti_replay = MBEDTLS_SSL_ANTI_REPLAY_ENABLED; +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + conf->hs_timeout_min = MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN; + conf->hs_timeout_max = MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX; +#endif + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + conf->renego_max_records = MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT; + memset( conf->renego_period, 0x00, 2 ); + memset( conf->renego_period + 2, 0xFF, 6 ); +#endif + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C) + if( endpoint == MBEDTLS_SSL_IS_SERVER ) + { + if( ( ret = mbedtls_ssl_conf_dh_param( conf, + MBEDTLS_DHM_RFC5114_MODP_2048_P, + MBEDTLS_DHM_RFC5114_MODP_2048_G ) ) != 0 ) + { + return( ret ); + } + } +#endif + + /* + * Preset-specific defaults + */ + switch( preset ) + { + /* + * NSA Suite B + */ + case MBEDTLS_SSL_PRESET_SUITEB: + conf->min_major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; + conf->min_minor_ver = MBEDTLS_SSL_MINOR_VERSION_3; /* TLS 1.2 */ + conf->max_major_ver = MBEDTLS_SSL_MAX_MAJOR_VERSION; + conf->max_minor_ver = MBEDTLS_SSL_MAX_MINOR_VERSION; + + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_0] = + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_1] = + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_2] = + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_3] = + ssl_preset_suiteb_ciphersuites; + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + conf->cert_profile = &mbedtls_x509_crt_profile_suiteb; +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + conf->sig_hashes = ssl_preset_suiteb_hashes; +#endif + +#if defined(MBEDTLS_ECP_C) + conf->curve_list = ssl_preset_suiteb_curves; +#endif + break; + + /* + * Default + */ + default: + conf->min_major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; + conf->min_minor_ver = MBEDTLS_SSL_MINOR_VERSION_1; /* TLS 1.0 */ + conf->max_major_ver = MBEDTLS_SSL_MAX_MAJOR_VERSION; + conf->max_minor_ver = MBEDTLS_SSL_MAX_MINOR_VERSION; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + conf->min_minor_ver = MBEDTLS_SSL_MINOR_VERSION_2; +#endif + + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_0] = + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_1] = + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_2] = + conf->ciphersuite_list[MBEDTLS_SSL_MINOR_VERSION_3] = + mbedtls_ssl_list_ciphersuites(); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + conf->cert_profile = &mbedtls_x509_crt_profile_default; +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + conf->sig_hashes = ssl_preset_default_hashes; +#endif + +#if defined(MBEDTLS_ECP_C) + conf->curve_list = mbedtls_ecp_grp_id_list(); +#endif + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) + conf->dhm_min_bitlen = 1024; +#endif + } + + return( 0 ); +} + +/* + * Free mbedtls_ssl_config + */ +void mbedtls_ssl_config_free( mbedtls_ssl_config *conf ) +{ +#if defined(MBEDTLS_DHM_C) + mbedtls_mpi_free( &conf->dhm_P ); + mbedtls_mpi_free( &conf->dhm_G ); +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + if( conf->psk != NULL ) + { + mbedtls_zeroize( conf->psk, conf->psk_len ); + mbedtls_zeroize( conf->psk_identity, conf->psk_identity_len ); + mbedtls_free( conf->psk ); + mbedtls_free( conf->psk_identity ); + conf->psk_len = 0; + conf->psk_identity_len = 0; + } +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + ssl_key_cert_free( conf->key_cert ); +#endif + + mbedtls_zeroize( conf, sizeof( mbedtls_ssl_config ) ); +} + +#if defined(MBEDTLS_PK_C) && \ + ( defined(MBEDTLS_RSA_C) || defined(MBEDTLS_ECDSA_C) ) +/* + * Convert between MBEDTLS_PK_XXX and SSL_SIG_XXX + */ +unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk ) +{ +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_can_do( pk, MBEDTLS_PK_RSA ) ) + return( MBEDTLS_SSL_SIG_RSA ); +#endif +#if defined(MBEDTLS_ECDSA_C) + if( mbedtls_pk_can_do( pk, MBEDTLS_PK_ECDSA ) ) + return( MBEDTLS_SSL_SIG_ECDSA ); +#endif + return( MBEDTLS_SSL_SIG_ANON ); +} + +mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig ) +{ + switch( sig ) + { +#if defined(MBEDTLS_RSA_C) + case MBEDTLS_SSL_SIG_RSA: + return( MBEDTLS_PK_RSA ); +#endif +#if defined(MBEDTLS_ECDSA_C) + case MBEDTLS_SSL_SIG_ECDSA: + return( MBEDTLS_PK_ECDSA ); +#endif + default: + return( MBEDTLS_PK_NONE ); + } +} +#endif /* MBEDTLS_PK_C && ( MBEDTLS_RSA_C || MBEDTLS_ECDSA_C ) */ + +/* + * Convert from MBEDTLS_SSL_HASH_XXX to MBEDTLS_MD_XXX + */ +mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash ) +{ + switch( hash ) + { +#if defined(MBEDTLS_MD5_C) + case MBEDTLS_SSL_HASH_MD5: + return( MBEDTLS_MD_MD5 ); +#endif +#if defined(MBEDTLS_SHA1_C) + case MBEDTLS_SSL_HASH_SHA1: + return( MBEDTLS_MD_SHA1 ); +#endif +#if defined(MBEDTLS_SHA256_C) + case MBEDTLS_SSL_HASH_SHA224: + return( MBEDTLS_MD_SHA224 ); + case MBEDTLS_SSL_HASH_SHA256: + return( MBEDTLS_MD_SHA256 ); +#endif +#if defined(MBEDTLS_SHA512_C) + case MBEDTLS_SSL_HASH_SHA384: + return( MBEDTLS_MD_SHA384 ); + case MBEDTLS_SSL_HASH_SHA512: + return( MBEDTLS_MD_SHA512 ); +#endif + default: + return( MBEDTLS_MD_NONE ); + } +} + +/* + * Convert from MBEDTLS_MD_XXX to MBEDTLS_SSL_HASH_XXX + */ +unsigned char mbedtls_ssl_hash_from_md_alg( int md ) +{ + switch( md ) + { +#if defined(MBEDTLS_MD5_C) + case MBEDTLS_MD_MD5: + return( MBEDTLS_SSL_HASH_MD5 ); +#endif +#if defined(MBEDTLS_SHA1_C) + case MBEDTLS_MD_SHA1: + return( MBEDTLS_SSL_HASH_SHA1 ); +#endif +#if defined(MBEDTLS_SHA256_C) + case MBEDTLS_MD_SHA224: + return( MBEDTLS_SSL_HASH_SHA224 ); + case MBEDTLS_MD_SHA256: + return( MBEDTLS_SSL_HASH_SHA256 ); +#endif +#if defined(MBEDTLS_SHA512_C) + case MBEDTLS_MD_SHA384: + return( MBEDTLS_SSL_HASH_SHA384 ); + case MBEDTLS_MD_SHA512: + return( MBEDTLS_SSL_HASH_SHA512 ); +#endif + default: + return( MBEDTLS_SSL_HASH_NONE ); + } +} + +#if defined(MBEDTLS_ECP_C) +/* + * Check if a curve proposed by the peer is in our list. + * Return 0 if we're willing to use it, -1 otherwise. + */ +int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id ) +{ + const mbedtls_ecp_group_id *gid; + + if( ssl->conf->curve_list == NULL ) + return( -1 ); + + for( gid = ssl->conf->curve_list; *gid != MBEDTLS_ECP_DP_NONE; gid++ ) + if( *gid == grp_id ) + return( 0 ); + + return( -1 ); +} +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +/* + * Check if a hash proposed by the peer is in our list. + * Return 0 if we're willing to use it, -1 otherwise. + */ +int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl, + mbedtls_md_type_t md ) +{ + const int *cur; + + if( ssl->conf->sig_hashes == NULL ) + return( -1 ); + + for( cur = ssl->conf->sig_hashes; *cur != MBEDTLS_MD_NONE; cur++ ) + if( *cur == (int) md ) + return( 0 ); + + return( -1 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt *cert, + const mbedtls_ssl_ciphersuite_t *ciphersuite, + int cert_endpoint, + uint32_t *flags ) +{ + int ret = 0; +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) + int usage = 0; +#endif +#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) + const char *ext_oid; + size_t ext_len; +#endif + +#if !defined(MBEDTLS_X509_CHECK_KEY_USAGE) && \ + !defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) + ((void) cert); + ((void) cert_endpoint); + ((void) flags); +#endif + +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) + if( cert_endpoint == MBEDTLS_SSL_IS_SERVER ) + { + /* Server part of the key exchange */ + switch( ciphersuite->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_RSA: + case MBEDTLS_KEY_EXCHANGE_RSA_PSK: + usage = MBEDTLS_X509_KU_KEY_ENCIPHERMENT; + break; + + case MBEDTLS_KEY_EXCHANGE_DHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + usage = MBEDTLS_X509_KU_DIGITAL_SIGNATURE; + break; + + case MBEDTLS_KEY_EXCHANGE_ECDH_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA: + usage = MBEDTLS_X509_KU_KEY_AGREEMENT; + break; + + /* Don't use default: we want warnings when adding new values */ + case MBEDTLS_KEY_EXCHANGE_NONE: + case MBEDTLS_KEY_EXCHANGE_PSK: + case MBEDTLS_KEY_EXCHANGE_DHE_PSK: + case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: + case MBEDTLS_KEY_EXCHANGE_ECJPAKE: + usage = 0; + } + } + else + { + /* Client auth: we only implement rsa_sign and mbedtls_ecdsa_sign for now */ + usage = MBEDTLS_X509_KU_DIGITAL_SIGNATURE; + } + + if( mbedtls_x509_crt_check_key_usage( cert, usage ) != 0 ) + { + *flags |= MBEDTLS_X509_BADCERT_KEY_USAGE; + ret = -1; + } +#else + ((void) ciphersuite); +#endif /* MBEDTLS_X509_CHECK_KEY_USAGE */ + +#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) + if( cert_endpoint == MBEDTLS_SSL_IS_SERVER ) + { + ext_oid = MBEDTLS_OID_SERVER_AUTH; + ext_len = MBEDTLS_OID_SIZE( MBEDTLS_OID_SERVER_AUTH ); + } + else + { + ext_oid = MBEDTLS_OID_CLIENT_AUTH; + ext_len = MBEDTLS_OID_SIZE( MBEDTLS_OID_CLIENT_AUTH ); + } + + if( mbedtls_x509_crt_check_extended_key_usage( cert, ext_oid, ext_len ) != 0 ) + { + *flags |= MBEDTLS_X509_BADCERT_EXT_KEY_USAGE; + ret = -1; + } +#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */ + + return( ret ); +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +/* + * Convert version numbers to/from wire format + * and, for DTLS, to/from TLS equivalent. + * + * For TLS this is the identity. + * For DTLS, use 1's complement (v -> 255 - v, and then map as follows: + * 1.0 <-> 3.2 (DTLS 1.0 is based on TLS 1.1) + * 1.x <-> 3.x+1 for x != 0 (DTLS 1.2 based on TLS 1.2) + */ +void mbedtls_ssl_write_version( int major, int minor, int transport, + unsigned char ver[2] ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + if( minor == MBEDTLS_SSL_MINOR_VERSION_2 ) + --minor; /* DTLS 1.0 stored as TLS 1.1 internally */ + + ver[0] = (unsigned char)( 255 - ( major - 2 ) ); + ver[1] = (unsigned char)( 255 - ( minor - 1 ) ); + } + else +#else + ((void) transport); +#endif + { + ver[0] = (unsigned char) major; + ver[1] = (unsigned char) minor; + } +} + +void mbedtls_ssl_read_version( int *major, int *minor, int transport, + const unsigned char ver[2] ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + *major = 255 - ver[0] + 2; + *minor = 255 - ver[1] + 1; + + if( *minor == MBEDTLS_SSL_MINOR_VERSION_1 ) + ++*minor; /* DTLS 1.0 stored as TLS 1.1 internally */ + } + else +#else + ((void) transport); +#endif + { + *major = ver[0]; + *minor = ver[1]; + } +} + +int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md ) +{ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 ) + return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH; + + switch( md ) + { +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) +#if defined(MBEDTLS_MD5_C) + case MBEDTLS_SSL_HASH_MD5: + return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH; +#endif +#if defined(MBEDTLS_SHA1_C) + case MBEDTLS_SSL_HASH_SHA1: + ssl->handshake->calc_verify = ssl_calc_verify_tls; + break; +#endif +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SHA512_C) + case MBEDTLS_SSL_HASH_SHA384: + ssl->handshake->calc_verify = ssl_calc_verify_tls_sha384; + break; +#endif +#if defined(MBEDTLS_SHA256_C) + case MBEDTLS_SSL_HASH_SHA256: + ssl->handshake->calc_verify = ssl_calc_verify_tls_sha256; + break; +#endif + default: + return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH; + } + + return 0; +#else /* !MBEDTLS_SSL_PROTO_TLS1_2 */ + (void) ssl; + (void) md; + + return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +} + +#endif /* MBEDTLS_SSL_TLS_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/threading.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/threading.c new file mode 100644 index 0000000..83ec01a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/threading.c @@ -0,0 +1,137 @@ +/* + * Threading abstraction layer + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_THREADING_C) + +#include "mbedtls/threading.h" + +#if defined(MBEDTLS_THREADING_PTHREAD) +static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *mutex ) +{ + if( mutex == NULL || mutex->is_valid ) + return; + + mutex->is_valid = pthread_mutex_init( &mutex->mutex, NULL ) == 0; +} + +static void threading_mutex_free_pthread( mbedtls_threading_mutex_t *mutex ) +{ + if( mutex == NULL || !mutex->is_valid ) + return; + + (void) pthread_mutex_destroy( &mutex->mutex ); + mutex->is_valid = 0; +} + +static int threading_mutex_lock_pthread( mbedtls_threading_mutex_t *mutex ) +{ + if( mutex == NULL || ! mutex->is_valid ) + return( MBEDTLS_ERR_THREADING_BAD_INPUT_DATA ); + + if( pthread_mutex_lock( &mutex->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); + + return( 0 ); +} + +static int threading_mutex_unlock_pthread( mbedtls_threading_mutex_t *mutex ) +{ + if( mutex == NULL || ! mutex->is_valid ) + return( MBEDTLS_ERR_THREADING_BAD_INPUT_DATA ); + + if( pthread_mutex_unlock( &mutex->mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); + + return( 0 ); +} + +void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t * ) = threading_mutex_init_pthread; +void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t * ) = threading_mutex_free_pthread; +int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t * ) = threading_mutex_lock_pthread; +int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t * ) = threading_mutex_unlock_pthread; + +/* + * With phtreads we can statically initialize mutexes + */ +#define MUTEX_INIT = { PTHREAD_MUTEX_INITIALIZER, 1 } + +#endif /* MBEDTLS_THREADING_PTHREAD */ + +#if defined(MBEDTLS_THREADING_ALT) +static int threading_mutex_fail( mbedtls_threading_mutex_t *mutex ) +{ + ((void) mutex ); + return( MBEDTLS_ERR_THREADING_BAD_INPUT_DATA ); +} +static void threading_mutex_dummy( mbedtls_threading_mutex_t *mutex ) +{ + ((void) mutex ); + return; +} + +void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t * ) = threading_mutex_dummy; +void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t * ) = threading_mutex_dummy; +int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t * ) = threading_mutex_fail; +int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t * ) = threading_mutex_fail; + +/* + * Set functions pointers and initialize global mutexes + */ +void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ), + void (*mutex_free)( mbedtls_threading_mutex_t * ), + int (*mutex_lock)( mbedtls_threading_mutex_t * ), + int (*mutex_unlock)( mbedtls_threading_mutex_t * ) ) +{ + mbedtls_mutex_init = mutex_init; + mbedtls_mutex_free = mutex_free; + mbedtls_mutex_lock = mutex_lock; + mbedtls_mutex_unlock = mutex_unlock; + + mbedtls_mutex_init( &mbedtls_threading_readdir_mutex ); + mbedtls_mutex_init( &mbedtls_threading_gmtime_mutex ); +} + +/* + * Free global mutexes + */ +void mbedtls_threading_free_alt( void ) +{ + mbedtls_mutex_free( &mbedtls_threading_readdir_mutex ); + mbedtls_mutex_free( &mbedtls_threading_gmtime_mutex ); +} +#endif /* MBEDTLS_THREADING_ALT */ + +/* + * Define global mutexes + */ +#ifndef MUTEX_INIT +#define MUTEX_INIT +#endif +mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex MUTEX_INIT; +mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex MUTEX_INIT; + +#endif /* MBEDTLS_THREADING_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/timing.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/timing.c new file mode 100644 index 0000000..a7c7ff0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/timing.c @@ -0,0 +1,525 @@ +/* + * Portable interface to the CPU cycle counter + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_TIMING_C) + +#include "mbedtls/timing.h" + +#if !defined(MBEDTLS_TIMING_ALT) + +#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ + !defined(__APPLE__) && !defined(_WIN32) +#error "This module only works on Unix and Windows, see MBEDTLS_TIMING_C in config.h" +#endif + +#ifndef asm +#define asm __asm +#endif + +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) + +#include +#include + +struct _hr_time +{ + LARGE_INTEGER start; +}; + +#else + +#include +#include +#include +#include +#include + +struct _hr_time +{ + struct timeval start; +}; + +#endif /* _WIN32 && !EFIX64 && !EFI32 */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + ( defined(_MSC_VER) && defined(_M_IX86) ) || defined(__WATCOMC__) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long tsc; + __asm rdtsc + __asm mov [tsc], eax + return( tsc ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + ( _MSC_VER && _M_IX86 ) || __WATCOMC__ */ + +/* some versions of mingw-64 have 32-bit longs even on x84_64 */ +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && ( defined(__i386__) || ( \ + ( defined(__amd64__) || defined( __x86_64__) ) && __SIZEOF_LONG__ == 4 ) ) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long lo, hi; + asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) ); + return( lo ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && __i386__ */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && ( defined(__amd64__) || defined(__x86_64__) ) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long lo, hi; + asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) ); + return( lo | ( hi << 32 ) ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && ( __amd64__ || __x86_64__ ) */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && ( defined(__powerpc__) || defined(__ppc__) ) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long tbl, tbu0, tbu1; + + do + { + asm volatile( "mftbu %0" : "=r" (tbu0) ); + asm volatile( "mftb %0" : "=r" (tbl ) ); + asm volatile( "mftbu %0" : "=r" (tbu1) ); + } + while( tbu0 != tbu1 ); + + return( tbl ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && ( __powerpc__ || __ppc__ ) */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && defined(__sparc64__) + +#if defined(__OpenBSD__) +#warning OpenBSD does not allow access to tick register using software version instead +#else +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long tick; + asm volatile( "rdpr %%tick, %0;" : "=&r" (tick) ); + return( tick ); +} +#endif /* __OpenBSD__ */ +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && __sparc64__ */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && defined(__sparc__) && !defined(__sparc64__) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long tick; + asm volatile( ".byte 0x83, 0x41, 0x00, 0x00" ); + asm volatile( "mov %%g1, %0" : "=r" (tick) ); + return( tick ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && __sparc__ && !__sparc64__ */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && defined(__alpha__) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long cc; + asm volatile( "rpcc %0" : "=r" (cc) ); + return( cc & 0xFFFFFFFF ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && __alpha__ */ + +#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ + defined(__GNUC__) && defined(__ia64__) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + unsigned long itc; + asm volatile( "mov %0 = ar.itc" : "=r" (itc) ); + return( itc ); +} +#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM && + __GNUC__ && __ia64__ */ + +#if !defined(HAVE_HARDCLOCK) && defined(_MSC_VER) && \ + !defined(EFIX64) && !defined(EFI32) + +#define HAVE_HARDCLOCK + +unsigned long mbedtls_timing_hardclock( void ) +{ + LARGE_INTEGER offset; + + QueryPerformanceCounter( &offset ); + + return( (unsigned long)( offset.QuadPart ) ); +} +#endif /* !HAVE_HARDCLOCK && _MSC_VER && !EFIX64 && !EFI32 */ + +#if !defined(HAVE_HARDCLOCK) + +#define HAVE_HARDCLOCK + +static int hardclock_init = 0; +static struct timeval tv_init; + +unsigned long mbedtls_timing_hardclock( void ) +{ + struct timeval tv_cur; + + if( hardclock_init == 0 ) + { + gettimeofday( &tv_init, NULL ); + hardclock_init = 1; + } + + gettimeofday( &tv_cur, NULL ); + return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000 + + ( tv_cur.tv_usec - tv_init.tv_usec ) ); +} +#endif /* !HAVE_HARDCLOCK */ + +volatile int mbedtls_timing_alarmed = 0; + +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) + +unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ) +{ + unsigned long delta; + LARGE_INTEGER offset, hfreq; + struct _hr_time *t = (struct _hr_time *) val; + + QueryPerformanceCounter( &offset ); + QueryPerformanceFrequency( &hfreq ); + + delta = (unsigned long)( ( 1000 * + ( offset.QuadPart - t->start.QuadPart ) ) / + hfreq.QuadPart ); + + if( reset ) + QueryPerformanceCounter( &t->start ); + + return( delta ); +} + +/* It's OK to use a global because alarm() is supposed to be global anyway */ +static DWORD alarmMs; + +static DWORD WINAPI TimerProc( LPVOID TimerContext ) +{ + ((void) TimerContext); + Sleep( alarmMs ); + mbedtls_timing_alarmed = 1; + return( TRUE ); +} + +void mbedtls_set_alarm( int seconds ) +{ + DWORD ThreadId; + + mbedtls_timing_alarmed = 0; + alarmMs = seconds * 1000; + CloseHandle( CreateThread( NULL, 0, TimerProc, NULL, 0, &ThreadId ) ); +} + +#else /* _WIN32 && !EFIX64 && !EFI32 */ + +unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ) +{ + unsigned long delta; + struct timeval offset; + struct _hr_time *t = (struct _hr_time *) val; + + gettimeofday( &offset, NULL ); + + if( reset ) + { + t->start.tv_sec = offset.tv_sec; + t->start.tv_usec = offset.tv_usec; + return( 0 ); + } + + delta = ( offset.tv_sec - t->start.tv_sec ) * 1000 + + ( offset.tv_usec - t->start.tv_usec ) / 1000; + + return( delta ); +} + +static void sighandler( int signum ) +{ + mbedtls_timing_alarmed = 1; + signal( signum, sighandler ); +} + +void mbedtls_set_alarm( int seconds ) +{ + mbedtls_timing_alarmed = 0; + signal( SIGALRM, sighandler ); + alarm( seconds ); +} + +#endif /* _WIN32 && !EFIX64 && !EFI32 */ + +/* + * Set delays to watch + */ +void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ) +{ + mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data; + + ctx->int_ms = int_ms; + ctx->fin_ms = fin_ms; + + if( fin_ms != 0 ) + (void) mbedtls_timing_get_timer( &ctx->timer, 1 ); +} + +/* + * Get number of delays expired + */ +int mbedtls_timing_get_delay( void *data ) +{ + mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data; + unsigned long elapsed_ms; + + if( ctx->fin_ms == 0 ) + return( -1 ); + + elapsed_ms = mbedtls_timing_get_timer( &ctx->timer, 0 ); + + if( elapsed_ms >= ctx->fin_ms ) + return( 2 ); + + if( elapsed_ms >= ctx->int_ms ) + return( 1 ); + + return( 0 ); +} + +#endif /* !MBEDTLS_TIMING_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +/* + * Busy-waits for the given number of milliseconds. + * Used for testing mbedtls_timing_hardclock. + */ +static void busy_msleep( unsigned long msec ) +{ + struct mbedtls_timing_hr_time hires; + unsigned long i = 0; /* for busy-waiting */ + volatile unsigned long j; /* to prevent optimisation */ + + (void) mbedtls_timing_get_timer( &hires, 1 ); + + while( mbedtls_timing_get_timer( &hires, 0 ) < msec ) + i++; + + j = i; + (void) j; +} + +#define FAIL do \ +{ \ + if( verbose != 0 ) \ + mbedtls_printf( "failed\n" ); \ + \ + return( 1 ); \ +} while( 0 ) + +/* + * Checkup routine + * + * Warning: this is work in progress, some tests may not be reliable enough + * yet! False positives may happen. + */ +int mbedtls_timing_self_test( int verbose ) +{ + unsigned long cycles, ratio; + unsigned long millisecs, secs; + int hardfail; + struct mbedtls_timing_hr_time hires; + uint32_t a, b; + mbedtls_timing_delay_context ctx; + + if( verbose != 0 ) + mbedtls_printf( " TIMING tests note: will take some time!\n" ); + + + if( verbose != 0 ) + mbedtls_printf( " TIMING test #1 (set_alarm / get_timer): " ); + + for( secs = 1; secs <= 3; secs++ ) + { + (void) mbedtls_timing_get_timer( &hires, 1 ); + + mbedtls_set_alarm( (int) secs ); + while( !mbedtls_timing_alarmed ) + ; + + millisecs = mbedtls_timing_get_timer( &hires, 0 ); + + /* For some reason on Windows it looks like alarm has an extra delay + * (maybe related to creating a new thread). Allow some room here. */ + if( millisecs < 800 * secs || millisecs > 1200 * secs + 300 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( 1 ); + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " TIMING test #2 (set/get_delay ): " ); + + for( a = 200; a <= 400; a += 200 ) + { + for( b = 200; b <= 400; b += 200 ) + { + mbedtls_timing_set_delay( &ctx, a, a + b ); + + busy_msleep( a - a / 8 ); + if( mbedtls_timing_get_delay( &ctx ) != 0 ) + FAIL; + + busy_msleep( a / 4 ); + if( mbedtls_timing_get_delay( &ctx ) != 1 ) + FAIL; + + busy_msleep( b - a / 8 - b / 8 ); + if( mbedtls_timing_get_delay( &ctx ) != 1 ) + FAIL; + + busy_msleep( b / 4 ); + if( mbedtls_timing_get_delay( &ctx ) != 2 ) + FAIL; + } + } + + mbedtls_timing_set_delay( &ctx, 0, 0 ); + busy_msleep( 200 ); + if( mbedtls_timing_get_delay( &ctx ) != -1 ) + FAIL; + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + + if( verbose != 0 ) + mbedtls_printf( " TIMING test #3 (hardclock / get_timer): " ); + + /* + * Allow one failure for possible counter wrapping. + * On a 4Ghz 32-bit machine the cycle counter wraps about once per second; + * since the whole test is about 10ms, it shouldn't happen twice in a row. + */ + hardfail = 0; + +hard_test: + if( hardfail > 1 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed (ignored)\n" ); + + goto hard_test_done; + } + + /* Get a reference ratio cycles/ms */ + millisecs = 1; + cycles = mbedtls_timing_hardclock(); + busy_msleep( millisecs ); + cycles = mbedtls_timing_hardclock() - cycles; + ratio = cycles / millisecs; + + /* Check that the ratio is mostly constant */ + for( millisecs = 2; millisecs <= 4; millisecs++ ) + { + cycles = mbedtls_timing_hardclock(); + busy_msleep( millisecs ); + cycles = mbedtls_timing_hardclock() - cycles; + + /* Allow variation up to 20% */ + if( cycles / millisecs < ratio - ratio / 5 || + cycles / millisecs > ratio + ratio / 5 ) + { + hardfail++; + goto hard_test; + } + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + +hard_test_done: + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_TIMING_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version.c new file mode 100644 index 0000000..6ca80d4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version.c @@ -0,0 +1,50 @@ +/* + * Version information + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_VERSION_C) + +#include "mbedtls/version.h" +#include + +unsigned int mbedtls_version_get_number() +{ + return( MBEDTLS_VERSION_NUMBER ); +} + +void mbedtls_version_get_string( char *string ) +{ + memcpy( string, MBEDTLS_VERSION_STRING, + sizeof( MBEDTLS_VERSION_STRING ) ); +} + +void mbedtls_version_get_string_full( char *string ) +{ + memcpy( string, MBEDTLS_VERSION_STRING_FULL, + sizeof( MBEDTLS_VERSION_STRING_FULL ) ); +} + +#endif /* MBEDTLS_VERSION_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version_features.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version_features.c new file mode 100644 index 0000000..e866e67 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/version_features.c @@ -0,0 +1,647 @@ +/* + * Version feature information + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_VERSION_C) + +#include "mbedtls/version.h" + +#include + +static const char *features[] = { +#if defined(MBEDTLS_VERSION_FEATURES) +#if defined(MBEDTLS_HAVE_ASM) + "MBEDTLS_HAVE_ASM", +#endif /* MBEDTLS_HAVE_ASM */ +#if defined(MBEDTLS_HAVE_SSE2) + "MBEDTLS_HAVE_SSE2", +#endif /* MBEDTLS_HAVE_SSE2 */ +#if defined(MBEDTLS_HAVE_TIME) + "MBEDTLS_HAVE_TIME", +#endif /* MBEDTLS_HAVE_TIME */ +#if defined(MBEDTLS_HAVE_TIME_DATE) + "MBEDTLS_HAVE_TIME_DATE", +#endif /* MBEDTLS_HAVE_TIME_DATE */ +#if defined(MBEDTLS_PLATFORM_MEMORY) + "MBEDTLS_PLATFORM_MEMORY", +#endif /* MBEDTLS_PLATFORM_MEMORY */ +#if defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) + "MBEDTLS_PLATFORM_NO_STD_FUNCTIONS", +#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ +#if defined(MBEDTLS_PLATFORM_EXIT_ALT) + "MBEDTLS_PLATFORM_EXIT_ALT", +#endif /* MBEDTLS_PLATFORM_EXIT_ALT */ +#if defined(MBEDTLS_PLATFORM_TIME_ALT) + "MBEDTLS_PLATFORM_TIME_ALT", +#endif /* MBEDTLS_PLATFORM_TIME_ALT */ +#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) + "MBEDTLS_PLATFORM_FPRINTF_ALT", +#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */ +#if defined(MBEDTLS_PLATFORM_PRINTF_ALT) + "MBEDTLS_PLATFORM_PRINTF_ALT", +#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */ +#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) + "MBEDTLS_PLATFORM_SNPRINTF_ALT", +#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ +#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) + "MBEDTLS_PLATFORM_NV_SEED_ALT", +#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ +#if defined(MBEDTLS_DEPRECATED_WARNING) + "MBEDTLS_DEPRECATED_WARNING", +#endif /* MBEDTLS_DEPRECATED_WARNING */ +#if defined(MBEDTLS_DEPRECATED_REMOVED) + "MBEDTLS_DEPRECATED_REMOVED", +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_TIMING_ALT) + "MBEDTLS_TIMING_ALT", +#endif /* MBEDTLS_TIMING_ALT */ +#if defined(MBEDTLS_AES_ALT) + "MBEDTLS_AES_ALT", +#endif /* MBEDTLS_AES_ALT */ +#if defined(MBEDTLS_ARC4_ALT) + "MBEDTLS_ARC4_ALT", +#endif /* MBEDTLS_ARC4_ALT */ +#if defined(MBEDTLS_BLOWFISH_ALT) + "MBEDTLS_BLOWFISH_ALT", +#endif /* MBEDTLS_BLOWFISH_ALT */ +#if defined(MBEDTLS_CAMELLIA_ALT) + "MBEDTLS_CAMELLIA_ALT", +#endif /* MBEDTLS_CAMELLIA_ALT */ +#if defined(MBEDTLS_DES_ALT) + "MBEDTLS_DES_ALT", +#endif /* MBEDTLS_DES_ALT */ +#if defined(MBEDTLS_XTEA_ALT) + "MBEDTLS_XTEA_ALT", +#endif /* MBEDTLS_XTEA_ALT */ +#if defined(MBEDTLS_MD2_ALT) + "MBEDTLS_MD2_ALT", +#endif /* MBEDTLS_MD2_ALT */ +#if defined(MBEDTLS_MD4_ALT) + "MBEDTLS_MD4_ALT", +#endif /* MBEDTLS_MD4_ALT */ +#if defined(MBEDTLS_MD5_ALT) + "MBEDTLS_MD5_ALT", +#endif /* MBEDTLS_MD5_ALT */ +#if defined(MBEDTLS_RIPEMD160_ALT) + "MBEDTLS_RIPEMD160_ALT", +#endif /* MBEDTLS_RIPEMD160_ALT */ +#if defined(MBEDTLS_SHA1_ALT) + "MBEDTLS_SHA1_ALT", +#endif /* MBEDTLS_SHA1_ALT */ +#if defined(MBEDTLS_SHA256_ALT) + "MBEDTLS_SHA256_ALT", +#endif /* MBEDTLS_SHA256_ALT */ +#if defined(MBEDTLS_SHA512_ALT) + "MBEDTLS_SHA512_ALT", +#endif /* MBEDTLS_SHA512_ALT */ +#if defined(MBEDTLS_MD2_PROCESS_ALT) + "MBEDTLS_MD2_PROCESS_ALT", +#endif /* MBEDTLS_MD2_PROCESS_ALT */ +#if defined(MBEDTLS_MD4_PROCESS_ALT) + "MBEDTLS_MD4_PROCESS_ALT", +#endif /* MBEDTLS_MD4_PROCESS_ALT */ +#if defined(MBEDTLS_MD5_PROCESS_ALT) + "MBEDTLS_MD5_PROCESS_ALT", +#endif /* MBEDTLS_MD5_PROCESS_ALT */ +#if defined(MBEDTLS_RIPEMD160_PROCESS_ALT) + "MBEDTLS_RIPEMD160_PROCESS_ALT", +#endif /* MBEDTLS_RIPEMD160_PROCESS_ALT */ +#if defined(MBEDTLS_SHA1_PROCESS_ALT) + "MBEDTLS_SHA1_PROCESS_ALT", +#endif /* MBEDTLS_SHA1_PROCESS_ALT */ +#if defined(MBEDTLS_SHA256_PROCESS_ALT) + "MBEDTLS_SHA256_PROCESS_ALT", +#endif /* MBEDTLS_SHA256_PROCESS_ALT */ +#if defined(MBEDTLS_SHA512_PROCESS_ALT) + "MBEDTLS_SHA512_PROCESS_ALT", +#endif /* MBEDTLS_SHA512_PROCESS_ALT */ +#if defined(MBEDTLS_DES_SETKEY_ALT) + "MBEDTLS_DES_SETKEY_ALT", +#endif /* MBEDTLS_DES_SETKEY_ALT */ +#if defined(MBEDTLS_DES_CRYPT_ECB_ALT) + "MBEDTLS_DES_CRYPT_ECB_ALT", +#endif /* MBEDTLS_DES_CRYPT_ECB_ALT */ +#if defined(MBEDTLS_DES3_CRYPT_ECB_ALT) + "MBEDTLS_DES3_CRYPT_ECB_ALT", +#endif /* MBEDTLS_DES3_CRYPT_ECB_ALT */ +#if defined(MBEDTLS_AES_SETKEY_ENC_ALT) + "MBEDTLS_AES_SETKEY_ENC_ALT", +#endif /* MBEDTLS_AES_SETKEY_ENC_ALT */ +#if defined(MBEDTLS_AES_SETKEY_DEC_ALT) + "MBEDTLS_AES_SETKEY_DEC_ALT", +#endif /* MBEDTLS_AES_SETKEY_DEC_ALT */ +#if defined(MBEDTLS_AES_ENCRYPT_ALT) + "MBEDTLS_AES_ENCRYPT_ALT", +#endif /* MBEDTLS_AES_ENCRYPT_ALT */ +#if defined(MBEDTLS_AES_DECRYPT_ALT) + "MBEDTLS_AES_DECRYPT_ALT", +#endif /* MBEDTLS_AES_DECRYPT_ALT */ +#if defined(MBEDTLS_TEST_NULL_ENTROPY) + "MBEDTLS_TEST_NULL_ENTROPY", +#endif /* MBEDTLS_TEST_NULL_ENTROPY */ +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + "MBEDTLS_ENTROPY_HARDWARE_ALT", +#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ +#if defined(MBEDTLS_AES_ROM_TABLES) + "MBEDTLS_AES_ROM_TABLES", +#endif /* MBEDTLS_AES_ROM_TABLES */ +#if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY) + "MBEDTLS_CAMELLIA_SMALL_MEMORY", +#endif /* MBEDTLS_CAMELLIA_SMALL_MEMORY */ +#if defined(MBEDTLS_CIPHER_MODE_CBC) + "MBEDTLS_CIPHER_MODE_CBC", +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_CIPHER_MODE_CFB) + "MBEDTLS_CIPHER_MODE_CFB", +#endif /* MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_CTR) + "MBEDTLS_CIPHER_MODE_CTR", +#endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) + "MBEDTLS_CIPHER_NULL_CIPHER", +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#if defined(MBEDTLS_CIPHER_PADDING_PKCS7) + "MBEDTLS_CIPHER_PADDING_PKCS7", +#endif /* MBEDTLS_CIPHER_PADDING_PKCS7 */ +#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS) + "MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS", +#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */ +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN) + "MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN", +#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */ +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS) + "MBEDTLS_CIPHER_PADDING_ZEROS", +#endif /* MBEDTLS_CIPHER_PADDING_ZEROS */ +#if defined(MBEDTLS_ENABLE_WEAK_CIPHERSUITES) + "MBEDTLS_ENABLE_WEAK_CIPHERSUITES", +#endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */ +#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES) + "MBEDTLS_REMOVE_ARC4_CIPHERSUITES", +#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */ +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + "MBEDTLS_ECP_DP_SECP192R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) + "MBEDTLS_ECP_DP_SECP224R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + "MBEDTLS_ECP_DP_SECP256R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + "MBEDTLS_ECP_DP_SECP384R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + "MBEDTLS_ECP_DP_SECP521R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) + "MBEDTLS_ECP_DP_SECP192K1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) + "MBEDTLS_ECP_DP_SECP224K1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) + "MBEDTLS_ECP_DP_SECP256K1_ENABLED", +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) + "MBEDTLS_ECP_DP_BP256R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) + "MBEDTLS_ECP_DP_BP384R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) + "MBEDTLS_ECP_DP_BP512R1_ENABLED", +#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + "MBEDTLS_ECP_DP_CURVE25519_ENABLED", +#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ +#if defined(MBEDTLS_ECP_NIST_OPTIM) + "MBEDTLS_ECP_NIST_OPTIM", +#endif /* MBEDTLS_ECP_NIST_OPTIM */ +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + "MBEDTLS_ECDSA_DETERMINISTIC", +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + "MBEDTLS_KEY_EXCHANGE_PSK_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) + "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) + "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED", +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ +#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED) + "MBEDTLS_PK_PARSE_EC_EXTENDED", +#endif /* MBEDTLS_PK_PARSE_EC_EXTENDED */ +#if defined(MBEDTLS_ERROR_STRERROR_DUMMY) + "MBEDTLS_ERROR_STRERROR_DUMMY", +#endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ +#if defined(MBEDTLS_GENPRIME) + "MBEDTLS_GENPRIME", +#endif /* MBEDTLS_GENPRIME */ +#if defined(MBEDTLS_FS_IO) + "MBEDTLS_FS_IO", +#endif /* MBEDTLS_FS_IO */ +#if defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) + "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES", +#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */ +#if defined(MBEDTLS_NO_PLATFORM_ENTROPY) + "MBEDTLS_NO_PLATFORM_ENTROPY", +#endif /* MBEDTLS_NO_PLATFORM_ENTROPY */ +#if defined(MBEDTLS_ENTROPY_FORCE_SHA256) + "MBEDTLS_ENTROPY_FORCE_SHA256", +#endif /* MBEDTLS_ENTROPY_FORCE_SHA256 */ +#if defined(MBEDTLS_ENTROPY_NV_SEED) + "MBEDTLS_ENTROPY_NV_SEED", +#endif /* MBEDTLS_ENTROPY_NV_SEED */ +#if defined(MBEDTLS_MEMORY_DEBUG) + "MBEDTLS_MEMORY_DEBUG", +#endif /* MBEDTLS_MEMORY_DEBUG */ +#if defined(MBEDTLS_MEMORY_BACKTRACE) + "MBEDTLS_MEMORY_BACKTRACE", +#endif /* MBEDTLS_MEMORY_BACKTRACE */ +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) + "MBEDTLS_PK_RSA_ALT_SUPPORT", +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ +#if defined(MBEDTLS_PKCS1_V15) + "MBEDTLS_PKCS1_V15", +#endif /* MBEDTLS_PKCS1_V15 */ +#if defined(MBEDTLS_PKCS1_V21) + "MBEDTLS_PKCS1_V21", +#endif /* MBEDTLS_PKCS1_V21 */ +#if defined(MBEDTLS_RSA_NO_CRT) + "MBEDTLS_RSA_NO_CRT", +#endif /* MBEDTLS_RSA_NO_CRT */ +#if defined(MBEDTLS_SELF_TEST) + "MBEDTLS_SELF_TEST", +#endif /* MBEDTLS_SELF_TEST */ +#if defined(MBEDTLS_SHA256_SMALLER) + "MBEDTLS_SHA256_SMALLER", +#endif /* MBEDTLS_SHA256_SMALLER */ +#if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES) + "MBEDTLS_SSL_ALL_ALERT_MESSAGES", +#endif /* MBEDTLS_SSL_ALL_ALERT_MESSAGES */ +#if defined(MBEDTLS_SSL_DEBUG_ALL) + "MBEDTLS_SSL_DEBUG_ALL", +#endif /* MBEDTLS_SSL_DEBUG_ALL */ +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + "MBEDTLS_SSL_ENCRYPT_THEN_MAC", +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + "MBEDTLS_SSL_EXTENDED_MASTER_SECRET", +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + "MBEDTLS_SSL_FALLBACK_SCSV", +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + "MBEDTLS_SSL_HW_RECORD_ACCEL", +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + "MBEDTLS_SSL_CBC_RECORD_SPLITTING", +#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + "MBEDTLS_SSL_RENEGOTIATION", +#endif /* MBEDTLS_SSL_RENEGOTIATION */ +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) + "MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO", +#endif /* MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO */ +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + "MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE", +#endif /* MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE */ +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + "MBEDTLS_SSL_MAX_FRAGMENT_LENGTH", +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + "MBEDTLS_SSL_PROTO_SSL3", +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) + "MBEDTLS_SSL_PROTO_TLS1", +#endif /* MBEDTLS_SSL_PROTO_TLS1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) + "MBEDTLS_SSL_PROTO_TLS1_1", +#endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + "MBEDTLS_SSL_PROTO_TLS1_2", +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + "MBEDTLS_SSL_PROTO_DTLS", +#endif /* MBEDTLS_SSL_PROTO_DTLS */ +#if defined(MBEDTLS_SSL_ALPN) + "MBEDTLS_SSL_ALPN", +#endif /* MBEDTLS_SSL_ALPN */ +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + "MBEDTLS_SSL_DTLS_ANTI_REPLAY", +#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + "MBEDTLS_SSL_DTLS_HELLO_VERIFY", +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) + "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE", +#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE */ +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) + "MBEDTLS_SSL_DTLS_BADMAC_LIMIT", +#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + "MBEDTLS_SSL_SESSION_TICKETS", +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + "MBEDTLS_SSL_EXPORT_KEYS", +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + "MBEDTLS_SSL_SERVER_NAME_INDICATION", +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + "MBEDTLS_SSL_TRUNCATED_HMAC", +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ +#if defined(MBEDTLS_THREADING_ALT) + "MBEDTLS_THREADING_ALT", +#endif /* MBEDTLS_THREADING_ALT */ +#if defined(MBEDTLS_THREADING_PTHREAD) + "MBEDTLS_THREADING_PTHREAD", +#endif /* MBEDTLS_THREADING_PTHREAD */ +#if defined(MBEDTLS_VERSION_FEATURES) + "MBEDTLS_VERSION_FEATURES", +#endif /* MBEDTLS_VERSION_FEATURES */ +#if defined(MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3) + "MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3", +#endif /* MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 */ +#if defined(MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION) + "MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION", +#endif /* MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION */ +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) + "MBEDTLS_X509_CHECK_KEY_USAGE", +#endif /* MBEDTLS_X509_CHECK_KEY_USAGE */ +#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) + "MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE", +#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */ +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + "MBEDTLS_X509_RSASSA_PSS_SUPPORT", +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ +#if defined(MBEDTLS_ZLIB_SUPPORT) + "MBEDTLS_ZLIB_SUPPORT", +#endif /* MBEDTLS_ZLIB_SUPPORT */ +#if defined(MBEDTLS_AESNI_C) + "MBEDTLS_AESNI_C", +#endif /* MBEDTLS_AESNI_C */ +#if defined(MBEDTLS_AES_C) + "MBEDTLS_AES_C", +#endif /* MBEDTLS_AES_C */ +#if defined(MBEDTLS_ARC4_C) + "MBEDTLS_ARC4_C", +#endif /* MBEDTLS_ARC4_C */ +#if defined(MBEDTLS_ASN1_PARSE_C) + "MBEDTLS_ASN1_PARSE_C", +#endif /* MBEDTLS_ASN1_PARSE_C */ +#if defined(MBEDTLS_ASN1_WRITE_C) + "MBEDTLS_ASN1_WRITE_C", +#endif /* MBEDTLS_ASN1_WRITE_C */ +#if defined(MBEDTLS_BASE64_C) + "MBEDTLS_BASE64_C", +#endif /* MBEDTLS_BASE64_C */ +#if defined(MBEDTLS_BIGNUM_C) + "MBEDTLS_BIGNUM_C", +#endif /* MBEDTLS_BIGNUM_C */ +#if defined(MBEDTLS_BLOWFISH_C) + "MBEDTLS_BLOWFISH_C", +#endif /* MBEDTLS_BLOWFISH_C */ +#if defined(MBEDTLS_CAMELLIA_C) + "MBEDTLS_CAMELLIA_C", +#endif /* MBEDTLS_CAMELLIA_C */ +#if defined(MBEDTLS_CCM_C) + "MBEDTLS_CCM_C", +#endif /* MBEDTLS_CCM_C */ +#if defined(MBEDTLS_CERTS_C) + "MBEDTLS_CERTS_C", +#endif /* MBEDTLS_CERTS_C */ +#if defined(MBEDTLS_CIPHER_C) + "MBEDTLS_CIPHER_C", +#endif /* MBEDTLS_CIPHER_C */ +#if defined(MBEDTLS_CMAC_C) + "MBEDTLS_CMAC_C", +#endif /* MBEDTLS_CMAC_C */ +#if defined(MBEDTLS_CTR_DRBG_C) + "MBEDTLS_CTR_DRBG_C", +#endif /* MBEDTLS_CTR_DRBG_C */ +#if defined(MBEDTLS_DEBUG_C) + "MBEDTLS_DEBUG_C", +#endif /* MBEDTLS_DEBUG_C */ +#if defined(MBEDTLS_DES_C) + "MBEDTLS_DES_C", +#endif /* MBEDTLS_DES_C */ +#if defined(MBEDTLS_DHM_C) + "MBEDTLS_DHM_C", +#endif /* MBEDTLS_DHM_C */ +#if defined(MBEDTLS_ECDH_C) + "MBEDTLS_ECDH_C", +#endif /* MBEDTLS_ECDH_C */ +#if defined(MBEDTLS_ECDSA_C) + "MBEDTLS_ECDSA_C", +#endif /* MBEDTLS_ECDSA_C */ +#if defined(MBEDTLS_ECJPAKE_C) + "MBEDTLS_ECJPAKE_C", +#endif /* MBEDTLS_ECJPAKE_C */ +#if defined(MBEDTLS_ECP_C) + "MBEDTLS_ECP_C", +#endif /* MBEDTLS_ECP_C */ +#if defined(MBEDTLS_ENTROPY_C) + "MBEDTLS_ENTROPY_C", +#endif /* MBEDTLS_ENTROPY_C */ +#if defined(MBEDTLS_ERROR_C) + "MBEDTLS_ERROR_C", +#endif /* MBEDTLS_ERROR_C */ +#if defined(MBEDTLS_GCM_C) + "MBEDTLS_GCM_C", +#endif /* MBEDTLS_GCM_C */ +#if defined(MBEDTLS_HAVEGE_C) + "MBEDTLS_HAVEGE_C", +#endif /* MBEDTLS_HAVEGE_C */ +#if defined(MBEDTLS_HMAC_DRBG_C) + "MBEDTLS_HMAC_DRBG_C", +#endif /* MBEDTLS_HMAC_DRBG_C */ +#if defined(MBEDTLS_MD_C) + "MBEDTLS_MD_C", +#endif /* MBEDTLS_MD_C */ +#if defined(MBEDTLS_MD2_C) + "MBEDTLS_MD2_C", +#endif /* MBEDTLS_MD2_C */ +#if defined(MBEDTLS_MD4_C) + "MBEDTLS_MD4_C", +#endif /* MBEDTLS_MD4_C */ +#if defined(MBEDTLS_MD5_C) + "MBEDTLS_MD5_C", +#endif /* MBEDTLS_MD5_C */ +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + "MBEDTLS_MEMORY_BUFFER_ALLOC_C", +#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */ +#if defined(MBEDTLS_NET_C) + "MBEDTLS_NET_C", +#endif /* MBEDTLS_NET_C */ +#if defined(MBEDTLS_OID_C) + "MBEDTLS_OID_C", +#endif /* MBEDTLS_OID_C */ +#if defined(MBEDTLS_PADLOCK_C) + "MBEDTLS_PADLOCK_C", +#endif /* MBEDTLS_PADLOCK_C */ +#if defined(MBEDTLS_PEM_PARSE_C) + "MBEDTLS_PEM_PARSE_C", +#endif /* MBEDTLS_PEM_PARSE_C */ +#if defined(MBEDTLS_PEM_WRITE_C) + "MBEDTLS_PEM_WRITE_C", +#endif /* MBEDTLS_PEM_WRITE_C */ +#if defined(MBEDTLS_PK_C) + "MBEDTLS_PK_C", +#endif /* MBEDTLS_PK_C */ +#if defined(MBEDTLS_PK_PARSE_C) + "MBEDTLS_PK_PARSE_C", +#endif /* MBEDTLS_PK_PARSE_C */ +#if defined(MBEDTLS_PK_WRITE_C) + "MBEDTLS_PK_WRITE_C", +#endif /* MBEDTLS_PK_WRITE_C */ +#if defined(MBEDTLS_PKCS5_C) + "MBEDTLS_PKCS5_C", +#endif /* MBEDTLS_PKCS5_C */ +#if defined(MBEDTLS_PKCS11_C) + "MBEDTLS_PKCS11_C", +#endif /* MBEDTLS_PKCS11_C */ +#if defined(MBEDTLS_PKCS12_C) + "MBEDTLS_PKCS12_C", +#endif /* MBEDTLS_PKCS12_C */ +#if defined(MBEDTLS_PLATFORM_C) + "MBEDTLS_PLATFORM_C", +#endif /* MBEDTLS_PLATFORM_C */ +#if defined(MBEDTLS_RIPEMD160_C) + "MBEDTLS_RIPEMD160_C", +#endif /* MBEDTLS_RIPEMD160_C */ +#if defined(MBEDTLS_RSA_C) + "MBEDTLS_RSA_C", +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_SHA1_C) + "MBEDTLS_SHA1_C", +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) + "MBEDTLS_SHA256_C", +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) + "MBEDTLS_SHA512_C", +#endif /* MBEDTLS_SHA512_C */ +#if defined(MBEDTLS_SSL_CACHE_C) + "MBEDTLS_SSL_CACHE_C", +#endif /* MBEDTLS_SSL_CACHE_C */ +#if defined(MBEDTLS_SSL_COOKIE_C) + "MBEDTLS_SSL_COOKIE_C", +#endif /* MBEDTLS_SSL_COOKIE_C */ +#if defined(MBEDTLS_SSL_TICKET_C) + "MBEDTLS_SSL_TICKET_C", +#endif /* MBEDTLS_SSL_TICKET_C */ +#if defined(MBEDTLS_SSL_CLI_C) + "MBEDTLS_SSL_CLI_C", +#endif /* MBEDTLS_SSL_CLI_C */ +#if defined(MBEDTLS_SSL_SRV_C) + "MBEDTLS_SSL_SRV_C", +#endif /* MBEDTLS_SSL_SRV_C */ +#if defined(MBEDTLS_SSL_TLS_C) + "MBEDTLS_SSL_TLS_C", +#endif /* MBEDTLS_SSL_TLS_C */ +#if defined(MBEDTLS_THREADING_C) + "MBEDTLS_THREADING_C", +#endif /* MBEDTLS_THREADING_C */ +#if defined(MBEDTLS_TIMING_C) + "MBEDTLS_TIMING_C", +#endif /* MBEDTLS_TIMING_C */ +#if defined(MBEDTLS_VERSION_C) + "MBEDTLS_VERSION_C", +#endif /* MBEDTLS_VERSION_C */ +#if defined(MBEDTLS_X509_USE_C) + "MBEDTLS_X509_USE_C", +#endif /* MBEDTLS_X509_USE_C */ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + "MBEDTLS_X509_CRT_PARSE_C", +#endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_X509_CRL_PARSE_C) + "MBEDTLS_X509_CRL_PARSE_C", +#endif /* MBEDTLS_X509_CRL_PARSE_C */ +#if defined(MBEDTLS_X509_CSR_PARSE_C) + "MBEDTLS_X509_CSR_PARSE_C", +#endif /* MBEDTLS_X509_CSR_PARSE_C */ +#if defined(MBEDTLS_X509_CREATE_C) + "MBEDTLS_X509_CREATE_C", +#endif /* MBEDTLS_X509_CREATE_C */ +#if defined(MBEDTLS_X509_CRT_WRITE_C) + "MBEDTLS_X509_CRT_WRITE_C", +#endif /* MBEDTLS_X509_CRT_WRITE_C */ +#if defined(MBEDTLS_X509_CSR_WRITE_C) + "MBEDTLS_X509_CSR_WRITE_C", +#endif /* MBEDTLS_X509_CSR_WRITE_C */ +#if defined(MBEDTLS_XTEA_C) + "MBEDTLS_XTEA_C", +#endif /* MBEDTLS_XTEA_C */ +#endif /* MBEDTLS_VERSION_FEATURES */ + NULL +}; + +int mbedtls_version_check_feature( const char *feature ) +{ + const char **idx = features; + + if( *idx == NULL ) + return( -2 ); + + if( feature == NULL ) + return( -1 ); + + while( *idx != NULL ) + { + if( !strcmp( *idx, feature ) ) + return( 0 ); + idx++; + } + return( -1 ); +} + +#endif /* MBEDTLS_VERSION_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509.c new file mode 100644 index 0000000..e438770 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509.c @@ -0,0 +1,1098 @@ +/* + * X.509 common functions for parsing and verification + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The ITU-T X.509 standard defines a certificate format for PKI. + * + * http://www.ietf.org/rfc/rfc5280.txt (Certificates and CRLs) + * http://www.ietf.org/rfc/rfc3279.txt (Alg IDs for CRLs) + * http://www.ietf.org/rfc/rfc2986.txt (CSRs, aka PKCS#10) + * + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_USE_C) + +#include "mbedtls/x509.h" +#include "mbedtls/asn1.h" +#include "mbedtls/oid.h" + +#include +#include + +#if defined(MBEDTLS_PEM_PARSE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_free free +#define mbedtls_calloc calloc +#define mbedtls_printf printf +#define mbedtls_snprintf snprintf +#endif + + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) +#include +#else +#include +#endif + +#if defined(MBEDTLS_FS_IO) +#include +#if !defined(_WIN32) +#include +#include +#include +#endif +#endif + +#define CHECK(code) if( ( ret = code ) != 0 ){ return( ret ); } +#define CHECK_RANGE(min, max, val) if( val < min || val > max ){ return( ret ); } + +/* + * CertificateSerialNumber ::= INTEGER + */ +int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *serial ) +{ + int ret; + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_SERIAL + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + if( **p != ( MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_PRIMITIVE | 2 ) && + **p != MBEDTLS_ASN1_INTEGER ) + return( MBEDTLS_ERR_X509_INVALID_SERIAL + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + serial->tag = *(*p)++; + + if( ( ret = mbedtls_asn1_get_len( p, end, &serial->len ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_SERIAL + ret ); + + serial->p = *p; + *p += serial->len; + + return( 0 ); +} + +/* Get an algorithm identifier without parameters (eg for signatures) + * + * AlgorithmIdentifier ::= SEQUENCE { + * algorithm OBJECT IDENTIFIER, + * parameters ANY DEFINED BY algorithm OPTIONAL } + */ +int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *alg ) +{ + int ret; + + if( ( ret = mbedtls_asn1_get_alg_null( p, end, alg ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + return( 0 ); +} + +/* + * Parse an algorithm identifier with (optional) paramaters + */ +int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *alg, mbedtls_x509_buf *params ) +{ + int ret; + + if( ( ret = mbedtls_asn1_get_alg( p, end, alg, params ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + return( 0 ); +} + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) +/* + * HashAlgorithm ::= AlgorithmIdentifier + * + * AlgorithmIdentifier ::= SEQUENCE { + * algorithm OBJECT IDENTIFIER, + * parameters ANY DEFINED BY algorithm OPTIONAL } + * + * For HashAlgorithm, parameters MUST be NULL or absent. + */ +static int x509_get_hash_alg( const mbedtls_x509_buf *alg, mbedtls_md_type_t *md_alg ) +{ + int ret; + unsigned char *p; + const unsigned char *end; + mbedtls_x509_buf md_oid; + size_t len; + + /* Make sure we got a SEQUENCE and setup bounds */ + if( alg->tag != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + p = (unsigned char *) alg->p; + end = p + alg->len; + + if( p >= end ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + /* Parse md_oid */ + md_oid.tag = *p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &md_oid.len, MBEDTLS_ASN1_OID ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + md_oid.p = p; + p += md_oid.len; + + /* Get md_alg from md_oid */ + if( ( ret = mbedtls_oid_get_md_alg( &md_oid, md_alg ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + /* Make sure params is absent of NULL */ + if( p == end ) + return( 0 ); + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_NULL ) ) != 0 || len != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p != end ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * RSASSA-PSS-params ::= SEQUENCE { + * hashAlgorithm [0] HashAlgorithm DEFAULT sha1Identifier, + * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1Identifier, + * saltLength [2] INTEGER DEFAULT 20, + * trailerField [3] INTEGER DEFAULT 1 } + * -- Note that the tags in this Sequence are explicit. + * + * RFC 4055 (which defines use of RSASSA-PSS in PKIX) states that the value + * of trailerField MUST be 1, and PKCS#1 v2.2 doesn't even define any other + * option. Enfore this at parsing time. + */ +int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params, + mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md, + int *salt_len ) +{ + int ret; + unsigned char *p; + const unsigned char *end, *end2; + size_t len; + mbedtls_x509_buf alg_id, alg_params; + + /* First set everything to defaults */ + *md_alg = MBEDTLS_MD_SHA1; + *mgf_md = MBEDTLS_MD_SHA1; + *salt_len = 20; + + /* Make sure params is a SEQUENCE and setup bounds */ + if( params->tag != ( MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + p = (unsigned char *) params->p; + end = p + params->len; + + if( p == end ) + return( 0 ); + + /* + * HashAlgorithm + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 0 ) ) == 0 ) + { + end2 = p + len; + + /* HashAlgorithm ::= AlgorithmIdentifier (without parameters) */ + if( ( ret = mbedtls_x509_get_alg_null( &p, end2, &alg_id ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_oid_get_md_alg( &alg_id, md_alg ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p != end2 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p == end ) + return( 0 ); + + /* + * MaskGenAlgorithm + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 1 ) ) == 0 ) + { + end2 = p + len; + + /* MaskGenAlgorithm ::= AlgorithmIdentifier (params = HashAlgorithm) */ + if( ( ret = mbedtls_x509_get_alg( &p, end2, &alg_id, &alg_params ) ) != 0 ) + return( ret ); + + /* Only MFG1 is recognised for now */ + if( MBEDTLS_OID_CMP( MBEDTLS_OID_MGF1, &alg_id ) != 0 ) + return( MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE + + MBEDTLS_ERR_OID_NOT_FOUND ); + + /* Parse HashAlgorithm */ + if( ( ret = x509_get_hash_alg( &alg_params, mgf_md ) ) != 0 ) + return( ret ); + + if( p != end2 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p == end ) + return( 0 ); + + /* + * salt_len + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 2 ) ) == 0 ) + { + end2 = p + len; + + if( ( ret = mbedtls_asn1_get_int( &p, end2, salt_len ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p != end2 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p == end ) + return( 0 ); + + /* + * trailer_field (if present, must be 1) + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 3 ) ) == 0 ) + { + int trailer_field; + + end2 = p + len; + + if( ( ret = mbedtls_asn1_get_int( &p, end2, &trailer_field ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p != end2 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + if( trailer_field != 1 ) + return( MBEDTLS_ERR_X509_INVALID_ALG ); + } + else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + if( p != end ) + return( MBEDTLS_ERR_X509_INVALID_ALG + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ + +/* + * AttributeTypeAndValue ::= SEQUENCE { + * type AttributeType, + * value AttributeValue } + * + * AttributeType ::= OBJECT IDENTIFIER + * + * AttributeValue ::= ANY DEFINED BY AttributeType + */ +static int x509_get_attr_type_value( unsigned char **p, + const unsigned char *end, + mbedtls_x509_name *cur ) +{ + int ret; + size_t len; + mbedtls_x509_buf *oid; + mbedtls_x509_buf *val; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_NAME + ret ); + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_NAME + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + oid = &cur->oid; + oid->tag = **p; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &oid->len, MBEDTLS_ASN1_OID ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_NAME + ret ); + + oid->p = *p; + *p += oid->len; + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_NAME + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + if( **p != MBEDTLS_ASN1_BMP_STRING && **p != MBEDTLS_ASN1_UTF8_STRING && + **p != MBEDTLS_ASN1_T61_STRING && **p != MBEDTLS_ASN1_PRINTABLE_STRING && + **p != MBEDTLS_ASN1_IA5_STRING && **p != MBEDTLS_ASN1_UNIVERSAL_STRING && + **p != MBEDTLS_ASN1_BIT_STRING ) + return( MBEDTLS_ERR_X509_INVALID_NAME + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + val = &cur->val; + val->tag = *(*p)++; + + if( ( ret = mbedtls_asn1_get_len( p, end, &val->len ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_NAME + ret ); + + val->p = *p; + *p += val->len; + + cur->next = NULL; + + return( 0 ); +} + +/* + * Name ::= CHOICE { -- only one possibility for now -- + * rdnSequence RDNSequence } + * + * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName + * + * RelativeDistinguishedName ::= + * SET OF AttributeTypeAndValue + * + * AttributeTypeAndValue ::= SEQUENCE { + * type AttributeType, + * value AttributeValue } + * + * AttributeType ::= OBJECT IDENTIFIER + * + * AttributeValue ::= ANY DEFINED BY AttributeType + * + * The data structure is optimized for the common case where each RDN has only + * one element, which is represented as a list of AttributeTypeAndValue. + * For the general case we still use a flat list, but we mark elements of the + * same set so that they are "merged" together in the functions that consume + * this list, eg mbedtls_x509_dn_gets(). + */ +int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end, + mbedtls_x509_name *cur ) +{ + int ret; + size_t set_len; + const unsigned char *end_set; + + /* don't use recursion, we'd risk stack overflow if not optimized */ + while( 1 ) + { + /* + * parse SET + */ + if( ( ret = mbedtls_asn1_get_tag( p, end, &set_len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SET ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_NAME + ret ); + + end_set = *p + set_len; + + while( 1 ) + { + if( ( ret = x509_get_attr_type_value( p, end_set, cur ) ) != 0 ) + return( ret ); + + if( *p == end_set ) + break; + + /* Mark this item as being no the only one in a set */ + cur->next_merged = 1; + + cur->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_name ) ); + + if( cur->next == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + cur = cur->next; + } + + /* + * continue until end of SEQUENCE is reached + */ + if( *p == end ) + return( 0 ); + + cur->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_name ) ); + + if( cur->next == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + cur = cur->next; + } +} + +static int x509_parse_int( unsigned char **p, size_t n, int *res ) +{ + *res = 0; + + for( ; n > 0; --n ) + { + if( ( **p < '0') || ( **p > '9' ) ) + return ( MBEDTLS_ERR_X509_INVALID_DATE ); + + *res *= 10; + *res += ( *(*p)++ - '0' ); + } + + return( 0 ); +} + +static int x509_date_is_valid(const mbedtls_x509_time *time) +{ + int ret = MBEDTLS_ERR_X509_INVALID_DATE; + + CHECK_RANGE( 0, 9999, time->year ); + CHECK_RANGE( 0, 23, time->hour ); + CHECK_RANGE( 0, 59, time->min ); + CHECK_RANGE( 0, 59, time->sec ); + + switch( time->mon ) + { + case 1: case 3: case 5: case 7: case 8: case 10: case 12: + CHECK_RANGE( 1, 31, time->day ); + break; + case 4: case 6: case 9: case 11: + CHECK_RANGE( 1, 30, time->day ); + break; + case 2: + CHECK_RANGE( 1, 28 + (time->year % 4 == 0), time->day ); + break; + default: + return( ret ); + } + + return( 0 ); +} + +/* + * Parse an ASN1_UTC_TIME (yearlen=2) or ASN1_GENERALIZED_TIME (yearlen=4) + * field. + */ +static int x509_parse_time( unsigned char **p, size_t len, size_t yearlen, + mbedtls_x509_time *time ) +{ + int ret; + + /* + * Minimum length is 10 or 12 depending on yearlen + */ + if ( len < yearlen + 8 ) + return ( MBEDTLS_ERR_X509_INVALID_DATE ); + len -= yearlen + 8; + + /* + * Parse year, month, day, hour, minute + */ + CHECK( x509_parse_int( p, yearlen, &time->year ) ); + if ( 2 == yearlen ) + { + if ( time->year < 50 ) + time->year += 100; + + time->year += 1900; + } + + CHECK( x509_parse_int( p, 2, &time->mon ) ); + CHECK( x509_parse_int( p, 2, &time->day ) ); + CHECK( x509_parse_int( p, 2, &time->hour ) ); + CHECK( x509_parse_int( p, 2, &time->min ) ); + + /* + * Parse seconds if present + */ + if ( len >= 2 ) + { + CHECK( x509_parse_int( p, 2, &time->sec ) ); + len -= 2; + } + else + return ( MBEDTLS_ERR_X509_INVALID_DATE ); + + /* + * Parse trailing 'Z' if present + */ + if ( 1 == len && 'Z' == **p ) + { + (*p)++; + len--; + } + + /* + * We should have parsed all characters at this point + */ + if ( 0 != len ) + return ( MBEDTLS_ERR_X509_INVALID_DATE ); + + CHECK( x509_date_is_valid( time ) ); + + return ( 0 ); +} + +/* + * Time ::= CHOICE { + * utcTime UTCTime, + * generalTime GeneralizedTime } + */ +int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end, + mbedtls_x509_time *time ) +{ + int ret; + size_t len, year_len; + unsigned char tag; + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_DATE + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + tag = **p; + + if( tag == MBEDTLS_ASN1_UTC_TIME ) + year_len = 2; + else if( tag == MBEDTLS_ASN1_GENERALIZED_TIME ) + year_len = 4; + else + return( MBEDTLS_ERR_X509_INVALID_DATE + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + (*p)++; + ret = mbedtls_asn1_get_len( p, end, &len ); + + if( ret != 0 ) + return( MBEDTLS_ERR_X509_INVALID_DATE + ret ); + + return x509_parse_time( p, len, year_len, time ); +} + +int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig ) +{ + int ret; + size_t len; + int tag_type; + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_SIGNATURE + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + tag_type = **p; + + if( ( ret = mbedtls_asn1_get_bitstring_null( p, end, &len ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_SIGNATURE + ret ); + + sig->tag = tag_type; + sig->len = len; + sig->p = *p; + + *p += len; + + return( 0 ); +} + +/* + * Get signature algorithm from alg OID and optional parameters + */ +int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, + mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, + void **sig_opts ) +{ + int ret; + + if( *sig_opts != NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + if( ( ret = mbedtls_oid_get_sig_alg( sig_oid, md_alg, pk_alg ) ) != 0 ) + return( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + ret ); + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + if( *pk_alg == MBEDTLS_PK_RSASSA_PSS ) + { + mbedtls_pk_rsassa_pss_options *pss_opts; + + pss_opts = mbedtls_calloc( 1, sizeof( mbedtls_pk_rsassa_pss_options ) ); + if( pss_opts == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + ret = mbedtls_x509_get_rsassa_pss_params( sig_params, + md_alg, + &pss_opts->mgf1_hash_id, + &pss_opts->expected_salt_len ); + if( ret != 0 ) + { + mbedtls_free( pss_opts ); + return( ret ); + } + + *sig_opts = (void *) pss_opts; + } + else +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ + { + /* Make sure parameters are absent or NULL */ + if( ( sig_params->tag != MBEDTLS_ASN1_NULL && sig_params->tag != 0 ) || + sig_params->len != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG ); + } + + return( 0 ); +} + +/* + * X.509 Extensions (No parsing of extensions, pointer should + * be either manually updated or extensions should be parsed!) + */ +int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end, + mbedtls_x509_buf *ext, int tag ) +{ + int ret; + size_t len; + + if( *p == end ) + return( 0 ); + + ext->tag = **p; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &ext->len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | tag ) ) != 0 ) + return( ret ); + + ext->p = *p; + end = *p + ext->len; + + /* + * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension + * + * Extension ::= SEQUENCE { + * extnID OBJECT IDENTIFIER, + * critical BOOLEAN DEFAULT FALSE, + * extnValue OCTET STRING } + */ + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( end != *p + len ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * Store the name in printable form into buf; no more + * than size characters will be written + */ +int mbedtls_x509_dn_gets( char *buf, size_t size, const mbedtls_x509_name *dn ) +{ + int ret; + size_t i, n; + unsigned char c, merge = 0; + const mbedtls_x509_name *name; + const char *short_name = NULL; + char s[MBEDTLS_X509_MAX_DN_NAME_SIZE], *p; + + memset( s, 0, sizeof( s ) ); + + name = dn; + p = buf; + n = size; + + while( name != NULL ) + { + if( !name->oid.p ) + { + name = name->next; + continue; + } + + if( name != dn ) + { + ret = mbedtls_snprintf( p, n, merge ? " + " : ", " ); + MBEDTLS_X509_SAFE_SNPRINTF; + } + + ret = mbedtls_oid_get_attr_short_name( &name->oid, &short_name ); + + if( ret == 0 ) + ret = mbedtls_snprintf( p, n, "%s=", short_name ); + else + ret = mbedtls_snprintf( p, n, "\?\?=" ); + MBEDTLS_X509_SAFE_SNPRINTF; + + for( i = 0; i < name->val.len; i++ ) + { + if( i >= sizeof( s ) - 1 ) + break; + + c = name->val.p[i]; + if( c < 32 || c == 127 || ( c > 128 && c < 160 ) ) + s[i] = '?'; + else s[i] = c; + } + s[i] = '\0'; + ret = mbedtls_snprintf( p, n, "%s", s ); + MBEDTLS_X509_SAFE_SNPRINTF; + + merge = name->next_merged; + name = name->next; + } + + return( (int) ( size - n ) ); +} + +/* + * Store the serial in printable form into buf; no more + * than size characters will be written + */ +int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *serial ) +{ + int ret; + size_t i, n, nr; + char *p; + + p = buf; + n = size; + + nr = ( serial->len <= 32 ) + ? serial->len : 28; + + for( i = 0; i < nr; i++ ) + { + if( i == 0 && nr > 1 && serial->p[i] == 0x0 ) + continue; + + ret = mbedtls_snprintf( p, n, "%02X%s", + serial->p[i], ( i < nr - 1 ) ? ":" : "" ); + MBEDTLS_X509_SAFE_SNPRINTF; + } + + if( nr != serial->len ) + { + ret = mbedtls_snprintf( p, n, "...." ); + MBEDTLS_X509_SAFE_SNPRINTF; + } + + return( (int) ( size - n ) ); +} + +/* + * Helper for writing signature algorithms + */ +int mbedtls_x509_sig_alg_gets( char *buf, size_t size, const mbedtls_x509_buf *sig_oid, + mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, + const void *sig_opts ) +{ + int ret; + char *p = buf; + size_t n = size; + const char *desc = NULL; + + ret = mbedtls_oid_get_sig_alg_desc( sig_oid, &desc ); + if( ret != 0 ) + ret = mbedtls_snprintf( p, n, "???" ); + else + ret = mbedtls_snprintf( p, n, "%s", desc ); + MBEDTLS_X509_SAFE_SNPRINTF; + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + if( pk_alg == MBEDTLS_PK_RSASSA_PSS ) + { + const mbedtls_pk_rsassa_pss_options *pss_opts; + const mbedtls_md_info_t *md_info, *mgf_md_info; + + pss_opts = (const mbedtls_pk_rsassa_pss_options *) sig_opts; + + md_info = mbedtls_md_info_from_type( md_alg ); + mgf_md_info = mbedtls_md_info_from_type( pss_opts->mgf1_hash_id ); + + ret = mbedtls_snprintf( p, n, " (%s, MGF1-%s, 0x%02X)", + md_info ? mbedtls_md_get_name( md_info ) : "???", + mgf_md_info ? mbedtls_md_get_name( mgf_md_info ) : "???", + pss_opts->expected_salt_len ); + MBEDTLS_X509_SAFE_SNPRINTF; + } +#else + ((void) pk_alg); + ((void) md_alg); + ((void) sig_opts); +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ + + return( (int)( size - n ) ); +} + +/* + * Helper for writing "RSA key size", "EC key size", etc + */ +int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name ) +{ + char *p = buf; + size_t n = buf_size; + int ret; + + ret = mbedtls_snprintf( p, n, "%s key size", name ); + MBEDTLS_X509_SAFE_SNPRINTF; + + return( 0 ); +} + +#if defined(MBEDTLS_HAVE_TIME_DATE) +/* + * Set the time structure to the current time. + * Return 0 on success, non-zero on failure. + */ +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) +static int x509_get_current_time( mbedtls_x509_time *now ) +{ + SYSTEMTIME st; + + GetSystemTime( &st ); + + now->year = st.wYear; + now->mon = st.wMonth; + now->day = st.wDay; + now->hour = st.wHour; + now->min = st.wMinute; + now->sec = st.wSecond; + + return( 0 ); +} +#else +static int x509_get_current_time( mbedtls_x509_time *now ) +{ + struct tm *lt; + mbedtls_time_t tt; + int ret = 0; + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_lock( &mbedtls_threading_gmtime_mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + tt = mbedtls_time( NULL ); + lt = gmtime( &tt ); + + if( lt == NULL ) + ret = -1; + else + { + now->year = lt->tm_year + 1900; + now->mon = lt->tm_mon + 1; + now->day = lt->tm_mday; + now->hour = lt->tm_hour; + now->min = lt->tm_min; + now->sec = lt->tm_sec; + } + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &mbedtls_threading_gmtime_mutex ) != 0 ) + return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); +#endif + + return( ret ); +} +#endif /* _WIN32 && !EFIX64 && !EFI32 */ + +/* + * Return 0 if before <= after, 1 otherwise + */ +static int x509_check_time( const mbedtls_x509_time *before, const mbedtls_x509_time *after ) +{ + if( before->year > after->year ) + return( 1 ); + + if( before->year == after->year && + before->mon > after->mon ) + return( 1 ); + + if( before->year == after->year && + before->mon == after->mon && + before->day > after->day ) + return( 1 ); + + if( before->year == after->year && + before->mon == after->mon && + before->day == after->day && + before->hour > after->hour ) + return( 1 ); + + if( before->year == after->year && + before->mon == after->mon && + before->day == after->day && + before->hour == after->hour && + before->min > after->min ) + return( 1 ); + + if( before->year == after->year && + before->mon == after->mon && + before->day == after->day && + before->hour == after->hour && + before->min == after->min && + before->sec > after->sec ) + return( 1 ); + + return( 0 ); +} + +int mbedtls_x509_time_is_past( const mbedtls_x509_time *to ) +{ + mbedtls_x509_time now; + + if( x509_get_current_time( &now ) != 0 ) + return( 1 ); + + return( x509_check_time( &now, to ) ); +} + +int mbedtls_x509_time_is_future( const mbedtls_x509_time *from ) +{ + mbedtls_x509_time now; + + if( x509_get_current_time( &now ) != 0 ) + return( 1 ); + + return( x509_check_time( from, &now ) ); +} + +#else /* MBEDTLS_HAVE_TIME_DATE */ + +int mbedtls_x509_time_is_past( const mbedtls_x509_time *to ) +{ + ((void) to); + return( 0 ); +} + +int mbedtls_x509_time_is_future( const mbedtls_x509_time *from ) +{ + ((void) from); + return( 0 ); +} +#endif /* MBEDTLS_HAVE_TIME_DATE */ + +#if defined(MBEDTLS_SELF_TEST) + +#include "mbedtls/x509_crt.h" +#include "mbedtls/certs.h" + +/* + * Checkup routine + */ +int mbedtls_x509_self_test( int verbose ) +{ +#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_SHA1_C) + int ret; + uint32_t flags; + mbedtls_x509_crt cacert; + mbedtls_x509_crt clicert; + + if( verbose != 0 ) + mbedtls_printf( " X.509 certificate load: " ); + + mbedtls_x509_crt_init( &clicert ); + + ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt, + mbedtls_test_cli_crt_len ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( ret ); + } + + mbedtls_x509_crt_init( &cacert ); + + ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_ca_crt, + mbedtls_test_ca_crt_len ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( ret ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n X.509 signature verify: "); + + ret = mbedtls_x509_crt_verify( &clicert, &cacert, NULL, NULL, &flags, NULL, NULL ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + return( ret ); + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n\n"); + + mbedtls_x509_crt_free( &cacert ); + mbedtls_x509_crt_free( &clicert ); + + return( 0 ); +#else + ((void) verbose); + return( 0 ); +#endif /* MBEDTLS_CERTS_C && MBEDTLS_SHA1_C */ +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_X509_USE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_create.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_create.c new file mode 100644 index 0000000..df20ec8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_create.c @@ -0,0 +1,340 @@ +/* + * X.509 base functions for creating certificates / CSRs + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_CREATE_C) + +#include "mbedtls/x509.h" +#include "mbedtls/asn1write.h" +#include "mbedtls/oid.h" + +#include + +typedef struct { + const char *name; + size_t name_len; + const char*oid; +} x509_attr_descriptor_t; + +#define ADD_STRLEN( s ) s, sizeof( s ) - 1 + +static const x509_attr_descriptor_t x509_attrs[] = +{ + { ADD_STRLEN( "CN" ), MBEDTLS_OID_AT_CN }, + { ADD_STRLEN( "commonName" ), MBEDTLS_OID_AT_CN }, + { ADD_STRLEN( "C" ), MBEDTLS_OID_AT_COUNTRY }, + { ADD_STRLEN( "countryName" ), MBEDTLS_OID_AT_COUNTRY }, + { ADD_STRLEN( "O" ), MBEDTLS_OID_AT_ORGANIZATION }, + { ADD_STRLEN( "organizationName" ), MBEDTLS_OID_AT_ORGANIZATION }, + { ADD_STRLEN( "L" ), MBEDTLS_OID_AT_LOCALITY }, + { ADD_STRLEN( "locality" ), MBEDTLS_OID_AT_LOCALITY }, + { ADD_STRLEN( "R" ), MBEDTLS_OID_PKCS9_EMAIL }, + { ADD_STRLEN( "OU" ), MBEDTLS_OID_AT_ORG_UNIT }, + { ADD_STRLEN( "organizationalUnitName" ), MBEDTLS_OID_AT_ORG_UNIT }, + { ADD_STRLEN( "ST" ), MBEDTLS_OID_AT_STATE }, + { ADD_STRLEN( "stateOrProvinceName" ), MBEDTLS_OID_AT_STATE }, + { ADD_STRLEN( "emailAddress" ), MBEDTLS_OID_PKCS9_EMAIL }, + { ADD_STRLEN( "serialNumber" ), MBEDTLS_OID_AT_SERIAL_NUMBER }, + { ADD_STRLEN( "postalAddress" ), MBEDTLS_OID_AT_POSTAL_ADDRESS }, + { ADD_STRLEN( "postalCode" ), MBEDTLS_OID_AT_POSTAL_CODE }, + { ADD_STRLEN( "dnQualifier" ), MBEDTLS_OID_AT_DN_QUALIFIER }, + { ADD_STRLEN( "title" ), MBEDTLS_OID_AT_TITLE }, + { ADD_STRLEN( "surName" ), MBEDTLS_OID_AT_SUR_NAME }, + { ADD_STRLEN( "SN" ), MBEDTLS_OID_AT_SUR_NAME }, + { ADD_STRLEN( "givenName" ), MBEDTLS_OID_AT_GIVEN_NAME }, + { ADD_STRLEN( "GN" ), MBEDTLS_OID_AT_GIVEN_NAME }, + { ADD_STRLEN( "initials" ), MBEDTLS_OID_AT_INITIALS }, + { ADD_STRLEN( "pseudonym" ), MBEDTLS_OID_AT_PSEUDONYM }, + { ADD_STRLEN( "generationQualifier" ), MBEDTLS_OID_AT_GENERATION_QUALIFIER }, + { ADD_STRLEN( "domainComponent" ), MBEDTLS_OID_DOMAIN_COMPONENT }, + { ADD_STRLEN( "DC" ), MBEDTLS_OID_DOMAIN_COMPONENT }, + { NULL, 0, NULL } +}; + +static const char *x509_at_oid_from_name( const char *name, size_t name_len ) +{ + const x509_attr_descriptor_t *cur; + + for( cur = x509_attrs; cur->name != NULL; cur++ ) + if( cur->name_len == name_len && + strncmp( cur->name, name, name_len ) == 0 ) + break; + + return( cur->oid ); +} + +int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name ) +{ + int ret = 0; + const char *s = name, *c = s; + const char *end = s + strlen( s ); + const char *oid = NULL; + int in_tag = 1; + char data[MBEDTLS_X509_MAX_DN_NAME_SIZE]; + char *d = data; + + /* Clear existing chain if present */ + mbedtls_asn1_free_named_data_list( head ); + + while( c <= end ) + { + if( in_tag && *c == '=' ) + { + if( ( oid = x509_at_oid_from_name( s, c - s ) ) == NULL ) + { + ret = MBEDTLS_ERR_X509_UNKNOWN_OID; + goto exit; + } + + s = c + 1; + in_tag = 0; + d = data; + } + + if( !in_tag && *c == '\\' && c != end ) + { + c++; + + /* Check for valid escaped characters */ + if( c == end || *c != ',' ) + { + ret = MBEDTLS_ERR_X509_INVALID_NAME; + goto exit; + } + } + else if( !in_tag && ( *c == ',' || c == end ) ) + { + if( mbedtls_asn1_store_named_data( head, oid, strlen( oid ), + (unsigned char *) data, + d - data ) == NULL ) + { + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + } + + while( c < end && *(c + 1) == ' ' ) + c++; + + s = c + 1; + in_tag = 1; + } + + if( !in_tag && s != c + 1 ) + { + *(d++) = *c; + + if( d - data == MBEDTLS_X509_MAX_DN_NAME_SIZE ) + { + ret = MBEDTLS_ERR_X509_INVALID_NAME; + goto exit; + } + } + + c++; + } + +exit: + + return( ret ); +} + +/* The first byte of the value in the mbedtls_asn1_named_data structure is reserved + * to store the critical boolean for us + */ +int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len, + int critical, const unsigned char *val, size_t val_len ) +{ + mbedtls_asn1_named_data *cur; + + if( ( cur = mbedtls_asn1_store_named_data( head, oid, oid_len, + NULL, val_len + 1 ) ) == NULL ) + { + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + } + + cur->val.p[0] = critical; + memcpy( cur->val.p + 1, val, val_len ); + + return( 0 ); +} + +/* + * RelativeDistinguishedName ::= + * SET OF AttributeTypeAndValue + * + * AttributeTypeAndValue ::= SEQUENCE { + * type AttributeType, + * value AttributeValue } + * + * AttributeType ::= OBJECT IDENTIFIER + * + * AttributeValue ::= ANY DEFINED BY AttributeType + */ +static int x509_write_name( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len, + const unsigned char *name, size_t name_len ) +{ + int ret; + size_t len = 0; + + // Write PrintableString for all except MBEDTLS_OID_PKCS9_EMAIL + // + if( MBEDTLS_OID_SIZE( MBEDTLS_OID_PKCS9_EMAIL ) == oid_len && + memcmp( oid, MBEDTLS_OID_PKCS9_EMAIL, oid_len ) == 0 ) + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_ia5_string( p, start, + (const char *) name, + name_len ) ); + } + else + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_printable_string( p, start, + (const char *) name, + name_len ) ); + } + + // Write OID + // + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( p, start, oid, oid_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SET ) ); + + return( (int) len ); +} + +int mbedtls_x509_write_names( unsigned char **p, unsigned char *start, + mbedtls_asn1_named_data *first ) +{ + int ret; + size_t len = 0; + mbedtls_asn1_named_data *cur = first; + + while( cur != NULL ) + { + MBEDTLS_ASN1_CHK_ADD( len, x509_write_name( p, start, (char *) cur->oid.p, + cur->oid.len, + cur->val.p, cur->val.len ) ); + cur = cur->next; + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len, + unsigned char *sig, size_t size ) +{ + int ret; + size_t len = 0; + + if( *p < start || (size_t)( *p - start ) < size ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len = size; + (*p) -= len; + memcpy( *p, sig, len ); + + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = 0; + len += 1; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_BIT_STRING ) ); + + // Write OID + // + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_algorithm_identifier( p, start, oid, + oid_len, 0 ) ); + + return( (int) len ); +} + +static int x509_write_extension( unsigned char **p, unsigned char *start, + mbedtls_asn1_named_data *ext ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, ext->val.p + 1, + ext->val.len - 1 ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, ext->val.len - 1 ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_OCTET_STRING ) ); + + if( ext->val.p[0] != 0 ) + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_bool( p, start, 1 ) ); + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, ext->oid.p, + ext->oid.len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, ext->oid.len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_OID ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +/* + * Extension ::= SEQUENCE { + * extnID OBJECT IDENTIFIER, + * critical BOOLEAN DEFAULT FALSE, + * extnValue OCTET STRING + * -- contains the DER encoding of an ASN.1 value + * -- corresponding to the extension type identified + * -- by extnID + * } + */ +int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start, + mbedtls_asn1_named_data *first ) +{ + int ret; + size_t len = 0; + mbedtls_asn1_named_data *cur_ext = first; + + while( cur_ext != NULL ) + { + MBEDTLS_ASN1_CHK_ADD( len, x509_write_extension( p, start, cur_ext ) ); + cur_ext = cur_ext->next; + } + + return( (int) len ); +} + +#endif /* MBEDTLS_X509_CREATE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crl.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crl.c new file mode 100644 index 0000000..76c49f1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crl.c @@ -0,0 +1,723 @@ +/* + * X.509 Certidicate Revocation List (CRL) parsing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The ITU-T X.509 standard defines a certificate format for PKI. + * + * http://www.ietf.org/rfc/rfc5280.txt (Certificates and CRLs) + * http://www.ietf.org/rfc/rfc3279.txt (Alg IDs for CRLs) + * http://www.ietf.org/rfc/rfc2986.txt (CSRs, aka PKCS#10) + * + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_CRL_PARSE_C) + +#include "mbedtls/x509_crl.h" +#include "mbedtls/oid.h" + +#include + +#if defined(MBEDTLS_PEM_PARSE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_free free +#define mbedtls_calloc calloc +#define mbedtls_snprintf snprintf +#endif + +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) +#include +#else +#include +#endif + +#if defined(MBEDTLS_FS_IO) || defined(EFIX64) || defined(EFI32) +#include +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Version ::= INTEGER { v1(0), v2(1) } + */ +static int x509_crl_get_version( unsigned char **p, + const unsigned char *end, + int *ver ) +{ + int ret; + + if( ( ret = mbedtls_asn1_get_int( p, end, ver ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + { + *ver = 0; + return( 0 ); + } + + return( MBEDTLS_ERR_X509_INVALID_VERSION + ret ); + } + + return( 0 ); +} + +/* + * X.509 CRL v2 extensions (no extensions parsed yet.) + */ +static int x509_get_crl_ext( unsigned char **p, + const unsigned char *end, + mbedtls_x509_buf *ext ) +{ + int ret; + size_t len = 0; + + /* Get explicit tag */ + if( ( ret = mbedtls_x509_get_ext( p, end, ext, 0) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( 0 ); + + return( ret ); + } + + while( *p < end ) + { + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + *p += len; + } + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * X.509 CRL v2 entry extensions (no extensions parsed yet.) + */ +static int x509_get_crl_entry_ext( unsigned char **p, + const unsigned char *end, + mbedtls_x509_buf *ext ) +{ + int ret; + size_t len = 0; + + /* OPTIONAL */ + if( end <= *p ) + return( 0 ); + + ext->tag = **p; + ext->p = *p; + + /* + * Get CRL-entry extension sequence header + * crlEntryExtensions Extensions OPTIONAL -- if present, MUST be v2 + */ + if( ( ret = mbedtls_asn1_get_tag( p, end, &ext->len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + { + ext->p = NULL; + return( 0 ); + } + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + } + + end = *p + ext->len; + + if( end != *p + ext->len ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + while( *p < end ) + { + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + *p += len; + } + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * X.509 CRL Entries + */ +static int x509_get_entries( unsigned char **p, + const unsigned char *end, + mbedtls_x509_crl_entry *entry ) +{ + int ret; + size_t entry_len; + mbedtls_x509_crl_entry *cur_entry = entry; + + if( *p == end ) + return( 0 ); + + if( ( ret = mbedtls_asn1_get_tag( p, end, &entry_len, + MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( 0 ); + + return( ret ); + } + + end = *p + entry_len; + + while( *p < end ) + { + size_t len2; + const unsigned char *end2; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len2, + MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED ) ) != 0 ) + { + return( ret ); + } + + cur_entry->raw.tag = **p; + cur_entry->raw.p = *p; + cur_entry->raw.len = len2; + end2 = *p + len2; + + if( ( ret = mbedtls_x509_get_serial( p, end2, &cur_entry->serial ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_x509_get_time( p, end2, + &cur_entry->revocation_date ) ) != 0 ) + return( ret ); + + if( ( ret = x509_get_crl_entry_ext( p, end2, + &cur_entry->entry_ext ) ) != 0 ) + return( ret ); + + if( *p < end ) + { + cur_entry->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl_entry ) ); + + if( cur_entry->next == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + cur_entry = cur_entry->next; + } + } + + return( 0 ); +} + +/* + * Parse one CRLs in DER format and append it to the chained list + */ +int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain, + const unsigned char *buf, size_t buflen ) +{ + int ret; + size_t len; + unsigned char *p, *end; + mbedtls_x509_buf sig_params1, sig_params2, sig_oid2; + mbedtls_x509_crl *crl = chain; + + /* + * Check for valid input + */ + if( crl == NULL || buf == NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + memset( &sig_params1, 0, sizeof( mbedtls_x509_buf ) ); + memset( &sig_params2, 0, sizeof( mbedtls_x509_buf ) ); + memset( &sig_oid2, 0, sizeof( mbedtls_x509_buf ) ); + + /* + * Add new CRL on the end of the chain if needed. + */ + while( crl->version != 0 && crl->next != NULL ) + crl = crl->next; + + if( crl->version != 0 && crl->next == NULL ) + { + crl->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl ) ); + + if( crl->next == NULL ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + } + + mbedtls_x509_crl_init( crl->next ); + crl = crl->next; + } + + /* + * Copy raw DER-encoded CRL + */ + if( ( p = mbedtls_calloc( 1, buflen ) ) == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + memcpy( p, buf, buflen ); + + crl->raw.p = p; + crl->raw.len = buflen; + + end = p + buflen; + + /* + * CertificateList ::= SEQUENCE { + * tbsCertList TBSCertList, + * signatureAlgorithm AlgorithmIdentifier, + * signatureValue BIT STRING } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT ); + } + + if( len != (size_t) ( end - p ) ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + /* + * TBSCertList ::= SEQUENCE { + */ + crl->tbs.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + end = p + len; + crl->tbs.len = end - crl->tbs.p; + + /* + * Version ::= INTEGER OPTIONAL { v1(0), v2(1) } + * -- if present, MUST be v2 + * + * signature AlgorithmIdentifier + */ + if( ( ret = x509_crl_get_version( &p, end, &crl->version ) ) != 0 || + ( ret = mbedtls_x509_get_alg( &p, end, &crl->sig_oid, &sig_params1 ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + + crl->version++; + + if( crl->version > 2 ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_UNKNOWN_VERSION ); + } + + if( ( ret = mbedtls_x509_get_sig_alg( &crl->sig_oid, &sig_params1, + &crl->sig_md, &crl->sig_pk, + &crl->sig_opts ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG ); + } + + /* + * issuer Name + */ + crl->issuer_raw.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + if( ( ret = mbedtls_x509_get_name( &p, p + len, &crl->issuer ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + + crl->issuer_raw.len = p - crl->issuer_raw.p; + + /* + * thisUpdate Time + * nextUpdate Time OPTIONAL + */ + if( ( ret = mbedtls_x509_get_time( &p, end, &crl->this_update ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + + if( ( ret = mbedtls_x509_get_time( &p, end, &crl->next_update ) ) != 0 ) + { + if( ret != ( MBEDTLS_ERR_X509_INVALID_DATE + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) && + ret != ( MBEDTLS_ERR_X509_INVALID_DATE + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ) ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + } + + /* + * revokedCertificates SEQUENCE OF SEQUENCE { + * userCertificate CertificateSerialNumber, + * revocationDate Time, + * crlEntryExtensions Extensions OPTIONAL + * -- if present, MUST be v2 + * } OPTIONAL + */ + if( ( ret = x509_get_entries( &p, end, &crl->entry ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + + /* + * crlExtensions EXPLICIT Extensions OPTIONAL + * -- if present, MUST be v2 + */ + if( crl->version == 2 ) + { + ret = x509_get_crl_ext( &p, end, &crl->crl_ext ); + + if( ret != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + } + + if( p != end ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + end = crl->raw.p + crl->raw.len; + + /* + * signatureAlgorithm AlgorithmIdentifier, + * signatureValue BIT STRING + */ + if( ( ret = mbedtls_x509_get_alg( &p, end, &sig_oid2, &sig_params2 ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + + if( crl->sig_oid.len != sig_oid2.len || + memcmp( crl->sig_oid.p, sig_oid2.p, crl->sig_oid.len ) != 0 || + sig_params1.len != sig_params2.len || + ( sig_params1.len != 0 && + memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 ) ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_SIG_MISMATCH ); + } + + if( ( ret = mbedtls_x509_get_sig( &p, end, &crl->sig ) ) != 0 ) + { + mbedtls_x509_crl_free( crl ); + return( ret ); + } + + if( p != end ) + { + mbedtls_x509_crl_free( crl ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + return( 0 ); +} + +/* + * Parse one or more CRLs and add them to the chained list + */ +int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen ) +{ +#if defined(MBEDTLS_PEM_PARSE_C) + int ret; + size_t use_len; + mbedtls_pem_context pem; + int is_pem = 0; + + if( chain == NULL || buf == NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + do + { + mbedtls_pem_init( &pem ); + + // Avoid calling mbedtls_pem_read_buffer() on non-null-terminated + // string + if( buflen == 0 || buf[buflen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN X509 CRL-----", + "-----END X509 CRL-----", + buf, NULL, 0, &use_len ); + + if( ret == 0 ) + { + /* + * Was PEM encoded + */ + is_pem = 1; + + buflen -= use_len; + buf += use_len; + + if( ( ret = mbedtls_x509_crl_parse_der( chain, + pem.buf, pem.buflen ) ) != 0 ) + { + mbedtls_pem_free( &pem ); + return( ret ); + } + } + else if( is_pem ) + { + mbedtls_pem_free( &pem ); + return( ret ); + } + + mbedtls_pem_free( &pem ); + } + /* In the PEM case, buflen is 1 at the end, for the terminated NULL byte. + * And a valid CRL cannot be less than 1 byte anyway. */ + while( is_pem && buflen > 1 ); + + if( is_pem ) + return( 0 ); + else +#endif /* MBEDTLS_PEM_PARSE_C */ + return( mbedtls_x509_crl_parse_der( chain, buf, buflen ) ); +} + +#if defined(MBEDTLS_FS_IO) +/* + * Load one or more CRLs and add them to the chained list + */ +int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path ) +{ + int ret; + size_t n; + unsigned char *buf; + + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) + return( ret ); + + ret = mbedtls_x509_crl_parse( chain, buf, n ); + + mbedtls_zeroize( buf, n ); + mbedtls_free( buf ); + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ + +/* + * Return an informational string about the certificate. + */ +#define BEFORE_COLON 14 +#define BC "14" +/* + * Return an informational string about the CRL. + */ +int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_crl *crl ) +{ + int ret; + size_t n; + char *p; + const mbedtls_x509_crl_entry *entry; + + p = buf; + n = size; + + ret = mbedtls_snprintf( p, n, "%sCRL version : %d", + prefix, crl->version ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%sissuer name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_x509_dn_gets( p, n, &crl->issuer ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%sthis update : " \ + "%04d-%02d-%02d %02d:%02d:%02d", prefix, + crl->this_update.year, crl->this_update.mon, + crl->this_update.day, crl->this_update.hour, + crl->this_update.min, crl->this_update.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%snext update : " \ + "%04d-%02d-%02d %02d:%02d:%02d", prefix, + crl->next_update.year, crl->next_update.mon, + crl->next_update.day, crl->next_update.hour, + crl->next_update.min, crl->next_update.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; + + entry = &crl->entry; + + ret = mbedtls_snprintf( p, n, "\n%sRevoked certificates:", + prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + while( entry != NULL && entry->raw.len != 0 ) + { + ret = mbedtls_snprintf( p, n, "\n%sserial number: ", + prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_x509_serial_gets( p, n, &entry->serial ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, " revocation date: " \ + "%04d-%02d-%02d %02d:%02d:%02d", + entry->revocation_date.year, entry->revocation_date.mon, + entry->revocation_date.day, entry->revocation_date.hour, + entry->revocation_date.min, entry->revocation_date.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; + + entry = entry->next; + } + + ret = mbedtls_snprintf( p, n, "\n%ssigned using : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_x509_sig_alg_gets( p, n, &crl->sig_oid, crl->sig_pk, crl->sig_md, + crl->sig_opts ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n" ); + MBEDTLS_X509_SAFE_SNPRINTF; + + return( (int) ( size - n ) ); +} + +/* + * Initialize a CRL chain + */ +void mbedtls_x509_crl_init( mbedtls_x509_crl *crl ) +{ + memset( crl, 0, sizeof(mbedtls_x509_crl) ); +} + +/* + * Unallocate all CRL data + */ +void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ) +{ + mbedtls_x509_crl *crl_cur = crl; + mbedtls_x509_crl *crl_prv; + mbedtls_x509_name *name_cur; + mbedtls_x509_name *name_prv; + mbedtls_x509_crl_entry *entry_cur; + mbedtls_x509_crl_entry *entry_prv; + + if( crl == NULL ) + return; + + do + { +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + mbedtls_free( crl_cur->sig_opts ); +#endif + + name_cur = crl_cur->issuer.next; + while( name_cur != NULL ) + { + name_prv = name_cur; + name_cur = name_cur->next; + mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_free( name_prv ); + } + + entry_cur = crl_cur->entry.next; + while( entry_cur != NULL ) + { + entry_prv = entry_cur; + entry_cur = entry_cur->next; + mbedtls_zeroize( entry_prv, sizeof( mbedtls_x509_crl_entry ) ); + mbedtls_free( entry_prv ); + } + + if( crl_cur->raw.p != NULL ) + { + mbedtls_zeroize( crl_cur->raw.p, crl_cur->raw.len ); + mbedtls_free( crl_cur->raw.p ); + } + + crl_cur = crl_cur->next; + } + while( crl_cur != NULL ); + + crl_cur = crl; + do + { + crl_prv = crl_cur; + crl_cur = crl_cur->next; + + mbedtls_zeroize( crl_prv, sizeof( mbedtls_x509_crl ) ); + if( crl_prv != crl ) + mbedtls_free( crl_prv ); + } + while( crl_cur != NULL ); +} + +#endif /* MBEDTLS_X509_CRL_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crt.c new file mode 100644 index 0000000..234f145 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_crt.c @@ -0,0 +1,2403 @@ +/* + * X.509 certificate parsing and verification + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The ITU-T X.509 standard defines a certificate format for PKI. + * + * http://www.ietf.org/rfc/rfc5280.txt (Certificates and CRLs) + * http://www.ietf.org/rfc/rfc3279.txt (Alg IDs for CRLs) + * http://www.ietf.org/rfc/rfc2986.txt (CSRs, aka PKCS#10) + * + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + +#include "mbedtls/x509_crt.h" +#include "mbedtls/oid.h" + +#include +#include + +#if defined(MBEDTLS_PEM_PARSE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_free free +#define mbedtls_calloc calloc +#define mbedtls_snprintf snprintf +#endif + +#if defined(MBEDTLS_THREADING_C) +#include "mbedtls/threading.h" +#endif + +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) +#include +#else +#include +#endif + +#if defined(MBEDTLS_FS_IO) +#include +#if !defined(_WIN32) || defined(EFIX64) || defined(EFI32) +#include +#include +#include +#endif /* !_WIN32 || EFIX64 || EFI32 */ +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Default profile + */ +const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default = +{ + /* Hashes from SHA-1 and above */ + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_RIPEMD160 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA512 ), + 0xFFFFFFF, /* Any PK alg */ + 0xFFFFFFF, /* Any curve */ + 2048, +}; + +/* + * Next-default profile + */ +const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next = +{ + /* Hashes from SHA-256 and above */ + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA512 ), + 0xFFFFFFF, /* Any PK alg */ +#if defined(MBEDTLS_ECP_C) + /* Curves at or above 128-bit security level */ + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP256R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP384R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP521R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_BP256R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_BP384R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_BP512R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP256K1 ), +#else + 0, +#endif + 2048, +}; + +/* + * NSA Suite B Profile + */ +const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb = +{ + /* Only SHA-256 and 384 */ + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ), + /* Only ECDSA */ + MBEDTLS_X509_ID_FLAG( MBEDTLS_PK_ECDSA ), +#if defined(MBEDTLS_ECP_C) + /* Only NIST P-256 and P-384 */ + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP256R1 ) | + MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP384R1 ), +#else + 0, +#endif + 0, +}; + +/* + * Check md_alg against profile + * Return 0 if md_alg acceptable for this profile, -1 otherwise + */ +static int x509_profile_check_md_alg( const mbedtls_x509_crt_profile *profile, + mbedtls_md_type_t md_alg ) +{ + if( ( profile->allowed_mds & MBEDTLS_X509_ID_FLAG( md_alg ) ) != 0 ) + return( 0 ); + + return( -1 ); +} + +/* + * Check pk_alg against profile + * Return 0 if pk_alg acceptable for this profile, -1 otherwise + */ +static int x509_profile_check_pk_alg( const mbedtls_x509_crt_profile *profile, + mbedtls_pk_type_t pk_alg ) +{ + if( ( profile->allowed_pks & MBEDTLS_X509_ID_FLAG( pk_alg ) ) != 0 ) + return( 0 ); + + return( -1 ); +} + +/* + * Check key against profile + * Return 0 if pk_alg acceptable for this profile, -1 otherwise + */ +static int x509_profile_check_key( const mbedtls_x509_crt_profile *profile, + mbedtls_pk_type_t pk_alg, + const mbedtls_pk_context *pk ) +{ +#if defined(MBEDTLS_RSA_C) + if( pk_alg == MBEDTLS_PK_RSA || pk_alg == MBEDTLS_PK_RSASSA_PSS ) + { + if( mbedtls_pk_get_bitlen( pk ) >= profile->rsa_min_bitlen ) + return( 0 ); + + return( -1 ); + } +#endif + +#if defined(MBEDTLS_ECP_C) + if( pk_alg == MBEDTLS_PK_ECDSA || + pk_alg == MBEDTLS_PK_ECKEY || + pk_alg == MBEDTLS_PK_ECKEY_DH ) + { + mbedtls_ecp_group_id gid = mbedtls_pk_ec( *pk )->grp.id; + + if( ( profile->allowed_curves & MBEDTLS_X509_ID_FLAG( gid ) ) != 0 ) + return( 0 ); + + return( -1 ); + } +#endif + + return( -1 ); +} + +/* + * Version ::= INTEGER { v1(0), v2(1), v3(2) } + */ +static int x509_get_version( unsigned char **p, + const unsigned char *end, + int *ver ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 0 ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + { + *ver = 0; + return( 0 ); + } + + return( ret ); + } + + end = *p + len; + + if( ( ret = mbedtls_asn1_get_int( p, end, ver ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_VERSION + ret ); + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_VERSION + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * Validity ::= SEQUENCE { + * notBefore Time, + * notAfter Time } + */ +static int x509_get_dates( unsigned char **p, + const unsigned char *end, + mbedtls_x509_time *from, + mbedtls_x509_time *to ) +{ + int ret; + size_t len; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_DATE + ret ); + + end = *p + len; + + if( ( ret = mbedtls_x509_get_time( p, end, from ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_x509_get_time( p, end, to ) ) != 0 ) + return( ret ); + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_DATE + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * X.509 v2/v3 unique identifier (not parsed) + */ +static int x509_get_uid( unsigned char **p, + const unsigned char *end, + mbedtls_x509_buf *uid, int n ) +{ + int ret; + + if( *p == end ) + return( 0 ); + + uid->tag = **p; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &uid->len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | n ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( 0 ); + + return( ret ); + } + + uid->p = *p; + *p += uid->len; + + return( 0 ); +} + +static int x509_get_basic_constraints( unsigned char **p, + const unsigned char *end, + int *ca_istrue, + int *max_pathlen ) +{ + int ret; + size_t len; + + /* + * BasicConstraints ::= SEQUENCE { + * cA BOOLEAN DEFAULT FALSE, + * pathLenConstraint INTEGER (0..MAX) OPTIONAL } + */ + *ca_istrue = 0; /* DEFAULT FALSE */ + *max_pathlen = 0; /* endless */ + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( *p == end ) + return( 0 ); + + if( ( ret = mbedtls_asn1_get_bool( p, end, ca_istrue ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + ret = mbedtls_asn1_get_int( p, end, ca_istrue ); + + if( ret != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( *ca_istrue != 0 ) + *ca_istrue = 1; + } + + if( *p == end ) + return( 0 ); + + if( ( ret = mbedtls_asn1_get_int( p, end, max_pathlen ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + (*max_pathlen)++; + + return( 0 ); +} + +static int x509_get_ns_cert_type( unsigned char **p, + const unsigned char *end, + unsigned char *ns_cert_type) +{ + int ret; + mbedtls_x509_bitstring bs = { 0, 0, NULL }; + + if( ( ret = mbedtls_asn1_get_bitstring( p, end, &bs ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( bs.len != 1 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + + /* Get actual bitstring */ + *ns_cert_type = *bs.p; + return( 0 ); +} + +static int x509_get_key_usage( unsigned char **p, + const unsigned char *end, + unsigned int *key_usage) +{ + int ret; + size_t i; + mbedtls_x509_bitstring bs = { 0, 0, NULL }; + + if( ( ret = mbedtls_asn1_get_bitstring( p, end, &bs ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( bs.len < 1 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + + /* Get actual bitstring */ + *key_usage = 0; + for( i = 0; i < bs.len && i < sizeof( unsigned int ); i++ ) + { + *key_usage |= (unsigned int) bs.p[i] << (8*i); + } + + return( 0 ); +} + +/* + * ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId + * + * KeyPurposeId ::= OBJECT IDENTIFIER + */ +static int x509_get_ext_key_usage( unsigned char **p, + const unsigned char *end, + mbedtls_x509_sequence *ext_key_usage) +{ + int ret; + + if( ( ret = mbedtls_asn1_get_sequence_of( p, end, ext_key_usage, MBEDTLS_ASN1_OID ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + /* Sequence length must be >= 1 */ + if( ext_key_usage->buf.p == NULL ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_INVALID_LENGTH ); + + return( 0 ); +} + +/* + * SubjectAltName ::= GeneralNames + * + * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName + * + * GeneralName ::= CHOICE { + * otherName [0] OtherName, + * rfc822Name [1] IA5String, + * dNSName [2] IA5String, + * x400Address [3] ORAddress, + * directoryName [4] Name, + * ediPartyName [5] EDIPartyName, + * uniformResourceIdentifier [6] IA5String, + * iPAddress [7] OCTET STRING, + * registeredID [8] OBJECT IDENTIFIER } + * + * OtherName ::= SEQUENCE { + * type-id OBJECT IDENTIFIER, + * value [0] EXPLICIT ANY DEFINED BY type-id } + * + * EDIPartyName ::= SEQUENCE { + * nameAssigner [0] DirectoryString OPTIONAL, + * partyName [1] DirectoryString } + * + * NOTE: we only parse and use dNSName at this point. + */ +static int x509_get_subject_alt_name( unsigned char **p, + const unsigned char *end, + mbedtls_x509_sequence *subject_alt_name ) +{ + int ret; + size_t len, tag_len; + mbedtls_asn1_buf *buf; + unsigned char tag; + mbedtls_asn1_sequence *cur = subject_alt_name; + + /* Get main sequence tag */ + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( *p + len != end ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + while( *p < end ) + { + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + tag = **p; + (*p)++; + if( ( ret = mbedtls_asn1_get_len( p, end, &tag_len ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + if( ( tag & MBEDTLS_ASN1_CONTEXT_SPECIFIC ) != MBEDTLS_ASN1_CONTEXT_SPECIFIC ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + + /* Skip everything but DNS name */ + if( tag != ( MBEDTLS_ASN1_CONTEXT_SPECIFIC | 2 ) ) + { + *p += tag_len; + continue; + } + + /* Allocate and assign next pointer */ + if( cur->buf.p != NULL ) + { + if( cur->next != NULL ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS ); + + cur->next = mbedtls_calloc( 1, sizeof( mbedtls_asn1_sequence ) ); + + if( cur->next == NULL ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_ALLOC_FAILED ); + + cur = cur->next; + } + + buf = &(cur->buf); + buf->tag = tag; + buf->p = *p; + buf->len = tag_len; + *p += buf->len; + } + + /* Set final sequence entry's next pointer to NULL */ + cur->next = NULL; + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * X.509 v3 extensions + * + */ +static int x509_get_crt_ext( unsigned char **p, + const unsigned char *end, + mbedtls_x509_crt *crt ) +{ + int ret; + size_t len; + unsigned char *end_ext_data, *end_ext_octet; + + if( ( ret = mbedtls_x509_get_ext( p, end, &crt->v3_ext, 3 ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + return( 0 ); + + return( ret ); + } + + while( *p < end ) + { + /* + * Extension ::= SEQUENCE { + * extnID OBJECT IDENTIFIER, + * critical BOOLEAN DEFAULT FALSE, + * extnValue OCTET STRING } + */ + mbedtls_x509_buf extn_oid = {0, 0, NULL}; + int is_critical = 0; /* DEFAULT FALSE */ + int ext_type = 0; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + end_ext_data = *p + len; + + /* Get extension ID */ + extn_oid.tag = **p; + + if( ( ret = mbedtls_asn1_get_tag( p, end, &extn_oid.len, MBEDTLS_ASN1_OID ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + extn_oid.p = *p; + *p += extn_oid.len; + + if( ( end - *p ) < 1 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); + + /* Get optional critical */ + if( ( ret = mbedtls_asn1_get_bool( p, end_ext_data, &is_critical ) ) != 0 && + ( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + /* Data should be octet string type */ + if( ( ret = mbedtls_asn1_get_tag( p, end_ext_data, &len, + MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); + + end_ext_octet = *p + len; + + if( end_ext_octet != end_ext_data ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + /* + * Detect supported extensions + */ + ret = mbedtls_oid_get_x509_ext_type( &extn_oid, &ext_type ); + + if( ret != 0 ) + { + /* No parser found, skip extension */ + *p = end_ext_octet; + +#if !defined(MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION) + if( is_critical ) + { + /* Data is marked as critical: fail */ + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); + } +#endif + continue; + } + + /* Forbid repeated extensions */ + if( ( crt->ext_types & ext_type ) != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS ); + + crt->ext_types |= ext_type; + + switch( ext_type ) + { + case MBEDTLS_X509_EXT_BASIC_CONSTRAINTS: + /* Parse basic constraints */ + if( ( ret = x509_get_basic_constraints( p, end_ext_octet, + &crt->ca_istrue, &crt->max_pathlen ) ) != 0 ) + return( ret ); + break; + + case MBEDTLS_X509_EXT_KEY_USAGE: + /* Parse key usage */ + if( ( ret = x509_get_key_usage( p, end_ext_octet, + &crt->key_usage ) ) != 0 ) + return( ret ); + break; + + case MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE: + /* Parse extended key usage */ + if( ( ret = x509_get_ext_key_usage( p, end_ext_octet, + &crt->ext_key_usage ) ) != 0 ) + return( ret ); + break; + + case MBEDTLS_X509_EXT_SUBJECT_ALT_NAME: + /* Parse subject alt name */ + if( ( ret = x509_get_subject_alt_name( p, end_ext_octet, + &crt->subject_alt_names ) ) != 0 ) + return( ret ); + break; + + case MBEDTLS_X509_EXT_NS_CERT_TYPE: + /* Parse netscape certificate type */ + if( ( ret = x509_get_ns_cert_type( p, end_ext_octet, + &crt->ns_cert_type ) ) != 0 ) + return( ret ); + break; + + default: + return( MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE ); + } + } + + if( *p != end ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + + return( 0 ); +} + +/* + * Parse and fill a single X.509 certificate in DER format + */ +static int x509_crt_parse_der_core( mbedtls_x509_crt *crt, const unsigned char *buf, + size_t buflen ) +{ + int ret; + size_t len; + unsigned char *p, *end, *crt_end; + mbedtls_x509_buf sig_params1, sig_params2, sig_oid2; + + memset( &sig_params1, 0, sizeof( mbedtls_x509_buf ) ); + memset( &sig_params2, 0, sizeof( mbedtls_x509_buf ) ); + memset( &sig_oid2, 0, sizeof( mbedtls_x509_buf ) ); + + /* + * Check for valid input + */ + if( crt == NULL || buf == NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + // Use the original buffer until we figure out actual length + p = (unsigned char*) buf; + len = buflen; + end = p + len; + + /* + * Certificate ::= SEQUENCE { + * tbsCertificate TBSCertificate, + * signatureAlgorithm AlgorithmIdentifier, + * signatureValue BIT STRING } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT ); + } + + if( len > (size_t) ( end - p ) ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + crt_end = p + len; + + // Create and populate a new buffer for the raw field + crt->raw.len = crt_end - buf; + crt->raw.p = p = mbedtls_calloc( 1, crt->raw.len ); + if( p == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + memcpy( p, buf, crt->raw.len ); + + // Direct pointers to the new buffer + p += crt->raw.len - len; + end = crt_end = p + len; + + /* + * TBSCertificate ::= SEQUENCE { + */ + crt->tbs.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + end = p + len; + crt->tbs.len = end - crt->tbs.p; + + /* + * Version ::= INTEGER { v1(0), v2(1), v3(2) } + * + * CertificateSerialNumber ::= INTEGER + * + * signature AlgorithmIdentifier + */ + if( ( ret = x509_get_version( &p, end, &crt->version ) ) != 0 || + ( ret = mbedtls_x509_get_serial( &p, end, &crt->serial ) ) != 0 || + ( ret = mbedtls_x509_get_alg( &p, end, &crt->sig_oid, + &sig_params1 ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + crt->version++; + + if( crt->version > 3 ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_UNKNOWN_VERSION ); + } + + if( ( ret = mbedtls_x509_get_sig_alg( &crt->sig_oid, &sig_params1, + &crt->sig_md, &crt->sig_pk, + &crt->sig_opts ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + /* + * issuer Name + */ + crt->issuer_raw.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + if( ( ret = mbedtls_x509_get_name( &p, p + len, &crt->issuer ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + crt->issuer_raw.len = p - crt->issuer_raw.p; + + /* + * Validity ::= SEQUENCE { + * notBefore Time, + * notAfter Time } + * + */ + if( ( ret = x509_get_dates( &p, end, &crt->valid_from, + &crt->valid_to ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + /* + * subject Name + */ + crt->subject_raw.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + if( len && ( ret = mbedtls_x509_get_name( &p, p + len, &crt->subject ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + crt->subject_raw.len = p - crt->subject_raw.p; + + /* + * SubjectPublicKeyInfo + */ + if( ( ret = mbedtls_pk_parse_subpubkey( &p, end, &crt->pk ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + /* + * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, + * -- If present, version shall be v2 or v3 + * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, + * -- If present, version shall be v2 or v3 + * extensions [3] EXPLICIT Extensions OPTIONAL + * -- If present, version shall be v3 + */ + if( crt->version == 2 || crt->version == 3 ) + { + ret = x509_get_uid( &p, end, &crt->issuer_id, 1 ); + if( ret != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + } + + if( crt->version == 2 || crt->version == 3 ) + { + ret = x509_get_uid( &p, end, &crt->subject_id, 2 ); + if( ret != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + } + +#if !defined(MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3) + if( crt->version == 3 ) +#endif + { + ret = x509_get_crt_ext( &p, end, crt ); + if( ret != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + } + + if( p != end ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + end = crt_end; + + /* + * } + * -- end of TBSCertificate + * + * signatureAlgorithm AlgorithmIdentifier, + * signatureValue BIT STRING + */ + if( ( ret = mbedtls_x509_get_alg( &p, end, &sig_oid2, &sig_params2 ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + if( crt->sig_oid.len != sig_oid2.len || + memcmp( crt->sig_oid.p, sig_oid2.p, crt->sig_oid.len ) != 0 || + sig_params1.len != sig_params2.len || + ( sig_params1.len != 0 && + memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 ) ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_SIG_MISMATCH ); + } + + if( ( ret = mbedtls_x509_get_sig( &p, end, &crt->sig ) ) != 0 ) + { + mbedtls_x509_crt_free( crt ); + return( ret ); + } + + if( p != end ) + { + mbedtls_x509_crt_free( crt ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + return( 0 ); +} + +/* + * Parse one X.509 certificate in DER format from a buffer and add them to a + * chained list + */ +int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain, const unsigned char *buf, + size_t buflen ) +{ + int ret; + mbedtls_x509_crt *crt = chain, *prev = NULL; + + /* + * Check for valid input + */ + if( crt == NULL || buf == NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + while( crt->version != 0 && crt->next != NULL ) + { + prev = crt; + crt = crt->next; + } + + /* + * Add new certificate on the end of the chain if needed. + */ + if( crt->version != 0 && crt->next == NULL ) + { + crt->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ); + + if( crt->next == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + prev = crt; + mbedtls_x509_crt_init( crt->next ); + crt = crt->next; + } + + if( ( ret = x509_crt_parse_der_core( crt, buf, buflen ) ) != 0 ) + { + if( prev ) + prev->next = NULL; + + if( crt != chain ) + mbedtls_free( crt ); + + return( ret ); + } + + return( 0 ); +} + +/* + * Parse one or more PEM certificates from a buffer and add them to the chained + * list + */ +int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen ) +{ +#if defined(MBEDTLS_PEM_PARSE_C) + int success = 0, first_error = 0, total_failed = 0; + int buf_format = MBEDTLS_X509_FORMAT_DER; +#endif + + /* + * Check for valid input + */ + if( chain == NULL || buf == NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + /* + * Determine buffer content. Buffer contains either one DER certificate or + * one or more PEM certificates. + */ +#if defined(MBEDTLS_PEM_PARSE_C) + if( buflen != 0 && buf[buflen - 1] == '\0' && + strstr( (const char *) buf, "-----BEGIN CERTIFICATE-----" ) != NULL ) + { + buf_format = MBEDTLS_X509_FORMAT_PEM; + } + + if( buf_format == MBEDTLS_X509_FORMAT_DER ) + return mbedtls_x509_crt_parse_der( chain, buf, buflen ); +#else + return mbedtls_x509_crt_parse_der( chain, buf, buflen ); +#endif + +#if defined(MBEDTLS_PEM_PARSE_C) + if( buf_format == MBEDTLS_X509_FORMAT_PEM ) + { + int ret; + mbedtls_pem_context pem; + + /* 1 rather than 0 since the terminating NULL byte is counted in */ + while( buflen > 1 ) + { + size_t use_len; + mbedtls_pem_init( &pem ); + + /* If we get there, we know the string is null-terminated */ + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN CERTIFICATE-----", + "-----END CERTIFICATE-----", + buf, NULL, 0, &use_len ); + + if( ret == 0 ) + { + /* + * Was PEM encoded + */ + buflen -= use_len; + buf += use_len; + } + else if( ret == MBEDTLS_ERR_PEM_BAD_INPUT_DATA ) + { + return( ret ); + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + { + mbedtls_pem_free( &pem ); + + /* + * PEM header and footer were found + */ + buflen -= use_len; + buf += use_len; + + if( first_error == 0 ) + first_error = ret; + + total_failed++; + continue; + } + else + break; + + ret = mbedtls_x509_crt_parse_der( chain, pem.buf, pem.buflen ); + + mbedtls_pem_free( &pem ); + + if( ret != 0 ) + { + /* + * Quit parsing on a memory error + */ + if( ret == MBEDTLS_ERR_X509_ALLOC_FAILED ) + return( ret ); + + if( first_error == 0 ) + first_error = ret; + + total_failed++; + continue; + } + + success = 1; + } + } + + if( success ) + return( total_failed ); + else if( first_error ) + return( first_error ); + else + return( MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT ); +#endif /* MBEDTLS_PEM_PARSE_C */ +} + +#if defined(MBEDTLS_FS_IO) +/* + * Load one or more certificates and add them to the chained list + */ +int mbedtls_x509_crt_parse_file( mbedtls_x509_crt *chain, const char *path ) +{ + int ret; + size_t n; + unsigned char *buf; + + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) + return( ret ); + + ret = mbedtls_x509_crt_parse( chain, buf, n ); + + mbedtls_zeroize( buf, n ); + mbedtls_free( buf ); + + return( ret ); +} + +int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path ) +{ + int ret = 0; +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) + int w_ret; + WCHAR szDir[MAX_PATH]; + char filename[MAX_PATH]; + char *p; + size_t len = strlen( path ); + + WIN32_FIND_DATAW file_data; + HANDLE hFind; + + if( len > MAX_PATH - 3 ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + memset( szDir, 0, sizeof(szDir) ); + memset( filename, 0, MAX_PATH ); + memcpy( filename, path, len ); + filename[len++] = '\\'; + p = filename + len; + filename[len++] = '*'; + + w_ret = MultiByteToWideChar( CP_ACP, 0, filename, (int)len, szDir, + MAX_PATH - 3 ); + if( w_ret == 0 ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + hFind = FindFirstFileW( szDir, &file_data ); + if( hFind == INVALID_HANDLE_VALUE ) + return( MBEDTLS_ERR_X509_FILE_IO_ERROR ); + + len = MAX_PATH - len; + do + { + memset( p, 0, len ); + + if( file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + continue; + + w_ret = WideCharToMultiByte( CP_ACP, 0, file_data.cFileName, + lstrlenW( file_data.cFileName ), + p, (int) len - 1, + NULL, NULL ); + if( w_ret == 0 ) + return( MBEDTLS_ERR_X509_FILE_IO_ERROR ); + + w_ret = mbedtls_x509_crt_parse_file( chain, filename ); + if( w_ret < 0 ) + ret++; + else + ret += w_ret; + } + while( FindNextFileW( hFind, &file_data ) != 0 ); + + if( GetLastError() != ERROR_NO_MORE_FILES ) + ret = MBEDTLS_ERR_X509_FILE_IO_ERROR; + + FindClose( hFind ); +#else /* _WIN32 */ + int t_ret; + int snp_ret; + struct stat sb; + struct dirent *entry; + char entry_name[MBEDTLS_X509_MAX_FILE_PATH_LEN]; + DIR *dir = opendir( path ); + + if( dir == NULL ) + return( MBEDTLS_ERR_X509_FILE_IO_ERROR ); + +#if defined(MBEDTLS_THREADING_PTHREAD) + if( ( ret = mbedtls_mutex_lock( &mbedtls_threading_readdir_mutex ) ) != 0 ) + { + closedir( dir ); + return( ret ); + } +#endif + + while( ( entry = readdir( dir ) ) != NULL ) + { + snp_ret = mbedtls_snprintf( entry_name, sizeof entry_name, + "%s/%s", path, entry->d_name ); + + if( snp_ret < 0 || (size_t)snp_ret >= sizeof entry_name ) + { + ret = MBEDTLS_ERR_X509_BUFFER_TOO_SMALL; + goto cleanup; + } + else if( stat( entry_name, &sb ) == -1 ) + { + ret = MBEDTLS_ERR_X509_FILE_IO_ERROR; + goto cleanup; + } + + if( !S_ISREG( sb.st_mode ) ) + continue; + + // Ignore parse errors + // + t_ret = mbedtls_x509_crt_parse_file( chain, entry_name ); + if( t_ret < 0 ) + ret++; + else + ret += t_ret; + } + +cleanup: + closedir( dir ); + +#if defined(MBEDTLS_THREADING_PTHREAD) + if( mbedtls_mutex_unlock( &mbedtls_threading_readdir_mutex ) != 0 ) + ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR; +#endif + +#endif /* _WIN32 */ + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ + +static int x509_info_subject_alt_name( char **buf, size_t *size, + const mbedtls_x509_sequence *subject_alt_name ) +{ + size_t i; + size_t n = *size; + char *p = *buf; + const mbedtls_x509_sequence *cur = subject_alt_name; + const char *sep = ""; + size_t sep_len = 0; + + while( cur != NULL ) + { + if( cur->buf.len + sep_len >= n ) + { + *p = '\0'; + return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL ); + } + + n -= cur->buf.len + sep_len; + for( i = 0; i < sep_len; i++ ) + *p++ = sep[i]; + for( i = 0; i < cur->buf.len; i++ ) + *p++ = cur->buf.p[i]; + + sep = ", "; + sep_len = 2; + + cur = cur->next; + } + + *p = '\0'; + + *size = n; + *buf = p; + + return( 0 ); +} + +#define PRINT_ITEM(i) \ + { \ + ret = mbedtls_snprintf( p, n, "%s" i, sep ); \ + MBEDTLS_X509_SAFE_SNPRINTF; \ + sep = ", "; \ + } + +#define CERT_TYPE(type,name) \ + if( ns_cert_type & type ) \ + PRINT_ITEM( name ); + +static int x509_info_cert_type( char **buf, size_t *size, + unsigned char ns_cert_type ) +{ + int ret; + size_t n = *size; + char *p = *buf; + const char *sep = ""; + + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT, "SSL Client" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER, "SSL Server" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_EMAIL, "Email" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING, "Object Signing" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_RESERVED, "Reserved" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_SSL_CA, "SSL CA" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA, "Email CA" ); + CERT_TYPE( MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA, "Object Signing CA" ); + + *size = n; + *buf = p; + + return( 0 ); +} + +#define KEY_USAGE(code,name) \ + if( key_usage & code ) \ + PRINT_ITEM( name ); + +static int x509_info_key_usage( char **buf, size_t *size, + unsigned int key_usage ) +{ + int ret; + size_t n = *size; + char *p = *buf; + const char *sep = ""; + + KEY_USAGE( MBEDTLS_X509_KU_DIGITAL_SIGNATURE, "Digital Signature" ); + KEY_USAGE( MBEDTLS_X509_KU_NON_REPUDIATION, "Non Repudiation" ); + KEY_USAGE( MBEDTLS_X509_KU_KEY_ENCIPHERMENT, "Key Encipherment" ); + KEY_USAGE( MBEDTLS_X509_KU_DATA_ENCIPHERMENT, "Data Encipherment" ); + KEY_USAGE( MBEDTLS_X509_KU_KEY_AGREEMENT, "Key Agreement" ); + KEY_USAGE( MBEDTLS_X509_KU_KEY_CERT_SIGN, "Key Cert Sign" ); + KEY_USAGE( MBEDTLS_X509_KU_CRL_SIGN, "CRL Sign" ); + KEY_USAGE( MBEDTLS_X509_KU_ENCIPHER_ONLY, "Encipher Only" ); + KEY_USAGE( MBEDTLS_X509_KU_DECIPHER_ONLY, "Decipher Only" ); + + *size = n; + *buf = p; + + return( 0 ); +} + +static int x509_info_ext_key_usage( char **buf, size_t *size, + const mbedtls_x509_sequence *extended_key_usage ) +{ + int ret; + const char *desc; + size_t n = *size; + char *p = *buf; + const mbedtls_x509_sequence *cur = extended_key_usage; + const char *sep = ""; + + while( cur != NULL ) + { + if( mbedtls_oid_get_extended_key_usage( &cur->buf, &desc ) != 0 ) + desc = "???"; + + ret = mbedtls_snprintf( p, n, "%s%s", sep, desc ); + MBEDTLS_X509_SAFE_SNPRINTF; + + sep = ", "; + + cur = cur->next; + } + + *size = n; + *buf = p; + + return( 0 ); +} + +/* + * Return an informational string about the certificate. + */ +#define BEFORE_COLON 18 +#define BC "18" +int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_crt *crt ) +{ + int ret; + size_t n; + char *p; + char key_size_str[BEFORE_COLON]; + + p = buf; + n = size; + + if( NULL == crt ) + { + ret = mbedtls_snprintf( p, n, "\nCertificate is uninitialised!\n" ); + MBEDTLS_X509_SAFE_SNPRINTF; + + return( (int) ( size - n ) ); + } + + ret = mbedtls_snprintf( p, n, "%scert. version : %d\n", + prefix, crt->version ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_snprintf( p, n, "%sserial number : ", + prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_x509_serial_gets( p, n, &crt->serial ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%sissuer name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_x509_dn_gets( p, n, &crt->issuer ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%ssubject name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_x509_dn_gets( p, n, &crt->subject ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%sissued on : " \ + "%04d-%02d-%02d %02d:%02d:%02d", prefix, + crt->valid_from.year, crt->valid_from.mon, + crt->valid_from.day, crt->valid_from.hour, + crt->valid_from.min, crt->valid_from.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%sexpires on : " \ + "%04d-%02d-%02d %02d:%02d:%02d", prefix, + crt->valid_to.year, crt->valid_to.mon, + crt->valid_to.day, crt->valid_to.hour, + crt->valid_to.min, crt->valid_to.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%ssigned using : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_x509_sig_alg_gets( p, n, &crt->sig_oid, crt->sig_pk, + crt->sig_md, crt->sig_opts ); + MBEDTLS_X509_SAFE_SNPRINTF; + + /* Key size */ + if( ( ret = mbedtls_x509_key_size_helper( key_size_str, BEFORE_COLON, + mbedtls_pk_get_name( &crt->pk ) ) ) != 0 ) + { + return( ret ); + } + + ret = mbedtls_snprintf( p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str, + (int) mbedtls_pk_get_bitlen( &crt->pk ) ); + MBEDTLS_X509_SAFE_SNPRINTF; + + /* + * Optional extensions + */ + + if( crt->ext_types & MBEDTLS_X509_EXT_BASIC_CONSTRAINTS ) + { + ret = mbedtls_snprintf( p, n, "\n%sbasic constraints : CA=%s", prefix, + crt->ca_istrue ? "true" : "false" ); + MBEDTLS_X509_SAFE_SNPRINTF; + + if( crt->max_pathlen > 0 ) + { + ret = mbedtls_snprintf( p, n, ", max_pathlen=%d", crt->max_pathlen - 1 ); + MBEDTLS_X509_SAFE_SNPRINTF; + } + } + + if( crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME ) + { + ret = mbedtls_snprintf( p, n, "\n%ssubject alt name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + if( ( ret = x509_info_subject_alt_name( &p, &n, + &crt->subject_alt_names ) ) != 0 ) + return( ret ); + } + + if( crt->ext_types & MBEDTLS_X509_EXT_NS_CERT_TYPE ) + { + ret = mbedtls_snprintf( p, n, "\n%scert. type : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + if( ( ret = x509_info_cert_type( &p, &n, crt->ns_cert_type ) ) != 0 ) + return( ret ); + } + + if( crt->ext_types & MBEDTLS_X509_EXT_KEY_USAGE ) + { + ret = mbedtls_snprintf( p, n, "\n%skey usage : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + if( ( ret = x509_info_key_usage( &p, &n, crt->key_usage ) ) != 0 ) + return( ret ); + } + + if( crt->ext_types & MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE ) + { + ret = mbedtls_snprintf( p, n, "\n%sext key usage : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + if( ( ret = x509_info_ext_key_usage( &p, &n, + &crt->ext_key_usage ) ) != 0 ) + return( ret ); + } + + ret = mbedtls_snprintf( p, n, "\n" ); + MBEDTLS_X509_SAFE_SNPRINTF; + + return( (int) ( size - n ) ); +} + +struct x509_crt_verify_string { + int code; + const char *string; +}; + +static const struct x509_crt_verify_string x509_crt_verify_strings[] = { + { MBEDTLS_X509_BADCERT_EXPIRED, "The certificate validity has expired" }, + { MBEDTLS_X509_BADCERT_REVOKED, "The certificate has been revoked (is on a CRL)" }, + { MBEDTLS_X509_BADCERT_CN_MISMATCH, "The certificate Common Name (CN) does not match with the expected CN" }, + { MBEDTLS_X509_BADCERT_NOT_TRUSTED, "The certificate is not correctly signed by the trusted CA" }, + { MBEDTLS_X509_BADCRL_NOT_TRUSTED, "The CRL is not correctly signed by the trusted CA" }, + { MBEDTLS_X509_BADCRL_EXPIRED, "The CRL is expired" }, + { MBEDTLS_X509_BADCERT_MISSING, "Certificate was missing" }, + { MBEDTLS_X509_BADCERT_SKIP_VERIFY, "Certificate verification was skipped" }, + { MBEDTLS_X509_BADCERT_OTHER, "Other reason (can be used by verify callback)" }, + { MBEDTLS_X509_BADCERT_FUTURE, "The certificate validity starts in the future" }, + { MBEDTLS_X509_BADCRL_FUTURE, "The CRL is from the future" }, + { MBEDTLS_X509_BADCERT_KEY_USAGE, "Usage does not match the keyUsage extension" }, + { MBEDTLS_X509_BADCERT_EXT_KEY_USAGE, "Usage does not match the extendedKeyUsage extension" }, + { MBEDTLS_X509_BADCERT_NS_CERT_TYPE, "Usage does not match the nsCertType extension" }, + { MBEDTLS_X509_BADCERT_BAD_MD, "The certificate is signed with an unacceptable hash." }, + { MBEDTLS_X509_BADCERT_BAD_PK, "The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA)." }, + { MBEDTLS_X509_BADCERT_BAD_KEY, "The certificate is signed with an unacceptable key (eg bad curve, RSA too short)." }, + { MBEDTLS_X509_BADCRL_BAD_MD, "The CRL is signed with an unacceptable hash." }, + { MBEDTLS_X509_BADCRL_BAD_PK, "The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA)." }, + { MBEDTLS_X509_BADCRL_BAD_KEY, "The CRL is signed with an unacceptable key (eg bad curve, RSA too short)." }, + { 0, NULL } +}; + +int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix, + uint32_t flags ) +{ + int ret; + const struct x509_crt_verify_string *cur; + char *p = buf; + size_t n = size; + + for( cur = x509_crt_verify_strings; cur->string != NULL ; cur++ ) + { + if( ( flags & cur->code ) == 0 ) + continue; + + ret = mbedtls_snprintf( p, n, "%s%s\n", prefix, cur->string ); + MBEDTLS_X509_SAFE_SNPRINTF; + flags ^= cur->code; + } + + if( flags != 0 ) + { + ret = mbedtls_snprintf( p, n, "%sUnknown reason " + "(this should not happen)\n", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + } + + return( (int) ( size - n ) ); +} + +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) +int mbedtls_x509_crt_check_key_usage( const mbedtls_x509_crt *crt, + unsigned int usage ) +{ + unsigned int usage_must, usage_may; + unsigned int may_mask = MBEDTLS_X509_KU_ENCIPHER_ONLY + | MBEDTLS_X509_KU_DECIPHER_ONLY; + + if( ( crt->ext_types & MBEDTLS_X509_EXT_KEY_USAGE ) == 0 ) + return( 0 ); + + usage_must = usage & ~may_mask; + + if( ( ( crt->key_usage & ~may_mask ) & usage_must ) != usage_must ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + usage_may = usage & may_mask; + + if( ( ( crt->key_usage & may_mask ) | usage_may ) != usage_may ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + return( 0 ); +} +#endif + +#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) +int mbedtls_x509_crt_check_extended_key_usage( const mbedtls_x509_crt *crt, + const char *usage_oid, + size_t usage_len ) +{ + const mbedtls_x509_sequence *cur; + + /* Extension is not mandatory, absent means no restriction */ + if( ( crt->ext_types & MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE ) == 0 ) + return( 0 ); + + /* + * Look for the requested usage (or wildcard ANY) in our list + */ + for( cur = &crt->ext_key_usage; cur != NULL; cur = cur->next ) + { + const mbedtls_x509_buf *cur_oid = &cur->buf; + + if( cur_oid->len == usage_len && + memcmp( cur_oid->p, usage_oid, usage_len ) == 0 ) + { + return( 0 ); + } + + if( MBEDTLS_OID_CMP( MBEDTLS_OID_ANY_EXTENDED_KEY_USAGE, cur_oid ) == 0 ) + return( 0 ); + } + + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); +} +#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */ + +#if defined(MBEDTLS_X509_CRL_PARSE_C) +/* + * Return 1 if the certificate is revoked, or 0 otherwise. + */ +int mbedtls_x509_crt_is_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl ) +{ + const mbedtls_x509_crl_entry *cur = &crl->entry; + + while( cur != NULL && cur->serial.len != 0 ) + { + if( crt->serial.len == cur->serial.len && + memcmp( crt->serial.p, cur->serial.p, crt->serial.len ) == 0 ) + { + if( mbedtls_x509_time_is_past( &cur->revocation_date ) ) + return( 1 ); + } + + cur = cur->next; + } + + return( 0 ); +} + +/* + * Check that the given certificate is not revoked according to the CRL. + * Skip validation is no CRL for the given CA is present. + */ +static int x509_crt_verifycrl( mbedtls_x509_crt *crt, mbedtls_x509_crt *ca, + mbedtls_x509_crl *crl_list, + const mbedtls_x509_crt_profile *profile ) +{ + int flags = 0; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + const mbedtls_md_info_t *md_info; + + if( ca == NULL ) + return( flags ); + + while( crl_list != NULL ) + { + if( crl_list->version == 0 || + crl_list->issuer_raw.len != ca->subject_raw.len || + memcmp( crl_list->issuer_raw.p, ca->subject_raw.p, + crl_list->issuer_raw.len ) != 0 ) + { + crl_list = crl_list->next; + continue; + } + + /* + * Check if the CA is configured to sign CRLs + */ +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) + if( mbedtls_x509_crt_check_key_usage( ca, MBEDTLS_X509_KU_CRL_SIGN ) != 0 ) + { + flags |= MBEDTLS_X509_BADCRL_NOT_TRUSTED; + break; + } +#endif + + /* + * Check if CRL is correctly signed by the trusted CA + */ + if( x509_profile_check_md_alg( profile, crl_list->sig_md ) != 0 ) + flags |= MBEDTLS_X509_BADCRL_BAD_MD; + + if( x509_profile_check_pk_alg( profile, crl_list->sig_pk ) != 0 ) + flags |= MBEDTLS_X509_BADCRL_BAD_PK; + + md_info = mbedtls_md_info_from_type( crl_list->sig_md ); + if( md_info == NULL ) + { + /* + * Cannot check 'unknown' hash + */ + flags |= MBEDTLS_X509_BADCRL_NOT_TRUSTED; + break; + } + + mbedtls_md( md_info, crl_list->tbs.p, crl_list->tbs.len, hash ); + + if( x509_profile_check_key( profile, crl_list->sig_pk, &ca->pk ) != 0 ) + flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + + if( mbedtls_pk_verify_ext( crl_list->sig_pk, crl_list->sig_opts, &ca->pk, + crl_list->sig_md, hash, mbedtls_md_get_size( md_info ), + crl_list->sig.p, crl_list->sig.len ) != 0 ) + { + flags |= MBEDTLS_X509_BADCRL_NOT_TRUSTED; + break; + } + + /* + * Check for validity of CRL (Do not drop out) + */ + if( mbedtls_x509_time_is_past( &crl_list->next_update ) ) + flags |= MBEDTLS_X509_BADCRL_EXPIRED; + + if( mbedtls_x509_time_is_future( &crl_list->this_update ) ) + flags |= MBEDTLS_X509_BADCRL_FUTURE; + + /* + * Check if certificate is revoked + */ + if( mbedtls_x509_crt_is_revoked( crt, crl_list ) ) + { + flags |= MBEDTLS_X509_BADCERT_REVOKED; + break; + } + + crl_list = crl_list->next; + } + + return( flags ); +} +#endif /* MBEDTLS_X509_CRL_PARSE_C */ + +/* + * Like memcmp, but case-insensitive and always returns -1 if different + */ +static int x509_memcasecmp( const void *s1, const void *s2, size_t len ) +{ + size_t i; + unsigned char diff; + const unsigned char *n1 = s1, *n2 = s2; + + for( i = 0; i < len; i++ ) + { + diff = n1[i] ^ n2[i]; + + if( diff == 0 ) + continue; + + if( diff == 32 && + ( ( n1[i] >= 'a' && n1[i] <= 'z' ) || + ( n1[i] >= 'A' && n1[i] <= 'Z' ) ) ) + { + continue; + } + + return( -1 ); + } + + return( 0 ); +} + +/* + * Return 0 if name matches wildcard, -1 otherwise + */ +static int x509_check_wildcard( const char *cn, mbedtls_x509_buf *name ) +{ + size_t i; + size_t cn_idx = 0, cn_len = strlen( cn ); + + if( name->len < 3 || name->p[0] != '*' || name->p[1] != '.' ) + return( 0 ); + + for( i = 0; i < cn_len; ++i ) + { + if( cn[i] == '.' ) + { + cn_idx = i; + break; + } + } + + if( cn_idx == 0 ) + return( -1 ); + + if( cn_len - cn_idx == name->len - 1 && + x509_memcasecmp( name->p + 1, cn + cn_idx, name->len - 1 ) == 0 ) + { + return( 0 ); + } + + return( -1 ); +} + +/* + * Compare two X.509 strings, case-insensitive, and allowing for some encoding + * variations (but not all). + * + * Return 0 if equal, -1 otherwise. + */ +static int x509_string_cmp( const mbedtls_x509_buf *a, const mbedtls_x509_buf *b ) +{ + if( a->tag == b->tag && + a->len == b->len && + memcmp( a->p, b->p, b->len ) == 0 ) + { + return( 0 ); + } + + if( ( a->tag == MBEDTLS_ASN1_UTF8_STRING || a->tag == MBEDTLS_ASN1_PRINTABLE_STRING ) && + ( b->tag == MBEDTLS_ASN1_UTF8_STRING || b->tag == MBEDTLS_ASN1_PRINTABLE_STRING ) && + a->len == b->len && + x509_memcasecmp( a->p, b->p, b->len ) == 0 ) + { + return( 0 ); + } + + return( -1 ); +} + +/* + * Compare two X.509 Names (aka rdnSequence). + * + * See RFC 5280 section 7.1, though we don't implement the whole algorithm: + * we sometimes return unequal when the full algorithm would return equal, + * but never the other way. (In particular, we don't do Unicode normalisation + * or space folding.) + * + * Return 0 if equal, -1 otherwise. + */ +static int x509_name_cmp( const mbedtls_x509_name *a, const mbedtls_x509_name *b ) +{ + /* Avoid recursion, it might not be optimised by the compiler */ + while( a != NULL || b != NULL ) + { + if( a == NULL || b == NULL ) + return( -1 ); + + /* type */ + if( a->oid.tag != b->oid.tag || + a->oid.len != b->oid.len || + memcmp( a->oid.p, b->oid.p, b->oid.len ) != 0 ) + { + return( -1 ); + } + + /* value */ + if( x509_string_cmp( &a->val, &b->val ) != 0 ) + return( -1 ); + + /* structure of the list of sets */ + if( a->next_merged != b->next_merged ) + return( -1 ); + + a = a->next; + b = b->next; + } + + /* a == NULL == b */ + return( 0 ); +} + +/* + * Check if 'parent' is a suitable parent (signing CA) for 'child'. + * Return 0 if yes, -1 if not. + * + * top means parent is a locally-trusted certificate + * bottom means child is the end entity cert + */ +static int x509_crt_check_parent( const mbedtls_x509_crt *child, + const mbedtls_x509_crt *parent, + int top, int bottom ) +{ + int need_ca_bit; + + /* Parent must be the issuer */ + if( x509_name_cmp( &child->issuer, &parent->subject ) != 0 ) + return( -1 ); + + /* Parent must have the basicConstraints CA bit set as a general rule */ + need_ca_bit = 1; + + /* Exception: v1/v2 certificates that are locally trusted. */ + if( top && parent->version < 3 ) + need_ca_bit = 0; + + /* Exception: self-signed end-entity certs that are locally trusted. */ + if( top && bottom && + child->raw.len == parent->raw.len && + memcmp( child->raw.p, parent->raw.p, child->raw.len ) == 0 ) + { + need_ca_bit = 0; + } + + if( need_ca_bit && ! parent->ca_istrue ) + return( -1 ); + +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) + if( need_ca_bit && + mbedtls_x509_crt_check_key_usage( parent, MBEDTLS_X509_KU_KEY_CERT_SIGN ) != 0 ) + { + return( -1 ); + } +#endif + + return( 0 ); +} + +static int x509_crt_verify_top( + mbedtls_x509_crt *child, mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + int path_cnt, int self_cnt, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + int ret; + uint32_t ca_flags = 0; + int check_path_cnt; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + const mbedtls_md_info_t *md_info; + mbedtls_x509_crt *future_past_ca = NULL; + + if( mbedtls_x509_time_is_past( &child->valid_to ) ) + *flags |= MBEDTLS_X509_BADCERT_EXPIRED; + + if( mbedtls_x509_time_is_future( &child->valid_from ) ) + *flags |= MBEDTLS_X509_BADCERT_FUTURE; + + if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_MD; + + if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_PK; + + /* + * Child is the top of the chain. Check against the trust_ca list. + */ + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + + md_info = mbedtls_md_info_from_type( child->sig_md ); + if( md_info == NULL ) + { + /* + * Cannot check 'unknown', no need to try any CA + */ + trust_ca = NULL; + } + else + mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ); + + for( /* trust_ca */ ; trust_ca != NULL; trust_ca = trust_ca->next ) + { + if( x509_crt_check_parent( child, trust_ca, 1, path_cnt == 0 ) != 0 ) + continue; + + check_path_cnt = path_cnt + 1; + + /* + * Reduce check_path_cnt to check against if top of the chain is + * the same as the trusted CA + */ + if( child->subject_raw.len == trust_ca->subject_raw.len && + memcmp( child->subject_raw.p, trust_ca->subject_raw.p, + child->issuer_raw.len ) == 0 ) + { + check_path_cnt--; + } + + /* Self signed certificates do not count towards the limit */ + if( trust_ca->max_pathlen > 0 && + trust_ca->max_pathlen < check_path_cnt - self_cnt ) + { + continue; + } + + if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &trust_ca->pk, + child->sig_md, hash, mbedtls_md_get_size( md_info ), + child->sig.p, child->sig.len ) != 0 ) + { + continue; + } + + if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) || + mbedtls_x509_time_is_future( &trust_ca->valid_from ) ) + { + if ( future_past_ca == NULL ) + future_past_ca = trust_ca; + + continue; + } + + break; + } + + if( trust_ca != NULL || ( trust_ca = future_past_ca ) != NULL ) + { + /* + * Top of chain is signed by a trusted CA + */ + *flags &= ~MBEDTLS_X509_BADCERT_NOT_TRUSTED; + + if( x509_profile_check_key( profile, child->sig_pk, &trust_ca->pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + } + + /* + * If top of chain is not the same as the trusted CA send a verify request + * to the callback for any issues with validity and CRL presence for the + * trusted CA certificate. + */ + if( trust_ca != NULL && + ( child->subject_raw.len != trust_ca->subject_raw.len || + memcmp( child->subject_raw.p, trust_ca->subject_raw.p, + child->issuer_raw.len ) != 0 ) ) + { +#if defined(MBEDTLS_X509_CRL_PARSE_C) + /* Check trusted CA's CRL for the chain's top crt */ + *flags |= x509_crt_verifycrl( child, trust_ca, ca_crl, profile ); +#else + ((void) ca_crl); +#endif + + if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) ) + ca_flags |= MBEDTLS_X509_BADCERT_EXPIRED; + + if( mbedtls_x509_time_is_future( &trust_ca->valid_from ) ) + ca_flags |= MBEDTLS_X509_BADCERT_FUTURE; + + if( NULL != f_vrfy ) + { + if( ( ret = f_vrfy( p_vrfy, trust_ca, path_cnt + 1, + &ca_flags ) ) != 0 ) + { + return( ret ); + } + } + } + + /* Call callback on top cert */ + if( NULL != f_vrfy ) + { + if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 ) + return( ret ); + } + + *flags |= ca_flags; + + return( 0 ); +} + +static int x509_crt_verify_child( + mbedtls_x509_crt *child, mbedtls_x509_crt *parent, + mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + int path_cnt, int self_cnt, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + int ret; + uint32_t parent_flags = 0; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + mbedtls_x509_crt *grandparent; + const mbedtls_md_info_t *md_info; + + /* Counting intermediate self signed certificates */ + if( ( path_cnt != 0 ) && x509_name_cmp( &child->issuer, &child->subject ) == 0 ) + self_cnt++; + + /* path_cnt is 0 for the first intermediate CA */ + if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA ) + { + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ); + } + + if( mbedtls_x509_time_is_past( &child->valid_to ) ) + *flags |= MBEDTLS_X509_BADCERT_EXPIRED; + + if( mbedtls_x509_time_is_future( &child->valid_from ) ) + *flags |= MBEDTLS_X509_BADCERT_FUTURE; + + if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_MD; + + if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_PK; + + md_info = mbedtls_md_info_from_type( child->sig_md ); + if( md_info == NULL ) + { + /* + * Cannot check 'unknown' hash + */ + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + else + { + mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ); + + if( x509_profile_check_key( profile, child->sig_pk, &parent->pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + + if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &parent->pk, + child->sig_md, hash, mbedtls_md_get_size( md_info ), + child->sig.p, child->sig.len ) != 0 ) + { + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + } + +#if defined(MBEDTLS_X509_CRL_PARSE_C) + /* Check trusted CA's CRL for the given crt */ + *flags |= x509_crt_verifycrl(child, parent, ca_crl, profile ); +#endif + + /* Look for a grandparent in trusted CAs */ + for( grandparent = trust_ca; + grandparent != NULL; + grandparent = grandparent->next ) + { + if( x509_crt_check_parent( parent, grandparent, + 0, path_cnt == 0 ) == 0 ) + break; + } + + if( grandparent != NULL ) + { + ret = x509_crt_verify_top( parent, grandparent, ca_crl, profile, + path_cnt + 1, self_cnt, &parent_flags, f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + /* Look for a grandparent upwards the chain */ + for( grandparent = parent->next; + grandparent != NULL; + grandparent = grandparent->next ) + { + /* +2 because the current step is not yet accounted for + * and because max_pathlen is one higher than it should be. + * Also self signed certificates do not count to the limit. */ + if( grandparent->max_pathlen > 0 && + grandparent->max_pathlen < 2 + path_cnt - self_cnt ) + { + continue; + } + + if( x509_crt_check_parent( parent, grandparent, + 0, path_cnt == 0 ) == 0 ) + break; + } + + /* Is our parent part of the chain or at the top? */ + if( grandparent != NULL ) + { + ret = x509_crt_verify_child( parent, grandparent, trust_ca, ca_crl, + profile, path_cnt + 1, self_cnt, &parent_flags, + f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + ret = x509_crt_verify_top( parent, trust_ca, ca_crl, profile, + path_cnt + 1, self_cnt, &parent_flags, + f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + } + + /* child is verified to be a child of the parent, call verify callback */ + if( NULL != f_vrfy ) + if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 ) + return( ret ); + + *flags |= parent_flags; + + return( 0 ); +} + +/* + * Verify the certificate validity + */ +int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const char *cn, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + return( mbedtls_x509_crt_verify_with_profile( crt, trust_ca, ca_crl, + &mbedtls_x509_crt_profile_default, cn, flags, f_vrfy, p_vrfy ) ); +} + + +/* + * Verify the certificate validity, with profile + */ +int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + const char *cn, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + size_t cn_len; + int ret; + int pathlen = 0, selfsigned = 0; + mbedtls_x509_crt *parent; + mbedtls_x509_name *name; + mbedtls_x509_sequence *cur = NULL; + mbedtls_pk_type_t pk_type; + + if( profile == NULL ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + *flags = 0; + + if( cn != NULL ) + { + name = &crt->subject; + cn_len = strlen( cn ); + + if( crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME ) + { + cur = &crt->subject_alt_names; + + while( cur != NULL ) + { + if( cur->buf.len == cn_len && + x509_memcasecmp( cn, cur->buf.p, cn_len ) == 0 ) + break; + + if( cur->buf.len > 2 && + memcmp( cur->buf.p, "*.", 2 ) == 0 && + x509_check_wildcard( cn, &cur->buf ) == 0 ) + { + break; + } + + cur = cur->next; + } + + if( cur == NULL ) + *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; + } + else + { + while( name != NULL ) + { + if( MBEDTLS_OID_CMP( MBEDTLS_OID_AT_CN, &name->oid ) == 0 ) + { + if( name->val.len == cn_len && + x509_memcasecmp( name->val.p, cn, cn_len ) == 0 ) + break; + + if( name->val.len > 2 && + memcmp( name->val.p, "*.", 2 ) == 0 && + x509_check_wildcard( cn, &name->val ) == 0 ) + break; + } + + name = name->next; + } + + if( name == NULL ) + *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; + } + } + + /* Check the type and size of the key */ + pk_type = mbedtls_pk_get_type( &crt->pk ); + + if( x509_profile_check_pk_alg( profile, pk_type ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_PK; + + if( x509_profile_check_key( profile, pk_type, &crt->pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + + /* Look for a parent in trusted CAs */ + for( parent = trust_ca; parent != NULL; parent = parent->next ) + { + if( x509_crt_check_parent( crt, parent, 0, pathlen == 0 ) == 0 ) + break; + } + + if( parent != NULL ) + { + ret = x509_crt_verify_top( crt, parent, ca_crl, profile, + pathlen, selfsigned, flags, f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + /* Look for a parent upwards the chain */ + for( parent = crt->next; parent != NULL; parent = parent->next ) + if( x509_crt_check_parent( crt, parent, 0, pathlen == 0 ) == 0 ) + break; + + /* Are we part of the chain or at the top? */ + if( parent != NULL ) + { + ret = x509_crt_verify_child( crt, parent, trust_ca, ca_crl, profile, + pathlen, selfsigned, flags, f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + ret = x509_crt_verify_top( crt, trust_ca, ca_crl, profile, + pathlen, selfsigned, flags, f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + } + + if( *flags != 0 ) + return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ); + + return( 0 ); +} + +/* + * Initialize a certificate chain + */ +void mbedtls_x509_crt_init( mbedtls_x509_crt *crt ) +{ + memset( crt, 0, sizeof(mbedtls_x509_crt) ); +} + +/* + * Unallocate all certificate data + */ +void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ) +{ + mbedtls_x509_crt *cert_cur = crt; + mbedtls_x509_crt *cert_prv; + mbedtls_x509_name *name_cur; + mbedtls_x509_name *name_prv; + mbedtls_x509_sequence *seq_cur; + mbedtls_x509_sequence *seq_prv; + + if( crt == NULL ) + return; + + do + { + mbedtls_pk_free( &cert_cur->pk ); + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + mbedtls_free( cert_cur->sig_opts ); +#endif + + name_cur = cert_cur->issuer.next; + while( name_cur != NULL ) + { + name_prv = name_cur; + name_cur = name_cur->next; + mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_free( name_prv ); + } + + name_cur = cert_cur->subject.next; + while( name_cur != NULL ) + { + name_prv = name_cur; + name_cur = name_cur->next; + mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_free( name_prv ); + } + + seq_cur = cert_cur->ext_key_usage.next; + while( seq_cur != NULL ) + { + seq_prv = seq_cur; + seq_cur = seq_cur->next; + mbedtls_zeroize( seq_prv, sizeof( mbedtls_x509_sequence ) ); + mbedtls_free( seq_prv ); + } + + seq_cur = cert_cur->subject_alt_names.next; + while( seq_cur != NULL ) + { + seq_prv = seq_cur; + seq_cur = seq_cur->next; + mbedtls_zeroize( seq_prv, sizeof( mbedtls_x509_sequence ) ); + mbedtls_free( seq_prv ); + } + + if( cert_cur->raw.p != NULL ) + { + mbedtls_zeroize( cert_cur->raw.p, cert_cur->raw.len ); + mbedtls_free( cert_cur->raw.p ); + } + + cert_cur = cert_cur->next; + } + while( cert_cur != NULL ); + + cert_cur = crt; + do + { + cert_prv = cert_cur; + cert_cur = cert_cur->next; + + mbedtls_zeroize( cert_prv, sizeof( mbedtls_x509_crt ) ); + if( cert_prv != crt ) + mbedtls_free( cert_prv ); + } + while( cert_cur != NULL ); +} + +#endif /* MBEDTLS_X509_CRT_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_csr.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_csr.c new file mode 100644 index 0000000..f92b66c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509_csr.c @@ -0,0 +1,423 @@ +/* + * X.509 Certificate Signing Request (CSR) parsing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * The ITU-T X.509 standard defines a certificate format for PKI. + * + * http://www.ietf.org/rfc/rfc5280.txt (Certificates and CRLs) + * http://www.ietf.org/rfc/rfc3279.txt (Alg IDs for CRLs) + * http://www.ietf.org/rfc/rfc2986.txt (CSRs, aka PKCS#10) + * + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf + * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_CSR_PARSE_C) + +#include "mbedtls/x509_csr.h" +#include "mbedtls/oid.h" + +#include + +#if defined(MBEDTLS_PEM_PARSE_C) +#include "mbedtls/pem.h" +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_free free +#define mbedtls_calloc calloc +#define mbedtls_snprintf snprintf +#endif + +#if defined(MBEDTLS_FS_IO) || defined(EFIX64) || defined(EFI32) +#include +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * Version ::= INTEGER { v1(0) } + */ +static int x509_csr_get_version( unsigned char **p, + const unsigned char *end, + int *ver ) +{ + int ret; + + if( ( ret = mbedtls_asn1_get_int( p, end, ver ) ) != 0 ) + { + if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) + { + *ver = 0; + return( 0 ); + } + + return( MBEDTLS_ERR_X509_INVALID_VERSION + ret ); + } + + return( 0 ); +} + +/* + * Parse a CSR in DER format + */ +int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr, + const unsigned char *buf, size_t buflen ) +{ + int ret; + size_t len; + unsigned char *p, *end; + mbedtls_x509_buf sig_params; + + memset( &sig_params, 0, sizeof( mbedtls_x509_buf ) ); + + /* + * Check for valid input + */ + if( csr == NULL || buf == NULL || buflen == 0 ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + mbedtls_x509_csr_init( csr ); + + /* + * first copy the raw DER data + */ + p = mbedtls_calloc( 1, len = buflen ); + + if( p == NULL ) + return( MBEDTLS_ERR_X509_ALLOC_FAILED ); + + memcpy( p, buf, buflen ); + + csr->raw.p = p; + csr->raw.len = len; + end = p + len; + + /* + * CertificationRequest ::= SEQUENCE { + * certificationRequestInfo CertificationRequestInfo, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING + * } + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT ); + } + + if( len != (size_t) ( end - p ) ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + /* + * CertificationRequestInfo ::= SEQUENCE { + */ + csr->cri.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + end = p + len; + csr->cri.len = end - csr->cri.p; + + /* + * Version ::= INTEGER { v1(0) } + */ + if( ( ret = x509_csr_get_version( &p, end, &csr->version ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( ret ); + } + + csr->version++; + + if( csr->version != 1 ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_UNKNOWN_VERSION ); + } + + /* + * subject Name + */ + csr->subject_raw.p = p; + + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + if( ( ret = mbedtls_x509_get_name( &p, p + len, &csr->subject ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( ret ); + } + + csr->subject_raw.len = p - csr->subject_raw.p; + + /* + * subjectPKInfo SubjectPublicKeyInfo + */ + if( ( ret = mbedtls_pk_parse_subpubkey( &p, end, &csr->pk ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( ret ); + } + + /* + * attributes [0] Attributes + * + * The list of possible attributes is open-ended, though RFC 2985 + * (PKCS#9) defines a few in section 5.4. We currently don't support any, + * so we just ignore them. This is a safe thing to do as the worst thing + * that could happen is that we issue a certificate that does not match + * the requester's expectations - this cannot cause a violation of our + * signature policies. + */ + if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_CONTEXT_SPECIFIC ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); + } + + p += len; + + end = csr->raw.p + csr->raw.len; + + /* + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING + */ + if( ( ret = mbedtls_x509_get_alg( &p, end, &csr->sig_oid, &sig_params ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( ret ); + } + + if( ( ret = mbedtls_x509_get_sig_alg( &csr->sig_oid, &sig_params, + &csr->sig_md, &csr->sig_pk, + &csr->sig_opts ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG ); + } + + if( ( ret = mbedtls_x509_get_sig( &p, end, &csr->sig ) ) != 0 ) + { + mbedtls_x509_csr_free( csr ); + return( ret ); + } + + if( p != end ) + { + mbedtls_x509_csr_free( csr ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + + return( 0 ); +} + +/* + * Parse a CSR, allowing for PEM or raw DER encoding + */ +int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen ) +{ +#if defined(MBEDTLS_PEM_PARSE_C) + int ret; + size_t use_len; + mbedtls_pem_context pem; +#endif + + /* + * Check for valid input + */ + if( csr == NULL || buf == NULL || buflen == 0 ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_PEM_PARSE_C) + mbedtls_pem_init( &pem ); + + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( buf[buflen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN CERTIFICATE REQUEST-----", + "-----END CERTIFICATE REQUEST-----", + buf, NULL, 0, &use_len ); + + if( ret == 0 ) + { + /* + * Was PEM encoded, parse the result + */ + if( ( ret = mbedtls_x509_csr_parse_der( csr, pem.buf, pem.buflen ) ) != 0 ) + return( ret ); + + mbedtls_pem_free( &pem ); + return( 0 ); + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + { + mbedtls_pem_free( &pem ); + return( ret ); + } + else +#endif /* MBEDTLS_PEM_PARSE_C */ + return( mbedtls_x509_csr_parse_der( csr, buf, buflen ) ); +} + +#if defined(MBEDTLS_FS_IO) +/* + * Load a CSR into the structure + */ +int mbedtls_x509_csr_parse_file( mbedtls_x509_csr *csr, const char *path ) +{ + int ret; + size_t n; + unsigned char *buf; + + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) + return( ret ); + + ret = mbedtls_x509_csr_parse( csr, buf, n ); + + mbedtls_zeroize( buf, n ); + mbedtls_free( buf ); + + return( ret ); +} +#endif /* MBEDTLS_FS_IO */ + +#define BEFORE_COLON 14 +#define BC "14" +/* + * Return an informational string about the CSR. + */ +int mbedtls_x509_csr_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_csr *csr ) +{ + int ret; + size_t n; + char *p; + char key_size_str[BEFORE_COLON]; + + p = buf; + n = size; + + ret = mbedtls_snprintf( p, n, "%sCSR version : %d", + prefix, csr->version ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%ssubject name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_x509_dn_gets( p, n, &csr->subject ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_snprintf( p, n, "\n%ssigned using : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + + ret = mbedtls_x509_sig_alg_gets( p, n, &csr->sig_oid, csr->sig_pk, csr->sig_md, + csr->sig_opts ); + MBEDTLS_X509_SAFE_SNPRINTF; + + if( ( ret = mbedtls_x509_key_size_helper( key_size_str, BEFORE_COLON, + mbedtls_pk_get_name( &csr->pk ) ) ) != 0 ) + { + return( ret ); + } + + ret = mbedtls_snprintf( p, n, "\n%s%-" BC "s: %d bits\n", prefix, key_size_str, + (int) mbedtls_pk_get_bitlen( &csr->pk ) ); + MBEDTLS_X509_SAFE_SNPRINTF; + + return( (int) ( size - n ) ); +} + +/* + * Initialize a CSR + */ +void mbedtls_x509_csr_init( mbedtls_x509_csr *csr ) +{ + memset( csr, 0, sizeof(mbedtls_x509_csr) ); +} + +/* + * Unallocate all CSR data + */ +void mbedtls_x509_csr_free( mbedtls_x509_csr *csr ) +{ + mbedtls_x509_name *name_cur; + mbedtls_x509_name *name_prv; + + if( csr == NULL ) + return; + + mbedtls_pk_free( &csr->pk ); + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + mbedtls_free( csr->sig_opts ); +#endif + + name_cur = csr->subject.next; + while( name_cur != NULL ) + { + name_prv = name_cur; + name_cur = name_cur->next; + mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_free( name_prv ); + } + + if( csr->raw.p != NULL ) + { + mbedtls_zeroize( csr->raw.p, csr->raw.len ); + mbedtls_free( csr->raw.p ); + } + + mbedtls_zeroize( csr, sizeof( mbedtls_x509_csr ) ); +} + +#endif /* MBEDTLS_X509_CSR_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_crt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_crt.c new file mode 100644 index 0000000..d1d9a22 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_crt.c @@ -0,0 +1,459 @@ +/* + * X.509 certificate writing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * References: + * - certificates: RFC 5280, updated by RFC 6818 + * - CSRs: PKCS#10 v1.7 aka RFC 2986 + * - attributes: PKCS#9 v2.0 aka RFC 2985 + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_CRT_WRITE_C) + +#include "mbedtls/x509_crt.h" +#include "mbedtls/oid.h" +#include "mbedtls/asn1write.h" +#include "mbedtls/sha1.h" + +#include + +#if defined(MBEDTLS_PEM_WRITE_C) +#include "mbedtls/pem.h" +#endif /* MBEDTLS_PEM_WRITE_C */ + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx ) +{ + memset( ctx, 0, sizeof(mbedtls_x509write_cert) ); + + mbedtls_mpi_init( &ctx->serial ); + ctx->version = MBEDTLS_X509_CRT_VERSION_3; +} + +void mbedtls_x509write_crt_free( mbedtls_x509write_cert *ctx ) +{ + mbedtls_mpi_free( &ctx->serial ); + + mbedtls_asn1_free_named_data_list( &ctx->subject ); + mbedtls_asn1_free_named_data_list( &ctx->issuer ); + mbedtls_asn1_free_named_data_list( &ctx->extensions ); + + mbedtls_zeroize( ctx, sizeof(mbedtls_x509write_cert) ); +} + +void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version ) +{ + ctx->version = version; +} + +void mbedtls_x509write_crt_set_md_alg( mbedtls_x509write_cert *ctx, mbedtls_md_type_t md_alg ) +{ + ctx->md_alg = md_alg; +} + +void mbedtls_x509write_crt_set_subject_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ) +{ + ctx->subject_key = key; +} + +void mbedtls_x509write_crt_set_issuer_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ) +{ + ctx->issuer_key = key; +} + +int mbedtls_x509write_crt_set_subject_name( mbedtls_x509write_cert *ctx, + const char *subject_name ) +{ + return mbedtls_x509_string_to_names( &ctx->subject, subject_name ); +} + +int mbedtls_x509write_crt_set_issuer_name( mbedtls_x509write_cert *ctx, + const char *issuer_name ) +{ + return mbedtls_x509_string_to_names( &ctx->issuer, issuer_name ); +} + +int mbedtls_x509write_crt_set_serial( mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial ) +{ + int ret; + + if( ( ret = mbedtls_mpi_copy( &ctx->serial, serial ) ) != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_x509write_crt_set_validity( mbedtls_x509write_cert *ctx, const char *not_before, + const char *not_after ) +{ + if( strlen( not_before ) != MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1 || + strlen( not_after ) != MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1 ) + { + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + } + strncpy( ctx->not_before, not_before, MBEDTLS_X509_RFC5280_UTC_TIME_LEN ); + strncpy( ctx->not_after , not_after , MBEDTLS_X509_RFC5280_UTC_TIME_LEN ); + ctx->not_before[MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1] = 'Z'; + ctx->not_after[MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1] = 'Z'; + + return( 0 ); +} + +int mbedtls_x509write_crt_set_extension( mbedtls_x509write_cert *ctx, + const char *oid, size_t oid_len, + int critical, + const unsigned char *val, size_t val_len ) +{ + return mbedtls_x509_set_extension( &ctx->extensions, oid, oid_len, + critical, val, val_len ); +} + +int mbedtls_x509write_crt_set_basic_constraints( mbedtls_x509write_cert *ctx, + int is_ca, int max_pathlen ) +{ + int ret; + unsigned char buf[9]; + unsigned char *c = buf + sizeof(buf); + size_t len = 0; + + memset( buf, 0, sizeof(buf) ); + + if( is_ca && max_pathlen > 127 ) + return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); + + if( is_ca ) + { + if( max_pathlen >= 0 ) + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_int( &c, buf, max_pathlen ) ); + } + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_bool( &c, buf, 1 ) ); + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_BASIC_CONSTRAINTS, + MBEDTLS_OID_SIZE( MBEDTLS_OID_BASIC_CONSTRAINTS ), + 0, buf + sizeof(buf) - len, len ); +} + +#if defined(MBEDTLS_SHA1_C) +int mbedtls_x509write_crt_set_subject_key_identifier( mbedtls_x509write_cert *ctx ) +{ + int ret; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE * 2 + 20]; /* tag, length + 2xMPI */ + unsigned char *c = buf + sizeof(buf); + size_t len = 0; + + memset( buf, 0, sizeof(buf) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->subject_key ) ); + + mbedtls_sha1( buf + sizeof(buf) - len, len, buf + sizeof(buf) - 20 ); + c = buf + sizeof(buf) - 20; + len = 20; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_OCTET_STRING ) ); + + return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER, + MBEDTLS_OID_SIZE( MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER ), + 0, buf + sizeof(buf) - len, len ); +} + +int mbedtls_x509write_crt_set_authority_key_identifier( mbedtls_x509write_cert *ctx ) +{ + int ret; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE * 2 + 20]; /* tag, length + 2xMPI */ + unsigned char *c = buf + sizeof(buf); + size_t len = 0; + + memset( buf, 0, sizeof(buf) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->issuer_key ) ); + + mbedtls_sha1( buf + sizeof(buf) - len, len, buf + sizeof(buf) - 20 ); + c = buf + sizeof(buf) - 20; + len = 20; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC | 0 ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER, + MBEDTLS_OID_SIZE( MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER ), + 0, buf + sizeof(buf) - len, len ); +} +#endif /* MBEDTLS_SHA1_C */ + +int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, + unsigned int key_usage ) +{ + unsigned char buf[4], ku; + unsigned char *c; + int ret; + + /* We currently only support 7 bits, from 0x80 to 0x02 */ + if( ( key_usage & ~0xfe ) != 0 ) + return( MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE ); + + c = buf + 4; + ku = (unsigned char) key_usage; + + if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &ku, 7 ) ) != 4 ) + return( ret ); + + ret = mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_KEY_USAGE, + MBEDTLS_OID_SIZE( MBEDTLS_OID_KEY_USAGE ), + 1, buf, 4 ); + if( ret != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx, + unsigned char ns_cert_type ) +{ + unsigned char buf[4]; + unsigned char *c; + int ret; + + c = buf + 4; + + if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &ns_cert_type, 8 ) ) != 4 ) + return( ret ); + + ret = mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_NS_CERT_TYPE, + MBEDTLS_OID_SIZE( MBEDTLS_OID_NS_CERT_TYPE ), + 0, buf, 4 ); + if( ret != 0 ) + return( ret ); + + return( 0 ); +} + +static int x509_write_time( unsigned char **p, unsigned char *start, + const char *time, size_t size ) +{ + int ret; + size_t len = 0; + + /* + * write MBEDTLS_ASN1_UTC_TIME if year < 2050 (2 bytes shorter) + */ + if( time[0] == '2' && time[1] == '0' && time [2] < '5' ) + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) time + 2, + size - 2 ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_UTC_TIME ) ); + } + else + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) time, + size ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_GENERALIZED_TIME ) ); + } + + return( (int) len ); +} + +int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + const char *sig_oid; + size_t sig_oid_len = 0; + unsigned char *c, *c2; + unsigned char hash[64]; + unsigned char sig[MBEDTLS_MPI_MAX_SIZE]; + unsigned char tmp_buf[2048]; + size_t sub_len = 0, pub_len = 0, sig_and_oid_len = 0, sig_len; + size_t len = 0; + mbedtls_pk_type_t pk_alg; + + /* + * Prepare data to be signed in tmp_buf + */ + c = tmp_buf + sizeof( tmp_buf ); + + /* Signature algorithm needed in TBS, and later for actual signature */ + pk_alg = mbedtls_pk_get_type( ctx->issuer_key ); + if( pk_alg == MBEDTLS_PK_ECKEY ) + pk_alg = MBEDTLS_PK_ECDSA; + + if( ( ret = mbedtls_oid_get_oid_by_sig_alg( pk_alg, ctx->md_alg, + &sig_oid, &sig_oid_len ) ) != 0 ) + { + return( ret ); + } + + /* + * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC | + MBEDTLS_ASN1_CONSTRUCTED | 3 ) ); + + /* + * SubjectPublicKeyInfo + */ + MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_pk_write_pubkey_der( ctx->subject_key, + tmp_buf, c - tmp_buf ) ); + c -= pub_len; + len += pub_len; + + /* + * Subject ::= Name + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->subject ) ); + + /* + * Validity ::= SEQUENCE { + * notBefore Time, + * notAfter Time } + */ + sub_len = 0; + + MBEDTLS_ASN1_CHK_ADD( sub_len, x509_write_time( &c, tmp_buf, ctx->not_after, + MBEDTLS_X509_RFC5280_UTC_TIME_LEN ) ); + + MBEDTLS_ASN1_CHK_ADD( sub_len, x509_write_time( &c, tmp_buf, ctx->not_before, + MBEDTLS_X509_RFC5280_UTC_TIME_LEN ) ); + + len += sub_len; + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, sub_len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + /* + * Issuer ::= Name + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->issuer ) ); + + /* + * Signature ::= AlgorithmIdentifier + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_algorithm_identifier( &c, tmp_buf, + sig_oid, strlen( sig_oid ), 0 ) ); + + /* + * Serial ::= INTEGER + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, tmp_buf, &ctx->serial ) ); + + /* + * Version ::= INTEGER { v1(0), v2(1), v3(2) } + */ + sub_len = 0; + MBEDTLS_ASN1_CHK_ADD( sub_len, mbedtls_asn1_write_int( &c, tmp_buf, ctx->version ) ); + len += sub_len; + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, sub_len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC | + MBEDTLS_ASN1_CONSTRUCTED | 0 ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + /* + * Make signature + */ + mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash ); + + if( ( ret = mbedtls_pk_sign( ctx->issuer_key, ctx->md_alg, hash, 0, sig, &sig_len, + f_rng, p_rng ) ) != 0 ) + { + return( ret ); + } + + /* + * Write data to output buffer + */ + c2 = buf + size; + MBEDTLS_ASN1_CHK_ADD( sig_and_oid_len, mbedtls_x509_write_sig( &c2, buf, + sig_oid, sig_oid_len, sig, sig_len ) ); + + if( len > (size_t)( c2 - buf ) ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + c2 -= len; + memcpy( c2, c, len ); + + len += sig_and_oid_len; + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c2, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c2, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +#define PEM_BEGIN_CRT "-----BEGIN CERTIFICATE-----\n" +#define PEM_END_CRT "-----END CERTIFICATE-----\n" + +#if defined(MBEDTLS_PEM_WRITE_C) +int mbedtls_x509write_crt_pem( mbedtls_x509write_cert *crt, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + unsigned char output_buf[4096]; + size_t olen = 0; + + if( ( ret = mbedtls_x509write_crt_der( crt, output_buf, sizeof(output_buf), + f_rng, p_rng ) ) < 0 ) + { + return( ret ); + } + + if( ( ret = mbedtls_pem_write_buffer( PEM_BEGIN_CRT, PEM_END_CRT, + output_buf + sizeof(output_buf) - ret, + ret, buf, size, &olen ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_PEM_WRITE_C */ + +#endif /* MBEDTLS_X509_CRT_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_csr.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_csr.c new file mode 100644 index 0000000..8fd856b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/x509write_csr.c @@ -0,0 +1,259 @@ +/* + * X.509 Certificate Signing Request writing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +/* + * References: + * - CSRs: PKCS#10 v1.7 aka RFC 2986 + * - attributes: PKCS#9 v2.0 aka RFC 2985 + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_X509_CSR_WRITE_C) + +#include "mbedtls/x509_csr.h" +#include "mbedtls/oid.h" +#include "mbedtls/asn1write.h" + +#include +#include + +#if defined(MBEDTLS_PEM_WRITE_C) +#include "mbedtls/pem.h" +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx ) +{ + memset( ctx, 0, sizeof(mbedtls_x509write_csr) ); +} + +void mbedtls_x509write_csr_free( mbedtls_x509write_csr *ctx ) +{ + mbedtls_asn1_free_named_data_list( &ctx->subject ); + mbedtls_asn1_free_named_data_list( &ctx->extensions ); + + mbedtls_zeroize( ctx, sizeof(mbedtls_x509write_csr) ); +} + +void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg ) +{ + ctx->md_alg = md_alg; +} + +void mbedtls_x509write_csr_set_key( mbedtls_x509write_csr *ctx, mbedtls_pk_context *key ) +{ + ctx->key = key; +} + +int mbedtls_x509write_csr_set_subject_name( mbedtls_x509write_csr *ctx, + const char *subject_name ) +{ + return mbedtls_x509_string_to_names( &ctx->subject, subject_name ); +} + +int mbedtls_x509write_csr_set_extension( mbedtls_x509write_csr *ctx, + const char *oid, size_t oid_len, + const unsigned char *val, size_t val_len ) +{ + return mbedtls_x509_set_extension( &ctx->extensions, oid, oid_len, + 0, val, val_len ); +} + +int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage ) +{ + unsigned char buf[4]; + unsigned char *c; + int ret; + + c = buf + 4; + + if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &key_usage, 7 ) ) != 4 ) + return( ret ); + + ret = mbedtls_x509write_csr_set_extension( ctx, MBEDTLS_OID_KEY_USAGE, + MBEDTLS_OID_SIZE( MBEDTLS_OID_KEY_USAGE ), + buf, 4 ); + if( ret != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_x509write_csr_set_ns_cert_type( mbedtls_x509write_csr *ctx, + unsigned char ns_cert_type ) +{ + unsigned char buf[4]; + unsigned char *c; + int ret; + + c = buf + 4; + + if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &ns_cert_type, 8 ) ) != 4 ) + return( ret ); + + ret = mbedtls_x509write_csr_set_extension( ctx, MBEDTLS_OID_NS_CERT_TYPE, + MBEDTLS_OID_SIZE( MBEDTLS_OID_NS_CERT_TYPE ), + buf, 4 ); + if( ret != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + const char *sig_oid; + size_t sig_oid_len = 0; + unsigned char *c, *c2; + unsigned char hash[64]; + unsigned char sig[MBEDTLS_MPI_MAX_SIZE]; + unsigned char tmp_buf[2048]; + size_t pub_len = 0, sig_and_oid_len = 0, sig_len; + size_t len = 0; + mbedtls_pk_type_t pk_alg; + + /* + * Prepare data to be signed in tmp_buf + */ + c = tmp_buf + sizeof( tmp_buf ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) ); + + if( len ) + { + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SET ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( &c, tmp_buf, MBEDTLS_OID_PKCS9_CSR_EXT_REQ, + MBEDTLS_OID_SIZE( MBEDTLS_OID_PKCS9_CSR_EXT_REQ ) ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_CONTEXT_SPECIFIC ) ); + + MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_pk_write_pubkey_der( ctx->key, + tmp_buf, c - tmp_buf ) ); + c -= pub_len; + len += pub_len; + + /* + * Subject ::= Name + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->subject ) ); + + /* + * Version ::= INTEGER { v1(0), v2(1), v3(2) } + */ + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_int( &c, tmp_buf, 0 ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + /* + * Prepare signature + */ + mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash ); + + pk_alg = mbedtls_pk_get_type( ctx->key ); + if( pk_alg == MBEDTLS_PK_ECKEY ) + pk_alg = MBEDTLS_PK_ECDSA; + + if( ( ret = mbedtls_pk_sign( ctx->key, ctx->md_alg, hash, 0, sig, &sig_len, + f_rng, p_rng ) ) != 0 || + ( ret = mbedtls_oid_get_oid_by_sig_alg( pk_alg, ctx->md_alg, + &sig_oid, &sig_oid_len ) ) != 0 ) + { + return( ret ); + } + + /* + * Write data to output buffer + */ + c2 = buf + size; + MBEDTLS_ASN1_CHK_ADD( sig_and_oid_len, mbedtls_x509_write_sig( &c2, buf, + sig_oid, sig_oid_len, sig, sig_len ) ); + + if( len > (size_t)( c2 - buf ) ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + c2 -= len; + memcpy( c2, c, len ); + + len += sig_and_oid_len; + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c2, buf, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c2, buf, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +#define PEM_BEGIN_CSR "-----BEGIN CERTIFICATE REQUEST-----\n" +#define PEM_END_CSR "-----END CERTIFICATE REQUEST-----\n" + +#if defined(MBEDTLS_PEM_WRITE_C) +int mbedtls_x509write_csr_pem( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + unsigned char output_buf[4096]; + size_t olen = 0; + + if( ( ret = mbedtls_x509write_csr_der( ctx, output_buf, sizeof(output_buf), + f_rng, p_rng ) ) < 0 ) + { + return( ret ); + } + + if( ( ret = mbedtls_pem_write_buffer( PEM_BEGIN_CSR, PEM_END_CSR, + output_buf + sizeof(output_buf) - ret, + ret, buf, size, &olen ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_PEM_WRITE_C */ + +#endif /* MBEDTLS_X509_CSR_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/xtea.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/xtea.c new file mode 100644 index 0000000..fe0a350 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/library/xtea.c @@ -0,0 +1,281 @@ +/* + * An 32-bit implementation of the XTEA algorithm + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_XTEA_C) + +#include "mbedtls/xtea.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_XTEA_ALT) + +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +void mbedtls_xtea_init( mbedtls_xtea_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_xtea_context ) ); +} + +void mbedtls_xtea_free( mbedtls_xtea_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_zeroize( ctx, sizeof( mbedtls_xtea_context ) ); +} + +/* + * XTEA key schedule + */ +void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] ) +{ + int i; + + memset( ctx, 0, sizeof(mbedtls_xtea_context) ); + + for( i = 0; i < 4; i++ ) + { + GET_UINT32_BE( ctx->k[i], key, i << 2 ); + } +} + +/* + * XTEA encrypt function + */ +int mbedtls_xtea_crypt_ecb( mbedtls_xtea_context *ctx, int mode, + const unsigned char input[8], unsigned char output[8]) +{ + uint32_t *k, v0, v1, i; + + k = ctx->k; + + GET_UINT32_BE( v0, input, 0 ); + GET_UINT32_BE( v1, input, 4 ); + + if( mode == MBEDTLS_XTEA_ENCRYPT ) + { + uint32_t sum = 0, delta = 0x9E3779B9; + + for( i = 0; i < 32; i++ ) + { + v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]); + sum += delta; + v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]); + } + } + else /* MBEDTLS_XTEA_DECRYPT */ + { + uint32_t delta = 0x9E3779B9, sum = delta * 32; + + for( i = 0; i < 32; i++ ) + { + v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]); + sum -= delta; + v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]); + } + } + + PUT_UINT32_BE( v0, output, 0 ); + PUT_UINT32_BE( v1, output, 4 ); + + return( 0 ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * XTEA-CBC buffer encryption/decryption + */ +int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx, int mode, size_t length, + unsigned char iv[8], const unsigned char *input, + unsigned char *output) +{ + int i; + unsigned char temp[8]; + + if( length % 8 ) + return( MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH ); + + if( mode == MBEDTLS_XTEA_DECRYPT ) + { + while( length > 0 ) + { + memcpy( temp, input, 8 ); + mbedtls_xtea_crypt_ecb( ctx, mode, input, output ); + + for( i = 0; i < 8; i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, 8 ); + + input += 8; + output += 8; + length -= 8; + } + } + else + { + while( length > 0 ) + { + for( i = 0; i < 8; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_xtea_crypt_ecb( ctx, mode, output, output ); + memcpy( iv, output, 8 ); + + input += 8; + output += 8; + length -= 8; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* !MBEDTLS_XTEA_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +/* + * XTEA tests vectors (non-official) + */ + +static const unsigned char xtea_test_key[6][16] = +{ + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 } +}; + +static const unsigned char xtea_test_pt[6][8] = +{ + { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 }, + { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }, + { 0x5a, 0x5b, 0x6e, 0x27, 0x89, 0x48, 0xd7, 0x7f }, + { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 }, + { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }, + { 0x70, 0xe1, 0x22, 0x5d, 0x6e, 0x4e, 0x76, 0x55 } +}; + +static const unsigned char xtea_test_ct[6][8] = +{ + { 0x49, 0x7d, 0xf3, 0xd0, 0x72, 0x61, 0x2c, 0xb5 }, + { 0xe7, 0x8f, 0x2d, 0x13, 0x74, 0x43, 0x41, 0xd8 }, + { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }, + { 0xa0, 0x39, 0x05, 0x89, 0xf8, 0xb8, 0xef, 0xa5 }, + { 0xed, 0x23, 0x37, 0x5a, 0x82, 0x1a, 0x8c, 0x2d }, + { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 } +}; + +/* + * Checkup routine + */ +int mbedtls_xtea_self_test( int verbose ) +{ + int i, ret = 0; + unsigned char buf[8]; + mbedtls_xtea_context ctx; + + mbedtls_xtea_init( &ctx ); + for( i = 0; i < 6; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " XTEA test #%d: ", i + 1 ); + + memcpy( buf, xtea_test_pt[i], 8 ); + + mbedtls_xtea_setup( &ctx, xtea_test_key[i] ); + mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, buf, buf ); + + if( memcmp( buf, xtea_test_ct[i], 8 ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + +exit: + mbedtls_xtea_free( &ctx ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_XTEA_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/CMakeLists.txt new file mode 100644 index 0000000..4cdae78 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(aes) +add_subdirectory(hash) +add_subdirectory(pkey) +add_subdirectory(random) +add_subdirectory(ssl) +add_subdirectory(test) +add_subdirectory(x509) +add_subdirectory(util) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/Makefile new file mode 100644 index 0000000..443689b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/Makefile @@ -0,0 +1,288 @@ + +# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS +# To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS + +CFLAGS ?= -O2 +WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement +LDFLAGS ?= + +LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 +LOCAL_LDFLAGS = -L../library \ + -lmbedtls$(SHARED_SUFFIX) \ + -lmbedx509$(SHARED_SUFFIX) \ + -lmbedcrypto$(SHARED_SUFFIX) + +ifndef SHARED +DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a +else +DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) +endif + +ifdef DEBUG +LOCAL_CFLAGS += -g3 +endif + +# if we're running on Windows, build for Windows +ifdef WINDOWS +WINDOWS_BUILD=1 +endif + +ifdef WINDOWS_BUILD +DLEXT=dll +EXEXT=.exe +LOCAL_LDFLAGS += -lws2_32 +ifdef SHARED +SHARED_SUFFIX=.$(DLEXT) +endif +else +DLEXT=so +EXEXT= +SHARED_SUFFIX= +endif + +# Zlib shared library extensions: +ifdef ZLIB +LOCAL_LDFLAGS += -lz +endif + +APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \ + hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \ + pkey/dh_client$(EXEXT) \ + pkey/dh_genprime$(EXEXT) pkey/dh_server$(EXEXT) \ + pkey/ecdh_curve25519$(EXEXT) \ + pkey/ecdsa$(EXEXT) pkey/gen_key$(EXEXT) \ + pkey/key_app$(EXEXT) pkey/key_app_writer$(EXEXT) \ + pkey/mpi_demo$(EXEXT) pkey/pk_decrypt$(EXEXT) \ + pkey/pk_encrypt$(EXEXT) pkey/pk_sign$(EXEXT) \ + pkey/pk_verify$(EXEXT) pkey/rsa_genkey$(EXEXT) \ + pkey/rsa_decrypt$(EXEXT) pkey/rsa_encrypt$(EXEXT) \ + pkey/rsa_sign$(EXEXT) pkey/rsa_verify$(EXEXT) \ + pkey/rsa_sign_pss$(EXEXT) pkey/rsa_verify_pss$(EXEXT) \ + ssl/dtls_client$(EXEXT) ssl/dtls_server$(EXEXT) \ + ssl/ssl_client1$(EXEXT) ssl/ssl_client2$(EXEXT) \ + ssl/ssl_server$(EXEXT) ssl/ssl_server2$(EXEXT) \ + ssl/ssl_fork_server$(EXEXT) ssl/mini_client$(EXEXT) \ + ssl/ssl_mail_client$(EXEXT) random/gen_entropy$(EXEXT) \ + random/gen_random_havege$(EXEXT) \ + random/gen_random_ctr_drbg$(EXEXT) \ + test/ssl_cert_test$(EXEXT) test/benchmark$(EXEXT) \ + test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \ + util/pem2der$(EXEXT) util/strerror$(EXEXT) \ + x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \ + x509/cert_req$(EXEXT) x509/cert_write$(EXEXT) \ + x509/req_app$(EXEXT) + +ifdef PTHREAD +APPS += ssl/ssl_pthread_server$(EXEXT) +endif + +.SILENT: + +.PHONY: all clean list + +all: $(APPS) + +$(DEP): + $(MAKE) -C ../library + +aes/aescrypt2$(EXEXT): aes/aescrypt2.c $(DEP) + echo " CC aes/aescrypt2.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) aes/aescrypt2.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +aes/crypt_and_hash$(EXEXT): aes/crypt_and_hash.c $(DEP) + echo " CC aes/crypt_and_hash.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) aes/crypt_and_hash.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +hash/hello$(EXEXT): hash/hello.c $(DEP) + echo " CC hash/hello.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) hash/hello.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +hash/generic_sum$(EXEXT): hash/generic_sum.c $(DEP) + echo " CC hash/generic_sum.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) hash/generic_sum.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/dh_client$(EXEXT): pkey/dh_client.c $(DEP) + echo " CC pkey/dh_client.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/dh_genprime$(EXEXT): pkey/dh_genprime.c $(DEP) + echo " CC pkey/dh_genprime.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_genprime.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/dh_server$(EXEXT): pkey/dh_server.c $(DEP) + echo " CC pkey/dh_server.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/ecdh_curve25519$(EXEXT): pkey/ecdh_curve25519.c $(DEP) + echo " CC pkey/ecdh_curve25519.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/ecdh_curve25519.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/ecdsa$(EXEXT): pkey/ecdsa.c $(DEP) + echo " CC pkey/ecdsa.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/ecdsa.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/gen_key$(EXEXT): pkey/gen_key.c $(DEP) + echo " CC pkey/gen_key.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/gen_key.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/key_app$(EXEXT): pkey/key_app.c $(DEP) + echo " CC pkey/key_app.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/key_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/key_app_writer$(EXEXT): pkey/key_app_writer.c $(DEP) + echo " CC pkey/key_app_writer.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/key_app_writer.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/mpi_demo$(EXEXT): pkey/mpi_demo.c $(DEP) + echo " CC pkey/mpi_demo.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/mpi_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/pk_decrypt$(EXEXT): pkey/pk_decrypt.c $(DEP) + echo " CC pkey/pk_decrypt.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_decrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/pk_encrypt$(EXEXT): pkey/pk_encrypt.c $(DEP) + echo " CC pkey/pk_encrypt.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_encrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/pk_sign$(EXEXT): pkey/pk_sign.c $(DEP) + echo " CC pkey/pk_sign.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_sign.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/pk_verify$(EXEXT): pkey/pk_verify.c $(DEP) + echo " CC pkey/pk_verify.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_verify.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_genkey$(EXEXT): pkey/rsa_genkey.c $(DEP) + echo " CC pkey/rsa_genkey.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_genkey.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_sign$(EXEXT): pkey/rsa_sign.c $(DEP) + echo " CC pkey/rsa_sign.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_sign.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_verify$(EXEXT): pkey/rsa_verify.c $(DEP) + echo " CC pkey/rsa_verify.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_verify.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_sign_pss$(EXEXT): pkey/rsa_sign_pss.c $(DEP) + echo " CC pkey/rsa_sign_pss.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_sign_pss.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_verify_pss$(EXEXT): pkey/rsa_verify_pss.c $(DEP) + echo " CC pkey/rsa_verify_pss.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_verify_pss.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_decrypt$(EXEXT): pkey/rsa_decrypt.c $(DEP) + echo " CC pkey/rsa_decrypt.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_decrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +pkey/rsa_encrypt$(EXEXT): pkey/rsa_encrypt.c $(DEP) + echo " CC pkey/rsa_encrypt.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_encrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +random/gen_entropy$(EXEXT): random/gen_entropy.c $(DEP) + echo " CC random/gen_entropy.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) random/gen_entropy.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +random/gen_random_havege$(EXEXT): random/gen_random_havege.c $(DEP) + echo " CC random/gen_random_havege.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) random/gen_random_havege.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +random/gen_random_ctr_drbg$(EXEXT): random/gen_random_ctr_drbg.c $(DEP) + echo " CC random/gen_random_ctr_drbg.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) random/gen_random_ctr_drbg.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/dtls_client$(EXEXT): ssl/dtls_client.c $(DEP) + echo " CC ssl/dtls_client.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/dtls_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/dtls_server$(EXEXT): ssl/dtls_server.c $(DEP) + echo " CC ssl/dtls_server.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/dtls_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP) + echo " CC ssl/ssl_client1.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(DEP) + echo " CC ssl/ssl_client2.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/ssl_server$(EXEXT): ssl/ssl_server.c $(DEP) + echo " CC ssl/ssl_server.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c $(DEP) + echo " CC ssl/ssl_server2.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/ssl_fork_server$(EXEXT): ssl/ssl_fork_server.c $(DEP) + echo " CC ssl/ssl_fork_server.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_fork_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/ssl_pthread_server$(EXEXT): ssl/ssl_pthread_server.c $(DEP) + echo " CC ssl/ssl_pthread_server.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_pthread_server.c $(LOCAL_LDFLAGS) -lpthread $(LDFLAGS) -o $@ + +ssl/ssl_mail_client$(EXEXT): ssl/ssl_mail_client.c $(DEP) + echo " CC ssl/ssl_mail_client.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_mail_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +ssl/mini_client$(EXEXT): ssl/mini_client.c $(DEP) + echo " CC ssl/mini_client.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/mini_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +test/ssl_cert_test$(EXEXT): test/ssl_cert_test.c $(DEP) + echo " CC test/ssl_cert_test.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/ssl_cert_test.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +test/benchmark$(EXEXT): test/benchmark.c $(DEP) + echo " CC test/benchmark.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/benchmark.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +test/selftest$(EXEXT): test/selftest.c $(DEP) + echo " CC test/selftest.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/selftest.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +test/udp_proxy$(EXEXT): test/udp_proxy.c $(DEP) + echo " CC test/udp_proxy.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/udp_proxy.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +util/pem2der$(EXEXT): util/pem2der.c $(DEP) + echo " CC util/pem2der.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) util/pem2der.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +util/strerror$(EXEXT): util/strerror.c $(DEP) + echo " CC util/strerror.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) util/strerror.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +x509/cert_app$(EXEXT): x509/cert_app.c $(DEP) + echo " CC x509/cert_app.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +x509/cert_write$(EXEXT): x509/cert_write.c $(DEP) + echo " CC x509/cert_write.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_write.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +x509/crl_app$(EXEXT): x509/crl_app.c $(DEP) + echo " CC x509/crl_app.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/crl_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +x509/cert_req$(EXEXT): x509/cert_req.c $(DEP) + echo " CC x509/cert_req.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_req.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +x509/req_app$(EXEXT): x509/req_app.c $(DEP) + echo " CC x509/req_app.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/req_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +clean: +ifndef WINDOWS + rm -f $(APPS) +else + del /S /Q /F *.o *.exe +endif + +list: + echo $(APPS) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/CMakeLists.txt new file mode 100644 index 0000000..f5a0caa --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(aescrypt2 aescrypt2.c) +target_link_libraries(aescrypt2 mbedtls) + +add_executable(crypt_and_hash crypt_and_hash.c) +target_link_libraries(crypt_and_hash mbedtls) + +install(TARGETS aescrypt2 crypt_and_hash + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/aescrypt2.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/aescrypt2.c new file mode 100644 index 0000000..c77d77f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/aescrypt2.c @@ -0,0 +1,452 @@ +/* + * AES-256 file encryption program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#include "mbedtls/aes.h" +#include "mbedtls/md.h" + +#include +#include +#include + +#if defined(_WIN32) +#include +#if !defined(_WIN32_WCE) +#include +#endif +#else +#include +#include +#endif + +#define MODE_ENCRYPT 0 +#define MODE_DECRYPT 1 + +#define USAGE \ + "\n aescrypt2 \n" \ + "\n : 0 = encrypt, 1 = decrypt\n" \ + "\n example: aescrypt2 0 file file.aes hex:E76B2413958B00E193\n" \ + "\n" + +#if !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_MD_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_SHA256_C " + "and/or MBEDTLS_FS_IO and/or MBEDTLS_MD_C " + "not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + int ret = 1; + + unsigned int i, n; + int mode, lastn; + size_t keylen; + FILE *fkey, *fin = NULL, *fout = NULL; + + char *p; + unsigned char IV[16]; + unsigned char key[512]; + unsigned char digest[32]; + unsigned char buffer[1024]; + unsigned char diff; + + mbedtls_aes_context aes_ctx; + mbedtls_md_context_t sha_ctx; + +#if defined(_WIN32_WCE) + long filesize, offset; +#elif defined(_WIN32) + LARGE_INTEGER li_size; + __int64 filesize, offset; +#else + off_t filesize, offset; +#endif + + mbedtls_aes_init( &aes_ctx ); + mbedtls_md_init( &sha_ctx ); + + ret = mbedtls_md_setup( &sha_ctx, mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), 1 ); + if( ret != 0 ) + { + mbedtls_printf( " ! mbedtls_md_setup() returned -0x%04x\n", -ret ); + goto exit; + } + + /* + * Parse the command-line arguments. + */ + if( argc != 5 ) + { + mbedtls_printf( USAGE ); + +#if defined(_WIN32) + mbedtls_printf( "\n Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + goto exit; + } + + mode = atoi( argv[1] ); + memset(IV, 0, sizeof(IV)); + memset(key, 0, sizeof(key)); + memset(digest, 0, sizeof(digest)); + memset(buffer, 0, sizeof(buffer)); + + if( mode != MODE_ENCRYPT && mode != MODE_DECRYPT ) + { + mbedtls_fprintf( stderr, "invalide operation mode\n" ); + goto exit; + } + + if( strcmp( argv[2], argv[3] ) == 0 ) + { + mbedtls_fprintf( stderr, "input and output filenames must differ\n" ); + goto exit; + } + + if( ( fin = fopen( argv[2], "rb" ) ) == NULL ) + { + mbedtls_fprintf( stderr, "fopen(%s,rb) failed\n", argv[2] ); + goto exit; + } + + if( ( fout = fopen( argv[3], "wb+" ) ) == NULL ) + { + mbedtls_fprintf( stderr, "fopen(%s,wb+) failed\n", argv[3] ); + goto exit; + } + + /* + * Read the secret key and clean the command line. + */ + if( ( fkey = fopen( argv[4], "rb" ) ) != NULL ) + { + keylen = fread( key, 1, sizeof( key ), fkey ); + fclose( fkey ); + } + else + { + if( memcmp( argv[4], "hex:", 4 ) == 0 ) + { + p = &argv[4][4]; + keylen = 0; + + while( sscanf( p, "%02X", &n ) > 0 && + keylen < (int) sizeof( key ) ) + { + key[keylen++] = (unsigned char) n; + p += 2; + } + } + else + { + keylen = strlen( argv[4] ); + + if( keylen > (int) sizeof( key ) ) + keylen = (int) sizeof( key ); + + memcpy( key, argv[4], keylen ); + } + } + + memset( argv[4], 0, strlen( argv[4] ) ); + +#if defined(_WIN32_WCE) + filesize = fseek( fin, 0L, SEEK_END ); +#else +#if defined(_WIN32) + /* + * Support large files (> 2Gb) on Win32 + */ + li_size.QuadPart = 0; + li_size.LowPart = + SetFilePointer( (HANDLE) _get_osfhandle( _fileno( fin ) ), + li_size.LowPart, &li_size.HighPart, FILE_END ); + + if( li_size.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR ) + { + mbedtls_fprintf( stderr, "SetFilePointer(0,FILE_END) failed\n" ); + goto exit; + } + + filesize = li_size.QuadPart; +#else + if( ( filesize = lseek( fileno( fin ), 0, SEEK_END ) ) < 0 ) + { + perror( "lseek" ); + goto exit; + } +#endif +#endif + + if( fseek( fin, 0, SEEK_SET ) < 0 ) + { + mbedtls_fprintf( stderr, "fseek(0,SEEK_SET) failed\n" ); + goto exit; + } + + if( mode == MODE_ENCRYPT ) + { + /* + * Generate the initialization vector as: + * IV = SHA-256( filesize || filename )[0..15] + */ + for( i = 0; i < 8; i++ ) + buffer[i] = (unsigned char)( filesize >> ( i << 3 ) ); + + p = argv[2]; + + mbedtls_md_starts( &sha_ctx ); + mbedtls_md_update( &sha_ctx, buffer, 8 ); + mbedtls_md_update( &sha_ctx, (unsigned char *) p, strlen( p ) ); + mbedtls_md_finish( &sha_ctx, digest ); + + memcpy( IV, digest, 16 ); + + /* + * The last four bits in the IV are actually used + * to store the file size modulo the AES block size. + */ + lastn = (int)( filesize & 0x0F ); + + IV[15] = (unsigned char) + ( ( IV[15] & 0xF0 ) | lastn ); + + /* + * Append the IV at the beginning of the output. + */ + if( fwrite( IV, 1, 16, fout ) != 16 ) + { + mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); + goto exit; + } + + /* + * Hash the IV and the secret key together 8192 times + * using the result to setup the AES context and HMAC. + */ + memset( digest, 0, 32 ); + memcpy( digest, IV, 16 ); + + for( i = 0; i < 8192; i++ ) + { + mbedtls_md_starts( &sha_ctx ); + mbedtls_md_update( &sha_ctx, digest, 32 ); + mbedtls_md_update( &sha_ctx, key, keylen ); + mbedtls_md_finish( &sha_ctx, digest ); + } + + memset( key, 0, sizeof( key ) ); + mbedtls_aes_setkey_enc( &aes_ctx, digest, 256 ); + mbedtls_md_hmac_starts( &sha_ctx, digest, 32 ); + + /* + * Encrypt and write the ciphertext. + */ + for( offset = 0; offset < filesize; offset += 16 ) + { + n = ( filesize - offset > 16 ) ? 16 : (int) + ( filesize - offset ); + + if( fread( buffer, 1, n, fin ) != (size_t) n ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", n ); + goto exit; + } + + for( i = 0; i < 16; i++ ) + buffer[i] = (unsigned char)( buffer[i] ^ IV[i] ); + + mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, buffer, buffer ); + mbedtls_md_hmac_update( &sha_ctx, buffer, 16 ); + + if( fwrite( buffer, 1, 16, fout ) != 16 ) + { + mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); + goto exit; + } + + memcpy( IV, buffer, 16 ); + } + + /* + * Finally write the HMAC. + */ + mbedtls_md_hmac_finish( &sha_ctx, digest ); + + if( fwrite( digest, 1, 32, fout ) != 32 ) + { + mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); + goto exit; + } + } + + if( mode == MODE_DECRYPT ) + { + unsigned char tmp[16]; + + /* + * The encrypted file must be structured as follows: + * + * 00 .. 15 Initialization Vector + * 16 .. 31 AES Encrypted Block #1 + * .. + * N*16 .. (N+1)*16 - 1 AES Encrypted Block #N + * (N+1)*16 .. (N+1)*16 + 32 HMAC-SHA-256(ciphertext) + */ + if( filesize < 48 ) + { + mbedtls_fprintf( stderr, "File too short to be encrypted.\n" ); + goto exit; + } + + if( ( filesize & 0x0F ) != 0 ) + { + mbedtls_fprintf( stderr, "File size not a multiple of 16.\n" ); + goto exit; + } + + /* + * Subtract the IV + HMAC length. + */ + filesize -= ( 16 + 32 ); + + /* + * Read the IV and original filesize modulo 16. + */ + if( fread( buffer, 1, 16, fin ) != 16 ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", 16 ); + goto exit; + } + + memcpy( IV, buffer, 16 ); + lastn = IV[15] & 0x0F; + + /* + * Hash the IV and the secret key together 8192 times + * using the result to setup the AES context and HMAC. + */ + memset( digest, 0, 32 ); + memcpy( digest, IV, 16 ); + + for( i = 0; i < 8192; i++ ) + { + mbedtls_md_starts( &sha_ctx ); + mbedtls_md_update( &sha_ctx, digest, 32 ); + mbedtls_md_update( &sha_ctx, key, keylen ); + mbedtls_md_finish( &sha_ctx, digest ); + } + + memset( key, 0, sizeof( key ) ); + mbedtls_aes_setkey_dec( &aes_ctx, digest, 256 ); + mbedtls_md_hmac_starts( &sha_ctx, digest, 32 ); + + /* + * Decrypt and write the plaintext. + */ + for( offset = 0; offset < filesize; offset += 16 ) + { + if( fread( buffer, 1, 16, fin ) != 16 ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", 16 ); + goto exit; + } + + memcpy( tmp, buffer, 16 ); + + mbedtls_md_hmac_update( &sha_ctx, buffer, 16 ); + mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_DECRYPT, buffer, buffer ); + + for( i = 0; i < 16; i++ ) + buffer[i] = (unsigned char)( buffer[i] ^ IV[i] ); + + memcpy( IV, tmp, 16 ); + + n = ( lastn > 0 && offset == filesize - 16 ) + ? lastn : 16; + + if( fwrite( buffer, 1, n, fout ) != (size_t) n ) + { + mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", n ); + goto exit; + } + } + + /* + * Verify the message authentication code. + */ + mbedtls_md_hmac_finish( &sha_ctx, digest ); + + if( fread( buffer, 1, 32, fin ) != 32 ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", 32 ); + goto exit; + } + + /* Use constant-time buffer comparison */ + diff = 0; + for( i = 0; i < 32; i++ ) + diff |= digest[i] ^ buffer[i]; + + if( diff != 0 ) + { + mbedtls_fprintf( stderr, "HMAC check failed: wrong key, " + "or file corrupted.\n" ); + goto exit; + } + } + + ret = 0; + +exit: + if( fin ) + fclose( fin ); + if( fout ) + fclose( fout ); + + memset( buffer, 0, sizeof( buffer ) ); + memset( digest, 0, sizeof( digest ) ); + + mbedtls_aes_free( &aes_ctx ); + mbedtls_md_free( &sha_ctx ); + + return( ret ); +} +#endif /* MBEDTLS_AES_C && MBEDTLS_SHA256_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/crypt_and_hash.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/crypt_and_hash.c new file mode 100644 index 0000000..adb95e0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/aes/crypt_and_hash.c @@ -0,0 +1,551 @@ +/* + * \brief Generic file encryption program using generic wrappers for configured + * security. + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_CIPHER_C) && defined(MBEDTLS_MD_C) && \ + defined(MBEDTLS_FS_IO) +#include "mbedtls/cipher.h" +#include "mbedtls/md.h" + +#include +#include +#include +#endif + +#if defined(_WIN32) +#include +#if !defined(_WIN32_WCE) +#include +#endif +#else +#include +#include +#endif + +#define MODE_ENCRYPT 0 +#define MODE_DECRYPT 1 + +#define USAGE \ + "\n crypt_and_hash \n" \ + "\n : 0 = encrypt, 1 = decrypt\n" \ + "\n example: crypt_and_hash 0 file file.aes AES-128-CBC SHA1 hex:E76B2413958B00E193\n" \ + "\n" + +#if !defined(MBEDTLS_CIPHER_C) || !defined(MBEDTLS_MD_C) || \ + !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_CIPHER_C and/or MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + int ret = 1, i, n; + int mode; + size_t keylen, ilen, olen; + FILE *fkey, *fin = NULL, *fout = NULL; + + char *p; + unsigned char IV[16]; + unsigned char key[512]; + unsigned char digest[MBEDTLS_MD_MAX_SIZE]; + unsigned char buffer[1024]; + unsigned char output[1024]; + unsigned char diff; + + const mbedtls_cipher_info_t *cipher_info; + const mbedtls_md_info_t *md_info; + mbedtls_cipher_context_t cipher_ctx; + mbedtls_md_context_t md_ctx; +#if defined(_WIN32_WCE) + long filesize, offset; +#elif defined(_WIN32) + LARGE_INTEGER li_size; + __int64 filesize, offset; +#else + off_t filesize, offset; +#endif + + mbedtls_cipher_init( &cipher_ctx ); + mbedtls_md_init( &md_ctx ); + + /* + * Parse the command-line arguments. + */ + if( argc != 7 ) + { + const int *list; + + mbedtls_printf( USAGE ); + + mbedtls_printf( "Available ciphers:\n" ); + list = mbedtls_cipher_list(); + while( *list ) + { + cipher_info = mbedtls_cipher_info_from_type( *list ); + mbedtls_printf( " %s\n", cipher_info->name ); + list++; + } + + mbedtls_printf( "\nAvailable message digests:\n" ); + list = mbedtls_md_list(); + while( *list ) + { + md_info = mbedtls_md_info_from_type( *list ); + mbedtls_printf( " %s\n", mbedtls_md_get_name( md_info ) ); + list++; + } + +#if defined(_WIN32) + mbedtls_printf( "\n Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + goto exit; + } + + mode = atoi( argv[1] ); + + if( mode != MODE_ENCRYPT && mode != MODE_DECRYPT ) + { + mbedtls_fprintf( stderr, "invalid operation mode\n" ); + goto exit; + } + + if( strcmp( argv[2], argv[3] ) == 0 ) + { + mbedtls_fprintf( stderr, "input and output filenames must differ\n" ); + goto exit; + } + + if( ( fin = fopen( argv[2], "rb" ) ) == NULL ) + { + mbedtls_fprintf( stderr, "fopen(%s,rb) failed\n", argv[2] ); + goto exit; + } + + if( ( fout = fopen( argv[3], "wb+" ) ) == NULL ) + { + mbedtls_fprintf( stderr, "fopen(%s,wb+) failed\n", argv[3] ); + goto exit; + } + + /* + * Read the Cipher and MD from the command line + */ + cipher_info = mbedtls_cipher_info_from_string( argv[4] ); + if( cipher_info == NULL ) + { + mbedtls_fprintf( stderr, "Cipher '%s' not found\n", argv[4] ); + goto exit; + } + if( ( ret = mbedtls_cipher_setup( &cipher_ctx, cipher_info) ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_setup failed\n" ); + goto exit; + } + + md_info = mbedtls_md_info_from_string( argv[5] ); + if( md_info == NULL ) + { + mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[5] ); + goto exit; + } + + if( mbedtls_md_setup( &md_ctx, md_info, 1 ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_md_setup failed\n" ); + goto exit; + } + + /* + * Read the secret key and clean the command line. + */ + if( ( fkey = fopen( argv[6], "rb" ) ) != NULL ) + { + keylen = fread( key, 1, sizeof( key ), fkey ); + fclose( fkey ); + } + else + { + if( memcmp( argv[6], "hex:", 4 ) == 0 ) + { + p = &argv[6][4]; + keylen = 0; + + while( sscanf( p, "%02X", &n ) > 0 && + keylen < (int) sizeof( key ) ) + { + key[keylen++] = (unsigned char) n; + p += 2; + } + } + else + { + keylen = strlen( argv[6] ); + + if( keylen > (int) sizeof( key ) ) + keylen = (int) sizeof( key ); + + memcpy( key, argv[6], keylen ); + } + } + + memset( argv[6], 0, strlen( argv[6] ) ); + +#if defined(_WIN32_WCE) + filesize = fseek( fin, 0L, SEEK_END ); +#else +#if defined(_WIN32) + /* + * Support large files (> 2Gb) on Win32 + */ + li_size.QuadPart = 0; + li_size.LowPart = + SetFilePointer( (HANDLE) _get_osfhandle( _fileno( fin ) ), + li_size.LowPart, &li_size.HighPart, FILE_END ); + + if( li_size.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR ) + { + mbedtls_fprintf( stderr, "SetFilePointer(0,FILE_END) failed\n" ); + goto exit; + } + + filesize = li_size.QuadPart; +#else + if( ( filesize = lseek( fileno( fin ), 0, SEEK_END ) ) < 0 ) + { + perror( "lseek" ); + goto exit; + } +#endif +#endif + + if( fseek( fin, 0, SEEK_SET ) < 0 ) + { + mbedtls_fprintf( stderr, "fseek(0,SEEK_SET) failed\n" ); + goto exit; + } + + if( mode == MODE_ENCRYPT ) + { + /* + * Generate the initialization vector as: + * IV = MD( filesize || filename )[0..15] + */ + for( i = 0; i < 8; i++ ) + buffer[i] = (unsigned char)( filesize >> ( i << 3 ) ); + + p = argv[2]; + + mbedtls_md_starts( &md_ctx ); + mbedtls_md_update( &md_ctx, buffer, 8 ); + mbedtls_md_update( &md_ctx, (unsigned char *) p, strlen( p ) ); + mbedtls_md_finish( &md_ctx, digest ); + + memcpy( IV, digest, 16 ); + + /* + * Append the IV at the beginning of the output. + */ + if( fwrite( IV, 1, 16, fout ) != 16 ) + { + mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); + goto exit; + } + + /* + * Hash the IV and the secret key together 8192 times + * using the result to setup the AES context and HMAC. + */ + memset( digest, 0, 32 ); + memcpy( digest, IV, 16 ); + + for( i = 0; i < 8192; i++ ) + { + mbedtls_md_starts( &md_ctx ); + mbedtls_md_update( &md_ctx, digest, 32 ); + mbedtls_md_update( &md_ctx, key, keylen ); + mbedtls_md_finish( &md_ctx, digest ); + + } + + memset( key, 0, sizeof( key ) ); + + if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->key_bitlen, + MBEDTLS_ENCRYPT ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n"); + goto exit; + } + if( mbedtls_cipher_set_iv( &cipher_ctx, IV, 16 ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_set_iv() returned error\n"); + goto exit; + } + if( mbedtls_cipher_reset( &cipher_ctx ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_reset() returned error\n"); + goto exit; + } + + mbedtls_md_hmac_starts( &md_ctx, digest, 32 ); + + /* + * Encrypt and write the ciphertext. + */ + for( offset = 0; offset < filesize; offset += mbedtls_cipher_get_block_size( &cipher_ctx ) ) + { + ilen = ( (unsigned int) filesize - offset > mbedtls_cipher_get_block_size( &cipher_ctx ) ) ? + mbedtls_cipher_get_block_size( &cipher_ctx ) : (unsigned int) ( filesize - offset ); + + if( fread( buffer, 1, ilen, fin ) != ilen ) + { + mbedtls_fprintf( stderr, "fread(%ld bytes) failed\n", (long) ilen ); + goto exit; + } + + if( mbedtls_cipher_update( &cipher_ctx, buffer, ilen, output, &olen ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_update() returned error\n"); + goto exit; + } + + mbedtls_md_hmac_update( &md_ctx, output, olen ); + + if( fwrite( output, 1, olen, fout ) != olen ) + { + mbedtls_fprintf( stderr, "fwrite(%ld bytes) failed\n", (long) olen ); + goto exit; + } + } + + if( mbedtls_cipher_finish( &cipher_ctx, output, &olen ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_finish() returned error\n" ); + goto exit; + } + mbedtls_md_hmac_update( &md_ctx, output, olen ); + + if( fwrite( output, 1, olen, fout ) != olen ) + { + mbedtls_fprintf( stderr, "fwrite(%ld bytes) failed\n", (long) olen ); + goto exit; + } + + /* + * Finally write the HMAC. + */ + mbedtls_md_hmac_finish( &md_ctx, digest ); + + if( fwrite( digest, 1, mbedtls_md_get_size( md_info ), fout ) != mbedtls_md_get_size( md_info ) ) + { + mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", mbedtls_md_get_size( md_info ) ); + goto exit; + } + } + + if( mode == MODE_DECRYPT ) + { + /* + * The encrypted file must be structured as follows: + * + * 00 .. 15 Initialization Vector + * 16 .. 31 Encrypted Block #1 + * .. + * N*16 .. (N+1)*16 - 1 Encrypted Block #N + * (N+1)*16 .. (N+1)*16 + n Hash(ciphertext) + */ + if( filesize < 16 + mbedtls_md_get_size( md_info ) ) + { + mbedtls_fprintf( stderr, "File too short to be encrypted.\n" ); + goto exit; + } + + if( mbedtls_cipher_get_block_size( &cipher_ctx ) == 0 ) + { + mbedtls_fprintf( stderr, "Invalid cipher block size: 0. \n" ); + goto exit; + } + + /* + * Check the file size. + */ + if( cipher_info->mode != MBEDTLS_MODE_GCM && + ( ( filesize - mbedtls_md_get_size( md_info ) ) % + mbedtls_cipher_get_block_size( &cipher_ctx ) ) != 0 ) + { + mbedtls_fprintf( stderr, "File content not a multiple of the block size (%d).\n", + mbedtls_cipher_get_block_size( &cipher_ctx )); + goto exit; + } + + /* + * Subtract the IV + HMAC length. + */ + filesize -= ( 16 + mbedtls_md_get_size( md_info ) ); + + /* + * Read the IV and original filesize modulo 16. + */ + if( fread( buffer, 1, 16, fin ) != 16 ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", 16 ); + goto exit; + } + + memcpy( IV, buffer, 16 ); + + /* + * Hash the IV and the secret key together 8192 times + * using the result to setup the AES context and HMAC. + */ + memset( digest, 0, 32 ); + memcpy( digest, IV, 16 ); + + for( i = 0; i < 8192; i++ ) + { + mbedtls_md_starts( &md_ctx ); + mbedtls_md_update( &md_ctx, digest, 32 ); + mbedtls_md_update( &md_ctx, key, keylen ); + mbedtls_md_finish( &md_ctx, digest ); + } + + memset( key, 0, sizeof( key ) ); + + if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->key_bitlen, + MBEDTLS_DECRYPT ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n" ); + goto exit; + } + + if( mbedtls_cipher_set_iv( &cipher_ctx, IV, 16 ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_set_iv() returned error\n" ); + goto exit; + } + + if( mbedtls_cipher_reset( &cipher_ctx ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_reset() returned error\n" ); + goto exit; + } + + mbedtls_md_hmac_starts( &md_ctx, digest, 32 ); + + /* + * Decrypt and write the plaintext. + */ + for( offset = 0; offset < filesize; offset += mbedtls_cipher_get_block_size( &cipher_ctx ) ) + { + ilen = ( (unsigned int) filesize - offset > mbedtls_cipher_get_block_size( &cipher_ctx ) ) ? + mbedtls_cipher_get_block_size( &cipher_ctx ) : (unsigned int) ( filesize - offset ); + + if( fread( buffer, 1, ilen, fin ) != ilen ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", + mbedtls_cipher_get_block_size( &cipher_ctx ) ); + goto exit; + } + + mbedtls_md_hmac_update( &md_ctx, buffer, ilen ); + if( mbedtls_cipher_update( &cipher_ctx, buffer, ilen, output, + &olen ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_update() returned error\n" ); + goto exit; + } + + if( fwrite( output, 1, olen, fout ) != olen ) + { + mbedtls_fprintf( stderr, "fwrite(%ld bytes) failed\n", (long) olen ); + goto exit; + } + } + + /* + * Verify the message authentication code. + */ + mbedtls_md_hmac_finish( &md_ctx, digest ); + + if( fread( buffer, 1, mbedtls_md_get_size( md_info ), fin ) != mbedtls_md_get_size( md_info ) ) + { + mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", mbedtls_md_get_size( md_info ) ); + goto exit; + } + + /* Use constant-time buffer comparison */ + diff = 0; + for( i = 0; i < mbedtls_md_get_size( md_info ); i++ ) + diff |= digest[i] ^ buffer[i]; + + if( diff != 0 ) + { + mbedtls_fprintf( stderr, "HMAC check failed: wrong key, " + "or file corrupted.\n" ); + goto exit; + } + + /* + * Write the final block of data + */ + mbedtls_cipher_finish( &cipher_ctx, output, &olen ); + + if( fwrite( output, 1, olen, fout ) != olen ) + { + mbedtls_fprintf( stderr, "fwrite(%ld bytes) failed\n", (long) olen ); + goto exit; + } + } + + ret = 0; + +exit: + if( fin ) + fclose( fin ); + if( fout ) + fclose( fout ); + + memset( buffer, 0, sizeof( buffer ) ); + memset( digest, 0, sizeof( digest ) ); + + mbedtls_cipher_free( &cipher_ctx ); + mbedtls_md_free( &md_ctx ); + + return( ret ); +} +#endif /* MBEDTLS_CIPHER_C && MBEDTLS_MD_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/CMakeLists.txt new file mode 100644 index 0000000..eda975b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(hello hello.c) +target_link_libraries(hello mbedtls) + +add_executable(generic_sum generic_sum.c) +target_link_libraries(generic_sum mbedtls) + +install(TARGETS hello generic_sum + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/generic_sum.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/generic_sum.c new file mode 100644 index 0000000..d1e81d4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/generic_sum.c @@ -0,0 +1,232 @@ +/* + * generic message digest layer demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_MD_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/md.h" + +#include +#include +#endif + +#if !defined(MBEDTLS_MD_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +static int generic_wrapper( const mbedtls_md_info_t *md_info, char *filename, unsigned char *sum ) +{ + int ret = mbedtls_md_file( md_info, filename, sum ); + + if( ret == 1 ) + mbedtls_fprintf( stderr, "failed to open: %s\n", filename ); + + if( ret == 2 ) + mbedtls_fprintf( stderr, "failed to read: %s\n", filename ); + + return( ret ); +} + +static int generic_print( const mbedtls_md_info_t *md_info, char *filename ) +{ + int i; + unsigned char sum[MBEDTLS_MD_MAX_SIZE]; + + if( generic_wrapper( md_info, filename, sum ) != 0 ) + return( 1 ); + + for( i = 0; i < mbedtls_md_get_size( md_info ); i++ ) + mbedtls_printf( "%02x", sum[i] ); + + mbedtls_printf( " %s\n", filename ); + return( 0 ); +} + +static int generic_check( const mbedtls_md_info_t *md_info, char *filename ) +{ + int i; + size_t n; + FILE *f; + int nb_err1, nb_err2; + int nb_tot1, nb_tot2; + unsigned char sum[MBEDTLS_MD_MAX_SIZE]; + char line[1024]; + char diff; +#if defined(__clang_analyzer__) + char buf[MBEDTLS_MD_MAX_SIZE * 2 + 1] = { }; +#else + char buf[MBEDTLS_MD_MAX_SIZE * 2 + 1]; +#endif + + if( ( f = fopen( filename, "rb" ) ) == NULL ) + { + mbedtls_printf( "failed to open: %s\n", filename ); + return( 1 ); + } + + nb_err1 = nb_err2 = 0; + nb_tot1 = nb_tot2 = 0; + + memset( line, 0, sizeof( line ) ); + + n = sizeof( line ); + + while( fgets( line, (int) n - 1, f ) != NULL ) + { + n = strlen( line ); + + if( n < (size_t) 2 * mbedtls_md_get_size( md_info ) + 4 ) + { + mbedtls_printf("No '%s' hash found on line.\n", mbedtls_md_get_name( md_info )); + continue; + } + + if( line[2 * mbedtls_md_get_size( md_info )] != ' ' || line[2 * mbedtls_md_get_size( md_info ) + 1] != ' ' ) + { + mbedtls_printf("No '%s' hash found on line.\n", mbedtls_md_get_name( md_info )); + continue; + } + + if( line[n - 1] == '\n' ) { n--; line[n] = '\0'; } + if( line[n - 1] == '\r' ) { n--; line[n] = '\0'; } + + nb_tot1++; + + if( generic_wrapper( md_info, line + 2 + 2 * mbedtls_md_get_size( md_info ), sum ) != 0 ) + { + nb_err1++; + continue; + } + + nb_tot2++; + + for( i = 0; i < mbedtls_md_get_size( md_info ); i++ ) + sprintf( buf + i * 2, "%02x", sum[i] ); + + /* Use constant-time buffer comparison */ + diff = 0; + for( i = 0; i < 2 * mbedtls_md_get_size( md_info ); i++ ) + diff |= line[i] ^ buf[i]; + + if( diff != 0 ) + { + nb_err2++; + mbedtls_fprintf( stderr, "wrong checksum: %s\n", line + 66 ); + } + + n = sizeof( line ); + } + + if( nb_err1 != 0 ) + { + mbedtls_printf( "WARNING: %d (out of %d) input files could " + "not be read\n", nb_err1, nb_tot1 ); + } + + if( nb_err2 != 0 ) + { + mbedtls_printf( "WARNING: %d (out of %d) computed checksums did " + "not match\n", nb_err2, nb_tot2 ); + } + + fclose( f ); + + return( nb_err1 != 0 || nb_err2 != 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret, i; + const mbedtls_md_info_t *md_info; + mbedtls_md_context_t md_ctx; + + mbedtls_md_init( &md_ctx ); + + if( argc == 1 ) + { + const int *list; + + mbedtls_printf( "print mode: generic_sum ...\n" ); + mbedtls_printf( "check mode: generic_sum -c \n" ); + + mbedtls_printf( "\nAvailable message digests:\n" ); + list = mbedtls_md_list(); + while( *list ) + { + md_info = mbedtls_md_info_from_type( *list ); + mbedtls_printf( " %s\n", mbedtls_md_get_name( md_info ) ); + list++; + } + +#if defined(_WIN32) + mbedtls_printf( "\n Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( 1 ); + } + + /* + * Read the MD from the command line + */ + md_info = mbedtls_md_info_from_string( argv[1] ); + if( md_info == NULL ) + { + mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] ); + return( 1 ); + } + if( mbedtls_md_setup( &md_ctx, md_info, 0 ) ) + { + mbedtls_fprintf( stderr, "Failed to initialize context.\n" ); + return( 1 ); + } + + ret = 0; + if( argc == 4 && strcmp( "-c", argv[2] ) == 0 ) + { + ret |= generic_check( md_info, argv[3] ); + goto exit; + } + + for( i = 2; i < argc; i++ ) + ret |= generic_print( md_info, argv[i] ); + +exit: + mbedtls_md_free( &md_ctx ); + + return( ret ); +} +#endif /* MBEDTLS_MD_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/hello.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/hello.c new file mode 100644 index 0000000..df420f2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/hash/hello.c @@ -0,0 +1,68 @@ +/* + * Classic "Hello, world" demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_MD5_C) +#include "mbedtls/md5.h" +#endif + +#if !defined(MBEDTLS_MD5_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_MD5_C not defined.\n"); + return( 0 ); +} +#else +int main( void ) +{ + int i; + unsigned char digest[16]; + char str[] = "Hello, world!"; + + mbedtls_printf( "\n MD5('%s') = ", str ); + + mbedtls_md5( (unsigned char *) str, 13, digest ); + + for( i = 0; i < 16; i++ ) + mbedtls_printf( "%02x", digest[i] ); + + mbedtls_printf( "\n\n" ); + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( 0 ); +} +#endif /* MBEDTLS_MD5_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/CMakeLists.txt new file mode 100644 index 0000000..5a37a42 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/CMakeLists.txt @@ -0,0 +1,63 @@ +add_executable(dh_client dh_client.c) +target_link_libraries(dh_client mbedtls) + +add_executable(dh_genprime dh_genprime.c) +target_link_libraries(dh_genprime mbedtls) + +add_executable(dh_server dh_server.c) +target_link_libraries(dh_server mbedtls) + +add_executable(ecdh_curve25519 ecdh_curve25519.c) +target_link_libraries(ecdh_curve25519 mbedtls) + +add_executable(ecdsa ecdsa.c) +target_link_libraries(ecdsa mbedtls) + +add_executable(gen_key gen_key.c) +target_link_libraries(gen_key mbedtls) + +add_executable(key_app key_app.c) +target_link_libraries(key_app mbedtls) + +add_executable(key_app_writer key_app_writer.c) +target_link_libraries(key_app_writer mbedtls) + +add_executable(mpi_demo mpi_demo.c) +target_link_libraries(mpi_demo mbedtls) + +add_executable(rsa_genkey rsa_genkey.c) +target_link_libraries(rsa_genkey mbedtls) + +add_executable(rsa_sign rsa_sign.c) +target_link_libraries(rsa_sign mbedtls) + +add_executable(rsa_verify rsa_verify.c) +target_link_libraries(rsa_verify mbedtls) + +add_executable(rsa_sign_pss rsa_sign_pss.c) +target_link_libraries(rsa_sign_pss mbedtls) + +add_executable(rsa_verify_pss rsa_verify_pss.c) +target_link_libraries(rsa_verify_pss mbedtls) + +add_executable(rsa_encrypt rsa_encrypt.c) +target_link_libraries(rsa_encrypt mbedtls) + +add_executable(rsa_decrypt rsa_decrypt.c) +target_link_libraries(rsa_decrypt mbedtls) + +add_executable(pk_sign pk_sign.c) +target_link_libraries(pk_sign mbedtls) + +add_executable(pk_verify pk_verify.c) +target_link_libraries(pk_verify mbedtls) + +add_executable(pk_encrypt pk_encrypt.c) +target_link_libraries(pk_encrypt mbedtls) + +add_executable(pk_decrypt pk_decrypt.c) +target_link_libraries(pk_decrypt mbedtls) + +install(TARGETS dh_client dh_genprime dh_server key_app mpi_demo rsa_genkey rsa_sign rsa_verify rsa_encrypt rsa_decrypt pk_encrypt pk_decrypt pk_sign pk_verify gen_key + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_client.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_client.c new file mode 100644 index 0000000..875d0b0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_client.c @@ -0,0 +1,304 @@ +/* + * Diffie-Hellman-Merkle key exchange (client side) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define mbedtls_time_t time_t +#endif + +#if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \ + defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \ + defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) && \ + defined(MBEDTLS_FS_IO) && defined(MBEDTLS_CTR_DRBG_C) && \ + defined(MBEDTLS_SHA1_C) +#include "mbedtls/net_sockets.h" +#include "mbedtls/aes.h" +#include "mbedtls/dhm.h" +#include "mbedtls/rsa.h" +#include "mbedtls/sha1.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include +#endif + +#define SERVER_NAME "localhost" +#define SERVER_PORT "11999" + +#if !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_DHM_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NET_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_SHA1_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_DHM_C and/or MBEDTLS_ENTROPY_C " + "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( void ) +{ + FILE *f; + + int ret; + size_t n, buflen; + mbedtls_net_context server_fd; + + unsigned char *p, *end; + unsigned char buf[2048]; + unsigned char hash[32]; + const char *pers = "dh_client"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_rsa_context rsa; + mbedtls_dhm_context dhm; + mbedtls_aes_context aes; + + mbedtls_net_init( &server_fd ); + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_SHA256 ); + mbedtls_dhm_init( &dhm ); + mbedtls_aes_init( &aes ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + /* + * 1. Setup the RNG + */ + mbedtls_printf( "\n . Seeding the random number generator" ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + /* + * 2. Read the server's public RSA key + */ + mbedtls_printf( "\n . Reading public key from rsa_pub.txt" ); + fflush( stdout ); + + if( ( f = fopen( "rsa_pub.txt", "rb" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not open rsa_pub.txt\n" \ + " ! Please run rsa_genkey first\n\n" ); + goto exit; + } + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + + if( ( ret = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret ); + fclose( f ); + goto exit; + } + + rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + + fclose( f ); + + /* + * 3. Initiate the connection + */ + mbedtls_printf( "\n . Connecting to tcp/%s/%s", SERVER_NAME, + SERVER_PORT ); + fflush( stdout ); + + if( ( ret = mbedtls_net_connect( &server_fd, SERVER_NAME, + SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret ); + goto exit; + } + + /* + * 4a. First get the buffer length + */ + mbedtls_printf( "\n . Receiving the server's DH parameters" ); + fflush( stdout ); + + memset( buf, 0, sizeof( buf ) ); + + if( ( ret = mbedtls_net_recv( &server_fd, buf, 2 ) ) != 2 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret ); + goto exit; + } + + n = buflen = ( buf[0] << 8 ) | buf[1]; + if( buflen < 1 || buflen > sizeof( buf ) ) + { + mbedtls_printf( " failed\n ! Got an invalid buffer length\n\n" ); + goto exit; + } + + /* + * 4b. Get the DHM parameters: P, G and Ys = G^Xs mod P + */ + memset( buf, 0, sizeof( buf ) ); + + if( ( ret = mbedtls_net_recv( &server_fd, buf, n ) ) != (int) n ) + { + mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret ); + goto exit; + } + + p = buf, end = buf + buflen; + + if( ( ret = mbedtls_dhm_read_params( &dhm, &p, end ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_read_params returned %d\n\n", ret ); + goto exit; + } + + if( dhm.len < 64 || dhm.len > 512 ) + { + ret = 1; + mbedtls_printf( " failed\n ! Invalid DHM modulus size\n\n" ); + goto exit; + } + + /* + * 5. Check that the server's RSA signature matches + * the SHA-256 hash of (P,G,Ys) + */ + mbedtls_printf( "\n . Verifying the server's RSA signature" ); + fflush( stdout ); + + p += 2; + + if( ( n = (size_t) ( end - p ) ) != rsa.len ) + { + ret = 1; + mbedtls_printf( " failed\n ! Invalid RSA signature size\n\n" ); + goto exit; + } + + mbedtls_sha1( buf, (int)( p - 2 - buf ), hash ); + + if( ( ret = mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, + MBEDTLS_MD_SHA256, 0, hash, p ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_verify returned %d\n\n", ret ); + goto exit; + } + + /* + * 6. Send our public value: Yc = G ^ Xc mod P + */ + mbedtls_printf( "\n . Sending own public value to server" ); + fflush( stdout ); + + n = dhm.len; + if( ( ret = mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, n, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_make_public returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_net_send( &server_fd, buf, n ) ) != (int) n ) + { + mbedtls_printf( " failed\n ! mbedtls_net_send returned %d\n\n", ret ); + goto exit; + } + + /* + * 7. Derive the shared secret: K = Ys ^ Xc mod P + */ + mbedtls_printf( "\n . Shared secret: " ); + fflush( stdout ); + + if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &n, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret ); + goto exit; + } + + for( n = 0; n < 16; n++ ) + mbedtls_printf( "%02x", buf[n] ); + + /* + * 8. Setup the AES-256 decryption key + * + * This is an overly simplified example; best practice is + * to hash the shared secret with a random value to derive + * the keying material for the encryption/decryption keys, + * IVs and MACs. + */ + mbedtls_printf( "...\n . Receiving and decrypting the ciphertext" ); + fflush( stdout ); + + mbedtls_aes_setkey_dec( &aes, buf, 256 ); + + memset( buf, 0, sizeof( buf ) ); + + if( ( ret = mbedtls_net_recv( &server_fd, buf, 16 ) ) != 16 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret ); + goto exit; + } + + mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_DECRYPT, buf, buf ); + buf[16] = '\0'; + mbedtls_printf( "\n . Plaintext is \"%s\"\n\n", (char *) buf ); + +exit: + + mbedtls_net_free( &server_fd ); + + mbedtls_aes_free( &aes ); + mbedtls_rsa_free( &rsa ); + mbedtls_dhm_free( &dhm ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C && + MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && + MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_genprime.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_genprime.c new file mode 100644 index 0000000..84a94a1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_genprime.c @@ -0,0 +1,197 @@ +/* + * Diffie-Hellman-Merkle key exchange (prime generation) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_time_t time_t +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_GENPRIME) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_FS_IO and/or MBEDTLS_CTR_DRBG_C and/or " + "MBEDTLS_GENPRIME not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/bignum.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include + +#define USAGE \ + "\n usage: dh_genprime param=<>...\n" \ + "\n acceprable parameters:\n" \ + " bits=%%d default: 2048\n" + +#define DFL_BITS 2048 + +/* + * Note: G = 4 is always a quadratic residue mod P, + * so it is a generator of order Q (with P = 2*Q+1). + */ +#define GENERATOR "4" + +int main( int argc, char **argv ) +{ + int ret = 1; + mbedtls_mpi G, P, Q; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + const char *pers = "dh_genprime"; + FILE *fout; + int nbits = DFL_BITS; + int i; + char *p, *q; + + mbedtls_mpi_init( &G ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + mbedtls_entropy_init( &entropy ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + return( 1 ); + } + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "bits" ) == 0 ) + { + nbits = atoi( q ); + if( nbits < 0 || nbits > MBEDTLS_MPI_MAX_BITS ) + goto usage; + } + else + goto usage; + } + + if( ( ret = mbedtls_mpi_read_string( &G, 10, GENERATOR ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_string returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ! Generating large primes may take minutes!\n" ); + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Generating the modulus, please wait..." ); + fflush( stdout ); + + /* + * This can take a long time... + */ + if( ( ret = mbedtls_mpi_gen_prime( &P, nbits, 1, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_gen_prime returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Verifying that Q = (P-1)/2 is prime..." ); + fflush( stdout ); + + if( ( ret = mbedtls_mpi_sub_int( &Q, &P, 1 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_sub_int returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_mpi_div_int( &Q, NULL, &Q, 2 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_div_int returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_mpi_is_prime( &Q, mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_is_prime returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Exporting the value in dh_prime.txt..." ); + fflush( stdout ); + + if( ( fout = fopen( "dh_prime.txt", "wb+" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not create dh_prime.txt\n\n" ); + goto exit; + } + + if( ( ret = mbedtls_mpi_write_file( "P = ", &P, 16, fout ) != 0 ) || + ( ret = mbedtls_mpi_write_file( "G = ", &G, 16, fout ) != 0 ) ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret ); + fclose( fout ); + goto exit; + } + + mbedtls_printf( " ok\n\n" ); + fclose( fout ); + +exit: + + mbedtls_mpi_free( &G ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_FS_IO && + MBEDTLS_CTR_DRBG_C && MBEDTLS_GENPRIME */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_prime.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_prime.txt new file mode 100644 index 0000000..de0c281 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_prime.txt @@ -0,0 +1,2 @@ +P = FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF +G = 02 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_server.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_server.c new file mode 100644 index 0000000..8bf2b1b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/dh_server.c @@ -0,0 +1,308 @@ +/* + * Diffie-Hellman-Merkle key exchange (server side) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define mbedtls_time_t time_t +#endif + +#if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \ + defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \ + defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) && \ + defined(MBEDTLS_FS_IO) && defined(MBEDTLS_CTR_DRBG_C) && \ + defined(MBEDTLS_SHA1_C) +#include "mbedtls/net_sockets.h" +#include "mbedtls/aes.h" +#include "mbedtls/dhm.h" +#include "mbedtls/rsa.h" +#include "mbedtls/sha1.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include +#endif + +#define SERVER_PORT "11999" +#define PLAINTEXT "==Hello there!==" + +#if !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_DHM_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NET_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_SHA1_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_DHM_C and/or MBEDTLS_ENTROPY_C " + "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( void ) +{ + FILE *f; + + int ret; + size_t n, buflen; + mbedtls_net_context listen_fd, client_fd; + + unsigned char buf[2048]; + unsigned char hash[32]; + unsigned char buf2[2]; + const char *pers = "dh_server"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_rsa_context rsa; + mbedtls_dhm_context dhm; + mbedtls_aes_context aes; + + mbedtls_net_init( &listen_fd ); + mbedtls_net_init( &client_fd ); + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_SHA256 ); + mbedtls_dhm_init( &dhm ); + mbedtls_aes_init( &aes ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + /* + * 1. Setup the RNG + */ + mbedtls_printf( "\n . Seeding the random number generator" ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + /* + * 2a. Read the server's private RSA key + */ + mbedtls_printf( "\n . Reading private key from rsa_priv.txt" ); + fflush( stdout ); + + if( ( f = fopen( "rsa_priv.txt", "rb" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not open rsa_priv.txt\n" \ + " ! Please run rsa_genkey first\n\n" ); + goto exit; + } + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + + if( ( ret = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret ); + fclose( f ); + goto exit; + } + + rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + + fclose( f ); + + /* + * 2b. Get the DHM modulus and generator + */ + mbedtls_printf( "\n . Reading DH parameters from dh_prime.txt" ); + fflush( stdout ); + + if( ( f = fopen( "dh_prime.txt", "rb" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not open dh_prime.txt\n" \ + " ! Please run dh_genprime first\n\n" ); + goto exit; + } + + if( mbedtls_mpi_read_file( &dhm.P, 16, f ) != 0 || + mbedtls_mpi_read_file( &dhm.G, 16, f ) != 0 ) + { + mbedtls_printf( " failed\n ! Invalid DH parameter file\n\n" ); + fclose( f ); + goto exit; + } + + fclose( f ); + + /* + * 3. Wait for a client to connect + */ + mbedtls_printf( "\n . Waiting for a remote connection" ); + fflush( stdout ); + + if( ( ret = mbedtls_net_bind( &listen_fd, NULL, SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd, + NULL, 0, NULL ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_accept returned %d\n\n", ret ); + goto exit; + } + + /* + * 4. Setup the DH parameters (P,G,Ys) + */ + mbedtls_printf( "\n . Sending the server's DH parameters" ); + fflush( stdout ); + + memset( buf, 0, sizeof( buf ) ); + + if( ( ret = mbedtls_dhm_make_params( &dhm, (int) mbedtls_mpi_size( &dhm.P ), buf, &n, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_make_params returned %d\n\n", ret ); + goto exit; + } + + /* + * 5. Sign the parameters and send them + */ + mbedtls_sha1( buf, n, hash ); + + buf[n ] = (unsigned char)( rsa.len >> 8 ); + buf[n + 1] = (unsigned char)( rsa.len ); + + if( ( ret = mbedtls_rsa_pkcs1_sign( &rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256, + 0, hash, buf + n + 2 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_sign returned %d\n\n", ret ); + goto exit; + } + + buflen = n + 2 + rsa.len; + buf2[0] = (unsigned char)( buflen >> 8 ); + buf2[1] = (unsigned char)( buflen ); + + if( ( ret = mbedtls_net_send( &client_fd, buf2, 2 ) ) != 2 || + ( ret = mbedtls_net_send( &client_fd, buf, buflen ) ) != (int) buflen ) + { + mbedtls_printf( " failed\n ! mbedtls_net_send returned %d\n\n", ret ); + goto exit; + } + + /* + * 6. Get the client's public value: Yc = G ^ Xc mod P + */ + mbedtls_printf( "\n . Receiving the client's public value" ); + fflush( stdout ); + + memset( buf, 0, sizeof( buf ) ); + + if( ( ret = mbedtls_net_recv( &client_fd, buf, n ) ) != (int) n ) + { + mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_dhm_read_public( &dhm, buf, dhm.len ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_read_public returned %d\n\n", ret ); + goto exit; + } + + /* + * 7. Derive the shared secret: K = Ys ^ Xc mod P + */ + mbedtls_printf( "\n . Shared secret: " ); + fflush( stdout ); + + if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &n, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret ); + goto exit; + } + + for( n = 0; n < 16; n++ ) + mbedtls_printf( "%02x", buf[n] ); + + /* + * 8. Setup the AES-256 encryption key + * + * This is an overly simplified example; best practice is + * to hash the shared secret with a random value to derive + * the keying material for the encryption/decryption keys + * and MACs. + */ + mbedtls_printf( "...\n . Encrypting and sending the ciphertext" ); + fflush( stdout ); + + mbedtls_aes_setkey_enc( &aes, buf, 256 ); + memcpy( buf, PLAINTEXT, 16 ); + mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_ENCRYPT, buf, buf ); + + if( ( ret = mbedtls_net_send( &client_fd, buf, 16 ) ) != 16 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_send returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( "\n\n" ); + +exit: + + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); + + mbedtls_aes_free( &aes ); + mbedtls_rsa_free( &rsa ); + mbedtls_dhm_free( &dhm ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C && + MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && + MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdh_curve25519.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdh_curve25519.c new file mode 100644 index 0000000..aa15c46 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdh_curve25519.c @@ -0,0 +1,237 @@ +/* + * Example ECDHE with Curve25519 program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_ECDH_C) || \ + !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf( "MBEDTLS_ECDH_C and/or " + "MBEDTLS_ECP_DP_CURVE25519_ENABLED and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C " + "not defined\n" ); + return( 0 ); +} +#else + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/ecdh.h" + +int main( int argc, char *argv[] ) +{ + int ret; + mbedtls_ecdh_context ctx_cli, ctx_srv; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char cli_to_srv[32], srv_to_cli[32]; + const char pers[] = "ecdh"; + ((void) argc); + ((void) argv); + + mbedtls_ecdh_init( &ctx_cli ); + mbedtls_ecdh_init( &ctx_srv ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + /* + * Initialize random number generation + */ + mbedtls_printf( " . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + sizeof pers ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * Client: inialize context and generate keypair + */ + mbedtls_printf( " . Setting up client context..." ); + fflush( stdout ); + + ret = mbedtls_ecp_group_load( &ctx_cli.grp, MBEDTLS_ECP_DP_CURVE25519 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecp_group_load returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_ecdh_gen_public( &ctx_cli.grp, &ctx_cli.d, &ctx_cli.Q, + mbedtls_ctr_drbg_random, &ctr_drbg ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdh_gen_public returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_mpi_write_binary( &ctx_cli.Q.X, cli_to_srv, 32 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_write_binary returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * Server: initialize context and generate keypair + */ + mbedtls_printf( " . Setting up server context..." ); + fflush( stdout ); + + ret = mbedtls_ecp_group_load( &ctx_srv.grp, MBEDTLS_ECP_DP_CURVE25519 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecp_group_load returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_ecdh_gen_public( &ctx_srv.grp, &ctx_srv.d, &ctx_srv.Q, + mbedtls_ctr_drbg_random, &ctr_drbg ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdh_gen_public returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_mpi_write_binary( &ctx_srv.Q.X, srv_to_cli, 32 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_write_binary returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * Server: read peer's key and generate shared secret + */ + mbedtls_printf( " . Server reading client key and computing secret..." ); + fflush( stdout ); + + ret = mbedtls_mpi_lset( &ctx_srv.Qp.Z, 1 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_lset returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_mpi_read_binary( &ctx_srv.Qp.X, cli_to_srv, 32 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_binary returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_ecdh_compute_shared( &ctx_srv.grp, &ctx_srv.z, + &ctx_srv.Qp, &ctx_srv.d, + mbedtls_ctr_drbg_random, &ctr_drbg ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdh_compute_shared returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * Client: read peer's key and generate shared secret + */ + mbedtls_printf( " . Client reading server key and computing secret..." ); + fflush( stdout ); + + ret = mbedtls_mpi_lset( &ctx_cli.Qp.Z, 1 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_lset returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_mpi_read_binary( &ctx_cli.Qp.X, srv_to_cli, 32 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_binary returned %d\n", ret ); + goto exit; + } + + ret = mbedtls_ecdh_compute_shared( &ctx_cli.grp, &ctx_cli.z, + &ctx_cli.Qp, &ctx_cli.d, + mbedtls_ctr_drbg_random, &ctr_drbg ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdh_compute_shared returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * Verification: are the computed secret equal? + */ + mbedtls_printf( " . Checking if both computed secrets are equal..." ); + fflush( stdout ); + + ret = mbedtls_mpi_cmp_mpi( &ctx_cli.z, &ctx_srv.z ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdh_compute_shared returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + +exit: + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + mbedtls_ecdh_free( &ctx_srv ); + mbedtls_ecdh_free( &ctx_cli ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + + return( ret != 0 ); +} +#endif /* MBEDTLS_ECDH_C && MBEDTLS_ECP_DP_CURVE25519_ENABLED && + MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdsa.c new file mode 100644 index 0000000..069d312 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/ecdsa.c @@ -0,0 +1,231 @@ +/* + * Example ECDSA program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_ECDSA_C) && \ + defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/ecdsa.h" + +#include +#endif + +/* + * Uncomment to show key and signature details + */ +#define VERBOSE + +/* + * Uncomment to force use of a specific curve + */ +#define ECPARAMS MBEDTLS_ECP_DP_SECP192R1 + +#if !defined(ECPARAMS) +#define ECPARAMS mbedtls_ecp_curve_list()->grp_id +#endif + +#if !defined(MBEDTLS_ECDSA_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_ECDSA_C and/or MBEDTLS_SHA256_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C not defined\n"); + return( 0 ); +} +#else +#if defined(VERBOSE) +static void dump_buf( const char *title, unsigned char *buf, size_t len ) +{ + size_t i; + + mbedtls_printf( "%s", title ); + for( i = 0; i < len; i++ ) + mbedtls_printf("%c%c", "0123456789ABCDEF" [buf[i] / 16], + "0123456789ABCDEF" [buf[i] % 16] ); + mbedtls_printf( "\n" ); +} + +static void dump_pubkey( const char *title, mbedtls_ecdsa_context *key ) +{ + unsigned char buf[300]; + size_t len; + + if( mbedtls_ecp_point_write_binary( &key->grp, &key->Q, + MBEDTLS_ECP_PF_UNCOMPRESSED, &len, buf, sizeof buf ) != 0 ) + { + mbedtls_printf("internal error\n"); + return; + } + + dump_buf( title, buf, len ); +} +#else +#define dump_buf( a, b, c ) +#define dump_pubkey( a, b ) +#endif + +int main( int argc, char *argv[] ) +{ + int ret; + mbedtls_ecdsa_context ctx_sign, ctx_verify; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char hash[] = "This should be the hash of a message."; + unsigned char sig[512]; + size_t sig_len; + const char *pers = "ecdsa"; + ((void) argv); + + mbedtls_ecdsa_init( &ctx_sign ); + mbedtls_ecdsa_init( &ctx_verify ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + memset(sig, 0, sizeof( sig ) ); + ret = 1; + + if( argc != 1 ) + { + mbedtls_printf( "usage: ecdsa\n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + /* + * Generate a key pair for signing + */ + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Generating key pair..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ecdsa_genkey( &ctx_sign, ECPARAMS, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdsa_genkey returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok (key size: %d bits)\n", (int) ctx_sign.grp.pbits ); + + dump_pubkey( " + Public key: ", &ctx_sign ); + + /* + * Sign some message hash + */ + mbedtls_printf( " . Signing message..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ecdsa_write_signature( &ctx_sign, MBEDTLS_MD_SHA256, + hash, sizeof( hash ), + sig, &sig_len, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdsa_genkey returned %d\n", ret ); + goto exit; + } + mbedtls_printf( " ok (signature length = %u)\n", (unsigned int) sig_len ); + + dump_buf( " + Hash: ", hash, sizeof hash ); + dump_buf( " + Signature: ", sig, sig_len ); + + /* + * Transfer public information to verifying context + * + * We could use the same context for verification and signatures, but we + * chose to use a new one in order to make it clear that the verifying + * context only needs the public key (Q), and not the private key (d). + */ + mbedtls_printf( " . Preparing verification context..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ecp_group_copy( &ctx_verify.grp, &ctx_sign.grp ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecp_group_copy returned %d\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ecp_copy( &ctx_verify.Q, &ctx_sign.Q ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecp_copy returned %d\n", ret ); + goto exit; + } + + ret = 0; + + /* + * Verify signature + */ + mbedtls_printf( " ok\n . Verifying signature..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ecdsa_read_signature( &ctx_verify, + hash, sizeof( hash ), + sig, sig_len ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ecdsa_read_signature returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +exit: + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + mbedtls_ecdsa_free( &ctx_verify ); + mbedtls_ecdsa_free( &ctx_sign ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + + return( ret ); +} +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && + ECPARAMS */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/gen_key.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/gen_key.c new file mode 100644 index 0000000..4812694 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/gen_key.c @@ -0,0 +1,425 @@ +/* + * Key generation application + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_PK_WRITE_C) && defined(MBEDTLS_FS_IO) && \ + defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/error.h" +#include "mbedtls/pk.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/rsa.h" +#include "mbedtls/error.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include +#include + +#if !defined(_WIN32) +#include + +#define DEV_RANDOM_THRESHOLD 32 + +int dev_random_entropy_poll( void *data, unsigned char *output, + size_t len, size_t *olen ) +{ + FILE *file; + size_t ret, left = len; + unsigned char *p = output; + ((void) data); + + *olen = 0; + + file = fopen( "/dev/random", "rb" ); + if( file == NULL ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + + while( left > 0 ) + { + /* /dev/random can return much less than requested. If so, try again */ + ret = fread( p, 1, left, file ); + if( ret == 0 && ferror( file ) ) + { + fclose( file ); + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + } + + p += ret; + left -= ret; + sleep( 1 ); + } + fclose( file ); + *olen = len; + + return( 0 ); +} +#endif /* !_WIN32 */ +#endif + +#if defined(MBEDTLS_ECP_C) +#define DFL_EC_CURVE mbedtls_ecp_curve_list()->grp_id +#else +#define DFL_EC_CURVE 0 +#endif + +#if !defined(_WIN32) && defined(MBEDTLS_FS_IO) +#define USAGE_DEV_RANDOM \ + " use_dev_random=0|1 default: 0\n" +#else +#define USAGE_DEV_RANDOM "" +#endif /* !_WIN32 && MBEDTLS_FS_IO */ + +#define FORMAT_PEM 0 +#define FORMAT_DER 1 + +#define DFL_TYPE MBEDTLS_PK_RSA +#define DFL_RSA_KEYSIZE 4096 +#define DFL_FILENAME "keyfile.key" +#define DFL_FORMAT FORMAT_PEM +#define DFL_USE_DEV_RANDOM 0 + +#define USAGE \ + "\n usage: gen_key param=<>...\n" \ + "\n acceptable parameters:\n" \ + " type=rsa|ec default: rsa\n" \ + " rsa_keysize=%%d default: 4096\n" \ + " ec_curve=%%s see below\n" \ + " filename=%%s default: keyfile.key\n" \ + " format=pem|der default: pem\n" \ + USAGE_DEV_RANDOM \ + "\n" + +#if !defined(MBEDTLS_PK_WRITE_C) || !defined(MBEDTLS_PEM_WRITE_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf( "MBEDTLS_PK_WRITE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " + "MBEDTLS_PEM_WRITE_C" + "not defined.\n" ); + return( 0 ); +} +#else +/* + * global options + */ +struct options +{ + int type; /* the type of key to generate */ + int rsa_keysize; /* length of key in bits */ + int ec_curve; /* curve identifier for EC keys */ + const char *filename; /* filename of the key file */ + int format; /* the output format to use */ + int use_dev_random; /* use /dev/random as entropy source */ +} opt; + +static int write_private_key( mbedtls_pk_context *key, const char *output_file ) +{ + int ret; + FILE *f; + unsigned char output_buf[16000]; + unsigned char *c = output_buf; + size_t len = 0; + + memset(output_buf, 0, 16000); + if( opt.format == FORMAT_PEM ) + { + if( ( ret = mbedtls_pk_write_key_pem( key, output_buf, 16000 ) ) != 0 ) + return( ret ); + + len = strlen( (char *) output_buf ); + } + else + { + if( ( ret = mbedtls_pk_write_key_der( key, output_buf, 16000 ) ) < 0 ) + return( ret ); + + len = ret; + c = output_buf + sizeof(output_buf) - len; + } + + if( ( f = fopen( output_file, "wb" ) ) == NULL ) + return( -1 ); + + if( fwrite( c, 1, len, f ) != len ) + { + fclose( f ); + return( -1 ); + } + + fclose( f ); + + return( 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0; + mbedtls_pk_context key; + char buf[1024]; + int i; + char *p, *q; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + const char *pers = "gen_key"; +#if defined(MBEDTLS_ECP_C) + const mbedtls_ecp_curve_info *curve_info; +#endif + + /* + * Set to sane values + */ + mbedtls_pk_init( &key ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + memset( buf, 0, sizeof( buf ) ); + + if( argc == 0 ) + { + usage: + ret = 1; + mbedtls_printf( USAGE ); +#if defined(MBEDTLS_ECP_C) + mbedtls_printf( " available ec_curve values:\n" ); + curve_info = mbedtls_ecp_curve_list(); + mbedtls_printf( " %s (default)\n", curve_info->name ); + while( ( ++curve_info )->name != NULL ) + mbedtls_printf( " %s\n", curve_info->name ); +#endif + goto exit; + } + + opt.type = DFL_TYPE; + opt.rsa_keysize = DFL_RSA_KEYSIZE; + opt.ec_curve = DFL_EC_CURVE; + opt.filename = DFL_FILENAME; + opt.format = DFL_FORMAT; + opt.use_dev_random = DFL_USE_DEV_RANDOM; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "type" ) == 0 ) + { + if( strcmp( q, "rsa" ) == 0 ) + opt.type = MBEDTLS_PK_RSA; + else if( strcmp( q, "ec" ) == 0 ) + opt.type = MBEDTLS_PK_ECKEY; + else + goto usage; + } + else if( strcmp( p, "format" ) == 0 ) + { + if( strcmp( q, "pem" ) == 0 ) + opt.format = FORMAT_PEM; + else if( strcmp( q, "der" ) == 0 ) + opt.format = FORMAT_DER; + else + goto usage; + } + else if( strcmp( p, "rsa_keysize" ) == 0 ) + { + opt.rsa_keysize = atoi( q ); + if( opt.rsa_keysize < 1024 || + opt.rsa_keysize > MBEDTLS_MPI_MAX_BITS ) + goto usage; + } +#if defined(MBEDTLS_ECP_C) + else if( strcmp( p, "ec_curve" ) == 0 ) + { + if( ( curve_info = mbedtls_ecp_curve_info_from_name( q ) ) == NULL ) + goto usage; + opt.ec_curve = curve_info->grp_id; + } +#endif + else if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else if( strcmp( p, "use_dev_random" ) == 0 ) + { + opt.use_dev_random = atoi( q ); + if( opt.use_dev_random < 0 || opt.use_dev_random > 1 ) + goto usage; + } + else + goto usage; + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); +#if !defined(_WIN32) && defined(MBEDTLS_FS_IO) + if( opt.use_dev_random ) + { + if( ( ret = mbedtls_entropy_add_source( &entropy, dev_random_entropy_poll, + NULL, DEV_RANDOM_THRESHOLD, + MBEDTLS_ENTROPY_SOURCE_STRONG ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_entropy_add_source returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf("\n Using /dev/random, so can take a long time! " ); + fflush( stdout ); + } +#endif /* !_WIN32 && MBEDTLS_FS_IO */ + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret ); + goto exit; + } + + /* + * 1.1. Generate the key + */ + mbedtls_printf( "\n . Generating the private key ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_setup( &key, mbedtls_pk_info_from_type( opt.type ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_setup returned -0x%04x", -ret ); + goto exit; + } + +#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_GENPRIME) + if( opt.type == MBEDTLS_PK_RSA ) + { + ret = mbedtls_rsa_gen_key( mbedtls_pk_rsa( key ), mbedtls_ctr_drbg_random, &ctr_drbg, + opt.rsa_keysize, 65537 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", -ret ); + goto exit; + } + } + else +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECP_C) + if( opt.type == MBEDTLS_PK_ECKEY ) + { + ret = mbedtls_ecp_gen_key( opt.ec_curve, mbedtls_pk_ec( key ), + mbedtls_ctr_drbg_random, &ctr_drbg ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", -ret ); + goto exit; + } + } + else +#endif /* MBEDTLS_ECP_C */ + { + mbedtls_printf( " failed\n ! key type not supported\n" ); + goto exit; + } + + /* + * 1.2 Print the key + */ + mbedtls_printf( " ok\n . Key information:\n" ); + +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_RSA ) + { + mbedtls_rsa_context *rsa = mbedtls_pk_rsa( key ); + mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL ); + mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL ); + mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL ); + mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL ); + mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL ); + mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL ); + mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL ); + mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL ); + } + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_ECKEY ) + { + mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); + mbedtls_printf( "curve: %s\n", + mbedtls_ecp_curve_info_from_grp_id( ecp->grp.id )->name ); + mbedtls_mpi_write_file( "X_Q: ", &ecp->Q.X, 16, NULL ); + mbedtls_mpi_write_file( "Y_Q: ", &ecp->Q.Y, 16, NULL ); + mbedtls_mpi_write_file( "D: ", &ecp->d , 16, NULL ); + } + else +#endif + mbedtls_printf(" ! key type not supported\n"); + + /* + * 1.3 Export key + */ + mbedtls_printf( " . Writing key to file..." ); + + if( ( ret = write_private_key( &key, opt.filename ) ) != 0 ) + { + mbedtls_printf( " failed\n" ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +exit: + + if( ret != 0 && ret != 1) + { +#ifdef MBEDTLS_ERROR_C + mbedtls_strerror( ret, buf, sizeof( buf ) ); + mbedtls_printf( " - %s\n", buf ); +#else + mbedtls_printf("\n"); +#endif + } + + mbedtls_pk_free( &key ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_PK_WRITE_C && MBEDTLS_PEM_WRITE_C && MBEDTLS_FS_IO && + * MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app.c new file mode 100644 index 0000000..b6b8446 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app.c @@ -0,0 +1,281 @@ +/* + * Key reading application + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_BIGNUM_C) && \ + defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/error.h" +#include "mbedtls/rsa.h" +#include "mbedtls/x509.h" + +#include +#endif + +#define MODE_NONE 0 +#define MODE_PRIVATE 1 +#define MODE_PUBLIC 2 + +#define DFL_MODE MODE_NONE +#define DFL_FILENAME "keyfile.key" +#define DFL_PASSWORD "" +#define DFL_PASSWORD_FILE "" +#define DFL_DEBUG_LEVEL 0 + +#define USAGE \ + "\n usage: key_app param=<>...\n" \ + "\n acceptable parameters:\n" \ + " mode=private|public default: none\n" \ + " filename=%%s default: keyfile.key\n" \ + " password=%%s default: \"\"\n" \ + " password_file=%%s default: \"\"\n" \ + "\n" + + +#if !defined(MBEDTLS_BIGNUM_C) || \ + !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or " + "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +/* + * global options + */ +struct options +{ + int mode; /* the mode to run the application in */ + const char *filename; /* filename of the key file */ + const char *password; /* password for the private key */ + const char *password_file; /* password_file for the private key */ +} opt; + +int main( int argc, char *argv[] ) +{ + int ret = 0; + mbedtls_pk_context pk; + char buf[1024]; + int i; + char *p, *q; + + /* + * Set to sane values + */ + mbedtls_pk_init( &pk ); + memset( buf, 0, sizeof(buf) ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + goto exit; + } + + opt.mode = DFL_MODE; + opt.filename = DFL_FILENAME; + opt.password = DFL_PASSWORD; + opt.password_file = DFL_PASSWORD_FILE; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "mode" ) == 0 ) + { + if( strcmp( q, "private" ) == 0 ) + opt.mode = MODE_PRIVATE; + else if( strcmp( q, "public" ) == 0 ) + opt.mode = MODE_PUBLIC; + else + goto usage; + } + else if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else if( strcmp( p, "password" ) == 0 ) + opt.password = q; + else if( strcmp( p, "password_file" ) == 0 ) + opt.password_file = q; + else + goto usage; + } + + if( opt.mode == MODE_PRIVATE ) + { + if( strlen( opt.password ) && strlen( opt.password_file ) ) + { + mbedtls_printf( "Error: cannot have both password and password_file\n" ); + goto usage; + } + + if( strlen( opt.password_file ) ) + { + FILE *f; + + mbedtls_printf( "\n . Loading the password file ..." ); + if( ( f = fopen( opt.password_file, "rb" ) ) == NULL ) + { + mbedtls_printf( " failed\n ! fopen returned NULL\n" ); + goto exit; + } + if( fgets( buf, sizeof(buf), f ) == NULL ) + { + fclose( f ); + mbedtls_printf( "Error: fgets() failed to retrieve password\n" ); + goto exit; + } + fclose( f ); + + i = (int) strlen( buf ); + if( buf[i - 1] == '\n' ) buf[i - 1] = '\0'; + if( buf[i - 2] == '\r' ) buf[i - 2] = '\0'; + opt.password = buf; + } + + /* + * 1.1. Load the key + */ + mbedtls_printf( "\n . Loading the private key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_keyfile( &pk, opt.filename, opt.password ); + + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2 Print the key + */ + mbedtls_printf( " . Key information ...\n" ); +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA ) + { + mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk ); + mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL ); + mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL ); + mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL ); + mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL ); + mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL ); + mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL ); + mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL ); + mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL ); + } + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY ) + { + mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk ); + mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ); + mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ); + mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ); + mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL ); + } + else +#endif + { + mbedtls_printf("Do not know how to print key information for this type\n" ); + goto exit; + } + } + else if( opt.mode == MODE_PUBLIC ) + { + /* + * 1.1. Load the key + */ + mbedtls_printf( "\n . Loading the public key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_public_keyfile( &pk, opt.filename ); + + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + mbedtls_printf( " . Key information ...\n" ); +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA ) + { + mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk ); + mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL ); + mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL ); + } + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY ) + { + mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk ); + mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ); + mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ); + mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ); + } + else +#endif + { + mbedtls_printf("Do not know how to print key information for this type\n" ); + goto exit; + } + } + else + goto usage; + +exit: + +#if defined(MBEDTLS_ERROR_C) + mbedtls_strerror( ret, buf, sizeof(buf) ); + mbedtls_printf( " ! Last error was: %s\n", buf ); +#endif + + mbedtls_pk_free( &pk ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app_writer.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app_writer.c new file mode 100644 index 0000000..9d12077 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/key_app_writer.c @@ -0,0 +1,406 @@ +/* + * Key writing application + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_PK_WRITE_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/error.h" +#include "mbedtls/pk.h" +#include "mbedtls/error.h" + +#include +#include +#endif + +#if defined(MBEDTLS_PEM_WRITE_C) +#define USAGE_OUT \ + " output_file=%%s default: keyfile.pem\n" \ + " output_format=pem|der default: pem\n" +#else +#define USAGE_OUT \ + " output_file=%%s default: keyfile.der\n" \ + " output_format=der default: der\n" +#endif + +#if defined(MBEDTLS_PEM_WRITE_C) +#define DFL_OUTPUT_FILENAME "keyfile.pem" +#define DFL_OUTPUT_FORMAT OUTPUT_FORMAT_PEM +#else +#define DFL_OUTPUT_FILENAME "keyfile.der" +#define DFL_OUTPUT_FORMAT OUTPUT_FORMAT_DER +#endif + +#define DFL_MODE MODE_NONE +#define DFL_FILENAME "keyfile.key" +#define DFL_DEBUG_LEVEL 0 +#define DFL_OUTPUT_MODE OUTPUT_MODE_NONE + +#define MODE_NONE 0 +#define MODE_PRIVATE 1 +#define MODE_PUBLIC 2 + +#define OUTPUT_MODE_NONE 0 +#define OUTPUT_MODE_PRIVATE 1 +#define OUTPUT_MODE_PUBLIC 2 + +#define OUTPUT_FORMAT_PEM 0 +#define OUTPUT_FORMAT_DER 1 + +#define USAGE \ + "\n usage: key_app param=<>...\n" \ + "\n acceptable parameters:\n" \ + " mode=private|public default: none\n" \ + " filename=%%s default: keyfile.key\n" \ + " output_mode=private|public default: none\n" \ + USAGE_OUT \ + "\n" + +#if !defined(MBEDTLS_PK_WRITE_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf( "MBEDTLS_PK_WRITE_C and/or MBEDTLS_FS_IO not defined.\n" ); + return( 0 ); +} +#else +/* + * global options + */ +struct options +{ + int mode; /* the mode to run the application in */ + const char *filename; /* filename of the key file */ + int output_mode; /* the output mode to use */ + const char *output_file; /* where to store the constructed key file */ + int output_format; /* the output format to use */ +} opt; + +static int write_public_key( mbedtls_pk_context *key, const char *output_file ) +{ + int ret; + FILE *f; + unsigned char output_buf[16000]; + unsigned char *c = output_buf; + size_t len = 0; + + memset(output_buf, 0, 16000); + +#if defined(MBEDTLS_PEM_WRITE_C) + if( opt.output_format == OUTPUT_FORMAT_PEM ) + { + if( ( ret = mbedtls_pk_write_pubkey_pem( key, output_buf, 16000 ) ) != 0 ) + return( ret ); + + len = strlen( (char *) output_buf ); + } + else +#endif + { + if( ( ret = mbedtls_pk_write_pubkey_der( key, output_buf, 16000 ) ) < 0 ) + return( ret ); + + len = ret; + c = output_buf + sizeof(output_buf) - len - 1; + } + + if( ( f = fopen( output_file, "w" ) ) == NULL ) + return( -1 ); + + if( fwrite( c, 1, len, f ) != len ) + { + fclose( f ); + return( -1 ); + } + + fclose( f ); + + return( 0 ); +} + +static int write_private_key( mbedtls_pk_context *key, const char *output_file ) +{ + int ret; + FILE *f; + unsigned char output_buf[16000]; + unsigned char *c = output_buf; + size_t len = 0; + + memset(output_buf, 0, 16000); + +#if defined(MBEDTLS_PEM_WRITE_C) + if( opt.output_format == OUTPUT_FORMAT_PEM ) + { + if( ( ret = mbedtls_pk_write_key_pem( key, output_buf, 16000 ) ) != 0 ) + return( ret ); + + len = strlen( (char *) output_buf ); + } + else +#endif + { + if( ( ret = mbedtls_pk_write_key_der( key, output_buf, 16000 ) ) < 0 ) + return( ret ); + + len = ret; + c = output_buf + sizeof(output_buf) - len - 1; + } + + if( ( f = fopen( output_file, "w" ) ) == NULL ) + return( -1 ); + + if( fwrite( c, 1, len, f ) != len ) + { + fclose( f ); + return( -1 ); + } + + fclose( f ); + + return( 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0; + mbedtls_pk_context key; + char buf[1024]; + int i; + char *p, *q; + + /* + * Set to sane values + */ + mbedtls_pk_init( &key ); + memset( buf, 0, sizeof( buf ) ); + + if( argc == 0 ) + { + usage: + ret = 1; + mbedtls_printf( USAGE ); + goto exit; + } + + opt.mode = DFL_MODE; + opt.filename = DFL_FILENAME; + opt.output_mode = DFL_OUTPUT_MODE; + opt.output_file = DFL_OUTPUT_FILENAME; + opt.output_format = DFL_OUTPUT_FORMAT; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "mode" ) == 0 ) + { + if( strcmp( q, "private" ) == 0 ) + opt.mode = MODE_PRIVATE; + else if( strcmp( q, "public" ) == 0 ) + opt.mode = MODE_PUBLIC; + else + goto usage; + } + else if( strcmp( p, "output_mode" ) == 0 ) + { + if( strcmp( q, "private" ) == 0 ) + opt.output_mode = OUTPUT_MODE_PRIVATE; + else if( strcmp( q, "public" ) == 0 ) + opt.output_mode = OUTPUT_MODE_PUBLIC; + else + goto usage; + } + else if( strcmp( p, "output_format" ) == 0 ) + { +#if defined(MBEDTLS_PEM_WRITE_C) + if( strcmp( q, "pem" ) == 0 ) + opt.output_format = OUTPUT_FORMAT_PEM; + else +#endif + if( strcmp( q, "der" ) == 0 ) + opt.output_format = OUTPUT_FORMAT_DER; + else + goto usage; + } + else if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else if( strcmp( p, "output_file" ) == 0 ) + opt.output_file = q; + else + goto usage; + } + + if( opt.mode == MODE_NONE && opt.output_mode != OUTPUT_MODE_NONE ) + { + mbedtls_printf( "\nCannot output a key without reading one.\n"); + goto exit; + } + + if( opt.mode == MODE_PUBLIC && opt.output_mode == OUTPUT_MODE_PRIVATE ) + { + mbedtls_printf( "\nCannot output a private key from a public key.\n"); + goto exit; + } + + if( opt.mode == MODE_PRIVATE ) + { + /* + * 1.1. Load the key + */ + mbedtls_printf( "\n . Loading the private key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_keyfile( &key, opt.filename, NULL ); + + if( ret != 0 ) + { + mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2 Print the key + */ + mbedtls_printf( " . Key information ...\n" ); + +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_RSA ) + { + mbedtls_rsa_context *rsa = mbedtls_pk_rsa( key ); + mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL ); + mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL ); + mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL ); + mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL ); + mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL ); + mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL ); + mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL ); + mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL ); + } + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_ECKEY ) + { + mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); + mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ); + mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ); + mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ); + mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL ); + } + else +#endif + mbedtls_printf("key type not supported yet\n"); + + } + else if( opt.mode == MODE_PUBLIC ) + { + /* + * 1.1. Load the key + */ + mbedtls_printf( "\n . Loading the public key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_public_keyfile( &key, opt.filename ); + + if( ret != 0 ) + { + mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2 Print the key + */ + mbedtls_printf( " . Key information ...\n" ); + +#if defined(MBEDTLS_RSA_C) + if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_RSA ) + { + mbedtls_rsa_context *rsa = mbedtls_pk_rsa( key ); + mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL ); + mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL ); + } + else +#endif +#if defined(MBEDTLS_ECP_C) + if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_ECKEY ) + { + mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); + mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ); + mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ); + mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ); + } + else +#endif + mbedtls_printf("key type not supported yet\n"); + } + else + goto usage; + + if( opt.output_mode == OUTPUT_MODE_PUBLIC ) + { + write_public_key( &key, opt.output_file ); + } + if( opt.output_mode == OUTPUT_MODE_PRIVATE ) + { + write_private_key( &key, opt.output_file ); + } + +exit: + + if( ret != 0 && ret != 1) + { +#ifdef MBEDTLS_ERROR_C + mbedtls_strerror( ret, buf, sizeof( buf ) ); + mbedtls_printf( " - %s\n", buf ); +#else + mbedtls_printf("\n"); +#endif + } + + mbedtls_pk_free( &key ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_PK_WRITE_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/mpi_demo.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/mpi_demo.c new file mode 100644 index 0000000..afe8957 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/mpi_demo.c @@ -0,0 +1,109 @@ +/* + * Simple MPI demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/bignum.h" + +#include +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +int main( void ) +{ + int ret; + mbedtls_mpi E, P, Q, N, H, D, X, Y, Z; + + mbedtls_mpi_init( &E ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &N ); + mbedtls_mpi_init( &H ); mbedtls_mpi_init( &D ); mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); + mbedtls_mpi_init( &Z ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &P, 10, "2789" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &Q, 10, "3203" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &E, 10, "257" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &N, &P, &Q ) ); + + mbedtls_printf( "\n Public key:\n\n" ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " N = ", &N, 10, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " E = ", &E, 10, NULL ) ); + + mbedtls_printf( "\n Private key:\n\n" ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " P = ", &P, 10, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " Q = ", &Q, 10, NULL ) ); + +#if defined(MBEDTLS_GENPRIME) + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P, &P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q, &Q, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P, &Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &D, &E, &H ) ); + + mbedtls_mpi_write_file( " D = E^-1 mod (P-1)*(Q-1) = ", + &D, 10, NULL ); +#else + mbedtls_printf("\nTest skipped (MBEDTLS_GENPRIME not defined).\n\n"); +#endif + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &X, 10, "55555" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &Y, &X, &E, &N, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &Z, &Y, &D, &N, NULL ) ); + + mbedtls_printf( "\n RSA operation:\n\n" ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " X (plaintext) = ", &X, 10, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " Y (ciphertext) = X^E mod N = ", &Y, 10, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( " Z (decrypted) = Y^D mod N = ", &Z, 10, NULL ) ); + mbedtls_printf( "\n" ); + +cleanup: + mbedtls_mpi_free( &E ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &N ); + mbedtls_mpi_free( &H ); mbedtls_mpi_free( &D ); mbedtls_mpi_free( &X ); mbedtls_mpi_free( &Y ); + mbedtls_mpi_free( &Z ); + + if( ret != 0 ) + { + mbedtls_printf( "\nAn error occurred.\n" ); + ret = 1; + } + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_decrypt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_decrypt.c new file mode 100644 index 0000000..32fbc75 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_decrypt.c @@ -0,0 +1,168 @@ +/* + * Public key-based simple decryption program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_PK_PARSE_C) && \ + defined(MBEDTLS_FS_IO) && defined(MBEDTLS_ENTROPY_C) && \ + defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/error.h" +#include "mbedtls/pk.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include +#endif + + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_PK_PARSE_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or " + "MBEDTLS_FS_IO and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret, c; + size_t i, olen = 0; + mbedtls_pk_context pk; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char result[1024]; + unsigned char buf[512]; + const char *pers = "mbedtls_pk_decrypt"; + ((void) argv); + + mbedtls_ctr_drbg_init( &ctr_drbg ); + memset(result, 0, sizeof( result ) ); + ret = 1; + + if( argc != 2 ) + { + mbedtls_printf( "usage: mbedtls_pk_decrypt \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( "\n . Reading private key from '%s'", argv[1] ); + fflush( stdout ); + + mbedtls_pk_init( &pk ); + + if( ( ret = mbedtls_pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret ); + goto exit; + } + + /* + * Extract the RSA encrypted value from the text file + */ + ret = 1; + + if( ( f = fopen( "result-enc.txt", "rb" ) ) == NULL ) + { + mbedtls_printf( "\n ! Could not open %s\n\n", "result-enc.txt" ); + goto exit; + } + + i = 0; + + while( fscanf( f, "%02X", &c ) > 0 && + i < (int) sizeof( buf ) ) + buf[i++] = (unsigned char) c; + + fclose( f ); + + /* + * Decrypt the encrypted RSA data and print the result. + */ + mbedtls_printf( "\n . Decrypting the encrypted data" ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_decrypt( &pk, buf, i, result, &olen, sizeof(result), + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_decrypt returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf( "\n . OK\n\n" ); + + mbedtls_printf( "The decrypted result is: '%s'\n\n", result ); + + ret = 0; + +exit: + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(MBEDTLS_ERROR_C) + if( ret != 0 ) + { + mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); + mbedtls_printf( " ! Last error was: %s\n", buf ); + } +#endif + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && + MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_encrypt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_encrypt.c new file mode 100644 index 0000000..7ca9d5a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_encrypt.c @@ -0,0 +1,168 @@ +/* + * RSA simple data encryption program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_PK_PARSE_C) && \ + defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_FS_IO) && \ + defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/error.h" +#include "mbedtls/pk.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_PK_PARSE_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret; + size_t i, olen = 0; + mbedtls_pk_context pk; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char input[1024]; + unsigned char buf[512]; + const char *pers = "mbedtls_pk_encrypt"; + + ret = 1; + mbedtls_ctr_drbg_init( &ctr_drbg ); + + if( argc != 3 ) + { + mbedtls_printf( "usage: mbedtls_pk_encrypt \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf( "\n . Reading public key from '%s'", argv[1] ); + fflush( stdout ); + + mbedtls_pk_init( &pk ); + + if( ( ret = mbedtls_pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret ); + goto exit; + } + + if( strlen( argv[2] ) > 100 ) + { + mbedtls_printf( " Input data larger than 100 characters.\n\n" ); + goto exit; + } + + memcpy( input, argv[2], strlen( argv[2] ) ); + + /* + * Calculate the RSA encryption of the hash. + */ + mbedtls_printf( "\n . Generating the encrypted value" ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_encrypt( &pk, input, strlen( argv[2] ), + buf, &olen, sizeof(buf), + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_encrypt returned -0x%04x\n", -ret ); + goto exit; + } + + /* + * Write the signature into result-enc.txt + */ + if( ( f = fopen( "result-enc.txt", "wb+" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not create %s\n\n", "result-enc.txt" ); + goto exit; + } + + for( i = 0; i < olen; i++ ) + mbedtls_fprintf( f, "%02X%s", buf[i], + ( i + 1 ) % 16 == 0 ? "\r\n" : " " ); + + fclose( f ); + + mbedtls_printf( "\n . Done (created \"%s\")\n\n", "result-enc.txt" ); + +exit: + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(MBEDTLS_ERROR_C) + if( ret != 0 ) + { + mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); + mbedtls_printf( " ! Last error was: %s\n", buf ); + } +#endif + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_ENTROPY_C && + MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_sign.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_sign.c new file mode 100644 index 0000000..daf08a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_sign.c @@ -0,0 +1,175 @@ +/* + * Public key-based signature creation program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_snprintf snprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \ + !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_SHA256_C and/or MBEDTLS_MD_C and/or " + "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/error.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/md.h" +#include "mbedtls/pk.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret = 1; + mbedtls_pk_context pk; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char hash[32]; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + char filename[512]; + const char *pers = "mbedtls_pk_sign"; + size_t olen = 0; + + mbedtls_entropy_init( &entropy ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + mbedtls_pk_init( &pk ); + + if( argc != 3 ) + { + mbedtls_printf( "usage: mbedtls_pk_sign \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf( "\n . Reading private key from '%s'", argv[1] ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not open '%s'\n", argv[1] ); + goto exit; + } + + /* + * Compute the SHA-256 hash of the input file, + * then calculate the signature of the hash. + */ + mbedtls_printf( "\n . Generating the SHA-256 signature" ); + fflush( stdout ); + + if( ( ret = mbedtls_md_file( + mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), + argv[2], hash ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[2] ); + goto exit; + } + + if( ( ret = mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, 0, buf, &olen, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_sign returned -0x%04x\n", -ret ); + goto exit; + } + + /* + * Write the signature into .sig + */ + mbedtls_snprintf( filename, sizeof(filename), "%s.sig", argv[2] ); + + if( ( f = fopen( filename, "wb+" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not create %s\n\n", filename ); + goto exit; + } + + if( fwrite( buf, 1, olen, f ) != olen ) + { + mbedtls_printf( "failed\n ! fwrite failed\n\n" ); + fclose( f ); + goto exit; + } + + fclose( f ); + + mbedtls_printf( "\n . Done (created \"%s\")\n\n", filename ); + +exit: + mbedtls_pk_free( &pk ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(MBEDTLS_ERROR_C) + if( ret != 0 ) + { + mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); + mbedtls_printf( " ! Last error was: %s\n", buf ); + } +#endif + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && + MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && + MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_verify.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_verify.c new file mode 100644 index 0000000..d35d17f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/pk_verify.c @@ -0,0 +1,149 @@ +/* + * Public key-based signature verification program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_snprintf snprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_MD_C) || \ + !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_PK_PARSE_C) || \ + !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_MD_C and/or " + "MBEDTLS_SHA256_C and/or MBEDTLS_PK_PARSE_C and/or " + "MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/error.h" +#include "mbedtls/md.h" +#include "mbedtls/pk.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret = 1; + size_t i; + mbedtls_pk_context pk; + unsigned char hash[32]; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + char filename[512]; + + mbedtls_pk_init( &pk ); + + if( argc != 3 ) + { + mbedtls_printf( "usage: mbedtls_pk_verify \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Reading public key from '%s'", argv[1] ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret ); + goto exit; + } + + /* + * Extract the signature from the file + */ + ret = 1; + mbedtls_snprintf( filename, sizeof(filename), "%s.sig", argv[2] ); + + if( ( f = fopen( filename, "rb" ) ) == NULL ) + { + mbedtls_printf( "\n ! Could not open %s\n\n", filename ); + goto exit; + } + + + i = fread( buf, 1, sizeof(buf), f ); + + fclose( f ); + + /* + * Compute the SHA-256 hash of the input file and + * verify the signature + */ + mbedtls_printf( "\n . Verifying the SHA-256 signature" ); + fflush( stdout ); + + if( ( ret = mbedtls_md_file( + mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), + argv[2], hash ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[2] ); + goto exit; + } + + if( ( ret = mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256, hash, 0, + buf, i ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_verify returned -0x%04x\n", -ret ); + goto exit; + } + + mbedtls_printf( "\n . OK (the signature is valid)\n\n" ); + + ret = 0; + +exit: + mbedtls_pk_free( &pk ); + +#if defined(MBEDTLS_ERROR_C) + if( ret != 0 ) + { + mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); + mbedtls_printf( " ! Last error was: %s\n", buf ); + } +#endif + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_SHA256_C && + MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_decrypt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_decrypt.c new file mode 100644 index 0000000..b64e156 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_decrypt.c @@ -0,0 +1,196 @@ +/* + * RSA simple decryption program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif + +#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_RSA_C) && \ + defined(MBEDTLS_FS_IO) && defined(MBEDTLS_ENTROPY_C) && \ + defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/rsa.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include + +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_FS_IO and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + int return_val, exit_val, c; + size_t i; + mbedtls_rsa_context rsa; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char result[1024]; + unsigned char buf[512]; + const char *pers = "rsa_decrypt"; + ((void) argv); + + memset(result, 0, sizeof( result ) ); + exit_val = MBEDTLS_EXIT_SUCCESS; + + if( argc != 1 ) + { + mbedtls_printf( "usage: rsa_decrypt\n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + mbedtls_entropy_init( &entropy ); + + return_val = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, + &entropy, (const unsigned char *) pers, + strlen( pers ) ); + if( return_val != 0 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", + return_val ); + goto exit; + } + + mbedtls_printf( "\n . Reading private key from rsa_priv.txt" ); + fflush( stdout ); + + if( ( f = fopen( "rsa_priv.txt", "rb" ) ) == NULL ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! Could not open rsa_priv.txt\n" \ + " ! Please run rsa_genkey first\n\n" ); + goto exit; + } + + if( ( return_val = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", + return_val ); + fclose( f ); + goto exit; + } + + rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + + fclose( f ); + + /* + * Extract the RSA encrypted value from the text file + */ + if( ( f = fopen( "result-enc.txt", "rb" ) ) == NULL ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( "\n ! Could not open %s\n\n", "result-enc.txt" ); + goto exit; + } + + i = 0; + + while( fscanf( f, "%02X", &c ) > 0 && + i < (int) sizeof( buf ) ) + buf[i++] = (unsigned char) c; + + fclose( f ); + + if( i != rsa.len ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( "\n ! Invalid RSA signature format\n\n" ); + goto exit; + } + + /* + * Decrypt the encrypted RSA data and print the result. + */ + mbedtls_printf( "\n . Decrypting the encrypted data" ); + fflush( stdout ); + + return_val = mbedtls_rsa_pkcs1_decrypt( &rsa, mbedtls_ctr_drbg_random, + &ctr_drbg, MBEDTLS_RSA_PRIVATE, &i, + buf, result, 1024 ); + if( return_val != 0 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_decrypt returned %d\n\n", + return_val ); + goto exit; + } + + mbedtls_printf( "\n . OK\n\n" ); + + mbedtls_printf( "The decrypted result is: '%s'\n\n", result ); + +exit: + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + mbedtls_rsa_free( &rsa ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( exit_val ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_FS_IO */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_encrypt.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_encrypt.c new file mode 100644 index 0000000..b9cb187 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_encrypt.c @@ -0,0 +1,186 @@ +/* + * RSA simple data encryption program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif + +#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_RSA_C) && \ + defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_FS_IO) && \ + defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/rsa.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + int return_val, exit_val; + size_t i; + mbedtls_rsa_context rsa; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char input[1024]; + unsigned char buf[512]; + const char *pers = "rsa_encrypt"; + + exit_val = MBEDTLS_EXIT_SUCCESS; + + if( argc != 2 ) + { + mbedtls_printf( "usage: rsa_encrypt \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + mbedtls_entropy_init( &entropy ); + + return_val = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, + &entropy, (const unsigned char *) pers, + strlen( pers ) ); + if( return_val != 0 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", + return_val ); + goto exit; + } + + mbedtls_printf( "\n . Reading public key from rsa_pub.txt" ); + fflush( stdout ); + + if( ( f = fopen( "rsa_pub.txt", "rb" ) ) == NULL ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! Could not open rsa_pub.txt\n" \ + " ! Please run rsa_genkey first\n\n" ); + goto exit; + } + + if( ( return_val = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 || + ( return_val = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", + return_val ); + fclose( f ); + goto exit; + } + + rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + + fclose( f ); + + if( strlen( argv[1] ) > 100 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " Input data larger than 100 characters.\n\n" ); + goto exit; + } + + memcpy( input, argv[1], strlen( argv[1] ) ); + + /* + * Calculate the RSA encryption of the hash. + */ + mbedtls_printf( "\n . Generating the RSA encrypted value" ); + fflush( stdout ); + + return_val = mbedtls_rsa_pkcs1_encrypt( &rsa, mbedtls_ctr_drbg_random, + &ctr_drbg, MBEDTLS_RSA_PUBLIC, + strlen( argv[1] ), input, buf ); + if( return_val != 0 ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_encrypt returned %d\n\n", + return_val ); + goto exit; + } + + /* + * Write the signature into result-enc.txt + */ + if( ( f = fopen( "result-enc.txt", "wb+" ) ) == NULL ) + { + exit_val = MBEDTLS_EXIT_FAILURE; + mbedtls_printf( " failed\n ! Could not create %s\n\n", "result-enc.txt" ); + goto exit; + } + + for( i = 0; i < rsa.len; i++ ) + mbedtls_fprintf( f, "%02X%s", buf[i], + ( i + 1 ) % 16 == 0 ? "\r\n" : " " ); + + fclose( f ); + + mbedtls_printf( "\n . Done (created \"%s\")\n\n", "result-enc.txt" ); + +exit: + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + mbedtls_rsa_free( &rsa ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( exit_val ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_ENTROPY_C && + MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_genkey.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_genkey.c new file mode 100644 index 0000000..e199ad2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_genkey.c @@ -0,0 +1,172 @@ +/* + * Example RSA key generation program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_ENTROPY_C) && \ + defined(MBEDTLS_RSA_C) && defined(MBEDTLS_GENPRIME) && \ + defined(MBEDTLS_FS_IO) && defined(MBEDTLS_CTR_DRBG_C) +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/bignum.h" +#include "mbedtls/x509.h" +#include "mbedtls/rsa.h" + +#include +#include +#endif + +#define KEY_SIZE 2048 +#define EXPONENT 65537 + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_GENPRIME) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_RSA_C and/or MBEDTLS_GENPRIME and/or " + "MBEDTLS_FS_IO and/or MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else +int main( void ) +{ + int ret; + mbedtls_rsa_context rsa; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + FILE *fpub = NULL; + FILE *fpriv = NULL; + const char *pers = "rsa_genkey"; + + mbedtls_ctr_drbg_init( &ctr_drbg ); + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Generating the RSA key [ %d-bit ]...", KEY_SIZE ); + fflush( stdout ); + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + + if( ( ret = mbedtls_rsa_gen_key( &rsa, mbedtls_ctr_drbg_random, &ctr_drbg, KEY_SIZE, + EXPONENT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Exporting the public key in rsa_pub.txt...." ); + fflush( stdout ); + + if( ( fpub = fopen( "rsa_pub.txt", "wb+" ) ) == NULL ) + { + mbedtls_printf( " failed\n ! could not open rsa_pub.txt for writing\n\n" ); + ret = 1; + goto exit; + } + + if( ( ret = mbedtls_mpi_write_file( "N = ", &rsa.N, 16, fpub ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "E = ", &rsa.E, 16, fpub ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n . Exporting the private key in rsa_priv.txt..." ); + fflush( stdout ); + + if( ( fpriv = fopen( "rsa_priv.txt", "wb+" ) ) == NULL ) + { + mbedtls_printf( " failed\n ! could not open rsa_priv.txt for writing\n" ); + ret = 1; + goto exit; + } + + if( ( ret = mbedtls_mpi_write_file( "N = " , &rsa.N , 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "E = " , &rsa.E , 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "D = " , &rsa.D , 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "P = " , &rsa.P , 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "Q = " , &rsa.Q , 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "DP = ", &rsa.DP, 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "DQ = ", &rsa.DQ, 16, fpriv ) ) != 0 || + ( ret = mbedtls_mpi_write_file( "QP = ", &rsa.QP, 16, fpriv ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret ); + goto exit; + } +/* + mbedtls_printf( " ok\n . Generating the certificate..." ); + + x509write_init_raw( &cert ); + x509write_add_pubkey( &cert, &rsa ); + x509write_add_subject( &cert, "CN='localhost'" ); + x509write_add_validity( &cert, "2007-09-06 17:00:32", + "2010-09-06 17:00:32" ); + x509write_create_selfsign( &cert, &rsa ); + x509write_crtfile( &cert, "cert.der", X509_OUTPUT_DER ); + x509write_crtfile( &cert, "cert.pem", X509_OUTPUT_PEM ); + x509write_free_raw( &cert ); +*/ + mbedtls_printf( " ok\n\n" ); + +exit: + + if( fpub != NULL ) + fclose( fpub ); + + if( fpriv != NULL ) + fclose( fpriv ); + + mbedtls_rsa_free( &rsa ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C && + MBEDTLS_GENPRIME && MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_priv.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_priv.txt new file mode 100644 index 0000000..254fcf8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_priv.txt @@ -0,0 +1,8 @@ +N = A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211 +E = 010001 +D = 589552BB4F2F023ADDDD5586D0C8FD857512D82080436678D07F984A29D892D31F1F7000FC5A39A0F73E27D885E47249A4148C8A5653EF69F91F8F736BA9F84841C2D99CD8C24DE8B72B5C9BE0EDBE23F93D731749FEA9CFB4A48DD2B7F35A2703E74AA2D4DB7DE9CEEA7D763AF0ADA7AC176C4E9A22C4CDA65CEC0C65964401 +P = CD083568D2D46C44C40C1FA0101AF2155E59C70B08423112AF0C1202514BBA5210765E29FF13036F56C7495894D80CF8C3BAEE2839BACBB0B86F6A2965F60DB1 +Q = CA0EEEA5E710E8E9811A6B846399420E3AE4A4C16647E426DDF8BBBCB11CD3F35CE2E4B6BCAD07AE2C0EC2ECBFCC601B207CDD77B5673E16382B1130BF465261 +DP = 0D0E21C07BF434B4A83B116472C2147A11D8EB98A33CFBBCF1D275EF19D815941622435AAF3839B6C432CA53CE9E772CFBE1923A937A766FD93E96E6EDEC1DF1 +DQ = 269CEBE6305DFEE4809377F078C814E37B45AE6677114DFC4F76F5097E1F3031D592567AC55B9B98213B40ECD54A4D2361F5FAACA1B1F51F71E4690893C4F081 +QP = 97AC5BB885ABCA314375E9E4DB1BA4B2218C90619F61BD474F5785075ECA81750A735199A8C191FE2D3355E7CF601A70E5CABDE0E02C2538BB9FB4871540B3C1 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_pub.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_pub.txt new file mode 100644 index 0000000..1e7ae0c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_pub.txt @@ -0,0 +1,2 @@ +N = A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211 +E = 010001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign.c new file mode 100644 index 0000000..affbf7a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign.c @@ -0,0 +1,170 @@ +/* + * RSA/SHA-256 signature creation program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#define mbedtls_snprintf snprintf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \ + !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_MD_C and/or " + "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/rsa.h" +#include "mbedtls/md.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret; + size_t i; + mbedtls_rsa_context rsa; + unsigned char hash[32]; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + char filename[512]; + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + ret = 1; + + if( argc != 2 ) + { + mbedtls_printf( "usage: rsa_sign \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Reading private key from rsa_priv.txt" ); + fflush( stdout ); + + if( ( f = fopen( "rsa_priv.txt", "rb" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not open rsa_priv.txt\n" \ + " ! Please run rsa_genkey first\n\n" ); + goto exit; + } + + if( ( ret = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret ); + fclose( f ); + goto exit; + } + + rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + + fclose( f ); + + mbedtls_printf( "\n . Checking the private key" ); + fflush( stdout ); + if( ( ret = mbedtls_rsa_check_privkey( &rsa ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_check_privkey failed with -0x%0x\n", -ret ); + goto exit; + } + + /* + * Compute the SHA-256 hash of the input file, + * then calculate the RSA signature of the hash. + */ + mbedtls_printf( "\n . Generating the RSA/SHA-256 signature" ); + fflush( stdout ); + + if( ( ret = mbedtls_md_file( + mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), + argv[1], hash ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[1] ); + goto exit; + } + + if( ( ret = mbedtls_rsa_pkcs1_sign( &rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256, + 20, hash, buf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_sign returned -0x%0x\n\n", -ret ); + goto exit; + } + + /* + * Write the signature into .sig + */ + mbedtls_snprintf( filename, sizeof(filename), "%s.sig", argv[1] ); + + if( ( f = fopen( filename, "wb+" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not create %s\n\n", argv[1] ); + goto exit; + } + + for( i = 0; i < rsa.len; i++ ) + mbedtls_fprintf( f, "%02X%s", buf[i], + ( i + 1 ) % 16 == 0 ? "\r\n" : " " ); + + fclose( f ); + + mbedtls_printf( "\n . Done (created \"%s\")\n\n", filename ); + +exit: + + mbedtls_rsa_free( &rsa ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && + MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign_pss.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign_pss.c new file mode 100644 index 0000000..7b6f14d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_sign_pss.c @@ -0,0 +1,178 @@ +/* + * RSASSA-PSS/SHA-256 signature creation program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_snprintf snprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_MD_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_RSA_C and/or MBEDTLS_SHA256_C and/or " + "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/md.h" +#include "mbedtls/rsa.h" +#include "mbedtls/md.h" +#include "mbedtls/x509.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret = 1; + mbedtls_pk_context pk; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + unsigned char hash[32]; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + char filename[512]; + const char *pers = "rsa_sign_pss"; + size_t olen = 0; + + mbedtls_entropy_init( &entropy ); + mbedtls_pk_init( &pk ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + if( argc != 3 ) + { + mbedtls_printf( "usage: rsa_sign_pss \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( "\n . Reading private key from '%s'", argv[1] ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not read key from '%s'\n", argv[1] ); + mbedtls_printf( " ! mbedtls_pk_parse_public_keyfile returned %d\n\n", ret ); + goto exit; + } + + if( !mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA ) ) + { + ret = 1; + mbedtls_printf( " failed\n ! Key is not an RSA key\n" ); + goto exit; + } + + mbedtls_rsa_set_padding( mbedtls_pk_rsa( pk ), MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA256 ); + + /* + * Compute the SHA-256 hash of the input file, + * then calculate the RSA signature of the hash. + */ + mbedtls_printf( "\n . Generating the RSA/SHA-256 signature" ); + fflush( stdout ); + + if( ( ret = mbedtls_md_file( + mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), + argv[2], hash ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[2] ); + goto exit; + } + + if( ( ret = mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, 0, buf, &olen, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_sign returned %d\n\n", ret ); + goto exit; + } + + /* + * Write the signature into .sig + */ + mbedtls_snprintf( filename, 512, "%s.sig", argv[2] ); + + if( ( f = fopen( filename, "wb+" ) ) == NULL ) + { + ret = 1; + mbedtls_printf( " failed\n ! Could not create %s\n\n", filename ); + goto exit; + } + + if( fwrite( buf, 1, olen, f ) != olen ) + { + mbedtls_printf( "failed\n ! fwrite failed\n\n" ); + fclose( f ); + goto exit; + } + + fclose( f ); + + mbedtls_printf( "\n . Done (created \"%s\")\n\n", filename ); + +exit: + mbedtls_pk_free( &pk ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C && + MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && + MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify.c new file mode 100644 index 0000000..1f827aa --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify.c @@ -0,0 +1,163 @@ +/* + * RSA/SHA-256 signature verification program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define mbedtls_snprintf snprintf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \ + !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_MD_C and/or " + "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/rsa.h" +#include "mbedtls/md.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret, c; + size_t i; + mbedtls_rsa_context rsa; + unsigned char hash[32]; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + char filename[512]; + + mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); + ret = 1; + + if( argc != 2 ) + { + mbedtls_printf( "usage: rsa_verify \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Reading public key from rsa_pub.txt" ); + fflush( stdout ); + + if( ( f = fopen( "rsa_pub.txt", "rb" ) ) == NULL ) + { + mbedtls_printf( " failed\n ! Could not open rsa_pub.txt\n" \ + " ! Please run rsa_genkey first\n\n" ); + goto exit; + } + + if( ( ret = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret ); + fclose( f ); + goto exit; + } + + rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + + fclose( f ); + + /* + * Extract the RSA signature from the text file + */ + ret = 1; + mbedtls_snprintf( filename, sizeof(filename), "%s.sig", argv[1] ); + + if( ( f = fopen( filename, "rb" ) ) == NULL ) + { + mbedtls_printf( "\n ! Could not open %s\n\n", filename ); + goto exit; + } + + i = 0; + while( fscanf( f, "%02X", &c ) > 0 && + i < (int) sizeof( buf ) ) + buf[i++] = (unsigned char) c; + + fclose( f ); + + if( i != rsa.len ) + { + mbedtls_printf( "\n ! Invalid RSA signature format\n\n" ); + goto exit; + } + + /* + * Compute the SHA-256 hash of the input file and + * verify the signature + */ + mbedtls_printf( "\n . Verifying the RSA/SHA-256 signature" ); + fflush( stdout ); + + if( ( ret = mbedtls_md_file( + mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), + argv[1], hash ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[1] ); + goto exit; + } + + if( ( ret = mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, + MBEDTLS_MD_SHA256, 20, hash, buf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_verify returned -0x%0x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( "\n . OK (the signature is valid)\n\n" ); + + ret = 0; + +exit: + + mbedtls_rsa_free( &rsa ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && + MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify_pss.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify_pss.c new file mode 100644 index 0000000..31b720f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/pkey/rsa_verify_pss.c @@ -0,0 +1,155 @@ +/* + * RSASSA-PSS/SHA-256 signature verification program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_snprintf snprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_MD_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_RSA_C and/or MBEDTLS_SHA256_C and/or " + "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/md.h" +#include "mbedtls/pem.h" +#include "mbedtls/pk.h" +#include "mbedtls/md.h" +#include "mbedtls/x509.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *f; + int ret = 1; + size_t i; + mbedtls_pk_context pk; + unsigned char hash[32]; + unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + char filename[512]; + + mbedtls_pk_init( &pk ); + + if( argc != 3 ) + { + mbedtls_printf( "usage: rsa_verify_pss \n" ); + +#if defined(_WIN32) + mbedtls_printf( "\n" ); +#endif + + goto exit; + } + + mbedtls_printf( "\n . Reading public key from '%s'", argv[1] ); + fflush( stdout ); + + if( ( ret = mbedtls_pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not read key from '%s'\n", argv[1] ); + mbedtls_printf( " ! mbedtls_pk_parse_public_keyfile returned %d\n\n", ret ); + goto exit; + } + + if( !mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA ) ) + { + ret = 1; + mbedtls_printf( " failed\n ! Key is not an RSA key\n" ); + goto exit; + } + + mbedtls_rsa_set_padding( mbedtls_pk_rsa( pk ), MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA256 ); + + /* + * Extract the RSA signature from the file + */ + ret = 1; + mbedtls_snprintf( filename, 512, "%s.sig", argv[2] ); + + if( ( f = fopen( filename, "rb" ) ) == NULL ) + { + mbedtls_printf( "\n ! Could not open %s\n\n", filename ); + goto exit; + } + + + i = fread( buf, 1, MBEDTLS_MPI_MAX_SIZE, f ); + + fclose( f ); + + /* + * Compute the SHA-256 hash of the input file and + * verify the signature + */ + mbedtls_printf( "\n . Verifying the RSA/SHA-256 signature" ); + fflush( stdout ); + + if( ( ret = mbedtls_md_file( + mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), + argv[2], hash ) ) != 0 ) + { + mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[2] ); + goto exit; + } + + if( ( ret = mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256, hash, 0, + buf, i ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_verify returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( "\n . OK (the signature is valid)\n\n" ); + + ret = 0; + +exit: + mbedtls_pk_free( &pk ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && + MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/CMakeLists.txt new file mode 100644 index 0000000..30933d8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(gen_random_havege gen_random_havege.c) +target_link_libraries(gen_random_havege mbedtls) + +add_executable(gen_random_ctr_drbg gen_random_ctr_drbg.c) +target_link_libraries(gen_random_ctr_drbg mbedtls) + +add_executable(gen_entropy gen_entropy.c) +target_link_libraries(gen_entropy mbedtls) + +install(TARGETS gen_random_havege gen_random_ctr_drbg gen_entropy + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_entropy.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_entropy.c new file mode 100644 index 0000000..792d381 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_entropy.c @@ -0,0 +1,96 @@ +/** + * \brief Use and generate multiple entropies calls into a file + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/entropy.h" + +#include +#endif + +#if !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + int i, k, ret; + mbedtls_entropy_context entropy; + unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; + + if( argc < 2 ) + { + mbedtls_fprintf( stderr, "usage: %s \n", argv[0] ); + return( 1 ); + } + + if( ( f = fopen( argv[1], "wb+" ) ) == NULL ) + { + mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] ); + return( 1 ); + } + + mbedtls_entropy_init( &entropy ); + + for( i = 0, k = 768; i < k; i++ ) + { + ret = mbedtls_entropy_func( &entropy, buf, sizeof( buf ) ); + if( ret != 0 ) + { + mbedtls_printf("failed!\n"); + goto cleanup; + } + + fwrite( buf, 1, sizeof( buf ), f ); + + mbedtls_printf( "Generating %ldkb of data in file '%s'... %04.1f" \ + "%% done\r", (long)(sizeof(buf) * k / 1024), argv[1], (100 * (float) (i + 1)) / k ); + fflush( stdout ); + } + + ret = 0; + +cleanup: + mbedtls_printf( "\n" ); + + fclose( f ); + mbedtls_entropy_free( &entropy ); + + return( ret ); +} +#endif /* MBEDTLS_ENTROPY_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_ctr_drbg.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_ctr_drbg.c new file mode 100644 index 0000000..c76f99d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_ctr_drbg.c @@ -0,0 +1,130 @@ +/** + * \brief Use and generate random data into a file via the CTR_DBRG based on AES + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_CTR_DRBG_C) && defined(MBEDTLS_ENTROPY_C) && \ + defined(MBEDTLS_FS_IO) +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#endif + +#if !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + int i, k, ret; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_entropy_context entropy; + unsigned char buf[1024]; + + mbedtls_ctr_drbg_init( &ctr_drbg ); + + if( argc < 2 ) + { + mbedtls_fprintf( stderr, "usage: %s \n", argv[0] ); + return( 1 ); + } + + if( ( f = fopen( argv[1], "wb+" ) ) == NULL ) + { + mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] ); + return( 1 ); + } + + mbedtls_entropy_init( &entropy ); + ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) "RANDOM_GEN", 10 ); + if( ret != 0 ) + { + mbedtls_printf( "failed in mbedtls_ctr_drbg_seed: %d\n", ret ); + goto cleanup; + } + mbedtls_ctr_drbg_set_prediction_resistance( &ctr_drbg, MBEDTLS_CTR_DRBG_PR_OFF ); + +#if defined(MBEDTLS_FS_IO) + ret = mbedtls_ctr_drbg_update_seed_file( &ctr_drbg, "seedfile" ); + + if( ret == MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR ) + { + mbedtls_printf( "Failed to open seedfile. Generating one.\n" ); + ret = mbedtls_ctr_drbg_write_seed_file( &ctr_drbg, "seedfile" ); + if( ret != 0 ) + { + mbedtls_printf( "failed in mbedtls_ctr_drbg_write_seed_file: %d\n", ret ); + goto cleanup; + } + } + else if( ret != 0 ) + { + mbedtls_printf( "failed in mbedtls_ctr_drbg_update_seed_file: %d\n", ret ); + goto cleanup; + } +#endif + + for( i = 0, k = 768; i < k; i++ ) + { + ret = mbedtls_ctr_drbg_random( &ctr_drbg, buf, sizeof( buf ) ); + if( ret != 0 ) + { + mbedtls_printf("failed!\n"); + goto cleanup; + } + + fwrite( buf, 1, sizeof( buf ), f ); + + mbedtls_printf( "Generating %ldkb of data in file '%s'... %04.1f" \ + "%% done\r", (long)(sizeof(buf) * k / 1024), argv[1], (100 * (float) (i + 1)) / k ); + fflush( stdout ); + } + + ret = 0; + +cleanup: + mbedtls_printf("\n"); + + fclose( f ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + + return( ret ); +} +#endif /* MBEDTLS_CTR_DRBG_C && MBEDTLS_ENTROPY_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_havege.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_havege.c new file mode 100644 index 0000000..6c31462 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/random/gen_random_havege.c @@ -0,0 +1,101 @@ +/** + * \brief Generate random data into a file + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_HAVEGE_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/havege.h" + +#include +#include +#endif + +#if !defined(MBEDTLS_HAVEGE_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_HAVEGE_C not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + FILE *f; + time_t t; + int i, k, ret = 0; + mbedtls_havege_state hs; + unsigned char buf[1024]; + + if( argc < 2 ) + { + mbedtls_fprintf( stderr, "usage: %s \n", argv[0] ); + return( 1 ); + } + + if( ( f = fopen( argv[1], "wb+" ) ) == NULL ) + { + mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] ); + return( 1 ); + } + + mbedtls_havege_init( &hs ); + + t = time( NULL ); + + for( i = 0, k = 768; i < k; i++ ) + { + if( mbedtls_havege_random( &hs, buf, sizeof( buf ) ) != 0 ) + { + mbedtls_printf( "Failed to get random from source.\n" ); + + ret = 1; + goto exit; + } + + fwrite( buf, sizeof( buf ), 1, f ); + + mbedtls_printf( "Generating %ldkb of data in file '%s'... %04.1f" \ + "%% done\r", (long)(sizeof(buf) * k / 1024), argv[1], (100 * (float) (i + 1)) / k ); + fflush( stdout ); + } + + if( t == time( NULL ) ) + t--; + + mbedtls_printf(" \n "); + +exit: + mbedtls_havege_free( &hs ); + fclose( f ); + return( ret ); +} +#endif /* MBEDTLS_HAVEGE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/CMakeLists.txt new file mode 100644 index 0000000..1e65633 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/CMakeLists.txt @@ -0,0 +1,62 @@ +set(THREADS_USE_PTHREADS_WIN32 true) +find_package(Threads) + +set(libs + mbedtls +) + +set(targets + dtls_client + dtls_server + ssl_client1 + ssl_client2 + ssl_server + ssl_fork_server + ssl_mail_client + mini_client +) + +if(USE_PKCS11_HELPER_LIBRARY) + set(libs ${libs} pkcs11-helper) +endif(USE_PKCS11_HELPER_LIBRARY) + +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + +add_executable(dtls_client dtls_client.c) +target_link_libraries(dtls_client ${libs}) + +add_executable(dtls_server dtls_server.c) +target_link_libraries(dtls_server ${libs}) + +add_executable(ssl_client1 ssl_client1.c) +target_link_libraries(ssl_client1 ${libs}) + +add_executable(ssl_client2 ssl_client2.c) +target_link_libraries(ssl_client2 ${libs}) + +add_executable(ssl_server ssl_server.c) +target_link_libraries(ssl_server ${libs}) + +add_executable(ssl_server2 ssl_server2.c) +target_link_libraries(ssl_server2 ${libs}) + +add_executable(ssl_fork_server ssl_fork_server.c) +target_link_libraries(ssl_fork_server ${libs}) + +add_executable(ssl_mail_client ssl_mail_client.c) +target_link_libraries(ssl_mail_client ${libs}) + +add_executable(mini_client mini_client.c) +target_link_libraries(mini_client ${libs}) + +if(THREADS_FOUND) + add_executable(ssl_pthread_server ssl_pthread_server.c) + target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT}) + set(targets ${targets} ssl_pthread_server) +endif(THREADS_FOUND) + +install(TARGETS ${targets} + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_client.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_client.c new file mode 100644 index 0000000..e18ee42 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_client.c @@ -0,0 +1,350 @@ +/* + * Simple DTLS client demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define mbedtls_fprintf fprintf +#endif + +#if !defined(MBEDTLS_SSL_CLI_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_TIMING_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) +int main( void ) +{ + mbedtls_printf( "MBEDTLS_SSL_CLI_C and/or MBEDTLS_SSL_PROTO_DTLS and/or " + "MBEDTLS_NET_C and/or MBEDTLS_TIMING_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " + "MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined.\n" ); + return( 0 ); +} +#else + +#include + +#include "mbedtls/net_sockets.h" +#include "mbedtls/debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/error.h" +#include "mbedtls/certs.h" +#include "mbedtls/timing.h" + +#define SERVER_PORT "4433" +#define SERVER_NAME "localhost" +#define SERVER_ADDR "127.0.0.1" /* forces IPv4 */ +#define MESSAGE "Echo this" + +#define READ_TIMEOUT_MS 1000 +#define MAX_RETRY 5 + +#define DEBUG_LEVEL 0 + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +int main( int argc, char *argv[] ) +{ + int ret, len; + mbedtls_net_context server_fd; + uint32_t flags; + unsigned char buf[1024]; + const char *pers = "dtls_client"; + int retry_left = MAX_RETRY; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt cacert; + mbedtls_timing_delay_context timer; + + ((void) argc); + ((void) argv); + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( DEBUG_LEVEL ); +#endif + + /* + * 0. Initialize the RNG and the session data + */ + mbedtls_net_init( &server_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + mbedtls_x509_crt_init( &cacert ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 0. Load certificates + */ + mbedtls_printf( " . Loading the CA root certificate ..." ); + fflush( stdout ); + + ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok (%d skipped)\n", ret ); + + /* + * 1. Start the connection + */ + mbedtls_printf( " . Connecting to udp/%s/%s...", SERVER_NAME, SERVER_PORT ); + fflush( stdout ); + + if( ( ret = mbedtls_net_connect( &server_fd, SERVER_ADDR, + SERVER_PORT, MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 2. Setup stuff + */ + mbedtls_printf( " . Setting up the DTLS structure..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_DATAGRAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + /* OPTIONAL is usually a bad choice for security, but makes interop easier + * in this simplified example, in which the ca chain is hardcoded. + * Production code should set a proper ca chain and use REQUIRED. */ + mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); + mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_set_hostname( &ssl, SERVER_NAME ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &server_fd, + mbedtls_net_send, mbedtls_net_recv, mbedtls_net_recv_timeout ); + + mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, + mbedtls_timing_get_delay ); + + mbedtls_printf( " ok\n" ); + + /* + * 4. Handshake + */ + mbedtls_printf( " . Performing the SSL/TLS handshake..." ); + fflush( stdout ); + + do ret = mbedtls_ssl_handshake( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 5. Verify the server certificate + */ + mbedtls_printf( " . Verifying peer X.509 certificate..." ); + + /* In real life, we would have used MBEDTLS_SSL_VERIFY_REQUIRED so that the + * handshake would not succeed if the peer's cert is bad. Even if we used + * MBEDTLS_SSL_VERIFY_OPTIONAL, we would bail out here if ret != 0 */ + if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 ) + { + char vrfy_buf[512]; + + mbedtls_printf( " failed\n" ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } + else + mbedtls_printf( " ok\n" ); + + /* + * 6. Write the echo request + */ +send_request: + mbedtls_printf( " > Write to server:" ); + fflush( stdout ); + + len = sizeof( MESSAGE ) - 1; + + do ret = mbedtls_ssl_write( &ssl, (unsigned char *) MESSAGE, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto exit; + } + + len = ret; + mbedtls_printf( " %d bytes written\n\n%s\n\n", len, MESSAGE ); + + /* + * 7. Read the echo response + */ + mbedtls_printf( " < Read from server:" ); + fflush( stdout ); + + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + + do ret = mbedtls_ssl_read( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_TIMEOUT: + mbedtls_printf( " timeout\n\n" ); + if( retry_left-- > 0 ) + goto send_request; + goto exit; + + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " connection was closed gracefully\n" ); + ret = 0; + goto close_notify; + + default: + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n\n", -ret ); + goto exit; + } + } + + len = ret; + mbedtls_printf( " %d bytes read\n\n%s\n\n", len, buf ); + + /* + * 8. Done, cleanly close the connection + */ +close_notify: + mbedtls_printf( " . Closing the connection..." ); + + /* No error checking, the connection might be closed already */ + do ret = mbedtls_ssl_close_notify( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + ret = 0; + + mbedtls_printf( " done\n" ); + + /* + * 9. Final clean-ups and exit + */ +exit: + +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf( "Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &server_fd ); + + mbedtls_x509_crt_free( &cacert ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + /* Shell can not handle large exit numbers -> 1 for errors */ + if( ret < 0 ) + ret = 1; + + return( ret ); +} +#endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_SSL_PROTO_DTLS && MBEDTLS_NET_C && + MBEDTLD_TIMING_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && + MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_RSA_C && MBEDTLS_CERTS_C && + MBEDTLS_PEM_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_server.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_server.c new file mode 100644 index 0000000..9d0dda4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/dtls_server.c @@ -0,0 +1,425 @@ +/* + * Simple DTLS server demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define mbedtls_fprintf fprintf +#define mbedtls_time_t time_t +#endif + +#if !defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \ + !defined(MBEDTLS_SSL_COOKIE_C) || !defined(MBEDTLS_NET_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \ + !defined(MBEDTLS_TIMING_C) + +int main( void ) +{ + printf( "MBEDTLS_SSL_SRV_C and/or MBEDTLS_SSL_PROTO_DTLS and/or " + "MBEDTLS_SSL_COOKIE_C and/or MBEDTLS_NET_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " + "MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C and/or " + "MBEDTLS_TIMING_C not defined.\n" ); + return( 0 ); +} +#else + +#if defined(_WIN32) +#include +#endif + +#include +#include +#include + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/error.h" +#include "mbedtls/debug.h" +#include "mbedtls/timing.h" + +#if defined(MBEDTLS_SSL_CACHE_C) +#include "mbedtls/ssl_cache.h" +#endif + +#define READ_TIMEOUT_MS 10000 /* 5 seconds */ +#define DEBUG_LEVEL 0 + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +int main( void ) +{ + int ret, len; + mbedtls_net_context listen_fd, client_fd; + unsigned char buf[1024]; + const char *pers = "dtls_server"; + unsigned char client_ip[16] = { 0 }; + size_t cliip_len; + mbedtls_ssl_cookie_ctx cookie_ctx; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt srvcert; + mbedtls_pk_context pkey; + mbedtls_timing_delay_context timer; +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_context cache; +#endif + + mbedtls_net_init( &listen_fd ); + mbedtls_net_init( &client_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + mbedtls_ssl_cookie_init( &cookie_ctx ); +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_init( &cache ); +#endif + mbedtls_x509_crt_init( &srvcert ); + mbedtls_pk_init( &pkey ); + mbedtls_entropy_init( &entropy ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( DEBUG_LEVEL ); +#endif + + /* + * 1. Load the certificates and private RSA key + */ + printf( "\n . Loading the server cert. and key..." ); + fflush( stdout ); + + /* + * This demonstration program uses embedded test certificates. + * Instead, you may want to use mbedtls_x509_crt_parse_file() to read the + * server and CA certificates, as well as mbedtls_pk_parse_keyfile(). + */ + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_srv_crt, + mbedtls_test_srv_crt_len ); + if( ret != 0 ) + { + printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); + if( ret != 0 ) + { + printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key, + mbedtls_test_srv_key_len, NULL, 0 ); + if( ret != 0 ) + { + printf( " failed\n ! mbedtls_pk_parse_key returned %d\n\n", ret ); + goto exit; + } + + printf( " ok\n" ); + + /* + * 2. Setup the "listening" UDP socket + */ + printf( " . Bind on udp/*/4433 ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_bind( &listen_fd, NULL, "4433", MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + { + printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret ); + goto exit; + } + + printf( " ok\n" ); + + /* + * 3. Seed the RNG + */ + printf( " . Seeding the random number generator..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + printf( " ok\n" ); + + /* + * 4. Setup stuff + */ + printf( " . Setting up the DTLS data..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_SERVER, + MBEDTLS_SSL_TRANSPORT_DATAGRAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_conf_session_cache( &conf, &cache, + mbedtls_ssl_cache_get, + mbedtls_ssl_cache_set ); +#endif + + mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) + { + printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_cookie_setup( &cookie_ctx, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + printf( " failed\n ! mbedtls_ssl_cookie_setup returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_conf_dtls_cookies( &conf, mbedtls_ssl_cookie_write, mbedtls_ssl_cookie_check, + &cookie_ctx ); + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, + mbedtls_timing_get_delay ); + + printf( " ok\n" ); + +reset: +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + printf("Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &client_fd ); + + mbedtls_ssl_session_reset( &ssl ); + + /* + * 3. Wait until a client connects + */ + printf( " . Waiting for a remote connection ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd, + client_ip, sizeof( client_ip ), &cliip_len ) ) != 0 ) + { + printf( " failed\n ! mbedtls_net_accept returned %d\n\n", ret ); + goto exit; + } + + /* For HelloVerifyRequest cookies */ + if( ( ret = mbedtls_ssl_set_client_transport_id( &ssl, + client_ip, cliip_len ) ) != 0 ) + { + printf( " failed\n ! " + "mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &client_fd, + mbedtls_net_send, mbedtls_net_recv, mbedtls_net_recv_timeout ); + + printf( " ok\n" ); + + /* + * 5. Handshake + */ + printf( " . Performing the DTLS handshake..." ); + fflush( stdout ); + + do ret = mbedtls_ssl_handshake( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ) + { + printf( " hello verification requested\n" ); + ret = 0; + goto reset; + } + else if( ret != 0 ) + { + printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + goto reset; + } + + printf( " ok\n" ); + + /* + * 6. Read the echo Request + */ + printf( " < Read from client:" ); + fflush( stdout ); + + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + + do ret = mbedtls_ssl_read( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_TIMEOUT: + printf( " timeout\n\n" ); + goto reset; + + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + printf( " connection was closed gracefully\n" ); + ret = 0; + goto close_notify; + + default: + printf( " mbedtls_ssl_read returned -0x%x\n\n", -ret ); + goto reset; + } + } + + len = ret; + printf( " %d bytes read\n\n%s\n\n", len, buf ); + + /* + * 7. Write the 200 Response + */ + printf( " > Write to client:" ); + fflush( stdout ); + + do ret = mbedtls_ssl_write( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret < 0 ) + { + printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto exit; + } + + len = ret; + printf( " %d bytes written\n\n%s\n\n", len, buf ); + + /* + * 8. Done, cleanly close the connection + */ +close_notify: + printf( " . Closing the connection..." ); + + /* No error checking, the connection might be closed already */ + do ret = mbedtls_ssl_close_notify( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + ret = 0; + + printf( " done\n" ); + + goto reset; + + /* + * Final clean-ups and exit + */ +exit: + +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + printf( "Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); + + mbedtls_x509_crt_free( &srvcert ); + mbedtls_pk_free( &pkey ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ssl_cookie_free( &cookie_ctx ); +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_free( &cache ); +#endif + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + /* Shell can not handle large exit numbers -> 1 for errors */ + if( ret < 0 ) + ret = 1; + + return( ret ); +} +#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_PROTO_DTLS && + MBEDTLS_SSL_COOKIE_C && MBEDTLS_NET_C && MBEDTLS_ENTROPY_C && + MBEDTLS_CTR_DRBG_C && MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_RSA_C + && MBEDTLS_CERTS_C && MBEDTLS_PEM_PARSE_C && MBEDTLS_TIMING_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/mini_client.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/mini_client.c new file mode 100644 index 0000000..290455e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/mini_client.c @@ -0,0 +1,302 @@ +/* + * Minimal SSL client, used for memory measurements. + * (meant to be used with config-suite-b.h or config-ccm-psk-tls1_2.h) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +/* + * We're creating and connecting the socket "manually" rather than using the + * NET module, in order to avoid the overhead of getaddrinfo() which tends to + * dominate memory usage in small configurations. For the sake of simplicity, + * only a Unix version is implemented. + * + * Warning: we are breaking some of the abtractions from the NET layer here. + * This is not a good example for general use. This programs has the specific + * goal of minimizing use of the libc functions on full-blown OSes. + */ +#if defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__) +#define UNIX +#endif + +#if !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_SSL_CLI_C) || \ + !defined(UNIX) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +int main( void ) +{ + mbedtls_printf( "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_SSL_CLI_C and/or UNIX " + "not defined.\n"); + return( 0 ); +} +#else + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#endif + +#include + +#include "mbedtls/net_sockets.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include +#include + +/* + * Hardcoded values for server host and port + */ +#define PORT_BE 0x1151 /* 4433 */ +#define PORT_LE 0x5111 +#define ADDR_BE 0x7f000001 /* 127.0.0.1 */ +#define ADDR_LE 0x0100007f +#define HOSTNAME "localhost" /* for cert verification if enabled */ + +#define GET_REQUEST "GET / HTTP/1.0\r\n\r\n" + +const char *pers = "mini_client"; + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +const unsigned char psk[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f +}; +const char psk_id[] = "Client_identity"; +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/* This is tests/data_files/test-ca2.crt, a CA using EC secp384r1 */ +const unsigned char ca_cert[] = { + 0x30, 0x82, 0x02, 0x52, 0x30, 0x82, 0x01, 0xd7, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x09, 0x00, 0xc1, 0x43, 0xe2, 0x7e, 0x62, 0x43, 0xcc, 0xe8, + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, + 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, + 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, + 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, + 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, + 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, + 0x43, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, 0x39, + 0x32, 0x34, 0x31, 0x35, 0x34, 0x39, 0x34, 0x38, 0x5a, 0x17, 0x0d, 0x32, + 0x33, 0x30, 0x39, 0x32, 0x32, 0x31, 0x35, 0x34, 0x39, 0x34, 0x38, 0x5a, + 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, + 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, + 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, + 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, + 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, + 0x43, 0x20, 0x43, 0x41, 0x30, 0x76, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, + 0x03, 0x62, 0x00, 0x04, 0xc3, 0xda, 0x2b, 0x34, 0x41, 0x37, 0x58, 0x2f, + 0x87, 0x56, 0xfe, 0xfc, 0x89, 0xba, 0x29, 0x43, 0x4b, 0x4e, 0xe0, 0x6e, + 0xc3, 0x0e, 0x57, 0x53, 0x33, 0x39, 0x58, 0xd4, 0x52, 0xb4, 0x91, 0x95, + 0x39, 0x0b, 0x23, 0xdf, 0x5f, 0x17, 0x24, 0x62, 0x48, 0xfc, 0x1a, 0x95, + 0x29, 0xce, 0x2c, 0x2d, 0x87, 0xc2, 0x88, 0x52, 0x80, 0xaf, 0xd6, 0x6a, + 0xab, 0x21, 0xdd, 0xb8, 0xd3, 0x1c, 0x6e, 0x58, 0xb8, 0xca, 0xe8, 0xb2, + 0x69, 0x8e, 0xf3, 0x41, 0xad, 0x29, 0xc3, 0xb4, 0x5f, 0x75, 0xa7, 0x47, + 0x6f, 0xd5, 0x19, 0x29, 0x55, 0x69, 0x9a, 0x53, 0x3b, 0x20, 0xb4, 0x66, + 0x16, 0x60, 0x33, 0x1e, 0xa3, 0x81, 0xa0, 0x30, 0x81, 0x9d, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x9d, 0x6d, 0x20, + 0x24, 0x49, 0x01, 0x3f, 0x2b, 0xcb, 0x78, 0xb5, 0x19, 0xbc, 0x7e, 0x24, + 0xc9, 0xdb, 0xfb, 0x36, 0x7c, 0x30, 0x6e, 0x06, 0x03, 0x55, 0x1d, 0x23, + 0x04, 0x67, 0x30, 0x65, 0x80, 0x14, 0x9d, 0x6d, 0x20, 0x24, 0x49, 0x01, + 0x3f, 0x2b, 0xcb, 0x78, 0xb5, 0x19, 0xbc, 0x7e, 0x24, 0xc9, 0xdb, 0xfb, + 0x36, 0x7c, 0xa1, 0x42, 0xa4, 0x40, 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, + 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, + 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, + 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, + 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x43, 0x20, 0x43, 0x41, 0x82, 0x09, + 0x00, 0xc1, 0x43, 0xe2, 0x7e, 0x62, 0x43, 0xcc, 0xe8, 0x30, 0x0c, 0x06, + 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, + 0x69, 0x00, 0x30, 0x66, 0x02, 0x31, 0x00, 0xc3, 0xb4, 0x62, 0x73, 0x56, + 0x28, 0x95, 0x00, 0x7d, 0x78, 0x12, 0x26, 0xd2, 0x71, 0x7b, 0x19, 0xf8, + 0x8a, 0x98, 0x3e, 0x92, 0xfe, 0x33, 0x9e, 0xe4, 0x79, 0xd2, 0xfe, 0x7a, + 0xb7, 0x87, 0x74, 0x3c, 0x2b, 0xb8, 0xd7, 0x69, 0x94, 0x0b, 0xa3, 0x67, + 0x77, 0xb8, 0xb3, 0xbe, 0xd1, 0x36, 0x32, 0x02, 0x31, 0x00, 0xfd, 0x67, + 0x9c, 0x94, 0x23, 0x67, 0xc0, 0x56, 0xba, 0x4b, 0x33, 0x15, 0x00, 0xc6, + 0xe3, 0xcc, 0x31, 0x08, 0x2c, 0x9c, 0x8b, 0xda, 0xa9, 0x75, 0x23, 0x2f, + 0xb8, 0x28, 0xe7, 0xf2, 0x9c, 0x14, 0x3a, 0x40, 0x01, 0x5c, 0xaf, 0x0c, + 0xb2, 0xcf, 0x74, 0x7f, 0x30, 0x9f, 0x08, 0x43, 0xad, 0x20, +}; +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +enum exit_codes +{ + exit_ok = 0, + ctr_drbg_seed_failed, + ssl_config_defaults_failed, + ssl_setup_failed, + hostname_failed, + socket_failed, + connect_failed, + x509_crt_parse_failed, + ssl_handshake_failed, + ssl_write_failed, +}; + +int main( void ) +{ + int ret = exit_ok; + mbedtls_net_context server_fd; + struct sockaddr_in addr; +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt ca; +#endif + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_ctr_drbg_init( &ctr_drbg ); + + /* + * 0. Initialize and setup stuff + */ + mbedtls_net_init( &server_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt_init( &ca ); +#endif + + mbedtls_entropy_init( &entropy ); + if( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, strlen( pers ) ) != 0 ) + { + ret = ctr_drbg_seed_failed; + goto exit; + } + + if( mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) != 0 ) + { + ret = ssl_config_defaults_failed; + goto exit; + } + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + mbedtls_ssl_conf_psk( &conf, psk, sizeof( psk ), + (const unsigned char *) psk_id, sizeof( psk_id ) - 1 ); +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( mbedtls_x509_crt_parse_der( &ca, ca_cert, sizeof( ca_cert ) ) != 0 ) + { + ret = x509_crt_parse_failed; + goto exit; + } + + mbedtls_ssl_conf_ca_chain( &conf, &ca, NULL ); + mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_REQUIRED ); +#endif + + if( mbedtls_ssl_setup( &ssl, &conf ) != 0 ) + { + ret = ssl_setup_failed; + goto exit; + } + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( mbedtls_ssl_set_hostname( &ssl, HOSTNAME ) != 0 ) + { + ret = hostname_failed; + goto exit; + } +#endif + + /* + * 1. Start the connection + */ + memset( &addr, 0, sizeof( addr ) ); + addr.sin_family = AF_INET; + + ret = 1; /* for endianness detection */ + addr.sin_port = *((char *) &ret) == ret ? PORT_LE : PORT_BE; + addr.sin_addr.s_addr = *((char *) &ret) == ret ? ADDR_LE : ADDR_BE; + ret = 0; + + if( ( server_fd.fd = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) + { + ret = socket_failed; + goto exit; + } + + if( connect( server_fd.fd, + (const struct sockaddr *) &addr, sizeof( addr ) ) < 0 ) + { + ret = connect_failed; + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + if( mbedtls_ssl_handshake( &ssl ) != 0 ) + { + ret = ssl_handshake_failed; + goto exit; + } + + /* + * 2. Write the GET request and close the connection + */ + if( mbedtls_ssl_write( &ssl, (const unsigned char *) GET_REQUEST, + sizeof( GET_REQUEST ) - 1 ) <= 0 ) + { + ret = ssl_write_failed; + goto exit; + } + + mbedtls_ssl_close_notify( &ssl ); + +exit: + mbedtls_net_free( &server_fd ); + + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt_free( &ca ); +#endif + + return( ret ); +} +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client1.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client1.c new file mode 100644 index 0000000..fa70431 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client1.c @@ -0,0 +1,313 @@ +/* + * SSL client demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \ + !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C " + "not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/net_sockets.h" +#include "mbedtls/debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/error.h" +#include "mbedtls/certs.h" + +#include + +#define SERVER_PORT "4433" +#define SERVER_NAME "localhost" +#define GET_REQUEST "GET / HTTP/1.0\r\n\r\n" + +#define DEBUG_LEVEL 1 + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +int main( void ) +{ + int ret, len; + mbedtls_net_context server_fd; + uint32_t flags; + unsigned char buf[1024]; + const char *pers = "ssl_client1"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt cacert; + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( DEBUG_LEVEL ); +#endif + + /* + * 0. Initialize the RNG and the session data + */ + mbedtls_net_init( &server_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + mbedtls_x509_crt_init( &cacert ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 0. Initialize certificates + */ + mbedtls_printf( " . Loading the CA root certificate ..." ); + fflush( stdout ); + + ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok (%d skipped)\n", ret ); + + /* + * 1. Start the connection + */ + mbedtls_printf( " . Connecting to tcp/%s/%s...", SERVER_NAME, SERVER_PORT ); + fflush( stdout ); + + if( ( ret = mbedtls_net_connect( &server_fd, SERVER_NAME, + SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 2. Setup stuff + */ + mbedtls_printf( " . Setting up the SSL/TLS structure..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* OPTIONAL is not optimal for security, + * but makes interop easier in this simplified example */ + mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); + mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_set_hostname( &ssl, SERVER_NAME ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + /* + * 4. Handshake + */ + mbedtls_printf( " . Performing the SSL/TLS handshake..." ); + fflush( stdout ); + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + goto exit; + } + } + + mbedtls_printf( " ok\n" ); + + /* + * 5. Verify the server certificate + */ + mbedtls_printf( " . Verifying peer X.509 certificate..." ); + + /* In real life, we probably want to bail out when ret != 0 */ + if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 ) + { + char vrfy_buf[512]; + + mbedtls_printf( " failed\n" ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } + else + mbedtls_printf( " ok\n" ); + + /* + * 3. Write the GET request + */ + mbedtls_printf( " > Write to server:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, GET_REQUEST ); + + while( ( ret = mbedtls_ssl_write( &ssl, buf, len ) ) <= 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto exit; + } + } + + len = ret; + mbedtls_printf( " %d bytes written\n\n%s", len, (char *) buf ); + + /* + * 7. Read the HTTP response + */ + mbedtls_printf( " < Read from server:" ); + fflush( stdout ); + + do + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + ret = mbedtls_ssl_read( &ssl, buf, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY ) + break; + + if( ret < 0 ) + { + mbedtls_printf( "failed\n ! mbedtls_ssl_read returned %d\n\n", ret ); + break; + } + + if( ret == 0 ) + { + mbedtls_printf( "\n\nEOF\n\n" ); + break; + } + + len = ret; + mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf ); + } + while( 1 ); + + mbedtls_ssl_close_notify( &ssl ); + +exit: + +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf("Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &server_fd ); + + mbedtls_x509_crt_free( &cacert ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && + MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && + MBEDTLS_CERTS_C && MBEDTLS_PEM_PARSE_C && MBEDTLS_CTR_DRBG_C && + MBEDTLS_X509_CRT_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client2.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client2.c new file mode 100644 index 0000000..a1d71e1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_client2.c @@ -0,0 +1,1673 @@ +/* + * SSL client with certificate authentication + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_printf printf +#define mbedtls_fprintf fprintf +#define mbedtls_snprintf snprintf +#endif + +#if !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/net_sockets.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" +#include "mbedtls/error.h" +#include "mbedtls/debug.h" +#include "mbedtls/timing.h" + +#include +#include +#include + +#define DFL_SERVER_NAME "localhost" +#define DFL_SERVER_ADDR NULL +#define DFL_SERVER_PORT "4433" +#define DFL_REQUEST_PAGE "/" +#define DFL_REQUEST_SIZE -1 +#define DFL_DEBUG_LEVEL 0 +#define DFL_NBIO 0 +#define DFL_READ_TIMEOUT 0 +#define DFL_MAX_RESEND 0 +#define DFL_CA_FILE "" +#define DFL_CA_PATH "" +#define DFL_CRT_FILE "" +#define DFL_KEY_FILE "" +#define DFL_PSK "" +#define DFL_PSK_IDENTITY "Client_identity" +#define DFL_ECJPAKE_PW NULL +#define DFL_FORCE_CIPHER 0 +#define DFL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION_DISABLED +#define DFL_ALLOW_LEGACY -2 +#define DFL_RENEGOTIATE 0 +#define DFL_EXCHANGES 1 +#define DFL_MIN_VERSION -1 +#define DFL_MAX_VERSION -1 +#define DFL_ARC4 -1 +#define DFL_AUTH_MODE -1 +#define DFL_MFL_CODE MBEDTLS_SSL_MAX_FRAG_LEN_NONE +#define DFL_TRUNC_HMAC -1 +#define DFL_RECSPLIT -1 +#define DFL_DHMLEN -1 +#define DFL_RECONNECT 0 +#define DFL_RECO_DELAY 0 +#define DFL_RECONNECT_HARD 0 +#define DFL_TICKETS MBEDTLS_SSL_SESSION_TICKETS_ENABLED +#define DFL_ALPN_STRING NULL +#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM +#define DFL_HS_TO_MIN 0 +#define DFL_HS_TO_MAX 0 +#define DFL_FALLBACK -1 +#define DFL_EXTENDED_MS -1 +#define DFL_ETM -1 + +#define GET_REQUEST "GET %s HTTP/1.0\r\nExtra-header: " +#define GET_REQUEST_END "\r\n\r\n" + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +#if defined(MBEDTLS_FS_IO) +#define USAGE_IO \ + " ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \ + " default: \"\" (pre-loaded)\n" \ + " ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \ + " default: \"\" (pre-loaded) (overrides ca_file)\n" \ + " crt_file=%%s Your own cert and chain (in bottom to top order, top may be omitted)\n" \ + " default: \"\" (pre-loaded)\n" \ + " key_file=%%s default: \"\" (pre-loaded)\n" +#else +#define USAGE_IO \ + " No file operations available (MBEDTLS_FS_IO not defined)\n" +#endif /* MBEDTLS_FS_IO */ +#else +#define USAGE_IO "" +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +#define USAGE_PSK \ + " psk=%%s default: \"\" (in hex, without 0x)\n" \ + " psk_identity=%%s default: \"Client_identity\"\n" +#else +#define USAGE_PSK "" +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +#define USAGE_TICKETS \ + " tickets=%%d default: 1 (enabled)\n" +#else +#define USAGE_TICKETS "" +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +#define USAGE_TRUNC_HMAC \ + " trunc_hmac=%%d default: library default\n" +#else +#define USAGE_TRUNC_HMAC "" +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +#define USAGE_MAX_FRAG_LEN \ + " max_frag_len=%%d default: 16384 (tls default)\n" \ + " options: 512, 1024, 2048, 4096\n" +#else +#define USAGE_MAX_FRAG_LEN "" +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) +#define USAGE_RECSPLIT \ + " recsplit=0/1 default: (library default: on)\n" +#else +#define USAGE_RECSPLIT +#endif + +#if defined(MBEDTLS_DHM_C) +#define USAGE_DHMLEN \ + " dhmlen=%%d default: (library default: 1024 bits)\n" +#else +#define USAGE_DHMLEN +#endif + +#if defined(MBEDTLS_SSL_ALPN) +#define USAGE_ALPN \ + " alpn=%%s default: \"\" (disabled)\n" \ + " example: spdy/1,http/1.1\n" +#else +#define USAGE_ALPN "" +#endif /* MBEDTLS_SSL_ALPN */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +#define USAGE_DTLS \ + " dtls=%%d default: 0 (TLS)\n" \ + " hs_timeout=%%d-%%d default: (library default: 1000-60000)\n" \ + " range of DTLS handshake timeouts in millisecs\n" +#else +#define USAGE_DTLS "" +#endif + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) +#define USAGE_FALLBACK \ + " fallback=0/1 default: (library default: off)\n" +#else +#define USAGE_FALLBACK "" +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +#define USAGE_EMS \ + " extended_ms=0/1 default: (library default: on)\n" +#else +#define USAGE_EMS "" +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +#define USAGE_ETM \ + " etm=0/1 default: (library default: on)\n" +#else +#define USAGE_ETM "" +#endif + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +#define USAGE_RENEGO \ + " renegotiation=%%d default: 0 (disabled)\n" \ + " renegotiate=%%d default: 0 (disabled)\n" +#else +#define USAGE_RENEGO "" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +#define USAGE_ECJPAKE \ + " ecjpake_pw=%%s default: none (disabled)\n" +#else +#define USAGE_ECJPAKE "" +#endif + +#define USAGE \ + "\n usage: ssl_client2 param=<>...\n" \ + "\n acceptable parameters:\n" \ + " server_name=%%s default: localhost\n" \ + " server_addr=%%s default: given by name\n" \ + " server_port=%%d default: 4433\n" \ + " request_page=%%s default: \".\"\n" \ + " request_size=%%d default: about 34 (basic request)\n" \ + " (minimum: 0, max: 16384)\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ + " nbio=%%d default: 0 (blocking I/O)\n" \ + " options: 1 (non-blocking), 2 (added delays)\n" \ + " read_timeout=%%d default: 0 ms (no timeout)\n" \ + " max_resend=%%d default: 0 (no resend on timeout)\n" \ + "\n" \ + USAGE_DTLS \ + "\n" \ + " auth_mode=%%s default: (library default: none)\n" \ + " options: none, optional, required\n" \ + USAGE_IO \ + "\n" \ + USAGE_PSK \ + USAGE_ECJPAKE \ + "\n" \ + " allow_legacy=%%d default: (library default: no)\n" \ + USAGE_RENEGO \ + " exchanges=%%d default: 1\n" \ + " reconnect=%%d default: 0 (disabled)\n" \ + " reco_delay=%%d default: 0 seconds\n" \ + " reconnect_hard=%%d default: 0 (disabled)\n" \ + USAGE_TICKETS \ + USAGE_MAX_FRAG_LEN \ + USAGE_TRUNC_HMAC \ + USAGE_ALPN \ + USAGE_FALLBACK \ + USAGE_EMS \ + USAGE_ETM \ + USAGE_RECSPLIT \ + USAGE_DHMLEN \ + "\n" \ + " arc4=%%d default: (library default: 0)\n" \ + " min_version=%%s default: (library default: tls1)\n" \ + " max_version=%%s default: (library default: tls1_2)\n" \ + " force_version=%%s default: \"\" (none)\n" \ + " options: ssl3, tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \ + "\n" \ + " force_ciphersuite= default: all enabled\n"\ + " acceptable ciphersuite names:\n" + +/* + * global options + */ +struct options +{ + const char *server_name; /* hostname of the server (client only) */ + const char *server_addr; /* address of the server (client only) */ + const char *server_port; /* port on which the ssl service runs */ + int debug_level; /* level of debugging */ + int nbio; /* should I/O be blocking? */ + uint32_t read_timeout; /* timeout on mbedtls_ssl_read() in milliseconds */ + int max_resend; /* DTLS times to resend on read timeout */ + const char *request_page; /* page on server to request */ + int request_size; /* pad request with header to requested size */ + const char *ca_file; /* the file with the CA certificate(s) */ + const char *ca_path; /* the path with the CA certificate(s) reside */ + const char *crt_file; /* the file with the client certificate */ + const char *key_file; /* the file with the client key */ + const char *psk; /* the pre-shared key */ + const char *psk_identity; /* the pre-shared key identity */ + const char *ecjpake_pw; /* the EC J-PAKE password */ + int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ + int renegotiation; /* enable / disable renegotiation */ + int allow_legacy; /* allow legacy renegotiation */ + int renegotiate; /* attempt renegotiation? */ + int renego_delay; /* delay before enforcing renegotiation */ + int exchanges; /* number of data exchanges */ + int min_version; /* minimum protocol version accepted */ + int max_version; /* maximum protocol version accepted */ + int arc4; /* flag for arc4 suites support */ + int auth_mode; /* verify mode for connection */ + unsigned char mfl_code; /* code for maximum fragment length */ + int trunc_hmac; /* negotiate truncated hmac or not */ + int recsplit; /* enable record splitting? */ + int dhmlen; /* minimum DHM params len in bits */ + int reconnect; /* attempt to resume session */ + int reco_delay; /* delay in seconds before resuming session */ + int reconnect_hard; /* unexpectedly reconnect from the same port */ + int tickets; /* enable / disable session tickets */ + const char *alpn_string; /* ALPN supported protocols */ + int transport; /* TLS or DTLS? */ + uint32_t hs_to_min; /* Initial value of DTLS handshake timer */ + uint32_t hs_to_max; /* Max value of DTLS handshake timer */ + int fallback; /* is this a fallback connection? */ + int extended_ms; /* negotiate extended master secret? */ + int etm; /* negotiate encrypt then mac? */ +} opt; + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + const char *p, *basename; + + /* Extract basename from file */ + for( p = basename = file; *p != '\0'; p++ ) + if( *p == '/' || *p == '\\' ) + basename = p + 1; + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str ); + fflush( (FILE *) ctx ); +} + +/* + * Test recv/send functions that make sure each try returns + * WANT_READ/WANT_WRITE at least once before sucesseding + */ +static int my_recv( void *ctx, unsigned char *buf, size_t len ) +{ + static int first_try = 1; + int ret; + + if( first_try ) + { + first_try = 0; + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + + ret = mbedtls_net_recv( ctx, buf, len ); + if( ret != MBEDTLS_ERR_SSL_WANT_READ ) + first_try = 1; /* Next call will be a new operation */ + return( ret ); +} + +static int my_send( void *ctx, const unsigned char *buf, size_t len ) +{ + static int first_try = 1; + int ret; + + if( first_try ) + { + first_try = 0; + return( MBEDTLS_ERR_SSL_WANT_WRITE ); + } + + ret = mbedtls_net_send( ctx, buf, len ); + if( ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + first_try = 1; /* Next call will be a new operation */ + return( ret ); +} + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/* + * Enabled if debug_level > 1 in code below + */ +static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags ) +{ + char buf[1024]; + ((void) data); + + mbedtls_printf( "\nVerify requested for (Depth %d):\n", depth ); + mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt ); + mbedtls_printf( "%s", buf ); + + if ( ( *flags ) == 0 ) + mbedtls_printf( " This certificate has no flags\n" ); + else + { + mbedtls_x509_crt_verify_info( buf, sizeof( buf ), " ! ", *flags ); + mbedtls_printf( "%s\n", buf ); + } + + return( 0 ); +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +int main( int argc, char *argv[] ) +{ + int ret = 0, len, tail_len, i, written, frags, retry_left; + mbedtls_net_context server_fd; + unsigned char buf[MBEDTLS_SSL_MAX_CONTENT_LEN + 1]; +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + unsigned char psk[MBEDTLS_PSK_MAX_LEN]; + size_t psk_len = 0; +#endif +#if defined(MBEDTLS_SSL_ALPN) + const char *alpn_list[10]; +#endif + const char *pers = "ssl_client2"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_ssl_session saved_session; +#if defined(MBEDTLS_TIMING_C) + mbedtls_timing_delay_context timer; +#endif +#if defined(MBEDTLS_X509_CRT_PARSE_C) + uint32_t flags; + mbedtls_x509_crt cacert; + mbedtls_x509_crt clicert; + mbedtls_pk_context pkey; +#endif + char *p, *q; + const int *list; + + /* + * Make sure memory references are valid. + */ + mbedtls_net_init( &server_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) ); + mbedtls_ctr_drbg_init( &ctr_drbg ); +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt_init( &cacert ); + mbedtls_x509_crt_init( &clicert ); + mbedtls_pk_init( &pkey ); +#endif +#if defined(MBEDTLS_SSL_ALPN) + memset( (void * ) alpn_list, 0, sizeof( alpn_list ) ); +#endif + + if( argc == 0 ) + { + usage: + if( ret == 0 ) + ret = 1; + + mbedtls_printf( USAGE ); + + list = mbedtls_ssl_list_ciphersuites(); + while( *list ) + { + mbedtls_printf(" %-42s", mbedtls_ssl_get_ciphersuite_name( *list ) ); + list++; + if( !*list ) + break; + mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name( *list ) ); + list++; + } + mbedtls_printf("\n"); + goto exit; + } + + opt.server_name = DFL_SERVER_NAME; + opt.server_addr = DFL_SERVER_ADDR; + opt.server_port = DFL_SERVER_PORT; + opt.debug_level = DFL_DEBUG_LEVEL; + opt.nbio = DFL_NBIO; + opt.read_timeout = DFL_READ_TIMEOUT; + opt.max_resend = DFL_MAX_RESEND; + opt.request_page = DFL_REQUEST_PAGE; + opt.request_size = DFL_REQUEST_SIZE; + opt.ca_file = DFL_CA_FILE; + opt.ca_path = DFL_CA_PATH; + opt.crt_file = DFL_CRT_FILE; + opt.key_file = DFL_KEY_FILE; + opt.psk = DFL_PSK; + opt.psk_identity = DFL_PSK_IDENTITY; + opt.ecjpake_pw = DFL_ECJPAKE_PW; + opt.force_ciphersuite[0]= DFL_FORCE_CIPHER; + opt.renegotiation = DFL_RENEGOTIATION; + opt.allow_legacy = DFL_ALLOW_LEGACY; + opt.renegotiate = DFL_RENEGOTIATE; + opt.exchanges = DFL_EXCHANGES; + opt.min_version = DFL_MIN_VERSION; + opt.max_version = DFL_MAX_VERSION; + opt.arc4 = DFL_ARC4; + opt.auth_mode = DFL_AUTH_MODE; + opt.mfl_code = DFL_MFL_CODE; + opt.trunc_hmac = DFL_TRUNC_HMAC; + opt.recsplit = DFL_RECSPLIT; + opt.dhmlen = DFL_DHMLEN; + opt.reconnect = DFL_RECONNECT; + opt.reco_delay = DFL_RECO_DELAY; + opt.reconnect_hard = DFL_RECONNECT_HARD; + opt.tickets = DFL_TICKETS; + opt.alpn_string = DFL_ALPN_STRING; + opt.transport = DFL_TRANSPORT; + opt.hs_to_min = DFL_HS_TO_MIN; + opt.hs_to_max = DFL_HS_TO_MAX; + opt.fallback = DFL_FALLBACK; + opt.extended_ms = DFL_EXTENDED_MS; + opt.etm = DFL_ETM; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "server_name" ) == 0 ) + opt.server_name = q; + else if( strcmp( p, "server_addr" ) == 0 ) + opt.server_addr = q; + else if( strcmp( p, "server_port" ) == 0 ) + opt.server_port = q; + else if( strcmp( p, "dtls" ) == 0 ) + { + int t = atoi( q ); + if( t == 0 ) + opt.transport = MBEDTLS_SSL_TRANSPORT_STREAM; + else if( t == 1 ) + opt.transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; + else + goto usage; + } + else if( strcmp( p, "debug_level" ) == 0 ) + { + opt.debug_level = atoi( q ); + if( opt.debug_level < 0 || opt.debug_level > 65535 ) + goto usage; + } + else if( strcmp( p, "nbio" ) == 0 ) + { + opt.nbio = atoi( q ); + if( opt.nbio < 0 || opt.nbio > 2 ) + goto usage; + } + else if( strcmp( p, "read_timeout" ) == 0 ) + opt.read_timeout = atoi( q ); + else if( strcmp( p, "max_resend" ) == 0 ) + { + opt.max_resend = atoi( q ); + if( opt.max_resend < 0 ) + goto usage; + } + else if( strcmp( p, "request_page" ) == 0 ) + opt.request_page = q; + else if( strcmp( p, "request_size" ) == 0 ) + { + opt.request_size = atoi( q ); + if( opt.request_size < 0 || opt.request_size > MBEDTLS_SSL_MAX_CONTENT_LEN ) + goto usage; + } + else if( strcmp( p, "ca_file" ) == 0 ) + opt.ca_file = q; + else if( strcmp( p, "ca_path" ) == 0 ) + opt.ca_path = q; + else if( strcmp( p, "crt_file" ) == 0 ) + opt.crt_file = q; + else if( strcmp( p, "key_file" ) == 0 ) + opt.key_file = q; + else if( strcmp( p, "psk" ) == 0 ) + opt.psk = q; + else if( strcmp( p, "psk_identity" ) == 0 ) + opt.psk_identity = q; + else if( strcmp( p, "ecjpake_pw" ) == 0 ) + opt.ecjpake_pw = q; + else if( strcmp( p, "force_ciphersuite" ) == 0 ) + { + opt.force_ciphersuite[0] = mbedtls_ssl_get_ciphersuite_id( q ); + + if( opt.force_ciphersuite[0] == 0 ) + { + ret = 2; + goto usage; + } + opt.force_ciphersuite[1] = 0; + } + else if( strcmp( p, "renegotiation" ) == 0 ) + { + opt.renegotiation = (atoi( q )) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED : + MBEDTLS_SSL_RENEGOTIATION_DISABLED; + } + else if( strcmp( p, "allow_legacy" ) == 0 ) + { + switch( atoi( q ) ) + { + case -1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE; break; + case 0: opt.allow_legacy = MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION; break; + case 1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION; break; + default: goto usage; + } + } + else if( strcmp( p, "renegotiate" ) == 0 ) + { + opt.renegotiate = atoi( q ); + if( opt.renegotiate < 0 || opt.renegotiate > 1 ) + goto usage; + } + else if( strcmp( p, "exchanges" ) == 0 ) + { + opt.exchanges = atoi( q ); + if( opt.exchanges < 1 ) + goto usage; + } + else if( strcmp( p, "reconnect" ) == 0 ) + { + opt.reconnect = atoi( q ); + if( opt.reconnect < 0 || opt.reconnect > 2 ) + goto usage; + } + else if( strcmp( p, "reco_delay" ) == 0 ) + { + opt.reco_delay = atoi( q ); + if( opt.reco_delay < 0 ) + goto usage; + } + else if( strcmp( p, "reconnect_hard" ) == 0 ) + { + opt.reconnect_hard = atoi( q ); + if( opt.reconnect_hard < 0 || opt.reconnect_hard > 1 ) + goto usage; + } + else if( strcmp( p, "tickets" ) == 0 ) + { + opt.tickets = atoi( q ); + if( opt.tickets < 0 || opt.tickets > 2 ) + goto usage; + } + else if( strcmp( p, "alpn" ) == 0 ) + { + opt.alpn_string = q; + } + else if( strcmp( p, "fallback" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.fallback = MBEDTLS_SSL_IS_NOT_FALLBACK; break; + case 1: opt.fallback = MBEDTLS_SSL_IS_FALLBACK; break; + default: goto usage; + } + } + else if( strcmp( p, "extended_ms" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_DISABLED; break; + case 1: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "etm" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.etm = MBEDTLS_SSL_ETM_DISABLED; break; + case 1: opt.etm = MBEDTLS_SSL_ETM_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "min_version" ) == 0 ) + { + if( strcmp( q, "ssl3" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0; + else if( strcmp( q, "tls1" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1; + else if( strcmp( q, "tls1_1" ) == 0 || + strcmp( q, "dtls1" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + else if( strcmp( q, "tls1_2" ) == 0 || + strcmp( q, "dtls1_2" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_3; + else + goto usage; + } + else if( strcmp( p, "max_version" ) == 0 ) + { + if( strcmp( q, "ssl3" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0; + else if( strcmp( q, "tls1" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1; + else if( strcmp( q, "tls1_1" ) == 0 || + strcmp( q, "dtls1" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_2; + else if( strcmp( q, "tls1_2" ) == 0 || + strcmp( q, "dtls1_2" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_3; + else + goto usage; + } + else if( strcmp( p, "arc4" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.arc4 = MBEDTLS_SSL_ARC4_DISABLED; break; + case 1: opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "force_version" ) == 0 ) + { + if( strcmp( q, "ssl3" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0; + } + else if( strcmp( q, "tls1" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1; + } + else if( strcmp( q, "tls1_1" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_2; + } + else if( strcmp( q, "tls1_2" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_3; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_3; + } + else if( strcmp( q, "dtls1" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_2; + opt.transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; + } + else if( strcmp( q, "dtls1_2" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_3; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_3; + opt.transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; + } + else + goto usage; + } + else if( strcmp( p, "auth_mode" ) == 0 ) + { + if( strcmp( q, "none" ) == 0 ) + opt.auth_mode = MBEDTLS_SSL_VERIFY_NONE; + else if( strcmp( q, "optional" ) == 0 ) + opt.auth_mode = MBEDTLS_SSL_VERIFY_OPTIONAL; + else if( strcmp( q, "required" ) == 0 ) + opt.auth_mode = MBEDTLS_SSL_VERIFY_REQUIRED; + else + goto usage; + } + else if( strcmp( p, "max_frag_len" ) == 0 ) + { + if( strcmp( q, "512" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_512; + else if( strcmp( q, "1024" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_1024; + else if( strcmp( q, "2048" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_2048; + else if( strcmp( q, "4096" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_4096; + else + goto usage; + } + else if( strcmp( p, "trunc_hmac" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_DISABLED; break; + case 1: opt.trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "hs_timeout" ) == 0 ) + { + if( ( p = strchr( q, '-' ) ) == NULL ) + goto usage; + *p++ = '\0'; + opt.hs_to_min = atoi( q ); + opt.hs_to_max = atoi( p ); + if( opt.hs_to_min == 0 || opt.hs_to_max < opt.hs_to_min ) + goto usage; + } + else if( strcmp( p, "recsplit" ) == 0 ) + { + opt.recsplit = atoi( q ); + if( opt.recsplit < 0 || opt.recsplit > 1 ) + goto usage; + } + else if( strcmp( p, "dhmlen" ) == 0 ) + { + opt.dhmlen = atoi( q ); + if( opt.dhmlen < 0 ) + goto usage; + } + else + goto usage; + } + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( opt.debug_level ); +#endif + + if( opt.force_ciphersuite[0] > 0 ) + { + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( opt.force_ciphersuite[0] ); + + if( opt.max_version != -1 && + ciphersuite_info->min_minor_ver > opt.max_version ) + { + mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + ret = 2; + goto usage; + } + if( opt.min_version != -1 && + ciphersuite_info->max_minor_ver < opt.min_version ) + { + mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + ret = 2; + goto usage; + } + + /* If the server selects a version that's not supported by + * this suite, then there will be no common ciphersuite... */ + if( opt.max_version == -1 || + opt.max_version > ciphersuite_info->max_minor_ver ) + { + opt.max_version = ciphersuite_info->max_minor_ver; + } + if( opt.min_version < ciphersuite_info->min_minor_ver ) + { + opt.min_version = ciphersuite_info->min_minor_ver; + /* DTLS starts with TLS 1.1 */ + if( opt.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + opt.min_version < MBEDTLS_SSL_MINOR_VERSION_2 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + } + + /* Enable RC4 if needed and not explicitly disabled */ + if( ciphersuite_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) + { + if( opt.arc4 == MBEDTLS_SSL_ARC4_DISABLED ) + { + mbedtls_printf("forced RC4 ciphersuite with RC4 disabled\n"); + ret = 2; + goto usage; + } + + opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED; + } + } + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + /* + * Unhexify the pre-shared key if any is given + */ + if( strlen( opt.psk ) ) + { + unsigned char c; + size_t j; + + if( strlen( opt.psk ) % 2 != 0 ) + { + mbedtls_printf("pre-shared key not valid hex\n"); + goto exit; + } + + psk_len = strlen( opt.psk ) / 2; + + for( j = 0; j < strlen( opt.psk ); j += 2 ) + { + c = opt.psk[j]; + if( c >= '0' && c <= '9' ) + c -= '0'; + else if( c >= 'a' && c <= 'f' ) + c -= 'a' - 10; + else if( c >= 'A' && c <= 'F' ) + c -= 'A' - 10; + else + { + mbedtls_printf("pre-shared key not valid hex\n"); + goto exit; + } + psk[ j / 2 ] = c << 4; + + c = opt.psk[j + 1]; + if( c >= '0' && c <= '9' ) + c -= '0'; + else if( c >= 'a' && c <= 'f' ) + c -= 'a' - 10; + else if( c >= 'A' && c <= 'F' ) + c -= 'A' - 10; + else + { + mbedtls_printf("pre-shared key not valid hex\n"); + goto exit; + } + psk[ j / 2 ] |= c; + } + } +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN) + if( opt.alpn_string != NULL ) + { + p = (char *) opt.alpn_string; + i = 0; + + /* Leave room for a final NULL in alpn_list */ + while( i < (int) sizeof alpn_list - 1 && *p != '\0' ) + { + alpn_list[i++] = p; + + /* Terminate the current string and move on to next one */ + while( *p != ',' && *p != '\0' ) + p++; + if( *p == ',' ) + *p++ = '\0'; + } + } +#endif /* MBEDTLS_SSL_ALPN */ + + /* + * 0. Initialize the RNG and the session data + */ + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * 1.1. Load the trusted CA + */ + mbedtls_printf( " . Loading the CA root certificate ..." ); + fflush( stdout ); + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.ca_path ) ) + if( strcmp( opt.ca_path, "none" ) == 0 ) + ret = 0; + else + ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); + else if( strlen( opt.ca_file ) ) + if( strcmp( opt.ca_file, "none" ) == 0 ) + ret = 0; + else + ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); + else +#endif +#if defined(MBEDTLS_CERTS_C) + for( i = 0; mbedtls_test_cas[i] != NULL; i++ ) + { + ret = mbedtls_x509_crt_parse( &cacert, + (const unsigned char *) mbedtls_test_cas[i], + mbedtls_test_cas_len[i] ); + if( ret != 0 ) + break; + } +#else + { + ret = 1; + mbedtls_printf("MBEDTLS_CERTS_C not defined."); + } +#endif + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok (%d skipped)\n", ret ); + + /* + * 1.2. Load own certificate and private key + * + * (can be skipped if client authentication is not required) + */ + mbedtls_printf( " . Loading the client cert. and key..." ); + fflush( stdout ); + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.crt_file ) ) + if( strcmp( opt.crt_file, "none" ) == 0 ) + ret = 0; + else + ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file ); + else +#endif +#if defined(MBEDTLS_CERTS_C) + ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt, + mbedtls_test_cli_crt_len ); +#else + { + ret = 1; + mbedtls_printf("MBEDTLS_CERTS_C not defined."); + } +#endif + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.key_file ) ) + if( strcmp( opt.key_file, "none" ) == 0 ) + ret = 0; + else + ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" ); + else +#endif +#if defined(MBEDTLS_CERTS_C) + ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_cli_key, + mbedtls_test_cli_key_len, NULL, 0 ); +#else + { + ret = 1; + mbedtls_printf("MBEDTLS_CERTS_C not defined."); + } +#endif + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + /* + * 2. Start the connection + */ + if( opt.server_addr == NULL) + opt.server_addr = opt.server_name; + + mbedtls_printf( " . Connecting to %s/%s/%s...", + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? "tcp" : "udp", + opt.server_addr, opt.server_port ); + fflush( stdout ); + + if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port, + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? + MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n", -ret ); + goto exit; + } + + if( opt.nbio > 0 ) + ret = mbedtls_net_set_nonblock( &server_fd ); + else + ret = mbedtls_net_set_block( &server_fd ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 3. Setup stuff + */ + mbedtls_printf( " . Setting up the SSL/TLS structure..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_CLIENT, + opt.transport, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n", -ret ); + goto exit; + } + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( opt.debug_level > 0 ) + mbedtls_ssl_conf_verify( &conf, my_verify, NULL ); +#endif + + if( opt.auth_mode != DFL_AUTH_MODE ) + mbedtls_ssl_conf_authmode( &conf, opt.auth_mode ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( opt.hs_to_min != DFL_HS_TO_MIN || opt.hs_to_max != DFL_HS_TO_MAX ) + mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min, opt.hs_to_max ); +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + if( ( ret = mbedtls_ssl_conf_max_frag_len( &conf, opt.mfl_code ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_max_frag_len returned %d\n\n", ret ); + goto exit; + } +#endif + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + if( opt.trunc_hmac != DFL_TRUNC_HMAC ) + mbedtls_ssl_conf_truncated_hmac( &conf, opt.trunc_hmac ); +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + if( opt.extended_ms != DFL_EXTENDED_MS ) + mbedtls_ssl_conf_extended_master_secret( &conf, opt.extended_ms ); +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + if( opt.etm != DFL_ETM ) + mbedtls_ssl_conf_encrypt_then_mac( &conf, opt.etm ); +#endif + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + if( opt.recsplit != DFL_RECSPLIT ) + mbedtls_ssl_conf_cbc_record_splitting( &conf, opt.recsplit + ? MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED + : MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED ); +#endif + +#if defined(MBEDTLS_DHM_C) + if( opt.dhmlen != DFL_DHMLEN ) + mbedtls_ssl_conf_dhm_min_bitlen( &conf, opt.dhmlen ); +#endif + +#if defined(MBEDTLS_SSL_ALPN) + if( opt.alpn_string != NULL ) + if( ( ret = mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_alpn_protocols returned %d\n\n", ret ); + goto exit; + } +#endif + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + + mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout ); + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + mbedtls_ssl_conf_session_tickets( &conf, opt.tickets ); +#endif + + if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER ) + mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite ); + +#if defined(MBEDTLS_ARC4_C) + if( opt.arc4 != DFL_ARC4 ) + mbedtls_ssl_conf_arc4_support( &conf, opt.arc4 ); +#endif + + if( opt.allow_legacy != DFL_ALLOW_LEGACY ) + mbedtls_ssl_conf_legacy_renegotiation( &conf, opt.allow_legacy ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + mbedtls_ssl_conf_renegotiation( &conf, opt.renegotiation ); +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( strcmp( opt.ca_path, "none" ) != 0 && + strcmp( opt.ca_file, "none" ) != 0 ) + { + mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); + } + if( strcmp( opt.crt_file, "none" ) != 0 && + strcmp( opt.key_file, "none" ) != 0 ) + { + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &clicert, &pkey ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + if( ( ret = mbedtls_ssl_conf_psk( &conf, psk, psk_len, + (const unsigned char *) opt.psk_identity, + strlen( opt.psk_identity ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_psk returned %d\n\n", ret ); + goto exit; + } +#endif + + if( opt.min_version != DFL_MIN_VERSION ) + mbedtls_ssl_conf_min_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, opt.min_version ); + + if( opt.max_version != DFL_MAX_VERSION ) + mbedtls_ssl_conf_max_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, opt.max_version ); + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + if( opt.fallback != DFL_FALLBACK ) + mbedtls_ssl_conf_fallback( &conf, opt.fallback ); +#endif + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", -ret ); + goto exit; + } + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); + goto exit; + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( opt.ecjpake_pw != DFL_ECJPAKE_PW ) + { + if( ( ret = mbedtls_ssl_set_hs_ecjpake_password( &ssl, + (const unsigned char *) opt.ecjpake_pw, + strlen( opt.ecjpake_pw ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hs_ecjpake_password returned %d\n\n", ret ); + goto exit; + } + } +#endif + + if( opt.nbio == 2 ) + mbedtls_ssl_set_bio( &ssl, &server_fd, my_send, my_recv, NULL ); + else + mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, + opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL ); + +#if defined(MBEDTLS_TIMING_C) + mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, + mbedtls_timing_get_delay ); +#endif + + mbedtls_printf( " ok\n" ); + + /* + * 4. Handshake + */ + mbedtls_printf( " . Performing the SSL/TLS handshake..." ); + fflush( stdout ); + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n", -ret ); + if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ) + mbedtls_printf( + " Unable to verify the server's certificate. " + "Either it is invalid,\n" + " or you didn't set ca_file or ca_path " + "to an appropriate value.\n" + " Alternatively, you may want to use " + "auth_mode=optional for testing purposes.\n" ); + mbedtls_printf( "\n" ); + goto exit; + } + } + + mbedtls_printf( " ok\n [ Protocol is %s ]\n [ Ciphersuite is %s ]\n", + mbedtls_ssl_get_version( &ssl ), mbedtls_ssl_get_ciphersuite( &ssl ) ); + + if( ( ret = mbedtls_ssl_get_record_expansion( &ssl ) ) >= 0 ) + mbedtls_printf( " [ Record expansion is %d ]\n", ret ); + else + mbedtls_printf( " [ Record expansion is unknown (compression) ]\n" ); + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + mbedtls_printf( " [ Maximum fragment length is %u ]\n", + (unsigned int) mbedtls_ssl_get_max_frag_len( &ssl ) ); +#endif + +#if defined(MBEDTLS_SSL_ALPN) + if( opt.alpn_string != NULL ) + { + const char *alp = mbedtls_ssl_get_alpn_protocol( &ssl ); + mbedtls_printf( " [ Application Layer Protocol is %s ]\n", + alp ? alp : "(none)" ); + } +#endif + + if( opt.reconnect != 0 ) + { + mbedtls_printf(" . Saving session for reuse..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_get_session( &ssl, &saved_session ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_get_session returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + } + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * 5. Verify the server certificate + */ + mbedtls_printf( " . Verifying peer X.509 certificate..." ); + + if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 ) + { + char vrfy_buf[512]; + + mbedtls_printf( " failed\n" ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } + else + mbedtls_printf( " ok\n" ); + + if( mbedtls_ssl_get_peer_cert( &ssl ) != NULL ) + { + mbedtls_printf( " . Peer certificate information ...\n" ); + mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", + mbedtls_ssl_get_peer_cert( &ssl ) ); + mbedtls_printf( "%s\n", buf ); + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( opt.renegotiate ) + { + /* + * Perform renegotiation (this must be done when the server is waiting + * for input from our side). + */ + mbedtls_printf( " . Performing renegotiation..." ); + fflush( stdout ); + while( ( ret = mbedtls_ssl_renegotiate( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n", ret ); + goto exit; + } + } + mbedtls_printf( " ok\n" ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + /* + * 6. Write the GET request + */ + retry_left = opt.max_resend; +send_request: + mbedtls_printf( " > Write to server:" ); + fflush( stdout ); + + len = mbedtls_snprintf( (char *) buf, sizeof(buf) - 1, GET_REQUEST, + opt.request_page ); + tail_len = (int) strlen( GET_REQUEST_END ); + + /* Add padding to GET request to reach opt.request_size in length */ + if( opt.request_size != DFL_REQUEST_SIZE && + len + tail_len < opt.request_size ) + { + memset( buf + len, 'A', opt.request_size - len - tail_len ); + len += opt.request_size - len - tail_len; + } + + strncpy( (char *) buf + len, GET_REQUEST_END, sizeof(buf) - len - 1 ); + len += tail_len; + + /* Truncate if request size is smaller than the "natural" size */ + if( opt.request_size != DFL_REQUEST_SIZE && + len > opt.request_size ) + { + len = opt.request_size; + + /* Still end with \r\n unless that's really not possible */ + if( len >= 2 ) buf[len - 2] = '\r'; + if( len >= 1 ) buf[len - 1] = '\n'; + } + + if( opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ) + { + for( written = 0, frags = 0; written < len; written += ret, frags++ ) + { + while( ( ret = mbedtls_ssl_write( &ssl, buf + written, len - written ) ) + <= 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned -0x%x\n\n", -ret ); + goto exit; + } + } + } + } + else /* Not stream, so datagram */ + { + do ret = mbedtls_ssl_write( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto exit; + } + + frags = 1; + written = ret; + } + + buf[written] = '\0'; + mbedtls_printf( " %d bytes written in %d fragments\n\n%s\n", written, frags, (char *) buf ); + + /* + * 7. Read the HTTP response + */ + mbedtls_printf( " < Read from server:" ); + fflush( stdout ); + + /* + * TLS and DTLS need different reading styles (stream vs datagram) + */ + if( opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ) + { + do + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + ret = mbedtls_ssl_read( &ssl, buf, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " connection was closed gracefully\n" ); + ret = 0; + goto close_notify; + + case 0: + case MBEDTLS_ERR_NET_CONN_RESET: + mbedtls_printf( " connection was reset by peer\n" ); + ret = 0; + goto reconnect; + + default: + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret ); + goto exit; + } + } + + len = ret; + buf[len] = '\0'; + mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf ); + + /* End of message should be detected according to the syntax of the + * application protocol (eg HTTP), just use a dummy test here. */ + if( ret > 0 && buf[len-1] == '\n' ) + { + ret = 0; + break; + } + } + while( 1 ); + } + else /* Not stream, so datagram */ + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + + do ret = mbedtls_ssl_read( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_TIMEOUT: + mbedtls_printf( " timeout\n" ); + if( retry_left-- > 0 ) + goto send_request; + goto exit; + + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " connection was closed gracefully\n" ); + ret = 0; + goto close_notify; + + default: + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret ); + goto exit; + } + } + + len = ret; + buf[len] = '\0'; + mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf ); + ret = 0; + } + + /* + * 7b. Simulate hard reset and reconnect from same port? + */ + if( opt.reconnect_hard != 0 ) + { + opt.reconnect_hard = 0; + + mbedtls_printf( " . Restarting connection from same port..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_session_reset( &ssl ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n", -ret ); + goto exit; + } + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + goto exit; + } + } + + mbedtls_printf( " ok\n" ); + + goto send_request; + } + + /* + * 7c. Continue doing data exchanges? + */ + if( --opt.exchanges > 0 ) + goto send_request; + + /* + * 8. Done, cleanly close the connection + */ +close_notify: + mbedtls_printf( " . Closing the connection..." ); + fflush( stdout ); + + /* No error checking, the connection might be closed already */ + do ret = mbedtls_ssl_close_notify( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + ret = 0; + + mbedtls_printf( " done\n" ); + + /* + * 9. Reconnect? + */ +reconnect: + if( opt.reconnect != 0 ) + { + --opt.reconnect; + + mbedtls_net_free( &server_fd ); + +#if defined(MBEDTLS_TIMING_C) + if( opt.reco_delay > 0 ) + mbedtls_net_usleep( 1000000 * opt.reco_delay ); +#endif + + mbedtls_printf( " . Reconnecting with saved session..." ); + + if( ( ret = mbedtls_ssl_session_reset( &ssl ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n", -ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_set_session( &ssl, &saved_session ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_session returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port, + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? + MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n", -ret ); + goto exit; + } + + if( opt.nbio > 0 ) + ret = mbedtls_net_set_nonblock( &server_fd ); + else + ret = mbedtls_net_set_block( &server_fd ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", + -ret ); + goto exit; + } + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + goto exit; + } + } + + mbedtls_printf( " ok\n" ); + + goto send_request; + } + + /* + * Cleanup and exit + */ +exit: +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf("Last error was: -0x%X - %s\n\n", -ret, error_buf ); + } +#endif + + mbedtls_net_free( &server_fd ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt_free( &clicert ); + mbedtls_x509_crt_free( &cacert ); + mbedtls_pk_free( &pkey ); +#endif + mbedtls_ssl_session_free( &saved_session ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + // Shell can not handle large exit numbers -> 1 for errors + if( ret < 0 ) + ret = 1; + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && + MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && + MBEDTLS_CTR_DRBG_C MBEDTLS_TIMING_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_fork_server.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_fork_server.c new file mode 100644 index 0000000..7624896 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_fork_server.c @@ -0,0 +1,416 @@ +/* + * SSL server demonstration program using fork() for handling multiple clients + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#define mbedtls_time_t time_t +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \ + !defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_TIMING_C) || \ + !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_PEM_PARSE_C) +int main( int argc, char *argv[] ) +{ + ((void) argc); + ((void) argv); + + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_CERTS_C and/or MBEDTLS_ENTROPY_C " + "and/or MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or " + "MBEDTLS_TIMING_C and/or MBEDTLS_PEM_PARSE_C not defined.\n"); + return( 0 ); +} +#elif defined(_WIN32) +int main( void ) +{ + mbedtls_printf("_WIN32 defined. This application requires fork() and signals " + "to work correctly.\n"); + return( 0 ); +} +#else + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" +#include "mbedtls/ssl.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/timing.h" + +#include +#include + +#if !defined(_MSC_VER) || defined(EFIX64) || defined(EFI32) +#include +#endif + +#define HTTP_RESPONSE \ + "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ + "

      mbed TLS Test Server

      \r\n" \ + "

      Successful connection using: %s

      \r\n" + +#define DEBUG_LEVEL 0 + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +int main( void ) +{ + int ret, len, cnt = 0, pid; + mbedtls_net_context listen_fd, client_fd; + unsigned char buf[1024]; + const char *pers = "ssl_fork_server"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt srvcert; + mbedtls_pk_context pkey; + + mbedtls_net_init( &listen_fd ); + mbedtls_net_init( &client_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + mbedtls_entropy_init( &entropy ); + mbedtls_pk_init( &pkey ); + mbedtls_x509_crt_init( &srvcert ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + signal( SIGCHLD, SIG_IGN ); + + /* + * 0. Initial seeding of the RNG + */ + mbedtls_printf( "\n . Initial seeding of the random generator..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed! mbedtls_ctr_drbg_seed returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1. Load the certificates and private RSA key + */ + mbedtls_printf( " . Loading the server cert. and key..." ); + fflush( stdout ); + + /* + * This demonstration program uses embedded test certificates. + * Instead, you may want to use mbedtls_x509_crt_parse_file() to read the + * server and CA certificates, as well as mbedtls_pk_parse_keyfile(). + */ + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_srv_crt, + mbedtls_test_srv_crt_len ); + if( ret != 0 ) + { + mbedtls_printf( " failed! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); + if( ret != 0 ) + { + mbedtls_printf( " failed! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key, + mbedtls_test_srv_key_len, NULL, 0 ); + if( ret != 0 ) + { + mbedtls_printf( " failed! mbedtls_pk_parse_key returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1b. Prepare SSL configuration + */ + mbedtls_printf( " . Configuring SSL..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_SERVER, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + + mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) + { + mbedtls_printf( " failed! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 2. Setup the listening TCP socket + */ + mbedtls_printf( " . Bind on https://localhost:4433/ ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_bind( &listen_fd, NULL, "4433", MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed! mbedtls_net_bind returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + while( 1 ) + { + /* + * 3. Wait until a client connects + */ + mbedtls_net_init( &client_fd ); + mbedtls_ssl_init( &ssl ); + + mbedtls_printf( " . Waiting for a remote connection ...\n" ); + fflush( stdout ); + + if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd, + NULL, 0, NULL ) ) != 0 ) + { + mbedtls_printf( " failed! mbedtls_net_accept returned %d\n\n", ret ); + goto exit; + } + + /* + * 3.5. Forking server thread + */ + + mbedtls_printf( " . Forking to handle connection ..." ); + fflush( stdout ); + + pid = fork(); + + if( pid < 0 ) + { + mbedtls_printf(" failed! fork returned %d\n\n", pid ); + goto exit; + } + + if( pid != 0 ) + { + mbedtls_printf( " ok\n" ); + + if( ( ret = mbedtls_ctr_drbg_reseed( &ctr_drbg, + (const unsigned char *) "parent", + 6 ) ) != 0 ) + { + mbedtls_printf( " failed! mbedtls_ctr_drbg_reseed returned %d\n\n", ret ); + goto exit; + } + + continue; + } + + mbedtls_net_init( &listen_fd ); + + pid = getpid(); + + /* + * 4. Setup stuff + */ + mbedtls_printf( "pid %d: Setting up the SSL data.\n", pid ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_reseed( &ctr_drbg, + (const unsigned char *) "child", + 5 ) ) != 0 ) + { + mbedtls_printf( + "pid %d: SSL setup failed! mbedtls_ctr_drbg_reseed returned %d\n\n", + pid, ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( + "pid %d: SSL setup failed! mbedtls_ssl_setup returned %d\n\n", + pid, ret ); + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + mbedtls_printf( "pid %d: SSL setup ok\n", pid ); + + /* + * 5. Handshake + */ + mbedtls_printf( "pid %d: Performing the SSL/TLS handshake.\n", pid ); + fflush( stdout ); + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( + "pid %d: SSL handshake failed! mbedtls_ssl_handshake returned %d\n\n", + pid, ret ); + goto exit; + } + } + + mbedtls_printf( "pid %d: SSL handshake ok\n", pid ); + + /* + * 6. Read the HTTP Request + */ + mbedtls_printf( "pid %d: Start reading from client.\n", pid ); + fflush( stdout ); + + do + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + ret = mbedtls_ssl_read( &ssl, buf, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( "pid %d: connection was closed gracefully\n", pid ); + break; + + case MBEDTLS_ERR_NET_CONN_RESET: + mbedtls_printf( "pid %d: connection was reset by peer\n", pid ); + break; + + default: + mbedtls_printf( "pid %d: mbedtls_ssl_read returned %d\n", pid, ret ); + break; + } + + break; + } + + len = ret; + mbedtls_printf( "pid %d: %d bytes read\n\n%s", pid, len, (char *) buf ); + + if( ret > 0 ) + break; + } + while( 1 ); + + /* + * 7. Write the 200 Response + */ + mbedtls_printf( "pid %d: Start writing to client.\n", pid ); + fflush( stdout ); + + len = sprintf( (char *) buf, HTTP_RESPONSE, + mbedtls_ssl_get_ciphersuite( &ssl ) ); + + while( cnt++ < 100 ) + { + while( ( ret = mbedtls_ssl_write( &ssl, buf, len ) ) <= 0 ) + { + if( ret == MBEDTLS_ERR_NET_CONN_RESET ) + { + mbedtls_printf( + "pid %d: Write failed! peer closed the connection\n\n", pid ); + goto exit; + } + + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( + "pid %d: Write failed! mbedtls_ssl_write returned %d\n\n", + pid, ret ); + goto exit; + } + } + len = ret; + mbedtls_printf( "pid %d: %d bytes written\n\n%s\n", pid, len, (char *) buf ); + + mbedtls_net_usleep( 1000000 ); + } + + mbedtls_ssl_close_notify( &ssl ); + goto exit; + } + +exit: + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); + + mbedtls_x509_crt_free( &srvcert ); + mbedtls_pk_free( &pkey ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C && + MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && + MBEDTLS_RSA_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_PARSE_C && + ! _WIN32 */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_mail_client.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_mail_client.c new file mode 100644 index 0000000..b49ffb4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_mail_client.c @@ -0,0 +1,842 @@ +/* + * SSL client for SMTP servers + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ + !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C " + "not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/base64.h" +#include "mbedtls/error.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" + +#include +#include + +#if !defined(_MSC_VER) || defined(EFIX64) || defined(EFI32) +#include +#else +#include +#endif + +#if defined(_WIN32) || defined(_WIN32_WCE) +#include +#include + +#if defined(_MSC_VER) +#if defined(_WIN32_WCE) +#pragma comment( lib, "ws2.lib" ) +#else +#pragma comment( lib, "ws2_32.lib" ) +#endif +#endif /* _MSC_VER */ +#endif + +#define DFL_SERVER_NAME "localhost" +#define DFL_SERVER_PORT "465" +#define DFL_USER_NAME "user" +#define DFL_USER_PWD "password" +#define DFL_MAIL_FROM "" +#define DFL_MAIL_TO "" +#define DFL_DEBUG_LEVEL 0 +#define DFL_CA_FILE "" +#define DFL_CRT_FILE "" +#define DFL_KEY_FILE "" +#define DFL_FORCE_CIPHER 0 +#define DFL_MODE 0 +#define DFL_AUTHENTICATION 0 + +#define MODE_SSL_TLS 0 +#define MODE_STARTTLS 0 + +#if defined(MBEDTLS_BASE64_C) +#define USAGE_AUTH \ + " authentication=%%d default: 0 (disabled)\n" \ + " user_name=%%s default: \"user\"\n" \ + " user_pwd=%%s default: \"password\"\n" +#else +#define USAGE_AUTH \ + " authentication options disabled. (Require MBEDTLS_BASE64_C)\n" +#endif /* MBEDTLS_BASE64_C */ + +#if defined(MBEDTLS_FS_IO) +#define USAGE_IO \ + " ca_file=%%s default: \"\" (pre-loaded)\n" \ + " crt_file=%%s default: \"\" (pre-loaded)\n" \ + " key_file=%%s default: \"\" (pre-loaded)\n" +#else +#define USAGE_IO \ + " No file operations available (MBEDTLS_FS_IO not defined)\n" +#endif /* MBEDTLS_FS_IO */ + +#define USAGE \ + "\n usage: ssl_mail_client param=<>...\n" \ + "\n acceptable parameters:\n" \ + " server_name=%%s default: localhost\n" \ + " server_port=%%d default: 4433\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ + " mode=%%d default: 0 (SSL/TLS) (1 for STARTTLS)\n" \ + USAGE_AUTH \ + " mail_from=%%s default: \"\"\n" \ + " mail_to=%%s default: \"\"\n" \ + USAGE_IO \ + " force_ciphersuite= default: all enabled\n"\ + " acceptable ciphersuite names:\n" + +/* + * global options + */ +struct options +{ + const char *server_name; /* hostname of the server (client only) */ + const char *server_port; /* port on which the ssl service runs */ + int debug_level; /* level of debugging */ + int authentication; /* if authentication is required */ + int mode; /* SSL/TLS (0) or STARTTLS (1) */ + const char *user_name; /* username to use for authentication */ + const char *user_pwd; /* password to use for authentication */ + const char *mail_from; /* E-Mail address to use as sender */ + const char *mail_to; /* E-Mail address to use as recipient */ + const char *ca_file; /* the file with the CA certificate(s) */ + const char *crt_file; /* the file with the client certificate */ + const char *key_file; /* the file with the client key */ + int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ +} opt; + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +static int do_handshake( mbedtls_ssl_context *ssl ) +{ + int ret; + uint32_t flags; + unsigned char buf[1024]; + memset(buf, 0, 1024); + + /* + * 4. Handshake + */ + mbedtls_printf( " . Performing the SSL/TLS handshake..." ); + fflush( stdout ); + + while( ( ret = mbedtls_ssl_handshake( ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { +#if defined(MBEDTLS_ERROR_C) + mbedtls_strerror( ret, (char *) buf, 1024 ); +#endif + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned %d: %s\n\n", ret, buf ); + return( -1 ); + } + } + + mbedtls_printf( " ok\n [ Ciphersuite is %s ]\n", + mbedtls_ssl_get_ciphersuite( ssl ) ); + + /* + * 5. Verify the server certificate + */ + mbedtls_printf( " . Verifying peer X.509 certificate..." ); + + /* In real life, we probably want to bail out when ret != 0 */ + if( ( flags = mbedtls_ssl_get_verify_result( ssl ) ) != 0 ) + { + char vrfy_buf[512]; + + mbedtls_printf( " failed\n" ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } + else + mbedtls_printf( " ok\n" ); + + mbedtls_printf( " . Peer certificate information ...\n" ); + mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", + mbedtls_ssl_get_peer_cert( ssl ) ); + mbedtls_printf( "%s\n", buf ); + + return( 0 ); +} + +static int write_ssl_data( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) +{ + int ret; + + mbedtls_printf("\n%s", buf); + while( len && ( ret = mbedtls_ssl_write( ssl, buf, len ) ) <= 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + return -1; + } + } + + return( 0 ); +} + +static int write_ssl_and_get_response( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) +{ + int ret; + unsigned char data[128]; + char code[4]; + size_t i, idx = 0; + + mbedtls_printf("\n%s", buf); + while( len && ( ret = mbedtls_ssl_write( ssl, buf, len ) ) <= 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + return -1; + } + } + + do + { + len = sizeof( data ) - 1; + memset( data, 0, sizeof( data ) ); + ret = mbedtls_ssl_read( ssl, data, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY ) + return -1; + + if( ret <= 0 ) + { + mbedtls_printf( "failed\n ! mbedtls_ssl_read returned %d\n\n", ret ); + return -1; + } + + mbedtls_printf("\n%s", data); + len = ret; + for( i = 0; i < len; i++ ) + { + if( data[i] != '\n' ) + { + if( idx < 4 ) + code[ idx++ ] = data[i]; + continue; + } + + if( idx == 4 && code[0] >= '0' && code[0] <= '9' && code[3] == ' ' ) + { + code[3] = '\0'; + return atoi( code ); + } + + idx = 0; + } + } + while( 1 ); +} + +static int write_and_get_response( mbedtls_net_context *sock_fd, unsigned char *buf, size_t len ) +{ + int ret; + unsigned char data[128]; + char code[4]; + size_t i, idx = 0; + + mbedtls_printf("\n%s", buf); + if( len && ( ret = mbedtls_net_send( sock_fd, buf, len ) ) <= 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + return -1; + } + + do + { + len = sizeof( data ) - 1; + memset( data, 0, sizeof( data ) ); + ret = mbedtls_net_recv( sock_fd, data, len ); + + if( ret <= 0 ) + { + mbedtls_printf( "failed\n ! read returned %d\n\n", ret ); + return -1; + } + + data[len] = '\0'; + mbedtls_printf("\n%s", data); + len = ret; + for( i = 0; i < len; i++ ) + { + if( data[i] != '\n' ) + { + if( idx < 4 ) + code[ idx++ ] = data[i]; + continue; + } + + if( idx == 4 && code[0] >= '0' && code[0] <= '9' && code[3] == ' ' ) + { + code[3] = '\0'; + return atoi( code ); + } + + idx = 0; + } + } + while( 1 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0, len; + mbedtls_net_context server_fd; + unsigned char buf[1024]; +#if defined(MBEDTLS_BASE64_C) + unsigned char base[1024]; +#endif + char hostname[32]; + const char *pers = "ssl_mail_client"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt cacert; + mbedtls_x509_crt clicert; + mbedtls_pk_context pkey; + int i; + size_t n; + char *p, *q; + const int *list; + + /* + * Make sure memory references are valid in case we exit early. + */ + mbedtls_net_init( &server_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + memset( &buf, 0, sizeof( buf ) ); + mbedtls_x509_crt_init( &cacert ); + mbedtls_x509_crt_init( &clicert ); + mbedtls_pk_init( &pkey ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + + list = mbedtls_ssl_list_ciphersuites(); + while( *list ) + { + mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name( *list ) ); + list++; + } + mbedtls_printf("\n"); + goto exit; + } + + opt.server_name = DFL_SERVER_NAME; + opt.server_port = DFL_SERVER_PORT; + opt.debug_level = DFL_DEBUG_LEVEL; + opt.authentication = DFL_AUTHENTICATION; + opt.mode = DFL_MODE; + opt.user_name = DFL_USER_NAME; + opt.user_pwd = DFL_USER_PWD; + opt.mail_from = DFL_MAIL_FROM; + opt.mail_to = DFL_MAIL_TO; + opt.ca_file = DFL_CA_FILE; + opt.crt_file = DFL_CRT_FILE; + opt.key_file = DFL_KEY_FILE; + opt.force_ciphersuite[0]= DFL_FORCE_CIPHER; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "server_name" ) == 0 ) + opt.server_name = q; + else if( strcmp( p, "server_port" ) == 0 ) + opt.server_port = q; + else if( strcmp( p, "debug_level" ) == 0 ) + { + opt.debug_level = atoi( q ); + if( opt.debug_level < 0 || opt.debug_level > 65535 ) + goto usage; + } + else if( strcmp( p, "authentication" ) == 0 ) + { + opt.authentication = atoi( q ); + if( opt.authentication < 0 || opt.authentication > 1 ) + goto usage; + } + else if( strcmp( p, "mode" ) == 0 ) + { + opt.mode = atoi( q ); + if( opt.mode < 0 || opt.mode > 1 ) + goto usage; + } + else if( strcmp( p, "user_name" ) == 0 ) + opt.user_name = q; + else if( strcmp( p, "user_pwd" ) == 0 ) + opt.user_pwd = q; + else if( strcmp( p, "mail_from" ) == 0 ) + opt.mail_from = q; + else if( strcmp( p, "mail_to" ) == 0 ) + opt.mail_to = q; + else if( strcmp( p, "ca_file" ) == 0 ) + opt.ca_file = q; + else if( strcmp( p, "crt_file" ) == 0 ) + opt.crt_file = q; + else if( strcmp( p, "key_file" ) == 0 ) + opt.key_file = q; + else if( strcmp( p, "force_ciphersuite" ) == 0 ) + { + opt.force_ciphersuite[0] = -1; + + opt.force_ciphersuite[0] = mbedtls_ssl_get_ciphersuite_id( q ); + + if( opt.force_ciphersuite[0] <= 0 ) + goto usage; + + opt.force_ciphersuite[1] = 0; + } + else + goto usage; + } + + /* + * 0. Initialize the RNG and the session data + */ + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.1. Load the trusted CA + */ + mbedtls_printf( " . Loading the CA root certificate ..." ); + fflush( stdout ); + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.ca_file ) ) + ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); + else +#endif +#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_PEM_PARSE_C) + ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); +#else + { + ret = 1; + mbedtls_printf("MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined."); + } +#endif + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok (%d skipped)\n", ret ); + + /* + * 1.2. Load own certificate and private key + * + * (can be skipped if client authentication is not required) + */ + mbedtls_printf( " . Loading the client cert. and key..." ); + fflush( stdout ); + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.crt_file ) ) + ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file ); + else +#endif +#if defined(MBEDTLS_CERTS_C) + ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt, + mbedtls_test_cli_crt_len ); +#else + { + ret = -1; + mbedtls_printf("MBEDTLS_CERTS_C not defined."); + } +#endif + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.key_file ) ) + ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" ); + else +#endif +#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_PEM_PARSE_C) + ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_cli_key, + mbedtls_test_cli_key_len, NULL, 0 ); +#else + { + ret = -1; + mbedtls_printf("MBEDTLS_CERTS_C or MBEDTLS_PEM_PARSE_C not defined."); + } +#endif + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 2. Start the connection + */ + mbedtls_printf( " . Connecting to tcp/%s/%s...", opt.server_name, + opt.server_port ); + fflush( stdout ); + + if( ( ret = mbedtls_net_connect( &server_fd, opt.server_name, + opt.server_port, MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 3. Setup stuff + */ + mbedtls_printf( " . Setting up the SSL/TLS structure..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + /* OPTIONAL is not optimal for security, + * but makes interop easier in this simplified example */ + mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + + if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER ) + mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite ); + + mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &clicert, &pkey ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + mbedtls_printf( " ok\n" ); + + if( opt.mode == MODE_SSL_TLS ) + { + if( do_handshake( &ssl ) != 0 ) + goto exit; + + mbedtls_printf( " > Get header from server:" ); + fflush( stdout ); + + ret = write_ssl_and_get_response( &ssl, buf, 0 ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write EHLO to server:" ); + fflush( stdout ); + + gethostname( hostname, 32 ); + len = sprintf( (char *) buf, "EHLO %s\r\n", hostname ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + } + else + { + mbedtls_printf( " > Get header from server:" ); + fflush( stdout ); + + ret = write_and_get_response( &server_fd, buf, 0 ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write EHLO to server:" ); + fflush( stdout ); + + gethostname( hostname, 32 ); + len = sprintf( (char *) buf, "EHLO %s\r\n", hostname ); + ret = write_and_get_response( &server_fd, buf, len ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write STARTTLS to server:" ); + fflush( stdout ); + + gethostname( hostname, 32 ); + len = sprintf( (char *) buf, "STARTTLS\r\n" ); + ret = write_and_get_response( &server_fd, buf, len ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + if( do_handshake( &ssl ) != 0 ) + goto exit; + } + +#if defined(MBEDTLS_BASE64_C) + if( opt.authentication ) + { + mbedtls_printf( " > Write AUTH LOGIN to server:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, "AUTH LOGIN\r\n" ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 200 || ret > 399 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write username to server: %s", opt.user_name ); + fflush( stdout ); + + ret = mbedtls_base64_encode( base, sizeof( base ), &n, (const unsigned char *) opt.user_name, + strlen( opt.user_name ) ); + + if( ret != 0 ) { + mbedtls_printf( " failed\n ! mbedtls_base64_encode returned %d\n\n", ret ); + goto exit; + } + len = sprintf( (char *) buf, "%s\r\n", base ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 300 || ret > 399 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write password to server: %s", opt.user_pwd ); + fflush( stdout ); + + ret = mbedtls_base64_encode( base, sizeof( base ), &n, (const unsigned char *) opt.user_pwd, + strlen( opt.user_pwd ) ); + + if( ret != 0 ) { + mbedtls_printf( " failed\n ! mbedtls_base64_encode returned %d\n\n", ret ); + goto exit; + } + len = sprintf( (char *) buf, "%s\r\n", base ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 200 || ret > 399 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + } +#endif + + mbedtls_printf( " > Write MAIL FROM to server:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, "MAIL FROM:<%s>\r\n", opt.mail_from ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write RCPT TO to server:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, "RCPT TO:<%s>\r\n", opt.mail_to ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write DATA to server:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, "DATA\r\n" ); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 300 || ret > 399 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_printf( " > Write content to server:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, "From: %s\r\nSubject: mbed TLS Test mail\r\n\r\n" + "This is a simple test mail from the " + "mbed TLS mail client example.\r\n" + "\r\n" + "Enjoy!", opt.mail_from ); + ret = write_ssl_data( &ssl, buf, len ); + + len = sprintf( (char *) buf, "\r\n.\r\n"); + ret = write_ssl_and_get_response( &ssl, buf, len ); + if( ret < 200 || ret > 299 ) + { + mbedtls_printf( " failed\n ! server responded with %d\n\n", ret ); + goto exit; + } + + mbedtls_printf(" ok\n" ); + + mbedtls_ssl_close_notify( &ssl ); + +exit: + + mbedtls_net_free( &server_fd ); + mbedtls_x509_crt_free( &clicert ); + mbedtls_x509_crt_free( &cacert ); + mbedtls_pk_free( &pkey ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && + MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C ** + MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_pthread_server.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_pthread_server.c new file mode 100644 index 0000000..9a05ad8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_pthread_server.c @@ -0,0 +1,529 @@ +/* + * SSL server demonstration program using pthread for handling multiple + * clients. + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#define mbedtls_snprintf snprintf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \ + !defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_THREADING_C) || !defined(MBEDTLS_THREADING_PTHREAD) || \ + !defined(MBEDTLS_PEM_PARSE_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_CERTS_C and/or MBEDTLS_ENTROPY_C " + "and/or MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or " + "MBEDTLS_THREADING_C and/or MBEDTLS_THREADING_PTHREAD " + "and/or MBEDTLS_PEM_PARSE_C not defined.\n"); + return( 0 ); +} +#else + +#include +#include + +#if defined(_WIN32) +#include +#endif + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" +#include "mbedtls/ssl.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/error.h" + +#if defined(MBEDTLS_SSL_CACHE_C) +#include "mbedtls/ssl_cache.h" +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#include "mbedtls/memory_buffer_alloc.h" +#endif + +#define HTTP_RESPONSE \ + "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ + "

      mbed TLS Test Server

      \r\n" \ + "

      Successful connection using: %s

      \r\n" + +#define DEBUG_LEVEL 0 + +#define MAX_NUM_THREADS 5 + +mbedtls_threading_mutex_t debug_mutex; + +static void my_mutexed_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + long int thread_id = (long int) pthread_self(); + + mbedtls_mutex_lock( &debug_mutex ); + + ((void) level); + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: [ #%ld ] %s", + file, line, thread_id, str ); + fflush( (FILE *) ctx ); + + mbedtls_mutex_unlock( &debug_mutex ); +} + +typedef struct { + mbedtls_net_context client_fd; + int thread_complete; + const mbedtls_ssl_config *config; +} thread_info_t; + +typedef struct { + int active; + thread_info_t data; + pthread_t thread; +} pthread_info_t; + +static thread_info_t base_info; +static pthread_info_t threads[MAX_NUM_THREADS]; + +static void *handle_ssl_connection( void *data ) +{ + int ret, len; + thread_info_t *thread_info = (thread_info_t *) data; + mbedtls_net_context *client_fd = &thread_info->client_fd; + long int thread_id = (long int) pthread_self(); + unsigned char buf[1024]; + mbedtls_ssl_context ssl; + + /* Make sure memory references are valid */ + mbedtls_ssl_init( &ssl ); + + mbedtls_printf( " [ #%ld ] Setting up SSL/TLS data\n", thread_id ); + + /* + * 4. Get the SSL context ready + */ + if( ( ret = mbedtls_ssl_setup( &ssl, thread_info->config ) ) != 0 ) + { + mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_setup returned -0x%04x\n", + thread_id, -ret ); + goto thread_exit; + } + + mbedtls_ssl_set_bio( &ssl, client_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + /* + * 5. Handshake + */ + mbedtls_printf( " [ #%ld ] Performing the SSL/TLS handshake\n", thread_id ); + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_handshake returned -0x%04x\n", + thread_id, -ret ); + goto thread_exit; + } + } + + mbedtls_printf( " [ #%ld ] ok\n", thread_id ); + + /* + * 6. Read the HTTP Request + */ + mbedtls_printf( " [ #%ld ] < Read from client\n", thread_id ); + + do + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + ret = mbedtls_ssl_read( &ssl, buf, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " [ #%ld ] connection was closed gracefully\n", + thread_id ); + goto thread_exit; + + case MBEDTLS_ERR_NET_CONN_RESET: + mbedtls_printf( " [ #%ld ] connection was reset by peer\n", + thread_id ); + goto thread_exit; + + default: + mbedtls_printf( " [ #%ld ] mbedtls_ssl_read returned -0x%04x\n", + thread_id, -ret ); + goto thread_exit; + } + } + + len = ret; + mbedtls_printf( " [ #%ld ] %d bytes read\n=====\n%s\n=====\n", + thread_id, len, (char *) buf ); + + if( ret > 0 ) + break; + } + while( 1 ); + + /* + * 7. Write the 200 Response + */ + mbedtls_printf( " [ #%ld ] > Write to client:\n", thread_id ); + + len = sprintf( (char *) buf, HTTP_RESPONSE, + mbedtls_ssl_get_ciphersuite( &ssl ) ); + + while( ( ret = mbedtls_ssl_write( &ssl, buf, len ) ) <= 0 ) + { + if( ret == MBEDTLS_ERR_NET_CONN_RESET ) + { + mbedtls_printf( " [ #%ld ] failed: peer closed the connection\n", + thread_id ); + goto thread_exit; + } + + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_write returned -0x%04x\n", + thread_id, ret ); + goto thread_exit; + } + } + + len = ret; + mbedtls_printf( " [ #%ld ] %d bytes written\n=====\n%s\n=====\n", + thread_id, len, (char *) buf ); + + mbedtls_printf( " [ #%ld ] . Closing the connection...", thread_id ); + + while( ( ret = mbedtls_ssl_close_notify( &ssl ) ) < 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_close_notify returned -0x%04x\n", + thread_id, ret ); + goto thread_exit; + } + } + + mbedtls_printf( " ok\n" ); + + ret = 0; + +thread_exit: + +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf(" [ #%ld ] Last error was: -0x%04x - %s\n\n", + thread_id, -ret, error_buf ); + } +#endif + + mbedtls_net_free( client_fd ); + mbedtls_ssl_free( &ssl ); + + thread_info->thread_complete = 1; + + return( NULL ); +} + +static int thread_create( mbedtls_net_context *client_fd ) +{ + int ret, i; + + /* + * Find in-active or finished thread slot + */ + for( i = 0; i < MAX_NUM_THREADS; i++ ) + { + if( threads[i].active == 0 ) + break; + + if( threads[i].data.thread_complete == 1 ) + { + mbedtls_printf( " [ main ] Cleaning up thread %d\n", i ); + pthread_join(threads[i].thread, NULL ); + memset( &threads[i], 0, sizeof(pthread_info_t) ); + break; + } + } + + if( i == MAX_NUM_THREADS ) + return( -1 ); + + /* + * Fill thread-info for thread + */ + memcpy( &threads[i].data, &base_info, sizeof(base_info) ); + threads[i].active = 1; + memcpy( &threads[i].data.client_fd, client_fd, sizeof( mbedtls_net_context ) ); + + if( ( ret = pthread_create( &threads[i].thread, NULL, handle_ssl_connection, + &threads[i].data ) ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} + +int main( void ) +{ + int ret; + mbedtls_net_context listen_fd, client_fd; + const char pers[] = "ssl_pthread_server"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_config conf; + mbedtls_x509_crt srvcert; + mbedtls_x509_crt cachain; + mbedtls_pk_context pkey; +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + unsigned char alloc_buf[100000]; +#endif +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_context cache; +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); +#endif + +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_init( &cache ); +#endif + + mbedtls_x509_crt_init( &srvcert ); + mbedtls_x509_crt_init( &cachain ); + + mbedtls_ssl_config_init( &conf ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + memset( threads, 0, sizeof(threads) ); + mbedtls_net_init( &listen_fd ); + mbedtls_net_init( &client_fd ); + + mbedtls_mutex_init( &debug_mutex ); + + base_info.config = &conf; + + /* + * We use only a single entropy source that is used in all the threads. + */ + mbedtls_entropy_init( &entropy ); + + /* + * 1. Load the certificates and private RSA key + */ + mbedtls_printf( "\n . Loading the server cert. and key..." ); + fflush( stdout ); + + /* + * This demonstration program uses embedded test certificates. + * Instead, you may want to use mbedtls_x509_crt_parse_file() to read the + * server and CA certificates, as well as mbedtls_pk_parse_keyfile(). + */ + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_srv_crt, + mbedtls_test_srv_crt_len ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_x509_crt_parse( &cachain, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + mbedtls_pk_init( &pkey ); + ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key, + mbedtls_test_srv_key_len, NULL, 0 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1b. Seed the random number generator + */ + mbedtls_printf( " . Seeding the random number generator..." ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed: mbedtls_ctr_drbg_seed returned -0x%04x\n", + -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1c. Prepare SSL configuration + */ + mbedtls_printf( " . Setting up the SSL data...." ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_SERVER, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed: mbedtls_ssl_config_defaults returned -0x%04x\n", + -ret ); + goto exit; + } + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_mutexed_debug, stdout ); + + /* mbedtls_ssl_cache_get() and mbedtls_ssl_cache_set() are thread-safe if + * MBEDTLS_THREADING_C is set. + */ +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_conf_session_cache( &conf, &cache, + mbedtls_ssl_cache_get, + mbedtls_ssl_cache_set ); +#endif + + mbedtls_ssl_conf_ca_chain( &conf, &cachain, NULL ); + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + + /* + * 2. Setup the listening TCP socket + */ + mbedtls_printf( " . Bind on https://localhost:4433/ ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_bind( &listen_fd, NULL, "4433", MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +reset: +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf( " [ main ] Last error was: -0x%04x - %s\n", -ret, error_buf ); + } +#endif + + /* + * 3. Wait until a client connects + */ + mbedtls_printf( " [ main ] Waiting for a remote connection\n" ); + + if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd, + NULL, 0, NULL ) ) != 0 ) + { + mbedtls_printf( " [ main ] failed: mbedtls_net_accept returned -0x%04x\n", ret ); + goto exit; + } + + mbedtls_printf( " [ main ] ok\n" ); + mbedtls_printf( " [ main ] Creating a new thread\n" ); + + if( ( ret = thread_create( &client_fd ) ) != 0 ) + { + mbedtls_printf( " [ main ] failed: thread_create returned %d\n", ret ); + mbedtls_net_free( &client_fd ); + goto reset; + } + + ret = 0; + goto reset; + +exit: + mbedtls_x509_crt_free( &srvcert ); + mbedtls_pk_free( &pkey ); +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_free( &cache ); +#endif + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + mbedtls_ssl_config_free( &conf ); + + mbedtls_net_free( &listen_fd ); + + mbedtls_mutex_free( &debug_mutex ); + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_free(); +#endif + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} + +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C && + MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && + MBEDTLS_RSA_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_THREADING_C && + MBEDTLS_THREADING_PTHREAD && MBEDTLS_PEM_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server.c new file mode 100644 index 0000000..fd54f17 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server.c @@ -0,0 +1,401 @@ +/* + * SSL server demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \ + !defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \ + !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_PEM_PARSE_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_CERTS_C and/or MBEDTLS_ENTROPY_C " + "and/or MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C " + "and/or MBEDTLS_PEM_PARSE_C not defined.\n"); + return( 0 ); +} +#else + +#include +#include + +#if defined(_WIN32) +#include +#endif + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" +#include "mbedtls/ssl.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/error.h" +#include "mbedtls/debug.h" + +#if defined(MBEDTLS_SSL_CACHE_C) +#include "mbedtls/ssl_cache.h" +#endif + +#define HTTP_RESPONSE \ + "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ + "

      mbed TLS Test Server

      \r\n" \ + "

      Successful connection using: %s

      \r\n" + +#define DEBUG_LEVEL 0 + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +int main( void ) +{ + int ret, len; + mbedtls_net_context listen_fd, client_fd; + unsigned char buf[1024]; + const char *pers = "ssl_server"; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt srvcert; + mbedtls_pk_context pkey; +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_context cache; +#endif + + mbedtls_net_init( &listen_fd ); + mbedtls_net_init( &client_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_init( &cache ); +#endif + mbedtls_x509_crt_init( &srvcert ); + mbedtls_pk_init( &pkey ); + mbedtls_entropy_init( &entropy ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( DEBUG_LEVEL ); +#endif + + /* + * 1. Load the certificates and private RSA key + */ + mbedtls_printf( "\n . Loading the server cert. and key..." ); + fflush( stdout ); + + /* + * This demonstration program uses embedded test certificates. + * Instead, you may want to use mbedtls_x509_crt_parse_file() to read the + * server and CA certificates, as well as mbedtls_pk_parse_keyfile(). + */ + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_srv_crt, + mbedtls_test_srv_crt_len ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret ); + goto exit; + } + + ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key, + mbedtls_test_srv_key_len, NULL, 0 ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 2. Setup the listening TCP socket + */ + mbedtls_printf( " . Bind on https://localhost:4433/ ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_bind( &listen_fd, NULL, "4433", MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 3. Seed the RNG + */ + mbedtls_printf( " . Seeding the random number generator..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 4. Setup stuff + */ + mbedtls_printf( " . Setting up the SSL data...." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_SERVER, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_conf_session_cache( &conf, &cache, + mbedtls_ssl_cache_get, + mbedtls_ssl_cache_set ); +#endif + + mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +reset: +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf("Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &client_fd ); + + mbedtls_ssl_session_reset( &ssl ); + + /* + * 3. Wait until a client connects + */ + mbedtls_printf( " . Waiting for a remote connection ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd, + NULL, 0, NULL ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_accept returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + mbedtls_printf( " ok\n" ); + + /* + * 5. Handshake + */ + mbedtls_printf( " . Performing the SSL/TLS handshake..." ); + fflush( stdout ); + + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned %d\n\n", ret ); + goto reset; + } + } + + mbedtls_printf( " ok\n" ); + + /* + * 6. Read the HTTP Request + */ + mbedtls_printf( " < Read from client:" ); + fflush( stdout ); + + do + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + ret = mbedtls_ssl_read( &ssl, buf, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " connection was closed gracefully\n" ); + break; + + case MBEDTLS_ERR_NET_CONN_RESET: + mbedtls_printf( " connection was reset by peer\n" ); + break; + + default: + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret ); + break; + } + + break; + } + + len = ret; + mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf ); + + if( ret > 0 ) + break; + } + while( 1 ); + + /* + * 7. Write the 200 Response + */ + mbedtls_printf( " > Write to client:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, HTTP_RESPONSE, + mbedtls_ssl_get_ciphersuite( &ssl ) ); + + while( ( ret = mbedtls_ssl_write( &ssl, buf, len ) ) <= 0 ) + { + if( ret == MBEDTLS_ERR_NET_CONN_RESET ) + { + mbedtls_printf( " failed\n ! peer closed the connection\n\n" ); + goto reset; + } + + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto exit; + } + } + + len = ret; + mbedtls_printf( " %d bytes written\n\n%s\n", len, (char *) buf ); + + mbedtls_printf( " . Closing the connection..." ); + + while( ( ret = mbedtls_ssl_close_notify( &ssl ) ) < 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_close_notify returned %d\n\n", ret ); + goto reset; + } + } + + mbedtls_printf( " ok\n" ); + + ret = 0; + goto reset; + +exit: + +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf("Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); + + mbedtls_x509_crt_free( &srvcert ); + mbedtls_pk_free( &pkey ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_free( &cache ); +#endif + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C && + MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && + MBEDTLS_RSA_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_X509_CRT_PARSE_C + && MBEDTLS_FS_IO && MBEDTLS_PEM_PARSE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server2.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server2.c new file mode 100644 index 0000000..96bd35f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/ssl/ssl_server2.c @@ -0,0 +1,2361 @@ +/* + * SSL client with options + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_free free +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_calloc calloc +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_SRV_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/net_sockets.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/certs.h" +#include "mbedtls/x509.h" +#include "mbedtls/error.h" +#include "mbedtls/debug.h" +#include "mbedtls/timing.h" + +#include +#include +#include +#include + +#if !defined(_MSC_VER) +#include +#endif + +#if !defined(_WIN32) +#include +#endif + +#if defined(MBEDTLS_SSL_CACHE_C) +#include "mbedtls/ssl_cache.h" +#endif + +#if defined(MBEDTLS_SSL_TICKET_C) +#include "mbedtls/ssl_ticket.h" +#endif + +#if defined(MBEDTLS_SSL_COOKIE_C) +#include "mbedtls/ssl_cookie.h" +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#include "mbedtls/memory_buffer_alloc.h" +#endif + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && defined(MBEDTLS_FS_IO) +#define SNI_OPTION +#endif + +#if defined(_WIN32) +#include +#endif + +#define DFL_SERVER_ADDR NULL +#define DFL_SERVER_PORT "4433" +#define DFL_DEBUG_LEVEL 0 +#define DFL_NBIO 0 +#define DFL_READ_TIMEOUT 0 +#define DFL_CA_FILE "" +#define DFL_CA_PATH "" +#define DFL_CRT_FILE "" +#define DFL_KEY_FILE "" +#define DFL_CRT_FILE2 "" +#define DFL_KEY_FILE2 "" +#define DFL_PSK "" +#define DFL_PSK_IDENTITY "Client_identity" +#define DFL_ECJPAKE_PW NULL +#define DFL_PSK_LIST NULL +#define DFL_FORCE_CIPHER 0 +#define DFL_VERSION_SUITES NULL +#define DFL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION_DISABLED +#define DFL_ALLOW_LEGACY -2 +#define DFL_RENEGOTIATE 0 +#define DFL_RENEGO_DELAY -2 +#define DFL_RENEGO_PERIOD ( (uint64_t)-1 ) +#define DFL_EXCHANGES 1 +#define DFL_MIN_VERSION -1 +#define DFL_MAX_VERSION -1 +#define DFL_ARC4 -1 +#define DFL_AUTH_MODE -1 +#define DFL_MFL_CODE MBEDTLS_SSL_MAX_FRAG_LEN_NONE +#define DFL_TRUNC_HMAC -1 +#define DFL_TICKETS MBEDTLS_SSL_SESSION_TICKETS_ENABLED +#define DFL_TICKET_TIMEOUT 86400 +#define DFL_CACHE_MAX -1 +#define DFL_CACHE_TIMEOUT -1 +#define DFL_SNI NULL +#define DFL_ALPN_STRING NULL +#define DFL_DHM_FILE NULL +#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM +#define DFL_COOKIES 1 +#define DFL_ANTI_REPLAY -1 +#define DFL_HS_TO_MIN 0 +#define DFL_HS_TO_MAX 0 +#define DFL_BADMAC_LIMIT -1 +#define DFL_EXTENDED_MS -1 +#define DFL_ETM -1 + +#define LONG_RESPONSE "

      01-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \ + "02-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \ + "03-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \ + "04-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \ + "05-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \ + "06-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \ + "07-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah

      \r\n" + +/* Uncomment LONG_RESPONSE at the end of HTTP_RESPONSE to test sending longer + * packets (for fragmentation purposes) */ +#define HTTP_RESPONSE \ + "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ + "

      mbed TLS Test Server

      \r\n" \ + "

      Successful connection using: %s

      \r\n" // LONG_RESPONSE + +/* + * Size of the basic I/O buffer. Able to hold our default response. + * + * You will need to adapt the mbedtls_ssl_get_bytes_avail() test in ssl-opt.sh + * if you change this value to something outside the range <= 100 or > 500 + */ +#define IO_BUF_LEN 200 + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +#if defined(MBEDTLS_FS_IO) +#define USAGE_IO \ + " ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \ + " default: \"\" (pre-loaded)\n" \ + " ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \ + " default: \"\" (pre-loaded) (overrides ca_file)\n" \ + " crt_file=%%s Your own cert and chain (in bottom to top order, top may be omitted)\n" \ + " default: see note after key_file2\n" \ + " key_file=%%s default: see note after key_file2\n" \ + " crt_file2=%%s Your second cert and chain (in bottom to top order, top may be omitted)\n" \ + " default: see note after key_file2\n" \ + " key_file2=%%s default: see note below\n" \ + " note: if neither crt_file/key_file nor crt_file2/key_file2 are used,\n" \ + " preloaded certificate(s) and key(s) are used if available\n" \ + " dhm_file=%%s File containing Diffie-Hellman parameters\n" \ + " default: preloaded parameters\n" +#else +#define USAGE_IO \ + "\n" \ + " No file operations available (MBEDTLS_FS_IO not defined)\n" \ + "\n" +#endif /* MBEDTLS_FS_IO */ +#else +#define USAGE_IO "" +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +#define USAGE_PSK \ + " psk=%%s default: \"\" (in hex, without 0x)\n" \ + " psk_identity=%%s default: \"Client_identity\"\n" +#else +#define USAGE_PSK "" +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +#define USAGE_TICKETS \ + " tickets=%%d default: 1 (enabled)\n" \ + " ticket_timeout=%%d default: 86400 (one day)\n" +#else +#define USAGE_TICKETS "" +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_CACHE_C) +#define USAGE_CACHE \ + " cache_max=%%d default: cache default (50)\n" \ + " cache_timeout=%%d default: cache default (1d)\n" +#else +#define USAGE_CACHE "" +#endif /* MBEDTLS_SSL_CACHE_C */ + +#if defined(SNI_OPTION) +#define USAGE_SNI \ + " sni=%%s name1,cert1,key1,ca1,crl1,auth1[,...]\n" \ + " default: disabled\n" +#else +#define USAGE_SNI "" +#endif /* SNI_OPTION */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +#define USAGE_MAX_FRAG_LEN \ + " max_frag_len=%%d default: 16384 (tls default)\n" \ + " options: 512, 1024, 2048, 4096\n" +#else +#define USAGE_MAX_FRAG_LEN "" +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +#define USAGE_TRUNC_HMAC \ + " trunc_hmac=%%d default: library default\n" +#else +#define USAGE_TRUNC_HMAC "" +#endif + +#if defined(MBEDTLS_SSL_ALPN) +#define USAGE_ALPN \ + " alpn=%%s default: \"\" (disabled)\n" \ + " example: spdy/1,http/1.1\n" +#else +#define USAGE_ALPN "" +#endif /* MBEDTLS_SSL_ALPN */ + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) +#define USAGE_COOKIES \ + " cookies=0/1/-1 default: 1 (enabled)\n" \ + " 0: disabled, -1: library default (broken)\n" +#else +#define USAGE_COOKIES "" +#endif + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +#define USAGE_ANTI_REPLAY \ + " anti_replay=0/1 default: (library default: enabled)\n" +#else +#define USAGE_ANTI_REPLAY "" +#endif + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) +#define USAGE_BADMAC_LIMIT \ + " badmac_limit=%%d default: (library default: disabled)\n" +#else +#define USAGE_BADMAC_LIMIT "" +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) +#define USAGE_DTLS \ + " dtls=%%d default: 0 (TLS)\n" \ + " hs_timeout=%%d-%%d default: (library default: 1000-60000)\n" \ + " range of DTLS handshake timeouts in millisecs\n" +#else +#define USAGE_DTLS "" +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +#define USAGE_EMS \ + " extended_ms=0/1 default: (library default: on)\n" +#else +#define USAGE_EMS "" +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +#define USAGE_ETM \ + " etm=0/1 default: (library default: on)\n" +#else +#define USAGE_ETM "" +#endif + +#if defined(MBEDTLS_SSL_RENEGOTIATION) +#define USAGE_RENEGO \ + " renegotiation=%%d default: 0 (disabled)\n" \ + " renegotiate=%%d default: 0 (disabled)\n" \ + " renego_delay=%%d default: -2 (library default)\n" \ + " renego_period=%%d default: (2^64 - 1 for TLS, 2^48 - 1 for DTLS)\n" +#else +#define USAGE_RENEGO "" +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +#define USAGE_ECJPAKE \ + " ecjpake_pw=%%s default: none (disabled)\n" +#else +#define USAGE_ECJPAKE "" +#endif + +#define USAGE \ + "\n usage: ssl_server2 param=<>...\n" \ + "\n acceptable parameters:\n" \ + " server_addr=%%d default: (all interfaces)\n" \ + " server_port=%%d default: 4433\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ + " nbio=%%d default: 0 (blocking I/O)\n" \ + " options: 1 (non-blocking), 2 (added delays)\n" \ + " read_timeout=%%d default: 0 ms (no timeout)\n" \ + "\n" \ + USAGE_DTLS \ + USAGE_COOKIES \ + USAGE_ANTI_REPLAY \ + USAGE_BADMAC_LIMIT \ + "\n" \ + " auth_mode=%%s default: (library default: none)\n" \ + " options: none, optional, required\n" \ + USAGE_IO \ + USAGE_SNI \ + "\n" \ + USAGE_PSK \ + USAGE_ECJPAKE \ + "\n" \ + " allow_legacy=%%d default: (library default: no)\n" \ + USAGE_RENEGO \ + " exchanges=%%d default: 1\n" \ + "\n" \ + USAGE_TICKETS \ + USAGE_CACHE \ + USAGE_MAX_FRAG_LEN \ + USAGE_TRUNC_HMAC \ + USAGE_ALPN \ + USAGE_EMS \ + USAGE_ETM \ + "\n" \ + " arc4=%%d default: (library default: 0)\n" \ + " min_version=%%s default: (library default: tls1)\n" \ + " max_version=%%s default: (library default: tls1_2)\n" \ + " force_version=%%s default: \"\" (none)\n" \ + " options: ssl3, tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \ + "\n" \ + " version_suites=a,b,c,d per-version ciphersuites\n" \ + " in order from ssl3 to tls1_2\n" \ + " default: all enabled\n" \ + " force_ciphersuite= default: all enabled\n" \ + " acceptable ciphersuite names:\n" + + +#define PUT_UINT64_BE(out_be,in_le,i) \ +{ \ + (out_be)[(i) + 0] = (unsigned char)( ( (in_le) >> 56 ) & 0xFF ); \ + (out_be)[(i) + 1] = (unsigned char)( ( (in_le) >> 48 ) & 0xFF ); \ + (out_be)[(i) + 2] = (unsigned char)( ( (in_le) >> 40 ) & 0xFF ); \ + (out_be)[(i) + 3] = (unsigned char)( ( (in_le) >> 32 ) & 0xFF ); \ + (out_be)[(i) + 4] = (unsigned char)( ( (in_le) >> 24 ) & 0xFF ); \ + (out_be)[(i) + 5] = (unsigned char)( ( (in_le) >> 16 ) & 0xFF ); \ + (out_be)[(i) + 6] = (unsigned char)( ( (in_le) >> 8 ) & 0xFF ); \ + (out_be)[(i) + 7] = (unsigned char)( ( (in_le) >> 0 ) & 0xFF ); \ +} + +/* + * global options + */ +struct options +{ + const char *server_addr; /* address on which the ssl service runs */ + const char *server_port; /* port on which the ssl service runs */ + int debug_level; /* level of debugging */ + int nbio; /* should I/O be blocking? */ + uint32_t read_timeout; /* timeout on mbedtls_ssl_read() in milliseconds */ + const char *ca_file; /* the file with the CA certificate(s) */ + const char *ca_path; /* the path with the CA certificate(s) reside */ + const char *crt_file; /* the file with the server certificate */ + const char *key_file; /* the file with the server key */ + const char *crt_file2; /* the file with the 2nd server certificate */ + const char *key_file2; /* the file with the 2nd server key */ + const char *psk; /* the pre-shared key */ + const char *psk_identity; /* the pre-shared key identity */ + char *psk_list; /* list of PSK id/key pairs for callback */ + const char *ecjpake_pw; /* the EC J-PAKE password */ + int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ + const char *version_suites; /* per-version ciphersuites */ + int renegotiation; /* enable / disable renegotiation */ + int allow_legacy; /* allow legacy renegotiation */ + int renegotiate; /* attempt renegotiation? */ + int renego_delay; /* delay before enforcing renegotiation */ + uint64_t renego_period; /* period for automatic renegotiation */ + int exchanges; /* number of data exchanges */ + int min_version; /* minimum protocol version accepted */ + int max_version; /* maximum protocol version accepted */ + int arc4; /* flag for arc4 suites support */ + int auth_mode; /* verify mode for connection */ + unsigned char mfl_code; /* code for maximum fragment length */ + int trunc_hmac; /* accept truncated hmac? */ + int tickets; /* enable / disable session tickets */ + int ticket_timeout; /* session ticket lifetime */ + int cache_max; /* max number of session cache entries */ + int cache_timeout; /* expiration delay of session cache entries */ + char *sni; /* string describing sni information */ + const char *alpn_string; /* ALPN supported protocols */ + const char *dhm_file; /* the file with the DH parameters */ + int extended_ms; /* allow negotiation of extended MS? */ + int etm; /* allow negotiation of encrypt-then-MAC? */ + int transport; /* TLS or DTLS? */ + int cookies; /* Use cookies for DTLS? -1 to break them */ + int anti_replay; /* Use anti-replay for DTLS? -1 for default */ + uint32_t hs_to_min; /* Initial value of DTLS handshake timer */ + uint32_t hs_to_max; /* Max value of DTLS handshake timer */ + int badmac_limit; /* Limit of records with bad MAC */ +} opt; + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + const char *p, *basename; + + /* Extract basename from file */ + for( p = basename = file; *p != '\0'; p++ ) + if( *p == '/' || *p == '\\' ) + basename = p + 1; + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str ); + fflush( (FILE *) ctx ); +} + +/* + * Test recv/send functions that make sure each try returns + * WANT_READ/WANT_WRITE at least once before sucesseding + */ +static int my_recv( void *ctx, unsigned char *buf, size_t len ) +{ + static int first_try = 1; + int ret; + + if( first_try ) + { + first_try = 0; + return( MBEDTLS_ERR_SSL_WANT_READ ); + } + + ret = mbedtls_net_recv( ctx, buf, len ); + if( ret != MBEDTLS_ERR_SSL_WANT_READ ) + first_try = 1; /* Next call will be a new operation */ + return( ret ); +} + +static int my_send( void *ctx, const unsigned char *buf, size_t len ) +{ + static int first_try = 1; + int ret; + + if( first_try ) + { + first_try = 0; + return( MBEDTLS_ERR_SSL_WANT_WRITE ); + } + + ret = mbedtls_net_send( ctx, buf, len ); + if( ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + first_try = 1; /* Next call will be a new operation */ + return( ret ); +} + +/* + * Return authmode from string, or -1 on error + */ +static int get_auth_mode( const char *s ) +{ + if( strcmp( s, "none" ) == 0 ) + return( MBEDTLS_SSL_VERIFY_NONE ); + if( strcmp( s, "optional" ) == 0 ) + return( MBEDTLS_SSL_VERIFY_OPTIONAL ); + if( strcmp( s, "required" ) == 0 ) + return( MBEDTLS_SSL_VERIFY_REQUIRED ); + + return( -1 ); +} + +/* + * Used by sni_parse and psk_parse to handle coma-separated lists + */ +#define GET_ITEM( dst ) \ + dst = p; \ + while( *p != ',' ) \ + if( ++p > end ) \ + goto error; \ + *p++ = '\0'; + +#if defined(SNI_OPTION) +typedef struct _sni_entry sni_entry; + +struct _sni_entry { + const char *name; + mbedtls_x509_crt *cert; + mbedtls_pk_context *key; + mbedtls_x509_crt* ca; + mbedtls_x509_crl* crl; + int authmode; + sni_entry *next; +}; + +void sni_free( sni_entry *head ) +{ + sni_entry *cur = head, *next; + + while( cur != NULL ) + { + mbedtls_x509_crt_free( cur->cert ); + mbedtls_free( cur->cert ); + + mbedtls_pk_free( cur->key ); + mbedtls_free( cur->key ); + + mbedtls_x509_crt_free( cur->ca ); + mbedtls_free( cur->ca ); + + mbedtls_x509_crl_free( cur->crl ); + mbedtls_free( cur->crl ); + + next = cur->next; + mbedtls_free( cur ); + cur = next; + } +} + +/* + * Parse a string of sextuples name1,crt1,key1,ca1,crl1,auth1[,...] + * into a usable sni_entry list. For ca1, crl1, auth1, the special value + * '-' means unset. If ca1 is unset, then crl1 is ignored too. + * + * Modifies the input string! This is not production quality! + */ +sni_entry *sni_parse( char *sni_string ) +{ + sni_entry *cur = NULL, *new = NULL; + char *p = sni_string; + char *end = p; + char *crt_file, *key_file, *ca_file, *crl_file, *auth_str; + + while( *end != '\0' ) + ++end; + *end = ','; + + while( p <= end ) + { + if( ( new = mbedtls_calloc( 1, sizeof( sni_entry ) ) ) == NULL ) + { + sni_free( cur ); + return( NULL ); + } + + GET_ITEM( new->name ); + GET_ITEM( crt_file ); + GET_ITEM( key_file ); + GET_ITEM( ca_file ); + GET_ITEM( crl_file ); + GET_ITEM( auth_str ); + + if( ( new->cert = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ) ) == NULL || + ( new->key = mbedtls_calloc( 1, sizeof( mbedtls_pk_context ) ) ) == NULL ) + goto error; + + mbedtls_x509_crt_init( new->cert ); + mbedtls_pk_init( new->key ); + + if( mbedtls_x509_crt_parse_file( new->cert, crt_file ) != 0 || + mbedtls_pk_parse_keyfile( new->key, key_file, "" ) != 0 ) + goto error; + + if( strcmp( ca_file, "-" ) != 0 ) + { + if( ( new->ca = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ) ) == NULL ) + goto error; + + mbedtls_x509_crt_init( new->ca ); + + if( mbedtls_x509_crt_parse_file( new->ca, ca_file ) != 0 ) + goto error; + } + + if( strcmp( crl_file, "-" ) != 0 ) + { + if( ( new->crl = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl ) ) ) == NULL ) + goto error; + + mbedtls_x509_crl_init( new->crl ); + + if( mbedtls_x509_crl_parse_file( new->crl, crl_file ) != 0 ) + goto error; + } + + if( strcmp( auth_str, "-" ) != 0 ) + { + if( ( new->authmode = get_auth_mode( auth_str ) ) < 0 ) + goto error; + } + else + new->authmode = DFL_AUTH_MODE; + + new->next = cur; + cur = new; + } + + return( cur ); + +error: + sni_free( new ); + sni_free( cur ); + return( NULL ); +} + +/* + * SNI callback. + */ +int sni_callback( void *p_info, mbedtls_ssl_context *ssl, + const unsigned char *name, size_t name_len ) +{ + const sni_entry *cur = (const sni_entry *) p_info; + + while( cur != NULL ) + { + if( name_len == strlen( cur->name ) && + memcmp( name, cur->name, name_len ) == 0 ) + { + if( cur->ca != NULL ) + mbedtls_ssl_set_hs_ca_chain( ssl, cur->ca, cur->crl ); + + if( cur->authmode != DFL_AUTH_MODE ) + mbedtls_ssl_set_hs_authmode( ssl, cur->authmode ); + + return( mbedtls_ssl_set_hs_own_cert( ssl, cur->cert, cur->key ) ); + } + + cur = cur->next; + } + + return( -1 ); +} + +#endif /* SNI_OPTION */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + +#define HEX2NUM( c ) \ + if( c >= '0' && c <= '9' ) \ + c -= '0'; \ + else if( c >= 'a' && c <= 'f' ) \ + c -= 'a' - 10; \ + else if( c >= 'A' && c <= 'F' ) \ + c -= 'A' - 10; \ + else \ + return( -1 ); + +/* + * Convert a hex string to bytes. + * Return 0 on success, -1 on error. + */ +int unhexify( unsigned char *output, const char *input, size_t *olen ) +{ + unsigned char c; + size_t j; + + *olen = strlen( input ); + if( *olen % 2 != 0 || *olen / 2 > MBEDTLS_PSK_MAX_LEN ) + return( -1 ); + *olen /= 2; + + for( j = 0; j < *olen * 2; j += 2 ) + { + c = input[j]; + HEX2NUM( c ); + output[ j / 2 ] = c << 4; + + c = input[j + 1]; + HEX2NUM( c ); + output[ j / 2 ] |= c; + } + + return( 0 ); +} + +typedef struct _psk_entry psk_entry; + +struct _psk_entry +{ + const char *name; + size_t key_len; + unsigned char key[MBEDTLS_PSK_MAX_LEN]; + psk_entry *next; +}; + +/* + * Free a list of psk_entry's + */ +void psk_free( psk_entry *head ) +{ + psk_entry *next; + + while( head != NULL ) + { + next = head->next; + mbedtls_free( head ); + head = next; + } +} + +/* + * Parse a string of pairs name1,key1[,name2,key2[,...]] + * into a usable psk_entry list. + * + * Modifies the input string! This is not production quality! + */ +psk_entry *psk_parse( char *psk_string ) +{ + psk_entry *cur = NULL, *new = NULL; + char *p = psk_string; + char *end = p; + char *key_hex; + + while( *end != '\0' ) + ++end; + *end = ','; + + while( p <= end ) + { + if( ( new = mbedtls_calloc( 1, sizeof( psk_entry ) ) ) == NULL ) + goto error; + + memset( new, 0, sizeof( psk_entry ) ); + + GET_ITEM( new->name ); + GET_ITEM( key_hex ); + + if( unhexify( new->key, key_hex, &new->key_len ) != 0 ) + goto error; + + new->next = cur; + cur = new; + } + + return( cur ); + +error: + psk_free( new ); + psk_free( cur ); + return( 0 ); +} + +/* + * PSK callback + */ +int psk_callback( void *p_info, mbedtls_ssl_context *ssl, + const unsigned char *name, size_t name_len ) +{ + psk_entry *cur = (psk_entry *) p_info; + + while( cur != NULL ) + { + if( name_len == strlen( cur->name ) && + memcmp( name, cur->name, name_len ) == 0 ) + { + return( mbedtls_ssl_set_hs_psk( ssl, cur->key, cur->key_len ) ); + } + + cur = cur->next; + } + + return( -1 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +static mbedtls_net_context listen_fd, client_fd; + +/* Interruption handler to ensure clean exit (for valgrind testing) */ +#if !defined(_WIN32) +static int received_sigterm = 0; +void term_handler( int sig ) +{ + ((void) sig); + received_sigterm = 1; + mbedtls_net_free( &listen_fd ); /* causes mbedtls_net_accept() to abort */ + mbedtls_net_free( &client_fd ); /* causes net_read() to abort */ +} +#endif + +int main( int argc, char *argv[] ) +{ + int ret = 0, len, written, frags, exchanges_left; + int version_suites[4][2]; + unsigned char buf[IO_BUF_LEN]; +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + unsigned char psk[MBEDTLS_PSK_MAX_LEN]; + size_t psk_len = 0; + psk_entry *psk_info = NULL; +#endif + const char *pers = "ssl_server2"; + unsigned char client_ip[16] = { 0 }; + size_t cliip_len; +#if defined(MBEDTLS_SSL_COOKIE_C) + mbedtls_ssl_cookie_ctx cookie_ctx; +#endif + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; +#if defined(MBEDTLS_TIMING_C) + mbedtls_timing_delay_context timer; +#endif +#if defined(MBEDTLS_SSL_RENEGOTIATION) + unsigned char renego_period[8] = { 0 }; +#endif +#if defined(MBEDTLS_X509_CRT_PARSE_C) + uint32_t flags; + mbedtls_x509_crt cacert; + mbedtls_x509_crt srvcert; + mbedtls_pk_context pkey; + mbedtls_x509_crt srvcert2; + mbedtls_pk_context pkey2; + int key_cert_init = 0, key_cert_init2 = 0; +#endif +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) + mbedtls_dhm_context dhm; +#endif +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_context cache; +#endif +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + mbedtls_ssl_ticket_context ticket_ctx; +#endif +#if defined(SNI_OPTION) + sni_entry *sni_info = NULL; +#endif +#if defined(MBEDTLS_SSL_ALPN) + const char *alpn_list[10]; +#endif +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + unsigned char alloc_buf[100000]; +#endif + + int i; + char *p, *q; + const int *list; + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); +#endif + + /* + * Make sure memory references are valid in case we exit early. + */ + mbedtls_net_init( &client_fd ); + mbedtls_net_init( &listen_fd ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + mbedtls_ctr_drbg_init( &ctr_drbg ); +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt_init( &cacert ); + mbedtls_x509_crt_init( &srvcert ); + mbedtls_pk_init( &pkey ); + mbedtls_x509_crt_init( &srvcert2 ); + mbedtls_pk_init( &pkey2 ); +#endif +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) + mbedtls_dhm_init( &dhm ); +#endif +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_init( &cache ); +#endif +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + mbedtls_ssl_ticket_init( &ticket_ctx ); +#endif +#if defined(MBEDTLS_SSL_ALPN) + memset( (void *) alpn_list, 0, sizeof( alpn_list ) ); +#endif +#if defined(MBEDTLS_SSL_COOKIE_C) + mbedtls_ssl_cookie_init( &cookie_ctx ); +#endif + +#if !defined(_WIN32) + /* Abort cleanly on SIGTERM and SIGINT */ + signal( SIGTERM, term_handler ); + signal( SIGINT, term_handler ); +#endif + + if( argc == 0 ) + { + usage: + if( ret == 0 ) + ret = 1; + + mbedtls_printf( USAGE ); + + list = mbedtls_ssl_list_ciphersuites(); + while( *list ) + { + mbedtls_printf(" %-42s", mbedtls_ssl_get_ciphersuite_name( *list ) ); + list++; + if( !*list ) + break; + mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name( *list ) ); + list++; + } + mbedtls_printf("\n"); + goto exit; + } + + opt.server_addr = DFL_SERVER_ADDR; + opt.server_port = DFL_SERVER_PORT; + opt.debug_level = DFL_DEBUG_LEVEL; + opt.nbio = DFL_NBIO; + opt.read_timeout = DFL_READ_TIMEOUT; + opt.ca_file = DFL_CA_FILE; + opt.ca_path = DFL_CA_PATH; + opt.crt_file = DFL_CRT_FILE; + opt.key_file = DFL_KEY_FILE; + opt.crt_file2 = DFL_CRT_FILE2; + opt.key_file2 = DFL_KEY_FILE2; + opt.psk = DFL_PSK; + opt.psk_identity = DFL_PSK_IDENTITY; + opt.psk_list = DFL_PSK_LIST; + opt.ecjpake_pw = DFL_ECJPAKE_PW; + opt.force_ciphersuite[0]= DFL_FORCE_CIPHER; + opt.version_suites = DFL_VERSION_SUITES; + opt.renegotiation = DFL_RENEGOTIATION; + opt.allow_legacy = DFL_ALLOW_LEGACY; + opt.renegotiate = DFL_RENEGOTIATE; + opt.renego_delay = DFL_RENEGO_DELAY; + opt.renego_period = DFL_RENEGO_PERIOD; + opt.exchanges = DFL_EXCHANGES; + opt.min_version = DFL_MIN_VERSION; + opt.max_version = DFL_MAX_VERSION; + opt.arc4 = DFL_ARC4; + opt.auth_mode = DFL_AUTH_MODE; + opt.mfl_code = DFL_MFL_CODE; + opt.trunc_hmac = DFL_TRUNC_HMAC; + opt.tickets = DFL_TICKETS; + opt.ticket_timeout = DFL_TICKET_TIMEOUT; + opt.cache_max = DFL_CACHE_MAX; + opt.cache_timeout = DFL_CACHE_TIMEOUT; + opt.sni = DFL_SNI; + opt.alpn_string = DFL_ALPN_STRING; + opt.dhm_file = DFL_DHM_FILE; + opt.transport = DFL_TRANSPORT; + opt.cookies = DFL_COOKIES; + opt.anti_replay = DFL_ANTI_REPLAY; + opt.hs_to_min = DFL_HS_TO_MIN; + opt.hs_to_max = DFL_HS_TO_MAX; + opt.badmac_limit = DFL_BADMAC_LIMIT; + opt.extended_ms = DFL_EXTENDED_MS; + opt.etm = DFL_ETM; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "server_port" ) == 0 ) + opt.server_port = q; + else if( strcmp( p, "server_addr" ) == 0 ) + opt.server_addr = q; + else if( strcmp( p, "dtls" ) == 0 ) + { + int t = atoi( q ); + if( t == 0 ) + opt.transport = MBEDTLS_SSL_TRANSPORT_STREAM; + else if( t == 1 ) + opt.transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; + else + goto usage; + } + else if( strcmp( p, "debug_level" ) == 0 ) + { + opt.debug_level = atoi( q ); + if( opt.debug_level < 0 || opt.debug_level > 65535 ) + goto usage; + } + else if( strcmp( p, "nbio" ) == 0 ) + { + opt.nbio = atoi( q ); + if( opt.nbio < 0 || opt.nbio > 2 ) + goto usage; + } + else if( strcmp( p, "read_timeout" ) == 0 ) + opt.read_timeout = atoi( q ); + else if( strcmp( p, "ca_file" ) == 0 ) + opt.ca_file = q; + else if( strcmp( p, "ca_path" ) == 0 ) + opt.ca_path = q; + else if( strcmp( p, "crt_file" ) == 0 ) + opt.crt_file = q; + else if( strcmp( p, "key_file" ) == 0 ) + opt.key_file = q; + else if( strcmp( p, "crt_file2" ) == 0 ) + opt.crt_file2 = q; + else if( strcmp( p, "key_file2" ) == 0 ) + opt.key_file2 = q; + else if( strcmp( p, "dhm_file" ) == 0 ) + opt.dhm_file = q; + else if( strcmp( p, "psk" ) == 0 ) + opt.psk = q; + else if( strcmp( p, "psk_identity" ) == 0 ) + opt.psk_identity = q; + else if( strcmp( p, "psk_list" ) == 0 ) + opt.psk_list = q; + else if( strcmp( p, "ecjpake_pw" ) == 0 ) + opt.ecjpake_pw = q; + else if( strcmp( p, "force_ciphersuite" ) == 0 ) + { + opt.force_ciphersuite[0] = mbedtls_ssl_get_ciphersuite_id( q ); + + if( opt.force_ciphersuite[0] == 0 ) + { + ret = 2; + goto usage; + } + opt.force_ciphersuite[1] = 0; + } + else if( strcmp( p, "version_suites" ) == 0 ) + opt.version_suites = q; + else if( strcmp( p, "renegotiation" ) == 0 ) + { + opt.renegotiation = (atoi( q )) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED : + MBEDTLS_SSL_RENEGOTIATION_DISABLED; + } + else if( strcmp( p, "allow_legacy" ) == 0 ) + { + switch( atoi( q ) ) + { + case -1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE; break; + case 0: opt.allow_legacy = MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION; break; + case 1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION; break; + default: goto usage; + } + } + else if( strcmp( p, "renegotiate" ) == 0 ) + { + opt.renegotiate = atoi( q ); + if( opt.renegotiate < 0 || opt.renegotiate > 1 ) + goto usage; + } + else if( strcmp( p, "renego_delay" ) == 0 ) + { + opt.renego_delay = atoi( q ); + } + else if( strcmp( p, "renego_period" ) == 0 ) + { +#if defined(_MSC_VER) + opt.renego_period = _strtoui64( q, NULL, 10 ); +#else + if( sscanf( q, "%" SCNu64, &opt.renego_period ) != 1 ) + goto usage; +#endif /* _MSC_VER */ + if( opt.renego_period < 2 ) + goto usage; + } + else if( strcmp( p, "exchanges" ) == 0 ) + { + opt.exchanges = atoi( q ); + if( opt.exchanges < 0 ) + goto usage; + } + else if( strcmp( p, "min_version" ) == 0 ) + { + if( strcmp( q, "ssl3" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0; + else if( strcmp( q, "tls1" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1; + else if( strcmp( q, "tls1_1" ) == 0 || + strcmp( q, "dtls1" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + else if( strcmp( q, "tls1_2" ) == 0 || + strcmp( q, "dtls1_2" ) == 0 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_3; + else + goto usage; + } + else if( strcmp( p, "max_version" ) == 0 ) + { + if( strcmp( q, "ssl3" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0; + else if( strcmp( q, "tls1" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1; + else if( strcmp( q, "tls1_1" ) == 0 || + strcmp( q, "dtls1" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_2; + else if( strcmp( q, "tls1_2" ) == 0 || + strcmp( q, "dtls1_2" ) == 0 ) + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_3; + else + goto usage; + } + else if( strcmp( p, "arc4" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.arc4 = MBEDTLS_SSL_ARC4_DISABLED; break; + case 1: opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "force_version" ) == 0 ) + { + if( strcmp( q, "ssl3" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0; + } + else if( strcmp( q, "tls1" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1; + } + else if( strcmp( q, "tls1_1" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_2; + } + else if( strcmp( q, "tls1_2" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_3; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_3; + } + else if( strcmp( q, "dtls1" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_2; + opt.transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; + } + else if( strcmp( q, "dtls1_2" ) == 0 ) + { + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_3; + opt.max_version = MBEDTLS_SSL_MINOR_VERSION_3; + opt.transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; + } + else + goto usage; + } + else if( strcmp( p, "auth_mode" ) == 0 ) + { + if( ( opt.auth_mode = get_auth_mode( q ) ) < 0 ) + goto usage; + } + else if( strcmp( p, "max_frag_len" ) == 0 ) + { + if( strcmp( q, "512" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_512; + else if( strcmp( q, "1024" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_1024; + else if( strcmp( q, "2048" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_2048; + else if( strcmp( q, "4096" ) == 0 ) + opt.mfl_code = MBEDTLS_SSL_MAX_FRAG_LEN_4096; + else + goto usage; + } + else if( strcmp( p, "alpn" ) == 0 ) + { + opt.alpn_string = q; + } + else if( strcmp( p, "trunc_hmac" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_DISABLED; break; + case 1: opt.trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "extended_ms" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_DISABLED; break; + case 1: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "etm" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.etm = MBEDTLS_SSL_ETM_DISABLED; break; + case 1: opt.etm = MBEDTLS_SSL_ETM_ENABLED; break; + default: goto usage; + } + } + else if( strcmp( p, "tickets" ) == 0 ) + { + opt.tickets = atoi( q ); + if( opt.tickets < 0 || opt.tickets > 1 ) + goto usage; + } + else if( strcmp( p, "ticket_timeout" ) == 0 ) + { + opt.ticket_timeout = atoi( q ); + if( opt.ticket_timeout < 0 ) + goto usage; + } + else if( strcmp( p, "cache_max" ) == 0 ) + { + opt.cache_max = atoi( q ); + if( opt.cache_max < 0 ) + goto usage; + } + else if( strcmp( p, "cache_timeout" ) == 0 ) + { + opt.cache_timeout = atoi( q ); + if( opt.cache_timeout < 0 ) + goto usage; + } + else if( strcmp( p, "cookies" ) == 0 ) + { + opt.cookies = atoi( q ); + if( opt.cookies < -1 || opt.cookies > 1) + goto usage; + } + else if( strcmp( p, "anti_replay" ) == 0 ) + { + opt.anti_replay = atoi( q ); + if( opt.anti_replay < 0 || opt.anti_replay > 1) + goto usage; + } + else if( strcmp( p, "badmac_limit" ) == 0 ) + { + opt.badmac_limit = atoi( q ); + if( opt.badmac_limit < 0 ) + goto usage; + } + else if( strcmp( p, "hs_timeout" ) == 0 ) + { + if( ( p = strchr( q, '-' ) ) == NULL ) + goto usage; + *p++ = '\0'; + opt.hs_to_min = atoi( q ); + opt.hs_to_max = atoi( p ); + if( opt.hs_to_min == 0 || opt.hs_to_max < opt.hs_to_min ) + goto usage; + } + else if( strcmp( p, "sni" ) == 0 ) + { + opt.sni = q; + } + else + goto usage; + } + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( opt.debug_level ); +#endif + + if( opt.force_ciphersuite[0] > 0 ) + { + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( opt.force_ciphersuite[0] ); + + if( opt.max_version != -1 && + ciphersuite_info->min_minor_ver > opt.max_version ) + { + mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + ret = 2; + goto usage; + } + if( opt.min_version != -1 && + ciphersuite_info->max_minor_ver < opt.min_version ) + { + mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + ret = 2; + goto usage; + } + + /* If we select a version that's not supported by + * this suite, then there will be no common ciphersuite... */ + if( opt.max_version == -1 || + opt.max_version > ciphersuite_info->max_minor_ver ) + { + opt.max_version = ciphersuite_info->max_minor_ver; + } + if( opt.min_version < ciphersuite_info->min_minor_ver ) + { + opt.min_version = ciphersuite_info->min_minor_ver; + /* DTLS starts with TLS 1.1 */ + if( opt.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + opt.min_version < MBEDTLS_SSL_MINOR_VERSION_2 ) + opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2; + } + + /* Enable RC4 if needed and not explicitly disabled */ + if( ciphersuite_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) + { + if( opt.arc4 == MBEDTLS_SSL_ARC4_DISABLED ) + { + mbedtls_printf("forced RC4 ciphersuite with RC4 disabled\n"); + ret = 2; + goto usage; + } + + opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED; + } + } + + if( opt.version_suites != NULL ) + { + const char *name[4] = { 0 }; + + /* Parse 4-element coma-separated list */ + for( i = 0, p = (char *) opt.version_suites; + i < 4 && *p != '\0'; + i++ ) + { + name[i] = p; + + /* Terminate the current string and move on to next one */ + while( *p != ',' && *p != '\0' ) + p++; + if( *p == ',' ) + *p++ = '\0'; + } + + if( i != 4 ) + { + mbedtls_printf( "too few values for version_suites\n" ); + ret = 1; + goto exit; + } + + memset( version_suites, 0, sizeof( version_suites ) ); + + /* Get the suites identifiers from their name */ + for( i = 0; i < 4; i++ ) + { + version_suites[i][0] = mbedtls_ssl_get_ciphersuite_id( name[i] ); + + if( version_suites[i][0] == 0 ) + { + mbedtls_printf( "unknown ciphersuite: '%s'\n", name[i] ); + ret = 2; + goto usage; + } + } + } + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + /* + * Unhexify the pre-shared key and parse the list if any given + */ + if( unhexify( psk, opt.psk, &psk_len ) != 0 ) + { + mbedtls_printf( "pre-shared key not valid hex\n" ); + goto exit; + } + + if( opt.psk_list != NULL ) + { + if( ( psk_info = psk_parse( opt.psk_list ) ) == NULL ) + { + mbedtls_printf( "psk_list invalid" ); + goto exit; + } + } +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN) + if( opt.alpn_string != NULL ) + { + p = (char *) opt.alpn_string; + i = 0; + + /* Leave room for a final NULL in alpn_list */ + while( i < (int) sizeof alpn_list - 1 && *p != '\0' ) + { + alpn_list[i++] = p; + + /* Terminate the current string and move on to next one */ + while( *p != ',' && *p != '\0' ) + p++; + if( *p == ',' ) + *p++ = '\0'; + } + } +#endif /* MBEDTLS_SSL_ALPN */ + + /* + * 0. Initialize the RNG and the session data + */ + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * 1.1. Load the trusted CA + */ + mbedtls_printf( " . Loading the CA root certificate ..." ); + fflush( stdout ); + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.ca_path ) ) + if( strcmp( opt.ca_path, "none" ) == 0 ) + ret = 0; + else + ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); + else if( strlen( opt.ca_file ) ) + if( strcmp( opt.ca_file, "none" ) == 0 ) + ret = 0; + else + ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); + else +#endif +#if defined(MBEDTLS_CERTS_C) + for( i = 0; mbedtls_test_cas[i] != NULL; i++ ) + { + ret = mbedtls_x509_crt_parse( &cacert, + (const unsigned char *) mbedtls_test_cas[i], + mbedtls_test_cas_len[i] ); + if( ret != 0 ) + break; + } +#else + { + ret = 1; + mbedtls_printf("MBEDTLS_CERTS_C not defined."); + } +#endif + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok (%d skipped)\n", ret ); + + /* + * 1.2. Load own certificate and private key + */ + mbedtls_printf( " . Loading the server cert. and key..." ); + fflush( stdout ); + +#if defined(MBEDTLS_FS_IO) + if( strlen( opt.crt_file ) && strcmp( opt.crt_file, "none" ) != 0 ) + { + key_cert_init++; + if( ( ret = mbedtls_x509_crt_parse_file( &srvcert, opt.crt_file ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%x\n\n", + -ret ); + goto exit; + } + } + if( strlen( opt.key_file ) && strcmp( opt.key_file, "none" ) != 0 ) + { + key_cert_init++; + if( ( ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%x\n\n", -ret ); + goto exit; + } + } + if( key_cert_init == 1 ) + { + mbedtls_printf( " failed\n ! crt_file without key_file or vice-versa\n\n" ); + goto exit; + } + + if( strlen( opt.crt_file2 ) && strcmp( opt.crt_file2, "none" ) != 0 ) + { + key_cert_init2++; + if( ( ret = mbedtls_x509_crt_parse_file( &srvcert2, opt.crt_file2 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file(2) returned -0x%x\n\n", + -ret ); + goto exit; + } + } + if( strlen( opt.key_file2 ) && strcmp( opt.key_file2, "none" ) != 0 ) + { + key_cert_init2++; + if( ( ret = mbedtls_pk_parse_keyfile( &pkey2, opt.key_file2, "" ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile(2) returned -0x%x\n\n", + -ret ); + goto exit; + } + } + if( key_cert_init2 == 1 ) + { + mbedtls_printf( " failed\n ! crt_file2 without key_file2 or vice-versa\n\n" ); + goto exit; + } +#endif + if( key_cert_init == 0 && + strcmp( opt.crt_file, "none" ) != 0 && + strcmp( opt.key_file, "none" ) != 0 && + key_cert_init2 == 0 && + strcmp( opt.crt_file2, "none" ) != 0 && + strcmp( opt.key_file2, "none" ) != 0 ) + { +#if !defined(MBEDTLS_CERTS_C) + mbedtls_printf( "Not certificated or key provided, and \n" + "MBEDTLS_CERTS_C not defined!\n" ); + goto exit; +#else +#if defined(MBEDTLS_RSA_C) + if( ( ret = mbedtls_x509_crt_parse( &srvcert, + (const unsigned char *) mbedtls_test_srv_crt_rsa, + mbedtls_test_srv_crt_rsa_len ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + if( ( ret = mbedtls_pk_parse_key( &pkey, + (const unsigned char *) mbedtls_test_srv_key_rsa, + mbedtls_test_srv_key_rsa_len, NULL, 0 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", -ret ); + goto exit; + } + key_cert_init = 2; +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECDSA_C) + if( ( ret = mbedtls_x509_crt_parse( &srvcert2, + (const unsigned char *) mbedtls_test_srv_crt_ec, + mbedtls_test_srv_crt_ec_len ) ) != 0 ) + { + mbedtls_printf( " failed\n ! x509_crt_parse2 returned -0x%x\n\n", -ret ); + goto exit; + } + if( ( ret = mbedtls_pk_parse_key( &pkey2, + (const unsigned char *) mbedtls_test_srv_key_ec, + mbedtls_test_srv_key_ec_len, NULL, 0 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! pk_parse_key2 returned -0x%x\n\n", -ret ); + goto exit; + } + key_cert_init2 = 2; +#endif /* MBEDTLS_ECDSA_C */ +#endif /* MBEDTLS_CERTS_C */ + } + + mbedtls_printf( " ok\n" ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) + if( opt.dhm_file != NULL ) + { + mbedtls_printf( " . Loading DHM parameters..." ); + fflush( stdout ); + + if( ( ret = mbedtls_dhm_parse_dhmfile( &dhm, opt.dhm_file ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_dhm_parse_dhmfile returned -0x%04X\n\n", + -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + } +#endif + +#if defined(SNI_OPTION) + if( opt.sni != NULL ) + { + mbedtls_printf( " . Setting up SNI information..." ); + fflush( stdout ); + + if( ( sni_info = sni_parse( opt.sni ) ) == NULL ) + { + mbedtls_printf( " failed\n" ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + } +#endif /* SNI_OPTION */ + + /* + * 2. Setup the listening TCP socket + */ + mbedtls_printf( " . Bind on %s://%s:%s/ ...", + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? "tcp" : "udp", + opt.server_addr ? opt.server_addr : "*", + opt.server_port ); + fflush( stdout ); + + if( ( ret = mbedtls_net_bind( &listen_fd, opt.server_addr, opt.server_port, + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? + MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_bind returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 3. Setup stuff + */ + mbedtls_printf( " . Setting up the SSL/TLS structure..." ); + fflush( stdout ); + + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_SERVER, + opt.transport, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n", -ret ); + goto exit; + } + + if( opt.auth_mode != DFL_AUTH_MODE ) + mbedtls_ssl_conf_authmode( &conf, opt.auth_mode ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( opt.hs_to_min != DFL_HS_TO_MIN || opt.hs_to_max != DFL_HS_TO_MAX ) + mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min, opt.hs_to_max ); +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + if( ( ret = mbedtls_ssl_conf_max_frag_len( &conf, opt.mfl_code ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_max_frag_len returned %d\n\n", ret ); + goto exit; + }; +#endif + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + if( opt.trunc_hmac != DFL_TRUNC_HMAC ) + mbedtls_ssl_conf_truncated_hmac( &conf, opt.trunc_hmac ); +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + if( opt.extended_ms != DFL_EXTENDED_MS ) + mbedtls_ssl_conf_extended_master_secret( &conf, opt.extended_ms ); +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + if( opt.etm != DFL_ETM ) + mbedtls_ssl_conf_encrypt_then_mac( &conf, opt.etm ); +#endif + +#if defined(MBEDTLS_SSL_ALPN) + if( opt.alpn_string != NULL ) + if( ( ret = mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_alpn_protocols returned %d\n\n", ret ); + goto exit; + } +#endif + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + +#if defined(MBEDTLS_SSL_CACHE_C) + if( opt.cache_max != -1 ) + mbedtls_ssl_cache_set_max_entries( &cache, opt.cache_max ); + + if( opt.cache_timeout != -1 ) + mbedtls_ssl_cache_set_timeout( &cache, opt.cache_timeout ); + + mbedtls_ssl_conf_session_cache( &conf, &cache, + mbedtls_ssl_cache_get, + mbedtls_ssl_cache_set ); +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( opt.tickets == MBEDTLS_SSL_SESSION_TICKETS_ENABLED ) + { + if( ( ret = mbedtls_ssl_ticket_setup( &ticket_ctx, + mbedtls_ctr_drbg_random, &ctr_drbg, + MBEDTLS_CIPHER_AES_256_GCM, + opt.ticket_timeout ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_ticket_setup returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_conf_session_tickets_cb( &conf, + mbedtls_ssl_ticket_write, + mbedtls_ssl_ticket_parse, + &ticket_ctx ); + } +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( opt.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { +#if defined(MBEDTLS_SSL_COOKIE_C) + if( opt.cookies > 0 ) + { + if( ( ret = mbedtls_ssl_cookie_setup( &cookie_ctx, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_cookie_setup returned %d\n\n", ret ); + goto exit; + } + + mbedtls_ssl_conf_dtls_cookies( &conf, mbedtls_ssl_cookie_write, mbedtls_ssl_cookie_check, + &cookie_ctx ); + } + else +#endif /* MBEDTLS_SSL_COOKIE_C */ +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( opt.cookies == 0 ) + { + mbedtls_ssl_conf_dtls_cookies( &conf, NULL, NULL, NULL ); + } + else +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + { + ; /* Nothing to do */ + } + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( opt.anti_replay != DFL_ANTI_REPLAY ) + mbedtls_ssl_conf_dtls_anti_replay( &conf, opt.anti_replay ); +#endif + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) + if( opt.badmac_limit != DFL_BADMAC_LIMIT ) + mbedtls_ssl_conf_dtls_badmac_limit( &conf, opt.badmac_limit ); +#endif + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER ) + mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite ); + +#if defined(MBEDTLS_ARC4_C) + if( opt.arc4 != DFL_ARC4 ) + mbedtls_ssl_conf_arc4_support( &conf, opt.arc4 ); +#endif + + if( opt.version_suites != NULL ) + { + mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[0], + MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_0 ); + mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[1], + MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_1 ); + mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[2], + MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_2 ); + mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[3], + MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3 ); + } + + if( opt.allow_legacy != DFL_ALLOW_LEGACY ) + mbedtls_ssl_conf_legacy_renegotiation( &conf, opt.allow_legacy ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + mbedtls_ssl_conf_renegotiation( &conf, opt.renegotiation ); + + if( opt.renego_delay != DFL_RENEGO_DELAY ) + mbedtls_ssl_conf_renegotiation_enforced( &conf, opt.renego_delay ); + + if( opt.renego_period != DFL_RENEGO_PERIOD ) + { + PUT_UINT64_BE( renego_period, opt.renego_period, 0 ); + mbedtls_ssl_conf_renegotiation_period( &conf, renego_period ); + } +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( strcmp( opt.ca_path, "none" ) != 0 && + strcmp( opt.ca_file, "none" ) != 0 ) + { + mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); + } + if( key_cert_init ) + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } + if( key_cert_init2 ) + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert2, &pkey2 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + goto exit; + } +#endif + +#if defined(SNI_OPTION) + if( opt.sni != NULL ) + mbedtls_ssl_conf_sni( &conf, sni_callback, sni_info ); +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + if( strlen( opt.psk ) != 0 && strlen( opt.psk_identity ) != 0 ) + { + ret = mbedtls_ssl_conf_psk( &conf, psk, psk_len, + (const unsigned char *) opt.psk_identity, + strlen( opt.psk_identity ) ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n mbedtls_ssl_conf_psk returned -0x%04X\n\n", - ret ); + goto exit; + } + } + + if( opt.psk_list != NULL ) + mbedtls_ssl_conf_psk_cb( &conf, psk_callback, psk_info ); +#endif + +#if defined(MBEDTLS_DHM_C) + /* + * Use different group than default DHM group + */ +#if defined(MBEDTLS_FS_IO) + if( opt.dhm_file != NULL ) + ret = mbedtls_ssl_conf_dh_param_ctx( &conf, &dhm ); +#endif + if( ret != 0 ) + { + mbedtls_printf( " failed\n mbedtls_ssl_conf_dh_param returned -0x%04X\n\n", - ret ); + goto exit; + } +#endif + + if( opt.min_version != DFL_MIN_VERSION ) + mbedtls_ssl_conf_min_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, opt.min_version ); + + if( opt.max_version != DFL_MIN_VERSION ) + mbedtls_ssl_conf_max_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, opt.max_version ); + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", -ret ); + goto exit; + } + + if( opt.nbio == 2 ) + mbedtls_ssl_set_bio( &ssl, &client_fd, my_send, my_recv, NULL ); + else + mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, + opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL ); + +#if defined(MBEDTLS_TIMING_C) + mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, + mbedtls_timing_get_delay ); +#endif + + mbedtls_printf( " ok\n" ); + +reset: +#if !defined(_WIN32) + if( received_sigterm ) + { + mbedtls_printf( " interrupted by SIGTERM\n" ); + ret = 0; + goto exit; + } +#endif + + if( ret == MBEDTLS_ERR_SSL_CLIENT_RECONNECT ) + { + mbedtls_printf( " ! Client initiated reconnection from same port\n" ); + goto handshake; + } + +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf("Last error was: %d - %s\n\n", ret, error_buf ); + } +#endif + + mbedtls_net_free( &client_fd ); + + mbedtls_ssl_session_reset( &ssl ); + + /* + * 3. Wait until a client connects + */ + mbedtls_printf( " . Waiting for a remote connection ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd, + client_ip, sizeof( client_ip ), &cliip_len ) ) != 0 ) + { +#if !defined(_WIN32) + if( received_sigterm ) + { + mbedtls_printf( " interrupted by signal\n" ); + ret = 0; + goto exit; + } +#endif + + mbedtls_printf( " failed\n ! mbedtls_net_accept returned -0x%x\n\n", -ret ); + goto exit; + } + + if( opt.nbio > 0 ) + ret = mbedtls_net_set_nonblock( &client_fd ); + else + ret = mbedtls_net_set_block( &client_fd ); + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( opt.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + if( ( ret = mbedtls_ssl_set_client_transport_id( &ssl, + client_ip, cliip_len ) ) != 0 ) + { + mbedtls_printf( " failed\n ! " + "mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", -ret ); + goto exit; + } + } +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( opt.ecjpake_pw != DFL_ECJPAKE_PW ) + { + if( ( ret = mbedtls_ssl_set_hs_ecjpake_password( &ssl, + (const unsigned char *) opt.ecjpake_pw, + strlen( opt.ecjpake_pw ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hs_ecjpake_password returned %d\n\n", ret ); + goto exit; + } + } +#endif + + mbedtls_printf( " ok\n" ); + + /* + * 4. Handshake + */ +handshake: + mbedtls_printf( " . Performing the SSL/TLS handshake..." ); + fflush( stdout ); + + do ret = mbedtls_ssl_handshake( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ) + { + mbedtls_printf( " hello verification requested\n" ); + ret = 0; + goto reset; + } + else if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ) + { + char vrfy_buf[512]; + flags = mbedtls_ssl_get_verify_result( &ssl ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } +#endif + + goto reset; + } + else /* ret == 0 */ + { + mbedtls_printf( " ok\n [ Protocol is %s ]\n [ Ciphersuite is %s ]\n", + mbedtls_ssl_get_version( &ssl ), mbedtls_ssl_get_ciphersuite( &ssl ) ); + } + + if( ( ret = mbedtls_ssl_get_record_expansion( &ssl ) ) >= 0 ) + mbedtls_printf( " [ Record expansion is %d ]\n", ret ); + else + mbedtls_printf( " [ Record expansion is unknown (compression) ]\n" ); + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + mbedtls_printf( " [ Maximum fragment length is %u ]\n", + (unsigned int) mbedtls_ssl_get_max_frag_len( &ssl ) ); +#endif + +#if defined(MBEDTLS_SSL_ALPN) + if( opt.alpn_string != NULL ) + { + const char *alp = mbedtls_ssl_get_alpn_protocol( &ssl ); + mbedtls_printf( " [ Application Layer Protocol is %s ]\n", + alp ? alp : "(none)" ); + } +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * 5. Verify the server certificate + */ + mbedtls_printf( " . Verifying peer X.509 certificate..." ); + + if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 ) + { + char vrfy_buf[512]; + + mbedtls_printf( " failed\n" ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } + else + mbedtls_printf( " ok\n" ); + + if( mbedtls_ssl_get_peer_cert( &ssl ) != NULL ) + { + char crt_buf[512]; + + mbedtls_printf( " . Peer certificate information ...\n" ); + mbedtls_x509_crt_info( crt_buf, sizeof( crt_buf ), " ", + mbedtls_ssl_get_peer_cert( &ssl ) ); + mbedtls_printf( "%s\n", crt_buf ); + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + + if( opt.exchanges == 0 ) + goto close_notify; + + exchanges_left = opt.exchanges; +data_exchange: + /* + * 6. Read the HTTP Request + */ + mbedtls_printf( " < Read from client:" ); + fflush( stdout ); + + /* + * TLS and DTLS need different reading styles (stream vs datagram) + */ + if( opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ) + { + do + { + int terminated = 0; + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + ret = mbedtls_ssl_read( &ssl, buf, len ); + + if( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + continue; + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " connection was closed gracefully\n" ); + goto close_notify; + + case 0: + case MBEDTLS_ERR_NET_CONN_RESET: + mbedtls_printf( " connection was reset by peer\n" ); + ret = MBEDTLS_ERR_NET_CONN_RESET; + goto reset; + + default: + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret ); + goto reset; + } + } + + if( mbedtls_ssl_get_bytes_avail( &ssl ) == 0 ) + { + len = ret; + buf[len] = '\0'; + mbedtls_printf( " %d bytes read\n\n%s\n", len, (char *) buf ); + + /* End of message should be detected according to the syntax of the + * application protocol (eg HTTP), just use a dummy test here. */ + if( buf[len - 1] == '\n' ) + terminated = 1; + } + else + { + int extra_len, ori_len; + unsigned char *larger_buf; + + ori_len = ret; + extra_len = (int) mbedtls_ssl_get_bytes_avail( &ssl ); + + larger_buf = mbedtls_calloc( 1, ori_len + extra_len + 1 ); + if( larger_buf == NULL ) + { + mbedtls_printf( " ! memory allocation failed\n" ); + ret = 1; + goto reset; + } + + memset( larger_buf, 0, ori_len + extra_len ); + memcpy( larger_buf, buf, ori_len ); + + /* This read should never fail and get the whole cached data */ + ret = mbedtls_ssl_read( &ssl, larger_buf + ori_len, extra_len ); + if( ret != extra_len || + mbedtls_ssl_get_bytes_avail( &ssl ) != 0 ) + { + mbedtls_printf( " ! mbedtls_ssl_read failed on cached data\n" ); + ret = 1; + goto reset; + } + + larger_buf[ori_len + extra_len] = '\0'; + mbedtls_printf( " %u bytes read (%u + %u)\n\n%s\n", + ori_len + extra_len, ori_len, extra_len, + (char *) larger_buf ); + + /* End of message should be detected according to the syntax of the + * application protocol (eg HTTP), just use a dummy test here. */ + if( larger_buf[ori_len + extra_len - 1] == '\n' ) + terminated = 1; + + mbedtls_free( larger_buf ); + } + + if( terminated ) + { + ret = 0; + break; + } + } + while( 1 ); + } + else /* Not stream, so datagram */ + { + len = sizeof( buf ) - 1; + memset( buf, 0, sizeof( buf ) ); + + do ret = mbedtls_ssl_read( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret <= 0 ) + { + switch( ret ) + { + case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: + mbedtls_printf( " connection was closed gracefully\n" ); + ret = 0; + goto close_notify; + + default: + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret ); + goto reset; + } + } + + len = ret; + buf[len] = '\0'; + mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf ); + ret = 0; + } + + /* + * 7a. Request renegotiation while client is waiting for input from us. + * (only on the first exchange, to be able to test retransmission) + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( opt.renegotiate && exchanges_left == opt.exchanges ) + { + mbedtls_printf( " . Requestion renegotiation..." ); + fflush( stdout ); + + while( ( ret = mbedtls_ssl_renegotiate( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n", ret ); + goto reset; + } + } + + mbedtls_printf( " ok\n" ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + /* + * 7. Write the 200 Response + */ + mbedtls_printf( " > Write to client:" ); + fflush( stdout ); + + len = sprintf( (char *) buf, HTTP_RESPONSE, + mbedtls_ssl_get_ciphersuite( &ssl ) ); + + if( opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ) + { + for( written = 0, frags = 0; written < len; written += ret, frags++ ) + { + while( ( ret = mbedtls_ssl_write( &ssl, buf + written, len - written ) ) + <= 0 ) + { + if( ret == MBEDTLS_ERR_NET_CONN_RESET ) + { + mbedtls_printf( " failed\n ! peer closed the connection\n\n" ); + goto reset; + } + + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto reset; + } + } + } + } + else /* Not stream, so datagram */ + { + do ret = mbedtls_ssl_write( &ssl, buf, len ); + while( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + goto reset; + } + + frags = 1; + written = ret; + } + + buf[written] = '\0'; + mbedtls_printf( " %d bytes written in %d fragments\n\n%s\n", written, frags, (char *) buf ); + ret = 0; + + /* + * 7b. Continue doing data exchanges? + */ + if( --exchanges_left > 0 ) + goto data_exchange; + + /* + * 8. Done, cleanly close the connection + */ +close_notify: + mbedtls_printf( " . Closing the connection..." ); + + /* No error checking, the connection might be closed already */ + do ret = mbedtls_ssl_close_notify( &ssl ); + while( ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + ret = 0; + + mbedtls_printf( " done\n" ); + + goto reset; + + /* + * Cleanup and exit + */ +exit: +#ifdef MBEDTLS_ERROR_C + if( ret != 0 ) + { + char error_buf[100]; + mbedtls_strerror( ret, error_buf, 100 ); + mbedtls_printf("Last error was: -0x%X - %s\n\n", -ret, error_buf ); + } +#endif + + mbedtls_printf( " . Cleaning up..." ); + fflush( stdout ); + + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) + mbedtls_dhm_free( &dhm ); +#endif +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_x509_crt_free( &cacert ); + mbedtls_x509_crt_free( &srvcert ); + mbedtls_pk_free( &pkey ); + mbedtls_x509_crt_free( &srvcert2 ); + mbedtls_pk_free( &pkey2 ); +#endif +#if defined(SNI_OPTION) + sni_free( sni_info ); +#endif +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + psk_free( psk_info ); +#endif +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) + mbedtls_dhm_free( &dhm ); +#endif + + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_free( &cache ); +#endif +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + mbedtls_ssl_ticket_free( &ticket_ctx ); +#endif +#if defined(MBEDTLS_SSL_COOKIE_C) + mbedtls_ssl_cookie_free( &cookie_ctx ); +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_memory_buffer_alloc_status(); +#endif + mbedtls_memory_buffer_alloc_free(); +#endif + + mbedtls_printf( " done.\n" ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + // Shell can not handle large exit numbers -> 1 for errors + if( ret < 0 ) + ret = 1; + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && + MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && + MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/CMakeLists.txt new file mode 100644 index 0000000..f9b6604 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/CMakeLists.txt @@ -0,0 +1,13 @@ +set(libs + mbedtls +) + +add_executable(strerror strerror.c) +target_link_libraries(strerror ${libs}) + +add_executable(pem2der pem2der.c) +target_link_libraries(pem2der ${libs}) + +install(TARGETS strerror pem2der + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/pem2der.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/pem2der.c new file mode 100644 index 0000000..ad2c6ac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/pem2der.c @@ -0,0 +1,286 @@ +/* + * Convert PEM to DER + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_free free +#define mbedtls_calloc calloc +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_FS_IO) +#include "mbedtls/error.h" +#include "mbedtls/base64.h" + +#include +#include +#include +#endif + +#define DFL_FILENAME "file.pem" +#define DFL_OUTPUT_FILENAME "file.der" + +#define USAGE \ + "\n usage: pem2der param=<>...\n" \ + "\n acceptable parameters:\n" \ + " filename=%%s default: file.pem\n" \ + " output_file=%%s default: file.der\n" \ + "\n" + +#if !defined(MBEDTLS_BASE64_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else +/* + * global options + */ +struct options +{ + const char *filename; /* filename of the input file */ + const char *output_file; /* where to store the output */ +} opt; + +int convert_pem_to_der( const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen ) +{ + int ret; + const unsigned char *s1, *s2, *end = input + ilen; + size_t len = 0; + + s1 = (unsigned char *) strstr( (const char *) input, "-----BEGIN" ); + if( s1 == NULL ) + return( -1 ); + + s2 = (unsigned char *) strstr( (const char *) input, "-----END" ); + if( s2 == NULL ) + return( -1 ); + + s1 += 10; + while( s1 < end && *s1 != '-' ) + s1++; + while( s1 < end && *s1 == '-' ) + s1++; + if( *s1 == '\r' ) s1++; + if( *s1 == '\n' ) s1++; + + if( s2 <= s1 || s2 > end ) + return( -1 ); + + ret = mbedtls_base64_decode( NULL, 0, &len, (const unsigned char *) s1, s2 - s1 ); + if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER ) + return( ret ); + + if( len > *olen ) + return( -1 ); + + if( ( ret = mbedtls_base64_decode( output, len, &len, (const unsigned char *) s1, + s2 - s1 ) ) != 0 ) + { + return( ret ); + } + + *olen = len; + + return( 0 ); +} + +/* + * Load all data from a file into a given buffer. + */ +static int load_file( const char *path, unsigned char **buf, size_t *n ) +{ + FILE *f; + long size; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( -1 ); + + fseek( f, 0, SEEK_END ); + if( ( size = ftell( f ) ) == -1 ) + { + fclose( f ); + return( -1 ); + } + fseek( f, 0, SEEK_SET ); + + *n = (size_t) size; + + if( *n + 1 == 0 || + ( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL ) + { + fclose( f ); + return( -1 ); + } + + if( fread( *buf, 1, *n, f ) != *n ) + { + fclose( f ); + free( *buf ); + *buf = NULL; + return( -1 ); + } + + fclose( f ); + + (*buf)[*n] = '\0'; + + return( 0 ); +} + +/* + * Write buffer to a file + */ +static int write_file( const char *path, unsigned char *buf, size_t n ) +{ + FILE *f; + + if( ( f = fopen( path, "wb" ) ) == NULL ) + return( -1 ); + + if( fwrite( buf, 1, n, f ) != n ) + { + fclose( f ); + return( -1 ); + } + + fclose( f ); + return( 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0; + unsigned char *pem_buffer = NULL; + unsigned char der_buffer[4096]; + char buf[1024]; + size_t pem_size, der_size = sizeof(der_buffer); + int i; + char *p, *q; + + /* + * Set to sane values + */ + memset( buf, 0, sizeof(buf) ); + memset( der_buffer, 0, sizeof(der_buffer) ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + goto exit; + } + + opt.filename = DFL_FILENAME; + opt.output_file = DFL_OUTPUT_FILENAME; + + for( i = 1; i < argc; i++ ) + { + + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else if( strcmp( p, "output_file" ) == 0 ) + opt.output_file = q; + else + goto usage; + } + + /* + * 1.1. Load the PEM file + */ + mbedtls_printf( "\n . Loading the PEM file ..." ); + fflush( stdout ); + + ret = load_file( opt.filename, &pem_buffer, &pem_size ); + + if( ret != 0 ) + { +#ifdef MBEDTLS_ERROR_C + mbedtls_strerror( ret, buf, 1024 ); +#endif + mbedtls_printf( " failed\n ! load_file returned %d - %s\n\n", ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2. Convert from PEM to DER + */ + mbedtls_printf( " . Converting from PEM to DER ..." ); + fflush( stdout ); + + if( ( ret = convert_pem_to_der( pem_buffer, pem_size, der_buffer, &der_size ) ) != 0 ) + { +#ifdef MBEDTLS_ERROR_C + mbedtls_strerror( ret, buf, 1024 ); +#endif + mbedtls_printf( " failed\n ! convert_pem_to_der %d - %s\n\n", ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.3. Write the DER file + */ + mbedtls_printf( " . Writing the DER file ..." ); + fflush( stdout ); + + ret = write_file( opt.output_file, der_buffer, der_size ); + + if( ret != 0 ) + { +#ifdef MBEDTLS_ERROR_C + mbedtls_strerror( ret, buf, 1024 ); +#endif + mbedtls_printf( " failed\n ! write_file returned %d - %s\n\n", ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +exit: + free( pem_buffer ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/strerror.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/strerror.c new file mode 100644 index 0000000..458280c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/util/strerror.c @@ -0,0 +1,92 @@ +/* + * Translate error code to error string + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) +#include "mbedtls/error.h" + +#include +#include +#include +#endif + +#define USAGE \ + "\n usage: strerror \n" \ + "\n where can be a decimal or hexadecimal (starts with 0x or -0x)\n" + +#if !defined(MBEDTLS_ERROR_C) && !defined(MBEDTLS_ERROR_STRERROR_DUMMY) +int main( void ) +{ + mbedtls_printf("MBEDTLS_ERROR_C and/or MBEDTLS_ERROR_STRERROR_DUMMY not defined.\n"); + return( 0 ); +} +#else +int main( int argc, char *argv[] ) +{ + long int val; + char *end = argv[1]; + + if( argc != 2 ) + { + mbedtls_printf( USAGE ); + return( 0 ); + } + + val = strtol( argv[1], &end, 10 ); + if( *end != '\0' ) + { + val = strtol( argv[1], &end, 16 ); + if( *end != '\0' ) + { + mbedtls_printf( USAGE ); + return( 0 ); + } + } + if( val > 0 ) + val = -val; + + if( val != 0 ) + { + char error_buf[200]; + mbedtls_strerror( val, error_buf, 200 ); + mbedtls_printf("Last error was: -0x%04x - %s\n\n", (int) -val, error_buf ); + } + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( val ); +} +#endif /* MBEDTLS_ERROR_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/wince_main.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/wince_main.c new file mode 100644 index 0000000..203a2ba --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/wince_main.c @@ -0,0 +1,45 @@ +/* + * Windows CE console application entry point + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if defined(_WIN32_WCE) + +#include + +extern int main( int, const char ** ); + +int _tmain( int argc, _TCHAR* targv[] ) +{ + char **argv; + int i; + + argv = ( char ** ) calloc( argc, sizeof( char * ) ); + + for ( i = 0; i < argc; i++ ) { + size_t len; + len = _tcslen( targv[i] ) + 1; + argv[i] = ( char * ) calloc( len, sizeof( char ) ); + wcstombs( argv[i], targv[i], len ); + } + + return main( argc, argv ); +} + +#endif /* defined(_WIN32_WCE) */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/CMakeLists.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/CMakeLists.txt new file mode 100644 index 0000000..39b8b5b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/CMakeLists.txt @@ -0,0 +1,30 @@ +set(libs + mbedtls +) + +if(USE_PKCS11_HELPER_LIBRARY) + set(libs ${libs} pkcs11-helper) +endif(USE_PKCS11_HELPER_LIBRARY) + +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + +add_executable(cert_app cert_app.c) +target_link_libraries(cert_app ${libs}) + +add_executable(crl_app crl_app.c) +target_link_libraries(crl_app ${libs}) + +add_executable(req_app req_app.c) +target_link_libraries(req_app ${libs}) + +add_executable(cert_req cert_req.c) +target_link_libraries(cert_req ${libs}) + +add_executable(cert_write cert_write.c) +target_link_libraries(cert_write ${libs}) + +install(TARGETS cert_app crl_app req_app cert_req cert_write + DESTINATION "bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_app.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_app.c new file mode 100644 index 0000000..c893ca8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_app.c @@ -0,0 +1,495 @@ +/* + * Certificate reading application + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ + !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_CTR_DRBG_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " + "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or " + "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_CTR_DRBG_C not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/ssl.h" +#include "mbedtls/x509.h" +#include "mbedtls/debug.h" + +#include +#include +#include + +#define MODE_NONE 0 +#define MODE_FILE 1 +#define MODE_SSL 2 + +#define DFL_MODE MODE_NONE +#define DFL_FILENAME "cert.crt" +#define DFL_CA_FILE "" +#define DFL_CRL_FILE "" +#define DFL_CA_PATH "" +#define DFL_SERVER_NAME "localhost" +#define DFL_SERVER_PORT "4433" +#define DFL_DEBUG_LEVEL 0 +#define DFL_PERMISSIVE 0 + +#define USAGE_IO \ + " ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \ + " default: \"\" (none)\n" \ + " crl_file=%%s The single CRL file you want to use\n" \ + " default: \"\" (none)\n" \ + " ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \ + " default: \"\" (none) (overrides ca_file)\n" + +#define USAGE \ + "\n usage: cert_app param=<>...\n" \ + "\n acceptable parameters:\n" \ + " mode=file|ssl default: none\n" \ + " filename=%%s default: cert.crt\n" \ + USAGE_IO \ + " server_name=%%s default: localhost\n" \ + " server_port=%%d default: 4433\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ + " permissive=%%d default: 0 (disabled)\n" \ + "\n" + +/* + * global options + */ +struct options +{ + int mode; /* the mode to run the application in */ + const char *filename; /* filename of the certificate file */ + const char *ca_file; /* the file with the CA certificate(s) */ + const char *crl_file; /* the file with the CRL to use */ + const char *ca_path; /* the path with the CA certificate(s) reside */ + const char *server_name; /* hostname of the server (client only) */ + const char *server_port; /* port on which the ssl service runs */ + int debug_level; /* level of debugging */ + int permissive; /* permissive parsing */ +} opt; + +static void my_debug( void *ctx, int level, + const char *file, int line, + const char *str ) +{ + ((void) level); + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + fflush( (FILE *) ctx ); +} + +static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags ) +{ + char buf[1024]; + ((void) data); + + mbedtls_printf( "\nVerify requested for (Depth %d):\n", depth ); + mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt ); + mbedtls_printf( "%s", buf ); + + if ( ( *flags ) == 0 ) + mbedtls_printf( " This certificate has no flags\n" ); + else + { + mbedtls_x509_crt_verify_info( buf, sizeof( buf ), " ! ", *flags ); + mbedtls_printf( "%s\n", buf ); + } + + return( 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0; + mbedtls_net_context server_fd; + unsigned char buf[1024]; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt cacert; + mbedtls_x509_crl cacrl; + int i, j; + uint32_t flags; + int verify = 0; + char *p, *q; + const char *pers = "cert_app"; + + /* + * Set to sane values + */ + mbedtls_net_init( &server_fd ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_config_init( &conf ); + mbedtls_x509_crt_init( &cacert ); +#if defined(MBEDTLS_X509_CRL_PARSE_C) + mbedtls_x509_crl_init( &cacrl ); +#else + /* Zeroize structure as CRL parsing is not supported and we have to pass + it to the verify function */ + memset( &cacrl, 0, sizeof(mbedtls_x509_crl) ); +#endif + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + ret = 2; + goto exit; + } + + opt.mode = DFL_MODE; + opt.filename = DFL_FILENAME; + opt.ca_file = DFL_CA_FILE; + opt.crl_file = DFL_CRL_FILE; + opt.ca_path = DFL_CA_PATH; + opt.server_name = DFL_SERVER_NAME; + opt.server_port = DFL_SERVER_PORT; + opt.debug_level = DFL_DEBUG_LEVEL; + opt.permissive = DFL_PERMISSIVE; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + for( j = 0; p + j < q; j++ ) + { + if( argv[i][j] >= 'A' && argv[i][j] <= 'Z' ) + argv[i][j] |= 0x20; + } + + if( strcmp( p, "mode" ) == 0 ) + { + if( strcmp( q, "file" ) == 0 ) + opt.mode = MODE_FILE; + else if( strcmp( q, "ssl" ) == 0 ) + opt.mode = MODE_SSL; + else + goto usage; + } + else if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else if( strcmp( p, "ca_file" ) == 0 ) + opt.ca_file = q; + else if( strcmp( p, "crl_file" ) == 0 ) + opt.crl_file = q; + else if( strcmp( p, "ca_path" ) == 0 ) + opt.ca_path = q; + else if( strcmp( p, "server_name" ) == 0 ) + opt.server_name = q; + else if( strcmp( p, "server_port" ) == 0 ) + opt.server_port = q; + else if( strcmp( p, "debug_level" ) == 0 ) + { + opt.debug_level = atoi( q ); + if( opt.debug_level < 0 || opt.debug_level > 65535 ) + goto usage; + } + else if( strcmp( p, "permissive" ) == 0 ) + { + opt.permissive = atoi( q ); + if( opt.permissive < 0 || opt.permissive > 1 ) + goto usage; + } + else + goto usage; + } + + /* + * 1.1. Load the trusted CA + */ + mbedtls_printf( " . Loading the CA root certificate ..." ); + fflush( stdout ); + + if( strlen( opt.ca_path ) ) + { + ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); + verify = 1; + } + else if( strlen( opt.ca_file ) ) + { + ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); + verify = 1; + } + + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + goto exit; + } + + mbedtls_printf( " ok (%d skipped)\n", ret ); + +#if defined(MBEDTLS_X509_CRL_PARSE_C) + if( strlen( opt.crl_file ) ) + { + if( ( ret = mbedtls_x509_crl_parse_file( &cacrl, opt.crl_file ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crl_parse returned -0x%x\n\n", -ret ); + goto exit; + } + + verify = 1; + } +#endif + + if( opt.mode == MODE_FILE ) + { + mbedtls_x509_crt crt; + mbedtls_x509_crt *cur = &crt; + mbedtls_x509_crt_init( &crt ); + + /* + * 1.1. Load the certificate(s) + */ + mbedtls_printf( "\n . Loading the certificate(s) ..." ); + fflush( stdout ); + + ret = mbedtls_x509_crt_parse_file( &crt, opt.filename ); + + if( ret < 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned %d\n\n", ret ); + mbedtls_x509_crt_free( &crt ); + goto exit; + } + + if( opt.permissive == 0 && ret > 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse failed to parse %d certificates\n\n", ret ); + mbedtls_x509_crt_free( &crt ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2 Print the certificate(s) + */ + while( cur != NULL ) + { + mbedtls_printf( " . Peer certificate information ...\n" ); + ret = mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", + cur ); + if( ret == -1 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_info returned %d\n\n", ret ); + mbedtls_x509_crt_free( &crt ); + goto exit; + } + + mbedtls_printf( "%s\n", buf ); + + cur = cur->next; + } + + ret = 0; + + /* + * 1.3 Verify the certificate + */ + if( verify ) + { + mbedtls_printf( " . Verifying X.509 certificate..." ); + + if( ( ret = mbedtls_x509_crt_verify( &crt, &cacert, &cacrl, NULL, &flags, + my_verify, NULL ) ) != 0 ) + { + char vrfy_buf[512]; + + mbedtls_printf( " failed\n" ); + + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + + mbedtls_printf( "%s\n", vrfy_buf ); + } + else + mbedtls_printf( " ok\n" ); + } + + mbedtls_x509_crt_free( &crt ); + } + else if( opt.mode == MODE_SSL ) + { + /* + * 1. Initialize the RNG and the session data + */ + mbedtls_printf( "\n . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); + goto ssl_exit; + } + + mbedtls_printf( " ok\n" ); + +#if defined(MBEDTLS_DEBUG_C) + mbedtls_debug_set_threshold( opt.debug_level ); +#endif + + /* + * 2. Start the connection + */ + mbedtls_printf( " . SSL connection to tcp/%s/%s...", opt.server_name, + opt.server_port ); + fflush( stdout ); + + if( ( ret = mbedtls_net_connect( &server_fd, opt.server_name, + opt.server_port, MBEDTLS_NET_PROTO_TCP ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret ); + goto ssl_exit; + } + + /* + * 3. Setup stuff + */ + if( ( ret = mbedtls_ssl_config_defaults( &conf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); + goto exit; + } + + if( verify ) + { + mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_REQUIRED ); + mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); + mbedtls_ssl_conf_verify( &conf, my_verify, NULL ); + } + else + mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_NONE ); + + mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); + mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); + + if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); + goto ssl_exit; + } + + if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); + goto ssl_exit; + } + + mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); + + /* + * 4. Handshake + */ + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { + if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned %d\n\n", ret ); + goto ssl_exit; + } + } + + mbedtls_printf( " ok\n" ); + + /* + * 5. Print the certificate + */ + mbedtls_printf( " . Peer certificate information ...\n" ); + ret = mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", + ssl.session->peer_cert ); + if( ret == -1 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crt_info returned %d\n\n", ret ); + goto ssl_exit; + } + + mbedtls_printf( "%s\n", buf ); + + mbedtls_ssl_close_notify( &ssl ); + +ssl_exit: + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + } + else + goto usage; + +exit: + + mbedtls_net_free( &server_fd ); + mbedtls_x509_crt_free( &cacert ); +#if defined(MBEDTLS_X509_CRL_PARSE_C) + mbedtls_x509_crl_free( &cacrl ); +#endif + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + if( ret < 0 ) + ret = 1; + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && + MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && + MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_req.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_req.c new file mode 100644 index 0000000..30df216 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_req.c @@ -0,0 +1,345 @@ +/* + * Certificate request generation + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_X509_CSR_WRITE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_PEM_WRITE_C) +int main( void ) +{ + mbedtls_printf( "MBEDTLS_X509_CSR_WRITE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_PK_PARSE_C and/or MBEDTLS_SHA256_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C " + "not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/x509_csr.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/error.h" + +#include +#include +#include + +#define DFL_FILENAME "keyfile.key" +#define DFL_DEBUG_LEVEL 0 +#define DFL_OUTPUT_FILENAME "cert.req" +#define DFL_SUBJECT_NAME "CN=Cert,O=mbed TLS,C=UK" +#define DFL_KEY_USAGE 0 +#define DFL_NS_CERT_TYPE 0 + +#define USAGE \ + "\n usage: cert_req param=<>...\n" \ + "\n acceptable parameters:\n" \ + " filename=%%s default: keyfile.key\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ + " output_file=%%s default: cert.req\n" \ + " subject_name=%%s default: CN=Cert,O=mbed TLS,C=UK\n" \ + " key_usage=%%s default: (empty)\n" \ + " Comma-separated-list of values:\n" \ + " digital_signature\n" \ + " non_repudiation\n" \ + " key_encipherment\n" \ + " data_encipherment\n" \ + " key_agreement\n" \ + " key_cert_sign\n" \ + " crl_sign\n" \ + " ns_cert_type=%%s default: (empty)\n" \ + " Comma-separated-list of values:\n" \ + " ssl_client\n" \ + " ssl_server\n" \ + " email\n" \ + " object_signing\n" \ + " ssl_ca\n" \ + " email_ca\n" \ + " object_signing_ca\n" \ + "\n" + +/* + * global options + */ +struct options +{ + const char *filename; /* filename of the key file */ + int debug_level; /* level of debugging */ + const char *output_file; /* where to store the constructed key file */ + const char *subject_name; /* subject name for certificate request */ + unsigned char key_usage; /* key usage flags */ + unsigned char ns_cert_type; /* NS cert type */ +} opt; + +int write_certificate_request( mbedtls_x509write_csr *req, const char *output_file, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + FILE *f; + unsigned char output_buf[4096]; + size_t len = 0; + + memset( output_buf, 0, 4096 ); + if( ( ret = mbedtls_x509write_csr_pem( req, output_buf, 4096, f_rng, p_rng ) ) < 0 ) + return( ret ); + + len = strlen( (char *) output_buf ); + + if( ( f = fopen( output_file, "w" ) ) == NULL ) + return( -1 ); + + if( fwrite( output_buf, 1, len, f ) != len ) + { + fclose( f ); + return( -1 ); + } + + fclose( f ); + + return( 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0; + mbedtls_pk_context key; + char buf[1024]; + int i; + char *p, *q, *r; + mbedtls_x509write_csr req; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + const char *pers = "csr example app"; + + /* + * Set to sane values + */ + mbedtls_x509write_csr_init( &req ); + mbedtls_x509write_csr_set_md_alg( &req, MBEDTLS_MD_SHA256 ); + mbedtls_pk_init( &key ); + mbedtls_ctr_drbg_init( &ctr_drbg ); + memset( buf, 0, sizeof( buf ) ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + ret = 1; + goto exit; + } + + opt.filename = DFL_FILENAME; + opt.debug_level = DFL_DEBUG_LEVEL; + opt.output_file = DFL_OUTPUT_FILENAME; + opt.subject_name = DFL_SUBJECT_NAME; + opt.key_usage = DFL_KEY_USAGE; + opt.ns_cert_type = DFL_NS_CERT_TYPE; + + for( i = 1; i < argc; i++ ) + { + + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else if( strcmp( p, "output_file" ) == 0 ) + opt.output_file = q; + else if( strcmp( p, "debug_level" ) == 0 ) + { + opt.debug_level = atoi( q ); + if( opt.debug_level < 0 || opt.debug_level > 65535 ) + goto usage; + } + else if( strcmp( p, "subject_name" ) == 0 ) + { + opt.subject_name = q; + } + else if( strcmp( p, "key_usage" ) == 0 ) + { + while( q != NULL ) + { + if( ( r = strchr( q, ',' ) ) != NULL ) + *r++ = '\0'; + + if( strcmp( q, "digital_signature" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_DIGITAL_SIGNATURE; + else if( strcmp( q, "non_repudiation" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_NON_REPUDIATION; + else if( strcmp( q, "key_encipherment" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_KEY_ENCIPHERMENT; + else if( strcmp( q, "data_encipherment" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_DATA_ENCIPHERMENT; + else if( strcmp( q, "key_agreement" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_KEY_AGREEMENT; + else if( strcmp( q, "key_cert_sign" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_KEY_CERT_SIGN; + else if( strcmp( q, "crl_sign" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_CRL_SIGN; + else + goto usage; + + q = r; + } + } + else if( strcmp( p, "ns_cert_type" ) == 0 ) + { + while( q != NULL ) + { + if( ( r = strchr( q, ',' ) ) != NULL ) + *r++ = '\0'; + + if( strcmp( q, "ssl_client" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT; + else if( strcmp( q, "ssl_server" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER; + else if( strcmp( q, "email" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_EMAIL; + else if( strcmp( q, "object_signing" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING; + else if( strcmp( q, "ssl_ca" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_SSL_CA; + else if( strcmp( q, "email_ca" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA; + else if( strcmp( q, "object_signing_ca" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA; + else + goto usage; + + q = r; + } + } + else + goto usage; + } + + if( opt.key_usage ) + mbedtls_x509write_csr_set_key_usage( &req, opt.key_usage ); + + if( opt.ns_cert_type ) + mbedtls_x509write_csr_set_ns_cert_type( &req, opt.ns_cert_type ); + + /* + * 0. Seed the PRNG + */ + mbedtls_printf( " . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.0. Check the subject name for validity + */ + mbedtls_printf( " . Checking subject name..." ); + fflush( stdout ); + + if( ( ret = mbedtls_x509write_csr_set_subject_name( &req, opt.subject_name ) ) != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509write_csr_set_subject_name returned %d", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.1. Load the key + */ + mbedtls_printf( " . Loading the private key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_keyfile( &key, opt.filename, NULL ); + + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned %d", ret ); + goto exit; + } + + mbedtls_x509write_csr_set_key( &req, &key ); + + mbedtls_printf( " ok\n" ); + + /* + * 1.2. Writing the request + */ + mbedtls_printf( " . Writing the certificate request ..." ); + fflush( stdout ); + + if( ( ret = write_certificate_request( &req, opt.output_file, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_printf( " failed\n ! write_certifcate_request %d", ret ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +exit: + + if( ret != 0 && ret != 1) + { +#ifdef MBEDTLS_ERROR_C + mbedtls_strerror( ret, buf, sizeof( buf ) ); + mbedtls_printf( " - %s\n", buf ); +#else + mbedtls_printf("\n"); +#endif + } + + mbedtls_x509write_csr_free( &req ); + mbedtls_pk_free( &key ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_X509_CSR_WRITE_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && + MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_write.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_write.c new file mode 100644 index 0000000..66e5f1d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/cert_write.c @@ -0,0 +1,668 @@ +/* + * Certificate generation and signing + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_X509_CRT_WRITE_C) || \ + !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \ + !defined(MBEDTLS_ERROR_C) || !defined(MBEDTLS_SHA256_C) || \ + !defined(MBEDTLS_PEM_WRITE_C) +int main( void ) +{ + mbedtls_printf( "MBEDTLS_X509_CRT_WRITE_C and/or MBEDTLS_X509_CRT_PARSE_C and/or " + "MBEDTLS_FS_IO and/or MBEDTLS_SHA256_C and/or " + "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " + "MBEDTLS_ERROR_C not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/x509_crt.h" +#include "mbedtls/x509_csr.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/error.h" + +#include +#include +#include + +#if defined(MBEDTLS_X509_CSR_PARSE_C) +#define USAGE_CSR \ + " request_file=%%s default: (empty)\n" \ + " If request_file is specified, subject_key,\n" \ + " subject_pwd and subject_name are ignored!\n" +#else +#define USAGE_CSR "" +#endif /* MBEDTLS_X509_CSR_PARSE_C */ + +#define DFL_ISSUER_CRT "" +#define DFL_REQUEST_FILE "" +#define DFL_SUBJECT_KEY "subject.key" +#define DFL_ISSUER_KEY "ca.key" +#define DFL_SUBJECT_PWD "" +#define DFL_ISSUER_PWD "" +#define DFL_OUTPUT_FILENAME "cert.crt" +#define DFL_SUBJECT_NAME "CN=Cert,O=mbed TLS,C=UK" +#define DFL_ISSUER_NAME "CN=CA,O=mbed TLS,C=UK" +#define DFL_NOT_BEFORE "20010101000000" +#define DFL_NOT_AFTER "20301231235959" +#define DFL_SERIAL "1" +#define DFL_SELFSIGN 0 +#define DFL_IS_CA 0 +#define DFL_MAX_PATHLEN -1 +#define DFL_KEY_USAGE 0 +#define DFL_NS_CERT_TYPE 0 + +#define USAGE \ + "\n usage: cert_write param=<>...\n" \ + "\n acceptable parameters:\n" \ + USAGE_CSR \ + " subject_key=%%s default: subject.key\n" \ + " subject_pwd=%%s default: (empty)\n" \ + " subject_name=%%s default: CN=Cert,O=mbed TLS,C=UK\n" \ + "\n" \ + " issuer_crt=%%s default: (empty)\n" \ + " If issuer_crt is specified, issuer_name is\n" \ + " ignored!\n" \ + " issuer_name=%%s default: CN=CA,O=mbed TLS,C=UK\n" \ + "\n" \ + " selfsign=%%d default: 0 (false)\n" \ + " If selfsign is enabled, issuer_name and\n" \ + " issuer_key are required (issuer_crt and\n" \ + " subject_* are ignored\n" \ + " issuer_key=%%s default: ca.key\n" \ + " issuer_pwd=%%s default: (empty)\n" \ + " output_file=%%s default: cert.crt\n" \ + " serial=%%s default: 1\n" \ + " not_before=%%s default: 20010101000000\n"\ + " not_after=%%s default: 20301231235959\n"\ + " is_ca=%%d default: 0 (disabled)\n" \ + " max_pathlen=%%d default: -1 (none)\n" \ + " key_usage=%%s default: (empty)\n" \ + " Comma-separated-list of values:\n" \ + " digital_signature\n" \ + " non_repudiation\n" \ + " key_encipherment\n" \ + " data_encipherment\n" \ + " key_agreement\n" \ + " key_cert_sign\n" \ + " crl_sign\n" \ + " ns_cert_type=%%s default: (empty)\n" \ + " Comma-separated-list of values:\n" \ + " ssl_client\n" \ + " ssl_server\n" \ + " email\n" \ + " object_signing\n" \ + " ssl_ca\n" \ + " email_ca\n" \ + " object_signing_ca\n" \ + "\n" + +/* + * global options + */ +struct options +{ + const char *issuer_crt; /* filename of the issuer certificate */ + const char *request_file; /* filename of the certificate request */ + const char *subject_key; /* filename of the subject key file */ + const char *issuer_key; /* filename of the issuer key file */ + const char *subject_pwd; /* password for the subject key file */ + const char *issuer_pwd; /* password for the issuer key file */ + const char *output_file; /* where to store the constructed key file */ + const char *subject_name; /* subject name for certificate */ + const char *issuer_name; /* issuer name for certificate */ + const char *not_before; /* validity period not before */ + const char *not_after; /* validity period not after */ + const char *serial; /* serial number string */ + int selfsign; /* selfsign the certificate */ + int is_ca; /* is a CA certificate */ + int max_pathlen; /* maximum CA path length */ + unsigned char key_usage; /* key usage flags */ + unsigned char ns_cert_type; /* NS cert type */ +} opt; + +int write_certificate( mbedtls_x509write_cert *crt, const char *output_file, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + FILE *f; + unsigned char output_buf[4096]; + size_t len = 0; + + memset( output_buf, 0, 4096 ); + if( ( ret = mbedtls_x509write_crt_pem( crt, output_buf, 4096, f_rng, p_rng ) ) < 0 ) + return( ret ); + + len = strlen( (char *) output_buf ); + + if( ( f = fopen( output_file, "w" ) ) == NULL ) + return( -1 ); + + if( fwrite( output_buf, 1, len, f ) != len ) + { + fclose( f ); + return( -1 ); + } + + fclose( f ); + + return( 0 ); +} + +int main( int argc, char *argv[] ) +{ + int ret = 0; + mbedtls_x509_crt issuer_crt; + mbedtls_pk_context loaded_issuer_key, loaded_subject_key; + mbedtls_pk_context *issuer_key = &loaded_issuer_key, + *subject_key = &loaded_subject_key; + char buf[1024]; + char issuer_name[256]; + int i; + char *p, *q, *r; +#if defined(MBEDTLS_X509_CSR_PARSE_C) + char subject_name[256]; + mbedtls_x509_csr csr; +#endif + mbedtls_x509write_cert crt; + mbedtls_mpi serial; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + const char *pers = "crt example app"; + + /* + * Set to sane values + */ + mbedtls_x509write_crt_init( &crt ); + mbedtls_x509write_crt_set_md_alg( &crt, MBEDTLS_MD_SHA256 ); + mbedtls_pk_init( &loaded_issuer_key ); + mbedtls_pk_init( &loaded_subject_key ); + mbedtls_mpi_init( &serial ); + mbedtls_ctr_drbg_init( &ctr_drbg ); +#if defined(MBEDTLS_X509_CSR_PARSE_C) + mbedtls_x509_csr_init( &csr ); +#endif + mbedtls_x509_crt_init( &issuer_crt ); + memset( buf, 0, 1024 ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + ret = 1; + goto exit; + } + + opt.issuer_crt = DFL_ISSUER_CRT; + opt.request_file = DFL_REQUEST_FILE; + opt.subject_key = DFL_SUBJECT_KEY; + opt.issuer_key = DFL_ISSUER_KEY; + opt.subject_pwd = DFL_SUBJECT_PWD; + opt.issuer_pwd = DFL_ISSUER_PWD; + opt.output_file = DFL_OUTPUT_FILENAME; + opt.subject_name = DFL_SUBJECT_NAME; + opt.issuer_name = DFL_ISSUER_NAME; + opt.not_before = DFL_NOT_BEFORE; + opt.not_after = DFL_NOT_AFTER; + opt.serial = DFL_SERIAL; + opt.selfsign = DFL_SELFSIGN; + opt.is_ca = DFL_IS_CA; + opt.max_pathlen = DFL_MAX_PATHLEN; + opt.key_usage = DFL_KEY_USAGE; + opt.ns_cert_type = DFL_NS_CERT_TYPE; + + for( i = 1; i < argc; i++ ) + { + + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "request_file" ) == 0 ) + opt.request_file = q; + else if( strcmp( p, "subject_key" ) == 0 ) + opt.subject_key = q; + else if( strcmp( p, "issuer_key" ) == 0 ) + opt.issuer_key = q; + else if( strcmp( p, "subject_pwd" ) == 0 ) + opt.subject_pwd = q; + else if( strcmp( p, "issuer_pwd" ) == 0 ) + opt.issuer_pwd = q; + else if( strcmp( p, "issuer_crt" ) == 0 ) + opt.issuer_crt = q; + else if( strcmp( p, "output_file" ) == 0 ) + opt.output_file = q; + else if( strcmp( p, "subject_name" ) == 0 ) + { + opt.subject_name = q; + } + else if( strcmp( p, "issuer_name" ) == 0 ) + { + opt.issuer_name = q; + } + else if( strcmp( p, "not_before" ) == 0 ) + { + opt.not_before = q; + } + else if( strcmp( p, "not_after" ) == 0 ) + { + opt.not_after = q; + } + else if( strcmp( p, "serial" ) == 0 ) + { + opt.serial = q; + } + else if( strcmp( p, "selfsign" ) == 0 ) + { + opt.selfsign = atoi( q ); + if( opt.selfsign < 0 || opt.selfsign > 1 ) + goto usage; + } + else if( strcmp( p, "is_ca" ) == 0 ) + { + opt.is_ca = atoi( q ); + if( opt.is_ca < 0 || opt.is_ca > 1 ) + goto usage; + } + else if( strcmp( p, "max_pathlen" ) == 0 ) + { + opt.max_pathlen = atoi( q ); + if( opt.max_pathlen < -1 || opt.max_pathlen > 127 ) + goto usage; + } + else if( strcmp( p, "key_usage" ) == 0 ) + { + while( q != NULL ) + { + if( ( r = strchr( q, ',' ) ) != NULL ) + *r++ = '\0'; + + if( strcmp( q, "digital_signature" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_DIGITAL_SIGNATURE; + else if( strcmp( q, "non_repudiation" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_NON_REPUDIATION; + else if( strcmp( q, "key_encipherment" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_KEY_ENCIPHERMENT; + else if( strcmp( q, "data_encipherment" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_DATA_ENCIPHERMENT; + else if( strcmp( q, "key_agreement" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_KEY_AGREEMENT; + else if( strcmp( q, "key_cert_sign" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_KEY_CERT_SIGN; + else if( strcmp( q, "crl_sign" ) == 0 ) + opt.key_usage |= MBEDTLS_X509_KU_CRL_SIGN; + else + goto usage; + + q = r; + } + } + else if( strcmp( p, "ns_cert_type" ) == 0 ) + { + while( q != NULL ) + { + if( ( r = strchr( q, ',' ) ) != NULL ) + *r++ = '\0'; + + if( strcmp( q, "ssl_client" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT; + else if( strcmp( q, "ssl_server" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER; + else if( strcmp( q, "email" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_EMAIL; + else if( strcmp( q, "object_signing" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING; + else if( strcmp( q, "ssl_ca" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_SSL_CA; + else if( strcmp( q, "email_ca" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA; + else if( strcmp( q, "object_signing_ca" ) == 0 ) + opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA; + else + goto usage; + + q = r; + } + } + else + goto usage; + } + + mbedtls_printf("\n"); + + /* + * 0. Seed the PRNG + */ + mbedtls_printf( " . Seeding the random number generator..." ); + fflush( stdout ); + + mbedtls_entropy_init( &entropy ); + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, + (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d - %s\n", ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + // Parse serial to MPI + // + mbedtls_printf( " . Reading serial number..." ); + fflush( stdout ); + + if( ( ret = mbedtls_mpi_read_string( &serial, 10, opt.serial ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_mpi_read_string returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + // Parse issuer certificate if present + // + if( !opt.selfsign && strlen( opt.issuer_crt ) ) + { + /* + * 1.0.a. Load the certificates + */ + mbedtls_printf( " . Loading the issuer certificate ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_x509_crt_parse_file( &issuer_crt, opt.issuer_crt ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + ret = mbedtls_x509_dn_gets( issuer_name, sizeof(issuer_name), + &issuer_crt.subject ); + if( ret < 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + opt.issuer_name = issuer_name; + + mbedtls_printf( " ok\n" ); + } + +#if defined(MBEDTLS_X509_CSR_PARSE_C) + // Parse certificate request if present + // + if( !opt.selfsign && strlen( opt.request_file ) ) + { + /* + * 1.0.b. Load the CSR + */ + mbedtls_printf( " . Loading the certificate request ..." ); + fflush( stdout ); + + if( ( ret = mbedtls_x509_csr_parse_file( &csr, opt.request_file ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + ret = mbedtls_x509_dn_gets( subject_name, sizeof(subject_name), + &csr.subject ); + if( ret < 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + opt.subject_name = subject_name; + subject_key = &csr.pk; + + mbedtls_printf( " ok\n" ); + } +#endif /* MBEDTLS_X509_CSR_PARSE_C */ + + /* + * 1.1. Load the keys + */ + if( !opt.selfsign && !strlen( opt.request_file ) ) + { + mbedtls_printf( " . Loading the subject key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_keyfile( &loaded_subject_key, opt.subject_key, + opt.subject_pwd ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + } + + mbedtls_printf( " . Loading the issuer key ..." ); + fflush( stdout ); + + ret = mbedtls_pk_parse_keyfile( &loaded_issuer_key, opt.issuer_key, + opt.issuer_pwd ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + // Check if key and issuer certificate match + // + if( strlen( opt.issuer_crt ) ) + { + if( !mbedtls_pk_can_do( &issuer_crt.pk, MBEDTLS_PK_RSA ) || + mbedtls_mpi_cmp_mpi( &mbedtls_pk_rsa( issuer_crt.pk )->N, + &mbedtls_pk_rsa( *issuer_key )->N ) != 0 || + mbedtls_mpi_cmp_mpi( &mbedtls_pk_rsa( issuer_crt.pk )->E, + &mbedtls_pk_rsa( *issuer_key )->E ) != 0 ) + { + mbedtls_printf( " failed\n ! issuer_key does not match issuer certificate\n\n" ); + ret = -1; + goto exit; + } + } + + mbedtls_printf( " ok\n" ); + + if( opt.selfsign ) + { + opt.subject_name = opt.issuer_name; + subject_key = issuer_key; + } + + mbedtls_x509write_crt_set_subject_key( &crt, subject_key ); + mbedtls_x509write_crt_set_issuer_key( &crt, issuer_key ); + + /* + * 1.0. Check the names for validity + */ + if( ( ret = mbedtls_x509write_crt_set_subject_name( &crt, opt.subject_name ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + if( ( ret = mbedtls_x509write_crt_set_issuer_name( &crt, opt.issuer_name ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " . Setting certificate values ..." ); + fflush( stdout ); + + ret = mbedtls_x509write_crt_set_serial( &crt, &serial ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + ret = mbedtls_x509write_crt_set_validity( &crt, opt.not_before, opt.not_after ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + mbedtls_printf( " . Adding the Basic Constraints extension ..." ); + fflush( stdout ); + + ret = mbedtls_x509write_crt_set_basic_constraints( &crt, opt.is_ca, + opt.max_pathlen ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +#if defined(MBEDTLS_SHA1_C) + mbedtls_printf( " . Adding the Subject Key Identifier ..." ); + fflush( stdout ); + + ret = mbedtls_x509write_crt_set_subject_key_identifier( &crt ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_key_identifier returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + mbedtls_printf( " . Adding the Authority Key Identifier ..." ); + fflush( stdout ); + + ret = mbedtls_x509write_crt_set_authority_key_identifier( &crt ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_key_identifier returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); +#endif /* MBEDTLS_SHA1_C */ + + if( opt.key_usage ) + { + mbedtls_printf( " . Adding the Key Usage extension ..." ); + fflush( stdout ); + + ret = mbedtls_x509write_crt_set_key_usage( &crt, opt.key_usage ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + } + + if( opt.ns_cert_type ) + { + mbedtls_printf( " . Adding the NS Cert Type extension ..." ); + fflush( stdout ); + + ret = mbedtls_x509write_crt_set_ns_cert_type( &crt, opt.ns_cert_type ); + if( ret != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ns_cert_type returned -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + } + + /* + * 1.2. Writing the request + */ + mbedtls_printf( " . Writing the certificate..." ); + fflush( stdout ); + + if( ( ret = write_certificate( &crt, opt.output_file, + mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + { + mbedtls_strerror( ret, buf, 1024 ); + mbedtls_printf( " failed\n ! write_certifcate -0x%02x - %s\n\n", -ret, buf ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + +exit: + mbedtls_x509write_crt_free( &crt ); + mbedtls_pk_free( &loaded_subject_key ); + mbedtls_pk_free( &loaded_issuer_key ); + mbedtls_mpi_free( &serial ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + mbedtls_entropy_free( &entropy ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_X509_CRT_WRITE_C && MBEDTLS_X509_CRT_PARSE_C && + MBEDTLS_FS_IO && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && + MBEDTLS_ERROR_C && MBEDTLS_PEM_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/crl_app.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/crl_app.c new file mode 100644 index 0000000..210d19e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/crl_app.c @@ -0,0 +1,145 @@ +/* + * CRL reading application + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_X509_CRL_PARSE_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_X509_CRL_PARSE_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/x509_crl.h" + +#include +#include +#include + +#define DFL_FILENAME "crl.pem" +#define DFL_DEBUG_LEVEL 0 + +#define USAGE \ + "\n usage: crl_app param=<>...\n" \ + "\n acceptable parameters:\n" \ + " filename=%%s default: crl.pem\n" \ + "\n" + +/* + * global options + */ +struct options +{ + const char *filename; /* filename of the certificate file */ +} opt; + +int main( int argc, char *argv[] ) +{ + int ret = 0; + unsigned char buf[100000]; + mbedtls_x509_crl crl; + int i; + char *p, *q; + + /* + * Set to sane values + */ + mbedtls_x509_crl_init( &crl ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + goto exit; + } + + opt.filename = DFL_FILENAME; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else + goto usage; + } + + /* + * 1.1. Load the CRL + */ + mbedtls_printf( "\n . Loading the CRL ..." ); + fflush( stdout ); + + ret = mbedtls_x509_crl_parse_file( &crl, opt.filename ); + + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crl_parse_file returned %d\n\n", ret ); + mbedtls_x509_crl_free( &crl ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2 Print the CRL + */ + mbedtls_printf( " . CRL information ...\n" ); + ret = mbedtls_x509_crl_info( (char *) buf, sizeof( buf ) - 1, " ", &crl ); + if( ret == -1 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_crl_info returned %d\n\n", ret ); + mbedtls_x509_crl_free( &crl ); + goto exit; + } + + mbedtls_printf( "%s\n", buf ); + +exit: + mbedtls_x509_crl_free( &crl ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_X509_CRL_PARSE_C && + MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/req_app.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/req_app.c new file mode 100644 index 0000000..8410a53 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/programs/x509/req_app.c @@ -0,0 +1,145 @@ +/* + * Certificate request reading application + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_X509_CSR_PARSE_C) || !defined(MBEDTLS_FS_IO) +int main( void ) +{ + mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " + "MBEDTLS_X509_CSR_PARSE_C and/or MBEDTLS_FS_IO not defined.\n"); + return( 0 ); +} +#else + +#include "mbedtls/x509_csr.h" + +#include +#include +#include + +#define DFL_FILENAME "cert.req" +#define DFL_DEBUG_LEVEL 0 + +#define USAGE \ + "\n usage: req_app param=<>...\n" \ + "\n acceptable parameters:\n" \ + " filename=%%s default: cert.req\n" \ + "\n" + +/* + * global options + */ +struct options +{ + const char *filename; /* filename of the certificate request */ +} opt; + +int main( int argc, char *argv[] ) +{ + int ret = 0; + unsigned char buf[100000]; + mbedtls_x509_csr csr; + int i; + char *p, *q; + + /* + * Set to sane values + */ + mbedtls_x509_csr_init( &csr ); + + if( argc == 0 ) + { + usage: + mbedtls_printf( USAGE ); + goto exit; + } + + opt.filename = DFL_FILENAME; + + for( i = 1; i < argc; i++ ) + { + p = argv[i]; + if( ( q = strchr( p, '=' ) ) == NULL ) + goto usage; + *q++ = '\0'; + + if( strcmp( p, "filename" ) == 0 ) + opt.filename = q; + else + goto usage; + } + + /* + * 1.1. Load the CSR + */ + mbedtls_printf( "\n . Loading the CSR ..." ); + fflush( stdout ); + + ret = mbedtls_x509_csr_parse_file( &csr, opt.filename ); + + if( ret != 0 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file returned %d\n\n", ret ); + mbedtls_x509_csr_free( &csr ); + goto exit; + } + + mbedtls_printf( " ok\n" ); + + /* + * 1.2 Print the CSR + */ + mbedtls_printf( " . CSR information ...\n" ); + ret = mbedtls_x509_csr_info( (char *) buf, sizeof( buf ) - 1, " ", &csr ); + if( ret == -1 ) + { + mbedtls_printf( " failed\n ! mbedtls_x509_csr_info returned %d\n\n", ret ); + mbedtls_x509_csr_free( &csr ); + goto exit; + } + + mbedtls_printf( "%s\n", buf ); + +exit: + mbedtls_x509_csr_free( &csr ); + +#if defined(_WIN32) + mbedtls_printf( " + Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_X509_CSR_PARSE_C && + MBEDTLS_FS_IO */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/apidoc_full.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/apidoc_full.sh new file mode 100644 index 0000000..bebab10 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/apidoc_full.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Generate doxygen documentation with a full config.h (this ensures that every +# available flag is documented, and avoids warnings about documentation +# without a corresponding #define). +# +# /!\ This must not be a Makefile target, as it would create a race condition +# when multiple targets are invoked in the same parallel build. + +set -eu + +CONFIG_H='include/mbedtls/config.h' + +if [ -r $CONFIG_H ]; then :; else + echo "$CONFIG_H not found" >&2 + exit 1 +fi + +CONFIG_BAK=${CONFIG_H}.bak +cp -p $CONFIG_H $CONFIG_BAK + +scripts/config.pl realfull +make apidoc + +mv $CONFIG_BAK $CONFIG_H diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/bump_version.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/bump_version.sh new file mode 100644 index 0000000..fc8b800 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/bump_version.sh @@ -0,0 +1,140 @@ +#!/bin/bash +# +# This file is part of mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2012-2016, ARM Limited, All Rights Reserved +# +# Purpose +# +# Sets the version numbers in the source code to those given. +# +# Usage: bump_version.sh [ --version ] [ --so-crypto ] +# [ --so-x509 ] [ --so-tls ] +# [ -v | --verbose ] [ -h | --help ] +# + +VERSION="" +SOVERSION="" + +# Parse arguments +# +until [ -z "$1" ] +do + case "$1" in + --version) + # Version to use + shift + VERSION=$1 + ;; + --so-crypto) + shift + SO_CRYPTO=$1 + ;; + --so-x509) + shift + SO_X509=$1 + ;; + --so-tls) + shift + SO_TLS=$1 + ;; + -v|--verbose) + # Be verbose + VERBOSE="1" + ;; + -h|--help) + # print help + echo "Usage: $0" + echo -e " -h|--help\t\tPrint this help." + echo -e " --version \tVersion to bump to." + echo -e " --so-crypto \tSO version to bump libmbedcrypto to." + echo -e " --so-x509 \tSO version to bump libmbedx509 to." + echo -e " --so-tls \tSO version to bump libmbedtls to." + echo -e " -v|--verbose\t\tVerbose." + exit 1 + ;; + *) + # print error + echo "Unknown argument: '$1'" + exit 1 + ;; + esac + shift +done + +if [ "X" = "X$VERSION" ]; +then + echo "No version specified. Unable to continue." + exit 1 +fi + +[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt" +sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp +mv tmp library/CMakeLists.txt + +if [ "X" != "X$SO_CRYPTO" ]; +then + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt" + sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp + mv tmp library/CMakeLists.txt + + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile" + sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp + mv tmp library/Makefile +fi + +if [ "X" != "X$SO_X509" ]; +then + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt" + sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp + mv tmp library/CMakeLists.txt + + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile" + sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp + mv tmp library/Makefile +fi + +if [ "X" != "X$SO_TLS" ]; +then + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt" + sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp + mv tmp library/CMakeLists.txt + + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile" + sed -e "s/SOEXT_TLS=so.[0-9]\{1,\}/SOEXT_TLS=so.$SO_TLS/g" < library/Makefile > tmp + mv tmp library/Makefile +fi + +[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h" +read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION) +VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )" +cat include/mbedtls/version.h | \ + sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \ + sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \ + sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \ + sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \ + sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \ + sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \ + > tmp +mv tmp include/mbedtls/version.h + +[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data" +sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp +mv tmp tests/suites/test_suite_version.data + +[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h" +for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h; +do + sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp + mv tmp $i +done + +[ $VERBOSE ] && echo "Re-generating library/error.c" +scripts/generate_errors.pl + +[ $VERBOSE ] && echo "Re-generating library/version_features.c" +scripts/generate_features.pl + +[ $VERBOSE ] && echo "Re-generating visualc files" +scripts/generate_visualc_files.pl + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/config.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/config.pl new file mode 100644 index 0000000..2757f17 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/config.pl @@ -0,0 +1,252 @@ +#!/usr/bin/perl +# +# This file is part of mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved +# +# Purpose +# +# Comments and uncomments #define lines in the given header file and optionally +# sets their value or can get the value. This is to provide scripting control of +# what preprocessor symbols, and therefore what build time configuration flags +# are set in the 'config.h' file. +# +# Usage: config.pl [-f | --file ] [-o | --force] +# [set | unset | get | +# full | realfull] +# +# Full usage description provided below. +# +# Things that shouldn't be enabled with "full". +# +# MBEDTLS_TEST_NULL_ENTROPY +# MBEDTLS_DEPRECATED_REMOVED +# MBEDTLS_HAVE_SSE2 +# MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +# MBEDTLS_ECP_DP_M221_ENABLED +# MBEDTLS_ECP_DP_M383_ENABLED +# MBEDTLS_ECP_DP_M511_ENABLED +# MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES +# MBEDTLS_NO_PLATFORM_ENTROPY +# MBEDTLS_REMOVE_ARC4_CIPHERSUITES +# MBEDTLS_SSL_HW_RECORD_ACCEL +# MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 +# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION +# - this could be enabled if the respective tests were adapted +# MBEDTLS_ZLIB_SUPPORT +# MBEDTLS_PKCS11_C +# and any symbol beginning _ALT +# + +use warnings; +use strict; + +my $config_file = "include/mbedtls/config.h"; +my $usage = < | --file ] [-o | --force] + [set | unset | get | + full | realfull] + +Commands + set [] - Uncomments or adds a #define for the to + the configuration file, and optionally making it + of . + If the symbol isn't present in the file an error + is returned. + unset - Comments out the #define for the given symbol if + present in the configuration file. + get - Finds the #define for the given symbol, returning + an exitcode of 0 if the symbol is found, and -1 if + not. The value of the symbol is output if one is + specified in the configuration file. + full - Uncomments all #define's in the configuration file + excluding some reserved symbols, until the + 'Module configuration options' section + realfull - Uncomments all #define's with no exclusions + +Options + -f | --file - The file or file path for the configuration file + to edit. When omitted, the following default is + used: + $config_file + -o | --force - If the symbol isn't present in the configuration + file when setting its value, a #define is + appended to the end of the file. + +EOU + +my @excluded = qw( +MBEDTLS_TEST_NULL_ENTROPY +MBEDTLS_DEPRECATED_REMOVED +MBEDTLS_HAVE_SSE2 +MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +MBEDTLS_ECP_DP_M221_ENABLED +MBEDTLS_ECP_DP_M383_ENABLED +MBEDTLS_ECP_DP_M511_ENABLED +MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES +MBEDTLS_NO_PLATFORM_ENTROPY +MBEDTLS_REMOVE_ARC4_CIPHERSUITES +MBEDTLS_SSL_HW_RECORD_ACCEL +MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 +MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION +MBEDTLS_ZLIB_SUPPORT +MBEDTLS_PKCS11_C +_ALT\s*$ +); + +# Things that should be enabled in "full" even if they match @excluded +my @non_excluded = qw( +PLATFORM_[A-Z0-9]+_ALT +); + +# Process the command line arguments + +my $force_option = 0; + +my ($arg, $name, $value, $action); + +while ($arg = shift) { + + # Check if the argument is an option + if ($arg eq "-f" || $arg eq "--file") { + $config_file = shift; + + -f $config_file or die "No such file: $config_file\n"; + + } + elsif ($arg eq "-o" || $arg eq "--force") { + $force_option = 1; + + } + else + { + # ...else assume it's a command + $action = $arg; + + if ($action eq "full" || $action eq "realfull") { + # No additional parameters + die $usage if @ARGV; + + } + elsif ($action eq "unset" || $action eq "get") { + die $usage unless @ARGV; + $name = shift; + + } + elsif ($action eq "set") { + die $usage unless @ARGV; + $name = shift; + $value = shift if @ARGV; + + } + else { + die "Command '$action' not recognised.\n\n".$usage; + } + } +} + +# If no command was specified, exit... +if ( not defined($action) ){ die $usage; } + +# Check the config file is present +if (! -f $config_file) { + + chdir '..' or die; + + # Confirm this is the project root directory and try again + if ( !(-d 'scripts' && -d 'include' && -d 'library' && -f $config_file) ) { + die "If no file specified, must be run from the project root or scripts directory.\n"; + } +} + + +# Now read the file and process the contents + +open my $config_read, '<', $config_file or die "read $config_file: $!\n"; +my @config_lines = <$config_read>; +close $config_read; + +my ($exclude_re, $no_exclude_re); +if ($action eq "realfull") { + $exclude_re = qr/^$/; + $no_exclude_re = qr/./; +} else { + $exclude_re = join '|', @excluded; + $no_exclude_re = join '|', @non_excluded; +} + +open my $config_write, '>', $config_file or die "write $config_file: $!\n"; + +my $done; +for my $line (@config_lines) { + if ($action eq "full" || $action eq "realfull") { + if ($line =~ /name SECTION: Module configuration options/) { + $done = 1; + } + + if (!$done && $line =~ m!^//\s?#define! && + ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) { + $line =~ s!^//\s?!!; + } + if (!$done && $line =~ m!^\s?#define! && + ! ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) { + $line =~ s!^!//!; + } + } elsif ($action eq "unset") { + if (!$done && $line =~ /^\s*#define\s*$name\b/) { + $line = '//' . $line; + $done = 1; + } + } elsif (!$done && $action eq "set") { + if ($line =~ m!^(?://)?\s*#define\s*$name\b!) { + $line = "#define $name"; + $line .= " $value" if defined $value && $value ne ""; + $line .= "\n"; + $done = 1; + } + } elsif (!$done && $action eq "get") { + if ($line =~ /^\s*#define\s*$name\s*(.*)\s*\b/) { + $value = $1; + $done = 1; + } + } + + print $config_write $line; +} + +# Did the set command work? +if ($action eq "set"&& $force_option && !$done) { + + # If the force option was set, append the symbol to the end of the file + my $line = "#define $name"; + $line .= " $value" if defined $value && $value ne ""; + $line .= "\n"; + $done = 1; + + print $config_write $line; +} + +close $config_write; + +if ($action eq "get") { + if($done) { + if ($value ne '') { + print $value; + } + exit 0; + } else { + # If the symbol was not found, return an error + exit -1; + } +} + +if ($action eq "full" && !$done) { + die "Configuration section was not found in $config_file\n"; + +} + +if ($action ne "full" && $action ne "unset" && !$done) { + die "A #define for the symbol $name was not found in $config_file\n"; +} + +__END__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/error.fmt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/error.fmt new file mode 100644 index 0000000..a08742c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/error.fmt @@ -0,0 +1,123 @@ +/* + * Error message information + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) +#include "mbedtls/error.h" +#include +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#define mbedtls_snprintf snprintf +#define mbedtls_time_t time_t +#endif + +#if defined(MBEDTLS_ERROR_C) + +#include + +HEADER_INCLUDED + +void mbedtls_strerror( int ret, char *buf, size_t buflen ) +{ + size_t len; + int use_ret; + + if( buflen == 0 ) + return; + + memset( buf, 0x00, buflen ); + + if( ret < 0 ) + ret = -ret; + + if( ret & 0xFF80 ) + { + use_ret = ret & 0xFF80; + + // High level error codes + // + // BEGIN generated code +HIGH_LEVEL_CODE_CHECKS + // END generated code + + if( strlen( buf ) == 0 ) + mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); + } + + use_ret = ret & ~0xFF80; + + if( use_ret == 0 ) + return; + + // If high level code is present, make a concatenation between both + // error strings. + // + len = strlen( buf ); + + if( len > 0 ) + { + if( buflen - len < 5 ) + return; + + mbedtls_snprintf( buf + len, buflen - len, " : " ); + + buf += len + 3; + buflen -= len + 3; + } + + // Low level error codes + // + // BEGIN generated code +LOW_LEVEL_CODE_CHECKS + // END generated code + + if( strlen( buf ) != 0 ) + return; + + mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); +} + +#else /* MBEDTLS_ERROR_C */ + +#if defined(MBEDTLS_ERROR_STRERROR_DUMMY) + +/* + * Provide an non-function in case MBEDTLS_ERROR_C is not defined + */ +void mbedtls_strerror( int ret, char *buf, size_t buflen ) +{ + ((void) ret); + + if( buflen > 0 ) + buf[0] = '\0'; +} + +#endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ + +#endif /* MBEDTLS_ERROR_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/rename-1.3-2.0.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/rename-1.3-2.0.txt new file mode 100644 index 0000000..cb3381a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/rename-1.3-2.0.txt @@ -0,0 +1,2174 @@ +AES_DECRYPT MBEDTLS_AES_DECRYPT +AES_ENCRYPT MBEDTLS_AES_ENCRYPT +ASN1_BIT_STRING MBEDTLS_ASN1_BIT_STRING +ASN1_BMP_STRING MBEDTLS_ASN1_BMP_STRING +ASN1_BOOLEAN MBEDTLS_ASN1_BOOLEAN +ASN1_CHK_ADD MBEDTLS_ASN1_CHK_ADD +ASN1_CONSTRUCTED MBEDTLS_ASN1_CONSTRUCTED +ASN1_CONTEXT_SPECIFIC MBEDTLS_ASN1_CONTEXT_SPECIFIC +ASN1_GENERALIZED_TIME MBEDTLS_ASN1_GENERALIZED_TIME +ASN1_IA5_STRING MBEDTLS_ASN1_IA5_STRING +ASN1_INTEGER MBEDTLS_ASN1_INTEGER +ASN1_NULL MBEDTLS_ASN1_NULL +ASN1_OCTET_STRING MBEDTLS_ASN1_OCTET_STRING +ASN1_OID MBEDTLS_ASN1_OID +ASN1_PRIMITIVE MBEDTLS_ASN1_PRIMITIVE +ASN1_PRINTABLE_STRING MBEDTLS_ASN1_PRINTABLE_STRING +ASN1_SEQUENCE MBEDTLS_ASN1_SEQUENCE +ASN1_SET MBEDTLS_ASN1_SET +ASN1_T61_STRING MBEDTLS_ASN1_T61_STRING +ASN1_UNIVERSAL_STRING MBEDTLS_ASN1_UNIVERSAL_STRING +ASN1_UTC_TIME MBEDTLS_ASN1_UTC_TIME +ASN1_UTF8_STRING MBEDTLS_ASN1_UTF8_STRING +BADCERT_CN_MISMATCH MBEDTLS_X509_BADCERT_CN_MISMATCH +BADCERT_EXPIRED MBEDTLS_X509_BADCERT_EXPIRED +BADCERT_EXT_KEY_USAGE MBEDTLS_X509_BADCERT_EXT_KEY_USAGE +BADCERT_FUTURE MBEDTLS_X509_BADCERT_FUTURE +BADCERT_KEY_USAGE MBEDTLS_X509_BADCERT_KEY_USAGE +BADCERT_MISSING MBEDTLS_X509_BADCERT_MISSING +BADCERT_NOT_TRUSTED MBEDTLS_X509_BADCERT_NOT_TRUSTED +BADCERT_NS_CERT_TYPE MBEDTLS_X509_BADCERT_NS_CERT_TYPE +BADCERT_OTHER MBEDTLS_X509_BADCERT_OTHER +BADCERT_REVOKED MBEDTLS_X509_BADCERT_REVOKED +BADCERT_SKIP_VERIFY MBEDTLS_X509_BADCERT_SKIP_VERIFY +BADCRL_EXPIRED MBEDTLS_X509_BADCRL_EXPIRED +BADCRL_FUTURE MBEDTLS_X509_BADCRL_FUTURE +BADCRL_NOT_TRUSTED MBEDTLS_X509_BADCRL_NOT_TRUSTED +BLOWFISH_BLOCKSIZE MBEDTLS_BLOWFISH_BLOCKSIZE +BLOWFISH_DECRYPT MBEDTLS_BLOWFISH_DECRYPT +BLOWFISH_ENCRYPT MBEDTLS_BLOWFISH_ENCRYPT +BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY_BITS +BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY_BITS +BLOWFISH_ROUNDS MBEDTLS_BLOWFISH_ROUNDS +CAMELLIA_DECRYPT MBEDTLS_CAMELLIA_DECRYPT +CAMELLIA_ENCRYPT MBEDTLS_CAMELLIA_ENCRYPT +COLLECT_SIZE MBEDTLS_HAVEGE_COLLECT_SIZE +CTR_DRBG_BLOCKSIZE MBEDTLS_CTR_DRBG_BLOCKSIZE +CTR_DRBG_ENTROPY_LEN MBEDTLS_CTR_DRBG_ENTROPY_LEN +CTR_DRBG_KEYBITS MBEDTLS_CTR_DRBG_KEYBITS +CTR_DRBG_KEYSIZE MBEDTLS_CTR_DRBG_KEYSIZE +CTR_DRBG_MAX_INPUT MBEDTLS_CTR_DRBG_MAX_INPUT +CTR_DRBG_MAX_REQUEST MBEDTLS_CTR_DRBG_MAX_REQUEST +CTR_DRBG_MAX_SEED_INPUT MBEDTLS_CTR_DRBG_MAX_SEED_INPUT +CTR_DRBG_PR_OFF MBEDTLS_CTR_DRBG_PR_OFF +CTR_DRBG_PR_ON MBEDTLS_CTR_DRBG_PR_ON +CTR_DRBG_RESEED_INTERVAL MBEDTLS_CTR_DRBG_RESEED_INTERVAL +CTR_DRBG_SEEDLEN MBEDTLS_CTR_DRBG_SEEDLEN +DEPRECATED MBEDTLS_DEPRECATED +DES_DECRYPT MBEDTLS_DES_DECRYPT +DES_ENCRYPT MBEDTLS_DES_ENCRYPT +DES_KEY_SIZE MBEDTLS_DES_KEY_SIZE +ENTROPY_BLOCK_SIZE MBEDTLS_ENTROPY_BLOCK_SIZE +ENTROPY_MAX_GATHER MBEDTLS_ENTROPY_MAX_GATHER +ENTROPY_MAX_SEED_SIZE MBEDTLS_ENTROPY_MAX_SEED_SIZE +ENTROPY_MAX_SOURCES MBEDTLS_ENTROPY_MAX_SOURCES +ENTROPY_MIN_HARDCLOCK MBEDTLS_ENTROPY_MIN_HARDCLOCK +ENTROPY_MIN_HAVEGE MBEDTLS_ENTROPY_MIN_HAVEGE +ENTROPY_MIN_PLATFORM MBEDTLS_ENTROPY_MIN_PLATFORM +ENTROPY_SOURCE_MANUAL MBEDTLS_ENTROPY_SOURCE_MANUAL +EXT_AUTHORITY_KEY_IDENTIFIER MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER +EXT_BASIC_CONSTRAINTS MBEDTLS_X509_EXT_BASIC_CONSTRAINTS +EXT_CERTIFICATE_POLICIES MBEDTLS_X509_EXT_CERTIFICATE_POLICIES +EXT_CRL_DISTRIBUTION_POINTS MBEDTLS_X509_EXT_CRL_DISTRIBUTION_POINTS +EXT_EXTENDED_KEY_USAGE MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE +EXT_FRESHEST_CRL MBEDTLS_X509_EXT_FRESHEST_CRL +EXT_INIHIBIT_ANYPOLICY MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY +EXT_ISSUER_ALT_NAME MBEDTLS_X509_EXT_ISSUER_ALT_NAME +EXT_KEY_USAGE MBEDTLS_X509_EXT_KEY_USAGE +EXT_NAME_CONSTRAINTS MBEDTLS_X509_EXT_NAME_CONSTRAINTS +EXT_NS_CERT_TYPE MBEDTLS_X509_EXT_NS_CERT_TYPE +EXT_POLICY_CONSTRAINTS MBEDTLS_X509_EXT_POLICY_CONSTRAINTS +EXT_POLICY_MAPPINGS MBEDTLS_X509_EXT_POLICY_MAPPINGS +EXT_SUBJECT_ALT_NAME MBEDTLS_X509_EXT_SUBJECT_ALT_NAME +EXT_SUBJECT_DIRECTORY_ATTRS MBEDTLS_X509_EXT_SUBJECT_DIRECTORY_ATTRS +EXT_SUBJECT_KEY_IDENTIFIER MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER +GCM_DECRYPT MBEDTLS_GCM_DECRYPT +GCM_ENCRYPT MBEDTLS_GCM_ENCRYPT +KU_CRL_SIGN MBEDTLS_X509_KU_CRL_SIGN +KU_DATA_ENCIPHERMENT MBEDTLS_X509_KU_DATA_ENCIPHERMENT +KU_DIGITAL_SIGNATURE MBEDTLS_X509_KU_DIGITAL_SIGNATURE +KU_KEY_AGREEMENT MBEDTLS_X509_KU_KEY_AGREEMENT +KU_KEY_CERT_SIGN MBEDTLS_X509_KU_KEY_CERT_SIGN +KU_KEY_ENCIPHERMENT MBEDTLS_X509_KU_KEY_ENCIPHERMENT +KU_NON_REPUDIATION MBEDTLS_X509_KU_NON_REPUDIATION +LN_2_DIV_LN_10_SCALE100 MBEDTLS_LN_2_DIV_LN_10_SCALE100 +MD_CONTEXT_T_INIT MBEDTLS_MD_CONTEXT_T_INIT +MEMORY_VERIFY_ALLOC MBEDTLS_MEMORY_VERIFY_ALLOC +MEMORY_VERIFY_ALWAYS MBEDTLS_MEMORY_VERIFY_ALWAYS +MEMORY_VERIFY_FREE MBEDTLS_MEMORY_VERIFY_FREE +MEMORY_VERIFY_NONE MBEDTLS_MEMORY_VERIFY_NONE +MPI_CHK MBEDTLS_MPI_CHK +NET_PROTO_TCP MBEDTLS_NET_PROTO_TCP +NET_PROTO_UDP MBEDTLS_NET_PROTO_UDP +NS_CERT_TYPE_EMAIL MBEDTLS_X509_NS_CERT_TYPE_EMAIL +NS_CERT_TYPE_EMAIL_CA MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA +NS_CERT_TYPE_OBJECT_SIGNING MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING +NS_CERT_TYPE_OBJECT_SIGNING_CA MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA +NS_CERT_TYPE_RESERVED MBEDTLS_X509_NS_CERT_TYPE_RESERVED +NS_CERT_TYPE_SSL_CA MBEDTLS_X509_NS_CERT_TYPE_SSL_CA +NS_CERT_TYPE_SSL_CLIENT MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT +NS_CERT_TYPE_SSL_SERVER MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER +OID_ANSI_X9_62 MBEDTLS_OID_ANSI_X9_62 +OID_ANSI_X9_62_FIELD_TYPE MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE +OID_ANSI_X9_62_PRIME_FIELD MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD +OID_ANSI_X9_62_SIG MBEDTLS_OID_ANSI_X9_62_SIG +OID_ANSI_X9_62_SIG_SHA2 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 +OID_ANY_EXTENDED_KEY_USAGE MBEDTLS_OID_ANY_EXTENDED_KEY_USAGE +OID_AT MBEDTLS_OID_AT +OID_AT_CN MBEDTLS_OID_AT_CN +OID_AT_COUNTRY MBEDTLS_OID_AT_COUNTRY +OID_AT_DN_QUALIFIER MBEDTLS_OID_AT_DN_QUALIFIER +OID_AT_GENERATION_QUALIFIER MBEDTLS_OID_AT_GENERATION_QUALIFIER +OID_AT_GIVEN_NAME MBEDTLS_OID_AT_GIVEN_NAME +OID_AT_INITIALS MBEDTLS_OID_AT_INITIALS +OID_AT_LOCALITY MBEDTLS_OID_AT_LOCALITY +OID_AT_ORGANIZATION MBEDTLS_OID_AT_ORGANIZATION +OID_AT_ORG_UNIT MBEDTLS_OID_AT_ORG_UNIT +OID_AT_POSTAL_ADDRESS MBEDTLS_OID_AT_POSTAL_ADDRESS +OID_AT_POSTAL_CODE MBEDTLS_OID_AT_POSTAL_CODE +OID_AT_PSEUDONYM MBEDTLS_OID_AT_PSEUDONYM +OID_AT_SERIAL_NUMBER MBEDTLS_OID_AT_SERIAL_NUMBER +OID_AT_STATE MBEDTLS_OID_AT_STATE +OID_AT_SUR_NAME MBEDTLS_OID_AT_SUR_NAME +OID_AT_TITLE MBEDTLS_OID_AT_TITLE +OID_AT_UNIQUE_IDENTIFIER MBEDTLS_OID_AT_UNIQUE_IDENTIFIER +OID_AUTHORITY_KEY_IDENTIFIER MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER +OID_BASIC_CONSTRAINTS MBEDTLS_OID_BASIC_CONSTRAINTS +OID_CERTICOM MBEDTLS_OID_CERTICOM +OID_CERTIFICATE_POLICIES MBEDTLS_OID_CERTIFICATE_POLICIES +OID_CLIENT_AUTH MBEDTLS_OID_CLIENT_AUTH +OID_CMP MBEDTLS_OID_CMP +OID_CODE_SIGNING MBEDTLS_OID_CODE_SIGNING +OID_COUNTRY_US MBEDTLS_OID_COUNTRY_US +OID_CRL_DISTRIBUTION_POINTS MBEDTLS_OID_CRL_DISTRIBUTION_POINTS +OID_CRL_NUMBER MBEDTLS_OID_CRL_NUMBER +OID_DES_CBC MBEDTLS_OID_DES_CBC +OID_DES_EDE3_CBC MBEDTLS_OID_DES_EDE3_CBC +OID_DIGEST_ALG_MD2 MBEDTLS_OID_DIGEST_ALG_MD2 +OID_DIGEST_ALG_MD4 MBEDTLS_OID_DIGEST_ALG_MD4 +OID_DIGEST_ALG_MD5 MBEDTLS_OID_DIGEST_ALG_MD5 +OID_DIGEST_ALG_SHA1 MBEDTLS_OID_DIGEST_ALG_SHA1 +OID_DIGEST_ALG_SHA224 MBEDTLS_OID_DIGEST_ALG_SHA224 +OID_DIGEST_ALG_SHA256 MBEDTLS_OID_DIGEST_ALG_SHA256 +OID_DIGEST_ALG_SHA384 MBEDTLS_OID_DIGEST_ALG_SHA384 +OID_DIGEST_ALG_SHA512 MBEDTLS_OID_DIGEST_ALG_SHA512 +OID_DOMAIN_COMPONENT MBEDTLS_OID_DOMAIN_COMPONENT +OID_ECDSA_SHA1 MBEDTLS_OID_ECDSA_SHA1 +OID_ECDSA_SHA224 MBEDTLS_OID_ECDSA_SHA224 +OID_ECDSA_SHA256 MBEDTLS_OID_ECDSA_SHA256 +OID_ECDSA_SHA384 MBEDTLS_OID_ECDSA_SHA384 +OID_ECDSA_SHA512 MBEDTLS_OID_ECDSA_SHA512 +OID_EC_ALG_ECDH MBEDTLS_OID_EC_ALG_ECDH +OID_EC_ALG_UNRESTRICTED MBEDTLS_OID_EC_ALG_UNRESTRICTED +OID_EC_BRAINPOOL_V1 MBEDTLS_OID_EC_BRAINPOOL_V1 +OID_EC_GRP_BP256R1 MBEDTLS_OID_EC_GRP_BP256R1 +OID_EC_GRP_BP384R1 MBEDTLS_OID_EC_GRP_BP384R1 +OID_EC_GRP_BP512R1 MBEDTLS_OID_EC_GRP_BP512R1 +OID_EC_GRP_SECP192K1 MBEDTLS_OID_EC_GRP_SECP192K1 +OID_EC_GRP_SECP192R1 MBEDTLS_OID_EC_GRP_SECP192R1 +OID_EC_GRP_SECP224K1 MBEDTLS_OID_EC_GRP_SECP224K1 +OID_EC_GRP_SECP224R1 MBEDTLS_OID_EC_GRP_SECP224R1 +OID_EC_GRP_SECP256K1 MBEDTLS_OID_EC_GRP_SECP256K1 +OID_EC_GRP_SECP256R1 MBEDTLS_OID_EC_GRP_SECP256R1 +OID_EC_GRP_SECP384R1 MBEDTLS_OID_EC_GRP_SECP384R1 +OID_EC_GRP_SECP521R1 MBEDTLS_OID_EC_GRP_SECP521R1 +OID_EMAIL_PROTECTION MBEDTLS_OID_EMAIL_PROTECTION +OID_EXTENDED_KEY_USAGE MBEDTLS_OID_EXTENDED_KEY_USAGE +OID_FRESHEST_CRL MBEDTLS_OID_FRESHEST_CRL +OID_GOV MBEDTLS_OID_GOV +OID_HMAC_SHA1 MBEDTLS_OID_HMAC_SHA1 +OID_ID_CE MBEDTLS_OID_ID_CE +OID_INIHIBIT_ANYPOLICY MBEDTLS_OID_INIHIBIT_ANYPOLICY +OID_ISO_CCITT_DS MBEDTLS_OID_ISO_CCITT_DS +OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ISO_IDENTIFIED_ORG +OID_ISO_ITU_COUNTRY MBEDTLS_OID_ISO_ITU_COUNTRY +OID_ISO_ITU_US_ORG MBEDTLS_OID_ISO_ITU_US_ORG +OID_ISO_MEMBER_BODIES MBEDTLS_OID_ISO_MEMBER_BODIES +OID_ISSUER_ALT_NAME MBEDTLS_OID_ISSUER_ALT_NAME +OID_KEY_USAGE MBEDTLS_OID_KEY_USAGE +OID_KP MBEDTLS_OID_KP +OID_MGF1 MBEDTLS_OID_MGF1 +OID_NAME_CONSTRAINTS MBEDTLS_OID_NAME_CONSTRAINTS +OID_NETSCAPE MBEDTLS_OID_NETSCAPE +OID_NS_BASE_URL MBEDTLS_OID_NS_BASE_URL +OID_NS_CA_POLICY_URL MBEDTLS_OID_NS_CA_POLICY_URL +OID_NS_CA_REVOCATION_URL MBEDTLS_OID_NS_CA_REVOCATION_URL +OID_NS_CERT MBEDTLS_OID_NS_CERT +OID_NS_CERT_SEQUENCE MBEDTLS_OID_NS_CERT_SEQUENCE +OID_NS_CERT_TYPE MBEDTLS_OID_NS_CERT_TYPE +OID_NS_COMMENT MBEDTLS_OID_NS_COMMENT +OID_NS_DATA_TYPE MBEDTLS_OID_NS_DATA_TYPE +OID_NS_RENEWAL_URL MBEDTLS_OID_NS_RENEWAL_URL +OID_NS_REVOCATION_URL MBEDTLS_OID_NS_REVOCATION_URL +OID_NS_SSL_SERVER_NAME MBEDTLS_OID_NS_SSL_SERVER_NAME +OID_OCSP_SIGNING MBEDTLS_OID_OCSP_SIGNING +OID_OIW_SECSIG MBEDTLS_OID_OIW_SECSIG +OID_OIW_SECSIG_ALG MBEDTLS_OID_OIW_SECSIG_ALG +OID_OIW_SECSIG_SHA1 MBEDTLS_OID_OIW_SECSIG_SHA1 +OID_ORGANIZATION MBEDTLS_OID_ORGANIZATION +OID_ORG_ANSI_X9_62 MBEDTLS_OID_ORG_ANSI_X9_62 +OID_ORG_CERTICOM MBEDTLS_OID_ORG_CERTICOM +OID_ORG_DOD MBEDTLS_OID_ORG_DOD +OID_ORG_GOV MBEDTLS_OID_ORG_GOV +OID_ORG_NETSCAPE MBEDTLS_OID_ORG_NETSCAPE +OID_ORG_OIW MBEDTLS_OID_ORG_OIW +OID_ORG_RSA_DATA_SECURITY MBEDTLS_OID_ORG_RSA_DATA_SECURITY +OID_ORG_TELETRUST MBEDTLS_OID_ORG_TELETRUST +OID_PKCS MBEDTLS_OID_PKCS +OID_PKCS1 MBEDTLS_OID_PKCS1 +OID_PKCS12 MBEDTLS_OID_PKCS12 +OID_PKCS12_PBE MBEDTLS_OID_PKCS12_PBE +OID_PKCS12_PBE_SHA1_DES2_EDE_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC +OID_PKCS12_PBE_SHA1_DES3_EDE_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC +OID_PKCS12_PBE_SHA1_RC2_128_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_128_CBC +OID_PKCS12_PBE_SHA1_RC2_40_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_40_CBC +OID_PKCS12_PBE_SHA1_RC4_128 MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_128 +OID_PKCS12_PBE_SHA1_RC4_40 MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_40 +OID_PKCS1_MD2 MBEDTLS_OID_PKCS1_MD2 +OID_PKCS1_MD4 MBEDTLS_OID_PKCS1_MD4 +OID_PKCS1_MD5 MBEDTLS_OID_PKCS1_MD5 +OID_PKCS1_RSA MBEDTLS_OID_PKCS1_RSA +OID_PKCS1_SHA1 MBEDTLS_OID_PKCS1_SHA1 +OID_PKCS1_SHA224 MBEDTLS_OID_PKCS1_SHA224 +OID_PKCS1_SHA256 MBEDTLS_OID_PKCS1_SHA256 +OID_PKCS1_SHA384 MBEDTLS_OID_PKCS1_SHA384 +OID_PKCS1_SHA512 MBEDTLS_OID_PKCS1_SHA512 +OID_PKCS5 MBEDTLS_OID_PKCS5 +OID_PKCS5_PBES2 MBEDTLS_OID_PKCS5_PBES2 +OID_PKCS5_PBE_MD2_DES_CBC MBEDTLS_OID_PKCS5_PBE_MD2_DES_CBC +OID_PKCS5_PBE_MD2_RC2_CBC MBEDTLS_OID_PKCS5_PBE_MD2_RC2_CBC +OID_PKCS5_PBE_MD5_DES_CBC MBEDTLS_OID_PKCS5_PBE_MD5_DES_CBC +OID_PKCS5_PBE_MD5_RC2_CBC MBEDTLS_OID_PKCS5_PBE_MD5_RC2_CBC +OID_PKCS5_PBE_SHA1_DES_CBC MBEDTLS_OID_PKCS5_PBE_SHA1_DES_CBC +OID_PKCS5_PBE_SHA1_RC2_CBC MBEDTLS_OID_PKCS5_PBE_SHA1_RC2_CBC +OID_PKCS5_PBKDF2 MBEDTLS_OID_PKCS5_PBKDF2 +OID_PKCS5_PBMAC1 MBEDTLS_OID_PKCS5_PBMAC1 +OID_PKCS9 MBEDTLS_OID_PKCS9 +OID_PKCS9_CSR_EXT_REQ MBEDTLS_OID_PKCS9_CSR_EXT_REQ +OID_PKCS9_EMAIL MBEDTLS_OID_PKCS9_EMAIL +OID_PKIX MBEDTLS_OID_PKIX +OID_POLICY_CONSTRAINTS MBEDTLS_OID_POLICY_CONSTRAINTS +OID_POLICY_MAPPINGS MBEDTLS_OID_POLICY_MAPPINGS +OID_PRIVATE_KEY_USAGE_PERIOD MBEDTLS_OID_PRIVATE_KEY_USAGE_PERIOD +OID_RSASSA_PSS MBEDTLS_OID_RSASSA_PSS +OID_RSA_COMPANY MBEDTLS_OID_RSA_COMPANY +OID_RSA_SHA_OBS MBEDTLS_OID_RSA_SHA_OBS +OID_SERVER_AUTH MBEDTLS_OID_SERVER_AUTH +OID_SIZE MBEDTLS_OID_SIZE +OID_SUBJECT_ALT_NAME MBEDTLS_OID_SUBJECT_ALT_NAME +OID_SUBJECT_DIRECTORY_ATTRS MBEDTLS_OID_SUBJECT_DIRECTORY_ATTRS +OID_SUBJECT_KEY_IDENTIFIER MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER +OID_TELETRUST MBEDTLS_OID_TELETRUST +OID_TIME_STAMPING MBEDTLS_OID_TIME_STAMPING +PADLOCK_ACE MBEDTLS_PADLOCK_ACE +PADLOCK_ALIGN16 MBEDTLS_PADLOCK_ALIGN16 +PADLOCK_PHE MBEDTLS_PADLOCK_PHE +PADLOCK_PMM MBEDTLS_PADLOCK_PMM +PADLOCK_RNG MBEDTLS_PADLOCK_RNG +PKCS12_DERIVE_IV MBEDTLS_PKCS12_DERIVE_IV +PKCS12_DERIVE_KEY MBEDTLS_PKCS12_DERIVE_KEY +PKCS12_DERIVE_MAC_KEY MBEDTLS_PKCS12_DERIVE_MAC_KEY +PKCS12_PBE_DECRYPT MBEDTLS_PKCS12_PBE_DECRYPT +PKCS12_PBE_ENCRYPT MBEDTLS_PKCS12_PBE_ENCRYPT +PKCS5_DECRYPT MBEDTLS_PKCS5_DECRYPT +PKCS5_ENCRYPT MBEDTLS_PKCS5_ENCRYPT +POLARSSL_AESNI_AES MBEDTLS_AESNI_AES +POLARSSL_AESNI_C MBEDTLS_AESNI_C +POLARSSL_AESNI_CLMUL MBEDTLS_AESNI_CLMUL +POLARSSL_AESNI_H MBEDTLS_AESNI_H +POLARSSL_AES_ALT MBEDTLS_AES_ALT +POLARSSL_AES_C MBEDTLS_AES_C +POLARSSL_AES_H MBEDTLS_AES_H +POLARSSL_AES_ROM_TABLES MBEDTLS_AES_ROM_TABLES +POLARSSL_ARC4_ALT MBEDTLS_ARC4_ALT +POLARSSL_ARC4_C MBEDTLS_ARC4_C +POLARSSL_ARC4_H MBEDTLS_ARC4_H +POLARSSL_ASN1_H MBEDTLS_ASN1_H +POLARSSL_ASN1_PARSE_C MBEDTLS_ASN1_PARSE_C +POLARSSL_ASN1_WRITE_C MBEDTLS_ASN1_WRITE_C +POLARSSL_ASN1_WRITE_H MBEDTLS_ASN1_WRITE_H +POLARSSL_BASE64_C MBEDTLS_BASE64_C +POLARSSL_BASE64_H MBEDTLS_BASE64_H +POLARSSL_BIGNUM_C MBEDTLS_BIGNUM_C +POLARSSL_BIGNUM_H MBEDTLS_BIGNUM_H +POLARSSL_BLOWFISH_ALT MBEDTLS_BLOWFISH_ALT +POLARSSL_BLOWFISH_C MBEDTLS_BLOWFISH_C +POLARSSL_BLOWFISH_H MBEDTLS_BLOWFISH_H +POLARSSL_BN_MUL_H MBEDTLS_BN_MUL_H +POLARSSL_CAMELLIA_ALT MBEDTLS_CAMELLIA_ALT +POLARSSL_CAMELLIA_C MBEDTLS_CAMELLIA_C +POLARSSL_CAMELLIA_H MBEDTLS_CAMELLIA_H +POLARSSL_CAMELLIA_SMALL_MEMORY MBEDTLS_CAMELLIA_SMALL_MEMORY +POLARSSL_CCM_C MBEDTLS_CCM_C +POLARSSL_CCM_H MBEDTLS_CCM_H +POLARSSL_CERTS_C MBEDTLS_CERTS_C +POLARSSL_CERTS_H MBEDTLS_CERTS_H +POLARSSL_CHECK_CONFIG_H MBEDTLS_CHECK_CONFIG_H +POLARSSL_CIPHERSUITE_NODTLS MBEDTLS_CIPHERSUITE_NODTLS +POLARSSL_CIPHERSUITE_SHORT_TAG MBEDTLS_CIPHERSUITE_SHORT_TAG +POLARSSL_CIPHERSUITE_WEAK MBEDTLS_CIPHERSUITE_WEAK +POLARSSL_CIPHER_AES_128_CBC MBEDTLS_CIPHER_AES_128_CBC +POLARSSL_CIPHER_AES_128_CCM MBEDTLS_CIPHER_AES_128_CCM +POLARSSL_CIPHER_AES_128_CFB128 MBEDTLS_CIPHER_AES_128_CFB128 +POLARSSL_CIPHER_AES_128_CTR MBEDTLS_CIPHER_AES_128_CTR +POLARSSL_CIPHER_AES_128_ECB MBEDTLS_CIPHER_AES_128_ECB +POLARSSL_CIPHER_AES_128_GCM MBEDTLS_CIPHER_AES_128_GCM +POLARSSL_CIPHER_AES_192_CBC MBEDTLS_CIPHER_AES_192_CBC +POLARSSL_CIPHER_AES_192_CCM MBEDTLS_CIPHER_AES_192_CCM +POLARSSL_CIPHER_AES_192_CFB128 MBEDTLS_CIPHER_AES_192_CFB128 +POLARSSL_CIPHER_AES_192_CTR MBEDTLS_CIPHER_AES_192_CTR +POLARSSL_CIPHER_AES_192_ECB MBEDTLS_CIPHER_AES_192_ECB +POLARSSL_CIPHER_AES_192_GCM MBEDTLS_CIPHER_AES_192_GCM +POLARSSL_CIPHER_AES_256_CBC MBEDTLS_CIPHER_AES_256_CBC +POLARSSL_CIPHER_AES_256_CCM MBEDTLS_CIPHER_AES_256_CCM +POLARSSL_CIPHER_AES_256_CFB128 MBEDTLS_CIPHER_AES_256_CFB128 +POLARSSL_CIPHER_AES_256_CTR MBEDTLS_CIPHER_AES_256_CTR +POLARSSL_CIPHER_AES_256_ECB MBEDTLS_CIPHER_AES_256_ECB +POLARSSL_CIPHER_AES_256_GCM MBEDTLS_CIPHER_AES_256_GCM +POLARSSL_CIPHER_ARC4_128 MBEDTLS_CIPHER_ARC4_128 +POLARSSL_CIPHER_BLOWFISH_CBC MBEDTLS_CIPHER_BLOWFISH_CBC +POLARSSL_CIPHER_BLOWFISH_CFB64 MBEDTLS_CIPHER_BLOWFISH_CFB64 +POLARSSL_CIPHER_BLOWFISH_CTR MBEDTLS_CIPHER_BLOWFISH_CTR +POLARSSL_CIPHER_BLOWFISH_ECB MBEDTLS_CIPHER_BLOWFISH_ECB +POLARSSL_CIPHER_C MBEDTLS_CIPHER_C +POLARSSL_CIPHER_CAMELLIA_128_CBC MBEDTLS_CIPHER_CAMELLIA_128_CBC +POLARSSL_CIPHER_CAMELLIA_128_CCM MBEDTLS_CIPHER_CAMELLIA_128_CCM +POLARSSL_CIPHER_CAMELLIA_128_CFB128 MBEDTLS_CIPHER_CAMELLIA_128_CFB128 +POLARSSL_CIPHER_CAMELLIA_128_CTR MBEDTLS_CIPHER_CAMELLIA_128_CTR +POLARSSL_CIPHER_CAMELLIA_128_ECB MBEDTLS_CIPHER_CAMELLIA_128_ECB +POLARSSL_CIPHER_CAMELLIA_128_GCM MBEDTLS_CIPHER_CAMELLIA_128_GCM +POLARSSL_CIPHER_CAMELLIA_192_CBC MBEDTLS_CIPHER_CAMELLIA_192_CBC +POLARSSL_CIPHER_CAMELLIA_192_CCM MBEDTLS_CIPHER_CAMELLIA_192_CCM +POLARSSL_CIPHER_CAMELLIA_192_CFB128 MBEDTLS_CIPHER_CAMELLIA_192_CFB128 +POLARSSL_CIPHER_CAMELLIA_192_CTR MBEDTLS_CIPHER_CAMELLIA_192_CTR +POLARSSL_CIPHER_CAMELLIA_192_ECB MBEDTLS_CIPHER_CAMELLIA_192_ECB +POLARSSL_CIPHER_CAMELLIA_192_GCM MBEDTLS_CIPHER_CAMELLIA_192_GCM +POLARSSL_CIPHER_CAMELLIA_256_CBC MBEDTLS_CIPHER_CAMELLIA_256_CBC +POLARSSL_CIPHER_CAMELLIA_256_CCM MBEDTLS_CIPHER_CAMELLIA_256_CCM +POLARSSL_CIPHER_CAMELLIA_256_CFB128 MBEDTLS_CIPHER_CAMELLIA_256_CFB128 +POLARSSL_CIPHER_CAMELLIA_256_CTR MBEDTLS_CIPHER_CAMELLIA_256_CTR +POLARSSL_CIPHER_CAMELLIA_256_ECB MBEDTLS_CIPHER_CAMELLIA_256_ECB +POLARSSL_CIPHER_CAMELLIA_256_GCM MBEDTLS_CIPHER_CAMELLIA_256_GCM +POLARSSL_CIPHER_DES_CBC MBEDTLS_CIPHER_DES_CBC +POLARSSL_CIPHER_DES_ECB MBEDTLS_CIPHER_DES_ECB +POLARSSL_CIPHER_DES_EDE3_CBC MBEDTLS_CIPHER_DES_EDE3_CBC +POLARSSL_CIPHER_DES_EDE3_ECB MBEDTLS_CIPHER_DES_EDE3_ECB +POLARSSL_CIPHER_DES_EDE_CBC MBEDTLS_CIPHER_DES_EDE_CBC +POLARSSL_CIPHER_DES_EDE_ECB MBEDTLS_CIPHER_DES_EDE_ECB +POLARSSL_CIPHER_H MBEDTLS_CIPHER_H +POLARSSL_CIPHER_ID_3DES MBEDTLS_CIPHER_ID_3DES +POLARSSL_CIPHER_ID_AES MBEDTLS_CIPHER_ID_AES +POLARSSL_CIPHER_ID_ARC4 MBEDTLS_CIPHER_ID_ARC4 +POLARSSL_CIPHER_ID_BLOWFISH MBEDTLS_CIPHER_ID_BLOWFISH +POLARSSL_CIPHER_ID_CAMELLIA MBEDTLS_CIPHER_ID_CAMELLIA +POLARSSL_CIPHER_ID_DES MBEDTLS_CIPHER_ID_DES +POLARSSL_CIPHER_ID_NONE MBEDTLS_CIPHER_ID_NONE +POLARSSL_CIPHER_ID_NULL MBEDTLS_CIPHER_ID_NULL +POLARSSL_CIPHER_MODE_AEAD MBEDTLS_CIPHER_MODE_AEAD +POLARSSL_CIPHER_MODE_CBC MBEDTLS_CIPHER_MODE_CBC +POLARSSL_CIPHER_MODE_CFB MBEDTLS_CIPHER_MODE_CFB +POLARSSL_CIPHER_MODE_CTR MBEDTLS_CIPHER_MODE_CTR +POLARSSL_CIPHER_MODE_STREAM MBEDTLS_CIPHER_MODE_STREAM +POLARSSL_CIPHER_MODE_WITH_PADDING MBEDTLS_CIPHER_MODE_WITH_PADDING +POLARSSL_CIPHER_NONE MBEDTLS_CIPHER_NONE +POLARSSL_CIPHER_NULL MBEDTLS_CIPHER_NULL +POLARSSL_CIPHER_NULL_CIPHER MBEDTLS_CIPHER_NULL_CIPHER +POLARSSL_CIPHER_PADDING_ONE_AND_ZEROS MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +POLARSSL_CIPHER_PADDING_PKCS7 MBEDTLS_CIPHER_PADDING_PKCS7 +POLARSSL_CIPHER_PADDING_ZEROS MBEDTLS_CIPHER_PADDING_ZEROS +POLARSSL_CIPHER_PADDING_ZEROS_AND_LEN MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +POLARSSL_CIPHER_VARIABLE_IV_LEN MBEDTLS_CIPHER_VARIABLE_IV_LEN +POLARSSL_CIPHER_VARIABLE_KEY_LEN MBEDTLS_CIPHER_VARIABLE_KEY_LEN +POLARSSL_CIPHER_WRAP_H MBEDTLS_CIPHER_WRAP_H +POLARSSL_CONFIG_FILE MBEDTLS_CONFIG_FILE +POLARSSL_CONFIG_H MBEDTLS_CONFIG_H +POLARSSL_CTR_DRBG_C MBEDTLS_CTR_DRBG_C +POLARSSL_CTR_DRBG_H MBEDTLS_CTR_DRBG_H +POLARSSL_DEBUG_C MBEDTLS_DEBUG_C +POLARSSL_DEBUG_DFL_MODE MBEDTLS_DEBUG_DFL_MODE +POLARSSL_DEBUG_H MBEDTLS_DEBUG_H +POLARSSL_DEBUG_LOG_FULL MBEDTLS_DEBUG_LOG_FULL +POLARSSL_DEBUG_LOG_RAW MBEDTLS_DEBUG_LOG_RAW +POLARSSL_DECRYPT MBEDTLS_DECRYPT +POLARSSL_DEPRECATED_REMOVED MBEDTLS_DEPRECATED_REMOVED +POLARSSL_DEPRECATED_WARNING MBEDTLS_DEPRECATED_WARNING +POLARSSL_DES_ALT MBEDTLS_DES_ALT +POLARSSL_DES_C MBEDTLS_DES_C +POLARSSL_DES_H MBEDTLS_DES_H +POLARSSL_DHM_C MBEDTLS_DHM_C +POLARSSL_DHM_H MBEDTLS_DHM_H +POLARSSL_DHM_RFC2409_MODP_1024_G MBEDTLS_DHM_RFC2409_MODP_1024_G +POLARSSL_DHM_RFC2409_MODP_1024_P MBEDTLS_DHM_RFC2409_MODP_1024_P +POLARSSL_DHM_RFC3526_MODP_2048_G MBEDTLS_DHM_RFC3526_MODP_2048_G +POLARSSL_DHM_RFC3526_MODP_2048_P MBEDTLS_DHM_RFC3526_MODP_2048_P +POLARSSL_DHM_RFC3526_MODP_3072_G MBEDTLS_DHM_RFC3526_MODP_3072_G +POLARSSL_DHM_RFC3526_MODP_3072_P MBEDTLS_DHM_RFC3526_MODP_3072_P +POLARSSL_DHM_RFC5114_MODP_1024_G MBEDTLS_DHM_RFC5114_MODP_1024_G +POLARSSL_DHM_RFC5114_MODP_1024_P MBEDTLS_DHM_RFC5114_MODP_1024_P +POLARSSL_DHM_RFC5114_MODP_2048_G MBEDTLS_DHM_RFC5114_MODP_2048_G +POLARSSL_DHM_RFC5114_MODP_2048_P MBEDTLS_DHM_RFC5114_MODP_2048_P +POLARSSL_ECDH_C MBEDTLS_ECDH_C +POLARSSL_ECDH_H MBEDTLS_ECDH_H +POLARSSL_ECDH_OURS MBEDTLS_ECDH_OURS +POLARSSL_ECDH_THEIRS MBEDTLS_ECDH_THEIRS +POLARSSL_ECDSA_C MBEDTLS_ECDSA_C +POLARSSL_ECDSA_DETERMINISTIC MBEDTLS_ECDSA_DETERMINISTIC +POLARSSL_ECDSA_H MBEDTLS_ECDSA_H +POLARSSL_ECP_C MBEDTLS_ECP_C +POLARSSL_ECP_DP_BP256R1 MBEDTLS_ECP_DP_BP256R1 +POLARSSL_ECP_DP_BP256R1_ENABLED MBEDTLS_ECP_DP_BP256R1_ENABLED +POLARSSL_ECP_DP_BP384R1 MBEDTLS_ECP_DP_BP384R1 +POLARSSL_ECP_DP_BP384R1_ENABLED MBEDTLS_ECP_DP_BP384R1_ENABLED +POLARSSL_ECP_DP_BP512R1 MBEDTLS_ECP_DP_BP512R1 +POLARSSL_ECP_DP_BP512R1_ENABLED MBEDTLS_ECP_DP_BP512R1_ENABLED +POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_CURVE25519 +POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_CURVE25519_ENABLED +POLARSSL_ECP_DP_MAX MBEDTLS_ECP_DP_MAX +POLARSSL_ECP_DP_NONE MBEDTLS_ECP_DP_NONE +POLARSSL_ECP_DP_SECP192K1 MBEDTLS_ECP_DP_SECP192K1 +POLARSSL_ECP_DP_SECP192K1_ENABLED MBEDTLS_ECP_DP_SECP192K1_ENABLED +POLARSSL_ECP_DP_SECP192R1 MBEDTLS_ECP_DP_SECP192R1 +POLARSSL_ECP_DP_SECP192R1_ENABLED MBEDTLS_ECP_DP_SECP192R1_ENABLED +POLARSSL_ECP_DP_SECP224K1 MBEDTLS_ECP_DP_SECP224K1 +POLARSSL_ECP_DP_SECP224K1_ENABLED MBEDTLS_ECP_DP_SECP224K1_ENABLED +POLARSSL_ECP_DP_SECP224R1 MBEDTLS_ECP_DP_SECP224R1 +POLARSSL_ECP_DP_SECP224R1_ENABLED MBEDTLS_ECP_DP_SECP224R1_ENABLED +POLARSSL_ECP_DP_SECP256K1 MBEDTLS_ECP_DP_SECP256K1 +POLARSSL_ECP_DP_SECP256K1_ENABLED MBEDTLS_ECP_DP_SECP256K1_ENABLED +POLARSSL_ECP_DP_SECP256R1 MBEDTLS_ECP_DP_SECP256R1 +POLARSSL_ECP_DP_SECP256R1_ENABLED MBEDTLS_ECP_DP_SECP256R1_ENABLED +POLARSSL_ECP_DP_SECP384R1 MBEDTLS_ECP_DP_SECP384R1 +POLARSSL_ECP_DP_SECP384R1_ENABLED MBEDTLS_ECP_DP_SECP384R1_ENABLED +POLARSSL_ECP_DP_SECP521R1 MBEDTLS_ECP_DP_SECP521R1 +POLARSSL_ECP_DP_SECP521R1_ENABLED MBEDTLS_ECP_DP_SECP521R1_ENABLED +POLARSSL_ECP_FIXED_POINT_OPTIM MBEDTLS_ECP_FIXED_POINT_OPTIM +POLARSSL_ECP_H MBEDTLS_ECP_H +POLARSSL_ECP_MAX_BITS MBEDTLS_ECP_MAX_BITS +POLARSSL_ECP_MAX_BYTES MBEDTLS_ECP_MAX_BYTES +POLARSSL_ECP_MAX_PT_LEN MBEDTLS_ECP_MAX_PT_LEN +POLARSSL_ECP_NIST_OPTIM MBEDTLS_ECP_NIST_OPTIM +POLARSSL_ECP_PF_COMPRESSED MBEDTLS_ECP_PF_COMPRESSED +POLARSSL_ECP_PF_UNCOMPRESSED MBEDTLS_ECP_PF_UNCOMPRESSED +POLARSSL_ECP_TLS_NAMED_CURVE MBEDTLS_ECP_TLS_NAMED_CURVE +POLARSSL_ECP_WINDOW_SIZE MBEDTLS_ECP_WINDOW_SIZE +POLARSSL_ENABLE_WEAK_CIPHERSUITES MBEDTLS_ENABLE_WEAK_CIPHERSUITES +POLARSSL_ENCRYPT MBEDTLS_ENCRYPT +POLARSSL_ENTROPY_C MBEDTLS_ENTROPY_C +POLARSSL_ENTROPY_FORCE_SHA256 MBEDTLS_ENTROPY_FORCE_SHA256 +POLARSSL_ENTROPY_H MBEDTLS_ENTROPY_H +POLARSSL_ENTROPY_POLL_H MBEDTLS_ENTROPY_POLL_H +POLARSSL_ENTROPY_SHA256_ACCUMULATOR MBEDTLS_ENTROPY_SHA256_ACCUMULATOR +POLARSSL_ENTROPY_SHA512_ACCUMULATOR MBEDTLS_ENTROPY_SHA512_ACCUMULATOR +POLARSSL_ERROR_C MBEDTLS_ERROR_C +POLARSSL_ERROR_H MBEDTLS_ERROR_H +POLARSSL_ERROR_STRERROR_BC MBEDTLS_ERROR_STRERROR_BC +POLARSSL_ERROR_STRERROR_DUMMY MBEDTLS_ERROR_STRERROR_DUMMY +POLARSSL_ERR_AES_INVALID_INPUT_LENGTH MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH +POLARSSL_ERR_AES_INVALID_KEY_LENGTH MBEDTLS_ERR_AES_INVALID_KEY_LENGTH +POLARSSL_ERR_ASN1_BUF_TOO_SMALL MBEDTLS_ERR_ASN1_BUF_TOO_SMALL +POLARSSL_ERR_ASN1_INVALID_DATA MBEDTLS_ERR_ASN1_INVALID_DATA +POLARSSL_ERR_ASN1_INVALID_LENGTH MBEDTLS_ERR_ASN1_INVALID_LENGTH +POLARSSL_ERR_ASN1_LENGTH_MISMATCH MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +POLARSSL_ERR_ASN1_MALLOC_FAILED MBEDTLS_ERR_ASN1_ALLOC_FAILED +POLARSSL_ERR_ASN1_OUT_OF_DATA MBEDTLS_ERR_ASN1_OUT_OF_DATA +POLARSSL_ERR_ASN1_UNEXPECTED_TAG MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL +POLARSSL_ERR_BASE64_INVALID_CHARACTER MBEDTLS_ERR_BASE64_INVALID_CHARACTER +POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH +POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH +POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH +POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH +POLARSSL_ERR_CCM_AUTH_FAILED MBEDTLS_ERR_CCM_AUTH_FAILED +POLARSSL_ERR_CCM_BAD_INPUT MBEDTLS_ERR_CCM_BAD_INPUT +POLARSSL_ERR_CIPHER_ALLOC_FAILED MBEDTLS_ERR_CIPHER_ALLOC_FAILED +POLARSSL_ERR_CIPHER_AUTH_FAILED MBEDTLS_ERR_CIPHER_AUTH_FAILED +POLARSSL_ERR_CIPHER_BAD_INPUT_DATA MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE +POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED +POLARSSL_ERR_CIPHER_INVALID_PADDING MBEDTLS_ERR_CIPHER_INVALID_PADDING +POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED +POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR +POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG +POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG +POLARSSL_ERR_DES_INVALID_INPUT_LENGTH MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH +POLARSSL_ERR_DHM_BAD_INPUT_DATA MBEDTLS_ERR_DHM_BAD_INPUT_DATA +POLARSSL_ERR_DHM_CALC_SECRET_FAILED MBEDTLS_ERR_DHM_CALC_SECRET_FAILED +POLARSSL_ERR_DHM_FILE_IO_ERROR MBEDTLS_ERR_DHM_FILE_IO_ERROR +POLARSSL_ERR_DHM_INVALID_FORMAT MBEDTLS_ERR_DHM_INVALID_FORMAT +POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED +POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED +POLARSSL_ERR_DHM_MALLOC_FAILED MBEDTLS_ERR_DHM_ALLOC_FAILED +POLARSSL_ERR_DHM_READ_PARAMS_FAILED MBEDTLS_ERR_DHM_READ_PARAMS_FAILED +POLARSSL_ERR_DHM_READ_PUBLIC_FAILED MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED +POLARSSL_ERR_ECP_BAD_INPUT_DATA MBEDTLS_ERR_ECP_BAD_INPUT_DATA +POLARSSL_ERR_ECP_BUFFER_TOO_SMALL MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL +POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE +POLARSSL_ERR_ECP_INVALID_KEY MBEDTLS_ERR_ECP_INVALID_KEY +POLARSSL_ERR_ECP_MALLOC_FAILED MBEDTLS_ERR_ECP_ALLOC_FAILED +POLARSSL_ERR_ECP_RANDOM_FAILED MBEDTLS_ERR_ECP_RANDOM_FAILED +POLARSSL_ERR_ECP_SIG_LEN_MISMATCH MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH +POLARSSL_ERR_ECP_VERIFY_FAILED MBEDTLS_ERR_ECP_VERIFY_FAILED +POLARSSL_ERR_ENTROPY_FILE_IO_ERROR MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR +POLARSSL_ERR_ENTROPY_MAX_SOURCES MBEDTLS_ERR_ENTROPY_MAX_SOURCES +POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED +POLARSSL_ERR_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_ENTROPY_SOURCE_FAILED +POLARSSL_ERR_GCM_AUTH_FAILED MBEDTLS_ERR_GCM_AUTH_FAILED +POLARSSL_ERR_GCM_BAD_INPUT MBEDTLS_ERR_GCM_BAD_INPUT +POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED +POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR +POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG +POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG +POLARSSL_ERR_MD2_FILE_IO_ERROR MBEDTLS_ERR_MD2_FILE_IO_ERROR +POLARSSL_ERR_MD4_FILE_IO_ERROR MBEDTLS_ERR_MD4_FILE_IO_ERROR +POLARSSL_ERR_MD5_FILE_IO_ERROR MBEDTLS_ERR_MD5_FILE_IO_ERROR +POLARSSL_ERR_MD_ALLOC_FAILED MBEDTLS_ERR_MD_ALLOC_FAILED +POLARSSL_ERR_MD_BAD_INPUT_DATA MBEDTLS_ERR_MD_BAD_INPUT_DATA +POLARSSL_ERR_MD_FEATURE_UNAVAILABLE MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE +POLARSSL_ERR_MD_FILE_IO_ERROR MBEDTLS_ERR_MD_FILE_IO_ERROR +POLARSSL_ERR_MPI_BAD_INPUT_DATA MBEDTLS_ERR_MPI_BAD_INPUT_DATA +POLARSSL_ERR_MPI_BUFFER_TOO_SMALL MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL +POLARSSL_ERR_MPI_DIVISION_BY_ZERO MBEDTLS_ERR_MPI_DIVISION_BY_ZERO +POLARSSL_ERR_MPI_FILE_IO_ERROR MBEDTLS_ERR_MPI_FILE_IO_ERROR +POLARSSL_ERR_MPI_INVALID_CHARACTER MBEDTLS_ERR_MPI_INVALID_CHARACTER +POLARSSL_ERR_MPI_MALLOC_FAILED MBEDTLS_ERR_MPI_ALLOC_FAILED +POLARSSL_ERR_MPI_NEGATIVE_VALUE MBEDTLS_ERR_MPI_NEGATIVE_VALUE +POLARSSL_ERR_MPI_NOT_ACCEPTABLE MBEDTLS_ERR_MPI_NOT_ACCEPTABLE +POLARSSL_ERR_NET_ACCEPT_FAILED MBEDTLS_ERR_NET_ACCEPT_FAILED +POLARSSL_ERR_NET_BIND_FAILED MBEDTLS_ERR_NET_BIND_FAILED +POLARSSL_ERR_NET_CONNECT_FAILED MBEDTLS_ERR_NET_CONNECT_FAILED +POLARSSL_ERR_NET_CONN_RESET MBEDTLS_ERR_NET_CONN_RESET +POLARSSL_ERR_NET_LISTEN_FAILED MBEDTLS_ERR_NET_LISTEN_FAILED +POLARSSL_ERR_NET_RECV_FAILED MBEDTLS_ERR_NET_RECV_FAILED +POLARSSL_ERR_NET_SEND_FAILED MBEDTLS_ERR_NET_SEND_FAILED +POLARSSL_ERR_NET_SOCKET_FAILED MBEDTLS_ERR_NET_SOCKET_FAILED +POLARSSL_ERR_NET_TIMEOUT MBEDTLS_ERR_SSL_TIMEOUT +POLARSSL_ERR_NET_UNKNOWN_HOST MBEDTLS_ERR_NET_UNKNOWN_HOST +POLARSSL_ERR_NET_WANT_READ MBEDTLS_ERR_SSL_WANT_READ +POLARSSL_ERR_NET_WANT_WRITE MBEDTLS_ERR_SSL_WANT_WRITE +POLARSSL_ERR_OID_BUF_TOO_SMALL MBEDTLS_ERR_OID_BUF_TOO_SMALL +POLARSSL_ERR_OID_NOT_FOUND MBEDTLS_ERR_OID_NOT_FOUND +POLARSSL_ERR_PADLOCK_DATA_MISALIGNED MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED +POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA MBEDTLS_ERR_PBKDF2_BAD_INPUT_DATA +POLARSSL_ERR_PEM_BAD_INPUT_DATA MBEDTLS_ERR_PEM_BAD_INPUT_DATA +POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE +POLARSSL_ERR_PEM_INVALID_DATA MBEDTLS_ERR_PEM_INVALID_DATA +POLARSSL_ERR_PEM_INVALID_ENC_IV MBEDTLS_ERR_PEM_INVALID_ENC_IV +POLARSSL_ERR_PEM_MALLOC_FAILED MBEDTLS_ERR_PEM_ALLOC_FAILED +POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT +POLARSSL_ERR_PEM_PASSWORD_MISMATCH MBEDTLS_ERR_PEM_PASSWORD_MISMATCH +POLARSSL_ERR_PEM_PASSWORD_REQUIRED MBEDTLS_ERR_PEM_PASSWORD_REQUIRED +POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG +POLARSSL_ERR_PKCS12_BAD_INPUT_DATA MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA +POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE +POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH +POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT +POLARSSL_ERR_PKCS5_BAD_INPUT_DATA MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA +POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE +POLARSSL_ERR_PKCS5_INVALID_FORMAT MBEDTLS_ERR_PKCS5_INVALID_FORMAT +POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH +POLARSSL_ERR_PK_BAD_INPUT_DATA MBEDTLS_ERR_PK_BAD_INPUT_DATA +POLARSSL_ERR_PK_FEATURE_UNAVAILABLE MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE +POLARSSL_ERR_PK_FILE_IO_ERROR MBEDTLS_ERR_PK_FILE_IO_ERROR +POLARSSL_ERR_PK_INVALID_ALG MBEDTLS_ERR_PK_INVALID_ALG +POLARSSL_ERR_PK_INVALID_PUBKEY MBEDTLS_ERR_PK_INVALID_PUBKEY +POLARSSL_ERR_PK_KEY_INVALID_FORMAT MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +POLARSSL_ERR_PK_KEY_INVALID_VERSION MBEDTLS_ERR_PK_KEY_INVALID_VERSION +POLARSSL_ERR_PK_MALLOC_FAILED MBEDTLS_ERR_PK_ALLOC_FAILED +POLARSSL_ERR_PK_PASSWORD_MISMATCH MBEDTLS_ERR_PK_PASSWORD_MISMATCH +POLARSSL_ERR_PK_PASSWORD_REQUIRED MBEDTLS_ERR_PK_PASSWORD_REQUIRED +POLARSSL_ERR_PK_SIG_LEN_MISMATCH MBEDTLS_ERR_PK_SIG_LEN_MISMATCH +POLARSSL_ERR_PK_TYPE_MISMATCH MBEDTLS_ERR_PK_TYPE_MISMATCH +POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE +POLARSSL_ERR_PK_UNKNOWN_PK_ALG MBEDTLS_ERR_PK_UNKNOWN_PK_ALG +POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR +POLARSSL_ERR_RSA_BAD_INPUT_DATA MBEDTLS_ERR_RSA_BAD_INPUT_DATA +POLARSSL_ERR_RSA_INVALID_PADDING MBEDTLS_ERR_RSA_INVALID_PADDING +POLARSSL_ERR_RSA_KEY_CHECK_FAILED MBEDTLS_ERR_RSA_KEY_CHECK_FAILED +POLARSSL_ERR_RSA_KEY_GEN_FAILED MBEDTLS_ERR_RSA_KEY_GEN_FAILED +POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE +POLARSSL_ERR_RSA_PRIVATE_FAILED MBEDTLS_ERR_RSA_PRIVATE_FAILED +POLARSSL_ERR_RSA_PUBLIC_FAILED MBEDTLS_ERR_RSA_PUBLIC_FAILED +POLARSSL_ERR_RSA_RNG_FAILED MBEDTLS_ERR_RSA_RNG_FAILED +POLARSSL_ERR_RSA_VERIFY_FAILED MBEDTLS_ERR_RSA_VERIFY_FAILED +POLARSSL_ERR_SHA1_FILE_IO_ERROR MBEDTLS_ERR_SHA1_FILE_IO_ERROR +POLARSSL_ERR_SHA256_FILE_IO_ERROR MBEDTLS_ERR_SHA256_FILE_IO_ERROR +POLARSSL_ERR_SHA512_FILE_IO_ERROR MBEDTLS_ERR_SHA512_FILE_IO_ERROR +POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE +POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST +POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY +POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC +POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO +POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE +POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS +POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP +POLARSSL_ERR_SSL_BAD_HS_FINISHED MBEDTLS_ERR_SSL_BAD_HS_FINISHED +POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET +POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION +POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO +POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE +POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE +POLARSSL_ERR_SSL_BAD_INPUT_DATA MBEDTLS_ERR_SSL_BAD_INPUT_DATA +POLARSSL_ERR_SSL_BUFFER_TOO_SMALL MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL +POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED +POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED +POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE +POLARSSL_ERR_SSL_COMPRESSION_FAILED MBEDTLS_ERR_SSL_COMPRESSION_FAILED +POLARSSL_ERR_SSL_CONN_EOF MBEDTLS_ERR_SSL_CONN_EOF +POLARSSL_ERR_SSL_COUNTER_WRAPPING MBEDTLS_ERR_SSL_COUNTER_WRAPPING +POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE +POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE +POLARSSL_ERR_SSL_HELLO_VERIFY_REQUIRED MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED +POLARSSL_ERR_SSL_HW_ACCEL_FAILED MBEDTLS_ERR_SSL_HW_ACCEL_FAILED +POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH +POLARSSL_ERR_SSL_INTERNAL_ERROR MBEDTLS_ERR_SSL_INTERNAL_ERROR +POLARSSL_ERR_SSL_INVALID_MAC MBEDTLS_ERR_SSL_INVALID_MAC +POLARSSL_ERR_SSL_INVALID_RECORD MBEDTLS_ERR_SSL_INVALID_RECORD +POLARSSL_ERR_SSL_MALLOC_FAILED MBEDTLS_ERR_SSL_ALLOC_FAILED +POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN +POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE +POLARSSL_ERR_SSL_NO_RNG MBEDTLS_ERR_SSL_NO_RNG +POLARSSL_ERR_SSL_NO_USABLE_CIPHERSUITE MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE +POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY +POLARSSL_ERR_SSL_PEER_VERIFY_FAILED MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED +POLARSSL_ERR_SSL_PK_TYPE_MISMATCH MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH +POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED +POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED +POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE +POLARSSL_ERR_SSL_UNKNOWN_CIPHER MBEDTLS_ERR_SSL_UNKNOWN_CIPHER +POLARSSL_ERR_SSL_UNKNOWN_IDENTITY MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY +POLARSSL_ERR_SSL_WAITING_SERVER_HELLO_RENEGO MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO +POLARSSL_ERR_THREADING_BAD_INPUT_DATA MBEDTLS_ERR_THREADING_BAD_INPUT_DATA +POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE +POLARSSL_ERR_THREADING_MUTEX_ERROR MBEDTLS_ERR_THREADING_MUTEX_ERROR +POLARSSL_ERR_X509_BAD_INPUT_DATA MBEDTLS_ERR_X509_BAD_INPUT_DATA +POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT +POLARSSL_ERR_X509_CERT_VERIFY_FAILED MBEDTLS_ERR_X509_CERT_VERIFY_FAILED +POLARSSL_ERR_X509_FEATURE_UNAVAILABLE MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE +POLARSSL_ERR_X509_FILE_IO_ERROR MBEDTLS_ERR_X509_FILE_IO_ERROR +POLARSSL_ERR_X509_INVALID_ALG MBEDTLS_ERR_X509_INVALID_ALG +POLARSSL_ERR_X509_INVALID_DATE MBEDTLS_ERR_X509_INVALID_DATE +POLARSSL_ERR_X509_INVALID_EXTENSIONS MBEDTLS_ERR_X509_INVALID_EXTENSIONS +POLARSSL_ERR_X509_INVALID_FORMAT MBEDTLS_ERR_X509_INVALID_FORMAT +POLARSSL_ERR_X509_INVALID_NAME MBEDTLS_ERR_X509_INVALID_NAME +POLARSSL_ERR_X509_INVALID_SERIAL MBEDTLS_ERR_X509_INVALID_SERIAL +POLARSSL_ERR_X509_INVALID_SIGNATURE MBEDTLS_ERR_X509_INVALID_SIGNATURE +POLARSSL_ERR_X509_INVALID_VERSION MBEDTLS_ERR_X509_INVALID_VERSION +POLARSSL_ERR_X509_MALLOC_FAILED MBEDTLS_ERR_X509_ALLOC_FAILED +POLARSSL_ERR_X509_SIG_MISMATCH MBEDTLS_ERR_X509_SIG_MISMATCH +POLARSSL_ERR_X509_UNKNOWN_OID MBEDTLS_ERR_X509_UNKNOWN_OID +POLARSSL_ERR_X509_UNKNOWN_SIG_ALG MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG +POLARSSL_ERR_X509_UNKNOWN_VERSION MBEDTLS_ERR_X509_UNKNOWN_VERSION +POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH +POLARSSL_FS_IO MBEDTLS_FS_IO +POLARSSL_GCM_C MBEDTLS_GCM_C +POLARSSL_GCM_H MBEDTLS_GCM_H +POLARSSL_GENPRIME MBEDTLS_GENPRIME +POLARSSL_HAVEGE_C MBEDTLS_HAVEGE_C +POLARSSL_HAVEGE_H MBEDTLS_HAVEGE_H +POLARSSL_HAVE_ASM MBEDTLS_HAVE_ASM +POLARSSL_HAVE_INT16 MBEDTLS_HAVE_INT16 +POLARSSL_HAVE_INT32 MBEDTLS_HAVE_INT32 +POLARSSL_HAVE_INT64 MBEDTLS_HAVE_INT64 +POLARSSL_HAVE_INT8 MBEDTLS_HAVE_INT8 +POLARSSL_HAVE_IPV6 MBEDTLS_HAVE_IPV6 +POLARSSL_HAVE_LONGLONG MBEDTLS_HAVE_LONGLONG +POLARSSL_HAVE_SSE2 MBEDTLS_HAVE_SSE2 +POLARSSL_HAVE_TIME MBEDTLS_HAVE_TIME +POLARSSL_HAVE_UDBL MBEDTLS_HAVE_UDBL +POLARSSL_HAVE_X86 MBEDTLS_HAVE_X86 +POLARSSL_HAVE_X86_64 MBEDTLS_HAVE_X86_64 +POLARSSL_HMAC_DRBG_C MBEDTLS_HMAC_DRBG_C +POLARSSL_HMAC_DRBG_H MBEDTLS_HMAC_DRBG_H +POLARSSL_HMAC_DRBG_MAX_INPUT MBEDTLS_HMAC_DRBG_MAX_INPUT +POLARSSL_HMAC_DRBG_MAX_REQUEST MBEDTLS_HMAC_DRBG_MAX_REQUEST +POLARSSL_HMAC_DRBG_MAX_SEED_INPUT MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT +POLARSSL_HMAC_DRBG_PR_OFF MBEDTLS_HMAC_DRBG_PR_OFF +POLARSSL_HMAC_DRBG_PR_ON MBEDTLS_HMAC_DRBG_PR_ON +POLARSSL_HMAC_DRBG_RESEED_INTERVAL MBEDTLS_HMAC_DRBG_RESEED_INTERVAL +POLARSSL_KEY_EXCHANGE_DHE_PSK MBEDTLS_KEY_EXCHANGE_DHE_PSK +POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED +POLARSSL_KEY_EXCHANGE_DHE_RSA MBEDTLS_KEY_EXCHANGE_DHE_RSA +POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED +POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +POLARSSL_KEY_EXCHANGE_ECDHE_PSK MBEDTLS_KEY_EXCHANGE_ECDHE_PSK +POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED +POLARSSL_KEY_EXCHANGE_ECDHE_RSA MBEDTLS_KEY_EXCHANGE_ECDHE_RSA +POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +POLARSSL_KEY_EXCHANGE_ECDH_ECDSA MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA +POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +POLARSSL_KEY_EXCHANGE_ECDH_RSA MBEDTLS_KEY_EXCHANGE_ECDH_RSA +POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +POLARSSL_KEY_EXCHANGE_NONE MBEDTLS_KEY_EXCHANGE_NONE +POLARSSL_KEY_EXCHANGE_PSK MBEDTLS_KEY_EXCHANGE_PSK +POLARSSL_KEY_EXCHANGE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +POLARSSL_KEY_EXCHANGE_RSA MBEDTLS_KEY_EXCHANGE_RSA +POLARSSL_KEY_EXCHANGE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +POLARSSL_KEY_EXCHANGE_RSA_PSK MBEDTLS_KEY_EXCHANGE_RSA_PSK +POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +POLARSSL_KEY_EXCHANGE__SOME__ECDHE_ENABLED MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED +POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED +POLARSSL_KEY_EXCHANGE__WITH_CERT__ENABLED MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED +POLARSSL_KEY_LENGTH_DES MBEDTLS_KEY_LENGTH_DES +POLARSSL_KEY_LENGTH_DES_EDE MBEDTLS_KEY_LENGTH_DES_EDE +POLARSSL_KEY_LENGTH_DES_EDE3 MBEDTLS_KEY_LENGTH_DES_EDE3 +POLARSSL_KEY_LENGTH_NONE MBEDTLS_KEY_LENGTH_NONE +POLARSSL_MAX_BLOCK_LENGTH MBEDTLS_MAX_BLOCK_LENGTH +POLARSSL_MAX_IV_LENGTH MBEDTLS_MAX_IV_LENGTH +POLARSSL_MD2_ALT MBEDTLS_MD2_ALT +POLARSSL_MD2_C MBEDTLS_MD2_C +POLARSSL_MD2_H MBEDTLS_MD2_H +POLARSSL_MD4_ALT MBEDTLS_MD4_ALT +POLARSSL_MD4_C MBEDTLS_MD4_C +POLARSSL_MD4_H MBEDTLS_MD4_H +POLARSSL_MD5_ALT MBEDTLS_MD5_ALT +POLARSSL_MD5_C MBEDTLS_MD5_C +POLARSSL_MD5_H MBEDTLS_MD5_H +POLARSSL_MD_C MBEDTLS_MD_C +POLARSSL_MD_H MBEDTLS_MD_H +POLARSSL_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE +POLARSSL_MD_MD2 MBEDTLS_MD_MD2 +POLARSSL_MD_MD4 MBEDTLS_MD_MD4 +POLARSSL_MD_MD5 MBEDTLS_MD_MD5 +POLARSSL_MD_NONE MBEDTLS_MD_NONE +POLARSSL_MD_RIPEMD160 MBEDTLS_MD_RIPEMD160 +POLARSSL_MD_SHA1 MBEDTLS_MD_SHA1 +POLARSSL_MD_SHA224 MBEDTLS_MD_SHA224 +POLARSSL_MD_SHA256 MBEDTLS_MD_SHA256 +POLARSSL_MD_SHA384 MBEDTLS_MD_SHA384 +POLARSSL_MD_SHA512 MBEDTLS_MD_SHA512 +POLARSSL_MD_WRAP_H MBEDTLS_MD_WRAP_H +POLARSSL_MEMORY_ALIGN_MULTIPLE MBEDTLS_MEMORY_ALIGN_MULTIPLE +POLARSSL_MEMORY_BACKTRACE MBEDTLS_MEMORY_BACKTRACE +POLARSSL_MEMORY_BUFFER_ALLOC_C MBEDTLS_MEMORY_BUFFER_ALLOC_C +POLARSSL_MEMORY_BUFFER_ALLOC_H MBEDTLS_MEMORY_BUFFER_ALLOC_H +POLARSSL_MEMORY_C MBEDTLS_MEMORY_C +POLARSSL_MEMORY_DEBUG MBEDTLS_MEMORY_DEBUG +POLARSSL_MEMORY_H MBEDTLS_MEMORY_H +POLARSSL_MODE_CBC MBEDTLS_MODE_CBC +POLARSSL_MODE_CCM MBEDTLS_MODE_CCM +POLARSSL_MODE_CFB MBEDTLS_MODE_CFB +POLARSSL_MODE_CTR MBEDTLS_MODE_CTR +POLARSSL_MODE_ECB MBEDTLS_MODE_ECB +POLARSSL_MODE_GCM MBEDTLS_MODE_GCM +POLARSSL_MODE_NONE MBEDTLS_MODE_NONE +POLARSSL_MODE_OFB MBEDTLS_MODE_OFB +POLARSSL_MODE_STREAM MBEDTLS_MODE_STREAM +POLARSSL_MPI_MAX_BITS MBEDTLS_MPI_MAX_BITS +POLARSSL_MPI_MAX_BITS_SCALE100 MBEDTLS_MPI_MAX_BITS_SCALE100 +POLARSSL_MPI_MAX_LIMBS MBEDTLS_MPI_MAX_LIMBS +POLARSSL_MPI_MAX_SIZE MBEDTLS_MPI_MAX_SIZE +POLARSSL_MPI_RW_BUFFER_SIZE MBEDTLS_MPI_RW_BUFFER_SIZE +POLARSSL_MPI_WINDOW_SIZE MBEDTLS_MPI_WINDOW_SIZE +POLARSSL_NET_C MBEDTLS_NET_C +POLARSSL_NET_H MBEDTLS_NET_H +POLARSSL_NET_LISTEN_BACKLOG MBEDTLS_NET_LISTEN_BACKLOG +POLARSSL_NO_DEFAULT_ENTROPY_SOURCES MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES +POLARSSL_NO_PLATFORM_ENTROPY MBEDTLS_NO_PLATFORM_ENTROPY +POLARSSL_OID_C MBEDTLS_OID_C +POLARSSL_OID_H MBEDTLS_OID_H +POLARSSL_OPERATION_NONE MBEDTLS_OPERATION_NONE +POLARSSL_PADDING_NONE MBEDTLS_PADDING_NONE +POLARSSL_PADDING_ONE_AND_ZEROS MBEDTLS_PADDING_ONE_AND_ZEROS +POLARSSL_PADDING_PKCS7 MBEDTLS_PADDING_PKCS7 +POLARSSL_PADDING_ZEROS MBEDTLS_PADDING_ZEROS +POLARSSL_PADDING_ZEROS_AND_LEN MBEDTLS_PADDING_ZEROS_AND_LEN +POLARSSL_PADLOCK_C MBEDTLS_PADLOCK_C +POLARSSL_PADLOCK_H MBEDTLS_PADLOCK_H +POLARSSL_PBKDF2_C MBEDTLS_PBKDF2_C +POLARSSL_PBKDF2_H MBEDTLS_PBKDF2_H +POLARSSL_PEM_H MBEDTLS_PEM_H +POLARSSL_PEM_PARSE_C MBEDTLS_PEM_PARSE_C +POLARSSL_PEM_WRITE_C MBEDTLS_PEM_WRITE_C +POLARSSL_PKCS11_C MBEDTLS_PKCS11_C +POLARSSL_PKCS11_H MBEDTLS_PKCS11_H +POLARSSL_PKCS12_C MBEDTLS_PKCS12_C +POLARSSL_PKCS12_H MBEDTLS_PKCS12_H +POLARSSL_PKCS1_V15 MBEDTLS_PKCS1_V15 +POLARSSL_PKCS1_V21 MBEDTLS_PKCS1_V21 +POLARSSL_PKCS5_C MBEDTLS_PKCS5_C +POLARSSL_PKCS5_H MBEDTLS_PKCS5_H +POLARSSL_PK_C MBEDTLS_PK_C +POLARSSL_PK_DEBUG_ECP MBEDTLS_PK_DEBUG_ECP +POLARSSL_PK_DEBUG_MAX_ITEMS MBEDTLS_PK_DEBUG_MAX_ITEMS +POLARSSL_PK_DEBUG_MPI MBEDTLS_PK_DEBUG_MPI +POLARSSL_PK_DEBUG_NONE MBEDTLS_PK_DEBUG_NONE +POLARSSL_PK_ECDSA MBEDTLS_PK_ECDSA +POLARSSL_PK_ECKEY MBEDTLS_PK_ECKEY +POLARSSL_PK_ECKEY_DH MBEDTLS_PK_ECKEY_DH +POLARSSL_PK_H MBEDTLS_PK_H +POLARSSL_PK_NONE MBEDTLS_PK_NONE +POLARSSL_PK_PARSE_C MBEDTLS_PK_PARSE_C +POLARSSL_PK_PARSE_EC_EXTENDED MBEDTLS_PK_PARSE_EC_EXTENDED +POLARSSL_PK_RSA MBEDTLS_PK_RSA +POLARSSL_PK_RSASSA_PSS MBEDTLS_PK_RSASSA_PSS +POLARSSL_PK_RSA_ALT MBEDTLS_PK_RSA_ALT +POLARSSL_PK_WRAP_H MBEDTLS_PK_WRAP_H +POLARSSL_PK_WRITE_C MBEDTLS_PK_WRITE_C +POLARSSL_PLATFORM_C MBEDTLS_PLATFORM_C +POLARSSL_PLATFORM_EXIT_ALT MBEDTLS_PLATFORM_EXIT_ALT +POLARSSL_PLATFORM_EXIT_MACRO MBEDTLS_PLATFORM_EXIT_MACRO +POLARSSL_PLATFORM_FPRINTF_ALT MBEDTLS_PLATFORM_FPRINTF_ALT +POLARSSL_PLATFORM_FPRINTF_MACRO MBEDTLS_PLATFORM_FPRINTF_MACRO +POLARSSL_PLATFORM_FREE_MACRO MBEDTLS_PLATFORM_FREE_MACRO +POLARSSL_PLATFORM_H MBEDTLS_PLATFORM_H +POLARSSL_PLATFORM_MALLOC_MACRO MBEDTLS_PLATFORM_ALLOC_MACRO +POLARSSL_PLATFORM_MEMORY MBEDTLS_PLATFORM_MEMORY +POLARSSL_PLATFORM_NO_STD_FUNCTIONS MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +POLARSSL_PLATFORM_PRINTF_ALT MBEDTLS_PLATFORM_PRINTF_ALT +POLARSSL_PLATFORM_PRINTF_MACRO MBEDTLS_PLATFORM_PRINTF_MACRO +POLARSSL_PLATFORM_SNPRINTF_ALT MBEDTLS_PLATFORM_SNPRINTF_ALT +POLARSSL_PLATFORM_SNPRINTF_MACRO MBEDTLS_PLATFORM_SNPRINTF_MACRO +POLARSSL_PLATFORM_STD_EXIT MBEDTLS_PLATFORM_STD_EXIT +POLARSSL_PLATFORM_STD_FPRINTF MBEDTLS_PLATFORM_STD_FPRINTF +POLARSSL_PLATFORM_STD_FREE MBEDTLS_PLATFORM_STD_FREE +POLARSSL_PLATFORM_STD_MALLOC MBEDTLS_PLATFORM_STD_CALLOC +POLARSSL_PLATFORM_STD_MEM_HDR MBEDTLS_PLATFORM_STD_MEM_HDR +POLARSSL_PLATFORM_STD_PRINTF MBEDTLS_PLATFORM_STD_PRINTF +POLARSSL_PLATFORM_STD_SNPRINTF MBEDTLS_PLATFORM_STD_SNPRINTF +POLARSSL_PREMASTER_SIZE MBEDTLS_PREMASTER_SIZE +POLARSSL_PSK_MAX_LEN MBEDTLS_PSK_MAX_LEN +POLARSSL_REMOVE_ARC4_CIPHERSUITES MBEDTLS_REMOVE_ARC4_CIPHERSUITES +POLARSSL_RIPEMD160_ALT MBEDTLS_RIPEMD160_ALT +POLARSSL_RIPEMD160_C MBEDTLS_RIPEMD160_C +POLARSSL_RIPEMD160_H MBEDTLS_RIPEMD160_H +POLARSSL_RSA_C MBEDTLS_RSA_C +POLARSSL_RSA_H MBEDTLS_RSA_H +POLARSSL_RSA_NO_CRT MBEDTLS_RSA_NO_CRT +POLARSSL_SELF_TEST MBEDTLS_SELF_TEST +POLARSSL_SHA1_ALT MBEDTLS_SHA1_ALT +POLARSSL_SHA1_C MBEDTLS_SHA1_C +POLARSSL_SHA1_H MBEDTLS_SHA1_H +POLARSSL_SHA256_ALT MBEDTLS_SHA256_ALT +POLARSSL_SHA256_C MBEDTLS_SHA256_C +POLARSSL_SHA256_H MBEDTLS_SHA256_H +POLARSSL_SHA512_ALT MBEDTLS_SHA512_ALT +POLARSSL_SHA512_C MBEDTLS_SHA512_C +POLARSSL_SHA512_H MBEDTLS_SHA512_H +POLARSSL_SSL_AEAD_RANDOM_IV MBEDTLS_SSL_AEAD_RANDOM_IV +POLARSSL_SSL_ALERT_MESSAGES MBEDTLS_SSL_ALERT_MESSAGES +POLARSSL_SSL_ALPN MBEDTLS_SSL_ALPN +POLARSSL_SSL_CACHE_C MBEDTLS_SSL_CACHE_C +POLARSSL_SSL_CACHE_H MBEDTLS_SSL_CACHE_H +POLARSSL_SSL_CBC_RECORD_SPLITTING MBEDTLS_SSL_CBC_RECORD_SPLITTING +POLARSSL_SSL_CIPHERSUITES_H MBEDTLS_SSL_CIPHERSUITES_H +POLARSSL_SSL_CLI_C MBEDTLS_SSL_CLI_C +POLARSSL_SSL_COOKIE_C MBEDTLS_SSL_COOKIE_C +POLARSSL_SSL_COOKIE_H MBEDTLS_SSL_COOKIE_H +POLARSSL_SSL_COOKIE_TIMEOUT MBEDTLS_SSL_COOKIE_TIMEOUT +POLARSSL_SSL_DEBUG_ALL MBEDTLS_SSL_DEBUG_ALL +POLARSSL_SSL_DISABLE_RENEGOTIATION MBEDTLS_SSL_DISABLE_RENEGOTIATION +POLARSSL_SSL_DTLS_ANTI_REPLAY MBEDTLS_SSL_DTLS_ANTI_REPLAY +POLARSSL_SSL_DTLS_BADMAC_LIMIT MBEDTLS_SSL_DTLS_BADMAC_LIMIT +POLARSSL_SSL_DTLS_HELLO_VERIFY MBEDTLS_SSL_DTLS_HELLO_VERIFY +POLARSSL_SSL_ENCRYPT_THEN_MAC MBEDTLS_SSL_ENCRYPT_THEN_MAC +POLARSSL_SSL_EXTENDED_MASTER_SECRET MBEDTLS_SSL_EXTENDED_MASTER_SECRET +POLARSSL_SSL_FALLBACK_SCSV MBEDTLS_SSL_FALLBACK_SCSV +POLARSSL_SSL_H MBEDTLS_SSL_H +POLARSSL_SSL_HW_RECORD_ACCEL MBEDTLS_SSL_HW_RECORD_ACCEL +POLARSSL_SSL_MAX_FRAGMENT_LENGTH MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +POLARSSL_SSL_PROTO_DTLS MBEDTLS_SSL_PROTO_DTLS +POLARSSL_SSL_PROTO_SSL3 MBEDTLS_SSL_PROTO_SSL3 +POLARSSL_SSL_PROTO_TLS1 MBEDTLS_SSL_PROTO_TLS1 +POLARSSL_SSL_PROTO_TLS1_1 MBEDTLS_SSL_PROTO_TLS1_1 +POLARSSL_SSL_PROTO_TLS1_2 MBEDTLS_SSL_PROTO_TLS1_2 +POLARSSL_SSL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION +POLARSSL_SSL_SERVER_NAME_INDICATION MBEDTLS_SSL_SERVER_NAME_INDICATION +POLARSSL_SSL_SESSION_TICKETS MBEDTLS_SSL_SESSION_TICKETS +POLARSSL_SSL_SRV_C MBEDTLS_SSL_SRV_C +POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE +POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO +POLARSSL_SSL_TLS_C MBEDTLS_SSL_TLS_C +POLARSSL_SSL_TRUNCATED_HMAC MBEDTLS_SSL_TRUNCATED_HMAC +POLARSSL_THREADING_ALT MBEDTLS_THREADING_ALT +POLARSSL_THREADING_C MBEDTLS_THREADING_C +POLARSSL_THREADING_H MBEDTLS_THREADING_H +POLARSSL_THREADING_IMPL MBEDTLS_THREADING_IMPL +POLARSSL_THREADING_PTHREAD MBEDTLS_THREADING_PTHREAD +POLARSSL_TIMING_ALT MBEDTLS_TIMING_ALT +POLARSSL_TIMING_C MBEDTLS_TIMING_C +POLARSSL_TIMING_H MBEDTLS_TIMING_H +POLARSSL_VERSION_C MBEDTLS_VERSION_C +POLARSSL_VERSION_FEATURES MBEDTLS_VERSION_FEATURES +POLARSSL_VERSION_H MBEDTLS_VERSION_H +POLARSSL_VERSION_MAJOR MBEDTLS_VERSION_MAJOR +POLARSSL_VERSION_MINOR MBEDTLS_VERSION_MINOR +POLARSSL_VERSION_NUMBER MBEDTLS_VERSION_NUMBER +POLARSSL_VERSION_PATCH MBEDTLS_VERSION_PATCH +POLARSSL_VERSION_STRING MBEDTLS_VERSION_STRING +POLARSSL_VERSION_STRING_FULL MBEDTLS_VERSION_STRING_FULL +POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3 MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 +POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION +POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE +POLARSSL_X509_CHECK_KEY_USAGE MBEDTLS_X509_CHECK_KEY_USAGE +POLARSSL_X509_CREATE_C MBEDTLS_X509_CREATE_C +POLARSSL_X509_CRL_H MBEDTLS_X509_CRL_H +POLARSSL_X509_CRL_PARSE_C MBEDTLS_X509_CRL_PARSE_C +POLARSSL_X509_CRT_H MBEDTLS_X509_CRT_H +POLARSSL_X509_CRT_PARSE_C MBEDTLS_X509_CRT_PARSE_C +POLARSSL_X509_CRT_WRITE_C MBEDTLS_X509_CRT_WRITE_C +POLARSSL_X509_CSR_H MBEDTLS_X509_CSR_H +POLARSSL_X509_CSR_PARSE_C MBEDTLS_X509_CSR_PARSE_C +POLARSSL_X509_CSR_WRITE_C MBEDTLS_X509_CSR_WRITE_C +POLARSSL_X509_H MBEDTLS_X509_H +POLARSSL_X509_MAX_INTERMEDIATE_CA MBEDTLS_X509_MAX_INTERMEDIATE_CA +POLARSSL_X509_RSASSA_PSS_SUPPORT MBEDTLS_X509_RSASSA_PSS_SUPPORT +POLARSSL_X509_USE_C MBEDTLS_X509_USE_C +POLARSSL_XTEA_ALT MBEDTLS_XTEA_ALT +POLARSSL_XTEA_C MBEDTLS_XTEA_C +POLARSSL_XTEA_H MBEDTLS_XTEA_H +POLARSSL_ZLIB_SUPPORT MBEDTLS_ZLIB_SUPPORT +RSA_CRYPT MBEDTLS_RSA_CRYPT +RSA_PKCS_V15 MBEDTLS_RSA_PKCS_V15 +RSA_PKCS_V21 MBEDTLS_RSA_PKCS_V21 +RSA_PRIVATE MBEDTLS_RSA_PRIVATE +RSA_PUBLIC MBEDTLS_RSA_PUBLIC +RSA_SALT_LEN_ANY MBEDTLS_RSA_SALT_LEN_ANY +RSA_SIGN MBEDTLS_RSA_SIGN +SSL_ALERT_LEVEL_FATAL MBEDTLS_SSL_ALERT_LEVEL_FATAL +SSL_ALERT_LEVEL_WARNING MBEDTLS_SSL_ALERT_LEVEL_WARNING +SSL_ALERT_MSG_ACCESS_DENIED MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED +SSL_ALERT_MSG_BAD_CERT MBEDTLS_SSL_ALERT_MSG_BAD_CERT +SSL_ALERT_MSG_BAD_RECORD_MAC MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC +SSL_ALERT_MSG_CERT_EXPIRED MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED +SSL_ALERT_MSG_CERT_REVOKED MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED +SSL_ALERT_MSG_CERT_UNKNOWN MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN +SSL_ALERT_MSG_CLOSE_NOTIFY MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY +SSL_ALERT_MSG_DECODE_ERROR MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR +SSL_ALERT_MSG_DECOMPRESSION_FAILURE MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE +SSL_ALERT_MSG_DECRYPTION_FAILED MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED +SSL_ALERT_MSG_DECRYPT_ERROR MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR +SSL_ALERT_MSG_EXPORT_RESTRICTION MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION +SSL_ALERT_MSG_HANDSHAKE_FAILURE MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE +SSL_ALERT_MSG_ILLEGAL_PARAMETER MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER +SSL_ALERT_MSG_INAPROPRIATE_FALLBACK MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK +SSL_ALERT_MSG_INSUFFICIENT_SECURITY MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY +SSL_ALERT_MSG_INTERNAL_ERROR MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR +SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL +SSL_ALERT_MSG_NO_CERT MBEDTLS_SSL_ALERT_MSG_NO_CERT +SSL_ALERT_MSG_NO_RENEGOTIATION MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION +SSL_ALERT_MSG_PROTOCOL_VERSION MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION +SSL_ALERT_MSG_RECORD_OVERFLOW MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW +SSL_ALERT_MSG_UNEXPECTED_MESSAGE MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE +SSL_ALERT_MSG_UNKNOWN_CA MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA +SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY +SSL_ALERT_MSG_UNRECOGNIZED_NAME MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME +SSL_ALERT_MSG_UNSUPPORTED_CERT MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT +SSL_ALERT_MSG_UNSUPPORTED_EXT MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT +SSL_ALERT_MSG_USER_CANCELED MBEDTLS_SSL_ALERT_MSG_USER_CANCELED +SSL_ANTI_REPLAY_DISABLED MBEDTLS_SSL_ANTI_REPLAY_DISABLED +SSL_ANTI_REPLAY_ENABLED MBEDTLS_SSL_ANTI_REPLAY_ENABLED +SSL_ARC4_DISABLED MBEDTLS_SSL_ARC4_DISABLED +SSL_ARC4_ENABLED MBEDTLS_SSL_ARC4_ENABLED +SSL_BUFFER_LEN MBEDTLS_SSL_BUFFER_LEN +SSL_CACHE_DEFAULT_MAX_ENTRIES MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES +SSL_CACHE_DEFAULT_TIMEOUT MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT +SSL_CBC_RECORD_SPLITTING_DISABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED +SSL_CBC_RECORD_SPLITTING_ENABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED +SSL_CERTIFICATE_REQUEST MBEDTLS_SSL_CERTIFICATE_REQUEST +SSL_CERTIFICATE_VERIFY MBEDTLS_SSL_CERTIFICATE_VERIFY +SSL_CERT_TYPE_ECDSA_SIGN MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN +SSL_CERT_TYPE_RSA_SIGN MBEDTLS_SSL_CERT_TYPE_RSA_SIGN +SSL_CHANNEL_INBOUND MBEDTLS_SSL_CHANNEL_INBOUND +SSL_CHANNEL_OUTBOUND MBEDTLS_SSL_CHANNEL_OUTBOUND +SSL_CIPHERSUITES MBEDTLS_SSL_CIPHERSUITES +SSL_CLIENT_CERTIFICATE MBEDTLS_SSL_CLIENT_CERTIFICATE +SSL_CLIENT_CHANGE_CIPHER_SPEC MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC +SSL_CLIENT_FINISHED MBEDTLS_SSL_CLIENT_FINISHED +SSL_CLIENT_HELLO MBEDTLS_SSL_CLIENT_HELLO +SSL_CLIENT_KEY_EXCHANGE MBEDTLS_SSL_CLIENT_KEY_EXCHANGE +SSL_COMPRESSION_ADD MBEDTLS_SSL_COMPRESSION_ADD +SSL_COMPRESS_DEFLATE MBEDTLS_SSL_COMPRESS_DEFLATE +SSL_COMPRESS_NULL MBEDTLS_SSL_COMPRESS_NULL +SSL_DEBUG_BUF MBEDTLS_SSL_DEBUG_BUF +SSL_DEBUG_CRT MBEDTLS_SSL_DEBUG_CRT +SSL_DEBUG_ECP MBEDTLS_SSL_DEBUG_ECP +SSL_DEBUG_MPI MBEDTLS_SSL_DEBUG_MPI +SSL_DEBUG_MSG MBEDTLS_SSL_DEBUG_MSG +SSL_DEBUG_RET MBEDTLS_SSL_DEBUG_RET +SSL_DEFAULT_TICKET_LIFETIME MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME +SSL_DTLS_TIMEOUT_DFL_MAX MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX +SSL_DTLS_TIMEOUT_DFL_MIN MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN +SSL_EMPTY_RENEGOTIATION_INFO MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO +SSL_ETM_DISABLED MBEDTLS_SSL_ETM_DISABLED +SSL_ETM_ENABLED MBEDTLS_SSL_ETM_ENABLED +SSL_EXTENDED_MS_DISABLED MBEDTLS_SSL_EXTENDED_MS_DISABLED +SSL_EXTENDED_MS_ENABLED MBEDTLS_SSL_EXTENDED_MS_ENABLED +SSL_FALLBACK_SCSV MBEDTLS_SSL_FALLBACK_SCSV +SSL_FLUSH_BUFFERS MBEDTLS_SSL_FLUSH_BUFFERS +SSL_HANDSHAKE_OVER MBEDTLS_SSL_HANDSHAKE_OVER +SSL_HANDSHAKE_WRAPUP MBEDTLS_SSL_HANDSHAKE_WRAPUP +SSL_HASH_MD5 MBEDTLS_SSL_HASH_MD5 +SSL_HASH_NONE MBEDTLS_SSL_HASH_NONE +SSL_HASH_SHA1 MBEDTLS_SSL_HASH_SHA1 +SSL_HASH_SHA224 MBEDTLS_SSL_HASH_SHA224 +SSL_HASH_SHA256 MBEDTLS_SSL_HASH_SHA256 +SSL_HASH_SHA384 MBEDTLS_SSL_HASH_SHA384 +SSL_HASH_SHA512 MBEDTLS_SSL_HASH_SHA512 +SSL_HELLO_REQUEST MBEDTLS_SSL_HELLO_REQUEST +SSL_HS_CERTIFICATE MBEDTLS_SSL_HS_CERTIFICATE +SSL_HS_CERTIFICATE_REQUEST MBEDTLS_SSL_HS_CERTIFICATE_REQUEST +SSL_HS_CERTIFICATE_VERIFY MBEDTLS_SSL_HS_CERTIFICATE_VERIFY +SSL_HS_CLIENT_HELLO MBEDTLS_SSL_HS_CLIENT_HELLO +SSL_HS_CLIENT_KEY_EXCHANGE MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE +SSL_HS_FINISHED MBEDTLS_SSL_HS_FINISHED +SSL_HS_HELLO_REQUEST MBEDTLS_SSL_HS_HELLO_REQUEST +SSL_HS_HELLO_VERIFY_REQUEST MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST +SSL_HS_NEW_SESSION_TICKET MBEDTLS_SSL_HS_NEW_SESSION_TICKET +SSL_HS_SERVER_HELLO MBEDTLS_SSL_HS_SERVER_HELLO +SSL_HS_SERVER_HELLO_DONE MBEDTLS_SSL_HS_SERVER_HELLO_DONE +SSL_HS_SERVER_KEY_EXCHANGE MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE +SSL_INITIAL_HANDSHAKE MBEDTLS_SSL_INITIAL_HANDSHAKE +SSL_IS_CLIENT MBEDTLS_SSL_IS_CLIENT +SSL_IS_FALLBACK MBEDTLS_SSL_IS_FALLBACK +SSL_IS_NOT_FALLBACK MBEDTLS_SSL_IS_NOT_FALLBACK +SSL_IS_SERVER MBEDTLS_SSL_IS_SERVER +SSL_LEGACY_ALLOW_RENEGOTIATION MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION +SSL_LEGACY_BREAK_HANDSHAKE MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE +SSL_LEGACY_NO_RENEGOTIATION MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION +SSL_LEGACY_RENEGOTIATION MBEDTLS_SSL_LEGACY_RENEGOTIATION +SSL_MAC_ADD MBEDTLS_SSL_MAC_ADD +SSL_MAJOR_VERSION_3 MBEDTLS_SSL_MAJOR_VERSION_3 +SSL_MAX_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN +SSL_MAX_FRAG_LEN_1024 MBEDTLS_SSL_MAX_FRAG_LEN_1024 +SSL_MAX_FRAG_LEN_2048 MBEDTLS_SSL_MAX_FRAG_LEN_2048 +SSL_MAX_FRAG_LEN_4096 MBEDTLS_SSL_MAX_FRAG_LEN_4096 +SSL_MAX_FRAG_LEN_512 MBEDTLS_SSL_MAX_FRAG_LEN_512 +SSL_MAX_FRAG_LEN_INVALID MBEDTLS_SSL_MAX_FRAG_LEN_INVALID +SSL_MAX_FRAG_LEN_NONE MBEDTLS_SSL_MAX_FRAG_LEN_NONE +SSL_MAX_MAJOR_VERSION MBEDTLS_SSL_MAX_MAJOR_VERSION +SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MAX_MINOR_VERSION +SSL_MINOR_VERSION_0 MBEDTLS_SSL_MINOR_VERSION_0 +SSL_MINOR_VERSION_1 MBEDTLS_SSL_MINOR_VERSION_1 +SSL_MINOR_VERSION_2 MBEDTLS_SSL_MINOR_VERSION_2 +SSL_MINOR_VERSION_3 MBEDTLS_SSL_MINOR_VERSION_3 +SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MIN_MAJOR_VERSION +SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MIN_MINOR_VERSION +SSL_MSG_ALERT MBEDTLS_SSL_MSG_ALERT +SSL_MSG_APPLICATION_DATA MBEDTLS_SSL_MSG_APPLICATION_DATA +SSL_MSG_CHANGE_CIPHER_SPEC MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC +SSL_MSG_HANDSHAKE MBEDTLS_SSL_MSG_HANDSHAKE +SSL_PADDING_ADD MBEDTLS_SSL_PADDING_ADD +SSL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION +SSL_RENEGOTIATION_DISABLED MBEDTLS_SSL_RENEGOTIATION_DISABLED +SSL_RENEGOTIATION_DONE MBEDTLS_SSL_RENEGOTIATION_DONE +SSL_RENEGOTIATION_ENABLED MBEDTLS_SSL_RENEGOTIATION_ENABLED +SSL_RENEGOTIATION_NOT_ENFORCED MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED +SSL_RENEGOTIATION_PENDING MBEDTLS_SSL_RENEGOTIATION_PENDING +SSL_RENEGO_MAX_RECORDS_DEFAULT MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT +SSL_RETRANS_FINISHED MBEDTLS_SSL_RETRANS_FINISHED +SSL_RETRANS_PREPARING MBEDTLS_SSL_RETRANS_PREPARING +SSL_RETRANS_SENDING MBEDTLS_SSL_RETRANS_SENDING +SSL_RETRANS_WAITING MBEDTLS_SSL_RETRANS_WAITING +SSL_SECURE_RENEGOTIATION MBEDTLS_SSL_SECURE_RENEGOTIATION +SSL_SERVER_CERTIFICATE MBEDTLS_SSL_SERVER_CERTIFICATE +SSL_SERVER_CHANGE_CIPHER_SPEC MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC +SSL_SERVER_FINISHED MBEDTLS_SSL_SERVER_FINISHED +SSL_SERVER_HELLO MBEDTLS_SSL_SERVER_HELLO +SSL_SERVER_HELLO_DONE MBEDTLS_SSL_SERVER_HELLO_DONE +SSL_SERVER_HELLO_VERIFY_REQUEST_SENT MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT +SSL_SERVER_KEY_EXCHANGE MBEDTLS_SSL_SERVER_KEY_EXCHANGE +SSL_SERVER_NEW_SESSION_TICKET MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET +SSL_SESSION_TICKETS_DISABLED MBEDTLS_SSL_SESSION_TICKETS_DISABLED +SSL_SESSION_TICKETS_ENABLED MBEDTLS_SSL_SESSION_TICKETS_ENABLED +SSL_SIG_ANON MBEDTLS_SSL_SIG_ANON +SSL_SIG_ECDSA MBEDTLS_SSL_SIG_ECDSA +SSL_SIG_RSA MBEDTLS_SSL_SIG_RSA +SSL_TRANSPORT_DATAGRAM MBEDTLS_SSL_TRANSPORT_DATAGRAM +SSL_TRANSPORT_STREAM MBEDTLS_SSL_TRANSPORT_STREAM +SSL_TRUNCATED_HMAC_LEN MBEDTLS_SSL_TRUNCATED_HMAC_LEN +SSL_TRUNC_HMAC_DISABLED MBEDTLS_SSL_TRUNC_HMAC_DISABLED +SSL_TRUNC_HMAC_ENABLED MBEDTLS_SSL_TRUNC_HMAC_ENABLED +SSL_VERIFY_DATA_MAX_LEN MBEDTLS_SSL_VERIFY_DATA_MAX_LEN +SSL_VERIFY_NONE MBEDTLS_SSL_VERIFY_NONE +SSL_VERIFY_OPTIONAL MBEDTLS_SSL_VERIFY_OPTIONAL +SSL_VERIFY_REQUIRED MBEDTLS_SSL_VERIFY_REQUIRED +TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA +TLS_DHE_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA +TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 +TLS_DHE_PSK_WITH_AES_128_CCM MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM +TLS_DHE_PSK_WITH_AES_128_CCM_8 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8 +TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 +TLS_DHE_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA +TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 +TLS_DHE_PSK_WITH_AES_256_CCM MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM +TLS_DHE_PSK_WITH_AES_256_CCM_8 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8 +TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 +TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 +TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 +TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 +TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 +TLS_DHE_PSK_WITH_NULL_SHA MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA +TLS_DHE_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 +TLS_DHE_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 +TLS_DHE_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA +TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA +TLS_DHE_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA +TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 +TLS_DHE_RSA_WITH_AES_128_CCM MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM +TLS_DHE_RSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8 +TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 +TLS_DHE_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA +TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 +TLS_DHE_RSA_WITH_AES_256_CCM MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM +TLS_DHE_RSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8 +TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 +TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA +TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 +TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 +TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA +TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 +TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 +TLS_DHE_RSA_WITH_DES_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA +TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA +TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA +TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 +TLS_ECDHE_ECDSA_WITH_AES_128_CCM MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM +TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 +TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 +TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA +TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 +TLS_ECDHE_ECDSA_WITH_AES_256_CCM MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM +TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 +TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 +TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 +TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 +TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 +TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 +TLS_ECDHE_ECDSA_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA +TLS_ECDHE_ECDSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA +TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA +TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA +TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 +TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA +TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 +TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 +TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 +TLS_ECDHE_PSK_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA +TLS_ECDHE_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 +TLS_ECDHE_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 +TLS_ECDHE_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA +TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA +TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA +TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 +TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 +TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA +TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 +TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 +TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 +TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 +TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 +TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 +TLS_ECDHE_RSA_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA +TLS_ECDHE_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA +TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA +TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA +TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 +TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 +TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA +TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 +TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 +TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 +TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 +TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 +TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 +TLS_ECDH_ECDSA_WITH_NULL_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA +TLS_ECDH_ECDSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA +TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA +TLS_ECDH_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA +TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 +TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 +TLS_ECDH_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA +TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 +TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 +TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 +TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 +TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 +TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 +TLS_ECDH_RSA_WITH_NULL_SHA MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA +TLS_ECDH_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA +TLS_EXT_ALPN MBEDTLS_TLS_EXT_ALPN +TLS_EXT_ENCRYPT_THEN_MAC MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC +TLS_EXT_EXTENDED_MASTER_SECRET MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET +TLS_EXT_MAX_FRAGMENT_LENGTH MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH +TLS_EXT_RENEGOTIATION_INFO MBEDTLS_TLS_EXT_RENEGOTIATION_INFO +TLS_EXT_SERVERNAME MBEDTLS_TLS_EXT_SERVERNAME +TLS_EXT_SERVERNAME_HOSTNAME MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME +TLS_EXT_SESSION_TICKET MBEDTLS_TLS_EXT_SESSION_TICKET +TLS_EXT_SIG_ALG MBEDTLS_TLS_EXT_SIG_ALG +TLS_EXT_SUPPORTED_ELLIPTIC_CURVES MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES +TLS_EXT_SUPPORTED_POINT_FORMATS MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS +TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT +TLS_EXT_TRUNCATED_HMAC MBEDTLS_TLS_EXT_TRUNCATED_HMAC +TLS_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA +TLS_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA +TLS_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 +TLS_PSK_WITH_AES_128_CCM MBEDTLS_TLS_PSK_WITH_AES_128_CCM +TLS_PSK_WITH_AES_128_CCM_8 MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 +TLS_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 +TLS_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA +TLS_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 +TLS_PSK_WITH_AES_256_CCM MBEDTLS_TLS_PSK_WITH_AES_256_CCM +TLS_PSK_WITH_AES_256_CCM_8 MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8 +TLS_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 +TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 +TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 +TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 +TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 +TLS_PSK_WITH_NULL_SHA MBEDTLS_TLS_PSK_WITH_NULL_SHA +TLS_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_PSK_WITH_NULL_SHA256 +TLS_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_PSK_WITH_NULL_SHA384 +TLS_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_PSK_WITH_RC4_128_SHA +TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA +TLS_RSA_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA +TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 +TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 +TLS_RSA_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA +TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 +TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 +TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 +TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 +TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 +TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 +TLS_RSA_PSK_WITH_NULL_SHA MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA +TLS_RSA_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 +TLS_RSA_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 +TLS_RSA_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA +TLS_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA +TLS_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA +TLS_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 +TLS_RSA_WITH_AES_128_CCM MBEDTLS_TLS_RSA_WITH_AES_128_CCM +TLS_RSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8 +TLS_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 +TLS_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA +TLS_RSA_WITH_AES_256_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 +TLS_RSA_WITH_AES_256_CCM MBEDTLS_TLS_RSA_WITH_AES_256_CCM +TLS_RSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8 +TLS_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 +TLS_RSA_WITH_CAMELLIA_128_CBC_SHA MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA +TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 +TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 +TLS_RSA_WITH_CAMELLIA_256_CBC_SHA MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA +TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 +TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 +TLS_RSA_WITH_DES_CBC_SHA MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA +TLS_RSA_WITH_NULL_MD5 MBEDTLS_TLS_RSA_WITH_NULL_MD5 +TLS_RSA_WITH_NULL_SHA MBEDTLS_TLS_RSA_WITH_NULL_SHA +TLS_RSA_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_WITH_NULL_SHA256 +TLS_RSA_WITH_RC4_128_MD5 MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 +TLS_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_WITH_RC4_128_SHA +X509_CRT_VERSION_1 MBEDTLS_X509_CRT_VERSION_1 +X509_CRT_VERSION_2 MBEDTLS_X509_CRT_VERSION_2 +X509_CRT_VERSION_3 MBEDTLS_X509_CRT_VERSION_3 +X509_FORMAT_DER MBEDTLS_X509_FORMAT_DER +X509_FORMAT_PEM MBEDTLS_X509_FORMAT_PEM +X509_MAX_DN_NAME_SIZE MBEDTLS_X509_MAX_DN_NAME_SIZE +X509_RFC5280_MAX_SERIAL_LEN MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN +X509_RFC5280_UTC_TIME_LEN MBEDTLS_X509_RFC5280_UTC_TIME_LEN +XTEA_DECRYPT MBEDTLS_XTEA_DECRYPT +XTEA_ENCRYPT MBEDTLS_XTEA_ENCRYPT +_asn1_bitstring mbedtls_asn1_bitstring +_asn1_buf mbedtls_asn1_buf +_asn1_named_data mbedtls_asn1_named_data +_asn1_sequence mbedtls_asn1_sequence +_ssl_cache_context mbedtls_ssl_cache_context +_ssl_cache_entry mbedtls_ssl_cache_entry +_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t +_ssl_context mbedtls_ssl_context +_ssl_flight_item mbedtls_ssl_flight_item +_ssl_handshake_params mbedtls_ssl_handshake_params +_ssl_key_cert mbedtls_ssl_key_cert +_ssl_premaster_secret mbedtls_ssl_premaster_secret +_ssl_session mbedtls_ssl_session +_ssl_ticket_keys mbedtls_ssl_ticket_keys +_ssl_transform mbedtls_ssl_transform +_x509_crl mbedtls_x509_crl +_x509_crl_entry mbedtls_x509_crl_entry +_x509_crt mbedtls_x509_crt +_x509_csr mbedtls_x509_csr +_x509_time mbedtls_x509_time +_x509write_cert mbedtls_x509write_cert +_x509write_csr mbedtls_x509write_csr +aes_context mbedtls_aes_context +aes_crypt_cbc mbedtls_aes_crypt_cbc +aes_crypt_cfb128 mbedtls_aes_crypt_cfb128 +aes_crypt_cfb8 mbedtls_aes_crypt_cfb8 +aes_crypt_ctr mbedtls_aes_crypt_ctr +aes_crypt_ecb mbedtls_aes_crypt_ecb +aes_free mbedtls_aes_free +aes_init mbedtls_aes_init +aes_self_test mbedtls_aes_self_test +aes_setkey_dec mbedtls_aes_setkey_dec +aes_setkey_enc mbedtls_aes_setkey_enc +aesni_crypt_ecb mbedtls_aesni_crypt_ecb +aesni_gcm_mult mbedtls_aesni_gcm_mult +aesni_inverse_key mbedtls_aesni_inverse_key +aesni_setkey_enc mbedtls_aesni_setkey_enc +aesni_supports mbedtls_aesni_has_support +alarmed mbedtls_timing_alarmed +arc4_context mbedtls_arc4_context +arc4_crypt mbedtls_arc4_crypt +arc4_free mbedtls_arc4_free +arc4_init mbedtls_arc4_init +arc4_self_test mbedtls_arc4_self_test +arc4_setup mbedtls_arc4_setup +asn1_bitstring mbedtls_asn1_bitstring +asn1_buf mbedtls_asn1_buf +asn1_find_named_data mbedtls_asn1_find_named_data +asn1_free_named_data mbedtls_asn1_free_named_data +asn1_free_named_data_list mbedtls_asn1_free_named_data_list +asn1_get_alg mbedtls_asn1_get_alg +asn1_get_alg_null mbedtls_asn1_get_alg_null +asn1_get_bitstring mbedtls_asn1_get_bitstring +asn1_get_bitstring_null mbedtls_asn1_get_bitstring_null +asn1_get_bool mbedtls_asn1_get_bool +asn1_get_int mbedtls_asn1_get_int +asn1_get_len mbedtls_asn1_get_len +asn1_get_mpi mbedtls_asn1_get_mpi +asn1_get_sequence_of mbedtls_asn1_get_sequence_of +asn1_get_tag mbedtls_asn1_get_tag +asn1_named_data mbedtls_asn1_named_data +asn1_sequence mbedtls_asn1_sequence +asn1_store_named_data mbedtls_asn1_store_named_data +asn1_write_algorithm_identifier mbedtls_asn1_write_algorithm_identifier +asn1_write_bitstring mbedtls_asn1_write_bitstring +asn1_write_bool mbedtls_asn1_write_bool +asn1_write_ia5_string mbedtls_asn1_write_ia5_string +asn1_write_int mbedtls_asn1_write_int +asn1_write_len mbedtls_asn1_write_len +asn1_write_mpi mbedtls_asn1_write_mpi +asn1_write_null mbedtls_asn1_write_null +asn1_write_octet_string mbedtls_asn1_write_octet_string +asn1_write_oid mbedtls_asn1_write_oid +asn1_write_printable_string mbedtls_asn1_write_printable_string +asn1_write_raw_buffer mbedtls_asn1_write_raw_buffer +asn1_write_tag mbedtls_asn1_write_tag +base64_decode mbedtls_base64_decode +base64_encode mbedtls_base64_encode +base64_self_test mbedtls_base64_self_test +blowfish_context mbedtls_blowfish_context +blowfish_crypt_cbc mbedtls_blowfish_crypt_cbc +blowfish_crypt_cfb64 mbedtls_blowfish_crypt_cfb64 +blowfish_crypt_ctr mbedtls_blowfish_crypt_ctr +blowfish_crypt_ecb mbedtls_blowfish_crypt_ecb +blowfish_free mbedtls_blowfish_free +blowfish_init mbedtls_blowfish_init +blowfish_setkey mbedtls_blowfish_setkey +camellia_context mbedtls_camellia_context +camellia_crypt_cbc mbedtls_camellia_crypt_cbc +camellia_crypt_cfb128 mbedtls_camellia_crypt_cfb128 +camellia_crypt_ctr mbedtls_camellia_crypt_ctr +camellia_crypt_ecb mbedtls_camellia_crypt_ecb +camellia_free mbedtls_camellia_free +camellia_init mbedtls_camellia_init +camellia_self_test mbedtls_camellia_self_test +camellia_setkey_dec mbedtls_camellia_setkey_dec +camellia_setkey_enc mbedtls_camellia_setkey_enc +ccm_auth_decrypt mbedtls_ccm_auth_decrypt +ccm_context mbedtls_ccm_context +ccm_encrypt_and_tag mbedtls_ccm_encrypt_and_tag +ccm_free mbedtls_ccm_free +ccm_init mbedtls_ccm_init +ccm_self_test mbedtls_ccm_self_test +cipher_auth_decrypt mbedtls_cipher_auth_decrypt +cipher_auth_encrypt mbedtls_cipher_auth_encrypt +cipher_base_t mbedtls_cipher_base_t +cipher_check_tag mbedtls_cipher_check_tag +cipher_context_t mbedtls_cipher_context_t +cipher_crypt mbedtls_cipher_crypt +cipher_definition_t mbedtls_cipher_definition_t +cipher_definitions mbedtls_cipher_definitions +cipher_finish mbedtls_cipher_finish +cipher_free mbedtls_cipher_free +cipher_free_ctx mbedtls_cipher_free_ctx +cipher_get_block_size mbedtls_cipher_get_block_size +cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode +cipher_get_iv_size mbedtls_cipher_get_iv_size +cipher_get_key_size mbedtls_cipher_get_key_bitlen +cipher_get_name mbedtls_cipher_get_name +cipher_get_operation mbedtls_cipher_get_operation +cipher_get_type mbedtls_cipher_get_type +cipher_id_t mbedtls_cipher_id_t +cipher_info_from_string mbedtls_cipher_info_from_string +cipher_info_from_type mbedtls_cipher_info_from_type +cipher_info_from_values mbedtls_cipher_info_from_values +cipher_info_t mbedtls_cipher_info_t +cipher_init mbedtls_cipher_init +cipher_init_ctx mbedtls_cipher_setup +cipher_list mbedtls_cipher_list +cipher_mode_t mbedtls_cipher_mode_t +cipher_padding_t mbedtls_cipher_padding_t +cipher_reset mbedtls_cipher_reset +cipher_self_test mbedtls_cipher_self_test +cipher_set_iv mbedtls_cipher_set_iv +cipher_set_padding_mode mbedtls_cipher_set_padding_mode +cipher_setkey mbedtls_cipher_setkey +cipher_type_t mbedtls_cipher_type_t +cipher_update mbedtls_cipher_update +cipher_update_ad mbedtls_cipher_update_ad +cipher_write_tag mbedtls_cipher_write_tag +ctr_drbg_context mbedtls_ctr_drbg_context +ctr_drbg_free mbedtls_ctr_drbg_free +ctr_drbg_init mbedtls_ctr_drbg_init +ctr_drbg_init_entropy_len mbedtls_ctr_drbg_init_entropy_len +ctr_drbg_random mbedtls_ctr_drbg_random +ctr_drbg_random_with_add mbedtls_ctr_drbg_random_with_add +ctr_drbg_reseed mbedtls_ctr_drbg_reseed +ctr_drbg_self_test mbedtls_ctr_drbg_self_test +ctr_drbg_set_entropy_len mbedtls_ctr_drbg_set_entropy_len +ctr_drbg_set_prediction_resistance mbedtls_ctr_drbg_set_prediction_resistance +ctr_drbg_set_reseed_interval mbedtls_ctr_drbg_set_reseed_interval +ctr_drbg_update mbedtls_ctr_drbg_update +ctr_drbg_update_seed_file mbedtls_ctr_drbg_update_seed_file +ctr_drbg_write_seed_file mbedtls_ctr_drbg_write_seed_file +debug_fmt mbedtls_debug_fmt +debug_print_buf mbedtls_debug_print_buf +debug_print_crt mbedtls_debug_print_crt +debug_print_ecp mbedtls_debug_print_ecp +debug_print_mpi mbedtls_debug_print_mpi +debug_print_msg mbedtls_debug_print_msg +debug_print_ret mbedtls_debug_print_ret +debug_set_log_mode mbedtls_debug_set_log_mode +debug_set_threshold mbedtls_debug_set_threshold +des3_context mbedtls_des3_context +des3_crypt_cbc mbedtls_des3_crypt_cbc +des3_crypt_ecb mbedtls_des3_crypt_ecb +des3_free mbedtls_des3_free +des3_init mbedtls_des3_init +des3_set2key_dec mbedtls_des3_set2key_dec +des3_set2key_enc mbedtls_des3_set2key_enc +des3_set3key_dec mbedtls_des3_set3key_dec +des3_set3key_enc mbedtls_des3_set3key_enc +des_context mbedtls_des_context +des_crypt_cbc mbedtls_des_crypt_cbc +des_crypt_ecb mbedtls_des_crypt_ecb +des_free mbedtls_des_free +des_init mbedtls_des_init +des_key_check_key_parity mbedtls_des_key_check_key_parity +des_key_check_weak mbedtls_des_key_check_weak +des_key_set_parity mbedtls_des_key_set_parity +des_self_test mbedtls_des_self_test +des_setkey_dec mbedtls_des_setkey_dec +des_setkey_enc mbedtls_des_setkey_enc +dhm_calc_secret mbedtls_dhm_calc_secret +dhm_context mbedtls_dhm_context +dhm_free mbedtls_dhm_free +dhm_init mbedtls_dhm_init +dhm_make_params mbedtls_dhm_make_params +dhm_make_public mbedtls_dhm_make_public +dhm_parse_dhm mbedtls_dhm_parse_dhm +dhm_parse_dhmfile mbedtls_dhm_parse_dhmfile +dhm_read_params mbedtls_dhm_read_params +dhm_read_public mbedtls_dhm_read_public +dhm_self_test mbedtls_dhm_self_test +ecdh_calc_secret mbedtls_ecdh_calc_secret +ecdh_compute_shared mbedtls_ecdh_compute_shared +ecdh_context mbedtls_ecdh_context +ecdh_free mbedtls_ecdh_free +ecdh_gen_public mbedtls_ecdh_gen_public +ecdh_get_params mbedtls_ecdh_get_params +ecdh_init mbedtls_ecdh_init +ecdh_make_params mbedtls_ecdh_make_params +ecdh_make_public mbedtls_ecdh_make_public +ecdh_read_params mbedtls_ecdh_read_params +ecdh_read_public mbedtls_ecdh_read_public +ecdh_self_test mbedtls_ecdh_self_test +ecdh_side mbedtls_ecdh_side +ecdsa_context mbedtls_ecdsa_context +ecdsa_free mbedtls_ecdsa_free +ecdsa_from_keypair mbedtls_ecdsa_from_keypair +ecdsa_genkey mbedtls_ecdsa_genkey +ecdsa_info mbedtls_ecdsa_info +ecdsa_init mbedtls_ecdsa_init +ecdsa_read_signature mbedtls_ecdsa_read_signature +ecdsa_self_test mbedtls_ecdsa_self_test +ecdsa_sign mbedtls_ecdsa_sign +ecdsa_sign_det mbedtls_ecdsa_sign_det +ecdsa_verify mbedtls_ecdsa_verify +ecdsa_write_signature mbedtls_ecdsa_write_signature +ecdsa_write_signature_det mbedtls_ecdsa_write_signature_det +eckey_info mbedtls_eckey_info +eckeydh_info mbedtls_eckeydh_info +ecp_add mbedtls_ecp_add +ecp_check_privkey mbedtls_ecp_check_privkey +ecp_check_pub_priv mbedtls_ecp_check_pub_priv +ecp_check_pubkey mbedtls_ecp_check_pubkey +ecp_copy mbedtls_ecp_copy +ecp_curve_info mbedtls_ecp_curve_info +ecp_curve_info_from_grp_id mbedtls_ecp_curve_info_from_grp_id +ecp_curve_info_from_name mbedtls_ecp_curve_info_from_name +ecp_curve_info_from_tls_id mbedtls_ecp_curve_info_from_tls_id +ecp_curve_list mbedtls_ecp_curve_list +ecp_gen_key mbedtls_ecp_gen_key +ecp_gen_keypair mbedtls_ecp_gen_keypair +ecp_group mbedtls_ecp_group +ecp_group_copy mbedtls_ecp_group_copy +ecp_group_free mbedtls_ecp_group_free +ecp_group_id mbedtls_ecp_group_id +ecp_group_init mbedtls_ecp_group_init +ecp_group_read_string mbedtls_ecp_group_read_string +ecp_grp_id_list mbedtls_ecp_grp_id_list +ecp_is_zero mbedtls_ecp_is_zero +ecp_keypair mbedtls_ecp_keypair +ecp_keypair_free mbedtls_ecp_keypair_free +ecp_keypair_init mbedtls_ecp_keypair_init +ecp_mul mbedtls_ecp_mul +ecp_point mbedtls_ecp_point +ecp_point_free mbedtls_ecp_point_free +ecp_point_init mbedtls_ecp_point_init +ecp_point_read_binary mbedtls_ecp_point_read_binary +ecp_point_read_string mbedtls_ecp_point_read_string +ecp_point_write_binary mbedtls_ecp_point_write_binary +ecp_self_test mbedtls_ecp_self_test +ecp_set_zero mbedtls_ecp_set_zero +ecp_sub mbedtls_ecp_sub +ecp_tls_read_group mbedtls_ecp_tls_read_group +ecp_tls_read_point mbedtls_ecp_tls_read_point +ecp_tls_write_group mbedtls_ecp_tls_write_group +ecp_tls_write_point mbedtls_ecp_tls_write_point +ecp_use_known_dp mbedtls_ecp_group_load +entropy_add_source mbedtls_entropy_add_source +entropy_context mbedtls_entropy_context +entropy_free mbedtls_entropy_free +entropy_func mbedtls_entropy_func +entropy_gather mbedtls_entropy_gather +entropy_init mbedtls_entropy_init +entropy_self_test mbedtls_entropy_self_test +entropy_update_manual mbedtls_entropy_update_manual +entropy_update_seed_file mbedtls_entropy_update_seed_file +entropy_write_seed_file mbedtls_entropy_write_seed_file +error_strerror mbedtls_strerror +f_source_ptr mbedtls_entropy_f_source_ptr +gcm_auth_decrypt mbedtls_gcm_auth_decrypt +gcm_context mbedtls_gcm_context +gcm_crypt_and_tag mbedtls_gcm_crypt_and_tag +gcm_finish mbedtls_gcm_finish +gcm_free mbedtls_gcm_free +gcm_init mbedtls_gcm_init +gcm_self_test mbedtls_gcm_self_test +gcm_starts mbedtls_gcm_starts +gcm_update mbedtls_gcm_update +get_timer mbedtls_timing_get_timer +hardclock mbedtls_timing_hardclock +hardclock_poll mbedtls_hardclock_poll +havege_free mbedtls_havege_free +havege_init mbedtls_havege_init +havege_poll mbedtls_havege_poll +havege_random mbedtls_havege_random +havege_state mbedtls_havege_state +hmac_drbg_context mbedtls_hmac_drbg_context +hmac_drbg_free mbedtls_hmac_drbg_free +hmac_drbg_init mbedtls_hmac_drbg_init +hmac_drbg_init_buf mbedtls_hmac_drbg_init_buf +hmac_drbg_random mbedtls_hmac_drbg_random +hmac_drbg_random_with_add mbedtls_hmac_drbg_random_with_add +hmac_drbg_reseed mbedtls_hmac_drbg_reseed +hmac_drbg_self_test mbedtls_hmac_drbg_self_test +hmac_drbg_set_entropy_len mbedtls_hmac_drbg_set_entropy_len +hmac_drbg_set_prediction_resistance mbedtls_hmac_drbg_set_prediction_resistance +hmac_drbg_set_reseed_interval mbedtls_hmac_drbg_set_reseed_interval +hmac_drbg_update mbedtls_hmac_drbg_update +hmac_drbg_update_seed_file mbedtls_hmac_drbg_update_seed_file +hmac_drbg_write_seed_file mbedtls_hmac_drbg_write_seed_file +hr_time mbedtls_timing_hr_time +key_exchange_type_t mbedtls_key_exchange_type_t +m_sleep mbedtls_timing_m_sleep +md mbedtls_md +md2 mbedtls_md2 +md2_context mbedtls_md2_context +md2_file mbedtls_md2_file +md2_finish mbedtls_md2_finish +md2_free mbedtls_md2_free +md2_hmac mbedtls_md2_hmac +md2_hmac_finish mbedtls_md2_hmac_finish +md2_hmac_reset mbedtls_md2_hmac_reset +md2_hmac_starts mbedtls_md2_hmac_starts +md2_hmac_update mbedtls_md2_hmac_update +md2_info mbedtls_md2_info +md2_init mbedtls_md2_init +md2_process mbedtls_md2_process +md2_self_test mbedtls_md2_self_test +md2_starts mbedtls_md2_starts +md2_update mbedtls_md2_update +md4 mbedtls_md4 +md4_context mbedtls_md4_context +md4_file mbedtls_md4_file +md4_finish mbedtls_md4_finish +md4_free mbedtls_md4_free +md4_hmac mbedtls_md4_hmac +md4_hmac_finish mbedtls_md4_hmac_finish +md4_hmac_reset mbedtls_md4_hmac_reset +md4_hmac_starts mbedtls_md4_hmac_starts +md4_hmac_update mbedtls_md4_hmac_update +md4_info mbedtls_md4_info +md4_init mbedtls_md4_init +md4_process mbedtls_md4_process +md4_self_test mbedtls_md4_self_test +md4_starts mbedtls_md4_starts +md4_update mbedtls_md4_update +md5 mbedtls_md5 +md5_context mbedtls_md5_context +md5_file mbedtls_md5_file +md5_finish mbedtls_md5_finish +md5_free mbedtls_md5_free +md5_hmac mbedtls_md5_hmac +md5_hmac_finish mbedtls_md5_hmac_finish +md5_hmac_reset mbedtls_md5_hmac_reset +md5_hmac_starts mbedtls_md5_hmac_starts +md5_hmac_update mbedtls_md5_hmac_update +md5_info mbedtls_md5_info +md5_init mbedtls_md5_init +md5_process mbedtls_md5_process +md5_self_test mbedtls_md5_self_test +md5_starts mbedtls_md5_starts +md5_update mbedtls_md5_update +md_context_t mbedtls_md_context_t +md_file mbedtls_md_file +md_finish mbedtls_md_finish +md_free mbedtls_md_free +md_free_ctx mbedtls_md_free_ctx +md_get_name mbedtls_md_get_name +md_get_size mbedtls_md_get_size +md_get_type mbedtls_md_get_type +md_hmac mbedtls_md_hmac +md_hmac_finish mbedtls_md_hmac_finish +md_hmac_reset mbedtls_md_hmac_reset +md_hmac_starts mbedtls_md_hmac_starts +md_hmac_update mbedtls_md_hmac_update +md_info_from_string mbedtls_md_info_from_string +md_info_from_type mbedtls_md_info_from_type +md_info_t mbedtls_md_info_t +md_init mbedtls_md_init +md_init_ctx mbedtls_md_init_ctx +md_list mbedtls_md_list +md_process mbedtls_md_process +md_starts mbedtls_md_starts +md_type_t mbedtls_md_type_t +md_update mbedtls_md_update +memory_buffer_alloc_cur_get mbedtls_memory_buffer_alloc_cur_get +memory_buffer_alloc_free mbedtls_memory_buffer_alloc_free +memory_buffer_alloc_init mbedtls_memory_buffer_alloc_init +memory_buffer_alloc_max_get mbedtls_memory_buffer_alloc_max_get +memory_buffer_alloc_max_reset mbedtls_memory_buffer_alloc_max_reset +memory_buffer_alloc_self_test mbedtls_memory_buffer_alloc_self_test +memory_buffer_alloc_status mbedtls_memory_buffer_alloc_status +memory_buffer_alloc_verify mbedtls_memory_buffer_alloc_verify +memory_buffer_set_verify mbedtls_memory_buffer_set_verify +memory_set_own mbedtls_memory_set_own +mpi mbedtls_mpi +mpi_add_abs mbedtls_mpi_add_abs +mpi_add_int mbedtls_mpi_add_int +mpi_add_mpi mbedtls_mpi_add_mpi +mpi_cmp_abs mbedtls_mpi_cmp_abs +mpi_cmp_int mbedtls_mpi_cmp_int +mpi_cmp_mpi mbedtls_mpi_cmp_mpi +mpi_copy mbedtls_mpi_copy +mpi_div_int mbedtls_mpi_div_int +mpi_div_mpi mbedtls_mpi_div_mpi +mpi_exp_mod mbedtls_mpi_exp_mod +mpi_fill_random mbedtls_mpi_fill_random +mpi_free mbedtls_mpi_free +mpi_gcd mbedtls_mpi_gcd +mpi_gen_prime mbedtls_mpi_gen_prime +mpi_get_bit mbedtls_mpi_get_bit +mpi_grow mbedtls_mpi_grow +mpi_init mbedtls_mpi_init +mpi_inv_mod mbedtls_mpi_inv_mod +mpi_is_prime mbedtls_mpi_is_prime +mpi_lsb mbedtls_mpi_lsb +mpi_lset mbedtls_mpi_lset +mpi_mod_int mbedtls_mpi_mod_int +mpi_mod_mpi mbedtls_mpi_mod_mpi +mpi_msb mbedtls_mpi_bitlen +mpi_mul_int mbedtls_mpi_mul_int +mpi_mul_mpi mbedtls_mpi_mul_mpi +mpi_read_binary mbedtls_mpi_read_binary +mpi_read_file mbedtls_mpi_read_file +mpi_read_string mbedtls_mpi_read_string +mpi_safe_cond_assign mbedtls_mpi_safe_cond_assign +mpi_safe_cond_swap mbedtls_mpi_safe_cond_swap +mpi_self_test mbedtls_mpi_self_test +mpi_set_bit mbedtls_mpi_set_bit +mpi_shift_l mbedtls_mpi_shift_l +mpi_shift_r mbedtls_mpi_shift_r +mpi_shrink mbedtls_mpi_shrink +mpi_size mbedtls_mpi_size +mpi_sub_abs mbedtls_mpi_sub_abs +mpi_sub_int mbedtls_mpi_sub_int +mpi_sub_mpi mbedtls_mpi_sub_mpi +mpi_swap mbedtls_mpi_swap +mpi_write_binary mbedtls_mpi_write_binary +mpi_write_file mbedtls_mpi_write_file +mpi_write_string mbedtls_mpi_write_string +net_accept mbedtls_net_accept +net_bind mbedtls_net_bind +net_close mbedtls_net_free +net_connect mbedtls_net_connect +net_recv mbedtls_net_recv +net_recv_timeout mbedtls_net_recv_timeout +net_send mbedtls_net_send +net_set_block mbedtls_net_set_block +net_set_nonblock mbedtls_net_set_nonblock +net_usleep mbedtls_net_usleep +oid_descriptor_t mbedtls_oid_descriptor_t +oid_get_attr_short_name mbedtls_oid_get_attr_short_name +oid_get_cipher_alg mbedtls_oid_get_cipher_alg +oid_get_ec_grp mbedtls_oid_get_ec_grp +oid_get_extended_key_usage mbedtls_oid_get_extended_key_usage +oid_get_md_alg mbedtls_oid_get_md_alg +oid_get_numeric_string mbedtls_oid_get_numeric_string +oid_get_oid_by_ec_grp mbedtls_oid_get_oid_by_ec_grp +oid_get_oid_by_md mbedtls_oid_get_oid_by_md +oid_get_oid_by_pk_alg mbedtls_oid_get_oid_by_pk_alg +oid_get_oid_by_sig_alg mbedtls_oid_get_oid_by_sig_alg +oid_get_pk_alg mbedtls_oid_get_pk_alg +oid_get_pkcs12_pbe_alg mbedtls_oid_get_pkcs12_pbe_alg +oid_get_sig_alg mbedtls_oid_get_sig_alg +oid_get_sig_alg_desc mbedtls_oid_get_sig_alg_desc +oid_get_x509_ext_type mbedtls_oid_get_x509_ext_type +operation_t mbedtls_operation_t +padlock_supports mbedtls_padlock_has_support +padlock_xcryptcbc mbedtls_padlock_xcryptcbc +padlock_xcryptecb mbedtls_padlock_xcryptecb +pem_context mbedtls_pem_context +pem_free mbedtls_pem_free +pem_init mbedtls_pem_init +pem_read_buffer mbedtls_pem_read_buffer +pem_write_buffer mbedtls_pem_write_buffer +pk_can_do mbedtls_pk_can_do +pk_check_pair mbedtls_pk_check_pair +pk_context mbedtls_pk_context +pk_debug mbedtls_pk_debug +pk_debug_item mbedtls_pk_debug_item +pk_debug_type mbedtls_pk_debug_type +pk_decrypt mbedtls_pk_decrypt +pk_ec mbedtls_pk_ec +pk_encrypt mbedtls_pk_encrypt +pk_free mbedtls_pk_free +pk_get_len mbedtls_pk_get_len +pk_get_name mbedtls_pk_get_name +pk_get_size mbedtls_pk_get_bitlen +pk_get_type mbedtls_pk_get_type +pk_info_from_type mbedtls_pk_info_from_type +pk_info_t mbedtls_pk_info_t +pk_init mbedtls_pk_init +pk_init_ctx mbedtls_pk_setup +pk_init_ctx_rsa_alt mbedtls_pk_setup_rsa_alt +pk_load_file mbedtls_pk_load_file +pk_parse_key mbedtls_pk_parse_key +pk_parse_keyfile mbedtls_pk_parse_keyfile +pk_parse_public_key mbedtls_pk_parse_public_key +pk_parse_public_keyfile mbedtls_pk_parse_public_keyfile +pk_parse_subpubkey mbedtls_pk_parse_subpubkey +pk_rsa mbedtls_pk_rsa +pk_rsa_alt_decrypt_func mbedtls_pk_rsa_alt_decrypt_func +pk_rsa_alt_key_len_func mbedtls_pk_rsa_alt_key_len_func +pk_rsa_alt_sign_func mbedtls_pk_rsa_alt_sign_func +pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options +pk_sign mbedtls_pk_sign +pk_type_t mbedtls_pk_type_t +pk_verify mbedtls_pk_verify +pk_verify_ext mbedtls_pk_verify_ext +pk_write_key_der mbedtls_pk_write_key_der +pk_write_key_pem mbedtls_pk_write_key_pem +pk_write_pubkey mbedtls_pk_write_pubkey +pk_write_pubkey_der mbedtls_pk_write_pubkey_der +pk_write_pubkey_pem mbedtls_pk_write_pubkey_pem +pkcs11_context mbedtls_pkcs11_context +pkcs11_decrypt mbedtls_pkcs11_decrypt +pkcs11_priv_key_free mbedtls_pkcs11_priv_key_free +pkcs11_priv_key_init mbedtls_pkcs11_priv_key_bind +pkcs11_sign mbedtls_pkcs11_sign +pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_bind +pkcs12_derivation mbedtls_pkcs12_derivation +pkcs12_pbe mbedtls_pkcs12_pbe +pkcs12_pbe_sha1_rc4_128 mbedtls_pkcs12_pbe_sha1_rc4_128 +pkcs5_pbes2 mbedtls_pkcs5_pbes2 +pkcs5_pbkdf2_hmac mbedtls_pkcs5_pbkdf2_hmac +pkcs5_self_test mbedtls_pkcs5_self_test +platform_entropy_poll mbedtls_platform_entropy_poll +platform_set_exit mbedtls_platform_set_exit +platform_set_fprintf mbedtls_platform_set_fprintf +platform_set_malloc_free mbedtls_platform_set_malloc_free +platform_set_printf mbedtls_platform_set_printf +platform_set_snprintf mbedtls_platform_set_snprintf +polarssl_exit mbedtls_exit +polarssl_fprintf mbedtls_fprintf +polarssl_free mbedtls_free +polarssl_malloc mbedtls_malloc +polarssl_mutex_free mbedtls_mutex_free +polarssl_mutex_init mbedtls_mutex_init +polarssl_mutex_lock mbedtls_mutex_lock +polarssl_mutex_unlock mbedtls_mutex_unlock +polarssl_printf mbedtls_printf +polarssl_snprintf mbedtls_snprintf +polarssl_strerror mbedtls_strerror +ripemd160 mbedtls_ripemd160 +ripemd160_context mbedtls_ripemd160_context +ripemd160_file mbedtls_ripemd160_file +ripemd160_finish mbedtls_ripemd160_finish +ripemd160_free mbedtls_ripemd160_free +ripemd160_hmac mbedtls_ripemd160_hmac +ripemd160_hmac_finish mbedtls_ripemd160_hmac_finish +ripemd160_hmac_reset mbedtls_ripemd160_hmac_reset +ripemd160_hmac_starts mbedtls_ripemd160_hmac_starts +ripemd160_hmac_update mbedtls_ripemd160_hmac_update +ripemd160_info mbedtls_ripemd160_info +ripemd160_init mbedtls_ripemd160_init +ripemd160_process mbedtls_ripemd160_process +ripemd160_self_test mbedtls_ripemd160_self_test +ripemd160_starts mbedtls_ripemd160_starts +ripemd160_update mbedtls_ripemd160_update +rsa_alt_context mbedtls_rsa_alt_context +rsa_alt_info mbedtls_rsa_alt_info +rsa_check_privkey mbedtls_rsa_check_privkey +rsa_check_pub_priv mbedtls_rsa_check_pub_priv +rsa_check_pubkey mbedtls_rsa_check_pubkey +rsa_context mbedtls_rsa_context +rsa_copy mbedtls_rsa_copy +rsa_decrypt_func mbedtls_rsa_decrypt_func +rsa_free mbedtls_rsa_free +rsa_gen_key mbedtls_rsa_gen_key +rsa_info mbedtls_rsa_info +rsa_init mbedtls_rsa_init +rsa_key_len_func mbedtls_rsa_key_len_func +rsa_pkcs1_decrypt mbedtls_rsa_pkcs1_decrypt +rsa_pkcs1_encrypt mbedtls_rsa_pkcs1_encrypt +rsa_pkcs1_sign mbedtls_rsa_pkcs1_sign +rsa_pkcs1_verify mbedtls_rsa_pkcs1_verify +rsa_private mbedtls_rsa_private +rsa_public mbedtls_rsa_public +rsa_rsaes_oaep_decrypt mbedtls_rsa_rsaes_oaep_decrypt +rsa_rsaes_oaep_encrypt mbedtls_rsa_rsaes_oaep_encrypt +rsa_rsaes_pkcs1_v15_decrypt mbedtls_rsa_rsaes_pkcs1_v15_decrypt +rsa_rsaes_pkcs1_v15_encrypt mbedtls_rsa_rsaes_pkcs1_v15_encrypt +rsa_rsassa_pkcs1_v15_sign mbedtls_rsa_rsassa_pkcs1_v15_sign +rsa_rsassa_pkcs1_v15_verify mbedtls_rsa_rsassa_pkcs1_v15_verify +rsa_rsassa_pss_sign mbedtls_rsa_rsassa_pss_sign +rsa_rsassa_pss_verify mbedtls_rsa_rsassa_pss_verify +rsa_rsassa_pss_verify_ext mbedtls_rsa_rsassa_pss_verify_ext +rsa_self_test mbedtls_rsa_self_test +rsa_set_padding mbedtls_rsa_set_padding +rsa_sign_func mbedtls_rsa_sign_func +safer_memcmp mbedtls_ssl_safer_memcmp +set_alarm mbedtls_set_alarm +sha1 mbedtls_sha1 +sha1_context mbedtls_sha1_context +sha1_file mbedtls_sha1_file +sha1_finish mbedtls_sha1_finish +sha1_free mbedtls_sha1_free +sha1_hmac mbedtls_sha1_hmac +sha1_hmac_finish mbedtls_sha1_hmac_finish +sha1_hmac_reset mbedtls_sha1_hmac_reset +sha1_hmac_starts mbedtls_sha1_hmac_starts +sha1_hmac_update mbedtls_sha1_hmac_update +sha1_info mbedtls_sha1_info +sha1_init mbedtls_sha1_init +sha1_process mbedtls_sha1_process +sha1_self_test mbedtls_sha1_self_test +sha1_starts mbedtls_sha1_starts +sha1_update mbedtls_sha1_update +sha224_info mbedtls_sha224_info +sha256 mbedtls_sha256 +sha256_context mbedtls_sha256_context +sha256_file mbedtls_sha256_file +sha256_finish mbedtls_sha256_finish +sha256_free mbedtls_sha256_free +sha256_hmac mbedtls_sha256_hmac +sha256_hmac_finish mbedtls_sha256_hmac_finish +sha256_hmac_reset mbedtls_sha256_hmac_reset +sha256_hmac_starts mbedtls_sha256_hmac_starts +sha256_hmac_update mbedtls_sha256_hmac_update +sha256_info mbedtls_sha256_info +sha256_init mbedtls_sha256_init +sha256_process mbedtls_sha256_process +sha256_self_test mbedtls_sha256_self_test +sha256_starts mbedtls_sha256_starts +sha256_update mbedtls_sha256_update +sha384_info mbedtls_sha384_info +sha512 mbedtls_sha512 +sha512_context mbedtls_sha512_context +sha512_file mbedtls_sha512_file +sha512_finish mbedtls_sha512_finish +sha512_free mbedtls_sha512_free +sha512_hmac mbedtls_sha512_hmac +sha512_hmac_finish mbedtls_sha512_hmac_finish +sha512_hmac_reset mbedtls_sha512_hmac_reset +sha512_hmac_starts mbedtls_sha512_hmac_starts +sha512_hmac_update mbedtls_sha512_hmac_update +sha512_info mbedtls_sha512_info +sha512_init mbedtls_sha512_init +sha512_process mbedtls_sha512_process +sha512_self_test mbedtls_sha512_self_test +sha512_starts mbedtls_sha512_starts +sha512_update mbedtls_sha512_update +source_state mbedtls_entropy_source_state +ssl_cache_context mbedtls_ssl_cache_context +ssl_cache_entry mbedtls_ssl_cache_entry +ssl_cache_free mbedtls_ssl_cache_free +ssl_cache_get mbedtls_ssl_cache_get +ssl_cache_init mbedtls_ssl_cache_init +ssl_cache_set mbedtls_ssl_cache_set +ssl_cache_set_max_entries mbedtls_ssl_cache_set_max_entries +ssl_cache_set_timeout mbedtls_ssl_cache_set_timeout +ssl_check_cert_usage mbedtls_ssl_check_cert_usage +ssl_ciphersuite_from_id mbedtls_ssl_ciphersuite_from_id +ssl_ciphersuite_from_string mbedtls_ssl_ciphersuite_from_string +ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t +ssl_ciphersuite_uses_ec mbedtls_ssl_ciphersuite_uses_ec +ssl_ciphersuite_uses_psk mbedtls_ssl_ciphersuite_uses_psk +ssl_close_notify mbedtls_ssl_close_notify +ssl_context mbedtls_ssl_context +ssl_cookie_check mbedtls_ssl_cookie_check +ssl_cookie_check_t mbedtls_ssl_cookie_check_t +ssl_cookie_ctx mbedtls_ssl_cookie_ctx +ssl_cookie_free mbedtls_ssl_cookie_free +ssl_cookie_init mbedtls_ssl_cookie_init +ssl_cookie_set_timeout mbedtls_ssl_cookie_set_timeout +ssl_cookie_setup mbedtls_ssl_cookie_setup +ssl_cookie_write mbedtls_ssl_cookie_write +ssl_cookie_write_t mbedtls_ssl_cookie_write_t +ssl_curve_is_acceptable mbedtls_ssl_curve_is_acceptable +ssl_derive_keys mbedtls_ssl_derive_keys +ssl_dtls_replay_check mbedtls_ssl_dtls_replay_check +ssl_dtls_replay_update mbedtls_ssl_dtls_replay_update +ssl_fetch_input mbedtls_ssl_fetch_input +ssl_flight_item mbedtls_ssl_flight_item +ssl_flush_output mbedtls_ssl_flush_output +ssl_free mbedtls_ssl_free +ssl_get_alpn_protocol mbedtls_ssl_get_alpn_protocol +ssl_get_bytes_avail mbedtls_ssl_get_bytes_avail +ssl_get_ciphersuite mbedtls_ssl_get_ciphersuite +ssl_get_ciphersuite_id mbedtls_ssl_get_ciphersuite_id +ssl_get_ciphersuite_name mbedtls_ssl_get_ciphersuite_name +ssl_get_ciphersuite_sig_pk_alg mbedtls_ssl_get_ciphersuite_sig_pk_alg +ssl_get_peer_cert mbedtls_ssl_get_peer_cert +ssl_get_record_expansion mbedtls_ssl_get_record_expansion +ssl_get_session mbedtls_ssl_get_session +ssl_get_verify_result mbedtls_ssl_get_verify_result +ssl_get_version mbedtls_ssl_get_version +ssl_handshake mbedtls_ssl_handshake +ssl_handshake_client_step mbedtls_ssl_handshake_client_step +ssl_handshake_free mbedtls_ssl_handshake_free +ssl_handshake_params mbedtls_ssl_handshake_params +ssl_handshake_server_step mbedtls_ssl_handshake_server_step +ssl_handshake_step mbedtls_ssl_handshake_step +ssl_handshake_wrapup mbedtls_ssl_handshake_wrapup +ssl_hdr_len mbedtls_ssl_hdr_len +ssl_hs_hdr_len mbedtls_ssl_hs_hdr_len +ssl_hw_record_activate mbedtls_ssl_hw_record_activate +ssl_hw_record_finish mbedtls_ssl_hw_record_finish +ssl_hw_record_init mbedtls_ssl_hw_record_init +ssl_hw_record_read mbedtls_ssl_hw_record_read +ssl_hw_record_reset mbedtls_ssl_hw_record_reset +ssl_hw_record_write mbedtls_ssl_hw_record_write +ssl_init mbedtls_ssl_init +ssl_key_cert mbedtls_ssl_key_cert +ssl_legacy_renegotiation mbedtls_ssl_conf_legacy_renegotiation +ssl_list_ciphersuites mbedtls_ssl_list_ciphersuites +ssl_md_alg_from_hash mbedtls_ssl_md_alg_from_hash +ssl_optimize_checksum mbedtls_ssl_optimize_checksum +ssl_own_cert mbedtls_ssl_own_cert +ssl_own_key mbedtls_ssl_own_key +ssl_parse_certificate mbedtls_ssl_parse_certificate +ssl_parse_change_cipher_spec mbedtls_ssl_parse_change_cipher_spec +ssl_parse_finished mbedtls_ssl_parse_finished +ssl_pk_alg_from_sig mbedtls_ssl_pk_alg_from_sig +ssl_pkcs11_decrypt mbedtls_ssl_pkcs11_decrypt +ssl_pkcs11_key_len mbedtls_ssl_pkcs11_key_len +ssl_pkcs11_sign mbedtls_ssl_pkcs11_sign +ssl_psk_derive_premaster mbedtls_ssl_psk_derive_premaster +ssl_read mbedtls_ssl_read +ssl_read_record mbedtls_ssl_read_record +ssl_read_version mbedtls_ssl_read_version +ssl_recv_flight_completed mbedtls_ssl_recv_flight_completed +ssl_renegotiate mbedtls_ssl_renegotiate +ssl_resend mbedtls_ssl_resend +ssl_reset_checksum mbedtls_ssl_reset_checksum +ssl_send_alert_message mbedtls_ssl_send_alert_message +ssl_send_fatal_handshake_failure mbedtls_ssl_send_fatal_handshake_failure +ssl_send_flight_completed mbedtls_ssl_send_flight_completed +ssl_session mbedtls_ssl_session +ssl_session_free mbedtls_ssl_session_free +ssl_session_init mbedtls_ssl_session_init +ssl_session_reset mbedtls_ssl_session_reset +ssl_set_alpn_protocols mbedtls_ssl_conf_alpn_protocols +ssl_set_arc4_support mbedtls_ssl_conf_arc4_support +ssl_set_authmode mbedtls_ssl_conf_authmode +ssl_set_bio mbedtls_ssl_set_bio +ssl_set_ca_chain mbedtls_ssl_conf_ca_chain +ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting +ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites +ssl_set_ciphersuites_for_version mbedtls_ssl_conf_ciphersuites_for_version +ssl_set_client_transport_id mbedtls_ssl_set_client_transport_id +ssl_set_curves mbedtls_ssl_conf_curves +ssl_set_dbg mbedtls_ssl_conf_dbg +ssl_set_dh_param mbedtls_ssl_conf_dh_param +ssl_set_dh_param_ctx mbedtls_ssl_conf_dh_param_ctx +ssl_set_dtls_anti_replay mbedtls_ssl_conf_dtls_anti_replay +ssl_set_dtls_badmac_limit mbedtls_ssl_conf_dtls_badmac_limit +ssl_set_dtls_cookies mbedtls_ssl_conf_dtls_cookies +ssl_set_encrypt_then_mac mbedtls_ssl_conf_encrypt_then_mac +ssl_set_endpoint mbedtls_ssl_conf_endpoint +ssl_set_extended_master_secret mbedtls_ssl_conf_extended_master_secret +ssl_set_fallback mbedtls_ssl_conf_fallback +ssl_set_handshake_timeout mbedtls_ssl_conf_handshake_timeout +ssl_set_hostname mbedtls_ssl_set_hostname +ssl_set_max_frag_len mbedtls_ssl_conf_max_frag_len +ssl_set_max_version mbedtls_ssl_conf_max_version +ssl_set_min_version mbedtls_ssl_conf_min_version +ssl_set_own_cert mbedtls_ssl_conf_own_cert +ssl_set_own_cert_alt mbedtls_ssl_set_own_cert_alt +ssl_set_own_cert_rsa mbedtls_ssl_set_own_cert_rsa +ssl_set_psk mbedtls_ssl_conf_psk +ssl_set_psk_cb mbedtls_ssl_conf_psk_cb +ssl_set_renegotiation mbedtls_ssl_conf_renegotiation +ssl_set_renegotiation_enforced mbedtls_ssl_conf_renegotiation_enforced +ssl_set_renegotiation_period mbedtls_ssl_conf_renegotiation_period +ssl_set_rng mbedtls_ssl_conf_rng +ssl_set_session mbedtls_ssl_set_session +ssl_set_session_cache mbedtls_ssl_conf_session_cache +ssl_set_session_ticket_lifetime mbedtls_ssl_conf_session_ticket_lifetime +ssl_set_session_tickets mbedtls_ssl_conf_session_tickets +ssl_set_sni mbedtls_ssl_conf_sni +ssl_set_transport mbedtls_ssl_conf_transport +ssl_set_truncated_hmac mbedtls_ssl_conf_truncated_hmac +ssl_set_verify mbedtls_ssl_conf_verify +ssl_sig_from_pk mbedtls_ssl_sig_from_pk +ssl_states mbedtls_ssl_states +ssl_ticket_keys mbedtls_ssl_ticket_keys +ssl_transform mbedtls_ssl_transform +ssl_transform_free mbedtls_ssl_transform_free +ssl_write mbedtls_ssl_write +ssl_write_certificate mbedtls_ssl_write_certificate +ssl_write_change_cipher_spec mbedtls_ssl_write_change_cipher_spec +ssl_write_finished mbedtls_ssl_write_finished +ssl_write_record mbedtls_ssl_write_record +ssl_write_version mbedtls_ssl_write_version +supported_ciphers mbedtls_cipher_supported +t_sint mbedtls_mpi_sint +t_udbl mbedtls_t_udbl +t_uint mbedtls_mpi_uint +test_ca_crt mbedtls_test_ca_crt +test_ca_crt_ec mbedtls_test_ca_crt_ec +test_ca_crt_rsa mbedtls_test_ca_crt_rsa +test_ca_key mbedtls_test_ca_key +test_ca_key_ec mbedtls_test_ca_key_ec +test_ca_key_rsa mbedtls_test_ca_key_rsa +test_ca_list mbedtls_test_cas_pem +test_ca_pwd mbedtls_test_ca_pwd +test_ca_pwd_ec mbedtls_test_ca_pwd_ec +test_ca_pwd_rsa mbedtls_test_ca_pwd_rsa +test_cli_crt mbedtls_test_cli_crt +test_cli_crt_ec mbedtls_test_cli_crt_ec +test_cli_crt_rsa mbedtls_test_cli_crt_rsa +test_cli_key mbedtls_test_cli_key +test_cli_key_ec mbedtls_test_cli_key_ec +test_cli_key_rsa mbedtls_test_cli_key_rsa +test_dhm_params mbedtls_test_dhm_params +test_srv_crt mbedtls_test_srv_crt +test_srv_crt_ec mbedtls_test_srv_crt_ec +test_srv_crt_rsa mbedtls_test_srv_crt_rsa +test_srv_key mbedtls_test_srv_key +test_srv_key_ec mbedtls_test_srv_key_ec +test_srv_key_rsa mbedtls_test_srv_key_rsa +threading_mutex_t mbedtls_threading_mutex_t +threading_set_alt mbedtls_threading_set_alt +timing_self_test mbedtls_timing_self_test +version_check_feature mbedtls_version_check_feature +version_get_number mbedtls_version_get_number +version_get_string mbedtls_version_get_string +version_get_string_full mbedtls_version_get_string_full +x509_bitstring mbedtls_x509_bitstring +x509_buf mbedtls_x509_buf +x509_crl mbedtls_x509_crl +x509_crl_entry mbedtls_x509_crl_entry +x509_crl_free mbedtls_x509_crl_free +x509_crl_info mbedtls_x509_crl_info +x509_crl_init mbedtls_x509_crl_init +x509_crl_parse mbedtls_x509_crl_parse +x509_crl_parse_der mbedtls_x509_crl_parse_der +x509_crl_parse_file mbedtls_x509_crl_parse_file +x509_crt mbedtls_x509_crt +x509_crt_check_extended_key_usage mbedtls_x509_crt_check_extended_key_usage +x509_crt_check_key_usage mbedtls_x509_crt_check_key_usage +x509_crt_free mbedtls_x509_crt_free +x509_crt_info mbedtls_x509_crt_info +x509_crt_init mbedtls_x509_crt_init +x509_crt_parse mbedtls_x509_crt_parse +x509_crt_parse_der mbedtls_x509_crt_parse_der +x509_crt_parse_file mbedtls_x509_crt_parse_file +x509_crt_parse_path mbedtls_x509_crt_parse_path +x509_crt_revoked mbedtls_x509_crt_is_revoked +x509_crt_verify mbedtls_x509_crt_verify +x509_crt_verify_info mbedtls_x509_crt_verify_info +x509_csr mbedtls_x509_csr +x509_csr_free mbedtls_x509_csr_free +x509_csr_info mbedtls_x509_csr_info +x509_csr_init mbedtls_x509_csr_init +x509_csr_parse mbedtls_x509_csr_parse +x509_csr_parse_der mbedtls_x509_csr_parse_der +x509_csr_parse_file mbedtls_x509_csr_parse_file +x509_dn_gets mbedtls_x509_dn_gets +x509_get_alg mbedtls_x509_get_alg +x509_get_alg_null mbedtls_x509_get_alg_null +x509_get_ext mbedtls_x509_get_ext +x509_get_name mbedtls_x509_get_name +x509_get_rsassa_pss_params mbedtls_x509_get_rsassa_pss_params +x509_get_serial mbedtls_x509_get_serial +x509_get_sig mbedtls_x509_get_sig +x509_get_sig_alg mbedtls_x509_get_sig_alg +x509_get_time mbedtls_x509_get_time +x509_key_size_helper mbedtls_x509_key_size_helper +x509_name mbedtls_x509_name +x509_oid_get_description mbedtls_x509_oid_get_description +x509_oid_get_numeric_string mbedtls_x509_oid_get_numeric_string +x509_self_test mbedtls_x509_self_test +x509_sequence mbedtls_x509_sequence +x509_serial_gets mbedtls_x509_serial_gets +x509_set_extension mbedtls_x509_set_extension +x509_sig_alg_gets mbedtls_x509_sig_alg_gets +x509_string_to_names mbedtls_x509_string_to_names +x509_time mbedtls_x509_time +x509_time_expired mbedtls_x509_time_is_past +x509_time_future mbedtls_x509_time_is_future +x509_write_extensions mbedtls_x509_write_extensions +x509_write_names mbedtls_x509_write_names +x509_write_sig mbedtls_x509_write_sig +x509write_cert mbedtls_x509write_cert +x509write_crt_der mbedtls_x509write_crt_der +x509write_crt_free mbedtls_x509write_crt_free +x509write_crt_init mbedtls_x509write_crt_init +x509write_crt_pem mbedtls_x509write_crt_pem +x509write_crt_set_authority_key_identifier mbedtls_x509write_crt_set_authority_key_identifier +x509write_crt_set_basic_constraints mbedtls_x509write_crt_set_basic_constraints +x509write_crt_set_extension mbedtls_x509write_crt_set_extension +x509write_crt_set_issuer_key mbedtls_x509write_crt_set_issuer_key +x509write_crt_set_issuer_name mbedtls_x509write_crt_set_issuer_name +x509write_crt_set_key_usage mbedtls_x509write_crt_set_key_usage +x509write_crt_set_md_alg mbedtls_x509write_crt_set_md_alg +x509write_crt_set_ns_cert_type mbedtls_x509write_crt_set_ns_cert_type +x509write_crt_set_serial mbedtls_x509write_crt_set_serial +x509write_crt_set_subject_key mbedtls_x509write_crt_set_subject_key +x509write_crt_set_subject_key_identifier mbedtls_x509write_crt_set_subject_key_identifier +x509write_crt_set_subject_name mbedtls_x509write_crt_set_subject_name +x509write_crt_set_validity mbedtls_x509write_crt_set_validity +x509write_crt_set_version mbedtls_x509write_crt_set_version +x509write_csr mbedtls_x509write_csr +x509write_csr_der mbedtls_x509write_csr_der +x509write_csr_free mbedtls_x509write_csr_free +x509write_csr_init mbedtls_x509write_csr_init +x509write_csr_pem mbedtls_x509write_csr_pem +x509write_csr_set_extension mbedtls_x509write_csr_set_extension +x509write_csr_set_key mbedtls_x509write_csr_set_key +x509write_csr_set_key_usage mbedtls_x509write_csr_set_key_usage +x509write_csr_set_md_alg mbedtls_x509write_csr_set_md_alg +x509write_csr_set_ns_cert_type mbedtls_x509write_csr_set_ns_cert_type +x509write_csr_set_subject_name mbedtls_x509write_csr_set_subject_name +xtea_context mbedtls_xtea_context +xtea_crypt_cbc mbedtls_xtea_crypt_cbc +xtea_crypt_ecb mbedtls_xtea_crypt_ecb +xtea_free mbedtls_xtea_free +xtea_init mbedtls_xtea_init +xtea_self_test mbedtls_xtea_self_test +xtea_setup mbedtls_xtea_setup diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/version_features.fmt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/version_features.fmt new file mode 100644 index 0000000..767eda1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/version_features.fmt @@ -0,0 +1,60 @@ +/* + * Version feature information + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_VERSION_C) + +#include "mbedtls/version.h" + +#include + +static const char *features[] = { +#if defined(MBEDTLS_VERSION_FEATURES) +FEATURE_DEFINES +#endif /* MBEDTLS_VERSION_FEATURES */ + NULL +}; + +int mbedtls_version_check_feature( const char *feature ) +{ + const char **idx = features; + + if( *idx == NULL ) + return( -2 ); + + if( feature == NULL ) + return( -1 ); + + while( *idx != NULL ) + { + if( !strcmp( *idx, feature ) ) + return( 0 ); + idx++; + } + return( -1 ); +} + +#endif /* MBEDTLS_VERSION_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-app-template.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-app-template.vcxproj new file mode 100644 index 0000000..adfb985 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-app-template.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + + Win32Proj + + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-main-template.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-main-template.vcxproj new file mode 100644 index 0000000..f91023a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-main-template.vcxproj @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {46CF2D25-6A36-4189-B59C-E4815388E554} + Win32Proj + mbedTLS + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + CompileAsC + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + CompileAsC + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + + + Windows + true + true + true + + + +HEADER_ENTRIES + + +SOURCE_ENTRIES + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-sln-template.sln b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-sln-template.sln new file mode 100644 index 0000000..1c7ad2b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs2010-sln-template.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbedTLS", "mbedTLS.vcxproj", "{46CF2D25-6A36-4189-B59C-E4815388E554}" +EndProject +APP_ENTRIES +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|Win32.ActiveCfg = Debug|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|Win32.Build.0 = Debug|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|x64.ActiveCfg = Debug|x64 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|x64.Build.0 = Debug|x64 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|Win32.ActiveCfg = Release|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|Win32.Build.0 = Release|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|x64.ActiveCfg = Release|x64 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|x64.Build.0 = Release|x64 +CONF_ENTRIES + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-app-template.dsp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-app-template.dsp new file mode 100644 index 0000000..ff7c00e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-app-template.dsp @@ -0,0 +1,101 @@ +# Microsoft Developer Studio Project File - Name="" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG= - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f ".mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f ".mak" CFG=" - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE " - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE " - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == " - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "" +# PROP BASE Intermediate_Dir "temp" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "" +# PROP Intermediate_Dir "temp" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x40c /d "NDEBUG" +# ADD RSC /l 0x40c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == " - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "" +# PROP BASE Intermediate_Dir "temp" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "temp" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x40c /d "_DEBUG" +# ADD RSC /l 0x40c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name " - Win32 Release" +# Name " - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\programs\.c +# ADD CPP /I "../../include" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-main-template.dsp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-main-template.dsp new file mode 100644 index 0000000..3f4d5c4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-main-template.dsp @@ -0,0 +1,94 @@ +# Microsoft Developer Studio Project File - Name="mbedtls" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=mbedtls - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "mbedtls.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mbedtls.mak" CFG="mbedtls - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mbedtls - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "mbedtls - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mbedtls - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "" +# PROP BASE Intermediate_Dir "temp" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "" +# PROP Intermediate_Dir "temp" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x40c /d "NDEBUG" +# ADD RSC /l 0x40c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "mbedtls - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "" +# PROP BASE Intermediate_Dir "temp" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "temp" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x40c /d "_DEBUG" +# ADD RSC /l 0x40c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "mbedtls - Win32 Release" +# Name "mbedtls - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +SOURCE_ENTRIES +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +HEADER_ENTRIES +# End Group +# End Target +# End Project diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-workspace-template.dsw b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-workspace-template.dsw new file mode 100644 index 0000000..9b2e262 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/data_files/vs6-workspace-template.dsw @@ -0,0 +1,18 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +APP_ENTRIES +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/ecc-heap.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/ecc-heap.sh new file mode 100644 index 0000000..94a04cf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/ecc-heap.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +# Measure heap usage (and performance) of ECC operations with various values of +# the relevant tunable compile-time parameters. +# +# Usage (preferably on a 32-bit platform): +# cmake -D CMAKE_BUILD_TYPE=Release . +# scripts/ecc-heap.sh | tee ecc-heap.log + +set -eu + +CONFIG_H='include/mbedtls/config.h' + +if [ -r $CONFIG_H ]; then :; else + echo "$CONFIG_H not found" >&2 + exit 1 +fi + +if grep -i cmake Makefile >/dev/null; then :; else + echo "Needs Cmake" >&2 + exit 1 +fi + +if git status | grep -F $CONFIG_H >/dev/null 2>&1; then + echo "config.h not clean" >&2 + exit 1 +fi + +CONFIG_BAK=${CONFIG_H}.bak +cp $CONFIG_H $CONFIG_BAK + +cat << EOF >$CONFIG_H +#define MBEDTLS_PLATFORM_C +#define MBEDTLS_PLATFORM_MEMORY +#define MBEDTLS_MEMORY_BUFFER_ALLOC_C +#define MBEDTLS_MEMORY_DEBUG + +#define MBEDTLS_TIMING_C + +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_ECP_C +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECDH_C + +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED + +#include "check_config.h" + +//#define MBEDTLS_ECP_WINDOW_SIZE 6 +//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 +EOF + +for F in 0 1; do + for W in 2 3 4 5 6; do + scripts/config.pl set MBEDTLS_ECP_WINDOW_SIZE $W + scripts/config.pl set MBEDTLS_ECP_FIXED_POINT_OPTIM $F + make benchmark >/dev/null 2>&1 + echo "fixed point optim = $F, max window size = $W" + echo "--------------------------------------------" + programs/test/benchmark + done +done + +# cleanup + +mv $CONFIG_BAK $CONFIG_H +make clean diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/find-mem-leak.cocci b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/find-mem-leak.cocci new file mode 100644 index 0000000..5cfe452 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/find-mem-leak.cocci @@ -0,0 +1,20 @@ +@@ +expression x, y; +statement S; +@@ + x = mbedtls_malloc(...); + y = mbedtls_malloc(...); + ... +* if (x == NULL || y == NULL) + S + +@@ +expression x, y; +statement S; +@@ + if ( +* (x = mbedtls_malloc(...)) == NULL + || +* (y = mbedtls_malloc(...)) == NULL + ) + S diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/footprint.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/footprint.sh new file mode 100644 index 0000000..d38e50a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/footprint.sh @@ -0,0 +1,114 @@ +#!/bin/sh +# +# This file is part of mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved +# +# Purpose +# +# This script determines ROM size (or code size) for the standard mbed TLS +# configurations, when built for a Cortex M3/M4 target. +# +# Configurations included: +# default include/mbedtls/config.h +# yotta yotta/module/mbedtls/config.h +# thread configs/config-thread.h +# suite-b configs/config-suite-b.h +# psk configs/config-ccm-psk-tls1_2.h +# +# Usage: footprint.sh +# +set -eu + +CONFIG_H='include/mbedtls/config.h' + +if [ -r $CONFIG_H ]; then :; else + echo "$CONFIG_H not found" >&2 + echo "This script needs to be run from the root of" >&2 + echo "a git checkout or uncompressed tarball" >&2 + exit 1 +fi + +if grep -i cmake Makefile >/dev/null; then + echo "Not compatible with CMake" >&2 + exit 1 +fi + +if which arm-none-eabi-gcc >/dev/null 2>&1; then :; else + echo "You need the ARM-GCC toolchain in your path" >&2 + echo "See https://launchpad.net/gcc-arm-embedded/" >&2 + exit 1 +fi + +ARMGCC_FLAGS='-Os -march=armv7-m -mthumb' +OUTFILE='00-footprint-summary.txt' + +log() +{ + echo "$@" + echo "$@" >> "$OUTFILE" +} + +doit() +{ + NAME="$1" + FILE="$2" + + log "" + log "$NAME ($FILE):" + + cp $CONFIG_H ${CONFIG_H}.bak + if [ "$FILE" != $CONFIG_H ]; then + cp "$FILE" $CONFIG_H + fi + + { + scripts/config.pl unset MBEDTLS_NET_C || true + scripts/config.pl unset MBEDTLS_TIMING_C || true + scripts/config.pl unset MBEDTLS_FS_IO || true + scripts/config.pl --force set MBEDTLS_NO_PLATFORM_ENTROPY || true + } >/dev/null 2>&1 + + make clean >/dev/null + CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld \ + CFLAGS="$ARMGCC_FLAGS" make lib >/dev/null + + OUT="size-${NAME}.txt" + arm-none-eabi-size -t library/libmbed*.a > "$OUT" + log "$( head -n1 "$OUT" )" + log "$( tail -n1 "$OUT" )" + + cp ${CONFIG_H}.bak $CONFIG_H +} + +# truncate the file just this time +echo "(generated by $0)" > "$OUTFILE" +echo "" >> "$OUTFILE" + +log "Footprint of standard configurations (minus net_sockets.c, timing.c, fs_io)" +log "for bare-metal ARM Cortex-M3/M4 microcontrollers." + +VERSION_H="include/mbedtls/version.h" +MBEDTLS_VERSION=$( sed -n 's/.*VERSION_STRING *"\(.*\)"/\1/p' $VERSION_H ) +if git rev-parse HEAD >/dev/null; then + GIT_HEAD=$( git rev-parse HEAD | head -c 10 ) + GIT_VERSION=" (git head: $GIT_HEAD)" +else + GIT_VERSION="" +fi + +log "" +log "mbed TLS $MBEDTLS_VERSION$GIT_VERSION" +log "$( arm-none-eabi-gcc --version | head -n1 )" +log "CFLAGS=$ARMGCC_FLAGS" + +# creates the yotta config +yotta/create-module.sh >/dev/null + +doit default include/mbedtls/config.h +doit yotta yotta/module/mbedtls/config.h +doit thread configs/config-thread.h +doit suite-b configs/config-suite-b.h +doit psk configs/config-ccm-psk-tls1_2.h + +zip mbedtls-footprint.zip "$OUTFILE" size-*.txt >/dev/null diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_errors.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_errors.pl new file mode 100644 index 0000000..cfcf07c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_errors.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl + +# Generate error.c +# +# Usage: ./generate_errors.pl or scripts/generate_errors.pl without arguments, +# or generate_errors.pl include_dir data_dir error_file + +use strict; + +my ($include_dir, $data_dir, $error_file); + +if( @ARGV ) { + die "Invalid number of arguments" if scalar @ARGV != 3; + ($include_dir, $data_dir, $error_file) = @ARGV; + + -d $include_dir or die "No such directory: $include_dir\n"; + -d $data_dir or die "No such directory: $data_dir\n"; +} else { + $include_dir = 'include/mbedtls'; + $data_dir = 'scripts/data_files'; + $error_file = 'library/error.c'; + + unless( -d $include_dir && -d $data_dir ) { + chdir '..' or die; + -d $include_dir && -d $data_dir + or die "Without arguments, must be run from root or scripts\n" + } +} + +my $error_format_file = $data_dir.'/error.fmt'; + +my @low_level_modules = ( "AES", "ASN1", "BLOWFISH", "CAMELLIA", "BIGNUM", + "BASE64", "XTEA", "PBKDF2", "OID", + "PADLOCK", "DES", "NET", "CTR_DRBG", "ENTROPY", + "HMAC_DRBG", "MD2", "MD4", "MD5", "RIPEMD160", + "SHA1", "SHA256", "SHA512", "GCM", "THREADING", "CCM" ); +my @high_level_modules = ( "PEM", "X509", "DHM", "RSA", "ECP", "MD", "CIPHER", "SSL", + "PK", "PKCS12", "PKCS5" ); + +my $line_separator = $/; +undef $/; + +open(FORMAT_FILE, "$error_format_file") or die "Opening error format file '$error_format_file': $!"; +my $error_format = ; +close(FORMAT_FILE); + +$/ = $line_separator; + +open(GREP, "grep \"define MBEDTLS_ERR_\" $include_dir/* |") || die("Failure when calling grep: $!"); + +my $ll_old_define = ""; +my $hl_old_define = ""; + +my $ll_code_check = ""; +my $hl_code_check = ""; + +my $headers = ""; + +my %error_codes_seen; + +while (my $line = ) +{ + next if ($line =~ /compat-1.2.h/); + my ($error_name, $error_code) = $line =~ /(MBEDTLS_ERR_\w+)\s+\-(0x\w+)/; + my ($description) = $line =~ /\/\*\*< (.*?)\.? \*\//; + + die "Duplicated error code: $error_code ($error_name)\n" + if( $error_codes_seen{$error_code}++ ); + + $description =~ s/\\/\\\\/g; + if ($description eq "") { + $description = "DESCRIPTION MISSING"; + warn "Missing description for $error_name\n"; + } + + my ($module_name) = $error_name =~ /^MBEDTLS_ERR_([^_]+)/; + + # Fix faulty ones + $module_name = "BIGNUM" if ($module_name eq "MPI"); + $module_name = "CTR_DRBG" if ($module_name eq "CTR"); + $module_name = "HMAC_DRBG" if ($module_name eq "HMAC"); + + my $define_name = $module_name; + $define_name = "X509_USE,X509_CREATE" if ($define_name eq "X509"); + $define_name = "ASN1_PARSE" if ($define_name eq "ASN1"); + $define_name = "SSL_TLS" if ($define_name eq "SSL"); + $define_name = "PEM_PARSE,PEM_WRITE" if ($define_name eq "PEM"); + + my $include_name = $module_name; + $include_name =~ tr/A-Z/a-z/; + $include_name = "" if ($include_name eq "asn1"); + + # Fix faulty ones + $include_name = "net_sockets" if ($module_name eq "NET"); + + my $found_ll = grep $_ eq $module_name, @low_level_modules; + my $found_hl = grep $_ eq $module_name, @high_level_modules; + if (!$found_ll && !$found_hl) + { + printf("Error: Do not know how to handle: $module_name\n"); + exit 1; + } + + my $code_check; + my $old_define; + my $white_space; + my $first; + + if ($found_ll) + { + $code_check = \$ll_code_check; + $old_define = \$ll_old_define; + $white_space = ' '; + } + else + { + $code_check = \$hl_code_check; + $old_define = \$hl_old_define; + $white_space = ' '; + } + + if ($define_name ne ${$old_define}) + { + if (${$old_define} ne "") + { + ${$code_check} .= "#endif /* "; + $first = 0; + foreach my $dep (split(/,/, ${$old_define})) + { + ${$code_check} .= " || " if ($first++); + ${$code_check} .= "MBEDTLS_${dep}_C"; + } + ${$code_check} .= " */\n\n"; + } + + ${$code_check} .= "#if "; + $headers .= "#if " if ($include_name ne ""); + $first = 0; + foreach my $dep (split(/,/, ${define_name})) + { + ${$code_check} .= " || " if ($first); + $headers .= " || " if ($first++); + + ${$code_check} .= "defined(MBEDTLS_${dep}_C)"; + $headers .= "defined(MBEDTLS_${dep}_C)" if + ($include_name ne ""); + } + ${$code_check} .= "\n"; + $headers .= "\n#include \"mbedtls/${include_name}.h\"\n". + "#endif\n\n" if ($include_name ne ""); + ${$old_define} = $define_name; + } + + if ($error_name eq "MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE") + { + ${$code_check} .= "${white_space}if( use_ret == -($error_name) )\n". + "${white_space}\{\n". + "${white_space} mbedtls_snprintf( buf, buflen, \"$module_name - $description\" );\n". + "${white_space} return;\n". + "${white_space}}\n" + } + else + { + ${$code_check} .= "${white_space}if( use_ret == -($error_name) )\n". + "${white_space} mbedtls_snprintf( buf, buflen, \"$module_name - $description\" );\n" + } +}; + +if ($ll_old_define ne "") +{ + $ll_code_check .= "#endif /* "; + my $first = 0; + foreach my $dep (split(/,/, $ll_old_define)) + { + $ll_code_check .= " || " if ($first++); + $ll_code_check .= "MBEDTLS_${dep}_C"; + } + $ll_code_check .= " */\n"; +} +if ($hl_old_define ne "") +{ + $hl_code_check .= "#endif /* "; + my $first = 0; + foreach my $dep (split(/,/, $hl_old_define)) + { + $hl_code_check .= " || " if ($first++); + $hl_code_check .= "MBEDTLS_${dep}_C"; + } + $hl_code_check .= " */\n"; +} + +$error_format =~ s/HEADER_INCLUDED\n/$headers/g; +$error_format =~ s/LOW_LEVEL_CODE_CHECKS\n/$ll_code_check/g; +$error_format =~ s/HIGH_LEVEL_CODE_CHECKS\n/$hl_code_check/g; + +open(ERROR_FILE, ">$error_file") or die "Opening destination file '$error_file': $!"; +print ERROR_FILE $error_format; +close(ERROR_FILE); diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_features.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_features.pl new file mode 100644 index 0000000..2aa695c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_features.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl +# + +use strict; + +my ($include_dir, $data_dir, $feature_file); + +if( @ARGV ) { + die "Invalid number of arguments" if scalar @ARGV != 3; + ($include_dir, $data_dir, $feature_file) = @ARGV; + + -d $include_dir or die "No such directory: $include_dir\n"; + -d $data_dir or die "No such directory: $data_dir\n"; +} else { + $include_dir = 'include/mbedtls'; + $data_dir = 'scripts/data_files'; + $feature_file = 'library/version_features.c'; + + unless( -d $include_dir && -d $data_dir ) { + chdir '..' or die; + -d $include_dir && -d $data_dir + or die "Without arguments, must be run from root or scripts\n" + } +} + +my $feature_format_file = $data_dir.'/version_features.fmt'; + +my @sections = ( "System support", "mbed TLS modules", + "mbed TLS feature support" ); + +my $line_separator = $/; +undef $/; + +open(FORMAT_FILE, "$feature_format_file") or die "Opening feature format file '$feature_format_file': $!"; +my $feature_format = ; +close(FORMAT_FILE); + +$/ = $line_separator; + +open(CONFIG_H, "$include_dir/config.h") || die("Failure when opening config.h: $!"); + +my $feature_defines = ""; +my $in_section = 0; + +while (my $line = ) +{ + next if ($in_section && $line !~ /#define/ && $line !~ /SECTION/); + next if (!$in_section && $line !~ /SECTION/); + + if ($in_section) { + if ($line =~ /SECTION/) { + $in_section = 0; + next; + } + + my ($define) = $line =~ /#define (\w+)/; + $feature_defines .= "#if defined(${define})\n"; + $feature_defines .= " \"${define}\",\n"; + $feature_defines .= "#endif /* ${define} */\n"; + } + + if (!$in_section) { + my ($section_name) = $line =~ /SECTION: ([\w ]+)/; + my $found_section = grep $_ eq $section_name, @sections; + + $in_section = 1 if ($found_section); + } +}; + +$feature_format =~ s/FEATURE_DEFINES\n/$feature_defines/g; + +open(ERROR_FILE, ">$feature_file") or die "Opening destination file '$feature_file': $!"; +print ERROR_FILE $feature_format; +close(ERROR_FILE); diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_visualc_files.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_visualc_files.pl new file mode 100644 index 0000000..8d36653 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/generate_visualc_files.pl @@ -0,0 +1,195 @@ +#!/usr/bin/perl + +# Generate files for MS Visual Studio: +# - for VS6: main project (library) file, individual app files, workspace +# - for VS2010: main file, individual apps, solution file +# +# Must be run from mbedTLS root or scripts directory. +# Takes no argument. + +use warnings; +use strict; +use Digest::MD5 'md5_hex'; + +my $vsx_dir = "visualc/VS2010"; +my $vsx_ext = "vcxproj"; +my $vsx_app_tpl_file = "scripts/data_files/vs2010-app-template.$vsx_ext"; +my $vsx_main_tpl_file = "scripts/data_files/vs2010-main-template.$vsx_ext"; +my $vsx_main_file = "$vsx_dir/mbedTLS.$vsx_ext"; +my $vsx_sln_tpl_file = "scripts/data_files/vs2010-sln-template.sln"; +my $vsx_sln_file = "$vsx_dir/mbedTLS.sln"; + +my $programs_dir = 'programs'; +my $header_dir = 'include/mbedtls'; +my $source_dir = 'library'; + +# Need windows line endings! +my $vsx_hdr_tpl = <\r +EOT +my $vsx_src_tpl = <\r +EOT + +my $vsx_sln_app_entry_tpl = <; + close $fh; + + return $content; +} + +sub content_to_file { + my ($content, $filename) = @_; + + open my $fh, '>', $filename or die "Could not write to $filename\n"; + print $fh $content; + close $fh; +} + +sub gen_app_guid { + my ($path) = @_; + + my $guid = md5_hex( "mbedTLS:$path" ); + $guid =~ s/(.{8})(.{4})(.{4})(.{4})(.{12})/\U{$1-$2-$3-$4-$5}/; + + return $guid; +} + +sub gen_app { + my ($path, $template, $dir, $ext) = @_; + + my $guid = gen_app_guid( $path ); + $path =~ s!/!\\!g; + (my $appname = $path) =~ s/.*\\//; + + my $content = $template; + $content =~ s//$path/g; + $content =~ s//$appname/g; + $content =~ s//$guid/g; + + content_to_file( $content, "$dir/$appname.$ext" ); +} + +sub get_app_list { + my $app_list = `cd $programs_dir && make list`; + die "make list failed: $!\n" if $?; + + return split /\s+/, $app_list; +} + +sub gen_app_files { + my @app_list = @_; + + my $vsx_tpl = slurp_file( $vsx_app_tpl_file ); + + for my $app ( @app_list ) { + gen_app( $app, $vsx_tpl, $vsx_dir, $vsx_ext ); + } +} + +sub gen_entry_list { + my ($tpl, @names) = @_; + + my $entries; + for my $name (@names) { + (my $entry = $tpl) =~ s/{NAME}/$name/g; + $entries .= $entry; + } + + return $entries; +} + +sub gen_main_file { + my ($headers, $sources, $hdr_tpl, $src_tpl, $main_tpl, $main_out) = @_; + + my $header_entries = gen_entry_list( $hdr_tpl, @$headers ); + my $source_entries = gen_entry_list( $src_tpl, @$sources ); + + my $out = slurp_file( $main_tpl ); + $out =~ s/SOURCE_ENTRIES\r\n/$source_entries/m; + $out =~ s/HEADER_ENTRIES\r\n/$header_entries/m; + + content_to_file( $out, $main_out ); +} + +sub gen_vsx_solution { + my (@app_names) = @_; + + my ($app_entries, $conf_entries); + for my $path (@app_names) { + my $guid = gen_app_guid( $path ); + (my $appname = $path) =~ s!.*/!!; + + my $app_entry = $vsx_sln_app_entry_tpl; + $app_entry =~ s/{APPNAME}/$appname/g; + $app_entry =~ s/{GUID}/$guid/g; + + $app_entries .= $app_entry; + + my $conf_entry = $vsx_sln_conf_entry_tpl; + $conf_entry =~ s/{GUID}/$guid/g; + + $conf_entries .= $conf_entry; + } + + my $out = slurp_file( $vsx_sln_tpl_file ); + $out =~ s/APP_ENTRIES\r\n/$app_entries/m; + $out =~ s/CONF_ENTRIES\r\n/$conf_entries/m; + + content_to_file( $out, $vsx_sln_file ); +} + +sub main { + if( ! check_dirs() ) { + chdir '..' or die; + check_dirs or die "Must but run from mbedTLS root or scripts dir\n"; + } + + my @app_list = get_app_list(); + my @headers = <$header_dir/*.h>; + my @sources = <$source_dir/*.c>; + map { s!/!\\!g } @headers; + map { s!/!\\!g } @sources; + + gen_app_files( @app_list ); + + gen_main_file( \@headers, \@sources, + $vsx_hdr_tpl, $vsx_src_tpl, + $vsx_main_tpl_file, $vsx_main_file ); + + gen_vsx_solution( @app_list ); + + return 0; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/malloc-init.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/malloc-init.pl new file mode 100644 index 0000000..b7d6fcf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/malloc-init.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl + +# Check for malloc calls not shortly followed by initialisation. +# +# Known limitations: +# - false negative: can't see allocations spanning more than one line +# - possible false negatives, see patterns +# - false positive: malloc-malloc-init-init is not accepted +# - false positives: "non-standard" init functions (eg, the things being +# initialised is not the first arg, or initialise struct members) +# +# Since false positives are expected, the results must be manually reviewed. +# +# Typical usage: scripts/malloc-init.pl library/*.c + +use warnings; +use strict; + +use utf8; +use open qw(:std utf8); + +my $limit = 7; +my $inits = qr/memset|memcpy|_init|fread|base64_..code/; + +# cases to bear in mind: +# +# 0. foo = malloc(...); memset( foo, ... ); +# 1. *foo = malloc(...); memset( *foo, ... ); +# 2. type *foo = malloc(...); memset( foo, ...); +# 3. foo = malloc(...); foo_init( (type *) foo ); +# 4. foo = malloc(...); for(i=0..n) { init( &foo[i] ); } +# +# The chosen patterns are a bit relaxed, but unlikely to cause false positives +# in real code (initialising *foo or &foo instead of foo will likely be caught +# by functional tests). +# +my $id = qr/([a-zA-Z-0-9_\->\.]*)/; +my $prefix = qr/\s(?:\*?|\&?|\([a-z_]* \*\))\s*/; + +my $name; +my $line; +my @bad; + +die "Usage: $0 file.c [...]\n" unless @ARGV; + +while (my $file = shift @ARGV) +{ + open my $fh, "<", $file or die "read $file failed: $!\n"; + while (<$fh>) + { + if( /mbedtls_malloc\(/ ) { + if( /$id\s*=.*mbedtls_malloc\(/ ) { + push @bad, "$file:$line:$name" if $name; + $name = $1; + $line = $.; + } else { + push @bad, "$file:$.:???" unless /return mbedtls_malloc/; + } + } elsif( $name && /(?:$inits)\($prefix\Q$name\E\b/ ) { + undef $name; + } elsif( $name && $. - $line > $limit ) { + push @bad, "$file:$line:$name"; + undef $name; + undef $line; + } + } + close $fh or die; +} + +print "$_\n" for @bad; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/massif_max.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/massif_max.pl new file mode 100644 index 0000000..d1ce4ca --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/massif_max.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +# Parse a massif.out.xxx file and output peak total memory usage + +use warnings; +use strict; + +use utf8; +use open qw(:std utf8); + +die unless @ARGV == 1; + +my @snaps; +open my $fh, '<', $ARGV[0] or die; +{ local $/ = 'snapshot='; @snaps = <$fh>; } +close $fh or die; + +my ($max, $max_heap, $max_he, $max_stack) = (0, 0, 0, 0); +for (@snaps) +{ + my ($heap, $heap_extra, $stack) = m{ + mem_heap_B=(\d+)\n + mem_heap_extra_B=(\d+)\n + mem_stacks_B=(\d+) + }xm; + next unless defined $heap; + my $total = $heap + $heap_extra + $stack; + if( $total > $max ) { + ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); + } +} + +printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/memory.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/memory.sh new file mode 100644 index 0000000..3dad289 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/memory.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +# Measure memory usage of a minimal client using a small configuration +# Currently hardwired to ccm-psk and suite-b, may be expanded later +# +# Use different build options for measuring executable size and memory usage, +# since for memory we want debug information. + +set -eu + +CONFIG_H='include/mbedtls/config.h' + +CLIENT='mini_client' + +CFLAGS_EXEC='-fno-asynchronous-unwind-tables -Wl,--gc-section -ffunction-sections -fdata-sections' +CFLAGS_MEM=-g3 + +if [ -r $CONFIG_H ]; then :; else + echo "$CONFIG_H not found" >&2 + exit 1 +fi + +if grep -i cmake Makefile >/dev/null; then + echo "Not compatible with CMake" >&2 + exit 1 +fi + +if [ $( uname ) != Linux ]; then + echo "Only work on Linux" >&2 + exit 1 +fi + +if git status | grep -F $CONFIG_H >/dev/null 2>&1; then + echo "config.h not clean" >&2 + exit 1 +fi + +# make measurements with one configuration +# usage: do_config +do_config() +{ + NAME=$1 + UNSET_LIST=$2 + SERVER_ARGS=$3 + + echo "" + echo "config-$NAME:" + cp configs/config-$NAME.h $CONFIG_H + scripts/config.pl unset MBEDTLS_SSL_SRV_C + + for FLAG in $UNSET_LIST; do + scripts/config.pl unset $FLAG + done + + grep -F SSL_MAX_CONTENT_LEN $CONFIG_H || echo 'SSL_MAX_CONTENT_LEN=16384' + + printf " Executable size... " + + make clean + CFLAGS=$CFLAGS_EXEC make OFLAGS=-Os lib >/dev/null 2>&1 + cd programs + CFLAGS=$CFLAGS_EXEC make OFLAGS=-Os ssl/$CLIENT >/dev/null + strip ssl/$CLIENT + stat -c '%s' ssl/$CLIENT + cd .. + + printf " Peak ram usage... " + + make clean + CFLAGS=$CFLAGS_MEM make OFLAGS=-Os lib >/dev/null 2>&1 + cd programs + CFLAGS=$CFLAGS_MEM make OFLAGS=-Os ssl/$CLIENT >/dev/null + cd .. + + ./ssl_server2 $SERVER_ARGS >/dev/null & + SRV_PID=$! + sleep 1; + + if valgrind --tool=massif --stacks=yes programs/ssl/$CLIENT >/dev/null 2>&1 + then + FAILED=0 + else + echo "client failed" >&2 + FAILED=1 + fi + + kill $SRV_PID + wait $SRV_PID + + scripts/massif_max.pl massif.out.* + mv massif.out.* massif-$NAME.$$ +} + +# preparation + +CONFIG_BAK=${CONFIG_H}.bak +cp $CONFIG_H $CONFIG_BAK + +rm -f massif.out.* + +printf "building server... " + +make clean +make lib >/dev/null 2>&1 +(cd programs && make ssl/ssl_server2) >/dev/null +cp programs/ssl/ssl_server2 . + +echo "done" + +# actual measurements + +do_config "ccm-psk-tls1_2" \ + "" \ + "psk=000102030405060708090A0B0C0D0E0F" + +do_config "suite-b" \ + "MBEDTLS_BASE64_C MBEDTLS_PEM_PARSE_C MBEDTLS_CERTS_C" \ + "" + +# cleanup + +mv $CONFIG_BAK $CONFIG_H +make clean +rm ssl_server2 + +exit $FAILED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/output_env.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/output_env.sh new file mode 100644 index 0000000..1afaac3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/output_env.sh @@ -0,0 +1,114 @@ +#! /usr/bin/env sh + +# output_env.sh +# +# This file is part of mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2016, ARM Limited, All Rights Reserved +# +# Purpose +# +# To print out all the relevant information about the development environment. +# +# This includes: +# - architecture of the system +# - type and version of the operating system +# - version of armcc, clang, gcc-arm and gcc compilers +# - version of libc, clang, asan and valgrind if installed +# - version of gnuTLS and OpenSSL + +print_version() +{ + BIN="$1" + shift + ARGS="$1" + shift + FAIL_MSG="$1" + shift + + if ! `type "$BIN" > /dev/null 2>&1`; then + echo "* $FAIL_MSG" + return 0 + fi + + BIN=`which "$BIN"` + VERSION_STR=`$BIN $ARGS 2>&1` + + # Apply all filters + while [ $# -gt 0 ]; do + FILTER="$1" + shift + VERSION_STR=`echo "$VERSION_STR" | $FILTER` + done + + echo "* ${BIN##*/}: $BIN: $VERSION_STR" +} + +print_version "uname" "-a" "" +echo + +: ${ARMC5_CC:=armcc} +print_version "$ARMC5_CC" "--vsn" "armcc not found!" "head -n 2" +echo + +: ${ARMC6_CC:=armclang} +print_version "$ARMC6_CC" "--vsn" "armclang not found!" "head -n 2" +echo + +print_version "arm-none-eabi-gcc" "--version" "gcc-arm not found!" "head -n 1" +echo + +print_version "gcc" "--version" "gcc not found!" "head -n 1" +echo + +print_version "clang" "--version" "clang not found" "head -n 2" +echo + +print_version "ldd" "--version" \ + "No ldd present: can't determine libc version!" \ + "head -n 1" +echo + +print_version "valgrind" "--version" "valgrind not found!" +echo + +: ${OPENSSL:=openssl} +print_version "$OPENSSL" "version" "openssl not found!" +echo + +if [ -n "${OPENSSL_LEGACY+set}" ]; then + print_version "$OPENSSL_LEGACY" "version" "openssl legacy version not found!" + echo +fi + +: ${GNUTLS_CLI:=gnutls-cli} +print_version "$GNUTLS_CLI" "--version" "gnuTLS client not found!" "head -n 1" +echo + +: ${GNUTLS_SERV:=gnutls-serv} +print_version "$GNUTLS_SERV" "--version" "gnuTLS server not found!" "head -n 1" +echo + +if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then + print_version "$GNUTLS_LEGACY_CLI" "--version" \ + "gnuTLS client legacy version not found!" \ + "head -n 1" + echo +fi + +if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then + print_version "$GNUTLS_LEGACY_SERV" "--version" \ + "gnuTLS server legacy version not found!" \ + "head -n 1" + echo +fi + +if `hash dpkg > /dev/null 2>&1`; then + echo "* asan:" + dpkg -s libasan2 2> /dev/null | grep -i version + dpkg -s libasan1 2> /dev/null | grep -i version + dpkg -s libasan0 2> /dev/null | grep -i version +else + echo "* No dpkg present: can't determine asan version!" +fi +echo diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rename.pl b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rename.pl new file mode 100644 index 0000000..c29519e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rename.pl @@ -0,0 +1,122 @@ +#!/usr/bin/perl +# +# This file is part of mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved +# +# Purpose +# +# This script migrates application source code from the mbed TLS 1.3 API to the +# mbed TLS 2.0 API. +# +# The script processes the given source code and renames identifiers - functions +# types, enums etc, as +# +# Usage: rename.pl [-f datafile] [-s] [--] [filenames...] +# + +use warnings; +use strict; + +use utf8; +use Path::Class; +use open qw(:std utf8); + +my $usage = "Usage: $0 [-f datafile] [-s] [--] [filenames...]\n"; + +(my $datafile = $0) =~ s/rename.pl$/data_files\/rename-1.3-2.0.txt/; +my $do_strings = 0; + +while( @ARGV && $ARGV[0] =~ /^-/ ) { + my $opt = shift; + if( $opt eq '--' ) { + last; + } elsif( $opt eq '-f' ) { + $datafile = shift; + } elsif( $opt eq '-s' ) { + $do_strings = 1; shift; + } else { + die $usage; + } +} + +my %subst; +open my $nfh, '<', $datafile or die "Could not read $datafile\n"; +my $ident = qr/[_A-Za-z][_A-Za-z0-9]*/; +while( my $line = <$nfh> ) { + chomp $line; + my ( $old, $new ) = ( $line =~ /^($ident)\s+($ident)$/ ); + if( ! $old || ! $new ) { + die "$0: $datafile:$.: bad input '$line'\n"; + } + $subst{$old} = $new; +} +close $nfh or die; + +my $string = qr/"(?:\\.|[^\\"])*"/; +my $space = qr/\s+/; +my $idnum = qr/[a-zA-Z0-9_]+/; +my $symbols = qr/[-!#\$%&'()*+,.\/:;<=>?@[\\\]^_`{|}~]+|"/; + +my $lib_include_dir = dir($0)->parent->parent->subdir('include', 'mbedtls'); +my $lib_source_dir = dir($0)->parent->parent->subdir('library'); + +# if we replace inside strings, we don't consider them a token +my $token = $do_strings ? qr/$space|$idnum|$symbols/ + : qr/$string|$space|$idnum|$symbols/; + +my %warnings; + +# If no files were passed, exit... +if ( not defined($ARGV[0]) ){ die $usage; } + +while( my $filename = shift ) +{ + print STDERR "$filename... "; + + if( dir($filename)->parent eq $lib_include_dir || + dir($filename)->parent eq $lib_source_dir ) + { + die "Script cannot be executed on the mbed TLS library itself."; + } + + if( -d $filename ) { print STDERR "skip (directory)\n"; next } + + open my $rfh, '<', $filename or die; + my @lines = <$rfh>; + close $rfh or die; + + my @out; + for my $line (@lines) { + if( $line =~ /#include/ ) { + $line =~ s/polarssl/mbedtls/; + $line =~ s/POLARSSL/MBEDTLS/; + push( @out, $line ); + next; + } + + my @words = ($line =~ /$token/g); + my $checkline = join '', @words; + if( $checkline eq $line ) { + my @new = map { exists $subst{$_} ? $subst{$_} : $_ } @words; + push( @out, join '', @new ); + } else { + $warnings{$filename} = [] unless $warnings{$filename}; + push @{ $warnings{$filename} }, $line; + push( @out, $line ); + } + } + + open my $wfh, '>', $filename or die; + print $wfh $_ for @out; + close $wfh or die; + print STDERR "done\n"; +} + +if( %warnings ) { + print "\nWarning: lines skipped due to unexpected characters:\n"; + for my $filename (sort keys %warnings) { + print "in $filename:\n"; + print for @{ $warnings{$filename} }; + } +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rm-malloc-cast.cocci b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rm-malloc-cast.cocci new file mode 100644 index 0000000..9337dc5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/rm-malloc-cast.cocci @@ -0,0 +1,7 @@ +@rm_malloc_cast@ +expression x, n; +type T; +@@ + x = +- (T *) + mbedtls_malloc(n) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/tmp_ignore_makefiles.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/tmp_ignore_makefiles.sh new file mode 100644 index 0000000..df9450e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/scripts/tmp_ignore_makefiles.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Temporarily (de)ignore Makefiles generated by CMake to allow easier +# git development + +IGNORE="" + +# Parse arguments +# +until [ -z "$1" ] +do + case "$1" in + -u|--undo) + IGNORE="0" + ;; + -v|--verbose) + # Be verbose + VERBOSE="1" + ;; + -h|--help) + # print help + echo "Usage: $0" + echo -e " -h|--help\t\tPrint this help." + echo -e " -u|--undo\t\tRemove ignores and continue tracking." + echo -e " -v|--verbose\t\tVerbose." + exit 1 + ;; + *) + # print error + echo "Unknown argument: '$1'" + exit 1 + ;; + esac + shift +done + +if [ "X" = "X$IGNORE" ]; +then + [ $VERBOSE ] && echo "Ignoring Makefiles" + git update-index --assume-unchanged Makefile library/Makefile programs/Makefile tests/Makefile +else + [ $VERBOSE ] && echo "Tracking Makefiles" + git update-index --no-assume-unchanged Makefile library/Makefile programs/Makefile tests/Makefile +fi diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/aescrypt2.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/aescrypt2.vcxproj new file mode 100644 index 0000000..a77c4cf --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/aescrypt2.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8} + Win32Proj + aescrypt2 + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/benchmark.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/benchmark.vcxproj new file mode 100644 index 0000000..93cd217 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/benchmark.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA} + Win32Proj + benchmark + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_app.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_app.vcxproj new file mode 100644 index 0000000..6d410db --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_app.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {D4D691D4-137C-CBFA-735B-D46636D7E4D8} + Win32Proj + cert_app + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_req.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_req.vcxproj new file mode 100644 index 0000000..8710bac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_req.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE} + Win32Proj + cert_req + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_write.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_write.vcxproj new file mode 100644 index 0000000..dd19014 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/cert_write.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {35E52E46-3BA9-4361-41D3-53663C2E9B8A} + Win32Proj + cert_write + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crl_app.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crl_app.vcxproj new file mode 100644 index 0000000..c0e1f7a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crl_app.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {DB904B85-AD31-B7FB-114F-88760CC485F2} + Win32Proj + crl_app + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crypt_and_hash.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crypt_and_hash.vcxproj new file mode 100644 index 0000000..680fb7d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/crypt_and_hash.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7} + Win32Proj + crypt_and_hash + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_client.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_client.vcxproj new file mode 100644 index 0000000..243ace9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_client.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE} + Win32Proj + dh_client + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_genprime.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_genprime.vcxproj new file mode 100644 index 0000000..9efb391 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_genprime.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {718960D9-5DA6-7B56-39AD-637E81076C71} + Win32Proj + dh_genprime + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_server.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_server.vcxproj new file mode 100644 index 0000000..7efbfa2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dh_server.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {8D91B804-E2CE-142D-8E06-FBB037ED1F65} + Win32Proj + dh_server + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_client.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_client.vcxproj new file mode 100644 index 0000000..37467d0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_client.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5} + Win32Proj + dtls_client + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_server.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_server.vcxproj new file mode 100644 index 0000000..4f7dff9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/dtls_server.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317} + Win32Proj + dtls_server + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdh_curve25519.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdh_curve25519.vcxproj new file mode 100644 index 0000000..d775736 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdh_curve25519.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {82EE497E-12CC-7C5B-A072-665678ACB43E} + Win32Proj + ecdh_curve25519 + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdsa.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdsa.vcxproj new file mode 100644 index 0000000..1a5d3de --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ecdsa.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E} + Win32Proj + ecdsa + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_entropy.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_entropy.vcxproj new file mode 100644 index 0000000..2f274f0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_entropy.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {DE695064-13C3-18B0-378D-8B22672BF3F4} + Win32Proj + gen_entropy + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_key.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_key.vcxproj new file mode 100644 index 0000000..96a10f1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_key.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52} + Win32Proj + gen_key + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_ctr_drbg.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_ctr_drbg.vcxproj new file mode 100644 index 0000000..6bf8731 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_ctr_drbg.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E} + Win32Proj + gen_random_ctr_drbg + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_havege.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_havege.vcxproj new file mode 100644 index 0000000..7885979 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/gen_random_havege.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {71257802-BBCA-99F5-E9D2-905738F30893} + Win32Proj + gen_random_havege + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/generic_sum.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/generic_sum.vcxproj new file mode 100644 index 0000000..6405d5e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/generic_sum.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {D071CCF7-ACA0-21F8-D382-52A759AEA261} + Win32Proj + generic_sum + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/hello.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/hello.vcxproj new file mode 100644 index 0000000..099cb69 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/hello.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D} + Win32Proj + hello + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app.vcxproj new file mode 100644 index 0000000..5181dda --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {10AE376F-1A70-0297-0216-1FD01AD15D19} + Win32Proj + key_app + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app_writer.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app_writer.vcxproj new file mode 100644 index 0000000..4edb569 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/key_app_writer.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8} + Win32Proj + key_app_writer + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.sln b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.sln new file mode 100644 index 0000000..4fa986c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.sln @@ -0,0 +1,637 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbedTLS", "mbedTLS.vcxproj", "{46CF2D25-6A36-4189-B59C-E4815388E554}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aescrypt2", "aescrypt2.vcxproj", "{7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypt_and_hash", "crypt_and_hash.vcxproj", "{5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello", "hello.vcxproj", "{B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "generic_sum", "generic_sum.vcxproj", "{D071CCF7-ACA0-21F8-D382-52A759AEA261}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dh_client", "dh_client.vcxproj", "{4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dh_genprime", "dh_genprime.vcxproj", "{718960D9-5DA6-7B56-39AD-637E81076C71}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dh_server", "dh_server.vcxproj", "{8D91B804-E2CE-142D-8E06-FBB037ED1F65}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecdh_curve25519", "ecdh_curve25519.vcxproj", "{82EE497E-12CC-7C5B-A072-665678ACB43E}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecdsa", "ecdsa.vcxproj", "{F58142CC-0CC7-0B18-5A0F-53642CFBA18E}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_key", "gen_key.vcxproj", "{BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "key_app", "key_app.vcxproj", "{10AE376F-1A70-0297-0216-1FD01AD15D19}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "key_app_writer", "key_app_writer.vcxproj", "{E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpi_demo", "mpi_demo.vcxproj", "{A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pk_decrypt", "pk_decrypt.vcxproj", "{1EC6CBA3-6187-D456-D9B7-A35399395D71}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pk_encrypt", "pk_encrypt.vcxproj", "{55007179-7746-9CFB-97EC-65102FB272C8}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pk_sign", "pk_sign.vcxproj", "{F2E8CA55-597F-7FDC-6456-D8650FB970A3}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pk_verify", "pk_verify.vcxproj", "{C429B336-1B30-119C-3B34-21A186D6744F}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_genkey", "rsa_genkey.vcxproj", "{F472475C-F677-0E7F-F127-45BF5B64F622}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_decrypt", "rsa_decrypt.vcxproj", "{E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_encrypt", "rsa_encrypt.vcxproj", "{D06CF12E-F222-9273-41BF-B8A052FA5527}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_sign", "rsa_sign.vcxproj", "{10790F49-6887-AAB6-2D86-BCBD516F8D26}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_verify", "rsa_verify.vcxproj", "{689E28CF-89ED-BA38-3A14-78A75D891D46}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_sign_pss", "rsa_sign_pss.vcxproj", "{DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa_verify_pss", "rsa_verify_pss.vcxproj", "{95C50864-854C-2A11-4C91-BCE654E344FB}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dtls_client", "dtls_client.vcxproj", "{FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dtls_server", "dtls_server.vcxproj", "{BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_client1", "ssl_client1.vcxproj", "{487A2F80-3CA3-678D-88D5-82194872CF08}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_client2", "ssl_client2.vcxproj", "{4E590E9D-E28F-87FF-385B-D58736388231}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_server", "ssl_server.vcxproj", "{E08E0065-896A-7487-DEA5-D3B80B71F975}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_server2", "ssl_server2.vcxproj", "{A4DA7463-1047-BDF5-E1B3-5632CB573F41}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_fork_server", "ssl_fork_server.vcxproj", "{918CD402-047D-8467-E11C-E1132053F916}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mini_client", "mini_client.vcxproj", "{C4FE29EA-266D-5295-4840-976B9B5B3843}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_mail_client", "ssl_mail_client.vcxproj", "{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_entropy", "gen_entropy.vcxproj", "{DE695064-13C3-18B0-378D-8B22672BF3F4}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_random_havege", "gen_random_havege.vcxproj", "{71257802-BBCA-99F5-E9D2-905738F30893}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_random_ctr_drbg", "gen_random_ctr_drbg.vcxproj", "{5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_cert_test", "ssl_cert_test.vcxproj", "{3FE0C0E1-D9BA-6A26-380C-F293E543B914}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcxproj", "{90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "selftest", "selftest.vcxproj", "{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udp_proxy", "udp_proxy.vcxproj", "{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pem2der", "pem2der.vcxproj", "{D3C6FBD6-D78E-7180-8345-5E09B492DBEC}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strerror", "strerror.vcxproj", "{23EF735C-CC4C-3EC4-A75E-903DB340F04A}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cert_app", "cert_app.vcxproj", "{D4D691D4-137C-CBFA-735B-D46636D7E4D8}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crl_app", "crl_app.vcxproj", "{DB904B85-AD31-B7FB-114F-88760CC485F2}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cert_req", "cert_req.vcxproj", "{C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cert_write", "cert_write.vcxproj", "{35E52E46-3BA9-4361-41D3-53663C2E9B8A}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "req_app", "req_app.vcxproj", "{486B1375-5CFA-C2D2-DD89-C9F497BADCB3}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|Win32.ActiveCfg = Debug|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|Win32.Build.0 = Debug|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|x64.ActiveCfg = Debug|x64 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Debug|x64.Build.0 = Debug|x64 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|Win32.ActiveCfg = Release|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|Win32.Build.0 = Release|Win32 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|x64.ActiveCfg = Release|x64 + {46CF2D25-6A36-4189-B59C-E4815388E554}.Release|x64.Build.0 = Release|x64 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Debug|Win32.Build.0 = Debug|Win32 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Debug|x64.ActiveCfg = Debug|x64 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Debug|x64.Build.0 = Debug|x64 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Release|Win32.ActiveCfg = Release|Win32 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Release|Win32.Build.0 = Release|Win32 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Release|x64.ActiveCfg = Release|x64 + {7A851DBD-7D57-E8F4-85E5-CCA72AEA7DF8}.Release|x64.Build.0 = Release|x64 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Debug|Win32.ActiveCfg = Debug|Win32 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Debug|Win32.Build.0 = Debug|Win32 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Debug|x64.ActiveCfg = Debug|x64 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Debug|x64.Build.0 = Debug|x64 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Release|Win32.ActiveCfg = Release|Win32 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Release|Win32.Build.0 = Release|Win32 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Release|x64.ActiveCfg = Release|x64 + {5DBB9FC3-6FD6-CA8D-E0FA-35F1E75EFAE7}.Release|x64.Build.0 = Release|x64 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Debug|Win32.Build.0 = Debug|Win32 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Debug|x64.ActiveCfg = Debug|x64 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Debug|x64.Build.0 = Debug|x64 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Release|Win32.ActiveCfg = Release|Win32 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Release|Win32.Build.0 = Release|Win32 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Release|x64.ActiveCfg = Release|x64 + {B02D4AE1-0218-1CD4-F44E-EFAE19B01B8D}.Release|x64.Build.0 = Release|x64 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Debug|Win32.ActiveCfg = Debug|Win32 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Debug|Win32.Build.0 = Debug|Win32 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Debug|x64.ActiveCfg = Debug|x64 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Debug|x64.Build.0 = Debug|x64 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Release|Win32.ActiveCfg = Release|Win32 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Release|Win32.Build.0 = Release|Win32 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Release|x64.ActiveCfg = Release|x64 + {D071CCF7-ACA0-21F8-D382-52A759AEA261}.Release|x64.Build.0 = Release|x64 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Debug|Win32.ActiveCfg = Debug|Win32 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Debug|Win32.Build.0 = Debug|Win32 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Debug|x64.ActiveCfg = Debug|x64 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Debug|x64.Build.0 = Debug|x64 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Release|Win32.ActiveCfg = Release|Win32 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Release|Win32.Build.0 = Release|Win32 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Release|x64.ActiveCfg = Release|x64 + {4D29BE4A-979C-C5AE-44B5-30FB37D8D4EE}.Release|x64.Build.0 = Release|x64 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Debug|Win32.ActiveCfg = Debug|Win32 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Debug|Win32.Build.0 = Debug|Win32 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Debug|x64.ActiveCfg = Debug|x64 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Debug|x64.Build.0 = Debug|x64 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Release|Win32.ActiveCfg = Release|Win32 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Release|Win32.Build.0 = Release|Win32 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Release|x64.ActiveCfg = Release|x64 + {718960D9-5DA6-7B56-39AD-637E81076C71}.Release|x64.Build.0 = Release|x64 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Debug|Win32.ActiveCfg = Debug|Win32 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Debug|Win32.Build.0 = Debug|Win32 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Debug|x64.ActiveCfg = Debug|x64 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Debug|x64.Build.0 = Debug|x64 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Release|Win32.ActiveCfg = Release|Win32 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Release|Win32.Build.0 = Release|Win32 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Release|x64.ActiveCfg = Release|x64 + {8D91B804-E2CE-142D-8E06-FBB037ED1F65}.Release|x64.Build.0 = Release|x64 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Debug|Win32.ActiveCfg = Debug|Win32 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Debug|Win32.Build.0 = Debug|Win32 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Debug|x64.ActiveCfg = Debug|x64 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Debug|x64.Build.0 = Debug|x64 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Release|Win32.ActiveCfg = Release|Win32 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Release|Win32.Build.0 = Release|Win32 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Release|x64.ActiveCfg = Release|x64 + {82EE497E-12CC-7C5B-A072-665678ACB43E}.Release|x64.Build.0 = Release|x64 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Debug|Win32.ActiveCfg = Debug|Win32 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Debug|Win32.Build.0 = Debug|Win32 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Debug|x64.ActiveCfg = Debug|x64 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Debug|x64.Build.0 = Debug|x64 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Release|Win32.ActiveCfg = Release|Win32 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Release|Win32.Build.0 = Release|Win32 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Release|x64.ActiveCfg = Release|x64 + {F58142CC-0CC7-0B18-5A0F-53642CFBA18E}.Release|x64.Build.0 = Release|x64 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Debug|Win32.ActiveCfg = Debug|Win32 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Debug|Win32.Build.0 = Debug|Win32 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Debug|x64.ActiveCfg = Debug|x64 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Debug|x64.Build.0 = Debug|x64 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Release|Win32.ActiveCfg = Release|Win32 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Release|Win32.Build.0 = Release|Win32 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Release|x64.ActiveCfg = Release|x64 + {BF782A50-E9AE-00CC-C28A-C9DA8AAB4D52}.Release|x64.Build.0 = Release|x64 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Debug|Win32.ActiveCfg = Debug|Win32 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Debug|Win32.Build.0 = Debug|Win32 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Debug|x64.ActiveCfg = Debug|x64 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Debug|x64.Build.0 = Debug|x64 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Release|Win32.ActiveCfg = Release|Win32 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Release|Win32.Build.0 = Release|Win32 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Release|x64.ActiveCfg = Release|x64 + {10AE376F-1A70-0297-0216-1FD01AD15D19}.Release|x64.Build.0 = Release|x64 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Debug|Win32.ActiveCfg = Debug|Win32 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Debug|Win32.Build.0 = Debug|Win32 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Debug|x64.ActiveCfg = Debug|x64 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Debug|x64.Build.0 = Debug|x64 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Release|Win32.ActiveCfg = Release|Win32 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Release|Win32.Build.0 = Release|Win32 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Release|x64.ActiveCfg = Release|x64 + {E8ED79F9-8034-1B09-263E-D3F8C4C5C4A8}.Release|x64.Build.0 = Release|x64 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Debug|Win32.ActiveCfg = Debug|Win32 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Debug|Win32.Build.0 = Debug|Win32 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Debug|x64.ActiveCfg = Debug|x64 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Debug|x64.Build.0 = Debug|x64 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Release|Win32.ActiveCfg = Release|Win32 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Release|Win32.Build.0 = Release|Win32 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Release|x64.ActiveCfg = Release|x64 + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE}.Release|x64.Build.0 = Release|x64 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Debug|Win32.ActiveCfg = Debug|Win32 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Debug|Win32.Build.0 = Debug|Win32 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Debug|x64.ActiveCfg = Debug|x64 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Debug|x64.Build.0 = Debug|x64 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Release|Win32.ActiveCfg = Release|Win32 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Release|Win32.Build.0 = Release|Win32 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Release|x64.ActiveCfg = Release|x64 + {1EC6CBA3-6187-D456-D9B7-A35399395D71}.Release|x64.Build.0 = Release|x64 + {55007179-7746-9CFB-97EC-65102FB272C8}.Debug|Win32.ActiveCfg = Debug|Win32 + {55007179-7746-9CFB-97EC-65102FB272C8}.Debug|Win32.Build.0 = Debug|Win32 + {55007179-7746-9CFB-97EC-65102FB272C8}.Debug|x64.ActiveCfg = Debug|x64 + {55007179-7746-9CFB-97EC-65102FB272C8}.Debug|x64.Build.0 = Debug|x64 + {55007179-7746-9CFB-97EC-65102FB272C8}.Release|Win32.ActiveCfg = Release|Win32 + {55007179-7746-9CFB-97EC-65102FB272C8}.Release|Win32.Build.0 = Release|Win32 + {55007179-7746-9CFB-97EC-65102FB272C8}.Release|x64.ActiveCfg = Release|x64 + {55007179-7746-9CFB-97EC-65102FB272C8}.Release|x64.Build.0 = Release|x64 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Debug|Win32.Build.0 = Debug|Win32 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Debug|x64.ActiveCfg = Debug|x64 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Debug|x64.Build.0 = Debug|x64 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Release|Win32.ActiveCfg = Release|Win32 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Release|Win32.Build.0 = Release|Win32 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Release|x64.ActiveCfg = Release|x64 + {F2E8CA55-597F-7FDC-6456-D8650FB970A3}.Release|x64.Build.0 = Release|x64 + {C429B336-1B30-119C-3B34-21A186D6744F}.Debug|Win32.ActiveCfg = Debug|Win32 + {C429B336-1B30-119C-3B34-21A186D6744F}.Debug|Win32.Build.0 = Debug|Win32 + {C429B336-1B30-119C-3B34-21A186D6744F}.Debug|x64.ActiveCfg = Debug|x64 + {C429B336-1B30-119C-3B34-21A186D6744F}.Debug|x64.Build.0 = Debug|x64 + {C429B336-1B30-119C-3B34-21A186D6744F}.Release|Win32.ActiveCfg = Release|Win32 + {C429B336-1B30-119C-3B34-21A186D6744F}.Release|Win32.Build.0 = Release|Win32 + {C429B336-1B30-119C-3B34-21A186D6744F}.Release|x64.ActiveCfg = Release|x64 + {C429B336-1B30-119C-3B34-21A186D6744F}.Release|x64.Build.0 = Release|x64 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Debug|Win32.ActiveCfg = Debug|Win32 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Debug|Win32.Build.0 = Debug|Win32 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Debug|x64.ActiveCfg = Debug|x64 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Debug|x64.Build.0 = Debug|x64 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Release|Win32.ActiveCfg = Release|Win32 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Release|Win32.Build.0 = Release|Win32 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Release|x64.ActiveCfg = Release|x64 + {F472475C-F677-0E7F-F127-45BF5B64F622}.Release|x64.Build.0 = Release|x64 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Debug|Win32.ActiveCfg = Debug|Win32 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Debug|Win32.Build.0 = Debug|Win32 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Debug|x64.ActiveCfg = Debug|x64 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Debug|x64.Build.0 = Debug|x64 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Release|Win32.ActiveCfg = Release|Win32 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Release|Win32.Build.0 = Release|Win32 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Release|x64.ActiveCfg = Release|x64 + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9}.Release|x64.Build.0 = Release|x64 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Debug|Win32.ActiveCfg = Debug|Win32 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Debug|Win32.Build.0 = Debug|Win32 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Debug|x64.ActiveCfg = Debug|x64 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Debug|x64.Build.0 = Debug|x64 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Release|Win32.ActiveCfg = Release|Win32 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Release|Win32.Build.0 = Release|Win32 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Release|x64.ActiveCfg = Release|x64 + {D06CF12E-F222-9273-41BF-B8A052FA5527}.Release|x64.Build.0 = Release|x64 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Debug|Win32.ActiveCfg = Debug|Win32 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Debug|Win32.Build.0 = Debug|Win32 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Debug|x64.ActiveCfg = Debug|x64 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Debug|x64.Build.0 = Debug|x64 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Release|Win32.ActiveCfg = Release|Win32 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Release|Win32.Build.0 = Release|Win32 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Release|x64.ActiveCfg = Release|x64 + {10790F49-6887-AAB6-2D86-BCBD516F8D26}.Release|x64.Build.0 = Release|x64 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Debug|Win32.ActiveCfg = Debug|Win32 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Debug|Win32.Build.0 = Debug|Win32 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Debug|x64.ActiveCfg = Debug|x64 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Debug|x64.Build.0 = Debug|x64 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Release|Win32.ActiveCfg = Release|Win32 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Release|Win32.Build.0 = Release|Win32 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Release|x64.ActiveCfg = Release|x64 + {689E28CF-89ED-BA38-3A14-78A75D891D46}.Release|x64.Build.0 = Release|x64 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Debug|Win32.ActiveCfg = Debug|Win32 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Debug|Win32.Build.0 = Debug|Win32 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Debug|x64.ActiveCfg = Debug|x64 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Debug|x64.Build.0 = Debug|x64 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Release|Win32.ActiveCfg = Release|Win32 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Release|Win32.Build.0 = Release|Win32 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Release|x64.ActiveCfg = Release|x64 + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D}.Release|x64.Build.0 = Release|x64 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Debug|Win32.ActiveCfg = Debug|Win32 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Debug|Win32.Build.0 = Debug|Win32 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Debug|x64.ActiveCfg = Debug|x64 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Debug|x64.Build.0 = Debug|x64 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Release|Win32.ActiveCfg = Release|Win32 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Release|Win32.Build.0 = Release|Win32 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Release|x64.ActiveCfg = Release|x64 + {95C50864-854C-2A11-4C91-BCE654E344FB}.Release|x64.Build.0 = Release|x64 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Debug|Win32.ActiveCfg = Debug|Win32 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Debug|Win32.Build.0 = Debug|Win32 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Debug|x64.ActiveCfg = Debug|x64 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Debug|x64.Build.0 = Debug|x64 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Release|Win32.ActiveCfg = Release|Win32 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Release|Win32.Build.0 = Release|Win32 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Release|x64.ActiveCfg = Release|x64 + {FE7AB78F-DBF1-0721-3522-0D7C3011D2E5}.Release|x64.Build.0 = Release|x64 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Debug|Win32.ActiveCfg = Debug|Win32 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Debug|Win32.Build.0 = Debug|Win32 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Debug|x64.ActiveCfg = Debug|x64 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Debug|x64.Build.0 = Debug|x64 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Release|Win32.ActiveCfg = Release|Win32 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Release|Win32.Build.0 = Release|Win32 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Release|x64.ActiveCfg = Release|x64 + {BFE89EAA-D98B-34E1-C5A4-4080F6FFE317}.Release|x64.Build.0 = Release|x64 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Debug|Win32.ActiveCfg = Debug|Win32 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Debug|Win32.Build.0 = Debug|Win32 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Debug|x64.ActiveCfg = Debug|x64 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Debug|x64.Build.0 = Debug|x64 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Release|Win32.ActiveCfg = Release|Win32 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Release|Win32.Build.0 = Release|Win32 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Release|x64.ActiveCfg = Release|x64 + {487A2F80-3CA3-678D-88D5-82194872CF08}.Release|x64.Build.0 = Release|x64 + {4E590E9D-E28F-87FF-385B-D58736388231}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E590E9D-E28F-87FF-385B-D58736388231}.Debug|Win32.Build.0 = Debug|Win32 + {4E590E9D-E28F-87FF-385B-D58736388231}.Debug|x64.ActiveCfg = Debug|x64 + {4E590E9D-E28F-87FF-385B-D58736388231}.Debug|x64.Build.0 = Debug|x64 + {4E590E9D-E28F-87FF-385B-D58736388231}.Release|Win32.ActiveCfg = Release|Win32 + {4E590E9D-E28F-87FF-385B-D58736388231}.Release|Win32.Build.0 = Release|Win32 + {4E590E9D-E28F-87FF-385B-D58736388231}.Release|x64.ActiveCfg = Release|x64 + {4E590E9D-E28F-87FF-385B-D58736388231}.Release|x64.Build.0 = Release|x64 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Debug|Win32.ActiveCfg = Debug|Win32 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Debug|Win32.Build.0 = Debug|Win32 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Debug|x64.ActiveCfg = Debug|x64 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Debug|x64.Build.0 = Debug|x64 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Release|Win32.ActiveCfg = Release|Win32 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Release|Win32.Build.0 = Release|Win32 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Release|x64.ActiveCfg = Release|x64 + {E08E0065-896A-7487-DEA5-D3B80B71F975}.Release|x64.Build.0 = Release|x64 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Debug|Win32.ActiveCfg = Debug|Win32 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Debug|Win32.Build.0 = Debug|Win32 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Debug|x64.ActiveCfg = Debug|x64 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Debug|x64.Build.0 = Debug|x64 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Release|Win32.ActiveCfg = Release|Win32 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Release|Win32.Build.0 = Release|Win32 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Release|x64.ActiveCfg = Release|x64 + {A4DA7463-1047-BDF5-E1B3-5632CB573F41}.Release|x64.Build.0 = Release|x64 + {918CD402-047D-8467-E11C-E1132053F916}.Debug|Win32.ActiveCfg = Debug|Win32 + {918CD402-047D-8467-E11C-E1132053F916}.Debug|Win32.Build.0 = Debug|Win32 + {918CD402-047D-8467-E11C-E1132053F916}.Debug|x64.ActiveCfg = Debug|x64 + {918CD402-047D-8467-E11C-E1132053F916}.Debug|x64.Build.0 = Debug|x64 + {918CD402-047D-8467-E11C-E1132053F916}.Release|Win32.ActiveCfg = Release|Win32 + {918CD402-047D-8467-E11C-E1132053F916}.Release|Win32.Build.0 = Release|Win32 + {918CD402-047D-8467-E11C-E1132053F916}.Release|x64.ActiveCfg = Release|x64 + {918CD402-047D-8467-E11C-E1132053F916}.Release|x64.Build.0 = Release|x64 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|Win32.ActiveCfg = Debug|Win32 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|Win32.Build.0 = Debug|Win32 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|x64.ActiveCfg = Debug|x64 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|x64.Build.0 = Debug|x64 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|Win32.ActiveCfg = Release|Win32 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|Win32.Build.0 = Release|Win32 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|x64.ActiveCfg = Release|x64 + {C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|x64.Build.0 = Release|x64 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|Win32.ActiveCfg = Debug|Win32 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|Win32.Build.0 = Debug|Win32 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|x64.ActiveCfg = Debug|x64 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|x64.Build.0 = Debug|x64 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Release|Win32.ActiveCfg = Release|Win32 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Release|Win32.Build.0 = Release|Win32 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Release|x64.ActiveCfg = Release|x64 + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Release|x64.Build.0 = Release|x64 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Debug|Win32.ActiveCfg = Debug|Win32 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Debug|Win32.Build.0 = Debug|Win32 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Debug|x64.ActiveCfg = Debug|x64 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Debug|x64.Build.0 = Debug|x64 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Release|Win32.ActiveCfg = Release|Win32 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Release|Win32.Build.0 = Release|Win32 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Release|x64.ActiveCfg = Release|x64 + {DE695064-13C3-18B0-378D-8B22672BF3F4}.Release|x64.Build.0 = Release|x64 + {71257802-BBCA-99F5-E9D2-905738F30893}.Debug|Win32.ActiveCfg = Debug|Win32 + {71257802-BBCA-99F5-E9D2-905738F30893}.Debug|Win32.Build.0 = Debug|Win32 + {71257802-BBCA-99F5-E9D2-905738F30893}.Debug|x64.ActiveCfg = Debug|x64 + {71257802-BBCA-99F5-E9D2-905738F30893}.Debug|x64.Build.0 = Debug|x64 + {71257802-BBCA-99F5-E9D2-905738F30893}.Release|Win32.ActiveCfg = Release|Win32 + {71257802-BBCA-99F5-E9D2-905738F30893}.Release|Win32.Build.0 = Release|Win32 + {71257802-BBCA-99F5-E9D2-905738F30893}.Release|x64.ActiveCfg = Release|x64 + {71257802-BBCA-99F5-E9D2-905738F30893}.Release|x64.Build.0 = Release|x64 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Debug|Win32.ActiveCfg = Debug|Win32 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Debug|Win32.Build.0 = Debug|Win32 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Debug|x64.ActiveCfg = Debug|x64 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Debug|x64.Build.0 = Debug|x64 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|Win32.ActiveCfg = Release|Win32 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|Win32.Build.0 = Release|Win32 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|x64.ActiveCfg = Release|x64 + {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|x64.Build.0 = Release|x64 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|Win32.ActiveCfg = Debug|Win32 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|Win32.Build.0 = Debug|Win32 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|x64.ActiveCfg = Debug|x64 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|x64.Build.0 = Debug|x64 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|Win32.ActiveCfg = Release|Win32 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|Win32.Build.0 = Release|Win32 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|x64.ActiveCfg = Release|x64 + {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|x64.Build.0 = Release|x64 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|Win32.ActiveCfg = Debug|Win32 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|Win32.Build.0 = Debug|Win32 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|x64.ActiveCfg = Debug|x64 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|x64.Build.0 = Debug|x64 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Release|Win32.ActiveCfg = Release|Win32 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Release|Win32.Build.0 = Release|Win32 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Release|x64.ActiveCfg = Release|x64 + {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Release|x64.Build.0 = Release|x64 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Debug|Win32.Build.0 = Debug|Win32 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Debug|x64.ActiveCfg = Debug|x64 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Debug|x64.Build.0 = Debug|x64 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|Win32.ActiveCfg = Release|Win32 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|Win32.Build.0 = Release|Win32 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|x64.ActiveCfg = Release|x64 + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|x64.Build.0 = Release|x64 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|Win32.Build.0 = Debug|Win32 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|x64.ActiveCfg = Debug|x64 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|x64.Build.0 = Debug|x64 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|Win32.ActiveCfg = Release|Win32 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|Win32.Build.0 = Release|Win32 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|x64.ActiveCfg = Release|x64 + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|x64.Build.0 = Release|x64 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|Win32.ActiveCfg = Debug|Win32 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|Win32.Build.0 = Debug|Win32 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|x64.ActiveCfg = Debug|x64 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|x64.Build.0 = Debug|x64 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Release|Win32.ActiveCfg = Release|Win32 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Release|Win32.Build.0 = Release|Win32 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Release|x64.ActiveCfg = Release|x64 + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Release|x64.Build.0 = Release|x64 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Debug|Win32.ActiveCfg = Debug|Win32 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Debug|Win32.Build.0 = Debug|Win32 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Debug|x64.ActiveCfg = Debug|x64 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Debug|x64.Build.0 = Debug|x64 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Release|Win32.ActiveCfg = Release|Win32 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Release|Win32.Build.0 = Release|Win32 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Release|x64.ActiveCfg = Release|x64 + {23EF735C-CC4C-3EC4-A75E-903DB340F04A}.Release|x64.Build.0 = Release|x64 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Debug|Win32.ActiveCfg = Debug|Win32 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Debug|Win32.Build.0 = Debug|Win32 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Debug|x64.ActiveCfg = Debug|x64 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Debug|x64.Build.0 = Debug|x64 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Release|Win32.ActiveCfg = Release|Win32 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Release|Win32.Build.0 = Release|Win32 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Release|x64.ActiveCfg = Release|x64 + {D4D691D4-137C-CBFA-735B-D46636D7E4D8}.Release|x64.Build.0 = Release|x64 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Debug|Win32.ActiveCfg = Debug|Win32 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Debug|Win32.Build.0 = Debug|Win32 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Debug|x64.ActiveCfg = Debug|x64 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Debug|x64.Build.0 = Debug|x64 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Release|Win32.ActiveCfg = Release|Win32 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Release|Win32.Build.0 = Release|Win32 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Release|x64.ActiveCfg = Release|x64 + {DB904B85-AD31-B7FB-114F-88760CC485F2}.Release|x64.Build.0 = Release|x64 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Debug|Win32.ActiveCfg = Debug|Win32 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Debug|Win32.Build.0 = Debug|Win32 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Debug|x64.ActiveCfg = Debug|x64 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Debug|x64.Build.0 = Debug|x64 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Release|Win32.ActiveCfg = Release|Win32 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Release|Win32.Build.0 = Release|Win32 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Release|x64.ActiveCfg = Release|x64 + {C9E2AB15-8AEF-DD48-60C3-557ECC5215BE}.Release|x64.Build.0 = Release|x64 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Debug|Win32.ActiveCfg = Debug|Win32 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Debug|Win32.Build.0 = Debug|Win32 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Debug|x64.ActiveCfg = Debug|x64 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Debug|x64.Build.0 = Debug|x64 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Release|Win32.ActiveCfg = Release|Win32 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Release|Win32.Build.0 = Release|Win32 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Release|x64.ActiveCfg = Release|x64 + {35E52E46-3BA9-4361-41D3-53663C2E9B8A}.Release|x64.Build.0 = Release|x64 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Debug|Win32.ActiveCfg = Debug|Win32 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Debug|Win32.Build.0 = Debug|Win32 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Debug|x64.ActiveCfg = Debug|x64 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Debug|x64.Build.0 = Debug|x64 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Release|Win32.ActiveCfg = Release|Win32 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Release|Win32.Build.0 = Release|Win32 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Release|x64.ActiveCfg = Release|x64 + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.vcxproj new file mode 100644 index 0000000..adc03df --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mbedTLS.vcxproj @@ -0,0 +1,295 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {46CF2D25-6A36-4189-B59C-E4815388E554} + Win32Proj + mbedTLS + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + CompileAsC + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + CompileAsC + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;%(PreprocessorDefinitions) + ../../include + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/md5sum.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/md5sum.vcxproj new file mode 100644 index 0000000..a61d89a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/md5sum.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {80FE1ECF-6992-A275-7973-E2976718D128} + Win32Proj + md5sum + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mini_client.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mini_client.vcxproj new file mode 100644 index 0000000..26f4a64 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mini_client.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {C4FE29EA-266D-5295-4840-976B9B5B3843} + Win32Proj + mini_client + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mpi_demo.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mpi_demo.vcxproj new file mode 100644 index 0000000..99e838e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/mpi_demo.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {A59FAA0B-9C34-1F99-794D-A365A3AA8CCE} + Win32Proj + mpi_demo + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pem2der.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pem2der.vcxproj new file mode 100644 index 0000000..8d3ced7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pem2der.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {D3C6FBD6-D78E-7180-8345-5E09B492DBEC} + Win32Proj + pem2der + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_decrypt.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_decrypt.vcxproj new file mode 100644 index 0000000..a1eb2a9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_decrypt.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {1EC6CBA3-6187-D456-D9B7-A35399395D71} + Win32Proj + pk_decrypt + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_encrypt.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_encrypt.vcxproj new file mode 100644 index 0000000..4cefcd4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_encrypt.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {55007179-7746-9CFB-97EC-65102FB272C8} + Win32Proj + pk_encrypt + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_sign.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_sign.vcxproj new file mode 100644 index 0000000..83de1bb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_sign.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {F2E8CA55-597F-7FDC-6456-D8650FB970A3} + Win32Proj + pk_sign + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_verify.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_verify.vcxproj new file mode 100644 index 0000000..8808a22 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/pk_verify.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {C429B336-1B30-119C-3B34-21A186D6744F} + Win32Proj + pk_verify + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/req_app.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/req_app.vcxproj new file mode 100644 index 0000000..a243817 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/req_app.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {486B1375-5CFA-C2D2-DD89-C9F497BADCB3} + Win32Proj + req_app + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_decrypt.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_decrypt.vcxproj new file mode 100644 index 0000000..4ab26af --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_decrypt.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {E0D71D72-8DF4-CCFC-EF60-741EADAB8BF9} + Win32Proj + rsa_decrypt + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_encrypt.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_encrypt.vcxproj new file mode 100644 index 0000000..e424773 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_encrypt.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {D06CF12E-F222-9273-41BF-B8A052FA5527} + Win32Proj + rsa_encrypt + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_genkey.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_genkey.vcxproj new file mode 100644 index 0000000..dfd2beb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_genkey.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {F472475C-F677-0E7F-F127-45BF5B64F622} + Win32Proj + rsa_genkey + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign.vcxproj new file mode 100644 index 0000000..874399b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {10790F49-6887-AAB6-2D86-BCBD516F8D26} + Win32Proj + rsa_sign + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign_pss.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign_pss.vcxproj new file mode 100644 index 0000000..24fd3a5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_sign_pss.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {DCD3A1B6-5EC1-8266-93EF-BD2B9BEFE12D} + Win32Proj + rsa_sign_pss + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify.vcxproj new file mode 100644 index 0000000..b57e2bd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {689E28CF-89ED-BA38-3A14-78A75D891D46} + Win32Proj + rsa_verify + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify_pss.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify_pss.vcxproj new file mode 100644 index 0000000..fb989e5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/rsa_verify_pss.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {95C50864-854C-2A11-4C91-BCE654E344FB} + Win32Proj + rsa_verify_pss + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/selftest.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/selftest.vcxproj new file mode 100644 index 0000000..e3f4f95 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/selftest.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {7DBC5F77-3DA1-5F73-8421-E693D95FC66A} + Win32Proj + selftest + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha1sum.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha1sum.vcxproj new file mode 100644 index 0000000..4c024ae --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha1sum.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {E91D12D7-01C0-357F-CAB1-8478B096743C} + Win32Proj + sha1sum + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha2sum.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha2sum.vcxproj new file mode 100644 index 0000000..d0410ed --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/sha2sum.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {8C5CF095-A0A4-54FB-0D48-8DF2B7FE4CA5} + Win32Proj + sha2sum + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj new file mode 100644 index 0000000..d71bd97 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {3FE0C0E1-D9BA-6A26-380C-F293E543B914} + Win32Proj + ssl_cert_test + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client1.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client1.vcxproj new file mode 100644 index 0000000..930821b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client1.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {487A2F80-3CA3-678D-88D5-82194872CF08} + Win32Proj + ssl_client1 + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client2.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client2.vcxproj new file mode 100644 index 0000000..6d82cdc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_client2.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {4E590E9D-E28F-87FF-385B-D58736388231} + Win32Proj + ssl_client2 + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_fork_server.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_fork_server.vcxproj new file mode 100644 index 0000000..88118b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_fork_server.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {918CD402-047D-8467-E11C-E1132053F916} + Win32Proj + ssl_fork_server + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_mail_client.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_mail_client.vcxproj new file mode 100644 index 0000000..df92412 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_mail_client.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {7C4863A1-941A-C5AE-E1F9-30F062E4B2FD} + Win32Proj + ssl_mail_client + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server.vcxproj new file mode 100644 index 0000000..054b99a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {E08E0065-896A-7487-DEA5-D3B80B71F975} + Win32Proj + ssl_server + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server2.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server2.vcxproj new file mode 100644 index 0000000..c1f7bfd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/ssl_server2.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {A4DA7463-1047-BDF5-E1B3-5632CB573F41} + Win32Proj + ssl_server2 + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/strerror.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/strerror.vcxproj new file mode 100644 index 0000000..1704ad2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/strerror.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {23EF735C-CC4C-3EC4-A75E-903DB340F04A} + Win32Proj + strerror + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/udp_proxy.vcxproj b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/udp_proxy.vcxproj new file mode 100644 index 0000000..0bcae5b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/visualc/VS2010/udp_proxy.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + + + + {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A} + Win32Proj + udp_proxy + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/create-module.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/create-module.sh new file mode 100644 index 0000000..4c79ebe --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/create-module.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +set -eu + +# relative to the script's directory +TREE=.. +DEST=module + +# make sure we're running in our own directory +if [ -f create-module.sh ]; then :; else + cd $( dirname $0 ) + if [ -f create-module.sh ]; then :; else + echo "Please run the script from is directory." >&2 + exit 1 + fi +fi + +# use a temporary directory to build the module, then rsync to DEST +# this allows touching only new files, for more efficient re-builds +TMP=$DEST-tmp +rm -rf $TMP + +mkdir -p $TMP/mbedtls $TMP/source +cp $TREE/include/mbedtls/*.h $TMP/mbedtls +cp $TREE/library/*.c $TMP/source + +# temporary, should depend on external module later +cp data/entropy_hardware_poll.c $TMP/source +cp data/target_config.h $TMP/mbedtls + +data/adjust-config.sh $TREE/scripts/config.pl $TMP/mbedtls/config.h + +mkdir -p $TMP/test +cp -r data/example-* $TMP/test +# later we should have the generated test suites here too + +cp data/module.json $TMP +cp data/README.md $TMP + +cp ../LICENSE $TMP +if [ -f ../apache-2.0.txt ]; then cp ../apache-2.0.txt $TMP; fi + +mkdir -p $DEST +rsync -cr --delete --exclude build --exclude yotta_\* $TMP/ $DEST/ +rm -rf $TMP + +echo "mbed TLS yotta module created in '$PWD/$DEST'." diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/README.md new file mode 100644 index 0000000..b748aac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/README.md @@ -0,0 +1,103 @@ +# mbed TLS + +mbed TLS makes it trivially easy for developers to include cryptographic and SSL/TLS capabilities in their embedded products, with a minimal code footprint. It offers an SSL library with an intuitive API and readable source code. + +**Note:** The current release is beta, and implements no secure source of random numbers, weakening its security. + +Currently the only supported yotta targets are: +- `frdm-k64f-gcc` +- `frdm-k64f-armcc` +- `x86-linux-native` +- `x86-osx-native` + +## Sample programs + +This release includes the following examples: + +1. [**Self test:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-selftest) Tests different basic functions in the mbed TLS library. + +2. [**Benchmark:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-benchmark) Measures the time taken to perform basic cryptographic functions used in the library. + +3. [**Hashing:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-hashing) Demonstrates the various APIs for computing hashes of data (also known as message digests) with SHA-256. + +4. [**Authenticated encryption:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-authcrypt) Demonstrates usage of the Cipher API for encrypting and authenticating data with AES-CCM. + +These examples are integrated as yotta tests, so that they are built automatically when you build mbed TLS. Each of them comes with complete usage instructions as a Readme file in the repository. + +## Performing TLS and DTLS connections + +A high-level API for performing TLS and DTLS connections with mbed TLS in mbed OS is provided in a separate yotta module: [mbed-tls-sockets](https://github.com/ARMmbed/mbed-tls-sockets). We recommend this API for TLS and DTLS connections. It is very similar to the API provided by the [sockets](https://github.com/ARMmbed/sockets) module for unencrypted TCP and UDP connections. + +The `mbed-tls-sockets` module includes a complete [example TLS client](https://github.com/ARMmbed/mbed-tls-sockets/blob/master/test/tls-client/main.cpp) with [usage instructions](https://github.com/ARMmbed/mbed-tls-sockets/blob/master/test/tls-client/README.md). + +## Configuring mbed TLS features + +mbed TLS makes it easy to disable any feature during compilation, if that feature isn't required for a particular project. The default configuration enables all modern and widely-used features, which should meet the needs of new projects, and disables all features that are older or less common, to minimize the code footprint. + +The list of available compilation flags is available in the fully documented [config.h file](https://github.com/ARMmbed/mbedtls/blob/development/include/mbedtls/config.h). + +If you need to adjust those flags, you can provide your own configuration-adjustment file with suitable `#define` and `#undef` statements. These will be included between the default definitions and the sanity checks. Your configuration file should be in your application's include directory, and can be named freely; you just need to let mbed TLS know the file's name. To do that, use yotta's [configuration system](http://docs.yottabuild.org/reference/config.html). The file's name should be in your `config.json` file, under mbedtls, as the key `user-config-file`. + +For example, in an application called `myapp`, if you want to enable the EC J-PAKE key exchange and disable the CBC cipher mode, you can create a file named `mbedtls-config-changes.h` in the `myapp` directory containing the following lines: + + #define MBEDTLS_ECJPAKE_C + #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + + #undef MBEDTLS_CIPHER_MODE_CBC + +And then create a file named `config.json` at the root of your application with the following contents: + + { + "mbedtls": { + "user-config-file": "\"myapp/mbedtls-config-changes.h\"" + } + } + +Please note: you need to provide the exact name that will be used in the `#include` directive, including the `<>` or quotes around the name. + +## Getting mbed TLS from GitHub + +Like most components of mbed OS, mbed TLS is developed in the open and its source can be found on GitHub: [ARMmbed/mbedtls](https://github.com/ARMmbed/mbedtls). Unlike most other mbed OS components, however, you cannot just clone the repository and run `yotta build` from its root. This is because mbed TLS also exists as an independent component, so its repository includes things that are not relevant for mbed OS, as well as other build systems. + +The way to use mbed TLS from a clone of the GitHub repository is to run the following commands from the root of a checkout: + + yotta/create-module.sh + cd yotta/module + +You can then run any yotta command you would normally run, such as `yotta build` or `yotta link`. + +## Differences between the standalone and mbed OS editions + +While the two editions share the same code base, there are still a number of differences, mainly in configuration and integration. You should keep in mind those differences when reading some articles in our [knowledge base](https://tls.mbed.org/kb), as currently all the articles are about the standalone edition. + +* The mbed OS edition has a smaller set of features enabled by default in `config.h`, in order to reduce footprint. While the default configuration of the standalone edition puts more emphasize on maintaining interoperability with old peers, the mbed OS edition only enables the most modern ciphers and the latest version of (D)TLS. + +* The following components of mbed TLS are disabled in the mbed OS edition: `net_sockets.c` and `timing.c`. This is because mbed OS include their equivalents. + +* The mbed OS edition comes with a fully integrated API for (D)TLS connections in a companion module: [mbed-tls-sockets](https://github.com/ARMmbed/mbed-tls-sockets). See "Performing TLS and DTLS connections" above. + +## Other resources + +The [mbed TLS website](https://tls.mbed.org) contains many other useful +resources for the developer, such as [developer +documentation](https://tls.mbed.org/dev-corner), [knowledgebase +articles](https://tls.mbed.org/kb), and a [support forum](https://tls.mbed.org/discussions). + +## Contributing + +We gratefully accept bug reports and contributions from the community. There are some requirements we need to fulfill in order to be able to integrate contributions: + +* Simple bug fixes to existing code do not contain copyright themselves and we can integrate without issue. The same is true of trivial contributions. + +* For larger contributions, such as a new feature, the code can possibly fall under copyright law. We then need your consent to share in the ownership of the copyright. We have a form for this, which we will send to you in case you submit a contribution or pull request that we deem this necessary for. + +To contribute, please: + +* [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug. + +* Fork the [mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the "development" branch as a basis. + +* Write a test that shows that the bug was fixed or that the feature works as expected. + +* Send a pull request and bug us until it gets merged and published. We will include your name in the ChangeLog. + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/adjust-config.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/adjust-config.sh new file mode 100644 index 0000000..3fa8490 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/adjust-config.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +set -eu + +if [ $# -ne 2 ]; then + echo "Usage: $0 path/to/config.pl path/to/config.h" >&2 + exit 1 +fi + +SCRIPT=$1 +FILE=$2 + +conf() { + $SCRIPT -f $FILE $@ +} + + +# Set the target specific header +conf set YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE \"mbedtls/target_config.h\" + +# not supported on mbed OS, nor used by mbed Client +conf unset MBEDTLS_NET_C +conf unset MBEDTLS_TIMING_C + +# not supported on all targets with mbed OS, nor used by mbed Client +conf unset MBEDTLS_FS_IO + +conf unset MBEDTLS_CIPHER_MODE_CFB +conf unset MBEDTLS_CIPHER_MODE_CTR +conf unset MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +conf unset MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +conf unset MBEDTLS_CIPHER_PADDING_ZEROS +conf unset MBEDTLS_ECP_DP_SECP192R1_ENABLED +conf unset MBEDTLS_ECP_DP_SECP224R1_ENABLED +conf unset MBEDTLS_ECP_DP_SECP521R1_ENABLED +conf unset MBEDTLS_ECP_DP_SECP192K1_ENABLED +conf unset MBEDTLS_ECP_DP_SECP224K1_ENABLED +conf unset MBEDTLS_ECP_DP_SECP256K1_ENABLED +conf unset MBEDTLS_ECP_DP_BP256R1_ENABLED +conf unset MBEDTLS_ECP_DP_BP384R1_ENABLED +conf unset MBEDTLS_ECP_DP_BP512R1_ENABLED +conf unset MBEDTLS_PK_PARSE_EC_EXTENDED + +conf unset MBEDTLS_AESNI_C +conf unset MBEDTLS_ARC4_C +conf unset MBEDTLS_BLOWFISH_C +conf unset MBEDTLS_CAMELLIA_C +conf unset MBEDTLS_DES_C +conf unset MBEDTLS_DHM_C +conf unset MBEDTLS_GENPRIME +conf unset MBEDTLS_MD5_C +conf unset MBEDTLS_PADLOCK_C +conf unset MBEDTLS_PEM_WRITE_C +conf unset MBEDTLS_PKCS5_C +conf unset MBEDTLS_PKCS12_C +conf unset MBEDTLS_RIPEMD160_C +conf unset MBEDTLS_SHA1_C +conf unset MBEDTLS_XTEA_C + +conf unset MBEDTLS_X509_RSASSA_PSS_SUPPORT + +conf unset MBEDTLS_X509_CSR_PARSE_C +conf unset MBEDTLS_X509_CREATE_C +conf unset MBEDTLS_X509_CRT_WRITE_C +conf unset MBEDTLS_X509_CSR_WRITE_C + +conf unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED +conf unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +conf unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +conf unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED +conf unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +conf unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +conf unset MBEDTLS_SSL_FALLBACK_SCSV +conf unset MBEDTLS_SSL_CBC_RECORD_SPLITTING +conf unset MBEDTLS_SSL_PROTO_TLS1 +conf unset MBEDTLS_SSL_PROTO_TLS1_1 +conf unset MBEDTLS_SSL_TRUNCATED_HMAC diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/entropy_hardware_poll.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/entropy_hardware_poll.c new file mode 100644 index 0000000..3a61e22 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/entropy_hardware_poll.c @@ -0,0 +1,88 @@ +/* + * Hardware entropy collector for the K64F, using Freescale's RNGA + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * WARNING: this is temporary! + * This should be in a separate yotta module which would be a target + * dependency of mbedtls (see IOTSSL-313) + */ + +#if defined(TARGET_LIKE_K64F) + +/* + * Reference: "K64 Sub-Family Reference Manual, Rev. 2", chapter 34 + */ + +#include "fsl_clock_manager.h" + +/* + * Get one byte of entropy from the RNG, assuming it is up and running. + * As recommended (34.1.1), get only one bit of each output. + */ +static void rng_get_byte( unsigned char *byte ) +{ + size_t bit; + + /* 34.5 Steps 3-4-5: poll SR and read from OR when ready */ + for( bit = 0; bit < 8; bit++ ) + { + while( ( RNG->SR & RNG_SR_OREG_LVL_MASK ) == 0 ); + *byte |= ( RNG->OR & 1 ) << bit; + } +} + +/* + * Get len bytes of entropy from the hardware RNG. + */ +int mbedtls_hardware_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) +{ + size_t i; + int ret; + ((void) data); + + CLOCK_SYS_EnableRngaClock( 0 ); + + /* Set "Interrupt Mask", "High Assurance" and "Go", + * unset "Clear interrupt" and "Sleep" */ + RNG->CR = RNG_CR_INTM_MASK | RNG_CR_HA_MASK | RNG_CR_GO_MASK; + + for( i = 0; i < len; i++ ) + rng_get_byte( output + i ); + + /* Just be extra sure that we didn't do it wrong */ + if( ( RNG->SR & RNG_SR_SECV_MASK ) != 0 ) + { + ret = -1; + goto cleanup; + } + + *olen = len; + ret = 0; + +cleanup: + /* Disable clock to save power - assume we're the only users of RNG */ + CLOCK_SYS_DisableRngaClock( 0 ); + + return( ret ); +} + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/README.md new file mode 100644 index 0000000..ae4b1ef --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/README.md @@ -0,0 +1,68 @@ +# Authenticated Encryption Example + +This application performs authenticated encryption and authenticated decryption of a buffer. It serves as a tutorial for the basic authenticated encryption functions of mbed TLS. + +## Pre-requisites + +To build and run this example you must have: + +* A computer with the following software installed: + * [CMake](http://www.cmake.org/download/). + * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). + * [Python](https://www.python.org/downloads/). + * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). + * A serial terminal emulator (Like screen, pySerial and cu). +* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). +* A micro-USB cable. +* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). + +## Getting started + +1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. + +2. Navigate to the mbedtls directory supplied with your release and open a terminal. + +3. Set the yotta target: + + ``` + yotta target frdm-k64f-gcc + ``` + +4. Build mbedtls and the examples. This may take a long time if this is your first compilation: + + ``` + $ yotta build + ``` + +5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-authcrypt.bin` to your mbed board and wait until the LED next to the USB port stops blinking. + +6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. + + Use the following settings: + + * 115200 baud (not 9600). + * 8N1. + * No flow control. + +7. Press the Reset button on the board. + +8. The output in the terminal window should look like: + + ``` + {{timeout;10}} + {{host_test_name;default}} + {{description;mbed TLS example authcrypt}} + {{test_id;MBEDTLS_EX_AUTHCRYPT}} + {{start}} + + + plaintext message: 536f6d65207468696e67732061726520626574746572206c65667420756e7265616400 + ciphertext: c57f7afb94f14c7977d785d08682a2596bd62ee9dcf216b8cccd997afee9b402f5de1739e8e6467aa363749ef39392e5c66622b01c7203ec0a3d14 + decrypted: 536f6d65207468696e67732061726520626574746572206c65667420756e7265616400 + + DONE + {{success}} + {{end}} + ``` + +The actual output for the ciphertext line will vary on each run because of the use of a random nonce in the encryption process. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/main.cpp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/main.cpp new file mode 100644 index 0000000..23fad27 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-authcrypt/main.cpp @@ -0,0 +1,197 @@ +/* + * Hello world example of using the authenticated encryption with mbed TLS + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#include "mbedtls/cipher.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + +#include +#include + +static void print_hex(const char *title, const unsigned char buf[], size_t len) +{ + printf("%s: ", title); + + for (size_t i = 0; i < len; i++) + printf("%02x", buf[i]); + + printf("\r\n"); +} + +/* + * The pre-shared key. Should be generated randomly and be unique to the + * device/channel/etc. Just used a fixed on here for simplicity. + */ +static const unsigned char secret_key[16] = { + 0xf4, 0x82, 0xc6, 0x70, 0x3c, 0xc7, 0x61, 0x0a, + 0xb9, 0xa0, 0xb8, 0xe9, 0x87, 0xb8, 0xc1, 0x72, +}; + +static int example(void) +{ + /* message that should be protected */ + const char message[] = "Some things are better left unread"; + /* metadata transmitted in the clear but authenticated */ + const char metadata[] = "eg sequence number, routing info"; + /* ciphertext buffer large enough to hold message + nonce + tag */ + unsigned char ciphertext[128] = { 0 }; + int ret; + + printf("\r\n\r\n"); + print_hex("plaintext message", (unsigned char *) message, sizeof message); + + /* + * Setup random number generator + * (Note: later this might be done automatically.) + */ + mbedtls_entropy_context entropy; /* entropy pool for seeding PRNG */ + mbedtls_ctr_drbg_context drbg; /* pseudo-random generator */ + + mbedtls_entropy_init(&entropy); + mbedtls_ctr_drbg_init(&drbg); + + /* Seed the PRNG using the entropy pool, and throw in our secret key as an + * additional source of randomness. */ + ret = mbedtls_ctr_drbg_seed(&drbg, mbedtls_entropy_func, &entropy, + secret_key, sizeof (secret_key)); + if (ret != 0) { + printf("mbedtls_ctr_drbg_init() returned -0x%04X\r\n", -ret); + return 1; + } + + /* + * Setup AES-CCM contex + */ + mbedtls_cipher_context_t ctx; + + mbedtls_cipher_init(&ctx); + + ret = mbedtls_cipher_setup(&ctx, mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_CCM)); + if (ret != 0) { + printf("mbedtls_cipher_setup() returned -0x%04X\r\n", -ret); + return 1; + } + + ret = mbedtls_cipher_setkey(&ctx, secret_key, 8 * sizeof secret_key, MBEDTLS_ENCRYPT); + if (ret != 0) { + printf("mbedtls_cipher_setkey() returned -0x%04X\r\n", -ret); + return 1; + } + + /* + * Encrypt-authenticate the message and authenticate additional data + * + * First generate a random 8-byte nonce. + * Put it directly in the output buffer as the recipient will need it. + * + * Warning: you must never re-use the same (key, nonce) pair. One of the + * best ways to ensure this to use a counter for the nonce. However this + * means you should save the counter accross rebots, if the key is a + * long-term one. The alternative we choose here is to generate the nonce + * randomly. However it only works if you have a good source of + * randomness. + */ + const size_t nonce_len = 8; + mbedtls_ctr_drbg_random(&drbg, ciphertext, nonce_len); + + size_t ciphertext_len = 0; + /* Go for a conservative 16-byte (128-bit) tag + * and append it to the ciphertext */ + const size_t tag_len = 16; + ret = mbedtls_cipher_auth_encrypt(&ctx, ciphertext, nonce_len, + (const unsigned char *) metadata, sizeof metadata, + (const unsigned char *) message, sizeof message, + ciphertext + nonce_len, &ciphertext_len, + ciphertext + nonce_len + sizeof message, tag_len ); + if (ret != 0) { + printf("mbedtls_cipher_auth_encrypt() returned -0x%04X\r\n", -ret); + return 1; + } + ciphertext_len += nonce_len + tag_len; + + /* + * The following information should now be transmitted: + * - first ciphertext_len bytes of ciphertext buffer + * - metadata if not already transmitted elsewhere + */ + print_hex("ciphertext", ciphertext, ciphertext_len); + + /* + * Decrypt-authenticate + */ + unsigned char decrypted[128] = { 0 }; + size_t decrypted_len = 0; + + ret = mbedtls_cipher_setkey(&ctx, secret_key, 8 * sizeof secret_key, MBEDTLS_DECRYPT); + if (ret != 0) { + printf("mbedtls_cipher_setkey() returned -0x%04X\r\n", -ret); + return 1; + } + + ret = mbedtls_cipher_auth_decrypt(&ctx, + ciphertext, nonce_len, + (const unsigned char *) metadata, sizeof metadata, + ciphertext + nonce_len, ciphertext_len - nonce_len - tag_len, + decrypted, &decrypted_len, + ciphertext + ciphertext_len - tag_len, tag_len ); + /* Checking the return code is CRITICAL for security here */ + if (ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED) { + printf("Something bad is happening! Data is not authentic!\r\n"); + return 1; + } + if (ret != 0) { + printf("mbedtls_cipher_authdecrypt() returned -0x%04X\r\n", -ret); + return 1; + } + + print_hex("decrypted", decrypted, decrypted_len); + + printf("\r\nDONE\r\n"); + + return 0; +} + +#if defined(TARGET_LIKE_MBED) + +#include "mbed-drivers/test_env.h" +#include "minar/minar.h" + +static void run() { + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default); + MBED_HOSTTEST_DESCRIPTION(mbed TLS example authcrypt); + MBED_HOSTTEST_START("MBEDTLS_EX_AUTHCRYPT"); + MBED_HOSTTEST_RESULT(example() == 0); +} + +void app_start(int, char*[]) { + /* Use 115200 bps for consistency with other examples */ + get_stdio_serial().baud(115200); + minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); +} + +#else + +int main() { + return example(); +} + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/README.md new file mode 100644 index 0000000..8589e7b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/README.md @@ -0,0 +1,100 @@ +# mbed TLS Benchmark Example + +This application benchmarks the various cryptographic primitives offered by mbed TLS. + +## Pre-requisites + +To build and run this example you must have: + +* A computer with the following software installed: + * [CMake](http://www.cmake.org/download/). + * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). + * [Python](https://www.python.org/downloads/). + * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). + * A serial terminal emulator (Like screen, pySerial and cu). +* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). +* A micro-USB cable. +* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). + +## Getting started + +1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. + +2. Navigate to the mbedtls directory supplied with your release and open a terminal. + +3. Set the yotta target: + + ``` + yotta target frdm-k64f-gcc + ``` + +4. Build mbedtls and the examples. This may take a long time if this is your first compilation: + + ``` + $ yotta build + ``` + +5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-benchmark.bin` to your mbed board and wait until the LED next to the USB port stops blinking. + +6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. + + Use the following settings: + + * 115200 baud (not 9600). + * 8N1. + * No flow control. + +7. Press the Reset button on the board. + +8. The output in the terminal window should look like: + + ``` + {{timeout;150}} + {{host_test_name;default}} + {{description;mbed TLS benchmark program}} + {{test_id;MBEDTLS_BENCHMARK}} + {{start}} + + + SHA-1 : 3644 Kb/s, 32 cycles/byte + SHA-256 : 1957 Kb/s, 59 cycles/byte + SHA-512 : 587 Kb/s, 200 cycles/byte + AES-CBC-128 : 1359 Kb/s, 86 cycles/byte + AES-CBC-192 : 1183 Kb/s, 99 cycles/byte + AES-CBC-256 : 1048 Kb/s, 111 cycles/byte + AES-GCM-128 : 421 Kb/s, 279 cycles/byte + AES-GCM-192 : 403 Kb/s, 292 cycles/byte + AES-GCM-256 : 385 Kb/s, 305 cycles/byte + AES-CCM-128 : 542 Kb/s, 216 cycles/byte + AES-CCM-192 : 484 Kb/s, 242 cycles/byte + AES-CCM-256 : 437 Kb/s, 268 cycles/byte + CTR_DRBG (NOPR) : 1002 Kb/s, 117 cycles/byte + CTR_DRBG (PR) : 705 Kb/s, 166 cycles/byte + HMAC_DRBG SHA-1 (NOPR) : 228 Kb/s, 517 cycles/byte + HMAC_DRBG SHA-1 (PR) : 210 Kb/s, 561 cycles/byte + HMAC_DRBG SHA-256 (NOPR) : 212 Kb/s, 557 cycles/byte + HMAC_DRBG SHA-256 (PR) : 185 Kb/s, 637 cycles/byte + RSA-2048 : 41 ms/ public + RSA-2048 : 1349 ms/private + RSA-4096 : 134 ms/ public + RSA-4096 : 7149 ms/private + ECDSA-secp384r1 : 640 ms/sign + ECDSA-secp256r1 : 387 ms/sign + ECDSA-secp384r1 : 1233 ms/verify + ECDSA-secp256r1 : 751 ms/verify + ECDHE-secp384r1 : 1191 ms/handshake + ECDHE-secp256r1 : 730 ms/handshake + ECDHE-Curve25519 : 611 ms/handshake + ECDH-secp384r1 : 584 ms/handshake + ECDH-secp256r1 : 365 ms/handshake + ECDH-Curve25519 : 303 ms/handshake + + {{success}} + {{end}} + ``` + +Any performance data generated by this example application are indicative only of the performance of the mbed TLS module on the platform it's executed on. + +Differences in the integration of mbed TLS into the platform, such as whether all available hardware accelerators have been used or not, can lead to significant differences in performance, and so results from the program are not intended to be used to meaningfully compare platforms. + +The figures may also slightly change from execution to execution due to variations in the timing functions. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/main.cpp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/main.cpp new file mode 100644 index 0000000..ef38c44 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-benchmark/main.cpp @@ -0,0 +1,951 @@ +/* + * Benchmark demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(TARGET_LIKE_MBED) + +#include + +int main() { + printf("this version of this program only works on mbed OS\n"); + return 0; +} + +#else + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_exit exit +#define mbedtls_printf printf +#define mbedtls_snprintf snprintf +#define mbedtls_free free +#endif + +#include + +#include "mbedtls/md4.h" +#include "mbedtls/md5.h" +#include "mbedtls/ripemd160.h" +#include "mbedtls/sha1.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +#include "mbedtls/arc4.h" +#include "mbedtls/des.h" +#include "mbedtls/aes.h" +#include "mbedtls/blowfish.h" +#include "mbedtls/camellia.h" +#include "mbedtls/gcm.h" +#include "mbedtls/ccm.h" +#include "mbedtls/havege.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/hmac_drbg.h" +#include "mbedtls/rsa.h" +#include "mbedtls/pk.h" +#include "mbedtls/dhm.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/ecdh.h" +#include "mbedtls/error.h" + +#include "mbed-drivers/mbed.h" + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#include "mbedtls/memory_buffer_alloc.h" +#endif + +#define RSA_PRIVATE_KEY_2048 \ +"-----BEGIN RSA PRIVATE KEY-----\r\n" \ +"MIIEogIBAAKCAQEA2dwVr+IMGEtA2/MCP6fA5eb/6B18Bq6e7gw8brNPkm3E6LyR\r\n" \ +"4DnMJVxZmw3bPDKBDoKzfntkMESi/Yw5UopLtVfjGfWeQWPClqffLZBsZ60BRAsg\r\n" \ +"/g+ID5tgzxSuxzftypK59uexOVCAm7hCKZHGO3DbI7bLY27j7VAgEP7d/yuaz5Fx\r\n" \ +"Kl/vu7shqrBoz6ABJVJD3KC8nUiMRUCXRINmxbyUUjA4DnicZv6+xrGKr36r6M8h\r\n" \ +"VYLa5msKc8WzbnBWzpUsrpb4/r7ML+qp92gdSfVJ8/bLiU7h2C7faDA59uaqrFK9\r\n" \ +"xmDdx7FaWhGQs3LWW6w1UNgkPS0FDYUslpsnsQIDAQABAoIBAC7IJNwM5V3+IuJY\r\n" \ +"T35Nzo1PyloUosJokvY5KGz5Ejg2XBdCDu0gXCcVqqQyGIbXrYDpLhQV+RCoXHun\r\n" \ +"tdN0oQdC5SB47s/J1Uo2qCUHo0+sBd6PqTkFKsl3KxWssk9TQjvCwC412IefMs69\r\n" \ +"hW+ZvwCanmQP56LleApIr2oW4KLfW8Ry/QfZlua+dizctdN7+H1mWwgZQTY9T27J\r\n" \ +"6RtGRA5NVkKVPzIHVJfdpKoO7xGg1g06aEbPB/VmGvZaaFWWnaf7uRvFjLZecBLu\r\n" \ +"QSx2DA/GDjirlDYj99PJb7DtB4xRtKzsyw0o+xapC8w6OtIl/3xFt9moCu2jGrsx\r\n" \ +"vpjHdfECgYEA7fSACRseIs9gAIVX8wq6gayTpA47DHYWAD6IQfIj35SJ+AgsvbFF\r\n" \ +"4AmrwDhcJVPmDy1N4nLBfyGAMt/2CfiYkdkW6QFX/ULRMMBL/G7kWV8hYQDICB2g\r\n" \ +"xaMRN1lPCmFq6BkSWjwIYTnYDFBDWVm1GVT8TMtJoM8Erej9qC0PeFUCgYEA6mF3\r\n" \ +"bigO3t8f5sig+XepaftEUbkJMzo72TVRnIR2ycdR2ihelPQ+25g9dwV0ZA5XXhBS\r\n" \ +"DKOABWjMM739Mwmy9v26Dlmu9R01zHQktMvtEAyfz7lk2NF0aMuj8285OJUBf9bz\r\n" \ +"Cq3MjtMCD+4CZ6iaEqCdUKOuxfpx5cWVJV+qve0CgYBhD1YaYMFOGaBjFgDl1f51\r\n" \ +"Xltqk5NqZdBbkSYrIAWZ8RDF5y+4wFJsLAWuhk6vuyUgE66tK3nZzWRpXAkT0B8L\r\n" \ +"fq1lpXKqj1KcvBNCiEkEW1VWJ+dvyAYIF5eyJ++hoFLnETL3M32HivyhKSwPihPg\r\n" \ +"nVW8TT9fJJIYDe1JZ/fjcQKBgHJfv7UsrR0LSvkG3K8AOtbx+8PZhOjPuRbk0v+L\r\n" \ +"EKCkuIe5/XW4vtfQMeZb7hFJgk7vrepm+vkoy8VQKDf4urGW3W1VTHBmobM01hi4\r\n" \ +"DuYvEul+Mf0wMRtWjJolo4m+BO5KiW2jpFfqFm6JmfjVqOIAKOSKC6am8V/MDF0h\r\n" \ +"kyN9AoGAT9oOiEXMolbkDZw/QCaBiRoAGlGlNYUkJ+58U6OjIZLISw6aFv+Y2uE0\r\n" \ +"mEImItjuYZtSYKblWikp6ldPoKlt9bwEFe3c6IZ8kJ3+xyEyAGrvjXjEY7PzP6dp\r\n" \ +"Ajbjp9X9uocEBv9W/KsBLdQ7yizcL/toHwdBO4vQqmqTvAc5IIw=\r\n" \ +"-----END RSA PRIVATE KEY-----\r\n" + +#define RSA_PRIVATE_KEY_4096 \ +"-----BEGIN RSA PRIVATE KEY-----\r\n" \ +"MIIJKgIBAAKCAgEAmkdGjoIshJuOt2NO47qB3Z3yyvmLg2j351isItSNuFQU3qr+\r\n" \ +"jXHIeANf03yw/K0Zvos8RPd+CqLjoxAQL3QDH4bZAl88bIo29i+SANbNSrKQmc0k\r\n" \ +"pH+yzw3alDzO0GZaOPZjsbo6AwBrno5msi0vRuC2aY8vGLPsZWSyLai7tneS1j/o\r\n" \ +"vYW6XIo8Cj61j2Ypy9HhVUW/4Wc+zAT25D/x7jTpkqJLWWT+YzibNbOY48M5eJcB\r\n" \ +"6/sMyUIeI3/u/wXyMrooNyLiCpedkuHRA0m7u5cWPTUISTunSRlVFij/NHJjuU8e\r\n" \ +"wA3B29yfZFsUqDEnyc+OxniIueAixTomVszxAaVn8zFEbYhFMPqziiFp99u3jfeG\r\n" \ +"k1q9mmUi/uCfUC4e2IC5rqq1ZbKSduH7Ug/Vn2bGQahww0sZFRHDXFrnBcotcW+M\r\n" \ +"bnC290VBDnYgzmdYrIOxuPb2aUwJo4ZlbKh5uBB1PigMuyhLKibQ1a+V5ZJGdpP6\r\n" \ +"SE9PGIdgYWSmh2QEMuLE6v+wTO2LQ5JgqsvFfi3GIZvkn0s8jTS72Jq2uMkFkMer\r\n" \ +"UBjPDYaSPy5kpo103KerWs+cMPOJ/3FtZzI++7MoSUTkWVr1ySQFt5i1EIZ/0Thi\r\n" \ +"jut2jNe8a4AoA3TtC8Rkk/3AIIbg8MVNT4EnT+KHROTMu6gET1oJ3YfBRpUCAwEA\r\n" \ +"AQKCAgEAhuNSmT7PVZH8kfLOAuYKrY1vvm+4v0iDl048Eqfs0QESziyLK3gUYnnw\r\n" \ +"yqP2yrU+EQ8Dvvj0xq/sf6GHxTWVlXb9PcmutueRbmXhLcKg83J0Y0StiPXtjIL8\r\n" \ +"XSddW3Bh6fPi7n14Qy+W6KZwu9AtybanRlvePabyRSRpdOpWVQ7u30w5XZsSed6S\r\n" \ +"6BI0BBC68m2qqje1sInoqdCdXKtcB31TytUDNEHM+UuAyM8iGeGS2hCNqZlycHTS\r\n" \ +"jQ9KEsdMH3YLu0lQgRpWtxmg+VL6ROWwmAtKF12EwbDYZ+uoVl69OkQnCpv8pxKa\r\n" \ +"ec/4m6V+uEA1AOpaAMorHG3fH31IKWC/fTZstovgO/eG2XCtlbcCoWCQ7amFq16l\r\n" \ +"Gh1UKeBHxMXpDj4oDmIUGUvgzSNnEeSN/v76losWvWYQDjXR/LMDa/CNYsD8BmJR\r\n" \ +"PZidIjIXdVRlYOhA7ljtySQvp6RBujBfw3tsVMyZw2XzXFwM9O89b1xXC6+M5jf9\r\n" \ +"DXs/U7Fw+J9qq/YpByABcPCwWdttwdQFRbOxwxaSOKarIqS87TW1JuFcNJ59Ut6G\r\n" \ +"kMvAg6gC34U+0ktkG/AmI1hgjC+P7ErHCXBR2xARoGzcO/CMZF59S+Z2HFchpTSP\r\n" \ +"5T2o4mGy3VfHSBidQQrcZRukg8ZP8M1NF3bXjpY6QZpeLHc4oHECggEBAMjdgzzk\r\n" \ +"xp4mIYFxAEiXYt7tzuUXJk+0UpEJj5uboWLirUZqZmNUPyh6WDnzlREBH++Ms0LO\r\n" \ +"+AWSfaGPDoMb0NE2j3c4FRWAhe7Vn6lj7nLVpF2RdwRo88yGerZ4uwGMY8NUQCtn\r\n" \ +"zum3J7eCJ5DojiceRb6uMxTJ8xZmUC4W2f3J/lrR7wlYjyVnnHqH5HcemYUipWSw\r\n" \ +"sM0/cHp3lrz2VWrbAEu8HVpklvDQpdAgl7cjXt/JHYawY+p426IF/PzQSRROnzgy\r\n" \ +"4WI8FVYNV2tgu0TOFURbkkEvuj/duDKeooUIF0G0XHzha5oAX/j0iWiHbrOF6wHj\r\n" \ +"0xeajL9msKBnmD8CggEBAMSgLWmv7G31x4tndJCcXnX4AyVL7KpygAx/ZwCcyTR8\r\n" \ +"rY1rO07f/ta2noEra/xmEW/BW98qJFCHSU2nSLAQ5FpFSWyuQqrnffrMJnfWyvpr\r\n" \ +"ceQ0yQ/MiA6/JIOvGAjabcspzZijxzGp+Qk3eTT0yOXLSVOCH9B9XVHLodcy4PQM\r\n" \ +"KSCxy0vVHhVNl2SdPEwTXRmxk99Q/rw6IHVpQxBq1OhQt05nTKT+rZMD/grSK22e\r\n" \ +"my2F0DodAJwLo063Zv3RXQZhDYodMmjcp9Hqrtvj9P3HD7J3z6ACiV3SCi8cZumL\r\n" \ +"bSmnKCcd0bb45+aOWm31ieECJuIcJ9rOREEa/KDYTCsCggEBAMG5WkSVhLWsou37\r\n" \ +"dUGNuA63nq42SH3gtS0q4nU6gUkkw+dA4ST1cMByVrr1oRQ4WHup4I4TnQOKyF3T\r\n" \ +"4jQy1I+ipnVeAn+tZ/7zyzwMpEHeqNqRXA9FxbTBEoMAJ6QTqXgOvqDeSqIAQm7r\r\n" \ +"OYu5rrgtqyh/S8bGCwvUe4ooAfCSKx2ekYMbBVwW9MT8YS09tuS/iHJ3Mt2RTMLg\r\n" \ +"qeHvVmxrcXqZoFm44Ba7tN/pP0mi9HKyviZT4tmV3IYEbn3JyGGsfkUuVU9wEUfg\r\n" \ +"MCrgrVxrwfketAzooiHMjkVL2ASjzAJTmEvdAPETYXxzJD9LN0ovY3t8JfAC37IN\r\n" \ +"sVXS8/MCggEBALByOS59Y4Ktq1rLBQx8djwQyuneP0wZohUVAx7Gk7xZIfklQDyg\r\n" \ +"v/R4PrcVezstcPpDnykdjScCsGJR+uWc0v667I/ttP/e6utz5hVmmBGu965dPAzE\r\n" \ +"c1ggaSkOqFfRg/Nr2Qbf+fH0YPnHYSqHe/zSt0OMIvaaeXLcdKhEDSCUBRhE1HWB\r\n" \ +"kxR046WzgBeYzNQwycz9xwqsctJKGpeR9ute+5ANHPd3X9XtID0fqz8ctI5eZaSw\r\n" \ +"wApIW01ZQcAF8B+4WkkVuFXnpWW33yCOaRyPVOPHpnclr5WU1fS+3Q85QkW9rkej\r\n" \ +"97zlkl0QY9AHJqrXnoML1ywAK7ns+MVyNK8CggEAf62xcKZhOb1djeF72Ms+i/i/\r\n" \ +"WIAq4Q4YpsElgvJTHpNH2v9g4ngSTKe3ws3bGc502sWRlhcoTFMOW2rJNe/iqKkb\r\n" \ +"3cdeTkseDbpqozmJWz9dJWSVtXas2bZjzBEa//gQ7nHGVeQdqZJQ9rxPsoOAkfpi\r\n" \ +"qCFrmfUVUqC53e3XMt8+W+aSvKl+JZiB9ozkO9A6Q0vfQLKtjUMdQE3XaCFQT8DI\r\n" \ +"smaLBlBmeRaBpc02ENeC4ADlWosm1SwgxqMhuh2Alba/GrHOoPlVl4hDs9Fb5a6R\r\n" \ +"rmpXSt07GAxnG6j9jssA95E4rc1zO0CVKG5bvjVTxwi/sT0/VVX7VsJM4uTAQg==\r\n" \ +"-----END RSA PRIVATE KEY-----\r\n" + +#if defined _MSC_VER && !defined snprintf +#define snprintf _snprintf +#endif + +/* + * For heap usage estimates, we need an estimate of the overhead per allocated + * block. ptmalloc2/3 (used in gnu libc for instance) uses 2 size_t per block, + * so use that as our baseline. + */ +#define MEM_BLOCK_OVERHEAD ( 2 * sizeof( size_t ) ) + +/* + * Size to use for the malloc buffer if MEMORY_BUFFER_ALLOC_C is defined. + */ +#define HEAP_SIZE (1u << 16) // 64k + +#define BUFSIZE 1024 +#define HEADER_FORMAT " %-24s : " +#define TITLE_LEN 25 + +#define OPTIONS \ + "md4, md5, ripemd160, sha1, sha256, sha512,\r\n" \ + "arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\r\n" \ + "havege, ctr_drbg, hmac_drbg\r\n" \ + "rsa, dhm, ecdsa, ecdh.\r\n" + +#if defined(MBEDTLS_ERROR_C) +#define PRINT_ERROR \ + mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \ + mbedtls_printf( "FAILED: %s\r\n", tmp ); +#else +#define PRINT_ERROR \ + mbedtls_printf( "FAILED: -0x%04x\r\n", -ret ); +#endif + +static unsigned long mbedtls_timing_hardclock( void ) +{ + static int dwt_started = 0; + + if( dwt_started == 0 ) + { + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; + } + + return( DWT->CYCCNT ); +} + +static volatile int alarmed; +static void alarm() { alarmed = 1; } + +#define TIME_AND_TSC( TITLE, CODE ) \ +do { \ + unsigned long i, j, tsc; \ + Timeout t; \ + \ + mbedtls_printf( HEADER_FORMAT, TITLE ); \ + fflush( stdout ); \ + \ + for( i = 1, alarmed = 0, t.attach( alarm, 1.0 ); !alarmed; i++ ) \ + { \ + CODE; \ + } \ + \ + tsc = mbedtls_timing_hardclock(); \ + for( j = 0; j < 1024; j++ ) \ + { \ + CODE; \ + } \ + \ + mbedtls_printf( "%9lu Kb/s, %9lu cycles/byte\r\n", \ + i * BUFSIZE / 1024, \ + ( mbedtls_timing_hardclock() - tsc ) / ( j * BUFSIZE ) ); \ +} while( 0 ) + +#if defined(MBEDTLS_ERROR_C) +#define PRINT_ERROR \ + mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \ + mbedtls_printf( "FAILED: %s\r\n", tmp ); +#else +#define PRINT_ERROR \ + mbedtls_printf( "FAILED: -0x%04x\r\n", -ret ); +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG) + +#define MEMORY_MEASURE_INIT \ + size_t max_used, max_blocks, max_bytes; \ + size_t prv_used, prv_blocks; \ + mbedtls_memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \ + mbedtls_memory_buffer_alloc_max_reset( ); + +#define MEMORY_MEASURE_PRINT( title_len ) \ + mbedtls_memory_buffer_alloc_max_get( &max_used, &max_blocks ); \ + for( i = 12 - title_len; i != 0; i-- ) mbedtls_printf( " " ); \ + max_used -= prv_used; \ + max_blocks -= prv_blocks; \ + max_bytes = max_used + MEM_BLOCK_OVERHEAD * max_blocks; \ + mbedtls_printf( "%6u heap bytes", (unsigned) max_bytes ); + +#else +#define MEMORY_MEASURE_INIT +#define MEMORY_MEASURE_PRINT( title_len ) +#endif + +#define TIME_PUBLIC( TITLE, TYPE, CODE ) \ +do { \ + unsigned long ms; \ + int ret = 0; \ + Timer t; \ + MEMORY_MEASURE_INIT; \ + \ + mbedtls_printf( HEADER_FORMAT, TITLE ); \ + fflush( stdout ); \ + \ + t.start(); \ + CODE; \ + t.stop(); \ + ms = t.read_ms(); \ + \ + if( ret != 0 ) \ + { \ + PRINT_ERROR; \ + } \ + else \ + { \ + mbedtls_printf( "%6lu ms/" TYPE, ms ); \ + MEMORY_MEASURE_PRINT( sizeof( TYPE ) + 1 ); \ + mbedtls_printf( "\r\n" ); \ + } \ +} while( 0 ) + +static int myrand( void *rng_state, unsigned char *output, size_t len ) +{ + size_t use_len; + int rnd; + + if( rng_state != NULL ) + rng_state = NULL; + + while( len > 0 ) + { + use_len = len; + if( use_len > sizeof(int) ) + use_len = sizeof(int); + + rnd = rand(); + memcpy( output, &rnd, use_len ); + output += use_len; + len -= use_len; + } + + return( 0 ); +} + +/* + * Clear some memory that was used to prepare the context + */ +#if defined(MBEDTLS_ECP_C) +void ecp_clear_precomputed( mbedtls_ecp_group *grp ) +{ + if( grp->T != NULL ) + { + size_t i; + for( i = 0; i < grp->T_size; i++ ) + mbedtls_ecp_point_free( &grp->T[i] ); + mbedtls_free( grp->T ); + } + grp->T = NULL; + grp->T_size = 0; +} +#else +#define ecp_clear_precomputed( g ) +#endif + +unsigned char buf[BUFSIZE]; + +typedef struct { + char md4, md5, ripemd160, sha1, sha256, sha512, + arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish, + havege, ctr_drbg, hmac_drbg, + rsa, dhm, ecdsa, ecdh; +} todo_list; + +int benchmark( int argc, char *argv[] ) +{ + int i; + unsigned char tmp[200]; + char title[TITLE_LEN]; + todo_list todo; +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + unsigned char malloc_buf[HEAP_SIZE] = { 0 }; +#endif + + if( argc <= 1 ) + { + memset( &todo, 1, sizeof( todo ) ); + } + else + { + memset( &todo, 0, sizeof( todo ) ); + + for( i = 1; i < argc; i++ ) + { + if( strcmp( argv[i], "md4" ) == 0 ) + todo.md4 = 1; + else if( strcmp( argv[i], "md5" ) == 0 ) + todo.md5 = 1; + else if( strcmp( argv[i], "ripemd160" ) == 0 ) + todo.ripemd160 = 1; + else if( strcmp( argv[i], "sha1" ) == 0 ) + todo.sha1 = 1; + else if( strcmp( argv[i], "sha256" ) == 0 ) + todo.sha256 = 1; + else if( strcmp( argv[i], "sha512" ) == 0 ) + todo.sha512 = 1; + else if( strcmp( argv[i], "arc4" ) == 0 ) + todo.arc4 = 1; + else if( strcmp( argv[i], "des3" ) == 0 ) + todo.des3 = 1; + else if( strcmp( argv[i], "des" ) == 0 ) + todo.des = 1; + else if( strcmp( argv[i], "aes_cbc" ) == 0 ) + todo.aes_cbc = 1; + else if( strcmp( argv[i], "aes_gcm" ) == 0 ) + todo.aes_gcm = 1; + else if( strcmp( argv[i], "aes_ccm" ) == 0 ) + todo.aes_ccm = 1; + else if( strcmp( argv[i], "camellia" ) == 0 ) + todo.camellia = 1; + else if( strcmp( argv[i], "blowfish" ) == 0 ) + todo.blowfish = 1; + else if( strcmp( argv[i], "havege" ) == 0 ) + todo.havege = 1; + else if( strcmp( argv[i], "ctr_drbg" ) == 0 ) + todo.ctr_drbg = 1; + else if( strcmp( argv[i], "hmac_drbg" ) == 0 ) + todo.hmac_drbg = 1; + else if( strcmp( argv[i], "rsa" ) == 0 ) + todo.rsa = 1; + else if( strcmp( argv[i], "dhm" ) == 0 ) + todo.dhm = 1; + else if( strcmp( argv[i], "ecdsa" ) == 0 ) + todo.ecdsa = 1; + else if( strcmp( argv[i], "ecdh" ) == 0 ) + todo.ecdh = 1; + else + { + mbedtls_printf( "Unrecognized option: %s\r\n", argv[i] ); + mbedtls_printf( "Available options: " OPTIONS ); + } + } + } + + mbedtls_printf( "\r\n\r\n" ); + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_init( malloc_buf, sizeof( malloc_buf ) ); +#endif + memset( buf, 0xAA, sizeof( buf ) ); + memset( tmp, 0xBB, sizeof( tmp ) ); + +#if defined(MBEDTLS_MD4_C) + if( todo.md4 ) + TIME_AND_TSC( "MD4", mbedtls_md4( buf, BUFSIZE, tmp ) ); +#endif + +#if defined(MBEDTLS_MD5_C) + if( todo.md5 ) + TIME_AND_TSC( "MD5", mbedtls_md5( buf, BUFSIZE, tmp ) ); +#endif + +#if defined(MBEDTLS_RIPEMD160_C) + if( todo.ripemd160 ) + TIME_AND_TSC( "RIPEMD160", mbedtls_ripemd160( buf, BUFSIZE, tmp ) ); +#endif + +#if defined(MBEDTLS_SHA1_C) + if( todo.sha1 ) + TIME_AND_TSC( "SHA-1", mbedtls_sha1( buf, BUFSIZE, tmp ) ); +#endif + +#if defined(MBEDTLS_SHA256_C) + if( todo.sha256 ) + TIME_AND_TSC( "SHA-256", mbedtls_sha256( buf, BUFSIZE, tmp, 0 ) ); +#endif + +#if defined(MBEDTLS_SHA512_C) + if( todo.sha512 ) + TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) ); +#endif + +#if defined(MBEDTLS_ARC4_C) + if( todo.arc4 ) + { + mbedtls_arc4_context arc4; + mbedtls_arc4_init( &arc4 ); + mbedtls_arc4_setup( &arc4, tmp, 32 ); + TIME_AND_TSC( "ARC4", mbedtls_arc4_crypt( &arc4, BUFSIZE, buf, buf ) ); + mbedtls_arc4_free( &arc4 ); + } +#endif + +#if defined(MBEDTLS_DES_C) && defined(MBEDTLS_CIPHER_MODE_CBC) + if( todo.des3 ) + { + mbedtls_des3_context des3; + mbedtls_des3_init( &des3 ); + mbedtls_des3_set3key_enc( &des3, tmp ); + TIME_AND_TSC( "3DES", + mbedtls_des3_crypt_cbc( &des3, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); + mbedtls_des3_free( &des3 ); + } + + if( todo.des ) + { + mbedtls_des_context des; + mbedtls_des_init( &des ); + mbedtls_des_setkey_enc( &des, tmp ); + TIME_AND_TSC( "DES", + mbedtls_des_crypt_cbc( &des, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); + mbedtls_des_free( &des ); + } +#endif + +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_CIPHER_MODE_CBC) + if( todo.aes_cbc ) + { + int keysize; + mbedtls_aes_context aes; + mbedtls_aes_init( &aes ); + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + mbedtls_snprintf( title, sizeof( title ), "AES-CBC-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_aes_setkey_enc( &aes, tmp, keysize ); + + TIME_AND_TSC( title, + mbedtls_aes_crypt_cbc( &aes, MBEDTLS_AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); + } + mbedtls_aes_free( &aes ); + } +#endif +#if defined(MBEDTLS_GCM_C) + if( todo.aes_gcm ) + { + int keysize; + mbedtls_gcm_context gcm; + + mbedtls_gcm_init( &gcm ); + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + mbedtls_snprintf( title, sizeof( title ), "AES-GCM-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_gcm_setkey( &gcm, MBEDTLS_CIPHER_ID_AES, tmp, keysize ); + + TIME_AND_TSC( title, + mbedtls_gcm_crypt_and_tag( &gcm, MBEDTLS_GCM_ENCRYPT, BUFSIZE, tmp, + 12, NULL, 0, buf, buf, 16, tmp ) ); + + mbedtls_gcm_free( &gcm ); + } + } +#endif +#if defined(MBEDTLS_CCM_C) + if( todo.aes_ccm ) + { + int keysize; + mbedtls_ccm_context ccm; + + mbedtls_ccm_init( &ccm ); + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + mbedtls_snprintf( title, sizeof( title ), "AES-CCM-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_ccm_setkey( &ccm, MBEDTLS_CIPHER_ID_AES, tmp, keysize ); + + TIME_AND_TSC( title, + mbedtls_ccm_encrypt_and_tag( &ccm, BUFSIZE, tmp, + 12, NULL, 0, buf, buf, tmp, 16 ) ); + + mbedtls_ccm_free( &ccm ); + } + } +#endif +#endif + +#if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC) + if( todo.camellia ) + { + int keysize; + mbedtls_camellia_context camellia; + mbedtls_camellia_init( &camellia ); + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + mbedtls_snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_camellia_setkey_enc( &camellia, tmp, keysize ); + + TIME_AND_TSC( title, + mbedtls_camellia_crypt_cbc( &camellia, MBEDTLS_CAMELLIA_ENCRYPT, + BUFSIZE, tmp, buf, buf ) ); + } + mbedtls_camellia_free( &camellia ); + } +#endif + +#if defined(MBEDTLS_BLOWFISH_C) && defined(MBEDTLS_CIPHER_MODE_CBC) + if( todo.blowfish ) + { + int keysize; + mbedtls_blowfish_context blowfish; + mbedtls_blowfish_init( &blowfish ); + + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + mbedtls_snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_blowfish_setkey( &blowfish, tmp, keysize ); + + TIME_AND_TSC( title, + mbedtls_blowfish_crypt_cbc( &blowfish, MBEDTLS_BLOWFISH_ENCRYPT, BUFSIZE, + tmp, buf, buf ) ); + } + + mbedtls_blowfish_free( &blowfish ); + } +#endif + +#if defined(MBEDTLS_HAVEGE_C) + if( todo.havege ) + { + mbedtls_havege_state hs; + mbedtls_havege_init( &hs ); + TIME_AND_TSC( "HAVEGE", mbedtls_havege_random( &hs, buf, BUFSIZE ) ); + mbedtls_havege_free( &hs ); + } +#endif + +#if defined(MBEDTLS_CTR_DRBG_C) + if( todo.ctr_drbg ) + { + mbedtls_ctr_drbg_context ctr_drbg; + + mbedtls_ctr_drbg_init( &ctr_drbg ); + + if( mbedtls_ctr_drbg_seed( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) + mbedtls_exit(1); + TIME_AND_TSC( "CTR_DRBG (NOPR)", + if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) + mbedtls_exit(1) ); + + if( mbedtls_ctr_drbg_seed( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) + mbedtls_exit(1); + mbedtls_ctr_drbg_set_prediction_resistance( &ctr_drbg, MBEDTLS_CTR_DRBG_PR_ON ); + TIME_AND_TSC( "CTR_DRBG (PR)", + if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) + mbedtls_exit(1) ); + mbedtls_ctr_drbg_free( &ctr_drbg ); + } +#endif + +#if defined(MBEDTLS_HMAC_DRBG_C) + if( todo.hmac_drbg ) + { + mbedtls_hmac_drbg_context hmac_drbg; + const mbedtls_md_info_t *md_info; + + mbedtls_hmac_drbg_init( &hmac_drbg ); + +#if defined(MBEDTLS_SHA1_C) + if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ) ) == NULL ) + mbedtls_exit(1); + + if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) + mbedtls_exit(1); + TIME_AND_TSC( "HMAC_DRBG SHA-1 (NOPR)", + if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) + mbedtls_exit(1) ); + mbedtls_hmac_drbg_free( &hmac_drbg ); + + if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) + mbedtls_exit(1); + mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg, + MBEDTLS_HMAC_DRBG_PR_ON ); + TIME_AND_TSC( "HMAC_DRBG SHA-1 (PR)", + if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) + mbedtls_exit(1) ); + mbedtls_hmac_drbg_free( &hmac_drbg ); +#endif + +#if defined(MBEDTLS_SHA256_C) + if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ) ) == NULL ) + mbedtls_exit(1); + + if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) + mbedtls_exit(1); + TIME_AND_TSC( "HMAC_DRBG SHA-256 (NOPR)", + if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) + mbedtls_exit(1) ); + mbedtls_hmac_drbg_free( &hmac_drbg ); + + if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) + mbedtls_exit(1); + mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg, + MBEDTLS_HMAC_DRBG_PR_ON ); + TIME_AND_TSC( "HMAC_DRBG SHA-256 (PR)", + if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) + mbedtls_exit(1) ); + mbedtls_hmac_drbg_free( &hmac_drbg ); +#endif + } +#endif + +#if defined(MBEDTLS_RSA_C) && \ + defined(MBEDTLS_PEM_PARSE_C) && defined(MBEDTLS_PK_PARSE_C) + if( todo.rsa ) + { + mbedtls_pk_context pk; + mbedtls_rsa_context *rsa; + const char *rsa_keys[] = { RSA_PRIVATE_KEY_2048, RSA_PRIVATE_KEY_4096 }; + size_t i; + + for( i = 0; i < sizeof( rsa_keys ) / sizeof( rsa_keys[0] ); i++ ) + { + mbedtls_pk_init( &pk ); + mbedtls_pk_parse_key( &pk, (const unsigned char *) rsa_keys[i], + strlen( rsa_keys[i] ) + 1, NULL, 0 ); + rsa = mbedtls_pk_rsa( pk ); + + mbedtls_snprintf( title, sizeof( title ), "RSA-%d", mbedtls_pk_get_bitlen( &pk ) ); + + TIME_PUBLIC( title, " public", + buf[0] = 0; + ret = mbedtls_rsa_public( rsa, buf, buf ) ); + + TIME_PUBLIC( title, "private", + buf[0] = 0; + ret = mbedtls_rsa_private( rsa, myrand, NULL, buf, buf ) ); + + mbedtls_pk_free( &pk ); + } + } +#endif + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_BIGNUM_C) + if( todo.dhm ) + { + int dhm_sizes[] = { 2048, 3072 }; + const char *dhm_P[] = { + MBEDTLS_DHM_RFC3526_MODP_2048_P, + MBEDTLS_DHM_RFC3526_MODP_3072_P, + }; + const char *dhm_G[] = { + MBEDTLS_DHM_RFC3526_MODP_2048_G, + MBEDTLS_DHM_RFC3526_MODP_3072_G, + }; + + mbedtls_dhm_context dhm; + size_t olen; + for( i = 0; (size_t) i < sizeof( dhm_sizes ) / sizeof( dhm_sizes[0] ); i++ ) + { + mbedtls_dhm_init( &dhm ); + + if( mbedtls_mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 || + mbedtls_mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 ) + { + mbedtls_exit( 1 ); + } + + dhm.len = mbedtls_mpi_size( &dhm.P ); + mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, myrand, NULL ); + if( mbedtls_mpi_copy( &dhm.GY, &dhm.GX ) != 0 ) + mbedtls_exit( 1 ); + + mbedtls_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] ); + TIME_PUBLIC( title, "handshake", + ret |= mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, + myrand, NULL ); + ret |= mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &olen, myrand, NULL ) ); + + mbedtls_snprintf( title, sizeof( title ), "DH-%d", dhm_sizes[i] ); + TIME_PUBLIC( title, "handshake", + ret |= mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &olen, myrand, NULL ) ); + + mbedtls_dhm_free( &dhm ); + } + } +#endif + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_SHA256_C) + if( todo.ecdsa ) + { + mbedtls_ecdsa_context ecdsa; + const mbedtls_ecp_curve_info *curve_info; + size_t sig_len; + + memset( buf, 0x2A, sizeof( buf ) ); + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + mbedtls_ecdsa_init( &ecdsa ); + + if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ) + mbedtls_exit( 1 ); + ecp_clear_precomputed( &ecdsa.grp ); + + mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s", + curve_info->name ); + TIME_PUBLIC( title, "sign", + ret = mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->bit_size, + tmp, &sig_len, myrand, NULL ) ); + + mbedtls_ecdsa_free( &ecdsa ); + } + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + mbedtls_ecdsa_init( &ecdsa ); + + if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 || + mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->bit_size, + tmp, &sig_len, myrand, NULL ) != 0 ) + { + mbedtls_exit( 1 ); + } + ecp_clear_precomputed( &ecdsa.grp ); + + mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s", + curve_info->name ); + TIME_PUBLIC( title, "verify", + ret = mbedtls_ecdsa_read_signature( &ecdsa, buf, curve_info->bit_size, + tmp, sig_len ) ); + + mbedtls_ecdsa_free( &ecdsa ); + } + } +#endif + +#if defined(MBEDTLS_ECDH_C) + if( todo.ecdh ) + { + mbedtls_ecdh_context ecdh; +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + mbedtls_mpi z; +#endif + const mbedtls_ecp_curve_info *curve_info; + size_t olen; + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + mbedtls_ecdh_init( &ecdh ); + + if( mbedtls_ecp_group_load( &ecdh.grp, curve_info->grp_id ) != 0 || + mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), + myrand, NULL ) != 0 || + mbedtls_ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 ) + { + mbedtls_exit( 1 ); + } + ecp_clear_precomputed( &ecdh.grp ); + + mbedtls_snprintf( title, sizeof( title ), "ECDHE-%s", + curve_info->name ); + TIME_PUBLIC( title, "handshake", + ret |= mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), + myrand, NULL ); + ret |= mbedtls_ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ), + myrand, NULL ) ); + mbedtls_ecdh_free( &ecdh ); + } + + /* Curve25519 needs to be handled separately */ +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + mbedtls_ecdh_init( &ecdh ); + mbedtls_mpi_init( &z ); + + if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || + mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 ) + { + mbedtls_exit( 1 ); + } + + TIME_PUBLIC( "ECDHE-Curve25519", "handshake", + ret |= mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, + myrand, NULL ); + ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, + myrand, NULL ) ); + + mbedtls_ecdh_free( &ecdh ); + mbedtls_mpi_free( &z ); +#endif + + for( curve_info = mbedtls_ecp_curve_list(); + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) + { + mbedtls_ecdh_init( &ecdh ); + + if( mbedtls_ecp_group_load( &ecdh.grp, curve_info->grp_id ) != 0 || + mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), + myrand, NULL ) != 0 || + mbedtls_ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 || + mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), + myrand, NULL ) != 0 ) + { + mbedtls_exit( 1 ); + } + ecp_clear_precomputed( &ecdh.grp ); + + mbedtls_snprintf( title, sizeof( title ), "ECDH-%s", + curve_info->name ); + TIME_PUBLIC( title, "handshake", + ret |= mbedtls_ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ), + myrand, NULL ) ); + mbedtls_ecdh_free( &ecdh ); + } + + /* Curve25519 needs to be handled separately */ +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + mbedtls_ecdh_init( &ecdh ); + mbedtls_mpi_init( &z ); + + if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || + mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, + myrand, NULL ) != 0 || + mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 ) + { + mbedtls_exit( 1 ); + } + + TIME_PUBLIC( "ECDH-Curve25519", "handshake", + ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, + myrand, NULL ) ); + + mbedtls_ecdh_free( &ecdh ); + mbedtls_mpi_free( &z ); +#endif + } +#endif + + mbedtls_printf( "\r\n" ); + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_free(); +#endif + +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\r\n" ); + fflush( stdout ); getchar(); +#endif + + return( 0 ); +} + +#include "mbed-drivers/test_env.h" +#include "minar/minar.h" + +static void run() { + MBED_HOSTTEST_TIMEOUT(150); + MBED_HOSTTEST_SELECT(default); + MBED_HOSTTEST_DESCRIPTION(mbed TLS benchmark program); + MBED_HOSTTEST_START("MBEDTLS_BENCHMARK"); + MBED_HOSTTEST_RESULT(benchmark(0, NULL) == 0); +} + +void app_start(int, char*[]) { + /* Use 115200 bps for consistency with other examples */ + get_stdio_serial().baud(115200); + minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); +} + +#endif /* TARGET_LIKE_MBED */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/README.md new file mode 100644 index 0000000..553c3a6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/README.md @@ -0,0 +1,67 @@ +# SHA-256 Hash Example + +This application performs hashing of a buffer with SHA-256 using various APIs. It serves as a tutorial for the basic hashing APIs of mbed TLS. + +## Pre-requisites + +To build and run this example you must have: + +* A computer with the following software installed: + * [CMake](http://www.cmake.org/download/). + * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). + * [Python](https://www.python.org/downloads/). + * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). + * A serial terminal emulator (Like screen, pySerial and cu). +* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). +* A micro-USB cable. +* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). + +## Getting started + +1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. + +2. Navigate to the mbedtls directory supplied with your release and open a terminal. + +3. Set the yotta target: + + ``` + yotta target frdm-k64f-gcc + ``` + +4. Build mbedtls and the examples. This may take a long time if this is your first compilation: + + ``` + $ yotta build + ``` + +5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-hashing.bin` to your mbed board and wait until the LED next to the USB port stops blinking. + +6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. + + Use the following settings: + + * 115200 baud (not 9600). + * 8N1. + * No flow control. + +7. Press the Reset button on the board. + +8. The output in the terminal window should look like: + + ``` + {{timeout;10}} + {{host_test_name;default}} + {{description;mbed TLS example on hashing}} + {{test_id;MBEDTLS_EX_HASHING}} + {{start}} + + + Method 1: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 + Method 2: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 + Method 3: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 + Method 4: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 + + DONE + {{success}} + {{end}} + ``` diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/main.cpp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/main.cpp new file mode 100644 index 0000000..574152a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-hashing/main.cpp @@ -0,0 +1,177 @@ +/* + * Hello world example of using the hashing functions of mbed TLS + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * This program illustrates various ways of hashing a buffer. + * You normally need only one of these two includes. + */ +#include "mbedtls/sha256.h" /* SHA-256 only */ +#include "mbedtls/md.h" /* generic interface */ + +#if defined(TARGET_LIKE_MBED) +#include "mbed-drivers/mbed.h" +#endif +#include + +static void print_hex(const char *title, const unsigned char buf[], size_t len) +{ + printf("%s: ", title); + + for (size_t i = 0; i < len; i++) + printf("%02x", buf[i]); + + printf("\r\n"); +} + +static const char hello_str[] = "Hello, world!"; +static const unsigned char *hello_buffer = (const unsigned char *) hello_str; +static const size_t hello_len = sizeof hello_str - 1; + +int example(void) +{ + printf( "\r\n\r\n" ); + + /* + * Method 1: use all-in-one function of a specific SHA-xxx module + */ + unsigned char output1[32]; /* SHA-256 outputs 32 bytes */ + + /* 0 here means use the full SHA-256, not the SHA-224 variant */ + mbedtls_sha256(hello_buffer, hello_len, output1, 0); + + print_hex("Method 1", output1, sizeof output1); + + + /* + * Method 2: use the streaming interface of a specific SHA-xxx module + * This is useful if we get our input piecewise. + */ + unsigned char output2[32]; + mbedtls_sha256_context ctx2; + + mbedtls_sha256_init(&ctx2); + mbedtls_sha256_starts(&ctx2, 0); /* SHA-256, not 224 */ + + /* Simulating multiple fragments */ + mbedtls_sha256_update(&ctx2, hello_buffer, 1); + mbedtls_sha256_update(&ctx2, hello_buffer + 1, 1); + mbedtls_sha256_update(&ctx2, hello_buffer + 2, hello_len - 2); + + mbedtls_sha256_finish(&ctx2, output2); + print_hex("Method 2", output2, sizeof output2); + + /* Or you could re-use the context by doing mbedtls_sha256_starts() again */ + mbedtls_sha256_free(&ctx2); + + /* + * Method 3: use all-in-one function of the generice interface + */ + unsigned char output3[MBEDTLS_MD_MAX_SIZE]; /* Enough for any hash */ + + /* Can easily pick any hash you want, by identifier */ + const mbedtls_md_info_t *md_info3 = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + + if (md_info3 == NULL) + { + printf("SHA256 not available\r\n"); + return 1; + } + + int ret3 = mbedtls_md(md_info3, hello_buffer, hello_len, output3); + + if (ret3 != 0) + { + printf("md() returned -0x%04X\r\n", -ret3); + return 1; + } + + print_hex("Method 3", output3, mbedtls_md_get_size(md_info3)); + + + /* + * Method 4: streaming & generic interface + */ + unsigned char output4[MBEDTLS_MD_MAX_SIZE]; /* Enough for any hash */ + + const mbedtls_md_info_t *md_info4 = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + + if (md_info4 == NULL) + { + printf("SHA256 not available\r\n"); + return 1; + } + + mbedtls_md_context_t ctx4; + + mbedtls_md_init(&ctx4); + + int ret4 = mbedtls_md_init_ctx(&ctx4, md_info4); + if (ret4 != 0) + { + printf("md_init_ctx() returned -0x%04X\r\n", -ret4); + return 1; + } + + mbedtls_md_starts(&ctx4); + + /* Simulating multiple fragments */ + mbedtls_md_update(&ctx4, hello_buffer, 1); + mbedtls_md_update(&ctx4, hello_buffer + 1, 1); + mbedtls_md_update(&ctx4, hello_buffer + 2, hello_len - 2); + + mbedtls_md_finish(&ctx4, output4); + print_hex("Method 4", output4, mbedtls_md_get_size(md_info4)); + + /* Or you could re-use the context by doing mbedtls_md_starts() again */ + mbedtls_md_free(&ctx4); + + + printf("\r\nDONE\r\n"); + + return 0; +} + +#if defined(TARGET_LIKE_MBED) + +#include "mbed-drivers/test_env.h" +#include "minar/minar.h" + +static void run() { + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default); + MBED_HOSTTEST_DESCRIPTION(mbed TLS example on hashing); + MBED_HOSTTEST_START("MBEDTLS_EX_HASHING"); + MBED_HOSTTEST_RESULT(example() == 0); +} + +void app_start(int, char*[]) { + /* Use 115200 bps for consistency with other examples */ + get_stdio_serial().baud(115200); + minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); +} + +#else + +int main() { + return example(); +} + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/README.md new file mode 100644 index 0000000..5bc22a6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/README.md @@ -0,0 +1,82 @@ +# mbed TLS Selftest Example + +This application runs the various selftest functions of individual mbed TLS components. It serves as a basic sanity check to verify operation of mbed TLS on your platform. In the future, a wider portion of the mbed TLS test suite will become part of this example application. + +## Pre-requisites + +To build and run this example you must have: + +* A computer with the following software installed: + * [CMake](http://www.cmake.org/download/). + * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). + * [Python](https://www.python.org/downloads/). + * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). + * A serial terminal emulator (Like screen, pySerial and cu). +* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). +* A micro-USB cable. +* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). + +## Getting started + +1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. + +2. Navigate to the mbedtls directory supplied with your release and open a terminal. + +3. Set the yotta target: + + ``` + yotta target frdm-k64f-gcc + ``` + +4. Build mbedtls and the examples. This may take a long time if this is your first compilation: + + ``` + $ yotta build + ``` + +5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-selftest.bin` to your mbed board and wait until the LED next to the USB port stops blinking. + +6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. + + Use the following settings: + + * 115200 baud (not 9600). + * 8N1. + * No flow control. + +7. Press the Reset button on the board. + +8. The output in the terminal window should look like: + + ``` + {{timeout;40}} + {{host_test_name;default}} + {{description;mbed TLS selftest program}} + {{test_id;MBEDTLS_SELFTEST}} + {{start}} + + SHA-224 test #1: passed + SHA-224 test #2: passed + SHA-224 test #3: passed + SHA-256 test #1: passed + SHA-256 test #2: passed + SHA-256 test #3: passed + + [ ... several lines omitted ... ] + + CTR_DRBG (PR = TRUE) : passed + CTR_DRBG (PR = FALSE): passed + + HMAC_DRBG (PR = True) : passed + HMAC_DRBG (PR = False) : passed + + ECP test #1 (constant op_count, base point G): passed + ECP test #2 (constant op_count, other point): passed + + ENTROPY test: passed + + [ All tests passed ] + + {{success}} + {{end}} + ``` diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/main.cpp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/main.cpp new file mode 100644 index 0000000..0ff5b04 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/example-selftest/main.cpp @@ -0,0 +1,268 @@ +/* + * Self-test demonstration program + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(POLARSSL_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "mbedtls/entropy.h" +#include "mbedtls/hmac_drbg.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/dhm.h" +#include "mbedtls/gcm.h" +#include "mbedtls/ccm.h" +#include "mbedtls/md2.h" +#include "mbedtls/md4.h" +#include "mbedtls/md5.h" +#include "mbedtls/ripemd160.h" +#include "mbedtls/sha1.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +#include "mbedtls/arc4.h" +#include "mbedtls/des.h" +#include "mbedtls/aes.h" +#include "mbedtls/camellia.h" +#include "mbedtls/base64.h" +#include "mbedtls/bignum.h" +#include "mbedtls/rsa.h" +#include "mbedtls/x509.h" +#include "mbedtls/xtea.h" +#include "mbedtls/pkcs5.h" +#include "mbedtls/ecp.h" + +#include +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#include "mbedtls/memory_buffer_alloc.h" +#endif + +int selftest( int argc, char *argv[] ) +{ + int ret = 0, v; +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + unsigned char buf[1000000]; +#endif + + if( argc == 2 && strcmp( argv[1], "-quiet" ) == 0 ) + v = 0; + else + { + v = 1; + mbedtls_printf( "\n" ); + } + +#if defined(MBEDTLS_SELF_TEST) + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) ); +#endif + +#if defined(MBEDTLS_MD2_C) + if( ( ret = mbedtls_md2_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_MD4_C) + if( ( ret = mbedtls_md4_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_MD5_C) + if( ( ret = mbedtls_md5_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_RIPEMD160_C) + if( ( ret = mbedtls_ripemd160_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_SHA1_C) + if( ( ret = mbedtls_sha1_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_SHA256_C) + if( ( ret = mbedtls_sha256_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_SHA512_C) + if( ( ret = mbedtls_sha512_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_ARC4_C) + if( ( ret = mbedtls_arc4_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_DES_C) + if( ( ret = mbedtls_des_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_AES_C) + if( ( ret = mbedtls_aes_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C) + if( ( ret = mbedtls_gcm_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C) + if( ( ret = mbedtls_ccm_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_BASE64_C) + if( ( ret = mbedtls_base64_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_BIGNUM_C) + if( ( ret = mbedtls_mpi_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_RSA_C) + if( ( ret = mbedtls_rsa_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_X509_USE_C) + if( ( ret = mbedtls_x509_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_XTEA_C) + if( ( ret = mbedtls_xtea_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_CAMELLIA_C) + if( ( ret = mbedtls_camellia_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_CTR_DRBG_C) + if( ( ret = mbedtls_ctr_drbg_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_HMAC_DRBG_C) + if( ( ret = mbedtls_hmac_drbg_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_ECP_C) + if( ( ret = mbedtls_ecp_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_DHM_C) + if( ( ret = mbedtls_dhm_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_ENTROPY_C) + if( ( ret = mbedtls_entropy_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_PKCS5_C) + if( ( ret = mbedtls_pkcs5_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#if defined(MBEDTLS_TIMING_C) + if( ( ret = mbedtls_timing_self_test( v ) ) != 0 ) + return( ret ); +#endif + +#else + mbedtls_printf( " POLARSSL_SELF_TEST not defined.\n" ); +#endif + + if( v != 0 ) + { +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_memory_buffer_alloc_status(); +#endif + } + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + mbedtls_memory_buffer_alloc_free(); + + if( ( ret = mbedtls_memory_buffer_alloc_self_test( v ) ) != 0 ) + return( ret ); +#endif + + if( v != 0 ) + { + mbedtls_printf( " [ All tests passed ]\n\n" ); +#if defined(_WIN32) + mbedtls_printf( " Press Enter to exit this program.\n" ); + fflush( stdout ); getchar(); +#endif + } + + return( ret ); +} + +#if defined(TARGET_LIKE_MBED) + +#include "mbed-drivers/test_env.h" +#include "minar/minar.h" + +static void run() { + MBED_HOSTTEST_TIMEOUT(40); + MBED_HOSTTEST_SELECT(default); + MBED_HOSTTEST_DESCRIPTION(mbed TLS selftest program); + MBED_HOSTTEST_START("MBEDTLS_SELFTEST"); + MBED_HOSTTEST_RESULT(selftest(0, NULL) == 0); +} + +void app_start(int, char*[]) { + /* Use 115200 bps for consistency with other examples */ + get_stdio_serial().baud(115200); + minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); +} + +#else + +int main() { + return selftest(0, NULL); +} + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/target_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/target_config.h new file mode 100644 index 0000000..f350ce3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/mbedtls/yotta/data/target_config.h @@ -0,0 +1,35 @@ +/* + * Temporary target-specific config.h for entropy collection + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if defined(TARGET_LIKE_MBED) +#define MBEDTLS_NO_PLATFORM_ENTROPY +#undef MBEDTLS_HAVE_TIME_DATE +#undef MBEDTLS_FS_IO +#endif + +/* + * WARNING: this is temporary! + * This should be in a separate yotta module which would be a target + * dependency of mbedtls (see IOTSSL-313) + */ +#if defined(TARGET_LIKE_K64F) +#define MBEDTLS_ENTROPY_HARDWARE_ALT +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.bat b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.bat new file mode 100644 index 0000000..8593e79 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.bat @@ -0,0 +1,24 @@ +@ECHO OFF + +:: This script will use git (must be in %PATH%) and arm-none-eabi tools in combination with GNU Make +:: to both fetch and compile all variants of micro-ecc for the nRF5 families + +WHERE >nul 2>nul git +IF %ERRORLEVEL% NEQ 0 ( + ECHO "git is not installed. Please install and append to PATH." +) + +IF NOT EXIST micro-ecc/uECC.c ( + ECHO "micro-ecc not found! Let's pull it from HEAD." + git clone https://github.com/kmackay/micro-ecc.git +) + +make -C nrf51_armgcc/armgcc +make -C nrf51_iar/armgcc +make -C nrf51_keil/armgcc +make -C nrf52hf_armgcc/armgcc +make -C nrf52hf_iar/armgcc +make -C nrf52hf_keil/armgcc +make -C nrf52nf_armgcc/armgcc +make -C nrf52nf_iar/armgcc +make -C nrf52nf_keil/armgcc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.sh similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.sh rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.sh index 6942c16..15845d7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/build_all.sh +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/build_all.sh @@ -1,17 +1,16 @@ #!/bin/bash -# This script will use git (must be in $PATH) and arm-none-eabi tools in combination with GNU Make +# This script will use git (must be in $PATH) and arm-none-eabi tools in combination with GNU Make # to both fetch and compile all variants of micro-ecc for the nRF5 families -# pushd and popd are commands that are provided by both Windows and *NIX based OSes. if ! [ -x "$(command -v git)" ]; then - echo 'git is not installed. Please install and append to PATH' >&2 - exit + echo 'git is not installed. Please install and append to PATH.' >&2 + exit fi if [ ! -f micro-ecc/uECC.c ]; then echo "micro-ecc not found! Let's pull it from HEAD." - git clone https://github.com/kmackay/micro-ecc.git + git clone https://github.com/kmackay/micro-ecc.git fi make -C nrf51_armgcc/armgcc && diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/license.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/license.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/license.txt diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/.gitignore b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/.gitignore similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/.gitignore rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/.gitignore diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/LICENSE.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/LICENSE.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/LICENSE.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/LICENSE.txt diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/README.md similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/README.md rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/README.md diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_arm.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_arm.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_arm.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_arm.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_arm_mult_square.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_arm_mult_square.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_arm_mult_square.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_arm_mult_square.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_arm_mult_square_umaal.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_arm_mult_square_umaal.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_arm_mult_square_umaal.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_arm_mult_square_umaal.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_avr.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_avr.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_avr.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_avr.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_avr_mult_square.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_avr_mult_square.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/asm_avr_mult_square.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/asm_avr_mult_square.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/curve-specific.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/curve-specific.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/curve-specific.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/curve-specific.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/emk_project.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/emk_project.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/emk_project.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/emk_project.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/emk_rules.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/emk_rules.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/emk_rules.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/emk_rules.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/examples/ecc_test/ecc_test.ino b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/examples/ecc_test/ecc_test.ino similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/examples/ecc_test/ecc_test.ino rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/examples/ecc_test/ecc_test.ino diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/library.properties b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/library.properties similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/library.properties rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/library.properties diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/platform-specific.inc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/platform-specific.inc similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/platform-specific.inc rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/platform-specific.inc diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/mult_arm.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/mult_arm.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/mult_arm.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/mult_arm.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/mult_avr.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/mult_avr.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/mult_avr.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/mult_avr.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/mult_avr_extra.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/mult_avr_extra.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/mult_avr_extra.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/mult_avr_extra.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/square_arm.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/square_arm.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/square_arm.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/square_arm.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/square_avr.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/square_avr.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/scripts/square_avr.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/scripts/square_avr.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/emk_rules.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/emk_rules.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/emk_rules.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/emk_rules.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_compress.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_compress.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_compress.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_compress.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_compute.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_compute.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_compute.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_compute.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_ecdh.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_ecdh.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_ecdh.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_ecdh.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_ecdsa.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_ecdsa.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_ecdsa.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_ecdsa.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_ecdsa_deterministic.c.example b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_ecdsa_deterministic.c.example similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/test/test_ecdsa_deterministic.c.example rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/test/test_ecdsa_deterministic.c.example diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/types.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/types.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/uECC.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/uECC.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/uECC.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/uECC.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/uECC.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/uECC.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/uECC.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/uECC.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/uECC_vli.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/uECC_vli.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/micro-ecc/uECC_vli.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/micro-ecc/uECC_vli.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_armgcc/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_armgcc/armgcc/Makefile similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_armgcc/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_armgcc/armgcc/Makefile index b4d59ff..6ce6197 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_armgcc/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_armgcc/armgcc/Makefile @@ -12,47 +12,50 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags -OPT = -Os -g2 +OPT = -Os -g3 # Uncomment the line below to enable link time optimization #OPT += -flto # C flags common to all targets CFLAGS += $(OPT) -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m0 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums +CFLAGS += -fno-builtin -fshort-enums -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets -ASMFLAGS += -g2 +ASMFLAGS += -g3 ASMFLAGS += -mcpu=cortex-m0 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=soft -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld index 077581f..e16047c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -7,7 +7,6 @@ MEMORY { FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - } SECTIONS @@ -28,8 +27,8 @@ SECTIONS .mem_section_dummy_rom : { } - } INSERT AFTER .text -INCLUDE "nrf5x_common.ld" + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar/armgcc/Makefile similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar/armgcc/Makefile index 908563e..d9d4cae 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar/armgcc/Makefile @@ -12,47 +12,50 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags -OPT = -Os -g2 +OPT = -Os -gdwarf-3 # Uncomment the line below to enable link time optimization #OPT += -flto # C flags common to all targets CFLAGS += $(OPT) -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m0 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums -fshort-wchar +CFLAGS += -fno-builtin -fshort-enums -fshort-wchar -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets -ASMFLAGS += -g2 +ASMFLAGS += -gdwarf-3 ASMFLAGS += -mcpu=cortex-m0 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=soft -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld index 077581f..e16047c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -7,7 +7,6 @@ MEMORY { FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - } SECTIONS @@ -28,8 +27,8 @@ SECTIONS .mem_section_dummy_rom : { } - } INSERT AFTER .text -INCLUDE "nrf5x_common.ld" + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil/armgcc/Makefile similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil/armgcc/Makefile index 40521de..f9def93 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil/armgcc/Makefile @@ -12,6 +12,8 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ @@ -23,36 +25,37 @@ OPT = -Os -g2 # C flags common to all targets CFLAGS += $(OPT) -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m0 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums -fshort-wchar +CFLAGS += -fno-builtin -fshort-enums -fshort-wchar -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets ASMFLAGS += -g2 ASMFLAGS += -mcpu=cortex-m0 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=soft -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld index 077581f..e16047c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf51_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -7,7 +7,6 @@ MEMORY { FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - } SECTIONS @@ -28,8 +27,8 @@ SECTIONS .mem_section_dummy_rom : { } - } INSERT AFTER .text -INCLUDE "nrf5x_common.ld" + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile index 4f21de6..df6c6fe 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc/armgcc/Makefile @@ -12,49 +12,52 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags -OPT = -Os -g2 +OPT = -Os -g3 # Uncomment the line below to enable link time optimization #OPT += -flto # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DFLOAT_ABI_HARD -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums +CFLAGS += -fno-builtin -fshort-enums -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets -ASMFLAGS += -g2 +ASMFLAGS += -g3 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 ASMFLAGS += -DFLOAT_ABI_HARD -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld similarity index 91% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld index 077581f..e16047c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf51_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -7,7 +7,6 @@ MEMORY { FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 - } SECTIONS @@ -28,8 +27,8 @@ SECTIONS .mem_section_dummy_rom : { } - } INSERT AFTER .text -INCLUDE "nrf5x_common.ld" + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/Makefile similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/Makefile index 8f114b2..5003bd4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_iar/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/Makefile @@ -12,49 +12,52 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags -OPT = -Os -g2 +OPT = -Os -gdwarf-3 # Uncomment the line below to enable link time optimization #OPT += -flto # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DFLOAT_ABI_HARD -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums -fshort-wchar +CFLAGS += -fno-builtin -fshort-enums -fshort-wchar -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets -ASMFLAGS += -g2 +ASMFLAGS += -gdwarf-3 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 ASMFLAGS += -DFLOAT_ABI_HARD -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld new file mode 100644 index 0000000..e16047c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 + RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/Makefile similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/Makefile index 3adb445..e938888 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52hf_keil/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/Makefile @@ -12,6 +12,8 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ @@ -24,37 +26,38 @@ OPT = -Os -g2 # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DFLOAT_ABI_HARD -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums -fshort-wchar +CFLAGS += -fno-builtin -fshort-enums -fshort-wchar -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets ASMFLAGS += -g2 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 ASMFLAGS += -DFLOAT_ABI_HARD -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld new file mode 100644 index 0000000..e16047c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52hf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 + RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile similarity index 80% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile index 3918470..f3b7ca4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/Makefile @@ -12,49 +12,52 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags -OPT = -Os -g2 +OPT = -Os -g3 # Uncomment the line below to enable link time optimization #OPT += -flto # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DFLOAT_ABI_SOFT -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums +CFLAGS += -fno-builtin -fshort-enums -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets -ASMFLAGS += -g2 +ASMFLAGS += -g3 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=soft ASMFLAGS += -DFLOAT_ABI_SOFT -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld new file mode 100644 index 0000000..e16047c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_armgcc/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 + RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/Makefile similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/Makefile index f7f0164..e1ae26d 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_iar/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/Makefile @@ -12,49 +12,52 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags -OPT = -Os -g2 +OPT = -Os -gdwarf-3 # Uncomment the line below to enable link time optimization #OPT += -flto # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DFLOAT_ABI_SOFT -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums -fshort-wchar +CFLAGS += -fno-builtin -fshort-enums -fshort-wchar -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets -ASMFLAGS += -g2 +ASMFLAGS += -gdwarf-3 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=soft ASMFLAGS += -DFLOAT_ABI_SOFT -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld new file mode 100644 index 0000000..e16047c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_iar/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 + RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/Makefile similarity index 81% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/Makefile index a2114bd..41ee2d2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/micro-ecc/nrf52nf_keil/armgcc/Makefile +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/Makefile @@ -12,6 +12,8 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ + $(SDK_ROOT)/components/toolchain/cmsis/include \ + $(PROJ_DIR)/micro-ecc \ # Libraries common to all targets LIB_FILES += \ @@ -24,37 +26,38 @@ OPT = -Os -g2 # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DFLOAT_ABI_SOFT -CFLAGS += -DuECC_ENABLE_VLI_API +CFLAGS += -DuECC_ENABLE_VLI_API=0 CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -CFLAGS += -DuECC_SQUARE_FUNC=1 -CFLAGS += -DuECC_SUPPORTS_secp256r1=1 +CFLAGS += -DuECC_SQUARE_FUNC=0 CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing -CFLAGS += -fno-builtin -fshort-enums -fshort-wchar +CFLAGS += -fno-builtin -fshort-enums -fshort-wchar -Wno-unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) - # Assembler flags common to all targets ASMFLAGS += -g2 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=soft ASMFLAGS += -DFLOAT_ABI_SOFT -ASMFLAGS += -DuECC_ENABLE_VLI_API +ASMFLAGS += -DuECC_ENABLE_VLI_API=0 ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 -ASMFLAGS += -DuECC_SQUARE_FUNC=1 -ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 +ASMFLAGS += -DuECC_SQUARE_FUNC=0 ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 +micro_ecc_lib: CFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: CFLAGS += -D__STACK_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__HEAP_SIZE=4096 +micro_ecc_lib: ASMFLAGS += -D__STACK_SIZE=4096 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld new file mode 100644 index 0000000..e16047c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/micro-ecc/nrf52nf_keil/armgcc/ext_micro_ecc_gcc_nRF5x.ld @@ -0,0 +1,34 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x0 + RAM (rwx) : ORIGIN = 0x0, LENGTH = 0x0 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/LICENSE.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/LICENSE.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/LICENSE.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/LICENSE.txt diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/camel_case_splitter.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/camel_case_splitter.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/camel_case_splitter.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/camel_case_splitter.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/nanopb_generator.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/nanopb_generator.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/nanopb_generator.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/nanopb_generator.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/Makefile similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/Makefile rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/Makefile diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/__init__.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/__init__.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/__init__.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/__init__.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/google/protobuf/descriptor.proto b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/google/protobuf/descriptor.proto similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/google/protobuf/descriptor.proto rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/google/protobuf/descriptor.proto diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/nanopb.proto b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/nanopb.proto similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/nanopb.proto rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/nanopb.proto diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/nanopb_pb2.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/nanopb_pb2.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/nanopb_pb2.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/nanopb_pb2.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/plugin.proto b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/plugin.proto similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/plugin.proto rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/plugin.proto diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/plugin_pb2.py b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/plugin_pb2.py similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/proto/plugin_pb2.py rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/proto/plugin_pb2.py diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/protoc-gen-nanopb b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/protoc-gen-nanopb similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/protoc-gen-nanopb rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/protoc-gen-nanopb diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/protoc-gen-nanopb.bat b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/protoc-gen-nanopb.bat similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/generator/protoc-gen-nanopb.bat rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/generator/protoc-gen-nanopb.bat diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb.h similarity index 99% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb.h index a17280d..3fd2a4e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb.h @@ -22,7 +22,7 @@ /* #define PB_MAX_REQUIRED_FIELDS 256 */ /* Add support for tag numbers > 255 and fields larger than 255 bytes. */ -/* #define PB_FIELD_16BIT 1 */ +#define PB_FIELD_16BIT 1 /* Add support for tag numbers > 65536 and fields larger than 65536 bytes. */ /* #define PB_FIELD_32BIT 1 */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_common.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_common.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_common.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_common.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_common.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_common.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_decode.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_decode.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_decode.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_decode.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_decode.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_decode.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_decode.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_decode.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_encode.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_encode.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_encode.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_encode.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_encode.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_encode.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nano-pb/pb_encode.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano-pb/pb_encode.h diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.c new file mode 100644 index 0000000..c044cb5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.c @@ -0,0 +1,2393 @@ +/*lint -e???? -save */ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#include +#include +#include +#include "unity.h" +#include "cmock.h" +#include "mock_pb_decode.h" + +typedef struct _CMOCK_pb_decode_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_field_t* Expected_fields; + void* Expected_dest_struct; + int Expected_stream_Depth; + int Expected_fields_Depth; + int Expected_dest_struct_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_struct_Used; + void* ReturnThruPtr_dest_struct_Val; + int ReturnThruPtr_dest_struct_Size; + int IgnoreArg_stream; + int IgnoreArg_fields; + int IgnoreArg_dest_struct; + +} CMOCK_pb_decode_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_noinit_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_field_t* Expected_fields; + void* Expected_dest_struct; + int Expected_stream_Depth; + int Expected_fields_Depth; + int Expected_dest_struct_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_struct_Used; + void* ReturnThruPtr_dest_struct_Val; + int ReturnThruPtr_dest_struct_Size; + int IgnoreArg_stream; + int IgnoreArg_fields; + int IgnoreArg_dest_struct; + +} CMOCK_pb_decode_noinit_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_delimited_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_field_t* Expected_fields; + void* Expected_dest_struct; + int Expected_stream_Depth; + int Expected_fields_Depth; + int Expected_dest_struct_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_struct_Used; + void* ReturnThruPtr_dest_struct_Val; + int ReturnThruPtr_dest_struct_Size; + int IgnoreArg_stream; + int IgnoreArg_fields; + int IgnoreArg_dest_struct; + +} CMOCK_pb_decode_delimited_CALL_INSTANCE; + +typedef struct _CMOCK_pb_release_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + int CallOrder; + pb_field_t* Expected_fields; + void* Expected_dest_struct; + int Expected_fields_Depth; + int Expected_dest_struct_Depth; + int ReturnThruPtr_dest_struct_Used; + void* ReturnThruPtr_dest_struct_Val; + int ReturnThruPtr_dest_struct_Size; + int IgnoreArg_fields; + int IgnoreArg_dest_struct; + +} CMOCK_pb_release_CALL_INSTANCE; + +typedef struct _CMOCK_pb_istream_from_buffer_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + pb_istream_t ReturnVal; + int CallOrder; + pb_byte_t* Expected_buf; + size_t Expected_bufsize; + int Expected_buf_Depth; + int IgnoreArg_buf; + int IgnoreArg_bufsize; + +} CMOCK_pb_istream_from_buffer_CALL_INSTANCE; + +typedef struct _CMOCK_pb_read_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_byte_t* Expected_buf; + size_t Expected_count; + int Expected_stream_Depth; + int Expected_buf_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_buf_Used; + pb_byte_t* ReturnThruPtr_buf_Val; + int ReturnThruPtr_buf_Size; + int IgnoreArg_stream; + int IgnoreArg_buf; + int IgnoreArg_count; + +} CMOCK_pb_read_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_tag_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_wire_type_t* Expected_wire_type; + uint32_t* Expected_tag; + bool* Expected_eof; + int Expected_stream_Depth; + int Expected_wire_type_Depth; + int Expected_tag_Depth; + int Expected_eof_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_wire_type_Used; + pb_wire_type_t* ReturnThruPtr_wire_type_Val; + int ReturnThruPtr_wire_type_Size; + int ReturnThruPtr_tag_Used; + uint32_t* ReturnThruPtr_tag_Val; + int ReturnThruPtr_tag_Size; + int ReturnThruPtr_eof_Used; + bool* ReturnThruPtr_eof_Val; + int ReturnThruPtr_eof_Size; + int IgnoreArg_stream; + int IgnoreArg_wire_type; + int IgnoreArg_tag; + int IgnoreArg_eof; + +} CMOCK_pb_decode_tag_CALL_INSTANCE; + +typedef struct _CMOCK_pb_skip_field_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_wire_type_t Expected_wire_type; + int Expected_stream_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int IgnoreArg_stream; + int IgnoreArg_wire_type; + +} CMOCK_pb_skip_field_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_varint_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + uint64_t* Expected_dest; + int Expected_stream_Depth; + int Expected_dest_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_Used; + uint64_t* ReturnThruPtr_dest_Val; + int ReturnThruPtr_dest_Size; + int IgnoreArg_stream; + int IgnoreArg_dest; + +} CMOCK_pb_decode_varint_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_svarint_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + int64_t* Expected_dest; + int Expected_stream_Depth; + int Expected_dest_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_Used; + int64_t* ReturnThruPtr_dest_Val; + int ReturnThruPtr_dest_Size; + int IgnoreArg_stream; + int IgnoreArg_dest; + +} CMOCK_pb_decode_svarint_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_fixed32_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + void* Expected_dest; + int Expected_stream_Depth; + int Expected_dest_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_Used; + void* ReturnThruPtr_dest_Val; + int ReturnThruPtr_dest_Size; + int IgnoreArg_stream; + int IgnoreArg_dest; + +} CMOCK_pb_decode_fixed32_CALL_INSTANCE; + +typedef struct _CMOCK_pb_decode_fixed64_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + void* Expected_dest; + int Expected_stream_Depth; + int Expected_dest_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_dest_Used; + void* ReturnThruPtr_dest_Val; + int ReturnThruPtr_dest_Size; + int IgnoreArg_stream; + int IgnoreArg_dest; + +} CMOCK_pb_decode_fixed64_CALL_INSTANCE; + +typedef struct _CMOCK_pb_make_string_substream_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + bool ReturnVal; + int CallOrder; + pb_istream_t* Expected_stream; + pb_istream_t* Expected_substream; + int Expected_stream_Depth; + int Expected_substream_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_substream_Used; + pb_istream_t* ReturnThruPtr_substream_Val; + int ReturnThruPtr_substream_Size; + int IgnoreArg_stream; + int IgnoreArg_substream; + +} CMOCK_pb_make_string_substream_CALL_INSTANCE; + +typedef struct _CMOCK_pb_close_string_substream_CALL_INSTANCE +{ + UNITY_LINE_TYPE LineNumber; + int CallOrder; + pb_istream_t* Expected_stream; + pb_istream_t* Expected_substream; + int Expected_stream_Depth; + int Expected_substream_Depth; + int ReturnThruPtr_stream_Used; + pb_istream_t* ReturnThruPtr_stream_Val; + int ReturnThruPtr_stream_Size; + int ReturnThruPtr_substream_Used; + pb_istream_t* ReturnThruPtr_substream_Val; + int ReturnThruPtr_substream_Size; + int IgnoreArg_stream; + int IgnoreArg_substream; + +} CMOCK_pb_close_string_substream_CALL_INSTANCE; + +static struct mock_pb_decodeInstance +{ + int pb_decode_IgnoreBool; + bool pb_decode_FinalReturn; + CMOCK_pb_decode_CALLBACK pb_decode_CallbackFunctionPointer; + int pb_decode_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_CallInstance; + int pb_decode_noinit_IgnoreBool; + bool pb_decode_noinit_FinalReturn; + CMOCK_pb_decode_noinit_CALLBACK pb_decode_noinit_CallbackFunctionPointer; + int pb_decode_noinit_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_noinit_CallInstance; + int pb_decode_delimited_IgnoreBool; + bool pb_decode_delimited_FinalReturn; + CMOCK_pb_decode_delimited_CALLBACK pb_decode_delimited_CallbackFunctionPointer; + int pb_decode_delimited_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_delimited_CallInstance; + int pb_release_IgnoreBool; + CMOCK_pb_release_CALLBACK pb_release_CallbackFunctionPointer; + int pb_release_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_release_CallInstance; + int pb_istream_from_buffer_IgnoreBool; + pb_istream_t pb_istream_from_buffer_FinalReturn; + CMOCK_pb_istream_from_buffer_CALLBACK pb_istream_from_buffer_CallbackFunctionPointer; + int pb_istream_from_buffer_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_istream_from_buffer_CallInstance; + int pb_read_IgnoreBool; + bool pb_read_FinalReturn; + CMOCK_pb_read_CALLBACK pb_read_CallbackFunctionPointer; + int pb_read_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_read_CallInstance; + int pb_decode_tag_IgnoreBool; + bool pb_decode_tag_FinalReturn; + CMOCK_pb_decode_tag_CALLBACK pb_decode_tag_CallbackFunctionPointer; + int pb_decode_tag_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_tag_CallInstance; + int pb_skip_field_IgnoreBool; + bool pb_skip_field_FinalReturn; + CMOCK_pb_skip_field_CALLBACK pb_skip_field_CallbackFunctionPointer; + int pb_skip_field_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_skip_field_CallInstance; + int pb_decode_varint_IgnoreBool; + bool pb_decode_varint_FinalReturn; + CMOCK_pb_decode_varint_CALLBACK pb_decode_varint_CallbackFunctionPointer; + int pb_decode_varint_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_varint_CallInstance; + int pb_decode_svarint_IgnoreBool; + bool pb_decode_svarint_FinalReturn; + CMOCK_pb_decode_svarint_CALLBACK pb_decode_svarint_CallbackFunctionPointer; + int pb_decode_svarint_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_svarint_CallInstance; + int pb_decode_fixed32_IgnoreBool; + bool pb_decode_fixed32_FinalReturn; + CMOCK_pb_decode_fixed32_CALLBACK pb_decode_fixed32_CallbackFunctionPointer; + int pb_decode_fixed32_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_fixed32_CallInstance; + int pb_decode_fixed64_IgnoreBool; + bool pb_decode_fixed64_FinalReturn; + CMOCK_pb_decode_fixed64_CALLBACK pb_decode_fixed64_CallbackFunctionPointer; + int pb_decode_fixed64_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_decode_fixed64_CallInstance; + int pb_make_string_substream_IgnoreBool; + bool pb_make_string_substream_FinalReturn; + CMOCK_pb_make_string_substream_CALLBACK pb_make_string_substream_CallbackFunctionPointer; + int pb_make_string_substream_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_make_string_substream_CallInstance; + int pb_close_string_substream_IgnoreBool; + CMOCK_pb_close_string_substream_CALLBACK pb_close_string_substream_CallbackFunctionPointer; + int pb_close_string_substream_CallbackCalls; + CMOCK_MEM_INDEX_TYPE pb_close_string_substream_CallInstance; +} Mock; + +extern jmp_buf AbortFrame; +extern int GlobalExpectCount; +extern int GlobalVerifyOrder; + +void mock_pb_decode_Verify(void) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_CallInstance, cmock_line, "Function 'pb_decode' called less times than expected."); + if (Mock.pb_decode_CallbackFunctionPointer != NULL) + Mock.pb_decode_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_noinit_CallInstance, cmock_line, "Function 'pb_decode_noinit' called less times than expected."); + if (Mock.pb_decode_noinit_CallbackFunctionPointer != NULL) + Mock.pb_decode_noinit_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_delimited_CallInstance, cmock_line, "Function 'pb_decode_delimited' called less times than expected."); + if (Mock.pb_decode_delimited_CallbackFunctionPointer != NULL) + Mock.pb_decode_delimited_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_release_CallInstance, cmock_line, "Function 'pb_release' called less times than expected."); + if (Mock.pb_release_CallbackFunctionPointer != NULL) + Mock.pb_release_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_istream_from_buffer_CallInstance, cmock_line, "Function 'pb_istream_from_buffer' called less times than expected."); + if (Mock.pb_istream_from_buffer_CallbackFunctionPointer != NULL) + Mock.pb_istream_from_buffer_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_read_CallInstance, cmock_line, "Function 'pb_read' called less times than expected."); + if (Mock.pb_read_CallbackFunctionPointer != NULL) + Mock.pb_read_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_tag_CallInstance, cmock_line, "Function 'pb_decode_tag' called less times than expected."); + if (Mock.pb_decode_tag_CallbackFunctionPointer != NULL) + Mock.pb_decode_tag_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_skip_field_CallInstance, cmock_line, "Function 'pb_skip_field' called less times than expected."); + if (Mock.pb_skip_field_CallbackFunctionPointer != NULL) + Mock.pb_skip_field_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_varint_CallInstance, cmock_line, "Function 'pb_decode_varint' called less times than expected."); + if (Mock.pb_decode_varint_CallbackFunctionPointer != NULL) + Mock.pb_decode_varint_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_svarint_CallInstance, cmock_line, "Function 'pb_decode_svarint' called less times than expected."); + if (Mock.pb_decode_svarint_CallbackFunctionPointer != NULL) + Mock.pb_decode_svarint_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_fixed32_CallInstance, cmock_line, "Function 'pb_decode_fixed32' called less times than expected."); + if (Mock.pb_decode_fixed32_CallbackFunctionPointer != NULL) + Mock.pb_decode_fixed32_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_decode_fixed64_CallInstance, cmock_line, "Function 'pb_decode_fixed64' called less times than expected."); + if (Mock.pb_decode_fixed64_CallbackFunctionPointer != NULL) + Mock.pb_decode_fixed64_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_make_string_substream_CallInstance, cmock_line, "Function 'pb_make_string_substream' called less times than expected."); + if (Mock.pb_make_string_substream_CallbackFunctionPointer != NULL) + Mock.pb_make_string_substream_CallInstance = CMOCK_GUTS_NONE; + UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.pb_close_string_substream_CallInstance, cmock_line, "Function 'pb_close_string_substream' called less times than expected."); + if (Mock.pb_close_string_substream_CallbackFunctionPointer != NULL) + Mock.pb_close_string_substream_CallInstance = CMOCK_GUTS_NONE; +} + +void mock_pb_decode_Init(void) +{ + mock_pb_decode_Destroy(); +} + +void mock_pb_decode_Destroy(void) +{ + CMock_Guts_MemFreeAll(); + memset(&Mock, 0, sizeof(Mock)); + Mock.pb_decode_CallbackFunctionPointer = NULL; + Mock.pb_decode_CallbackCalls = 0; + Mock.pb_decode_noinit_CallbackFunctionPointer = NULL; + Mock.pb_decode_noinit_CallbackCalls = 0; + Mock.pb_decode_delimited_CallbackFunctionPointer = NULL; + Mock.pb_decode_delimited_CallbackCalls = 0; + Mock.pb_release_CallbackFunctionPointer = NULL; + Mock.pb_release_CallbackCalls = 0; + Mock.pb_istream_from_buffer_CallbackFunctionPointer = NULL; + Mock.pb_istream_from_buffer_CallbackCalls = 0; + Mock.pb_read_CallbackFunctionPointer = NULL; + Mock.pb_read_CallbackCalls = 0; + Mock.pb_decode_tag_CallbackFunctionPointer = NULL; + Mock.pb_decode_tag_CallbackCalls = 0; + Mock.pb_skip_field_CallbackFunctionPointer = NULL; + Mock.pb_skip_field_CallbackCalls = 0; + Mock.pb_decode_varint_CallbackFunctionPointer = NULL; + Mock.pb_decode_varint_CallbackCalls = 0; + Mock.pb_decode_svarint_CallbackFunctionPointer = NULL; + Mock.pb_decode_svarint_CallbackCalls = 0; + Mock.pb_decode_fixed32_CallbackFunctionPointer = NULL; + Mock.pb_decode_fixed32_CallbackCalls = 0; + Mock.pb_decode_fixed64_CallbackFunctionPointer = NULL; + Mock.pb_decode_fixed64_CallbackCalls = 0; + Mock.pb_make_string_substream_CallbackFunctionPointer = NULL; + Mock.pb_make_string_substream_CallbackCalls = 0; + Mock.pb_close_string_substream_CallbackFunctionPointer = NULL; + Mock.pb_close_string_substream_CallbackCalls = 0; + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; +} + +bool pb_decode(pb_istream_t* stream, const pb_field_t* fields, void* dest_struct) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_CallInstance); + Mock.pb_decode_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_CallInstance); + if (Mock.pb_decode_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_FinalReturn; + Mock.pb_decode_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_CallbackFunctionPointer(stream, fields, dest_struct, Mock.pb_decode_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_fields) + { + if (cmock_call_instance->Expected_fields == NULL) + { UNITY_TEST_ASSERT_NULL(fields, cmock_line, "Expected NULL. Function 'pb_decode' called with unexpected value for argument 'fields'."); } + else if (cmock_call_instance->Expected_fields_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_fields, fields, cmock_line, "Function 'pb_decode' called with unexpected value for argument 'fields'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_fields), (void*)(fields), sizeof(pb_field_t), cmock_call_instance->Expected_fields_Depth, cmock_line, "Function 'pb_decode' called with unexpected value for argument 'fields'."); } + } + if (!cmock_call_instance->IgnoreArg_dest_struct) + { + UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest_struct, dest_struct, cmock_line, "Function 'pb_decode' called with unexpected value for argument 'dest_struct'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_struct_Used) + { + memcpy((void*)dest_struct, (void*)cmock_call_instance->ReturnThruPtr_dest_struct_Val, + cmock_call_instance->ReturnThruPtr_dest_struct_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode(CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, const pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_fields = (pb_field_t*)fields; + cmock_call_instance->Expected_fields_Depth = fields_Depth; + cmock_call_instance->IgnoreArg_fields = 0; + cmock_call_instance->Expected_dest_struct = dest_struct; + cmock_call_instance->Expected_dest_struct_Depth = dest_struct_Depth; + cmock_call_instance->IgnoreArg_dest_struct = 0; + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 0; +} + +void pb_decode_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_CALL_INSTANCE)); + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_IgnoreBool = (int)1; +} + +void pb_decode_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_CALL_INSTANCE)); + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode(cmock_call_instance, stream, 0, fields, 0, dest_struct, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_StubWithCallback(CMOCK_pb_decode_CALLBACK Callback) +{ + Mock.pb_decode_CallbackFunctionPointer = Callback; +} + +void pb_decode_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_CALL_INSTANCE)); + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode(cmock_call_instance, stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size) +{ + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct ReturnThruPtr called before Expect on 'pb_decode'."); + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_struct_Val = dest_struct; + cmock_call_instance->ReturnThruPtr_dest_struct_Size = cmock_size; +} + +void pb_decode_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "fields IgnoreArg called before Expect on 'pb_decode'."); + cmock_call_instance->IgnoreArg_fields = 1; +} + +void pb_decode_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct IgnoreArg called before Expect on 'pb_decode'."); + cmock_call_instance->IgnoreArg_dest_struct = 1; +} + +bool pb_decode_noinit(pb_istream_t* stream, const pb_field_t* fields, void* dest_struct) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_noinit_CallInstance); + Mock.pb_decode_noinit_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_noinit_CallInstance); + if (Mock.pb_decode_noinit_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_noinit_FinalReturn; + Mock.pb_decode_noinit_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_noinit_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_noinit_CallbackFunctionPointer(stream, fields, dest_struct, Mock.pb_decode_noinit_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_noinit' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_noinit' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_noinit' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_noinit' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_noinit' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_noinit' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_fields) + { + if (cmock_call_instance->Expected_fields == NULL) + { UNITY_TEST_ASSERT_NULL(fields, cmock_line, "Expected NULL. Function 'pb_decode_noinit' called with unexpected value for argument 'fields'."); } + else if (cmock_call_instance->Expected_fields_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_fields, fields, cmock_line, "Function 'pb_decode_noinit' called with unexpected value for argument 'fields'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_fields), (void*)(fields), sizeof(pb_field_t), cmock_call_instance->Expected_fields_Depth, cmock_line, "Function 'pb_decode_noinit' called with unexpected value for argument 'fields'."); } + } + if (!cmock_call_instance->IgnoreArg_dest_struct) + { + UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest_struct, dest_struct, cmock_line, "Function 'pb_decode_noinit' called with unexpected value for argument 'dest_struct'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_struct_Used) + { + memcpy((void*)dest_struct, (void*)cmock_call_instance->ReturnThruPtr_dest_struct_Val, + cmock_call_instance->ReturnThruPtr_dest_struct_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_noinit(CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, const pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_fields = (pb_field_t*)fields; + cmock_call_instance->Expected_fields_Depth = fields_Depth; + cmock_call_instance->IgnoreArg_fields = 0; + cmock_call_instance->Expected_dest_struct = dest_struct; + cmock_call_instance->Expected_dest_struct_Depth = dest_struct_Depth; + cmock_call_instance->IgnoreArg_dest_struct = 0; + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 0; +} + +void pb_decode_noinit_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_noinit_CALL_INSTANCE)); + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_noinit_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_noinit_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_noinit_IgnoreBool = (int)1; +} + +void pb_decode_noinit_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_noinit_CALL_INSTANCE)); + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_noinit_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_noinit_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_noinit(cmock_call_instance, stream, 0, fields, 0, dest_struct, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_noinit_StubWithCallback(CMOCK_pb_decode_noinit_CALLBACK Callback) +{ + Mock.pb_decode_noinit_CallbackFunctionPointer = Callback; +} + +void pb_decode_noinit_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_noinit_CALL_INSTANCE)); + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_noinit_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_noinit_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_noinit(cmock_call_instance, stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_noinit_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_noinit_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_noinit'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_noinit_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size) +{ + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_noinit_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct ReturnThruPtr called before Expect on 'pb_decode_noinit'."); + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_struct_Val = dest_struct; + cmock_call_instance->ReturnThruPtr_dest_struct_Size = cmock_size; +} + +void pb_decode_noinit_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_noinit_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_noinit'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_noinit_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_noinit_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "fields IgnoreArg called before Expect on 'pb_decode_noinit'."); + cmock_call_instance->IgnoreArg_fields = 1; +} + +void pb_decode_noinit_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_noinit_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_noinit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_noinit_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct IgnoreArg called before Expect on 'pb_decode_noinit'."); + cmock_call_instance->IgnoreArg_dest_struct = 1; +} + +bool pb_decode_delimited(pb_istream_t* stream, const pb_field_t* fields, void* dest_struct) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_delimited_CallInstance); + Mock.pb_decode_delimited_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_delimited_CallInstance); + if (Mock.pb_decode_delimited_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_delimited_FinalReturn; + Mock.pb_decode_delimited_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_delimited_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_delimited_CallbackFunctionPointer(stream, fields, dest_struct, Mock.pb_decode_delimited_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_delimited' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_delimited' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_delimited' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_delimited' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_delimited' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_delimited' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_fields) + { + if (cmock_call_instance->Expected_fields == NULL) + { UNITY_TEST_ASSERT_NULL(fields, cmock_line, "Expected NULL. Function 'pb_decode_delimited' called with unexpected value for argument 'fields'."); } + else if (cmock_call_instance->Expected_fields_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_fields, fields, cmock_line, "Function 'pb_decode_delimited' called with unexpected value for argument 'fields'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_fields), (void*)(fields), sizeof(pb_field_t), cmock_call_instance->Expected_fields_Depth, cmock_line, "Function 'pb_decode_delimited' called with unexpected value for argument 'fields'."); } + } + if (!cmock_call_instance->IgnoreArg_dest_struct) + { + UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest_struct, dest_struct, cmock_line, "Function 'pb_decode_delimited' called with unexpected value for argument 'dest_struct'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_struct_Used) + { + memcpy((void*)dest_struct, (void*)cmock_call_instance->ReturnThruPtr_dest_struct_Val, + cmock_call_instance->ReturnThruPtr_dest_struct_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_delimited(CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, const pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_fields = (pb_field_t*)fields; + cmock_call_instance->Expected_fields_Depth = fields_Depth; + cmock_call_instance->IgnoreArg_fields = 0; + cmock_call_instance->Expected_dest_struct = dest_struct; + cmock_call_instance->Expected_dest_struct_Depth = dest_struct_Depth; + cmock_call_instance->IgnoreArg_dest_struct = 0; + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 0; +} + +void pb_decode_delimited_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_delimited_CALL_INSTANCE)); + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_delimited_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_delimited_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_delimited_IgnoreBool = (int)1; +} + +void pb_decode_delimited_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_delimited_CALL_INSTANCE)); + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_delimited_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_delimited_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_delimited(cmock_call_instance, stream, 0, fields, 0, dest_struct, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_delimited_StubWithCallback(CMOCK_pb_decode_delimited_CALLBACK Callback) +{ + Mock.pb_decode_delimited_CallbackFunctionPointer = Callback; +} + +void pb_decode_delimited_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_delimited_CALL_INSTANCE)); + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_delimited_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_delimited_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_delimited(cmock_call_instance, stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_delimited_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_delimited_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_delimited'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_delimited_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size) +{ + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_delimited_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct ReturnThruPtr called before Expect on 'pb_decode_delimited'."); + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_struct_Val = dest_struct; + cmock_call_instance->ReturnThruPtr_dest_struct_Size = cmock_size; +} + +void pb_decode_delimited_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_delimited_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_delimited'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_delimited_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_delimited_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "fields IgnoreArg called before Expect on 'pb_decode_delimited'."); + cmock_call_instance->IgnoreArg_fields = 1; +} + +void pb_decode_delimited_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_delimited_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_delimited_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_delimited_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct IgnoreArg called before Expect on 'pb_decode_delimited'."); + cmock_call_instance->IgnoreArg_dest_struct = 1; +} + +void pb_release(const pb_field_t* fields, void* dest_struct) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_release_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_release_CallInstance); + Mock.pb_release_CallInstance = CMock_Guts_MemNext(Mock.pb_release_CallInstance); + if (Mock.pb_release_IgnoreBool) + { + return; + } + if (Mock.pb_release_CallbackFunctionPointer != NULL) + { + Mock.pb_release_CallbackFunctionPointer(fields, dest_struct, Mock.pb_release_CallbackCalls++); + return; + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_release' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_release' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_release' called later than expected."); + if (!cmock_call_instance->IgnoreArg_fields) + { + if (cmock_call_instance->Expected_fields == NULL) + { UNITY_TEST_ASSERT_NULL(fields, cmock_line, "Expected NULL. Function 'pb_release' called with unexpected value for argument 'fields'."); } + else if (cmock_call_instance->Expected_fields_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_fields, fields, cmock_line, "Function 'pb_release' called with unexpected value for argument 'fields'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_fields), (void*)(fields), sizeof(pb_field_t), cmock_call_instance->Expected_fields_Depth, cmock_line, "Function 'pb_release' called with unexpected value for argument 'fields'."); } + } + if (!cmock_call_instance->IgnoreArg_dest_struct) + { + UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest_struct, dest_struct, cmock_line, "Function 'pb_release' called with unexpected value for argument 'dest_struct'."); + } + if (cmock_call_instance->ReturnThruPtr_dest_struct_Used) + { + memcpy((void*)dest_struct, (void*)cmock_call_instance->ReturnThruPtr_dest_struct_Val, + cmock_call_instance->ReturnThruPtr_dest_struct_Size); + } +} + +void CMockExpectParameters_pb_release(CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance, const pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth) +{ + cmock_call_instance->Expected_fields = (pb_field_t*)fields; + cmock_call_instance->Expected_fields_Depth = fields_Depth; + cmock_call_instance->IgnoreArg_fields = 0; + cmock_call_instance->Expected_dest_struct = dest_struct; + cmock_call_instance->Expected_dest_struct_Depth = dest_struct_Depth; + cmock_call_instance->IgnoreArg_dest_struct = 0; + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 0; +} + +void pb_release_CMockIgnore(void) +{ + Mock.pb_release_IgnoreBool = (int)1; +} + +void pb_release_CMockExpect(UNITY_LINE_TYPE cmock_line, const pb_field_t* fields, void* dest_struct) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_release_CALL_INSTANCE)); + CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_release_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_release_CallInstance = CMock_Guts_MemChain(Mock.pb_release_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_release(cmock_call_instance, fields, 0, dest_struct, 0); +} + +void pb_release_StubWithCallback(CMOCK_pb_release_CALLBACK Callback) +{ + Mock.pb_release_CallbackFunctionPointer = Callback; +} + +void pb_release_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_release_CALL_INSTANCE)); + CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_release_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_release_CallInstance = CMock_Guts_MemChain(Mock.pb_release_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_release(cmock_call_instance, fields, fields_Depth, dest_struct, dest_struct_Depth); +} + +void pb_release_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size) +{ + CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_release_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_release_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct ReturnThruPtr called before Expect on 'pb_release'."); + cmock_call_instance->ReturnThruPtr_dest_struct_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_struct_Val = dest_struct; + cmock_call_instance->ReturnThruPtr_dest_struct_Size = cmock_size; +} + +void pb_release_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_release_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_release_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "fields IgnoreArg called before Expect on 'pb_release'."); + cmock_call_instance->IgnoreArg_fields = 1; +} + +void pb_release_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_release_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_release_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_release_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest_struct IgnoreArg called before Expect on 'pb_release'."); + cmock_call_instance->IgnoreArg_dest_struct = 1; +} + +pb_istream_t pb_istream_from_buffer(const pb_byte_t* buf, size_t bufsize) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_istream_from_buffer_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_istream_from_buffer_CallInstance); + Mock.pb_istream_from_buffer_CallInstance = CMock_Guts_MemNext(Mock.pb_istream_from_buffer_CallInstance); + if (Mock.pb_istream_from_buffer_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_istream_from_buffer_FinalReturn; + memcpy(&Mock.pb_istream_from_buffer_FinalReturn, &cmock_call_instance->ReturnVal, sizeof(pb_istream_t)); + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_istream_from_buffer_CallbackFunctionPointer != NULL) + { + return Mock.pb_istream_from_buffer_CallbackFunctionPointer(buf, bufsize, Mock.pb_istream_from_buffer_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_istream_from_buffer' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_istream_from_buffer' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_istream_from_buffer' called later than expected."); + if (!cmock_call_instance->IgnoreArg_buf) + { + if (cmock_call_instance->Expected_buf == NULL) + { UNITY_TEST_ASSERT_NULL(buf, cmock_line, "Expected NULL. Function 'pb_istream_from_buffer' called with unexpected value for argument 'buf'."); } + else if (cmock_call_instance->Expected_buf_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_buf, buf, cmock_line, "Function 'pb_istream_from_buffer' called with unexpected value for argument 'buf'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_buf), (void*)(buf), sizeof(pb_byte_t), cmock_call_instance->Expected_buf_Depth, cmock_line, "Function 'pb_istream_from_buffer' called with unexpected value for argument 'buf'."); } + } + if (!cmock_call_instance->IgnoreArg_bufsize) + { + UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_bufsize), (void*)(&bufsize), sizeof(size_t), cmock_line, "Function 'pb_istream_from_buffer' called with unexpected value for argument 'bufsize'."); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_istream_from_buffer(CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance, const pb_byte_t* buf, int buf_Depth, size_t bufsize) +{ + cmock_call_instance->Expected_buf = (pb_byte_t*)buf; + cmock_call_instance->Expected_buf_Depth = buf_Depth; + cmock_call_instance->IgnoreArg_buf = 0; + memcpy(&cmock_call_instance->Expected_bufsize, &bufsize, sizeof(size_t)); + cmock_call_instance->IgnoreArg_bufsize = 0; +} + +void pb_istream_from_buffer_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_istream_from_buffer_CALL_INSTANCE)); + CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_istream_from_buffer_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_istream_from_buffer_CallInstance = CMock_Guts_MemChain(Mock.pb_istream_from_buffer_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_istream_from_buffer_IgnoreBool = (int)1; +} + +void pb_istream_from_buffer_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const pb_byte_t* buf, size_t bufsize, pb_istream_t cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_istream_from_buffer_CALL_INSTANCE)); + CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_istream_from_buffer_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_istream_from_buffer_CallInstance = CMock_Guts_MemChain(Mock.pb_istream_from_buffer_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_istream_from_buffer(cmock_call_instance, buf, 0, bufsize); + memcpy(&cmock_call_instance->ReturnVal, &cmock_to_return, sizeof(pb_istream_t)); +} + +void pb_istream_from_buffer_StubWithCallback(CMOCK_pb_istream_from_buffer_CALLBACK Callback) +{ + Mock.pb_istream_from_buffer_CallbackFunctionPointer = Callback; +} + +void pb_istream_from_buffer_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_byte_t* buf, int buf_Depth, size_t bufsize, pb_istream_t cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_istream_from_buffer_CALL_INSTANCE)); + CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_istream_from_buffer_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_istream_from_buffer_CallInstance = CMock_Guts_MemChain(Mock.pb_istream_from_buffer_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_istream_from_buffer(cmock_call_instance, buf, buf_Depth, bufsize); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_istream_from_buffer_CMockIgnoreArg_buf(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_istream_from_buffer_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_istream_from_buffer_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "buf IgnoreArg called before Expect on 'pb_istream_from_buffer'."); + cmock_call_instance->IgnoreArg_buf = 1; +} + +void pb_istream_from_buffer_CMockIgnoreArg_bufsize(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_istream_from_buffer_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_istream_from_buffer_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_istream_from_buffer_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "bufsize IgnoreArg called before Expect on 'pb_istream_from_buffer'."); + cmock_call_instance->IgnoreArg_bufsize = 1; +} + +bool pb_read(pb_istream_t* stream, pb_byte_t* buf, size_t count) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_read_CallInstance); + Mock.pb_read_CallInstance = CMock_Guts_MemNext(Mock.pb_read_CallInstance); + if (Mock.pb_read_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_read_FinalReturn; + Mock.pb_read_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_read_CallbackFunctionPointer != NULL) + { + return Mock.pb_read_CallbackFunctionPointer(stream, buf, count, Mock.pb_read_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_read' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_read' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_read' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_read' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_read' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_read' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_buf) + { + if (cmock_call_instance->Expected_buf == NULL) + { UNITY_TEST_ASSERT_NULL(buf, cmock_line, "Expected NULL. Function 'pb_read' called with unexpected value for argument 'buf'."); } + else if (cmock_call_instance->Expected_buf_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_buf, buf, cmock_line, "Function 'pb_read' called with unexpected value for argument 'buf'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_buf), (void*)(buf), sizeof(pb_byte_t), cmock_call_instance->Expected_buf_Depth, cmock_line, "Function 'pb_read' called with unexpected value for argument 'buf'."); } + } + if (!cmock_call_instance->IgnoreArg_count) + { + UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_count), (void*)(&count), sizeof(size_t), cmock_line, "Function 'pb_read' called with unexpected value for argument 'count'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_buf_Used) + { + memcpy((void*)buf, (void*)cmock_call_instance->ReturnThruPtr_buf_Val, + cmock_call_instance->ReturnThruPtr_buf_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_read(CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, pb_byte_t* buf, int buf_Depth, size_t count) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_buf = buf; + cmock_call_instance->Expected_buf_Depth = buf_Depth; + cmock_call_instance->IgnoreArg_buf = 0; + cmock_call_instance->ReturnThruPtr_buf_Used = 0; + memcpy(&cmock_call_instance->Expected_count, &count, sizeof(size_t)); + cmock_call_instance->IgnoreArg_count = 0; +} + +void pb_read_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_read_CALL_INSTANCE)); + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_read_CallInstance = CMock_Guts_MemChain(Mock.pb_read_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_read_IgnoreBool = (int)1; +} + +void pb_read_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_byte_t* buf, size_t count, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_read_CALL_INSTANCE)); + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_read_CallInstance = CMock_Guts_MemChain(Mock.pb_read_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_read(cmock_call_instance, stream, 0, buf, 0, count); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_read_StubWithCallback(CMOCK_pb_read_CALLBACK Callback) +{ + Mock.pb_read_CallbackFunctionPointer = Callback; +} + +void pb_read_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_byte_t* buf, int buf_Depth, size_t count, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_read_CALL_INSTANCE)); + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_read_CallInstance = CMock_Guts_MemChain(Mock.pb_read_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_read(cmock_call_instance, stream, stream_Depth, buf, buf_Depth, count); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_read_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_read_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_read'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_read_CMockReturnMemThruPtr_buf(UNITY_LINE_TYPE cmock_line, pb_byte_t* buf, int cmock_size) +{ + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_read_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "buf ReturnThruPtr called before Expect on 'pb_read'."); + cmock_call_instance->ReturnThruPtr_buf_Used = 1; + cmock_call_instance->ReturnThruPtr_buf_Val = buf; + cmock_call_instance->ReturnThruPtr_buf_Size = cmock_size; +} + +void pb_read_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_read_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_read'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_read_CMockIgnoreArg_buf(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_read_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "buf IgnoreArg called before Expect on 'pb_read'."); + cmock_call_instance->IgnoreArg_buf = 1; +} + +void pb_read_CMockIgnoreArg_count(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_read_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_read_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "count IgnoreArg called before Expect on 'pb_read'."); + cmock_call_instance->IgnoreArg_count = 1; +} + +bool pb_decode_tag(pb_istream_t* stream, pb_wire_type_t* wire_type, uint32_t* tag, bool* eof) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_tag_CallInstance); + Mock.pb_decode_tag_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_tag_CallInstance); + if (Mock.pb_decode_tag_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_tag_FinalReturn; + Mock.pb_decode_tag_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_tag_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_tag_CallbackFunctionPointer(stream, wire_type, tag, eof, Mock.pb_decode_tag_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_tag' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_tag' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_tag' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_tag' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_wire_type) + { + if (cmock_call_instance->Expected_wire_type == NULL) + { UNITY_TEST_ASSERT_NULL(wire_type, cmock_line, "Expected NULL. Function 'pb_decode_tag' called with unexpected value for argument 'wire_type'."); } + else if (cmock_call_instance->Expected_wire_type_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_wire_type, wire_type, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'wire_type'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_wire_type), (void*)(wire_type), sizeof(pb_wire_type_t), cmock_call_instance->Expected_wire_type_Depth, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'wire_type'."); } + } + if (!cmock_call_instance->IgnoreArg_tag) + { + if (cmock_call_instance->Expected_tag == NULL) + { UNITY_TEST_ASSERT_NULL(tag, cmock_line, "Expected NULL. Function 'pb_decode_tag' called with unexpected value for argument 'tag'."); } + else if (cmock_call_instance->Expected_tag_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_tag, tag, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'tag'."); } + else + { UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(cmock_call_instance->Expected_tag, tag, cmock_call_instance->Expected_tag_Depth, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'tag'."); } + } + if (!cmock_call_instance->IgnoreArg_eof) + { + if (cmock_call_instance->Expected_eof == NULL) + { UNITY_TEST_ASSERT_NULL(eof, cmock_line, "Expected NULL. Function 'pb_decode_tag' called with unexpected value for argument 'eof'."); } + else if (cmock_call_instance->Expected_eof_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_eof, eof, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'eof'."); } + else + { UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(cmock_call_instance->Expected_eof, eof, cmock_call_instance->Expected_eof_Depth, cmock_line, "Function 'pb_decode_tag' called with unexpected value for argument 'eof'."); } + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_wire_type_Used) + { + memcpy((void*)wire_type, (void*)cmock_call_instance->ReturnThruPtr_wire_type_Val, + cmock_call_instance->ReturnThruPtr_wire_type_Size); + } + if (cmock_call_instance->ReturnThruPtr_tag_Used) + { + memcpy((void*)tag, (void*)cmock_call_instance->ReturnThruPtr_tag_Val, + cmock_call_instance->ReturnThruPtr_tag_Size); + } + if (cmock_call_instance->ReturnThruPtr_eof_Used) + { + memcpy((void*)eof, (void*)cmock_call_instance->ReturnThruPtr_eof_Val, + cmock_call_instance->ReturnThruPtr_eof_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_tag(CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, pb_wire_type_t* wire_type, int wire_type_Depth, uint32_t* tag, int tag_Depth, bool* eof, int eof_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_wire_type = wire_type; + cmock_call_instance->Expected_wire_type_Depth = wire_type_Depth; + cmock_call_instance->IgnoreArg_wire_type = 0; + cmock_call_instance->ReturnThruPtr_wire_type_Used = 0; + cmock_call_instance->Expected_tag = tag; + cmock_call_instance->Expected_tag_Depth = tag_Depth; + cmock_call_instance->IgnoreArg_tag = 0; + cmock_call_instance->ReturnThruPtr_tag_Used = 0; + cmock_call_instance->Expected_eof = eof; + cmock_call_instance->Expected_eof_Depth = eof_Depth; + cmock_call_instance->IgnoreArg_eof = 0; + cmock_call_instance->ReturnThruPtr_eof_Used = 0; +} + +void pb_decode_tag_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_tag_CALL_INSTANCE)); + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_tag_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_tag_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_tag_IgnoreBool = (int)1; +} + +void pb_decode_tag_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_wire_type_t* wire_type, uint32_t* tag, bool* eof, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_tag_CALL_INSTANCE)); + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_tag_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_tag_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_tag(cmock_call_instance, stream, 0, wire_type, 0, tag, 0, eof, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_tag_StubWithCallback(CMOCK_pb_decode_tag_CALLBACK Callback) +{ + Mock.pb_decode_tag_CallbackFunctionPointer = Callback; +} + +void pb_decode_tag_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_wire_type_t* wire_type, int wire_type_Depth, uint32_t* tag, int tag_Depth, bool* eof, int eof_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_tag_CALL_INSTANCE)); + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_tag_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_tag_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_tag(cmock_call_instance, stream, stream_Depth, wire_type, wire_type_Depth, tag, tag_Depth, eof, eof_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_tag_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_tag'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_tag_CMockReturnMemThruPtr_wire_type(UNITY_LINE_TYPE cmock_line, pb_wire_type_t* wire_type, int cmock_size) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "wire_type ReturnThruPtr called before Expect on 'pb_decode_tag'."); + cmock_call_instance->ReturnThruPtr_wire_type_Used = 1; + cmock_call_instance->ReturnThruPtr_wire_type_Val = wire_type; + cmock_call_instance->ReturnThruPtr_wire_type_Size = cmock_size; +} + +void pb_decode_tag_CMockReturnMemThruPtr_tag(UNITY_LINE_TYPE cmock_line, uint32_t* tag, int cmock_size) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "tag ReturnThruPtr called before Expect on 'pb_decode_tag'."); + cmock_call_instance->ReturnThruPtr_tag_Used = 1; + cmock_call_instance->ReturnThruPtr_tag_Val = tag; + cmock_call_instance->ReturnThruPtr_tag_Size = cmock_size; +} + +void pb_decode_tag_CMockReturnMemThruPtr_eof(UNITY_LINE_TYPE cmock_line, bool* eof, int cmock_size) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "eof ReturnThruPtr called before Expect on 'pb_decode_tag'."); + cmock_call_instance->ReturnThruPtr_eof_Used = 1; + cmock_call_instance->ReturnThruPtr_eof_Val = eof; + cmock_call_instance->ReturnThruPtr_eof_Size = cmock_size; +} + +void pb_decode_tag_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_tag'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_tag_CMockIgnoreArg_wire_type(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "wire_type IgnoreArg called before Expect on 'pb_decode_tag'."); + cmock_call_instance->IgnoreArg_wire_type = 1; +} + +void pb_decode_tag_CMockIgnoreArg_tag(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "tag IgnoreArg called before Expect on 'pb_decode_tag'."); + cmock_call_instance->IgnoreArg_tag = 1; +} + +void pb_decode_tag_CMockIgnoreArg_eof(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_tag_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_tag_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_tag_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "eof IgnoreArg called before Expect on 'pb_decode_tag'."); + cmock_call_instance->IgnoreArg_eof = 1; +} + +bool pb_skip_field(pb_istream_t* stream, pb_wire_type_t wire_type) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_skip_field_CallInstance); + Mock.pb_skip_field_CallInstance = CMock_Guts_MemNext(Mock.pb_skip_field_CallInstance); + if (Mock.pb_skip_field_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_skip_field_FinalReturn; + Mock.pb_skip_field_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_skip_field_CallbackFunctionPointer != NULL) + { + return Mock.pb_skip_field_CallbackFunctionPointer(stream, wire_type, Mock.pb_skip_field_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_skip_field' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_skip_field' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_skip_field' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_skip_field' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_skip_field' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_skip_field' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_wire_type) + { + UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_wire_type), (void*)(&wire_type), sizeof(pb_wire_type_t), cmock_line, "Function 'pb_skip_field' called with unexpected value for argument 'wire_type'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_skip_field(CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, pb_wire_type_t wire_type) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + memcpy(&cmock_call_instance->Expected_wire_type, &wire_type, sizeof(pb_wire_type_t)); + cmock_call_instance->IgnoreArg_wire_type = 0; +} + +void pb_skip_field_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_skip_field_CALL_INSTANCE)); + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_skip_field_CallInstance = CMock_Guts_MemChain(Mock.pb_skip_field_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_skip_field_IgnoreBool = (int)1; +} + +void pb_skip_field_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_wire_type_t wire_type, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_skip_field_CALL_INSTANCE)); + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_skip_field_CallInstance = CMock_Guts_MemChain(Mock.pb_skip_field_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_skip_field(cmock_call_instance, stream, 0, wire_type); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_skip_field_StubWithCallback(CMOCK_pb_skip_field_CALLBACK Callback) +{ + Mock.pb_skip_field_CallbackFunctionPointer = Callback; +} + +void pb_skip_field_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_wire_type_t wire_type, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_skip_field_CALL_INSTANCE)); + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_skip_field_CallInstance = CMock_Guts_MemChain(Mock.pb_skip_field_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_skip_field(cmock_call_instance, stream, stream_Depth, wire_type); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_skip_field_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_skip_field_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_skip_field'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_skip_field_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_skip_field_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_skip_field'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_skip_field_CMockIgnoreArg_wire_type(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_skip_field_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_skip_field_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_skip_field_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "wire_type IgnoreArg called before Expect on 'pb_skip_field'."); + cmock_call_instance->IgnoreArg_wire_type = 1; +} + +bool pb_decode_varint(pb_istream_t* stream, uint64_t* dest) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_varint_CallInstance); + Mock.pb_decode_varint_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_varint_CallInstance); + if (Mock.pb_decode_varint_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_varint_FinalReturn; + Mock.pb_decode_varint_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_varint_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_varint_CallbackFunctionPointer(stream, dest, Mock.pb_decode_varint_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_varint' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_varint' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_varint' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_varint' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_varint' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_varint' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_dest) + { + if (cmock_call_instance->Expected_dest == NULL) + { UNITY_TEST_ASSERT_NULL(dest, cmock_line, "Expected NULL. Function 'pb_decode_varint' called with unexpected value for argument 'dest'."); } + else if (cmock_call_instance->Expected_dest_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest, dest, cmock_line, "Function 'pb_decode_varint' called with unexpected value for argument 'dest'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_dest), (void*)(dest), sizeof(uint64_t), cmock_call_instance->Expected_dest_Depth, cmock_line, "Function 'pb_decode_varint' called with unexpected value for argument 'dest'."); } + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_Used) + { + memcpy((void*)dest, (void*)cmock_call_instance->ReturnThruPtr_dest_Val, + cmock_call_instance->ReturnThruPtr_dest_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_varint(CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, uint64_t* dest, int dest_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_dest = dest; + cmock_call_instance->Expected_dest_Depth = dest_Depth; + cmock_call_instance->IgnoreArg_dest = 0; + cmock_call_instance->ReturnThruPtr_dest_Used = 0; +} + +void pb_decode_varint_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_varint_CALL_INSTANCE)); + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_varint_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_varint_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_varint_IgnoreBool = (int)1; +} + +void pb_decode_varint_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, uint64_t* dest, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_varint_CALL_INSTANCE)); + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_varint_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_varint_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_varint(cmock_call_instance, stream, 0, dest, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_varint_StubWithCallback(CMOCK_pb_decode_varint_CALLBACK Callback) +{ + Mock.pb_decode_varint_CallbackFunctionPointer = Callback; +} + +void pb_decode_varint_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, uint64_t* dest, int dest_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_varint_CALL_INSTANCE)); + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_varint_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_varint_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_varint(cmock_call_instance, stream, stream_Depth, dest, dest_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_varint_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_varint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_varint'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_varint_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, uint64_t* dest, int cmock_size) +{ + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_varint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest ReturnThruPtr called before Expect on 'pb_decode_varint'."); + cmock_call_instance->ReturnThruPtr_dest_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_Val = dest; + cmock_call_instance->ReturnThruPtr_dest_Size = cmock_size; +} + +void pb_decode_varint_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_varint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_varint'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_varint_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_varint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_varint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_varint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest IgnoreArg called before Expect on 'pb_decode_varint'."); + cmock_call_instance->IgnoreArg_dest = 1; +} + +bool pb_decode_svarint(pb_istream_t* stream, int64_t* dest) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_svarint_CallInstance); + Mock.pb_decode_svarint_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_svarint_CallInstance); + if (Mock.pb_decode_svarint_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_svarint_FinalReturn; + Mock.pb_decode_svarint_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_svarint_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_svarint_CallbackFunctionPointer(stream, dest, Mock.pb_decode_svarint_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_svarint' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_svarint' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_svarint' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_svarint' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_svarint' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_svarint' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_dest) + { + if (cmock_call_instance->Expected_dest == NULL) + { UNITY_TEST_ASSERT_NULL(dest, cmock_line, "Expected NULL. Function 'pb_decode_svarint' called with unexpected value for argument 'dest'."); } + else if (cmock_call_instance->Expected_dest_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest, dest, cmock_line, "Function 'pb_decode_svarint' called with unexpected value for argument 'dest'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_dest), (void*)(dest), sizeof(int64_t), cmock_call_instance->Expected_dest_Depth, cmock_line, "Function 'pb_decode_svarint' called with unexpected value for argument 'dest'."); } + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_Used) + { + memcpy((void*)dest, (void*)cmock_call_instance->ReturnThruPtr_dest_Val, + cmock_call_instance->ReturnThruPtr_dest_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_svarint(CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, int64_t* dest, int dest_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_dest = dest; + cmock_call_instance->Expected_dest_Depth = dest_Depth; + cmock_call_instance->IgnoreArg_dest = 0; + cmock_call_instance->ReturnThruPtr_dest_Used = 0; +} + +void pb_decode_svarint_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_svarint_CALL_INSTANCE)); + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_svarint_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_svarint_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_svarint_IgnoreBool = (int)1; +} + +void pb_decode_svarint_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int64_t* dest, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_svarint_CALL_INSTANCE)); + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_svarint_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_svarint_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_svarint(cmock_call_instance, stream, 0, dest, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_svarint_StubWithCallback(CMOCK_pb_decode_svarint_CALLBACK Callback) +{ + Mock.pb_decode_svarint_CallbackFunctionPointer = Callback; +} + +void pb_decode_svarint_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, int64_t* dest, int dest_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_svarint_CALL_INSTANCE)); + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_svarint_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_svarint_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_svarint(cmock_call_instance, stream, stream_Depth, dest, dest_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_svarint_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_svarint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_svarint'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_svarint_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, int64_t* dest, int cmock_size) +{ + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_svarint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest ReturnThruPtr called before Expect on 'pb_decode_svarint'."); + cmock_call_instance->ReturnThruPtr_dest_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_Val = dest; + cmock_call_instance->ReturnThruPtr_dest_Size = cmock_size; +} + +void pb_decode_svarint_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_svarint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_svarint'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_svarint_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_svarint_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_svarint_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_svarint_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest IgnoreArg called before Expect on 'pb_decode_svarint'."); + cmock_call_instance->IgnoreArg_dest = 1; +} + +bool pb_decode_fixed32(pb_istream_t* stream, void* dest) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_fixed32_CallInstance); + Mock.pb_decode_fixed32_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_fixed32_CallInstance); + if (Mock.pb_decode_fixed32_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_fixed32_FinalReturn; + Mock.pb_decode_fixed32_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_fixed32_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_fixed32_CallbackFunctionPointer(stream, dest, Mock.pb_decode_fixed32_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_fixed32' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_fixed32' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_fixed32' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_fixed32' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_fixed32' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_fixed32' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_dest) + { + UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest, dest, cmock_line, "Function 'pb_decode_fixed32' called with unexpected value for argument 'dest'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_Used) + { + memcpy((void*)dest, (void*)cmock_call_instance->ReturnThruPtr_dest_Val, + cmock_call_instance->ReturnThruPtr_dest_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_fixed32(CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, void* dest, int dest_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_dest = dest; + cmock_call_instance->Expected_dest_Depth = dest_Depth; + cmock_call_instance->IgnoreArg_dest = 0; + cmock_call_instance->ReturnThruPtr_dest_Used = 0; +} + +void pb_decode_fixed32_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_fixed32_CALL_INSTANCE)); + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_fixed32_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_fixed32_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_fixed32_IgnoreBool = (int)1; +} + +void pb_decode_fixed32_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, void* dest, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_fixed32_CALL_INSTANCE)); + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_fixed32_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_fixed32_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_fixed32(cmock_call_instance, stream, 0, dest, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_fixed32_StubWithCallback(CMOCK_pb_decode_fixed32_CALLBACK Callback) +{ + Mock.pb_decode_fixed32_CallbackFunctionPointer = Callback; +} + +void pb_decode_fixed32_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, void* dest, int dest_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_fixed32_CALL_INSTANCE)); + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_fixed32_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_fixed32_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_fixed32(cmock_call_instance, stream, stream_Depth, dest, dest_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_fixed32_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed32_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_fixed32'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_fixed32_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, void* dest, int cmock_size) +{ + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed32_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest ReturnThruPtr called before Expect on 'pb_decode_fixed32'."); + cmock_call_instance->ReturnThruPtr_dest_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_Val = dest; + cmock_call_instance->ReturnThruPtr_dest_Size = cmock_size; +} + +void pb_decode_fixed32_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed32_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_fixed32'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_fixed32_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_fixed32_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed32_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed32_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest IgnoreArg called before Expect on 'pb_decode_fixed32'."); + cmock_call_instance->IgnoreArg_dest = 1; +} + +bool pb_decode_fixed64(pb_istream_t* stream, void* dest) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_decode_fixed64_CallInstance); + Mock.pb_decode_fixed64_CallInstance = CMock_Guts_MemNext(Mock.pb_decode_fixed64_CallInstance); + if (Mock.pb_decode_fixed64_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_decode_fixed64_FinalReturn; + Mock.pb_decode_fixed64_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_decode_fixed64_CallbackFunctionPointer != NULL) + { + return Mock.pb_decode_fixed64_CallbackFunctionPointer(stream, dest, Mock.pb_decode_fixed64_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_decode_fixed64' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_fixed64' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_decode_fixed64' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_decode_fixed64' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_decode_fixed64' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_decode_fixed64' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_dest) + { + UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_dest, dest, cmock_line, "Function 'pb_decode_fixed64' called with unexpected value for argument 'dest'."); + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_dest_Used) + { + memcpy((void*)dest, (void*)cmock_call_instance->ReturnThruPtr_dest_Val, + cmock_call_instance->ReturnThruPtr_dest_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_decode_fixed64(CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, void* dest, int dest_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_dest = dest; + cmock_call_instance->Expected_dest_Depth = dest_Depth; + cmock_call_instance->IgnoreArg_dest = 0; + cmock_call_instance->ReturnThruPtr_dest_Used = 0; +} + +void pb_decode_fixed64_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_fixed64_CALL_INSTANCE)); + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_fixed64_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_fixed64_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_decode_fixed64_IgnoreBool = (int)1; +} + +void pb_decode_fixed64_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, void* dest, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_fixed64_CALL_INSTANCE)); + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_fixed64_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_fixed64_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_fixed64(cmock_call_instance, stream, 0, dest, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_fixed64_StubWithCallback(CMOCK_pb_decode_fixed64_CALLBACK Callback) +{ + Mock.pb_decode_fixed64_CallbackFunctionPointer = Callback; +} + +void pb_decode_fixed64_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, void* dest, int dest_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_decode_fixed64_CALL_INSTANCE)); + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_decode_fixed64_CallInstance = CMock_Guts_MemChain(Mock.pb_decode_fixed64_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_decode_fixed64(cmock_call_instance, stream, stream_Depth, dest, dest_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_decode_fixed64_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed64_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_decode_fixed64'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_decode_fixed64_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, void* dest, int cmock_size) +{ + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed64_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest ReturnThruPtr called before Expect on 'pb_decode_fixed64'."); + cmock_call_instance->ReturnThruPtr_dest_Used = 1; + cmock_call_instance->ReturnThruPtr_dest_Val = dest; + cmock_call_instance->ReturnThruPtr_dest_Size = cmock_size; +} + +void pb_decode_fixed64_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed64_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_decode_fixed64'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_decode_fixed64_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_decode_fixed64_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_decode_fixed64_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_decode_fixed64_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "dest IgnoreArg called before Expect on 'pb_decode_fixed64'."); + cmock_call_instance->IgnoreArg_dest = 1; +} + +bool pb_make_string_substream(pb_istream_t* stream, pb_istream_t* substream) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_make_string_substream_CallInstance); + Mock.pb_make_string_substream_CallInstance = CMock_Guts_MemNext(Mock.pb_make_string_substream_CallInstance); + if (Mock.pb_make_string_substream_IgnoreBool) + { + if (cmock_call_instance == NULL) + return Mock.pb_make_string_substream_FinalReturn; + Mock.pb_make_string_substream_FinalReturn = cmock_call_instance->ReturnVal; + return cmock_call_instance->ReturnVal; + } + if (Mock.pb_make_string_substream_CallbackFunctionPointer != NULL) + { + return Mock.pb_make_string_substream_CallbackFunctionPointer(stream, substream, Mock.pb_make_string_substream_CallbackCalls++); + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_make_string_substream' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_make_string_substream' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_make_string_substream' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_make_string_substream' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_make_string_substream' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_make_string_substream' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_substream) + { + if (cmock_call_instance->Expected_substream == NULL) + { UNITY_TEST_ASSERT_NULL(substream, cmock_line, "Expected NULL. Function 'pb_make_string_substream' called with unexpected value for argument 'substream'."); } + else if (cmock_call_instance->Expected_substream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_substream, substream, cmock_line, "Function 'pb_make_string_substream' called with unexpected value for argument 'substream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_substream), (void*)(substream), sizeof(pb_istream_t), cmock_call_instance->Expected_substream_Depth, cmock_line, "Function 'pb_make_string_substream' called with unexpected value for argument 'substream'."); } + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_substream_Used) + { + memcpy((void*)substream, (void*)cmock_call_instance->ReturnThruPtr_substream_Val, + cmock_call_instance->ReturnThruPtr_substream_Size); + } + return cmock_call_instance->ReturnVal; +} + +void CMockExpectParameters_pb_make_string_substream(CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, pb_istream_t* substream, int substream_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_substream = substream; + cmock_call_instance->Expected_substream_Depth = substream_Depth; + cmock_call_instance->IgnoreArg_substream = 0; + cmock_call_instance->ReturnThruPtr_substream_Used = 0; +} + +void pb_make_string_substream_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_make_string_substream_CALL_INSTANCE)); + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_make_string_substream_CallInstance = CMock_Guts_MemChain(Mock.pb_make_string_substream_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->ReturnVal = cmock_to_return; + Mock.pb_make_string_substream_IgnoreBool = (int)1; +} + +void pb_make_string_substream_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_istream_t* substream, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_make_string_substream_CALL_INSTANCE)); + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_make_string_substream_CallInstance = CMock_Guts_MemChain(Mock.pb_make_string_substream_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_make_string_substream(cmock_call_instance, stream, 0, substream, 0); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_make_string_substream_StubWithCallback(CMOCK_pb_make_string_substream_CALLBACK Callback) +{ + Mock.pb_make_string_substream_CallbackFunctionPointer = Callback; +} + +void pb_make_string_substream_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_istream_t* substream, int substream_Depth, bool cmock_to_return) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_make_string_substream_CALL_INSTANCE)); + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_make_string_substream_CallInstance = CMock_Guts_MemChain(Mock.pb_make_string_substream_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_make_string_substream(cmock_call_instance, stream, stream_Depth, substream, substream_Depth); + cmock_call_instance->ReturnVal = cmock_to_return; +} + +void pb_make_string_substream_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_make_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_make_string_substream'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_make_string_substream_CMockReturnMemThruPtr_substream(UNITY_LINE_TYPE cmock_line, pb_istream_t* substream, int cmock_size) +{ + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_make_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "substream ReturnThruPtr called before Expect on 'pb_make_string_substream'."); + cmock_call_instance->ReturnThruPtr_substream_Used = 1; + cmock_call_instance->ReturnThruPtr_substream_Val = substream; + cmock_call_instance->ReturnThruPtr_substream_Size = cmock_size; +} + +void pb_make_string_substream_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_make_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_make_string_substream'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_make_string_substream_CMockIgnoreArg_substream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_make_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_make_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_make_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "substream IgnoreArg called before Expect on 'pb_make_string_substream'."); + cmock_call_instance->IgnoreArg_substream = 1; +} + +void pb_close_string_substream(pb_istream_t* stream, pb_istream_t* substream) +{ + UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.pb_close_string_substream_CallInstance); + Mock.pb_close_string_substream_CallInstance = CMock_Guts_MemNext(Mock.pb_close_string_substream_CallInstance); + if (Mock.pb_close_string_substream_IgnoreBool) + { + return; + } + if (Mock.pb_close_string_substream_CallbackFunctionPointer != NULL) + { + Mock.pb_close_string_substream_CallbackFunctionPointer(stream, substream, Mock.pb_close_string_substream_CallbackCalls++); + return; + } + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'pb_close_string_substream' called more times than expected."); + cmock_line = cmock_call_instance->LineNumber; + if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_close_string_substream' called earlier than expected."); + if (cmock_call_instance->CallOrder < GlobalVerifyOrder) + UNITY_TEST_FAIL(cmock_line, "Function 'pb_close_string_substream' called later than expected."); + if (!cmock_call_instance->IgnoreArg_stream) + { + if (cmock_call_instance->Expected_stream == NULL) + { UNITY_TEST_ASSERT_NULL(stream, cmock_line, "Expected NULL. Function 'pb_close_string_substream' called with unexpected value for argument 'stream'."); } + else if (cmock_call_instance->Expected_stream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_stream, stream, cmock_line, "Function 'pb_close_string_substream' called with unexpected value for argument 'stream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_stream), (void*)(stream), sizeof(pb_istream_t), cmock_call_instance->Expected_stream_Depth, cmock_line, "Function 'pb_close_string_substream' called with unexpected value for argument 'stream'."); } + } + if (!cmock_call_instance->IgnoreArg_substream) + { + if (cmock_call_instance->Expected_substream == NULL) + { UNITY_TEST_ASSERT_NULL(substream, cmock_line, "Expected NULL. Function 'pb_close_string_substream' called with unexpected value for argument 'substream'."); } + else if (cmock_call_instance->Expected_substream_Depth == 0) + { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_substream, substream, cmock_line, "Function 'pb_close_string_substream' called with unexpected value for argument 'substream'."); } + else + { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_substream), (void*)(substream), sizeof(pb_istream_t), cmock_call_instance->Expected_substream_Depth, cmock_line, "Function 'pb_close_string_substream' called with unexpected value for argument 'substream'."); } + } + if (cmock_call_instance->ReturnThruPtr_stream_Used) + { + memcpy((void*)stream, (void*)cmock_call_instance->ReturnThruPtr_stream_Val, + cmock_call_instance->ReturnThruPtr_stream_Size); + } + if (cmock_call_instance->ReturnThruPtr_substream_Used) + { + memcpy((void*)substream, (void*)cmock_call_instance->ReturnThruPtr_substream_Val, + cmock_call_instance->ReturnThruPtr_substream_Size); + } +} + +void CMockExpectParameters_pb_close_string_substream(CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance, pb_istream_t* stream, int stream_Depth, pb_istream_t* substream, int substream_Depth) +{ + cmock_call_instance->Expected_stream = stream; + cmock_call_instance->Expected_stream_Depth = stream_Depth; + cmock_call_instance->IgnoreArg_stream = 0; + cmock_call_instance->ReturnThruPtr_stream_Used = 0; + cmock_call_instance->Expected_substream = substream; + cmock_call_instance->Expected_substream_Depth = substream_Depth; + cmock_call_instance->IgnoreArg_substream = 0; + cmock_call_instance->ReturnThruPtr_substream_Used = 0; +} + +void pb_close_string_substream_CMockIgnore(void) +{ + Mock.pb_close_string_substream_IgnoreBool = (int)1; +} + +void pb_close_string_substream_CMockExpect(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_istream_t* substream) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_close_string_substream_CALL_INSTANCE)); + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_close_string_substream_CallInstance = CMock_Guts_MemChain(Mock.pb_close_string_substream_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_close_string_substream(cmock_call_instance, stream, 0, substream, 0); +} + +void pb_close_string_substream_StubWithCallback(CMOCK_pb_close_string_substream_CALLBACK Callback) +{ + Mock.pb_close_string_substream_CallbackFunctionPointer = Callback; +} + +void pb_close_string_substream_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_istream_t* substream, int substream_Depth) +{ + CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_pb_close_string_substream_CALL_INSTANCE)); + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more."); + Mock.pb_close_string_substream_CallInstance = CMock_Guts_MemChain(Mock.pb_close_string_substream_CallInstance, cmock_guts_index); + cmock_call_instance->LineNumber = cmock_line; + cmock_call_instance->CallOrder = ++GlobalExpectCount; + CMockExpectParameters_pb_close_string_substream(cmock_call_instance, stream, stream_Depth, substream, substream_Depth); +} + +void pb_close_string_substream_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size) +{ + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_close_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream ReturnThruPtr called before Expect on 'pb_close_string_substream'."); + cmock_call_instance->ReturnThruPtr_stream_Used = 1; + cmock_call_instance->ReturnThruPtr_stream_Val = stream; + cmock_call_instance->ReturnThruPtr_stream_Size = cmock_size; +} + +void pb_close_string_substream_CMockReturnMemThruPtr_substream(UNITY_LINE_TYPE cmock_line, pb_istream_t* substream, int cmock_size) +{ + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_close_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "substream ReturnThruPtr called before Expect on 'pb_close_string_substream'."); + cmock_call_instance->ReturnThruPtr_substream_Used = 1; + cmock_call_instance->ReturnThruPtr_substream_Val = substream; + cmock_call_instance->ReturnThruPtr_substream_Size = cmock_size; +} + +void pb_close_string_substream_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_close_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "stream IgnoreArg called before Expect on 'pb_close_string_substream'."); + cmock_call_instance->IgnoreArg_stream = 1; +} + +void pb_close_string_substream_CMockIgnoreArg_substream(UNITY_LINE_TYPE cmock_line) +{ + CMOCK_pb_close_string_substream_CALL_INSTANCE* cmock_call_instance = cmock_call_instance = (CMOCK_pb_close_string_substream_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.pb_close_string_substream_CallInstance)); + UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "substream IgnoreArg called before Expect on 'pb_close_string_substream'."); + cmock_call_instance->IgnoreArg_substream = 1; +} + +/* lint -restore */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.h new file mode 100644 index 0000000..2ae4753 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nano/mock_pb_decode.h @@ -0,0 +1,311 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#ifndef _MOCK_PB_DECODE_H +#define _MOCK_PB_DECODE_H + +#ifndef __STATIC_INLINE +#define __STATIC_INLINE +#else +#undef __STATIC_INLINE +#define __STATIC_INLINE +#endif +#define SUPPRESS_INLINE_IMPLEMENTATION + +#include +#undef SUPPRESS_INLINE_IMPLEMENTATION +#undef __STATIC_INLINE +#define __STATIC_INLINE __STATIC_INLINE1 +#include + +void mock_pb_decode_Init(void); +void mock_pb_decode_Destroy(void); +void mock_pb_decode_Verify(void); + + + + +#define pb_decode_IgnoreAndReturn(cmock_retval) pb_decode_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_ExpectAndReturn(stream, fields, dest_struct, cmock_retval) pb_decode_CMockExpectAndReturn(__LINE__, stream, fields, dest_struct, cmock_retval) +void pb_decode_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_CALLBACK)(pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, int cmock_num_calls); +void pb_decode_StubWithCallback(CMOCK_pb_decode_CALLBACK Callback); +#define pb_decode_ExpectWithArrayAndReturn(stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth, cmock_retval) pb_decode_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth, cmock_retval) +void pb_decode_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth, bool cmock_to_return); +#define pb_decode_ReturnThruPtr_stream(stream) pb_decode_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_ReturnThruPtr_dest_struct(dest_struct) pb_decode_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, sizeof(*dest_struct)) +#define pb_decode_ReturnArrayThruPtr_dest_struct(dest_struct, cmock_len) pb_decode_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_len * sizeof(*dest_struct)) +#define pb_decode_ReturnMemThruPtr_dest_struct(dest_struct, cmock_size) pb_decode_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_size) +void pb_decode_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size); +#define pb_decode_IgnoreArg_stream() pb_decode_CMockIgnoreArg_stream(__LINE__) +void pb_decode_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_IgnoreArg_fields() pb_decode_CMockIgnoreArg_fields(__LINE__) +void pb_decode_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line); +#define pb_decode_IgnoreArg_dest_struct() pb_decode_CMockIgnoreArg_dest_struct(__LINE__) +void pb_decode_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line); +#define pb_decode_noinit_IgnoreAndReturn(cmock_retval) pb_decode_noinit_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_noinit_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_noinit_ExpectAndReturn(stream, fields, dest_struct, cmock_retval) pb_decode_noinit_CMockExpectAndReturn(__LINE__, stream, fields, dest_struct, cmock_retval) +void pb_decode_noinit_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_noinit_CALLBACK)(pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, int cmock_num_calls); +void pb_decode_noinit_StubWithCallback(CMOCK_pb_decode_noinit_CALLBACK Callback); +#define pb_decode_noinit_ExpectWithArrayAndReturn(stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth, cmock_retval) pb_decode_noinit_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth, cmock_retval) +void pb_decode_noinit_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth, bool cmock_to_return); +#define pb_decode_noinit_ReturnThruPtr_stream(stream) pb_decode_noinit_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_noinit_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_noinit_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_noinit_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_noinit_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_noinit_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_noinit_ReturnThruPtr_dest_struct(dest_struct) pb_decode_noinit_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, sizeof(*dest_struct)) +#define pb_decode_noinit_ReturnArrayThruPtr_dest_struct(dest_struct, cmock_len) pb_decode_noinit_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_len * sizeof(*dest_struct)) +#define pb_decode_noinit_ReturnMemThruPtr_dest_struct(dest_struct, cmock_size) pb_decode_noinit_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_size) +void pb_decode_noinit_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size); +#define pb_decode_noinit_IgnoreArg_stream() pb_decode_noinit_CMockIgnoreArg_stream(__LINE__) +void pb_decode_noinit_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_noinit_IgnoreArg_fields() pb_decode_noinit_CMockIgnoreArg_fields(__LINE__) +void pb_decode_noinit_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line); +#define pb_decode_noinit_IgnoreArg_dest_struct() pb_decode_noinit_CMockIgnoreArg_dest_struct(__LINE__) +void pb_decode_noinit_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line); +#define pb_decode_delimited_IgnoreAndReturn(cmock_retval) pb_decode_delimited_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_delimited_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_delimited_ExpectAndReturn(stream, fields, dest_struct, cmock_retval) pb_decode_delimited_CMockExpectAndReturn(__LINE__, stream, fields, dest_struct, cmock_retval) +void pb_decode_delimited_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_delimited_CALLBACK)(pb_istream_t* stream, const pb_field_t* fields, void* dest_struct, int cmock_num_calls); +void pb_decode_delimited_StubWithCallback(CMOCK_pb_decode_delimited_CALLBACK Callback); +#define pb_decode_delimited_ExpectWithArrayAndReturn(stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth, cmock_retval) pb_decode_delimited_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, fields, fields_Depth, dest_struct, dest_struct_Depth, cmock_retval) +void pb_decode_delimited_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth, bool cmock_to_return); +#define pb_decode_delimited_ReturnThruPtr_stream(stream) pb_decode_delimited_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_delimited_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_delimited_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_delimited_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_delimited_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_delimited_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_delimited_ReturnThruPtr_dest_struct(dest_struct) pb_decode_delimited_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, sizeof(*dest_struct)) +#define pb_decode_delimited_ReturnArrayThruPtr_dest_struct(dest_struct, cmock_len) pb_decode_delimited_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_len * sizeof(*dest_struct)) +#define pb_decode_delimited_ReturnMemThruPtr_dest_struct(dest_struct, cmock_size) pb_decode_delimited_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_size) +void pb_decode_delimited_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size); +#define pb_decode_delimited_IgnoreArg_stream() pb_decode_delimited_CMockIgnoreArg_stream(__LINE__) +void pb_decode_delimited_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_delimited_IgnoreArg_fields() pb_decode_delimited_CMockIgnoreArg_fields(__LINE__) +void pb_decode_delimited_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line); +#define pb_decode_delimited_IgnoreArg_dest_struct() pb_decode_delimited_CMockIgnoreArg_dest_struct(__LINE__) +void pb_decode_delimited_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line); +#define pb_release_Ignore() pb_release_CMockIgnore() +void pb_release_CMockIgnore(void); +#define pb_release_Expect(fields, dest_struct) pb_release_CMockExpect(__LINE__, fields, dest_struct) +void pb_release_CMockExpect(UNITY_LINE_TYPE cmock_line, const pb_field_t* fields, void* dest_struct); +typedef void (* CMOCK_pb_release_CALLBACK)(const pb_field_t* fields, void* dest_struct, int cmock_num_calls); +void pb_release_StubWithCallback(CMOCK_pb_release_CALLBACK Callback); +#define pb_release_ExpectWithArray(fields, fields_Depth, dest_struct, dest_struct_Depth) pb_release_CMockExpectWithArray(__LINE__, fields, fields_Depth, dest_struct, dest_struct_Depth) +void pb_release_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, pb_field_t* fields, int fields_Depth, void* dest_struct, int dest_struct_Depth); +#define pb_release_ReturnThruPtr_dest_struct(dest_struct) pb_release_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, sizeof(*dest_struct)) +#define pb_release_ReturnArrayThruPtr_dest_struct(dest_struct, cmock_len) pb_release_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_len * sizeof(*dest_struct)) +#define pb_release_ReturnMemThruPtr_dest_struct(dest_struct, cmock_size) pb_release_CMockReturnMemThruPtr_dest_struct(__LINE__, dest_struct, cmock_size) +void pb_release_CMockReturnMemThruPtr_dest_struct(UNITY_LINE_TYPE cmock_line, void* dest_struct, int cmock_size); +#define pb_release_IgnoreArg_fields() pb_release_CMockIgnoreArg_fields(__LINE__) +void pb_release_CMockIgnoreArg_fields(UNITY_LINE_TYPE cmock_line); +#define pb_release_IgnoreArg_dest_struct() pb_release_CMockIgnoreArg_dest_struct(__LINE__) +void pb_release_CMockIgnoreArg_dest_struct(UNITY_LINE_TYPE cmock_line); +#define pb_istream_from_buffer_IgnoreAndReturn(cmock_retval) pb_istream_from_buffer_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_istream_from_buffer_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t cmock_to_return); +#define pb_istream_from_buffer_ExpectAndReturn(buf, bufsize, cmock_retval) pb_istream_from_buffer_CMockExpectAndReturn(__LINE__, buf, bufsize, cmock_retval) +void pb_istream_from_buffer_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, const pb_byte_t* buf, size_t bufsize, pb_istream_t cmock_to_return); +typedef pb_istream_t (* CMOCK_pb_istream_from_buffer_CALLBACK)(const pb_byte_t* buf, size_t bufsize, int cmock_num_calls); +void pb_istream_from_buffer_StubWithCallback(CMOCK_pb_istream_from_buffer_CALLBACK Callback); +#define pb_istream_from_buffer_ExpectWithArrayAndReturn(buf, buf_Depth, bufsize, cmock_retval) pb_istream_from_buffer_CMockExpectWithArrayAndReturn(__LINE__, buf, buf_Depth, bufsize, cmock_retval) +void pb_istream_from_buffer_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_byte_t* buf, int buf_Depth, size_t bufsize, pb_istream_t cmock_to_return); +#define pb_istream_from_buffer_IgnoreArg_buf() pb_istream_from_buffer_CMockIgnoreArg_buf(__LINE__) +void pb_istream_from_buffer_CMockIgnoreArg_buf(UNITY_LINE_TYPE cmock_line); +#define pb_istream_from_buffer_IgnoreArg_bufsize() pb_istream_from_buffer_CMockIgnoreArg_bufsize(__LINE__) +void pb_istream_from_buffer_CMockIgnoreArg_bufsize(UNITY_LINE_TYPE cmock_line); +#define pb_read_IgnoreAndReturn(cmock_retval) pb_read_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_read_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_read_ExpectAndReturn(stream, buf, count, cmock_retval) pb_read_CMockExpectAndReturn(__LINE__, stream, buf, count, cmock_retval) +void pb_read_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_byte_t* buf, size_t count, bool cmock_to_return); +typedef bool (* CMOCK_pb_read_CALLBACK)(pb_istream_t* stream, pb_byte_t* buf, size_t count, int cmock_num_calls); +void pb_read_StubWithCallback(CMOCK_pb_read_CALLBACK Callback); +#define pb_read_ExpectWithArrayAndReturn(stream, stream_Depth, buf, buf_Depth, count, cmock_retval) pb_read_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, buf, buf_Depth, count, cmock_retval) +void pb_read_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_byte_t* buf, int buf_Depth, size_t count, bool cmock_to_return); +#define pb_read_ReturnThruPtr_stream(stream) pb_read_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_read_ReturnArrayThruPtr_stream(stream, cmock_len) pb_read_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_read_ReturnMemThruPtr_stream(stream, cmock_size) pb_read_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_read_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_read_ReturnThruPtr_buf(buf) pb_read_CMockReturnMemThruPtr_buf(__LINE__, buf, sizeof(*buf)) +#define pb_read_ReturnArrayThruPtr_buf(buf, cmock_len) pb_read_CMockReturnMemThruPtr_buf(__LINE__, buf, cmock_len * sizeof(*buf)) +#define pb_read_ReturnMemThruPtr_buf(buf, cmock_size) pb_read_CMockReturnMemThruPtr_buf(__LINE__, buf, cmock_size) +void pb_read_CMockReturnMemThruPtr_buf(UNITY_LINE_TYPE cmock_line, pb_byte_t* buf, int cmock_size); +#define pb_read_IgnoreArg_stream() pb_read_CMockIgnoreArg_stream(__LINE__) +void pb_read_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_read_IgnoreArg_buf() pb_read_CMockIgnoreArg_buf(__LINE__) +void pb_read_CMockIgnoreArg_buf(UNITY_LINE_TYPE cmock_line); +#define pb_read_IgnoreArg_count() pb_read_CMockIgnoreArg_count(__LINE__) +void pb_read_CMockIgnoreArg_count(UNITY_LINE_TYPE cmock_line); +#define pb_decode_tag_IgnoreAndReturn(cmock_retval) pb_decode_tag_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_tag_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_tag_ExpectAndReturn(stream, wire_type, tag, eof, cmock_retval) pb_decode_tag_CMockExpectAndReturn(__LINE__, stream, wire_type, tag, eof, cmock_retval) +void pb_decode_tag_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_wire_type_t* wire_type, uint32_t* tag, bool* eof, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_tag_CALLBACK)(pb_istream_t* stream, pb_wire_type_t* wire_type, uint32_t* tag, bool* eof, int cmock_num_calls); +void pb_decode_tag_StubWithCallback(CMOCK_pb_decode_tag_CALLBACK Callback); +#define pb_decode_tag_ExpectWithArrayAndReturn(stream, stream_Depth, wire_type, wire_type_Depth, tag, tag_Depth, eof, eof_Depth, cmock_retval) pb_decode_tag_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, wire_type, wire_type_Depth, tag, tag_Depth, eof, eof_Depth, cmock_retval) +void pb_decode_tag_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_wire_type_t* wire_type, int wire_type_Depth, uint32_t* tag, int tag_Depth, bool* eof, int eof_Depth, bool cmock_to_return); +#define pb_decode_tag_ReturnThruPtr_stream(stream) pb_decode_tag_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_tag_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_tag_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_tag_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_tag_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_tag_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_tag_ReturnThruPtr_wire_type(wire_type) pb_decode_tag_CMockReturnMemThruPtr_wire_type(__LINE__, wire_type, sizeof(*wire_type)) +#define pb_decode_tag_ReturnArrayThruPtr_wire_type(wire_type, cmock_len) pb_decode_tag_CMockReturnMemThruPtr_wire_type(__LINE__, wire_type, cmock_len * sizeof(*wire_type)) +#define pb_decode_tag_ReturnMemThruPtr_wire_type(wire_type, cmock_size) pb_decode_tag_CMockReturnMemThruPtr_wire_type(__LINE__, wire_type, cmock_size) +void pb_decode_tag_CMockReturnMemThruPtr_wire_type(UNITY_LINE_TYPE cmock_line, pb_wire_type_t* wire_type, int cmock_size); +#define pb_decode_tag_ReturnThruPtr_tag(tag) pb_decode_tag_CMockReturnMemThruPtr_tag(__LINE__, tag, sizeof(*tag)) +#define pb_decode_tag_ReturnArrayThruPtr_tag(tag, cmock_len) pb_decode_tag_CMockReturnMemThruPtr_tag(__LINE__, tag, cmock_len * sizeof(*tag)) +#define pb_decode_tag_ReturnMemThruPtr_tag(tag, cmock_size) pb_decode_tag_CMockReturnMemThruPtr_tag(__LINE__, tag, cmock_size) +void pb_decode_tag_CMockReturnMemThruPtr_tag(UNITY_LINE_TYPE cmock_line, uint32_t* tag, int cmock_size); +#define pb_decode_tag_ReturnThruPtr_eof(eof) pb_decode_tag_CMockReturnMemThruPtr_eof(__LINE__, eof, sizeof(*eof)) +#define pb_decode_tag_ReturnArrayThruPtr_eof(eof, cmock_len) pb_decode_tag_CMockReturnMemThruPtr_eof(__LINE__, eof, cmock_len * sizeof(*eof)) +#define pb_decode_tag_ReturnMemThruPtr_eof(eof, cmock_size) pb_decode_tag_CMockReturnMemThruPtr_eof(__LINE__, eof, cmock_size) +void pb_decode_tag_CMockReturnMemThruPtr_eof(UNITY_LINE_TYPE cmock_line, bool* eof, int cmock_size); +#define pb_decode_tag_IgnoreArg_stream() pb_decode_tag_CMockIgnoreArg_stream(__LINE__) +void pb_decode_tag_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_tag_IgnoreArg_wire_type() pb_decode_tag_CMockIgnoreArg_wire_type(__LINE__) +void pb_decode_tag_CMockIgnoreArg_wire_type(UNITY_LINE_TYPE cmock_line); +#define pb_decode_tag_IgnoreArg_tag() pb_decode_tag_CMockIgnoreArg_tag(__LINE__) +void pb_decode_tag_CMockIgnoreArg_tag(UNITY_LINE_TYPE cmock_line); +#define pb_decode_tag_IgnoreArg_eof() pb_decode_tag_CMockIgnoreArg_eof(__LINE__) +void pb_decode_tag_CMockIgnoreArg_eof(UNITY_LINE_TYPE cmock_line); +#define pb_skip_field_IgnoreAndReturn(cmock_retval) pb_skip_field_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_skip_field_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_skip_field_ExpectAndReturn(stream, wire_type, cmock_retval) pb_skip_field_CMockExpectAndReturn(__LINE__, stream, wire_type, cmock_retval) +void pb_skip_field_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_wire_type_t wire_type, bool cmock_to_return); +typedef bool (* CMOCK_pb_skip_field_CALLBACK)(pb_istream_t* stream, pb_wire_type_t wire_type, int cmock_num_calls); +void pb_skip_field_StubWithCallback(CMOCK_pb_skip_field_CALLBACK Callback); +#define pb_skip_field_ExpectWithArrayAndReturn(stream, stream_Depth, wire_type, cmock_retval) pb_skip_field_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, wire_type, cmock_retval) +void pb_skip_field_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_wire_type_t wire_type, bool cmock_to_return); +#define pb_skip_field_ReturnThruPtr_stream(stream) pb_skip_field_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_skip_field_ReturnArrayThruPtr_stream(stream, cmock_len) pb_skip_field_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_skip_field_ReturnMemThruPtr_stream(stream, cmock_size) pb_skip_field_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_skip_field_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_skip_field_IgnoreArg_stream() pb_skip_field_CMockIgnoreArg_stream(__LINE__) +void pb_skip_field_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_skip_field_IgnoreArg_wire_type() pb_skip_field_CMockIgnoreArg_wire_type(__LINE__) +void pb_skip_field_CMockIgnoreArg_wire_type(UNITY_LINE_TYPE cmock_line); +#define pb_decode_varint_IgnoreAndReturn(cmock_retval) pb_decode_varint_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_varint_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_varint_ExpectAndReturn(stream, dest, cmock_retval) pb_decode_varint_CMockExpectAndReturn(__LINE__, stream, dest, cmock_retval) +void pb_decode_varint_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, uint64_t* dest, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_varint_CALLBACK)(pb_istream_t* stream, uint64_t* dest, int cmock_num_calls); +void pb_decode_varint_StubWithCallback(CMOCK_pb_decode_varint_CALLBACK Callback); +#define pb_decode_varint_ExpectWithArrayAndReturn(stream, stream_Depth, dest, dest_Depth, cmock_retval) pb_decode_varint_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, dest, dest_Depth, cmock_retval) +void pb_decode_varint_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, uint64_t* dest, int dest_Depth, bool cmock_to_return); +#define pb_decode_varint_ReturnThruPtr_stream(stream) pb_decode_varint_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_varint_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_varint_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_varint_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_varint_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_varint_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_varint_ReturnThruPtr_dest(dest) pb_decode_varint_CMockReturnMemThruPtr_dest(__LINE__, dest, sizeof(*dest)) +#define pb_decode_varint_ReturnArrayThruPtr_dest(dest, cmock_len) pb_decode_varint_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_len * sizeof(*dest)) +#define pb_decode_varint_ReturnMemThruPtr_dest(dest, cmock_size) pb_decode_varint_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_size) +void pb_decode_varint_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, uint64_t* dest, int cmock_size); +#define pb_decode_varint_IgnoreArg_stream() pb_decode_varint_CMockIgnoreArg_stream(__LINE__) +void pb_decode_varint_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_varint_IgnoreArg_dest() pb_decode_varint_CMockIgnoreArg_dest(__LINE__) +void pb_decode_varint_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line); +#define pb_decode_svarint_IgnoreAndReturn(cmock_retval) pb_decode_svarint_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_svarint_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_svarint_ExpectAndReturn(stream, dest, cmock_retval) pb_decode_svarint_CMockExpectAndReturn(__LINE__, stream, dest, cmock_retval) +void pb_decode_svarint_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int64_t* dest, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_svarint_CALLBACK)(pb_istream_t* stream, int64_t* dest, int cmock_num_calls); +void pb_decode_svarint_StubWithCallback(CMOCK_pb_decode_svarint_CALLBACK Callback); +#define pb_decode_svarint_ExpectWithArrayAndReturn(stream, stream_Depth, dest, dest_Depth, cmock_retval) pb_decode_svarint_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, dest, dest_Depth, cmock_retval) +void pb_decode_svarint_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, int64_t* dest, int dest_Depth, bool cmock_to_return); +#define pb_decode_svarint_ReturnThruPtr_stream(stream) pb_decode_svarint_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_svarint_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_svarint_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_svarint_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_svarint_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_svarint_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_svarint_ReturnThruPtr_dest(dest) pb_decode_svarint_CMockReturnMemThruPtr_dest(__LINE__, dest, sizeof(*dest)) +#define pb_decode_svarint_ReturnArrayThruPtr_dest(dest, cmock_len) pb_decode_svarint_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_len * sizeof(*dest)) +#define pb_decode_svarint_ReturnMemThruPtr_dest(dest, cmock_size) pb_decode_svarint_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_size) +void pb_decode_svarint_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, int64_t* dest, int cmock_size); +#define pb_decode_svarint_IgnoreArg_stream() pb_decode_svarint_CMockIgnoreArg_stream(__LINE__) +void pb_decode_svarint_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_svarint_IgnoreArg_dest() pb_decode_svarint_CMockIgnoreArg_dest(__LINE__) +void pb_decode_svarint_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line); +#define pb_decode_fixed32_IgnoreAndReturn(cmock_retval) pb_decode_fixed32_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_fixed32_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_fixed32_ExpectAndReturn(stream, dest, cmock_retval) pb_decode_fixed32_CMockExpectAndReturn(__LINE__, stream, dest, cmock_retval) +void pb_decode_fixed32_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, void* dest, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_fixed32_CALLBACK)(pb_istream_t* stream, void* dest, int cmock_num_calls); +void pb_decode_fixed32_StubWithCallback(CMOCK_pb_decode_fixed32_CALLBACK Callback); +#define pb_decode_fixed32_ExpectWithArrayAndReturn(stream, stream_Depth, dest, dest_Depth, cmock_retval) pb_decode_fixed32_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, dest, dest_Depth, cmock_retval) +void pb_decode_fixed32_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, void* dest, int dest_Depth, bool cmock_to_return); +#define pb_decode_fixed32_ReturnThruPtr_stream(stream) pb_decode_fixed32_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_fixed32_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_fixed32_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_fixed32_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_fixed32_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_fixed32_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_fixed32_ReturnThruPtr_dest(dest) pb_decode_fixed32_CMockReturnMemThruPtr_dest(__LINE__, dest, sizeof(*dest)) +#define pb_decode_fixed32_ReturnArrayThruPtr_dest(dest, cmock_len) pb_decode_fixed32_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_len * sizeof(*dest)) +#define pb_decode_fixed32_ReturnMemThruPtr_dest(dest, cmock_size) pb_decode_fixed32_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_size) +void pb_decode_fixed32_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, void* dest, int cmock_size); +#define pb_decode_fixed32_IgnoreArg_stream() pb_decode_fixed32_CMockIgnoreArg_stream(__LINE__) +void pb_decode_fixed32_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_fixed32_IgnoreArg_dest() pb_decode_fixed32_CMockIgnoreArg_dest(__LINE__) +void pb_decode_fixed32_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line); +#define pb_decode_fixed64_IgnoreAndReturn(cmock_retval) pb_decode_fixed64_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_decode_fixed64_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_decode_fixed64_ExpectAndReturn(stream, dest, cmock_retval) pb_decode_fixed64_CMockExpectAndReturn(__LINE__, stream, dest, cmock_retval) +void pb_decode_fixed64_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, void* dest, bool cmock_to_return); +typedef bool (* CMOCK_pb_decode_fixed64_CALLBACK)(pb_istream_t* stream, void* dest, int cmock_num_calls); +void pb_decode_fixed64_StubWithCallback(CMOCK_pb_decode_fixed64_CALLBACK Callback); +#define pb_decode_fixed64_ExpectWithArrayAndReturn(stream, stream_Depth, dest, dest_Depth, cmock_retval) pb_decode_fixed64_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, dest, dest_Depth, cmock_retval) +void pb_decode_fixed64_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, void* dest, int dest_Depth, bool cmock_to_return); +#define pb_decode_fixed64_ReturnThruPtr_stream(stream) pb_decode_fixed64_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_decode_fixed64_ReturnArrayThruPtr_stream(stream, cmock_len) pb_decode_fixed64_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_decode_fixed64_ReturnMemThruPtr_stream(stream, cmock_size) pb_decode_fixed64_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_decode_fixed64_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_decode_fixed64_ReturnThruPtr_dest(dest) pb_decode_fixed64_CMockReturnMemThruPtr_dest(__LINE__, dest, sizeof(*dest)) +#define pb_decode_fixed64_ReturnArrayThruPtr_dest(dest, cmock_len) pb_decode_fixed64_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_len * sizeof(*dest)) +#define pb_decode_fixed64_ReturnMemThruPtr_dest(dest, cmock_size) pb_decode_fixed64_CMockReturnMemThruPtr_dest(__LINE__, dest, cmock_size) +void pb_decode_fixed64_CMockReturnMemThruPtr_dest(UNITY_LINE_TYPE cmock_line, void* dest, int cmock_size); +#define pb_decode_fixed64_IgnoreArg_stream() pb_decode_fixed64_CMockIgnoreArg_stream(__LINE__) +void pb_decode_fixed64_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_decode_fixed64_IgnoreArg_dest() pb_decode_fixed64_CMockIgnoreArg_dest(__LINE__) +void pb_decode_fixed64_CMockIgnoreArg_dest(UNITY_LINE_TYPE cmock_line); +#define pb_make_string_substream_IgnoreAndReturn(cmock_retval) pb_make_string_substream_CMockIgnoreAndReturn(__LINE__, cmock_retval) +void pb_make_string_substream_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return); +#define pb_make_string_substream_ExpectAndReturn(stream, substream, cmock_retval) pb_make_string_substream_CMockExpectAndReturn(__LINE__, stream, substream, cmock_retval) +void pb_make_string_substream_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_istream_t* substream, bool cmock_to_return); +typedef bool (* CMOCK_pb_make_string_substream_CALLBACK)(pb_istream_t* stream, pb_istream_t* substream, int cmock_num_calls); +void pb_make_string_substream_StubWithCallback(CMOCK_pb_make_string_substream_CALLBACK Callback); +#define pb_make_string_substream_ExpectWithArrayAndReturn(stream, stream_Depth, substream, substream_Depth, cmock_retval) pb_make_string_substream_CMockExpectWithArrayAndReturn(__LINE__, stream, stream_Depth, substream, substream_Depth, cmock_retval) +void pb_make_string_substream_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_istream_t* substream, int substream_Depth, bool cmock_to_return); +#define pb_make_string_substream_ReturnThruPtr_stream(stream) pb_make_string_substream_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_make_string_substream_ReturnArrayThruPtr_stream(stream, cmock_len) pb_make_string_substream_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_make_string_substream_ReturnMemThruPtr_stream(stream, cmock_size) pb_make_string_substream_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_make_string_substream_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_make_string_substream_ReturnThruPtr_substream(substream) pb_make_string_substream_CMockReturnMemThruPtr_substream(__LINE__, substream, sizeof(*substream)) +#define pb_make_string_substream_ReturnArrayThruPtr_substream(substream, cmock_len) pb_make_string_substream_CMockReturnMemThruPtr_substream(__LINE__, substream, cmock_len * sizeof(*substream)) +#define pb_make_string_substream_ReturnMemThruPtr_substream(substream, cmock_size) pb_make_string_substream_CMockReturnMemThruPtr_substream(__LINE__, substream, cmock_size) +void pb_make_string_substream_CMockReturnMemThruPtr_substream(UNITY_LINE_TYPE cmock_line, pb_istream_t* substream, int cmock_size); +#define pb_make_string_substream_IgnoreArg_stream() pb_make_string_substream_CMockIgnoreArg_stream(__LINE__) +void pb_make_string_substream_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_make_string_substream_IgnoreArg_substream() pb_make_string_substream_CMockIgnoreArg_substream(__LINE__) +void pb_make_string_substream_CMockIgnoreArg_substream(UNITY_LINE_TYPE cmock_line); +#define pb_close_string_substream_Ignore() pb_close_string_substream_CMockIgnore() +void pb_close_string_substream_CMockIgnore(void); +#define pb_close_string_substream_Expect(stream, substream) pb_close_string_substream_CMockExpect(__LINE__, stream, substream) +void pb_close_string_substream_CMockExpect(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, pb_istream_t* substream); +typedef void (* CMOCK_pb_close_string_substream_CALLBACK)(pb_istream_t* stream, pb_istream_t* substream, int cmock_num_calls); +void pb_close_string_substream_StubWithCallback(CMOCK_pb_close_string_substream_CALLBACK Callback); +#define pb_close_string_substream_ExpectWithArray(stream, stream_Depth, substream, substream_Depth) pb_close_string_substream_CMockExpectWithArray(__LINE__, stream, stream_Depth, substream, substream_Depth) +void pb_close_string_substream_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int stream_Depth, pb_istream_t* substream, int substream_Depth); +#define pb_close_string_substream_ReturnThruPtr_stream(stream) pb_close_string_substream_CMockReturnMemThruPtr_stream(__LINE__, stream, sizeof(*stream)) +#define pb_close_string_substream_ReturnArrayThruPtr_stream(stream, cmock_len) pb_close_string_substream_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_len * sizeof(*stream)) +#define pb_close_string_substream_ReturnMemThruPtr_stream(stream, cmock_size) pb_close_string_substream_CMockReturnMemThruPtr_stream(__LINE__, stream, cmock_size) +void pb_close_string_substream_CMockReturnMemThruPtr_stream(UNITY_LINE_TYPE cmock_line, pb_istream_t* stream, int cmock_size); +#define pb_close_string_substream_ReturnThruPtr_substream(substream) pb_close_string_substream_CMockReturnMemThruPtr_substream(__LINE__, substream, sizeof(*substream)) +#define pb_close_string_substream_ReturnArrayThruPtr_substream(substream, cmock_len) pb_close_string_substream_CMockReturnMemThruPtr_substream(__LINE__, substream, cmock_len * sizeof(*substream)) +#define pb_close_string_substream_ReturnMemThruPtr_substream(substream, cmock_size) pb_close_string_substream_CMockReturnMemThruPtr_substream(__LINE__, substream, cmock_size) +void pb_close_string_substream_CMockReturnMemThruPtr_substream(UNITY_LINE_TYPE cmock_line, pb_istream_t* substream, int cmock_size); +#define pb_close_string_substream_IgnoreArg_stream() pb_close_string_substream_CMockIgnoreArg_stream(__LINE__) +void pb_close_string_substream_CMockIgnoreArg_stream(UNITY_LINE_TYPE cmock_line); +#define pb_close_string_substream_IgnoreArg_substream() pb_close_string_substream_CMockIgnoreArg_substream(__LINE__) +void pb_close_string_substream_CMockIgnoreArg_substream(UNITY_LINE_TYPE cmock_line); + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nfc_adafruit_library/adafruit_pn532.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nfc_adafruit_library/adafruit_pn532.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nfc_adafruit_library/adafruit_pn532.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nfc_adafruit_library/adafruit_pn532.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nfc_adafruit_library/adafruit_pn532.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nfc_adafruit_library/adafruit_pn532.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nfc_adafruit_library/adafruit_pn532.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nfc_adafruit_library/adafruit_pn532.h diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile new file mode 100644 index 0000000..850e016 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile @@ -0,0 +1,11 @@ +@INCLUDE_PATH = /build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/ +@INCLUDE = doxygen_cc310.conf + +PROJECT_NAME = "ARM TrustZone CryptoCell 310 TEE API Documentation" +PROJECT_LOGO = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/ARM_Logo.png" +HTML_HEADER = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/header.html" +HTML_FOOTER = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/footer.html" +HTML_STYLESHEET = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/sasi_doxygen.css" + +INPUT = /build/HP-NG7-JOB1/build/release/runtime/include +OUTPUT_DIRECTORY = runtime/docs/external/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile.internal b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile.internal new file mode 100644 index 0000000..765dce5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/Doxyfile.internal @@ -0,0 +1,25 @@ +@INCLUDE_PATH = /build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/ +@INCLUDE = doxygen_cc310.conf + +PROJECT_NAME = "ARM TrustZone CryptoCell 310 TEE API Documentation - INTERNAL" +PROJECT_LOGO = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/ARM_Logo.png" +HTML_HEADER = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/header.html" +HTML_FOOTER = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/footer.html" +HTML_STYLESHEET = "/build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/doxygen/doxywrapper/sasi_doxygen.css" + +INPUT = /build/HP-NG7-JOB1/ext/arm_cc310/arm-sw-cc310-1.2.0.1294/ +RECURSIVE = YES +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_PACKAGE = YES +EXTRACT_STATIC = YES +INTERNAL_DOCS = YES +HAVE_DOT = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = YES +CALLER_GRAPH = YES +DIRECTORY_GRAPH = YES +GENERATE_ECLIPSEHELP = YES +ECLIPSE_DOC_ID = com.nordic.cc310 +OUTPUT_DIRECTORY = runtime/docs/internal diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_defs.h new file mode 100644 index 0000000..0963e08 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_defs.h @@ -0,0 +1,73 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +#include "SEGGER_RTT.h" +#include "ssi_pal_types_plat.h" + +#if DX_LINUX_PLATFORM +extern uint32_t g_free_mem_addr; +extern uint32_t *g_test_stack_base_addr; +extern uint32_t g_rom_base_addr; +extern uint32_t g_env_rom_base_addr; +#endif + + +SaSiError_t mapEnvMemory(void); +void unmapMemory(void); +SaSiError_t integration_tests_setup(void); +void integration_tests_clear(void); + + +#define REG_BASE_ADR DX_BASE_CC +#define REG_AREA_LEN 0x20000 +#define ENV_REG_BASE_ADR DX_BASE_ENV_REGS +#define ENV_REG_AREA_LEN 0x20000 +#define SRAM_BASE_ADR 0 +#define TEST_DATA_START_ADDRESS sizeof(CRYS_RND_State_t)+sizeof(CRYS_RND_WorkBuff_t) + +/* Zynq EVBs have 1GB and we reserve the memory at offset 768M */ +#define FREE_MEM_BASE_ADR 0x20020000 +#define CONTIG_FREE_MEM 0x8000 +/* Free memory is dedicated for SW image storage */ +#define BOOT_FREE_MEM_BASE_ADR FREE_MEM_BASE_ADR +#define BOOT_FREE_MEM_LEN 0x500000 + +/* user space follows the free memory, and uses for stack and workspace memory */ +#define PTHREAD_STACK_BASE_ADR (FREE_MEM_BASE_ADR + CONTIG_FREE_MEM) +#define PTHREAD_STACK_SIZE 16*1024 + +#define WORKSPACE_BASE_ADDR (PTHREAD_STACK_BASE_ADR + PTHREAD_STACK_SIZE) + +#define INTEG_TEST_PRINT(...) SEGGER_RTT_printf(0, __VA_ARGS__) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_utils.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_utils.c new file mode 100644 index 0000000..0c6405c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_plat_utils.c @@ -0,0 +1,120 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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. * +**************************************************************************************/ +#ifdef DX_LINUX_PLATFORM +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif +#include "ssi_pal_types.h" + +#include "integration_test_plat_defs.h" +#include "crys_rnd.h" + +#include "nrf.h" +#include "SEGGER_RTT.h" + +/*Globals*/ +uint32_t g_free_mem_addr; +uint32_t *g_test_stack_base_addr; +uint32_t g_rom_base_addr; +uint32_t g_env_rom_base_addr; + + +CRYS_RND_WorkBuff_t* rndWorkBuff_ptr; +CRYS_RND_State_t* rndState_ptr; + +#if defined(__CC_ARM) +CRYS_RND_State_t rndState = {0}; +CRYS_RND_WorkBuff_t rndWorkBuff = {0}; +#else +CRYS_RND_State_t rndState; +CRYS_RND_WorkBuff_t rndWorkBuff; +#endif + +uint32_t* UserSpace = 0; + + +//initializatoins that need to be done prior to running the integration tests. +SaSiError_t integration_tests_setup(void) +{ + SaSiError_t ret = 0; + rndState_ptr = &rndState; + rndWorkBuff_ptr = &rndWorkBuff; + + // Initialize Segger RTT logging + + (void)SEGGER_RTT_Init(); + + INTEG_TEST_PRINT("==================== TEST START ====================\r\n"); + + NVIC_EnableIRQ(CRYPTOCELL_IRQn); + + NRF_CRYPTOCELL->ENABLE = 1; + + return ret; +} + + +void integration_tests_clear(void) +{ + INTEG_TEST_PRINT("==================== TEST END ====================\r\n"); + while(1) + { + __WFI(); + } +} + + +void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) +{ + (void)id; + (void)pc; + (void)info; + while(1); +} + + +void SaSi_PalAbort(const char *msg) +{ + // This function overrides SaSi_PalAbort implemented in the library. + // The library version does a NVIC_SystemReset() and has no logging. + INTEG_TEST_PRINT("CC310 abort called: %s\r\n", msg); + while(1); +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_data.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_data.h similarity index 69% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_data.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_data.h index ab4d7d0..cafaa38 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/common/integration_test_ssi_data.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_data.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 "ssi_pal_types.h" #ifdef AES_INTEGTEST @@ -47,7 +71,7 @@ #define MAX_RND_SIZE_VECTOR 0x20 #ifdef AES_INTEGTEST -typedef struct aesDataStuct{ +typedef struct aesDataStuct{ uint8_t aesTest_name[MAX_TEST_DATA_SIZE]; uint8_t TST_KeyData[SASI_AES_KEY_MAX_SIZE_IN_BYTES]; uint8_t TST_KeySize; @@ -55,13 +79,13 @@ typedef struct aesDataStuct{ uint8_t aesTest_input_data[MAX_TEST_DATA_SIZE]; uint8_t aesTest_output_data[MAX_TEST_DATA_SIZE]; uint8_t aesTest_Expected_output_data[MAX_TEST_DATA_SIZE]; - uint16_t aesTest_DataSize; + uint16_t aesTest_DataSize; SaSiAesOperationMode_t aesTest_OperationMode; SaSiAesEncryptMode_t aesTest_EncDecMode; uint32_t aesTest_OutputDataSize; } aesDataStuct; -typedef struct aesCCMDataStuct{ +typedef struct aesCCMDataStuct{ uint8_t aesCCMTest_name[MAX_TEST_DATA_SIZE]; CRYS_AESCCM_Key_t aesCCMTest_Key; CRYS_AESCCM_KeySize_t aesCCMTest_KeySize; @@ -81,38 +105,38 @@ typedef struct aesCCMDataStuct{ #endif #ifdef ECC_INTEGTEST -typedef struct eccSignDataStuct{ +typedef struct eccSignDataStuct{ uint8_t eccTest_name[MAX_TEST_DATA_SIZE]; CRYS_ECPKI_DomainID_t eccTest_DomainID; CRYS_ECPKI_HASH_OpMode_t eccTest_HashMode; uint8_t eccTest_InputData[MAX_TEST_DATA_SIZE]; - uint32_t eccTest_InputDataSize; + uint32_t eccTest_InputDataSize; uint8_t eccTest_PubKey[MAX_TEST_DATA_SIZE]; - uint32_t eccTest_PubKeySize; + uint32_t eccTest_PubKeySize; uint8_t eccTest_PrivKey[MAX_TEST_DATA_SIZE]; uint32_t eccTest_PrivKeySize; - uint32_t eccTest_SignitureSize; - + uint32_t eccTest_SignitureSize; + } eccSignDataStuct; - -typedef struct eccDHDataStuct{ + +typedef struct eccDHDataStuct{ uint8_t eccDHTest_name[MAX_TEST_DATA_SIZE]; CRYS_ECPKI_DomainID_t eccDHTest_DomainID; uint8_t eccDHTest_PubKey1[MAX_TEST_DATA_SIZE]; - uint32_t eccDHTest_PubKeySize1; + uint32_t eccDHTest_PubKeySize1; uint8_t eccDHTest_PrivKey1[MAX_TEST_DATA_SIZE]; uint32_t eccDHTest_PrivKeySize1; uint8_t eccDHTest_PubKey2[MAX_TEST_DATA_SIZE]; - uint32_t eccDHTest_PubKeySize2; + uint32_t eccDHTest_PubKeySize2; uint8_t eccDHTest_PrivKey2[MAX_TEST_DATA_SIZE]; uint32_t eccDHTest_PrivKeySize2; -} eccDHDataStuct; +} eccDHDataStuct; #endif #ifdef CHACHA_INTEGTEST typedef struct CHACHA_DataStruct { - uint8_t testName[MAX_TEST_DATA_SIZE]; + uint8_t testName[MAX_TEST_DATA_SIZE]; CRYS_CHACHA_Nonce_t pIVCounter; CRYS_CHACHA_NonceSize_t IVSize; CRYS_CHACHA_Key_t pKey; @@ -126,7 +150,7 @@ typedef struct CHACHA_DataStruct { #define TEST_CHACHA_POLY_DATA_SIZE_MAX 272 typedef struct CHACHA_POLY_DataStruct { - uint8_t testName[MAX_TEST_DATA_SIZE]; + uint8_t testName[MAX_TEST_DATA_SIZE]; CRYS_CHACHA_EncryptMode_t encryptDecryptFlag; CRYS_CHACHA_Key_t pKey; uint8_t pDataIn[TEST_CHACHA_POLY_DATA_SIZE_MAX]; @@ -142,7 +166,7 @@ typedef struct CHACHA_POLY_DataStruct { #ifdef HASH_INTEGTEST -typedef struct hashDataStuct{ +typedef struct hashDataStuct{ uint8_t hashTest_Name[MAX_TEST_DATA_SIZE]; CRYS_HASH_OperationMode_t hashTest_TST_OperationMode; uint8_t hashTest_InputData[MAX_TEST_DATA_SIZE]; @@ -153,16 +177,16 @@ typedef struct hashDataStuct{ #endif #ifdef HMAC_INTEGTEST -typedef struct hmacDataStuct{ +typedef struct hmacDataStuct{ uint8_t hmacTest_Name[MAX_TEST_DATA_SIZE]; CRYS_HASH_OperationMode_t hmacTest_TST_OperationMode; uint8_t hmacTest_Key[CRYS_HMAC_KEY_SIZE_IN_BYTES]; - uint16_t hmacTest_KeySize; + uint16_t hmacTest_KeySize; uint8_t hmacTest_InputData[MAX_TEST_DATA_SIZE]; uint32_t hmacTest_InputDataSize; CRYS_HASH_Result_t hmacTest_ExpOutData; uint32_t hmacTest_ExpOutDataSize; -} hmacDataStuct; +} hmacDataStuct; #endif #ifdef RND_INTEGTEST @@ -192,7 +216,7 @@ typedef struct rndDataStuct{ #define TST_MAX_SIGN_VERIFY_DATA_IN_BYTES 512 #define TST_MAX_PUB_EXP_SIZE_IN_BYTES 3 #define TST_MAX_SINGLE_RSA_SIGN_BLOCK_SIZE_IN_BYTS 16 -#define TST_LESS_DATA_FOR_PKCS1V15_ENCRYPT 11 +#define TST_LESS_DATA_FOR_PKCS1V15_ENCRYPT 11 #define TST_LESS_DATA_FOR_OAEP_ENCRYPT_SHA1 42 #define TST_LESS_DATA_FOR_OAEP_ENCRYPT_SHA224 58 #define TST_LESS_DATA_FOR_OAEP_ENCRYPT_SHA256 66 @@ -210,59 +234,59 @@ typedef struct rndDataStuct{ #define TST_LESS_DATA_FOR_OAEP_ENCRYPT_SHA512 130 -typedef struct rsaEncDecDataStuct{ +typedef struct rsaEncDecDataStuct{ uint8_t rsaEncDec_Name[MAX_TEST_DATA_SIZE]; uint8_t rsaEncDec_PrivetExponent_D[TST_MAX_PRVT_EXP_SIZE_IN_BYTES]; uint8_t rsaEncDec_PublicExponent_E[TST_MAX_PUB_EXP_SIZE_IN_BYTES]; uint8_t rsaEncDec_Modulus_N[TST_MAX_MOD_SIZE_IN_BYTES]; - uint8_t rsaEncDec_P[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; - uint8_t rsaEncDec_Q[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; + uint8_t rsaEncDec_P[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; + uint8_t rsaEncDec_Q[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; uint8_t rsaEncDec_dP[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; uint8_t rsaEncDec_dQ[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; - uint8_t rsaEncDec_Qinv[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; + uint8_t rsaEncDec_Qinv[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; uint16_t rsaEncDec_KeySize; uint16_t rsaEncDec_DPSize; - uint16_t rsaEncDec_PubExponentSize; - uint8_t rsaEncDec_input_data[TST_MAX_ENCDEC_DATA_IN_BYTES]; - uint8_t rsaEncDec_output_data[TST_MAX_ENCDEC_DATA_IN_BYTES]; - uint8_t rsaEncDec_Expected_output_data[TST_MAX_ENCDEC_DATA_IN_BYTES]; + uint16_t rsaEncDec_PubExponentSize; + uint8_t rsaEncDec_input_data[TST_MAX_ENCDEC_DATA_IN_BYTES]; + uint8_t rsaEncDec_output_data[TST_MAX_ENCDEC_DATA_IN_BYTES]; + uint8_t rsaEncDec_Expected_output_data[TST_MAX_ENCDEC_DATA_IN_BYTES]; } rsaEncDecDataStuct; -typedef struct rsaSignVerifyDataStuct{ +typedef struct rsaSignVerifyDataStuct{ char rsaSignVerify_Name[MAX_TEST_DATA_SIZE]; uint8_t rsaSignVerify_PrivetExponent_D[TST_MAX_PRVT_EXP_SIZE_IN_BYTES]; uint8_t rsaSignVerify_PublicExponent_E[TST_MAX_PRVT_EXP_SIZE_IN_BYTES]; uint8_t rsaSignVerify_Modulus_N[TST_MAX_MOD_SIZE_IN_BYTES]; - uint8_t rsaSignVerify_P[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; - uint8_t rsaSignVerify_Q[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; + uint8_t rsaSignVerify_P[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; + uint8_t rsaSignVerify_Q[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; uint8_t rsaSignVerify_dP[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; uint8_t rsaSignVerify_dQ[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; - uint8_t rsaSignVerify_Qinv[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; + uint8_t rsaSignVerify_Qinv[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; uint16_t rsaSignVerify_KeySize; uint16_t rsaSignVerify_DPSize; - uint16_t rsaSignVerify_PubExponentSize; + uint16_t rsaSignVerify_PubExponentSize; uint16_t rsaSignVerify_SaltLength; uint8_t rsaSignVerify_input_data[TST_MAX_SIGN_VERIFY_DATA_IN_BYTES]; uint16_t rsaSignVerify_input_dataSize; - uint8_t rsaSignVerify_output_signiture[TST_MAX_PRVT_EXP_SIZE_IN_BYTES]; + uint8_t rsaSignVerify_output_signiture[TST_MAX_PRVT_EXP_SIZE_IN_BYTES]; uint8_t rsaSignVerify_hash_SHA1[CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES]; uint8_t rsaSignVerify_hash_SHA256[CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES]; uint8_t rsaSignVerify_hash_SHA512[CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES]; - + } rsaSignVerifyDataStuct; #endif #ifdef HKDF_INTEGTEST #define TST_NAME_STRING_LEN 150 -#define TST_HKDF_MAX_IKM_SIZE 512 -#define TST_HKDF_MAX_SALT_SIZE 512 -#define TST_HKDF_MAX_INFO_SIZE 128 -#define TST_HKDF_MAX_PRK_SIZE 2048 -#define TST_HKDF_MAX_OKM_SIZE 4096 +#define TST_HKDF_MAX_IKM_SIZE 512 +#define TST_HKDF_MAX_SALT_SIZE 512 +#define TST_HKDF_MAX_INFO_SIZE 128 +#define TST_HKDF_MAX_PRK_SIZE 2048 +#define TST_HKDF_MAX_OKM_SIZE 4096 -typedef struct hkdfDataStuct{ +typedef struct hkdfDataStuct{ char hkdf_Name[TST_NAME_STRING_LEN]; CRYS_HKDF_HASH_OpMode_t hkdfHashMode; uint8_t hkdf_IKM[TST_HKDF_MAX_IKM_SIZE]; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_defs.h new file mode 100644 index 0000000..c266b65 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/common/integration_test_ssi_defs.h @@ -0,0 +1,78 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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. * +**************************************************************************************/ + +#define SHARED_SECRET_MAX_LENGHT 250 +#define ECC_KEY_MAX_LENGHT 0x256 +#define AES_KEY_MAX_LENGHT_IN_BYTES 0x10 + + + +#define HASH_TESTS_NUMBER 0x3 +#define AES_TESTS_NUMBER 0x4 +#define AES_CCM_TESTS_NUMBER 0x1 +#define ECC_SIGN_TESTS_NUMBER 0x2 +#define ECC_DH_TESTS_NUMBER 0x2 +#define CHACHA_TESTS_NUMBER 0xA +#define CHACHA_POLY_TESTS_NUMBER 0x2 +#define HMAC_TESTS_NUMBER 0x2 +#define RSA_ENCDEC_OEP_TESTS_NUMBER 0x2 +#define RSA_SIGN_VERIFY_OEP_TESTS_NUMBER 0x1 +#define HKDF_TESTS_NUMBER 0x8 +#define OPERATIONS_NUMBER 0x2//Integrated/noniNtegrated + + +typedef enum OperationType_enum +{ + INTEGRATED_OPERATION , + NON_INTEGRATED_OPERATION , + OperationTypeLast= 0x7FFFFFFF, + +}OperationType_t; + +typedef enum BufferType_enum +{ + NON_INPLACE_BUFFER , + INPLACE_BUFFER , + BufferTypeLast= 0x7FFFFFFF, + +}BufferType_t; + +typedef enum RSAType_enum +{ + NON_CRT_MODE , + CRT_MODE , + RSATypeLast= 0x7FFFFFFF, + +}RSAType_enum; + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ccsw_crys_rsa_shared_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ccsw_crys_rsa_shared_types.h new file mode 100644 index 0000000..4b1e39f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ccsw_crys_rsa_shared_types.h @@ -0,0 +1,144 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 SW_CRYS_RSA_SHARED_TYPES_H +#define SW_CRYS_RSA_SHARED_TYPES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @file + * @brief This file contains the types for the CCSW RSA module. + */ + +/************************ Defines ******************************/ + +/************************************************************************/ +/* the following definitions are only relevant for RSA code on SW */ +/************************************************************************/ +/* Define the maximal allowed width of the exponentiation sliding window +in range 2...6. This define is actual for projects on soft platform. +To minimize code size use the minimum value. To optimize performance +choose the maximum value */ + +/* The valid key size in bits */ +#define SW_CRYS_RSA_MIN_VALID_KEY_SIZE_VALUE_IN_BITS 512 + +#ifndef CRYS_NO_RSA_MAX_KEY_SIZE_4096_BIT_SUPPORT +#define SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 4096 +#define SW_CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS 4096 +#else +#ifndef CRYS_NO_RSA_MAX_KEY_SIZE_3072_BIT_SUPPORT +#define SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 3072 +#define SW_CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS 3072 +#else +#define SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 2048 +#define SW_CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS 2048 +#endif +#endif + + + + + +/* Define the size of the exponentiation temp buffer, used in LLF_PKI exponentiation and NON DEPENDED on + width of the sliding window. The size defined in units equaled to maximal RSA modulus size */ +#define PKI_EXP_CONST_TEMP_BUFF_SIZE_IN_MODULUS_UNITS 7 + +#define PKI_EXP_SLIDING_WINDOW_MAX_VALUE 2 + + /* The maximum buffer size for the 'H' value */ +#define SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS ((SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS + 64UL ) / 32 ) + + +/* definition of PKI_KEY_GEN_TEMP_BUFF_SIZE_WORDS IS DEPENDED on width of the sliding window*/ +#if( PKI_EXP_SLIDING_WINDOW_MAX_VALUE > 2 ) +#define PKI_KEY_GEN_TEMP_BUFF_SIZE_WORDS \ + ((4 + (1<<(PKI_EXP_SLIDING_WINDOW_MAX_VALUE-2))) * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS) +#else +#define PKI_KEY_GEN_TEMP_BUFF_SIZE_WORDS \ + (16 * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS) +#endif + +#ifndef PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS +#define PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS (3 + (1 << (PKI_EXP_SLIDING_WINDOW_MAX_VALUE-1))) +#endif + + +/* Define the size of the temp buffer, used in LLF_PKI exponentiation and DEPENDED on + width of the sliding window in words */ +#if (PKI_EXP_CONST_TEMP_BUFF_SIZE_IN_MODULUS_UNITS > PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS ) +#define PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS \ + (PKI_EXP_CONST_TEMP_BUFF_SIZE_IN_MODULUS_UNITS * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS + 2 ) +#else +#define PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS \ + (PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS + 2 ) +#endif + +/* the RSA data type */ +typedef struct SW_Shared_CRYS_RSAPrimeData_t { + /* The aligned input and output data buffers */ + uint32_t DataIn[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + uint32_t DataOut[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + + /* #include specific fields that are used by the low level */ + struct { + union { + struct { /* Temporary buffers used for the exponent calculation */ + uint32_t Tempbuff1[PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS]; + uint32_t Tempbuff2[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS * 2]; + /* Temporary buffer for self-test support */ + uint32_t TempBuffer[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + }NonCrt; + + struct { /* Temporary buffers used for the exponent calculation */ + uint32_t Tempbuff1[PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS]; + uint32_t Tempbuff2[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS * 2]; + }Crt; + }Data; + }LLF; + +}SW_Shared_CRYS_RSAPrimeData_t; + + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm.h new file mode 100644 index 0000000..c6a3392 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm.h @@ -0,0 +1,315 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_AESCCM_H +#define CRYS_AESCCM_H + +#include "ssi_pal_types.h" +#include "crys_error.h" + +#include "ssi_aes.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains all of the enums and definitions that are used for the CRYS AESCCM APIs, as well as the APIs themselves. +The API supports AES-CCM and AES-CCM* as defined in ieee-802.15.4. +@defgroup crys_aesccm CryptoCell AES-CCM APIs +@{ +@ingroup cryptocell_api + + +@note +Regarding the AES-CCM*, the API supports only AES-CCM* as defined in ieee-802.15.4-2011; With the instantiations as defined in B.3.2 and the nonce as defined in 7.3.2. +in case of AES-CCM* the flow should be as follows: +
      • AES-CCM* integrated
      • +
        • CRYS_AESCCMStar_NonceGenerate
        • +
        • CRYS_AESCCMStar
      +
      • AES-CCM* non-integrated
      • +
        • CRYS_AESCCMStar_NonceGenerate
        • +
        • CRYS_AESCCMStar_Init
        • +
        • CRYS_AESCCM_BlockAdata
        • +
        • CRYS_AESCCM_BlockTextData
        • +
        • CRYS_AESCCM_Finish
      +*/ + +/************************ Defines ******************************/ + +/*! AES CCM context size in words.*/ +#define CRYS_AESCCM_USER_CTX_SIZE_IN_WORDS (152/4) + +/*! AES CCM maximal key size in words. */ +#define CRYS_AESCCM_KEY_SIZE_WORDS 8 + +/* nonce and AESCCM-MAC sizes definitions */ +/*! AES CCM NONCE minimal size in bytes. */ +#define CRYS_AESCCM_NONCE_MIN_SIZE_BYTES 7 +/*! AES CCM NONCE maximal size in bytes. */ +#define CRYS_AESCCM_NONCE_MAX_SIZE_BYTES 13 +/*! AES CCM MAC minimal size in bytes..*/ +#define CRYS_AESCCM_MAC_MIN_SIZE_BYTES 4 +/*! AES CCM MAC maximal size in bytes. */ +#define CRYS_AESCCM_MAC_MAX_SIZE_BYTES 16 + +/*! AES CCM star NONCE size in bytes. */ +#define CRYS_AESCCM_STAR_NONCE_SIZE_BYTES 13 +/*! AES CCM star source address size in bytes. */ +#define CRYS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES 8 + +/*! AES CCM mode - CCM. */ +#define CRYS_AESCCM_MODE_CCM 0 +/*! AES CCM mode - CCM STAR. */ +#define CRYS_AESCCM_MODE_STAR 1 + + +/************************ Typedefs ****************************/ +/*! AES CCM key sizes. */ +typedef enum { + /*! Key size 128 bits. */ + CRYS_AES_Key128BitSize = 0, + /*! Key size 192 bits. */ + CRYS_AES_Key192BitSize = 1, + /*! Key size 256 bits. */ + CRYS_AES_Key256BitSize = 2, + /*! Key size 512 bits. */ + CRYS_AES_Key512BitSize = 3, + /*! Number of optional key sizes. */ + CRYS_AES_KeySizeNumOfOptions, + /*! Reserved. */ + CRYS_AES_KeySizeLast = 0x7FFFFFFF, + +}CRYS_AESCCM_KeySize_t; + +/*! AES_CCM key buffer definition.*/ +typedef uint8_t CRYS_AESCCM_Key_t[CRYS_AESCCM_KEY_SIZE_WORDS * sizeof(uint32_t)]; +/*! AES_CCM MAC buffer definition.*/ +typedef uint8_t CRYS_AESCCM_Mac_Res_t[SASI_AES_BLOCK_SIZE_IN_BYTES]; + +/*! AES_CCM_STAR source address buffer defintion. */ +typedef uint8_t CRYS_AESCCMStar_SourceAddress_t[CRYS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES]; +/*! AES_CCM_STAR Nonce buffer defintion. */ +typedef uint8_t CRYS_AESCCMStar_Nonce_t[CRYS_AESCCM_STAR_NONCE_SIZE_BYTES]; + +/******************* Context Structure ***********************/ +/*! The user's context structure - the argument type that is passed by the user to the AES CCM APIs */ +typedef struct CRYS_AESCCM_UserContext_t +{ + /*! AES CCM context buffer for internal usage. */ + uint32_t buff[CRYS_AESCCM_USER_CTX_SIZE_IN_WORDS]; +}CRYS_AESCCM_UserContext_t; + + +/************************ Public Functions **********************/ + +/*! +@brief This function initializes the AES CCM context. + +It formats of the input data, calculates AES-MAC value for the formatted B0 block containing control information and +CCM unique value (Nonce), and initializes the AES context structure including the initial CTR0 value. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CC_AESCCM_Init( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the AES context buffer that is allocated by the user and is used for + the AES operation. */ + SaSiAesEncryptMode_t EncrDecrMode, /*!< [in] Flag specifying whether Encrypt (::SASI_AES_ENCRYPT) or Decrypt + (::SASI_AES_DECRYPT) operation should be performed. */ + CRYS_AESCCM_Key_t CCM_Key, /*!< [in] Pointer to the AES-CCM key. */ + CRYS_AESCCM_KeySize_t KeySizeId, /*!< [in] Enumerator defining the key size (only 128 bit is valid). */ + uint32_t AdataSize, /*!< [in] Full byte length of additional (associated) data. If set to zero, + calling ::CRYS_AESCCM_BlockAdata on the same context would return an error. */ + uint32_t TextSizeQ, /*!< [in] Full length of plain text data. */ + uint8_t *N_ptr, /*!< [in] Pointer to the Nonce. */ + uint8_t SizeOfN, /*!< [in] Nonce byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [7 .. 13].
      • +
      • CCM*: valid values = [13].
      */ + uint8_t SizeOfT, /*!< [in] AES-CCM MAC (tag) byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [4, 6, 8, 10, 12, 14, 16].
      • +
      • CCM*: valid values = [0, 4, 8, 16].
      */ + uint32_t ccmMode /*!< [in] Flag specifying whether AES-CCM or AES-CCM* should be performed. */ +); + +/*! Macro defintion for CRYS_AESCCM_Init (AES CCM non-star implementation). */ +#define CRYS_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT) \ + CC_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT, CRYS_AESCCM_MODE_CCM) + +/*! Macro defintion CRYS_AESCCMStar_Init (AES CCM star implementation). */ +#define CRYS_AESCCMStar_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT) \ + CC_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT, CRYS_AESCCM_MODE_STAR) + +/*! +@brief This function receives a CCM context and a block of additional data, and adds it to the AES MAC +calculation. +This API can be called only once per operation context. It should not be called in case AdataSize was set to +zero in ::CC_AESCCM_Init. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CRYS_AESCCM_BlockAdata( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ + uint8_t *DataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ + uint32_t DataInSize /*!< [in] Byte size of the additional data. Must match AdataSize parameter provided to + ::CRYS_AESCCM_Init. */ +); + +/*! +@brief This function can be invoked for any block of Text data whose size is a multiple of 16 bytes, +excluding the last block that must be processed by ::CRYS_AESCCM_Finish. +
      • If encrypting: + Continues calculation of the intermediate AES_MAC value of the text data, while simultaneously encrypting the text data using AES_CTR, + starting from CTR value = CTR0+1.
      • +
      • If decrypting: + Continues decryption of the text data, while calculating the intermediate AES_MAC value of decrypted data.
      + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CRYS_AESCCM_BlockTextData( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ + uint8_t *DataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ + uint32_t DataInSize, /*!< [in] Byte size of the text data block. Must be a multiple of 16 bytes. */ + uint8_t *DataOut_ptr /*!< [out] Pointer to the output data. The size of the output buffer must be at least DataInSize. + The buffer must be contiguous. */ +); + +/*! +@brief This function must be the last to be called on the text data. +It can either be called on the entire text data (if transferred as one block), or on the last block of the text data, +even if total size of text data is equal to 0. +It performs the same operations as ::CRYS_AESCCM_BlockTextData, but additionally: +
      • If encrypting:
      • +
        • If the size of text data is not in multiples of 16 bytes, it pads the remaining bytes with zeros to a full 16-bytes block and + processes the data using AES_MAC and AES_CTR algorithms.
        • +
        • Encrypts the AES_MAC result with AES_CTR using the CTR0 value saved in the context and places the SizeOfT bytes of MAC (tag) + at the end.
      +
      • If decrypting:
      • +
        • Processes the text data, except for the last SizeOfT bytes (tag), using AES_CTR and then AES_MAC algorithms.
        • +
        • Encrypts the calculated MAC using AES_CTR based on the saved CTR0 value, and compares it with SizeOfT last bytes of input data (i.e. + tag value).
        • +
        • The function saves the validation result (Valid/Invalid) in the context.
        • +
        • Returns (as the error code) the final CCM-MAC verification result.
      + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CEXPORT_C CRYSError_t CRYS_AESCCM_Finish( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ + uint8_t *DataIn_ptr, /*!< [in] Pointer to the last input data. The buffer must be contiguous. */ + uint32_t DataInSize, /*!< [in] Byte size of the last text data block. Can be zero. */ + uint8_t *DataOut_ptr, /*!< [in] Pointer to the output (cipher or plain text data) data. The buffer must + be contiguous. If DataInSize = 0, output buffer is not required. */ + CRYS_AESCCM_Mac_Res_t MacRes, /*!< [in] MAC result buffer pointer. */ + uint8_t *SizeOfT /*!< [out] AES-CCM MAC byte size as defined in CRYS_AESCCM_Init. */ +); + +/****************************************************************************************************/ +/******** AESCCM FUNCTION ******/ +/****************************************************************************************************/ +/*! +@brief AES CCM combines Counter mode encryption with CBC-MAC authentication. +Input to CCM includes the following elements: +
      • Payload - text data that is both authenticated and encrypted.
      • +
      • Associated data (Adata) - data that is authenticated but not encrypted, e.g., a header.
      • +
      • Nonce - A unique value that is assigned to the payload and the associated data.
      + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CIMPORT_C CRYSError_t CC_AESCCM( + SaSiAesEncryptMode_t EncrDecrMode, /*!< [in] A flag specifying whether an AES Encrypt (::SASI_AES_ENCRYPT) or Decrypt + (::SASI_AES_DECRYPT) operation should be performed. */ + CRYS_AESCCM_Key_t CCM_Key, /*!< [in] Pointer to AES-CCM key. */ + CRYS_AESCCM_KeySize_t KeySizeId, /*!< [in] Enumerator defining the key size (only 128 bit is valid). */ + uint8_t *N_ptr, /*!< [in] Pointer to the Nonce. */ + uint8_t SizeOfN, /*!< [in] Nonce byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [7 .. 13].
      • +
      • CCM*: valid values = [13].
      */ + uint8_t *ADataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ + uint32_t ADataInSize, /*!< [in] Byte size of the additional data. */ + uint8_t *TextDataIn_ptr, /*!< [in] Pointer to the plain-text data for encryption or cipher-text data for decryption. + The buffer must be contiguous. */ + uint32_t TextDataInSize, /*!< [in] Byte size of the full text data. */ + uint8_t *TextDataOut_ptr, /*!< [out] Pointer to the output (cipher or plain text data according to encrypt-decrypt mode) + data. The buffer must be contiguous. */ + uint8_t SizeOfT, /*!< [in] AES-CCM MAC (tag) byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [4, 6, 8, 10, 12, 14, 16].
      • +
      • CCM*: valid values = [0, 4, 8, 16].
      */ + CRYS_AESCCM_Mac_Res_t Mac_Res, /*!< [in/out] Pointer to the MAC result buffer. */ + uint32_t ccmMode /*!< [in] Flag specifying whether AES-CCM or AES-CCM* should be performed. */ +); + +/*! Macro defintion for CRYS_AESCCM (AES CCM non-star implementation). */ +#define CRYS_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res) \ + CC_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res, CRYS_AESCCM_MODE_CCM) + +/*! Macro defintion for CRYS_AESCCMStar (AES CCM star implementation). */ +#define CRYS_AESCCMStar(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res) \ + CC_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res, CRYS_AESCCM_MODE_STAR) + + +/*! +@brief This function receives the MAC source address, the frame counter and the MAC size +and returns the required nonce for AES-CCM* as defined in ieee-802.15.4. +This API should be called before CRYS_AESCCMStar and CRYS_AESCCMStar_Init, +and the generated nonce should be provided to these functions. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CRYS_AESCCMStar_NonceGenerate( + CRYS_AESCCMStar_SourceAddress_t srcAddr, /*!< [in] The MAC address in EUI-64 format. */ + uint32_t FrameCounter, /*!< [in] The MAC frame counter. */ + uint8_t SizeOfT, /*!< [in] AES-CCM* MAC (tag) byte size. Valid values = [0,4,8,16]. */ + CRYS_AESCCMStar_Nonce_t nonce /*!< [out] The required nonce for AES-CCM*. */ +); + +#ifdef __cplusplus +} +#endif + +/** +@} + */ + +#endif /*#ifndef CRYS_AESCCM_H*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm_error.h new file mode 100644 index 0000000..a2b20a0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_aesccm_error.h @@ -0,0 +1,134 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_AESCCM_ERROR_H +#define CRYS_AESCCM_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS AESCCM errors. +@defgroup crys_aesccm_error CryptoCell AES-CCM specific errors +@{ +@ingroup crys_aesccm +*/ + +/************************ Defines ******************************/ + +/*! CRYS AESCCM module errors. CRYS_AESCCM_MODULE_ERROR_BASE = 0x00F01500. */ +/*! Invalid context pointer. */ +#define CRYS_AESCCM_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x00UL) +/*! Illegal key size. */ +#define CRYS_AESCCM_ILLEGAL_KEY_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x01UL) +/*! Invalid key pointer. */ +#define CRYS_AESCCM_INVALID_KEY_POINTER_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x02UL) +/*! Invalid encryption mode. */ +#define CRYS_AESCCM_INVALID_ENCRYPT_MODE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x03UL) +/*! Context is corrupted. */ +#define CRYS_AESCCM_USER_CONTEXT_CORRUPTED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x04UL) +/*! Invalid data in pointer. */ +#define CRYS_AESCCM_DATA_IN_POINTER_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x05UL) +/*! Invalid data out pointer. */ +#define CRYS_AESCCM_DATA_OUT_POINTER_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x06UL) +/*! Illegal data in size. */ +#define CRYS_AESCCM_DATA_IN_SIZE_ILLEGAL (CRYS_AESCCM_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal data in or data out address. */ +#define CRYS_AESCCM_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x08UL) +/*! Illegal data out size. */ +#define CRYS_AESCCM_DATA_OUT_SIZE_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x09UL) +/*! Illegal call to process additional data. */ +#define CRYS_AESCCM_ADDITIONAL_BLOCK_NOT_PERMITTED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0AUL) +/*! Illegal dma buffer type. */ +#define CRYS_AESCCM_ILLEGAL_DMA_BUFF_TYPE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0BUL) +/*! Illegal parameter size. */ +#define CRYS_AESCCM_ILLEGAL_PARAMETER_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0CUL) +/*! Invalid parameter pointer. */ +#define CRYS_AESCCM_ILLEGAL_PARAMETER_PTR_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0DUL) +/*! Invalid data type. */ +#define CRYS_AESCCM_ILLEGAL_DATA_TYPE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0EUL) +/*! CCM MAC compare failure. */ +#define CRYS_AESCCM_CCM_MAC_INVALID_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x0FUL) +/*! Illegal operation. */ +#define CRYS_AESCCM_LAST_BLOCK_NOT_PERMITTED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x10UL) +/*! Illegal parameter. */ +#define CRYS_AESCCM_ILLEGAL_PARAMETER_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x11UL) +/*! Additional data input size is incorrect. */ +#define CRYS_AESCCM_NOT_ALL_ADATA_WAS_PROCESSED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x13UL) +/*! Text data input size is incorrect. */ +#define CRYS_AESCCM_NOT_ALL_DATA_WAS_PROCESSED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x14UL) +/*! Additional data was already processed (must be processed only once). */ +#define CRYS_AESCCM_ADATA_WAS_PROCESSED_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x15UL) +/*! Illegal Nonce size. */ +#define CRYS_AESCCM_ILLEGAL_NONCE_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x16UL) +/*! Illegal tag (MAC) size. */ +#define CRYS_AESCCM_ILLEGAL_TAG_SIZE_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x17UL) + +/*! Illegal context size. */ +#define CRYS_AESCCM_CTX_SIZES_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x28UL) +/*! Illegal parameters. */ +#define CRYS_AESCCM_ILLEGAL_PARAMS_ERROR (CRYS_AESCCM_MODULE_ERROR_BASE + 0x29UL) +/*! AESCCM is not supported. */ +#define CRYS_AESCCM_IS_NOT_SUPPORTED (CRYS_AESCCM_MODULE_ERROR_BASE + 0xFFUL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif + +/** +@} + */ + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha.h similarity index 63% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha.h index 17106b2..d303a38 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_chacha.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha.h @@ -1,18 +1,45 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 @brief This file contains all of the enums and definitions that are used for the CRYS CHACHA APIs, as well as the APIs themselves. +@defgroup crys_chacha CryptoCell CHACHA APIs +@{ +@ingroup cryptocell_api */ #ifndef CRYS_CHACHA_H #define CRYS_CHACHA_H @@ -28,43 +55,49 @@ extern "C" #endif /************************ Defines ******************************/ - -/* -brief - a definition describing the low level Engine type ( SW, Hardware, Etc ) -*/ - +/*! CHACHA user's context size in words. */ #define CRYS_CHACHA_USER_CTX_SIZE_IN_WORDS 17 +/*! CHACHA block size in words. */ #define CRYS_CHACHA_BLOCK_SIZE_IN_WORDS 16 +/*! CHACHA block size in bytes. */ #define CRYS_CHACHA_BLOCK_SIZE_IN_BYTES (CRYS_CHACHA_BLOCK_SIZE_IN_WORDS * sizeof(uint32_t)) -/*! The max size of the nonce buffer. */ +/*! Nonce buffer max size in words. */ #define CRYS_CHACHA_NONCE_MAX_SIZE_IN_WORDS 3 +/*! Nonce buffer max size in bytes. */ #define CRYS_CHACHA_NONCE_MAX_SIZE_IN_BYTES (CRYS_CHACHA_NONCE_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) -/*! The maximum size of the CHACHA KEY in words and bytes. */ +/*! CHACHA KEY maximal size in words. */ #define CRYS_CHACHA_KEY_MAX_SIZE_IN_WORDS 8 +/*! CHACHA KEY maximal size in bytes. */ #define CRYS_CHACHA_KEY_MAX_SIZE_IN_BYTES (CRYS_CHACHA_KEY_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) /************************ Enums ********************************/ -/* Enum defining the Encrypt or Decrypt operation mode */ +/*! Enum defining the CHACHA Encrypt or Decrypt operation mode. */ typedef enum { - CRYS_CHACHA_Encrypt = 0, - CRYS_CHACHA_Decrypt = 1, + /*! CHACHA encrypt mode. */ + CRYS_CHACHA_Encrypt = 0, + /*! CHACHA decrypt mode. */ + CRYS_CHACHA_Decrypt = 1, + /*! CHACHA maximal number of operations (encrypt/decrypt). */ + CRYS_CHACHA_EncryptNumOfOptions, - CRYS_CHACHA_EncryptNumOfOptions, - - CRYS_CHACHA_EncryptModeLast = 0x7FFFFFFF, + /*! Reserved. */ + CRYS_CHACHA_EncryptModeLast = 0x7FFFFFFF, }CRYS_CHACHA_EncryptMode_t; +/*! Enum defining the CHACHA Nonce size in bits. */ typedef enum { + /*! 64 bit Nonce size. */ CRYS_CHACHA_Nonce64BitSize = 0, + /*! 96 bit Nonce size. */ CRYS_CHACHA_Nonce96BitSize = 1, - + /*! CHACHA maximal number of nonce sizes. */ CRYS_CHACHA_NonceSizeNumOfOptions, - + /*! Reserved. */ CRYS_CHACHA_NonceSizeLast = 0x7FFFFFFF, }CRYS_CHACHA_NonceSize_t; @@ -80,12 +113,14 @@ typedef uint8_t CRYS_CHACHA_Key_t[CRYS_CHACHA_KEY_MAX_SIZE_IN_BYTES]; /************************ context Structs ******************************/ -/* The user's context prototype - the argument type that is passed by the user - to the APIs called */ +/*! The user's context prototype - the argument type that is passed by the user + to the CHACHA API. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow (for example till ::CRYS_CHACHA_Free is called). */ typedef struct CRYS_CHACHAUserContext_t { - /* Allocated buffer must be double the size of actual context - * + 1 word for offset management */ - uint32_t buff[CRYS_CHACHA_USER_CTX_SIZE_IN_WORDS]; + /* Allocated buffer must be double the size of actual context + * + 1 word for offset management */ + /*! Context buffer for internal use */ + uint32_t buff[CRYS_CHACHA_USER_CTX_SIZE_IN_WORDS]; }CRYS_CHACHAUserContext_t; /************************ Public Variables **********************/ @@ -104,7 +139,7 @@ typedef struct CRYS_CHACHAUserContext_t { CIMPORT_C CRYSError_t CRYS_CHACHA_Init( CRYS_CHACHAUserContext_t *pContextID, /*!< [in] Pointer to the CHACHA context buffer that is allocated by the user and is used for the CHACHA operation. */ - CRYS_CHACHA_Nonce_t pNonce, /*!< [in] A buffer containing an nonce. */ + CRYS_CHACHA_Nonce_t pNonce, /*!< [in] A buffer containing an nonce. */ CRYS_CHACHA_NonceSize_t nonceSize, /*!< [in] Enumerator defining the nonce size (only 64 and 96 bit are valid). */ CRYS_CHACHA_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ uint32_t initialCounter, /*!< [in] An initial counter. */ @@ -167,7 +202,7 @@ CIMPORT_C CRYSError_t CRYS_CHACHA_Free( @return A non-zero value on failure as defined crys_chacha_error.h. */ CIMPORT_C CRYSError_t CRYS_CHACHA( - CRYS_CHACHA_Nonce_t pNonce, /*!< [in] A buffer containing an nonce. */ + CRYS_CHACHA_Nonce_t pNonce, /*!< [in] A buffer containing an nonce. */ CRYS_CHACHA_NonceSize_t nonceSize, /*!< [in] Enumerator defining the nonce size (only 64 and 96 bit are valid). */ CRYS_CHACHA_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ uint32_t initialCounter, /*!< [in] An initial counter. */ @@ -187,6 +222,10 @@ CIMPORT_C CRYSError_t CRYS_CHACHA( } #endif +/** +@} + */ + #endif /* #ifndef CRYS_CHACHA_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_error.h new file mode 100644 index 0000000..6be2c35 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_error.h @@ -0,0 +1,103 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_CHACHA_ERROR_H +#define CRYS_CHACHA_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS CHACHA errors. +@defgroup crys_chacha_error CryptoCell CHACHA specific errors +@{ +@ingroup crys_chacha +*/ + + + +/************************ Defines ******************************/ + +/*! The CRYS CHACHA module errors base address - 0x00F02200. */ +/*! Illegal Nonce. */ +#define CRYS_CHACHA_INVALID_NONCE_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x01UL) +/*! Illegal key size. */ +#define CRYS_CHACHA_ILLEGAL_KEY_SIZE_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal key pointer. */ +#define CRYS_CHACHA_INVALID_KEY_POINTER_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x03UL) +/*! Illegal operation mode. */ +#define CRYS_CHACHA_INVALID_ENCRYPT_MODE_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x04UL) +/*! Illegal data in pointer. */ +#define CRYS_CHACHA_DATA_IN_POINTER_INVALID_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x05UL) +/*! Illegal data out pointer. */ +#define CRYS_CHACHA_DATA_OUT_POINTER_INVALID_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x06UL) +/*! Illegal user context. */ +#define CRYS_CHACHA_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal user context size. */ +#define CRYS_CHACHA_CTX_SIZES_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x08UL) +/*! Illegal Nonce pointer. */ +#define CRYS_CHACHA_INVALID_NONCE_PTR_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x09UL) +/*! Illegal data in size. */ +#define CRYS_CHACHA_DATA_IN_SIZE_ILLEGAL (CRYS_CHACHA_MODULE_ERROR_BASE + 0x0AUL) +/*! General error. */ +#define CRYS_CHACHA_GENERAL_ERROR (CRYS_CHACHA_MODULE_ERROR_BASE + 0x0BUL) +/*! CHACHA is not supported. */ +#define CRYS_CHACHA_IS_NOT_SUPPORTED (CRYS_CHACHA_MODULE_ERROR_BASE + 0xFFUL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly.h new file mode 100644 index 0000000..a7f074a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly.h @@ -0,0 +1,95 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the + CRYS CHACHA-POLY APIs, as well as the APIs themselves. +@defgroup crys_chacha_poly CryptoCell CHACHA-POLY APIs +@{ +@ingroup cryptocell_api +*/ +#ifndef CRYS_CHACHA_POLY_H +#define CRYS_CHACHA_POLY_H + + +#include "ssi_pal_types.h" +#include "crys_error.h" +#include "crys_chacha.h" +#include "crys_poly.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/*! +@brief This function is used to perform the CHACHA-POLY encryption and authentication operation. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_chacha_poly_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_CHACHA_POLY( + CRYS_CHACHA_Nonce_t pNonce, /*!< [in] A pointer to a buffer containing the nonce value. */ + CRYS_CHACHA_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ + CRYS_CHACHA_EncryptMode_t encryptDecryptFlag, /*!< [in] A flag specifying whether the CHACHA-POLY should perform an Encrypt or + Decrypt operation. */ + uint8_t *pAddData, /*!< [in] A pointer to the buffer of the additional data to the POLY. + The pointer does not need to be aligned. must not be null. */ + size_t addDataSize, /*!< [in] The size of the input data. must not be 0. */ + uint8_t *pDataIn, /*!< [in] A pointer to the buffer of the input data to the CHACHA. + The pointer does not need to be aligned. must not be null. */ + size_t dataInSize, /*!< [in] The size of the input data. must not be 0. */ + uint8_t *pDataOut, /*!< [out] A pointer to the buffer of the output data from the CHACHA. + must not be null. */ + CRYS_POLY_Mac_t macRes /*!< [in/out] Pointer to the MAC result buffer.*/ +); + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef CRYS_CHACHA_POLY_H */ + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly_error.h new file mode 100644 index 0000000..433d071 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_chacha_poly_error.h @@ -0,0 +1,95 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_CHACHA_POLY_ERROR_H +#define CRYS_CHACHA_POLY_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS CHACHA POLY errors. +@defgroup crys_chacha_poly_error CryptoCell CHACHA POLY specific errors +@{ +@ingroup crys_chacha_poly +*/ + + + +/************************ Defines ******************************/ + +/*! The CRYS CHACHA POLY module errors base address - 0x00F02400. */ +/*! Invalid Additional data. */ +#define CRYS_CHACHA_POLY_ADATA_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x01UL) +/*! Invalid input data. */ +#define CRYS_CHACHA_POLY_DATA_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal encryption mode. */ +#define CRYS_CHACHA_POLY_ENC_MODE_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x03UL) +/*! Illegal data size. */ +#define CRYS_CHACHA_POLY_DATA_SIZE_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x04UL) +/*! Key generation error. */ +#define CRYS_CHACHA_POLY_GEN_KEY_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x05UL) +/*! CHACHA Key generation error. */ +#define CRYS_CHACHA_POLY_ENCRYPTION_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x06UL) +/*! Authentication error. */ +#define CRYS_CHACHA_POLY_AUTH_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x07UL) +/*! MAC comparison error. */ +#define CRYS_CHACHA_POLY_MAC_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x08UL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common.h similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common.h index ca7937f..74c13cf 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_common.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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. * +**************************************************************************************/ + @@ -25,7 +49,7 @@ extern "C" /************************ Defines ******************************/ -#define CRYS_AES_SECRET_KEY_SIZE_IN_WORDS 4 +#define CRYS_AES_SECRET_KEY_SIZE_IN_WORDS 4 /* the ROT13 definition - relevant only on SW low level engines compiled in the ROT mode */ #define CRYS_COMMON_ROT_13_OFFSET 13 @@ -109,8 +133,8 @@ extern "C" * @return - no return value. */ void CRYS_COMMON_InPlaceConvertBytesWordsAndArrayEndianness( - uint32_t *buf_ptr, - uint32_t sizeWords); + uint32_t *buf_ptr, + uint32_t sizeWords); /***********************************************************************/ @@ -119,16 +143,13 @@ void CRYS_COMMON_InPlaceConvertBytesWordsAndArrayEndianness( * array with words order according to little endian / * * 1. Assumed, that input bytes order is set according - * to big endianness: MS Byte is most left, i.e. order is from - * Msb to Lsb. + * to big endianness: MS Byte is most left, i.e. order is from + * Msb to Lsb. * 2. Output words array should set according to - * little endianness words order: LSWord is most left, i.e. order - * is from Lsw to Msw. Order bytes in each word - according to - * processor endianness. - * 3. Owerlapping of buffers is not allowed, besides in - * place operation and size aligned to full words. - * 4. Implementation is given for both big and little - * endianness of processor. + * little endianness words order: LSWord is most left, i.e. order + * is from Lsw to Msw. Order bytes in each word - according to + * 3. Implementation is given for both big and little + * endianness of processor. * * @param[out] out32_ptr - The 32-bits pointer to output buffer. * @param[in] sizeOutBuffBytes - The size in bytes of output buffer, must be @@ -140,55 +161,59 @@ void CRYS_COMMON_InPlaceConvertBytesWordsAndArrayEndianness( * value MODULE_* as defined in . */ CRYSError_t CRYS_COMMON_ConvertMsbLsbBytesToLswMswWords( - uint32_t *out32_ptr, - uint32_t sizeOutBuffBytes, - const uint8_t *in8_ptr, - uint32_t sizeInBytes); + uint32_t *out32_ptr, + uint32_t sizeOutBuffBytes, + const uint8_t *in8_ptr, + uint32_t sizeInBytes); /***********************************************************************/ /** * @brief This function converts LE 32bit-words array to BE bytes array. * - * 1. Assumed, that output bytes order is according - * to big endianness: MS Byte is most left, i.e. order is from - * Msb to Lsb. - * 2. Input words array should be set according to - * little endianness words order: LSWord is most left, i.e. order - * is from Lsw to Msw. Bytes order in each word - according to - * processor endianness. + * Note: The function allows output full size of the data and also output + * without leading zeros, if the user gives appropriate exact output + * size < input size. + * + * Assuming: + * 1. Output bytes order is according to big endianness: + * MS Byte is most left, i.e. order is from Msb to Lsb. + * 2. Input array words order is set according to + * little endianness words order: LSWord is most left, i.e. order + * is from Lsw to Msw. Bytes order in each word - according to + * processor endianness. * 3. Owerlapping of buffers is not allowed, besides in - * place operation and size aligned to full words. + * place operation and size aligned to full words. * 4. Implementation is given for both big and little - * endianness of processor. + * endianness of processor. * - * @param[in] out32_ptr - The 32-bits pointer to output buffer. - * @param[in] sizeOutBuffBytes - The size in bytes of output buffer, must be - * not less than sizeInBytes. - * @param[out] in8_ptr - The pointer to input buffer. - * @param[in] sizeInBytes - The size in bytes. The size must be not 0 and - * aligned to 4 bytes word. + * @param[in] out8_ptr - The bytes pointer to the output buffer. + * @param[in] sizeOutBuffBytes - The size of the data in bytes to output; must + * be not less, than sizeInBytes. + * @param[out] in32_ptr - The pointer to the input buffer. + * @param[in] sizeInpBytes - The size of the input data in bytes. The size must + * be > 0 and aligned to 4 bytes. * * @return CRYSError_t - On success CRYS_OK is returned, on failure a * value MODULE_* as defined in . */ CRYSError_t CRYS_COMMON_ConvertLswMswWordsToMsbLsbBytes( - uint8_t *out8_ptr, - uint32_t sizeOutBuffBytes, - uint32_t *in32_ptr, - uint32_t sizeInBytes); + uint8_t *out8_ptr, + uint32_t sizeOutBytes, + uint32_t *in32_ptr, + uint32_t sizeInpBytes); /***********************************************************************/ /** * @brief VOS_GetGlobalData get the global random key hidden inside the function - * the global data implemented for now are random key buffer and AES secret key buffer + * the global data implemented for now are random key buffer and AES secret key buffer * * When no_rtos is declared then we allow a global data. The random key/AES secret key are hidden as static inside the function * * - * @param[in] Globalid select the buffer - * @param[in] GlobalDataSizeWords - the global data buffer size needed in words - this value must be a predetermined value + * @param[in] Globalid select the buffer + * @param[in] GlobalDataSizeWords - the global data buffer size needed in words - this value must be a predetermined value * @param[out] GlobalData_ptr - Pointer to the global buffer returned. The buffer must be at least GlobalDataSizeWords size * * @return CRYSError_t - On success CRYS_OK is returned, on failure an Error as defined in VOS_error @@ -199,11 +224,11 @@ CRYSError_t CRYS_COMMON_GetGlobalData(uint16_t Globalid, uint32_t *GlobalData_pt /***********************************************************************/ /** * @brief CRYS_COMMON_StoreGlobalData store the global random key into the global buffer hidden inside the function -* the global data implemented for now are random key buffer and AES secret key buffer +* the global data implemented for now are random key buffer and AES secret key buffer * * -* @param[in] Globalid - random key / AES secret key -* @param[in] GlobalDataSizeWords - the global data buffer size needed in words - this value must be a predetermined value +* @param[in] Globalid - random key / AES secret key +* @param[in] GlobalDataSizeWords - the global data buffer size needed in words - this value must be a predetermined value * @param[in] GlobalData_ptr - Pointer to the global buffer to be saved. The buffer must be at least GlobalDataSizeWords size * * Return Value: @@ -296,9 +321,9 @@ CRYSError_t CRYS_COMMON_StoreGlobalData(uint16_t Globalid, uint32_t *GlobalData_ * value MODULE_* as defined in . */ void CRYS_COMMON_ConvertLswMswWordsToLsbMsbBytes( - uint8_t *out8Le, - const uint32_t *in32Le, - size_t sizeInWords); + uint8_t *out8Le, + const uint32_t *in32Le, + size_t sizeInWords); /***********************************************************************/ @@ -317,9 +342,24 @@ void CRYS_COMMON_ConvertLswMswWordsToLsbMsbBytes( * value MODULE_* as defined in . */ void CRYS_COMMON_ConvertLsbMsbBytesToLswMswWords( - uint32_t *out32Le, - const uint8_t *in8Le, - size_t sizeInBytes); + uint32_t *out32Le, + const uint8_t *in8Le, + size_t sizeInBytes); + + +/** + * The function compares value of byte vector to null. + * + * @author reuvenl (6/20/2016) + * + * @param vect - a pointer to bytes vector. + * @param sizeBytes - size of the vector. + * + * @return uint32_t - if vector's value iz zero, then returns 1, else - 0; + */ +uint32_t CRYS_COMMON_CheckIsVectorZero(uint8_t *vect, uint32_t sizeBytes); + + #ifdef __cplusplus diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common_error.h new file mode 100644 index 0000000..c8e455c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_common_error.h @@ -0,0 +1,95 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_COMMON_ERROR_H +#define CRYS_COMMON_ERROR_H + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/************************ Defines ******************************/ + +/* CRYS COMMON module errors. Base address - 0x00F00D00 */ + +#define CRYS_COMMON_INIT_HW_SEM_CREATION_FAILURE (CRYS_COMMON_MODULE_ERROR_BASE + 0x0UL) +#define CRYS_COMMON_DATA_IN_POINTER_INVALID_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x4UL) +#define CRYS_COMMON_DATA_SIZE_ILLEGAL (CRYS_COMMON_MODULE_ERROR_BASE + 0x5UL) +#define CRYS_COMMON_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x6UL) +#define CRYS_COMMON_DATA_OUT_POINTER_INVALID_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x7UL) +#define CRYS_COMMON_OUTPUT_BUFF_SIZE_ILLEGAL (CRYS_COMMON_MODULE_ERROR_BASE + 0x9UL) + +#define CRYS_COMMON_TST_UTIL_CHUNK_SIZE_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x10UL) +#define CRYS_COMMON_ERROR_IN_SAVING_LLI_DATA_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x11UL) + + +#define CRYS_COMMON_TST_UTIL_LLI_ENTRY_SIZE_TOO_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x12UL) +#define CRYS_COMMON_TST_CSI_DATA_SIZE_EXCEED_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x13UL) +#define CRYS_COMMON_TST_CSI_MODULE_ID_OUT_OF_RANGE (CRYS_COMMON_MODULE_ERROR_BASE + 0x14UL) +#define CRYS_COMMON_TST_CSI_MEMORY_MAPPING_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x15UL) + +#define CRYS_COMMON_TERM_HW_SEM_DELETE_FAILURE (CRYS_COMMON_MODULE_ERROR_BASE + 0x16UL) + +#define CRYS_COMMON_TST_UTIL_NOT_INTEGER_CHAR_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x17UL) +#define CRYS_COMMON_TST_UTIL_BUFFER_IS_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x18UL) +#define CRYS_COMMON_POINTER_NOT_ALIGNED_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x19UL) + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh.h similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh.h index eb7aa6c..d612658 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_dh.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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. * +**************************************************************************************/ + @@ -27,102 +51,137 @@ extern "C" /*! @file @brief This module defines the API that supports Diffie-Hellman key exchange, as defined in [PKCS3] and in [X9.42] (key lengths 1024 and 2048 bits). +@defgroup crys_dh CryptoCell DH APIs +@{ +@ingroup cryptocell_api */ /************************ Defines ******************************/ - +/*! Defintion for DH public key.*/ #define CRYS_DHPubKey_t CRYSRSAPubKey_t +/*! Maximal valid key size in bits.*/ #define CRYS_DH_MAX_VALID_KEY_SIZE_VALUE_IN_BITS CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS /*!< \internal RL restrict to 2048 */ - +/*! Minimal valid key size in bits.*/ #define CRYS_DH_MIN_VALID_KEY_SIZE_VALUE_IN_BITS 1024 /*!< Size limitation according to ANSI standard */ - -#define CRYS_DH_MAX_MOD_SIZE_IN_BYTES (CRYS_DH_MAX_VALID_KEY_SIZE_VALUE_IN_BITS / 8) +/*! Maximal modulus size in bytes.*/ +#define CRYS_DH_MAX_MOD_SIZE_IN_BYTES (CRYS_DH_MAX_VALID_KEY_SIZE_VALUE_IN_BITS / SASI_BITS_IN_BYTE) +/*! Maximal modulus size in words.*/ #define CRYS_DH_MAX_MOD_SIZE_IN_WORDS (CRYS_DH_MAX_MOD_SIZE_IN_BYTES/sizeof(uint32_t)) +/*! Modulus buffer size in words.*/ #define CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS (CRYS_DH_MAX_MOD_SIZE_IN_WORDS + 2) +/*! Maximal domain generation size in bits.*/ #define CRYS_DH_DOMAIN_GENERATION_MAX_SIZE_BITS CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS /*!< \internal RL restrict to 2048 */ -/* The following defines are for the readability of the user */ +/*! Defintion for DH primitives data.*/ #define CRYS_DHPrimeData_t CRYS_RSAPrimeData_t +/*! Defintion for DH public key.*/ #define CRYS_DHUserPubKey_t CRYS_RSAUserPubKey_t +/*! Defintion for DH other info.*/ #define CRYS_DH_OtherInfo_t CRYS_KDF_OtherInfo_t -#define CRYS_DH_COUNT_OF_OTHER_INFO_ENTRIES CRYS_KDF_COUNT_OF_OTHER_INFO_ENTRIES -#define CRYS_DH_MAX_SIZE_OF_OTHER_INFO_ENTRY CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY /*!< Size is in bytes */ -#define CRYS_DH_MAX_SIZE_OF_KEYING_DATA CRYS_KDF_MAX_SIZE_OF_KEYING_DATA /*!< Size is in bytes*/ + +/*! Keying data size is in bytes*/ +#define CRYS_DH_MAX_SIZE_OF_KEYING_DATA CRYS_KDF_MAX_SIZE_OF_KEYING_DATA /************************ Enums ********************************/ -/* DH operations mode (used in some functions of DH) */ +/*! DH operations mode */ typedef enum { - CRYS_DH_PKCS3_mode = 0, - CRYS_DH_ANSI_X942_mode = 1, - CRYS_DH_NumOfModes, + /*! PKCS3 operation mode. */ + CRYS_DH_PKCS3_mode = 0, + /*! ANSI X942 operation mode. */ + CRYS_DH_ANSI_X942_mode = 1, + /*! Total number of operation modes. */ + CRYS_DH_NumOfModes, - CRYS_DH_OpModeLast = 0x7FFFFFFF, + /*! Reserved. */ + CRYS_DH_OpModeLast = 0x7FFFFFFF, }CRYS_DH_OpMode_t; -/* HASH operation modes, used in DH */ +/*! HASH operation modes */ typedef enum { - CRYS_DH_HASH_SHA1_mode = CRYS_HASH_SHA1_mode, - CRYS_DH_HASH_SHA224_mode = CRYS_HASH_SHA224_mode, - CRYS_DH_HASH_SHA256_mode = CRYS_HASH_SHA256_mode, - CRYS_DH_HASH_SHA384_mode = CRYS_HASH_SHA384_mode, - CRYS_DH_HASH_SHA512_mode = CRYS_HASH_SHA512_mode, - CRYS_DH_HASH_MD5_mode = CRYS_HASH_MD5_mode, /*!< \internal not used in DH */ - - CRYS_DH_HASH_NumOfModes = CRYS_HASH_MD5_mode, - CRYS_DH_HASH_OperationModeLast = 0x7FFFFFFF, + /*! SHA1 operation mode. */ + CRYS_DH_HASH_SHA1_mode = CRYS_HASH_SHA1_mode, + /*! SHA224 operation mode. */ + CRYS_DH_HASH_SHA224_mode = CRYS_HASH_SHA224_mode, + /*! SHA256 operation mode. */ + CRYS_DH_HASH_SHA256_mode = CRYS_HASH_SHA256_mode, + /*! SHA384 operation mode. */ + CRYS_DH_HASH_SHA384_mode = CRYS_HASH_SHA384_mode, + /*! SHA512 operation mode. */ + CRYS_DH_HASH_SHA512_mode = CRYS_HASH_SHA512_mode, + /*! MD5 operation mode (not used in DH). */ + CRYS_DH_HASH_MD5_mode = CRYS_HASH_MD5_mode, /*!< \internal not used in DH */ + /*! Total number of HASH modes. */ + CRYS_DH_HASH_NumOfModes = CRYS_HASH_MD5_mode, + /*! Reserved. */ + CRYS_DH_HASH_OperationModeLast = 0x7FFFFFFF, }CRYS_DH_HASH_OpMode_t; -/* key derivation modes, used in DH */ +/*! Key derivation modes. */ typedef enum { - CRYS_DH_ASN1_Der_mode = CRYS_KDF_ASN1_DerivMode, - CRYS_DH_Concat_Der_mode = CRYS_KDF_ConcatDerivMode, - CRYS_DH_X963_DerMode = CRYS_KDF_ConcatDerivMode, - - CRYS_DH_DerivationFunc_ModeLast= 0x7FFFFFFF, + /*! ASN1 derivation mode.*/ + CRYS_DH_ASN1_Der_mode = CRYS_KDF_ASN1_DerivMode, + /*! Concatination derivation mode.*/ + CRYS_DH_Concat_Der_mode = CRYS_KDF_ConcatDerivMode, + /*! X963 derivation mode.*/ + CRYS_DH_X963_DerMode = CRYS_KDF_ConcatDerivMode, + /*! Reserved. */ + CRYS_DH_DerivationFunc_ModeLast= 0x7FFFFFFF, }CRYS_DH_DerivationFunc_Mode; /************************ Typedefs *************************************/ -/* temp buffer structure used for exponentiation in DH functions */ +/*! Temporary buffer structure for internal usage.*/ typedef struct { - CRYS_DHPrimeData_t PrimeData; - CRYS_DHPubKey_t PubKey; - uint32_t TempBuff[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary primitives data */ + CRYS_DHPrimeData_t PrimeData; + /*! Public key. */ + CRYS_DHPubKey_t PubKey; + /*! Temporary buffer for internal usage. */ + uint32_t TempBuff[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; } CRYS_DH_ExpTemp_t; -/* temp buffer structure used for DH functions (non hybrid) */ +/*! Temporary buffer structure for internal usage. */ typedef struct { - CRYS_DHPrimeData_t PrimeData; - CRYS_DHUserPubKey_t UserPubKey; - uint32_t TempBuff[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary primitives data */ + CRYS_DHPrimeData_t PrimeData; + /*! User's public key. */ + CRYS_DHUserPubKey_t UserPubKey; + /*! Temporary buffer for internal usage. */ + uint32_t TempBuff[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; } CRYS_DH_Temp_t; -/* temp buffer structure used for DH hybrid functions */ +/*! Temporary buffer structure for internal usage. */ typedef struct { - CRYS_DHPrimeData_t PrimeData; - CRYS_DHUserPubKey_t UserPubKey; - uint32_t TempBuff[2*CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary primitives data */ + CRYS_DHPrimeData_t PrimeData; + /*! User's public key. */ + CRYS_DHUserPubKey_t UserPubKey; + /*! Temporary buffer for internal usage. */ + uint32_t TempBuff[2*CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; } CRYS_DH_HybrTemp_t; -/* Buffer used for FIPS KAT */ +/*! Defintion of buffer used for FIPS Known Answer Tests. */ typedef struct { - CRYS_DHUserPubKey_t pubKey; - CRYS_DHPrimeData_t primeData; - uint8_t secretBuff[CRYS_DH_MIN_VALID_KEY_SIZE_VALUE_IN_BITS/SASI_BITS_IN_BYTE]; // KAT tests uses 1024 bit key + /*! Public key. */ + CRYS_DHUserPubKey_t pubKey; + /*! Temporary primitives data */ + CRYS_DHPrimeData_t primeData; + /*! Buffer for the secret value.*/ + uint8_t secretBuff[CRYS_DH_MIN_VALID_KEY_SIZE_VALUE_IN_BITS/SASI_BITS_IN_BYTE]; // KAT tests uses 1024 bit key } CRYS_DH_FipsKat_t; @@ -137,33 +196,34 @@ typedef struct /*! @brief This function has two purposes:
      1. Randomly generate the client private key according to the choosen version [PKCS3] or [ANSI X9.42].
      2. -
      3. Computes the client public key as follows: ClientPub = Generator^Prv mod Prime, where '^' is the symbol of exponentiation.
      +
    • Computes the client public key as follows: ClientPub = Generator^Prv mod Prime, where '^' is the symbol of exponentiation.
    • This function should not be called directly. Instead, use the macros ::CRYS_DH_PKCS3_GeneratePubPrv and ::CRYS_DH_ANSI_X942_GeneratePubPrv. \note All buffer parameters should be in Big-Endian form. @return CRYS_OK on success. -@return A non-zero value on failure as defined crys_dh_error.h +@return A non-zero value on failure as defined crys_dh_error.h, crys_rnd_error.h or crys_rsa_error.h. */ CIMPORT_C CRYSError_t _DX_DH_GeneratePubPrv( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ uint8_t *Generator_ptr, /*!< [in] Pointer to the Generator octet string. */ uint16_t GeneratorSize, /*!< [in] The size of the Generator string (in bytes). */ uint8_t *Prime_ptr, /*!< [in] Pointer to the Prime octet string P (used as modulus in the algorithm). */ uint16_t PrimeSize, /*!< [in] The size of the Prime string in bytes. */ uint16_t L, /*!< [in] Exact size in bits of the Prime to be generated (relevant only for [PKCS3]):
      • If L!=0, force the private key to be [2^(L-1) ? Prv < 2^L], where '^' - indicates exponentiation.
      • + indicates exponentiation.
      • If L = 0 then [0 < Prv < P-1].
      */ uint8_t *Q_ptr, /*!< [in] Relevant only for [ANSI X9.42] - Pointer to the Q octet string in the range: 1 <= Prv <= Q-1 or 1 < Prv < Q-1. */ uint16_t QSize, /*!< [in] Relevant only for [ANSI X9.42] - Size of the Q string (in bytes). */ CRYS_DH_OpMode_t DH_mode, /*!< [in] An enumerator declaring whether this is [PKCS3] or [ANSI X9.42] mode. */ CRYS_DHUserPubKey_t *tmpPubKey_ptr, /*!< [in] Pointer to a temporary buffer for public key structure. Used for the - exponentiation function. */ + exponentiation function. */ CRYS_DHPrimeData_t *tmpPrimeData_ptr, /*!< [in] Pointer to a structure holding internal temporary buffers. */ uint8_t *ClientPrvKey_ptr, /*!< [out] Pointer to the Private key Prv. This buffer should be at least the following - size (in bytes): + size (in bytes):
      • If L is provided: (L+7)/8.
      • If L is NULL: \p PrimeSize.
      */ uint16_t *ClientPrvKeySize_ptr, /*!< [in/out] Pointer to the Private key size: @@ -181,37 +241,37 @@ CIMPORT_C CRYSError_t _DX_DH_GeneratePubPrv( /*! This macro is used to generate the public and private DH keys according to [PKCS3]. For a description of the parameters see ::_DX_DH_GeneratePubPrv. */ -#define CRYS_DH_PKCS3_GeneratePubPrv(rndContext_ptr, Generator_ptr,GeneratorSize,\ - Prime_ptr,PrimeSize,\ - L,\ - tmpPubKey_ptr,tmpPrimeData_ptr,\ - ClientPrvKey_ptr,ClientPrvKeySize_ptr,\ - ClientPub_ptr,ClientPubSize_ptr)\ - _DX_DH_GeneratePubPrv(rndContext_ptr, (Generator_ptr),(GeneratorSize),\ - (Prime_ptr),(PrimeSize),\ - (L),\ - (uint8_t *)NULL,(uint16_t)0,\ - CRYS_DH_PKCS3_mode,\ - (tmpPubKey_ptr),(tmpPrimeData_ptr),\ - (ClientPrvKey_ptr),(ClientPrvKeySize_ptr),\ - (ClientPub_ptr),(ClientPubSize_ptr)) +#define CRYS_DH_PKCS3_GeneratePubPrv(rndState_ptr, rndGenerateVectFunc, Generator_ptr,GeneratorSize,\ + Prime_ptr,PrimeSize,\ + L,\ + tmpPubKey_ptr,tmpPrimeData_ptr,\ + ClientPrvKey_ptr,ClientPrvKeySize_ptr,\ + ClientPub_ptr,ClientPubSize_ptr)\ + _DX_DH_GeneratePubPrv(rndState_ptr, rndGenerateVectFunc, (Generator_ptr),(GeneratorSize),\ + (Prime_ptr),(PrimeSize),\ + (L),\ + (uint8_t *)NULL,(uint16_t)0,\ + CRYS_DH_PKCS3_mode,\ + (tmpPubKey_ptr),(tmpPrimeData_ptr),\ + (ClientPrvKey_ptr),(ClientPrvKeySize_ptr),\ + (ClientPub_ptr),(ClientPubSize_ptr)) /*! This macro is used to generate the public and private DH keys according to [ANSI X9.42]. For a description of the parameters see ::_DX_DH_GeneratePubPrv. */ -#define CRYS_DH_ANSI_X942_GeneratePubPrv(rndContext_ptr, Generator_ptr,GeneratorSize,Prime_ptr,PrimeSize,\ - Q_ptr,QSize,\ - tmpPubKey_ptr,tmpPrimeData_ptr,\ - ClientPrvKey_ptr,ClientPrvKeySize_ptr,\ - ClientPub_ptr,ClientPubSize_ptr)\ - _DX_DH_GeneratePubPrv(rndContext_ptr, (Generator_ptr),(GeneratorSize),\ - (Prime_ptr),(PrimeSize),\ - (uint16_t)0,\ - (Q_ptr),(QSize),\ - CRYS_DH_ANSI_X942_mode,\ - (tmpPubKey_ptr),(tmpPrimeData_ptr),\ - (ClientPrvKey_ptr),(ClientPrvKeySize_ptr),\ - (ClientPub_ptr),(ClientPubSize_ptr)) +#define CRYS_DH_ANSI_X942_GeneratePubPrv(rndState_ptr, rndGenerateVectFunc, Generator_ptr,GeneratorSize,Prime_ptr,PrimeSize,\ + Q_ptr,QSize,\ + tmpPubKey_ptr,tmpPrimeData_ptr,\ + ClientPrvKey_ptr,ClientPrvKeySize_ptr,\ + ClientPub_ptr,ClientPubSize_ptr)\ + _DX_DH_GeneratePubPrv(rndState_ptr, rndGenerateVectFunc, (Generator_ptr),(GeneratorSize),\ + (Prime_ptr),(PrimeSize),\ + (uint16_t)0,\ + (Q_ptr),(QSize),\ + CRYS_DH_ANSI_X942_mode,\ + (tmpPubKey_ptr),(tmpPrimeData_ptr),\ + (ClientPrvKey_ptr),(ClientPrvKeySize_ptr),\ + (ClientPub_ptr),(ClientPubSize_ptr)) /*******************************************************************************************/ @@ -225,24 +285,24 @@ described in [ANSI X9.42] paragraph 7.4. size of the Prime (modulus in bits).
    @return CRYS_OK on success. -@return A non-zero value on failure as defined in crys_dh_error.h. +@return A non-zero value on failure as defined in crys_dh_error.h or crys_rsa_error.h. */ CIMPORT_C CRYSError_t CRYS_DH_GetSecretKey( - uint8_t *ClientPrvKey_ptr, /*!< [in] Pointer to the Private key octet string Prv < Prime. */ - uint16_t ClientPrvKeySize, /*!< [in] The Private key Size (in bytes). */ - uint8_t *ServerPubKey_ptr, /*!< [in] Pointer to the Server public key octet string. */ - uint16_t ServerPubKeySize, /*!< [in] The Server Public key Size (in bytes). */ - uint8_t *Prime_ptr, /*!< [in] Pointer to the Prime octet string. */ - uint16_t PrimeSize, /*!< [in] The size of the Prime string. */ - CRYS_DHUserPubKey_t *tmpPubKey_ptr, /*!< [in] Pointer to the public key structure. Used for the exponentiation - operation function. Need not be initialized. */ - CRYS_DHPrimeData_t *tmpPrimeData_ptr, /*!< [in] Pointer to a structure containing internal temp buffers. */ - uint8_t *SecretKey_ptr, /*!< [out] Pointer to the secret key octet string. This buffer should be at - least PrimeSize bytes. */ - uint16_t *SecretKeySize_ptr /*!< [in/out] Pointer to the secret key Buffer Size. This buffer should be at - least of PrimeSize bytes: -
    • Input - size of the given buffer.
    • -
    • Output - actual size.
    */ + uint8_t *ClientPrvKey_ptr, /*!< [in] Pointer to the Private key octet string Prv < Prime. */ + uint16_t ClientPrvKeySize, /*!< [in] The Private key Size (in bytes). */ + uint8_t *ServerPubKey_ptr, /*!< [in] Pointer to the Server public key octet string. */ + uint16_t ServerPubKeySize, /*!< [in] The Server Public key Size (in bytes). */ + uint8_t *Prime_ptr, /*!< [in] Pointer to the Prime octet string. */ + uint16_t PrimeSize, /*!< [in] The size of the Prime string. */ + CRYS_DHUserPubKey_t *tmpPubKey_ptr, /*!< [in] Pointer to the public key structure. Used for the exponentiation + operation function. Need not be initialized. */ + CRYS_DHPrimeData_t *tmpPrimeData_ptr, /*!< [in] Pointer to a structure containing internal temp buffers. */ + uint8_t *SecretKey_ptr, /*!< [out] Pointer to the secret key octet string. This buffer should be at + least PrimeSize bytes. */ + uint16_t *SecretKeySize_ptr /*!< [in/out] Pointer to the secret key Buffer Size. This buffer should be at + least of PrimeSize bytes: +
    • Input - size of the given buffer.
    • +
    • Output - actual size.
    */ ); @@ -259,28 +319,28 @@ the other derivation modes.
  • All buffers arguments are represented in Big-Endian form.
@return CRYS_OK on success. -@return A non-zero value on failure as defined in crys_dh_error.h. +@return A non-zero value on failure as defined in crys_dh_error.h, crys_rsa_error.h, crys_kdf_error.h or crys_hash_error.h. */ CIMPORT_C CRYSError_t CRYS_DH_X942_GetSecretData( uint8_t *ClientPrvKey_ptr, /*!< [in] Pointer to the Private key octet string. */ uint16_t ClientPrvKeySize, /*!< [in] The Private key size (in bytes). */ uint8_t *ServerPubKey_ptr, /*!< [in] Pointer to the Server public key octet string. */ - uint16_t ServerPubKeySize, /*!< [in] The Server Public key size (in bytes). */ + uint16_t ServerPubKeySize, /*!< [in] The Server Public key size (in bytes). */ uint8_t *Prime_ptr, /*!< [in] Pointer to the Prime octet string. */ uint16_t PrimeSize, /*!< [in] The size of the Prime string. */ CRYS_DH_OtherInfo_t *otherInfo_ptr, /*!< [in] Pointer to structure containing other data, shared by two entities - sharing the secret keying data. + sharing the secret keying data. The Maximal size of each data entry of "other info" is limited - see crys_kdf.h - for the defined value. */ + for the defined value. */ CRYS_DH_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes. The supported modes are according to the supported - HASH modes for the product (and MD5 is not supported). */ + HASH modes for the product (and MD5 is not supported). */ CRYS_DH_DerivationFunc_Mode DerivFunc_mode, /*!< [in] The enumerator ID of key derivation function mode. ASN1 or Concatenation - modes are supported. */ + modes are supported. */ CRYS_DH_Temp_t *tmpBuff_ptr, /*!< [in] A pointer to the DH temp buffer structure. Not initialized. */ uint8_t *SecretKeyingData_ptr, /*!< [out] Pointer to the secret key octet string. This buffer should be at least - PrimeSize bytes. */ + PrimeSize bytes. */ uint16_t SecretKeyingDataSize /*!< [in] The required Secret Keying data size (in bytes). Must be larger than 0, - and smaller than the maximal - CRYS_DH_MAX_SIZE_OF_KEYING_DATA. */ + and smaller than the maximal - CRYS_DH_MAX_SIZE_OF_KEYING_DATA. */ ); /****************************************************************/ @@ -288,12 +348,12 @@ the other derivation modes. This macro implements the DH [ANSI X9.42] standard. It derives a secret key using the Derivation function based on ASN.1. For a description of the parameters see ::CRYS_DH_X942_GetSecretData.*/ #define CRYS_DH_X942_GetSecretDataAsn1(ClientPrvKey_ptr,ClientPrvKeySize,ServerPubKey_ptr,ServerPubKeySize,Prime_ptr,PrimeSize,otherInfo_ptr,hashMode,tmpBuff_ptr,SecretKeyingData_ptr,SecretKeyingDataSize)\ - CRYS_DH_X942_GetSecretData((ClientPrvKey_ptr),(ClientPrvKeySize),(ServerPubKey_ptr),(ServerPubKeySize),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashMode),(CRYS_DH_ASN1_Der_mode),(tmpBuff_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) + CRYS_DH_X942_GetSecretData((ClientPrvKey_ptr),(ClientPrvKeySize),(ServerPubKey_ptr),(ServerPubKeySize),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashMode),(CRYS_DH_ASN1_Der_mode),(tmpBuff_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) /*! This macro implements the DH [ANSI X9.42] standard. It derives a secret key using the Derivation function based on concatenation of HASHed data. For a description of the parameters see ::CRYS_DH_X942_GetSecretData.*/ #define CRYS_DH_X942_GetSecretDataConcat(ClientPrvKey_ptr,ClientPrvKeySize,ServerPubKey_ptr,ServerPubKeySize,Prime_ptr,PrimeSize,otherInfo_ptr,hashMode,tmpBuff_ptr,SecretKeyingData_ptr,SecretKeyingDataSize)\ - CRYS_DH_X942_GetSecretData((ClientPrvKey_ptr),(ClientPrvKeySize),(ServerPubKey_ptr),(ServerPubKeySize),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashMode),(CRYS_DH_Concat_Der_mode),(tmpBuff_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) + CRYS_DH_X942_GetSecretData((ClientPrvKey_ptr),(ClientPrvKeySize),(ServerPubKey_ptr),(ServerPubKeySize),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashMode),(CRYS_DH_Concat_Der_mode),(tmpBuff_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) /****************************************************************/ @@ -313,13 +373,13 @@ If used, all entries of the structure should be initialized with relevant data a
  • All buffers arguments are represented in Big-Endian form.
  • @return CRYS_OK on success. -@return A non-zero value on failure as defined in crys_dh_error.h or crys_kdf_error.h. +@return A non-zero value on failure as defined in crys_dh_error.h, crys_rsa_error.h or crys_hash_error.h. */ CIMPORT_C CRYSError_t CRYS_DH_X942_HybridGetSecretData( uint8_t *ClientPrvKey_ptr1, /*!< [in] Pointer to the First Private key octet string number. */ uint16_t ClientPrvKeySize1, /*!< [in] The First Private key Size (in bytes). */ uint8_t *ClientPrvKey_ptr2, /*!< [in] Pointer to the Second Private key octet string. */ - uint16_t ClientPrvKeySize2, /*!< [in] The Second Private key Size (in bytes). */ + uint16_t ClientPrvKeySize2, /*!< [in] The Second Private key Size (in bytes). */ uint8_t *ServerPubKey_ptr1, /*!< [in] Pointer to the First Server public key octet string. */ uint16_t ServerPubKeySize1, /*!< [in] The First Server Public key Size (in bytes). */ uint8_t *ServerPubKey_ptr2, /*!< [in] Pointer to the Second Server public key octet string. */ @@ -327,17 +387,17 @@ CIMPORT_C CRYSError_t CRYS_DH_X942_HybridGetSecretData( uint8_t *Prime_ptr, /*!< [in] Pointer to the Prime octet string. */ uint16_t PrimeSize, /*!< [in] The size of the Prime string. */ CRYS_DH_OtherInfo_t *otherInfo_ptr, /*!< [in] Pointer to structure containing optional other data, shared by two entities - sharing the secret keying data. */ + sharing the secret keying data. */ CRYS_DH_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes. The supported modes are according to the supported - HASH modes for the product (and MD5 is not supported). */ + HASH modes for the product (and MD5 is not supported). */ CRYS_DH_DerivationFunc_Mode DerivFunc_mode, /*!< [in] The type of function to use to derive the secret key to the key data. - ASN.1 or Concatenation modes are supported. */ + ASN.1 or Concatenation modes are supported. */ CRYS_DH_HybrTemp_t *tmpDhHybr_ptr, /*!< [in] Pointer to a CRYS_DH_Temp_t structure that contains temp buffers for - internal operations. */ + internal operations. */ uint8_t *SecretKeyingData_ptr, /*!< [out] Pointer to the secret key octet string. This buffer should be at least - of size PrimeSize bytes. */ + of size PrimeSize bytes. */ uint16_t SecretKeyingDataSize /*!< [in] The required Secret Keying data size (in bytes). Must be larger than 0, - and smaller than CRYS_DH_MAX_SIZE_OF_KEYING_DATA. */ + and smaller than CRYS_DH_MAX_SIZE_OF_KEYING_DATA. */ ); @@ -346,14 +406,14 @@ CIMPORT_C CRYSError_t CRYS_DH_X942_HybridGetSecretData( This macro implements the DH [X9.42] standard deriving a hybrid secret key from two public-private pair of keys using the Derivation function based on ASN.1. For a description of the parameters see ::CRYS_DH_X942_HybridGetSecretData.*/ #define CRYS_DH_X942_HybridGetSecretDataAsn1(ClientPrvKey_ptr1,ClientPrvKeySize1,ClientPrvKey_ptr2,ClientPrvKeySize2,ServerPubKey_ptr1,ServerPubKeySize1,ServerPubKey_ptr2,ServerPubKeySize2,Prime_ptr,PrimeSize,otherInfo_ptr,hashFunc,tmpDhHybr_ptr,SecretKeyingData_ptr,SecretKeyingDataSize)\ - CRYS_DH_X942_HybridGetSecretData((ClientPrvKey_ptr1),(ClientPrvKeySize1),(ClientPrvKey_ptr2),(ClientPrvKeySize2),(ServerPubKey_ptr1),(ServerPubKeySize1),(ServerPubKey_ptr2),(ServerPubKeySize2),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashFunc),CRYS_DH_ASN1_Der_mode,(tmpDhHybr_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) + CRYS_DH_X942_HybridGetSecretData((ClientPrvKey_ptr1),(ClientPrvKeySize1),(ClientPrvKey_ptr2),(ClientPrvKeySize2),(ServerPubKey_ptr1),(ServerPubKeySize1),(ServerPubKey_ptr2),(ServerPubKeySize2),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashFunc),CRYS_DH_ASN1_Der_mode,(tmpDhHybr_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) /*! This macro implements the DH [X9.42] standard, deriving a hybrid secret key from two pairs of public-private keys, using the Derivation function based on concatenation using SHA-x HASH. For a description of the parameters see ::CRYS_DH_X942_HybridGetSecretData. */ #define CRYS_DH_X942_HybridGetSecretDataConcat(ClientPrvKey_ptr1,ClientPrvKeySize1,ClientPrvKey_ptr2,ClientPrvKeySize2,ServerPubKey_ptr1,ServerPubKeySize1,ServerPubKey_ptr2,ServerPubKeySize2,Prime_ptr,PrimeSize,otherInfo_ptr,hashFunc,tmpDhHybr_ptr,SecretKeyingData_ptr,SecretKeyingDataSize)\ - CRYS_DH_X942_HybridGetSecretData((ClientPrvKey_ptr1),(ClientPrvKeySize1),(ClientPrvKey_ptr2),(ClientPrvKeySize2),(ServerPubKey_ptr1),(ServerPubKeySize1),(ServerPubKey_ptr2),(ServerPubKeySize2),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashFunc),CRYS_DH_Concat_Der_mode,(tmpDhHybr_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) + CRYS_DH_X942_HybridGetSecretData((ClientPrvKey_ptr1),(ClientPrvKeySize1),(ClientPrvKey_ptr2),(ClientPrvKeySize2),(ServerPubKey_ptr1),(ServerPubKeySize1),(ServerPubKey_ptr2),(ServerPubKeySize2),(Prime_ptr),(PrimeSize),(otherInfo_ptr),(hashFunc),CRYS_DH_Concat_Der_mode,(tmpDhHybr_ptr),(SecretKeyingData_ptr),(SecretKeyingDataSize)) /******************************************************************************************/ @@ -367,18 +427,20 @@ Assuming: The DH domain parameters are valid. @return A non-zero value on failure as defined in crys_dh_error.h. */ CIMPORT_C CRYSError_t CRYS_DH_CheckPubKey( - uint8_t *modP_ptr, /*!< [in] The pointer to the modulus (prime) P. */ - uint32_t modPsizeBytes, /*!< [in] The modulus size in bytes. */ - uint8_t *orderQ_ptr, /*!< [in] The pointer to the prime order Q of generator. */ - uint32_t orderQsizeBytes, /*!< [in] The size of order of generator in bytes. */ - uint8_t *pubKey_ptr, /*!< [in] The pointer to the public key to be validated. */ - uint32_t pubKeySizeBytes, /*!< [in] The public key size in bytes. */ - CRYS_DH_Temp_t *tempBuff_ptr /*!< [in] The temp buffer for internal calculations. */ + uint8_t *modP_ptr, /*!< [in] The pointer to the modulus (prime) P. */ + uint32_t modPsizeBytes, /*!< [in] The modulus size in bytes. */ + uint8_t *orderQ_ptr, /*!< [in] The pointer to the prime order Q of generator. */ + uint32_t orderQsizeBytes, /*!< [in] The size of order of generator in bytes. */ + uint8_t *pubKey_ptr, /*!< [in] The pointer to the public key to be validated. */ + uint32_t pubKeySizeBytes, /*!< [in] The public key size in bytes. */ + CRYS_DH_Temp_t *tempBuff_ptr /*!< [in] The temp buffer for internal calculations. */ ); #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_error.h new file mode 100644 index 0000000..15258a2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_error.h @@ -0,0 +1,158 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_DH_ERROR_H +#define CRYS_DH_ERROR_H + + +#include "crys_error.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains error codes definitions for CRYS DH module. +@defgroup crys_dh_error CryptoCell DH specific errors +@{ +@ingroup crys_dh +*/ +/************************ Defines ******************************/ +/* DH module on the CRYS layer base address - 0x00F00500 */ +/*! The CRYS DH module errors */ +/*! Illegal input pointer.*/ +#define CRYS_DH_INVALID_ARGUMENT_POINTER_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x0UL) +/*! Illegal input size.*/ +#define CRYS_DH_INVALID_ARGUMENT_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x1UL) +/*! Illegal operation mode.*/ +#define CRYS_DH_INVALID_ARGUMENT_OPERATION_MODE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal hash mode.*/ +#define CRYS_DH_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x3UL) + +/*! Illegal secret key data size. */ +#define CRYS_DH_SECRET_KEYING_DATA_SIZE_ILLEGAL_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal L input. */ +#define CRYS_DH_INVALID_L_ARGUMENT_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x5UL) +/*! Prime is smaller than generator. */ +#define CRYS_DH_ARGUMENT_PRIME_SMALLER_THAN_GENERATOR_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x6UL) +/*! Generator is smaller than zero. */ +#define CRYS_DH_ARGUMENT_GENERATOR_SMALLER_THAN_ZERO_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x7UL) +/*! Illegal private key size. */ +#define CRYS_DH_ARGUMENT_PRV_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x8UL) +/*! Illegal buffer size. */ +#define CRYS_DH_ARGUMENT_BUFFER_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x9UL) +/*! Invalid shared secret value. */ +#define CRYS_DH_INVALID_SHARED_SECRET_VALUE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0xAUL) +/*! DH is not supported. */ +#define CRYS_DH_IS_NOT_SUPPORTED (CRYS_DH_MODULE_ERROR_BASE + 0xFUL) +/*! Illegal X942 hybrid buffer size.*/ +#define CRYS_DH_X942_HYBRID_SIZE1_BUFFER_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x15UL) + +/*The requested derived secret key size is invalid*/ +/*! Illegal secret key size .*/ +#define CRYS_DH_SECRET_KEY_SIZE_NEEDED_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x16UL) +/*! Illegal output secret key size .*/ +#define CRYS_DH_SECRET_KEY_SIZE_OUTPUT_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x17UL) +/*! Illegal otherInfo size .*/ +#define CRYS_DH_OTHERINFO_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x18UL) + +/* DH domain and key generation and checking errors */ +/*! Illegal modulus size. */ +#define CRYS_DH_INVALID_MODULUS_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x20UL) +/*! Illegal order size. */ +#define CRYS_DH_INVALID_ORDER_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x21UL) +/*! Illegal seed size. */ +#define CRYS_DH_INVALID_SEED_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x22UL) +/*! Illegal J factor pointer size. */ +#define CRYS_DH_INVALID_J_FACTOR_PTR_OR_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x23UL) +/*! Illegal generator pointer or size. */ +#define CRYS_DH_INVALID_GENERATOR_PTR_OR_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x24UL) + +/*! Illegal domain primes. */ +#define CRYS_DH_CHECK_DOMAIN_PRIMES_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x25UL) +/*! Illegal domain generator. */ +#define CRYS_DH_CHECK_DOMAIN_GENERATOR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x26UL) +/*! Illegal public key size. */ +#define CRYS_DH_INVALID_PUBLIC_KEY_SIZE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x27UL) +/*! Illegal public key. */ +#define CRYS_DH_CHECK_PUB_KEY_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x28UL) +/*! Illegal generator size or pointer. */ +#define CRYS_DH_CHECK_GENERATOR_SIZE_OR_PTR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x29UL) +/*! Illegal seed size or pointer. */ +#define CRYS_DH_CHECK_SEED_SIZE_OR_PTR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2AUL) +/*! Illegal generator. */ +#define CRYS_DH_CHECK_GENERATOR_NOT_VALID_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2BUL) +/*! Prime generation failed. */ +#define CRYS_DH_PRIME_P_GENERATION_FAILURE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2CUL) +/*! Illegal public key. */ +#define CRYS_DH_INVALID_PUBLIC_KEY_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2DUL) +/*! Illegal seed. */ +#define CRYS_DH_PASSED_INVALID_SEED_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2EUL) +/*! Prime generation failed. */ +#define CRYS_DH_PRIME_Q_GENERATION_FAILURE_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x2FUL) +/*! Internal PKI error */ +#define CRYS_DH_PKI_INTERNAL_ERROR (CRYS_DH_MODULE_ERROR_BASE + 0x30UL) + + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_kg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_kg.h new file mode 100644 index 0000000..961d1a0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_dh_kg.h @@ -0,0 +1,203 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _CRYS_DH_KG_H +#define _CRYS_DH_KG_H + + +#include "crys_dh.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! @file +@brief This module defines the API that supports Diffie-Hellman domain. +@defgroup crys_dh_kg CryptoCell DH Key Generation APIs +@{ +@ingroup crys_dh +*/ + +/************************ Defines ******************************/ +/*! Minimal size of DH seed in bytes. */ +#define CRYS_DH_SEED_MIN_SIZE_IN_BYTES CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES +/*! Minimal size of DH seed in bits. */ +#define CRYS_DH_SEED_MIN_SIZE_IN_BITS (CRYS_DH_SEED_MIN_SIZE_IN_BYTES * 8) + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + +/* temp buffers, used in different DH KG functions */ + +/*! Temporary data buffer structure for domain parameters generation in DH. */ +typedef struct CRYS_DHKGData_t +{ + /* The aligned input and output temp buffers */ + /*! Temporary buffer. */ + uint32_t TempBuff1[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + uint32_t TempBuff2[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + uint32_t TempBuff3[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + uint32_t TempBuff4[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + uint32_t TempBuff5[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + uint32_t TempBuff6[CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + CRYS_DH_Temp_t ExpTemps; +}CRYS_DHKGData_t; + +/*! Temporary buffer structure . */ +typedef struct CRYS_DHKG_CheckTemp_t +{ + /*! Temporary buffer. */ + uint32_t CheckTempBuff[3*CRYS_DH_MAX_MOD_BUFFER_SIZE_IN_WORDS]; + /*! Temporary buffer. */ + CRYS_DHKGData_t DhKgBuff; +}CRYS_DHKG_CheckTemp_t; + +/*! DH Domain generation values definitions */ +/*! Minimal modulus size for X942 - 1024.*/ +#define DH_X942_PRIME_MOD_MIN_VAL 1024 +/*! Maximal modulus size for X942 - 2048.*/ +#define DH_X942_PRIME_MOD_MAX_VAL 2048 +/*! PGeneration counter for X942 - 4096.*/ +#define DH_X942_PGEN_COUNTER_CONST 4096 +/*! HASH size in bits for X942 - 160.*/ +#define DH_X942_HASH_SIZE_BITS 160 +/*! Maximal allowed ratio between modulus and generator order sizes (by implementation) */ +#define DH_MAX_RATIO_MODULO_TO_ORDER 4 + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + + +/******************************************************************************************/ +/*! +@brief This function generates DH domain parameters in Galois prime field according to standard [ANS X9.42]. +It receives the required sizes (in bits) of the modulus, the generator's order, and the seed, and then generates +the prime modulus and the generator according to given sizes. +If generateSeed argument is set to 1, the function generates and outputs the random seed. Otherwise (if set to 0), +the seed has to be passed as an input argument. According to implementation the seed should be not greate, than (2^seedSizeBits - 2^32). +The seed and some additional parameters, generated by the function (factorJ, pgenCounter), are used for checking +that all domain parameters are generated according to the standard and not forged. +\note All buffer parameters should be in Big-Endian form. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_dh_error.h, crys_rnd_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_DH_CreateDomainParams( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to a random vector generation function. */ + uint32_t modPsizeBits, /*!< [in] Size of the modulus (Prime) in bits equal 256*n, where n >= 4. FIPS 186-4 + defines sizes 1024 and 2048 bit. */ + uint32_t orderQsizeBits, /*!< [in] Size of the Generator's order in bits. FIPS 186-4 defines orderQSizeBits = 160 + for modulus 1024 bit and 224 or 256 bit for modPSizeBits = 2048. We not recommend + sizes > 256 and returns an error if orderQSizeBits > modPSizeBits/4 */ + uint32_t seedSizeBits, /*!< [in] Seed size in bits. Requirements: modPSizeBits >= seedSizeBits >= orderQSizeBits + (the first is required by our implementation). */ + uint8_t *modP_ptr, /*!< [out] Pointer to the modulus (prime) buffer. The size of the buffer for output + generated value must be no less than given modulus size. */ + uint8_t *orderQ_ptr, /*!< [out] Pointer to the order Q of generator. The size of the buffer for output generated + value must be no less than the given order size. */ + uint8_t *generatorG_ptr, /*!< [out] Pointer to the generator of multiplicative subgroup in GF(P). + If the user does not need this output, then both the pointer and the buffer size + must be set to 0. */ + uint32_t *generGsizeBytes_ptr, /*!< [in/out] Pointer to the one word buffer for outputting the generator's size. + The passed size (if needed) must be not less than modulus size and the function + returns the actual size of the generator. */ + uint8_t *factorJ_ptr, /*!< [out] Pointer to the buffer for integer factor J. If NULL, the function does not output + this parameter (in this case JsizeBytes_ptr also must be set to NULL, else the function + returns an error). */ + uint32_t *JsizeBytes_ptr, /*!< [in/out] Pointer to the size of integer factor J. If NULL, the function does not output + this parameter. */ + uint8_t *seedS_ptr, /*!< [in/out] Random seed used for prime generation. The size of the buffer must be + at least the seed size. */ + int8_t generateSeed, /*!< [in] Flag, defining whether the seed should be generated randomly by the function + (1) or is passed by the user (0). */ + uint32_t *pgenCounter_ptr, /*!< [out] Pointer to counter of tries to generate the primes. If NULL, the function does not + output this parameter. */ + CRYS_DHKGData_t *DHKGbuff_ptr /*!< [out] The temp buffer of defined structure for internal calculations. */ +); + + +/******************************************************************************************/ +/*! +@brief This function receives DH domain parameters, seed and prime generation counter and then verifies +that the domain was created according to the standard [ANS X9.42]. +According to implementation, the value of the user passed seed should be not +greate, than (2^seedSizeBits - 2^32), otherwise an error is returned. +\note All buffer parameters should be in Big-Endian form. For more detailed +description of the parameters see ::CRYS_DH_CreateDomainParams. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_dh_error.h, crys_rnd_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_DH_CheckDomainParams( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in/out] Pointer to the RND Generate vector function pointer. */ + uint8_t *modP_ptr, /*!< [in] Pointer to the modulus (Prime). */ + uint32_t modPsizeBytes, /*!< [in] Size of the modulus (Prime) in bytes. */ + uint8_t *orderQ_ptr, /*!< [in] Pointer to the order Q of generator. The size of the buffer for output + generated value must be no less than the order size. */ + uint32_t orderQsizeBytes, /*!< [in] Size of the Generator's order in bytes. */ + uint8_t *generatorG_ptr, /*!< [in] Pointer to the generator of the multiplicative subgroup in GF(P). */ + uint32_t generatorSizeBytes, /*!< [in] Size of the generator in bytes. */ + uint8_t *seedS_ptr, /*!< [in] Random seed used for prime generation. */ + uint32_t seedSizeBits, /*!< [in] Seed size in bits. */ + uint32_t pgenCounter, /*!< [in] Counter of prime generation attempts. */ + CRYS_DHKG_CheckTemp_t *checkTempBuff_ptr /*!< [in] Temporary buffer for internal calculations. */ + +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_edw_api.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_edw_api.h new file mode 100644 index 0000000..47c7f08 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_edw_api.h @@ -0,0 +1,201 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_EC_EDW_API_H +#define CRYS_EC_EDW_API_H + +#include "ssi_pal_types.h" +#include "crys_hash.h" +#include "crys_rnd.h" +#include "crys_pka_defs_hw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@defgroup cryptocell_ec CryptoCell EC 25519 curve APIs +@{ +@ingroup cryptocell_api +@brief This group is the cryptocell EC 25519 curve root group +@} + +@file +@brief This file contains the CRYS APIs used for EC EDW (Edwards) ed25519 algorithms. +@defgroup crys_ec_edw CryptoCell EC Edwards APIs +@{ +@ingroup cryptocell_ec + +\note Algorithms of Montgomery and Edwards elliptic curves cryptography were developed by + Daniel.J.Bernstein. +*/ + +/*! EC Edwards ed25519 modulus and order sizes in bits, words and bytes. */ +/*! EC Edwards modulus size in bits. */ +#define CRYS_ECEDW_MOD_SIZE_IN_BITS 255U /*!<\internal MOD - EC Edw modulus size*/ +/*! EC Edwards order size in bits. */ +#define CRYS_ECEDW_ORD_SIZE_IN_BITS 255U /*!<\internal ORD - EC Edw generator order size*/ +/*! EC Edwards nodulus size in words. */ +#define CRYS_ECEDW_MOD_SIZE_IN_32BIT_WORDS ((CRYS_ECEDW_MOD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / SASI_BITS_IN_32BIT_WORD) +/*! EC Edwards modulus size in bytes. */ +#define CRYS_ECEDW_MOD_SIZE_IN_BYTES (CRYS_ECEDW_MOD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) +/*! EC Edwards order size in words. */ +#define CRYS_ECEDW_ORD_SIZE_IN_32BIT_WORDS ((CRYS_ECEDW_ORD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / SASI_BITS_IN_32BIT_WORD) +/*! EC Edwards order size in bytes. */ +#define CRYS_ECEDW_ORD_SIZE_IN_BYTES (CRYS_ECEDW_ORD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) + +/*! Constant sizes of special EC_MONT buffers and arrays */ +/*! EC Edwards seed size in bytes. */ +#define CRYS_ECEDW_SEED_BYTES CRYS_ECEDW_MOD_SIZE_IN_BYTES +/*! EC Edwards secret key size in bytes. */ +#define CRYS_ECEDW_SECRET_KEY_BYTES (2 * CRYS_ECEDW_MOD_SIZE_IN_BYTES) +/*! EC Edwards signatue size in bytes. */ +#define CRYS_ECEDW_SIGNATURE_BYTES (2 * CRYS_ECEDW_ORD_SIZE_IN_BYTES) +/*! EC Edwards scalar size in bytes. */ +#define CRYS_ECEDW_SCALAR_BYTES CRYS_ECEDW_ORD_SIZE_IN_BYTES +/*! EC Edwards scalar multiplication size in bytes. */ +#define CRYS_ECEDW_SCALARMULT_BYTES CRYS_ECEDW_MOD_SIZE_IN_BYTES + +/*! EC_EDW temp buffer size definition. */ +#define CRYS_ECEDW_TEMP_BUFF_SIZE_IN_32BIT_WORD (10*CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS + (sizeof(CRYS_HASHUserContext_t)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE) + +/*! EC_EDW temp buffer type definition. */ +typedef struct { + /*! Internal buffer. */ + uint32_t buff[CRYS_ECEDW_TEMP_BUFF_SIZE_IN_32BIT_WORD]; +} CRYS_ECEDW_TempBuff_t; + + +/******************************************************************************/ +/*! +@brief The function creates EC Edwards signature on the message. +\note Used detached form of signature, separated from the message. + Implemented algorithm of Bernstein D. etc. sign ed25519. + +@return CRYS_OK on success, +@return A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECEDW_Sign ( + uint8_t *pSign, /*!< [out] Pointer to the detached signature. */ + size_t *pSignSize, /*!< [in/out] Pointer to the total size of the signature ; + In - the buffer size, which (must be at least 2*EC order size); + Out - the actual size of output data. */ + const uint8_t *pMsg, /*!< [in] Pointer to the message. */ + size_t msgSize, /*!< [in] Message size in bytes: must be less, than + (CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES - 2*(EC_EDW modulus size)). */ + const uint8_t *pSignSecrKey, /*!< [in] Pointer to the signer secret key (seed || pulKey) */ + size_t secrKeySize, /*!< [in] Size of signer secret key in bytes: (must be 2*EC order size). */ + CRYS_ECEDW_TempBuff_t *pTempBuff /*!< [in] Pointer to the temp buffer. */); + + + +/******************************************************************************/ +/*! +@brief The function verifies the EC Edwards ed25519 signature on the message. +\note The input signature is in detached form, i.e. separated from the message. + +@return CRYS_OK on success, +@return A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECEDW_Verify( + const uint8_t *pSign, /*!< [in] Pointer to detached signature, i.e. the + signature is separated from the message. */ + size_t signSize, /*!< [in] Size of the signature in bytes, it must be + equal to two EC Order size in bytes. */ + const uint8_t *pSignPublKey, /*!< [in] Pointer to signer public key. */ + size_t publKeySize, /*!< [in] Size of the signer public key in bytes; must be + equal to EC modulus size. */ + uint8_t *pMsg, /*!< [in] Pointer to the message. */ + size_t msgSize, /*!< [in] Pointer to the message size in bytes. Must be less than + (CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES - 2*(EC_EDW modulus size)). */ + CRYS_ECEDW_TempBuff_t *pTempBuff /*!< [in] Pointer to the temp buffer, for internal use. */); + + +/******************************************************************************/ +/*! +@brief The function randomly generates Ec ed25519 private and public keys + using given seed. + The generation is performed using EC Edwards ed25519 algorithm. + +@return CRYS_OK on success, +@return A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECEDW_SeedKeyPair ( + const uint8_t *pSeed, /*!< [in] Pointer to the given seed. */ + size_t seedSize, /*!< [in] Size of the seed in bytes, must be equal the EC order size + in bytes. */ + uint8_t *pSecrKey, /*!< [out] Pointer to the secret key, including the seed, concatenated + with the public key. */ + size_t *pSecrKeySize, /*!< [in/out] Pointer to the size of the secret key buffer in bytes + (must be at least 2*EC order size). */ + uint8_t *pPublKey, /*!< [out] Pointer to the public key. */ + size_t *pPublKeySize, /*!< [in/out] Pointer to the size of the public key in bytes. + In - the size of buffer must be at least EC modulus size; + Out - the actual size. */ + CRYS_ECEDW_TempBuff_t *pTempBuff /*!< [in] Pointer to the temp buffer, for internal use. */); + +/*******************************************************************/ +/*! + @brief The function randomly generates the EC Edwards ed25519 private and + public keys. + The generation is performed using EC Edwards ed25519 algorithm. + +@return CRYS_OK on success, +@return A non-zero value on failure as defined crys_ec_mont_edw_error.h, crys_hash_error.h or crys_rnd_error. +*/ +CIMPORT_C CRYSError_t CRYS_ECEDW_KeyPair ( + uint8_t *pSecrKey, /*!< [out] Pointer to the secret key (including seed and public key). */ + size_t *pSecrKeySize, /*!< [in/out] Pointer to the size of the secret key in bytes, + (must be at least 2*EC order size). */ + uint8_t *pPublKey, /*!< [out] Pointer to the public key. */ + size_t *pPublKeySize, /*!< [in/out] - Pointer to the size of the public key in bytes. + In - the size of buffer must be at least EC modulus size; + Out - the actual size. */ + void *pRndState, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + CRYS_ECEDW_TempBuff_t *pTempBuff /*!< [in] Pointer to the temp buffer. */); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_mont_api.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_api.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_mont_api.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_api.h index 61c7dbc..f9d56ca 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_ec_mont_api.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_api.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECMONT_API_H @@ -24,43 +48,57 @@ extern "C" { /*! @file @brief This file contains the CRYS APIs used for EC MONT (Montgomery Curve25519) algorithms. +@defgroup crys_ec_mont CryptoCell EC Montgomery APIs +@{ +@ingroup cryptocell_ec + \note Implemented algorithms according to Montgomery elliptic curves cryptography, developed by Daniel J.Bernstein etc. */ /*! EC Montgomery curve25519 modulus size in bits, words and bytes */ +/*! EC Montgomery modulus size in bits. */ #define CRYS_ECMONT_MOD_SIZE_IN_BITS 255U -#define CRYS_ECMONT_MOD_SIZE_IN_32BIT_WORDS \ - ((CRYS_ECMONT_MOD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / SASI_BITS_IN_32BIT_WORD) -#define CRYS_ECMONT_MOD_SIZE_IN_BYTES \ - ((CRYS_ECMONT_MOD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / sizeof(uint32_t)) +/*! EC Montgomery modulus size in words. */ +#define CRYS_ECMONT_MOD_SIZE_IN_32BIT_WORDS ((CRYS_ECMONT_MOD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / SASI_BITS_IN_32BIT_WORD) +/*! EC Montgomery modulus size in bytes. */ +#define CRYS_ECMONT_MOD_SIZE_IN_BYTES ((CRYS_ECMONT_MOD_SIZE_IN_BITS + SASI_BITS_IN_32BIT_WORD - 1) / sizeof(uint32_t)) /*! Constant sizes of special EC_MONT buffers and arrays */ +/*! EC Montgomery scalar size in bytes. */ #define CRYS_ECMONT_SCALARBYTES (CRYS_ECMONT_MOD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) +/*! EC Montgomery scalar multiplication size in bytes. */ #define CRYS_ECMONT_SCALARMULTBYTES (CRYS_ECMONT_MOD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) +/*! EC Montgomery scalar seed size in bytes. */ #define CRYS_ECMONT_SEEDBYTES (CRYS_ECMONT_MOD_SIZE_IN_32BIT_WORDS * SASI_32BIT_WORD_SIZE) -/*!< EC Montgomery domains ID-s enumerator */ +/*! EC Montgomery domains ID-s enumerator. */ typedef enum { - CRYS_ECMONT_DOMAIN_CURVE_25519, /*!< EC Curve25519 */ - + CRYS_ECMONT_DOMAIN_CURVE_25519, /*!< EC Curve25519. */ + /*! EC Montgomery last domain. */ CRYS_ECMONT_DOMAIN_OFF_MODE, + /*! Reserved. */ CRYS_ECMONT_DOMAIN_LAST = 0x7FFFFFFF }CRYS_ECMONT_DomainId_t; /*! EC_MONT scalar mult temp buffer type definition */ typedef struct { - uint32_t ecMontScalarMultTempBuff[CRYS_EC_MONT_TEMP_BUFF_SIZE_IN_32BIT_WORDS]; + /*! Internal temporary buffer. */ + uint32_t ecMontScalarMultTempBuff[CRYS_EC_MONT_TEMP_BUFF_SIZE_IN_32BIT_WORDS]; // set needed } CRYS_ECMONT_ScalrMultTempBuff_t; /*! EC_MONT temp buffer type definition */ typedef struct { - /*! Don't change sequence order of the buffers */ + /* Don't change sequence order of the buffers */ + /*! Internal temporary buffer. */ uint32_t ecMontScalar[CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; + /*! Internal temporary buffer. */ uint32_t ecMontResPoint[CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; + /*! Internal temporary buffer. */ uint32_t ecMontInPoint[CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; + /*! Internal temporary buffer. */ CRYS_ECMONT_ScalrMultTempBuff_t ecMontScalrMultTempBuff; // if needed } CRYS_ECMONT_TempBuff_t; @@ -84,8 +122,7 @@ CIMPORT_C CRYSError_t CRYS_ECMONT_Scalarmult( must be equal to EC order size (for curve25519 - 32 bytes). */ const uint8_t *pInPoint, /*!< [in] Pointer to the input point (compressed). */ size_t inPointSize, /*!< [in] Size of the point - must be equal to CRYS_ECMONT_MOD_SIZE_IN_BYTES. */ - CRYS_ECMONT_TempBuff_t *pEcMontTempBuff); /*!< [in] Pointer to temp buffer, for internal use. */ - + CRYS_ECMONT_TempBuff_t *pEcMontTempBuff /*!< [in] Pointer to temp buffer, for internal use. */); /*********************************************************************/ @@ -102,12 +139,12 @@ CIMPORT_C CRYSError_t CRYS_ECMONT_ScalarmultBase( uint8_t *pResPoint, /*!< [out] Pointer to the public (secret) key. */ size_t *pResPointSize, /*!< [in/out] Pointer to the size of the public key in bytes. In - the size of buffer must be at least EC modulus size - (for curve25519 - 32 bytes); + (for curve25519 - 32 bytes); Out - the actual size. */ const uint8_t *pScalar, /*!< [in] Pointer to the secret (private) key. */ size_t scalarSize, /*!< [in] Pointer to the size of the scalar in bytes - must be equal to EC order size (for curve25519 - 32 bytes). */ - CRYS_ECMONT_TempBuff_t *pEcMontTempBuff); /*!< [in] Pointer to temp buffer, for internal use. */ + CRYS_ECMONT_TempBuff_t *pEcMontTempBuff /*!< [in] Pointer to temp buffer, for internal use. */); /*******************************************************************/ @@ -121,20 +158,21 @@ CIMPORT_C CRYSError_t CRYS_ECMONT_ScalarmultBase( secrKey[0] &= 248; secrKey[31] &= 127; secrKey[31] |= 64; @return CRYS_OK on success, -@return A non-zero value on failure as defined crys_ec_mont_edw_error.h. +@return A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_rnd_error.h. */ CIMPORT_C CRYSError_t CRYS_ECMONT_KeyPair ( uint8_t *pPublKey, /*!< [out] Pointer to the public key. */ size_t *pPublKeySize, /*!< [in/out] Pointer to the size of the public key in bytes. In - the size of the buffer must be at least EC order size - (for curve25519 - 32 bytes); + (for curve25519 - 32 bytes); Out - the actual size. */ uint8_t *pSecrKey, /*!< [out] Pointer to the secret key, including. */ size_t *pSecrKeySize, /*!< [in/out] Pointer to the size of buffer for the secret key in bytes - must be at least EC order size (for curve25519 - 32 bytes). */ - CRYS_RND_Context_t *pRndContext, /*!< [in/out] Pointer to the RND context buffer. */ - CRYS_ECMONT_TempBuff_t *pEcMontTempBuff); /*!< [in] Pointer to the temp buffer, for internal use. */ + void *pRndState, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + CRYS_ECMONT_TempBuff_t *pEcMontTempBuff /*!< [in] Pointer to the temp buffer, for internal use. */); /*******************************************************************/ @@ -145,29 +183,30 @@ CIMPORT_C CRYSError_t CRYS_ECMONT_KeyPair ( @return CRYS_OK on success, -@return A non-zero value on failure as defined crys_ec_mont_edw_error.h. +@return A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_hash_error.h. */ CIMPORT_C CRYSError_t CRYS_ECMONT_SeedKeyPair ( uint8_t *pPublKey, /*!< [out] Pointer to the public (secret) key. */ size_t *pPublKeySize, /*!< [in/out] Pointer to the size of the public key in bytes. In - the size of buffer must be at least EC order size - (for curve25519 - 32 bytes); + (for curve25519 - 32 bytes); Out - the actual size. */ uint8_t *pSecrKey, /*!< [out] Pointer to the secret (private) key. */ size_t *pSecrKeySize, /*!< [in/out] Pointer to the size of the secret key in bytes In - the size of buffer must be at least EC order size - (for curve25519 - 32 bytes); + (for curve25519 - 32 bytes); Out - the actual size. */ const uint8_t *pSeed, /*!< [in] Pointer to the given seed - 32 bytes. */ size_t seedSize, /*!< [in/] Size of the seed in bytes (must be equal to CRYS_ECMONT_SEEDBYTES). */ - CRYS_ECMONT_TempBuff_t *pEcMontTempBuff); /*!< [in] Pointer to a temp buffer, for internal use. */ - + CRYS_ECMONT_TempBuff_t *pEcMontTempBuff /*!< [in] Pointer to a temp buffer, for internal use. */); #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_edw_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_edw_error.h new file mode 100644 index 0000000..2251b7d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ec_mont_edw_error.h @@ -0,0 +1,114 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_EC_MONT_EDW_ERROR_H +#define CRYS_EC_MONT_EDW_ERROR_H + +/*! +@file +@brief This module containes the definitions of the CRYS ECC-25519 errors. +@defgroup crys_ecmontedw_error CryptoCell ECC-25519 errors +@{ +@ingroup cryptocell_ec +*/ + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/************************ Defines ******************************/ + +/********************************************************************************************************** + * CRYS EC Montgomery-Edwards MODULE ERRORS base address - 0x00F02300 * + **********************************************************************************************************/ +/*! Illegal input pointer */ +#define CRYS_ECEDW_INVALID_INPUT_POINTER_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x00UL) +/*! Illegal input size */ +#define CRYS_ECEDW_INVALID_INPUT_SIZE_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x01UL) +/*! Illegal scalar size */ +#define CRYS_ECEDW_INVALID_SCALAR_SIZE_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal scalar data */ +#define CRYS_ECEDW_INVALID_SCALAR_DATA_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x03UL) +/*! Invalid RND context pointer */ +#define CRYS_ECEDW_RND_CONTEXT_PTR_INVALID_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x04UL) +/*! Invalid RND generate vector functions pointer */ +#define CRYS_ECEDW_RND_GEN_VECTOR_FUNC_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x05UL) +/*! Signing or verification operation failed */ +#define CRYS_ECEDW_SIGN_VERIFY_FAILED_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x20UL) +/*! Illegal input pointer */ +#define CRYS_ECMONT_INVALID_INPUT_POINTER_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x30UL) +/*! Illegal input size */ +#define CRYS_ECMONT_INVALID_INPUT_SIZE_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x31UL) +/*! Illegal domain id */ +#define CRYS_ECMONT_INVALID_DOMAIN_ID_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x32UL) +/*! Internal PKI error */ +#define CRYS_ECEDW_PKI_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x33UL) +/*! Internal PKI error */ +#define CRYS_ECMONT_PKI_ERROR (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0x34UL) + + +/************************************************************************************************************ + * NOT SUPPORTED MODULES ERROR IDs * + ************************************************************************************************************/ +/*! EC montgomery is not supported */ +#define CRYS_ECMONT_IS_NOT_SUPPORTED (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0xFEUL) +/*! EC edwards is not supported */ +#define CRYS_ECEDW_IS_NOT_SUPPORTED (CRYS_EC_MONT_EDW_MODULE_ERROR_BASE + 0xFFUL) + + + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} +*/ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_build.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_build.h new file mode 100644 index 0000000..5a48e21 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_build.h @@ -0,0 +1,224 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_BUILD_H +#define CRYS_ECPKI_BUILD_H + +/*! +@defgroup cryptocell_ecpki CryptoCell ECC APIs +@{ +@ingroup cryptocell_api +@brief This group is the cryptocell ECC root group +@} + +@file +@brief This module defines functions for building key structures used in Elliptic Curves Cryptography (ECC). +@defgroup crys_ecpki_build CryptoCell key build for ECC APIs +@{ +@ingroup cryptocell_ecpki +*/ + + +#include "crys_error.h" +#include "crys_ecpki_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/********************************************************************************** + * CRYS_ECPKI_BuildPrivKey function * + **********************************************************************************/ +/*! +@brief Builds (imports) the user private key structure from an existing private key so +that this structure can be used by other EC primitives. +This function should be called before using of the private key. Input +domain structure must be initialized by EC parameters and auxiliary +values, using CRYS_ECPKI_GetDomain or CRYS_ECPKI_SetDomain functions. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECPKI_BuildPrivKey( + const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] The EC domain (curve). */ + const uint8_t *pPrivKeyIn, /*!< [in] Pointer to private key data. */ + uint32_t PrivKeySizeInBytes, /*!< [in] Size of private key data (in bytes). */ + CRYS_ECPKI_UserPrivKey_t *pUserPrivKey /*!< [out] Pointer to the private key structure. + This structure is used as input to the ECPKI cryptographic primitives. */ + ); + + +/********************************************************************************** + * CRYS_ECPKI_ExportPrivKey function * + **********************************************************************************/ +/*! +@brief Converts an existing private key from internal representation to Big-Endian export representation. +\note Size of output is equal to ModSizeInBytes. +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECPKI_ExportPrivKey( + CRYS_ECPKI_UserPrivKey_t *pUserPrivKey, /*!< [in] */ + uint8_t *pExportPrivKey, /*!< [out] */ + uint32_t *pPrivKeySizeBytes /*!< [in/out] */ + ); + + +/********************************************************************************** + * _DX_ECPKI_BuildPublKey function * + **********************************************************************************/ +/*! +@brief Builds a user public key structure from an imported public key, +so it can be used by other EC primitives. +When operating the EC cryptographic algorithms with imported EC public +key, this function should be called before using of the public key. + +\note The Incoming public key PublKeyIn structure is big endian bytes array, containing +concatenation of PC||X||Y, where: +
    • PC - point control single byte, defining the type of point: 0x4 - uncompressed, +06,07 - hybrid, 2,3 - compressed.
    • +
    • X,Y - EC point coordinates of public key (y is omitted in compressed form), +size of X and Y must be equal to size of EC modulus.
    + +The user may call this function by appropriate macros, according to necessary validation level [SEC1. ECC standard: 3.2, ANS X9.62]: +
    • Checking the input pointers and sizes only - ::CRYS_ECPKI_BuildPublKey.
    • +
    • Partially checking of public key - ::CRYS_ECPKI_BuildPublKeyPartlyCheck.
    • +
    • Full checking of public key - ::CRYS_ECPKI_BuildPublKeyFullCheck.
    + +\note Full check mode takes long time and should be used when it is actually needed. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h. +*/ +/* +The function performs the following operations: +- Checks validity of incoming variables and pointers; +- Converts incoming key data from big endian into little endian; +- If public key is given in compressed form (i.e. byte[0] = 2 or 3 and + coordinate Y is omitted), then the function uncompress it; +- Performs checking of input key according to CheckMode parameter. +- Initializes variables and structures. +*/ +CIMPORT_C CRYSError_t _DX_ECPKI_BuildPublKey( + const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] The EC domain (curve). */ + uint8_t *PublKeyIn_ptr, /*!< [in] Pointer to the input public key data, in compressed or + uncompressed or hybrid form: + [PC||X||Y] Big-Endian representation, structured according to + [IEEE1363], where: +
    • X and Y are the public key's EC point coordinates. + In compressed form, Y is omitted.
    • +
    • The sizes of X and Y are equal to the size of the EC modulus.
    • +
    • PC is a one-byte point control that defines the type of point + compression.
    */ + uint32_t PublKeySizeInBytes, /*!< [in] The size of public key data (in bytes). */ + EC_PublKeyCheckMode_t CheckMode, /*!< [in] The required level of public key verification + (higher verification level means longer verification time): +
    • 0 = preliminary validation.
    • +
    • 1 = partial validation.
    • +
    • 2 = full validation.
    */ + CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [out] Pointer to the output public key structure. + This structure is used as input to the ECPKI cryptographic primitives. */ + CRYS_ECPKI_BUILD_TempData_t *pTempBuff /*!< [in] Pointer for a temporary buffer required for the build function. */ + ); + + +/********************************************************************************** + * CRYS_ECPKI_BuildPublKey macro * + **********************************************************************************/ +/*! +@brief This macro calls _DX_ECPKI_BuildPublKey function for building the public key +while checking input pointers and sizes. For a description of the parameters see ::_DX_ECPKI_BuildPublKey. +*/ +#define CRYS_ECPKI_BuildPublKey(pDomain, PublKeyIn_ptr, PublKeySizeInBytes, pUserPublKey) \ + _DX_ECPKI_BuildPublKey((pDomain), (PublKeyIn_ptr), (PublKeySizeInBytes), CheckPointersAndSizesOnly, (pUserPublKey), NULL) + + +/********************************************************************************** + * CRYS_ECPKI_BuildPublKeyPartlyCheck macro * + **********************************************************************************/ +/*! +@brief This macro calls _DX_ECPKI_BuildPublKey function for building the public key with partial validation of the key [SEC1] - 3.2.3. +For a description of the parameters see ::_DX_ECPKI_BuildPublKey. +*/ +#define CRYS_ECPKI_BuildPublKeyPartlyCheck(pDomain, PublKeyIn_ptr, PublKeySizeInBytes, pUserPublKey, pTempBuff) \ + _DX_ECPKI_BuildPublKey((pDomain), (PublKeyIn_ptr), (PublKeySizeInBytes), ECpublKeyPartlyCheck, (pUserPublKey), (pTempBuff)) + + +/********************************************************************************** + * CRYS_ECPKI_BuildPublKeyFullCheck macro * + **********************************************************************************/ +/*! +@brief This macro calls _DX_ECPKI_BuildPublKey function for building the public key with full validation of the key [SEC1] - 3.2.2. +For a description of the parameters and return values see _DX_ECPKI_BuildPublKey. +*/ +#define CRYS_ECPKI_BuildPublKeyFullCheck(pDomain, PublKeyIn_ptr, PublKeySizeInBytes, pUserPublKey, pTempBuff) \ + _DX_ECPKI_BuildPublKey((pDomain), (PublKeyIn_ptr), (PublKeySizeInBytes), (ECpublKeyFullCheck), (pUserPublKey), (pTempBuff)) + + +/*********************************************************************************** + * CRYS_ECPKI_ExportPublKey function * + ***********************************************************************************/ +/*! +@brief Converts an existing public key from internal representation to Big-Endian export representation. +The function converts the X,Y coordinates of public key EC point to big endianness, +and sets the public key as follows: +
    • In case "Uncompressed" point: PubKey = PC||X||Y, PC = 0x4 - single byte;
    • +
    • In case of "Hybrid" key PC = 0x6.
    • +
    • In case of "Compressed" key PC = 0x2.
    +\note Size of output X and Y coordinates is equal to ModSizeInBytes. +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECPKI_ExportPublKey( + CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [in] Pointer to the input public key structure (in Little-Endian form). */ + CRYS_ECPKI_PointCompression_t compression, /*!< [in] Compression mode: Compressed, Uncompressed or Hybrid. */ + uint8_t *pExternPublKey, /*!< [out] Pointer to the exported public key array, in compressed or uncompressed + or hybrid form: + [PC||X||Y] Big-Endian representation, structured according to [IEEE1363]. + In compressed form, Y is omitted. */ + uint32_t *pPublKeySizeBytes /*!< [in/out] Pointer used for the input of the user public key buffer size + (in bytes), and the output of the size of the converted public key in bytes. */ + ); + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_dh.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_dh.h new file mode 100644 index 0000000..5ed48ad --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_dh.h @@ -0,0 +1,90 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_DH_H +#define CRYS_ECPKI_DH_H + +/*! @file +@brief Defines the API that supports EC Diffie-Hellman shared secret value derivation primitives. +@defgroup crys_ecpki_dh CryptoCell ECC Diffie-Hellman APIs +@{ +@ingroup cryptocell_ecpki +*/ + + +#include "crys_ecpki_types.h" +#include "crys_ecpki_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*********************************************************************** + * CRYS_ECDH_SVDP_DH function * + ***********************************************************************/ +/*! +@brief Creates the shared secret value according to [IEEE1363, ANS X9.63]: + +
    1. Checks input-parameter pointers and EC Domain in public and private +keys.
    2. +
    3. Derives the partner public key and calls the EcWrstDhDeriveSharedSecret +function, which performs EC SVDP operations.
    +\note The term "User" +refers to any party that calculates a shared secret value using this primitive. +The term "Partner" refers to any other party of shared secret value calculation. +Partner's public key shall be validated before using in this primitive. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECDH_SVDP_DH( + CRYS_ECPKI_UserPublKey_t *PartnerPublKey_ptr, /*!< [in] Pointer to a partner public key. */ + CRYS_ECPKI_UserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to a user private key. */ + uint8_t *SharedSecretValue_ptr, /*!< [out] Pointer to an output buffer that will contain the shared + secret value. */ + uint32_t *SharedSecrValSize_ptr, /*!< [in/out] Pointer to the size of user-passed buffer (in) and + actual size of output of calculated shared secret value + (out). */ + CRYS_ECDH_TempData_t *TempBuff_ptr /*!< [in] Pointer to a temporary buffer. */); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_domain.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_domain.h new file mode 100644 index 0000000..c8faaea --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_domain.h @@ -0,0 +1,80 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_DOMAIN_H +#define CRYS_ECPKI_DOMAIN_H + + +/*! +@file +@brief Defines the ecpki build domain API. +@defgroup crys_ecpki_domain CryptoCell ECC domain APIs +@{ +@ingroup cryptocell_ecpki +*/ + + +#include "crys_error.h" +#include "crys_ecpki_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + + + +/********************************************************************************** + * CRYS_ECPKI_GetEcDomain function * + **********************************************************************************/ + +/*! + * @brief The function returns a pointer to an ECDSA saved domain (one of the supported domains). + * + * @return Domain pointer on success. + * @return NULL on failure. + */ + +const CRYS_ECPKI_Domain_t *CRYS_ECPKI_GetEcDomain(CRYS_ECPKI_DomainID_t domainId /*!< [in] Index of one of the domain Id (must be one of the supported domains). */); + +#ifdef __cplusplus +} +#endif +/** +@} +*/ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_ecdsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_ecdsa.h new file mode 100644 index 0000000..13138c5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_ecdsa.h @@ -0,0 +1,139 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_ECDSA_H +#define CRYS_ECPKI_ECDSA_H + +/*! +@file +@brief Defines the APIs that support the ECDSA functions. +@defgroup crys_ecpki_ecdsa CryptoCell ECDSA APIs +@{ +@ingroup cryptocell_ecpki +*/ + +#include "crys_error.h" +#include "crys_ecpki_types.h" +#include "crys_hash.h" +#include "crys_rnd.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + + +/************************************************************************** + * CRYS_ECDSA_Sign - integrated function + **************************************************************************/ +/*! +@brief This function performs an ECDSA sign operation in integrated form. + +\note +Using of HASH functions with HASH size greater than EC modulus size, is not recommended!. +Algorithm according [ANS X9.62] standard. + +The message data may be either a non-hashed data or a digest of a hash function. +For a non-hashed data, the message data will be hashed using the hash function indicated by ::CRYS_ECPKI_HASH_OpMode_t. +For a digest, ::CRYS_ECPKI_HASH_OpMode_t should indicate the hash function that the message data was created by, and it will not be hashed. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h, crys_hash_error.h or crys_rnd_error.h. +**/ +CIMPORT_C CRYSError_t CRYS_ECDSA_Sign( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + CRYS_ECDSA_SignUserContext_t *pSignUserContext, /*!< [in/out] Pointer to the user buffer for signing the database. */ + CRYS_ECPKI_UserPrivKey_t *pSignerPrivKey, /*!< [in] A pointer to a user private key structure. */ + CRYS_ECPKI_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in + ::CRYS_ECPKI_HASH_OpMode_t. + \note MD5 is not supported. */ + uint8_t *pMessageDataIn, /*!< [in] Pointer to the input data to be signed. + The size of the scatter/gather list representing the data buffer + is limited to 128 entries, and the size of each entry is limited + to 64KB (fragments larger than 64KB are broken into + fragments <= 64KB). */ + uint32_t messageSizeInBytes, /*!< [in] Size of message data in bytes. */ + uint8_t *pSignatureOut, /*!< [in] Pointer to a buffer for output of signature. */ + uint32_t *pSignatureOutSize /*!< [in/out] Pointer to the signature size. Used to pass the size of + the SignatureOut buffer (in), which must be >= 2 + * OrderSizeInBytes. When the API returns, + it is replaced with the size of the actual signature (out). */ + ); + + + +/************************************************************************** + * CRYS_ECDSA_Verify integrated function + **************************************************************************/ +/*! +@brief This function performs an ECDSA verify operation in integrated form. +Algorithm according [ANS X9.62] standard. + +The message data may be either a non-hashed data or a digest of a hash function. +For a non-hashed data, the message data will be hashed using the hash function indicated by ::CRYS_ECPKI_HASH_OpMode_t. +For a digest, ::CRYS_ECPKI_HASH_OpMode_t should indicate the hash function that the message data was created by, and it will not be hashed. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_ECDSA_Verify ( + CRYS_ECDSA_VerifyUserContext_t *pVerifyUserContext, /*!< [in] Pointer to the user buffer for signing the database. */ + CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [in] Pointer to a user public key structure. */ + CRYS_ECPKI_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in + ::CRYS_ECPKI_HASH_OpMode_t. + \note MD5 is not supported. */ + uint8_t *pSignatureIn, /*!< [in] Pointer to the signature to be verified. */ + uint32_t SignatureSizeBytes, /*!< [in] Size of the signature (in bytes). */ + uint8_t *pMessageDataIn, /*!< [in] Pointer to the input data that was signed (same as given to + the signing function). The size of the scatter/gather list representing + the data buffer is limited to 128 entries, and the size of each entry is + limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). */ + uint32_t messageSizeInBytes /*!< [in] Size of the input data (in bytes). */ + ); + + +/**********************************************************************************************************/ + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_error.h new file mode 100644 index 0000000..950dce0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_error.h @@ -0,0 +1,317 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_ERROR_H +#define CRYS_ECPKI_ERROR_H + + +/*! +@file +@brief This module contains the definitions of the CRYS ECPKI errors. +@defgroup crys_ecpki_error CryptoCell ECC specific errors +@{ +@ingroup cryptocell_ecpki +*/ + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/************************ Defines ******************************/ + +/* CRYS_ECPKI_MODULE_ERROR_BASE = 0x00F00800 */ + +/********************************************************************************************* + * CRYS ECPKI MODULE ERRORS * + *********************************************************************************************/ +/*! Illegal domain ID. */ +#define CRYS_ECPKI_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1UL) +/*! Illegal domain pointer. */ +#define CRYS_ECPKI_DOMAIN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x2UL) +/* The CRYS ECPKI GEN KEY PAIR module errors */ +/*! Illegal private key pointer. */ +#define CRYS_ECPKI_GEN_KEY_INVALID_PRIVATE_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal public key pointer. */ +#define CRYS_ECPKI_GEN_KEY_INVALID_PUBLIC_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECPKI_GEN_KEY_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal RND context pointer. */ +#define CRYS_ECPKI_RND_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x6UL) + +/************************************************************************************************************ +* The CRYS ECPKI BUILD KEYS MODULE ERRORS * +*************************************************************************************************************/ +/*! Illegal compression mode. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_COMPRESSION_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal domain ID. */ +#define CRYS_ECPKI_BUILD_KEY_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x08UL) +/*! Illegal private key pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x09UL) +/*! Illegal private key structure pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0AUL) +/*! Illegal private key size. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0BUL) +/*! Illegal private key data. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0CUL) +/*! Illegal public key pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0DUL) +/*! Illegal public key structure pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_USER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0EUL) +/*! Illegal public key size. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0FUL) +/*! Illegal public key data. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x10UL) +/*! Illegal EC build check mode option. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_CHECK_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x11UL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_TEMP_BUFF_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x12UL) + +/* The CRYS ECPKI EXPORT PUBLIC KEY MODULE ERRORS */ +/*! Illegal public key structure pointer. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_USER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x14UL) +/*! Illegal public key compression mode. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_COMPRESSION_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x15UL) +/*! Illegal output public key pointer. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_EXTERN_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x16UL) +/*! Illegal output public key size pointer. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x17UL) +/*! Illegal output public key size. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x18UL) +/*! Illegal domain ID. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x19UL) +/*! Validation of public key failed. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1AUL) +/*! Validation of public key failed. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1BUL) + +/* The CRYS ECPKI EXPORT PRIVATE KEY MODULE ERRORS */ +/*! Illegal private key structure pointer. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC0UL) +/*! Illegal output private key pointer. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_EXTERN_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC1UL) +/*! Validation of private key failed. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_ILLEGAL_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC2UL) +/*! Illegal output private key size pointer. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_PRIV_KEY_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC3UL) +/*! Illegal output private key size. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_PRIV_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC4UL) +/*! Validation of private key failed. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_PRIV_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC5UL) + +/* The CRYS ECPKI BUILD ECC DOMAIN ERRORS */ +/*! Illegal domain ID. */ +#define CRYS_ECPKI_BUILD_DOMAIN_ID_IS_NOT_VALID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x20UL) +/*! Illegal domain ID pointer. */ +#define CRYS_ECPKI_BUILD_DOMAIN_DOMAIN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x21UL) +/*! Illegal domain parameter pointer. */ +#define CRYS_ECPKI_BUILD_DOMAIN_EC_PARAMETR_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x22UL) +/*! Illegal domain parameter size. */ +#define CRYS_ECPKI_BUILD_DOMAIN_EC_PARAMETR_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x23UL) +/*! Illegal domain cofactor parameters. */ +#define CRYS_ECPKI_BUILD_DOMAIN_COFACTOR_PARAMS_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x24UL) +/*! Insufficient strength. */ +#define CRYS_ECPKI_BUILD_DOMAIN_SECURITY_STRENGTH_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x25UL) +/*! SCA resistance error. */ +#define CRYS_ECPKI_BUILD_SCA_RESIST_ILLEGAL_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x26UL) + + +/*! Internal PKI error */ +#define CRYS_ECPKI_PKI_INTERNAL_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x30UL) + +/************************************************************************************************************ + * CRYS EC DIFFIE-HELLMAN MODULE ERRORS +*************************************************************************************************************/ +/* The CRYS EC SVDP_DH Function errors */ +/*! Illegal partner's public key pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_PARTNER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x31UL) +/*! Partner's public key validation failed. */ +#define CRYS_ECDH_SVDP_DH_PARTNER_PUBL_KEY_VALID_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x32UL) +/*! Illegal user private key pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x33UL) +/*! Private key validation failed. */ +#define CRYS_ECDH_SVDP_DH_USER_PRIV_KEY_VALID_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x34UL) +/*! Illegal shared secret pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x35UL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x36UL) +/*! Illegal shared secret size pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x37UL) +/*! Illegal shared secret size. */ +#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x38UL) +/*! Illegal domain ID. */ +#define CRYS_ECDH_SVDP_DH_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x39UL) +/*! Illegal private and public domain ID are different. */ +#define CRYS_ECDH_SVDP_DH_NOT_CONCENT_PUBL_AND_PRIV_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x3AUL) + + +/************************************************************************************************************ + * CRYS ECDSA MODULE ERRORS + ************************************************************************************************************/ +/* The CRYS ECDSA Signing errors */ +/*! Illegal domain ID. */ +#define CRYS_ECDSA_SIGN_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x50UL) +/*! Illegal context pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_USER_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x51UL) +/*! Illegal private key pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x52UL) +/*! Illegal hash operation mode. */ +#define CRYS_ECDSA_SIGN_ILLEGAL_HASH_OP_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x53UL) +/*! Illegal data in pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x54UL) +/*! Illegal data in size. */ +#define CRYS_ECDSA_SIGN_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x55UL) +/*! Context validation failed. */ +#define CRYS_ECDSA_SIGN_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x57UL) +/*! User's private key validation failed. */ +#define CRYS_ECDSA_SIGN_USER_PRIV_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x58UL) +/*! Illegal signature pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x60UL) +/*! Illegal signature size pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x61UL) +/*! Illegal signature size. */ +#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x62UL) +/*! Ephemeral key error. */ +#define CRYS_ECDSA_SIGN_INVALID_IS_EPHEMER_KEY_INTERNAL_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x63UL) +/*! Illegal ephemeral key pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_EPHEMERAL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x64UL) +/*! Illegal RND context pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_RND_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x65UL) +/*! Illegal RND function pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_RND_FUNCTION_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x66UL) +/*! Signature calculation failed. */ +#define CRYS_ECDSA_SIGN_SIGNING_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x67UL) + +/* The CRYS ECDSA Verifying errors */ +/*! Illegal domain ID. */ +#define CRYS_ECDSA_VERIFY_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x70UL) +/*! Illegal user's context pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x71UL) +/*! Illegal public key pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_SIGNER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x72UL) +/*! Illegal hash operation mode. */ +#define CRYS_ECDSA_VERIFY_ILLEGAL_HASH_OP_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x73UL) +/*! Illegal signature pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x76UL) +/*! Illegal signature size. */ +#define CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x77UL) +/*! Illegal data in pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x80UL) +/*! Illegal data in size. */ +#define CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x81UL) +/*! Context validation failed. */ +#define CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x82UL) +/*! public key validation failed. */ +#define CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x83UL) +/*! Verification failed. */ +#define CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x84UL) + +/*! Illegal parameters. */ +#define CRYS_ECC_ILLEGAL_PARAMS_ACCORDING_TO_PRIV_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xD3UL) +/*! Illegal hash mode. */ +#define CRYS_ECC_ILLEGAL_HASH_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE0UL) + + +/************************************************************************************************************ + * CRYS ECPKI MODULE COMMON ERRORS +*************************************************************************************************************/ +/*! Illegal RND function pointer. */ +#define CRYS_ECPKI_INVALID_RND_FUNC_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x90UL) +/*! Illegal RND context pointer. */ +#define CRYS_ECPKI_INVALID_RND_CTX_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x91UL) +/*! Illegal domain ID. */ +#define CRYS_ECPKI_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x92UL) +/*! Private key validation failed. */ +#define CRYS_ECPKI_INVALID_PRIV_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x93UL) +/*! Public key validation failed. */ +#define CRYS_ECPKI_INVALID_PUBL_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x94UL) +/*! Illegal data in. */ +#define CRYS_ECPKI_INVALID_DATA_IN_PASSED_STRUCT_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x95UL) + +/************************************************************************************************************ + * CRYS ECIES MODULE ERRORS +*************************************************************************************************************/ +/*! Illegal public key pointer. */ +#define CRYS_ECIES_INVALID_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE0UL) +/*! Public key validation failed. */ +#define CRYS_ECIES_INVALID_PUBL_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE1UL) +/*! Illegal private key pointer. */ +#define CRYS_ECIES_INVALID_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE2UL) +/*! Private key validation failed. */ +#define CRYS_ECIES_INVALID_PRIV_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE3UL) +/*! Illegal private key value. */ +#define CRYS_ECIES_INVALID_PRIV_KEY_VALUE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE4UL) +/*! Illegal KDF derivation mode. */ +#define CRYS_ECIES_INVALID_KDF_DERIV_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE5UL) +/*! Illegal KDF hash mode. */ +#define CRYS_ECIES_INVALID_KDF_HASH_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE6UL) +/*! Illegal secret key pointer. */ +#define CRYS_ECIES_INVALID_SECRET_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE7UL) +/*! Illegal secret key size. */ +#define CRYS_ECIES_INVALID_SECRET_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE8UL) +/*! Illegal cipher data pointer. */ +#define CRYS_ECIES_INVALID_CIPHER_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE9UL) +/*! Illegal cipher data size pointer. */ +#define CRYS_ECIES_INVALID_CIPHER_DATA_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEAUL) +/*! Illegal cipher data size. */ +#define CRYS_ECIES_INVALID_CIPHER_DATA_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEBUL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECIES_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xECUL) +/*! Illegal ephemeral key pointer */ +#define CRYS_ECIES_INVALID_EPHEM_KEY_PAIR_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEDUL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_kg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_kg.h new file mode 100644 index 0000000..2279c25 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_kg.h @@ -0,0 +1,88 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_KG_H +#define CRYS_ECPKI_KG_H + +/*! @file +@brief Defines the API for generation of ECC private and public keys. +@defgroup crys_ecpki_kg CryptoCell ECC Key Generation APIs +@{ +@ingroup cryptocell_ecpki +*/ + + +#include "crys_error.h" +#include "crys_rnd.h" +#include "crys_ecpki_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/***************** CRYS_ECPKI_GenKeyPair function **********************/ +/*! +@brief Generates a pair of private and public keys in internal representation according to [ANS X9.62]. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_ecpki_error.h or crys_rnd_error.h +*/ +CIMPORT_C CRYSError_t CRYS_ECPKI_GenKeyPair( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] Pointer to EC domain (curve). */ + CRYS_ECPKI_UserPrivKey_t *pUserPrivKey, /*!< [out] Pointer to the private key structure. This structure is used as input to the + ECPKI cryptographic primitives. */ + CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [out] Pointer to the public key structure. This structure is used as input to the + ECPKI cryptographic primitives. */ + CRYS_ECPKI_KG_TempData_t *pTempData, /*!< [in] Temporary buffers for internal use, defined in ::CRYS_ECPKI_KG_TempData_t. */ + CRYS_ECPKI_KG_FipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ +); + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_types.h new file mode 100644 index 0000000..f32aa77 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_ecpki_types.h @@ -0,0 +1,478 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_TYPES_H +#define CRYS_ECPKI_TYPES_H + +/*! +@file +@brief Contains all of the enums and definitions that are used for the CRYS ECPKI APIs. +@defgroup crys_ecpki_types CryptoCell ECC specific types +@{ +@ingroup cryptocell_ecpki +*/ + +#include "ssi_pal_types_plat.h" +#include "crys_hash.h" +#include "crys_pka_defs_hw.h" +#include "ssi_pal_compiler.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/************************ Defines ******************************/ +/*! Internal buffer size in words. */ +#define CRYS_PKA_DOMAIN_LLF_BUFF_SIZE_IN_WORDS (10 + 3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS) + +/************************************************************************************** + * Enumerators + ***************************************************************************************/ + +/*------------------------------------------------------------------*/ +/*! Enumerator for the EC Domain idetifier + References: [13] - SEC 2: Recommended elliptic curve domain parameters. + Version 1.0. Certicom 2000. + [8] - WAP-261-WTLS-20010406-a, Version 06-April-2001. */ + +typedef enum +{ + /* For prime field */ + CRYS_ECPKI_DomainID_secp160k1, /*!< EC secp160r1 */ + CRYS_ECPKI_DomainID_secp160r1, /*!< EC secp160k1 */ + CRYS_ECPKI_DomainID_secp160r2, /*!< EC secp160r2 */ + CRYS_ECPKI_DomainID_secp192k1, /*!< EC secp192k1 */ + CRYS_ECPKI_DomainID_secp192r1, /*!< EC secp192r1 */ + CRYS_ECPKI_DomainID_secp224k1, /*!< EC secp224k1 */ + CRYS_ECPKI_DomainID_secp224r1, /*!< EC secp224r1 */ + CRYS_ECPKI_DomainID_secp256k1, /*!< EC secp256k1 */ + CRYS_ECPKI_DomainID_secp256r1, /*!< EC secp256r1 */ + CRYS_ECPKI_DomainID_secp384r1, /*!< EC secp384r1 */ + CRYS_ECPKI_DomainID_secp521r1, /*!< EC secp521r1 */ + + CRYS_ECPKI_DomainID_Builded, /*!< User given, not identified. */ + CRYS_ECPKI_DomainID_OffMode, /*!< Reserved.*/ + + CRYS_ECPKI_DomainIDLast = 0x7FFFFFFF, /*! Reserved.*/ + +}CRYS_ECPKI_DomainID_t; + + +/*------------------------------------------------------------------*/ +/*! Defines the enum for the HASH operation mode. + * The enumerator defines 6 HASH modes according to IEEE 1363. + * + */ +typedef enum +{ + CRYS_ECPKI_HASH_SHA1_mode = 0, /*!< The message data will be hashed with SHA1. */ + CRYS_ECPKI_HASH_SHA224_mode = 1, /*!< The message data will be hashed with SHA224. */ + CRYS_ECPKI_HASH_SHA256_mode = 2, /*!< The message data will be hashed with SHA256. */ + CRYS_ECPKI_HASH_SHA384_mode = 3, /*!< The message data will be hashed with SHA384. */ + CRYS_ECPKI_HASH_SHA512_mode = 4, /*!< The message data will be hashed with SHA512. */ + + CRYS_ECPKI_AFTER_HASH_SHA1_mode = 5, /*!< The message data is a digest of SHA1 and will not be hashed. */ + CRYS_ECPKI_AFTER_HASH_SHA224_mode = 6, /*!< The message data is a digest of SHA224 and will not be hashed. */ + CRYS_ECPKI_AFTER_HASH_SHA256_mode = 7, /*!< The message data is a digest of SHA256 and will not be hashed. */ + CRYS_ECPKI_AFTER_HASH_SHA384_mode = 8, /*!< The message data is a digest of SHA384 and will not be hashed. */ + CRYS_ECPKI_AFTER_HASH_SHA512_mode = 9, /*!< The message data is a digest of SHA512 and will not be hashed. */ + + + CRYS_ECPKI_HASH_NumOfModes, /*!< Maximal number of HASH modes. */ + CRYS_ECPKI_HASH_OpModeLast = 0x7FFFFFFF, /*!< Reserved. */ + +}CRYS_ECPKI_HASH_OpMode_t; + + +/*---------------------------------------------------*/ +/*! Enumerator for the EC point compression idetifier. */ +typedef enum +{ + CRYS_EC_PointCompressed = 2, /*!< Compressed point. */ + CRYS_EC_PointUncompressed = 4, /*!< Uncompressed point. */ + CRYS_EC_PointContWrong = 5, /*!< Wrong Point Control value. */ + CRYS_EC_PointHybrid = 6, /*!< Hybrid point. */ + + CRYS_EC_PointCompresOffMode = 8, /*!< Reserved. */ + + CRYS_ECPKI_PointCompressionLast= 0x7FFFFFFF, /*!< Reserved. */ + +}CRYS_ECPKI_PointCompression_t; + + +/*! EC key checks defintions. */ +typedef enum { + CheckPointersAndSizesOnly = 0, /*!< Only preliminary input parameters are checked. */ + ECpublKeyPartlyCheck = 1, /*!< Preliminary input parameters check and verify that EC PubKey point is on the curve. */ + ECpublKeyFullCheck = 2, /*!< All the above and in addition verifies that EC_GeneratorOrder*PubKey = O */ + + PublKeyChecingOffMode, /*! Reserved. */ + EC_PublKeyCheckModeLast = 0x7FFFFFFF, /*! Reserved. */ +}EC_PublKeyCheckMode_t; + +/*----------------------------------------------------*/ +/*! Defintion of sw SCA protection. */ +typedef enum { + SCAP_Inactive, /*! Inactive.*/ + SCAP_Active, /*! Active.*/ + SCAP_OFF_MODE, /*! Reserved. */ + SCAP_LAST = 0x7FFFFFFF /*! Reserved. */ +} CRYS_ECPKI_ScaProtection_t; + + +/************************************************************************************** + * EC Domain structure definition + ***************************************************************************************/ + +/*! The structure containing the EC domain parameters in little-endian form + EC equation: Y^2 = X^3 + A*X + B over prime fild GFp. */ +typedef struct { + + /*! EC modulus: P. */ + uint32_t ecP [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! EC equation parameter a. */ + uint32_t ecA [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! EC equation parameter b. */ + uint32_t ecB [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! Order of generator. */ + uint32_t ecR [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1]; + /*! EC cofactor EC_Cofactor_K + Generator (EC base point) coordinates in projective form. */ + uint32_t ecGx [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! EC cofactor EC_Cofactor_K + Generator (EC base point) coordinates in projective form. */ + uint32_t ecGy [CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! EC cofactor EC_Cofactor_K + Generator (EC base point) coordinates in projective form. */ + uint32_t ecH; + /*! Specific fields that are used by the low level.*/ + uint32_t llfBuff[CRYS_PKA_DOMAIN_LLF_BUFF_SIZE_IN_WORDS]; + /*! Size of fields in bits. */ + uint32_t modSizeInBits; + /*! Order size in bits. */ + uint32_t ordSizeInBits; + /*! Size of each inserted Barret tag in words; 0 - if not inserted.*/ + uint32_t barrTagSizeInWords; + /*! EC Domain identifier.*/ + CRYS_ECPKI_DomainID_t DomainID; + + /*! Internal buffer. */ + int8_t name[20]; + +} CRYS_ECPKI_Domain_t; + + + +/************************************************************************************** + * EC point structures definitions + ***************************************************************************************/ + +/*! The structure containing the EC point in affine coordinates + and little endian form. */ +typedef struct +{ + /*! Point coordinate X. */ + uint32_t x[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! Point coordinate Y. */ + uint32_t y[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + +}CRYS_ECPKI_PointAffine_t; + + +/************************************************************************************** + * ECPKI public and private key Structures + ***************************************************************************************/ + +/* --------------------------------------------------------------------- */ +/* .................. The public key structures definitions ............ */ +/* --------------------------------------------------------------------- */ + +/*! The structure containing the Public Key in affine coordinates.*/ +typedef struct +{ + /*! Public Key coordinate X.*/ + uint32_t x[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! Public Key coordinate Y.*/ + uint32_t y[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS]; + /*! EC Domain.*/ + CRYS_ECPKI_Domain_t domain; + /*! Point type.*/ + uint32_t pointType; +} CRYS_ECPKI_PublKey_t; + +/*! The EC public key's user structure prototype. This structure must be saved by the user, and is used as input to the ECC functions +(such as ::CRYS_ECDSA_Verify etc.). */ +typedef struct CRYS_ECPKI_UserPublKey_t +{ + /*! Validation tag.*/ + uint32_t valid_tag; + /*! Public key data. */ + uint32_t PublKeyDbBuff[(sizeof(CRYS_ECPKI_PublKey_t)+3)/4]; + +} CRYS_ECPKI_UserPublKey_t; + + +/* --------------------------------------------------------------------- */ +/* .................. The private key structures definitions ........... */ +/* --------------------------------------------------------------------- */ + +/*! Structure containing the Private key data. */ +typedef struct +{ + /*! Private Key data. */ + uint32_t PrivKey[CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1]; + /*! Domain. */ + CRYS_ECPKI_Domain_t domain; + /*! SCA protection mode. */ + CRYS_ECPKI_ScaProtection_t scaProtection; + +}CRYS_ECPKI_PrivKey_t; + + +/*! The EC private key's user structure prototype. This structure must be saved by the user, and is used as input to the ECC functions +(such as ::CRYS_ECDSA_Sign etc.). */ +typedef struct CRYS_ECPKI_UserPrivKey_t +{ + /*! Validation tag. */ + uint32_t valid_tag; + /*! Private key data. */ + uint32_t PrivKeyDbBuff[(sizeof(CRYS_ECPKI_PrivKey_t)+3)/4]; + +} CRYS_ECPKI_UserPrivKey_t; + +/*! ECDH temporary data type */ +typedef struct CRYS_ECDH_TempData_t +{ + /*! Temporary buffers. */ + uint32_t crysEcdhIntBuff[CRYS_PKA_ECDH_BUFF_MAX_LENGTH_IN_WORDS]; +}CRYS_ECDH_TempData_t; + +/*! EC build temporary data. */ +typedef struct CRYS_ECPKI_BUILD_TempData_t +{ + /*! Temporary buffers. */ + uint32_t crysBuildTmpIntBuff[CRYS_PKA_ECPKI_BUILD_TMP_BUFF_MAX_LENGTH_IN_WORDS]; +}CRYS_ECPKI_BUILD_TempData_t; + + + +/************************************************************************** + * CRYS ECDSA context structures + **************************************************************************/ + +/* --------------------------------------------------------------------- */ +/* CRYS ECDSA Signing context structure */ +/* --------------------------------------------------------------------- */ +/*! Internal buffer used in the signing process. */ +typedef uint32_t CRYS_ECDSA_SignIntBuff[CRYS_PKA_ECDSA_SIGN_BUFF_MAX_LENGTH_IN_WORDS]; + +/*! Context definition for Signing operation. */ +typedef struct +{ + /*! Private Key data. */ + CRYS_ECPKI_UserPrivKey_t ECDSA_SignerPrivKey; + + /*! HASH context. */ + CRYS_HASHUserContext_t hashUserCtxBuff; + /*! HASH result buffer. */ + CRYS_HASH_Result_t hashResult; + /*! HASH result size in words. */ + uint32_t hashResultSizeWords; + /*! HASH mode. */ + CRYS_ECPKI_HASH_OpMode_t hashMode; + /*! Internal buffer. */ + CRYS_ECDSA_SignIntBuff crysEcdsaSignIntBuff; +}ECDSA_SignContext_t; + + +/* --------------------------------------------------------------------- */ +/* CRYS ECDSA Signing User context database */ +/* --------------------------------------------------------------------- */ + +/*! User's context definition for signing operation. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow */ +typedef struct CRYS_ECDSA_SignUserContext_t +{ + /*! Signing process data. */ + uint32_t context_buff [(sizeof(ECDSA_SignContext_t)+3)/4]; + /*! Validation tag*/ + uint32_t valid_tag; +} CRYS_ECDSA_SignUserContext_t; + + + +/****************************************************************************/ + +/* --------------------------------------------------------------------- */ +/* CRYS ECDSA Verifying context structure */ +/* --------------------------------------------------------------------- */ +/*! Internal buffer used in the verification process. */ +typedef uint32_t CRYS_ECDSA_VerifyIntBuff[CRYS_PKA_ECDSA_VERIFY_BUFF_MAX_LENGTH_IN_WORDS]; + +/*! Context definition for verification operation. */ +typedef struct +{ + /*! Public key data. */ + CRYS_ECPKI_UserPublKey_t ECDSA_SignerPublKey; + + /*! HASH context. */ + CRYS_HASHUserContext_t hashUserCtxBuff; + /*! HASH result. */ + CRYS_HASH_Result_t hashResult; + /*! HASH result size in words. */ + uint32_t hashResultSizeWords; + /*! HASH mode. */ + CRYS_ECPKI_HASH_OpMode_t hashMode; + /*! Internal buffer. */ + CRYS_ECDSA_VerifyIntBuff crysEcdsaVerIntBuff; + +}ECDSA_VerifyContext_t; + + +/* --------------------------------------------------------------------- */ +/* CRYS ECDSA Verifying User context database */ +/* --------------------------------------------------------------------- */ +/*! User's context definition for verification operation. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow */ +typedef struct CRYS_ECDSA_VerifyUserContext_t +{ + /*! Verification process data. */ + uint32_t context_buff[(sizeof(ECDSA_VerifyContext_t)+3)/4]; + /*! Validation tag. */ + uint32_t valid_tag; +}CRYS_ECDSA_VerifyUserContext_t; + + + + +/* --------------------------------------------------------------------- */ +/* .................. key generation temp buffer ........... */ +/* --------------------------------------------------------------------- */ + +/*! ECPKI KG temporary data type */ +typedef struct CRYS_ECPKI_KG_TempData_t +{ + /*! Internal buffer. */ + uint32_t crysKGIntBuff[CRYS_PKA_KG_BUFF_MAX_LENGTH_IN_WORDS]; +}CRYS_ECPKI_KG_TempData_t; + +/*! ECIES temporary data definition. */ +typedef struct CRYS_ECIES_TempData_t { + + /*! Private key data. */ + CRYS_ECPKI_UserPrivKey_t PrivKey; + /*! Public key data. */ + CRYS_ECPKI_UserPublKey_t PublKey; + /*! Internal buffer. */ + uint32_t zz[3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1]; + /*! Internal buffers. */ + union { + CRYS_ECPKI_BUILD_TempData_t buildTempbuff; + CRYS_ECPKI_KG_TempData_t KgTempBuff; + CRYS_ECDH_TempData_t DhTempBuff; + } tmp; + +}CRYS_ECIES_TempData_t; + + +/* --------------------------------------------------------------------- */ +/* .................. defines for FIPS ........... */ +/* --------------------------------------------------------------------- */ + +/*! Order length for the FIPS ECC tests. */ +#define CRYS_ECPKI_FIPS_ORDER_LENGTH (256/SASI_BITS_IN_BYTE) // the order of secp256r1 in bytes + +/*! Context definition required for internal FIPS verification for ECPKI key generation. */ +typedef struct CRYS_ECPKI_KG_FipsContext_t +{ + /*! Signing and verification data. */ + union { + CRYS_ECDSA_SignUserContext_t signCtx; + CRYS_ECDSA_VerifyUserContext_t verifyCtx; + }operationCtx; + /*! Internal buffer. */ + uint32_t signBuff[2*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS]; +}CRYS_ECPKI_KG_FipsContext_t; + + + +/*! Context defintion, required for internal FIPS verification for ECDSA KAT. * +* The ECDSA KAT tests defined for domain 256r1. */ +typedef struct CRYS_ECDSAFipsKatContext_t{ + /*! Key data. */ + union { + /*! Private key data. */ + struct { + CRYS_ECPKI_UserPrivKey_t PrivKey; + CRYS_ECDSA_SignUserContext_t signCtx; + }userSignData; + /*! Public key data. */ + struct { + CRYS_ECPKI_UserPublKey_t PublKey; + union { + CRYS_ECDSA_VerifyUserContext_t verifyCtx; + CRYS_ECPKI_BUILD_TempData_t tempData; + }buildOrVerify; + }userVerifyData; + }keyContextData; + /*! Internal buffer. */ + uint8_t signBuff[2*CRYS_ECPKI_FIPS_ORDER_LENGTH]; +}CRYS_ECDSAFipsKatContext_t; + +/*! Context definition, required for internal FIPS verification for ECDH KAT. */ +typedef struct CRYS_ECDHFipsKatContext_t{ + /*! Public key data. */ + CRYS_ECPKI_UserPublKey_t pubKey; + /*! Private key data. */ + CRYS_ECPKI_UserPrivKey_t privKey; + /*! Internal buffers. */ + union { + CRYS_ECPKI_BUILD_TempData_t ecpkiTempData; + CRYS_ECDH_TempData_t ecdhTempBuff; + }tmpData; + /*! Buffer for the secret key. */ + uint8_t secretBuff[CRYS_ECPKI_FIPS_ORDER_LENGTH]; +}CRYS_ECDHFipsKatContext_t; + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_error.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_error.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_error.h index 0f4f5d6..bf5673f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_error.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_error.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ERROR_H #define CRYS_ERROR_H @@ -22,6 +46,9 @@ extern "C" /*! @file @brief This module defines the error return code types and the numbering spaces of the error codes for each module of the layers listed below. +@defgroup crys_error CryptoCell general base error codes +@{ +@ingroup cryptocell_api */ /*! The definitions of the error number space used for the different modules */ @@ -29,167 +56,193 @@ for each module of the layers listed below. /* ........... Error base numeric mapping definitions ................... */ /* ----------------------------------------------------------------------- */ - /* The global error base number */ + /*! CRYS error base number. */ #define CRYS_ERROR_BASE 0x00F00000UL -/* The error range number assigned for each layer */ +/*! Error range number assigned for each layer. */ #define CRYS_ERROR_LAYER_RANGE 0x00010000UL -/* The error range number assigned to each module on its specified layer */ +/*! Error range number assigned to each module on its specified layer. */ #define CRYS_ERROR_MODULE_RANGE 0x00000100UL -/* Defines the layer index for the error mapping */ +/* Defines the layer index for the error mapping. */ +/*! CRYS error layer index. */ #define CRYS_LAYER_ERROR_IDX 0x00UL +/*! Low level functions error layer index. */ #define LLF_LAYER_ERROR_IDX 0x01UL +/*! Generic error layer index. */ #define GENERIC_ERROR_IDX 0x05UL /* Defines the module index for error mapping */ +/*! AES error index.*/ #define AES_ERROR_IDX 0x00UL +/*! DES error index.*/ #define DES_ERROR_IDX 0x01UL +/*! HASH error index.*/ #define HASH_ERROR_IDX 0x02UL +/*! HMAC error index.*/ #define HMAC_ERROR_IDX 0x03UL +/*! RSA error index.*/ #define RSA_ERROR_IDX 0x04UL +/*! DH error index.*/ #define DH_ERROR_IDX 0x05UL +/*! ECPKI error index.*/ #define ECPKI_ERROR_IDX 0x08UL +/*! RND error index.*/ #define RND_ERROR_IDX 0x0CUL +/*! Common error index.*/ #define COMMON_ERROR_IDX 0x0DUL +/*! KDF error index.*/ #define KDF_ERROR_IDX 0x11UL +/*! HKDF error index.*/ #define HKDF_ERROR_IDX 0x12UL +/*! AESCCM error index.*/ #define AESCCM_ERROR_IDX 0x15UL +/*! FIPS error index.*/ #define FIPS_ERROR_IDX 0x17UL +/*! PKA error index.*/ #define PKA_MODULE_ERROR_IDX 0x21UL +/*! CHACHA error index.*/ #define CHACHA_ERROR_IDX 0x22UL +/*! EC montgomery and edwards error index.*/ #define EC_MONT_EDW_ERROR_IDX 0x23UL +/*! CHACHA POLY error index.*/ #define CHACHA_POLY_ERROR_IDX 0x24UL -#define POLY_ERROR_IDX 0x25UL -#define SRP_ERROR_IDX 0x26UL +/*! POLY error index.*/ +#define POLY_ERROR_IDX 0x25UL +/*! SRP error index.*/ +#define SRP_ERROR_IDX 0x26UL /* .......... defining the error spaces for each module on each layer ........... */ /* ------------------------------------------------------------------------------ */ -/* AES module on the CRYS layer base address - 0x00F00000 */ +/*! AES module error base address - 0x00F00000. */ #define CRYS_AES_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * AES_ERROR_IDX ) ) -/* DES module on the CRYS layer base address - 0x00F00100 */ +/*! DES module error base address - 0x00F00100. */ #define CRYS_DES_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * DES_ERROR_IDX ) ) -/* HASH module on the CRYS layer base address - 0x00F00200 */ +/*! HASH module error base address - 0x00F00200. */ #define CRYS_HASH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * HASH_ERROR_IDX ) ) -/* HMAC module on the CRYS layer base address - 0x00F00300 */ +/*! HMAC module error base address - 0x00F00300. */ #define CRYS_HMAC_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * HMAC_ERROR_IDX ) ) -/* PKI RSA module on the CRYS layer base address - 0x00F00400 */ +/*! RSA module error base address - 0x00F00400. */ #define CRYS_RSA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * RSA_ERROR_IDX ) ) -/* DH module on the CRYS layer base address - 0x00F00500 */ +/*! DH module error base address - 0x00F00500. */ #define CRYS_DH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * DH_ERROR_IDX ) ) -/* ECPKI module on the CRYS layer base address - 0x00F00800 */ +/*! ECPKI module error base address - 0x00F00800. */ #define CRYS_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) ) -/* ECPKI module on the LLF layer base address - 0x00F10800 */ +/*! Low level ECPKI module error base address - 0x00F10800. */ #define LLF_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) ) -/* RND module on the CRYS layer base address - 0x00F00C00 */ +/*! RND module error base address - 0x00F00C00. */ #define CRYS_RND_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) ) -/* RND module on the LLF layer base address - 0x00F10C00 */ +/*! Low level RND module error base address - 0x00F10C00. */ #define LLF_RND_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) ) -/* COMMMON module on the CRYS layer base address - 0x00F00D00 */ +/*! COMMMON module error base address - 0x00F00D00. */ #define CRYS_COMMON_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * COMMON_ERROR_IDX ) ) -/* KDF module on the CRYS layer base address - 0x00F01100 */ +/*! KDF module error base address - 0x00F01100. */ #define CRYS_KDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * KDF_ERROR_IDX ) ) -/* KDF module on the CRYS layer base address - 0x00F01100 */ +/*! HKDF module error base address - 0x00F01100. */ #define CRYS_HKDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * HKDF_ERROR_IDX ) ) -/* AESCCM module on the CRYS layer base address - 0x00F01500 */ +/*! AESCCM module error base address - 0x00F01500. */ #define CRYS_AESCCM_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ - (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ - (CRYS_ERROR_MODULE_RANGE * AESCCM_ERROR_IDX ) ) + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * AESCCM_ERROR_IDX ) ) -/* FIPS module on the CRYS layer base address - 0x00F01700 */ +/*! FIPS module error base address - 0x00F01700. */ #define CRYS_FIPS_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ - (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ - (CRYS_ERROR_MODULE_RANGE * FIPS_ERROR_IDX ) ) + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * FIPS_ERROR_IDX ) ) -/* SELF TEST module on the CRYS layer base address - 0x00F02100 */ -#define PKA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ +/*! PKA module error base address - 0x00F02100. */ +#define PKA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * PKA_MODULE_ERROR_IDX ) ) -/* CRYS CHACHA module on the CRYS layer base address - */ +/*! CHACHA module error base address - 0x00F02200. */ #define CRYS_CHACHA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * CHACHA_ERROR_IDX ) ) -/* CRYS CHACHA module on the CRYS layer base address - */ +/*! CHACHA POLY module error base address - 0x00F02400. */ #define CRYS_CHACHA_POLY_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * CHACHA_POLY_ERROR_IDX ) ) -/* CRYS CHACHA module on the CRYS layer base address - */ +/*! POLY module error base address - 0x00F02500. */ #define CRYS_POLY_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * POLY_ERROR_IDX ) ) -/* CRYS SRP module on the CRYS layer base address - */ +/*! SRP module error base address - 0x00F02600. */ #define CRYS_SRP_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * SRP_ERROR_IDX ) ) -/* CRYS EC MONT_EDW module on the CRYS layer base address - */ +/*! EC MONT_EDW module error base address - 0x00F02300. */ #define CRYS_EC_MONT_EDW_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ (CRYS_ERROR_MODULE_RANGE * EC_MONT_EDW_ERROR_IDX ) ) -/* User generic layer base address - 0x00F50000 */ +/*! User generic error base address - 0x00F50000 */ #define GENERIC_ERROR_BASE ( CRYS_ERROR_BASE + (CRYS_ERROR_LAYER_RANGE * GENERIC_ERROR_IDX) ) -#define CRYS_FATAL_ERROR (GENERIC_ERROR_BASE + 0x00UL) -#define CRYS_OUT_OF_RESOURCE_ERROR (GENERIC_ERROR_BASE + 0x01UL) -#define CRYS_ILLEGAL_RESOURCE_VAL_ERROR (GENERIC_ERROR_BASE + 0x02UL) +/*! CRYS fatal error. */ +#define CRYS_FATAL_ERROR (GENERIC_ERROR_BASE + 0x00UL) +/*! CRYS out of resources error. */ +#define CRYS_OUT_OF_RESOURCE_ERROR (GENERIC_ERROR_BASE + 0x01UL) +/*! CRYS illegal resource value error. */ +#define CRYS_ILLEGAL_RESOURCE_VAL_ERROR (GENERIC_ERROR_BASE + 0x02UL) /* ............ The OK (success) definition ....................... */ +/*! Success defintion. */ #define CRYS_OK 0 - +/*! MACRO that defines crys return value. */ #define SASI_CRYS_RETURN_ERROR(retCode, retcodeInfo, funcHandler) \ - ((retCode) == 0 ? CRYS_OK : funcHandler(retCode, retcodeInfo)) + ((retCode) == 0 ? CRYS_OK : funcHandler(retCode, retcodeInfo)) /************************ Enums ********************************/ @@ -210,7 +263,9 @@ typedef uint32_t CRYSError_t; #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash.h similarity index 59% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash.h index 7a6f692..dede2a0 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hash.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash.h @@ -1,18 +1,46 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 @brief This file contains all of the enums and definitions that are used for the CRYS HASH APIs, as well as the APIs themselves. +@defgroup crys_hash CryptoCell HASH APIs +@{ +@ingroup cryptocell_api + This product supports the following HASH algorithms (or modes, according to product):
    • CRYS_HASH_MD5 (producing 16 byte output).
    • @@ -24,13 +52,13 @@ This product supports the following HASH algorithms (or modes, according to prod HASH calculation can be performed in either of the following two modes of operation:
      • Integrated operation - Processes all data in a single function call. This flow is applicable when all data is available prior to the - cryptographic operation.
      • + cryptographic operation.
      • Block operation - Processes a subset of the data buffers, and is called multiple times in a sequence. This flow is applicable when the next data buffer becomes available only during/after processing of the current data buffer.
      The following is a typical HASH Block operation flow:
      1. ::CRYS_HASH_Init - this function initializes the HASH machine on the CRYS level by setting the context pointer that is used on the entire - HASH operation.
      2. + HASH operation.
      3. ::CRYS_HASH_Update - this function runs a HASH operation on a block of data allocated by the user. This function may be called as many times as required.
      4. ::CRYS_HASH_Finish - this function ends the HASH operation. It returns the digest result and clears the context.
      @@ -54,57 +82,58 @@ extern "C" /************************ Defines ******************************/ /* The hash result in words #define CRYS_HASH_RESULT_SIZE_IN_WORDS 5*/ -/* The maximum hash result is 512 bits for SHA512 */ -#define CRYS_HASH_RESULT_SIZE_IN_WORDS 16 +/*! The maximal hash result is 512 bits for SHA512. */ +#define CRYS_HASH_RESULT_SIZE_IN_WORDS 16 -/* The MD5 digest result size in bytes */ +/*! MD5 digest result size in bytes. */ #define CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES 16 -/* The MD5 digest result size in words */ +/*! MD5 digest result size in words. */ #define CRYS_HASH_MD5_DIGEST_SIZE_IN_WORDS 4 -/* The SHA-1 digest result size in bytes */ +/*! SHA-1 digest result size in bytes. */ #define CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES 20 -/* The SHA-1 digest result size in words */ +/*! SHA-1 digest result size in words. */ #define CRYS_HASH_SHA1_DIGEST_SIZE_IN_WORDS 5 -/* The SHA-256 digest result size in bytes */ +/*! SHA-256 digest result size in words. */ #define CRYS_HASH_SHA224_DIGEST_SIZE_IN_WORDS 7 -/* The SHA-256 digest result size in bytes */ +/*! SHA-256 digest result size in words. */ #define CRYS_HASH_SHA256_DIGEST_SIZE_IN_WORDS 8 -/* The SHA-384 digest result size in bytes */ +/*! SHA-384 digest result size in words. */ #define CRYS_HASH_SHA384_DIGEST_SIZE_IN_WORDS 12 -/* The SHA-512 digest result size in bytes */ +/*! SHA-512 digest result size in words. */ #define CRYS_HASH_SHA512_DIGEST_SIZE_IN_WORDS 16 -/* The SHA-256 digest result size in bytes */ +/*! SHA-256 digest result size in bytes */ #define CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES 28 -/* The SHA-256 digest result size in bytes */ +/*! SHA-256 digest result size in bytes */ #define CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES 32 -/* The SHA-384 digest result size in bytes */ +/*! SHA-384 digest result size in bytes */ #define CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES 48 -/* The SHA-512 digest result size in bytes */ +/*! SHA-512 digest result size in bytes */ #define CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES 64 -/* The SHA1 hash block size in words */ +/*! SHA1 hash block size in words */ #define CRYS_HASH_BLOCK_SIZE_IN_WORDS 16 -/* The SHA1 hash block size in bytes */ +/*! SHA1 hash block size in bytes */ #define CRYS_HASH_BLOCK_SIZE_IN_BYTES 64 -/* The SHA2 hash block size in words */ -#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_WORDS 32 +/*! SHA2 hash block size in words */ +#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_WORDS 32 -/* The SHA2 hash block size in bytes */ -#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_BYTES 128 +/*! SHA2 hash block size in bytes */ +#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_BYTES 128 +/*! Maximal data size for update operation. */ #define CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES (1 << 29) @@ -114,29 +143,31 @@ extern "C" HASH operation mode */ typedef enum { - CRYS_HASH_SHA1_mode = 0, /*!< SHA1 */ - CRYS_HASH_SHA224_mode = 1, /*!< SHA224 */ - CRYS_HASH_SHA256_mode = 2, /*!< SHA256 */ - CRYS_HASH_SHA384_mode = 3, /*!< SHA384 */ - CRYS_HASH_SHA512_mode = 4, /*!< SHA512 */ - CRYS_HASH_MD5_mode = 5, /*!< MD5 */ - - CRYS_HASH_NumOfModes, - - CRYS_HASH_OperationModeLast= 0x7FFFFFFF, + CRYS_HASH_SHA1_mode = 0, /*!< SHA1. */ + CRYS_HASH_SHA224_mode = 1, /*!< SHA224. */ + CRYS_HASH_SHA256_mode = 2, /*!< SHA256. */ + CRYS_HASH_SHA384_mode = 3, /*!< SHA384. */ + CRYS_HASH_SHA512_mode = 4, /*!< SHA512. */ + CRYS_HASH_MD5_mode = 5, /*!< MD5. */ + /*! Number of hash modes. */ + CRYS_HASH_NumOfModes, + /*! Reserved. */ + CRYS_HASH_OperationModeLast= 0x7FFFFFFF, }CRYS_HASH_OperationMode_t; /************************ Typedefs *****************************/ -/*! Defines the HASH result buffer. */ +/*! HASH result buffer. */ typedef uint32_t CRYS_HASH_Result_t[CRYS_HASH_RESULT_SIZE_IN_WORDS]; /************************ Structs ******************************/ /*! The user's context prototype - the argument type that is passed by the user - to the APIs called. */ + to the HASH APIs. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow. */ typedef struct CRYS_HASHUserContext_t { - uint32_t buff[CRYS_HASH_USER_CTX_SIZE_IN_WORDS]; + /*! Internal buffer */ + uint32_t buff[CRYS_HASH_USER_CTX_SIZE_IN_WORDS]; }CRYS_HASHUserContext_t; /************************ Public Variables **********************/ @@ -156,7 +187,7 @@ and initializes the HASH Context with the cryptographic attributes that are need */ CIMPORT_C CRYSError_t CRYS_HASH_Init( CRYS_HASHUserContext_t *ContextID_ptr, /*!< [in] Pointer to the HASH context buffer allocated by the user that is used - for the HASH machine operation. */ + for the HASH machine operation. */ CRYS_HASH_OperationMode_t OperationMode /*!< [in] One of the supported HASH modes, as defined in CRYS_HASH_OperationMode_t. */ ); @@ -172,16 +203,14 @@ It updates a HASH Context that was previously initialized by CRYS_HASH_Init or u CIMPORT_C CRYSError_t CRYS_HASH_Update( CRYS_HASHUserContext_t *ContextID_ptr, /*!< [in] Pointer to the HASH context buffer allocated by the user, which is used for the - HASH machine operation. */ + HASH machine operation. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the input data to be HASHed. - The size of the scatter/gather list representing the data buffer is limited to - 128 entries, and the size of each entry is limited to 64KB - (fragments larger than 64KB are broken into fragments <= 64KB). */ + it is a one contiguous memory block. */ size_t DataInSize /*!< [in] Byte size of the input data. Must be > 0. If not a multiple of the HASH block size (64 for MD5, SHA-1 and SHA-224/256, - 128 for SHA-384/512), no further calls + 128 for SHA-384/512), no further calls to CRYS_HASH_Update are allowed in this context, and only CRYS_HASH_Finish - can be called to complete the computation. */ + can be called to complete the computation. */ ); /************************************************************************************************/ @@ -197,9 +226,9 @@ It "adds" a header to the data block according to the relevant HASH standard, an CIMPORT_C CRYSError_t CRYS_HASH_Finish( CRYS_HASHUserContext_t *ContextID_ptr, /*!< [in] Pointer to the HASH context buffer allocated by the user that is used for - the HASH machine operation. */ + the HASH machine operation. */ CRYS_HASH_Result_t HashResultBuff /*!< [in] Pointer to the word-aligned 64 byte buffer. The actual size of the HASH - result depends on CRYS_HASH_OperationMode_t. */ + result depends on CRYS_HASH_OperationMode_t. */ ); @@ -218,7 +247,7 @@ The function executes the following major steps: CIMPORT_C CRYSError_t CRYS_HASH_Free( CRYS_HASHUserContext_t *ContextID_ptr /*!< [in] Pointer to the HASH context buffer allocated by the user that is used for - the HASH machine operation. */ + the HASH machine operation. */ ); @@ -238,11 +267,11 @@ CIMPORT_C CRYSError_t CRYS_HASH ( CRYS_HASH_OperationMode_t OperationMode, /*!< [in] One of the supported HASH modes, as defined in CRYS_HASH_OperationMode_t. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the input data to be HASHed. The size of the scatter/gather list representing the data buffer is limited - to 128 entries, and the size of each entry is limited to 64KB - (fragments larger than 64KB are broken into fragments <= 64KB). */ + to 128 entries, and the size of each entry is limited to 64KB + (fragments larger than 64KB are broken into fragments <= 64KB). */ size_t DataSize, /*!< [in] The size of the data to be hashed in bytes. */ CRYS_HASH_Result_t HashResultBuff /*!< [out] Pointer to a word-aligned 64 byte buffer. The actual size of the HASH - result depends on CRYS_HASH_OperationMode_t. */ + result depends on CRYS_HASH_OperationMode_t. */ ); @@ -250,5 +279,7 @@ CIMPORT_C CRYSError_t CRYS_HASH ( #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_defs.h new file mode 100644 index 0000000..701f78a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_defs.h @@ -0,0 +1,66 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HASH_DEFS_H +#define CRYS_HASH_DEFS_H + +/*! +@file +@brief This file contains HASH definitions. +@defgroup crys_hash_defs CryptoCell Hash definitions +@{ +@ingroup crys_hash +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/************************ Defines ******************************/ + +/*! The size of user's context prototype (see ::CRYS_HASHUserContext_t) in words. */ +#define CRYS_HASH_USER_CTX_SIZE_IN_WORDS 60 + + +#ifdef __cplusplus +} +#endif + +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_error.h new file mode 100644 index 0000000..c1d304e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hash_error.h @@ -0,0 +1,108 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HASH_ERROR_H +#define CRYS_HASH_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS HASH errors. +@defgroup crys_hash_error CryptoCell HASH specific errors +@{ +@ingroup crys_hash +*/ + + + + +/************************ Defines ******************************/ +/*! HASH module on the CRYS layer base address - 0x00F00200*/ +/* The CRYS HASH module errors */ +/*! Illegal context pointer. */ +#define CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x0UL) +/*! Illegal operation mode. */ +#define CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x1UL) +/*! Context is corrupted. */ +#define CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal data in pointer. */ +#define CRYS_HASH_DATA_IN_POINTER_INVALID_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal data in size. */ +#define CRYS_HASH_DATA_SIZE_ILLEGAL (CRYS_HASH_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal result buffer pointer. */ +#define CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x5UL) +/*! Last block was already processed (may happen if previous block was not a multiple of block size). */ +#define CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xCUL) +/*! Illegal parameter. */ +#define CRYS_HASH_ILLEGAL_PARAMS_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xDUL) +/*! Illegal context size. */ +#define CRYS_HASH_CTX_SIZES_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xEUL) +/*! HASH is not supported. */ +#define CRYS_HASH_IS_NOT_SUPPORTED (CRYS_HASH_MODULE_ERROR_BASE + 0xFUL) + + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf.h new file mode 100644 index 0000000..2d9b948 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf.h @@ -0,0 +1,124 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HKDF_H +#define CRYS_HKDF_H + +#include "crys_hash.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module defines the API that supports HMAC Key derivation function as defined by RFC5869. +@defgroup crys_hkdf CryptoCell HMAC Key Derivation APIs +@{ +@ingroup cryptocell_api +*/ + +/*! HKDF maximal key size in words. */ +#define CRYS_HKDF_MAX_HASH_KEY_SIZE_IN_BYTES 512 + +/*! HKDF maximal HASH digest size in bytes. */ +#define CRYS_HKDF_MAX_HASH_DIGEST_SIZE_IN_BYTES CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES + +/************************ Defines ******************************/ + +/************************ Enums ********************************/ + +/*! Enum defining HKDF HASH available modes. */ +typedef enum +{ + /*! SHA1 mode. */ + CRYS_HKDF_HASH_SHA1_mode = 0, + /*! SHA224 mode. */ + CRYS_HKDF_HASH_SHA224_mode = 1, + /*! SHA256 mode. */ + CRYS_HKDF_HASH_SHA256_mode = 2, + /*! SHA384 mode. */ + CRYS_HKDF_HASH_SHA384_mode = 3, + /*! SHA512 mode. */ + CRYS_HKDF_HASH_SHA512_mode = 4, + + /*! Maximal number of HASH modes. */ + CRYS_HKDF_HASH_NumOfModes, + + /*! Reserved */ + CRYS_HKDF_HASH_OpModeLast = 0x7FFFFFFF, + +}CRYS_HKDF_HASH_OpMode_t; + +/************************ Typedefs ****************************/ + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + +/****************************************************************/ + + +/*********************************************************************************************************/ +/*! +@brief CRYS_HKDF_KeyDerivFunc performs the HMAC-based key derivation, according to RFC5869 + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_kdf_error.h, crys_hash_error or crys_hmac_error.h +*/ +CEXPORT_C CRYSError_t CRYS_HKDF_KeyDerivFunc( + CRYS_HKDF_HASH_OpMode_t HKDFhashMode, /*!< [in] The HKDF identifier of hash function to be used. */ + uint8_t* Salt_ptr, /*!< [in] A pointer to a non secret random value. can be NULL. */ + size_t SaltLen, /*!< [in] The size of the salt_ptr. */ + uint8_t* Ikm_ptr, /*!< [in] A pointer to a input key message. */ + uint32_t IkmLen, /*!< [in] The size of the input key message */ + uint8_t* Info, /*!< [in] A pointer to an optional context and application specific information. can be NULL */ + uint32_t InfoLen, /*!< [in] The size of the info. */ + uint8_t* Okm, /*!< [in] A pointer to a output key material. */ + uint32_t OkmLen, /*!< [in] The size of the output key material. */ + SaSiBool IsStrongKey /*!< [in] if TRUE , then no need to perform the extraction phase. */ + ); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf_error.h new file mode 100644 index 0000000..36ddaee --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hkdf_error.h @@ -0,0 +1,91 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HKDF_ERROR_H +#define CRYS_HKDF_ERROR_H + +#include "crys_error.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS HKDF errors. +@defgroup crys_hkdf_error HMAC Key Derivation specific errors +@{ +@ingroup crys_hkdf + */ + + +/************************ Defines *******************************/ + +/*! CryptoCell HKDF module errors / base address - 0x00F01100. */ +/*! Invalid argument. */ +#define CRYS_HKDF_INVALID_ARGUMENT_POINTER_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x0UL) +/*! Invalid argument size. */ +#define CRYS_HKDF_INVALID_ARGUMENT_SIZE_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x1UL) +/*! Illegal hash mode. */ +#define CRYS_HKDF_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x3UL) +/*! HKDF not supported. */ +#define CRYS_HKDF_IS_NOT_SUPPORTED (CRYS_HKDF_MODULE_ERROR_BASE + 0xFFUL) + +/************************ Enums *********************************/ + +/************************ Typedefs *****************************/ + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac.h similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac.h index d116b14..1ba7659 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_hmac.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac.h @@ -1,18 +1,46 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 @brief This file contains all of the enums and definitions that are used for the CRYS HMAC APIs, as well as the APIs themselves. +@defgroup crys_hmac CryptoCell HMAC APIs +@{ +@ingroup cryptocell_api + HMAC is a wrapping algorithm that uses a HASH function (one of the supported HASH algorithms, as specified in the HASH chapter) and a key, to generate a unique authentication code over the input data. @@ -24,7 +52,7 @@ the next data buffer becomes available only during/after processing of the curre The following is a typical HMAC Block operation flow:
      1. ::CRYS_HMAC_Init: This function initializes the HMAC machine on the CRYS level by setting the context pointer that is - used on the entire HMAC operation.
      2. + used on the entire HMAC operation.
      3. ::CRYS_HMAC_Update: This function runs an HMAC operation on a block of data allocated by the user. This function may be called as many times as required.
      4. ::CRYS_HMAC_Finish: This function ends the HMAC operation. It returns the digest result and clears the context.
      @@ -48,10 +76,10 @@ extern "C" /************************ Defines ******************************/ -/* The HMAC key size after padding for MD5, SHA1, SHA256 */ +/*! HMAC key size after padding for MD5, SHA1, SHA256. */ #define CRYS_HMAC_KEY_SIZE_IN_BYTES 64 -/* The HMAC key size after padding for SHA384, SHA512 */ +/*! HMAC key size after padding for SHA384, SHA512 */ #define CRYS_HMAC_SHA2_1024BIT_KEY_SIZE_IN_BYTES 128 /************************ Enums ********************************/ @@ -61,10 +89,12 @@ extern "C" /*********************** Structures ****************************/ -/* The user's context prototype - the argument type that is passed by the user - to the APIs called */ +/*! User's context prototype - the argument type that is passed by the user + to the HMAC APIs. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow */ typedef struct CRYS_HMACUserContext_t { - uint32_t buff[CRYS_HMAC_USER_CTX_SIZE_IN_WORDS]; + /*! Context buffer for internal use */ + uint32_t buff[CRYS_HMAC_USER_CTX_SIZE_IN_WORDS]; }CRYS_HMACUserContext_t; @@ -83,14 +113,15 @@ It allocates and initializes the HMAC Context. It initiates a HASH session and p then stores it in the context @return CRYS_OK on success. -@return A non-zero value from crys_hmac_error.h on failure. +@return A non-zero value from crys_hmac_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t CRYS_HMAC_Init( CRYS_HMACUserContext_t *ContextID_ptr, /*!< [in] Pointer to the HMAC context buffer allocated by the user, which is used - for the HMAC machine operation. */ + for the HMAC machine operation. */ CRYS_HASH_OperationMode_t OperationMode, /*!< [in] One of the supported HASH modes, as defined in CRYS_HASH_OperationMode_t. */ uint8_t *key_ptr, /*!< [in] The pointer to the user's key buffer. */ - uint16_t keySize /*!< [in] The key size in bytes. */ + uint16_t keySize /*!< [in] The key size in bytes. If the key size is bigger than the HASH block, the key will be hashed. + The limitations on the key size are the same as the limitations on MAX hash size. */ ); @@ -100,21 +131,21 @@ CIMPORT_C CRYSError_t CRYS_HMAC_Init( It receives a handle to the HMAC Context, and updates the HASH value with the new data. @return CRYS_OK on success. -@return A non-zero value from crys_hmac_error.h on failure. +@return A non-zero value from crys_hmac_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t CRYS_HMAC_Update( CRYS_HMACUserContext_t *ContextID_ptr, /*!< [in] Pointer to the HMAC context buffer allocated by the user - that is used for the HMAC machine operation. */ + that is used for the HMAC machine operation. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the input data to be HASHed. The size of the scatter/gather list representing the data buffer is limited to - 128 entries, and the size of each entry is limited to 64KB - (fragments larger than 64KB are broken into fragments <= 64KB). */ + 128 entries, and the size of each entry is limited to 64KB + (fragments larger than 64KB are broken into fragments <= 64KB). */ size_t DataInSize /*!< [in] Byte size of the input data. Must be > 0. If not a multiple of the HASH block size (64 for SHA-1 and SHA-224/256, - 128 for SHA-384/512), no further calls to ::CRYS_HMAC_Update are allowed in - this context, and only ::CRYS_HMAC_Finish can be called to complete the - computation. */ + 128 for SHA-384/512), no further calls to ::CRYS_HMAC_Update are allowed in + this context, and only ::CRYS_HMAC_Finish can be called to complete the + computation. */ ); @@ -126,14 +157,14 @@ It completes the HASH calculation on the ipad and text, and then executes a new HASH operation result. @return CRYS_OK on success. -@return A non-zero value from crys_hmac_error.h on failure. +@return A non-zero value from crys_hmac_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t CRYS_HMAC_Finish( CRYS_HMACUserContext_t *ContextID_ptr, /*!< [in] Pointer to the HMAC context buffer allocated by the user, which is used - for the HMAC machine operation. */ + for the HMAC machine operation. */ CRYS_HASH_Result_t HmacResultBuff /*!< [out] Pointer to the word-aligned 64 byte buffer. The actual size of the - HASH result depends on CRYS_HASH_OperationMode_t. */ + HASH result depends on CRYS_HASH_OperationMode_t. */ ); @@ -151,7 +182,7 @@ The function executes the following major steps: CIMPORT_C CRYSError_t CRYS_HMAC_Free( CRYS_HMACUserContext_t *ContextID_ptr /*!< [in] Pointer to the HMAC context buffer allocated by the user, which is used for - the HMAC machine operation. */ + the HMAC machine operation. */ ); @@ -159,22 +190,25 @@ CIMPORT_C CRYSError_t CRYS_HMAC_Free( @brief This function processes a single buffer of data, and returns the data buffer's message digest. @return CRYS_OK on success. -@return A non-zero value from crys_hmac_error.h on failure. +@return A non-zero value from crys_hmac_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t CRYS_HMAC ( CRYS_HASH_OperationMode_t OperationMode, /*!< [in] One of the supported HASH modes, as defined in CRYS_HASH_OperationMode_t. */ uint8_t *key_ptr, /*!< [in] The pointer to the user's key buffer. */ - uint16_t keySize, /*!< [in] The key size in bytes. */ + uint16_t keySize, /*!< [in] The key size in bytes. If the key size is bigger than the HASH block, the key will be hashed. + The limitations on the key size are the same as the limitations on MAX hash size.*/ uint8_t *DataIn_ptr, /*!< [in] Pointer to the input data to be HASHed. The size of the scatter/gather list representing the data buffer is limited to 128 - entries, and the size of each entry is limited to 64KB (fragments larger than - 64KB are broken into fragments <= 64KB). */ + entries, and the size of each entry is limited to 64KB (fragments larger than + 64KB are broken into fragments <= 64KB). */ size_t DataSize, /*!< [in] The size of the data to be hashed (in bytes). */ CRYS_HASH_Result_t HmacResultBuff /*!< [out] Pointer to the word-aligned 64 byte buffer. The actual size of the - HMAC result depends on CRYS_HASH_OperationMode_t. */ + HMAC result depends on CRYS_HASH_OperationMode_t. */ ); #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_defs.h new file mode 100644 index 0000000..6e76d71 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_defs.h @@ -0,0 +1,64 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HMAC_DEFS_H +#define CRYS_HMAC_DEFS_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains HMAC definitions. +@defgroup crys_hmac_defs CryptoCell Hmac definitions +@{ +@ingroup crys_hmac +*/ + +/************************ Defines ******************************/ +/*! The size of user's context prototype (see ::CRYS_HMACUserContext_t) in words. */ +#define CRYS_HMAC_USER_CTX_SIZE_IN_WORDS 94 + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_error.h new file mode 100644 index 0000000..9530ab8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_hmac_error.h @@ -0,0 +1,108 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HMAC_ERROR_H +#define CRYS_HMAC_ERROR_H + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! @file +@brief This module contains the definitions of the CRYS HMAC errors. +@defgroup crys_hmac_error CryptoCell HMAC specific errors +@{ +@ingroup crys_hmac +*/ + + + +/************************ Defines ******************************/ + +/*! The CRYS HMAC module errors */ +/*! Illegal context pointer. */ +#define CRYS_HMAC_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x0UL) +/*! Illegal operation mode. */ +#define CRYS_HMAC_ILLEGAL_OPERATION_MODE_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x1UL) +/*! Context is corrupted. */ +#define CRYS_HMAC_USER_CONTEXT_CORRUPTED_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal data in pointer. */ +#define CRYS_HMAC_DATA_IN_POINTER_INVALID_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal data in size. */ +#define CRYS_HMAC_DATA_SIZE_ILLEGAL (CRYS_HMAC_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal result buffer pointer. */ +#define CRYS_HMAC_INVALID_RESULT_BUFFER_POINTER_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal key buffer pointer. */ +#define CRYS_HMAC_INVALID_KEY_POINTER_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x6UL) +/*! Illegal key size. */ +#define CRYS_HMAC_UNVALID_KEY_SIZE_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0x7UL) +/*! Last block was already processed (may happen if previous block was not a multiple of block size). */ +#define CRYS_HMAC_LAST_BLOCK_ALREADY_PROCESSED_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0xBUL) +/*! Illegal parameters. */ +#define CRYS_HMAC_ILLEGAL_PARAMS_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0xCUL) +/*! Illegal context size. */ +#define CRYS_HMAC_CTX_SIZES_ERROR (CRYS_HMAC_MODULE_ERROR_BASE + 0xEUL) +/*! HMAC is not supported. */ +#define CRYS_HMAC_IS_NOT_SUPPORTED (CRYS_HMAC_MODULE_ERROR_BASE + 0xFUL) + + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf.h new file mode 100644 index 0000000..78cde00 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf.h @@ -0,0 +1,211 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_KDF_H +#define CRYS_KDF_H + + +#include "crys_hash.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module defines the API that supports Key derivation function in modes +as defined in PKCS#3, ANSI X9.42-2001, and ANSI X9.63-1999. +@defgroup crys_kdf CryptoCell Key Derivation APIs +@{ +@ingroup cryptocell_api +*/ + +#include "crys_hash.h" + +/************************ Defines ******************************/ + +/*! Shared secret value max size in bytes */ +#define CRYS_KDF_MAX_SIZE_OF_SHARED_SECRET_VALUE 1024 + +/* Count and max. sizeof OtherInfo entries (pointers to data buffers) */ +/*! Number of other info entries. */ +#define CRYS_KDF_COUNT_OF_OTHER_INFO_ENTRIES 5 +/*! Maximal size of other info entry. */ +#define CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY 64 /*!< Size is in bytes*/ +/*! Maximal size of keying data in bytes. */ +#define CRYS_KDF_MAX_SIZE_OF_KEYING_DATA 2048 + +/************************ Enums ********************************/ +/*! HASH operation modes */ +typedef enum +{ + /*! SHA1 mode.*/ + CRYS_KDF_HASH_SHA1_mode = 0, + /*! SHA224 mode.*/ + CRYS_KDF_HASH_SHA224_mode = 1, + /*! SHA256 mode.*/ + CRYS_KDF_HASH_SHA256_mode = 2, + /*! SHA384 mode.*/ + CRYS_KDF_HASH_SHA384_mode = 3, + /*! SHA512 mode.*/ + CRYS_KDF_HASH_SHA512_mode = 4, + /*! Maximal number of HASH modes. */ + CRYS_KDF_HASH_NumOfModes, + /*! Reserved.*/ + CRYS_KDF_HASH_OpModeLast = 0x7FFFFFFF, + +}CRYS_KDF_HASH_OpMode_t; + +/*! Key derivation modes. */ +typedef enum +{ + /*! ASN1 key derivation mode.*/ + CRYS_KDF_ASN1_DerivMode = 0, + /*! Concatination key derivation mode.*/ + CRYS_KDF_ConcatDerivMode = 1, + /*! X963 key derivation mode.*/ + CRYS_KDF_X963_DerivMode = CRYS_KDF_ConcatDerivMode, + /*! ISO 18033 KDF1 key derivation mode.*/ + CRYS_KDF_ISO18033_KDF1_DerivMode = 3, + /*! ISO 18033 KDF2 key derivation mode.*/ + CRYS_KDF_ISO18033_KDF2_DerivMode = 4, + /*! Maximal number of key derivation modes. */ + CRYS_KDF_DerivFunc_NumOfModes = 5, + /*! Reserved.*/ + CRYS_KDF_DerivFuncModeLast= 0x7FFFFFFF, + +}CRYS_KDF_DerivFuncMode_t; + +/************************ Typedefs ****************************/ + +/*! Structure, containing the optional data (other info) for KDF, + if any data is not needed, then the pointer value and + the size must be set to NULL */ +typedef struct +{ + /*! A unique object identifier (OID), indicating algorithm(s) + for which the keying data is used. */ + uint8_t AlgorithmID[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; + uint32_t SizeOfAlgorithmID; /*!< Size of algorithm ID.*/ + /*! Public information contributed by the initiator. */ + uint8_t PartyUInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; + uint32_t SizeOfPartyUInfo; /*!< Size of the Public information contributed by the initiator. */ + /*! Public information contributed by the responder. */ + uint8_t PartyVInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; + uint32_t SizeOfPartyVInfo; /*!< Size of the responder's public information. */ + /*! Mutually-known private information, e.g. shared information + communicated throgh a separate channel. */ + uint8_t SuppPrivInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; + uint32_t SizeOfSuppPrivInfo; /*!< Size of the private information. */ + /*! Mutually-known public information, */ + uint8_t SuppPubInfo[CRYS_KDF_MAX_SIZE_OF_OTHER_INFO_ENTRY]; + uint32_t SizeOfSuppPubInfo; /*!< Size of the public information. */ + +}CRYS_KDF_OtherInfo_t; + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + +/****************************************************************/ + + +/*********************************************************************************************************/ +/*! + @brief CRYS_KDF_KeyDerivFunc performs key derivation according to one of the modes defined in standards: + ANS X9.42-2001, ANS X9.63, ISO/IEC 18033-2. + +The present implementation of the function allows the following operation modes: +
      • CRYS_KDF_ASN1_DerivMode - mode based on ASN.1 DER encoding;
      • +
      • CRYS_KDF_ConcatDerivMode - mode based on concatenation;
      • +
      • CRYS_KDF_X963_DerivMode = CRYS_KDF_ConcatDerivMode;
      • +
      • CRYS_KDF_ISO18033_KDF1_DerivMode - specific mode according to ECIES-KEM algorithm (ISO/IEC 18033-2).
      + +The purpose of this function is to derive a keying data from the shared secret value and some +other optional shared information (SharedInfo). + +\note +
      • The length in Bytes of the hash result buffer is denoted by "hashlen".
      • +
      • All buffers arguments are represented in Big-Endian format.
      • + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_kdf_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_KDF_KeyDerivFunc( + uint8_t *ZZSecret_ptr, /*!< [in] A pointer to shared secret value octet string. */ + uint32_t ZZSecretSize, /*!< [in] The size of the shared secret value in bytes. + The maximal size is defined as: CRYS_KDF_MAX_SIZE_OF_SHARED_SECRET_VALUE. */ + CRYS_KDF_OtherInfo_t *OtherInfo_ptr, /*!< [in] The pointer to structure, containing the data, shared by two entities of + agreement and the data sizes. This argument may be optional in several modes + (if it is not needed - set NULL). + On two ISO/IEC 18033-2 modes - set NULL. + On KDF ASN1 mode the OtherInfo and its AlgorithmID entry are mandatory. */ + CRYS_KDF_HASH_OpMode_t KDFhashMode, /*!< [in] The KDF identifier of hash function to be used. The hash function output + must be at least 160 bits. */ + CRYS_KDF_DerivFuncMode_t derivation_mode, /*!< [in] Specifies one of above described derivation modes. */ + uint8_t *KeyingData_ptr, /*!< [out] A pointer to the buffer for derived keying data. */ + uint32_t KeyingDataSizeBytes /*!< [in] The size in bytes of the keying data to be derived. + The maximal size is defined as: CRYS_KDF_MAX_SIZE_OF_KEYING_DATA. */ +); + +/*********************************************************************************************************/ +/*! + CRYS_KDF_ASN1_KeyDerivFunc is A MACRO that performs key derivation according to ASN1 DER encoding method defined + in standard ANS X9.42-2001, 7.2.1. For a description of the parameters see ::CRYS_KDF_KeyDerivFunc. +*/ +#define CRYS_KDF_ASN1_KeyDerivFunc(ZZSecret_ptr,ZZSecretSize,OtherInfo_ptr,KDFhashMode,KeyingData_ptr,KeyLenInBytes)\ + CRYS_KDF_KeyDerivFunc((ZZSecret_ptr),(ZZSecretSize),(OtherInfo_ptr),(KDFhashMode),CRYS_KDF_ASN1_DerivMode,(KeyingData_ptr),(KeyLenInBytes)) + + +/*********************************************************************************************************/ +/*! + CRYS_KDF_ConcatKeyDerivFunc is a MACRO that performs key derivation according to concatenation mode defined + in standard ANS X9.42-2001, 7.2.2. For a description of the parameters see + ::CRYS_KDF_KeyDerivFunc. +*/ +#define CRYS_KDF_ConcatKeyDerivFunc(ZZSecret_ptr,ZZSecretSize,OtherInfo_ptr,KDFhashMode,KeyingData_ptr,KeyLenInBytes)\ + CRYS_KDF_KeyDerivFunc((ZZSecret_ptr),(ZZSecretSize),(OtherInfo_ptr),(KDFhashMode),CRYS_KDF_ConcatDerivMode,(KeyingData_ptr),(KeyLenInBytes)) + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf_error.h new file mode 100644 index 0000000..f550140 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_kdf_error.h @@ -0,0 +1,105 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_KDF_ERROR_H +#define CRYS_KDF_ERROR_H + +#include "crys_error.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS KDF errors. +@defgroup crys_kdf_error CryptoCell Key Derivation specific errors +@{ +@ingroup crys_kdf + */ + + +/************************ Defines *******************************/ + +/*! The CRYS KDF module errors / base address - 0x00F01100*/ +/*! Illegal input pointer. */ +#define CRYS_KDF_INVALID_ARGUMENT_POINTER_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x0UL) +/*! Illegal input size. */ +#define CRYS_KDF_INVALID_ARGUMENT_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x1UL) +/*! Illegal operation mode. */ +#define CRYS_KDF_INVALID_ARGUMENT_OPERATION_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal hash mode. */ +#define CRYS_KDF_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal key derivation mode. */ +#define CRYS_KDF_INVALID_KEY_DERIVATION_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal shared secret value size. */ +#define CRYS_KDF_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal otherInfo size. */ +#define CRYS_KDF_INVALID_OTHER_INFO_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x6UL) +/*! Illegal key data size. */ +#define CRYS_KDF_INVALID_KEYING_DATA_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x7UL) +/*! Illegal algorithm ID pointer. */ +#define CRYS_KDF_INVALID_ALGORITHM_ID_POINTER_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x8UL) +/*! Illegal algorithm ID size. */ +#define CRYS_KDF_INVALID_ALGORITHM_ID_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x9UL) +/*! KDF is not supproted. */ +#define CRYS_KDF_IS_NOT_SUPPORTED (CRYS_KDF_MODULE_ERROR_BASE + 0xFFUL) + +/************************ Enums *********************************/ + +/************************ Typedefs *****************************/ + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_pka_defs_hw.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_pka_defs_hw.h new file mode 100644 index 0000000..5073ad2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_pka_defs_hw.h @@ -0,0 +1,128 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _CRYS_PKA_DEFS_HW_H_ +#define _CRYS_PKA_DEFS_HW_H_ + +#include "ssi_pal_types.h" +#include "ssi_pka_hw_plat_defs.h" + +/*! +@defgroup cryptocell_pka CryptoCell PKA group +@{ +@ingroup cryptocell_api +@brief This group is the cryptocell PKA root group +@} + +@file +@brief The file contains all of the enums and definitions that are used in the PKA related code. +@defgroup crys_pka_defs_hw CryptoCell PKA specific definitions +@{ +@ingroup cryptocell_pka +*/ + + +/* The valid key sizes in bits for RSA primitives (exponentiation) */ +/*! Maximal RSA modulus size */ +#define CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS ((CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS + SASI_PKA_WORD_SIZE_IN_BITS) / SASI_BITS_IN_32BIT_WORD ) +/*! Maximal EC modulus size */ +#define CRYS_ECPKI_MODUL_MAX_LENGTH_IN_BITS 521 + +/*! size of buffers for Barrett modulus tag NP, used in PKI algorithms. */ +#define CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS 5 +/*! size of buffers for Barrett modulus tag NP, used in ECC. */ +#define CRYS_PKA_ECPKI_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS +/*! Maximal PKA modulus size */ +#define CRYS_PKA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS +/*! Maximal PKA public key size in words */ +#define CRYS_PKA_PUB_KEY_BUFF_SIZE_IN_WORDS (2*CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS) +/*! Maximal PKA private key size in words */ +#define CRYS_PKA_PRIV_KEY_BUFF_SIZE_IN_WORDS (2*CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS) +/*! Maximal PKA KG buffer size in words */ +#define CRYS_PKA_KGDATA_BUFF_SIZE_IN_WORDS (3*CRYS_PKA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS) + + +/*! Maximal EC modulus size in words. */ +#define CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS 18 /*!< \internal [(CRYS_ECPKI_MODUL_MAX_LENGTH_IN_BITS + 31)/(sizeof(uint32_t)) + 1] */ +/*! Maximal EC order size in words. */ +#define CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS (CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1) +/*! Maximal EC domain size in words. */ +#define CRYS_PKA_DOMAIN_BUFF_SIZE_IN_WORDS (2*CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS) + + +/*! ECC NAF buffer definitions */ +#define COUNT_NAF_WORDS_PER_KEY_WORD 8 /*!< \internal Change according to NAF representation (? 2)*/ +/*! Maximal ECC NAF length */ +#define CRYS_PKA_ECDSA_NAF_BUFF_MAX_LENGTH_IN_WORDS (COUNT_NAF_WORDS_PER_KEY_WORD*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS + 1) + +#ifndef SSI_SUPPORT_ECC_SCA_SW_PROTECT +/* on fast SCA non protected mode required additional buffers for NAF key */ +/*! Scalar Buffer size in words */ +#define CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS (CRYS_PKA_ECDSA_NAF_BUFF_MAX_LENGTH_IN_WORDS+CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS+2) +#else +/*! Scalar Buffer size in words */ +#define CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS 1 /*(4*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS)*/ +#endif +/*! ECC temp buffer size in words */ +#define CRYS_PKA_ECPKI_BUILD_TMP_BUFF_MAX_LENGTH_IN_WORDS (3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS+CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) +/*! ECC sign temp buffer size in words */ +#define CRYS_PKA_ECDSA_SIGN_BUFF_MAX_LENGTH_IN_WORDS (6*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS+CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) +/*! ECC ecdh temp buffer size in words */ +#define CRYS_PKA_ECDH_BUFF_MAX_LENGTH_IN_WORDS (2*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS + CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) +/*! PKA KG temp buffer size in words */ +#define CRYS_PKA_KG_BUFF_MAX_LENGTH_IN_WORDS (2*CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS + CRYS_PKA_ECPKI_SCALAR_MUL_BUFF_MAX_LENGTH_IN_WORDS) +/*! ECC verify temp buffer size in words */ +#define CRYS_PKA_ECDSA_VERIFY_BUFF_MAX_LENGTH_IN_WORDS (3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS) + +/* *************************************************************************** */ +/*! Definitions of maximal size of modulus buffers for CRYS_EC_MONT and EC_EDW in bytes */ +#define CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_BYTES 32U /*!< \internal for Curve25519 */ +/*! Definitions of maximal size of modulus buffers for CRYS_EC_MONT and EC_EDW in words */ +#define CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS 8U /*!< \internal for Curve25519 */ +/*! ECC montgomery temp buffer size in words */ +#define CRYS_EC_MONT_TEMP_BUFF_SIZE_IN_32BIT_WORDS (8 * CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS) +/*! ECC edwards temp buffer size in words */ +#define CRYS_EC_EDW_TEMP_BUFF_SIZE_IN_32BIT_WORD (8*CRYS_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS + (sizeof(CRYS_HASHUserContext_t)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE) + +/** +@} + */ +/** +@} + */ +#endif /*_CRYS_PKA_DEFS_HW_H_*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly.h new file mode 100644 index 0000000..d8ad3e6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly.h @@ -0,0 +1,107 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the + CRYS POLY APIs, as well as the APIs themselves. +@defgroup crys_poly CryptoCell POLY APIs +@{ +@ingroup cryptocell_api + +*/ +#ifndef CRYS_POLY_H +#define CRYS_POLY_H + + +#include "ssi_pal_types.h" +#include "crys_error.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ +/*! POLY KEY size in words. */ +#define CRYS_POLY_KEY_SIZE_IN_WORDS 8 +/*! POLY KEY size in bytes. */ +#define CRYS_POLY_KEY_SIZE_IN_BYTES (CRYS_POLY_KEY_SIZE_IN_WORDS*SASI_32BIT_WORD_SIZE) + +/*! POLY MAC size in words. */ +#define CRYS_POLY_MAC_SIZE_IN_WORDS 4 +/*! POLY MAC size in bytes. */ +#define CRYS_POLY_MAC_SIZE_IN_BYTES (CRYS_POLY_MAC_SIZE_IN_WORDS*SASI_32BIT_WORD_SIZE) + +/************************ Typedefs ****************************/ + +/*! CHACHA MAC buffer definition. */ +typedef uint32_t CRYS_POLY_Mac_t[CRYS_POLY_MAC_SIZE_IN_WORDS]; + +/*! CHACHA key buffer definition. */ +typedef uint32_t CRYS_POLY_Key_t[CRYS_POLY_KEY_SIZE_IN_WORDS]; + +/************************ Public Functions **********************/ + +/****************************************************************************************************/ +/*! +@brief This function is used to perform the POLY MAC Calculation. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_poly_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_POLY( + CRYS_POLY_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ + uint8_t *pDataIn, /*!< [in] A pointer to the buffer of the input data to the CHACHA. + must not be null. */ + size_t dataInSize, /*!< [in] The size of the input data. must not be 0. */ + CRYS_POLY_Mac_t macRes /*!< [in/out] Pointer to the MAC result buffer.*/ +); + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef CRYS_POLY_H */ + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly_error.h new file mode 100644 index 0000000..0b89892 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_poly_error.h @@ -0,0 +1,89 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_POLY_ERROR_H +#define CRYS_POLY_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS POLY errors. +@defgroup crys_poly_error CryptoCell POLY specific errors +@{ +@ingroup crys_poly +*/ + + +/************************ Defines ******************************/ + +/*! The CRYS POLY module errors base address - 0x00F02500 */ +/*! Invalid key. */ +#define CRYS_POLY_KEY_INVALID_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x01UL) +/*! Invalid input data. */ +#define CRYS_POLY_DATA_INVALID_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal input data size. */ +#define CRYS_POLY_DATA_SIZE_INVALID_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x03UL) +/*! MAC calculation error. */ +#define CRYS_POLY_MAC_CALCULATION_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x04UL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif + + +/** +@} + */ + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd.h new file mode 100644 index 0000000..653768c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd.h @@ -0,0 +1,398 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RND_H +#define CRYS_RND_H + +#include "crys_error.h" +#include "ssi_aes.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains the CRYS APIs used for random number generation. +The random-number generation module implements referenced standard [SP800-90]. +@defgroup crys_rnd CryptoCell Random Generator APIs +@{ +@ingroup cryptocell_api +*/ + +/************************ Defines ******************************/ + +/*! Maximal reseed counter - indicates maximal number of +requests allowed between reseeds; according to NIST 800-90 +it is (2^48 - 1), our restriction is : (0xFFFFFFFF - 0xF).*/ +#define CRYS_RND_MAX_RESEED_COUNTER (0xFFFFFFFF - 0xF) + +/* Max size for one RNG generation (in bits) = + max_num_of_bits_per_request = 2^19 (FIPS 800-90 Tab.3) */ +/*! Maximal size of generated vector in bits. */ +#define CRYS_RND_MAX_GEN_VECTOR_SIZE_BITS 0x7FFFF +/*! Maximal size of generated vector in bytes. */ +#define CRYS_RND_MAX_GEN_VECTOR_SIZE_BYTES 0xFFFF + +/*! AES output block size in words. */ +#define CRYS_RND_AES_BLOCK_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS + + +/* RND seed and additional input sizes */ +/*! Maximal size of random seed in words. */ +#define CRYS_RND_SEED_MAX_SIZE_WORDS 12 + +#ifndef CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS +/*! Maximal size of additional input data in words. */ +#define CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS CRYS_RND_SEED_MAX_SIZE_WORDS +#endif + +/* allowed sizes of AES Key, in words */ +/*! AES key size (128 bits) in words. */ +#define CRYS_RND_AES_KEY_128_SIZE_WORDS 4 +/*! AES key size (192 bits) in words. */ +#define CRYS_RND_AES_KEY_192_SIZE_WORDS 6 +/*! AES key size (256 bits) in words. */ +#define CRYS_RND_AES_KEY_256_SIZE_WORDS 8 + +/* Definitions of temp buffer for RND_DMA version of CRYS_RND */ +/*******************************************************************/ +/* Definitions of temp buffer for DMA version of CRYS_RND */ + +/*! Temporary buffer size in words. */ +#define CRYS_RND_WORK_BUFFER_SIZE_WORDS 1528 + +/*! A definition for RAM buffer to be internally used in instantiation (or reseeding) operation. */ +typedef struct +{ + /*! Internal buffer*/ + uint32_t crysRndWorkBuff[CRYS_RND_WORK_BUFFER_SIZE_WORDS]; +}CRYS_RND_WorkBuff_t; + +/*! A definition for entropy estimation data type. */ +#define CRYS_RND_EntropyEstimatData_t CRYS_RND_WorkBuff_t +/*! A definition for entropy estimation buffer. */ +#define crysRndEntrIntBuff crysRndWorkBuff + + +/* RND source buffer inner (entrpopy) offset */ +/*! An internal offset definition. */ +#define CRYS_RND_TRNG_SRC_INNER_OFFSET_WORDS 2 +/*! An internal offset definition. */ +#define CRYS_RND_TRNG_SRC_INNER_OFFSET_BYTES (CRYS_RND_TRNG_SRC_INNER_OFFSET_WORDS*sizeof(uint32_t)) + + + + +/* Size of the expected output buffer used by FIPS KAT */ +/*! FIPS Known answer test output size. */ +#define CRYS_PRNG_FIPS_KAT_OUT_DATA_SIZE 64 + +/************************ Enumerators ****************************/ + +/*! Definition of random operation modes. */ +typedef enum +{ + /*! SW entropy estimation mode. */ + CRYS_RND_Fast = 0, + /*! Full entropy mode. */ + CRYS_RND_Slow = 1, + /*! Reserved. */ + CRYS_RND_ModeLast = 0x7FFFFFFF, +} CRYS_RND_mode_t; + + + +/************************ Structs *****************************/ + + +/* The internal state of DRBG mechanism based on AES CTR and CBC-MAC + algorithms. It is set as global data defined by the following + structure */ +/*! RND state structure. Includes internal data that needs to be saved between boots by the user.*/ +typedef struct +{ + /* Seed buffer, consists from concatenated Key||V: max size 12 words */ + /*! Random Seed buffer */ + uint32_t Seed[CRYS_RND_SEED_MAX_SIZE_WORDS]; + /* Previous value for continuous test */ + /*! Previous random data (used for continuous test). */ + uint32_t PreviousRandValue[SASI_AES_BLOCK_SIZE_IN_WORDS]; + + /* AdditionalInput buffer max size = seed max size words + 4w for padding*/ + /*! Previous additional input buffer. */ + uint32_t PreviousAdditionalInput[CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS+5]; + /*! Additional input buffer. */ + uint32_t AdditionalInput[CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS+4]; + /*! Additional input size in words. */ + uint32_t AddInputSizeWords; /* size of additional data set by user, words */ + + /*! Entropy source size in words */ + uint32_t EntropySourceSizeWords; + + /*! Reseed counter (32 bits active) - indicates number of requests for entropy + since instantiation or reseeding */ + uint32_t ReseedCounter; + + /*! Key size: 4 or 8 words according to security strength 128 bits or 256 bits*/ + uint32_t KeySizeWords; + + /* State flag (see definition of StateFlag above), containing bit-fields, defining: + - b'0: instantiation steps: 0 - not done, 1 - done; + - 2b'9,8: working or testing mode: 0 - working, 1 - KAT DRBG test, 2 - + KAT TRNG test; + b'16: flag defining is Previous random valid or not: + 0 - not valid, 1 - valid */ + /*! State flag used internally in the code.*/ + uint32_t StateFlag; + + /* Trng processing flag - indicates which ROSC lengths are: + - allowed (bits 0-3); + - total started (bits 8-11); + - processed (bits 16-19); + - started, but not processed (bits24-27) */ + /*! TRNG process state used internally in the code */ + uint32_t TrngProcesState; + + /* validation tag */ + /*! Validation tag used internally in the code */ + uint32_t ValidTag; + + /*! Rnd source entropy size in bits */ + uint32_t EntropySizeBits; + +} CRYS_RND_State_t; + + +/*! The RND Generate vector function pointer type definition. + The prototype intendent for External and CRYS internal RND functions + pointers definitions. + Full description can be found in ::CRYS_RND_GenerateVector function API. */ +typedef uint32_t (*SaSiRndGenerateVectWorkFunc_t)( \ + void *rndState_ptr, /*context*/ \ + uint16_t outSizeBytes, /*in*/ \ + uint8_t *out_ptr /*out*/); + + + +/*! Data structure required for internal FIPS verification for PRNG KAT. */ +typedef struct +{ + /*! Internal working buffer. */ + CRYS_RND_WorkBuff_t rndWorkBuff; + /*! Output buffer. */ + uint8_t rndOutputBuff[CRYS_PRNG_FIPS_KAT_OUT_DATA_SIZE]; +} CRYS_PrngFipsKatCtx_t; + + +/*****************************************************************************/ +/********************** Public Functions *************************/ +/*****************************************************************************/ + +/*! +@brief This function needs to be called once. +It calls CRYS_RND_Instantiation to initialize the TRNG and the primary RND context. +An initialized RND context is required for calling RND APIs and asymmetric cryptography key generation and signatures. +The primary context returned by this function can be used as a single global context for all RND needs. +Alternatively, other contexts may be initialized and used with a more limited scope (for specific applications or specific threads). + +\note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library, +this API is not thread-safe. + +@param[in/out] rnd_ctx - Pointer to the RND state structure. +@param[in/out] rndWorkBuff_ptr - Pointer to the RND scratch buffer. +*/ +CEXPORT_C CRYSError_t CRYS_RndInit(void* rnd_ctx, /*!< [in/out] Pointer to the RND state buffer, + allocated by the user. This state must be saved and provided + as parameter to any API that uses the RND module.*/ + CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in] Scratchpad for the RND module's work. */); + +/*! +@brief This function initializes the RND context. +It must be called at least once prior to using this context with any API that requires it as a parameter (e.g., other RND APIs, asymmetric +cryptography key generation and signatures). +It is called as part of ARM TrustZone CryptoCell library initialization, which initializes and returns the primary RND context. +This primary context can be used as a single global context for all RND needs. +Alternatively, other contexts may be initialized and used with a more limited scope (for specific applications or specific threads). +The call to this function must be followed by a call to ::CRYS_RND_SetGenerateVectorFunc API to set the generate vector function. +It implements referenced standard [SP800-90] - 10.2.1.3.2 - CTR-DRBG Instantiate algorithm using AES (FIPS-PUB 197) and Derivation Function (DF). +\note Additional data can be mixed with the random seed (personalization data or nonce). If required, this data should be provided by calling ::CRYS_RND_AddAdditionalInput prior to using this API. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_Instantiation( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state buffer allocated by the user, which is used to + maintain the RND state. This context state must be saved and provided as a + parameter to any API that uses the RND module. + \note the context must be cleared before sent to the function. */ + CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in/out] Scratchpad for the RND module's work. */ +); + + +/*! +@brief Clears existing RNG instantiation state. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_UnInstantiation( + void *rndState_ptr /*!< [in/out] Pointer to the RND context state buffer. */ +); + + +/*! +@brief This function is used for reseeding the RNG with additional entropy and additional user-provided input. +(additional data should be provided by calling ::CRYS_RND_AddAdditionalInput prior to using this API). +It implements referenced standard [SP800-90] - 10.2.1.4.2 - CTR-DRBG Reseeding algorithm, using AES (FIPS-PUB 197) and Derivation Function (DF). + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_Reseeding( + void *rndState_ptr, /*!< [in/out] Pointer to the RND context buffer. */ + CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in/out] Scratchpad for the RND module's work. */ +); + + +/****************************************************************************************/ +/*! +@brief Generates a random vector according to the algorithm defined in referenced standard [SP800-90] - 10.2.1.5.2 - CTR-DRBG. +The generation algorithm uses AES (FIPS-PUB 197) and Derivation Function (DF). + +\note +
        • The RND module must be instantiated prior to invocation of this API.
        • +
        • In the following cases, Reseeding operation must be performed prior to vector generation:
        • +
          • Prediction resistance is required.
          • +
          • The function returns CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR, stating that the Reseed Counter has passed its upper-limit (2^32-2).
        + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_GenerateVector( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure, which is part of the RND context structure. + Use rndContext->rndState field of the context for this parameter. */ + uint16_t outSizeBytes, /*!< [in] The size in bytes of the random vector required. The maximal size is 2^16 -1 bytes. */ + uint8_t *out_ptr /*!< [out] The pointer to output buffer. */ +); + + + +/**********************************************************************************************************/ +/*! +@brief Generates a random vector with specific limitations by testing candidates (described and used in FIPS 186-4: B.1.2, B.4.2 etc.). + +This function draws a random vector, compare it to the range limits, and if within range - return it in rndVect_ptr. +If outside the range, the function continues retrying until a conforming vector is found, or the maximal retries limit is exceeded. +If maxVect_ptr is provided, rndSizeInBits specifies its size, and the output vector must conform to the range [1 < rndVect < maxVect]. +If maxVect_ptr is NULL, rndSizeInBits specifies the exact required vector size, and the output vector must be the exact same +bit size (with its most significant bit = 1). +\note +The RND module must be instantiated prior to invocation of this API. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_GenerateVectorInRange( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + uint32_t rndSizeInBits, /*!< [in] The size in bits of the random vector required. The allowed size in range 2 <= rndSizeInBits < 2^19-1, bits. */ + uint8_t *maxVect_ptr, /*!< [in] Pointer to the vector defining the upper limit for the random vector output, Given as little-endian byte array. + If not NULL, its actual size is treated as [(rndSizeInBits+7)/8] bytes and its value must be in range (3, 2^19) */ + uint8_t *rndVect_ptr /*!< [in/out] Pointer to the output buffer for the random vector. Must be at least [(rndSizeInBits+7)/8] bytes. + Treated as little-endian byte array. */ +); + + +/*************************************************************************************/ +/*! +@brief Used for adding additional input/personalization data provided by the user, +to be later used by the ::CRYS_RND_Instantiation/::CRYS_RND_Reseeding/::CRYS_RND_GenerateVector functions. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_AddAdditionalInput( + void *rndState_ptr, /*!< [in/out] Pointer to the RND context state buffer. */ + uint8_t *additonalInput_ptr, /*!< [in] The Additional Input buffer. */ + uint16_t additonalInputSize /*!< [in] The size of the Additional Input buffer. It must + be <= CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS and a multiple of 4. */ +); + +/*! +@brief The CRYS_RND_EnterKatMode function sets KAT mode bit into StateFlag of global CRYS_RND_WorkingState structure. + +The user must call this function before calling functions performing KAT tests. + +\note Total size of entropy and nonce must be not great than 126 words (maximal size of entropy and nonce). + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_EnterKatMode( + void *rndState_ptr, /*!< [in/out] Pointer to the RND context state buffer. */ + uint8_t *entrData_ptr, /*!< [in] Entropy data. */ + uint32_t entrSize, /*!< [in] Entropy size in bytes. */ + uint8_t *nonce_ptr, /*!< [in] Nonce. */ + uint32_t nonceSize, /*!< [in] Entropy size in bytes. */ + CRYS_RND_WorkBuff_t *workBuff_ptr /*!< [out] RND working buffer, must be the same buffer, which should be passed into + Instantiation/Reseeding functions. */ +); + +/**********************************************************************************************************/ +/*! +@brief The CRYS_RND_DisableKatMode function disables KAT mode bit into StateFlag of global CRYS_RND_State_t structure. + +The user must call this function after KAT tests before actual using RND module (Instantiation etc.). + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C void CRYS_RND_DisableKatMode( + void *rndState_ptr /*!< [in/out] Pointer to the RND state buffer. */ +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef CRYS_RND_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd_error.h new file mode 100644 index 0000000..417eaff --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rnd_error.h @@ -0,0 +1,160 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RND_ERROR_H +#define CRYS_RND_ERROR_H + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/*! +@file +@brief This module contains the definitions of the CRYS RND errors. +@defgroup crys_rnd_error CryptoCell RND specific errors +@{ +@ingroup crys_rnd +*/ + + + +/************************ Defines ******************************/ +/*! RND module on the CRYS layer base address - 0x00F00C00 */ + +/*! Illegal output pointer.*/ +#define CRYS_RND_DATA_OUT_POINTER_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x0UL) +/*! Random generation in range failed .*/ +#define CRYS_RND_CAN_NOT_GENERATE_RAND_IN_RANGE (CRYS_RND_MODULE_ERROR_BASE + 0x1UL) +/*! CPRNGT test failed.*/ +#define CRYS_RND_CPRNG_TEST_FAIL_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal additional data buffer. */ +#define CRYS_RND_ADDITIONAL_INPUT_BUFFER_NULL (CRYS_RND_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal additional data size. */ +#define CRYS_RND_ADDITIONAL_INPUT_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x4UL) +/*! Data size overflow. */ +#define CRYS_RND_DATA_SIZE_OVERFLOW_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal vector size. */ +#define CRYS_RND_VECTOR_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x6UL) +/*! Reseed counter overflow - in case this error was returned instantiation or reseeding operation must be called. */ +#define CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x7UL) +/*! Instantiation was not yet called. */ +#define CRYS_RND_INSTANTIATION_NOT_DONE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x8UL) +/*! TRNG loss of samples. */ +#define CRYS_RND_TRNG_LOSS_SAMPLES_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x9UL) +/*! TRNG Time exceeded limitations. */ +#define CRYS_RND_TRNG_TIME_EXCEED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xAUL) +/*! TRNG loss of samples and time exceeded limitations. */ +#define CRYS_RND_TRNG_LOSS_SAMPLES_AND_TIME_EXCEED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xBUL) +/*! RND is in Known Answer Test mode. */ +#define CRYS_RND_IS_KAT_MODE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xCUL) +/*! RND operation not supported. */ +#define CRYS_RND_OPERATION_IS_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xDUL) +/*! RND validity check failed. */ +#define CRYS_RND_STATE_VALIDATION_TAG_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xEUL) +/*! RND is not supported. */ +#define CRYS_RND_IS_NOT_SUPPORTED (CRYS_RND_MODULE_ERROR_BASE + 0xFUL) +/*! RND Init failed. */ +#define CRYS_RND_INIT_FAILED (CRYS_RND_MODULE_ERROR_BASE + 0x10UL) +/*! RND Init failed. */ +#define CRYS_RND_STARTUP_FAILED (CRYS_RND_MODULE_ERROR_BASE + 0x11UL) +/*! Instantiation Failed. */ +#define CRYS_RND_INSTANTIATION_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x12L) + + +/*! Illegal generate vector function pointer. */ +#define CRYS_RND_GEN_VECTOR_FUNC_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x14UL) + +/*! Illegal work buffer pointer. */ +#define CRYS_RND_WORK_BUFFER_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x20UL) +/*! Illegal AES key size. */ +#define CRYS_RND_ILLEGAL_AES_KEY_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x21UL) +/*! Illegal data pointer. */ +#define CRYS_RND_ILLEGAL_DATA_PTR_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x22UL) +/*! Illegal data size. */ +#define CRYS_RND_ILLEGAL_DATA_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x23UL) +/*! Illegal parameter. */ +#define CRYS_RND_ILLEGAL_PARAMETER_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x24UL) +/*! Illegal RND state pointer. */ +#define CRYS_RND_STATE_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x25UL) +/*! TRNG errors. */ +#define CRYS_RND_TRNG_ERRORS_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x26UL) +/*! Illegal context pointer. */ +#define CRYS_RND_CONTEXT_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x27UL) + +/*! Illegal output vector pointer. */ +#define CRYS_RND_VECTOR_OUT_PTR_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x30UL) +/*! Illegal output vector size. */ +#define CRYS_RND_VECTOR_OUT_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x31UL) +/*! Maximal vector size is too small. */ +#define CRYS_RND_MAX_VECTOR_IS_TOO_SMALL_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x32UL) +/*! Illegal Known Answer Tests parameters. */ +#define CRYS_RND_KAT_DATA_PARAMS_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x33UL) +/*! TRNG Known Answer Test not supported. */ +#define CRYS_RND_TRNG_KAT_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x34UL) +/*! SRAM memory is not defined. */ +#define CRYS_RND_SRAM_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x35UL) +/*! AES operation failure. */ +#define CRYS_RND_AES_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x36UL) + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_build.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_build.h similarity index 61% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_build.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_build.h index 164d2e1..a48e46f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_build.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_build.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RSA_BUILD_H @@ -23,8 +47,17 @@ extern "C" #endif /*! +@defgroup crys_rsa CryptoCell RSA APIs +@{ +@ingroup cryptocell_api +@brief This group is the cryptocell ECC root group +@} + @file @brief This module defines some utility functions for working with RSA cryptography. +@defgroup crys_rsa_build CryptoCell RSA Utility APIs +@{ +@ingroup crys_rsa */ /******************************************************************************************/ @@ -39,7 +72,7 @@ CIMPORT_C CRYSError_t CRYS_RSA_Build_PubKey( uint8_t *Exponent_ptr, /*!< [in] Pointer to the exponent stream of bytes (Big-Endian format). */ uint16_t ExponentSize, /*!< [in] The size of the exponent (in bytes). */ uint8_t *Modulus_ptr, /*!< [in] Pointer to the modulus stream of bytes (Big-Endian format). - The most significant bit (MSB) must be set to '1'. */ + The most significant bit (MSB) must be set to '1'. */ uint16_t ModulusSize /*!< [in] The modulus size in bytes. Supported sizes are 64, 128, 256, 384 and 512. */ ); @@ -58,7 +91,7 @@ CIMPORT_C CRYSError_t CRYS_RSA_Build_PrivKey( uint8_t *PubExponent_ptr, /*!< [in] Pointer to the public exponent stream of bytes (Big-Endian format). */ uint16_t PubExponentSize, /*!< [in] The size of the public exponent (in bytes). */ uint8_t *Modulus_ptr, /*!< [in] Pointer to the modulus stream of bytes (Big-Endian format). - The most significant bit must be set to '1'. */ + The most significant bit must be set to '1'. */ uint16_t ModulusSize /*!< [in] The modulus size in bytes. Supported sizes are 64, 128, 256, 384 and 512. */ ); @@ -76,10 +109,10 @@ CIMPORT_C CRYSError_t CRYS_RSA_Build_PrivKeyCRT( uint8_t *Q_ptr, /*!< [in] Pointer to the second factor stream of bytes (Big-Endian format). */ uint16_t QSize, /*!< [in] The size of the second factor (in bytes). */ uint8_t *dP_ptr, /*!< [in] Pointer to the first factor's CRT exponent stream of bytes - (Big-Endian format). */ + (Big-Endian format). */ uint16_t dPSize, /*!< [in] The size of the first factor's CRT exponent (in bytes). */ uint8_t *dQ_ptr, /*!< [in] Pointer to the second factor's CRT exponent stream of bytes - (Big-Endian format). */ + (Big-Endian format). */ uint16_t dQSize, /*!< [in] The size of the second factor's CRT exponent (in bytes). */ uint8_t *qInv_ptr, /*!< [in] Pointer to the first CRT coefficient stream of bytes (Big-Endian format). */ uint16_t qInvSize /*!< [in] The size of the first CRT coefficient (in bytes). */ @@ -102,16 +135,18 @@ CIMPORT_C CRYSError_t CRYS_RSA_Get_PubKey( CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] A pointer to the public key structure. */ uint8_t *Exponent_ptr, /*!< [out] A pointer to the exponent stream of bytes (Big-Endian format). */ uint16_t *ExponentSize_ptr, /*!< [in/out] the size of the exponent buffer in bytes, - it is updated to the actual size of the exponent, in bytes. */ + it is updated to the actual size of the exponent, in bytes. */ uint8_t *Modulus_ptr, /*!< [out] A pointer to the modulus stream of bytes (Big-Endian format). - The MS (most significant) bit must be set to '1'. */ + The MS (most significant) bit must be set to '1'. */ uint16_t *ModulusSize_ptr /*!< [in/out] the size of the modulus buffer in bytes, it is updated to the actual - size of the modulus, in bytes. */ + size of the modulus, in bytes. */ ); #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_error.h similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_error.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_error.h index 6d14b88..0f8f8d9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_error.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_error.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RSA_ERROR_H @@ -22,122 +46,209 @@ extern "C" #endif /*! @file -* @brief This module contains the definitions of the CRYS RSA errors. +@brief This module contains the definitions of the CRYS RSA errors. +@defgroup crys_rsa_error CryptoCell RSA specific errors +@{ +@ingroup crys_rsa */ /************************ Defines ******************************/ -/* PKI RSA module on the CRYS layer base address - 0x00F00400 */ +/*! CRYS RSA module on the CRYS layer base address - 0x00F00400 */ -/* The CRYS RSA module errors */ +/*! The CRYS RSA module errors */ +/*! Illegal modulus size. */ #define CRYS_RSA_INVALID_MODULUS_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0x0UL) +/*! Illegal modulus pointer. */ #define CRYS_RSA_INVALID_MODULUS_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x1UL) +/*! Illegal exponent pointer. */ #define CRYS_RSA_INVALID_EXPONENT_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal public key structure pointer. */ #define CRYS_RSA_INVALID_PUB_KEY_STRUCT_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal private key structure pointer. */ #define CRYS_RSA_INVALID_PRIV_KEY_STRUCT_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal exponent value. */ #define CRYS_RSA_INVALID_EXPONENT_VAL (CRYS_RSA_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal exponent size. */ #define CRYS_RSA_INVALID_EXPONENT_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0x6UL) +/*! Illegal CRT first factor pointer (P_ptr) . */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x7UL) +/*! Illegal CRT second factor pointer (Q_ptr) . */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x8UL) +/*! Illegal CRT first exponent factor pointer (dP_ptr) . */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_EXP_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x9UL) +/*! Illegal CRT second exponent factor pointer (dQ_ptr) . */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_EXP_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0xAUL) +/*! Illegal CRT coefficient pointer (qInv_ptr) . */ #define CRYS_RSA_INVALID_CRT_COEFFICIENT_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0xBUL) +/*! Illegal CRT first factor size (Psize). */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0xCUL) +/*! Illegal CRT second factor size (Qsize). */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0xDUL) +/*! Illegal CRT first and second factor size (Psize + Qsize). */ #define CRYS_RSA_INVALID_CRT_FIRST_AND_SECOND_FACTOR_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0xEUL) +/*! Illegal CRT first factor exponent value (dP). */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_EXPONENT_VAL (CRYS_RSA_MODULE_ERROR_BASE + 0xFUL) +/*! Illegal CRT first factor exponent value (dQ). */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_EXPONENT_VAL (CRYS_RSA_MODULE_ERROR_BASE + 0x10UL) +/*! Illegal CRT coefficient value (qInv). */ #define CRYS_RSA_INVALID_CRT_COEFF_VAL (CRYS_RSA_MODULE_ERROR_BASE + 0x11UL) +/*! Illegal data in. */ #define CRYS_RSA_DATA_POINTER_INVALID_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x12UL) +/*! Illegal message data size. */ #define CRYS_RSA_INVALID_MESSAGE_DATA_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0x13UL) +/*! Illegal message value. */ #define CRYS_RSA_INVALID_MESSAGE_VAL (CRYS_RSA_MODULE_ERROR_BASE + 0x14UL) +/*! Modulus even error. */ #define CRYS_RSA_MODULUS_EVEN_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x15UL) +/*! Illegal context pointer. */ #define CRYS_RSA_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x16UL) +/*! Illegal hash operation mode. */ #define CRYS_RSA_HASH_ILLEGAL_OPERATION_MODE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x17UL) +/*! Illegal MGF value. */ #define CRYS_RSA_MGF_ILLEGAL_ARG_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x18UL) +/*! Illegal PKCS1 version. */ #define CRYS_RSA_PKCS1_VER_ARG_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x19UL) +/*! Invalid private key. */ #define CRYS_RSA_PRIV_KEY_VALIDATION_TAG_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x1AUL) +/*! Invalid public key. */ #define CRYS_RSA_PUB_KEY_VALIDATION_TAG_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x1BUL) +/*! Invalid context. */ #define CRYS_RSA_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x1CUL) +/*! Illegal output pointer. */ #define CRYS_RSA_INVALID_OUTPUT_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x1DUL) +/*! Illegal output size pointer. */ #define CRYS_RSA_INVALID_OUTPUT_SIZE_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x1FUL) +/*! Illegal temporary buffer pointer. */ #define CRYS_RSA_CONV_TO_CRT_INVALID_TEMP_BUFF_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x20UL) +/*! OAEP encode parameter string is too long. */ #define CRYS_RSA_BASE_OAEP_ENCODE_PARAMETER_STRING_TOO_LONG (CRYS_RSA_MODULE_ERROR_BASE + 0x22UL) +/*! OAEP decode parameter string is too long. */ #define CRYS_RSA_BASE_OAEP_DECODE_PARAMETER_STRING_TOO_LONG (CRYS_RSA_MODULE_ERROR_BASE + 0x23UL) +/*! OAEP encode message is too long. */ #define CRYS_RSA_BASE_OAEP_ENCODE_MESSAGE_TOO_LONG (CRYS_RSA_MODULE_ERROR_BASE + 0x24UL) +/*! OAEP decode message is too long. */ #define CRYS_RSA_BASE_OAEP_DECODE_MESSAGE_TOO_LONG (CRYS_RSA_MODULE_ERROR_BASE + 0x25UL) +/*! Illegal key generation data struct pointer. */ #define CRYS_RSA_KEY_GEN_DATA_STRUCT_POINTER_INVALID (CRYS_RSA_MODULE_ERROR_BASE + 0x26UL) +/*! Illegal PRIM data struct pointer. */ #define CRYS_RSA_PRIM_DATA_STRUCT_POINTER_INVALID (CRYS_RSA_MODULE_ERROR_BASE + 0x27UL) +/*! Illegal message buffer size. */ #define CRYS_RSA_INVALID_MESSAGE_BUFFER_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0x28UL) +/*! Illegal signature buffer size. */ #define CRYS_RSA_INVALID_SIGNATURE_BUFFER_SIZE (CRYS_RSA_MODULE_ERROR_BASE + 0x29UL) +/*! Illegal modulus size pointer. */ #define CRYS_RSA_INVALID_MOD_BUFFER_SIZE_POINTER (CRYS_RSA_MODULE_ERROR_BASE + 0x2AUL) +/*! Illegal exponent size pointer. */ #define CRYS_RSA_INVALID_EXP_BUFFER_SIZE_POINTER (CRYS_RSA_MODULE_ERROR_BASE + 0x2BUL) +/*! Illegal signature pointer. */ #define CRYS_RSA_INVALID_SIGNATURE_BUFFER_POINTER (CRYS_RSA_MODULE_ERROR_BASE + 0x2CUL) +/*! Wrong private key type. */ #define CRYS_RSA_WRONG_PRIVATE_KEY_TYPE (CRYS_RSA_MODULE_ERROR_BASE + 0x2DUL) +/*! Illegal CRT first factor size pointer (Psize) . */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_SIZE_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x2EUL) +/*! Illegal CRT second factor size pointer (Qsize) . */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_SIZE_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x2FUL) +/*! Illegal CRT first factor exponent size pointer (dPsize) . */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_EXP_SIZE_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x30UL) +/*! Illegal CRT second factor exponent size pointer (dQsize) . */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_EXP_SIZE_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x31UL) -#define CRYS_RSA_INVALID_CRT_COEFFICIENT_SIZE_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x32UL) +/*! Illegal CRT coefficient size pointer (qInvsize) . */ +#define CRYS_RSA_INVALID_CRT_COEFFICIENT_SIZE_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x32UL) +/*! Illegal CRT first factor size (Psize) . */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x33UL) +/*! Illegal CRT second factor size (Qsize) . */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x34UL) +/*! Illegal CRT first factor exponent size (dPsize) . */ #define CRYS_RSA_INVALID_CRT_FIRST_FACTOR_EXP_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x35UL) +/*! Illegal CRT second factor exponent size (dQsize) . */ #define CRYS_RSA_INVALID_CRT_SECOND_FACTOR_EXP_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x36UL) -#define CRYS_RSA_INVALID_CRT_COEFFICIENT_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x37UL) -#define CRYS_RSA_KEY_GEN_CONDITIONAL_TEST_FAIL_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x38UL) - -#define CRYS_RSA_CAN_NOT_GENERATE_RAND_IN_RANGE (CRYS_RSA_MODULE_ERROR_BASE + 0x39UL) +/*! Illegal CRT coefficient size (qInvsize) . */ +#define CRYS_RSA_INVALID_CRT_COEFFICIENT_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x37UL) +/*! Key generation conditional test failed. */ +#define CRYS_RSA_KEY_GEN_CONDITIONAL_TEST_FAIL_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x38UL) + +/*! Random generation in range failed. */ +#define CRYS_RSA_CAN_NOT_GENERATE_RAND_IN_RANGE (CRYS_RSA_MODULE_ERROR_BASE + 0x39UL) +/*! Illegal CRT parameter size. */ #define CRYS_RSA_INVALID_CRT_PARAMETR_SIZE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x3AUL) +/*! Illegal modulus. */ #define CRYS_RSA_INVALID_MODULUS_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x40UL) +/*! Illegal pointer. */ #define CRYS_RSA_INVALID_PTR_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x41UL) +/*! Illegal decryption mode. */ #define CRYS_RSA_INVALID_DECRYPRION_MODE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x42UL) +/*! Illegal generated private key. */ #define CRYS_RSA_GENERATED_PRIV_KEY_IS_TOO_LOW (CRYS_RSA_MODULE_ERROR_BASE + 0x43UL) +/*! Key generation error. */ #define CRYS_RSA_KEY_GENERATION_FAILURE_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x44UL) +/*! Internal error. */ +#define CRYS_RSA_INTERNAL_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x45UL) /**************************************************************************************** * PKCS#1 VERSION 1.5 ERRORS ****************************************************************************************/ +/*! BER encoding passed. */ #define CRYS_RSA_BER_ENCODING_OK CRYS_OK +/*! Error in BER parsing. */ #define CRYS_RSA_ERROR_BER_PARSING (CRYS_RSA_MODULE_ERROR_BASE+0x51UL) +/*! Error in PKCS15 message. */ #define CRYS_RSA_ENCODE_15_MSG_OUT_OF_RANGE (CRYS_RSA_MODULE_ERROR_BASE+0x52UL) +/*! Error in PKCS15 PS. */ #define CRYS_RSA_ENCODE_15_PS_TOO_SHORT (CRYS_RSA_MODULE_ERROR_BASE+0x53UL) +/*! PKCS15 block type is not supported. */ #define CRYS_RSA_PKCS1_15_BLOCK_TYPE_NOT_SUPPORTED (CRYS_RSA_MODULE_ERROR_BASE+0x54UL) +/*! Error in PKCS15 decrypted block parsing. */ #define CRYS_RSA_15_ERROR_IN_DECRYPTED_BLOCK_PARSING (CRYS_RSA_MODULE_ERROR_BASE+0x55UL) +/*! Error in random operation. */ #define CRYS_RSA_ERROR_IN_RANDOM_OPERATION_FOR_ENCODE (CRYS_RSA_MODULE_ERROR_BASE+0x56UL) +/*! PKCS15 verification failed. */ #define CRYS_RSA_ERROR_VER15_INCONSISTENT_VERIFY (CRYS_RSA_MODULE_ERROR_BASE+0x57UL) +/*! Illegal message size (in no hash operation case). */ #define CRYS_RSA_INVALID_MESSAGE_DATA_SIZE_IN_NO_HASH_CASE (CRYS_RSA_MODULE_ERROR_BASE+0x58UL) -#define CRYS_RSA_INVALID_MESSAGE_DATA_SIZE_IN_SSL_CASE (CRYS_RSA_MODULE_ERROR_BASE+0x59UL) -#define CRYS_RSA_PKCS15_VERIFY_BER_ENCODING_HASH_TYPE (CRYS_RSA_MODULE_ERROR_BASE+0x60UL) /*!< \internal PKCS#1 Ver 1.5 verify hash input inconsistent with hash mode derived from signature*/ +/*! Illegal message size. */ +#define CRYS_RSA_INVALID_MESSAGE_DATA_SIZE_IN_SSL_CASE (CRYS_RSA_MODULE_ERROR_BASE+0x59UL) +/*! PKCS#1 Ver 1.5 verify hash input inconsistent with hash mode derived from signature. */ +#define CRYS_RSA_PKCS15_VERIFY_BER_ENCODING_HASH_TYPE (CRYS_RSA_MODULE_ERROR_BASE+0x60UL) +/*! Illegal DER hash mode */ #define CRYS_RSA_GET_DER_HASH_MODE_ILLEGAL (CRYS_RSA_MODULE_ERROR_BASE+0x61UL) /**************************************************************************************** * PKCS#1 VERSION 2.1 ERRORS ****************************************************************************************/ +/*! Illegal salt length. */ #define CRYS_RSA_PSS_ENCODING_MODULUS_HASH_SALT_LENGTHS_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x80UL) +/*! Illegal MGF mask. */ #define CRYS_RSA_BASE_MGF_MASK_TOO_LONG (CRYS_RSA_MODULE_ERROR_BASE+0x81UL) +/*! PSS verification failed. */ #define CRYS_RSA_ERROR_PSS_INCONSISTENT_VERIFY (CRYS_RSA_MODULE_ERROR_BASE+0x82UL) +/*! OAEP message too long. */ #define CRYS_RSA_OAEP_VER21_MESSAGE_TOO_LONG (CRYS_RSA_MODULE_ERROR_BASE+0x83UL) +/*! OAEP error in decrypted block parsing. */ #define CRYS_RSA_ERROR_IN_DECRYPTED_BLOCK_PARSING (CRYS_RSA_MODULE_ERROR_BASE+0x84UL) +/*! OAEP decoding error. */ #define CRYS_RSA_OAEP_DECODE_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x85UL) +/*! Error in decrypted data size. */ #define CRYS_RSA_15_ERROR_IN_DECRYPTED_DATA_SIZE (CRYS_RSA_MODULE_ERROR_BASE+0x86UL) +/*! Error in decrypted data. */ #define CRYS_RSA_15_ERROR_IN_DECRYPTED_DATA (CRYS_RSA_MODULE_ERROR_BASE+0x87UL) +/*! Illegal L pointer. */ #define CRYS_RSA_OAEP_L_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x88UL) +/*! Illegal output size. */ #define CRYS_RSA_DECRYPT_INVALID_OUTPUT_SIZE (CRYS_RSA_MODULE_ERROR_BASE+0x89UL) +/*! Illegal output size pointer. */ #define CRYS_RSA_DECRYPT_OUTPUT_SIZE_POINTER_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x8AUL) - -#define CRYS_RSA_HOST_MSG_GENERAL_RPC_A_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x90UL) -#define CRYS_RSA_HOST_MSG_GENERAL_RPC_B_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x91UL) -#define CRYS_RSA_HOST_MSG_GENERAL_RPC_C_ERROR (CRYS_RSA_MODULE_ERROR_BASE+0x92UL) - +/*! Illegal parameters. */ #define CRYS_RSA_ILLEGAL_PARAMS_ACCORDING_TO_PRIV_ERROR (CRYS_RSA_MODULE_ERROR_BASE + 0x93UL) +/*! RSA is not supported. */ #define CRYS_RSA_IS_NOT_SUPPORTED (CRYS_RSA_MODULE_ERROR_BASE+0xFFUL) @@ -158,7 +269,9 @@ extern "C" #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_kg.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_kg.h new file mode 100644 index 0000000..2ea2e47 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_kg.h @@ -0,0 +1,129 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RSA_KG_H +#define CRYS_RSA_KG_H + +#include "crys_rsa_types.h" +#include "crys_rnd.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief Generates a RSA pair of public and private keys. +@defgroup crys_rsa_kg CryptoCell RSA key generation APIs +@{ +@ingroup crys_rsa +*/ + +/************************ Defines ******************************/ + +/* Max allowed size and values of public exponent for key generation in CRYS */ +/*! Maximal public exponent size in bits. */ +#define CRYS_RSA_KG_PUB_EXP_MAX_SIZE_BITS 17 +/*! Definition of public exponent value. */ +#define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_1 0x000003 +/*! Definition of public exponent value. */ +#define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_2 0x000011 +/*! Definition of public exponent value. */ +#define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_3 0x010001 + + + + +/***********************************************************************************************/ + +/*! +@brief CRYS_RSA_KG_GenerateKeyPair generates a Pair of public and private keys on non CRT mode according to [ANS X9.31]. + +\note To be FIPS 186-4 [5.1] compliant use only the following key sizes (in bits): 1024, 2048 and 3072. + +@return CRYS_OK on success. +@return A non-zero value from crys_rsa_error.h or crys_rnd_error.h on failure. + +*/ + +CIMPORT_C CRYSError_t CRYS_RSA_KG_GenerateKeyPair( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + uint8_t *pubExp_ptr, /*!< [in] The pointer to the public exponent (public key). */ + uint16_t pubExpSizeInBytes, /*!< [in] The public exponent size in bytes. */ + uint32_t keySize, /*!< [in] The size of the key, in bits. Supported sizes are + 512, 1024, 2048, 3072 and 4096 bit. */ + CRYS_RSAUserPrivKey_t *userPrivKey_ptr, /*!< [out] Pointer to the private key structure. */ + CRYS_RSAUserPubKey_t *userPubKey_ptr, /*!< [out] Pointer to the public key structure. */ + CRYS_RSAKGData_t *keyGenData_ptr, /*!< [in] Pointer to a temporary structure required for the KeyGen operation. */ + CRYS_RSAKGFipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ +); + +/***********************************************************************************************/ +/*! +@brief Generates a pair of public and private keys on CRT mode according to [ANS X9.31]. + +\note To be FIPS 186-4 [5.1] compliant use only the following key sizes (in bits): 1024, 2048 and 3072. + +@return CRYS_OK on success. +@return A non-zero value from crys_rsa_error.h or crys_rnd_error.h on failure. +*/ + +CIMPORT_C CRYSError_t CRYS_RSA_KG_GenerateKeyPairCRT( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + uint8_t *pubExp_ptr, /*!< [in] The pointer to the public exponent (public key). */ + uint16_t pubExpSizeInBytes, /*!< [in] The public exponent size in bytes. */ + uint32_t keySize, /*!< [in] The size of the key, in bits. Supported sizes are + 512, 1024, 2048, 3072 and 4096 bit. */ + CRYS_RSAUserPrivKey_t *userPrivKey_ptr, /*!< [out] Pointer to the private key structure. */ + CRYS_RSAUserPubKey_t *userPubKey_ptr, /*!< [out] Pointer to the public key structure. */ + CRYS_RSAKGData_t *keyGenData_ptr, /*!< [in] Pointer to a temporary structure required for the KeyGen operation. */ + CRYS_RSAKGFipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_prim.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_prim.h new file mode 100644 index 0000000..6712086 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_prim.h @@ -0,0 +1,125 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RSA_PRIM_H +#define CRYS_RSA_PRIM_H + +#include "crys_rsa_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module defines the API that implements the [PKCS1_2.1] primitive functions. +@defgroup crys_rsa_prim CryptoCell RSA primitive APIs +@{ +@ingroup crys_rsa + + +\note Direct use of primitive functions, rather than schemes to protect data, is strongly discouraged as primitive functions are +susceptible to well-known attacks. +*/ + + + +/**********************************************************************************/ +/*! +@brief Implements the RSAEP algorithm, as defined in [PKCS1_2.1] - 6.1.1. + +@return CRYS_OK on success. +@return A non-zero value from crys_rsa_error.h on failure. + */ +CIMPORT_C CRYSError_t CRYS_RSA_PRIM_Encrypt( + CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] Pointer to the public key data structure. */ + CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure containing internal buffers. */ + uint8_t *Data_ptr, /*!< [in] Pointer to the data to encrypt. */ + uint16_t DataSize, /*!< [in] The size (in bytes) of input data must be ≤ modulus size. If is smaller, + then the function padds it by zeros on left side up to the modulus size + and therefore, after further decrypt operation, its result will contain + zero-padding also. If the function is used for recovering the plain data + from result of inverse function (CRYS_RSA_PRIM_Decrypt), the input size + must be equal to modulus size exactly. */ + uint8_t *Output_ptr /*!< [out] Pointer to the encrypted data. The buffer size must be ≥ the modulus size. */ +); + + +/**********************************************************************************/ +/*! +@brief Implements the RSADP algorithm, as defined in [PKCS1_2.1] - 6.1.2. + +@return CRYS_OK on success. +@return A non-zero value from crys_rsa_error.h on failure. + +*/ +CIMPORT_C CRYSError_t CRYS_RSA_PRIM_Decrypt( + CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to the private key data structure. + The key representation (pair or quintuple) and hence the RSA algorithm + (CRT or not-CRT) is determined by enum value in the structure + ::CRYS_RSA_Build_PrivKey or ::CRYS_RSA_Build_PrivKeyCRT. */ + CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure containing internal buffers required for + the RSA operation. */ + uint8_t *Data_ptr, /*!< [in] Pointer to the data to be decrypted. */ + uint16_t DataSize, /*!< [in] The size (in bytes) of input data must be ≤ modulus size. + If the size is smaller (not recommendet), then the data will be zero-padded + by the function on left side up to the modulus size and therefore, after further + decrypt operation,its result will contain zero-padding also. If the function is used + for recovering the plain data from result of inverse function (CRYS_RSA_PRIM_Encrypt), + the input size must be equal to modulus size exactly. */ + uint8_t *Output_ptr /*!< [out] Pointer to the decrypted data. The buffer size must be ≤ the modulus size. */ +); + + +/*! +@brief Implements the RSASP1 algorithm, as defined in [PKCS1_2.1] - 6.2.1, as a call to ::CRYS_RSA_PRIM_Decrypt, +since the signature primitive is identical to the decryption primitive. +*/ +#define CRYS_RSA_PRIM_Sign CRYS_RSA_PRIM_Decrypt + +/*! +@brief Implements the RSAVP1 algorithm, as defined in [PKCS1_2.1] - 6.2.2, as a call to ::CRYS_RSA_PRIM_Encrypt. +*/ +#define CRYS_RSA_PRIM_Verify CRYS_RSA_PRIM_Encrypt + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_schemes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_schemes.h similarity index 56% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_schemes.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_schemes.h index 2cbf072..be26af2 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_schemes.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_schemes.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RSA_SCHEMES_H @@ -26,6 +50,9 @@ extern "C" /*! @file @brief This module defines APIs that support [PKCS1_1.5] and [PKCS1_2.1] encryption and signature schemes. +@defgroup crys_rsa_schemes CryptoCell RSA encryption and signature schemes +@{ +@ingroup crys_rsa */ /**********************************************************************************************************/ @@ -35,21 +62,22 @@ extern "C" It should not be called directly. Instead, use macros ::CRYS_RSA_OAEP_Encrypt or ::CRYS_RSA_PKCS1v15_Encrypt. @return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. +@return A non-zero value from crys_rsa_error.h, crys_rnd_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t SaSi_RsaSchemesEncrypt( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] Pointer to the public key data structure. */ CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure that is internally used as workspace for the - Encryption operation. */ + Encryption operation. */ CRYS_RSA_HASH_OpMode_t hashFunc, /*!< [in] The HASH function to be used. One of the supported SHA-x HASH modes, as defined - in ::CRYS_RSA_HASH_OpMode_t (MD5 is not supported).*/ + in ::CRYS_RSA_HASH_OpMode_t (MD5 is not supported).*/ uint8_t *L, /*!< [in] The label input pointer. Relevant for [PKCS1_2.1] only. NULL by default. - NULL for [PKCS1_1.5]. */ + NULL for [PKCS1_1.5]. */ uint16_t Llen, /*!< [in] The label length. Relevant for [PKCS1_2.1] only. Zero by default. - Must be <=2048. Zero for [PKCS1_1.5]. */ + Must be <=2048. Zero for [PKCS1_1.5]. */ CRYS_PKCS1_MGF_t MGF, /*!< [in] The mask generation function. [PKCS1_2.1] defines MGF1, so the only value - allowed here is CRYS_PKCS1_MGF1. */ + allowed here is CRYS_PKCS1_MGF1. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the data to encrypt. */ uint16_t DataInSize, /*!< [in] The size (in bytes) of the data to encrypt. The data size must be: - For [PKCS1_2.1], DataSize <= modulus size - 2*HashLen - 2. @@ -64,7 +92,7 @@ CIMPORT_C CRYSError_t SaSi_RsaSchemesEncrypt( as defined in PKCS#1 v2.1 8.1. \note It is not recommended to use hash MD5 in OAEP PKCS1 ver 2.1, therefore - it is not supported. + it is not supported. This function combines the RSA encryption primitive and the EME-OAEP encoding method, to provide an RSA-based encryption @@ -72,17 +100,17 @@ CIMPORT_C CRYSError_t SaSi_RsaSchemesEncrypt( chosen-ciphertext attacks. For additional details, please refer to the PKCS#1 standard. */ -#define CRYS_RSA_OAEP_Encrypt(rndContext_ptr, UserPubKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr)\ - SaSi_RsaSchemesEncrypt(rndContext_ptr, UserPubKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_OAEP_Encrypt(rndState_ptr, rndGenerateVectFunc, UserPubKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr)\ + SaSi_RsaSchemesEncrypt(rndState_ptr, rndGenerateVectFunc, UserPubKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr,CRYS_PKCS1_VER21) /*! @brief CRYS_RSA_PKCS1v15_Encrypt implements the RSAES-PKCS1v15 algorithm as defined in PKCS#1 v2.1 8.2. */ -#define CRYS_RSA_PKCS1v15_Encrypt(rndContext_ptr, UserPubKey_ptr,PrimeData_ptr,DataIn_ptr,DataInSize,Output_ptr)\ - SaSi_RsaSchemesEncrypt(rndContext_ptr, UserPubKey_ptr,PrimeData_ptr,CRYS_RSA_HASH_NO_HASH_mode,NULL,0,CRYS_PKCS1_NO_MGF,DataIn_ptr, \ - DataInSize, Output_ptr,CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_Encrypt(rndState_ptr, rndGenerateVectFunc, UserPubKey_ptr,PrimeData_ptr,DataIn_ptr,DataInSize,Output_ptr)\ + SaSi_RsaSchemesEncrypt(rndState_ptr, rndGenerateVectFunc, UserPubKey_ptr,PrimeData_ptr,CRYS_RSA_HASH_NO_HASH_mode,NULL,0,CRYS_PKCS1_NO_MGF,DataIn_ptr, \ + DataInSize, Output_ptr,CRYS_PKCS1_VER15) /**********************************************************************************************************/ @@ -92,32 +120,32 @@ CIMPORT_C CRYSError_t SaSi_RsaSchemesEncrypt( It should not be called directly. Instead, use macros ::CRYS_RSA_OAEP_Decrypt or ::CRYS_RSA_PKCS1v15_Decrypt. @return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. +@return A non-zero value from crys_rsa_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t SaSi_RsaSchemesDecrypt( CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to the private key data structure of the user. */ CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure that is internally used as workspace - for the decryption operation. */ + for the decryption operation. */ CRYS_RSA_HASH_OpMode_t hashFunc, /*!< [in] The HASH function to be used. One of the supported SHA-x HASH modes, - as defined in ::CRYS_RSA_HASH_OpMode_t (MD5 is not supported). */ + as defined in ::CRYS_RSA_HASH_OpMode_t (MD5 is not supported). */ uint8_t *L, /*!< [in] The label input pointer. Relevant for [PKCS1_2.1] only. NULL by default. - NULL for [PKCS1_1.5]. */ + NULL for [PKCS1_1.5]. */ uint16_t Llen, /*!< [in] The label length. Relevant for [PKCS1_2.1] only. Zero by default. - Zero for [PKCS1_1.5]. */ + Zero for [PKCS1_1.5]. */ CRYS_PKCS1_MGF_t MGF, /*!< [in] The mask generation function. [PKCS1_2.1] defines MGF1, so the only - value allowed here is CRYS_PKCS1_MGF1. */ + value allowed here is CRYS_PKCS1_MGF1. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the data to decrypt. */ uint16_t DataInSize, /*!< [in] The size (in bytes) of the data to decrypt. DataSize must be ≤ - the modulus size. */ + the modulus size. */ uint8_t *Output_ptr, /*!< [in] Pointer to the decrypted data. The buffer must be at least - PrivKey_ptr->N.len bytes long (i.e. the modulus size in bytes). */ + PrivKey_ptr->N.len bytes long (i.e. the modulus size in bytes). */ uint16_t *OutputSize_ptr, /*!< [in] Pointer to the byte size of the buffer pointed to by Output_buffer. - The size must be: + The size must be:
        • For PKCS #1 v2.1: Modulus size > OutputSize >= - (modulus size - 2*HashLen - 2).
        • + (modulus size - 2*HashLen - 2).
        • For PKCS #1 v1.5: Modulus size > OutputSize >= (modulus size - 11). The value pointed by OutputSize_ptr is updated after decryption with - the actual number of bytes that are loaded to Output_ptr.
        */ + the actual number of bytes that are loaded to Output_ptr.
      */ CRYS_PKCS1_version PKCS1_ver /*!< [in] [PKCS1_1.5] or [PKCS1_2.1], according to the functionality required. */ ); @@ -138,7 +166,7 @@ CIMPORT_C CRYSError_t SaSi_RsaSchemesDecrypt( */ #define CRYS_RSA_OAEP_Decrypt(UserPrivKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSchemesDecrypt(UserPrivKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) + SaSi_RsaSchemesDecrypt(UserPrivKey_ptr,PrimeData_ptr,HashMode,L,Llen,MGF,Data_ptr,DataSize,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /** @@ -147,41 +175,46 @@ CIMPORT_C CRYSError_t SaSi_RsaSchemesDecrypt( in PKCS#1 v2.1 8.2. */ #define CRYS_RSA_PKCS1v15_Decrypt(UserPrivKey_ptr,PrimeData_ptr,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSchemesDecrypt(UserPrivKey_ptr,PrimeData_ptr,CRYS_RSA_HASH_NO_HASH_mode,NULL,0,CRYS_PKCS1_NO_MGF,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER15) + SaSi_RsaSchemesDecrypt(UserPrivKey_ptr,PrimeData_ptr,CRYS_RSA_HASH_NO_HASH_mode,NULL,0,CRYS_PKCS1_NO_MGF,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER15) /**********************************************************************************************************/ /*! @brief Implements the Signing algorithm, as defined in [PKCS1_1.5] or [PKCS1_2.1], using a single function. +The input data may be either a non-hashed data or a digest of a hash function. +For a non-hashed data, the input data will be hashed using the hash function indicated by ::CRYS_RSA_HASH_OpMode_t. +For a digest, ::CRYS_RSA_HASH_OpMode_t should indicate the hash function that the input data was created by, and it will not be hashed. + @return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. +@return A non-zero value from crys_rsa_error.h, crys_rnd_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t SaSi_RsaSign( - CRYS_RND_Context_t *rndContext_ptr, /*!< [in/out] Pointer to the RND context buffer. */ + void *rndState_ptr, /*!< [in/out] Pointer to the RND state. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in/out] Pointer to the RND Generate vector function pointer. */ CRYS_RSAPrivUserContext_t *UserContext_ptr, /*!< [in] Pointer to a temporary context for internal use. */ CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to the private key data structure of the user. The representation (pair or quintuple) and hence the algorithm (CRT or not CRT) - is determined by the Private Key build function - + is determined by the Private Key build function - ::CRYS_RSA_Build_PrivKey or ::CRYS_RSA_Build_PrivKeyCRT. */ CRYS_RSA_HASH_OpMode_t rsaHashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in ::CRYS_RSA_HASH_OpMode_t. - (MD5 is not supported). */ + (MD5 is not supported). */ CRYS_PKCS1_MGF_t MGF, /*!< [in] The mask generation function. [PKCS1_2.1] defines only MGF1, so the only value - allowed for [PKCS1_2.1] is CRYS_PKCS1_MGF1. */ + allowed for [PKCS1_2.1] is CRYS_PKCS1_MGF1. */ uint16_t SaltLen, /*!< [in] The Length of the Salt buffer (relevant for PKCS#1 Ver 2.1 only, typically lengths is 0 or hash Len). FIPS 186-4 requires, that SaltLen <= hash len. If SaltLen > KeySize - hash Len - 2, the function returns an error. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the input data to be signed. The size of the scatter/gather list representing the data buffer is limited to 128 - entries, and the size of each entry is limited to 64KB (fragments larger than - 64KB are broken into fragments <= 64KB). */ + entries, and the size of each entry is limited to 64KB (fragments larger than + 64KB are broken into fragments <= 64KB). */ uint32_t DataInSize, /*!< [in] The size (in bytes) of the data to sign. */ uint8_t *Output_ptr, /*!< [out] Pointer to the signature. The buffer must be at least PrivKey_ptr->N.len bytes - long (i.e. the modulus size in bytes). */ + long (i.e. the modulus size in bytes). */ uint16_t *OutputSize_ptr, /*!< [in/out] Pointer to the signature size value - the input value is the signature - buffer size allocated, the output value is the signature size used. + buffer size allocated, the output value is the signature size used. he buffer must be equal to PrivKey_ptr->N.len bytes long - (i.e. the modulus size in bytes). */ + (i.e. the modulus size in bytes). */ CRYS_PKCS1_version PKCS1_ver /*!< [in] [PKCS1_1.5] or [PKCS1_2.1], according to the functionality required. */ ); @@ -193,8 +226,8 @@ This function combines the RSASP1 signature primitive and the EMSA-PKCS1v15 enco For more details, please refer to the PKCS#1 standard. */ -#define CRYS_RSA_PKCS1v15_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,hashFunc,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),(hashFunc),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),(DataInSize),(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,hashFunc,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),(hashFunc),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),(DataInSize),(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) /*! @@ -203,8 +236,8 @@ it assumes that the data in has already been hashed using SHA-1. \note The data_in size is already known after the Hash. */ -#define CRYS_RSA_PKCS1v15_SHA1_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA1_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_SHA1_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA1_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_MD5_Sign implements the RSASSA-PKCS1v15 algorithm as defined in PKCS#1 v1.5, but without performing a HASH function - @@ -213,8 +246,8 @@ it assumes that the data in has already been hashed using MD5. \note The data_in size is already known after the Hash. */ -#define CRYS_RSA_PKCS1v15_MD5_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),CRYS_RSA_After_MD5_mode,CRYS_PKCS1_NO_MGF,0,(DataIn_ptr),CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_MD5_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),CRYS_RSA_After_MD5_mode,CRYS_PKCS1_NO_MGF,0,(DataIn_ptr),CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) /*! @@ -223,8 +256,8 @@ it assumes that the data in has already been hashed using SHA-224. \note The data_in size is already known after the Hash. */ -#define CRYS_RSA_PKCS1v15_SHA224_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA224_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_SHA224_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA224_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) /*! @@ -233,8 +266,8 @@ it assumes that the data in has already been hashed using SHA-256. \note The data_in size is already known after the Hash. */ -#define CRYS_RSA_PKCS1v15_SHA256_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA256_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_SHA256_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA256_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_SHA1_Sign implements the RSASSA-PKCS1v15 algorithm as defined in PKCS#1 v1.5, but without performing a HASH function - @@ -242,8 +275,8 @@ it assumes that the data in has already been hashed using SHA-384. \note The data_in size is already known after the Hash. */ -#define CRYS_RSA_PKCS1v15_SHA384_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA384_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_SHA384_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA384_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) /*! @@ -252,8 +285,8 @@ it assumes that the data in has already been hashed using SHA-512. \note The data_in size is already known after the Hash. */ -#define CRYS_RSA_PKCS1v15_SHA512_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA512_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) +#define CRYS_RSA_PKCS1v15_SHA512_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, (UserContext_ptr),(UserPrivKey_ptr),(CRYS_RSA_After_SHA512_mode),(CRYS_PKCS1_NO_MGF),0,(DataIn_ptr),CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,(Output_ptr),(OutputSize_ptr),CRYS_PKCS1_VER15) @@ -265,8 +298,8 @@ it assumes that the data in has already been hashed using SHA-512. The actual macro that is used by the user is ::CRYS_RSA_PSS_Sign. */ -#define CRYS_RSA_PSS_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_PSS_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /*! @@ -278,8 +311,8 @@ it assumes that the data in has already been hashed using SHA-1. The actual macro that is used by the users is ::CRYS_RSA_PSS_SHA1_Sign. */ -#define CRYS_RSA_PSS_SHA1_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA1_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_PSS_SHA1_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA1_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /*! @@ -291,8 +324,8 @@ it assumes that the data in has already been hashed using SHA-224. The actual macro that is used by the users is ::CRYS_RSA_PSS_SHA224_Sign. */ -#define CRYS_RSA_PSS_SHA224_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA224_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_PSS_SHA224_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA224_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /*! @@ -304,8 +337,8 @@ it assumes that the data in has already been hashed using SHA-256. The actual macro that is used by the users is ::CRYS_RSA_PSS_SHA256_Sign. */ -#define CRYS_RSA_PSS_SHA256_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA256_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_PSS_SHA256_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA256_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /*! @@ -317,8 +350,8 @@ it assumes that the data in has already been hashed using SHA-384. The actual macro that is used by the users is ::CRYS_RSA_PSS_SHA384_Sign. */ -#define CRYS_RSA_PSS_SHA384_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA384_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_PSS_SHA384_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA384_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /*! @@ -330,8 +363,8 @@ it assumes that the data in has already been hashed using SHA-512. The actual macro that is used by the users is ::CRYS_RSA_PSS_SHA512_Sign. */ -#define CRYS_RSA_PSS_SHA512_Sign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ - SaSi_RsaSign(rndContext_ptr, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA512_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) +#define CRYS_RSA_PSS_SHA512_Sign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,MGF,SaltLen,DataIn_ptr,Output_ptr,OutputSize_ptr)\ + SaSi_RsaSign(rndState_ptr, rndGenerateVectFunc, UserContext_ptr,UserPrivKey_ptr,CRYS_RSA_After_SHA512_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,Output_ptr,OutputSize_ptr,CRYS_PKCS1_VER21) /**********************************************************************************************************/ @@ -339,42 +372,48 @@ The actual macro that is used by the users is ::CRYS_RSA_PSS_SHA512_Sign. @brief Implements the RSA signature verification algorithms, in a single function call, as defined in referenced standards [PKCS1_1.5] and [PKCS1_2.1]. +The input data may be either a non-hashed data or a digest of a hash function. +For a non-hashed data, the input data will be hashed using the hash function indicated by ::CRYS_RSA_HASH_OpMode_t. +For a digest, ::CRYS_RSA_HASH_OpMode_t should indicate the hash function that the input data was created by, and it will not be hashed. + @return CRYS_OK on success. -@return A non-zero value from crys_rsa_error.h on failure. +@return A non-zero value from crys_rsa_error.h or crys_hash_error.h on failure. */ CIMPORT_C CRYSError_t SaSi_RsaVerify( CRYS_RSAPubUserContext_t *UserContext_ptr, /*!< [in] Pointer to a temporary context for internal use. */ CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] Pointer to the public key data structure of the user. */ CRYS_RSA_HASH_OpMode_t rsaHashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in ::CRYS_RSA_HASH_OpMode_t. - (MD5 is not supported). */ + (MD5 is not supported). */ CRYS_PKCS1_MGF_t MGF, /*!< [in] The mask generation function. [PKCS1_2.1] defines only MGF1, so the only - value allowed for [PKCS_2.1] is CRYS_PKCS1_MGF1. */ + value allowed for [PKCS_2.1] is CRYS_PKCS1_MGF1. */ uint16_t SaltLen, /*!< [in] The Length of the Salt buffer. Relevant only for [PKCS1_2.1]. - Typical lengths are 0 or hash Len (20 for SHA-1). + Typical lengths are 0 or hash Len (20 for SHA-1). The maximum length allowed is [modulus size - hash Len - 2]. */ uint8_t *DataIn_ptr, /*!< [in] Pointer to the input data to be verified. The size of the scatter/gather list representing the data buffer is - limited to 128 entries, and the size of each entry is limited to 64KB - (fragments larger than 64KB are broken into fragments <= 64KB). */ + limited to 128 entries, and the size of each entry is limited to 64KB + (fragments larger than 64KB are broken into fragments <= 64KB). */ uint32_t DataInSize, /*!< [in] The size (in bytes) of the data whose signature is to be verified. */ uint8_t *Sig_ptr, /*!< [in] Pointer to the signature to be verified. The length of the signature is PubKey_ptr->N.len bytes - (i.e. the modulus size in bytes). */ + (i.e. the modulus size in bytes). */ CRYS_PKCS1_version PKCS1_ver /*!< [in] [PKCS1_1.5] or [PKCS1_2.1], according to the functionality required. */ ); +/*! +@brief CRYS_RSA_PKCS1v15_Verify implements the RSASSA-PKCS1v15 Verify algorithm as defined in PKCS#1 v1.5. +*/ #define CRYS_RSA_PKCS1v15_Verify(UserContext_ptr,UserPubKey_ptr,hashFunc,DataIn_ptr,DataInSize,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,hashFunc,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,DataInSize,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,hashFunc,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,DataInSize,Sig_ptr,CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_MD5_Verify implements the RSASSA-PKCS1v15 Verify algorithm as defined in PKCS#1 v1.5, but without operating the HASH function - it assumes the DataIn_ptr data has already been hashed using MD5. */ - #define CRYS_RSA_PKCS1v15_MD5_Verify(UserContext_ptr,UserPubKey_ptr,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_MD5_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_MD5_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) /*! @@ -383,7 +422,7 @@ it assumes that the DataIn_ptr data has already been hashed using SHA1. */ #define CRYS_RSA_PKCS1v15_SHA1_Verify(UserContext_ptr,UserPubKey_ptr,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA1_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA1_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_SHA224_Verify implements the RSASSA-PKCS1v15 Verify algorithm as defined in PKCS#1 v1.5, but without operating the HASH function - @@ -391,7 +430,7 @@ it assumes that the DataIn_ptr data has already been hashed using SHA224. */ #define CRYS_RSA_PKCS1v15_SHA224_Verify(UserContext_ptr,UserPubKey_ptr,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA224_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA224_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_SHA256_Verify implements the RSASSA-PKCS1v15 Verify algorithm as defined in PKCS#1 v1.5, but without operating the HASH function - @@ -399,7 +438,7 @@ it assumes that the DataIn_ptr data has already been hashed using SHA256. */ #define CRYS_RSA_PKCS1v15_SHA256_Verify(UserContext_ptr,UserPubKey_ptr,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA256_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA256_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_SHA384_Verify implements the RSASSA-PKCS1v15 Verify algorithm as defined in PKCS#1 v1.5, but without operating the HASH function - @@ -407,7 +446,7 @@ it assumes that the DataIn_ptr data has already been hashed using SHA384. */ #define CRYS_RSA_PKCS1v15_SHA384_Verify(UserContext_ptr,UserPubKey_ptr,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA384_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA384_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PKCS1v15_SHA512_Verify implements the RSASSA-PKCS1v15 Verify algorithm as defined in PKCS#1 v1.5, but without operating the HASH function - @@ -415,23 +454,23 @@ it assumes that the DataIn_ptr data has already been hashed using SHA512. */ #define CRYS_RSA_PKCS1v15_SHA512_Verify(UserContext_ptr,UserPubKey_ptr,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA512_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA512_mode,CRYS_PKCS1_NO_MGF,0,DataIn_ptr,CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER15) /*! @brief CRYS_RSA_PSS_Verify implements the RSASSA-PKCS1v21 Verify algorithm as defined in PKCS#1 v2.1. */ #define CRYS_RSA_PSS_Verify(UserContext_ptr,UserPubKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Sig_ptr,CRYS_PKCS1_VER21) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,hashFunc,MGF,SaltLen,DataIn_ptr,DataInSize,Sig_ptr,CRYS_PKCS1_VER21) - /*! + /*! @brief CRYS_RSA_PSS_SHA1_Verify implements the PKCS1v21 Verify algorithm as defined in PKCS#1 v2.1, but without operating the HASH function - it assumes the DataIn_ptr has already been hashed using SHA1. */ #define CRYS_RSA_PSS_SHA1_Verify(UserContext_ptr,UserPubKey_ptr,MGF,SaltLen,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA1_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA1_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) /*! @@ -440,7 +479,7 @@ it assumes the DataIn_ptr has already been hashed using SHA224. */ #define CRYS_RSA_PSS_SHA224_Verify(UserContext_ptr,UserPubKey_ptr,MGF,SaltLen,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA224_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA224_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) /*! @brief CRYS_RSA_PSS_SHA256_Verify implements the PKCS1v21 Verify algorithm as defined in PKCS#1 v2.1, but without operating the HASH function - @@ -449,7 +488,7 @@ it assumes the DataIn_ptr has already been hashed using SHA256. */ #define CRYS_RSA_PSS_SHA256_Verify(UserContext_ptr,UserPubKey_ptr,MGF,SaltLen,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA256_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA256_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) /*! @@ -459,7 +498,7 @@ it assumes the DataIn_ptr has already been hashed using SHA384. */ #define CRYS_RSA_PSS_SHA384_Verify(UserContext_ptr,UserPubKey_ptr,MGF,SaltLen,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA384_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA384_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) /*! @@ -468,7 +507,7 @@ it assumes the DataIn_ptr has already been hashed using SHA512. */ #define CRYS_RSA_PSS_SHA512_Verify(UserContext_ptr,UserPubKey_ptr,MGF,SaltLen,DataIn_ptr,Sig_ptr)\ - SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA512_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) + SaSi_RsaVerify(UserContext_ptr,UserPubKey_ptr,CRYS_RSA_After_SHA512_mode,MGF,SaltLen,DataIn_ptr,CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES,Sig_ptr,CRYS_PKCS1_VER21) /**********************************************************************************************************/ @@ -476,5 +515,7 @@ it assumes the DataIn_ptr has already been hashed using SHA512. #ifdef __cplusplus } #endif - +/** +@} + */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_types.h similarity index 79% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_types.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_types.h index f68a726..a0acc52 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/crys_rsa_types.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_rsa_types.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RSA_TYPES_H #define CRYS_RSA_TYPES_H @@ -27,9 +51,9 @@ extern "C" { #endif /*! -@file -@brief This file contains all of the enums and definitions that are used for the CRYS RSA APIs. -@defgroup crys_rsa_types_f CryptoCell RSA used definitions and enums +@file +@brief This file contains all of the enums and definitions that are used for the CRYS RSA APIs. +@defgroup crys_rsa_types CryptoCell RSA used definitions and enums @{ @ingroup crys_rsa */ @@ -89,20 +113,20 @@ extern "C" /*! MGF1 definitions */ #define CRYS_RSA_MGF_2_POWER_32 65535 /*!< \internal 0xFFFF This is the 2^32 of the 2^32*hLen boundary check */ /*! MGF1 definitions */ -#define CRYS_RSA_SIZE_OF_T_STRING_BYTES (CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS*sizeof(uint32_t)) +#define CRYS_RSA_SIZE_OF_T_STRING_BYTES (CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS*sizeof(uint32_t)) /*********************************************************** * * RSA PKCS#1 v2.1 DEFINES * - ***********************************************************/ + ***********************************************************/ /*! Size of OEAP seed. */ #define CRYS_RSA_OAEP_ENCODE_MAX_SEEDMASK_SIZE CRYS_RSA_OAEP_MAX_HLEN /*! Maximal PSS salt size. */ #define CRYS_RSA_PSS_SALT_LENGTH CRYS_RSA_OAEP_MAX_HLEN /*! PSS padding length. */ #define CRYS_RSA_PSS_PAD1_LEN 8 - + /*! OAEP encode mask size. */ #define CRYS_RSA_OAEP_ENCODE_MAX_MASKDB_SIZE (CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS*sizeof(uint32_t)) /*!< \internal For OAEP Encode; the max size is emLen */ /*! OAEP decode mask size. */ @@ -125,14 +149,14 @@ typedef enum CRYS_RSA_After_SHA256_mode = 9, /*!< The input data is a digest of SHA256 and will not be hashed. */ CRYS_RSA_After_SHA384_mode = 10, /*!< The input data is a digest of SHA384 and will not be hashed. */ CRYS_RSA_After_SHA512_mode = 11, /*!< The input data is a digest of SHA512 and will not be hashed. */ - CRYS_RSA_After_HASH_NOT_KNOWN_mode = 12, /*!< \internal used only for PKCS#1 Ver 1.5 - possible to perform verify operation without hash mode input, + CRYS_RSA_After_HASH_NOT_KNOWN_mode = 12, /*!< \internal used only for PKCS#1 Ver 1.5 - possible to perform verify operation without hash mode input, the hash mode is derived from the signature.*/ CRYS_RSA_HASH_NO_HASH_mode = 13, /*!< Used for PKCS1 v1.5 Encrypt and Decrypt.*/ CRYS_RSA_HASH_NumOfModes, /*!< Maximal number of hash operations modes. */ - + CRYS_RSA_HASH_OpModeLast = 0x7FFFFFFF, /*! Reserved.*/ -}CRYS_RSA_HASH_OpMode_t; +}CRYS_RSA_HASH_OpMode_t; /*! Defines the enum of the RSA decryption mode. */ @@ -140,9 +164,9 @@ typedef enum { CRYS_RSA_NoCrt = 10, /*!< Decryption no CRT mode.*/ CRYS_RSA_Crt = 11, /*!< Decryption CRT mode.*/ - + CRYS_RSADecryptionNumOfOptions, /*! Reserved.*/ - + CRYS_RSA_DecryptionModeLast= 0x7FFFFFFF, /*! Reserved.*/ }CRYS_RSA_DecryptionMode_t; @@ -152,10 +176,10 @@ typedef enum { CRYS_RSA_ExternalKey = 1, /*!< External key.*/ CRYS_RSA_InternalKey = 2, /*!< Internal key.*/ - + CRYS_RSA_KeySourceLast= 0x7FFFFFFF, /*!< Reserved. */ -}CRYS_RSA_KeySource_t; +}CRYS_RSA_KeySource_t; /*! MGF values. */ typedef enum @@ -173,26 +197,26 @@ typedef enum { CRYS_PKCS1_VER15 = 0, /*! PKCS1 version 15. */ CRYS_PKCS1_VER21 = 1, /*! PKCS1 version 21. */ - + CRYS_RSA_NumOf_PKCS1_versions, /*! Maximal number of PKCS versions. */ - + CRYS_PKCS1_versionLast= 0x7FFFFFFF, /*! Reserved.*/ }CRYS_PKCS1_version; -/*! Enum defining primality testing mode in Rabin-Miller - and Lucas-Lehmer tests (internal tests). */ +/*! Enum defining primality testing mode in Rabin-Miller + and Lucas-Lehmer tests (internal tests). */ typedef enum { /* P and Q primes */ CRYS_RSA_PRIME_TEST_MODE = 0, /*!< PRIME test. */ - /* FFC (DH, DSA) primes */ + /* FFC (DH, DSA) primes */ CRYS_DH_PRIME_TEST_MODE = 1, /*!< DH Prime test. */ - CRYS_RSA_DH_PRIME_TEST_OFF_MODE /*!< Reserved.*/ - -}CRYS_RSA_DH_PrimeTestMode_t; + CRYS_RSA_DH_PRIME_TEST_OFF_MODE /*!< Reserved.*/ + +}CRYS_RSA_DH_PrimeTestMode_t; /************************ Public and private key database Structs ******************************/ @@ -200,32 +224,32 @@ typedef enum /* --------------------------------------------------------------------- */ /*! Public key data structure (used internally). */ -typedef struct -{ +typedef struct +{ /*! RSA modulus buffer. */ uint32_t n[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! RSA modulus size in bits. */ uint32_t nSizeInBits; - + /*! RSA public exponent buffer. */ uint32_t e[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! RSA public exponent buffer. */ uint32_t eSizeInBits; - + /*! Buffer for internal usage.*/ uint32_t crysRSAIntBuff[CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; - + }CRYSRSAPubKey_t; -/*! The public key's user structure prototype. This structure must be saved by the user, and is used as input to the RSA functions +/*! The public key's user structure prototype. This structure must be saved by the user, and is used as input to the RSA functions (such as ::SaSi_RsaSchemesEncrypt etc.) */ -typedef struct CRYS_RSAUserPubKey_t +typedef struct CRYS_RSAUserPubKey_t { /*! Validation tag. */ - uint32_t valid_tag; - /*! Public key data. */ - uint32_t PublicKeyDbBuff[ sizeof(CRYSRSAPubKey_t)/sizeof(uint32_t) + 1 ]; - + uint32_t valid_tag; + /*! Public key data. */ + uint32_t PublicKeyDbBuff[ sizeof(CRYSRSAPubKey_t)/sizeof(uint32_t) + 1 ]; + }CRYS_RSAUserPubKey_t; @@ -233,72 +257,72 @@ typedef struct CRYS_RSAUserPubKey_t /* --------------------------------------------------------------------- */ /*! Private key on non-CRT mode data structure (used internally). */ -typedef struct -{ +typedef struct +{ /*! RSA private exponent buffer. */ uint32_t d[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! RSA private exponent size in bits. */ uint32_t dSizeInBits; - + /*! RSA public exponent buffer. */ uint32_t e[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! RSA public exponent size in bits. */ uint32_t eSizeInBits; - + }CRYSRSAPrivNonCRTKey_t; /*! Private key on CRT mode data structure (used internally). */ #ifndef CRYS_NO_RSA_SMALL_CRT_BUFFERS_SUPPORT /* use small CRT buffers */ -typedef struct +typedef struct { /*! First factor buffer. */ - uint32_t P[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; + uint32_t P[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; /*! First factor size in bits. */ uint32_t PSizeInBits; - + /*! Second factor buffer. */ - uint32_t Q[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; + uint32_t Q[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; /*! Second factor size in bits. */ uint32_t QSizeInBits; - + /*! First CRT exponent buffer. */ - uint32_t dP[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; + uint32_t dP[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; /*! First CRT exponent size in bits. */ uint32_t dPSizeInBits; - + /*! Second CRT exponent buffer. */ - uint32_t dQ[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; + uint32_t dQ[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; /*! Second CRT exponent size in bits. */ uint32_t dQSizeInBits; - + /*! First CRT coefficient buffer. */ uint32_t qInv[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS/2]; /*! First CRT coefficient size in bits. */ uint32_t qInvSizeInBits; - + }CRYSRSAPrivCRTKey_t; /*! Size of CRYSRSAPrivCRTKey_t structure in words (used for temp buffers allocation). */ #define CRYS_RSA_SIZE_IN_WORDS_OF_CRYSRSAPrivCRTKey_t (CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS*7/2 + 5) #else /* use large CRT buffers */ -typedef struct -{ +typedef struct +{ /* The first factor buffer and size in bits */ - uint32_t P[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + uint32_t P[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; uint32_t PSizeInBits; /* The second factor buffer and its size in bits */ - uint32_t Q[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + uint32_t Q[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; uint32_t QSizeInBits; /* The first CRT exponent buffer and its size in bits */ - uint32_t dP[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + uint32_t dP[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; uint32_t dPSizeInBits; /* The second CRT exponent buffer and its size in bits */ - uint32_t dQ[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; + uint32_t dQ[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; uint32_t dQSizeInBits; /* The first CRT coefficient buffer and its size in bits */ @@ -318,35 +342,35 @@ typedef struct /*! RSA modulus buffer. */ uint32_t n[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! RSA modulus size in bits. */ - uint32_t nSizeInBits; - + uint32_t nSizeInBits; + /*! Decryption operation mode. */ CRYS_RSA_DecryptionMode_t OperationMode; - + /*! Key source ( internal or external ). */ - CRYS_RSA_KeySource_t KeySource; - - + CRYS_RSA_KeySource_t KeySource; + + /*! Union between the CRT and non-CRT data structures. */ - union - { + union + { CRYSRSAPrivNonCRTKey_t NonCrt; /*!< Non CRT data structure. */ CRYSRSAPrivCRTKey_t Crt; /*!< CRT data structure. */ }PriveKeyDb; - + /*! Internal buffer. */ uint32_t crysRSAPrivKeyIntBuff[CRYS_PKA_PRIV_KEY_BUFF_SIZE_IN_WORDS]; }CRYSRSAPrivKey_t; -/*! The private key's user structure prototype. This structure must be saved by the user, and is used as input to the RSA functions +/*! The private key's user structure prototype. This structure must be saved by the user, and is used as input to the RSA functions (such as ::SaSi_RsaSchemesDecrypt etc.). */ -typedef struct CRYS_RSAUserPrivKey_t +typedef struct CRYS_RSAUserPrivKey_t { /*! Validation tag.*/ - uint32_t valid_tag; - /*! Private key data. */ - uint32_t PrivateKeyDbBuff[ sizeof(CRYSRSAPrivKey_t)/sizeof(uint32_t) + 1 ] ; + uint32_t valid_tag; + /*! Private key data. */ + uint32_t PrivateKeyDbBuff[ sizeof(CRYSRSAPrivKey_t)/sizeof(uint32_t) + 1 ] ; }CRYS_RSAUserPrivKey_t; @@ -357,9 +381,9 @@ typedef struct CRYS_RSAPrimeData_t uint32_t DataIn[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*!< Temporary buffer for data in.*/ uint32_t DataOut[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*!< Temporary buffer for data out.*/ /*! Temporary buffer for internal data.*/ - SASI_PAL_COMPILER_ALIGN(4) uint8_t InternalBuff[CRYS_RSA_TMP_BUFF_SIZE]; + SASI_PAL_COMPILER_ALIGN(4) uint8_t InternalBuff[CRYS_RSA_TMP_BUFF_SIZE]; -}CRYS_RSAPrimeData_t; +}CRYS_RSAPrimeData_t; /*! KG data type. */ typedef union CRYS_RSAKGData_t @@ -373,7 +397,7 @@ typedef union CRYS_RSAKGData_t /*! Second factor buffer. */ uint32_t q[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS / 2]; union { - /*! Internal buffer. */ + /*! Internal buffer. */ uint32_t crysRSAKGDataIntBuff[CRYS_PKA_KGDATA_BUFF_SIZE_IN_WORDS]; #ifdef DX_SOFT_KEYGEN /* # added for compatibility with size of KGData SW type */ @@ -392,33 +416,33 @@ typedef union CRYS_RSAKGData_t /* # added for compatibility with size of SW CRYSRSAPrivKey_t type */ SW_Shared_CRYS_RSAPrimeData_t SW_Shared_PrimData; #endif - }prim; -}CRYS_RSAKGData_t; + }prim; +}CRYS_RSAKGData_t; /************* - * RSA contexts + * RSA contexts **************/ /************************ CRYS RSA struct for Private Key ******************************/ /*! Context definition for operations that use the RSA private key. */ -typedef struct +typedef struct { /*! Private key data. */ CRYS_RSAUserPrivKey_t PrivUserKey; - + /*! RSA PKCS#1 Version 1.5 or 2.1 */ uint8_t PKCS1_Version; - + /*! MGF to be used for the PKCS1 Ver 2.1 sign or verify operations. */ uint8_t MGF_2use; - + /*! Salt random length for PKCS#1 PSS Ver 2.1*/ uint16_t SaltLen; - + /*! Internal buffer. */ CRYS_RSAPrimeData_t PrimeData; - + /*! HASH context buffer. */ uint32_t CRYSPKAHashCtxBuff[CRYS_PKA_RSA_HASH_CTX_SIZE_IN_WORDS]; /*! HASH result buffer. */ @@ -433,68 +457,68 @@ typedef struct uint16_t HashBlockSize; /*in words*/ /*! HASH flag. */ bool doHash; - + /* Used for sensitive data manipulation in the context space, which is safer and which saves stack space */ /*! Internal buffer.*/ uint32_t EBD[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! Internal bufffer used size in bits. */ uint32_t EBDSizeInBits; - + /* Used for sensitive data manipulation in the context space, which is safer and which saves stack space */ /*! Internal buffer.*/ uint8_t T_Buf[CRYS_RSA_SIZE_OF_T_STRING_BYTES]; /*! Internal buffer used size.*/ uint16_t T_BufSize; - + /*! Buffer for the use of the Ber encoder in the case of PKCS#1 Ver 1.5. */ uint32_t BER[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! Ber encoder buffer size.*/ uint16_t BERSize; - + /*! Internal buffer.*/ uint8_t DummyBufAESBlockSize[16]; - + }RSAPrivContext_t; /*! The user's context prototype - the argument type that is passed by the user - to the RSA APIs. The context saves the state of the operation and must be saved by the user + to the RSA APIs. The context saves the state of the operation and must be saved by the user till the end of the APIs flow . */ -typedef struct CRYS_RSAPrivUserContext_t +typedef struct CRYS_RSAPrivUserContext_t { /*! Validation tag. */ - uint32_t valid_tag; + uint32_t valid_tag; /*! Internally used value.*/ - uint32_t AES_iv; + uint32_t AES_iv; /*! Private data context buffer. */ SASI_PAL_COMPILER_ALIGN(4) uint8_t context_buff[ sizeof(RSAPrivContext_t) + sizeof(uint32_t)]; /* must be aligned to 4 */ - + }CRYS_RSAPrivUserContext_t; -/************************ CRYS RSA struct for Public Key ******************************/ - +/************************ CRYS RSA struct for Public Key ******************************/ + /*! Context definition for operations that use the RSA public key. */ -typedef struct +typedef struct { /*! RSA public key structure. */ CRYS_RSAUserPubKey_t PubUserKey; - + /*! Public key size in bytes */ uint32_t nSizeInBytes; - + /*! RSA PKCS#1 Version 1.5 or 2.1 */ uint8_t PKCS1_Version; - + /*! MGF to be used for the PKCS1 Ver 2.1 Sign or Verify operations */ uint8_t MGF_2use; - + /*! Salt random length for PKCS#1 PSS Ver 2.1*/ uint16_t SaltLen; - + /*! Internal buffer. */ CRYS_RSAPrimeData_t PrimeData; - + /*! HASH context. */ uint32_t CRYSPKAHashCtxBuff[CRYS_PKA_RSA_HASH_CTX_SIZE_IN_WORDS]; /*! HASH result buffer. */ @@ -509,39 +533,39 @@ typedef struct uint16_t HashBlockSize; /*in words*/ /*! HASH flag.*/ bool doHash; - + /* Used for sensitive data manipulation in the context space, which is safer and which saves stack space */ /*! Internal buffer.*/ uint32_t EBD[CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS]; /*! Internal bufffer used size in bits. */ uint32_t EBDSizeInBits; - + /* Used for sensitive data manipulation in the context space, which is safer and which saves stack space */ /*! Internal buffer.*/ uint8_t T_Buf[CRYS_RSA_SIZE_OF_T_STRING_BYTES]; /*! Internal buffer used size.*/ uint16_t T_BufSize; - + /*! Internal buffer.*/ uint8_t DummyBufAESBlockSize[16]; }RSAPubContext_t; /*! Temporary buffers for the RSA usage. */ -typedef struct CRYS_RSAPubUserContext_t +typedef struct CRYS_RSAPubUserContext_t { /*! Validation tag. */ - uint32_t valid_tag; + uint32_t valid_tag; /*! Internally used value.*/ - uint32_t AES_iv; /* For the use of the AES CBC mode of Encryption and Decryption of the context in CCM */ + uint32_t AES_iv; /* For the use of the AES CBC mode of Encryption and Decryption of the context in CCM */ /*! Public data context buffer. */ - uint32_t context_buff[ sizeof(RSAPubContext_t)/sizeof(uint32_t) + 1] ; - + uint32_t context_buff[ sizeof(RSAPubContext_t)/sizeof(uint32_t) + 1] ; + }CRYS_RSAPubUserContext_t; -/*! Required for internal FIPS verification for RSA key generation. */ +/*! Required for internal FIPS verification for RSA key generation. */ typedef struct CRYS_RSAKGFipsContext_t{ /*! Internal buffer. */ CRYS_RSAPrimeData_t primData; @@ -586,7 +610,7 @@ typedef struct CRYS_RSAFipsKatContext_t{ #ifdef __cplusplus } #endif -/** +/** @} */ #endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp.h new file mode 100644 index 0000000..ed23098 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp.h @@ -0,0 +1,375 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the + CRYS SRP APIs, as well as the APIs themselves. +@defgroup crys_srp CryptoCell SRP APIs +@{ +@ingroup cryptocell_api + +*/ +#ifndef CRYS_SRP_H +#define CRYS_SRP_H + + +#include "ssi_pal_types.h" +#include "crys_error.h" +#include "crys_pka_defs_hw.h" +#include "crys_hash.h" +#include "crys_rnd.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*!\internal The following describes the SRP APIs usage for the Device and the Accessory :* + + Device (User) Accessory (Host) +* -------------- ----------------- + + 1. CRYS_SRP_HK_INIT(CRYS_SRP_USER, .......) CRYS_SRP_HK_INIT(CRYS_SRP_HOST, .....) + + 2. CRYS_SRP_PwdVerCreate(..) + + 3. CRYS_SRP_UserPubKeyCreate(..) CRYS_SRP_HostPubKeyCreate(..) + + 4. CRYS_SRP_UserProofCalc(..) + + 5. CRYS_SRP_HostProofVerifyAndCalc(..) + + 6. CRYS_SRP_UserProofVerify(..) + + 7. CRYS_SRP_Clear(..) CRYS_SRP_Clear(..) + + */ + +/************************ Defines ******************************/ +/*! The SRP modulus sizes. */ +/*! 1024 bits modulus size. */ +#define CRYS_SRP_MODULUS_SIZE_1024_BITS 1024 +/*! 1536 bits modulus size. */ +#define CRYS_SRP_MODULUS_SIZE_1536_BITS 1536 +/*! 2048 bits modulus size. */ +#define CRYS_SRP_MODULUS_SIZE_2048_BITS 2048 +/*! 3072 bits modulus size. */ +#define CRYS_SRP_MODULUS_SIZE_3072_BITS 3072 + +/*! Maximal modulus size in bits. */ +#define CRYS_SRP_MAX_MODULUS_IN_BITS CRYS_SRP_MODULUS_SIZE_3072_BITS +/*! Maximal modulus size in bytes. */ +#define CRYS_SRP_MAX_MODULUS (CRYS_SRP_MAX_MODULUS_IN_BITS/SASI_BITS_IN_BYTE) +/*! Maximal modulus size in words. */ +#define CRYS_SRP_MAX_MODULUS_IN_WORDS (CRYS_SRP_MAX_MODULUS_IN_BITS/SASI_BITS_IN_32BIT_WORD) + +/*! The SRP private number size range. */ +/*! Minimal private number size in bits. */ +#define CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_BITS (256) +/*! Minimal private number size in bytes. */ +#define CRYS_SRP_PRIV_NUM_MIN_SIZE (CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_BITS/SASI_BITS_IN_BYTE) +/*! Minimal private number size in words. */ +#define CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_WORDS (CRYS_SRP_PRIV_NUM_MIN_SIZE_IN_BITS/SASI_BITS_IN_32BIT_WORD) +/*! Maximal private number size in bits. */ +#define CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_BITS (CRYS_SRP_MAX_MODULUS_IN_BITS) +/*! Maximal private number size in bytes. */ +#define CRYS_SRP_PRIV_NUM_MAX_SIZE (CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_BITS/SASI_BITS_IN_BYTE) +/*! Maximal private number size in words. */ +#define CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_WORDS (CRYS_SRP_PRIV_NUM_MAX_SIZE_IN_BITS/SASI_BITS_IN_32BIT_WORD) + +/*! Maximal SRP HASH digest size in words. */ +#define CRYS_SRP_MAX_DIGEST_IN_WORDS CRYS_HASH_RESULT_SIZE_IN_WORDS +/*! Maximal SRP HASH digest size in bytes. */ +#define CRYS_SRP_MAX_DIGEST (CRYS_SRP_MAX_DIGEST_IN_WORDS*SASI_32BIT_WORD_SIZE) + +/*! Minimal salt size in bytes. */ +#define CRYS_SRP_MIN_SALT_SIZE (8) +/*! Minimal salt size in words. */ +#define CRYS_SRP_MIN_SALT_SIZE_IN_WORDS (CRYS_SRP_MIN_SALT_SIZE/SASI_32BIT_WORD_SIZE) +/*! Maximal salt size in bytes. */ +#define CRYS_SRP_MAX_SALT_SIZE (64) +/*! Maximal salt size in words. */ +#define CRYS_SRP_MAX_SALT_SIZE_IN_WORDS (CRYS_SRP_MAX_SALT_SIZE/SASI_32BIT_WORD_SIZE) + +/************************ Typedefs ****************************/ +/*! SRP modulus buffer definition. */ +typedef uint8_t CRYS_SRP_Modulus_t[CRYS_SRP_MAX_MODULUS]; + +/*! SRP digest buffer definition. */ +typedef uint8_t CRYS_SRP_Digest_t[CRYS_SRP_MAX_DIGEST]; + +/*! SRP secret buffer definition. */ +typedef uint8_t CRYS_SRP_Secret_t[2*CRYS_SRP_MAX_DIGEST]; + +/************************ Enums ********************************/ + +/*! +SRP supported versions +*/ +typedef enum { + CRYS_SRP_VER_3 = 0, /*!< VER 3. */ + CRYS_SRP_VER_6 = 1, /*!< VER 6. */ + CRYS_SRP_VER_6A = 2, /*!< VER 6A. */ + CRYS_SRP_VER_HK = 3, /*!< VER 6A. */ + /*! Maximal number of supported versions.*/ + CRYS_SRP_NumOfVersions, + /*! Reserved.*/ + CRYS_SRP_VersionLast= 0x7FFFFFFF, + +}CRYS_SRP_Version_t; + +/*! +SRP entity type +*/ +typedef enum { + CRYS_SRP_HOST = 1, /*!< Host entity, called also server, verifier, or Accessory in Home-Kit */ + CRYS_SRP_USER = 2, /*!< User entity, called also client, or Device in Home-Kit */ + /*! Maximal number of entities types.*/ + CRYS_SRP_NumOfEntityType, + /*! Reserved.*/ + CRYS_SRP_EntityLast= 0x7FFFFFFF, + +}CRYS_SRP_Entity_t; + +/************************ Structs ******************************/ + +/*! Group parameters for the SRP - defines the modulus and the generator used */ +typedef struct CRYS_SRP_GroupParam_t { + /*! SRP modulus.*/ + CRYS_SRP_Modulus_t modulus; + /*! SRP generator.*/ + uint8_t gen; + /*! SRP modulus size in bits .*/ + size_t modSizeInBits; + /*! SRP valid Np.*/ + uint32_t validNp; + /*! SRP Np buffer.*/ + uint32_t Np[CRYS_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; +}CRYS_SRP_GroupParam_t; + +/************************ context Structs ******************************/ +/*! The SRP context prototype */ +typedef struct CRYS_SRP_Context_t { + /*! SRP entitiy type.*/ + CRYS_SRP_Entity_t srpType; + /*! SRP version.*/ + CRYS_SRP_Version_t srpVer; + /*! Group parameter including the modulus information.*/ + CRYS_SRP_GroupParam_t groupParam; // N, g, Np + /*! Hash mode.*/ + CRYS_HASH_OperationMode_t hashMode; + /*! Hash digest size.*/ + size_t hashDigestSize; + /*! Pointer to RND state.*/ + CRYS_RND_State_t *pRndState; + /*! Pointer to random vector generation function.*/ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc; + /*! Modulus.*/ + CRYS_SRP_Modulus_t ephemPriv; // a or b + /*! Modulus size.*/ + size_t ephemPrivSize; + /*! User name digest.*/ + CRYS_SRP_Digest_t userNameDigest; // M + /*! Cred digest.*/ + CRYS_SRP_Digest_t credDigest; // p + /*! SRP K multiplier. */ // + CRYS_SRP_Digest_t kMult; // k multiplier +}CRYS_SRP_Context_t; + + +/************************ SRP common Functions **********************/ +/****************************************************************************************************/ +/*! +@brief This function initiates the SRP context. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_Init( + CRYS_SRP_Entity_t srpType, /*!< [in] SRP entity type. */ + CRYS_SRP_Version_t srpVer, /*!< [in] SRP version. */ + CRYS_SRP_Modulus_t srpModulus, /*!< [in] A pointer to the SRP modulus, BE byte buffer. */ + uint8_t srpGen, /*!< [in] The SRP generator param. */ + size_t modSizeInBits, /*!< [in] The SRP modulus size in bits:1024, 1536, 2048 & 3072 */ + CRYS_HASH_OperationMode_t hashMode, /*!< [in] Enumerator defining the HASH mode. */ + uint8_t *pUserName, /*!< [in] A Pointer to user name. */ + size_t userNameSize, /*!< [in] The user name buffer size > 0. */ + uint8_t *pPwd, /*!< [in] A Pointer to user password. */ + size_t pwdSize, /*!< [in] The user password buffer size > 0 if pPwd is valid. */ + void *pRndState, /*!< [in] A Pointer to RND context.*/ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to random vector generation function.*/ + CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP host context.*/ +); + +/*! MACRO definition for a specific SRP initialization function.*/ +#define CRYS_SRP_HK_INIT(srpType, srpModulus, srpGen, modSizeInBits, pUserName, userNameSize, pPwd, pwdSize, pRndState, rndGenerateVectFunc, pCtx) \ + CRYS_SRP_Init(srpType, CRYS_SRP_VER_HK, srpModulus, srpGen, modSizeInBits, CRYS_HASH_SHA512_mode, pUserName, userNameSize, pPwd, pwdSize, pRndState, rndGenerateVectFunc, pCtx) + + +/****************************************************************************************************/ +/*! +@brief This function calculates pSalt & password verifier + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h, crys_rnd_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_PwdVerCreate( + size_t saltSize, /*!< [in] The size of the random salt to generate, + The range is between CRYS_SRP_MIN_SALT_SIZE + to CRYS_SRP_MAX_SALT_SIZE. */ + uint8_t *pSalt, /*!< [out] A Pointer to the pSalt number (s).*/ + CRYS_SRP_Modulus_t pwdVerifier, /*!< [out] A Pointer to the password verifier (v). */ + CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP context.*/ +); + + +/****************************************************************************************************/ +/*! +@brief Clears the SRP context. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_Clear( + CRYS_SRP_Context_t *pCtx /*!< [in/out] A Pointer to the SRP context.*/ +); + + +/************************ SRP Host Functions **********************/ +/****************************************************************************************************/ +/*! +@brief This function generates host public & private ephemeral key, known as B & b in RFC + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h or crys_rnd_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_HostPubKeyCreate( + size_t ephemPrivSize, /*!< [in] The size of the generated ephemeral private key (b). + The range is between CRYS_SRP_PRIV_NUM_MIN_SIZE to + CRYS_SRP_PRIV_NUM_MAX_SIZE */ + CRYS_SRP_Modulus_t pwdVerifier, /*!< [in] A Pointer to the verifier (v). */ + CRYS_SRP_Modulus_t hostPubKeyB, /*!< [out] A Pointer to the host ephemeral public key (B). */ + CRYS_SRP_Context_t *pCtx /*!< [in/out] A Pointer to the SRP context.*/ +); + + +/*! +@brief Verifies the user Proof and calculates the Host message proof. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_HostProofVerifyAndCalc( + size_t saltSize, /*!< [in] The size of the random salt, + The range is between CRYS_SRP_MIN_SALT_SIZE + to CRYS_SRP_MAX_SALT_SIZE. */ + uint8_t *pSalt, /*!< [in] A Pointer to the pSalt number.*/ + CRYS_SRP_Modulus_t pwdVerifier, /*!< [in] A Pointer to the password verifier (v). */ + CRYS_SRP_Modulus_t userPubKeyA, /*!< [in] A Pointer to the user ephemeral public key (A). */ + CRYS_SRP_Modulus_t hostPubKeyB, /*!< [in] A Pointer to the host ephemeral public key (B). */ + CRYS_SRP_Digest_t userProof, /*!< [in] A Pointer to the SRP user proof buffer (M1).*/ + CRYS_SRP_Digest_t hostProof, /*!< [out] A Pointer to the SRP host proof buffer (M2).*/ + CRYS_SRP_Secret_t sharedSecret, /*!< [out] A Pointer to the SRP shared secret (K).*/ + CRYS_SRP_Context_t *pCtx /*!< [in] A Pointer to the SRP context.*/ +); + + + +/************************ SRP User Functions **********************/ +/****************************************************************************************************/ +/*! +@brief This function generates user public & private ephemeral key, known as A & a in RFC + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h or crys_rnd_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_UserPubKeyCreate( + size_t ephemPrivSize, /*!< [in] The size of the generated ephemeral private key (a). + The range is between CRYS_SRP_PRIV_NUM_MIN_SIZE to + CRYS_SRP_PRIV_NUM_MAX_SIZE */ + CRYS_SRP_Modulus_t userPubKeyA, /*!< [out] A Pointer to the user ephemeral public key (A). */ + CRYS_SRP_Context_t *pCtx /*!< [in/out] A Pointer to the SRP context.*/ +); + + +/****************************************************************************************************/ +/*! +@brief This function calculates the user proof. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_UserProofCalc( + size_t saltSize, /*!< [in] The size of the random salt, + The range is between CRYS_SRP_MIN_SALT_SIZE + to CRYS_SRP_MAX_SALT_SIZE. */ + uint8_t *pSalt, /*!< [in] A Pointer to the pSalt number.*/ + CRYS_SRP_Modulus_t userPubKeyA, /*!< [in] A Pointer to the user public ephmeral key (A).*/ + CRYS_SRP_Modulus_t hostPubKeyB, /*!< [in] A Pointer to the host public ephmeral key (B).*/ + CRYS_SRP_Digest_t userProof, /*!< [out] A Pointer to the SRP user proof buffer (M1).*/ + CRYS_SRP_Secret_t sharedSecret, /*!< [out] A Pointer to the SRP shared secret (K).*/ + CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP context.*/ +); + +/****************************************************************************************************/ +/*! +@brief This function verifies the host proof + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_srp_error.h or crys_hash_error.h. +*/ +CIMPORT_C CRYSError_t CRYS_SRP_UserProofVerify( + CRYS_SRP_Secret_t sharedSecret, /*!< [in] A Pointer to the SRP shared secret (K).*/ + CRYS_SRP_Modulus_t userPubKeyA, /*!< [in] A Pointer to the user public ephmeral key (A).*/ + CRYS_SRP_Digest_t userProof, /*!< [in] A Pointer to the SRP user proof buffer (M1).*/ + CRYS_SRP_Digest_t hostProof, /*!< [in] A Pointer to the SRP host proof buffer (M2).*/ + CRYS_SRP_Context_t *pCtx /*!< [out] A Pointer to the SRP user context.*/ +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef CRYS_SRP_H */ + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp_error.h new file mode 100644 index 0000000..085b03b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/crys_srp_error.h @@ -0,0 +1,91 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_SRP_ERROR_H +#define CRYS_SRP_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS SRP errors. +@defgroup crys_srp_error CryptoCell SRP specific errors +@{ +@ingroup crys_srp +*/ + + + +/************************ Defines ******************************/ + +/*! The CRYS SRP module errors base address - 0x00F02600. */ +/*! Illegal parameter. */ +#define CRYS_SRP_PARAM_INVALID_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x01UL) +/*! Illegal modulus size . */ +#define CRYS_SRP_MOD_SIZE_INVALID_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal state (uninitialized) . */ +#define CRYS_SRP_STATE_UNINITIALIZED_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x03UL) +/*! Result validation error. */ +#define CRYS_SRP_RESULT_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x04UL) +/*! Invalid parameter. */ +#define CRYS_SRP_PARAM_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x05UL) +/*! Internal PKI error */ +#define CRYS_SRP_PKI_INTERNAL_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x06UL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/dx_reg_base_host.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/dx_reg_base_host.h new file mode 100644 index 0000000..8c60ff3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/dx_reg_base_host.h @@ -0,0 +1,60 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 __DX_REG_BASE_HOST_H__ +#define __DX_REG_BASE_HOST_H__ + +/* Identify platform: Xilinx Zynq7000 ZC706 */ +#define DX_PLAT_ZYNQ7000 1 +#define DX_PLAT_ZYNQ7000_ZC706 1 + +/* SEP core clock frequency in MHz */ +#define DX_SEP_FREQ_MHZ 64 +#if defined(CRYPTOCELL_ARCH_BASE_ADDRESS) +#define DX_BASE_CC CRYPTOCELL_ARCH_BASE_ADDRESS +#else +#error Please set CRYPTOCELL_ARCH_BASE_ADDRESS to a non-negative number +#endif + +#define DX_BASE_ENV_REGS 0x40008000 +#define DX_BASE_ENV_CC_MEMORIES 0x40008000 +#define DX_BASE_ENV_FLASH 0x40008700 +#define DX_BASE_ENV_PERF_RAM 0x40009000 + +#define DX_BASE_HOST_RGF 0x0UL +#define DX_BASE_CRY_KERNEL 0x0UL +#define DX_BASE_ROM 0x40000000 + +#define DX_BASE_RNG 0x0000UL +#endif /*__DX_REG_BASE_HOST_H__*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/sns_silib.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/sns_silib.h new file mode 100644 index 0000000..5760501 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/sns_silib.h @@ -0,0 +1,101 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the + CryptoCell Lib init and finish APIs, as well as the APIs themselves. +@defgroup sns_silib CryptoCell library basic APIs +@{ +@ingroup cryptocell_api + +*/ + +#ifndef __SNS_SILIB_H__ +#define __SNS_SILIB_H__ + +#include "ssi_pal_types.h" +#include "crys_rnd.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! Definitions for error returns from SaSi_LibInit or SaSi_LibFini functions. */ +typedef enum { + SA_SILIB_RET_OK = 0, /*!< Success defintion.*/ + SA_SILIB_RET_EINVAL_CTX_PTR, /*!< Illegal context pointer.*/ + SA_SILIB_RET_EINVAL_WORK_BUF_PTR, /*!< Illegal work buffer pointer.*/ + SA_SILIB_RET_HAL, /*!< Error returned from HAL layer.*/ + SA_SILIB_RET_PAL, /*!< Error returned from PAL layer.*/ + SA_SILIB_RET_EINVAL_HW_VERSION, /*!< Invalid HW version. */ + SA_SILIB_RET_EINVAL_HW_SIGNATURE, /*!< Invalid HW signature. */ + SA_SILIB_RESERVE32B = 0x7FFFFFFFL /*!< Reserved.*/ +} SA_SilibRetCode_t; + + +/*! Internal defintion for the product register. */ +#define DX_VERSION_PRODUCT_BIT_SHIFT 0x18UL +/*! Internal defintion for the product register size. */ +#define DX_VERSION_PRODUCT_BIT_SIZE 0x8UL + + + +/*! +@brief This function Perform global initialization of the ARM CryptoCell 3xx runtime library; +it must be called once per ARM CryptoCell for 3xx cold boot cycle. + +\note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library, +this API is not thread-safe. +@return SA_SILIB_RET_OK on success. +@return A non-zero value in case of failure. +*/ +SA_SilibRetCode_t SaSi_LibInit(void); + +/*! +@brief This function finalize the library operations. It frees the associated resources (mutexes) and call hal and pal terminate functions. +in case of active instansiation - one must call CRYS_RND_UnInstantiation to clean the rnd state. +*/ +void SaSi_LibFini(void); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*__DX_CCLIB_H__*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes.h new file mode 100644 index 0000000..a42b65f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes.h @@ -0,0 +1,325 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the +CryptoCell AES APIs, as well as the APIs themselves. +@defgroup ssi_aes CryptoCell AES APIs +@{ +@ingroup cryptocell_api +*/ + +#ifndef SSI_AES_H +#define SSI_AES_H + +#include "ssi_pal_types.h" +#include "ssi_aes_error.h" +#include "ssi_aes_defs.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ + + +/************************ Enums ********************************/ + +/*! +Encrypt or Decrypt operation mode. +*/ +typedef enum { + /*! Encrypt operation. */ + SASI_AES_ENCRYPT = 0, + /*! Decrypt operation. */ + SASI_AES_DECRYPT = 1, + /*! Maximal number of operations. */ + SASI_AES_NUM_OF_ENCRYPT_MODES, + /*! Reserved. */ + SASI_AES_ENCRYPT_MODE_LAST = 0x7FFFFFFF +}SaSiAesEncryptMode_t; + +/*! +AES operation mode. +*/ +typedef enum { + SASI_AES_MODE_ECB = 0, /*!< ECB mode. */ + SASI_AES_MODE_CBC = 1, /*!< CBC mode. */ + SASI_AES_MODE_CBC_MAC = 2, /*!< CBC-MAC mode. */ + SASI_AES_MODE_CTR = 3, /*!< CTR mode. */ + SASI_AES_MODE_XCBC_MAC = 4, /*!< XCBC-MAC mode. */ + SASI_AES_MODE_CMAC = 5, /*!< CMAC mode. */ + SASI_AES_MODE_XTS = 6, /*!< XTS mode. */ + SASI_AES_MODE_CBC_CTS = 7, /*!< CBC-CTS mode. */ + SASI_AES_MODE_OFB = 8, /*!< OFB mode. */ + + /*! Maximal number of AES modes */ + SASI_AES_NUM_OF_OPERATION_MODES, + /*! Reserved. */ + SASI_AES_OPERATION_MODE_LAST = 0x7FFFFFFF +}SaSiAesOperationMode_t; + +/*! +AES padding type. +*/ +typedef enum { + SASI_AES_PADDING_NONE = 0, /*!< No padding. */ + SASI_AES_PADDING_PKCS7 = 1, /*!< PKCS7 padding. */ + + /*! Maximal number of AES padding modes */ + SASI_AES_NUM_OF_PADDING_TYPES, + /*! Reserved. */ + SASI_AES_PADDING_TYPE_LAST = 0x7FFFFFFF +}SaSiAesPaddingType_t; + +/*! +AES key type. +*/ +typedef enum { + SASI_AES_USER_KEY = 0, /*!< user key. */ + SASI_AES_PLATFORM_KEY = 1, /*!< Kplt hardware key. */ + SASI_AES_CUSTOMER_KEY = 2, /*!< Kcst hardware key. */ + + /*! Maximal number of AES key types */ + SASI_AES_NUM_OF_KEY_TYPES, + /*! Reserved. */ + SASI_AES_KEY_TYPE_LAST = 0x7FFFFFFF +}SaSiAesKeyType_t; + +/************************ Typedefs ****************************/ + +/*! Defines the IV buffer - 16 bytes array. */ +typedef uint8_t SaSiAesIv_t[SASI_AES_IV_SIZE_IN_BYTES]; + +/*! Defines the AES key data buffer. */ +typedef uint8_t SaSiAesKeyBuffer_t[SASI_AES_KEY_MAX_SIZE_IN_BYTES]; + +/************************ Structs ******************************/ + +/*! The user's context prototype - the argument type that is passed by the user + to the AES APIs. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow*/ +typedef struct SaSiAesUserContext_t { + /*! Context buffer for internal usage. */ + uint32_t buff[SASI_AES_USER_CTX_SIZE_IN_WORDS]; +}SaSiAesUserContext_t; + + +/*! AES User Key Data. */ +typedef struct SaSiAesUserKeyData_t { + uint8_t * pKey; /*!< Pointer to the key. */ + size_t keySize; /*!< The key size in bytes. Valid values: +
      • For XTS mode - 32 or 64 byte, indicating the full size of the double key (2x128 or 2x256 bit).
      • +
      • For XCBC-MAC mode - 16 byte (limited by the standard).
      • +
      • For all other modes - 16, 24 or 32 byte.
      */ +}SaSiAesUserKeyData_t; + +/*! AES HW Key Data - this structure is likely to be changed when we'll start using it. */ +typedef struct SaSiAesHwKeyData_t { + size_t slotNumber; /*!< Slot number. */ +}SaSiAesHwKeyData_t; + + +/************************ Functions *****************************/ + +/*! +@brief This function is used to initialize an AES operation context. + To operate the AES machine, this must be the first API called. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesInit( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context buffer that is allocated by the caller and initialized by this API. + Should be used in all subsequent calls that are part of the same operation. */ + SaSiAesEncryptMode_t encryptDecryptFlag, /*!< [in] A flag specifying whether an AES Encrypt (SASI_AES_Encrypt) or Decrypt (SASI_AES_Decrypt) operation should be performed. + Must be set to CRYS_AES_Encrypt in CBC-MAC, XCBC-MAC and CMAC modes. */ + SaSiAesOperationMode_t operationMode, /*!< [in] The operation cipher/mode. */ + SaSiAesPaddingType_t paddingType /*!< [in] The padding type for AES operation: +
      • NONE - supported for all operation modes.
      • +
      • PKCS7 - supported for ECB, CBC, CBC-MAC operation modes.
      */ +); + + +/*! +@brief This function sets the key information for the AES operation, in the context that was initialized by SaSi_AesInit. +\note When FIPS certification mode is set to ON, and the mode is AES-XTS, weak keys are not allowed (128/256 lsb bits must be +different than 128/256 msb bits, according to the key size). +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesSetKey( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context, after it was initialized by SaSi_AesInit. */ + SaSiAesKeyType_t keyType, /*!< [in] The type of key to be used for the AES operation. + Currently only SASI_AES_USER_KEY is supported - the key is plaintext and provided in the pKeyData parameter. */ + void * pKeyData, /*!< [in] Pointer to the key data structure (to be casted to the relevant struct type). */ + size_t keyDataSize /*!< [in] The size of data passed in pKeyData in bytes. */ +); + + +/*! +@brief This function sets the IV, counter or tweak data for the following AES operation on the same context. + The context must be first initialized by SaSi_AesInit. + It must be called at least once prior to the first SaSi_AesBlock operation on the same context - for those ciphers that require it. + If needed, it can also be called to override the IV in the middle of a sequence of SaSi_AesBlock operations. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesSetIv( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + SaSiAesIv_t pIV /*!< [in] Pointer to the buffer of the IV, counter or tweak. +
      • For CBC, CBC-CTS, OFB and CBC-MAC modes - the IV value.
      • +
      • For CTR mode - the counter.
      • +
      • For XTS mode - the tweak value.
      • +
      • For all other modes - N/A.
      */ +); + + +/*! +@brief This function retrieves the current IV, counter or tweak from the AES context. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesGetIv( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + SaSiAesIv_t pIV /*!< [out] Pointer to the buffer of the IV, counter or tweak. +
      • For CBC, CBC-CTS, OFB and CBC-MAC modes - the IV value.
      • +
      • For CTR mode - the counter.
      • +
      • For XTS mode - the tweak value.
      • +
      • For all other modes - N/A.
      */ +); + + +/*! +@brief This function performs an AES operation on an input data buffer, according to the configuration defined in the context parameter. + It can be called as many times as needed, until all the input data is processed. + SaSi_AesInit, SaSi_AesSetKey, and for some ciphers SaSi_AesSetIv, must be called before + the first call to this API with the same context. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesBlock( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + uint8_t * pDataIn, /*!< [in] Pointer to the buffer of the input data to the AES. The pointer does not need to be aligned. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ + size_t dataInSize, /*!< [in] Size of the input data in bytes. +
      • For all modes except XTS, must be multiple of 16 bytes.
      • +
      • For XTS mode, only the following data sizes are supported: 64, 512, 520, 521, 1024 and 4096 bytes. + The data passed in a single SaSi_AesBlock call is considered to be a single XTS unit. + All subsequent calls to this API with the same context must use the same data size.
      */ + uint8_t * pDataOut /*!< [out] Pointer to the output buffer. The pointer does not need to be aligned. + For CBC-MAC, XCBC-MAC, CMAC modes it may be NULL. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ +); + + +/*! +@brief This function is used to finish AES operation. + + It processes the last data block if needed, finalizes the AES operation (cipher-specific), + and produces operation results (for MAC operations). + \note In case AES padding is used (PKCS#7) Din and Dout user's buffers must include extra space for + the padding scheme. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesFinish( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + size_t dataSize, /*!< [in] The size of the input data in bytes. +
      • For CBC-CTS mode, must be > 16. Can be <=16 only if this is the only data (no previous calls were + made to SaSi_AesBlock with the same context).
      • +
      • For XTS mode, the data size must conform to the dataInSize rules as listed for XTS under the + SaSi_AesBlock API, and match the data size passed in the previous calls to SaSi_AesBlock with the + same context.
      • +
      • For all other modes, zero is a valid size.
      • +
      • For ECB, CBC, CBC-MAC modes:
      • +
        • Must be >= 0, if direction is SASI_AES_ENCRYPT and padding type is SASI_AES_PADDING_PKCS7.
        • +
        • Must be >= 16 and a multiple of 16 bytes, if direction is SASI_AES_DECRYPT and padding type + is SASI_AES_PADDING_PKCS7.
        • +
        • Must be a multiple of 16 bytes, otherwise.
      */ + uint8_t * pDataIn, /*!< [in] Pointer of the input data buffer. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ + size_t dataInBuffSize, /*!< [in] Size of pDataIn buffer in bytes. +
      • Must be >= dataSize.
      • +
      • According to padding type, must be >= dataSize + padding. For PKCS7, padding size is + maximum SASI_AES_BLOCK_SIZE_IN_BYTES.
      */ + uint8_t * pDataOut, /*!< [out] Pointer to the output buffer. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ + size_t * dataOutBuffSize /*!< [in,out] In - Size of pDataOut buffer in bytes. + The output buffer size must be no less than: +
      • For CBC-MAC, XCBC-MAC, CMAC modes - 16 bytes (for MAC result).
      • +
      • For non-MAC modes - dataInBuffSize.
      + Out - The size in bytes of the actual output data: +
      • If direction is SASI_AES_ENCRYPT and padding type is SASI_AES_PADDING_PKCS7, it is the actual size + with the padding.
      • +
      • If direction is SASI_AES_DECRYPT and padding type is SASI_AES_PADDING_PKCS7, it is the size without + the padding.
      • +
      • For CBC-MAC, XCBC-MAC, CMAC modes - always 16 bytes.
      */ +); + + +/*! +@brief This function releases and crears resources after AES operations. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesFree( + SaSiAesUserContext_t * pContext /*!< [in] Pointer to the AES context. */ +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef SSI_AES_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_defs.h new file mode 100644 index 0000000..02789d0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_defs.h @@ -0,0 +1,83 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains definitions that are used for the ARM CryptoCell 3xx version of the CryptoCell AES APIs. +@defgroup ssi_aes_defs CryptoCell AES definitions +@{ +@ingroup ssi_aes + +*/ + +#ifndef SSI_AES_DEFS_H +#define SSI_AES_DEFS_H + +#include "ssi_pal_types.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ + +/*! The size of the user's context prototype (see ::SaSiAesUserContext_t) in words. */ +#define SASI_AES_USER_CTX_SIZE_IN_WORDS (4+4+7+4) + +/*! The AES block size in words. */ +#define SASI_AES_BLOCK_SIZE_IN_WORDS 4 +/*! The AES block size in bytes. */ +#define SASI_AES_BLOCK_SIZE_IN_BYTES (SASI_AES_BLOCK_SIZE_IN_WORDS * sizeof(uint32_t)) + +/*! The size of the IV buffer in words. */ +#define SASI_AES_IV_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS +/*! The size of the IV buffer in bytes. */ +#define SASI_AES_IV_SIZE_IN_BYTES (SASI_AES_IV_SIZE_IN_WORDS * sizeof(uint32_t)) + +/*! The maximum size of the AES KEY in words. */ +#define SASI_AES_KEY_MAX_SIZE_IN_WORDS 4 +/*! The maximum size of the AES KEY in bytes. */ +#define SASI_AES_KEY_MAX_SIZE_IN_BYTES (SASI_AES_KEY_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef SSI_AES_DEFS_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_error.h new file mode 100644 index 0000000..11c6927 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_aes_error.h @@ -0,0 +1,133 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains the definitions of the CryptoCell AES errors. +@defgroup ssi_aes_error CryptoCell AES specific errors +@{ +@ingroup ssi_aes +*/ + +#ifndef SSI_AES_ERROR_H +#define SSI_AES_ERROR_H + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ + +/* generic errors */ +/*! General fatal error. */ +#define SASI_FATAL_ERROR CRYS_FATAL_ERROR +/*! General out of resources error. */ +#define SASI_OUT_OF_RESOURCE_ERROR CRYS_OUT_OF_RESOURCE_ERROR +/*! General Illegal resource value error. */ +#define SASI_ILLEGAL_RESOURCE_VAL_ERROR CRYS_ILLEGAL_RESOURCE_VAL_ERROR + +/*! CRYS_AES_MODULE_ERROR_BASE - 0x00F00000. */ +/*! Illegal user context. */ +#define SASI_AES_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x00UL) +/*! Illegal IV or tweak pointer. */ +#define SASI_AES_INVALID_IV_OR_TWEAK_PTR_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x01UL) +/*! Illegal operation. */ +#define SASI_AES_ILLEGAL_OPERATION_MODE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal key size. */ +#define SASI_AES_ILLEGAL_KEY_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x03UL) +/*! Illegal key pointer. */ +#define SASI_AES_INVALID_KEY_POINTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x04UL) +/*! Unsupported key type. */ +#define SASI_AES_KEY_TYPE_NOT_SUPPORTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x05UL) +/*! Illegal operation. */ +#define SASI_AES_INVALID_ENCRYPT_MODE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x06UL) +/*! User context corrupted. */ +#define SASI_AES_USER_CONTEXT_CORRUPTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal data in pointer. */ +#define SASI_AES_DATA_IN_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x08UL) +/*! Illegal data out pointer. */ +#define SASI_AES_DATA_OUT_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x09UL) +/*! Illegal data in size. */ +#define SASI_AES_DATA_IN_SIZE_ILLEGAL (CRYS_AES_MODULE_ERROR_BASE + 0x0AUL) +/*! Illegal data out address. */ +#define SASI_AES_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0BUL) +/*! Illegal data in buffer size. */ +#define SASI_AES_DATA_IN_BUFFER_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0CUL) +/*! Illegal data out buffer size. */ +#define SASI_AES_DATA_OUT_BUFFER_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0DUL) +/*! Illegal padding type. */ +#define SASI_AES_ILLEGAL_PADDING_TYPE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0EUL) +/*! Incorrect padding. */ +#define SASI_AES_INCORRECT_PADDING_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0FUL) +/*! Output is corrupted. */ +#define SASI_AES_CORRUPTED_OUTPUT_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x10UL) +/*! Illegal output size. */ +#define SASI_AES_DATA_OUT_SIZE_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x11UL) +/*! Decryption operation is not permitted in this mode. */ +#define SASI_AES_DECRYPTION_NOT_ALLOWED_ON_THIS_MODE (CRYS_AES_MODULE_ERROR_BASE + 0x12UL) +/*! Additional block operation is not permitted. */ +#define SASI_AES_ADDITIONAL_BLOCK_NOT_PERMITTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x15UL) +/*! Illegal context size. */ +#define SASI_AES_CTX_SIZES_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x16UL) + +/*! Illegal parameters. */ +#define SASI_AES_ILLEGAL_PARAMS_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x60UL) +/*! Illegal CTR block offset. */ +#define SASI_AES_CTR_ILLEGAL_BLOCK_OFFSET_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x70UL) +/*! Illegal counter (in CTR mode). */ +#define SASI_AES_CTR_ILLEGAL_COUNTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x71UL) +/*! AES is not supported. */ +#define SASI_AES_IS_NOT_SUPPORTED (CRYS_AES_MODULE_ERROR_BASE + 0xFFUL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef SSI_AES_ERROR_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_bitops.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_bitops.h new file mode 100644 index 0000000..56c85ee --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_bitops.h @@ -0,0 +1,81 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 ssi_bitops.h + * Bit fields operations macros. + */ +#ifndef _SSI_BITOPS_H_ +#define _SSI_BITOPS_H_ + +#define BITMASK(mask_size) (((mask_size) < 32) ? \ + ((1UL << (mask_size)) - 1) : 0xFFFFFFFFUL) +#define BITMASK_AT(mask_size, mask_offset) (BITMASK(mask_size) << (mask_offset)) + +#define BITFIELD_GET(word, bit_offset, bit_size) \ + (((word) >> (bit_offset)) & BITMASK(bit_size)) +#define BITFIELD_SET(word, bit_offset, bit_size, new_val) do { \ + word = ((word) & ~BITMASK_AT(bit_size, bit_offset)) | \ + (((new_val) & BITMASK(bit_size)) << (bit_offset)); \ +} while (0) + +/* Is val aligned to "align" ("align" must be power of 2) */ +#ifndef IS_ALIGNED +#define IS_ALIGNED(val, align) \ + (((uint32_t)(val) & ((align) - 1)) == 0) +#endif + +#define SWAP_ENDIAN(word) \ + (((word) >> 24) | (((word) & 0x00FF0000) >> 8) | \ + (((word) & 0x0000FF00) << 8) | (((word) & 0x000000FF) << 24)) + +#ifdef BIG__ENDIAN +#define SWAP_TO_LE(word) SWAP_ENDIAN(word) +#define SWAP_TO_BE(word) word +#else +#define SWAP_TO_LE(word) word +#define SWAP_TO_BE(word) SWAP_ENDIAN(word) +#endif + + + +/* Is val a multiple of "mult" ("mult" must be power of 2) */ +#define IS_MULT(val, mult) \ + (((val) & ((mult) - 1)) == 0) + +#define IS_NULL_ADDR(adr) \ + (!(adr)) + +#endif /*_SSI_BITOPS_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_abort.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_abort.h new file mode 100644 index 0000000..8d7035b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_abort.h @@ -0,0 +1,80 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_ABORT_H +#define _SSI_PAL_ABORT_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/*! +@defgroup ssi_pal CryptoCell PAL APIs +@{ +@ingroup cryptocell_api +@brief This group is the PAL root group +@} + +@file +@brief This file contains definitions for PAL Abort API. +@defgroup ssi_pal_abort CryptoCell PAL abort APIs +@{ +@ingroup ssi_pal + +*/ + +/*! +This function performs the "Abort" operation, should be implemented according to platform and OS. +*/ + +void SaSi_PalAbort(const char *msg); +/** +@} + */ + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_barrier.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_barrier.h new file mode 100644 index 0000000..1188026 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_barrier.h @@ -0,0 +1,71 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_BARRIER_H +#define _SSI_PAL_BARRIER_H + +/*! +@file +@brief This file contains the definitions and APIs for memory barrier implementation. + This is a place holder for platform specific memory barrier implementation + The secure core driver should include a memory barrier before and after the last word of the descriptor + to allow correct order between the words and different descriptors. +@defgroup ssi_pal_barrier CryptoCell PAL memory Barrier APIs +@{ +@ingroup ssi_pal + +*/ + +/*! + * This MACRO is responsible to put the memory barrier after the write operation. + * + * @return None + */ + +void SaSi_PalWmb(void); + +/*! + * This MACRO is responsible to put the memory barrier before the read operation. + * + * @return None + */ +void SaSi_PalRmb(void); + +/** +@} + */ +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_compiler.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_compiler.h similarity index 62% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_compiler.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_compiler.h index 6d914ab..081ce72 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/nrf_cc310/include/ssi_pal_compiler.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_compiler.h @@ -1,13 +1,37 @@ -// Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved -// -// This file and the related binary are licensed under the ARM Object Code and -// Headers License; you may not use these files except in compliance with this -// license. -// -// You may obtain a copy of the License at <.../external/nrf_cc310/license.txt> -// -// See the License for the specific language governing permissions and -// limitations under the License. +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 __SSI_PAL_COMPILER_H__ #define __SSI_PAL_COMPILER_H__ @@ -15,6 +39,10 @@ /*! @file @brief This file contains compiler related definitions. +@defgroup ssi_pal_compiler CryptoCell PAL platform dependant compiler specific definitions +@{ +@ingroup ssi_pal + */ #ifdef __GNUC__ @@ -33,7 +61,7 @@ /*! Mark function that never returns. */ #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn)) -/* Prevent function from being inlined */ +/*! Prevent function from being inlined */ #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline)) /*! Given data type may cast (alias) another data type pointer. */ @@ -51,7 +79,7 @@ enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) } #elif defined(__ARM_DSM__) || defined(__CC_ARM) -#define inline +#define inline /*! Associate a symbol with a link section. */ #define SASI_PAL_COMPILER_SECTION(sectionName) __attribute__((section(sectionName))) @@ -100,7 +128,7 @@ /*! Given data type may cast (alias) another data type pointer. */ /* (this is used for "superclass" struct casting) */ -#define SASI_PAL_COMPILER_TYPE_MAY_ALIAS +#define SASI_PAL_COMPILER_TYPE_MAY_ALIAS /*! Get sizeof for a structure type member. */ #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \ @@ -135,7 +163,7 @@ /*! Given data type may cast (alias) another data type pointer. */ /* (this is used for "superclass" struct casting). Not implemented */ -#define SASI_PAL_COMPILER_TYPE_MAY_ALIAS +#define SASI_PAL_COMPILER_TYPE_MAY_ALIAS /*! Get sizeof for a structure type member. */ #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \ @@ -149,8 +177,10 @@ enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) } -#else +#else #error Unsupported compiler. #endif - +/** +@} + */ #endif /*__SSI_PAL_COMPILER_H__*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma.h new file mode 100644 index 0000000..2a89846 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma.h @@ -0,0 +1,175 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_DMA_H +#define _SSI_PAL_DMA_H + +/*! +@file +@brief This file contains definitions that are used for the DMA related APIs. The implementation of these functions +need to be replaced according to Platform and OS. +@defgroup ssi_pal_dma CryptoCell PAL DMA related APIs +@{ +@ingroup ssi_pal + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "ssi_pal_types.h" +#include "ssi_pal_dma_plat.h" +#include "ssi_pal_dma_defs.h" + +/*! User buffer scatter information. */ +typedef struct { + SaSiDmaAddr_t blockPhysAddr; /*!< Physical address.*/ + uint32_t blockSize; /*!< Block size.*/ +}SaSi_PalDmaBlockInfo_t; + +#ifdef BIG__ENDIAN +/*! Defintion for big to little endian. */ +#define SET_WORD_LE(val) cpu_to_le32(val) +#else +/*! Defintion for big to little endian. */ +#define SET_WORD_LE +#endif + +/** + * @brief This function is called by the ARM TrustZone CryptoCell TEE runtime library before the HW is used. + * It maps a given data buffer (virtual address) for ARM TrustZone CryptoCell TEE HW DMA use (physical address), and returns the list of + * one or more DMA-able (physical) blocks. It may lock the buffer for ARM TrustZone CryptoCell TEE HW use. Once it is called, + * only ARM TrustZone CryptoCell TEE HW access to the buffer is allowed, until it is unmapped. + * If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, + * this API does not have to perform any actual mapping operation, but only return the list of DMA-able blocks. + * + * @return A non-zero value in case of failure. + */ +uint32_t SaSi_PalDmaBufferMap(uint8_t *pDataBuffer, /*!< [in] Address of the buffer to map. */ + uint32_t buffSize, /*!< [in] Buffer size in bytes. */ + SaSi_PalDmaBufferDirection_t copyDirection, /*!< [in] Copy direction of the buffer, according to ::SaSi_PalDmaBufferDirection_t, +
      • TO_DEVICE - the original buffer is the input to the operation, + and this function should copy it to the temp buffer, + prior to the activating the HW on the temp buffer.
      • +
      • FROM_DEVICE - not relevant for this API.
      • +
      • BI_DIRECTION - used when the crypto operation is "in-place", meaning + the result of encryption or decryption is written over the original data + at the same address. Should be treated by this API same as + TO_DEVICE.
      */ + uint32_t *pNumOfBlocks, /*!< [in/out] Maximum numOfBlocks to fill, as output the actual number. */ + SaSi_PalDmaBlockInfo_t *pDmaBlockList, /*!< [out] List of DMA-able blocks that the buffer maps to. */ + SaSi_PalDmaBufferHandle *dmaBuffHandle /*!< [out] A handle to the mapped buffer private resources.*/ ); + + +/** + * @brief This function is called by the ARM TrustZone CryptoCell TEE runtime library after the HW is used. + * It unmaps a given buffer, and frees its associated resources, if needed. It may unlock the buffer and flush it for CPU use. + * Once it is called, ARM TrustZone CryptoCell TEE HW does not require access to this buffer anymore. + * If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, this API does + * not have to perform any un-mapping operation, and the actual un-mapping can be done by the Secure OS outside the context + * of the ARM TrustZone CryptoCell TEE runtime library. + * @return A non-zero value in case of failure. + */ +uint32_t SaSi_PalDmaBufferUnmap(uint8_t *pDataBuffer, /*!< [in] Address of the buffer to unmap. */ + uint32_t buffSize, /*!< [in] Buffer size in bytes. */ + SaSi_PalDmaBufferDirection_t copyDirection, /*!< [in] Copy direction of the buffer, according to ::SaSi_PalDmaBufferDirection_t +
      • TO_DEVICE - not relevant for this API.
      • +
      • FROM_DEVICE - the temp buffer holds the output of the HW, and this + API should copy it to the actual output buffer.
      • +
      • BI_DIRECTION - used when the crypto operation is "in-place", meaning + the result of encryption or decryption is written over the original data + at the same address. Should be treated by this API same as + FROM_DEVICE.
      */ + uint32_t numOfBlocks, /*!< [in] Number of DMA-able blocks that the buffer maps to. */ + SaSi_PalDmaBlockInfo_t *pDmaBlockList, /*!< [in] List of DMA-able blocks that the buffer maps to. */ + SaSi_PalDmaBufferHandle dmaBuffHandle /*!< [in] A handle to the mapped buffer private resources. */); + + +/** + * @brief Allocates a DMA-contiguous buffer for CPU use, and returns its virtual address. + * Before passing the buffer to the ARM TrustZone CryptoCell TEE HW, ::SaSi_PalDmaBufferMap should be called. + * \note The returned address must be aligned to 32 bits. + * + * + * @return A non-zero value in case of failure. + */ +uint32_t SaSi_PalDmaContigBufferAllocate(uint32_t buffSize, /*!< [in] Buffer size in bytes.*/ + uint8_t **ppVirtBuffAddr /*!< [out] Virtual address of the allocated buffer.*/); + + + +/** + * @brief Frees resources previously allocated by ::SaSi_PalDmaContigBufferAllocate. + * + * + * @return A non-zero value in case of failure. + */ +uint32_t SaSi_PalDmaContigBufferFree(uint32_t buffSize, /*!< [in] Buffer size in Bytes. */ + uint8_t *pVirtBuffAddr /*!< [in] Virtual address of the buffer to free. */); + + + +/** + * @brief Checks whether the buffer is guaranteed to be a single contiguous DMA block. + * + * + * @return Returns TRUE if the buffer is guaranteed to be a single contiguous DMA block, and FALSE otherwise. + */ +uint32_t SaSi_PalIsDmaBufferContiguous(uint8_t *pDataBuffer, /*!< [in] User buffer address. */ + uint32_t buffSize /*!< [in] User buffer size. */); + + +/** + * @brief Maps virtual address to physical address. + * + * + * @return Physical address. + */ +SaSiDmaAddr_t SaSi_PalMapVirtualToPhysical(uint8_t *pVirtualAddr /*!< [in] Pointer to virtual address. */); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_defs.h new file mode 100644 index 0000000..ce74c10 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_defs.h @@ -0,0 +1,77 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains the platform dependent DMA definitions. +@defgroup ssi_pal_dma_defs CryptoCell PAL DMA specific definitions +@{ +@ingroup ssi_pal +*/ + +#ifndef _SSI_PAL_DMA_DEFS_H +#define _SSI_PAL_DMA_DEFS_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! Definition for DMA buffer handle.*/ +typedef void * SaSi_PalDmaBufferHandle; + +/*! DMA directions configuration */ +typedef enum { + SASI_PAL_DMA_DIR_NONE = 0, /*!< No direction. */ + SASI_PAL_DMA_DIR_TO_DEVICE = 1, /*!< The original buffer is the input to the operation, and should be copied/mapped to a temp buffer, + prior to activating the HW on the temp buffer. */ + SASI_PAL_DMA_DIR_FROM_DEVICE = 2, /*!< The temp buffer holds the output of the HW, and this API should copy/map it to the original output buffer.*/ + SASI_PAL_DMA_DIR_BI_DIRECTION = 3, /*!< Used when the result is written over the original data at the same address. should be treated as 1 & 2.*/ + SASI_PAL_DMA_DIR_MAX, /*!< Maximal DMA directions options. */ + SASI_PAL_DMA_DIR_RESERVE32 = 0x7FFFFFFF /*!< Reserved.*/ +}SaSi_PalDmaBufferDirection_t; + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_plat.h new file mode 100644 index 0000000..e296977 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_dma_plat.h @@ -0,0 +1,72 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_DMA_PLAT_H +#define _SSI_PAL_DMA_PLAT_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief stub function, the function should initialize the DMA mapping of the platform (if needed) + * + * @param[in] buffSize - buffer size in Bytes + * @param[in] physBuffAddr - physical start address of the memory to map + * + * @return Virtual start address of contiguous memory + */ +extern uint32_t SaSi_PalDmaInit(uint32_t buffSize, + uint32_t physBuffAddr); + +/** + * @brief free system resources created in PD_PAL_DmaInit() + * + * + * @return void + */ +extern void SaSi_PalDmaTerminate(void); +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_error.h new file mode 100644 index 0000000..9210acd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_error.h @@ -0,0 +1,84 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_ERROR_H +#define _SSI_PAL_ERROR_H + +/*! +@file +@brief This file contains the platform dependent error definitions. +@defgroup ssi_pal_error CryptoCell PAL specific errors +@{ +@ingroup ssi_pal + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! PAL error base.*/ +#define SASI_PAL_BASE_ERROR 0x0F000000 + +/* Memory error returns */ +/*! Buffer 1 is greater than buffer 2 error.*/ +#define SASI_PAL_MEM_BUF1_GREATER SASI_PAL_BASE_ERROR + 0x01UL +/*! Buffer 2 is greater than buffer 1 error.*/ +#define SASI_PAL_MEM_BUF2_GREATER SASI_PAL_BASE_ERROR + 0x02UL + +/* Semaphore error returns */ +/*! Semaphor creation failed.*/ +#define SASI_PAL_SEM_CREATE_FAILED SASI_PAL_BASE_ERROR + 0x03UL +/*! Semaphor deletion failed.*/ +#define SASI_PAL_SEM_DELETE_FAILED SASI_PAL_BASE_ERROR + 0x04UL +/*! Semaphor reached timeout.*/ +#define SASI_PAL_SEM_WAIT_TIMEOUT SASI_PAL_BASE_ERROR + 0x05UL +/*! Semaphor wait failed.*/ +#define SASI_PAL_SEM_WAIT_FAILED SASI_PAL_BASE_ERROR + 0x06UL +/*! Semaphor release failed.*/ +#define SASI_PAL_SEM_RELEASE_FAILED SASI_PAL_BASE_ERROR + 0x07UL +/*! PAL illegal address.*/ +#define SASI_PAL_ILLEGAL_ADDRESS SASI_PAL_BASE_ERROR + 0x08UL + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file.h new file mode 100644 index 0000000..a39875d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file.h @@ -0,0 +1,225 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_FILE_H +#define _SSI_PAL_FILE_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "ssi_pal_types.h" +#include "ssi_pal_file_plat.h" +/** +* @brief File Description: +* This file contains functions for file related operations. The functions implementations +* are generally just wrappers to different operating system calls. +* None of the described functions will check the input parameters so the behavior +* of the APIs in illegal parameters case is dependent on the operating system behavior. +* +*/ + +/**** ----- Files General Definitions ----- ****/ +typedef enum +{ + SASI_PAL_Read = 0, /* "r", read only */ + SASI_PAL_ReadAndWrite = 1, /* "r+", read and write */ + SASI_PAL_Write = 2, /* "w", write only */ + SASI_PAL_WriteAndRead = 3, /* "w+", write and read */ + SASI_PAL_Append = 4, /* "a", append to the end of file */ + SASI_PAL_AppendAndRead = 5, /* "a+", append (to the end of file) and read */ + SASI_PAL_ReadBinary = 6, /* "rb", read binary */ + SASI_PAL_ReadAndWriteBinary = 7, /* "r+b" read and write binary */ + SASI_PAL_WriteBinary = 8, /* "wb" write binary */ + SASI_PAL_WriteAndReadBinary = 9, /* "w+b" write and read binary */ + SASI_PAL_AppendBinary = 10, /* "ab" append binary */ + SASI_PAL_AppendAndReadBinary = 11, /* "a+b" append and read binary */ + + SASI_PAL_DummyMode = 0x7FFFFFFF + +}SaSi_PalFileMode_t; + +/* Definitions for SEEK positions */ + +#define SASI_PAL_SEEK_START 0 /* Seek from start of file */ +#define SASI_PAL_SEEK_CUR 1 /* Seek from current position */ +#define SASI_PAL_SEEK_END 2 /* Seek from end of file */ + +/* Definition for DxFile */ +typedef struct _SaSiFile_t* SaSiFile_t; +/**** ------------------------------------- ****/ + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/** + * @brief This function purpose is to create a new file. The function will delete a file + * If it is already exist. + * + * + * @param[in] aFileName - The file name to create + * + * @return The function returns a FILE handle to the opened file, in case of failure + * the function will return NULL + */ +SaSiFile_t SaSi_PalFileCreate( char *aFileName ); + +/* Definition for SaSi_PalFileCreate */ +#define SaSi_PalFileCreate(aFileName) _SaSi_PalFileCreate(aFileName) +/** + * @brief This function purpose is to create a new file. The function will delete a file + * If it is already exist. + * + * + * @param[in] aFileName - The file name to open + * @param[in] aFileMode - The mode to open the file + * + * @return The function returns a FILE handle to the opened file, in case of failure + * the function will return NULL + */ +SaSiFile_t SaSi_PalFOpen( char *aFileName, SaSi_PalFileMode_t aFileMode ); + +/* Definition for fopen */ +#define SaSi_PalFOpen(aFileName, aFileMode) _SaSi_PalFOpen(aFileName, aFileMode) +/** + * @brief This function purpose is to close a file (pointed by aFileHandle), The function + * will dissociate the file from the handle. + * + * + * @param[in] aFileHandle - The file name to create + * + * @return The return values is according to operating system return values. + */ +SaSiError_t SaSi_PalFClose( SaSiFile_t aFileHandle ); + +/* Definition for fclose */ +#define SaSi_PalFClose(aFileHandle) _SaSi_PalFClose(aFileHandle) + +/** + * @brief This function purpose is to change the file pointer position according to aOffset + * + * + * @param[in] aFileHandle - The file handle + * @param[in] aOffset - offset to move the file pointer inside the file + * @param[in] aSeekOrigin - seek origin (current, end or start) to move aOffset from + * + * @return The return values is according to operating system return values. + */ +SaSiError_t SaSi_PalFSeek( SaSiFile_t aFileHandle, int32_t aOffset, uint8_t aSeekOrigin ); + +/* Definition for fseek */ +#define SaSi_PalFSeek(aFileHandle ,aOffset, aSeekOrigin) _SaSi_PalFSeek(aFileHandle, aOffset, aSeekOrigin) + +/** + * @brief This function purpose is to return the file pointer position + * + * + * @param[in] aFileHandle - The file handle + * + * @return The file pointer position + */ +uint32_t SaSi_PalFTell( SaSiFile_t aFileHandle ); + +/* definition for SaSi_PalFTell */ +#define SaSi_PalFTell(aFileHandle) _SaSi_PalFTell(aFileHandle) + +/** + * @brief This function purpose is to read aSize of bytes from the file and write it + * to aBuffer. In case EOF reached before aSize is read the returned size is smaller + * than aSize. + * + * + * @param[in] aFileHandle - The file handle + * @param[in] aBuffer - Pointer to buffer to read the data into + * @param[in] aSize - Number of bytes to read from file + * + * @return The number of bytes read from the file + */ +uint32_t SaSi_PalFRead(SaSiFile_t aFileHandle, void *aBuffer, uint32_t aSize ); + +/* Definition for fread */ +#define SaSi_PalFRead(aFileHandle, aBuffer, aSize) _SaSi_PalFRead(aFileHandle, aBuffer, aSize) +/** + * @brief This function purpose is to write aSize bytes from aBuffer to the file pointed + * by aFileHandle. + * + * + * @param[in] aFileHandle - The file handle + * @param[in] aBuffer - Pointer to buffer to read the data into + * @param[in] aSize - Number of bytes to read from file + * + * @return The number of bytes written to the file + */ +uint32_t SaSi_PalFWrite( SaSiFile_t aFileHandle, const void *aBuffer, uint32_t aSize ); + +#define SaSi_PalFWrite(aFileHandle, aBuffer, aSize) _SaSi_PalFWrite(aFileHandle, aBuffer, aSize) +/** + * @brief This function purpose is to save all buffered data to disk + * + * + * @param[in] aFileHandle - The file handle + * + * @return The return values is according to operating system return values. + */ +SaSiError_t SaSi_PalFFlush( SaSiFile_t aFileHandle ); + +/* Definition for fflush */ +#define SaSi_PalFFlush(aFileHandle) _SaSi_PalFFlush(aFileHandle) + +/** + * @brief This function purpose is to return the file size + * + * + * @param[in] aFileHandle - The file handle + * @param[out] aFileSize - The returned file size + * + * @return The function will return SASI_SUCCESS in case of success, else errors from + * ssi_pal_error.h is returned. + */ +SaSiError_t SaSi_PalFGetFileSize( SaSiFile_t aFileHandle, uint32_t *aFileSize ); + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file_plat.h new file mode 100644 index 0000000..1d99c52 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_file_plat.h @@ -0,0 +1,128 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_FILE_INT_H +#define _SSI_PAL_FILE_INT_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "stdio.h" + +/** +* @brief File Description: +* This file contains wrapper functions for file related operations. +*/ + +/**** ----- Files General Definitions ----- ****/ + +/* Definitions for file modes */ +#define SASI_PAL_MAX_SIZE_MODE 4 +#define SASI_PAL_NUM_OF_SUPPORT_MODES 12 + +typedef char SaSiPalFileModeStr_t[SASI_PAL_MAX_SIZE_MODE]; + +typedef SaSiPalFileModeStr_t SaSiPalFileModesTable_t[SASI_PAL_NUM_OF_SUPPORT_MODES]; + +extern const SaSiPalFileModeStr_t SaSiPalFileModeTable[]; +/**** ------------------------------------- ****/ + +//#define _SaSiFile_t FILE + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ +/** +* @brief A wrapper for fopen functionality (to create a new file, the file is opened for read and +* write). +* +*/ +#define _SaSi_PalFileCreate(aFileName) SaSi_PalFOpen(aFileName, SASI_PAL_WriteAndRead) + +/** +* @brief A wrapper for fopen functionality. SaSiPalFileModeTable contains all possible modes +* for fopen +* +*/ +#define _SaSi_PalFOpen(aFileName, aFileMode) ((SaSiFile_t)fopen(aFileName, SaSiPalFileModeTable[aFileMode])) + +/** + * @brief A wrapper for fclose functionality. + * + */ +#define _SaSi_PalFClose(aFileHandle) fclose((FILE*)aFileHandle) + +/** + * @brief A wrapper for fseek functionality + * + */ +#define _SaSi_PalFSeek(aFileHandle, aOffset, aSeekOrigin) fseek((FILE*)aFileHandle, aOffset, aSeekOrigin) + +/** + * @brief A wrapper for ftell functionality + * + */ +#define _SaSi_PalFTell(aFileHandle) ftell((FILE*)aFileHandle) + +/** +* @brief A wrapper for fread functionality +* +*/ +#define _SaSi_PalFRead(aFileHandle, aBuffer, aSize) fread(aBuffer, 1, aSize, (FILE*)aFileHandle) + +/** +* @brief A wrapper for fwrite functionality +* +*/ +#define _SaSi_PalFWrite(aFileHandle, aBuffer, aSize) fwrite(aBuffer, 1, aSize, (FILE*)aFileHandle) +/** + * @brief A wrapper for fflush functionality + * + */ +#define _SaSi_PalFFlush(aFileHandle) fflush((FILE*)aFileHandle) + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_fips.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_fips.h new file mode 100644 index 0000000..5fba32e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_fips.h @@ -0,0 +1,119 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_FIPS_H +#define _SSI_PAL_FIPS_H + +/*! +@file +@brief This file contains definitions that are used by the FIPS related APIs. The implementation of these functions +need to be replaced according to Platform and OS. +*/ + +#include "ssi_pal_types_plat.h" +#include "crys_fips.h" +#include "crys_fips_defs.h" + +/** + * @brief This function purpose is to get the FIPS state. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsGetState(CC_FipsState_t *pFipsState); + + +/** + * @brief This function purpose is to get the FIPS Error. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsGetError(CC_FipsError_t *pFipsError); + + +/** + * @brief This function purpose is to get the FIPS trace. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsGetTrace(CC_FipsTrace_t *pFipsTrace); + + +/** + * @brief This function purpose is to set the FIPS state. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsSetState(CC_FipsState_t fipsState); + + +/** + * @brief This function purpose is to set the FIPS error. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsSetError(CC_FipsError_t fipsError); + + +/** + * @brief This function purpose is to set the FIPS trace. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsSetTrace(CC_FipsTrace_t fipsTrace); + + +/** + * @brief This function should push the FIPS TEE library error towards the REE library, + * the FIPS error can occur while running KAT tests at library init or while running + * conditional or continues tests + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalFipsNotifyUponTeeError(void); + +#endif // _SSI_PAL_FIPS_H \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_init.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_init.h new file mode 100644 index 0000000..a607547 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_init.h @@ -0,0 +1,85 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_INIT_H +#define _SSI_PAL_INIT_H + +#include "ssi_pal_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains the PAL layer entry point, it includes the definitions and APIs for PAL initialization and termination. +@defgroup ssi_pal_init CryptoCell PAL entry\exit point APIs +@{ +@ingroup ssi_pal + +*/ + +/** + * @brief This function Performs all initializations that may be required by the customer's PAL implementation, specifically by the DMA-able buffer + * scheme. The existing implementation allocates a contiguous memory pool that is later used by the ARM TrustZone CryptoCell TEE implementation. + * In case no initializations are needed in the customer's environment, the function can be minimized to return OK. + * It is called by ::SaSi_LibInit. + * + * @return A non-zero value in case of failure. + */ +int SaSi_PalInit(void); + + + +/** + * @brief This function is used to terminate the PAL implementation and free the resources that were taken by ::SaSi_PalInit. + * + * @return Void. + */ +void SaSi_PalTerminate(void); + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_list.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_list.h new file mode 100644 index 0000000..eda599b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_list.h @@ -0,0 +1,118 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_LIST_H +#define _SSI_PAL_LIST_H + + +typedef struct SaSi_PalListItem { + struct SaSi_PalListItem *prev; + struct SaSi_PalListItem *next; +} SaSi_PalListItem_s; + +/*! + * Initializes a list. Prev/Next points to the same head object. + * + * \param head The head of the list. + */ +static inline void SaSi_PalListInit(SaSi_PalListItem_s *head) +{ + head->prev = head; + head->next = head; +} + +/*! + * Add a new list item after head of list. + * + * \param new New entry to be added + * \param head List head to add it after + */ +static inline void SaSi_PalListAdd(SaSi_PalListItem_s *new, SaSi_PalListItem_s *head) +{ + SaSi_PalListItem_s *next = head->next; + + next->prev = new; + new->next = next; + new->prev = head; + head->next = new; +} + +/*! + * Add a new list item after head of list. + * + * \param new New entry to be added + * \param head List head to add it after + */ +static inline void SaSi_PalListAddTail(SaSi_PalListItem_s *new, SaSi_PalListItem_s *head) +{ + SaSi_PalListItem_s *prev = head->prev; + + prev->next = new; + new->next = head; + new->prev = prev; + head->prev = new; +} + +/*! + * Deletes entry from list. + * + * \param item The item to delete from the list. + */ +static inline void SaSi_PalListDel(SaSi_PalListItem_s *item) +{ + SaSi_PalListItem_s *prev = item->prev; + SaSi_PalListItem_s *next = item->next; + + prev->next = next; + next->prev = prev; + + item->next = item; + item->prev = item; +} + +/*! + * Checks whether a list is empty. + * + * \param head The list's head + * + * \return int True if empty list, False otherwise. + */ +static inline int SaSi_PalIsListEmpty(const SaSi_PalListItem_s *head) +{ + return (head->next == head); +} + +#endif + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_log.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_log.h new file mode 100644 index 0000000..fd97069 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_log.h @@ -0,0 +1,216 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_LOG_H_ +#define _SSI_PAL_LOG_H_ + +#include "ssi_pal_types.h" + + +/*! +@file +@brief This file contains the PAL layer log definitions, by default the log is disabled. +@defgroup ssi_pal_log CryptoCell PAL logging APIs and definitions +@{ +@ingroup ssi_pal + +*/ + +/* PAL log levels (to be used in SASI_PAL_logLevel) */ +/*! PAL log level - disabled. */ +#define SASI_PAL_LOG_LEVEL_NULL -1 /*!< \internal Disable logging */ +/*! PAL log level - error. */ +#define SASI_PAL_LOG_LEVEL_ERR 0 +/*! PAL log level - warning. */ +#define SASI_PAL_LOG_LEVEL_WARN 1 +/*! PAL log level - info. */ +#define SASI_PAL_LOG_LEVEL_INFO 2 +/*! PAL log level - debug. */ +#define SASI_PAL_LOG_LEVEL_DEBUG 3 +/*! PAL log level - trace. */ +#define SASI_PAL_LOG_LEVEL_TRACE 4 +/*! PAL log level - data. */ +#define SASI_PAL_LOG_LEVEL_DATA 5 + +#ifndef SASI_PAL_LOG_CUR_COMPONENT +/* Setting default component mask in case caller did not define */ +/* (a mask that is always on for every log mask value but full masking) */ +/*! Default log debugged component.*/ +#define SASI_PAL_LOG_CUR_COMPONENT 0xFFFFFFFF +#endif +#ifndef SASI_PAL_LOG_CUR_COMPONENT_NAME +/*! Default log component name.*/ +#define SASI_PAL_LOG_CUR_COMPONENT_NAME "Dx" +#endif + +/* Select compile time log level (default if not explicitly specified by caller) */ +#ifndef SASI_PAL_MAX_LOG_LEVEL /* Can be overriden by external definition of this constant */ +#ifdef DEBUG +/*! Default debug log level (when debug is set to on).*/ +#define SASI_PAL_MAX_LOG_LEVEL SASI_PAL_LOG_LEVEL_ERR /*SASI_PAL_LOG_LEVEL_DEBUG*/ +#else /* Disable logging */ +/*! Default debug log level (when debug is set to off).*/ +#define SASI_PAL_MAX_LOG_LEVEL SASI_PAL_LOG_LEVEL_NULL +#endif +#endif /*SASI_PAL_MAX_LOG_LEVEL*/ +/*! Evaluate SASI_PAL_MAX_LOG_LEVEL in case provided by caller */ +#define __SASI_PAL_LOG_LEVEL_EVAL(level) level +/*! Maximal log level defintion.*/ +#define _SASI_PAL_MAX_LOG_LEVEL __SASI_PAL_LOG_LEVEL_EVAL(SASI_PAL_MAX_LOG_LEVEL) + +#ifdef ARM_DSM //not support ARM DSM log feature +/*! Log init function. */ +#define SaSi_PalLogInit() do {} while (0) +/*! Log set level function - sets the level of logging in case of debug. */ +#define SaSi_PalLogLevelSet(setLevel) do {} while (0) +/*! Log set mask function - sets the component masking in case of debug. */ +#define SaSi_PalLogMaskSet(setMask) do {} while (0) +/*! Log log funtion based on various platform */ +#define SaSi_PalLogPlatsampan(level, msg) do {} while (0) + +#else +#if _SASI_PAL_MAX_LOG_LEVEL > SASI_PAL_LOG_LEVEL_NULL +/*! Log init function. */ +void SaSi_PalLogInit(void); +/*! Log set level function - sets the level of logging in case of debug. */ +void SaSi_PalLogLevelSet(int setLevel); +/*! Log set mask function - sets the component masking in case of debug. */ +void SaSi_PalLogMaskSet(uint32_t setMask); +/*! Log log funtion based on various platform */ +void SaSi_PalLogPlat(uint32_t level, const char *msg); + +/*! Global variable for log level */ +extern int SaSi_PAL_logLevel; +/*! Global variable for log mask */ +extern uint32_t SaSi_PAL_logMask; +#else /* No log */ +/*! Log init function. */ +#define SaSi_PalLogInit() do {} while (0) +/*! Log set level function - sets the level of logging in case of debug. */ +#define SaSi_PalLogLevelSet(setLevel) do {} while (0) +/*! Log set mask function - sets the component masking in case of debug. */ +#define SaSi_PalLogMaskSet(setMask) do {} while (0) +/*! Log log funtion based on various platform */ +#define SaSi_PalLogPlat(level, msg) do {} while (0) + +#endif +#endif + +/*! Filter logging based on logMask and dispatch to platform specific logging mechanism */ +#define _SASI_PAL_LOG(level, msg) \ + if (SaSi_PAL_logMask & SASI_PAL_LOG_CUR_COMPONENT) \ + SaSi_PalLogPlat(SASI_PAL_LOG_LEVEL_ ## level, msg ) + +#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_ERR) + +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_ERR(msg) \ + _SASI_PAL_LOG(ERR, msg) +#else +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_ERR( ... ) do {} while (0) +#endif + +#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_WARN) +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_WARN(msg) \ + if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_WARN) \ + _SASI_PAL_LOG(WARN, msg) +#else +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_WARN( ... ) do {} while (0) +#endif + +#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_INFO) +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_INFO(msg) \ + if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_INFO) \ + _SASI_PAL_LOG(INFO, msg) +#else +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_INFO( ... ) do {} while (0) +#endif + +#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_DEBUG) +/*! Log messages according to log level.*/ +#define SASI_PAL_LOG_DEBUG(msg) \ + if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_DEBUG) \ + _SASI_PAL_LOG(DEBUG, msg) + +/*! Log message buffer.*/ +#define SASI_PAL_LOG_DUMP_BUF(msg, buf, size) \ + do { \ + int i; \ + uint8_t *pData = (uint8_t*)buf; \ + \ + PRINTF("%s (%d):\n", msg, size); \ + for (i = 0; i < size; i++) { \ + PRINTF("0x%02X ", pData[i]); \ + if ((i & 0xF) == 0xF) { \ + PRINTF("\n"); \ + } \ + } \ + PRINTF("\n"); \ + } while (0) +#else +/*! Log debug messages.*/ +#define SASI_PAL_LOG_DEBUG( ... ) do {} while (0) +/*! Log debug buffer.*/ +#define SASI_PAL_LOG_DUMP_BUF(msg, buf, size) do {} while (0) +#endif + +#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_TRACE) +/*! Log debug trace.*/ +#define SASI_PAL_LOG_TRACE(msg) \ + if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_TRACE) \ + _SASI_PAL_LOG(TRACE, format, msg) +#else +/*! Log debug trace.*/ +#define SASI_PAL_LOG_TRACE(...) do {} while (0) +#endif + +#if (_SASI_PAL_MAX_LOG_LEVEL >= SASI_PAL_LOG_LEVEL_TRACE) +/*! Log debug data.*/ +#define SASI_PAL_LOG_DATA(msg) \ + if (SaSi_PAL_logLevel >= SASI_PAL_LOG_LEVEL_TRACE) \ + _SASI_PAL_LOG(DATA, format, msg) +#else +/*! Log debug data.*/ +#define SASI_PAL_LOG_DATA( ...) do {} while (0) +#endif +/** +@} + */ +#endif /*_SSI_PAL_LOG_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mem.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mem.h new file mode 100644 index 0000000..796ca0b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mem.h @@ -0,0 +1,162 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_MEM_H +#define _SSI_PAL_MEM_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "ssi_pal_types.h" + +/*! +@file +@brief This file contains functions for memory operations. The functions implementations + are generally just wrappers to different operating system calls. + None of the described functions will check the input parameters so the behavior + of the APIs in illegal parameters case is dependent on the operating system behavior. +@defgroup ssi_pal_mem CryptoCell PAL memory operations +@{ +@ingroup ssi_pal +*/ + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/**** ----- Memory Operations APIs ----- ****/ + +/*! +* @brief This function purpose is to compare between two given buffers according to given size. +* +* @return The return values is according to operating system return values. +*/ + + +int32_t SaSi_PalMemCmp( const void* aTarget, /*!< [in] The target buffer to compare. */ + const void* aSource, /*!< [in] The Source buffer to compare to. */ + uint32_t aSize /*!< [in] Number of bytes to compare. */); + +/*! + * @brief This function purpose is to perform secured memory comparison between two given + * buffers according to given size. The function will compare each byte till aSize + * number of bytes was compared even if the bytes are different. + * The function should be used to avoid security timing attacks. + * + * @return SASI_SUCCESS in case of success, + * @return value on failure as defined in ssi_pal_error.h. + */ +SaSiError_t SaSi_PalSecMemCmp( const uint8_t* aTarget, /*!< [in] The target buffer to compare. */ + const uint8_t* aSource, /*!< [in] The Source buffer to compare to. */ + uint32_t aSize /*!< [in] Number of bytes to compare. */); + +/*! + * @brief This function purpose is to copy aSize bytes from source buffer to destination buffer. + * + * @return void. + */ +void SaSi_PalMemCopy( void* aDestination, /*!< [out] The destination buffer to copy bytes to. */ + const void* aSource, /*!< [in] The Source buffer to copy from. */ + uint32_t aSize /*!< [in] Number of bytes to copy. */ ); + +/*! + * @brief This function purpose is to copy aSize bytes from source buffer to destination buffer. + * This function Supports overlapped buffers. + * + * @return void. + */ +void SaSi_PalMemMove( void* aDestination, /*!< [out] The destination buffer to copy bytes to. */ + const void* aSource, /*!< [in] The Source buffer to copy from. */ + uint32_t aSize /*!< [in] Number of bytes to copy. */); + +/*! + * @brief This function purpose is to set aSize bytes in the given buffer with aChar. + * + * @return void. + */ +void SaSi_PalMemSet( void* aTarget, /*!< [out] The target buffer to set. */ + const uint8_t aChar, /*!< [in] The char to set into aTarget. */ + uint32_t aSize /*!< [in] Number of bytes to set. */); + +/*! + * @brief This function purpose is to set aSize bytes in the given buffer with zeroes. + * + * @return void. + */ +void SaSi_PalMemSetZero( void* aTarget, /*!< [out] The target buffer to set. */ + uint32_t aSize /*!< [in] Number of bytes to set. */); + +/**** ----- Memory Allocation APIs ----- ****/ + +/*! + * @brief This function purpose is to allocate a memory buffer according to aSize. + * + * + * @return The function will return a pointer to allocated buffer or NULL if allocation failed. + */ +void* SaSi_PalMemMalloc(uint32_t aSize /*!< [in] Number of bytes to allocate. */); + +/*! + * @brief This function purpose is to reallocate a memory buffer according to aNewSize. + * The content of the old buffer is moved to the new location. + * + * @return The function will return a pointer to the newly allocated buffer or NULL if allocation failed. + */ +void* SaSi_PalMemRealloc( void* aBuffer, /*!< [in] Pointer to allocated buffer. */ + uint32_t aNewSize /*!< [in] Number of bytes to reallocate. */); + +/*! + * @brief This function purpose is to free allocated buffer. + * + * + * @return void. + */ +void SaSi_PalMemFree(void* aBuffer /*!< [in] Pointer to allocated buffer.*/); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_memmap.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_memmap.h new file mode 100644 index 0000000..b0d70bb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_memmap.h @@ -0,0 +1,95 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_MEMMAP_H +#define _SSI_PAL_MEMMAP_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include "ssi_pal_types.h" +/*! +@file +@brief This file contains functions for memory mapping + None of the described functions will check the input parameters so the behavior + of the APIs in illegal parameters case is dependent on the operating system behavior. +@defgroup ssi_pal_memmap CryptoCell PAL memory mapping APIs +@{ +@ingroup ssi_pal + +*/ + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/** + * @brief This function purpose is to return the base virtual address that maps the + * base physical address + * + * @return Zero on success. + * @return A non-zero value in case of failure. + */ +uint32_t SaSi_PalMemMap(uint32_t physicalAddress, /*!< [in] Start physical address of the I/O range to be mapped. */ + uint32_t mapSize, /*!< [in] Number of bytes that were mapped. */ + uint32_t **ppVirtBuffAddr /*!< [out] Pointer to the base virtual address to which the physical pages were mapped. */ ); + + +/** + * @brief This function purpose is to Unmap a specified address range previously mapped + * by SaSi_PalMemMap. + * + * @return Zero on success. + * @return A non-zero value in case of failure. + */ +uint32_t SaSi_PalMemUnMap(uint32_t *pVirtBuffAddr, /*!< [in] Pointer to the base virtual address to which the physical pages were mapped. */ + uint32_t mapSize /*!< [in] Number of bytes that were mapped. */); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex.h new file mode 100644 index 0000000..b0dd666 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex.h @@ -0,0 +1,117 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_MUTEX_H +#define _SSI_PAL_MUTEX_H + +#include "ssi_pal_mutex_plat.h" +#include "ssi_pal_types_plat.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains functions for resource management (mutex operations). + The functions implementations are generally just wrappers to different operating system calls. + None of the described functions will check the input parameters so the behavior + of the APIs in illegal parameters case is dependent on the operating system behavior. +@defgroup ssi_pal_mutex CryptoCell PAL mutex APIs +@{ +@ingroup ssi_pal +*/ + + + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/** + * @brief This function purpose is to create a mutex. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalMutexCreate(SaSi_PalMutex *pMutexId /*!< [out] Pointer to created mutex handle. */); + + +/** + * @brief This function purpose is to destroy a mutex. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalMutexDestroy(SaSi_PalMutex *pMutexId /*!< [in] Pointer to mutex handle. */); + + +/** + * @brief This function purpose is to Wait for Mutex with aTimeOut. aTimeOut is + * specified in milliseconds (SASI_INFINITE is blocking). + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalMutexLock (SaSi_PalMutex *pMutexId, /*!< [in] Pointer to Mutex handle. */ + uint32_t aTimeOut /*!< [in] Timeout in mSec, or SASI_INFINITE. */); + + +/** + * @brief This function purpose is to release the mutex. + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalMutexUnlock (SaSi_PalMutex *pMutexId/*!< [in] Pointer to Mutex handle. */); + + + + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex_plat.h new file mode 100644 index 0000000..9141c8b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_mutex_plat.h @@ -0,0 +1,71 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_MUTEX_PLAT_H +#define _SSI_PAL_MUTEX_PLAT_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif +/** +* @brief File Description: +* This file contains functions for resource management (semaphor operations). +* The functions implementations are generally just wrappers to different operating system calls. +* None of the described functions will check the input parameters so the behavior +* of the APIs in illegal parameters case is dependent on the operating system behavior. +* +*/ + +typedef uint32_t SaSi_PalMutex; + + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf.h new file mode 100644 index 0000000..8bad274 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf.h @@ -0,0 +1,143 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_PERF_H_ +#define _SSI_PAL_PERF_H_ + +#ifdef LIB_PERF +#include "ssi_pal_perf_plat.h" +#endif + +typedef enum { + PERF_TEST_TYPE_CRYS_AES_INTGR = 0x1, + PERF_TEST_TYPE_CRYS_AES_INIT = 0x2, + PERF_TEST_TYPE_CRYS_AES_BLOCK = 0x3, + PERF_TEST_TYPE_CRYS_AES_FIN = 0x4, + PERF_TEST_TYPE_HW_CMPLT = 0x5, + PERF_TEST_TYPE_PAL_MAP = 0x6, + PERF_TEST_TYPE_PAL_UNMAP = 0x7, + PERF_TEST_TYPE_MLLI_BUILD = 0x8, + PERF_TEST_TYPE_SYM_DRV_INIT = 0x9, + PERF_TEST_TYPE_SYM_DRV_PROC = 0xA, + PERF_TEST_TYPE_SYM_DRV_FIN = 0xB, + PERF_TEST_TYPE_CRYS_HASH_INIT = 0xC, + PERF_TEST_TYPE_CRYS_HASH_UPDATE=0xD, + PERF_TEST_TYPE_CRYS_HASH_FIN = 0xE, + PERF_TEST_TYPE_CRYS_HMAC_INIT = 0xF, + PERF_TEST_TYPE_CRYS_HMAC_UPDATE=0x10, + PERF_TEST_TYPE_CRYS_HMAC_FIN = 0x11, + PERF_TEST_TYPE_CMPLT_SLEEP = 0x12, + PERF_TEST_TYPE_CRYS_AES_SET_KEY = 0x13, + PERF_TEST_TYPE_PKA_ModExp = 0x30, + PERF_TEST_TYPE_TEST_BASE = 0x100, + PERF_TEST_TYPE_MAX, + PERF_TEST_TYPE_RESERVE32 = 0x7FFFFFFF +}SaSiPalPerfType_t; + + +#ifdef LIB_PERF +#define SASI_PAL_PERF_INIT SaSi_PalPerfInit +#define SASI_PAL_PERF_OPEN_NEW_ENTRY(num, type) \ + num = SaSi_PalPerfOpenNewEntry(type) + +#define SASI_PAL_PERF_CLOSE_ENTRY(num, type) \ + SaSi_PalPerfCloseEntry(num, type) +#define SASI_PAL_PERF_DUMP SaSi_PalPerfDump +#define SASI_PAL_PERF_FIN SaSi_PalPerfFin + +/** + * @brief initialize performance test mechanism + * + * @param[in] + * * + * @return None + */ +void SaSi_PalPerfInit(void); + + +/** + * @brief opens new entry in perf buffer to record new entry + * + * @param[in] entryType - entry type (defined in ssi_pal_perf.h) to be recorded in buffer + * + * @return A non-zero value in case of failure. + */ +SaSi_PalPerfData_t SaSi_PalPerfOpenNewEntry(SaSiPalPerfType_t entryType); + + +/** + * @brief closes entry in perf buffer previously opened by SaSi_PalPerfOpenNewEntry + * + * @param[in] idx - index of the entry to be closed, the return value of SaSi_PalPerfOpenNewEntry + * @param[in] entryType - entry type (defined in ssi_pal_perf.h) to be recorded in buffer + * + * @return A non-zero value in case of failure. + */ +void SaSi_PalPerfCloseEntry(SaSi_PalPerfData_t idx, SaSiPalPerfType_t entryType); + + +/** + * @brief dumps the performance buffer + * + * @param[in] None + * + * @return None + */ +void SaSi_PalPerfDump(void); + + +/** + * @brief terminates resources used for performance tests + * + * @param[in] + * * + * @return None + */ +void SaSi_PalPerfFin(void); + +#else //LIB_PERF +#define SASI_PAL_PERF_INIT() +#define SASI_PAL_PERF_OPEN_NEW_ENTRY(num, type) (num=num) +#define SASI_PAL_PERF_CLOSE_ENTRY(num, type) +#define SASI_PAL_PERF_DUMP() +#define SASI_PAL_PERF_FIN() + + +typedef uint32_t SaSi_PalPerfData_t; + +#endif //LIB_PERF + + +#endif /*_SSI_PAL_PERF_H__*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf_plat.h new file mode 100644 index 0000000..04972de --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_perf_plat.h @@ -0,0 +1,55 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_PERF_PLAT_H__ +#define _SSI_PAL_PERF_PLAT_H__ + + + + +typedef unsigned int SaSi_PalPerfData_t; + +/** + * @brief DSM environment bug - sometimes very long write operation. + * to overcome this bug we added while to make sure write opeartion is completed + * + * @param[in] + * * + * @return None + */ +void SaSi_PalDsmWorkarround(void); + + +#endif /*_SSI_PAL_PERF_PLAT_H__*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem.h new file mode 100644 index 0000000..c371143 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem.h @@ -0,0 +1,123 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_SEM_H +#define _SSI_PAL_SEM_H + +#include "ssi_pal_sem_plat.h" + +#define SASI_PAL_SEM_NO_WAIT 0 +#define SASI_PAL_SEM_FREE 1 +#define SASI_PAL_SEM_LOCKED 0 + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** +* @brief File Description: +* This file contains functions for resource management (semaphor operations). +* The functions implementations are generally just wrappers to different operating system calls. +* None of the described functions will check the input parameters so the behavior +* of the APIs in illegal parameters case is dependent on the operating system behavior. +* +*/ + + + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/** + * @brief This function purpose is to create a semaphore. + * + * + * @param[out] aSemId - Pointer to created semaphor handle + * @param[in] aInitialVal - Initial semaphore value + * + * @return The return values is according to operating system return values. + */ +//SaSiError_t SaSi_PalSemCreate( DX_PAL_SEM *aSemId, uint32_t aInitialVal ); +#define SaSi_PalSemCreate _SaSi_PalSemCreate +/** + * @brief This function purpose is to delete a semaphore + * + * + * @param[in] aSemId - Semaphore handle + * + * @return The return values is according to operating system return values. + */ +//SaSiError_t SaSi_PalSemDelete( DX_PAL_SEM *aSemId ); +#define SaSi_PalSemDelete _SaSi_PalSemDelete +/** + * @brief This function purpose is to Wait for semaphore with aTimeOut. aTimeOut is + * specified in milliseconds. + * + * + * @param[in] aSemId - Semaphore handle + * @param[in] aTimeOut - timeout in mSec, or SASI_INFINITE + * + * @return The return values is according to operating system return values. + */ +//SaSiError_t SaSi_PalSemWait(DX_PAL_SEM aSemId, uint32_t aTimeOut); +#define SaSi_PalSemWait _SaSi_PalSemWait +/** + * @brief This function purpose is to signal the semaphore. + * + * + * @param[in] aSemId - Semaphore handle + * + * @return The return values is according to operating system return values. + */ +//SaSiError_t SaSi_PalSemGive(DX_PAL_SEM aSemId); + +#define SaSi_PalSemGive _SaSi_PalSemGive + + + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem_plat.h new file mode 100644 index 0000000..8e65ce2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_sem_plat.h @@ -0,0 +1,120 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_SEM_INT__H +#define _SSI_PAL_SEM_INT__H + + + +#ifdef __cplusplus +extern "C" +{ +#endif +#include "ssi_pal_types.h" +/** +* @brief File Description: +* This file contains functions for resource management (semaphor operations). +* The functions implementations are generally just wrappers to different operating system calls. +* None of the described functions will check the input parameters so the behavior +* of the APIs in illegal parameters case is dependent on the operating system behavior. +* +*/ + +typedef int DX_PAL_SEM; + + + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/** + * @brief This function purpose is to create a semaphore. + * + * + * @param[out] aSemId - Pointer to created semaphor handle + * @param[in] aInitialVal - Initial semaphore value + * + * @return The return values is according to operating system return values. + */ +SaSiError_t _SaSi_PalSemCreate( DX_PAL_SEM *aSemId, uint32_t aInitialVal ); + +#define _SaSi_PalSemCreate(aSemId,aInitialVal) SASI_SUCCESS +/** + * @brief This function purpose is to delete a semaphore + * + * + * @param[in] aSemId - Semaphore handle + * + * @return The return values is according to operating system return values. + */ +SaSiError_t _SaSi_PalSemDelete( DX_PAL_SEM *aSemId ); + +#define _SaSi_PalSemDelete( aSemId ) SASI_SUCCESS +/** + * @brief This function purpose is to Wait for semaphore with aTimeOut. aTimeOut is + * specified in milliseconds. + * + * + * @param[in] aSemId - Semaphore handle + * @param[in] aTimeOut - timeout in mSec, or SASI_INFINITE + * + * @return The return values is according to operating system return values. + */ +SaSiError_t _SaSi_PalSemWait(DX_PAL_SEM aSemId, uint32_t aTimeOut); + +#define _SaSi_PalSemWait(aSemId, aTimeOut) SASI_SUCCESS +/** + * @brief This function purpose is to signal the semaphore. + * + * + * @param[in] aSemId - Semaphore handle + * + * @return The return values is according to operating system return values. + */ +SaSiError_t _SaSi_PalSemGive(DX_PAL_SEM aSemId); + +#define _SaSi_PalSemGive(aSemId) SASI_SUCCESS + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_trng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_trng.h new file mode 100644 index 0000000..029bb0a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_trng.h @@ -0,0 +1,66 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_PAL_TRNG_H +#define _SSI_PAL_TRNG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*---------------------------- + PUBLIC FUNCTIONS +-----------------------------------*/ + +/** + * @brief This function purpose is to get TRNG characterization parameters. + * + * + * @return Zero on success. + * @return A non-zero value on failure. + */ +SaSiError_t SaSi_PalTrngParameterGet(uint32_t *SubSamplingRatio /*!< [out] TRNG characterization parameters, array size = 4. */); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types.h new file mode 100644 index 0000000..ed9c333 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types.h @@ -0,0 +1,115 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains the platform dependent definitions and types. +@defgroup ssi_pal_types CryptoCell PAL platform dependant types +@{ +@ingroup ssi_pal +*/ + +#ifndef SSI_PAL_TYPES_H +#define SSI_PAL_TYPES_H + +#include "ssi_pal_types_plat.h" + +/*! Boolean definition.*/ +typedef enum { + /*! Boolean false definition.*/ + SASI_FALSE = 0, + /*! Boolean true definition.*/ + SASI_TRUE = 1 +} SaSiBool; + +/*! Success definition. */ +#define SASI_SUCCESS 0UL +/*! Failure definition. */ +#define SASI_FAIL 1UL + +/*! Defintion of 1KB in bytes. */ +#define SASI_1K_SIZE_IN_BYTES 1024 +/*! Defintion of number of bits in a byte. */ +#define SASI_BITS_IN_BYTE 8 +/*! Defintion of number of bits in a 32bits word. */ +#define SASI_BITS_IN_32BIT_WORD 32 +/*! Defintion of number of bytes in a 32bits word. */ +#define SASI_32BIT_WORD_SIZE (sizeof(uint32_t)) + +/*! Success (OK) defintion. */ +#define SASI_OK SASI_SUCCESS + +/*! Macro that handles unused parameters in the code (to avoid compilation warnings). */ +#define SASI_UNUSED_PARAM(prm) ((void)prm) + +/*! Maximal uint32 value.*/ +#define SASI_MAX_UINT32_VAL (0xFFFFFFFF) + + +/* Minimum and Maximum macros */ +#ifdef min +/*! Definition for minimum. */ +#define CRYS_MIN(a,b) min( a , b ) +#else +/*! Definition for minimum. */ +#define CRYS_MIN( a , b ) ( ( (a) < (b) ) ? (a) : (b) ) +#endif + +#ifdef max +/*! Definition for maximum. */ +#define CRYS_MAX(a,b) max( a , b ) +#else +/*! Definition for maximum. */ +#define CRYS_MAX( a , b ) ( ( (a) > (b) ) ? (a) : (b) ) +#endif + +/*! Macro that calculates number of full bytes from bits (i.e. 7 bits are 1 byte). */ +#define CALC_FULL_BYTES(numBits) (((numBits) + (SASI_BITS_IN_BYTE -1))/SASI_BITS_IN_BYTE) +/*! Macro that calculates number of full 32bits words from bits (i.e. 31 bits are 1 word). */ +#define CALC_FULL_32BIT_WORDS(numBits) (((numBits) + (SASI_BITS_IN_32BIT_WORD -1))/SASI_BITS_IN_32BIT_WORD) +/*! Macro that calculates number of full 32bits words from bytes (i.e. 3 bytes are 1 word). */ +#define CALC_32BIT_WORDS_FROM_BYTES(sizeBytes) (((sizeBytes) + SASI_32BIT_WORD_SIZE - 1) / SASI_32BIT_WORD_SIZE) +/*! Macro that round up bits to 32bits words. */ +#define ROUNDUP_BITS_TO_32BIT_WORD(numBits) (CALC_FULL_32BIT_WORDS(numBits)*SASI_BITS_IN_32BIT_WORD) +/*! Macro that round up bits to bytes. */ +#define ROUNDUP_BITS_TO_BYTES(numBits) (CALC_FULL_BYTES(numBits)*SASI_BITS_IN_BYTE) +/*! Macro that round up bytes to 32bits words. */ +#define ROUNDUP_BYTES_TO_32BIT_WORD(numBytes) (SASI_32BIT_WORD_SIZE*(((numBytes)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE)) + + +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types_plat.h new file mode 100644 index 0000000..50e7e40 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pal_types_plat.h @@ -0,0 +1,57 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains basic type definitions that are platform dependent. +*/ +#ifndef SSI_PAL_TYPES_PLAT_H +#define SSI_PAL_TYPES_PLAT_H +/* Host specific types for standard (ISO-C99) compilant platforms */ + +#include +#include +#include + +typedef uintptr_t SaSiVirtAddr_t; +typedef uint32_t SaSiBool_t; +typedef uint32_t SaSiStatus; + +#define SaSiError_t SaSiStatus +#define SASI_INFINITE 0xFFFFFFFF + +#define CEXPORT_C +#define CIMPORT_C + +#endif /*SSI_PAL_TYPES_PLAT_H*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h new file mode 100644 index 0000000..1ea406c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_pka_hw_plat_defs.h @@ -0,0 +1,77 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 PKA_HW_PLAT_DEFS_H +#define PKA_HW_PLAT_DEFS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief Contains the enums and definitions that are used in the PKA code (definitions that are platform dependent). +@defgroup ssi_pka_hw_plat_defs CryptoCell PKA specific types and definitions +@{ +@ingroup cryptocell_pka + +*/ + +/*! Size of PKA engine word.*/ +#define SASI_PKA_WORD_SIZE_IN_BITS 64 +/*! Maximal supported modulus size in bits. */ +#define CRYS_SRP_MAX_MODULUS_SIZE_IN_BITS 3072 +/*! Maximal supported modulus size in RSA in bits. */ +#define CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 2048 +/*! Maximal supported key generation size in RSA in bits. */ +#define CRYS_RSA_MAX_KEY_GENERATION_HW_SIZE_BITS 2048 + +/*! PKA operations maximal count of extra bits. */ +#define PKA_EXTRA_BITS 8 +/*! PKA operations number of memory registers. */ +#define PKA_MAX_COUNT_OF_PHYS_MEM_REGS 32 + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif //PKA_HW_PLAT_DEFS_H + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_regs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_regs.h new file mode 100644 index 0000000..82290ba --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_regs.h @@ -0,0 +1,166 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 + * @brief Macro definitions for accessing ARM TrustZone CryptoCell register space. + */ + +#ifndef _SSI_REGS_H_ +#define _SSI_REGS_H_ + +#include "ssi_bitops.h" + +/* Register Offset macro */ +#define SASI_REG_OFFSET(unit_name, reg_name) \ + (DX_BASE_ ## unit_name + DX_ ## reg_name ## _REG_OFFSET) + +#define SASI_REG_BIT_SHIFT(reg_name, field_name) \ + (DX_ ## reg_name ## _ ## field_name ## _BIT_SHIFT) + +/* Register Offset macros (from registers base address in host) */ +#if defined(DX_CC_REE) || defined(DX_CC_TEE) || defined(DX_CONFIG_IOT_SUPPORTED) + +#include "dx_reg_base_host.h" + +/* Indexed GPR offset macros - note the (not original) preprocessor tricks...*/ +/* (Using the macro without the "_" prefix is allowed with another macro * + * as the gpr_idx) */ +#define _SEP_HOST_GPR_REG_OFFSET(gpr_idx) \ + SASI_REG_OFFSET(HOST_RGF, HOST_SEP_HOST_GPR ## gpr_idx) +#define SEP_HOST_GPR_REG_OFFSET(gpr_idx) _SEP_HOST_GPR_REG_OFFSET(gpr_idx) +#define _HOST_SEP_GPR_REG_OFFSET(gpr_idx) \ + SASI_REG_OFFSET(HOST_RGF, HOST_HOST_SEP_GPR ## gpr_idx) +#define HOST_SEP_GPR_REG_OFFSET(gpr_idx) _HOST_SEP_GPR_REG_OFFSET(gpr_idx) + +/* GPR IRQ bit shift/mask by GPR index */ +#define _SEP_HOST_GPR_IRQ_SHIFT(gpr_idx) \ + DX_HOST_IRR_SEP_HOST_GPR ## gpr_idx ## _INT_BIT_SHIFT +#define SEP_HOST_GPR_IRQ_SHIFT(gpr_idx) \ + _SEP_HOST_GPR_IRQ_SHIFT(gpr_idx) +#define SEP_HOST_GPR_IRQ_MASK(gpr_idx) \ + (1 << SEP_HOST_GPR_IRQ_CAUSE_SHIFT(gpr_idx)) + +/* Read-Modify-Write a field of a register */ +#define MODIFY_REGISTER_FLD(unitName, regName, fldName, fldVal) \ +do { \ + uint32_t regVal; \ + regVal = READ_REGISTER(SASI_REG_ADDR(unitName, regName)); \ + SASI_REG_FLD_SET(unitName, regName, fldName, regVal, fldVal); \ + WRITE_REGISTER(SASI_REG_ADDR(unitName, regName), regVal); \ +} while (0) + +#elif defined(DX_CC_SEP) + +#include "dx_reg_base_sep.h" + +/* We only provide this macro for SEP code because other platforms require usage + of (mapping base + offset), i.e., use of SASI_REG_OFFSET */ +/* PLEASE AVOID USING THIS MACRO FOR NEW SEP CODE. USE THE OFFSET MACROS. */ +#define SASI_REG_ADDR(unit_name, reg_name) \ + (DX_BASE_CC_PERIF + DX_BASE_ ## unit_name + \ + DX_ ## reg_name ## _REG_OFFSET) + +/* Indexed GPR address macros - note the (not original) preprocessor tricks...*/ +/* (Using the macro without the "_" prefix is allowed with another macro * + * as the gpr_idx) */ +#define _SEP_HOST_GPR_REG_ADDR(gpr_idx) \ + SASI_REG_ADDR(SEP_RGF, SEP_SEP_HOST_GPR ## gpr_idx) +#define SEP_HOST_GPR_REG_ADDR(gpr_idx) _SEP_HOST_GPR_REG_ADDR(gpr_idx) +#define _HOST_SEP_GPR_REG_ADDR(gpr_idx) \ + SASI_REG_ADDR(SEP_RGF, SEP_HOST_SEP_GPR ## gpr_idx) +#define HOST_SEP_GPR_REG_ADDR(gpr_idx) _HOST_SEP_GPR_REG_ADDR(gpr_idx) + +#else +#error Execution domain is not DX_CC_SEP/DX_CC_REE/DX_CC_TEE/DX_CONFIG_IOT_SUPPORTED +#endif + +/* Registers address macros for ENV registers (development FPGA only) */ +#ifdef DX_BASE_ENV_REGS + +#ifndef DX_CC_SEP /* Irrelevant for SeP code */ +/* This offset should be added to mapping address of DX_BASE_ENV_REGS */ +#define SASI_ENV_REG_OFFSET(reg_name) (DX_ENV_ ## reg_name ## _REG_OFFSET) +#endif + +#endif /*DX_BASE_ENV_REGS*/ + +/* Bit fields access */ +#define SASI_REG_FLD_GET(unit_name, reg_name, fld_name, reg_val) \ + (DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20 ? \ + reg_val /*!< \internal Optimization for 32b fields */ : \ + BITFIELD_GET(reg_val, DX_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ + DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE)) + +/* Bit fields access */ +#define SASI2_REG_FLD_GET(unit_name, reg_name, fld_name, reg_val) \ + (SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20 ? \ + reg_val /*!< \internal Optimization for 32b fields */ : \ + BITFIELD_GET(reg_val, SASI_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ + SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE)) + +#define SASI_REG_FLD_SET( \ + unit_name, reg_name, fld_name, reg_shadow_var, new_fld_val) \ +do { \ + if (DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20) \ + reg_shadow_var = new_fld_val; /*!< \internal Optimization for 32b fields */\ + else \ + BITFIELD_SET(reg_shadow_var, \ + DX_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ + DX_ ## reg_name ## _ ## fld_name ## _BIT_SIZE, \ + new_fld_val); \ +} while (0) + +#define SASI2_REG_FLD_SET( \ + unit_name, reg_name, fld_name, reg_shadow_var, new_fld_val) \ +do { \ + if (SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE == 0x20) \ + reg_shadow_var = new_fld_val; /*!< \internal Optimization for 32b fields */\ + else \ + BITFIELD_SET(reg_shadow_var, \ + SASI_ ## reg_name ## _ ## fld_name ## _BIT_SHIFT, \ + SASI_ ## reg_name ## _ ## fld_name ## _BIT_SIZE, \ + new_fld_val); \ +} while (0) + +/* Usage example: + uint32_t reg_shadow = READ_REGISTER(SASI_REG_ADDR(CRY_KERNEL,AES_CONTROL)); + SASI_REG_FLD_SET(CRY_KERNEL,AES_CONTROL,NK_KEY0,reg_shadow, 3); + SASI_REG_FLD_SET(CRY_KERNEL,AES_CONTROL,NK_KEY1,reg_shadow, 1); + WRITE_REGISTER(SASI_REG_ADDR(CRY_KERNEL,AES_CONTROL), reg_shadow); + */ + +#endif /*_SSI_REGS_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_sram_map.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_sram_map.h new file mode 100644 index 0000000..b409598 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_sram_map.h @@ -0,0 +1,71 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_SRAM_MAP_H_ +#define _SSI_SRAM_MAP_H_ + +/*! +@file +@brief This file contains internal SRAM mapping definitions. +@defgroup ssi_sram_map CryptoCell SRAM mapping APIs +@{ +@ingroup cryptocell_api + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! PKA base address in the PKA SRAM. */ +#define SASI_SRAM_PKA_BASE_ADDRESS 0x0 +/*! PKA SRAM size in KB. */ +#define SASI_PKA_SRAM_SIZE_IN_KBYTES 4 + +/*! RND SRAM address. */ +#define SASI_SRAM_RND_HW_DMA_ADDRESS 0x0 +/*! Addresses 0K-2KB in SRAM reserved for RND operations. */ +#define SASI_SRAM_RND_MAX_SIZE 0x800 +/*! SRAM maximal size. */ +#define SASI_SRAM_MAX_SIZE 0x1000 + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*_SSI_SRAM_MAP_H_*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_defs.h new file mode 100644 index 0000000..f6e7746 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_defs.h @@ -0,0 +1,93 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_UTIL_DEFS_H +#define _SSI_UTIL_DEFS_H + +/*! +@defgroup ssi_utils CryptoCell utility APIs +@{ +@ingroup cryptocell_api +@brief This group is the utility apis group +@} + +@file +@brief This file contains CryptoCell Util general definitions. +@defgroup ssi_utils_defs CryptoCell utils general definitions +@{ +@ingroup ssi_utils + +*/ + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "ssi_pal_types_plat.h" +#include "ssi_util_key_derivation_defs.h" + + +/****************************************************************************** +* DEFINITIONS +******************************************************************************/ +/*! Supported AES key size in bits. */ +#define SASI_UTIL_AES_128BIT_SIZE 16 // same as SEP_AES_128_BIT_KEY_SIZE +/*****************************************/ +/* CMAC derive key definitions*/ +/*****************************************/ +/*! Minimal data size for CMAC derivation operation. */ +#define SASI_UTIL_CMAC_DERV_MIN_DATA_IN_SIZE SASI_UTIL_FIX_DATA_MIN_SIZE_IN_BYTES+2 +/*! Maximal data size for CMAC derivation operation. */ +#define SASI_UTIL_CMAC_DERV_MAX_DATA_IN_SIZE SASI_UTIL_MAX_KDF_SIZE_IN_BYTES +/*! AES CMAC result size in bytes. */ +#define SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES 0x10UL +/*! AES CMAC result size in words. */ +#define SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_WORDS (SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES/4) + +/*! Util Error type. */ +typedef uint32_t SaSiUtilError_t; +/*! Defines the CMAC result buffer. */ +typedef uint8_t SaSiUtilAesCmacResult_t[SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES]; + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*_SSI_UTIL_DEFS_H*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_error.h new file mode 100644 index 0000000..e932a52 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_error.h @@ -0,0 +1,97 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_UTIL_ERROR_H +#define _SSI_UTIL_ERROR_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the UTIL module errors. +@defgroup ssi_utils_errors CryptoCell utils error definitions +@{ +@ingroup ssi_utils + +*/ + +/***********************/ +/* Util return codes */ +/***********************/ + +/*! Success definition. */ +#define SASI_UTIL_OK 0x00UL +/*! Error base number definition. */ +#define SASI_UTIL_MODULE_ERROR_BASE 0x80000000 + +/*! Illegal key type. */ +#define SASI_UTIL_INVALID_KEY_TYPE (SASI_UTIL_MODULE_ERROR_BASE + 0x00UL) +/*! Illegal data in pointer. */ +#define SASI_UTIL_DATA_IN_POINTER_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x01UL) +/*! Illegal data in size. */ +#define SASI_UTIL_DATA_IN_SIZE_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal data out pointer. */ +#define SASI_UTIL_DATA_OUT_POINTER_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x03UL) +/*! Illegal data out size. */ +#define SASI_UTIL_DATA_OUT_SIZE_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x04UL) +/*! Fatal error. */ +#define SASI_UTIL_FATAL_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x05UL) +/*! Illegal parameters. */ +#define SASI_UTIL_ILLEGAL_PARAMS_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x06UL) +/*! Invalid address given. */ +#define SASI_UTIL_BAD_ADDR_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal domain for endorsement key. */ +#define SASI_UTIL_EK_DOMAIN_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x08UL) +/*! Kdr is not valid. */ +#define SASI_UTIL_KDR_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x09UL) +/*! LCS is not valid. */ +#define SASI_UTIL_LCS_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x0AUL) +/*! session key is not valid. */ +#define SASI_UTIL_SESSION_KEY_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x0BUL) +/*! Illegal user key size. */ +#define SASI_UTIL_INVALID_USER_KEY_SIZE (SASI_UTIL_MODULE_ERROR_BASE + 0x0DUL) +/*! Illegal LCS for the required operation. */ +#define SASI_UTIL_ILLEGAL_LCS_FOR_OPERATION_ERR (SASI_UTIL_MODULE_ERROR_BASE + 0x0EUL) + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*_SSI_UTIL_ERROR_H*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation.h new file mode 100644 index 0000000..ac39184 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation.h @@ -0,0 +1,107 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_UTIL_KEY_DERIVATION_H +#define _SSI_UTIL_KEY_DERIVATION_H + +/*! +@file +@brief This module defines the API that supports Key derivation function as specified + in [SP800-108] in section "KDF in Counter Mode". +@defgroup ssi_utils_key_derivation CryptoCell utility key derivation APIs +@{ +@ingroup ssi_utils + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "ssi_util_defs.h" +#include "ssi_util_key_derivation_defs.h" +#include "ssi_aes.h" + +/****************************************************************************** +* DEFINITIONS +******************************************************************************/ + +/*! Input key derivation type. */ +typedef enum { + /*! User's key.*/ + SASI_UTIL_USER_KEY = 0, + /*! Root key (Kdr).*/ + SASI_UTIL_ROOT_KEY = 1, + /*! Reserved.*/ + SASI_UTIL_END_OF_KEY_TYPE = 0x7FFFFFFF +}SaSiUtilKeyType_t; + + +/*! +@brief The key derivation function is as specified in [SP800-108] in section "KDF in Counter Mode". + The derivation is based on length l, label L, context C and derivation key Ki. + AES-CMAC is used as the pseudorandom function (PRF). + +@return SASI_UTIL_OK on success. +@return A non-zero value from ssi_util_error.h on failure. +*/ + +/* A key derivation functions can iterates n times until l bits of keying material are generated. + For each of the iteration of the PRF, i=1 to n, do: + result(0) = 0; + K(i) = PRF (Ki, [i] || Label || 0x00 || Context || length); + results(i) = result(i-1) || K(i); + + concisely, result(i) = K(i) || k(i-1) || .... || k(0)*/ +SaSiUtilError_t SaSi_UtilKeyDerivation( + SaSiUtilKeyType_t keyType, /*!< [in] The key type that is used as an input to a key derivation function. + Can be one of: SASI_UTIL_USER_KEY or SASI_UTIL_ROOT_KEY. */ + SaSiAesUserKeyData_t *pUserKey, /*!< [in] A pointer to the user's key buffer (in case of SASI_UTIL_USER_KEY). */ + const uint8_t *pLabel, /*!< [in] A string that identifies the purpose for the derived keying material.*/ + size_t labelSize, /*!< [in] The label size should be in range of 1 to 64 bytes length. */ + const uint8_t *pContextData, /*!< [in] A binary string containing the information related to the derived keying material. */ + size_t contextSize, /*!< [in] The context size should be in range of 1 to 64 bytes length. */ + uint8_t *pDerivedKey, /*!< [out] Keying material output (MUST be atleast the size of derivedKeySize). */ + size_t derivedKeySize /*!< [in] Size of the derived keying material in bytes (limited to 4080 bytes). */ + ); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*_SSI_UTIL_KEY_DERIVATION_H*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation_defs.h new file mode 100644 index 0000000..10a8869 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/include/ssi_util_key_derivation_defs.h @@ -0,0 +1,81 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 _SSI_UTIL_KEY_DERIVATION_DEFS_H +#define _SSI_UTIL_KEY_DERIVATION_DEFS_H + +/*! +@file +@brief This file contains the definitions for the key derivation API. +@defgroup ssi_utils_key_defs CryptoCell utils general key definitions +@{ +@ingroup ssi_utils + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/****************************************************************************** +* DEFINITIONS +******************************************************************************/ + +/*! Maximal label length in bytes. */ +#define SASI_UTIL_MAX_LABEL_LENGTH_IN_BYTES 64 +/*! Maximal context length in bytes. */ +#define SASI_UTIL_MAX_CONTEXT_LENGTH_IN_BYTES 64 + +/*! Minimal fixed data size in bytes. */ +#define SASI_UTIL_FIX_DATA_MIN_SIZE_IN_BYTES 3 /*!< \internal counter, 0x00, lengt(-0xff) */ +/*! Maximal fixed data size in bytes. */ +#define SASI_UTIL_FIX_DATA_MAX_SIZE_IN_BYTES 4 /*!< \internal counter, 0x00, lengt(0x100-0xff0) */ + +/*! Maximal derived key material size in bytes. */ +#define SASI_UTIL_MAX_KDF_SIZE_IN_BYTES (SASI_UTIL_MAX_LABEL_LENGTH_IN_BYTES+ \ + SASI_UTIL_MAX_CONTEXT_LENGTH_IN_BYTES+SASI_UTIL_FIX_DATA_MAX_SIZE_IN_BYTES) + +/*! Maximal derived key size in bytes. */ +#define SASI_UTIL_MAX_DERIVED_KEY_SIZE_IN_BYTES 4080 + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*_SSI_UTIL_KEY_DERIVATION_DEFS_H*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/lib/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/lib/license.txt new file mode 100644 index 0000000..d45aeb3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/lib/license.txt @@ -0,0 +1,28 @@ +ARM Object Code and Header Files License +Version 1.0 + +Redistribution. + +Redistribution and use of object code, header files, and +documentation, without modification, are permitted provided that the following +conditions are met: +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of is permitted. +3) Redistribution and use is permitted solely for the purpose of + developing or executing applications that are targeted for use + on an ARM-based product. + + DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDERS 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. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/license.txt new file mode 100644 index 0000000..d45aeb3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/license.txt @@ -0,0 +1,28 @@ +ARM Object Code and Header Files License +Version 1.0 + +Redistribution. + +Redistribution and use of object code, header files, and +documentation, without modification, are permitted provided that the following +conditions are met: +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of is permitted. +3) Redistribution and use is permitted solely for the purpose of + developing or executing applications that are targeted for use + on an ARM-based product. + + DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDERS 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. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_aesccm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_aesccm.h new file mode 100644 index 0000000..c6a3392 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_aesccm.h @@ -0,0 +1,315 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_AESCCM_H +#define CRYS_AESCCM_H + +#include "ssi_pal_types.h" +#include "crys_error.h" + +#include "ssi_aes.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains all of the enums and definitions that are used for the CRYS AESCCM APIs, as well as the APIs themselves. +The API supports AES-CCM and AES-CCM* as defined in ieee-802.15.4. +@defgroup crys_aesccm CryptoCell AES-CCM APIs +@{ +@ingroup cryptocell_api + + +@note +Regarding the AES-CCM*, the API supports only AES-CCM* as defined in ieee-802.15.4-2011; With the instantiations as defined in B.3.2 and the nonce as defined in 7.3.2. +in case of AES-CCM* the flow should be as follows: +
      • AES-CCM* integrated
      • +
        • CRYS_AESCCMStar_NonceGenerate
        • +
        • CRYS_AESCCMStar
      +
      • AES-CCM* non-integrated
      • +
        • CRYS_AESCCMStar_NonceGenerate
        • +
        • CRYS_AESCCMStar_Init
        • +
        • CRYS_AESCCM_BlockAdata
        • +
        • CRYS_AESCCM_BlockTextData
        • +
        • CRYS_AESCCM_Finish
      +*/ + +/************************ Defines ******************************/ + +/*! AES CCM context size in words.*/ +#define CRYS_AESCCM_USER_CTX_SIZE_IN_WORDS (152/4) + +/*! AES CCM maximal key size in words. */ +#define CRYS_AESCCM_KEY_SIZE_WORDS 8 + +/* nonce and AESCCM-MAC sizes definitions */ +/*! AES CCM NONCE minimal size in bytes. */ +#define CRYS_AESCCM_NONCE_MIN_SIZE_BYTES 7 +/*! AES CCM NONCE maximal size in bytes. */ +#define CRYS_AESCCM_NONCE_MAX_SIZE_BYTES 13 +/*! AES CCM MAC minimal size in bytes..*/ +#define CRYS_AESCCM_MAC_MIN_SIZE_BYTES 4 +/*! AES CCM MAC maximal size in bytes. */ +#define CRYS_AESCCM_MAC_MAX_SIZE_BYTES 16 + +/*! AES CCM star NONCE size in bytes. */ +#define CRYS_AESCCM_STAR_NONCE_SIZE_BYTES 13 +/*! AES CCM star source address size in bytes. */ +#define CRYS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES 8 + +/*! AES CCM mode - CCM. */ +#define CRYS_AESCCM_MODE_CCM 0 +/*! AES CCM mode - CCM STAR. */ +#define CRYS_AESCCM_MODE_STAR 1 + + +/************************ Typedefs ****************************/ +/*! AES CCM key sizes. */ +typedef enum { + /*! Key size 128 bits. */ + CRYS_AES_Key128BitSize = 0, + /*! Key size 192 bits. */ + CRYS_AES_Key192BitSize = 1, + /*! Key size 256 bits. */ + CRYS_AES_Key256BitSize = 2, + /*! Key size 512 bits. */ + CRYS_AES_Key512BitSize = 3, + /*! Number of optional key sizes. */ + CRYS_AES_KeySizeNumOfOptions, + /*! Reserved. */ + CRYS_AES_KeySizeLast = 0x7FFFFFFF, + +}CRYS_AESCCM_KeySize_t; + +/*! AES_CCM key buffer definition.*/ +typedef uint8_t CRYS_AESCCM_Key_t[CRYS_AESCCM_KEY_SIZE_WORDS * sizeof(uint32_t)]; +/*! AES_CCM MAC buffer definition.*/ +typedef uint8_t CRYS_AESCCM_Mac_Res_t[SASI_AES_BLOCK_SIZE_IN_BYTES]; + +/*! AES_CCM_STAR source address buffer defintion. */ +typedef uint8_t CRYS_AESCCMStar_SourceAddress_t[CRYS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES]; +/*! AES_CCM_STAR Nonce buffer defintion. */ +typedef uint8_t CRYS_AESCCMStar_Nonce_t[CRYS_AESCCM_STAR_NONCE_SIZE_BYTES]; + +/******************* Context Structure ***********************/ +/*! The user's context structure - the argument type that is passed by the user to the AES CCM APIs */ +typedef struct CRYS_AESCCM_UserContext_t +{ + /*! AES CCM context buffer for internal usage. */ + uint32_t buff[CRYS_AESCCM_USER_CTX_SIZE_IN_WORDS]; +}CRYS_AESCCM_UserContext_t; + + +/************************ Public Functions **********************/ + +/*! +@brief This function initializes the AES CCM context. + +It formats of the input data, calculates AES-MAC value for the formatted B0 block containing control information and +CCM unique value (Nonce), and initializes the AES context structure including the initial CTR0 value. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CC_AESCCM_Init( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the AES context buffer that is allocated by the user and is used for + the AES operation. */ + SaSiAesEncryptMode_t EncrDecrMode, /*!< [in] Flag specifying whether Encrypt (::SASI_AES_ENCRYPT) or Decrypt + (::SASI_AES_DECRYPT) operation should be performed. */ + CRYS_AESCCM_Key_t CCM_Key, /*!< [in] Pointer to the AES-CCM key. */ + CRYS_AESCCM_KeySize_t KeySizeId, /*!< [in] Enumerator defining the key size (only 128 bit is valid). */ + uint32_t AdataSize, /*!< [in] Full byte length of additional (associated) data. If set to zero, + calling ::CRYS_AESCCM_BlockAdata on the same context would return an error. */ + uint32_t TextSizeQ, /*!< [in] Full length of plain text data. */ + uint8_t *N_ptr, /*!< [in] Pointer to the Nonce. */ + uint8_t SizeOfN, /*!< [in] Nonce byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [7 .. 13].
      • +
      • CCM*: valid values = [13].
      */ + uint8_t SizeOfT, /*!< [in] AES-CCM MAC (tag) byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [4, 6, 8, 10, 12, 14, 16].
      • +
      • CCM*: valid values = [0, 4, 8, 16].
      */ + uint32_t ccmMode /*!< [in] Flag specifying whether AES-CCM or AES-CCM* should be performed. */ +); + +/*! Macro defintion for CRYS_AESCCM_Init (AES CCM non-star implementation). */ +#define CRYS_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT) \ + CC_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT, CRYS_AESCCM_MODE_CCM) + +/*! Macro defintion CRYS_AESCCMStar_Init (AES CCM star implementation). */ +#define CRYS_AESCCMStar_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT) \ + CC_AESCCM_Init(ContextID_ptr, EncrDecrMode, CCM_Key, KeySizeId, AdataSize, TextSizeQ, N_ptr, SizeOfN, SizeOfT, CRYS_AESCCM_MODE_STAR) + +/*! +@brief This function receives a CCM context and a block of additional data, and adds it to the AES MAC +calculation. +This API can be called only once per operation context. It should not be called in case AdataSize was set to +zero in ::CC_AESCCM_Init. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CRYS_AESCCM_BlockAdata( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ + uint8_t *DataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ + uint32_t DataInSize /*!< [in] Byte size of the additional data. Must match AdataSize parameter provided to + ::CRYS_AESCCM_Init. */ +); + +/*! +@brief This function can be invoked for any block of Text data whose size is a multiple of 16 bytes, +excluding the last block that must be processed by ::CRYS_AESCCM_Finish. +
      • If encrypting: + Continues calculation of the intermediate AES_MAC value of the text data, while simultaneously encrypting the text data using AES_CTR, + starting from CTR value = CTR0+1.
      • +
      • If decrypting: + Continues decryption of the text data, while calculating the intermediate AES_MAC value of decrypted data.
      + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CRYS_AESCCM_BlockTextData( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ + uint8_t *DataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ + uint32_t DataInSize, /*!< [in] Byte size of the text data block. Must be a multiple of 16 bytes. */ + uint8_t *DataOut_ptr /*!< [out] Pointer to the output data. The size of the output buffer must be at least DataInSize. + The buffer must be contiguous. */ +); + +/*! +@brief This function must be the last to be called on the text data. +It can either be called on the entire text data (if transferred as one block), or on the last block of the text data, +even if total size of text data is equal to 0. +It performs the same operations as ::CRYS_AESCCM_BlockTextData, but additionally: +
      • If encrypting:
      • +
        • If the size of text data is not in multiples of 16 bytes, it pads the remaining bytes with zeros to a full 16-bytes block and + processes the data using AES_MAC and AES_CTR algorithms.
        • +
        • Encrypts the AES_MAC result with AES_CTR using the CTR0 value saved in the context and places the SizeOfT bytes of MAC (tag) + at the end.
      +
      • If decrypting:
      • +
        • Processes the text data, except for the last SizeOfT bytes (tag), using AES_CTR and then AES_MAC algorithms.
        • +
        • Encrypts the calculated MAC using AES_CTR based on the saved CTR0 value, and compares it with SizeOfT last bytes of input data (i.e. + tag value).
        • +
        • The function saves the validation result (Valid/Invalid) in the context.
        • +
        • Returns (as the error code) the final CCM-MAC verification result.
      + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CEXPORT_C CRYSError_t CRYS_AESCCM_Finish( + CRYS_AESCCM_UserContext_t *ContextID_ptr, /*!< [in] Pointer to the context buffer. */ + uint8_t *DataIn_ptr, /*!< [in] Pointer to the last input data. The buffer must be contiguous. */ + uint32_t DataInSize, /*!< [in] Byte size of the last text data block. Can be zero. */ + uint8_t *DataOut_ptr, /*!< [in] Pointer to the output (cipher or plain text data) data. The buffer must + be contiguous. If DataInSize = 0, output buffer is not required. */ + CRYS_AESCCM_Mac_Res_t MacRes, /*!< [in] MAC result buffer pointer. */ + uint8_t *SizeOfT /*!< [out] AES-CCM MAC byte size as defined in CRYS_AESCCM_Init. */ +); + +/****************************************************************************************************/ +/******** AESCCM FUNCTION ******/ +/****************************************************************************************************/ +/*! +@brief AES CCM combines Counter mode encryption with CBC-MAC authentication. +Input to CCM includes the following elements: +
      • Payload - text data that is both authenticated and encrypted.
      • +
      • Associated data (Adata) - data that is authenticated but not encrypted, e.g., a header.
      • +
      • Nonce - A unique value that is assigned to the payload and the associated data.
      + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CIMPORT_C CRYSError_t CC_AESCCM( + SaSiAesEncryptMode_t EncrDecrMode, /*!< [in] A flag specifying whether an AES Encrypt (::SASI_AES_ENCRYPT) or Decrypt + (::SASI_AES_DECRYPT) operation should be performed. */ + CRYS_AESCCM_Key_t CCM_Key, /*!< [in] Pointer to AES-CCM key. */ + CRYS_AESCCM_KeySize_t KeySizeId, /*!< [in] Enumerator defining the key size (only 128 bit is valid). */ + uint8_t *N_ptr, /*!< [in] Pointer to the Nonce. */ + uint8_t SizeOfN, /*!< [in] Nonce byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [7 .. 13].
      • +
      • CCM*: valid values = [13].
      */ + uint8_t *ADataIn_ptr, /*!< [in] Pointer to the additional input data. The buffer must be contiguous. */ + uint32_t ADataInSize, /*!< [in] Byte size of the additional data. */ + uint8_t *TextDataIn_ptr, /*!< [in] Pointer to the plain-text data for encryption or cipher-text data for decryption. + The buffer must be contiguous. */ + uint32_t TextDataInSize, /*!< [in] Byte size of the full text data. */ + uint8_t *TextDataOut_ptr, /*!< [out] Pointer to the output (cipher or plain text data according to encrypt-decrypt mode) + data. The buffer must be contiguous. */ + uint8_t SizeOfT, /*!< [in] AES-CCM MAC (tag) byte size. The valid values depend on the ccm mode: +
      • CCM: valid values = [4, 6, 8, 10, 12, 14, 16].
      • +
      • CCM*: valid values = [0, 4, 8, 16].
      */ + CRYS_AESCCM_Mac_Res_t Mac_Res, /*!< [in/out] Pointer to the MAC result buffer. */ + uint32_t ccmMode /*!< [in] Flag specifying whether AES-CCM or AES-CCM* should be performed. */ +); + +/*! Macro defintion for CRYS_AESCCM (AES CCM non-star implementation). */ +#define CRYS_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res) \ + CC_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res, CRYS_AESCCM_MODE_CCM) + +/*! Macro defintion for CRYS_AESCCMStar (AES CCM star implementation). */ +#define CRYS_AESCCMStar(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res) \ + CC_AESCCM(EncrDecrMode, CCM_Key, KeySizeId, N_ptr, SizeOfN, ADataIn_ptr, ADataInSize, TextDataIn_ptr, TextDataInSize, TextDataOut_ptr, SizeOfT, Mac_Res, CRYS_AESCCM_MODE_STAR) + + +/*! +@brief This function receives the MAC source address, the frame counter and the MAC size +and returns the required nonce for AES-CCM* as defined in ieee-802.15.4. +This API should be called before CRYS_AESCCMStar and CRYS_AESCCMStar_Init, +and the generated nonce should be provided to these functions. + +@return CRYS_OK on success. +@return A non-zero value on failure as defined crys_aesccm_error.h. +*/ +CRYSError_t CRYS_AESCCMStar_NonceGenerate( + CRYS_AESCCMStar_SourceAddress_t srcAddr, /*!< [in] The MAC address in EUI-64 format. */ + uint32_t FrameCounter, /*!< [in] The MAC frame counter. */ + uint8_t SizeOfT, /*!< [in] AES-CCM* MAC (tag) byte size. Valid values = [0,4,8,16]. */ + CRYS_AESCCMStar_Nonce_t nonce /*!< [out] The required nonce for AES-CCM*. */ +); + +#ifdef __cplusplus +} +#endif + +/** +@} + */ + +#endif /*#ifndef CRYS_AESCCM_H*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_ecpki_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_ecpki_error.h new file mode 100644 index 0000000..950dce0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_ecpki_error.h @@ -0,0 +1,317 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ECPKI_ERROR_H +#define CRYS_ECPKI_ERROR_H + + +/*! +@file +@brief This module contains the definitions of the CRYS ECPKI errors. +@defgroup crys_ecpki_error CryptoCell ECC specific errors +@{ +@ingroup cryptocell_ecpki +*/ + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/************************ Defines ******************************/ + +/* CRYS_ECPKI_MODULE_ERROR_BASE = 0x00F00800 */ + +/********************************************************************************************* + * CRYS ECPKI MODULE ERRORS * + *********************************************************************************************/ +/*! Illegal domain ID. */ +#define CRYS_ECPKI_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1UL) +/*! Illegal domain pointer. */ +#define CRYS_ECPKI_DOMAIN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x2UL) +/* The CRYS ECPKI GEN KEY PAIR module errors */ +/*! Illegal private key pointer. */ +#define CRYS_ECPKI_GEN_KEY_INVALID_PRIVATE_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal public key pointer. */ +#define CRYS_ECPKI_GEN_KEY_INVALID_PUBLIC_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECPKI_GEN_KEY_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal RND context pointer. */ +#define CRYS_ECPKI_RND_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x6UL) + +/************************************************************************************************************ +* The CRYS ECPKI BUILD KEYS MODULE ERRORS * +*************************************************************************************************************/ +/*! Illegal compression mode. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_COMPRESSION_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal domain ID. */ +#define CRYS_ECPKI_BUILD_KEY_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x08UL) +/*! Illegal private key pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x09UL) +/*! Illegal private key structure pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0AUL) +/*! Illegal private key size. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0BUL) +/*! Illegal private key data. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PRIV_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0CUL) +/*! Illegal public key pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0DUL) +/*! Illegal public key structure pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_USER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0EUL) +/*! Illegal public key size. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x0FUL) +/*! Illegal public key data. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_PUBL_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x10UL) +/*! Illegal EC build check mode option. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_CHECK_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x11UL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECPKI_BUILD_KEY_INVALID_TEMP_BUFF_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x12UL) + +/* The CRYS ECPKI EXPORT PUBLIC KEY MODULE ERRORS */ +/*! Illegal public key structure pointer. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_USER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x14UL) +/*! Illegal public key compression mode. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_COMPRESSION_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x15UL) +/*! Illegal output public key pointer. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_EXTERN_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x16UL) +/*! Illegal output public key size pointer. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x17UL) +/*! Illegal output public key size. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x18UL) +/*! Illegal domain ID. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x19UL) +/*! Validation of public key failed. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_ILLEGAL_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1AUL) +/*! Validation of public key failed. */ +#define CRYS_ECPKI_EXPORT_PUBL_KEY_INVALID_PUBL_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x1BUL) + +/* The CRYS ECPKI EXPORT PRIVATE KEY MODULE ERRORS */ +/*! Illegal private key structure pointer. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC0UL) +/*! Illegal output private key pointer. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_EXTERN_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC1UL) +/*! Validation of private key failed. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_ILLEGAL_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC2UL) +/*! Illegal output private key size pointer. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_PRIV_KEY_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC3UL) +/*! Illegal output private key size. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_PRIV_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC4UL) +/*! Validation of private key failed. */ +#define CRYS_ECPKI_EXPORT_PRIV_KEY_INVALID_PRIV_KEY_DATA_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xC5UL) + +/* The CRYS ECPKI BUILD ECC DOMAIN ERRORS */ +/*! Illegal domain ID. */ +#define CRYS_ECPKI_BUILD_DOMAIN_ID_IS_NOT_VALID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x20UL) +/*! Illegal domain ID pointer. */ +#define CRYS_ECPKI_BUILD_DOMAIN_DOMAIN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x21UL) +/*! Illegal domain parameter pointer. */ +#define CRYS_ECPKI_BUILD_DOMAIN_EC_PARAMETR_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x22UL) +/*! Illegal domain parameter size. */ +#define CRYS_ECPKI_BUILD_DOMAIN_EC_PARAMETR_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x23UL) +/*! Illegal domain cofactor parameters. */ +#define CRYS_ECPKI_BUILD_DOMAIN_COFACTOR_PARAMS_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x24UL) +/*! Insufficient strength. */ +#define CRYS_ECPKI_BUILD_DOMAIN_SECURITY_STRENGTH_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x25UL) +/*! SCA resistance error. */ +#define CRYS_ECPKI_BUILD_SCA_RESIST_ILLEGAL_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x26UL) + + +/*! Internal PKI error */ +#define CRYS_ECPKI_PKI_INTERNAL_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x30UL) + +/************************************************************************************************************ + * CRYS EC DIFFIE-HELLMAN MODULE ERRORS +*************************************************************************************************************/ +/* The CRYS EC SVDP_DH Function errors */ +/*! Illegal partner's public key pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_PARTNER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x31UL) +/*! Partner's public key validation failed. */ +#define CRYS_ECDH_SVDP_DH_PARTNER_PUBL_KEY_VALID_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x32UL) +/*! Illegal user private key pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x33UL) +/*! Private key validation failed. */ +#define CRYS_ECDH_SVDP_DH_USER_PRIV_KEY_VALID_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x34UL) +/*! Illegal shared secret pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x35UL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x36UL) +/*! Illegal shared secret size pointer. */ +#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x37UL) +/*! Illegal shared secret size. */ +#define CRYS_ECDH_SVDP_DH_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x38UL) +/*! Illegal domain ID. */ +#define CRYS_ECDH_SVDP_DH_ILLEGAL_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x39UL) +/*! Illegal private and public domain ID are different. */ +#define CRYS_ECDH_SVDP_DH_NOT_CONCENT_PUBL_AND_PRIV_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x3AUL) + + +/************************************************************************************************************ + * CRYS ECDSA MODULE ERRORS + ************************************************************************************************************/ +/* The CRYS ECDSA Signing errors */ +/*! Illegal domain ID. */ +#define CRYS_ECDSA_SIGN_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x50UL) +/*! Illegal context pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_USER_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x51UL) +/*! Illegal private key pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_USER_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x52UL) +/*! Illegal hash operation mode. */ +#define CRYS_ECDSA_SIGN_ILLEGAL_HASH_OP_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x53UL) +/*! Illegal data in pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x54UL) +/*! Illegal data in size. */ +#define CRYS_ECDSA_SIGN_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x55UL) +/*! Context validation failed. */ +#define CRYS_ECDSA_SIGN_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x57UL) +/*! User's private key validation failed. */ +#define CRYS_ECDSA_SIGN_USER_PRIV_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x58UL) +/*! Illegal signature pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x60UL) +/*! Illegal signature size pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x61UL) +/*! Illegal signature size. */ +#define CRYS_ECDSA_SIGN_INVALID_SIGNATURE_OUT_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x62UL) +/*! Ephemeral key error. */ +#define CRYS_ECDSA_SIGN_INVALID_IS_EPHEMER_KEY_INTERNAL_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x63UL) +/*! Illegal ephemeral key pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_EPHEMERAL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x64UL) +/*! Illegal RND context pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_RND_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x65UL) +/*! Illegal RND function pointer. */ +#define CRYS_ECDSA_SIGN_INVALID_RND_FUNCTION_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x66UL) +/*! Signature calculation failed. */ +#define CRYS_ECDSA_SIGN_SIGNING_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x67UL) + +/* The CRYS ECDSA Verifying errors */ +/*! Illegal domain ID. */ +#define CRYS_ECDSA_VERIFY_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x70UL) +/*! Illegal user's context pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x71UL) +/*! Illegal public key pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_SIGNER_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x72UL) +/*! Illegal hash operation mode. */ +#define CRYS_ECDSA_VERIFY_ILLEGAL_HASH_OP_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x73UL) +/*! Illegal signature pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x76UL) +/*! Illegal signature size. */ +#define CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x77UL) +/*! Illegal data in pointer. */ +#define CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x80UL) +/*! Illegal data in size. */ +#define CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x81UL) +/*! Context validation failed. */ +#define CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x82UL) +/*! public key validation failed. */ +#define CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x83UL) +/*! Verification failed. */ +#define CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x84UL) + +/*! Illegal parameters. */ +#define CRYS_ECC_ILLEGAL_PARAMS_ACCORDING_TO_PRIV_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xD3UL) +/*! Illegal hash mode. */ +#define CRYS_ECC_ILLEGAL_HASH_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE0UL) + + +/************************************************************************************************************ + * CRYS ECPKI MODULE COMMON ERRORS +*************************************************************************************************************/ +/*! Illegal RND function pointer. */ +#define CRYS_ECPKI_INVALID_RND_FUNC_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x90UL) +/*! Illegal RND context pointer. */ +#define CRYS_ECPKI_INVALID_RND_CTX_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x91UL) +/*! Illegal domain ID. */ +#define CRYS_ECPKI_INVALID_DOMAIN_ID_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x92UL) +/*! Private key validation failed. */ +#define CRYS_ECPKI_INVALID_PRIV_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x93UL) +/*! Public key validation failed. */ +#define CRYS_ECPKI_INVALID_PUBL_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x94UL) +/*! Illegal data in. */ +#define CRYS_ECPKI_INVALID_DATA_IN_PASSED_STRUCT_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0x95UL) + +/************************************************************************************************************ + * CRYS ECIES MODULE ERRORS +*************************************************************************************************************/ +/*! Illegal public key pointer. */ +#define CRYS_ECIES_INVALID_PUBL_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE0UL) +/*! Public key validation failed. */ +#define CRYS_ECIES_INVALID_PUBL_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE1UL) +/*! Illegal private key pointer. */ +#define CRYS_ECIES_INVALID_PRIV_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE2UL) +/*! Private key validation failed. */ +#define CRYS_ECIES_INVALID_PRIV_KEY_TAG_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE3UL) +/*! Illegal private key value. */ +#define CRYS_ECIES_INVALID_PRIV_KEY_VALUE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE4UL) +/*! Illegal KDF derivation mode. */ +#define CRYS_ECIES_INVALID_KDF_DERIV_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE5UL) +/*! Illegal KDF hash mode. */ +#define CRYS_ECIES_INVALID_KDF_HASH_MODE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE6UL) +/*! Illegal secret key pointer. */ +#define CRYS_ECIES_INVALID_SECRET_KEY_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE7UL) +/*! Illegal secret key size. */ +#define CRYS_ECIES_INVALID_SECRET_KEY_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE8UL) +/*! Illegal cipher data pointer. */ +#define CRYS_ECIES_INVALID_CIPHER_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xE9UL) +/*! Illegal cipher data size pointer. */ +#define CRYS_ECIES_INVALID_CIPHER_DATA_SIZE_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEAUL) +/*! Illegal cipher data size. */ +#define CRYS_ECIES_INVALID_CIPHER_DATA_SIZE_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEBUL) +/*! Illegal temporary buffer pointer. */ +#define CRYS_ECIES_INVALID_TEMP_DATA_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xECUL) +/*! Illegal ephemeral key pointer */ +#define CRYS_ECIES_INVALID_EPHEM_KEY_PAIR_PTR_ERROR (CRYS_ECPKI_MODULE_ERROR_BASE + 0xEDUL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs ******************************/ + +/************************ Public Variables **********************/ + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_error.h new file mode 100644 index 0000000..bf5673f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_error.h @@ -0,0 +1,273 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_ERROR_H +#define CRYS_ERROR_H + +#include "ssi_pal_types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! @file +@brief This module defines the error return code types and the numbering spaces of the error codes +for each module of the layers listed below. +@defgroup crys_error CryptoCell general base error codes +@{ +@ingroup cryptocell_api +*/ + +/*! The definitions of the error number space used for the different modules */ + +/* ........... Error base numeric mapping definitions ................... */ +/* ----------------------------------------------------------------------- */ + + /*! CRYS error base number. */ +#define CRYS_ERROR_BASE 0x00F00000UL + +/*! Error range number assigned for each layer. */ +#define CRYS_ERROR_LAYER_RANGE 0x00010000UL + +/*! Error range number assigned to each module on its specified layer. */ +#define CRYS_ERROR_MODULE_RANGE 0x00000100UL + +/* Defines the layer index for the error mapping. */ +/*! CRYS error layer index. */ +#define CRYS_LAYER_ERROR_IDX 0x00UL +/*! Low level functions error layer index. */ +#define LLF_LAYER_ERROR_IDX 0x01UL +/*! Generic error layer index. */ +#define GENERIC_ERROR_IDX 0x05UL + +/* Defines the module index for error mapping */ +/*! AES error index.*/ +#define AES_ERROR_IDX 0x00UL +/*! DES error index.*/ +#define DES_ERROR_IDX 0x01UL +/*! HASH error index.*/ +#define HASH_ERROR_IDX 0x02UL +/*! HMAC error index.*/ +#define HMAC_ERROR_IDX 0x03UL +/*! RSA error index.*/ +#define RSA_ERROR_IDX 0x04UL +/*! DH error index.*/ +#define DH_ERROR_IDX 0x05UL + +/*! ECPKI error index.*/ +#define ECPKI_ERROR_IDX 0x08UL +/*! RND error index.*/ +#define RND_ERROR_IDX 0x0CUL +/*! Common error index.*/ +#define COMMON_ERROR_IDX 0x0DUL +/*! KDF error index.*/ +#define KDF_ERROR_IDX 0x11UL +/*! HKDF error index.*/ +#define HKDF_ERROR_IDX 0x12UL +/*! AESCCM error index.*/ +#define AESCCM_ERROR_IDX 0x15UL +/*! FIPS error index.*/ +#define FIPS_ERROR_IDX 0x17UL + +/*! PKA error index.*/ +#define PKA_MODULE_ERROR_IDX 0x21UL +/*! CHACHA error index.*/ +#define CHACHA_ERROR_IDX 0x22UL +/*! EC montgomery and edwards error index.*/ +#define EC_MONT_EDW_ERROR_IDX 0x23UL +/*! CHACHA POLY error index.*/ +#define CHACHA_POLY_ERROR_IDX 0x24UL +/*! POLY error index.*/ +#define POLY_ERROR_IDX 0x25UL +/*! SRP error index.*/ +#define SRP_ERROR_IDX 0x26UL + + + +/* .......... defining the error spaces for each module on each layer ........... */ +/* ------------------------------------------------------------------------------ */ + +/*! AES module error base address - 0x00F00000. */ +#define CRYS_AES_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * AES_ERROR_IDX ) ) + +/*! DES module error base address - 0x00F00100. */ +#define CRYS_DES_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * DES_ERROR_IDX ) ) + +/*! HASH module error base address - 0x00F00200. */ +#define CRYS_HASH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * HASH_ERROR_IDX ) ) + +/*! HMAC module error base address - 0x00F00300. */ +#define CRYS_HMAC_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * HMAC_ERROR_IDX ) ) + +/*! RSA module error base address - 0x00F00400. */ +#define CRYS_RSA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * RSA_ERROR_IDX ) ) + +/*! DH module error base address - 0x00F00500. */ +#define CRYS_DH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * DH_ERROR_IDX ) ) + +/*! ECPKI module error base address - 0x00F00800. */ +#define CRYS_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) ) + +/*! Low level ECPKI module error base address - 0x00F10800. */ +#define LLF_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) ) + +/*! RND module error base address - 0x00F00C00. */ +#define CRYS_RND_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) ) + +/*! Low level RND module error base address - 0x00F10C00. */ +#define LLF_RND_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) ) + +/*! COMMMON module error base address - 0x00F00D00. */ +#define CRYS_COMMON_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * COMMON_ERROR_IDX ) ) + +/*! KDF module error base address - 0x00F01100. */ +#define CRYS_KDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * KDF_ERROR_IDX ) ) + +/*! HKDF module error base address - 0x00F01100. */ +#define CRYS_HKDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * HKDF_ERROR_IDX ) ) + +/*! AESCCM module error base address - 0x00F01500. */ +#define CRYS_AESCCM_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * AESCCM_ERROR_IDX ) ) + +/*! FIPS module error base address - 0x00F01700. */ +#define CRYS_FIPS_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * FIPS_ERROR_IDX ) ) + +/*! PKA module error base address - 0x00F02100. */ +#define PKA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * PKA_MODULE_ERROR_IDX ) ) + +/*! CHACHA module error base address - 0x00F02200. */ +#define CRYS_CHACHA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * CHACHA_ERROR_IDX ) ) +/*! CHACHA POLY module error base address - 0x00F02400. */ +#define CRYS_CHACHA_POLY_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * CHACHA_POLY_ERROR_IDX ) ) +/*! POLY module error base address - 0x00F02500. */ +#define CRYS_POLY_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * POLY_ERROR_IDX ) ) + +/*! SRP module error base address - 0x00F02600. */ +#define CRYS_SRP_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * SRP_ERROR_IDX ) ) + + +/*! EC MONT_EDW module error base address - 0x00F02300. */ +#define CRYS_EC_MONT_EDW_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \ + (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \ + (CRYS_ERROR_MODULE_RANGE * EC_MONT_EDW_ERROR_IDX ) ) + + +/*! User generic error base address - 0x00F50000 */ +#define GENERIC_ERROR_BASE ( CRYS_ERROR_BASE + (CRYS_ERROR_LAYER_RANGE * GENERIC_ERROR_IDX) ) +/*! CRYS fatal error. */ +#define CRYS_FATAL_ERROR (GENERIC_ERROR_BASE + 0x00UL) +/*! CRYS out of resources error. */ +#define CRYS_OUT_OF_RESOURCE_ERROR (GENERIC_ERROR_BASE + 0x01UL) +/*! CRYS illegal resource value error. */ +#define CRYS_ILLEGAL_RESOURCE_VAL_ERROR (GENERIC_ERROR_BASE + 0x02UL) + + + +/* ............ The OK (success) definition ....................... */ +/*! Success defintion. */ +#define CRYS_OK 0 + +/*! MACRO that defines crys return value. */ +#define SASI_CRYS_RETURN_ERROR(retCode, retcodeInfo, funcHandler) \ + ((retCode) == 0 ? CRYS_OK : funcHandler(retCode, retcodeInfo)) + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + +/*! The typedef definition of all of the error codes that are returned from the CRYS functions */ +typedef uint32_t CRYSError_t; + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_hash_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_hash_error.h new file mode 100644 index 0000000..c1d304e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_hash_error.h @@ -0,0 +1,108 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_HASH_ERROR_H +#define CRYS_HASH_ERROR_H + + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This module contains the definitions of the CRYS HASH errors. +@defgroup crys_hash_error CryptoCell HASH specific errors +@{ +@ingroup crys_hash +*/ + + + + +/************************ Defines ******************************/ +/*! HASH module on the CRYS layer base address - 0x00F00200*/ +/* The CRYS HASH module errors */ +/*! Illegal context pointer. */ +#define CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x0UL) +/*! Illegal operation mode. */ +#define CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x1UL) +/*! Context is corrupted. */ +#define CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal data in pointer. */ +#define CRYS_HASH_DATA_IN_POINTER_INVALID_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal data in size. */ +#define CRYS_HASH_DATA_SIZE_ILLEGAL (CRYS_HASH_MODULE_ERROR_BASE + 0x4UL) +/*! Illegal result buffer pointer. */ +#define CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x5UL) +/*! Last block was already processed (may happen if previous block was not a multiple of block size). */ +#define CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xCUL) +/*! Illegal parameter. */ +#define CRYS_HASH_ILLEGAL_PARAMS_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xDUL) +/*! Illegal context size. */ +#define CRYS_HASH_CTX_SIZES_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xEUL) +/*! HASH is not supported. */ +#define CRYS_HASH_IS_NOT_SUPPORTED (CRYS_HASH_MODULE_ERROR_BASE + 0xFUL) + + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd.h new file mode 100644 index 0000000..653768c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd.h @@ -0,0 +1,398 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RND_H +#define CRYS_RND_H + +#include "crys_error.h" +#include "ssi_aes.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! +@file +@brief This file contains the CRYS APIs used for random number generation. +The random-number generation module implements referenced standard [SP800-90]. +@defgroup crys_rnd CryptoCell Random Generator APIs +@{ +@ingroup cryptocell_api +*/ + +/************************ Defines ******************************/ + +/*! Maximal reseed counter - indicates maximal number of +requests allowed between reseeds; according to NIST 800-90 +it is (2^48 - 1), our restriction is : (0xFFFFFFFF - 0xF).*/ +#define CRYS_RND_MAX_RESEED_COUNTER (0xFFFFFFFF - 0xF) + +/* Max size for one RNG generation (in bits) = + max_num_of_bits_per_request = 2^19 (FIPS 800-90 Tab.3) */ +/*! Maximal size of generated vector in bits. */ +#define CRYS_RND_MAX_GEN_VECTOR_SIZE_BITS 0x7FFFF +/*! Maximal size of generated vector in bytes. */ +#define CRYS_RND_MAX_GEN_VECTOR_SIZE_BYTES 0xFFFF + +/*! AES output block size in words. */ +#define CRYS_RND_AES_BLOCK_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS + + +/* RND seed and additional input sizes */ +/*! Maximal size of random seed in words. */ +#define CRYS_RND_SEED_MAX_SIZE_WORDS 12 + +#ifndef CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS +/*! Maximal size of additional input data in words. */ +#define CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS CRYS_RND_SEED_MAX_SIZE_WORDS +#endif + +/* allowed sizes of AES Key, in words */ +/*! AES key size (128 bits) in words. */ +#define CRYS_RND_AES_KEY_128_SIZE_WORDS 4 +/*! AES key size (192 bits) in words. */ +#define CRYS_RND_AES_KEY_192_SIZE_WORDS 6 +/*! AES key size (256 bits) in words. */ +#define CRYS_RND_AES_KEY_256_SIZE_WORDS 8 + +/* Definitions of temp buffer for RND_DMA version of CRYS_RND */ +/*******************************************************************/ +/* Definitions of temp buffer for DMA version of CRYS_RND */ + +/*! Temporary buffer size in words. */ +#define CRYS_RND_WORK_BUFFER_SIZE_WORDS 1528 + +/*! A definition for RAM buffer to be internally used in instantiation (or reseeding) operation. */ +typedef struct +{ + /*! Internal buffer*/ + uint32_t crysRndWorkBuff[CRYS_RND_WORK_BUFFER_SIZE_WORDS]; +}CRYS_RND_WorkBuff_t; + +/*! A definition for entropy estimation data type. */ +#define CRYS_RND_EntropyEstimatData_t CRYS_RND_WorkBuff_t +/*! A definition for entropy estimation buffer. */ +#define crysRndEntrIntBuff crysRndWorkBuff + + +/* RND source buffer inner (entrpopy) offset */ +/*! An internal offset definition. */ +#define CRYS_RND_TRNG_SRC_INNER_OFFSET_WORDS 2 +/*! An internal offset definition. */ +#define CRYS_RND_TRNG_SRC_INNER_OFFSET_BYTES (CRYS_RND_TRNG_SRC_INNER_OFFSET_WORDS*sizeof(uint32_t)) + + + + +/* Size of the expected output buffer used by FIPS KAT */ +/*! FIPS Known answer test output size. */ +#define CRYS_PRNG_FIPS_KAT_OUT_DATA_SIZE 64 + +/************************ Enumerators ****************************/ + +/*! Definition of random operation modes. */ +typedef enum +{ + /*! SW entropy estimation mode. */ + CRYS_RND_Fast = 0, + /*! Full entropy mode. */ + CRYS_RND_Slow = 1, + /*! Reserved. */ + CRYS_RND_ModeLast = 0x7FFFFFFF, +} CRYS_RND_mode_t; + + + +/************************ Structs *****************************/ + + +/* The internal state of DRBG mechanism based on AES CTR and CBC-MAC + algorithms. It is set as global data defined by the following + structure */ +/*! RND state structure. Includes internal data that needs to be saved between boots by the user.*/ +typedef struct +{ + /* Seed buffer, consists from concatenated Key||V: max size 12 words */ + /*! Random Seed buffer */ + uint32_t Seed[CRYS_RND_SEED_MAX_SIZE_WORDS]; + /* Previous value for continuous test */ + /*! Previous random data (used for continuous test). */ + uint32_t PreviousRandValue[SASI_AES_BLOCK_SIZE_IN_WORDS]; + + /* AdditionalInput buffer max size = seed max size words + 4w for padding*/ + /*! Previous additional input buffer. */ + uint32_t PreviousAdditionalInput[CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS+5]; + /*! Additional input buffer. */ + uint32_t AdditionalInput[CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS+4]; + /*! Additional input size in words. */ + uint32_t AddInputSizeWords; /* size of additional data set by user, words */ + + /*! Entropy source size in words */ + uint32_t EntropySourceSizeWords; + + /*! Reseed counter (32 bits active) - indicates number of requests for entropy + since instantiation or reseeding */ + uint32_t ReseedCounter; + + /*! Key size: 4 or 8 words according to security strength 128 bits or 256 bits*/ + uint32_t KeySizeWords; + + /* State flag (see definition of StateFlag above), containing bit-fields, defining: + - b'0: instantiation steps: 0 - not done, 1 - done; + - 2b'9,8: working or testing mode: 0 - working, 1 - KAT DRBG test, 2 - + KAT TRNG test; + b'16: flag defining is Previous random valid or not: + 0 - not valid, 1 - valid */ + /*! State flag used internally in the code.*/ + uint32_t StateFlag; + + /* Trng processing flag - indicates which ROSC lengths are: + - allowed (bits 0-3); + - total started (bits 8-11); + - processed (bits 16-19); + - started, but not processed (bits24-27) */ + /*! TRNG process state used internally in the code */ + uint32_t TrngProcesState; + + /* validation tag */ + /*! Validation tag used internally in the code */ + uint32_t ValidTag; + + /*! Rnd source entropy size in bits */ + uint32_t EntropySizeBits; + +} CRYS_RND_State_t; + + +/*! The RND Generate vector function pointer type definition. + The prototype intendent for External and CRYS internal RND functions + pointers definitions. + Full description can be found in ::CRYS_RND_GenerateVector function API. */ +typedef uint32_t (*SaSiRndGenerateVectWorkFunc_t)( \ + void *rndState_ptr, /*context*/ \ + uint16_t outSizeBytes, /*in*/ \ + uint8_t *out_ptr /*out*/); + + + +/*! Data structure required for internal FIPS verification for PRNG KAT. */ +typedef struct +{ + /*! Internal working buffer. */ + CRYS_RND_WorkBuff_t rndWorkBuff; + /*! Output buffer. */ + uint8_t rndOutputBuff[CRYS_PRNG_FIPS_KAT_OUT_DATA_SIZE]; +} CRYS_PrngFipsKatCtx_t; + + +/*****************************************************************************/ +/********************** Public Functions *************************/ +/*****************************************************************************/ + +/*! +@brief This function needs to be called once. +It calls CRYS_RND_Instantiation to initialize the TRNG and the primary RND context. +An initialized RND context is required for calling RND APIs and asymmetric cryptography key generation and signatures. +The primary context returned by this function can be used as a single global context for all RND needs. +Alternatively, other contexts may be initialized and used with a more limited scope (for specific applications or specific threads). + +\note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library, +this API is not thread-safe. + +@param[in/out] rnd_ctx - Pointer to the RND state structure. +@param[in/out] rndWorkBuff_ptr - Pointer to the RND scratch buffer. +*/ +CEXPORT_C CRYSError_t CRYS_RndInit(void* rnd_ctx, /*!< [in/out] Pointer to the RND state buffer, + allocated by the user. This state must be saved and provided + as parameter to any API that uses the RND module.*/ + CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in] Scratchpad for the RND module's work. */); + +/*! +@brief This function initializes the RND context. +It must be called at least once prior to using this context with any API that requires it as a parameter (e.g., other RND APIs, asymmetric +cryptography key generation and signatures). +It is called as part of ARM TrustZone CryptoCell library initialization, which initializes and returns the primary RND context. +This primary context can be used as a single global context for all RND needs. +Alternatively, other contexts may be initialized and used with a more limited scope (for specific applications or specific threads). +The call to this function must be followed by a call to ::CRYS_RND_SetGenerateVectorFunc API to set the generate vector function. +It implements referenced standard [SP800-90] - 10.2.1.3.2 - CTR-DRBG Instantiate algorithm using AES (FIPS-PUB 197) and Derivation Function (DF). +\note Additional data can be mixed with the random seed (personalization data or nonce). If required, this data should be provided by calling ::CRYS_RND_AddAdditionalInput prior to using this API. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_Instantiation( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state buffer allocated by the user, which is used to + maintain the RND state. This context state must be saved and provided as a + parameter to any API that uses the RND module. + \note the context must be cleared before sent to the function. */ + CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in/out] Scratchpad for the RND module's work. */ +); + + +/*! +@brief Clears existing RNG instantiation state. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_UnInstantiation( + void *rndState_ptr /*!< [in/out] Pointer to the RND context state buffer. */ +); + + +/*! +@brief This function is used for reseeding the RNG with additional entropy and additional user-provided input. +(additional data should be provided by calling ::CRYS_RND_AddAdditionalInput prior to using this API). +It implements referenced standard [SP800-90] - 10.2.1.4.2 - CTR-DRBG Reseeding algorithm, using AES (FIPS-PUB 197) and Derivation Function (DF). + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_Reseeding( + void *rndState_ptr, /*!< [in/out] Pointer to the RND context buffer. */ + CRYS_RND_WorkBuff_t *rndWorkBuff_ptr /*!< [in/out] Scratchpad for the RND module's work. */ +); + + +/****************************************************************************************/ +/*! +@brief Generates a random vector according to the algorithm defined in referenced standard [SP800-90] - 10.2.1.5.2 - CTR-DRBG. +The generation algorithm uses AES (FIPS-PUB 197) and Derivation Function (DF). + +\note +
      • The RND module must be instantiated prior to invocation of this API.
      • +
      • In the following cases, Reseeding operation must be performed prior to vector generation:
      • +
        • Prediction resistance is required.
        • +
        • The function returns CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR, stating that the Reseed Counter has passed its upper-limit (2^32-2).
      + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_GenerateVector( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure, which is part of the RND context structure. + Use rndContext->rndState field of the context for this parameter. */ + uint16_t outSizeBytes, /*!< [in] The size in bytes of the random vector required. The maximal size is 2^16 -1 bytes. */ + uint8_t *out_ptr /*!< [out] The pointer to output buffer. */ +); + + + +/**********************************************************************************************************/ +/*! +@brief Generates a random vector with specific limitations by testing candidates (described and used in FIPS 186-4: B.1.2, B.4.2 etc.). + +This function draws a random vector, compare it to the range limits, and if within range - return it in rndVect_ptr. +If outside the range, the function continues retrying until a conforming vector is found, or the maximal retries limit is exceeded. +If maxVect_ptr is provided, rndSizeInBits specifies its size, and the output vector must conform to the range [1 < rndVect < maxVect]. +If maxVect_ptr is NULL, rndSizeInBits specifies the exact required vector size, and the output vector must be the exact same +bit size (with its most significant bit = 1). +\note +The RND module must be instantiated prior to invocation of this API. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_GenerateVectorInRange( + void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ + SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ + uint32_t rndSizeInBits, /*!< [in] The size in bits of the random vector required. The allowed size in range 2 <= rndSizeInBits < 2^19-1, bits. */ + uint8_t *maxVect_ptr, /*!< [in] Pointer to the vector defining the upper limit for the random vector output, Given as little-endian byte array. + If not NULL, its actual size is treated as [(rndSizeInBits+7)/8] bytes and its value must be in range (3, 2^19) */ + uint8_t *rndVect_ptr /*!< [in/out] Pointer to the output buffer for the random vector. Must be at least [(rndSizeInBits+7)/8] bytes. + Treated as little-endian byte array. */ +); + + +/*************************************************************************************/ +/*! +@brief Used for adding additional input/personalization data provided by the user, +to be later used by the ::CRYS_RND_Instantiation/::CRYS_RND_Reseeding/::CRYS_RND_GenerateVector functions. + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_AddAdditionalInput( + void *rndState_ptr, /*!< [in/out] Pointer to the RND context state buffer. */ + uint8_t *additonalInput_ptr, /*!< [in] The Additional Input buffer. */ + uint16_t additonalInputSize /*!< [in] The size of the Additional Input buffer. It must + be <= CRYS_RND_ADDITINAL_INPUT_MAX_SIZE_WORDS and a multiple of 4. */ +); + +/*! +@brief The CRYS_RND_EnterKatMode function sets KAT mode bit into StateFlag of global CRYS_RND_WorkingState structure. + +The user must call this function before calling functions performing KAT tests. + +\note Total size of entropy and nonce must be not great than 126 words (maximal size of entropy and nonce). + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C CRYSError_t CRYS_RND_EnterKatMode( + void *rndState_ptr, /*!< [in/out] Pointer to the RND context state buffer. */ + uint8_t *entrData_ptr, /*!< [in] Entropy data. */ + uint32_t entrSize, /*!< [in] Entropy size in bytes. */ + uint8_t *nonce_ptr, /*!< [in] Nonce. */ + uint32_t nonceSize, /*!< [in] Entropy size in bytes. */ + CRYS_RND_WorkBuff_t *workBuff_ptr /*!< [out] RND working buffer, must be the same buffer, which should be passed into + Instantiation/Reseeding functions. */ +); + +/**********************************************************************************************************/ +/*! +@brief The CRYS_RND_DisableKatMode function disables KAT mode bit into StateFlag of global CRYS_RND_State_t structure. + +The user must call this function after KAT tests before actual using RND module (Instantiation etc.). + +@return CRYS_OK on success. +@return A non-zero value from crys_rnd_error.h on failure. +*/ +CIMPORT_C void CRYS_RND_DisableKatMode( + void *rndState_ptr /*!< [in/out] Pointer to the RND state buffer. */ +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef CRYS_RND_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd_error.h new file mode 100644 index 0000000..417eaff --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/crys_rnd_error.h @@ -0,0 +1,160 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 CRYS_RND_ERROR_H +#define CRYS_RND_ERROR_H + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/*! +@file +@brief This module contains the definitions of the CRYS RND errors. +@defgroup crys_rnd_error CryptoCell RND specific errors +@{ +@ingroup crys_rnd +*/ + + + +/************************ Defines ******************************/ +/*! RND module on the CRYS layer base address - 0x00F00C00 */ + +/*! Illegal output pointer.*/ +#define CRYS_RND_DATA_OUT_POINTER_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x0UL) +/*! Random generation in range failed .*/ +#define CRYS_RND_CAN_NOT_GENERATE_RAND_IN_RANGE (CRYS_RND_MODULE_ERROR_BASE + 0x1UL) +/*! CPRNGT test failed.*/ +#define CRYS_RND_CPRNG_TEST_FAIL_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x2UL) +/*! Illegal additional data buffer. */ +#define CRYS_RND_ADDITIONAL_INPUT_BUFFER_NULL (CRYS_RND_MODULE_ERROR_BASE + 0x3UL) +/*! Illegal additional data size. */ +#define CRYS_RND_ADDITIONAL_INPUT_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x4UL) +/*! Data size overflow. */ +#define CRYS_RND_DATA_SIZE_OVERFLOW_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x5UL) +/*! Illegal vector size. */ +#define CRYS_RND_VECTOR_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x6UL) +/*! Reseed counter overflow - in case this error was returned instantiation or reseeding operation must be called. */ +#define CRYS_RND_RESEED_COUNTER_OVERFLOW_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x7UL) +/*! Instantiation was not yet called. */ +#define CRYS_RND_INSTANTIATION_NOT_DONE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x8UL) +/*! TRNG loss of samples. */ +#define CRYS_RND_TRNG_LOSS_SAMPLES_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x9UL) +/*! TRNG Time exceeded limitations. */ +#define CRYS_RND_TRNG_TIME_EXCEED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xAUL) +/*! TRNG loss of samples and time exceeded limitations. */ +#define CRYS_RND_TRNG_LOSS_SAMPLES_AND_TIME_EXCEED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xBUL) +/*! RND is in Known Answer Test mode. */ +#define CRYS_RND_IS_KAT_MODE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xCUL) +/*! RND operation not supported. */ +#define CRYS_RND_OPERATION_IS_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xDUL) +/*! RND validity check failed. */ +#define CRYS_RND_STATE_VALIDATION_TAG_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0xEUL) +/*! RND is not supported. */ +#define CRYS_RND_IS_NOT_SUPPORTED (CRYS_RND_MODULE_ERROR_BASE + 0xFUL) +/*! RND Init failed. */ +#define CRYS_RND_INIT_FAILED (CRYS_RND_MODULE_ERROR_BASE + 0x10UL) +/*! RND Init failed. */ +#define CRYS_RND_STARTUP_FAILED (CRYS_RND_MODULE_ERROR_BASE + 0x11UL) +/*! Instantiation Failed. */ +#define CRYS_RND_INSTANTIATION_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x12L) + + +/*! Illegal generate vector function pointer. */ +#define CRYS_RND_GEN_VECTOR_FUNC_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x14UL) + +/*! Illegal work buffer pointer. */ +#define CRYS_RND_WORK_BUFFER_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x20UL) +/*! Illegal AES key size. */ +#define CRYS_RND_ILLEGAL_AES_KEY_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x21UL) +/*! Illegal data pointer. */ +#define CRYS_RND_ILLEGAL_DATA_PTR_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x22UL) +/*! Illegal data size. */ +#define CRYS_RND_ILLEGAL_DATA_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x23UL) +/*! Illegal parameter. */ +#define CRYS_RND_ILLEGAL_PARAMETER_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x24UL) +/*! Illegal RND state pointer. */ +#define CRYS_RND_STATE_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x25UL) +/*! TRNG errors. */ +#define CRYS_RND_TRNG_ERRORS_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x26UL) +/*! Illegal context pointer. */ +#define CRYS_RND_CONTEXT_PTR_INVALID_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x27UL) + +/*! Illegal output vector pointer. */ +#define CRYS_RND_VECTOR_OUT_PTR_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x30UL) +/*! Illegal output vector size. */ +#define CRYS_RND_VECTOR_OUT_SIZE_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x31UL) +/*! Maximal vector size is too small. */ +#define CRYS_RND_MAX_VECTOR_IS_TOO_SMALL_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x32UL) +/*! Illegal Known Answer Tests parameters. */ +#define CRYS_RND_KAT_DATA_PARAMS_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x33UL) +/*! TRNG Known Answer Test not supported. */ +#define CRYS_RND_TRNG_KAT_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x34UL) +/*! SRAM memory is not defined. */ +#define CRYS_RND_SRAM_NOT_SUPPORTED_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x35UL) +/*! AES operation failure. */ +#define CRYS_RND_AES_ERROR (CRYS_RND_MODULE_ERROR_BASE + 0x36UL) + + +/************************ Enums ********************************/ + + +/************************ Typedefs ****************************/ + + +/************************ Structs ******************************/ + + +/************************ Public Variables **********************/ + + +/************************ Public Functions **********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl.h new file mode 100644 index 0000000..b9fc491 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl.h @@ -0,0 +1,52 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_H__ +#define NRF_CC310_BL_H__ + +/**@file + * + * @defgroup nrf_cc310_bl CC310 bootloader API (nrf_cc310_bl) + * @brief This is a customized version of the CC310 API tailored to work with the + * @ref lib_bootloader. + * @{ + */ + +#include "nrf_cc310_bl_init.h" +#include "nrf_cc310_bl_hash_sha256.h" +#include "nrf_cc310_bl_ecdsa_verify_secp224r1.h" +#include "nrf_cc310_bl_ecdsa_verify_secp256r1.h" + +/** @} */ + +#endif //NRF_CC310_BL_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_common.h new file mode 100644 index 0000000..9ad6d02 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_common.h @@ -0,0 +1,61 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_ECDSA_VERIFY_COMMON_H__ +#define NRF_CC310_BL_ECDSA_VERIFY_COMMON_H__ + +/**@file + * + * @defgroup nrf_cc310_bl_ecdsa_verify_common nrf_cc310_bl ECDSA verify common declarations + * @ingroup nrf_cc310_bl + * @brief Common declarations for nrf_cc310_bl ECDSA verify APIs. + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CC310_BL_ECDSA_CONTEXT_INITIALIZED (0xBBAA55DD) + +#define NRF_CC310_BL_ECDSA_VERIFY_CONTEXT_SIZE_SECP224R1 (140) //!< Macro for the size of the ECDSA Verify context. +#define NRF_CC310_BL_ECDSA_VERIFY_CONTEXT_SIZE_SECP256R1 (160) //!< Macro for the size of the ECDSA Verify context. + +#ifdef __cplusplus +} +#endif + +/** @} */ + + +#endif // NRF_CC310_BL_ECDSA_VERIFY_COMMON_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp224r1.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp224r1.h new file mode 100644 index 0000000..8068c72 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp224r1.h @@ -0,0 +1,167 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_ECDSA_VERIFY_SECP224R1_H__ +#define NRF_CC310_BL_ECDSA_VERIFY_SECP224R1_H__ + +/**@file + * + * @defgroup nrf_cc310_bl_ecdsa_verify_secp224r1 nrf_cc310_bl ECDSA verify secp224r1 types + * @ingroup nrf_cc310_bl + * @brief Type definitions and APIs for nrf_cc310_bl ECDSA verify using curve secp224r1. + * @{ + */ + +#include +#include "crys_error.h" +#include "nrf_cc310_bl_ecdsa_verify_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Structure holding the secp224r1 public key represented by X,Y coordinates (uncompressed). +*/ +typedef struct +{ + uint8_t x[28]; //!< Public key X coordinate in big-endian format. + uint8_t y[28]; //!< Public key Y coordinate in big-endian format. + +} nrf_cc310_bl_ecc_public_key_secp224r1_t; + + +/**@brief Structure holding secp224r1 signature represented by R,S. +*/ +typedef struct +{ + uint8_t r[28]; //!< Signature R part in big-endian format. + uint8_t s[28]; //!< Signature S part in big-endian format. + +} nrf_cc310_bl_ecc_signature_secp224r1_t; + + +/**@brief Type definition for a context structure for running an ECDSA verify operation using + * curve secp224r1. + */ +typedef struct +{ + uint32_t init_val; //!< Value indicating the initialized state of the context structure. + uint8_t context_buffer[NRF_CC310_BL_ECDSA_VERIFY_CONTEXT_SIZE_SECP224R1]; //!< Buffer containing the required memory for running the ECDSA verify operation. + +} nrf_cc310_bl_ecdsa_verify_context_secp224r1_t; + + +/**@brief Function for initializing the context information for an ECDSA verify operation + * using curve secp224r1. + * + * @note The memory that holds the context object must be allocated prior to this call. + * + * @param[in,out] p_context Pointer to the structure holding context information + * * for the ECDSA verify operation. + * @param[in] p_public_key Pointer to the structure holding the public key for the + * ECDSA verify operation. + * + * @retval CRYS_OK Context initialized succesfully. + * @retval CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR p_context was NULL. + * @retval CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR p_public_key was NULL. + */ +CRYSError_t nrf_cc310_bl_ecdsa_verify_init_secp224r1( + nrf_cc310_bl_ecdsa_verify_context_secp224r1_t * const p_context, + nrf_cc310_bl_ecc_public_key_secp224r1_t const * const p_public_key); + + +/**@brief Function for executing an ECDSA verify on secp224r1 with hash input. + * + * @note The ECDSA verify context structure must be initialized prior to this call + * using @ref nrf_cc310_bl_ecdsa_verify_init_secp224r1. + * + * @param[in,out] p_context Pointer to the structure holding context information for + * the ECDSA verify operation. + * @param[in] p_signature Pointer to the structure holding the signature to use for the +* ECDSA verify operation. + * @param[in] p_hash Pointer to the hash to use in the ECDSA verify operation. + * @param[in] hash_len Length of the hash to verify. + * + * @retval CRYS_OK Signature was successfully verified. + * @retval CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR p_context was NULL. + * @retval CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR p_context was not initialized. + * @retval CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR p_signature was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR p_hash was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR hash_len was invalid. + * @retval CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR Signature verification failed. + */ +CRYSError_t nrf_cc310_bl_ecdsa_verify_hash_secp224r1( + nrf_cc310_bl_ecdsa_verify_context_secp224r1_t * const p_context, + nrf_cc310_bl_ecc_signature_secp224r1_t const * const p_signature, + uint8_t const * const p_hash, + uint32_t hash_len); + + +/**@brief Function for executing an ECDSA verify on secp224r1 with hash input in integrated form. + * + * @note This will run initialization of ECDSA context and run ECDSA verify in + * a single integrated step. + * + * @param[in,out] p_context Pointer to the structure holding context information + * for the ECDSA verify operation. + * @param[in] p_public_key Pointer to the structure holding the public key for + * the ECDSA verify operation. + * @param[in] p_signature Pointer to the structure holding the signature to use + * for the ECDSA verify operation. + * @param[in] p_hash Pointer to the hash to use in the ECDSA verify operation. + * @param[in] hash_len Length of the hash to verify. + * + * @retval CRYS_OK Signature was successfully verified. + * @retval CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR p_context was NULL. + * @retval CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR p_context was not initialized. + * @retval CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR + * p_public_key was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR p_signature was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR p_hash was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR hash_len was invalid. + * @retval CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR Signature verification failed. + */ +CRYSError_t nrf_cc310_bl_ecdsa_verify_secp224r1( + nrf_cc310_bl_ecdsa_verify_context_secp224r1_t * const p_context, + nrf_cc310_bl_ecc_public_key_secp224r1_t const * const p_public_key, + nrf_cc310_bl_ecc_signature_secp224r1_t const * const p_signature, + uint8_t const * const p_hash, + uint32_t hash_len); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // NRF_CC310_BL_ECDSA_VERIFY_SECP224R1_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp256r1.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp256r1.h new file mode 100644 index 0000000..cc89c41 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_ecdsa_verify_secp256r1.h @@ -0,0 +1,161 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_ECDSA_VERIFY_SECP256R1_H__ +#define NRF_CC310_BL_ECDSA_VERIFY_SECP256R1_H__ + +/**@file + * + * @defgroup nrf_cc310_bl_ecdsa_verify_secp256r1 nrf_cc310_bl ECDSA verify secp256r1 types + * @ingroup nrf_cc310_bl + * @brief Type definitions and APIs for nrf_cc310_bl ECDSA verify using curve secp256r1. + * @{ + */ + +#include +#include "crys_error.h" +#include "nrf_cc310_bl_ecdsa_verify_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Structure holding the secp256r1 public key represented by X,Y coordinates. +*/ +typedef struct +{ + uint8_t x[32]; //!< Public key X coordinate in big-endian format. + uint8_t y[32]; //!< Public key Y coordinate in big-endian format. +} nrf_cc310_bl_ecc_public_key_secp256r1_t; + + +/**@brief Structure holding the secp256r1 signature represented by R,S values. +*/ +typedef struct +{ + uint8_t r[32]; //!< Signature R part in big-endian format. + uint8_t s[32]; //!< Signature S part in big-endian format. +} nrf_cc310_bl_ecc_signature_secp256r1_t; + + +/**@brief Structure holding memory required for allocation of CC310 ECDSA verify context + * using curve secp256r1. + */ +typedef struct +{ + uint32_t init_val; + uint8_t context_buffer[NRF_CC310_BL_ECDSA_VERIFY_CONTEXT_SIZE_SECP256R1]; +} nrf_cc310_bl_ecdsa_verify_context_secp256r1_t; + + +/**@brief Function for initializing the context information for an ECDSA verify operation. + * + * @note The memory that holds the context object must be allocated prior to this call. + * + * @param[in,out] p_context Pointer to the structure holding context information + * for the ECDSA verify operation. + * @param[in] p_public_key Pointer to the structure holding the public key for + * the ECDSA verify operation. + * + * @retval CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR p_context was NULL. + * @retval CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR p_public_key was NULL. + */ +CRYSError_t nrf_cc310_bl_ecdsa_verify_init_secp256r1( + nrf_cc310_bl_ecdsa_verify_context_secp256r1_t * const p_context, + nrf_cc310_bl_ecc_public_key_secp256r1_t const * const p_public_key); + + +/**@brief Function for executing an ECDSA verify operation using secp256r1 with hash input. + * + * @note The ECDSA verify context structure must be initialized prior to this call using + * @ref nrf_cc310_bl_ecdsa_verify_init_secp256r1. + * + * @param[in,out] p_context Pointer to the structure holding context information + * for the ECDSA verify operation. + * @param[in] p_signature Pointer to the structure holding the signature to use for + * the ECDSA verify operation. + * @param[in] p_hash Pointer to the hash to use in the ECDSA verify operation. + * @param[in] hash_len Length of the hash to verify. + * + * @retval CRYS_OK Signature was successfully verified. + * @retval CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR p_context was NULL. + * @retval CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR p_context was not initialized. + * @retval CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR p_signature was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR p_hash was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR hash_len was invalid. + * @retval CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR Signature verification failed. + */ +CRYSError_t nrf_cc310_bl_ecdsa_verify_hash_secp256r1( + nrf_cc310_bl_ecdsa_verify_context_secp256r1_t * const p_context, + nrf_cc310_bl_ecc_signature_secp256r1_t const * const p_signature, + uint8_t const * const p_hash, + uint32_t hash_len); + +/**@brief Function for executing an ECDSA verify operation using secp256r1 with + * hash input in integrated form. + * + * @note This will run initialization of ECDSA context and run ECDSA verify in a single step. + * + * @param[in,out] p_context Pointer to the structure holding context information for + * the ECDSA verify operation. + * @param[in] p_public_key Pointer to the structure holding the public key for + * the ECDSA verify operation. + * @param[in] p_signature Pointer to the structure holding the signature to use + * for the ECDSA verify operation. + * @param[in] p_hash Pointer to the hash to use in the ECDSA verify operation. + * @param[in] hash_len Length of the hash to verify. + * + * @retval CRYS_OK Signature was successfully verified. + * @retval CRYS_ECDSA_VERIFY_INVALID_USER_CONTEXT_PTR_ERROR p_context was NULL. + * @retval CRYS_ECDSA_VERIFY_USER_CONTEXT_VALIDATION_TAG_ERROR p_context was not initialized. + * @retval CRYS_ECDSA_VERIFY_SIGNER_PUBL_KEY_VALIDATION_TAG_ERROR + * p_public_key was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_SIGNATURE_IN_PTR_ERROR p_signature was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_PTR_ERROR p_hash was NULL. + * @retval CRYS_ECDSA_VERIFY_INVALID_MESSAGE_DATA_IN_SIZE_ERROR hash_len was invalid. + * @retval CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR Signature verification failed. + */ +CRYSError_t nrf_cc310_bl_ecdsa_verify_secp256r1( + nrf_cc310_bl_ecdsa_verify_context_secp256r1_t * const p_context, + nrf_cc310_bl_ecc_public_key_secp256r1_t const * const p_public_key, + nrf_cc310_bl_ecc_signature_secp256r1_t const * const p_signature, + uint8_t const * const p_hash, + uint32_t hash_len); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // NRF_CC310_BL_ECDSA_VERIFY_SECP256R1_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_common.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_common.h new file mode 100644 index 0000000..3fa9dda --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_common.h @@ -0,0 +1,60 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_HASH_COMMON_H__ +#define NRF_CC310_BL_HASH_COMMON_H__ + +/**@file + * + * @defgroup nrf_cc310_bl_hash_common nrf_crypto_bl Hash common declarations + * @ingroup nrf_cc310_bl + * @brief Shared declarations used by nrf_cc310_bl for hash APIs. + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_CC310_BL_HASH_CONTEXT_INITIALIZED (0xBBAA55DD) //!< Value indicating that the hash context is initialized. +#define NRF_CC310_BL_HASH_CONTEXT_BUFFER_SIZE_SHA256 (112) //!< Size of internal representation of SHA-256 hash context. +#define NRF_CC310_BL_SHA256_DIGEST_SIZE_IN_WORDS (8) //!< Size of SHA-256 hash digest in words. +#define NRF_CC310_BL_SHA256_DIGEST_SIZE_IN_BYTES (32) //!< Size of SHA-256 hash digest in bytes. + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // NRF_CC310_BL_HASH_COMMON_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_sha256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_sha256.h new file mode 100644 index 0000000..199911b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_hash_sha256.h @@ -0,0 +1,120 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_HASH_SHA256_H__ +#define NRF_CC310_BL_HASH_SHA256_H__ + +/**@file + * + * @defgroup nrf_cc310_bl_hash_sha256 nrf_cc310_bl Hash SHA-256 API + * @ingroup nrf_cc310_bl + * @brief Type definitions and public APIs for nrf_cc310_bl HASH using SHA-256. + * @{ + */ + +#include +#include "nrf_cc310_bl_hash_common.h" +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Structure to hold SHA-256 context information. + */ +typedef struct +{ + uint32_t init_val; + uint8_t context_buffer[NRF_CC310_BL_HASH_CONTEXT_BUFFER_SIZE_SHA256]; +} nrf_cc310_bl_hash_context_sha256_t; + + +/**@brief Array to hold SHA-256 hash digest. + */ +typedef uint8_t nrf_cc310_bl_hash_digest_sha256_t[NRF_CC310_BL_SHA256_DIGEST_SIZE_IN_BYTES]; + + +/**@brief Function for initializing the SHA-256 context. + * + * @note Memory pointed to in hash context must be allocated prior to this call. + * + * @param[in,out] p_hash_context Structure holding context information for + * the SHA-256 operation. + * + * @retval CRYS_OK If call was successful. + * @retval CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR p_hash_context was NULL. + */ +CRYSError_t nrf_cc310_bl_hash_sha256_init( + nrf_cc310_bl_hash_context_sha256_t * const p_hash_context); + + +/** @brief Function for running an update to the SHA-256 hash calculation. + * + * @param[in,out] p_hash_context Structure holding context information + * for the SHA-256 operation. + * + * @retval CRYS_OK If call was successful. + * @retval CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR p_hash_context was NULL. + * @retval CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR p_hash_context not initialized. + * @retval CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR p_hash_context already finalized. + */ +CRYSError_t nrf_cc310_bl_hash_sha256_update( + nrf_cc310_bl_hash_context_sha256_t * const p_hash_context, + uint8_t const * p_src, + uint32_t len); + + +/** @brief Function for finalizing the hash calculation. + * + * @note Memory pointed to in hash digest must be allocated prior to this call. + * + * @param[in,out] p_hash_context Structure holding context information for + * the SHA-256 operation. + * @param[in,out] p_hash_digest Pointer to the structure holding SHA-256 + * hash digest. Data pointed to must be 32 bytes long. + * + * @retval CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR p_hash_context was NULL. + * @retval CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR p_hash_context was corrupted. + * @retval CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR p_digest was NULL. + */ +CRYSError_t nrf_cc310_bl_hash_sha256_finalize( + nrf_cc310_bl_hash_context_sha256_t * const p_hash_context, + nrf_cc310_bl_hash_digest_sha256_t * const p_digest); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // NRF_CC310_BL_HASH_SHA256_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_init.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_init.h new file mode 100644 index 0000000..e8ae3bc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/nrf_cc310_bl_init.h @@ -0,0 +1,62 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 NRF_CC310_BL_INIT_H__ +#define NRF_CC310_BL_INIT_H__ + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@file + * + * @addtogroup nrf_cc310_bl + * @{ + * @brief Function for initializing the CC310 hardware and runtime library. + * + * @note Running this initialization is intended for cases where there + * is no direct requirement for the RNG subsystem (all operations are deterministic). + * + * @retval CRYS_OK Initialization was successful. + */ +CRYSError_t nrf_cc310_bl_init(void); + +#ifdef __cplusplus +} +#endif + +/** @} */ + + #endif // NRF_CC310_BL_INIT_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/sns_silib.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/sns_silib.h new file mode 100644 index 0000000..5760501 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/sns_silib.h @@ -0,0 +1,101 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the + CryptoCell Lib init and finish APIs, as well as the APIs themselves. +@defgroup sns_silib CryptoCell library basic APIs +@{ +@ingroup cryptocell_api + +*/ + +#ifndef __SNS_SILIB_H__ +#define __SNS_SILIB_H__ + +#include "ssi_pal_types.h" +#include "crys_rnd.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! Definitions for error returns from SaSi_LibInit or SaSi_LibFini functions. */ +typedef enum { + SA_SILIB_RET_OK = 0, /*!< Success defintion.*/ + SA_SILIB_RET_EINVAL_CTX_PTR, /*!< Illegal context pointer.*/ + SA_SILIB_RET_EINVAL_WORK_BUF_PTR, /*!< Illegal work buffer pointer.*/ + SA_SILIB_RET_HAL, /*!< Error returned from HAL layer.*/ + SA_SILIB_RET_PAL, /*!< Error returned from PAL layer.*/ + SA_SILIB_RET_EINVAL_HW_VERSION, /*!< Invalid HW version. */ + SA_SILIB_RET_EINVAL_HW_SIGNATURE, /*!< Invalid HW signature. */ + SA_SILIB_RESERVE32B = 0x7FFFFFFFL /*!< Reserved.*/ +} SA_SilibRetCode_t; + + +/*! Internal defintion for the product register. */ +#define DX_VERSION_PRODUCT_BIT_SHIFT 0x18UL +/*! Internal defintion for the product register size. */ +#define DX_VERSION_PRODUCT_BIT_SIZE 0x8UL + + + +/*! +@brief This function Perform global initialization of the ARM CryptoCell 3xx runtime library; +it must be called once per ARM CryptoCell for 3xx cold boot cycle. + +\note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library, +this API is not thread-safe. +@return SA_SILIB_RET_OK on success. +@return A non-zero value in case of failure. +*/ +SA_SilibRetCode_t SaSi_LibInit(void); + +/*! +@brief This function finalize the library operations. It frees the associated resources (mutexes) and call hal and pal terminate functions. +in case of active instansiation - one must call CRYS_RND_UnInstantiation to clean the rnd state. +*/ +void SaSi_LibFini(void); + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /*__DX_CCLIB_H__*/ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes.h new file mode 100644 index 0000000..a42b65f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes.h @@ -0,0 +1,325 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains all of the enums and definitions that are used for the +CryptoCell AES APIs, as well as the APIs themselves. +@defgroup ssi_aes CryptoCell AES APIs +@{ +@ingroup cryptocell_api +*/ + +#ifndef SSI_AES_H +#define SSI_AES_H + +#include "ssi_pal_types.h" +#include "ssi_aes_error.h" +#include "ssi_aes_defs.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ + + +/************************ Enums ********************************/ + +/*! +Encrypt or Decrypt operation mode. +*/ +typedef enum { + /*! Encrypt operation. */ + SASI_AES_ENCRYPT = 0, + /*! Decrypt operation. */ + SASI_AES_DECRYPT = 1, + /*! Maximal number of operations. */ + SASI_AES_NUM_OF_ENCRYPT_MODES, + /*! Reserved. */ + SASI_AES_ENCRYPT_MODE_LAST = 0x7FFFFFFF +}SaSiAesEncryptMode_t; + +/*! +AES operation mode. +*/ +typedef enum { + SASI_AES_MODE_ECB = 0, /*!< ECB mode. */ + SASI_AES_MODE_CBC = 1, /*!< CBC mode. */ + SASI_AES_MODE_CBC_MAC = 2, /*!< CBC-MAC mode. */ + SASI_AES_MODE_CTR = 3, /*!< CTR mode. */ + SASI_AES_MODE_XCBC_MAC = 4, /*!< XCBC-MAC mode. */ + SASI_AES_MODE_CMAC = 5, /*!< CMAC mode. */ + SASI_AES_MODE_XTS = 6, /*!< XTS mode. */ + SASI_AES_MODE_CBC_CTS = 7, /*!< CBC-CTS mode. */ + SASI_AES_MODE_OFB = 8, /*!< OFB mode. */ + + /*! Maximal number of AES modes */ + SASI_AES_NUM_OF_OPERATION_MODES, + /*! Reserved. */ + SASI_AES_OPERATION_MODE_LAST = 0x7FFFFFFF +}SaSiAesOperationMode_t; + +/*! +AES padding type. +*/ +typedef enum { + SASI_AES_PADDING_NONE = 0, /*!< No padding. */ + SASI_AES_PADDING_PKCS7 = 1, /*!< PKCS7 padding. */ + + /*! Maximal number of AES padding modes */ + SASI_AES_NUM_OF_PADDING_TYPES, + /*! Reserved. */ + SASI_AES_PADDING_TYPE_LAST = 0x7FFFFFFF +}SaSiAesPaddingType_t; + +/*! +AES key type. +*/ +typedef enum { + SASI_AES_USER_KEY = 0, /*!< user key. */ + SASI_AES_PLATFORM_KEY = 1, /*!< Kplt hardware key. */ + SASI_AES_CUSTOMER_KEY = 2, /*!< Kcst hardware key. */ + + /*! Maximal number of AES key types */ + SASI_AES_NUM_OF_KEY_TYPES, + /*! Reserved. */ + SASI_AES_KEY_TYPE_LAST = 0x7FFFFFFF +}SaSiAesKeyType_t; + +/************************ Typedefs ****************************/ + +/*! Defines the IV buffer - 16 bytes array. */ +typedef uint8_t SaSiAesIv_t[SASI_AES_IV_SIZE_IN_BYTES]; + +/*! Defines the AES key data buffer. */ +typedef uint8_t SaSiAesKeyBuffer_t[SASI_AES_KEY_MAX_SIZE_IN_BYTES]; + +/************************ Structs ******************************/ + +/*! The user's context prototype - the argument type that is passed by the user + to the AES APIs. The context saves the state of the operation and must be saved by the user + till the end of the APIs flow*/ +typedef struct SaSiAesUserContext_t { + /*! Context buffer for internal usage. */ + uint32_t buff[SASI_AES_USER_CTX_SIZE_IN_WORDS]; +}SaSiAesUserContext_t; + + +/*! AES User Key Data. */ +typedef struct SaSiAesUserKeyData_t { + uint8_t * pKey; /*!< Pointer to the key. */ + size_t keySize; /*!< The key size in bytes. Valid values: +
      • For XTS mode - 32 or 64 byte, indicating the full size of the double key (2x128 or 2x256 bit).
      • +
      • For XCBC-MAC mode - 16 byte (limited by the standard).
      • +
      • For all other modes - 16, 24 or 32 byte.
      */ +}SaSiAesUserKeyData_t; + +/*! AES HW Key Data - this structure is likely to be changed when we'll start using it. */ +typedef struct SaSiAesHwKeyData_t { + size_t slotNumber; /*!< Slot number. */ +}SaSiAesHwKeyData_t; + + +/************************ Functions *****************************/ + +/*! +@brief This function is used to initialize an AES operation context. + To operate the AES machine, this must be the first API called. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesInit( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context buffer that is allocated by the caller and initialized by this API. + Should be used in all subsequent calls that are part of the same operation. */ + SaSiAesEncryptMode_t encryptDecryptFlag, /*!< [in] A flag specifying whether an AES Encrypt (SASI_AES_Encrypt) or Decrypt (SASI_AES_Decrypt) operation should be performed. + Must be set to CRYS_AES_Encrypt in CBC-MAC, XCBC-MAC and CMAC modes. */ + SaSiAesOperationMode_t operationMode, /*!< [in] The operation cipher/mode. */ + SaSiAesPaddingType_t paddingType /*!< [in] The padding type for AES operation: +
      • NONE - supported for all operation modes.
      • +
      • PKCS7 - supported for ECB, CBC, CBC-MAC operation modes.
      */ +); + + +/*! +@brief This function sets the key information for the AES operation, in the context that was initialized by SaSi_AesInit. +\note When FIPS certification mode is set to ON, and the mode is AES-XTS, weak keys are not allowed (128/256 lsb bits must be +different than 128/256 msb bits, according to the key size). +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesSetKey( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context, after it was initialized by SaSi_AesInit. */ + SaSiAesKeyType_t keyType, /*!< [in] The type of key to be used for the AES operation. + Currently only SASI_AES_USER_KEY is supported - the key is plaintext and provided in the pKeyData parameter. */ + void * pKeyData, /*!< [in] Pointer to the key data structure (to be casted to the relevant struct type). */ + size_t keyDataSize /*!< [in] The size of data passed in pKeyData in bytes. */ +); + + +/*! +@brief This function sets the IV, counter or tweak data for the following AES operation on the same context. + The context must be first initialized by SaSi_AesInit. + It must be called at least once prior to the first SaSi_AesBlock operation on the same context - for those ciphers that require it. + If needed, it can also be called to override the IV in the middle of a sequence of SaSi_AesBlock operations. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesSetIv( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + SaSiAesIv_t pIV /*!< [in] Pointer to the buffer of the IV, counter or tweak. +
      • For CBC, CBC-CTS, OFB and CBC-MAC modes - the IV value.
      • +
      • For CTR mode - the counter.
      • +
      • For XTS mode - the tweak value.
      • +
      • For all other modes - N/A.
      */ +); + + +/*! +@brief This function retrieves the current IV, counter or tweak from the AES context. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesGetIv( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + SaSiAesIv_t pIV /*!< [out] Pointer to the buffer of the IV, counter or tweak. +
      • For CBC, CBC-CTS, OFB and CBC-MAC modes - the IV value.
      • +
      • For CTR mode - the counter.
      • +
      • For XTS mode - the tweak value.
      • +
      • For all other modes - N/A.
      */ +); + + +/*! +@brief This function performs an AES operation on an input data buffer, according to the configuration defined in the context parameter. + It can be called as many times as needed, until all the input data is processed. + SaSi_AesInit, SaSi_AesSetKey, and for some ciphers SaSi_AesSetIv, must be called before + the first call to this API with the same context. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesBlock( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + uint8_t * pDataIn, /*!< [in] Pointer to the buffer of the input data to the AES. The pointer does not need to be aligned. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ + size_t dataInSize, /*!< [in] Size of the input data in bytes. +
      • For all modes except XTS, must be multiple of 16 bytes.
      • +
      • For XTS mode, only the following data sizes are supported: 64, 512, 520, 521, 1024 and 4096 bytes. + The data passed in a single SaSi_AesBlock call is considered to be a single XTS unit. + All subsequent calls to this API with the same context must use the same data size.
      */ + uint8_t * pDataOut /*!< [out] Pointer to the output buffer. The pointer does not need to be aligned. + For CBC-MAC, XCBC-MAC, CMAC modes it may be NULL. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ +); + + +/*! +@brief This function is used to finish AES operation. + + It processes the last data block if needed, finalizes the AES operation (cipher-specific), + and produces operation results (for MAC operations). + \note In case AES padding is used (PKCS#7) Din and Dout user's buffers must include extra space for + the padding scheme. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesFinish( + SaSiAesUserContext_t * pContext, /*!< [in] Pointer to the AES context. */ + size_t dataSize, /*!< [in] The size of the input data in bytes. +
      • For CBC-CTS mode, must be > 16. Can be <=16 only if this is the only data (no previous calls were + made to SaSi_AesBlock with the same context).
      • +
      • For XTS mode, the data size must conform to the dataInSize rules as listed for XTS under the + SaSi_AesBlock API, and match the data size passed in the previous calls to SaSi_AesBlock with the + same context.
      • +
      • For all other modes, zero is a valid size.
      • +
      • For ECB, CBC, CBC-MAC modes:
      • +
        • Must be >= 0, if direction is SASI_AES_ENCRYPT and padding type is SASI_AES_PADDING_PKCS7.
        • +
        • Must be >= 16 and a multiple of 16 bytes, if direction is SASI_AES_DECRYPT and padding type + is SASI_AES_PADDING_PKCS7.
        • +
        • Must be a multiple of 16 bytes, otherwise.
      */ + uint8_t * pDataIn, /*!< [in] Pointer of the input data buffer. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ + size_t dataInBuffSize, /*!< [in] Size of pDataIn buffer in bytes. +
      • Must be >= dataSize.
      • +
      • According to padding type, must be >= dataSize + padding. For PKCS7, padding size is + maximum SASI_AES_BLOCK_SIZE_IN_BYTES.
      */ + uint8_t * pDataOut, /*!< [out] Pointer to the output buffer. + For TZ, the size of the scatter/gather list representing the data buffer is limited to 128 entries, + and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). + For ARM CryptoCell 3xx, The buffer must be contiguous and limited to 64KB. */ + size_t * dataOutBuffSize /*!< [in,out] In - Size of pDataOut buffer in bytes. + The output buffer size must be no less than: +
      • For CBC-MAC, XCBC-MAC, CMAC modes - 16 bytes (for MAC result).
      • +
      • For non-MAC modes - dataInBuffSize.
      + Out - The size in bytes of the actual output data: +
      • If direction is SASI_AES_ENCRYPT and padding type is SASI_AES_PADDING_PKCS7, it is the actual size + with the padding.
      • +
      • If direction is SASI_AES_DECRYPT and padding type is SASI_AES_PADDING_PKCS7, it is the size without + the padding.
      • +
      • For CBC-MAC, XCBC-MAC, CMAC modes - always 16 bytes.
      */ +); + + +/*! +@brief This function releases and crears resources after AES operations. + +@return SASI_OK on success, +@return A non-zero value from ssi_aes_error.h on failure. +*/ +CIMPORT_C SaSiError_t SaSi_AesFree( + SaSiAesUserContext_t * pContext /*!< [in] Pointer to the AES context. */ +); + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef SSI_AES_H */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_defs.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_defs.h new file mode 100644 index 0000000..02789d0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_defs.h @@ -0,0 +1,83 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains definitions that are used for the ARM CryptoCell 3xx version of the CryptoCell AES APIs. +@defgroup ssi_aes_defs CryptoCell AES definitions +@{ +@ingroup ssi_aes + +*/ + +#ifndef SSI_AES_DEFS_H +#define SSI_AES_DEFS_H + +#include "ssi_pal_types.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ + +/*! The size of the user's context prototype (see ::SaSiAesUserContext_t) in words. */ +#define SASI_AES_USER_CTX_SIZE_IN_WORDS (4+4+7+4) + +/*! The AES block size in words. */ +#define SASI_AES_BLOCK_SIZE_IN_WORDS 4 +/*! The AES block size in bytes. */ +#define SASI_AES_BLOCK_SIZE_IN_BYTES (SASI_AES_BLOCK_SIZE_IN_WORDS * sizeof(uint32_t)) + +/*! The size of the IV buffer in words. */ +#define SASI_AES_IV_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS +/*! The size of the IV buffer in bytes. */ +#define SASI_AES_IV_SIZE_IN_BYTES (SASI_AES_IV_SIZE_IN_WORDS * sizeof(uint32_t)) + +/*! The maximum size of the AES KEY in words. */ +#define SASI_AES_KEY_MAX_SIZE_IN_WORDS 4 +/*! The maximum size of the AES KEY in bytes. */ +#define SASI_AES_KEY_MAX_SIZE_IN_BYTES (SASI_AES_KEY_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) + + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef SSI_AES_DEFS_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_error.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_error.h new file mode 100644 index 0000000..11c6927 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_aes_error.h @@ -0,0 +1,133 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains the definitions of the CryptoCell AES errors. +@defgroup ssi_aes_error CryptoCell AES specific errors +@{ +@ingroup ssi_aes +*/ + +#ifndef SSI_AES_ERROR_H +#define SSI_AES_ERROR_H + +#include "crys_error.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************ Defines ******************************/ + +/* generic errors */ +/*! General fatal error. */ +#define SASI_FATAL_ERROR CRYS_FATAL_ERROR +/*! General out of resources error. */ +#define SASI_OUT_OF_RESOURCE_ERROR CRYS_OUT_OF_RESOURCE_ERROR +/*! General Illegal resource value error. */ +#define SASI_ILLEGAL_RESOURCE_VAL_ERROR CRYS_ILLEGAL_RESOURCE_VAL_ERROR + +/*! CRYS_AES_MODULE_ERROR_BASE - 0x00F00000. */ +/*! Illegal user context. */ +#define SASI_AES_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x00UL) +/*! Illegal IV or tweak pointer. */ +#define SASI_AES_INVALID_IV_OR_TWEAK_PTR_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x01UL) +/*! Illegal operation. */ +#define SASI_AES_ILLEGAL_OPERATION_MODE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x02UL) +/*! Illegal key size. */ +#define SASI_AES_ILLEGAL_KEY_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x03UL) +/*! Illegal key pointer. */ +#define SASI_AES_INVALID_KEY_POINTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x04UL) +/*! Unsupported key type. */ +#define SASI_AES_KEY_TYPE_NOT_SUPPORTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x05UL) +/*! Illegal operation. */ +#define SASI_AES_INVALID_ENCRYPT_MODE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x06UL) +/*! User context corrupted. */ +#define SASI_AES_USER_CONTEXT_CORRUPTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x07UL) +/*! Illegal data in pointer. */ +#define SASI_AES_DATA_IN_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x08UL) +/*! Illegal data out pointer. */ +#define SASI_AES_DATA_OUT_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x09UL) +/*! Illegal data in size. */ +#define SASI_AES_DATA_IN_SIZE_ILLEGAL (CRYS_AES_MODULE_ERROR_BASE + 0x0AUL) +/*! Illegal data out address. */ +#define SASI_AES_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0BUL) +/*! Illegal data in buffer size. */ +#define SASI_AES_DATA_IN_BUFFER_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0CUL) +/*! Illegal data out buffer size. */ +#define SASI_AES_DATA_OUT_BUFFER_SIZE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0DUL) +/*! Illegal padding type. */ +#define SASI_AES_ILLEGAL_PADDING_TYPE_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0EUL) +/*! Incorrect padding. */ +#define SASI_AES_INCORRECT_PADDING_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x0FUL) +/*! Output is corrupted. */ +#define SASI_AES_CORRUPTED_OUTPUT_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x10UL) +/*! Illegal output size. */ +#define SASI_AES_DATA_OUT_SIZE_POINTER_INVALID_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x11UL) +/*! Decryption operation is not permitted in this mode. */ +#define SASI_AES_DECRYPTION_NOT_ALLOWED_ON_THIS_MODE (CRYS_AES_MODULE_ERROR_BASE + 0x12UL) +/*! Additional block operation is not permitted. */ +#define SASI_AES_ADDITIONAL_BLOCK_NOT_PERMITTED_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x15UL) +/*! Illegal context size. */ +#define SASI_AES_CTX_SIZES_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x16UL) + +/*! Illegal parameters. */ +#define SASI_AES_ILLEGAL_PARAMS_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x60UL) +/*! Illegal CTR block offset. */ +#define SASI_AES_CTR_ILLEGAL_BLOCK_OFFSET_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x70UL) +/*! Illegal counter (in CTR mode). */ +#define SASI_AES_CTR_ILLEGAL_COUNTER_ERROR (CRYS_AES_MODULE_ERROR_BASE + 0x71UL) +/*! AES is not supported. */ +#define SASI_AES_IS_NOT_SUPPORTED (CRYS_AES_MODULE_ERROR_BASE + 0xFFUL) + +/************************ Enums ********************************/ + +/************************ Typedefs ****************************/ + +/************************ Structs *****************************/ + +/************************ Public Variables *********************/ + +/************************ Public Functions *********************/ + +#ifdef __cplusplus +} +#endif +/** +@} + */ +#endif /* #ifndef SSI_AES_ERROR_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types.h new file mode 100644 index 0000000..ed9c333 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types.h @@ -0,0 +1,115 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains the platform dependent definitions and types. +@defgroup ssi_pal_types CryptoCell PAL platform dependant types +@{ +@ingroup ssi_pal +*/ + +#ifndef SSI_PAL_TYPES_H +#define SSI_PAL_TYPES_H + +#include "ssi_pal_types_plat.h" + +/*! Boolean definition.*/ +typedef enum { + /*! Boolean false definition.*/ + SASI_FALSE = 0, + /*! Boolean true definition.*/ + SASI_TRUE = 1 +} SaSiBool; + +/*! Success definition. */ +#define SASI_SUCCESS 0UL +/*! Failure definition. */ +#define SASI_FAIL 1UL + +/*! Defintion of 1KB in bytes. */ +#define SASI_1K_SIZE_IN_BYTES 1024 +/*! Defintion of number of bits in a byte. */ +#define SASI_BITS_IN_BYTE 8 +/*! Defintion of number of bits in a 32bits word. */ +#define SASI_BITS_IN_32BIT_WORD 32 +/*! Defintion of number of bytes in a 32bits word. */ +#define SASI_32BIT_WORD_SIZE (sizeof(uint32_t)) + +/*! Success (OK) defintion. */ +#define SASI_OK SASI_SUCCESS + +/*! Macro that handles unused parameters in the code (to avoid compilation warnings). */ +#define SASI_UNUSED_PARAM(prm) ((void)prm) + +/*! Maximal uint32 value.*/ +#define SASI_MAX_UINT32_VAL (0xFFFFFFFF) + + +/* Minimum and Maximum macros */ +#ifdef min +/*! Definition for minimum. */ +#define CRYS_MIN(a,b) min( a , b ) +#else +/*! Definition for minimum. */ +#define CRYS_MIN( a , b ) ( ( (a) < (b) ) ? (a) : (b) ) +#endif + +#ifdef max +/*! Definition for maximum. */ +#define CRYS_MAX(a,b) max( a , b ) +#else +/*! Definition for maximum. */ +#define CRYS_MAX( a , b ) ( ( (a) > (b) ) ? (a) : (b) ) +#endif + +/*! Macro that calculates number of full bytes from bits (i.e. 7 bits are 1 byte). */ +#define CALC_FULL_BYTES(numBits) (((numBits) + (SASI_BITS_IN_BYTE -1))/SASI_BITS_IN_BYTE) +/*! Macro that calculates number of full 32bits words from bits (i.e. 31 bits are 1 word). */ +#define CALC_FULL_32BIT_WORDS(numBits) (((numBits) + (SASI_BITS_IN_32BIT_WORD -1))/SASI_BITS_IN_32BIT_WORD) +/*! Macro that calculates number of full 32bits words from bytes (i.e. 3 bytes are 1 word). */ +#define CALC_32BIT_WORDS_FROM_BYTES(sizeBytes) (((sizeBytes) + SASI_32BIT_WORD_SIZE - 1) / SASI_32BIT_WORD_SIZE) +/*! Macro that round up bits to 32bits words. */ +#define ROUNDUP_BITS_TO_32BIT_WORD(numBits) (CALC_FULL_32BIT_WORDS(numBits)*SASI_BITS_IN_32BIT_WORD) +/*! Macro that round up bits to bytes. */ +#define ROUNDUP_BITS_TO_BYTES(numBits) (CALC_FULL_BYTES(numBits)*SASI_BITS_IN_BYTE) +/*! Macro that round up bytes to 32bits words. */ +#define ROUNDUP_BYTES_TO_32BIT_WORD(numBytes) (SASI_32BIT_WORD_SIZE*(((numBytes)+SASI_32BIT_WORD_SIZE-1)/SASI_32BIT_WORD_SIZE)) + + +/** +@} + */ +#endif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types_plat.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types_plat.h new file mode 100644 index 0000000..50e7e40 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/include/ssi_pal_types_plat.h @@ -0,0 +1,57 @@ +/************************************************************************************** +* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * +* * +* This file and the related binary are licensed under the following license: * +* * +* ARM Object Code and Header Files License, v1.0 Redistribution. * +* * +* Redistribution and use of object code, header files, and documentation, without * +* modification, are permitted provided that the following conditions are met: * +* * +* 1) Redistributions must reproduce the above copyright notice and the * +* following disclaimer in the documentation and/or other materials * +* provided with the distribution. * +* * +* 2) Unless to the extent explicitly permitted by law, no reverse * +* engineering, decompilation, or disassembly of is permitted. * +* * +* 3) Redistribution and use is permitted solely for the purpose of * +* developing or executing applications that are targeted for use * +* on an ARM-based product. * +* * +* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * +* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT HOLDERS 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 +@brief This file contains basic type definitions that are platform dependent. +*/ +#ifndef SSI_PAL_TYPES_PLAT_H +#define SSI_PAL_TYPES_PLAT_H +/* Host specific types for standard (ISO-C99) compilant platforms */ + +#include +#include +#include + +typedef uintptr_t SaSiVirtAddr_t; +typedef uint32_t SaSiBool_t; +typedef uint32_t SaSiStatus; + +#define SaSiError_t SaSiStatus +#define SASI_INFINITE 0xFFFFFFFF + +#define CEXPORT_C +#define CIMPORT_C + +#endif /*SSI_PAL_TYPES_PLAT_H*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/lib/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/lib/license.txt new file mode 100644 index 0000000..d45aeb3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/lib/license.txt @@ -0,0 +1,28 @@ +ARM Object Code and Header Files License +Version 1.0 + +Redistribution. + +Redistribution and use of object code, header files, and +documentation, without modification, are permitted provided that the following +conditions are met: +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of is permitted. +3) Redistribution and use is permitted solely for the purpose of + developing or executing applications that are targeted for use + on an ARM-based product. + + DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDERS 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. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/license.txt new file mode 100644 index 0000000..d45aeb3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310_bl/license.txt @@ -0,0 +1,28 @@ +ARM Object Code and Header Files License +Version 1.0 + +Redistribution. + +Redistribution and use of object code, header files, and +documentation, without modification, are permitted provided that the following +conditions are met: +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of is permitted. +3) Redistribution and use is permitted solely for the purpose of + developing or executing applications that are targeted for use + on an ARM-based product. + + DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDERS 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. \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_ctr.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_ctr.h new file mode 100644 index 0000000..111cff5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_ctr.h @@ -0,0 +1,148 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_aes AES - Advanced Encryption Standard APIs + * @ingroup nrf_oberon + * @{ + * @brief AES (advanced encryption standard) is a symmetric encryption algorithm standardized by NIST. + * AES transfers a 128-bit block of data into an encrypted block of the same size. + * @} + * + * @defgroup nrf_oberon_aes_ctr AES-CTR - AES Counter Mode + * @ingroup nrf_oberon_aes + * @{ + * @brief Type definitions and APIs for AES-CTR (AES Counter mode). + * + * AES (advanced encryption standard) is a symmetric encryption algorithm standardized by NIST. + * AES transfers a 128-bit block of data into an encrypted block of the same size. + * + * AES-CTR (AES counter mode) is an AES mode which effectively turns the block cipher into a stream + * cipher. The AES block encryption is used on a value which is incremented for each new block. + * The resulting cypher stream is then xor combined with the plaintext to get the ciphertext. + * In contrast to AES itself, encryption and decryption operations are identical for AES-CTR. + */ + +#ifndef OCRYPTO_AES_CTR_H +#define OCRYPTO_AES_CTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/**@cond */ +typedef struct { + uint32_t xkey[60]; + uint8_t counter[16]; + uint8_t cypher[16]; + uint8_t size; // Key size (16, 24, or 32 bytes). + uint32_t valid; // Valid bytes in cypher. +} ocrypto_aes_ctr_ctx; +/**@endcond */ + + +/**@name Incremental AES-CTR encryption/decryption. + * + * This group of functions can be used to incrementally compute the + * AES-CTR encryption/decryption for a given message. + */ +/**@{*/ +/** + * AES-CTR initialization. + * + * The context @p ctx is initialized using the given key @p key and initial vector @p iv. + * + * @param[out] ctx Context. + * @param key AES key. + * @param size Key size (16, 24, or 32 bytes). + * @param iv Initial vector. + */ +void ocrypto_aes_ctr_init(ocrypto_aes_ctr_ctx *ctx, const uint8_t *key, size_t size, const uint8_t iv[16]); + +/** + * AES-CTR incremental encryption. + * + * The plaintext @p pt is encrypted to the ciphertext @p ct using the context @p ctx. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param ctx Context. + * @param[out] ct Ciphertext. + * @param pt Plaintext. + * @param pt_len Length of @p pt and @p ct. + * + * @remark @p ct and @p pt can point to the same address. + * @remark Initialization of the context @p ctx through + * @c ocrypto_aes_ctr_init is required before this function can be called. + */ +void ocrypto_aes_ctr_encrypt(ocrypto_aes_ctr_ctx *ctx, uint8_t* ct, const uint8_t* pt, size_t pt_len); + +/** + * AES-CTR incremental decryption. + * + * The ciphertext @p ct is decrypted to the plaintext @p pt using the context @p ctx. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param ctx Context. + * @param[out] pt Plaintext. + * @param ct Ciphertext. + * @param ct_len Length of @p ct and @p pt. + * + * @remark @p ct and @p pt can point to the same address. + * @remark Initialization of the context @p ctx through + * @c ocrypto_aes_ctr_init is required before this function can be called. + */ +void ocrypto_aes_ctr_decrypt(ocrypto_aes_ctr_ctx *ctx, uint8_t* pt, const uint8_t* ct, size_t ct_len); +/**@}*/ + + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_eax.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_eax.h new file mode 100644 index 0000000..883b918 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_eax.h @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_aes_eax AES EAX APIs + * @ingroup nrf_oberon_aes + * @{ + * @brief Type definitions and APIS for AES EAX (Encrypt-then-authenticate-then-translate) + * + * AES (advanced encryption standard) is a symmetric encryption algorithm standardized by NIST. + * AES transfers a 128-bit block of data into an encrypted block of the same size. + * + * AES-EAX (encrypt-then-authenticate-then-translate) is an AES mode which effectively turns the + * block cipher into a stream cipher. The AES block cipher primitive is used in CTR mode for + * encryption and as OMAC for authentication over each block. + */ + +#ifndef OCRYPTO_AES_EAX_H +#define OCRYPTO_AES_EAX_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * AES-EAX encryption. + * + * @param[out] ct Cyphertext. + * @param[out] tag Authentication tag. + * @param pt Plaintext. + * @param pt_len Plaintext length. + * @param key AES key. + * @param size Key size (16, 24, or 32 bytes). + * @param iv Initial vector. + * @param iv_len Initial vector length. + * @param aa Additional authentication data. + * @param aa_len Additional authentication data length. + * + * @remark @p ct and @p pt can point to the same address. + */ +void ocrypto_aes_eax_encrypt ( + uint8_t* ct, uint8_t tag[16], const uint8_t* pt, size_t pt_len, const uint8_t *key, size_t size, + const uint8_t* iv, size_t iv_len, const uint8_t *aa, size_t aa_len); + +/** + * AES-EAX decryption. + * + * @param[out] pt Plaintext. + * @param tag Authentication tag. + * @param ct Cyphertext. + * @param ct_len Cyphertext length. + * @param key AES key. + * @param size Key size (16, 24, or 32 bytes). + * @param iv Initial vector. + * @param iv_len Initial vector length. + * @param aa Additional authentication data. + * @param aa_len Additional authentication data length. + * + * @remark @p ct and @p pt can point to the same address. + * + * @retval 0 If @p tag is valid. + * @retval -1 Otherwise. + */ +int ocrypto_aes_eax_decrypt ( + uint8_t* pt, const uint8_t tag[16], const uint8_t* ct, size_t ct_len, const uint8_t *key, size_t size, + const uint8_t* iv, size_t iv_len, const uint8_t *aa, size_t aa_len); + + +#ifdef __cplusplus +} +#endif + +#endif +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_gcm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_gcm.h new file mode 100644 index 0000000..1588e06 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_gcm.h @@ -0,0 +1,114 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_aes_gcm AES GCM - AES Galois/Counter Mode APIs + * @ingroup nrf_oberon_aes + * @{ + * @brief Type definitions and APIs for AES-GCM (AES Galois/Counter Mode). + * + * AES (advanced encryption standard) is a symmetric encryption algorithm standardized by NIST. + * AES transfers a 128-bit block of data into an encrypted block of the same size. + * + * AES-GCM (AES Galois/Counter Mode) is an AES mode which effectively turns the block cipher into + * a stream cipher. The AES block cipher primitive is used in CTR mode for encryption and decryption. + * In addition, 128-bit Galois Field multiplication is used for authentication. + */ + +#ifndef OCRYPTO_AES_GCM_H +#define OCRYPTO_AES_GCM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * AES-GCM encryption. + * + * @param[out] ct Cyphertext. + * @param[out] tag Authentication tag. + * @param pt Plaintext. + * @param pt_len Plaintext length. + * @param key AES key. + * @param size Key size (16, 24, or 32 bytes). + * @param iv Initial vector. + * @param aa Additional authentication data. + * @param aa_len Additional authentication data length. + * + * @remark @p ct and @p pt can point to the same address. + */ +void ocrypto_aes_gcm_encrypt ( + uint8_t* ct, uint8_t tag[16], const uint8_t* pt, size_t pt_len, + const uint8_t *key, size_t size, const uint8_t iv[12], const uint8_t *aa, size_t aa_len); + +/** + * AES-GCM decryption. + * + * @param[out] pt Plaintext. + * @param tag Authentication tag. + * @param ct Cyphertext. + * @param ct_len Cyphertext length. + * @param key AES key. + * @param size Key size (16, 24, or 32 bytes). + * @param iv Initial vector. + * @param aa Additional authentication data. + * @param aa_len Additional authentication data length. + * + * @remark @p ct and @p pt can point to the same address. + * + * @retval 0 If @p tag is valid. + * @retval -1 Otherwise. + */ +int ocrypto_aes_gcm_decrypt ( + uint8_t* pt, const uint8_t tag[16], const uint8_t* ct, size_t ct_len, + const uint8_t *key, size_t size, const uint8_t iv[12], const uint8_t *aa, size_t aa_len); + + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_key.h similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_key.h index d82b729..252173f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/nrf_crypto_sw/nrf_crypto_sw_hash.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_aes_key.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2019, 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 @@ -35,36 +35,36 @@ * 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 NRF_CRYPTO_SW_HASH_H__ -#define NRF_CRYPTO_SW_HASH_H__ -/** @file - * - * @defgroup nrf_crypto_sw_hash Software-based hashing using sha256 +/**@file + * @defgroup nrf_oberon_aes_key AES key sizes + * @ingroup nrf_oberon_aes * @{ - * @ingroup nrf_crypto_backend_microecc + * @brief Type definition of AES key sizes. * - * @brief Macros for type sizes in nrf_crypt SW backend. + * AES (advanced encryption standard) is a symmetric encryption algorithm standardized by NIST. + * AES transfers a 128-bit block of data into an encrypted block of the same size. */ -#include -#include "nrf_crypto_types.h" -#include "sha256.h" +#ifndef OCRYPTO_AES_KEY_H +#define OCRYPTO_AES_KEY_H #ifdef __cplusplus extern "C" { #endif -/** @brief Size of buffer required for hash context object. - */ -#define NRF_CRYPTO_HASH_CONTEXT_SIZE sizeof(sha256_context_t) +#include + +#define ocrypto_aes128_KEY_BYTES ((size_t) 16) //!< AES-128 key size in bytes +#define ocrypto_aes192_KEY_BYTES ((size_t) 24) //!< AES-192 key size in bytes +#define ocrypto_aes256_KEY_BYTES ((size_t) 32) //!< AES-256 key size in bytes #ifdef __cplusplus } #endif -/** @} */ +#endif -#endif // #ifndef NRF_CRYPTO_HASH_H__ +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20.h new file mode 100644 index 0000000..ce141c0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20.h @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_chacha ChaCha20 APIs + * @ingroup nrf_oberon_chacha_poly + * @{ + * @brief Type declaration and APIs for the Chacha20 stream cipher algorithm. + * + * ChaCha20 is a stream cipher developed by Daniel J. Bernstein based on the 20-round cipher + * Salsa20/20. + * + * A 256-bit key is expanded into 2^64 randomly accessible streams, each + * containing 2^64 randomly accessible 64-byte (512-bit) blocks. + * + * The changes from Salsa20/20 to ChaCha20 are designed to improve diffusion per + * round, conjecturally increasing resistance to cryptanalysis, while + * preserving - and often improving - time per round. + * + * @see [RFC 7539 - ChaCha20 and Poly1305 for IETF Protocols](http://tools.ietf.org/html/rfc7539) + * @see [The ChaCha family of stream ciphers](http://cr.yp.to/chacha.html) + */ + +#ifndef OCRYPTO_CHACHA20_H +#define OCRYPTO_CHACHA20_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * Length of the encryption key. + */ +#define ocrypto_chacha20_KEY_BYTES (32) + +/** + * Maximum length of the nonce. + */ +#define ocrypto_chacha20_NONCE_BYTES_MAX (12) + + +/** + * ChaCha20 cipher stream generator. + * + * The encryption key @p k, the nonce @p n, and the initial block counter + * @p count are used to generate a pseudo random cipher stream. + * + * Possible applications include key generation and random number generation. + * + * @param[out] c Generated cipher stream. + * @param c_len Length of @p c. + * @param n Nonce. + * @param n_len Nonce length. 0 <= @p n_len <= @c ocrypto_chacha20_NONCE_BYTES_MAX. + * @param k Encryption key. + * @param count Initial block counter. + * + * @remark When reusing an encryption key @p k, a different nonce @p n or + * initial block counter @p count must be used. + * + * @remark This function is equivalent to @c chacha20_stream_xor with a + * message @p m consisting of @p c_len zeroes. + */ +void ocrypto_chacha20_stream( + uint8_t *c, size_t c_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_KEY_BYTES], + uint32_t count); + +/** + * ChaCha20 cipher stream encoder. + * + * The message @p m is encrypted by applying the XOR operation with a pseudo + * random cipher stream derived from the encryption key @p k, the nonce @p n, and + * the initial block counter @p count. + * + * Calling the function a second time with the generated ciphertext as input + * message @p m decrypts it back to the original message. + * + * @param[out] c Generated ciphertext. Same length as input message. + * @param m Input message. + * @param m_len Length of @p c and @p m. + * @param n Nonce. + * @param n_len Nonce length. 0 <= @p n_len <= @c ocrypto_chacha20_NONCE_BYTES_MAX. + * @param k Encryption key. + * @param count Initial block counter. + * + * @remark @p c and @p m can point to the same address. + * + * @remark When reusing an encryption key @p k for a different message @p m, a + * different nonce @p n or initial block counter @p count must be used. + */ +void ocrypto_chacha20_stream_xor( + uint8_t *c, + const uint8_t *m, size_t m_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_KEY_BYTES], + uint32_t count); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305.h new file mode 100644 index 0000000..ba43258 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305.h @@ -0,0 +1,226 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_chacha_poly ChaCha20-Poly1305 + * @ingroup nrf_oberon + * @{ + * @brief ChaCha20-Poly1305 is an authenticated encryption algorithm with optional + * additional authenticated data developed by Daniel J.Bernstein. + * @} + * + * @defgroup nrf_oberon_chacha_poly_apis ChaCha20-Poly1305 APIs + * @ingroup nrf_oberon_chacha_poly + * @{ + * @brief Type declaration and APIs for authenticated encryption and additional data using + * the ChaCha20-Poly1305 algorithm. + * + * ChaCha20-Poly1305 is an authenticated encryption algorithm with optional + * additional authenticated data developed by Daniel J.Bernstein. + * + * The ChaCha20 stream cipher is combined with the Poly1305 authenticator. + * + * @see [RFC 7539 - ChaCha20 and Poly1305 for IETF Protocols](http://tools.ietf.org/html/rfc7539) + */ + +#ifndef OCRYPTO_CHACHA20_POLY1305_H +#define OCRYPTO_CHACHA20_POLY1305_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * Length of the encryption key. + */ +#define ocrypto_chacha20_poly1305_KEY_BYTES (32) + +/** + * Maximum length of the nonce. + */ +#define ocrypto_chacha20_poly1305_NONCE_BYTES_MAX (12) + +/** + * Length of the authentication tag. + */ +#define ocrypto_chacha20_poly1305_TAG_BYTES (16) + + +/**@{*/ +/** + * AEAD ChaCha20-Poly1305 encrypt. + * + * The message @p m is encrypted using a ChaCha20 cipher stream derived from the + * encryption key @p k and the nonce @p n. The resulting ciphertext has the same + * length @p m_len as the input message @p m and is put into @p c. + * + * Additionally, the ciphertext @p c is authenticated with a tag that is + * generated with Poly1305 using a unique subkey derived from @p k and @p n, and + * then put into @p tag. + + * + * @param[out] tag Generated authentication tag. + * @param[out] c Generated ciphertext. Same length as input message. + * @param m Input message. + * @param m_len Length of @p m and @p c. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + * + * @remark @p c and @p m can point to the same address. + * + * @remark When reusing an encryption key @p k for a different message @p m, a + * different nonce @p n must be used. + */ +void ocrypto_chacha20_poly1305_encrypt( + uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES], + uint8_t *c, + const uint8_t *m, size_t m_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); + +/** + * AEAD ChaCha20-Poly1305 encrypt with AAD. + * + * The message @p m is encrypted using a ChaCha20 cipher stream derived from the + * encryption key @p k and the nonce @p n. The resulting ciphertext has the same + * length @p m_len as the input message @p m and is put into @p c. + * + * Additionally, the ciphertext @p c, as well as the additional authenticated + * data @p a, is authenticated with a tag that is generated with Poly1305 using a + * unique subkey derived from @p k and @p n, and then put into @p tag. + * + * @param[out] tag Generated authentication tag. + * @param[out] c Generated ciphertext. Same length as input message. + * @param m Input message. + * @param m_len Length of @p m and @p c. + * @param a Additional authenticated data. + * @param a_len Length of @p a. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + * + * @remark @p c and @p m can point to the same address. + * + * @remark When reusing an encryption key @p k for a different message @p m or + * different additional authenticated data @p a, a different nonce @p n + * must be used. + */ +void ocrypto_chacha20_poly1305_encrypt_aad( + uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES], + uint8_t *c, + const uint8_t *m, size_t m_len, + const uint8_t *a, size_t a_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); +/**@}*/ + +/**@{*/ +/** + * AEAD ChaCha20-Poly1305 decrypt. + * + * If the authentication tag @p tag is valid for the ciphertext @p c, the + * encryption key @p k and the nonce @p n, the ciphertext is decrypted and put + * into @p m. The decrypted message @p m has the same length @p c_len as the + * original ciphertext. + * + * @param tag Received authentication tag. + * @param[out] m Decoded message. Same length as received ciphertext. + * @param c Received ciphertext. + * @param c_len Length of @p c and @p m. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + * + * @retval 0 If @p tag is valid. + * @retval -1 Otherwise. + * + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_chacha20_poly1305_decrypt( + const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES], + uint8_t *m, + const uint8_t *c, size_t c_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); + +/** + * AEAD ChaCha20-Poly1305 decrypt with AAD. + * + * If the authentication tag @p tag is valid for the ciphertext @p c, the + * additional authenticated data @p a, the encryption key @p k and the nonce + * @p n, the ciphertext is decrypted and put into @p m. The decrypted message + * @p m has the same length @p c_len as the original ciphertext. + * + * @param tag Received authentication tag. + * @param[out] m Decoded message. Same length as received ciphertext. + * @param c Received ciphertext. + * @param c_len Length of @p c and @p m. + * @param a Received additional authenticated data. + * @param a_len Length of @p a. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + * + * @retval 0 If @p tag is valid. + * @retval -1 Otherwise. + * + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_chacha20_poly1305_decrypt_aad( + const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES], + uint8_t *m, + const uint8_t *c, size_t c_len, + const uint8_t *a, size_t a_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305_inc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305_inc.h new file mode 100644 index 0000000..9576f3c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_chacha20_poly1305_inc.h @@ -0,0 +1,245 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_chacha_poly_inc ChaCha20-Poly1305 incremental APIs + * @ingroup nrf_oberon_chacha_poly + * @{ + * @brief Type declaration and APIs for authenticated encryption and additional data using + * the ChaCha20-Poly1305 algorithm in incremental steps. + * + * ChaCha20-Poly1305 is an authenticated encryption algorithm with optional + * additional authenticated data developed by Daniel J.Bernstein. + * + * The ChaCha20 stream cipher is combined with the Poly1305 authenticator. + * + * @see [RFC 7539 - ChaCha20 and Poly1305 for IETF Protocols](http://tools.ietf.org/html/rfc7539) + */ + +#ifndef OCRYPTO_CHACHA20_POLY1305_INC_H +#define OCRYPTO_CHACHA20_POLY1305_INC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "ocrypto_chacha20_poly1305.h" +#include "ocrypto_poly1305.h" + + +/**@cond */ +typedef struct { + ocrypto_poly1305_ctx auth_ctx; + uint8_t subkey[32]; + uint8_t buffer[16]; + uint32_t buffer_len; + uint8_t cypher[64]; + uint32_t cypher_idx; + uint32_t count; + size_t msg_len; + size_t aad_len; +} ocrypto_chacha20_poly1305_ctx; +/**@endcond */ + + +/**@name Incremental ChaCha20-Poly1305 generator. + * + * This group of functions can be used to incrementally encode and decode using the ChaCha20-Poly1305 stream cypher. + * + * Use pattern: + * + * Encoding: + * @code + * ocrypto_chacha20_poly1305_init(ctx, nonce, nonce_len, key); + * ocrypto_chacha20_poly1305_update_aad(ctx, aad, aad_len, nonce, nonce_len, key); + * ... + * ocrypto_chacha20_poly1305_update_aad(ctx, aad, aad_len, nonce, nonce_len, key); + * ocrypto_chacha20_poly1305_update_enc(ctx, ct, pt, pt_len, nonce, nonce_len, key); + * ... + * ocrypto_chacha20_poly1305_update_enc(ctx, ct, pt, pt_len, nonce, nonce_len, key); + * ocrypto_chacha20_poly1305_final_enc(ctx, tag); + * @endcode + * Decoding: + * @code + * ocrypto_chacha20_poly1305_init(ctx, nonce, nonce_len, key); + * ocrypto_chacha20_poly1305_update_aad(ctx, aad, aad_len, nonce, nonce_len, key); + * ... + * ocrypto_chacha20_poly1305_update_aad(ctx, aad, aad_len, nonce, nonce_len, key); + * ocrypto_chacha20_poly1305_update_dec(ctx, pt, ct, ct_len, nonce, nonce_len, key); + * ... + * ocrypto_chacha20_poly1305_update_dec(ctx, pt, ct, ct_len, nonce, nonce_len, key); + * res = ocrypto_chacha20_poly1305_final_dec(ctx, tag); + * @endcode + */ +/**@{*/ + +/** + * ChaCha20-Poly1305 initialization. + * + * The generator state @p ctx is initialized by this function. + * + * @param[out] ctx Generator state. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + */ +void ocrypto_chacha20_poly1305_init( + ocrypto_chacha20_poly1305_ctx *ctx, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); + +/** + * SHA-ChaCha20-Poly1305 incremental aad input. + * + * The generator state @p ctx is updated to include a data chunk @p a. + * + * This function can be called repeatedly until the whole data is processed. + * + * @param ctx Generator state. + * @param a Additional authenticated data. + * @param a_len Length of @p a. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_chacha20_poly1305_init is required before this function can be called. + * + * @remark @c ocrypto_chacha20_poly1305_update_aad must be called before any call to + * @c ocrypto_chacha20_poly1305_update_enc or @c ocrypto_chacha20_poly1305_update_dec. + */ +void ocrypto_chacha20_poly1305_update_aad( + ocrypto_chacha20_poly1305_ctx *ctx, + const uint8_t *a, size_t a_len); + +/** + * SHA-ChaCha20-Poly1305 incremental encoder input. + * + * The generator state @p ctx is updated to include a message chunk @p m. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param ctx Generator state. + * @param[out] c Generated ciphertext. Same length as input message. + * @param m Message chunk. + * @param m_len Length of @p m. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_chacha20_poly1305_init is required before this function can be called. + * + * @remark @c ocrypto_chacha20_poly1305_update_enc must be called after any call to + * @c ocrypto_chacha20_poly1305_update_aad. + * + * @remark @p c and @p m can point to the same address. + */ +void ocrypto_chacha20_poly1305_update_enc( + ocrypto_chacha20_poly1305_ctx *ctx, + uint8_t *c, + const uint8_t *m, size_t m_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); + +/** + * SHA-ChaCha20-Poly1305 incremental decoder input. + * + * The generator state @p ctx is updated to include a cyphertext chunk @p c. + * + * This function can be called repeatedly until the whole cyphertext is processed. + * + * @param ctx Generator state. + * @param[out] m Decoded message. Same length as received ciphertext. + * @param c Cyphertext chunk. + * @param c_len Length of @p c. + * @param n Nonce. + * @param n_len Length of @p n. 0 <= @p n_len <= @c ocrypto_chacha20_poly1305_NONCE_BYTES_MAX. + * @param k Encryption key. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_chacha20_poly1305_init is required before this function can be called. + * + * @remark @c ocrypto_chacha20_poly1305_update_dec must be called after any call to + * @c ocrypto_chacha20_poly1305_update_aad. + * + * @remark @p m and @p c can point to the same address. + */ +void ocrypto_chacha20_poly1305_update_dec( + ocrypto_chacha20_poly1305_ctx *ctx, + uint8_t *m, + const uint8_t *c, size_t c_len, + const uint8_t *n, size_t n_len, + const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]); + +/** + * SHA-ChaCha20-Poly1305 final encoder step. + * + * The generator state @p ctx is used to finalize the encryption and generate the tag. + * + * @param ctx Generator state. + * @param[out] tag Generated authentication tag. + */ +void ocrypto_chacha20_poly1305_final_enc( + ocrypto_chacha20_poly1305_ctx *ctx, + uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES]); + +/** + * SHA-ChaCha20-Poly1305 final decoder step. + * + * The generator state @p ctx is used to finalize the decryption and check the tag. + * + * @param ctx Generator state. + * @param tag Received authentication tag. + * + * @retval 0 If @p tag is valid. + * @retval -1 Otherwise. + */ +int ocrypto_chacha20_poly1305_final_dec( + ocrypto_chacha20_poly1305_ctx *ctx, + const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES]); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_constant_time.h similarity index 53% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_constant_time.h index 60f192d..d4c992e 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_constant_time.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2019, 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 @@ -35,70 +35,78 @@ * 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 nrf_oberon Oberon cryptographic library + * @{ + * @brief Highly optimized cryptographic algorithm implementation for Cortex-M0, Cortex-M4, + * and Cortex-M33. Created by Oberon, under distribution license with Nordic Semiconductor ASA. + * @} + * + * @defgroup nrf_oberon_constant_time Constant time APIs + * @ingroup nrf_oberon + * @{ + * @brief Timing-invariant functions to use with cryptography. + * + * Collection of timing-invariant implementations of basic functions. */ -#ifndef NRF_CRYPTO_H__ -#define NRF_CRYPTO_H__ -#include -#include "nrf_crypto_init.h" -#include "nrf_crypto_mem.h" -#include "nrf_crypto_keys.h" -#include "nrf_crypto_hash.h" -#include "nrf_crypto_ecdsa.h" -#include "nrf_crypto_ecdh.h" -#include "nrf_crypto_rng.h" +#ifndef OCRYPTO_CONSTANT_TIME_H +#define OCRYPTO_CONSTANT_TIME_H #ifdef __cplusplus extern "C" { #endif +#include + + /** - * @defgroup nrf_crypto Cryptography library - * @ingroup app_common - * @{ - * - * @brief Cryptography library (nrf_crypto). - * - * @details The cryptography library provides functions to compute keys, shared secrets, and hashes, - * and to sign and verify data using digital signatures. - * @} + * Variable length comparison. * - * @defgroup nrf_crypto_backends Backends - * @ingroup nrf_crypto - * @{ - * - * @brief Backends for the cryptography library. - * - * @details The cryptography library can be used with several backends that provide different functionality. - * @} - * - * @defgroup nrf_crypto_backend_cryptocell Hardware-accelerated backend (CryptoCell) - * @ingroup nrf_crypto_backends - * @{ - * - * @brief @tagAPI52840 Hardware-accelerated backend for the cryptography library based on CryptoCell (CC310). - * - * @details The CryptoCell backend is available on the nRF52840 SoC only, because it requires cryptography hardware. It uses the @ref cryptocell_api. - * @} - * - * @defgroup nrf_crypto_backend_microecc Software backend (micro-ecc) - * @ingroup nrf_crypto_backends - * @{ + * @param x Memory region to compare with @p y. + * @param y Memory region to compare with @p x. + * @param length Number of bytes to compare, @p length > 0. * - * @brief Software backend for the cryptography library based on micro-ecc. + * @retval 1 If @p x and @p y point to equal memory regions. + * @retval 0 Otherwise. + */ +int ocrypto_constant_time_equal(const void *x, const void *y, size_t length); + +/** + * Variable length compare to zero. * - * @details The Software backend uses the external micro-ecc library. Make sure to install the library if you use this backend. See @ref lib_crypto_installing for details. + * @param x Pointer to memory region that will be compared. + * @param length Number of bytes to compare, @p length > 0. * - * @ref nrf_crypto_sw_hash "Hashing" and @ref nrf_crypto_sw_rng "random number generation" must be enabled separately. - * @} + * @retval 1 If @p x is equal to a zero memory region. + * @retval 0 Otherwise. + */ +int ocrypto_constant_time_is_zero(const void *x, size_t length); + +/** + * Variable length copy. * + * @param x Pointer to memory region to copy @p y to. + * @param y Pointer to memory region to copy to @p x. + * @param length Number of bytes to copy, @p length > 0. */ +void ocrypto_constant_time_copy(void *x, const void *y, size_t length); +/** + * Variable length fill with zero. + * + * @param x Pointer to memory region to be filled with zero. + * @param length Number of bytes to fill, @p length > 0. + */ +void ocrypto_constant_time_fill_zero(void *x, size_t length); #ifdef __cplusplus } #endif -#endif // NRF_CRYPTO_H__ +#endif +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve25519.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve25519.h new file mode 100644 index 0000000..3498375 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve25519.h @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_curve25519 ECC Curve25519 low-level APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for low-level elliptic curve point operations + * based on Curve25519. + * + * Curve25519 is an elliptic curve offering 128 bits of security. It is designed + * for use in the Elliptic Curve Diffie-Hellman (ECDH) key agreement scheme. + * + * @see [RFC 7748 - Elliptic Curves for Security](https://tools.ietf.org/html/rfc7748) + * @see [Curve25519: high-speed elliptic-curve cryptography](http://cr.yp.to/ecdh.html) + */ + +#ifndef OCRYPTO_CURVE25519_H +#define OCRYPTO_CURVE25519_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + +/** + * Length of a scalar. + */ +#define ocrypto_curve25519_SCALAR_BYTES (32) + +/** + * Length of a curve point. + */ +#define ocrypto_curve25519_BYTES (32) + + +/** + * Curve25519 scalar multiplication `r = n * basePoint`. + * + * Given a secret key @p n, the corresponding Curve25519 public key is computed + * and put into @p r. + * + * The inverse of this function is difficult to compute. + * + * @param[out] r Resulting curve point. + * @param[in] n Scalar factor. + * + * @remark @p r and @p n can point to the same address. + */ +void ocrypto_curve25519_scalarmult_base( + uint8_t r[ocrypto_curve25519_BYTES], + const uint8_t n[ocrypto_curve25519_SCALAR_BYTES]); + +/** + * Curve25519 scalar multiplication `r = n * p`. + * + * A shared secret is computed from the local secret key @p n and another + * party's public key @p p and put into @p r. The same shared secret is + * generated when the other party combines its private key with the local public + * key. + * + * @param[out] r Resulting curve point. + * @param[in] n Scalar factor. + * @param[in] p Point factor. + * + * @remark @p r and @p n can point to the same address. + */ +void ocrypto_curve25519_scalarmult( + uint8_t r[ocrypto_curve25519_BYTES], + const uint8_t n[ocrypto_curve25519_SCALAR_BYTES], + const uint8_t p[ocrypto_curve25519_BYTES]); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve_p256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve_p256.h new file mode 100644 index 0000000..7cf972d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_curve_p256.h @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_p256 ECC secp256r1 low-level APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for low-level elliptic curve point operations + * based on the NIST secp256r1 curve. + */ + +#ifndef OCRYPTO_CURVE_P256_H +#define OCRYPTO_CURVE_P256_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ocrypto_sc_p256.h" + + +// (x,y) only jacobian coordinates +/**@cond */ +typedef struct { + ocrypto_mod_p256 x; + ocrypto_mod_p256 y; +} ocrypto_cp_p256; +/**@endcond */ + +/** Load r.x from bytes, keep r.y. + * + * @param[out] r Point with r.x loaded, r.y kept. + * @param p x as as array of bytes. + * + * @retval 0 If @p r is a legal curve point. + * @retval -1 Otherwise. + */ +int ocrypto_curve_p256_from32bytes(ocrypto_cp_p256 *r, const uint8_t p[32]); + + +/** Load point from bytes. + * + * @param[out] r Loaded point. + * @param p Point as array of bytes. + * + * @retval 0 If @p r is a legal curve point. + * @retval -1 Otherwise. + */ +int ocrypto_curve_p256_from64bytes(ocrypto_cp_p256 *r, const uint8_t p[64]); + +/** Store p.x to bytes. + * + * @param[out] r x stored as array. + * @param p Point with x to be stored. + */ +void ocrypto_curve_p256_to32bytes(uint8_t r[32], ocrypto_cp_p256 *p); + +/** Store p.x to bytes. + * + * @param[out] r Point stored as array. + * @param p Point to be stored. + */ +void ocrypto_curve_p256_to64bytes(uint8_t r[64], ocrypto_cp_p256 *p); + +/** P256 scalar multiplication. + * + * r = p * s + * r = [0,0] if p = [0,0] or s mod q = 0 + * + * @param[out] r Output point. + * @param p Input point. + * @param s Scalar. + * + * @retval -1 If r = [0,0]. + * @retval 0 If 0 < s < q. + * @retval 1 If s > q. + */ +int ocrypto_curve_p256_scalarmult(ocrypto_cp_p256 *r, const ocrypto_cp_p256 *p, const ocrypto_sc_p256 *s); + +/** P256 scalar base multiplication. + * + * r = basePoint * s + * r = [0,0] if s mod q = 0 + * + * @param[out] r Output point. + * @param s Scalar. + * + * @retval -1 If r = [0,0]. + * @retval 0 If 0 < s < q. + * @retval 1 If s > q. + */ +int ocrypto_curve_p256_scalarmult_base(ocrypto_cp_p256 *r, const ocrypto_sc_p256 *s); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdh_p256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdh_p256.h new file mode 100644 index 0000000..13805b7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdh_p256.h @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_ecdh ECDH APIs + * @ingroup nrf_oberon + * @{ + * @brief APIs to do Elliptic Curve Diffie-Hellman using the NIST secp256r1 curve. + */ + +#ifndef OCRYPTO_ECDH_P256_H +#define OCRYPTO_ECDH_P256_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + +/** ECDH P-256 public key r = n * p. + * + * @param[out] r Resulting public key. + * @param s Secret key. + * + * @remark @p r may be the same as @p s. + * @retval 0 If @p s is a legal secret key. + */ +int ocrypto_ecdh_p256_public_key(uint8_t r[64], const uint8_t s[32]); + +/** ECDH P-256 common secret. + * + * @param[out] r Resulting common secret. + * @param s Secret key. + * @param p Public key. + * + * @remark @p r may be the same as @p s or @p p. + * @retval 0 If @p s is a legal secret key and @p p is a legal public key. + */ +int ocrypto_ecdh_p256_common_secret(uint8_t r[32], const uint8_t s[32], const uint8_t p[64]); + + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdsa_p256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdsa_p256.h new file mode 100644 index 0000000..e4d9f01 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ecdsa_p256.h @@ -0,0 +1,142 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_ecdsa ECDSA APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs to do Elliptic Curve Digital Signature Algorith using the + * NIST secp256r1 curve. + */ +#ifndef OCRYPTO_ECDSA_P256_H +#define OCRYPTO_ECDSA_P256_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * ECDSA P-256 signature key pair generation. + * + * @param[out] pk Generated public key. + * @param[out] sk Private key. + * + * @retval 0 If @p sk is a legal secret key. + */ +int ocrypto_ecdsa_p256_public_key( + uint8_t pk[64], + const uint8_t sk[32]); + + +/** + * ECDSA P-256 signature generation. + * + * @param[out] sig Generated signature. + * @param m Input message. + * @param mlen Length of the message. + * @param sk Secret key. + * @param ek Session key. + * + * @retval 0 If @p ek is a valid session key. + */ +int ocrypto_ecdsa_p256_sign( + uint8_t sig[64], + const uint8_t *m, size_t mlen, + const uint8_t sk[32], + const uint8_t ek[32]); + + +/** + * ECDSA P-256 signature generation from hash. + * + * @param[out] sig Generated signature. + * @param hash SHA-256 hash of the input message. + * @param sk Secret key. + * @param ek Session key. + * + * @retval 0 If @p ek is a valid session key. + */ +int ocrypto_ecdsa_p256_sign_hash(uint8_t sig[64], + const uint8_t hash[32], + const uint8_t sk[32], + const uint8_t ek[32]); + + +/** + * ECDSA P-256 signature verification. + * + * @param sig Input signature. + * @param m Input message. + * @param mlen Input length. + * @param pk Public key. + * + * @retval 0 If signature is valid. + * @retval -1 Otherwise. + */ +int ocrypto_ecdsa_p256_verify( + const uint8_t sig[64], + const uint8_t *m, size_t mlen, + const uint8_t pk[64]); + + +/** + * ECDSA P-256 signature verification from hash. + * + * @param sig Input signature. + * @param hash SHA-256 hash of the input message. + * @param pk Public key. + * + * @retval 0 If signature is valid. +* @retval -1 Otherwise. + */ +int ocrypto_ecdsa_p256_verify_hash(const uint8_t sig[64], + const uint8_t hash[32], + const uint8_t pk[64]); + + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ed25519.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ed25519.h new file mode 100644 index 0000000..41fbac5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_ed25519.h @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_ed25519 Ed25519 APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for the Ed25519 algorithm. + * + * Ed25519 is a specific implementation of EdDSA, a digital signature scheme. + * EdDSA is based on Twisted Edwards curves and is designed to be faster than + * existing digital signature schemes without sacrificing security. It was + * developed by Daniel J. Bernstein, et al. Ed25519 is intended to provide + * attack resistance comparable to quality 128-bit symmetric ciphers. + * + * @see [Ed25519: high-speed high-security signatures](https://ed25519.cr.yp.to) + */ + +#ifndef OCRYPTO_ED25519_H +#define OCRYPTO_ED25519_H + +#include +#include + + +/** + * Length of a public key. + */ +#define ocrypto_ed25519_PUBLIC_KEY_BYTES (32) + +/** + * Length of a secret key. + */ +#define ocrypto_ed25519_SECRET_KEY_BYTES (32) + +/** + * Length of a signature. + */ +#define ocrypto_ed25519_BYTES (64) + + +/** + * Ed25519 signature key pair generation. + * + * Given a secret key @p sk, the corresponding public key is computed and put + * into @p pk. The key pair can then be used to sign and verify message signatures. + * + * @param[out] pk Generated public key. + * @param sk Secret key. Must be pre-filled with random data. + */ +void ocrypto_ed25519_public_key(uint8_t pk[ocrypto_ed25519_PUBLIC_KEY_BYTES], + const uint8_t sk[ocrypto_ed25519_SECRET_KEY_BYTES]); + +/** + * Ed25519 signature generate. + * + * The message @p m is signed using the secret key @p sk and the corresponding + * public key @p pk. The signature is put into @p sig. + * + * @param[out] sig Generated signature. + * @param m Input message. + * @param m_len Length of @p m. + * @param sk Secret key. + * @param pk Public key. + */ +void ocrypto_ed25519_sign(uint8_t sig[ocrypto_ed25519_BYTES], + const uint8_t *m, size_t m_len, + const uint8_t sk[ocrypto_ed25519_SECRET_KEY_BYTES], + const uint8_t pk[ocrypto_ed25519_PUBLIC_KEY_BYTES]); + +/** + * Ed25519 signature verification. + * + * The signature @p sig of the input message @p m is verified using the signer's + * public key @p pk. + * + * @param sig Input signature. + * @param m Input message. + * @param m_len Length of @p m. + * @param pk Signer's public key. + * + * @retval 0 If signature is OK. + * @retval -1 Otherwise. + */ +int ocrypto_ed25519_verify(const uint8_t sig[ocrypto_ed25519_BYTES], + const uint8_t *m, size_t m_len, + const uint8_t pk[ocrypto_ed25519_PUBLIC_KEY_BYTES]); + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha256.h similarity index 56% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha256.h index d5344b1..eb6866f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/bootloader/dfu/nrf_dfu.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha256.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2019, 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 @@ -35,78 +35,74 @@ * 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 nrf_oberon_hkdf HKDF - HMAC based Key Derivation Function + * @ingroup nrf_oberon + * @{ + * @brief HKDF is a key derivation function based on HMAC Extract-and-Expand + * @} * - * @defgroup nrf_dfu DFU bootloader + * @defgroup nrf_oberon_hkdf_256 HKDF APIs using SHA-256 + * @ingroup nrf_oberon_hkdf * @{ - * @ingroup sdk_nrf_bootloader - * @brief Bootloader with Device Firmware Update (DFU) functionality. + * @brief Type declarations and APIs for the HKDF-SHA256 algorithm. + * + * HKDF-SHA256 is a key derivation function based on HMAC-SHA256. * - * The DFU bootloader module, in combination with the @ref sdk_bootloader module, - * can be used to implement a bootloader that supports Device Firmware Updates. + * @see [RFC 5869 - HMAC-based Extract-and-Expand Key Derivation Function (HKDF)](http://tools.ietf.org/html/rfc5869) */ - -#ifndef NRF_DFU_H__ -#define NRF_DFU_H__ - -#include -#include +#ifndef OCRYPTO_HKDF_SHA256_H +#define OCRYPTO_HKDF_SHA256_H #ifdef __cplusplus extern "C" { #endif +#include +#include -/** @brief Function for initializing a DFU operation. - * - * This function initializes a DFU operation and any transports that are registered - * in the system. - * - * @retval NRF_SUCCESS If the DFU operation was successfully initialized. - */ -uint32_t nrf_dfu_init(void); - - -/** @brief Function to check if button was pressed - * - * @note This function must be implemented by the application to enable - * entering bootloader mode based on button press. - * - * @retval true if the DFU mode should be entered, otherwise false. +/** + * Maximum length of a derived key. */ -bool nrf_dfu_button_enter_check(void); - +#define ocrypto_hkdf_sha256_LENGTH_MAX (32) -/** @brief Function for checking if DFU mode should be entered. - * - * This function checks whether DFU mode is required. - * - * @retval true If DFU mode must be entered. - * @retval false If there is no need to enter DFU mode. +/** + * Maximum salt length. */ -bool nrf_dfu_enter_check(void); +#define ocrypto_hkdf_sha256_SALT_LENGTH_MAX (64) -/** @brief Function for checking if DFU should be reset (failsafe). - * - * This function will check if DFU should be reset (failsafe). +/** + * HKDF-SHA256 algorithm. * - * If this returns true, DFU mode will be entered and DFU will be reset. + * A new pseudo-random key of length @p r_len is derived from an input key + * @p key, a salt @p salt and additional information @p info. The new key is put + * into @p r. * - * @retval true If DFU must be reset (failsafe). - * @retval false If there is no need to reset DFU. + * @param[out] r Output key. + * @param r_len Length of @p r, 0 < @p r_len <= @c ocrypto_hkdf_sha256_LENGTH_MAX. + * @param key Input key. + * @param key_len Length of @p key. + * @param salt Salt. + * @param salt_len Length of salt @p salt. 0 <= @p salt_len <= @c ocrypto_hkdf_sha256_SALT_LENGTH_MAX. + * @param info Additional information. + * @param info_len Length of @p info. */ -bool nrf_dfu_check_failsafe_reset(void); - +void ocrypto_hkdf_sha256( + uint8_t* r, size_t r_len, + const uint8_t* key, size_t key_len, + const uint8_t* salt, size_t salt_len, + const uint8_t* info, size_t info_len); #ifdef __cplusplus } #endif -#endif // NRF_DFU_H__ +#endif /** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha512.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha512.h new file mode 100644 index 0000000..9e0825f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hkdf_sha512.h @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_hkdf_512 HKDF APIs using SHA-512 + * @ingroup nrf_oberon_hkdf + * @{ + * @brief Type declaration and APIs for the HKDF-SHA512 algorithm. + * + * HKDF-SHA512 is a key derivation function based on HMAC-SHA512. + * + * @see [RFC 5869 - HMAC-based Extract-and-Expand Key Derivation Function (HKDF)](http://tools.ietf.org/html/rfc5869) + */ + +#ifndef OCRYPTO_HKDF_SHA512_H +#define OCRYPTO_HKDF_SHA512_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * Maximum length of a derived key. + */ +#define ocrypto_hkdf_sha512_LENGTH_MAX (64) + +/** + * Maximum salt length. + */ +#define ocrypto_hkdf_sha512_SALT_LENGTH_MAX (128) + + +/** + * HKDF-SHA512 algorithm. + * + * A new pseudo-random key of length @p r_len is derived from an input key + * @p key, a salt @p salt and additional information @p info. The new key is put + * into @p r. + * + * @param[out] r Output key. + * @param r_len Length of @p r, 0 < @p r_len <= @c ocrypto_hkdf_sha512_LENGTH_MAX. + * @param key Input key. + * @param key_len Length of @p key. + * @param salt Salt. + * @param salt_len Length of salt @p salt. 0 <= @p salt_len <= @c ocrypto_hkdf_sha512_SALT_LENGTH_MAX. + * @param info Additional information. + * @param info_len Length of @p info. + */ +void ocrypto_hkdf_sha512( + uint8_t* r, size_t r_len, + const uint8_t* key, size_t key_len, + const uint8_t* salt, size_t salt_len, + const uint8_t* info, size_t info_len); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha256.h new file mode 100644 index 0000000..32ea2f2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha256.h @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_hmac HMAC - Hash-based Aessage Authentication Code + * @ingroup nrf_oberon + * @{ + * @brief HMAC is a hash-based Message Authentication Code utilizing a secure hash function. + * @} + * @defgroup nrf_oberon_hmac_256 HMAC APIs using SHA-256 + * @ingroup nrf_oberon_hmac + * @{ + * @brief Type declarations and APIs for the HMAC-SHA256 algorithm. + * + * HMAC-SHA256 is an algorithm for message authentication using the + * cryptographic hash function SHA256 and a reusable secret key. Users in + * possession of the key can verify the integrity and authenticity of the + * message. + * + * @see [RFC 2104 - HMAC: Keyed-Hashing for Message Authentication](http://tools.ietf.org/html/rfc2104) + */ + +#ifndef OCRYPTO_HMAC_SHA256_H +#define OCRYPTO_HMAC_SHA256_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "include/ocrypto_sha256.h" + + +/** + * Maximum key length. + */ +#define ocrypto_hmac_sha256_KEY_BYTES_MAX (64) + +/** + * Length of the authenticator. + */ +#define ocrypto_hmac_sha256_BYTES (32) + + +/**@cond */ +typedef struct +{ + ocrypto_sha256_ctx hash_ctx; + uint8_t ikey[ocrypto_hmac_sha256_KEY_BYTES_MAX]; + uint8_t okey[ocrypto_hmac_sha256_KEY_BYTES_MAX]; + uint8_t key[ocrypto_hmac_sha256_KEY_BYTES_MAX]; +} ocrypto_hmac_sha256_ctx; +/**@endcond */ + + +/**@name Incremental HMAC-SHA256 generator. + * + * This group of functions can be used to incrementally compute HMAC-SHA256 + * for a given message. + */ +/**@{*/ + +/** + * HMAC-SHA256 initialization. + * + * The generator state @p ctx is initialized by this function. + * + * @param[out] ctx Generator state. + * @param key HMAC key. + * @param key_len Length of @p key. + */ +void ocrypto_hmac_sha256_init(ocrypto_hmac_sha256_ctx * ctx, + const uint8_t* key, size_t key_len); + +/** + * HMAC-SHA256 incremental data input. + * + * The generator state @p ctx is updated to hash a message chunk @p in. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param[in,out] ctx Generator state. + * @param in Input data. + * @param in_len Length of @p in. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_hmac_sha256_init is required before this function can be called. + */ +void ocrypto_hmac_sha256_update(ocrypto_hmac_sha256_ctx * ctx, + const uint8_t* in, size_t in_len); + +/** + * HMAC-SHA256 output. + * + * The generator state @p ctx is updated to finalize the HMAC calculation. + * The HMAC digest is put into @p r. + * + * @param[in,out] ctx Generator state. + * @param[out] r Generated HMAC digest. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_hmac_sha256_init is required before this function can be called. + * + * @remark After return, the generator state @p ctx must no longer be used with + * @c ocrypto_hmac_sha256_update and @c ocrypto_hmac_sha256_final unless it is + * reinitialized using @c ocrypto_hmac_sha256_init. + */ +void ocrypto_hmac_sha256_final(ocrypto_hmac_sha256_ctx * ctx, + uint8_t r[ocrypto_hmac_sha256_BYTES]); +/**@}*/ + + +/** + * HMAC-SHA256 algorithm. + * + * The input message @p in is authenticated using the key @p k. The computed + * authenticator is put into @p r. To verify the authenticator, the recipient + * needs to recompute the HMAC authenticator and can then compare it with the + * received authenticator. + * + * @param[out] r HMAC output. + * @param key HMAC key. + * @param key_len Length of @p key. 0 <= @p key_len <= @c ocrypto_hmac_sha256_KEY_BYTES_MAX. + * @param in Input data. + * @param in_len Length of @p in. + */ +void ocrypto_hmac_sha256( + uint8_t r[ocrypto_hmac_sha256_BYTES], + const uint8_t* key, size_t key_len, + const uint8_t* in, size_t in_len); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha512.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha512.h new file mode 100644 index 0000000..5c340f7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_hmac_sha512.h @@ -0,0 +1,171 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_hmac_512 HMAC APIs using SHA-512 + * @ingroup nrf_oberon_hmac + * @{ + * @brief Type declarations and APIs for the HMAC-SHA512 algorithm. + * + * HMAC-SHA512 is an algorithm for message authentication using the + * cryptographic hash function SHA512 and a reusable secret key. Users in + * possession of the key can verify the integrity and authenticity of the + * message. + * + * @see [RFC 2104 - HMAC: Keyed-Hashing for Message Authentication](http://tools.ietf.org/html/rfc2104) + */ + +#ifndef OCRYPTO_HMAC_SHA512_H +#define OCRYPTO_HMAC_SHA512_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "include/ocrypto_sha512.h" + +/** + * Maximum key length. + */ +#define ocrypto_hmac_sha512_KEY_BYTES_MAX (128) + +/** + * Length of the authenticator. + */ +#define ocrypto_hmac_sha512_BYTES (64) + +/**@cond */ +typedef struct +{ + ocrypto_sha512_ctx hash_ctx; + uint8_t ikey[ocrypto_hmac_sha512_KEY_BYTES_MAX]; + uint8_t okey[ocrypto_hmac_sha512_KEY_BYTES_MAX]; + uint8_t key[ocrypto_hmac_sha512_KEY_BYTES_MAX]; +} ocrypto_hmac_sha512_ctx; +/**@endcond */ + + +/**@name Incremental HMAC-SHA512 generator. + * + * This group of functions can be used to incrementally compute HMAC-SHA512 + * for a given message. + */ +/**@{*/ + + +/** + * HMAC-SHA512 initialization. + * + * The generator state @p ctx is initialized by this function. + * + * @param[out] ctx Generator state. + * @param key HMAC key. + * @param key_len Length of @p key. + */ +void ocrypto_hmac_sha512_init(ocrypto_hmac_sha512_ctx * ctx, + const uint8_t* key, size_t key_len); + +/** + * HMAC-SHA512 incremental data input. + * + * The generator state @p ctx is updated to hash a message chunk @p in. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param[in,out] ctx Generator state. + * @param in Input data. + * @param in_len Length of @p in. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_hmac_sha512_init is required before this function can be called. + */ +void ocrypto_hmac_sha512_update(ocrypto_hmac_sha512_ctx * ctx, + const uint8_t* in, size_t in_len); + +/** + * HMAC-SHA512 output. + * + * The generator state @p ctx is updated to finalize the HMAC calculation. + * The HMAC digest is put into @p r. + * + * @param[in,out] ctx Generator state. + * @param[out] r Generated HMAC digest. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_hmac_sha512_init is required before this function can be called. + * + * @remark After return, the generator state @p ctx must no longer be used with + * @c ocrypto_hmac_sha512_update and @c ocrypto_hmac_sha512_final unless it is + * reinitialized using @c ocrypto_hmac_sha512_init. + */ +void ocrypto_hmac_sha512_final(ocrypto_hmac_sha512_ctx * ctx, + uint8_t r[ocrypto_hmac_sha512_BYTES]); +/**@}*/ + + + +/** + * HMAC-SHA512 algorithm. + * + * The input message @p in is authenticated using the key @p k. The computed + * authenticator is put into @p r. To verify the authenticator, the recipient + * needs to recompute the HMAC authenticator and can then compare it with the + * received authenticator. + * + * @param[out] r HMAC output. + * @param key HMAC key. + * @param key_len Length of @p key. 0 <= @p key_len <= @c ocrypto_hmac_sha512_KEY_BYTES_MAX. + * @param in Input data. + * @param in_len Length of @p in. + */ +void ocrypto_hmac_sha512( + uint8_t r[ocrypto_hmac_sha512_BYTES], + const uint8_t* key, size_t key_len, + const uint8_t* in, size_t in_len); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa.h new file mode 100644 index 0000000..fb5a74c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa.h @@ -0,0 +1,643 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_rsa RSA - Rivest-Shamir-Adleman algorithm + * @ingroup nrf_oberon + * @{ + * @brief RSA is a number theoretic public-key encryption and signature algorithm. + * @} + * @defgroup nrf_oberon_rsa_api RSA APIs + * @ingroup nrf_oberon_rsa + * @{ + * @brief APIs to for RSA encryption/decryption and sign/verify using PKCS1 v1.5, OEAP and PSS. + * + * These functions support RSA encryption and signatures with 1024 and 2048-bit + * modulo and PKCS1 V1.5 padding. + */ + +#ifndef OCRYPTO_RSA_H +#define OCRYPTO_RSA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include "ocrypto_rsa_key.h" + + +/**@name 1024-bit RSA Functions. + * + * This group of functions is used for 1024-bit RSA. + */ +/**@{*/ +/** + * 1024 bit RSA PKCS1 V1.5 encryption. + * + * The message @p m is encrypted to a ciphertext returned in @p c. + * + * @param[out] c The generated 128-byte ciphertext. + * @param m The message to be encrypted. + * @param mlen Length of @p m. 0 <= mlen <= 117. + * @param seed The random seed to be used for the padding. + * @param slen Length of @p seed. @p slen >= 125 - @p mlen + * @param pk A valid 1024-bit RSA public key. + * + * @retval -1 If the message is too long (mlen > 117). + * @retval -2 If the seed is too short (slen < 125 - mlen). + * @retval 0 Otherwise. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa1024_init_pub_key. + * @remark The @p seed should consist of non-zero random bytes. + * @remark @p c and @p m can point to the same address. + */ +int ocrypto_rsa1024_pkcs1_v15_encrypt( + uint8_t c[128], + const uint8_t *m, size_t mlen, + const uint8_t *seed, size_t slen, + const ocrypto_rsa1024_pub_key *pk); + +/** + * 1024-bit RSA PKCS1 V1.5 decryption. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 128-byte ciphertext to decrypt. + * @param k A valid 1024-bit RSA secret key. + * + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa1024_pkcs1_v15_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[128], + const ocrypto_rsa1024_key *k); + +/** + * 1024-bit RSA PKCS1 V1.5 decryption with CRT acceleration. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 128-byte ciphertext to decrypt. + * @param k A valid 1024-bit RSA secret key with CRT coefficients. + * + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_crt_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa1024_pkcs1_v15_crt_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[128], + const ocrypto_rsa1024_crt_key *k); + +/** + * 1024-bit RSA OAEP SHA256 encryption. + * + * The message @p m is encrypted to a ciphertext returned in @p c. + * + * @param[out] c The generated 128-byte ciphertext. + * @param m The message to be encrypted. + * @param mlen Length of @p m. 0 <= mlen <= 62. + * @param label The label associated with the message. + * @param llen Length of @p label. May be 0. + * @param seed 32-byte random seed. + * @param pk A valid 1024-bit RSA public key. + * + * @retval -1 If the message is too long (mlen > 62). + * @retval 0 Otherwise. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa1024_init_pub_key. + * @remark @p c and @p m can point to the same address. + */ +int ocrypto_rsa1024_oaep_sha256_encrypt( + uint8_t c[128], + const uint8_t *m, size_t mlen, + const uint8_t *label, size_t llen, + const uint8_t seed[32], + const ocrypto_rsa1024_pub_key *pk); + +/** + * 1024-bit RSA OAEP SHA256 decryption. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 128-byte ciphertext to decrypt. + * @param label The label associated with the message. + * @param llen Length of @p label. May be 0. + * @param k A valid 1024-bit RSA secret key. + * + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa1024_oaep_sha256_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[128], + const uint8_t *label, size_t llen, + const ocrypto_rsa1024_key *k); + +/** + * 1024-bit RSA OAEP SHA256 decryption with CRT acceleration. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 128-byte ciphertext to decrypt. + * @param label The label associated with the message. + * @param llen Length of @p label. May be 0. + * @param k A valid 1024-bit RSA secret key with CRT coefficients. + * + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_crt_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa1024_oaep_sha256_crt_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[128], + const uint8_t *label, size_t llen, + const ocrypto_rsa1024_crt_key *k); + +/** + * 1024-bit RSA PKCS1 V1.5 SHA-256 sign. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 128-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param k A valid 1024-bit RSA secret key. + * + * @return 0 + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa1024_pkcs1_v15_sha256_sign( + uint8_t s[128], + const uint8_t *m, size_t mlen, + const ocrypto_rsa1024_key *k); + +/** + * 1024-bit RSA PKCS1 V1.5 SHA-256 sign with CRT acceleration. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 128-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param k A valid 1024-bit RSA secret key with CRT coefficients. + * + * @return 0 + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_crt_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa1024_pkcs1_v15_sha256_crt_sign( + uint8_t s[128], + const uint8_t *m, size_t mlen, + const ocrypto_rsa1024_crt_key *k); + +/** + * 1024-bit RSA PKCS1 V1.5 SHA-256 signature verify. + * + * The signature @p s is verified for a correct signature of message @p m. + * + * @param s The 128-byte signature. + * @param m The signed message. + * @param mlen Length of @p m. + * @param pk A valid 1024-bit RSA public key. + * + * @retval 0 If the signature is successfully verified. + * @retval -1 If verification failed. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa1024_init_pub_key. + */ +int ocrypto_rsa1024_pkcs1_v15_sha256_verify( + const uint8_t s[128], + const uint8_t *m, size_t mlen, + const ocrypto_rsa1024_pub_key *pk); + +/** + * 1024-bit RSA PSS SHA-256 sign. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 128-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param salt The salt to be used. + * @param slen Length of @p salt. + * @param k A valid 1024-bit RSA secret key. + * + * @retval -2 If the salt is too long. + * @retval 0 Otherwise. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa1024_pss_sha256_sign( + uint8_t s[128], + const uint8_t *m, size_t mlen, + const uint8_t *salt, size_t slen, + const ocrypto_rsa1024_key *k); + +/** + * 1024-bit RSA PSS SHA-256 sign with CRT acceleration. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 128-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param salt The salt to be used. + * @param slen Length of @p salt. + * @param k A valid 1024-bit RSA secret key with CRT coefficients. + * + * @retval -2 If the salt is too long. + * @retval 0 Otherwise. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa1024_init_crt_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa1024_pss_sha256_crt_sign( + uint8_t s[128], + const uint8_t *m, size_t mlen, + const uint8_t *salt, size_t slen, + const ocrypto_rsa1024_crt_key *k); + +/** + * 1024-bit RSA PSS SHA-256 signature verify. + * + * The signature @p s is verified for a correct signature of message @p m. + * + * @param s The 128-byte signature. + * @param m The signed message. + * @param mlen Length of @p m. + * @param slen The length of the salt. + * @param pk A valid 1024-bit RSA public key. + * + * @retval 0 If the signature is successfully verified. + * @retval -1 If verification failed. + * @retval -2 If the salt is too long. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa1024_init_pub_key. + */ +int ocrypto_rsa1024_pss_sha256_verify( + const uint8_t s[128], + const uint8_t *m, size_t mlen, + size_t slen, // salt length + const ocrypto_rsa1024_pub_key *pk); +/**@}*/ + + +/**@name 2048-bit RSA Functions. + * + * This group of functions is used for 2048-bit RSA. + */ +/**@{*/ +/** + * 2048-bit RSA PKCS1 V1.5 encryption. + * + * The message @p m is encrypted to a ciphertext returned in @p c. + * + * @param[out] c The generated 256-byte ciphertext. + * @param m The message to be encrypted. + * @param mlen Length of @p m. 0 <= @p mlen <= 245. + * @param seed The random seed to be used for the padding. + * @param slen Length of @p seed. @p slen >= 253 - @p mlen. + * @param pk A valid 2048-bit RSA public key. + * + * @retval -1 If the message is too long (mlen > 245). + * @retval -2 If the seed is too short (slen < 253 - mlen). + * @retval 0 Otherwise. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa2048_init_pub_key. + * @remark The @p seed should consist of non-zero random bytes. + * @remark @p c and @p m can point to the same address. + */ +int ocrypto_rsa2048_pkcs1_v15_encrypt( + uint8_t c[256], + const uint8_t *m, size_t mlen, + const uint8_t *seed, size_t slen, + const ocrypto_rsa2048_pub_key *pk); + +/** + * 2048-bit RSA PKCS1 V1.5 decryption. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 256-byte ciphertext to decrypt. + * @param k A valid 2048-bit RSA secret key. + + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa2048_pkcs1_v15_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[256], + const ocrypto_rsa2048_key *k); + +/** + * 2048-bit RSA PKCS1 V1.5 decryption with CRT acceleration. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 256-byte ciphertext to decrypt. + * @param k A valid 2048-bit RSA secret key with CRT coefficients. + + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_crt_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa2048_pkcs1_v15_crt_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[256], + const ocrypto_rsa2048_crt_key *k); + +/** + * 2048-bit RSA OAEP SHA256 encryption. + * + * The message @p m is encrypted to a ciphertext returned in @p c. + * + * @param[out] c The generated 256-byte ciphertext. + * @param m The message to be encrypted. + * @param mlen Length of @p m. 0 <= mlen <= 190. + * @param label The label associated with the message. + * @param llen Length of @p label. May be 0. + * @param seed 32-byte random seed. + * @param pk A valid 2048-bit RSA public key. + * + * @retval -1 If the message is too long (mlen > 190). + * @retval 0 Otherwise. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa2048_init_pub_key. + * @remark @p c and @p m can point to the same address. + */ +int ocrypto_rsa2048_oaep_sha256_encrypt( + uint8_t c[256], + const uint8_t *m, size_t mlen, + const uint8_t *label, size_t llen, + const uint8_t seed[32], + const ocrypto_rsa2048_pub_key *pk); + +/** + * 2048-bit RSA OAEP SHA256 decryption. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 256-byte ciphertext to decrypt. + * @param label The label associated with the message. + * @param llen Length of @p label. May be 0. + * @param k A valid 2048-bit RSA secret key. + * + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa2048_oaep_sha256_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[256], + const uint8_t *label, size_t llen, + const ocrypto_rsa2048_key *k); + +/** + * 2048-bit RSA OAEP SHA256 decryption with CRT acceleration. + * + * The ciphertext @p c is decrypted to the message returned in @p m. + * + * @param[out] m The decrypted message. The buffer must be long enough to hold the message. + * @param mlen Length of @p m. + * @param c The 256-byte ciphertext to decrypt. + * @param label The label associated with the message. + * @param llen Length of @p label. May be 0. + * @param k A valid 2048-bit RSA secret key with CRT coefficients. + * + * @retval -1 If decryption failed. + * @retval -2 If the output buffer is too short (mlen < length of message). + * @retval n If a message of length n was successfully decrypted. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_crt_key. + * @remark @p m and @p c can point to the same address. + */ +int ocrypto_rsa2048_oaep_sha256_crt_decrypt( + uint8_t *m, size_t mlen, + const uint8_t c[256], + const uint8_t *label, size_t llen, + const ocrypto_rsa2048_crt_key *k); + +/** + * 2048-bit RSA PKCS1 V1.5 SHA-256 sign. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 256-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param k A valid 2048-bit RSA secret key. + + * @returns 0 + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa2048_pkcs1_v15_sha256_sign( + uint8_t s[256], + const uint8_t *m, size_t mlen, + const ocrypto_rsa2048_key *k); + +/** + * 2048-bit RSA PKCS1 V1.5 SHA-256 sign with CRT acceleration. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 256-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param k A valid 2048-bit RSA secret key with CRT coefficients. + + * @returns 0 + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_crt_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa2048_pkcs1_v15_sha256_crt_sign( + uint8_t s[256], + const uint8_t *m, size_t mlen, + const ocrypto_rsa2048_crt_key *k); + +/** + * 2048-bit RSA PKCS1 V1.5 SHA-256 signature verify. + * + * The signature @p s is verified for a correct signature of message @p m. + * + * @param s The 256-byte signature. + * @param m The signed message. + * @param mlen Length of @p m. + * @param pk A valid 2048-bit RSA public key. + * + * @retval 0 If the signature is successfully verified. + * @retval -1 If verification failed. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa2048_init_pub_key. + */ +int ocrypto_rsa2048_pkcs1_v15_sha256_verify( + const uint8_t s[256], + const uint8_t *m, size_t mlen, + const ocrypto_rsa2048_pub_key *pk); + +/** + * 2048-bit RSA PSS SHA-256 sign. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 256-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param salt The salt to be used. + * @param slen Length of @p salt. + * @param k A valid 2048-bit RSA secret key. + * + * @retval -2 If the salt is too long. + * @retval 0 Otherwise. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa2048_pss_sha256_sign( + uint8_t s[256], + const uint8_t *m, size_t mlen, + const uint8_t *salt, size_t slen, + const ocrypto_rsa2048_key *k); + +/** + * 2048-bit RSA PSS SHA-256 sign with CRT acceleration. + * + * The message @p m is signed and the signature returned in @p s. + * + * @param[out] s The generated 256-byte signature. + * @param m The message to be signed. + * @param mlen Length of @p m. + * @param salt The salt to be used. + * @param slen Length of @p salt. + * @param k A valid 2048-bit RSA secret key with CRT coefficients. + * + * @retval -2 If the salt is too long. + * @retval 0 Otherwise. + * + * @remark The key @p k should be initialized with @c ocrypto_rsa2048_init_crt_key. + * @remark @p s and @p m can point to the same address. + */ +int ocrypto_rsa2048_pss_sha256_crt_sign( + uint8_t s[256], + const uint8_t *m, size_t mlen, + const uint8_t *salt, size_t slen, + const ocrypto_rsa2048_crt_key *k); + +/** + * 2048-bit RSA PSS SHA-256 signature verify. + * + * The signature @p s is verified for a correct signature of message @p m. + * + * @param s The 256-byte signature. + * @param m The signed message. + * @param mlen Length of @p m. + * @param slen The length of the salt. + * @param pk A valid 2048-bit RSA public key. + * + * @retval 0 If the signature is successfully verified. + * @retval -1 If verification failed. + * @retval -2 If the salt is too long. + * + * @remark The key @p pk should be initialized with @c ocrypto_rsa2048_init_pub_key. + */ +int ocrypto_rsa2048_pss_sha256_verify( + const uint8_t s[256], + const uint8_t *m, size_t mlen, + size_t slen, // salt length + const ocrypto_rsa2048_pub_key *pk); +/**@}*/ + + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa_key.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa_key.h new file mode 100644 index 0000000..8e2161a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_rsa_key.h @@ -0,0 +1,279 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_rsa_key RSA key APIs + * @ingroup nrf_oberon_rsa + * @{ + * @brief Type declarations for RSA APIs. + * + * RSA is a number theoretic public-key encryption and signature algorithm. + * + * These functions support the setup of 1024 and 4069 RSA secret and public keys. + */ + +#ifndef OCRYPTO_RSA_KEY_H +#define OCRYPTO_RSA_KEY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + +/** + * The Public RSA Exponent. + */ +#define PUB_EXP 65537 // 2^16 + 1 + + +/**@name 1024-bit RSA Keys + * + * This group of keys is used for 1024-bit RSA. + */ +/**@{*/ +/** + * 1024-bit RSA public key. + */ +/**@cond */ +typedef struct { + uint32_t n[32]; + // e = 65537 +} ocrypto_rsa1024_pub_key; +/**@endcond */ + +/** + * 1024 bit RSA secret key. + */ +/**@cond */ +typedef struct { + uint32_t n[32]; + uint32_t d[32]; // x^(e*d) mod n == x +} ocrypto_rsa1024_key; +/**@endcond */ + +/** + * 1024-bit RSA secret key with CRT coefficients. + */ +/**@cond */ +typedef struct { + uint32_t n[32]; + uint32_t p[16], q[16]; // primes, p*q = n + uint32_t dp[16], dq[16]; // d mod (p-1), d mod (q-1) + uint32_t qinv[16]; // 1/q mod p +} ocrypto_rsa1024_crt_key; +/**@endcond */ +/**@}*/ + + +/**@name 2048-bit RSA Keys + * + * This group of keys is used for 2048-bit RSA. + */ +/**@{*/ +/** + * 2048-bit RSA public key. + */ +/**@cond */ +typedef struct { + uint32_t n[64]; + // e = 65537 +} ocrypto_rsa2048_pub_key; +/**@endcond */ + +/** + * 2048-bit RSA secret key. + */ +/**@cond */ +typedef struct { + uint32_t n[64]; + uint32_t d[64]; // x^(e*d) mod n == x +} ocrypto_rsa2048_key; +/**@endcond */ + +/** + * 2048-bit RSA secret key with CRT coefficients. + */ +/**@cond */ +typedef struct { + uint32_t n[64]; + uint32_t p[32], q[32]; // primes, p*q = n + uint32_t dp[32], dq[32]; // d mod (p-1), d mod (q-1) + uint32_t qinv[32]; // 1/q mod p +} ocrypto_rsa2048_crt_key; +/**@endcond */ + +/**@name 1024-bit RSA key setup + * + * This group of functions is used for 1024-bit RSA key setup. + */ +/**@{*/ +/** + * 1024-bit RSA public key setup. + * + * @param[out] k The initialized public key. + * @param n The RSA modulus. Must be exactly 1024 bits. + * @param nlen Length of @p n. + * + * @retval -1 If the input length is not correct. + * @retval 0 Otherwise. + * + * @remark The public exponent is fixed at 65537. + */ +int ocrypto_rsa1024_init_pub_key( + ocrypto_rsa1024_pub_key *k, + const uint8_t *n, size_t nlen); + +/** + * 1024-bit RSA secret key setup. + * + * @param[out] k The initialized public key. + * @param n The RSA modulus. Must be exactly 1024 bits. + * @param nlen Length of @p n. + * @param d The secret exponent. Must be <= 1024 bits. + * @param dlen Length of @p d. + * + * @retval -1 If the input length is not correct. + * @retval 0 Otherwise. + */ +int ocrypto_rsa1024_init_key( + ocrypto_rsa1024_key *k, + const uint8_t *n, size_t nlen, + const uint8_t *d, size_t dlen); + +/** + * 1024-bit RSA secret key setup with CRT coefficients. + * + * @param[out] k The initialized secret key. + * @param p The 1. RSA prime. Must be exactly 512 bits. + * @param plen Length of @p p. + * @param q The 2. RSA prime. Must be exactly 512 bits. + * @param qlen Length of @p q. + * @param dp The 1. CRT exponent. dp = d mod (p-1). + * @param dplen Length of @p dp. + * @param dq The 2. CRT exponent. dq = d mod (q-1). + * @param dqlen Length of @p dq. + * @param qinv The CRT coefficient. qinv = 1/q mod p. + * @param qilen Length of @p qinv. + * + * @retval -1 If the input length is not correct. + * @retval 0 Otherwise. + */ +int ocrypto_rsa1024_init_crt_key( + ocrypto_rsa1024_crt_key *k, + const uint8_t *p, size_t plen, + const uint8_t *q, size_t qlen, + const uint8_t *dp, size_t dplen, + const uint8_t *dq, size_t dqlen, + const uint8_t *qinv, size_t qilen); +/**@}*/ + +/**@name 2048-bit RSA key setup + * + * This group of functions is used for 2048-bit RSA key setup. + */ +/**@{*/ +/** + * 2048-bit RSA public key setup. + * + * @param[out] k The initialized public key. + * @param n The RSA modulus. Must be exactly 2048 bits. + * @param nlen Length of @p n. + * + * @retval -1 If the input length is not correct + * @retval 0 Otherwise. + * + * @remark The public exponent is fixed at 65537. + */ +int ocrypto_rsa2048_init_pub_key( + ocrypto_rsa2048_pub_key *k, + const uint8_t *n, size_t nlen); + +/** + * 2048-bit RSA secret key setup. + * + * @param[out] k The initialized public key. + * @param n The RSA modulus. Must be exactly 2048 bits. + * @param nlen Length of @p n. + * @param d The secret exponent. Must be <= 2048 bits. + * @param dlen Length of @p d. + * + * @retval -1 If the input length is not correct. + * @retval 0 Otherwise. + */ +int ocrypto_rsa2048_init_key(ocrypto_rsa2048_key *k, + const uint8_t *n, size_t nlen, + const uint8_t *d, size_t dlen); + +/** + * 2048-bit RSA secret key setup with CRT coefficients. + * + * @param[out] k The initialized secret key. + * @param p The 1. RSA prime. Must be exactly 1024 bits. + * @param plen Length of @p p. + * @param q The 2. RSA prime. Must be exactly 1024 bits. + * @param qlen Length of @p q. + * @param dp The 1. CRT exponent. dp = d mod (p-1). + * @param dplen Length of @p dp. + * @param dq The 2. CRT exponent. dq = d mod (q-1). + * @param dqlen Length of @p dq. + * @param qinv The CRT coefficient. qinv = 1/q mod p. + * @param qilen Length of @p qinv. + * + * @retval -1 If the input length is not correct. + * @retval 0 Otherwise. + */ +int ocrypto_rsa2048_init_crt_key( + ocrypto_rsa2048_crt_key *k, + const uint8_t *p, size_t plen, + const uint8_t *q, size_t qlen, + const uint8_t *dp, size_t dplen, + const uint8_t *dq, size_t dqlen, + const uint8_t *qinv, size_t qilen); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha256.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha256.h new file mode 100644 index 0000000..d09f0f4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha256.h @@ -0,0 +1,155 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_sha_256 SHA-256 APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for the SHA-256 algorithm. + * + * SHA-256 is part of the SHA-2 family that is a set of cryptographic hash + * functions designed by the NSA. It is the successor of the SHA-1 algorithm. + * + * A fixed-sized message digest is computed from variable length input data. + * The function is practically impossible to revert, and small changes in the + * input message lead to major changes in the message digest. + */ + +#ifndef OCRYPTO_SHA256_H +#define OCRYPTO_SHA256_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * Length of SHA-256 hash. + */ +#define ocrypto_sha256_BYTES (32) + + +/**@cond */ +typedef struct { + uint32_t h[8]; + uint8_t padded[64]; + uint32_t length; + size_t bytes; +} ocrypto_sha256_ctx; +/**@endcond */ + + +/**@name Incremental SHA-256 generator + * + * This group of functions can be used to incrementally compute the SHA-256 + * hash for a given message. + */ +/**@{*/ +/** + * SHA-256 initialization. + * + * The generator state @p ctx is initialized by this function. + * + * @param[out] ctx Generator state. + */ +void ocrypto_sha256_init( + ocrypto_sha256_ctx *ctx); + +/** + * SHA-256 incremental data input. + * + * The generator state @p ctx is updated to hash a message chunk @p in. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param ctx Generator state. + * @param in Input data. + * @param in_len Length of @p in. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_sha256_init is required before this function can be called. + */ +void ocrypto_sha256_update( + ocrypto_sha256_ctx *ctx, + const uint8_t *in, size_t in_len); + +/** + * SHA-256 output. + * + * The generator state @p ctx is updated to finalize the hash for the previously + * processed message chunks. The hash is put into @p r. + * + * @param ctx Generator state. + * @param[out] r Generated hash value. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_sha256_init is required before this function can be called. + * + * @remark After return, the generator state @p ctx must no longer be used with + * @c ocrypto_sha256_update and @c ocrypto_sha256_final unless it is + * reinitialized using @c ocrypto_sha256_init. + */ +void ocrypto_sha256_final( + ocrypto_sha256_ctx *ctx, + uint8_t r[ocrypto_sha256_BYTES]); +/**@}*/ + +/** + * SHA-256 hash. + * + * The SHA-256 hash of a given input message @p in is computed and put into @p r. + * + * @param[out] r Generated hash. + * @param in Input data. + * @param in_len Length of @p in. + */ +void ocrypto_sha256( + uint8_t r[ocrypto_sha256_BYTES], + const uint8_t *in, size_t in_len); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha512.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha512.h new file mode 100644 index 0000000..ec16bb0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_sha512.h @@ -0,0 +1,155 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_sha_512 SHA-512 APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for the SHA-512 algorithm. + * + * SHA-512 is part of the SHA-2 family that is a set of cryptographic hash + * functions designed by the NSA. It is the successor of the SHA-1 algorithm. + * + * A fixed-sized message digest is computed from variable length input data. + * The function is practically impossible to revert, and small changes in the + * input message lead to major changes in the message digest. + */ + +#ifndef OCRYPTO_SHA512_H +#define OCRYPTO_SHA512_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * Length of SHA-512 hash. + */ +#define ocrypto_sha512_BYTES (64) + + +/**@cond */ +typedef struct { + uint64_t h[8]; + uint8_t padded[128]; + uint32_t length; + size_t bytes; +} ocrypto_sha512_ctx; +/**@endcond */ + + +/**@name Incremental SHA-512 generator + * + * This group of functions can be used to incrementally compute the SHA-512 + * hash for a given message. + */ +/**@{*/ +/** + * SHA-512 initialization. + * + * The generator state @p ctx is initialized by this function. + * + * @param[out] ctx Generator state. + */ +void ocrypto_sha512_init( + ocrypto_sha512_ctx *ctx); + +/** + * SHA-512 incremental data input. + * + * The generator state @p ctx is updated to hash a message chunk @p in. + * + * This function can be called repeatedly until the whole message is processed. + * + * @param ctx Generator state. + * @param in Input data. + * @param in_len Length of @p in. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_sha512_init is required before this function can be called. + */ +void ocrypto_sha512_update( + ocrypto_sha512_ctx *ctx, + const uint8_t *in, size_t in_len); + +/** + * SHA-512 output. + * + * The generator state @p ctx is updated to finalize the hash for the previously + * processed message chunks. The hash is put into @p r. + * + * @param ctx Generator state. + * @param[out] r Generated hash value. + * + * @remark Initialization of the generator state @p ctx through + * @c ocrypto_sha512_init is required before this function can be called. + * + * @remark After return, the generator state @p ctx must no longer be used with + * @c ocrypto_sha512_update and @c ocrypto_sha512_final unless it is + * reinitialized using @c ocrypto_sha512_init. + */ +void ocrypto_sha512_final( + ocrypto_sha512_ctx *ctx, + uint8_t r[ocrypto_sha512_BYTES]); +/**@}*/ + +/** + * SHA-512 hash. + * + * The SHA-512 hash of a given input message @p in is computed and put into @p r. + * + * @param[out] r Generated hash. + * @param in Input data. + * @param in_len Length of @p in. + */ +void ocrypto_sha512( + uint8_t r[ocrypto_sha512_BYTES], + const uint8_t *in, size_t in_len); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srp.h new file mode 100644 index 0000000..7fbcf74 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srp.h @@ -0,0 +1,311 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_srp SRP - Secure Remote Password APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for the SRP key agreement protocol. + * + * SRP is an augmented password-authenticated key agreement protocol, + * specifically designed to work around existing patents. SRP allows the use of + * user names and passwords over unencrypted channels and supplies a shared + * secret at the end of the authentication sequence that can be used to generate + * encryption keys. + * + * An eavesdropper or man in the middle cannot obtain enough information to be + * able to brute force guess a password without further interactions with the + * parties for each guess. + * + * The server does not store password-equivalent data. This means that an + * attacker who steals the server data cannot masquerade as the client unless + * they first perform a brute force search for the password. + * + * The specific variant implemented here is SRP-6 3072 bit SHA-512. + * + * @see [RFC 5054 - Using the Secure Remote Password (SRP) Protocol for TLS Authentication](https://tools.ietf.org/html/rfc5054) + * @see [The Stanford SRP Homepage](http://srp.stanford.edu) + * + * **Basic protocol overview** + * + * *Setup* + * 1. Server generates a username / password combination together with a salt. + * 2. Server derives a password verifier (see #ocrypto_srp_verifier). + * 3. The username, salt and verifier are stored and required to open sessions. + * The original password is no longer needed. + * + * *Session opening* + * 1. Client sends a username and the public key of an ephemeral key pair to the + * server. + * 2. Server sends the salt and the public key of another ephemeral key pair to + * the client (see #ocrypto_srp_public_key). + * 3. Client and Server both compute the session key from this information (see + * #ocrypto_srp_scrambling_parameter, #ocrypto_srp_premaster_secret, + * #ocrypto_srp_session_key). + * 4. Client sends proof of the session key to the server. + * 5. Server validates proof (see #ocrypto_srp_proof_m1), then sends proof of the + * session key to the client (see #ocrypto_srp_proof_m2). + * 6. Client validates proof. Both parties know that they share the same private + * session key. + */ + +#ifndef OCRYPTO_SRP_H +#define OCRYPTO_SRP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * Salt length. + */ +#define ocrypto_srp_SALT_BYTES (16) + +/** + * Password verifier length. + */ +#define ocrypto_srp_VERIFIER_BYTES (384) + +/** + * Secret key length. + */ +#define ocrypto_srp_SECRET_KEY_BYTES (32) + +/** + * Public key length. + */ +#define ocrypto_srp_PUBLIC_KEY_BYTES (384) + +/** + * Scrambling parameter length. + */ +#define ocrypto_srp_SCRAMBLING_PARAMETER_BYTES (64) + +/** + * Premaster secret length. + */ +#define ocrypto_srp_PREMASTER_SECRET_BYTES (384) + +/** + * Session key length. + */ +#define ocrypto_srp_SESSION_KEY_BYTES (64) + +/** + * Proof length. + */ +#define ocrypto_srp_PROOF_BYTES (64) + + +/**@name SRP-6 Password verifier generation + * + * A password verifier is generated from a user name and a password. The + * password @p pass may be discarded, as only the verifier is used during later + * computations. + */ +/**@{*/ +/** + * SRP-6 Password Verifier. + * + * The verifier is generated for a given user name @p user, a password @p pass + * and salt @p salt. + * + * @param[out] v Generated password verifier, must be 32-bit aligned. + * @param salt Salt. + * @param user User name. + * @param user_len Length of @p user. + * @param pass Password. + * @param pass_len Length of @p pass. + */ +void ocrypto_srp_verifier( + uint8_t v[ocrypto_srp_VERIFIER_BYTES], + const uint8_t salt[ocrypto_srp_SALT_BYTES], + const uint8_t *user, size_t user_len, + const uint8_t *pass, size_t pass_len); +/**@}*/ + +/**@name SRP-6 Public key generation + * + * An ephemeral keypair can be generated based on the password verifier to be + * used when opening a new session. + */ +/**@{*/ +/** + * SRP-6 Public Key. + * + * The public key for a given private key @p priv_b is generated using the + * password verifier @p v and put into @p pub_b. + * + * @param[out] pub_b Generated public key, must be 32-bit aligned. + * @param priv_b Private key. + * @param v Password verifier. + */ +void ocrypto_srp_public_key( + uint8_t pub_b[ocrypto_srp_PUBLIC_KEY_BYTES], + const uint8_t priv_b[ocrypto_srp_SECRET_KEY_BYTES], + const uint8_t v[ocrypto_srp_VERIFIER_BYTES]); +/**@}*/ + +/**@name SRP-6 Session key generation + * + * A premaster secret can be derived from both the client's and server's public + * keys, the server's private key and the password verifier. A shared session + * key can be generated from this premaster secret. + */ +/**@{*/ +/** + * SRP-6 Scrambling Parameter. + * + * The scrambling parameter is computed from both the client's public key + * @p pub_a and the server's public key @p pub_b. The scrambling parameter + * is required to compute the premaster secret. + * + * @param[out] u Generated scrambling parameter. + * @param pub_a Client public key. + * @param pub_b Server public key. + */ +void ocrypto_srp_scrambling_parameter( + uint8_t u[ocrypto_srp_SCRAMBLING_PARAMETER_BYTES], + const uint8_t pub_a[ocrypto_srp_PUBLIC_KEY_BYTES], + const uint8_t pub_b[ocrypto_srp_PUBLIC_KEY_BYTES]); + +/** + * SRP-6 Premaster Secret. + * + * The premaster secret between the client and the server is computed using the + * client public key @p pub_a, the server private key @p priv_b, the scrambling + * parameter @p u and the password verifier @p v. If the client public key + * @p pub_a is valid, the premaster secret is then put into @p s. The premaster + * secret can be used to generate encryption keys. + * + * @param[out] s Generated premaster secret, must be 32-bit aligned. + * @param pub_a Client public key. + * @param priv_b Server private key. + * @param u Scrambling parameter; generated with @c srp_scrambling_parameter. + * @param v Password verifier. + * + * @retval 0 If @p pub_a is a legal public key. + * @retval 1 Otherwise. + */ +int ocrypto_srp_premaster_secret( + uint8_t s[ocrypto_srp_PREMASTER_SECRET_BYTES], + const uint8_t pub_a[ocrypto_srp_PUBLIC_KEY_BYTES], + const uint8_t priv_b[ocrypto_srp_SECRET_KEY_BYTES], + const uint8_t u[ocrypto_srp_SCRAMBLING_PARAMETER_BYTES], + const uint8_t v[ocrypto_srp_VERIFIER_BYTES]); + +/** + * SRP-6 SRP Session Key. + * + * Generates the shared SRP session key from the premaster secret @p s and puts + * it into @p k. + * + * @param[out] k Generated SRP session key. + * @param s Premaster secret. + */ +void ocrypto_srp_session_key( + uint8_t k[ocrypto_srp_SESSION_KEY_BYTES], + const uint8_t s[ocrypto_srp_PREMASTER_SECRET_BYTES]); +/**@}*/ + +/**@name SRP-6 Proof exchange + * + * Proofs are exchanged from client to server and vice versa to ensure that both + * parties computed the same shared session key. The proofs only match if the + * correct password is used by the client. + */ +/**@{*/ +/** + * SRP-6 Proof M1 (client to server). + * + * A proof is generated by the client and sent to the server to assert that the + * client is in possession of the shared session key @p k. The server also + * generates the proof. Only if the proofs match, the process can continue. + * The proof is based on the salt @p salt, the client public key @p pub_a, + * the server public key @p pub_b and the shared session key @p k. + * + * @param[out] m1 Generated proof. + * @param user User name. + * @param user_len Length of @p user. + * @param salt Salt. + * @param pub_a Client public key. + * @param pub_b Server public key. + * @param k Session key. + */ +void ocrypto_srp_proof_m1( + uint8_t m1[ocrypto_srp_PROOF_BYTES], + const uint8_t *user, size_t user_len, + const uint8_t salt[ocrypto_srp_SALT_BYTES], + const uint8_t pub_a[ocrypto_srp_PUBLIC_KEY_BYTES], + const uint8_t pub_b[ocrypto_srp_PUBLIC_KEY_BYTES], + const uint8_t k[ocrypto_srp_SESSION_KEY_BYTES]); + +/** + * SRP-6 Proof M2 (server to client). + * + * A second proof is generated by the server and sent back to the client to + * assert that the server is in possession of the shared session key @p k. The + * client also generates the proof. If the proofs match, both parties can assume + * that they share the same session key @p k. The second proof is based on the + * client public key @p pub_a, the first proof @p m1 and the session key @p k. + * + * @param[out] m2 Generated proof. + * @param pub_a Client public key. + * @param m1 First proof. Generated with @c srp_proof_m1. + * @param k Session key. + */ +void ocrypto_srp_proof_m2( + uint8_t m2[ocrypto_srp_PROOF_BYTES], + const uint8_t pub_a[ocrypto_srp_PUBLIC_KEY_BYTES], + const uint8_t m1[ocrypto_srp_PROOF_BYTES], + const uint8_t k[ocrypto_srp_SESSION_KEY_BYTES]); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srtp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srtp.h new file mode 100644 index 0000000..31c748c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/include/ocrypto_srtp.h @@ -0,0 +1,205 @@ +/** + * Copyright (c) 2019, 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 nrf_oberon_srpt SRPT - Secure Real-Time Transport Protocol APIs + * @ingroup nrf_oberon + * @{ + * @brief Type declarations and APIs for SRTP - Secure Real-time Transport Protocol. + */ + +#ifndef OCRYPTO_SRTP_H +#define OCRYPTO_SRTP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include "ocrypto_aes_key.h" + +/** + * SRTP Authentication Key Size. + */ +#define ocrypto_srtp_AuthKeySize (20) + +/** + * SRTP Salt Size. + */ +#define ocrypto_srtp_SaltSize (14) + +/** + * SRTP Maximum Key Size. + */ +#define ocrypto_srtp_MaxKeySize (ocrypto_aes256_KEY_BYTES) + +/** + * SRTP Context. + */ +typedef struct { + /** + * Key size [bytes]. + */ + uint32_t keySize; + + /** + * Tag size [bytes]. + */ + uint32_t tagSize; + + /** + * Session encryption key (max 256 bits). + */ + uint8_t encrKey[ocrypto_srtp_MaxKeySize]; + + /** + * Session authentication key + * 160 bits. + */ + uint8_t authKey[ocrypto_srtp_AuthKeySize]; + + /** + * Session salt + * 112 bits. + */ + uint8_t saltKey[ocrypto_srtp_SaltSize]; +} ocrypto_srtp_context; + +/** + * Set up SRTP contexts. + * + * @param[out] srtpContext SRTP context to be set up. + * @param[out] srtcpContext SRTCP context to be set up. + * @param key Master key. + * @param keySize Size of the master key (16, 24, or 32 bytes) + * @param salt Master salt. + * @param tagSize Size of the authentication tag. + * @param ssrc Synchronization source. + */ +void ocrypto_srtp_setupContext( + ocrypto_srtp_context *srtpContext, + ocrypto_srtp_context *srtcpContext, + const uint8_t *key, + uint32_t keySize, + const uint8_t *salt, + uint32_t tagSize, + uint32_t ssrc); + +/** + * Encrypt SRTP packet. + * + * The final packet consists of @p numHeaderBytes encrytped in place, followed + * by @p numDataBytes copied from @p dataBytes during encryption. + * + * @param srtpContext SRTP context. + * @param[in,out] packet Encrypted packet. + * @param dataBytes Data bytes to be encrypted. + * @param numHeaderBytes Number of header bytes. + * @param numDataBytes Number of data bytes. + * @param index Packet index. + */ +void ocrypto_srtp_encrypt( + const ocrypto_srtp_context *srtpContext, + uint8_t *packet, + const uint8_t *dataBytes, + size_t numHeaderBytes, + size_t numDataBytes, + uint32_t index); + +/** + * Decrypt SRTP packet. + * + * @param srtpContext SRTP context. + * @param[out] data Decrypted data. + * @param packetBytes Packet bytes. + * @param numPacketBytes Number of packet bytes. + * @param index Packet index. + */ +void ocrypto_srtp_decrypt( + const ocrypto_srtp_context *srtpContext, + uint8_t *data, + const uint8_t *packetBytes, + size_t numPacketBytes, + uint32_t index); + +/** + * Generate SRTP authentication tag from bytes and index. + * + * @param context SRTP context. + * @param[out] tag Authentication tag generated. + * @param bytes Byte buffer. + * @param numBytes Number of bytes in buffer. + * @param index Index. + */ +void ocrypto_srtp_authenticate( + const ocrypto_srtp_context *context, + uint8_t *tag, + const uint8_t *bytes, + size_t numBytes, + uint32_t index); + +/** + * Check SRTP authentication tag against bytes and index. + * + * @param context SRTP context. + * @param tag Tag. + * @param bytes Byte buffer. + * @param numBytes Number of bytes in buffer. + * @param index Index. + * + * @retval 1 If the tag is valid. + * @retval 0 Otherwise. + */ +int ocrypto_srtp_verifyAuthentication( + ocrypto_srtp_context *context, + const uint8_t *tag, + const uint8_t *bytes, + size_t numBytes, + uint32_t index); + +#ifdef __cplusplus +} +#endif + +#endif + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/lib/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/lib/license.txt new file mode 100644 index 0000000..81a8b7b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/lib/license.txt @@ -0,0 +1,37 @@ +Copyright (c) 2016 - 2019, 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. + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/license.txt new file mode 100644 index 0000000..81a8b7b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_oberon/license.txt @@ -0,0 +1,37 @@ +Copyright (c) 2016 - 2019, 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. + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/dtls/config/nrf_dtls_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/dtls/config/nrf_dtls_config.h new file mode 100644 index 0000000..b6c5d11 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/dtls/config/nrf_dtls_config.h @@ -0,0 +1,2477 @@ +/** + * \file nrf_dtls_config.h + * + * \brief Configuration options (set of defines) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2015 Nordic Semiconductor ASA, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* + * This set of compile-time options may be used to enable + * or disable features selectively, and reduce the global + * memory footprint. + */ +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +/** + * \name SECTION: System support + * + * This section sets system specific settings. + * \{ + */ + +/** + * \def MBEDTLS_HAVE_ASM + * + * The compiler has support for asm(). + * + * Requires support for asm() in compiler. + * + * Used in: + * library/timing.c + * library/padlock.c + * include/mbedtls/bn_mul.h + * + * Comment to disable the use of assembly code. + */ +//#define MBEDTLS_HAVE_ASM + +/** + * \def MBEDTLS_HAVE_SSE2 + * + * CPU supports SSE2 instruction set. + * + * Uncomment if the CPU supports SSE2 (IA-32 specific). + */ +//#define MBEDTLS_HAVE_SSE2 + +/** + * \def MBEDTLS_HAVE_TIME + * + * System has time.h and time(). + * The time does not need to be correct, only time differences are used, + * by contrast with MBEDTLS_HAVE_TIME_DATE + * + * Comment if your system does not support time functions + */ +//#define MBEDTLS_HAVE_TIME + +/** + * \def MBEDTLS_HAVE_TIME_DATE + * + * System has time.h and time(), gmtime() and the clock is correct. + * The time needs to be correct (not necesarily very accurate, but at least + * the date should be correct). This is used to verify the validity period of + * X.509 certificates. + * + * Comment if your system does not have a correct clock. + */ +//#define MBEDTLS_HAVE_TIME_DATE + +/** + * \def MBEDTLS_PLATFORM_MEMORY + * + * Enable the memory allocation layer. + * + * By default mbed TLS uses the system-provided calloc() and free(). + * This allows different allocators (self-implemented or provided) to be + * provided to the platform abstraction layer. + * + * Enabling MBEDTLS_PLATFORM_MEMORY without the + * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide + * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and + * free() function pointer at runtime. + * + * Enabling MBEDTLS_PLATFORM_MEMORY and specifying + * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the + * alternate function at compile time. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Enable this layer to allow use of alternative memory allocators. + */ +#define MBEDTLS_PLATFORM_MEMORY + +/** + * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + * + * Do not assign standard functions in the platform layer (e.g. calloc() to + * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) + * + * This makes sure there are no linking errors on platforms that do not support + * these functions. You will HAVE to provide alternatives, either at runtime + * via the platform_set_xxx() functions or at compile time by setting + * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a + * MBEDTLS_PLATFORM_XXX_MACRO. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Uncomment to prevent default assignment of standard functions in the + * platform layer. + */ +#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + +/** + * \def MBEDTLS_PLATFORM_XXX_ALT + * + * Uncomment a macro to let mbed TLS support the function in the platform + * abstraction layer. + * + * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will + * provide a function "mbedtls_platform_set_printf()" that allows you to set an + * alternative printf function pointer. + * + * All these define require MBEDTLS_PLATFORM_C to be defined! + * + * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; + * it will be enabled automatically by check_config.h + * + * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as + * MBEDTLS_PLATFORM_XXX_MACRO! + * + * Uncomment a macro to enable alternate implementation of specific base + * platform function + */ +//#define MBEDTLS_PLATFORM_EXIT_ALT +//#define MBEDTLS_PLATFORM_FPRINTF_ALT +//#define MBEDTLS_PLATFORM_PRINTF_ALT +//#define MBEDTLS_PLATFORM_SNPRINTF_ALT + +/** + * \def MBEDTLS_DEPRECATED_WARNING + * + * Mark deprecated functions so that they generate a warning if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * This only works with GCC and Clang. With other compilers, you may want to + * use MBEDTLS_DEPRECATED_REMOVED + * + * Uncomment to get warnings on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_WARNING + +/** + * \def MBEDTLS_DEPRECATED_REMOVED + * + * Remove deprecated functions so that they generate an error if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * Uncomment to get errors on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_REMOVED + +/* \} name SECTION: System support */ + +/** + * \name SECTION: mbed TLS feature support + * + * This section sets support for features that are or are not needed + * within the modules that are enabled. + * \{ + */ + +/** + * \def MBEDTLS_TIMING_ALT + * + * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), + * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() + * + * Only works if you have MBEDTLS_TIMING_C enabled. + * + * You will need to provide a header "timing_alt.h" and an implementation at + * compile time. + */ +//#define MBEDTLS_TIMING_ALT + +/** + * \def MBEDTLS__MODULE_NAME__ALT + * + * Uncomment a macro to let mbed TLS use your alternate core implementation of + * a symmetric crypto or hash module (e.g. platform specific assembly + * optimized implementations). Keep in mind that the function prototypes + * should remain the same. + * + * This replaces the whole module. If you only want to replace one of the + * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer + * provide the "struct mbedtls_aes_context" definition and omit the base function + * declarations and implementations. "aes_alt.h" will be included from + * "aes.h" to include the new function definitions. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * module. + */ +//#define MBEDTLS_AES_ALT +//#define MBEDTLS_ARC4_ALT +//#define MBEDTLS_BLOWFISH_ALT +//#define MBEDTLS_CAMELLIA_ALT +//#define MBEDTLS_DES_ALT +//#define MBEDTLS_XTEA_ALT +//#define MBEDTLS_MD2_ALT +//#define MBEDTLS_MD4_ALT +//#define MBEDTLS_MD5_ALT +//#define MBEDTLS_RIPEMD160_ALT +//#define MBEDTLS_SHA1_ALT +//#define MBEDTLS_SHA256_ALT +//#define MBEDTLS_SHA512_ALT + +/** + * \def MBEDTLS__FUNCTION_NAME__ALT + * + * Uncomment a macro to let mbed TLS use you alternate core implementation of + * symmetric crypto or hash function. Keep in mind that function prototypes + * should remain the same. + * + * This replaces only one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will + * no longer provide the mbedtls_sha1_process() function, but it will still provide + * the other function (using your mbedtls_sha1_process() function) and the definition + * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible + * with this definition. + * + * Note: if you use the AES_xxx_ALT macros, then is is recommended to also set + * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES + * tables. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + */ +//#define MBEDTLS_MD2_PROCESS_ALT +//#define MBEDTLS_MD4_PROCESS_ALT +//#define MBEDTLS_MD5_PROCESS_ALT +//#define MBEDTLS_RIPEMD160_PROCESS_ALT +//#define MBEDTLS_SHA1_PROCESS_ALT +//#define MBEDTLS_SHA256_PROCESS_ALT +//#define MBEDTLS_SHA512_PROCESS_ALT +//#define MBEDTLS_DES_SETKEY_ALT +//#define MBEDTLS_DES_CRYPT_ECB_ALT +//#define MBEDTLS_DES3_CRYPT_ECB_ALT +//#define MBEDTLS_AES_SETKEY_ENC_ALT +//#define MBEDTLS_AES_SETKEY_DEC_ALT +//#define MBEDTLS_AES_ENCRYPT_ALT +//#define MBEDTLS_AES_DECRYPT_ALT + +/** + * \def MBEDTLS_ENTROPY_HARDWARE_ALT + * + * Uncomment this macro to let mbed TLS use your own implementation of a + * hardware entropy collector. + * + * Your function must be called \c mbedtls_hardware_poll(), have the same + * prototype as declared in entropy_poll.h, and accept NULL as first argument. + * + * Uncomment to use your own hardware entropy collector. + */ +//#define MBEDTLS_ENTROPY_HARDWARE_ALT + +/** + * \def MBEDTLS_AES_ROM_TABLES + * + * Store the AES tables in ROM. + * + * Uncomment this macro to store the AES tables in ROM. + */ +#define MBEDTLS_AES_ROM_TABLES + +/** + * \def MBEDTLS_CAMELLIA_SMALL_MEMORY + * + * Use less ROM for the Camellia implementation (saves about 768 bytes). + * + * Uncomment this macro to use less memory for Camellia. + */ +//#define MBEDTLS_CAMELLIA_SMALL_MEMORY + +/** + * \def MBEDTLS_CIPHER_MODE_CBC + * + * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. + */ +//#define MBEDTLS_CIPHER_MODE_CBC + +/** + * \def MBEDTLS_CIPHER_MODE_CFB + * + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. + */ +//#define MBEDTLS_CIPHER_MODE_CFB + +/** + * \def MBEDTLS_CIPHER_MODE_CTR + * + * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. + */ +//#define MBEDTLS_CIPHER_MODE_CTR + +/** + * \def MBEDTLS_CIPHER_NULL_CIPHER + * + * Enable NULL cipher. + * Warning: Only do so when you know what you are doing. This allows for + * encryption or channels without any security! + * + * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable + * the following ciphersuites: + * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA + * + * Uncomment this macro to enable the NULL cipher and ciphersuites + */ +//#define MBEDTLS_CIPHER_NULL_CIPHER + +/** + * \def MBEDTLS_CIPHER_PADDING_XXX + * + * Uncomment or comment macros to add support for specific padding modes + * in the cipher layer with cipher modes that support padding (e.g. CBC) + * + * If you disable all padding modes, only full blocks can be used with CBC. + * + * Enable padding modes in the cipher layer. + */ +#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#define MBEDTLS_CIPHER_PADDING_ZEROS + +/** + * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES + * + * Enable weak ciphersuites in SSL / TLS. + * Warning: Only do so when you know what you are doing. This allows for + * channels with virtually no security at all! + * + * This enables the following ciphersuites: + * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA + * + * Uncomment this macro to enable weak ciphersuites + */ +//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES + +/** + * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES + * + * Remove RC4 ciphersuites by default in SSL / TLS. + * This flag removes the ciphersuites based on RC4 from the default list as + * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to + * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them + * explicitly. + * + * Uncomment this macro to remove RC4 ciphersuites by default. + */ +#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES + +/** + * \def MBEDTLS_ECP_XXXX_ENABLED + * + * Enables specific curves within the Elliptic Curve module. + * By default all supported curves are enabled. + * + * Comment macros to disable the curve and functions for it + */ +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#define MBEDTLS_ECP_DP_BP512R1_ENABLED +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED + +/** + * \def MBEDTLS_ECP_NIST_OPTIM + * + * Enable specific 'modulo p' routines for each NIST prime. + * Depending on the prime and architecture, makes operations 4 to 8 times + * faster on the corresponding curve. + * + * Comment this macro to disable NIST curves optimisation. + */ +//#define MBEDTLS_ECP_NIST_OPTIM + +/** + * \def MBEDTLS_ECDSA_DETERMINISTIC + * + * Enable deterministic ECDSA (RFC 6979). + * Standard ECDSA is "fragile" in the sense that lack of entropy when signing + * may result in a compromise of the long-term signing key. This is avoided by + * the deterministic variant. + * + * Requires: MBEDTLS_HMAC_DRBG_C + * + * Comment this macro to disable deterministic ECDSA. + */ +//#define MBEDTLS_ECDSA_DETERMINISTIC + +/** + * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + * + * Enable the PSK based ciphersuite modes in SSL / TLS. + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + * + * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + * + * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + * + * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + * + * Enable the RSA-only based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + */ +//#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + * + * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + * + * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + * + * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + * + * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + * + * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + * + * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Requires: MBEDTLS_ECJPAKE_C + * MBEDTLS_SHA256_C + * MBEDTLS_ECP_DP_SECP256R1_ENABLED + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + +/** + * \def MBEDTLS_PK_PARSE_EC_EXTENDED + * + * Enhance support for reading EC keys using variants of SEC1 not allowed by + * RFC 5915 and RFC 5480. + * + * Currently this means parsing the SpecifiedECDomain choice of EC + * parameters (only known groups are supported, not arbitrary domains, to + * avoid validation issues). + * + * Disable if you only need to support RFC 5915 + 5480 key formats. + */ +//#define MBEDTLS_PK_PARSE_EC_EXTENDED + +/** + * \def MBEDTLS_ERROR_STRERROR_DUMMY + * + * Enable a dummy error function to make use of mbedtls_strerror() in + * third party libraries easier when MBEDTLS_ERROR_C is disabled + * (no effect when MBEDTLS_ERROR_C is enabled). + * + * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're + * not using mbedtls_strerror() or error_strerror() in your application. + * + * Disable if you run into name conflicts and want to really remove the + * mbedtls_strerror() + */ +#define MBEDTLS_ERROR_STRERROR_DUMMY + +/** + * \def MBEDTLS_GENPRIME + * + * Enable the prime-number generation code. + * + * Requires: MBEDTLS_BIGNUM_C + */ +#define MBEDTLS_GENPRIME + +/** + * \def MBEDTLS_FS_IO + * + * Enable functions that use the filesystem. + */ +//#define MBEDTLS_FS_IO + +/** + * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + * + * Do not add default entropy sources. These are the platform specific, + * mbedtls_timing_hardclock and HAVEGE based poll functions. + * + * This is useful to have more control over the added entropy sources in an + * application. + * + * Uncomment this macro to prevent loading of default entropy functions. + */ +#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + +/** + * \def MBEDTLS_NO_PLATFORM_ENTROPY + * + * Do not use built-in platform entropy functions. + * This is useful if your platform does not support + * standards like the /dev/urandom or Windows CryptoAPI. + * + * Uncomment this macro to disable the built-in platform entropy functions. + */ +#define MBEDTLS_NO_PLATFORM_ENTROPY + +/** + * \def MBEDTLS_ENTROPY_FORCE_SHA256 + * + * Force the entropy accumulator to use a SHA-256 accumulator instead of the + * default SHA-512 based one (if both are available). + * + * Requires: MBEDTLS_SHA256_C + * + * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option + * if you have performance concerns. + * + * This option is only useful if both MBEDTLS_SHA256_C and + * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. + */ +//#define MBEDTLS_ENTROPY_FORCE_SHA256 + +/** + * \def MBEDTLS_MEMORY_DEBUG + * + * Enable debugging of buffer allocator memory issues. Automatically prints + * (to stderr) all (fatal) messages on memory allocation issues. Enables + * function for 'debug output' of allocated memory. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Uncomment this macro to let the buffer allocator print out error messages. + */ +//#define MBEDTLS_MEMORY_DEBUG + +/** + * \def MBEDTLS_MEMORY_BACKTRACE + * + * Include backtrace information with each allocated block. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * GLIBC-compatible backtrace() an backtrace_symbols() support + * + * Uncomment this macro to include backtrace information + */ +//#define MBEDTLS_MEMORY_BACKTRACE + +/** + * \def MBEDTLS_PK_RSA_ALT_SUPPORT + * + * Support external private RSA keys (eg from a HSM) in the PK layer. + * + * Comment this macro to disable support for external private RSA keys. + */ +//#define MBEDTLS_PK_RSA_ALT_SUPPORT + +/** + * \def MBEDTLS_PKCS1_V15 + * + * Enable support for PKCS#1 v1.5 encoding. + * + * Requires: MBEDTLS_RSA_C + * + * This enables support for PKCS#1 v1.5 operations. + */ +//#define MBEDTLS_PKCS1_V15 + +/** + * \def MBEDTLS_PKCS1_V21 + * + * Enable support for PKCS#1 v2.1 encoding. + * + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C + * + * This enables support for RSAES-OAEP and RSASSA-PSS operations. + */ +//#define MBEDTLS_PKCS1_V21 + +/** + * \def MBEDTLS_RSA_NO_CRT + * + * Do not use the Chinese Remainder Theorem for the RSA private operation. + * + * Uncomment this macro to disable the use of CRT in RSA. + * + */ +//#define MBEDTLS_RSA_NO_CRT + +/** + * \def MBEDTLS_SELF_TEST + * + * Enable the checkup functions (*_self_test). + */ +//#define MBEDTLS_SELF_TEST + +/** + * \def MBEDTLS_SHA256_SMALLER + * + * Enable an implementation of SHA-256 that has lower ROM footprint but also + * lower performance. + * + * The default implementation is meant to be a reasonnable compromise between + * performance and size. This version optimizes more aggressively for size at + * the expense of performance. Eg on Cortex-M4 it reduces the size of + * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about + * 30%. + * + * Uncomment to enable the smaller implementation of SHA256. + */ +//#define MBEDTLS_SHA256_SMALLER + +/** + * \def MBEDTLS_SSL_AEAD_RANDOM_IV + * + * Generate a random IV rather than using the record sequence number as a + * nonce for ciphersuites using and AEAD algorithm (GCM or CCM). + * + * Using the sequence number is generally recommended. + * + * Uncomment this macro to always use random IVs with AEAD ciphersuites. + */ +//#define MBEDTLS_SSL_AEAD_RANDOM_IV + +/** + * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES + * + * Enable sending of alert messages in case of encountered errors as per RFC. + * If you choose not to send the alert messages, mbed TLS can still communicate + * with other servers, only debugging of failures is harder. + * + * The advantage of not sending alert messages, is that no information is given + * about reasons for failures thus preventing adversaries of gaining intel. + * + * Enable sending of all alert messages + */ +#define MBEDTLS_SSL_ALL_ALERT_MESSAGES + +/** + * \def MBEDTLS_SSL_DEBUG_ALL + * + * Enable the debug messages in SSL module for all issues. + * Debug messages have been disabled in some places to prevent timing + * attacks due to (unbalanced) debugging function calls. + * + * If you need all error reporting you should enable this during debugging, + * but remove this for production servers that should log as well. + * + * Uncomment this macro to report all debug messages on errors introducing + * a timing side-channel. + * + */ +//#define MBEDTLS_SSL_DEBUG_ALL + +/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC + * + * Enable support for Encrypt-then-MAC, RFC 7366. + * + * This allows peers that both support it to use a more robust protection for + * ciphersuites using CBC, providing deep resistance against timing attacks + * on the padding or underlying cipher. + * + * This only affects CBC ciphersuites, and is useless if none is defined. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Encrypt-then-MAC + */ +#define MBEDTLS_SSL_ENCRYPT_THEN_MAC + +/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET + * + * Enable support for Extended Master Secret, aka Session Hash + * (draft-ietf-tls-session-hash-02). + * + * This was introduced as "the proper fix" to the Triple Handshake familiy of + * attacks, but it is recommended to always use it (even if you disable + * renegotiation), since it actually fixes a more fundamental issue in the + * original SSL/TLS design, and has implications beyond Triple Handshake. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Extended Master Secret. + */ +//#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET + +/** + * \def MBEDTLS_SSL_FALLBACK_SCSV + * + * Enable support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv-00). + * + * For servers, it is recommended to always enable this, unless you support + * only one version of TLS, or know for sure that none of your clients + * implements a fallback strategy. + * + * For clients, you only need this if you're using a fallback strategy, which + * is not recommended in the first place, unless you absolutely need it to + * interoperate with buggy (version-intolerant) servers. + * + * Comment this macro to disable support for FALLBACK_SCSV + */ +//#define MBEDTLS_SSL_FALLBACK_SCSV + +/** + * \def MBEDTLS_SSL_HW_RECORD_ACCEL + * + * Enable hooking functions in SSL module for hardware acceleration of + * individual records. + * + * Uncomment this macro to enable hooking functions. + */ +//#define MBEDTLS_SSL_HW_RECORD_ACCEL + +/** + * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING + * + * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. + * + * This is a countermeasure to the BEAST attack, which also minimizes the risk + * of interoperability issues compared to sending 0-length records. + * + * Comment this macro to disable 1/n-1 record splitting. + */ +//#define MBEDTLS_SSL_CBC_RECORD_SPLITTING + +/** + * \def MBEDTLS_SSL_RENEGOTIATION + * + * Disable support for TLS renegotiation. + * + * The two main uses of renegotiation are (1) refresh keys on long-lived + * connections and (2) client authentication after the initial handshake. + * If you don't need renegotiation, it's probably better to disable it, since + * it has been associated with security issues in the past and is easy to + * misuse/misunderstand. + * + * Comment this to disable support for renegotiation. + */ +#define MBEDTLS_SSL_RENEGOTIATION + +/** + * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + * + * Enable support for receiving and parsing SSLv2 Client Hello messages for the + * SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to enable support for SSLv2 Client Hello messages. + */ +//#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + +/** + * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + * + * Pick the ciphersuite according to the client's preferences rather than ours + * in the SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to respect client's ciphersuite order + */ +//#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + +/** + * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + * + * Enable support for RFC 6066 max_fragment_length extension in SSL. + * + * Comment this macro to disable support for the max_fragment_length extension + */ +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + +/** + * \def MBEDTLS_SSL_PROTO_SSL3 + * + * Enable support for SSL 3.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for SSL 3.0 + */ +//#define MBEDTLS_SSL_PROTO_SSL3 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1 + * + * Enable support for TLS 1.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.0 + */ +//#define MBEDTLS_SSL_PROTO_TLS1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_1 + * + * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 + */ +//#define MBEDTLS_SSL_PROTO_TLS1_1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_2 + * + * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). + * + * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C + * (Depends on ciphersuites) + * + * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 + */ +#define MBEDTLS_SSL_PROTO_TLS1_2 + +/** + * \def MBEDTLS_SSL_PROTO_DTLS + * + * Enable support for DTLS (all available versions). + * + * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, + * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_1 + * or MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for DTLS + */ +#define MBEDTLS_SSL_PROTO_DTLS + +/** + * \def MBEDTLS_SSL_ALPN + * + * Enable support for RFC 7301 Application Layer Protocol Negotiation. + * + * Comment this macro to disable support for ALPN. + */ +//#define MBEDTLS_SSL_ALPN + +/** + * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY + * + * Enable support for the anti-replay mechanism in DTLS. + * + * Requires: MBEDTLS_SSL_TLS_C + * MBEDTLS_SSL_PROTO_DTLS + * + * \warning Disabling this is often a security risk! + * See mbedtls_ssl_conf_dtls_anti_replay() for details. + * + * Comment this to disable anti-replay in DTLS. + */ +//#define MBEDTLS_SSL_DTLS_ANTI_REPLAY + +/** + * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Enable support for HelloVerifyRequest on DTLS servers. + * + * This feature is highly recommended to prevent DTLS servers being used as + * amplifiers in DoS attacks against other hosts. It should always be enabled + * unless you know for sure amplification cannot be a problem in the + * environment in which your server operates. + * + * \warning Disabling this can ba a security risk! (see above) + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Comment this to disable support for HelloVerifyRequest. + */ +//#define MBEDTLS_SSL_DTLS_HELLO_VERIFY + +/** + * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + * + * Enable server-side support for clients that reconnect from the same port. + * + * Some clients unexpectedly close the connection and try to reconnect using the + * same source port. This needs special support from the server to handle the + * new connection securely, as described in section 4.2.8 of RFC 6347. This + * flag enables that support. + * + * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Comment this to disable support for clients reusing the source port. + */ +//#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + +/** + * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT + * + * Enable support for a limit of records with bad MAC. + * + * See mbedtls_ssl_conf_dtls_badmac_limit(). + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + */ +//#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT + +/** + * \def MBEDTLS_SSL_SESSION_TICKETS + * + * Enable support for RFC 5077 session tickets in SSL. + * Client-side, provides full support for session tickets (maintainance of a + * session store remains the responsibility of the application, though). + * Server-side, you also need to provide callbacks for writing and parsing + * tickets, including authenticated encryption and key management. Example + * callbacks are provided by MBEDTLS_SSL_TICKET_C. + * + * Comment this macro to disable support for SSL session tickets + */ +#define MBEDTLS_SSL_SESSION_TICKETS + +/** + * \def MBEDTLS_SSL_EXPORT_KEYS + * + * Enable support for exporting key block and master secret. + * This is required for certain users of TLS, e.g. EAP-TLS. + * + * Comment this macro to disable support for key export + */ +//#define MBEDTLS_SSL_EXPORT_KEYS + +/** + * \def MBEDTLS_SSL_SERVER_NAME_INDICATION + * + * Enable support for RFC 6066 server name indication (SNI) in SSL. + * + * Requires: MBEDTLS_X509_CRT_PARSE_C + * + * Comment this macro to disable support for server name indication in SSL + */ +//#define MBEDTLS_SSL_SERVER_NAME_INDICATION + +/** + * \def MBEDTLS_SSL_TRUNCATED_HMAC + * + * Enable support for RFC 6066 truncated HMAC in SSL. + * + * Comment this macro to disable support for truncated HMAC in SSL + */ +//#define MBEDTLS_SSL_TRUNCATED_HMAC + +/** + * \def MBEDTLS_THREADING_ALT + * + * Provide your own alternate threading implementation. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to allow your own alternate threading implementation. + */ +//#define MBEDTLS_THREADING_ALT + +/** + * \def MBEDTLS_THREADING_PTHREAD + * + * Enable the pthread wrapper layer for the threading layer. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to enable pthread mutexes. + */ +//#define MBEDTLS_THREADING_PTHREAD + +/** + * \def MBEDTLS_VERSION_FEATURES + * + * Allow run-time checking of compile-time enabled features. Thus allowing users + * to check at run-time if the library is for instance compiled with threading + * support via mbedtls_version_check_feature(). + * + * Requires: MBEDTLS_VERSION_C + * + * Comment this to disable run-time checking and save ROM space + */ +#define MBEDTLS_VERSION_FEATURES + +/** + * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an extension in a v1 or v2 certificate. + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + +/** + * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an unknown critical extension. + * + * \warning Depending on your PKI use, enabling this can be a security risk! + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + +/** + * \def MBEDTLS_X509_CHECK_KEY_USAGE + * + * Enable verification of the keyUsage extension (CA and leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused + * (intermediate) CA and leaf certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip keyUsage checking for both CA and leaf certificates. + */ +//#define MBEDTLS_X509_CHECK_KEY_USAGE + +/** + * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + * + * Enable verification of the extendedKeyUsage extension (leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip extendedKeyUsage checking for certificates. + */ +//#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + +/** + * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT + * + * Enable parsing and verification of X.509 certificates, CRLs and CSRS + * signed with RSASSA-PSS (aka PKCS#1 v2.1). + * + * Comment this macro to disallow using RSASSA-PSS in certificates. + */ +//#define MBEDTLS_X509_RSASSA_PSS_SUPPORT + +/** + * \def MBEDTLS_ZLIB_SUPPORT + * + * If set, the SSL/TLS module uses ZLIB to support compression and + * decompression of packet data. + * + * \warning TLS-level compression MAY REDUCE SECURITY! See for example the + * CRIME attack. Before enabling this option, you should examine with care if + * CRIME or similar exploits may be a applicable to your use case. + * + * \note Currently compression can't be used with DTLS. + * + * Used in: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This feature requires zlib library and headers to be present. + * + * Uncomment to enable use of ZLIB + */ +//#define MBEDTLS_ZLIB_SUPPORT +/* \} name SECTION: mbed TLS feature support */ + +/** + * \name SECTION: mbed TLS modules + * + * This section enables or disables entire modules in mbed TLS + * \{ + */ + +/** + * \def MBEDTLS_AESNI_C + * + * Enable AES-NI support on x86-64. + * + * Module: library/aesni.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the AES-NI instructions on x86-64 + */ +//#define MBEDTLS_AESNI_C + +/** + * \def MBEDTLS_AES_C + * + * Enable the AES block cipher. + * + * Module: library/aes.c + * Caller: library/ssl_tls.c + * library/pem.c + * library/ctr_drbg.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * + * PEM_PARSE uses AES for decrypting encrypted keys. + */ +#define MBEDTLS_AES_C + +/** + * \def MBEDTLS_ARC4_C + * + * Enable the ARCFOUR stream cipher. + * + * Module: library/arc4.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_ARC4_C + +/** + * \def MBEDTLS_ASN1_PARSE_C + * + * Enable the generic ASN1 parser. + * + * Module: library/asn1.c + * Caller: library/x509.c + * library/dhm.c + * library/pkcs12.c + * library/pkcs5.c + * library/pkparse.c + */ +//#define MBEDTLS_ASN1_PARSE_C + +/** + * \def MBEDTLS_ASN1_WRITE_C + * + * Enable the generic ASN1 writer. + * + * Module: library/asn1write.c + * Caller: library/ecdsa.c + * library/pkwrite.c + * library/x509_create.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + */ +//#define MBEDTLS_ASN1_WRITE_C + +/** + * \def MBEDTLS_BASE64_C + * + * Enable the Base64 module. + * + * Module: library/base64.c + * Caller: library/pem.c + * + * This module is required for PEM support (required by X.509). + */ +//#define MBEDTLS_BASE64_C + +/** + * \def MBEDTLS_BIGNUM_C + * + * Enable the multi-precision integer library. + * + * Module: library/bignum.c + * Caller: library/dhm.c + * library/ecp.c + * library/ecdsa.c + * library/rsa.c + * library/ssl_tls.c + * + * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. + */ +#define MBEDTLS_BIGNUM_C + +/** + * \def MBEDTLS_BLOWFISH_C + * + * Enable the Blowfish block cipher. + * + * Module: library/blowfish.c + */ +//#define MBEDTLS_BLOWFISH_C + +/** + * \def MBEDTLS_CAMELLIA_C + * + * Enable the Camellia block cipher. + * + * Module: library/camellia.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +//#define MBEDTLS_CAMELLIA_C + +/** + * \def MBEDTLS_CCM_C + * + * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. + * + * Module: library/ccm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-CCM ciphersuites, if other requisites are + * enabled as well. + */ +#define MBEDTLS_CCM_C + +/** + * \def MBEDTLS_CERTS_C + * + * Enable the test certificates. + * + * Module: library/certs.c + * Caller: + * + * This module is used for testing (ssl_client/server). + */ +//#define MBEDTLS_CERTS_C + +/** + * \def MBEDTLS_CIPHER_C + * + * Enable the generic cipher layer. + * + * Module: library/cipher.c + * Caller: library/ssl_tls.c + * + * Uncomment to enable generic cipher wrappers. + */ +#define MBEDTLS_CIPHER_C + +/** + * \def MBEDTLS_CTR_DRBG_C + * + * Enable the CTR_DRBG AES-256-based random generator. + * + * Module: library/ctr_drbg.c + * Caller: + * + * Requires: MBEDTLS_AES_C + * + * This module provides the CTR_DRBG AES-256 random number generator. + */ +//#define MBEDTLS_CTR_DRBG_C + +/** + * \def MBEDTLS_DEBUG_C + * + * Enable the debug functions. + * + * Module: library/debug.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module provides debugging functions. + */ +//#define MBEDTLS_DEBUG_C + +/** + * \def MBEDTLS_DES_C + * + * Enable the DES block cipher. + * + * Module: library/des.c + * Caller: library/pem.c + * library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * + * PEM_PARSE uses DES/3DES for decrypting encrypted keys. + */ +//#define MBEDTLS_DES_C + +/** + * \def MBEDTLS_DHM_C + * + * Enable the Diffie-Hellman-Merkle module. + * + * Module: library/dhm.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * DHE-RSA, DHE-PSK + */ +//#define MBEDTLS_DHM_C + +/** + * \def MBEDTLS_ECDH_C + * + * Enable the elliptic curve Diffie-Hellman library. + * + * Module: library/ecdh.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK + * + * Requires: MBEDTLS_ECP_C + */ +//#define MBEDTLS_ECDH_C + +/** + * \def MBEDTLS_ECDSA_C + * + * Enable the elliptic curve DSA library. + * + * Module: library/ecdsa.c + * Caller: + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C + */ +//#define MBEDTLS_ECDSA_C + +/** + * \def MBEDTLS_ECP_C + * + * Enable the elliptic curve over GF(p) library. + * + * Module: library/ecp.c + * Caller: library/ecdh.c + * library/ecdsa.c + * library/ecjpake.c + * + * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED + */ +//#define MBEDTLS_ECP_C + +/** + * \def MBEDTLS_ENTROPY_C + * + * Enable the platform-specific entropy code. + * + * Module: library/entropy.c + * Caller: + * + * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C + * + * This module provides a generic entropy pool + */ +//#define MBEDTLS_ENTROPY_C + +/** + * \def MBEDTLS_ERROR_C + * + * Enable error code to error string conversion. + * + * Module: library/error.c + * Caller: + * + * This module enables mbedtls_strerror(). + */ +//#define MBEDTLS_ERROR_C + +/** + * \def MBEDTLS_GCM_C + * + * Enable the Galois/Counter Mode (GCM) for AES. + * + * Module: library/gcm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other + * requisites are enabled as well. + */ +//#define MBEDTLS_GCM_C + +/** + * \def MBEDTLS_HAVEGE_C + * + * Enable the HAVEGE random generator. + * + * Warning: the HAVEGE random generator is not suitable for virtualized + * environments + * + * Warning: the HAVEGE random generator is dependent on timing and specific + * processor traits. It is therefore not advised to use HAVEGE as + * your applications primary random generator or primary entropy pool + * input. As a secondary input to your entropy pool, it IS able add + * the (limited) extra entropy it provides. + * + * Module: library/havege.c + * Caller: + * + * Requires: MBEDTLS_TIMING_C + * + * Uncomment to enable the HAVEGE random generator. + */ +//#define MBEDTLS_HAVEGE_C + +/** + * \def MBEDTLS_HMAC_DRBG_C + * + * Enable the HMAC_DRBG random generator. + * + * Module: library/hmac_drbg.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * Uncomment to enable the HMAC_DRBG random number geerator. + */ +//#define MBEDTLS_HMAC_DRBG_C + +/** + * \def MBEDTLS_MD_C + * + * Enable the generic message digest layer. + * + * Module: library/mbedtls_md.c + * Caller: + * + * Uncomment to enable generic message digest wrappers. + */ +#define MBEDTLS_MD_C + +/** + * \def MBEDTLS_MD2_C + * + * Enable the MD2 hash algorithm. + * + * Module: library/mbedtls_md2.c + * Caller: + * + * Uncomment to enable support for (rare) MD2-signed X.509 certs. + */ +//#define MBEDTLS_MD2_C + +/** + * \def MBEDTLS_MD4_C + * + * Enable the MD4 hash algorithm. + * + * Module: library/mbedtls_md4.c + * Caller: + * + * Uncomment to enable support for (rare) MD4-signed X.509 certs. + */ +//#define MBEDTLS_MD4_C + +/** + * \def MBEDTLS_MD5_C + * + * Enable the MD5 hash algorithm. + * + * Module: library/mbedtls_md5.c + * Caller: library/mbedtls_md.c + * library/pem.c + * library/ssl_tls.c + * + * This module is required for SSL/TLS and X.509. + * PEM_PARSE uses MD5 for decrypting encrypted keys. + */ +#define MBEDTLS_MD5_C + + +/** + * \def MBEDTLS_NET_C + * + * Enable the TCP/IP networking routines. + * + * Module: library/net.c + * + * This module provides TCP/IP networking routines. + */ +//#define MBEDTLS_NET_C + +/** + * \def MBEDTLS_OID_C + * + * Enable the OID database. + * + * Module: library/oid.c + * Caller: library/asn1write.c + * library/pkcs5.c + * library/pkparse.c + * library/pkwrite.c + * library/rsa.c + * library/x509.c + * library/x509_create.c + * library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + * + * This modules translates between OIDs and internal values. + */ +#define MBEDTLS_OID_C + +/** + * \def MBEDTLS_PADLOCK_C + * + * Enable VIA Padlock support on x86. + * + * Module: library/padlock.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the VIA PadLock on x86. + */ +//#define MBEDTLS_PADLOCK_C + +/** + * \def MBEDTLS_PEM_PARSE_C + * + * Enable PEM decoding / parsing. + * + * Module: library/pem.c + * Caller: library/dhm.c + * library/pkparse.c + * library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for decoding / parsing PEM files. + */ +//#define MBEDTLS_PEM_PARSE_C + +/** + * \def MBEDTLS_PEM_WRITE_C + * + * Enable PEM encoding / writing. + * + * Module: library/pem.c + * Caller: library/pkwrite.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for encoding / writing PEM files. + */ +//#define MBEDTLS_PEM_WRITE_C + +/** + * \def MBEDTLS_PK_C + * + * Enable the generic public (asymetric) key layer. + * + * Module: library/pk.c + * Caller: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C + * + * Uncomment to enable generic public key wrappers. + */ +//#define MBEDTLS_PK_C + +/** + * \def MBEDTLS_PK_PARSE_C + * + * Enable the generic public (asymetric) key parser. + * + * Module: library/pkparse.c + * Caller: library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key parse functions. +*/ +//#define MBEDTLS_PK_PARSE_C + +/** + * \def MBEDTLS_PK_WRITE_C + * + * Enable the generic public (asymetric) key writer. + * + * Module: library/pkwrite.c + * Caller: library/x509write.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key write functions. + */ +//#define MBEDTLS_PK_WRITE_C + +/** + * \def MBEDTLS_PKCS5_C + * + * Enable PKCS#5 functions. + * + * Module: library/pkcs5.c + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the PKCS#5 functions. + */ +//#define MBEDTLS_PKCS5_C + +/** + * \def MBEDTLS_PKCS11_C + * + * Enable wrapper for PKCS#11 smartcard support. + * + * Module: library/pkcs11.c + * Caller: library/pk.c + * + * Requires: MBEDTLS_PK_C + * + * This module enables SSL/TLS PKCS #11 smartcard support. + * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) + */ +//#define MBEDTLS_PKCS11_C + +/** + * \def MBEDTLS_PKCS12_C + * + * Enable PKCS#12 PBE functions. + * Adds algorithms for parsing PKCS#8 encrypted private keys + * + * Module: library/pkcs12.c + * Caller: library/pkparse.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * Can use: MBEDTLS_ARC4_C + * + * This module enables PKCS#12 functions. + */ +//#define MBEDTLS_PKCS12_C + +/** + * \def MBEDTLS_PLATFORM_C + * + * Enable the platform abstraction layer that allows you to re-assign + * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). + * + * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT + * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned + * above to be specified at runtime or compile time respectively. + * + * \note This abstraction layer must be enabled on Windows (including MSYS2) + * as other module rely on it for a fixed snprintf implementation. + * + * Module: library/platform.c + * Caller: Most other .c files + * + * This module enables abstraction of common (libc) functions. + */ +#define MBEDTLS_PLATFORM_C + +/** + * \def MBEDTLS_RIPEMD160_C + * + * Enable the RIPEMD-160 hash algorithm. + * + * Module: library/mbedtls_ripemd160.c + * Caller: library/mbedtls_md.c + * + */ +//#define MBEDTLS_RIPEMD160_C + +/** + * \def MBEDTLS_RSA_C + * + * Enable the RSA public-key cryptosystem. + * + * Module: library/rsa.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509.c + * + * This module is used by the following key exchanges: + * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C + */ +//#define MBEDTLS_RSA_C + +/** + * \def MBEDTLS_SHA1_C + * + * Enable the SHA1 cryptographic hash algorithm. + * + * Module: library/mbedtls_sha1.c + * Caller: library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509write_crt.c + * + * This module is required for SSL/TLS and SHA1-signed certificates. + */ +//#define MBEDTLS_SHA1_C + +/** + * \def MBEDTLS_SHA256_C + * + * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. + * + * Module: library/mbedtls_sha256.c + * Caller: library/entropy.c + * library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module adds support for SHA-224 and SHA-256. + * This module is required for the SSL/TLS 1.2 PRF function. + */ +#define MBEDTLS_SHA256_C + +/** + * \def MBEDTLS_SHA512_C + * + * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. + * + * Module: library/mbedtls_sha512.c + * Caller: library/entropy.c + * library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This module adds support for SHA-384 and SHA-512. + */ +//#define MBEDTLS_SHA512_C + +/** + * \def MBEDTLS_SSL_CACHE_C + * + * Enable simple SSL cache implementation. + * + * Module: library/ssl_cache.c + * Caller: + * + * Requires: MBEDTLS_SSL_CACHE_C + */ +//#define MBEDTLS_SSL_CACHE_C + +/** + * \def MBEDTLS_SSL_COOKIE_C + * + * Enable basic implementation of DTLS cookies for hello verification. + * + * Module: library/ssl_cookie.c + * Caller: + */ +#define MBEDTLS_SSL_COOKIE_C + +/** + * \def MBEDTLS_SSL_TICKET_C + * + * Enable an implementation of TLS server-side callbacks for session tickets. + * + * Module: library/ssl_ticket.c + * Caller: + * + * Requires: MBEDTLS_CIPHER_C + */ +//#define MBEDTLS_SSL_TICKET_C + +/** + * \def MBEDTLS_SSL_CLI_C + * + * Enable the SSL/TLS client code. + * + * Module: library/ssl_cli.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS client support. + */ +#define MBEDTLS_SSL_CLI_C + +/** + * \def MBEDTLS_SSL_SRV_C + * + * Enable the SSL/TLS server code. + * + * Module: library/ssl_srv.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS server support. + */ +#define MBEDTLS_SSL_SRV_C + +/** + * \def MBEDTLS_SSL_TLS_C + * + * Enable the generic SSL/TLS code. + * + * Module: library/ssl_tls.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * and at least one of the MBEDTLS_SSL_PROTO_XXX defines + * + * This module is required for SSL/TLS. + */ +#define MBEDTLS_SSL_TLS_C + +/** + * \def MBEDTLS_THREADING_C + * + * Enable the threading abstraction layer. + * By default mbed TLS assumes it is used in a non-threaded environment or that + * contexts are not shared between threads. If you do intend to use contexts + * between threads, you will need to enable this layer to prevent race + * conditions. + * + * Module: library/threading.c + * + * This allows different threading implementations (self-implemented or + * provided). + * + * You will have to enable either MBEDTLS_THREADING_ALT or + * MBEDTLS_THREADING_PTHREAD. + * + * Enable this layer to allow use of mutexes within mbed TLS + */ +//#define MBEDTLS_THREADING_C + +/** + * \def MBEDTLS_TIMING_C + * + * Enable the portable timing interface. + * + * Module: library/timing.c + * Caller: library/havege.c + * + * This module is used by the HAVEGE random number generator. + */ +//#define MBEDTLS_TIMING_C + +/** + * \def MBEDTLS_VERSION_C + * + * Enable run-time version information. + * + * Module: library/version.c + * + * This module provides run-time version information. + */ +#define MBEDTLS_VERSION_C + +/** + * \def MBEDTLS_X509_USE_C + * + * Enable X.509 core for using certificates. + * + * Module: library/x509.c + * Caller: library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, + * MBEDTLS_PK_PARSE_C + * + * This module is required for the X.509 parsing modules. + */ +//#define MBEDTLS_X509_USE_C + +/** + * \def MBEDTLS_X509_CRT_PARSE_C + * + * Enable X.509 certificate parsing. + * + * Module: library/mbedtls_x509_crt.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 certificate parsing. + */ +//#define MBEDTLS_X509_CRT_PARSE_C + +/** + * \def MBEDTLS_X509_CRL_PARSE_C + * + * Enable X.509 CRL parsing. + * + * Module: library/mbedtls_x509_crl.c + * Caller: library/mbedtls_x509_crt.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 CRL parsing. + */ +//#define MBEDTLS_X509_CRL_PARSE_C + +/** + * \def MBEDTLS_X509_CSR_PARSE_C + * + * Enable X.509 Certificate Signing Request (CSR) parsing. + * + * Module: library/mbedtls_x509_csr.c + * Caller: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is used for reading X.509 certificate request. + */ +//#define MBEDTLS_X509_CSR_PARSE_C + +/** + * \def MBEDTLS_X509_CREATE_C + * + * Enable X.509 core for creating certificates. + * + * Module: library/x509_create.c + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C + * + * This module is the basis for creating X.509 certificates and CSRs. + */ +//#define MBEDTLS_X509_CREATE_C + +/** + * \def MBEDTLS_X509_CRT_WRITE_C + * + * Enable creating X.509 certificates. + * + * Module: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate creation. + */ +//#define MBEDTLS_X509_CRT_WRITE_C + +/** + * \def MBEDTLS_X509_CSR_WRITE_C + * + * Enable creating X.509 Certificate Signing Requests (CSR). + * + * Module: library/x509_csr_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate request writing. + */ +//#define MBEDTLS_X509_CSR_WRITE_C + +/** + * \def MBEDTLS_XTEA_C + * + * Enable the XTEA block cipher. + * + * Module: library/xtea.c + * Caller: + */ +//#define MBEDTLS_XTEA_C + +/* \} name SECTION: mbed TLS modules */ + +/** + * \name SECTION: Module configuration options + * + * This section allows for the setting of module specific sizes and + * configuration options. The default values are already present in the + * relevant header files and should suffice for the regular use cases. + * + * Our advice is to enable options and change their values here + * only if you have a good reason and know the consequences. + * + * Please check the respective header file for documentation on these + * parameters (to prevent duplicate documentation). + * \{ + */ + +/* MPI / BIGNUM options */ +//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ +//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ + +/* CTR_DRBG options */ +//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ +//#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* HMAC_DRBG options */ +//#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* ECP options */ +//#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ +//#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ + +/* Entropy options */ +//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ +//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ + +/* Memory buffer allocator options */ +#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ + +/* Platform options */ +//#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ +//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ + +/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ +/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ +//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ + +/* SSL Cache options */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ + +/* SSL options */ +#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ +//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ +#define MBEDTLS_PSK_MAX_LEN 16 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ +//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ + +/** + * Complete list of ciphersuites to use, in order of preference. + * + * \warning No dependency checking is done on that field! This option can only + * be used to restrict the set of available ciphersuites. It is your + * responsibility to make sure the needed modules are active. + * + * Use this to save a few hundred bytes of ROM (default ordering of all + * available ciphersuites) and a few to a few hundred bytes of RAM. + * + * The value below is only an example, not the default. + */ +//#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + +/* X509 options */ +//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ + +/* \} name SECTION: Module configuration options */ + +#if defined(TARGET_LIKE_MBED) +#include "mbedtls/target_config.h" +#endif + +/* + * Allow user to override any previous default. + * + * Use two macro names for that, as: + * - with yotta the prefix YOTTA_CFG_ is forced + * - without yotta is looks weird to have a YOTTA prefix. + */ +#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) +#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE +#elif defined(MBEDTLS_USER_CONFIG_FILE) +#include MBEDTLS_USER_CONFIG_FILE +#endif + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/nrf_crypto/config/nrf_crypto_mbedtls_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/nrf_crypto/config/nrf_crypto_mbedtls_config.h new file mode 100644 index 0000000..b866101 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/nrf_crypto/config/nrf_crypto_mbedtls_config.h @@ -0,0 +1,2514 @@ +/** + * \file nrf_crypto_mbedtls_config.h + * + * \brief Configuration options (set of defines) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2018 Nordic Semiconductor ASA, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* + * This set of compile-time options may be used to enable + * or disable features selectively, and reduce the global + * memory footprint. + */ +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +#include "sdk_config.h" + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +/** + * \name SECTION: System support + * + * This section sets system specific settings. + * \{ + */ + +/** + * \def MBEDTLS_HAVE_ASM + * + * The compiler has support for asm(). + * + * Requires support for asm() in compiler. + * + * Used in: + * library/timing.c + * library/padlock.c + * include/mbedtls/bn_mul.h + * + * Comment to disable the use of assembly code. + */ +//#define MBEDTLS_HAVE_ASM + +/** + * \def MBEDTLS_HAVE_SSE2 + * + * CPU supports SSE2 instruction set. + * + * Uncomment if the CPU supports SSE2 (IA-32 specific). + */ +//#define MBEDTLS_HAVE_SSE2 + +/** + * \def MBEDTLS_HAVE_TIME + * + * System has time.h and time(). + * The time does not need to be correct, only time differences are used, + * by contrast with MBEDTLS_HAVE_TIME_DATE + * + * Comment if your system does not support time functions + */ +//#define MBEDTLS_HAVE_TIME + +/** + * \def MBEDTLS_HAVE_TIME_DATE + * + * System has time.h and time(), gmtime() and the clock is correct. + * The time needs to be correct (not necesarily very accurate, but at least + * the date should be correct). This is used to verify the validity period of + * X.509 certificates. + * + * Comment if your system does not have a correct clock. + */ +//#define MBEDTLS_HAVE_TIME_DATE + +/** + * \def MBEDTLS_PLATFORM_MEMORY + * + * Enable the memory allocation layer. + * + * By default mbed TLS uses the system-provided calloc() and free(). + * This allows different allocators (self-implemented or provided) to be + * provided to the platform abstraction layer. + * + * Enabling MBEDTLS_PLATFORM_MEMORY without the + * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide + * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and + * free() function pointer at runtime. + * + * Enabling MBEDTLS_PLATFORM_MEMORY and specifying + * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the + * alternate function at compile time. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Enable this layer to allow use of alternative memory allocators. + */ +#define MBEDTLS_PLATFORM_MEMORY + +/** + * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + * + * Do not assign standard functions in the platform layer (e.g. calloc() to + * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) + * + * This makes sure there are no linking errors on platforms that do not support + * these functions. You will HAVE to provide alternatives, either at runtime + * via the platform_set_xxx() functions or at compile time by setting + * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a + * MBEDTLS_PLATFORM_XXX_MACRO. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Uncomment to prevent default assignment of standard functions in the + * platform layer. + */ +#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + +/** + * \def MBEDTLS_PLATFORM_XXX_ALT + * + * Uncomment a macro to let mbed TLS support the function in the platform + * abstraction layer. + * + * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will + * provide a function "mbedtls_platform_set_printf()" that allows you to set an + * alternative printf function pointer. + * + * All these define require MBEDTLS_PLATFORM_C to be defined! + * + * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; + * it will be enabled automatically by check_config.h + * + * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as + * MBEDTLS_PLATFORM_XXX_MACRO! + * + * Uncomment a macro to enable alternate implementation of specific base + * platform function + */ +//#define MBEDTLS_PLATFORM_EXIT_ALT +//#define MBEDTLS_PLATFORM_FPRINTF_ALT +//#define MBEDTLS_PLATFORM_PRINTF_ALT +//#define MBEDTLS_PLATFORM_SNPRINTF_ALT + +/** + * \def MBEDTLS_DEPRECATED_WARNING + * + * Mark deprecated functions so that they generate a warning if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * This only works with GCC and Clang. With other compilers, you may want to + * use MBEDTLS_DEPRECATED_REMOVED + * + * Uncomment to get warnings on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_WARNING + +/** + * \def MBEDTLS_DEPRECATED_REMOVED + * + * Remove deprecated functions so that they generate an error if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * Uncomment to get errors on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_REMOVED + +/* \} name SECTION: System support */ + +/** + * \name SECTION: mbed TLS feature support + * + * This section sets support for features that are or are not needed + * within the modules that are enabled. + * \{ + */ + +/** + * \def MBEDTLS_TIMING_ALT + * + * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), + * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() + * + * Only works if you have MBEDTLS_TIMING_C enabled. + * + * You will need to provide a header "timing_alt.h" and an implementation at + * compile time. + */ +//#define MBEDTLS_TIMING_ALT + +/** + * \def MBEDTLS__MODULE_NAME__ALT + * + * Uncomment a macro to let mbed TLS use your alternate core implementation of + * a symmetric crypto or hash module (e.g. platform specific assembly + * optimized implementations). Keep in mind that the function prototypes + * should remain the same. + * + * This replaces the whole module. If you only want to replace one of the + * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer + * provide the "struct mbedtls_aes_context" definition and omit the base function + * declarations and implementations. "aes_alt.h" will be included from + * "aes.h" to include the new function definitions. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * module. + */ +//#define MBEDTLS_AES_ALT +//#define MBEDTLS_ARC4_ALT +//#define MBEDTLS_BLOWFISH_ALT +//#define MBEDTLS_CAMELLIA_ALT +//#define MBEDTLS_DES_ALT +//#define MBEDTLS_XTEA_ALT +//#define MBEDTLS_MD2_ALT +//#define MBEDTLS_MD4_ALT +//#define MBEDTLS_MD5_ALT +//#define MBEDTLS_RIPEMD160_ALT +//#define MBEDTLS_SHA1_ALT +//#define MBEDTLS_SHA256_ALT +//#define MBEDTLS_SHA512_ALT + +/** + * \def MBEDTLS__FUNCTION_NAME__ALT + * + * Uncomment a macro to let mbed TLS use you alternate core implementation of + * symmetric crypto or hash function. Keep in mind that function prototypes + * should remain the same. + * + * This replaces only one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will + * no longer provide the mbedtls_sha1_process() function, but it will still provide + * the other function (using your mbedtls_sha1_process() function) and the definition + * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible + * with this definition. + * + * Note: if you use the AES_xxx_ALT macros, then is is recommended to also set + * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES + * tables. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + */ +//#define MBEDTLS_MD2_PROCESS_ALT +//#define MBEDTLS_MD4_PROCESS_ALT +//#define MBEDTLS_MD5_PROCESS_ALT +//#define MBEDTLS_RIPEMD160_PROCESS_ALT +//#define MBEDTLS_SHA1_PROCESS_ALT +//#define MBEDTLS_SHA256_PROCESS_ALT +//#define MBEDTLS_SHA512_PROCESS_ALT +//#define MBEDTLS_DES_SETKEY_ALT +//#define MBEDTLS_DES_CRYPT_ECB_ALT +//#define MBEDTLS_DES3_CRYPT_ECB_ALT +//#define MBEDTLS_AES_SETKEY_ENC_ALT +//#define MBEDTLS_AES_SETKEY_DEC_ALT +//#define MBEDTLS_AES_ENCRYPT_ALT +//#define MBEDTLS_AES_DECRYPT_ALT + +/** + * \def MBEDTLS_ENTROPY_HARDWARE_ALT + * + * Uncomment this macro to let mbed TLS use your own implementation of a + * hardware entropy collector. + * + * Your function must be called \c mbedtls_hardware_poll(), have the same + * prototype as declared in entropy_poll.h, and accept NULL as first argument. + * + * Uncomment to use your own hardware entropy collector. + */ +//#define MBEDTLS_ENTROPY_HARDWARE_ALT + +/** + * \def MBEDTLS_AES_ROM_TABLES + * + * Store the AES tables in ROM. + * + * Uncomment this macro to store the AES tables in ROM. + */ +#define MBEDTLS_AES_ROM_TABLES + +/** + * \def MBEDTLS_CAMELLIA_SMALL_MEMORY + * + * Use less ROM for the Camellia implementation (saves about 768 bytes). + * + * Uncomment this macro to use less memory for Camellia. + */ +//#define MBEDTLS_CAMELLIA_SMALL_MEMORY + +/** + * \def MBEDTLS_CIPHER_MODE_CBC + * + * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CBC + +/** + * \def MBEDTLS_CIPHER_MODE_CFB + * + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CFB + +/** + * \def MBEDTLS_CIPHER_MODE_CTR + * + * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CTR + +/** + * \def MBEDTLS_CIPHER_NULL_CIPHER + * + * Enable NULL cipher. + * Warning: Only do so when you know what you are doing. This allows for + * encryption or channels without any security! + * + * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable + * the following ciphersuites: + * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA + * + * Uncomment this macro to enable the NULL cipher and ciphersuites + */ +//#define MBEDTLS_CIPHER_NULL_CIPHER + +/** + * \def MBEDTLS_CIPHER_PADDING_XXX + * + * Uncomment or comment macros to add support for specific padding modes + * in the cipher layer with cipher modes that support padding (e.g. CBC) + * + * If you disable all padding modes, only full blocks can be used with CBC. + * + * Enable padding modes in the cipher layer. + */ +// #define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#define MBEDTLS_CIPHER_PADDING_ZEROS + +/** + * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES + * + * Enable weak ciphersuites in SSL / TLS. + * Warning: Only do so when you know what you are doing. This allows for + * channels with virtually no security at all! + * + * This enables the following ciphersuites: + * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA + * + * Uncomment this macro to enable weak ciphersuites + */ +//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES + +/** + * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES + * + * Remove RC4 ciphersuites by default in SSL / TLS. + * This flag removes the ciphersuites based on RC4 from the default list as + * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to + * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them + * explicitly. + * + * Uncomment this macro to remove RC4 ciphersuites by default. + */ +#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES + +/** + * \def MBEDTLS_ECP_XXXX_ENABLED + * + * Enables specific curves within the Elliptic Curve module. + * By default all supported curves are enabled. + * + * Comment macros to disable the curve and functions for it + */ +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#define MBEDTLS_ECP_DP_BP512R1_ENABLED +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED + +/** + * \def MBEDTLS_ECP_NIST_OPTIM + * + * Enable specific 'modulo p' routines for each NIST prime. + * Depending on the prime and architecture, makes operations 4 to 8 times + * faster on the corresponding curve. + * + * Comment this macro to disable NIST curves optimisation. + */ +#define MBEDTLS_ECP_NIST_OPTIM + +/** + * \def MBEDTLS_ECDSA_DETERMINISTIC + * + * Enable deterministic ECDSA (RFC 6979). + * Standard ECDSA is "fragile" in the sense that lack of entropy when signing + * may result in a compromise of the long-term signing key. This is avoided by + * the deterministic variant. + * + * Requires: MBEDTLS_HMAC_DRBG_C + * + * Comment this macro to disable deterministic ECDSA. + */ +//#define MBEDTLS_ECDSA_DETERMINISTIC + +/** + * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + * + * Enable the PSK based ciphersuite modes in SSL / TLS. + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + * + * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + * + * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + * + * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + * + * Enable the RSA-only based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + */ +//#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + * + * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + * + * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + * + * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + * + * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + * + * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + * + * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Requires: MBEDTLS_ECJPAKE_C + * MBEDTLS_SHA256_C + * MBEDTLS_ECP_DP_SECP256R1_ENABLED + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + +/** + * \def MBEDTLS_PK_PARSE_EC_EXTENDED + * + * Enhance support for reading EC keys using variants of SEC1 not allowed by + * RFC 5915 and RFC 5480. + * + * Currently this means parsing the SpecifiedECDomain choice of EC + * parameters (only known groups are supported, not arbitrary domains, to + * avoid validation issues). + * + * Disable if you only need to support RFC 5915 + 5480 key formats. + */ +//#define MBEDTLS_PK_PARSE_EC_EXTENDED + +/** + * \def MBEDTLS_ERROR_STRERROR_DUMMY + * + * Enable a dummy error function to make use of mbedtls_strerror() in + * third party libraries easier when MBEDTLS_ERROR_C is disabled + * (no effect when MBEDTLS_ERROR_C is enabled). + * + * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're + * not using mbedtls_strerror() or error_strerror() in your application. + * + * Disable if you run into name conflicts and want to really remove the + * mbedtls_strerror() + */ +#define MBEDTLS_ERROR_STRERROR_DUMMY + +/** + * \def MBEDTLS_GENPRIME + * + * Enable the prime-number generation code. + * + * Requires: MBEDTLS_BIGNUM_C + */ +#define MBEDTLS_GENPRIME + +/** + * \def MBEDTLS_FS_IO + * + * Enable functions that use the filesystem. + */ +//#define MBEDTLS_FS_IO + +/** + * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + * + * Do not add default entropy sources. These are the platform specific, + * mbedtls_timing_hardclock and HAVEGE based poll functions. + * + * This is useful to have more control over the added entropy sources in an + * application. + * + * Uncomment this macro to prevent loading of default entropy functions. + */ +#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + +/** + * \def MBEDTLS_NO_PLATFORM_ENTROPY + * + * Do not use built-in platform entropy functions. + * This is useful if your platform does not support + * standards like the /dev/urandom or Windows CryptoAPI. + * + * Uncomment this macro to disable the built-in platform entropy functions. + */ +#define MBEDTLS_NO_PLATFORM_ENTROPY + +/** + * \def MBEDTLS_ENTROPY_FORCE_SHA256 + * + * Force the entropy accumulator to use a SHA-256 accumulator instead of the + * default SHA-512 based one (if both are available). + * + * Requires: MBEDTLS_SHA256_C + * + * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option + * if you have performance concerns. + * + * This option is only useful if both MBEDTLS_SHA256_C and + * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. + */ +//#define MBEDTLS_ENTROPY_FORCE_SHA256 + +/** + * \def MBEDTLS_MEMORY_DEBUG + * + * Enable debugging of buffer allocator memory issues. Automatically prints + * (to stderr) all (fatal) messages on memory allocation issues. Enables + * function for 'debug output' of allocated memory. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Uncomment this macro to let the buffer allocator print out error messages. + */ +//#define MBEDTLS_MEMORY_DEBUG + +/** + * \def MBEDTLS_MEMORY_BACKTRACE + * + * Include backtrace information with each allocated block. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * GLIBC-compatible backtrace() an backtrace_symbols() support + * + * Uncomment this macro to include backtrace information + */ +//#define MBEDTLS_MEMORY_BACKTRACE + +/** + * \def MBEDTLS_PK_RSA_ALT_SUPPORT + * + * Support external private RSA keys (eg from a HSM) in the PK layer. + * + * Comment this macro to disable support for external private RSA keys. + */ +//#define MBEDTLS_PK_RSA_ALT_SUPPORT + +/** + * \def MBEDTLS_PKCS1_V15 + * + * Enable support for PKCS#1 v1.5 encoding. + * + * Requires: MBEDTLS_RSA_C + * + * This enables support for PKCS#1 v1.5 operations. + */ +#define MBEDTLS_PKCS1_V15 + +/** + * \def MBEDTLS_PKCS1_V21 + * + * Enable support for PKCS#1 v2.1 encoding. + * + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C + * + * This enables support for RSAES-OAEP and RSASSA-PSS operations. + */ +//#define MBEDTLS_PKCS1_V21 + +/** + * \def MBEDTLS_RSA_NO_CRT + * + * Do not use the Chinese Remainder Theorem for the RSA private operation. + * + * Uncomment this macro to disable the use of CRT in RSA. + * + */ +//#define MBEDTLS_RSA_NO_CRT + +/** + * \def MBEDTLS_SELF_TEST + * + * Enable the checkup functions (*_self_test). + */ +//#define MBEDTLS_SELF_TEST + +/** + * \def MBEDTLS_SHA256_SMALLER + * + * Enable an implementation of SHA-256 that has lower ROM footprint but also + * lower performance. + * + * The default implementation is meant to be a reasonnable compromise between + * performance and size. This version optimizes more aggressively for size at + * the expense of performance. Eg on Cortex-M4 it reduces the size of + * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about + * 30%. + * + * Uncomment to enable the smaller implementation of SHA256. + */ +//#define MBEDTLS_SHA256_SMALLER + +/** + * \def MBEDTLS_SSL_AEAD_RANDOM_IV + * + * Generate a random IV rather than using the record sequence number as a + * nonce for ciphersuites using and AEAD algorithm (GCM or CCM). + * + * Using the sequence number is generally recommended. + * + * Uncomment this macro to always use random IVs with AEAD ciphersuites. + */ +//#define MBEDTLS_SSL_AEAD_RANDOM_IV + +/** + * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES + * + * Enable sending of alert messages in case of encountered errors as per RFC. + * If you choose not to send the alert messages, mbed TLS can still communicate + * with other servers, only debugging of failures is harder. + * + * The advantage of not sending alert messages, is that no information is given + * about reasons for failures thus preventing adversaries of gaining intel. + * + * Enable sending of all alert messages + */ +#define MBEDTLS_SSL_ALL_ALERT_MESSAGES + +/** + * \def MBEDTLS_SSL_DEBUG_ALL + * + * Enable the debug messages in SSL module for all issues. + * Debug messages have been disabled in some places to prevent timing + * attacks due to (unbalanced) debugging function calls. + * + * If you need all error reporting you should enable this during debugging, + * but remove this for production servers that should log as well. + * + * Uncomment this macro to report all debug messages on errors introducing + * a timing side-channel. + * + */ +//#define MBEDTLS_SSL_DEBUG_ALL + +/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC + * + * Enable support for Encrypt-then-MAC, RFC 7366. + * + * This allows peers that both support it to use a more robust protection for + * ciphersuites using CBC, providing deep resistance against timing attacks + * on the padding or underlying cipher. + * + * This only affects CBC ciphersuites, and is useless if none is defined. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Encrypt-then-MAC + */ +//#define MBEDTLS_SSL_ENCRYPT_THEN_MAC + +/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET + * + * Enable support for Extended Master Secret, aka Session Hash + * (draft-ietf-tls-session-hash-02). + * + * This was introduced as "the proper fix" to the Triple Handshake familiy of + * attacks, but it is recommended to always use it (even if you disable + * renegotiation), since it actually fixes a more fundamental issue in the + * original SSL/TLS design, and has implications beyond Triple Handshake. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Extended Master Secret. + */ +//#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET + +/** + * \def MBEDTLS_SSL_FALLBACK_SCSV + * + * Enable support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv-00). + * + * For servers, it is recommended to always enable this, unless you support + * only one version of TLS, or know for sure that none of your clients + * implements a fallback strategy. + * + * For clients, you only need this if you're using a fallback strategy, which + * is not recommended in the first place, unless you absolutely need it to + * interoperate with buggy (version-intolerant) servers. + * + * Comment this macro to disable support for FALLBACK_SCSV + */ +//#define MBEDTLS_SSL_FALLBACK_SCSV + +/** + * \def MBEDTLS_SSL_HW_RECORD_ACCEL + * + * Enable hooking functions in SSL module for hardware acceleration of + * individual records. + * + * Uncomment this macro to enable hooking functions. + */ +//#define MBEDTLS_SSL_HW_RECORD_ACCEL + +/** + * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING + * + * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. + * + * This is a countermeasure to the BEAST attack, which also minimizes the risk + * of interoperability issues compared to sending 0-length records. + * + * Comment this macro to disable 1/n-1 record splitting. + */ +//#define MBEDTLS_SSL_CBC_RECORD_SPLITTING + +/** + * \def MBEDTLS_SSL_RENEGOTIATION + * + * Disable support for TLS renegotiation. + * + * The two main uses of renegotiation are (1) refresh keys on long-lived + * connections and (2) client authentication after the initial handshake. + * If you don't need renegotiation, it's probably better to disable it, since + * it has been associated with security issues in the past and is easy to + * misuse/misunderstand. + * + * Comment this to disable support for renegotiation. + */ +#define MBEDTLS_SSL_RENEGOTIATION + +/** + * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + * + * Enable support for receiving and parsing SSLv2 Client Hello messages for the + * SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to enable support for SSLv2 Client Hello messages. + */ +//#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + +/** + * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + * + * Pick the ciphersuite according to the client's preferences rather than ours + * in the SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to respect client's ciphersuite order + */ +//#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + +/** + * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + * + * Enable support for RFC 6066 max_fragment_length extension in SSL. + * + * Comment this macro to disable support for the max_fragment_length extension + */ +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + +/** + * \def MBEDTLS_SSL_PROTO_SSL3 + * + * Enable support for SSL 3.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for SSL 3.0 + */ +//#define MBEDTLS_SSL_PROTO_SSL3 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1 + * + * Enable support for TLS 1.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.0 + */ +//#define MBEDTLS_SSL_PROTO_TLS1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_1 + * + * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 + */ +//#define MBEDTLS_SSL_PROTO_TLS1_1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_2 + * + * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). + * + * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C + * (Depends on ciphersuites) + * + * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 + */ +//#define MBEDTLS_SSL_PROTO_TLS1_2 + +/** + * \def MBEDTLS_SSL_PROTO_DTLS + * + * Enable support for DTLS (all available versions). + * + * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, + * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_1 + * or MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for DTLS + */ +//#define MBEDTLS_SSL_PROTO_DTLS + +/** + * \def MBEDTLS_SSL_ALPN + * + * Enable support for RFC 7301 Application Layer Protocol Negotiation. + * + * Comment this macro to disable support for ALPN. + */ +//#define MBEDTLS_SSL_ALPN + +/** + * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY + * + * Enable support for the anti-replay mechanism in DTLS. + * + * Requires: MBEDTLS_SSL_TLS_C + * MBEDTLS_SSL_PROTO_DTLS + * + * \warning Disabling this is often a security risk! + * See mbedtls_ssl_conf_dtls_anti_replay() for details. + * + * Comment this to disable anti-replay in DTLS. + */ +//#define MBEDTLS_SSL_DTLS_ANTI_REPLAY + +/** + * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Enable support for HelloVerifyRequest on DTLS servers. + * + * This feature is highly recommended to prevent DTLS servers being used as + * amplifiers in DoS attacks against other hosts. It should always be enabled + * unless you know for sure amplification cannot be a problem in the + * environment in which your server operates. + * + * \warning Disabling this can ba a security risk! (see above) + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Comment this to disable support for HelloVerifyRequest. + */ +//#define MBEDTLS_SSL_DTLS_HELLO_VERIFY + +/** + * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + * + * Enable server-side support for clients that reconnect from the same port. + * + * Some clients unexpectedly close the connection and try to reconnect using the + * same source port. This needs special support from the server to handle the + * new connection securely, as described in section 4.2.8 of RFC 6347. This + * flag enables that support. + * + * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Comment this to disable support for clients reusing the source port. + */ +//#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + +/** + * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT + * + * Enable support for a limit of records with bad MAC. + * + * See mbedtls_ssl_conf_dtls_badmac_limit(). + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + */ +//#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT + +/** + * \def MBEDTLS_SSL_SESSION_TICKETS + * + * Enable support for RFC 5077 session tickets in SSL. + * Client-side, provides full support for session tickets (maintainance of a + * session store remains the responsibility of the application, though). + * Server-side, you also need to provide callbacks for writing and parsing + * tickets, including authenticated encryption and key management. Example + * callbacks are provided by MBEDTLS_SSL_TICKET_C. + * + * Comment this macro to disable support for SSL session tickets + */ +//#define MBEDTLS_SSL_SESSION_TICKETS + +/** + * \def MBEDTLS_SSL_EXPORT_KEYS + * + * Enable support for exporting key block and master secret. + * This is required for certain users of TLS, e.g. EAP-TLS. + * + * Comment this macro to disable support for key export + */ +//#define MBEDTLS_SSL_EXPORT_KEYS + +/** + * \def MBEDTLS_SSL_SERVER_NAME_INDICATION + * + * Enable support for RFC 6066 server name indication (SNI) in SSL. + * + * Requires: MBEDTLS_X509_CRT_PARSE_C + * + * Comment this macro to disable support for server name indication in SSL + */ +//#define MBEDTLS_SSL_SERVER_NAME_INDICATION + +/** + * \def MBEDTLS_SSL_TRUNCATED_HMAC + * + * Enable support for RFC 6066 truncated HMAC in SSL. + * + * Comment this macro to disable support for truncated HMAC in SSL + */ +//#define MBEDTLS_SSL_TRUNCATED_HMAC + +/** + * \def MBEDTLS_THREADING_ALT + * + * Provide your own alternate threading implementation. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to allow your own alternate threading implementation. + */ +//#define MBEDTLS_THREADING_ALT + +/** + * \def MBEDTLS_THREADING_PTHREAD + * + * Enable the pthread wrapper layer for the threading layer. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to enable pthread mutexes. + */ +//#define MBEDTLS_THREADING_PTHREAD + +/** + * \def MBEDTLS_VERSION_FEATURES + * + * Allow run-time checking of compile-time enabled features. Thus allowing users + * to check at run-time if the library is for instance compiled with threading + * support via mbedtls_version_check_feature(). + * + * Requires: MBEDTLS_VERSION_C + * + * Comment this to disable run-time checking and save ROM space + */ +#define MBEDTLS_VERSION_FEATURES + +/** + * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an extension in a v1 or v2 certificate. + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + +/** + * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an unknown critical extension. + * + * \warning Depending on your PKI use, enabling this can be a security risk! + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + +/** + * \def MBEDTLS_X509_CHECK_KEY_USAGE + * + * Enable verification of the keyUsage extension (CA and leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused + * (intermediate) CA and leaf certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip keyUsage checking for both CA and leaf certificates. + */ +//#define MBEDTLS_X509_CHECK_KEY_USAGE + +/** + * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + * + * Enable verification of the extendedKeyUsage extension (leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip extendedKeyUsage checking for certificates. + */ +//#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + +/** + * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT + * + * Enable parsing and verification of X.509 certificates, CRLs and CSRS + * signed with RSASSA-PSS (aka PKCS#1 v2.1). + * + * Comment this macro to disallow using RSASSA-PSS in certificates. + */ +//#define MBEDTLS_X509_RSASSA_PSS_SUPPORT + +/** + * \def MBEDTLS_ZLIB_SUPPORT + * + * If set, the SSL/TLS module uses ZLIB to support compression and + * decompression of packet data. + * + * \warning TLS-level compression MAY REDUCE SECURITY! See for example the + * CRIME attack. Before enabling this option, you should examine with care if + * CRIME or similar exploits may be a applicable to your use case. + * + * \note Currently compression can't be used with DTLS. + * + * Used in: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This feature requires zlib library and headers to be present. + * + * Uncomment to enable use of ZLIB + */ +//#define MBEDTLS_ZLIB_SUPPORT +/* \} name SECTION: mbed TLS feature support */ + +/** + * \name SECTION: mbed TLS modules + * + * This section enables or disables entire modules in mbed TLS + * \{ + */ + +/** + * \def MBEDTLS_AESNI_C + * + * Enable AES-NI support on x86-64. + * + * Module: library/aesni.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the AES-NI instructions on x86-64 + */ +//#define MBEDTLS_AESNI_C + +/** + * \def MBEDTLS_AES_C + * + * Enable the AES block cipher. + * + * Module: library/aes.c + * Caller: library/ssl_tls.c + * library/pem.c + * library/ctr_drbg.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * + * PEM_PARSE uses AES for decrypting encrypted keys. + */ +#define MBEDTLS_AES_C + +/** + * \def MBEDTLS_ARC4_C + * + * Enable the ARCFOUR stream cipher. + * + * Module: library/arc4.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_ARC4_C + +/** + * \def MBEDTLS_ASN1_PARSE_C + * + * Enable the generic ASN1 parser. + * + * Module: library/asn1.c + * Caller: library/x509.c + * library/dhm.c + * library/pkcs12.c + * library/pkcs5.c + * library/pkparse.c + */ +#define MBEDTLS_ASN1_PARSE_C + +/** + * \def MBEDTLS_ASN1_WRITE_C + * + * Enable the generic ASN1 writer. + * + * Module: library/asn1write.c + * Caller: library/ecdsa.c + * library/pkwrite.c + * library/x509_create.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + */ +#define MBEDTLS_ASN1_WRITE_C + +/** + * \def MBEDTLS_BASE64_C + * + * Enable the Base64 module. + * + * Module: library/base64.c + * Caller: library/pem.c + * + * This module is required for PEM support (required by X.509). + */ +#define MBEDTLS_BASE64_C + +/** + * \def MBEDTLS_BIGNUM_C + * + * Enable the multi-precision integer library. + * + * Module: library/bignum.c + * Caller: library/dhm.c + * library/ecp.c + * library/ecdsa.c + * library/rsa.c + * library/ssl_tls.c + * + * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. + */ +#define MBEDTLS_BIGNUM_C + +/** + * \def MBEDTLS_BLOWFISH_C + * + * Enable the Blowfish block cipher. + * + * Module: library/blowfish.c + */ +//#define MBEDTLS_BLOWFISH_C + +/** + * \def MBEDTLS_CAMELLIA_C + * + * Enable the Camellia block cipher. + * + * Module: library/camellia.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +//#define MBEDTLS_CAMELLIA_C + +/** + * \def MBEDTLS_CCM_C + * + * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. + * + * Module: library/ccm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-CCM ciphersuites, if other requisites are + * enabled as well. + */ +#define MBEDTLS_CCM_C + +/** + * \def MBEDTLS_CERTS_C + * + * Enable the test certificates. + * + * Module: library/certs.c + * Caller: + * + * This module is used for testing (ssl_client/server). + */ +//#define MBEDTLS_CERTS_C + +/** + * \def MBEDTLS_CIPHER_C + * + * Enable the generic cipher layer. + * + * Module: library/cipher.c + * Caller: library/ssl_tls.c + * + * Uncomment to enable generic cipher wrappers. + */ +#define MBEDTLS_CIPHER_C + +/** + * \def MBEDTLS_CMAC_C + * + * Enable the CMAC (Cipher-based Message Authentication Code) mode for block + * ciphers. + * + * Module: library/cmac.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C + * + */ +#define MBEDTLS_CMAC_C + +/** + * \def MBEDTLS_CTR_DRBG_C + * + * Enable the CTR_DRBG AES-256-based random generator. + * + * Module: library/ctr_drbg.c + * Caller: + * + * Requires: MBEDTLS_AES_C + * + * This module provides the CTR_DRBG AES-256 random number generator. + */ +#define MBEDTLS_CTR_DRBG_C + +/** + * \def MBEDTLS_DEBUG_C + * + * Enable the debug functions. + * + * Module: library/debug.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module provides debugging functions. + */ +//#define MBEDTLS_DEBUG_C + +/** + * \def MBEDTLS_DES_C + * + * Enable the DES block cipher. + * + * Module: library/des.c + * Caller: library/pem.c + * library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * + * PEM_PARSE uses DES/3DES for decrypting encrypted keys. + */ +//#define MBEDTLS_DES_C + +/** + * \def MBEDTLS_DHM_C + * + * Enable the Diffie-Hellman-Merkle module. + * + * Module: library/dhm.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * DHE-RSA, DHE-PSK + */ +//#define MBEDTLS_DHM_C + +/** + * \def MBEDTLS_ECDH_C + * + * Enable the elliptic curve Diffie-Hellman library. + * + * Module: library/ecdh.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK + * + * Requires: MBEDTLS_ECP_C + */ +#define MBEDTLS_ECDH_C + +/** + * \def MBEDTLS_ECDSA_C + * + * Enable the elliptic curve DSA library. + * + * Module: library/ecdsa.c + * Caller: + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C + */ +#define MBEDTLS_ECDSA_C + +/** + * \def MBEDTLS_ECJPAKE_C + * + * Enable the elliptic curve J-PAKE library. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Module: library/ecjpake.c + * Caller: + * + * This module is used by the following key exchanges: + * ECJPAKE + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C + */ +//#define MBEDTLS_ECJPAKE_C + +/** + * \def MBEDTLS_ECP_C + * + * Enable the elliptic curve over GF(p) library. + * + * Module: library/ecp.c + * Caller: library/ecdh.c + * library/ecdsa.c + * library/ecjpake.c + * + * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED + */ +#define MBEDTLS_ECP_C + +/** + * \def MBEDTLS_ENTROPY_C + * + * Enable the platform-specific entropy code. + * + * Module: library/entropy.c + * Caller: + * + * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C + * + * This module provides a generic entropy pool + */ +//#define MBEDTLS_ENTROPY_C + +/** + * \def MBEDTLS_ERROR_C + * + * Enable error code to error string conversion. + * + * Module: library/error.c + * Caller: + * + * This module enables mbedtls_strerror(). + */ +//#define MBEDTLS_ERROR_C + +/** + * \def MBEDTLS_GCM_C + * + * Enable the Galois/Counter Mode (GCM) for AES. + * + * Module: library/gcm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other + * requisites are enabled as well. + */ +#define MBEDTLS_GCM_C + +/** + * \def MBEDTLS_HAVEGE_C + * + * Enable the HAVEGE random generator. + * + * Warning: the HAVEGE random generator is not suitable for virtualized + * environments + * + * Warning: the HAVEGE random generator is dependent on timing and specific + * processor traits. It is therefore not advised to use HAVEGE as + * your applications primary random generator or primary entropy pool + * input. As a secondary input to your entropy pool, it IS able add + * the (limited) extra entropy it provides. + * + * Module: library/havege.c + * Caller: + * + * Requires: MBEDTLS_TIMING_C + * + * Uncomment to enable the HAVEGE random generator. + */ +//#define MBEDTLS_HAVEGE_C + +/** + * \def MBEDTLS_HMAC_DRBG_C + * + * Enable the HMAC_DRBG random generator. + * + * Module: library/hmac_drbg.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * Uncomment to enable the HMAC_DRBG random number geerator. + */ +//#define MBEDTLS_HMAC_DRBG_C + +/** + * \def MBEDTLS_MD_C + * + * Enable the generic message digest layer. + * + * Module: library/mbedtls_md.c + * Caller: + * + * Uncomment to enable generic message digest wrappers. + */ +#define MBEDTLS_MD_C + +/** + * \def MBEDTLS_MD2_C + * + * Enable the MD2 hash algorithm. + * + * Module: library/mbedtls_md2.c + * Caller: + * + * Uncomment to enable support for (rare) MD2-signed X.509 certs. + */ +//#define MBEDTLS_MD2_C + +/** + * \def MBEDTLS_MD4_C + * + * Enable the MD4 hash algorithm. + * + * Module: library/mbedtls_md4.c + * Caller: + * + * Uncomment to enable support for (rare) MD4-signed X.509 certs. + */ +//#define MBEDTLS_MD4_C + +/** + * \def MBEDTLS_MD5_C + * + * Enable the MD5 hash algorithm. + * + * Module: library/mbedtls_md5.c + * Caller: library/mbedtls_md.c + * library/pem.c + * library/ssl_tls.c + * + * This module is required for SSL/TLS and X.509. + * PEM_PARSE uses MD5 for decrypting encrypted keys. + */ +#define MBEDTLS_MD5_C + + +/** + * \def MBEDTLS_NET_C + * + * Enable the TCP/IP networking routines. + * + * Module: library/net.c + * + * This module provides TCP/IP networking routines. + */ +//#define MBEDTLS_NET_C + +/** + * \def MBEDTLS_OID_C + * + * Enable the OID database. + * + * Module: library/oid.c + * Caller: library/asn1write.c + * library/pkcs5.c + * library/pkparse.c + * library/pkwrite.c + * library/rsa.c + * library/x509.c + * library/x509_create.c + * library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + * + * This modules translates between OIDs and internal values. + */ +//#define MBEDTLS_OID_C + +/** + * \def MBEDTLS_PADLOCK_C + * + * Enable VIA Padlock support on x86. + * + * Module: library/padlock.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the VIA PadLock on x86. + */ +//#define MBEDTLS_PADLOCK_C + +/** + * \def MBEDTLS_PEM_PARSE_C + * + * Enable PEM decoding / parsing. + * + * Module: library/pem.c + * Caller: library/dhm.c + * library/pkparse.c + * library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for decoding / parsing PEM files. + */ +//#define MBEDTLS_PEM_PARSE_C + +/** + * \def MBEDTLS_PEM_WRITE_C + * + * Enable PEM encoding / writing. + * + * Module: library/pem.c + * Caller: library/pkwrite.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for encoding / writing PEM files. + */ +//#define MBEDTLS_PEM_WRITE_C + +/** + * \def MBEDTLS_PK_C + * + * Enable the generic public (asymetric) key layer. + * + * Module: library/pk.c + * Caller: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C + * + * Uncomment to enable generic public key wrappers. + */ +//#define MBEDTLS_PK_C + +/** + * \def MBEDTLS_PK_PARSE_C + * + * Enable the generic public (asymetric) key parser. + * + * Module: library/pkparse.c + * Caller: library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key parse functions. + */ +//#define MBEDTLS_PK_PARSE_C + +/** + * \def MBEDTLS_PK_WRITE_C + * + * Enable the generic public (asymetric) key writer. + * + * Module: library/pkwrite.c + * Caller: library/x509write.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key write functions. + */ +//#define MBEDTLS_PK_WRITE_C + +/** + * \def MBEDTLS_PKCS5_C + * + * Enable PKCS#5 functions. + * + * Module: library/pkcs5.c + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the PKCS#5 functions. + */ +//#define MBEDTLS_PKCS5_C + +/** + * \def MBEDTLS_PKCS11_C + * + * Enable wrapper for PKCS#11 smartcard support. + * + * Module: library/pkcs11.c + * Caller: library/pk.c + * + * Requires: MBEDTLS_PK_C + * + * This module enables SSL/TLS PKCS #11 smartcard support. + * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) + */ +//#define MBEDTLS_PKCS11_C + +/** + * \def MBEDTLS_PKCS12_C + * + * Enable PKCS#12 PBE functions. + * Adds algorithms for parsing PKCS#8 encrypted private keys + * + * Module: library/pkcs12.c + * Caller: library/pkparse.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * Can use: MBEDTLS_ARC4_C + * + * This module enables PKCS#12 functions. + */ +//#define MBEDTLS_PKCS12_C + +/** + * \def MBEDTLS_PLATFORM_C + * + * Enable the platform abstraction layer that allows you to re-assign + * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). + * + * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT + * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned + * above to be specified at runtime or compile time respectively. + * + * \note This abstraction layer must be enabled on Windows (including MSYS2) + * as other module rely on it for a fixed snprintf implementation. + * + * Module: library/platform.c + * Caller: Most other .c files + * + * This module enables abstraction of common (libc) functions. + */ +#define MBEDTLS_PLATFORM_C + +/** + * \def MBEDTLS_RIPEMD160_C + * + * Enable the RIPEMD-160 hash algorithm. + * + * Module: library/mbedtls_ripemd160.c + * Caller: library/mbedtls_md.c + * + */ +//#define MBEDTLS_RIPEMD160_C + +/** + * \def MBEDTLS_RSA_C + * + * Enable the RSA public-key cryptosystem. + * + * Module: library/rsa.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509.c + * + * This module is used by the following key exchanges: + * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C + */ +//#define MBEDTLS_RSA_C + +/** + * \def MBEDTLS_SHA1_C + * + * Enable the SHA1 cryptographic hash algorithm. + * + * Module: library/mbedtls_sha1.c + * Caller: library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509write_crt.c + * + * This module is required for SSL/TLS and SHA1-signed certificates. + */ +//#define MBEDTLS_SHA1_C + +/** + * \def MBEDTLS_SHA256_C + * + * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. + * + * Module: library/mbedtls_sha256.c + * Caller: library/entropy.c + * library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module adds support for SHA-224 and SHA-256. + * This module is required for the SSL/TLS 1.2 PRF function. + */ +#define MBEDTLS_SHA256_C + +/** + * \def MBEDTLS_SHA512_C + * + * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. + * + * Module: library/mbedtls_sha512.c + * Caller: library/entropy.c + * library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This module adds support for SHA-384 and SHA-512. + */ +#define MBEDTLS_SHA512_C + +/** + * \def MBEDTLS_SSL_CACHE_C + * + * Enable simple SSL cache implementation. + * + * Module: library/ssl_cache.c + * Caller: + * + * Requires: MBEDTLS_SSL_CACHE_C + */ +//#define MBEDTLS_SSL_CACHE_C + +/** + * \def MBEDTLS_SSL_COOKIE_C + * + * Enable basic implementation of DTLS cookies for hello verification. + * + * Module: library/ssl_cookie.c + * Caller: + */ +//#define MBEDTLS_SSL_COOKIE_C + +/** + * \def MBEDTLS_SSL_TICKET_C + * + * Enable an implementation of TLS server-side callbacks for session tickets. + * + * Module: library/ssl_ticket.c + * Caller: + * + * Requires: MBEDTLS_CIPHER_C + */ +//#define MBEDTLS_SSL_TICKET_C + +/** + * \def MBEDTLS_SSL_CLI_C + * + * Enable the SSL/TLS client code. + * + * Module: library/ssl_cli.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS client support. + */ +//#define MBEDTLS_SSL_CLI_C + +/** + * \def MBEDTLS_SSL_SRV_C + * + * Enable the SSL/TLS server code. + * + * Module: library/ssl_srv.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS server support. + */ +//#define MBEDTLS_SSL_SRV_C + +/** + * \def MBEDTLS_SSL_TLS_C + * + * Enable the generic SSL/TLS code. + * + * Module: library/ssl_tls.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * and at least one of the MBEDTLS_SSL_PROTO_XXX defines + * + * This module is required for SSL/TLS. + */ +//define MBEDTLS_SSL_TLS_C + +/** + * \def MBEDTLS_THREADING_C + * + * Enable the threading abstraction layer. + * By default mbed TLS assumes it is used in a non-threaded environment or that + * contexts are not shared between threads. If you do intend to use contexts + * between threads, you will need to enable this layer to prevent race + * conditions. + * + * Module: library/threading.c + * + * This allows different threading implementations (self-implemented or + * provided). + * + * You will have to enable either MBEDTLS_THREADING_ALT or + * MBEDTLS_THREADING_PTHREAD. + * + * Enable this layer to allow use of mutexes within mbed TLS + */ +//#define MBEDTLS_THREADING_C + +/** + * \def MBEDTLS_TIMING_C + * + * Enable the portable timing interface. + * + * Module: library/timing.c + * Caller: library/havege.c + * + * This module is used by the HAVEGE random number generator. + */ +//#define MBEDTLS_TIMING_C + +/** + * \def MBEDTLS_VERSION_C + * + * Enable run-time version information. + * + * Module: library/version.c + * + * This module provides run-time version information. + */ +#define MBEDTLS_VERSION_C + +/** + * \def MBEDTLS_X509_USE_C + * + * Enable X.509 core for using certificates. + * + * Module: library/x509.c + * Caller: library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, + * MBEDTLS_PK_PARSE_C + * + * This module is required for the X.509 parsing modules. + */ +//#define MBEDTLS_X509_USE_C + +/** + * \def MBEDTLS_X509_CRT_PARSE_C + * + * Enable X.509 certificate parsing. + * + * Module: library/mbedtls_x509_crt.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 certificate parsing. + */ +//#define MBEDTLS_X509_CRT_PARSE_C + +/** + * \def MBEDTLS_X509_CRL_PARSE_C + * + * Enable X.509 CRL parsing. + * + * Module: library/mbedtls_x509_crl.c + * Caller: library/mbedtls_x509_crt.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 CRL parsing. + */ +//#define MBEDTLS_X509_CRL_PARSE_C + +/** + * \def MBEDTLS_X509_CSR_PARSE_C + * + * Enable X.509 Certificate Signing Request (CSR) parsing. + * + * Module: library/mbedtls_x509_csr.c + * Caller: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is used for reading X.509 certificate request. + */ +//#define MBEDTLS_X509_CSR_PARSE_C + +/** + * \def MBEDTLS_X509_CREATE_C + * + * Enable X.509 core for creating certificates. + * + * Module: library/x509_create.c + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C + * + * This module is the basis for creating X.509 certificates and CSRs. + */ +//#define MBEDTLS_X509_CREATE_C + +/** + * \def MBEDTLS_X509_CRT_WRITE_C + * + * Enable creating X.509 certificates. + * + * Module: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate creation. + */ +//#define MBEDTLS_X509_CRT_WRITE_C + +/** + * \def MBEDTLS_X509_CSR_WRITE_C + * + * Enable creating X.509 Certificate Signing Requests (CSR). + * + * Module: library/x509_csr_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate request writing. + */ +//#define MBEDTLS_X509_CSR_WRITE_C + +/** + * \def MBEDTLS_XTEA_C + * + * Enable the XTEA block cipher. + * + * Module: library/xtea.c + * Caller: + */ +//#define MBEDTLS_XTEA_C + +/* \} name SECTION: mbed TLS modules */ + +/** + * \name SECTION: Module configuration options + * + * This section allows for the setting of module specific sizes and + * configuration options. The default values are already present in the + * relevant header files and should suffice for the regular use cases. + * + * Our advice is to enable options and change their values here + * only if you have a good reason and know the consequences. + * + * Please check the respective header file for documentation on these + * parameters (to prevent duplicate documentation). + * \{ + */ + +/* MPI / BIGNUM options */ +//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ +//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ + +/* CTR_DRBG options */ +//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ +//#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* HMAC_DRBG options */ +//#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* ECP options */ +//#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ +//#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ + +/* Entropy options */ +//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ +//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ + +/* Memory buffer allocator options */ +#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ + +/* Platform options */ +#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ +#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ +#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ + +/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ +/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ +//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ + +/* SSL Cache options */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ + +/* SSL options */ +//#define MBEDTLS_SSL_MAX_CONTENT_LEN 3072 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ +//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ +//#define MBEDTLS_PSK_MAX_LEN 16 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ +//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ + +/** + * Complete list of ciphersuites to use, in order of preference. + * + * \warning No dependency checking is done on that field! This option can only + * be used to restrict the set of available ciphersuites. It is your + * responsibility to make sure the needed modules are active. + * + * Use this to save a few hundred bytes of ROM (default ordering of all + * available ciphersuites) and a few to a few hundred bytes of RAM. + * + * The value below is only an example, not the default. + */ +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,\ + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,\ + MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA,\ + MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + +/* X509 options */ +//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ + +/* \} name SECTION: Module configuration options */ + +#if defined(TARGET_LIKE_MBED) +#include "mbedtls/target_config.h" +#endif + +/* + * Allow user to override any previous default. + * + * Use two macro names for that, as: + * - with yotta the prefix YOTTA_CFG_ is forced + * - without yotta is looks weird to have a YOTTA prefix. + */ +#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) +#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE +#elif defined(MBEDTLS_USER_CONFIG_FILE) +#include MBEDTLS_USER_CONFIG_FILE +#endif + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/asn1write.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/asn1write.c new file mode 100644 index 0000000..284bb11 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/asn1write.c @@ -0,0 +1,392 @@ +/* + * ASN.1 buffer writing functionality + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ASN1_WRITE_C) + +#include "mbedtls/asn1write.h" + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len ) +{ + size_t upper_bound = 0xFFFFFFFF; + + if( len < 0x80 ) + { + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = (unsigned char) len; + return( 1 ); + } + + if( len <= 0xFF ) + { + if( *p - start < 2 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = (unsigned char) len; + *--(*p) = 0x81; + return( 2 ); + } + + if( len <= 0xFFFF ) + { + if( *p - start < 3 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = ( len ) & 0xFF; + *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = 0x82; + return( 3 ); + } + + if( len <= 0xFFFFFF ) + { + if( *p - start < 4 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = ( len ) & 0xFF; + *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = ( len >> 16 ) & 0xFF; + *--(*p) = 0x83; + return( 4 ); + } + + if( len <= upper_bound ) + { + if( *p - start < 5 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = ( len ) & 0xFF; + *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = ( len >> 16 ) & 0xFF; + *--(*p) = ( len >> 24 ) & 0xFF; + *--(*p) = 0x84; + return( 5 ); + } + + return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); +} + +int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag ) +{ + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = tag; + + return( 1 ); +} + +int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t size ) +{ + size_t len = 0; + + if( *p < start || (size_t)( *p - start ) < size ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len = size; + (*p) -= len; + memcpy( *p, buf, len ); + + return( (int) len ); +} + +#if defined(MBEDTLS_BIGNUM_C) +int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X ) +{ + int ret; + size_t len = 0; + + // Write the MPI + // + len = mbedtls_mpi_size( X ); + + if( *p < start || (size_t)( *p - start ) < len ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + (*p) -= len; + MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( X, *p, len ) ); + + // DER format assumes 2s complement for numbers, so the leftmost bit + // should be 0 for positive numbers and 1 for negative numbers. + // + if( X->s ==1 && **p & 0x80 ) + { + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = 0x00; + len += 1; + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_INTEGER ) ); + + ret = (int) len; + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_BIGNUM_C */ + +int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start ) +{ + int ret; + size_t len = 0; + + // Write NULL + // + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, 0) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_NULL ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) oid, oid_len ) ); + MBEDTLS_ASN1_CHK_ADD( len , mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len , mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_OID ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, + const char *oid, size_t oid_len, + size_t par_len ) +{ + int ret; + size_t len = 0; + + if( par_len == 0 ) + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_null( p, start ) ); + else + len += par_len; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( p, start, oid, oid_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean ) +{ + int ret; + size_t len = 0; + + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = (boolean) ? 255 : 0; + len++; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_BOOLEAN ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ) +{ + int ret; + size_t len = 0; + + // TODO negative values and values larger than 128 + // DER format assumes 2s complement for numbers, so the leftmost bit + // should be 0 for positive numbers and 1 for negative numbers. + // + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len += 1; + *--(*p) = val; + + if( val > 0 && **p & 0x80 ) + { + if( *p - start < 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + *--(*p) = 0x00; + len += 1; + } + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_INTEGER ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) text, text_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_PRINTABLE_STRING ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, + (const unsigned char *) text, text_len ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_IA5_STRING ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t bits ) +{ + int ret; + size_t len = 0, size; + + size = ( bits / 8 ) + ( ( bits % 8 ) ? 1 : 0 ); + + // Calculate byte length + // + if( *p < start || (size_t)( *p - start ) < size + 1 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + len = size + 1; + (*p) -= size; + memcpy( *p, buf, size ); + + // Write unused bits + // + *--(*p) = (unsigned char) (size * 8 - bits); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_BIT_STRING ) ); + + return( (int) len ); +} + +int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start, + const unsigned char *buf, size_t size ) +{ + int ret; + size_t len = 0; + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, buf, size ) ); + + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_OCTET_STRING ) ); + + return( (int) len ); +} + +mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data **head, + const char *oid, size_t oid_len, + const unsigned char *val, + size_t val_len ) +{ + mbedtls_asn1_named_data *cur; + + if( ( cur = mbedtls_asn1_find_named_data( *head, oid, oid_len ) ) == NULL ) + { + // Add new entry if not present yet based on OID + // + cur = (mbedtls_asn1_named_data*)mbedtls_calloc( 1, + sizeof(mbedtls_asn1_named_data) ); + if( cur == NULL ) + return( NULL ); + + cur->oid.len = oid_len; + cur->oid.p = mbedtls_calloc( 1, oid_len ); + if( cur->oid.p == NULL ) + { + mbedtls_free( cur ); + return( NULL ); + } + + memcpy( cur->oid.p, oid, oid_len ); + + cur->val.len = val_len; + cur->val.p = mbedtls_calloc( 1, val_len ); + if( cur->val.p == NULL ) + { + mbedtls_free( cur->oid.p ); + mbedtls_free( cur ); + return( NULL ); + } + + cur->next = *head; + *head = cur; + } + else if( cur->val.len < val_len ) + { + /* + * Enlarge existing value buffer if needed + * Preserve old data until the allocation succeeded, to leave list in + * a consistent state in case allocation fails. + */ + void *p = mbedtls_calloc( 1, val_len ); + if( p == NULL ) + return( NULL ); + + mbedtls_free( cur->val.p ); + cur->val.p = p; + cur->val.len = val_len; + } + + if( val != NULL ) + memcpy( cur->val.p, val, val_len ); + + return( cur ); +} +#endif /* MBEDTLS_ASN1_WRITE_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/ssl_srv.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/ssl_srv.c new file mode 100644 index 0000000..ea29680 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/replacements/ssl_srv.c @@ -0,0 +1,3926 @@ +/* + * SSLv3/TLSv1 server-side functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_SSL_SRV_C) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_internal.h" + +#include + +#if defined(MBEDTLS_ECP_C) +#include "mbedtls/ecp.h" +#endif + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} +#endif + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) +int mbedtls_ssl_set_client_transport_id( mbedtls_ssl_context *ssl, + const unsigned char *info, + size_t ilen ) +{ + if( ssl->conf->endpoint != MBEDTLS_SSL_IS_SERVER ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + mbedtls_free( ssl->cli_id ); + + if( ( ssl->cli_id = mbedtls_calloc( 1, ilen ) ) == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + memcpy( ssl->cli_id, info, ilen ); + ssl->cli_id_len = ilen; + + return( 0 ); +} + +void mbedtls_ssl_conf_dtls_cookies( mbedtls_ssl_config *conf, + mbedtls_ssl_cookie_write_t *f_cookie_write, + mbedtls_ssl_cookie_check_t *f_cookie_check, + void *p_cookie ) +{ + conf->f_cookie_write = f_cookie_write; + conf->f_cookie_check = f_cookie_check; + conf->p_cookie = p_cookie; +} +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +static int ssl_parse_servername_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + size_t servername_list_size, hostname_len; + const unsigned char *p; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "parse ServerName extension" ) ); + + servername_list_size = ( ( buf[0] << 8 ) | ( buf[1] ) ); + if( servername_list_size + 2 != len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + p = buf + 2; + while( servername_list_size > 0 ) + { + hostname_len = ( ( p[1] << 8 ) | p[2] ); + if( hostname_len + 3 > servername_list_size ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( p[0] == MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ) + { + ret = ssl->conf->f_sni( ssl->conf->p_sni, + ssl, p + 3, hostname_len ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_sni_wrapper", ret ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + return( 0 ); + } + + servername_list_size -= hostname_len + 3; + p += hostname_len + 3; + } + + if( servername_list_size != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +static int ssl_parse_renegotiation_info( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Check verify-data in constant-time. The length OTOH is no secret */ + if( len != 1 + ssl->verify_data_len || + buf[0] != ssl->verify_data_len || + mbedtls_ssl_safer_memcmp( buf + 1, ssl->peer_verify_data, + ssl->verify_data_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching renegotiation info" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } + else +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + { + if( len != 1 || buf[0] != 0x0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-zero length renegotiation info" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + } + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +static int ssl_parse_signature_algorithms_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t sig_alg_list_size; + const unsigned char *p; + const unsigned char *end = buf + len; + const int *md_cur; + + + sig_alg_list_size = ( ( buf[0] << 8 ) | ( buf[1] ) ); + if( sig_alg_list_size + 2 != len || + sig_alg_list_size % 2 != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * For now, ignore the SignatureAlgorithm part and rely on offered + * ciphersuites only for that part. To be fixed later. + * + * So, just look at the HashAlgorithm part. + */ + for( md_cur = ssl->conf->sig_hashes; *md_cur != MBEDTLS_MD_NONE; md_cur++ ) { + for( p = buf + 2; p < end; p += 2 ) { + if( *md_cur == (int) mbedtls_ssl_md_alg_from_hash( p[0] ) ) { + ssl->handshake->sig_alg = p[0]; + goto have_sig_alg; + } + } + } + + /* Some key echanges do not need signatures at all */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "no signature_algorithm in common" ) ); + return( 0 ); + +have_sig_alg: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext: %d", + ssl->handshake->sig_alg ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static int ssl_parse_supported_elliptic_curves( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t list_size, our_size; + const unsigned char *p; + const mbedtls_ecp_curve_info *curve_info, **curves; + + list_size = ( ( buf[0] << 8 ) | ( buf[1] ) ); + if( list_size + 2 != len || + list_size % 2 != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* Should never happen unless client duplicates the extension */ + if( ssl->handshake->curves != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* Don't allow our peer to make us allocate too much memory, + * and leave room for a final 0 */ + our_size = list_size / 2 + 1; + if( our_size > MBEDTLS_ECP_DP_MAX ) + our_size = MBEDTLS_ECP_DP_MAX; + + if( ( curves = mbedtls_calloc( our_size, sizeof( *curves ) ) ) == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + ssl->handshake->curves = curves; + + p = buf + 2; + while( list_size > 0 && our_size > 1 ) + { + curve_info = mbedtls_ecp_curve_info_from_tls_id( ( p[0] << 8 ) | p[1] ); + + if( curve_info != NULL ) + { + *curves++ = curve_info; + our_size--; + } + + list_size -= 2; + p += 2; + } + + return( 0 ); +} + +static int ssl_parse_supported_point_formats( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + size_t list_size; + const unsigned char *p; + + list_size = buf[0]; + if( list_size + 1 != len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + p = buf + 1; + while( list_size > 0 ) + { + if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED || + p[0] == MBEDTLS_ECP_PF_COMPRESSED ) + { +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) + ssl->handshake->ecdh_ctx.point_format = p[0]; +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl->handshake->ecjpake_ctx.point_format = p[0]; +#endif + MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) ); + return( 0 ); + } + + list_size--; + p++; + } + + return( 0 ); +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret; + + if( mbedtls_ecjpake_check( &ssl->handshake->ecjpake_ctx ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip ecjpake kkpp extension" ) ); + return( 0 ); + } + + if( ( ret = mbedtls_ecjpake_read_round_one( &ssl->handshake->ecjpake_ctx, + buf, len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_one", ret ); + return( ret ); + } + + /* Only mark the extension as OK when we're sure it is */ + ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK; + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +static int ssl_parse_max_fragment_length_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 1 || buf[0] >= MBEDTLS_SSL_MAX_FRAG_LEN_INVALID ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->session_negotiate->mfl_code = buf[0]; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +static int ssl_parse_truncated_hmac_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ((void) buf); + + if( ssl->conf->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_ENABLED ) + ssl->session_negotiate->trunc_hmac = MBEDTLS_SSL_TRUNC_HMAC_ENABLED; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +static int ssl_parse_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ((void) buf); + + if( ssl->conf->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED && + ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl->session_negotiate->encrypt_then_mac = MBEDTLS_SSL_ETM_ENABLED; + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +static int ssl_parse_extended_ms_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + if( len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ((void) buf); + + if( ssl->conf->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED && + ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + ssl->handshake->extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; + } + + return( 0 ); +} +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t len ) +{ + int ret; + mbedtls_ssl_session session; + + mbedtls_ssl_session_init( &session ); + + if( ssl->conf->f_ticket_parse == NULL || + ssl->conf->f_ticket_write == NULL ) + { + return( 0 ); + } + + /* Remember the client asked us to send a new ticket */ + ssl->handshake->new_session_ticket = 1; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket length: %d", len ) ); + + if( len == 0 ) + return( 0 ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket rejected: renegotiating" ) ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + /* + * Failures are ok: just ignore the ticket and proceed. + */ + if( ( ret = ssl->conf->f_ticket_parse( ssl->conf->p_ticket, &session, + buf, len ) ) != 0 ) + { + mbedtls_ssl_session_free( &session ); + + if( ret == MBEDTLS_ERR_SSL_INVALID_MAC ) + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket is not authentic" ) ); + else if( ret == MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED ) + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket is expired" ) ); + else + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_ticket_parse", ret ); + + return( 0 ); + } + + /* + * Keep the session ID sent by the client, since we MUST send it back to + * inform them we're accepting the ticket (RFC 5077 section 3.4) + */ + session.id_len = ssl->session_negotiate->id_len; + memcpy( &session.id, ssl->session_negotiate->id, session.id_len ); + + mbedtls_ssl_session_free( ssl->session_negotiate ); + memcpy( ssl->session_negotiate, &session, sizeof( mbedtls_ssl_session ) ); + + /* Zeroize instead of free as we copied the content */ + mbedtls_zeroize( &session, sizeof( mbedtls_ssl_session ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from ticket" ) ); + + ssl->handshake->resume = 1; + + /* Don't send a new ticket after all, this one is OK */ + ssl->handshake->new_session_ticket = 0; + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) +static int ssl_parse_alpn_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, size_t len ) +{ + size_t list_len, cur_len, ours_len; + const unsigned char *theirs, *start, *end; + const char **ours; + + /* If ALPN not configured, just ignore the extension */ + if( ssl->conf->alpn_list == NULL ) + return( 0 ); + + /* + * opaque ProtocolName<1..2^8-1>; + * + * struct { + * ProtocolName protocol_name_list<2..2^16-1> + * } ProtocolNameList; + */ + + /* Min length is 2 (list_len) + 1 (name_len) + 1 (name) */ + if( len < 4 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + list_len = ( buf[0] << 8 ) | buf[1]; + if( list_len != len - 2 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + /* + * Use our order of preference + */ + start = buf + 2; + end = buf + len; + for( ours = ssl->conf->alpn_list; *ours != NULL; ours++ ) + { + ours_len = strlen( *ours ); + for( theirs = start; theirs != end; theirs += cur_len ) + { + /* If the list is well formed, we should get equality first */ + if( theirs > end ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + cur_len = *theirs++; + + /* Empty strings MUST NOT be included */ + if( cur_len == 0 ) + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + + if( cur_len == ours_len && + memcmp( theirs, *ours, cur_len ) == 0 ) + { + ssl->alpn_chosen = *ours; + return( 0 ); + } + } + } + + /* If we get there, no match was found */ + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); +} +#endif /* MBEDTLS_SSL_ALPN */ + +/* + * Auxiliary functions for ServerHello parsing and related actions + */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/* + * Return 0 if the given key uses one of the acceptable curves, -1 otherwise + */ +#if defined(MBEDTLS_ECDSA_C) +static int ssl_check_key_curve( mbedtls_pk_context *pk, + const mbedtls_ecp_curve_info **curves ) +{ + const mbedtls_ecp_curve_info **crv = curves; + mbedtls_ecp_group_id grp_id = mbedtls_pk_ec( *pk )->grp.id; + + while( *crv != NULL ) + { + if( (*crv)->grp_id == grp_id ) + return( 0 ); + crv++; + } + + return( -1 ); +} +#endif /* MBEDTLS_ECDSA_C */ + +/* + * Try picking a certificate for this ciphersuite, + * return 0 on success and -1 on failure. + */ +static int ssl_pick_cert( mbedtls_ssl_context *ssl, + const mbedtls_ssl_ciphersuite_t * ciphersuite_info ) +{ + mbedtls_ssl_key_cert *cur, *list, *fallback = NULL; + mbedtls_pk_type_t pk_alg = mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info ); + uint32_t flags; + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_key_cert != NULL ) + list = ssl->handshake->sni_key_cert; + else +#endif + list = ssl->conf->key_cert; + + if( pk_alg == MBEDTLS_PK_NONE ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite requires certificate" ) ); + + if( list == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server has no certificate" ) ); + return( -1 ); + } + + for( cur = list; cur != NULL; cur = cur->next ) + { + MBEDTLS_SSL_DEBUG_CRT( 3, "candidate certificate chain, certificate", + cur->cert ); + + if( ! mbedtls_pk_can_do( cur->key, pk_alg ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: key type" ) ); + continue; + } + + /* + * This avoids sending the client a cert it'll reject based on + * keyUsage or other extensions. + * + * It also allows the user to provision different certificates for + * different uses based on keyUsage, eg if they want to avoid signing + * and decrypting with the same RSA key. + */ + if( mbedtls_ssl_check_cert_usage( cur->cert, ciphersuite_info, + MBEDTLS_SSL_IS_SERVER, &flags ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: " + "(extended) key usage extension" ) ); + continue; + } + +#if defined(MBEDTLS_ECDSA_C) + if( pk_alg == MBEDTLS_PK_ECDSA && + ssl_check_key_curve( cur->key, ssl->handshake->curves ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: elliptic curve" ) ); + continue; + } +#endif + + /* + * Try to select a SHA-1 certificate for pre-1.2 clients, but still + * present them a SHA-higher cert rather than failing if it's the only + * one we got that satisfies the other conditions. + */ + if( ssl->minor_ver < MBEDTLS_SSL_MINOR_VERSION_3 && + cur->cert->sig_md != MBEDTLS_MD_SHA1 ) + { + if( fallback == NULL ) + fallback = cur; + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate not preferred: " + "sha-2 with pre-TLS 1.2 client" ) ); + continue; + } + } + + /* If we get there, we got a winner */ + break; + } + + if( cur == NULL ) + cur = fallback; + + /* Do not update ssl->handshake->key_cert unless there is a match */ + if( cur != NULL ) + { + ssl->handshake->key_cert = cur; + MBEDTLS_SSL_DEBUG_CRT( 3, "selected certificate chain, certificate", + ssl->handshake->key_cert->cert ); + return( 0 ); + } + + return( -1 ); +} +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +/* + * Check if a given ciphersuite is suitable for use with our config/keys/etc + * Sets ciphersuite_info only if the suite matches. + */ +static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id, + const mbedtls_ssl_ciphersuite_t **ciphersuite_info ) +{ + const mbedtls_ssl_ciphersuite_t *suite_info; + + suite_info = mbedtls_ssl_ciphersuite_from_id( suite_id ); + if( suite_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "trying ciphersuite: %s", suite_info->name ) ); + + if( suite_info->min_minor_ver > ssl->minor_ver || + suite_info->max_minor_ver < ssl->minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: version" ) ); + return( 0 ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( suite_info->flags & MBEDTLS_CIPHERSUITE_NODTLS ) ) + return( 0 ); +#endif + +#if defined(MBEDTLS_ARC4_C) + if( ssl->conf->arc4_disabled == MBEDTLS_SSL_ARC4_DISABLED && + suite_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: rc4" ) ); + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( suite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE && + ( ssl->handshake->cli_exts & MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: ecjpake " + "not configured or ext missing" ) ); + return( 0 ); + } +#endif + + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) + if( mbedtls_ssl_ciphersuite_uses_ec( suite_info ) && + ( ssl->handshake->curves == NULL || + ssl->handshake->curves[0] == NULL ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: " + "no common elliptic curve" ) ); + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) + /* If the ciphersuite requires a pre-shared key and we don't + * have one, skip it now rather than failing later */ + if( mbedtls_ssl_ciphersuite_uses_psk( suite_info ) && + ssl->conf->f_psk == NULL && + ( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL || + ssl->conf->psk_identity_len == 0 || ssl->conf->psk_len == 0 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: no pre-shared key" ) ); + return( 0 ); + } +#endif + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + /* + * Final check: if ciphersuite requires us to have a + * certificate/key of a particular type: + * - select the appropriate certificate if we have one, or + * - try the next ciphersuite if we don't + * This must be done last since we modify the key_cert list. + */ + if( ssl_pick_cert( ssl, suite_info ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: " + "no suitable certificate" ) ); + return( 0 ); + } +#endif + + *ciphersuite_info = suite_info; + return( 0 ); +} + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) +static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl ) +{ + int ret, got_common_suite; + unsigned int i, j; + size_t n; + unsigned int ciph_len, sess_len, chal_len; + unsigned char *buf, *p; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client hello v2" ) ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "client hello v2 illegal for renegotiation" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + buf = ssl->in_hdr; + + MBEDTLS_SSL_DEBUG_BUF( 4, "record header", buf, 5 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v2, message type: %d", + buf[2] ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v2, message len.: %d", + ( ( buf[0] & 0x7F ) << 8 ) | buf[1] ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v2, max. version: [%d:%d]", + buf[3], buf[4] ) ); + + /* + * SSLv2 Client Hello + * + * Record layer: + * 0 . 1 message length + * + * SSL layer: + * 2 . 2 message type + * 3 . 4 protocol version + */ + if( buf[2] != MBEDTLS_SSL_HS_CLIENT_HELLO || + buf[3] != MBEDTLS_SSL_MAJOR_VERSION_3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + n = ( ( buf[0] << 8 ) | buf[1] ) & 0x7FFF; + + if( n < 17 || n > 512 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; + ssl->minor_ver = ( buf[4] <= ssl->conf->max_minor_ver ) + ? buf[4] : ssl->conf->max_minor_ver; + + if( ssl->minor_ver < ssl->conf->min_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "client only supports ssl smaller than minimum" + " [%d:%d] < [%d:%d]", + ssl->major_ver, ssl->minor_ver, + ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + ssl->handshake->max_major_ver = buf[3]; + ssl->handshake->max_minor_ver = buf[4]; + + if( ( ret = mbedtls_ssl_fetch_input( ssl, 2 + n ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + + ssl->handshake->update_checksum( ssl, buf + 2, n ); + + buf = ssl->in_msg; + n = ssl->in_left - 5; + + /* + * 0 . 1 ciphersuitelist length + * 2 . 3 session id length + * 4 . 5 challenge length + * 6 . .. ciphersuitelist + * .. . .. session id + * .. . .. challenge + */ + MBEDTLS_SSL_DEBUG_BUF( 4, "record contents", buf, n ); + + ciph_len = ( buf[0] << 8 ) | buf[1]; + sess_len = ( buf[2] << 8 ) | buf[3]; + chal_len = ( buf[4] << 8 ) | buf[5]; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciph_len: %d, sess_len: %d, chal_len: %d", + ciph_len, sess_len, chal_len ) ); + + /* + * Make sure each parameter length is valid + */ + if( ciph_len < 3 || ( ciph_len % 3 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( sess_len > 32 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( chal_len < 8 || chal_len > 32 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( n != 6 + ciph_len + sess_len + chal_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, ciphersuitelist", + buf + 6, ciph_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", + buf + 6 + ciph_len, sess_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, challenge", + buf + 6 + ciph_len + sess_len, chal_len ); + + p = buf + 6 + ciph_len; + ssl->session_negotiate->id_len = sess_len; + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); + memcpy( ssl->session_negotiate->id, p, ssl->session_negotiate->id_len ); + + p += sess_len; + memset( ssl->handshake->randbytes, 0, 64 ); + memcpy( ssl->handshake->randbytes + 32 - chal_len, p, chal_len ); + + /* + * Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ + for( i = 0, p = buf + 6; i < ciph_len; i += 3, p += 3 ) + { + if( p[0] == 0 && p[1] == 0 && p[2] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "received TLS_EMPTY_RENEGOTIATION_INFO " ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV " + "during renegotiation" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + break; + } + } + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + for( i = 0, p = buf + 6; i < ciph_len; i += 3, p += 3 ) + { + if( p[0] == 0 && + p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) && + p[2] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "received FALLBACK_SCSV" ) ); + + if( ssl->minor_ver < ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "inapropriate fallback" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + break; + } + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + + got_common_suite = 0; + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + ciphersuite_info = NULL; +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 ) + { + for( i = 0; ciphersuites[i] != 0; i++ ) +#else + for( i = 0; ciphersuites[i] != 0; i++ ) + { + for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 ) +#endif + { + if( p[0] != 0 || + p[1] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || + p[2] != ( ( ciphersuites[i] ) & 0xFF ) ) + continue; + + got_common_suite = 1; + + if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i], + &ciphersuite_info ) ) != 0 ) + return( ret ); + + if( ciphersuite_info != NULL ) + goto have_ciphersuite_v2; + } + } + + if( got_common_suite ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got ciphersuites in common, " + "but none of them usable" ) ); + return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no ciphersuites in common" ) ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + +have_ciphersuite_v2: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "selected ciphersuite: %s", ciphersuite_info->name ) ); + + ssl->session_negotiate->ciphersuite = ciphersuites[i]; + ssl->transform_negotiate->ciphersuite_info = ciphersuite_info; + + /* + * SSLv2 Client Hello relevant renegotiation security checks + */ + if( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->in_left = 0; + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello v2" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO */ + +static int ssl_parse_client_hello( mbedtls_ssl_context *ssl ) +{ + int ret, got_common_suite; + size_t i, j; + size_t ciph_offset, comp_offset, ext_offset; + size_t msg_len, ciph_len, sess_len, comp_len, ext_len; +#if defined(MBEDTLS_SSL_PROTO_DTLS) + size_t cookie_offset, cookie_len; +#endif + unsigned char *buf, *p, *ext; +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renegotiation_info_seen = 0; +#endif + int handshake_failure = 0; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + int major, minor; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client hello" ) ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +read_record_header: +#endif + /* + * If renegotiating, then the input was read with mbedtls_ssl_read_record(), + * otherwise read it ourselves manually in order to support SSLv2 + * ClientHello, which doesn't use the same record layer format. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + if( ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + } + + buf = ssl->in_hdr; + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM ) +#endif + if( ( buf[0] & 0x80 ) != 0 ) + return ssl_parse_client_hello_v2( ssl ); +#endif + + MBEDTLS_SSL_DEBUG_BUF( 4, "record header", buf, mbedtls_ssl_hdr_len( ssl ) ); + + /* + * SSLv3/TLS Client Hello + * + * Record layer: + * 0 . 0 message type + * 1 . 2 protocol version + * 3 . 11 DTLS: epoch + record sequence number + * 3 . 4 message length + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, message type: %d", + buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, message len.: %d", + ( ssl->in_len[0] << 8 ) | ssl->in_len[1] ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, protocol version: [%d:%d]", + buf[1], buf[2] ) ); + + mbedtls_ssl_read_version( &major, &minor, ssl->conf->transport, buf + 1 ); + + /* According to RFC 5246 Appendix E.1, the version here is typically + * "{03,00}, the lowest version number supported by the client, [or] the + * value of ClientHello.client_version", so the only meaningful check here + * is the major version shouldn't be less than 3 */ + if( major < MBEDTLS_SSL_MAJOR_VERSION_3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* For DTLS if this is the initial handshake, remember the client sequence + * number to use it in our next message (RFC 6347 4.2.1) */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + /* Epoch should be 0 for initial handshakes */ + if( ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + memcpy( ssl->out_ctr + 2, ssl->in_ctr + 2, 6 ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "replayed record, discarding" ) ); + ssl->next_record_offset = 0; + ssl->in_left = 0; + goto read_record_header; + } + + /* No MAC to check yet, so we can update right now */ + mbedtls_ssl_dtls_replay_update( ssl ); +#endif + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + msg_len = ( ssl->in_len[0] << 8 ) | ssl->in_len[1]; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Set by mbedtls_ssl_read_record() */ + msg_len = ssl->in_hslen; + } + else +#endif + { + if( msg_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) + msg_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); + } + + /* Done reading this record, get ready for the next one */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->next_record_offset = msg_len + mbedtls_ssl_hdr_len( ssl ); + else +#endif + ssl->in_left = 0; + } + + buf = ssl->in_msg; + + MBEDTLS_SSL_DEBUG_BUF( 4, "record contents", buf, msg_len ); + + ssl->handshake->update_checksum( ssl, buf, msg_len ); + + /* + * Handshake layer: + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 DTLS only: message seqence number + * 6 . 8 DTLS only: fragment offset + * 9 . 11 DTLS only: fragment length + */ + if( msg_len < mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, handshake type: %d", buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, handshake len.: %d", + ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ) ); + + /* We don't support fragmentation of ClientHello (yet?) */ + if( buf[1] != 0 || + msg_len != mbedtls_ssl_hs_hdr_len( ssl ) + ( ( buf[2] << 8 ) | buf[3] ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + /* + * Copy the client's handshake message_seq on initial handshakes, + * check sequence number on renego. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + /* This couldn't be done in ssl_prepare_handshake_record() */ + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + + if( cli_msg_seq != ssl->handshake->in_msg_seq ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message_seq: " + "%d (expected %d)", cli_msg_seq, + ssl->handshake->in_msg_seq ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->handshake->in_msg_seq++; + } + else +#endif + { + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + ssl->handshake->out_msg_seq = cli_msg_seq; + ssl->handshake->in_msg_seq = cli_msg_seq + 1; + } + + /* + * For now we don't support fragmentation, so make sure + * fragment_offset == 0 and fragment_length == length + */ + if( ssl->in_msg[6] != 0 || ssl->in_msg[7] != 0 || ssl->in_msg[8] != 0 || + memcmp( ssl->in_msg + 1, ssl->in_msg + 9, 3 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ClientHello fragmentation not supported" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + buf += mbedtls_ssl_hs_hdr_len( ssl ); + msg_len -= mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * ClientHello layer: + * 0 . 1 protocol version + * 2 . 33 random bytes (starting with 4 bytes of Unix time) + * 34 . 35 session id length (1 byte) + * 35 . 34+x session id + * 35+x . 35+x DTLS only: cookie length (1 byte) + * 36+x . .. DTLS only: cookie + * .. . .. ciphersuite list length (2 bytes) + * .. . .. ciphersuite list + * .. . .. compression alg. list length (1 byte) + * .. . .. compression alg. list + * .. . .. extensions length (2 bytes, optional) + * .. . .. extensions (optional) + */ + + /* + * Minimal length (with everything empty and extensions ommitted) is + * 2 + 32 + 1 + 2 + 1 = 38 bytes. Check that first, so that we can + * read at least up to session id length without worrying. + */ + if( msg_len < 38 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Check and save the protocol version + */ + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, version", buf, 2 ); + + mbedtls_ssl_read_version( &ssl->major_ver, &ssl->minor_ver, + ssl->conf->transport, buf ); + + ssl->handshake->max_major_ver = ssl->major_ver; + ssl->handshake->max_minor_ver = ssl->minor_ver; + + if( ssl->major_ver < ssl->conf->min_major_ver || + ssl->minor_ver < ssl->conf->min_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "client only supports ssl smaller than minimum" + " [%d:%d] < [%d:%d]", + ssl->major_ver, ssl->minor_ver, + ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + if( ssl->major_ver > ssl->conf->max_major_ver ) + { + ssl->major_ver = ssl->conf->max_major_ver; + ssl->minor_ver = ssl->conf->max_minor_ver; + } + else if( ssl->minor_ver > ssl->conf->max_minor_ver ) + ssl->minor_ver = ssl->conf->max_minor_ver; + + /* + * Save client random (inc. Unix time) + */ + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf + 2, 32 ); + + memcpy( ssl->handshake->randbytes, buf + 2, 32 ); + + /* + * Check the session ID length and save session ID + */ + sess_len = buf[34]; + + if( sess_len > sizeof( ssl->session_negotiate->id ) || + sess_len + 34 + 2 > msg_len ) /* 2 for cipherlist length field */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", buf + 35, sess_len ); + + ssl->session_negotiate->id_len = sess_len; + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); + memcpy( ssl->session_negotiate->id, buf + 35, + ssl->session_negotiate->id_len ); + + /* + * Check the cookie length and content + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + cookie_offset = 35 + sess_len; + cookie_len = buf[cookie_offset]; + + if( cookie_offset + 1 + cookie_len + 2 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, cookie", + buf + cookie_offset + 1, cookie_len ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( ssl->conf->f_cookie_check != NULL +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + if( ssl->conf->f_cookie_check( ssl->conf->p_cookie, + buf + cookie_offset + 1, cookie_len, + ssl->cli_id, ssl->cli_id_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "cookie verification failed" ) ); + ssl->handshake->verify_cookie_len = 1; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "cookie verification passed" ) ); + ssl->handshake->verify_cookie_len = 0; + } + } + else +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + { + /* We know we didn't send a cookie, so it should be empty */ + if( cookie_len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "cookie verification skipped" ) ); + } + + /* + * Check the ciphersuitelist length (will be parsed later) + */ + ciph_offset = cookie_offset + 1 + cookie_len; + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + ciph_offset = 35 + sess_len; + + ciph_len = ( buf[ciph_offset + 0] << 8 ) + | ( buf[ciph_offset + 1] ); + + if( ciph_len < 2 || + ciph_len + 2 + ciph_offset + 1 > msg_len || /* 1 for comp. alg. len */ + ( ciph_len % 2 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, ciphersuitelist", + buf + ciph_offset + 2, ciph_len ); + + /* + * Check the compression algorithms length and pick one + */ + comp_offset = ciph_offset + 2 + ciph_len; + + comp_len = buf[comp_offset]; + + if( comp_len < 1 || + comp_len > 16 || + comp_len + comp_offset + 1 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, compression", + buf + comp_offset + 1, comp_len ); + + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#if defined(MBEDTLS_ZLIB_SUPPORT) + for( i = 0; i < comp_len; ++i ) + { + if( buf[comp_offset + 1 + i] == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_DEFLATE; + break; + } + } +#endif + + /* See comments in ssl_write_client_hello() */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#endif + + /* Do not parse the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + /* + * Check the extension length + */ + ext_offset = comp_offset + 1 + comp_len; + if( msg_len > ext_offset ) + { + if( msg_len < ext_offset + 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ext_len = ( buf[ext_offset + 0] << 8 ) + | ( buf[ext_offset + 1] ); + + if( ( ext_len > 0 && ext_len < 4 ) || + msg_len != ext_offset + 2 + ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } + else + ext_len = 0; + + ext = buf + ext_offset + 2; + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", ext, ext_len ); + + while( ext_len != 0 ) + { + unsigned int ext_id = ( ( ext[0] << 8 ) + | ( ext[1] ) ); + unsigned int ext_size = ( ( ext[2] << 8 ) + | ( ext[3] ) ); + + if( ext_size + 4 > ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + switch( ext_id ) + { +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + case MBEDTLS_TLS_EXT_SERVERNAME: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found ServerName extension" ) ); + if( ssl->conf->f_sni == NULL ) + break; + + ret = ssl_parse_servername_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + + case MBEDTLS_TLS_EXT_RENEGOTIATION_INFO: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found renegotiation extension" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + renegotiation_info_seen = 1; +#endif + + ret = ssl_parse_renegotiation_info( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + case MBEDTLS_TLS_EXT_SIG_ALG: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found signature_algorithms extension" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + break; +#endif + + ret = ssl_parse_signature_algorithms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported elliptic curves extension" ) ); + + ret = ssl_parse_supported_elliptic_curves( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + + case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported point formats extension" ) ); + ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT; + + ret = ssl_parse_supported_point_formats( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_ECJPAKE_KKPP: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found ecjpake kkpp extension" ) ); + + ret = ssl_parse_ecjpake_kkpp( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + case MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found max fragment length extension" ) ); + + ret = ssl_parse_max_fragment_length_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + case MBEDTLS_TLS_EXT_TRUNCATED_HMAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found truncated hmac extension" ) ); + + ret = ssl_parse_truncated_hmac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + case MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found encrypt then mac extension" ) ); + + ret = ssl_parse_encrypt_then_mac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + case MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found extended master secret extension" ) ); + + ret = ssl_parse_extended_ms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + case MBEDTLS_TLS_EXT_SESSION_TICKET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found session ticket extension" ) ); + + ret = ssl_parse_session_ticket_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) + case MBEDTLS_TLS_EXT_ALPN: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found alpn extension" ) ); + + ret = ssl_parse_alpn_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "unknown extension found: %d (ignoring)", + ext_id ) ); + } + + ext_len -= 4 + ext_size; + ext += 4 + ext_size; + + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + for( i = 0, p = buf + 41 + sess_len; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) && + p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received FALLBACK_SCSV" ) ); + + if( ssl->minor_ver < ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "inapropriate fallback" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + break; + } + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + + /* + * Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ + for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "received TLS_EMPTY_RENEGOTIATION_INFO " ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV during renegotiation" ) ); + + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + break; + } + } + + /* + * Renegotiation security checks + */ + if( ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) ); + handshake_failure = 1; + } +#if defined(MBEDTLS_SSL_RENEGOTIATION) + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION && + renegotiation_info_seen == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension missing (secure)" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation not allowed" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + renegotiation_info_seen == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension present (legacy)" ) ); + handshake_failure = 1; + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + if( handshake_failure == 1 ) + { + if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 ) + return( ret ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Search for a matching ciphersuite + * (At the end because we need information from the EC-based extensions + * and certificate from the SNI callback triggered by the SNI extension.) + */ + got_common_suite = 0; + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + ciphersuite_info = NULL; +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) + { + for( i = 0; ciphersuites[i] != 0; i++ ) +#else + for( i = 0; ciphersuites[i] != 0; i++ ) + { + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) +#endif + { + if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || + p[1] != ( ( ciphersuites[i] ) & 0xFF ) ) + continue; + + got_common_suite = 1; + + if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i], + &ciphersuite_info ) ) != 0 ) + return( ret ); + + if( ciphersuite_info != NULL ) + goto have_ciphersuite; + } + } + + if( got_common_suite ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got ciphersuites in common, " + "but none of them usable" ) ); + mbedtls_ssl_send_fatal_handshake_failure( ssl ); + return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no ciphersuites in common" ) ); + mbedtls_ssl_send_fatal_handshake_failure( ssl ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + +have_ciphersuite: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "selected ciphersuite: %s", ciphersuite_info->name ) ); + + ssl->session_negotiate->ciphersuite = ciphersuites[i]; + ssl->transform_negotiate->ciphersuite_info = ciphersuite_info; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_recv_flight_completed( ssl ); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) +static void ssl_write_truncated_hmac_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->session_negotiate->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_DISABLED ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding truncated hmac extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_TRUNCATED_HMAC >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_TRUNCATED_HMAC ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + const mbedtls_ssl_ciphersuite_t *suite = NULL; + const mbedtls_cipher_info_t *cipher = NULL; + + if( ssl->session_negotiate->encrypt_then_mac == MBEDTLS_SSL_EXTENDED_MS_DISABLED || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + *olen = 0; + return; + } + + /* + * RFC 7366: "If a server receives an encrypt-then-MAC request extension + * from a client and then selects a stream or Authenticated Encryption + * with Associated Data (AEAD) ciphersuite, it MUST NOT send an + * encrypt-then-MAC response extension back to the client." + */ + if( ( suite = mbedtls_ssl_ciphersuite_from_id( + ssl->session_negotiate->ciphersuite ) ) == NULL || + ( cipher = mbedtls_cipher_info_from_type( suite->cipher ) ) == NULL || + cipher->mode != MBEDTLS_MODE_CBC ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding encrypt then mac extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_DISABLED || + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding extended master secret " + "extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->handshake->new_session_ticket == 0 ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding session ticket extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET ) & 0xFF ); + + *p++ = 0x00; + *p++ = 0x00; + + *olen = 4; +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, secure renegotiation extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ) & 0xFF ); + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + *p++ = 0x00; + *p++ = ( ssl->verify_data_len * 2 + 1 ) & 0xFF; + *p++ = ssl->verify_data_len * 2 & 0xFF; + + memcpy( p, ssl->peer_verify_data, ssl->verify_data_len ); + p += ssl->verify_data_len; + memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); + p += ssl->verify_data_len; + } + else +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + { + *p++ = 0x00; + *p++ = 0x01; + *p++ = 0x00; + } + + *olen = p - buf; +} + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) +static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + + if( ssl->session_negotiate->mfl_code == MBEDTLS_SSL_MAX_FRAG_LEN_NONE ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, max_fragment_length extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ) & 0xFF ); + + *p++ = 0x00; + *p++ = 1; + + *p++ = ssl->session_negotiate->mfl_code; + + *olen = 5; +} +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + unsigned char *p = buf; + ((void) ssl); + + if( ( ssl->handshake->cli_exts & + MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT ) == 0 ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, supported_point_formats extension" ) ); + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ) & 0xFF ); + + *p++ = 0x00; + *p++ = 2; + + *p++ = 1; + *p++ = MBEDTLS_ECP_PF_UNCOMPRESSED; + + *olen = 6; +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t *olen ) +{ + int ret; + unsigned char *p = buf; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t kkpp_len; + + *olen = 0; + + /* Skip costly computation if not needed */ + if( ssl->transform_negotiate->ciphersuite_info->key_exchange != + MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + return; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, ecjpake kkpp extension" ) ); + + if( end - p < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ) & 0xFF ); + + ret = mbedtls_ecjpake_write_round_one( &ssl->handshake->ecjpake_ctx, + p + 2, end - p - 2, &kkpp_len, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1 , "mbedtls_ecjpake_write_round_one", ret ); + return; + } + + *p++ = (unsigned char)( ( kkpp_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( kkpp_len ) & 0xFF ); + + *olen = kkpp_len + 4; +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_ALPN ) +static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t *olen ) +{ + if( ssl->alpn_chosen == NULL ) + { + *olen = 0; + return; + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding alpn extension" ) ); + + /* + * 0 . 1 ext identifier + * 2 . 3 ext length + * 4 . 5 protocol list length + * 6 . 6 protocol name length + * 7 . 7+n protocol name + */ + buf[0] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN >> 8 ) & 0xFF ); + buf[1] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN ) & 0xFF ); + + *olen = 7 + strlen( ssl->alpn_chosen ); + + buf[2] = (unsigned char)( ( ( *olen - 4 ) >> 8 ) & 0xFF ); + buf[3] = (unsigned char)( ( ( *olen - 4 ) ) & 0xFF ); + + buf[4] = (unsigned char)( ( ( *olen - 6 ) >> 8 ) & 0xFF ); + buf[5] = (unsigned char)( ( ( *olen - 6 ) ) & 0xFF ); + + buf[6] = (unsigned char)( ( ( *olen - 7 ) ) & 0xFF ); + + memcpy( buf + 7, ssl->alpn_chosen, *olen - 7 ); +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) +static int ssl_write_hello_verify_request( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *p = ssl->out_msg + 4; + unsigned char *cookie_len_byte; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write hello verify request" ) ); + + /* + * struct { + * ProtocolVersion server_version; + * opaque cookie<0..2^8-1>; + * } HelloVerifyRequest; + */ + + /* The RFC is not clear on this point, but sending the actual negotiated + * version looks like the most interoperable thing to do. */ + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, p ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server version", p, 2 ); + p += 2; + + /* If we get here, f_cookie_check is not null */ + if( ssl->conf->f_cookie_write == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "inconsistent cookie callbacks" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* Skip length byte until we know the length */ + cookie_len_byte = p++; + + if( ( ret = ssl->conf->f_cookie_write( ssl->conf->p_cookie, + &p, ssl->out_buf + MBEDTLS_SSL_BUFFER_LEN, + ssl->cli_id, ssl->cli_id_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "f_cookie_write", ret ); + return( ret ); + } + + *cookie_len_byte = (unsigned char)( p - ( cookie_len_byte + 1 ) ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "cookie sent", cookie_len_byte + 1, *cookie_len_byte ); + + ssl->out_msglen = p - ssl->out_msg; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST; + + ssl->state = MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write hello verify request" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_HAVE_TIME) + mbedtls_time_t t; +#endif + int ret; + size_t olen, ext_len = 0, n; + unsigned char *buf, *p; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server hello" ) ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->verify_cookie_len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "client hello was not authenticated" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello" ) ); + + return( ssl_write_hello_verify_request( ssl ) ); + } +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided") ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } + + /* + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 protocol version + * 6 . 9 UNIX time() + * 10 . 37 random bytes + */ + buf = ssl->out_msg; + p = buf + 4; + + mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + ssl->conf->transport, p ); + p += 2; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen version: [%d:%d]", + buf[4], buf[5] ) ); + +#if defined(MBEDTLS_HAVE_TIME) + t = mbedtls_time( NULL ); + *p++ = (unsigned char)( t >> 24 ); + *p++ = (unsigned char)( t >> 16 ); + *p++ = (unsigned char)( t >> 8 ); + *p++ = (unsigned char)( t ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) ); +#else + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 ) + return( ret ); + + p += 4; +#endif /* MBEDTLS_HAVE_TIME */ + + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 ) + return( ret ); + + p += 28; + + memcpy( ssl->handshake->randbytes + 32, buf + 6, 32 ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 6, 32 ); + + /* + * Resume is 0 by default, see ssl_handshake_init(). + * It may be already set to 1 by ssl_parse_session_ticket_ext(). + * If not, try looking up session ID in our cache. + */ + if( ssl->handshake->resume == 0 && +#if defined(MBEDTLS_SSL_RENEGOTIATION) + ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE && +#endif + ssl->session_negotiate->id_len != 0 && + ssl->conf->f_get_cache != NULL && + ssl->conf->f_get_cache( ssl->conf->p_cache, ssl->session_negotiate ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from cache" ) ); + ssl->handshake->resume = 1; + } + + if( ssl->handshake->resume == 0 ) + { + /* + * New session, create a new session id, + * unless we're about to issue a session ticket + */ + ssl->state++; + +#if defined(MBEDTLS_HAVE_TIME) + ssl->session_negotiate->start = mbedtls_time( NULL ); +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( ssl->handshake->new_session_ticket != 0 ) + { + ssl->session_negotiate->id_len = n = 0; + memset( ssl->session_negotiate->id, 0, 32 ); + } + else +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + { + ssl->session_negotiate->id_len = n = 32; + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id, + n ) ) != 0 ) + return( ret ); + } + } + else + { + /* + * Resuming a session + */ + n = ssl->session_negotiate->id_len; + ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + } + + /* + * 38 . 38 session id length + * 39 . 38+n session id + * 39+n . 40+n chosen ciphersuite + * 41+n . 41+n chosen compression alg. + * 42+n . 43+n extensions length + * 44+n . 43+n+m extensions + */ + *p++ = (unsigned char) ssl->session_negotiate->id_len; + memcpy( p, ssl->session_negotiate->id, ssl->session_negotiate->id_len ); + p += ssl->session_negotiate->id_len; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", + ssl->handshake->resume ? "a" : "no" ) ); + + *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite >> 8 ); + *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite ); + *p++ = (unsigned char)( ssl->session_negotiate->compression ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", + mbedtls_ssl_get_ciphersuite_name( ssl->session_negotiate->ciphersuite ) ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: 0x%02X", + ssl->session_negotiate->compression ) ); + + /* Do not write the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + + /* + * First write extensions, then the total length + */ + ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + ssl_write_max_fragment_length_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + ssl_write_truncated_hmac_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + ssl_write_encrypt_then_mac_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + ssl_write_extended_ms_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + ssl_write_session_ticket_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + ssl_write_ecjpake_kkpp_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + +#if defined(MBEDTLS_SSL_ALPN) + ssl_write_alpn_ext( ssl, p + 2 + ext_len, &olen ); + ext_len += olen; +#endif + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, total extension length: %d", ext_len ) ); + + if( ext_len > 0 ) + { + *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + p += ext_len; + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + + ssl->out_msglen = p - buf; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO; + + ret = mbedtls_ssl_write_record( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello" ) ); + + return( ret ); +} + +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate request" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + size_t dn_size, total_dn_size; /* excluding length bytes */ + size_t ct_len, sa_len; /* including length bytes */ + unsigned char *buf, *p; + const unsigned char * const end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const mbedtls_x509_crt *crt; + int authmode; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) ); + + ssl->state++; + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET ) + authmode = ssl->handshake->sni_authmode; + else +#endif + authmode = ssl->conf->authmode; + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE || + authmode == MBEDTLS_SSL_VERIFY_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate request" ) ); + return( 0 ); + } + + /* + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 4 cert type count + * 5 .. m-1 cert types + * m .. m+1 sig alg length (TLS 1.2 only) + * m+1 .. n-1 SignatureAndHashAlgorithms (TLS 1.2 only) + * n .. n+1 length of all DNs + * n+2 .. n+3 length of DN 1 + * n+4 .. ... Distinguished Name #1 + * ... .. ... length of DN 2, etc. + */ + buf = ssl->out_msg; + p = buf + 4; + + /* + * Supported certificate types + * + * ClientCertificateType certificate_types<1..2^8-1>; + * enum { (255) } ClientCertificateType; + */ + ct_len = 0; + +#if defined(MBEDTLS_RSA_C) + p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_RSA_SIGN; +#endif +#if defined(MBEDTLS_ECDSA_C) + p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN; +#endif + + p[0] = (unsigned char) ct_len++; + p += ct_len; + + sa_len = 0; +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + /* + * Add signature_algorithms for verify (TLS 1.2) + * + * SignatureAndHashAlgorithm supported_signature_algorithms<2..2^16-2>; + * + * struct { + * HashAlgorithm hash; + * SignatureAlgorithm signature; + * } SignatureAndHashAlgorithm; + * + * enum { (255) } HashAlgorithm; + * enum { (255) } SignatureAlgorithm; + */ + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + const int *cur; + + /* + * Supported signature algorithms + */ + for( cur = ssl->conf->sig_hashes; *cur != MBEDTLS_MD_NONE; cur++ ) + { + unsigned char hash = mbedtls_ssl_hash_from_md_alg( *cur ); + + if( MBEDTLS_SSL_HASH_NONE == hash || mbedtls_ssl_set_calc_verify_md( ssl, hash ) ) + continue; + +#if defined(MBEDTLS_RSA_C) + p[2 + sa_len++] = hash; + p[2 + sa_len++] = MBEDTLS_SSL_SIG_RSA; +#endif +#if defined(MBEDTLS_ECDSA_C) + p[2 + sa_len++] = hash; + p[2 + sa_len++] = MBEDTLS_SSL_SIG_ECDSA; +#endif + } + + p[0] = (unsigned char)( sa_len >> 8 ); + p[1] = (unsigned char)( sa_len ); + sa_len += 2; + p += sa_len; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + /* + * DistinguishedName certificate_authorities<0..2^16-1>; + * opaque DistinguishedName<1..2^16-1>; + */ + p += 2; +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_ca_chain != NULL ) + crt = ssl->handshake->sni_ca_chain; + else +#endif + crt = ssl->conf->ca_chain; + + total_dn_size = 0; + while( crt != NULL && crt->version != 0 ) + { + dn_size = crt->subject_raw.len; + + if( end < p || + (size_t)( end - p ) < dn_size || + (size_t)( end - p ) < 2 + dn_size ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "skipping CAs: buffer too short" ) ); + break; + } + + *p++ = (unsigned char)( dn_size >> 8 ); + *p++ = (unsigned char)( dn_size ); + memcpy( p, crt->subject_raw.p, dn_size ); + p += dn_size; + + MBEDTLS_SSL_DEBUG_BUF( 3, "requested DN", p - dn_size, dn_size ); + + total_dn_size += 2 + dn_size; + crt = crt->next; + } + + ssl->out_msglen = p - buf; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_REQUEST; + ssl->out_msg[4 + ct_len + sa_len] = (unsigned char)( total_dn_size >> 8 ); + ssl->out_msg[5 + ct_len + sa_len] = (unsigned char)( total_dn_size ); + + ret = mbedtls_ssl_write_record( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write certificate request" ) ); + + return( ret ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl ) +{ + int ret; + + if( ! mbedtls_pk_can_do( mbedtls_ssl_own_key( ssl ), MBEDTLS_PK_ECKEY ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key not ECDH capable" ) ); + return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH ); + } + + if( ( ret = mbedtls_ecdh_get_params( &ssl->handshake->ecdh_ctx, + mbedtls_pk_ec( *mbedtls_ssl_own_key( ssl ) ), + MBEDTLS_ECDH_OURS ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_get_params" ), ret ); + return( ret ); + } + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t n = 0; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = + ssl->transform_negotiate->ciphersuite_info; + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + unsigned char *p = ssl->out_msg + 4; + unsigned char *dig_signed = p; + size_t dig_signed_len = 0, len = 0; + ((void) dig_signed); + ((void) dig_signed_len); + ((void) len); +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); + ssl->state++; + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA ) + { + ssl_get_ecdh_params_from_cert( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); + ssl->state++; + return( 0 ); + } +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + size_t jlen; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + + ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx, + p, end - p, &jlen, ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_write_round_two", ret ); + return( ret ); + } + + p += jlen; + n += jlen; + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + /* Note: we don't support identity hints, until someone asks + * for them. */ + *(p++) = 0x00; + *(p++) = 0x00; + + n += 2; + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + if( ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no DH parameters set" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + /* + * Ephemeral DH parameters: + * + * struct { + * opaque dh_p<1..2^16-1>; + * opaque dh_g<1..2^16-1>; + * opaque dh_Ys<1..2^16-1>; + * } ServerDHParams; + */ + if( ( ret = mbedtls_mpi_copy( &ssl->handshake->dhm_ctx.P, &ssl->conf->dhm_P ) ) != 0 || + ( ret = mbedtls_mpi_copy( &ssl->handshake->dhm_ctx.G, &ssl->conf->dhm_G ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_mpi_copy", ret ); + return( ret ); + } + + if( ( ret = mbedtls_dhm_make_params( &ssl->handshake->dhm_ctx, + (int) mbedtls_mpi_size( &ssl->handshake->dhm_ctx.P ), + p, &len, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_make_params", ret ); + return( ret ); + } + + dig_signed = p; + dig_signed_len = len; + + p += len; + n += len; + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->handshake->dhm_ctx.X ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: P ", &ssl->handshake->dhm_ctx.P ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: G ", &ssl->handshake->dhm_ctx.G ); + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->handshake->dhm_ctx.GX ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + /* + * Ephemeral ECDH parameters: + * + * struct { + * ECParameters curve_params; + * ECPoint public; + * } ServerECDHParams; + */ + const mbedtls_ecp_curve_info **curve = NULL; + const mbedtls_ecp_group_id *gid; + + /* Match our preference list against the offered curves */ + for( gid = ssl->conf->curve_list; *gid != MBEDTLS_ECP_DP_NONE; gid++ ) + for( curve = ssl->handshake->curves; *curve != NULL; curve++ ) + if( (*curve)->grp_id == *gid ) + goto curve_matching_done; + +curve_matching_done: + if( curve == NULL || *curve == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no matching curve for ECDHE" ) ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDHE curve: %s", (*curve)->name ) ); + + if( ( ret = mbedtls_ecp_group_load( &ssl->handshake->ecdh_ctx.grp, + (*curve)->grp_id ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecp_group_load", ret ); + return( ret ); + } + + if( ( ret = mbedtls_ecdh_make_params( &ssl->handshake->ecdh_ctx, &len, + p, MBEDTLS_SSL_MAX_CONTENT_LEN - n, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_make_params", ret ); + return( ret ); + } + + dig_signed = p; + dig_signed_len = len; + + p += len; + n += len; + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q ", &ssl->handshake->ecdh_ctx.Q ); + } +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ) + { + size_t signature_len = 0; + unsigned int hashlen = 0; + unsigned char hash[64]; + mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE; + + /* + * Choose hash algorithm. NONE means MD5 + SHA1 here. + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + md_alg = mbedtls_ssl_md_alg_from_hash( ssl->handshake->sig_alg ); + + if( md_alg == MBEDTLS_MD_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ciphersuite_info->key_exchange == + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ) + { + md_alg = MBEDTLS_MD_SHA1; + } + else +#endif + { + md_alg = MBEDTLS_MD_NONE; + } + + /* + * Compute the hash to be signed + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( md_alg == MBEDTLS_MD_NONE ) + { + mbedtls_md5_context mbedtls_md5; + mbedtls_sha1_context mbedtls_sha1; + + mbedtls_md5_init( &mbedtls_md5 ); + mbedtls_sha1_init( &mbedtls_sha1 ); + + /* + * digitally-signed struct { + * opaque md5_hash[16]; + * opaque sha_hash[20]; + * }; + * + * md5_hash + * MD5(ClientHello.random + ServerHello.random + * + ServerParams); + * sha_hash + * SHA(ClientHello.random + ServerHello.random + * + ServerParams); + */ + mbedtls_md5_starts( &mbedtls_md5 ); + mbedtls_md5_update( &mbedtls_md5, ssl->handshake->randbytes, 64 ); + mbedtls_md5_update( &mbedtls_md5, dig_signed, dig_signed_len ); + mbedtls_md5_finish( &mbedtls_md5, hash ); + + mbedtls_sha1_starts( &mbedtls_sha1 ); + mbedtls_sha1_update( &mbedtls_sha1, ssl->handshake->randbytes, 64 ); + mbedtls_sha1_update( &mbedtls_sha1, dig_signed, dig_signed_len ); + mbedtls_sha1_finish( &mbedtls_sha1, hash + 16 ); + + hashlen = 36; + + mbedtls_md5_free( &mbedtls_md5 ); + mbedtls_sha1_free( &mbedtls_sha1 ); + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \ + MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( md_alg != MBEDTLS_MD_NONE ) + { + mbedtls_md_context_t ctx; + const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); + + mbedtls_md_init( &ctx ); + + /* Info from md_alg will be used instead */ + hashlen = 0; + + /* + * digitally-signed struct { + * opaque client_random[32]; + * opaque server_random[32]; + * ServerDHParams params; + * }; + */ + if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret ); + return( ret ); + } + + mbedtls_md_starts( &ctx ); + mbedtls_md_update( &ctx, ssl->handshake->randbytes, 64 ); + mbedtls_md_update( &ctx, dig_signed, dig_signed_len ); + mbedtls_md_finish( &ctx, hash ); + mbedtls_md_free( &ctx ); + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ + MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen : + (unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) ); + + /* + * Make the signature + */ + if( mbedtls_ssl_own_key( ssl ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no private key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + *(p++) = ssl->handshake->sig_alg; + *(p++) = mbedtls_ssl_sig_from_pk( mbedtls_ssl_own_key( ssl ) ); + + n += 2; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + + if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash, hashlen, + p + 2 , &signature_len, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_sign", ret ); + return( ret ); + } + + *(p++) = (unsigned char)( signature_len >> 8 ); + *(p++) = (unsigned char)( signature_len ); + n += 2; + + MBEDTLS_SSL_DEBUG_BUF( 3, "my signature", p, signature_len ); + + n += signature_len; + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + + ssl->out_msglen = 4 + n; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE; + + ssl->state++; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server key exchange" ) ); + + return( 0 ); +} + +static int ssl_write_server_hello_done( mbedtls_ssl_context *ssl ) +{ + int ret; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server hello done" ) ); + + ssl->out_msglen = 4; + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO_DONE; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_send_flight_completed( ssl ); +#endif + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello done" ) ); + + return( 0 ); +} + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +static int ssl_parse_client_dh_public( mbedtls_ssl_context *ssl, unsigned char **p, + const unsigned char *end ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t n; + + /* + * Receive G^Y mod P, premaster = (G^Y)^X mod P + */ + if( *p + 2 > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + n = ( (*p)[0] << 8 ) | (*p)[1]; + *p += 2; + + if( *p + n > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_dhm_read_public( &ssl->handshake->dhm_ctx, *p, n ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_read_public", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); + } + + *p += n; + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GY", &ssl->handshake->dhm_ctx.GY ); + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) +static int ssl_parse_encrypted_pms( mbedtls_ssl_context *ssl, + const unsigned char *p, + const unsigned char *end, + size_t pms_offset ) +{ + int ret; + size_t len = mbedtls_pk_get_len( mbedtls_ssl_own_key( ssl ) ); + unsigned char *pms = ssl->handshake->premaster + pms_offset; + unsigned char ver[2]; + unsigned char fake_pms[48], peer_pms[48]; + unsigned char mask; + size_t i, peer_pmslen; + unsigned int diff; + + if( ! mbedtls_pk_can_do( mbedtls_ssl_own_key( ssl ), MBEDTLS_PK_RSA ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no RSA private key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + /* + * Decrypt the premaster using own private RSA key + */ +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_0 ) + { + if( *p++ != ( ( len >> 8 ) & 0xFF ) || + *p++ != ( ( len ) & 0xFF ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + } +#endif + + if( p + len != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + mbedtls_ssl_write_version( ssl->handshake->max_major_ver, + ssl->handshake->max_minor_ver, + ssl->conf->transport, ver ); + + /* + * Protection against Bleichenbacher's attack: invalid PKCS#1 v1.5 padding + * must not cause the connection to end immediately; instead, send a + * bad_record_mac later in the handshake. + * Also, avoid data-dependant branches here to protect against + * timing-based variants. + */ + ret = ssl->conf->f_rng( ssl->conf->p_rng, fake_pms, sizeof( fake_pms ) ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_pk_decrypt( mbedtls_ssl_own_key( ssl ), p, len, + peer_pms, &peer_pmslen, + sizeof( peer_pms ), + ssl->conf->f_rng, ssl->conf->p_rng ); + + diff = (unsigned int) ret; + diff |= peer_pmslen ^ 48; + diff |= peer_pms[0] ^ ver[0]; + diff |= peer_pms[1] ^ ver[1]; + +#if defined(MBEDTLS_SSL_DEBUG_ALL) + if( diff != 0 ) + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); +#endif + + if( sizeof( ssl->handshake->premaster ) < pms_offset || + sizeof( ssl->handshake->premaster ) - pms_offset < 48 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + ssl->handshake->pmslen = 48; + + /* mask = diff ? 0xff : 0x00 using bit operations to avoid branches */ + /* MSVC has a warning about unary minus on unsigned, but this is + * well-defined and precisely what we want to do here */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + mask = - ( ( diff | - diff ) >> ( sizeof( unsigned int ) * 8 - 1 ) ); +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + + for( i = 0; i < ssl->handshake->pmslen; i++ ) + pms[i] = ( mask & fake_pms[i] ) | ( (~mask) & peer_pms[i] ); + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) +static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned char **p, + const unsigned char *end ) +{ + int ret = 0; + size_t n; + + if( ssl->conf->f_psk == NULL && + ( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL || + ssl->conf->psk_identity_len == 0 || ssl->conf->psk_len == 0 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no pre-shared key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + /* + * Receive client pre-shared key identity name + */ + if( *p + 2 > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + n = ( (*p)[0] << 8 ) | (*p)[1]; + *p += 2; + + if( n < 1 || n > 65535 || *p + n > end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ssl->conf->f_psk != NULL ) + { + if( ssl->conf->f_psk( ssl->conf->p_psk, ssl, *p, n ) != 0 ) + ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY; + } + else + { + /* Identity is not a big secret since clients send it in the clear, + * but treat it carefully anyway, just in case */ + if( n != ssl->conf->psk_identity_len || + mbedtls_ssl_safer_memcmp( ssl->conf->psk_identity, *p, n ) != 0 ) + { + ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY; + } + } + + if( ret == MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY ) + { + MBEDTLS_SSL_DEBUG_BUF( 3, "Unknown PSK identity", *p, n ); + if( ( ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY ) ) != 0 ) + { + return( ret ); + } + + return( MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY ); + } + + *p += n; + + return( 0 ); +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ + +static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + unsigned char *p, *end; + + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client key exchange" ) ); + + if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); + end = ssl->in_msg + ssl->in_hslen; + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA ) + { + if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_dh_public" ), ret ); + return( ret ); + } + + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_dhm_calc_secret( &ssl->handshake->dhm_ctx, + ssl->handshake->premaster, + MBEDTLS_PREMASTER_SIZE, + &ssl->handshake->pmslen, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA ) + { + if( ( ret = mbedtls_ecdh_read_public( &ssl->handshake->ecdh_ctx, + p, end - p) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_read_public", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); + } + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp ", &ssl->handshake->ecdh_ctx.Qp ); + + if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, + &ssl->handshake->pmslen, + ssl->handshake->premaster, + MBEDTLS_MPI_MAX_SIZE, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS ); + } + + MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z ", &ssl->handshake->ecdh_ctx.z ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED || + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + + if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 2 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_encrypted_pms" ), ret ); + return( ret ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_dh_public" ), ret ); + return( ret ); + } + + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); + } + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) + { + if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); + return( ret ); + } + + if( ( ret = mbedtls_ecdh_read_public( &ssl->handshake->ecdh_ctx, + p, end - p ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_read_public", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); + } + + MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp ", &ssl->handshake->ecdh_ctx.Qp ); + + if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, + ciphersuite_info->key_exchange ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA ) + { + if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_parse_encrypted_pms_secret" ), ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + ret = mbedtls_ecjpake_read_round_two( &ssl->handshake->ecjpake_ctx, + p, end - p ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_two", ret ); + return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); + } + + ret = mbedtls_ecjpake_derive_secret( &ssl->handshake->ecjpake_ctx, + ssl->handshake->premaster, 32, &ssl->handshake->pmslen, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_derive_secret", ret ); + return( ret ); + } + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + + ssl->state++; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client key exchange" ) ); + + return( 0 ); +} + +#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \ + !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) +{ + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} +#else +static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t i, sig_len; + unsigned char hash[48]; + unsigned char *hash_start = hash; + size_t hashlen; +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + mbedtls_pk_type_t pk_alg; +#endif + mbedtls_md_type_t md_alg; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE || + ssl->session_negotiate->peer_cert == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); + ssl->state++; + return( 0 ); + } + + /* Read the message without adding it to the checksum */ + do { + + if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret ); + return( ret ); + } + + ret = mbedtls_ssl_handle_message_type( ssl ); + + } while( MBEDTLS_ERR_SSL_NON_FATAL == ret ); + + if( 0 != ret ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_handle_message_type" ), ret ); + return( ret ); + } + + ssl->state++; + + /* Process the message contents */ + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || + ssl->in_msg[0] != MBEDTLS_SSL_HS_CERTIFICATE_VERIFY ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + i = mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * struct { + * SignatureAndHashAlgorithm algorithm; -- TLS 1.2 only + * opaque signature<0..2^16-1>; + * } DigitallySigned; + */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 ) + { + md_alg = MBEDTLS_MD_NONE; + hashlen = 36; + + /* For ECDSA, use SHA-1, not MD-5 + SHA-1 */ + if( mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, + MBEDTLS_PK_ECDSA ) ) + { + hash_start += 16; + hashlen -= 16; + md_alg = MBEDTLS_MD_SHA1; + } + } + else +#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || + MBEDTLS_SSL_PROTO_TLS1_1 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + if( i + 2 > ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + /* + * Hash + */ + md_alg = mbedtls_ssl_md_alg_from_hash( ssl->in_msg[i] ); + + if( md_alg == MBEDTLS_MD_NONE || mbedtls_ssl_set_calc_verify_md( ssl, ssl->in_msg[i] ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "peer not adhering to requested sig_alg" + " for verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + +#if !defined(MBEDTLS_MD_SHA1) + if( MBEDTLS_MD_SHA1 == md_alg ) + hash_start += 16; +#endif + + /* Info from md_alg will be used instead */ + hashlen = 0; + + i++; + + /* + * Signature + */ + if( ( pk_alg = mbedtls_ssl_pk_alg_from_sig( ssl->in_msg[i] ) ) + == MBEDTLS_PK_NONE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "peer not adhering to requested sig_alg" + " for verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + /* + * Check the certificate's key type matches the signature alg + */ + if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, pk_alg ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "sig_alg doesn't match cert key" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + i++; + } + else +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + if( i + 2 > ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + sig_len = ( ssl->in_msg[i] << 8 ) | ssl->in_msg[i+1]; + i += 2; + + if( i + sig_len != ssl->in_hslen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); + } + + /* Calculate hash and verify signature */ + ssl->handshake->calc_verify( ssl, hash ); + + if( ( ret = mbedtls_pk_verify( &ssl->session_negotiate->peer_cert->pk, + md_alg, hash_start, hashlen, + ssl->in_msg + i, sig_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify", ret ); + return( ret ); + } + + mbedtls_ssl_update_handshake_status( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate verify" ) ); + + return( ret ); +} +#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED && + !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) +static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t tlen; + uint32_t lifetime; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write new session ticket" ) ); + + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = MBEDTLS_SSL_HS_NEW_SESSION_TICKET; + + /* + * struct { + * uint32 ticket_lifetime_hint; + * opaque ticket<0..2^16-1>; + * } NewSessionTicket; + * + * 4 . 7 ticket_lifetime_hint (0 = unspecified) + * 8 . 9 ticket_len (n) + * 10 . 9+n ticket content + */ + + if( ( ret = ssl->conf->f_ticket_write( ssl->conf->p_ticket, + ssl->session_negotiate, + ssl->out_msg + 10, + ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN, + &tlen, &lifetime ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_ticket_write", ret ); + tlen = 0; + } + + ssl->out_msg[4] = ( lifetime >> 24 ) & 0xFF; + ssl->out_msg[5] = ( lifetime >> 16 ) & 0xFF; + ssl->out_msg[6] = ( lifetime >> 8 ) & 0xFF; + ssl->out_msg[7] = ( lifetime ) & 0xFF; + + ssl->out_msg[8] = (unsigned char)( ( tlen >> 8 ) & 0xFF ); + ssl->out_msg[9] = (unsigned char)( ( tlen ) & 0xFF ); + + ssl->out_msglen = 10 + tlen; + + /* + * Morally equivalent to updating ssl->state, but NewSessionTicket and + * ChangeCipherSpec share the same state. + */ + ssl->handshake->new_session_ticket = 0; + + if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write new session ticket" ) ); + + return( 0 ); +} +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +/* + * SSL handshake -- server side -- single step + */ +int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "server state: %d", ssl->state ) ); + + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) + { + if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + return( ret ); + } +#endif + + switch( ssl->state ) + { + case MBEDTLS_SSL_HELLO_REQUEST: + ssl->state = MBEDTLS_SSL_CLIENT_HELLO; + break; + + /* + * <== ClientHello + */ + case MBEDTLS_SSL_CLIENT_HELLO: + ret = ssl_parse_client_hello( ssl ); + break; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + case MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT: + return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ); +#endif + + /* + * ==> ServerHello + * Certificate + * ( ServerKeyExchange ) + * ( CertificateRequest ) + * ServerHelloDone + */ + case MBEDTLS_SSL_SERVER_HELLO: + ret = ssl_write_server_hello( ssl ); + break; + + case MBEDTLS_SSL_SERVER_CERTIFICATE: + ret = mbedtls_ssl_write_certificate( ssl ); + break; + + case MBEDTLS_SSL_SERVER_KEY_EXCHANGE: + ret = ssl_write_server_key_exchange( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_REQUEST: + ret = ssl_write_certificate_request( ssl ); + break; + + case MBEDTLS_SSL_SERVER_HELLO_DONE: + ret = ssl_write_server_hello_done( ssl ); + break; + + /* + * <== ( Certificate/Alert ) + * ClientKeyExchange + * ( CertificateVerify ) + * ChangeCipherSpec + * Finished + */ + case MBEDTLS_SSL_CLIENT_CERTIFICATE: + ret = mbedtls_ssl_parse_certificate( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_KEY_EXCHANGE: + ret = ssl_parse_client_key_exchange( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_VERIFY: + ret = ssl_parse_certificate_verify( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC: + ret = mbedtls_ssl_parse_change_cipher_spec( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_FINISHED: + ret = mbedtls_ssl_parse_finished( ssl ); + break; + + /* + * ==> ( NewSessionTicket ) + * ChangeCipherSpec + * Finished + */ + case MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC: +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( ssl->handshake->new_session_ticket != 0 ) + ret = ssl_write_new_session_ticket( ssl ); + else +#endif + ret = mbedtls_ssl_write_change_cipher_spec( ssl ); + break; + + case MBEDTLS_SSL_SERVER_FINISHED: + ret = mbedtls_ssl_write_finished( ssl ); + break; + + case MBEDTLS_SSL_FLUSH_BUFFERS: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "handshake: done" ) ); + ssl->state = MBEDTLS_SSL_HANDSHAKE_WRAPUP; + break; + + case MBEDTLS_SSL_HANDSHAKE_WRAPUP: + mbedtls_ssl_handshake_wrapup( ssl ); + break; + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + return( ret ); +} +#endif /* MBEDTLS_SSL_SRV_C */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls/config/nrf_tls_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls/config/nrf_tls_config.h new file mode 100644 index 0000000..f5a741e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls/config/nrf_tls_config.h @@ -0,0 +1,2502 @@ +/** + * \file nrf_dtls_config.h + * + * \brief Configuration options (set of defines) + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2015 Nordic Semiconductor ASA, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* + * This set of compile-time options may be used to enable + * or disable features selectively, and reduce the global + * memory footprint. + */ +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +/** + * \name SECTION: System support + * + * This section sets system specific settings. + * \{ + */ + +/** + * \def MBEDTLS_HAVE_ASM + * + * The compiler has support for asm(). + * + * Requires support for asm() in compiler. + * + * Used in: + * library/timing.c + * library/padlock.c + * include/mbedtls/bn_mul.h + * + * Comment to disable the use of assembly code. + */ +//#define MBEDTLS_HAVE_ASM + +/** + * \def MBEDTLS_HAVE_SSE2 + * + * CPU supports SSE2 instruction set. + * + * Uncomment if the CPU supports SSE2 (IA-32 specific). + */ +//#define MBEDTLS_HAVE_SSE2 + +/** + * \def MBEDTLS_HAVE_TIME + * + * System has time.h and time(). + * The time does not need to be correct, only time differences are used, + * by contrast with MBEDTLS_HAVE_TIME_DATE + * + * Comment if your system does not support time functions + */ +//#define MBEDTLS_HAVE_TIME + +/** + * \def MBEDTLS_HAVE_TIME_DATE + * + * System has time.h and time(), gmtime() and the clock is correct. + * The time needs to be correct (not necesarily very accurate, but at least + * the date should be correct). This is used to verify the validity period of + * X.509 certificates. + * + * Comment if your system does not have a correct clock. + */ +//#define MBEDTLS_HAVE_TIME_DATE + +/** + * \def MBEDTLS_PLATFORM_MEMORY + * + * Enable the memory allocation layer. + * + * By default mbed TLS uses the system-provided calloc() and free(). + * This allows different allocators (self-implemented or provided) to be + * provided to the platform abstraction layer. + * + * Enabling MBEDTLS_PLATFORM_MEMORY without the + * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide + * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and + * free() function pointer at runtime. + * + * Enabling MBEDTLS_PLATFORM_MEMORY and specifying + * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the + * alternate function at compile time. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Enable this layer to allow use of alternative memory allocators. + */ +#define MBEDTLS_PLATFORM_MEMORY + +/** + * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + * + * Do not assign standard functions in the platform layer (e.g. calloc() to + * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) + * + * This makes sure there are no linking errors on platforms that do not support + * these functions. You will HAVE to provide alternatives, either at runtime + * via the platform_set_xxx() functions or at compile time by setting + * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a + * MBEDTLS_PLATFORM_XXX_MACRO. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Uncomment to prevent default assignment of standard functions in the + * platform layer. + */ +#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + +/** + * \def MBEDTLS_PLATFORM_XXX_ALT + * + * Uncomment a macro to let mbed TLS support the function in the platform + * abstraction layer. + * + * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will + * provide a function "mbedtls_platform_set_printf()" that allows you to set an + * alternative printf function pointer. + * + * All these define require MBEDTLS_PLATFORM_C to be defined! + * + * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; + * it will be enabled automatically by check_config.h + * + * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as + * MBEDTLS_PLATFORM_XXX_MACRO! + * + * Uncomment a macro to enable alternate implementation of specific base + * platform function + */ +//#define MBEDTLS_PLATFORM_EXIT_ALT +//#define MBEDTLS_PLATFORM_FPRINTF_ALT +//#define MBEDTLS_PLATFORM_PRINTF_ALT +//#define MBEDTLS_PLATFORM_SNPRINTF_ALT + +/** + * \def MBEDTLS_DEPRECATED_WARNING + * + * Mark deprecated functions so that they generate a warning if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * This only works with GCC and Clang. With other compilers, you may want to + * use MBEDTLS_DEPRECATED_REMOVED + * + * Uncomment to get warnings on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_WARNING + +/** + * \def MBEDTLS_DEPRECATED_REMOVED + * + * Remove deprecated functions so that they generate an error if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * Uncomment to get errors on using deprecated functions. + */ +//#define MBEDTLS_DEPRECATED_REMOVED + +/* \} name SECTION: System support */ + +/** + * \name SECTION: mbed TLS feature support + * + * This section sets support for features that are or are not needed + * within the modules that are enabled. + * \{ + */ + +/** + * \def MBEDTLS_TIMING_ALT + * + * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), + * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() + * + * Only works if you have MBEDTLS_TIMING_C enabled. + * + * You will need to provide a header "timing_alt.h" and an implementation at + * compile time. + */ +//#define MBEDTLS_TIMING_ALT + +/** + * \def MBEDTLS__MODULE_NAME__ALT + * + * Uncomment a macro to let mbed TLS use your alternate core implementation of + * a symmetric crypto or hash module (e.g. platform specific assembly + * optimized implementations). Keep in mind that the function prototypes + * should remain the same. + * + * This replaces the whole module. If you only want to replace one of the + * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer + * provide the "struct mbedtls_aes_context" definition and omit the base function + * declarations and implementations. "aes_alt.h" will be included from + * "aes.h" to include the new function definitions. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * module. + */ +//#define MBEDTLS_AES_ALT +//#define MBEDTLS_ARC4_ALT +//#define MBEDTLS_BLOWFISH_ALT +//#define MBEDTLS_CAMELLIA_ALT +//#define MBEDTLS_DES_ALT +//#define MBEDTLS_XTEA_ALT +//#define MBEDTLS_MD2_ALT +//#define MBEDTLS_MD4_ALT +//#define MBEDTLS_MD5_ALT +//#define MBEDTLS_RIPEMD160_ALT +//#define MBEDTLS_SHA1_ALT +//#define MBEDTLS_SHA256_ALT +//#define MBEDTLS_SHA512_ALT + +/** + * \def MBEDTLS__FUNCTION_NAME__ALT + * + * Uncomment a macro to let mbed TLS use you alternate core implementation of + * symmetric crypto or hash function. Keep in mind that function prototypes + * should remain the same. + * + * This replaces only one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will + * no longer provide the mbedtls_sha1_process() function, but it will still provide + * the other function (using your mbedtls_sha1_process() function) and the definition + * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible + * with this definition. + * + * Note: if you use the AES_xxx_ALT macros, then is is recommended to also set + * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES + * tables. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + */ +//#define MBEDTLS_MD2_PROCESS_ALT +//#define MBEDTLS_MD4_PROCESS_ALT +//#define MBEDTLS_MD5_PROCESS_ALT +//#define MBEDTLS_RIPEMD160_PROCESS_ALT +//#define MBEDTLS_SHA1_PROCESS_ALT +//#define MBEDTLS_SHA256_PROCESS_ALT +//#define MBEDTLS_SHA512_PROCESS_ALT +//#define MBEDTLS_DES_SETKEY_ALT +//#define MBEDTLS_DES_CRYPT_ECB_ALT +//#define MBEDTLS_DES3_CRYPT_ECB_ALT +//#define MBEDTLS_AES_SETKEY_ENC_ALT +//#define MBEDTLS_AES_SETKEY_DEC_ALT +//#define MBEDTLS_AES_ENCRYPT_ALT +//#define MBEDTLS_AES_DECRYPT_ALT + +/** + * \def MBEDTLS_ENTROPY_HARDWARE_ALT + * + * Uncomment this macro to let mbed TLS use your own implementation of a + * hardware entropy collector. + * + * Your function must be called \c mbedtls_hardware_poll(), have the same + * prototype as declared in entropy_poll.h, and accept NULL as first argument. + * + * Uncomment to use your own hardware entropy collector. + */ +//#define MBEDTLS_ENTROPY_HARDWARE_ALT + +/** + * \def MBEDTLS_AES_ROM_TABLES + * + * Store the AES tables in ROM. + * + * Uncomment this macro to store the AES tables in ROM. + */ +#define MBEDTLS_AES_ROM_TABLES + +/** + * \def MBEDTLS_CAMELLIA_SMALL_MEMORY + * + * Use less ROM for the Camellia implementation (saves about 768 bytes). + * + * Uncomment this macro to use less memory for Camellia. + */ +//#define MBEDTLS_CAMELLIA_SMALL_MEMORY + +/** + * \def MBEDTLS_CIPHER_MODE_CBC + * + * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CBC + +/** + * \def MBEDTLS_CIPHER_MODE_CFB + * + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. + */ +//#define MBEDTLS_CIPHER_MODE_CFB + +/** + * \def MBEDTLS_CIPHER_MODE_CTR + * + * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. + */ +//#define MBEDTLS_CIPHER_MODE_CTR + +/** + * \def MBEDTLS_CIPHER_NULL_CIPHER + * + * Enable NULL cipher. + * Warning: Only do so when you know what you are doing. This allows for + * encryption or channels without any security! + * + * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable + * the following ciphersuites: + * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA + * + * Uncomment this macro to enable the NULL cipher and ciphersuites + */ +//#define MBEDTLS_CIPHER_NULL_CIPHER + +/** + * \def MBEDTLS_CIPHER_PADDING_XXX + * + * Uncomment or comment macros to add support for specific padding modes + * in the cipher layer with cipher modes that support padding (e.g. CBC) + * + * If you disable all padding modes, only full blocks can be used with CBC. + * + * Enable padding modes in the cipher layer. + */ +//#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#define MBEDTLS_CIPHER_PADDING_ZEROS + +/** + * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES + * + * Enable weak ciphersuites in SSL / TLS. + * Warning: Only do so when you know what you are doing. This allows for + * channels with virtually no security at all! + * + * This enables the following ciphersuites: + * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA + * + * Uncomment this macro to enable weak ciphersuites + */ +//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES + +/** + * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES + * + * Remove RC4 ciphersuites by default in SSL / TLS. + * This flag removes the ciphersuites based on RC4 from the default list as + * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to + * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them + * explicitly. + * + * Uncomment this macro to remove RC4 ciphersuites by default. + */ +#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES + +/** + * \def MBEDTLS_ECP_XXXX_ENABLED + * + * Enables specific curves within the Elliptic Curve module. + * By default all supported curves are enabled. + * + * Comment macros to disable the curve and functions for it + */ +//#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +//#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +//#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +//#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +//#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +//#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +//#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +//#define MBEDTLS_ECP_DP_BP256R1_ENABLED +//#define MBEDTLS_ECP_DP_BP384R1_ENABLED +//#define MBEDTLS_ECP_DP_BP512R1_ENABLED +//#define MBEDTLS_ECP_DP_CURVE25519_ENABLED + +/** + * \def MBEDTLS_ECP_NIST_OPTIM + * + * Enable specific 'modulo p' routines for each NIST prime. + * Depending on the prime and architecture, makes operations 4 to 8 times + * faster on the corresponding curve. + * + * Comment this macro to disable NIST curves optimisation. + */ +#define MBEDTLS_ECP_NIST_OPTIM + +/** + * \def MBEDTLS_ECDSA_DETERMINISTIC + * + * Enable deterministic ECDSA (RFC 6979). + * Standard ECDSA is "fragile" in the sense that lack of entropy when signing + * may result in a compromise of the long-term signing key. This is avoided by + * the deterministic variant. + * + * Requires: MBEDTLS_HMAC_DRBG_C + * + * Comment this macro to disable deterministic ECDSA. + */ +//#define MBEDTLS_ECDSA_DETERMINISTIC + +/** + * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + * + * Enable the PSK based ciphersuite modes in SSL / TLS. + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + * + * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + * + * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + * + * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + * + * Enable the RSA-only based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + */ +//#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + * + * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + * + * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + */ +#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + * + * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + * + * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + * + * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + * + * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Requires: MBEDTLS_ECJPAKE_C + * MBEDTLS_SHA256_C + * MBEDTLS_ECP_DP_SECP256R1_ENABLED + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + */ +//#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + +/** + * \def MBEDTLS_PK_PARSE_EC_EXTENDED + * + * Enhance support for reading EC keys using variants of SEC1 not allowed by + * RFC 5915 and RFC 5480. + * + * Currently this means parsing the SpecifiedECDomain choice of EC + * parameters (only known groups are supported, not arbitrary domains, to + * avoid validation issues). + * + * Disable if you only need to support RFC 5915 + 5480 key formats. + */ +//#define MBEDTLS_PK_PARSE_EC_EXTENDED + +/** + * \def MBEDTLS_ERROR_STRERROR_DUMMY + * + * Enable a dummy error function to make use of mbedtls_strerror() in + * third party libraries easier when MBEDTLS_ERROR_C is disabled + * (no effect when MBEDTLS_ERROR_C is enabled). + * + * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're + * not using mbedtls_strerror() or error_strerror() in your application. + * + * Disable if you run into name conflicts and want to really remove the + * mbedtls_strerror() + */ +#define MBEDTLS_ERROR_STRERROR_DUMMY + +/** + * \def MBEDTLS_GENPRIME + * + * Enable the prime-number generation code. + * + * Requires: MBEDTLS_BIGNUM_C + */ +#define MBEDTLS_GENPRIME + +/** + * \def MBEDTLS_FS_IO + * + * Enable functions that use the filesystem. + */ +//#define MBEDTLS_FS_IO + +/** + * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + * + * Do not add default entropy sources. These are the platform specific, + * mbedtls_timing_hardclock and HAVEGE based poll functions. + * + * This is useful to have more control over the added entropy sources in an + * application. + * + * Uncomment this macro to prevent loading of default entropy functions. + */ +#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + +/** + * \def MBEDTLS_NO_PLATFORM_ENTROPY + * + * Do not use built-in platform entropy functions. + * This is useful if your platform does not support + * standards like the /dev/urandom or Windows CryptoAPI. + * + * Uncomment this macro to disable the built-in platform entropy functions. + */ +#define MBEDTLS_NO_PLATFORM_ENTROPY + +/** + * \def MBEDTLS_ENTROPY_FORCE_SHA256 + * + * Force the entropy accumulator to use a SHA-256 accumulator instead of the + * default SHA-512 based one (if both are available). + * + * Requires: MBEDTLS_SHA256_C + * + * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option + * if you have performance concerns. + * + * This option is only useful if both MBEDTLS_SHA256_C and + * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. + */ +//#define MBEDTLS_ENTROPY_FORCE_SHA256 + +/** + * \def MBEDTLS_MEMORY_DEBUG + * + * Enable debugging of buffer allocator memory issues. Automatically prints + * (to stderr) all (fatal) messages on memory allocation issues. Enables + * function for 'debug output' of allocated memory. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Uncomment this macro to let the buffer allocator print out error messages. + */ +//#define MBEDTLS_MEMORY_DEBUG + +/** + * \def MBEDTLS_MEMORY_BACKTRACE + * + * Include backtrace information with each allocated block. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * GLIBC-compatible backtrace() an backtrace_symbols() support + * + * Uncomment this macro to include backtrace information + */ +//#define MBEDTLS_MEMORY_BACKTRACE + +/** + * \def MBEDTLS_PK_RSA_ALT_SUPPORT + * + * Support external private RSA keys (eg from a HSM) in the PK layer. + * + * Comment this macro to disable support for external private RSA keys. + */ +//#define MBEDTLS_PK_RSA_ALT_SUPPORT + +/** + * \def MBEDTLS_PKCS1_V15 + * + * Enable support for PKCS#1 v1.5 encoding. + * + * Requires: MBEDTLS_RSA_C + * + * This enables support for PKCS#1 v1.5 operations. + */ +#define MBEDTLS_PKCS1_V15 + +/** + * \def MBEDTLS_PKCS1_V21 + * + * Enable support for PKCS#1 v2.1 encoding. + * + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C + * + * This enables support for RSAES-OAEP and RSASSA-PSS operations. + */ +//#define MBEDTLS_PKCS1_V21 + +/** + * \def MBEDTLS_RSA_NO_CRT + * + * Do not use the Chinese Remainder Theorem for the RSA private operation. + * + * Uncomment this macro to disable the use of CRT in RSA. + * + */ +//#define MBEDTLS_RSA_NO_CRT + +/** + * \def MBEDTLS_SELF_TEST + * + * Enable the checkup functions (*_self_test). + */ +//#define MBEDTLS_SELF_TEST + +/** + * \def MBEDTLS_SHA256_SMALLER + * + * Enable an implementation of SHA-256 that has lower ROM footprint but also + * lower performance. + * + * The default implementation is meant to be a reasonnable compromise between + * performance and size. This version optimizes more aggressively for size at + * the expense of performance. Eg on Cortex-M4 it reduces the size of + * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about + * 30%. + * + * Uncomment to enable the smaller implementation of SHA256. + */ +//#define MBEDTLS_SHA256_SMALLER + +/** + * \def MBEDTLS_SSL_AEAD_RANDOM_IV + * + * Generate a random IV rather than using the record sequence number as a + * nonce for ciphersuites using and AEAD algorithm (GCM or CCM). + * + * Using the sequence number is generally recommended. + * + * Uncomment this macro to always use random IVs with AEAD ciphersuites. + */ +//#define MBEDTLS_SSL_AEAD_RANDOM_IV + +/** + * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES + * + * Enable sending of alert messages in case of encountered errors as per RFC. + * If you choose not to send the alert messages, mbed TLS can still communicate + * with other servers, only debugging of failures is harder. + * + * The advantage of not sending alert messages, is that no information is given + * about reasons for failures thus preventing adversaries of gaining intel. + * + * Enable sending of all alert messages + */ +#define MBEDTLS_SSL_ALL_ALERT_MESSAGES + +/** + * \def MBEDTLS_SSL_DEBUG_ALL + * + * Enable the debug messages in SSL module for all issues. + * Debug messages have been disabled in some places to prevent timing + * attacks due to (unbalanced) debugging function calls. + * + * If you need all error reporting you should enable this during debugging, + * but remove this for production servers that should log as well. + * + * Uncomment this macro to report all debug messages on errors introducing + * a timing side-channel. + * + */ +//#define MBEDTLS_SSL_DEBUG_ALL + +/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC + * + * Enable support for Encrypt-then-MAC, RFC 7366. + * + * This allows peers that both support it to use a more robust protection for + * ciphersuites using CBC, providing deep resistance against timing attacks + * on the padding or underlying cipher. + * + * This only affects CBC ciphersuites, and is useless if none is defined. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Encrypt-then-MAC + */ +#define MBEDTLS_SSL_ENCRYPT_THEN_MAC + +/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET + * + * Enable support for Extended Master Secret, aka Session Hash + * (draft-ietf-tls-session-hash-02). + * + * This was introduced as "the proper fix" to the Triple Handshake familiy of + * attacks, but it is recommended to always use it (even if you disable + * renegotiation), since it actually fixes a more fundamental issue in the + * original SSL/TLS design, and has implications beyond Triple Handshake. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1 or + * MBEDTLS_SSL_PROTO_TLS1_1 or + * MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Extended Master Secret. + */ +//#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET + +/** + * \def MBEDTLS_SSL_FALLBACK_SCSV + * + * Enable support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv-00). + * + * For servers, it is recommended to always enable this, unless you support + * only one version of TLS, or know for sure that none of your clients + * implements a fallback strategy. + * + * For clients, you only need this if you're using a fallback strategy, which + * is not recommended in the first place, unless you absolutely need it to + * interoperate with buggy (version-intolerant) servers. + * + * Comment this macro to disable support for FALLBACK_SCSV + */ +//#define MBEDTLS_SSL_FALLBACK_SCSV + +/** + * \def MBEDTLS_SSL_HW_RECORD_ACCEL + * + * Enable hooking functions in SSL module for hardware acceleration of + * individual records. + * + * Uncomment this macro to enable hooking functions. + */ +//#define MBEDTLS_SSL_HW_RECORD_ACCEL + +/** + * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING + * + * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. + * + * This is a countermeasure to the BEAST attack, which also minimizes the risk + * of interoperability issues compared to sending 0-length records. + * + * Comment this macro to disable 1/n-1 record splitting. + */ +//#define MBEDTLS_SSL_CBC_RECORD_SPLITTING + +/** + * \def MBEDTLS_SSL_RENEGOTIATION + * + * Disable support for TLS renegotiation. + * + * The two main uses of renegotiation are (1) refresh keys on long-lived + * connections and (2) client authentication after the initial handshake. + * If you don't need renegotiation, it's probably better to disable it, since + * it has been associated with security issues in the past and is easy to + * misuse/misunderstand. + * + * Comment this to disable support for renegotiation. + */ +#define MBEDTLS_SSL_RENEGOTIATION + +/** + * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + * + * Enable support for receiving and parsing SSLv2 Client Hello messages for the + * SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to enable support for SSLv2 Client Hello messages. + */ +//#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO + +/** + * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + * + * Pick the ciphersuite according to the client's preferences rather than ours + * in the SSL Server module (MBEDTLS_SSL_SRV_C). + * + * Uncomment this macro to respect client's ciphersuite order + */ +//#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE + +/** + * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + * + * Enable support for RFC 6066 max_fragment_length extension in SSL. + * + * Comment this macro to disable support for the max_fragment_length extension + */ +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + +/** + * \def MBEDTLS_SSL_PROTO_SSL3 + * + * Enable support for SSL 3.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for SSL 3.0 + */ +//#define MBEDTLS_SSL_PROTO_SSL3 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1 + * + * Enable support for TLS 1.0. + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.0 + */ +#define MBEDTLS_SSL_PROTO_TLS1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_1 + * + * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). + * + * Requires: MBEDTLS_MD5_C + * MBEDTLS_SHA1_C + * + * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 + */ +//#define MBEDTLS_SSL_PROTO_TLS1_1 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_2 + * + * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). + * + * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C + * (Depends on ciphersuites) + * + * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 + */ +//#define MBEDTLS_SSL_PROTO_TLS1_2 + +/** + * \def MBEDTLS_SSL_PROTO_DTLS + * + * Enable support for DTLS (all available versions). + * + * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, + * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_1 + * or MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for DTLS + */ +//#define MBEDTLS_SSL_PROTO_DTLS + +/** + * \def MBEDTLS_SSL_ALPN + * + * Enable support for RFC 7301 Application Layer Protocol Negotiation. + * + * Comment this macro to disable support for ALPN. + */ +//#define MBEDTLS_SSL_ALPN + +/** + * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY + * + * Enable support for the anti-replay mechanism in DTLS. + * + * Requires: MBEDTLS_SSL_TLS_C + * MBEDTLS_SSL_PROTO_DTLS + * + * \warning Disabling this is often a security risk! + * See mbedtls_ssl_conf_dtls_anti_replay() for details. + * + * Comment this to disable anti-replay in DTLS. + */ +//#define MBEDTLS_SSL_DTLS_ANTI_REPLAY + +/** + * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Enable support for HelloVerifyRequest on DTLS servers. + * + * This feature is highly recommended to prevent DTLS servers being used as + * amplifiers in DoS attacks against other hosts. It should always be enabled + * unless you know for sure amplification cannot be a problem in the + * environment in which your server operates. + * + * \warning Disabling this can ba a security risk! (see above) + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Comment this to disable support for HelloVerifyRequest. + */ +//#define MBEDTLS_SSL_DTLS_HELLO_VERIFY + +/** + * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + * + * Enable server-side support for clients that reconnect from the same port. + * + * Some clients unexpectedly close the connection and try to reconnect using the + * same source port. This needs special support from the server to handle the + * new connection securely, as described in section 4.2.8 of RFC 6347. This + * flag enables that support. + * + * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Comment this to disable support for clients reusing the source port. + */ +//#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + +/** + * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT + * + * Enable support for a limit of records with bad MAC. + * + * See mbedtls_ssl_conf_dtls_badmac_limit(). + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + */ +//#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT + +/** + * \def MBEDTLS_SSL_SESSION_TICKETS + * + * Enable support for RFC 5077 session tickets in SSL. + * Client-side, provides full support for session tickets (maintainance of a + * session store remains the responsibility of the application, though). + * Server-side, you also need to provide callbacks for writing and parsing + * tickets, including authenticated encryption and key management. Example + * callbacks are provided by MBEDTLS_SSL_TICKET_C. + * + * Comment this macro to disable support for SSL session tickets + */ +//#define MBEDTLS_SSL_SESSION_TICKETS + +/** + * \def MBEDTLS_SSL_EXPORT_KEYS + * + * Enable support for exporting key block and master secret. + * This is required for certain users of TLS, e.g. EAP-TLS. + * + * Comment this macro to disable support for key export + */ +//#define MBEDTLS_SSL_EXPORT_KEYS + +/** + * \def MBEDTLS_SSL_SERVER_NAME_INDICATION + * + * Enable support for RFC 6066 server name indication (SNI) in SSL. + * + * Requires: MBEDTLS_X509_CRT_PARSE_C + * + * Comment this macro to disable support for server name indication in SSL + */ +//#define MBEDTLS_SSL_SERVER_NAME_INDICATION + +/** + * \def MBEDTLS_SSL_TRUNCATED_HMAC + * + * Enable support for RFC 6066 truncated HMAC in SSL. + * + * Comment this macro to disable support for truncated HMAC in SSL + */ +//#define MBEDTLS_SSL_TRUNCATED_HMAC + +/** + * \def MBEDTLS_THREADING_ALT + * + * Provide your own alternate threading implementation. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to allow your own alternate threading implementation. + */ +//#define MBEDTLS_THREADING_ALT + +/** + * \def MBEDTLS_THREADING_PTHREAD + * + * Enable the pthread wrapper layer for the threading layer. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to enable pthread mutexes. + */ +//#define MBEDTLS_THREADING_PTHREAD + +/** + * \def MBEDTLS_VERSION_FEATURES + * + * Allow run-time checking of compile-time enabled features. Thus allowing users + * to check at run-time if the library is for instance compiled with threading + * support via mbedtls_version_check_feature(). + * + * Requires: MBEDTLS_VERSION_C + * + * Comment this to disable run-time checking and save ROM space + */ +#define MBEDTLS_VERSION_FEATURES + +/** + * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an extension in a v1 or v2 certificate. + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 + +/** + * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + * + * If set, the X509 parser will not break-off when parsing an X509 certificate + * and encountering an unknown critical extension. + * + * \warning Depending on your PKI use, enabling this can be a security risk! + * + * Uncomment to prevent an error. + */ +//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION + +/** + * \def MBEDTLS_X509_CHECK_KEY_USAGE + * + * Enable verification of the keyUsage extension (CA and leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused + * (intermediate) CA and leaf certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip keyUsage checking for both CA and leaf certificates. + */ +//#define MBEDTLS_X509_CHECK_KEY_USAGE + +/** + * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + * + * Enable verification of the extendedKeyUsage extension (leaf certificates). + * + * Disabling this avoids problems with mis-issued and/or misused certificates. + * + * \warning Depending on your PKI use, disabling this can be a security risk! + * + * Comment to skip extendedKeyUsage checking for certificates. + */ +//#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + +/** + * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT + * + * Enable parsing and verification of X.509 certificates, CRLs and CSRS + * signed with RSASSA-PSS (aka PKCS#1 v2.1). + * + * Comment this macro to disallow using RSASSA-PSS in certificates. + */ +//#define MBEDTLS_X509_RSASSA_PSS_SUPPORT + +/** + * \def MBEDTLS_ZLIB_SUPPORT + * + * If set, the SSL/TLS module uses ZLIB to support compression and + * decompression of packet data. + * + * \warning TLS-level compression MAY REDUCE SECURITY! See for example the + * CRIME attack. Before enabling this option, you should examine with care if + * CRIME or similar exploits may be a applicable to your use case. + * + * \note Currently compression can't be used with DTLS. + * + * Used in: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This feature requires zlib library and headers to be present. + * + * Uncomment to enable use of ZLIB + */ +//#define MBEDTLS_ZLIB_SUPPORT +/* \} name SECTION: mbed TLS feature support */ + +/** + * \name SECTION: mbed TLS modules + * + * This section enables or disables entire modules in mbed TLS + * \{ + */ + +/** + * \def MBEDTLS_AESNI_C + * + * Enable AES-NI support on x86-64. + * + * Module: library/aesni.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the AES-NI instructions on x86-64 + */ +//#define MBEDTLS_AESNI_C + +/** + * \def MBEDTLS_AES_C + * + * Enable the AES block cipher. + * + * Module: library/aes.c + * Caller: library/ssl_tls.c + * library/pem.c + * library/ctr_drbg.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * + * PEM_PARSE uses AES for decrypting encrypted keys. + */ +#define MBEDTLS_AES_C + +/** + * \def MBEDTLS_ARC4_C + * + * Enable the ARCFOUR stream cipher. + * + * Module: library/arc4.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA + * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +//#define MBEDTLS_ARC4_C + +/** + * \def MBEDTLS_ASN1_PARSE_C + * + * Enable the generic ASN1 parser. + * + * Module: library/asn1.c + * Caller: library/x509.c + * library/dhm.c + * library/pkcs12.c + * library/pkcs5.c + * library/pkparse.c + */ +#define MBEDTLS_ASN1_PARSE_C + +/** + * \def MBEDTLS_ASN1_WRITE_C + * + * Enable the generic ASN1 writer. + * + * Module: library/asn1write.c + * Caller: library/ecdsa.c + * library/pkwrite.c + * library/x509_create.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + */ +#define MBEDTLS_ASN1_WRITE_C + +/** + * \def MBEDTLS_BASE64_C + * + * Enable the Base64 module. + * + * Module: library/base64.c + * Caller: library/pem.c + * + * This module is required for PEM support (required by X.509). + */ +#define MBEDTLS_BASE64_C + +/** + * \def MBEDTLS_BIGNUM_C + * + * Enable the multi-precision integer library. + * + * Module: library/bignum.c + * Caller: library/dhm.c + * library/ecp.c + * library/ecdsa.c + * library/rsa.c + * library/ssl_tls.c + * + * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. + */ +#define MBEDTLS_BIGNUM_C + +/** + * \def MBEDTLS_BLOWFISH_C + * + * Enable the Blowfish block cipher. + * + * Module: library/blowfish.c + */ +//#define MBEDTLS_BLOWFISH_C + +/** + * \def MBEDTLS_CAMELLIA_C + * + * Enable the Camellia block cipher. + * + * Module: library/camellia.c + * Caller: library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +//#define MBEDTLS_CAMELLIA_C + +/** + * \def MBEDTLS_CCM_C + * + * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. + * + * Module: library/ccm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-CCM ciphersuites, if other requisites are + * enabled as well. + */ +//#define MBEDTLS_CCM_C + +/** + * \def MBEDTLS_CERTS_C + * + * Enable the test certificates. + * + * Module: library/certs.c + * Caller: + * + * This module is used for testing (ssl_client/server). + */ +//#define MBEDTLS_CERTS_C + +/** + * \def MBEDTLS_CIPHER_C + * + * Enable the generic cipher layer. + * + * Module: library/cipher.c + * Caller: library/ssl_tls.c + * + * Uncomment to enable generic cipher wrappers. + */ +#define MBEDTLS_CIPHER_C + +/** + * \def MBEDTLS_CTR_DRBG_C + * + * Enable the CTR_DRBG AES-256-based random generator. + * + * Module: library/ctr_drbg.c + * Caller: + * + * Requires: MBEDTLS_AES_C + * + * This module provides the CTR_DRBG AES-256 random number generator. + */ +//#define MBEDTLS_CTR_DRBG_C + +/** + * \def MBEDTLS_DEBUG_C + * + * Enable the debug functions. + * + * Module: library/debug.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module provides debugging functions. + */ +//#define MBEDTLS_DEBUG_C + +/** + * \def MBEDTLS_DES_C + * + * Enable the DES block cipher. + * + * Module: library/des.c + * Caller: library/pem.c + * library/ssl_tls.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA + * + * PEM_PARSE uses DES/3DES for decrypting encrypted keys. + */ +//#define MBEDTLS_DES_C + +/** + * \def MBEDTLS_DHM_C + * + * Enable the Diffie-Hellman-Merkle module. + * + * Module: library/dhm.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * DHE-RSA, DHE-PSK + */ +//#define MBEDTLS_DHM_C + +/** + * \def MBEDTLS_ECDH_C + * + * Enable the elliptic curve Diffie-Hellman library. + * + * Module: library/ecdh.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK + * + * Requires: MBEDTLS_ECP_C + */ +#define MBEDTLS_ECDH_C + +/** + * \def MBEDTLS_ECDSA_C + * + * Enable the elliptic curve DSA library. + * + * Module: library/ecdsa.c + * Caller: + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C + */ +#define MBEDTLS_ECDSA_C + +/** + * \def MBEDTLS_ECJPAKE_C + * + * Enable the elliptic curve J-PAKE library. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Module: library/ecjpake.c + * Caller: + * + * This module is used by the following key exchanges: + * ECJPAKE + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C + */ +//#define MBEDTLS_ECJPAKE_C + +/** + * \def MBEDTLS_ECP_C + * + * Enable the elliptic curve over GF(p) library. + * + * Module: library/ecp.c + * Caller: library/ecdh.c + * library/ecdsa.c + * library/ecjpake.c + * + * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED + */ +#define MBEDTLS_ECP_C + +/** + * \def MBEDTLS_ENTROPY_C + * + * Enable the platform-specific entropy code. + * + * Module: library/entropy.c + * Caller: + * + * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C + * + * This module provides a generic entropy pool + */ +//#define MBEDTLS_ENTROPY_C + +/** + * \def MBEDTLS_ERROR_C + * + * Enable error code to error string conversion. + * + * Module: library/error.c + * Caller: + * + * This module enables mbedtls_strerror(). + */ +//#define MBEDTLS_ERROR_C + +/** + * \def MBEDTLS_GCM_C + * + * Enable the Galois/Counter Mode (GCM) for AES. + * + * Module: library/gcm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other + * requisites are enabled as well. + */ +//#define MBEDTLS_GCM_C + +/** + * \def MBEDTLS_HAVEGE_C + * + * Enable the HAVEGE random generator. + * + * Warning: the HAVEGE random generator is not suitable for virtualized + * environments + * + * Warning: the HAVEGE random generator is dependent on timing and specific + * processor traits. It is therefore not advised to use HAVEGE as + * your applications primary random generator or primary entropy pool + * input. As a secondary input to your entropy pool, it IS able add + * the (limited) extra entropy it provides. + * + * Module: library/havege.c + * Caller: + * + * Requires: MBEDTLS_TIMING_C + * + * Uncomment to enable the HAVEGE random generator. + */ +//#define MBEDTLS_HAVEGE_C + +/** + * \def MBEDTLS_HMAC_DRBG_C + * + * Enable the HMAC_DRBG random generator. + * + * Module: library/hmac_drbg.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * Uncomment to enable the HMAC_DRBG random number geerator. + */ +//#define MBEDTLS_HMAC_DRBG_C + +/** + * \def MBEDTLS_MD_C + * + * Enable the generic message digest layer. + * + * Module: library/mbedtls_md.c + * Caller: + * + * Uncomment to enable generic message digest wrappers. + */ +#define MBEDTLS_MD_C + +/** + * \def MBEDTLS_MD2_C + * + * Enable the MD2 hash algorithm. + * + * Module: library/mbedtls_md2.c + * Caller: + * + * Uncomment to enable support for (rare) MD2-signed X.509 certs. + */ +//#define MBEDTLS_MD2_C + +/** + * \def MBEDTLS_MD4_C + * + * Enable the MD4 hash algorithm. + * + * Module: library/mbedtls_md4.c + * Caller: + * + * Uncomment to enable support for (rare) MD4-signed X.509 certs. + */ +//#define MBEDTLS_MD4_C + +/** + * \def MBEDTLS_MD5_C + * + * Enable the MD5 hash algorithm. + * + * Module: library/mbedtls_md5.c + * Caller: library/mbedtls_md.c + * library/pem.c + * library/ssl_tls.c + * + * This module is required for SSL/TLS and X.509. + * PEM_PARSE uses MD5 for decrypting encrypted keys. + */ +#define MBEDTLS_MD5_C + + +/** + * \def MBEDTLS_NET_C + * + * Enable the TCP/IP networking routines. + * + * Module: library/net.c + * + * This module provides TCP/IP networking routines. + */ +//#define MBEDTLS_NET_C + +/** + * \def MBEDTLS_OID_C + * + * Enable the OID database. + * + * Module: library/oid.c + * Caller: library/asn1write.c + * library/pkcs5.c + * library/pkparse.c + * library/pkwrite.c + * library/rsa.c + * library/x509.c + * library/x509_create.c + * library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + * + * This modules translates between OIDs and internal values. + */ +#define MBEDTLS_OID_C + +/** + * \def MBEDTLS_PADLOCK_C + * + * Enable VIA Padlock support on x86. + * + * Module: library/padlock.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the VIA PadLock on x86. + */ +//#define MBEDTLS_PADLOCK_C + +/** + * \def MBEDTLS_PEM_PARSE_C + * + * Enable PEM decoding / parsing. + * + * Module: library/pem.c + * Caller: library/dhm.c + * library/pkparse.c + * library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for decoding / parsing PEM files. + */ +#define MBEDTLS_PEM_PARSE_C + +/** + * \def MBEDTLS_PEM_WRITE_C + * + * Enable PEM encoding / writing. + * + * Module: library/pem.c + * Caller: library/pkwrite.c + * library/x509write_crt.c + * library/mbedtls_x509write_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for encoding / writing PEM files. + */ +//#define MBEDTLS_PEM_WRITE_C + +/** + * \def MBEDTLS_PK_C + * + * Enable the generic public (asymetric) key layer. + * + * Module: library/pk.c + * Caller: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C + * + * Uncomment to enable generic public key wrappers. + */ +#define MBEDTLS_PK_C + +/** + * \def MBEDTLS_PK_PARSE_C + * + * Enable the generic public (asymetric) key parser. + * + * Module: library/pkparse.c + * Caller: library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key parse functions. + */ +#define MBEDTLS_PK_PARSE_C + +/** + * \def MBEDTLS_PK_WRITE_C + * + * Enable the generic public (asymetric) key writer. + * + * Module: library/pkwrite.c + * Caller: library/x509write.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key write functions. + */ +#define MBEDTLS_PK_WRITE_C + +/** + * \def MBEDTLS_PKCS5_C + * + * Enable PKCS#5 functions. + * + * Module: library/pkcs5.c + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the PKCS#5 functions. + */ +//#define MBEDTLS_PKCS5_C + +/** + * \def MBEDTLS_PKCS11_C + * + * Enable wrapper for PKCS#11 smartcard support. + * + * Module: library/pkcs11.c + * Caller: library/pk.c + * + * Requires: MBEDTLS_PK_C + * + * This module enables SSL/TLS PKCS #11 smartcard support. + * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) + */ +//#define MBEDTLS_PKCS11_C + +/** + * \def MBEDTLS_PKCS12_C + * + * Enable PKCS#12 PBE functions. + * Adds algorithms for parsing PKCS#8 encrypted private keys + * + * Module: library/pkcs12.c + * Caller: library/pkparse.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * Can use: MBEDTLS_ARC4_C + * + * This module enables PKCS#12 functions. + */ +//#define MBEDTLS_PKCS12_C + +/** + * \def MBEDTLS_PLATFORM_C + * + * Enable the platform abstraction layer that allows you to re-assign + * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). + * + * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT + * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned + * above to be specified at runtime or compile time respectively. + * + * \note This abstraction layer must be enabled on Windows (including MSYS2) + * as other module rely on it for a fixed snprintf implementation. + * + * Module: library/platform.c + * Caller: Most other .c files + * + * This module enables abstraction of common (libc) functions. + */ +#define MBEDTLS_PLATFORM_C + +/** + * \def MBEDTLS_RIPEMD160_C + * + * Enable the RIPEMD-160 hash algorithm. + * + * Module: library/mbedtls_ripemd160.c + * Caller: library/mbedtls_md.c + * + */ +//#define MBEDTLS_RIPEMD160_C + +/** + * \def MBEDTLS_RSA_C + * + * Enable the RSA public-key cryptosystem. + * + * Module: library/rsa.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509.c + * + * This module is used by the following key exchanges: + * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C + */ +#define MBEDTLS_RSA_C + +/** + * \def MBEDTLS_SHA1_C + * + * Enable the SHA1 cryptographic hash algorithm. + * + * Module: library/mbedtls_sha1.c + * Caller: library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509write_crt.c + * + * This module is required for SSL/TLS and SHA1-signed certificates. + */ +#define MBEDTLS_SHA1_C + +/** + * \def MBEDTLS_SHA256_C + * + * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. + * + * Module: library/mbedtls_sha256.c + * Caller: library/entropy.c + * library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module adds support for SHA-224 and SHA-256. + * This module is required for the SSL/TLS 1.2 PRF function. + */ +#define MBEDTLS_SHA256_C + +/** + * \def MBEDTLS_SHA512_C + * + * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. + * + * Module: library/mbedtls_sha512.c + * Caller: library/entropy.c + * library/mbedtls_md.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * This module adds support for SHA-384 and SHA-512. + */ +#define MBEDTLS_SHA512_C + +/** + * \def MBEDTLS_SSL_CACHE_C + * + * Enable simple SSL cache implementation. + * + * Module: library/ssl_cache.c + * Caller: + * + * Requires: MBEDTLS_SSL_CACHE_C + */ +//#define MBEDTLS_SSL_CACHE_C + +/** + * \def MBEDTLS_SSL_COOKIE_C + * + * Enable basic implementation of DTLS cookies for hello verification. + * + * Module: library/ssl_cookie.c + * Caller: + */ +//#define MBEDTLS_SSL_COOKIE_C + +/** + * \def MBEDTLS_SSL_TICKET_C + * + * Enable an implementation of TLS server-side callbacks for session tickets. + * + * Module: library/ssl_ticket.c + * Caller: + * + * Requires: MBEDTLS_CIPHER_C + */ +//#define MBEDTLS_SSL_TICKET_C + +/** + * \def MBEDTLS_SSL_CLI_C + * + * Enable the SSL/TLS client code. + * + * Module: library/ssl_cli.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS client support. + */ +#define MBEDTLS_SSL_CLI_C + +/** + * \def MBEDTLS_SSL_SRV_C + * + * Enable the SSL/TLS server code. + * + * Module: library/ssl_srv.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS server support. + */ +//#define MBEDTLS_SSL_SRV_C + +/** + * \def MBEDTLS_SSL_TLS_C + * + * Enable the generic SSL/TLS code. + * + * Module: library/ssl_tls.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * and at least one of the MBEDTLS_SSL_PROTO_XXX defines + * + * This module is required for SSL/TLS. + */ +#define MBEDTLS_SSL_TLS_C + +/** + * \def MBEDTLS_THREADING_C + * + * Enable the threading abstraction layer. + * By default mbed TLS assumes it is used in a non-threaded environment or that + * contexts are not shared between threads. If you do intend to use contexts + * between threads, you will need to enable this layer to prevent race + * conditions. + * + * Module: library/threading.c + * + * This allows different threading implementations (self-implemented or + * provided). + * + * You will have to enable either MBEDTLS_THREADING_ALT or + * MBEDTLS_THREADING_PTHREAD. + * + * Enable this layer to allow use of mutexes within mbed TLS + */ +//#define MBEDTLS_THREADING_C + +/** + * \def MBEDTLS_TIMING_C + * + * Enable the portable timing interface. + * + * Module: library/timing.c + * Caller: library/havege.c + * + * This module is used by the HAVEGE random number generator. + */ +//#define MBEDTLS_TIMING_C + +/** + * \def MBEDTLS_VERSION_C + * + * Enable run-time version information. + * + * Module: library/version.c + * + * This module provides run-time version information. + */ +#define MBEDTLS_VERSION_C + +/** + * \def MBEDTLS_X509_USE_C + * + * Enable X.509 core for using certificates. + * + * Module: library/x509.c + * Caller: library/mbedtls_x509_crl.c + * library/mbedtls_x509_crt.c + * library/mbedtls_x509_csr.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, + * MBEDTLS_PK_PARSE_C + * + * This module is required for the X.509 parsing modules. + */ +#define MBEDTLS_X509_USE_C + +/** + * \def MBEDTLS_X509_CRT_PARSE_C + * + * Enable X.509 certificate parsing. + * + * Module: library/mbedtls_x509_crt.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 certificate parsing. + */ +#define MBEDTLS_X509_CRT_PARSE_C + +/** + * \def MBEDTLS_X509_CRL_PARSE_C + * + * Enable X.509 CRL parsing. + * + * Module: library/mbedtls_x509_crl.c + * Caller: library/mbedtls_x509_crt.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 CRL parsing. + */ +#define MBEDTLS_X509_CRL_PARSE_C + +/** + * \def MBEDTLS_X509_CSR_PARSE_C + * + * Enable X.509 Certificate Signing Request (CSR) parsing. + * + * Module: library/mbedtls_x509_csr.c + * Caller: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is used for reading X.509 certificate request. + */ +#define MBEDTLS_X509_CSR_PARSE_C + +/** + * \def MBEDTLS_X509_CREATE_C + * + * Enable X.509 core for creating certificates. + * + * Module: library/x509_create.c + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C + * + * This module is the basis for creating X.509 certificates and CSRs. + */ +#define MBEDTLS_X509_CREATE_C + +/** + * \def MBEDTLS_X509_CRT_WRITE_C + * + * Enable creating X.509 certificates. + * + * Module: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate creation. + */ +//#define MBEDTLS_X509_CRT_WRITE_C + +/** + * \def MBEDTLS_X509_CSR_WRITE_C + * + * Enable creating X.509 Certificate Signing Requests (CSR). + * + * Module: library/x509_csr_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate request writing. + */ +//#define MBEDTLS_X509_CSR_WRITE_C + +/** + * \def MBEDTLS_XTEA_C + * + * Enable the XTEA block cipher. + * + * Module: library/xtea.c + * Caller: + */ +//#define MBEDTLS_XTEA_C + +/* \} name SECTION: mbed TLS modules */ + +/** + * \name SECTION: Module configuration options + * + * This section allows for the setting of module specific sizes and + * configuration options. The default values are already present in the + * relevant header files and should suffice for the regular use cases. + * + * Our advice is to enable options and change their values here + * only if you have a good reason and know the consequences. + * + * Please check the respective header file for documentation on these + * parameters (to prevent duplicate documentation). + * \{ + */ + +/* MPI / BIGNUM options */ +//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ +//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ + +/* CTR_DRBG options */ +//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ +//#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* HMAC_DRBG options */ +//#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ +//#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ +//#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ +//#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ + +/* ECP options */ +//#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ +//#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ + +/* Entropy options */ +//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ +//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ + +/* Memory buffer allocator options */ +#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ + +/* Platform options */ +//#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ +//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ + +/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ +/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ +//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ +/* Note: your snprintf must correclty zero-terminate the buffer! */ +//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ + +/* SSL Cache options */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ +//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ + +/* SSL options */ +#define MBEDTLS_SSL_MAX_CONTENT_LEN 3072 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ +//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ +#define MBEDTLS_PSK_MAX_LEN 16 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ +//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ + +/** + * Complete list of ciphersuites to use, in order of preference. + * + * \warning No dependency checking is done on that field! This option can only + * be used to restrict the set of available ciphersuites. It is your + * responsibility to make sure the needed modules are active. + * + * Use this to save a few hundred bytes of ROM (default ordering of all + * available ciphersuites) and a few to a few hundred bytes of RAM. + * + * The value below is only an example, not the default. + */ +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,\ + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,\ + MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA,\ + MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + +/* X509 options */ +//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ + +/* \} name SECTION: Module configuration options */ + +#if defined(TARGET_LIKE_MBED) +#include "mbedtls/target_config.h" +#endif + +/* + * Allow user to override any previous default. + * + * Use two macro names for that, as: + * - with yotta the prefix YOTTA_CFG_ is forced + * - without yotta is looks weird to have a YOTTA prefix. + */ +#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) +#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE +#elif defined(MBEDTLS_USER_CONFIG_FILE) +#include MBEDTLS_USER_CONFIG_FILE +#endif + +// Adding include to stdio.h to prevent warning (not finding snprintf) +#include + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls_interface.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls_interface.c new file mode 100644 index 0000000..bf87f79 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/mbedtls/tls_interface.c @@ -0,0 +1,1111 @@ +/** + * Copyright (c) 2016 - 2019, 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 +#include +#include "nrf_error.h" +#include "nrf_drv_rng.h" +#include "app_fifo.h" +#include "mem_manager.h" +#include "mbedtls/ssl.h" +#include "mbedtls/platform.h" +#include "mbedtls/sha256.h" +#include "mbedtls/debug.h" +#include "nrf_tls.h" +#include "nrf_assert.h" +#include "iot_timer.h" +#include "iot_errors.h" + +#if TLS_CONFIG_LOG_ENABLED + +#define NRF_LOG_MODULE_NAME TLS + +#define NRF_LOG_LEVEL TLS_CONFIG_LOG_LEVEL +#define NRF_LOG_INFO_COLOR TLS_CONFIG_INFO_COLOR +#define NRF_LOG_DEBUG_COLOR TLS_CONFIG_DEBUG_COLOR + +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define TLS_LOG NRF_LOG_INFO /**< Used for getting trace of execution in the module. */ +#define TLS_ERR NRF_LOG_ERROR /**< Used for logging errors in the module. */ +#define TLS_DUMP NRF_LOG_HEXDUMP_DEBUG /**< Used for dumping octet information to get details of bond information etc. */ + +#define TLS_ENTRY() TLS_TRC(">> %s", __func__) +#define TLS_EXIT() TLS_TRC("<< %s", __func__) + +#else // TLS_CONFIG_LOG_ENABLED + +#define TLS_LOG(...) /**< Disables traces. */ +#define TLS_DUMP(...) /**< Disables dumping of octet streams. */ +#define TLS_ERR(...) /**< Disables error logs. */ + +#define TLS_ENTRY(...) +#define TLS_EXIT(...) + +#endif // TLS_CONFIG_LOG_ENABLED + +#define TIME_PERIOD_INVALID 0xFFFFFFFF /**< Identifier for invalid time period. Used for timer functions. */ + +#define TLS_MUTEX_LOCK() SDK_MUTEX_LOCK(m_tls_mutex) /**< Lock module using mutex */ +#define TLS_MUTEX_UNLOCK() SDK_MUTEX_UNLOCK(m_tls_mutex) /**< Unlock module using mutex */ + +/** + * @brief This macro is used for developer debugging. + * + * @note Not enabled normally as too many logs result and this level of detail is needed + * less frequently. + */ +#define TLS_TRC(...) + +/**@brief TLS interface. */ +typedef struct +{ + uint32_t transport_id; /**< Transport identifier provided by the application to map the TLS instance with associated transport. Set by the application on allocation. */ + nrf_tls_output_t output_fn; /**< Output function registered by the application to write TLS data on the transport. */ + app_fifo_t input_fifo; /**< Input FIFO used for queueing up data received from the transport. Data on the transport us*/ + app_fifo_t output_fifo; /**< Output FIFO used for queueing up decrypted data received on the TLS interface. */ + mbedtls_ssl_context context; /**< SSL context used by mBedTLS for managing the TLS instance. */ + mbedtls_ssl_config conf; /**< Pointer to the configuration paramaters used for the instance. Memory is allocated on nrf_tls_alloc. */ +#ifdef MBEDTLS_X509_CRT_PARSE_C + mbedtls_pk_context pkey; /**< Private key information. Used only when own certificate is provided. */ + mbedtls_x509_crt * p_owncert; /**< Own parsed certificate. */ + mbedtls_x509_crt * p_cacert; /**< CA's parsed certificate. */ +#endif // MBEDTLS_X509_CRT_PARSE_C + /**@brief Timer management used to provide timeouts to the TLS library. */ + uint32_t start_tick; /**< Indicator (in milliseconds) of when the timeout was requested. */ + uint32_t intrmediate_delay; /**< Period indicating intermediate timeout period in milliseconds. */ + uint32_t final_delay; /**< Final timeout period in milliseconds. */ +} interface_t; + + +#ifdef MBEDTLS_X509_CRT_PARSE_C + +/**@brief Input buffer size used for the input FIFO. + * + * @note For ECDHE-RSA, though the context length is set to a value smaller than 3072, a buffer size + * of 4k is needed for the cloud sends a certificate that does not fit the size. + * Also configuration of input FIFO is possible in powers of 2 therefore tuning this value to + * a smaller FIFO size to exactly the size of certificate size is not possible. + */ +#define INPUT_BUFFER_SIZE 4096 + +#endif // MBEDTLS_X509_CRT_PARSE_C + +/**@brief Input buffer size when certificates are not used. */ +#ifndef INPUT_BUFFER_SIZE +#define INPUT_BUFFER_SIZE MBEDTLS_SSL_MAX_CONTENT_LEN +#endif // INPUT_BUFFER_SIZE + +/**@brief Output buffer size. + * + * @note Limiting to 1024 instead of MBEDTLS_SSL_MAX_CONTENT_LEN due to RAM constraints. + */ +#define OUTPUT_BUFFER_SIZE 1024 + + +static interface_t * m_interface[NRF_TLS_MAX_INSTANCE_COUNT]; /**< Interface table to manage the interfaces. */ +static uint8_t m_input_buffer[INPUT_BUFFER_SIZE * NRF_TLS_MAX_INSTANCE_COUNT]; /**< Input buffer that is statically reserved. */ +SDK_MUTEX_DEFINE(m_tls_mutex) /**< Mutex variable. Currently unused, this declaration does not occupy any space in RAM. */ + + +/**@brief Initializes the interface. + * + * @param[in] index Identifies instance in m_interface table to be initialized. + */ +static __INLINE void interface_init(uint32_t index) +{ + m_interface[index] = NULL; +} + + +/**@brief Wrapper function to avoid GCC errors with incompatible parameters. + * + * @param[in] n Number of blocks to be allocated. + * @param[in] s Size of each block to be assigned. + * + * @retval Pointer to memory block if procedure succeeded. + * @retval NULL if procedure failed. + */ +static __INLINE void * wrapper_calloc(size_t n, size_t s) +{ + return nrf_calloc(n,s); +} + + +/**@brief Frees an allocated interface instance. + * + * @param[in] p_instance Identifies the interface instance to be freed. + */ +static void interface_free(uint32_t index) +{ + interface_t * const p_interface = m_interface[index]; + + if (p_interface != NULL) + { + nrf_free(p_interface->input_fifo.p_buf); + nrf_free(p_interface->output_fifo.p_buf); +#ifdef MBEDTLS_X509_CRT_PARSE_C + nrf_free(p_interface->p_cacert); + nrf_free(p_interface->p_owncert); +#endif // MBEDTLS_X509_CRT_PARSE_C + + mbedtls_ssl_config_free(&p_interface->conf); + mbedtls_ssl_config_init(&p_interface->conf); + + mbedtls_ssl_free(&p_interface->context); + + nrf_free(p_interface); + } + interface_init(index); +} + + +/**@brief Allocates an interface instance. + * + * @param[inout] p_instance Provides transport identifier for the TLS instance. + * And if procedure was successful, will conatin allocated TLS instance identifier. + * @param[in] p_options TLS options to be used for the instance. + * + * @retval NRF_SUCCESS if the procedure was successful, else an error code indicating reason + ( for failure. + */ +static uint32_t interface_alloc(nrf_tls_instance_t * p_instance, + nrf_tls_options_t const * p_options) +{ + uint32_t index; + uint32_t err_code = NRF_TLS_NO_FREE_INSTANCE; + interface_t * p_interface = NULL; + + TLS_ENTRY(); + + // Allocate memory for the TLS instance. + for (index = 0; index < NRF_TLS_MAX_INSTANCE_COUNT; index++) + { + if (m_interface[index] == NULL) + { + err_code = (NRF_ERROR_NO_MEM | IOT_TLS_ERR_BASE); + + // Check if we have space to book keep the instance information. + p_interface = nrf_malloc(sizeof(interface_t)); + + m_interface[index] = p_interface; + break; + } + } + + if ((index < NRF_TLS_MAX_INSTANCE_COUNT) && (p_interface != NULL)) + { + // Initialize the memory holding the structure. + memset(p_interface, 0, sizeof(interface_t)); + + p_interface->output_fn = p_options->output_fn; + + // Found free instance. Allocate memory for input and output queues. + uint8_t * p_input_memory = &m_input_buffer[INPUT_BUFFER_SIZE * index]; + uint8_t * p_output_memory = (uint8_t *)nrf_malloc(OUTPUT_BUFFER_SIZE); + + TLS_LOG("Input memory address %p", p_input_memory); + TLS_LOG("Output memory address %p", p_output_memory); + + if (p_output_memory != NULL) + { + // Initialize the instance. + err_code = app_fifo_init(&p_interface->input_fifo, + p_input_memory, + INPUT_BUFFER_SIZE); + + TLS_LOG("Input FIFO init result %08lx", err_code); + + if (err_code == NRF_SUCCESS) + { + err_code = app_fifo_init(&p_interface->output_fifo, + p_output_memory, + OUTPUT_BUFFER_SIZE); + + TLS_LOG("Output FIFO init result %08lx", err_code); + } + + if (err_code == NRF_SUCCESS) + { + // All prerequisites for using the instance met. + // Procedure was successful. + p_interface->transport_id = p_instance->transport_id; + p_instance->instance_id = index; + } + else + { + err_code = (NRF_ERROR_INTERNAL | IOT_TLS_ERR_BASE); + } + } + + if (err_code != NRF_SUCCESS) + { + TLS_ERR("Allocation failed - Initialization procedures."); + interface_free(index); + } + } + else + { + TLS_ERR("Allocation failed - Inadequate memory."); + } + + return err_code; +} + + +/**@brief Transport read function registered with the TLS library. + * + * @details Data read on the transport is fed to the interface using the nrf_tls_input function. + * The TLS library requests the data based on state of SSL connection. + * + * @param[in] p_ctx Context registered with the library on creation of the TLS instance. + * @param[out] p_buffer Buffer where read data is fetched. + * @param[in] size Size to be read. + * + * @retval size of data read if procedure was successful. + * @retval MBEDTLS_ERR_SSL_CONN_EOF indicating there is not enough data received on the transport. + */ +static int interface_transport_read(void * p_ctx, + unsigned char * p_buffer, + size_t buffer_size) +{ + uint32_t err_code; + uint32_t length = buffer_size; + interface_t * const p_interface = m_interface[(uint32_t)p_ctx]; + uint32_t available_size = 0; + + TLS_MUTEX_LOCK(); + + TLS_TRC("[%p]: interface_transport_read requested %08x", + p_interface, + buffer_size); + + // Verify how much data is available in the queue. + err_code = app_fifo_read(&p_interface->input_fifo, NULL, &available_size); + + TLS_TRC("[%p]: interface_transport_read, app_fifo_read result %ld", + p_interface, + err_code); + + // For datagram connection, read all that is available. + // For stream sockets, read only if available data is at least as much as requested. + if (( (p_interface->conf.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) && + (available_size > 0) )|| + ( (p_interface->conf.transport == MBEDTLS_SSL_TRANSPORT_STREAM) && + (available_size >= buffer_size)) ) + { + TLS_TRC("[%p]: interface_transport_read requested 0x%08x, available %08lx.", + p_interface, + buffer_size, + available_size); + + err_code = app_fifo_read(&p_interface->input_fifo, p_buffer, &length); + + if (err_code == NRF_SUCCESS) + { + TLS_TRC("[%p]: interface_transport_read success, length 0x%08lx.", + p_interface, + length); + + TLS_TRC("[NRF TLS]: ---------------- SSL Read data --------------"); + TLS_DUMP(p_buffer, length); + TLS_TRC("[NRF TLS]: -------------------- End ------------------"); + + TLS_MUTEX_UNLOCK(); + + return length; + } + } + else + { + TLS_TRC("[%p]: interface_transport_read requested size 0x%08x, " + "available 0x%08lx.", + p_interface, + buffer_size, + available_size); + } + + TLS_MUTEX_UNLOCK(); + + return MBEDTLS_ERR_SSL_CONN_EOF; +} + + +/**@brief Write function that the TLS library calls to write on the transport. + * + * @param[in] p_ctx Context registered with the library on creation of the TLS instance. + * @param[in] p_buf Buffer containing data to be written on the transport. + * @param[in] len Length of data to be written. + * + * @retval length of data written on the transport if the procedure was successful. + * @retval MBEDTLS_ERR_SSL_CONN_EOF in case the procedure failed. + */ +static int interface_transport_write(void * p_ctx, + const unsigned char * p_buf, + size_t len) +{ + int op_len = len; + interface_t * const p_interface = m_interface[(uint32_t)p_ctx]; + + TLS_MUTEX_LOCK(); + + const nrf_tls_instance_t handle = { + .transport_id = p_interface->transport_id, + .instance_id = (uint32_t)p_ctx + }; + + TLS_TRC("[%p]: interface_transport_write requested 0x%08x", + p_interface, len); + + TLS_MUTEX_UNLOCK(); + + uint32_t err_code = p_interface->output_fn(&handle, (uint8_t *)p_buf, len); + + TLS_MUTEX_LOCK(); + + if (err_code != NRF_SUCCESS) + { + op_len = MBEDTLS_ERR_SSL_CONN_EOF; + } + + TLS_MUTEX_UNLOCK(); + + return op_len; +} + + +/** + * @brief Random number generator registered with the TLS library to create random numbers + * when needed. + * + * @param[in] p_ctx Context registered with the library on creation of the TLS instance. + * @param[out] p_buffer Buffer where generated random vector is to be fetched. + * @param[in] size Requested size of the random vector. + * + * @retval 0 when procedure is successful. + * + * @note This loop is time critical when available is less than requested size. + */ +static int random_vector_generate(void * p_ctx, + unsigned char * p_buffer, + size_t size) +{ + uint8_t available = 0; + + ASSERT(size <= RNG_CONFIG_POOL_SIZE); + + while (available < size) + { + nrf_drv_rng_bytes_available(&available); + + TLS_TRC(">> random_vector_generate, requested 0x%08lx, available 0x%08x", + size, + available); + } + + UNUSED_RETURN_VALUE(nrf_drv_rng_rand(p_buffer, size)); + + return 0; +} + + +/**@brief Routine called periodically to advance the SSL context state. + * + * @param[in] p_instance Provides transport identifier for the TLS instance. + */ +static void interface_continue(interface_t * p_interface) +{ + uint8_t * data = nrf_malloc(OUTPUT_BUFFER_SIZE); + + if (data != NULL) + { + int len; + + TLS_MUTEX_UNLOCK(); + + len = mbedtls_ssl_read(&p_interface->context, &data[0], OUTPUT_BUFFER_SIZE); + + TLS_MUTEX_LOCK(); + + TLS_TRC("[%p]: mbedtls_ssl_read result(len) 0x%08lx", + p_interface, + len); + + if (len > 0) + { + uint32_t write_len = len; + + uint32_t err_code = app_fifo_write(&p_interface->output_fifo, data, &write_len); + if (err_code != NRF_SUCCESS) + { + TLS_LOG("Failed to write decrypted data."); + } + } + + nrf_free(data); + } +} + + +/**@brief Debug log funciton registered with the TLS library. + * + * @param[in] p_ctx Context registered with the library on creation of the TLS instance. + * @param[in] level Debug level of the log. + * @param[in] p_file File requesting the log. + * @param[in] line Line number in the file requesting the log. + * @param[in] p_str String containing the log message. + */ +static void mbedtls_log(void * p_ctx, + int level, + const char * p_file, + int line, + const char * p_str) +{ + TLS_LOG("[%s]:[%d]: %s", &p_file[strlen(p_file)-12], line, p_str); +} + + +/**@brief Function registered with TLS library to set (start/stop) timer. + * + * @param[in] p_ctx Context registered with the library on creation of the TLS instance. + * @param[in] int_ms Intermediate timeout period in milliseconds. + * @param[in] fin_ms Finaly timout period in milliseconds. + * Value of zero indicates a request to stop the timer. + */ +static void tls_set_timer(void * p_ctx, + uint32_t int_ms, + uint32_t fin_ms) +{ + TLS_MUTEX_LOCK(); + + interface_t * const p_interface = m_interface[(uint32_t)p_ctx]; + + if (fin_ms > 0) + { + TLS_TRC("[%p]: set_timer, start %d, final %d, intermediate %d", + p_interface, + p_interface->start_tick, + p_interface->final_delay, + p_interface->intrmediate_delay); + + uint32_t err_code = iot_timer_wall_clock_get(&p_interface->start_tick); + + if (err_code == NRF_SUCCESS) + { + p_interface->final_delay = fin_ms; + p_interface->intrmediate_delay = int_ms; + } + } + else + { + p_interface->start_tick = TIME_PERIOD_INVALID; + p_interface->final_delay = TIME_PERIOD_INVALID; + p_interface->intrmediate_delay = 0; + } + + TLS_MUTEX_UNLOCK(); +} + + +/**@brief Function registered with TLS library to get the status of the timer. + * + * @param[in] p_ctx Context registered with the library on creation of the TLS instance. + * + * @retval -1 if timer is cancelled + * @retval 0 if none of the delays is expired + * @retval 1 if the intermediate delay only is expired + * @retval 2 if the final delay is expired + */ +static int tls_get_timer(void * p_ctx) +{ + int retval = 0; + + TLS_MUTEX_LOCK(); + + iot_timer_time_in_ms_t elapsed_time; + interface_t * const p_interface = m_interface[(uint32_t)p_ctx]; + + uint32_t err_code = iot_timer_wall_clock_delta_get(&p_interface->start_tick, &elapsed_time); + + TLS_TRC("[%p]: get_timer, start %d, final %d, intermediate %d, elapsed %d", + p_interface, + p_interface->start_tick, + p_interface->final_delay, + p_interface->intrmediate_delay, + elapsed_time); + + if (err_code == NRF_SUCCESS) + { + if (p_interface->final_delay <= elapsed_time) + { + retval = 2; + } + else if (p_interface->intrmediate_delay <= elapsed_time) + { + retval = 1; + } + else if ((p_interface->intrmediate_delay == TIME_PERIOD_INVALID) && + (p_interface->final_delay == TIME_PERIOD_INVALID)) + { + retval = -1; + } + } + + TLS_MUTEX_UNLOCK(); + + return retval; +} + + +/**@brief Prints/displays the configuration of the interface. Used for debugging purposes. + * + * @param[in] p_interface Identifies the instance whose ssl configuration is to be printed. + */ +static void interface_conf_debug_print(interface_t * p_interface) +{ + + TLS_TRC("[%p] SSL Conf", p_interface); + + for (int i = 0; i < 4; i++) + { + TLS_TRC("\t Cipger Suites : %02d", i); + TLS_TRC("\t\t\tCiphersuite[0] = %02d", p_interface->conf.ciphersuite_list[i][0]); + TLS_TRC("\t\t\tCiphersuite[1] = %02d", p_interface->conf.ciphersuite_list[i][1]); + TLS_TRC("\t\t\tCiphersuite[2] = %02d", p_interface->conf.ciphersuite_list[i][2]); + TLS_TRC("\t\t\tCiphersuite[3] = %02d", p_interface->conf.ciphersuite_list[i][3]); + } + + TLS_TRC("\t\tf_dbg = %p", p_interface->conf.f_dbg); + TLS_TRC("\t\tp_dbg = %p", p_interface->conf.p_dbg); + + TLS_TRC("\t\tf_rng = %p", p_interface->conf.f_rng); + TLS_TRC("\t\tp_rng = %p", p_interface->conf.p_rng); + + TLS_TRC("\t\tf_get_cache = %p", p_interface->conf.f_get_cache); + TLS_TRC("\t\tf_set_cache = %p", p_interface->conf.f_set_cache); + TLS_TRC("\t\tf_set_cache = %p", p_interface->conf.p_cache); + + TLS_TRC("\t\tf_vrfy = %p", p_interface->conf.f_vrfy); + TLS_TRC("\t\tp_vrfy = %p", p_interface->conf.p_vrfy); + + TLS_TRC("\t\tcert_profile = %p", p_interface->conf.cert_profile); + TLS_TRC("\t\tkey_cert = %p", p_interface->conf.key_cert); + TLS_TRC("\t\tca_chain = %p", p_interface->conf.ca_chain); + TLS_TRC("\t\tca_crl = %p", p_interface->conf.ca_crl); + + TLS_TRC("\t\tmax_major_ver = %2d", p_interface->conf.max_major_ver); + TLS_TRC("\t\tmax_minor_ver = %2d", p_interface->conf.max_minor_ver); + TLS_TRC("\t\tmin_major_ver = %2d", p_interface->conf.min_major_ver); + TLS_TRC("\t\tmax_major_ver = %2d", p_interface->conf.max_major_ver); +} + + +/**@brief Sets up own certificate on the interface instance. + * + * @param[in] p_interface TLS interface instance for which the procedure is requested. + * @param[in] p_own Supplies own certifcate setup information. + * + * @retval NRF_SUCCESS if the procedure was successful, else an error code indicating reason for + * failure. + */ +static uint32_t own_certificate_set(interface_t * const p_interface, + nrf_tls_certificate_t const * p_own) +{ +#ifdef MBEDTLS_X509_CRT_PARSE_C + uint32_t error_code = (NRF_ERROR_NO_MEM | IOT_TLS_ERR_BASE); + + int result; + + p_interface->p_owncert = nrf_malloc(sizeof(mbedtls_x509_crt)); + + if (p_interface->p_owncert) + { + mbedtls_x509_crt_init(p_interface->p_owncert); + + result = mbedtls_x509_crt_parse(p_interface->p_owncert, + p_own->p_certificate, + p_own->certificate_len); + + if (result == 0) + { + mbedtls_pk_init(&p_interface->pkey); + + result = mbedtls_pk_parse_key(&p_interface->pkey, + p_own->p_private_key, + p_own->private_key_len, + NULL, + 0 ); + + result = mbedtls_ssl_conf_own_cert(&p_interface->conf, + p_interface->p_owncert, + &p_interface->pkey); + if (result == 0) + { + error_code = NRF_SUCCESS; + } + else + { + error_code = NRF_TLS_OWN_CERT_SETUP_FAILED; + } + } + else + { + error_code = NRF_TLS_OWN_CERT_SETUP_FAILED; + } + } + + return error_code; +#else + return NRF_SUCCESS; +#endif // MBEDTLS_X509_CRT_PARSE_C +} + + +/**@brief Sets up verification option for the interfce, + * + * @param[in] p_interface TLS interface instance for which the procedure is requested. + * @param[in] p_settings Key setting supplying CA PEM file. + * + * @retval NRF_SUCCESS if the procedure was successful, else an error code indicating reason for + * failure. + */ +static uint32_t verify_options_set(interface_t * const p_interface, + nrf_tls_key_settings_t const * p_settings) +{ + uint32_t err_code = NRF_SUCCESS; + +#ifdef MBEDTLS_X509_CRT_PARSE_C + if ((p_settings != NULL) && (p_settings->p_ca_cert_pem != NULL)) + { + mbedtls_ssl_conf_authmode(&p_interface->conf, MBEDTLS_SSL_VERIFY_REQUIRED ); + + p_interface->p_cacert = nrf_malloc(sizeof(mbedtls_x509_crt)); + + if (p_interface->p_cacert != NULL) + { + // Initialize ca certificate. + mbedtls_x509_crt_init(p_interface->p_cacert); + + int result = mbedtls_x509_crt_parse(p_interface->p_cacert, + p_settings->p_ca_cert_pem, + p_settings->ca_cert_pem_len); + if (result >= 0) + { + mbedtls_ssl_conf_ca_chain(&p_interface->conf, p_interface->p_cacert, NULL); + } + else + { + err_code = NRF_TLS_INVALID_CA_CERTIFICATE; + } + } + else + { + err_code = (NRF_ERROR_NO_MEM | IOT_TLS_ERR_BASE); + } + } + else +#endif // MBEDTLS_X509_CRT_PARSE_C + { + mbedtls_ssl_conf_authmode(&p_interface->conf, MBEDTLS_SSL_VERIFY_NONE); + } + + return err_code; +} + + +/**@brief Sets up the configuration for SSL context according to the options specificed. + * + * @param[in] instance_id Identifies the TLS instance for which the procedure is requested. + * @param[in] p_options Supplies options to be used for the configuration. + * + * @retval NRF_SUCCESS if the procedure was successful, else an error indicating reason + * for failure. + */ +static uint32_t interface_conf_setup(uint32_t instance_id, + nrf_tls_options_t const * p_options) +{ + int result; + interface_t * p_interface = m_interface[instance_id]; + uint32_t err_code = NRF_TLS_CONFIGURATION_FAILED; + + mbedtls_ssl_config_init(&p_interface->conf); + + result = mbedtls_ssl_config_defaults(&p_interface->conf, + p_options->role, + p_options->transport_type, + MBEDTLS_SSL_PRESET_DEFAULT); + + mbedtls_ssl_conf_rng(&p_interface->conf, random_vector_generate, NULL); + mbedtls_ssl_conf_dbg(&p_interface->conf, mbedtls_log, NULL); + + TLS_TRC("[%p]: mbedtls_ssl_config_defaults result %08lx", p_interface, result); + +#ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + if (result == 0) + { + if ((p_options->p_key_settings != NULL) && (p_options->p_key_settings->p_psk != NULL)) + { + result = mbedtls_ssl_conf_psk(&p_interface->conf, + p_options->p_key_settings->p_psk->p_secret_key, + p_options->p_key_settings->p_psk->secret_key_len, + p_options->p_key_settings->p_psk->p_identity, + p_options->p_key_settings->p_psk->identity_len); + } + } +#endif // MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + + if (result == 0) + { + if (p_options->p_key_settings->p_own_certificate != NULL) + { + err_code = own_certificate_set(p_interface, + p_options->p_key_settings->p_own_certificate); + } + else + { + err_code = NRF_SUCCESS; + } + } + + if (err_code == NRF_SUCCESS) + { + err_code = verify_options_set(p_interface, p_options->p_key_settings); + } + +#ifdef MBEDTLS_SSL_PROTO_DTLS + if (err_code == NRF_SUCCESS) + { + if (p_interface->conf.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) + { + mbedtls_ssl_conf_min_version(&p_interface->conf, + MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3); + + mbedtls_ssl_conf_max_version(&p_interface->conf, + MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3); + + if (p_options->transport_type == MBEDTLS_SSL_TRANSPORT_DATAGRAM) + { + mbedtls_ssl_conf_handshake_timeout(&p_interface->conf, + (MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN * 2), + (MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN * 2)); + } + } + } +#endif // MBEDTLS_SSL_PROTO_DTLS + + interface_conf_debug_print(p_interface); + + return err_code; +} + + +/**@brief Sets up the SSL context according to the options specificed. + * + * @param[in] instance_id Identifies the TLS instance for which the procedure is requested. + * + * @retval NRF_SUCCESS if the procedure was successful, else an error indicating reason for + * failure. + * + * @note For client roles, handshake prcoedure is initiated here. + */ +static uint32_t interface_ssl_context_setup(uint32_t instance_id) +{ + int result; + interface_t * p_interface = m_interface[instance_id]; + + TLS_TRC("[%p]: Major number: 0x%08lx Minor number: 0x%08lx", + p_interface->conf, + p_interface->conf.min_major_ver, + p_interface->conf.min_minor_ver); + + mbedtls_ssl_init(&p_interface->context); + + result = mbedtls_ssl_setup(&p_interface->context, &p_interface->conf); + + TLS_LOG("mbedtls_ssl_setup result %d",result); + + if (result == 0) + { + //ssl_set_ciphersuites(&p_interface->context, default_ciphers); + mbedtls_ssl_set_bio(&p_interface->context, + (void *)instance_id, + interface_transport_write, + interface_transport_read, + NULL); + + if (p_interface->conf.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) + { + mbedtls_ssl_set_timer_cb(&p_interface->context, + (void *)instance_id, + tls_set_timer, + tls_get_timer); + } + + TLS_MUTEX_UNLOCK(); + + result = mbedtls_ssl_handshake(&p_interface->context); + + TLS_MUTEX_LOCK(); + + TLS_LOG("mbedtls_ssl_handshake result %d", result); + + if (result == MBEDTLS_ERR_SSL_CONN_EOF) + { + result = 0; + } + } + + return (result ? (NRF_ERROR_INTERNAL | IOT_TLS_ERR_BASE) : NRF_SUCCESS); +} + + +uint32_t nrf_tls_init(void) +{ + uint32_t index = 0; + + SDK_MUTEX_INIT(m_tls_mutex); + + for (index = 0; index < NRF_TLS_MAX_INSTANCE_COUNT; index++) + { + interface_init(index); + } + + UNUSED_RETURN_VALUE(mbedtls_platform_set_calloc_free(wrapper_calloc, nrf_free)); + +#ifdef MBEDTLS_DEBUG_C + mbedtls_debug_set_threshold(2); +#endif // MBEDTLS_DEBUG_C + + UNUSED_RETURN_VALUE(nrf_drv_rng_init(NULL)); + + return NRF_SUCCESS; +} + + +uint32_t nrf_tls_alloc(nrf_tls_instance_t * p_instance, + nrf_tls_options_t const * p_options) +{ + uint32_t err_code = (NRF_ERROR_NO_MEM | IOT_TLS_ERR_BASE); + + TLS_MUTEX_LOCK(); + + err_code = interface_alloc(p_instance, p_options); + + if (err_code == NRF_SUCCESS) + { + err_code = interface_conf_setup(p_instance->instance_id, p_options); + } + + if (err_code == NRF_SUCCESS) + { + err_code = interface_ssl_context_setup(p_instance->instance_id); + } + + if (err_code != NRF_SUCCESS) + { + interface_free(p_instance->instance_id); + } + + TLS_MUTEX_UNLOCK(); + + return err_code; +} + + +uint32_t nrf_tls_input(nrf_tls_instance_t const * p_instance, + uint8_t const * p_data, + uint32_t datalen) +{ + + uint32_t actual_size = 0; + uint32_t err_code = (NRF_ERROR_NOT_FOUND | IOT_TLS_ERR_BASE); + + TLS_MUTEX_LOCK(); + + if ((p_instance->instance_id < NRF_TLS_MAX_INSTANCE_COUNT) && + (m_interface[p_instance->instance_id] != NULL)) + { + interface_t * const p_interface = m_interface[p_instance->instance_id]; + + // Verify all data can be queued in the FIFO. + err_code = app_fifo_write(&p_interface->input_fifo, NULL, &actual_size); + if (err_code == NRF_SUCCESS) + { + // Avoid partial write. + if (datalen <= actual_size) + { + actual_size = datalen; + + err_code = app_fifo_write(&p_interface->input_fifo, p_data, &actual_size); + + TLS_TRC("[%p]: >> nrf_tls_input datalen 0x%08lx result 0x%08lx", + p_interface, + datalen, + err_code); + } + else + { + TLS_LOG("[%p]: Failed to queue input. " + "Available 0x%08lx, requested 0x%08lx", + p_interface, + actual_size, + datalen); + } + + interface_continue(p_interface); + } + else + { + // Not enough room in the FIFO, indicate error. + err_code = (NRF_ERROR_NO_MEM | IOT_TLS_ERR_BASE); + } + } + + TLS_MUTEX_UNLOCK(); + + return err_code; +} + + +uint32_t nrf_tls_read(nrf_tls_instance_t const * p_instance, + uint8_t * p_data, + uint32_t * p_datalen) +{ + uint32_t err_code = (NRF_ERROR_NOT_FOUND | IOT_TLS_ERR_BASE); + + TLS_MUTEX_LOCK(); + + if ((p_instance->instance_id < NRF_TLS_MAX_INSTANCE_COUNT) && + (m_interface[p_instance->instance_id] != NULL)) + { + interface_t * const p_interface = m_interface[p_instance->instance_id]; + + err_code = app_fifo_read(&p_interface->output_fifo, p_data, p_datalen); + } + + TLS_MUTEX_UNLOCK(); + + return err_code; +} + + +uint32_t nrf_tls_write(nrf_tls_instance_t const * p_instance, + uint8_t const * p_data, + uint32_t * p_datalen) +{ + uint32_t err_code = (NRF_ERROR_NOT_FOUND | IOT_TLS_ERR_BASE); + + TLS_MUTEX_LOCK(); + + if ((p_instance->instance_id < NRF_TLS_MAX_INSTANCE_COUNT) && + (m_interface[p_instance->instance_id] != NULL)) + { + interface_t * const p_interface = m_interface[p_instance->instance_id]; + + int actual_len = (*p_datalen); + + TLS_MUTEX_UNLOCK(); + + actual_len = mbedtls_ssl_write(&p_interface->context, p_data, actual_len); + + TLS_MUTEX_LOCK(); + + if (actual_len < 0) + { + err_code = (NRF_ERROR_INTERNAL | IOT_TLS_ERR_BASE); + + if (actual_len == MBEDTLS_ERR_SSL_CONN_EOF) + { + if (p_interface->context.state < MBEDTLS_SSL_HANDSHAKE_OVER) + { + err_code = NRF_TLS_HANDSHAKE_IN_PROGRESS; + } + } + } + else + { + (* p_datalen) = actual_len; + err_code = NRF_SUCCESS; + } + } + + TLS_MUTEX_UNLOCK(); + + return err_code; +} + + +uint32_t nrf_tls_free(nrf_tls_instance_t const * p_instance) +{ + uint32_t err_code = (NRF_ERROR_NOT_FOUND | IOT_TLS_ERR_BASE); + + TLS_MUTEX_LOCK(); + + if ((p_instance->instance_id < NRF_TLS_MAX_INSTANCE_COUNT) && + (m_interface[p_instance->instance_id] != NULL)) + { + interface_free(p_instance->instance_id); + err_code = NRF_SUCCESS; + } + + TLS_MUTEX_UNLOCK(); + + return err_code; +} + + +void nrf_tls_process(void) +{ + uint32_t index; + + TLS_MUTEX_LOCK(); + + for (index = 0; index < NRF_TLS_MAX_INSTANCE_COUNT; index++) + { + if (m_interface[index] != NULL) + { + interface_continue(m_interface[index]); + } + } + + TLS_MUTEX_UNLOCK(); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/nrf_tls.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/nrf_tls.h new file mode 100644 index 0000000..c624b68 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/nrf_tls/nrf_tls.h @@ -0,0 +1,307 @@ +/** + * Copyright (c) 2015 - 2019, 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 nrf_tls.h + * + * @defgroup iot_nrf_tls TLS on nRF5x + * @ingroup iot_sdk_common + * @{ + * @brief TLS interface on nRF5x. + * + * @details Defines TLS interface for securing UDP/TCP transport using DTLS/TLS respectively. + * The interface integrates TLS library with needed libraries/drivers on the nRF. + * + */ + +#ifndef NRF_TLS_H__ +#define NRF_TLS_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Maximum number of TLS instances to be supported. */ +#define NRF_TLS_INVALID_INSTANCE_IDENTIFIER 0xFFFFFFFF + +/**@brief Initializes the TLS instance. */ +#define NRF_TLS_INTSANCE_INIT(INSTANCE) \ + do \ + { \ + (INSTANCE)->transport_id = NRF_TLS_INVALID_INSTANCE_IDENTIFIER; \ + (INSTANCE)->instance_id = NRF_TLS_INVALID_INSTANCE_IDENTIFIER; \ + }while(0) + +/**@brief Transport type definitions. The type determines whether TLS or DTLS shall be used. */ +typedef enum +{ + NRF_TLS_TYPE_STREAM, /**< TCP transport, TLS to be used for the instance. */ + NRF_TLS_TYPE_DATAGRAM /**< UDP transport, DTLS to be used for the instance. */ +} nrf_transport_type_t; + +/**@brief TLS/DTLS roles definition. */ +typedef enum +{ + NRF_TLS_ROLE_CLIENT, /**< Client role. */ + NRF_TLS_ROLE_SERVER /**< Server role. */ +} nrf_tls_role_t; + +/**@brief TLS Instance identifier*/ +typedef struct +{ + uint32_t transport_id; /**< Identifies the TCP/UDP transport which is being secured. */ + uint32_t instance_id; /**< Identifies the TLS instance. */ +} nrf_tls_instance_t; + +/**@brief Information needed when using Pre-shared key ciphers. */ +typedef struct +{ + const uint8_t * p_identity; /**< Client identity. */ + const uint8_t * p_secret_key; /**< Secret Preshared Key. */ + uint16_t identity_len; /**< Length of the client identity. */ + uint16_t secret_key_len; /**< Length of the preshared key. */ +} nrf_tls_preshared_key_t; + +/**@brief Information provided when using Raw Public key ciphers. */ +typedef struct +{ + const uint8_t * p_private_key; /**< Private key. */ + const uint8_t * p_public_key; /**< Raw public key. */ + uint16_t private_key_len; /**< Length of the private key. */ + uint16_t public_key_len; /**< Length of the raw public key. */ +} nrf_tls_raw_key_t; + +/**@brief Certificate to be used when using certificates for key derivation. */ +typedef struct +{ + const uint8_t * p_private_key; /**< Private key. */ + const uint8_t * p_certificate; /**< Own certificate in PEM format. */ + uint16_t private_key_len; /**< Length of the private key. */ + uint16_t certificate_len; /**< Length of the certificate. */ +} nrf_tls_certificate_t; + +/**@brief Key settings to be used for TLS instance. */ +typedef struct +{ + nrf_tls_certificate_t * p_own_certificate; /**< Own certificate to be used for the instance. Can be NULL. */ + uint8_t * p_ca_cert_pem; /**< CA certificate in PEM formart. */ + uint16_t ca_cert_pem_len; /**< Length of the CA certificate. */ + nrf_tls_preshared_key_t * p_psk; /**< Identitiy and shared secret in case pre-shared key is used. Can be NULL. */ + nrf_tls_raw_key_t * p_raw_key; /**< Public and private key in case RAW keys are used. This method is not currently supported. */ +} nrf_tls_key_settings_t; + +/**@brief Transport write function registered for the instance. + * + * @details Function registered with the interface to write on the transport interface. + * The application shall implement the function registered here to ensure handshake + * messages and encrypted data can be written by the interface/TLS library on the + * transport. + * + * @param[in] p_instance Identifies the instance on which transport write is requested. + * Shall not be NULL. + * @param[in] p_data Pointer to data to be written on the instance. + * Shall not be NULL. + * @param[in] datalen Length of data to be written on the transport. + * + * @retval NRF_SUCCESS If the procedure was successful, else an error code indicating reason + * for failure. + */ +typedef uint32_t (*nrf_tls_output_t)(nrf_tls_instance_t const * p_instance, + uint8_t const * p_data, + uint32_t datalen); + +/**@brief Options when requesting an TLS instance. */ +typedef struct +{ + nrf_tls_output_t output_fn; /**< Function registered to deliver output of TLS operations on a TLS interface. Shall not be NULL. */ + uint8_t transport_type; /**< Indicates type of transport being secured. @ref nrf_transport_type_t for possible transports. */ + uint8_t role; /**< Indicates role to be played, server or client. @ref nrf_tls_role_t for possible roles. */ + nrf_tls_key_settings_t * p_key_settings; /**< Provide key configurations/certificates here. */ +} nrf_tls_options_t; + +/**@brief Initialize TLS interface. + * + * @details This function initializes TLS interface. Initialization includes initializing the TLS + * library, RNG driver, and any other dependencies. This API shall be called before using + * any other APIs of the interface. + * + * @retval NRF_SUCCESS If the procedure is successful, else, an error code indicating + * reason for failure. If the procedure fails, the application shall + * not proceed with using other APIs of the interface. + */ +uint32_t nrf_tls_init(void); + + +/**@brief Allocate an TLS/DTLS instance. + * + * @details This function allocates an instance for TLS/DTLS. Options indicate whether DTLS/TLS will + * be used and role is server or client. + * + * @param[inout] p_instance Instance with transport id set by the application to identify the + * transport being secured. If the procedure is successful, the + * instance id is allocated by the interface. The application is + * expected to remember the instance information for all subsequent + * procedures on the transport. + * Shall not be NULL. + * @param[in] p_options Pointer to options that indicate transport type, role, keys etc. + * Output function registered is used write TLS/DTLS data on the + * raw transport (TCP.UDP) for the instance. + * Shall not be NULL. + * @note + * + * @retval NRF_SUCCESS If the procedure is successful, else, an error code indicating + * reason for failure. If the procedure succeeds, the application + * shall use the instance allocated for all subsequent procedures on + * the instance. + */ +uint32_t nrf_tls_alloc(nrf_tls_instance_t * p_instance, + nrf_tls_options_t const * p_options); + + +/**@brief Free the TLS/DTLS instance. + * + * @details This function frees the instance allocated for TLS/DTLS. All sessions, buffered data +* related to instance are freed as well by this API. + * + * @param[in] p_instance Identifies the instance being freed. + * Shall not be NULL. + * + * @retval NRF_SUCCESS If the procedure is successful, else, an error code indicating + * reason for failure. If the procedure succeeds, the application + * shall use the instance allocated for all subsequent procedures on + * the instance. + */ +uint32_t nrf_tls_free(nrf_tls_instance_t const * p_instance); + + +/**@brief Write data on the TLS/DTLS instance. + * + * @details This function writes data on the TLS/DTLS instance. The requested data is encrypted + * and padded based on cipher configuration and selected cipher during handshake. + * If no sessions exists already with the peer, a handshake is initiated automatically + * by the interface, if the role played on the instance is a client role. Requested data to + * be written is buffered until a session is established. + * + * @param[in] p_instance Identifies the instance on which write is requested. + * Shall not be NULL. + * @param[in] p_data Pointer to data to be written on the instance. + * Shall not be NULL. + * @param[inout] p_datalen Pointer to size of data to be written. The actual size written can + * be smaller than requested and is indicated here if the procedure is + * successful. The application shall check for the actual size written + * and make subsequent requests in case the right was partial. + * Shall not be NULL. + * + * @retval NRF_SUCCESS If the procedure is successful, else, an error code indicating + * reason for failure. If the procedure succeeds, the application + * shall check for the actual size written and make subsequent + * requests in case the right was partial. + */ +uint32_t nrf_tls_write(nrf_tls_instance_t const * p_instance, + uint8_t const * p_data, + uint32_t * p_datalen); + + +/**@brief Read data from the TLS/DTLS instance. + * + * @details This function reads data from the TLS/DTLS interface. The read data is + * decrypted based on cipher configuration and selected cipher during handshake. + * If no data is available on the instance, the API indicates so with an error code. + * It is possible to request size of data that can be read by passing a NULL parameter on + * the data. + * + * @param[in] p_instance Identifies the instance on which read is requested. + * Shall not be NULL. + * @param[in] p_data Pointer to data where read data is to be copied. + * Can be NULL. In case, this parameter is NULL, size of bytes that + * are available to read is returned in the p_datalen parameter. + * @param[inout] p_datalen Pointer to size of data to be read. The application shall ensure that + * the memory pointed to by p_data parameter is the size indicated. + * The actual size read can be smaller than requested and is indicated + * here if the procedure is successful. The application should check for +* the actual size read. + * Shall not be NULL. + * + * @retval NRF_SUCCESS If the procedure is successful, else, an error code indicating + * reason for failure. If the procedure succeeds, the application + * should check for the actual size read. + */ +uint32_t nrf_tls_read(nrf_tls_instance_t const * p_instance, + uint8_t * p_data, + uint32_t * p_datalen); + + +/**@brief Function to input data read on the transport to the TLS library. + * + * @details Function to input data read on the transport to TLS library for further processing. + * Further processing could include advancing the handshake or decrypting the received + * data based on the state of TLS session. + * + * @param[in] p_instance Identifies the instance on which transport write is requested. + * Shall not be NULL. + * @param[in] p_data Pointer to data to be processed on the instance. + * Shall not be NULL. + * @param[in] datalen Length of data to be written on the transport. + * + * @retval NRF_SUCCESS If the procedure was successful, else an error code indicating reason + * for failure. + */ +uint32_t nrf_tls_input(nrf_tls_instance_t const * p_instance, + uint8_t const * p_data, + uint32_t datalen); + + +/**@brief Function to continue TLS/DTLS operation after a busy state on transport. + * + * @details The transport writes requested by the TLS interface may return failure if transport + * data flow was off. In order to resume and retry the operations, this function shall be + * called periodically. This function shall be called in order to ensure TLS interface + * and the library behaves as expected. + */ +void nrf_tls_process(void); + +#ifdef __cplusplus +} +#endif + +#endif // NRF_TLS_H__ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/nrf_pt.h similarity index 84% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/nrf_pt.h index 27a1595..d7458d7 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/nrf_crypto_rng.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/nrf_pt.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,16 +35,11 @@ * 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(NRF_CRYPTO) -#include "nrf_crypto_rng.h" -#include "nrf_drv_rng.h" +//lint -emacro(142 438 616 646, PT_YIELD, PT_WAIT_THREAD, PT_END) -#if NRF_CRYPTO_BACKEND_MICRO_ECC && NRF_CRYPTO_BACKEND_MICRO_ECC_SHA256 -#include "nrf_crypto_sw_rng.h" -#endif +#include "pt.h" -#endif // NRF_MODULE_ENABLED(NRF_CRYPTO) +typedef struct pt pt_t; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/Makefile new file mode 100644 index 0000000..ff573ef --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/Makefile @@ -0,0 +1,9 @@ +CFLAGS=-O -Wuninitialized -Werror + +all: example-codelock example-buffer example-small + +example-codelock: example-codelock.c pt.h lc.h + +example-buffer: example-buffer.c pt.h lc.h + +example-small: example-small.c pt.h lc.h diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README new file mode 100644 index 0000000..eeace5d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README @@ -0,0 +1,51 @@ +Protothreads are extremely lightweight stackless threads designed for +severely memory constrained systems such as small embedded systems or +sensor network nodes. Protothreads can be used with or without an +underlying operating system. + +Protothreads provides a blocking context on top of an event-driven +system, without the overhead of per-thread stacks. The purpose of +protothreads is to implement sequential flow of control without +complex state machines or full multi-threading. + +Main features: + + * No machine specific code - the protothreads library is pure C + * Does not use error-prone functions such as longjmp() + * Very small RAM overhead - only two bytes per protothread + * Can be used with or without an OS + * Provides blocking wait without full multi-threading or + stack-switching + * Freely available under a BSD-like open source license + +Example applications: + + * Memory constrained systems + * Event-driven protocol stacks + * Small embedded systems + * Sensor network nodes + +The protothreads library is released under an open source BSD-style +license that allows for both non-commercial and commercial usage. The +only requirement is that credit is given. + +The protothreads library was written by Adam Dunkels +with support from Oliver Schmidt . + +More information and new versions can be found at the protothreads +homepage: + http://www.sics.se/~adam/pt/ + +Documentation can be found in the doc/ subdirectory. + +Two example programs illustrating the use of protothreads can be found +in this directory: + + example-small.c A small example showing how to use protothreads + example-buffer.c The bounded buffer problem with protothreads + example-codelock.c A code lock with simulated key input + +To compile the examples, simply run "make". + + +Adam Dunkels, 3 June 2006 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README-VISUAL-C++.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README-VISUAL-C++.txt new file mode 100644 index 0000000..3b09a69 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/README-VISUAL-C++.txt @@ -0,0 +1,5 @@ +Protothreads can in some cases fail to compile under Visual C++ +version 6.0 due to a bug in the compiler. See the following page for a +solution to the problem: + +http://support.microsoft.com/default.aspx?scid=kb;en-us;199057 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Doxyfile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Doxyfile new file mode 100644 index 0000000..cecf583 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Doxyfile @@ -0,0 +1,229 @@ +# Doxyfile 1.4.6 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "The Protothreads Library 1.4" +PROJECT_NUMBER = +OUTPUT_DIRECTORY = . +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = ../ +STRIP_FROM_INC_PATH = +SHORT_NAMES = YES +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = YES +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = NO +GENERATE_DEPRECATEDLIST= NO +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = NO +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = pt-mainpage.txt \ + pt-doc.txt \ + ../pt.h \ + ../pt-sem.h \ + ../lc.h \ + ../lc-switch.h \ + ../lc-addrlabels.h +FILE_PATTERNS = +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = .. +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = YES +STRIP_CODE_COMMENTS = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = YES +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = YES +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = header.tex +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = DOXYGEN +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +HIDE_UNDOC_RELATIONS = NO +HAVE_DOT = NO +CLASS_GRAPH = NO +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = NO +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Makefile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Makefile new file mode 100644 index 0000000..fd0c7d1 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/Makefile @@ -0,0 +1,7 @@ +dox: + doxygen Doxyfile + + +pdf: dox + (cd latex; $(MAKE) refman.pdf) + mv latex/refman.pdf pt-refman.pdf \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/header.tex b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/header.tex new file mode 100644 index 0000000..5899653 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/header.tex @@ -0,0 +1,52 @@ +\documentclass[a4paper]{article} +\usepackage{a4wide} +\usepackage{makeidx} +\usepackage{fancyhdr} +\usepackage{graphicx} +\usepackage{multicol} +\usepackage{float} +\usepackage{textcomp} +\usepackage{alltt} +\usepackage{times} +\usepackage{epsfig} +\ifx\pdfoutput\undefined +\usepackage[ps2pdf, + pagebackref=true, + colorlinks=true, + linkcolor=blue + ]{hyperref} +\usepackage{pspicture} +\else +\usepackage[pdftex, + pagebackref=true, + colorlinks=true, + linkcolor=blue + ]{hyperref} +\fi +\usepackage{doxygen} +\makeindex +\setcounter{tocdepth}{1} +\renewcommand{\footrulewidth}{0.4pt} +\begin{document} +\begin{titlepage} +\vspace*{5cm} +\begin{center} +{\Huge Protothreads}\\ +\vspace*{1cm} +{\LARGE The Protothreads Library 1.3 Reference Manual}\\ +\vspace*{3cm} +{\Large June 2006}\\ +\vspace*{2cm} +\includegraphics[width=6cm]{../sicslogo.pdf}\\ +\vspace*{1cm} +{\Large Adam Dunkels}\\ +{\Large \texttt{adam@sics.se}}\\ +\vspace*{1cm} +{\LARGE Swedish Institute of Computer Science}\\ +\vspace*{0.5cm} + +\end{center} +\end{titlepage} +\pagenumbering{roman} +\tableofcontents +\pagenumbering{arabic} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00005.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00005.html new file mode 100644 index 0000000..4f2e17d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00005.html @@ -0,0 +1,40 @@ + + +The Protothreads Library 1.4: pt Struct Reference + + + + + + +

      pt Struct Reference
      + +[Protothreads] +


      Detailed Description

      + +

      + +

      +Definition at line 54 of file pt.h. + + + + +

      Data Fields

      +lc_t lc
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00006.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00006.html new file mode 100644 index 0000000..2ea0775 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00006.html @@ -0,0 +1,40 @@ + + +The Protothreads Library 1.4: pt_sem Struct Reference + + + + + + +

      pt_sem Struct Reference
      + +[Protothread semaphores] +


      Detailed Description

      + +

      + +

      +Definition at line 165 of file pt-sem.h. + + + + +

      Data Fields

      +unsigned int count
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00009.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00009.html new file mode 100644 index 0000000..b15ca22 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00009.html @@ -0,0 +1,61 @@ + + +The Protothreads Library 1.4: lc-addrlabels.h File Reference + + + + + + +

      lc-addrlabels.h File Reference


      Detailed Description

      +Implementation of local continuations based on the "Labels as values" feature of gcc. +

      +

      Author:
      Adam Dunkels <adam@sics.se>
      +This implementation of local continuations is based on a special feature of the GCC C compiler called "labels as values". This feature allows assigning pointers with the address of the code corresponding to a particular C label.

      +For more information, see the GCC documentation: http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html +

      +Definition in file lc-addrlabels.h. +

      + +

      +Go to the source code of this file. + + + + + + + + + + + + + + + + + +

      Defines

      +#define LC_INIT(s)   s = NULL
      +#define LC_RESUME(s)
      +#define LC_CONCAT2(s1, s2)   s1##s2
      +#define LC_CONCAT(s1, s2)   LC_CONCAT2(s1, s2)
      +#define LC_SET(s)
      +#define LC_END(s)

      Typedefs

      +typedef void * lc_t
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00010.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00010.html new file mode 100644 index 0000000..4ba31de --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00010.html @@ -0,0 +1,56 @@ + + +The Protothreads Library 1.4: lc-switch.h File Reference + + + + + + +

      lc-switch.h File Reference


      Detailed Description

      +Implementation of local continuations based on switch() statment. +

      +

      Author:
      Adam Dunkels <adam@sics.se>
      +This implementation of local continuations uses the C switch() statement to resume execution of a function somewhere inside the function's body. The implementation is based on the fact that switch() statements are able to jump directly into the bodies of control structures such as if() or while() statmenets.

      +This implementation borrows heavily from Simon Tatham's coroutines implementation in C: http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html +

      +Definition in file lc-switch.h. +

      + +

      +Go to the source code of this file. + + + + + + + + + + + + + + +

      Defines

      +#define LC_INIT(s)   s = 0;
      +#define LC_RESUME(s)   switch(s) { case 0:
      +#define LC_SET(s)   s = __LINE__; case __LINE__:
      +#define LC_END(s)   }

      Typedefs

      +typedef unsigned short lc_t
       The local continuation type.
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00011.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00011.html new file mode 100644 index 0000000..b9bf8ac --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00011.html @@ -0,0 +1,51 @@ + + +The Protothreads Library 1.4: lc.h File Reference + + + + + + +

      lc.h File Reference


      Detailed Description

      +Local continuations. +

      +

      Author:
      Adam Dunkels <adam@sics.se>
      + +

      +Definition in file lc.h. +

      +#include "lc-switch.h"
      + +

      +Go to the source code of this file. + + + + + + + + + + + + + + +

      Defines

      #define LC_INIT(lc)
       Initialize a local continuation.
      #define LC_SET(lc)
       Set a local continuation.
      #define LC_RESUME(lc)
       Resume a local continuation.
      #define LC_END(lc)
       Mark the end of local continuation usage.
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00012.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00012.html new file mode 100644 index 0000000..25054d5 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00012.html @@ -0,0 +1,51 @@ + + +The Protothreads Library 1.4: pt-sem.h File Reference + + + + + + +

      pt-sem.h File Reference


      Detailed Description

      +Couting semaphores implemented on protothreads. +

      +

      Author:
      Adam Dunkels <adam@sics.se>
      + +

      +Definition in file pt-sem.h. +

      +#include "pt.h"
      + +

      +Go to the source code of this file. + + + + + + + + + + + + + + +

      Data Structures

      struct  pt_sem

      Defines

      #define PT_SEM_INIT(s, c)
       Initialize a semaphore.
      #define PT_SEM_WAIT(pt, s)
       Wait for a semaphore.
      #define PT_SEM_SIGNAL(pt, s)
       Signal a semaphore.
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00013.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00013.html new file mode 100644 index 0000000..76430ea --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00013.html @@ -0,0 +1,100 @@ + + +The Protothreads Library 1.4: pt.h File Reference + + + + + + +

      pt.h File Reference


      Detailed Description

      +Protothreads implementation. +

      +

      Author:
      Adam Dunkels <adam@sics.se>
      + +

      +Definition in file pt.h. +

      +#include "lc.h"
      + +

      +Go to the source code of this file. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      Data Structures

      struct  pt

      Initialization

      #define PT_INIT(pt)
       Initialize a protothread.

      Declaration and definition

      #define PT_THREAD(name_args)
       Declaration of a protothread.
      #define PT_BEGIN(pt)
       Declare the start of a protothread inside the C function implementing the protothread.
      #define PT_END(pt)
       Declare the end of a protothread.

      Blocked wait

      #define PT_WAIT_UNTIL(pt, condition)
       Block and wait until condition is true.
      #define PT_WAIT_WHILE(pt, cond)
       Block and wait while condition is true.

      Hierarchical protothreads

      #define PT_WAIT_THREAD(pt, thread)
       Block and wait until a child protothread completes.
      #define PT_SPAWN(pt, child, thread)
       Spawn a child protothread and wait until it exits.

      Exiting and restarting

      #define PT_RESTART(pt)
       Restart the protothread.
      #define PT_EXIT(pt)
       Exit the protothread.

      Calling a protothread

      #define PT_SCHEDULE(f)
       Schedule a protothread.

      Yielding from a protothread

      #define PT_YIELD(pt)
       Yield from the current protothread.
      #define PT_YIELD_UNTIL(pt, cond)
       Yield from the protothread until a condition occurs.

      Defines

      +#define PT_WAITING   0
      +#define PT_YIELDED   1
      +#define PT_EXITED   2
      +#define PT_ENDED   3
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00014.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00014.html new file mode 100644 index 0000000..424adc4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00014.html @@ -0,0 +1,627 @@ + + +The Protothreads Library 1.4: Protothreads + + + + + +

      Protothreads


      Detailed Description

      +Protothreads are implemented in a single header file, pt.h, which includes the local continuations header file, lc.h. +

      +This file in turn includes the actual implementation of local continuations, which typically also is contained in a single header file. +

      + + + + + + + +

      +

      + + + + +

      +

      + + + +

      +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      Files

      file  pt.h
       Protothreads implementation.

      Modules

       Protothread semaphores
       This module implements counting semaphores on top of protothreads.
       Local continuations
       Local continuations form the basis for implementing protothreads.

      Data Structures

      struct  pt

      Initialization

      #define PT_INIT(pt)
       Initialize a protothread.

      Declaration and definition

      #define PT_THREAD(name_args)
       Declaration of a protothread.
      #define PT_BEGIN(pt)
       Declare the start of a protothread inside the C function implementing the protothread.
      #define PT_END(pt)
       Declare the end of a protothread.

      Blocked wait

      #define PT_WAIT_UNTIL(pt, condition)
       Block and wait until condition is true.
      #define PT_WAIT_WHILE(pt, cond)
       Block and wait while condition is true.

      Hierarchical protothreads

      #define PT_WAIT_THREAD(pt, thread)
       Block and wait until a child protothread completes.
      #define PT_SPAWN(pt, child, thread)
       Spawn a child protothread and wait until it exits.

      Exiting and restarting

      #define PT_RESTART(pt)
       Restart the protothread.
      #define PT_EXIT(pt)
       Exit the protothread.

      Calling a protothread

      #define PT_SCHEDULE(f)
       Schedule a protothread.

      Yielding from a protothread

      #define PT_YIELD(pt)
       Yield from the current protothread.
      #define PT_YIELD_UNTIL(pt, cond)
       Yield from the protothread until a condition occurs.

      Defines

      +#define PT_WAITING   0
      +#define PT_YIELDED   1
      +#define PT_EXITED   2
      +#define PT_ENDED   3
      +


      Define Documentation

      +

      + + + + +
      + + + + + + + + + +
      #define PT_BEGIN pt   ) 
      +
      + + + + + +
      +   + + +

      +Declare the start of a protothread inside the C function implementing the protothread. +

      +This macro is used to declare the starting point of a protothread. It should be placed at the start of the function in which the protothread runs. All C statements above the PT_BEGIN() invokation will be executed each time the protothread is scheduled.

      +

      Parameters:
      + + +
      pt A pointer to the protothread control structure.
      +
      + +

      +Definition at line 115 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_END pt   ) 
      +
      + + + + + +
      +   + + +

      +Declare the end of a protothread. +

      +This macro is used for declaring that a protothread ends. It must always be used together with a matching PT_BEGIN() macro.

      +

      Parameters:
      + + +
      pt A pointer to the protothread control structure.
      +
      + +

      +Definition at line 127 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_EXIT pt   ) 
      +
      + + + + + +
      +   + + +

      +Exit the protothread. +

      +This macro causes the protothread to exit. If the protothread was spawned by another protothread, the parent protothread will become unblocked and can continue to run.

      +

      Parameters:
      + + +
      pt A pointer to the protothread control structure.
      +
      + +

      +Definition at line 246 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_INIT pt   ) 
      +
      + + + + + +
      +   + + +

      +Initialize a protothread. +

      +Initializes a protothread. Initialization must be done prior to starting to execute the protothread.

      +

      Parameters:
      + + +
      pt A pointer to the protothread control structure.
      +
      +
      See also:
      PT_SPAWN()
      + +

      +Definition at line 80 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_RESTART pt   ) 
      +
      + + + + + +
      +   + + +

      +Restart the protothread. +

      +This macro will block and cause the running protothread to restart its execution at the place of the PT_BEGIN() call.

      +

      Parameters:
      + + +
      pt A pointer to the protothread control structure.
      +
      + +

      +Definition at line 229 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_SCHEDULE  ) 
      +
      + + + + + +
      +   + + +

      +Schedule a protothread. +

      +This function shedules a protothread. The return value of the function is non-zero if the protothread is running or zero if the protothread has exited.

      +

      Parameters:
      + + +
      f The call to the C function implementing the protothread to be scheduled
      +
      + +

      +Definition at line 271 of file pt.h.

      +

      + + + + +
      + + + + + + + + + + + + + + + +
      #define PT_SPAWN pt,
      child,
      thread   ) 
      +
      + + + + + +
      +   + + +

      +Spawn a child protothread and wait until it exits. +

      +This macro spawns a child protothread and waits until it exits. The macro can only be used within a protothread.

      +

      Parameters:
      + + + + +
      pt A pointer to the protothread control structure.
      child A pointer to the child protothread's control structure.
      thread The child protothread with arguments
      +
      + +

      +Definition at line 206 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_THREAD name_args   ) 
      +
      + + + + + +
      +   + + +

      +Declaration of a protothread. +

      +This macro is used to declare a protothread. All protothreads must be declared with this macro.

      +

      Parameters:
      + + +
      name_args The name and arguments of the C function implementing the protothread.
      +
      + +

      +Definition at line 100 of file pt.h.

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_WAIT_THREAD pt,
      thread   ) 
      +
      + + + + + +
      +   + + +

      +Block and wait until a child protothread completes. +

      +This macro schedules a child protothread. The current protothread will block until the child protothread completes.

      +

      Note:
      The child protothread must be manually initialized with the PT_INIT() function before this function is used.
      +
      Parameters:
      + + + +
      pt A pointer to the protothread control structure.
      thread The child protothread with arguments
      +
      +
      See also:
      PT_SPAWN()
      + +

      +Definition at line 192 of file pt.h.

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_WAIT_UNTIL pt,
      condition   ) 
      +
      + + + + + +
      +   + + +

      +Block and wait until condition is true. +

      +This macro blocks the protothread until the specified condition is true.

      +

      Parameters:
      + + + +
      pt A pointer to the protothread control structure.
      condition The condition.
      +
      + +

      +Definition at line 148 of file pt.h.

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_WAIT_WHILE pt,
      cond   ) 
      +
      + + + + + +
      +   + + +

      +Block and wait while condition is true. +

      +This function blocks and waits while condition is true. See PT_WAIT_UNTIL().

      +

      Parameters:
      + + + +
      pt A pointer to the protothread control structure.
      cond The condition.
      +
      + +

      +Definition at line 167 of file pt.h.

      +

      + + + + +
      + + + + + + + + + +
      #define PT_YIELD pt   ) 
      +
      + + + + + +
      +   + + +

      +Yield from the current protothread. +

      +This function will yield the protothread, thereby allowing other processing to take place in the system.

      +

      Parameters:
      + + +
      pt A pointer to the protothread control structure.
      +
      + +

      +Definition at line 290 of file pt.h.

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_YIELD_UNTIL pt,
      cond   ) 
      +
      + + + + + +
      +   + + +

      +Yield from the protothread until a condition occurs. +

      +

      Parameters:
      + + + +
      pt A pointer to the protothread control structure.
      cond The condition.
      +
      +This function will yield the protothread, until the specified condition evaluates to true. +

      +Definition at line 310 of file pt.h.

      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00015.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00015.html new file mode 100644 index 0000000..1a0d69a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00015.html @@ -0,0 +1,711 @@ + + +The Protothreads Library 1.4: Examples + + + + + +

      Examples

      +A small example

      +This first example shows a very simple program: two protothreads waiting for each other to toggle two flags. The code illustrates how to write protothreads code, how to initialize protothreads, and how to schedule them.

      +

      /**
      + * This is a very small example that shows how to use
      + * protothreads. The program consists of two protothreads that wait
      + * for each other to toggle a variable.
      + */
      +
      +/* We must always include pt.h in our protothreads code. */
      +#include "pt.h"
      +
      +#include <stdio.h> /* For printf(). */
      +
      +/* Two flags that the two protothread functions use. */
      +static int protothread1_flag, protothread2_flag;
      +
      +/**
      + * The first protothread function. A protothread function must always
      + * return an integer, but must never explicitly return - returning is
      + * performed inside the protothread statements.
      + *
      + * The protothread function is driven by the main loop further down in
      + * the code.
      + */
      +static int
      +protothread1(struct pt *pt)
      +{
      +  /* A protothread function must begin with PT_BEGIN() which takes a
      +     pointer to a struct pt. */
      +  PT_BEGIN(pt);
      +
      +  /* We loop forever here. */
      +  while(1) {
      +    /* Wait until the other protothread has set its flag. */
      +    PT_WAIT_UNTIL(pt, protothread2_flag != 0);
      +    printf("Protothread 1 running\n");
      +
      +    /* We then reset the other protothread's flag, and set our own
      +       flag so that the other protothread can run. */
      +    protothread2_flag = 0;
      +    protothread1_flag = 1;
      +
      +    /* And we loop. */
      +  }
      +
      +  /* All protothread functions must end with PT_END() which takes a
      +     pointer to a struct pt. */
      +  PT_END(pt);
      +}
      +
      +/**
      + * The second protothread function. This is almost the same as the
      + * first one.
      + */
      +static int
      +protothread2(struct pt *pt)
      +{
      +  PT_BEGIN(pt);
      +
      +  while(1) {
      +    /* Let the other protothread run. */
      +    protothread2_flag = 1;
      +
      +    /* Wait until the other protothread has set its flag. */
      +    PT_WAIT_UNTIL(pt, protothread1_flag != 0);
      +    printf("Protothread 2 running\n");
      +    
      +    /* We then reset the other protothread's flag. */
      +    protothread1_flag = 0;
      +
      +    /* And we loop. */
      +  }
      +  PT_END(pt);
      +}
      +
      +/**
      + * Finally, we have the main loop. Here is where the protothreads are
      + * initialized and scheduled. First, however, we define the
      + * protothread state variables pt1 and pt2, which hold the state of
      + * the two protothreads.
      + */
      +static struct pt pt1, pt2;
      +int
      +main(void)
      +{
      +  /* Initialize the protothread state variables with PT_INIT(). */
      +  PT_INIT(&pt1);
      +  PT_INIT(&pt2);
      +  
      +  /*
      +   * Then we schedule the two protothreads by repeatedly calling their
      +   * protothread functions and passing a pointer to the protothread
      +   * state variables as arguments.
      +   */
      +  while(1) {
      +    protothread1(&pt1);
      +    protothread2(&pt2);
      +  }
      +}
      +

      +A code-lock

      +This example shows how to implement a simple code lock - the kind of device that is placed next to doors and that you have to push a four digit number into in order to unlock the door.

      +The code lock waits for key presses from a numeric keyboard and if the correct code is entered, the lock is unlocked. There is a maximum time of one second between each key press, and after the correct code has been entered, no more keys must be pressed for 0.5 seconds before the lock is opened.

      +

      /*
      + * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
      + * All rights reserved. 
      + *
      + * Redistribution and use in source and binary forms, with or without 
      + * modification, are permitted provided that the following conditions 
      + * are met: 
      + * 1. Redistributions of source code must retain the above copyright 
      + *    notice, this list of conditions and the following disclaimer. 
      + * 2. Redistributions in binary form must reproduce the above copyright 
      + *    notice, this list of conditions and the following disclaimer in the 
      + *    documentation and/or other materials provided with the distribution. 
      + * 3. Neither the name of the Institute nor the names of its contributors 
      + *    may be used to endorse or promote products derived from this software 
      + *    without specific prior written permission. 
      + *
      + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
      + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
      + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
      + * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE 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. 
      + *
      + * This file is part of the protothreads library.
      + *
      + * Author: Adam Dunkels <adam@sics.se>
      + *
      + * $Id: example-codelock.c,v 1.5 2005/10/06 07:57:08 adam Exp $
      + */
      +
      +/*
      + *
      + * This example shows how to implement a simple code lock. The code
      + * lock waits for key presses from a numeric keyboard and if the
      + * correct code is entered, the lock is unlocked. There is a maximum
      + * time of one second between each key press, and after the correct
      + * code has been entered, no more keys must be pressed for 0.5 seconds
      + * before the lock is opened.
      + *
      + * This is an example that shows two things:
      + * - how to implement a code lock key input mechanism, and
      + * - how to implement a sequential timed routine.
      + *
      + * The program consists of two protothreads, one that implements the
      + * code lock reader and one that implements simulated keyboard input.
      + *
      + *
      + */
      +
      +#ifdef _WIN32
      +#include <windows.h>
      +#else
      +#include <unistd.h>
      +#include <sys/time.h>
      +#endif
      +#include <stdio.h>
      +
      +#include "pt.h"
      +
      +/*---------------------------------------------------------------------------*/
      +/*
      + * The following definitions are just for the simple timer library
      + * used in this example. The actual implementation of the functions
      + * can be found at the end of this file.
      + */
      +struct timer { int start, interval; };
      +static int  timer_expired(struct timer *t);
      +static void timer_set(struct timer *t, int usecs);
      +/*---------------------------------------------------------------------------*/
      +/*
      + * This example uses two timers: one for the code lock protothread and
      + * one for the simulated key input protothread.
      + */
      +static struct timer codelock_timer, input_timer;
      +/*---------------------------------------------------------------------------*/
      +/*
      + * This is the code that has to be entered.
      + */
      +static const char code[4] = {'1', '4', '2', '3'};
      +/*---------------------------------------------------------------------------*/
      +/*
      + * This example has two protothread and therefor has two protothread
      + * control structures of type struct pt. These are initialized with
      + * PT_INIT() in the main() function below.
      + */
      +static struct pt codelock_pt, input_pt;
      +/*---------------------------------------------------------------------------*/
      +/*
      + * The following code implements a simple key input. Input is made
      + * with the press_key() function, and the function key_pressed()
      + * checks if a key has been pressed. The variable "key" holds the
      + * latest key that was pressed. The variable "key_pressed_flag" is set
      + * when a key is pressed and cleared when a key press is checked.
      + */
      +static char key, key_pressed_flag;
      +
      +static void
      +press_key(char k)
      +{
      +  printf("--- Key '%c' pressed\n", k);
      +  key = k;
      +  key_pressed_flag = 1;
      +}
      +
      +static int
      +key_pressed(void)
      +{
      +  if(key_pressed_flag != 0) {
      +    key_pressed_flag = 0;
      +    return 1;
      +  }
      +  return 0;
      +}
      +/*---------------------------------------------------------------------------*/
      +/*
      + * Declaration of the protothread function implementing the code lock
      + * logic. The protothread function is declared using the PT_THREAD()
      + * macro. The function is declared with the "static" keyword since it
      + * is local to this file. The name of the function is codelock_thread
      + * and it takes one argument, pt, of the type struct pt.
      + *
      + */
      +static
      +PT_THREAD(codelock_thread(struct pt *pt))
      +{
      +  /* This is a local variable that holds the number of keys that have
      +   * been pressed. Note that it is declared with the "static" keyword
      +   * to make sure that the variable is *not* allocated on the stack.
      +   */
      +  static int keys;
      +
      +  /*
      +   * Declare the beginning of the protothread.
      +   */
      +  PT_BEGIN(pt);
      +
      +  /*
      +   * We'll let the protothread loop until the protothread is
      +   * expliticly exited with PT_EXIT().
      +   */
      +  while(1) {
      +
      +    /*
      +     * We'll be reading key presses until we get the right amount of
      +     * correct keys.
      +     */ 
      +    for(keys = 0; keys < sizeof(code); ++keys) {
      +
      +      /*
      +       * If we haven't gotten any keypresses, we'll simply wait for one.
      +       */
      +      if(keys == 0) {
      +
      +        /*
      +         * The PT_WAIT_UNTIL() function will block until the condition
      +         * key_pressed() is true.
      +         */
      +        PT_WAIT_UNTIL(pt, key_pressed());
      +      } else {
      +        
      +        /*
      +         * If the "key" variable was larger than zero, we have already
      +         * gotten at least one correct key press. If so, we'll not
      +         * only wait for the next key, but we'll also set a timer that
      +         * expires in one second. This gives the person pressing the
      +         * keys one second to press the next key in the code.
      +         */
      +        timer_set(&codelock_timer, 1000);
      +
      +        /*
      +         * The following statement shows how complex blocking
      +         * conditions can be easily expressed with protothreads and
      +         * the PT_WAIT_UNTIL() function.
      +         */
      +        PT_WAIT_UNTIL(pt, key_pressed() || timer_expired(&codelock_timer));
      +
      +        /*
      +         * If the timer expired, we should break out of the for() loop
      +         * and start reading keys from the beginning of the while(1)
      +         * loop instead.
      +         */
      +        if(timer_expired(&codelock_timer)) {
      +          printf("Code lock timer expired.\n");
      +          
      +          /*
      +           * Break out from the for() loop and start from the
      +           * beginning of the while(1) loop.
      +           */
      +          break;
      +        }
      +      }
      +
      +      /*
      +       * Check if the pressed key was correct.
      +       */
      +      if(key != code[keys]) {
      +        printf("Incorrect key '%c' found\n", key);
      +        /*
      +         * Break out of the for() loop since the key was incorrect.
      +         */
      +        break;
      +      } else {
      +        printf("Correct key '%c' found\n", key);
      +      }
      +    }
      +
      +    /*
      +     * Check if we have gotten all keys.
      +     */
      +    if(keys == sizeof(code)) {
      +      printf("Correct code entered, waiting for 500 ms before unlocking.\n");
      +
      +      /*
      +       * Ok, we got the correct code. But to make sure that the code
      +       * was not just a fluke of luck by an intruder, but the correct
      +       * code entered by a person that knows the correct code, we'll
      +       * wait for half a second before opening the lock. If another
      +       * key is pressed during this time, we'll assume that it was a
      +       * fluke of luck that the correct code was entered the first
      +       * time.
      +       */
      +      timer_set(&codelock_timer, 500);      
      +      PT_WAIT_UNTIL(pt, key_pressed() || timer_expired(&codelock_timer));
      +
      +      /*
      +       * If we continued from the PT_WAIT_UNTIL() statement without
      +       * the timer expired, we don't open the lock.
      +       */
      +      if(!timer_expired(&codelock_timer)) {
      +        printf("Key pressed during final wait, code lock locked again.\n");
      +      } else {
      +
      +        /*
      +         * If the timer expired, we'll open the lock and exit from the
      +         * protothread.
      +         */
      +        printf("Code lock unlocked.\n");
      +        PT_EXIT(pt);
      +      }
      +    }
      +  }
      +
      +  /*
      +   * Finally, we'll mark the end of the protothread.
      +   */
      +  PT_END(pt);
      +}
      +/*---------------------------------------------------------------------------*/
      +/*
      + * This is the second protothread in this example. It implements a
      + * simulated user pressing the keys. This illustrates how a linear
      + * sequence of timed instructions can be implemented with
      + * protothreads.
      + */
      +static
      +PT_THREAD(input_thread(struct pt *pt))
      +{
      +  PT_BEGIN(pt);
      +
      +  printf("Waiting 1 second before entering first key.\n");
      +  
      +  timer_set(&input_timer, 1000);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +
      +  press_key('1');
      +  
      +  timer_set(&input_timer, 100);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('2');
      +
      +  timer_set(&input_timer, 100);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('3');
      +
      +  timer_set(&input_timer, 2000);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('1');
      +
      +  timer_set(&input_timer, 200);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('4');
      +
      +  timer_set(&input_timer, 200);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('2');
      +  
      +  timer_set(&input_timer, 2000);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('3');
      +
      +  timer_set(&input_timer, 200);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('1');
      +
      +  timer_set(&input_timer, 200);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('4');
      +
      +  timer_set(&input_timer, 200);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('2');
      +  
      +  timer_set(&input_timer, 100);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('3');
      +
      +  timer_set(&input_timer, 100);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('4');
      +
      +  timer_set(&input_timer, 1500);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('1');
      +
      +  timer_set(&input_timer, 300);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('4');
      +
      +  timer_set(&input_timer, 400);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('2');
      +
      +  timer_set(&input_timer, 500);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  press_key('3');
      +
      +  timer_set(&input_timer, 2000);
      +  PT_WAIT_UNTIL(pt, timer_expired(&input_timer));
      +  
      +  PT_END(pt);
      +}
      +/*---------------------------------------------------------------------------*/
      +/*
      + * This is the main function. It initializes the two protothread
      + * control structures and schedules the two protothreads. The main
      + * function returns when the protothread the runs the code lock exits.
      + */
      +int
      +main(void)
      +{
      +  /*
      +   * Initialize the two protothread control structures.
      +   */
      +  PT_INIT(&input_pt);
      +  PT_INIT(&codelock_pt);
      +
      +  /*
      +   * Schedule the two protothreads until the codelock_thread() exits.
      +   */
      +  while(PT_SCHEDULE(codelock_thread(&codelock_pt))) {
      +    PT_SCHEDULE(input_thread(&input_pt));
      +    
      +    /*
      +     * When running this example on a multitasking system, we must
      +     * give other processes a chance to run too and therefore we call
      +     * usleep() resp. Sleep() here. On a dedicated embedded system,
      +     * we usually do not need to do this.
      +     */
      +#ifdef _WIN32
      +    Sleep(0);
      +#else
      +    usleep(10);
      +#endif
      +  }
      +
      +  return 0;
      +}
      +/*---------------------------------------------------------------------------*/
      +/*
      + * Finally, the implementation of the simple timer library follows.
      + */
      +#ifdef _WIN32
      +
      +static int clock_time(void)
      +{ return (int)GetTickCount(); }
      +
      +#else /* _WIN32 */
      +
      +static int clock_time(void)
      +{
      +  struct timeval tv;
      +  struct timezone tz;   
      +  gettimeofday(&tv, &tz); 
      +  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
      +}
      +
      +#endif /* _WIN32 */
      +
      +static int timer_expired(struct timer *t)
      +{ return (int)(clock_time() - t->start) >= (int)t->interval; }
      +
      +static void timer_set(struct timer *t, int interval)
      +{ t->interval = interval; t->start = clock_time(); }
      +/*---------------------------------------------------------------------------*/
      +

      +The bounded buffer with protothread semaphores

      +The following example shows how to implement the bounded buffer problem using the protothreads semaphore library. The example uses three protothreads: one producer() protothread that produces items, one consumer() protothread that consumes items, and one driver_thread() that schedules the producer and consumer protothreads.

      +Note that there is no need for a mutex to guard the add_to_buffer() and get_from_buffer() functions because of the implicit locking semantics of protothreads - a protothread will never be preempted and will never block except in an explicit PT_WAIT statement.

      +

      /*
      + * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
      + * All rights reserved. 
      + *
      + * Redistribution and use in source and binary forms, with or without 
      + * modification, are permitted provided that the following conditions 
      + * are met: 
      + * 1. Redistributions of source code must retain the above copyright 
      + *    notice, this list of conditions and the following disclaimer. 
      + * 2. Redistributions in binary form must reproduce the above copyright 
      + *    notice, this list of conditions and the following disclaimer in the 
      + *    documentation and/or other materials provided with the distribution. 
      + * 3. Neither the name of the Institute nor the names of its contributors 
      + *    may be used to endorse or promote products derived from this software 
      + *    without specific prior written permission. 
      + *
      + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
      + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
      + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
      + * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE 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. 
      + *
      + * This file is part of the protothreads library.
      + *
      + * Author: Adam Dunkels <adam@sics.se>
      + *
      + * $Id: example-buffer.c,v 1.5 2005/10/07 05:21:33 adam Exp $
      + */
      +
      +#ifdef _WIN32
      +#include <windows.h>
      +#else
      +#include <unistd.h>
      +#endif
      +#include <stdio.h>
      +
      +#include "pt-sem.h"
      + 
      +#define NUM_ITEMS 32
      +#define BUFSIZE 8
      +
      +static int buffer[BUFSIZE];
      +static int bufptr;
      +
      +static void
      +add_to_buffer(int item)
      +{
      +  printf("Item %d added to buffer at place %d\n", item, bufptr);  
      +  buffer[bufptr] = item;
      +  bufptr = (bufptr + 1) % BUFSIZE;
      +}
      +static int
      +get_from_buffer(void)
      +{
      +  int item;
      +  item = buffer[bufptr];
      +  printf("Item %d retrieved from buffer at place %d\n",
      +         item, bufptr);
      +  bufptr = (bufptr + 1) % BUFSIZE;
      +  return item;
      +}
      +
      +static int
      +produce_item(void)
      +{
      +  static int item = 0;
      +  printf("Item %d produced\n", item);
      +  return item++;
      +}
      +
      +static void
      +consume_item(int item)
      +{
      +  printf("Item %d consumed\n", item);
      +}
      +
      +static struct pt_sem full, empty;
      + 
      +static 
      +PT_THREAD(producer(struct pt *pt))
      +{
      +  static int produced;
      +  
      +  PT_BEGIN(pt);
      +  
      +  for(produced = 0; produced < NUM_ITEMS; ++produced) {
      +  
      +    PT_SEM_WAIT(pt, &full);
      +    
      +    add_to_buffer(produce_item());
      +    
      +    PT_SEM_SIGNAL(pt, &empty);
      +  }
      +
      +  PT_END(pt);
      +}
      + 
      +static 
      +PT_THREAD(consumer(struct pt *pt))
      +{
      +  static int consumed;
      +  
      +  PT_BEGIN(pt);
      + 
      +  for(consumed = 0; consumed < NUM_ITEMS; ++consumed) {
      +    
      +    PT_SEM_WAIT(pt, &empty);
      +    
      +    consume_item(get_from_buffer());    
      +    
      +    PT_SEM_SIGNAL(pt, &full);
      +  }
      + 
      +  PT_END(pt);
      +}
      + 
      +static 
      +PT_THREAD(driver_thread(struct pt *pt))
      +{
      +  static struct pt pt_producer, pt_consumer;
      + 
      +  PT_BEGIN(pt);
      +  
      +  PT_SEM_INIT(&empty, 0);
      +  PT_SEM_INIT(&full, BUFSIZE);
      + 
      +  PT_INIT(&pt_producer);
      +  PT_INIT(&pt_consumer);
      + 
      +  PT_WAIT_THREAD(pt, producer(&pt_producer) &
      +                     consumer(&pt_consumer));
      + 
      +  PT_END(pt);
      +}
      +
      +
      +int
      +main(void)
      +{
      +  struct pt driver_pt;
      +
      +  PT_INIT(&driver_pt);
      +
      +  while(PT_SCHEDULE(driver_thread(&driver_pt))) {
      +
      +    /*
      +     * When running this example on a multitasking system, we must
      +     * give other processes a chance to run too and therefore we call
      +     * usleep() resp. Sleep() here. On a dedicated embedded system,
      +     * we usually do not need to do this.
      +     */
      +#ifdef _WIN32
      +    Sleep(0);
      +#else
      +    usleep(10);
      +#endif
      +  }
      +  return 0;
      +}
      +
      +

      + + +
      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00016.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00016.html new file mode 100644 index 0000000..743f2bd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00016.html @@ -0,0 +1,246 @@ + + +The Protothreads Library 1.4: Protothread semaphores + + + + + +

      Protothread semaphores
      + +[Protothreads] +


      Detailed Description

      +This module implements counting semaphores on top of protothreads. +

      +Semaphores are a synchronization primitive that provide two operations: "wait" and "signal". The "wait" operation checks the semaphore counter and blocks the thread if the counter is zero. The "signal" operation increases the semaphore counter but does not block. If another thread has blocked waiting for the semaphore that is signalled, the blocked thread will become runnable again.

      +Semaphores can be used to implement other, more structured, synchronization primitives such as monitors and message queues/bounded buffers (see below).

      +The following example shows how the producer-consumer problem, also known as the bounded buffer problem, can be solved using protothreads and semaphores. Notes on the program follow after the example.

      +

      #include "pt-sem.h"
      +
      +#define NUM_ITEMS 32
      +#define BUFSIZE 8
      +
      +static struct pt_sem mutex, full, empty;
      +
      +PT_THREAD(producer(struct pt *pt))
      +{
      +  static int produced;
      +  
      +  PT_BEGIN(pt);
      +  
      +  for(produced = 0; produced < NUM_ITEMS; ++produced) {
      +  
      +    PT_SEM_WAIT(pt, &full);
      +    
      +    PT_SEM_WAIT(pt, &mutex);
      +    add_to_buffer(produce_item());    
      +    PT_SEM_SIGNAL(pt, &mutex);
      +    
      +    PT_SEM_SIGNAL(pt, &empty);
      +  }
      +
      +  PT_END(pt);
      +}
      +
      +PT_THREAD(consumer(struct pt *pt))
      +{
      +  static int consumed;
      +  
      +  PT_BEGIN(pt);
      +
      +  for(consumed = 0; consumed < NUM_ITEMS; ++consumed) {
      +    
      +    PT_SEM_WAIT(pt, &empty);
      +    
      +    PT_SEM_WAIT(pt, &mutex);    
      +    consume_item(get_from_buffer());    
      +    PT_SEM_SIGNAL(pt, &mutex);
      +    
      +    PT_SEM_SIGNAL(pt, &full);
      +  }
      +
      +  PT_END(pt);
      +}
      +
      +PT_THREAD(driver_thread(struct pt *pt))
      +{
      +  static struct pt pt_producer, pt_consumer;
      +
      +  PT_BEGIN(pt);
      +  
      +  PT_SEM_INIT(&empty, 0);
      +  PT_SEM_INIT(&full, BUFSIZE);
      +  PT_SEM_INIT(&mutex, 1);
      +
      +  PT_INIT(&pt_producer);
      +  PT_INIT(&pt_consumer);
      +
      +  PT_WAIT_THREAD(pt, producer(&pt_producer) &
      +                     consumer(&pt_consumer));
      +
      +  PT_END(pt);
      +}
      +

      +The program uses three protothreads: one protothread that implements the consumer, one thread that implements the producer, and one protothread that drives the two other protothreads. The program uses three semaphores: "full", "empty" and "mutex". The "mutex" semaphore is used to provide mutual exclusion for the buffer, the "empty" semaphore is used to block the consumer is the buffer is empty, and the "full" semaphore is used to block the producer is the buffer is full.

      +The "driver_thread" holds two protothread state variables, "pt_producer" and "pt_consumer". It is important to note that both these variables are declared as static. If the static keyword is not used, both variables are stored on the stack. Since protothreads do not store the stack, these variables may be overwritten during a protothread wait operation. Similarly, both the "consumer" and "producer" protothreads declare their local variables as static, to avoid them being stored on the stack. +

      + + + + + + + +

      +

      + + + + + + + + + + + + +

      Files

      file  pt-sem.h
       Couting semaphores implemented on protothreads.

      Data Structures

      struct  pt_sem

      Defines

      #define PT_SEM_INIT(s, c)
       Initialize a semaphore.
      #define PT_SEM_WAIT(pt, s)
       Wait for a semaphore.
      #define PT_SEM_SIGNAL(pt, s)
       Signal a semaphore.
      +


      Define Documentation

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_SEM_INIT s,
       ) 
      +
      + + + + + +
      +   + + +

      +Initialize a semaphore. +

      +This macro initializes a semaphore with a value for the counter. Internally, the semaphores use an "unsigned int" to represent the counter, and therefore the "count" argument should be within range of an unsigned int.

      +

      Parameters:
      + + + +
      s (struct pt_sem *) A pointer to the pt_sem struct representing the semaphore
      c (unsigned int) The initial count of the semaphore.
      +
      + +

      +Definition at line 183 of file pt-sem.h.

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_SEM_SIGNAL pt,
       ) 
      +
      + + + + + +
      +   + + +

      +Signal a semaphore. +

      +This macro carries out the "signal" operation on the semaphore. The signal operation increments the counter inside the semaphore, which eventually will cause waiting protothreads to continue executing.

      +

      Parameters:
      + + + +
      pt (struct pt *) A pointer to the protothread (struct pt) in which the operation is executed.
      s (struct pt_sem *) A pointer to the pt_sem struct representing the semaphore
      +
      + +

      +Definition at line 222 of file pt-sem.h.

      +

      + + + + +
      + + + + + + + + + + + + +
      #define PT_SEM_WAIT pt,
       ) 
      +
      + + + + + +
      +   + + +

      +Wait for a semaphore. +

      +This macro carries out the "wait" operation on the semaphore. The wait operation causes the protothread to block while the counter is zero. When the counter reaches a value larger than zero, the protothread will continue.

      +

      Parameters:
      + + + +
      pt (struct pt *) A pointer to the protothread (struct pt) in which the operation is executed.
      s (struct pt_sem *) A pointer to the pt_sem struct representing the semaphore
      +
      + +

      +Definition at line 201 of file pt-sem.h.

      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00017.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00017.html new file mode 100644 index 0000000..9a37968 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00017.html @@ -0,0 +1,226 @@ + + +The Protothreads Library 1.4: Local continuations + + + + + +

      Local continuations
      + +[Protothreads] +


      Detailed Description

      +Local continuations form the basis for implementing protothreads. +

      +A local continuation can be set in a specific function to capture the state of the function. After a local continuation has been set can be resumed in order to restore the state of the function at the point where the local continuation was set. +

      + + + + + + + +

      +

      + + + +

      +

      + + + +

      +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      Files

      file  lc.h
       Local continuations.
      file  lc-switch.h
       Implementation of local continuations based on switch() statment.
      file  lc-addrlabels.h
       Implementation of local continuations based on the "Labels as values" feature of gcc.

      Defines

      #define LC_INIT(lc)
       Initialize a local continuation.
      #define LC_SET(lc)
       Set a local continuation.
      #define LC_RESUME(lc)
       Resume a local continuation.
      #define LC_END(lc)
       Mark the end of local continuation usage.
      +#define LC_INIT(s)   s = 0;
      +#define LC_RESUME(s)   switch(s) { case 0:
      +#define LC_SET(s)   s = __LINE__; case __LINE__:
      +#define LC_END(s)   }
      +#define LC_INIT(s)   s = NULL
      +#define LC_RESUME(s)
      +#define LC_CONCAT2(s1, s2)   s1##s2
      +#define LC_CONCAT(s1, s2)   LC_CONCAT2(s1, s2)
      +#define LC_SET(s)
      +#define LC_END(s)

      Typedefs

      +typedef unsigned short lc_t
       The local continuation type.
      +typedef void * lc_t
      +


      Define Documentation

      +

      + + + + +
      + + + + + + + + + +
      #define LC_END lc   ) 
      +
      + + + + + +
      +   + + +

      +Mark the end of local continuation usage. +

      +The end operation signifies that local continuations should not be used any more in the function. This operation is not needed for most implementations of local continuation, but is required by a few implementations. +

      +Definition at line 108 of file lc.h.

      +

      + + + + +
      + + + + + + + + + +
      #define LC_INIT lc   ) 
      +
      + + + + + +
      +   + + +

      +Initialize a local continuation. +

      +This operation initializes the local continuation, thereby unsetting any previously set continuation state. +

      +Definition at line 71 of file lc.h.

      +

      + + + + +
      + + + + + + + + + +
      #define LC_RESUME lc   ) 
      +
      + + + + + +
      +   + + +

      +Resume a local continuation. +

      +The resume operation resumes a previously set local continuation, thus restoring the state in which the function was when the local continuation was set. If the local continuation has not been previously set, the resume operation does nothing. +

      +Definition at line 96 of file lc.h.

      +

      + + + + +
      + + + + + + + + + +
      #define LC_SET lc   ) 
      +
      + + + + + +
      +   + + +

      +Set a local continuation. +

      +The set operation saves the state of the function at the point where the operation is executed. As far as the set operation is concerned, the state of the function does not include the call-stack or local (automatic) variables, but only the program counter and such CPU registers that needs to be saved. +

      +Definition at line 84 of file lc.h.

      +


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00018.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00018.html new file mode 100644 index 0000000..8f20cba --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00018.html @@ -0,0 +1,109 @@ + + +The Protothreads Library 1.4: lc-addrlabels.h Source File + + + + + + +

      lc-addrlabels.h

      Go to the documentation of this file.
      00001 /*
      +00002  * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
      +00003  * All rights reserved.
      +00004  *
      +00005  * Redistribution and use in source and binary forms, with or without
      +00006  * modification, are permitted provided that the following conditions
      +00007  * are met:
      +00008  * 1. Redistributions of source code must retain the above copyright
      +00009  *    notice, this list of conditions and the following disclaimer.
      +00010  * 2. Redistributions in binary form must reproduce the above copyright
      +00011  *    notice, this list of conditions and the following disclaimer in the
      +00012  *    documentation and/or other materials provided with the distribution.
      +00013  * 3. Neither the name of the Institute nor the names of its contributors
      +00014  *    may be used to endorse or promote products derived from this software
      +00015  *    without specific prior written permission.
      +00016  *
      +00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
      +00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      +00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      +00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
      +00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      +00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      +00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      +00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      +00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      +00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      +00027  * SUCH DAMAGE.
      +00028  *
      +00029  * This file is part of the Contiki operating system.
      +00030  *
      +00031  * Author: Adam Dunkels <adam@sics.se>
      +00032  *
      +00033  * $Id: lc-addrlabels.h,v 1.4 2006/06/03 11:29:43 adam Exp $
      +00034  */
      +00035 
      +00036 /**
      +00037  * \addtogroup lc
      +00038  * @{
      +00039  */
      +00040 
      +00041 /**
      +00042  * \file
      +00043  * Implementation of local continuations based on the "Labels as
      +00044  * values" feature of gcc
      +00045  * \author
      +00046  * Adam Dunkels <adam@sics.se>
      +00047  *
      +00048  * This implementation of local continuations is based on a special
      +00049  * feature of the GCC C compiler called "labels as values". This
      +00050  * feature allows assigning pointers with the address of the code
      +00051  * corresponding to a particular C label.
      +00052  *
      +00053  * For more information, see the GCC documentation:
      +00054  * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
      +00055  *
      +00056  */
      +00057 
      +00058 #ifndef __LC_ADDRLABELS_H__
      +00059 #define __LC_ADDRLABELS_H__
      +00060 
      +00061 /** \hideinitializer */
      +00062 typedef void * lc_t;
      +00063 
      +00064 #define LC_INIT(s) s = NULL
      +00065 
      +00066 #define LC_RESUME(s)                            \
      +00067   do {                                          \
      +00068     if(s != NULL) {                             \
      +00069       goto *s;                                  \
      +00070     }                                           \
      +00071   } while(0)
      +00072 
      +00073 #define LC_CONCAT2(s1, s2) s1##s2
      +00074 #define LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2)
      +00075 
      +00076 #define LC_SET(s)                               \
      +00077   do {                                          \
      +00078     LC_CONCAT(LC_LABEL, __LINE__):              \
      +00079     (s) = &&LC_CONCAT(LC_LABEL, __LINE__);      \
      +00080   } while(0)
      +00081 
      +00082 #define LC_END(s)
      +00083 
      +00084 #endif /* __LC_ADDRLABELS_H__ */
      +00085 /** @} */
      +

      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00019.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00019.html new file mode 100644 index 0000000..a443882 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00019.html @@ -0,0 +1,100 @@ + + +The Protothreads Library 1.4: lc-switch.h Source File + + + + + + +

      lc-switch.h

      Go to the documentation of this file.
      00001 /*
      +00002  * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
      +00003  * All rights reserved.
      +00004  *
      +00005  * Redistribution and use in source and binary forms, with or without
      +00006  * modification, are permitted provided that the following conditions
      +00007  * are met:
      +00008  * 1. Redistributions of source code must retain the above copyright
      +00009  *    notice, this list of conditions and the following disclaimer.
      +00010  * 2. Redistributions in binary form must reproduce the above copyright
      +00011  *    notice, this list of conditions and the following disclaimer in the
      +00012  *    documentation and/or other materials provided with the distribution.
      +00013  * 3. Neither the name of the Institute nor the names of its contributors
      +00014  *    may be used to endorse or promote products derived from this software
      +00015  *    without specific prior written permission.
      +00016  *
      +00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
      +00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      +00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      +00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
      +00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      +00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      +00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      +00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      +00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      +00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      +00027  * SUCH DAMAGE.
      +00028  *
      +00029  * This file is part of the Contiki operating system.
      +00030  *
      +00031  * Author: Adam Dunkels <adam@sics.se>
      +00032  *
      +00033  * $Id: lc-switch.h,v 1.4 2006/06/03 11:29:43 adam Exp $
      +00034  */
      +00035 
      +00036 /**
      +00037  * \addtogroup lc
      +00038  * @{
      +00039  */
      +00040 
      +00041 /**
      +00042  * \file
      +00043  * Implementation of local continuations based on switch() statment
      +00044  * \author Adam Dunkels <adam@sics.se>
      +00045  *
      +00046  * This implementation of local continuations uses the C switch()
      +00047  * statement to resume execution of a function somewhere inside the
      +00048  * function's body. The implementation is based on the fact that
      +00049  * switch() statements are able to jump directly into the bodies of
      +00050  * control structures such as if() or while() statmenets.
      +00051  *
      +00052  * This implementation borrows heavily from Simon Tatham's coroutines
      +00053  * implementation in C:
      +00054  * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
      +00055  */
      +00056 
      +00057 #ifndef __LC_SWITCH_H__
      +00058 #define __LC_SWITCH_H__
      +00059 
      +00060 /* WARNING! lc implementation using switch() does not work if an
      +00061    LC_SET() is done within another switch() statement! */
      +00062 
      +00063 /** \hideinitializer */
      +00064 typedef unsigned short lc_t;
      +00065 
      +00066 #define LC_INIT(s) s = 0;
      +00067 
      +00068 #define LC_RESUME(s) switch(s) { case 0:
      +00069 
      +00070 #define LC_SET(s) s = __LINE__; case __LINE__:
      +00071 
      +00072 #define LC_END(s) }
      +00073 
      +00074 #endif /* __LC_SWITCH_H__ */
      +00075 
      +00076 /** @} */
      +

      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00020.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00020.html new file mode 100644 index 0000000..0381a4c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00020.html @@ -0,0 +1,156 @@ + + +The Protothreads Library 1.4: lc.h Source File + + + + + + +

      lc.h

      Go to the documentation of this file.
      00001 /*
      +00002  * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
      +00003  * All rights reserved. 
      +00004  *
      +00005  * Redistribution and use in source and binary forms, with or without 
      +00006  * modification, are permitted provided that the following conditions 
      +00007  * are met: 
      +00008  * 1. Redistributions of source code must retain the above copyright 
      +00009  *    notice, this list of conditions and the following disclaimer. 
      +00010  * 2. Redistributions in binary form must reproduce the above copyright 
      +00011  *    notice, this list of conditions and the following disclaimer in the 
      +00012  *    documentation and/or other materials provided with the distribution. 
      +00013  * 3. Neither the name of the Institute nor the names of its contributors 
      +00014  *    may be used to endorse or promote products derived from this software 
      +00015  *    without specific prior written permission. 
      +00016  *
      +00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
      +00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
      +00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
      +00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
      +00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
      +00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
      +00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
      +00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
      +00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
      +00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
      +00027  * SUCH DAMAGE. 
      +00028  *
      +00029  * This file is part of the protothreads library.
      +00030  * 
      +00031  * Author: Adam Dunkels <adam@sics.se>
      +00032  *
      +00033  * $Id: lc.h,v 1.2 2005/02/24 10:36:59 adam Exp $
      +00034  */
      +00035 
      +00036 /**
      +00037  * \addtogroup pt
      +00038  * @{
      +00039  */
      +00040 
      +00041 /**
      +00042  * \defgroup lc Local continuations
      +00043  * @{
      +00044  *
      +00045  * Local continuations form the basis for implementing protothreads. A
      +00046  * local continuation can be <i>set</i> in a specific function to
      +00047  * capture the state of the function. After a local continuation has
      +00048  * been set can be <i>resumed</i> in order to restore the state of the
      +00049  * function at the point where the local continuation was set.
      +00050  *
      +00051  *
      +00052  */
      +00053 
      +00054 /**
      +00055  * \file lc.h
      +00056  * Local continuations
      +00057  * \author
      +00058  * Adam Dunkels <adam@sics.se>
      +00059  *
      +00060  */
      +00061 
      +00062 #ifdef DOXYGEN
      +00063 /**
      +00064  * Initialize a local continuation.
      +00065  *
      +00066  * This operation initializes the local continuation, thereby
      +00067  * unsetting any previously set continuation state.
      +00068  *
      +00069  * \hideinitializer
      +00070  */
      +00071 #define LC_INIT(lc)
      +00072 
      +00073 /**
      +00074  * Set a local continuation.
      +00075  *
      +00076  * The set operation saves the state of the function at the point
      +00077  * where the operation is executed. As far as the set operation is
      +00078  * concerned, the state of the function does <b>not</b> include the
      +00079  * call-stack or local (automatic) variables, but only the program
      +00080  * counter and such CPU registers that needs to be saved.
      +00081  *
      +00082  * \hideinitializer
      +00083  */
      +00084 #define LC_SET(lc)
      +00085 
      +00086 /**
      +00087  * Resume a local continuation.
      +00088  *
      +00089  * The resume operation resumes a previously set local continuation, thus
      +00090  * restoring the state in which the function was when the local
      +00091  * continuation was set. If the local continuation has not been
      +00092  * previously set, the resume operation does nothing.
      +00093  *
      +00094  * \hideinitializer
      +00095  */
      +00096 #define LC_RESUME(lc)
      +00097 
      +00098 /**
      +00099  * Mark the end of local continuation usage.
      +00100  *
      +00101  * The end operation signifies that local continuations should not be
      +00102  * used any more in the function. This operation is not needed for
      +00103  * most implementations of local continuation, but is required by a
      +00104  * few implementations.
      +00105  *
      +00106  * \hideinitializer 
      +00107  */
      +00108 #define LC_END(lc)
      +00109 
      +00110 /**
      +00111  * \var typedef lc_t;
      +00112  *
      +00113  * The local continuation type.
      +00114  *
      +00115  * \hideinitializer
      +00116  */
      +00117 #endif /* DOXYGEN */
      +00118 
      +00119 #ifndef __LC_H__
      +00120 #define __LC_H__
      +00121 
      +00122 
      +00123 #ifdef LC_INCLUDE
      +00124 #include LC_INCLUDE
      +00125 #else
      +00126 #include "lc-switch.h"
      +00127 #endif /* LC_INCLUDE */
      +00128 
      +00129 #endif /* __LC_H__ */
      +00130 
      +00131 /** @} */
      +00132 /** @} */
      +

      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00021.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00021.html new file mode 100644 index 0000000..1c4f116 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00021.html @@ -0,0 +1,252 @@ + + +The Protothreads Library 1.4: pt-sem.h Source File + + + + + + +

      pt-sem.h

      Go to the documentation of this file.
      00001 /*
      +00002  * Copyright (c) 2004, Swedish Institute of Computer Science.
      +00003  * All rights reserved. 
      +00004  *
      +00005  * Redistribution and use in source and binary forms, with or without 
      +00006  * modification, are permitted provided that the following conditions 
      +00007  * are met: 
      +00008  * 1. Redistributions of source code must retain the above copyright 
      +00009  *    notice, this list of conditions and the following disclaimer. 
      +00010  * 2. Redistributions in binary form must reproduce the above copyright 
      +00011  *    notice, this list of conditions and the following disclaimer in the 
      +00012  *    documentation and/or other materials provided with the distribution. 
      +00013  * 3. Neither the name of the Institute nor the names of its contributors 
      +00014  *    may be used to endorse or promote products derived from this software 
      +00015  *    without specific prior written permission. 
      +00016  *
      +00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
      +00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
      +00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
      +00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
      +00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
      +00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
      +00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
      +00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
      +00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
      +00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
      +00027  * SUCH DAMAGE. 
      +00028  *
      +00029  * This file is part of the protothreads library.
      +00030  * 
      +00031  * Author: Adam Dunkels <adam@sics.se>
      +00032  *
      +00033  * $Id: pt-sem.h,v 1.2 2005/02/24 10:36:59 adam Exp $
      +00034  */
      +00035 
      +00036 /**
      +00037  * \addtogroup pt
      +00038  * @{
      +00039  */
      +00040 
      +00041 /**
      +00042  * \defgroup ptsem Protothread semaphores
      +00043  * @{
      +00044  *
      +00045  * This module implements counting semaphores on top of
      +00046  * protothreads. Semaphores are a synchronization primitive that
      +00047  * provide two operations: "wait" and "signal". The "wait" operation
      +00048  * checks the semaphore counter and blocks the thread if the counter
      +00049  * is zero. The "signal" operation increases the semaphore counter but
      +00050  * does not block. If another thread has blocked waiting for the
      +00051  * semaphore that is signalled, the blocked thread will become
      +00052  * runnable again.
      +00053  *
      +00054  * Semaphores can be used to implement other, more structured,
      +00055  * synchronization primitives such as monitors and message
      +00056  * queues/bounded buffers (see below).
      +00057  *
      +00058  * The following example shows how the producer-consumer problem, also
      +00059  * known as the bounded buffer problem, can be solved using
      +00060  * protothreads and semaphores. Notes on the program follow after the
      +00061  * example.
      +00062  *
      +00063  \code
      +00064 #include "pt-sem.h"
      +00065 
      +00066 #define NUM_ITEMS 32
      +00067 #define BUFSIZE 8
      +00068 
      +00069 static struct pt_sem mutex, full, empty;
      +00070 
      +00071 PT_THREAD(producer(struct pt *pt))
      +00072 {
      +00073   static int produced;
      +00074   
      +00075   PT_BEGIN(pt);
      +00076   
      +00077   for(produced = 0; produced < NUM_ITEMS; ++produced) {
      +00078   
      +00079     PT_SEM_WAIT(pt, &full);
      +00080     
      +00081     PT_SEM_WAIT(pt, &mutex);
      +00082     add_to_buffer(produce_item());    
      +00083     PT_SEM_SIGNAL(pt, &mutex);
      +00084     
      +00085     PT_SEM_SIGNAL(pt, &empty);
      +00086   }
      +00087 
      +00088   PT_END(pt);
      +00089 }
      +00090 
      +00091 PT_THREAD(consumer(struct pt *pt))
      +00092 {
      +00093   static int consumed;
      +00094   
      +00095   PT_BEGIN(pt);
      +00096 
      +00097   for(consumed = 0; consumed < NUM_ITEMS; ++consumed) {
      +00098     
      +00099     PT_SEM_WAIT(pt, &empty);
      +00100     
      +00101     PT_SEM_WAIT(pt, &mutex);    
      +00102     consume_item(get_from_buffer());    
      +00103     PT_SEM_SIGNAL(pt, &mutex);
      +00104     
      +00105     PT_SEM_SIGNAL(pt, &full);
      +00106   }
      +00107 
      +00108   PT_END(pt);
      +00109 }
      +00110 
      +00111 PT_THREAD(driver_thread(struct pt *pt))
      +00112 {
      +00113   static struct pt pt_producer, pt_consumer;
      +00114 
      +00115   PT_BEGIN(pt);
      +00116   
      +00117   PT_SEM_INIT(&empty, 0);
      +00118   PT_SEM_INIT(&full, BUFSIZE);
      +00119   PT_SEM_INIT(&mutex, 1);
      +00120 
      +00121   PT_INIT(&pt_producer);
      +00122   PT_INIT(&pt_consumer);
      +00123 
      +00124   PT_WAIT_THREAD(pt, producer(&pt_producer) &
      +00125                      consumer(&pt_consumer));
      +00126 
      +00127   PT_END(pt);
      +00128 }
      +00129  \endcode
      +00130  *
      +00131  * The program uses three protothreads: one protothread that
      +00132  * implements the consumer, one thread that implements the producer,
      +00133  * and one protothread that drives the two other protothreads. The
      +00134  * program uses three semaphores: "full", "empty" and "mutex". The
      +00135  * "mutex" semaphore is used to provide mutual exclusion for the
      +00136  * buffer, the "empty" semaphore is used to block the consumer is the
      +00137  * buffer is empty, and the "full" semaphore is used to block the
      +00138  * producer is the buffer is full.
      +00139  *
      +00140  * The "driver_thread" holds two protothread state variables,
      +00141  * "pt_producer" and "pt_consumer". It is important to note that both
      +00142  * these variables are declared as <i>static</i>. If the static
      +00143  * keyword is not used, both variables are stored on the stack. Since
      +00144  * protothreads do not store the stack, these variables may be
      +00145  * overwritten during a protothread wait operation. Similarly, both
      +00146  * the "consumer" and "producer" protothreads declare their local
      +00147  * variables as static, to avoid them being stored on the stack.
      +00148  * 
      +00149  *
      +00150  */
      +00151    
      +00152 /**
      +00153  * \file
      +00154  * Couting semaphores implemented on protothreads
      +00155  * \author
      +00156  * Adam Dunkels <adam@sics.se>
      +00157  *
      +00158  */
      +00159 
      +00160 #ifndef __PT_SEM_H__
      +00161 #define __PT_SEM_H__
      +00162 
      +00163 #include "pt.h"
      +00164 
      +00165 struct pt_sem {
      +00166   unsigned int count;
      +00167 };
      +00168 
      +00169 /**
      +00170  * Initialize a semaphore
      +00171  *
      +00172  * This macro initializes a semaphore with a value for the
      +00173  * counter. Internally, the semaphores use an "unsigned int" to
      +00174  * represent the counter, and therefore the "count" argument should be
      +00175  * within range of an unsigned int.
      +00176  *
      +00177  * \param s (struct pt_sem *) A pointer to the pt_sem struct
      +00178  * representing the semaphore
      +00179  *
      +00180  * \param c (unsigned int) The initial count of the semaphore.
      +00181  * \hideinitializer
      +00182  */
      +00183 #define PT_SEM_INIT(s, c) (s)->count = c
      +00184 
      +00185 /**
      +00186  * Wait for a semaphore
      +00187  *
      +00188  * This macro carries out the "wait" operation on the semaphore. The
      +00189  * wait operation causes the protothread to block while the counter is
      +00190  * zero. When the counter reaches a value larger than zero, the
      +00191  * protothread will continue.
      +00192  *
      +00193  * \param pt (struct pt *) A pointer to the protothread (struct pt) in
      +00194  * which the operation is executed.
      +00195  *
      +00196  * \param s (struct pt_sem *) A pointer to the pt_sem struct
      +00197  * representing the semaphore
      +00198  *
      +00199  * \hideinitializer
      +00200  */
      +00201 #define PT_SEM_WAIT(pt, s)      \
      +00202   do {                                          \
      +00203     PT_WAIT_UNTIL(pt, (s)->count > 0);          \
      +00204     --(s)->count;                               \
      +00205   } while(0)
      +00206 
      +00207 /**
      +00208  * Signal a semaphore
      +00209  *
      +00210  * This macro carries out the "signal" operation on the semaphore. The
      +00211  * signal operation increments the counter inside the semaphore, which
      +00212  * eventually will cause waiting protothreads to continue executing.
      +00213  *
      +00214  * \param pt (struct pt *) A pointer to the protothread (struct pt) in
      +00215  * which the operation is executed.
      +00216  *
      +00217  * \param s (struct pt_sem *) A pointer to the pt_sem struct
      +00218  * representing the semaphore
      +00219  *
      +00220  * \hideinitializer
      +00221  */
      +00222 #define PT_SEM_SIGNAL(pt, s) ++(s)->count
      +00223 
      +00224 #endif /* __PT_SEM_H__ */
      +00225 
      +00226 /** @} */
      +00227 /** @} */
      +00228    
      +

      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00022.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00022.html new file mode 100644 index 0000000..ceb6716 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/a00022.html @@ -0,0 +1,347 @@ + + +The Protothreads Library 1.4: pt.h Source File + + + + + + +

      pt.h

      Go to the documentation of this file.
      00001 /*
      +00002  * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
      +00003  * All rights reserved.
      +00004  *
      +00005  * Redistribution and use in source and binary forms, with or without
      +00006  * modification, are permitted provided that the following conditions
      +00007  * are met:
      +00008  * 1. Redistributions of source code must retain the above copyright
      +00009  *    notice, this list of conditions and the following disclaimer.
      +00010  * 2. Redistributions in binary form must reproduce the above copyright
      +00011  *    notice, this list of conditions and the following disclaimer in the
      +00012  *    documentation and/or other materials provided with the distribution.
      +00013  * 3. Neither the name of the Institute nor the names of its contributors
      +00014  *    may be used to endorse or promote products derived from this software
      +00015  *    without specific prior written permission.
      +00016  *
      +00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
      +00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      +00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      +00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
      +00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      +00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      +00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      +00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      +00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      +00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      +00027  * SUCH DAMAGE.
      +00028  *
      +00029  * This file is part of the Contiki operating system.
      +00030  *
      +00031  * Author: Adam Dunkels <adam@sics.se>
      +00032  *
      +00033  * $Id: pt.h,v 1.7 2006/10/02 07:52:56 adam Exp $
      +00034  */
      +00035 
      +00036 /**
      +00037  * \addtogroup pt
      +00038  * @{
      +00039  */
      +00040 
      +00041 /**
      +00042  * \file
      +00043  * Protothreads implementation.
      +00044  * \author
      +00045  * Adam Dunkels <adam@sics.se>
      +00046  *
      +00047  */
      +00048 
      +00049 #ifndef __PT_H__
      +00050 #define __PT_H__
      +00051 
      +00052 #include "lc.h"
      +00053 
      +00054 struct pt {
      +00055   lc_t lc;
      +00056 };
      +00057 
      +00058 #define PT_WAITING 0
      +00059 #define PT_YIELDED 1
      +00060 #define PT_EXITED  2
      +00061 #define PT_ENDED   3
      +00062 
      +00063 /**
      +00064  * \name Initialization
      +00065  * @{
      +00066  */
      +00067 
      +00068 /**
      +00069  * Initialize a protothread.
      +00070  *
      +00071  * Initializes a protothread. Initialization must be done prior to
      +00072  * starting to execute the protothread.
      +00073  *
      +00074  * \param pt A pointer to the protothread control structure.
      +00075  *
      +00076  * \sa PT_SPAWN()
      +00077  *
      +00078  * \hideinitializer
      +00079  */
      +00080 #define PT_INIT(pt)   LC_INIT((pt)->lc)
      +00081 
      +00082 /** @} */
      +00083 
      +00084 /**
      +00085  * \name Declaration and definition
      +00086  * @{
      +00087  */
      +00088 
      +00089 /**
      +00090  * Declaration of a protothread.
      +00091  *
      +00092  * This macro is used to declare a protothread. All protothreads must
      +00093  * be declared with this macro.
      +00094  *
      +00095  * \param name_args The name and arguments of the C function
      +00096  * implementing the protothread.
      +00097  *
      +00098  * \hideinitializer
      +00099  */
      +00100 #define PT_THREAD(name_args) char name_args
      +00101 
      +00102 /**
      +00103  * Declare the start of a protothread inside the C function
      +00104  * implementing the protothread.
      +00105  *
      +00106  * This macro is used to declare the starting point of a
      +00107  * protothread. It should be placed at the start of the function in
      +00108  * which the protothread runs. All C statements above the PT_BEGIN()
      +00109  * invokation will be executed each time the protothread is scheduled.
      +00110  *
      +00111  * \param pt A pointer to the protothread control structure.
      +00112  *
      +00113  * \hideinitializer
      +00114  */
      +00115 #define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)
      +00116 
      +00117 /**
      +00118  * Declare the end of a protothread.
      +00119  *
      +00120  * This macro is used for declaring that a protothread ends. It must
      +00121  * always be used together with a matching PT_BEGIN() macro.
      +00122  *
      +00123  * \param pt A pointer to the protothread control structure.
      +00124  *
      +00125  * \hideinitializer
      +00126  */
      +00127 #define PT_END(pt) LC_END((pt)->lc); PT_YIELD_FLAG = 0; \
      +00128                    PT_INIT(pt); return PT_ENDED; }
      +00129 
      +00130 /** @} */
      +00131 
      +00132 /**
      +00133  * \name Blocked wait
      +00134  * @{
      +00135  */
      +00136 
      +00137 /**
      +00138  * Block and wait until condition is true.
      +00139  *
      +00140  * This macro blocks the protothread until the specified condition is
      +00141  * true.
      +00142  *
      +00143  * \param pt A pointer to the protothread control structure.
      +00144  * \param condition The condition.
      +00145  *
      +00146  * \hideinitializer
      +00147  */
      +00148 #define PT_WAIT_UNTIL(pt, condition)            \
      +00149   do {                                          \
      +00150     LC_SET((pt)->lc);                           \
      +00151     if(!(condition)) {                          \
      +00152       return PT_WAITING;                        \
      +00153     }                                           \
      +00154   } while(0)
      +00155 
      +00156 /**
      +00157  * Block and wait while condition is true.
      +00158  *
      +00159  * This function blocks and waits while condition is true. See
      +00160  * PT_WAIT_UNTIL().
      +00161  *
      +00162  * \param pt A pointer to the protothread control structure.
      +00163  * \param cond The condition.
      +00164  *
      +00165  * \hideinitializer
      +00166  */
      +00167 #define PT_WAIT_WHILE(pt, cond)  PT_WAIT_UNTIL((pt), !(cond))
      +00168 
      +00169 /** @} */
      +00170 
      +00171 /**
      +00172  * \name Hierarchical protothreads
      +00173  * @{
      +00174  */
      +00175 
      +00176 /**
      +00177  * Block and wait until a child protothread completes.
      +00178  *
      +00179  * This macro schedules a child protothread. The current protothread
      +00180  * will block until the child protothread completes.
      +00181  *
      +00182  * \note The child protothread must be manually initialized with the
      +00183  * PT_INIT() function before this function is used.
      +00184  *
      +00185  * \param pt A pointer to the protothread control structure.
      +00186  * \param thread The child protothread with arguments
      +00187  *
      +00188  * \sa PT_SPAWN()
      +00189  *
      +00190  * \hideinitializer
      +00191  */
      +00192 #define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread))
      +00193 
      +00194 /**
      +00195  * Spawn a child protothread and wait until it exits.
      +00196  *
      +00197  * This macro spawns a child protothread and waits until it exits. The
      +00198  * macro can only be used within a protothread.
      +00199  *
      +00200  * \param pt A pointer to the protothread control structure.
      +00201  * \param child A pointer to the child protothread's control structure.
      +00202  * \param thread The child protothread with arguments
      +00203  *
      +00204  * \hideinitializer
      +00205  */
      +00206 #define PT_SPAWN(pt, child, thread)             \
      +00207   do {                                          \
      +00208     PT_INIT((child));                           \
      +00209     PT_WAIT_THREAD((pt), (thread));             \
      +00210   } while(0)
      +00211 
      +00212 /** @} */
      +00213 
      +00214 /**
      +00215  * \name Exiting and restarting
      +00216  * @{
      +00217  */
      +00218 
      +00219 /**
      +00220  * Restart the protothread.
      +00221  *
      +00222  * This macro will block and cause the running protothread to restart
      +00223  * its execution at the place of the PT_BEGIN() call.
      +00224  *
      +00225  * \param pt A pointer to the protothread control structure.
      +00226  *
      +00227  * \hideinitializer
      +00228  */
      +00229 #define PT_RESTART(pt)                          \
      +00230   do {                                          \
      +00231     PT_INIT(pt);                                \
      +00232     return PT_WAITING;                  \
      +00233   } while(0)
      +00234 
      +00235 /**
      +00236  * Exit the protothread.
      +00237  *
      +00238  * This macro causes the protothread to exit. If the protothread was
      +00239  * spawned by another protothread, the parent protothread will become
      +00240  * unblocked and can continue to run.
      +00241  *
      +00242  * \param pt A pointer to the protothread control structure.
      +00243  *
      +00244  * \hideinitializer
      +00245  */
      +00246 #define PT_EXIT(pt)                             \
      +00247   do {                                          \
      +00248     PT_INIT(pt);                                \
      +00249     return PT_EXITED;                   \
      +00250   } while(0)
      +00251 
      +00252 /** @} */
      +00253 
      +00254 /**
      +00255  * \name Calling a protothread
      +00256  * @{
      +00257  */
      +00258 
      +00259 /**
      +00260  * Schedule a protothread.
      +00261  *
      +00262  * This function shedules a protothread. The return value of the
      +00263  * function is non-zero if the protothread is running or zero if the
      +00264  * protothread has exited.
      +00265  *
      +00266  * \param f The call to the C function implementing the protothread to
      +00267  * be scheduled
      +00268  *
      +00269  * \hideinitializer
      +00270  */
      +00271 #define PT_SCHEDULE(f) ((f) < PT_EXITED)
      +00272 
      +00273 /** @} */
      +00274 
      +00275 /**
      +00276  * \name Yielding from a protothread
      +00277  * @{
      +00278  */
      +00279 
      +00280 /**
      +00281  * Yield from the current protothread.
      +00282  *
      +00283  * This function will yield the protothread, thereby allowing other
      +00284  * processing to take place in the system.
      +00285  *
      +00286  * \param pt A pointer to the protothread control structure.
      +00287  *
      +00288  * \hideinitializer
      +00289  */
      +00290 #define PT_YIELD(pt)                            \
      +00291   do {                                          \
      +00292     PT_YIELD_FLAG = 0;                          \
      +00293     LC_SET((pt)->lc);                           \
      +00294     if(PT_YIELD_FLAG == 0) {                    \
      +00295       return PT_YIELDED;                        \
      +00296     }                                           \
      +00297   } while(0)
      +00298 
      +00299 /**
      +00300  * \brief      Yield from the protothread until a condition occurs.
      +00301  * \param pt   A pointer to the protothread control structure.
      +00302  * \param cond The condition.
      +00303  *
      +00304  *             This function will yield the protothread, until the
      +00305  *             specified condition evaluates to true.
      +00306  *
      +00307  *
      +00308  * \hideinitializer
      +00309  */
      +00310 #define PT_YIELD_UNTIL(pt, cond)                \
      +00311   do {                                          \
      +00312     PT_YIELD_FLAG = 0;                          \
      +00313     LC_SET((pt)->lc);                           \
      +00314     if((PT_YIELD_FLAG == 0) || !(cond)) {       \
      +00315       return PT_YIELDED;                        \
      +00316     }                                           \
      +00317   } while(0)
      +00318 
      +00319 /** @} */
      +00320 
      +00321 #endif /* __PT_H__ */
      +00322 
      +00323 /** @} */
      +

      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/annotated.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/annotated.html new file mode 100644 index 0000000..461fec4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/annotated.html @@ -0,0 +1,29 @@ + + +The Protothreads Library 1.4: Data Structures + + + + + + +

      The Protothreads Library 1.4 Data Structures

      Here are the data structures with brief descriptions: + + +
      pt
      pt_sem
      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.css b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.css new file mode 100644 index 0000000..05615b2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.css @@ -0,0 +1,310 @@ +BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { + font-family: Geneva, Arial, Helvetica, sans-serif; +} +BODY,TD { + font-size: 90%; +} +H1 { + text-align: center; + font-size: 160%; +} +H2 { + font-size: 120%; +} +H3 { + font-size: 100%; +} +CAPTION { font-weight: bold } +DIV.qindex { + width: 100%; + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + padding: 2px; + line-height: 140%; +} +DIV.nav { + width: 100%; + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + padding: 2px; + line-height: 140%; +} +DIV.navtab { + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} +TD.navtab { + font-size: 70%; +} +A.qindex { + text-decoration: none; + font-weight: bold; + color: #1A419D; +} +A.qindex:visited { + text-decoration: none; + font-weight: bold; + color: #1A419D +} +A.qindex:hover { + text-decoration: none; + background-color: #ddddff; +} +A.qindexHL { + text-decoration: none; + font-weight: bold; + background-color: #6666cc; + color: #ffffff; + border: 1px double #9295C2; +} +A.qindexHL:hover { + text-decoration: none; + background-color: #6666cc; + color: #ffffff; +} +A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff } +A.el { text-decoration: none; font-weight: bold } +A.elRef { font-weight: bold } +A.code:link { text-decoration: none; font-weight: normal; color: #0000FF} +A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF} +A.codeRef:link { font-weight: normal; color: #0000FF} +A.codeRef:visited { font-weight: normal; color: #0000FF} +A:hover { text-decoration: none; background-color: #f2f2ff } +DL.el { margin-left: -1cm } +.fragment { + font-family: Fixed, monospace; + font-size: 95%; +} +PRE.fragment { + border: 1px solid #CCCCCC; + background-color: #f5f5f5; + margin-top: 4px; + margin-bottom: 4px; + margin-left: 2px; + margin-right: 8px; + padding-left: 6px; + padding-right: 6px; + padding-top: 4px; + padding-bottom: 4px; +} +DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } +TD.md { background-color: #F4F4FB; font-weight: bold; } +TD.mdPrefix { + background-color: #F4F4FB; + color: #606060; + font-size: 80%; +} +TD.mdname1 { background-color: #F4F4FB; font-weight: bold; color: #602020; } +TD.mdname { background-color: #F4F4FB; font-weight: bold; color: #602020; width: 600px; } +DIV.groupHeader { + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold; +} +DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% } +BODY { + background: white; + color: black; + margin-right: 20px; + margin-left: 20px; +} +TD.indexkey { + background-color: #e8eef2; + font-weight: bold; + padding-right : 10px; + padding-top : 2px; + padding-left : 10px; + padding-bottom : 2px; + margin-left : 0px; + margin-right : 0px; + margin-top : 2px; + margin-bottom : 2px; + border: 1px solid #CCCCCC; +} +TD.indexvalue { + background-color: #e8eef2; + font-style: italic; + padding-right : 10px; + padding-top : 2px; + padding-left : 10px; + padding-bottom : 2px; + margin-left : 0px; + margin-right : 0px; + margin-top : 2px; + margin-bottom : 2px; + border: 1px solid #CCCCCC; +} +TR.memlist { + background-color: #f0f0f0; +} +P.formulaDsp { text-align: center; } +IMG.formulaDsp { } +IMG.formulaInl { vertical-align: middle; } +SPAN.keyword { color: #008000 } +SPAN.keywordtype { color: #604020 } +SPAN.keywordflow { color: #e08000 } +SPAN.comment { color: #800000 } +SPAN.preprocessor { color: #806020 } +SPAN.stringliteral { color: #002080 } +SPAN.charliteral { color: #008080 } +.mdTable { + border: 1px solid #868686; + background-color: #F4F4FB; +} +.mdRow { + padding: 8px 10px; +} +.mdescLeft { + padding: 0px 8px 4px 8px; + font-size: 80%; + font-style: italic; + background-color: #FAFAFA; + border-top: 1px none #E0E0E0; + border-right: 1px none #E0E0E0; + border-bottom: 1px none #E0E0E0; + border-left: 1px none #E0E0E0; + margin: 0px; +} +.mdescRight { + padding: 0px 8px 4px 8px; + font-size: 80%; + font-style: italic; + background-color: #FAFAFA; + border-top: 1px none #E0E0E0; + border-right: 1px none #E0E0E0; + border-bottom: 1px none #E0E0E0; + border-left: 1px none #E0E0E0; + margin: 0px; +} +.memItemLeft { + padding: 1px 0px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: solid; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 80%; +} +.memItemRight { + padding: 1px 8px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: solid; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 80%; +} +.memTemplItemLeft { + padding: 1px 0px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 80%; +} +.memTemplItemRight { + padding: 1px 8px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 80%; +} +.memTemplParams { + padding: 1px 0px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: solid; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + color: #606060; + background-color: #FAFAFA; + font-size: 80%; +} +.search { color: #003399; + font-weight: bold; +} +FORM.search { + margin-bottom: 0px; + margin-top: 0px; +} +INPUT.search { font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +TD.tiny { font-size: 75%; +} +a { + color: #1A41A8; +} +a:visited { + color: #2A3798; +} +.dirtab { padding: 4px; + border-collapse: collapse; + border: 1px solid #84b0c7; +} +TH.dirtab { background: #e8eef2; + font-weight: bold; +} +HR { height: 1px; + border: none; + border-top: 1px solid black; +} + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/doxygen.png new file mode 100644 index 0000000000000000000000000000000000000000..f0a274bbaffdd67f6d784c894d9cf28729db0e14 GIT binary patch literal 1281 zcmaJ>ZA?>F7(Vx-ms?uoS`b@hdRtpo6o^%HU>M$hfGrBvQnk$LE?p^P!kn&ikhyq! zX~V@&tPF5Qt@V?oTL96Bi%aRiwbe1)9DWQI#?)=HxS7QSw`J`5fAJ*eJbB;uNuKA& zdERDo*{Y<(If(#(B$Lr#;nB(8Y#ia=ZCeW?JfPLuQY`=@cW$k}Rivq|vbxGrRq1Tl9;+(gNt?}UtVKM2`T5t1jLzuL@0UIs`S#vlhl4)^ zLgSYrPj@$+`|j?eSbXTmiHGkWxV8V}BzNR?pl9k_s4pDu9vd5a_UzZEPk)}Ad{AV_ zzddrjrh4=Imr`E06;LY{)YYt?o}L~H@7C}F^WB!Ra=v`Q0bj{>5&$66CWF>mf6vjP z2N>RRY6ZYa=K`76>+|_)Xdwko+7wv}7cN|btOhWb(*{sta~6b?S8Omrxw}!4`NhGr zZVpNqpu1@BE`QGWNTpEpcJVW5izu~2B^GlM?1(OPg)zwW;QcP@Ltcclm>XbJL9C|j z=9!2?ua=uIlf0%AndzHsRC}IyTL$EhAee(fdKB`?27KeS^2M8M_7b~PiCFO&r5LC7 z7gl1*a<8;SjNaw#h=843_AV9iZbWQOAp5YOC^&_F*9K0> zB|6%IDb?aM#3viTxkLU4aXg&@+CkNTOnQ1iMP*^?b|^lJy$4C)Zk4isV!|RZ*XhXh zw8q3$=*0LeGC!XI_Wc?dkT~3+*Gu%%yIqP+Wr3H$=&ROMQU6q}Ag^P~>c5vAEO;a- z_dK-3PPeKar%)6$j~vI2#*-YH!1h6HYVtwCX5_wM`iF#UKz&&@9Oo5w3%XGYrX zW>dY~)SG-((Yim%`InwgTvyRC?e=Wh^8KCao!R6Eg&TpVWUY1sN~4G}V?nFnEGo-; zHZ_$eW9-GnC%^WS9b z@p;-$oH#MtC0v>Q$HX%4^JdFdO$0cbv-W)Q TtK}Eh@>>I#ipmV1>S*>q-hkC} literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/files.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/files.html new file mode 100644 index 0000000..bdb9c7f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/files.html @@ -0,0 +1,31 @@ + + +The Protothreads Library 1.4: File Index + + + + + + +

      The Protothreads Library 1.4 File List

      Here is a list of all documented files with brief descriptions: + + + + + +
      lc-addrlabels.h [code]Implementation of local continuations based on the "Labels as values" feature of gcc
      lc-switch.h [code]Implementation of local continuations based on switch() statment
      lc.h [code]Local continuations
      pt-sem.h [code]Couting semaphores implemented on protothreads
      pt.h [code]Protothreads implementation
      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2blank.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2blank.png new file mode 100644 index 0000000000000000000000000000000000000000..493c3c0b615ade5b22027bde773faf2c0e076d66 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr2qYM%T@!Q%(o7{me!&ckj8p!u14)&*MwA5S zr6z#mEsk^N1FBF3sc_EE%}vcKVF=AhO-xa6_jFST&P^;T z2~I3aEm8;rVk12R#UIz>f`J-DJY5_^DsClP9B62eH+WF*G=YJMp~A-KbWwke5Kx}M M)78&qol`;+0EL(^EC2ui literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2doc.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2doc.png new file mode 100644 index 0000000000000000000000000000000000000000..f72999f92172cca6edaa2538286b3e369bec9f49 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^5yjnX4egh%q=bp-`Pe zR7&bp17l3gfhmh7Fm(iZ2eAfco|q!h5)>qKG?UBh!IC9QGMbJAHf6IEiufk_g|d7~ qkWqJ4k(|I-Aeo-5U~n{Fnc?dN!3Uwu?t6hQVDNPHb6Mw<&;$TLIZ`G7 literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2folderclosed.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2folderclosed.png new file mode 100644 index 0000000000000000000000000000000000000000..d6d063440cbf13c4128dacd96661b6fce58abf26 GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^55uo^`BphW;jCHO69?}tw{JfcdnZ<*@N=4I z?xF5Qc|QYEmKAIZ;JRGVHe=bn*tx1_|J^^vyg*oVM#A1kZlFULJYD@<);T3K0RTgB BWg7qh literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2folderopen.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2folderopen.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe2c913cf493ee37ad8e3a5132382138d93ac92 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^5u(C zYP)Mg%H-DB+{J~>rPn_#pYTax?r*V6ubqGX{lvROQ{?n5_cbm+cQAOm`njxgN@xNA D92;js literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2lastnode.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2lastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..e7b9ba90cb0cf71c8ce662956bfee7d64cf60fa6 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6UZ?L@CkAK|NlRbNhD}!Xpp$P zU;Pg)ksC(lf|p%(p+w2Gk+!>EaktaVt4N i!r*{E4>QXNV>t$uAA#a^n)TVt_DW*G8-srQl%FeIsRSdYm zeDdtWec}u&7@8h5rqv#p7g*pRdwwmugmlS-+cHV~j}#7`Nwj9m+AU)JGGo`8z_}`K z?s#Xsy%Z;1_jl5Y+?Gum8WyK6`MBvup0SAOKJ)mWcHyteJ?WLL>>-)=?&<$H&t5oH Vd!azZ1yDdSc)I$ztaD0e0sw}(dc*(# literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2mlastnode.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2mlastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..09ceb6adb01054ce799ad20c0e818ab9272f2df2 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr#LU3Jc=+&fg$isFPOjJ*AaIJQGm()YSDb0rfjgNefXW#>UHx3vIVCg! E0ORy6RsaA1 literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2mnode.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2mnode.png new file mode 100644 index 0000000000000000000000000000000000000000..3254c05112199fbc80aad313611c58a5b388792d GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6Ub2s@Ck7}aNq!ti3c<^Gz9OH zn+a6GSQ6wH%;50sMjDVKR^l2_5}cn_Ql40p%8;I!W>k=uu3)5RqGz-?&YcgaLd(;| zF{I*Fa>4?=2W(CyOv{5p*uLi}G<-ambjQcb>&~4!CzK3KXWY6d$*{eWU47N}X+XCz OFnGH9xvXPg)ksC(lf|p%(p+w2Gk+y>EaktaVt4N l!r*{E4>Lv;t literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2plastnode.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2plastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..0b07e00913d8069ebbb51bd7fd6d70d8bba88f75 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr#LU3Jc=+&MJ literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2pnode.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2pnode.png new file mode 100644 index 0000000000000000000000000000000000000000..2001b797ba2b98a4127f1d3efca64aef08bf6d51 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6Ub2s@Ck7}aNq!ti3c<^Gz9OH zn+a6GSQ6wH%;50sMjDVKR^l2_5}cn_Ql40p%8;I!W>k=uu3)5RqGz-?&Ycga!obtT zF{I*Fa>4?=2W(Dkd1@Anj~<0|oqBMOmqox%*rjK-r)THv+0v0L%h-agt(X~hWwYzA SIxU|Ma*U^|pUXO@geCywmoZiV literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2vertline.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/ftv2vertline.png new file mode 100644 index 0000000000000000000000000000000000000000..b330f3a33c0085c183ff39fc56b1b274160c1da0 GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6UZ?L@CkAK|NlRbNhD}!Xpp$P zU;Pg)ksC(lf|p%(p+w2Gqgt>EaktaVt4N e!r*{^G#i7W2*a|cHZQDzQVgE1elF{r5}E+)J2fZ( literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions.html new file mode 100644 index 0000000..fd14c80 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions.html @@ -0,0 +1,37 @@ + + +The Protothreads Library 1.4: Data Fields + + + + + + +
      + +
      +Here is a list of all documented struct and union fields with links to the struct/union documentation for each field: +

      +

      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions_vars.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions_vars.html new file mode 100644 index 0000000..11f2c17 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/functions_vars.html @@ -0,0 +1,37 @@ + + +The Protothreads Library 1.4: Data Fields - Variables + + + + + + +
      + +
      +  +

      +

      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals.html new file mode 100644 index 0000000..4263758 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals.html @@ -0,0 +1,62 @@ + + +The Protothreads Library 1.4: Data Fields + + + + + + +
      + +
      +Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: +

      +

      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_defs.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_defs.html new file mode 100644 index 0000000..e97df36 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_defs.html @@ -0,0 +1,61 @@ + + +The Protothreads Library 1.4: Data Fields + + + + + + +
      + +
      +  +

      +

      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_type.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_type.html new file mode 100644 index 0000000..1cfd1df --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/globals_type.html @@ -0,0 +1,36 @@ + + +The Protothreads Library 1.4: Data Fields + + + + + + +
      + +
      +  +

      +

      +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/hierarchy.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/hierarchy.html new file mode 100644 index 0000000..1a654ba --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/hierarchy.html @@ -0,0 +1,29 @@ + + +The Protothreads Library 1.4: Hierarchical Index + + + + + + +

      The Protothreads Library 1.4 Class Hierarchy

      This inheritance list is sorted roughly, but not completely, alphabetically: +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhc b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhc new file mode 100644 index 0000000..7e0f7f4 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhc @@ -0,0 +1,43 @@ + + + + + +
        +
      • +
      • +
          +
        • +
        • +
        • +
        • +
        • +
        +
      • +
          +
        • +
        • +
        +
      • +
          +
        • +
        • +
        +
      • +
      • +
          +
        • +
            +
          • +
              +
            +
          • +
              +
            +
          +
        • +
            +
          +
        +
      • +
      diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhk b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhk new file mode 100644 index 0000000..837b6f0 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhk @@ -0,0 +1,56 @@ + + + + + +
        +
      • +
      • +
      • +
      • +
      • +
          +
        • +
        • +
        • +
        • +
        +
      • +
          +
        • +
        • +
        • +
        +
      • +
          +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        • +
        +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhp b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhp new file mode 100644 index 0000000..071ac3d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.hhp @@ -0,0 +1,44 @@ +[OPTIONS] +Compatibility=1.1 +Full-text search=Yes +Contents file=index.hhc +Default Window=main +Default topic=main.html +Index file=index.hhk +Language=0x409 English (United States) +Title=The Protothreads Library 1.4 + +[WINDOWS] +main="The Protothreads Library 1.4","index.hhc","index.hhk","main.html","main.html",,,,,0x23520,,0x387e,,,,,,,,0 + +[FILES] +main.html +files.html +a00018.html +a00019.html +a00020.html +a00021.html +a00022.html +a00009.html +a00010.html +a00011.html +a00012.html +a00013.html +annotated.html +hierarchy.html +functions.html +functions_vars.html +a00005.html +a00006.html +a00014.html +a00015.html +a00016.html +a00017.html +modules.html +globals.html +globals_type.html +globals_defs.html +tabs.css +tab_b.gif +tab_l.gif +tab_r.gif diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.html new file mode 100644 index 0000000..a0bcca8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/index.html @@ -0,0 +1,8 @@ + + +The Protothreads Library 1.4 + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/main.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/main.html new file mode 100644 index 0000000..d539dbc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/main.html @@ -0,0 +1,81 @@ + + +The Protothreads Library 1.4: The Protothreads Library + + + + + +

      The Protothreads Library

      +

      +

      Author:
      Adam Dunkels <adam@sics.se>
      +Protothreads are a type of lightweight stackless threads designed for severly memory constrained systems such as deeply embedded systems or sensor network nodes. Protothreads provides linear code execution for event-driven systems implemented in C. Protothreads can be used with or without an RTOS.

      +Protothreads are a extremely lightweight, stackless type of threads that provides a blocking context on top of an event-driven system, without the overhead of per-thread stacks. The purpose of protothreads is to implement sequential flow of control without complex state machines or full multi-threading. Protothreads provides conditional blocking inside C functions.

      +Main features:

      +

        +
      • No machine specific code - the protothreads library is pure C
      +

      +

        +
      • Does not use error-prone functions such as longjmp()
      +

      +

        +
      • Very small RAM overhead - only two bytes per protothread
      +

      +

        +
      • Can be used with or without an OS
      +

      +

        +
      • Provides blocking wait without full multi-threading or stack-switching
      +

      +Examples applications:

      +

        +
      • Memory constrained systems
      +

      +

        +
      • Event-driven protocol stacks
      +

      +

        +
      • Deeply embedded systems
      +

      +

        +
      • Sensor network nodes
      +

      +

      See also:
      Example programs

      +Protothreads API documentation

      +The protothreads library is released under a BSD-style license that allows for both non-commercial and commercial usage. The only requirement is that credit is given.

      +More information and new version of the code can be found at the Protothreads homepage:

      +http://www.sics.se/~adam/pt/

      +Authors

      +The protothreads library was written by Adam Dunkels <adam@sics.se> with support from Oliver Schmidt <ol.sc@web.de>.

      +Using protothreads

      +Using protothreads in a project is easy: simply copy the files pt.h, lc.h and lc-switch.h into the include files directory of the project, and #include "pt.h" in all files that should use protothreads.

      +Protothreads

      +Protothreads are a extremely lightweight, stackless threads that provides a blocking context on top of an event-driven system, without the overhead of per-thread stacks. The purpose of protothreads is to implement sequential flow of control without using complex state machines or full multi-threading. Protothreads provides conditional blocking inside a C function.

      +In memory constrained systems, such as deeply embedded systems, traditional multi-threading may have a too large memory overhead. In traditional multi-threading, each thread requires its own stack, that typically is over-provisioned. The stacks may use large parts of the available memory.

      +The main advantage of protothreads over ordinary threads is that protothreads are very lightweight: a protothread does not require its own stack. Rather, all protothreads run on the same stack and context switching is done by stack rewinding. This is advantageous in memory constrained systems, where a stack for a thread might use a large part of the available memory. A protothread only requires only two bytes of memory per protothread. Moreover, protothreads are implemented in pure C and do not require any machine-specific assembler code.

      +A protothread runs within a single C function and cannot span over other functions. A protothread may call normal C functions, but cannot block inside a called function. Blocking inside nested function calls is instead made by spawning a separate protothread for each potentially blocking function. The advantage of this approach is that blocking is explicit: the programmer knows exactly which functions that block that which functions the never blocks.

      +Protothreads are similar to asymmetric co-routines. The main difference is that co-routines uses a separate stack for each co-routine, whereas protothreads are stackless. The most similar mechanism to protothreads are Python generators. These are also stackless constructs, but have a different purpose. Protothreads provides blocking contexts inside a C function, whereas Python generators provide multiple exit points from a generator function.

      +Local variables

      +
      Note:
      Because protothreads do not save the stack context across a blocking call, local variables are not preserved when the protothread blocks. This means that local variables should be used with utmost care - if in doubt, do not use local variables inside a protothread!
      +

      +Scheduling

      +A protothread is driven by repeated calls to the function in which the protothread is running. Each time the function is called, the protothread will run until it blocks or exits. Thus the scheduling of protothreads is done by the application that uses protothreads.

      +Implementation

      +Protothreads are implemented using local continuations. A local continuation represents the current state of execution at a particular place in the program, but does not provide any call history or local variables. A local continuation can be set in a specific function to capture the state of the function. After a local continuation has been set can be resumed in order to restore the state of the function at the point where the local continuation was set.

      +Local continuations can be implemented in a variety of ways:

      +

        +
      1. by using machine specific assembler code,
      2. by using standard C constructs, or
      3. by using compiler extensions.
      +

      +The first way works by saving and restoring the processor state, except for stack pointers, and requires between 16 and 32 bytes of memory per protothread. The exact amount of memory required depends on the architecture.

      +The standard C implementation requires only two bytes of state per protothread and utilizes the C switch() statement in a non-obvious way that is similar to Duff's device. This implementation does, however, impose a slight restriction to the code that uses protothreads: a protothread cannot perform a blocking wait (PT_WAIT_UNTIL() or PT_YIELD()) inside a switch() statement.

      +Certain compilers has C extensions that can be used to implement protothreads. GCC supports label pointers that can be used for this purpose. With this implementation, protothreads require 4 bytes of RAM per protothread.


      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/modules.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/modules.html new file mode 100644 index 0000000..dcc1841 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/modules.html @@ -0,0 +1,27 @@ + + +The Protothreads Library 1.4: Module Index + + + + + +

      The Protothreads Library 1.4 Modules

      Here is a list of all modules: +
      Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by  + +doxygen 1.4.6
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_b.gif b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_b.gif new file mode 100644 index 0000000000000000000000000000000000000000..0d623483ffdf5f9f96900108042a7ab0643fe2a3 GIT binary patch literal 35 ncmZ?wbhEHbWMp7uXkcJy*>IeJfk6j|fqX^=1|}vKMh0sDa2W*H literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_l.gif b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_l.gif new file mode 100644 index 0000000000000000000000000000000000000000..9b1e6337c9299a700401a2a78a2c6ffced475216 GIT binary patch literal 706 zcmZ?wbhEHbZT`}F1e&(Gg}Y(8=I;HA5#Z$3JI=gGB)FQ#odI(O&E^@q;x zK6mr*m3xOS-#u~t!I@i+u0DKm^U160k6t`|^WpV}&n+8{U%dD9&a>B#U%!9-@yol< zU%&tQ{rk_K|NsC0`}dE5ET99@1@a36+kb~?0UJ*yc&I3X_m z!ND^5$O7$#8OFRuDhG}!?8z?cdZK&!`PWjdR;Aj^wZ` zeK{IEYHBJ)6K8VIp1`BVt++swf6j+=L{p1*nO(VhE`pFexG@5$|>uaCcd z`0m=9m+yak{QmXN#Sc$^{$X9h9&q2jiKAI|&T)a;PPx2K9p`YIdw8HtR5k2Q$2-O2 z*;3y{MQ-RnJTgJfI&R5|O)AHxDf_00XbPvDZPy4t=hHd)nfLPvms&O`Ok(sD()5v$ z5U@&h;a=#xbxVbo2~X&Xj0Ie(f{v>vERH+qC+nTG=B8Nca=wU-O$?1&vUgV~9=!H; zx>3p9Yn%*<>t~sk+&0xfyS8RsPfYBd<~wWK%j-LmpU>O7yX^h#UCp1x-p#i7@bE;py8XI6 zmY<)m>~)W~yIWcMVoiPg{duuf<*)9qZ9l$m*Ph&W&$jlv*Vpa+{pH@n=IQ$L?0$ax ec60Ul|8o2P|NVbd{6P)#weSbE3}s?04AuZvx_~SI literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_r.gif b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tab_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..ce9dd9f533cb5486d6941844f442b59d4a9e9175 GIT binary patch literal 2585 zcmbV}`9Bkk1ILFF--w5zJc=ZZT(zjE=;2|_S)Qm~rCWz1Pc)KPl;jv%A#&v2*x}yc zmf2~Jm~&=xjJY?PqwIN}f8qQ2{r$uH{c*nJbmr{cR5??*egHrs-B=MzCF`3%e{FAW z{oL5xTHn~5TM{jaB;@|_Ue5F&Zb@p(kMyG{*;gWDg zyeL|eZf7Qd8=#bXzSiR{yzRgLSj-fJS8>lBjVHN z^o-0eS=nE6a`W;LChBs=`+QAJP~{b93>H^eRb5kCSC1zUNezun%`L5M?RDzv#%jk7 zYVRX=vATPD`+oEfum^{RM@GjuP?-r=yh0!p;Vx^T9G7~`7%5ydH%70=jyJ;;`d;hv92x3R=z{xp+Lg2!*@OK*K15-t&okoPtSED)h&$RLxdbA zseWm^C3d%-yRNi-ryk^!ek+C`n&~cd$#ZWct_cUL{l~i+Nzx^5d!n94(>bW-iL~Rl z&8r)?q|1DIo=0=judQ{FaGcfLERz8gfn3-Qt<2lksh{mzpT}DXxUuR^z=^key&q4! z+wWI45vL0k$R^(F#{qfqhUsN@WA+w-V?LPH33!Q?WFSB3)WBojE@hK41Nb?KfS+Qo zXgrzfsP$wr4Qzy*{OD>uJBjdgGM@VMml5)2f~_}lD*YyOb}Hjeobhz#4c`w(l^>KK zr?Ud;W~Z}*w;%hZ|2^p^+f06gJDJQD zeIhGADbDmm&6arh(q>EZ<7mjzg7l|z$hRL8=1>)Nv=S7CY$B}iYJ&*T_-T_OG*L1q ztZ3Lana33?y3AKnyq^YCF|4x%Rb5WU&2qcl{TFKey%QJeMxn^SdT!hZ5+0i1zeusiYVp-phBl7b5+Px-X&LhByq z0F&<;K0l2+v>qiHlXb#$jXMv$uK-dEGE9L~qtdU(XeRXmvu*K2Q&6!fD**JxYP4b4BR7FdJ$Qx9G9`J%-_X!a#LGpp3g9)VWytGCa;7`S1_e8F~!R+aSJ zOF17p2`H?2kPs8Q`_;U}+D%3p zs2-0BTqFwpUoBk`?P;iPQ(IbEA|JmMx!P&YYG|R@S=5Mnw;-?A6rEEVyV%d7{iU4a zNk`i!%F(Ykpm`}#oH;BjY->@b8vQedv;pza2FL&*6ufjd+*3Ute&>kes~TU?^KkojsTh(o~(3tk1Y6>4(yn( z#U*ID9@eg-beKo1B;HXe+}{Z%n@7m0+yxivuqk9~;!1LGQlah)xYK4>wgL}l6dsaN zIxlRlq`*`j9PG4*0hD6YV_b_2w5b#)o7J?`q#{GjvvKlD`T*dWcZx<-s(ZvLB44E# z=!|sw!?)@%y$oRNL#25WS3lzdii}TuQ3?CLnvQ1_n};2sT_;Y;#d3=+-(O% zMN$>O!3;ke(UuLR%h_&)N zs^!-@A>QR}4yB1bPp`9S19ikTbZ~O{&FF-yHK{En;mmShDUIEw03`j(DBIsM}Rjki2J#SQa3gFZTKBPDeIiLt9Z z%bL3(B@Qw%(B`wSMS~dPh$=R`(}lBoFXKy(s|*{#ru$wjsBc_O#zxNk9w+UUHmx(U zmJ8+M+ndtnZ<7|VU9Mbt61zpo9T&3%Wx&XII=#QJxjR`CZf22ac3d51Z?GD%LEe_&*t46Qf;4`bZ7p2K(Ab5>GfT^}4! zBT&HZD`^PEgWoI&{~o-ID0F?O`75sm(87x%A{(}Ch1)QlzdJ)1B-eqe5a(weg0`4lQIf1evjvbBY50DVbzO7CLf|vP z2#0(U-|jZ`H{y5N^o7%iK6H>_HEGN->U6^!)1{XpJV!!4(Ig7wzZQ*9WYF4X1rG0x z=1uA@i`rIAciubDC{;~b(|&|A@xkjRP5aRcvRU9tvIm}jDB6J eQ0-6-y)mpwdT=ayS0tBxKDA*~;EWmo literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tabs.css b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tabs.css new file mode 100644 index 0000000..a61552a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tabs.css @@ -0,0 +1,102 @@ +/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ + +DIV.tabs +{ + float : left; + width : 100%; + background : url("tab_b.gif") repeat-x bottom; + margin-bottom : 4px; +} + +DIV.tabs UL +{ + margin : 0px; + padding-left : 10px; + list-style : none; +} + +DIV.tabs LI, DIV.tabs FORM +{ + display : inline; + margin : 0px; + padding : 0px; +} + +DIV.tabs FORM +{ + float : right; +} + +DIV.tabs A +{ + float : left; + background : url("tab_r.gif") no-repeat right top; + border-bottom : 1px solid #84B0C7; + font-size : x-small; + font-weight : bold; + text-decoration : none; +} + +DIV.tabs A:hover +{ + background-position: 100% -150px; +} + +DIV.tabs A:link, DIV.tabs A:visited, +DIV.tabs A:active, DIV.tabs A:hover +{ + color: #1A419D; +} + +DIV.tabs SPAN +{ + float : left; + display : block; + background : url("tab_l.gif") no-repeat left top; + padding : 5px 9px; + white-space : nowrap; +} + +DIV.tabs INPUT +{ + float : right; + display : inline; + font-size : 1em; +} + +DIV.tabs TD +{ + font-size : x-small; + font-weight : bold; + text-decoration : none; +} + + + +/* Commented Backslash Hack hides rule from IE5-Mac \*/ +DIV.tabs SPAN {float : none;} +/* End IE5-Mac hack */ + +DIV.tabs A:hover SPAN +{ + background-position: 0% -150px; +} + +DIV.tabs LI#current A +{ + background-position: 100% -150px; + border-width : 0px; +} + +DIV.tabs LI#current SPAN +{ + background-position: 0% -150px; + padding-bottom : 6px; +} + +DIV.nav +{ + background : none; + border : none; + border-bottom : 1px solid #84B0C7; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tree.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tree.html new file mode 100644 index 0000000..be8ac5d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/html/tree.html @@ -0,0 +1,108 @@ + + + + + + + TreeView + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-doc.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-doc.txt new file mode 100644 index 0000000..2d6742e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-doc.txt @@ -0,0 +1,58 @@ +/** +\defgroup pt Protothreads +@{ +Protothreads are implemented in a single header file, pt.h, which +includes the local continuations header file, lc.h. This file in turn +includes the actual implementation of local continuations, which +typically also is contained in a single header file. + +*/ + +/** @} */ + +/** +\defgroup examples Examples +@{ + +\section example-small A small example + +This first example shows a very simple program: two protothreads +waiting for each other to toggle two flags. The code illustrates how +to write protothreads code, how to initialize protothreads, and how to +schedule them. + +\include example-small.c + + +\section example-code-lock A code-lock +This example shows how to implement a simple code lock - the kind of +device that is placed next to doors and that you have to push a four +digit number into in order to unlock the door. + +The code lock waits for key presses from a numeric keyboard and if the +correct code is entered, the lock is unlocked. There is a maximum time +of one second between each key press, and after the correct code has +been entered, no more keys must be pressed for 0.5 seconds before the +lock is opened. + +\include example-codelock.c + +\section example-buffer The bounded buffer with protothread semaphores + +The following example shows how to implement the bounded buffer +problem using the protothreads semaphore library. The example uses +three protothreads: one producer() protothread that produces items, +one consumer() protothread that consumes items, and one +driver_thread() that schedules the producer and consumer protothreads. + +Note that there is no need for a mutex to guard the add_to_buffer() +and get_from_buffer() functions because of the implicit locking +semantics of protothreads - a protothread will never be preempted and +will never block except in an explicit PT_WAIT statement. + +\include example-buffer.c + +*/ + + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-mainpage.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-mainpage.txt new file mode 100644 index 0000000..60eb016 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-mainpage.txt @@ -0,0 +1,156 @@ +/** + +\mainpage The Protothreads Library + +\author Adam Dunkels + +Protothreads are a type of lightweight stackless threads designed for +severly memory constrained systems such as deeply embedded systems or +sensor network nodes. Protothreads provides linear code execution for +event-driven systems implemented in C. Protothreads can be used with +or without an RTOS. + +Protothreads are a extremely lightweight, stackless type of threads +that provides a blocking context on top of an event-driven system, +without the overhead of per-thread stacks. The purpose of protothreads +is to implement sequential flow of control without complex state +machines or full multi-threading. Protothreads provides conditional +blocking inside C functions. + +Main features: + + - No machine specific code - the protothreads library is pure C + + - Does not use error-prone functions such as longjmp() + + - Very small RAM overhead - only two bytes per protothread + + - Can be used with or without an OS + + - Provides blocking wait without full multi-threading or + stack-switching + +Examples applications: + + - Memory constrained systems + + - Event-driven protocol stacks + + - Deeply embedded systems + + - Sensor network nodes + + +\sa \ref examples "Example programs" +\sa \ref pt "Protothreads API documentation" + +The protothreads library is released under a BSD-style license that +allows for both non-commercial and commercial usage. The only +requirement is that credit is given. + +More information and new version of the code can be found at the +Protothreads homepage: + + http://www.sics.se/~adam/pt/ + +\section authors Authors + +The protothreads library was written by Adam Dunkels +with support from Oliver Schmidt . + +\section using Using protothreads + +Using protothreads in a project is easy: simply copy the files pt.h, +lc.h and lc-switch.h into the include files directory of the project, +and \#include "pt.h" in all files that should use protothreads. + +\section pt-desc Protothreads + +Protothreads are a extremely lightweight, stackless threads that +provides a blocking context on top of an event-driven system, without +the overhead of per-thread stacks. The purpose of protothreads is to +implement sequential flow of control without using complex state +machines or full multi-threading. Protothreads provides conditional +blocking inside a C function. + +In memory constrained systems, such as deeply embedded systems, +traditional multi-threading may have a too large memory overhead. In +traditional multi-threading, each thread requires its own stack, that +typically is over-provisioned. The stacks may use large parts of the +available memory. + +The main advantage of protothreads over ordinary threads is that +protothreads are very lightweight: a protothread does not require its +own stack. Rather, all protothreads run on the same stack and context +switching is done by stack rewinding. This is advantageous in memory +constrained systems, where a stack for a thread might use a large part +of the available memory. A protothread only requires only two bytes of +memory per protothread. Moreover, protothreads are implemented in pure +C and do not require any machine-specific assembler code. + +A protothread runs within a single C function and cannot span over +other functions. A protothread may call normal C functions, but cannot +block inside a called function. Blocking inside nested function calls +is instead made by spawning a separate protothread for each +potentially blocking function. The advantage of this approach is that +blocking is explicit: the programmer knows exactly which functions +that block that which functions the never blocks. + +Protothreads are similar to asymmetric co-routines. The main +difference is that co-routines uses a separate stack for each +co-routine, whereas protothreads are stackless. The most similar +mechanism to protothreads are Python generators. These are also +stackless constructs, but have a different purpose. Protothreads +provides blocking contexts inside a C function, whereas Python +generators provide multiple exit points from a generator function. + +\section pt-autovars Local variables + +\note +Because protothreads do not save the stack context across a blocking +call, local variables are not preserved when the protothread +blocks. This means that local variables should be used with utmost +care - if in doubt, do not use local variables inside a protothread! + +\section pt-scheduling Scheduling + +A protothread is driven by repeated calls to the function in which the +protothread is running. Each time the function is called, the +protothread will run until it blocks or exits. Thus the scheduling of +protothreads is done by the application that uses protothreads. + +\section pt-impl Implementation + +Protothreads are implemented using local continuations. A local +continuation represents the current state of execution at a particular +place in the program, but does not provide any call history or local +variables. A local continuation can be set in a specific function to +capture the state of the function. After a local continuation has been +set can be resumed in order to restore the state of the function at +the point where the local continuation was set. + + +Local continuations can be implemented in a variety of ways: + + -# by using machine specific assembler code, + -# by using standard C constructs, or + -# by using compiler extensions. + +The first way works by saving and restoring the processor state, +except for stack pointers, and requires between 16 and 32 bytes of +memory per protothread. The exact amount of memory required depends on +the architecture. + +The standard C implementation requires only two bytes of state per +protothread and utilizes the C switch() statement in a non-obvious way +that is similar to Duff's device. This implementation does, however, +impose a slight restriction to the code that uses protothreads: a +protothread cannot perform a blocking wait (PT_WAIT_UNTIL() or +PT_YIELD()) inside a switch() statement. + +Certain compilers has C extensions that can be used to implement +protothreads. GCC supports label pointers that can be used for this +purpose. With this implementation, protothreads require 4 bytes of RAM +per protothread. + +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-refman.pdf b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/doc/pt-refman.pdf new file mode 100644 index 0000000000000000000000000000000000000000..2ee4db038a3e8dbb9bccf24199bd977d3a2c9ec1 GIT binary patch literal 226750 zcmb@u2RxVG`#&zSXUHBeo9N}WhrP=#AtQV5P4yJ+egZ{=M@?RDae`Ha?<|j|W zeisXK8MGfX(mj5hj z_I>()*!w@CMjyWCMhy^1Si!~}WN=`tA-?uHNKA}GSjEE8%H0|SM`J)=zDR)U?cFV0 zfp+#L?iO+uW=`f7B)~{@a|Z^b1IhVe4~-7BCMmK9Zv;1n*i0AvmoJ?-6fA|C!u*r!|K!hw&ag{yU?z$PiErYWdYQJ4HD1Z6dMbFUar&n(h#S2+SYx9#CpRB%g z__ZtubFEI5DT!rgNZPmcd4E)McFYo&i)6Rwj+5BO^LH0BtZl^jk3P79Dshh=&QhOw zn=j~71~zOByS3mTSjO6D_Uxt}FL#Ks%Ajle?4(F~|0yd%zDaM$)Z!=O-1HY>#fhwo zTBp(8<&HjY+vUB|6YhF>YLD89bc|Gg?722L=={twaQD;bm=l3kVFWN$e(i&=ljeR8 z1GDFTM{0UITY!X5nOIqn2+KM-x&uSP4Yc3Y8YIFR7H&=+u4Wd%Z}z4Q;5Vuk<~AlW zPUk`Td%r+pkzg1ai2`8|P%s9A#TbwPw{ivU0YZLhARz(zX7%gPI$%{t-P9JC)k%cU zc$m8H<4|yNbpRp>_X=914bf{Q^OL`SEub08c6N#RtD^4nx4c z{~n3?=QGgkyF>Q|5%9t?J7eJv(g!*~P5}h`UH-iLi8H{QWU=oh4Fm|eH^pcG;|Lf@ z-v%9WZ>j+L;x_{>)n89H7T$HqZ&1KJB;{qI+0a?*q0eO9D40L){|LJpF`sdA)13Mo#CD}gvW!tUqew>d}Ry(_x zbWOp*EyfCLBeugbn6eu)T~)V{&{|&PH~rybXt;KxFuBWUu9aIQrserYzI$aO@qVH!;|PYh2Wi0I6< zct~!%|BbTnc>8yu_D{8x$^^8`K5q<;VjPava;L z>e1Jq@k&Q+w@Fg@`l>c^)>geeb>32VfMsQ+V;g54$s}W2>qN% z&#HzJft&Zj^#=N%oK_`Vx`F4njb}qw!spz(b9QlaJ!o@v%(-H4!JB3?bW8Z=5tBE? zgnd=!N$r7`>@d8oY7pwV5rr(l&v^Fst=f!f6#Dj@&c0%;W5ToZP|s19HJ1xxyeV0b{q_6$#J5X$sa+d2)N$F zo+FqUw9NpcE!U}5WQxHINvA=v~> z$*ju)pZR=sf=`m~CYxCk;?A>K&X_g_xQgMpH%FhVc zE6TiUQZvrH8V`z^vY-I-%`Oq8UuTR{s54;Uv^Qg--X$tEtxG*8wdwlY*b&V4goJo= z#qH4LTcq}B6xmuAFm9Gv7uXv7S*`D!~E*~l?hH&SdZJji!mQgo% zBqw_6AO5UqspCP(`w%-#8SjTuOB-1Y9}U&o24Jo9-Qq?FmO;YC>+){iXnTV^$g7WX z%0*t1PDUNO>=W_xo|Fvam6V-~Y&i@1(Q&D&j1L6QARfK;7*y=86_apLIe817@X0=- zacNM1om`c1sw0=39NI$s*}AGQqhHBUd+t!`3reoMmY9q)HC9Bi;~dp*&y<{$U5%6% z#N@hEU&l~5W}qCv`zkD7(|CfTt(Y+ns~&R4>*nq`lat`8dni7+HMojydUxR@IJxprgDJ~VACVX_s_Q{Gil$QfJ@{8^ zC)K>D=x_F&TV9O36F9w#OT%Hl;&YSI zssxsAa@NXteYj-2(O$;d^qgaIvgjN!9nuXXS1C@Z+PokGHrVPVpcq}Ggy9ay8h(^L zrd3LF-DQOXeO)f#lyoOD@$Wj<+vNM5b0|txCx8B*_nLQQPP>kO_0~$n6G!!w-x>3?#Z*Z$NBDy zGElH-=nfULP0QtzBh|4Da_z_Oecv&6_7@STh%?%Zm8M^^$QUm< zvwW{^atCpeTx7ZGzJSzjHS;W`P11`fj4TIRa&Y@`!eco~tB=McHGM9=ARL}!31Esk znvd{Jy8hnRBUI^*z1Onjy`yu>%x{f4Z+cx-+A(2Cq_v^mJtbnHw}2XU$jY#UvYe3Y zw6%pPlM{~eK~;oz`Z}qXUOa_5E*IYPhS)imG4u_t@jW+66Q8DM?I0d}_aV#t`J;|l zD}mIN*yJbg2Z`Cq`&gB4pXa$zkEn8ZoW)Mg-H|VWx6u*L&`j1Ee(LJ&qj}D+{3s>^ zlZC=@c*?dx(fT7Mx3wgd&#L+1D5uJno}wC~5OvWu+g3_}Puy>J4-*X(IqETgp*5vo ziM&U0BJ&CnEmnz4{7U9*vzSI}yiY@C=MLk%$|)HXGo>VLr0#%NSr6>+`iA}^I4nAK43j$y*8fO7HqXS65}uhbr2{AMOLSpjolt` z(}`N5Hg516qc--x6Gp__Nm?ok_XX)E;!`(aa`UmMtA389MH~foiPFpBv^SF_XLF8R z&Yz$24+)Jk3ce6}znU)IxCrT}sAAYJLwl9Jf|K|*E5DjEDSui3vaOv(Hrao63s3aU ze<(DW!|f6<|7_QEiZy3K3H`wR@Ur{n@-~5=L+%Mxv1W@5LCq0^&&Jm+!zrxKb5PU4 z@fW5p(y0qGV4lCzzA8mZ_einYaV)mZ)Tn9P$-N}6EW>A!>gl72A)8IcWrmlhu{U&O zyju+DgF}-|X&oq|D5Y>TPhqcQPcS@8>Y!nK$|h^%BzJ5u&y}Vx=%pqpjI2w3^+D!f zuZMqA;3@S{>VY27#s<sMW{x)2N53WPjlEn4TM)_s`k3yhWYrr8_*Ae< zg!C=0qqD4A(#>_BBHP9SZp&UI&usKfo_E!9U5F|xoWyJ0%FWmy7!5G3y-biU6<_0M zC9R?6S9kvOvUQN4cTYOkpFkfHoc4PuBeZDPwCP#A za+S`9eCm8xV@~th8^K9I|#VWG6cuq3{0pC zS2e2Z=Q{M#X2RwRU#Ck)xuo`iMxG`pwc@DYbesn(@Ly&2d;an!#T(FdRd>P_Ly0G= zH1UP;Ez;ecrWQ0!^647RmK;r*<;ISWN$+r6M>DY+ZbXIqAH&5$!1VsPSEBoSSyo9N zy|V(xd8R1tx_}Lq!)kBjZmvaLv{Sbxtnp23qxZLY^(3vNo-MWkk@qomqmZ(?(BsXK z3m1zuWExrs&1nw9OjeTfnAKUB$9W>#FNe9KPly@S*S}gYPd{?}ZWX^ec1sk}nWx(? zefcaq15?>X$Cg)T!30?Efo$CE52}fm9!%yWjyrL^Cj{NRF5xgO$0r0yvJ&JX3Y@pO z^xAaHz{q($aePHX@y6s;ws71@!i0W_f*P0gyo7UXDvG#Bb6^^UoBJ|i{)AId zxx8?an?#6hs?x^hh+o#L3ik7B0`qQbQs?F$5QqEAg))b6BI;jnTRUI92rOh;k7?T8 zVeh_#8?#t%QW*{UaEl{m+G%Ttaz2LQ=}*GLJ`?|yj*SEEzSviyA}}g0I3ZS31AQiQWydg zhQUElm1wh6DJ^)G_-~hnJp85fNMu8A}5{$;4q$m7U zdfC5B(E$pAfB(}Ds)Vqn#d$yoJb)3uPabg{K~aS- zzo)IaW_gT`FoaP3c5k0c53fi3I?xrQ`I;U#g>f`uS6XFD`AS2YJ68O9u6?} zk`z)SyGgSp`-UTVr_oDh$!G1nB-h$;+WNH9S`R}$BnWJIi0`Z%wOZ>Y7N6-FM5|J= zc^tlFUpMBbms%fKS$Dp&PA@>WKDid*OhoQCOE%9>_Y^$f@VWiL1Y65k{Zk2ljy3YC z6-xycHUiTCLgD62lP5Df$sJVzZI)-tB}W3x<$E8|UC4OJM&QB9Zz4kRnDsR=c#?lr zq;0=<4;8B(0ZI+PPxrJ ztXVd5dA%m4J)+KwEXZvxLY&=KOs_vIFeLBQytj??>jwUs1;vwOcUU9oGN2pFaR}i) zm+2;pQmkeE;_^0cH9LqjdD2%}I7|Y{lk)D<;m(-gksudqp607Tj2fbl<5wQ15ie9C zf;BWB*CJxej<~0~wsK|8%J-TL=JRr58|ELI1)oT6dicnfL`>E;;x@i@r$6{X;%U~l z+jnck9=|_b!DL1htv1n!+fSbV?9^ReToLF(IMSRScW?#o18q3)cqK02lO0!UEGM?FQhB9G5ct^jXBHRo5p;xNa7I(CUsBO)xR; z3Cg84$MY&f#?&)Z3TcOXuMC^m9?~PN8*gUiJHcTvk=h?^USh}JFGtJgYAFqhabY9VBErZVGE3d*%9D6osbo?hl1_p zbq*vhJE_lICJSw?S)V@To4>XN*{;UCA4nRP^F@}me)Lpq<7_*on51#*ek)62(;+>! z%|NEAxg9ks8CNfZg#Jpm-Sq)y{mPQ6#bifH9|b~A=bgl3mjrJs5sX|UrMZMZhN;j- z-Ww*tjjrvV|Y5V);w*JdX^xET`Ae|SifJ{MWs#!;d64U4+AjVt9Pp6j_THo z_InY35){lAiE=8>)(}sv!CT?I)8mk4Z{DwZI-j>KKC-2f=V)|xC!6`J07d$?I{tpU zb5mLd3N|A(K6!KIsLdZ(jWk>0y^V^@2|c^pZN5otRjm*+kL&j z*aSzv!~xOm?9qn!*E${aqwgkrLZ?X+^Ec0`F<+weo~fx=rw&#U_PZiUtz;0gtjZ)6 z7iT1COzlCVvL(VJJ)F(`(Nm?bHt)LnXdJY_&`RF##*F?p-Q-RE51BPxTIwwg*X^wn z$}<{*>L+C{kYF{b$h~%HlnU;+th5roy^~5MN<^T%JJ81=kQgJR4Lj8@pwV!Twnz|t z#NGvSJtC{;=G@F^_Jw%O-GK|oNk{B)DOmVg2e}?(cNNBzw^$7ckdUpa4WOHFrisdg zV7lkq8Dh(Ee6P`D#D%PRaL#WWdAYS}8J3Zyh~a+-jN4ng(7R`jVq=m+%i9)nuUlOC zU^ZUBcZ2rL&AM|bxLU^# zZg$WPp%n6_gMH@+RRb-X;7mN-Q4L^>ZK;;(iwkSYC&h~GHVruNv}JP#GG(c6U!fKn zNJTzQ_;~02p*IknP}rJWV!q7DSDq|FQux7FqnO1g`lw44~-iVgYB94Xb6J5%ehy@hS(H+Ziy8(06drv9@mnqXDLGK1Pp2t8xLK=5l4>5&6 zgY;13&Yf9@oL@SUcHi3>jMu;*XKC{{PUl)~w$dlsk}?+*C^*u2=ceR~8yzR7ywApP z&S&R^U8a)kxJj7!C-D*5m{SfGS2a%@Ps>vq>em$Ye3tHyI3H+XHbuh+(iD68genHw zQ)Z(80962hD&&q*hLY#jrX$|c=G@1RA0Bb$SX^>2DCr`o&(9Djsu;1P47nS;p5qo% zUv=3zP%A(#LiYOOE}o$pp3_4ujSzQsb^=)licAkBPG&}T$%LVDgd)^tQ)8S#?(<`i z2s)fC^oj^4+14$hm=8yA^^nBIoi7DGx!e-*>z!?xCC}6?ea#8)X?u+87%t;H&vNJ# z#rv?$g3r8HjhgYQCL;PiZcSh_pW*GQp2P;9eyFyZ9W#7aC2pQF*2g8XU(R&y3>B7Z zjFD7}gCi})>ZIJW+|M8V-+qt|G^hz2;tgF^+N$@X3;B#wZrc|0^LpxQesupu{L4hn z{;T?5i5%o!HugUxa)hNF9i4#GkUj|YC7*)Y&rE<&`^g9pYX7z%)E*)Y5bDdK1GSf9 z1b+IGQAB^a^59Bh|5pFbMD3da@+(fR<`%B|NhXMa@JV4sVOjk>yO8}P3Xs*&$6$fP z3LFhWVPRk>6bgbtv0yk9$XuZzFfbMifdW_llUGu)akL{5mfm0P{NF_d-`Sf10bpMXJpLD8 z2<+ap0Rv(m1BUJ~DI^ec7!35UfPE>&_zrA;X8YsW0s?}9_RMJjsc#?|jRpoI1gIH8 zz+hku;35zV2?3*E09QjG5MT%b1OGme3GdBg!qQ@5!g~QDEWKY5C45F$OG9z*AHRbM zP=nzlVq$LMAhnk!2fJAa0Br9&Qq)172+&gGm-+f1S_*{$-3I%KULFk9pIad?dlMbx zXEKXAnDYNcI|LSpS~T(}bNlb8Z~pwwW`S}WcOWc7CF= zFbpsU{UMdjVS3>>sjxa~#9?k^Zro>yuJvY!mbZi{URfYW?mC|i^UhElew`8_qw#!p zxibH5%IoRVAuTwT?EM}_qfFH+6X`FT$9NH$7yVi7d*&XGh&8QlqT?&QO6r;M9{5&O z?>s$wL#H{I1VyP%Ckwi8TEl^@%&1c1$;i!hF{ho4f%79~^-jY}83S`Fcrd3;%i63UC$*}DA9JWKBk0gV zK5pH~m8>8^_nWx9?vgVegZH>yZ*Jb!f9r5#;{tt(kdZYAHWev75!u~5U$-3OX_jY! zBUk!PjNSQyQkX_Wr-s_p)iS%KM5RNgjM{{I2o<^Rm{@N*=lIVQ8u8|n1{XMK52Yr@ zydr>1t&KcW^x#h(lpPVPZ0j*HpCZjMTeI-EKp;!c5YLHH*!8aP;O11Hx3d?8nD5Ar ztgF^Lt#Qv^+^l2|$dDe$Zar4KlP#R$1CCtfdL@{HHp?PaB*+tdV8S9GfNK=bF0mjT zR~L0Uj%&j?M~H1CTYQpxnC`*Qj76F|Ljgu~KzFPM!cpbLKE7P@>D&y(36j{SR|C@5 z$G3L&Py8*#%ifZx$cWv9Wo1s&`gob2CJ#07+k2u zbW=;N=XP#apd_6`EXnN)A&b%<2*H7>G!eko=QQU zbXHWSB8Qe0c%bklg2UVa9fVYmrBS#h!#i=h5pwy#yFM0Hjn)lk`?q#Gx$Tr0*LM<{ zZDo$%Bf-j9Pg+bWd`{(k0fkhbg?JPn!qF;Q-f7w$9ewLgZ4l>~)v4Ip%KKIl zMK92eltsg#AL{PCR;bSuowVd%mzmCW5ki`7yTm@EDiQXkrcA<6XkE7j zn}|*}LjBj*<_6iqG9Bhw--%0|J~QTdA_S( ziwlr7QVH93EDU{P$dW+Og;mK*JWI0M>2$7xZ09nTy&qTd6&Dc4DKnc7_ z%Dx3p_Kj#r@$ilaW|ipVJG6X~WGL-UM73g4f`3SwT-xKqgZKK;vy9X!6V2h9Zfd>K z#~7aZYhMx8#ecMM4JsyTLAISp^)51jg%YzI4jn%%nsU_t&B?5K=pjvZfbPDMAwK#BPjh2#i^)472d{l%_z6c^$?d#=m-j13Ia3t?iaC z*rbcVvUX0}T|E*v;}YZe<%#nOI&%`_}dp&-wmz0Yy*uBe3qJTwY8Aj4M zfDPnNMv5|Bfu)@;3kP?|xsKK=Y)zy_R_dBvz1Q#tKih`$4cRE}V_YlgVPlkTGO}ak9_G=KXjGNe4|jnS9Tn6#T`46^I7mHj z`>yLzx^@kq~dbQO=+ucn?bMz(97zhlRW<>bVrxeEP-qd}h$ukcQW6_;`j! z6Kd*7ypEwniz7#3!Hjq-h6CG&5_vDbkuWNxxLz8^yBHmGiB^Z@w7e&$!}wL+BQ1vX zvk6{@qi7NI17bpX8*#CVRsyW7PtfZe5urB=GVw`B=D}coDz{5hXM0)bpBs2R>BZG= zyjHG0D2)_Y+gOddpW;-|7+T$k7n2(69+@*r0>UfvEou3n#!FVf{m$in{43iE{ggg# z>NFAV2ja>aRiA$Q8bN9x)+c;DQ=ebVs?`D|GsHCv!;`k~6j+R#O=nj8oH&I@NP z5ci4h`Msqidr$bdC&Ng&Gfy$-dcXbnB_C38Ea^=(NlACT0G?53cfMZ9nBE@lVII z%IXfUC4N|aBF>`PlUBsioxMzYBEb35+xMKVMUavTQ+5UT5@W3{`qZ1r#JkGO!(Caf z?-NN_HC!8{&uZe&7>Jhoi!XUvQPns_Uz@Qhx65R0UGlNLePxG)#iE5~b^Y*#EH&@M zxhwESvZKePjyQ`!Pdx3=j#(rD^*OAfc3`sN&XC3~)uKYZK1M>pWr^&=LrmasZIPy) z28Dk2j}-3DX~1vZO5BMq$`bdgl{{Cid`f}xRgX*fJUMUiDe3!n-KZ*U;?7gqay!nO z=79;{5sK+?YID@hGLZ^uR$sQctb5XTF8;#1se3M!CvD8^!Qs>T8PiQ4TW-WjM%t%d zN?{xGdfRdP8t$O)v2%&m-m*dzo=p#>bw!v2qGKt^I9p(=iDO~G3#8LR|(+3 zjehD6YSYI@g-=UXH#`%NT;%_7a(Rq&NvktDjlQINmQ4+hGLbz?o6ULQY5mJ(Ho80A zsR`#_`LAu0>D?6UJ{hPQ`WcV+dGqd18Wpg-|GvWhrAD>C2LG2vh5ny4DxfTVPkBOr zp$nM(T4WIBizhtZ}j6YnK=}K+T%1ZKnX(w;tHULK>>CI zL+q(67zh}NM#8?+InX|z`;{(b0u(4ie^d)V4HS@L0l&de5HJ*u1&H~c=z>LHzq{*q?AO}e-C0Cf*vrcc z{FVF)2kcQ{VP|*Yf79UoNcfM4;efP(L1VE%T{%G5p)fR18xIh62z;+t8&LY7DD2J=o1m%FDtOZ2p6^ zus@#u80o*YTsRyGhGGG+8Ud8f!?D0%fg>H9MoBVXa_@L!B7OC zULes3FaicltUs0)U=Gg4KePrq5DDy70Gq2;`oe{Zs3MQuz;g z#C~e`|L`yr3rJmPK-U5wBM{J^A@9GszJ=TGrK|5n8Nv#{-7sHLB*5o?B(1$-jo->x zP{`hR`eycPNd^oK`0EdKtU_If%aavHKGoGX?rJh(?q=r=?s~qcH549F?roMo#VwtY zP-VwaHg&RZ(IL>^3L~pqX5lnU(9qK7jDh=MQt5%J-!1hbSgBH0^D|9`;;7wAI^u`6 zn=VbgCGT{~B{Onx`m}oXXaP(zI`sT~|9jM?Z%+i1X^*U)Q2+4ChwB2>n7{tidmkFP z#+?V(8#`)`1?G9wfAZdWf9%>FVe^zArgJ%0&aVZC+FCYo9#!t!8R@z#8LdT35a7?{ zmyq*(j!_~^xLinQ(Wz0Y`tpaFog0BMuGWoUona&H{#AmU^>TiamlSx@(HM=-EflwJ zC~^(kr4mcVNmp4%nGLH{KV4CS8xbWGP#@WHNtGMOcGA1$q<&v%;-n_1_%3Vp)AzXU zCmw2WL+)nXLTG+W0Iy~a&R=ThT<*S~i>y_9W1)VnEN46yi6MF@VMIt*@MKcnvNd#U zs-+kqH2m0lYTNYU6?%h_^3GIl@jizYyMD2is0T&k1?bFpL)D0ozGw3w5jK*-rS<3B z?sCrWRtijHBh)r)xbT!GuHD&u&`TamU2*i})tl4}dc8Y#?)*-*cYX9q2EBV}B3?{~ zD?F7-l0;Hj?ih&nspa#cq=sH-B(q*3D0kXvIZo?&dG;FfhdXTBm6_vZtZbdk=v*UT z8BEFT$WWiTmvFeEwoyW7a__Ul*CaCyZf{z1y$D4eTbHL@wTRk+`5P^`WBbl$d#-fu z7)MLb-i6#cUWb3_SQ@)*1}CLUYh>BoZgY{x;WKQ8)P`Qp;X%xxukNX zN=47kW1Ap{cz~j>+S53&Xf7pJN-{3|u_lrfjyNHqe6NCwX|$$2LvYe!c!^+!;r{zp zx2&AY>!S6$PjufaFX>j0?_3g(dlIQ|LWE^5|B3gwC$D6UMc|C3@pMQ!@f+iKaUn~} zohr#bpJHZNrlRwVg&#fZZXs^X28XssmIWLR%jA>lSqb1eil^I8rk#EPak5~!vF}O3 z(<*CfKibJtW;((gVYm@RcrbsdW`qy1sYra7daq%Ksq+}EFWs4>r*GG;c;y}o7g@gO zm$xRBsJ7l0844Fb79<&nMu>L5!duBp@F6(@e$f} z{|C`q7feE$Sv$K+`P<2=2GSx~Ukh~3q_U{c=*~R!N7UR(_Otz@aWdVPsAS3YuxMCG zF7oPv=M{4_(>sL~dOw>XeRXndY^JwC!!Lyh4ZodSZ{+18eq&xQzl7Q)@3&6$`2(i}B-=vPO|jw@I>*X!C1b9Mv}ZDS8oq2u0ci}rzjUtH zCLuFD5|d`EUyi&`xcr{2$ofreMxWDlDqIVg_A84pUa~NP1#+twn__?fn8d*c?%LijVk5t|6pd9J4PUVp`S8+^JhUFHRt#;t^S1*-bd` zdC1f3QKdt4v}a8dT-#-)&qQa}Ay4F?4!OAXn#vItA121h;;e*|rw$!qGbG~~yy8|H zGGO{l0KQH^rv*~8Kw+ zbYgnk+by^-TaaJtap$kC%$Nc0A3e1;i0U-i%BmpUj_-BmIu zzBY94(HYIrChoJF$C9-+D|IZwvw5(Kr6mFOc|C^@IX`gb+N3FuZzDbAO4ZkI+8T4) zhwgF$Wue!-kb%dPJvyhaG$$`b>ek%|x3U~p*?x9wI$3kX%06)0GW}X z$uad&d%BvdLzE#HOz9lLU9{+IOq?PKxp!(;Ay!=#*7fmZ^Q+|+)2Tq!&&lT$CXLv~ z$Lnjuq^Ss~lykL(O(3ohO`EC_oIWv7U!fEVOEWq0rL zqJR%u3XokHZ95-%^_l~2{Cxq%o2pW!FQ^qChjVkYhEw1Xr^MrrQ8G9!j0~jOu~n6v zS8D1_B+z+895N6l=eCW*k79qc?Byi+oW(MMlJ=iciGbc=+2FDd@=?Nk=*lx{RGz!Go zzTqhxsU=y9>(PJ1TUqX*m?shU#|KD~U8yK*p3J6Gx?;YulER+J-tcLOK+;59+m*ww zTz#9xLb0cD%ARuMJAHE8pBU8KibOBr{E#pc3|wfMc!RbgKH?{D$d~rsO$E zBH2!*(kF(&-7W_HUR8%*$h9oXEaWR%X&g7SB`!`LJ5zBA)VyeRbh9)*+36qFR){KkN;oDJAM-tuh-=AQuZIm-Jno2$@r z=EfB!>pMz(e)Ht*@UYinVj|zDkn}+cmhd*v{D+6Hw07>m8{`+^Ga{Y$zR3jLyl927miwE4D#{7cmXD2IT<0Anx= z8jOShIcz9UDFK54=QqHx!2V~TF#0>u{0)CY7+GPl76>>%BrMEO0EGnzH39+bRWN~> zV<9ke3&fAI$d{-5kI11I3>dlB3I9NcA>aU6h6BI(5741Vq?xG+3JL>&!_hF5IRs_~ zlpA0G0*SG-F#oaC;!DT;N9afhP$&-r3XJx7K2QqZD9Y5iSH!!OTheRe84vNJ%R;=LcnkU)pvM%rCM<8A1Pt~!uKP&{}RamD?T6u z5C~vXz(4q~K&=W4iujY5{TI9+g)yMOsaT ze~?0cgp3447Yr8htCl~=5Gy1Vi<3=PZ%<3#qQ@$|r1ncjFCF^bwImQ~>~TJ7KLYHhips@yBjk;EN7B^g~j?ox8WS^^9) z)r*`U^m}yCS~YYB|8~Ll72!IePxgyL^zRQF!7!)!HB$)f9>>K)9)>dI#&Ri@gnc|6 zUPAjaT`~mA$suNI!W-=rps-2lt&yg1tVAX$4>HSizc@-XV*9RaR?D*zhGC@8`Xg}@ zzBKg^6i%^VUaMM!K-sb3me`YN2?@T_py|52_(E3tohE}6$)aqX zx_j!5+O)!yj_r=i1S@0Kca(g(`2$bhx{(bd?qD|}uh1+sJaUq3hvfPk*_~+PQF--~ z4=*IYW6#fgA}uLo&i9m0Zs{HTQ-tTGz+-;LHd_`24%3>;%Xk=aP$_`~*3WTRo1jDk z6WexAhM(_7V$(S!T1~9I#AN*k>qI8j`it>Gl$*2fc?22NkQZkiE4wAE<#O?E=*{={ zTptMw6LN{QZ)?1h5J-KN$EZmj?O=D`U7M!$^$G19$ItY-uJaR$jPx&L6BfOuXP0I; zQbReCUydSQP=)tW+fCOlG2Oi4O}a*ZNJc73(@waRpc$dS5Mg?K)CEta+|EVZ^AkBl ze!+&PaXU~Zs#->~q*|$`@v$Iru(pC}PDoLkbV`m)>ap!>2z8iPZgqzuE#|+->6-OUXrToHno>2H`|IF zAay1xYaMsV%xEuYe5};UwR1Nmy$88^Rm||jh(nz0_|-&y)&+cGD+v}w!^RUNs!o6cv#I?NF}n)*v5 zHAK&g2#KOyX+9YoDX)vj_A_CB$@_e`*`b2s+%Ro(Zyw#y`^%jQ>|QP}XQi(^x4d*Z zh8A0^CECcxgd}7VrZBku*$zKfk0a-8>PNk#t474N{A%JolS~2xhddT3at1SIUXn&J zh_5W2G4x8fxw>#6^Y#OuXZq9qG%w|tqoMlqjrVy^TP&n!CI)0%@mq?_WRB_~dv2$+ zaZ8pv%0#+9d84*OXX!C{gzWi6o6OLnhD>9ozEmS3Edha@fUX`x^?XyGVBgNCx)X}A zvb8j%VhPu*42?Oc=ro=lcg8C(e8Hp#H`02#HNdb6>?{AC#SG@o-y-LgJ73z#=l;HZt}S84E97W{e#x^RQ&WQv3sJW6K53j zmnkKTc6acelL>$uhc7+2m+<-CI9rP4r}q0VQE_W%;umAw4-A>{ZVloljq6n@2^W>Q2l^aU_R3 zES0EA%^Jm(Nmsw5mX~;+zPo#A$TL)p#N}xVaVQPX{XA?vp55bR6KL!QSd!obLQieK2 z$Clv?w8)5*HPI5wkDSjaPsqr=HydO3gD`MwJc$lClOHH^)wzIbw01Fx;KH35-%}?V zulOY{#B(yG-b+tuU@x67x+5sKb@Y01o+l;rx~F?>mML-TmW5>Ns2Iv)?#-k@*;>F6 zvCau$|9HK~pLr6HV)_13`87}4fA9Q@CqZHRMW6o@Q3CY$eWC;u0)P4bC1DH&mjC-d z@1O7n5UBmr+4jDFB~tLO?SQnym+QW^|GJG5`sKK+y>wSPM%HGfaB4+y-zrDo&l9>I&5zsIwknO+%rR(1~0vZkhV`0d>BfEaTP2wO) z_;E`Dbl-XZ8Q@ov0OZPn0&#$-{sRz5Pl6G^Hh{kb2$bmm$YQ>o>i1s?$MFmWR6P9OLev4z0bK4UfCowEUjqEcb1>lKL<}03O`rg)#_Xl);d_-sNZ22V zHhZ3fLVf~vkkkGpuzx%U1H=zB8tBr0V(xE%{mXMd#oYc|@jniV@16r{8(_f50FHJ5 zWF;)H2ms_YV87VGN}>O|Yxh0(QAAHa>|%oe1ylzd_ZPta z<+z^|xc!CJf9%=sjsuoTK(ql$CQx(&0m_tMz$}NwVh`-h`c1_B+@S}>w!iGq?~Vfs zyr2l+jsHF3{sP#)9QV_ke}6^#A04+hV*uhmpiBcLau5`-5&_h3Kw|~O!#xjT(SNo% zcYmz@?79DG`rWV21UeEZ*~9D!gHQk%91TPXkpBRRm;UJW@as9`+hNuFE0H~2aG%ut ziPn2iQTtUx2ol&83;l%@3Dh2br%k_T3B2!sB`f9^isC^Z{-WWY;tB|^zc2~^QT_bk zDUpCK4TR*+CiltOw|M%6Ng(3`M#2HX@<$C5Sd;y~pAx7S1Oso$iRGOX3hdFTDbq*nTO9~ zq+Sm2Z<*EMI(~=cnUf%CJV=_D^;u#%FLm5o{00W~vBleRs-7)HI$CFSYs6IQI|JF> zvZ#2E9g12dKRw1`(8a7hdCfTfT58~B3IB#k9?a$r5m#;kgXAMgh9iY<&%<9|dl5Kr zi}IEvv*`QKxeG-@hfP=;8bseT>}j|Kt{!#ml)a=%@oiQyZ$$))`?<#lHlrrT&P|WB ze5mTAc)w-}9RAWP@1im|lhbugWohsQ?+Beu+;YYH#Zd=xgJn9p>LG_{Ki>kW2rK8y zWo=Ezj0$4jx9+f%%%5l~l~{ zV&ld#e}99BXeH9ZZ9?Ce#@V&(vdv>gRuQqp2{N1zZlCf_{4E;k61h}?fU-03{<(e1 zY$30XldK&zw?73nY>a!XQE`60%?S>FB9lMTIelyQX2Sz7|B|gF%Cym*h#lNQG0G|_ zvSUyd(K8T(Dt8>yNtN1+*kC29I9k7{!=7YYR=?^g?Fn8)Q=v&JbLFCb#Rr&!{j+JO747l z`89+T;o2>!Y-gc3`*?+O<&eSqUOPTM##5I-cL7IWd`3Mz zNt(&~KC)Yf6?3$NnuLUA-96?#E60;Mb(5!duCuN7_G-(Z6u0g@2+3DwU}MS&UAiWf zmRDAq?|Z-F9%TMgglS;dO!iW5ja(dQu%?W)Q+rL2R6DA~x}AVgecmf-+x#v9wW{o`H<&4MK@jU<3?V1SH*l(xU<4L?)Lo0@tPM4 zNhT^8f_%F>IP_F0CZy5NoG(64eg$!YH-VRhI|}T3Dgv%P=25bi(VN=6YQF+Si`Dke ziF_8RP3{usqm{j8$I5spI_k9Vz#N;Far#+K4jL%teDr0X?uwDCuTr=OmK0uBS|W~aPL}hI>Ry3r0X@akD{JGdYUgJI->2tA5c62pDiNN#`86#9~Hojku8=!U%2_g z^ybo{W4XJNU5&&Uu=iyYB&vg!>*4SOF79ymqpV>nb1@s)utD1lM`c)DhS56s-t{nzp*!{`f#IqU+@04m@J)NpTb+nkYI? zrA~n(G<;YG=1+J?Ic1xPRe>(da+gECvGQGS`=-H1S=Eb7WK*7DgEJe9PGXhM+6bpS z_bjz7CY~*}LXVD$&%|+*)pYTzZX=mE~Pbfyq6cP!H=a>E%=e;ZUn0GA8v>@$%o?iE1;^Qq+_no^r?w6F5 z=$Th=?I!o9UyC>)JK{$_`a+tf<;WY&vuX9`mg&ZCA7()YNMw6Ie-5QlG6tj*mS^Hx1irT2aFJl|jc2>0nauJbyt^E{5vaeO|9Z>602aI6ujD&774 zT)jtw_0EbHX?yyyHmLC1d~)Z=Z_*>@Cu9$gK*t{4x8k?_X!E|68iQT&$sx^Wp6K3O zC>L9_2?}RcpLCqfqq*|6rTwS!n=`y$$`!Ul+b+JF%V)NmzP;T$tuse?Hd?T#q=)a^ zXX+HZNyOt2_>qpz_apafK=4ab22ckBoQt0!@UJ2~{|W;CCej1vEFD47-(-5=x(r{x z{{~Heqf`Ok=j+cwy7}n$KrZ6zS9mB0pzR}q0{rVYi2NJf3KZIW`~6pl{U?a~$cCS9 z{*S{*Hh@9F@p&j$%CSmS6;{;6GXpdDV0!N~=x zqX0Ys6pBFD&Bg|&HUUx#JNFONrvDK>9)lN8rZ@tBQhy640bui+VF2v}x-0+>0IUWs zD7-=kD2}iL5t2WF+>d7LSBaLdtLC517&`zF;czD?#sNGku)x>=3kbpuU_}l92!QOx z9|zpWk?f!NHYW_Y*#JHa(j@@h1mGBec)pYR;1D~g_TU2Csz07FP~QfF8XCa3jEz9? z7AFvVG2%AhG%$idd5ldsIY7zDF_7h7@e#SfGv)%Nd4HP@!X=>m1ZMe!rXQcvlM(-Z zS%rViDH{lEK*R+B>>)0ol?AW@5PX7vCz(=qV-6#3Lt_pD!1sf4^1uw)IZQZ>Atolq z>@Y4Muk$NZdbD}{(`EYIatKJTKsW%K?%Vsr1&~NM0gLm`-yg6VfRToVJTQZZPWd*P&Tn!0Gfc^2C&jzNH%aD}=Y)|Z*hAvF^hY4#q=tQ8rfh)J_m%w#ur5HQ z1j!m6px4Cx$Js6Tl%BLE_hh`)pSK3EErN1l2uO{5Hyj*PfJzNk#R)C{&5ZtteEs7Y z1=%GoE>QLe0bF2E5(!Tn0z`<5$Y(UQroUtb~{rH@MWYN!{*O4##C&=fKPUQD( z7>>~WG7<`0Csr;Xj`k};2a*>5{hFLSY|QMezk@!1Vrc&6njCw*bpK}Lk5BG5BiVrgciv-wd z*|@%X_J39f`crA?cg88)yg#f1E!4CE5F!5Is$N>$9$j~$?cED~Hu43s)H6Qg!^Gwf%!z!h`#^ zyosv`3OA};HTRz#I<)zNQcT2)@fTjS1`dsuX+A=ZY_UE3@NQmj%@U)>^`0l*fXoZs zDGUj*o4ofbryf?ZR0raaOy1*rA3W!oR)W@)jTr**$7!y6B{9zW$Mcai5J5=xwSIN>3)`n0RkkA9|=##Lz&Tz9JPmKF;e_9y`{D<=0z= zQrnA_7h=sB5bKs#@l5)jM!Nol*DXMwKY?Z8$)dHXHNrK!5TBP2c5A=R5{Xxs%Ys^` z8fyG_aD-{rRG4tX?axOEX+ICaL1HgG%_3?)jsA%JbWsBlJ3)>_W#5wJVC5$Z$Jb2y zbo;NKsjODK_lqeNc$$*D{b=-Zx#bs2VzCz=mfyTuj>ULnq)JMuHU9SPEw!Y)3mm+4 zUgwH1!l_aysnVn{Ai5}-xsPhDxcT!=8I17ao|PN)#4OH7qMUG{T!>J}K_cU#t1icO zxm(|7?^e}!_i*~!OmOsL+$lN&bid9WTn%zY#K)J@5E*%S(6LiCQ*9hGQ5*JWL?SmT zuU>9GtA!EJ(1vR6EbPG{BiGU5g`0Z)bYo+X7By8@%t1=Ty=M-UvQfEEy`}5v7g;^& z{d^5aNs%`6FVL}xCW^8fNmL-tIe)2|w;gliPwF(XV_y~aY06QwtQo;L+obnbYdL?}CpCe}Q@0SV+~Vz=yoU%tR(qY}YGMatikBLO2*_64trjP(crkpD$Zf zZ079@cFw+4Fne&xuC#G6$5%v1M3gFeNHJoqAPuv4K+%t@IE{G+84EW4U_}$_z`oYm zk%)yIQ%MAN9vM4oI;0@@LpuXLrUG?sv+31^G0L$}J29eHi?{Bn_;Qvq|r+v@;rTIWC5S2ak!S39s3_>kM3b$L z7RzBBDsQ)K8S*^FT#WmCM+vW-Z}H7b{8D@?k&>oC@z;y|6Gjmdl^=^=Bl)=ScBJ7F zU(h3gA(VThj;}pFlOXrD`CvJgXf=WmRP^&P&A3-QIxIe#YI%Ey7SoO_VplPhk+V_TG|gj`wq_^(R06-Fy`W> z*V4f{s1tw63}Lg)!Q^R0COW%qsNfeNhxRfke2pH(LnVTeDP@MxC~StKSmE|_KH3hj z!lmWG3cn*=S9P|tgs0^?JprO$=dEUKT*dh6@fTrRs;lSoun3=#iaklf#>W$T&nRKd zX2Tbl-#oW-%7G9zU>VC594`_=Iy|$V<1V;Ju{CE-dYC_yu$<5s5-EhzNS}cBdPyiD z)-|U2ZOmJwTXy(kl#6_qPM=bGGadTOG7!F7Hdz_5=*c$K3?WK)>X1JjiE7UqCORYN zOChisqCcwJzwN(ym^-nR;%;@XXZ~Prob}b*EJmc7`*Q;Ow28~N(Qsw-?a-IRQI~uCgWbtQ0#H$8WAhI_JxpYC>o+l6 zo(b}QU>Z*1{8Gut6;l7Ck{K3wQ`+m^d2U%j^}aCN_bcUi1FTJREXnoY%-P#g-m6@_ zfVfJLvfby;!V_CJ{$8_hd5gI6mId9HL0#q#*mFW3zs%JySypgqkdfpxP-K%RJ;+%( z(>)Ep{n-caNAqT3d{1r~D%!+)?M!ZFU!V-_{M^9yAWgAg8L1_~2o=M=%5SpMj!M^p zq>qohsMBXvmY}|SJ=Y?Hwi~-m^XZOd@2$L2>EyT%o1&Zo>xDAO1;||Qovd734BZa> zye_}iM`aDdU-I0Swb3pwX1Sz-`(`9WIuj#%#o+~yLEGo-QML9@DkH+&9q#i2`=&-+ zXjWfv_pzcU6|GndnXFpX6<-Hajj`M$$!z3OOyK*lRBhz6ZxKv4;a0h~L>$4QC#bgP zhR}_XfrPhDS;MOsc^q;D4%gp)>sN>RSIG4{7xVAFt!yBG0yyUhAXhk-@My#lqzPA0 zhaB<3l)=}pm??lh;GY2Bf5luOKttv0_g^tn2!NiBzCWT6fzN&8bpnpsx1WC-_l?&H z0TKSu=Z~6wgU=tOh~Zzqeg0e7Gtk!l`njX5{?BE{Uv2#EK%Ow%_$!`=0>BKy0nkcN zUI}Vt0j3PJr$Ch|+aGcNjv&S(h=kjOi`9so72qUrkOUOwm>3#Ec?>`~E~gR4uMo-C zY5j+$LqM#_4X>&B+jI~}1I&--#HJsMl)gUae`wg>b9yAw14>uG+_D4L9}0qE2oLl` zco`3jhs%J~ki(eM$Ou&XaTs&Mz@Ovf2B4V%CqSTni9NqA%ztV);L*YnNa#1aLBI@T zsX*DqNe%zae8SiHKQ-$+KEerNC@4F4^}uTf&@u2IPB3h!!pnR~dKu`%7;h?Mv&_99LH&DPk84(-+cVMgF;4wBb;DQ*zSlPKb4NV{hJSHY= zT->l@tMn&^eoY!%U0~c#I+J zMqI{#{eNsV{EH120)R$#cz)+E!$Gks8(bLRq?R9_(IZFa->yBWVKV1w! zV3Zl;y&y+t7|_!Lxd*t@ax$j?28cTBfYQOr1=1vJT*h1wV@?>v*ciy{aRJ=;S3vr! zH~Ft89n>&$v4ZR@Xxa#OV?b>+5UXV8JlWxEVgLgNH#>~e2;>q@FqgJPh>g#D1&kHutN>F4IofM6OaNn zV&yd9HUNoWLmu{HZo|K!vVpJx6k&rT3aCc_Qx41pWe6bO43J;&ACP+f(~Rr!_wT2& z;1e!l;AnkSqy_s8;3t3>1um!x>JmVj9b|&Q+?*)+cfx!sSav_05^!+-C@lPg>;;?< z@VEE*yODs02NZUXrxM`3QvT~mPIy5Es9ZS)>w^-K|2~ofkWj!{Jg)o+6lwnZNOo{d zkaasQA^}{3|2`71mjG+-clUX$9Qv2J{m&zT9shNP;M5gP9^eE0n)m>V`hSdsJEB03 z=QksN^cQ~fJRu-W12RL$(=;Hv_CKx(4ivBuev=vk1>OJkKEWus_Q~(8{U1-|KaTv0 zV0_=V|L;>nfE@F~J$}TKb|*S?YTka+KpzGd(xcw-;=_MOpq!9Y^^9*rG z7Owdc?@%X3-A1fbCYAv-{$lsZ|mfuwApVT0)>*MoESK5bu z_Qe(TX9}GKF=!ffi_A)p=eP-{E4SK$D>fY*k!3q#{OGUTag#17NRV&0G%8*VcsVgj zx~b!4GnQZ2L0l=ba$qeX!iVf2mLG;zUSpr_H&9agszcXiU9xOAC2_&(6%k3;);1aD zlPB*(t1ZUD`RQ*w8^Xg^10ejnQET(Z_cRfFlE9QfJ=c}$^T4a4C z3ASbNz6)YjoEh?!=QEak^qJnKZvFJhx+tTyVBOtC%Kl3`zn!B^%8F?ON%YfQ*{=59K74}dIw~At8Pu-( zDBR(nER1pZSGTN@#!bv`*>xF>)n$k?SE4)R2k2o4;lRZBFQTo8rW-xVfI4vHQkp zT1OyF=&U4r*Kp}sJpuGqy6a8Mlh;&jd=E-u)oamQizXl2RwmBLmYFoOR+o(zSXs?c z8Cw^r1~l0-*6iEudrI7n4T^iv+-7l}_-1%$tstOK7<8jUmaZYLAVEUkhN3-a@~f7Gk=2&IUR!c-+_yyItWmzy6FyXIS>_fq(n>j+LX<`PoRjJZdGmxaG6DBznoK zWi^7HUaXUthbUdT^i9W*eNc+^!wK}&9sLE_|9VLMR7?#ja>1y7iR^!Cw+=9G_}>D- z%r}Ic^C$-Z!m_W`(r|L*(eJ-C;DdZ^)cTX~2jnM8*a@9#;G6SQYi4sDbR)jc>kbF>i<_?|LAFa_k2z~ zqrgyjv;^-M$;tyNNa6fJfDXWQEqDN_mFtgl8pq?Oqvi3B4TG1JgJ|if*(S$Pp*e`D zp&&H?imBnHfB!tLJ6f*)(5}B)p@7BB3N1f`U&PDIe`o|8PdXzxQyt3w8kNgU}v;CV=V8=hx>1&w7C80n&8vwl=@RDL_i`KN}7%4BxN00K$0uy1&3N zzn|;>)biu2-|+pt_hDzyY%U4FQ)@9{J|x%P+gbgjlw zJngn!%=*}`L#Q=^P}<*BHemyF;5&=sY8EI`0+WoTgGJOlIoRYQl-6+MxyeSDL;7i9 z{Bu&MAF+nvXUS-M7T48ti)%=WKr|oKS^nxLU@W z=D~H5nC179k~F2a(b`^Db*jb9@|6g!1Bd1}#~99?YNG$x=;M4&F)}dlj@1x% z>s8^0-Ss5Yg446aiTA1-o=2Y26KJ3&#k;il$+|Je^otbnaG;>YRp&HkgNso4n(JN} zR83y@pxk2Ntfvl3g9Qxa2FzxavDb>~wd?P?-a4GG4pfMprreiQF;mdu=;zOJ?9g7DwlDVXy?rofF(j3HqgTf2f}ry|DANXwCf=$`aF^7DBD8#un}cW) zxU?BjX#acrq9D(HaxA4h1w|&%M=Ak#JfoxS66K;1U`kjN%+J_|jDY z0a;Q3bt_zf-)%5Ydt@_6^jV2yws(byYvdJV0y-LL)*(n$c|sXlWXp=$tC0$l-CI7& zPpcibrR_r-W z#IGpJG8edV4wTrfpel5^Wa{oO^4n-RRj_kSn`ucR%(-jcH=dW+uZan3{+ce-_v z?&f7?o9V%4uj!1^Z}s!I_;NpFbTE{Yw==tLktoXJY3NGmiLH@B)0a%%jI0@mMS|i< zXNV~OzT@@H+`1vCpK=iCbh_2%iz#T}_2&(!{#%N*9WNohm>z);LCYzX&_1(Wb%d)p z1kFRPa$46d>8zf{qU&ckJVtaG=Dwe-fbQN_8MQ=iW7_L&G>kJ^t{^kP%D4aQ-T0+L zBd9A59&uQeCA1~G)Vx(i%p|fp+7r{f?;+(A%dFjKzTAhl(8sA(PFIsyMAIASebpEd zC#eT76_NADkUb3*3@G_5EqRO8nXp)|zMh*;P0|+KcwM|IG|821xMYk5iWWA=c4m1Y zBi@n0Jg1u1@x{Zr#q;(RQC0qXr^G^%*vITRqYI)$mCCEnXOvb1!^X;#w)}diwg^L} zrMGNkg3IdLk<73k+#Ni{I@2Kbev_Z9s8&<1%Fv^P#aUjc3n$Nek!eubb^84$?~k_{ zq{i;*xOE1~FTX5$N{rwxky1#zj6VG;ql@J7>V>FciYt>ijNAfAWnA4NtDB`1*oK(g znfT{IosElP%HeCqv#9)$V`dC-L%mm7$bmJB)zOOKbY3LbHJyw%Kiv4p-vM<`8YNBX z)3Jfve+-FVi9;*oQzaeU(|RhB7fohj)rHv%9boIYHl3e|?SyT%+Og>Gr_Pps_RRuo zl-rnEv!zBp83%NOQJk-i)-aP>C^^g}o-{#uxHK3>ud?AD$>-z=y*?X2ooeCta7mtIb6gdqCOxxBhd&?qRQLsP5K z=xx`v1r4gYyHA+DEVLToF8I*CyVr=>N3KjD^r$aUv9^0S{C#%>U4qAskCU&l5Gm#( z|H6r^x|n7P-9R$K>N-tn^vZ`@kJ@Q{&-EGWL#9i#WV=7pmB^e$O1@g__;AB#qGUby zfo#hTD=}N;_3(G0F5-E0p2B=91S1wb$PqWZ9Ista$t+Ii@LEo*)g7^QFY}({I&W*i zH)pEOpYc-H{r!RCBZ23yLuv2mV7lGNSDk3(a*B0lm%(Fq6kxxV?0Qfh`qCP4Nb<2K z<{<{}$0UN|@jqxF_qQkT`}qIpQ2jan2ib&w9shqLu)uxuqxk+CyBZ{tkG}tr^$a=s z?03K6grNW^{R7nq@ScO9O(GO1m4j>^h^Rr}LIcvkK#T8RgeX6;a!zU&(DDMMPjEsZ zs7?d*P#}j6>Lx%s`KX@)8#ntOhbYIRF@XG}>iO%yzd{fwybg-%cfrq3Nelz@64&JX*4eA>~ z?DL!6jBH1>!rxcsf4uO241SI_&F{m1AN>3s?*N|J-+|Dd1wTI#{k{i3@TR7J9Q;^? zCP?4{o|)$$OF1EQ5BuIE{%nM|c_- z9&s|6pN(Uapn3=@`1>%_5s=fy1Gh02tY)XxFfwCYt5zMq20!>KXf)h&6T9WF8u0W< z4Qy(i>Sqv&U65(Db=?BD95s}S1d8s)60=M!P2Pkmi9Vmwx)<6v zCgrWmLPJAmJW*TYiGb!=d*EegXkFTx(3(=1Y?3xH#fu|4!-mp?EY$Nr02h&zCP!hj z>--J^tpGhEHG5@^hP!jM2q|-lPNCqz!QSrDE|RhBU0%71SbnJxAfJU(1d`q^h}Fn43^%$Rie*lzf6~ z3l=&$Li>}E1OBdQmSEq7$L7qdYElzfH|!kwRm`CcX4V6xI|Ttoh)b5<54AlKShn zd{v>gG-eA$nIU7mhS#mx4VMre*`M{g&U}FXk<9iS%zL}GJ#0hw;_lSV>9kh?*_kdy zS+jIgr*2+e78mtRnhCY9GRaMo5^J8LtG5yuihj|OhRD~~C&uy=cA5ZLVb7oRyOU2Il0z1CYK41J=^{_6GUL(YtDzedGZ#IS+xM~s{kF0u4) zaRa6b=B6R~UgB3|$C*Y0x;auhrc>fW?=M*kTpdgqaLJ*G@D^noaCv4(V12VyZoR~| zgvkW|6Pflo*z^{qB)wi|e{Cq=sAEpFK>df0Q+&JF%UhKEqmC0gI=c0?4&>4vv;=9A zFh}uqf_l7dzE9Y%s4XbXIU^DgTg<6lUYiH?Va_PVcu`m}w=ArD`ch3~)Wy+ZUp`5^ zdGuRG#&ft{$AiZ2RnfbdL$Qd4}Jk0oH^i&Wi-|3t1 zcZTyc&SuE9Mr3`?+>N!uOX{-SX_}){S5K3BtZF@QN{@FI#^q@rkVGl% z(Ou*mx2KuZHP7p>S`sW@%iE=V{)(1RP~FhN~D$YpT=`QjthVjzJFA|Fsx4n$o4c`oMP zXaa%B0@|t|vjBP@!JTr@svNXA1AWARiV`rH2SERSYS=%}*Z8^){^^v$g$h84?NRG& z(9!~4xC%tSk6PJ-D2WyP=ub^Q{;dCvvJO~(@RD{=Vh^-{pnx6(o;6(T8>I5s;knj7 z7p6LH*H2Pja5wjx+QI*9xDKN1Ut)q^NB)N>26W~6F9ZK_>7gK~g8<>9W5EdMoc3SF zgJ1$)B?_`m$4A07#(oZCel+>7E5qp{aFv|jT=~C^hlernml942`!#?9O%MO%%Aoll z$ejN!dGwQ{)NdXWTu7P?6xbiT^07?a&$kS~2yj7=&;{&1p5F{-`>8bGHy36DDeI#~ zk;iWNNC5BqtN6Q-paO%N2V}jEkNh7i3v~1N4_j$8hg64LT%EA%S$ ziv%?9F#RzQFGp*Ym7AbYd0hN>`i%Mmg{u`!LKj(}pJ*YZv1rQGMp=-LNK8;+k+WRt zI5l@msPIyK8?uTX@eaGve#{A^xcSK}`Jtrfmo99U(VG58<-6HGWEHSiH6~owsbd*6Z zRSEE?ES0G_aaN2zy0mdw=B|53wo_W#gY$N-ms85pi#U2s*^wd}*)KKhh$HkmZD&le=d!gJpD{htPns!tg?aB( z1M=xB@9ZsnU8!-=mAZ}G3#9F6T6tJQtb`R)w(L5l=~348hVn-RH#|HV-y@=q;n#LC zQbqr^W|ATRo-!;kmIIO6E}hd8W0a6PGxuvBGpaX)Wz zKegs`V6X=azsz^qN|@n|=N0v~t|ZIhfe^j|!`tfG^p0}d!PIBpG1G~fnI})iTLoYR zw(sPXO1ih?*+COO6PCNvcb2b}iOMUhbp+0~e6H2>NWGYkn6gT=UZEY4G6$h=GhZ0S z-Z$~q$JsbvRcF9u!fw=dqv=lev$Jn%c&_r*b37?*pZD(=;@^$DaYr7*ttzNN0umZ@ zeN6pwvo-5TiVz+x4eIi~c~>FphjxFy(%RX1rxF9)w;xA^@iq{AsorOyIGm!TFStaP zDjzq9Xf^f42#ZZuGNDPr)-i}nrAChp zh@jw9#GR`V;GurAe~X8=UJ?4f(=~6;Pj8Umm7E@i<@I0+ZO%IbtR!7>$_J)m<114m zI#T)xahb{nl}NiOOg?(?VkBHEibPQn_7y~v`YLltQN2ddDY4_1KlYmtGp*41ILDD; zn2DK^jE%N&l)Kb=r&h%9hjz$gwlOm9-#Ha{DxG5`!zt%_bYZJrXke9EnyX>mCC3~2 zQ+1;FRu;D^EVq>aZ=6CwEZH3ey}cs{-q*n(CuksvVV+&Qoy9}rMxd*n`z?#=HZNW zL^>oDi3aCphTq-a_4xdHx$#Nw!^J~|*3-^K?-1Q_T3hR5hLzNGZN@L(Gb9gvGI2&U zjXOR0OD4wrCM6G+N9Z7|w2JN#&4zSpv0pH*vLAbNiHOU640b~W{2XUD*5J^H7sg2W zC|<=huJ=XXpwZqaT*TYLo=u8%(YSy$Qh7N<(Kbgh;>sPoi;~O{x9~a=rZ=-2ZUmRC z-c6Vke4+jdxlc3`tFitRvl`i>;~~jUicr4~NxmwtqO<%hS^yf6fMfZels5j|3m5?U zzZ~sHru+#Ge025ir^$aft$-fo*U;wAU_s!7{O#dvC>%kUIZjA|_v@wRF(p z>Ko_5rM8@mX6hx(P5H^yo1z1^d2cyqJ5r_X?PB`B#UQQE!O-?Kr7o7sU?21id28Qv zBdbw3-ijuJ;C%fZ%I*anP~TcTQE~B&wQc|2x&105+Uo<|b*C-j2t^9EUtkO=Bl=tM zKDe?`TsC>w$A?C5cbVXDr@ZQ~T16bpL8tMC>&E(- zdBa#jk!H<1xw&JB(NDDJxn+D*kRe!FO0$slYdQ4i82q6#lj@eL^p1rOhPg+qZ0YoM z!fP(xm%jO|U4h$%EOv^h!-8Ak%=I#9{fimO7hM8w<6jvue>WGCbKgG2t59*$qP}X(pxl>dJ@Fm#GsO#{{Y0Ug+pN zR~ux%;=->K@tEMY*i5na+BK=C>;3#xn`lqn^!k_Y?7G?HZ)Xx#qnVDS?9w9jdf1tg zBcYyG-K(s7Z+TrZzJIvTVJ2+!%c-KP$T$aBY#Fp$MN+p#XwZhaZzi)jUDjIVmywt# zbD8UguYAoY38MjF*91UIz5ywvjVg=WK>IgIBI8PpJqA5zx-Bom@+2L8G-wJcD=UvH? z?5oYItNCkgYBg(Y5(r!La*6LT-Gf`?Zud1kwmnUhn)gBEq6S7>u@775Q<^rlQdSh= zdvt8k>EY@kO>eBzNdq;=+I2rw;cJPQ>*kb&JV~=!Ph@$QzbKPG;hN1ip)Pq9$?W-t z0j=1MT{YvY8ltuKfYsX*GSAQ91(fPMYe^@^#*DghnCV1^GTX-->DHemx`FQ8TV5US zH91VtTxuM9>QX+7&P}Y$n`t(aq6lFRPrK{%C(63O4x$p0cb-Gr#XYms<*zf7tYNbv z&96X>Se{nNo}ESeFstix$+(rT6RC*5eP!1u1K&910|h@@;5lxd`DsJq*L|WoAJLZD z`aWM)sn`m&Q>_g0G+YcZKQ~7ZZATW;8sll<$bgoXKaBWaJfxYXl)g-MLBg8nuYztf-0Kxi^ikbZ!_#a8_BRew@NvAfobo#mn2-%b-Vo zSJ94WIyzNO#;!5)Y`RF$d-TSZtgyG_Nm4!NyNmJNs`qigBR5);G6kY^HS4ClKsOvNgCd7QKZUj(%- ze6~d)eP*rGAgGmjvytjTCa!dF3K7F4$ES%;oI}i>y~$l>dw|wsSdipK^eiE`@(Wpw z$QDobB%CZ;ZZimMq7`=Q~leFKz z-zVxgyO=CxE}}{wLfW=2+R;*mmG~%=35JKf{hmPj@ny>N(x{|@1ryQj%NYhf7x+K$ zkVQ9zz56t8IXXEaV-(Y?yVuDS!lg;h$68n+P+ajBuP|LDQj9=B24>_W&WSLOTg#kNXExIk2X?qjitMr^fN~Y2rCB7!ny$$+?Wq-DS_3 zP4hxDkr4|!A8{eq$JF$iGLij_)gc?HM^^Pg9oqfG?M!_#gks{WiT7U@5Z_9>=+awM zSEgRKhIC7-r>NbzgA_L|h0~}XhO4VcP_xRa6y5G|tubh`ny$)=PGa;hjQ1O}Z9N)( zM~Q%*-YaJGZgMv*k-Db`XDbzYr^xsWxP(S?A* zTk~mxnsVCxt`)J9-CooPc~I9ClnnpnNoOPOFVAx*&L5m}Ic!ZpS2)eJYWxXGNk0{1 zS-Fu}{idq}M@ZnaNU6a}Z>>_!R@EjiBDQzr1xQTIxL8j#u9(ikU$pj=^%*>ou94vQK?E(U9Q2CaL>T!z1qW zl~QIz1);OmX=9&=Q<0x_c9d@4#`}zdzBka9&`aW&CYX??r=-y2%wCOx-HCPkRDb0i z6O#dAc8{d89nk^&w(6w@v~#OA{J4>9#+n(0`RarSev)q&!^Un(4>y>jhK7kMHdQBo z9-gotaMGXeDW`agv~VfyzB3| zZr4)t&Z8N-<>4UxC}ks6ovLqB*tI#s{KMxGbF;ctKHrRMrm~pW zgH}jqM>(7w7Z%$35fBluCDnv^6%?H|+;-*4Qge|8o?g@}$2eU)?2jMs&w4WZTADf7ifN>=GkeH} zFumEt%&9svNJ+vi>*cO_`|WbMkua9>esp!B;JvF?&vHK;D{J59bLD;4u-uVT3rV&$ zyS;UHcWY)_DFsK;MuLThgIG&JelqAn#sF5VUedMm(~{Hk(~Hy=C>ho?&okZ)UmfEr z#}{xqSibJIyD`(+5gA^Gaaunx+Gs?pU*1Uj_7nC*8tjfZCq-QBS@uJQlGhNH+YynK zLc;XW3!l?b1D3VumNV&Y>0;iu&!8bHP#Zyc_<)=m+5RvF-!Dry-LJy#L+vekX7O?I zGX_*?^f-bG244vD(t4UtAtCIMdKpc9WV7`v=R>BVJ{_>sKa_~H?SNPHWQO-@dm%yc zD!H4LcM`5yg3^oN?1MDhR(()_fagU>g5*zXdk!_s43X!D2t}h*lfMS2;8c`HOM3;Cn^udcfLLzPzQ|3>p4_ZRx5GqX$ z?p-IF6ZaH(N$eeQOG42z-L0!$wWcHZM%$d?lL(!D5e9AbVP5+*LDe&FZ2Vbcm7rSuG950SQdxx4sSm|21)N3f_PL*3^^iF0dZKiG z#PfkW*Zno4ku&S2l+-Lt=WzW3-WlZ?qDHc3oUVn+ z%P`vOD4dn}F_6k!4yMiP3e5-6y+s`P+>G^?LkgE4ykUH!S+$FWni`iTgGhIJ1hZP! z)jeFXdQQx%fK6E;SK?gOL~9u;8eU30Wj#l5h>A0bse!Vz2EY0gQ@UG5I}V>zrR+_j zLC(n*C8fyo{bvZf3uo^*y^ymVaMcit9I|GjZ*syC7d^9?ss zV)E0Ofi3&?^6qOfj%MTb=CVksZ^B++OF(yv`WLIq_@!@K;K#T~6{4BO>Myl4NgES? zmYt=FGEp(i8NMbrES}L|tzlC!56#I}k!g-YU+%^))(JaJn`_*1y@#At0=j`zb{T^w ztWtLXzXe!M1a|h1V1pSk1OZn0& zF6a?^E}wVY{P3dW!VIv`IA%`IFIa?_uYJ1kxN-MACea4Pn==iy;k|ePD7W#?^!Yt| zOEw{)EHKNR_r^h&uJk@;`_Q%F$JP=O^$ctlVFntHx;gF5wC?fD#Yeh-KtQU$<5MMl zT{XAOFmqRmU`9cA+y&S$SZQI2sDoH}%+^<>XxJwv*W)QHP1+DsDZaZu2mIudR`4H-7_h6Ofw zsI}s4U{?*ZJ*Y>195tV=^j7LlAQFk;JC6Eibz&M?9xF+YM7_Qsddg>e9zWTC%3u74 zll>?c{1dKoBp-1iT<5C-2l|gE`>(jpktu(4vi~Sv@xM;lKf-m`f6`R>ezLNI~F&itkCa{KK(oKKt>u-P$IH4WKn^`7y(-> zFB-$N6w*R|A~z;t+#k8Xty}U%K$*YO`Dr1um169>uC=Q9)w`00NdAJB$j?9OOk!HL zvo{SPkYV(@@-?vX<4SUIRN)g(C=gv(p+ zM3;X@t}HM#lFQfIieRMfTuZ0M>*!kV1nCkYnp;*lUBQP`HD4YC#R+Ygc*yaQR=26T z&=8<_!V1oWz?MVrer%tr5D7W^oaD)+8N+Jvb7=t!Yk05DY9JQQkMg`?%<@WetAMo}?H5?eH{pTXf+nn`j_;W5PY){AnbQpFV7ghnCy4$Xca)1`!* z6s8Yq?@^w4S9LfyUmL26v|8}ZVx;qtp*V*?hiMq{rhymr7WrD1W-sUKJ2GV}x|VyV zs-*VYQ=8ADIkiN{3dO&$Sl;kK+;V01??LCO?Y}R3R=~rpzeYq!xGSQ;=TermG!idT z5jrD(1P9&q?qx+OQZH2E-qKoVtwEd5K+v%58iQw1p~PJXbNBcG|M@_Jp&qi?6oa{} zxomkol~z@DYtrixOB2?#JMZ#p#_g4d&#BY4$fy^~$QH;X!V*7T9Q-7$nObT2S-WSP zkuv|T{rfel@aq=iN%_~2*b;*?YAXBL%7Ze6g?Da+^e9ryp2NZ%>|cLA!(f;ryMb%q`gEP7Mpc1EMKrO7WCV zUANMAIl*}kKV6G|!s(cYj93%HSLhC18+}}jdDIizU8FVfoC^Qa4?D$=N?bmAl z47MnzMlYRnlX!wU%abJiRZ!u3fprUotgr9gz1~JNU}T zjn+7fhB}y`T7lqfj;7t>^LwUkbr+VbdzU+rD|#51HqtvLMI zjzKTv4Fb;vC%LAEZi?&Uy#nEBAR4TF* z-;!J1nVUC}7=ID;Bzx>3b2|N{(vCDsb1HUs>VwvfwcWX`)k1y-m51(ZtzR-t*^q7I zc1kR0Of0daRRY5{0v8Iqo{tTv+CTmY%f=ekQ z$0>H*rL6m#>+?BDZZG z+Of|tM4ljkZM#EzgHWvQs;{XemWWqP7TUENs%6?yLo**(o~`9?*o{0M#F1bL-+qan zNrx1|l|hX|&*f2532fDhR+Z z2D*Fjq6Tc)vbz61vQEE_z$}wl>Q)VOQGZq>)&G=o&Vc%5L#oy299<+8L+h>K!|jN7ftw~5 zWFieNdcDlNyFLEKPLe7OsYP(1rGd-`iEGRId0dfmgT{l!;j1|@dxo`ohf^+t_qOss z@RX2C>dpks-SKEQa>QNdn@q<%SV^>bBhQ4dv7|GFj{?~ z-XaSX>hyAW>_`Y%;(alSeukai)*J{*o}b&Bf?i`~G}xso;$jBu^y8;&oikYV>;GJw z!Xhy(I2p`5;f73$>#lgE+m5#zHDhVmm)`&EHGF8TYICBASg(o1yNCT`m$sybTnn|h zhbeta9C3#@CqjlP9$iYlkrt-H_?E}vLj-xHcN$99?Ubl;Dd$RILZ4Qd=KVWck;+3} z;)k_47A*d|>058*JR%;N zd#D%FT?r_VnQ%i;bg4eygvX0y)@^qw+CMvqLo*&zBaFPPb+ojNpVM5sGP8>X@Z*P}};F9muH_7&jX-B4ZuVw5q( z=TD7?_Ten_Uo}Im{`lB%&j}+^v*~pYgBE0IKSw6#uA_n?V=8Y%8{+K`%6GW8hA{NQ zjaasnr@K58rU_b?X7R~O!=A}rCYnfY+bYdrF$rCwiK0*)b~LR<`l9^GC;wIA$F13x z(^mCYsoVvxLg`;D%FVVEy-+L7px@~zold@^nuVNpU3;&Fj6#I({=8e(vi$CozV+Z#{g&4J7?lctflx7`d$b#&98fiD}f;;~oYiAvo z<+A;4Iz&>C?i8e3QfX-^k?!v9F6r(@Qo6eZq`L*AkuGW88}{C3Tj%`T=e+;y=YyN! zUeCQME?Gd_u5%-e=2L zC20~jk7?lbfElD8%4$8!$gn>C`lgua1kqeO(@QNwTNPAcSG;#j+enNmxTH~aToo_O zf8^C%#k0)WlNy8Gc#d8Nkw%v#l-Rm8KIoUD&g1IorSl`OHeL2%dWGI*)TobN_>k2< z3f(^j-HsfvUqn`L%7X8_88UNGhI~N}fTu(^aKkTI)2**aeN_VwjAt33V zjMJn^a9esp8%6tM>vo}UvGKSR$9{_kCdF%`7X6C|2oZBas^e0?O4F4zCu4UjwCe*u z@_dC@;_>3%=xXgYT9<>JrzwlJwZdCq_r@C9k zzw=a#e^lrHC$i};Jk<|p0D+T@chC91Wz#>N{+EyY|KzE@b$)+&DmtLX%WrzB@z=AK zz^N{mNre&z|MwCQ-~^!In=&I5A(j@SG0E0sJ^K2{WpvrXJ`i0KBa^+2-$Ay zQgR_p&X?<<*As+;ui~?VS_^7JfK6r&7*Bf*)Z%b&5^``w9ks7{=4kAl)dnVmK%mNy zCmF$_f_fs`ww+xgL)z2vBei87$WkRPN5;(yhCfgiM>@T&neT@W?<=MLIZ+# z;{WNIC8^1Y0XFA0$v1NHW!uXsadcxYmDTqYuit-&24Or{4RpZj+&1jAD$jbSyfgKR zY6+Tc$S@TCtNMzT0Y^lIeN)O=C3q$#97sBzC6*Dn75GX-{Q6T-NJ-JhiMyPGF^@Of zil$0!wd4qiT4SD~$&;Z6zDIp?G?X7R4DO6lGwGRcV}KwwYI&@WZJPAXrGQ$gv;tD@ z0H!JD6Uvm7+uW3A_3ITYoqbwA$NsdlhEhwV8Ors%Ar$-uO{4ND!NAI*D5`-%a(gV& zi8Fr%(ClMV;JW1PL`X!N1I!QvVA3(qNd zB^K;D&Z?`V5Pu07QO%8i;n&&3K3Dg`NZntP7i`0X@N8}+19E5cOxtos;?ZnRS@`Ng zkE06oqZuwRJ>!&Bn~#s)D;^)c7%QEWLk9Z{|X1Mji}?{`mGSJ59SF1;h_ifyJPK*%5 zsZZ4)*07@xbp{42QInc9iN{7D=zb>R%CPAF5WEEg@ib=BnkD>b$>4AX(St}VbEu~B zO$+tptf=V=W?_s~b#Rwc35n8FZ2n@dpj`iWHysuX52TJ%N5b@i{tlJUbf{<5h_ zIj&DrIqvi-s@w-}yg{$Mg$)}?CO)K)mk?3W#3?C=yNOL$5I+RCsAj}78XSE@8C(9M z$9cZo#tu7)#`pqh>K2~)INetWkz=k~^VUI+58v=+3LBfHjL+R<%_R$4amSo^k9fBG z@+`DD^uy|>;i97x8FGCxcia6vF88W=eXoo-3>`Wdp^a>x9FymP_*ac;xE^H~79YBk zJvk~sgZoH)J?68O}=B zO=~{strWb{&XUP3QMoBNST4#1#}tr02=xj(>#l737EHIHFKMnr`xpWQY1b)Bx)(VX zM=6RPB?Mn}p2+3Dd%~(=uRhpQWG3G+E5_kj1G$f|#=*}d7F3%#;O7lbxyoYG`}*^1 zctX4y;>su!DsuLx1G4!=*f|u|9g6K!g)x)pWy-W^E_27S`_PRm<%B;k2)|%p{7{pT z@&0A`J_ZBIMBRsF|BG7i9m3*nLAW>NcVe*nr~m(r!M?k0{Z|ae0^G6x%@_<2xI;(T zkZwMyNpF&jHO?kXIY77idHE=HfadH3AmZeg1=I%%N2+dHs|{U$#dg|eGLWgFa!1SO zVoZtc(h4QF-fqFi?HXV^=0mAhrISz~)^mnjnItxxl3A3j2WuV_3{|T&#))K8Z?&%) z!UB8gEI4f+Ua5>}US1C~QyWu&Gx{YAmJ*TY723WC%+aOCF{ys)_W z#BT%e?X7Vb%-Q!@sZk%=r|VwjV}i(tHMAUYFlA;FJE^WQNWQ%aNfiU< z6{gu)tZQqnE7B&7WtLREhGKwE4%qMQp*seV_SC1Q6Zfb!bOO2NOPH z3_-j~c(v9UV*iEuWj;*QWcLbdEe_N;7l@%XV(w&b!{SF60^5Vnq2;k|&0I30pscnY z6}Q8c#Y(cLRfPo@c14+$_0c>wZrn5u0ZkL)ifgOU0^I12Ra_n|W-*k(-n>tEvBrR` zHe>TyUbyL5XAg6==8I3&T$d>-tJp?phiRsxq^mE?hmVL=$aD-D3k=&!A^1c-z85b@ zpv_PCIxiNPVPBINOu?r1l@SHuJYjKPGqvD7_U_I9cr3VcA%b-p>cO75+A8Vsuw zKKsaI$*L+x{Tay_94!P-u5P`^v8#Yi3~im1ZS5_5QhP#sr76pZ!wmFGTKEf5j;-B1 zu}dHIi{%>wxFW>M<;!h~WnIyEB*Ox}Yd`+a$7yU)dBumXbT&2zc2W!A^gBi4yXQXf zj%x}Dugn^~T%&T*Kt0z<9wXaCmy?#AQl+)hFmNz*7L%5zGY~LZ*{e#ibNZbp6)0hJu>n81iQaq z#;5R{A2!e?--UarF2Sfg5c z_DkVUxQ;G1)sm+EbA6DKm2;2dT5&f>GaQpMLl)}tvEKC>=if+Mp2k?=fYBP=ehTbU zcA1~^hdJ_Eq!7)r4fQ+UPox7!itBP%a2v1t-II|(6^+G||*W!{A z<_flIp+NsR>gY_GZ=GRg`=c<#)5 zWZ}W3bXp0&&%DIy)P*mHTZVUE!(`yX5$HYz>3xbM%=)+mtG&s;64~8Ye*M8suqRki z^n7-G@#{DQwb#A}B|gtZpAa|N({&nSuvk^+M#yuLfF5yD-xNi>tY3a}iO_C}5Rk7Y zmsQrre#&GBF^^YX!$8~Hg#OS^hgZoxQf z*0lC;RGwq^17)k8(JcDL-d$5ZdfPk^t5~QDkW~Yk@b@$?T~NpPb?jlIpQmN1%-l9* zP{^PPpPmUf52V9QJni;1K_S>2IV<(`DtYroP%hl&%1|90nj`RQGy288`~H0Eo-@Ln zFw?%*-bGYyvnv#G1E}WA^%-Uun>F##!RWK}64!oFRjs|kSJEe#TVEwP?29S$vFNVS z2Og2zw`uZOCxHk#4pK!9?TlY*+)6y|b}+(5EsU~Xvt{*;9q->kqqPH-ReJ%AbcIj2 zmfigem;SA|@#`4>-rfD+(*IOi{wJ6I?e5~vzheyj;+c2UAfRUR&zB;ByQ@GD^SfchKR%6ihaCU=&;J!tumKc?-wY{$yAWoX z_a#y^RGbV)X1vk8#7E>iSwyPJ#2=iE96P>*eIF@jVh&1fmw&Oq@nyb~x0_UAPZX_Z zySHzfaj>sR(4coer$W4Te)2LR?*hra$|PTI*dewsfn!z`^>)i6QpgF8_wr*A2&PyrRn zo3j=EKp$RZR1DprtJDQiexGO|rAFx!$Qn;F5lkd{Wy84h`>rxK~Ewx1U*(Pubf@bG3mh z{}s=izl=lvxkXH*bEKBM_~UJkm-0sXVzq+8<~X0JIZ%geox3Rv(h_I%!WDZ-8B2X) z4;Ti_9YZtqb{hMfV(TJvR&*mHNp$%jEIJ+}2001ZOU4+FAWdeO3gcv@zIF)DDhQG} z;k6u)iP(J;A>PFEsDOkB4h0I8xEe1Drwc2GDq=k@Q!%H9D}bN68O~C=4eYaJJZIQh zj9fcO2ux+-4q`z|N!$6s&DPtFiURuX{2tkCPB9|-MY3K2?iCLh$t5lG$T{?9M2)Gf z(4yXX-ET0}lU7JNa5a+5^+k!G&T!}L zy%m==QZ&lIrC*17$(hVk*BO4XOk&!cSi?kyd)ncZE-|u=W}ybjxo&D+>i^cAY&&on z#&~&a2FADu#UoB9n->-I%h$GUu$3*5Xwtwd4;sN@nC91!@#)M6n=h!O!ZcSUHc_x+ z<>#I{Nz1BL!JV&nFW0}b+ERN{)DPaHM60}xi#4kykF8o->_*d}n-Y3eJ6JFg1Q(JN zzn8HzXQyns5z6yaGVW$AG5PGq=_tsn#I4cXBoy05+0@yQ{y7*;&GH*Y{ApF87F_W) zEhdg-8<6ft^GiOk2}EiemlAsGd!Kky-P;aQ%J#-=h1Q2O;D;g36_~Lk!+EHbInlV^ za5BYw$sBgpJXi~?by~7726+SF64Wr<@j}Mw;SqjFLKIyq;`&uG*Rq(y`h@o3xiykI zzFzy#V{4`M9x8&p8l-7D!6L51K(@(z;%*HB2cm%p^ivo#=1T?a7do{H$wDPum$B>= zp4&GVT@z!^9vx)+%}(m#_q7hsRpvmR5IHoQm$ZG2Uk+-#_ITjNHS6LhSY_AN%BD)K zxSrBa7)-s8UkXVn#2O%-ZrVl?u9v5H0Oj_7H2iW742>y%xf7I7zq5VV{-j zWzNW2QuK+gOxFiStP&Lu@!9Or78WRIcQnKpbUuV``@(espH;3z$wo$F7`%{9q#F9P zeP%WNkP-&P3H<9?rd4>l^{GpGeS(_t8C)4EE29Ml+{jhHC=w2tC0pk^HvhML8{!Z2 zmT4h+XIfy1xYo7>L3vVwSPxQPC!sYXrd{U*dB;aB;WziysAc*izMbwB`>I?1x+R!s zd#>D8U?fnf!8NN}$TD?Y=lZo=2y-yL9bDgO7c-UfH4gvHhLoq3>?`T#It1~QPT6N~ zpAz+DTDk=2CcHTqS$ttpGv|Lf|J8ghG{R4;?y}S)yx3h~ZcMeZG++q?k4p#46gP0) z#2qvuN=$Z+QnX2Neg0u_Rz0hD#v)HZ?TRsXqwlrOM{?s}`0LU(bJwl(g)<0TrnnqQ zsn0_%HMtRAGc>G!#FxNgb9-r)oI^hN&?+@77t{_(VA8>||3fyMp+?M#y__+N+`DEw z*dqC7iy(OGaE5E}U^coNCM0Dn`D#z6N*WSF>s6sXzrAF+P#JbSNE|?r&e>-4u^Vv@ zW$f|hrVGZmWl50&oqkJUlR0;Vo0?fqy<$Q-M?QWo%Wxyv?tUW09aGbJ&fLfu?aAj= zVQ4PF%^wvUH%hl9+MoztR?%`ny? zJpJ-!`Kan4ved)*GfCQwSs^zqf)g~EC(Y;B5z~`USBi@6X|5?t7&)z{0^!`|>rJ8olq8}eiVd9if$Hz=ni8+xOE3FB> z!=swp_q8}Y7^PNjHG&v%17V^&qgCYN$No7C`US!7M`h#QMSmX#-4m{WfBNk(2&g!6 zuZ8@5bnlLp_P6K13rYS2J^vNVurjj(W$S@r(?6CTVEm4+^>3ukf0d~QLXv-WJ(Cfr z*YdYve}*J%Kvjz04M{rXl_Y2BP+bR${li!)srrq{ZBeH1c)g4KZH?g*n0TcPP;$pu zNNq6nXWUZFU`1l0q?yDWN?e>x7Y_8+d2ve+w`hh;jIoOhkX;xi-Cf%|xZv}5XlC~w zqanELT$ct|PnyFL)#1Y-LSSJ$&$?U^2*k*p_W^N_`AU~Ut2dnQvYNW_m<}Pl)w1A#l_cA*8acRlW6{+p( z`82JXZnQEq+|f;bMOyuA>5@0uA~h-epkG~J>1rgi39&VTw2&;D+b>J865p$771X9ruZ- zEw+c?2@sQC*h1cltZ(;!RHFCo49j#ivp0W(K#B2cmC!N9uP>98Ge735&(oVD*XXI7 zqJFi~K?C*FqvEO9`Avm#S}WP!rbAug%R^}3Ka08-a&b};RTr;6@iY04YOAVigM+6M ztH+<*2D>pAtHnv|Wiq8z8!#ax3JZsMsHmHKg+ZC6Gx1K;_s24L-9vH-sl9h%O4GAD zbjlQMRNjM=FByIDn3Nz(Z1j1mb(Dk0Gsp94$9bZWQ%m7?TKCfp_K?28cC`wmJ zI$Yomg+_nkX09!hs3+g1Kp+LKj4L!URG~Iu*K?NhzCjPkFdTv@aBalemoOmVXsD^j%ra zzxGBfK((FU+#9{aFaiph?AN>bgoF7gkL3%$EE{t%M6b3P&Yu6A(NaewMKbd^-;e5* z$Y}blixA!u(bBT_*q*#A^9QO89G~LFxXy@2rxIyAeXtpMlCoDj5=}v`EMGiyL^yLu zT|9R@T!G9SoeJi|l9`hiZAW7^uSY-E% z?QvBgmI8VDro@M@aeDpaOONHe20 zewNW??Obs_RO*68zG#UH2Gt-I^t1s{wCBghtbe`{x#`I;2?w4{?b6)zI=OJd&C%nl zIW6s}cyi?vGj&N<>1>d%4%-*$_(9=0Hl#C$kJ$s};y%P&Etij9XkKr9T`iZfF{H&G zTq9(wBHt8dc*QyPP-`&Qa|&O7_>oiAhv(4_cGkJWhkg1Z8 zv6RH9yqv0u1+iUi3)*c=)TQTgHcJJp>&L3FTCtAU-J}}ih*+|ZMYW`lEbT}6p`kB@ z`l}X^iRE_fMmtPW~#o1ljj5FCe)?r#$b@1LxQmB@yaUcAVYn5(X|15p-Z8DYa2H4N49tQ;!_H9 z56bW=NGKoAU3P5IZHsnp$ev?=uzvjS9T_{!cK68fL^Eg~ zlop~nvVSR}`#LE9>B5{Gooi5*e7nwUT;TEU6N8IQ;*MZ1_k2B2Hu^PRLdC1DoWVm* z&YXPx3z{Qwc(526dNIjbu{0t~i5%rD@upaI?Mhwn(79yei8_K@EmBUje7sznqL+L< zR0ie-^YX9Iy_)jp)a6d3)D-vN)xFfZ4NWL842Z>Ks_P{k-@39RRaT=QD7cMg<)&px6 zy+9wUj8YLA$sm;cl-$mM?rOPLNxZKvc}qWG+BSkukU1Tx%XHz_$jG(ZUqJS0k;p?n z@JNP6E}AcRncik_@W4@V%s#?#ElYQJBTSkXW}R>rG<6QQ$3aHXxy_k8GHudYZoHXKMdtSD5*27fB(s93c+m^#pTGWKgp|s2 z*sf`vqSFQcu#R4+l*$mhq6c4;RxM{Th^_tMBYzZ=IzIUTk0|rk6Tuk4Nx;1Ej^&!h z`qEt0u==@&6hcIo%l~88hu8O#1fx$`s63W5RhJ^-N!d zAh{DewA1{2kMQ6vNJ4Z2LzEu=C)M{8z18bA%!R!rgcvyXH%p!8TcM<;8OWzEUc7pj z-G$vpjGh*;lSX>0Tel^ygc@q%RTIl<7xbhtub6dv9?Rakxg$*=P!I}+QSo@u@1WyY zk{i6>$$54AM5`3@#}o45Z3L-bhMM8A^4cr3{-_q8+DAhRak2mFn$d6UeN=}SA_A;mDum9-~APBFazfZe>2)>d@X%fHVq*4 zAYIXQ8@&%l6%g4u9m+6R%jl`=>~y#BNq=og)KT_IL<0NaKpx9ba>Sh#rR>adfZ#cbULa(7*j{&S^Qh~S{tAq3oGdZqcDMV{5nrb?mo3p ziFFlgF!ZyxU#9Sd_IT*XA;XG=`i_<<%(+|Pj_h&Zaxg@es%gIruWn2ZAW{akN`-)a zg^uvv=0yR@!Ui?+itKu~eT{qI9J!hQ{zeY4mlvmaNAY6HK*9?|HXt3X`eRyrj zb0`b3#>;|1~?`ksxTeUX7#Y z=#>XvQy%LfXDSJK1?^IWGSnrXQU`rf+C!kag_3ww6w)@SSpHg0N2B!0P1nY4;U+c< z0Z(YF;^SVqA*c%0vtxQ)swGJJ$c~*2nCeUo(}JNRK4hHbDz=Y1TqMWJQuz52&qV6! zZ_&OwIVY$Pq=o@78y6qMkyfzeg<}b$i;Y3>%wc}u>!mJwt zB_lH5Bj;>^i{EKDXIko`?!opi0C%f|7SN=Remz6#i%wZ;EIQW^v@bL?xzljJ;ASGb;qjfdAksCYFs7K>qXJ${a$aRP|s*Z&=oTnsBJa{0I>uWtDD%&SPCn=2<%%O|$_ed-La#-k@O#Rg_uX?vld!SIu~bhh&RMY`iM z@bY_=Uuh**+hCm8@>RM;s>z9*@JeuroRGHm9v-#ZR87;S-E=TWwYq^&d|8J7g}?uH zzx!|e{r%qgyEBsaWWfK`-+!ym-Fxl(jsI`tPw$`p-{dj@_5%X}{hw7?fA2CdP*nNv zc<4`e3V>~YyU1JP8>P@$mdAJCJ6$zn_5MQ%O0#Kk>?~p0daX3Xc_Jy!gi?@DE~8%Y zQMHBk0#a#|@omT>^?(cOruKF#VrK1trO>Bv4YDuNJuPbIxM=qeVSN{9{M{Nn))QG4 z&1O3l7U=4pN)hHMo8lKjh=iqi(^Mn!6q9Ivfp5hqcI7M%P)$ydDX&(LJ1_Yp<)IL} zRqH&RI=2YI((jrJdVWoav?C)t+f|g>TniP@coeHIjkuik-+oV zK{yG;8uq8V=(qlsbKsY4LpYEcR%9ZWZLjD!dd#-KDY(;UKKN_(b(u_qy~dK-5#%f3 zPcm?g)at$w$lI_&erP5=q#Hq>VcFoF2_`zd+!=?L?;YcQjaq0Gc{V z7;a>3Z@{uht)Hq-$o>jK-qG^rgM)WQ8bn{H9UXYpD}UjZm()n;huLH~qVR@o{?d_; zVG3T*68Ghve;uvN3zg*h3YAl}3$Jx@)SK>D6e7N=wPLc0s04Dm?Cg_dL7S6 zmiv1d8(Mog8qhgr$9mzqImEukkvGgOTRkJOOpbK}$q{i;CKmMW?&D5-wRYnOSBSLU zx4Ow19k92&2nP2^<>lxwq$xPrW45+3IL;n>rNxJ4uNM*a)bOsv9$C_aXS_Y`?wVv< zv@#^I494Oy<(YH4p7*m`Xr4VqOMlJBu#8E?FYC)4y%tg165Ct{vd{{T*-P(ljLOb(84q7jjNrhyb)a0N=d^DZ+9Dw?Oig+ex1QsAnk zocF3qEvfm(=p2Vks%i(l8cRRt5Gu)n@NSdZLrJ3-2U{oZJdb=yVn$*S@>7~H`R55%v=|m)5^)ziSKAdvVho@oXJFiO z|5!>kvIa%3fXc%6q91OV#gQnCxKH0gjR&{49sL8XA3RUErEZKtCiLYigaR3gmu=^u z88;Aw$GH;CtU2@J#_1okedizLLUCf7Q-27YDDXdvH7nI!Fg;Q8YLqhDDG}$5u;k9s z%aa<)xgN1qYd;M|H9S$?9U!+;6cV{n+;q*LuqseU-O^ofxcQRsR?eYDes_XQ&1!i2 zx_j5!XJ^%cy06VdogDsUJJ|5cbcwZ5YPfhY z03T~BdZC@%(r7WAS_DnIof)h7Q~|$HV)dX0F%_>7>6Sub;8UwLikTlgH`yC%%h66FrL4B+!Xre(SDZIxw3}~P4S3+CQKO_rmQ-_9Otufh`CY~ zBs62hwA28)dN_%0jZ&WpN5@m-=!nz&bp96_BczoUYz^0IIIwMjc$fU_$7e}+0doO6 z)t<&+B1~Ey?l0p-y0%{uyhGbj0x9=c0bfNS;9V@_SFUo{2@R5{gr{)Q${f7fjZE=; z;8{UtU4%@`t<@pBTZ5eULHOkxF>GM<=u03ZirYRfvLZC{jr0C&kR(dEqs)b;7uVVp z5g7h~_JaZ(3z{0JuJzoz1IXyN&!v;d;B%uY(AA`j0?1TeJyI)V(hDIB?e9;nYGr65 zIrr2bspQFY#$imSvcuj|?DrYUcPWycCE783hi;e4M@^PsgLx%gZe`}S5~!?hJwky> z2=(~M)yH~INpiR*6U%|e3eGEgEHpuZ>4A?XAOCP3%97`cAiPmrw@8h$} z17s=o3H}+W_UWVKU@p<>5tXAhOZd;S)$I>3>u{}VsRq~U%9agn>R3$2o<-Hx)W445 zu(NZ_8z`!^+Sfvy|GYq<$_8D9*iZ!iVrzNV81WM=t46Zz2i#B}vd*sdcdoe~oEH+0 zMw>qE%;Gvn6K1{(#aAYl8?b)Baps;_>9tE zXL*4fU1rNj+39ZuY+MRMI@c-DrIKF_G7(|1aG$wJeZItdG@_?gnAmXh-_7)AU z@u9<;6Za4335-*&7AbjgCR1Zz&{Nhz&&07fM!c=0docuce4Ug zQz(HB(JqS%?uzHxNW5T!P1dNO*edXAYr%c( zRuJmx8MNZ^a?H=+6ma6{?{MMQ;naOZ@q>Kw=Pi_foQI{oXINMfC=mc`IpE2!fX_do zD8_sE^4-t(f17~u9*GS6e2;m*`@BOe-+li1`+txJ0f776HvstSIB&>2hs*x-)H&Por|b!WZfnlsb?Ho~5s;Ryi{#C?;C zzW?t3tzC?401p7bgxn$BnAm{sqi12K0T|H$TN^;JGXM#j-zHM9{AAd-vF<fX_7voUC}GHcQ?Y5rvTx2d%M+H`;!#|k_c;9mn&4Lab60P|hlJXWUPCa2t)&Ip*S z%f_m~%%A}rEd*u?I~|KI13MF)4g&+b4uj5*rhi8P|A(gEfx6iNCI$d0|I2iMwgRxy z0l4KqH2o(K$RF?Ee>+eAnhs2C0Cy31dG4v3>?}aVB&ItU2Y|%*C)0smM?*uGNt<1p zm01U%oB-26ON#|4hj=$ln04vdf9lh3$?X5MPXWXWFkFD4|1zDCl?LGHu>E7xf6=Eu zZ)AUeO=4mMz#2f!a^NH`0DS=t39#tfVU z25OxD%Pv6122eymIm`duuJ4$d|I{vk(E}7np$CZa^fYv=z^TXqbON6awHm|M`(jOe{ddUmbo2f{XuXEEBNC1L&!rDMpOU|Hs$-4=ulS z`9FS524HqFGcf}G5Fm;HRD)j}*uRHE|K%foY!76-?$~I|EI=uTpU%~N$8`R&<-eXx z4>&mBY~C;012ts-?yY~5p!()q-ZzrkcWhN!K_KJCb~k3P?!q)$DN8dg869gNR;88V z7bKvS)v>oG_%5vc4*L9;)H=lte&vW3Hs zEfw(()2YD<`&8ggW}G7COfJ80po+vhmSzzJf`p5~ug7C@Gvd4yeT;Dv?(-p#pG26E z27P)NO_j4{-%g=}N45RP=IMTM|M(ZXAR4BTh>x9XO%nvLC{aV5x|hqZh??F!3OYD! zrx*QNz>H=ekBcbh%Jxpql{2b$q1E+E{r{#!^@UFYM4mP_D=y-=1*1_B+aAMt;sA5(a^L@}8E;C)Pl< zw&!bC+kBR4yn|S(ZC4vX0rLA}D+eyS@?H-K*`8Ic1T-PL#CHPW*gUSBa=Y0xn07~7 z4g!WP3aX!bP?_nk2l<4!%hdY=z{G9|HZWx)-{mk&4dpsghK!fappnh9d_v0dG0&4x zgeFn^v=cf_dm2NNYIpvrMmh)bL)r4CRD4_T#7+ANq6|(e?}yIA-T|C9GQylbG@#tG zm^`#LTFphdud^>BV;6EdA1J%PP>j=Xu{{senp8Y2Kb@l1vuRqW#wDrrYI;~x88n>- z(Z){-CxWI4cIe=r^jsfT^rSYAsV&Zf27%PwKEpYGGG7=U-aFlSw39q8!&{m`pLZ}! zu+9v&C7GI#?K!N*=l3>jtgy)bqQZXCU$OJJ4XOImU*hO`rd~E8_@d%WV^WnJ?5n2_xP@>8pMlZBix}uMn5h7WLur zhMzV*6A-?f}hZq^`@b>$qJ$gWL&sFWc@y z@~C57qlW5Bm}B-1n%h1+MhbQzkl9lx`XZ4b5C2I^lYG=uMYYHx@p!aznH`Z-C0yp% zMCFBkPFqih*cgZDO`F56oJNNrEqt_(mL*3HUrsL?y{fC}8*odxx?8#G7zdCgI6CH`aBX;LXQ4+Bz@ zy^P%6$*o(cjLz*G4Rj=^#A$;yKB@pKv^D1GQ)&J(fh&Va$?M}Q^H!S8-9iEU({qGq zaJ^?Cke=_-(Iw+bTUva*2o>T#>v7pA=Exq~*~JMgF)_TI5*A+qJ7@L{&I|rxD36Z$ z`bF+8k=iFCud66{uEvu#9evh{Y4U_fiv`T6u)6ZnCW~zHi#Z5nedtNCc08}~b2=Ez zj26Kjm3CNMyNvM+WNfM+aO!wIjR3(2BW}}(Y8V!JYX6#U3Nq4&XTy(z3_Hj$(Wr1V z#vn}9WwGs&q)k>ZgAz*8b0+BxRk+vXs;~*v`bt#aY-zunn z#Jb=%j+V}Qu+!mcP3s%Xy1lQVxl_hPy>0x+#T3|?@Snn&1tZY`w= zm?6TB`?!?RSft7kXa00kM7)DuB}6Nl5glN}A|w9dWIYt0*+t0A`64RJ2aEljoGSQX z#f71rSNL~VbNV(m3+)!&++1$kFU5Iy7SD*h6a0C@5$yrX6Syn>X;rK+Mr(7>S3--;J z8|9m67M}zS$8P4qqFM>l&_DkqXdKZ{+J<~6u?TfoWuDVB3zho(6D*^nBbNiu!raZ? zviROO-r7(i1v8$Ppdna8u?d+Qq)-widt`I?F@~F0T;-D0bwMRPc31i!BSjm;CBrt>Ao+`u94yZ{i0yeBIuRq+sH zU;*Cc@em%C?C7JL` zmXjM|Vet{pSFCM^7DK#;7}g2P)GL^%_|@qJHWI0vTTY{7q06>5%=o(*u?V||l6I}P z7;L1l!QSd#fgzy5!i3G6d%A{e!agV&BF@>7!sKB|yJF};B{a@@2&WvzU!yMQ=dQ?| zRWf#8>|;M&kiu<(*4P}(KOIDDn+y{du8=&zC#*pvJRNX-Xd%hHVkhwCYBzeO`1y&$ zG@>%T+vRmDP9124+bJVbD-S4ntJvAkA|Mcg{vAO5u}}E%GRA$V^SubjaxdWh7w4Y8 z5dr_e{t__$nc`&pgA5G({HHj0kMjgXy+4t@cRTNUvF}f$FXKJ>68Qi31l7CGKf<@~ zqqJ|s!+*L90;Ch*j{`v8e<6N>og~9u&7J=l@%zV@{wreshlc%Y-^c=JYYe~+`|o`t z02!qLq`?0{{ktE9|I)C(_Kp9t>tFlE{||P3yDj>s9rmY;%LHI@nV5mOOMj<=N zCVF6u=@@@sl%)Sr0Qe3%`(N6{2&l?{&`1xABQvnKyL$xyGBVrm>y30jS@pjNOn>$k zBcLP$DhZ%1vjd20W?%!z2<(#qi0*G|c62`}a`*4>e>uDE2klNmn&$DnzqFtami>S!~tF*50}YUpUP{v?duFFOCT z;lK$^ru#GkpefSdopZcbZdqAbe^-E_2Ta%1q}OKFVPU1$0p>FclLo5>tERRFGaI`m zvo;eW(@!(>J4En5ouPjTxb!S{dIexG@D~+UI~&0%RnBM8w@>0iZneKT0n9I@!-}CqS|PI~KSTWA1~4 z-_hm(-Qz#E1bitSpiuv){{X7ze`p9)hoAwRFObDxyMMudZvNf1%wJf{3?RGd>43E2 zj}N{>B>YE<0mTc*0s%epbIWf>_ZQD(VgLa5fVli~!~dgufwUbBJCNl1x#f?@>>me) zo{kl8Ab_~_(=+b_wZGn>-_XaH?p9ZzXMjQfMiTok&Z2#H&iyZaj1JIKe_J0@GMlSH zaa~X= zQwOx4`yRRAsN$4$?1w&;X$W!%8VM8V-B|{s#a}#Ph092o9BQh9zo}MqKDiB}k%%?BCu2#2A7ZLF5Z~=XFE0Pd4p=6g_}L+*Djku*%h*sjLB4BCWoP9p^{Z~*qV}mY z{-bBw6ai`LozkO7Oa6?Eh8xy+%&l|-bQ+>sWFKxGy>n(G^GruyT^h07AiyekqTD9+ zHZwQ$(lGYco1WSVI!S;cn;z3WF#F>9v~x-O(5Z|Do2vi@tJxm6vdh)+jUfh9XP9ve z$qf!h0j&9?Qmj*-1vrnttn!g^#cccHGXBe8#mHXrD_t>92!4Uj`(;c|!Bd$krYo47 z{bQJ}Y6P)Zb{`rXx2y}dms_pI2T` zou9wfqj)$^mmNwGj2tl1dr<<a5CJUJRyYd?8{BoW`0HKqCDSZ zbplElNf$5dUX}2|wjp?9d62#>ofz%QtUwzzIR4U%ae_I1hCmJeB$Da!06_yZx1YHi zMu?ig*~!j{ZqPy4kv0+djNyZs0~SSOQ=a*`AQ1vG{}1UxU@;z&U^B*Vz_|HE!CaMz zL9y+8AsiR2NEQ*>4>-)~7yDZs>KCEy8czi1Ua&|?3D^1=_qGUCu_Ths`ss)7bTMns z)-ZPOdJGcI-hK7(>(lz#YPDh*!dBn9sGJt~cQ;}f1p!FPX1Z%Yoc2}>a|e#Sdwo}yuYpe-@b7V7|Ln{4rBpS&gMF&WVJ zk-cCd$fEv!2E8p^6)cImGk*H?fZ<|*;cD3!&TgR&jW928A*^ zm=(`oq1bS-6vRQ&N}kg!uo53GBJ&{!j|LtB19k`u*dZ`rtH6M*4!4`Evgzz_M2jCt zt#Qb~BFfFz*>HGFqlP~hLzmOqCeN_Ce!CGe%fSj}ff<$E!!HjbWPm~bqMAad#_kJy z1fPYJ_YRcaleZ{eK6?!7fISy{FG?tm90FOv@@2(R$_}>cz)9*{fW%S2-d#C{lm+oo z94qV*bpB@&RH$fWd4g36iT$zUZ2Cm`v{e9R!BZri7CbAnxQ^EOTyA?snY3@K|H=Dp z4VW-X`Q@Pi7F~)p5?p?#+6;rsyc*o**a{JpA%TyX0nP?g=yvwY10zTW5CcqGA8@5@ z)^8*fPH0T_@^?1rX_fL=VIH_opbm71QQN5~@XM|rC8SmJNhJy-bD9qNl*NM0iO^<< zg;p_2_X%x%}7bQH=N=vwf6UeJb zcEfQ8NKuwFjAjCoPvG7P-t2<8W1>f~NBO8vqN&)=D^xPszfX|2ad3XN=BqN^+{Dy}15-A#TfP0Kc$z3RSa42gx=R%V&VOv5Dq5$4E4a{09LF%18ze2x%-TX~^zWHNjm`i$12=jx`2dcENR`EY339szmc z1nj|%>?>R4sKkL{Z5a55x>J}?z8$Idk&BMBmz3mldn;+U-B{iH$T1rHMZTm1U&?R8 zQIwP_5Xt6?M#|w^5W+^Asn3`$Vj%`;9^i$vsg=RFjagj=W|{6Nwue#Jw0RXCA;~5N zyjw1(piQ1>&0uzkLJ}yxPTP6PvP5bG-7hI8oo_anQFM}U842Hn{-Ac2?RKKGjH~h- zLA%QV!+E}2^-?0bvZ6m>xbx-2n+!Oj9XNp(((H`Y4)A(ulOx-6(*KXPD}jfyYu`v& zv!pCVwic<(V%8FoH7TW(tYc}nkh0sC^?S)EFwAhkT(vFJAnl_bCl$7;|`e-*pU%nO+TYR!euz&{t&*QgdCcNVETv650`8N0RY~m}^R3gcLl~KDebyLBw zke{pFZ1$zSsaPD#xruN0we3%o4IUe~S=wgAva2f|_Fva_rL*~?EGnGm!#v5S^_G?f zCYaGM6{C{nz&eJxq#g-VF;*PIVJemjdE%JrX1qgSDn?OFfS3BKd?}L|83ypaAC6+y zXOY1%DsgRqS0)Svdo#u|3b;T0ugvRl47ueE!w(aO74Dqqh5>=8up~f(2KHzON=3pD zSlSn3=&-#Z+2DY(MWfO&HWZ?bHHk=5rhq6L4nrA5TVi-+c)zf~Wa%f15n=hNjNp5i zfqgL%LsTLWNGzF7Bhl$pP*S1bpe5|sh&E^{8cik9FjNB7hB|6r%;?C;noa;3lQOVN z2DX<(fSAa@RAXgBPo>~7RJt|R22Ug5@iZG6Y&5N5Z)roKDO;1Vw2}K_M&wP}a3JU4 za6lLw*k8h)Scwe#LRKtib%V(mE0eYy_H;Nhq>c{6Ie|!q%_WW{%UO(b=IEZZ<-j|_ zox4{#LGzyhO#*nBZqJ=ph zP1KxZNjpqv1c5D-G5GG^S+K7zQh zIJ4k@^!gVRVevVHg-INPaG?zaGI`{r$b76$)aOLNdhkFlNBFbgXCUGM!oWt9?fz#~vXQ02VH`2Bn=K|=Wneu- z{0G=gnNbIIz*`80HL@Xe9hL}K`zSzZSSjzZT4DhG0*dpfmbhW%@5X3JfGC0EhS4A) zZdCcY5!S*H7|`J%ct=``1MKi`K#y@xJQ0ZWI8d7#-Et&YH{zcE(sJmT<5>3u8Y--B zMuT;@VeE z^RJrC-KOei{5fEQRCL?gfG4wZPE`}F_#RZw;5S^UF}1X?RqsfHT!XW~`UmQdTV11tFPSR`cvNR4TWeaeCSvNf2-`YVC5KB!=lFvU*(bSZ$#C z{t8L8>`Tj>ncTe=Q$sWwQw|({U7U3(Hkfz2?@irQzjb@XQy$M~z3Zhda%Mrh)ALp9 zZ98@g&s$uBgg1?AfKb*>Wrhs|Q!&>Ew%(lZ!KE$}D+uEGxKa zo6EU{CcSEDGUbOgPo=&qI{)PTetV11=I5;?1} zw8FFampePfE2h0z;<(0Fy5`35vR5f;eHPX?BYv#fs%9wI@^XvWH+$)ys(Sfoy!ce1 zt9JYRxJmckU!+7EXCAID*&{zgV@44VEqHg#j4!PlWTcNdnXGW<6A6vrcCq+g{6tIo z1eb7x&{-XqrQHk4FMNA-_V*1Hng|uEyb<~V2IR6t*-9@VpwpU3hS<4H$8<{LIJUn0Z@)M4yhe^MG z27au$`shQ53hG?*r{bNrW?p+|(UXHJ%sXK0-{w*7_)7Ox#tpGgo40=blWE;tnN;JM zxcYVTQ|r<{&a0cP9XEGnJ6!v4;NfA#Q2hY5$9W;n>hpF@FRO@NsIMt@E?rwv$@^T* zX-Rsaxk>ZZ7lA@bG8SbQPdS)8QJ>>Se*Jo3j!{Rv(Ms2OinEm264};?8f972QEpL> z+n4y z3oDXyiyd|;ehKe6-=w+i$gI5HZN75rr$r<`NQ~Qa{@&}frm6A|lizQ~Kkwo5 zPEOX9c_uvjfW%zA2M!@2Ukx^hZzFH!o)ec>Zd8bs`bv(mD=iS=q?gziZTDYG#aDWC z*6&+!LAvbc3Bu=sy>*G9lDlN?2{+20Udu;Sy-WGL$vr!#`+L)`%Bp69mWbw}AKz-l z4eA8~GT6gsmcLU=YFyQ^QtjgYYB=ksUgJuj@7{HyycYYN$K~1i!yU3)Uv{}IZ+5Ct zzW;6K>BQTo;Q-=mUt?$caj}YGH?}GH91prNpHmm)o4fSP6BjlO)DKRetXPyuuNSF~ zH;8Ipb>sf8_ukgk*|rh2Q`B@E)uum86YXmI*!=PRd=0y+53YQWtmmc%&0Chj!+Rxb zt^3c=EB=lr**?E5n7w~~NVc8~@7hmy-Rk0|RXHrz1bpeb;?nhU&%h=>4+anzX5g|4m&UIyA1KN3GmN{jI#X>OC{HUFfoJ z-#(=5y4LwbT2n0$gEH>><9=GSfbEI2td87oRB+Q}%TdrHf|2}v=8p+IG9Q@3phw(5 zA%}6N$&Q8|aSXX)fE1ZR#_-Bq-Q)U&zi>=(GZ`F1jSQ}1DxJV9vOYrIGoeZ(cZ2!9 zzkPqo%}}Ns^Iik%3l_J27+_J6;g}uH>4}h=1_&qyfgW){90brn3GV;@xP4-JXQGxX z!)^sAIYTT*vR#lB7>kyp@s?C&8w%QnLLvaVL06^|sc2;~1vamc6#_}C)+4b~W_M21 zaG;FAIvA1>aU>-&4(Lf35^RD1?Ulj7ZioaKg5&i$nqWz=0p1WK*xKN*G`tOsY@>`N z+t^?*7&6ekh`5mi7iIvC+j6uF&~Ct*4Rk7G)Lcr5G;5ZWLC3nUFB zbC8G~%7#L%v3K5vQddzyAt8xUr+V7EIHQbEn>Oen|5I?H*gJZKsU?@Xt;P(6@8qt;NY>5d*tDIQCWDUM!r4<$QKC&!V$X6T-Y)lmxK z=E?v#GE%aYAHi z2Owz-q&WkiG9ucP6ygPb4^g3>V8Dv^k2mI8)VSb7Y-57y7> zfR>2E0p}JuHUi)hkPb3Hr>w*|tDy8q-Bad*Y&@*Qq538Owv1}{59lb&Lqk@4V>JXE zj)Z*MNPGu4y%TH+q``l0NdRPs49A0`?g?4F|Ird*9plHyi$-wIzbo4@ekb9dT4F|~ zH;;5Jf{v2lNj}P2NFe|Bd*T6$2i=e{@WNqg_hVR#2ezm(8IbLfy@JDzKu1Sfiz6VX z&10}cal`6zjB(F@Y&lYLchoJF5e_@Z>x?uO5tsSbPJy2Y5FuPOy5$IPa^yY#u_bPp z%Yl(i|95LKL^uqBMd?Umnfs%GN5FsMnGn7V#xBB3WwE#ljzMT0 zxYYoh3Hbu!g)=iuoDNpwgnCa|#_SZFC!J85o4Odi^4pV{RUFN&Jn?f*zt4?d&`Mb@ zDHYaN{3KSg+P#S%Rhme=g_9d)0~bhR{Z`>E7PF4 zy85T;(j)V>CUxD%X>HWxQ;fS)vqL%ewtf9cuMj=!{Gj7KKlx6j-F@O>BaV^U^G9Td zmFA7}KWd|m8q_kc`&^fvy&^MlE*ht&{+fI}iJ!7)%ZjJR&%KKh-2Y`+9x6Qbfw)`r zAN$jpoDR73?-AM{kEqq1{Lrd*&Bf1DVg5t~aXcfpbH+a0k!w+=m3~!+y8`rD*%FmNs8xymh_(wxti2q#L^>alTlw&0uqDJ*_UY`B$5fH<$n3sns7cd6z`sVz)lx z3G%xrB(_DJ`=y4V4&S2r3A=izZ54q{uG2rOlda7}(nN$Wv@2e=ettbO^2$r>qH7No zpLQ4&s?PanB*%zE1~1pIgLoPTbXe|+WV8H2MT(7V(YbTF0JjAx%?vb-g(i$pdGWF z1$N6_rj=~0?g?ypbKA*9kZ7InSXntYpy)xc__N-GXR$L5+rJTgLYeYhcVF)17~a<9 zB7zwb-6dS4T)BHGNkSbv1-;U1XFqq;3_)yF<@K736p6LmdfyN`F9_QQqx>_;k#b9eMm78P-4v5 zU-Rs7g~?X$#6u>pBs4unIRW^0?iG! z#fp*B?N6WL+*q$v-O=qX^P_&5hHxl1d6vo=(U+nE1=^;^-3rcMnu|gyojP^O@Y>^d z?^gILZ1`RkxVP;cyHuSe|GcR)l{JsPG%(IjukLVC;7*YwPK~)i$&e8J*W>M95c?l3Hn}K^m*m++8U0y%gGMXrz^Pv37Ty8o@GRzT(DB#Dw@s0 z@faI5Vkt-TdjhB3`%~({0>8a5+LmR69Tzy5xrT@BaXGEU!Qrw9&% z&gTx@rBa^`>?1kw&!sgq6rNKx*n1>j9DnOI4*x*Nv`qY=Q}T-kD?(>WefLPlIBTD& zSpUAZeWhKn>r&ED*WkEg8Ui;A!osSnH>2K|y{S|EDpKIX-x{jL>$Y@l+?Fa1`EI-W z3;tjteLp-)~4SI=LZ<%wD#S%2>QfhkT?x_@s|xbuAa z%Efu{3imMw4)Y6KI=IB1C;ICBD1+-X{;P$tZZ%=^ood#~wyyq)IrL?cQ<#^(MbM)mDh*|at5*XSL}{SI(_h* zyK`@B#oVOX6#9X@_`JvG5}}SO-&D2ZQ7d@GDy@~z?6%%`+TKpzKRZl!mR1Pg$Hsuv zi?Y33g{yvjiwrj|N)efQ?_h@N4EDB*Z4O3Xx9Oj}(!QRgn=I7UwDpa`@2llvX9O!c zXJ740EU&<~r*5^h`(<@Gjrz+ZxJGYZ&<_hqwJlTURJfHbBer3%6mNjCGT4IIX$<8A9Sac25h~*sjnlf zqW5F&O-&wDnJV|~`)#of6%ki&xOAMC`LsCDpserqz7u|jH_w@~>V3vjO-s6umRYv{ zJoTDQvgQSwdLM>|d%p2G^QYD|KQw5{4zpuyqk+?5f<4Tw(g@Bb^U*vUIAsU~!Jj4r zoHAs4008aR6U6oF3BoEERx9v##_|<;MOH7!Yd=S`UtbWkfS7;p*B8X~>kAG8OovGW zvAPi)Ae{Ua791d)fRq_)!h#6q!5ZO&>6U>7(SMr$5AYp>0D&Bm55jjq{sH)oFoY}f zU!d53!*|0rR4kebfG8RS+d!`kHU?+_$zkIPn^y=5JW_fX5)uDyTmQ?_e)!JE$47~3 zXHRk8rey0*r#nN?BT$}_*EUq3hpi{Y(~jbVqPn=dczFV}HztHPYyRqDesH z13|f=K>B|K12~;kG>I`+PBvVCM1<(6BBvJ&I0;zxAhbGk3i)rtS;dnWllue>A0#=# z0SO4N!j5>582ay3|5(GdHVMGAfAx;qTHvu=~8T0P}f*mQ10MCFChy`PrG7dNqq0bFRW=6II zKw23Cxw<344j?-JdrJaL-dNHYbW6-IK~4mj8F5bp79%NTi2I2ZhndxCEf^n6sq zQRwH0TjGEV4s|KUYB>^T8_^Q_fZI3@je|A4Rxcot%Bq_Ob(hqN3AbTz0f2u!>&VJz0utC6Gizp*%gX#ul+yqMNy z6LYAXH8TJzXJv}bi6;jdEeWHT9~Av^?25k1&$CN;U#*{!xbI{oHnXMT+XlH=s}Jd2 zp3ZUqnx|*Ui;p=o{S2`DLGwyUMjEn3+0Tynh@7a+{~{)0jVgKDS;N(RGrs%xi5F|+ zmtK4(TH(d0^kEZ~;!`TwT6w}M`a;L69hP-xt1D0Nss!BL8dvl}%g?;UX5Q%|$Ip?^ z@oYA_WFsw#T6iJqNcC!wH8TpjD?Ze6oiN{dKTae%zF6xQamU>VJA>=FJQtn?n5LzYn8!%0ST2Xy+|1#gO^$mV6R) zQ)Ar^|Y(!aKOvp6Z%QXax2_D?0u*hvD^IN>mGBzn=O%c zDnMm>Kqj~52T6=El_XOcz&b_#o!L+tTcNh@FyRQtIyeg1@C(7 z;~Dm1@#!1oQ$2fy%Irwhsh2igwdmRQ^@5#hc{Tm2vp`(6K}MBiq(esSnM93QI%bQ7 z#T>k5MBb2jXuibY@sIOZc_n9xo>&*Vywck5%OIzI1(Qlv*6crjL7o%7p^A8ZyGEX9Qc4zoNqeI2mJj?NQ;!zQ&jm9D!OXc}rXZL(7tH+bikRvD z`)B*(=U5GqBMWEL8!l>)sUl6`JDO;wj494nU1nV`YJ)o=mRqvdB*paWdv}jll8$MK z`<#mlqeUC{GO1iS6RWYh%@E-E=`|i*L3;QS$~Bk zzp@u7$;c5t=$XtCdU*b0QVq%{rEA$#ulQoaj(aNAb7d&RqLXJ*vhUQkSnW3qvaGF5 zdz$NRl=EEaVn?o1#${(8x?6@|8&As0HSUMq&I^4q6I@ohvq4p{=KhCzo@X+m70G%Z zN{>pE@orS*;fj?jtbZj%cU~{+<$?|II}|+Kbc;dIrkYBeG~x6%qstuz$9P&>j?A>d z#{0PjRIJ;%@m&7<)xVMmacZ_LpNTTDu&@a&%&hv}t zDo#rkKYUa16)*bUr&52PEUYwdx0G`H-RkpK<|_Kq)r$UjktCudF%hwD@l76QJsq&# zzjJ~L^1pMr?Y)`l+ogEJuXX(^qZe7HR-MZZwF{e5Dfwirz*Rn;G%LNFT8=cr)AqN# zHljSG1wI|KZuU6)uBN2_EU!6#JGp80+iO))M_!#hx-V?@H2!IEi;hSKyyyyk6m@&| ze9NEfAB2kqgjD2xUVf{q(|(H0`4}sT~?UFqkzK1Edrx*zwAA+k(CIrR-Y0t4dU}F{ zvFV*IyPge3y&C&dEd`}gEV+~w>xywFMHg2~=7vS~Ji&&|*rc&y?X2Sq_(ids3I&c_ zu|`>?M!vu0G^^{D{H5$ws^=q-`&-PiJeB9Wf@oK4(=lY&9Kpf(015!v7=RgJS=!dID0IaP z!O2>VhlE}12?S2^%X68Au8^$OwaDY!F@|ja$DBJ2DF$$Czfu?ZXkM z+dvr@WdPYA;|fI12Fk#IT0T;LW!wX9Q~?2mQu=p?F;Qp=bm~EU4Z#`)%D_M!6hyOf z++oRj6&S!q{}+}cJYX~sYzM2rAjKje&2-#-J%K7P%!kVaqhYWL3_~`bVfsK77*)%n0;3XsOiN_HU6^K!w2WA-bIA%jQ zhyY-2R7*tf^51U>uo>`8N3-d04CUW}pc~_!aPR>z_gGo2!*oW+Xo&^hB21d2vy_L4 zf{f7+!5^WB(-^$1VSwkDEfF#~q;!nJlSU@ej_eZ*BD+ce@N-m4R@ME6C54U&MU5{( zbXYR#0Qy7*HXGwVyeMs8<@B$)}9$q zv011nigV+^%D6KMjb&@!;k-(>Xw8k4v6}ZlR8IejW`W+F+i_0~R|${{mV6Ig)b{Gd={`5_O+>X^IBG+IdM!p4%irKi>v zi|%!nI${+&^HSg1x?2U0dGBpky&EC1GapfW|hPRjDnv>V2BMc+j;*XoZ7`*y+!KZqia>#|s21Cxa?>w@_)virkkz{2dAhE>xOEfAKz<=2Lwsv7){2UGIaaQ`~#S)8}o_ zx03hzS(we3vSvQkg)O?aY zRbgjL)h*Wl5ZdmYlViG5L>C=>nxOC5W7O`xI4ggb`0nn8S$+1$E^IbO zoPDS@FM2V>;dPDKO3ST!kNAuBtL*MIUA_Bs@psW#OHyB-vA+4e%xY2f&G2g(r?ARa zhpb3WAK#MctyjfW>KxYkb(+au%89&Dld$7ei@O|7J=ji+X$S;vW zUEE;fy32f})vh^PJa>ggJ`~>fxk}jii|Uq5VejT}#ig%Y^io)QE-h;R?zgR?lv`%E z)b5ZhebrYAgi?>`3U1lBri!|F`&_=JudC-J%}AW%()xn?=B+8pHLmw%YIJj#DxPn= z`l@+BZ?uu&>gSrSzM*cLGi>WNz0R4UltDJY+38z27$t8w^kO=Fabe@^%fHI2d!nPh zC_w;pNf?zbF+Y2kTVmB39xPUqtM(gPyi5Wnt>X2^1+^C*&L`AfxfFFcx3jZ2e^yz7 z=67{lS9W$=JFE4!+=_Eg$|h_(dG;L08)p9IwvE{Jwza%C-S<~x(}%K@r|6B(qhnm9 zamf+cB{q4K<8`!erS5m{EZY?urmsMnDg6F?Qj|cF!Ib4|pGgQC*}Au=271hJQ;(U~ zY_7YGZaj630yZS#ZO-(RtV6r*H)QTE{FJ#${8%-m*2X#arhJ39{*Grg0^x8=kFM6r z(jRoHFIom?xGc`4Js7Q8Mu-GK{Ha_PIKgV8x=FXikL8kyYbc$L22 zNMQR`EghTmPyu@SZnA{g2m0YFf4lzolDv`30u+2HdJvI=SLqQS*Y_ z$C-cpx4*g@bl6fTUXO!!kMuh+arwRH_WjwtyRhe;EdL*^Em^I6n|*d!-njqpw-$+i zf7Y+4>rth*wMFVYhF>Ka;BDY z*y|OMvRq%VXW3a%vK~2VbxNhE85M4nHu7N96u%6D_eQ?#(BJ_ogSeS4!Hq(yChxK1;AYh*je^gPwii);Sf^CBMRSV@Pcm2c>U`>4;g z6~q_5z3No*C?VM4b@)SpVh2N9<$l`Eje?3*nm#k%+qXQ~r`u-5CbbrI*HUeHkXysT zV=HGGKR4vU#h(d`vnORxN}oN*xb;BW)BN^X&m$2I=u?J^mo7*xr!>xUR|vnjYjcjI zAOFXMDdd{`2Oq!pc>SP%B7RB_b}Oe6Rh4dLi7Qla>ZV;|FDb9Qy-d}_A}#LA`9&M+ z*P18Kd~+@-<+h8F!c6LkOTiRU@B#XkEj2ie$bC+`yym=j_0rj*qrW5CZ&$&0-xX6N zNT$@(-+?P$&Y7+_Bdmn*S^mJDk4FM%I!t%5uX`)W<3vlU6`f_&{#w#@r=OsQ>W8JA znH*+N2yc^R1EY6jMC|osJM@T%FWVyuVxatv4|_;!;V&5iu>fy+lrn?hkj-Ln!lvSa-tPW?X6=fPWefagdpqvs^6?Nx`m(KG>>AU;WcW4>}h)_*V z*A*-LY`fi=o*u4>>T)>W_Bg7YEBWf}vZRR3V$zLsF65S2Ucr9j(`R3NZF=38yM63e z++0dWLv_P6MVK4Fk@PLbI$$_d$I#}OBz=pi1hg=Kc_0VOu-`xw z-(i_f0%;J2SPjCTu<9a;Jo#M{8XBSj{NaMn9s z!$$AO{wHdNu%CsLIs_#Gatn}Ipe!romw@{DxHEDwI7?eP!J0xR(x^~>77|-XR1yVG zp@MKd%?6JHTxYaThaL#C+Sx$9!9z^S{52hTILa82CbJt`8I)AB^E8gM6r>;|>38KaAYXx<}a zH$0vNvKu&*2-Tw@c~u#2O^2e)G%^|n6@iLXhB1dGfJ)nlNMJrmCTcoFDkH`Aujw$l zAYT<+%A)CG_;hIg)kH@Zl6McJVBQt_#ueQF$4pch66-`CIAnVRm;cl=wv3+fhfg7{v(ts z2Q6Nt96KBk$iVcE07v5n40=X3MU-QuxR=iJ{^iWPBcn^&>I#LGPvno?I8`XP|dJMpTpb*)c)qhJ} zQ?>t{y1KFy6UWW%;r@F2y9!%euiN6;BG}X4&f6Xw%A44o%n`aWTG2b&$o`Ke_cwP6 zI!G(}wL;>mbH12Wvv=A3=)Iw+#(uy_;(+qbc`@0mENZK2aq;?=VTBiHoNkLHzBO1X z*>3)!QQG~HE-Q1|r(NhE;d%7^gKrIaW>Ide5)NMVC`Gtn%f6z}f`zj@-y8GJ{l%_! zgq!c4$k$AS`E=QYC?I`%3RWai{()9h<|m2Ny9-r2^PM-O^5^Dkcy-E-b3+RCd1TKu zf@$;Z9;Z_Cx!zOX|LN%s49Z=c{OoBV?{tSl{FtSFW>k4$ktFh5@3iD)GAYM5-Om#^ z;+ZCmepknt=H(JaY_22x;qF)fHqYrO?p?;WB== z#^-yhT})EvbIkX$u4RzJ<}ckAIWM?A=1BW<%+sy$wdA1tX@}(RKC4q%dnUZ4wrr~5 z{rIDNiuP%u$BW#Ie5#(EsIW;vLVZ}N6WbZTC&9`snE9;trpA+Sc z-O^Xzdvz^e<<8R0>%5&URNkOZC@0N)6oXyinMNVW>Lzb}6CSzU+}XGoSCL`b(i^q= z*+z;#=iJN#ToERZ?!6R^#Q2Lw{#eHM=a&4EGC67L+3aW;XX;r&+v`8eMSoyG`*^s9kz16`7KWFdN9Lb#A&d<6} zUDK;#W2KgS>E42m%qAKjXuyoa6lFghc2zCklrbo{cr z+YD;o863Z9pn9(iJYe>w%(Bk%SxIrI&IyGdxOkreJ2^?kvog_y-&gc839AoYCAeuT%#Me{d4@&rH;3rZeL^m#nA^WqJAkymu8tAH)l9+;5f?-XgVFd}H{wo2tuC5LCA}Nr)t0 z5|9>`Xi`v>dAVM4N#**4=!g4a>ocUz6&`OM-o?rBO!SD7SM-a;UMDIJSACLN-zfSg ze#1jLr&~`EmC(F=9{t!O-x-pMcP%!VEUwa1ZArQ2_r6|8LU_l@)F+}xuDD0PNO3<= zv8fW8euSoqNYlJk873w5X~HkIE^xP6&*RP^t~dQ;&B5Dp%F!fgrK`D8i(RL$j`N9s zy4X4T#o=F%ND1k4o8zxN;PkYvinUnNrMOk9b&;fbX5oDkgI75lU)r7vKs8Q#V2=`s zcirOJx~eZVW!=kJv0JD?7DBrEmzpq|@(DBiwmLtpwYDUb?v=8xs}j6}I-VuDq3_;z zj{AHG$D`O1BocY8ADlDqp*vql_IdlIkQ(r5M~_$5>j0M!Ipd(;Rc7&ZL0y4H&bd6P zy%nzy-VI{ke-^_z3X#MQQ_p2CBS#>T%=vy8B8g|H{Z0;%#4{9e0V!l?(IBt=2q8mz z1$p0(FfueskoWz_B11m}dEbvP_AB?{`<44(!3~cm_?#i5F}x@U^PZDk;0-32BAH8| zTn5!_kz^k{Yxn~d3V=}2I6TPp<0y0jh{a*)%GSy>5|MX=3X5iCfS@p-c8Eq86)dwGkwr5=4$uoYGL1?hVySe{ zipN{qfIK|t?h&Dq$tagjX3-2AI7m+;LD7bO%V8CbhMft^mXG1l{{;Yn#h9Qc=us#M&X^BCHlW{d;0{7^ zHh|PDT0YvNj0eU9?HY_xsJ#L7P$0NNEmcIg3}7-CUf`7>8K3{2Mu{LNL~AI70Y!$b z33ws_LxH0g8!8PH&(Kh?2uG!jLQWXZxJjE1S$J6Bfgz7CWP=XE{xHmx$4|mUVgdO0 zz`P=(i2&|mh%_RIoI>dw8VIlwLE>~2jK+8UgI=@1mV{{T(nLr^?umo!xIJTmq@iru=e*!gtlt(QY7<$PAP6zOXx!4;A_yS6| zL$>&1wfv{FT>MD=yOH+<@mr(>&uBOU;jj(^LPoVj6p@jlDx)Bjky2|TTPnlz1mNw_ z4Tlx2_-_OS9`2B&%UE5Gi_?c3sr>y({YVMKFKN6;$w|{{XUQDlfR4?d*K-`<{}!jy z>~FpJ`Rp)!mO@8O}R$b<-KreQ8^(%XDvS!Ej`D=TF`vQNgZrH!~<#&-k!ROY+V^w&=wXu($-6}UrKA_s?*VpJ0 zRMDt8TfnT5)^~c3sjqV?c41d_&}oYuck;S^G-dUuSv3E`uj9~rxC-Zg@;v(*6?EpK zL?flr?D`y`mfbcTpW3seJABruwQt-o=gO^23UB44b4l$WV83Q^e$*Usk>5vZ~xlWb1!cywT-*8qb_gzicZSgFIv7f z0=;s0ZkcWc-|}fPf&6}@GKVC7OVy|Dl?rmvRbQVfr|+Zf{v}lDC92N6Nw_)Ev^HT; zvqVW1+nVjCeGGEnE$DpRDp;i)X??kB*0Z_i=r4LHKJBd)waInsz8V+#Y6RT9PGFOG zc)&+1z)(e7czLfy0DSAFyq{*|^u;N6swjdMu9q{8-z^I*0Sl}IZ-$DZcwqzxOQ1BZUyW zg!PgW1f@(JsfLIoshz6@x&_0RzvOfzZ?HNf&)4gvLohigzuNtGoax+Po#I$rNgghI zJACd3pD%>Z*AYzaiX_XB4n4m~7TvFWpYv(n!En@Zf>pr*UU`0#wzS#TijMK`#LnkF z9#>RQ)ZQauWPGAdWk*nNXV0CA5=-gZYG<{Kf}3pxE<~M2Ja)@&Yr{#$=hPR6RKsdr z9;?kXkkCqBFemkc>@KnDH)^UXYAQi~w{mX>VBUXesczqo65PKTzS@_#3iH;cTw%M|D2sH=Cc%KZ!yDEsw#eb`f%E(y zDa7JkytS9vtuK4Z-Wu5V=Tq(RD4#@MF4KfPZeb$t_)cZ8KSGDyvKOa*{2-~a{Nl3C zvulbKB5yc|P0Q4EiS+K?z@{zEW^{LB_<>gF&1Jh(QCDh07KrW8QG3=FouC`#E;TFs zVnRw=P=XIf*i-S3(dUzFp%c+x0_t$QYA^D_iCS=i)E=X0)_RxOBzdm2->baA*b~Fi(E;` z&N80Uh#6~ttD;&$)@=^Tq<%AaBolefpY8mj_ZqGBjd5AI71F4f<+2KrsRC~MWbTWB zF$ZG!{oGn*T~l^7ehzP3fY|aTxP5(jb8lmh$;JzxY}cO%yq6hJaCu#*0;MdIaf{3z zRhQXo#lOgh+Z1{KEXX{)ex`jpn}b7<$+5lte{! ze2KMuxGyliS3)bsxRsYTLFQ|5-+#51QwLt(}$H@-`2boL+07lEs*^4^v6 zWIexqb6S1GRYS`PnZ_?jzouV!^GQoecg{3V_sm3T?~rIY-LvnF*19fCeJmv%Dj=PU zH+H@C8+ViAg7bDPSpC{*-D#i3E|p*Si?5b>c0Z~}5{a}jxMoma%zKhfjXf8<;mIS3 z)w)W^^cfp|YjG?^F#M?GvR(^!b>URKYhmwYx8~TnSA6SEZ?ROjbUK^1;mOL}x$oJ1 z0!854f1iAVMb%ByQ2vI)`RaGxjRA8G%5QL!USqfQjeL(#2-j;n!Hz_p*KLXU+-jmf zzXm$ShDcvL5awKSV|uGwSW+baK5Rg`tW$oN?5waXKCQ;sz*h&HUedS^eSUFN>-df& z*)Q!}!UC2Ur~D(bQ?Y+JeL>ya}3t1tapN>4pvn{&4dpB=;DLl~Fu+L?`eMp!M&mu>E7u&mUOpOd@ zZp&Dh_iomw23)0wS8GG<(aZ~<;vOESovpypO3UNRI315}v^t~*6XwB8lN7yW=H12S zrr3+W(jIQ-{Ay}{EyG^Lfg@8z5&a}_YTr$r>eN^A_Bn0kXR-o<>^;gKH{bY1X1{z> z&NPH^|1w#We_xFAulg5H_TBEdfQ0M*z0bGj=Ae9YIF=WSf2DjC0nXDL@SM02rTW2= zFPrzu>ZV|n@-8@bS1o95@{)9w7#sEqw%Ph(Xn^_o(pSlZjU$BHk~{D zPoqyE^5Fh_Kn&%-W?523hg48s6mhE7RmJp$J?{HM0duPV@67COAiDLx@BcoAjtp{r|M&GP|3NKF=5=t6%D6vl>Y1S zG$HT%zppekJf^%a46oEWMC}fK4s^Eu@XCv%Nv85}GRH|bJ%|s1@eK{J= z&Iw4-5i+K9}L zq(w@+V8a=z)S&ME-)3;4$-7>C1x`_a}+8) zDMeH`l>!BRfX@M|Br~)lkP4z`n9uQ`;|T=^#y?+RM_V=&B4V{O5gAA%{_#+~8>+8D z{3CTE@G!&T5pWVv#PRp$=otfKy`;F1FR^e{so?<02TmY(4oa3WnCh_Z7{9|t$Jk_M zfAA0Z3B*C591#f%vm#O-52}fSrFckQAh9qkN6r4jlq6XVF<9V`5&1li2#NI&QNY;)-Ai~1fL%ygBv@}u!mi0o z{h%*^g=1JaE`vxXf;}LE0JL3Lx zY?#0TtA>$4X9QH7WDv;+paXzijB1HcB^*}Skn%A8F*(|<$uKkE?ywbtb4_?+Lv<$@ zl0?v*!NGP96u*=py=DAEa%53HWT`Uo2PK#Ri3ZSb2z43syTLFhk_1UoU@8>5gMGlb z$K+_kCb8;Aj#EK{2|5l|5}?e2JdYsciLmii#=@aC>;ooY*kq=CSW?3y8_Lc@pp%gr zsF1G!^BD9bkXm5U82^KEw8JLDRDojlAgc{@3fOl;#uLOo%w3S10xpDPIxOr0#_h0C zJMm!>Hmr_Gm`lMhNHBxJi6qFu!wAfR6LYW_Qv1d~BuASynMog!AV+W|EDQlg9w$5k zz)gUdK$a;iFfila@QyZYQpCVeEFnEnE|g87*2_ZPAtgMJ(rA873L&ZLw92kk-x&5(!Dpudph zSyuXSw7(`Z=MUNiQy0wnL;4Yv2MDmc9Cv(;wreO)gw-h@i)H3O!?O~Z@gb29R1h5hLHI>{zvy{!zLq>IA|DbanVE=LVrC5eM%;=@QfV8uu07LKx~Dc zLm*%XDOgcJU&1p9id!HsF$kmr;cwibKWZ7qIAob9}KT)C!StP&e5aL&`%TtmnU730gXUZj#5}m7@)t#JoS~ zF&wN1p>znciR>ShNCjO2=uJ$*W0P3yDFwDi*LcLc}Wo z6oc~bjDG-S75)L@+2G9a2ia)LhE;|~$h-`S!gy%F0HXXwJH}`UJ4-}!c8siM2A^SI z$o&_yc6?-7K;#(4@R~Ay5ZJG6?`h5p3=FsrFOG34kNj)wj|YI8fBLu|aQcUj8I+2D z{Bj7PA%0>ml(d{dq0`>kmKUXIZ(~Dur#n;W9x|qI9ZJdB#gj(2k-?y7E}j%BmG10` zvav_mIHGLaDO68;7iW~6m$NO!-OI_5;^m224!otVg3n<^nn7YJM)bz#og1M;z)zvi1P4qa-uNIcXfB6c~L!4 zuJ$NfcM2Hg<^^Bq0VX@rQ68=oDjh}lr8+`gKgI_%Yq+DAlQkXc!`M25L5_|Tca$sL zo#7ga6a34A;!I;+>~3#s2j5Hqk2=zA`v1lJBgF&kviI1Aa&`3bfRce=4$98Y)sF6r ze3`uq4aIb!Ki%C01ztpX`naGx?V#u&%EraZ9XbI_^|1Fvd4MCGQFO+goT2C-e3v8m z&x7t{&-@qS4b(7qfN^vW#*e3XqSR3us8uLUlom=GrGwH%>7iDm^igY22B@{DbtpsB zdejD#5o#l96UrF18MOsvg4znbN1<+`Ls!6WvW9;$P3`~d!0)5l+f(h`sa{SfFJ~Hf z1N9~$_?d?@<4f_yindKACxc3 z59QCeFTMY+?#y>X?&fLlNTb6JjQBU4uq2e07dX(~*^>^v>o}xyttlRGYeyFd&cU8# z{EhDDXz%J_?}4IGY;Ec8{VzzrGk=baBi$G2BTqXQFGg1zF@x0B%ifU@HVgyTX`$9R z(QPRxcM8p(3U{WsLZtaJ`T>9&++Q1U#KHSBS`LI6^OsqBIXcokQ805LJt-(h7k|35EgfY-vxl(&KMgs@_-gAgU%fL178S1=jzvgS9h8X#2zCQ5tlg9 zosdBbk>coLi+BRY>p-Nt({1gMThVDKCkhoA_B7}w2ytXkFeV2i>^-~~Bf^~-{)6u* zR4-4MLcEaiMS;$Bwd)@_$S+`gCzVcv`%{qNGuX<-o#sUGpnActqoW4x>o?sQ=^l4z zj5M*MINC68+5bn6!EwWIlsa>|P-ohqJ|sBQnf;?a=pA)r21KcAp;ir;q{VEk#cZrK zq_NguD?R2lddzF|hFqgJc#W2)9cnG}cI%jzuVY@mZph{9`Y#x4<>ck)Y47Ujhg!!R zxto|xH!+)T8q##rU>g(Wha2r&+?`P{E}USNvv%}AA+Cq1h{F7sGNdicuP`7{5dX}m zLs1xRpuiM0;09z+LSs6!F?~p5=(_$^_RMSSnb-8sDU3mAKX?rt+~CZ-oeT4F7v|+I zL%!0b|AN6*G<$D*FwlkR1TSVoFJ?opAq~9-Tlg_QgrN^k@EiE^P}UrlQS)wKHNniI z0mz+z!}6k-@1T$i)QKE;rwqy8gCEI|0C^s7!cDW6?Z$)6FO~8(uRq}MInO6%?t!`} znWgjCHS~2kUY-+U|6;(&nbdK`^GjaD%=Jlp92?GMh2FOP)^oYz#J7^Hjt@`Y^x)^Kf(4!xmP^sud|vF--`2Wql`Pr|_ejDu zYLCd(>x<>j%Ha50csb9W6=Xke$j!z*b&4jGA%FSurDhWwopg_n=ep0zDcRA}*W~#5 z{pqFuY34|8@8oiyvnQl7mxJUit#YQ=br)aRtN{I1H38f%4R$*&g?xbq{;3LI8;@T6 zsxr-WMLA}gO4v<}m@I?OIn~Pw^4XS(i#JAwxKC-S*A4z*$;Bq#!n?D_dHQ_Ur{^L# zg4q-}XY%Jx5A_c@8}UX+nvGrSX1-x^wJjU})O4K?vlm%D!C_OZu2|XnJo?7r-0b~b zZK~{n@1}xrrcFoI2=3EJ%-0p?n4Vp9iECp|%Gw)KxOwekKWuBv?-r!rAD*5ZiMp8 z-8awWeC!Qa-q$Gd-SQ@vtWdE4}8B`K= zGet^LX35VusdxK+b2YGQ_2$T2d81qqV9LqO;p6p-W91od&5&iTKb=;yRrIZ)@9aDA zsE>V5pFBsO&WE0k`#rhZeIMud`n>sc$0+6I^5tKH&78UF(^gE$Hpj_q&TqcLZpR*o zn&Tsu|1Dt3ls@Sg8L{~56+vQMJ}yR|EwvWkJt-UXu=m|&&x|{p!Y#L$t^A2n=0C^# zW0%HHE4%b5`2rtyYQZ;iW_aZ{DomCAD?aczAlIE4v5pJZToRShiP;(`$Ek z-cHk^-b1M5^U1ae2~WD-I990@`)7&lB(!O)Wba#k@FGF7t)#$3asK@5h56x@A2MeK zt{27x-?+iKa;wI(Z+)@tg8RSUDXx;i&1m59Rh%a?ZytYkPtU^+%Y{$xyhzRtd3)fE zJS}2cj)wDvmeXNx(66QT+?v%@BA4ydE&WODhv061jk}tsFTAxnD)jJ1w5R7R1MhF> z@AkIgXm1yVg!J;yPR=W*-sBSx4W>5U~+33|}$f&1iy!^Se)b4ccx~+Vqh8Y?Qw&@piPBWew=Np|^l%N|@ zE7HPdyuT(m*YP1YHptb%peau@a#{59O@7BsCHKr(`0zySlz_Yy&0X2j#$WudTk}-X zRa|w+2^=-oK7TCQs~=#2-J0;bc;WQT4mQiPV(p9U$Tv2c7=N}?D?MzUdGw;XZatS; z!83Kgss+!guU@n^Zn}`hIX7VUJT*;&w#xd?&wf4M(y3^8b3>N(icRRlq=4$#iNU)5 z_K&K?&!>`l!qWKfPbqd?TV)fl@l3gW@T1=~>(+|q%?@z=_1anX&;JqjPEocjTe$8l z+qOB&cFnSF+qSD_*|u%lwr$(CPp!SqKDhVcJdBYMkvV!q_H5bOXqjLCe|GPR{pvpE zzl6&8?8H2hLthnkn!^gthzGTgJimMAIRXwTm~fQR*6^1-Hkq|fse<~HcYV!E(=ZM$ zm7I~yNnD}h9B%NetMB7ecicIr@VaeMxRx$JB_6Vq?AsAfZ)bwR(81q_`R4)2_SCo_ zR{HwHIC1uDh#fafR`811EZ#U3=npgKBJTOg9XCtU$fde9w9>FgI(4L92dn{On55;- z6SSh_B0&O2>T!AV@LloS>+2T9Z>>A4+LDTLgXU-^L;61xtQVibab?^Qa7XC@vP0+y zi7P=_9V_RLM$vDP5z&2M?8LDkvOHvP;0*MqpSIM>x#ykf?!~r%>{pN`~ zM;y3`R=lK+w1t9PYaZTAM8^|Ips9N$$YCZ@;G3Vsw(tGNy+pzX=t?jOuBisp(y#(7 zz1?m0-v}kbW|gJOWL(}PukvC#+$v@QKGIh|3@{MO|6dvpxSZE8=E3NOm=byss zmbb6`g}mlDD6|J%t{`D-uSdq2!mIu|!vV5$2d|3&XKg=Re#`&ewtx&L4TBPqWfK)7 zyaAMP4)?gv(zE01r8UB()>~3G*D~jdjSYHs(;o#Jj6(LH#v;`TOxC1$2TTxoePvP3 zvO_zx2jmobt{G;)g@?JY@YsHaaCvDmT*(?E{))6_1XB+sF`$Jg3a14J_ZGeTfP@nh zA>PAu>-W|oVmacN5@(7kD@<^?;E5HbpgIVEI%W4pi{99B+Wf5~>Tt8uvHaAo?`@quD^85(@A-g>zW_-`aYBBrY4!z3beu;8f@EQg)`x7 zn1Bq=c+#NY(f*OR+2}OBkkQ5W7;nUcANGpBG!l_TOSg$^6P2^Dm0jO(^}3+zN~zzO z_tv?|=wmDX^wkpq+AAyYA(o|`3rSI3mpNuT1J&ZX8nLfM z5typG-QeZ2PxJ(Q3O0uJNFpck*xls&+^zQ9X+0&V1bIvF7UU}JPX+*~R&cTivd}6T zZ};NUA!T+)blEkRqCnXLks2`0u_PjPDpH_dCW?~uJz8ob5BP4jYo0G}FBIb#m^+hN zB-edvVeSU&?1ZsfYqs~K3^yL&6kesM-C^0j2PEgiIYr$I@F%=&FpX>u7(Ejh)#HXZ# zBjs4FIKd$0s9nz6WwJBsaLAN#?&xNoSitgP7sXLJa2srnkL(Xmg|ZwJwbT?}B@4E_ zd?B>aKxE#XB7$8@Ez)EZ!9$>ID5!T&8(+S{t68XN4F0WZSRAITi|o6`tkP|J4r6le zW~W#SmR+5%d&i7gpwCEoixCgp!Q+-IsZC2x9T<45Zm>@X z4{gaU<TaWEqoS1jp`n@gK`aA|O6{WQv(@pM<;|W^D~N=uV{_ODm{gCNc&O zW*X^az65$B(n@L=AK~ONDZUcF#XlCDdFAFEVZA7DHgiY1g;`Gz%}>8JnQyHg(tBEq ze8%#8n4qOu1Lm_k8b`|6ZSK^jVgYK)GX_oorv^Dv_eZNdJIMnv!FEE{v4{G6lo<># ze`&vCGz}CZNl$Ox1*+!Y3iYgqSbM!#(zeg}xfa({va_*y7lo4B+)|5iYBm5bgr< zYCaI2!P=q&kjTn?scj7@l59-|9}BEBmuqNH+g;jct9Ltx5cJuJCixu#*IF{{S^q(c z6vB7PZJPs^P)loc-PSEskny*|e;CxIsEp(h}jWMa@_FhjGhOhyy}+pjykdTlX)$FXza^qzLAJC zVs!Hb^M=LmTn4^U5emuCOo+6`Yev30iu$MrC*NxjP1oK)ynzH)EcaAIeJT3I_eh$f%_B%4b1_X34@ijQ$5_> z>JN<6R&lV#%(`fpC|M@qmi8_}J!cefVStV+r(8?kTz?H>%ZSRFk?z^A?>8 zS?KV3xWEdJ1)oVn3vb2+1H=?c{RrAUHkK7OjT1b4&yep?G4yk5HSe7v8R|l!IHkQ3#OnTWRUJNn0)*TkR)emBtfoRID`+*^p%usy zwxtj#&k_o5yg9t!Hw`0FX)L%BlVuq0L`l!9d4(KRG+p9GcTMu-xBGnB zFYh;(&&L(Yl~}wV|5gLuU{83W0-gxSr$-EtDuCi{)Y_AWdIzbtcW*-p&_mW?v^@bT z=P%QjoGim#3$*)2ki$3qRMT!h2(|(Xs)O-%^R}cvnpbuvVo_VqIQH27POu#JdD^{H z)w){Su*(30$Y9cJ=59#{kw|_>7&g$F1;&q7AM4Ch{%RKNrd3`(4`Wo)s@tnGXo5wa z?IL5oJWR6tZB$Au2Dk}XQ!r%N?Ts^MXJOAE9c;cjZxT?GBLQ>cS6_Ior$e{G6(J(YFqm3Ncr!) z!%>AG7rsN?5TrD7J;08Z&!*{8D^X81!PvnsTgFmAQ$_WQ2!y*CVO6#nWb-DueEQP# zr6Yl5B*u(r$d)LmuTEK_+B}@HuO%z_EE=?rvS64ijToFqVGO=SWmckV_?4Vka$!-Q zzZx`S1GTk_&#wIY#SA*7NcH1ZnwP6+edHuU+{#r1irkSo{6aDX{b%M<>K7TipO*FhwT6q9VaCDYwPU!&{_=}^12vm#ul%H*R8g;_b; zrbq)1nr7JT;lDi#9i7gMhe}gI5;Kw}4!46vUGZ5r7rlx_JKY9D&@rpi44#_1S!Pp2XdXqLSs z5z1wQ%?PDL8znS#)ifQ1{#$I`lI}N0B%ztj*$e@s@}ydhryQGFz#&-V<$fHaM;Mq} zp%UTz7K7k&!m0FI5>o{qd0usah}TJVc&sQFsamy8nQkeC{`la&XlpFOKLvuDeoLTw z2TU=NK|6?SgSw%Hyb{|_=uKo1Yfz7u1dIm-b=Y$fVkFLzp zZeUUl#fK_AKrU+NV@D<*qkW=d8;K;RBF?M@l@}424Q}VTTROG1?4l-|15Y>=ytuC} zzf)fqVn3CT2V4`K84W4aA6iavEP)vfgP<&(td>Ql!>ZvRX77~vqsqzn5s=;$Y=vefd`U1TcjjhqZO;l(9AyMvPVXQOqz5ApZt8{LVSQqC1~^L?MMEQj~4 zdK7Qe9j;6O2c}b*1LyRsB}VsvEyim^kFbs7@hBA|6pX$+)pZCmYDwh>)3vTO$Tmr3 zB#^{C0$>;uK)?k~|NTP4*31|6Kc><3zPgGdu^yB{=WVS%-jV&p|B5G*Zjhj3eM~Ky ztwkUcJy|C0>5BE^WcQ3rb4rM4y?5J%>6-jF8sn6{gJYwqOVsn&gk~PzTe$1C;k`&xS9oQIa~P zb3$mJd$+3L_7r;&tFE(}#bD=Z^f0zJ&B5;?e9*q7aCyqpkk4;C{H32i6LKCD&kQ5;VOQb&W?Lx}Xp6Kxnr; z7_$t1Wns*!@DxK+2xJasB#_19M9p*n&V|exdE zsTo#ise#n4zHq0~;@S@XcsbnaY%%Wiqma11VxjEaw^#Gaq5o>Hqd(y{En9=dE`1At zWr|{L1-`OA{}zY|V`Xk?!jZ@LPJ>(RJ?14}c-q=9;vV7(hMwVCsPG_tn14bAa@A&Z zRf)|?l}mUQG1a0{X+$b7y?wj5+Igd55~A`QP*o}FNSYF9@FxCm6^VY&*I+Nprm!Kf z9_qO!Y8vK9*lbW=lN1Bv?83SLxf%Jji?k5fYaz`ZhpkLuI1Bcxe z+Gb*01_d(ZZoQd~Jm=T>Iv*fnsca|L;SICl?l>N+bMH?g0rB-=kz%?4K4h)SZyU~0 zv6UpO3|(rEt1<&_CZL%#$vo86Ldh3ve*Pl@%1ixTqBvxsgy}PyOkc&AQx1 zusW{Kaa#OpqCR-Vi2WYt^?*@}3D2Ux!~|CI4J~y9`k=C5reY7?wJM$n9ms70<>$LF zv?Arj#l15ns-%@5B9it!0i;yb%0wZRpW2v&@Gk_LXFH5o_j6y7Z9Yp@+x%wT9modE z)uso#h|FFQZaS>taPC7;+`tDhXZo-p4aQ)%=z3jo$(de`Hm@R2#q#T^XA`Q)n-wHo zZ8oM^FJBWJi)gK7hddZr;WDav^<`)zIV7^%>N@&2q*P(1D!)@FgNSJA?9EuDZ@t&K ztImC?*877Zt>56F-t)4rjiTDUdz?VdCVyq@Zf%Rjfe-;ZruK(vw}0R>OFfGv-PQF! z+kT**FEdj*$Sj94&o~Nuxy(>VM(D<}wyAmRfBKFkZE}l4boS^;DJ-V8c6{+*On>Sm zKCVcLNX6Rep1zB;CiIKBgflPKzchuz`-5MGu7t$+je?nUZdR_G@54SmaR2Uu&IPik z_1!L}e!D{$mPiDm+>bfLB$6}M#;M$hUQswFJXY1_k+r=a1)JJuEDlPUlX>@%54H zSX0{-nL)_SI}(kvOpKRYWb-RaC(${efy(hn|B|$MZJqj<(FSMfxr zL|B?UV7R(+G}Y=fH*S(~9pu8b&D`5AUexH_QRV%L<7Q`xkV&-ZLe`3Ud%Wre$I@{H z0355-`QgN*)*hmgqKx|Y&K!cAy|2E$L+#SdRGN4-4n#N z*$%u3y^&BnB=1Aw+WMXs7H&mvb6d&%RYR4!fa>rNd4m3qs-e*yg-I?KO3YhEH@^cR z&!-np0yFly`f?#6O=?C=kZhwx5}N_X$o)74^!tE9q?&lTJXbZ$l-Kf}2=jSb#EexU zn<)Xr)e8(ex?JvQUK@j5o9p$>;K!r*LWarI(8-Xgq^>_^_G*Slz5S~2%l>5h&#mE< zF9{156zWk|F77h+9#vqKNzd!1>46mE(;*@Whw}Qj@{>v42~Tc9w7+8l7gt>F_z1Mw zGI@cnJMPm@3?KdHH8*}qA>Qb!9d-%*kqTK7p=E8^N2ZW44a<~{ffsA!CuQhYOt?fO z%Y%;QHk4!c^b3t23h@HA490>)UM`38ByAYA!>Gb09q8aVHG9AZJwi`wQwwl;ystWG z#p0p0*7_1jWT301gc%i0g)vuixOBXV0)>kXXU9aO{#}DN$EvJFNEObYOfz*r`zVWZQ2_wG!H=L zTyYa^LZ*y4jpA{_WNl}{ynTpu(-Q5)Q^z}6g>(SZ&`KE{YcNG z=GMt&WPvQg&8`0-M{`8E=It_X^0C3osB%(7%53A9Ue7#5hDNILgT8IE9;R=uBSmL^ zNwZkxy%?lZ!stmmy;>GjyXaWIMs43uupfsgidXN6zX1uhif?fObRIWWZEJZ=1B0QV zT_n(zQ}GTP4er7eoN}azxgWPbAc&j`OE0bv(kv~z*(qmpx?F?A<$mQge0%r`h_;-H zxZz=^4f7}tXRLm(JUh3i`dEZ#0L#6JRR#~jhnj(Z%f+%gz5hM$G>YLA&7o|vV19FJ zh7}|!B3bOtPW@_aA5B>{${dB>>pr|Oz2n#Rh-Ncg~i1mS>c$QSpjU4Gk%3qrk9 zK}6Vl+E5%=B1SzD30lfvs9owwNzG$h9mjCC99V@*t&ET4+wx(J^ATe*mr4iw`vS2au(Pds^k&>z4{nJ4;Ng>$!=zHlU4|87zvwC#mDhP=Qh>W zFpzxQA9bNntxi$np-Xr>t=fT>TLzm|Tb9I7&=7}~zbR_N=hXLof5kDK7p}aG6`*Ae zIVa2{bgh)Aif1MJRMK2|25yHKR*^|th+Y(qq9o?SXuVu4ehWPm23|<>=BAG>PdG$} z2sRSc$$vV-7Wt=Y6$iD4u(NIvBM)k3FP6iV4gS?#J+E7y=i4LQR8(T)UGR|;<7)54 z>Om>h^@g`C`&y_K?y3{@maL~}phDM)D4BBn9ni3)*0>c{A$*4mQl}w*f3)U1!2^U1 z{7pdt&`ZPSey*XBPNI#_U1=M=>Q5~_y?*vsugj_xoy6d^3`Y8R?dseTMV? zxp!N(DA@B-<%UXPT-k;r!Bf3sxpqSiS1*`k)zJNVVyLjE1<93aJO#Xm2^}J#nhm7J zbotlmDKS^Ktq9(uuG2lbY(=p#oeaI_u5F2e1~m(e9H|Q+ngk<%J5&SDTSGz?Epn4rkAy`aJDnA6orHg zdV`!(>2g$q;o@*-gX^*HP|^I+5%WPI0aCY6R4z zR&lT7X}W=}c_GS;P+(MlNOjb^_Zr)EB!dO8F;#4|UoXkLb;Jb)I7=(>yg*I$Y6e>} zFCHtv7M0yu%PF?Da1QHfJzY}Sl!KOK<^>)w=h>~pPTytJBtG!0E0#`bw<;KA#Zxyj z)5V#dh?w6jU63N3lk?6 zNF{*5-}eiX8!OcyGr9=v46!~-o^D)^coYaeg3zVPY#ZMFcxL<8qsfEi=7UV7n%J8W zW|L-7oVPv5JqH?enm%3|REM=9w@#rYLE$wT`R&u}tvJSh*J&cXvGNLjXYYJN0M;-f z2MG3S{ShV0`v$>dnmhRaNkK9EM{w!C*uuY9;6ErNB&~vzzN4G15kBodgY=NJ|AhsA zG(`TRiS&=#x4na-fT^B6K0EUd*6>5N{ipK--9yrD{nI{X~_4-hF2Nz4C3UHu2K zq!s0pRTdKdEp29{@8lqFVRJ8-{h3_Q$icwg%+}Gy{-?6+-^qA* z@c$=7`R~YoSIp<|5B2k-HpB)=E1+j9`X3(d-|jzA{@F*(K*#=XTxmV4pY!>DEa0DI zm>KZ>g8|}G|6tvWKdEpuvQqv5%;+F#RsZJamCm8nS&0W`X85f_MbvV zc9wro*dG&g69;^zpLPADNWsVvpZxy>;`IJM5ZwO;;QoWZQT!YI$57qqCkOu~@qg#w z-?aXR_59cK@855xpNsiV>z^&-j||N}?SB-neyqKIt^(bEwyZzxf5!f^??1+=|H#$; z^ZDnf|AnglxGMep;J;b^KX4Y-{{k#OwM9R5i2tkmfAcK#KXsG;dhPt2$N$3={?gG% z5ql$!8rF9Qv!Qn93XuzbW3$kAsL;;Eg{%e41?I}ScXQKE!_{*;GnMnai`8dqqPkhT zda?6up=wRZ$vHERSV`6xo~4!G8FNP|5svCekz6BAP2#JOTy9O=>C`nFgJn_m5 zH9%6J5tf;WJ|O96$3;{rRoIX^{i-lDYTIA&UVH{CCp#mqH8*JU(T0 z4h01nKu%JO0*L4@tG}?-Hs#_PGpdw6RU*%GHWY6upelWvE*+%M&Y_Y624%kO*a65Kr)psDCOi?nG- z+Nbe>^-20Z$`6K*CF&R549bTJ4H141@PVm`(aBTRd*;Lxz=I2hbQC^Ty^r!AINM)o z7#u0805~|?W?QY_ZJ9n#5HB*DSZk|lt)Dnn@6F3T3%>w40V^dj5Y$w+9Wed39nyU* z;ZwiT(8RD5G=4$d^InijJAX&91L1si;h%LI2OV{S3m|D={bv0OF@qc{Hii0;h4|;w zrMY7Zuz$NzVMktkpqLv#e-@_F`+Zgk`ysOUJ@i_A!z&NIp3?bypr@~Qa^Ll+T|( zSn)oWyIRfNoVxPL@n~|Wh3~XYm)ld2*9rj2cJ)AjU)1q!6_ukt*k5^w2(?Ziu5>lF zcfZh8TT{02_TL>2^o*Y0cndz$Lk_b|)C6jPMo@AlCq^bF0A0U7pRajk+P?Yk7l&4s z4yxJZL9y0SI-<9H(7*g5GqJI^P`*8|I$XZ4kGt^z;7=f#gf-KenUA0vL_f1YtA-|V z(UIn_PW63p!RvlkDNu~uS2kQeh{0?gP%yfdLh4s!?|jbhvA9@1xBV7sXI%(15L!%y z=9(sXAS^ze63}_y7!qneo-R;{$Z*cXJ+-@)Fa{D1k5{v@v5=G#t3CmVGR^x*)b3u^ zQ1S-*G+OxH6zt$STOkYRJDEB+u&~qD?dWkp|2t<{*KV)x*VONoD=ombiWIm6&ndc* zY$DIgdT`)I#c{4YdLtvuF;e4sFt#LukolE%g>XELDf|+NhdEX~QC8IG`}LOsBWEW7 zh?xUi2UonWks$BCCG6FQRJ6AvU7V{nVpRMcna|irW-1Q3vwF>?csUv*Uz07TN^OFj zvjbJ`7%o!2w#I!MfJ4m3pO>&!cu`hFru%wC(4TU_W5U1yl#vIa;M%tcE*b` zX=wO_=BdQ^RWm!nE+xs&=+63?kbcyJqtT*U=2-gHh(LPz%B%&bWL+QcBa#n6GL7)T=Kr>Bwf)@a!$}a#!S?cxX7qsnf-7On802SH@y8Zl~6|&!t zBc>Soc{3mr5M$^BQoMnhU~NT@70J#1WUL@gN3=hUj7#RznpV$PHiT@UxFj*T^h97SH!N zswK5v=M7Xm_nWiSbAsK$b9jN@8p+C?-4hGXkr}X!u~&0^H^h7l6$(jus<{c%&AA{w z$hV?+m*s|MpL+P4bSvlh@M)fI;|=*GpV<+n4^{~u1|8|Kq{(gp_W7|j3zybqE4b?%O|H3L26HX*f?g(oAF{KeBA?boinse`0vqGc z-tz3H;f0^x?;CU^AC3V|`aq-0C57D)oiW&(mJ10NJ{afKTF0o%M#(~<*P3;CqXf|* zLO&Ojx;DvS6$}gW@(LU5GCbsaz^{#GYyPGp<=fiJ;mnlp#S`RZw$T-PsPMnq?r#mN z?cO>QygO3uE;ABpRNcs~$f9RbLT$TxevMz9o>HuF-yd#o> z6~M#jAzF9nVlS3H{5%+leWFlZX;UGamCJe`_;k*TA2<5hQR8Z{Pqa_wQO#}{pcvj@ zaF+rJIikJctEfKj4xAGN$IN>R?qGqPG$n3-5WzX&IR%WC5LtCuQHZ-dX5U-cF@ZDa z?vVXQ&i%Ef%E^bngXouz=WXjz$zRj%INQ3uM}7C-Frrt!s4Wij!qb>Hhw1w;k2(dp zy-sw}_*dA*@-Cm&3BOI^0!Afzf}_&vm@X*?$I=!0{Jd0KPu`@u{65#E*2g=Hx68Pe z+^e9D6Y87=b9f^@MY|TL(pM!wf3urtJ3Rr79;}N5990|LCIiKsz$NvtGzgCcJo2AU zjhAo&Zj13_rs^sUZ@uE7Ng8|m_O5whU^P*~ErWHtXdRdV zMV;g_>WHYW4PB8eH@aP{I`d8-ZAAvvt8I#7Q;2!H(zK#K=Wiy7?LV9~wMuWv3ewr^k? z&KC43=t5mRyCN+0eeO(B2D;~S)jP;C<$N;hRA-HTb507iN&51IQqj;Z z+o?C;^h#s2nePXe`~b&%&ITNBps4JuH&q5!g=Od|w~s9=!{mRn|GYD}Kh7SLz~yIV z71dkBRj>y#0CMmOgLG~uL!DOyspDqRZe+oc->zvHfc6wly&}>FpK6O%funTxi;k~I zf*gE7g%R#}QXN$!@hQ&V%=^`yqVk?gEOfw)*iW-PDab@W03U%C=J z&d>y{5jc^rR&ux|-+v++&tEPE{fLP3)f=khlvvTCH<4mpF~<5Fv;=QvmWr!~KR=vp z=gWpRhSN;`kM zBNF_9yCMKPrNX!agQ{lvTiO7cLJ(K)V#Qnf<$#>8XMx<_zKy+ln=8G6ftY?(gQh?A zA}d5>Rn9my2!ZG=rvXBysZWlP-c#5(;|{%(cCTg|^GRgNmCuT<-m>OYo5RVMQ}uMm zfT$S}D59E{sSHpK>a>LIWl2`udw|Yx2A%hFB>uTdGr*A|&SgD5fiCV>)}l*Op6nF2 zVPh|(JL;3W7=vR>1&+(7Ji__1p(ZVR^VBm2ZoaT)i2i4}J}3f5vMc0)Qc_y69!&G3 zlfH@H>!&VOZ+gXbk($x#ETHotX#2Dr!+2F4SuhnH=16uI+t3^@nb*4@r_^5u9OIF$@A=c^F$da5jcx$}U zg>YsKbomVLeFob$3s&N>tX&?Mr4uqT5zJx%@;W5P=IzdOA&?37S&nX*1Groxnj=;P z%V6jb(6A4{*k0~~k>*R0B(jT}v@^VJnq8Fkn`CUTph&t)Ye}rOzZ6O9+oYI_jlgC! z?KRS~BqrTH9yt=O$XbeW)m|kdgWeHkUARnL9@4M5@Ugfu`N!K1^2t8!@yQJ@I9Lv( zc6r=i{!T9Kup3IBpdAl`CzTr_Ha;Kh-t{HrBM1|Tjh0cZnZ!8qX7-kUe9g%)&u;c=q4-b$QaZYBu6slc=@n z=C&(`CY1{>2|11;Bt=-{m>RCJqUOX(dhE>d)9- z&-d*M@Y`07hN25$d&SLpHV&j>W{e|D6C9RW~rrfwAo03A}KZm0ZkCy~^~nwud_J zAKi#5gXnhslc6+#KKq)AD|3P*d-hy8N5Al)8F8!Djla8OU^mXkgPMndeV1Zi?N8`r z5k^NGe_r5vU$)hgrphJ_Rhqc{$@nsFfC=S!T((w*-G@ckloMo9b&JLKsXXhY<&(j= z>3*em-SOOkNan39X@35v36GfRT^0~-)jhtY&2SC#U zv+0Vxpm1@VpnOcwUcQOY)m{thS&fsp>SdT*##O{DGZ&$D?M19^G4q2F@^aC^JtP55 z?o4JxEh`e@;+i3HR<}YlLBK|Ch=LhYkdjcxp*h#PbF;UhoA2`i&yI11U17+6Sw7{A zWn^~yJlKyNdTRg6&)JJ<7G32m=NWbL$h8_lz#xJ&FKxPr7v^%jatj&=`MiM8CqC&9 zsWL%d&4}F{r+c{P6nKQ16eH$%oK)RWLsE>)YG)=n zV;pAIaUM&8aNAgUGWGgKx)w5nhbr5SZ&o_d2V*vMS7(E0i2S;+S!e~}SM5Ri0K+&7 z@YsQMvvV?EmB-#9kKy;B4twBMD4}N(uC|!R3VEet2PpG=L;5r&*YzaMLY95vh^UlXSKHj~tb1j4U1um3ZTo_v zs8Kyv&Sa=9*QQ&JqiF{OYn>!csNp07Exag8HW`_48n@2OWsiAMb0uUG>ff$pL>5Qh z6-mSM5`c@IrNUVSUGnCC~G@MoKJ)nYo;CP{OR>4R?Y z_OZ&huu@E-F9p}+&=ioEbbW0^ok8E-G0Hw^AfzV{VHRFn)}AzTEJQO{Y;=r=`crp4 z@A^h6yx2q2qwuyRKbr>yhA-kQ>u1Y72*I6o{yN<|io3tR%rC8)9IVjlUG`2DhJiW4oQ0TIbTi%Ed0ZCl5hZeLz= z@n$`bg75)1;;{65^P=6X5F^dvL8Vq3=@`f)-ZXb$i|;* z9QMK28zdvlx8yp1^uScDWrU9#jv=e?*Qya;VN9P0!uL@U$z=(bKOPdHHB9*BEshtC zO0LaXQ%Z}kgJCb!ta=otq-idB@e)Eul1q zKfzPgkJv^l4|-otcW}%jEiY3vcw6>W7jk^CCf{ zt=w%3_Fyr;1fX3GSaZ9aXR9=#QB-)`VTmYNhuQB@Ik`LsbCT@~e!yZRaVtn-4d9&3 zo%$zW$;}~3mI3bPF+7lb;_B^}=slqm z6?Aq>65(?%F;}YLhA)}kFxDM$m))ObngQhrmcn1>WA}nHre~Qbny}zJ{M5>uy}|ZYUcnA&8iZ{@~1T z0-Usv2)g%%y{`3wFu1@>9}e}sheHJnrUXu_5;euGxkL!3z`W{>3V-ZaB=lU zAv_k&ApIXlBKl{xYnmG;o2s1W5H;rI8Ydnr*&>dN>vEx{y0uRwidy3Xc(Y)xuea<( zOLXRpRA}#%5S2}{mSXr%AixVw@J^}O^t;hUjW-YmGV-(9k&SGC*b1t70cYmAVo0Cd z&_TVD1C0wma$L%g0&WfiovKM2!oFToTmTc9heO4Cir6v>QbGyiboN3j>nY* zs?E$kvtbnBH{~(FGUj`JDes9__+>Gg-!MXO61p980VB+%RW6= ztAM1ojo<|9>)jF+UfKiYHeZ0KqbjH(MSIy(Iex*DL=C}=qNr{bt8CqFB6lE}(v$QP z*qJ&QhjMYklBH^6eZ-yLG|GUO)Cq2swio%WT1*dd`|2;bwq!Z&lEn7CSOOX!2KR&XD^BxcE2~OFz#~>CDC@GhFV9S8sr$tfjoT# z4RacE!-elTBQCGj&=Km$Dff^`i&@UUY{mnf3G zHgJOX%1BPow^b5AA^Uss_y?k;B zbQo?Mj|neaI^&D&z{d;JPa|TtIBMYs`8dpE%9FSl#wEE%C6+{189wAeHxTiE&hnDS z5-|s!%D3YvI_FGEfCoBZ8=V|5)5 zC}sg^8}m~;DfuAoE7m#LsW~A|JG5N~*sO~$WuK_BZku!iReuX{aBDNfq3HiaX@R5G za*iT)J51q$_68STj8)K*D8yLxh~erg<%biD9{mb7l1I2jz_YmucXNU>Vm^kHzKN&V?_lBZm4o1`#B|F-=Xo}X1)hfK zcTDt*?>P%T(@Gj1jXVzdG9||nW>OTuL-ZcnSHdTW&9*n5q&Kh0M-?0ZaX5ulMel9w z(G9~+2`<@i;=WS2?)ZrKVmbRFHSVo*O_iO24^j=E_)UH1@O$>%F=HfsFr5s)jHy{_ zA}Z*ttAee#=b*PV4J5El z=|1b|Sn@#z&wg(2NAZJR!lVhHv;lC72bN`6%{!A|A<@7yM1g;PF=QS9qj36UCjTn5 zcID7nOV%!6;J;J72FM1nsQkjQdM2dewthr)I%~qUCo53v&Z`Va1(?O?Pq8^4Ki-C3 zEB6-_Cud-O>-s!E0eD+2+@x?f1{XOTIAu6t77ynwUE5OX`2d{5{*)YcD8erj=a6&P z8jg2A$rD=a02xN7U?jtnBMC3W<5_a|6h17cefjGkdEeXaKPE8CLvujI330z2`XBNBAyyzGl69q>QnjzTEXe7?;B?!o_>7 zaSx9E+q0m~H~Xas+kekgP&{xOF}u!xD$-{BxpZ`Ob4O2c^>uy_vWyISO)F%yXk7LCJWYYJSGB z?A-dvRG}8*T`_1Rp(pK|Q0A3@yMF36rt=)0bbk@&BQif4Vl)6$FR12LyX9X2{AZ61 z+1N-`RhoMQBiQ8R=(oFv$@;#z9C)o@^_XDL$u2c<5G21*djwl-A=2baz{suI{MGke ziivZ?Ww+W(BPXT0d)+`901_w9k~sNHzW_`rh%sJiru7P)ACFZ(mFHwxjdrkid(Z&T z?#oG8QxzD$ipe~zdK8L`<3&h|1)jpuxTidKD$Mswld_F%@7YGoGP$zy`x@F!bTw-C ziLt*$uY?N=2vzva&X-Amf90*Y!E2pSMf!dnjn-3jx1dHE_j#X^LCszPoz6on0xz$2 zuu-mAkcZ2-I&|Pu*@u%G(s9S)YR$wye2L84C^Cg5gG)`HPP_}pUUd*J$ zUYmyy9rh~=+{FJO*7YoT*p-9cEwdyKdCVJc7(WpNchre2z}G|)0*iKsH7T7r5mk?a zGaK5>T3{qUQ=t86fVtoZ7%XI(p$!m@pLz(R%Va|@z<71Ta58H!L&EtN~`FaK_4^eWgmTlD+Kr zKH9O7Fe^^W`%aY~P_1R=Nx``YWE;g>>D_cYM5j(5^rpW-)%7g|=kcDDH?{o-{YzO& zXXnDQ7|v4u=#zx|rYng_3ZJNc_VFsnnGByH@D9cx7FNbzCwA%aRVa$$OirYnca6K{ z0hOdZ+{!7W=8)pT=4G($+3sfx$@P9>|Ove(E$~M}Xt4)Pf9zlA| zu=G)rB*eT%RzbiK6|<{TzrmSkz>HSa7W~mG)dZbU&G0hDqluwKcr ze3D#|o#wpz17?#@HWsvcpiZ1{xv5I1^u!Rr(^;F*`bul%CoW&kiLa2}i}*&*0*Ps4 zEoWwp@em4u!w65x`OLB{e3OT~_Cqm3Ay|ESGL^Wr|{UnQtvETplH(82lIyX zZ!OmDp2YrbChnDL|54>Q#rGr0P`w7(i-j%8X^m}(DO`b<^pPqWnM zB+2rqcMPX`y`$E3`VF}yF+e+Siwib`|GG((Mm~qwFsgg@N4dUOZD%)UYvB>s{B=pk z4TC%9B1)}{uOvmOkG_mjEPuc`#9_i%RVt0+3lZqBcJ7oZDjBHr8~X2Sk*W{?p}JdW z675ZXTQlAZm)S}e569{`n{3PC7J0o-0e>5@_BZgn&hF3q7S+c>vvfY^%DVLZFv3Lo zEV$L+k`b{|bN{HEPO>5R*^|eo(pI|9lU0ulWb=#m%PH4&o4KKc&uS6bd&qc&yG}Hw z%;XFG*+k-VG~8qZ33^SPKkJ3>$?P{616x9Cg^j7X;^T$BtM*ok#O1qpdi4wje&c42 zP7?VSg)!l^sM;$5+H$+*P5pw#hko+hA2<^vTezF60836FX*fxURtAeJ9&_3UYY-+* z*k>I=68JEtS6(z7H@CM*Q(9Ndrr~aTX26N84-0#R69M5*g&2wtUnj$_7I zY_+up4qQdN_?3GyK55Q>m=sqXx9S$6NzL0SnX&plc8Dj9$IH|-4ELREqHmbk7YNWs zc4GSIX$IRkTt!s$r8Zyf85CkfpHqY^-79yLAUxLMpE?w&Kul~sVy$~TTyFM;@EqZO zpTocw;8)gQrl5?LY{H@nk|hOUZ7~abAx7QOVZ^c4En-xaCH+-d@o*>+k?Ja@T?;FU zDm{Wvz$K9vPsEEq7&3Eb?-(tS9vF$#w01;GCV0{(Jlsc}^16qhwAEJ!40D<{sZhb~ zQg!nQ$FrU2lK|ba;w^`C*g0!YfK#va0j?oH`1%2HgQ_e&Z*=p4b$WXlE^Z*aXneF= zdKY6@Qpb_Xxnl8o{69E*2k6MQb$`3lv7L@>+v?c1ZQJbFwr$(C?e5q%|LJqi-e(`& z``z(Xjii>c=BlcU%wJ~B=Y4X>bV+NBIm4DwGIUIlkcD|a)^{L;xi*z&lI+iU(oalf zt635w4Ntf9G*S3>XX%bX6&KNor5EdO=~&2~@78hnI|^N$bzIwV{7Gyj32Ba8tiGm) zep4#ks&2HJzV)6tA7C~lCN{r?o3N<=fO9}BMgJ9sbXaRNa=tWMl6SoTaZgmp`IP8zCYjQG03@ze9*_U5)6pz4{cK z$#rwGd`mk}iwR(KYn*0oMQ^4OPVwA`pQZ*lIR30~K;HS@m z2!YU1gUu2-)0rnzyRLb@MiWlTb2O;pzFBC;|Mo1!FBgJ|My+B?i>JxC4#hrn$g)YSLG z*OS;1{rBaQsWV;HZo%B4YBfykb!I=N~JBF>u=x0(_mD z?s_`GpwtD_Mfw$zx|Utipz#Df3#6koS?GaOUTvMgZyI>%g!1!Y z@&G|wxb;{LS*{#`+iCk8`hXEQZ-UZB^MU`sDCxaDg(eL>DRYv*f%~r9sXr8Eff!@) zKtR+tUKmZMIJh-CgUkk1S-Dy!|KX?|&7@u}~0Y;oKOo zxXtOWAu-E;fy01i8Kd!vFvYd)wz*ZuXdJk~x-!%KW;bc%3gpy9bC4nI@5Lrf#(HgH z*Egh-U!^Cv`my760Ewu>DWPQB_0d6mHkjECAk9?RgrbiETU_7Oa3FdO&qqiP=kgzx^39Do%0$COwL~j6jqq9Y^#xSw?;@P@HSsj z&~;6}rZVvM0ny~y`@KW?8m03p$uTt{7kPZ398{z8LQGVC8FMCp=u5O!^o()keH-b8 zBUulm9a}G%WSmTH8?uvZ{Nl8NIyk`5TsYQ#%e%s^tPIS-0pDl&Ef+>JQW*41IbtT< z!V~ZVV#%SKMoRQmy&IiBvJ45~;e=_n3PI}H$UNs}P*JiIi3x=yEkIT7ExsWk2Wnbs za7>RrqJe<|&}VOys;e3J(lf4pFMWaJM667GSLp}@rFBC%dr@UUH$wSk=vHa#o`}AD z$vXCZg8HJVF5FShaWF!)yeA5(E3tx3Dl% z!P~P1uI>KzyEM!A+8ZbCT$g;7jTiUN7eQw^scyExPJSZRc-K4HF%!iIjkAW5RD>zt zx(%nL4yNKa>bL@MovkD$_ z1G2;_rPj6`9SuyUNRNCB_o_uiQh+-$rPR$AiGB#W#Cx~SK&DhHlH=%xR5HaHY$6?z zF-ebTin6J-{pqP>_opq@3Sj7rEvJL7SQ4$_xjM}7%7x3Xj z=%@bKF2qBN8zfMAESug~lLoqx(UEeHFH8!6Q&X3--{0o2#)zOOLrsN9s2kDWmk60Z zKPFhKwP+I}a!&OsNY0x=7`TkW>|eT+`!ylcyL0*c8Xk=X_*|WIr=&rUAA*)vNz=N# z=g@BOGqr-au^O1+b0Qven$go4u>Q|I`*I|9`JMn!N8w<6ve79AV!vhA89g8@JU!$Z z@cMx-x&`$JDQs;jnBK=HVp)`#F)Bq~^a>TK3M=uYPn1kE0{)is0!v5NU-hTu2r(eW z#|t4d$FNQltu>;Un2tx0D{;B%86zPSU2K&p8(cixeK89QtRMI7Zk=e_%2{jD1=*b7 z={ud0NarurM%Y9-0=L2o^|Xh2lKS@wOrfM)`CYC&$}OwRh9_XFt^!)BJ#UPt;@L*O zuaEMqQ}^)~v3zy+)^32BFSL4o3Dj?`O@33^Cy(W@)33H2{ zSFBXw5ija~`waf6MB4)F-XVp#1asimY|tx${34de4&5CT^}{3nFoX|$k_&I&h=G*x zAqf1Kxn!3wcf;d;20sq192nU3U_3c;^I?aVP^*Di_qHku%DnBE|B?b(Aj z_>L*c2BD07zsp-jecgc3ma`{w(&_F~UhbZmwSs!5LFxZSO6fAtslu0EdZSOr(#f_^ zyj{XBld#sj(5YUw(TX-{D9&wEO7uB*u~2 z!jREHAGwVFN41601eKUbhau@L-;7jl>=mHrc~rKo&E_W5XjA2s@3a8X>ksxDuzREU zU{-C6qz;%D{wqg)?3w+(85e?AcDDGcP&s`ZYQu<14gwFC^ngKOp^~};g#M-Ej$cC* z0n`Z!>3n`fI}9_eyE?UL-`vR%RP&3uSOEAIj;-hdgbZiyYgP|v*9Wa)Yf##7b$2QFP8-MpFWrGK)rOJ?aVWPti=5W6840S3L$rl_YB znpCPuC@{6$y<3DB`p)#X&f^+^%}|!Auq|V0Wumm}yIEfBFil{NSI}Lm`fGDS#~vs* zj4R)!mlHLb-XG0ugDO8b^$2686h)StW8j1qoq}Jkcg!k9h+uz#CMbd;h@~*5-$&YK zc|YAXcI?||MRG;$2X*4uR7xOdb6MNUMPC{&$y)WSK%ouI7l!p%LcZ3mqZhtj36M(8 z^J4oQ=kr9TTAerLYfc%l;=J}+hPP5H>5p4D(Xu$LAdX2c*Bmf@AJ%cW}_7l>@q(i8jws&sYY?L6(B(5O8t%u z)0C|Zw)QRF2JN{m2|}+<(AgMrbu!atfj;+ET@5$%>b7VYl*uuYVN`>y(o;jrTh^5e z@|G)Ld^I&+^z9~an2%XZ&3Y7u=zAlsZijj{3x>P+6W*)subeIlNp1X{hTQVS^BGo< z)^pA==BF|X7;^%`6Xct-skE}g?7O|<_cT*bt8nQH26wG_Et?tdGl|_ul zAfX8nmi>=?(5nx`SDx=W7Ql=SU)Izx*j4b~X{ZS1vHt@{`Lv+@1v~ivi=!}nLKpwU zQRqKOjX!ae-(G@$!BOOur1|9e{|!fxGc4;tw2!`CoCA z->ZM(D0FO}NXc)^6+WZ|yVfj4gpEL^NC!q8Dl>eYne$yLNpT*ig zi*M7>;-yn6^H+OrRu*G-!=HNO0?+TYD3HXqbjuWXFcfutmORHI?n%5#rdyD z%ir-5xxc)QpHjuYzw;34pB3*v7yr2b23dZ8{jvTjrucLDe_#3(e|*ZlS#VkCKNT;Z z%YQ%mk8}NoU|9cg-oNkt{rwMQ=J&CG-~0Qxe{JUvbmp(P&2M<-kL`cQZGP|lz4W{F zKlc27r2QLg^9OMAd&}=5e_!YC$KPMS_x%at{EK_!4-V(kyz);Bhn4a7ulr}AX9tsi zgK!u>ZFGOT{U0D4Ia38hVz*m8{`S^Zf5Ng3(0rc!7 z^8xa?AamG*1kR*{xg==gJGX~6{Z(qmVBy!T_lr zp(EP;ss>!(Hu;mtd{&?#D?WZcJybLAxkhK&PbMFVHyftFz->kZNWyA~5VU7h-^lvj zeq-9+Ffff;QkTxTv<~!c8B~%(B6MJo$BX4abT?%NGTCNyfvXk|?tZwGhco5dU|mSC z9|E>~5E{VPUkXW8`t+>e+Bp`T`ilQYgM z?VaddV29)8ur)N5?|Y6#fp)8BoI#|j1kdX&H-%blWyuIxxxB-##lA)t$lHO(=!yo} zW9+p0qmuMa@oj`VUbk4q-l!!c;?p$KjTB(O6MhNR24?Q03ud#plU0`$jBlAu;Ps0Q zZ3Em*^K8HuPXeRXju?))b#B*pOb-N+I016nT#PlG$+zV|k!#8gV@6(62j=4D?Vtq9 zDIx0vMfQn2>UY3Fcm22qvb-I%B7-$^ojWm>89=$LZ>z?PrG0w)!Z?{7gH?<8Pq*X1riqq7R zusSS1fH=DcAy-SPm*HqHGVe{cL-aMdpp8uF$F9MzJI>>_rzV~oC-pL~CJg~^_h;{4 zM7|mDa1{4};qi=lW1Ae*nkhXhK2Xu2S<%gm>z~@l=qg9S!r8 z*9)ttFUKHpuc&BwRaUpNtj0tELt`egAu!P9Xfn|XV%)xL;X$O?;r)tvN1f$Q9AC`% zqW8qa5p_1z71elh)1thsLBo{kZ1B1hqAVx>qopWPIAMUt$>C8S_gzLzk#{d&&~tIe zZOW*@>~1scq)@;lF}DS4Wd3XUL6jA_fZ!GGwZ`J~3I$#j`8?-4kB7tYs|8tC1BM4(Th=|92C|6>CBEj9W~HU9*1KNH5E0f_#yd-yZ|{O-&CCI2W& zD2PZ2Q1DC2tI~b)t^bDKvi|Nh|JqIeZNtB%9Tuj~AN(tP``P+m(#~h||4cjo*4)3Q zo4 zrZlJgT26GqO$C*R-qj2Y92g1?SC0}E3>P+}g=IH!SIe!%Hy=R2Lq=3FQP9F+L|!2t zqAZlxGkYGPj274u0SYFL0H{Z<|B!=LfRF^?4Co_e)C51;iic5hN#-PH zo_u+z$`BJGhl>wp&hPVi19d0ge}#`D{uPW(Se;_Q97GuVvO#95#z0rvj|(ITtdR*T z^Ru~^7cVF{+@*UM01TqX?aPVi03~rK{4O#tdmNwws#MCWG7htj>Cf!BY2?9IzY>}z`LrHbhIp`Si7^=K+E`bV`{DV4@nYo{QFj}|3r zdDN)0XxYW?^EdlhjEC99g7B`~w?>15@gh+gty^wy{oF=Q1#~Wpb?NcoyL&FU$}rGe{9Cr%`~;sEHP^oL)cbOC8rpeLO@rj z%`#$~pn;`c!2fKWwyumLwWUQbc2=cvItjxro-%B^Bp&>R_3at+)a!`lR$er`z;-uy zDp%trhYE7mi4I4AhUNL)%$Ylvd0_fT-F^0Yr`_-+`_MvYzO#OZ37%=KA#li#%{>bI z7{~T>v~G$EndvQ?yf2J5L%F}ucOKC}tZ0-r*IYdNvt~GeV8Tn{CsL-hLoV%4X&pCedp@ z_izPElNL7c9pALB=dl_Xi_#i{5bFD?q?8hdRa^YI%A}rL;LHcf1Bxw5cI%B=Cc-%w zhBD)uVY&NQaN1EOtx30lfj29IHF(tMet9>U^Cca)8Rl2-Br#CrlOLr4t!&0Wl~Ve5 z+G{DvD<6F=vh$?vGe1d@4%fEpVz)F~w_t$PrU?1bS*O@!-F5E9q;X!nXAy#Y*fJG0 z=(xMqktN@pD)t7&L{)(?cTojNgLTT$dLySa9t51&re*gaXFFoP=Hj{`(`Kogj9W`JkbZPn^A*9>*`Zee7TI(9iX2WeU*y@r&COw}Hb*+;ZK1 zuirQS<4uOny@A+Y6dAed749YtnyH1yvwmE&ElkuHn~?VG>t2E`6C>Wv?zS8kb&a;i z^xJzUKjgu9 z%fOYjy55vyWElx!PgdnF-q(Hf2|juIeuR7#gD&p|mniF=BmDsJzYA~pk6iU%yv@I3 z$^TmDThDP ze;C&Ony3DjME?4mnArZIXoOJzosnoiquReDrT;Wb{vVRkr@`v?1$>U^{E>!mndv_j zZhsTL;WGc}l>2K&`c!rPXGWr9rvKB%^BIzu=>I1<4;}O8{r{Shnhb3WCSr+5jf|8+ zQ-0qP^o)!O5$sF)p@@ur-x9>a3o0%;j*e z;O&Lwv-9)(F#sV67-)EBRyXH26c=W+W@3ahzXO<9K|h)w_~d27*#o3Dt8%ahr!@n( z0;uuY`>;+!b&o>m{QC9FH}6X@8@p?pin>}0Krxd-gUR9H;m6#yG+6ii3lFEabE}#< z`xnv=ZkI1-m>H+OFjn4p@7mT1fL{Tulz4pt8nEDS3-ikf@<@TR6XoW=hyY;uP!l_S zF?5#aFlX>-Z$O*wK^6h5ws8Phesc$)wRfOxdM{#B9_&)Vul$1OQ-(M_{(QllorE@h zg!7H78~jku`t11m0Zr!&qS}GZ*5+jmkVV+1!9OLV?TH8IeU%FHLvVOx;L7^PoA#DA zt)Z|oi!#GEa}t*Bt@6?B*pK}qBg5@`X)EQEE-RnBfh`exVTK29vFD@E*&ZA#gE)y=VoU*Pgzih0MxwVh~Mlvvdd1ile?Bb z91eI+fL>`9(pcG6TtCd4cDi!kNkGk6l(RE{2{0i~w$hEPyzSN1IJ)WH7%1prP$Ive z?0c_GY-GIm9RN5yDf<_Hq@bmC5lW0>VV$-E?DImh5(^49b&&zge_SXSy(Y1URHh2 z?CAR8!kY5-!9w-{+<%>A4vfh1&78((bE`E)^IVa}nH4e2 zzBkF4H~PD6T1#8=EApdu(1-QHN6q`vIH0c=6$oxvFoDr!+yhPz zJk1F5Eud48MRY<30%^JNFrP(8*cd^H>bFUUxVbFj^M(UB+`}!C69WQ#Az+GuD3Vl4 zu3tdYll~rM44+dOH)Dz^BXF=ogk~NGS}}Kw>rxCXVm15%QYE+vawd{3i70dC$=joG zbktXj$9885>3;RB2+qZBBQ42oO8%0o`?1F-EUW0Ag6hVF@O{4~(VBGcI~L5th^!6v zTz^p{uw&KqZdPC&^6Q&oaA7TvA*GI4ujuYB=#ZnvADT74SIWpK| zNq9M84BX7IorqVNsd-4Iv0(2Om`6&FR8T&N14I?9igeg_0K+oM6*^f}X92mKkv<;X zWcD*2be^v3;Gu1KetogMdNLE2b|Lud=h@Yp}!}W)+&jJNb z2$Q3S^}4Qt?_g84YUDQvtdsl{Qy@%QG#kD_zK{Ocq86UlUYjrXb;i7eH)-BDaNeuk z$FmXIhMq>MSeW55+bdP0w798KKCH9Z>oAy+lya+G`s3>2`x5))f|M*#w+OV-U>&|t z?s2&-<=>)EE3aM-6!%FRRP%;%lL1FzjRe+=nR9euB~#I z30p7RgU0RC^V?6liOs&h)MWEHOkWEcZH;LbyU@drw%>gEph|7 z^#AY;p_QWGYIy-f>NsR+n;BMurM@1%^#!#`8r-ClQOE!olr&CBHBpjkF6R4`BrKbU zehKc!T}-9l+oIl_vM8SM&yNc{p@JD@MButpR=Ug6^fbutQYr^ELEpYVAb#Nu*P=QI zZ2>l&*V~*<0xLk)xXFJre5F~;l<4(<;!}Ey6R9<(!ems8Ybhv>LcILMDtCZZ(x%15 z6e1c&Cs(V!QwzS89Hah>#V$Q9%?Q) z4EyEerkh_1MiiZ`on%}54XRPB19mHtXeG?!UVOBj_0I7~zj$2NL3pEV=E%5&xO%rh zB-3Le5v@hPW+s_7%GtGgy-;ni3N}ai#)Y?>KKh|lq`QT&cVLRx!OaW8;VV^e(l&Gr zGinHnhQ~C8Vw0DQyyLBMMji%w$9kNVC(Pn7Elj%o))VrMEH)X43^_vW_xgU+p(WSRHm?#*=u6e`ktShcTv@-mO*iY{&^3Nki)7wN{cjEyj;T= zO~gT5Pa{fLCTF!wnh&Jqf{MP&+k7~~*W#Xi?*B;;J$%Gnnpl?^U z%e*zMvpJ|azxZr?J;ll|t=^G3GA8#1S~Dpg%M9`84Sxf&+*SZMx-EoD4XjvOx`}hX zIN?u>R+XXFPBYg(-cViGCVTCy2|qDdW>Jy2!asF9k6fgAJQ)p-j!c$o5+7Mf*Ax<4 z$d_P&c^UMjlFnLaW0E>&N-XcYTyvNfqf-E_iqoY`brE)WsrM%U3Biz``i| zoV3cFPNu7DyzDqlL_fL!xHjv8&z%n7sL&S$uU?=VwaOz!3SzxF?soB*Q-_0%ecNp~n?k|W6y^`Dsf(q@3Iojjx~}*jbg9WG$gpD zc%3a%Q6PFrcxe?;SAd%E>JllR?q zTGxz~wc8Acf--tJvEH5qFA4#MQPA-oh`EYq(;D6JfN?V$C0lM4Uo_IY20h5X_C%oA z_V?z-X_?uCsYFt?{dV3yBRf)RDlU(;^%|6#6&FWR5_z zBhhf0Wt|r*TMHiThVHfQ755pgh#@u=Mwg(@3A+-JhiOQ)oQPm3z}Rr|_L&EEQqS+k zHhhC9Vo$aeeG&b{>aO}1{${x`Um!ZK2`1);zW1_1CROu-(@2QOoDkJ$`U6@$ahk@+ z0pi!cxf0}$S zTh}^t?d#JFLYO>qqt%LrWvvX`?3+B14`8fVMI~L{!&uis=63+{PZi` z3jJ`7nip)Cf*R>V?U-fI#fVsH`R%Xz-hQ|!er3`;osN8AL@+Zm{iFn})fYeSwpnAX zxtT`fieYf~u!VMmgCr^Rg2jH<|~dMxwf8?GoJ~U55C*Ipkkn_>Re0Ulx%C?4<}&6rGzCI1XI5t zQibzD&$vV{t|h0A?gdz=&?^jr8c?c)Oj94Dr13#vh2Oq>g^0pFO}pbnoOay;fRX@- zeN-?@H}6?%&ogBJGL_N*YGDkXW^opEh0&yvX?}8qsue$Y9%1>}5p8#Ex^g^A*Osj^3QVd^ zmKE_|3A7cJk5l_qn*=9%@zkfD9n8O-LDRd|Z__(H^kV z&Sm$Q3ies^BtbtyM(fBNie5U}P7cSWF zs8XT{4n%`hh^uV6hV`5JhF_MGHcf#+)mEgw3-LPS6qyQ(TD`TucjOlH|L9Qx#a%7D zfFq}7w_lcr4x%=FpHEL{XXlk*rith})W99QJbltpzGkqoJ~p>J{Cdn-fElTX9@nmf zjWc+2+Jx41KkQ@dK|5U81MlLK%wV*ofu`C#s7}^$QT)}&l+LrBUHqBj`uuI&GdHdp zuJ}mdl=%8W0c-dr-GzdVx?*c*H!VbvNP+zMG3p#$U;FWLm&r3T3lprOz(S=B(gkio z_b14txpa?`)s}?(9k8TgUi#dcI;RJGRSGMYtxbeR-~s*Z^k(08eR)y*gMv+M>5%5vSV_O^m-4 zwg}-cSwg-c$B?b~m9XQ23D4*&AUmx>2SUv(aR%EHHxaz`4S+e~HJ`Kox)86k;pjH< zUw_tjm!#jxTNM|t8bBx>55f_frZC*@EeYU|i znv((~ZoeVB)dnjjov1~sqGCgMC_qp?NQaS`F|lJ(7w}G$EqlA@H!F7>R;;Wh^Lj<% zhmRRW_0Sf1G}-&Ig7pXlq9?vJa96xaa@}taxkGEK!33`~g{8;n+1pQjZxgZm@m}Fn zdf%y2>0sNS8`%VBdVR0Q@}p}>6p(Nut18-%c=wE1%Hd}w!oIcg-MYGV1p9^bQ(Wjn zi&vFSaQpjD8x`jOJ4LIl1_alJJu?wVeFoz!EM2eNh0R{IR`v5XysrgCHB_AS7+Jb; zf!y+Tr)p#8h!BPLAfNTXInU;I$L|x50)hyaXu@X8Z-C*kTdB<8%M;bHi*$#yL`~-!P1CEfN+ECc>o;v6ri= zQ(yWhZ=P#^@(9ysWkZdyuA5{RFb=sb#>EU}$5`n3eOYzNDYqkxQau*~gy{7NBoUj} zo_$3tK75@x4C3AdxWdZ~x$r4ZPl^y>UYMTHzErl#+{x3m(92tiwN_UH&}DXqDjl#5 z(M8a^Nxi;qUMhcZmmv~NwIHOyx8MgO2!d_U?Iks;gDv>VwZ0Q*`XiqEZh{bP)GLR{ zO4G>Mpc8v#rIg?yz(wtstq6+TUFP%Qd%9nvtf#xWWIrN_2H)j?wXu1oP_=#c5xHSJ z$c5?0?bzxbwTr2zj0;pi4PH>BsO6r&{>%}4^K;E4BKOR)w2+`GIIT_DxClP#W|WSc zzRYm0oUOXfnWX`6e-oH?u-f?z`52z-W~^f4S|MTOFjo5cZC3 zrj=ywY#Z0f}d6mu$EYeA>r;D-KK@ zoK9pHg_SR#=)Vd%KGrt!7Fb5sN6Y^My8qfa{IhvN!aID&szDF1z8 z=ebdGXeD5lFn!lG1y&gSE)&xi*!wBB8Y7I=N}bS~5?nggf|`WdxlzA`tn-cmA3^N! zQ*d(Ut(hOK;R7<%1dJmcY3PqmXrv8OA{4$0UBu2&6hutAy zVDO*;TX4QSO)4UF;u9D1gCGhKanB>^uu^h}L%34{W)nW!c}J@%2r>cd3oi(pW@1YP zjw0OL_2~OL8Vt$sc&E$09Wobr%GZqesgb3LyvOT>fw53s3QW&d8ADUn*5%^NQPdSi z9o+P`G5(5jDtR=LOLP8O1vFE`8>H^0P*eSZ-Ry&L#egY(j?DEF)hjPe zd&o#aCGI-ov$Qw0V(NA+ve~iwcvB{xE^XaJj6Kwd)xJhJR6!zrAFAvOzI2k=MZ&T8Ot1IQjl!n4?DZo5WO*`n zTc^;x#F($UAeSp9`>)Y{RBc^s^EkQ_gfhHM zQ`Y+^OzF$IXy8j6@AnQ?Auw3BGgRSv@*&-zJY;)q(P(RIpxXMedp=#iY|ZG6A_kP}*@_W$7!v{h(2*dk;SD?2X}eVn#y7Z|R|7r?_v6ecs1Z0@?~cNO z>B^u8-TDEqUayDUObLl{bK+4%>SlZ`dp``ZCHuC!Rk#t=gSg(PD5{FHFu^%Q;TC<_ zB%I{PNR88}JaiHIT;-_gjjqFets2ngwbj>izqT$X`GsSdkWhM&6L1fpuDhssmODvS zZa>Z%B+mZKm>SX;WMs^3(2HVknH9p#=Rl)B9@6_R_i??oPL@8E;Z6aM4q?%n_^ccG(cN7^$S?chk_FC?yG0MW9XdS zkb<`y3}-loll}wV+I?~q9kugaithN5cYa%%_-g=O${MX&6^oiBp~pgre`eOlGPoHQ z1hq>wLsacUWd}ZTlzZN!|8dAvg;qzXI@Qn}(7UE-`wUpP9*EFa)4qs&Fyl|6cmoJ1 zp&t-ajpB4(7;dChh47#)a^e(;vo!vJVI|lFf96L40$c$S>^Rpke)ls48REGqpW`WH z`e_cNS@6In8RVpM;5T5BUuzY#mk$w)52M(Ope<6&cClNW!e6qZdLJzg0W?fQpDA}U zl_IHHY3~4%6!tq8Ol%=OzjEWt7{U_9boSco>E_h*okUOu{rcUP_G)ORefce z1iPSET~Cyjha;dAl03cXn+M+sAe3H*iAg^qyEt4@2-YN4(W3gHaX@%r;IJ7i<*78e1?Izb%LxO5Oki_-b@TjdxQPVB`;Yk zCC2E2^XWBKRSP*O8M#VZdG7|ywiwlG3ZjC`i*q+(xb-_N!4S9y3rcE&ay8GTr;p%z z`HnnVa-a>dLh`v6Qx_*3>+8kb#Mvv;Ma?y@kMnxXh8X5CVFH!}zl;#q)}b#FN^alu z7!_;EUrDSzbKk=@18m^aY-D1M_d`73xXYNi7Q`qW6Qe^QERh&YEY78*KY1_`Y~d(8i**8Q z2uU8BP?ayCo4#L8brfI#vRnprkWwWNBMH{p9&%EHGJ(AN@eS^c4zur^q$mtq zJbUV}%W*5$a751l_C~?^n|D{$bBS#CO7Z13i9e*3BX3vR@;RhwmQPdw`vIC11=D$vmU>4+U4;;j9RrzW@)zxF8FOQgyf z7AF=Y;Ah4ys#CqQ@yadY0+;$PxM0UrxPDMX;)DlmD*j5Vtsx;)3!hhT4Z84btwERG zPB}OK%Uaf-qjJ~2Z3kB`m`Pa(G@*Gs#ms~iv*@Ad*&w<}ogjtX7FxI+9vU(hnUr}0 zZV6K}or}d6Xok6|b*b_Ul6d0<`f*>Is^MW(*F~`XQm$+8(ix>zf^5VXxi*+JP>Mes7M95Q8u1m`xkwd+K{?=sE9&y|M=SdEA%7!!{al_V?rAJTfBC0t?%N793~w4i5V zBE20qj~46ErMRLj#F(=+ELK3N@xchhXF_+>Ln?C}MQhJTFB+c}A+KJF3Loer0p!?E z;*s((+(dPmzlMUthw|64;=i5&Ap-lC)s@z%J;;*+r8Pr21D*7Zk&em|;)1%$TT$4X zC}Q%2nwUoGRwe|zc}1ra!pB+31Ut8RkH)!bM*5<#gP$cp{TcTF zE2^l?)iJlk1T+60VM3X^CKvegsn>%{2|KT$i6cl{)QJA2;srDYyuUvQ2 zDrMfdl63+yi34Ct>?6|aP(r34lv?SB7HZsv2`?6#U9Swh+k4w!O<%yqhI~96-cqyi z@k|L~hQVS=t8I{1$ObThjTGKuBUKo!bt((yp{(u(MOKhZxLWt8$R1}1O`ZCJA&MAd z3|(QW#}S3|VeeF7uGVvdjS^EnpnU?FOClw?A@D*+KjSO>1d!zchAtewihA_G^4XkzC=hb{|Cpao(b7hQRq z354iV86d$GPK`8u2_jtFPkK1~9%wUuSAS)?V#Zs#FeCfcrNvy7dTaP_^)+$S4C5xH zjg0PF%(fvh56X)*EhDkzMqQXhx7TQYbuNO@Ze3`N)uvH$tij8b@jHB&W)7;Nb8HI= z`-ip=u9|&|O3=oq_36fpH2egd`YN?VDiJ0-At91fdGCMLnd<1HSCoJKM1?Uf@LFOTO64~nSUM(zmh4yjC<#^(rAJXkw=vP)a zX_oO8fJ1wrnBQ#P?3V|z#^wB>lA1)>(yJJ3Ds@b|MS` zpPt@4l~+I>1o?U_3>zeeZ(|#g%$*!V5szO_shv`XkK>mS;RASEjl@)&L;UGzfi2P=U0>Z0#W7=ip0xV- zSpG)3cb1J+pj6Br0vXiF;2n*LT?R(KNEqJK;$rj4`0@Mk zn**+EF?<59RU$v@AQNDV4(`rHQ)tejx@D3LDQrU4>ly+rgtGd% zN}$95_^A<%-kg}7Ox?cZhgv=uW4rkhB z6T;$4tIv-x9>fiG_e{t&Uk(ej&BcL4AGbLMrHq9g6UD6Xq~)dZ zRd$(gAJP?}l{KG3Ex2h3It#w3_a0SSmpSl8*7Rb-ebAw&2D?LA4U}5bN@Wm{Ph0CH zj|JC|Ef@S6joU*|-DW=T0GEbBI#gk3v}Z|InI@u0$}xF|ZN;+mw#zQ}lB#Y_(rNdT zj~ee^l-*lWgjyX>{wa8Q$vH8Wc!iQiG9FoWP%9U6+)fD4(f(oXAZ zp<9=E+ikjMq<(KR<&%Gr-ZWDtJJE0~e70Kgr7MJ(<@vxq@apDfIWJoIk^W*2bX=fU zB!Y~^YJIC(X+}t%@C(T|AU6LL#TES*zde?qU#20Yq)CLMC>!C;{-lBTT!iZZkzEuQ zX}777Xc-0bj^yoa2t0}?3$l5&yJC!Ds+ zK^A|)k%OrKjh!q~shspZ{#|Kz%r?pW!--+0gOwT(lu;zo!)^p>3kQ@Q?HFA5!DW?% z)6J5)mX+Mu*I!lrGH4~4BHv6Z6 z^-75$j)<3@pYH2iCcuvlgG#d;!iAw&S`n73=~nNcqhbdVhBv2kR4^+wC1TCd3pjL| zOFu&|<+dD64tGmr#H}UVT;RB(gb5L&{@|jqmHo^^G(8p(S?^2uL`EBoP&@2!>5LW> zO$18cOlEdWOaORv&K!Y`8h1{U$Gx9Kh8U^ zJ)6)1DDxeXYkxzAoa z=7>Lr44`u^6-y{C_tiIzt^)!tQ+5L5@*+U22H=IgHAM!N$M$v5ql+F0+*h3|0jj`~ zLmAWY*3Trd)+~bP*!3Ft#{f$gNKp!mg(Ovlve)Mf-|nr@F~Le$OUuHtgD)hr^4=aC zIMuLWbB_CfOD?)ay43QbJvA#cbRk`x*+ zj__(cis`UM{rGd}zZjC;O&gaCSW&jr+1GT>;HtG)&#{=yzSkA;8!urx@%Y zMDAwO;WF-*sshpTENOiY$84qRa?gm)e$wRCIRxWfKymybvpy`&7BfQW6OXKsWFr^* zeN5tbRa15FoK8@+zuz%*Es1Y^UoLeqm1g@X6XBi?q$hVOhvI?3RkmhL8Kq~3$TTcF z48e0A@th*Vxs3EJ)(*xB;)X)JFM2~l>aMXu@-pfDhnPRx;i;9Rm&RVQg?%w;40rhM z!(+IwK=>(k{TzrSejSt5DK02T6jAq}v^b`wND6AdDGM79nq_#}A=h@+V8zh8<09Gf z3o$PxlvO~t3_=T3$J1K$g1*C})>U@t%B#`9Jx*I%s10_;ubw#FGTfZD|3}(A2iFp9 zi^7j>+qP|I$F^;A$H|Uu+jg?!WXHB`+kDyQ+;iT&_uco^tNN-|SIyaTtl6U%{^_3M z*KknDFvs$JpNn$VLj_g8j{xm5aZ`=u!pguFkVn|V$m{|S-fXg67wJQ_2T;QMtVd;aeA>2Klmm(XA_JPG)pO+yD=?IZT~<(B)1RKIJEDp^ zrVH0JLv@jb8XKQ>T%dLjulh*>N*m%lp>R{NF__of%Luj{gDFD}%RatJ6R@2@21H?D zvott}VqBS&Z#)MrURRipUJkYe911!it0>Z8?NMc#AIM@!HAZx-$?;!=*@U zKfs}eX8)CSEf8U0`;(P{gjBJw4vq&XMTg;tuf{$>mWN-i!(P&y_{zJMIcYtIos2_9R3&S#Og~qK^|KUmJm%kUY=P z{b^Rie)3=g&7HitB%=N}fOba0VuO>hWaJe2)#tTA0g45Ppn`KMho<8;;q=eF!DgAA zHm#?aOcwbxtFq7I>^Bo40s+)`tsaBxEQAAf3%YIQ)r1o@+35qC*KBmJ2zf!JB{8}4 z_RdW|&Yvjn?};i)cP6?y>%#Fm)5-@i-N|es`>AxsA)j0x@4V${YuB&l!Vp{>yoWXeflIj10 zsv24DCo2($@XBm+^dxS;C=goY_ePKtHVvOJ%vdkZhCzS7oy};i7hFHLCkTGTlM&b< zW1V#n&ly2>knS?jFaOM;D{`4kdOf!~Nh}F_EsEdiEn;RW$x|xJwr&{#SbSXVDV?up zH>| z0Wn&ci%W)_9H#y}^R)g!l^^uSVGCCh>aRW5QC#iu&j$<(b$M}*y3fc*Rsl0+Ojcf) z=Z400@|QK>T*oRT+)37p2;*fBmLr8MyxjrN;h&$OG@h1LLXX-#FJ9+uyQ3%I4tHQU z%XIB?gXspgF&qS4K^0XsqEHbM-I0vsJYKL|j7{?f<%##ZxFtVG-d>0L0TuI$vFk|>5YCO`>2@qzUDIq4$~%RX2e+$ z?YB42Y(!>JaJ>^WYhiqmT^?S=g28o|mTRP_dI}^Xq1bOM5&u@Ooz}LbX^gww)c^+| zDZ8wJ1eMXryxXKq^N?tG8@=Yx6g99q8)^x!|by$eOs zh#6E{I64N!X7Q9tWl()Pt=+Ndyzyu^=(!$DV*e1%Y!z6|DG733sZ}#QV7u$O^*`F(Gy)cNXQHqmuFNeMtaAdo>ryuohUvOqTrIYeACmSz?{I>gax*a8lxeB}~QA+hOWN zn=AFJDB|@YDV55pV++yb9*B6M;ptsO7l(;0H7vdorW&$mBF?m%o~Er$AV)90mqoP! z!XO0fN_F}aYhnm_xM<7%_iYKf9u7j<*#zkvB_qR4inPyo6jESbLP{BS9ogfjK(x@| zl_9Mon8Wkv_Hs*_xi_@>bu;bsKmw3gwYwlQB;Gwh?lobOScOIi16Mog&zCaOjEd2j zhq*lW`9AeHC`>_Mi$H(i#Nq;_yHKH*-nV``V}6-kbLk?gx$V*vd8z@vi0R~-V6*vv(w z-|=n>>FTqEDmHh-#9D8}#q8|nFqs(aF{Td12}a70B|dNrtIZ~#HCjlUaI*u1Ns=2J zWvT279f!2B9r}e8CPCD$f|9srT(NVumlqfW4h^9o`V88)nQzOUiy^ic>%EmrXOc%` z3-FtL5P?3Uzy8`datl0$O1~AEog^*~c2vQF5AdKjVsr1J0AxUZWrDlfqq~J+=CZXz z>1PHKnowYj7ty7rzDKr9+QR2DNXjp%K%Y_aimPCTt@#IR4eK88YH7l z2)-+^{X@TxXznyP4!er@OML?15p z$T*{`c7d99=LaG*6?ItHS0duU$|TD`Ur(@pu0dCv(+4OXaaXl!g}mxgME!etmchBY z4Vo-~1WkOwlUV6sl`yVUZz z@m%2SO_?cEVGAmEYnu^$ecXxFg&%#Q0}Ax_;Cl7L(Qjs%{6OrNL<^HmI}|rM50UG7 zee$@<9C#l^8tN=#DxYR#?dHn6cB+;?9ZCwX&a<1kiZ<&%87ED)EA|B&67<0lWS zmV`-oD~v|?r)x0lJ=4nXcEVso{D_+e-ID9AWq!|Zdl=<;#eUztan{Dhr9N7WKNfcP z2fkG!7JKPZ+PkvHsOwizc_=&`x`lBwCyZgw#6>Nxu;xSRV$&C|A$!s+5GV3~$*e4d zQrR%ahK|R9-0+J|c6p?lMrN)UqgG32c6@G6tA5bsUvuedu=BX~CdML6w%Qxr>1E-d z=8va4VRn!<7-gi1yx%%xioTwKIU{aB7C@@irkka+3z7^! z9W6a`!s|%j4}Ah%>68{M3ZitFSGsM-%xX#L^a9v>Hli&6Tqext|Z1YAYw>?+WSEj@^&o~}z zXw#P_5aH$hMx@pU9<&xlVGENBBt>*LmK`)tjTnGo9##gE2zrSWN{mX*C|`f`*}fWX ziAaZb%GAd{SlUO9`+-xtV-05v1X-B8?InmWKcY@rlUKul@zscjPnKYvOoS2g7^9u% zr;N53j2xIZ$?*zyJZ-b(1FDlV{F};5YEH|_ikP%Nj(HCbfCnD*&m4KzoyCO{p2`YJ z-i7!JCTlyAQ+g;aZ#kA=Q$n9y+) z_}BPHx(%0m0tm(}Sl!MtY+EH)PvTJo>kQ`(wd3;Dowp}{`89}Gwp(4S{Q7%ne zSec^*$&WG&gJEZfs`Fo0AMEOs=o1bU3Qc&|azM~316`_WAu3BtGtN*vo^z8K3GW!`v=?+AI6QyuE7hpjQkkt&r)fQ0?*SPF zk&9d;59I5Q5A7WC7zvCIwwRYfGnSOoZi0c?tCn;s&+3gCi>BZgd5}Hk*(wpf2`)U2 z5rld>fVvifUY4SfNR({Hjy;04O>xFgDZxL z3Kl0pqF*U0Wj(?pM6oQy5~5$=D{XuMesJU}5r%1;Wja0q+H~>x12GLma51fTWxH2H z`GAy;&fA-V*-|d(R-y@woT9~-y+Jw7f=0u&c542e_wB4#5NEM;Q}>W#wmd3xd+>3) zofF56NckEeS(JpN5hKfFBIYi@tWZ{4CqUq?wU{z8gJqYW$7O}U$uW_JzyPINu=n1G zQO*_N^@X5&gjWn2vb{1z()&rgxp{#p0h3WJ6t-8>=J_(l_ z^zy%T=0qN-p|}QR$HA!9&eI=)-={)gqLqft^)=k3BI;g!q_{cA6~E-qQdz5VsbRT3!V3gb03b1Udp`Kx;8S zCm%GI{g~ESYf{i4?8(z#$81qk&uANWQJ&yJ``90~Hd#a;*9K&hci-7A>HcYlVH~&C zf|~jme4w_>ZT|J>+I?DtnME+6#~r7+(bq?+5-sKZIF@UBmNP}T_e78YulA}{kX5Rs zZ~&-yw4|7hm?0pmhi5&H?w$Zf-gG~tIh}F1{o2{Y=+x~nx}y-2(ov0=kFBc;ySPMa z+G)x=NYD(I8@}ux%Jg7jz-!;g>q7p%Wveg zGE`EOxm9zyr@SQ#(?3|m6McnDUqx~b5=IiqZ5JNV)|`f8sSA@y$h4`5u29?Q055)N~ z`=s2lHJUcYA$F=~%O1Ye>nD)q&v5*4JE)cy>DkXFDx~D;pjUtJlTZIeD*lda>ndR0 z&FIq|2EmYy{a~lU8H!WuGhh6f+BDOjI+REXsKaC~A(T*fRDJ3joT-pPk?S(Egj-*^ zK5=(FN$dy9R-BLn(rH_y{&lbeY7L(24vSufPe2Cl{7T`orRK2W2u<`}AG&q)$DBHQo1J$NdyQRJjQ z;c|j(4XH#sOO?1A-_>TS-Nt-8_E#)*#K9K*&|QALje=POZE^PhDhJt{#Zt~wb>v!5 z;Njn!X?EtyOl4NOzSJj$T+5~w`N+POMDrPB!$s)^vAk}HB5=NFDUoVL8S*Mp^(W=a z+vf81&RSz&IiIn6ukZw5{n{)xd-gr+WtV{pA%yk_mX6~%DdNMQz z2FRDP;m(t#S%d)Th1)&WiZJgT)R=tB=3Anzc5Yd1=T%>kM?Cl z8?%4P?fuxt<&u02JkFl2i(}7748CwhFm@VBVv1FVGn8f2tkjVbT<`)frVLL=?CZg+ zc>}VW3g8-$2@JV+o_J0n@k=Y7gn_~V3w+G3f@Z^1pi(-HbK-T`#aNro1Ug=$Lb9gq zes;A43-o)*&}tMs@`*STvDCqFq)q4PAEp2uE^rG3Akl&PS8DC=2PLLgOt>HC6h`9nD|cYIJ; zsMON*R=|-ZJM)W5pQ3fc0mTg&SCj<*wzF^jjgC z?G@EwhBV=veNTQ3`;?H7xI9m2C_&gNh*CEP9sCHO5(FB=ZNtp(C-6D6asTvb0Z7x$ z>=m;k)D0PHof9xgH$$31C|&q0olTy*56~S+*Zoz8>Lpsb8 z+Ys1#!b3!g!Mc%x<^~XN72&H>g1FSuI1k;mgwiCqZiE=w&}s&nvx-ydm;_Z8JJaMU z!pok-C?U7*#jt7=62H6b!yyOB_2Am^4AsWNokT*t@guCuUXc`Ib<~konjig4u0%Y1 zMiwMR>^QjFOCigi((p#&!slFDkjA$?_;Pl|@bd6x^VF%4#V88Ww@ha3Bi?j)s+&hP zjvS*wu*Xl(=x5z&R>$C>w!YYBQu|p(1fwc~iz&^vgB{%~ZeyiBUmmy1>VHx~K%|&= zGu9*HWPS$S^0ot)M)>+XHlzzJkog~6GDPdNlWughFJqDNgS~6)3B^vgDW-HnywbW$J%46 z-n;;<1sUVmf)35BcN3OR6EnjA;9a?{4A5SLz0Q$)vu+SOWv6|?``Ul;_k589jGz0F z(b+~nlF>EWf1$sXu-gA0Dg!I$f2z#?f7Gs+zTfgqE&Olo>RUAUH_E{HU%1b|vww#Q z8915z#U2RgrR5~lHe@hK)|5d>H%Z}1AvoL;B4c~&~w}tgTQw^pT^#4Xa zZCz{(O&pyp%xwQ>@6*W6#>Rl&+{517O5hXtkee*&KWH^}S%wx5-i^&f=i zzsCPFN&1(|_}l*{OZt}$`+wQ~g^>Ph#(xl{|3Q`htNoWF{R?LN-TsoGe`EhLp`71D z=--&X`~L}-{(~6(W=j8#{%!vSJiZh8N6HCI$LAXgGbm-@+#D2%Q|=hs#SDbPQU(bEs2zrVj9L{*_t2L8KV10gaeq z{ZlEOc|(sz(9DmpXQg+3`L-sbETpdN4?h)_Utn26RZ+v;mYZJ@bIwdsI0A(c=}54h@XXXV``H ziyCY#`-`Hm{LZ$;vR{@61N_XwFYJ)Q$UnKU z<^00RFj+b?JIA(S0m8qylTSY1BtGqOpSyo;f1!DPZ4H0a;C$GnJbyj#eW{r%lI_d}Zx_!ABQH>};7re7hT@ zLH^M@TS8K1j8gDQ$e>c_M$mp~c@tZ*A5ztpW`?KV-;vpC%8V~7vcTAI&$XU26<_QMvH5_iH^`nz8IXA)OuW@dV7F4lwZM%h=r;`3N%M0m-ct^Q9l%KAsLud{3T z;Mmws@ScpvE7(F4LsRhD57^<};o~>o&_{ZV!7rXMtTqk}Pk_d+cS5ZqTox7rj7R%TohOn9e#&yK!8@ zq`0gT#h5sLF4}zFNoDSA^&g8>S z%{%Znf;;FZ?%NQSQc@jrAuKW~BeGs8LUn6!=a4okh41xM&>IgunAid@@IB5lJBX zuaCu~I1_eOw~mC#HSoAyhcQ*m{B_L?s{b5|Oy5Zj6ay~ZD`O=6B4GB7O2EEu;6&u{@3=W;^fb`9f|%x#ajk3&NdT>p68V%R-d@CC zO<1%mxX#tRCOVw1k8u2N+X+6tvH4R0g3a+%g2)zQClE5V^i*41XYNYqI6?PM= z^BD+|uF$$hQq0}Y=MqItK)#|sR_ffWN0?Zs${8cEdA#VwCUQkTiYav!Uhe#XQ{N&W zV!gQrWT5x*8{_!$u!mj)zr1v@D^7HfM}8?z{}R#A^0wl=R~i1=Cq&XVElqc*;CO>D zowB{y2r0ie<^$8T#2DrtEE}DxEI^w5;R70Dfglb(diUVO$nfHVQzM=I5}Dhf9E5YT zO{+#!Zfb3%|81=|vaK3grA4P8!?(XPkK9wbs}tsEqb^JEv~7g#68`pkeFUo) zEy*9m;Hy*$%D&hcDTF=pC6Uz9LsifVvJX)#Oj1&4s~qKh>{0Y|;0a(0Fk1&fmW1vt zf6pHS77QzRVV2F|U&qA;S`Oe9-E*lPW&`TcnJsV7Ui_}U?ZuE~T@A}MsTGW|MW}YA z8N+F$uB?A5ODfB>BX`U1>J><(wV+j!Df*Sst&+JKb;N@E<9IGw60BJ=nn3Wh^Sm1y z5CMSSIE>+o3{SJiN)ngF|FB!o>Mwg;2G!8(dBN>bF_>BH!NbAeY89lDnjhUcwOS7l9Y`*_a^y~zMSg~5)ZPKf zaP9Io45`+wWXn~KGLn`HOksX>F6f4a`-Ji7PVSyu_23UbM9u(fI*%VId>OjRHZc8ZY$O;3(m{Wu47<0Dz*x$Z zZ86{Z@L9W?c&SRTS#znziBo{pxGl;!w=+O(Z2>A&QSMaGeJ&I7-3>6LN=7P*Mj36* zv7_;46_2;)s~e40+fa7pkC;wY3&I>I%BCzk1);=>=B7Vju}%mmocm-lAN zoqO*!D(6kruKU>W9Lbx9B>hzfJV*SSRFbkg&jsWRlDOdQe7G2e!#S;soP{9-TGB&> zSqBlk;&oxFek-N8RvREC{h1d0Or}L2eW3s3LRcrgw)xEUnzbwt27-fn<^}FHD7fZ# z0B%G)y=P2imd7CB5V%+FaS%##FpKr<&L8%Xn5yI2bHPa!GS`pHc?U8GZ5(q->q9{Z z|IYR%95U*Y>BC*DgB6ga4lM#+er{_yNF5lDlO@TTmv*CqjTK^x2$qVs#CaS$*x`>j zI+NweDGFMeg=UQ9q%2G!yoE5tq3v56*y4i@C7AfWO1dqeC$IB*M?D=e1Ip4Fa$9~! z<4sEj&nUh9;ttAOEFFJ=iDO*9)hz_s@)xlgznN>+FSTsRxQ@iBAuZ;4xdRvkG>FQ; z+y1`ko~y<4WELK;5MtKGlY%gBMlCl3UdW#;Fj;C}c5?*+x5jnDGmXfObO2Mihpb5=kbtaq^@y+B5}^KKaD=ff3V33s%qVpQWs;BP4GNp7bE<>&#qFQ#P|Zvp0RMN2)LM2 z-nf%-$R!}-%GjeL&j5#}le&&GE3te)D~k}$MTTHn{YV9Luu6&94fz(KNejilRR9OP zNnCZ7txV)x{jE;Z)v|+fR{kf7P|BTYk94|{X|0wtRV!IB9_OY?!B0K=lP7_N-vV$SO4Ig62(e%!=c|YD;RD+( zNi1wOuU6b(sx@; za{QY>=nX#2_xke4mJdO{ct#!Ny^-@UGqH^&Hi`)Ox6%eFlbYZLwl|R&k`Ygn zK}?m_tw)6h9!&=AN?7Fc@{y#P3+wSPQUc)XdjRDZiGdci_G!4;T?d}eGs*4Wn39Br z3sl{^W+J`sFvg0eQj#LlRiUKKIM?;DWW}+_>+Rqt_!DA)1B*gP%4V-LpL-*n88z4b zYH?$uzkfp-#HZejh8P1-^OjZ?D@JV*??>CkB{M|Q(e2H4MqhdG=06ZW;KxWkd&#}( z5jH{vih%W`h08%f1DeA&Wpq32_8W z(0DgCzP zzA_a9X+%-*+oXg&H`1FKkkdMgCN--@hI$FoW|Oi5E4-72ns)ur;wOuO#I|wLwf{ui zfDpwy8olKCRwc*yQoO%uqhJSCd_T9x#j?->kCky)_P{HNClS^y9T2rUB8mDh(mjP$ zLt<-J-L3jF8hW5w4ALB|Ou(#RXS zlh)G=`TN@GX*vu0HwRk#@qmi`R;gCnU zA1*k%bk;Dhs)Us8z4b3OWeE3O(9-ZHdZA*s<{8U~5co-(3W6p}c(qBvxhBb6TXUAR!45Tr zK3X>qI^lJ6yA|-P*xRVxjq9wR&^9FKjxrYcbuHqZuR$A{Mz@h=WGajYuYzRu7{6T7 zgB7R7G!!a_q z4st&dKs8v{o$iw6MYEevcKfK~^{ugQg=(NEkc8CQ06Vg?O0wdj>P4l^{uySTDHUXV zh1i-uL2bn*7@_(wn#o=SnjE=WB{v9f$+CEP?mDtOuUy=4)B<-6E0-J420}m2&(48K zCDY%N^f#S27};G^>*(Xu(F0lPSdF4R z7x~1B6xGON;8$@$^Ogiuj+p)qBTV43aL(VLppFRJ{{QDRS~I`P%dQ=L-b6 z-SXp060Yp>&?W>`a=YdqlaDI0Xgzk2xi-4V_hpEDdi@N(mxHkiv${rBces(C z_rlI>?Gh3ln=A|ojzbXXNXiWU%R1wdDKmZRk>;+|3lwc{9QA%^0%4;?c2Wz6TXeg{ zClAE<&!jGs`YZOgTD^uqI2&c&`K`-KlRgnaKM|t+8TYC>$>fVp>h``UBxd=`!}xQAfE7`eH=dURQ0v?SSS-=GQht zBnxS86}ihpq%wHM3 z=TspNbA%=$N6*79#hG2b;-T&!lC|c*FwFbt+@`twV}oGRDJA;>(+Sx3OquBIx-i$; zoS$Bq?ftP;ib8%*Z=f1Yp>5E=V820G5TDg;Q3qb@`E9BJ)r7m9_pWQ`;WL`?MKwS_ zSSz~R)%mif0cq2*fx~8y)>Vl9g$t-;Y&#iFx&Y+48PnJ z5z*T|x7Q_KKR-LiW}nj)TYE<{hGa(~<34gjY2$u^zS1<_Y}Ia2)?I9&1&LaxnXdtr z#_~Kgo_5K4q4m1(%I}RRa~>h0h~Z`8VO1wddPQ*DX|bm~|4yX2jXqjFuQLg7DOH+# z*#UD^p0=BW^rV#hL|BAU8ZX!&k0waI$WPnka`_t`9%y4#gd@C&`$=rcHd2X}`#y;~ zleqY73f9}&688tAy-Ydj{1j=%A;LBdGIw`ddL@zDU&TLiK4B=vBvb4%ZR>St!|r{e z&e*QB>MAN47u*Ntv)p>7AIRwgLgMUgfy#vB}@-)zpRy~ z`i^j4o1k8%#@98mqi0P>bwk0sFxsCu^SK4xOWr~?ia4rCv-)|4N(0{TS+kG(Y3qNK zsE{f+M?d#U!obYr17=Q!qY-ntTNmL&2j>n;DR<0m);wAyr0WqkwzR)924T5hWtkI_B?>5qnf!ambKj zC=WETxrO#Ky62mQzfB!PCBm9mEXYkf4M#gawu^#}O~P^A)3{Z*`iIH3y`bI7cYJ z?2R=3iOBQx8I-W%RLh!K@--Yddg?Ukd@IgnRP&b_T=+xS6va+k@-z>$K*AmE_C6HN`Gcd z9vC&*G(y1m*0d?7$E4yHQFQnugTqO7v<80vgFpQlo{VYxPaL@PLzD7k3U|=K@ci4Phax zH=rp9eAVOBW3>|79gUQA+jQ}aUim{3tWBp1-Iz`^d*vDYa_1x_`M3^k#(;^R;*EW4 zdV1y7^nsa0@&N3jROK*z+=kJCp?IQ=b{-m7+pN86efB$k+ry!NSFlTR(G-f=7zEgN zEZKnufG4B)P{fB|;D@xPYQt#~=-Z1+LT>XZX@D4?9Oo1WfRj!%!f+K!09YfYP^E3Z z)Zn@2>lGdop;vWAl7N0D;~J_G2R1s@qh2LKg%gVj-HaKe+EV*PvTUu~5@QRVuYC$s z4Mg=0iIO=5PuIn}*DDCq-NBIvVOfm%dEm3gx09IwPyEzX-Pa!OG~S7EUqB$_Eq^%8 zP4E4#zTNDT!e$7sLEP432KRUc-YxSGr3#83{h)H1FBcb+=i6_^2a1`^`ywX4KJ(z{bY7WrdXy&t}D(mlZjZkt-JZu=EWbw6B*Hg zFNR2z7p4&Vl%#Z4y39YAj)Jtk?(M?l^Ls&MKF3g(eU0=+{Z^}F)3LV7bNZf^NM)>n zx#`5g+nEkjM{zm~mLm-G)Ef85?Be&x$%c(*_)oNYM2K+&d*SpXai5vM8tR?odRS}g zx+c2-hruZ%nrJkTd`N~)1uGb8^n6(2 zJ)mII`YN;5*aEu5Oir|=q|qa4J!5*FJd7=~UO0c^+Q66I>hXsvIdqPSVe}v4%qZ?e zJ`#Kr^HW3QOa|^__yrtD*m}fbcSOppAzZl$e4$Z~fvikesn%RCiM#;GY07jb7}~~d z&D80Ea>Z^~b3`L;r&Z;bnxIGQ&iJrn8L40R0&bk;W7ooc7z&i!L8mHc78v@pO9R99)bs zy6#mssLYzkc!=(1)`rn<`&PZ2xg(|dRIt@FXDQDu^A|FkLbV_~rl?u+4Qe$a)J;le zl7Ezeca3rA2b|8LRQ&NRW6wx|nYD!;q=}~7%_!Z*v$f6j!=T_e9T?vG^=oO9B}u8) zX{Eh4S`04~uMJh3b1)hlwOPC=p^E3YHu`4u$g40S%c;b|fe@s^%i-tp;ORQRc^kWu zO2#PD3|{LI1g06a-%)(_xpavjw-4Hoo!y$Jxv7SV&+tW>f>HUB^vI!15 zoqGAu!Bm0$=;KpoxqjCcgtIP8!5RHQ26#-SY zMQoYVSUo-&lfnn$DjPnm6Slo_T*7jK9~1d(3ZJ&i23D&ZO_|-~^Jdgi=xAxG>&~}F zgYi^U0?y>l;F9#)+X_2z zj>lqvIveIrNAdYZ*4Zztdw^}djn;V8aL!6^C$p@L2@`dV#&(ukWweR`&DPR3O3Dd;tOJq*GCH8a@d41iW@Tawqp+OY433P(>ZUky z+AB*f6O9;2?U=A}ikmhoyjP~E#*#2OGR?u)F}-BFJi z6)8*+T%$_41ZocoC)jx)7esYcp7b2I=5~TXHovywVAkXV(1eDGPiybaIcw%+-y)eI zN0EP6z{OJ6Om1I#F2I9LUmt29em;k-DW5fr{|az>ish4E)ODbIxY+VfzkowO{SvcH zouqAnbkxj%#gz`eyN8Qs+ET#vN6s=tUe3SmutueS&6j}`>8w81HX#}G+?b^rWi=<+ z(N<-*9{~EfIukWB0xDQOX>yD(k+sxLhtw+5jk_Nds*ngL#3&)ad#TEB_$$XLg)pe= z(Sh~?Cy^P-7=|Yky|h>3G7kG}INGpAQznfmWqV*j2lHBu^9h_{JZI=!u9Lb1Z;mjU z#vRfjO2Ze$!oe#{$_m<0+INxx#XBYF`_j55OJk~8Mn!BzwkR8Eh_5Y6Ww$Gn8M98|>{At*8^+7O=(5nRfxY#JlJ>jnzNqA{_xg(5ti`!*NXz2DnAw zF*y4vD%!mXHy#<#N53ARJ3}uq!+hL=0tRbqnXpB{#33#VB^%h6J)&{FtIF6?Z3SWk zzdYWpF~|6^)bk+m$fxk5w6#{poZV0;JHL)$C$4ueddln{Oq}3S*(L2!@`^>eQx{SW zXpck|@;{BBtFh!mh%VYUl5|pb>8RXr7cM5ebfAJHhRTA@8S#NNsLMCL%086kPkrw1 zPbeTet4#Wtb%tku1U4y?`H_~gw};?~Elbhnx&E1;ob66>*&9n42c^P@r}-cq`ofk= zj=Wcwru(ug5)Xejt>uxDV(34S^Cp zgO3|0-wh;R?we!c?yTXhiEDs5q*%b2rxp~`>dyt(3fiS@?Z zZ6?n>Y`=$#M72gIqUaN2a%_3vsy_ApMvW@n!FRx|+QsZDd#i zU}O9|H5LisB|43L8B>U`2k^z~dyD;NHY)=OehLA8@qqZa&*pfb*h6H@!p@<$_y_<6 zNH42xruZHMk0-D+Ow@po!jZ8cl`R0s3(v`0nens32J^5|rdQU2I_QTej9;iji`yvA zCq0htL(g!kyeM@z!{oWt6r)KQ zSDXWuUj=MHk62x5*H3ft)#LZa_^EBmp0C=NHidPZ;v5(!YNT=@QA{R7SA}*9U4*@^ z>-{D>PeO2!Lu&*M_JqFF7blYGM=S18$Pig|b9f7BJO{%qvv)Hd1-{g7F2E}{ro{44 zW6g<-gvAgPcB*Bp@6!PX`b4jJjR23)JGIImj6r~^%VjRhvOoF^?s)Aa^QKw40c^HHYzIox54T=mb1vGJutpF#ID?PAjdlUjJ%!k>Nu3KvX?2`{E9Z=KOYR<8~-o zo)F62pzh=VzFe_?u+VVLE;H7hc@v&W>7lNnxc(U8v&IB>LJeC~qRMMGYxx4o5=|pp zG#Pn=?5s#H0(0h-4_Cx5+>l#jx8|^cv+&Qw6ZIy5o~!=0=4f|J73k%f_W{mok0>mW zD&@M2=}TtB=W*xNsR|t58>XnlIo3W)7j`TWP3IDBA$HW3S;r9D`R5u3kv3l&SeKLR zkd`NdWycZaXj>aOk06oQaP6|Ebtz+FVN^Zfu@y2u8x{J8^svF(Ou9hiO~Ez&O_ zlwub#DW(Zx=vP&<6_ErCfq+Ya=!>Gs=xvzAKV&7jj$1InC!zm~wtIk)^=TJHKelaK zJ?0wQTw~j|ZF7z7S!3JA8mzHxn`id_+c|fieZHG}Z*p!Yom5q->v`W)rPF!q>0c@M z`z*YVrJqlBdG$te#?+x{PBL&J=IUV1kmR20u($Qnaga<0L@EdJ>BpF_0)peh{pg?I=Mrk)>>au=@i+ z!z8J57X~;Re&qmzQmB6cUW&-5FwQ4HpM)pozW~O{Q;yTh>H77-#q`jfKfPiw&USwB z@q739nfoup;txh@l^$3XB+lmQ1Pe=jJx)7&GOZR*XJSh4USD(;#`O>*OU4GwJcmD|rDz+wGIcK^H=!!!x^9xb?<|D3ZY{7M2@zub7U3gf_>Hr|?A62$NmM*04TQcu zfa_yiLDrb`v}3UQ@T1+N^NhZzm^+EQHF>=PXPF7?l%Jm>H^_-lJ_jzSc45iqfTwPy zLUCmM^z!HWsE4je)b5KB8JH~xS*H$25VfW@oCgDy(MaF=ImyyR@*7HRJNg)vM_Hjk zG?5k;L~Y%$k0I_cL0n<2DK%}n+;^)hp5Y6KbW}MtAKsh}LOGcPLKUN5QRY}Cg;nzz zh~x=F#e3mz5y(SQb{tI9vR2GSGgw`Eeijd`zJOBx*fG1DPW&Fh$>(iIy_0^aW?0ME z?!-THXw-;n^63tbY*wd+!nLbw4=v)r8hZwwx<(t&bX{|KsiV|3DKy*dRiwV%&{IX9 z?{nSCJRL{L$NBbV$60pEHtcL6t5Uo_iXWDi544;2v=DLq+Lrp}Nb;4_0V~MI8&2vK zf{1bx=SAPghoCmUje9tXxP|Fc=G+eSs@WR(Rb8=*c5V%Vi-yVsCaB5QAwSA1Q(2bM z9=cFIS}4oa03Snoq`RoHC2ADbD#~m>jSGH6JA*B_Qp$E?%}$I|!|bav1W(DA=_PAR zFTjtE()rkRikz&;bgcPqqPK370NVU$WC(M0ln9zRym>+R`GM48XXsh>;T!c86eY)c zvK56<`7|Fccw*$+uZ+Kz2dKKa??D*%Srnz4iI6D+WwDUd&sDa%e{we#b_ zD^dIm2!i5`Ulc;I*>vRP6OOdD9<&)do&*VpFEhM$5g-M5Fo_BVy>n;ZK!YpxnJwm~ zK~@pxKf$*gup((Y1^+q@t;EHiMC#%M;ALA}8*CuZww048C7Hi2#R1vdiY6 zAMR(hQ|QeB)r{@94)RL>y;DmKeDWmX&<8X)Yewm7W=~EPtOF$vOW7F4&!fJVQ1fw5 zO`Sb0AE7&Bu`2fRg3dLHw*{zt*;ffBVOmbk-sV=d&hx0Brp5=!4LOo@|0GDVp=No9 z)VI+4%S|1LVehC5W*08IWILQ^?{h&C%44w-i;`tNdAVGFZQJic{*&NF75T|y69QvE ziI;h@inqy#1^zaX~$K3O^0LL6O1I#NT$>l*i)Hb&Vk@)bEpXUijvJU=IaCBgTFc$g# z<2kxC6#0GD7%6;QQ-T%kwsg%lCqXR@RF=^UT@C(VW~6wlPvn=zC9?4P!*2jV3kImT zTC01;fHfR1vsPjVO+z1?-zH@`4eD$6j*%jX+$aa7`MLtO;-C;<6 zu7{4xbm-VtWa-rr1`@W5CZ=iua)DAH8CUXT67Zm@whkK zY1$~b76SWV!)SH8-m`+mH=WhUO5ybPs#{BZovB5Hu=CcTSZ2GD8V~PES5mO?dKF(K z{}w7WwfG6#YL?C|r8x9QwI(iDvSNDZEc>f+KW=36Ao)zpxTIYa^*FTuKBt;igp5kU4>+Dbqi!PXl{@)4q8f`_Ty9Rbt77@MjCW++DK0@ z2Lnn6lYntvvl6jXj*w)xUrvZ1afOh)m2m;2pfUX32aTaX{N7wQId8Go`$}*4;q-1J zW~02{2Nj>{vO4e}5Hpc- zThMEI5M*K6N#fv&27W_H%ULxJL>WiBIkBhCh|kt*)U}`1OWCCxE>z#YvjBHw#ia>* zfZQ9uk@!d~s`(UUP-&PySAgqKu1#BEH)ozw5{5L90C@@>s$~VQhx8 z?I)Rc!w<9SfW>&~l-!lR@kZ9uX&7RMT=uyoQ5X4%pRD-*{ z-GUygQ^_IHd64b>c+d8AKSE9caZctm9ns4Cp z#vlKJAVS6%Kh*6Q{5x1-zZ&~rmg?vZk`q)Br5JD7OJkwhoE8)~U=6T3w)Uv3lmc`c zlgE!Yy(zGOtArfe%51p;Mx`~tj}^3g>z9RnlG%dL5T0|Ezz{6RTucq)r}CO3+&Z!D z0THE2*ZIDM^oR}q(hjfc(PaVcN;lI3uOO_vqDVI75L5s1LXp@av22XgOcSI@_QrLK zq1e&ch_SWzD$&1(ysr&>+SVrWWZy^b`3Figm)Yh&Xz95lRxkICH)~tslYUMI%Q2Eypm&FbEE^r) zV=7}kh1h-d=9aPyiQn>?VPu`L!4(nPNpkfU=k&SB6S*Hiehp>sPrrDTaNm7IaXzAi zg1=uGXZ3y~*|DTwH~I{+rxQk^GkKr^BG7qoFV8eZEma%8BG~1NUVm1xxEol4SF?63 z_tUa>G5EQkp25klFd~pTA=#i?F`~U0a7xlg_t(eBcWjlkM6nn*Z5-7BKe$VUuBsBv zr18KJradvx3HJjtwkIn*B@i%d;Yg&~tL8ozJV3{Yvslj6ld28_50u#6hT1*nErPb~|fe|I#Ky zoEa<4HF)RLY6fvobpRw`m)0}Y3*Xs@MyG!k zFK_Ze6~3Hytz|1mjZ*>MsRKj>E#DP4s>Ne|TUWd;4w zW=Bj3{%~jM*wDxRf%j0_2tgT)9Cg$XwCdVnUdXgcvt8K|M-G%SSC@eTh+(4p_I%*y z(HYEgK)%m%nM3$N>Vo0+D|u$9$eA>K0cRrG)Epk5d-;3+>4z&F;pT=wWe4bQzqnM2 zG2H5;iz`q&1JV#!ap6{%40Qb3caH>9;HUT+eT1IHTPP8X(5J&AA}I@)Ez2E9sP`B= z%+M;9qw2|H1{!IVcq9hvNUOrt)?;oBR2|l{WEu?EJQd>K4~KgDXdXW>epTk(M~u^C zSY@m(tmNL4Pzu7exFmjvig>p!d5k8^2&#EH9B8GRY7g$Jn{GN?0bhDa%rc%3jS~lV zuz|auSn*$_4;I})<{yq0s(p6$7d(O(9j(O;F$gV@Vtzp_lYHE?*8BZ>2a3=PIb&3= zb}Ct^4_tJ|r>LdpRX%(MZQLEjYj?U+`Mq)ZfRrLlc#qm;J!oZJ)-SfBz*N_5@Z9E^ zVvc1F5pa5L4W52cE$lp2XSy%{b3vY%21dM{YS+~75i<&`~9%_b7#=U~ft(+1G5>9Nco6^^#W zlBd!OA?xKZTl8oXC_P=?E}5&e z5rPud6OR03Op+%Ui0Wm67}&su4iyLvjdQ^4cVe62+Aa)auP#9}_Wwmc0cu$MHMb;U zb8w+8`DZS8LwbAdm{I=ey{pdR{&)xDQuP>527RW%(#D32I0{@@9G8v^3Jlcm#KUcn zUWFkh^#jG7K2X(!?a8tbKIaGJ@J9*mR}xj53Q1AasP48d>rI(h^jYm+YQY)l@Z-~| zi$)5P8K!{@(1x(9ei-(tff3&{>26nHf)al^KfW?ew3wT`?p&gIq5ys3E&w*=v$6Yu?OY!HlW68_wYy82(h6JyXy!^80rb zZOn^dP=41E_Z-85*3Vv(+8kD`Xem6!d7G9!*_5nwaej8r%IyaPaOfNGU@y#zlH>q4 z_-PrXj;_%;wxnt!0}HTlgLP6a-Xga)#gwaQ>ElUI&MxPdTS~C|;p&nOF9PZ&|AjTW zB0T%m=>Ylpz0BozQ=*2ah6*aGoFL~hmlya+^Xn6_>D>}$TI&nMAAWxMqFh3(hJpd> zx?CkDYl}BW5yW|0Yy$|YLd*mEh@YuIC)s8e13YN-$+o*3`O(R4Mw4sZrZB_paxQLy zSdca&0>4MQ>0Juo&~6!^;L*?gZjJ_DfsMC`2D%bjiJ_aIWT+MiKu2B``C3saMpoH9 zU{gqkiTcG>Cu}vo6CCV$_~csCD-C(eW)W5Em#y&);=V#Z!A5F&dfQ47NXuI3-QAYz zHF^#RV$1e6ZK2P97&bb8c<%)s8)O)M_R_%|;WC~ksT+SdO`a_^bw#f(cMZBGqG%_z z4?!PGBSHw~V7uAc*o6^a8bMiDB_a6Us|z+n>cfXgxv=wqQ5+>fmjBGk%cO5+GZDqG zuRsYYR_(j8ES)0d~d*r~R%cd)>)qugS`KEXT<4HYhUz#mizh}YHZORGZ7 z&sp>HYd)C=B{80gaV_pu_yBv~EB1JKLb}MPwuz>q3`I{Ejo2C5aMOE5Sz9`loyLbu z!Z(zU!iB7>AAC4_LXnqXSs}OGR;xlgibL1Tx@}NhK|g!8H7o=LLm67M=FHvfhZH%V zF(J+`wzFv%z4b*O8x~OLf+IM?iu&W6Dpuk+-Po^9R=ES?VF%3}2xl;o)G&xAMiN5o zrGt{#yYQEm8%F@+{QDgVy~M&nH(%t4F_xDGW7<6YMs>VO^xH%i9)Rg zx-C+P>ym`9@z>~YdK@xPMp9iG{+e@z`XQ^esDu()^B;U1{u1b0Cy}H>5vh_^m==-; z#?WqENfFWj^EgB5#h!7IQmfBW6!oGVXsq}8-p|rEb0^lKeaVMp@yv8AAx38oyCP25 zz*)<6vmdbpP_EhrBi@jXXTA4ZjQTPQK%4Yxt1Tz1Z~*J%cr0dwBS&oQTggq3nxP{X z)p4elG{y<6*cV_3UJ56y#EEv>U|c*@nC&u`38~LMP_IE$rn+_mbBiwA*9v;>EK!Uy zKiGZ6YMDZ@QyE7FJvx^;EJ&2hEhWfZ@H=rdmwHc?u@zFCjWatIpyAR9``XsUzvW%1 zsl0`)z{`#(vj}euXBwr?F)09T=0!S-B#=D`ny2!zBHSgU>{Ud`DXSy@_#|CxxMzW( zYtAd|c!FWLaL8j6DxtN-CCdIZVl?#T8vv(VkVIJcWshH9#%R5O!8N}QUsAs3Bwi+V zt~mBh@P%ntWzLqrzqwG~Q=0qaH7hTrTgnt2 zzB}_f%gA)Y3RzYfrC%(ShP=H2!K}+nWy`39wB6GIN-!k4p<$;OBZ?H zE3CF0@Jc$)Ei+1bPp>_>>1NmEXw*^731bAi1P8A~XuX}902}e$6a{F33vS} zLu2UAi>EfYp#$F5w!x|Y<5VGPt5HK(Bc&kuSxpri zI(j)=Wp0VK|64V7^depp7a8bqm767m&5+bkr|*_Y=jRPVh;z`kTOQenkmKc=-qyCI zqHwhvagb+Fpk^m6ax>9}0=ry!SY(Ro{Nl|6yqTW7TP5K2frQmaIi8FXXPyW9ExAXZ@% zqxwaJdDh?abYY|rsVme;!R(Fk2w6M>$aU}L&hA9CH0mwvOy!@4DGKMtYhP%}E!}Mr z348^R2BAqg0jiuZHh2iFwaudbrORViSYs)+jnPE13m-X^s5fo!hBj(T8`d?_i{U}= zfvqud`p&H=Oq<4Z2W?C}L)DQSvl#?Mn{F>XfD6pB4ChB)HDBa1wb!!3DKkQv7|60ql zBBMNw$o7tV44h=GHW)_~==gbZrj+Q_8h!$m#?>Tu+N>S^mZ)VP_Ac}6#OPQ{+k~h? zu&*7bzJ5azFWyqzPPf}-uwQMvM_ahK`MB!FaFDp|SY*HwKMXh*zuY8h%V}4sr)j(@ zn~y(U%clNpyDcuI6{nj_X1XTHjgblkAf)fjt=SGCD|d>Dny2=@)Q;QBen8=4AJ2GN z$~>-Y{7EppZMt@Q`i@X{2rtsb^vNm-8Sn~tViFDhyx3LmU5NjM+88? zJh?4#JV6^LoHVP(qt^=&3Jc=9>G6vF%7Pu6vQ8`_dUF?FojyCm=JnYL+|9N1N1SHZ5LW*y-))P3b9YW+KC(FBXUiG+ym8TS+Zy7ME_kZ*UZT zqj>CfL#wsLdw`dtq6fs$I7Z7mxH4qDQat>5byW>j~^5EC+=i-+ZvP ze^v{;h&d?zNtLob$)MYvMtz4raI#gqTUfw8C(OXXpVRUS=W<6?)!kciP4MwHVnnf_ zy~|5P;o?^he_T56cqneZ-|YIu9gBZO4E0zas$TDh^uaF0V;*|GunXQ>8F+7z0LMEE z=lbkyP_l~ihxGU032c%*x3mZkD~koMJ`I9zl5o)V^=u9^6sx+Qo54cithvZX+~Zk8 zHoUk&Zz~QPsbO5fZ)8Kf1}e)qoTiEeD#Jl*OR!?gzo`lhVu}?g4Uc8nj)rmSOkbu` zks7ov)kiEpuBKfs5wE@c)*Pvs5G#0Jm676M2pdzp3c26MMDvxyFf?7CEY+Li`!Y8Z zL!GAL%{7{M7-{2HvQNd=v3K7~Wh~z-VPWWg$cHQK%-*}{#vw#1&|60O_^v;*V%KL^ zH@P)fH{t-dF1A?tQ-}6-qh|rL^i#>{{*Ca2E8uB5ZyvV%vx48w1R_>xVeRbJLj$DW z<4x%`DO2%y@lKTiS$&zF3}G61BuW{xy&awC=zB!%v+Z1Lom%BKC9}nAT8Oeln12be zGFin>$TKUnBl~4-$aJ7Imx?)#fsOp4m4s<&iun6^SaRDVFt&(qutJXR7-C$ zDb0?NH+6c>E3MlN3;pUBn$n!YdvEnwo?h4J)Vq3?D?_Y=731N2uJYX3n-Hu9EnQp-*zJ$08tfvwW*<90R=Naj zHbo+`_=6hU3(fV%(?i$#15<_D9@Tv0|Ug+@}$PBe*FR5=$fR`9DUc44Nfy% zY?v@V6?|~WKYGIc7Df-d8+p*sbSnyk=2tClfd!M`L)q(jNTkqHuEpwK^?1{|-&L!kP)gBBRseZWT z*KZ_B<*R9P<*O4<%-DE)^qZm;+-`WH1dlvHNS6JDAGf`1zrv3AbrWF@BdCqBgF@-b{2q1(C~=LBh&Q%( zSp}2a9z}p4(EzaGzgK< z(Gx{TOP1~{1|Ke^S36rU=u0Y4k|-`T^^#G@Ng;EBEr1sJ=5A_UYQxeKN@_L6 zH)9c9fa7h~*+ANaxvyTSTgqeGZY{0Y>$C@QiavU|-32Ay`+CV~9yf%8`#+FyndbTQ z=REM0HT}-uu?jptIwhKZWeurLiitbv6Dt9So8zVy<%x|6s~VE7oLq;1r7}C1kue1w z-u-nRjWI^f$D0uymvo{5o46By@;);oMHr#;dC^Kd^7b2`9!-dvjF5srouP|!gINF_ zCZMVyZhT|Cyh<#il3Tx6$)ciAFZ`+Evv>0bkpF!Z9g0TuTgNtBl+Hs3Ns$BNG-7^_ z0!3j*3Yd9Iy8wmoq4(f71<-GkJmJ)2?0FLPb>&i4gL1QLKOV(~7fF@Y&F&B-(tc8Q zEt%nr59U(Cyptm8d$?XqU(i7Og(PlJbg;BzfYUGz?-_^=wKQ4TFs&y&p?_XcE`q@) zzkc6~6$`$y#C*B+Jj}w$)2FF2JR(G~f97XcFX-g|p{D!+#1{|vkhwo1EYM;W!- z+j|J}wD$^bjiRMyh0$|7oy|Yu`4zW~v!F(@9X4})IAqYJu7+jSx%kAqW4-<`u!uL6 zm~;l!O_^A8LZQg0Oge4?6G9C59iM*L9Sg0DTr+( z!^*?HyEGGFk1Ue5)Fu~Df^5RK=!&+f70H)7?Q7qRUkBPA!?T@Lfg1M5><(4}*4`IF4f}~>dUZW^s zaXtoSGKaf+wnNin;TNM;F9>F#-n%PgP1!WxVzkc55y~)ZI7jDzz#RRM%pmiWgWJf% zSr-~AwBS-xyjV~-=l2r6O0l6Snp@u~Ij&iUBDQ$x!&$`o%dt3H6~vFtWJD0sJoKF@ zvy@XOynC0Y{!C$>q55?Ky?7!Ar!8x~M&1)UczGRaGZ%PbPZHDJI@B)S%V{C}=@o9< z+8MiRdAHEee=y{gysd+rk*;Nk+mJ@Y6j5KVGkI@n3F|YEf?^Ix{?U01M*11wtXU)q z^(UkU6Ps>{%G^%r`nDEUeT<5^jdvFf{j^VbNl*Ciqn~9)!O-|WwV6i3|+j9;w84XDIaPB@5k&IBIqo~@{O0#_dlWupK%y88^{ul69H?3&l-ptJ84DDeegPXIqd$4jFTg+(i=zAIcsoaU|v&+=Hg?b!c zjlYH}m-4^bs-_-id7v<>uFuyf0bnLHJ_ZPna9?K=H14uveZ3UB;z>gOD6jKptktAq7>)3ewH zV*FPwpVaFJ2~mvUCuIA&tKkOCwu#@+K5YKDO$!!>(Hw#kPUEap>Lcqdd>c_3X;Nm~ z8|u|g@c14e>iU6u(5kAC0NK4UzpTMFGhDqbxdpqF&;}cxj!0`m*a6TciYs@4__-;` zN(Js?cVmheADs$^lnla{V?0N{8A?&6|FXp=>WvO`+l5t0-uR-;z$83jvC)|`mE%!& zBKF*Z(;$;;@yq#fP@tzI+{B7Tm9kOq-s^ENmDXi9g^tZgWvLph+{FY_6T6j4g&vM4 zQH78&?~aCAN_;*0%av3Woq2NRiSN%P7?D^=1LqffsNjv;hM+ry@=qTE;3YLkKL23( z=if>_q){-Ar)?|?u?VJpMpmrBDjI7UqIW~j0&Z41CfRT2(LYR8MwNa~xR!NOtJPxy zH*Ht>Y>+Ys-j#Nr^SC6aLWaiSop2MPU=)`fK6XRngq=laBRw{~i`I8AkQ7cTIQ0 zekGQ%1lfFYuszmuGpSCEZGS4|wZV7GDPeVI%r&Qd8VytkX2pi?;Vb&muh$QJ`~2c` z9~0=w;r6cJ4N)gVV*Y<)99jQQFpexN|BK_u1_MyDFm^U~B4YoCt@~dbM>#oFF+tV; zbR1>vY-Q+`Ow3&VH^hWaAf^98~-QZ$ox&*{l_>$LU!&%TJ%iJMD)xo97OEjejq0k)4%5%P27#F z4Q&1`;b?4UZEfKAA5No@iLEohz~;N;WMFIjug;GDfQKrL zaQ-(cq%=SVAPe}H3#kZD0w@Di06zh$|7k;N0t_7ujI2zY|G5Xl@8Z8M?LS-pbwB?F zkorFa~^cl>jqi^^=IoSXCX8A{({BOJ@CmTB>(SN+Y z=lJ{4gNY*%K+O7kxr&$=*%_O_@bSSoIe)KT8yNT1sum;r1D|hR(#4vGr`d)Q-#IJR z=5qO4nUteES#FMrwYj@^^EjML=f0XuOTRNv`$($}vHDQ`OF^lsP=d)0fs-KtWRrcI zj{VCW$Pt4*bUIc_0GErXg{~_xBAsQsCI>$?OM9Vjuy+i^oYr*PxF1x3g$W`&9Sc}p z9cXfWeZ6)cNHH(FBPb-j4b@-jr({eS}r=I$4_!pb1nwy`Y;V^b|VaQHZ_xx|m2UlExJ--$pJ-2T}SK`|kP zds}w?A*8*NeZ7k(S8!SWK(Jb*R%UyCFwd17;GdO5JdoRZh?zajJ^C;L;*{c~kgzG(cMtF78H7>& z>p}{%n*!dp*8Td<@#sE(hBg$2{9f@>6@av7WMZ*rY-V?Geuuroe9Jv~H_P?^D)s{9 z;jw!169xS`c;L6HwRdE#V>j_PF@4FLA3d?NWr5XFANF$<9bZI)(l>o=*<4<^^;rO0|-2e0|)+F?cFYybP>eG(+o0#1E;&A+; z75|zb{q*yh`9jz1Us=_h?mfH$d4C%Q`Xs;x)#}~i0gVTLcQUVn$NThSf?&s3y!z_+1wf z)D-f2OwaaUv-o@vu<`4NHep6C2$gm!= zuQQR;T)sP^eh|Y2()hILNb*#Vc6bO%hipF#bv!U5X%>t z7|jDZUoCtnF+TtliOQ>Op*$+lOBou6Z3=Kv-bcm3sNIuS;uEE%T(()QHng=872BQ|) zKE1)S<{%m;k4-+&$-oGct=pez62Qix^T&@wGBRQ1X1m%Un1G**jlov*zgh=$G9M@Xl?e03UmhR5)@Q? zQpj`GE-$*A!A6U?#Kpc}>lh`D@Khrn#uubd16HX}DEKL*e zdrIhkU6r%Fa70!L7biOk$@R~@&{iiLKhwmUHJxcP;evl8-Zz#RDI9YoUKPe8bQB3L`=jSpHK1@&y9l(_=rCzf1P`=zTKKN)KGCOg8Gh%7fxnd~aIeXOx~dS z@^|Bo_=O-5He^K(v9;jhHGGRLONk2s!iDBYdA!xUHkdH+nJn6(9^!p;Wj9}!k^K9! zujJeZpfmXSnkJYw&E*Snj+W^^q6yLj6gXplxUk`__{svWGkyDwm6_8~|LXAEdwwBQ z{6*cn@u9A@UP!gIxgsDe@jBHtwXJ-=Jh%N~s`*%wG4 z2zo{~0@|3Mr0!p}OIAWWi`ueOMrR&3U1H>hQPYf|WPI&m}%2 zCCx=y!R#6=55CK@TiD;5m*6LcYsNlU^wou?E094PS2p9cM{LOn3KLZlyvU9{kkx1_ ztG?Jz%kLv^cPQ$*(^LbyY7{rdCI2>+CVy|1r?gtCZ4%h7#iJ_~n-_dhThl$9h zNxL1ewyHHzuxzY&SZOVEa=QK^WUrpeYU{A5i>gq0p;N^UJ{gL7HX%^fRc0|lqv_xw zdptHqprgxxR3h$gaxd}?3QiML(TZiy`fBL1qGGz^zYZxFUJV|ay^c88m&mR1$iHjJ z2Co$5UgnWVcDxp?93s@cwZJArr94&2Em)K8JJUbdWP+)eB-qJuO14rt3K4h4<`A(i z9-Q{Pwel+Yl1mJDd1)6iZtmOJE#NJ+n9sR7Z6>(}fK7tm4AD^D z_3HaRjoqxDQ3r77`E{%RDp5FM3T1)Efy0IwBInvKovE+7-3trJTYtOumJQ6U1KEAv zs|ogV{yIutvcDDL(e2SCoWT>gbn=)e+D+p-FPuw3G@S~2?=PujSFlC;wi&FIE>sI0 z8sm0WmVmI@<$iHg!4EL~gZF31px%LD!mY+H6p{*qkF`nQszmm?g>@FSY7mj|ONYsR zRUC!f_OjAKZF*mXoDi-$aKXU7;M>|b^-D&AiKS}D1iR??J)n@@llQoDgVu|BgY$cT zdwvv0y0XwfhB8(!!r9hHt%*jB2=Jd^ z2lzH`0CT(5qGMRAI{)R%%SNI;@^u=fV(I?-s!vYsEmbSCwCi1w-xH3{4rEE!#(YO^!1M2(O?_C0Je$dPV@&NBI#UkEbVZ8dd2 zVIG+cLeEM$!xgs(`|fXcl3&FvY@^QL*{b$9bX{o@>JBwpk-T>!xh3j(c&ABKsiY8} zfAr_c!faruxXP9JM;B;9hDj;olE}bHyj4_R^GIe$ZRDo*L>#-_u#EeYPhpdyiIB{R z^5sj_D5(Jgm#Ge-kVXnJV%_-cTB0~^T6!0g2Hh$7`uE0xW)daLXOYWQYsp!Ioiu{^ z4KTfSK3kj;JtPABvN)a_rfvsko#Vtc`=@v0cJfcaUy3TQ&f_<$grFip;1vFDT&PoSH=tE zN!w`Uu%vgRM%9osRR>|#{R8{YxFYL^lm*$rm;LV=a_ZC=BSI&wzt*6yG>=%^ zQVBYiaOiEMHFuTW1iVL$k&T<5HWnG2f=kgvV0Et7nrf&)P<2`e6ODwA3%uiKDa*HA zbqWEp`X;;D@|wU%X^wVDO-SKhU2>~b6>(Q22&J`mf2N$OAo0wUm*`F$3lo@WGK2&gnsBymkA`MN&I;knp zPtX2Z{d^7}{n>m)k`OSf50@?Sb;%Z6N`R7E8> z&vZK_2`C=DuQ5x|3I@SQ{S7Y3ZJl8auw1p|c${nVuRF~v>SyJhWkEUWj!-R<8h$^} zX!Q6n=yy_+Qyq@x>8*+`p7$W=M|@I=#lv2q(^!E%7t>hECAyWmSOe*ZMy8C#n=nF~ z!iXpYU^r|QL8>_t{FQU^jWpybuJY5FI38Sars_LByu;2XG(TTh#PHDJ4sO3Iw#vMY zGV7%4h=u@pZJbv7xesT#_eLy7Wbwa_7u(;=dw(1}-Qz`RbaTldDB#fPmW0;3tJm`5-PAgu&2Q|KTTab_lCSj|D zgHA$8(XN+FjqoMk#uCgmT(UKIS0KW#w|jjG2JiTWN_%2FM`XsI3DIcT!W9KfkT06>{TjPeqDyfTt4DT(ZL2ui0=8_((ci+u znNW!0lB?vj1mW`)7U`;#!v6LHEV_jVw0{3tzoUK3f;k?EDYPPw*t=jIiH(5h%Xf^{ zO)-oZpCbdD&VHceHjj0so*9);$}v^*nSl9`a}5_j&6oQ-Mq{FC?ghd4%p;tlvaL0m ze!f(W1q3MQP7nq763x8J(T;ujuKa zemw(=>EOCrAM`Rk6c@vC4{*OZDoPIVK300UiM&YbrM=ipN|+6^{5HmNcSSE~)rj4T z`_80=U^9VRx>NV9>FP?+Xffs@3whWnA`fV5miSo;y}9xuXSCwhmj8lpBQhMqYsGvj z-pDB(Pl!xlq>=~gXW`|FK|-g+W9TMTvs&)K(hwjl`4pYJ)&8 zLCPF~tiHO1qd_3*qXlI{^~5Ts&$e%K6Hd=O``n2=BJ~A}QXgR+)9LBBRXC0j)}pyK z<2pbHpgX>|ELq{p>O7Awdd1k#V$wK?`tvxDuzXSLh7ww__soG8fjgk|`kwA>CYQ^A zH!^@cMmtkG#o(^3y?Gz(Ch9zJ?3MIK6;gSpt6wCALw~F88!3L1I=qkSrAHAi?>9-d zNwU@r*TDB-HrI~W?IU0N*?tv3Ie4R6>(Nvlg{k$kznKwFLg_e=%>}fPHKV}6pFYtE z^8uX1=wPQ;yHGWBDGfPvf>bqX%_Y!F?C51v!`IEOSi^Hy%lug0y1bFo`wC~MH3GZ| z_gq*H*#c<2k+c|4;dTGz=2Oc{&Fg1k%FO;%FMOyTG7^fZE~ zOd&oEW7&atgeZv4fZ(>`X5wGeOc*kLc@M$`JwM6E+*j{#Y{=8;JQXNq!b2Md-5l?j zgk4DVD*1PbO9e1aBB%w$9wk73jzJ9%6;)CGIfo7_i}|rS zLuTSM7^^X(E+B_S?+fvcEb+AvT)~(}*YH*#dV1OQaWGn}&>GA>YM>wTmQIw8r2oWTrjjv{iW zJ|EAV1aGsq?>y_@#_BTY$7eC<4q;>IHvFep%k4OPON^i(Y;jDU)fujCaolsmU#tuax{9Q; zpPh>}{&x4pPFwp?5ip)0N$UKbZS}oQTN_E%uaD}4m;4hYys~KA<(&Yhosw~;_>6X$ zhOK6@K2_&G4cv2k!iR)P#>FqmF|Q~Oh@0QCK;M&uud`5Uo?4JDK>@I|;3GndB_zZ*fik$%pRNLsO zG_OEivIZHMnB*d?EXJ;=>^~dIb%`xV0#A|ZyAGcl4ICPcW z07p8B4`exW({s6F4#eQA2o(;Ep60!id=w!H*0V6|KEZd{B-aSNld0`(C(~-$RDWGF z#(A;D)MYV}%UI&O1vxA=I2A>sO2w~f+`5?4anC=va*|Si3H7_x()24>;Be2SQc`b^d%2Jc4ge;?CVO(v{_`t}jL$09mLIt+{kFW5{=Hs@Fx(<{dzEDWmPSr$kmLI64KH&!aJoh3 zkBjG*-JP`C7u7vA7)0;Pq0q`-mA>4ICAEvZZ+WiRy0gj=pUUd;?){qdM}2EVS6rR& zoWhjsJqFX`%&O&!NZo&=N}e>3O38~>$xB#Yap`R=>rh`%H$g3SYUp$G;IbAkw9p}Gxh!w9`Z};$phJW|Tuu>w!|LF3YGa~oi=-qmCc3-OX$(>K* zzZ942$F@&mD6UY}=}?-#%{a^@ELh#3e!1t0*#rX_l>w`_xp&rXQ^|Fjyd|`>B*5ZZ z*QWZ%G>&S(YzrZIOG4_Z8yagQxH#par8YaS6#v{Baz*M_K^;wKZ(Cnn|L%^%I~kKc zk~0^qxs1E{>%^4T`@i1pX1v&zV_LGr)Vo(9sYl}ADjx z6ug=oj~T?q`EOXVMDMps(ovyV_H&>5v8~i<`k$s`S*5=VfBe=>%w|K}=?@Z$w^EV{ zvcFEfa{Bc&*2O>>p;Ld;l6Dx=o>(~+`ZmoQ$kkn6wL6{M>SMwQq2u>yzc~5Q=a=S2 zyp#5vFX6swhormv-bT&7b%0|1+AY0tBr1DWa>2+{Iq%U zp)r0T*IR;!cht3Uk4k(vXSYZ!?)uNC)2wc=mwNS-PmefQtyJrr zW3Yef5#c-27M8d_#67=xxqHW@4~sP}f2YfOY`be2@+x~rW%IQu666^oyN0B{E}vBF z|NY1lxnGL-wbKn#3nneCPf)9#TcmRL-JOzzqqRAYnF(bkx`~wra`YO1uc!AF%O0$w z+r=5n|2SbJ5*c*Od0VtyPu_v-w5i7eRwq%l_ImnXQLJ6iw$qt&@sLZ#W^o;hvj=PL zm*pfHe5={MuqW>ikJ_GWGQH zBhPDI&e&Kgqg4Dg-QyrJD2(fwlz|pPmCfl^_lX3huDRE}V2^_ z)3S-)vDB@9$u)JA$sZn>HP&R*Z7(w0=DzOHswJ|;#Ksu?d5e0?x7s~-_?_*l(=|c< z?1RsSzoztYekA2yJ*ig{{I`4m#jvvWX`&9BKRw$hX`R?Vd}Vcyu$iOtiwzM@Nw@rF ztIhtt=9BGY;rN$r-ok|@LbodJA0wEC9C;sEIa_k(+PHYvqn}*yMFB(m-%H(hsoeJD z*E+F#sRn1S_9Z=gT}Y!d0)A;RqU?Onx|m1H3=z16;d_>22hyLV$ehc}jjlL!BKOaa zooA~bmH+v50#`S5aDw8)dVSr6Pvs8SZ+<;3>h<11*~H~Np?L?7FM9a9R;0Ii%6r{7 z^H|Q&l8Ua>n_m-7#8}{n`jcyL4pptoJAAZSYyTMkdEV@@IC8Ik)PjJD?)rXVH z8Q*H7E)TDeJoIAzv`e*CGOfSej9BTV=~*&IL!Rqv>sd<nTFfZhC+|wk>#0%&ET3HFJ^zJ1aneSaaBg2?+n45sxm#^_OQ>fhoxj@)1|L*!!gZ+Un{eB>SvrW$bU!Mm)+nLGBKy- zNq( zTbjO~D&E766|*!BXrRVz@{iGvcYN!v<3f2>#gW%$MqA#YbzNE6Hg$Ri`$N{sIxP|M2haGmlHspn9Zosa zg;QQy&-}8TvWp&5Te-I^uy$4dd83QwjwYTxo1C;n?lQe1H-}c=*|Y6a6uI?F(>ow4EEc5dmN5hubpvh{?pAp>U7(#-Bce1i!$A>6BYXXvmfeCCCP0* zQem1)Ul+XQTd~v3pJHM&`_vo{+{Kr>@8%TGmRTuJoV2YixKQt6d9s#BYS?v>`Ofq8 zst5G-o4f|pJQ&*VY|87G6ir`vJ1jed`TpA8$euG1TUshr=7vOfoI!ACDWsNYw{sIxi}Zm#q(>s@y0=5v*EoGR0^(YIBj<;l73 zO)4p^sgBEwZe~A|4$e=_fBgP|`Hyu$cDfP!-&G$8ir$>zxW3+N^8ikmd_I>xK|=lW z?-TdefB)e-=gNf@lVb=SgGQHr7`V-4{;-%e^No6g`7}{=zn49e#HZyZhdE7e(d*4P zMcQ|=F6Q_bog40FJmnkiY~lJ_uUUV?H|X*SGWTkFZSbl{YxUKxnv#*BFH|;U&YN*o z=fD&i$vGwUx24MZytDEP*fQ**OFbS{QNn$BGkpANFVC<_?vF4Cma|A+Rdl}W;=Q+l z*LN3W2n~ApN|~;+&`P}V<^AzGmIysb#@{S`pY}S!z%{4k)unCso4)uA-(KsxvUm0u zjX!((XnnVR4JU-0EW0paccHIp!U2B?%gX$1$3LHS%eYv@!4p30H?pw(BDOQ6h*4HL z%=r8!%wzBJRev&$8oKMg>9qDaS9@!v<`SP(DGCvO)X@Gk&-HOqTboumcG8brw*K?8 zYC^MxeuM6nwi#YJC6n_4V`Gll^jL|W=$V$Nskn4XXQ^{^NbaF`>w{QnUoTXtS*m1^ zQlbv~p3s@1`|2x8?@ETm+#~(-Z&P+SuRp8Ay*aP;kn_^2s78vs;f37KW~Kcy+oz~R zv~P)9d?bCnWZbSp?kRsuR!c~&ZoPEv$kE!`f<1}L4b_w)zrNa@c6+U#t^dia`$jpI z=4P7P96oKe?>$ZZGPqH0itL$CozOyjvh@6^vrS5NZ|8Ew2OKu-GWk6Zmw0QI;)0`_ zI&LxEi0BLx?XF)`2>z9!adZ!3p>yAa)uD}D#7(k)oZbWlw$ZcYr;%`TziwE%s`qqs zO^g0d(oJIrrJ0`X+uu68JH2^Ysc{8dfjn6}zd%Uh!H48iQ6d%-GneazM%Izns2M9= ze7N>}>34ULNjC`fXQINGhp%-UBC9?A`K>v$+OMIIVJ4OxWVS#)GvixK*K_fJTZOL{ zEfkkEZ5v!yI!z*M#cAe(kp8c$Ss_7&t&@|c9Nbrb>&5f?16taTG|P2g5R~N%f7a{9 zrmEi4>9`X&`P#Jgoik4!b8~qt*`IZ~>OlWnTbg0;4Hesir#))ag!Fuzd&Rajyw|-O zr#H)(JE1K?dQY;X(bxQG``wl$dCxeT_+hJoD$X#{bmsB^*%MnmR_13%)ogr=yLqkc z_lAl-*^O^KI{MwaoG)G28GQJ~n-(iS)g+l~(J~Vk3zu9I)PrdToS8SaQw8pRhb zi<91VJ<`IYAnv8=z}$^g6_?Er zIJ`~WETw#_=Gu*zHU^W!dJ~Cw_WE(H}YXqcuy+!itwpEWP{5#N_ac z;0vzI6~hbE&R9K~s@~~PsXI?vN%WiPZztSCYP9WO%b8fi)JrbYtXJrT9OPc4+Y-LE@vcnseo~~ST&#dW5-Myw+BH~lx2<(=JX6rvsJ5ZH&KaO9Lb&s5+5tT-$j$Ym?fNfxUQ16~^6b z=k}(q?)hAjw?W>jrK$P-_k`S5rC31mnfyoX3fODHp z^)7X&Ds^1n9T+2VaHBCUz1?%$4Bf36-TLc~o@y9mPTUss{o2bnA`OPB_Y1Qcn_o^! z2ruS(ly8b3Xs33~d#zb1B)iR|KInNb_wtARJ)ozH#<*U+&=gJB)CUDBr6fH}3pCyusw!gVob+Cui@&=V{!Ymho8ku5*#f#0EW`ZF$>D zGdo)FjnxakC>g$g7o$x$Aggt*H|UJne&PAebF$vcZ}fiewtdqP)3zM;GdX$A-cwnG zrck?g^IwPI3Nu>7E>_DF1$MCp;r+sl-)n+tK{QGG>dAvD%)9Ek233ukQ6IOvWR#k2 zOS&mSP+RWs?A@*@F<-aL4F0ubn3nTt>26j})R7gNz5iVJb>fGz{h4T&#RdseaI=qE z`tO(4?X8nmY_5)`p0QBh{ANy5opz{YIfW3G(0KE%;;n=|&+Xy}U+hSR4pt9U*L`aw zXb;=TR`lh&es$gdR3d#|yVv0c#rfA>Oe9fv2G&-m?6~IRwR|%D!3Vi41s89zMwJ;! zv6y$^H{NSP5Z4VyVW}B+G~Ct-Ra-IS80yecmG>vSF*@w!&4^(=l8xO zthY*UoAmx}ZE|J*M3b09A77;<*PgOJ^JkfLi+n<=t?cq+sh7-lX8K)iHXFDz!-aHp ze!!{RfTqIR#<@iK8`ILwC!G;`xMQMn%7b!}zx%0Ul}aJW!chvny~ z>F@Rwyyf<}FkjESBXaNvL*v$#SXs#jJwK0%du@ze{IzM}1b;R92_e5<*#+qqZE1np zsWWVRA_oud54+O4Z~6W1qzHvWHhXAW4wZGtX~i$>t(%j;C6!iRG_11h#P?IvCM|hjQS|AY{f;zdT}W@JuTtgoa}_C<(l;;O zFUc(0A$CKy`(EG9u8#I^OJ+7n72P4x|E&B}acbo>(TLQE6Nl7`7#Hk1JBM;lDJtZ+ zcZ5-d-TKvEi3u%Scl{aBW`D;Ijr>fjx+Im5k`+G;*xjsD%QhR0eI=I~O&up6W|TPh z-Fj&?MbzNt)ZR)hRj-K6>QS$*6K3`NS3DC5?v*No$$+HVJ8jAx(r&|W+&5$L(*;sknbkhP_%Y5HU zP3!B`w|R#PJG!p>QrMd8?x0_KwrsWADP;@8vp;g5&6#X_byMiX)*lUD4nKL7nmHtU z^FuzvpgrrhL1@U2 zlOE9N*tD(Y5mAvCgqK6RoF(MnbE0t z$$JLsDH~P2VU3Frp8ohfL=RTI8?>FtYv`G*d>?r4KNf@dM{O&w$*AB>C zLJA*W7^WZF9Xai)TJWEiFL?a1w~cE&!!8YM+$foS?W(mYsL|Uip@mji@w=+KfBWBC zR54M3b!+0+J#&Xf5XxVyQ?XxYYtS0Z1jL^@CO)==L5CG^Fdc?-4h?H4~k{VekR zgZZDchI?>VX6^GM70VJ=J$6y}pnV~-Yw3YsvgvaTtRDp(9JD^l5HIbh2cHywWh7W6Y ziuo>yZaOPw=cnfR^MqD-_@tAhHI%LePoK3d^U7GhNL(!Gh1zYu@D)=|G^cz$;WV$D zvEB0F?qB|YwWht&`*>@8*S`CH;*qT2y!f|OVtp?P>K`-=9^Z6}X%+D65937R{Qj7$ z<}Wub&3Q_B9ogQMwKFk~+>m{0Fhh>Cy6oxB*$ETc?*8a$T20vz6tib;z1MKZx?!I{ zufqA~#1md-JyQ-7xwR-?oIA_i(ZQurFwq*F5gw? zuyC@@bW_(E->o)p3ZnXF1s#zZP#wN$a&8sQRMDd1*-Te+;WaTbO1D*({ahwL_4d4e zgZleZpRInY(>8xy z@szVE`xDRgmlZqBXN8{WD^K1OtcmYB`dxhTk5||4eh9GeT+vDm37)KHe5>F1rOdtD z4H2K5Li`O-!EgAe`(0|$;<;4uNEl=q-jd{&(yMZ+1gq^yDQHlIa9sH z@ptC)j@(@J!k5Qq?Q7roInw*<@^ps=Zg+0;Vi9_3)xQ2L&A1~4DH?z0=hiOO2&t4- znR-WlOZ&v7@9VCvRWuq*hwaVCS!>JuCaMuK3$oTFs2w@kfBRld`Hu9XGqm!uv^`GV zR_o%HE?3Zrf8#xCheM+l?M|*=ds}a^pW2g?iN)`)&@7Hx%aLP^S2V8I#YGP@Q+hQ{ zeNpuEXl}W&=Ysx{xu)qf&&HOjl`$W;r=31|hatPHRN3kEw9Sji$LY`CrkDH-t`_NE zxLx%7ZJU~##09_Z=;>Rt1Mzs3Yg+d;Rz}WHStMbwXkJ@tJbv>xRmpW#n%6RAe*WIQ zgvq=tpF7W=Sk&VDrMqP6SNx_8W*NWZ+!gI=^;*Sz3c59Z`POee;u?)6^Hg(&qSvNxv)(Dy@~(j!D`5otbVDy)8?kM8EvNg2=V3CH)I*7+$ltbFTQ&In%9=0@ZIiVsca~M$i9g=ODf&#B-_4 z<5XAYyt_-wQ%|RC3fR}C?P%D|cvRLUx0vy#cU{Z19h6|xpe;(^{$QqPxjNRy{FIm1zFl zo^NTL^Wt})>ypGvRkaxCGIg;>;ZCHo3|A zcBA-?x8d-oeOw3Ib19yN#sh2LW&Tolt#s^$X!Qr*MT?`z!cWyAVs|H}+sK-2?~1?2 zP3RXpu&Ltm=Fm#1#q>W;wOh+1j(xPlEW}M%b-l}P z&+u7~iD7e&I++FNwcJ#_a>naKtGsC9flcxA6yz!<$sS4X)Vpod3Zj)yy{5+C8SR_@<&VF2kChB!Nc%s)5VN8-5N#%O-mcXx=s5z_OGQ6 z-+3_4B57j8o`{z%2~Bm3S{pLR{qxT=;V8Z^U#GMDnW;(b??kkb;+ zNfn}V#IH6CH`qHD4zJZay`jhd-m>!PH0O*(_Bl# zgdZn0z7a$}_Pw%<|1DJiUH{?h!!P0{mHQ^7Na?pEB-}s3a(N}aVV-jS*DcH~cH5Jm z9(&z!s(+xZSE16<`o6^9ldQs+oxfj4PjwZNd=l#5HQ>#WaetR1^0eq8hFR#%#JsY=O-fW$l`KvjhiBJ5b4QH|26?9!R)8qzD`^8eWt$tCe z+C-k^u7P(cAw9k-dUvYW6{C;6r_aC0(EI7M9N+wT^6a;>%HcZ?W7j8_ZeDdx`1s`h z^o&Dh2S2ZNEtCwssA@j=_F2q!TvmS9T6*xw12V2xEh0ZDxcjZMJ^$A9*F1@3$%djQ z!lQFE)$*R_aehxeC$&AIaf@Bdr_368>axK`U#EAQlBU;)=K4t-ti7KWzs|yJe&#OC z^XqpWwxj*biApqoW>e-Yq4>)9s#5}aarvJ1`BSI%&ol_t6J077F;uN`!L;a$$?h_x zjHdPzszXA}$IiKSDHPSjrVt(;ofB^Txa8bRGND}2pe*G=P`bB)XM9X_r zQg-dRSE(=TKzh0R<{?RXLhQj6o(9vr|9bV1_aFAYNL`0Jx~ z_425J$HV=S84C9=J}A2O-nD5;f8FL~qFHnQimtbP?r+;tP`qrX$~?WHFh2#6?JlpW z@3odsvc!=r0;e_}TkDk6FrVz4A!{LR}SeVLvO+~1YthxS#X+;H6^C(ryj;y6v((z5H~vo~jM@BG#@tflOJ-bUzf1(`Lq?HHJ|kQwjP>xXR&o_;sLkoX|H$ZPY7C0 zlkrh{sCn?&cij|L)G&z?%h1a5?i8Cgv5|Q5#%IR|?{@qDN!(zqAd7p;4QQ~qwbDN- z-TO$vXO-BG_o4`a7N<^KEF5@T73k_dKQ?tJ zQN6oCscK$;WM${#S#3?#O&>a@PqC3u*>ZfH{Hzr_232C+heY1E3}QUs=IqJe zvMDI_^hD;3au?6{Gqf8O#Z0!|X2-M+1-_{1632-PaxU50C#=x=bU_c zKPt;3D)EM0fx(calHoyH`5J@S^BGk)ES3xw&nK=@KUy|zdtY3z(5fAMM^>HrKI5z& zewN)I^WUl2!>L}kOqa|jJ3cO6deQOyo+HGsi$Zko##pJUu;j{T6D4;hsqCZ#brx)T z!ntf8CGEc<&uY=h&gH7|4DHac!Q_qmjs#p*MQo?+stvon&8b=a}xyo%GXPnttTi zv*)x(n~L^rJ?+FK_6Ok;#W%!W#3m>XPMBhS8gEx@=CHo8K8xc}a7L@{PDH=RqTG`1 zxzFNdLqC1W_^tE9^!T4`m-1Mvn;eV-KFYp#7V;|p#-@FLvVX0vPsweH!ij+saDwNl zV*CF5^b?)Ew$f_ zEGf4=^QG+sqn6US3bVfd`SoDME}=$TK}+|8m1<8J(=v?$!l?J3e+&@%+P?brw`5QK z->UVMxGOohXD!K|{xaL=bf1=GeQbMEezQ61d#l;E2IA}<%Y^3iEhk;Ie7DomFGfCWp9ZFBQzSgV{k z^+>i`PDRD0^l85`jBd-ksa~YBQ)BlH5w>%>q~rWjABUs?lB z>{5PSY<#HW+Mx{>1J3l-aqiY$7L~oeNL!RXcfa(ach|Mroz>6JT0IB9ZiDIHKx%)^HRVdcEt>@28PeZ+J-=``azuYO-SAJ}w+VJyDb8oVr@7QbFl6p6U-T8~{ zQ#E@>zfiLMqVFdq`xf83eCWY<LvA7hA$#F)-CW+4ok_>%hqX} zWwGbo%dpf{iKfQ{8z z_s%JoXqL2JgtONyTt13?%)GR{B|++K+v&QupYUs6-&@zL_Rcck*TJEsp6yCK71ENI zHhJIs_~F?5LKBnEt&6&w(xsLA)`>fNyB50c*!T%=g&Qssy`q1xKzU(`XM@WroiukR zcGi%n=kd3pPrBEqD~o?y+8H3tHj`8dx^zHdg>}x&Z;axOt2#4UJ$#Ox|9dI#c6oSS zfl4sfy=mR-M|tyI+!oLBix#b8mzTS}mK1M0zdzyn2JMFrB^DP*KMYS=LGl zhvz!4wMTz0l2~7nkw9xzGyG0n6&@qndii-rU@U%v*_Q`jzulWD66v$6()Y^O)tB?y z`wiwdJ6<`nWC4k#DpFwS8+YTQan7zU3ZfTs7WMz0lY3`!OzR8>;r6#bi>F!yOvrmp zPxQQAFIOq%crtca)&3YG_=cNY=H$?WmfKXM96A<%q6A2u+M5-9$NtKbm6J|AoY5cB z?6=P}KYx0l#r!D~)wcdJ8J@ODXpike(H+AV@9rWLc-C*5ws}v-6p6P7>rRJ1$aysQ z*U|RX-*Yx%6ZYjDT~)B<$l^WXGTSs+uRLBv_DI>L(5;^kbyrs%meUuzV-l6T=hfFs zbb{v#(&zkT5yaTomvcQ;gA0dhhx{J}KR$CK^Y6DW4HeT;e!Bh+yK2}M7*0Qu2s7`tOG}ykXTF5i^(npDu)GOjS(nFQUl;5T8 zTKt3Uv?g8Cyt=@klJ7mkE=Hr=%PCoiu<#^&uIJY?SU}z2zo?MAPnQ*QY8J2!}nS&92hn)kWe$T5<;_tDS5;lyp~mIosrnC#x{Z2Obpk8g4L zYcMcfp!oY-gvsp8y_9<=LtRud!zC7H{+e}a7`me8Uros}x~;WA>BptsS<6?cQTrSSKWg7TpW{%|We7nd=*KVYXIY&1f_uP1;G3vl_i`26HJ=!zU55G?Na8USM zLSFmB)^Is(&+S${f4?-&QEigZ*d5$jGpxQl(A;CchpYV7FYVN<%l8eujHP5|Jy_Ng zQx|t9Pv+I$?Ba65`#YgYbD#U>hSH*@s7#pdaE3i}%;(GX1zz9egCDfmJs19V-n#3l ze21s-W8Dv}3h_n@7A$+d@^y3O_tR6;Hf^9@JQ2Al{QaNK^eYxaDNEe@Yvvl?{pw9^ z${4WR>Do*&Q*IFE6?mK90aV=$FM#=Ky>grRacluwSxa@aVbF+h}w9{ez76<#c zO)nc8)ps|DBv-TM-0QQQKD(=|%t3U9>7Hce+0Bt(8yciDvptngh&Q?&n=xPU*YOO4 zqe&O*ErSBmfNqz27BY(2f&noBNsnSJJS$6pn(7xvye{8^@b zK6z#**{MX|ANE@ZlPIjS?e(1t>l$XnE_@|n>~q@r>4CwxBh}WT+D{~8SEbY_RzFzj z;IPHQ$l(4?`}SQgy{+0o@nHwv ziEiyawbtgU*gd5=IeRysbo-`1q;00##GaA<)O}0U!;e;p=@NHOKJ~RIw+?V=x|iiF z_s%HieW$l@R@0^>FDrtCU!~a{b(hFLbA3aT%T2qRFRK$v20HIm7tg&2@2j)^ekKj- zT<6YQ8s^-@3f-xdP5(Xac{-am(Ika+N{;@F61>4VMO}?r;W6kLo zTQmHuKTbN=uzcb+{g}OKkGkSq{|0%zFg=lMF@0wHvCzx}m#y0yZNtm+V@{E_-|JgD z<>-aq+mBn`ZdK%DZ#SGDEGBiwr}EZ&ubNG^1NUyfDcv?qTi@>8akoDuL)pk+)wyZy zd*lW-+v5*d?+%Tdm49&hnS84$+nEg=ec@BJ`imlJleYv^OP$*@f#FL!nl@&S*uIhJH!QspjG`hLQRD zAOqX^!xxEqK`Q&-Hj^i-nk8fjQ78D#I&r`yUQaay?`1?-yRD*g{cbCNp?VjU1v)w% zQ{mm~HQAn#z2~>?ut_tSW`5+YKHFD*@Y^;cPO|XHI@{oqN7pIKPuM%FL@w3zo|bjz zj9lvko8VpYyB;MxIkgP0=Q+LbkhRgI-Zf`C^Yh*s>F3;j;8x{)ko|34*Wt*SvU`;E z+Ot3DC+EcPDn2UPW_td?Ri)iY)}NDBqzTK@Un+;Dx94u$)-u=b%u`L;TH8~t#!C~< zcEkkr5?ivLiI`mtC$EiK{YdOl;d1?b@82x-F8wi_^`fOIu(UPgcH62QhkGrOFI5@Z~kBHeMhHjUS?hSzVc1ur@s?kE6h*C-nd2?ckz+AzZ=|5hTJYTQ`yX$ z>BajK0m21j8(rWkBYPKHDKeb^UEmfq9eWQ?FD*NUhZJG_g=-}GxC__t{HB@=PY!}s zN?FU?%3`bW$c1aBuFjiX>Hn)c*GRm+>grNJG;%W*2?3z*T%*#)-?>I11Ety=PvkB$ zxEBpSa#tGv&b9wx=>NQSjRx1b{kwLJ3^zfIzjlp61N=0+6dniHbY_Y$xf=goH4SA=Wi4fG<&DZZ%DT#W z%KFL%<1SM}U!^wgmbCwmcca0LY;b>^t(})L)7#03<0WuC8gd(#;Pq&TBJr+ABa2S2>ecs!4Ouj=TdrIvfB1|>~#_)bo`MNZ0?HL5Uz~9#R7D)=SV( zo)?GTyg{UhB>s$v6drNoXG+3j!^!_!f%4f(!t-ZFBJpKN;tv9f#wUi1#|%oQ|8Hap zG2y?ph|HhS_!;o^?0;Yz5wP)fkf*$$2qWwvj3@}7@upIIUVx7B$Pt5Mm-iHfm!C2qc=@fzsx*=p7+`j9%VT6keXfBlO}&#PUy{1n`cCiI126 zWE@`PsUTjSwZQBF?sCngx73Xem*69%~d6l8Ax#meY1+DVljPJiO$kM(kWp-;3j{gqMeeithmU z00IKwdj>v$2mn0a|Hv^Q_rj3@K;}EF5r8#|$YtQT3>t+(qjQKHDho%XGw>7^ob+Z0M-;Pk%Y$+a9k3BP3E%cTq1$a<>K*pI+;$Ql7I>lUx`P0 z&=C}T-^@dS#~}c|zvKg8Y9kJU|2Hx-^2p4PiQoYzohK4LN<0bv9*=-zZHp(9Sxg26 zPrwu5&R+tBjU%vdI0B6X#Be!mWF8~#lRpM@A#iD2Dvm|OG3gu*j>f>_h+HO{LT8Y` zeX~d`dGKH3xQFL;;WD8$nM^`D5J^M^hrp$?IV2{B&1G|;3!XlHs?deVCb4KtHi^Mt zGbm&_he;%H$!r3b%Lew-afn#y;~0#LLS^DeFmEE6$>9>{Y&woiqElD|B9p_bLDO&=kEL!%QZ3>t$#VRE@-5(`J>(in6a zok=G$p$p$Pj*Y@#<4H^=lZ&Ghm~Qi^|~0Fntz*LT3Z(fN4C1L1{Ah00NUn!7(T# zCIzS`GnhmMlSRP8P1!U$g^Lh2o?}3%fXwi8E@>CNSGJmev2jyKt{=g2j` zicYR9M?lG6ACC||*2L49;p7C5Y2%4ROqM>*o#829B3JcF&~OCsltdDp1+3sw zNn8Sr!s4(AI3kPJWxU=)7YYZgo=WH7sRU4W8jVQfkhx^gO$Lib$J2PzAFmG3h0X#~ z!f`oV9GE=_44ebtrx8gUDuctMf(8Lw1PNm?$aofqNdW&tBa^{t1Bpzaic4b?nREhJ z7g4}dz$oCdI4mN8#vsusG?*8ai-XX@qOtKT3X97E4^9+t`p|_7{Gx*AVKea%Tp_x0 z*i0G@cmR~aDhWm*;ZW1(GVx&N6e^xW!jUK-N(Pk)E)rZGnN0%kgv^DPUW`Z|ku7Pw z(t+eilyL?`fH+GUui6B_K^l*P0FHsoPp_op>|NL#KY1z2h`Km4>|LxG-d=XD9-i`2 zqg>=c-MkdxfvXP#c``cl(I;%EFadOgj!~#RcnUBQ+=!Npf<0Mw9JV*)_O{5w5lQhL zdVBJKw2_3z4OYHL21FXc%l{iDNEliB$nhc2gfMD}dbzbsI9`B(M3@BlsBz=~HTcmO&Fcfi;769L{7C^Vgprjy9{{8fM)jH3 z1t=lF)$wC<1VRYZe+uBiu=QZL*(p(!@Ja+kHy{v?Hby-|^o074$Eb%$&ygYt5Q2J$ zXb-Pw1@Rg45cojgReJv8A<}V-)q+@&e*AAaz#;|4A(gd}NelJ^9uh`#aWpXqJ1HaH z0R0T%?5JZvKjSg^pUMi3hwyt$W@FEYe0~#0Dog^5L7pM%I-0(Z9}juPQ{4ZM6N!%# zk}&Mtk!OIDH0r6w<3yeTPSTiZj?sxc1AdbDWf3VkPY%n=-qmFdqAa6|H3mbJguj{` z-xAS|(Q(JxBGMf-{V^yqx6vir7!)zgQB4?wA`XWC%_-wYL!8X0qK>si9L=cH7=t2) zI_k8>pdd5SNR4W2zCbRXGU9swHRXkekuuh}rZ8cMHhdwBwME!Z!eBrcKf1mgYm2a) zJmQ@W19KpUY58`<4j(^G%JaN4C3O)s@h@+t#JuXi-poBGI ze$a7zUkGa8#{LB=fu|rpgd3#sq8;l?9SO1jEKi^>NRrogyiShw1#$A8j;1YwG}DxL z^CgW2ee_e_j7a|i8){sh%9Hpj4A?3*w0E}mLKQ-JYCWDBq>td%1fqhYrBwbN1i!qB z+FU@q&S*2(42OXzd`lm5m5^efVj|60yKDwFgbZ;b7bQIew%qS z9Uzr~Pg=+qf4O?d88XZ{Tcv#Mz3imy;7Edp2Zt-=2H)icw8|@Q@o;5(!-le)8?4=- zog(DRc!s?4CXT1X&zT7TRqw z-?&vt2R5ad3>O#pDknK}J9|$l_-_Qaf|MnEM;aiK0*!#gi%#H=rU=F)C1(ZeZY?RQ z5*aadM>ht1@f?RC<@2ux0w2c)KbXc$i0koDep7~td8@W;d8 zGZAsuC>XE!F90JzbqY%#RI;&sk$gv>FR&Ed7YEBkBy}F&j)0@mk&JOX3_g?p14cn& zg+MzfH6crx@i4$gLu!xXVepxPAPi5V^3s6ueF-?ghvEyU zI38J4k8cM{5FB#!LjVR9Xv9;FhrzgXqyjk}2BPG-a})3*w_u zu=9Y5DTY@xI`TWXTWly80ZHjlFbWch$HQR0P+>>Ipz4n10f~m3`V#01Jb-E@ z3Wg^k9$c^;B*|D`LZ@MD6%T7(3_eKGP_)37Ar5VW03#sFbHTZRTA^$U59ce;HVq^r z$BzX1f_H|^0W1uoyLc$xq4|P`3JC@VTd!yt;bFfGGX@d1_|W5m&qnJ3^hLH=$IlmN z=A9xz!!UXZ`+AtZU4MW=k4wlrIxC+h=D+ zGobpCFg_NJ2Vi0k>?UCP(!h;Avg|# z!Ur(qP@=#X;IA+;r$bJNmIs6*jIGjvK8$=}PZd310)@9HhHS?R!XOt#&kc5qF)0@dXV3nAdf~2Qtp95U^k8$Z3e+nl)Ffk8w64{;=oEzmo z^nlDe!YJ5|jLB7CJq@cX6h0CWyetL=X#)yIq+{0$aOeYz4_2LMKMrTEF>5sv4v)1} z5C=wg!QL=DfLMW=2P|DMb`Ap&(DLnN$9l{iP9&juUElb#|#N_<2Ou@ueFfB}701nh) z=>x}x9v7Bi7(WD?te9L1^bd;N7XyPN z2^FJ2H+bjO1ayc3$HdV*r9hzp1A~MEZI@6c#N^`?_y=t>6bca|OBfg94NV{N6Q>s1SVc0>VnpLsDNVVqeAk7))!dfVB$VlJ|>5QQV>RWsj#3y^AAaB&@!Sz z&WiRMa0(pb@1Y%*W;lX}mIoD5E|kona19!RvOy}m0)TA?r;yR@z`tPl0{#lkQ&1~R z-h{Xz%owm)kD(b<63Z8CZIcQrj+QwU-bKXpg~Nat-opu73@tP$R-xxhreW+Huwm*n zRCu)mGY`lKG2_CX2!>`@YG7!Fv<}l3wvRBn0m~kYjG$zMp#>BlJ1z~&KN|04P62;F zh5Z@K7@$NLnFC`m^ig>SMFsIeE{g37g#i@rk&+CW2XIOpLo%Q^8|^>V@vu9Hi3{^9(7FL-U`(w5Sb)(}$i}hbLJfr?5=HjEfWy zP__Uk5-|BQ>=9t+3uRGEUwF9?takz64ezm^BG-8I#x1 zA!Wtj1OI}>2b&3K9zd#$nFrVwwl6HM(0w5gV%pKDXncs=&^a(9yO@{^=hCosbXdis z?Hu~TZh{~!cqrGQ*8u<{q4)TpFBESueaYyUjI=}N0)P(^B1~U8I&MK=B&e!RP@TPW=x(z@hhD;En=JjTT@; zbiM{K%o#&~K?MQDD?Ef0w2UC^qtEd`!40#o0WeH{05IO$GXgS)*<$z%Wj%E62z`Mu zX!_u66ox)1RHN2vkmO+MgaG5ctRhGYZ04h735UVZF$MZ!^#x7|V&n!X4LS#bH{f|M zu?mh$CS&vp4@c?H`UguKbQ}Z~!eQbERKqYn3`!p8+6eUJz49YS3$|8;s3|&51B{Nb zEeHYVd;@mld9N@Ejsb26?PH-*kB-047nA=140B!-3No15A;9qHdJe#dSbc`IE-LSY zc9^vWz%cub0HdRG0eE2r!U|eX!G&RL3qm(W*XU$)O$+dWQ^eqdm4zS-)@s-|4S6Dl zrx4!I^(HXh|7RF&Wnf1ae8dwK2d~Mw$e!u0!v00)rX2w;WY3 zupw%S-Yx<94PzZBPz<mzEFY0bK#+xhO>27+5$OyEz&o6xlCgV7zs~7B@9(|;c%J8TeV6;XulxSvxo#;_ZQb)wc}0K}W$A7{KnVl^ z5gc3rDk@+@4BnaK0)o>KBv==VBVmXjur3Zo!f0b0322O(8o-N0#Gu>(ep$gcZzL*q zCj<@3lENQ;PIDZxbQwBe`#2GyN@Es2Wmw&ZB+uWmnCY0w>DnGtwAsqo^xeO;=fAtS zs(y>`p=tjhDffVObzoQjp?fUTOY87^nQ4FLIrTV&fIfe{B8i;>=s?s_{KpPf8ZN{@&uy zpa#LlvZwdSqZ$A1t=+burHdZ6rK3u$V6;JwJ?MjGojBq%yA=3Doj=| z_?ye%ctKHee7LI9iR;cyU&W1qW%z2*0#wR2?qrX$41w9xUHC{`&iFVe*Ew^N$4S2~ zRAdwmd>M6mnQ%r^R4Qg2R$-gN6(^3EZpT>n+R+98kioUCer)RCXw{hO79dNeuWqC8`5j>a0uXO{5qrJolA$@%bG2m_to6&iYk)CpW-yR^ZiIKwz%_yt{@C)FAG zIoV)j8o>6XrqIEuU8x#*Cm+JCZ;y zXoC!BlH`loXvw@P?3HMIDMtQW69R zUZjcLKQ6css`N%_U6U2Y7MaGtH2hg&+jC$$oNsDDl(u=z@J7B^dA#Jp_}tf+;^+hXZ2OqS92 z8y%4ky;Hl}L&Pv-y`sY>w7glUSn9^G&;cS`%N5vuHgOyKpftH8YsM;B(sMNy}(4y_@?vHGJS@7kVx z*-7B^j6L-_TbjuPt;l2Wfl2ITwg0QEJhLwop|LXl$ODdfwpwn4eCI>D}UPi!)I(T9T{Sj*8RAX>O&6_=D{B+wvd25X-3 z9@P8zT1Cy%@akj52m83Zw=09PVn8E-na(0HAoLyUflFOkUcWxxV&O>EFvsbq@8a{! zUOBTQPKek4Wmb7rYb{1cPPvFQ;kkZyVpT=9P!d7-{QTwPka!_o!WM9Q1jLJgrND6# zDDQam08DZ}(VWC#(`bKA#IUJn@G+U&i{$gQ@B#70k>m_YSRL=|-qKb1jM^hD4#GSE z7voh9V}d z<|iihv1JYg#*swZU9Gd%s<=`;SHOiyx>kfh|T?eeDOMlcc&i zmZo4u)WMD zS|9~J{Oqcw>v@@)OZ@Dj$QwfyqO;m1fTClYNPQ&>lEju<(Nrb(m1uP{)~yyv?Z1Qw zs`9o}Seic}YiFVP7Q&?) zZd_w^Z=hPo`+==B-i6|7ou@DCPMO5jhUs99w0i1BB0*%xhA%D8nXKH_8J?I4P-`|C-vC;){RsRf)YV_kWT+~D z9k0qwz~oI-no(agPVd030xweQYGgI`>V@Vxu<66G%39*08DSmgna>vLuQiXWn+HS> zGmk6?hX}^`P@Wf9lvk6w`-j**0lPQ zOA!0?t&DR~3{urwpg5~h)RSxK2A0M_3TQI#mhZ-U*V4^D@vIDjp`AlxbiU*=BXdnv*CMC6RI2gHw3!tR9JMI-*S zlaI9(Ru*qt%0>6$WE_w8=YOJ!+ue{BCQpR9Ymw_4C&l4*5~ZVZ0}0QH3Go$u$-4$x zOYJxPw#!fpjNP*612?j%Na3VDyn%F#N}^G>n1bAkt{ADbV)Eq7M{N%5Q=OvNUHrs3 zc@>W@%|!E>fcceszFDMboZxNNtH+NgHaggmCkUj$U~Y=IS1`%{CcTqO;Jv7p9YOo-;8P-3U+8D^6AEnII%^G& z20wWRlW&=tjByV1UV7VdVh3z|F6cAS{8@3iBmUfenf9#>rk3y#{Pp|%WreRSWIIIp z7F%p8F5l3TwA-RZ)9Y;4}D~*Z9?J}gVw-Qx0I)ybAZIi;}skMeI?zwZ#J z(c-#Nl4EZxn0|~~03H`8&=`l01ZSfKbDzbQI`gMhm&Y8JnA3vi8okbdn+>wv(d6qd zm=m<+_I?wizqdzGjY0|1 zIJ>4F+n^S`2(_J^|0+cKgQEYi&3iNp4owk{G>?ewY=@=DW_o{wv6E|A0P#SP21 zS7t~SYY4t;mBKK<{Gw;xn^mGgd9S&F7dqzlDebO~QylSh~zQ&bY zmi$ihW0wPli>#B2^l%aQ?N7d7?3ebO$|ljo7TD9>tc@~``ZDjiQ@5il zke6HDF{8PTDWFy}o(h==3r$GHbli<3!LO*;H8p)%Lg$`3|E%te31agSr0eO8e$Bg< zV*G;D8=afJU8R%qHygB)o@^VXB{WPIrcDq||6m4Xr>eQnYRjC1q&v%Sa!+h(<9^Ge788D}Cj;PMxT#_~55pFoKeaeckPTJixsC%K(GrnBh9* z`boKEAsMPOi-()%%)r!8>2b3=YTuy|AA8-$H}bP*vy9cPS(+Xw#)UN*#IjS+jAEHB z-_GiHyHut(eR#Kn9IYLm|FZP*tfWrIr^K;iBytSX^QF^CAz6Xx4w_z}<43w;_OnR&XD;0ygS7~F6200BbZD!Q06O%G%3-_z*lZB^kPGN1 z87~mn0E_klSpg2IA^|oadIxX%?9l&J3jL?_SEUw;gu)S=|8DUgroX3x{X73RPp~n{ z9Ro(fz~)G>9-2-QOY#Ssm>PkgU^62SL>{8>yUF2_eq9S7VSvMy$lpPQ-$A-2Xm3Xh z@yr$DYoIGG1TT`8BN6LC0>R}Wa9O$_^!ox5;r|Ik;2`TW7!NOBB9?@)mi;>wOTcT> z_u-5J1abikQ2;9_f}jc)6%iL9in3~Izr^$-Vw?aF5CQ=CXMmJ0Tu{6KasvIrU=S$% zL>vwf{vQmgMAz!ym?Gi=eX0M(U=StxcKjPtRE8q{F9v}?|2q$k_^&(|RFN*=-~C8L z6c&de(l1; + * + * $Id: example-buffer.c,v 1.5 2005/10/07 05:21:33 adam Exp $ + */ + +#ifdef _WIN32 +#include +#else +#include +#endif +#include + +#include "pt-sem.h" + +#define NUM_ITEMS 32 +#define BUFSIZE 8 + +static int buffer[BUFSIZE]; +static int bufptr; + +static void +add_to_buffer(int item) +{ + printf("Item %d added to buffer at place %d\n", item, bufptr); + buffer[bufptr] = item; + bufptr = (bufptr + 1) % BUFSIZE; +} +static int +get_from_buffer(void) +{ + int item; + item = buffer[bufptr]; + printf("Item %d retrieved from buffer at place %d\n", + item, bufptr); + bufptr = (bufptr + 1) % BUFSIZE; + return item; +} + +static int +produce_item(void) +{ + static int item = 0; + printf("Item %d produced\n", item); + return item++; +} + +static void +consume_item(int item) +{ + printf("Item %d consumed\n", item); +} + +static struct pt_sem full, empty; + +static +PT_THREAD(producer(struct pt *pt)) +{ + static int produced; + + PT_BEGIN(pt); + + for(produced = 0; produced < NUM_ITEMS; ++produced) { + + PT_SEM_WAIT(pt, &full); + + add_to_buffer(produce_item()); + + PT_SEM_SIGNAL(pt, &empty); + } + + PT_END(pt); +} + +static +PT_THREAD(consumer(struct pt *pt)) +{ + static int consumed; + + PT_BEGIN(pt); + + for(consumed = 0; consumed < NUM_ITEMS; ++consumed) { + + PT_SEM_WAIT(pt, &empty); + + consume_item(get_from_buffer()); + + PT_SEM_SIGNAL(pt, &full); + } + + PT_END(pt); +} + +static +PT_THREAD(driver_thread(struct pt *pt)) +{ + static struct pt pt_producer, pt_consumer; + + PT_BEGIN(pt); + + PT_SEM_INIT(&empty, 0); + PT_SEM_INIT(&full, BUFSIZE); + + PT_INIT(&pt_producer); + PT_INIT(&pt_consumer); + + PT_WAIT_THREAD(pt, producer(&pt_producer) & + consumer(&pt_consumer)); + + PT_END(pt); +} + + +int +main(void) +{ + struct pt driver_pt; + + PT_INIT(&driver_pt); + + while(PT_SCHEDULE(driver_thread(&driver_pt))) { + + /* + * When running this example on a multitasking system, we must + * give other processes a chance to run too and therefore we call + * usleep() resp. Sleep() here. On a dedicated embedded system, + * we usually do not need to do this. + */ +#ifdef _WIN32 + Sleep(0); +#else + usleep(10); +#endif + } + return 0; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-codelock.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-codelock.c new file mode 100644 index 0000000..cbeeb96 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-codelock.c @@ -0,0 +1,414 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. + * + * This file is part of the protothreads library. + * + * Author: Adam Dunkels + * + * $Id: example-codelock.c,v 1.5 2005/10/06 07:57:08 adam Exp $ + */ + +/* + * + * This example shows how to implement a simple code lock. The code + * lock waits for key presses from a numeric keyboard and if the + * correct code is entered, the lock is unlocked. There is a maximum + * time of one second between each key press, and after the correct + * code has been entered, no more keys must be pressed for 0.5 seconds + * before the lock is opened. + * + * This is an example that shows two things: + * - how to implement a code lock key input mechanism, and + * - how to implement a sequential timed routine. + * + * The program consists of two protothreads, one that implements the + * code lock reader and one that implements simulated keyboard input. + * + * + */ + +#ifdef _WIN32 +#include +#else +#include +#include +#endif +#include + +#include "pt.h" + +/*---------------------------------------------------------------------------*/ +/* + * The following definitions are just for the simple timer library + * used in this example. The actual implementation of the functions + * can be found at the end of this file. + */ +struct timer { int start, interval; }; +static int timer_expired(struct timer *t); +static void timer_set(struct timer *t, int usecs); +/*---------------------------------------------------------------------------*/ +/* + * This example uses two timers: one for the code lock protothread and + * one for the simulated key input protothread. + */ +static struct timer codelock_timer, input_timer; +/*---------------------------------------------------------------------------*/ +/* + * This is the code that has to be entered. + */ +static const char code[4] = {'1', '4', '2', '3'}; +/*---------------------------------------------------------------------------*/ +/* + * This example has two protothread and therefor has two protothread + * control structures of type struct pt. These are initialized with + * PT_INIT() in the main() function below. + */ +static struct pt codelock_pt, input_pt; +/*---------------------------------------------------------------------------*/ +/* + * The following code implements a simple key input. Input is made + * with the press_key() function, and the function key_pressed() + * checks if a key has been pressed. The variable "key" holds the + * latest key that was pressed. The variable "key_pressed_flag" is set + * when a key is pressed and cleared when a key press is checked. + */ +static char key, key_pressed_flag; + +static void +press_key(char k) +{ + printf("--- Key '%c' pressed\n", k); + key = k; + key_pressed_flag = 1; +} + +static int +key_pressed(void) +{ + if(key_pressed_flag != 0) { + key_pressed_flag = 0; + return 1; + } + return 0; +} +/*---------------------------------------------------------------------------*/ +/* + * Declaration of the protothread function implementing the code lock + * logic. The protothread function is declared using the PT_THREAD() + * macro. The function is declared with the "static" keyword since it + * is local to this file. The name of the function is codelock_thread + * and it takes one argument, pt, of the type struct pt. + * + */ +static +PT_THREAD(codelock_thread(struct pt *pt)) +{ + /* This is a local variable that holds the number of keys that have + * been pressed. Note that it is declared with the "static" keyword + * to make sure that the variable is *not* allocated on the stack. + */ + static int keys; + + /* + * Declare the beginning of the protothread. + */ + PT_BEGIN(pt); + + /* + * We'll let the protothread loop until the protothread is + * expliticly exited with PT_EXIT(). + */ + while(1) { + + /* + * We'll be reading key presses until we get the right amount of + * correct keys. + */ + for(keys = 0; keys < sizeof(code); ++keys) { + + /* + * If we haven't gotten any keypresses, we'll simply wait for one. + */ + if(keys == 0) { + + /* + * The PT_WAIT_UNTIL() function will block until the condition + * key_pressed() is true. + */ + PT_WAIT_UNTIL(pt, key_pressed()); + } else { + + /* + * If the "key" variable was larger than zero, we have already + * gotten at least one correct key press. If so, we'll not + * only wait for the next key, but we'll also set a timer that + * expires in one second. This gives the person pressing the + * keys one second to press the next key in the code. + */ + timer_set(&codelock_timer, 1000); + + /* + * The following statement shows how complex blocking + * conditions can be easily expressed with protothreads and + * the PT_WAIT_UNTIL() function. + */ + PT_WAIT_UNTIL(pt, key_pressed() || timer_expired(&codelock_timer)); + + /* + * If the timer expired, we should break out of the for() loop + * and start reading keys from the beginning of the while(1) + * loop instead. + */ + if(timer_expired(&codelock_timer)) { + printf("Code lock timer expired.\n"); + + /* + * Break out from the for() loop and start from the + * beginning of the while(1) loop. + */ + break; + } + } + + /* + * Check if the pressed key was correct. + */ + if(key != code[keys]) { + printf("Incorrect key '%c' found\n", key); + /* + * Break out of the for() loop since the key was incorrect. + */ + break; + } else { + printf("Correct key '%c' found\n", key); + } + } + + /* + * Check if we have gotten all keys. + */ + if(keys == sizeof(code)) { + printf("Correct code entered, waiting for 500 ms before unlocking.\n"); + + /* + * Ok, we got the correct code. But to make sure that the code + * was not just a fluke of luck by an intruder, but the correct + * code entered by a person that knows the correct code, we'll + * wait for half a second before opening the lock. If another + * key is pressed during this time, we'll assume that it was a + * fluke of luck that the correct code was entered the first + * time. + */ + timer_set(&codelock_timer, 500); + PT_WAIT_UNTIL(pt, key_pressed() || timer_expired(&codelock_timer)); + + /* + * If we continued from the PT_WAIT_UNTIL() statement without + * the timer expired, we don't open the lock. + */ + if(!timer_expired(&codelock_timer)) { + printf("Key pressed during final wait, code lock locked again.\n"); + } else { + + /* + * If the timer expired, we'll open the lock and exit from the + * protothread. + */ + printf("Code lock unlocked.\n"); + PT_EXIT(pt); + } + } + } + + /* + * Finally, we'll mark the end of the protothread. + */ + PT_END(pt); +} +/*---------------------------------------------------------------------------*/ +/* + * This is the second protothread in this example. It implements a + * simulated user pressing the keys. This illustrates how a linear + * sequence of timed instructions can be implemented with + * protothreads. + */ +static +PT_THREAD(input_thread(struct pt *pt)) +{ + PT_BEGIN(pt); + + printf("Waiting 1 second before entering first key.\n"); + + timer_set(&input_timer, 1000); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('1'); + + timer_set(&input_timer, 100); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('2'); + + timer_set(&input_timer, 100); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('3'); + + timer_set(&input_timer, 2000); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('1'); + + timer_set(&input_timer, 200); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('4'); + + timer_set(&input_timer, 200); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('2'); + + timer_set(&input_timer, 2000); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('3'); + + timer_set(&input_timer, 200); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('1'); + + timer_set(&input_timer, 200); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('4'); + + timer_set(&input_timer, 200); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('2'); + + timer_set(&input_timer, 100); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('3'); + + timer_set(&input_timer, 100); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('4'); + + timer_set(&input_timer, 1500); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('1'); + + timer_set(&input_timer, 300); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('4'); + + timer_set(&input_timer, 400); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('2'); + + timer_set(&input_timer, 500); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + press_key('3'); + + timer_set(&input_timer, 2000); + PT_WAIT_UNTIL(pt, timer_expired(&input_timer)); + + PT_END(pt); +} +/*---------------------------------------------------------------------------*/ +/* + * This is the main function. It initializes the two protothread + * control structures and schedules the two protothreads. The main + * function returns when the protothread the runs the code lock exits. + */ +int +main(void) +{ + /* + * Initialize the two protothread control structures. + */ + PT_INIT(&input_pt); + PT_INIT(&codelock_pt); + + /* + * Schedule the two protothreads until the codelock_thread() exits. + */ + while(PT_SCHEDULE(codelock_thread(&codelock_pt))) { + PT_SCHEDULE(input_thread(&input_pt)); + + /* + * When running this example on a multitasking system, we must + * give other processes a chance to run too and therefore we call + * usleep() resp. Sleep() here. On a dedicated embedded system, + * we usually do not need to do this. + */ +#ifdef _WIN32 + Sleep(0); +#else + usleep(10); +#endif + } + + return 0; +} +/*---------------------------------------------------------------------------*/ +/* + * Finally, the implementation of the simple timer library follows. + */ +#ifdef _WIN32 + +static int clock_time(void) +{ return (int)GetTickCount(); } + +#else /* _WIN32 */ + +static int clock_time(void) +{ + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + +#endif /* _WIN32 */ + +static int timer_expired(struct timer *t) +{ return (int)(clock_time() - t->start) >= (int)t->interval; } + +static void timer_set(struct timer *t, int interval) +{ t->interval = interval; t->start = clock_time(); } +/*---------------------------------------------------------------------------*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-small.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-small.c new file mode 100644 index 0000000..37c1716 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/example-small.c @@ -0,0 +1,97 @@ +/** + * This is a very small example that shows how to use + * protothreads. The program consists of two protothreads that wait + * for each other to toggle a variable. + */ + +/* We must always include pt.h in our protothreads code. */ +#include "pt.h" + +#include /* For printf(). */ + +/* Two flags that the two protothread functions use. */ +static int protothread1_flag, protothread2_flag; + +/** + * The first protothread function. A protothread function must always + * return an integer, but must never explicitly return - returning is + * performed inside the protothread statements. + * + * The protothread function is driven by the main loop further down in + * the code. + */ +static int +protothread1(struct pt *pt) +{ + /* A protothread function must begin with PT_BEGIN() which takes a + pointer to a struct pt. */ + PT_BEGIN(pt); + + /* We loop forever here. */ + while(1) { + /* Wait until the other protothread has set its flag. */ + PT_WAIT_UNTIL(pt, protothread2_flag != 0); + printf("Protothread 1 running\n"); + + /* We then reset the other protothread's flag, and set our own + flag so that the other protothread can run. */ + protothread2_flag = 0; + protothread1_flag = 1; + + /* And we loop. */ + } + + /* All protothread functions must end with PT_END() which takes a + pointer to a struct pt. */ + PT_END(pt); +} + +/** + * The second protothread function. This is almost the same as the + * first one. + */ +static int +protothread2(struct pt *pt) +{ + PT_BEGIN(pt); + + while(1) { + /* Let the other protothread run. */ + protothread2_flag = 1; + + /* Wait until the other protothread has set its flag. */ + PT_WAIT_UNTIL(pt, protothread1_flag != 0); + printf("Protothread 2 running\n"); + + /* We then reset the other protothread's flag. */ + protothread1_flag = 0; + + /* And we loop. */ + } + PT_END(pt); +} + +/** + * Finally, we have the main loop. Here is where the protothreads are + * initialized and scheduled. First, however, we define the + * protothread state variables pt1 and pt2, which hold the state of + * the two protothreads. + */ +static struct pt pt1, pt2; +int +main(void) +{ + /* Initialize the protothread state variables with PT_INIT(). */ + PT_INIT(&pt1); + PT_INIT(&pt2); + + /* + * Then we schedule the two protothreads by repeatedly calling their + * protothread functions and passing a pointer to the protothread + * state variables as arguments. + */ + while(1) { + protothread1(&pt1); + protothread2(&pt2); + } +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-addrlabels.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-addrlabels.h new file mode 100644 index 0000000..3e6474e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-addrlabels.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * Author: Adam Dunkels + * + * $Id: lc-addrlabels.h,v 1.4 2006/06/03 11:29:43 adam Exp $ + */ + +/** + * \addtogroup lc + * @{ + */ + +/** + * \file + * Implementation of local continuations based on the "Labels as + * values" feature of gcc + * \author + * Adam Dunkels + * + * This implementation of local continuations is based on a special + * feature of the GCC C compiler called "labels as values". This + * feature allows assigning pointers with the address of the code + * corresponding to a particular C label. + * + * For more information, see the GCC documentation: + * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html + * + */ + +#ifndef __LC_ADDRLABELS_H__ +#define __LC_ADDRLABELS_H__ + +/** \hideinitializer */ +typedef void * lc_t; + +#define LC_INIT(s) s = NULL + +#define LC_RESUME(s) \ + do { \ + if(s != NULL) { \ + goto *s; \ + } \ + } while(0) + +#define LC_CONCAT2(s1, s2) s1##s2 +#define LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2) + +#define LC_SET(s) \ + do { \ + LC_CONCAT(LC_LABEL, __LINE__): \ + (s) = &&LC_CONCAT(LC_LABEL, __LINE__); \ + } while(0) + +#define LC_END(s) + +#endif /* __LC_ADDRLABELS_H__ */ +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-switch.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-switch.h new file mode 100644 index 0000000..dbdde01 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc-switch.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * Author: Adam Dunkels + * + * $Id: lc-switch.h,v 1.4 2006/06/03 11:29:43 adam Exp $ + */ + +/** + * \addtogroup lc + * @{ + */ + +/** + * \file + * Implementation of local continuations based on switch() statment + * \author Adam Dunkels + * + * This implementation of local continuations uses the C switch() + * statement to resume execution of a function somewhere inside the + * function's body. The implementation is based on the fact that + * switch() statements are able to jump directly into the bodies of + * control structures such as if() or while() statmenets. + * + * This implementation borrows heavily from Simon Tatham's coroutines + * implementation in C: + * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html + */ + +#ifndef __LC_SWITCH_H__ +#define __LC_SWITCH_H__ + +/* WARNING! lc implementation using switch() does not work if an + LC_SET() is done within another switch() statement! */ + +/** \hideinitializer */ +typedef unsigned short lc_t; + +#define LC_INIT(s) s = 0; + +#define LC_RESUME(s) switch(s) { case 0: + +#define LC_SET(s) s = __LINE__; case __LINE__: + +#define LC_END(s) } + +#endif /* __LC_SWITCH_H__ */ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc.h new file mode 100644 index 0000000..a965956 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/lc.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. + * + * This file is part of the protothreads library. + * + * Author: Adam Dunkels + * + * $Id: lc.h,v 1.2 2005/02/24 10:36:59 adam Exp $ + */ + +/** + * \addtogroup pt + * @{ + */ + +/** + * \defgroup lc Local continuations + * @{ + * + * Local continuations form the basis for implementing protothreads. A + * local continuation can be set in a specific function to + * capture the state of the function. After a local continuation has + * been set can be resumed in order to restore the state of the + * function at the point where the local continuation was set. + * + * + */ + +/** + * \file lc.h + * Local continuations + * \author + * Adam Dunkels + * + */ + +#ifdef DOXYGEN +/** + * Initialize a local continuation. + * + * This operation initializes the local continuation, thereby + * unsetting any previously set continuation state. + * + * \hideinitializer + */ +#define LC_INIT(lc) + +/** + * Set a local continuation. + * + * The set operation saves the state of the function at the point + * where the operation is executed. As far as the set operation is + * concerned, the state of the function does not include the + * call-stack or local (automatic) variables, but only the program + * counter and such CPU registers that needs to be saved. + * + * \hideinitializer + */ +#define LC_SET(lc) + +/** + * Resume a local continuation. + * + * The resume operation resumes a previously set local continuation, thus + * restoring the state in which the function was when the local + * continuation was set. If the local continuation has not been + * previously set, the resume operation does nothing. + * + * \hideinitializer + */ +#define LC_RESUME(lc) + +/** + * Mark the end of local continuation usage. + * + * The end operation signifies that local continuations should not be + * used any more in the function. This operation is not needed for + * most implementations of local continuation, but is required by a + * few implementations. + * + * \hideinitializer + */ +#define LC_END(lc) + +/** + * \var typedef lc_t; + * + * The local continuation type. + * + * \hideinitializer + */ +#endif /* DOXYGEN */ + +#ifndef __LC_H__ +#define __LC_H__ + + +#ifdef LC_INCLUDE +#include LC_INCLUDE +#else +#include "lc-switch.h" +#endif /* LC_INCLUDE */ + +#endif /* __LC_H__ */ + +/** @} */ +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt-sem.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt-sem.h new file mode 100644 index 0000000..98ae25d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt-sem.h @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2004, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. + * + * This file is part of the protothreads library. + * + * Author: Adam Dunkels + * + * $Id: pt-sem.h,v 1.2 2005/02/24 10:36:59 adam Exp $ + */ + +/** + * \addtogroup pt + * @{ + */ + +/** + * \defgroup ptsem Protothread semaphores + * @{ + * + * This module implements counting semaphores on top of + * protothreads. Semaphores are a synchronization primitive that + * provide two operations: "wait" and "signal". The "wait" operation + * checks the semaphore counter and blocks the thread if the counter + * is zero. The "signal" operation increases the semaphore counter but + * does not block. If another thread has blocked waiting for the + * semaphore that is signalled, the blocked thread will become + * runnable again. + * + * Semaphores can be used to implement other, more structured, + * synchronization primitives such as monitors and message + * queues/bounded buffers (see below). + * + * The following example shows how the producer-consumer problem, also + * known as the bounded buffer problem, can be solved using + * protothreads and semaphores. Notes on the program follow after the + * example. + * + \code +#include "pt-sem.h" + +#define NUM_ITEMS 32 +#define BUFSIZE 8 + +static struct pt_sem mutex, full, empty; + +PT_THREAD(producer(struct pt *pt)) +{ + static int produced; + + PT_BEGIN(pt); + + for(produced = 0; produced < NUM_ITEMS; ++produced) { + + PT_SEM_WAIT(pt, &full); + + PT_SEM_WAIT(pt, &mutex); + add_to_buffer(produce_item()); + PT_SEM_SIGNAL(pt, &mutex); + + PT_SEM_SIGNAL(pt, &empty); + } + + PT_END(pt); +} + +PT_THREAD(consumer(struct pt *pt)) +{ + static int consumed; + + PT_BEGIN(pt); + + for(consumed = 0; consumed < NUM_ITEMS; ++consumed) { + + PT_SEM_WAIT(pt, &empty); + + PT_SEM_WAIT(pt, &mutex); + consume_item(get_from_buffer()); + PT_SEM_SIGNAL(pt, &mutex); + + PT_SEM_SIGNAL(pt, &full); + } + + PT_END(pt); +} + +PT_THREAD(driver_thread(struct pt *pt)) +{ + static struct pt pt_producer, pt_consumer; + + PT_BEGIN(pt); + + PT_SEM_INIT(&empty, 0); + PT_SEM_INIT(&full, BUFSIZE); + PT_SEM_INIT(&mutex, 1); + + PT_INIT(&pt_producer); + PT_INIT(&pt_consumer); + + PT_WAIT_THREAD(pt, producer(&pt_producer) & + consumer(&pt_consumer)); + + PT_END(pt); +} + \endcode + * + * The program uses three protothreads: one protothread that + * implements the consumer, one thread that implements the producer, + * and one protothread that drives the two other protothreads. The + * program uses three semaphores: "full", "empty" and "mutex". The + * "mutex" semaphore is used to provide mutual exclusion for the + * buffer, the "empty" semaphore is used to block the consumer is the + * buffer is empty, and the "full" semaphore is used to block the + * producer is the buffer is full. + * + * The "driver_thread" holds two protothread state variables, + * "pt_producer" and "pt_consumer". It is important to note that both + * these variables are declared as static. If the static + * keyword is not used, both variables are stored on the stack. Since + * protothreads do not store the stack, these variables may be + * overwritten during a protothread wait operation. Similarly, both + * the "consumer" and "producer" protothreads declare their local + * variables as static, to avoid them being stored on the stack. + * + * + */ + +/** + * \file + * Couting semaphores implemented on protothreads + * \author + * Adam Dunkels + * + */ + +#ifndef __PT_SEM_H__ +#define __PT_SEM_H__ + +#include "pt.h" + +struct pt_sem { + unsigned int count; +}; + +/** + * Initialize a semaphore + * + * This macro initializes a semaphore with a value for the + * counter. Internally, the semaphores use an "unsigned int" to + * represent the counter, and therefore the "count" argument should be + * within range of an unsigned int. + * + * \param s (struct pt_sem *) A pointer to the pt_sem struct + * representing the semaphore + * + * \param c (unsigned int) The initial count of the semaphore. + * \hideinitializer + */ +#define PT_SEM_INIT(s, c) (s)->count = c + +/** + * Wait for a semaphore + * + * This macro carries out the "wait" operation on the semaphore. The + * wait operation causes the protothread to block while the counter is + * zero. When the counter reaches a value larger than zero, the + * protothread will continue. + * + * \param pt (struct pt *) A pointer to the protothread (struct pt) in + * which the operation is executed. + * + * \param s (struct pt_sem *) A pointer to the pt_sem struct + * representing the semaphore + * + * \hideinitializer + */ +#define PT_SEM_WAIT(pt, s) \ + do { \ + PT_WAIT_UNTIL(pt, (s)->count > 0); \ + --(s)->count; \ + } while(0) + +/** + * Signal a semaphore + * + * This macro carries out the "signal" operation on the semaphore. The + * signal operation increments the counter inside the semaphore, which + * eventually will cause waiting protothreads to continue executing. + * + * \param pt (struct pt *) A pointer to the protothread (struct pt) in + * which the operation is executed. + * + * \param s (struct pt_sem *) A pointer to the pt_sem struct + * representing the semaphore + * + * \hideinitializer + */ +#define PT_SEM_SIGNAL(pt, s) ++(s)->count + +#endif /* __PT_SEM_H__ */ + +/** @} */ +/** @} */ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt.h new file mode 100644 index 0000000..92856cb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/protothreads/pt-1.4/pt.h @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * Author: Adam Dunkels + * + * $Id: pt.h,v 1.7 2006/10/02 07:52:56 adam Exp $ + */ + +/** + * \addtogroup pt + * @{ + */ + +/** + * \file + * Protothreads implementation. + * \author + * Adam Dunkels + * + */ + +#ifndef __PT_H__ +#define __PT_H__ + +#include "lc.h" + +struct pt { + lc_t lc; +}; + +#define PT_WAITING 0 +#define PT_YIELDED 1 +#define PT_EXITED 2 +#define PT_ENDED 3 + +/** + * \name Initialization + * @{ + */ + +/** + * Initialize a protothread. + * + * Initializes a protothread. Initialization must be done prior to + * starting to execute the protothread. + * + * \param pt A pointer to the protothread control structure. + * + * \sa PT_SPAWN() + * + * \hideinitializer + */ +#define PT_INIT(pt) LC_INIT((pt)->lc) + +/** @} */ + +/** + * \name Declaration and definition + * @{ + */ + +/** + * Declaration of a protothread. + * + * This macro is used to declare a protothread. All protothreads must + * be declared with this macro. + * + * \param name_args The name and arguments of the C function + * implementing the protothread. + * + * \hideinitializer + */ +#define PT_THREAD(name_args) char name_args + +/** + * Declare the start of a protothread inside the C function + * implementing the protothread. + * + * This macro is used to declare the starting point of a + * protothread. It should be placed at the start of the function in + * which the protothread runs. All C statements above the PT_BEGIN() + * invokation will be executed each time the protothread is scheduled. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc) + +/** + * Declare the end of a protothread. + * + * This macro is used for declaring that a protothread ends. It must + * always be used together with a matching PT_BEGIN() macro. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_END(pt) LC_END((pt)->lc); PT_YIELD_FLAG = 0; \ + PT_INIT(pt); return PT_ENDED; } + +/** @} */ + +/** + * \name Blocked wait + * @{ + */ + +/** + * Block and wait until condition is true. + * + * This macro blocks the protothread until the specified condition is + * true. + * + * \param pt A pointer to the protothread control structure. + * \param condition The condition. + * + * \hideinitializer + */ +#define PT_WAIT_UNTIL(pt, condition) \ + do { \ + LC_SET((pt)->lc); \ + if(!(condition)) { \ + return PT_WAITING; \ + } \ + } while(0) + +/** + * Block and wait while condition is true. + * + * This function blocks and waits while condition is true. See + * PT_WAIT_UNTIL(). + * + * \param pt A pointer to the protothread control structure. + * \param cond The condition. + * + * \hideinitializer + */ +#define PT_WAIT_WHILE(pt, cond) PT_WAIT_UNTIL((pt), !(cond)) + +/** @} */ + +/** + * \name Hierarchical protothreads + * @{ + */ + +/** + * Block and wait until a child protothread completes. + * + * This macro schedules a child protothread. The current protothread + * will block until the child protothread completes. + * + * \note The child protothread must be manually initialized with the + * PT_INIT() function before this function is used. + * + * \param pt A pointer to the protothread control structure. + * \param thread The child protothread with arguments + * + * \sa PT_SPAWN() + * + * \hideinitializer + */ +#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread)) + +/** + * Spawn a child protothread and wait until it exits. + * + * This macro spawns a child protothread and waits until it exits. The + * macro can only be used within a protothread. + * + * \param pt A pointer to the protothread control structure. + * \param child A pointer to the child protothread's control structure. + * \param thread The child protothread with arguments + * + * \hideinitializer + */ +#define PT_SPAWN(pt, child, thread) \ + do { \ + PT_INIT((child)); \ + PT_WAIT_THREAD((pt), (thread)); \ + } while(0) + +/** @} */ + +/** + * \name Exiting and restarting + * @{ + */ + +/** + * Restart the protothread. + * + * This macro will block and cause the running protothread to restart + * its execution at the place of the PT_BEGIN() call. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_RESTART(pt) \ + do { \ + PT_INIT(pt); \ + return PT_WAITING; \ + } while(0) + +/** + * Exit the protothread. + * + * This macro causes the protothread to exit. If the protothread was + * spawned by another protothread, the parent protothread will become + * unblocked and can continue to run. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_EXIT(pt) \ + do { \ + PT_INIT(pt); \ + return PT_EXITED; \ + } while(0) + +/** @} */ + +/** + * \name Calling a protothread + * @{ + */ + +/** + * Schedule a protothread. + * + * This function shedules a protothread. The return value of the + * function is non-zero if the protothread is running or zero if the + * protothread has exited. + * + * \param f The call to the C function implementing the protothread to + * be scheduled + * + * \hideinitializer + */ +#define PT_SCHEDULE(f) ((f) < PT_EXITED) + +/** @} */ + +/** + * \name Yielding from a protothread + * @{ + */ + +/** + * Yield from the current protothread. + * + * This function will yield the protothread, thereby allowing other + * processing to take place in the system. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_YIELD(pt) \ + do { \ + PT_YIELD_FLAG = 0; \ + LC_SET((pt)->lc); \ + if(PT_YIELD_FLAG == 0) { \ + return PT_YIELDED; \ + } \ + } while(0) + +/** + * \brief Yield from the protothread until a condition occurs. + * \param pt A pointer to the protothread control structure. + * \param cond The condition. + * + * This function will yield the protothread, until the + * specified condition evaluates to true. + * + * + * \hideinitializer + */ +#define PT_YIELD_UNTIL(pt, cond) \ + do { \ + PT_YIELD_FLAG = 0; \ + LC_SET((pt)->lc); \ + if((PT_YIELD_FLAG == 0) || !(cond)) { \ + return PT_YIELDED; \ + } \ + } while(0) + +/** @} */ + +#endif /* __PT_H__ */ + +/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Conf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Conf.h similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Conf.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Conf.h diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_IAR.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_IAR.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_IAR.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_IAR.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_KEIL.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_KEIL.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_KEIL.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_KEIL.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_SES.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_SES.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_Syscalls_SES.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_Syscalls_SES.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_printf.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_printf.c similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/SEGGER_RTT_printf.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/SEGGER_RTT_printf.c diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/license/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/license/license.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external/segger_rtt/license/license.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/segger_rtt/license/license.txt diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/SIL-License.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/SIL-License.txt new file mode 100644 index 0000000..6cbde89 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/SIL-License.txt @@ -0,0 +1,89 @@ +SIL OPEN FONT LICENSE + +Version 1.1 - 26 February 2007 + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting — in part or in whole — any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. + +© 2003-2014 SIL International, all rights reserved, unless otherwise noted elsewhere on this page. +Provided by SIL's Non-Roman Script Initiative. Contact us here: http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=support \ No newline at end of file diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/nrf_font.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/nrf_font.h new file mode 100644 index 0000000..379dc0b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/nrf_font.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2016 Eran Duchan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef NRF_FONT_H__ +#define NRF_FONT_H__ + +#include "stdint.h" + +/** @file + * + * @defgroup nrf_font Font header + * @{ + * @ingroup nrf_gfx + * + * @brief Generated font structures. + */ + +/** + * @brief Font char information. + */ +typedef struct +{ + uint8_t widthBits; /**< Width in bits (or pixels) of the character. */ + uint16_t offset; /**< Offset of the character's bitmap, in bytes, into the FONT_INFO's data array. */ +}FONT_CHAR_INFO; + +/** + * @brief Font descriptor. + */ +typedef struct +{ + uint8_t height; /**< Height in bits (or pixels), of the font's characters. */ + uint8_t startChar; /**< The first character in the font (e.g. in charInfo and data). */ + uint8_t endChar; /**< The last character in the font. */ + uint8_t spacePixels; /**< Number of pixels that the space character takes up. */ + const FONT_CHAR_INFO * charInfo; /**< Pointer to array of char information. */ + const uint8_t * data; /**< Pointer to a generated array of character visual representation. */ +}FONT_INFO; + + +/** @} */ + +#endif // NRF_FONT_H__ + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney24pts.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney24pts.c new file mode 100644 index 0000000..9416177 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney24pts.c @@ -0,0 +1,4736 @@ +/* Font copyrights: + * + * Copyright (c) 2015, + * Alfredo Marco Pradil (https://behance.net/pradil), + * Samuel Oakes (http://oakes.co/), + * Cristiano Sobral (https://www.behance.net/cssobral20f492), + * with Reserved Font Name Orkney. + * + * Code was generated by The Dot Factory (https://github.com/pavius/the-dot-factory) + * + * This Font Software is licensed under the SIL Open Font License, Version 1.1. See SIL-License.txt + * for more informations. + * + */ + +#include "nrf_font.h" +// Character bitmaps for Orkney 24pt +const uint8_t orkney_24ptBitmaps[] = +{ + // @0 '!' (4 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x60, // ## + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @47 '"' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xE3, 0xC0, // ### #### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0xC0, // ### ### + 0xE1, 0x80, // ### ## + 0xE1, 0x80, // ### ## + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @141 '#' (27 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x70, 0x1C, 0x00, // ### ### + 0x00, 0x70, 0x1C, 0x00, // ### ### + 0x00, 0x60, 0x18, 0x00, // ## ## + 0x00, 0x60, 0x18, 0x00, // ## ## + 0x00, 0x60, 0x18, 0x00, // ## ## + 0x00, 0xE0, 0x38, 0x00, // ### ### + 0x00, 0xE0, 0x38, 0x00, // ### ### + 0x1F, 0xFF, 0xFF, 0xE0, // ######################## + 0x3F, 0xFF, 0xFF, 0xC0, // ######################## + 0x3F, 0xFF, 0xFF, 0xC0, // ######################## + 0x00, 0xC0, 0x30, 0x00, // ## ## + 0x00, 0xC0, 0x30, 0x00, // ## ## + 0x01, 0xC0, 0x30, 0x00, // ### ## + 0x01, 0xC0, 0x70, 0x00, // ### ### + 0x01, 0xC0, 0x70, 0x00, // ### ### + 0x01, 0xC0, 0x70, 0x00, // ### ### + 0x01, 0x80, 0x70, 0x00, // ## ### + 0x01, 0x80, 0x60, 0x00, // ## ## + 0x01, 0x80, 0x60, 0x00, // ## ## + 0x7F, 0xFF, 0xFF, 0x80, // ######################## + 0x7F, 0xFF, 0xFF, 0x80, // ######################## + 0xFF, 0xFF, 0xFF, 0x80, // ######################### + 0x03, 0x80, 0xE0, 0x00, // ### ### + 0x03, 0x80, 0xE0, 0x00, // ### ### + 0x03, 0x00, 0xE0, 0x00, // ## ### + 0x03, 0x00, 0xC0, 0x00, // ## ## + 0x03, 0x00, 0xC0, 0x00, // ## ## + 0x07, 0x01, 0xC0, 0x00, // ### ### + 0x07, 0x01, 0xC0, 0x00, // ### ### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @329 '$' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x70, 0x00, // ### + 0x00, 0x70, 0x00, // ### + 0x00, 0x70, 0x00, // ### + 0x00, 0xF0, 0x00, // #### + 0x07, 0xFE, 0x00, // ########## + 0x0F, 0xFF, 0x00, // ############ + 0x1F, 0x07, 0x80, // ##### #### + 0x3C, 0x03, 0xC0, // #### #### + 0x38, 0x01, 0x00, // ### # + 0x78, 0x00, 0x00, // #### + 0x70, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, // ### + 0x78, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0x3C, 0x00, 0x00, // #### + 0x3E, 0x00, 0x00, // ##### + 0x1F, 0x80, 0x00, // ###### + 0x0F, 0xF0, 0x00, // ######## + 0x03, 0xFC, 0x00, // ######## + 0x00, 0xFF, 0x00, // ######## + 0x00, 0x3F, 0x80, // ####### + 0x00, 0x07, 0xC0, // ##### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x00, 0xF0, // #### + 0x00, 0x00, 0x70, // ### + 0x00, 0x00, 0x70, // ### + 0x20, 0x00, 0x70, // # ### + 0x60, 0x00, 0xF0, // ## #### + 0xF0, 0x00, 0xE0, // #### ### + 0x78, 0x01, 0xE0, // #### #### + 0x3E, 0x07, 0xC0, // ##### ##### + 0x1F, 0xFF, 0x80, // ############## + 0x0F, 0xFF, 0x00, // ############ + 0x01, 0xF8, 0x00, // ###### + 0x00, 0x70, 0x00, // ### + 0x00, 0x70, 0x00, // ### + 0x00, 0x70, 0x00, // ### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @470 '%' (26 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x0F, 0x00, 0x07, 0x80, // #### #### + 0x3F, 0x80, 0x0F, 0x00, // ####### #### + 0x7F, 0xC0, 0x0E, 0x00, // ######### ### + 0x71, 0xE0, 0x1E, 0x00, // ### #### #### + 0xE0, 0xE0, 0x3C, 0x00, // ### ### #### + 0xE0, 0xE0, 0x38, 0x00, // ### ### ### + 0xE0, 0x60, 0x78, 0x00, // ### ## #### + 0xE0, 0xE0, 0xF0, 0x00, // ### ### #### + 0xF0, 0xE0, 0xF0, 0x00, // #### ### #### + 0x71, 0xE1, 0xE0, 0x00, // ### #### #### + 0x7F, 0xC3, 0xC0, 0x00, // ######### #### + 0x3F, 0x83, 0xC0, 0x00, // ####### #### + 0x0F, 0x07, 0x80, 0x00, // #### #### + 0x00, 0x07, 0x00, 0x00, // ### + 0x00, 0x0F, 0x00, 0x00, // #### + 0x00, 0x1E, 0x00, 0x00, // #### + 0x00, 0x1C, 0x00, 0x00, // ### + 0x00, 0x3C, 0x00, 0x00, // #### + 0x00, 0x78, 0x3C, 0x00, // #### #### + 0x00, 0x70, 0x7F, 0x00, // ### ####### + 0x00, 0xF0, 0xFF, 0x80, // #### ######### + 0x01, 0xE1, 0xE3, 0x80, // #### #### ### + 0x01, 0xC1, 0xC1, 0xC0, // ### ### ### + 0x03, 0xC1, 0xC1, 0xC0, // #### ### ### + 0x07, 0x81, 0xC1, 0xC0, // #### ### ### + 0x07, 0x01, 0xC1, 0xC0, // ### ### ### + 0x0F, 0x01, 0xC1, 0xC0, // #### ### ### + 0x1E, 0x01, 0xE3, 0x80, // #### #### ### + 0x1C, 0x00, 0xFF, 0x80, // ### ######### + 0x3C, 0x00, 0x7F, 0x00, // #### ####### + 0x78, 0x00, 0x3E, 0x00, // #### ##### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @658 '&' (24 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xE0, 0x00, // ##### + 0x0F, 0xF8, 0x00, // ######### + 0x1F, 0xFC, 0x00, // ########### + 0x3E, 0x1E, 0x00, // ##### #### + 0x38, 0x0E, 0x00, // ### ### + 0x78, 0x0F, 0x00, // #### #### + 0x70, 0x07, 0x00, // ### ### + 0x70, 0x00, 0x00, // ### + 0x78, 0x00, 0x00, // #### + 0x38, 0x00, 0x00, // ### + 0x3C, 0x00, 0x00, // #### + 0x3E, 0x00, 0x00, // ##### + 0x1F, 0x00, 0x00, // ##### + 0x0F, 0x80, 0x00, // ##### + 0x0F, 0xC0, 0x00, // ###### + 0x1F, 0xE0, 0x00, // ######## + 0x3D, 0xF0, 0x00, // #### ##### + 0x78, 0xF8, 0x00, // #### ##### + 0x70, 0x7C, 0x04, // ### ##### # + 0xF0, 0x3E, 0x0E, // #### ##### ### + 0xE0, 0x1F, 0x1F, // ### ##### ##### + 0xE0, 0x0F, 0xBE, // ### ##### ##### + 0xE0, 0x07, 0xFC, // ### ######### + 0xE0, 0x03, 0xF8, // ### ####### + 0xF0, 0x01, 0xF0, // #### ##### + 0x70, 0x03, 0xF8, // ### ####### + 0x78, 0x07, 0xFC, // #### ######### + 0x3E, 0x0F, 0xBE, // ##### ##### ##### + 0x1F, 0xFF, 0x1F, // ############# ##### + 0x0F, 0xFC, 0x0E, // ########## ### + 0x03, 0xF0, 0x04, // ###### # + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @799 ''' (3 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @846 '(' (11 pixels wide) + 0x00, 0x20, // # + 0x01, 0xE0, // #### + 0x03, 0xE0, // ##### + 0x07, 0xE0, // ###### + 0x0F, 0x00, // #### + 0x0E, 0x00, // ### + 0x1E, 0x00, // #### + 0x1C, 0x00, // ### + 0x3C, 0x00, // #### + 0x38, 0x00, // ### + 0x78, 0x00, // #### + 0x70, 0x00, // ### + 0x70, 0x00, // ### + 0x70, 0x00, // ### + 0x70, 0x00, // ### + 0xF0, 0x00, // #### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xF0, 0x00, // #### + 0x70, 0x00, // ### + 0x70, 0x00, // ### + 0x70, 0x00, // ### + 0x70, 0x00, // ### + 0x38, 0x00, // ### + 0x38, 0x00, // ### + 0x38, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x0E, 0x00, // ### + 0x0F, 0x00, // #### + 0x07, 0xC0, // ##### + 0x03, 0xE0, // ##### + 0x00, 0xE0, // ### + + // @940 ')' (10 pixels wide) + 0x80, 0x00, // # + 0xE0, 0x00, // ### + 0xF0, 0x00, // #### + 0xF8, 0x00, // ##### + 0x3C, 0x00, // #### + 0x1E, 0x00, // #### + 0x0E, 0x00, // ### + 0x0F, 0x00, // #### + 0x07, 0x00, // ### + 0x07, 0x00, // ### + 0x07, 0x80, // #### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0xC0, // #### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x01, 0xC0, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x07, 0x00, // ### + 0x07, 0x00, // ### + 0x0E, 0x00, // ### + 0x0E, 0x00, // ### + 0x1C, 0x00, // ### + 0x3C, 0x00, // #### + 0xF8, 0x00, // ##### + 0xF0, 0x00, // #### + 0xC0, 0x00, // ## + + // @1034 '*' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x12, 0x00, // # # + 0x33, 0x00, // ## ## + 0x36, 0x00, // ## ## + 0x1E, 0x00, // #### + 0xEF, 0xC0, // ### ###### + 0xFF, 0xC0, // ########## + 0x1C, 0x00, // ### + 0x16, 0x00, // # ## + 0x33, 0x00, // ## ## + 0x32, 0x00, // ## # + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @1128 '+' (24 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0xFF, 0xFF, 0xFF, // ######################## + 0xFF, 0xFF, 0xFF, // ######################## + 0xFF, 0xFF, 0xFF, // ######################## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x18, 0x00, // ## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @1269 ',' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x60, // ## + 0xF0, // #### + 0xF8, // ##### + 0xF8, // ##### + 0x78, // #### + 0x18, // ## + 0x18, // ## + 0x30, // ## + 0x30, // ## + 0x70, // ### + 0xE0, // ### + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1316 '-' (14 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xFF, 0xFC, // ############## + 0xFF, 0xFC, // ############## + 0xFF, 0xFC, // ############## + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @1410 '.' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0x78, // #### + 0xF8, // ##### + 0x78, // #### + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1457 '/' (25 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x07, 0x80, // #### + 0x00, 0x00, 0x07, 0x00, // ### + 0x00, 0x00, 0x0F, 0x00, // #### + 0x00, 0x00, 0x0E, 0x00, // ### + 0x00, 0x00, 0x1C, 0x00, // ### + 0x00, 0x00, 0x1C, 0x00, // ### + 0x00, 0x00, 0x38, 0x00, // ### + 0x00, 0x00, 0x38, 0x00, // ### + 0x00, 0x00, 0x70, 0x00, // ### + 0x00, 0x00, 0x70, 0x00, // ### + 0x00, 0x00, 0xE0, 0x00, // ### + 0x00, 0x00, 0xE0, 0x00, // ### + 0x00, 0x01, 0xC0, 0x00, // ### + 0x00, 0x03, 0xC0, 0x00, // #### + 0x00, 0x03, 0x80, 0x00, // ### + 0x00, 0x07, 0x80, 0x00, // #### + 0x00, 0x07, 0x00, 0x00, // ### + 0x00, 0x0F, 0x00, 0x00, // #### + 0x00, 0x0E, 0x00, 0x00, // ### + 0x00, 0x1E, 0x00, 0x00, // #### + 0x00, 0x1C, 0x00, 0x00, // ### + 0x00, 0x3C, 0x00, 0x00, // #### + 0x00, 0x38, 0x00, 0x00, // ### + 0x00, 0x78, 0x00, 0x00, // #### + 0x00, 0x70, 0x00, 0x00, // ### + 0x00, 0xF0, 0x00, 0x00, // #### + 0x00, 0xE0, 0x00, 0x00, // ### + 0x01, 0xE0, 0x00, 0x00, // #### + 0x01, 0xC0, 0x00, 0x00, // ### + 0x03, 0xC0, 0x00, 0x00, // #### + 0x03, 0x80, 0x00, 0x00, // ### + 0x07, 0x80, 0x00, 0x00, // #### + 0x07, 0x00, 0x00, 0x00, // ### + 0x0F, 0x00, 0x00, 0x00, // #### + 0x0E, 0x00, 0x00, 0x00, // ### + 0x1E, 0x00, 0x00, 0x00, // #### + 0x1C, 0x00, 0x00, 0x00, // ### + 0x3C, 0x00, 0x00, 0x00, // #### + 0x38, 0x00, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, 0x00, // ### + 0xF0, 0x00, 0x00, 0x00, // #### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @1645 '0' (21 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0xFC, 0x00, // ###### + 0x03, 0xFF, 0x00, // ########## + 0x07, 0xFF, 0x80, // ############ + 0x0F, 0x87, 0xC0, // ##### ##### + 0x1E, 0x03, 0xC0, // #### #### + 0x3C, 0x01, 0xE0, // #### #### + 0x3C, 0x00, 0xF0, // #### #### + 0x78, 0x00, 0xF0, // #### #### + 0x78, 0x00, 0x70, // #### ### + 0x70, 0x00, 0x78, // ### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x38, // #### ### + 0xE0, 0x00, 0x38, // ### ### + 0xE0, 0x00, 0x38, // ### ### + 0xE0, 0x00, 0x38, // ### ### + 0xE0, 0x00, 0x38, // ### ### + 0xE0, 0x00, 0x38, // ### ### + 0xF0, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x78, // #### #### + 0x70, 0x00, 0x78, // ### #### + 0x78, 0x00, 0x70, // #### ### + 0x78, 0x00, 0xF0, // #### #### + 0x3C, 0x00, 0xF0, // #### #### + 0x3C, 0x01, 0xE0, // #### #### + 0x1E, 0x03, 0xC0, // #### #### + 0x0F, 0x87, 0xC0, // ##### ##### + 0x07, 0xFF, 0x80, // ############ + 0x03, 0xFF, 0x00, // ########## + 0x00, 0xFC, 0x00, // ###### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @1786 '1' (9 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x07, 0x80, // #### + 0x0F, 0x80, // ##### + 0x1F, 0x80, // ###### + 0x7F, 0x80, // ######## + 0xFF, 0x80, // ######### + 0xF3, 0x80, // #### ### + 0xE3, 0x80, // ### ### + 0xC3, 0x80, // ## ### + 0x83, 0x80, // # ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x03, 0x80, // ### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @1880 '2' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x01, 0xF8, 0x00, // ###### + 0x07, 0xFE, 0x00, // ########## + 0x1F, 0xFF, 0x00, // ############# + 0x3E, 0x0F, 0x80, // ##### ##### + 0x3C, 0x03, 0xC0, // #### #### + 0x78, 0x01, 0xC0, // #### ### + 0x70, 0x01, 0xE0, // ### #### + 0x70, 0x01, 0xE0, // ### #### + 0x70, 0x01, 0xE0, // ### #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xC0, // ### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x07, 0x80, // #### + 0x00, 0x0F, 0x00, // #### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x7C, 0x00, // ##### + 0x00, 0xF8, 0x00, // ##### + 0x01, 0xF0, 0x00, // ##### + 0x01, 0xE0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x07, 0x80, 0x00, // #### + 0x0F, 0x00, 0x00, // #### + 0x1E, 0x00, 0x00, // #### + 0x3C, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xF0, // #################### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2021 '3' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x01, 0xF8, 0x00, // ###### + 0x07, 0xFC, 0x00, // ######### + 0x1F, 0xFF, 0x00, // ############# + 0x1E, 0x0F, 0x00, // #### #### + 0x3C, 0x07, 0x80, // #### #### + 0x38, 0x03, 0x80, // ### ### + 0x38, 0x03, 0x80, // ### ### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0x80, // ### + 0x00, 0x03, 0x80, // ### + 0x00, 0x07, 0x80, // #### + 0x00, 0x0F, 0x00, // #### + 0x01, 0xFE, 0x00, // ######## + 0x01, 0xFC, 0x00, // ####### + 0x01, 0xFE, 0x00, // ######## + 0x00, 0x0F, 0x80, // ##### + 0x00, 0x03, 0x80, // ### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x00, 0xE0, // ### + 0xF0, 0x00, 0xE0, // #### ### + 0x70, 0x01, 0xE0, // ### #### + 0x70, 0x01, 0xE0, // ### #### + 0x78, 0x03, 0xC0, // #### #### + 0x3C, 0x03, 0xC0, // #### #### + 0x3E, 0x0F, 0x80, // ##### ##### + 0x1F, 0xFF, 0x00, // ############# + 0x07, 0xFE, 0x00, // ########## + 0x01, 0xF8, 0x00, // ###### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2162 '4' (21 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x07, 0xC0, // ##### + 0x00, 0x0F, 0xC0, // ###### + 0x00, 0x0F, 0xC0, // ###### + 0x00, 0x1F, 0xC0, // ####### + 0x00, 0x1F, 0xC0, // ####### + 0x00, 0x3B, 0xC0, // ### #### + 0x00, 0x7B, 0xC0, // #### #### + 0x00, 0x73, 0xC0, // ### #### + 0x00, 0xE3, 0xC0, // ### #### + 0x01, 0xE3, 0xC0, // #### #### + 0x01, 0xC3, 0xC0, // ### #### + 0x03, 0xC3, 0xC0, // #### #### + 0x03, 0x83, 0xC0, // ### #### + 0x07, 0x03, 0xC0, // ### #### + 0x0F, 0x03, 0xC0, // #### #### + 0x0E, 0x03, 0xC0, // ### #### + 0x1E, 0x03, 0xC0, // #### #### + 0x3C, 0x03, 0xC0, // #### #### + 0x38, 0x03, 0xC0, // ### #### + 0x78, 0x03, 0xC0, // #### #### + 0x70, 0x03, 0xC0, // ### #### + 0xFF, 0xFF, 0xF8, // ##################### + 0xFF, 0xFF, 0xF8, // ##################### + 0xFF, 0xFF, 0xF8, // ##################### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2303 '5' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x3F, 0xFF, 0x80, // ############### + 0x3F, 0xFF, 0x80, // ############### + 0x3F, 0xFF, 0x80, // ############### + 0x38, 0x00, 0x00, // ### + 0x78, 0x00, 0x00, // #### + 0x70, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, // ### + 0x73, 0xF8, 0x00, // ### ####### + 0x7F, 0xFE, 0x00, // ############## + 0xFF, 0xFF, 0x00, // ################ + 0xFC, 0x1F, 0x80, // ###### ###### + 0x70, 0x07, 0xC0, // ### ##### + 0x10, 0x03, 0xC0, // # #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x00, 0xE0, // ### + 0x00, 0x01, 0xE0, // #### + 0x20, 0x01, 0xE0, // # #### + 0x60, 0x03, 0xC0, // ## #### + 0xF0, 0x07, 0xC0, // #### ##### + 0xFC, 0x1F, 0x80, // ###### ###### + 0x3F, 0xFF, 0x00, // ############## + 0x1F, 0xFE, 0x00, // ############ + 0x03, 0xF0, 0x00, // ###### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2444 '6' (22 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x07, 0xC0, // ##### + 0x00, 0x0F, 0x00, // #### + 0x00, 0x0F, 0x00, // #### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x78, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x01, 0xE0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x07, 0xFE, 0x00, // ########## + 0x07, 0xFF, 0x80, // ############ + 0x0F, 0xFF, 0xC0, // ############## + 0x1F, 0x07, 0xE0, // ##### ###### + 0x3C, 0x01, 0xF0, // #### ##### + 0x3C, 0x00, 0xF0, // #### #### + 0x78, 0x00, 0x78, // #### #### + 0x70, 0x00, 0x78, // ### #### + 0x70, 0x00, 0x38, // ### ### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0x70, 0x00, 0x38, // ### ### + 0x78, 0x00, 0x38, // #### ### + 0x78, 0x00, 0x78, // #### #### + 0x3C, 0x00, 0xF0, // #### #### + 0x3E, 0x00, 0xF0, // ##### #### + 0x1F, 0x83, 0xE0, // ###### ##### + 0x0F, 0xFF, 0xC0, // ############## + 0x03, 0xFF, 0x80, // ########### + 0x00, 0xFE, 0x00, // ####### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2585 '7' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xE0, // ################### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xC0, // ### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0x80, // ### + 0x00, 0x07, 0x80, // #### + 0x00, 0x0F, 0x00, // #### + 0x00, 0x0F, 0x00, // #### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x38, 0x00, // ### + 0x00, 0x78, 0x00, // #### + 0x00, 0x70, 0x00, // ### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xE0, 0x00, // ### + 0x01, 0xE0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x07, 0x80, 0x00, // #### + 0x07, 0x80, 0x00, // #### + 0x0F, 0x00, 0x00, // #### + 0x0F, 0x00, 0x00, // #### + 0x1E, 0x00, 0x00, // #### + 0x1C, 0x00, 0x00, // ### + 0x3C, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2726 '8' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xF0, 0x00, // ###### + 0x07, 0xFC, 0x00, // ######### + 0x1F, 0xFE, 0x00, // ############ + 0x1E, 0x0F, 0x00, // #### #### + 0x3C, 0x07, 0x80, // #### #### + 0x38, 0x03, 0x80, // ### ### + 0x38, 0x03, 0x80, // ### ### + 0x38, 0x03, 0x80, // ### ### + 0x38, 0x03, 0x80, // ### ### + 0x38, 0x03, 0x80, // ### ### + 0x3C, 0x07, 0x80, // #### #### + 0x1E, 0x0F, 0x00, // #### #### + 0x0F, 0xFF, 0x00, // ############ + 0x0F, 0xFC, 0x00, // ########## + 0x1F, 0xFE, 0x00, // ############ + 0x3E, 0x0F, 0x00, // ##### #### + 0x78, 0x07, 0x80, // #### #### + 0x78, 0x03, 0xC0, // #### #### + 0xF0, 0x01, 0xC0, // #### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x01, 0xE0, // ### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0x78, 0x03, 0xC0, // #### #### + 0x7C, 0x07, 0xC0, // ##### ##### + 0x3E, 0x0F, 0x80, // ##### ##### + 0x1F, 0xFF, 0x00, // ############# + 0x0F, 0xFE, 0x00, // ########### + 0x03, 0xF8, 0x00, // ####### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @2867 '9' (22 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x01, 0xFC, 0x00, // ####### + 0x07, 0xFF, 0x00, // ########### + 0x0F, 0xFF, 0xC0, // ############## + 0x1F, 0x07, 0xE0, // ##### ###### + 0x3C, 0x01, 0xF0, // #### ##### + 0x38, 0x00, 0xF0, // ### #### + 0x78, 0x00, 0x78, // #### #### + 0x70, 0x00, 0x78, // ### #### + 0x70, 0x00, 0x38, // ### ### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0x70, 0x00, 0x38, // ### ### + 0x78, 0x00, 0x38, // #### ### + 0x78, 0x00, 0x78, // #### #### + 0x3C, 0x00, 0xF0, // #### #### + 0x3E, 0x00, 0xF0, // ##### #### + 0x1F, 0x83, 0xE0, // ###### ##### + 0x0F, 0xFF, 0xC0, // ############## + 0x07, 0xFF, 0x80, // ############ + 0x01, 0xFF, 0x80, // ########## + 0x00, 0x0F, 0x00, // #### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x78, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x01, 0xE0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x0F, 0x80, 0x00, // ##### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @3008 ':' (4 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x60, // ## + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x60, // ## + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @3055 ';' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x60, // ## + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x60, // ## + 0xF0, // #### + 0xF8, // ##### + 0xF8, // ##### + 0x78, // #### + 0x38, // ### + 0x18, // ## + 0x30, // ## + 0x30, // ## + 0x60, // ## + 0xE0, // ### + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @3102 '<' (22 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x0C, // ## + 0x00, 0x00, 0x3C, // #### + 0x00, 0x00, 0xFC, // ###### + 0x00, 0x03, 0xF0, // ###### + 0x00, 0x0F, 0xC0, // ###### + 0x00, 0x3F, 0x80, // ####### + 0x00, 0x7E, 0x00, // ###### + 0x01, 0xF8, 0x00, // ###### + 0x07, 0xE0, 0x00, // ###### + 0x1F, 0x80, 0x00, // ###### + 0x7E, 0x00, 0x00, // ###### + 0xF8, 0x00, 0x00, // ##### + 0xE0, 0x00, 0x00, // ### + 0xF0, 0x00, 0x00, // #### + 0xFC, 0x00, 0x00, // ###### + 0x3F, 0x00, 0x00, // ###### + 0x0F, 0xC0, 0x00, // ###### + 0x07, 0xE0, 0x00, // ###### + 0x01, 0xF8, 0x00, // ###### + 0x00, 0x7E, 0x00, // ###### + 0x00, 0x1F, 0x80, // ###### + 0x00, 0x07, 0xE0, // ###### + 0x00, 0x01, 0xF8, // ###### + 0x00, 0x00, 0x7C, // ##### + 0x00, 0x00, 0x1C, // ### + 0x00, 0x00, 0x04, // # + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @3243 '=' (24 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0xFF, // ######################## + 0xFF, 0xFF, 0xFF, // ######################## + 0xFF, 0xFF, 0xFF, // ######################## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0xFF, // ######################## + 0xFF, 0xFF, 0xFF, // ######################## + 0xFF, 0xFF, 0xFF, // ######################## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @3384 '>' (22 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x80, 0x00, 0x00, // # + 0xE0, 0x00, 0x00, // ### + 0xF8, 0x00, 0x00, // ##### + 0x7E, 0x00, 0x00, // ###### + 0x1F, 0x80, 0x00, // ###### + 0x07, 0xE0, 0x00, // ###### + 0x01, 0xF8, 0x00, // ###### + 0x00, 0x7E, 0x00, // ###### + 0x00, 0x1F, 0x80, // ###### + 0x00, 0x0F, 0xE0, // ####### + 0x00, 0x03, 0xF0, // ###### + 0x00, 0x00, 0xFC, // ###### + 0x00, 0x00, 0x3C, // #### + 0x00, 0x00, 0x3C, // #### + 0x00, 0x00, 0xFC, // ###### + 0x00, 0x03, 0xF0, // ###### + 0x00, 0x0F, 0xC0, // ###### + 0x00, 0x3F, 0x00, // ###### + 0x00, 0xFC, 0x00, // ###### + 0x03, 0xF0, 0x00, // ###### + 0x0F, 0xC0, 0x00, // ###### + 0x3F, 0x00, 0x00, // ###### + 0xFC, 0x00, 0x00, // ###### + 0xF0, 0x00, 0x00, // #### + 0xC0, 0x00, 0x00, // ## + 0x80, 0x00, 0x00, // # + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @3525 '?' (18 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xF0, 0x00, // ###### + 0x0F, 0xFC, 0x00, // ########## + 0x1F, 0xFF, 0x00, // ############# + 0x3E, 0x0F, 0x00, // ##### #### + 0x78, 0x07, 0x80, // #### #### + 0x70, 0x03, 0x80, // ### ### + 0x70, 0x01, 0xC0, // ### ### + 0xF0, 0x01, 0xC0, // #### ### + 0x00, 0x01, 0xC0, // ### + 0x00, 0x01, 0xC0, // ### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0x80, // ### + 0x00, 0x07, 0x80, // #### + 0x00, 0x1F, 0x00, // ##### + 0x00, 0x7E, 0x00, // ###### + 0x00, 0x78, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xE0, 0x00, // ### + 0x00, 0xE0, 0x00, // ### + 0x00, 0xE0, 0x00, // ### + 0x00, 0xE0, 0x00, // ### + 0x00, 0xE0, 0x00, // ### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0xE0, 0x00, // ### + 0x01, 0xE0, 0x00, // #### + 0x01, 0xF0, 0x00, // ##### + 0x01, 0xE0, 0x00, // #### + 0x00, 0xE0, 0x00, // ### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @3666 '@' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0xFC, 0x00, // ###### + 0x03, 0xFF, 0x00, // ########## + 0x0F, 0xFF, 0x80, // ############# + 0x1F, 0x07, 0x80, // ##### #### + 0x3C, 0x01, 0xC0, // #### ### + 0x38, 0x00, 0xC0, // ### ## + 0x70, 0x00, 0xE0, // ### ### + 0x70, 0x3E, 0xE0, // ### ##### ### + 0x60, 0x7F, 0xE0, // ## ########## + 0x60, 0xE1, 0xE0, // ## ### #### + 0xE0, 0xC0, 0xE0, // ### ## ### + 0xE1, 0xC0, 0xE0, // ### ### ### + 0xE1, 0xC0, 0xE0, // ### ### ### + 0x60, 0xC0, 0xE0, // ## ## ### + 0x60, 0xE1, 0xE0, // ## ### #### + 0x70, 0x7F, 0xE0, // ### ########## + 0x70, 0x3E, 0xE0, // ### ##### ### + 0x38, 0x00, 0x00, // ### + 0x1E, 0x00, 0x00, // #### + 0x0F, 0x80, 0x00, // ##### + 0x07, 0xFF, 0xE0, // ############## + 0x03, 0xFF, 0xE0, // ############# + 0x00, 0xFF, 0xE0, // ########### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @3807 'A' (28 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x0F, 0x00, 0x00, // #### + 0x00, 0x1F, 0x00, 0x00, // ##### + 0x00, 0x1F, 0x80, 0x00, // ###### + 0x00, 0x3F, 0x80, 0x00, // ####### + 0x00, 0x3F, 0xC0, 0x00, // ######## + 0x00, 0x3B, 0xC0, 0x00, // ### #### + 0x00, 0x79, 0xC0, 0x00, // #### ### + 0x00, 0x71, 0xE0, 0x00, // ### #### + 0x00, 0xF0, 0xE0, 0x00, // #### ### + 0x00, 0xF0, 0xF0, 0x00, // #### #### + 0x00, 0xE0, 0xF0, 0x00, // ### #### + 0x01, 0xE0, 0x70, 0x00, // #### ### + 0x01, 0xE0, 0x78, 0x00, // #### #### + 0x01, 0xC0, 0x38, 0x00, // ### ### + 0x03, 0xC0, 0x3C, 0x00, // #### #### + 0x03, 0x80, 0x3C, 0x00, // ### #### + 0x07, 0x80, 0x1C, 0x00, // #### ### + 0x07, 0x80, 0x1E, 0x00, // #### #### + 0x07, 0x00, 0x1E, 0x00, // ### #### + 0x0F, 0x00, 0x0E, 0x00, // #### ### + 0x0F, 0x00, 0x0F, 0x00, // #### #### + 0x1F, 0xFF, 0xFF, 0x00, // ##################### + 0x1F, 0xFF, 0xFF, 0x80, // ###################### + 0x1F, 0xFF, 0xFF, 0x80, // ###################### + 0x3C, 0x00, 0x03, 0x80, // #### ### + 0x3C, 0x00, 0x03, 0xC0, // #### #### + 0x38, 0x00, 0x03, 0xC0, // ### #### + 0x78, 0x00, 0x01, 0xE0, // #### #### + 0x78, 0x00, 0x01, 0xE0, // #### #### + 0xF0, 0x00, 0x01, 0xE0, // #### #### + 0xF0, 0x00, 0x00, 0xF0, // #### #### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @3995 'B' (21 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xF8, 0x00, // ############# + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xFF, 0x00, // ################ + 0xF0, 0x0F, 0x80, // #### ##### + 0xF0, 0x07, 0xC0, // #### ##### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x01, 0xC0, // #### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xC0, // #### ### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x07, 0xC0, // #### ##### + 0xF0, 0x0F, 0x80, // #### ##### + 0xFF, 0xFF, 0x00, // ################ + 0xFF, 0xFF, 0x00, // ################ + 0xFF, 0xFF, 0xC0, // ################## + 0xF0, 0x03, 0xE0, // #### ##### + 0xF0, 0x00, 0xF0, // #### #### + 0xF0, 0x00, 0xF0, // #### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0xF0, // #### #### + 0xF0, 0x00, 0xF0, // #### #### + 0xF0, 0x03, 0xF0, // #### ###### + 0xFF, 0xFF, 0xE0, // ################### + 0xFF, 0xFF, 0xC0, // ################## + 0xFF, 0xFF, 0x00, // ################ + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4136 'C' (23 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x1F, 0xE0, // ######## + 0x00, 0xFF, 0xF8, // ############# + 0x03, 0xFF, 0xFE, // ################# + 0x07, 0xE0, 0x3E, // ###### ##### + 0x0F, 0x80, 0x0E, // ##### ### + 0x1F, 0x00, 0x06, // ##### ## + 0x1E, 0x00, 0x02, // #### # + 0x3C, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0x70, 0x00, 0x00, // ### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xE0, 0x00, 0x00, // ### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0x70, 0x00, 0x00, // ### + 0x78, 0x00, 0x00, // #### + 0x38, 0x00, 0x00, // ### + 0x3C, 0x00, 0x00, // #### + 0x1E, 0x00, 0x02, // #### # + 0x1F, 0x00, 0x06, // ##### ## + 0x0F, 0x80, 0x0E, // ##### ### + 0x07, 0xE0, 0x3E, // ###### ##### + 0x03, 0xFF, 0xFE, // ################# + 0x00, 0xFF, 0xF8, // ############# + 0x00, 0x1F, 0xE0, // ######## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4277 'D' (23 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xF0, 0x00, // ############ + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xFF, 0x80, // ################# + 0xF0, 0x0F, 0xC0, // #### ###### + 0xF0, 0x03, 0xE0, // #### ##### + 0xF0, 0x01, 0xF0, // #### ##### + 0xF0, 0x00, 0xF8, // #### ##### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x3C, // #### #### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0xF8, // #### ##### + 0xF0, 0x01, 0xF0, // #### ##### + 0xF0, 0x03, 0xE0, // #### ##### + 0xF0, 0x0F, 0xC0, // #### ###### + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xF0, 0x00, // ############ + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4418 'E' (17 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xFE, 0x00, // ############### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4559 'F' (17 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xFE, 0x00, // ############### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4700 'G' (24 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x1F, 0xE0, // ######## + 0x00, 0xFF, 0xFC, // ############## + 0x03, 0xFF, 0xFF, // ################## + 0x07, 0xE0, 0x3F, // ###### ###### + 0x0F, 0x80, 0x07, // ##### ### + 0x1F, 0x00, 0x03, // ##### ## + 0x3E, 0x00, 0x01, // ##### # + 0x3C, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0x70, 0x00, 0x00, // ### + 0x70, 0x00, 0x00, // ### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x07, 0xFF, // ### ########### + 0xE0, 0x07, 0xFF, // ### ########### + 0xE0, 0x07, 0xFF, // ### ########### + 0xE0, 0x00, 0x0F, // ### #### + 0xF0, 0x00, 0x0F, // #### #### + 0xF0, 0x00, 0x0F, // #### #### + 0x70, 0x00, 0x0F, // ### #### + 0x70, 0x00, 0x0F, // ### #### + 0x78, 0x00, 0x0F, // #### #### + 0x3C, 0x00, 0x0F, // #### #### + 0x3E, 0x00, 0x0F, // ##### #### + 0x1F, 0x00, 0x0F, // ##### #### + 0x0F, 0x80, 0x0F, // ##### #### + 0x07, 0xF0, 0x3F, // ####### ###### + 0x03, 0xFF, 0xFF, // ################## + 0x00, 0xFF, 0xFC, // ############## + 0x00, 0x1F, 0xE0, // ######## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4841 'H' (23 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x0E, // #### ### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @4982 'I' (4 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @5029 'J' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0xC0, // #### + 0x03, 0x80, // ### + 0x07, 0x80, // #### + 0xFF, 0x00, // ######## + 0xFE, 0x00, // ####### + 0xFC, 0x00, // ###### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @5123 'K' (21 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x01, 0xF8, // #### ###### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x07, 0x80, // #### #### + 0xF0, 0x0F, 0x00, // #### #### + 0xF0, 0x1E, 0x00, // #### #### + 0xF0, 0x3E, 0x00, // #### ##### + 0xF0, 0x7C, 0x00, // #### ##### + 0xF0, 0xF8, 0x00, // #### ##### + 0xF1, 0xF0, 0x00, // #### ##### + 0xF3, 0xE0, 0x00, // #### ##### + 0xF7, 0xC0, 0x00, // #### ##### + 0xFF, 0x80, 0x00, // ######### + 0xFF, 0x00, 0x00, // ######## + 0xFF, 0x00, 0x00, // ######## + 0xFF, 0x80, 0x00, // ######### + 0xF7, 0xC0, 0x00, // #### ##### + 0xF3, 0xE0, 0x00, // #### ##### + 0xF1, 0xF0, 0x00, // #### ##### + 0xF0, 0xF8, 0x00, // #### ##### + 0xF0, 0x7C, 0x00, // #### ##### + 0xF0, 0x3E, 0x00, // #### ##### + 0xF0, 0x1F, 0x00, // #### ##### + 0xF0, 0x0F, 0x80, // #### ##### + 0xF0, 0x07, 0xC0, // #### ##### + 0xF0, 0x03, 0xE0, // #### ##### + 0xF0, 0x01, 0xF0, // #### ##### + 0xF0, 0x00, 0xF8, // #### ##### + 0xF0, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x18, // #### ## + 0x00, 0x00, 0x08, // # + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @5264 'L' (15 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xFF, 0xFE, // ############### + 0xFF, 0xFE, // ############### + 0xFF, 0xFE, // ############### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @5358 'M' (30 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x00, 0x3C, // #### #### + 0xF8, 0x00, 0x00, 0x7C, // ##### ##### + 0xF8, 0x00, 0x00, 0x7C, // ##### ##### + 0xFC, 0x00, 0x00, 0xFC, // ###### ###### + 0xFE, 0x00, 0x01, 0xFC, // ####### ####### + 0xFE, 0x00, 0x01, 0xFC, // ####### ####### + 0xFF, 0x00, 0x03, 0xDC, // ######## #### ### + 0xF7, 0x80, 0x03, 0x9C, // #### #### ### ### + 0xF7, 0x80, 0x07, 0x9C, // #### #### #### ### + 0xF3, 0xC0, 0x0F, 0x1C, // #### #### #### ### + 0xF1, 0xE0, 0x0E, 0x1C, // #### #### ### ### + 0xF1, 0xE0, 0x1E, 0x1C, // #### #### #### ### + 0xF0, 0xF0, 0x3C, 0x1C, // #### #### #### ### + 0xF0, 0x78, 0x3C, 0x1C, // #### #### #### ### + 0xF0, 0x78, 0x78, 0x1C, // #### #### #### ### + 0xF0, 0x3C, 0xF0, 0x1C, // #### #### #### ### + 0xF0, 0x1E, 0xF0, 0x1C, // #### #### #### ### + 0xF0, 0x1F, 0xE0, 0x1C, // #### ######## ### + 0xF0, 0x0F, 0xC0, 0x1C, // #### ###### ### + 0xF0, 0x07, 0xC0, 0x1C, // #### ##### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x03, 0x00, 0x1C, // #### ## ### + 0xF0, 0x03, 0x00, 0x1C, // #### ## ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0xF0, 0x00, 0x00, 0x1C, // #### ### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @5546 'N' (25 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x03, 0x80, // #### ### + 0xF8, 0x00, 0x03, 0x80, // ##### ### + 0xF8, 0x00, 0x03, 0x80, // ##### ### + 0xFC, 0x00, 0x03, 0x80, // ###### ### + 0xFE, 0x00, 0x03, 0x80, // ####### ### + 0xFE, 0x00, 0x03, 0x80, // ####### ### + 0xFF, 0x00, 0x03, 0x80, // ######## ### + 0xF7, 0x80, 0x03, 0x80, // #### #### ### + 0xF7, 0xC0, 0x03, 0x80, // #### ##### ### + 0xF3, 0xC0, 0x03, 0x80, // #### #### ### + 0xF1, 0xE0, 0x03, 0x80, // #### #### ### + 0xF1, 0xF0, 0x03, 0x80, // #### ##### ### + 0xF0, 0xF8, 0x03, 0x80, // #### ##### ### + 0xF0, 0x78, 0x03, 0x80, // #### #### ### + 0xF0, 0x3C, 0x03, 0x80, // #### #### ### + 0xF0, 0x3E, 0x03, 0x80, // #### ##### ### + 0xF0, 0x1E, 0x03, 0x80, // #### #### ### + 0xF0, 0x0F, 0x03, 0x80, // #### #### ### + 0xF0, 0x07, 0x83, 0x80, // #### #### ### + 0xF0, 0x07, 0xC3, 0x80, // #### ##### ### + 0xF0, 0x03, 0xC3, 0x80, // #### #### ### + 0xF0, 0x01, 0xE3, 0x80, // #### #### ### + 0xF0, 0x01, 0xF3, 0x80, // #### ##### ### + 0xF0, 0x00, 0xF3, 0x80, // #### #### ### + 0xF0, 0x00, 0x7B, 0x80, // #### #### ### + 0xF0, 0x00, 0x3F, 0x80, // #### ####### + 0xF0, 0x00, 0x3F, 0x80, // #### ####### + 0xF0, 0x00, 0x1F, 0x80, // #### ###### + 0xF0, 0x00, 0x0F, 0x80, // #### ##### + 0xF0, 0x00, 0x07, 0x80, // #### #### + 0xF0, 0x00, 0x07, 0x80, // #### #### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @5734 'O' (29 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x1F, 0xE0, 0x00, // ######## + 0x00, 0xFF, 0xF8, 0x00, // ############# + 0x03, 0xFF, 0xFE, 0x00, // ################# + 0x07, 0xE0, 0x3F, 0x00, // ###### ###### + 0x0F, 0x80, 0x0F, 0x80, // ##### ##### + 0x1F, 0x00, 0x03, 0xC0, // ##### #### + 0x1E, 0x00, 0x01, 0xE0, // #### #### + 0x3C, 0x00, 0x01, 0xE0, // #### #### + 0x78, 0x00, 0x00, 0xF0, // #### #### + 0x78, 0x00, 0x00, 0x70, // #### ### + 0x70, 0x00, 0x00, 0x78, // ### #### + 0xF0, 0x00, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xE0, 0x00, 0x00, 0x38, // ### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x78, // #### #### + 0x70, 0x00, 0x00, 0x78, // ### #### + 0x78, 0x00, 0x00, 0x70, // #### ### + 0x38, 0x00, 0x00, 0xF0, // ### #### + 0x3C, 0x00, 0x01, 0xE0, // #### #### + 0x1E, 0x00, 0x01, 0xE0, // #### #### + 0x1F, 0x00, 0x03, 0xC0, // ##### #### + 0x0F, 0x80, 0x0F, 0x80, // ##### ##### + 0x07, 0xE0, 0x3F, 0x00, // ###### ###### + 0x03, 0xFF, 0xFE, 0x00, // ################# + 0x00, 0xFF, 0xF8, 0x00, // ############# + 0x00, 0x1F, 0xE0, 0x00, // ######## + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @5922 'P' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFC, 0x00, // ############## + 0xFF, 0xFF, 0x00, // ################ + 0xFF, 0xFF, 0x80, // ################# + 0xF0, 0x07, 0xC0, // #### ##### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x03, 0xE0, // #### ##### + 0xF0, 0x07, 0xC0, // #### ##### + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x00, // ################ + 0xFF, 0xFC, 0x00, // ############## + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @6063 'Q' (30 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x1F, 0xE0, 0x00, // ######## + 0x00, 0xFF, 0xF8, 0x00, // ############# + 0x03, 0xFF, 0xFE, 0x00, // ################# + 0x07, 0xE0, 0x3F, 0x00, // ###### ###### + 0x0F, 0x80, 0x0F, 0x80, // ##### ##### + 0x1F, 0x00, 0x03, 0xC0, // ##### #### + 0x1E, 0x00, 0x01, 0xE0, // #### #### + 0x3C, 0x00, 0x01, 0xE0, // #### #### + 0x78, 0x00, 0x00, 0xF0, // #### #### + 0x78, 0x00, 0x00, 0x70, // #### ### + 0x70, 0x00, 0x00, 0x78, // ### #### + 0xF0, 0x00, 0x00, 0x78, // #### #### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xE0, 0x00, 0x00, 0x38, // ### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x00, 0x38, // #### ### + 0xF0, 0x00, 0x10, 0x38, // #### # ### + 0xF0, 0x00, 0x30, 0x78, // #### ## #### + 0x70, 0x00, 0x78, 0x78, // ### #### #### + 0x78, 0x00, 0x3C, 0x70, // #### #### ### + 0x38, 0x00, 0x1E, 0xF0, // ### #### #### + 0x3C, 0x00, 0x0F, 0xF0, // #### ######## + 0x1E, 0x00, 0x0F, 0xE0, // #### ####### + 0x1F, 0x00, 0x07, 0xE0, // ##### ###### + 0x0F, 0x80, 0x07, 0xE0, // ##### ###### + 0x07, 0xE0, 0x3F, 0xF0, // ###### ########## + 0x03, 0xFF, 0xFE, 0xFC, // ################# ###### + 0x00, 0xFF, 0xFC, 0x7C, // ############## ##### + 0x00, 0x1F, 0xE0, 0x1C, // ######## ### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @6251 'R' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFC, 0x00, // ############## + 0xFF, 0xFF, 0x00, // ################ + 0xFF, 0xFF, 0x80, // ################# + 0xF0, 0x07, 0xC0, // #### ##### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x00, 0xE0, // #### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x03, 0xE0, // #### ##### + 0xF0, 0x07, 0xC0, // #### ##### + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x00, // ################ + 0xFF, 0xFC, 0x00, // ############## + 0xF0, 0x78, 0x00, // #### #### + 0xF0, 0x38, 0x00, // #### ### + 0xF0, 0x3C, 0x00, // #### #### + 0xF0, 0x1E, 0x00, // #### #### + 0xF0, 0x1E, 0x00, // #### #### + 0xF0, 0x0F, 0x00, // #### #### + 0xF0, 0x0F, 0x00, // #### #### + 0xF0, 0x07, 0x80, // #### #### + 0xF0, 0x07, 0x80, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x00, 0xF0, // #### #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @6392 'S' (21 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x01, 0xFE, 0x00, // ######## + 0x07, 0xFF, 0xC0, // ############# + 0x0F, 0xFF, 0xE0, // ############### + 0x1F, 0x03, 0xF0, // ##### ###### + 0x3C, 0x00, 0xF8, // #### ##### + 0x3C, 0x00, 0x30, // #### ## + 0x38, 0x00, 0x20, // ### # + 0x38, 0x00, 0x00, // ### + 0x38, 0x00, 0x00, // ### + 0x3C, 0x00, 0x00, // #### + 0x3E, 0x00, 0x00, // ##### + 0x1F, 0x00, 0x00, // ##### + 0x1F, 0xC0, 0x00, // ####### + 0x0F, 0xF8, 0x00, // ######### + 0x03, 0xFE, 0x00, // ######### + 0x00, 0xFF, 0x80, // ######### + 0x00, 0x1F, 0xC0, // ####### + 0x00, 0x07, 0xF0, // ####### + 0x00, 0x01, 0xF0, // ##### + 0x00, 0x00, 0xF8, // ##### + 0x00, 0x00, 0x78, // #### + 0x00, 0x00, 0x78, // #### + 0x00, 0x00, 0x78, // #### + 0x20, 0x00, 0x38, // # ### + 0x60, 0x00, 0x78, // ## #### + 0xF0, 0x00, 0x78, // #### #### + 0xFC, 0x00, 0xF0, // ###### #### + 0x7F, 0x03, 0xF0, // ####### ###### + 0x1F, 0xFF, 0xE0, // ################ + 0x0F, 0xFF, 0x80, // ############# + 0x01, 0xFE, 0x00, // ######## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @6533 'T' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xF0, // #################### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @6674 'U' (23 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0x78, 0x00, 0x1E, // #### #### + 0x78, 0x00, 0x3C, // #### #### + 0x3C, 0x00, 0x7C, // #### ##### + 0x3E, 0x00, 0xF8, // ##### ##### + 0x1F, 0x83, 0xF0, // ###### ###### + 0x0F, 0xFF, 0xE0, // ############### + 0x03, 0xFF, 0xC0, // ############ + 0x00, 0xFE, 0x00, // ####### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @6815 'V' (28 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0xF8, 0x00, 0x00, 0xF0, // ##### #### + 0x78, 0x00, 0x00, 0xF0, // #### #### + 0x78, 0x00, 0x01, 0xE0, // #### #### + 0x3C, 0x00, 0x01, 0xE0, // #### #### + 0x3C, 0x00, 0x01, 0xE0, // #### #### + 0x3C, 0x00, 0x03, 0xC0, // #### #### + 0x1E, 0x00, 0x03, 0xC0, // #### #### + 0x1E, 0x00, 0x03, 0xC0, // #### #### + 0x0F, 0x00, 0x07, 0x80, // #### #### + 0x0F, 0x00, 0x07, 0x80, // #### #### + 0x0F, 0x00, 0x0F, 0x00, // #### #### + 0x07, 0x80, 0x0F, 0x00, // #### #### + 0x07, 0x80, 0x0F, 0x00, // #### #### + 0x07, 0x80, 0x1E, 0x00, // #### #### + 0x03, 0xC0, 0x1E, 0x00, // #### #### + 0x03, 0xC0, 0x1C, 0x00, // #### ### + 0x01, 0xE0, 0x3C, 0x00, // #### #### + 0x01, 0xE0, 0x3C, 0x00, // #### #### + 0x01, 0xE0, 0x78, 0x00, // #### #### + 0x00, 0xF0, 0x78, 0x00, // #### #### + 0x00, 0xF0, 0x70, 0x00, // #### ### + 0x00, 0x70, 0xF0, 0x00, // ### #### + 0x00, 0x78, 0xF0, 0x00, // #### #### + 0x00, 0x78, 0xE0, 0x00, // #### ### + 0x00, 0x3D, 0xE0, 0x00, // #### #### + 0x00, 0x3D, 0xE0, 0x00, // #### #### + 0x00, 0x1F, 0xC0, 0x00, // ####### + 0x00, 0x1F, 0xC0, 0x00, // ####### + 0x00, 0x1F, 0x80, 0x00, // ###### + 0x00, 0x0F, 0x80, 0x00, // ##### + 0x00, 0x0F, 0x80, 0x00, // ##### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @7003 'W' (44 pixels wide) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0xF0, 0x03, 0xC0, 0x00, 0x00, 0xF0, // #### #### #### + 0xF0, 0x01, 0xE0, 0x00, 0x01, 0xE0, // #### #### #### + 0x78, 0x01, 0xE0, 0x00, 0x01, 0xE0, // #### #### #### + 0x78, 0x00, 0xF0, 0x00, 0x03, 0xC0, // #### #### #### + 0x78, 0x00, 0xF0, 0x00, 0x03, 0xC0, // #### #### #### + 0x3C, 0x00, 0x70, 0x00, 0x03, 0x80, // #### ### ### + 0x3C, 0x00, 0x78, 0x00, 0x07, 0x80, // #### #### #### + 0x1E, 0x00, 0x78, 0x00, 0x07, 0x80, // #### #### #### + 0x1E, 0x00, 0x3C, 0x00, 0x0F, 0x00, // #### #### #### + 0x1E, 0x00, 0x3C, 0x00, 0x0F, 0x00, // #### #### #### + 0x0F, 0x00, 0x1C, 0x00, 0x0E, 0x00, // #### ### ### + 0x0F, 0x00, 0x1E, 0x00, 0x1E, 0x00, // #### #### #### + 0x07, 0x80, 0x0E, 0x00, 0x1E, 0x00, // #### ### #### + 0x07, 0x80, 0x0F, 0x00, 0x3C, 0x00, // #### #### #### + 0x03, 0x80, 0x1F, 0x00, 0x3C, 0x00, // ### ##### #### + 0x03, 0xC0, 0x1F, 0x00, 0x78, 0x00, // #### ##### #### + 0x03, 0xC0, 0x1F, 0x80, 0x78, 0x00, // #### ###### #### + 0x01, 0xE0, 0x3F, 0x80, 0x78, 0x00, // #### ####### #### + 0x01, 0xE0, 0x3B, 0xC0, 0xF0, 0x00, // #### ### #### #### + 0x00, 0xF0, 0x7B, 0xC0, 0xF0, 0x00, // #### #### #### #### + 0x00, 0xF0, 0x79, 0xC1, 0xE0, 0x00, // #### #### ### #### + 0x00, 0xF0, 0xF1, 0xE1, 0xE0, 0x00, // #### #### #### #### + 0x00, 0x78, 0xF0, 0xE1, 0xE0, 0x00, // #### #### ### #### + 0x00, 0x78, 0xE0, 0xF3, 0xC0, 0x00, // #### ### #### #### + 0x00, 0x3D, 0xE0, 0xF3, 0xC0, 0x00, // #### #### #### #### + 0x00, 0x3D, 0xE0, 0x7F, 0x80, 0x00, // #### #### ######## + 0x00, 0x3F, 0xC0, 0x7F, 0x80, 0x00, // ######## ######## + 0x00, 0x1F, 0xC0, 0x3F, 0x80, 0x00, // ####### ####### + 0x00, 0x1F, 0x80, 0x3F, 0x00, 0x00, // ###### ###### + 0x00, 0x0F, 0x80, 0x1F, 0x00, 0x00, // ##### ##### + 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x00, // #### #### + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + + // @7285 'X' (24 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF8, 0x00, 0x1F, // ##### ##### + 0x78, 0x00, 0x1E, // #### #### + 0x3C, 0x00, 0x3C, // #### #### + 0x3C, 0x00, 0x7C, // #### ##### + 0x1E, 0x00, 0x78, // #### #### + 0x0F, 0x00, 0xF0, // #### #### + 0x0F, 0x00, 0xF0, // #### #### + 0x07, 0x81, 0xE0, // #### #### + 0x03, 0xC3, 0xC0, // #### #### + 0x03, 0xC3, 0xC0, // #### #### + 0x01, 0xE7, 0x80, // #### #### + 0x01, 0xEF, 0x00, // #### #### + 0x00, 0xFF, 0x00, // ######## + 0x00, 0x7E, 0x00, // ###### + 0x00, 0x7C, 0x00, // ##### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x7E, 0x00, // ###### + 0x00, 0x7E, 0x00, // ###### + 0x00, 0xFF, 0x00, // ######## + 0x01, 0xE7, 0x80, // #### #### + 0x01, 0xE7, 0x80, // #### #### + 0x03, 0xC3, 0xC0, // #### #### + 0x07, 0x81, 0xE0, // #### #### + 0x07, 0x81, 0xE0, // #### #### + 0x0F, 0x00, 0xF0, // #### #### + 0x1E, 0x00, 0xF8, // #### ##### + 0x1E, 0x00, 0x78, // #### #### + 0x3C, 0x00, 0x3C, // #### #### + 0x7C, 0x00, 0x3E, // ##### ##### + 0x78, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x0F, // #### #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @7426 'Y' (24 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x0F, // #### #### + 0x78, 0x00, 0x1E, // #### #### + 0x78, 0x00, 0x1E, // #### #### + 0x3C, 0x00, 0x3C, // #### #### + 0x1E, 0x00, 0x78, // #### #### + 0x1E, 0x00, 0x78, // #### #### + 0x0F, 0x00, 0xF0, // #### #### + 0x07, 0x80, 0xF0, // #### #### + 0x07, 0x81, 0xE0, // #### #### + 0x03, 0xC3, 0xC0, // #### #### + 0x03, 0xC3, 0xC0, // #### #### + 0x01, 0xE7, 0x80, // #### #### + 0x00, 0xF7, 0x00, // #### ### + 0x00, 0xFF, 0x00, // ######## + 0x00, 0x7E, 0x00, // ###### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @7567 'Z' (23 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0xFC, // ###################### + 0xFF, 0xFF, 0xFC, // ###################### + 0xFF, 0xFF, 0xFC, // ###################### + 0x00, 0x00, 0x78, // #### + 0x00, 0x00, 0xF0, // #### + 0x00, 0x01, 0xF0, // ##### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x07, 0xC0, // ##### + 0x00, 0x07, 0x80, // #### + 0x00, 0x0F, 0x00, // #### + 0x00, 0x1F, 0x00, // ##### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x3C, 0x00, // #### + 0x00, 0x7C, 0x00, // ##### + 0x00, 0x78, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x01, 0xE0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x03, 0xC0, 0x00, // #### + 0x07, 0x80, 0x00, // #### + 0x0F, 0x00, 0x00, // #### + 0x0F, 0x00, 0x00, // #### + 0x1E, 0x00, 0x00, // #### + 0x3C, 0x00, 0x00, // #### + 0x3C, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @7708 '[' (8 pixels wide) + 0x00, // + 0xFF, // ######## + 0xFF, // ######## + 0xFF, // ######## + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xE0, // ### + 0xFF, // ######## + + // @7755 '\' (25 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x00, 0x00, // #### + 0x70, 0x00, 0x00, 0x00, // ### + 0x38, 0x00, 0x00, 0x00, // ### + 0x3C, 0x00, 0x00, 0x00, // #### + 0x1C, 0x00, 0x00, 0x00, // ### + 0x1E, 0x00, 0x00, 0x00, // #### + 0x0E, 0x00, 0x00, 0x00, // ### + 0x0F, 0x00, 0x00, 0x00, // #### + 0x07, 0x00, 0x00, 0x00, // ### + 0x07, 0x80, 0x00, 0x00, // #### + 0x03, 0x80, 0x00, 0x00, // ### + 0x03, 0xC0, 0x00, 0x00, // #### + 0x01, 0xC0, 0x00, 0x00, // ### + 0x01, 0xE0, 0x00, 0x00, // #### + 0x00, 0xE0, 0x00, 0x00, // ### + 0x00, 0xF0, 0x00, 0x00, // #### + 0x00, 0x70, 0x00, 0x00, // ### + 0x00, 0x78, 0x00, 0x00, // #### + 0x00, 0x38, 0x00, 0x00, // ### + 0x00, 0x3C, 0x00, 0x00, // #### + 0x00, 0x1C, 0x00, 0x00, // ### + 0x00, 0x1E, 0x00, 0x00, // #### + 0x00, 0x0E, 0x00, 0x00, // ### + 0x00, 0x0F, 0x00, 0x00, // #### + 0x00, 0x07, 0x00, 0x00, // ### + 0x00, 0x07, 0x80, 0x00, // #### + 0x00, 0x03, 0x80, 0x00, // ### + 0x00, 0x03, 0xC0, 0x00, // #### + 0x00, 0x01, 0xC0, 0x00, // ### + 0x00, 0x00, 0xE0, 0x00, // ### + 0x00, 0x00, 0xE0, 0x00, // ### + 0x00, 0x00, 0x70, 0x00, // ### + 0x00, 0x00, 0x70, 0x00, // ### + 0x00, 0x00, 0x38, 0x00, // ### + 0x00, 0x00, 0x38, 0x00, // ### + 0x00, 0x00, 0x1C, 0x00, // ### + 0x00, 0x00, 0x1C, 0x00, // ### + 0x00, 0x00, 0x0E, 0x00, // ### + 0x00, 0x00, 0x0F, 0x00, // #### + 0x00, 0x00, 0x07, 0x00, // ### + 0x00, 0x00, 0x07, 0x80, // #### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @7943 ']' (8 pixels wide) + 0x00, // + 0xFF, // ######## + 0xFF, // ######## + 0xFF, // ######## + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0x07, // ### + 0xFF, // ######## + + // @7990 '^' (26 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x1E, 0x00, 0x00, // #### + 0x00, 0x1E, 0x00, 0x00, // #### + 0x00, 0x3F, 0x00, 0x00, // ###### + 0x00, 0x3F, 0x00, 0x00, // ###### + 0x00, 0x77, 0x80, 0x00, // ### #### + 0x00, 0x73, 0x80, 0x00, // ### ### + 0x00, 0xE3, 0xC0, 0x00, // ### #### + 0x00, 0xE1, 0xC0, 0x00, // ### ### + 0x01, 0xC1, 0xE0, 0x00, // ### #### + 0x01, 0xC0, 0xE0, 0x00, // ### ### + 0x03, 0x80, 0xF0, 0x00, // ### #### + 0x03, 0x80, 0x70, 0x00, // ### ### + 0x07, 0x00, 0x70, 0x00, // ### ### + 0x07, 0x00, 0x38, 0x00, // ### ### + 0x0E, 0x00, 0x38, 0x00, // ### ### + 0x0E, 0x00, 0x1C, 0x00, // ### ### + 0x1C, 0x00, 0x1C, 0x00, // ### ### + 0x1C, 0x00, 0x0E, 0x00, // ### ### + 0x38, 0x00, 0x0E, 0x00, // ### ### + 0x38, 0x00, 0x07, 0x00, // ### ### + 0x70, 0x00, 0x07, 0x00, // ### ### + 0x70, 0x00, 0x03, 0x80, // ### ### + 0xE0, 0x00, 0x03, 0xC0, // ### #### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @8178 '_' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0xF0, // #################### + 0xFF, 0xFF, 0xF0, // #################### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @8319 '`' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xF0, // #### + 0x70, // ### + 0x38, // ### + 0x3C, // #### + 0x1C, // ### + 0x0E, // ### + 0x0E, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @8366 'a' (17 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x07, 0xF0, 0x00, // ####### + 0x1F, 0xFC, 0x00, // ########### + 0x7F, 0xFE, 0x00, // ############## + 0xFC, 0x1F, 0x00, // ###### ##### + 0x70, 0x0F, 0x00, // ### #### + 0x20, 0x07, 0x00, // # ### + 0x00, 0x07, 0x80, // #### + 0x00, 0x07, 0x80, // #### + 0x00, 0x07, 0x80, // #### + 0x0F, 0xC7, 0x80, // ###### #### + 0x3F, 0xFF, 0x80, // ############### + 0x7F, 0xFF, 0x80, // ################ + 0xF8, 0x07, 0x80, // ##### #### + 0xF0, 0x07, 0x80, // #### #### + 0xE0, 0x07, 0x80, // ### #### + 0xE0, 0x07, 0x80, // ### #### + 0xF0, 0x1F, 0x80, // #### ###### + 0xF8, 0x7F, 0x80, // ##### ######## + 0x7F, 0xFF, 0x80, // ################ + 0x3F, 0xE7, 0x80, // ######### #### + 0x1F, 0x87, 0x80, // ###### #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @8507 'b' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE1, 0xF8, 0x00, // ### ###### + 0xE7, 0xFE, 0x00, // ### ########## + 0xEF, 0xFF, 0x00, // ### ############ + 0xFE, 0x0F, 0x80, // ####### ##### + 0xFC, 0x07, 0xC0, // ###### ##### + 0xF8, 0x03, 0xC0, // ##### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF8, 0x03, 0xC0, // ##### #### + 0xFC, 0x07, 0xC0, // ###### ##### + 0xFE, 0x0F, 0x80, // ####### ##### + 0xEF, 0xFF, 0x00, // ### ############ + 0xE7, 0xFE, 0x00, // ### ########## + 0xE1, 0xF8, 0x00, // ### ###### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @8648 'c' (14 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x03, 0xF0, // ###### + 0x0F, 0xFC, // ########## + 0x1F, 0xFC, // ########### + 0x3E, 0x0C, // ##### ## + 0x78, 0x04, // #### # + 0x70, 0x00, // ### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xE0, 0x00, // ### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0x70, 0x00, // ### + 0x78, 0x04, // #### # + 0x3E, 0x0C, // ##### ## + 0x1F, 0xFC, // ########### + 0x0F, 0xFC, // ########## + 0x03, 0xF0, // ###### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @8742 'd' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x03, 0xF1, 0xE0, // ###### #### + 0x0F, 0xFD, 0xE0, // ########## #### + 0x1F, 0xFF, 0xE0, // ################ + 0x3E, 0x0F, 0xE0, // ##### ####### + 0x78, 0x07, 0xE0, // #### ###### + 0x78, 0x03, 0xE0, // #### ##### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0x70, 0x03, 0xE0, // ### ##### + 0x78, 0x07, 0xE0, // #### ###### + 0x3E, 0x0F, 0xE0, // ##### ####### + 0x1F, 0xFE, 0xE0, // ############ ### + 0x0F, 0xFC, 0xE0, // ########## ### + 0x03, 0xF0, 0xE0, // ###### ### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @8883 'e' (18 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xF0, 0x00, // ###### + 0x0F, 0xFC, 0x00, // ########## + 0x1F, 0xFE, 0x00, // ############ + 0x3E, 0x0F, 0x00, // ##### #### + 0x78, 0x07, 0x80, // #### #### + 0x70, 0x03, 0x80, // ### ### + 0xF0, 0x03, 0xC0, // #### #### + 0xE0, 0x01, 0xC0, // ### ### + 0xE0, 0x01, 0xC0, // ### ### + 0xFF, 0xFF, 0xC0, // ################## + 0xFF, 0xFF, 0xC0, // ################## + 0xFF, 0xFF, 0xC0, // ################## + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xF0, 0x00, 0x00, // #### + 0x70, 0x03, 0x00, // ### ## + 0x78, 0x07, 0x80, // #### #### + 0x3E, 0x0F, 0x80, // ##### ##### + 0x1F, 0xFF, 0x00, // ############# + 0x0F, 0xFE, 0x00, // ########### + 0x03, 0xF0, 0x00, // ###### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @9024 'f' (14 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x01, 0xF0, // ##### + 0x07, 0xF8, // ######## + 0x0F, 0xFC, // ########## + 0x1F, 0x10, // ##### # + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0xFF, 0xF0, // ############ + 0xFF, 0xF0, // ############ + 0xFF, 0xF0, // ############ + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x1E, 0x00, // #### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @9118 'g' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xF0, 0xE0, // ###### ### + 0x0F, 0xFC, 0xE0, // ########## ### + 0x1F, 0xFE, 0xE0, // ############ ### + 0x3E, 0x0F, 0xE0, // ##### ####### + 0x78, 0x07, 0xE0, // #### ###### + 0x78, 0x03, 0xE0, // #### ##### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0x78, 0x03, 0xE0, // #### ##### + 0x78, 0x07, 0xE0, // #### ###### + 0x3E, 0x0F, 0xE0, // ##### ####### + 0x1F, 0xFF, 0xE0, // ################ + 0x0F, 0xFD, 0xE0, // ########## #### + 0x03, 0xF1, 0xE0, // ###### #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xC0, // ### + 0x10, 0x03, 0xC0, // # #### + 0x18, 0x07, 0x80, // ## #### + 0x1E, 0x0F, 0x80, // #### ##### + 0x1F, 0xFF, 0x00, // ############# + 0x0F, 0xFE, 0x00, // ########### + 0x03, 0xF8, 0x00, // ####### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @9259 'h' (18 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF1, 0xF8, 0x00, // #### ###### + 0xF7, 0xFE, 0x00, // #### ########## + 0xFF, 0xFF, 0x00, // ################ + 0xFE, 0x1F, 0x00, // ####### ##### + 0xF8, 0x07, 0x80, // ##### #### + 0xF0, 0x07, 0x80, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @9400 'i' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0xF8, // ##### + 0xF8, // ##### + 0xF8, // ##### + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @9447 'j' (9 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x03, 0x00, // ## + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x03, 0x00, // ## + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x07, 0x80, // #### + 0x8F, 0x00, // # #### + 0xFF, 0x00, // ######## + 0xFE, 0x00, // ####### + 0xF8, 0x00, // ##### + 0x00, 0x00, // + 0x00, 0x00, // + + // @9541 'k' (17 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x1F, 0x00, // #### ##### + 0xF0, 0x3E, 0x00, // #### ##### + 0xF0, 0x7C, 0x00, // #### ##### + 0xF0, 0xF8, 0x00, // #### ##### + 0xF1, 0xF0, 0x00, // #### ##### + 0xF3, 0xE0, 0x00, // #### ##### + 0xF7, 0xC0, 0x00, // #### ##### + 0xFF, 0x80, 0x00, // ######### + 0xFF, 0x00, 0x00, // ######## + 0xFE, 0x00, 0x00, // ####### + 0xFF, 0x00, 0x00, // ######## + 0xFF, 0x80, 0x00, // ######### + 0xF3, 0xC0, 0x00, // #### #### + 0xF1, 0xE0, 0x00, // #### #### + 0xF0, 0xF0, 0x00, // #### #### + 0xF0, 0x7C, 0x00, // #### ##### + 0xF0, 0x3E, 0x00, // #### ##### + 0xF0, 0x1F, 0x00, // #### ##### + 0xF0, 0x0F, 0x80, // #### ##### + 0xF0, 0x07, 0x80, // #### #### + 0xF0, 0x03, 0x80, // #### ### + 0x00, 0x01, 0x80, // ## + 0x00, 0x00, 0x80, // # + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @9682 'l' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0x78, 0x80, // #### # + 0x7F, 0xC0, // ######### + 0x3F, 0xC0, // ######## + 0x0F, 0x80, // ##### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @9776 'm' (30 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0xE1, 0xF0, 0x0F, 0xC0, // ### ##### ###### + 0xE7, 0xFC, 0x3F, 0xE0, // ### ######### ######### + 0xEF, 0xFE, 0x7F, 0xF0, // ### ########### ########### + 0xFC, 0x1F, 0xF0, 0xF8, // ###### ######### ##### + 0xF8, 0x0F, 0xC0, 0x7C, // ##### ###### ##### + 0xF0, 0x07, 0xC0, 0x3C, // #### ##### #### + 0xF0, 0x07, 0x80, 0x3C, // #### #### #### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0xF0, 0x07, 0x80, 0x1C, // #### #### ### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @9964 'n' (18 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xE1, 0xF8, 0x00, // ### ###### + 0xE7, 0xFE, 0x00, // ### ########## + 0xEF, 0xFF, 0x00, // ### ############ + 0xFE, 0x1F, 0x00, // ####### ##### + 0xF8, 0x07, 0x80, // ##### #### + 0xF0, 0x07, 0x80, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @10105 'o' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xF8, 0x00, // ####### + 0x0F, 0xFE, 0x00, // ########### + 0x1F, 0xFF, 0x00, // ############# + 0x3E, 0x0F, 0x80, // ##### ##### + 0x78, 0x07, 0xC0, // #### ##### + 0x78, 0x03, 0xC0, // #### #### + 0xF0, 0x01, 0xC0, // #### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x01, 0xE0, // ### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xC0, // #### ### + 0x70, 0x03, 0xC0, // ### #### + 0x78, 0x07, 0xC0, // #### ##### + 0x3E, 0x0F, 0x80, // ##### ##### + 0x1F, 0xFF, 0x00, // ############# + 0x0F, 0xFE, 0x00, // ########### + 0x03, 0xF8, 0x00, // ####### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @10246 'p' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xE1, 0xF8, 0x00, // ### ###### + 0xE7, 0xFE, 0x00, // ### ########## + 0xEF, 0xFF, 0x00, // ### ############ + 0xFE, 0x0F, 0x80, // ####### ##### + 0xFC, 0x07, 0xC0, // ###### ##### + 0xF8, 0x03, 0xC0, // ##### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xE0, 0x00, 0xE0, // ### ### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF8, 0x03, 0xC0, // ##### #### + 0xFC, 0x07, 0xC0, // ###### ##### + 0xFE, 0x0F, 0x80, // ####### ##### + 0xEF, 0xFF, 0x00, // ### ############ + 0xE7, 0xFE, 0x00, // ### ########## + 0xE1, 0xF8, 0x00, // ### ###### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0xE0, 0x00, 0x00, // ### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @10387 'q' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x03, 0xF1, 0xE0, // ###### #### + 0x0F, 0xFD, 0xE0, // ########## #### + 0x1F, 0xFF, 0xE0, // ################ + 0x3E, 0x0F, 0xE0, // ##### ####### + 0x78, 0x07, 0xE0, // #### ###### + 0x78, 0x03, 0xE0, // #### ##### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xE0, 0x01, 0xE0, // ### #### + 0xF0, 0x01, 0xE0, // #### #### + 0xF0, 0x01, 0xE0, // #### #### + 0x70, 0x03, 0xE0, // ### ##### + 0x78, 0x07, 0xE0, // #### ###### + 0x3E, 0x0F, 0xE0, // ##### ####### + 0x1F, 0xFF, 0xE0, // ################ + 0x0F, 0xFD, 0xE0, // ########## #### + 0x03, 0xF1, 0xE0, // ###### #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x01, 0xE0, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @10528 'r' (14 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xE1, 0xF8, // ### ###### + 0xE7, 0xFC, // ### ######### + 0xEF, 0xF8, // ### ######### + 0xFE, 0x10, // ####### # + 0xFC, 0x00, // ###### + 0xF8, 0x00, // ##### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0xF0, 0x00, // #### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @10622 's' (16 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x03, 0xF0, // ###### + 0x0F, 0xFC, // ########## + 0x1F, 0xFF, // ############# + 0x3C, 0x0E, // #### ### + 0x38, 0x04, // ### # + 0x78, 0x00, // #### + 0x38, 0x00, // ### + 0x3C, 0x00, // #### + 0x3F, 0x00, // ###### + 0x1F, 0xF0, // ######### + 0x07, 0xFC, // ######### + 0x00, 0xFE, // ####### + 0x00, 0x1F, // ##### + 0x00, 0x0F, // #### + 0x00, 0x07, // ### + 0x20, 0x07, // # ### + 0x60, 0x0F, // ## #### + 0xFC, 0x1F, // ###### ##### + 0x7F, 0xFE, // ############## + 0x1F, 0xFC, // ########### + 0x07, 0xF0, // ####### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @10716 't' (13 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0xFF, 0xE0, // ########### + 0xFF, 0xE0, // ########### + 0xFF, 0xE0, // ########### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1E, 0x20, // #### # + 0x0F, 0xF0, // ######## + 0x0F, 0xF8, // ######### + 0x03, 0xE0, // ##### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @10810 'u' (18 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x07, 0xC0, // #### ##### + 0x78, 0x07, 0xC0, // #### ##### + 0x7E, 0x1F, 0xC0, // ###### ####### + 0x3F, 0xFF, 0xC0, // ################ + 0x1F, 0xFB, 0xC0, // ########## #### + 0x07, 0xE3, 0xC0, // ###### #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @10951 'v' (20 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0xF0, // #### #### + 0x78, 0x01, 0xE0, // #### #### + 0x78, 0x01, 0xE0, // #### #### + 0x38, 0x01, 0xC0, // ### ### + 0x3C, 0x03, 0xC0, // #### #### + 0x3C, 0x03, 0xC0, // #### #### + 0x1C, 0x03, 0x80, // ### ### + 0x1E, 0x07, 0x80, // #### #### + 0x0E, 0x07, 0x00, // ### ### + 0x0E, 0x07, 0x00, // ### ### + 0x0F, 0x0F, 0x00, // #### #### + 0x07, 0x0E, 0x00, // ### ### + 0x07, 0x8E, 0x00, // #### ### + 0x07, 0x9E, 0x00, // #### #### + 0x03, 0x9C, 0x00, // ### ### + 0x03, 0xFC, 0x00, // ######## + 0x01, 0xF8, 0x00, // ###### + 0x01, 0xF8, 0x00, // ###### + 0x01, 0xF8, 0x00, // ###### + 0x00, 0xF0, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @11092 'w' (28 pixels wide) + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0xF8, 0x1C, 0x00, 0xF0, // ##### ### #### + 0x78, 0x1E, 0x00, 0xF0, // #### #### #### + 0x78, 0x1E, 0x00, 0xE0, // #### #### ### + 0x38, 0x0E, 0x01, 0xE0, // ### ### #### + 0x3C, 0x0E, 0x01, 0xE0, // #### ### #### + 0x3C, 0x0F, 0x01, 0xE0, // #### #### #### + 0x3C, 0x07, 0x03, 0xC0, // #### ### #### + 0x1E, 0x0F, 0x03, 0xC0, // #### #### #### + 0x1E, 0x0F, 0x83, 0xC0, // #### ##### #### + 0x1E, 0x0F, 0x83, 0x80, // #### ##### ### + 0x0F, 0x1F, 0x87, 0x80, // #### ###### #### + 0x0F, 0x1F, 0xC7, 0x80, // #### ####### #### + 0x0F, 0x1D, 0xC7, 0x00, // #### ### ### ### + 0x07, 0x39, 0xCF, 0x00, // ### ### ### #### + 0x07, 0xB9, 0xEF, 0x00, // #### ### #### #### + 0x07, 0xB8, 0xEE, 0x00, // #### ### ### ### + 0x03, 0xF8, 0xFE, 0x00, // ####### ####### + 0x03, 0xF0, 0xFE, 0x00, // ###### ####### + 0x03, 0xF0, 0x7C, 0x00, // ###### ##### + 0x01, 0xF0, 0x7C, 0x00, // ##### ##### + 0x01, 0xE0, 0x7C, 0x00, // #### ##### + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, // + + // @11280 'x' (21 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x00, 0xF8, // #### ##### + 0x78, 0x01, 0xF0, // #### ##### + 0x3C, 0x03, 0xE0, // #### ##### + 0x1E, 0x03, 0xC0, // #### #### + 0x1F, 0x07, 0x80, // ##### #### + 0x0F, 0x0F, 0x00, // #### #### + 0x07, 0x9F, 0x00, // #### ##### + 0x03, 0xDE, 0x00, // #### #### + 0x03, 0xFC, 0x00, // ######## + 0x01, 0xF8, 0x00, // ###### + 0x00, 0xF0, 0x00, // #### + 0x01, 0xF8, 0x00, // ###### + 0x01, 0xFC, 0x00, // ####### + 0x03, 0xFE, 0x00, // ######### + 0x07, 0x9F, 0x00, // #### ##### + 0x0F, 0x0F, 0x00, // #### #### + 0x1F, 0x07, 0x80, // ##### #### + 0x1E, 0x03, 0xC0, // #### #### + 0x3C, 0x03, 0xE0, // #### ##### + 0x78, 0x01, 0xF0, // #### ##### + 0xF0, 0x00, 0xF8, // #### ##### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @11421 'y' (18 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x03, 0xC0, // #### #### + 0xF0, 0x07, 0xC0, // #### ##### + 0x78, 0x07, 0xC0, // #### ##### + 0x7E, 0x1F, 0xC0, // ###### ####### + 0x3F, 0xFF, 0xC0, // ################ + 0x1F, 0xFB, 0xC0, // ########## #### + 0x07, 0xE3, 0xC0, // ###### #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0x80, // ### + 0x40, 0x07, 0x80, // # #### + 0x60, 0x07, 0x00, // ## ### + 0x78, 0x1F, 0x00, // #### ##### + 0x7F, 0xFE, 0x00, // ############## + 0x3F, 0xFC, 0x00, // ############ + 0x0F, 0xF0, 0x00, // ######## + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @11562 'z' (17 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0x00, 0x0F, 0x00, // #### + 0x00, 0x1E, 0x00, // #### + 0x00, 0x3E, 0x00, // ##### + 0x00, 0x7C, 0x00, // ##### + 0x00, 0x78, 0x00, // #### + 0x00, 0xF0, 0x00, // #### + 0x01, 0xE0, 0x00, // #### + 0x03, 0xE0, 0x00, // ##### + 0x07, 0xC0, 0x00, // ##### + 0x07, 0x80, 0x00, // #### + 0x0F, 0x00, 0x00, // #### + 0x1E, 0x00, 0x00, // #### + 0x3E, 0x00, 0x00, // ##### + 0x3C, 0x00, 0x00, // #### + 0x78, 0x00, 0x00, // #### + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFF, 0x80, // ################# + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + + // @11703 '{' (9 pixels wide) + 0x07, 0x80, // #### + 0x0F, 0x80, // ##### + 0x0F, 0x80, // ##### + 0x1E, 0x00, // #### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x38, 0x00, // ### + 0x78, 0x00, // #### + 0xF0, 0x00, // #### + 0xE0, 0x00, // ### + 0xF0, 0x00, // #### + 0x78, 0x00, // #### + 0x38, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1E, 0x00, // #### + 0x0F, 0x80, // ##### + 0x0F, 0x80, // ##### + 0x07, 0x80, // #### + + // @11797 '|' (2 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @11844 '}' (9 pixels wide) + 0xF0, 0x00, // #### + 0xF8, 0x00, // ##### + 0xFC, 0x00, // ###### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x0C, 0x00, // ## + 0x0E, 0x00, // ### + 0x0E, 0x00, // ### + 0x0F, 0x00, // #### + 0x07, 0x80, // #### + 0x03, 0x80, // ### + 0x07, 0x80, // #### + 0x0F, 0x00, // #### + 0x0E, 0x00, // ### + 0x0E, 0x00, // ### + 0x0C, 0x00, // ## + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x1C, 0x00, // ### + 0x3C, 0x00, // #### + 0xFC, 0x00, // ###### + 0xF8, 0x00, // ##### + 0xF0, 0x00, // #### + + // @11938 '~' (19 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x1E, 0x00, 0x00, // #### + 0x7F, 0x80, 0x60, // ######## ## + 0x61, 0xC0, 0x60, // ## ### ## + 0xC0, 0xE0, 0xC0, // ## ### ## + 0xC0, 0x71, 0xC0, // ## ### ### + 0xC0, 0x3F, 0x80, // ## ####### + 0xC0, 0x1F, 0x00, // ## ##### + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, // +}; + +// Character descriptors for Orkney 24pt +// { [Char width in bits], [Offset into orkney_24ptCharBitmaps in bytes] } +const FONT_CHAR_INFO orkney_24ptDescriptors[] = +{ + {4, 0}, // ! + {10, 47}, // " + {27, 141}, // # + {20, 329}, // $ + {26, 470}, // % + {24, 658}, // & + {3, 799}, // ' + {11, 846}, // ( + {10, 940}, // ) + {10, 1034}, // * + {24, 1128}, // + + {5, 1269}, // , + {14, 1316}, // - + {5, 1410}, // . + {25, 1457}, // / + {21, 1645}, // 0 + {9, 1786}, // 1 + {20, 1880}, // 2 + {19, 2021}, // 3 + {21, 2162}, // 4 + {19, 2303}, // 5 + {22, 2444}, // 6 + {20, 2585}, // 7 + {19, 2726}, // 8 + {22, 2867}, // 9 + {4, 3008}, // : + {5, 3055}, // ; + {22, 3102}, // < + {24, 3243}, // = + {22, 3384}, // > + {18, 3525}, // ? + {19, 3666}, // @ + {28, 3807}, // A + {21, 3995}, // B + {23, 4136}, // C + {23, 4277}, // D + {17, 4418}, // E + {17, 4559}, // F + {24, 4700}, // G + {23, 4841}, // H + {4, 4982}, // I + {10, 5029}, // J + {21, 5123}, // K + {15, 5264}, // L + {30, 5358}, // M + {25, 5546}, // N + {29, 5734}, // O + {19, 5922}, // P + {30, 6063}, // Q + {20, 6251}, // R + {21, 6392}, // S + {20, 6533}, // T + {23, 6674}, // U + {28, 6815}, // V + {44, 7003}, // W + {24, 7285}, // X + {24, 7426}, // Y + {23, 7567}, // Z + {8, 7708}, // [ + {25, 7755}, // '\' + {8, 7943}, // ] + {26, 7990}, // ^ + {20, 8178}, // _ + {7, 8319}, // ` + {17, 8366}, // a + {19, 8507}, // b + {14, 8648}, // c + {19, 8742}, // d + {18, 8883}, // e + {14, 9024}, // f + {19, 9118}, // g + {18, 9259}, // h + {5, 9400}, // i + {9, 9447}, // j + {17, 9541}, // k + {10, 9682}, // l + {30, 9776}, // m + {18, 9964}, // n + {19, 10105}, // o + {19, 10246}, // p + {19, 10387}, // q + {14, 10528}, // r + {16, 10622}, // s + {13, 10716}, // t + {18, 10810}, // u + {20, 10951}, // v + {28, 11092}, // w + {21, 11280}, // x + {18, 11421}, // y + {17, 11562}, // z + {9, 11703}, // { + {2, 11797}, // | + {9, 11844}, // } + {19, 11938}, // ~ +}; + +// Font information for Orkney 24pt +const FONT_INFO orkney_24ptFontInfo = +{ + 45, // Character height + '!', // Start character + '~', // End character + 2, // Width, in pixels, of space character + orkney_24ptDescriptors, // Character descriptor array + orkney_24ptBitmaps, // Character bitmap array +}; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney8pts.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney8pts.c new file mode 100644 index 0000000..7b733ec --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/thedotfactory_fonts/orkney8pts.c @@ -0,0 +1,1823 @@ +/* Font copyrights: + * + * Copyright (c) 2015, + * Alfredo Marco Pradil (https://behance.net/pradil), + * Samuel Oakes (http://oakes.co/), + * Cristiano Sobral (https://www.behance.net/cssobral20f492), + * with Reserved Font Name Orkney. + * + * Code was generated by The Dot Factory (https://github.com/pavius/the-dot-factory) + * + * This Font Software is licensed under the SIL Open Font License, Version 1.1. See SIL-License.txt + * for more informations. + * + */ + +#include "nrf_font.h" + +// Character bitmaps for Orkney 8pt +const uint8_t orkney_8ptBitmaps[] = +{ + // @0 '!' (2 pixels wide) + 0x00, // + 0x00, // + 0xC0, // ## + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @16 '"' (3 pixels wide) + 0x00, // + 0x00, // + 0xA0, // # # + 0xA0, // # # + 0xA0, // # # + 0xA0, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @32 '#' (8 pixels wide) + 0x00, // + 0x00, // + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0xFF, // ######## + 0x24, // # # + 0x24, // # # + 0x24, // # # + 0xFF, // ######## + 0x44, // # # + 0x44, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @48 '$' (6 pixels wide) + 0x10, // # + 0x38, // ### + 0x44, // # # + 0x80, // # + 0xC0, // ## + 0x60, // ## + 0x38, // ### + 0x0C, // ## + 0x04, // # + 0x84, // # # + 0xC4, // ## # + 0x78, // #### + 0x10, // # + 0x00, // + 0x00, // + 0x00, // + + // @64 '%' (8 pixels wide) + 0x00, // + 0x00, // + 0xE3, // ### ## + 0xA2, // # # # + 0xA4, // # # # + 0xE8, // ### # + 0x08, // # + 0x10, // # + 0x26, // # ## + 0x29, // # # # + 0x49, // # # # + 0x86, // # ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @80 '&' (8 pixels wide) + 0x00, // + 0x00, // + 0x38, // ### + 0x48, // # # + 0x40, // # + 0x40, // # + 0x20, // # + 0x50, // # # + 0x89, // # # # + 0x86, // # ## + 0x46, // # ## + 0x39, // ### # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @96 ''' (1 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @112 '(' (3 pixels wide) + 0x20, // # + 0x20, // # + 0x40, // # + 0x40, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x40, // # + 0x40, // # + 0x20, // # + + // @128 ')' (3 pixels wide) + 0x80, // # + 0xC0, // ## + 0x40, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x40, // # + 0x80, // # + + // @144 '*' (3 pixels wide) + 0x00, // + 0x00, // + 0xC0, // ## + 0xE0, // ### + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @160 '+' (8 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0xFF, // ######## + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @176 ',' (1 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + + // @192 '-' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xF8, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @208 '.' (2 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @224 '/' (8 pixels wide) + 0x00, // + 0x00, // + 0x03, // ## + 0x02, // # + 0x04, // # + 0x04, // # + 0x08, // # + 0x08, // # + 0x10, // # + 0x10, // # + 0x20, // # + 0x20, // # + 0x40, // # + 0x40, // # + 0x80, // # + 0x00, // + + // @240 '0' (7 pixels wide) + 0x00, // + 0x00, // + 0x38, // ### + 0x44, // # # + 0xC6, // ## ## + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0xC6, // ## ## + 0x44, // # # + 0x38, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @256 '1' (4 pixels wide) + 0x00, // + 0x00, // + 0x30, // ## + 0x70, // ### + 0xB0, // # ## + 0x30, // ## + 0x30, // ## + 0x30, // ## + 0x30, // ## + 0x30, // ## + 0x30, // ## + 0x30, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @272 '2' (6 pixels wide) + 0x00, // + 0x00, // + 0x78, // #### + 0xC8, // ## # + 0x84, // # # + 0x04, // # + 0x08, // # + 0x10, // # + 0x30, // ## + 0x60, // ## + 0xC0, // ## + 0xFC, // ###### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @288 '3' (6 pixels wide) + 0x00, // + 0x00, // + 0x70, // ### + 0xC8, // ## # + 0x08, // # + 0x08, // # + 0x30, // ## + 0x08, // # + 0x04, // # + 0x84, // # # + 0xC8, // ## # + 0x78, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @304 '4' (7 pixels wide) + 0x00, // + 0x00, // + 0x0C, // ## + 0x0C, // ## + 0x14, // # # + 0x14, // # # + 0x24, // # # + 0x44, // # # + 0x44, // # # + 0xFE, // ####### + 0x04, // # + 0x04, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @320 '5' (6 pixels wide) + 0x00, // + 0x00, // + 0x7C, // ##### + 0x80, // # + 0x80, // # + 0xF8, // ##### + 0x8C, // # ## + 0x04, // # + 0x04, // # + 0x04, // # + 0x8C, // # ## + 0x78, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @336 '6' (7 pixels wide) + 0x00, // + 0x00, // + 0x08, // # + 0x10, // # + 0x20, // # + 0x78, // #### + 0x44, // # # + 0x86, // # ## + 0x82, // # # + 0x86, // # ## + 0xC4, // ## # + 0x78, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @352 '7' (7 pixels wide) + 0x00, // + 0x00, // + 0xFE, // ####### + 0x06, // ## + 0x04, // # + 0x0C, // ## + 0x08, // # + 0x10, // # + 0x10, // # + 0x20, // # + 0x20, // # + 0x40, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @368 '8' (6 pixels wide) + 0x00, // + 0x00, // + 0x70, // ### + 0xC8, // ## # + 0x88, // # # + 0xC8, // ## # + 0x70, // ### + 0x88, // # # + 0x84, // # # + 0x84, // # # + 0x88, // # # + 0x78, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @384 '9' (7 pixels wide) + 0x00, // + 0x00, // + 0x78, // #### + 0xC4, // ## # + 0x86, // # ## + 0x82, // # # + 0x84, // # # + 0xC4, // ## # + 0x78, // #### + 0x10, // # + 0x30, // ## + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @400 ':' (2 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @416 ';' (2 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC0, // ## + 0x40, // # + 0x40, // # + 0x80, // # + 0x00, // + + // @432 '<' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x02, // # + 0x0C, // ## + 0x30, // ## + 0x60, // ## + 0xC0, // ## + 0x60, // ## + 0x18, // ## + 0x06, // ## + 0x02, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @448 '=' (8 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xFF, // ######## + 0x00, // + 0x00, // + 0xFF, // ######## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @464 '>' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x80, // # + 0x60, // ## + 0x18, // ## + 0x06, // ## + 0x02, // # + 0x0C, // ## + 0x30, // ## + 0xC0, // ## + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @480 '?' (5 pixels wide) + 0x00, // + 0x00, // + 0x70, // ### + 0x88, // # # + 0x88, // # # + 0x08, // # + 0x18, // ## + 0x30, // ## + 0x20, // # + 0x20, // # + 0x00, // + 0x20, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @496 '@' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x78, // #### + 0x48, // # # + 0x9C, // # ### + 0xA4, // # # # + 0xA4, // # # # + 0x9C, // # ### + 0x40, // # + 0x3C, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @512 'A' (9 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x0C, 0x00, // ## + 0x0C, 0x00, // ## + 0x14, 0x00, // # # + 0x12, 0x00, // # # + 0x32, 0x00, // ## # + 0x23, 0x00, // # ## + 0x21, 0x00, // # # + 0x7F, 0x00, // ####### + 0x40, 0x80, // # # + 0xC0, 0x80, // ## # + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @544 'B' (7 pixels wide) + 0x00, // + 0x00, // + 0xF8, // ##### + 0x8C, // # ## + 0x84, // # # + 0x8C, // # ## + 0xF8, // ##### + 0x84, // # # + 0x82, // # # + 0x82, // # # + 0x86, // # ## + 0xFC, // ###### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @560 'C' (7 pixels wide) + 0x00, // + 0x00, // + 0x3E, // ##### + 0x62, // ## # + 0xC0, // ## + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0xC0, // ## + 0x62, // ## # + 0x3E, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @576 'D' (8 pixels wide) + 0x00, // + 0x00, // + 0xF8, // ##### + 0x84, // # # + 0x82, // # # + 0x82, // # # + 0x83, // # ## + 0x83, // # ## + 0x82, // # # + 0x82, // # # + 0x84, // # # + 0xF8, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @592 'E' (5 pixels wide) + 0x00, // + 0x00, // + 0xF8, // ##### + 0x80, // # + 0x80, // # + 0x80, // # + 0xF8, // ##### + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0xF8, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @608 'F' (5 pixels wide) + 0x00, // + 0x00, // + 0xF8, // ##### + 0x80, // # + 0x80, // # + 0x80, // # + 0xF8, // ##### + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @624 'G' (8 pixels wide) + 0x00, // + 0x00, // + 0x1E, // #### + 0x61, // ## # + 0x40, // # + 0x80, // # + 0x8F, // # #### + 0x81, // # # + 0x81, // # # + 0x41, // # # + 0x61, // ## # + 0x1E, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @640 'H' (8 pixels wide) + 0x00, // + 0x00, // + 0x83, // # ## + 0x83, // # ## + 0x83, // # ## + 0x83, // # ## + 0xFF, // ######## + 0x83, // # ## + 0x83, // # ## + 0x83, // # ## + 0x83, // # ## + 0x83, // # ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @656 'I' (1 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @672 'J' (3 pixels wide) + 0x00, // + 0x00, // + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0xC0, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @688 'K' (7 pixels wide) + 0x00, // + 0x00, // + 0x86, // # ## + 0x88, // # # + 0x90, // # # + 0xA0, // # # + 0xC0, // ## + 0xA0, // # # + 0x90, // # # + 0x88, // # # + 0x84, // # # + 0x82, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @704 'L' (5 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0xF8, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @720 'M' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0xC0, 0xC0, // ## ## + 0xC0, 0xC0, // ## ## + 0xA1, 0x40, // # # # # + 0xB3, 0x40, // # ## ## # + 0x92, 0x40, // # # # # + 0x8C, 0x40, // # ## # + 0x8C, 0x40, // # ## # + 0x88, 0x40, // # # # + 0x80, 0x40, // # # + 0x80, 0x40, // # # + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @752 'N' (8 pixels wide) + 0x00, // + 0x00, // + 0x81, // # # + 0xC1, // ## # + 0xA1, // # # # + 0xB1, // # ## # + 0x91, // # # # + 0x89, // # # # + 0x8D, // # ## # + 0x87, // # ### + 0x83, // # ## + 0x81, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @768 'O' (9 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x3E, 0x00, // ##### + 0x63, 0x00, // ## ## + 0xC1, 0x80, // ## ## + 0x80, 0x80, // # # + 0x80, 0x80, // # # + 0x80, 0x80, // # # + 0x80, 0x80, // # # + 0xC1, 0x80, // ## ## + 0x63, 0x00, // ## ## + 0x3E, 0x00, // ##### + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @800 'P' (6 pixels wide) + 0x00, // + 0x00, // + 0xF8, // ##### + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0xF8, // ##### + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @816 'Q' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x3E, 0x00, // ##### + 0x63, 0x00, // ## ## + 0xC1, 0x80, // ## ## + 0x80, 0x80, // # # + 0x80, 0x80, // # # + 0x80, 0x80, // # # + 0x84, 0x80, // # # # + 0xC3, 0x80, // ## ### + 0x63, 0x00, // ## ## + 0x3E, 0xC0, // ##### ## + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @848 'R' (7 pixels wide) + 0x00, // + 0x00, // + 0xF8, // ##### + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0xFC, // ###### + 0x90, // # # + 0x88, // # # + 0x88, // # # + 0x84, // # # + 0x86, // # ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @864 'S' (7 pixels wide) + 0x00, // + 0x00, // + 0x78, // #### + 0xC4, // ## # + 0x80, // # + 0xC0, // ## + 0x70, // ### + 0x0C, // ## + 0x04, // # + 0x86, // # ## + 0x84, // # # + 0x78, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @880 'T' (7 pixels wide) + 0x00, // + 0x00, // + 0xFE, // ####### + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @896 'U' (7 pixels wide) + 0x00, // + 0x00, // + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x82, // # # + 0x46, // # ## + 0x3C, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @912 'V' (9 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0xC0, 0x80, // ## # + 0x41, 0x80, // # ## + 0x41, 0x00, // # # + 0x61, 0x00, // ## # + 0x22, 0x00, // # # + 0x22, 0x00, // # # + 0x16, 0x00, // # ## + 0x14, 0x00, // # # + 0x1C, 0x00, // ### + 0x0C, 0x00, // ## + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @944 'W' (14 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x84, 0x04, // # # # + 0xC6, 0x0C, // ## ## ## + 0x42, 0x08, // # # # + 0x62, 0x18, // ## # ## + 0x23, 0x10, // # ## # + 0x23, 0x10, // # ## # + 0x13, 0xB0, // # ### ## + 0x14, 0xA0, // # # # # + 0x1C, 0xE0, // ### ### + 0x08, 0x40, // # # + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @976 'X' (8 pixels wide) + 0x00, // + 0x00, // + 0xC3, // ## ## + 0x62, // ## # + 0x24, // # # + 0x1C, // ### + 0x18, // ## + 0x18, // ## + 0x14, // # # + 0x26, // # ## + 0x62, // ## # + 0xC1, // ## # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @992 'Y' (8 pixels wide) + 0x00, // + 0x00, // + 0xC1, // ## # + 0x62, // ## # + 0x26, // # ## + 0x14, // # # + 0x18, // ## + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1008 'Z' (7 pixels wide) + 0x00, // + 0x00, // + 0xFE, // ####### + 0x04, // # + 0x0C, // ## + 0x08, // # + 0x10, // # + 0x30, // ## + 0x20, // # + 0x40, // # + 0xC0, // ## + 0xFE, // ####### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1024 '[' (3 pixels wide) + 0xE0, // ### + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0xE0, // ### + + // @1040 '\' (8 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x40, // # + 0x40, // # + 0x20, // # + 0x20, // # + 0x10, // # + 0x10, // # + 0x08, // # + 0x08, // # + 0x04, // # + 0x04, // # + 0x02, // # + 0x03, // ## + 0x00, // + + // @1056 ']' (3 pixels wide) + 0xE0, // ### + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0x20, // # + 0xE0, // ### + + // @1072 '^' (9 pixels wide) + 0x00, 0x00, // + 0x08, 0x00, // # + 0x0C, 0x00, // ## + 0x14, 0x00, // # # + 0x16, 0x00, // # ## + 0x22, 0x00, // # # + 0x22, 0x00, // # # + 0x41, 0x00, // # # + 0xC1, 0x80, // ## ## + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @1104 '_' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xFE, // ####### + 0x00, // + 0x00, // + 0x00, // + + // @1120 '`' (3 pixels wide) + 0x00, // + 0x00, // + 0xC0, // ## + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1136 'a' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0x88, // # # + 0x08, // # + 0xF8, // ##### + 0x88, // # # + 0x98, // # ## + 0xE8, // ### # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1152 'b' (6 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0xB8, // # ### + 0xCC, // ## ## + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0xCC, // ## ## + 0xB8, // # ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1168 'c' (4 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0x90, // # # + 0x80, // # + 0x80, // # + 0x80, // # + 0x90, // # # + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1184 'd' (6 pixels wide) + 0x00, // + 0x00, // + 0x04, // # + 0x04, // # + 0x04, // # + 0x74, // ### # + 0x8C, // # ## + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x8C, // # ## + 0x74, // ### # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1200 'e' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0x88, // # # + 0x88, // # # + 0xFC, // ###### + 0x80, // # + 0x88, // # # + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1216 'f' (4 pixels wide) + 0x00, // + 0x00, // + 0x70, // ### + 0x40, // # + 0x40, // # + 0xE0, // ### + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1232 'g' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x74, // ### # + 0x8C, // # ## + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x8C, // # ## + 0x74, // ### # + 0x04, // # + 0x88, // # # + 0x70, // ### + 0x00, // + + // @1248 'h' (6 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0xB8, // # ### + 0xC8, // ## # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1264 'i' (2 pixels wide) + 0x00, // + 0x00, // + 0xC0, // ## + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1280 'j' (3 pixels wide) + 0x00, // + 0x00, // + 0x60, // ## + 0x00, // + 0x00, // + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x60, // ## + 0x40, // # + 0xC0, // ## + 0x00, // + + // @1296 'k' (5 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x98, // # ## + 0xB0, // # ## + 0xE0, // ### + 0xE0, // ### + 0xB0, // # ## + 0x98, // # ## + 0x88, // # # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + + // @1312 'l' (3 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x60, // ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1328 'm' (10 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xFB, 0x80, // ##### ### + 0xCC, 0xC0, // ## ## ## + 0x88, 0x40, // # # # + 0x88, 0x40, // # # # + 0x88, 0x40, // # # # + 0x88, 0x40, // # # # + 0x88, 0x40, // # # # + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @1360 'n' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xB8, // # ### + 0xC8, // ## # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1376 'o' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x70, // ### + 0x88, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x88, // # # + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1392 'p' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xB8, // # ### + 0xCC, // ## ## + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0xCC, // ## ## + 0xB8, // # ### + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + + // @1408 'q' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x74, // ### # + 0x8C, // # ## + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x8C, // # ## + 0x74, // ### # + 0x04, // # + 0x04, // # + 0x04, // # + 0x00, // + + // @1424 'r' (4 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xB0, // # ## + 0xC0, // ## + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1440 's' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x38, // ### + 0x48, // # # + 0x40, // # + 0x38, // ### + 0x0C, // ## + 0xCC, // ## ## + 0x78, // #### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1456 't' (5 pixels wide) + 0x00, // + 0x00, // + 0x40, // # + 0x40, // # + 0x40, // # + 0xF0, // #### + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x38, // ### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1472 'u' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0xCC, // ## ## + 0x74, // ### # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1488 'v' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC4, // ## # + 0x44, // # # + 0x48, // # # + 0x68, // ## # + 0x28, // # # + 0x30, // ## + 0x10, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1504 'w' (9 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0xD8, 0x80, // ## ## # + 0x49, 0x80, // # # ## + 0x49, 0x00, // # # # + 0x4D, 0x00, // # ## # + 0x35, 0x00, // ## # # + 0x36, 0x00, // ## ## + 0x32, 0x00, // ## # + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @1536 'x' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xC6, // ## ## + 0x4C, // # ## + 0x38, // ### + 0x10, // # + 0x38, // ### + 0x4C, // # ## + 0xC6, // ## ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1552 'y' (6 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0x84, // # # + 0xCC, // ## ## + 0x74, // ### # + 0x04, // # + 0x88, // # # + 0x70, // ### + 0x00, // + + // @1568 'z' (5 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0xF8, // ##### + 0x18, // ## + 0x30, // ## + 0x20, // # + 0x40, // # + 0xC0, // ## + 0xF8, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @1584 '{' (3 pixels wide) + 0x60, // ## + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x60, // ## + + // @1600 '|' (1 pixels wide) + 0x00, // + 0x00, // + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x80, // # + 0x00, // + 0x00, // + + // @1616 '}' (3 pixels wide) + 0x80, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x60, // ## + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x40, // # + 0x80, // # + + // @1632 '~' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x62, // ## # + 0x52, // # # # + 0x8C, // # ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // +}; + +// Character descriptors for Orkney 8pt +// { [Char width in bits], [Offset into orkney_8ptCharBitmaps in bytes] } +const FONT_CHAR_INFO orkney_8ptDescriptors[] = +{ + {2, 0}, // ! + {3, 16}, // " + {8, 32}, // # + {6, 48}, // $ + {8, 64}, // % + {8, 80}, // & + {1, 96}, // ' + {3, 112}, // ( + {3, 128}, // ) + {3, 144}, // * + {8, 160}, // + + {1, 176}, // , + {5, 192}, // - + {2, 208}, // . + {8, 224}, // / + {7, 240}, // 0 + {4, 256}, // 1 + {6, 272}, // 2 + {6, 288}, // 3 + {7, 304}, // 4 + {6, 320}, // 5 + {7, 336}, // 6 + {7, 352}, // 7 + {6, 368}, // 8 + {7, 384}, // 9 + {2, 400}, // : + {2, 416}, // ; + {7, 432}, // < + {8, 448}, // = + {7, 464}, // > + {5, 480}, // ? + {6, 496}, // @ + {9, 512}, // A + {7, 544}, // B + {7, 560}, // C + {8, 576}, // D + {5, 592}, // E + {5, 608}, // F + {8, 624}, // G + {8, 640}, // H + {1, 656}, // I + {3, 672}, // J + {7, 688}, // K + {5, 704}, // L + {10, 720}, // M + {8, 752}, // N + {9, 768}, // O + {6, 800}, // P + {10, 816}, // Q + {7, 848}, // R + {7, 864}, // S + {7, 880}, // T + {7, 896}, // U + {9, 912}, // V + {14, 944}, // W + {8, 976}, // X + {8, 992}, // Y + {7, 1008}, // Z + {3, 1024}, // [ + {8, 1040}, // '\' + {3, 1056}, // ] + {9, 1072}, // ^ + {7, 1104}, // _ + {3, 1120}, // ` + {5, 1136}, // a + {6, 1152}, // b + {4, 1168}, // c + {6, 1184}, // d + {6, 1200}, // e + {4, 1216}, // f + {6, 1232}, // g + {6, 1248}, // h + {2, 1264}, // i + {3, 1280}, // j + {5, 1296}, // k + {3, 1312}, // l + {10, 1328}, // m + {6, 1360}, // n + {6, 1376}, // o + {6, 1392}, // p + {6, 1408}, // q + {4, 1424}, // r + {6, 1440}, // s + {5, 1456}, // t + {6, 1472}, // u + {6, 1488}, // v + {9, 1504}, // w + {7, 1536}, // x + {6, 1552}, // y + {5, 1568}, // z + {3, 1584}, // { + {1, 1600}, // | + {3, 1616}, // } + {7, 1632}, // ~ +}; + +// Font information for Orkney 8pt +const FONT_INFO orkney_8ptFontInfo = +{ + 15, // Character height + '!', // Start character + '~', // End character + 2, // Width, in pixels, of space character + orkney_8ptDescriptors, // Character descriptor array + orkney_8ptBitmaps, // Character bitmap array +}; diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/LICENSE b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/LICENSE new file mode 100644 index 0000000..fdee8ad --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/LICENSE @@ -0,0 +1,9 @@ +Copyright (c) 2016 Pietro Gagliardi + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(this is called the MIT License or Expat License; see http://www.opensource.org/licenses/MIT) diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.c new file mode 100644 index 0000000..e76afe7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.c @@ -0,0 +1,350 @@ +// utf by pietro gagliardi (andlabs) — https://github.com/andlabs/utf/ +// 10 november 2016 +#include "utf.h" + +// this code imitates Go's unicode/utf8 and unicode/utf16 +// the biggest difference is that a rune is unsigned instead of signed (because Go guarantees what a right shift on a signed number will do, whereas C does not) +// it is also an imitation so we can license it under looser terms than the Go source +#define badrune 0xFFFD + +// encoded must be at most 4 bytes +// TODO clean this code up somehow +size_t utf8EncodeRune(uint32_t rune, char *encoded) +{ + uint8_t b; + uint8_t c = 0; + uint8_t d = 0; + uint8_t e = 0; + size_t n; + + // not in the valid range for Unicode + if (rune > 0x10FFFF) + rune = badrune; + // surrogate runes cannot be encoded + if (rune >= 0xD800 && rune < 0xE000) + rune = badrune; + + if (rune < 0x80) { // ASCII bytes represent themselves + b = (uint8_t) (rune & 0xFF); + n = 1; + goto done; + } + if (rune < 0x800) { // two-byte encoding + c = (uint8_t) (rune & 0x3F); + c |= 0x80; + rune >>= 6; + b = (uint8_t) (rune & 0x1F); + b |= 0xC0; + n = 2; + goto done; + } + if (rune < 0x10000) { // three-byte encoding + d = (uint8_t) (rune & 0x3F); + d |= 0x80; + rune >>= 6; + c = (uint8_t) (rune & 0x3F); + c |= 0x80; + rune >>= 6; + b = (uint8_t) (rune & 0x0F); + b |= 0xE0; + n = 3; + goto done; + } + // otherwise use a four-byte encoding + e = (uint8_t) (rune & 0x3F); + e |= 0x80; + rune >>= 6; + d = (uint8_t) (rune & 0x3F); + d |= 0x80; + rune >>= 6; + c = (uint8_t) (rune & 0x3F); + c |= 0x80; + rune >>= 6; + b = (uint8_t) (rune & 0x07); + b |= 0xF0; + n = 4; + +done: + encoded[0] = b; + if (n > 1) + encoded[1] = c; + if (n > 2) + encoded[2] = d; + if (n > 3) + encoded[3] = e; + return n; +} + +const char *utf8DecodeRune(const char *s, size_t nElem, uint32_t *rune) +{ + uint8_t b, c; + uint8_t lowestAllowed, highestAllowed; + size_t i, expected; + int bad; + + b = (uint8_t) (*s); + if (b < 0x80) { // ASCII bytes represent themselves + *rune = b; + s++; + return s; + } + // 0xC0 and 0xC1 cover 2-byte overlong equivalents + // 0xF5 to 0xFD cover values > 0x10FFFF + // 0xFE and 0xFF were never defined (always illegal) + if (b < 0xC2 || b > 0xF4) { // invalid + *rune = badrune; + s++; + return s; + } + + // this determines the range of allowed first continuation bytes + lowestAllowed = 0x80; + highestAllowed = 0xBF; + switch (b) { + case 0xE0: + // disallow 3-byte overlong equivalents + lowestAllowed = 0xA0; + break; + case 0xED: + // disallow surrogate characters + highestAllowed = 0x9F; + break; + case 0xF0: + // disallow 4-byte overlong equivalents + lowestAllowed = 0x90; + break; + case 0xF4: + // disallow values > 0x10FFFF + highestAllowed = 0x8F; + break; + } + + // and this determines how many continuation bytes are expected + expected = 1; + if (b >= 0xE0) + expected++; + if (b >= 0xF0) + expected++; + if (nElem != 0) { // are there enough bytes? + nElem--; + if (nElem < expected) { // nope + *rune = badrune; + s++; + return s; + } + } + + // ensure that everything is correct + // if not, **only** consume the initial byte + bad = 0; + for (i = 0; i < expected; i++) { + c = (uint8_t) (s[1 + i]); + if (c < lowestAllowed || c > highestAllowed) { + bad = 1; + break; + } + // the old lowestAllowed and highestAllowed is only for the first continuation byte + lowestAllowed = 0x80; + highestAllowed = 0xBF; + } + if (bad) { + *rune = badrune; + s++; + return s; + } + + // now do the topmost bits + if (b < 0xE0) + *rune = b & 0x1F; + else if (b < 0xF0) + *rune = b & 0x0F; + else + *rune = b & 0x07; + s++; // we can finally move on + + // now do the continuation bytes + for (; expected; expected--) { + c = (uint8_t) (*s); + s++; + c &= 0x3F; // strip continuation bits + *rune <<= 6; + *rune |= c; + } + + return s; +} + +// encoded must have at most 2 elements +size_t utf16EncodeRune(uint32_t rune, uint16_t *encoded) +{ + uint16_t low, high; + + // not in the valid range for Unicode + if (rune > 0x10FFFF) + rune = badrune; + // surrogate runes cannot be encoded + if (rune >= 0xD800 && rune < 0xE000) + rune = badrune; + + if (rune < 0x10000) { + encoded[0] = (uint16_t) rune; + return 1; + } + + rune -= 0x10000; + low = (uint16_t) (rune & 0x3FF); + rune >>= 10; + high = (uint16_t) (rune & 0x3FF); + encoded[0] = high | 0xD800; + encoded[1] = low | 0xDC00; + return 2; +} + +// TODO see if this can be cleaned up somehow +const uint16_t *utf16DecodeRune(const uint16_t *s, size_t nElem, uint32_t *rune) +{ + uint16_t high, low; + + if (*s < 0xD800 || *s >= 0xE000) { + // self-representing character + *rune = *s; + s++; + return s; + } + if (*s >= 0xDC00) { + // out-of-order surrogates + *rune = badrune; + s++; + return s; + } + if (nElem == 1) { // not enough elements + *rune = badrune; + s++; + return s; + } + high = *s; + high &= 0x3FF; + if (s[1] < 0xDC00 || s[1] >= 0xE000) { + // bad surrogate pair + *rune = badrune; + s++; + return s; + } + s++; + low = *s; + s++; + low &= 0x3FF; + *rune = high; + *rune <<= 10; + *rune |= low; + *rune += 0x10000; + return s; +} + +// TODO find a way to reduce the code in all of these somehow +// TODO find a way to remove u as well +size_t utf8RuneCount(const char *s, size_t nElem) +{ + size_t len; + uint32_t rune; + + if (nElem != 0) { + const char *t, *u; + + len = 0; + t = s; + while (nElem != 0) { + u = utf8DecodeRune(t, nElem, &rune); + len++; + nElem -= u - t; + t = u; + } + return len; + } + len = 0; + while (*s) { + s = utf8DecodeRune(s, nElem, &rune); + len++; + } + return len; +} + +size_t utf8UTF16Count(const char *s, size_t nElem) +{ + size_t len; + uint32_t rune; + uint16_t encoded[2]; + + if (nElem != 0) { + const char *t, *u; + + len = 0; + t = s; + while (nElem != 0) { + u = utf8DecodeRune(t, nElem, &rune); + len += utf16EncodeRune(rune, encoded); + nElem -= u - t; + t = u; + } + return len; + } + len = 0; + while (*s) { + s = utf8DecodeRune(s, nElem, &rune); + len += utf16EncodeRune(rune, encoded); + } + return len; +} + +size_t utf16RuneCount(const uint16_t *s, size_t nElem) +{ + size_t len; + uint32_t rune; + + if (nElem != 0) { + const uint16_t *t, *u; + + len = 0; + t = s; + while (nElem != 0) { + u = utf16DecodeRune(t, nElem, &rune); + len++; + nElem -= u - t; + t = u; + } + return len; + } + len = 0; + while (*s) { + s = utf16DecodeRune(s, nElem, &rune); + len++; + } + return len; +} + +size_t utf16UTF8Count(const uint16_t *s, size_t nElem) +{ + size_t len; + uint32_t rune; + char encoded[4]; + + if (nElem != 0) { + const uint16_t *t, *u; + + len = 0; + t = s; + while (nElem != 0) { + u = utf16DecodeRune(t, nElem, &rune); + len += utf8EncodeRune(rune, encoded); + nElem -= u - t; + t = u; + } + return len; + } + len = 0; + while (*s) { + s = utf16DecodeRune(s, nElem, &rune); + len += utf8EncodeRune(rune, encoded); + } + return len; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.h new file mode 100644 index 0000000..b810a49 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external/utf_converter/utf.h @@ -0,0 +1,61 @@ +// utf by pietro gagliardi (andlabs) — https://github.com/andlabs/utf/ +// 10 november 2016 + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +// if nElem == 0, assume the buffer has no upper limit and is '\0' terminated +// otherwise, assume buffer is NOT '\0' terminated but is bounded by nElem *elements* + +extern size_t utf8EncodeRune(uint32_t rune, char *encoded); +extern const char *utf8DecodeRune(const char *s, size_t nElem, uint32_t *rune); +extern size_t utf16EncodeRune(uint32_t rune, uint16_t *encoded); +extern const uint16_t *utf16DecodeRune(const uint16_t *s, size_t nElem, uint32_t *rune); + +extern size_t utf8RuneCount(const char *s, size_t nElem); +extern size_t utf8UTF16Count(const char *s, size_t nElem); +extern size_t utf16RuneCount(const uint16_t *s, size_t nElem); +extern size_t utf16UTF8Count(const uint16_t *s, size_t nElem); + +#ifdef __cplusplus +} + +// Provide overloads on Windows for using these functions with wchar_t and WCHAR when wchar_t is a keyword in C++ mode (the default). +// Otherwise, you'd need to cast to pass a wchar_t pointer, WCHAR pointer, or equivalent to these functions. +// We use __wchar_t to be independent of the setting; see https://blogs.msdn.microsoft.com/oldnewthing/20161201-00/?p=94836 (ironically posted one day after I initially wrote this code!). +// TODO check this on MinGW-w64 +// TODO check this under /Wall +// TODO C-style casts enough? or will that fail in /Wall? +// TODO same for UniChar/unichar on Mac? if both are unsigned then we have nothing to worry about +#if defined(_MSC_VER) + +inline size_t utf16EncodeRune(uint32_t rune, __wchar_t *encoded) +{ + return utf16EncodeRune(rune, reinterpret_cast(encoded)); +} + +inline const __wchar_t *utf16DecodeRune(const __wchar_t *s, size_t nElem, uint32_t *rune) +{ + const uint16_t *ret; + + ret = utf16DecodeRune(reinterpret_cast(s), nElem, rune); + return reinterpret_cast(ret); +} + +inline size_t utf16RuneCount(const __wchar_t *s, size_t nElem) +{ + return utf16RuneCount(reinterpret_cast(s), nElem); +} + +inline size_t utf16UTF8Count(const __wchar_t *s, size_t nElem) +{ + return utf16UTF8Count(reinterpret_cast(s), nElem); +} + +#endif + +#endif diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external_tools/cmsisconfig/LICENSE.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external_tools/cmsisconfig/LICENSE.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external_tools/cmsisconfig/LICENSE.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external_tools/cmsisconfig/LICENSE.txt diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external_tools/cmsisconfig/README.TXT b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external_tools/cmsisconfig/README.TXT similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/external_tools/cmsisconfig/README.TXT rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/external_tools/cmsisconfig/README.TXT diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/apply_old_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/apply_old_config.h new file mode 100644 index 0000000..b371852 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/apply_old_config.h @@ -0,0 +1,1391 @@ +/** + * Copyright (c) 2017 - 2019, 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 APPLY_OLD_CONFIG_H__ +#define APPLY_OLD_CONFIG_H__ + +//------------------------------------------------------------------------------ +// Peripheral Resource Sharing (PRS) + +#if defined(PERIPHERAL_RESOURCE_SHARING_ENABLED) + +#define NRFX_PRS_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_0_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_1_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_2_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_3_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_4_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED + +#if defined(COMMON_CONFIG_LOG_ENABLED) +#undef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED COMMON_CONFIG_LOG_ENABLED +#endif +#if defined(COMMON_CONFIG_LOG_LEVEL) +#undef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL COMMON_CONFIG_LOG_LEVEL +#endif +#if defined(COMMON_CONFIG_INFO_COLOR) +#undef NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR COMMON_CONFIG_INFO_COLOR +#endif +#if defined(COMMON_CONFIG_DEBUG_COLOR) +#undef NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR COMMON_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(PERIPHERAL_RESOURCE_SHARING_ENABLED) + +//------------------------------------------------------------------------------ +// CLOCK + +#if defined(NRF_CLOCK_ENABLED) + +#if defined(CLOCK_CONFIG_LF_CAL_ENABLED) && defined(CLOCK_CONFIG_LF_SRC) +#if (CLOCK_CONFIG_LF_SRC == CLOCK_LFCLKSRC_SRC_RC) +#define NRFX_CLOCK_CONFIG_LF_CAL_ENABLED 1 +#endif +#endif + +#undef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED NRF_CLOCK_ENABLED + +#if defined(CLOCK_CONFIG_LF_SRC) +#undef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC CLOCK_CONFIG_LF_SRC +#endif +#if defined(CLOCK_CONFIG_IRQ_PRIORITY) +#undef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY CLOCK_CONFIG_IRQ_PRIORITY +#endif + +#if defined(CLOCK_CONFIG_LOG_ENABLED) +#undef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED CLOCK_CONFIG_LOG_ENABLED +#endif +#if defined(CLOCK_CONFIG_LOG_LEVEL) +#undef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL CLOCK_CONFIG_LOG_LEVEL +#endif +#if defined(CLOCK_CONFIG_INFO_COLOR) +#undef NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR CLOCK_CONFIG_INFO_COLOR +#endif +#if defined(CLOCK_CONFIG_DEBUG_COLOR) +#undef NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(NRF_CLOCK_ENABLED) + +//------------------------------------------------------------------------------ +// COMP + +#if defined(COMP_ENABLED) + +#undef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED COMP_ENABLED + +#if defined(COMP_CONFIG_REF) +#undef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF COMP_CONFIG_REF +#endif +#if defined(COMP_CONFIG_MAIN_MODE) +#undef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE COMP_CONFIG_MAIN_MODE +#endif +#if defined(COMP_CONFIG_SPEED_MODE) +#undef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE COMP_CONFIG_SPEED_MODE +#endif +#if defined(COMP_CONFIG_HYST) +#undef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST COMP_CONFIG_HYST +#endif +#if defined(COMP_CONFIG_ISOURCE) +#undef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE COMP_CONFIG_ISOURCE +#endif +#if defined(COMP_CONFIG_INPUT) +#undef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT COMP_CONFIG_INPUT +#endif +#if defined(COMP_CONFIG_IRQ_PRIORITY) +#undef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY COMP_CONFIG_IRQ_PRIORITY +#endif + +#if defined(COMP_CONFIG_LOG_ENABLED) +#undef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED COMP_CONFIG_LOG_ENABLED +#endif +#if defined(COMP_CONFIG_LOG_LEVEL) +#undef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL COMP_CONFIG_LOG_LEVEL +#endif +#if defined(COMP_CONFIG_INFO_COLOR) +#undef NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR COMP_CONFIG_INFO_COLOR +#endif +#if defined(COMP_CONFIG_DEBUG_COLOR) +#undef NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR COMP_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(COMP_ENABLED) + +//------------------------------------------------------------------------------ +// GPIOTE + +#if defined(GPIOTE_ENABLED) + +#undef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED GPIOTE_ENABLED + +#if defined(GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS) +#undef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#endif + +#if defined(GPIOTE_CONFIG_IRQ_PRIORITY) +#undef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY GPIOTE_CONFIG_IRQ_PRIORITY +#endif + +#if defined(GPIOTE_CONFIG_LOG_ENABLED) +#undef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED GPIOTE_CONFIG_LOG_ENABLED +#endif +#if defined(GPIOTE_CONFIG_LOG_LEVEL) +#undef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL GPIOTE_CONFIG_LOG_LEVEL +#endif +#if defined(GPIOTE_CONFIG_INFO_COLOR) +#undef NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR GPIOTE_CONFIG_INFO_COLOR +#endif +#if defined(GPIOTE_CONFIG_DEBUG_COLOR) +#undef NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR GPIOTE_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(GPIOTE_ENABLED) + +//------------------------------------------------------------------------------ +// I2S + +#if defined(I2S_ENABLED) + +#undef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED I2S_ENABLED + +#if defined(I2S_CONFIG_SCK_PIN) +#undef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN I2S_CONFIG_SCK_PIN +#endif +#if defined(I2S_CONFIG_LRCK_PIN) +#undef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN I2S_CONFIG_LRCK_PIN +#endif +#if defined(I2S_CONFIG_MCK_PIN) +#undef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN I2S_CONFIG_MCK_PIN +#endif +#if defined(I2S_CONFIG_SDOUT_PIN) +#undef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN I2S_CONFIG_SDOUT_PIN +#endif +#if defined(I2S_CONFIG_SDIN_PIN) +#undef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN I2S_CONFIG_SDIN_PIN +#endif + +#if defined(I2S_CONFIG_MASTER) +#undef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER I2S_CONFIG_MASTER +#endif +#if defined(I2S_CONFIG_FORMAT) +#undef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT I2S_CONFIG_FORMAT +#endif +#if defined(I2S_CONFIG_ALIGN) +#undef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN I2S_CONFIG_ALIGN +#endif +#if defined(I2S_CONFIG_SWIDTH) +#undef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH I2S_CONFIG_SWIDTH +#endif +#if defined(I2S_CONFIG_CHANNELS) +#undef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS I2S_CONFIG_CHANNELS +#endif +#if defined(I2S_CONFIG_MCK_SETUP) +#undef NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP I2S_CONFIG_MCK_SETUP +#endif +#if defined(I2S_CONFIG_RATIO) +#undef NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO I2S_CONFIG_RATIO +#endif +#if defined(I2S_CONFIG_IRQ_PRIORITY) +#undef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY I2S_CONFIG_IRQ_PRIORITY +#endif + +#if defined(I2S_CONFIG_LOG_ENABLED) +#undef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED I2S_CONFIG_LOG_ENABLED +#endif +#if defined(I2S_CONFIG_LOG_LEVEL) +#undef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL I2S_CONFIG_LOG_LEVEL +#endif +#if defined(I2S_CONFIG_INFO_COLOR) +#undef NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR I2S_CONFIG_INFO_COLOR +#endif +#if defined(I2S_CONFIG_DEBUG_COLOR) +#undef NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR I2S_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(I2S_ENABLED) + +//------------------------------------------------------------------------------ +// LPCOMP + +#if defined(LPCOMP_ENABLED) + +#undef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED LPCOMP_ENABLED + +#if defined(LPCOMP_CONFIG_REFERENCE) +#undef NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE LPCOMP_CONFIG_REFERENCE +#endif +#if defined(LPCOMP_CONFIG_DETECTION) +#undef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION LPCOMP_CONFIG_DETECTION +#endif +#if defined(LPCOMP_CONFIG_INPUT) +#undef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT LPCOMP_CONFIG_INPUT +#endif +#if defined(LPCOMP_CONFIG_HYST) +#undef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST LPCOMP_CONFIG_HYST +#endif +#if defined(LPCOMP_CONFIG_IRQ_PRIORITY) +#undef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY LPCOMP_CONFIG_IRQ_PRIORITY +#endif + +#if defined(LPCOMP_CONFIG_LOG_ENABLED) +#undef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED LPCOMP_CONFIG_LOG_ENABLED +#endif +#if defined(LPCOMP_CONFIG_LOG_LEVEL) +#undef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL LPCOMP_CONFIG_LOG_LEVEL +#endif +#if defined(LPCOMP_CONFIG_INFO_COLOR) +#undef NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR LPCOMP_CONFIG_INFO_COLOR +#endif +#if defined(LPCOMP_CONFIG_DEBUG_COLOR) +#undef NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR LPCOMP_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(LPCOMP_ENABLED) + +//------------------------------------------------------------------------------ +// PDM + +#if defined(PDM_ENABLED) + +#undef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED PDM_ENABLED + +#if defined(PDM_CONFIG_MODE) +#undef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE PDM_CONFIG_MODE +#endif +#if defined(PDM_CONFIG_EDGE) +#undef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE PDM_CONFIG_EDGE +#endif +#if defined(PDM_CONFIG_CLOCK_FREQ) +#undef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ PDM_CONFIG_CLOCK_FREQ +#endif +#if defined(PDM_CONFIG_IRQ_PRIORITY) +#undef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY PDM_CONFIG_IRQ_PRIORITY +#endif + +#if defined(PDM_CONFIG_LOG_ENABLED) +#undef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED PDM_CONFIG_LOG_ENABLED +#endif +#if defined(PDM_CONFIG_LOG_LEVEL) +#undef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL PDM_CONFIG_LOG_LEVEL +#endif +#if defined(PDM_CONFIG_INFO_COLOR) +#undef NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR PDM_CONFIG_INFO_COLOR +#endif +#if defined(PDM_CONFIG_DEBUG_COLOR) +#undef NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR PDM_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(PDM_ENABLED) + +//------------------------------------------------------------------------------ +// POWER + +#if defined(POWER_ENABLED) + +#undef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED POWER_ENABLED + +#if defined(POWER_CONFIG_IRQ_PRIORITY) +#undef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY POWER_CONFIG_IRQ_PRIORITY +#endif + +#if defined(POWER_CONFIG_DEFAULT_DCDCEN) +#undef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN POWER_CONFIG_DEFAULT_DCDCEN +#endif +#if defined(POWER_CONFIG_DEFAULT_DCDCENHV) +#undef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV POWER_CONFIG_DEFAULT_DCDCENHV +#endif + +#endif // defined(POWER_ENABLED) + +//------------------------------------------------------------------------------ +// PPI + +#if defined(PPI_ENABLED) + +#undef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED PPI_ENABLED + +#if defined(PPI_CONFIG_LOG_ENABLED) +#undef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED PPI_CONFIG_LOG_ENABLED +#endif +#if defined(PPI_CONFIG_LOG_LEVEL) +#undef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL PPI_CONFIG_LOG_LEVEL +#endif +#if defined(PPI_CONFIG_INFO_COLOR) +#undef NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR PPI_CONFIG_INFO_COLOR +#endif +#if defined(PPI_CONFIG_DEBUG_COLOR) +#undef NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR PPI_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(PPI_ENABLED) + +//------------------------------------------------------------------------------ +// PWM + +#if defined(PWM_ENABLED) + +#undef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED PWM_ENABLED + +#if defined(PWM0_ENABLED) +#undef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED PWM0_ENABLED +#endif +#if defined(PWM1_ENABLED) +#undef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED PWM1_ENABLED +#endif +#if defined(PWM2_ENABLED) +#undef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED PWM2_ENABLED +#endif +#if defined(PWM3_ENABLED) +#undef NRFX_PWM3_ENABLED +#define NRFX_PWM3_ENABLED PWM3_ENABLED +#endif + +#if defined(PWM_DEFAULT_CONFIG_OUT0_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN PWM_DEFAULT_CONFIG_OUT0_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_OUT1_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN PWM_DEFAULT_CONFIG_OUT1_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_OUT2_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN PWM_DEFAULT_CONFIG_OUT2_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_OUT3_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN PWM_DEFAULT_CONFIG_OUT3_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_BASE_CLOCK) +#undef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK PWM_DEFAULT_CONFIG_BASE_CLOCK +#endif +#if defined(PWM_DEFAULT_CONFIG_COUNT_MODE) +#undef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE PWM_DEFAULT_CONFIG_COUNT_MODE +#endif +#if defined(PWM_DEFAULT_CONFIG_TOP_VALUE) +#undef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE PWM_DEFAULT_CONFIG_TOP_VALUE +#endif +#if defined(PWM_DEFAULT_CONFIG_LOAD_MODE) +#undef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE PWM_DEFAULT_CONFIG_LOAD_MODE +#endif +#if defined(PWM_DEFAULT_CONFIG_STEP_MODE) +#undef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE PWM_DEFAULT_CONFIG_STEP_MODE +#endif +#if defined(PWM_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(PWM_CONFIG_LOG_ENABLED) +#undef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED PWM_CONFIG_LOG_ENABLED +#endif +#if defined(PWM_CONFIG_LOG_LEVEL) +#undef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL PWM_CONFIG_LOG_LEVEL +#endif +#if defined(PWM_CONFIG_INFO_COLOR) +#undef NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR PWM_CONFIG_INFO_COLOR +#endif +#if defined(PWM_CONFIG_DEBUG_COLOR) +#undef NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR PWM_CONFIG_DEBUG_COLOR +#endif + +#if defined(PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif +#if defined(PWM_NRF52_ANOMALY_109_EGU_INSTANCE) +#undef NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#endif + +#endif // defined(PWM_ENABLED) + +//------------------------------------------------------------------------------ +// QDEC + +#if defined(QDEC_ENABLED) + +#undef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED QDEC_ENABLED + +#if defined(QDEC_CONFIG_REPORTPER) +#undef NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER QDEC_CONFIG_REPORTPER +#endif +#if defined(QDEC_CONFIG_SAMPLEPER) +#undef NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER QDEC_CONFIG_SAMPLEPER +#endif +#if defined(QDEC_CONFIG_PIO_A) +#undef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A QDEC_CONFIG_PIO_A +#endif +#if defined(QDEC_CONFIG_PIO_B) +#undef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B QDEC_CONFIG_PIO_B +#endif +#if defined(QDEC_CONFIG_PIO_LED) +#undef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED QDEC_CONFIG_PIO_LED +#endif +#if defined(QDEC_CONFIG_LEDPRE) +#undef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE QDEC_CONFIG_LEDPRE +#endif +#if defined(QDEC_CONFIG_LEDPOL) +#undef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL QDEC_CONFIG_LEDPOL +#endif +#if defined(QDEC_CONFIG_DBFEN) +#undef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN QDEC_CONFIG_DBFEN +#endif +#if defined(QDEC_CONFIG_SAMPLE_INTEN) +#undef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN QDEC_CONFIG_SAMPLE_INTEN +#endif +#if defined(QDEC_CONFIG_IRQ_PRIORITY) +#undef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY QDEC_CONFIG_IRQ_PRIORITY +#endif + +#if defined(QDEC_CONFIG_LOG_ENABLED) +#undef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED QDEC_CONFIG_LOG_ENABLED +#endif +#if defined(QDEC_CONFIG_LOG_LEVEL) +#undef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL QDEC_CONFIG_LOG_LEVEL +#endif +#if defined(QDEC_CONFIG_INFO_COLOR) +#undef NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR QDEC_CONFIG_INFO_COLOR +#endif +#if defined(QDEC_CONFIG_DEBUG_COLOR) +#undef NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR QDEC_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(QDEC_ENABLED) + +//------------------------------------------------------------------------------ +// QSPI + +#if defined(QSPI_ENABLED) + +#undef NRFX_QSPI_ENABLED +#define NRFX_QSPI_ENABLED QSPI_ENABLED + +#if defined(QSPI_CONFIG_SCK_DELAY) +#undef NRFX_QSPI_CONFIG_SCK_DELAY +#define NRFX_QSPI_CONFIG_SCK_DELAY QSPI_CONFIG_SCK_DELAY +#endif +#if defined(QSPI_CONFIG_XIP_OFFSET) +#undef NRFX_QSPI_CONFIG_XIP_OFFSET +#define NRFX_QSPI_CONFIG_XIP_OFFSET QSPI_CONFIG_XIP_OFFSET +#endif +#if defined(QSPI_CONFIG_READOC) +#undef NRFX_QSPI_CONFIG_READOC +#define NRFX_QSPI_CONFIG_READOC QSPI_CONFIG_READOC +#endif +#if defined(QSPI_CONFIG_WRITEOC) +#undef NRFX_QSPI_CONFIG_WRITEOC +#define NRFX_QSPI_CONFIG_WRITEOC QSPI_CONFIG_WRITEOC +#endif +#if defined(QSPI_CONFIG_ADDRMODE) +#undef NRFX_QSPI_CONFIG_ADDRMODE +#define NRFX_QSPI_CONFIG_ADDRMODE QSPI_CONFIG_ADDRMODE +#endif +#if defined(QSPI_CONFIG_MODE) +#undef NRFX_QSPI_CONFIG_MODE +#define NRFX_QSPI_CONFIG_MODE QSPI_CONFIG_MODE +#endif +#if defined(QSPI_CONFIG_FREQUENCY) +#undef NRFX_QSPI_CONFIG_FREQUENCY +#define NRFX_QSPI_CONFIG_FREQUENCY QSPI_CONFIG_FREQUENCY +#endif +#if defined(QSPI_CONFIG_IRQ_PRIORITY) +#undef NRFX_QSPI_CONFIG_IRQ_PRIORITY +#define NRFX_QSPI_CONFIG_IRQ_PRIORITY QSPI_CONFIG_IRQ_PRIORITY +#endif + +#if defined(QSPI_PIN_SCK) +#undef NRFX_QSPI_PIN_SCK +#define NRFX_QSPI_PIN_SCK QSPI_PIN_SCK +#endif +#if defined(QSPI_PIN_CSN) +#undef NRFX_QSPI_PIN_CSN +#define NRFX_QSPI_PIN_CSN QSPI_PIN_CSN +#endif +#if defined(QSPI_PIN_IO0) +#undef NRFX_QSPI_PIN_IO0 +#define NRFX_QSPI_PIN_IO0 QSPI_PIN_IO0 +#endif +#if defined(QSPI_PIN_IO0) +#undef NRFX_QSPI_PIN_IO0 +#define NRFX_QSPI_PIN_IO0 QSPI_PIN_IO0 +#endif +#if defined(QSPI_PIN_IO1) +#undef NRFX_QSPI_PIN_IO1 +#define NRFX_QSPI_PIN_IO1 QSPI_PIN_IO1 +#endif +#if defined(QSPI_PIN_IO2) +#undef NRFX_QSPI_PIN_IO2 +#define NRFX_QSPI_PIN_IO2 QSPI_PIN_IO2 +#endif +#if defined(QSPI_PIN_IO3) +#undef NRFX_QSPI_PIN_IO3 +#define NRFX_QSPI_PIN_IO3 QSPI_PIN_IO3 +#endif + +#endif // defined(QSPI_ENABLED) + +//------------------------------------------------------------------------------ +// RNG + +#if defined(RNG_ENABLED) + +#undef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED RNG_ENABLED + +#if defined(RNG_CONFIG_ERROR_CORRECTION) +#undef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION RNG_CONFIG_ERROR_CORRECTION +#endif + +#if defined(RNG_CONFIG_IRQ_PRIORITY) +#undef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY RNG_CONFIG_IRQ_PRIORITY +#endif + +#if defined(RNG_CONFIG_LOG_ENABLED) +#undef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED RNG_CONFIG_LOG_ENABLED +#endif +#if defined(RNG_CONFIG_LOG_LEVEL) +#undef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL RNG_CONFIG_LOG_LEVEL +#endif +#if defined(RNG_CONFIG_INFO_COLOR) +#undef NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR RNG_CONFIG_INFO_COLOR +#endif +#if defined(RNG_CONFIG_DEBUG_COLOR) +#undef NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR RNG_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(RNG_ENABLED) + +//------------------------------------------------------------------------------ +// RTC + +#if defined(RTC_ENABLED) + +#undef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED RTC_ENABLED + +#if defined(RTC0_ENABLED) +#undef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED RTC0_ENABLED +#endif +#if defined(RTC1_ENABLED) +#undef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED RTC1_ENABLED +#endif +#if defined(RTC2_ENABLED) +#undef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED RTC2_ENABLED +#endif + +#if defined(RTC_DEFAULT_CONFIG_FREQUENCY) +#undef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY RTC_DEFAULT_CONFIG_FREQUENCY +#endif +#if defined(RTC_DEFAULT_CONFIG_RELIABLE) +#undef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE RTC_DEFAULT_CONFIG_RELIABLE +#endif +#if defined(RTC_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(NRF_MAXIMUM_LATENCY_US) +#undef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US NRF_MAXIMUM_LATENCY_US +#endif + +#if defined(RTC_CONFIG_LOG_ENABLED) +#undef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED RTC_CONFIG_LOG_ENABLED +#endif +#if defined(RTC_CONFIG_LOG_LEVEL) +#undef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL RTC_CONFIG_LOG_LEVEL +#endif +#if defined(RTC_CONFIG_INFO_COLOR) +#undef NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR RTC_CONFIG_INFO_COLOR +#endif +#if defined(RTC_CONFIG_DEBUG_COLOR) +#undef NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR RTC_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(RTC_ENABLED) + +//------------------------------------------------------------------------------ +// SAADC + +#if defined(SAADC_ENABLED) + +#undef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED SAADC_ENABLED + +#if defined(SAADC_CONFIG_RESOLUTION) +#undef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION SAADC_CONFIG_RESOLUTION +#endif +#if defined(SAADC_CONFIG_OVERSAMPLE) +#undef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE SAADC_CONFIG_OVERSAMPLE +#endif +#if defined(SAADC_CONFIG_LP_MODE) +#undef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE SAADC_CONFIG_LP_MODE +#endif +#if defined(SAADC_CONFIG_IRQ_PRIORITY) +#undef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY SAADC_CONFIG_IRQ_PRIORITY +#endif + +#if defined(SAADC_CONFIG_LOG_ENABLED) +#undef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED SAADC_CONFIG_LOG_ENABLED +#endif +#if defined(SAADC_CONFIG_LOG_LEVEL) +#undef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL SAADC_CONFIG_LOG_LEVEL +#endif +#if defined(SAADC_CONFIG_INFO_COLOR) +#undef NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR SAADC_CONFIG_INFO_COLOR +#endif +#if defined(SAADC_CONFIG_DEBUG_COLOR) +#undef NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR SAADC_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(SAADC_ENABLED) + +//------------------------------------------------------------------------------ +// SPI + +#if defined(SPI_ENABLED) + +#undef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED \ + (SPI_ENABLED && (NRFX_SPI0_ENABLED || NRFX_SPI1_ENABLED || NRFX_SPI2_ENABLED)) +#undef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED \ + (SPI_ENABLED && (NRFX_SPIM0_ENABLED || NRFX_SPIM1_ENABLED || NRFX_SPIM2_ENABLED)) + +#if defined(SPI_PRESENT) && !defined(SPIM_PRESENT) + +#undef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED SPI0_ENABLED +#undef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 + +#undef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED SPI1_ENABLED +#undef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 + +#undef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED SPI2_ENABLED +#undef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 + +#elif !defined(SPI_PRESENT) && defined(SPIM_PRESENT) + +#undef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#undef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED SPI0_ENABLED + +#undef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#undef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED SPI1_ENABLED + +#undef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#undef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED SPI2_ENABLED + +#else // -> defined(SPI_PRESENT) && defined(SPIM_PRESENT) + +#undef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED (SPI0_ENABLED && !SPI0_USE_EASY_DMA) +#undef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED (SPI0_ENABLED && SPI0_USE_EASY_DMA) + +#undef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED (SPI1_ENABLED && !SPI1_USE_EASY_DMA) +#undef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED (SPI1_ENABLED && SPI1_USE_EASY_DMA) + +#undef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED (SPI2_ENABLED && !SPI2_USE_EASY_DMA) +#undef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED (SPI2_ENABLED && SPI2_USE_EASY_DMA) + +#endif // -> defined(SPI_PRESENT) && defined(SPIM_PRESENT) + +#if defined(NRF_SPI_DRV_MISO_PULLUP_CFG) +#undef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG NRF_SPI_DRV_MISO_PULLUP_CFG +#undef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG NRF_SPI_DRV_MISO_PULLUP_CFG +#endif + +#if defined(SPI_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#undef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(SPI_CONFIG_LOG_ENABLED) +#undef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED SPI_CONFIG_LOG_ENABLED +#undef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED SPI_CONFIG_LOG_ENABLED +#endif +#if defined(SPI_CONFIG_LOG_LEVEL) +#undef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL SPI_CONFIG_LOG_LEVEL +#undef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL SPI_CONFIG_LOG_LEVEL +#endif +#if defined(SPI_CONFIG_INFO_COLOR) +#undef NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR SPI_CONFIG_INFO_COLOR +#undef NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR SPI_CONFIG_INFO_COLOR +#endif +#if defined(SPI_CONFIG_DEBUG_COLOR) +#undef NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR SPI_CONFIG_DEBUG_COLOR +#undef NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR SPI_CONFIG_DEBUG_COLOR +#endif + +#if defined(SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif + +#endif // defined(SPI_ENABLED) + +//------------------------------------------------------------------------------ +// SPIS + +#if defined(SPIS_ENABLED) + +#undef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED SPIS_ENABLED + +#if defined(SPIS0_ENABLED) +#undef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED SPIS0_ENABLED +#endif +#if defined(SPIS1_ENABLED) +#undef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED SPIS1_ENABLED +#endif +#if defined(SPIS2_ENABLED) +#undef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED SPIS2_ENABLED +#endif + +#if defined(SPIS_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#endif +#if defined(SPIS_DEFAULT_MODE) +#undef NRFX_SPIS_DEFAULT_MODE +#define NRFX_SPIS_DEFAULT_MODE SPIS_DEFAULT_MODE +#endif +#if defined(SPIS_DEFAULT_BIT_ORDER) +#undef NRFX_SPIS_DEFAULT_BIT_ORDER +#define NRFX_SPIS_DEFAULT_BIT_ORDER SPIS_DEFAULT_BIT_ORDER +#endif +#if defined(SPIS_DEFAULT_DEF) +#undef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF SPIS_DEFAULT_DEF +#endif +#if defined(SPIS_DEFAULT_ORC) +#undef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC SPIS_DEFAULT_ORC +#endif + +#if defined(SPIS_CONFIG_LOG_ENABLED) +#undef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED SPIS_CONFIG_LOG_ENABLED +#endif +#if defined(SPIS_CONFIG_LOG_LEVEL) +#undef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL SPIS_CONFIG_LOG_LEVEL +#endif +#if defined(SPIS_CONFIG_INFO_COLOR) +#undef NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR SPIS_CONFIG_INFO_COLOR +#endif +#if defined(SPIS_CONFIG_DEBUG_COLOR) +#undef NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR SPIS_CONFIG_DEBUG_COLOR +#endif + +#if defined(SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif + +#endif // defined(SPIS_ENABLED) + +//------------------------------------------------------------------------------ +// SWI + +#if defined(SWI_DISABLE0) +#undef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 1 +#endif +#if defined(SWI_DISABLE1) +#undef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 1 +#endif +#if defined(SWI_DISABLE2) +#undef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 1 +#endif +#if defined(SWI_DISABLE3) +#undef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 1 +#endif +#if defined(SWI_DISABLE4) +#undef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 1 +#endif +#if defined(SWI_DISABLE5) +#undef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 1 +#endif + +#if defined(EGU_ENABLED) +#undef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED EGU_ENABLED +#endif + +#if defined(SWI_CONFIG_LOG_ENABLED) +#undef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED SWI_CONFIG_LOG_ENABLED +#endif +#if defined(SWI_CONFIG_LOG_LEVEL) +#undef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL SWI_CONFIG_LOG_LEVEL +#endif +#if defined(SWI_CONFIG_INFO_COLOR) +#undef NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR SWI_CONFIG_INFO_COLOR +#endif +#if defined(SWI_CONFIG_DEBUG_COLOR) +#undef NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR SWI_CONFIG_DEBUG_COLOR +#endif + +//------------------------------------------------------------------------------ +// SysTick + +#if defined(SYSTICK_ENABLED) + +#undef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED SYSTICK_ENABLED + +#endif // defined(SYSTICK_ENABLED) + +//------------------------------------------------------------------------------ +// TIMER + +#if defined(TIMER_ENABLED) + +#undef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED TIMER_ENABLED + +#if defined(TIMER0_ENABLED) +#undef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED TIMER0_ENABLED +#endif +#if defined(TIMER1_ENABLED) +#undef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED TIMER1_ENABLED +#endif +#if defined(TIMER2_ENABLED) +#undef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED TIMER2_ENABLED +#endif +#if defined(TIMER3_ENABLED) +#undef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED TIMER3_ENABLED +#endif +#if defined(TIMER4_ENABLED) +#undef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED TIMER4_ENABLED +#endif + +#if defined(TIMER_DEFAULT_CONFIG_FREQUENCY) +#undef NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY TIMER_DEFAULT_CONFIG_FREQUENCY +#endif +#if defined(TIMER_DEFAULT_CONFIG_MODE) +#undef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE TIMER_DEFAULT_CONFIG_MODE +#endif +#if defined(TIMER_DEFAULT_CONFIG_BIT_WIDTH) +#undef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH TIMER_DEFAULT_CONFIG_BIT_WIDTH +#endif +#if defined(TIMER_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(TIMER_CONFIG_LOG_ENABLED) +#undef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED TIMER_CONFIG_LOG_ENABLED +#endif +#if defined(TIMER_CONFIG_LOG_LEVEL) +#undef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL TIMER_CONFIG_LOG_LEVEL +#endif +#if defined(TIMER_CONFIG_INFO_COLOR) +#undef NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR TIMER_CONFIG_INFO_COLOR +#endif +#if defined(TIMER_CONFIG_DEBUG_COLOR) +#undef NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR TIMER_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(TIMER_ENABLED) + +//------------------------------------------------------------------------------ +// TWI +#define TWI_ONLY ( defined(TWI_PRESENT) && !defined(TWIM_PRESENT)) +#define TWIM_ONLY (!defined(TWI_PRESENT) && defined(TWIM_PRESENT)) +#define TWI_AND_TWIM ( defined(TWI_PRESENT) && defined(TWIM_PRESENT)) + +#if defined(TWI_ENABLED) + +#undef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED (TWI_ENABLED && (NRFX_TWI0_ENABLED || NRFX_TWI1_ENABLED)) +#undef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED (TWI_ENABLED && (NRFX_TWIM0_ENABLED || NRFX_TWIM1_ENABLED)) + +#if defined(TWI_PRESENT) && !defined(TWIM_PRESENT) + +#undef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED TWI0_ENABLED +#undef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 + +#undef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED TWI1_ENABLED +#undef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 + +#elif !defined(TWI_PRESENT) && defined(TWIM_PRESENT) + +#undef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#undef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED TWI0_ENABLED + +#undef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#undef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED TWI1_ENABLED + +#else // -> defined(TWI_PRESENT) && defined(TWIM_PRESENT) + +#undef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED (TWI0_ENABLED && !TWI0_USE_EASY_DMA) +#undef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED (TWI0_ENABLED && TWI0_USE_EASY_DMA) + +#undef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED (TWI1_ENABLED && !TWI1_USE_EASY_DMA) +#undef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED (TWI1_ENABLED && TWI1_USE_EASY_DMA) + +#endif // -> defined(TWI_PRESENT) && defined(TWIM_PRESENT) + +#if defined(TWI_DEFAULT_CONFIG_FREQUENCY) +#undef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY TWI_DEFAULT_CONFIG_FREQUENCY +#undef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY TWI_DEFAULT_CONFIG_FREQUENCY +#endif +#if defined(TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT) +#undef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#undef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#endif +#if defined(TWI_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#undef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(TWI_CONFIG_LOG_ENABLED) +#undef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED TWI_CONFIG_LOG_ENABLED +#undef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED TWI_CONFIG_LOG_ENABLED +#endif +#if defined(TWI_CONFIG_LOG_LEVEL) +#undef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL TWI_CONFIG_LOG_LEVEL +#undef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL TWI_CONFIG_LOG_LEVEL +#endif +#if defined(TWI_CONFIG_INFO_COLOR) +#undef NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR TWI_CONFIG_INFO_COLOR +#undef NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR TWI_CONFIG_INFO_COLOR +#endif +#if defined(TWI_CONFIG_DEBUG_COLOR) +#undef NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR TWI_CONFIG_DEBUG_COLOR +#undef NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR TWI_CONFIG_DEBUG_COLOR +#endif + +#if defined(TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif + +#endif // defined(TWI_ENABLED) + +//------------------------------------------------------------------------------ +// TWIS + +#if defined(TWIS_ENABLED) + +#undef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED TWIS_ENABLED + +#if defined(TWIS0_ENABLED) +#undef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED TWIS0_ENABLED +#endif +#if defined(TWIS1_ENABLED) +#undef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED TWIS1_ENABLED +#endif + +#if defined(TWIS_ASSUME_INIT_AFTER_RESET_ONLY) +#undef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#endif +#if defined(TWIS_NO_SYNC_MODE) +#undef NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE TWIS_NO_SYNC_MODE +#endif + +#if defined(TWIS_DEFAULT_CONFIG_ADDR0) +#undef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 TWIS_DEFAULT_CONFIG_ADDR0 +#endif +#if defined(TWIS_DEFAULT_CONFIG_ADDR1) +#undef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 TWIS_DEFAULT_CONFIG_ADDR1 +#endif +#if defined(TWIS_DEFAULT_CONFIG_SCL_PULL) +#undef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL TWIS_DEFAULT_CONFIG_SCL_PULL +#endif +#if defined(TWIS_DEFAULT_CONFIG_SDA_PULL) +#undef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL TWIS_DEFAULT_CONFIG_SDA_PULL +#endif +#if defined(TWIS_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(TWIS_CONFIG_LOG_ENABLED) +#undef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED TWIS_CONFIG_LOG_ENABLED +#endif +#if defined(TWIS_CONFIG_LOG_LEVEL) +#undef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL TWIS_CONFIG_LOG_LEVEL +#endif +#if defined(TWIS_CONFIG_INFO_COLOR) +#undef NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR TWIS_CONFIG_INFO_COLOR +#endif +#if defined(TWIS_CONFIG_DEBUG_COLOR) +#undef NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR TWIS_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(TWIS_ENABLED) + +//------------------------------------------------------------------------------ +// UART + +#if defined(UART_ENABLED) + +#undef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED (UART_ENABLED && NRFX_UART0_ENABLED) +#undef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED (UART_ENABLED && (NRFX_UARTE0_ENABLED || NRFX_UARTE1_ENABLED)) + +#if defined(UART0_ENABLED) +#undef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED (UART0_ENABLED && UART_LEGACY_SUPPORT) +#undef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED (UART0_ENABLED && UART_EASY_DMA_SUPPORT) +#endif +#if defined(UART1_ENABLED) +#undef NRFX_UARTE1_ENABLED +#define NRFX_UARTE1_ENABLED (UART1_ENABLED && UART_EASY_DMA_SUPPORT) +#endif + +#if defined(UART_DEFAULT_CONFIG_HWFC) +#undef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC UART_DEFAULT_CONFIG_HWFC +#undef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC UART_DEFAULT_CONFIG_HWFC +#endif +#if defined(UART_DEFAULT_CONFIG_PARITY) +#undef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY UART_DEFAULT_CONFIG_PARITY +#undef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY UART_DEFAULT_CONFIG_PARITY +#endif +#if defined(UART_DEFAULT_CONFIG_BAUDRATE) +#undef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE UART_DEFAULT_CONFIG_BAUDRATE +#undef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE UART_DEFAULT_CONFIG_BAUDRATE +#endif +#if defined(UART_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY UART_DEFAULT_CONFIG_IRQ_PRIORITY +#undef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY UART_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(UART_CONFIG_LOG_ENABLED) +#undef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED UART_CONFIG_LOG_ENABLED +#undef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED UART_CONFIG_LOG_ENABLED +#endif +#if defined(UART_CONFIG_LOG_LEVEL) +#undef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL UART_CONFIG_LOG_LEVEL +#undef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL UART_CONFIG_LOG_LEVEL +#endif +#if defined(UART_CONFIG_INFO_COLOR) +#undef NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR UART_CONFIG_INFO_COLOR +#undef NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR UART_CONFIG_INFO_COLOR +#endif +#if defined(UART_CONFIG_DEBUG_COLOR) +#undef NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR UART_CONFIG_DEBUG_COLOR +#undef NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR UART_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(UART_ENABLED) + +//------------------------------------------------------------------------------ +// WDT + +#if defined(WDT_ENABLED) + +#undef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED WDT_ENABLED + +#if defined(WDT_CONFIG_BEHAVIOUR) +#undef NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR WDT_CONFIG_BEHAVIOUR +#endif +#if defined(WDT_CONFIG_RELOAD_VALUE) +#undef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE WDT_CONFIG_RELOAD_VALUE +#endif +#if defined(WDT_CONFIG_IRQ_PRIORITY) +#undef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY WDT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(WDT_CONFIG_LOG_ENABLED) +#undef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED WDT_CONFIG_LOG_ENABLED +#endif +#if defined(WDT_CONFIG_LOG_LEVEL) +#undef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL WDT_CONFIG_LOG_LEVEL +#endif +#if defined(WDT_CONFIG_INFO_COLOR) +#undef NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR WDT_CONFIG_INFO_COLOR +#endif +#if defined(WDT_CONFIG_DEBUG_COLOR) +#undef NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR WDT_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(WDT_ENABLED) + +#endif // APPLY_OLD_CONFIG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock/nrf_drv_clock.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_clock.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock/nrf_drv_clock.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_clock.c index cb02c3c..cc3a07c 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock/nrf_drv_clock.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_clock.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,38 +35,37 @@ * 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(CLOCK) +#include #include "nrf_drv_clock.h" -#include "nrf_error.h" -#include "app_util_platform.h" + +#if NRF_MODULE_ENABLED(NRF_CLOCK) + #ifdef SOFTDEVICE_PRESENT #include "nrf_sdh.h" #include "nrf_sdh_soc.h" #endif #define NRF_LOG_MODULE_NAME clock - #if CLOCK_CONFIG_LOG_ENABLED -#define NRF_LOG_LEVEL CLOCK_CONFIG_LOG_LEVEL -#define NRF_LOG_INFO_COLOR CLOCK_CONFIG_INFO_COLOR -#define NRF_LOG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR -#define EVT_TO_STR(event) (event == NRF_CLOCK_EVENT_HFCLKSTARTED ? "NRF_CLOCK_EVENT_HFCLKSTARTED" : \ - (event == NRF_CLOCK_EVENT_LFCLKSTARTED ? "NRF_CLOCK_EVENT_LFCLKSTARTED" : \ - (event == NRF_CLOCK_EVENT_DONE ? "NRF_CLOCK_EVENT_DONE" : \ - (event == NRF_CLOCK_EVENT_CTTO ? "NRF_CLOCK_EVENT_CTTO" : "UNKNOWN EVENT")))) + #define NRF_LOG_LEVEL CLOCK_CONFIG_LOG_LEVEL + #define NRF_LOG_INFO_COLOR CLOCK_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR #else //CLOCK_CONFIG_LOG_ENABLED -#define EVT_TO_STR(event) "" -#define NRF_LOG_LEVEL 0 + #define NRF_LOG_LEVEL 0 #endif //CLOCK_CONFIG_LOG_ENABLED #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -/* Validate configuration */ -INTERRUPT_PRIORITY_VALIDATION(CLOCK_CONFIG_IRQ_PRIORITY); +#define EVT_TO_STR(event) \ + (event == NRF_CLOCK_EVENT_HFCLKSTARTED ? "NRF_CLOCK_EVENT_HFCLKSTARTED" : \ + (event == NRF_CLOCK_EVENT_LFCLKSTARTED ? "NRF_CLOCK_EVENT_LFCLKSTARTED" : \ + (event == NRF_CLOCK_EVENT_DONE ? "NRF_CLOCK_EVENT_DONE" : \ + (event == NRF_CLOCK_EVENT_CTTO ? "NRF_CLOCK_EVENT_CTTO" : \ + "UNKNOWN EVENT")))) + /*lint -save -e652 */ #define NRF_CLOCK_LFCLK_RC CLOCK_LFCLKSRC_SRC_RC @@ -107,22 +106,12 @@ typedef struct static nrf_drv_clock_cb_t m_clock_cb; +static void clock_irq_handler(nrfx_clock_evt_type_t evt); -/**@brief Function for starting LFCLK. This function will return immediately without waiting for start. - */ -static void lfclk_start(void) -{ - nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); - nrf_clock_int_enable(NRF_CLOCK_INT_LF_STARTED_MASK); - nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); -} - -/**@brief Function for stopping LFCLK and calibration (if it was set up). - */ static void lfclk_stop(void) { #if CALIBRATION_SUPPORT - (void)nrf_drv_clock_calibration_abort(); + nrfx_clock_calibration_timer_stop(); #endif #ifdef SOFTDEVICE_PRESENT @@ -132,9 +121,7 @@ static void lfclk_stop(void) ASSERT(!nrf_sdh_is_enabled()); #endif // SOFTDEVICE_PRESENT - nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTOP); - while (nrf_clock_lf_is_running()) - {} + nrfx_clock_lfclk_stop(); m_clock_cb.lfclk_on = false; } @@ -148,9 +135,7 @@ static void hfclk_start(void) } #endif // SOFTDEVICE_PRESENT - nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED); - nrf_clock_int_enable(NRF_CLOCK_INT_HF_STARTED_MASK); - nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART); + nrfx_clock_hfclk_start(); } static void hfclk_stop(void) @@ -159,13 +144,12 @@ static void hfclk_stop(void) if (nrf_sdh_is_enabled()) { (void)sd_clock_hfclk_release(); + m_clock_cb.hfclk_on = false; return; } #endif // SOFTDEVICE_PRESENT - nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP); - while (nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY)) - {} + nrfx_clock_hfclk_stop(); m_clock_cb.hfclk_on = false; } @@ -187,12 +171,12 @@ ret_code_t nrf_drv_clock_init(void) m_clock_cb.hfclk_requests = 0; m_clock_cb.p_lf_head = NULL; m_clock_cb.lfclk_requests = 0; - nrf_drv_common_power_clock_irq_init(); + err_code = nrfx_clock_init(clock_irq_handler); #ifdef SOFTDEVICE_PRESENT if (!nrf_sdh_is_enabled()) #endif { - nrf_clock_lf_src_set((nrf_clock_lfclk_t)CLOCK_CONFIG_LF_SRC); + nrfx_clock_enable(); } #if CALIBRATION_SUPPORT @@ -203,24 +187,22 @@ ret_code_t nrf_drv_clock_init(void) } NRF_LOG_INFO("Function: %s, error code: %s.", - (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; } void nrf_drv_clock_uninit(void) { ASSERT(m_clock_cb.module_initialized); - nrf_drv_common_clock_irq_disable(); - nrf_clock_int_disable(0xFFFFFFFF); + nrfx_clock_disable(); + nrfx_clock_uninit(); - lfclk_stop(); - hfclk_stop(); m_clock_cb.module_initialized = false; - NRF_LOG_INFO("Uninitialized."); } static void item_enqueue(nrf_drv_clock_handler_item_t ** p_head, - nrf_drv_clock_handler_item_t * p_item) + nrf_drv_clock_handler_item_t * p_item) { nrf_drv_clock_handler_item_t * p_next = *p_head; while (p_next) @@ -270,7 +252,7 @@ void nrf_drv_clock_lfclk_request(nrf_drv_clock_handler_item_t * p_handler_item) } if (m_clock_cb.lfclk_requests == 0) { - lfclk_start(); + nrfx_clock_lfclk_start(); } ++(m_clock_cb.lfclk_requests); CRITICAL_REGION_EXIT(); @@ -304,7 +286,7 @@ bool nrf_drv_clock_lfclk_is_running(void) } #endif // SOFTDEVICE_PRESENT - return nrf_clock_lf_is_running(); + return nrfx_clock_lfclk_is_running(); } void nrf_drv_clock_hfclk_request(nrf_drv_clock_handler_item_t * p_handler_item) @@ -367,7 +349,7 @@ bool nrf_drv_clock_hfclk_is_running(void) } #endif // SOFTDEVICE_PRESENT - return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY); + return nrfx_clock_hfclk_is_running(); } #if CALIBRATION_SUPPORT @@ -384,10 +366,11 @@ static void clock_calibration_hf_started(nrf_drv_clock_evt_type_t event) } else { - nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE); - nrf_clock_int_enable(NRF_CLOCK_INT_DONE_MASK); - m_clock_cb.cal_state = CAL_STATE_CAL; - nrf_clock_task_trigger(NRF_CLOCK_TASK_CAL); + ASSERT(event == NRF_DRV_CLOCK_EVT_HFCLK_STARTED); + if (nrfx_clock_calibration_start() != NRFX_SUCCESS) + { + ASSERT(false); + } } } #endif // CALIBRATION_SUPPORT @@ -413,21 +396,24 @@ ret_code_t nrf_drv_clock_calibration_start(uint8_t interval, nrf_drv_clock_event else { m_clock_cb.cal_state = CAL_STATE_CT; - nrf_clock_cal_timer_timeout_set(interval); - nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); - nrf_clock_int_enable(NRF_CLOCK_INT_CTTO_MASK); - nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTART); + nrfx_clock_calibration_timer_start(interval); } } else { err_code = NRF_ERROR_BUSY; } - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; #else + UNUSED_PARAMETER(interval); + UNUSED_PARAMETER(handler); err_code = NRF_ERROR_FORBIDDEN; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; #endif // CALIBRATION_SUPPORT } @@ -440,8 +426,7 @@ ret_code_t nrf_drv_clock_calibration_abort(void) switch (m_clock_cb.cal_state) { case CAL_STATE_CT: - nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK); - nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTOP); + nrfx_clock_calibration_timer_stop(); m_clock_cb.cal_state = CAL_STATE_IDLE; if (m_clock_cb.cal_done_handler) { @@ -458,11 +443,15 @@ ret_code_t nrf_drv_clock_calibration_abort(void) } CRITICAL_REGION_EXIT(); - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + NRF_LOG_INFO("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; #else err_code = NRF_ERROR_FORBIDDEN; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; #endif // CALIBRATION_SUPPORT } @@ -473,11 +462,16 @@ ret_code_t nrf_drv_clock_is_calibrating(bool * p_is_calibrating) #if CALIBRATION_SUPPORT ASSERT(m_clock_cb.module_initialized); *p_is_calibrating = (m_clock_cb.cal_state != CAL_STATE_IDLE); - NRF_LOG_INFO("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + NRF_LOG_INFO("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; #else + UNUSED_PARAMETER(p_is_calibrating); err_code = NRF_ERROR_FORBIDDEN; - NRF_LOG_WARNING("Function: %s, error code: %s.", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); return err_code; #endif // CALIBRATION_SUPPORT } @@ -506,42 +500,26 @@ __STATIC_INLINE void clock_clk_started_notify(nrf_drv_clock_evt_type_t evt_type) } } -#if NRF_DRV_COMMON_POWER_CLOCK_ISR -void nrf_drv_clock_onIRQ(void) -#else -void POWER_CLOCK_IRQHandler(void) -#endif +static void clock_irq_handler(nrfx_clock_evt_type_t evt) { - if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED)) + if (evt == NRFX_CLOCK_EVT_HFCLK_STARTED) { - nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_HFCLKSTARTED)); - nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK); m_clock_cb.hfclk_on = true; clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED); } - if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED)) + if (evt == NRFX_CLOCK_EVT_LFCLK_STARTED) { - nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_LFCLKSTARTED)); - nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK); m_clock_cb.lfclk_on = true; clock_clk_started_notify(NRF_DRV_CLOCK_EVT_LFCLK_STARTED); } #if CALIBRATION_SUPPORT - if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO)) + if (evt == NRFX_CLOCK_EVT_CTTO) { - nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_CTTO)); - nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK); nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); } - if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE)) + if (evt == NRFX_CLOCK_EVT_CAL_DONE) { - nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE); - NRF_LOG_DEBUG("Event: %s.", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_DONE)); - nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK); nrf_drv_clock_hfclk_release(); bool aborted = (m_clock_cb.cal_state == CAL_STATE_ABORT); m_clock_cb.cal_state = CAL_STATE_IDLE; @@ -565,10 +543,10 @@ static void soc_evt_handler(uint32_t evt_id, void * p_context) { if (evt_id == NRF_EVT_HFCLKSTARTED) { + m_clock_cb.hfclk_on = true; clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED); } } - NRF_SDH_SOC_OBSERVER(m_soc_evt_observer, CLOCK_CONFIG_SOC_OBSERVER_PRIO, soc_evt_handler, NULL); /** @@ -601,7 +579,7 @@ static void sd_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context) case NRF_SDH_EVT_STATE_DISABLED: /* Reinit interrupts */ ASSERT(m_clock_cb.module_initialized); - nrf_drv_common_irq_enable(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY); + nrfx_clock_enable(); /* SD leaves LFCLK enabled - disable it if it is no longer required. */ nrf_drv_clock_lfclk_release(); @@ -624,4 +602,4 @@ NRF_SDH_STATE_OBSERVER(m_sd_state_observer, CLOCK_CONFIG_STATE_OBSERVER_PRIO) = #undef NRF_CLOCK_LFCLK_Xtal #undef NRF_CLOCK_LFCLK_Synth -#endif // NRF_MODULE_ENABLED(CLOCK) +#endif // NRF_MODULE_ENABLED(NRF_CLOCK) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock/nrf_drv_clock.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_clock.h similarity index 78% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock/nrf_drv_clock.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_clock.h index be2831b..53c0ec8 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/clock/nrf_drv_clock.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_clock.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,35 +35,23 @@ * 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 NRF_DRV_CLOCK_H__ #define NRF_DRV_CLOCK_H__ -#include -#include -#include "sdk_errors.h" -#include "nrf_assert.h" -#include "nrf_clock.h" -#include "sdk_config.h" -#include "nrf_drv_common.h" +#include #ifdef __cplusplus extern "C" { #endif /** - * - * @addtogroup nrf_clock Clock HAL and driver - * @ingroup nrf_drivers - * @brief Clock APIs. - * @details The clock HAL provides basic APIs for accessing the registers of the clock. - * The clock driver provides APIs on a higher level. - * - * @defgroup nrf_drv_clock Clock driver + * @defgroup nrf_drv_clock Clock driver - legacy layer * @{ * @ingroup nrf_clock - * @brief Driver for managing the low-frequency clock (LFCLK) and the high-frequency clock (HFCLK). + * + * @brief Layer providing compatibility with the former API. */ /** @@ -96,9 +84,6 @@ struct nrf_drv_clock_handler_item_s /** * @brief Function for checking if driver is already initialized * - * This function is used to check whatever common POWER_CLOCK common interrupt - * should be disabled or not if @ref nrf_drv_power tries to disable the interrupt. - * * @retval true Driver is initialized * @retval false Driver is uninitialized */ @@ -109,8 +94,8 @@ bool nrf_drv_clock_init_check(void); * * After initialization, the module is in power off state (clocks are not requested). * - * @retval NRF_SUCCESS If the procedure was successful. - * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the driver was already initialized. + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the driver was already initialized. */ ret_code_t nrf_drv_clock_init(void); @@ -155,7 +140,7 @@ void nrf_drv_clock_lfclk_release(void); /** * @brief Function for checking the LFCLK state. * - * @retval true If the LFCLK is running. + * @retval true If the LFCLK is running. * @retval false If the LFCLK is not running. */ bool nrf_drv_clock_lfclk_is_running(void); @@ -209,13 +194,13 @@ bool nrf_drv_clock_hfclk_is_running(void); * - Requesting the high-accuracy HFCLK * - Hardware-supported calibration * - * @param[in] delay Time after which the calibration will be started (in 0.25 s units). - * @param[in] handler NULL or user function to be called when calibration is completed or aborted. + * @param[in] delay Time after which the calibration will be started (in 0.25 s units). + * @param[in] handler NULL or user function to be called when calibration is completed or aborted. * - * @retval NRF_SUCCESS If the procedure was successful. - * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. - * @retval NRF_ERROR_INVALID_STATE If the low-frequency clock is off. - * @retval NRF_ERROR_BUSY If calibration is in progress. + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. + * @retval NRF_ERROR_INVALID_STATE If the low-frequency clock is off. + * @retval NRF_ERROR_BUSY If calibration is in progress. */ ret_code_t nrf_drv_clock_calibration_start(uint8_t delay, nrf_drv_clock_event_handler_t handler); @@ -227,8 +212,8 @@ ret_code_t nrf_drv_clock_calibration_start(uint8_t delay, nrf_drv_clock_event_ha * aborted calibration is completed. @ref nrf_drv_clock_is_calibrating can also be used to check * if the system is calibrating. * - * @retval NRF_SUCCESS If the procedure was successful. - * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. */ ret_code_t nrf_drv_clock_calibration_abort(void); @@ -238,28 +223,57 @@ ret_code_t nrf_drv_clock_calibration_abort(void); * This function indicates that the system is * in calibration if it is in any of the calibration process phases (see @ref nrf_drv_clock_calibration_start). * - * @param[out] p_is_calibrating True if calibration is in progress, false if not. + * @param[out] p_is_calibrating True if calibration is in progress, false if not. * - * @retval NRF_SUCCESS If the procedure was successful. - * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. */ ret_code_t nrf_drv_clock_is_calibrating(bool * p_is_calibrating); /**@brief Function for returning a requested task address for the clock driver module. * - * @param[in] task One of the peripheral tasks. + * @param[in] task One of the peripheral tasks. * - * @return Task address. + * @return Task address. */ __STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr(nrf_clock_task_t task); /**@brief Function for returning a requested event address for the clock driver module. * - * @param[in] event One of the peripheral events. + * @param[in] event One of the peripheral events. * - * @return Event address. + * @return Event address. */ __STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr(nrf_clock_event_t event); + + +#ifdef SOFTDEVICE_PRESENT +/** + * @brief Function called by the SoftDevice handler if an @ref NRF_SOC_EVTS event is received from the SoftDevice. + * + * @param[in] evt_id One of NRF_SOC_EVTS values. + */ +void nrf_drv_clock_on_soc_event(uint32_t evt_id); + +/** + * @brief Function called by the SoftDevice handler when the SoftDevice has been enabled. + * + * This function is called just after the SoftDevice has been properly enabled. + * Its main purpose is to mark that LFCLK has been requested by SD. + */ +void nrf_drv_clock_on_sd_enable(void); + +/** + * @brief Function called by the SoftDevice handler when the SoftDevice has been disabled. + * + * This function is called just after the SoftDevice has been properly disabled. + * It has two purposes: + * 1. Releases the LFCLK from the SD. + * 2. Reinitializes an interrupt after the SD releases POWER_CLOCK_IRQ. + */ +void nrf_drv_clock_on_sd_disable(void); + +#endif /** *@} **/ @@ -276,10 +290,8 @@ __STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr(nrf_clock_event_t event) } #endif //SUPPRESS_INLINE_IMPLEMENTATION -/*lint --flb "Leave library region" */ - #ifdef __cplusplus } #endif -#endif // NRF_CLOCK_H__ +#endif // NRF_DRV_CLOCK_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_common.h similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_common.h index 537d04a..909562f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/micro_ecc/micro_ecc_lib_init.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_common.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,35 +35,29 @@ * 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 MICRO_ECC_LIB_INIT_H__ -#define MICRO_ECC_LIB_INIT_H__ - -/** @file - * - * @defgroup nrf_crypto_backend_micro_ecc_lib_init micro-ecc backend initialization types. - * @{ - * @ingroup nrf_crypto_backend_microecc * - * @brief Provides types required for CC310 backend initialization. */ -#include "nrf_crypto_init.h" +#ifndef NRF_DRV_COMMON_H__ +#define NRF_DRV_COMMON_H__ + +#include #ifdef __cplusplus extern "C" { #endif +#define INTERRUPT_PRIORITY_VALIDATION(pri) STATIC_ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri))) +#define INTERRUPT_PRIORITY_ASSERT(pri) ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri))) -/** @brief Size of buffer required to initalize nrf_crypto micro_ecc backend. - */ -#define NRF_CRYPTO_INIT_RAM_BUFFER (0) +#define nrf_drv_irq_handler_t nrfx_irq_handler_t +#define nrf_drv_bitpos_to_event nrfx_bitpos_to_event +#define nrf_drv_event_to_bitpos nrfx_event_to_bitpos +#define nrf_drv_get_IRQn nrfx_get_irq_number +#define nrf_drv_is_in_RAM nrfx_is_in_ram #ifdef __cplusplus } #endif -/**@} */ - -#endif // MICRO_ECC_LIB_INIT_H__ +#endif // NRF_DRV_COMMON_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_comp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_comp.h new file mode 100644 index 0000000..1729555 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_comp.h @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_COMP_H__ +#define NRF_DRV_COMP_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_comp COMP driver - legacy layer + * @{ + * @ingroup nrf_comp + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_comp_config_t nrf_drv_comp_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define VOLTAGE_THRESHOLD_TO_INT NRFX_VOLTAGE_THRESHOLD_TO_INT +/** @brief Macro for forwarding the new implementation. */ +#define COMP_CONFIG_TH NRFX_COMP_CONFIG_TH +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_DEFAULT_CONFIG NRFX_COMP_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define comp_events_handler_t nrfx_comp_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_SHORT_STOP_AFTER_CROSS_EVT NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_SHORT_STOP_AFTER_UP_EVT NRFX_COMP_SHORT_STOP_AFTER_UP_EVT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_short_mask_t nrfx_comp_short_mask_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_CROSS_MASK NRFX_COMP_EVT_EN_CROSS_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_UP_MASK NRFX_COMP_EVT_EN_UP_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_DOWN_MASK NRFX_COMP_EVT_EN_DOWN_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_READY_MASK NRFX_COMP_EVT_EN_READY_MASK +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_evt_en_mask_t nrfx_comp_evt_en_mask_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_uninit nrfx_comp_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_pin_select nrfx_comp_pin_select +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_start nrfx_comp_start +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_stop nrfx_comp_stop +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_sample nrfx_comp_sample + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_task_address_get nrfx_comp_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_event_address_get nrfx_comp_event_address_get + +/** + * @brief Function for initializing the COMP driver. + * + * This function initializes the COMP driver, but does not enable the peripheral or any interrupts. + * To start the driver, call the function @ref nrf_drv_comp_start() after initialization. + * + * If no configuration structure is provided, the driver is initialized with the default settings. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] event_handler Handler function. + * + * @retval NRF_ERROR_INVALID_PARAM If the configuration is invalid. + * @retval NRF_ERROR_INVALID_STATE If the driver has already been initialized. + * @retval NRF_ERROR_BUSY If the LPCOMP driver is initialized. + */ +__STATIC_INLINE ret_code_t nrf_drv_comp_init(nrf_drv_comp_config_t const * p_config, + comp_events_handler_t event_handler) +{ + if (p_config == NULL) + { + static nrfx_comp_config_t const default_config = NRFX_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_0); + p_config = &default_config; + } + return nrfx_comp_init(p_config, event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_COMP_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_gpiote.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_gpiote.h new file mode 100644 index 0000000..8c96067 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_gpiote.h @@ -0,0 +1,139 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_GPIOTE_H__ +#define NRF_DRV_GPIOTE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_gpiote GPIOTE driver - legacy layer + * @{ + * @ingroup nrf_gpiote + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_in_config_t nrf_drv_gpiote_in_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_pin_t nrf_drv_gpiote_pin_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_out_config_t nrf_drv_gpiote_out_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_evt_handler_t nrf_drv_gpiote_evt_handler_t; + +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_IN_SENSE_LOTOHI NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_IN_SENSE_HITOLO NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_IN_SENSE_TOGGLE NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_SIMPLE NRFX_GPIOTE_CONFIG_OUT_SIMPLE +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_TASK_LOW NRFX_GPIOTE_CONFIG_OUT_TASK_LOW +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_TASK_HIGH NRFX_GPIOTE_CONFIG_OUT_TASK_HIGH +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_TASK_TOGGLE NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_init nrfx_gpiote_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_is_init nrfx_gpiote_is_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_uninit nrfx_gpiote_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_init nrfx_gpiote_out_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_uninit nrfx_gpiote_out_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_set nrfx_gpiote_out_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_clear nrfx_gpiote_out_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_toggle nrfx_gpiote_out_toggle +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_enable nrfx_gpiote_out_task_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_disable nrfx_gpiote_out_task_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_addr_get nrfx_gpiote_out_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_init nrfx_gpiote_in_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_uninit nrfx_gpiote_in_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_event_enable nrfx_gpiote_in_event_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_event_disable nrfx_gpiote_in_event_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_is_set nrfx_gpiote_in_is_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_event_addr_get nrfx_gpiote_in_event_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_set_task_addr_get nrfx_gpiote_set_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_clr_task_addr_get nrfx_gpiote_clr_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_force nrfx_gpiote_out_task_force +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_trigger nrfx_gpiote_out_task_trigger +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_set_task_trigger nrfx_gpiote_set_task_trigger +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_clr_task_trigger nrfx_gpiote_clr_task_trigger + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif //NRF_DRV_GPIOTE_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_i2s.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_i2s.h new file mode 100644 index 0000000..d107f09 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_i2s.h @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_I2S_H__ +#define NRF_DRV_I2S_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_i2s I2S driver - legacy layer + * @{ + * @ingroup nrf_i2s + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_i2s_config_t nrf_drv_i2s_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_i2s_buffers_t nrf_drv_i2s_buffers_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_PIN_NOT_USED NRFX_I2S_PIN_NOT_USED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE NRFX_I2S_FLAG_SYNCHRONIZED_MODE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_DEFAULT_CONFIG NRFX_I2S_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_STATUS_NEXT_BUFFERS_NEEDED NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_data_handler_t nrfx_i2s_data_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_uninit nrfx_i2s_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_start nrfx_i2s_start +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_next_buffers_set nrfx_i2s_next_buffers_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_stop nrfx_i2s_stop + +/** + * @brief Function for initializing the I2S driver. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * If NULL, the default configuration is used. + * @param[in] handler Data handler provided by the user. Must not be NULL. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. + * @retval NRF_ERROR_INVALID_PARAM If the requested combination of configuration + * options is not allowed by the I2S peripheral. + */ +__STATIC_INLINE ret_code_t nrf_drv_i2s_init(nrf_drv_i2s_config_t const * p_config, + nrf_drv_i2s_data_handler_t handler) +{ + if (p_config == NULL) + { + static nrfx_i2s_config_t const default_config = NRFX_I2S_DEFAULT_CONFIG; + p_config = &default_config; + } + return nrfx_i2s_init(p_config, handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_I2S_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_lpcomp.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_lpcomp.h new file mode 100644 index 0000000..c1869bb --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_lpcomp.h @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2014 - 2019, 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 NRF_DRV_LPCOMP_H__ +#define NRF_DRV_LPCOMP_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_lpcomp LPCOMP driver - legacy layer + * @{ + * @ingroup nrf_lpcomp + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_lpcomp_config_t nrf_drv_lpcomp_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_LPCOMP_DEFAULT_CONFIG NRFX_LPCOMP_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define lpcomp_events_handler_t nrfx_lpcomp_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_init nrfx_lpcomp_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_uninit nrfx_lpcomp_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_enable nrfx_lpcomp_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_disable nrfx_lpcomp_disable + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_LPCOMP_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pdm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pdm.h new file mode 100644 index 0000000..998ee99 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pdm.h @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_PDM_H__ +#define NRF_DRV_PDM_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_pdm PDM driver - legacy layer + * @{ + * @ingroup nrf_pdm + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pdm_config_t nrf_drv_pdm_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pdm_evt_t nrf_drv_pdm_evt_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PDM_MAX_BUFFER_SIZE NRFX_PDM_MAX_BUFFER_SIZE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PDM_DEFAULT_CONFIG NRFX_PDM_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define PDM_NO_ERROR NRFX_PDM_NO_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define PDM_ERROR_OVERFLOW NRFX_PDM_ERROR_OVERFLOW +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_error_t nrfx_pdm_error_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_event_handler_t nrfx_pdm_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_uninit nrfx_pdm_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_task_address_get nrfx_pdm_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_enable_check nrfx_pdm_enable_check +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_start nrfx_pdm_start +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_stop nrfx_pdm_stop +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_buffer_set nrfx_pdm_buffer_set + +/** + * @brief Function for initializing the PDM interface. + * + * @param[in] p_config Pointer to the structure with initial configuration. Cannot be NULL. + * @param[in] event_handler Event handler provided by the user. Cannot be NULL. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. + * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were specified. + */ +__STATIC_INLINE ret_code_t nrf_drv_pdm_init(nrf_drv_pdm_config_t const * p_config, + nrf_drv_pdm_event_handler_t event_handler) +{ + if (p_config == NULL) + { + return NRFX_ERROR_INVALID_PARAM; + } + return nrfx_pdm_init(p_config, event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_PDM_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.c similarity index 54% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.c index 3c1f268..5141ec4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/power/nrf_drv_power.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,76 +35,31 @@ * 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(POWER) - #include "nrf_drv_power.h" -#include "nrf_assert.h" -#include "nordic_common.h" -#include "app_util_platform.h" +#include #ifdef SOFTDEVICE_PRESENT -#include "nrf_sdm.h" -#include "nrf_soc.h" #include "nrf_sdh.h" #include "nrf_sdh_soc.h" #endif -/* Validate configuration */ -INTERRUPT_PRIORITY_VALIDATION(POWER_CONFIG_IRQ_PRIORITY); +#include -/** - * @internal - * @defgroup nrf_drv_power_internals POWER driver internals - * @ingroup nrf_drv_power - * - * Internal variables, auxiliary macros and functions of POWER driver. - * @{ - */ - -/** - * @brief Default configuration - * - * The structure with default configuration data. - * This structure would be used if configuration pointer given - * to the @ref nrf_drv_power_init is set to NULL. - */ -static const nrf_drv_power_config_t m_drv_power_config_default = +// The structure with default configuration data. +static const nrfx_power_config_t m_drv_power_config_default = { - .dcdcen = POWER_CONFIG_DEFAULT_DCDCEN, + .dcdcen = NRFX_POWER_CONFIG_DEFAULT_DCDCEN, #if NRF_POWER_HAS_VDDH - .dcdcenhv = POWER_CONFIG_DEFAULT_DCDCENHV, + .dcdcenhv = NRFX_POWER_CONFIG_DEFAULT_DCDCENHV, #endif }; -/** - * @brief The initialization flag - */ static bool m_initialized; -/** - * @brief The handler of power fail comparator warning event - */ -static nrf_drv_power_pofwarn_event_handler_t m_pofwarn_handler; - -#if NRF_POWER_HAS_SLEEPEVT -/** - * @brief The handler of sleep event handler - */ -static nrf_drv_power_sleep_event_handler_t m_sleepevt_handler; -#endif - -#if NRF_POWER_HAS_USBREG -/** - * @brief The handler of USB power events - */ -static nrf_drv_power_usb_event_handler_t m_usbevt_handler; -#endif - -/** @} */ - bool nrf_drv_power_init_check(void) { return m_initialized; @@ -112,34 +67,33 @@ bool nrf_drv_power_init_check(void) ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config) { - nrf_drv_power_config_t const * p_used_config; if (m_initialized) { return NRF_ERROR_MODULE_ALREADY_INITIALIZED; } + #ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { return NRF_ERROR_INVALID_STATE; } #endif + if (p_config == NULL) + { + p_config = &m_drv_power_config_default; + } - p_used_config = (p_config != NULL) ? - p_config : (&m_drv_power_config_default); -#if NRF_POWER_HAS_VDDH - nrf_power_dcdcen_vddh_set(p_used_config->dcdcenhv); -#endif - nrf_power_dcdcen_set(p_used_config->dcdcen); - - nrf_drv_common_power_clock_irq_init(); - - m_initialized = true; - return NRF_SUCCESS; + ret_code_t err_code = nrfx_power_init(p_config); + if (err_code == NRFX_SUCCESS) + { + m_initialized = true; + } + return err_code; } -void nrf_drv_power_uninit(void) +void nrf_drv_power_uninit() { - ASSERT(m_initialized); + nrfx_power_uninit(); nrf_drv_power_pof_uninit(); #if NRF_POWER_HAS_SLEEPEVT nrf_drv_power_sleepevt_uninit(); @@ -152,10 +106,8 @@ void nrf_drv_power_uninit(void) ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_config) { - ASSERT(p_config != NULL); - - nrf_drv_power_pof_uninit(); - + ret_code_t err_code = NRF_SUCCESS; + nrfx_power_pof_init(p_config); #ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { @@ -176,7 +128,7 @@ ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_confi * the values taken by SD is different than the one in hardware */ uint8_t thr; - switch (p_config->thr) + switch(p_config->thr) { case NRF_POWER_POFTHR_V21: thr = NRF_POWER_THRESHOLD_V21; @@ -192,76 +144,51 @@ ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_confi break; default: /* Cannot configure */ + nrfx_power_pof_uninit(); return NRF_ERROR_INVALID_STATE; } - ASSERT(sd_power_pof_threshold_set(thr)); + err_code = sd_power_pof_threshold_set(thr); + if (err_code != NRF_SUCCESS) + { + return err_code; + } } + err_code = sd_power_pof_enable(true); } else #endif /* SOFTDEVICE_PRESENT */ { - nrf_power_pofcon_set(true, p_config->thr); -#if NRF_POWER_HAS_VDDH - nrf_power_pofcon_vddh_set(p_config->thrvddh); -#endif - } - - if (p_config->handler != NULL) - { - m_pofwarn_handler = p_config->handler; -#ifdef SOFTDEVICE_PRESENT - if (nrf_sdh_is_enabled()) - { - (void) sd_power_pof_enable(true); - } - else -#endif - { - nrf_power_int_enable(NRF_POWER_INT_POFWARN_MASK); - } + nrfx_power_pof_enable(p_config); } - return NRF_SUCCESS; + return err_code; } -void nrf_drv_power_pof_uninit(void) +void nrf_drv_power_pof_uninit() { #ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { - (void) sd_power_pof_enable(false); + ret_code_t err_code = sd_power_pof_enable(false); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); //handle no-debug case } else #endif { - nrf_power_int_disable(NRF_POWER_INT_POFWARN_MASK); + nrfx_power_pof_disable(); } - m_pofwarn_handler = NULL; + nrfx_power_pof_uninit(); } #if NRF_POWER_HAS_SLEEPEVT ret_code_t nrf_drv_power_sleepevt_init(nrf_drv_power_sleepevt_config_t const * p_config) { - ASSERT(p_config != NULL); - - nrf_drv_power_sleepevt_uninit(); if (p_config->handler != NULL) { - uint32_t enmask = 0; - m_sleepevt_handler = p_config->handler; - if (p_config->en_enter) - { - enmask |= NRF_POWER_INT_SLEEPENTER_MASK; - nrf_power_event_clear(NRF_POWER_EVENT_SLEEPENTER); - } - if (p_config->en_exit) - { - enmask |= NRF_POWER_INT_SLEEPEXIT_MASK; - nrf_power_event_clear(NRF_POWER_EVENT_SLEEPEXIT); - } #ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { - if (enmask != 0) + if ((p_config->en_enter) || (p_config->en_exit)) { return NRF_ERROR_INVALID_STATE; } @@ -269,11 +196,10 @@ ret_code_t nrf_drv_power_sleepevt_init(nrf_drv_power_sleepevt_config_t const * p else #endif { - nrf_power_int_enable(enmask); + nrfx_power_sleepevt_enable(p_config); } } - - return NRF_SUCCESS; + return NRF_SUCCESS; } void nrf_drv_power_sleepevt_uninit(void) @@ -286,122 +212,98 @@ void nrf_drv_power_sleepevt_uninit(void) else #endif { - nrf_power_int_disable( - NRF_POWER_INT_SLEEPENTER_MASK | - NRF_POWER_INT_SLEEPEXIT_MASK); + nrfx_power_sleepevt_disable(); } - m_sleepevt_handler = NULL; + nrfx_power_sleepevt_uninit(); } #endif /* NRF_POWER_HAS_SLEEPEVT */ #if NRF_POWER_HAS_USBREG -ret_code_t nrf_drv_power_usbevt_init(nrf_drv_power_usbevt_config_t const * p_config) + +#ifdef SOFTDEVICE_PRESENT +static ret_code_t nrf_drv_power_sd_usbevt_enable(bool enable) { - nrf_drv_power_usbevt_uninit(); - if (p_config->handler != NULL) + ret_code_t err_code; + err_code = sd_power_usbdetected_enable(enable); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) { - m_usbevt_handler = p_config->handler; -#ifdef SOFTDEVICE_PRESENT - if (nrf_sdh_is_enabled()) - { - /** @todo Implement USB power events when SD support it */ - return NRF_ERROR_INVALID_STATE; - } - else -#endif - { - nrf_power_int_enable( - NRF_POWER_INT_USBDETECTED_MASK | - NRF_POWER_INT_USBREMOVED_MASK | - NRF_POWER_INT_USBPWRRDY_MASK); - } + return err_code; } - return NRF_SUCCESS; + + err_code = sd_power_usbpwrrdy_enable(enable); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = sd_power_usbremoved_enable(enable); + ASSERT(err_code == NRF_SUCCESS); + return err_code; } +#endif // SOFTDEVICE_PRESENT -void nrf_drv_power_usbevt_uninit(void) +ret_code_t nrf_drv_power_usbevt_init(nrf_drv_power_usbevt_config_t const * p_config) { + nrf_drv_power_usbevt_uninit(); + nrfx_power_usbevt_init(p_config); #ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { - /** @todo Implement USB power events when SD support it */ + ret_code_t err_code = nrf_drv_power_sd_usbevt_enable(true); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + uint32_t regstatus; + err_code = sd_power_usbregstatus_get(®status); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + if (regstatus & POWER_USBREGSTATUS_VBUSDETECT_Msk) + { + nrfx_power_usb_event_handler_t usbevt_handler = nrfx_power_usb_handler_get(); + ASSERT(usbevt_handler != NULL); + usbevt_handler(NRFX_POWER_USB_EVT_DETECTED); + } } else #endif { - nrf_power_int_disable( - NRF_POWER_INT_USBDETECTED_MASK | - NRF_POWER_INT_USBREMOVED_MASK | - NRF_POWER_INT_USBPWRRDY_MASK); + nrfx_power_usbevt_enable(); } - m_usbevt_handler = NULL; + return NRF_SUCCESS; } -#endif /* NRF_POWER_HAS_USBREG */ - -/** - * @ingroup nrf_drv_power_internals - * @brief Interrupt handler - * - * POWER peripheral interrupt handler - */ -#if NRF_DRV_COMMON_POWER_CLOCK_ISR -void nrf_drv_power_onIRQ(void) -#else -void POWER_CLOCK_IRQHandler(void) -#endif +void nrf_drv_power_usbevt_uninit(void) { - uint32_t enabled = nrf_power_int_enable_get(); - if ((0 != (enabled & NRF_POWER_INT_POFWARN_MASK)) && - nrf_power_event_get_and_clear(NRF_POWER_EVENT_POFWARN)) - { - /* Cannot be null if event is enabled */ - ASSERT(m_pofwarn_handler != NULL); - m_pofwarn_handler(); - } -#if NRF_POWER_HAS_SLEEPEVT - if ((0 != (enabled & NRF_POWER_INT_SLEEPENTER_MASK)) && - nrf_power_event_get_and_clear(NRF_POWER_EVENT_SLEEPENTER)) - { - /* Cannot be null if event is enabled */ - ASSERT(m_sleepevt_handler != NULL); - m_sleepevt_handler(NRF_DRV_POWER_SLEEP_EVT_ENTER); - } - if ((0 != (enabled & NRF_POWER_INT_SLEEPEXIT_MASK)) && - nrf_power_event_get_and_clear(NRF_POWER_EVENT_SLEEPEXIT)) +#ifdef SOFTDEVICE_PRESENT + CRITICAL_REGION_ENTER(); + if (nrf_sdh_is_enabled()) { - /* Cannot be null if event is enabled */ - ASSERT(m_sleepevt_handler != NULL); - m_sleepevt_handler(NRF_DRV_POWER_SLEEP_EVT_EXIT); + ret_code_t err_code = nrf_drv_power_sd_usbevt_enable(false); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); } + else #endif -#if NRF_POWER_HAS_USBREG - if ((0 != (enabled & NRF_POWER_INT_USBDETECTED_MASK)) && - nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBDETECTED)) { - /* Cannot be null if event is enabled */ - ASSERT(m_usbevt_handler != NULL); - m_usbevt_handler(NRF_DRV_POWER_USB_EVT_DETECTED); - } - if ((0 != (enabled & NRF_POWER_INT_USBREMOVED_MASK)) && - nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBREMOVED)) - { - /* Cannot be null if event is enabled */ - ASSERT(m_usbevt_handler != NULL); - m_usbevt_handler(NRF_DRV_POWER_USB_EVT_REMOVED); - } - if ((0 != (enabled & NRF_POWER_INT_USBPWRRDY_MASK)) && - nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBPWRRDY)) - { - /* Cannot be null if event is enabled */ - ASSERT(m_usbevt_handler != NULL); - m_usbevt_handler(NRF_DRV_POWER_USB_EVT_READY); + nrfx_power_usbevt_disable(); } +#ifdef SOFTDEVICE_PRESENT + CRITICAL_REGION_EXIT(); #endif + nrfx_power_usbevt_uninit(); } +#endif /* NRF_POWER_HAS_USBREG */ #ifdef SOFTDEVICE_PRESENT - static void nrf_drv_power_sdh_soc_evt_handler(uint32_t evt_id, void * p_context); static void nrf_drv_power_sdh_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context); @@ -418,34 +320,73 @@ static void nrf_drv_power_sdh_soc_evt_handler(uint32_t evt_id, void * p_context) { if (evt_id == NRF_EVT_POWER_FAILURE_WARNING) { + nrfx_power_pofwarn_event_handler_t pofwarn_handler = nrfx_power_pof_handler_get(); /* Cannot be null if event is enabled */ - ASSERT(m_pofwarn_handler != NULL); - m_pofwarn_handler(); + ASSERT(pofwarn_handler != NULL); + pofwarn_handler(); } + +#if NRF_POWER_HAS_USBREG + nrfx_power_usb_event_handler_t usbevt_handler = nrfx_power_usb_handler_get(); + if (usbevt_handler != NULL) + { + switch (evt_id) + { + case NRF_EVT_POWER_USB_POWER_READY: + usbevt_handler(NRFX_POWER_USB_EVT_READY); + break; + + case NRF_EVT_POWER_USB_DETECTED: + usbevt_handler(NRFX_POWER_USB_EVT_DETECTED); + break; + + case NRF_EVT_POWER_USB_REMOVED: + usbevt_handler(NRFX_POWER_USB_EVT_REMOVED); + break; + + default: + break; + + } + } +#endif } static void nrf_drv_power_on_sd_enable(void) { ASSERT(m_initialized); /* This module has to be enabled first */ CRITICAL_REGION_ENTER(); - if (m_pofwarn_handler != NULL) + if (nrfx_power_pof_handler_get() != NULL) { - (void) sd_power_pof_enable(true); + ret_code_t err_code = sd_power_pof_enable(true); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); //handle no-debug case } CRITICAL_REGION_EXIT(); + +#if NRF_POWER_HAS_USBREG + if (nrfx_power_usb_handler_get() != NULL) + { + ret_code_t err_code = nrf_drv_power_sd_usbevt_enable(true); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); //handle no-debug case + } +#endif } static void nrf_drv_power_on_sd_disable(void) { /* Reinit interrupts */ ASSERT(m_initialized); - nrf_drv_common_irq_enable(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY); - if (m_pofwarn_handler != NULL) + NRFX_IRQ_PRIORITY_SET(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY); + NRFX_IRQ_ENABLE(POWER_CLOCK_IRQn); + if (nrfx_power_pof_handler_get() != NULL) { nrf_power_int_enable(NRF_POWER_INT_POFWARN_MASK); } + #if NRF_POWER_HAS_USBREG - if (m_usbevt_handler != NULL) + if (nrfx_power_usb_handler_get() != NULL) { nrf_power_int_enable( NRF_POWER_INT_USBDETECTED_MASK | @@ -473,5 +414,4 @@ static void nrf_drv_power_sdh_state_evt_handler(nrf_sdh_state_evt_t state, void } #endif // SOFTDEVICE_PRESENT - -#endif /* NRF_MODULE_ENABLED(POWER) */ +#endif //POWER_ENABLED diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.h new file mode 100644 index 0000000..105dda2 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_power.h @@ -0,0 +1,232 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRF_DRV_POWER_H__ +#define NRF_DRV_POWER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_power POWER driver - legacy layer + * @{ + * @ingroup nrf_power + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_config_t nrf_drv_power_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_pofwarn_config_t nrf_drv_power_pofwarn_config_t; +#if NRF_POWER_HAS_SLEEPEVT || defined(__SDK_DOXYGEN__) +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_sleepevt_config_t nrf_drv_power_sleepevt_config_t; +#endif +#if NRF_POWER_HAS_USBREG || defined(__SDK_DOXYGEN__) +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_usbevt_config_t nrf_drv_power_usbevt_config_t; +#endif + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_MODE_CONSTLAT NRFX_POWER_MODE_CONSTLAT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_MODE_LOWPWR NRFX_POWER_MODE_LOWPWR +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_mode_t nrfx_power_mode_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_SLEEP_EVT_ENTER NRFX_POWER_SLEEP_EVT_ENTER +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_SLEEP_EVT_EXIT NRFX_POWER_SLEEP_EVT_EXIT +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_sleep_evt_t nrfx_power_sleep_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_EVT_DETECTED NRFX_POWER_USB_EVT_DETECTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_EVT_REMOVED NRFX_POWER_USB_EVT_REMOVED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_EVT_READY NRFX_POWER_USB_EVT_READY +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usb_evt_t nrfx_power_usb_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_STATE_DISCONNECTED NRFX_POWER_USB_STATE_DISCONNECTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_STATE_CONNECTED NRFX_POWER_USB_STATE_CONNECTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_STATE_READY NRFX_POWER_USB_STATE_READY +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usb_state_t nrfx_power_usb_state_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_pofwarn_event_handler_t nrfx_power_pofwarn_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_sleep_event_handler_t nrfx_power_sleep_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usb_event_handler_t nrfx_power_usb_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usbstatus_get nrfx_power_usbstatus_get + +/** + * @brief Function for checking if driver is already initialized + * + * This function is used to check whether common POWER_CLOCK interrupt + * should be disabled or not if @ref nrf_drv_clock tries to disable the interrupt. + * + * @retval true Driver is initialized + * @retval false Driver is uninitialized + * + * @sa nrf_drv_power_uninit + */ +bool nrf_drv_power_init_check(void); + +/** + * @brief Initialize power module driver + * + * Enabled power module driver would process all the interrupts from power system. + * + * @param[in] p_config Driver configuration. Can be NULL - the default configuration + * from @em sdk_config.h file would be used then. + * + * @retval NRF_ERROR_INVALID_STATE Power driver has to be enabled + * before SoftDevice. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED Module is initialized already. + * @retval NRF_SUCCESS Successfully initialized. + */ +ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config); + +/** + * @brief Unintialize power module driver + * + * Disables all the interrupt handling in the module. + * + * @sa nrf_drv_power_init + */ +void nrf_drv_power_uninit(void); + +/** + * @brief Initialize power failure comparator + * + * Configures and setups the power failure comparator and enables it. + * + * @param[in] p_config Configuration with values and event handler. + * If event handler is set to NULL, interrupt would be disabled. + * + * @retval NRF_ERROR_INVALID_STATE POF is initialized when SD is enabled and + * the configuration differs from the old one and + * is not possible to be set using SD interface. + * @retval NRF_SUCCESS Successfully initialized and configured. + */ +ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_config); + +/** + * @brief Turn off the power failure comparator + * + * Disables and clears the settings of the power failure comparator. + */ +void nrf_drv_power_pof_uninit(void); + +#if NRF_POWER_HAS_SLEEPEVT || defined(__SDK_DOXYGEN__) + +/** + * @brief Initialize sleep entering and exiting events processing + * + * Configures and setups the sleep event processing. + * + * @param[in] p_config Configuration with values and event handler. + * + * @sa nrf_drv_power_sleepevt_uninit + * + * @note Sleep events are not available when SoftDevice is enabled. + * @note If sleep event is enabled when SoftDevice is initialized, sleep events + * would be automatically disabled - it is the limitation of the + * SoftDevice itself. + * + * @retval NRF_ERROR_INVALID_STATE This event cannot be initialized + * when SD is enabled. + * @retval NRF_SUCCESS Successfully initialized and configured. + */ +ret_code_t nrf_drv_power_sleepevt_init(nrf_drv_power_sleepevt_config_t const * p_config); + +/** + * @brief Uninitialize sleep entering and exiting events processing + * + * @sa nrf_drv_power_sleepevt_init + */ +void nrf_drv_power_sleepevt_uninit(void); + +#endif // NRF_POWER_HAS_SLEEPEVT || defined(__SDK_DOXYGEN__) + +#if NRF_POWER_HAS_USBREG || defined(__SDK_DOXYGEN__) + +/** + * @brief Initialize USB power event processing + * + * Configures and setups the USB power event processing. + * + * @param[in] p_config Configuration with values and event handler. + * + * @sa nrf_drv_power_usbevt_uninit + * + * @retval NRF_ERROR_INVALID_STATE This event cannot be initialized + * when SD is enabled and SD does not support + * USB power events. + * @retval NRF_SUCCESS Successfully initialized and configured. + */ +ret_code_t nrf_drv_power_usbevt_init(nrf_drv_power_usbevt_config_t const * p_config); + +/** + * @brief Uninitalize USB power event processing + * + * @sa nrf_drv_power_usbevt_init + */ +void nrf_drv_power_usbevt_uninit(void); + +#endif // NRF_POWER_HAS_USBREG || defined(__SDK_DOXYGEN__) + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_POWER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.c similarity index 74% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.c index 7c62229..fb8587f 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_hash.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,37 +35,35 @@ * 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 CC310_LIB_HASH_H__ -#define CC310_LIB_HASH_H__ - -/** @file * - * @defgroup nrf_crypto_backend_cc310_lib_hash CC310 backend hash types. - * @{ - * @ingroup nrf_crypto_backend_cryptocell - * - * @brief Provides types required for CC310 backend hash. */ -#include "nrf_crypto_hash.h" -#include "crys_hash.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "nrf_drv_ppi.h" +static nrfx_drv_state_t m_drv_state; /**< Driver state */ -/** @brief Size of hash context context. - */ -#define NRF_CRYPTO_HASH_CONTEXT_SIZE sizeof(CRYS_HASHUserContext_t) +ret_code_t nrf_drv_ppi_init(void) +{ + if (m_drv_state == NRFX_DRV_STATE_UNINITIALIZED) + { + m_drv_state = NRFX_DRV_STATE_INITIALIZED; + } + else + { + return NRF_ERROR_MODULE_ALREADY_INITIALIZED; + } + return NRF_SUCCESS; +} +ret_code_t nrf_drv_ppi_uninit(void) +{ + if (m_drv_state == NRFX_DRV_STATE_UNINITIALIZED) + { + return NRF_ERROR_INVALID_STATE; + } -#ifdef __cplusplus + m_drv_state = NRFX_DRV_STATE_UNINITIALIZED; + nrfx_ppi_free_all(); + return NRF_SUCCESS; } -#endif - -/**@} */ -#endif // #ifndef CC310_LIB_HASH_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.h new file mode 100644 index 0000000..3fe978f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_ppi.h @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_PPI_H__ +#define NRF_DRV_PPI_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_ppi PPI driver - legacy layer + * @{ + * @ingroup nrf_ppi + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PPI_ALL_APP_CHANNELS_MASK NRFX_PPI_ALL_APP_CHANNELS_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PPI_PROG_APP_CHANNELS_MASK NRFX_PPI_PROG_APP_CHANNELS_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PPI_ALL_APP_GROUPS_MASK NRFX_PPI_ALL_APP_GROUPS_MASK + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_alloc nrfx_ppi_channel_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_free nrfx_ppi_channel_free +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_assign nrfx_ppi_channel_assign +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_fork_assign nrfx_ppi_channel_fork_assign +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_enable nrfx_ppi_channel_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_disable nrfx_ppi_channel_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_to_mask nrfx_ppi_channel_to_mask +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channels_include_in_group nrfx_ppi_channels_include_in_group +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_include_in_group nrfx_ppi_channel_include_in_group +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channels_remove_from_group nrfx_ppi_channels_remove_from_group +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_remove_from_group nrfx_ppi_channel_remove_from_group + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_alloc nrfx_ppi_group_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_free nrfx_ppi_group_free +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_clear nrfx_ppi_group_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_enable nrfx_ppi_group_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_disable nrfx_ppi_group_disable + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_task_addr_get nrfx_ppi_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_task_addr_group_enable_get nrfx_ppi_task_addr_group_enable_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_task_addr_group_disable_get nrfx_ppi_task_addr_group_disable_get + +/** + * @brief Function for initializing PPI module. + * + * @retval NRF_SUCCESS If the module was successfully initialized. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized. + */ +ret_code_t nrf_drv_ppi_init(void); + +/** + * @brief Function for uninitializing the PPI module. + * + * This function also disables all channels and clears the channel groups. + * + * @retval NRF_SUCCESS If the module was successfully uninitialized. + * @retval NRF_ERROR_INVALID_STATE If the module has not been initialized yet. + */ +ret_code_t nrf_drv_ppi_uninit(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_PPI_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pwm.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pwm.h new file mode 100644 index 0000000..e7f2bf8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_pwm.h @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_PWM_H__ +#define NRF_DRV_PWM_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_pwm PWM driver - legacy layer + * @{ + * @ingroup nrf_pwm + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pwm_t nrf_drv_pwm_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pwm_config_t nrf_drv_pwm_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_INSTANCE NRFX_PWM_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_PIN_NOT_USED NRFX_PWM_PIN_NOT_USED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_PIN_INVERTED NRFX_PWM_PIN_INVERTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_DEFAULT_CONFIG NRFX_PWM_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_STOP NRFX_PWM_FLAG_STOP +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_LOOP NRFX_PWM_FLAG_LOOP +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0 NRFX_PWM_FLAG_SIGNAL_END_SEQ0 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1 NRFX_PWM_FLAG_SIGNAL_END_SEQ1 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_NO_EVT_FINISHED NRFX_PWM_FLAG_NO_EVT_FINISHED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_START_VIA_TASK NRFX_PWM_FLAG_START_VIA_TASK +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_flag_t nrfx_pwm_flag_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_FINISHED NRFX_PWM_EVT_FINISHED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_END_SEQ0 NRFX_PWM_EVT_END_SEQ0 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_END_SEQ1 NRFX_PWM_EVT_END_SEQ1 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_STOPPED NRFX_PWM_EVT_STOPPED +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_evt_type_t nrfx_pwm_evt_type_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_handler_t nrfx_pwm_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_init nrfx_pwm_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_uninit nrfx_pwm_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_simple_playback nrfx_pwm_simple_playback +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_complex_playback nrfx_pwm_complex_playback +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_step nrfx_pwm_step +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_stop nrfx_pwm_stop +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_is_stopped nrfx_pwm_is_stopped +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_update nrfx_pwm_sequence_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_values_update nrfx_pwm_sequence_values_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_length_update nrfx_pwm_sequence_length_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_repeats_update nrfx_pwm_sequence_repeats_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_end_delay_update nrfx_pwm_sequence_end_delay_update + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_task_address_get nrfx_pwm_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_event_address_get nrfx_pwm_event_address_get + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_PWM_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qdec.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qdec.h new file mode 100644 index 0000000..69de13d --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qdec.h @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_QDEC_H__ +#define NRF_DRV_QDEC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_qdec QDEC driver - legacy layer + * @{ + * @ingroup nrf_qdec + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_config_t nrf_drv_qdec_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_sample_data_evt_t nrf_drv_qdec_sample_data_evt_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_report_data_evt_t nrf_drv_qdec_report_data_evt_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_event_t nrf_drv_qdec_event_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QDEC_DEFAULT_CONFIG NRFX_QDEC_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define qdec_event_handler_t nrfx_qdec_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_uninit nrfx_qdec_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_enable nrfx_qdec_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_disable nrfx_qdec_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_accumulators_read nrfx_qdec_accumulators_read + +/** + * @brief Function for initializing QDEC. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] event_handler Event handler function. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were supplied. + * @retval NRF_ERROR_INVALID_STATE If QDEC was already initialized. + */ +__STATIC_INLINE ret_code_t nrf_drv_qdec_init(nrf_drv_qdec_config_t const * p_config, + qdec_event_handler_t event_handler) +{ + if (p_config == NULL) + { + static nrf_drv_qdec_config_t const default_config = NRFX_QDEC_DEFAULT_CONFIG; + p_config = &default_config; + } + return nrfx_qdec_init(p_config, event_handler); +} + +/** + * @brief Function for returning the address of a specific timer task. + * + * @param[in] task QDEC task. + * @param[out] p_task Task address. + */ +void nrf_drv_qdec_task_address_get(nrf_qdec_task_t task, uint32_t * p_task) +{ + *p_task = nrfx_qdec_task_address_get(task); +} + +/** + * @brief Function for returning the address of a specific timer event. + * + * @param[in] event QDEC event. + * @param[out] p_event Event address. + */ +void nrf_drv_qdec_event_address_get(nrf_qdec_event_t event, uint32_t * p_event) +{ + *p_event = nrfx_qdec_event_address_get(event); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_QDEC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qspi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qspi.h new file mode 100644 index 0000000..7187943 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_qspi.h @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2016 - 2019, 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 NRF_DRV_QSPI_H__ +#define NRF_DRV_QSPI_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_qspi QSPI driver - legacy layer + * @{ + * @ingroup nrf_qspi + * + * @brief @tagAPI52840 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qspi_config_t nrf_drv_qspi_config_t; + +#if QSPI_PIN_SCK == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_SCK + #define QSPI_PIN_SCK BSP_QSPI_SCK_PIN +#endif +#if QSPI_PIN_CSN == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_CSN + #define QSPI_PIN_CSN BSP_QSPI_CSN_PIN +#endif +#if QSPI_PIN_IO0 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO0 + #define QSPI_PIN_IO0 BSP_QSPI_IO0_PIN +#endif +#if QSPI_PIN_IO1 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO1 + #define QSPI_PIN_IO1 BSP_QSPI_IO1_PIN +#endif +#if QSPI_PIN_IO2 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO2 + #define QSPI_PIN_IO2 BSP_QSPI_IO2_PIN +#endif +#if QSPI_PIN_IO3 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO3 + #define QSPI_PIN_IO3 BSP_QSPI_IO3_PIN +#endif + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QSPI_DEFAULT_CONFIG NRFX_QSPI_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QSPI_DEFAULT_CINSTR NRFX_QSPI_DEFAULT_CINSTR +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QSPI_EVENT_DONE NRFX_QSPI_EVENT_DONE +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_evt_t nrfx_qspi_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_handler_t nrfx_qspi_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_init nrfx_qspi_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_uninit nrfx_qspi_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_read nrfx_qspi_read +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_write nrfx_qspi_write +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_erase nrfx_qspi_erase +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_chip_erase nrfx_qspi_chip_erase +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_mem_busy_check nrfx_qspi_mem_busy_check +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_cinstr_xfer nrfx_qspi_cinstr_xfer +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_cinstr_quick_send nrfx_qspi_cinstr_quick_send + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_QSPI_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng/nrf_drv_rng.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rng.c similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng/nrf_drv_rng.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rng.c index 8f02e76..025c8cd 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng/nrf_drv_rng.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rng.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,7 +35,7 @@ * 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(RNG) @@ -43,7 +43,6 @@ #include #include #include "nrf_drv_rng.h" -#include "nrf_drv_common.h" #include "nordic_common.h" #include "app_util_platform.h" #include "nrf_assert.h" @@ -65,12 +64,9 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); -/* Validate configuration */ -INTERRUPT_PRIORITY_VALIDATION(RNG_CONFIG_IRQ_PRIORITY); - typedef struct { - nrf_drv_state_t state; + nrfx_drv_state_t state; nrf_drv_rng_config_t config; } nrf_drv_rng_cb_t; @@ -79,11 +75,8 @@ NRF_QUEUE_DEF(uint8_t, m_rand_pool, RNG_CONFIG_POOL_SIZE, NRF_QUEUE_MODE_OVERFLO static const nrf_drv_rng_config_t m_default_config = NRF_DRV_RNG_DEFAULT_CONFIG; #ifdef SOFTDEVICE_PRESENT -#ifdef S132 #define SD_RAND_POOL_SIZE (64) -#else - #define SD_RAND_POOL_SIZE (32) -#endif + STATIC_ASSERT(RNG_CONFIG_POOL_SIZE == SD_RAND_POOL_SIZE); #define NRF_DRV_RNG_LOCK() CRITICAL_REGION_ENTER() @@ -96,47 +89,28 @@ static const nrf_drv_rng_config_t m_default_config = NRF_DRV_RNG_DEFAULT_CONFIG; #endif // SOFTDEVICE_PRESENT -/** - * @brief Function for starting generation. - */ -static void nrf_drv_rng_start(void) -{ - ASSERT(!NRF_DRV_RNG_SD_IS_ENABLED()); - - nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY); - nrf_rng_int_enable(NRF_RNG_INT_VALRDY_MASK); - nrf_rng_task_trigger(NRF_RNG_TASK_START); -} - -/** - * @brief Function for stoping generation. - */ -static void nrf_drv_rng_stop(void) +static void nrfx_rng_handler(uint8_t rng_val) { - ASSERT(!NRF_DRV_RNG_SD_IS_ENABLED()); - - nrf_rng_int_disable(NRF_RNG_INT_VALRDY_MASK); - nrf_rng_task_trigger(NRF_RNG_TASK_STOP); -} + NRF_DRV_RNG_LOCK(); + if (!NRF_DRV_RNG_SD_IS_ENABLED()) + { + UNUSED_RETURN_VALUE(nrf_queue_push(&m_rand_pool, &rng_val)); -/** - * @brief Function for setting up RNG hardware. - */ -static void nrf_drv_rng_setup(void) -{ - ASSERT(!NRF_DRV_RNG_SD_IS_ENABLED()); + if (nrf_queue_is_full(&m_rand_pool)) + { + nrfx_rng_stop(); + } - if (m_rng_cb.config.error_correction) - { - nrf_rng_error_correction_enable(); + NRF_LOG_DEBUG("Event: NRF_RNG_EVENT_VALRDY."); } - nrf_rng_shorts_disable(NRF_RNG_SHORT_VALRDY_STOP_MASK); - nrf_drv_common_irq_enable(RNG_IRQn, m_rng_cb.config.interrupt_priority); + NRF_DRV_RNG_RELEASE(); + } ret_code_t nrf_drv_rng_init(nrf_drv_rng_config_t const * p_config) { - if (m_rng_cb.state != NRF_DRV_STATE_UNINITIALIZED) + ret_code_t err_code = NRF_SUCCESS; + if (m_rng_cb.state != NRFX_DRV_STATE_UNINITIALIZED) { return NRF_ERROR_MODULE_ALREADY_INITIALIZED; } @@ -151,39 +125,42 @@ ret_code_t nrf_drv_rng_init(nrf_drv_rng_config_t const * p_config) if (!NRF_DRV_RNG_SD_IS_ENABLED()) { - nrf_drv_rng_setup(); - nrf_drv_rng_start(); + err_code = nrfx_rng_init(&m_rng_cb.config, nrfx_rng_handler); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + nrfx_rng_start(); } + m_rng_cb.state = NRFX_DRV_STATE_INITIALIZED; NRF_DRV_RNG_RELEASE(); - m_rng_cb.state = NRF_DRV_STATE_INITIALIZED; - - return NRF_SUCCESS; + return err_code; } void nrf_drv_rng_uninit(void) { - ASSERT(m_rng_cb.state == NRF_DRV_STATE_INITIALIZED); + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); NRF_DRV_RNG_LOCK(); if (!NRF_DRV_RNG_SD_IS_ENABLED()) { - nrf_drv_rng_stop(); - nrf_drv_common_irq_disable(RNG_IRQn); + nrfx_rng_stop(); + nrfx_rng_uninit(); } NRF_DRV_RNG_RELEASE(); nrf_queue_reset(&m_rand_pool); - m_rng_cb.state = NRF_DRV_STATE_UNINITIALIZED; + m_rng_cb.state = NRFX_DRV_STATE_UNINITIALIZED; NRF_LOG_INFO("Uninitialized."); } void nrf_drv_rng_bytes_available(uint8_t * p_bytes_available) { - ASSERT(m_rng_cb.state == NRF_DRV_STATE_INITIALIZED); + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); #ifdef SOFTDEVICE_PRESENT if (NRF_DRV_RNG_SD_IS_ENABLED()) @@ -203,7 +180,7 @@ void nrf_drv_rng_bytes_available(uint8_t * p_bytes_available) ret_code_t nrf_drv_rng_rand(uint8_t * p_buff, uint8_t length) { ret_code_t err_code = NRF_SUCCESS; - ASSERT(m_rng_cb.state == NRF_DRV_STATE_INITIALIZED); + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); #ifdef SOFTDEVICE_PRESENT do { @@ -214,7 +191,7 @@ ret_code_t nrf_drv_rng_rand(uint8_t * p_buff, uint8_t length) #endif // SOFTDEVICE_PRESENT { err_code = nrf_queue_read(&m_rand_pool, p_buff, (uint32_t)length); - nrf_drv_rng_start(); + nrfx_rng_start(); } #ifdef SOFTDEVICE_PRESENT NRF_DRV_RNG_RELEASE(); @@ -244,7 +221,7 @@ ret_code_t nrf_drv_rng_rand(uint8_t * p_buff, uint8_t length) void nrf_drv_rng_block_rand(uint8_t * p_buff, uint32_t length) { - ASSERT(m_rng_cb.state == NRF_DRV_STATE_INITIALIZED); + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); while (length) { @@ -269,15 +246,23 @@ static void sd_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context) switch (state) { case NRF_SDH_EVT_STATE_ENABLE_PREPARE: - NVIC_DisableIRQ(RNG_IRQn); + if (m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED) + { + nrfx_rng_stop(); + nrfx_rng_uninit(); + } break; case NRF_SDH_EVT_STATE_DISABLED: NRF_DRV_RNG_LOCK(); - if (m_rng_cb.state == NRF_DRV_STATE_INITIALIZED) + if (m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED) { - nrf_drv_rng_setup(); - nrf_drv_rng_start(); + ret_code_t err_code = nrfx_rng_init(&m_rng_cb.config, nrfx_rng_handler); + if (err_code != NRF_SUCCESS) + { + ASSERT(false); + } + nrfx_rng_start(); } NRF_DRV_RNG_RELEASE(); break; @@ -295,27 +280,4 @@ NRF_SDH_STATE_OBSERVER(m_sd_state_observer, RNG_CONFIG_STATE_OBSERVER_PRIO) = #endif // SOFTDEVICE_PRESENT -void RNG_IRQHandler(void) -{ - NRF_DRV_RNG_LOCK(); - if ( - !NRF_DRV_RNG_SD_IS_ENABLED() && - nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) && - nrf_rng_int_get(NRF_RNG_INT_VALRDY_MASK)) - { - nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY); - - uint8_t new_value = nrf_rng_random_value_get(); - UNUSED_RETURN_VALUE(nrf_queue_push(&m_rand_pool, &new_value)); - - if (nrf_queue_is_full(&m_rand_pool)) - { - nrf_drv_rng_stop(); - } - - NRF_LOG_DEBUG("Event: NRF_RNG_EVENT_VALRDY."); - } - NRF_DRV_RNG_RELEASE(); -} - #endif // NRF_MODULE_ENABLED(RNG) diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng/nrf_drv_rng.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rng.h similarity index 76% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng/nrf_drv_rng.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rng.h index 7d242d3..fad8eb9 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/rng/nrf_drv_rng.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rng.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, 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 @@ -35,49 +35,31 @@ * 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 NRF_DRV_RNG_H__ #define NRF_DRV_RNG_H__ -#include -#include - -#include "nrf_rng.h" -#include "sdk_errors.h" -#include "sdk_config.h" -#include "nrf_drv_common.h" +#include #ifdef __cplusplus extern "C" { #endif /** - * @addtogroup nrf_rng RNG HAL and driver - * @ingroup nrf_drivers - * @brief Random number generator (RNG) APIs. - * @details The RNG HAL provides basic APIs for accessing the registers of the random number - * generator. The RNG driver provides APIs on a higher level. - * - * @defgroup nrf_drv_rng RNG driver + * @defgroup nrf_drv_rng RNG driver - legacy layer * @{ - * @ingroup nrf_rng - * @brief Driver for managing the random number generator (RNG). + * @ingroup nrf_rng + * + * @brief Layer providing compatibility with the former API. */ -/**@brief Struct for RNG configuration. */ -typedef struct -{ - bool error_correction : 1; /**< Error correction flag. */ - uint8_t interrupt_priority; /**< interrupt priority */ -} nrf_drv_rng_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_rng_config_t nrf_drv_rng_config_t; -/**@brief RNG default configuration. */ -#define NRF_DRV_RNG_DEFAULT_CONFIG \ - { \ - .error_correction = RNG_CONFIG_ERROR_CORRECTION, \ - .interrupt_priority = RNG_CONFIG_IRQ_PRIORITY, \ - } +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RNG_DEFAULT_CONFIG NRFX_RNG_DEFAULT_CONFIG /** * @brief Function for initializing the nrf_drv_rng module. @@ -124,9 +106,7 @@ ret_code_t nrf_drv_rng_rand(uint8_t * p_buff, uint8_t length); */ void nrf_drv_rng_block_rand(uint8_t * p_buff, uint32_t length); -/** - *@} - **/ +/** @} */ #ifdef __cplusplus } diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rtc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rtc.h new file mode 100644 index 0000000..d56792f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_rtc.h @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2014 - 2019, 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 NRF_DRV_RTC_H__ +#define NRF_DRV_RTC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_rtc RTC driver - legacy layer + * @{ + * @ingroup nrf_rtc + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_rtc_t nrf_drv_rtc_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_rtc_config_t nrf_drv_rtc_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INSTANCE NRFX_RTC_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_DEFAULT_CONFIG NRFX_RTC_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define RTC_US_TO_TICKS NRFX_RTC_US_TO_TICKS + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE0 NRFX_RTC_INT_COMPARE0 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE1 NRFX_RTC_INT_COMPARE1 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE2 NRFX_RTC_INT_COMPARE2 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE3 NRFX_RTC_INT_COMPARE3 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_TICK NRFX_RTC_INT_TICK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_OVERFLOW NRFX_RTC_INT_OVERFLOW +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_int_type_t nrfx_rtc_int_type_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_handler_t nrfx_rtc_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_init nrfx_rtc_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_uninit nrfx_rtc_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_enable nrfx_rtc_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_disable nrfx_rtc_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_cc_set nrfx_rtc_cc_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_cc_disable nrfx_rtc_cc_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_tick_enable nrfx_rtc_tick_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_tick_disable nrfx_rtc_tick_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_overflow_enable nrfx_rtc_overflow_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_overflow_disable nrfx_rtc_overflow_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_max_ticks_get nrfx_rtc_max_ticks_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_int_disable nrfx_rtc_int_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_int_enable nrfx_rtc_int_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_counter_get nrfx_rtc_counter_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_counter_clear nrfx_rtc_counter_clear + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_task_address_get nrfx_rtc_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_event_address_get nrfx_rtc_event_address_get + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_RTC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_saadc.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_saadc.h new file mode 100644 index 0000000..b44acdd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_saadc.h @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_SAADC_H__ +#define NRF_DRV_SAADC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_saadc SAADC driver - legacy layer + * @{ + * @ingroup nrf_saadc + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_saadc_config_t nrf_drv_saadc_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_EVT_DONE NRFX_SAADC_EVT_DONE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_EVT_LIMIT NRFX_SAADC_EVT_LIMIT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_EVT_CALIBRATEDONE NRFX_SAADC_EVT_CALIBRATEDONE +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_evt_type_t nrfx_saadc_evt_type_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_done_evt_t nrfx_saadc_done_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_limit_evt_t nrfx_saadc_limit_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_evt_t nrfx_saadc_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_event_handler_t nrfx_saadc_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_LIMITH_DISABLED NRFX_SAADC_LIMITH_DISABLED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_LIMITL_DISABLED NRFX_SAADC_LIMITL_DISABLED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_DEFAULT_CONFIG NRFX_SAADC_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE \ + NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL \ + NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_uninit nrfx_saadc_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_channel_init nrfx_saadc_channel_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_channel_uninit nrfx_saadc_channel_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_sample nrfx_saadc_sample +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_sample_convert nrfx_saadc_sample_convert +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_buffer_convert nrfx_saadc_buffer_convert +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_calibrate_offset nrfx_saadc_calibrate_offset +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_is_busy nrfx_saadc_is_busy +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_abort nrfx_saadc_abort +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_limits_set nrfx_saadc_limits_set + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_sample_task_get nrfx_saadc_sample_task_get + +/** + * @brief Function for initializing the SAADC. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * If NULL, the default one is used. + * @param[in] event_handler Event handler provided by the user. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. + * @retval NRF_ERROR_INVALID_PARAM If event_handler is NULL. + */ +__STATIC_INLINE ret_code_t nrf_drv_saadc_init(nrf_drv_saadc_config_t const * p_config, + nrf_drv_saadc_event_handler_t event_handler) +{ + if (p_config == NULL) + { + static const nrfx_saadc_config_t default_config = NRFX_SAADC_DEFAULT_CONFIG; + p_config = &default_config; + } + return nrfx_saadc_init(p_config, event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SAADC_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.c new file mode 100644 index 0000000..190f237 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.c @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf_drv_spi.h" + +#ifdef SPIM_PRESENT +#define INSTANCE_COUNT SPIM_COUNT +#else +#define INSTANCE_COUNT SPI_COUNT +#endif + +static nrf_drv_spi_evt_handler_t m_handlers[INSTANCE_COUNT]; +static void * m_contexts[INSTANCE_COUNT]; + +#ifdef SPIM_PRESENT +static void spim_evt_handler(nrfx_spim_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_spi_evt_t const event = + { + .type = (nrf_drv_spi_evt_type_t)p_event->type, + .data = + { + .done = + { + .p_tx_buffer = p_event->xfer_desc.p_tx_buffer, + .tx_length = p_event->xfer_desc.tx_length, + .p_rx_buffer = p_event->xfer_desc.p_rx_buffer, + .rx_length = p_event->xfer_desc.rx_length, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // SPIM_PRESENT + +#ifdef SPI_PRESENT +static void spi_evt_handler(nrfx_spi_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_spi_evt_t const event = + { + .type = (nrf_drv_spi_evt_type_t)p_event->type, + .data = + { + .done = + { + .p_tx_buffer = p_event->xfer_desc.p_tx_buffer, + .tx_length = p_event->xfer_desc.tx_length, + .p_rx_buffer = p_event->xfer_desc.p_rx_buffer, + .rx_length = p_event->xfer_desc.rx_length, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // SPI_PRESENT + +ret_code_t nrf_drv_spi_init(nrf_drv_spi_t const * const p_instance, + nrf_drv_spi_config_t const * p_config, + nrf_drv_spi_evt_handler_t handler, + void * p_context) +{ + uint32_t inst_idx = p_instance->inst_idx; + m_handlers[inst_idx] = handler; + m_contexts[inst_idx] = p_context; + + ret_code_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { +#ifdef SPIM_PRESENT + nrfx_spim_config_t config_spim = NRFX_SPIM_DEFAULT_CONFIG; + config_spim.sck_pin = p_config->sck_pin; + config_spim.mosi_pin = p_config->mosi_pin; + config_spim.miso_pin = p_config->miso_pin; + config_spim.ss_pin = p_config->ss_pin; + config_spim.irq_priority = p_config->irq_priority; + config_spim.orc = p_config->orc; + config_spim.frequency = (nrf_spim_frequency_t)p_config->frequency; + config_spim.mode = (nrf_spim_mode_t)p_config->mode; + config_spim.bit_order = (nrf_spim_bit_order_t)p_config->bit_order; + result = nrfx_spim_init(&p_instance->u.spim, + &config_spim, + handler ? spim_evt_handler : NULL, + (void *)inst_idx); +#endif + } + else if (NRF_DRV_SPI_USE_SPI) + { + result = nrfx_spi_init(&p_instance->u.spi, + (nrfx_spi_config_t const *)p_config, + handler ? spi_evt_handler : NULL, + (void *)inst_idx); + } + return result; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.h similarity index 66% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.h index 01eb919..78fcab6 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/spi_master/nrf_drv_spi.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spi.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,96 +35,64 @@ * 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 - * @addtogroup nrf_spi Serial peripheral interface (SPI/SPIM) - * @ingroup nrf_drivers - * @brief Serial peripheral interface (SPI/SPIM) APIs. * */ #ifndef NRF_DRV_SPI_H__ #define NRF_DRV_SPI_H__ -#include "nordic_common.h" -#include "sdk_config.h" -#include "nrf_peripherals.h" -#include "sdk_errors.h" - -#ifdef SPI0_ENABLED -#define SPI0_INCR SPI0_ENABLED -#else -#define SPI0_INCR 0 -#endif - -#ifdef SPI1_ENABLED -#define SPI1_INCR SPI1_ENABLED -#else -#define SPI1_INCR 0 -#endif - -#ifdef SPI2_ENABLED -#define SPI2_INCR SPI2_ENABLED -#else -#define SPI2_INCR 0 -#endif - -#ifdef SPI3_ENABLED -#define SPI3_INCR SPI3_ENABLED +#include +#ifdef SPIM_PRESENT + #include #else -#define SPI3_INCR 0 + // Compilers (at least the smart ones) will remove the SPIM related code + // (blocks starting with "if (NRF_DRV_SPI_USE_SPIM)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_spim_init(...) 0 + #define nrfx_spim_uninit(...) + #define nrfx_spim_start_task_get(...) 0 + #define nrfx_spim_end_event_get(...) 0 + #define nrfx_spim_abort(...) #endif -#define ENABLED_SPI_COUNT (SPI0_INCR + SPI1_INCR + SPI2_INCR + SPI3_INCR) - #ifdef SPI_PRESENT -#include "nrf_spi.h" -#endif - -#ifdef SPIM_PRESENT -#include "nrf_spim.h" + #include +#else + // Compilers (at least the smart ones) will remove the SPI related code + // (blocks starting with "if (NRF_DRV_SPI_USE_SPI)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_spi_init(...) 0 + #define nrfx_spi_uninit(...) + #define nrfx_spi_start_task_get(...) 0 + #define nrfx_spi_end_event_get(...) 0 + #define nrfx_spi_abort(...) + + // This part is for old modules that use directly SPI HAL definitions + // (to make them compilable for chips that have only SPIM). + #define NRF_SPI_FREQ_125K NRF_SPIM_FREQ_125K + #define NRF_SPI_FREQ_250K NRF_SPIM_FREQ_250K + #define NRF_SPI_FREQ_500K NRF_SPIM_FREQ_500K + #define NRF_SPI_FREQ_1M NRF_SPIM_FREQ_1M + #define NRF_SPI_FREQ_2M NRF_SPIM_FREQ_2M + #define NRF_SPI_FREQ_4M NRF_SPIM_FREQ_4M + #define NRF_SPI_FREQ_8M NRF_SPIM_FREQ_8M + #define NRF_SPI_MODE_0 NRF_SPIM_MODE_0 + #define NRF_SPI_MODE_1 NRF_SPIM_MODE_1 + #define NRF_SPI_MODE_2 NRF_SPIM_MODE_2 + #define NRF_SPI_MODE_3 NRF_SPIM_MODE_3 + #define NRF_SPI_BIT_ORDER_MSB_FIRST NRF_SPIM_BIT_ORDER_MSB_FIRST + #define NRF_SPI_BIT_ORDER_LSB_FIRST NRF_SPIM_BIT_ORDER_LSB_FIRST #endif #ifdef __cplusplus extern "C" { #endif -#if defined(SPIM_PRESENT) && defined(SPI_PRESENT) - #define NRF_DRV_SPI_PERIPHERAL(id) \ - (CONCAT_3(SPI, id, _USE_EASY_DMA) == 1 ? \ - (void *)CONCAT_2(NRF_SPIM, id) \ - : (void *)CONCAT_2(NRF_SPI, id)) - #define SPI2_IRQ SPIM2_SPIS2_SPI2_IRQn - #define SPI2_IRQ_HANDLER SPIM2_SPIS2_SPI2_IRQHandler -#elif defined (SPI_PRESENT) - #define NRF_DRV_SPI_PERIPHERAL(id) (void *)CONCAT_2(NRF_SPI, id) -#elif defined (SPIM_PRESENT) - #define NRF_DRV_SPI_PERIPHERAL(id) (void *)CONCAT_2(NRF_SPIM, id) -#endif - -#ifndef SPI_PRESENT -typedef nrf_spim_frequency_t nrf_spi_frequency_t; -typedef nrf_spim_mode_t nrf_spi_mode_t; -typedef nrf_spim_bit_order_t nrf_spi_bit_order_t; -#define NRF_SPI_PIN_NOT_CONNECTED 0xFFFFFFFF -#endif - -#ifdef NRF52810_XXAA -#define SPI0_IRQ SPIM0_SPIS0_IRQn -#define SPI0_IRQ_HANDLER SPIM0_SPIS0_IRQHandler -#else -#define SPI0_IRQ SPI0_TWI0_IRQn -#define SPI0_IRQ_HANDLER SPI0_TWI0_IRQHandler -#define SPI1_IRQ SPI1_TWI1_IRQn -#define SPI1_IRQ_HANDLER SPI1_TWI1_IRQHandler -#endif /** * @defgroup nrf_drv_spi SPI master driver * @{ * @ingroup nrf_spi - * - * @brief Multi-instance SPI master driver. + * @brief Layer providing compatibility with the former API. */ /** @@ -132,34 +100,46 @@ typedef nrf_spim_bit_order_t nrf_spi_bit_order_t; */ typedef struct { - void * p_registers; ///< Pointer to the structure with SPI/SPIM peripheral instance registers. - IRQn_Type irq; ///< SPI/SPIM peripheral instance IRQ number. - uint8_t drv_inst_idx; ///< Driver instance index. - bool use_easy_dma; ///< True if the peripheral with EasyDMA (SPIM) shall be used. -} nrf_drv_spi_t; - -#define SPI0_INSTANCE_INDEX 0 -#define SPI1_INSTANCE_INDEX SPI0_INSTANCE_INDEX+SPI0_ENABLED -#define SPI2_INSTANCE_INDEX SPI1_INSTANCE_INDEX+SPI1_ENABLED - -#if defined(SPIM_PRESENT) && defined(SPI_PRESENT) -#define SPI_N_USE_EASY_DMA(_id) CONCAT_3(SPI, _id, _USE_EASY_DMA) -#elif defined(SPIM_PRESENT) && !defined(SPI_PRESENT) -#define SPI_N_USE_EASY_DMA(_id) true -#else -#define SPI_N_USE_EASY_DMA(_id) false + uint8_t inst_idx; + union + { +#ifdef SPIM_PRESENT + nrfx_spim_t spim; #endif +#ifdef SPI_PRESENT + nrfx_spi_t spi; +#endif + } u; + bool use_easy_dma; +} nrf_drv_spi_t; /** * @brief Macro for creating an SPI master driver instance. */ -#define NRF_DRV_SPI_INSTANCE(id) \ -{ \ - .p_registers = NRF_DRV_SPI_PERIPHERAL(id), \ - .irq = CONCAT_3(SPI, id, _IRQ), \ - .drv_inst_idx = CONCAT_3(SPI, id, _INSTANCE_INDEX), \ - .use_easy_dma = SPI_N_USE_EASY_DMA(id) \ -} +#define NRF_DRV_SPI_INSTANCE(id) NRF_DRV_SPI_INSTANCE_(id) +#define NRF_DRV_SPI_INSTANCE_(id) NRF_DRV_SPI_INSTANCE_ ## id +#if NRFX_CHECK(NRFX_SPIM0_ENABLED) + #define NRF_DRV_SPI_INSTANCE_0 \ + { 0, { .spim = NRFX_SPIM_INSTANCE(0) }, true } +#elif NRFX_CHECK(NRFX_SPI0_ENABLED) + #define NRF_DRV_SPI_INSTANCE_0 \ + { 0, { .spi = NRFX_SPI_INSTANCE(0) }, false } +#endif +#if NRFX_CHECK(NRFX_SPIM1_ENABLED) + #define NRF_DRV_SPI_INSTANCE_1 \ + { 1, { .spim = NRFX_SPIM_INSTANCE(1) }, true } +#elif NRFX_CHECK(NRFX_SPI1_ENABLED) + #define NRF_DRV_SPI_INSTANCE_1 \ + { 1, { .spi = NRFX_SPI_INSTANCE(1) }, false } +#endif +#if NRFX_CHECK(NRFX_SPIM2_ENABLED) + #define NRF_DRV_SPI_INSTANCE_2 \ + { 2, { .spim = NRFX_SPIM_INSTANCE(2) }, true } +#elif NRFX_CHECK(NRFX_SPI2_ENABLED) + #define NRF_DRV_SPI_INSTANCE_2 \ + { 2, { .spi = NRFX_SPI_INSTANCE(2) }, false } +#endif + /** * @brief This value can be provided instead of a pin number for signals MOSI, * MISO, and Slave Select to specify that the given signal is not used and @@ -316,6 +296,7 @@ typedef struct typedef void (* nrf_drv_spi_evt_handler_t)(nrf_drv_spi_evt_t const * p_event, void * p_context); + /** * @brief Function for initializing the SPI master driver instance. * @@ -339,8 +320,8 @@ typedef void (* nrf_drv_spi_evt_handler_t)(nrf_drv_spi_evt_t const * p_event, */ ret_code_t nrf_drv_spi_init(nrf_drv_spi_t const * const p_instance, nrf_drv_spi_config_t const * p_config, - nrf_drv_spi_evt_handler_t handler, - void * p_context); + nrf_drv_spi_evt_handler_t handler, + void * p_context); /** * @brief Function for uninitializing the SPI master driver instance. @@ -349,7 +330,8 @@ ret_code_t nrf_drv_spi_init(nrf_drv_spi_t const * const p_instance, * * @param[in] p_instance Pointer to the driver instance structure. */ -void nrf_drv_spi_uninit(nrf_drv_spi_t const * const p_instance); +__STATIC_INLINE +void nrf_drv_spi_uninit(nrf_drv_spi_t const * const p_instance); /** * @brief Function for starting the SPI data transfer. @@ -377,6 +359,7 @@ void nrf_drv_spi_uninit(nrf_drv_spi_t const * const p_instance); * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the Data * RAM region. */ +__STATIC_INLINE ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance, uint8_t const * p_tx_buffer, uint8_t tx_buffer_length, @@ -424,6 +407,7 @@ ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance, * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the Data * RAM region. */ +__STATIC_INLINE ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance, nrf_drv_spi_xfer_desc_t const * p_xfer_desc, uint32_t flags); @@ -438,6 +422,7 @@ ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance, * * @return Start task address. */ +__STATIC_INLINE uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance); /** @@ -450,6 +435,7 @@ uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance); * * @return END event address. */ +__STATIC_INLINE uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance); /** @@ -457,12 +443,173 @@ uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance); * * @param[in] p_instance Pointer to the driver instance structure. */ +__STATIC_INLINE void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance); + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +#if defined(SPI_PRESENT) && !defined(SPIM_PRESENT) +#define NRF_DRV_SPI_WITH_SPI +#elif !defined(SPI_PRESENT) && defined(SPIM_PRESENT) +#define NRF_DRV_SPI_WITH_SPIM +#else +#if (NRFX_CHECK(SPI0_ENABLED) && NRFX_CHECK(SPI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI1_ENABLED) && NRFX_CHECK(SPI1_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI2_ENABLED) && NRFX_CHECK(SPI2_USE_EASY_DMA)) + #define NRF_DRV_SPI_WITH_SPIM +#endif +#if (NRFX_CHECK(SPI0_ENABLED) && !NRFX_CHECK(SPI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI1_ENABLED) && !NRFX_CHECK(SPI1_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI2_ENABLED) && !NRFX_CHECK(SPI2_USE_EASY_DMA)) + #define NRF_DRV_SPI_WITH_SPI +#endif +#endif +#if defined(NRF_DRV_SPI_WITH_SPIM) && defined(NRF_DRV_SPI_WITH_SPI) + #define NRF_DRV_SPI_USE_SPIM (p_instance->use_easy_dma) +#elif defined(NRF_DRV_SPI_WITH_SPIM) + #define NRF_DRV_SPI_USE_SPIM true +#else + #define NRF_DRV_SPI_USE_SPIM false +#endif +#define NRF_DRV_SPI_USE_SPI (!NRF_DRV_SPI_USE_SPIM) + +__STATIC_INLINE +void nrf_drv_spi_uninit(nrf_drv_spi_t const * p_instance) +{ + if (NRF_DRV_SPI_USE_SPIM) + { + nrfx_spim_uninit(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + nrfx_spi_uninit(&p_instance->u.spi); + } +} + +__STATIC_INLINE +ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance, + uint8_t const * p_tx_buffer, + uint8_t tx_buffer_length, + uint8_t * p_rx_buffer, + uint8_t rx_buffer_length) +{ + ret_code_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + #ifdef SPIM_PRESENT + nrfx_spim_xfer_desc_t const spim_xfer_desc = + { + .p_tx_buffer = p_tx_buffer, + .tx_length = tx_buffer_length, + .p_rx_buffer = p_rx_buffer, + .rx_length = rx_buffer_length, + }; + result = nrfx_spim_xfer(&p_instance->u.spim, &spim_xfer_desc, 0); + #endif + } + else if (NRF_DRV_SPI_USE_SPI) + { + #ifdef SPI_PRESENT + nrfx_spi_xfer_desc_t const spi_xfer_desc = + { + .p_tx_buffer = p_tx_buffer, + .tx_length = tx_buffer_length, + .p_rx_buffer = p_rx_buffer, + .rx_length = rx_buffer_length, + }; + result = nrfx_spi_xfer(&p_instance->u.spi, &spi_xfer_desc, 0); + #endif + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance, + nrf_drv_spi_xfer_desc_t const * p_xfer_desc, + uint32_t flags) +{ + ret_code_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + #ifdef SPIM_PRESENT + nrfx_spim_xfer_desc_t const spim_xfer_desc = + { + .p_tx_buffer = p_xfer_desc->p_tx_buffer, + .tx_length = p_xfer_desc->tx_length, + .p_rx_buffer = p_xfer_desc->p_rx_buffer, + .rx_length = p_xfer_desc->rx_length, + }; + result = nrfx_spim_xfer(&p_instance->u.spim, &spim_xfer_desc, flags); + #endif + } + else if (NRF_DRV_SPI_USE_SPI) + { + #ifdef SPI_PRESENT + nrfx_spi_xfer_desc_t const spi_xfer_desc = + { + .p_tx_buffer = p_xfer_desc->p_tx_buffer, + .tx_length = p_xfer_desc->tx_length, + .p_rx_buffer = p_xfer_desc->p_rx_buffer, + .rx_length = p_xfer_desc->rx_length, + }; + result = nrfx_spi_xfer(&p_instance->u.spi, &spi_xfer_desc, flags); + #endif + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + result = nrfx_spim_start_task_get(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + result = nrfx_spim_end_event_get(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + return result; +} + +__STATIC_INLINE +void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance) +{ + if (NRF_DRV_SPI_USE_SPIM) + { + nrfx_spim_abort(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + nrfx_spi_abort(&p_instance->u.spi); + } +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +/** @} */ + #ifdef __cplusplus } #endif #endif // NRF_DRV_SPI_H__ - -/** @} */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.c new file mode 100644 index 0000000..2cc3f50 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.c @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2018 - 2019, 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 "nrf_drv_spis.h" + +static nrf_drv_spis_event_handler_t m_handlers[SPIS_COUNT]; + +static void spis_event_handler(nrfx_spis_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + m_handlers[inst_idx](*p_event); +} + +ret_code_t nrf_drv_spis_init(nrf_drv_spis_t const * const p_instance, + nrf_drv_spis_config_t const * p_config, + nrf_drv_spis_event_handler_t event_handler) +{ + uint32_t inst_idx = p_instance->drv_inst_idx; + m_handlers[inst_idx] = event_handler; + + return nrfx_spis_init(p_instance, + p_config, + spis_event_handler, + (void *)inst_idx); +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.h new file mode 100644 index 0000000..45cf5b8 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_spis.h @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2014 - 2019, 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 NRF_DRV_SPIS_H__ +#define NRF_DRV_SPIS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_spis SPIS driver - legacy layer + * @{ + * @ingroup nrf_spis + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_spis_t nrf_drv_spis_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_spis_config_t nrf_drv_spis_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_spis_evt_t nrf_drv_spis_event_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_INSTANCE NRFX_SPIS_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_DEFAULT_CONFIG NRFX_SPIS_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_DEFAULT_CSN_PULLUP NRFX_SPIS_DEFAULT_CSN_PULLUP +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_DEFAULT_MISO_DRIVE NRFX_SPIS_DEFAULT_MISO_DRIVE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_PIN_NOT_USED NRFX_SPIS_PIN_NOT_USED + +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_BIT_ORDER_LSB_FIRST NRF_SPIS_BIT_ORDER_LSB_FIRST +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_BIT_ORDER_MSB_FIRST NRF_SPIS_BIT_ORDER_MSB_FIRST +/** @brief Macro for providing API backward compatibility. */ +#define nrf_drv_spis_endian_t nrf_spis_bit_order_t +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_0 NRF_SPIS_MODE_0 +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_1 NRF_SPIS_MODE_1 +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_2 NRF_SPIS_MODE_2 +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_3 NRF_SPIS_MODE_3 +/** @brief Macro for providing API backward compatibility. */ +#define nrf_drv_spis_mode_t nrf_spis_mode_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_BUFFERS_SET_DONE NRFX_SPIS_BUFFERS_SET_DONE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_XFER_DONE NRFX_SPIS_XFER_DONE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_EVT_TYPE_MAX NRFX_SPIS_EVT_TYPE_MAX +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_spis_event_type_t nrfx_spis_evt_type_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_spis_uninit nrfx_spis_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_spis_buffers_set nrfx_spis_buffers_set + +/** @brief SPI slave event callback function type. + * + * @param[in] event SPI slave driver event. + */ +typedef void (*nrf_drv_spis_event_handler_t)(nrf_drv_spis_event_t event); + +/** @brief Function for initializing the SPI slave driver instance. + * + * @note When the nRF52 Anomaly 109 workaround for SPIS is enabled, this function + * initializes the GPIOTE driver as well, and uses one of GPIOTE channels + * to detect falling edges on CSN pin. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Pointer to the structure with the initial configuration. + * If NULL, the default configuration will be used. + * @param[in] event_handler Function to be called by the SPI slave driver upon event. + * + * @retval NRF_SUCCESS If the initialization was successful. + * @retval NRF_ERROR_INVALID_PARAM If an invalid parameter is supplied. + * @retval NRFX_ERROR_INVALID_STATE If the instance is already initialized. + * @retval NRF_ERROR_BUSY If some other peripheral with the same + * instance ID is already in use. This is + * possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED + * is set to a value other than zero. + * @retval NRF_ERROR_INTERNAL GPIOTE channel for detecting falling edges + * on CSN pin cannot be initialized. Possible + * only when using nRF52 Anomaly 109 workaround. + */ +ret_code_t nrf_drv_spis_init(nrf_drv_spis_t const * const p_instance, + nrf_drv_spis_config_t const * p_config, + nrf_drv_spis_event_handler_t event_handler); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SPIS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.c similarity index 75% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.c index 19f1f0d..1ca4dd4 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/crypto/backend/cc310_lib/cc310_lib_init.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.c @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,34 +35,32 @@ * 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 CC310_LIB_INIT_H__ -#define CC310_LIB_INIT_H__ - -/** @file * - * @defgroup nrf_crypto_backend_cc310_lib_init CC310 backend initialization types. - * @{ - * @ingroup nrf_crypto_backend_cryptocell - * - * @brief Provides types required for CC310 backend initialization. */ -#include "nrf_crypto_init.h" +#include "nrf_drv_swi.h" -#ifdef __cplusplus -extern "C" { -#endif +static nrfx_drv_state_t m_drv_state = NRFX_DRV_STATE_UNINITIALIZED; -/** @brief Size of buffer required to initalize nrf_crypto CC310 backend. - */ -#define NRF_CRYPTO_INIT_RAM_BUFFER (0) +ret_code_t nrf_drv_swi_init(void) +{ + if (m_drv_state == NRFX_DRV_STATE_INITIALIZED) + { + return NRF_ERROR_MODULE_ALREADY_INITIALIZED; + } -#ifdef __cplusplus + m_drv_state = NRFX_DRV_STATE_INITIALIZED; + return NRF_SUCCESS; } -#endif -/**@} */ +ret_code_t nrf_drv_swi_uninit(void) +{ + if (m_drv_state == NRFX_DRV_STATE_UNINITIALIZED) + { + return NRF_ERROR_INVALID_STATE; + } -#endif // #ifndef CC310_LIB_INIT_H__ + nrfx_swi_all_free(); + m_drv_state = NRFX_DRV_STATE_UNINITIALIZED; + return NRF_SUCCESS; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.h new file mode 100644 index 0000000..f13c727 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_swi.h @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_SWI_H__ +#define NRF_DRV_SWI_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_swi SWI driver - legacy layer + * @{ + * @ingroup nrf_swi_egu + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_SWI_UNALLOCATED NRFX_SWI_UNALLOCATED +/** @brief Macro for forwarding the new implementation. */ +#define SWI_DEFAULT_PRIORITY NRFX_SWI_DEFAULT_PRIORITY + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_swi_t nrfx_swi_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_swi_flags_t nrfx_swi_flags_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_swi_handler_t nrfx_swi_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_alloc nrfx_swi_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_free nrfx_swi_free +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_trigger nrfx_swi_trigger + +#if NRF_MODULE_ENABLED(EGU) || defined(__SDK_DOXYGEN__) +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_task_trigger_address_get nrfx_swi_task_trigger_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_event_triggered_address_get nrfx_swi_event_triggered_address_get +#endif // NRF_MODULE_ENABLED(EGU) || defined(__SDK_DOXYGEN__) + +/** + * @brief Function for initializing the SWI module. + * + * @retval NRF_SUCCESS If the module was successfully initialized. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized. + */ +ret_code_t nrf_drv_swi_init(void); + +/** + * @brief Function for uninitializing the SWI module. + * + * This function also frees all SWIs. + * + * @retval NRF_SUCCESS If the module was successfully uninitialized. + * @retval NRF_ERROR_INVALID_STATE If the module has not been initialized yet. + */ +ret_code_t nrf_drv_swi_uninit(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SWI_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_systick.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_systick.h new file mode 100644 index 0000000..cb3f4f3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_systick.h @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2016 - 2019, 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 NRF_DRV_SYSTICK_H__ +#define NRF_DRV_SYSTICK_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_systick ARM(R) SysTick driver - legacy layer + * @{ + * @ingroup nrf_systick + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_systick_state_t nrf_drv_systick_state_t; + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_init nrfx_systick_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_get nrfx_systick_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_test nrfx_systick_test +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_delay_ticks nrfx_systick_delay_ticks +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_delay_us nrfx_systick_delay_us +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_delay_ms nrfx_systick_delay_ms + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SYSTICK_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_timer.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_timer.h new file mode 100644 index 0000000..84f1c61 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_timer.h @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_TIMER_H__ +#define NRF_DRV_TIMER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_timer TIMER driver - legacy layer + * @{ + * @ingroup nrf_timer + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_timer_t nrf_drv_timer_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_timer_config_t nrf_drv_timer_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TIMER_INSTANCE NRFX_TIMER_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TIMER_DEFAULT_CONFIG NRFX_TIMER_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_timer_event_handler_t nrfx_timer_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_init nrfx_timer_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_uninit nrfx_timer_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_enable nrfx_timer_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_disable nrfx_timer_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_is_enabled nrfx_timer_is_enabled +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_pause nrfx_timer_pause +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_resume nrfx_timer_resume +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_clear nrfx_timer_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_increment nrfx_timer_increment +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_capture nrfx_timer_capture +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_capture_get nrfx_timer_capture_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare nrfx_timer_compare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_extended_compare nrfx_timer_extended_compare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_us_to_ticks nrfx_timer_us_to_ticks +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_ms_to_ticks nrfx_timer_ms_to_ticks +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare_int_enable nrfx_timer_compare_int_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare_int_disable nrfx_timer_compare_int_disable + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_task_address_get nrfx_timer_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_capture_task_address_get nrfx_timer_capture_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_event_address_get nrfx_timer_event_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare_event_address_get nrfx_timer_compare_event_address_get + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_TIMER_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.c new file mode 100644 index 0000000..ef5f42b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.c @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf_drv_twi.h" +#include +#include + +#ifdef TWIM_PRESENT +#define INSTANCE_COUNT TWIM_COUNT +#else +#define INSTANCE_COUNT TWI_COUNT +#endif + +#define SCL_PIN_INIT_CONF \ + ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ + | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \ + | (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) \ + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)) + +#define SDA_PIN_INIT_CONF SCL_PIN_INIT_CONF + +#define SDA_PIN_UNINIT_CONF \ + ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ + | (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) \ + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \ + | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) \ + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)) + +#define SCL_PIN_UNINIT_CONF SDA_PIN_UNINIT_CONF + +#define SCL_PIN_INIT_CONF_CLR \ + ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ + | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \ + | (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) \ + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ + | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)) + +#define SDA_PIN_INIT_CONF_CLR SCL_PIN_INIT_CONF_CLR + +static nrf_drv_twi_evt_handler_t m_handlers[INSTANCE_COUNT]; +static void * m_contexts[INSTANCE_COUNT]; + +static void twi_clear_bus(nrf_drv_twi_config_t const * p_config) +{ + NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF; + NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF; + + nrf_gpio_pin_set(p_config->scl); + nrf_gpio_pin_set(p_config->sda); + + NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF_CLR; + NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF_CLR; + + nrf_delay_us(4); + + for (int i = 0; i < 9; i++) + { + if (nrf_gpio_pin_read(p_config->sda)) + { + if (i == 0) + { + return; + } + else + { + break; + } + } + nrf_gpio_pin_clear(p_config->scl); + nrf_delay_us(4); + nrf_gpio_pin_set(p_config->scl); + nrf_delay_us(4); + } + nrf_gpio_pin_clear(p_config->sda); + nrf_delay_us(4); + nrf_gpio_pin_set(p_config->sda); +} + +#ifdef TWIM_PRESENT +static void twim_evt_handler(nrfx_twim_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_twi_evt_t const event = + { + .type = (nrf_drv_twi_evt_type_t)p_event->type, + .xfer_desc = + { + .type = (nrf_drv_twi_xfer_type_t)p_event->xfer_desc.type, + .address = p_event->xfer_desc.address, + .primary_length = p_event->xfer_desc.primary_length, + .secondary_length = p_event->xfer_desc.secondary_length, + .p_primary_buf = p_event->xfer_desc.p_primary_buf, + .p_secondary_buf = p_event->xfer_desc.p_secondary_buf, + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // TWIM_PRESENT + +#ifdef TWI_PRESENT +static void twi_evt_handler(nrfx_twi_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_twi_evt_t const event = + { + .type = (nrf_drv_twi_evt_type_t)p_event->type, + .xfer_desc = + { + .type = (nrf_drv_twi_xfer_type_t)p_event->xfer_desc.type, + .address = p_event->xfer_desc.address, + .primary_length = p_event->xfer_desc.primary_length, + .secondary_length = p_event->xfer_desc.secondary_length, + .p_primary_buf = p_event->xfer_desc.p_primary_buf, + .p_secondary_buf = p_event->xfer_desc.p_secondary_buf, + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // TWI_PRESENT + +ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_config_t const * p_config, + nrf_drv_twi_evt_handler_t event_handler, + void * p_context) +{ + uint32_t inst_idx = p_instance->inst_idx; + m_handlers[inst_idx] = event_handler; + m_contexts[inst_idx] = p_context; + + if(p_config->clear_bus_init) + { + /* Send clocks (max 9) until slave device back from stuck mode */ + twi_clear_bus(p_config); + } + + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_init(&p_instance->u.twim, + (nrfx_twim_config_t const *)p_config, + event_handler ? twim_evt_handler : NULL, + (void *)inst_idx); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_init(&p_instance->u.twi, + (nrfx_twi_config_t const *)p_config, + event_handler ? twi_evt_handler : NULL, + (void *)inst_idx); + } + return result; +} diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.h similarity index 65% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.h rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.h index 0a73c88..9b750de 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/twi_master/nrf_drv_twi.h +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twi.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2015 - 2019, 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 @@ -35,166 +35,138 @@ * 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 - * @addtogroup nrf_twi Two Wire master interface (TWI/TWIM) - * @ingroup nrf_drivers - * @brief Two Wire master interface (TWI/TWIM) APIs. * - * - * @defgroup nrf_drv_twi TWI driver - * @{ - * @ingroup nrf_twi - * @brief TWI master APIs. */ + #ifndef NRF_DRV_TWI_H__ #define NRF_DRV_TWI_H__ -#include "sdk_common.h" -#include "nrf_peripherals.h" - -#ifdef TWI0_ENABLED -#define TWI0_INCR TWI0_ENABLED -#else -#define TWI0_INCR 0 -#endif - -#ifdef TWI1_ENABLED -#define TWI1_INCR TWI1_ENABLED +#include +#ifdef TWIM_PRESENT + #include #else -#define TWI1_INCR 0 -#endif - -#define ENABLED_TWI_COUNT (TWI0_INCR + TWI1_INCR) - -#define TWIM_ONLY ( defined(TWIM_PRESENT) && !defined(TWI_PRESENT)) -#define TWI_TWIM_PRESENT ( defined(TWIM_PRESENT) && defined(TWI_PRESENT)) -#define TWI_ONLY (!defined(TWIM_PRESENT) && defined(TWI_PRESENT)) - -#define TWI0_WITH_DMA (defined(TWI0_USE_EASY_DMA) && TWI0_USE_EASY_DMA && TWI0_ENABLED) -#define TWI1_WITH_DMA (defined(TWI1_USE_EASY_DMA) && TWI1_USE_EASY_DMA && TWI1_ENABLED) - -#define TWI0_WITHOUT_DMA (defined(TWI0_USE_EASY_DMA) && !TWI0_USE_EASY_DMA && TWI0_ENABLED) -#define TWI1_WITHOUT_DMA (defined(TWI1_USE_EASY_DMA) && !TWI1_USE_EASY_DMA && TWI1_ENABLED) - -// suppress: non-standard use of 'defined' preprocessor operator -/*lint -save -e491*/ -// Too complex macros for Doxygen -// This set of macros makes it possible to exclude parts of code when one type -// of supported peripherals is not used. -#ifndef DOXYGEN - -#if (TWI_ONLY && ENABLED_TWI_COUNT) || \ - ((TWI_TWIM_PRESENT) && (TWI0_WITHOUT_DMA || TWI1_WITHOUT_DMA)) -#define TWI_IN_USE 1 -#endif - -#if (TWIM_ONLY && ENABLED_TWI_COUNT) || \ - ((TWI_TWIM_PRESENT) && (TWI0_WITH_DMA || TWI1_WITH_DMA)) -#define TWIM_IN_USE 1 + // Compilers (at least the smart ones) will remove the TWIM related code + // (blocks starting with "if (NRF_DRV_TWI_USE_TWIM)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_twim_init(...) 0 + #define nrfx_twim_uninit(...) + #define nrfx_twim_enable(...) + #define nrfx_twim_disable(...) + #define nrfx_twim_tx(...) 0 + #define nrfx_twim_rx(...) 0 + #define nrfx_twim_is_busy(...) 0 + #define nrfx_twim_start_task_get(...) 0 + #define nrfx_twim_stopped_event_get(...) 0 #endif -#endif // DOXYGEN - #ifdef TWI_PRESENT - #include "nrf_twi.h" -#endif - -#ifdef TWIM_PRESENT - #include "nrf_twim.h" + #include +#else + // Compilers (at least the smart ones) will remove the TWI related code + // (blocks starting with "if (NRF_DRV_TWI_USE_TWI)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_twi_init(...) 0 + #define nrfx_twi_uninit(...) + #define nrfx_twi_enable(...) + #define nrfx_twi_disable(...) + #define nrfx_twi_tx(...) 0 + #define nrfx_twi_rx(...) 0 + #define nrfx_twi_is_busy(...) 0 + #define nrfx_twi_data_count_get(...) 0 + #define nrfx_twi_stopped_event_get(...) 0 + + // This part is for old modules that use directly TWI HAL definitions + // (to make them compilable for chips that have only TWIM). + #define NRF_TWI_ERROR_ADDRESS_NACK NRF_TWIM_ERROR_ADDRESS_NACK + #define NRF_TWI_ERROR_DATA_NACK NRF_TWIM_ERROR_DATA_NACK + #define NRF_TWI_FREQ_100K NRF_TWIM_FREQ_100K + #define NRF_TWI_FREQ_250K NRF_TWIM_FREQ_250K + #define NRF_TWI_FREQ_400K NRF_TWIM_FREQ_400K #endif -#include "sdk_errors.h" - #ifdef __cplusplus extern "C" { #endif -#if defined(TWIM_IN_USE) && defined(TWI_IN_USE) - #define NRF_DRV_TWI_PERIPHERAL(id) \ - (CONCAT_3(TWI, id, _USE_EASY_DMA) == 1 ? \ - (void *)CONCAT_2(NRF_TWIM, id) \ - : (void *)CONCAT_2(NRF_TWI, id)) -#elif defined(TWIM_IN_USE) && !defined(TWI_IN_USE) - #define NRF_DRV_TWI_PERIPHERAL(id) (void *)CONCAT_2(NRF_TWIM, id) -#else - #define NRF_DRV_TWI_PERIPHERAL(id) (void *)CONCAT_2(NRF_TWI, id) -#endif - -#ifndef TWI_PRESENT -typedef nrf_twim_frequency_t nrf_twi_frequency_t; -typedef nrf_twim_error_t nrf_twi_error_t; -#endif +/** + * @defgroup nrf_drv_twi TWI driver - legacy layer + * @{ + * @ingroup nrf_twi + * @brief Layer providing compatibility with the former API. + */ /** * @brief Structure for the TWI master driver instance. */ typedef struct { + uint8_t inst_idx; union { -#ifdef TWIM_IN_USE - NRF_TWIM_Type * p_twim; ///< Pointer to a structure with TWIM registers. +#ifdef TWIM_PRESENT + nrfx_twim_t twim; #endif -#ifdef TWI_IN_USE - NRF_TWI_Type * p_twi; ///< Pointer to a structure with TWI registers. +#ifdef TWI_PRESENT + nrfx_twi_t twi; #endif - void * p_regs; - } reg; - uint8_t drv_inst_idx; ///< Driver instance index. - bool use_easy_dma; ///< True if the peripheral with EasyDMA (TWIM) shall be used. + } u; + bool use_easy_dma; } nrf_drv_twi_t; -#define TWI0_INSTANCE_INDEX 0 -#define TWI1_INSTANCE_INDEX TWI0_INSTANCE_INDEX+TWI0_INCR - -#ifndef DOXYGEN -#if defined(TWIM_IN_USE) - #if TWIM_ONLY - #define TWI_USE_EASY_DMA(_id) true - #else - #define TWI_USE_EASY_DMA(_id) CONCAT_3(TWI, _id, _USE_EASY_DMA) - #endif -#else - #define TWI_USE_EASY_DMA(_id) false +/** + * @brief Macro for creating a TWI master driver instance. + */ +#define NRF_DRV_TWI_INSTANCE(id) NRF_DRV_TWI_INSTANCE_(id) +#define NRF_DRV_TWI_INSTANCE_(id) NRF_DRV_TWI_INSTANCE_ ## id +#if NRFX_CHECK(NRFX_TWIM0_ENABLED) + #define NRF_DRV_TWI_INSTANCE_0 \ + { 0, { .twim = NRFX_TWIM_INSTANCE(0) }, true } +#elif NRFX_CHECK(NRFX_TWI0_ENABLED) + #define NRF_DRV_TWI_INSTANCE_0 \ + { 0, { .twi = NRFX_TWI_INSTANCE(0) }, false } +#endif +#if NRFX_CHECK(NRFX_TWIM1_ENABLED) + #define NRF_DRV_TWI_INSTANCE_1 \ + { 1, { .twim = NRFX_TWIM_INSTANCE(1) }, true } +#elif NRFX_CHECK(NRFX_TWI1_ENABLED) + #define NRF_DRV_TWI_INSTANCE_1 \ + { 1, { .twi = NRFX_TWI_INSTANCE(1) }, false } #endif -#endif // DOXYGEN /** - * @brief Macro for creating a TWI master driver instance. + * @brief TWI master clock frequency. */ -#define NRF_DRV_TWI_INSTANCE(id) \ -{ \ - .reg = {NRF_DRV_TWI_PERIPHERAL(id)}, \ - .drv_inst_idx = CONCAT_3(TWI, id, _INSTANCE_INDEX), \ - .use_easy_dma = TWI_USE_EASY_DMA(id) \ -} +typedef enum +{ + NRF_DRV_TWI_FREQ_100K = NRF_TWI_FREQ_100K , ///< 100 kbps. + NRF_DRV_TWI_FREQ_250K = NRF_TWI_FREQ_250K , ///< 250 kbps. + NRF_DRV_TWI_FREQ_400K = NRF_TWI_FREQ_400K ///< 400 kbps. +} nrf_drv_twi_frequency_t; /** * @brief Structure for the TWI master driver instance configuration. */ typedef struct { - uint32_t scl; ///< SCL pin number. - uint32_t sda; ///< SDA pin number. - nrf_twi_frequency_t frequency; ///< TWI frequency. - uint8_t interrupt_priority; ///< Interrupt priority. - bool clear_bus_init; ///< Clear bus during init. - bool hold_bus_uninit; ///< Hold pull up state on gpio pins after uninit. + uint32_t scl; ///< SCL pin number. + uint32_t sda; ///< SDA pin number. + nrf_drv_twi_frequency_t frequency; ///< TWI frequency. + uint8_t interrupt_priority; ///< Interrupt priority. + bool clear_bus_init; ///< Clear bus during init. + bool hold_bus_uninit; ///< Hold pull up state on gpio pins after uninit. } nrf_drv_twi_config_t; /** * @brief TWI master driver instance default configuration. */ -#define NRF_DRV_TWI_DEFAULT_CONFIG \ -{ \ - .frequency = (nrf_twi_frequency_t)TWI_DEFAULT_CONFIG_FREQUENCY, \ - .scl = 31, \ - .sda = 31, \ - .interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \ - .clear_bus_init = TWI_DEFAULT_CONFIG_CLR_BUS_INIT, \ - .hold_bus_uninit = TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \ +#define NRF_DRV_TWI_DEFAULT_CONFIG \ +{ \ + .frequency = (nrf_drv_twi_frequency_t)TWI_DEFAULT_CONFIG_FREQUENCY, \ + .scl = 31, \ + .sda = 31, \ + .interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \ + .clear_bus_init = TWI_DEFAULT_CONFIG_CLR_BUS_INIT, \ + .hold_bus_uninit = TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \ } #define NRF_DRV_TWI_FLAG_TX_POSTINC (1UL << 0) /**< TX buffer address incremented after transfer. */ @@ -319,6 +291,7 @@ ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const * p_instance, * * @param[in] p_instance Pointer to the driver instance structure. */ +__STATIC_INLINE void nrf_drv_twi_uninit(nrf_drv_twi_t const * p_instance); /** @@ -326,6 +299,7 @@ void nrf_drv_twi_uninit(nrf_drv_twi_t const * p_instance); * * @param[in] p_instance Pointer to the driver instance structure. */ +__STATIC_INLINE void nrf_drv_twi_enable(nrf_drv_twi_t const * p_instance); /** @@ -333,6 +307,7 @@ void nrf_drv_twi_enable(nrf_drv_twi_t const * p_instance); * * @param[in] p_instance Pointer to the driver instance structure. */ +__STATIC_INLINE void nrf_drv_twi_disable(nrf_drv_twi_t const * p_instance); /** @@ -356,6 +331,7 @@ void nrf_drv_twi_disable(nrf_drv_twi_t const * p_instance); * @retval NRF_ERROR_DRV_TWI_ERR_ANACK If NACK received after sending the address in polling mode. * @retval NRF_ERROR_DRV_TWI_ERR_DNACK If NACK received after sending a data byte in polling mode. */ +__STATIC_INLINE ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance, uint8_t address, uint8_t const * p_data, @@ -380,6 +356,7 @@ ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance, * @retval NRF_ERROR_DRV_TWI_ERR_ANACK If NACK received after sending the address in polling mode. * @retval NRF_ERROR_DRV_TWI_ERR_DNACK If NACK received after sending a data byte in polling mode. */ +__STATIC_INLINE ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance, uint8_t address, uint8_t * p_data, @@ -434,6 +411,7 @@ ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance, * @retval NRF_ERROR_DRV_TWI_ERR_ANACK If NACK received after sending the address. * @retval NRF_ERROR_DRV_TWI_ERR_DNACK If NACK received after sending a data byte. */ +__STATIC_INLINE ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance, nrf_drv_twi_xfer_desc_t const * p_xfer_desc, uint32_t flags); @@ -446,6 +424,7 @@ ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance, * @retval true If the TWI driver is currently busy performing a transfer. * @retval false If the TWI driver is ready for a new transfer. */ +__STATIC_INLINE bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance); /** @@ -457,6 +436,7 @@ bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance); * * @return Data count. */ +__STATIC_INLINE uint32_t nrf_drv_twi_data_count_get(nrf_drv_twi_t const * const p_instance); /** @@ -470,6 +450,7 @@ uint32_t nrf_drv_twi_data_count_get(nrf_drv_twi_t const * const p_instance); * * @return Start task address (TX or RX) depending on the value of xfer_type. */ +__STATIC_INLINE uint32_t nrf_drv_twi_start_task_get(nrf_drv_twi_t const * p_instance, nrf_drv_twi_xfer_type_t xfer_type); /** @@ -482,16 +463,224 @@ uint32_t nrf_drv_twi_start_task_get(nrf_drv_twi_t const * p_instance, nrf_drv_tw * * @return STOPPED event address. */ +__STATIC_INLINE uint32_t nrf_drv_twi_stopped_event_get(nrf_drv_twi_t const * p_instance); -/** - *@} - **/ -/*lint -restore*/ + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +#if defined(TWI_PRESENT) && !defined(TWIM_PRESENT) +#define NRF_DRV_TWI_WITH_TWI +#elif !defined(TWI_PRESENT) && defined(TWIM_PRESENT) +#define NRF_DRV_TWI_WITH_TWIM +#else +#if (NRFX_CHECK(TWI0_ENABLED) && NRFX_CHECK(TWI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(TWI1_ENABLED) && NRFX_CHECK(TWI1_USE_EASY_DMA)) + #define NRF_DRV_TWI_WITH_TWIM +#endif +#if (NRFX_CHECK(TWI0_ENABLED) && !NRFX_CHECK(TWI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(TWI1_ENABLED) && !NRFX_CHECK(TWI1_USE_EASY_DMA)) + #define NRF_DRV_TWI_WITH_TWI +#endif +#endif +#if defined(NRF_DRV_TWI_WITH_TWIM) && defined(NRF_DRV_TWI_WITH_TWI) + #define NRF_DRV_TWI_USE_TWIM (p_instance->use_easy_dma) +#elif defined(NRF_DRV_TWI_WITH_TWIM) + #define NRF_DRV_TWI_USE_TWIM true +#else + #define NRF_DRV_TWI_USE_TWIM false +#endif +#define NRF_DRV_TWI_USE_TWI (!NRF_DRV_TWI_USE_TWIM) + +__STATIC_INLINE +void nrf_drv_twi_uninit(nrf_drv_twi_t const * p_instance) +{ + if (NRF_DRV_TWI_USE_TWIM) + { + nrfx_twim_uninit(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + nrfx_twi_uninit(&p_instance->u.twi); + } +} + +__STATIC_INLINE +void nrf_drv_twi_enable(nrf_drv_twi_t const * p_instance) +{ + if (NRF_DRV_TWI_USE_TWIM) + { + nrfx_twim_enable(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + nrfx_twi_enable(&p_instance->u.twi); + } +} + +__STATIC_INLINE +void nrf_drv_twi_disable(nrf_drv_twi_t const * p_instance) +{ + if (NRF_DRV_TWI_USE_TWIM) + { + nrfx_twim_disable(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + nrfx_twi_disable(&p_instance->u.twi); + } +} + +__STATIC_INLINE +ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance, + uint8_t address, + uint8_t const * p_data, + uint8_t length, + bool no_stop) +{ + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_tx(&p_instance->u.twim, + address, p_data, length, no_stop); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_tx(&p_instance->u.twi, + address, p_data, length, no_stop); + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance, + uint8_t address, + uint8_t * p_data, + uint8_t length) +{ + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_rx(&p_instance->u.twim, + address, p_data, length); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_rx(&p_instance->u.twi, + address, p_data, length); + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_xfer_desc_t const * p_xfer_desc, + uint32_t flags) +{ + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + #ifdef TWIM_PRESENT + nrfx_twim_xfer_desc_t const twim_xfer_desc = + { + .type = (nrfx_twim_xfer_type_t)p_xfer_desc->type, + .address = p_xfer_desc->address, + .primary_length = p_xfer_desc->primary_length, + .secondary_length = p_xfer_desc->secondary_length, + .p_primary_buf = p_xfer_desc->p_primary_buf, + .p_secondary_buf = p_xfer_desc->p_secondary_buf, + }; + result = nrfx_twim_xfer(&p_instance->u.twim, &twim_xfer_desc, flags); + #endif + } + else if (NRF_DRV_TWI_USE_TWI) + { + #ifdef TWI_PRESENT + nrfx_twi_xfer_desc_t const twi_xfer_desc = + { + .type = (nrfx_twi_xfer_type_t)p_xfer_desc->type, + .address = p_xfer_desc->address, + .primary_length = p_xfer_desc->primary_length, + .secondary_length = p_xfer_desc->secondary_length, + .p_primary_buf = p_xfer_desc->p_primary_buf, + .p_secondary_buf = p_xfer_desc->p_secondary_buf, + }; + result = nrfx_twi_xfer(&p_instance->u.twi, &twi_xfer_desc, flags); + #endif + } + return result; +} + +__STATIC_INLINE +bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance) +{ + bool result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_is_busy(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_is_busy(&p_instance->u.twi); + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_twi_data_count_get(nrf_drv_twi_t const * const p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_data_count_get(&p_instance->u.twi); + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_twi_start_task_get(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_xfer_type_t xfer_type) +{ + uint32_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_start_task_get(&p_instance->u.twim, + (nrfx_twim_xfer_type_t)xfer_type); + } + else if (NRF_DRV_TWI_USE_TWI) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_twi_stopped_event_get(nrf_drv_twi_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_stopped_event_get(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_stopped_event_get(&p_instance->u.twi); + } + return result; +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +/** @} */ #ifdef __cplusplus } #endif #endif // NRF_DRV_TWI_H__ - diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twis.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twis.h new file mode 100644 index 0000000..5f24511 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_twis.h @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_TWIS_H__ +#define NRF_DRV_TWIS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_twis TWIS driver - legacy layer + * @{ + * @ingroup nrf_twis + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_twis_t nrf_drv_twis_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_twis_config_t nrf_drv_twis_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_twis_evt_t nrf_drv_twis_evt_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_INSTANCE NRFX_TWIS_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_DEFAULT_CONFIG NRFX_TWIS_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_READ_REQ NRFX_TWIS_EVT_READ_REQ +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_READ_DONE NRFX_TWIS_EVT_READ_DONE +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_READ_ERROR NRFX_TWIS_EVT_READ_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_WRITE_REQ NRFX_TWIS_EVT_WRITE_REQ +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_WRITE_DONE NRFX_TWIS_EVT_WRITE_DONE +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_WRITE_ERROR NRFX_TWIS_EVT_WRITE_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_GENERAL_ERROR NRFX_TWIS_EVT_GENERAL_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_evt_type_t nrfx_twis_evt_type_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_OVERFLOW NRFX_TWIS_ERROR_OVERFLOW +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_DATA_NACK NRFX_TWIS_ERROR_DATA_NACK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_OVERREAD NRFX_TWIS_ERROR_OVERREAD +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_UNEXPECTED_EVENT NRFX_TWIS_ERROR_UNEXPECTED_EVENT +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_error_t nrfx_twis_error_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_event_handler_t nrfx_twis_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_init nrfx_twis_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_uninit nrfx_twis_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_enable nrfx_twis_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_disable nrfx_twis_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_error_get_and_clear nrfx_twis_error_get_and_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_tx_prepare nrfx_twis_tx_prepare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_tx_amount nrfx_twis_tx_amount +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_rx_prepare nrfx_twis_rx_prepare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_rx_amount nrfx_twis_rx_amount +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_busy nrfx_twis_is_busy +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_waiting_tx_buff nrfx_twis_is_waiting_tx_buff +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_waiting_rx_buff nrfx_twis_is_waiting_rx_buff +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_pending_tx nrfx_twis_is_pending_tx +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_pending_rx nrfx_twis_is_pending_rx + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_TWIS_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.c new file mode 100644 index 0000000..a40c2e3 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.c @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2017 - 2019, 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 "nrf_drv_uart.h" + +#ifdef UARTE_PRESENT +#define INSTANCE_COUNT UARTE_COUNT +#else +#define INSTANCE_COUNT UART_COUNT +#endif + +static nrf_uart_event_handler_t m_handlers[INSTANCE_COUNT]; +static void * m_contexts[INSTANCE_COUNT]; + +#if defined(UARTE_PRESENT) && defined(UART_PRESENT) +uint8_t nrf_drv_uart_use_easy_dma[INSTANCE_COUNT]; +#endif + +#if defined(NRF_DRV_UART_WITH_UARTE) +static void uarte_evt_handler(nrfx_uarte_event_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_uart_event_t event = + { + .type = (nrf_drv_uart_evt_type_t)p_event->type, + .data = + { + .error = + { + .rxtx = + { + .p_data = p_event->data.error.rxtx.p_data, + .bytes = p_event->data.error.rxtx.bytes, + }, + .error_mask = p_event->data.error.error_mask, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // defined(NRF_DRV_UART_WITH_UARTE) + +#if defined(NRF_DRV_UART_WITH_UART) +static void uart_evt_handler(nrfx_uart_event_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_uart_event_t event = + { + .type = (nrf_drv_uart_evt_type_t)p_event->type, + .data = + { + .error = + { + .rxtx = + { + .p_data = p_event->data.error.rxtx.p_data, + .bytes = p_event->data.error.rxtx.bytes, + }, + .error_mask = p_event->data.error.error_mask, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // defined(NRF_DRV_UART_WITH_UART) + +ret_code_t nrf_drv_uart_init(nrf_drv_uart_t const * p_instance, + nrf_drv_uart_config_t const * p_config, + nrf_uart_event_handler_t event_handler) +{ + uint32_t inst_idx = p_instance->inst_idx; + m_handlers[inst_idx] = event_handler; + m_contexts[inst_idx] = p_config->p_context; + +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) +#ifdef NRF52840_XXAA + if (inst_idx == 1) + { + ASSERT(p_config->use_easy_dma); + } +#endif + nrf_drv_uart_use_easy_dma[inst_idx] = p_config->use_easy_dma; +#endif + + nrf_drv_uart_config_t config = *p_config; + config.p_context = (void *)inst_idx; + + ret_code_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_init(&p_instance->uarte, + (nrfx_uarte_config_t const *)&config, + event_handler ? uarte_evt_handler : NULL); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_init(&p_instance->uart, + (nrfx_uart_config_t const *)&config, + event_handler ? uart_evt_handler : NULL); + } + return result; +} diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.h new file mode 100644 index 0000000..81ac59a --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_uart.h @@ -0,0 +1,660 @@ +/** + * Copyright (c) 2015 - 2019, 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 NRF_DRV_UART_H__ +#define NRF_DRV_UART_H__ + +#include + +#if defined(UARTE_PRESENT) && NRFX_CHECK(NRFX_UARTE_ENABLED) + #define NRF_DRV_UART_WITH_UARTE +#endif +#if defined(UART_PRESENT) && NRFX_CHECK(NRFX_UART_ENABLED) + #define NRF_DRV_UART_WITH_UART +#endif + +#if defined(NRF_DRV_UART_WITH_UARTE) + #include + #define NRF_DRV_UART_CREATE_UARTE(id) \ + .uarte = NRFX_UARTE_INSTANCE(id), +#else + // Compilers (at least the smart ones) will remove the UARTE related code + // (blocks starting with "if (NRF_DRV_UART_USE_UARTE)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_uarte_init(...) 0 + #define nrfx_uarte_uninit(...) + #define nrfx_uarte_task_address_get(...) 0 + #define nrfx_uarte_event_address_get(...) 0 + #define nrfx_uarte_tx(...) 0 + #define nrfx_uarte_tx_in_progress(...) 0 + #define nrfx_uarte_tx_abort(...) + #define nrfx_uarte_rx(...) 0 + #define nrfx_uarte_rx_ready(...) 0 + #define nrfx_uarte_rx_abort(...) + #define nrfx_uarte_errorsrc_get(...) 0 + #define NRF_DRV_UART_CREATE_UARTE(id) +#endif + +#if defined(NRF_DRV_UART_WITH_UART) + #include + + #define NRF_DRV_UART_CREATE_UART(id) _NRF_DRV_UART_CREATE_UART(id) + #define _NRF_DRV_UART_CREATE_UART(id) NRF_DRV_UART_CREATE_UART_##id + #define NRF_DRV_UART_CREATE_UART_0 \ + .uart = NRFX_UART_INSTANCE(0), + #define NRF_DRV_UART_CREATE_UART_1 \ + .uart = { .p_reg = NULL }, + +#else + // Compilers (at least the smart ones) will remove the UART related code + // (blocks starting with "if (NRF_DRV_UART_USE_UART)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_uart_init(...) 0 + #define nrfx_uart_uninit(...) + #define nrfx_uart_task_address_get(...) 0 + #define nrfx_uart_event_address_get(...) 0 + #define nrfx_uart_tx(...) 0 + #define nrfx_uart_tx_in_progress(...) 0 + #define nrfx_uart_tx_abort(...) + #define nrfx_uart_rx(...) 0 + #define nrfx_uart_rx_enable(...) + #define nrfx_uart_rx_disable(...) + #define nrfx_uart_rx_ready(...) 0 + #define nrfx_uart_rx_abort(...) + #define nrfx_uart_errorsrc_get(...) 0 + #define NRF_DRV_UART_CREATE_UART(id) + + // This part is for old modules that use directly UART HAL definitions + // (to make them compilable for chips that have only UARTE). + #define NRF_UART_BAUDRATE_1200 NRF_UARTE_BAUDRATE_1200 + #define NRF_UART_BAUDRATE_2400 NRF_UARTE_BAUDRATE_2400 + #define NRF_UART_BAUDRATE_4800 NRF_UARTE_BAUDRATE_4800 + #define NRF_UART_BAUDRATE_9600 NRF_UARTE_BAUDRATE_9600 + #define NRF_UART_BAUDRATE_14400 NRF_UARTE_BAUDRATE_14400 + #define NRF_UART_BAUDRATE_19200 NRF_UARTE_BAUDRATE_19200 + #define NRF_UART_BAUDRATE_28800 NRF_UARTE_BAUDRATE_28800 + #define NRF_UART_BAUDRATE_38400 NRF_UARTE_BAUDRATE_38400 + #define NRF_UART_BAUDRATE_57600 NRF_UARTE_BAUDRATE_57600 + #define NRF_UART_BAUDRATE_76800 NRF_UARTE_BAUDRATE_76800 + #define NRF_UART_BAUDRATE_115200 NRF_UARTE_BAUDRATE_115200 + #define NRF_UART_BAUDRATE_230400 NRF_UARTE_BAUDRATE_230400 + #define NRF_UART_BAUDRATE_250000 NRF_UARTE_BAUDRATE_250000 + #define NRF_UART_BAUDRATE_460800 NRF_UARTE_BAUDRATE_460800 + #define NRF_UART_BAUDRATE_921600 NRF_UARTE_BAUDRATE_921600 + #define NRF_UART_BAUDRATE_1000000 NRF_UARTE_BAUDRATE_1000000 + typedef nrf_uarte_baudrate_t nrf_uart_baudrate_t; + #define NRF_UART_ERROR_OVERRUN_MASK NRF_UARTE_ERROR_OVERRUN_MASK + #define NRF_UART_ERROR_PARITY_MASK NRF_UARTE_ERROR_PARITY_MASK + #define NRF_UART_ERROR_FRAMING_MASK NRF_UARTE_ERROR_PARITY_MASK + #define NRF_UART_ERROR_BREAK_MASK NRF_UARTE_ERROR_BREAK_MASK + typedef nrf_uarte_error_mask_t nrf_uart_error_mask_t; + #define NRF_UART_HWFC_DISABLED NRF_UARTE_HWFC_DISABLED + #define NRF_UART_HWFC_ENABLED NRF_UARTE_HWFC_ENABLED + typedef nrf_uarte_hwfc_t nrf_uart_hwfc_t; + #define NRF_UART_PARITY_EXCLUDED NRF_UARTE_PARITY_EXCLUDED + #define NRF_UART_PARITY_INCLUDED NRF_UARTE_PARITY_INCLUDED + typedef nrf_uarte_parity_t nrf_uart_parity_t; + typedef nrf_uarte_task_t nrf_uart_task_t; + typedef nrf_uarte_event_t nrf_uart_event_t; + #define NRF_UART_PSEL_DISCONNECTED NRF_UARTE_PSEL_DISCONNECTED + #define nrf_uart_event_clear(...) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_uart UART driver - legacy layer + * @{ + * @ingroup nrf_uart + * @brief Layer providing compatibility with the former API. + */ + +/** + * @brief Structure for the UART driver instance. + */ +typedef struct +{ + uint8_t inst_idx; +#if defined(NRF_DRV_UART_WITH_UARTE) + nrfx_uarte_t uarte; +#endif +#if defined(NRF_DRV_UART_WITH_UART) + nrfx_uart_t uart; +#endif +} nrf_drv_uart_t; + +/** + * @brief Macro for creating an UART driver instance. + */ +#define NRF_DRV_UART_INSTANCE(id) \ +{ \ + .inst_idx = id, \ + NRF_DRV_UART_CREATE_UARTE(id) \ + NRF_DRV_UART_CREATE_UART(id) \ +} + +/** + * @brief Types of UART driver events. + */ +typedef enum +{ + NRF_DRV_UART_EVT_TX_DONE, ///< Requested TX transfer completed. + NRF_DRV_UART_EVT_RX_DONE, ///< Requested RX transfer completed. + NRF_DRV_UART_EVT_ERROR, ///< Error reported by UART peripheral. +} nrf_drv_uart_evt_type_t; + +/**@brief Structure for UART configuration. */ +typedef struct +{ + uint32_t pseltxd; ///< TXD pin number. + uint32_t pselrxd; ///< RXD pin number. + uint32_t pselcts; ///< CTS pin number. + uint32_t pselrts; ///< RTS pin number. + void * p_context; ///< Context passed to interrupt handler. + nrf_uart_hwfc_t hwfc; ///< Flow control configuration. + nrf_uart_parity_t parity; ///< Parity configuration. + nrf_uart_baudrate_t baudrate; ///< Baudrate. + uint8_t interrupt_priority; ///< Interrupt priority. +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) + bool use_easy_dma; +#endif +} nrf_drv_uart_config_t; + +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) +extern uint8_t nrf_drv_uart_use_easy_dma[]; +#define NRF_DRV_UART_DEFAULT_CONFIG_USE_EASY_DMA .use_easy_dma = true, +#else +#define NRF_DRV_UART_DEFAULT_CONFIG_USE_EASY_DMA +#endif + +/**@brief UART default configuration. */ +#define NRF_DRV_UART_DEFAULT_CONFIG \ +{ \ + .pseltxd = NRF_UART_PSEL_DISCONNECTED, \ + .pselrxd = NRF_UART_PSEL_DISCONNECTED, \ + .pselcts = NRF_UART_PSEL_DISCONNECTED, \ + .pselrts = NRF_UART_PSEL_DISCONNECTED, \ + .p_context = NULL, \ + .hwfc = (nrf_uart_hwfc_t)UART_DEFAULT_CONFIG_HWFC, \ + .parity = (nrf_uart_parity_t)UART_DEFAULT_CONFIG_PARITY, \ + .baudrate = (nrf_uart_baudrate_t)UART_DEFAULT_CONFIG_BAUDRATE, \ + .interrupt_priority = UART_DEFAULT_CONFIG_IRQ_PRIORITY, \ + NRF_DRV_UART_DEFAULT_CONFIG_USE_EASY_DMA \ +} + +/**@brief Structure for UART transfer completion event. */ +typedef struct +{ + uint8_t * p_data; ///< Pointer to memory used for transfer. + uint8_t bytes; ///< Number of bytes transfered. +} nrf_drv_uart_xfer_evt_t; + +/**@brief Structure for UART error event. */ +typedef struct +{ + nrf_drv_uart_xfer_evt_t rxtx; ///< Transfer details includes number of bytes transfered. + uint32_t error_mask;///< Mask of error flags that generated the event. +} nrf_drv_uart_error_evt_t; + +/**@brief Structure for UART event. */ +typedef struct +{ + nrf_drv_uart_evt_type_t type; ///< Event type. + union + { + nrf_drv_uart_xfer_evt_t rxtx; ///< Data provided for transfer completion events. + nrf_drv_uart_error_evt_t error;///< Data provided for error event. + } data; +} nrf_drv_uart_event_t; + +/** + * @brief UART interrupt event handler. + * + * @param[in] p_event Pointer to event structure. Event is allocated on the stack so it is available + * only within the context of the event handler. + * @param[in] p_context Context passed to interrupt handler, set on initialization. + */ +typedef void (*nrf_uart_event_handler_t)(nrf_drv_uart_event_t * p_event, void * p_context); + +/** + * @brief Function for initializing the UART driver. + * + * This function configures and enables UART. After this function GPIO pins are controlled by UART. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Initial configuration. + * @param[in] event_handler Event handler provided by the user. If not provided driver works in + * blocking mode. + * + * @retval NRFX_SUCCESS If initialization was successful. + * @retval NRFX_ERROR_INVALID_STATE If driver is already initialized. + */ +ret_code_t nrf_drv_uart_init(nrf_drv_uart_t const * p_instance, + nrf_drv_uart_config_t const * p_config, + nrf_uart_event_handler_t event_handler); + +/** + * @brief Function for uninitializing the UART driver. + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_uninit(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for getting the address of a specific UART task. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] task Task. + * + * @return Task address. + */ +__STATIC_INLINE +uint32_t nrf_drv_uart_task_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_task_t task); + +/** + * @brief Function for getting the address of a specific UART event. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] event Event. + * + * @return Event address. + */ +__STATIC_INLINE +uint32_t nrf_drv_uart_event_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_event_t event); + +/** + * @brief Function for sending data over UART. + * + * If an event handler was provided in nrf_drv_uart_init() call, this function + * returns immediately and the handler is called when the transfer is done. + * Otherwise, the transfer is performed in blocking mode, i.e. this function + * returns when the transfer is finished. Blocking mode is not using interrupt so + * there is no context switching inside the function. + * + * @note Peripherals using EasyDMA (i.e. UARTE) require that the transfer buffers + * are placed in the Data RAM region. If they are not and UARTE instance is + * used, this function will fail with error code NRFX_ERROR_INVALID_ADDR. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_data Pointer to data. + * @param[in] length Number of bytes to send. + * + * @retval NRFX_SUCCESS If initialization was successful. + * @retval NRFX_ERROR_BUSY If driver is already transferring. + * @retval NRFX_ERROR_FORBIDDEN If the transfer was aborted from a different context + * (blocking mode only, also see @ref nrf_drv_uart_rx_disable). + * @retval NRFX_ERROR_INVALID_ADDR If p_data does not point to RAM buffer (UARTE only). + */ +__STATIC_INLINE +ret_code_t nrf_drv_uart_tx(nrf_drv_uart_t const * p_instance, + uint8_t const * const p_data, + uint8_t length); + +/** + * @brief Function for checking if UART is currently transmitting. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @retval true If UART is transmitting. + * @retval false If UART is not transmitting. + */ +__STATIC_INLINE +bool nrf_drv_uart_tx_in_progress(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for aborting any ongoing transmission. + * @note @ref NRF_DRV_UART_EVT_TX_DONE event will be generated in non-blocking mode. Event will + * contain number of bytes sent until abort was called. If Easy DMA is not used event will be + * called from the function context. If Easy DMA is used it will be called from UART interrupt + * context. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_tx_abort(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for receiving data over UART. + * + * If an event handler was provided in the nrf_drv_uart_init() call, this function + * returns immediately and the handler is called when the transfer is done. + * Otherwise, the transfer is performed in blocking mode, i.e. this function + * returns when the transfer is finished. Blocking mode is not using interrupt so + * there is no context switching inside the function. + * The receive buffer pointer is double buffered in non-blocking mode. The secondary + * buffer can be set immediately after starting the transfer and will be filled + * when the primary buffer is full. The double buffering feature allows + * receiving data continuously. + * + * @note Peripherals using EasyDMA (i.e. UARTE) require that the transfer buffers + * are placed in the Data RAM region. If they are not and UARTE driver instance + * is used, this function will fail with error code NRFX_ERROR_INVALID_ADDR. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_data Pointer to data. + * @param[in] length Number of bytes to receive. + * + * @retval NRFX_SUCCESS If initialization was successful. + * @retval NRFX_ERROR_BUSY If the driver is already receiving + * (and the secondary buffer has already been set + * in non-blocking mode). + * @retval NRFX_ERROR_FORBIDDEN If the transfer was aborted from a different context + * (blocking mode only, also see @ref nrf_drv_uart_rx_disable). + * @retval NRFX_ERROR_INTERNAL If UART peripheral reported an error. + * @retval NRFX_ERROR_INVALID_ADDR If p_data does not point to RAM buffer (UARTE only). + */ +__STATIC_INLINE +ret_code_t nrf_drv_uart_rx(nrf_drv_uart_t const * p_instance, + uint8_t * p_data, + uint8_t length); + + + +/** + * @brief Function for testing the receiver state in blocking mode. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @retval true If the receiver has at least one byte of data to get. + * @retval false If the receiver is empty. + */ +__STATIC_INLINE +bool nrf_drv_uart_rx_ready(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for enabling the receiver. + * + * UART has a 6-byte-long RX FIFO and it is used to store incoming data. If a user does not call the + * UART receive function before the FIFO is filled, an overrun error will appear. Enabling the receiver + * without specifying an RX buffer is supported only in UART mode (without Easy DMA). The receiver must be + * explicitly closed by the user @sa nrf_drv_uart_rx_disable. This function asserts if the mode is wrong. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_rx_enable(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for disabling the receiver. + * + * This function must be called to close the receiver after it has been explicitly enabled by + * @sa nrf_drv_uart_rx_enable. The feature is supported only in UART mode (without Easy DMA). The function + * asserts if mode is wrong. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_rx_disable(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for aborting any ongoing reception. + * @note @ref NRF_DRV_UART_EVT_RX_DONE event will be generated in non-blocking mode. The event will + * contain the number of bytes received until abort was called. The event is called from UART interrupt + * context. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_rx_abort(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for reading error source mask. Mask contains values from @ref nrf_uart_error_mask_t. + * @note Function should be used in blocking mode only. In case of non-blocking mode, an error event is + * generated. Function clears error sources after reading. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @retval Mask of reported errors. + */ +__STATIC_INLINE +uint32_t nrf_drv_uart_errorsrc_get(nrf_drv_uart_t const * p_instance); + + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) + #define NRF_DRV_UART_USE_UARTE (nrf_drv_uart_use_easy_dma[p_instance->inst_idx]) +#elif defined(NRF_DRV_UART_WITH_UARTE) + #define NRF_DRV_UART_USE_UARTE true +#else + #define NRF_DRV_UART_USE_UARTE false +#endif +#define NRF_DRV_UART_USE_UART (!NRF_DRV_UART_USE_UARTE) + +__STATIC_INLINE +void nrf_drv_uart_uninit(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + nrfx_uarte_uninit(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_uninit(&p_instance->uart); + } +} + +__STATIC_INLINE +uint32_t nrf_drv_uart_task_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_task_t task) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_task_address_get(&p_instance->uarte, + (nrf_uarte_task_t)task); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_task_address_get(&p_instance->uart, task); + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_uart_event_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_event_t event) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_event_address_get(&p_instance->uarte, + (nrf_uarte_event_t)event); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_event_address_get(&p_instance->uart, event); + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_uart_tx(nrf_drv_uart_t const * p_instance, + uint8_t const * p_data, + uint8_t length) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_tx(&p_instance->uarte, + p_data, + length); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_tx(&p_instance->uart, + p_data, + length); + } + return result; +} + +__STATIC_INLINE +bool nrf_drv_uart_tx_in_progress(nrf_drv_uart_t const * p_instance) +{ + bool result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_tx_in_progress(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_tx_in_progress(&p_instance->uart); + } + return result; +} + +__STATIC_INLINE +void nrf_drv_uart_tx_abort(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + nrfx_uarte_tx_abort(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_tx_abort(&p_instance->uart); + } +} + +__STATIC_INLINE +ret_code_t nrf_drv_uart_rx(nrf_drv_uart_t const * p_instance, + uint8_t * p_data, + uint8_t length) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_rx(&p_instance->uarte, + p_data, + length); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_rx(&p_instance->uart, + p_data, + length); + } + return result; +} + +__STATIC_INLINE +bool nrf_drv_uart_rx_ready(nrf_drv_uart_t const * p_instance) +{ + bool result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_rx_ready(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_rx_ready(&p_instance->uart); + } + return result; +} + +__STATIC_INLINE +void nrf_drv_uart_rx_enable(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + NRFX_ASSERT(false); // not supported + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_rx_enable(&p_instance->uart); + } +} + +__STATIC_INLINE +void nrf_drv_uart_rx_disable(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + NRFX_ASSERT(false); // not supported + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_rx_disable(&p_instance->uart); + } +} + +__STATIC_INLINE +void nrf_drv_uart_rx_abort(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + nrfx_uarte_rx_abort(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_rx_abort(&p_instance->uart); + } +} + +__STATIC_INLINE +uint32_t nrf_drv_uart_errorsrc_get(nrf_drv_uart_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_errorsrc_get(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrf_uart_event_clear(p_instance->uart.p_reg, NRF_UART_EVENT_ERROR); + result = nrfx_uart_errorsrc_get(&p_instance->uart); + } + return result; +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_UART_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd.h new file mode 100644 index 0000000..db30fce --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd.h @@ -0,0 +1,272 @@ +/** + * Copyright (c) 2016 - 2019, 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 NRF_DRV_USBD_H__ +#define NRF_DRV_USBD_H__ + +#include "nrfx.h" +#include "nrfx_usbd.h" +#include "nrf_drv_usbd_errata.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_usbd USBD driver - legacy layer + * @{ + * @ingroup nrf_usbd + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_DMASCHEDULER_PRIORITIZED NRFX_USBD_DMASCHEDULER_PRIORITIZED +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_DMASCHEDULER_ROUNDROBIN NRFX_USBD_DMASCHEDULER_ROUNDROBIN +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPSIZE NRFX_USBD_EPSIZE +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_ISOSIZE NRFX_USBD_ISOSIZE +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_FEEDER_BUFFER_SIZE NRFX_USBD_EPSIZE +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN NRFX_USBD_EPIN +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT NRFX_USBD_EPOUT + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_ep_t nrf_drv_usbd_ep_t; +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT0 NRFX_USBD_EPOUT0 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT1 NRFX_USBD_EPOUT1 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT2 NRFX_USBD_EPOUT2 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT3 NRFX_USBD_EPOUT3 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT4 NRFX_USBD_EPOUT4 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT5 NRFX_USBD_EPOUT5 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT6 NRFX_USBD_EPOUT6 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT7 NRFX_USBD_EPOUT7 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPOUT8 NRFX_USBD_EPOUT8 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN0 NRFX_USBD_EPIN0 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN1 NRFX_USBD_EPIN1 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN2 NRFX_USBD_EPIN2 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN3 NRFX_USBD_EPIN3 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN4 NRFX_USBD_EPIN4 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN5 NRFX_USBD_EPIN5 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN6 NRFX_USBD_EPIN6 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN7 NRFX_USBD_EPIN7 +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EPIN8 NRFX_USBD_EPIN8 + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_event_type_t nrf_drv_usbd_event_type_t; +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_SOF NRFX_USBD_EVT_SOF +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_RESET NRFX_USBD_EVT_RESET +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_SUSPEND NRFX_USBD_EVT_SUSPEND +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_RESUME NRFX_USBD_EVT_RESUME +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_WUREQ NRFX_USBD_EVT_WUREQ +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_SETUP NRFX_USBD_EVT_SETUP +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_EPTRANSFER NRFX_USBD_EVT_EPTRANSFER +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_EVT_CNT NRFX_USBD_EVT_CNT + +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_USBD_EP_OK NRFX_USBD_EP_OK +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_USBD_EP_WAITING NRFX_USBD_EP_WAITING +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_USBD_EP_OVERLOAD NRFX_USBD_EP_OVERLOAD +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_USBD_EP_ABORTED NRFX_USBD_EP_ABORTED + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_ep_status_t nrf_drv_usbd_ep_status_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_evt_t nrf_drv_usbd_evt_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_event_handler_t nrf_drv_usbd_event_handler_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_data_ptr_t nrf_drv_usbd_data_ptr_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_ep_transfer_t nrf_drv_usbd_ep_transfer_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_transfer_flags_t nrf_drv_usbd_transfer_flags_t; +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_TRANSFER_ZLP_FLAG NRFX_USBD_TRANSFER_ZLP_FLAG + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_transfer_t nrf_drv_usbd_transfer_t; + +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_TRANSFER_IN_FLAGS(name, tx_buff, tx_size, tx_flags) \ + NRFX_USBD_TRANSFER_IN(name, tx_buff, tx_size, tx_flags) +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_TRANSFER_IN(name, tx_buff, tx_size) \ + NRFX_USBD_TRANSFER_IN(name, tx_buff, tx_size, 0) +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_TRANSFER_IN_ZLP(name, tx_buff, tx_size) \ + NRFX_USBD_TRANSFER_IN(name, tx_buff, tx_size, NRFX_USBD_TRANSFER_ZLP_FLAG) +/** @brief Type definition for forwarding the new implementation. */ +#define NRF_DRV_USBD_TRANSFER_OUT NRFX_USBD_TRANSFER_OUT + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_feeder_t nrf_drv_usbd_feeder_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_consumer_t nrf_drv_usbd_consumer_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_handler_t nrf_drv_usbd_handler_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_handler_desc_t nrf_drv_usbd_handler_desc_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_usbd_setup_t nrf_drv_usbd_setup_t; + +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_init nrfx_usbd_init +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_enable nrfx_usbd_enable +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_disable nrfx_usbd_disable +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_start nrfx_usbd_start +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_stop nrfx_usbd_stop +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_is_initialized nrfx_usbd_is_initialized +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_is_enabled nrfx_usbd_is_enabled +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_is_started nrfx_usbd_is_started +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_suspend nrfx_usbd_suspend +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_wakeup_req nrfx_usbd_wakeup_req +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_suspend_check nrfx_usbd_suspend_check +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_suspend_irq_config nrfx_usbd_suspend_irq_config +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_active_irq_config nrfx_usbd_active_irq_config +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_force_bus_wakeup nrfx_usbd_force_bus_wakeup +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_bus_suspend_check nrfx_usbd_bus_suspend_check +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_max_packet_size_set nrfx_usbd_ep_max_packet_size_set +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_max_packet_size_get nrfx_usbd_ep_max_packet_size_get +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_enable_check nrfx_usbd_ep_enable_check +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_enable nrfx_usbd_ep_enable +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_disable nrfx_usbd_ep_disable +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_default_config nrfx_usbd_ep_default_config +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_transfer nrfx_usbd_ep_transfer +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_handled_transfer nrfx_usbd_ep_handled_transfer +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_feeder_buffer_get nrfx_usbd_feeder_buffer_get +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_status_get nrfx_usbd_ep_status_get +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_epout_size_get nrfx_usbd_epout_size_get +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_is_busy nrfx_usbd_ep_is_busy +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_stall nrfx_usbd_ep_stall +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_stall_clear nrfx_usbd_ep_stall_clear +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_stall_check nrfx_usbd_ep_stall_check +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_dtoggle_clear nrfx_usbd_ep_dtoggle_clear +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_setup_get nrfx_usbd_setup_get +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_setup_data_clear nrfx_usbd_setup_data_clear +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_setup_clear nrfx_usbd_setup_clear +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_setup_stall nrfx_usbd_setup_stall +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_ep_abort nrfx_usbd_ep_abort +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_last_setup_dir_get nrfx_usbd_last_setup_dir_get +/** @brief Type definition for forwarding the new implementation. */ +#define nrf_drv_usbd_transfer_out_drop nrfx_usbd_transfer_out_drop + +/** @brief Type definition for forwarding the new implementation. */ +static inline ret_code_t nrf_drv_usbd_uninit(void) +{ + nrfx_usbd_uninit(); + return NRF_SUCCESS; +} + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* NRF_DRV_USBD_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd_errata.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd_errata.h new file mode 100644 index 0000000..00c589b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_usbd_errata.h @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRF_DRV_USBD_ERRATA_H__ +#define NRF_DRV_USBD_ERRATA_H__ + +#include "nrfx.h" + +#ifndef NRFX_USBD_ERRATA_ENABLE + #ifdef NRF_DRV_USBD_ERRATA_ENABLE + #define NRFX_USBD_ERRATA_ENABLE NRF_DRV_USBD_ERRATA_ENABLE + #endif +#endif + +#include "../src/nrfx_usbd_errata.h" + +#ifndef NRF_DRV_USBD_ERRATA_ENABLE +#define NRF_DRV_USBD_ERRATA_ENABLE NRFX_USBD_ERRATA_ENABLE +#endif + +#define nrf_drv_usbd_errata_type_52840 nrfx_usbd_errata_type_52840 +#define nrf_drv_usbd_errata_type_52840_proto1 nrfx_usbd_errata_type_52840_proto1 +#define nrf_drv_usbd_errata_type_52840_fp1 nrfx_usbd_errata_type_52840_fp1 +#define nrf_drv_usbd_errata_type_52840_fp2 nrfx_usbd_errata_type_52840_fp2 +#define nrf_drv_usbd_errata_104 nrfx_usbd_errata_104 +#define nrf_drv_usbd_errata_154 nrfx_usbd_errata_154 +#define nrf_drv_usbd_errata_166 nrfx_usbd_errata_166 +#define nrf_drv_usbd_errata_171 nrfx_usbd_errata_171 +#define nrf_drv_usbd_errata_187 nrfx_usbd_errata_187 +#define nrf_drv_usbd_errata_sizeepout_rw nrfx_usbd_errata_sizeepout_rw +#define nrf_drv_usb_errata_199 nrfx_usb_errata_199 + +#endif /* NRF_DRV_USBD_ERRATA_H__ */ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_wdt.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_wdt.h new file mode 100644 index 0000000..23aa637 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/legacy/nrf_drv_wdt.h @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2014 - 2019, 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 NRF_DRV_WDT_H__ +#define NRF_DRV_WDT_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_wdt WDT driver - legacy layer + * @{ + * @ingroup nrf_wdt + * + * @brief A layer providing compatibility with former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_wdt_config_t nrf_drv_wdt_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_WDT_DEAFULT_CONFIG NRFX_WDT_DEAFULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_wdt_event_handler_t nrfx_wdt_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_channel_id nrfx_wdt_channel_id + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_channel_alloc nrfx_wdt_channel_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_enable nrfx_wdt_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_feed nrfx_wdt_feed +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_channel_feed nrfx_wdt_channel_feed + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_ppi_task_addr nrfx_wdt_ppi_task_addr +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_ppi_event_addr nrfx_wdt_ppi_event_addr + +/** + * @brief This function initializes watchdog. + * + * @param[in] p_config Pointer to the structure with initial configuration. Default + * configuration used if NULL. + * @param[in] wdt_event_handler Specifies event handler provided by user. + * + * @note Function asserts if wdt_event_handler is NULL. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +__STATIC_INLINE ret_code_t nrf_drv_wdt_init(nrf_drv_wdt_config_t const * p_config, + nrf_wdt_event_handler_t wdt_event_handler) +{ + if (p_config == NULL) + { + static const nrfx_wdt_config_t default_config = NRFX_WDT_DEAFULT_CONFIG; + p_config = &default_config; + } + return nrfx_wdt_init(p_config, wdt_event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_WDT_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_config.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_config.h new file mode 100644 index 0000000..b006b6b --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_config.h @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRFX_CONFIG_H__ +#define NRFX_CONFIG_H__ + +// TODO - temporary redirection +#include + +#endif // NRFX_CONFIG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_glue.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_glue.h new file mode 100644 index 0000000..20c5fbd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_glue.h @@ -0,0 +1,338 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRFX_GLUE_H__ +#define NRFX_GLUE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrfx_glue nrfx_glue.h + * @{ + * @ingroup nrfx + * + * @brief This file contains macros that should be implemented according to + * the needs of the host environment into which @em nrfx is integrated. + */ + +#include + +#include + +//------------------------------------------------------------------------------ + +#include +/** + * @brief Macro for placing a runtime assertion. + * + * @param expression Expression to evaluate. + */ +#define NRFX_ASSERT(expression) ASSERT(expression) + +#include +/** + * @brief Macro for placing a compile time assertion. + * + * @param expression Expression to evaluate. + */ +#define NRFX_STATIC_ASSERT(expression) STATIC_ASSERT(expression) + +//------------------------------------------------------------------------------ + +#ifdef NRF51 +#ifdef SOFTDEVICE_PRESENT +#define INTERRUPT_PRIORITY_IS_VALID(pri) (((pri) == 1) || ((pri) == 3)) +#else +#define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 4) +#endif //SOFTDEVICE_PRESENT +#else +#ifdef SOFTDEVICE_PRESENT +#define INTERRUPT_PRIORITY_IS_VALID(pri) ((((pri) > 1) && ((pri) < 4)) || \ + (((pri) > 4) && ((pri) < 8))) +#else +#define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 8) +#endif //SOFTDEVICE_PRESENT +#endif //NRF52 + +/** + * @brief Macro for setting the priority of a specific IRQ. + * + * @param irq_number IRQ number. + * @param priority Priority to set. + */ +#define NRFX_IRQ_PRIORITY_SET(irq_number, priority) \ + _NRFX_IRQ_PRIORITY_SET(irq_number, priority) +static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number, + uint8_t priority) +{ + ASSERT(INTERRUPT_PRIORITY_IS_VALID(priority)); + NVIC_SetPriority(irq_number, priority); +} + +/** + * @brief Macro for enabling a specific IRQ. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_ENABLE(irq_number) _NRFX_IRQ_ENABLE(irq_number) +static inline void _NRFX_IRQ_ENABLE(IRQn_Type irq_number) +{ + NVIC_EnableIRQ(irq_number); +} + +/** + * @brief Macro for checking if a specific IRQ is enabled. + * + * @param irq_number IRQ number. + * + * @retval true If the IRQ is enabled. + * @retval false Otherwise. + */ +#define NRFX_IRQ_IS_ENABLED(irq_number) _NRFX_IRQ_IS_ENABLED(irq_number) +static inline bool _NRFX_IRQ_IS_ENABLED(IRQn_Type irq_number) +{ + return 0 != (NVIC->ISER[irq_number / 32] & (1UL << (irq_number % 32))); +} + +/** + * @brief Macro for disabling a specific IRQ. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_DISABLE(irq_number) _NRFX_IRQ_DISABLE(irq_number) +static inline void _NRFX_IRQ_DISABLE(IRQn_Type irq_number) +{ + NVIC_DisableIRQ(irq_number); +} + +/** + * @brief Macro for setting a specific IRQ as pending. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_PENDING_SET(irq_number) _NRFX_IRQ_PENDING_SET(irq_number) +static inline void _NRFX_IRQ_PENDING_SET(IRQn_Type irq_number) +{ + NVIC_SetPendingIRQ(irq_number); +} + +/** + * @brief Macro for clearing the pending status of a specific IRQ. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_PENDING_CLEAR(irq_number) _NRFX_IRQ_PENDING_CLEAR(irq_number) +static inline void _NRFX_IRQ_PENDING_CLEAR(IRQn_Type irq_number) +{ + NVIC_ClearPendingIRQ(irq_number); +} + +/** + * @brief Macro for checking the pending status of a specific IRQ. + * + * @retval true If the IRQ is pending. + * @retval false Otherwise. + */ +#define NRFX_IRQ_IS_PENDING(irq_number) _NRFX_IRQ_IS_PENDING(irq_number) +static inline bool _NRFX_IRQ_IS_PENDING(IRQn_Type irq_number) +{ + return (NVIC_GetPendingIRQ(irq_number) == 1); +} + +#include +#include +/** + * @brief Macro for entering into a critical section. + */ +#define NRFX_CRITICAL_SECTION_ENTER() CRITICAL_REGION_ENTER() + +/** + * @brief Macro for exiting from a critical section. + */ +#define NRFX_CRITICAL_SECTION_EXIT() CRITICAL_REGION_EXIT() + +//------------------------------------------------------------------------------ + +/** + * @brief When set to a non-zero value, this macro specifies that + * @ref nrfx_coredep_delay_us uses a precise DWT-based solution. + * A compilation error is generated if the DWT unit is not present + * in the SoC used. + */ +#define NRFX_DELAY_DWT_BASED 0 + +#include + +#define NRFX_DELAY_US(us_time) nrfx_coredep_delay_us(us_time) + +//------------------------------------------------------------------------------ + +#include + +/** + * @brief Atomic 32 bit unsigned type. + */ +#define nrfx_atomic_t nrfx_atomic_u32_t + +/** + * @brief Stores value to an atomic object and returns previously stored value. + * + * @param[in] p_data Atomic memory pointer. + * @param[in] value Value to store. + * + * @return Old value stored into atomic object. + */ +#define NRFX_ATOMIC_FETCH_STORE(p_data, value) nrfx_atomic_u32_fetch_store(p_data, value) + +/** + * @brief Performs logical OR operation on an atomic object and returns previously stored value. + * + * @param[in] p_data Atomic memory pointer. + * @param[in] value Value of second operand of OR operation. + * + * @return Old value stored into atomic object. + */ +#define NRFX_ATOMIC_FETCH_OR(p_data, value) nrfx_atomic_u32_fetch_or(p_data, value) + +/** + * @brief Performs logical AND operation on an atomic object and returns previously stored value. + * + * @param[in] p_data Atomic memory pointer. + * @param[in] value Value of second operand of AND operation. + * + * @return Old value stored into atomic object. + */ +#define NRFX_ATOMIC_FETCH_AND(p_data, value) nrfx_atomic_u32_fetch_and(p_data, value) + +/** + * @brief Performs logical XOR operation on an atomic object and returns previously stored value. + * + * @param[in] p_data Atomic memory pointer. + * @param[in] value Value of second operand of XOR operation. + * + * @return Old value stored into atomic object. + */ +#define NRFX_ATOMIC_FETCH_XOR(p_data, value) nrfx_atomic_u32_fetch_xor(p_data, value) + +/** + * @brief Performs logical ADD operation on an atomic object and returns previously stored value. + * + * @param[in] p_data Atomic memory pointer. + * @param[in] value Value of second operand of ADD operation. + * + * @return Old value stored into atomic object. + */ +#define NRFX_ATOMIC_FETCH_ADD(p_data, value) nrfx_atomic_u32_fetch_add(p_data, value) + +/** + * @brief Performs logical SUB operation on an atomic object and returns previously stored value. + * + * @param[in] p_data Atomic memory pointer. + * @param[in] value Value of second operand of SUB operation. + * + * @return Old value stored into atomic object. + */ +#define NRFX_ATOMIC_FETCH_SUB(p_data, value) nrfx_atomic_u32_fetch_sub(p_data, value) + +//------------------------------------------------------------------------------ +#ifndef NRFX_CUSTOM_ERROR_CODES + +#include +/** + * @brief When set to a non-zero value, this macro specifies that the + * @ref nrfx_error_codes and the @ref ret_code_t type itself are defined + * in a customized way and the default definitions from @c + * should not be used. + */ +#define NRFX_CUSTOM_ERROR_CODES 1 + +typedef ret_code_t nrfx_err_t; + +#define NRFX_SUCCESS NRF_SUCCESS +#define NRFX_ERROR_INTERNAL NRF_ERROR_INTERNAL +#define NRFX_ERROR_NO_MEM NRF_ERROR_NO_MEM +#define NRFX_ERROR_NOT_SUPPORTED NRF_ERROR_NOT_SUPPORTED +#define NRFX_ERROR_INVALID_PARAM NRF_ERROR_INVALID_PARAM +#define NRFX_ERROR_INVALID_STATE NRF_ERROR_INVALID_STATE +#define NRFX_ERROR_INVALID_LENGTH NRF_ERROR_INVALID_LENGTH +#define NRFX_ERROR_TIMEOUT NRF_ERROR_TIMEOUT +#define NRFX_ERROR_FORBIDDEN NRF_ERROR_FORBIDDEN +#define NRFX_ERROR_NULL NRF_ERROR_NULL +#define NRFX_ERROR_INVALID_ADDR NRF_ERROR_INVALID_ADDR +#define NRFX_ERROR_BUSY NRF_ERROR_BUSY +#define NRFX_ERROR_ALREADY_INITIALIZED NRF_ERROR_MODULE_ALREADY_INITIALIZED + +#define NRFX_ERROR_DRV_TWI_ERR_OVERRUN NRF_ERROR_DRV_TWI_ERR_OVERRUN +#define NRFX_ERROR_DRV_TWI_ERR_ANACK NRF_ERROR_DRV_TWI_ERR_ANACK +#define NRFX_ERROR_DRV_TWI_ERR_DNACK NRF_ERROR_DRV_TWI_ERR_DNACK + +#endif // NRFX_CUSTOM_ERROR_CODES +//------------------------------------------------------------------------------ + +#include +/** + * @brief Bitmask defining PPI channels reserved to be used outside of nrfx. + */ +#define NRFX_PPI_CHANNELS_USED NRF_PPI_CHANNELS_USED + +/** + * @brief Bitmask defining PPI groups reserved to be used outside of nrfx. + */ +#define NRFX_PPI_GROUPS_USED NRF_PPI_GROUPS_USED + +/** + * @brief Bitmask defining SWI instances reserved to be used outside of nrfx. + */ +#define NRFX_SWI_USED NRF_SWI_USED + +/** + * @brief Bitmask defining TIMER instances reserved to be used outside of nrfx. + */ +#define NRFX_TIMERS_USED NRF_TIMERS_USED + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRFX_GLUE_H__ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_log.h b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_log.h new file mode 100644 index 0000000..c4d81a7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/integration/nrfx/nrfx_log.h @@ -0,0 +1,152 @@ +/** + * Copyright (c) 2017 - 2019, 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 NRFX_LOG_H__ +#define NRFX_LOG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(NRFX_LOG_MODULE) +#define NRF_LOG_MODULE_NAME NRFX_LOG_MODULE + +#define NRFX_CONFIG_ENTRY(x) CONCAT_3(NRFX_, NRFX_LOG_MODULE, x) + +#if NRFX_CHECK(NRFX_CONFIG_ENTRY(_CONFIG_LOG_ENABLED)) +#define NRF_LOG_LEVEL NRFX_CONFIG_ENTRY(_CONFIG_LOG_LEVEL) +#define NRF_LOG_INFO_COLOR NRFX_CONFIG_ENTRY(_CONFIG_INFO_COLOR) +#define NRF_LOG_DEBUG_COLOR NRFX_CONFIG_ENTRY(_CONFIG_DEBUG_COLOR) +#else +#define NRF_LOG_LEVEL 0 +#endif +#endif // defined(NRFX_LOG_MODULE) + +#include + +#if defined(NRFX_LOG_MODULE) +NRF_LOG_MODULE_REGISTER(); +#endif + +#define TEST_MACRO_INFO(...) NRF_LOG_INFO(__VA_ARGS__) +/** + * @defgroup nrfx_log nrfx_log.h + * @{ + * @ingroup nrfx + * + * @brief This file contains macros that should be implemented according to + * the needs of the host environment into which @em nrfx is integrated. + */ + +/** + * @brief Macro for logging a message with the severity level ERROR. + */ +#define NRFX_LOG_ERROR(...) NRF_LOG_ERROR(__VA_ARGS__) + +/** + * @brief Macro for logging a message with the severity level WARNING. + */ +#define NRFX_LOG_WARNING(...) NRF_LOG_WARNING(__VA_ARGS__) + +/** + * @brief Macro for logging a message with the severity level INFO. + */ +#define NRFX_LOG_INFO(...) TEST_MACRO_INFO(__VA_ARGS__) + +/** + * @brief Macro for logging a message with the severity level DEBUG. + */ +#define NRFX_LOG_DEBUG(...) NRF_LOG_DEBUG(__VA_ARGS__) + + +/** + * @brief Macro for logging a memory dump with the severity level ERROR. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_ERROR(p_memory, length) \ + NRF_LOG_HEXDUMP_ERROR(p_memory, length) + +/** + * @brief Macro for logging a memory dump with the severity level WARNING. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_WARNING(p_memory, length) \ + NRF_LOG_HEXDUMP_WARNING(p_memory, length) + +/** + * @brief Macro for logging a memory dump with the severity level INFO. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_INFO(p_memory, length) \ + NRF_LOG_HEXDUMP_INFO(p_memory, length) + +/** + * @brief Macro for logging a memory dump with the severity level DEBUG. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_DEBUG(p_memory, length) \ + NRF_LOG_HEXDUMP_DEBUG(p_memory, length) + + +/** + * @brief Macro for getting the textual representation of a given error code. + * + * @param[in] error_code Error code. + * + * @return String containing the textual representation of the error code. + */ +#define NRFX_LOG_ERROR_STRING_GET(error_code) \ + NRF_LOG_ERROR_STRING_GET(error_code) + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRFX_LOG_H__ diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/license.txt b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/license.txt similarity index 100% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/license.txt rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/license.txt diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/CHANGELOG.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/CHANGELOG.md new file mode 100644 index 0000000..a148f33 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/CHANGELOG.md @@ -0,0 +1,230 @@ +# Changelog +All notable changes to this project are documented in this file. + +## [1.8.0] - 2019-08-27 +### Added +- Added support for nRF52833. +- Added bus recovery feature in the TWI and TWIM drivers. +- Added the nrfx_gppi helper layer to facilitate developing generic code that can utilize PPI or DPPI, depending on which interface is available in a given SoC. + +### Changed +- Updated MDK to version 8.27.0. + +### Fixed +- Fixed an issue in the TWIM driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred. +- Fixed a frame timing bug in the NFCT driver. Previously, the timing of the SENS_RES response could be violated after the NFCT peripheral was put to the Sleep state with the SLP_REQ command. + +## [1.7.2] - 2019-07-25 +### Added +- Added functions in the DPPI, GPIOTE, PPI, RTC, and TIMER HALs for getting tasks and events specified by index. +- Added the possibility of suspending transfers in the TWI driver. This allows combining several transfers into one continuous TWI transaction. +- Added termination of transfers at deinitialization of the UARTE driver. +- Added buffer alignment checks in the QSPI driver. +- Introduced the NRFX_OFFSETOF macro that duplicates the functionality of the built-in offsetof() mechanism, but can be used without issues also with non-constant expressions. +- Added an alternative way of ending the DMA transfer loop in the USBD driver. +- Added the CTSTARTED and CTSTOPPED events to the CLOCK HAL. + +### Changed +- Removed an assertion that prevented setting the data payload size of isochronous endpoints to zero, to fulfill requirements of the USB 2.0 specification, paragraph 5.6.3. +- Declared the tx_buffer_length field in the UART driver's control block as volatile to prevent issues in case of compilation with high optimization level. + +### Fixed +- Fixed an incorrect conversion of frequency values in the RADIO HAL. +- Fixed an incorrectly enabled interrupt in the QSPI driver. +- Corrected the LFCLK source selection values in the template configuration file for nRF9160. +- Fixed support for external LFCLK sources for nRF52811. + +## [1.7.1] - 2019-04-08 +### Added +- Added functions in the NVMC driver for getting the flash page size, the count of pages and the total flash size. + +### Fixed +- Fixed handling of short unaligned write requests (1 or 2 bytes in length) in the nrfx_nvmc_bytes_write() function. + +## [1.7.0] - 2019-03-29 +### Added +- Added drivers for NVMC and TEMP. +- Added HALs: AAR and FICR. +- Added support for the custom instruction long frame mode in the QSPI driver. + +### Changed +- Reworked HAL for NVMC. Now it can be used for all SoCs supported by nrfx. +- Reworked HAL for TEMP. +- Improved documentation. Now it is more precise and can be generated without warnings with newer versions of doxygen. +- Improved the UARTE driver to consume less current after the TX operation. Now at the end of the transmission the transmitter is turned off by the STOPTX task. +- Improved C++ support in drivers. Now fields in structures are filled up in the correct order. +- Changed to size_t the type used for holding the amount of data in the TWIS driver. + +### Fixed +- Fixed a race condition in the USBD driver. It could occur when an IN transfer was interrupted by an OUT transaction, which in turn was interrupted by a process with a higher priority. + +## [1.6.2] - 2019-02-12 +### Added +- Added the possibility to use the macro NRFX_COREDEP_DELAY_US_LOOP_CYCLES to specify the number of cycles consumed by one iteration of the internal loop in the function nrfx_coredep_delay_us(). + +### Changed +- Updated MDK to version 8.24.1. + +## [1.6.1] - 2019-01-29 +### Fixed +- Fixed an issue in the NFCT driver that caused a performance loss on nRF52832. The interrupt configuration is now properly restored after the NRFX_NFCT_EVT_FIELD_LOST event. + +## [1.6.0] - 2019-01-18 +### Added +- Added support for nRF52811. +- Added support for the legacy peripherals SPI, TWI, and UART in nRF52810. +- Added support for SAMPLERATE in nrf_saadc.h. +- Added clearing of the STOPPED event in the nrfx_saadc_init() function to prevent driver deadlock in some cases. +- Added HALs: BPROT, MPU, MWU. +- Added function for reading the pin input buffer configuration in the GPIO HAL. +- Implemented workaround for nRF9160 anomaly 1 in the I2S driver. + +### Changed +- Improved handling of hardware anomalies in the USBD driver. +- Updated MDK to version 8.23.1. + +### Fixed +- Fixed the condition in NRFX_WAIT_FOR in the nrfx_saadc_abort() function. The macro now correctly waits for a stop of the driver. +- Fixed the pending interrupt clearing in NVIC in the nrfx_usbd_stop() function. The driver now correctly handles power management. +- Fixed the case when nrfx_uarte_tx_in_progress() function would return an incorrect value. The driver now correctly updates the tx_buffer_length variable internally. + +## [1.5.0] - 2018-12-12 +### Added +- Added support for nRF9160. +- Added allocator for DPPI. +- Added HALs: DPPI, KMU, REGULATORS, SPU, VMC. +- Added support for DPPI subscription and publishing in HALs related to nRF9160. +- Added support for instances 2 and 3 in SPIS, TWIM, TWIS, and UARTE drivers. + +### Changed +- Updated MDK to version 8.21.1. + +### Fixed +- Corrected NRFX_I2S_CONFIG_RATIO value in nrfx_config.h. It now correctly uses supported value. + +## [1.4.0] - 2018-11-30 +### Added +- Added the nrfx_is_word_aligned() function for checking whether an address is word-aligned. +- Added HAL for ACL. +- Added functions for disabling and re-enabling interrupts in the SWI driver. +- Added possibility to completely remove interrupt handling from the WDT driver. + +### Changed +- Updated the documentation for the nrfx_uarte_rx() function. It now correctly reflects the actual behavior of the function. + +### Fixed +- Corrected the type of the nrfx_uarte_xfer_evt_t structure field that holds the amount of transferred bytes. +- Corrected the way of disabling interrupts in the NFCT driver when moving the peripheral to the disabled state. +- Fixed a typo in the name of the bmRequest field in the nrfx_usbd_setup_t structure. The new correct name is bRequest. +- Fixed the nrfx_ppi_channel_fork_assign() function. It now accepts also pre-programmed channels. +- Fixed handling of long custom instruction responses in the QSPI driver. +- Fixed a bug affecting the conversion of time to ticks in the TIMER HAL. + +## [1.3.1] - 2018-09-28 +### Fixed +- Corrected the type of nrfx_usbd_ep_status_get() return value. +- Corrected calls to undefined macros in NFCT and USBD drivers. + +## [1.3.0] - 2018-09-21 +### Added +- Added HAL and driver for NFCT. +- Added driver for USBD. +- Added function for setting the burst mode in the SAADC HAL. +- Added the NRFX_ARRAY_SIZE macro. + +### Changed +- Moved the implementation of nrfx_power_clock_irq_handler() to nrfx_power.c, removed nrfx_power_clock.c. + +### Fixed +- Replaced ARRAY_SIZE macro calls with NRFX_ARRAY_SIZE ones. + +## [1.2.0] - 2018-09-06 +### Added +- Added function for checking if a specific channel is enabled in the GPIOTE HAL. +- Added support for using the QDEC driver without LED. +- Added functions for modifying only the event endpoint or only the task endpoint in the PPI HAL. +- Added function for reading the pin pull configuration in the GPIO HAL. + +### Changed +- Corrected ISOSPLIT enumerator names in the USBD HAL. + +### Fixed +- Fixed a double buffering bug that occurred in the UARTE driver after the RX abort. +- Fixed the TXRX transfers in the TWIM driver. They can now be started after transfers that are not ended with the stop condition. + +## [1.1.0] - 2018-06-15 +### Added +- Implemented workaround for nRF52832 and nRF52840 anomaly 194 in the I2S driver. +- Implemented workaround for nRF52840 anomaly 195 in the SPIM driver. +- Added HALs for CCM, ECB, and RADIO. +- Extended HALs for GPIO, PPI, SAADC, and USBD. +- Added support for external LFCLK sources. + +### Changed +- Corrected handling of transfer lengths in the TWI driver. +- Updated MDK to version 8.17.0. + +### Fixed +- Fixed logging in the PPI driver. +- Fixed SPIM interrupt definition for nRF52810. +- Fixed Slave Select configuration in the SPIM driver. +- Corrected default settings for NRF_SPIM3. +- Fixed a typo in the UARTE TXDRDY event definition. +- Corrected the TIMEOUT event clearing in the WDT interrupt handler. + +## [1.0.0] - 2018-03-21 +### Added +- Added the NRFX_WAIT_FOR macro to improve the time-out functionality in QSPI and SAADC drivers. +- Added glue layer macros for checking and modifying the pending status of interrupts. +- Added new enumeration values for interrupts and events in the UARTE HAL. +- Implemented workarounds for nRF52 anomalies 192 and 201 in the CLOCK driver. +- Implemented workaround for nRF52840 anomaly 122 in the QSPI driver. +- Implemented workaround for nRF52840 anomaly 198 in the SPIM driver. + +### Changed +- Updated MDK to 8.16.0. +- Extended input pin configuration in the GPIOTE driver. +- Unified the way of checking if a required event handler was provided. Now, all drivers do it with assertions. +- Changed the RNG bias correction configuration option to be enabled by default. +- Refactored the ADC driver and HAL. +- Corrected assertions in the TIMER driver to make it usable in debug version with PPI. +- Improved buffer handling in the I2S driver. The API of the driver has been slightly modified. +- Enhanced SPIS driver API: added the "p_context" parameter, allowed NULL pointers for zero-length buffers. + +### Fixed +- Fixed result value casting in the TEMP HAL. +- Fixed types of conversion result and buffer size in the ADC HAL and driver. +- Fixed time-out in the SAADC driver in abort function. + +## [0.8.0] - 2017-12-20 +### Added +- Added XIP support in the QSPI driver. +- Implemented Errata 132 in the CLOCK driver. +- Added function for checking if a TIMER instance is enabled. +- Added extended SPIM support. + +### Changed +- Updated MDK to 8.15.0. Introduced Segger Embedded Studio startup files. +- Updated drivers: COMP, PWM, QDEC, SAADC, SPIS, TIMER, TWI, TWIS. +- Changed the type used for transfer lengths to 'size_t' in drivers: SPI, SPIM, SPIS, TWI, TWIM, TWIS, UART, UARTE. Introduced checking of EasyDMA transfers limits. +- Updated HALs: COMP, NVMC, UART, UARTE, USBD. +- Updated template files and documentation of configuration options. + +### Fixed +- Fixed TWI and TWIM drivers so that they now support GPIOs from all ports. +- Fixed definitions related to compare channels in the TIMER HAL. + +### Removed +- Removed the possibility of passing NULL instead of configuration to get default settings during drivers initialization. +- Removed support for UART1 and PRS box #5. + +## [0.7.0] - 2017-10-20 +### Added +- This CHANGELOG.md file. +- README.md file with simple description and explanations. +- HAL for: ADC, CLOCK, COMP, ECB, EGU, GPIO, GPIOTE, I2S, LPCOMP, NVMC, PDM, POWER, PPI, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TEMP, TIMER, TWI, TWIM, TWIS, UART, UARTE, USBD, WDT. +- Drivers for: ADC, CLOCK, COMP, GPIOTE, I2S, LPCOMP, PDM, POWER, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TIMER, TWI, TWIM, TWIS, UART, UARTE, WDT. +- Allocators for: PPI, SWI/EGU. +- MDK in version 8.14.0. +- Offline documentation for every added driver and simple integration description. +- Template integration files. diff --git a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.c b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/LICENSE similarity index 93% rename from src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.c rename to src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/LICENSE index 5f118ee..96d8319 100644 --- a/src/nordic_sdk/nRF5_SDK_14.2.0_17b948a/components/libraries/twi/app_twi.c +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/LICENSE @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2017, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, 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 @@ -35,8 +35,5 @@ * 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 "../twi_mngr/nrf_twi_mngr.c" - diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/README.md b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/README.md new file mode 100644 index 0000000..597398c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/README.md @@ -0,0 +1,44 @@ +# nrfx + +## Overview + +nrfx is a standalone set of drivers for peripherals present in Nordic +Semiconductor's SoCs. It originated as an extract from the nRF5 SDK. +The intention was to provide drivers that can be used in various environments +without the necessity to integrate other parts of the SDK into them. +For the user's convenience, the drivers come with the MDK package. This package +contains definitions of register structures and bitfields for all supported +SoCs, as well as startup and initialization files for them. + +## Supported SoCs + +* nRF51 Series +* nRF52810 +* nRF52811 +* nRF52832 +* nRF52833 +* nRF52840 +* nRF9160 + +## Directories + +``` + . + ├── doc # Project documentation files + ├── drivers # nrfx driver files + │ └── include # nrfx driver headers + │ └── src # nrfx driver sources + ├── hal # Hardware Access Layer files + ├── helpers # nrfx driver helper files + ├── mdk # nRF MDK files + ├── soc # SoC specific files + └── templates # Templates of nrfx integration files +``` + +## Generating documentation + +nrfx documentation is available in the `doc\html` folder of the release package. + +You can also generate documentation yourself from the source code. To do it, install doxygen +and run one of the scripts: `generate_html_doc.bat` or `generate_html_doc.sh`. Generated +documentation will be stored in the `doc\html` directory. Use `index.html` to open it. diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/extra_stylesheet.css b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/extra_stylesheet.css new file mode 100644 index 0000000..3b53f26 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/extra_stylesheet.css @@ -0,0 +1,506 @@ +.appliesto {background-color:#3D578C;color:#fff} + +div.header +{ + background-image:none; + background-color: #FFF; + border-bottom: 0px; +} + +body, table, div, p, dl { + font-size: 16px; + font-family: Open Sans, Calibri, Arial, Sans-Serif; + color: #474747; + line-height: 20px; + +} + +a.code { + color: #1c99c7; +} + +a.el { + font-weight: normal; +} + +.contents a:visited, a:visited.code { + color: #16779a; +} + +.title { + font-size: 1.34em +} + +h1 { + font-size: 1.25em +} + +h2 { + font-size: 1.15em +} + +h3 { + font-size: 1.05em +} + +h4 { + font-size: 1em +} + +table.memberdecls, table.directory, table.memname { + margin:0px; + border:0px; + -moz-box-shadow: 0 0px 0px #d1d1d1; + -webkit-box-shadow: 0 0px 0px #d1d1d1; + box-shadow: 0 0px 0px #d1d1d1; +} + +table.memberdecls tr { + padding-left:0px; +} + +table.memberdecls tr:hover td, table.memname tr:hover td { + background: inherit; +} + +table.directory tr.even, table.directory tr.odd { + background: inherit; +} + +table.memberdecls td, table.directory td, table.directory td.desc { + border:0px; + padding: 2px 0px 0px; +} + +table.memberdecls td.memSeparator { + background-color:#inherit; + padding:2px; + border-bottom: 1px dotted #DEE4F0; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: inherit; +} + +div.levels { + display:none; +} + +table.retval { +border:#ccc 1px solid; +} + + +table.memname td, table.params td, table.retval td { +padding:5px; +border:0px; +} + +div.fragment div.line { +font-size: 14px; +line-height:18px; +} + +table.fieldtable, table.params, table.retval { + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +table.fieldtable th { + border:none; + border-bottom:1px solid #A8B8D9; +} + +table.blank, table.blank tr th, table.blank tr td { + border:none; + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +table.blank tr:hover td { + background: #ffffff; +} + + +#projectlogo +{ + text-align: left; + vertical-align: middle; + border-collapse: separate; +} + +#projectname +{ + font-size: 40px; + font-family: Open Sans, Calibri, Arial, Sans-Serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font-size: 30px; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + border-bottom: 1px solid #e0e0e0; +} + +.label a, .item a +{ + border-bottom: none; + +} + +#nav-tree { + background-image: none; + background-color: #FAFAFA; +} + +div.contents { + margin-left: 30px; + margin-right: 30px; + +} + +div.header { + margin-left: 20px; +} + +table td.doclinks a { + font-size: 12px; + font-style: italic; + color: #e97c25; + border: 1px solid #e97c25; + padding: 2px 5px; + text-decoration: none; +} + +table td.docselected a { + background: #e97c25; + color: #fff; +} + +table td.doclinkintro { + font-size: 12px; + font-style: italic; +} + + +/* nordic.css */ +.p { + margin-top: .3em; +} + +/* fix for table spacing */ +td p.p { + margin: 0em; + padding: 0px; +} +dt.line_sep { + border-top: solid #c9c9c9 1px; + padding-top: 5px; + +} + +a +{ + color: #1c99c7; + text-decoration: none; + border-bottom: 1px #e5e5e5 solid; + +} + +a:visited +{ + color: #16779a; +} +a:hover +{ + color: #none; + text-decoration: underline; + border: none; +} + +a:active +{ + +} + +ul.ul { + margin-top: 4px; + margin-bottom: 10px; +} + + +a[href*='.pdf'] { +background:transparent url(./pdf.png) center left no-repeat; +padding-left:22px; +line-height:18px; +} + + +a[href*='.zip'] { +background:transparent url(./zip_s.png) center left no-repeat; +padding-left:22px; +line-height:18px; +} + +a[href*='.exe'] { +background:transparent url(./execute_s.png) center left no-repeat; +padding-left:22px; +line-height:18px; +} + +a[href*='.msi'] { +background:transparent url(./msi_s.png) center left no-repeat; +padding-left:22px; +line-height:18px; +} + +table a:link { + color: #1c99c7; + text-decoration: none; + border-bottom: 1px #e5e5e5 solid; +} +table a:visited { + color: #16779a; +} +table a:active, +table a:hover { + color: #none; + text-decoration: underline; + border: none; +} +table { + font-family:Calibri, Arial, Sans-Serif; + color:#474747; + font-size:16px; + margin-left: auto; + margin-right: auto; + border:#ccc 1px solid; + + + -moz-box-shadow: 0 1px 2px #d1d1d1; + -webkit-box-shadow: 0 1px 2px #d1d1d1; + box-shadow: 0 1px 2px #d1d1d1; +} +table th { + color: #000; + font-size: 18px; + font-weight: bold; + text-align: left; + padding:10px 15px 10px 10px; + border-top:1px solid #7eceed; + border-bottom:1px solid #7eceed; + border-right:1px solid #7eceed; + border-left:1px solid #7eceed; + + background: #7eceed; + background: -webkit-gradient(linear, left top, left bottom, from(#7eceed), to(#7eceed)); + background: -moz-linear-gradient(top, #7eceed, #7eceed); +} + +table th.center { + text-align: center; +} +table tr { + text-align: left; + +} +table td { + padding:5px 5px 5px 10px; + border-top: 1px solid #ffffff; + border-bottom:1px solid #e0e0e0; + border-left: 1px solid #e0e0e0; + border-right: 1px solid #e0e0e0; + +} +table tr:hover td { + background: #ebebeb; + background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0)); + background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0); +} + + + + +img { + border: 0; + margin-left: auto; + margin-right: auto; + max-width:100%; +} + + +/* make svg files scale in IE. compatible with Dita OT v2.0 +img:not(.png) { + width: 100%; + margin-left: auto; + margin-right: auto; +} +*/ + + +/* make svg files scale in IE */ +embed.image:not(.png):not(.gif):not(.jpg) { + width: 100%; + margin-left: auto; + margin-right: auto; + margin-bottom: 15px; +} + +svg { + position: absolute; + top: 0; + left: 0; + +} + +caption { + caption-side: bottom; + text-align: center; + font-size: 100%; + font-weight: bold; + margin-top: 15px; + margin-bottom: 35px; + + } + +figdesc { + caption-side: bottom; + text-align: center; + font-size: 100%; + font-weight: bold; + margin-top: 15px; + margin-bottom: 20px; + + } + +/* to get figure captions to appear below the image and center */ + +div.fig { + display: table; + width: 100%; + margin-top: 10px; + margin-bottom: 55px; +} + +div.fig span.figcap { + display:table-footer-group; + text-align:center; + font-size: 100%; + font-weight: bold; + margin-top: 10px; + margin-bottom: 20px; + font-style: normal; +} +div.fig div.imagecenter { + display:table-row-group; +} + + +/* fix to hide borders in image maps (Chrome only) */ +img.map, map area{ + outline: none; +} + + +/* fix placement of ® */ +sup { + line-height: 1em; +} + +.sdkversion span { + font-size: 12px; + font-style: italic; + color: #e97c25; + border: 1px solid #e97c25; + padding: 2px 5px; +} + +.sdkversion { + text-align: right; +} + +.whichSDs span,.whichnRF span { + font-size: 12px; + font-style: italic; + color: #e97c25; + border: 1px solid #e97c25; + padding: 2px 5px; + } + +.whichSDs.nRF52 span,.whichnRF.nRF52 span { + color: #e97c25; + border-color: #e97c25; +} + +.whichSDs.nRF52840 span,.whichnRF.nRF52840 span { + color: #0081B7; + border-color: #0081B7; +} + +.whichSDs.nRF51 span,.whichnRF.nRF51 span { + color: #7f7f7f; + border-color: #7f7f7f; +} + +div.whichnRF { + padding-bottom: 5px; +} + +span.whichnRF{ + font-size: 12px; + font-style: italic; + color: #e97c25; + border: 1px solid #e97c25; + padding: 2px 5px; +} + +span.whichnRF.nRF52 { + color: #e97c25; + border-color: #e97c25; +} + +span.whichnRF.nRF52840 { + color: #0081B7; + border-color: #0081B7; +} + +span.whichnRF.nRF51 { + color: #7f7f7f; + border-color: #7f7f7f; +} + +.orange { + color: #e97c25; +} + +hr { + margin-top:20px; + border-top:1px solid #8EA7B0; +} + + +.directory td.entry { + white-space: normal; + width:50%; +} + +/* overrides */ +.topicfooter { + text-align: right; +// margin-top: 1px; + padding-right: 10px; + box-shadow: inset 0px 1px 0px 0px #e0e0e0; + font-size: 13px; +} + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/favicon.ico b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..0bd6cc084510296cd3415452a8ac627b8279a523 GIT binary patch literal 26694 zcmeHQ30zcF+dtZ(ZLihat5Lmbnpv7_F6o=My`)*l=FH+uHTVuypJ)bNpk&;Z1&xZsXk)tIW$KQrsGR^#0O<9pB6a7 zw`I$gZ0%b5u4N4kEm?W=Iu^Bd7z+yvWAWSWWvYWMnV)N4c6i(vrVBgDOxY1E)uSgX z4u6|n{;~^8KkynWj-15;=X7E7({A zU3d_%yvR%?=xc8$`ZwyoUd9d=t zy^vuyRvxvAsk{%P&Gt+m9SDq{u)+vu$h|E~-QSXht(wG)+He)!k8MMi>WMj z^DyY$e8^)vtB&1(>%TGWp}Ww=VWv7X8fEmXDseFjo4q}x(ccP|=H-Rs zB&H9Xgz-kPn#5JCp*jgV?aI8JozTt$DBF!Sm~wz;D(a7BWznl}Z$_eA2I}?2eG7yx zIipM=+FH!YlLA?B@KhGR%Ly2~(Qi+T)e(74%zv&k`iaGO2BVKLXlEevn)C)UC2d9> zS6~gp^)R%J=fm5P<#-Lov%Hz59$JRy7;*{Tj%RNS#_tF@IpTU5j?Y@AgZ~F7Z5R35 z9Yx!=Z5K7opj3aC8%;8hP9K|ekw)eBKWddD(xrbC>8qs_QGVJbMTVky+qOsL3^`RQ zzj$%FIYUmj97PSwmB7D$+NH(mgZH3DW4hwZD%sNh;5~axib9IhJ&JR4`@l2!lrp*T zJaw?$@^3YkP@X+aK$Qt*`7BbVSTi~mdY#Y2s~GfcJy%Gn3|?yAy=_}N<*Tagmw%OX zq)GW9$2;0DFFnjQ<>SlTkDJ@Kl1*#*(YG%DbQ#LqX+O@QuFCSePBl~BQrZfC2gXEs z+woe>w~g)7Jj@7>b$Lo4<9Dj^8u%Y;4 z%)mO-G4Qxj)~b}<#aIYyfj`{Je@`*oHfnjC8rBMbLJkI!LmgW!d-TSrxIT!j!IlraMVMt zg0BjW>eEGVRN}0}Q;CxjPbI#pA0cJ=Enf}0XoB_2r}H9xSwg`aAVb!H8QZ1BtB;F^)l2u@1; zHPzz-!9j_)5~tN3{fFSK#081F64y)tcO^bbe3iH=aZ%#p#0C9aCkVbuJi0RJpx~p# zS&4JVe3bZWeeQ7!XI1_Frr@l)(=Q0#stZSFg1qW{^&lbEj;>-DhYZ7J!3>tOJwMZyn4{MDq|FF35uXNd4QkdHy;vifsFEIgJt zYz25R@z%6spEUB>b7L$Vo%k$qbmFtbYok_mZo+4Cf&*DW@DvNLEsk~)yjJA}4hn8d zyt_PhtA*ndzm>VIpKBj*OZXHN+}3}t6HEAB;>%;JCzTiNg}7)kg;l&Pp7X_^ixhWe%&4J__FYy5O(mpO86hLxWauSmLb2 zUH_`j$2JYQSzVuUd&}drB4vStgTw2VYg~DHd9?XWPU!D20r?Xg`b!CJxI+Gt!1zd! zK-c0kfjW_{DF2JOd3(QR&T=jl89v*5De{x3(7dd}?t0faPid;9(PO(XOd6xR)7rw8^b?|)up(%k*b1nH|M3%Na9sEYMnev4) z-;(Fx;O5rr(7#4yiTs&viVSh;=2kE^td;9iQvMj*e9y!lt;52mHk0q>F#cNWX7k>Yvp)$WmqNjt4lwa=P@P5RTR{8DPx&f4& z-?eDVGCxKBiOG~J=ij%U=_3^R+7Nb1(jcmz6rTqL{Ci{jXM}!=dyV|SqzrM*I!yw; z)~&}&SB$+b+7GUjuNixC><330uNXQxY4Ku+^iIm$zw%tNBk=EPzPheMU5C;(rL8n~ zY3_3W3oS0R)glCKqU|=bg@lTY1Zr`Q>wtv~(G*eR*7QOH&yzxwUi zDdbNlzxrQor!;4yko_XrDUr8rr^q&nNq3;pPAQT6=>OMtitJbaBQ{E1?lJa%Vy6`S z*G~EOu~U@R$I`~x!@0*pmJ4TxQ|9wi4oiDn{d}Fc8clP(!z!Gw!f|Pj_MgW;LFdvW zKfzO)?w7uW^!^`O7IDu`k-{!Odf+tuaM1<~22J5|$zE96W5xm58d&Nu^7EwSW;>y+ zY+x*18sZW>G->&OuI9?p!L#jx!Dknv{LH0_^raKL!deX;Ws| z8QQ8PT8=NRV+bJ&&V48A7{x9rUS^34d$dH%uP^g@pW?#c+gag)Uq`Q{nD9u!yNe^< zGV^T@R;|+^e-OAKVpXZ@r1i}E8Ssa91l$%0Z|8A{?=53`KPU9_D61<@V8t-HiF4;gfqx(Bix^m6aHj!+Qxo4N{%z8Ev!q>j zBgVL%g)Zv}{I3Y^NIaYPcQLpQap$C6{}9}oV!L(4Y2Z?`QTHGVT;wWvHLZEtBM*Uh zKO=ZG#c_#S7heqoPX}l9>@LNEVBiz z)vfIXr>8hB@oeJ4#KmcSAs!yRp__a7S=wlXj2b$`lK(PCJhH@0(2Jfp{i3GjZkQJjEBJ5e6^Rcg?Ri1) zV?WoIz@7J?{!|gmCEi<2@ndja;?!A)-B!or-UNHF_&uLN7ETzSBgR0nTinMvPQWo0 z*rXV)*QC)%bB5lxWLGwH!9DGQ@n|ugXITyGL6d4b@Vx`worwFCfIgyt%a7&y^%Hw1 zQuo}&8gv_2*k?VMk27N8h@0E_xKx=FJ;br1-NW^?IDIf-LOT~WVnVxiV>{iq?WcD5 z44mLI1&4=U{*A7tEOFZ6Mb|^pm*C$e?rrKPccp9bo$wZ)TK}H7rj)Gtwa4D*Gb;qy z?WRn*?$Elm<$8+yNSf7a_aHwP*+UM9%UX56`u9TGxgQ=opROH-x9e9wD`dm-3m4$J zWH{RFS0AvAu|p-@<`eKK6Xx{M(#h2@`j;_}+0xPKUrd!Ow}!FMP^;vdUWB7;ZZ7#e zZTH`FY_=ZF$^ZTSR|bDn2O6r<8L!D^yjsP0RT_?JJmc5IbwhO~(lYQ(5#NT=sJBWl zP5xQuKVfBAQs9Fn@n_+C4QEC1QJAOwSx%@w%RV2-@}e)YG*3^K9U8?dG-$Uv5nr@r z$dTHkzTi)8sL?WBiM98+>+6QJwcL=lhMO{fxKv+y@oh0?8pEC9C)_nTtgi6vETd|x){wS}o79_lS@aa1 zvX}Ae-?rhgTe=yN54r7t{2$7@cpmZ(xPAGPY>oM>zBpnqutphDR}0+6^e?%AzG?2_ zx;E#)abB6+Ufd&$^_KD%@=jv)B^O4(Umamcqjn(^v}sar=4F?s3jB%RKh9$|b>X4Q zyYLI^-bhP1^3CMj$Y9tk=Wnh*LKmPrl{cQP)gAg7ZPyB{X51G1;(8r7q^{yd)s})f z{TVmt^8KjSjQ)_0X)(U|-nH4k9He`wY}X$C*v(ye#23Bzxy3zsz{kCL8E}l zQWzi4(y_nGTK{oBVK?#08;{oId95|1udgC(hIC-Gi`{%5D39bvkKBtftRj=-f@c)ZZ+%f1>3Fgsb)^+(om7m zh4Xr}t7=(a7&OPI{x(C5Q6Udyy8=J-r~Jw^3;r0h{008`1G)d4mobK6-0S^e{Iu&N zP3#YQ=ai;p+|SFyhnX^Wh6#C_btv*J{=`(M5ah zEBm)Sm&?~`HURrZo)_%K&o7@^TAOpISkgm9#V|lX2Jm@UdA^nwfT-lb4&$bUaosP=#M%8*=pS_uv#(d6Wzn#oaP9DvV zPkgJ`lyk6I{K~fIT;PwH&Qmde()`n?|9ye|MachUp7@h9ue`p7*XL~H#tg_E^=!W~ zW+gt`GV(Q*snc%aHOcEBlc_v#o+J03<_I~x$xlokS7gfht*ANq%WcRbm!+5_TsVMjN?U7pF&2PFivaS_Hf!ull!3~<(o8Lp{hiJMox13@=>%Y@H-3q3ESK9%j=)!FL9?LJd_uwIJ-Fe8eK3HS= zN%*0oGX9g3-zhR>{aj>kzPHzxQMHj*T>XUS`8)FJ8!OS*=4N%AaM^1^iC1}U(rke& z)^XjLiTv8P-T0+-oq5#i7kJoby>0MIa~$c<$ti??pOF9U$WQ8TJ#=ylaBpZ_?3;%^9yTw@URuO_!aV>Isy29veF-=Oqx5F$J!ju z=F*kz88h%~YPRz7xcNNuSU1dPZFs_W?fCWYI`Fu!pONrGf12RO8Y$_|XgtFci(sQc ze_-o1^Zd%`GA8*br_<41n!S7~Cv+URYm!&-T))9s%kSbzyBJUU;W3QiNr4}JvD?Ex z-3j>j*u`(Je>qLyxCw4~Jj!x(F7z(#OI{QTf6Xi77eH5f@{C^@PyYp99Mf=A;=ggH`ZM(ne%j^3 zTvO)vx5O`FwZ++NI_7bc8akfh&h=*pbM?V{1a{SL;GG@{{J0M{mA}pW6QEeXPEG-S z*U8zY%pC&1j72`$VpU$tW#pqWPw061dR`Ls4%Z%igsUKH)d9xU_|nmW-&TKiNzZRQ z=AWj|Z(p%~1Bo&hDo#CB7Yf=d{p9U?p!WQYa7YD?D908eWJailqdzypZ>2wzU*~7$I;%|TZ!Gv_e70Eak4svI4JoU6!MUMa^LuN7 z-GW)hZk9jYizfPi%lQZPgJS))#y^Vt&;Q5@zY^!o#$v>JZ_L=pOD{M<#~&8DVi&hO z2D9!r!LO9RUH!MlA4vLdw%<;CIEn`>nw4o(eQlAy62HB3qY7(2=JJZTk9m&wGtx6j z7!N6QMaFD%RLcM6`qRGg`CVg+zj6LQ3H=F}?{WjaDd2DPVc5fMp!pE?VO7F1o*(!M zbmdWCz6VD$_FLh%k-r7MLVpr>J|gU&gdLp~_^s_9rT(0v^>?~c9DGAXwmukHci^Le z?`RY3+BLj5`~#ll*&Udlan0fT|1f^b`UU+-hW(JVlh)%-yeM)eS05e4V>flU zrTue~*54T)#2Pa;S>c!EPr70R{<6y-bDhsno_Vwz*8Z+IK5fQ--yPv^GJj(JC;KPu zm%nj+FkDipYr#FgB%dv&KK(j z@c{XrlYdxsWP}30wf;BqU#wqve*HdnzGO&WTO#}%uxl$~mtiiS0l7@zI$z-T9`={u z7xO0UwJgu4V1rH(wy1cnY-~S)|L|}-`fta6n2h;qbq%V-U_Q=DqhbF?0W##}%eN~Ks@Mru!%z{74!oMW^jq)GPPfQxggO<*{ zV9Je{To&~iFAkl{3(va(|1_Q-@aOT9-KIYDKviMr*sF#V=s4yvai0}}Qfc-h0Np`7#e(x!_E- zF1KxcSthH^jbpVr7w)f0J?swo*XH_-1O7M7`tR6?|9JEB59v5z*ZB?(D!=;ma6@Jo zGiZWXZC)7SEIH(#f3Pm!=QH3ewfM`RPlTJkwC0!ue#ljpzheCjTGW^Ox%A+npTB!O z@z)&_b1y`(+VToU_)R&{7{e9B(@I&5`pn>>h^1jVJi9rkF#kaQH2-LunLkyq6G+Fi zPd%4ba%qKgjXI!3b=pb9{m+Q6z)!I&ir>{_;hmDG7izP9{!NOHSo1y;=0CiP--w^| z|5LM}M}YMsv1}A@e+|PCv=2QjXfek1O$BQi6Ow1@5R6wg05-m@a{=l;g*OVIIPX25TH)TjgR z48MpICgXnGz`eNg&)VE0JAuDGZGTUG{f8mfvd(_@Vd0fCOc!z(an0k9`?)*EpBW5! z`e5%>G^@!B9DsLTelEVaY$Vt;x z#O?RR(Y2$DaH@^8ED;4ei(Z_+`;`s>>K?z`WF$4MS5jj z{z(wJ>uqRHix@xcxvEw_T&F+18umg7*$Z+#(f>L0zvBTOy`eilzqA)Wa! z4<8tlh2K*$7C`n!&E55d=Uk2It!ia`rN2-*hd)T{SNbNSz9@JyZzzLJ7djsINF~L( z*9yEAyBFgxIOk~TKV(^75$int(Gc$W9`PhM&x*95>2*1~E>o=22!E^WqmlczcQj?d zC!t-#%MuSB#Qu+533H<_R<1+iCm*Ife(FD9&Oi~T51coFryZUPUq1RxUnBaJ>&ZuX z92Q$1c36GZCSIMqmM8r@6YY$tMx3F9Y-XxsDQ7+x{Rf--U*C-fE$G36mpJm212fU@ zm+-65UW7)TAor_0${6Ypi^l$Ip6NY{hb$ifo`Qj>q`BS;itf`JPO_O|@4^Od zoq6P{o{)PVOaG^-f5eH6h!Zs5Kl&rT7x^3Q^evB9&ZGH?xFX&+fW7}u#7zG#`j6T4 zyy!o4d0)|g0LD-KdrzNO1pX}i%+!W$dvd$BN857LC&h;yy5GQ=U(5T*K>EE^=+iSUB`6zsIct$BklIPc3!~kgzj1)V2 z0R2B<)4yW;=>N3Kq+G-i;ir@CzucdteH)o5(`mdE-zf-&-}=zKqHppciukFBo!aYP zF@ERa+;`TLZ1OY9^R3+f&5qJN#(q!i*UR>D5FFj&g9Tr2?EgW;&Fzn$^xp^lpP4f) z1AA9)uYYlmxAMwsbK%46Dq=R|+Ys>)^26i&PR8#uV>tJp=d6OiPxz^u9kYmoZROQT z%dr*@Kz}Xm#*=LOzp=Y{`HS(-7{&t^&eX_$a=Cx&drUrlcf|Ey2fsxeOCGOH48dj4hom!E&qf1l~1{}imbmhoHqhQERQa`^2?_&A=!nD3EdInBjGY~)XS z50ZA?jTk~_p0M*d_}r!EPwt<_e_A|$?;%dm=x3+7hUV+)1o+s4-iA-2E9TxO5z~0^ z<}m@ef9M}Qd#U^G<+*2uVK31tp8CrmtR2rZeg2(CU{B_UG2|yF*^`gRkmAmZBWDQz zl=gTZu07rj7}{I+Z!3GcCV%WN6hChP-Rz5fdP^|(e=XWf+27yNzjFLS|397%KmEEg z>c1k^4RM7@@a?^Z{^6TMY{72-Hur#Zg8X|q-d(YWYL1u(X+D(Z?Jv31f0rinuMhMu zVBXA2hScwpOQROSzw0ddM^C?w{^46}u77#_G-mXh?fE$70{G6MFElsEdMx{NllS%K zcz4IDf4cvtrZ{r^&Pli__wsu-b&Q1~jW!)64G%r7I0 z;$vA($T?P(og?+Hk7u>;4b~MVLl#%zSKIngj`u6Mn!_ET`|V&yycAh}ZQCf5E`}M% zca`P|U*-`-|5@M@;4bvVI|mKL;e%?kcAq8x{*51>=hwEsoR)sveOmrSzm|npFTh`R zfn}WwXwrYJ{<`@6SL(x%72;4FwdlK&OJ7Vgz~3kQd60Jv#@uZGw1*yCj(m5-=S;d& zv$A~Wt}0EAda!`r3xmH=e}(*wjs5>eb6<;}hVzD@4MPoW3~j`3Pqc9V%RMjdXj9Wl z)5_4n(57y6!%)awe8^AH`1=zbab^F5!vDK|3gV&U2LOj}AYTA{@%4p)V+ukhZZC-1 z)3rDu8u}9i|N42sdyVD1wflG!DhCREzzAUz{^j=E3z30KzUle%7 zdrD}Z$`SW3y*$vQ-F=SY2eg*v`t|3r8{1&N%8NB|Kdkr?_#e^+hcRP5o>fyG`5K-z zWqTYE@dn{5fE|vy*n3c4t2^=?d<^@jbD?4{jG~_0>tJiyOflX0ki7T1yS+X<4-UiH-wV7LUc}4VOqjqjM7yRi!bV_IKOg<01B1gX`+U-8kMSt_064v)vC! z`18bs7qo}FGGP^u|KVNO5RQ1Sj}+&m_OpGb@rYIZu_p&(o;4Iajd=2Rf~Ux3#Sv>v z#kB>(Ml@lcx>cS+*3up{>?OY7!f)*9!=qMp!QSUySPKV8?N1vA9%g617}ig$X~LGU z*S5@m2ty`prG)K|V2?`&e(B5Z(1$+!ths&f>EPLBo@K9{rfFmc(q7!p5pNxYeGx6i z-uA?u?fA8CI$5{xiuV>~yjyU)`<3Wj1sYRv#M|Ia_w%&<;4Jti@3|W`t9AQAK4|~+ zOs8CVKMvV9P4PlbW)4~&^AUK_lY$p1If1?Qg?!My@2vN;j2WAS9d6sUwEu%R=3?v} z=q_v@nFoly7qEqhb5Z+thf0s3{Av?=#<5Bx5 z)c%gg_|o{E_RoAWIaB5lgrD}w7{HrKE>6eZicZo#P1$Z#9Od?D-|r3VwN@SM z%@cp@#V@XVUd$)5e0-cIBpcE<6w!VyYP;gv63jcJz=^PL=*SbWQOx{A(Khiyk`vuq z)xk$$*M9&Tbt6ytc@TV=T^sdN+~4+&2Nm+wEGP7YzkAVIA67266VE==E{NA*E zicPBz-itj(!^IvW@>P*cllKj^RH7ThkW#`4B^Dfu}@;*4iDDbMmQv1Yj6zvmc z)qxiEc>x2;=$_MaK(Zts4DItEds>O#d)feg&TV#Ftv=zAifcQ5q&+5Lf6Pg9`$wM= z?USq}p3pnE;`*+B4JB9G)#V-EjXA49%=cz{^~PSbzqTvphn|>!@DA1T_b%o{gbt`J zOk#DV8j9l&%Rf6gL3_L}@OOv&9~bvG>*TWuC0EwGQ=NJec3~jaE5w7b9@Upb4ZwPI zUi6XbF6N)emF;Ozk{R3v_D z;yf!!Lfhu{X&klqeFlT-%mW3XGu9VH&T}Q((wH5^sxy3=wofqu>IdtrN#`{!%lDJd z3u6NA%ZoznIu`47c(7>yf89QT{X@T}-^Da&i+)3euv`CrN=N%f z7*hZAIK_Li;=Z-1%R9CqH()|gPN+xU{7V$q2xF!~#88aHXH@sq<$Hfhy3fbx@$d%n|Vs@<9tnxeih^bhO-v^BtNAIMH_m9%VJ7A`| z+{4@9IDQ=O(4LagVMoEInu+}nVaq$iAKjN<_-by7LA@`)2>-lf14(l|z5iuIJE{{a zuVWsqmTeBIum1g69=*OdS9#9HTnaxnFv)Yc#rGV(fL~ny2KV~lwF;|s1io|pKOe9q zKIe6?Rbl4ieIY#!mi2>8V)~b zTOPBq1Grx=#4TQe&uvVR?K&W1mG&Ngg*n>^&-CBL9?GO$55xBA0^fCS)E@|c<+yyo zaTPX~yzW)RxnkbIT#tE?_L0(F#v4C8YN;Ra$v}EF@Mpk&t**Sf40hk!*kg@-vxjNVFU{rBdO`TJPj<%pbhB|kHt>WW`eCn7 z5A*oPYpRoWdgtR^vh0)akznsq=8?ywbrSWmyq>;Z7V~iw`BUk>)L_0#*wq(nO?R~L3wWqUJR?x3q3t}(gw}$W=1%H}HF@~QAW_SAYgj5Gzv;P5^-XJ6Z literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/footer.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/footer.html new file mode 100644 index 0000000..974fce9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/footer.html @@ -0,0 +1,10 @@ + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/header.html b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/header.html new file mode 100644 index 0000000..1c3b27e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/header.html @@ -0,0 +1,58 @@ + + + + + + + +$projectname $projectnumber: $title +$title + + + +$treeview +$search +$mathjax + +$extrastylesheet + + + + + +
      + + +
      + + + + + + + + + + + + + + + + + + + + + +
      +
      $projectname +  $projectnumber +
      +
      $projectbrief
      +
      +
      $projectbrief
      +
      $searchbox
      +
      + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/layout.xml b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/layout.xml new file mode 100644 index 0000000..3bd29b7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/layout.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/nordic_small.png b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/buildfiles/nordic_small.png new file mode 100644 index 0000000000000000000000000000000000000000..9ebfb7b56fe34f80b39288e2ce7e035deb518702 GIT binary patch literal 4338 zcmVZPiBbI#DebNWnI)!n-4ySKjkec!#K2t)naZrIj6D82?90zHRz)-r-2?mr z)&AkU3EuPTPDfc|(VPH)MLV>f;9T8`R(Ek_)&J$Ct`cn;e*v#scNwT@z?XeeZUJ>G zW2=^A-I@g(yK<Kf06*ceciY15?_aF^XEbuYa0I5jn~EZbb74H6gdT5Zv5 z{naR@0LSL3{Etz(mNy5^pjO!lSDxR{6J?J@tCM|8@fUEH*HQLFY6h>&uDK=J8Y1Ac z*Yzi&W&-^RRL`quHIXZ;)-bEF6A}Az&_e>}4ldvT8h8$6-%?UrN+@P;=tIPQjb!Uc zzOjLsSnMOF%0uN0C*Xq8>*4S)YK9&Pm9IpbB8qAm30C_e)MWwVvH2&8xu6fDl~u6X zw5o#gYk>dFvV;?X-fn5Ya-@@HqPLR|WFGQTfO;%o5O6VYGNK;t2R;J+?359tlO7NB z&2aqyunpMhQ%-;2xHQ*xIr%>f&>olGz)8;c7|;+f-|@h3U;uJYIy&`#2&@EN0}f}X za|f_1ilr==2ecHV21^~C$I|Wv&dgI;T@V3#ip;_dPzl@xY(yS@E-0srCBPjyl+z8k4roLM zfsQ%03m^jA2fPA&4Syfa7lHplI+$DkH-Y~LdI8;mV-r;br4OTZ9q=SjtO?pVD19Bu zJ{BGGQvp6t%7AC_AA$VnggnIIX|AX1>?a{=($F012N9n8feZ3b&II69pmUC8%>aH# zdcjV2U!DdII^Q)iith&gg>#UI1)x6x^$6&CWT-DRWuQi5MQVu99;I~=>dc1Ikym0a z%mI3O&b@?;KAn+{Q~{iajPT}zEeGZy`l%m-5n)ltTi{$or*~1n?LK8}H_EUO-F!GA zRA#&S0rQbjI2&$7I*Q3oM1AWAv_tO87lBbgom2l`kWt@dzH@yuGUwQlVUlM9Y(}XE zfYn(xJS4g^w!Q|`FjRrmmfX1s_T2)1?~x1 z?*T-(M**hetvW;*8WFk%;6H(ji0i%}^S22h+XW)DwVrc-LMDp$Awt~joZk&B09;^{^t;=f}Oq_pXRO9_C?o1&ShMHQ#d_rd=Hn zRl{W;a$oXBcEMCyYm{CGY9pdk4$NnxS~33xoCBYAxQ7uH;_U!=Pw*VC4_Wu?p5qf! zri$|faeccCnb>;UFg;`&QsE6(_STV!<4ElEjpW&6oNctAgKol#F2vR=L5~I9H9yU2 zwH!buQY(-Vu>zQdnC|=*dvx*~hc&}`(|gPFa+c5aI;8En61H6?$9RtOzA`L#SGnDy zAhs9r7(PpS_i0<<6~u<@G6qw2146dT zWQV660}z{c-Y7t@leR&>hNY&U)jRnwzg5tJnC{%!zJ)kHzK|i$3KAdYNWz&K$9s#GZwvr=zldowjDS z0sn0re;K$uL;5|4kh^pwxL0%>V46w~kv>?;L?bqHQ@8yk$)j$zdLb`=Nu1;c;VBaB%e|5CTR$wP zJ)IDj`ss+9d@*AGHrurjs1MmL5H)YI=Uf$HetZ-O2{;j%fSwLqi`>WMh+iUOBx8j zZ*JMokrxoFMGy`mixa|bT(kwTw{HxY&*fv1h2=L$YQ$%rQ|2nT=~Bo1SZPudTGA0QLMuoE~hvq|h&oq(By z3v-PDYk{93Bj_E(qy2K_G30IbH1MfU+O5RzOWMw*s9RT?r^e-oRR;P}5@Qo`L#f5o zRC$AWg3^V=iO!q&2PPed=+7Xg#B|YaUb-W3*4+>b!am>=B*b++!8(6u5_cclOzNPx zN|NKz&9tYI>|q2E>|M^sPxwr_5nsAz6a1cZK;n1$Bk}JQh!g2=h)T4X0QaR82{>Ry zHMZ`YH@AOo0$!pG@Hwg|DLC@n{v`@b>k{zKaNPdZ5#jbPQ9xR$fIHZZ+aDf8>0+(+ zFVTj`LBOq@po-*~)Ssew9*alGK8h|ICLt5OKayx-vk+^9`RVP+dn<5-aeM_b>o=)J zCQaTg^9CWd;a3m`$_*q2Az6rHXd&YMpGI;V_5j4GWcnJeK?220>JSIbOk_V2@7$-S zbNwXa-0dVgXCg?v{1U{%bTA*#`TWCPm%SQD-bJ>G7lA9+}t7CvmAo3o>HWGfpX?SEyiOq=H{{mk8KQV0$4CpdN9N-vB(1JYcU4+N38kGR+|I4P`n~&O;nU<{Hhth?bQ4hUqJimm*v(H7W5wDVg z{7o_y3dI?~rC91Hu!`iFESTG0BO}YT$hy--Dbh?rguxrt)(`POK8mObV~_~IkI4K= zbp<)oW~eR5Nb42A_N4YGEyt<|L;@$c@UWx%|Zlj8_7|8_aH*Gn8YPz z{fMu$zZtPEX#54-MiwaaLLTH|WQ2Ny_-dim$SeBizy?GZHy|<9-i?J^4j_7ay3yvx zi1p$fC#@Ns_jg3spGMq8ehi7xk1LQJ25OOzh8K}dqJo6vg1lkoBWlMg#Co(C>CCC3 zEZ;)z{X_T&d4z9W-wTywj`2q+jZ6&u=mP3AwDm8v-d}`iD1gRh3+>w1QUAmTS(f1n zXlKOibu)UJc~`7rVpX+$FS zHXC&}AUjKyAu7vrh@NkD=m-*D@<*iOe2jFOEy#W-E*+fnn~((zlS%H#3y{fOJE!e8 zIOUiubAEHo`7A&tiU&OD6w;ZzVYv0qZ;c{xI8%|u+~(j|=CorC@inm(NC!`e;<>da zP-b0)(&4rmR?0>*DrBApup7|oOwiftYr)WJJ66>!YKmp6FVPy2@w9$ZJ5_lpsGKy(zn`bM(b5n zR=!+PM@nQOxY2IT>n9RnBw9O5vOW{=W>9mfh&{n&gY&mS8MKy(D!PTc!WSzBn1 zEalt%vsqbQ;s_(0Ra$FB-MT8UhM`m?*d4LebgmlsQ9)YwEdT%j07*qoM6N<$f{c+A$^ZZW literal 0 HcmV?d00001 diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/drv_supp_matrix.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/drv_supp_matrix.dox new file mode 100644 index 0000000..de320a6 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/drv_supp_matrix.dox @@ -0,0 +1,55 @@ +/** +@page nrfx_drv_supp_matrix Driver support matrix +The following matrix shows which drivers are supported by specific Nordic SoCs. +@{ + +Driver | nRF51 Series | nRF52810/nRF52811 | nRF52832 | nRF52833 | nRF52840 | nRF9160 | +-----------------|--------------|-------------------| -------------| -------------| -------------| -------------| +@ref nrf_aar |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_adc |@tagGreenTick |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross | +@ref nrf_acl |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_bprot |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagRedCross |@tagRedCross |@tagRedCross | +@ref nrf_ccm |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_clock |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_comp |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_dppi |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick | +@ref nrf_ecb |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_ficr |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_gpio |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_gpiote |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_i2s |@tagRedCross |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_kmu |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick | +@ref nrf_lpcomp |@tagGreenTick |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_mpu |@tagGreenTick |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross | +@ref nrf_mwu |@tagRedCross |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_nfct |@tagRedCross |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_nvmc |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_pdm |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_power |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_ppi |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_pwm |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_qdec |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_qspi |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick |@tagRedCross | +@ref nrf_radio |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_rng |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_rtc |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_saadc |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_spi |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_spim |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_spis |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_spu |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick | +@ref nrf_systick |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_swi_egu |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_temp |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_timer |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_twi |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_twim |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_twis |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_uart |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_uarte |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | +@ref nrf_usbd |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagRedCross | +@ref nrf_vmc |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick | +@ref nrf_wdt |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick | + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.bat b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.bat new file mode 100644 index 0000000..f63b3e7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.bat @@ -0,0 +1,2 @@ +del html\*.* /Q +doxygen nrfx.doxyfile diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.sh b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.sh new file mode 100644 index 0000000..9cc608c --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/generate_html_doc.sh @@ -0,0 +1,2 @@ +rm -rf html +doxygen nrfx.doxyfile diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/main_page.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/main_page.dox new file mode 100644 index 0000000..6ff79d7 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/main_page.dox @@ -0,0 +1,89 @@ +/** +@mainpage Introduction + +@em nrfx is a standalone set of drivers for peripherals present in Nordic +Semiconductor's SoCs. It originated as an extract from the nRF5 SDK. +The intention was to provide drivers that can be used in various environments +without the necessity to integrate other parts of the SDK into them. +For the user's convenience, the drivers come with the MDK package. This package +contains definitions of register structures and bitfields for all supported +SoCs, as well as startup and initialization files for them. + +Refer to the @ref nrfx_drv_supp_matrix to check which drivers are suitable +for a given SoC. + +@section nrfx_integration Integration + +The purpose of @em nrfx is to make it possible to use the same set of peripheral +drivers in various environments, from RTOSes to bare metal applications. +Hence, for a given host environment, a light integration layer must be provided +that implements certain specific routines, like interrupt management, critical +sections, assertions, or logging. This is done by filling a predefined set of +macros with proper implementations (or keeping some empty if desired) in files +named: +- @ref nrfx_glue +- @ref nrfx_log + +Templates of these files are provided +in the templates subfolder. Their customized +versions can be placed in any location within the host environment that the +used compiler can access via include paths. + +In addition, the following locations should be specified as include paths +([nrfx] stands for the @em nrfx root folder location): +@code +[nrfx]/ +[nrfx]/drivers/include +[nrfx]/mdk +@endcode + +@section nrfx_irq_handlers IRQ handlers + +The IRQ handlers in all drivers are implemented as ordinary API functions +named "nrfx_*_irq_handler". They can be bound to some structures or called in +a specific way according to the requirements of the host environment. +To install the handlers in the standard MDK way, you must only add the following +line to the @ref nrfx_glue file: + +@code +#include +@endcode + +This will cause the preprocessor to properly rename all the IRQ handler +functions so that the linker could install them in the vector table. + +@section nrfx_configuration Configuration + +The drivers use both dynamic (run time) and static (compile time) configuration. + +Dynamic configuration is done by specifying desired options in configuration +structures passed to the drivers during their initialization. +Refer to the API reference for a given driver to see the members of its +configuration structure. + +Static configuration allows enabling and disabling (excluding their code from +compilation) particular drivers or in some cases their specific features, +defining default parameters for dynamic configuration, parametrization of +logging in particular drivers. It is done by specifying desired values of macros +in a file named: + +- nrfx_config.h + +This file, similarly to the integration files mentioned above, can be placed +in any suitable location within the host environment. +The templates subfolder contains templates of +configuration files for all currently supported Nordic SoCs placed in respective +subfolders. +Refer to the "driver configuration" section in the API reference for a given +driver for more information regarding configuration options available for it. + +@section nrfx_additional_reqs Additional requirements + +Nordic SoCs are based on ARM® Cortex™-M series processors. Before you can +start developing with @em nrfx, you must add the CMSIS header files to include +paths during the compilation process. Download these files from the following +website: + +- ARM® CMSIS repository +(CMSIS/Include directory) +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf51_series.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf51_series.dox new file mode 100644 index 0000000..3f8201f --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf51_series.dox @@ -0,0 +1,56 @@ +/** +@page nrf51_series_drivers nRF51 Series Drivers +@{ + +@ref nrf_aar + +@ref nrf_adc + +@ref nrf_ccm + +@ref nrf_clock + +@ref nrf_ecb + +@ref nrf_ficr + +@ref nrf_gpio + +@ref nrf_gpiote + +@ref nrf_lpcomp + +@ref nrf_mpu + +@ref nrf_nvmc + +@ref nrf_power + +@ref nrf_ppi + +@ref nrf_qdec + +@ref nrf_radio + +@ref nrf_rng + +@ref nrf_rtc + +@ref nrf_spi + +@ref nrf_spis + +@ref nrf_swi_egu + +@ref nrf_temp + +@ref nrf_timer + +@ref nrf_twi + +@ref nrf_uart + +@ref nrf_wdt + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52810.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52810.dox new file mode 100644 index 0000000..6aba434 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52810.dox @@ -0,0 +1,70 @@ +/** +@page nrf52810_drivers nRF52810/nRF52811 Drivers +@{ + +@ref nrf_aar + +@ref nrf_bprot + +@ref nrf_ccm + +@ref nrf_clock + +@ref nrf_comp + +@ref nrf_ecb + +@ref nrf_ficr + +@ref nrf_gpio + +@ref nrf_gpiote + +@ref nrf_nvmc + +@ref nrf_pdm + +@ref nrf_power + +@ref nrf_ppi + +@ref nrf_pwm + +@ref nrf_qdec + +@ref nrf_radio + +@ref nrf_rng + +@ref nrf_rtc + +@ref nrf_saadc + +@ref nrf_spi + +@ref nrf_spim + +@ref nrf_spis + +@ref nrf_systick + +@ref nrf_swi_egu + +@ref nrf_temp + +@ref nrf_timer + +@ref nrf_twi + +@ref nrf_twim + +@ref nrf_twis + +@ref nrf_uart + +@ref nrf_uarte + +@ref nrf_wdt + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52832.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52832.dox new file mode 100644 index 0000000..58f3bbd --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52832.dox @@ -0,0 +1,78 @@ +/** +@page nrf52832_drivers nRF52832 Drivers +@{ + +@ref nrf_aar + +@ref nrf_bprot + +@ref nrf_ccm + +@ref nrf_clock + +@ref nrf_comp + +@ref nrf_ecb + +@ref nrf_ficr + +@ref nrf_gpio + +@ref nrf_gpiote + +@ref nrf_i2s + +@ref nrf_lpcomp + +@ref nrf_mwu + +@ref nrf_nfct + +@ref nrf_nvmc + +@ref nrf_pdm + +@ref nrf_power + +@ref nrf_ppi + +@ref nrf_pwm + +@ref nrf_qdec + +@ref nrf_radio + +@ref nrf_rng + +@ref nrf_rtc + +@ref nrf_saadc + +@ref nrf_spi + +@ref nrf_spim + +@ref nrf_spis + +@ref nrf_systick + +@ref nrf_swi_egu + +@ref nrf_temp + +@ref nrf_timer + +@ref nrf_twi + +@ref nrf_twim + +@ref nrf_twis + +@ref nrf_uart + +@ref nrf_uarte + +@ref nrf_wdt + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52833.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52833.dox new file mode 100644 index 0000000..d2637d9 --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52833.dox @@ -0,0 +1,80 @@ +/** +@page nrf52833_drivers nRF52833 Drivers +@{ + +@ref nrf_aar + +@ref nrf_acl + +@ref nrf_ccm + +@ref nrf_clock + +@ref nrf_comp + +@ref nrf_ecb + +@ref nrf_ficr + +@ref nrf_gpio + +@ref nrf_gpiote + +@ref nrf_i2s + +@ref nrf_lpcomp + +@ref nrf_mwu + +@ref nrf_nfct + +@ref nrf_nvmc + +@ref nrf_pdm + +@ref nrf_power + +@ref nrf_ppi + +@ref nrf_pwm + +@ref nrf_qdec + +@ref nrf_radio + +@ref nrf_rng + +@ref nrf_rtc + +@ref nrf_saadc + +@ref nrf_spi + +@ref nrf_spim + +@ref nrf_spis + +@ref nrf_systick + +@ref nrf_swi_egu + +@ref nrf_temp + +@ref nrf_timer + +@ref nrf_twi + +@ref nrf_twim + +@ref nrf_twis + +@ref nrf_uart + +@ref nrf_uarte + +@ref nrf_usbd + +@ref nrf_wdt + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52840.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52840.dox new file mode 100644 index 0000000..7e9b51e --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf52840.dox @@ -0,0 +1,82 @@ +/** +@page nrf52840_drivers nRF52840 Drivers +@{ + +@ref nrf_aar + +@ref nrf_acl + +@ref nrf_ccm + +@ref nrf_clock + +@ref nrf_comp + +@ref nrf_ecb + +@ref nrf_ficr + +@ref nrf_gpio + +@ref nrf_gpiote + +@ref nrf_i2s + +@ref nrf_lpcomp + +@ref nrf_mwu + +@ref nrf_nfct + +@ref nrf_nvmc + +@ref nrf_pdm + +@ref nrf_power + +@ref nrf_ppi + +@ref nrf_pwm + +@ref nrf_qdec + +@ref nrf_qspi + +@ref nrf_radio + +@ref nrf_rng + +@ref nrf_rtc + +@ref nrf_saadc + +@ref nrf_spi + +@ref nrf_spim + +@ref nrf_spis + +@ref nrf_systick + +@ref nrf_swi_egu + +@ref nrf_temp + +@ref nrf_timer + +@ref nrf_twi + +@ref nrf_twim + +@ref nrf_twis + +@ref nrf_uart + +@ref nrf_uarte + +@ref nrf_usbd + +@ref nrf_wdt + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf9160.dox b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf9160.dox new file mode 100644 index 0000000..fd929ad --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrf9160.dox @@ -0,0 +1,54 @@ +/** +@page nrf9160_drivers nRF9160 drivers +@{ + +@ref nrf_clock + +@ref nrf_systick + +@ref nrf_dppi + +@ref nrf_ficr + +@ref nrf_gpio + +@ref nrf_gpiote + +@ref nrf_i2s + +@ref nrf_kmu + +@ref nrf_nvmc + +@ref nrf_pdm + +@ref nrf_power + +@ref nrf_pwm + +@ref nrf_rtc + +@ref nrf_saadc + +@ref nrf_spim + +@ref nrf_spis + +@ref nrf_spu + +@ref nrf_swi_egu + +@ref nrf_timer + +@ref nrf_twim + +@ref nrf_twis + +@ref nrf_uarte + +@ref nrf_vmc + +@ref nrf_wdt + +@} +*/ diff --git a/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrfx.doxyfile b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrfx.doxyfile new file mode 100644 index 0000000..3bf06cc --- /dev/null +++ b/src/nordic_sdk/nRF5_SDK_16.0.0_98a08e2/modules/nrfx/doc/nrfx.doxyfile @@ -0,0 +1,2505 @@ +# Doxyfile 1.8.14 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "nrfx" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +### EDIT THIS ### + +PROJECT_NUMBER = "1.8" + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +### EDIT THIS ### + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = buildfiles/nordic_small.png + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +### EDIT THIS ### + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +#ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = .. + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. + +ALIASES = "tagGreenTick=@htmlonly
      ✔
      @endhtmlonly" \ + "tagRedCross=@htmlonly
      ✖
      @endhtmlonly" \ + "linkProductSpecification52=[nRF52840 Product Specification](http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52/dita/nrf52/chips/nrf52840_ps.html) or [nRF52832 Product Specification](http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52/dita/nrf52/chips/nrf52832_ps.html)" + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 0. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +#TOC_INCLUDE_HEADINGS = 0 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +#GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +#HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +#SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = NO + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = buildfiles/layout.xml + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +#WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = warnings_nrfx.txt + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +### EDIT THIS ### + +INPUT = ../helpers \ + ../drivers \ + ../hal \ + ../soc \ + ../templates \ + config_dox \ + . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: https://www.gnu.org/software/libiconv/) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. + +FILE_PATTERNS = *.h \ + *.dox + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +#SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = NO + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: NO. + +#CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +#CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files +# were built. This is equivalent to specifying the "-p" option to a clang tool, +# such as clang-check. These options will then be passed to the parser. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: 0. + +#CLANG_COMPILATION_DATABASE_PATH = 0 + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = NO + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = buildfiles/header.html + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = buildfiles/footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = buildfiles/extra_stylesheet.css + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = buildfiles/favicon.ico + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 196 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 46 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 92 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via Javascript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have Javascript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +#HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: https://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = YES + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = com.nordic.infocenter.nrfx + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +### EDIT THIS ### + +DISABLE_INDEX = YES + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 1 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +#MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /